"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    var desc = Object.getOwnPropertyDescriptor(m, k);
    if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
      desc = { enumerable: true, get: function() { return m[k]; } };
    }
    Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
    Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
    o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
    if (mod && mod.__esModule) return mod;
    var result = {};
    if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
    __setModuleDefault(result, mod);
    return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.ConfigurationData = void 0;
const StitchMode_1 = require("../enums/StitchMode");
const BrowserType_1 = require("../enums/BrowserType");
const IosDeviceName_1 = require("../enums/IosDeviceName");
const ScreenOrientation_1 = require("../enums/ScreenOrientation");
const RectangleSize_1 = require("./RectangleSize");
const ImageRotation_1 = require("./ImageRotation");
const ProxySettings_1 = require("./ProxySettings");
const BatchInfo_1 = require("./BatchInfo");
const PropertyData_1 = require("./PropertyData");
const ImageMatchSettings_1 = require("./ImageMatchSettings");
const utils = __importStar(require("@applitools/utils"));
class ConfigurationData {
    _isElementReference(value) {
        var _a, _b, _c;
        const spec = (_a = this._spec) !== null && _a !== void 0 ? _a : this.constructor._spec;
        return !!((_b = spec.isElement) === null || _b === void 0 ? void 0 : _b.call(spec, value)) || !!((_c = spec.isSecondaryElement) === null || _c === void 0 ? void 0 : _c.call(spec, value)) || this._isSelectorReference(value);
    }
    _isSelectorReference(selector) {
        var _a, _b, _c, _d, _e;
        const spec = (_a = this._spec) !== null && _a !== void 0 ? _a : this.constructor._spec;
        return (!!((_b = spec.isSelector) === null || _b === void 0 ? void 0 : _b.call(spec, selector)) ||
            !!((_c = spec.isSecondarySelector) === null || _c === void 0 ? void 0 : _c.call(spec, selector)) ||
            utils.types.isString(selector) ||
            (utils.types.isPlainObject(selector) &&
                utils.types.has(selector, 'selector') &&
                (utils.types.isString(selector.selector) ||
                    !!((_d = spec.isSelector) === null || _d === void 0 ? void 0 : _d.call(spec, selector.selector)) ||
                    !!((_e = spec.isSecondarySelector) === null || _e === void 0 ? void 0 : _e.call(spec, selector.selector)))));
    }
    constructor(config, spec) {
        this._config = {};
        config = utils.types.instanceOf(config, ConfigurationData) ? config.toObject() : config !== null && config !== void 0 ? config : {};
        this._spec = spec;
        for (const [key, value] of Object.entries(config)) {
            ;
            this[key] = value;
        }
    }
    /** @undocumented */
    get debugScreenshots() {
        return this._config.debugScreenshots;
    }
    /** @undocumented */
    set debugScreenshots(debugScreenshots) {
        this._config.debugScreenshots = debugScreenshots;
    }
    /** @undocumented */
    getSaveDebugScreenshots() {
        var _a, _b;
        return (_b = (_a = this.debugScreenshots) === null || _a === void 0 ? void 0 : _a.save) !== null && _b !== void 0 ? _b : false;
    }
    /** @undocumented */
    setSaveDebugScreenshots(save) {
        this.debugScreenshots = { ...this.debugScreenshots, save };
        return this;
    }
    /** @undocumented */
    getDebugScreenshotsPath() {
        return this.debugScreenshots.path;
    }
    /** @undocumented */
    setDebugScreenshotsPath(path) {
        this.debugScreenshots = { ...this.debugScreenshots, path };
        return this;
    }
    /** @undocumented */
    getDebugScreenshotsPrefix() {
        return this.debugScreenshots.prefix;
    }
    /** @undocumented */
    setDebugScreenshotsPrefix(prefix) {
        this.debugScreenshots = { ...this.debugScreenshots, prefix };
        return this;
    }
    get appName() {
        return this._config.appName;
    }
    set appName(appName) {
        utils.guard.isString(appName, { name: 'appName', strict: false });
        this._config.appName = appName;
    }
    getAppName() {
        return this.appName;
    }
    setAppName(appName) {
        this.appName = appName;
        return this;
    }
    get testName() {
        return this._config.testName;
    }
    set testName(testName) {
        utils.guard.isString(testName, { name: 'testName', strict: false });
        this._config.testName = testName;
    }
    getTestName() {
        return this.testName;
    }
    setTestName(testName) {
        this.testName = testName;
        return this;
    }
    get displayName() {
        return this._config.displayName;
    }
    set displayName(displayName) {
        utils.guard.isString(displayName, { name: 'displayName', strict: false });
        this._config.displayName = displayName;
    }
    getDisplayName() {
        return this.displayName;
    }
    setDisplayName(displayName) {
        this.displayName = displayName;
        return this;
    }
    get isDisabled() {
        return this._config.isDisabled;
    }
    set isDisabled(isDisabled) {
        utils.guard.isBoolean(isDisabled, { name: 'isDisabled', strict: false });
        this._config.isDisabled = isDisabled;
    }
    getIsDisabled() {
        return this.isDisabled;
    }
    setIsDisabled(isDisabled) {
        this.isDisabled = isDisabled;
        return this;
    }
    get matchTimeout() {
        return this._config.matchTimeout;
    }
    set matchTimeout(matchTimeout) {
        utils.guard.isInteger(matchTimeout, { name: 'matchTimeout' });
        this._config.matchTimeout = matchTimeout;
    }
    getMatchTimeout() {
        return this.matchTimeout;
    }
    setMatchTimeout(matchTimeout) {
        this.matchTimeout = matchTimeout;
        return this;
    }
    get sessionType() {
        return this._config.sessionType;
    }
    set sessionType(sessionType) {
        this._config.sessionType = sessionType;
    }
    getSessionType() {
        return this.sessionType;
    }
    setSessionType(sessionType) {
        this.sessionType = sessionType;
        return this;
    }
    get viewportSize() {
        return this._config.viewportSize;
    }
    set viewportSize(viewportSize) {
        this._config.viewportSize = viewportSize;
    }
    getViewportSize() {
        return this.viewportSize && new RectangleSize_1.RectangleSizeData(this.viewportSize);
    }
    setViewportSize(viewportSize) {
        this.viewportSize = viewportSize;
        return this;
    }
    get agentId() {
        return this._config.agentId;
    }
    set agentId(agentId) {
        utils.guard.isString(agentId, { name: 'agentId' });
        this._config.agentId = agentId;
    }
    getAgentId() {
        return this.agentId;
    }
    setAgentId(agentId) {
        this.agentId = agentId;
        return this;
    }
    get apiKey() {
        return this._config.apiKey;
    }
    set apiKey(apiKey) {
        utils.guard.isString(apiKey, { name: 'apiKey', alpha: true, numeric: true });
        this._config.apiKey = apiKey;
    }
    getApiKey() {
        var _a;
        return (_a = this.apiKey) !== null && _a !== void 0 ? _a : utils.general.getEnvValue('API_KEY');
    }
    setApiKey(apiKey) {
        this.apiKey = apiKey;
        return this;
    }
    get serverUrl() {
        return this._config.serverUrl;
    }
    set serverUrl(serverUrl) {
        utils.guard.isString(serverUrl, { name: 'serverUrl', strict: false });
        this._config.serverUrl = serverUrl;
    }
    getServerUrl() {
        var _a;
        return (_a = this.serverUrl) !== null && _a !== void 0 ? _a : utils.general.getEnvValue('SERVER_URL');
    }
    setServerUrl(serverUrl) {
        this.serverUrl = serverUrl;
        return this;
    }
    get proxy() {
        return this._config.proxy;
    }
    set proxy(proxy) {
        this._config.proxy = proxy;
    }
    getProxy() {
        return new ProxySettings_1.ProxySettingsData(this.proxy);
    }
    setProxy(proxyOrUrlOrIsEnabled, username, password) {
        if (proxyOrUrlOrIsEnabled === false) {
            this.proxy = undefined;
        }
        else if (utils.types.isString(proxyOrUrlOrIsEnabled)) {
            this.proxy = { url: proxyOrUrlOrIsEnabled, username, password };
        }
        else {
            this.proxy = proxyOrUrlOrIsEnabled;
        }
        return this;
    }
    get autProxy() {
        return this._config.autProxy;
    }
    set autProxy(autProxy) {
        this._config.autProxy = autProxy;
    }
    getAutProxy() {
        return this.autProxy;
    }
    setAutProxy(autProxy) {
        this.autProxy = autProxy;
        return this;
    }
    /** @undocumented */
    get connectionTimeout() {
        return this._config.connectionTimeout;
    }
    /** @undocumented */
    set connectionTimeout(connectionTimeout) {
        utils.guard.isInteger(connectionTimeout, { name: 'connectionTimeout', gte: 0 });
        this._config.connectionTimeout = connectionTimeout;
    }
    /** @undocumented */
    getConnectionTimeout() {
        return this.connectionTimeout;
    }
    /** @undocumented */
    setConnectionTimeout(connectionTimeout) {
        this.connectionTimeout = connectionTimeout;
        return this;
    }
    /** @undocumented */
    get removeSession() {
        return this._config.removeSession;
    }
    /** @undocumented */
    set removeSession(removeSession) {
        utils.guard.isBoolean(removeSession, { name: 'removeSession' });
        this._config.removeSession = removeSession;
    }
    /** @undocumented */
    getRemoveSession() {
        return this.removeSession;
    }
    /** @undocumented */
    setRemoveSession(removeSession) {
        this.removeSession = removeSession;
        return this;
    }
    get batch() {
        return this._config.batch;
    }
    set batch(batch) {
        this._config.batch = batch;
    }
    getBatch() {
        return new BatchInfo_1.BatchInfoData(this.batch);
    }
    setBatch(batch) {
        this.batch = batch;
        return this;
    }
    get properties() {
        return this._config.properties;
    }
    set properties(properties) {
        utils.guard.isArray(properties, { name: 'properties' });
        this._config.properties = properties;
    }
    getProperties() {
        var _a, _b;
        return (_b = (_a = this.properties) === null || _a === void 0 ? void 0 : _a.map(property => new PropertyData_1.PropertyDataData(property))) !== null && _b !== void 0 ? _b : [];
    }
    setProperties(properties) {
        this.properties = properties;
        return this;
    }
    addProperty(propOrName, value) {
        const property = utils.types.isString(propOrName) ? { name: propOrName, value: value } : propOrName;
        if (!this.properties)
            this.properties = [];
        this.properties.push(property);
        return this;
    }
    clearProperties() {
        this.properties = [];
        return this;
    }
    get baselineEnvName() {
        return this._config.baselineEnvName;
    }
    set baselineEnvName(baselineEnvName) {
        utils.guard.isString(baselineEnvName, { name: 'baselineEnvName', strict: false });
        this._config.baselineEnvName = baselineEnvName ? baselineEnvName.trim() : undefined;
    }
    getBaselineEnvName() {
        return this.baselineEnvName;
    }
    setBaselineEnvName(baselineEnvName) {
        this.baselineEnvName = baselineEnvName;
        return this;
    }
    get environmentName() {
        return this._config.environmentName;
    }
    set environmentName(environmentName) {
        utils.guard.isString(environmentName, { name: 'environmentName', strict: false });
        this._config.environmentName = environmentName ? environmentName.trim() : undefined;
    }
    getEnvironmentName() {
        return this.environmentName;
    }
    setEnvironmentName(environmentName) {
        this.environmentName = environmentName;
        return this;
    }
    get branchName() {
        return this._config.branchName;
    }
    set branchName(branchName) {
        utils.guard.isString(branchName, { name: 'branchName' });
        this._config.branchName = branchName;
    }
    getBranchName() {
        var _a;
        return (_a = this.branchName) !== null && _a !== void 0 ? _a : utils.general.getEnvValue('BRANCH');
    }
    setBranchName(branchName) {
        this.branchName = branchName;
        return this;
    }
    get parentBranchName() {
        return this._config.parentBranchName;
    }
    set parentBranchName(parentBranchName) {
        utils.guard.isString(parentBranchName, { name: 'parentBranchName' });
        this._config.parentBranchName = parentBranchName;
    }
    getParentBranchName() {
        var _a;
        return (_a = this.parentBranchName) !== null && _a !== void 0 ? _a : utils.general.getEnvValue('PARENT_BRANCH');
    }
    setParentBranchName(parentBranchName) {
        this.parentBranchName = parentBranchName;
        return this;
    }
    get baselineBranchName() {
        return this._config.baselineBranchName;
    }
    set baselineBranchName(baselineBranchName) {
        utils.guard.isString(baselineBranchName, { name: 'baselineBranchName' });
        this._config.baselineBranchName = baselineBranchName;
    }
    getBaselineBranchName() {
        var _a;
        return (_a = this.baselineBranchName) !== null && _a !== void 0 ? _a : utils.general.getEnvValue('BASELINE_BRANCH_NAME');
    }
    setBaselineBranchName(baselineBranchName) {
        this.baselineBranchName = baselineBranchName;
        return this;
    }
    get gitMergeBaseTimestamp() {
        return this._config.gitMergeBaseTimestamp;
    }
    set gitMergeBaseTimestamp(gitMergeBaseTimestamp) {
        utils.guard.isString(gitMergeBaseTimestamp, { name: 'gitMergeBaseTimestamp' });
        this._config.gitMergeBaseTimestamp = gitMergeBaseTimestamp;
    }
    getGitMergeBaseTimestamp() {
        return this.gitMergeBaseTimestamp;
    }
    setGitMergeBaseTimestamp(gitMergeBaseTimestamp) {
        this.gitMergeBaseTimestamp = gitMergeBaseTimestamp;
        return this;
    }
    get compareWithParentBranch() {
        return this._config.compareWithParentBranch;
    }
    set compareWithParentBranch(compareWithParentBranch) {
        utils.guard.isBoolean(compareWithParentBranch, { name: 'compareWithParentBranch' });
        this._config.compareWithParentBranch = compareWithParentBranch;
    }
    getCompareWithParentBranch() {
        return this.compareWithParentBranch;
    }
    setCompareWithParentBranch(compareWithParentBranch) {
        this.compareWithParentBranch = compareWithParentBranch;
        return this;
    }
    get ignoreGitMergeBase() {
        return this._config.ignoreGitMergeBase;
    }
    set ignoreGitMergeBase(ignoreGitMergeBase) {
        utils.guard.isBoolean(ignoreGitMergeBase, { name: 'ignoreGitMergeBase' });
        this._config.ignoreGitMergeBase = ignoreGitMergeBase;
    }
    getIgnoreGitMergeBase() {
        return this.ignoreGitMergeBase;
    }
    setIgnoreGitMergeBase(ignoreGitMergeBase) {
        this.ignoreGitMergeBase = ignoreGitMergeBase;
        return this;
    }
    get ignoreBaseline() {
        return this._config.ignoreBaseline;
    }
    set ignoreBaseline(ignoreBaseline) {
        utils.guard.isBoolean(ignoreBaseline, { name: 'ignoreBaseline' });
        this._config.ignoreBaseline = ignoreBaseline;
    }
    getIgnoreBaseline() {
        return this.ignoreBaseline;
    }
    setIgnoreBaseline(ignoreBaseline) {
        this.ignoreBaseline = ignoreBaseline;
        return this;
    }
    get saveFailedTests() {
        return this._config.saveFailedTests;
    }
    set saveFailedTests(saveFailedTests) {
        utils.guard.isBoolean(saveFailedTests, { name: 'saveFailedTests' });
        this._config.saveFailedTests = saveFailedTests;
    }
    getSaveFailedTests() {
        return this.saveFailedTests;
    }
    setSaveFailedTests(saveFailedTests) {
        this.saveFailedTests = saveFailedTests;
        return this;
    }
    get saveNewTests() {
        return this._config.saveNewTests;
    }
    set saveNewTests(saveNewTests) {
        utils.guard.isBoolean(saveNewTests, { name: 'saveNewTests' });
        this._config.saveNewTests = saveNewTests;
    }
    getSaveNewTests() {
        return this.saveNewTests;
    }
    setSaveNewTests(saveNewTests) {
        this.saveNewTests = saveNewTests;
        return this;
    }
    get saveDiffs() {
        return this._config.saveDiffs;
    }
    set saveDiffs(saveDiffs) {
        utils.guard.isBoolean(saveDiffs, { name: 'saveDiffs' });
        this._config.saveDiffs = saveDiffs;
    }
    getSaveDiffs() {
        return this.saveDiffs;
    }
    setSaveDiffs(saveDiffs) {
        this.saveDiffs = saveDiffs;
        return this;
    }
    get sendDom() {
        return this._config.sendDom;
    }
    set sendDom(sendDom) {
        utils.guard.isBoolean(sendDom, { name: 'sendDom' });
        this._config.sendDom = sendDom;
    }
    getSendDom() {
        return this.sendDom;
    }
    setSendDom(sendDom) {
        this.sendDom = sendDom;
        return this;
    }
    get hostApp() {
        return this._config.hostApp;
    }
    set hostApp(hostApp) {
        this._config.hostApp = hostApp ? hostApp.trim() : undefined;
    }
    getHostApp() {
        return this.hostApp;
    }
    setHostApp(hostApp) {
        this.hostApp = hostApp;
        return this;
    }
    get hostOS() {
        return this._config.hostOS;
    }
    set hostOS(hostOS) {
        this._config.hostOS = hostOS ? hostOS.trim() : undefined;
    }
    getHostOS() {
        return this.hostOS;
    }
    setHostOS(hostOS) {
        this.hostOS = hostOS;
        return this;
    }
    get hostAppInfo() {
        return this._config.hostAppInfo;
    }
    set hostAppInfo(hostAppInfo) {
        this._config.hostAppInfo = hostAppInfo ? hostAppInfo.trim() : undefined;
    }
    getHostAppInfo() {
        return this.hostAppInfo;
    }
    setHostAppInfo(hostAppInfo) {
        this.hostAppInfo = hostAppInfo;
        return this;
    }
    get hostOSInfo() {
        return this._config.hostOSInfo;
    }
    set hostOSInfo(hostOSInfo) {
        this._config.hostOSInfo = hostOSInfo ? hostOSInfo.trim() : undefined;
    }
    getHostOSInfo() {
        return this.hostOSInfo;
    }
    setHostOSInfo(hostOSInfo) {
        this.hostOSInfo = hostOSInfo;
        return this;
    }
    get deviceInfo() {
        return this._config.deviceInfo;
    }
    set deviceInfo(deviceInfo) {
        this._config.deviceInfo = deviceInfo ? deviceInfo.trim() : undefined;
    }
    getDeviceInfo() {
        return this.deviceInfo;
    }
    setDeviceInfo(deviceInfo) {
        this.deviceInfo = deviceInfo;
        return this;
    }
    get defaultMatchSettings() {
        return this._config.defaultMatchSettings;
    }
    set defaultMatchSettings(defaultMatchSettings) {
        utils.guard.notNull(defaultMatchSettings, { name: 'defaultMatchSettings' });
        this._config.defaultMatchSettings = defaultMatchSettings;
    }
    getDefaultMatchSettings() {
        return new ImageMatchSettings_1.ImageMatchSettingsData(this.defaultMatchSettings);
    }
    setDefaultMatchSettings(defaultMatchSettings) {
        this.defaultMatchSettings = defaultMatchSettings;
        return this;
    }
    getMatchLevel() {
        var _a;
        return (_a = this.defaultMatchSettings) === null || _a === void 0 ? void 0 : _a.matchLevel;
    }
    setMatchLevel(matchLevel) {
        if (!this.defaultMatchSettings)
            this.defaultMatchSettings = {};
        this.defaultMatchSettings.matchLevel = matchLevel;
        return this;
    }
    getAccessibilityValidation() {
        return this.defaultMatchSettings.accessibilitySettings;
    }
    setAccessibilityValidation(accessibilityValidation) {
        if (!this.defaultMatchSettings)
            this.defaultMatchSettings = {};
        this.defaultMatchSettings.accessibilitySettings = accessibilityValidation;
        return this;
    }
    getUseDom() {
        return this.defaultMatchSettings.useDom;
    }
    setUseDom(useDom) {
        if (!this.defaultMatchSettings)
            this.defaultMatchSettings = {};
        this.defaultMatchSettings.useDom = useDom;
        return this;
    }
    getEnablePatterns() {
        return this.defaultMatchSettings.enablePatterns;
    }
    setEnablePatterns(enablePatterns) {
        if (!this.defaultMatchSettings)
            this.defaultMatchSettings = {};
        this.defaultMatchSettings.enablePatterns = enablePatterns;
        return this;
    }
    getIgnoreDisplacements() {
        return this.defaultMatchSettings.ignoreDisplacements;
    }
    setIgnoreDisplacements(ignoreDisplacements) {
        if (!this.defaultMatchSettings)
            this.defaultMatchSettings = {};
        this.defaultMatchSettings.ignoreDisplacements = ignoreDisplacements;
        return this;
    }
    getIgnoreCaret() {
        return this.defaultMatchSettings.ignoreCaret;
    }
    setIgnoreCaret(ignoreCaret) {
        if (!this.defaultMatchSettings)
            this.defaultMatchSettings = {};
        this.defaultMatchSettings.ignoreCaret = ignoreCaret;
        return this;
    }
    get forceFullPageScreenshot() {
        return this._config.forceFullPageScreenshot;
    }
    set forceFullPageScreenshot(forceFullPageScreenshot) {
        this._config.forceFullPageScreenshot = forceFullPageScreenshot;
    }
    getForceFullPageScreenshot() {
        return this.forceFullPageScreenshot;
    }
    setForceFullPageScreenshot(forceFullPageScreenshot) {
        this.forceFullPageScreenshot = forceFullPageScreenshot;
        return this;
    }
    get waitBeforeScreenshots() {
        return this._config.waitBeforeScreenshots;
    }
    set waitBeforeScreenshots(waitBeforeScreenshots) {
        utils.guard.isInteger(waitBeforeScreenshots, { name: 'waitBeforeScreenshots', gt: 0 });
        this._config.waitBeforeScreenshots = waitBeforeScreenshots;
    }
    getWaitBeforeScreenshots() {
        return this.waitBeforeScreenshots;
    }
    setWaitBeforeScreenshots(waitBeforeScreenshots) {
        this.waitBeforeScreenshots = waitBeforeScreenshots;
        return this;
    }
    get waitBeforeCapture() {
        return this._config.waitBeforeCapture;
    }
    set waitBeforeCapture(waitBeforeCapture) {
        utils.guard.isInteger(waitBeforeCapture, { name: 'waitBeforeCapture', gt: 0 });
        this._config.waitBeforeCapture = waitBeforeCapture;
    }
    getWaitBeforeCapture() {
        return this.waitBeforeCapture;
    }
    setWaitBeforeCapture(waitBeforeCapture) {
        this.waitBeforeCapture = waitBeforeCapture;
        return this;
    }
    get stitchMode() {
        return this._config.stitchMode;
    }
    set stitchMode(stitchMode) {
        utils.guard.isEnumValue(stitchMode, StitchMode_1.StitchModeEnum, { name: 'stitchMode' });
        this._config.stitchMode = stitchMode;
    }
    getStitchMode() {
        return this.stitchMode;
    }
    setStitchMode(stitchMode) {
        this.stitchMode = stitchMode;
        return this;
    }
    get hideScrollbars() {
        return this._config.hideScrollbars;
    }
    set hideScrollbars(hideScrollbars) {
        this._config.hideScrollbars = hideScrollbars;
    }
    getHideScrollbars() {
        return this.hideScrollbars;
    }
    setHideScrollbars(hideScrollbars) {
        this.hideScrollbars = hideScrollbars;
        return this;
    }
    get hideCaret() {
        return this._config.hideCaret;
    }
    set hideCaret(hideCaret) {
        this._config.hideCaret = hideCaret;
    }
    getHideCaret() {
        return this.hideCaret;
    }
    setHideCaret(hideCaret) {
        this.hideCaret = hideCaret;
        return this;
    }
    get stitchOverlap() {
        return this._config.stitchOverlap;
    }
    set stitchOverlap(stitchOverlap) {
        utils.guard.isInteger(stitchOverlap, { name: 'stitchOverlap', strict: false });
        this._config.stitchOverlap = stitchOverlap;
    }
    getStitchOverlap() {
        return this.stitchOverlap;
    }
    setStitchOverlap(stitchOverlap) {
        this.stitchOverlap = stitchOverlap;
        return this;
    }
    get scrollRootElement() {
        return this._config.scrollRootElement;
    }
    set scrollRootElement(scrollRootElement) {
        utils.guard.custom(scrollRootElement, value => this._isElementReference(value), {
            name: 'scrollRootElement',
            message: 'must be element or selector',
            strict: false,
        });
        this._config.scrollRootElement = scrollRootElement;
    }
    getScrollRootElement() {
        return this.scrollRootElement;
    }
    setScrollRootElement(scrollRootElement) {
        this.scrollRootElement = scrollRootElement;
        return this;
    }
    get cut() {
        return this._config.cut;
    }
    set cut(cut) {
        this._config.cut = cut;
    }
    getCut() {
        return this._config.cut;
    }
    setCut(cut) {
        this.cut = cut;
        return this;
    }
    get rotation() {
        return this._config.rotation;
    }
    set rotation(rotation) {
        this._config.rotation = rotation;
    }
    getRotation() {
        return new ImageRotation_1.ImageRotationData(this.rotation);
    }
    setRotation(rotation) {
        this.rotation = utils.types.isNumber(rotation) ? rotation : rotation.rotation;
        return this;
    }
    get scaleRatio() {
        return this._config.scaleRatio;
    }
    set scaleRatio(scaleRatio) {
        utils.guard.isNumber(scaleRatio, { name: 'scaleRatio', strict: false });
        this._config.scaleRatio = scaleRatio;
    }
    getScaleRatio() {
        return this.scaleRatio;
    }
    setScaleRatio(scaleRatio) {
        this.scaleRatio = scaleRatio;
        return this;
    }
    /** @undocumented */
    get concurrentSessions() {
        return this._config.concurrentSessions;
    }
    /** @undocumented */
    set concurrentSessions(concurrentSessions) {
        this._config.concurrentSessions = concurrentSessions;
    }
    /** @undocumented */
    getConcurrentSessions() {
        return this.concurrentSessions;
    }
    /** @undocumented */
    setConcurrentSessions(concurrentSessions) {
        this.concurrentSessions = concurrentSessions;
        return this;
    }
    get browsersInfo() {
        return this._config.browsersInfo;
    }
    set browsersInfo(browsersInfo) {
        utils.guard.isArray(browsersInfo, { name: 'browsersInfo' });
        this._config.browsersInfo = browsersInfo;
    }
    getBrowsersInfo() {
        return this.browsersInfo;
    }
    setBrowsersInfo(browsersInfo) {
        this.browsersInfo = browsersInfo.map(browserInfo => utils.types.has(browserInfo, 'deviceName') ? { chromeEmulationInfo: browserInfo } : browserInfo);
        return this;
    }
    addBrowsers(...browsersInfo) {
        for (const [index, browserInfo] of browsersInfo.entries()) {
            utils.guard.isObject(browserInfo, { name: `addBrowsers( arg${index} )` });
        }
        if (!this.browsersInfo)
            this.browsersInfo = [];
        this.browsersInfo.push(...browsersInfo.map(browserInfo => utils.types.has(browserInfo, 'deviceName') ? { chromeEmulationInfo: browserInfo } : browserInfo));
        return this;
    }
    addBrowser(browserInfoOrWidth, height, name = BrowserType_1.BrowserTypeEnum.CHROME) {
        if (utils.types.isObject(browserInfoOrWidth))
            return this.addBrowsers(browserInfoOrWidth);
        else
            return this.addBrowsers({ width: browserInfoOrWidth, height: height, name });
    }
    addDeviceEmulation(deviceName, screenOrientation = ScreenOrientation_1.ScreenOrientationEnum.PORTRAIT) {
        if (!this.browsersInfo)
            this.browsersInfo = [];
        this.browsersInfo.push({ chromeEmulationInfo: { deviceName, screenOrientation } });
        return this;
    }
    addMobileDevice(deviceName, screenOrientation, version) {
        if (!this.browsersInfo)
            this.browsersInfo = [];
        if (utils.types.isEnumValue(deviceName, IosDeviceName_1.IosDeviceNameEnum)) {
            this.browsersInfo.push({
                iosDeviceInfo: {
                    deviceName: deviceName,
                    screenOrientation,
                    iosVersion: version,
                },
            });
        }
        else {
            this.browsersInfo.push({
                androidDeviceInfo: {
                    deviceName: deviceName,
                    screenOrientation,
                    version: version,
                },
            });
        }
        return this;
    }
    addMultiDeviceTarget(deviceName) {
        if (!this.browsersInfo)
            this.browsersInfo = [];
        this.browsersInfo.push({ iosDeviceInfo: { deviceName } });
        return this;
    }
    get visualGridOptions() {
        return this._config.visualGridOptions;
    }
    set visualGridOptions(visualGridOptions) {
        this._config.visualGridOptions = visualGridOptions;
    }
    getVisualGridOptions() {
        return this.visualGridOptions;
    }
    setVisualGridOptions(visualGridOptions) {
        this.visualGridOptions = visualGridOptions;
        return this;
    }
    setVisualGridOption(key, value) {
        if (!this.visualGridOptions)
            this.visualGridOptions = {};
        this.visualGridOptions[key] = value;
        return this;
    }
    get layoutBreakpoints() {
        return this._config.layoutBreakpoints;
    }
    set layoutBreakpoints(layoutBreakpoints) {
        utils.guard.notNull(layoutBreakpoints, { name: 'layoutBreakpoints' });
        if (utils.types.isArray(layoutBreakpoints)) {
            this._config.layoutBreakpoints = layoutBreakpoints.length > 0 ? layoutBreakpoints : false;
        }
        else {
            this._config.layoutBreakpoints = layoutBreakpoints;
        }
    }
    getLayoutBreakpoints() {
        return this.layoutBreakpoints;
    }
    setLayoutBreakpoints(layoutBreakpoints) {
        this.layoutBreakpoints = layoutBreakpoints;
        return this;
    }
    get disableBrowserFetching() {
        return this._config.disableBrowserFetching;
    }
    set disableBrowserFetching(disableBrowserFetching) {
        this._config.disableBrowserFetching = disableBrowserFetching;
    }
    getDisableBrowserFetching() {
        return this.disableBrowserFetching;
    }
    setDisableBrowserFetching(disableBrowserFetching) {
        this.disableBrowserFetching = disableBrowserFetching;
        return this;
    }
    /** @undocumented */
    get dontCloseBatches() {
        return this._config.dontCloseBatches;
    }
    /** @undocumented */
    set dontCloseBatches(dontCloseBatches) {
        this._config.dontCloseBatches = dontCloseBatches;
    }
    /** @undocumented */
    getDontCloseBatches() {
        var _a;
        return (_a = this.dontCloseBatches) !== null && _a !== void 0 ? _a : utils.general.getEnvValue('DONT_CLOSE_BATCHES', 'boolean');
    }
    /** @undocumented */
    setDontCloseBatches(dontCloseBatches) {
        this.dontCloseBatches = dontCloseBatches;
        return this;
    }
    /** @internal */
    toObject() {
        return this._config;
    }
    /** @internal */
    toJSON() {
        var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
        return utils.general.toJSON({
            open: utils.general.removeUndefinedProps({
                eyesServerUrl: this.serverUrl,
                apiKey: this.apiKey,
                agentId: this.agentId,
                proxy: this.proxy,
                connectionTimeout: this.connectionTimeout,
                removeSession: this.removeSession,
                appName: this.appName,
                testName: this.testName,
                displayName: this.displayName,
                sessionType: this.sessionType,
                properties: this.properties,
                batch: this.batch,
                baselineEnvName: this.baselineEnvName,
                environmentName: this.environmentName,
                environment: utils.general.removeUndefinedProps({
                    hostingApp: this.hostApp,
                    displayHostingApp: this.hostAppInfo,
                    os: this.hostOS,
                    displayOs: this.hostOSInfo,
                    deviceName: this.deviceInfo,
                    viewportSize: this.viewportSize,
                }),
                branchName: this.branchName,
                parentBranchName: this.parentBranchName,
                baselineBranchName: this.baselineBranchName,
                compareWithParentBranch: this.compareWithParentBranch,
                ignoreBaseline: this.ignoreBaseline,
                gitBranchingTimestamp: this.gitMergeBaseTimestamp,
                ignoreGitBranching: this.ignoreGitMergeBase,
                saveDiffs: this.saveDiffs,
                keepBatchOpen: this.dontCloseBatches,
            }),
            screenshot: utils.general.removeUndefinedProps({
                fully: this.forceFullPageScreenshot,
                scrollRootElement: this.scrollRootElement,
                stitchMode: this.stitchMode,
                hideScrollbars: this.hideScrollbars,
                hideCaret: this.hideCaret,
                overlap: !utils.types.isNull(this.stitchOverlap) ? { bottom: this.stitchOverlap } : undefined,
                waitBetweenStitches: this.waitBeforeScreenshots,
                waitBeforeCapture: this.waitBeforeCapture,
                normalization: utils.general.removeUndefinedProps({
                    cut: this.cut,
                    rotation: this.rotation,
                    scaleRatio: this.scaleRatio,
                }),
                debugImages: ((_a = this.debugScreenshots) === null || _a === void 0 ? void 0 : _a.save) && utils.types.has(this.debugScreenshots, 'path')
                    ? this.debugScreenshots
                    : undefined,
            }),
            check: utils.general.removeUndefinedProps({
                environments: (_b = this.browsersInfo) === null || _b === void 0 ? void 0 : _b.map(browserInfo => {
                    if (utils.types.has(browserInfo, 'iosDeviceInfo')) {
                        const { iosVersion, ...iosDeviceInfo } = browserInfo.iosDeviceInfo;
                        return { iosDeviceInfo: { ...iosDeviceInfo, version: iosVersion } };
                    }
                    return browserInfo;
                }),
                ufgOptions: this.visualGridOptions,
                layoutBreakpoints: utils.types.isDefined(this.layoutBreakpoints)
                    ? utils.types.has(this.layoutBreakpoints, 'breakpoints')
                        ? this.layoutBreakpoints
                        : { breakpoints: (_c = this.layoutBreakpoints) !== null && _c !== void 0 ? _c : false }
                    : undefined,
                disableBrowserFetching: this.disableBrowserFetching,
                autProxy: this.autProxy,
                sendDom: this.sendDom,
                retryTimeout: this.matchTimeout,
                matchLevel: (_d = this.defaultMatchSettings) === null || _d === void 0 ? void 0 : _d.matchLevel,
                ignoreCaret: (_e = this.defaultMatchSettings) === null || _e === void 0 ? void 0 : _e.ignoreCaret,
                ignoreDisplacements: (_f = this.defaultMatchSettings) === null || _f === void 0 ? void 0 : _f.ignoreDisplacements,
                enablePatterns: (_g = this.defaultMatchSettings) === null || _g === void 0 ? void 0 : _g.enablePatterns,
                accessibilitySettings: ((_h = this.defaultMatchSettings) === null || _h === void 0 ? void 0 : _h.accessibilitySettings) && {
                    level: this.defaultMatchSettings.accessibilitySettings.level,
                    version: this.defaultMatchSettings.accessibilitySettings.guidelinesVersion,
                },
                useDom: (_j = this.defaultMatchSettings) === null || _j === void 0 ? void 0 : _j.useDom,
                ignoreRegions: (_k = this.defaultMatchSettings) === null || _k === void 0 ? void 0 : _k.ignoreRegions,
                contentRegions: (_l = this.defaultMatchSettings) === null || _l === void 0 ? void 0 : _l.contentRegions,
                layoutRegions: (_m = this.defaultMatchSettings) === null || _m === void 0 ? void 0 : _m.layoutRegions,
                strictRegions: (_o = this.defaultMatchSettings) === null || _o === void 0 ? void 0 : _o.strictRegions,
                floatingRegions: (_p = this.defaultMatchSettings) === null || _p === void 0 ? void 0 : _p.floatingRegions,
                accessibilityRegions: (_q = this.defaultMatchSettings) === null || _q === void 0 ? void 0 : _q.accessibilityRegions,
            }),
            close: utils.general.removeUndefinedProps({
                updateBaselineIfDifferent: this.saveFailedTests,
                updateBaselineIfNew: this.saveNewTests,
            }),
        });
    }
    /** @internal */
    toString() {
        return utils.general.toString(this);
    }
}
exports.ConfigurationData = ConfigurationData;
