{"version":3,"file":"helpers.mjs","names":[],"sources":["../../../../../../../../../../node_modules/@vitest/utils/dist/helpers.js"],"sourcesContent":["import { VALID_ID_PREFIX, NULL_BYTE_PLACEHOLDER } from './constants.js';\n\n// port from nanoid\n// https://github.com/ai/nanoid\nconst urlAlphabet = \"useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict\";\nfunction nanoid(size = 21) {\n\tlet id = \"\";\n\tlet i = size;\n\twhile (i--) {\n\t\tid += urlAlphabet[Math.random() * 64 | 0];\n\t}\n\treturn id;\n}\n\nconst RealDate = Date;\nfunction random(seed) {\n\tconst x = Math.sin(seed++) * 1e4;\n\treturn x - Math.floor(x);\n}\nfunction shuffle(array, seed = RealDate.now()) {\n\tlet length = array.length;\n\twhile (length) {\n\t\tconst index = Math.floor(random(seed) * length--);\n\t\tconst previous = array[length];\n\t\tarray[length] = array[index];\n\t\tarray[index] = previous;\n\t\t++seed;\n\t}\n\treturn array;\n}\n\n/**\n* Get original stacktrace without source map support the most performant way.\n* - Create only 1 stack frame.\n* - Rewrite prepareStackTrace to bypass \"support-stack-trace\" (usually takes ~250ms).\n*/\nfunction createSimpleStackTrace(options) {\n\tconst { message = \"$$stack trace error\", stackTraceLimit = 1 } = options || {};\n\tconst limit = Error.stackTraceLimit;\n\tconst prepareStackTrace = Error.prepareStackTrace;\n\tError.stackTraceLimit = stackTraceLimit;\n\tError.prepareStackTrace = (e) => e.stack;\n\tconst err = new Error(message);\n\tconst stackTrace = err.stack || \"\";\n\tError.prepareStackTrace = prepareStackTrace;\n\tError.stackTraceLimit = limit;\n\treturn stackTrace;\n}\nfunction notNullish(v) {\n\treturn v != null;\n}\nfunction assertTypes(value, name, types) {\n\tconst receivedType = typeof value;\n\tconst pass = types.includes(receivedType);\n\tif (!pass) {\n\t\tthrow new TypeError(`${name} value must be ${types.join(\" or \")}, received \"${receivedType}\"`);\n\t}\n}\nfunction isPrimitive(value) {\n\treturn value === null || typeof value !== \"function\" && typeof value !== \"object\";\n}\nfunction slash(path) {\n\treturn path.replace(/\\\\/g, \"/\");\n}\nconst postfixRE = /[?#].*$/;\nfunction cleanUrl(url) {\n\treturn url.replace(postfixRE, \"\");\n}\nfunction splitFileAndPostfix(path) {\n\tconst file = cleanUrl(path);\n\treturn {\n\t\tfile,\n\t\tpostfix: path.slice(file.length)\n\t};\n}\nconst externalRE = /^(?:[a-z]+:)?\\/\\//;\nconst isExternalUrl = (url) => externalRE.test(url);\n/**\n* Prepend `/@id/` and replace null byte so the id is URL-safe.\n* This is prepended to resolved ids that are not valid browser\n* import specifiers by the importAnalysis plugin.\n*/\nfunction wrapId(id) {\n\treturn id.startsWith(VALID_ID_PREFIX) ? id : VALID_ID_PREFIX + id.replace(\"\\0\", NULL_BYTE_PLACEHOLDER);\n}\n/**\n* Undo {@link wrapId}'s `/@id/` and null byte replacements.\n*/\nfunction unwrapId(id) {\n\treturn id.startsWith(VALID_ID_PREFIX) ? id.slice(VALID_ID_PREFIX.length).replace(NULL_BYTE_PLACEHOLDER, \"\\0\") : id;\n}\nfunction withTrailingSlash(path) {\n\tif (path.at(-1) !== \"/\") {\n\t\treturn `${path}/`;\n\t}\n\treturn path;\n}\nfunction filterOutComments(s) {\n\tconst result = [];\n\tlet commentState = \"none\";\n\tfor (let i = 0; i < s.length; ++i) {\n\t\tif (commentState === \"singleline\") {\n\t\t\tif (s[i] === \"\\n\") {\n\t\t\t\tcommentState = \"none\";\n\t\t\t}\n\t\t} else if (commentState === \"multiline\") {\n\t\t\tif (s[i - 1] === \"*\" && s[i] === \"/\") {\n\t\t\t\tcommentState = \"none\";\n\t\t\t}\n\t\t} else if (commentState === \"none\") {\n\t\t\tif (s[i] === \"/\" && s[i + 1] === \"/\") {\n\t\t\t\tcommentState = \"singleline\";\n\t\t\t} else if (s[i] === \"/\" && s[i + 1] === \"*\") {\n\t\t\t\tcommentState = \"multiline\";\n\t\t\t\ti += 2;\n\t\t\t} else {\n\t\t\t\tresult.push(s[i]);\n\t\t\t}\n\t\t}\n\t}\n\treturn result.join(\"\");\n}\nconst bareImportRE = /^(?![a-z]:)[\\w@](?!.*:\\/\\/)/i;\nfunction isBareImport(id) {\n\treturn bareImportRE.test(id);\n}\nfunction toArray(array) {\n\tif (array === null || array === undefined) {\n\t\tarray = [];\n\t}\n\tif (Array.isArray(array)) {\n\t\treturn array;\n\t}\n\treturn [array];\n}\nfunction isObject(item) {\n\treturn item != null && typeof item === \"object\" && !Array.isArray(item);\n}\nfunction isFinalObj(obj) {\n\treturn obj === Object.prototype || obj === Function.prototype || obj === RegExp.prototype;\n}\nfunction getType(value) {\n\treturn Object.prototype.toString.apply(value).slice(8, -1);\n}\nfunction collectOwnProperties(obj, collector) {\n\tconst collect = typeof collector === \"function\" ? collector : (key) => collector.add(key);\n\tObject.getOwnPropertyNames(obj).forEach(collect);\n\tObject.getOwnPropertySymbols(obj).forEach(collect);\n}\nfunction getOwnProperties(obj) {\n\tconst ownProps = new Set();\n\tif (isFinalObj(obj)) {\n\t\treturn [];\n\t}\n\tcollectOwnProperties(obj, ownProps);\n\treturn Array.from(ownProps);\n}\nconst defaultCloneOptions = { forceWritable: false };\nfunction deepClone(val, options = defaultCloneOptions) {\n\tconst seen = new WeakMap();\n\treturn clone(val, seen, options);\n}\nfunction clone(val, seen, options = defaultCloneOptions) {\n\tlet k, out;\n\tif (seen.has(val)) {\n\t\treturn seen.get(val);\n\t}\n\tif (Array.isArray(val)) {\n\t\tout = Array.from({ length: k = val.length });\n\t\tseen.set(val, out);\n\t\twhile (k--) {\n\t\t\tout[k] = clone(val[k], seen, options);\n\t\t}\n\t\treturn out;\n\t}\n\tif (Object.prototype.toString.call(val) === \"[object Object]\") {\n\t\tout = Object.create(Object.getPrototypeOf(val));\n\t\tseen.set(val, out);\n\t\t// we don't need properties from prototype\n\t\tconst props = getOwnProperties(val);\n\t\tfor (const k of props) {\n\t\t\tconst descriptor = Object.getOwnPropertyDescriptor(val, k);\n\t\t\tif (!descriptor) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tconst cloned = clone(val[k], seen, options);\n\t\t\tif (options.forceWritable) {\n\t\t\t\tObject.defineProperty(out, k, {\n\t\t\t\t\tenumerable: descriptor.enumerable,\n\t\t\t\t\tconfigurable: true,\n\t\t\t\t\twritable: true,\n\t\t\t\t\tvalue: cloned\n\t\t\t\t});\n\t\t\t} else if (\"get\" in descriptor) {\n\t\t\t\tObject.defineProperty(out, k, {\n\t\t\t\t\t...descriptor,\n\t\t\t\t\tget() {\n\t\t\t\t\t\treturn cloned;\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\tObject.defineProperty(out, k, {\n\t\t\t\t\t...descriptor,\n\t\t\t\t\tvalue: cloned\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t\treturn out;\n\t}\n\treturn val;\n}\nfunction noop() {}\nfunction objectAttr(source, path, defaultValue = undefined) {\n\t// a[3].b -> a.3.b\n\tconst paths = path.replace(/\\[(\\d+)\\]/g, \".$1\").split(\".\");\n\tlet result = source;\n\tfor (const p of paths) {\n\t\tresult = new Object(result)[p];\n\t\tif (result === undefined) {\n\t\t\treturn defaultValue;\n\t\t}\n\t}\n\treturn result;\n}\nfunction createDefer() {\n\tlet resolve = null;\n\tlet reject = null;\n\tconst p = new Promise((_resolve, _reject) => {\n\t\tresolve = _resolve;\n\t\treject = _reject;\n\t});\n\tp.resolve = resolve;\n\tp.reject = reject;\n\treturn p;\n}\n/**\n* If code starts with a function call, will return its last index, respecting arguments.\n* This will return 25 - last ending character of toMatch \")\"\n* Also works with callbacks\n* ```\n* toMatch({ test: '123' });\n* toBeAliased('123')\n* ```\n*/\nfunction getCallLastIndex(code) {\n\tlet charIndex = -1;\n\tlet inString = null;\n\tlet startedBracers = 0;\n\tlet endedBracers = 0;\n\tlet beforeChar = null;\n\twhile (charIndex <= code.length) {\n\t\tbeforeChar = code[charIndex];\n\t\tcharIndex++;\n\t\tconst char = code[charIndex];\n\t\tconst isCharString = char === \"\\\"\" || char === \"'\" || char === \"`\";\n\t\tif (isCharString && beforeChar !== \"\\\\\") {\n\t\t\tif (inString === char) {\n\t\t\t\tinString = null;\n\t\t\t} else if (!inString) {\n\t\t\t\tinString = char;\n\t\t\t}\n\t\t}\n\t\tif (!inString) {\n\t\t\tif (char === \"(\") {\n\t\t\t\tstartedBracers++;\n\t\t\t}\n\t\t\tif (char === \")\") {\n\t\t\t\tendedBracers++;\n\t\t\t}\n\t\t}\n\t\tif (startedBracers && endedBracers && startedBracers === endedBracers) {\n\t\t\treturn charIndex;\n\t\t}\n\t}\n\treturn null;\n}\nfunction isNegativeNaN(val) {\n\tif (!Number.isNaN(val)) {\n\t\treturn false;\n\t}\n\tconst f64 = new Float64Array(1);\n\tf64[0] = val;\n\tconst u32 = new Uint32Array(f64.buffer);\n\tconst isNegative = u32[1] >>> 31 === 1;\n\treturn isNegative;\n}\nfunction toString(v) {\n\treturn Object.prototype.toString.call(v);\n}\nfunction isPlainObject(val) {\n\treturn toString(val) === \"[object Object]\" && (!val.constructor || val.constructor.name === \"Object\");\n}\nfunction isMergeableObject(item) {\n\treturn isPlainObject(item) && !Array.isArray(item);\n}\nfunction ordinal(i) {\n\tconst j = i % 10;\n\tconst k = i % 100;\n\tif (j === 1 && k !== 11) {\n\t\treturn `${i}st`;\n\t}\n\tif (j === 2 && k !== 12) {\n\t\treturn `${i}nd`;\n\t}\n\tif (j === 3 && k !== 13) {\n\t\treturn `${i}rd`;\n\t}\n\treturn `${i}th`;\n}\n/**\n* Deep merge :P\n*\n* Will merge objects only if they are plain\n*\n* Do not merge types - it is very expensive and usually it's better to case a type here\n*/\nfunction deepMerge(target, ...sources) {\n\tif (!sources.length) {\n\t\treturn target;\n\t}\n\tconst source = sources.shift();\n\tif (source === undefined) {\n\t\treturn target;\n\t}\n\tif (isMergeableObject(target) && isMergeableObject(source)) {\n\t\tObject.keys(source).forEach((key) => {\n\t\t\tconst _source = source;\n\t\t\tif (isMergeableObject(_source[key])) {\n\t\t\t\tif (!target[key]) {\n\t\t\t\t\ttarget[key] = {};\n\t\t\t\t}\n\t\t\t\tdeepMerge(target[key], _source[key]);\n\t\t\t} else {\n\t\t\t\ttarget[key] = _source[key];\n\t\t\t}\n\t\t});\n\t}\n\treturn deepMerge(target, ...sources);\n}\nfunction unique(array) {\n\treturn Array.from(new Set(array));\n}\n\nexport { assertTypes, cleanUrl, clone, createDefer, createSimpleStackTrace, deepClone, deepMerge, filterOutComments, getCallLastIndex, getOwnProperties, getType, isBareImport, isExternalUrl, isNegativeNaN, isObject, isPrimitive, nanoid, noop, notNullish, objectAttr, ordinal, shuffle, slash, splitFileAndPostfix, toArray, unique, unwrapId, withTrailingSlash, wrapId };\n"],"x_google_ignoreList":[0],"mappings":";;;;;;AAoCA,SAAS,uBAAuB,SAAS;CACxC,MAAM,EAAE,UAAU,uBAAuB,kBAAkB,MAAM,WAAW,CAAC;CAC7E,MAAM,QAAQ,MAAM;CACpB,MAAM,oBAAoB,MAAM;CAChC,MAAM,kBAAkB;CACxB,MAAM,qBAAqB,MAAM,EAAE;CAEnC,MAAM,aAAa,IADH,MAAM,OACD,CAAC,CAAC,SAAS;CAChC,MAAM,oBAAoB;CAC1B,MAAM,kBAAkB;CACxB,OAAO;AACR;AACA,SAAS,WAAW,GAAG;CACtB,OAAO,KAAK;AACb;AACA,SAAS,YAAY,OAAO,MAAM,OAAO;CACxC,MAAM,eAAe,OAAO;CAE5B,IAAI,CADS,MAAM,SAAS,YACpB,GACP,MAAM,IAAI,UAAU,GAAG,KAAK,iBAAiB,MAAM,KAAK,MAAM,EAAE,cAAc,aAAa,EAAE;AAE/F;AACA,SAAS,YAAY,OAAO;CAC3B,OAAO,UAAU,QAAQ,OAAO,UAAU,cAAc,OAAO,UAAU;AAC1E;AAqCA,SAAS,kBAAkB,GAAG;CAC7B,MAAM,SAAS,CAAC;CAChB,IAAI,eAAe;CACnB,KAAK,IAAI,IAAI,GAAG,IAAI,EAAE,QAAQ,EAAE,GAC/B,IAAI,iBAAiB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