/** * @vue/compiler-sfc v3.6.0-rc.10 * (c) 2018-present Yuxi (Evan) You and Vue contributors * @license MIT **/ Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } }); //#region \0rolldown/runtime.js var __create = Object.create; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __getProtoOf = Object.getPrototypeOf; var __hasOwnProp = Object.prototype.hasOwnProperty; var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports); var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) { key = keys[i]; if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: ((k) => from[k]).bind(null, key), enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod)); //#endregion let _vue_compiler_core = require("@vue/compiler-core"); let _vue_compiler_dom = require("@vue/compiler-dom"); _vue_compiler_dom = __toESM(_vue_compiler_dom); let source_map_js = require("source-map-js"); let _vue_shared = require("@vue/shared"); let path = require("path"); path = __toESM(path); let url = require("url"); let _vue_compiler_vapor = require("@vue/compiler-vapor"); _vue_compiler_vapor = __toESM(_vue_compiler_vapor); let _vue_compiler_ssr = require("@vue/compiler-ssr"); _vue_compiler_ssr = __toESM(_vue_compiler_ssr); let postcss = require("postcss"); postcss = __toESM(postcss); let _babel_parser = require("@babel/parser"); let estree_walker = require("estree-walker"); let magic_string = require("magic-string"); magic_string = __toESM(magic_string); let process$1 = require("process"); process$1 = __toESM(process$1); //#endregion //#region packages/compiler-sfc/src/style/cssVars.ts var import_hash_sum = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((exports, module) => { function pad(hash, len) { while (hash.length < len) hash = "0" + hash; return hash; } function fold(hash, text) { var i; var chr; var len; if (text.length === 0) return hash; for (i = 0, len = text.length; i < len; i++) { chr = text.charCodeAt(i); hash = (hash << 5) - hash + chr; hash |= 0; } return hash < 0 ? hash * -2 : hash; } function foldObject(hash, o, seen) { return Object.keys(o).sort().reduce(foldKey, hash); function foldKey(hash, key) { return foldValue(hash, o[key], key, seen); } } function foldValue(input, value, key, seen) { var hash = fold(fold(fold(input, key), toString(value)), typeof value); if (value === null) return fold(hash, "null"); if (value === void 0) return fold(hash, "undefined"); if (typeof value === "object" || typeof value === "function") { if (seen.indexOf(value) !== -1) return fold(hash, "[Circular]" + key); seen.push(value); var objHash = foldObject(hash, value, seen); if (!("valueOf" in value) || typeof value.valueOf !== "function") return objHash; try { return fold(objHash, String(value.valueOf())); } catch (err) { return fold(objHash, "[valueOf exception]" + (err.stack || err.message)); } } return fold(hash, value.toString()); } function toString(o) { return Object.prototype.toString.call(o); } function sum(o) { return pad(foldValue(0, o, "", []).toString(16), 8); } module.exports = sum; })))()); const CSS_VARS_HELPER = `useCssVars`; function getCssVarsHelper(vapor) { return vapor ? `useVaporCssVars` : CSS_VARS_HELPER; } function genCssVarsFromList(vars, id, isProd, isSSR = false) { return `{\n ${vars.map((key) => `"${isSSR ? `:--` : ``}${genVarName(id, key, isProd, isSSR)}": (${key})`).join(",\n ")}\n}`; } function genVarName(id, raw, isProd, isSSR = false) { if (isProd) return (0, import_hash_sum.default)(id + raw).replace(/^\d/, (r) => `v${r}`); else return `${id}-${(0, _vue_shared.getEscapedCssVarName)(raw, isSSR)}`; } function normalizeExpression(exp) { exp = exp.trim(); if (exp[0] === `'` && exp[exp.length - 1] === `'` || exp[0] === `"` && exp[exp.length - 1] === `"`) return exp.slice(1, -1); return exp; } const vBindRE = /v-bind\s*\(/g; function parseCssVars(sfc) { const vars = []; sfc.styles.forEach((style) => { let match; const content = stripComments(style.content); while (match = vBindRE.exec(content)) { const start = match.index + match[0].length; const end = lexBinding(content, start); if (end !== null) { const variable = normalizeExpression(content.slice(start, end)); if (!vars.includes(variable)) vars.push(variable); } } }); return vars; } const cssSpecialRE = /[/"'\\(]/g; function stripComments(content) { const len = content.length; let out = ""; let last = 0; let i = 0; cssSpecialRE.lastIndex = 0; while (cssSpecialRE.test(content)) { i = cssSpecialRE.lastIndex - 1; const c = content.charCodeAt(i); if (c === 47) { const next = content.charCodeAt(i + 1); if (next === 42) { out += content.slice(last, i); const end = content.indexOf("*/", i + 2); i = last = end === -1 ? len : end + 2; } else if (next === 47) { out += content.slice(last, i); i += 2; while (i < len && !isNewline(content.charCodeAt(i))) i++; last = i; } else i++; } else if (c === 34 || c === 39) i = skipString(content, i + 1, c); else if (c === 92) i += 2; else if (isUrlFunction(content, i)) i = skipUrl(content, i + 1); else i++; cssSpecialRE.lastIndex = i; } return last === 0 ? content : out + content.slice(last); } function skipString(s, i, quote) { while (i < s.length) { const c = s.charCodeAt(i); if (c === quote) return i + 1; if (isNewline(c)) return i; if (c === 92) i += s.charCodeAt(i + 1) === 13 && s.charCodeAt(i + 2) === 10 ? 3 : 2; else i++; } return i; } function isUrlFunction(s, i) { const prev = s.charCodeAt(i - 4); return (s.charCodeAt(i - 3) | 32) === 117 && (s.charCodeAt(i - 2) | 32) === 114 && (s.charCodeAt(i - 1) | 32) === 108 && prev !== 92 && !isIdentChar(prev); } function skipUrl(s, i) { while (isWhitespace(s.charCodeAt(i))) i++; const c = s.charCodeAt(i); if (c === 34 || c === 39) return i; while (i < s.length) { const c = s.charCodeAt(i); if (c === 41) return i + 1; i += c === 92 ? 2 : 1; } return i; } function isIdentChar(c) { return c >= 97 && c <= 122 || c >= 65 && c <= 90 || c >= 48 && c <= 57 || c === 45 || c === 95 || c >= 128; } function isNewline(c) { return c === 10 || c === 13; } function isWhitespace(c) { return c === 32 || c === 9 || c === 12 || isNewline(c); } function lexBinding(content, start) { let state = 0; let parenDepth = 0; for (let i = start; i < content.length; i++) { const char = content.charAt(i); switch (state) { case 0: if (char === `'`) state = 1; else if (char === `"`) state = 2; else if (char === `(`) parenDepth++; else if (char === `)`) { if (parenDepth > 0) parenDepth--; else return i; } break; case 1: if (char === `'`) state = 0; break; case 2: if (char === `"`) state = 0; } } return null; } const cssVarsPlugin = (opts) => { const { id, isProd } = opts; return { postcssPlugin: "vue-sfc-vars", Declaration(decl) { const value = decl.value; if (vBindRE.test(value)) { vBindRE.lastIndex = 0; let transformed = ""; let lastIndex = 0; let match; while (match = vBindRE.exec(value)) { const start = match.index + match[0].length; const end = lexBinding(value, start); if (end !== null) { const variable = normalizeExpression(value.slice(start, end)); transformed += value.slice(lastIndex, match.index) + `var(--${genVarName(id, variable, isProd)})`; lastIndex = end + 1; } } decl.value = transformed + value.slice(lastIndex); } } }; }; cssVarsPlugin.postcss = true; function genCssVarsCode(vars, bindings, id, isProd, vapor) { const varsExp = genCssVarsFromList(vars, id, isProd); const exp = (0, _vue_compiler_dom.createSimpleExpression)(varsExp, false); const context = (0, _vue_compiler_dom.createTransformContext)((0, _vue_compiler_dom.createRoot)([]), { prefixIdentifiers: true, inline: true, bindingMetadata: bindings.__isScriptSetup === false ? void 0 : bindings }); const transformed = (0, _vue_compiler_dom.processExpression)(exp, context); const transformedString = transformed.type === 4 ? transformed.content : transformed.children.map((c) => { return typeof c === "string" ? c : c.content; }).join(""); return `_${getCssVarsHelper(vapor)}(_ctx => (${transformedString}))`; } function genNormalScriptCssVarsCode(cssVars, bindings, id, isProd, defaultVar) { return `\nimport { ${CSS_VARS_HELPER} as _${CSS_VARS_HELPER} } from 'vue'\nconst __injectCSSVars__ = () => {\n${genCssVarsCode(cssVars, bindings, id, isProd)}}\nconst __setup__ = ${defaultVar}.setup\n${defaultVar}.setup = __setup__\n ? (props, ctx) => { __injectCSSVars__();return __setup__(props, ctx) }\n : __injectCSSVars__\n`; } //#endregion //#region \0@oxc-project+runtime@0.146.0/helpers/esm/typeof.js function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) { return typeof o; } : function(o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); } //#endregion //#region \0@oxc-project+runtime@0.146.0/helpers/esm/toPrimitive.js function toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } //#endregion //#region \0@oxc-project+runtime@0.146.0/helpers/esm/toPropertyKey.js function toPropertyKey(t) { var i = toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; } //#endregion //#region \0@oxc-project+runtime@0.146.0/helpers/esm/defineProperty.js function _defineProperty(e, r, t) { return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; } //#endregion //#region \0@oxc-project+runtime@0.146.0/helpers/esm/checkPrivateRedeclaration.js function _checkPrivateRedeclaration(e, t) { if (t.has(e)) throw new TypeError("Cannot initialize the same private elements twice on an object"); } //#endregion //#region \0@oxc-project+runtime@0.146.0/helpers/esm/classPrivateMethodInitSpec.js function _classPrivateMethodInitSpec(e, a) { _checkPrivateRedeclaration(e, a), a.add(e); } //#endregion //#region \0@oxc-project+runtime@0.146.0/helpers/esm/classPrivateFieldInitSpec.js function _classPrivateFieldInitSpec(e, t, a) { _checkPrivateRedeclaration(e, t), t.set(e, a); } //#endregion //#region \0@oxc-project+runtime@0.146.0/helpers/esm/assertClassBrand.js function _assertClassBrand(e, t, n) { if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n; throw new TypeError("Private element is not present on this object"); } //#endregion //#region \0@oxc-project+runtime@0.146.0/helpers/esm/classPrivateFieldGet2.js function _classPrivateFieldGet2(s, a) { return s.get(_assertClassBrand(s, a)); } //#endregion //#region \0@oxc-project+runtime@0.146.0/helpers/esm/classPrivateFieldSet2.js function _classPrivateFieldSet2(s, a, r) { return s.set(_assertClassBrand(s, a), r), r; } //#endregion //#region node_modules/.pnpm/lru-cache@10.1.0/node_modules/lru-cache/dist/esm/index.js let _Symbol$iterator; /** * @module LRUCache */ const perf = typeof performance === "object" && performance && typeof performance.now === "function" ? performance : Date; const warned = /* @__PURE__ */ new Set(); /* c8 ignore start */ const PROCESS = typeof process === "object" && !!process ? process : {}; /* c8 ignore start */ const emitWarning = (msg, type, code, fn) => { typeof PROCESS.emitWarning === "function" ? PROCESS.emitWarning(msg, type, code, fn) : console.error(`[${code}] ${type}: ${msg}`); }; let AC = globalThis.AbortController; let AS = globalThis.AbortSignal; /* c8 ignore start */ if (typeof AC === "undefined") { var _PROCESS$env; AS = class AbortSignal { constructor() { _defineProperty(this, "onabort", void 0); _defineProperty(this, "_onabort", []); _defineProperty(this, "reason", void 0); _defineProperty(this, "aborted", false); } addEventListener(_, fn) { this._onabort.push(fn); } }; AC = class AbortController { constructor() { _defineProperty(this, "signal", new AS()); warnACPolyfill(); } abort(reason) { var _this$signal$onabort, _this$signal; if (this.signal.aborted) return; this.signal.reason = reason; this.signal.aborted = true; for (const fn of this.signal._onabort) fn(reason); (_this$signal$onabort = (_this$signal = this.signal).onabort) === null || _this$signal$onabort === void 0 || _this$signal$onabort.call(_this$signal, reason); } }; let printACPolyfillWarning = ((_PROCESS$env = PROCESS.env) === null || _PROCESS$env === void 0 ? void 0 : _PROCESS$env.LRU_CACHE_IGNORE_AC_WARNING) !== "1"; const warnACPolyfill = () => { if (!printACPolyfillWarning) return; printACPolyfillWarning = false; emitWarning("AbortController is not defined. If using lru-cache in node 14, load an AbortController polyfill from the `node-abort-controller` package. A minimal polyfill is provided for use by LRUCache.fetch(), but it should not be relied upon in other contexts (eg, passing it to other APIs that use AbortController/AbortSignal might have undesirable effects). You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.", "NO_ABORT_CONTROLLER", "ENOTSUP", warnACPolyfill); }; } /* c8 ignore stop */ const shouldWarn = (code) => !warned.has(code); const isPosInt = (n) => n && n === Math.floor(n) && n > 0 && isFinite(n); /* c8 ignore start */ const getUintArray = (max) => !isPosInt(max) ? null : max <= Math.pow(2, 8) ? Uint8Array : max <= Math.pow(2, 16) ? Uint16Array : max <= Math.pow(2, 32) ? Uint32Array : max <= Number.MAX_SAFE_INTEGER ? ZeroArray : null; /* c8 ignore stop */ var ZeroArray = class extends Array { constructor(size) { super(size); this.fill(0); } }; var Stack = class Stack { static create(max) { const HeapCls = getUintArray(max); if (!HeapCls) return []; _constructing._ = true; const s = new Stack(max, HeapCls); _constructing._ = false; return s; } constructor(max, HeapCls) { _defineProperty(this, "heap", void 0); _defineProperty(this, "length", void 0); /* c8 ignore start */ if (!_constructing._) throw new TypeError("instantiate Stack using Stack.create(n)"); /* c8 ignore stop */ this.heap = new HeapCls(max); this.length = 0; } push(n) { this.heap[this.length++] = n; } pop() { return this.heap[--this.length]; } }; var _constructing = { _: false }; var _max = /* @__PURE__ */ new WeakMap(); var _maxSize = /* @__PURE__ */ new WeakMap(); var _dispose = /* @__PURE__ */ new WeakMap(); var _disposeAfter = /* @__PURE__ */ new WeakMap(); var _fetchMethod = /* @__PURE__ */ new WeakMap(); var _size = /* @__PURE__ */ new WeakMap(); var _calculatedSize = /* @__PURE__ */ new WeakMap(); var _keyMap = /* @__PURE__ */ new WeakMap(); var _keyList = /* @__PURE__ */ new WeakMap(); var _valList = /* @__PURE__ */ new WeakMap(); var _next = /* @__PURE__ */ new WeakMap(); var _prev = /* @__PURE__ */ new WeakMap(); var _head = /* @__PURE__ */ new WeakMap(); var _tail = /* @__PURE__ */ new WeakMap(); var _free = /* @__PURE__ */ new WeakMap(); var _disposed = /* @__PURE__ */ new WeakMap(); var _sizes = /* @__PURE__ */ new WeakMap(); var _starts = /* @__PURE__ */ new WeakMap(); var _ttls = /* @__PURE__ */ new WeakMap(); var _hasDispose = /* @__PURE__ */ new WeakMap(); var _hasFetchMethod = /* @__PURE__ */ new WeakMap(); var _hasDisposeAfter = /* @__PURE__ */ new WeakMap(); var _LRUCache_brand = /* @__PURE__ */ new WeakSet(); var _updateItemAge = /* @__PURE__ */ new WeakMap(); var _statusTTL = /* @__PURE__ */ new WeakMap(); var _setItemTTL = /* @__PURE__ */ new WeakMap(); var _isStale = /* @__PURE__ */ new WeakMap(); var _removeItemSize = /* @__PURE__ */ new WeakMap(); var _addItemSize = /* @__PURE__ */ new WeakMap(); var _requireSize = /* @__PURE__ */ new WeakMap(); _Symbol$iterator = Symbol.iterator; /** * Default export, the thing you're using this module to get. * * All properties from the options object (with the exception of * {@link OptionsBase.max} and {@link OptionsBase.maxSize}) are added as * normal public members. (`max` and `maxBase` are read-only getters.) * Changing any of these will alter the defaults for subsequent method calls, * but is otherwise safe. */ var LRUCache = class LRUCache { /** * Do not call this method unless you need to inspect the * inner workings of the cache. If anything returned by this * object is modified in any way, strange breakage may occur. * * These fields are private for a reason! * * @internal */ static unsafeExposeInternals(c) { return { starts: _classPrivateFieldGet2(_starts, c), ttls: _classPrivateFieldGet2(_ttls, c), sizes: _classPrivateFieldGet2(_sizes, c), keyMap: _classPrivateFieldGet2(_keyMap, c), keyList: _classPrivateFieldGet2(_keyList, c), valList: _classPrivateFieldGet2(_valList, c), next: _classPrivateFieldGet2(_next, c), prev: _classPrivateFieldGet2(_prev, c), get head() { return _classPrivateFieldGet2(_head, c); }, get tail() { return _classPrivateFieldGet2(_tail, c); }, free: _classPrivateFieldGet2(_free, c), isBackgroundFetch: (p) => _assertClassBrand(_LRUCache_brand, c, _isBackgroundFetch).call(c, p), backgroundFetch: (k, index, options, context) => _assertClassBrand(_LRUCache_brand, c, _backgroundFetch).call(c, k, index, options, context), moveToTail: (index) => _assertClassBrand(_LRUCache_brand, c, _moveToTail).call(c, index), indexes: (options) => _assertClassBrand(_LRUCache_brand, c, _indexes).call(c, options), rindexes: (options) => _assertClassBrand(_LRUCache_brand, c, _rindexes).call(c, options), isStale: (index) => _classPrivateFieldGet2(_isStale, c).call(c, index) }; } /** * {@link LRUCache.OptionsBase.max} (read-only) */ get max() { return _classPrivateFieldGet2(_max, this); } /** * {@link LRUCache.OptionsBase.maxSize} (read-only) */ get maxSize() { return _classPrivateFieldGet2(_maxSize, this); } /** * The total computed size of items in the cache (read-only) */ get calculatedSize() { return _classPrivateFieldGet2(_calculatedSize, this); } /** * The number of items stored in the cache (read-only) */ get size() { return _classPrivateFieldGet2(_size, this); } /** * {@link LRUCache.OptionsBase.fetchMethod} (read-only) */ get fetchMethod() { return _classPrivateFieldGet2(_fetchMethod, this); } /** * {@link LRUCache.OptionsBase.dispose} (read-only) */ get dispose() { return _classPrivateFieldGet2(_dispose, this); } /** * {@link LRUCache.OptionsBase.disposeAfter} (read-only) */ get disposeAfter() { return _classPrivateFieldGet2(_disposeAfter, this); } constructor(options) { _classPrivateMethodInitSpec(this, _LRUCache_brand); _classPrivateFieldInitSpec(this, _max, void 0); _classPrivateFieldInitSpec(this, _maxSize, void 0); _classPrivateFieldInitSpec(this, _dispose, void 0); _classPrivateFieldInitSpec(this, _disposeAfter, void 0); _classPrivateFieldInitSpec(this, _fetchMethod, void 0); _defineProperty( this, /** * {@link LRUCache.OptionsBase.ttl} */ "ttl", void 0 ); _defineProperty( this, /** * {@link LRUCache.OptionsBase.ttlResolution} */ "ttlResolution", void 0 ); _defineProperty( this, /** * {@link LRUCache.OptionsBase.ttlAutopurge} */ "ttlAutopurge", void 0 ); _defineProperty( this, /** * {@link LRUCache.OptionsBase.updateAgeOnGet} */ "updateAgeOnGet", void 0 ); _defineProperty( this, /** * {@link LRUCache.OptionsBase.updateAgeOnHas} */ "updateAgeOnHas", void 0 ); _defineProperty( this, /** * {@link LRUCache.OptionsBase.allowStale} */ "allowStale", void 0 ); _defineProperty( this, /** * {@link LRUCache.OptionsBase.noDisposeOnSet} */ "noDisposeOnSet", void 0 ); _defineProperty( this, /** * {@link LRUCache.OptionsBase.noUpdateTTL} */ "noUpdateTTL", void 0 ); _defineProperty( this, /** * {@link LRUCache.OptionsBase.maxEntrySize} */ "maxEntrySize", void 0 ); _defineProperty( this, /** * {@link LRUCache.OptionsBase.sizeCalculation} */ "sizeCalculation", void 0 ); _defineProperty( this, /** * {@link LRUCache.OptionsBase.noDeleteOnFetchRejection} */ "noDeleteOnFetchRejection", void 0 ); _defineProperty( this, /** * {@link LRUCache.OptionsBase.noDeleteOnStaleGet} */ "noDeleteOnStaleGet", void 0 ); _defineProperty( this, /** * {@link LRUCache.OptionsBase.allowStaleOnFetchAbort} */ "allowStaleOnFetchAbort", void 0 ); _defineProperty( this, /** * {@link LRUCache.OptionsBase.allowStaleOnFetchRejection} */ "allowStaleOnFetchRejection", void 0 ); _defineProperty( this, /** * {@link LRUCache.OptionsBase.ignoreFetchAbort} */ "ignoreFetchAbort", void 0 ); _classPrivateFieldInitSpec(this, _size, void 0); _classPrivateFieldInitSpec(this, _calculatedSize, void 0); _classPrivateFieldInitSpec(this, _keyMap, void 0); _classPrivateFieldInitSpec(this, _keyList, void 0); _classPrivateFieldInitSpec(this, _valList, void 0); _classPrivateFieldInitSpec(this, _next, void 0); _classPrivateFieldInitSpec(this, _prev, void 0); _classPrivateFieldInitSpec(this, _head, void 0); _classPrivateFieldInitSpec(this, _tail, void 0); _classPrivateFieldInitSpec(this, _free, void 0); _classPrivateFieldInitSpec(this, _disposed, void 0); _classPrivateFieldInitSpec(this, _sizes, void 0); _classPrivateFieldInitSpec(this, _starts, void 0); _classPrivateFieldInitSpec(this, _ttls, void 0); _classPrivateFieldInitSpec(this, _hasDispose, void 0); _classPrivateFieldInitSpec(this, _hasFetchMethod, void 0); _classPrivateFieldInitSpec(this, _hasDisposeAfter, void 0); _classPrivateFieldInitSpec(this, _updateItemAge, () => {}); _classPrivateFieldInitSpec(this, _statusTTL, () => {}); _classPrivateFieldInitSpec(this, _setItemTTL, () => {}); _classPrivateFieldInitSpec(this, _isStale, () => false); _classPrivateFieldInitSpec(this, _removeItemSize, (_i) => {}); _classPrivateFieldInitSpec(this, _addItemSize, (_i, _s, _st) => {}); _classPrivateFieldInitSpec(this, _requireSize, (_k, _v, size, sizeCalculation) => { if (size || sizeCalculation) throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache"); return 0; }); const { max = 0, ttl, ttlResolution = 1, ttlAutopurge, updateAgeOnGet, updateAgeOnHas, allowStale, dispose, disposeAfter, noDisposeOnSet, noUpdateTTL, maxSize = 0, maxEntrySize = 0, sizeCalculation, fetchMethod, noDeleteOnFetchRejection, noDeleteOnStaleGet, allowStaleOnFetchRejection, allowStaleOnFetchAbort, ignoreFetchAbort } = options; if (max !== 0 && !isPosInt(max)) throw new TypeError("max option must be a nonnegative integer"); const UintArray = max ? getUintArray(max) : Array; if (!UintArray) throw new Error("invalid max value: " + max); _classPrivateFieldSet2(_max, this, max); _classPrivateFieldSet2(_maxSize, this, maxSize); this.maxEntrySize = maxEntrySize || _classPrivateFieldGet2(_maxSize, this); this.sizeCalculation = sizeCalculation; if (this.sizeCalculation) { if (!_classPrivateFieldGet2(_maxSize, this) && !this.maxEntrySize) throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize"); if (typeof this.sizeCalculation !== "function") throw new TypeError("sizeCalculation set to non-function"); } if (fetchMethod !== void 0 && typeof fetchMethod !== "function") throw new TypeError("fetchMethod must be a function if specified"); _classPrivateFieldSet2(_fetchMethod, this, fetchMethod); _classPrivateFieldSet2(_hasFetchMethod, this, !!fetchMethod); _classPrivateFieldSet2(_keyMap, this, /* @__PURE__ */ new Map()); _classPrivateFieldSet2(_keyList, this, new Array(max).fill(void 0)); _classPrivateFieldSet2(_valList, this, new Array(max).fill(void 0)); _classPrivateFieldSet2(_next, this, new UintArray(max)); _classPrivateFieldSet2(_prev, this, new UintArray(max)); _classPrivateFieldSet2(_head, this, 0); _classPrivateFieldSet2(_tail, this, 0); _classPrivateFieldSet2(_free, this, Stack.create(max)); _classPrivateFieldSet2(_size, this, 0); _classPrivateFieldSet2(_calculatedSize, this, 0); if (typeof dispose === "function") _classPrivateFieldSet2(_dispose, this, dispose); if (typeof disposeAfter === "function") { _classPrivateFieldSet2(_disposeAfter, this, disposeAfter); _classPrivateFieldSet2(_disposed, this, []); } else { _classPrivateFieldSet2(_disposeAfter, this, void 0); _classPrivateFieldSet2(_disposed, this, void 0); } _classPrivateFieldSet2(_hasDispose, this, !!_classPrivateFieldGet2(_dispose, this)); _classPrivateFieldSet2(_hasDisposeAfter, this, !!_classPrivateFieldGet2(_disposeAfter, this)); this.noDisposeOnSet = !!noDisposeOnSet; this.noUpdateTTL = !!noUpdateTTL; this.noDeleteOnFetchRejection = !!noDeleteOnFetchRejection; this.allowStaleOnFetchRejection = !!allowStaleOnFetchRejection; this.allowStaleOnFetchAbort = !!allowStaleOnFetchAbort; this.ignoreFetchAbort = !!ignoreFetchAbort; if (this.maxEntrySize !== 0) { if (_classPrivateFieldGet2(_maxSize, this) !== 0) { if (!isPosInt(_classPrivateFieldGet2(_maxSize, this))) throw new TypeError("maxSize must be a positive integer if specified"); } if (!isPosInt(this.maxEntrySize)) throw new TypeError("maxEntrySize must be a positive integer if specified"); _assertClassBrand(_LRUCache_brand, this, _initializeSizeTracking).call(this); } this.allowStale = !!allowStale; this.noDeleteOnStaleGet = !!noDeleteOnStaleGet; this.updateAgeOnGet = !!updateAgeOnGet; this.updateAgeOnHas = !!updateAgeOnHas; this.ttlResolution = isPosInt(ttlResolution) || ttlResolution === 0 ? ttlResolution : 1; this.ttlAutopurge = !!ttlAutopurge; this.ttl = ttl || 0; if (this.ttl) { if (!isPosInt(this.ttl)) throw new TypeError("ttl must be a positive integer if specified"); _assertClassBrand(_LRUCache_brand, this, _initializeTTLTracking).call(this); } if (_classPrivateFieldGet2(_max, this) === 0 && this.ttl === 0 && _classPrivateFieldGet2(_maxSize, this) === 0) throw new TypeError("At least one of max, maxSize, or ttl is required"); if (!this.ttlAutopurge && !_classPrivateFieldGet2(_max, this) && !_classPrivateFieldGet2(_maxSize, this)) { const code = "LRU_CACHE_UNBOUNDED"; if (shouldWarn(code)) { warned.add(code); emitWarning("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.", "UnboundedCacheWarning", code, LRUCache); } } } /** * Return the remaining TTL time for a given entry key */ getRemainingTTL(key) { return _classPrivateFieldGet2(_keyMap, this).has(key) ? Infinity : 0; } /** * Return a generator yielding `[key, value]` pairs, * in order from most recently used to least recently used. */ *entries() { for (const i of _assertClassBrand(_LRUCache_brand, this, _indexes).call(this)) if (_classPrivateFieldGet2(_valList, this)[i] !== void 0 && _classPrivateFieldGet2(_keyList, this)[i] !== void 0 && !_assertClassBrand(_LRUCache_brand, this, _isBackgroundFetch).call(this, _classPrivateFieldGet2(_valList, this)[i])) yield [_classPrivateFieldGet2(_keyList, this)[i], _classPrivateFieldGet2(_valList, this)[i]]; } /** * Inverse order version of {@link LRUCache.entries} * * Return a generator yielding `[key, value]` pairs, * in order from least recently used to most recently used. */ *rentries() { for (const i of _assertClassBrand(_LRUCache_brand, this, _rindexes).call(this)) if (_classPrivateFieldGet2(_valList, this)[i] !== void 0 && _classPrivateFieldGet2(_keyList, this)[i] !== void 0 && !_assertClassBrand(_LRUCache_brand, this, _isBackgroundFetch).call(this, _classPrivateFieldGet2(_valList, this)[i])) yield [_classPrivateFieldGet2(_keyList, this)[i], _classPrivateFieldGet2(_valList, this)[i]]; } /** * Return a generator yielding the keys in the cache, * in order from most recently used to least recently used. */ *keys() { for (const i of _assertClassBrand(_LRUCache_brand, this, _indexes).call(this)) { const k = _classPrivateFieldGet2(_keyList, this)[i]; if (k !== void 0 && !_assertClassBrand(_LRUCache_brand, this, _isBackgroundFetch).call(this, _classPrivateFieldGet2(_valList, this)[i])) yield k; } } /** * Inverse order version of {@link LRUCache.keys} * * Return a generator yielding the keys in the cache, * in order from least recently used to most recently used. */ *rkeys() { for (const i of _assertClassBrand(_LRUCache_brand, this, _rindexes).call(this)) { const k = _classPrivateFieldGet2(_keyList, this)[i]; if (k !== void 0 && !_assertClassBrand(_LRUCache_brand, this, _isBackgroundFetch).call(this, _classPrivateFieldGet2(_valList, this)[i])) yield k; } } /** * Return a generator yielding the values in the cache, * in order from most recently used to least recently used. */ *values() { for (const i of _assertClassBrand(_LRUCache_brand, this, _indexes).call(this)) if (_classPrivateFieldGet2(_valList, this)[i] !== void 0 && !_assertClassBrand(_LRUCache_brand, this, _isBackgroundFetch).call(this, _classPrivateFieldGet2(_valList, this)[i])) yield _classPrivateFieldGet2(_valList, this)[i]; } /** * Inverse order version of {@link LRUCache.values} * * Return a generator yielding the values in the cache, * in order from least recently used to most recently used. */ *rvalues() { for (const i of _assertClassBrand(_LRUCache_brand, this, _rindexes).call(this)) if (_classPrivateFieldGet2(_valList, this)[i] !== void 0 && !_assertClassBrand(_LRUCache_brand, this, _isBackgroundFetch).call(this, _classPrivateFieldGet2(_valList, this)[i])) yield _classPrivateFieldGet2(_valList, this)[i]; } /** * Iterating over the cache itself yields the same results as * {@link LRUCache.entries} */ [_Symbol$iterator]() { return this.entries(); } /** * Find a value for which the supplied fn method returns a truthy value, * similar to Array.find(). fn is called as fn(value, key, cache). */ find(fn, getOptions = {}) { for (const i of _assertClassBrand(_LRUCache_brand, this, _indexes).call(this)) { const v = _classPrivateFieldGet2(_valList, this)[i]; const value = _assertClassBrand(_LRUCache_brand, this, _isBackgroundFetch).call(this, v) ? v.__staleWhileFetching : v; if (value === void 0) continue; if (fn(value, _classPrivateFieldGet2(_keyList, this)[i], this)) return this.get(_classPrivateFieldGet2(_keyList, this)[i], getOptions); } } /** * Call the supplied function on each item in the cache, in order from * most recently used to least recently used. fn is called as * fn(value, key, cache). Does not update age or recenty of use. * Does not iterate over stale values. */ forEach(fn, thisp = this) { for (const i of _assertClassBrand(_LRUCache_brand, this, _indexes).call(this)) { const v = _classPrivateFieldGet2(_valList, this)[i]; const value = _assertClassBrand(_LRUCache_brand, this, _isBackgroundFetch).call(this, v) ? v.__staleWhileFetching : v; if (value === void 0) continue; fn.call(thisp, value, _classPrivateFieldGet2(_keyList, this)[i], this); } } /** * The same as {@link LRUCache.forEach} but items are iterated over in * reverse order. (ie, less recently used items are iterated over first.) */ rforEach(fn, thisp = this) { for (const i of _assertClassBrand(_LRUCache_brand, this, _rindexes).call(this)) { const v = _classPrivateFieldGet2(_valList, this)[i]; const value = _assertClassBrand(_LRUCache_brand, this, _isBackgroundFetch).call(this, v) ? v.__staleWhileFetching : v; if (value === void 0) continue; fn.call(thisp, value, _classPrivateFieldGet2(_keyList, this)[i], this); } } /** * Delete any stale entries. Returns true if anything was removed, * false otherwise. */ purgeStale() { let deleted = false; for (const i of _assertClassBrand(_LRUCache_brand, this, _rindexes).call(this, { allowStale: true })) if (_classPrivateFieldGet2(_isStale, this).call(this, i)) { this.delete(_classPrivateFieldGet2(_keyList, this)[i]); deleted = true; } return deleted; } /** * Get the extended info about a given entry, to get its value, size, and * TTL info simultaneously. Like {@link LRUCache#dump}, but just for a * single key. Always returns stale values, if their info is found in the * cache, so be sure to check for expired TTLs if relevant. */ info(key) { const i = _classPrivateFieldGet2(_keyMap, this).get(key); if (i === void 0) return void 0; const v = _classPrivateFieldGet2(_valList, this)[i]; const value = _assertClassBrand(_LRUCache_brand, this, _isBackgroundFetch).call(this, v) ? v.__staleWhileFetching : v; if (value === void 0) return void 0; const entry = { value }; if (_classPrivateFieldGet2(_ttls, this) && _classPrivateFieldGet2(_starts, this)) { const ttl = _classPrivateFieldGet2(_ttls, this)[i]; const start = _classPrivateFieldGet2(_starts, this)[i]; if (ttl && start) { entry.ttl = ttl - (perf.now() - start); entry.start = Date.now(); } } if (_classPrivateFieldGet2(_sizes, this)) entry.size = _classPrivateFieldGet2(_sizes, this)[i]; return entry; } /** * Return an array of [key, {@link LRUCache.Entry}] tuples which can be * passed to cache.load() */ dump() { const arr = []; for (const i of _assertClassBrand(_LRUCache_brand, this, _indexes).call(this, { allowStale: true })) { const key = _classPrivateFieldGet2(_keyList, this)[i]; const v = _classPrivateFieldGet2(_valList, this)[i]; const value = _assertClassBrand(_LRUCache_brand, this, _isBackgroundFetch).call(this, v) ? v.__staleWhileFetching : v; if (value === void 0 || key === void 0) continue; const entry = { value }; if (_classPrivateFieldGet2(_ttls, this) && _classPrivateFieldGet2(_starts, this)) { entry.ttl = _classPrivateFieldGet2(_ttls, this)[i]; const age = perf.now() - _classPrivateFieldGet2(_starts, this)[i]; entry.start = Math.floor(Date.now() - age); } if (_classPrivateFieldGet2(_sizes, this)) entry.size = _classPrivateFieldGet2(_sizes, this)[i]; arr.unshift([key, entry]); } return arr; } /** * Reset the cache and load in the items in entries in the order listed. * Note that the shape of the resulting cache may be different if the * same options are not used in both caches. */ load(arr) { this.clear(); for (const [key, entry] of arr) { if (entry.start) { const age = Date.now() - entry.start; entry.start = perf.now() - age; } this.set(key, entry.value, entry); } } /** * Add a value to the cache. * * Note: if `undefined` is specified as a value, this is an alias for * {@link LRUCache#delete} */ set(k, v, setOptions = {}) { if (v === void 0) { this.delete(k); return this; } const { ttl = this.ttl, start, noDisposeOnSet = this.noDisposeOnSet, sizeCalculation = this.sizeCalculation, status } = setOptions; let { noUpdateTTL = this.noUpdateTTL } = setOptions; const size = _classPrivateFieldGet2(_requireSize, this).call(this, k, v, setOptions.size || 0, sizeCalculation); if (this.maxEntrySize && size > this.maxEntrySize) { if (status) { status.set = "miss"; status.maxEntrySizeExceeded = true; } this.delete(k); return this; } let index = _classPrivateFieldGet2(_size, this) === 0 ? void 0 : _classPrivateFieldGet2(_keyMap, this).get(k); if (index === void 0) { var _this$size; index = _classPrivateFieldGet2(_size, this) === 0 ? _classPrivateFieldGet2(_tail, this) : _classPrivateFieldGet2(_free, this).length !== 0 ? _classPrivateFieldGet2(_free, this).pop() : _classPrivateFieldGet2(_size, this) === _classPrivateFieldGet2(_max, this) ? _assertClassBrand(_LRUCache_brand, this, _evict).call(this, false) : _classPrivateFieldGet2(_size, this); _classPrivateFieldGet2(_keyList, this)[index] = k; _classPrivateFieldGet2(_valList, this)[index] = v; _classPrivateFieldGet2(_keyMap, this).set(k, index); _classPrivateFieldGet2(_next, this)[_classPrivateFieldGet2(_tail, this)] = index; _classPrivateFieldGet2(_prev, this)[index] = _classPrivateFieldGet2(_tail, this); _classPrivateFieldSet2(_tail, this, index); _classPrivateFieldSet2(_size, this, (_this$size = _classPrivateFieldGet2(_size, this), _this$size++, _this$size)); _classPrivateFieldGet2(_addItemSize, this).call(this, index, size, status); if (status) status.set = "add"; noUpdateTTL = false; } else { _assertClassBrand(_LRUCache_brand, this, _moveToTail).call(this, index); const oldVal = _classPrivateFieldGet2(_valList, this)[index]; if (v !== oldVal) { if (_classPrivateFieldGet2(_hasFetchMethod, this) && _assertClassBrand(_LRUCache_brand, this, _isBackgroundFetch).call(this, oldVal)) { oldVal.__abortController.abort(/* @__PURE__ */ new Error("replaced")); const { __staleWhileFetching: s } = oldVal; if (s !== void 0 && !noDisposeOnSet) { if (_classPrivateFieldGet2(_hasDispose, this)) { var _classPrivateFieldGet2$2; (_classPrivateFieldGet2$2 = _classPrivateFieldGet2(_dispose, this)) === null || _classPrivateFieldGet2$2 === void 0 || _classPrivateFieldGet2$2.call(this, s, k, "set"); } if (_classPrivateFieldGet2(_hasDisposeAfter, this)) { var _classPrivateFieldGet3; (_classPrivateFieldGet3 = _classPrivateFieldGet2(_disposed, this)) === null || _classPrivateFieldGet3 === void 0 || _classPrivateFieldGet3.push([ s, k, "set" ]); } } } else if (!noDisposeOnSet) { if (_classPrivateFieldGet2(_hasDispose, this)) { var _classPrivateFieldGet4; (_classPrivateFieldGet4 = _classPrivateFieldGet2(_dispose, this)) === null || _classPrivateFieldGet4 === void 0 || _classPrivateFieldGet4.call(this, oldVal, k, "set"); } if (_classPrivateFieldGet2(_hasDisposeAfter, this)) { var _classPrivateFieldGet5; (_classPrivateFieldGet5 = _classPrivateFieldGet2(_disposed, this)) === null || _classPrivateFieldGet5 === void 0 || _classPrivateFieldGet5.push([ oldVal, k, "set" ]); } } _classPrivateFieldGet2(_removeItemSize, this).call(this, index); _classPrivateFieldGet2(_addItemSize, this).call(this, index, size, status); _classPrivateFieldGet2(_valList, this)[index] = v; if (status) { status.set = "replace"; const oldValue = oldVal && _assertClassBrand(_LRUCache_brand, this, _isBackgroundFetch).call(this, oldVal) ? oldVal.__staleWhileFetching : oldVal; if (oldValue !== void 0) status.oldValue = oldValue; } } else if (status) status.set = "update"; } if (ttl !== 0 && !_classPrivateFieldGet2(_ttls, this)) _assertClassBrand(_LRUCache_brand, this, _initializeTTLTracking).call(this); if (_classPrivateFieldGet2(_ttls, this)) { if (!noUpdateTTL) _classPrivateFieldGet2(_setItemTTL, this).call(this, index, ttl, start); if (status) _classPrivateFieldGet2(_statusTTL, this).call(this, status, index); } if (!noDisposeOnSet && _classPrivateFieldGet2(_hasDisposeAfter, this) && _classPrivateFieldGet2(_disposed, this)) { const dt = _classPrivateFieldGet2(_disposed, this); let task; while (task = dt === null || dt === void 0 ? void 0 : dt.shift()) { var _classPrivateFieldGet6; (_classPrivateFieldGet6 = _classPrivateFieldGet2(_disposeAfter, this)) === null || _classPrivateFieldGet6 === void 0 || _classPrivateFieldGet6.call(this, ...task); } } return this; } /** * Evict the least recently used item, returning its value or * `undefined` if cache is empty. */ pop() { try { while (_classPrivateFieldGet2(_size, this)) { const val = _classPrivateFieldGet2(_valList, this)[_classPrivateFieldGet2(_head, this)]; _assertClassBrand(_LRUCache_brand, this, _evict).call(this, true); if (_assertClassBrand(_LRUCache_brand, this, _isBackgroundFetch).call(this, val)) { if (val.__staleWhileFetching) return val.__staleWhileFetching; } else if (val !== void 0) return val; } } finally { if (_classPrivateFieldGet2(_hasDisposeAfter, this) && _classPrivateFieldGet2(_disposed, this)) { const dt = _classPrivateFieldGet2(_disposed, this); let task; while (task = dt === null || dt === void 0 ? void 0 : dt.shift()) { var _classPrivateFieldGet7; (_classPrivateFieldGet7 = _classPrivateFieldGet2(_disposeAfter, this)) === null || _classPrivateFieldGet7 === void 0 || _classPrivateFieldGet7.call(this, ...task); } } } } /** * Check if a key is in the cache, without updating the recency of use. * Will return false if the item is stale, even though it is technically * in the cache. * * Will not update item age unless * {@link LRUCache.OptionsBase.updateAgeOnHas} is set. */ has(k, hasOptions = {}) { const { updateAgeOnHas = this.updateAgeOnHas, status } = hasOptions; const index = _classPrivateFieldGet2(_keyMap, this).get(k); if (index !== void 0) { const v = _classPrivateFieldGet2(_valList, this)[index]; if (_assertClassBrand(_LRUCache_brand, this, _isBackgroundFetch).call(this, v) && v.__staleWhileFetching === void 0) return false; if (!_classPrivateFieldGet2(_isStale, this).call(this, index)) { if (updateAgeOnHas) _classPrivateFieldGet2(_updateItemAge, this).call(this, index); if (status) { status.has = "hit"; _classPrivateFieldGet2(_statusTTL, this).call(this, status, index); } return true; } else if (status) { status.has = "stale"; _classPrivateFieldGet2(_statusTTL, this).call(this, status, index); } } else if (status) status.has = "miss"; return false; } /** * Like {@link LRUCache#get} but doesn't update recency or delete stale * items. * * Returns `undefined` if the item is stale, unless * {@link LRUCache.OptionsBase.allowStale} is set. */ peek(k, peekOptions = {}) { const { allowStale = this.allowStale } = peekOptions; const index = _classPrivateFieldGet2(_keyMap, this).get(k); if (index === void 0 || !allowStale && _classPrivateFieldGet2(_isStale, this).call(this, index)) return; const v = _classPrivateFieldGet2(_valList, this)[index]; return _assertClassBrand(_LRUCache_brand, this, _isBackgroundFetch).call(this, v) ? v.__staleWhileFetching : v; } async fetch(k, fetchOptions = {}) { const { allowStale = this.allowStale, updateAgeOnGet = this.updateAgeOnGet, noDeleteOnStaleGet = this.noDeleteOnStaleGet, ttl = this.ttl, noDisposeOnSet = this.noDisposeOnSet, size = 0, sizeCalculation = this.sizeCalculation, noUpdateTTL = this.noUpdateTTL, noDeleteOnFetchRejection = this.noDeleteOnFetchRejection, allowStaleOnFetchRejection = this.allowStaleOnFetchRejection, ignoreFetchAbort = this.ignoreFetchAbort, allowStaleOnFetchAbort = this.allowStaleOnFetchAbort, context, forceRefresh = false, status, signal } = fetchOptions; if (!_classPrivateFieldGet2(_hasFetchMethod, this)) { if (status) status.fetch = "get"; return this.get(k, { allowStale, updateAgeOnGet, noDeleteOnStaleGet, status }); } const options = { allowStale, updateAgeOnGet, noDeleteOnStaleGet, ttl, noDisposeOnSet, size, sizeCalculation, noUpdateTTL, noDeleteOnFetchRejection, allowStaleOnFetchRejection, allowStaleOnFetchAbort, ignoreFetchAbort, status, signal }; let index = _classPrivateFieldGet2(_keyMap, this).get(k); if (index === void 0) { if (status) status.fetch = "miss"; const p = _assertClassBrand(_LRUCache_brand, this, _backgroundFetch).call(this, k, index, options, context); return p.__returned = p; } else { const v = _classPrivateFieldGet2(_valList, this)[index]; if (_assertClassBrand(_LRUCache_brand, this, _isBackgroundFetch).call(this, v)) { const stale = allowStale && v.__staleWhileFetching !== void 0; if (status) { status.fetch = "inflight"; if (stale) status.returnedStale = true; } return stale ? v.__staleWhileFetching : v.__returned = v; } const isStale = _classPrivateFieldGet2(_isStale, this).call(this, index); if (!forceRefresh && !isStale) { if (status) status.fetch = "hit"; _assertClassBrand(_LRUCache_brand, this, _moveToTail).call(this, index); if (updateAgeOnGet) _classPrivateFieldGet2(_updateItemAge, this).call(this, index); if (status) _classPrivateFieldGet2(_statusTTL, this).call(this, status, index); return v; } const p = _assertClassBrand(_LRUCache_brand, this, _backgroundFetch).call(this, k, index, options, context); const staleVal = p.__staleWhileFetching !== void 0 && allowStale; if (status) { status.fetch = isStale ? "stale" : "refresh"; if (staleVal && isStale) status.returnedStale = true; } return staleVal ? p.__staleWhileFetching : p.__returned = p; } } /** * Return a value from the cache. Will update the recency of the cache * entry found. * * If the key is not found, get() will return `undefined`. */ get(k, getOptions = {}) { const { allowStale = this.allowStale, updateAgeOnGet = this.updateAgeOnGet, noDeleteOnStaleGet = this.noDeleteOnStaleGet, status } = getOptions; const index = _classPrivateFieldGet2(_keyMap, this).get(k); if (index !== void 0) { const value = _classPrivateFieldGet2(_valList, this)[index]; const fetching = _assertClassBrand(_LRUCache_brand, this, _isBackgroundFetch).call(this, value); if (status) _classPrivateFieldGet2(_statusTTL, this).call(this, status, index); if (_classPrivateFieldGet2(_isStale, this).call(this, index)) { if (status) status.get = "stale"; if (!fetching) { if (!noDeleteOnStaleGet) this.delete(k); if (status && allowStale) status.returnedStale = true; return allowStale ? value : void 0; } else { if (status && allowStale && value.__staleWhileFetching !== void 0) status.returnedStale = true; return allowStale ? value.__staleWhileFetching : void 0; } } else { if (status) status.get = "hit"; if (fetching) return value.__staleWhileFetching; _assertClassBrand(_LRUCache_brand, this, _moveToTail).call(this, index); if (updateAgeOnGet) _classPrivateFieldGet2(_updateItemAge, this).call(this, index); return value; } } else if (status) status.get = "miss"; } /** * Deletes a key out of the cache. * Returns true if the key was deleted, false otherwise. */ delete(k) { var _classPrivateFieldGet13; let deleted = false; if (_classPrivateFieldGet2(_size, this) !== 0) { const index = _classPrivateFieldGet2(_keyMap, this).get(k); if (index !== void 0) { deleted = true; if (_classPrivateFieldGet2(_size, this) === 1) this.clear(); else { var _this$size5; _classPrivateFieldGet2(_removeItemSize, this).call(this, index); const v = _classPrivateFieldGet2(_valList, this)[index]; if (_assertClassBrand(_LRUCache_brand, this, _isBackgroundFetch).call(this, v)) v.__abortController.abort(/* @__PURE__ */ new Error("deleted")); else if (_classPrivateFieldGet2(_hasDispose, this) || _classPrivateFieldGet2(_hasDisposeAfter, this)) { if (_classPrivateFieldGet2(_hasDispose, this)) { var _classPrivateFieldGet11; (_classPrivateFieldGet11 = _classPrivateFieldGet2(_dispose, this)) === null || _classPrivateFieldGet11 === void 0 || _classPrivateFieldGet11.call(this, v, k, "delete"); } if (_classPrivateFieldGet2(_hasDisposeAfter, this)) { var _classPrivateFieldGet12; (_classPrivateFieldGet12 = _classPrivateFieldGet2(_disposed, this)) === null || _classPrivateFieldGet12 === void 0 || _classPrivateFieldGet12.push([ v, k, "delete" ]); } } _classPrivateFieldGet2(_keyMap, this).delete(k); _classPrivateFieldGet2(_keyList, this)[index] = void 0; _classPrivateFieldGet2(_valList, this)[index] = void 0; if (index === _classPrivateFieldGet2(_tail, this)) _classPrivateFieldSet2(_tail, this, _classPrivateFieldGet2(_prev, this)[index]); else if (index === _classPrivateFieldGet2(_head, this)) _classPrivateFieldSet2(_head, this, _classPrivateFieldGet2(_next, this)[index]); else { const pi = _classPrivateFieldGet2(_prev, this)[index]; _classPrivateFieldGet2(_next, this)[pi] = _classPrivateFieldGet2(_next, this)[index]; const ni = _classPrivateFieldGet2(_next, this)[index]; _classPrivateFieldGet2(_prev, this)[ni] = _classPrivateFieldGet2(_prev, this)[index]; } _classPrivateFieldSet2(_size, this, (_this$size5 = _classPrivateFieldGet2(_size, this), _this$size5--, _this$size5)); _classPrivateFieldGet2(_free, this).push(index); } } } if (_classPrivateFieldGet2(_hasDisposeAfter, this) && ((_classPrivateFieldGet13 = _classPrivateFieldGet2(_disposed, this)) === null || _classPrivateFieldGet13 === void 0 ? void 0 : _classPrivateFieldGet13.length)) { const dt = _classPrivateFieldGet2(_disposed, this); let task; while (task = dt === null || dt === void 0 ? void 0 : dt.shift()) { var _classPrivateFieldGet14; (_classPrivateFieldGet14 = _classPrivateFieldGet2(_disposeAfter, this)) === null || _classPrivateFieldGet14 === void 0 || _classPrivateFieldGet14.call(this, ...task); } } return deleted; } /** * Clear the cache entirely, throwing away all values. */ clear() { for (const index of _assertClassBrand(_LRUCache_brand, this, _rindexes).call(this, { allowStale: true })) { const v = _classPrivateFieldGet2(_valList, this)[index]; if (_assertClassBrand(_LRUCache_brand, this, _isBackgroundFetch).call(this, v)) v.__abortController.abort(/* @__PURE__ */ new Error("deleted")); else { const k = _classPrivateFieldGet2(_keyList, this)[index]; if (_classPrivateFieldGet2(_hasDispose, this)) { var _classPrivateFieldGet15; (_classPrivateFieldGet15 = _classPrivateFieldGet2(_dispose, this)) === null || _classPrivateFieldGet15 === void 0 || _classPrivateFieldGet15.call(this, v, k, "delete"); } if (_classPrivateFieldGet2(_hasDisposeAfter, this)) { var _classPrivateFieldGet16; (_classPrivateFieldGet16 = _classPrivateFieldGet2(_disposed, this)) === null || _classPrivateFieldGet16 === void 0 || _classPrivateFieldGet16.push([ v, k, "delete" ]); } } } _classPrivateFieldGet2(_keyMap, this).clear(); _classPrivateFieldGet2(_valList, this).fill(void 0); _classPrivateFieldGet2(_keyList, this).fill(void 0); if (_classPrivateFieldGet2(_ttls, this) && _classPrivateFieldGet2(_starts, this)) { _classPrivateFieldGet2(_ttls, this).fill(0); _classPrivateFieldGet2(_starts, this).fill(0); } if (_classPrivateFieldGet2(_sizes, this)) _classPrivateFieldGet2(_sizes, this).fill(0); _classPrivateFieldSet2(_head, this, 0); _classPrivateFieldSet2(_tail, this, 0); _classPrivateFieldGet2(_free, this).length = 0; _classPrivateFieldSet2(_calculatedSize, this, 0); _classPrivateFieldSet2(_size, this, 0); if (_classPrivateFieldGet2(_hasDisposeAfter, this) && _classPrivateFieldGet2(_disposed, this)) { const dt = _classPrivateFieldGet2(_disposed, this); let task; while (task = dt === null || dt === void 0 ? void 0 : dt.shift()) { var _classPrivateFieldGet17; (_classPrivateFieldGet17 = _classPrivateFieldGet2(_disposeAfter, this)) === null || _classPrivateFieldGet17 === void 0 || _classPrivateFieldGet17.call(this, ...task); } } } }; function _initializeTTLTracking() { const ttls = new ZeroArray(_classPrivateFieldGet2(_max, this)); const starts = new ZeroArray(_classPrivateFieldGet2(_max, this)); _classPrivateFieldSet2(_ttls, this, ttls); _classPrivateFieldSet2(_starts, this, starts); _classPrivateFieldSet2(_setItemTTL, this, (index, ttl, start = perf.now()) => { starts[index] = ttl !== 0 ? start : 0; ttls[index] = ttl; if (ttl !== 0 && this.ttlAutopurge) { const t = setTimeout(() => { if (_classPrivateFieldGet2(_isStale, this).call(this, index)) this.delete(_classPrivateFieldGet2(_keyList, this)[index]); }, ttl + 1); /* c8 ignore start */ if (t.unref) t.unref(); } }); _classPrivateFieldSet2(_updateItemAge, this, (index) => { starts[index] = ttls[index] !== 0 ? perf.now() : 0; }); _classPrivateFieldSet2(_statusTTL, this, (status, index) => { if (ttls[index]) { const ttl = ttls[index]; const start = starts[index]; /* c8 ignore next */ if (!ttl || !start) return; status.ttl = ttl; status.start = start; status.now = cachedNow || getNow(); status.remainingTTL = ttl - (status.now - start); } }); let cachedNow = 0; const getNow = () => { const n = perf.now(); if (this.ttlResolution > 0) { cachedNow = n; const t = setTimeout(() => cachedNow = 0, this.ttlResolution); /* c8 ignore start */ if (t.unref) t.unref(); } return n; }; this.getRemainingTTL = (key) => { const index = _classPrivateFieldGet2(_keyMap, this).get(key); if (index === void 0) return 0; const ttl = ttls[index]; const start = starts[index]; if (!ttl || !start) return Infinity; return ttl - ((cachedNow || getNow()) - start); }; _classPrivateFieldSet2(_isStale, this, (index) => { const s = starts[index]; const t = ttls[index]; return !!t && !!s && (cachedNow || getNow()) - s > t; }); } function _initializeSizeTracking() { const sizes = new ZeroArray(_classPrivateFieldGet2(_max, this)); _classPrivateFieldSet2(_calculatedSize, this, 0); _classPrivateFieldSet2(_sizes, this, sizes); _classPrivateFieldSet2(_removeItemSize, this, (index) => { _classPrivateFieldSet2(_calculatedSize, this, _classPrivateFieldGet2(_calculatedSize, this) - sizes[index]); sizes[index] = 0; }); _classPrivateFieldSet2(_requireSize, this, (k, v, size, sizeCalculation) => { if (_assertClassBrand(_LRUCache_brand, this, _isBackgroundFetch).call(this, v)) return 0; if (!isPosInt(size)) { if (sizeCalculation) { if (typeof sizeCalculation !== "function") throw new TypeError("sizeCalculation must be a function"); size = sizeCalculation(v, k); if (!isPosInt(size)) throw new TypeError("sizeCalculation return invalid (expect positive integer)"); } else throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set."); } return size; }); _classPrivateFieldSet2(_addItemSize, this, (index, size, status) => { sizes[index] = size; if (_classPrivateFieldGet2(_maxSize, this)) { const maxSize = _classPrivateFieldGet2(_maxSize, this) - sizes[index]; while (_classPrivateFieldGet2(_calculatedSize, this) > maxSize) _assertClassBrand(_LRUCache_brand, this, _evict).call(this, true); } _classPrivateFieldSet2(_calculatedSize, this, _classPrivateFieldGet2(_calculatedSize, this) + sizes[index]); if (status) { status.entrySize = size; status.totalCalculatedSize = _classPrivateFieldGet2(_calculatedSize, this); } }); } function* _indexes({ allowStale = this.allowStale } = {}) { if (_classPrivateFieldGet2(_size, this)) for (let i = _classPrivateFieldGet2(_tail, this);;) { if (!_assertClassBrand(_LRUCache_brand, this, _isValidIndex).call(this, i)) break; if (allowStale || !_classPrivateFieldGet2(_isStale, this).call(this, i)) yield i; if (i === _classPrivateFieldGet2(_head, this)) break; else i = _classPrivateFieldGet2(_prev, this)[i]; } } function* _rindexes({ allowStale = this.allowStale } = {}) { if (_classPrivateFieldGet2(_size, this)) for (let i = _classPrivateFieldGet2(_head, this);;) { if (!_assertClassBrand(_LRUCache_brand, this, _isValidIndex).call(this, i)) break; if (allowStale || !_classPrivateFieldGet2(_isStale, this).call(this, i)) yield i; if (i === _classPrivateFieldGet2(_tail, this)) break; else i = _classPrivateFieldGet2(_next, this)[i]; } } function _isValidIndex(index) { return index !== void 0 && _classPrivateFieldGet2(_keyMap, this).get(_classPrivateFieldGet2(_keyList, this)[index]) === index; } function _evict(free) { var _this$size3; const head = _classPrivateFieldGet2(_head, this); const k = _classPrivateFieldGet2(_keyList, this)[head]; const v = _classPrivateFieldGet2(_valList, this)[head]; if (_classPrivateFieldGet2(_hasFetchMethod, this) && _assertClassBrand(_LRUCache_brand, this, _isBackgroundFetch).call(this, v)) v.__abortController.abort(/* @__PURE__ */ new Error("evicted")); else if (_classPrivateFieldGet2(_hasDispose, this) || _classPrivateFieldGet2(_hasDisposeAfter, this)) { if (_classPrivateFieldGet2(_hasDispose, this)) { var _classPrivateFieldGet8; (_classPrivateFieldGet8 = _classPrivateFieldGet2(_dispose, this)) === null || _classPrivateFieldGet8 === void 0 || _classPrivateFieldGet8.call(this, v, k, "evict"); } if (_classPrivateFieldGet2(_hasDisposeAfter, this)) { var _classPrivateFieldGet9; (_classPrivateFieldGet9 = _classPrivateFieldGet2(_disposed, this)) === null || _classPrivateFieldGet9 === void 0 || _classPrivateFieldGet9.push([ v, k, "evict" ]); } } _classPrivateFieldGet2(_removeItemSize, this).call(this, head); if (free) { _classPrivateFieldGet2(_keyList, this)[head] = void 0; _classPrivateFieldGet2(_valList, this)[head] = void 0; _classPrivateFieldGet2(_free, this).push(head); } if (_classPrivateFieldGet2(_size, this) === 1) { _classPrivateFieldSet2(_head, this, _classPrivateFieldSet2(_tail, this, 0)); _classPrivateFieldGet2(_free, this).length = 0; } else _classPrivateFieldSet2(_head, this, _classPrivateFieldGet2(_next, this)[head]); _classPrivateFieldGet2(_keyMap, this).delete(k); _classPrivateFieldSet2(_size, this, (_this$size3 = _classPrivateFieldGet2(_size, this), _this$size3--, _this$size3)); return head; } function _backgroundFetch(k, index, options, context) { const v = index === void 0 ? void 0 : _classPrivateFieldGet2(_valList, this)[index]; if (_assertClassBrand(_LRUCache_brand, this, _isBackgroundFetch).call(this, v)) return v; const ac = new AC(); const { signal } = options; signal === null || signal === void 0 || signal.addEventListener("abort", () => ac.abort(signal.reason), { signal: ac.signal }); const fetchOpts = { signal: ac.signal, options, context }; const cb = (v, updateCache = false) => { const { aborted } = ac.signal; const ignoreAbort = options.ignoreFetchAbort && v !== void 0; if (options.status) { if (aborted && !updateCache) { options.status.fetchAborted = true; options.status.fetchError = ac.signal.reason; if (ignoreAbort) options.status.fetchAbortIgnored = true; } else options.status.fetchResolved = true; } if (aborted && !ignoreAbort && !updateCache) return fetchFail(ac.signal.reason); const bf = p; if (_classPrivateFieldGet2(_valList, this)[index] === p) { if (v === void 0) { if (bf.__staleWhileFetching) _classPrivateFieldGet2(_valList, this)[index] = bf.__staleWhileFetching; else this.delete(k); } else { if (options.status) options.status.fetchUpdated = true; this.set(k, v, fetchOpts.options); } } return v; }; const eb = (er) => { if (options.status) { options.status.fetchRejected = true; options.status.fetchError = er; } return fetchFail(er); }; const fetchFail = (er) => { const { aborted } = ac.signal; const allowStaleAborted = aborted && options.allowStaleOnFetchAbort; const allowStale = allowStaleAborted || options.allowStaleOnFetchRejection; const noDelete = allowStale || options.noDeleteOnFetchRejection; const bf = p; if (_classPrivateFieldGet2(_valList, this)[index] === p) { if (!noDelete || bf.__staleWhileFetching === void 0) this.delete(k); else if (!allowStaleAborted) _classPrivateFieldGet2(_valList, this)[index] = bf.__staleWhileFetching; } if (allowStale) { if (options.status && bf.__staleWhileFetching !== void 0) options.status.returnedStale = true; return bf.__staleWhileFetching; } else if (bf.__returned === bf) throw er; }; const pcall = (res, rej) => { var _classPrivateFieldGet10; const fmp = (_classPrivateFieldGet10 = _classPrivateFieldGet2(_fetchMethod, this)) === null || _classPrivateFieldGet10 === void 0 ? void 0 : _classPrivateFieldGet10.call(this, k, v, fetchOpts); if (fmp && fmp instanceof Promise) fmp.then((v) => res(v === void 0 ? void 0 : v), rej); ac.signal.addEventListener("abort", () => { if (!options.ignoreFetchAbort || options.allowStaleOnFetchAbort) { res(void 0); if (options.allowStaleOnFetchAbort) res = (v) => cb(v, true); } }); }; if (options.status) options.status.fetchDispatched = true; const p = new Promise(pcall).then(cb, eb); const bf = Object.assign(p, { __abortController: ac, __staleWhileFetching: v, __returned: void 0 }); if (index === void 0) { this.set(k, bf, { ...fetchOpts.options, status: void 0 }); index = _classPrivateFieldGet2(_keyMap, this).get(k); } else _classPrivateFieldGet2(_valList, this)[index] = bf; return bf; } function _isBackgroundFetch(p) { if (!_classPrivateFieldGet2(_hasFetchMethod, this)) return false; const b = p; return !!b && b instanceof Promise && b.hasOwnProperty("__staleWhileFetching") && b.__abortController instanceof AC; } function _connect(p, n) { _classPrivateFieldGet2(_prev, this)[n] = p; _classPrivateFieldGet2(_next, this)[p] = n; } function _moveToTail(index) { if (index !== _classPrivateFieldGet2(_tail, this)) { if (index === _classPrivateFieldGet2(_head, this)) _classPrivateFieldSet2(_head, this, _classPrivateFieldGet2(_next, this)[index]); else _assertClassBrand(_LRUCache_brand, this, _connect).call(this, _classPrivateFieldGet2(_prev, this)[index], _classPrivateFieldGet2(_next, this)[index]); _assertClassBrand(_LRUCache_brand, this, _connect).call(this, _classPrivateFieldGet2(_tail, this), index); _classPrivateFieldSet2(_tail, this, index); } } //#endregion //#region packages/compiler-sfc/src/cache.ts function createCache(max = 500) { return new LRUCache({ max }); } //#endregion //#region packages/compiler-sfc/src/template/resolveTemplateAST.ts function resolveTemplateAST(inAST, options) { if (!(inAST === null || inAST === void 0 ? void 0 : inAST.transformed)) return inAST; const { compiler = _vue_compiler_dom, compilerOptions, ssr, onError } = options; const template = (ssr ? _vue_compiler_dom : compiler).parse(inAST.source, { prefixIdentifiers: true, ...compilerOptions, parseMode: "sfc", onError }).children.find((node) => node.type === 1 && node.tag === "template"); return (0, _vue_compiler_core.createRoot)(template.children, inAST.source); } //#endregion //#region packages/compiler-sfc/src/script/importUsageCheck.ts /** * Check if an identifier is used in the SFC's template. * - 1.used to determine the properties that should be included in the object returned from setup() * when not using inline mode. * - 2.check whether the built-in properties such as $attrs, $slots, $emit are used in the template */ function isUsedInTemplate(identifier, sfc, options) { return resolveTemplateUsedIdentifiers(sfc, options).has(identifier); } const templateAnalysisCache = createCache(); function resolveTemplateVModelIdentifiers(sfc, options) { return resolveTemplateAnalysisResult(sfc, false, options).vModelIds; } function resolveTemplateUsedIdentifiers(sfc, options) { return resolveTemplateAnalysisResult(sfc, true, options).usedIds; } function resolveTemplateAnalysisResult(sfc, collectUsedIds = true, options) { const { content, ast } = sfc.template; const cached = templateAnalysisCache.get(content); if (cached && (!collectUsedIds || cached.usedIds)) return cached; const ids = collectUsedIds ? /* @__PURE__ */ new Set() : void 0; const vModelIds = /* @__PURE__ */ new Set(); resolveTemplateAST(ast, { compiler: options === null || options === void 0 ? void 0 : options.compiler, compilerOptions: options === null || options === void 0 ? void 0 : options.compilerOptions, ssr: options === null || options === void 0 ? void 0 : options.ssr, onError: () => {} }).children.forEach(walk); function walk(node) { switch (node.type) { case 1: let tag = node.tag; if (tag.includes(".")) tag = tag.split(".")[0].trim(); if (!_vue_compiler_dom.parserOptions.isNativeTag(tag) && !_vue_compiler_dom.parserOptions.isBuiltInComponent(tag)) { if (ids) { ids.add((0, _vue_shared.camelize)(tag)); ids.add((0, _vue_shared.capitalize)((0, _vue_shared.camelize)(tag))); } } for (let i = 0; i < node.props.length; i++) { var _prop$value; const prop = node.props[i]; if (prop.type === 7) { if (ids) { if (!(0, _vue_shared.isBuiltInDirective)(prop.name)) ids.add(`v${(0, _vue_shared.capitalize)((0, _vue_shared.camelize)(prop.name))}`); } if (prop.name === "model") { const exp = prop.exp; if (exp && exp.type === 4) { const expString = exp.content.trim(); if ((0, _vue_compiler_dom.isSimpleIdentifier)(expString) && expString !== "undefined") vModelIds.add(expString); } } if (ids && prop.arg && !prop.arg.isStatic) extractIdentifiers$2(ids, prop.arg); if (ids) { if (prop.name === "for") extractIdentifiers$2(ids, prop.forParseResult.source); else if (prop.exp) extractIdentifiers$2(ids, prop.exp); else if (prop.name === "bind" && !prop.exp) ids.add((0, _vue_shared.camelize)(prop.arg.content)); } } if (ids && prop.type === 6 && prop.name === "ref" && ((_prop$value = prop.value) === null || _prop$value === void 0 ? void 0 : _prop$value.content)) ids.add(prop.value.content); } node.children.forEach(walk); break; case 5: if (ids) extractIdentifiers$2(ids, node.content); } } const result = { usedIds: ids, vModelIds }; templateAnalysisCache.set(content, result); return result; } function extractIdentifiers$2(ids, node) { if (node.ast) (0, _vue_compiler_dom.walkIdentifiers)(node.ast, (n) => ids.add(n.name)); else if (node.ast === null) ids.add(node.content); } //#endregion //#region packages/compiler-sfc/src/parse.ts const DEFAULT_FILENAME = "anonymous.vue"; const parseCache$1 = createCache(); function parse(source, options = {}) { var _options$compiler; const sourceKey = (0, _vue_shared.genCacheKey)(source, { ...options, compiler: { parse: (_options$compiler = options.compiler) === null || _options$compiler === void 0 ? void 0 : _options$compiler.parse } }); const cache = parseCache$1.get(sourceKey); if (cache) return cache; const { sourceMap = true, filename = DEFAULT_FILENAME, sourceRoot = "", pad = false, ignoreEmpty = true, compiler = _vue_compiler_dom, templateParseOptions = {} } = options; const descriptor = { filename, source, template: null, script: null, scriptSetup: null, styles: [], customBlocks: [], cssVars: [], slotted: false, vapor: false, shouldForceReload: (prevImports) => hmrShouldReload(prevImports, descriptor) }; const errors = []; compiler.parse(source, { parseMode: "sfc", prefixIdentifiers: true, ...templateParseOptions, onError: (e) => { errors.push(e); } }).children.forEach((node) => { if (node.type !== 1) return; if (ignoreEmpty && node.tag !== "template" && isEmpty(node) && !hasAttr(node, "src")) { descriptor.vapor || (descriptor.vapor = hasAttr(node, "vapor")); return; } switch (node.tag) { case "template": if (!descriptor.template) { const templateBlock = descriptor.template = createBlock(node, source, false); descriptor.vapor || (descriptor.vapor = !!templateBlock.attrs.vapor); if (!templateBlock.attrs.src) templateBlock.ast = (0, _vue_compiler_core.createRoot)(node.children, source); if (templateBlock.attrs.functional) { const err = /* @__PURE__ */ new SyntaxError("