@storybook/core
Version:
Storybook framework-agnostic API
1,391 lines (1,379 loc) • 159 kB
JavaScript
import ESM_COMPAT_Module from "node:module";
import { fileURLToPath as ESM_COMPAT_fileURLToPath } from 'node:url';
import { dirname as ESM_COMPAT_dirname } from 'node:path';
const __filename = ESM_COMPAT_fileURLToPath(import.meta.url);
const __dirname = ESM_COMPAT_dirname(__filename);
const require = ESM_COMPAT_Module.createRequire(import.meta.url);
var gs = Object.create;
var qt = Object.defineProperty;
var ws = Object.getOwnPropertyDescriptor;
var ys = Object.getOwnPropertyNames;
var bs = Object.getPrototypeOf, Ss = Object.prototype.hasOwnProperty;
var l = (n, t) => qt(n, "name", { value: t, configurable: !0 });
var me = (n, t) => () => (t || n((t = { exports: {} }).exports, t), t.exports);
var Es = (n, t, e, s) => {
if (t && typeof t == "object" || typeof t == "function")
for (let i of ys(t))
!Ss.call(n, i) && i !== e && qt(n, i, { get: () => t[i], enumerable: !(s = ws(t, i)) || s.enumerable });
return n;
};
var xs = (n, t, e) => (e = n != null ? gs(bs(n)) : {}, Es(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
t || !n || !n.__esModule ? qt(e, "default", { value: n, enumerable: !0 }) : e,
n
));
// ../node_modules/balanced-match/index.js
var Se = me((tr, be) => {
"use strict";
be.exports = we;
function we(n, t, e) {
n instanceof RegExp && (n = ge(n, e)), t instanceof RegExp && (t = ge(t, e));
var s = ye(n, t, e);
return s && {
start: s[0],
end: s[1],
pre: e.slice(0, s[0]),
body: e.slice(s[0] + n.length, s[1]),
post: e.slice(s[1] + t.length)
};
}
l(we, "balanced");
function ge(n, t) {
var e = t.match(n);
return e ? e[0] : null;
}
l(ge, "maybeMatch");
we.range = ye;
function ye(n, t, e) {
var s, i, r, o, h, a = e.indexOf(n), c = e.indexOf(t, a + 1), f = a;
if (a >= 0 && c > 0) {
if (n === t)
return [a, c];
for (s = [], r = e.length; f >= 0 && !h; )
f == a ? (s.push(f), a = e.indexOf(n, f + 1)) : s.length == 1 ? h = [s.pop(), c] : (i = s.pop(), i < r && (r = i, o = c), c = e.indexOf(
t, f + 1)), f = a < c && a >= 0 ? a : c;
s.length && (h = [r, o]);
}
return h;
}
l(ye, "range");
});
// ../node_modules/brace-expansion/index.js
var Re = me((sr, Ae) => {
var Ee = Se();
Ae.exports = Cs;
var xe = "\0SLASH" + Math.random() + "\0", ve = "\0OPEN" + Math.random() + "\0", Vt = "\0CLOSE" + Math.random() + "\0", Te = "\0COMMA" + Math.
random() + "\0", Ce = "\0PERIOD" + Math.random() + "\0";
function Kt(n) {
return parseInt(n, 10) == n ? parseInt(n, 10) : n.charCodeAt(0);
}
l(Kt, "numeric");
function vs(n) {
return n.split("\\\\").join(xe).split("\\{").join(ve).split("\\}").join(Vt).split("\\,").join(Te).split("\\.").join(Ce);
}
l(vs, "escapeBraces");
function Ts(n) {
return n.split(xe).join("\\").split(ve).join("{").split(Vt).join("}").split(Te).join(",").split(Ce).join(".");
}
l(Ts, "unescapeBraces");
function ke(n) {
if (!n)
return [""];
var t = [], e = Ee("{", "}", n);
if (!e)
return n.split(",");
var s = e.pre, i = e.body, r = e.post, o = s.split(",");
o[o.length - 1] += "{" + i + "}";
var h = ke(r);
return r.length && (o[o.length - 1] += h.shift(), o.push.apply(o, h)), t.push.apply(t, o), t;
}
l(ke, "parseCommaParts");
function Cs(n) {
return n ? (n.substr(0, 2) === "{}" && (n = "\\{\\}" + n.substr(2)), ct(vs(n), !0).map(Ts)) : [];
}
l(Cs, "expandTop");
function ks(n) {
return "{" + n + "}";
}
l(ks, "embrace");
function As(n) {
return /^-?0\d/.test(n);
}
l(As, "isPadded");
function Rs(n, t) {
return n <= t;
}
l(Rs, "lte");
function Ds(n, t) {
return n >= t;
}
l(Ds, "gte");
function ct(n, t) {
var e = [], s = Ee("{", "}", n);
if (!s) return [n];
var i = s.pre, r = s.post.length ? ct(s.post, !1) : [""];
if (/\$$/.test(s.pre))
for (var o = 0; o < r.length; o++) {
var h = i + "{" + s.body + "}" + r[o];
e.push(h);
}
else {
var a = /^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(s.body), c = /^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(s.body), f = a || c, u = s.body.
indexOf(",") >= 0;
if (!f && !u)
return s.post.match(/,.*\}/) ? (n = s.pre + "{" + s.body + Vt + s.post, ct(n)) : [n];
var d;
if (f)
d = s.body.split(/\.\./);
else if (d = ke(s.body), d.length === 1 && (d = ct(d[0], !1).map(ks), d.length === 1))
return r.map(function(kt) {
return s.pre + d[0] + kt;
});
var p;
if (f) {
var w = Kt(d[0]), m = Kt(d[1]), y = Math.max(d[0].length, d[1].length), g = d.length == 3 ? Math.abs(Kt(d[2])) : 1, E = Rs, S = m < w;
S && (g *= -1, E = Ds);
var b = d.some(As);
p = [];
for (var x = w; E(x, m); x += g) {
var T;
if (c)
T = String.fromCharCode(x), T === "\\" && (T = "");
else if (T = String(x), b) {
var j = y - T.length;
if (j > 0) {
var J = new Array(j + 1).join("0");
x < 0 ? T = "-" + J + T.slice(1) : T = J + T;
}
}
p.push(T);
}
} else {
p = [];
for (var I = 0; I < d.length; I++)
p.push.apply(p, ct(d[I], !1));
}
for (var I = 0; I < p.length; I++)
for (var o = 0; o < r.length; o++) {
var h = i + p[I] + r[o];
(!t || f || h) && e.push(h);
}
}
return e;
}
l(ct, "expand");
});
// src/core-server/utils/remove-mdx-entries.ts
import { isAbsolute as ds, join as pe, relative as Yi } from "node:path";
import { commonGlobOptions as Ji, normalizeStories as Zi } from "@storybook/core/common";
// ../node_modules/glob/node_modules/minimatch/dist/esm/index.js
var Pe = xs(Re(), 1);
// ../node_modules/glob/node_modules/minimatch/dist/esm/assert-valid-pattern.js
var ft = /* @__PURE__ */ l((n) => {
if (typeof n != "string")
throw new TypeError("invalid pattern");
if (n.length > 65536)
throw new TypeError("pattern is too long");
}, "assertValidPattern");
// ../node_modules/glob/node_modules/minimatch/dist/esm/brace-expressions.js
var Os = {
"[:alnum:]": ["\\p{L}\\p{Nl}\\p{Nd}", !0],
"[:alpha:]": ["\\p{L}\\p{Nl}", !0],
"[:ascii:]": ["\\x00-\\x7f", !1],
"[:blank:]": ["\\p{Zs}\\t", !0],
"[:cntrl:]": ["\\p{Cc}", !0],
"[:digit:]": ["\\p{Nd}", !0],
"[:graph:]": ["\\p{Z}\\p{C}", !0, !0],
"[:lower:]": ["\\p{Ll}", !0],
"[:print:]": ["\\p{C}", !0],
"[:punct:]": ["\\p{P}", !0],
"[:space:]": ["\\p{Z}\\t\\r\\n\\v\\f", !0],
"[:upper:]": ["\\p{Lu}", !0],
"[:word:]": ["\\p{L}\\p{Nl}\\p{Nd}\\p{Pc}", !0],
"[:xdigit:]": ["A-Fa-f0-9", !1]
}, ut = /* @__PURE__ */ l((n) => n.replace(/[[\]\\-]/g, "\\$&"), "braceEscape"), Fs = /* @__PURE__ */ l((n) => n.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,
"\\$&"), "regexpEscape"), De = /* @__PURE__ */ l((n) => n.join(""), "rangesToString"), Oe = /* @__PURE__ */ l((n, t) => {
let e = t;
if (n.charAt(e) !== "[")
throw new Error("not in a brace expression");
let s = [], i = [], r = e + 1, o = !1, h = !1, a = !1, c = !1, f = e, u = "";
t: for (; r < n.length; ) {
let m = n.charAt(r);
if ((m === "!" || m === "^") && r === e + 1) {
c = !0, r++;
continue;
}
if (m === "]" && o && !a) {
f = r + 1;
break;
}
if (o = !0, m === "\\" && !a) {
a = !0, r++;
continue;
}
if (m === "[" && !a) {
for (let [y, [g, E, S]] of Object.entries(Os))
if (n.startsWith(y, r)) {
if (u)
return ["$.", !1, n.length - e, !0];
r += y.length, S ? i.push(g) : s.push(g), h = h || E;
continue t;
}
}
if (a = !1, u) {
m > u ? s.push(ut(u) + "-" + ut(m)) : m === u && s.push(ut(m)), u = "", r++;
continue;
}
if (n.startsWith("-]", r + 1)) {
s.push(ut(m + "-")), r += 2;
continue;
}
if (n.startsWith("-", r + 1)) {
u = m, r += 2;
continue;
}
s.push(ut(m)), r++;
}
if (f < r)
return ["", !1, 0, !1];
if (!s.length && !i.length)
return ["$.", !1, n.length - e, !0];
if (i.length === 0 && s.length === 1 && /^\\?.$/.test(s[0]) && !c) {
let m = s[0].length === 2 ? s[0].slice(-1) : s[0];
return [Fs(m), !1, f - e, !1];
}
let d = "[" + (c ? "^" : "") + De(s) + "]", p = "[" + (c ? "" : "^") + De(i) + "]";
return [s.length && i.length ? "(" + d + "|" + p + ")" : s.length ? d : p, h, f - e, !0];
}, "parseClass");
// ../node_modules/glob/node_modules/minimatch/dist/esm/unescape.js
var z = /* @__PURE__ */ l((n, { windowsPathsNoEscape: t = !1 } = {}) => t ? n.replace(/\[([^\/\\])\]/g, "$1") : n.replace(/((?!\\).|^)\[([^\/\\])\]/g,
"$1$2").replace(/\\([^\/])/g, "$1"), "unescape");
// ../node_modules/glob/node_modules/minimatch/dist/esm/ast.js
var Ms = /* @__PURE__ */ new Set(["!", "?", "+", "*", "@"]), Fe = /* @__PURE__ */ l((n) => Ms.has(n), "isExtglobType"), _s = "(?!(?:^|/)\\.\\.\
?(?:$|/))", At = "(?!\\.)", Ns = /* @__PURE__ */ new Set(["[", "."]), Ls = /* @__PURE__ */ new Set(["..", "."]), Ps = new Set("().*{}+?[]^$\\\
!"), Ws = /* @__PURE__ */ l((n) => n.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"), "regExpEscape"), Xt = "[^/]", Me = Xt + "*?", _e = Xt + "+\
?", tt = class n {
static {
l(this, "AST");
}
type;
#t;
#e;
#n = !1;
#i = [];
#o;
#S;
#l;
#f = !1;
#h;
#a;
// set to true if it's an extglob with no children
// (which really means one child of '')
#r = !1;
constructor(t, e, s = {}) {
this.type = t, t && (this.#e = !0), this.#o = e, this.#t = this.#o ? this.#o.#t : this, this.#h = this.#t === this ? s : this.#t.#h, this.#l =
this.#t === this ? [] : this.#t.#l, t === "!" && !this.#t.#f && this.#l.push(this), this.#S = this.#o ? this.#o.#i.length : 0;
}
get hasMagic() {
if (this.#e !== void 0)
return this.#e;
for (let t of this.#i)
if (typeof t != "string" && (t.type || t.hasMagic))
return this.#e = !0;
return this.#e;
}
// reconstructs the pattern
toString() {
return this.#a !== void 0 ? this.#a : this.type ? this.#a = this.type + "(" + this.#i.map((t) => String(t)).join("|") + ")" : this.#a = this.#i.
map((t) => String(t)).join("");
}
#g() {
if (this !== this.#t)
throw new Error("should only call on root");
if (this.#f)
return this;
this.toString(), this.#f = !0;
let t;
for (; t = this.#l.pop(); ) {
if (t.type !== "!")
continue;
let e = t, s = e.#o;
for (; s; ) {
for (let i = e.#S + 1; !s.type && i < s.#i.length; i++)
for (let r of t.#i) {
if (typeof r == "string")
throw new Error("string part in extglob AST??");
r.copyIn(s.#i[i]);
}
e = s, s = e.#o;
}
}
return this;
}
push(...t) {
for (let e of t)
if (e !== "") {
if (typeof e != "string" && !(e instanceof n && e.#o === this))
throw new Error("invalid part: " + e);
this.#i.push(e);
}
}
toJSON() {
let t = this.type === null ? this.#i.slice().map((e) => typeof e == "string" ? e : e.toJSON()) : [this.type, ...this.#i.map((e) => e.toJSON())];
return this.isStart() && !this.type && t.unshift([]), this.isEnd() && (this === this.#t || this.#t.#f && this.#o?.type === "!") && t.push(
{}), t;
}
isStart() {
if (this.#t === this)
return !0;
if (!this.#o?.isStart())
return !1;
if (this.#S === 0)
return !0;
let t = this.#o;
for (let e = 0; e < this.#S; e++) {
let s = t.#i[e];
if (!(s instanceof n && s.type === "!"))
return !1;
}
return !0;
}
isEnd() {
if (this.#t === this || this.#o?.type === "!")
return !0;
if (!this.#o?.isEnd())
return !1;
if (!this.type)
return this.#o?.isEnd();
let t = this.#o ? this.#o.#i.length : 0;
return this.#S === t - 1;
}
copyIn(t) {
typeof t == "string" ? this.push(t) : this.push(t.clone(this));
}
clone(t) {
let e = new n(this.type, t);
for (let s of this.#i)
e.copyIn(s);
return e;
}
static #w(t, e, s, i) {
let r = !1, o = !1, h = -1, a = !1;
if (e.type === null) {
let p = s, w = "";
for (; p < t.length; ) {
let m = t.charAt(p++);
if (r || m === "\\") {
r = !r, w += m;
continue;
}
if (o) {
p === h + 1 ? (m === "^" || m === "!") && (a = !0) : m === "]" && !(p === h + 2 && a) && (o = !1), w += m;
continue;
} else if (m === "[") {
o = !0, h = p, a = !1, w += m;
continue;
}
if (!i.noext && Fe(m) && t.charAt(p) === "(") {
e.push(w), w = "";
let y = new n(m, e);
p = n.#w(t, y, p, i), e.push(y);
continue;
}
w += m;
}
return e.push(w), p;
}
let c = s + 1, f = new n(null, e), u = [], d = "";
for (; c < t.length; ) {
let p = t.charAt(c++);
if (r || p === "\\") {
r = !r, d += p;
continue;
}
if (o) {
c === h + 1 ? (p === "^" || p === "!") && (a = !0) : p === "]" && !(c === h + 2 && a) && (o = !1), d += p;
continue;
} else if (p === "[") {
o = !0, h = c, a = !1, d += p;
continue;
}
if (Fe(p) && t.charAt(c) === "(") {
f.push(d), d = "";
let w = new n(p, f);
f.push(w), c = n.#w(t, w, c, i);
continue;
}
if (p === "|") {
f.push(d), d = "", u.push(f), f = new n(null, e);
continue;
}
if (p === ")")
return d === "" && e.#i.length === 0 && (e.#r = !0), f.push(d), d = "", e.push(...u, f), c;
d += p;
}
return e.type = null, e.#e = void 0, e.#i = [t.substring(s - 1)], c;
}
static fromGlob(t, e = {}) {
let s = new n(null, void 0, e);
return n.#w(t, s, 0, e), s;
}
// returns the regular expression if there's magic, or the unescaped
// string if not.
toMMPattern() {
if (this !== this.#t)
return this.#t.toMMPattern();
let t = this.toString(), [e, s, i, r] = this.toRegExpSource();
if (!(i || this.#e || this.#h.nocase && !this.#h.nocaseMagicOnly && t.toUpperCase() !== t.toLowerCase()))
return s;
let h = (this.#h.nocase ? "i" : "") + (r ? "u" : "");
return Object.assign(new RegExp(`^${e}$`, h), {
_src: e,
_glob: t
});
}
get options() {
return this.#h;
}
// returns the string match, the regexp source, whether there's magic
// in the regexp (so a regular expression is required) and whether or
// not the uflag is needed for the regular expression (for posix classes)
// TODO: instead of injecting the start/end at this point, just return
// the BODY of the regexp, along with the start/end portions suitable
// for binding the start/end in either a joined full-path makeRe context
// (where we bind to (^|/), or a standalone matchPart context (where
// we bind to ^, and not /). Otherwise slashes get duped!
//
// In part-matching mode, the start is:
// - if not isStart: nothing
// - if traversal possible, but not allowed: ^(?!\.\.?$)
// - if dots allowed or not possible: ^
// - if dots possible and not allowed: ^(?!\.)
// end is:
// - if not isEnd(): nothing
// - else: $
//
// In full-path matching mode, we put the slash at the START of the
// pattern, so start is:
// - if first pattern: same as part-matching mode
// - if not isStart(): nothing
// - if traversal possible, but not allowed: /(?!\.\.?(?:$|/))
// - if dots allowed or not possible: /
// - if dots possible and not allowed: /(?!\.)
// end is:
// - if last pattern, same as part-matching mode
// - else nothing
//
// Always put the (?:$|/) on negated tails, though, because that has to be
// there to bind the end of the negated pattern portion, and it's easier to
// just stick it in now rather than try to inject it later in the middle of
// the pattern.
//
// We can just always return the same end, and leave it up to the caller
// to know whether it's going to be used joined or in parts.
// And, if the start is adjusted slightly, can do the same there:
// - if not isStart: nothing
// - if traversal possible, but not allowed: (?:/|^)(?!\.\.?$)
// - if dots allowed or not possible: (?:/|^)
// - if dots possible and not allowed: (?:/|^)(?!\.)
//
// But it's better to have a simpler binding without a conditional, for
// performance, so probably better to return both start options.
//
// Then the caller just ignores the end if it's not the first pattern,
// and the start always gets applied.
//
// But that's always going to be $ if it's the ending pattern, or nothing,
// so the caller can just attach $ at the end of the pattern when building.
//
// So the todo is:
// - better detect what kind of start is needed
// - return both flavors of starting pattern
// - attach $ at the end of the pattern when creating the actual RegExp
//
// Ah, but wait, no, that all only applies to the root when the first pattern
// is not an extglob. If the first pattern IS an extglob, then we need all
// that dot prevention biz to live in the extglob portions, because eg
// +(*|.x*) can match .xy but not .yx.
//
// So, return the two flavors if it's #root and the first child is not an
// AST, otherwise leave it to the child AST to handle it, and there,
// use the (?:^|/) style of start binding.
//
// Even simplified further:
// - Since the start for a join is eg /(?!\.) and the start for a part
// is ^(?!\.), we can just prepend (?!\.) to the pattern (either root
// or start or whatever) and prepend ^ or / at the Regexp construction.
toRegExpSource(t) {
let e = t ?? !!this.#h.dot;
if (this.#t === this && this.#g(), !this.type) {
let a = this.isStart() && this.isEnd(), c = this.#i.map((p) => {
let [w, m, y, g] = typeof p == "string" ? n.#u(p, this.#e, a) : p.toRegExpSource(t);
return this.#e = this.#e || y, this.#n = this.#n || g, w;
}).join(""), f = "";
if (this.isStart() && typeof this.#i[0] == "string" && !(this.#i.length === 1 && Ls.has(this.#i[0]))) {
let w = Ns, m = (
// dots are allowed, and the pattern starts with [ or .
e && w.has(c.charAt(0)) || // the pattern starts with \., and then [ or .
c.startsWith("\\.") && w.has(c.charAt(2)) || // the pattern starts with \.\., and then [ or .
c.startsWith("\\.\\.") && w.has(c.charAt(4))
), y = !e && !t && w.has(c.charAt(0));
f = m ? _s : y ? At : "";
}
let u = "";
return this.isEnd() && this.#t.#f && this.#o?.type === "!" && (u = "(?:$|\\/)"), [
f + c + u,
z(c),
this.#e = !!this.#e,
this.#n
];
}
let s = this.type === "*" || this.type === "+", i = this.type === "!" ? "(?:(?!(?:" : "(?:", r = this.#d(e);
if (this.isStart() && this.isEnd() && !r && this.type !== "!") {
let a = this.toString();
return this.#i = [a], this.type = null, this.#e = void 0, [a, z(this.toString()), !1, !1];
}
let o = !s || t || e || !At ? "" : this.#d(!0);
o === r && (o = ""), o && (r = `(?:${r})(?:${o})*?`);
let h = "";
if (this.type === "!" && this.#r)
h = (this.isStart() && !e ? At : "") + _e;
else {
let a = this.type === "!" ? (
// !() must match something,but !(x) can match ''
"))" + (this.isStart() && !e && !t ? At : "") + Me + ")"
) : this.type === "@" ? ")" : this.type === "?" ? ")?" : this.type === "+" && o ? ")" : this.type === "*" && o ? ")?" : `)${this.type}`;
h = i + r + a;
}
return [
h,
z(r),
this.#e = !!this.#e,
this.#n
];
}
#d(t) {
return this.#i.map((e) => {
if (typeof e == "string")
throw new Error("string type in extglob ast??");
let [s, i, r, o] = e.toRegExpSource(t);
return this.#n = this.#n || o, s;
}).filter((e) => !(this.isStart() && this.isEnd()) || !!e).join("|");
}
static #u(t, e, s = !1) {
let i = !1, r = "", o = !1;
for (let h = 0; h < t.length; h++) {
let a = t.charAt(h);
if (i) {
i = !1, r += (Ps.has(a) ? "\\" : "") + a;
continue;
}
if (a === "\\") {
h === t.length - 1 ? r += "\\\\" : i = !0;
continue;
}
if (a === "[") {
let [c, f, u, d] = Oe(t, h);
if (u) {
r += c, o = o || f, h += u - 1, e = e || d;
continue;
}
}
if (a === "*") {
s && t === "*" ? r += _e : r += Me, e = !0;
continue;
}
if (a === "?") {
r += Xt, e = !0;
continue;
}
r += Ws(a);
}
return [r, z(t), !!e, o];
}
};
// ../node_modules/glob/node_modules/minimatch/dist/esm/escape.js
var et = /* @__PURE__ */ l((n, { windowsPathsNoEscape: t = !1 } = {}) => t ? n.replace(/[?*()[\]]/g, "[$&]") : n.replace(/[?*()[\]\\]/g, "\\$\
&"), "escape");
// ../node_modules/glob/node_modules/minimatch/dist/esm/index.js
var F = /* @__PURE__ */ l((n, t, e = {}) => (ft(t), !e.nocomment && t.charAt(0) === "#" ? !1 : new _(t, e).match(n)), "minimatch"), js = /^\*+([^+@!?\*\[\(]*)$/,
Is = /* @__PURE__ */ l((n) => (t) => !t.startsWith(".") && t.endsWith(n), "starDotExtTest"), zs = /* @__PURE__ */ l((n) => (t) => t.endsWith(
n), "starDotExtTestDot"), Bs = /* @__PURE__ */ l((n) => (n = n.toLowerCase(), (t) => !t.startsWith(".") && t.toLowerCase().endsWith(n)), "st\
arDotExtTestNocase"), Us = /* @__PURE__ */ l((n) => (n = n.toLowerCase(), (t) => t.toLowerCase().endsWith(n)), "starDotExtTestNocaseDot"), $s = /^\*+\.\*+$/,
Gs = /* @__PURE__ */ l((n) => !n.startsWith(".") && n.includes("."), "starDotStarTest"), Hs = /* @__PURE__ */ l((n) => n !== "." && n !== ".\
." && n.includes("."), "starDotStarTestDot"), qs = /^\.\*+$/, Ks = /* @__PURE__ */ l((n) => n !== "." && n !== ".." && n.startsWith("."), "d\
otStarTest"), Vs = /^\*+$/, Xs = /* @__PURE__ */ l((n) => n.length !== 0 && !n.startsWith("."), "starTest"), Ys = /* @__PURE__ */ l((n) => n.
length !== 0 && n !== "." && n !== "..", "starTestDot"), Js = /^\?+([^+@!?\*\[\(]*)?$/, Zs = /* @__PURE__ */ l(([n, t = ""]) => {
let e = We([n]);
return t ? (t = t.toLowerCase(), (s) => e(s) && s.toLowerCase().endsWith(t)) : e;
}, "qmarksTestNocase"), Qs = /* @__PURE__ */ l(([n, t = ""]) => {
let e = je([n]);
return t ? (t = t.toLowerCase(), (s) => e(s) && s.toLowerCase().endsWith(t)) : e;
}, "qmarksTestNocaseDot"), ti = /* @__PURE__ */ l(([n, t = ""]) => {
let e = je([n]);
return t ? (s) => e(s) && s.endsWith(t) : e;
}, "qmarksTestDot"), ei = /* @__PURE__ */ l(([n, t = ""]) => {
let e = We([n]);
return t ? (s) => e(s) && s.endsWith(t) : e;
}, "qmarksTest"), We = /* @__PURE__ */ l(([n]) => {
let t = n.length;
return (e) => e.length === t && !e.startsWith(".");
}, "qmarksTestNoExt"), je = /* @__PURE__ */ l(([n]) => {
let t = n.length;
return (e) => e.length === t && e !== "." && e !== "..";
}, "qmarksTestNoExtDot"), Ie = typeof process == "object" && process ? typeof process.env == "object" && process.env && process.env.__MINIMATCH_TESTING_PLATFORM__ ||
process.platform : "posix", Ne = {
win32: { sep: "\\" },
posix: { sep: "/" }
}, si = Ie === "win32" ? Ne.win32.sep : Ne.posix.sep;
F.sep = si;
var R = Symbol("globstar **");
F.GLOBSTAR = R;
var ii = "[^/]", ri = ii + "*?", ni = "(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?", oi = "(?:(?!(?:\\/|^)\\.).)*?", hi = /* @__PURE__ */ l((n, t = {}) => (e) => F(
e, n, t), "filter");
F.filter = hi;
var L = /* @__PURE__ */ l((n, t = {}) => Object.assign({}, n, t), "ext"), ai = /* @__PURE__ */ l((n) => {
if (!n || typeof n != "object" || !Object.keys(n).length)
return F;
let t = F;
return Object.assign(/* @__PURE__ */ l((s, i, r = {}) => t(s, i, L(n, r)), "m"), {
Minimatch: class extends t.Minimatch {
static {
l(this, "Minimatch");
}
constructor(i, r = {}) {
super(i, L(n, r));
}
static defaults(i) {
return t.defaults(L(n, i)).Minimatch;
}
},
AST: class extends t.AST {
static {
l(this, "AST");
}
/* c8 ignore start */
constructor(i, r, o = {}) {
super(i, r, L(n, o));
}
/* c8 ignore stop */
static fromGlob(i, r = {}) {
return t.AST.fromGlob(i, L(n, r));
}
},
unescape: /* @__PURE__ */ l((s, i = {}) => t.unescape(s, L(n, i)), "unescape"),
escape: /* @__PURE__ */ l((s, i = {}) => t.escape(s, L(n, i)), "escape"),
filter: /* @__PURE__ */ l((s, i = {}) => t.filter(s, L(n, i)), "filter"),
defaults: /* @__PURE__ */ l((s) => t.defaults(L(n, s)), "defaults"),
makeRe: /* @__PURE__ */ l((s, i = {}) => t.makeRe(s, L(n, i)), "makeRe"),
braceExpand: /* @__PURE__ */ l((s, i = {}) => t.braceExpand(s, L(n, i)), "braceExpand"),
match: /* @__PURE__ */ l((s, i, r = {}) => t.match(s, i, L(n, r)), "match"),
sep: t.sep,
GLOBSTAR: R
});
}, "defaults");
F.defaults = ai;
var ze = /* @__PURE__ */ l((n, t = {}) => (ft(n), t.nobrace || !/\{(?:(?!\{).)*\}/.test(n) ? [n] : (0, Pe.default)(n)), "braceExpand");
F.braceExpand = ze;
var li = /* @__PURE__ */ l((n, t = {}) => new _(n, t).makeRe(), "makeRe");
F.makeRe = li;
var ci = /* @__PURE__ */ l((n, t, e = {}) => {
let s = new _(t, e);
return n = n.filter((i) => s.match(i)), s.options.nonull && !n.length && n.push(t), n;
}, "match");
F.match = ci;
var Le = /[?*]|[+@!]\(.*?\)|\[|\]/, fi = /* @__PURE__ */ l((n) => n.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"), "regExpEscape"), _ = class {
static {
l(this, "Minimatch");
}
options;
set;
pattern;
windowsPathsNoEscape;
nonegate;
negate;
comment;
empty;
preserveMultipleSlashes;
partial;
globSet;
globParts;
nocase;
isWindows;
platform;
windowsNoMagicRoot;
regexp;
constructor(t, e = {}) {
ft(t), e = e || {}, this.options = e, this.pattern = t, this.platform = e.platform || Ie, this.isWindows = this.platform === "win32", this.
windowsPathsNoEscape = !!e.windowsPathsNoEscape || e.allowWindowsEscape === !1, this.windowsPathsNoEscape && (this.pattern = this.pattern.
replace(/\\/g, "/")), this.preserveMultipleSlashes = !!e.preserveMultipleSlashes, this.regexp = null, this.negate = !1, this.nonegate = !!e.
nonegate, this.comment = !1, this.empty = !1, this.partial = !!e.partial, this.nocase = !!this.options.nocase, this.windowsNoMagicRoot =
e.windowsNoMagicRoot !== void 0 ? e.windowsNoMagicRoot : !!(this.isWindows && this.nocase), this.globSet = [], this.globParts = [], this.
set = [], this.make();
}
hasMagic() {
if (this.options.magicalBraces && this.set.length > 1)
return !0;
for (let t of this.set)
for (let e of t)
if (typeof e != "string")
return !0;
return !1;
}
debug(...t) {
}
make() {
let t = this.pattern, e = this.options;
if (!e.nocomment && t.charAt(0) === "#") {
this.comment = !0;
return;
}
if (!t) {
this.empty = !0;
return;
}
this.parseNegate(), this.globSet = [...new Set(this.braceExpand())], e.debug && (this.debug = (...r) => console.error(...r)), this.debug(
this.pattern, this.globSet);
let s = this.globSet.map((r) => this.slashSplit(r));
this.globParts = this.preprocess(s), this.debug(this.pattern, this.globParts);
let i = this.globParts.map((r, o, h) => {
if (this.isWindows && this.windowsNoMagicRoot) {
let a = r[0] === "" && r[1] === "" && (r[2] === "?" || !Le.test(r[2])) && !Le.test(r[3]), c = /^[a-z]:/i.test(r[0]);
if (a)
return [...r.slice(0, 4), ...r.slice(4).map((f) => this.parse(f))];
if (c)
return [r[0], ...r.slice(1).map((f) => this.parse(f))];
}
return r.map((a) => this.parse(a));
});
if (this.debug(this.pattern, i), this.set = i.filter((r) => r.indexOf(!1) === -1), this.isWindows)
for (let r = 0; r < this.set.length; r++) {
let o = this.set[r];
o[0] === "" && o[1] === "" && this.globParts[r][2] === "?" && typeof o[3] == "string" && /^[a-z]:$/i.test(o[3]) && (o[2] = "?");
}
this.debug(this.pattern, this.set);
}
// various transforms to equivalent pattern sets that are
// faster to process in a filesystem walk. The goal is to
// eliminate what we can, and push all ** patterns as far
// to the right as possible, even if it increases the number
// of patterns that we have to process.
preprocess(t) {
if (this.options.noglobstar)
for (let s = 0; s < t.length; s++)
for (let i = 0; i < t[s].length; i++)
t[s][i] === "**" && (t[s][i] = "*");
let { optimizationLevel: e = 1 } = this.options;
return e >= 2 ? (t = this.firstPhasePreProcess(t), t = this.secondPhasePreProcess(t)) : e >= 1 ? t = this.levelOneOptimize(t) : t = this.
adjascentGlobstarOptimize(t), t;
}
// just get rid of adjascent ** portions
adjascentGlobstarOptimize(t) {
return t.map((e) => {
let s = -1;
for (; (s = e.indexOf("**", s + 1)) !== -1; ) {
let i = s;
for (; e[i + 1] === "**"; )
i++;
i !== s && e.splice(s, i - s);
}
return e;
});
}
// get rid of adjascent ** and resolve .. portions
levelOneOptimize(t) {
return t.map((e) => (e = e.reduce((s, i) => {
let r = s[s.length - 1];
return i === "**" && r === "**" ? s : i === ".." && r && r !== ".." && r !== "." && r !== "**" ? (s.pop(), s) : (s.push(i), s);
}, []), e.length === 0 ? [""] : e));
}
levelTwoFileOptimize(t) {
Array.isArray(t) || (t = this.slashSplit(t));
let e = !1;
do {
if (e = !1, !this.preserveMultipleSlashes) {
for (let i = 1; i < t.length - 1; i++) {
let r = t[i];
i === 1 && r === "" && t[0] === "" || (r === "." || r === "") && (e = !0, t.splice(i, 1), i--);
}
t[0] === "." && t.length === 2 && (t[1] === "." || t[1] === "") && (e = !0, t.pop());
}
let s = 0;
for (; (s = t.indexOf("..", s + 1)) !== -1; ) {
let i = t[s - 1];
i && i !== "." && i !== ".." && i !== "**" && (e = !0, t.splice(s - 1, 2), s -= 2);
}
} while (e);
return t.length === 0 ? [""] : t;
}
// First phase: single-pattern processing
// <pre> is 1 or more portions
// <rest> is 1 or more portions
// <p> is any portion other than ., .., '', or **
// <e> is . or ''
//
// **/.. is *brutal* for filesystem walking performance, because
// it effectively resets the recursive walk each time it occurs,
// and ** cannot be reduced out by a .. pattern part like a regexp
// or most strings (other than .., ., and '') can be.
//
// <pre>/**/../<p>/<p>/<rest> -> {<pre>/../<p>/<p>/<rest>,<pre>/**/<p>/<p>/<rest>}
// <pre>/<e>/<rest> -> <pre>/<rest>
// <pre>/<p>/../<rest> -> <pre>/<rest>
// **/**/<rest> -> **/<rest>
//
// **/*/<rest> -> */**/<rest> <== not valid because ** doesn't follow
// this WOULD be allowed if ** did follow symlinks, or * didn't
firstPhasePreProcess(t) {
let e = !1;
do {
e = !1;
for (let s of t) {
let i = -1;
for (; (i = s.indexOf("**", i + 1)) !== -1; ) {
let o = i;
for (; s[o + 1] === "**"; )
o++;
o > i && s.splice(i + 1, o - i);
let h = s[i + 1], a = s[i + 2], c = s[i + 3];
if (h !== ".." || !a || a === "." || a === ".." || !c || c === "." || c === "..")
continue;
e = !0, s.splice(i, 1);
let f = s.slice(0);
f[i] = "**", t.push(f), i--;
}
if (!this.preserveMultipleSlashes) {
for (let o = 1; o < s.length - 1; o++) {
let h = s[o];
o === 1 && h === "" && s[0] === "" || (h === "." || h === "") && (e = !0, s.splice(o, 1), o--);
}
s[0] === "." && s.length === 2 && (s[1] === "." || s[1] === "") && (e = !0, s.pop());
}
let r = 0;
for (; (r = s.indexOf("..", r + 1)) !== -1; ) {
let o = s[r - 1];
if (o && o !== "." && o !== ".." && o !== "**") {
e = !0;
let a = r === 1 && s[r + 1] === "**" ? ["."] : [];
s.splice(r - 1, 2, ...a), s.length === 0 && s.push(""), r -= 2;
}
}
}
} while (e);
return t;
}
// second phase: multi-pattern dedupes
// {<pre>/*/<rest>,<pre>/<p>/<rest>} -> <pre>/*/<rest>
// {<pre>/<rest>,<pre>/<rest>} -> <pre>/<rest>
// {<pre>/**/<rest>,<pre>/<rest>} -> <pre>/**/<rest>
//
// {<pre>/**/<rest>,<pre>/**/<p>/<rest>} -> <pre>/**/<rest>
// ^-- not valid because ** doens't follow symlinks
secondPhasePreProcess(t) {
for (let e = 0; e < t.length - 1; e++)
for (let s = e + 1; s < t.length; s++) {
let i = this.partsMatch(t[e], t[s], !this.preserveMultipleSlashes);
if (i) {
t[e] = [], t[s] = i;
break;
}
}
return t.filter((e) => e.length);
}
partsMatch(t, e, s = !1) {
let i = 0, r = 0, o = [], h = "";
for (; i < t.length && r < e.length; )
if (t[i] === e[r])
o.push(h === "b" ? e[r] : t[i]), i++, r++;
else if (s && t[i] === "**" && e[r] === t[i + 1])
o.push(t[i]), i++;
else if (s && e[r] === "**" && t[i] === e[r + 1])
o.push(e[r]), r++;
else if (t[i] === "*" && e[r] && (this.options.dot || !e[r].startsWith(".")) && e[r] !== "**") {
if (h === "b")
return !1;
h = "a", o.push(t[i]), i++, r++;
} else if (e[r] === "*" && t[i] && (this.options.dot || !t[i].startsWith(".")) && t[i] !== "**") {
if (h === "a")
return !1;
h = "b", o.push(e[r]), i++, r++;
} else
return !1;
return t.length === e.length && o;
}
parseNegate() {
if (this.nonegate)
return;
let t = this.pattern, e = !1, s = 0;
for (let i = 0; i < t.length && t.charAt(i) === "!"; i++)
e = !e, s++;
s && (this.pattern = t.slice(s)), this.negate = e;
}
// set partial to true to test if, for example,
// "/a/b" matches the start of "/*/b/*/d"
// Partial means, if you run out of file before you run
// out of pattern, then that's fine, as long as all
// the parts match.
matchOne(t, e, s = !1) {
let i = this.options;
if (this.isWindows) {
let m = typeof t[0] == "string" && /^[a-z]:$/i.test(t[0]), y = !m && t[0] === "" && t[1] === "" && t[2] === "?" && /^[a-z]:$/i.test(t[3]),
g = typeof e[0] == "string" && /^[a-z]:$/i.test(e[0]), E = !g && e[0] === "" && e[1] === "" && e[2] === "?" && typeof e[3] == "string" &&
/^[a-z]:$/i.test(e[3]), S = y ? 3 : m ? 0 : void 0, b = E ? 3 : g ? 0 : void 0;
if (typeof S == "number" && typeof b == "number") {
let [x, T] = [t[S], e[b]];
x.toLowerCase() === T.toLowerCase() && (e[b] = x, b > S ? e = e.slice(b) : S > b && (t = t.slice(S)));
}
}
let { optimizationLevel: r = 1 } = this.options;
r >= 2 && (t = this.levelTwoFileOptimize(t)), this.debug("matchOne", this, { file: t, pattern: e }), this.debug("matchOne", t.length, e.
length);
for (var o = 0, h = 0, a = t.length, c = e.length; o < a && h < c; o++, h++) {
this.debug("matchOne loop");
var f = e[h], u = t[o];
if (this.debug(e, f, u), f === !1)
return !1;
if (f === R) {
this.debug("GLOBSTAR", [e, f, u]);
var d = o, p = h + 1;
if (p === c) {
for (this.debug("** at the end"); o < a; o++)
if (t[o] === "." || t[o] === ".." || !i.dot && t[o].charAt(0) === ".")
return !1;
return !0;
}
for (; d < a; ) {
var w = t[d];
if (this.debug(`
globstar while`, t, d, e, p, w), this.matchOne(t.slice(d), e.slice(p), s))
return this.debug("globstar found match!", d, a, w), !0;
if (w === "." || w === ".." || !i.dot && w.charAt(0) === ".") {
this.debug("dot detected!", t, d, e, p);
break;
}
this.debug("globstar swallow a segment, and continue"), d++;
}
return !!(s && (this.debug(`
>>> no match, partial?`, t, d, e, p), d === a));
}
let m;
if (typeof f == "string" ? (m = u === f, this.debug("string match", f, u, m)) : (m = f.test(u), this.debug("pattern match", f, u, m)),
!m)
return !1;
}
if (o === a && h === c)
return !0;
if (o === a)
return s;
if (h === c)
return o === a - 1 && t[o] === "";
throw new Error("wtf?");
}
braceExpand() {
return ze(this.pattern, this.options);
}
parse(t) {
ft(t);
let e = this.options;
if (t === "**")
return R;
if (t === "")
return "";
let s, i = null;
(s = t.match(Vs)) ? i = e.dot ? Ys : Xs : (s = t.match(js)) ? i = (e.nocase ? e.dot ? Us : Bs : e.dot ? zs : Is)(s[1]) : (s = t.match(Js)) ?
i = (e.nocase ? e.dot ? Qs : Zs : e.dot ? ti : ei)(s) : (s = t.match($s)) ? i = e.dot ? Hs : Gs : (s = t.match(qs)) && (i = Ks);
let r = tt.fromGlob(t, this.options).toMMPattern();
return i && typeof r == "object" && Reflect.defineProperty(r, "test", { value: i }), r;
}
makeRe() {
if (this.regexp || this.regexp === !1)
return this.regexp;
let t = this.set;
if (!t.length)
return this.regexp = !1, this.regexp;
let e = this.options, s = e.noglobstar ? ri : e.dot ? ni : oi, i = new Set(e.nocase ? ["i"] : []), r = t.map((a) => {
let c = a.map((f) => {
if (f instanceof RegExp)
for (let u of f.flags.split(""))
i.add(u);
return typeof f == "string" ? fi(f) : f === R ? R : f._src;
});
return c.forEach((f, u) => {
let d = c[u + 1], p = c[u - 1];
f !== R || p === R || (p === void 0 ? d !== void 0 && d !== R ? c[u + 1] = "(?:\\/|" + s + "\\/)?" + d : c[u] = s : d === void 0 ? c[u -
1] = p + "(?:\\/|" + s + ")?" : d !== R && (c[u - 1] = p + "(?:\\/|\\/" + s + "\\/)" + d, c[u + 1] = R));
}), c.filter((f) => f !== R).join("/");
}).join("|"), [o, h] = t.length > 1 ? ["(?:", ")"] : ["", ""];
r = "^" + o + r + h + "$", this.negate && (r = "^(?!" + r + ").+$");
try {
this.regexp = new RegExp(r, [...i].join(""));
} catch {
this.regexp = !1;
}
return this.regexp;
}
slashSplit(t) {
return this.preserveMultipleSlashes ? t.split("/") : this.isWindows && /^\/\/[^\/]+/.test(t) ? ["", ...t.split(/\/+/)] : t.split(/\/+/);
}
match(t, e = this.partial) {
if (this.debug("match", t, this.pattern), this.comment)
return !1;
if (this.empty)
return t === "";
if (t === "/" && e)
return !0;
let s = this.options;
this.isWindows && (t = t.split("\\").join("/"));
let i = this.slashSplit(t);
this.debug(this.pattern, "split", i);
let r = this.set;
this.debug(this.pattern, "set", r);
let o = i[i.length - 1];
if (!o)
for (let h = i.length - 2; !o && h >= 0; h--)
o = i[h];
for (let h = 0; h < r.length; h++) {
let a = r[h], c = i;
if (s.matchBase && a.length === 1 && (c = [o]), this.matchOne(c, a, e))
return s.flipNegate ? !0 : !this.negate;
}
return s.flipNegate ? !1 : this.negate;
}
static defaults(t) {
return F.defaults(t).Minimatch;
}
};
F.AST = tt;
F.Minimatch = _;
F.escape = et;
F.unescape = z;
// ../node_modules/glob/dist/esm/glob.js
import { fileURLToPath as $i } from "node:url";
// ../node_modules/lru-cache/dist/esm/index.js
var st = typeof performance == "object" && performance && typeof performance.now == "function" ? performance : Date, Ue = /* @__PURE__ */ new Set(),
Yt = typeof process == "object" && process ? process : {}, $e = /* @__PURE__ */ l((n, t, e, s) => {
typeof Yt.emitWarning == "function" ? Yt.emitWarning(n, t, e, s) : console.error(`[${e}] ${t}: ${n}`);
}, "emitWarning"), Rt = globalThis.AbortController, Be = globalThis.AbortSignal;
if (typeof Rt > "u") {
Be = class {
static {
l(this, "AbortSignal");
}
onabort;
_onabort = [];
reason;
aborted = !1;
addEventListener(s, i) {
this._onabort.push(i);
}
}, Rt = class {
static {
l(this, "AbortController");
}
constructor() {
t();
}
signal = new Be();
abort(s) {
if (!this.signal.aborted) {
this.signal.reason = s, this.signal.aborted = !0;
for (let i of this.signal._onabort)
i(s);
this.signal.onabort?.(s);
}
}
};
let n = Yt.env?.LRU_CACHE_IGNORE_AC_WARNING !== "1", t = /* @__PURE__ */ l(() => {
n && (n = !1, $e("AbortController is not defined. If using lru-cache in node 14, load an AbortController polyfill from the `node-abort-c\
ontroller` package. A minimal polyfill is provided for use by LRUCache.fetch(), but it should not be relied upon in other contexts (eg, pass\
ing it to other APIs that use AbortController/AbortSignal might have undesirable effects). You may disable this with LRU_CACHE_IGNORE_AC_WAR\
NING=1 in the env.", "NO_ABORT_CONTROLLER", "ENOTSUP", t));
}, "warnACPolyfill");
}
var ui = /* @__PURE__ */ l((n) => !Ue.has(n), "shouldWarn"), Dr = Symbol("type"), V = /* @__PURE__ */ l((n) => n && n === Math.floor(n) && n >
0 && isFinite(n), "isPosInt"), Ge = /* @__PURE__ */ l((n) => V(n) ? n <= Math.pow(2, 8) ? Uint8Array : n <= Math.pow(2, 16) ? Uint16Array : n <=
Math.pow(2, 32) ? Uint32Array : n <= Number.MAX_SAFE_INTEGER ? it : null : null, "getUintArray"), it = class extends Array {
static {
l(this, "ZeroArray");
}
constructor(t) {
super(t), this.fill(0);
}
}, Jt = class n {
static {
l(this, "Stack");
}
heap;
length;
// private constructor
static #t = !1;
static create(t) {
let e = Ge(t);
if (!e)
return [];
n.#t = !0;
let s = new n(t, e);
return n.#t = !1, s;
}
constructor(t, e) {
if (!n.#t)
throw new TypeError("instantiate Stack using Stack.create(n)");
this.heap = new e(t), this.length = 0;
}
push(t) {
this.heap[this.length++] = t;
}
pop() {
return this.heap[--this.length];
}
}, dt = class n {
static {
l(this, "LRUCache");
}
// options that cannot be changed without disaster
#t;
#e;
#n;
#i;
#o;
#S;
/**
* {@link LRUCache.OptionsBase.ttl}
*/
ttl;
/**
* {@link LRUCache.OptionsBase.ttlResolution}
*/
ttlResolution;
/**
* {@link LRUCache.OptionsBase.ttlAutopurge}
*/
ttlAutopurge;
/**
* {@link LRUCache.OptionsBase.updateAgeOnGet}
*/
updateAgeOnGet;
/**
* {@link LRUCache.OptionsBase.updateAgeOnHas}
*/
updateAgeOnHas;
/**
* {@link LRUCache.OptionsBase.allowStale}
*/
allowStale;
/**
* {@link LRUCache.OptionsBase.noDisposeOnSet}
*/
noDisposeOnSet;
/**
* {@link LRUCache.OptionsBase.noUpdateTTL}
*/
noUpdateTTL;
/**
* {@link LRUCache.OptionsBase.maxEntrySize}
*/
maxEntrySize;
/**
* {@link LRUCache.OptionsBase.sizeCalculation}
*/
sizeCalculation;
/**
* {@link LRUCache.OptionsBase.noDeleteOnFetchRejection}
*/
noDeleteOnFetchRejection;
/**
* {@link LRUCache.OptionsBase.noDeleteOnStaleGet}
*/
noDeleteOnStaleGet;
/**
* {@link LRUCache.OptionsBase.allowStaleOnFetchAbort}
*/
allowStaleOnFetchAbort;
/**
* {@link LRUCache.OptionsBase.allowStaleOnFetchRejection}
*/
allowStaleOnFetchRejection;
/**
* {@link LRUCache.OptionsBase.ignoreFetchAbort}
*/
ignoreFetchAbort;
// computed properties
#l;
#f;
#h;
#a;
#r;
#g;
#w;
#d;
#u;
#v;
#m;
#T;
#C;
#b;
#E;
#x;
#p;
/**
* 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(t) {
return {
// properties
starts: t.#C,
ttls: t.#b,
sizes: t.#T,
keyMap: t.#h,
keyList: t.#a,
valList: t.#r,
next: t.#g,
prev: t.#w,
get head() {
return t.#d;
},
get tail() {
return t.#u;
},
free: t.#v,
// methods
isBackgroundFetch: /* @__PURE__ */ l((e) => t.#c(e), "isBackgroundFetch"),
backgroundFetch: /* @__PURE__ */ l((e, s, i, r) => t.#j(e, s, i, r), "backgroundFetch"),
moveToTail: /* @__PURE__ */ l((e) => t.#z(e), "moveToTail"),
indexes: /* @__PURE__ */ l((e) => t.#A(e), "indexes"),
rindexes: /* @__PURE__ */ l((e) => t.#R(e), "rindexes"),
isStale: /* @__PURE__ */ l((e) => t.#y(e), "isStale")
};
}
// Protected read-only members
/**
* {@link LRUCache.OptionsBase.max} (read-only)
*/
get max() {
return this.#t;
}
/**
* {@link LRUCache.OptionsBase.maxSize} (read-only)
*/
get maxSize() {
return this.#e;
}
/**
* The total computed size of items in the cache (read-only)
*/
get calculatedSize() {
return this.#f;
}
/**
* The number of items stored in the cache (read-only)
*/
get size() {
return this.#l;
}
/**
* {@link LRUCache.OptionsBase.fetchMethod} (read-only)
*/
get fetchMethod() {
return this.#o;
}
get memoMethod() {
return this.#S;
}
/**
* {@link LRUCache.OptionsBase.dispose} (read-only)
*/
get dispose() {
return this.#n;
}
/**
* {@link LRUCache.OptionsBase.disposeAfter} (read-only)
*/
get disposeAfter() {
return this.#i;
}
constructor(t) {
let { max: e = 0, ttl: s, ttlResolution: i = 1, ttlAutopurge: r, updateAgeOnGet: o, updateAgeOnHas: h, allowStale: a, dispose: c, disposeAfter: f,
noDisposeOnSet: u, noUpdateTTL: d, maxSize: p = 0, maxEntrySize: w = 0, sizeCalculation: m, fetchMethod: y, memoMethod: g, noDeleteOnFetchRejection: E,
noDeleteOnStaleGet: S, allowStaleOnFetchRejection: b, allowStaleOnFetchAbort: x, ignoreFetchAbort: T } = t;
if (e !== 0 && !V(e))
throw new TypeError("max option must be a nonnegative integer");
let j = e ? Ge(e) : Array;
if (!j)
throw new Error("invalid max value: " + e);
if (this.#t = e, this.#e = p, this.maxEntrySize = w || this.#e, this.sizeCalculation = m, this.sizeCalculation) {
if (!this.#e && !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 (g !== void 0 && typeof g != "function")
throw new TypeError("memoMethod must be a function if defined");
if (this.#S = g, y !== void 0 && typeof y != "function")
throw new TypeError("fetchMethod must be a function if specified");
if (this.#o = y, this.#x = !!y, this.#h = /* @__PURE__ */ new Map(), this.#a = new Array(e).fill(void 0), this.#r = new Array(e).fill(void 0),
this.#g = new j(e), this.#w = new j(e), this.#d = 0, this.#u = 0, this.#v = Jt.create(e), this.#l = 0, this.#f = 0, typeof c == "functio\
n" && (this.#n = c), typeof f == "function" ? (this.#i = f, this.#m = []) : (this.#i = void 0, this.#m = void 0), this.#E = !!this.#n, this.#p =
!!this.#i, this.noDisposeOnSet = !!u, this.noUpdateTTL = !!d, this.noDeleteOnFetchRejection = !!E, this.allowStaleOnFetchRejection = !!b,
this.allowStaleOnFetchAbort = !!x, this.ignoreFetchAbort = !!T, this.maxEntrySize !== 0) {
if (this.#e !== 0 && !V(this.#e))
throw new TypeError("maxSize must be a positive integer if specified");
if (!V(this.maxEntrySize))
throw new TypeError("maxEntrySize must be a positive integer if specified");
this.#O();
}
if (this.allowStale = !!a, this.noDeleteOnStaleGet = !!S, this.updateAgeOnGet = !!o, this.updateAgeOnHas = !!h, this.ttlResolution = V(i) ||
i === 0 ? i : 1, this.ttlAutopurge = !!r, this.ttl = s || 0, this.ttl) {
if (!V(this.ttl))
throw new TypeError("ttl must be a positive integer if specified");
this.#D();
}
if (this.#t === 0 && this.ttl === 0 && this.#e === 0)
throw new TypeError("At least one of max, maxSize, or ttl is required");
if (!this.ttlAutopurge && !this.#t && !this.#e) {
let J = "LRU_CACHE_UNBOUNDED";
ui(J) && (Ue.add(J), $e("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.", "UnboundedCac\
heWarning", J, n));
}
}
/**
* Return the number of ms left in the item's TTL. If item is not in cache,
* returns `0`. Returns `Infinity` if item is in cache without a defined TTL.
*/
getRemainingTTL(t) {
return this.#h.has(t) ? 1 / 0 : 0;
}
#D() {
let t = new it(this.#t), e = new it(this.#t);
this.#b = t, this.#C = e, this.#M = (r, o, h = st.now()) => {
if (e[r] = o !== 0 ? h : 0, t[r] = o, o !== 0 && this.ttlAutopurge) {
let a = setTimeout(() => {
this.#y(r) && this.#F(this.#a[r], "expire");
}, o + 1);
a.unref && a.unref();
}
}, this.#k = (r) => {
e[r] = t[r] !== 0 ? st.now() : 0;
}, this.#s = (r, o) => {
if (t[o]) {
let h = t[o], a = e[o];
if (!h || !a)
return;
r.ttl = h, r.start = a, r.now = s || i();
let c = r.now - a;
r.remainingTTL = h - c;
}
};
let s = 0, i = /* @__PURE__ */ l(() => {
let r = st.now();
if (this.ttlResolution > 0) {
s = r;
let o = setTimeout(() =>