import { DEFAULT_MASKING_CONFIG } from './defaults';
import { isValidArray, isValidBoolean, isValidFunction } from './validators';
import { SessionRecorderSdk } from '@multiplayer-app/session-recorder-common';
const { mask, sensitiveFields, sensitiveHeaders } = SessionRecorderSdk;
export const getMaskingConfig = (masking) => {
    var _a, _b, _c, _d;
    const baseMasking = DEFAULT_MASKING_CONFIG;
    if (typeof masking !== 'object') {
        return baseMasking;
    }
    const maskHeadersList = isValidArray(masking.maskHeadersList, sensitiveHeaders);
    const maskBodyFieldsList = isValidArray(masking.maskBodyFieldsList, sensitiveFields);
    return {
        maskAllInputs: isValidBoolean(masking.maskAllInputs, (_a = baseMasking.maskAllInputs) !== null && _a !== void 0 ? _a : true),
        maskTextClass: masking.maskTextClass,
        maskTextSelector: masking.maskTextSelector,
        maskInputOptions: masking.maskInputOptions && typeof masking.maskInputOptions === 'object' ? masking.maskInputOptions : undefined,
        maskInput: isValidFunction(masking.maskInput, undefined),
        maskText: isValidFunction(masking.maskText, undefined),
        maskConsoleEvent: isValidFunction(masking.maskConsoleEvent, undefined),
        maskHeadersList,
        maskBodyFieldsList,
        headersToInclude: isValidArray(masking.headersToInclude, (_b = baseMasking.headersToInclude) !== null && _b !== void 0 ? _b : []),
        headersToExclude: isValidArray(masking.headersToExclude, (_c = baseMasking.headersToExclude) !== null && _c !== void 0 ? _c : []),
        isContentMaskingEnabled: isValidBoolean(masking.isContentMaskingEnabled, (_d = baseMasking.isContentMaskingEnabled) !== null && _d !== void 0 ? _d : true),
        maskBody: isValidFunction(masking.maskBody, mask(maskBodyFieldsList)),
        maskHeaders: isValidFunction(masking.maskHeaders, mask(maskHeadersList)),
    };
};
//# sourceMappingURL=masking.js.map