"use strict";var __importDefault=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.cryptoLib=void 0,exports.isSameMime=isSameMime,exports.normalizeMimeType=normalizeMimeType,exports.unescapeServerVariables=unescapeServerVariables,exports.arrayMergeStrategy=arrayMergeStrategy,exports.isEmptyObject=isEmptyObject,exports.deepClone=deepClone;const deepmerge_1=__importDefault(require("deepmerge")),theme_1=require("@redocly/theme"),utils_1=require("../utils");function isSameMime(e,r){return!(!e||!r)&&normalizeMimeType(e)===normalizeMimeType(r)}function normalizeMimeType(e){if(!e)return;const r=e.split(";")[0].toLowerCase(),[t,i]=r.split("/");if(void 0===i)return t;return`${t}/${i.split("+").pop()}`}function unescapeServerVariables(e){const r=new RegExp("%7B","g"),t=new RegExp("%7D","g");return e.replace(r,"{").replace(t,"}").replace("///","//").replace("./",".")}function arrayMergeStrategy(e,r){if(!e.length||!hasObjectOrArray(e))return r;const t=e.filter((e=>Object.keys(e).length>0));return r.forEach((function(r,i){(0,utils_1.isMergeableObject)(r)?t[i]=(0,deepmerge_1.default)(e[i],r,{arrayMerge:arrayMergeStrategy}):Array.isArray(r)?t.push(r):t[i]=r})),t}const hasObjectOrArray=e=>e.some((e=>(0,theme_1.isObject)(e)&&Object.keys(e).length>0));function isEmptyObject(e){return!!e&&0===Object.keys(e).length}function deepClone(e){if("object"!=typeof e||null===e)return e;const r=Array.isArray(e)?[]:{};for(const t in e){const i=e[t];r[t]=deepClone(i)}return r}exports.cryptoLib="undefined"!=typeof window&&(window.crypto||window.msCrypto)||void 0;
//# sourceMappingURL=utils.js.map