// Metro module 535 (f536). import * as _Module536 from "./Module536"; import { decode, isRegExp, maybeMap, merge, compact } from "./Module536"; let parseArrayValue, parseQueryStringKeys; const hasOwnProperty = Object.prototype.hasOwnProperty; const isArray = Array.isArray; let c508_4 = { allowDots: false, allowEmptyArrays: false, allowPrototypes: false, allowSparse: false, arrayLimit: 20, charset: "utf-8", charsetSentinel: false, comma: false, decodeDotInKeys: false, decoder: decode, delimiter: "&", depth: 5, duplicates: "combine", ignoreQueryPrefix: false, interpretNumericEntities: false, parameterLimit: 1000, parseArrays: true, plainObjects: false, strictDepth: false, strictNullHandling: false, throwOnLimitExceeded: false }; const interpretNumericEntities = function interpretNumericEntities(a0) {}; parseArrayValue = function parseArrayValue(a0, a1, a2) {}; parseQueryStringKeys = function parseQueryStringKeys(a0, a1, a2, a3) {}; module.exports = function(a0, a1) { let r4, r13, r219, r234, r235, r306, r385, r427, r443, depth2, length, length2, length3; if (a1) { if (a1.allowEmptyArrays !== void 0 && typeof a1.allowEmptyArrays !== "boolean") { throw new TypeError("`allowEmptyArrays` option can only be `true` or `false`, when provided"); } if (a1.decodeDotInKeys !== void 0 && typeof a1.decodeDotInKeys !== "boolean") { throw new TypeError("`decodeDotInKeys` option can only be `true` or `false`, when provided"); } if (a1.decoder !== null && a1.decoder !== void 0 && typeof a1.decoder !== "function") { throw new TypeError("Decoder has to be a function."); } if (a1.charset !== void 0 && a1.charset !== "utf-8" && a1.charset !== "iso-8859-1") { throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined"); } if (a1.throwOnLimitExceeded !== void 0 && typeof a1.throwOnLimitExceeded !== "boolean") { throw new TypeError("`throwOnLimitExceeded` option must be a boolean"); } const charset3 = a1.charset === void 0 ? c508_4.charset : a1.charset; const duplicates = a1.duplicates === void 0 ? c508_4.duplicates : a1.duplicates; if (duplicates !== "combine" && duplicates !== "first" && duplicates !== "last") { throw new TypeError("The duplicates option must be either combine, first, or last"); } const allowDots = a1.allowDots === void 0 ? a1.decodeDotInKeys === true || c508_4.allowDots : !!a1.allowDots; const allowEmptyArrays = typeof a1.allowEmptyArrays === "boolean" ? !!a1.allowEmptyArrays : c508_4.allowEmptyArrays; const allowPrototypes3 = typeof a1.allowPrototypes === "boolean" ? a1.allowPrototypes : c508_4.allowPrototypes; const allowSparse = typeof a1.allowSparse === "boolean" ? a1.allowSparse : c508_4.allowSparse; const arrayLimit3 = typeof a1.arrayLimit === "number" ? a1.arrayLimit : c508_4.arrayLimit; const charsetSentinel2 = typeof a1.charsetSentinel === "boolean" ? a1.charsetSentinel : c508_4.charsetSentinel; const comma = typeof a1.comma === "boolean" ? a1.comma : c508_4.comma; const decodeDotInKeys = typeof a1.decodeDotInKeys === "boolean" ? a1.decodeDotInKeys : c508_4.decodeDotInKeys; const decoder = typeof a1.decoder === "function" ? a1.decoder : c508_4.decoder; const delimiter = typeof a1.delimiter !== "string" && !isRegExp(a1.delimiter) ? c508_4.delimiter : a1.delimiter; const depth3 = typeof a1.depth !== "number" && a1.depth !== false ? c508_4.depth : +a1.depth; const interpretNumericEntities2 = typeof a1.interpretNumericEntities === "boolean" ? a1.interpretNumericEntities : c508_4.interpretNumericEntities; const parameterLimit = typeof a1.parameterLimit === "number" ? a1.parameterLimit : c508_4.parameterLimit; const plainObjects2 = typeof a1.plainObjects === "boolean" ? a1.plainObjects : c508_4.plainObjects; const strictDepth = typeof a1.strictDepth === "boolean" ? !!a1.strictDepth : c508_4.strictDepth; const strictNullHandling = typeof a1.strictNullHandling === "boolean" ? a1.strictNullHandling : c508_4.strictNullHandling; const throwOnLimitExceeded = a1.throwOnLimitExceeded; r13 = { allowDots, allowEmptyArrays, allowPrototypes: allowPrototypes3, allowSparse, arrayLimit: arrayLimit3, charset: charset3, charsetSentinel: charsetSentinel2, comma, decodeDotInKeys, decoder, delimiter, depth: depth3, duplicates, ignoreQueryPrefix: a1.ignoreQueryPrefix === true, interpretNumericEntities: interpretNumericEntities2, parameterLimit, parseArrays: a1.parseArrays !== false, plainObjects: plainObjects2, strictDepth, strictNullHandling, throwOnLimitExceeded: typeof throwOnLimitExceeded === "boolean" ? a1.throwOnLimitExceeded : typeof throwOnLimitExceeded === "boolean" }; } else { r13 = c508_4; } if (a0 !== "" && a0 != null) { let r29 = a0; if (typeof a0 === "string") { let c12360_0 = r13; const r155 = (r13.ignoreQueryPrefix ? a0.replace(/^\?/, "") : a0).replace(/%5B/gi, "[").replace(/%5D/gi, "]"); const r158 = r13.parameterLimit !== Infinity ? r13.parameterLimit : void 0; const r31 = r155.split(r13.delimiter, r13.throwOnLimitExceeded ? r158 + 1 : r158); if (r13.throwOnLimitExceeded && r31.length > r158) { throw new RangeError(HermesInternal.concat.call("Parameter limit exceeded. Only " + r158, " parameter", r158 === 1 ? "" : "s", " allowed.")); } const charset2 = r13.charset; let charset = charset2; const charsetSentinel = r13.charsetSentinel; let r28 = charset2; let r27 = -1; if (charsetSentinel) { const r169 = 0 < r31.length; let r171 = charset2; let r172 = -1; let r173 = 0; r28 = r171; r27 = -1; if (r169) { do { const r175 = r31[r173].indexOf("utf8="); let r36 = r171; let r33 = r172; const r35 = r173; let r34 = r36; let r176 = r35; if (r175 === 0) { if (r31[r35] === "utf8=%E2%9C%93") { charset = "utf-8"; r36 = "utf-8"; } else if (r31[r35] === "utf8=%26%2310003%3B") { charset = "iso-8859-1"; r36 = "iso-8859-1"; } r176 = r31.length; r34 = r36; r33 = r35; } r173 = r176 + 1; length = r31.length; r171 = r34; r172 = r33; r28 = r171; r27 = r172; } while (r173 < length); } } const r180 = { __proto__: null }; const r12 = 0 < r31.length; const r187 = r28 === "iso-8859-1"; let r192 = 0; r29 = r180; if (r12) { do { L144: { r4 = r192; if (r4 !== r27) { const r193 = r31[r4]; const r195 = r193.indexOf("]="); const r196 = r195 === -1 ? r193.indexOf("=") : r195 + 1; if (r196 === -1) { const r243 = r13.decoder(r193, c508_4.decoder, r28, "key"); r234 = r13.strictNullHandling ? null : ""; r235 = r243; } else { const r201 = r13.decoder(r193.slice(0, r196), c508_4.decoder, r28, "key"); const r208 = r193.slice(r196 + 1); const r211 = isArray(r180[r201]) ? r180[r201].length : 0; if (r208 && (typeof r208 === "string" && (r13.comma && r208.indexOf(",") > -1))) { r219 = r208.split(","); } else { const throwOnLimitExceeded2 = r13.throwOnLimitExceeded; r219 = r208; if (throwOnLimitExceeded2) { const arrayLimit = r13.arrayLimit; r219 = r208; if (r211 >= arrayLimit) { throw new RangeError(HermesInternal.concat.call("Array limit exceeded. Only " + r13.arrayLimit, " element", r13.arrayLimit === 1 ? "" : "s", " allowed in an array.")); } } } r234 = maybeMap(r219, function(a0) { return c12360_0.decoder(a0, c508_4.decoder, charset, "value"); }); r235 = r201; } const r247 = (r234 ? r13.interpretNumericEntities : r234) && r187 ? String(r234).replace(/&#(\d+);/g, function(a0, a1) { return String.fromCharCode(parseInt(a1, 10)); }) : r234; const r258 = r193.indexOf("[]=") > -1 ? isArray(r247) ? [r247] : r247 : r247; const call = hasOwnProperty.call; let r265 = hasOwnProperty.call(r180, r235); if (r265 && r13.duplicates === "combine") { r180[r235] = _Module536.combine(r180[r235], r258); break L144; } if (r265) { r265 = r13.duplicates !== "last"; } if (!r265) { r180[r235] = r258; } } } r192 = r4 + 1; length2 = r31.length; r29 = r180; } while (r192 < length2); } } const r277 = r13.plainObjects ? { __proto__: null } : {}; const r281 = Object.keys(r29); const r284 = 0 < r281.length; let r297 = r277; let r298 = 0; let r299 = r297; if (r284) { do { const r300 = r281[r298]; const r302 = r29[r300]; const r8 = r298; const r303 = r297; L233: { r306 = void 0; if (r300) { const r308 = r13.allowDots ? r300.replace(/\.([^.[]+)/g, "[$1]") : r300; let r312 = r13.depth > 0 && /(\[[^[\]]*])/.exec(r308); const r315 = r312 ? r308.slice(0, r312.index) : r308; const r318 = []; if (r315) { if (!r13.plainObjects) { const call2 = hasOwnProperty.call; if (hasOwnProperty.call(Object.prototype, r315)) { const allowPrototypes = r13.allowPrototypes; r306 = void 0; if (!allowPrototypes) { break L233; } } } r318.push(r315); } if (r13.depth > 0) { const r329 = /(\[[^[\]]*])/g; const r331 = r329.exec(r308); r312 = r331; if (r331 !== null) { const r333 = 0 < r13.depth; let r0 = 0; let r334 = r331; r312 = r334; if (r333) { do { const plainObjects = r13.plainObjects; const r2 = r0; const r336 = r334; if (!plainObjects) { const call3 = hasOwnProperty.call; if (hasOwnProperty.call(Object.prototype, r336[1].slice(1, -1))) { const allowPrototypes2 = r13.allowPrototypes; r306 = void 0; if (!allowPrototypes2) { break L233; } } } r318.push(r336[1]); const depth = r13.depth; r312 = r336; if (!(depth > 0)) { break; } const r351 = r329.exec(r308); r312 = r351; if (r351 === null) { break; } r0 = r2 + 1; depth2 = r13.depth; r334 = r351; r312 = r334; } while (r0 < depth2); } } } if (r312) { if (r13.strictDepth === true) { throw new RangeError("Input depth exceeded depth option of " + r13.depth + " and strictDepth is true"); } r318.push("[" + r308.slice(r312.index) + "]"); } const r362 = r318.length > 0; let r363 = 0; if (r362) { const r366 = r318[r318.length - 1]; r363 = 0; if (r366 === "[]") { const r370 = r318.slice(0, -1).join(""); r363 = Array.isArray(r302) ? r302[r370] ? r302[r370].length : 0 : 0; } } let r377 = r302; if (typeof a0 !== "string") { if (r302 && (typeof r302 === "string" && (r13.comma && r302.indexOf(",") > -1))) { r385 = r302.split(","); } else { const throwOnLimitExceeded3 = r13.throwOnLimitExceeded; r385 = r302; if (throwOnLimitExceeded3) { const arrayLimit2 = r13.arrayLimit; r385 = r302; if (r363 >= arrayLimit2) { throw new RangeError(HermesInternal.concat.call("Array limit exceeded. Only " + r13.arrayLimit, " element", r13.arrayLimit === 1 ? "" : "s", " allowed in an array.")); } } } r377 = r385; } let r404 = r318.length - 1; let r405 = r377; let r406 = r405; while (0 <= r404) { const r407 = r318[r404]; const r408 = r404; const r409 = r405; if (r407 === "[]" && r13.parseArrays) { L230: { L228: { if (r13.allowEmptyArrays) { if (r409 !== "") { if (!r13.strictNullHandling) { break L228; } if (r409 !== null) { break L228; } } r443 = []; break L230; } } r443 = _Module536.combine([], r409); } r427 = r443; } else { const r412 = r13.plainObjects ? { __proto__: null } : {}; const r415 = r407.charAt(0) === "[" ? r407.charAt(r407.length - 1) === "]" ? r407.slice(1, -1) : r407 : r407; const r421 = r13.decodeDotInKeys ? r415.replace(/%2E/g, ".") : r415; const r425 = parseInt(r421, 10); if (!r13.parseArrays && r421 === "") { r427 = { 0: r409 }; } else if (!isNaN(r425) && (r407 !== r421 && (String(r425) === r421 && (r425 >= 0 && (r13.parseArrays && r425 <= r13.arrayLimit))))) { const r434 = []; r434[r425] = r409; r427 = r434; } else { r427 = r412; if (r421 !== "__proto__") { r412[r421] = r409; r427 = r412; } } } r404 = r408 - 1; r405 = r427; r406 = r405; } r306 = r406; } } r297 = merge(r303, r306, r13); r298 = r8 + 1; length3 = r281.length; r299 = r297; } while (r298 < length3); } return r13.allowSparse !== true ? compact(r299) : r299; } return r13.plainObjects ? { __proto__: null } : {}; };