"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.SessionReplayLocalConfig = exports.getDefaultConfig = void 0;
var tslib_1 = require("tslib");
var analytics_core_1 = require("@amplitude/analytics-core");
var constants_1 = require("../constants");
var logger_1 = require("../logger");
var helpers_1 = require("../helpers");
var getDefaultConfig = function () { return ({
    flushMaxRetries: 2,
    logLevel: analytics_core_1.LogLevel.Warn,
    loggerProvider: new analytics_core_1.Logger(),
    transportProvider: new analytics_core_1.FetchTransport(),
}); };
exports.getDefaultConfig = getDefaultConfig;
var SessionReplayLocalConfig = /** @class */ (function (_super) {
    tslib_1.__extends(SessionReplayLocalConfig, _super);
    function SessionReplayLocalConfig(apiKey, options) {
        var _this = this;
        var _a, _b, _c, _d, _e, _f, _g;
        var defaultConfig = (0, exports.getDefaultConfig)();
        _this = _super.call(this, tslib_1.__assign(tslib_1.__assign({ transportProvider: defaultConfig.transportProvider, loggerProvider: new logger_1.SafeLoggerProvider(options.loggerProvider || defaultConfig.loggerProvider) }, options), { apiKey: apiKey })) || this;
        _this.flushMaxRetries =
            options.flushMaxRetries !== undefined && options.flushMaxRetries <= defaultConfig.flushMaxRetries
                ? options.flushMaxRetries
                : defaultConfig.flushMaxRetries;
        _this.apiKey = apiKey;
        _this.sampleRate = options.sampleRate || constants_1.DEFAULT_SAMPLE_RATE;
        _this.serverZone = options.serverZone || constants_1.DEFAULT_SERVER_ZONE;
        _this.configServerUrl = options.configServerUrl;
        _this.trackServerUrl = options.trackServerUrl;
        _this.shouldInlineStylesheet = options.shouldInlineStylesheet;
        _this.version = options.version;
        _this.performanceConfig = options.performanceConfig || constants_1.DEFAULT_PERFORMANCE_CONFIG;
        _this.storeType = (_a = options.storeType) !== null && _a !== void 0 ? _a : 'idb';
        _this.applyBackgroundColorToBlockedElements = (_b = options.applyBackgroundColorToBlockedElements) !== null && _b !== void 0 ? _b : false;
        _this.enableUrlChangePolling = (_c = options.enableUrlChangePolling) !== null && _c !== void 0 ? _c : false;
        _this.urlChangePollingInterval = (_d = options.urlChangePollingInterval) !== null && _d !== void 0 ? _d : constants_1.DEFAULT_URL_CHANGE_POLLING_INTERVAL;
        _this.captureDocumentTitle = (_e = options.captureDocumentTitle) !== null && _e !== void 0 ? _e : false;
        if (options.privacyConfig) {
            _this.privacyConfig = options.privacyConfig;
        }
        if (options.interactionConfig) {
            _this.interactionConfig = options.interactionConfig;
            // validate ugcFilterRules, throw error if invalid - throw error at the beginning of the config
            if (_this.interactionConfig.ugcFilterRules) {
                (0, helpers_1.validateUGCFilterRules)(_this.interactionConfig.ugcFilterRules);
            }
        }
        if (options.debugMode) {
            _this.debugMode = options.debugMode;
        }
        // Support both new useWebWorker and legacy experimental.useWebWorker for backwards compatibility
        if (options.useWebWorker !== undefined) {
            _this.useWebWorker = options.useWebWorker;
        }
        else {
            var legacyOptions = options;
            if (((_f = legacyOptions.experimental) === null || _f === void 0 ? void 0 : _f.useWebWorker) !== undefined) {
                _this.useWebWorker = legacyOptions.experimental.useWebWorker;
            }
        }
        if (options.omitElementTags) {
            _this.omitElementTags = options.omitElementTags;
        }
        _this.captureAdoptedStyleSheets = (_g = options.captureAdoptedStyleSheets) !== null && _g !== void 0 ? _g : true;
        if (options.crossOriginIframes) {
            _this.crossOriginIframes = options.crossOriginIframes;
        }
        return _this;
    }
    return SessionReplayLocalConfig;
}(analytics_core_1.Config));
exports.SessionReplayLocalConfig = SessionReplayLocalConfig;
//# sourceMappingURL=local-config.js.map