clanka 0.17.0 → 0.17.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. package/dist/Agent.d.ts +4 -0
  2. package/dist/Agent.d.ts.map +1 -1
  3. package/dist/Agent.js +5 -1
  4. package/dist/Agent.js.map +1 -1
  5. package/dist/Agent.test.js +35 -0
  6. package/dist/Agent.test.js.map +1 -1
  7. package/dist/AgentCallerConfig.test.js +5 -3
  8. package/dist/AgentCallerConfig.test.js.map +1 -1
  9. package/dist/ChunkRepo.d.ts +1 -1
  10. package/dist/ClaudeAgent.d.ts.map +1 -1
  11. package/dist/ClaudeAgent.js +46 -17
  12. package/dist/ClaudeAgent.js.map +1 -1
  13. package/dist/ClaudeAgent.test.js +87 -16
  14. package/dist/ClaudeAgent.test.js.map +1 -1
  15. package/dist/Compaction.test.js +2 -1
  16. package/dist/Compaction.test.js.map +1 -1
  17. package/dist/CompactionTokens.test.js +15 -8
  18. package/dist/CompactionTokens.test.js.map +1 -1
  19. package/dist/bin/{Effect-On-1ks2z.mjs → Effect-DNYYQ84C.mjs} +421 -367
  20. package/dist/bin/Effect-DNYYQ84C.mjs.map +1 -0
  21. package/dist/bin/Latch-BSlIwuxI.mjs +7 -0
  22. package/dist/bin/Latch-BSlIwuxI.mjs.map +1 -0
  23. package/dist/bin/{McpClient-iwrW83Si.mjs → McpClient-C7ctqJWo.mjs} +4 -5
  24. package/dist/bin/{McpClient-iwrW83Si.mjs.map → McpClient-C7ctqJWo.mjs.map} +1 -1
  25. package/dist/bin/{OutputFormatter-DeNaqhQM.mjs → OutputFormatter-DXej05JW.mjs} +8 -13
  26. package/dist/bin/{OutputFormatter-DeNaqhQM.mjs.map → OutputFormatter-DXej05JW.mjs.map} +1 -1
  27. package/dist/bin/{Schema-B3pFcw4E.mjs → Schema-CSQN_Zso.mjs} +754 -800
  28. package/dist/bin/Schema-CSQN_Zso.mjs.map +1 -0
  29. package/dist/bin/{SemanticSearch-BZIXkWYz.mjs → SemanticSearch-BiwCnpKX.mjs} +241 -148
  30. package/dist/bin/SemanticSearch-BiwCnpKX.mjs.map +1 -0
  31. package/dist/bin/{Stream-DCB3_nIX.mjs → Stream-Dwvj9X5X.mjs} +161 -116
  32. package/dist/bin/Stream-Dwvj9X5X.mjs.map +1 -0
  33. package/dist/bin/cli.mjs +4022 -3231
  34. package/dist/bin/cli.mjs.map +1 -1
  35. package/dist/bin/{helpers-BPLUsjsL.mjs → helpers-CljL9OKa.mjs} +143 -177
  36. package/dist/bin/helpers-CljL9OKa.mjs.map +1 -0
  37. package/dist/bin/index.min-ClUfQ5ji.mjs +3782 -0
  38. package/dist/bin/index.min-ClUfQ5ji.mjs.map +1 -0
  39. package/dist/bin/{rolldown-runtime-Cjv6nE1W.mjs → rolldown-runtime-5zChB7MF.mjs} +1 -2
  40. package/dist/bin/{server-CBmuybpI.mjs → server-HlLriZxF.mjs} +5 -7
  41. package/dist/bin/{server-CBmuybpI.mjs.map → server-HlLriZxF.mjs.map} +1 -1
  42. package/dist/bin/{turndown.cjs-cie0BXQQ.mjs → turndown.cjs-C2WBxeA-.mjs} +56 -110
  43. package/dist/bin/{turndown.cjs-cie0BXQQ.mjs.map → turndown.cjs-C2WBxeA-.mjs.map} +1 -1
  44. package/dist/bin/{types-RT_9fFNm.mjs → types-LcwjLVkt.mjs} +20 -38
  45. package/dist/bin/{types-RT_9fFNm.mjs.map → types-LcwjLVkt.mjs.map} +1 -1
  46. package/dist/bin/upgrade-BSNjCnra.mjs +342 -0
  47. package/dist/bin/upgrade-BSNjCnra.mjs.map +1 -0
  48. package/package.json +14 -20
  49. package/src/Agent.test.ts +69 -0
  50. package/src/Agent.ts +5 -1
  51. package/src/AgentCallerConfig.test.ts +5 -3
  52. package/src/ClaudeAgent.test.ts +120 -21
  53. package/src/ClaudeAgent.ts +59 -19
  54. package/src/Compaction.test.ts +2 -1
  55. package/src/CompactionTokens.test.ts +15 -11
  56. package/dist/bin/Effect-On-1ks2z.mjs.map +0 -1
  57. package/dist/bin/Schema-B3pFcw4E.mjs.map +0 -1
  58. package/dist/bin/SemanticSearch-BZIXkWYz.mjs.map +0 -1
  59. package/dist/bin/Stream-DCB3_nIX.mjs.map +0 -1
  60. package/dist/bin/helpers-BPLUsjsL.mjs.map +0 -1
  61. package/dist/bin/index.min-Bkz7vIWv.mjs +0 -3300
  62. package/dist/bin/index.min-Bkz7vIWv.mjs.map +0 -1
@@ -0,0 +1,3782 @@
1
+ import cs from "node:stream";
2
+ import { StringDecoder } from "node:string_decoder";
3
+ import * as $i from "node:fs";
4
+ import { posix, win32 } from "node:path";
5
+ import { fileURLToPath } from "node:url";
6
+ import { lstatSync, readdir, readdirSync, readlinkSync, realpathSync } from "fs";
7
+ import { EventEmitter } from "node:events";
8
+ import { channel, tracingChannel } from "node:diagnostics_channel";
9
+ import { lstat, readdir as readdir$1, readlink, realpath } from "node:fs/promises";
10
+ // node_modules/.pnpm/glob@14.0.3/node_modules/glob/dist/esm/index.min.js
11
+ var se = (r, t, e) => {
12
+ let s = r instanceof RegExp ? De(r, e) : r, i = t instanceof RegExp ? De(t, e) : t, n = s !== null && i != null && Ms(s, i, e);
13
+ return n && {
14
+ start: n[0],
15
+ end: n[1],
16
+ pre: e.slice(0, n[0]),
17
+ body: e.slice(n[0] + s.length, n[1]),
18
+ post: e.slice(n[1] + i.length)
19
+ };
20
+ };
21
+ var De = (r, t) => {
22
+ let e = t.match(r);
23
+ return e ? e[0] : null;
24
+ };
25
+ var Ms = (r, t, e) => {
26
+ let s, i, n, o, a, h = e.indexOf(r), l = e.indexOf(t, h + 1), c = h;
27
+ if (h >= 0 && l > 0) {
28
+ if (r === t) return [h, l];
29
+ for (s = [], n = e.length; c >= 0 && !a;) {
30
+ if (c === h) s.push(c), h = e.indexOf(r, c + 1);
31
+ else if (s.length === 1) {
32
+ let f = s.pop();
33
+ f !== void 0 && (a = [f, l]);
34
+ } else i = s.pop(), i !== void 0 && i < n && (n = i, o = l), l = e.indexOf(t, c + 1);
35
+ c = h < l && h >= 0 ? h : l;
36
+ }
37
+ s.length && o !== void 0 && (a = [n, o]);
38
+ }
39
+ return a;
40
+ };
41
+ var Ne = "\0SLASH" + Math.random() + "\0";
42
+ var Pe = "\0OPEN" + Math.random() + "\0";
43
+ var oe = "\0CLOSE" + Math.random() + "\0";
44
+ var ze = "\0COMMA" + Math.random() + "\0";
45
+ var Le = "\0PERIOD" + Math.random() + "\0";
46
+ var Ts = new RegExp(Ne, "g");
47
+ var Fs = new RegExp(Pe, "g");
48
+ var _s = new RegExp(oe, "g");
49
+ var Ds = new RegExp(ze, "g");
50
+ var Ns = new RegExp(Le, "g");
51
+ var Ps = /\\\\/g;
52
+ var zs = /\\{/g;
53
+ var Ls = /\\}/g;
54
+ var js = /\\,/g;
55
+ var Ws = /\\\./g;
56
+ var $s = 1e5;
57
+ var Bs = 4e6;
58
+ var Is = 1e3;
59
+ var Us = 1e3;
60
+ function ie(r) {
61
+ return isNaN(r) ? r.charCodeAt(0) : parseInt(r, 10);
62
+ }
63
+ function Gs(r) {
64
+ return r.replace(Ps, Ne).replace(zs, Pe).replace(Ls, oe).replace(js, ze).replace(Ws, Le);
65
+ }
66
+ function Hs(r) {
67
+ return r.replace(Ts, "\\").replace(Fs, "{").replace(_s, "}").replace(Ds, ",").replace(Ns, ".");
68
+ }
69
+ function ne(r, t) {
70
+ for (let e = 0; e < t.length; e++) r.push(t[e]);
71
+ }
72
+ function qs(r) {
73
+ let t = [], e = "";
74
+ for (;;) {
75
+ let s = se("{", "}", r);
76
+ if (!s) {
77
+ let h = r.split(",");
78
+ return h[0] = e + h[0], ne(t, h), t;
79
+ }
80
+ let { pre: i, body: n, post: o } = s, a = i.split(",");
81
+ if (a[0] = e + a[0], a[a.length - 1] += "{" + n + "}", !o.length) return ne(t, a), t;
82
+ e = a.pop(), ne(t, a), r = o;
83
+ }
84
+ }
85
+ function je(r, t = {}) {
86
+ if (!r) return [];
87
+ let { max: e = $s, maxLength: s = Bs, maxDepth: i = Is, maxRewrites: n = Us } = t;
88
+ return r.slice(0, 2) === "{}" && (r = "\\{\\}" + r.slice(2)), re(Gs(r), e, s, i, 0, n, !0).map(Hs);
89
+ }
90
+ function Ks(r) {
91
+ return "{" + r + "}";
92
+ }
93
+ function Xs(r) {
94
+ return /^-?0\d/.test(r);
95
+ }
96
+ function Vs(r, t) {
97
+ return r <= t;
98
+ }
99
+ function Ys(r, t) {
100
+ return r >= t;
101
+ }
102
+ function lt(r, t, e, s, i, n) {
103
+ let o = [], a = 0;
104
+ for (let h = 0; h < r.length; h++) for (let l = 0; l < e.length; l++) {
105
+ if (o.length >= s) return o;
106
+ let c = r[h] + t + e[l];
107
+ if (!(n && !c)) {
108
+ if (a + c.length > i) return o;
109
+ o.push(c), a += c.length;
110
+ }
111
+ }
112
+ return o;
113
+ }
114
+ function Zs(r, t, e, s) {
115
+ let i = r.split(/\.\./), n = [];
116
+ if (i[0] === void 0 || i[1] === void 0) return n;
117
+ let o = ie(i[0]), a = ie(i[1]), h = Math.max(i[0].length, i[1].length), l = i.length === 3 && i[2] !== void 0 ? Math.max(Math.abs(ie(i[2])), 1) : 1, c = Vs;
118
+ a < o && (l *= -1, c = Ys);
119
+ let p = i.some(Xs), d = 0;
120
+ for (let g = o; c(g, a) && n.length < e; g += l) {
121
+ let u;
122
+ if (t) u = String.fromCharCode(g), u === "\\" && (u = "");
123
+ else if (u = String(g), p) {
124
+ let w = h - u.length;
125
+ if (w > 0) {
126
+ let m = new Array(w + 1).join("0");
127
+ g < 0 ? u = "-" + m + u.slice(1) : u = m + u;
128
+ }
129
+ }
130
+ if (d + u.length > s) break;
131
+ n.push(u), d += u.length;
132
+ }
133
+ return n;
134
+ }
135
+ function re(r, t, e, s, i, n, o) {
136
+ if (i > s) return [r];
137
+ let a = [""], h = 0, l = !1, c = !0;
138
+ for (;;) {
139
+ let f = se("{", "}", r);
140
+ if (!f) return lt(a, r, [""], t, e, l);
141
+ let p = f.pre;
142
+ if (/\$$/.test(p)) {
143
+ if (a = lt(a, p + "{" + f.body + "}", [""], t, e, l && !f.post.length), c = !1, !f.post.length) break;
144
+ r = f.post;
145
+ continue;
146
+ }
147
+ let d = /^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(f.body), g = /^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(f.body), u = d || g, w = f.body.indexOf(",") >= 0;
148
+ if (!u && !w) {
149
+ if (h < n && f.post.match(/,(?!,).*\}/)) {
150
+ h++, r = f.pre + "{" + f.body + oe + f.post, o = !0;
151
+ continue;
152
+ }
153
+ return lt(a, p + "{" + f.body + "}" + f.post, [""], t, e, l);
154
+ }
155
+ c && (l = o && !u, c = !1);
156
+ let m;
157
+ if (u) m = Zs(f.body, g, t, e);
158
+ else {
159
+ let b = qs(f.body);
160
+ if (b.length === 1 && b[0] !== void 0 && (b = re(b[0], t, e, s, i + 1, n, !1).map(Ks), b.length === 1)) {
161
+ if (a = lt(a, p + b[0], [""], t, e, l && !f.post.length), !f.post.length) break;
162
+ r = f.post;
163
+ continue;
164
+ }
165
+ let v = l && !f.post.length && !p;
166
+ for (let y = 0; v && y < a.length; y++) a[y] && (v = !1);
167
+ m = [];
168
+ let S = 0;
169
+ t: for (let y = 0; y < b.length; y++) {
170
+ let q = re(b[y], t, e, s, i + 1, n, !1);
171
+ for (let W = 0; W < q.length; W++) {
172
+ let I = q[W];
173
+ if (!(v && !I)) {
174
+ if (m.length >= t || S + I.length > e) break t;
175
+ m.push(I), S += I.length;
176
+ }
177
+ }
178
+ }
179
+ }
180
+ if (a = lt(a, p, m, t, e, l && !f.post.length), !f.post.length) break;
181
+ r = f.post;
182
+ }
183
+ return a;
184
+ }
185
+ var Js = {
186
+ "[:alnum:]": ["\\p{L}\\p{Nl}\\p{Nd}"],
187
+ "[:alpha:]": ["\\p{L}\\p{Nl}"],
188
+ "[:ascii:]": ["\\x00-\\x7f"],
189
+ "[:blank:]": ["\\p{Zs}\\t"],
190
+ "[:cntrl:]": ["\\p{Cc}"],
191
+ "[:digit:]": ["\\p{Nd}"],
192
+ "[:graph:]": ["\\p{Z}\\p{C}", !0],
193
+ "[:lower:]": ["\\p{Ll}"],
194
+ "[:print:]": ["\\p{C}", !0],
195
+ "[:punct:]": ["\\p{P}\\p{S}"],
196
+ "[:space:]": ["\\p{Z}\\t\\r\\n\\v\\f"],
197
+ "[:upper:]": ["\\p{Lu}"],
198
+ "[:word:]": ["\\p{L}\\p{Nl}\\p{Nd}\\p{Pc}"],
199
+ "[:xdigit:]": ["A-Fa-f0-9"]
200
+ };
201
+ var ct = (r) => r.replace(/[[\]\\-]/g, "\\$&");
202
+ var he = /$./;
203
+ var We = (r, t, e = !1, s) => {
204
+ let i = (m) => {
205
+ let b = s ? m.normalize(s) : m;
206
+ return [...b].length === 1 ? b : m;
207
+ }, n = t;
208
+ if (r.charAt(n) !== "[") throw new Error("not in a brace expression");
209
+ let o = [], a = [], h = n + 1, l = !1, c = !1, f = !1, p = n, d = "";
210
+ t: for (; h < r.length;) {
211
+ let m = String.fromCodePoint(r.codePointAt(h));
212
+ if ((m === "!" || m === "^") && h === n + 1) {
213
+ f = !0, h++;
214
+ continue;
215
+ }
216
+ if (m === "]" && l && !c) {
217
+ p = h + 1;
218
+ break;
219
+ }
220
+ if (l = !0, m === "\\" && !c) {
221
+ c = !0, h++;
222
+ continue;
223
+ }
224
+ if (m === "[" && !c) {
225
+ for (let [v, [S, y]] of Object.entries(Js)) if (r.startsWith(v, h)) {
226
+ if (d) return [he, r.length - n];
227
+ h += v.length, y ? a.push(S) : o.push(S);
228
+ continue t;
229
+ }
230
+ }
231
+ c = !1;
232
+ let b = i(m);
233
+ if (d) {
234
+ b.codePointAt(0) > d.codePointAt(0) ? o.push(ct(d) + "-" + ct(b)) : b === d && o.push(ct(b)), d = "", h += m.length;
235
+ continue;
236
+ }
237
+ if (r.startsWith("-]", h + m.length)) {
238
+ o.push(ct(b + "-")), h += m.length + 1;
239
+ continue;
240
+ }
241
+ if (r.startsWith("-", h + m.length)) {
242
+ d = b, h += m.length + 1;
243
+ continue;
244
+ }
245
+ o.push(ct(b)), h += m.length;
246
+ }
247
+ if (p < h) return [he, 0];
248
+ if (!o.length && !a.length) return [he, r.length - n];
249
+ let g = "[" + (f ? "^" : "") + o.join("") + "]", u = "[" + (f ? "" : "^") + a.join("") + "]", w = "^" + (o.length && a.length ? "(" + g + "|" + u + ")" : o.length ? g : u);
250
+ return [new RegExp(w, e ? "iu" : "u"), p - n];
251
+ };
252
+ var ae = {
253
+ t: "match",
254
+ id: 0
255
+ };
256
+ var Qs = "!?+*@";
257
+ var J = (r) => ({
258
+ t: "lit",
259
+ ch: r
260
+ });
261
+ var ti = (r) => r.replace(/[\\^$.*+?()[\]{}|/]/g, "\\$&");
262
+ var le = (r) => new RegExp(`^${ti(r)}$`, "iu");
263
+ var ue = (r, t) => {
264
+ if (t === r.ch) return !0;
265
+ if (!r.re) return !1;
266
+ let e = t.charCodeAt(0);
267
+ if (e >= 128) return r.re.test(t);
268
+ let s = r.ascii ??= new Uint8Array(128);
269
+ return s[e] ||= r.re.test(t) ? 1 : 2, s[e] === 1;
270
+ };
271
+ var ei = (r, t, e, s) => {
272
+ let i = [];
273
+ for (let n = 0; n < r.length;) {
274
+ let o = String.fromCodePoint(r.codePointAt(n));
275
+ if (o === "\\") {
276
+ let a = r.codePointAt(n + 1), h = a === void 0 ? o : String.fromCodePoint(a);
277
+ i.push(J(h)), n += 1 + h.length;
278
+ continue;
279
+ }
280
+ if (o === "[") {
281
+ let [a, h] = We(r, n, t, s);
282
+ if (h) {
283
+ i.push({
284
+ t: "class",
285
+ re: a
286
+ }), n += h;
287
+ continue;
288
+ }
289
+ }
290
+ if (!e && Qs.includes(o) && r[n + 1] === "(") {
291
+ i.push({
292
+ t: "open",
293
+ type: o
294
+ }), n += 2;
295
+ continue;
296
+ }
297
+ i.push(!e && o === "|" ? { t: "bar" } : !e && o === ")" ? { t: "close" } : o === "*" ? { t: "star" } : o === "?" ? { t: "any" } : J(o)), n += o.length;
298
+ }
299
+ return i;
300
+ };
301
+ var si = (r) => {
302
+ let t = new Map(), e = [];
303
+ return r.forEach((s, i) => {
304
+ s.t === "open" ? e.push(i) : s.t === "close" && e.length && t.set(e.pop(), i);
305
+ }), t;
306
+ };
307
+ var Ue = (r, t, e, s, i) => {
308
+ let n = [], o = [n];
309
+ for (let a = e; a < s; a++) {
310
+ let h = r[a], l = t.get(a);
311
+ if (h.t === "open" && l !== void 0) {
312
+ let c = Ue(r, t, a + 1, l, !1);
313
+ n.push({
314
+ t: "ext",
315
+ type: h.type,
316
+ alts: c
317
+ }), a = l;
318
+ } else h.t === "bar" && !i ? o.push(n = []) : h.t === "open" ? n.push(J(h.type), J("(")) : h.t === "bar" ? n.push(J("|")) : h.t === "close" ? n.push(J(")")) : n.push(h);
319
+ }
320
+ return o;
321
+ };
322
+ var Ge = (r, t) => {
323
+ let e = [], s = "", i = () => {
324
+ for (let n of s.normalize(t)) e.push(J(n));
325
+ s = "";
326
+ };
327
+ for (let n of r) {
328
+ if (n.t === "lit") {
329
+ s += n.ch;
330
+ continue;
331
+ }
332
+ i(), e.push(n.t === "ext" ? {
333
+ ...n,
334
+ alts: n.alts.map((o) => Ge(o, t))
335
+ } : n);
336
+ }
337
+ return i(), e;
338
+ };
339
+ var ii = (r, t) => {
340
+ let e = 1, s = (a) => ({
341
+ t: "split",
342
+ id: e++,
343
+ out: a
344
+ }), i = (a, h) => a.reduceRight((l, c) => n(c, l), h), n = (a, h) => {
345
+ switch (a.t) {
346
+ case "lit":
347
+ let p = t ? le(a.ch) : void 0;
348
+ return {
349
+ t: "lit",
350
+ id: e++,
351
+ ch: a.ch,
352
+ re: p,
353
+ next: h
354
+ };
355
+ case "any":
356
+ case "star": return {
357
+ t: a.t,
358
+ id: e++,
359
+ next: h
360
+ };
361
+ case "class": return {
362
+ t: "class",
363
+ id: e++,
364
+ re: a.re,
365
+ next: h
366
+ };
367
+ }
368
+ let l = (p) => a.alts.map((d) => i(d, p));
369
+ switch (a.type) {
370
+ case "@": return s(l(h));
371
+ case "?": return s([h, ...l(h)]);
372
+ case "!": return {
373
+ t: "neg",
374
+ id: e++,
375
+ sub: s(l(ae)),
376
+ next: h
377
+ };
378
+ }
379
+ let c = s([]), f = s(l(c));
380
+ return c.out.push(h, f), a.type === "*" ? c : f;
381
+ };
382
+ return [i(r, ae), e];
383
+ };
384
+ var ni = (r) => {
385
+ let t = [], e = new Set(), s = (n) => n.t === "match" ? "match" : String(n.id), i = (n, o) => {
386
+ if (n.t === "match" || e.has(n)) return;
387
+ e.add(n);
388
+ let a = (h) => t.push(`${o}${n.id}: ${h}`);
389
+ switch (n.t) {
390
+ case "split":
391
+ a(`split -> ${n.out.map(s).join(", ")}`);
392
+ for (let h of n.out) i(h, o);
393
+ return;
394
+ case "neg": return a(`!(${s(n.sub)}) -> ${s(n.next)}`), i(n.sub, o + " "), i(n.next, o);
395
+ case "lit":
396
+ a(`${JSON.stringify(n.ch)} -> ${s(n.next)}`);
397
+ break;
398
+ case "class":
399
+ a(`${n.re} -> ${s(n.next)}`);
400
+ break;
401
+ default: a(`${n.t === "any" ? "?" : "*"} -> ${s(n.next)}`);
402
+ }
403
+ i(n.next, o);
404
+ };
405
+ return i(r, ""), [`start -> ${s(r)}`, ...t].join(`
406
+ `);
407
+ };
408
+ var ce = class {
409
+ gen;
410
+ threads = [];
411
+ match = !1;
412
+ runs = [];
413
+ ids = [];
414
+ constructor(t) {
415
+ this.gen = t;
416
+ }
417
+ get dead() {
418
+ return !this.threads.length && !this.match && !this.runs.length;
419
+ }
420
+ };
421
+ var He = (r, t) => r.ids.length !== t.ids.length || r.runs.length !== t.runs.length || r.ids.some((e, s) => e !== t.ids[s]) ? !1 : r.runs.every((e) => t.runs.some((s) => s.neg === e.neg && He(s.state, e.state)));
422
+ var $e = (r) => ({
423
+ has: new Float64Array(r),
424
+ seen: new Float64Array(r),
425
+ gen: 0
426
+ });
427
+ var ft = class {
428
+ dots;
429
+ dotStart;
430
+ #t;
431
+ constructor(t, e, s) {
432
+ this.dots = t, this.dotStart = e, this.#t = s;
433
+ }
434
+ state() {
435
+ return new ce(++this.#t.gen);
436
+ }
437
+ done(t) {
438
+ return t.ids = t.threads.map((e) => e.id).sort((e, s) => e - s), t.match && t.ids.unshift(ae.id), t;
439
+ }
440
+ #i(t, e) {
441
+ let { seen: s } = this.#t;
442
+ return s[e.id] === t.gen ? !1 : (s[e.id] = t.gen, !0);
443
+ }
444
+ #e(t, e) {
445
+ let { has: s } = this.#t;
446
+ return s[e.id] === t.gen ? !1 : (s[e.id] = t.gen, t.threads.push(e), !0);
447
+ }
448
+ restricted(t, e) {
449
+ return e && (this.dots || this.dotStart && t === 0);
450
+ }
451
+ add(t, e, s, i) {
452
+ switch (e.t) {
453
+ case "split":
454
+ if (!this.#i(t, e)) return;
455
+ for (let o of e.out) this.add(t, o, s, i);
456
+ return;
457
+ case "neg":
458
+ if (!this.#i(t, e)) return;
459
+ let n = this.state();
460
+ return this.add(n, e.sub, s, !1), this.done(n), this.addRun(t, {
461
+ t: "run",
462
+ neg: e,
463
+ state: n
464
+ }, s, i);
465
+ case "star":
466
+ if (this.restricted(s, i)) return;
467
+ this.#e(t, e) && this.add(t, e.next, s, i);
468
+ return;
469
+ case "match":
470
+ t.match = !0;
471
+ return;
472
+ default: this.#e(t, e);
473
+ }
474
+ }
475
+ addRun(t, e, s, i) {
476
+ for (let n of t.runs) if (n.neg === e.neg && He(n.state, e.state)) return;
477
+ t.runs.push(e), e.state.match || this.add(t, e.neg.next, s, i);
478
+ }
479
+ step(t, e, s, i) {
480
+ let n = this.state();
481
+ for (let o of t.threads) switch (o.t) {
482
+ case "lit":
483
+ ue(o, e) && this.add(n, o.next, s + 1, i);
484
+ break;
485
+ case "any":
486
+ this.restricted(s, i) || this.add(n, o.next, s + 1, i);
487
+ break;
488
+ case "class":
489
+ !this.restricted(s, i) && o.re.test(e) && this.add(n, o.next, s + 1, i);
490
+ break;
491
+ case "star": this.restricted(s, i) || this.add(n, o, s + 1, i);
492
+ }
493
+ if (!this.restricted(s, i)) for (let o of t.runs) {
494
+ if (o.state.dead) {
495
+ this.addRun(n, o, s + 1, i);
496
+ continue;
497
+ }
498
+ let a = this.step(o.state, e, s, !1);
499
+ this.addRun(n, {
500
+ t: "run",
501
+ neg: o.neg,
502
+ state: a
503
+ }, s + 1, i);
504
+ }
505
+ return this.done(n);
506
+ }
507
+ };
508
+ var qe = (r) => {
509
+ let t = r.ids.join();
510
+ if (!r.runs.length) return t;
511
+ return `${t}|${r.runs.map((s) => `${s.neg.id}(${qe(s.state)})`).sort().join("|")}`;
512
+ };
513
+ var ri = 1 << 18;
514
+ var fe = class {
515
+ #t;
516
+ #i = new Map();
517
+ #e = 0;
518
+ #o;
519
+ #r;
520
+ #d;
521
+ #c;
522
+ constructor(t, e) {
523
+ this.#t = t, this.#d = new ft(!1, !1, e), this.#c = new ft(!1, !0, e);
524
+ }
525
+ #p(t) {
526
+ return {
527
+ state: t,
528
+ match: t.match,
529
+ dead: t.dead,
530
+ next: new Map()
531
+ };
532
+ }
533
+ #h(t) {
534
+ let e = qe(t), s = this.#i.get(e);
535
+ if (s) return s;
536
+ this.#e > ri && this.#m();
537
+ let i = this.#p(t);
538
+ return this.#i.set(e, i), this.#e += e.length + 1, i;
539
+ }
540
+ #m() {
541
+ this.#i.clear(), this.#e = 0, this.#o = void 0, this.#r = void 0;
542
+ }
543
+ start(t) {
544
+ if (t) {
545
+ if (this.#r) return this.#r;
546
+ let s = this.#c.state();
547
+ return this.#c.add(s, this.#t, 0, !0), this.#r = this.#p(this.#c.done(s));
548
+ }
549
+ if (this.#o) return this.#o;
550
+ let e = this.#d.state();
551
+ return this.#d.add(e, this.#t, 0, !0), this.#o = this.#h(this.#d.done(e));
552
+ }
553
+ next(t, e) {
554
+ let s = e.charCodeAt(0), i = s < 128 ? void 0 : t.next.get(e);
555
+ if (i) return i;
556
+ let n = t === this.#r ? this.#h(this.#c.step(t.state, e, 0, !0)) : this.#h(this.#d.step(t.state, e, 1, !0));
557
+ return s < 128 ? (t.ascii || (t.ascii = new Array(128), this.#e += 128), t.ascii[s] = n) : t.next.set(e, n), this.#e++, n;
558
+ }
559
+ };
560
+ var oi = (r) => {
561
+ let t = [];
562
+ for (let e = r; e.t !== "match"; e = e.next) {
563
+ if (e.t === "split" || e.t === "neg") return;
564
+ t.push(e);
565
+ }
566
+ return t;
567
+ };
568
+ var hi = (r, t, e, s) => {
569
+ let i = 0, n = e, o = -1, a = 0;
570
+ for (; n < s;) {
571
+ let h = r[i];
572
+ if (h?.t === "star") {
573
+ o = i++, a = n;
574
+ continue;
575
+ }
576
+ let l = t[n];
577
+ if (h && (h.t === "any" || h.t === "lit" && ue(h, l) || h.t === "class" && h.re.test(l))) {
578
+ i++, n++;
579
+ continue;
580
+ }
581
+ if (o === -1) return !1;
582
+ i = o + 1, n = ++a;
583
+ }
584
+ for (; r[i]?.t === "star";) i++;
585
+ return i === r.length;
586
+ };
587
+ var Ke = (r) => {
588
+ let t = 0, e = 0;
589
+ for (let s of r) {
590
+ let [i, n] = ai(s);
591
+ t += i, e += n;
592
+ }
593
+ return [t, e];
594
+ };
595
+ var ai = (r) => {
596
+ if (r.t === "star") return [0, 1 / 0];
597
+ if (r.t !== "ext") return [1, 1];
598
+ if (r.type === "!") return [0, 1 / 0];
599
+ let t = r.alts.map(Ke), e = Math.min(...t.map((n) => n[0])), s = Math.max(...t.map((n) => n[1])), i = s === 0 ? 0 : 1 / 0;
600
+ return r.type === "@" ? [e, s] : r.type === "?" ? [0, s] : r.type === "*" ? [0, i] : [e, i];
601
+ };
602
+ var Be = (r, t, e) => {
603
+ for (let s = 0; s < r.length; s++) if (!ue(r[s], t[e + s])) return !1;
604
+ return !0;
605
+ };
606
+ var li = /[/\ud800-\udfff]/;
607
+ var ci = /[\ud800-\udfff]/;
608
+ var Ft = (r) => ci.test(r) ? [...r] : r;
609
+ var Ie = (r) => {
610
+ if (r.includes("/")) throw new Error("can only match a single path portion, got: " + r);
611
+ };
612
+ var ut = class {
613
+ pattern;
614
+ options;
615
+ #t;
616
+ #i;
617
+ #e;
618
+ #o;
619
+ #r;
620
+ #d;
621
+ #c;
622
+ #p = !1;
623
+ #h = 0;
624
+ #m = 1 / 0;
625
+ #a = [];
626
+ #l = [];
627
+ #n;
628
+ #w;
629
+ #x = !1;
630
+ #b;
631
+ #f;
632
+ constructor(t, e = {}) {
633
+ if (t.includes("/")) throw new Error("can only match a single path portion, got pattern: " + t);
634
+ this.pattern = t, this.options = e;
635
+ let { nocase: s = !1, noext: i = !1, normalize: n } = e;
636
+ this.#f = n === !0 ? "NFC" : n || void 0;
637
+ let o = /^[?*+@]\(\)$/.test(t), a = ei(t, s, i || o, this.#f), [h] = Ue(a, si(a), 0, a.length, !0);
638
+ this.#f && (h = Ge(h, this.#f));
639
+ let [l, c] = ii(h, s);
640
+ if (this.#t = l, this.#i = c, h.every((f) => f.t === "lit")) this.#r = h.map((f) => f.ch).join(""), s && (this.#d = le(this.#r));
641
+ else {
642
+ let f = (g) => g.t !== "lit" ? void 0 : s ? {
643
+ ch: g.ch,
644
+ re: le(g.ch)
645
+ } : { ch: g.ch };
646
+ for (let g of h) {
647
+ let u = f(g);
648
+ if (!u) break;
649
+ this.#a.push(u);
650
+ }
651
+ for (let g = h.length - 1; g >= 0; g--) {
652
+ let u = f(h[g]);
653
+ if (!u) break;
654
+ this.#l.unshift(u);
655
+ }
656
+ this.#x = !!(this.#a.length || this.#l.length), s || (this.#n = this.#a.map((g) => g.ch).join(""), this.#w = this.#l.map((g) => g.ch).join("")), this.#c = oi(this.#t)?.slice(this.#a.length, -this.#l.length || void 0), this.#p = !!this.#c?.every((g) => g.t === "star" || g.t === "any");
657
+ let [p, d] = Ke(h);
658
+ this.#h = p, this.#m = d;
659
+ }
660
+ }
661
+ test(t) {
662
+ return this.#f ? (Ie(t), this.#v(t.normalize(this.#f))) : li.test(t) ? (Ie(t), this.#v(t, [...t])) : this.#v(t, t);
663
+ }
664
+ testUnchecked(t) {
665
+ return this.#v(this.#f ? t.normalize(this.#f) : t);
666
+ }
667
+ #v(t, e) {
668
+ if (this.#r !== void 0) return this.#d ? this.#d.test(t) : t === this.#r;
669
+ let s = this.#h, i = this.#m;
670
+ if (e === void 0) {
671
+ let c = t.length, f = c + 1 >> 1;
672
+ if (c < s || f > i) return !1;
673
+ (f < s || c > i) && (e = Ft(t));
674
+ }
675
+ if (e !== void 0 && (e.length < s || e.length > i)) return !1;
676
+ let n = this.#a.length;
677
+ if (this.#x) if (this.#n !== void 0 && this.#w !== void 0) {
678
+ if (!t.startsWith(this.#n) || !t.endsWith(this.#w)) return !1;
679
+ } else {
680
+ e ??= Ft(t);
681
+ let c = e.length - this.#l.length;
682
+ if (!Be(this.#a, e, 0) || !Be(this.#l, e, c)) return !1;
683
+ }
684
+ let o = !this.options.dot && t.startsWith(".");
685
+ if (this.#c) {
686
+ if (t === "." || t === ".." || o && !n) return !1;
687
+ if (this.#p) return !0;
688
+ e ??= Ft(t);
689
+ let c = e.length - this.#l.length;
690
+ return hi(this.#c, e, n, c);
691
+ }
692
+ if (e ??= Ft(t), t === "." || t === "..") {
693
+ this.#e ??= $e(this.#i);
694
+ let c = this.#o ??= new ft(!0, !1, this.#e), f = c.state();
695
+ c.add(f, this.#t, 0, !0);
696
+ let p = c.done(f);
697
+ for (let d = 0; d < e.length; d++) p = c.step(p, e[d], d, !0);
698
+ return p.match;
699
+ }
700
+ this.#e ??= $e(this.#i);
701
+ let a = this.#b ??= new fe(this.#t, this.#e), h = a.start(o), l = e === t;
702
+ for (let c = 0; c < e.length; c++) {
703
+ if (h.dead) return !1;
704
+ let f = l ? t.charCodeAt(c) : e[c].charCodeAt(0);
705
+ h = h.ascii?.[f] ?? a.next(h, e[c]);
706
+ }
707
+ return h.match;
708
+ }
709
+ toString() {
710
+ return ni(this.#t);
711
+ }
712
+ };
713
+ var dt = (r) => {
714
+ if (typeof r != "string") throw new TypeError("invalid pattern");
715
+ if (r.length > 65536) throw new TypeError("pattern is too long");
716
+ };
717
+ var K = (r, { windowsPathsNoEscape: t = !1, magicalBraces: e = !1 } = {}) => e ? t ? r.replace(/[?*()[\]{}]/g, "[$&]") : r.replace(/[?*()[\]\\{}]/g, "\\$&") : t ? r.replace(/[?*()[\]]/g, "[$&]") : r.replace(/[?*()[\]\\]/g, "\\$&");
718
+ var st = (r, { windowsPathsNoEscape: t = !1, magicalBraces: e = !0 } = {}) => e ? t ? r.replace(/\[([^/\\])\]/g, "$1") : r.replace(/((?!\\).|^)\[([^/\\])\]/g, "$1$2").replace(/\\([^/])/g, "$1") : t ? r.replace(/\[([^/\\{}])\]/g, "$1") : r.replace(/((?!\\).|^)\[([^/\\{}])\]/g, "$1$2").replace(/\\([^/{}])/g, "$1");
719
+ var F = (r, t, e = {}) => (dt(t), !e.nocomment && t.charAt(0) === "#" ? !1 : new D(t, e).match(r));
720
+ var Qe = typeof process == "object" && process ? process.env?.__MINIMATCH_TESTING_PLATFORM__ || process.platform : "posix";
721
+ var Xe = {
722
+ win32: { sep: "\\" },
723
+ posix: { sep: "/" }
724
+ };
725
+ F.sep = Qe === "win32" ? Xe.win32.sep : Xe.posix.sep;
726
+ var x = Symbol("globstar **");
727
+ F.GLOBSTAR = x;
728
+ var ui = (r, t = {}) => (e) => F(e, r, t);
729
+ F.filter = ui;
730
+ var U = (r, t = {}) => Object.assign({}, r, t);
731
+ var di = (r) => {
732
+ if (!r || typeof r != "object" || !Object.keys(r).length) return F;
733
+ let t = F;
734
+ return Object.assign((s, i, n = {}) => t(s, i, U(r, n)), {
735
+ Minimatch: class extends t.Minimatch {
736
+ constructor(i, n = {}) {
737
+ super(i, U(r, n));
738
+ }
739
+ static defaults(i) {
740
+ return t.defaults(U(r, i)).Minimatch;
741
+ }
742
+ },
743
+ unescape: (s, i = {}) => t.unescape(s, U(r, i)),
744
+ escape: (s, i = {}) => t.escape(s, U(r, i)),
745
+ filter: (s, i = {}) => t.filter(s, U(r, i)),
746
+ defaults: (s) => t.defaults(U(r, s)),
747
+ braceExpand: (s, i = {}) => t.braceExpand(s, U(r, i)),
748
+ match: (s, i, n = {}) => t.match(s, i, U(r, n)),
749
+ sep: t.sep,
750
+ GLOBSTAR: x
751
+ });
752
+ };
753
+ F.defaults = di;
754
+ var ts = (r, t = {}) => (dt(r), t.nobrace || !/\{(?:(?!\{).)*\}/.test(r) ? [r] : je(r, { max: t.braceExpandMax }));
755
+ F.braceExpand = ts;
756
+ var pi = (r, t, e = {}) => {
757
+ let s = new D(t, e);
758
+ return r = r.filter((i) => s.match(i)), s.options.nonull && !r.length && r.push(t), r;
759
+ };
760
+ F.match = pi;
761
+ var Ve = /[?*]|[+@!]\(.*?\)|\[|\]/;
762
+ var es = (r, t) => {
763
+ let e = t + 1;
764
+ (r.charAt(e) === "!" || r.charAt(e) === "^") && e++;
765
+ let s = !1;
766
+ for (; e < r.length; e++) {
767
+ let i = r.charAt(e);
768
+ if (i === "]" && s) return e;
769
+ s = !0, i === "\\" && e++;
770
+ }
771
+ return -1;
772
+ };
773
+ var mi = (r, t) => {
774
+ if (!t && (r === "+()" || r === "@()")) return r;
775
+ let e = "";
776
+ for (let s = 0; s < r.length; s++) {
777
+ let i = r.charAt(s);
778
+ if (i === "\\") e += r.charAt(++s) || i;
779
+ else {
780
+ if (i === "*" || i === "?") return;
781
+ if (i === "[") {
782
+ let n = es(r, s);
783
+ if (n === -1) {
784
+ e += i;
785
+ continue;
786
+ }
787
+ let o = r.slice(s + 1, n);
788
+ if (o.startsWith("\\") && (o = o.slice(1)), [...o].length !== 1 || "!^".includes(r.charAt(s + 1))) return;
789
+ e += o, s = n;
790
+ } else {
791
+ if (!t && "+@!".includes(i) && r.charAt(s + 1) === "(" && r.includes(")", s + 2)) return;
792
+ e += i;
793
+ }
794
+ }
795
+ }
796
+ return e;
797
+ };
798
+ var gi = (r) => {
799
+ if (/^[?*+@]\(\)$/.test(r) || r.includes("[:")) return !1;
800
+ let t = 0;
801
+ for (let e = 0; e < r.length; e++) {
802
+ let s = r.charAt(e);
803
+ if (s === "\\") {
804
+ if (++e === r.length) return !1;
805
+ } else if (s === "[") {
806
+ let i = es(r, e);
807
+ i !== -1 && (e = i);
808
+ } else if ("+@!?*".includes(s) && r.charAt(e + 1) === "(") t++, e++;
809
+ else if (s === ")") {
810
+ if (!t--) return !1;
811
+ } else if (s === "|" && !t) return !1;
812
+ }
813
+ return !t;
814
+ };
815
+ var de;
816
+ var Ye;
817
+ var X = (r, t) => typeof r == "string" ? t === r : t !== "" && r.testUnchecked(t);
818
+ var Ze = (r, t, e, s, i) => X(r, t) ? e : s !== void 0 && X(r, s) ? i : -1;
819
+ var ge = (r) => r === "." || r === "..";
820
+ var pe = (r) => typeof r == "string" && /^[a-z]:$/i.test(r);
821
+ var Dt = (r) => typeof r == "string" && /^unc$/i.test(r);
822
+ var me = (r) => {
823
+ if (r[0] !== "" || r[1] !== "") return -1;
824
+ let t = r[2] !== "?" ? 2 : Dt(r[3]) ? 4 : -1, e = r[t], s = r[t + 1];
825
+ return t !== -1 && e !== void 0 && e !== "" && e !== x && s !== void 0 && s !== "" && s !== x ? t : -1;
826
+ };
827
+ var _t = (r, t) => !ge(r) && (t || !r.startsWith("."));
828
+ var pt = (r, t, e, s, i) => {
829
+ for (let n = t; n < e;) {
830
+ if (r.charCodeAt(n) === 46) {
831
+ if (!s) return !0;
832
+ let a = r.charCodeAt(n + 1) === 46 ? n + 2 : n + 1;
833
+ if (a >= e || Nt(r.charCodeAt(a), i)) return !0;
834
+ }
835
+ let o = we(r, n, i);
836
+ if (o === -1) return !1;
837
+ for (n = o + 1; n < e && Nt(r.charCodeAt(n), i);) n++;
838
+ }
839
+ return !1;
840
+ };
841
+ var Nt = (r, t) => t === "/" ? r === 47 : t === "\\" ? r === 92 : r === 47 || r === 92;
842
+ var we = (r, t, e) => {
843
+ if (e !== "both") return r.indexOf(e, t);
844
+ let s = r.indexOf("/", t), i = r.indexOf("\\", t);
845
+ return s === -1 ? i : i === -1 ? s : Math.min(s, i);
846
+ };
847
+ var Je = (r, t, e) => e !== "both" ? r.lastIndexOf(e, t) : Math.max(r.lastIndexOf("/", t), r.lastIndexOf("\\", t));
848
+ var D = class {
849
+ options;
850
+ set;
851
+ pattern;
852
+ windowsPathsNoEscape;
853
+ nonegate;
854
+ negate;
855
+ comment;
856
+ empty;
857
+ preserveMultipleSlashes;
858
+ partial;
859
+ globSet;
860
+ globParts;
861
+ nocase;
862
+ isWindows;
863
+ platform;
864
+ windowsNoMagicRoot;
865
+ maxGlobstarRecursion;
866
+ #t;
867
+ #i;
868
+ #e;
869
+ #o;
870
+ #r = [];
871
+ #d = [];
872
+ #c = [];
873
+ #p = new Map();
874
+ #h = new WeakMap();
875
+ constructor(t, e = {}) {
876
+ dt(t), e = e || {}, this.options = e, this.maxGlobstarRecursion = e.maxGlobstarRecursion ?? 200, this.pattern = t, this.platform = e.platform || Qe, this.isWindows = this.platform === "win32";
877
+ let s = "allowWindowsEscape";
878
+ this.windowsPathsNoEscape = !!e.windowsPathsNoEscape || e[s] === !1, this.windowsPathsNoEscape && (this.pattern = this.pattern.replace(/\\/g, "/")), this.preserveMultipleSlashes = !!e.preserveMultipleSlashes, 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.#t = !this.preserveMultipleSlashes, this.#e = (e.optimizationLevel ?? 1) >= 2;
879
+ let i = e.normalize;
880
+ this.#o = i === !0 ? "NFC" : i || void 0, this.make();
881
+ let n = this.set.map((o) => this.#a(o));
882
+ this.#c = this.set.map((o, a) => this.#t && o.length - 1 > n[a]), this.#r = this.set.map((o, a) => {
883
+ let h = this.#c[a] ? o.length - 1 : o.length, l = o.slice(n[a] + 1, h).filter((c) => typeof c == "string" && !!c);
884
+ return [...new Set(l)];
885
+ }), this.#i = this.#r.some((o) => o.length), this.#d = this.set.map((o, a) => {
886
+ let [h, l, c] = o;
887
+ if (this.#c[a] && o.length === 2 && h === x && l !== x) return "tail";
888
+ if (this.#c[a] && e.matchBase && o.length === 1 && h !== x && h !== "") return "base";
889
+ if (!(!this.#t || n[a] !== -1)) {
890
+ if (o.length === 3 && h === x && c === x && l !== x && l !== "" && this.maxGlobstarRecursion > 0) return "mid";
891
+ if (o.length === 2 && l === x && h !== x && h !== "") return "head";
892
+ }
893
+ });
894
+ }
895
+ #m(t) {
896
+ return this.#o ? t.normalize(this.#o) : t;
897
+ }
898
+ #a(t) {
899
+ if (!this.isWindows) return -1;
900
+ if (pe(t[0])) return 0;
901
+ if (t[0] === "" && t[1] === "" && t[2] === "?" && pe(t[3])) return 3;
902
+ let s = me(t);
903
+ return s === -1 ? -1 : s + 1;
904
+ }
905
+ hasMagic() {
906
+ if (this.options.magicalBraces && this.set.length > 1) return !0;
907
+ for (let t of this.set) for (let e of t) if (typeof e != "string") return !0;
908
+ return !1;
909
+ }
910
+ make() {
911
+ let t = this.pattern, e = this.options;
912
+ if (!e.nocomment && t.charAt(0) === "#") {
913
+ this.comment = !0;
914
+ return;
915
+ }
916
+ if (!t) {
917
+ this.empty = !0;
918
+ return;
919
+ }
920
+ this.parseNegate(), this.globSet = [...new Set(this.braceExpand())];
921
+ let s = this.globSet.map((n) => this.#S(n));
922
+ this.globParts = this.preprocess(s);
923
+ let i = this.globParts.map((n, o, a) => {
924
+ if (this.isWindows && this.windowsNoMagicRoot) {
925
+ let h = n[2] === "?" && Dt(n[3]) ? 6 : 4, l = n[0] === "" && n[1] === "" && (n[2] === "?" || !Ve.test(n[2])) && n.slice(3, h).every((f) => !Ve.test(f)), c = /^[a-z]:/i.test(n[0]);
926
+ if (l) return [...n.slice(0, h).map((f) => this.#m(f)), ...n.slice(h).map((f) => this.parse(f))];
927
+ if (c) return [this.#m(n[0]), ...n.slice(1).map((f) => this.parse(f))];
928
+ }
929
+ return n.map((h) => this.parse(h));
930
+ });
931
+ if (this.set = i.filter((n) => n.indexOf(!1) === -1), this.isWindows) for (let n = 0; n < this.set.length; n++) {
932
+ let o = this.set[n];
933
+ o[0] === "" && o[1] === "" && this.globParts[n][2] === "?" && (pe(o[3]) || Dt(this.globParts[n][3])) && (Dt(this.globParts[n][3]) && (o[3] = "UNC"), o[2] = "?");
934
+ }
935
+ e.noext || this.mergeRows();
936
+ }
937
+ mergeRows() {
938
+ let t = !0;
939
+ for (; t;) {
940
+ t = !1;
941
+ let e = Math.max(0, ...this.set.map((s) => s.length));
942
+ for (let s = 0; s < e; s++) {
943
+ let i = new Map();
944
+ this.set.forEach((o, a) => {
945
+ if (!(o[s] instanceof ut) || !gi(this.globParts[a][s])) return;
946
+ let h = [...this.globParts[a]];
947
+ h[s] = "";
948
+ let l = `${o.length}/${h.join("/")}`, c = i.get(l);
949
+ c ? c.push(a) : i.set(l, [a]);
950
+ });
951
+ let n = new Set();
952
+ for (let o of i.values()) {
953
+ if (o.length < 2) continue;
954
+ let [a, ...h] = o, c = `@(${o.map((f) => this.globParts[f][s]).join("|")})`;
955
+ this.globParts[a][s] = c, this.set[a][s] = this.parse(c);
956
+ for (let f of h) n.add(f);
957
+ }
958
+ n.size && (t = !0, this.set = this.set.filter((o, a) => !n.has(a)), this.globParts = this.globParts.filter((o, a) => !n.has(a)));
959
+ }
960
+ }
961
+ }
962
+ preprocess(t) {
963
+ if (this.options.noglobstar) for (let s of t) for (let i = 0; i < s.length; i++) s[i] === "**" && (s[i] = "*");
964
+ let { optimizationLevel: e = 1 } = this.options;
965
+ return e >= 2 ? (t = this.firstPhasePreProcess(t), t = this.secondPhasePreProcess(t)) : e >= 1 ? t = this.levelOneOptimize(t) : t = this.adjascentGlobstarOptimize(t), t;
966
+ }
967
+ adjascentGlobstarOptimize(t) {
968
+ return t.map((e) => {
969
+ let s = -1;
970
+ for (; (s = e.indexOf("**", s + 1)) !== -1;) {
971
+ let i = s;
972
+ for (; e[i + 1] === "**";) i++;
973
+ i !== s && e.splice(s, i - s);
974
+ }
975
+ return e;
976
+ });
977
+ }
978
+ levelOneOptimize(t) {
979
+ return t.map((e) => {
980
+ let s = this.#a(e) + 1;
981
+ return e = e.reduce((i, n) => {
982
+ let o = i[i.length - 1];
983
+ return n === "**" && o === "**" ? i : n === ".." && i.length > s && o && o !== ".." && o !== "." && o !== "**" ? (i.pop(), i) : (i.push(n), i);
984
+ }, []), e.length === 0 ? [""] : e;
985
+ });
986
+ }
987
+ #l(t) {
988
+ let e = !this.isWindows || !t.includes("\\") ? "/" : t.includes("/") ? "both" : "\\", s = this.#t ? 0 : -1, i = "", n = 0, o, a = 0, h = !!this.options.dot;
989
+ t: for (let l = 0; l < this.set.length; l++) {
990
+ let c = this.set[l], f = c[c.length - 1], p = s !== -1 && this.#c[l] && f !== x;
991
+ if (p && s === 0) {
992
+ let u = Je(t, t.length, e);
993
+ if (n = u + 1, i = t.slice(n), i === "" && u >= 0) {
994
+ let m = u;
995
+ for (; m > 0 && Nt(t.charCodeAt(m - 1), e);) m--;
996
+ a = m === 0 ? 0 : Je(t, m - 1, e) + 1, o = t.slice(a, m);
997
+ }
998
+ let w = this.#e && (ge(i) || i === "" && o !== void 0 && ge(o));
999
+ s = w ? -1 : 1, p = !w;
1000
+ }
1001
+ let d = -1;
1002
+ if (p && typeof f == "string" && (d = Ze(f, i, n, o, a), d === -1)) continue;
1003
+ if (this.#i) {
1004
+ for (let u of this.#r[l]) if (!t.includes(u)) continue t;
1005
+ }
1006
+ if (p && typeof f == "object" && (d = Ze(f, i, n, o, a), d === -1)) continue;
1007
+ let g = this.#d[l];
1008
+ if (g === "base" && p) return "yes";
1009
+ if (g === "tail" && p) {
1010
+ if (this.#e && pt(t, 0, d, !0, e)) return "maybe";
1011
+ if (!pt(t, 0, d, h, e)) return "yes";
1012
+ continue;
1013
+ }
1014
+ if (g === "mid" || g === "head") {
1015
+ let u = this.#w(t, c, g === "head", h, e);
1016
+ if (u !== "no") return u;
1017
+ continue;
1018
+ }
1019
+ return "maybe";
1020
+ }
1021
+ return "no";
1022
+ }
1023
+ #n(t, e, s) {
1024
+ let i = !!this.options.dot, n = t.length;
1025
+ if (s === "head") {
1026
+ if (n < 2 || !X(e[0], t[0])) return !1;
1027
+ for (let a = 1; a < n; a++) if (!_t(t[a], i)) return !1;
1028
+ return !0;
1029
+ }
1030
+ let o = e[1];
1031
+ if (s === "tail") {
1032
+ let a = n - 1;
1033
+ if (!X(o, t[a]) && (t[a] !== "" || n === 1 || !X(o, t[--a]))) return !1;
1034
+ for (let h = 0; h < a; h++) if (!_t(t[h], i)) return !1;
1035
+ return !0;
1036
+ }
1037
+ for (let a = 0; a < n; a++) {
1038
+ if (X(o, t[a]) && a + 1 < n) {
1039
+ let h = a + 1;
1040
+ for (; h < n && _t(t[h], i);) h++;
1041
+ if (h === n) return !0;
1042
+ }
1043
+ if (!_t(t[a], i)) return !1;
1044
+ }
1045
+ return !1;
1046
+ }
1047
+ #w(t, e, s, i, n) {
1048
+ if (this.#e && pt(t, 0, t.length, !0, n)) return "maybe";
1049
+ let o = e[s ? 0 : 1], a = 0;
1050
+ for (let h = we(t, a, n); h !== -1; h = we(t, a, n)) {
1051
+ let l = h + 1;
1052
+ for (; l < t.length && Nt(t.charCodeAt(l), n);) l++;
1053
+ if ((typeof o == "string" ? h - a === o.length && t.startsWith(o, a) : h > a && o.testUnchecked(t.slice(a, h))) && !pt(t, l, t.length, i, n)) return "yes";
1054
+ if (s || pt(t, a, l, i, n)) return "no";
1055
+ a = l;
1056
+ }
1057
+ return "no";
1058
+ }
1059
+ #x(t) {
1060
+ let e = de;
1061
+ return e?.f === t && e.isWindows === this.isWindows && e.preserveMultipleSlashes === this.preserveMultipleSlashes && e.normalize === this.#o ? e : void 0;
1062
+ }
1063
+ #b(t) {
1064
+ let { isWindows: e, preserveMultipleSlashes: s } = this, i = this.#S(e ? t.split("\\").join("/") : t), n = this.#o;
1065
+ return n && (i = i.map((o) => o.normalize(n))), de = {
1066
+ f: t,
1067
+ isWindows: e,
1068
+ preserveMultipleSlashes: s,
1069
+ normalize: n,
1070
+ parts: i
1071
+ }, de;
1072
+ }
1073
+ #f(t) {
1074
+ let e = [...t], s = !1;
1075
+ do {
1076
+ if (s = !1, !this.preserveMultipleSlashes) {
1077
+ for (let o = 1; o < e.length - 1; o++) {
1078
+ let a = e[o];
1079
+ o === 1 && a === "" && e[0] === "" || (a === "." || a === "") && (s = !0, e.splice(o, 1), o--);
1080
+ }
1081
+ e[0] === "." && e.length === 2 && (e[1] === "." || e[1] === "") && (s = !0, e.pop());
1082
+ }
1083
+ let i = this.#a(e) + 1, n = i;
1084
+ for (; (n = e.indexOf("..", n + 1)) !== -1;) {
1085
+ let o = e[n - 1];
1086
+ o && o !== "." && o !== ".." && o !== "**" && (s = !0, e.splice(n - 1, 2), n = Math.max(n - 2, i));
1087
+ }
1088
+ } while (s);
1089
+ return e.length === 0 ? [""] : e;
1090
+ }
1091
+ firstPhasePreProcess(t) {
1092
+ let { braceExpandMax: e = 1e5 } = this.options, s = !1;
1093
+ do {
1094
+ s = !1;
1095
+ for (let i of t) {
1096
+ let n = -1;
1097
+ for (; (n = i.indexOf("**", n + 1)) !== -1;) {
1098
+ let h = n;
1099
+ for (; i[h + 1] === "**";) h++;
1100
+ h > n && i.splice(n + 1, h - n);
1101
+ let l = i[n + 1], c = i[n + 2], f = i[n + 3];
1102
+ if (l !== ".." || !c || c === "." || c === ".." || !f || f === "." || f === ".." || t.length >= e) continue;
1103
+ s = !0, i.splice(n, 1);
1104
+ let p = i.slice(0);
1105
+ p[n] = "**", t.push(p), n--;
1106
+ }
1107
+ if (!this.preserveMultipleSlashes) {
1108
+ for (let h = 1; h < i.length - 1; h++) {
1109
+ let l = i[h];
1110
+ h === 1 && l === "" && i[0] === "" || (l === "." || l === "") && (s = !0, i.splice(h, 1), h--);
1111
+ }
1112
+ i[0] === "." && i.length === 2 && (i[1] === "." || i[1] === "") && (s = !0, i.pop());
1113
+ }
1114
+ let o = this.#a(i) + 1, a = o;
1115
+ for (; (a = i.indexOf("..", a + 1)) !== -1;) {
1116
+ let h = i[a - 1];
1117
+ if (h && h !== "." && h !== ".." && h !== "**") {
1118
+ s = !0;
1119
+ let c = a === 1 && i[a + 1] === "**" ? ["."] : [];
1120
+ i.splice(a - 1, 2, ...c), i.length === 0 && i.push(""), a = Math.max(a - 2, o);
1121
+ }
1122
+ }
1123
+ }
1124
+ } while (s);
1125
+ return t;
1126
+ }
1127
+ secondPhasePreProcess(t) {
1128
+ if (t.length > 1e3) return t;
1129
+ for (let e = 0; e < t.length - 1; e++) for (let s = e + 1; s < t.length; s++) {
1130
+ let i = this.partsMatch(t[e], t[s], !this.preserveMultipleSlashes);
1131
+ if (i) {
1132
+ t[e] = [], t[s] = i;
1133
+ break;
1134
+ }
1135
+ }
1136
+ return t.filter((e) => e.length);
1137
+ }
1138
+ partsMatch(t, e, s = !1) {
1139
+ let i = 0, n = 0, o = [], a = "";
1140
+ for (; i < t.length && n < e.length;) if (t[i] === e[n]) o.push(a === "b" ? e[n] : t[i]), i++, n++;
1141
+ else if (s && t[i] === "**" && e[n] === t[i + 1]) o.push(t[i]), i++;
1142
+ else if (s && e[n] === "**" && t[i] === e[n + 1]) o.push(e[n]), n++;
1143
+ else if (t[i] === "*" && e[n] && (this.options.dot || !e[n].startsWith(".")) && e[n] !== "**") {
1144
+ if (a === "b") return !1;
1145
+ a = "a", o.push(t[i]), i++, n++;
1146
+ } else if (e[n] === "*" && t[i] && (this.options.dot || !t[i].startsWith(".")) && t[i] !== "**") {
1147
+ if (a === "a") return !1;
1148
+ a = "b", o.push(e[n]), i++, n++;
1149
+ } else return !1;
1150
+ return t.length === e.length && o;
1151
+ }
1152
+ parseNegate() {
1153
+ if (this.nonegate) return;
1154
+ let t = this.pattern, e = !1, s = 0;
1155
+ for (let i = 0; i < t.length && t.charAt(i) === "!"; i++) e = !e, s++;
1156
+ s && (this.pattern = t.slice(s)), this.negate = e;
1157
+ }
1158
+ #v(t, e, s, i) {
1159
+ let n = 0, o = 0, a = this.isWindows ? me(e) : -1, h = a === -1 ? -1 : me(s);
1160
+ if (h !== -1) {
1161
+ let l = s[h], c = s[h + 1];
1162
+ typeof l != "string" || typeof c != "string" ? (n = a, o = h) : e[a].toLowerCase() === l.toLowerCase() && e[a + 1].toLowerCase() === c.toLowerCase() && (n = a + 2, o = h + 2);
1163
+ } else if (this.isWindows) {
1164
+ let l = typeof t[0] == "string" && /^[a-z]:$/i.test(t[0]), c = !l && t[0] === "" && t[1] === "" && t[2] === "?" && /^[a-z]:$/i.test(t[3]), f = typeof s[0] == "string" && /^[a-z]:$/i.test(s[0]), p = !f && s[0] === "" && s[1] === "" && s[2] === "?" && typeof s[3] == "string" && /^[a-z]:$/i.test(s[3]), d = c ? 3 : l ? 0 : void 0, g = p ? 3 : f ? 0 : void 0;
1165
+ if (typeof d == "number" && typeof g == "number") {
1166
+ let [u, w] = [t[d], s[g]];
1167
+ u.toLowerCase() === w.toLowerCase() && (o = g + 1, n = d + 1);
1168
+ }
1169
+ }
1170
+ return t = e, s.includes(x) ? this.#y(t, s, i, n, o) : this.#g(t, s, i, n, o);
1171
+ }
1172
+ #y(t, e, s, i, n) {
1173
+ let { head: o, body: a, tail: h, segments: l } = this.#E(e, s, n);
1174
+ if (o.length) {
1175
+ let f = i + o.length;
1176
+ if (!this.#g(t, o, s, i, 0, f)) return !1;
1177
+ i += o.length, n += o.length;
1178
+ }
1179
+ let c = 0;
1180
+ if (h.length) {
1181
+ if (h.length + i > t.length) return !1;
1182
+ let f = t.length - h.length;
1183
+ if (this.#g(t, h, s, f, 0)) c = h.length;
1184
+ else {
1185
+ if (t[t.length - 1] !== "" || i + h.length === t.length || (f--, !this.#g(t, h, s, f, 0))) return !1;
1186
+ c = h.length + 1;
1187
+ }
1188
+ }
1189
+ if (!a.length) {
1190
+ let f = !!c;
1191
+ for (let p = i; p < t.length - c; p++) {
1192
+ let d = String(t[p]);
1193
+ if (f = !0, d === "." || d === ".." || !this.options.dot && d.startsWith(".")) return !1;
1194
+ }
1195
+ return s || f;
1196
+ }
1197
+ return !!this.#k(t, l, t.length - c, i, 0, s, 0, !!c, new Set());
1198
+ }
1199
+ #E(t, e, s) {
1200
+ let i = this.#h.get(t);
1201
+ i || (i = [], this.#h.set(t, i));
1202
+ let n = s * 2 + (e ? 1 : 0), o = i[n];
1203
+ if (o) return o;
1204
+ let a = t.indexOf(x, s), h = t.lastIndexOf(x), l = t.slice(s, a), c = t.slice(a + 1, e ? void 0 : h), f = e ? [] : t.slice(h + 1), p = [[[], 0]], d = p[0], g = 0, u = [0];
1205
+ for (let m of c) m === x ? (u.push(g), d = [[], 0], p.push(d)) : (d[0].push(m), g++);
1206
+ p.forEach((m, b) => {
1207
+ m[1] = g - u[b];
1208
+ });
1209
+ let w = {
1210
+ head: l,
1211
+ body: c,
1212
+ tail: f,
1213
+ segments: p
1214
+ };
1215
+ return i[n] = w, w;
1216
+ }
1217
+ #k(t, e, s, i, n, o, a, h, l) {
1218
+ let c = e[n];
1219
+ if (!c) {
1220
+ if (o) return i >= s || i === s - 1 && t[i] === "";
1221
+ for (let g = i; g < s; g++) {
1222
+ h = !0;
1223
+ let u = t[g];
1224
+ if (u === "." || u === ".." || !this.options.dot && u.startsWith(".")) return !1;
1225
+ }
1226
+ return h;
1227
+ }
1228
+ let [f, p] = c, d = o ? s : s - p;
1229
+ for (; i <= d;) {
1230
+ let g = n * (t.length + 1) + i;
1231
+ if (l.has(g)) return !1;
1232
+ if (l.add(g), this.#g(t, f, o, i, 0, i + f.length) && a < this.maxGlobstarRecursion) {
1233
+ let m = this.#k(t, e, s, i + f.length, n + 1, o, a + 1, h, l);
1234
+ if (m !== !1) return m;
1235
+ }
1236
+ if (i === d) break;
1237
+ let w = t[i];
1238
+ if (w === "." || w === ".." || !this.options.dot && w.startsWith(".")) return !1;
1239
+ i++;
1240
+ }
1241
+ return o || null;
1242
+ }
1243
+ #g(t, e, s, i, n, o = t.length) {
1244
+ let a, h, l, c;
1245
+ for (a = i, h = n, c = Math.min(o, t.length), l = e.length; a < c && h < l; a++, h++) {
1246
+ let f = e[h], p = t[a];
1247
+ if (f === !1 || f === x || !X(f, p)) return !1;
1248
+ }
1249
+ if (a === c && h === l) return !0;
1250
+ if (a === c) return s;
1251
+ if (h === l) return a === c - 1 && t[a] === "";
1252
+ throw new Error("wtf?");
1253
+ }
1254
+ braceExpand() {
1255
+ return ts(this.pattern, this.options);
1256
+ }
1257
+ parse(t) {
1258
+ dt(t);
1259
+ let e = this.options;
1260
+ if (t === "**") return x;
1261
+ if (t === "") return "";
1262
+ let { nocase: s, nocaseMagicOnly: i, noext: n = !1, dot: o, normalize: a } = e, h = mi(t, n);
1263
+ if (h !== void 0 && !(s && !i && t.toUpperCase() !== t.toLowerCase())) return this.#m(h);
1264
+ let l = this.#p.get(t);
1265
+ return l || (l = new ut(t, {
1266
+ nocase: s,
1267
+ noext: n,
1268
+ dot: o,
1269
+ normalize: a
1270
+ }), this.#p.set(t, l)), l;
1271
+ }
1272
+ #S(t) {
1273
+ return this.preserveMultipleSlashes ? t.split("/") : this.isWindows && /^\/\/[^/]+/.test(t) ? ["", ...t.split(/\/+/)] : t.split(/\/+/);
1274
+ }
1275
+ match(t, e = this.partial) {
1276
+ if (this.comment) return !1;
1277
+ if (this.empty) return t === "";
1278
+ if (t === "/" && e) return !0;
1279
+ let s = this.options, i = this.#x(t);
1280
+ if (!i) {
1281
+ if (!e && !this.#o && (this.#t || this.#i) && Ye !== t) {
1282
+ Ye = t;
1283
+ let l = this.#l(t);
1284
+ if (l === "no") return s.flipNegate ? !1 : this.negate;
1285
+ if (l === "yes") return s.flipNegate ? !0 : !this.negate;
1286
+ }
1287
+ i = this.#b(t);
1288
+ }
1289
+ let n = i.parts, o = this.#e ? i.resolved ??= this.#f(n) : n, a = this.set, h = n[n.length - 1];
1290
+ if (!h) for (let l = n.length - 2; !h && l >= 0; l--) h = n[l];
1291
+ for (let l = 0; l < a.length; l++) {
1292
+ let c = a[l], f = e ? void 0 : this.#d[l];
1293
+ if (f === "base" ? X(c[0], h) : f ? this.#n(o, c, f) : s.matchBase && c.length === 1 ? this.#v([h], [h], c, e) : this.#v(n, o, c, e)) return s.flipNegate ? !0 : !this.negate;
1294
+ }
1295
+ return s.flipNegate ? !1 : this.negate;
1296
+ }
1297
+ static defaults(t) {
1298
+ return F.defaults(t).Minimatch;
1299
+ }
1300
+ };
1301
+ F.Minimatch = D;
1302
+ F.escape = K;
1303
+ F.unescape = st;
1304
+ var R = channel("lru-cache:metrics");
1305
+ var mt = tracingChannel("lru-cache");
1306
+ var yi = typeof performance == "object" && performance && typeof performance.now == "function" ? performance : Date;
1307
+ var be = () => R.hasSubscribers || mt.hasSubscribers;
1308
+ var is = new Set();
1309
+ var ss = typeof process == "object" && process ? process : {};
1310
+ var Si = (r, t, e, s) => {
1311
+ typeof ss.emitWarning == "function" ? ss.emitWarning(r, t, e, s) : console.error(`[${e}] ${t}: ${r}`);
1312
+ };
1313
+ var vi = (r) => !is.has(r);
1314
+ var V = (r) => !!r && r === Math.floor(r) && r > 0 && isFinite(r);
1315
+ var ns = (r) => V(r) ? r <= Math.pow(2, 8) ? Uint8Array : r <= Math.pow(2, 16) ? Uint16Array : r <= Math.pow(2, 32) ? Uint32Array : r <= Number.MAX_SAFE_INTEGER ? Pt : null : null;
1316
+ var Pt = class extends Array {
1317
+ constructor(r) {
1318
+ super(r), this.fill(0);
1319
+ }
1320
+ };
1321
+ var xi = class gt {
1322
+ heap;
1323
+ length;
1324
+ static #t = !1;
1325
+ static create(t) {
1326
+ let e = ns(t);
1327
+ if (!e) return [];
1328
+ gt.#t = !0;
1329
+ let s = new gt(t, e);
1330
+ return gt.#t = !1, s;
1331
+ }
1332
+ constructor(t, e) {
1333
+ if (!gt.#t) throw new TypeError("instantiate Stack using Stack.create(n)");
1334
+ this.heap = new e(t), this.length = 0;
1335
+ }
1336
+ push(t) {
1337
+ this.heap[this.length++] = t;
1338
+ }
1339
+ pop() {
1340
+ return this.heap[--this.length];
1341
+ }
1342
+ };
1343
+ var wt = class rs {
1344
+ #t;
1345
+ #i;
1346
+ #e;
1347
+ #o;
1348
+ #r;
1349
+ #d;
1350
+ #c;
1351
+ #p;
1352
+ get perf() {
1353
+ return this.#p;
1354
+ }
1355
+ ttl;
1356
+ ttlResolution;
1357
+ ttlAutopurge;
1358
+ updateAgeOnGet;
1359
+ updateAgeOnHas;
1360
+ allowStale;
1361
+ noDisposeOnSet;
1362
+ noUpdateTTL;
1363
+ maxEntrySize;
1364
+ sizeCalculation;
1365
+ noDeleteOnFetchRejection;
1366
+ noDeleteOnStaleGet;
1367
+ allowStaleOnFetchAbort;
1368
+ allowStaleOnFetchRejection;
1369
+ ignoreFetchAbort;
1370
+ backgroundFetchSize;
1371
+ #h;
1372
+ #m;
1373
+ #a;
1374
+ #l;
1375
+ #n;
1376
+ #w;
1377
+ #x;
1378
+ #b;
1379
+ #f;
1380
+ #v;
1381
+ #y;
1382
+ #E;
1383
+ #k;
1384
+ #g;
1385
+ #S;
1386
+ #C;
1387
+ #O;
1388
+ #s;
1389
+ #F;
1390
+ static unsafeExposeInternals(t) {
1391
+ return {
1392
+ starts: t.#k,
1393
+ ttls: t.#g,
1394
+ autopurgeTimers: t.#S,
1395
+ sizes: t.#E,
1396
+ keyMap: t.#a,
1397
+ keyList: t.#l,
1398
+ valList: t.#n,
1399
+ next: t.#w,
1400
+ prev: t.#x,
1401
+ get head() {
1402
+ return t.#b;
1403
+ },
1404
+ get tail() {
1405
+ return t.#f;
1406
+ },
1407
+ free: t.#v,
1408
+ isBackgroundFetch: (e) => t.#u(e),
1409
+ backgroundFetch: (e, s, i, n) => t.#L(e, s, i, n),
1410
+ moveToTail: (e) => t.#X(e),
1411
+ indexes: (e) => t.#M(e),
1412
+ rindexes: (e) => t.#T(e),
1413
+ isStale: (e) => t.#A(e)
1414
+ };
1415
+ }
1416
+ get max() {
1417
+ return this.#t;
1418
+ }
1419
+ get maxSize() {
1420
+ return this.#i;
1421
+ }
1422
+ get calculatedSize() {
1423
+ return this.#m;
1424
+ }
1425
+ get size() {
1426
+ return this.#h;
1427
+ }
1428
+ get fetchMethod() {
1429
+ return this.#d;
1430
+ }
1431
+ get memoMethod() {
1432
+ return this.#c;
1433
+ }
1434
+ get dispose() {
1435
+ return this.#e;
1436
+ }
1437
+ get onInsert() {
1438
+ return this.#o;
1439
+ }
1440
+ get disposeAfter() {
1441
+ return this.#r;
1442
+ }
1443
+ constructor(t) {
1444
+ let { max: e = 0, ttl: s, ttlResolution: i = 1, ttlAutopurge: n, updateAgeOnGet: o, updateAgeOnHas: a, allowStale: h, dispose: l, onInsert: c, disposeAfter: f, noDisposeOnSet: p, noUpdateTTL: d, maxSize: g = 0, maxEntrySize: u = 0, sizeCalculation: w, fetchMethod: m, memoMethod: b, noDeleteOnFetchRejection: v, noDeleteOnStaleGet: S, allowStaleOnFetchRejection: y, allowStaleOnFetchAbort: q, ignoreFetchAbort: W, backgroundFetchSize: I = 1, perf: et } = t;
1445
+ if (this.backgroundFetchSize = I, et !== void 0 && typeof et?.now != "function") throw new TypeError("perf option must have a now() method if specified");
1446
+ if (this.#p = et ?? yi, e !== 0 && !V(e)) throw new TypeError("max option must be a nonnegative integer");
1447
+ let te = e ? ns(e) : Array;
1448
+ if (!te) throw new Error("invalid max value: " + e);
1449
+ if (this.#t = e, this.#i = g, this.maxEntrySize = u || this.#i, this.sizeCalculation = w, this.sizeCalculation) {
1450
+ if (!this.#i && !this.maxEntrySize) throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");
1451
+ if (typeof this.sizeCalculation != "function") throw new TypeError("sizeCalculation set to non-function");
1452
+ }
1453
+ if (b !== void 0 && typeof b != "function") throw new TypeError("memoMethod must be a function if defined");
1454
+ if (this.#c = b, m !== void 0 && typeof m != "function") throw new TypeError("fetchMethod must be a function if specified");
1455
+ if (this.#d = m, this.#O = !!m, this.#a = new Map(), this.#l = Array.from({ length: e }).fill(void 0), this.#n = Array.from({ length: e }).fill(void 0), this.#w = new te(e), this.#x = new te(e), this.#b = 0, this.#f = 0, this.#v = xi.create(e), this.#h = 0, this.#m = 0, typeof l == "function" && (this.#e = l), typeof c == "function" && (this.#o = c), typeof f == "function" ? (this.#r = f, this.#y = []) : (this.#r = void 0, this.#y = void 0), this.#C = !!this.#e, this.#F = !!this.#o, this.#s = !!this.#r, this.noDisposeOnSet = !!p, this.noUpdateTTL = !!d, this.noDeleteOnFetchRejection = !!v, this.allowStaleOnFetchRejection = !!y, this.allowStaleOnFetchAbort = !!q, this.ignoreFetchAbort = !!W, this.maxEntrySize !== 0) {
1456
+ if (this.#i !== 0 && !V(this.#i)) throw new TypeError("maxSize must be a positive integer if specified");
1457
+ if (!V(this.maxEntrySize)) throw new TypeError("maxEntrySize must be a positive integer if specified");
1458
+ this.#G();
1459
+ }
1460
+ if (this.allowStale = !!h, this.noDeleteOnStaleGet = !!S, this.updateAgeOnGet = !!o, this.updateAgeOnHas = !!a, this.ttlResolution = V(i) || i === 0 ? i : 1, this.ttlAutopurge = !!n, this.ttl = s || 0, this.ttl) {
1461
+ if (!V(this.ttl)) throw new TypeError("ttl must be a positive integer if specified");
1462
+ this.#_();
1463
+ }
1464
+ if (this.#t === 0 && this.ttl === 0 && this.#i === 0) throw new TypeError("At least one of max, maxSize, or ttl is required");
1465
+ if (!this.ttlAutopurge && !this.#t && !this.#i) {
1466
+ let ee = "LRU_CACHE_UNBOUNDED";
1467
+ vi(ee) && (is.add(ee), Si("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.", "UnboundedCacheWarning", ee, rs));
1468
+ }
1469
+ }
1470
+ getRemainingTTL(t) {
1471
+ return this.#a.has(t) ? 1 / 0 : 0;
1472
+ }
1473
+ #_() {
1474
+ let t = new Pt(this.#t), e = new Pt(this.#t);
1475
+ this.#g = t, this.#k = e;
1476
+ let s = this.ttlAutopurge ? Array.from({ length: this.#t }) : void 0;
1477
+ this.#S = s, this.#W = (h, l, c = this.#p.now()) => {
1478
+ e[h] = l !== 0 ? c : 0, t[h] = l, i(h, l);
1479
+ }, this.#R = (h) => {
1480
+ e[h] = t[h] !== 0 ? this.#p.now() : 0, i(h, t[h]);
1481
+ };
1482
+ let i = this.ttlAutopurge ? (h, l) => {
1483
+ if (s?.[h] && (clearTimeout(s[h]), s[h] = void 0), l && l !== 0 && s) {
1484
+ let c = setTimeout(() => {
1485
+ this.#A(h) ? (this.#j(this.#l[h], "expire"), s[h] = void 0) : i(h, a(h));
1486
+ }, l + 1);
1487
+ c.unref && c.unref(), s[h] = c;
1488
+ }
1489
+ } : () => {};
1490
+ this.#D = (h, l) => {
1491
+ if (t[l]) {
1492
+ let c = t[l], f = e[l];
1493
+ if (!c || !f) return;
1494
+ h.ttl = c, h.start = f, h.now = n || o();
1495
+ h.remainingTTL = c - (h.now - f);
1496
+ }
1497
+ };
1498
+ let n = 0, o = () => {
1499
+ let h = this.#p.now();
1500
+ if (this.ttlResolution > 0) {
1501
+ n = h;
1502
+ let l = setTimeout(() => n = 0, this.ttlResolution);
1503
+ l.unref && l.unref();
1504
+ }
1505
+ return h;
1506
+ };
1507
+ this.getRemainingTTL = (h) => {
1508
+ let l = this.#a.get(h);
1509
+ return l === void 0 ? 0 : a(l);
1510
+ };
1511
+ let a = (h) => {
1512
+ let l = t[h], c = e[h];
1513
+ if (!l || !c) return 1 / 0;
1514
+ return l - ((n || o()) - c);
1515
+ };
1516
+ this.#A = (h) => {
1517
+ let l = e[h], c = t[h];
1518
+ return !!c && !!l && (n || o()) - l > c;
1519
+ };
1520
+ }
1521
+ #R = () => {};
1522
+ #D = () => {};
1523
+ #W = () => {};
1524
+ #A = () => !1;
1525
+ #G() {
1526
+ let t = new Pt(this.#t);
1527
+ this.#m = 0, this.#E = t, this.#P = (e) => {
1528
+ this.#m -= t[e], t[e] = 0;
1529
+ }, this.#$ = (e, s, i, n) => {
1530
+ if (!V(i)) {
1531
+ if (this.#u(s)) return this.backgroundFetchSize;
1532
+ if (n) {
1533
+ if (typeof n != "function") throw new TypeError("sizeCalculation must be a function");
1534
+ if (i = n(s, e), !V(i)) throw new TypeError("sizeCalculation return invalid (expect positive integer)");
1535
+ } else throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");
1536
+ }
1537
+ return i;
1538
+ }, this.#N = (e, s, i) => {
1539
+ if (t[e] = s, this.#i) {
1540
+ let n = this.#i - t[e];
1541
+ for (; this.#m > n;) this.#U(!0);
1542
+ }
1543
+ this.#m += t[e], i && (i.entrySize = s, i.totalCalculatedSize = this.#m);
1544
+ };
1545
+ }
1546
+ #P = (t) => {};
1547
+ #N = (t, e, s) => {};
1548
+ #$ = (t, e, s, i) => {
1549
+ if (s || i) throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");
1550
+ return 0;
1551
+ };
1552
+ *#M({ allowStale: t = this.allowStale } = {}) {
1553
+ if (this.#h) for (let e = this.#f; this.#B(e) && ((t || !this.#A(e)) && (yield e), e !== this.#b);) e = this.#x[e];
1554
+ }
1555
+ *#T({ allowStale: t = this.allowStale } = {}) {
1556
+ if (this.#h) for (let e = this.#b; this.#B(e) && ((t || !this.#A(e)) && (yield e), e !== this.#f);) e = this.#w[e];
1557
+ }
1558
+ #B(t) {
1559
+ return t !== void 0 && this.#a.get(this.#l[t]) === t;
1560
+ }
1561
+ *entries() {
1562
+ for (let t of this.#M()) this.#n[t] !== void 0 && this.#l[t] !== void 0 && !this.#u(this.#n[t]) && (yield [this.#l[t], this.#n[t]]);
1563
+ }
1564
+ *rentries() {
1565
+ for (let t of this.#T()) this.#n[t] !== void 0 && this.#l[t] !== void 0 && !this.#u(this.#n[t]) && (yield [this.#l[t], this.#n[t]]);
1566
+ }
1567
+ *keys() {
1568
+ for (let t of this.#M()) {
1569
+ let e = this.#l[t];
1570
+ e !== void 0 && !this.#u(this.#n[t]) && (yield e);
1571
+ }
1572
+ }
1573
+ *rkeys() {
1574
+ for (let t of this.#T()) {
1575
+ let e = this.#l[t];
1576
+ e !== void 0 && !this.#u(this.#n[t]) && (yield e);
1577
+ }
1578
+ }
1579
+ *values() {
1580
+ for (let t of this.#M()) this.#n[t] !== void 0 && !this.#u(this.#n[t]) && (yield this.#n[t]);
1581
+ }
1582
+ *rvalues() {
1583
+ for (let t of this.#T()) this.#n[t] !== void 0 && !this.#u(this.#n[t]) && (yield this.#n[t]);
1584
+ }
1585
+ [Symbol.iterator]() {
1586
+ return this.entries();
1587
+ }
1588
+ [Symbol.toStringTag] = "LRUCache";
1589
+ find(t, e = {}) {
1590
+ for (let s of this.#M()) {
1591
+ let i = this.#n[s], n = this.#u(i) ? i.__staleWhileFetching : i;
1592
+ if (n !== void 0 && t(n, this.#l[s], this)) return this.#K(this.#l[s], e);
1593
+ }
1594
+ }
1595
+ forEach(t, e = this) {
1596
+ for (let s of this.#M()) {
1597
+ let i = this.#n[s], n = this.#u(i) ? i.__staleWhileFetching : i;
1598
+ n !== void 0 && t.call(e, n, this.#l[s], this);
1599
+ }
1600
+ }
1601
+ rforEach(t, e = this) {
1602
+ for (let s of this.#T()) {
1603
+ let i = this.#n[s], n = this.#u(i) ? i.__staleWhileFetching : i;
1604
+ n !== void 0 && t.call(e, n, this.#l[s], this);
1605
+ }
1606
+ }
1607
+ purgeStale() {
1608
+ let t = !1;
1609
+ for (let e of this.#T({ allowStale: !0 })) this.#A(e) && (this.#j(this.#l[e], "expire"), t = !0);
1610
+ return t;
1611
+ }
1612
+ info(t) {
1613
+ let e = this.#a.get(t);
1614
+ if (e === void 0) return;
1615
+ let s = this.#n[e], i = this.#u(s) ? s.__staleWhileFetching : s;
1616
+ if (i === void 0) return;
1617
+ let n = { value: i };
1618
+ if (this.#g && this.#k) {
1619
+ let o = this.#g[e], a = this.#k[e];
1620
+ if (o && a) n.ttl = o - (this.#p.now() - a), n.start = Date.now();
1621
+ }
1622
+ return this.#E && (n.size = this.#E[e]), n;
1623
+ }
1624
+ dump() {
1625
+ let t = [];
1626
+ for (let e of this.#M({ allowStale: !0 })) {
1627
+ let s = this.#l[e], i = this.#n[e], n = this.#u(i) ? i.__staleWhileFetching : i;
1628
+ if (n === void 0 || s === void 0) continue;
1629
+ let o = { value: n };
1630
+ if (this.#g && this.#k) {
1631
+ o.ttl = this.#g[e];
1632
+ let a = this.#p.now() - this.#k[e];
1633
+ o.start = Math.floor(Date.now() - a);
1634
+ }
1635
+ this.#E && (o.size = this.#E[e]), t.unshift([s, o]);
1636
+ }
1637
+ return t;
1638
+ }
1639
+ load(t) {
1640
+ this.clear();
1641
+ for (let [e, s] of t) {
1642
+ if (s.start) {
1643
+ let i = Date.now() - s.start;
1644
+ s.start = this.#p.now() - i;
1645
+ }
1646
+ this.#z(e, s.value, s);
1647
+ }
1648
+ }
1649
+ set(t, e, s = {}) {
1650
+ let { status: i = R.hasSubscribers ? {} : void 0 } = s;
1651
+ s.status = i, i && (i.op = "set", i.key = t, e !== void 0 && (i.value = e), i.cache = this);
1652
+ let n = this.#z(t, e, s);
1653
+ return i && R.hasSubscribers && R.publish(i), n;
1654
+ }
1655
+ #z(t, e, s, i) {
1656
+ let { ttl: n = this.ttl, start: o, noDisposeOnSet: a = this.noDisposeOnSet, sizeCalculation: h = this.sizeCalculation, status: l } = s, c = this.#u(e);
1657
+ if (e === void 0) return l && (l.set = "deleted"), this.delete(t), this;
1658
+ let { noUpdateTTL: f = this.noUpdateTTL } = s;
1659
+ l && !c && (l.value = e);
1660
+ let p = this.#$(t, e, s.size || 0, h, l);
1661
+ if (this.maxEntrySize && p > this.maxEntrySize) return this.#j(t, "set"), l && (l.set = "miss", l.maxEntrySizeExceeded = !0), this;
1662
+ let d = this.#h === 0 ? void 0 : this.#a.get(t);
1663
+ if (d === void 0) d = this.#h === 0 ? this.#f : this.#v.length !== 0 ? this.#v.pop() : this.#h === this.#t ? this.#U(!1) : this.#h, this.#l[d] = t, this.#n[d] = e, this.#a.set(t, d), this.#w[this.#f] = d, this.#x[d] = this.#f, this.#f = d, this.#h++, this.#N(d, p, l), l && (l.set = "add"), f = !1, this.#F && !c && this.#o?.(e, t, "add");
1664
+ else {
1665
+ this.#X(d);
1666
+ let g = this.#n[d];
1667
+ if (e !== g) {
1668
+ if (!a) if (this.#u(g)) {
1669
+ g !== i && g.__abortController.abort(new Error("replaced"));
1670
+ let { __staleWhileFetching: u } = g;
1671
+ u !== void 0 && u !== e && (this.#C && this.#e?.(u, t, "set"), this.#s && this.#y?.push([
1672
+ u,
1673
+ t,
1674
+ "set"
1675
+ ]));
1676
+ } else this.#C && this.#e?.(g, t, "set"), this.#s && this.#y?.push([
1677
+ g,
1678
+ t,
1679
+ "set"
1680
+ ]);
1681
+ if (this.#P(d), this.#N(d, p, l), this.#n[d] = e, !c) {
1682
+ let u = g && this.#u(g) ? g.__staleWhileFetching : g, w = u === void 0 ? "add" : e !== u ? "replace" : "update";
1683
+ l && (l.set = w, u !== void 0 && (l.oldValue = u)), this.#F && this.onInsert?.(e, t, w);
1684
+ }
1685
+ } else c || (l && (l.set = "update"), this.#F && this.onInsert?.(e, t, "update"));
1686
+ }
1687
+ if (n !== 0 && !this.#g && this.#_(), this.#g && (f || this.#W(d, n, o), l && this.#D(l, d)), !a && this.#s && this.#y) {
1688
+ let g = this.#y, u;
1689
+ for (; u = g?.shift();) this.#r?.(...u);
1690
+ }
1691
+ return this;
1692
+ }
1693
+ pop() {
1694
+ try {
1695
+ for (; this.#h;) {
1696
+ let t = this.#n[this.#b];
1697
+ if (this.#U(!0), this.#u(t)) {
1698
+ if (t.__staleWhileFetching) return t.__staleWhileFetching;
1699
+ } else if (t !== void 0) return t;
1700
+ }
1701
+ } finally {
1702
+ if (this.#s && this.#y) {
1703
+ let t = this.#y, e;
1704
+ for (; e = t?.shift();) this.#r?.(...e);
1705
+ }
1706
+ }
1707
+ }
1708
+ #U(t) {
1709
+ let e = this.#b, s = this.#l[e], i = this.#n[e], n = this.#u(i);
1710
+ n && i.__abortController.abort(new Error("evicted"));
1711
+ let o = n ? i.__staleWhileFetching : i;
1712
+ return (this.#C || this.#s) && o !== void 0 && (this.#C && this.#e?.(o, s, "evict"), this.#s && this.#y?.push([
1713
+ o,
1714
+ s,
1715
+ "evict"
1716
+ ])), this.#P(e), this.#S?.[e] && (clearTimeout(this.#S[e]), this.#S[e] = void 0), t && (this.#l[e] = void 0, this.#n[e] = void 0, this.#v.push(e)), this.#h === 1 ? (this.#b = this.#f = 0, this.#v.length = 0) : this.#b = this.#w[e], this.#a.delete(s), this.#h--, e;
1717
+ }
1718
+ has(t, e = {}) {
1719
+ let { status: s = R.hasSubscribers ? {} : void 0 } = e;
1720
+ e.status = s, s && (s.op = "has", s.key = t, s.cache = this);
1721
+ let i = this.#V(t, e);
1722
+ return R.hasSubscribers && R.publish(s), i;
1723
+ }
1724
+ #V(t, e = {}) {
1725
+ let { updateAgeOnHas: s = this.updateAgeOnHas, status: i } = e, n = this.#a.get(t);
1726
+ if (n !== void 0) {
1727
+ let o = this.#n[n];
1728
+ if (this.#u(o) && o.__staleWhileFetching === void 0) return !1;
1729
+ if (this.#A(n)) i && (i.has = "stale", this.#D(i, n));
1730
+ else return s && this.#R(n), i && (i.has = "hit", this.#D(i, n)), !0;
1731
+ } else i && (i.has = "miss");
1732
+ return !1;
1733
+ }
1734
+ peek(t, e = {}) {
1735
+ let { status: s = be() ? {} : void 0 } = e;
1736
+ s && (s.op = "peek", s.key = t, s.cache = this), e.status = s;
1737
+ let i = this.#H(t, e);
1738
+ return R.hasSubscribers && R.publish(s), i;
1739
+ }
1740
+ #H(t, e) {
1741
+ let { status: s, allowStale: i = this.allowStale } = e, n = this.#a.get(t);
1742
+ if (n === void 0 || !i && this.#A(n)) {
1743
+ s && (s.peek = n === void 0 ? "miss" : "stale");
1744
+ return;
1745
+ }
1746
+ let o = this.#n[n], a = this.#u(o) ? o.__staleWhileFetching : o;
1747
+ return s && (a !== void 0 ? (s.peek = "hit", s.value = a) : s.peek = "miss"), a;
1748
+ }
1749
+ #L(t, e, s, i) {
1750
+ let n = e === void 0 ? void 0 : this.#n[e];
1751
+ if (this.#u(n)) return n;
1752
+ let o = new AbortController(), { signal: a } = s;
1753
+ a?.addEventListener("abort", () => o.abort(a.reason), { signal: o.signal });
1754
+ let h = {
1755
+ signal: o.signal,
1756
+ options: s,
1757
+ context: i
1758
+ }, l = (u, w = !1) => {
1759
+ let { aborted: m } = o.signal, b = s.ignoreFetchAbort && u !== void 0, v = s.ignoreFetchAbort || !!(s.allowStaleOnFetchAbort && u !== void 0);
1760
+ if (s.status && (m && !w ? (s.status.fetchAborted = !0, s.status.fetchError = o.signal.reason, b && (s.status.fetchAbortIgnored = !0)) : s.status.fetchResolved = !0), m && !b && !w) return f(o.signal.reason, v);
1761
+ let S = d, y = this.#n[e];
1762
+ return (y === d || y === void 0 && b && w) && (u === void 0 ? S.__staleWhileFetching !== void 0 ? this.#n[e] = S.__staleWhileFetching : this.#j(t, "fetch") : (s.status && (s.status.fetchUpdated = !0), this.#z(t, u, h.options, S))), u;
1763
+ }, c = (u) => (s.status && (s.status.fetchRejected = !0, s.status.fetchError = u), f(u, !1)), f = (u, w) => {
1764
+ let { aborted: m } = o.signal, b = m && s.allowStaleOnFetchAbort, v = b || s.allowStaleOnFetchRejection, S = v || s.noDeleteOnFetchRejection, y = d;
1765
+ if (this.#n[e] === d && (!S || !w && y.__staleWhileFetching === void 0 ? this.#j(t, "fetch") : b || (this.#n[e] = y.__staleWhileFetching)), v) return s.status && y.__staleWhileFetching !== void 0 && (s.status.returnedStale = !0), y.__staleWhileFetching;
1766
+ if (y.__returned === y) throw u;
1767
+ }, p = (u, w) => {
1768
+ let m = this.#d?.(t, n, h);
1769
+ o.signal.addEventListener("abort", () => {
1770
+ (!s.ignoreFetchAbort || s.allowStaleOnFetchAbort) && (u(void 0), s.allowStaleOnFetchAbort && (u = (b) => l(b, !0)));
1771
+ }), m && m instanceof Promise ? m.then((b) => u(b === void 0 ? void 0 : b), w) : m !== void 0 && u(m);
1772
+ };
1773
+ s.status && (s.status.fetchDispatched = !0);
1774
+ let d = new Promise(p).then(l, c), g = Object.assign(d, {
1775
+ __abortController: o,
1776
+ __staleWhileFetching: n,
1777
+ __returned: void 0
1778
+ });
1779
+ return e === void 0 ? (this.#z(t, g, {
1780
+ ...h.options,
1781
+ status: void 0
1782
+ }), e = this.#a.get(t)) : this.#n[e] = g, g;
1783
+ }
1784
+ #u(t) {
1785
+ if (!this.#O) return !1;
1786
+ let e = t;
1787
+ return !!e && e instanceof Promise && e.hasOwnProperty("__staleWhileFetching") && e.__abortController instanceof AbortController;
1788
+ }
1789
+ fetch(t, e = {}) {
1790
+ let s = mt.hasSubscribers, { status: i = be() ? {} : void 0 } = e;
1791
+ e.status = i, i && e.context && (i.context = e.context);
1792
+ let n = this.#q(t, e);
1793
+ return i && s && (i.trace = !0, mt.tracePromise(() => n, i).catch(() => {})), n;
1794
+ }
1795
+ async #q(t, e = {}) {
1796
+ let { allowStale: s = this.allowStale, updateAgeOnGet: i = this.updateAgeOnGet, noDeleteOnStaleGet: n = this.noDeleteOnStaleGet, ttl: o = this.ttl, noDisposeOnSet: a = this.noDisposeOnSet, size: h = 0, sizeCalculation: l = this.sizeCalculation, noUpdateTTL: c = this.noUpdateTTL, noDeleteOnFetchRejection: f = this.noDeleteOnFetchRejection, allowStaleOnFetchRejection: p = this.allowStaleOnFetchRejection, ignoreFetchAbort: d = this.ignoreFetchAbort, allowStaleOnFetchAbort: g = this.allowStaleOnFetchAbort, context: u, forceRefresh: w = !1, status: m, signal: b } = e;
1797
+ if (m && (m.op = "fetch", m.key = t, w && (m.forceRefresh = !0), m.cache = this), !this.#O) return m && (m.fetch = "get"), this.#K(t, {
1798
+ allowStale: s,
1799
+ updateAgeOnGet: i,
1800
+ noDeleteOnStaleGet: n,
1801
+ status: m
1802
+ });
1803
+ let v = {
1804
+ allowStale: s,
1805
+ updateAgeOnGet: i,
1806
+ noDeleteOnStaleGet: n,
1807
+ ttl: o,
1808
+ noDisposeOnSet: a,
1809
+ size: h,
1810
+ sizeCalculation: l,
1811
+ noUpdateTTL: c,
1812
+ noDeleteOnFetchRejection: f,
1813
+ allowStaleOnFetchRejection: p,
1814
+ allowStaleOnFetchAbort: g,
1815
+ ignoreFetchAbort: d,
1816
+ status: m,
1817
+ signal: b
1818
+ }, S = this.#a.get(t);
1819
+ if (S === void 0) {
1820
+ m && (m.fetch = "miss");
1821
+ let y = this.#L(t, S, v, u);
1822
+ return y.__returned = y;
1823
+ } else {
1824
+ let y = this.#n[S];
1825
+ if (this.#u(y)) {
1826
+ let et = s && y.__staleWhileFetching !== void 0;
1827
+ return m && (m.fetch = "inflight", et && (m.returnedStale = !0)), et ? y.__staleWhileFetching : y.__returned = y;
1828
+ }
1829
+ let q = this.#A(S);
1830
+ if (!w && !q) return m && (m.fetch = "hit"), this.#X(S), i && this.#R(S), m && this.#D(m, S), y;
1831
+ let W = this.#L(t, S, v, u), I = W.__staleWhileFetching !== void 0 && s;
1832
+ return m && (m.fetch = q ? "stale" : "refresh", I && q && (m.returnedStale = !0)), I ? W.__staleWhileFetching : W.__returned = W;
1833
+ }
1834
+ }
1835
+ forceFetch(t, e = {}) {
1836
+ let s = mt.hasSubscribers, { status: i = be() ? {} : void 0 } = e;
1837
+ e.status = i, i && e.context && (i.context = e.context);
1838
+ let n = this.#I(t, e);
1839
+ return i && s && (i.trace = !0, mt.tracePromise(() => n, i).catch(() => {})), n;
1840
+ }
1841
+ async #I(t, e = {}) {
1842
+ let s = await this.#q(t, e);
1843
+ if (s === void 0) throw new Error("fetch() returned undefined");
1844
+ return s;
1845
+ }
1846
+ memo(t, e = {}) {
1847
+ let { status: s = R.hasSubscribers ? {} : void 0 } = e;
1848
+ e.status = s, s && (s.op = "memo", s.key = t, e.context && (s.context = e.context), s.cache = this);
1849
+ let i = this.#J(t, e);
1850
+ return s && (s.value = i), R.hasSubscribers && R.publish(s), i;
1851
+ }
1852
+ #J(t, e = {}) {
1853
+ let s = this.#c;
1854
+ if (!s) throw new Error("no memoMethod provided to constructor");
1855
+ let { context: i, status: n, forceRefresh: o, ...a } = e;
1856
+ n && o && (n.forceRefresh = !0);
1857
+ let h = this.#K(t, a), l = o || h === void 0;
1858
+ if (n && (n.memo = l ? "miss" : "hit", l || (n.value = h)), !l) return h;
1859
+ let c = s(t, h, {
1860
+ options: a,
1861
+ context: i
1862
+ });
1863
+ return n && (n.value = c), this.#z(t, c, a), c;
1864
+ }
1865
+ get(t, e = {}) {
1866
+ let { status: s = R.hasSubscribers ? {} : void 0 } = e;
1867
+ e.status = s, s && (s.op = "get", s.key = t, s.cache = this);
1868
+ let i = this.#K(t, e);
1869
+ return s && (i !== void 0 && (s.value = i), R.hasSubscribers && R.publish(s)), i;
1870
+ }
1871
+ #K(t, e = {}) {
1872
+ let { allowStale: s = this.allowStale, updateAgeOnGet: i = this.updateAgeOnGet, noDeleteOnStaleGet: n = this.noDeleteOnStaleGet, status: o } = e, a = this.#a.get(t);
1873
+ if (a === void 0) {
1874
+ o && (o.get = "miss");
1875
+ return;
1876
+ }
1877
+ let h = this.#n[a], l = this.#u(h);
1878
+ return o && this.#D(o, a), this.#A(a) ? l ? (o && (o.get = "stale-fetching"), s && h.__staleWhileFetching !== void 0 ? (o && (o.returnedStale = !0), h.__staleWhileFetching) : void 0) : (n || this.#j(t, "expire"), o && (o.get = "stale"), s ? (o && (o.returnedStale = !0), h) : void 0) : (o && (o.get = l ? "fetching" : "hit"), this.#X(a), i && this.#R(a), l ? h.__staleWhileFetching : h);
1879
+ }
1880
+ #Y(t, e) {
1881
+ this.#x[e] = t, this.#w[t] = e;
1882
+ }
1883
+ #X(t) {
1884
+ t !== this.#f && (t === this.#b ? this.#b = this.#w[t] : this.#Y(this.#x[t], this.#w[t]), this.#Y(this.#f, t), this.#f = t);
1885
+ }
1886
+ delete(t) {
1887
+ return this.#j(t, "delete");
1888
+ }
1889
+ #j(t, e) {
1890
+ R.hasSubscribers && R.publish({
1891
+ op: "delete",
1892
+ delete: e,
1893
+ key: t,
1894
+ cache: this
1895
+ });
1896
+ let s = !1;
1897
+ if (this.#h !== 0) {
1898
+ let i = this.#a.get(t);
1899
+ if (i !== void 0) if (this.#S?.[i] && (clearTimeout(this.#S[i]), this.#S[i] = void 0), s = !0, this.#h === 1) this.#Z(e);
1900
+ else {
1901
+ this.#P(i);
1902
+ let n = this.#n[i];
1903
+ if (this.#u(n) ? n.__abortController.abort(new Error("deleted")) : (this.#C || this.#s) && (this.#C && this.#e?.(n, t, e), this.#s && this.#y?.push([
1904
+ n,
1905
+ t,
1906
+ e
1907
+ ])), this.#a.delete(t), this.#l[i] = void 0, this.#n[i] = void 0, i === this.#f) this.#f = this.#x[i];
1908
+ else if (i === this.#b) this.#b = this.#w[i];
1909
+ else {
1910
+ let o = this.#x[i];
1911
+ this.#w[o] = this.#w[i];
1912
+ let a = this.#w[i];
1913
+ this.#x[a] = this.#x[i];
1914
+ }
1915
+ this.#h--, this.#v.push(i);
1916
+ }
1917
+ }
1918
+ if (this.#s && this.#y?.length) {
1919
+ let i = this.#y, n;
1920
+ for (; n = i?.shift();) this.#r?.(...n);
1921
+ }
1922
+ return s;
1923
+ }
1924
+ clear() {
1925
+ return this.#Z("delete");
1926
+ }
1927
+ #Z(t) {
1928
+ for (let e of this.#T({ allowStale: !0 })) {
1929
+ let s = this.#n[e];
1930
+ if (this.#u(s)) s.__abortController.abort(new Error("deleted"));
1931
+ else {
1932
+ let i = this.#l[e];
1933
+ this.#C && this.#e?.(s, i, t), this.#s && this.#y?.push([
1934
+ s,
1935
+ i,
1936
+ t
1937
+ ]);
1938
+ }
1939
+ }
1940
+ if (this.#a.clear(), this.#n.fill(void 0), this.#l.fill(void 0), this.#g && this.#k) {
1941
+ this.#g.fill(0), this.#k.fill(0);
1942
+ for (let e of this.#S ?? []) e !== void 0 && clearTimeout(e);
1943
+ this.#S?.fill(void 0);
1944
+ }
1945
+ if (this.#E && this.#E.fill(0), this.#b = 0, this.#f = 0, this.#v.length = 0, this.#m = 0, this.#h = 0, this.#s && this.#y) {
1946
+ let e = this.#y, s;
1947
+ for (; s = e?.shift();) this.#r?.(...s);
1948
+ }
1949
+ }
1950
+ };
1951
+ var os = typeof process == "object" && process ? process : {
1952
+ stdout: null,
1953
+ stderr: null
1954
+ };
1955
+ var ki = (r) => !!r && typeof r == "object" && (r instanceof Z || r instanceof cs || Ci(r) || Ai(r));
1956
+ var Ci = (r) => !!r && typeof r == "object" && r instanceof EventEmitter && typeof r.pipe == "function" && r.pipe !== cs.Writable.prototype.pipe;
1957
+ var Ai = (r) => !!r && typeof r == "object" && r instanceof EventEmitter && typeof r.write == "function" && typeof r.end == "function";
1958
+ var G = Symbol("EOF");
1959
+ var H = Symbol("maybeEmitEnd");
1960
+ var Y = Symbol("emittedEnd");
1961
+ var zt = Symbol("emittingEnd");
1962
+ var bt = Symbol("emittedError");
1963
+ var Lt = Symbol("closed");
1964
+ var hs = Symbol("read");
1965
+ var jt = Symbol("flush");
1966
+ var as = Symbol("flushChunk");
1967
+ var z = Symbol("encoding");
1968
+ var it = Symbol("decoder");
1969
+ var k = Symbol("flowing");
1970
+ var yt = Symbol("paused");
1971
+ var nt = Symbol("resume");
1972
+ var C = Symbol("buffer");
1973
+ var T = Symbol("pipes");
1974
+ var A = Symbol("bufferLength");
1975
+ var ye = Symbol("bufferPush");
1976
+ var Wt = Symbol("bufferShift");
1977
+ var O = Symbol("objectMode");
1978
+ var E = Symbol("destroyed");
1979
+ var Se = Symbol("error");
1980
+ var ve = Symbol("emitData");
1981
+ var ls = Symbol("emitEnd");
1982
+ var xe = Symbol("emitEnd2");
1983
+ var $ = Symbol("async");
1984
+ var Ee = Symbol("abort");
1985
+ var $t = Symbol("aborted");
1986
+ var St = Symbol("signal");
1987
+ var Q = Symbol("dataListeners");
1988
+ var _ = Symbol("discarded");
1989
+ var vt = (r) => Promise.resolve().then(r);
1990
+ var Ri = (r) => r();
1991
+ var Oi = (r) => r === "end" || r === "finish" || r === "prefinish";
1992
+ var Mi = (r) => r instanceof ArrayBuffer || !!r && typeof r == "object" && r.constructor && r.constructor.name === "ArrayBuffer" && r.byteLength >= 0;
1993
+ var Ti = (r) => !Buffer.isBuffer(r) && ArrayBuffer.isView(r);
1994
+ var Bt = class {
1995
+ src;
1996
+ dest;
1997
+ opts;
1998
+ ondrain;
1999
+ constructor(t, e, s) {
2000
+ this.src = t, this.dest = e, this.opts = s, this.ondrain = () => t[nt](), this.dest.on("drain", this.ondrain);
2001
+ }
2002
+ unpipe() {
2003
+ this.dest.removeListener("drain", this.ondrain);
2004
+ }
2005
+ proxyErrors(t) {}
2006
+ end() {
2007
+ this.unpipe(), this.opts.end && this.dest.end();
2008
+ }
2009
+ };
2010
+ var ke = class extends Bt {
2011
+ unpipe() {
2012
+ this.src.removeListener("error", this.proxyErrors), super.unpipe();
2013
+ }
2014
+ constructor(t, e, s) {
2015
+ super(t, e, s), this.proxyErrors = (i) => this.dest.emit("error", i), t.on("error", this.proxyErrors);
2016
+ }
2017
+ };
2018
+ var Fi = (r) => !!r.objectMode;
2019
+ var _i = (r) => !r.objectMode && !!r.encoding && r.encoding !== "buffer";
2020
+ var Z = class extends EventEmitter {
2021
+ [k] = !1;
2022
+ [yt] = !1;
2023
+ [T] = [];
2024
+ [C] = [];
2025
+ [O];
2026
+ [z];
2027
+ [$];
2028
+ [it];
2029
+ [G] = !1;
2030
+ [Y] = !1;
2031
+ [zt] = !1;
2032
+ [Lt] = !1;
2033
+ [bt] = null;
2034
+ [A] = 0;
2035
+ [E] = !1;
2036
+ [St];
2037
+ [$t] = !1;
2038
+ [Q] = 0;
2039
+ [_] = !1;
2040
+ writable = !0;
2041
+ readable = !0;
2042
+ constructor(...t) {
2043
+ let e = t[0] || {};
2044
+ if (super(), e.objectMode && typeof e.encoding == "string") throw new TypeError("Encoding and objectMode may not be used together");
2045
+ Fi(e) ? (this[O] = !0, this[z] = null) : _i(e) ? (this[z] = e.encoding, this[O] = !1) : (this[O] = !1, this[z] = null), this[$] = !!e.async, this[it] = this[z] ? new StringDecoder(this[z]) : null, e && e.debugExposeBuffer === !0 && Object.defineProperty(this, "buffer", { get: () => this[C] }), e && e.debugExposePipes === !0 && Object.defineProperty(this, "pipes", { get: () => this[T] });
2046
+ let { signal: s } = e;
2047
+ s && (this[St] = s, s.aborted ? this[Ee]() : s.addEventListener("abort", () => this[Ee]()));
2048
+ }
2049
+ get bufferLength() {
2050
+ return this[A];
2051
+ }
2052
+ get encoding() {
2053
+ return this[z];
2054
+ }
2055
+ set encoding(t) {
2056
+ throw new Error("Encoding must be set at instantiation time");
2057
+ }
2058
+ setEncoding(t) {
2059
+ throw new Error("Encoding must be set at instantiation time");
2060
+ }
2061
+ get objectMode() {
2062
+ return this[O];
2063
+ }
2064
+ set objectMode(t) {
2065
+ throw new Error("objectMode must be set at instantiation time");
2066
+ }
2067
+ get async() {
2068
+ return this[$];
2069
+ }
2070
+ set async(t) {
2071
+ this[$] = this[$] || !!t;
2072
+ }
2073
+ [Ee]() {
2074
+ this[$t] = !0, this.emit("abort", this[St]?.reason), this.destroy(this[St]?.reason);
2075
+ }
2076
+ get aborted() {
2077
+ return this[$t];
2078
+ }
2079
+ set aborted(t) {}
2080
+ write(t, e, s) {
2081
+ if (this[$t]) return !1;
2082
+ if (this[G]) throw new Error("write after end");
2083
+ if (this[E]) return this.emit("error", Object.assign(new Error("Cannot call write after a stream was destroyed"), { code: "ERR_STREAM_DESTROYED" })), !0;
2084
+ typeof e == "function" && (s = e, e = "utf8"), e || (e = "utf8");
2085
+ let i = this[$] ? vt : Ri;
2086
+ if (!this[O] && !Buffer.isBuffer(t)) {
2087
+ if (Ti(t)) t = Buffer.from(t.buffer, t.byteOffset, t.byteLength);
2088
+ else if (Mi(t)) t = Buffer.from(t);
2089
+ else if (typeof t != "string") throw new Error("Non-contiguous data written to non-objectMode stream");
2090
+ }
2091
+ return this[O] ? (this[k] && this[A] !== 0 && this[jt](!0), this[k] ? this.emit("data", t) : this[ye](t), this[A] !== 0 && this.emit("readable"), s && i(s), this[k]) : t.length ? (typeof t == "string" && (e !== this[z] || this[it]?.lastNeed) && (t = Buffer.from(t, e)), Buffer.isBuffer(t) && this[z] && (t = this[it].write(t)), this[k] && this[A] !== 0 && this[jt](!0), this[k] ? this.emit("data", t) : this[ye](t), this[A] !== 0 && this.emit("readable"), s && i(s), this[k]) : (this[A] !== 0 && this.emit("readable"), s && i(s), this[k]);
2092
+ }
2093
+ read(t) {
2094
+ if (this[E]) return null;
2095
+ if (this[_] = !1, this[A] === 0 || t === 0 || t && t > this[A]) return this[H](), null;
2096
+ this[O] && (t = null), this[C].length > 1 && !this[O] && (this[C] = [this[z] ? this[C].join("") : Buffer.concat(this[C], this[A])]);
2097
+ let e = this[hs](t || null, this[C][0]);
2098
+ return this[H](), e;
2099
+ }
2100
+ [hs](t, e) {
2101
+ if (this[O]) this[Wt]();
2102
+ else {
2103
+ let s = e;
2104
+ t === s.length || t === null ? this[Wt]() : typeof s == "string" ? (this[C][0] = s.slice(t), e = s.slice(0, t), this[A] -= t) : (this[C][0] = s.subarray(t), e = s.subarray(0, t), this[A] -= t);
2105
+ }
2106
+ return this.emit("data", e), !this[C].length && !this[G] && this.emit("drain"), e;
2107
+ }
2108
+ end(t, e, s) {
2109
+ return typeof t == "function" && (s = t, t = void 0), typeof e == "function" && (s = e, e = "utf8"), t !== void 0 && this.write(t, e), s && this.once("end", s), this[G] = !0, this.writable = !1, (this[k] || !this[yt]) && this[H](), this;
2110
+ }
2111
+ [nt]() {
2112
+ this[E] || (!this[Q] && !this[T].length && (this[_] = !0), this[yt] = !1, this[k] = !0, this.emit("resume"), this[C].length ? this[jt]() : this[G] ? this[H]() : this.emit("drain"));
2113
+ }
2114
+ resume() {
2115
+ return this[nt]();
2116
+ }
2117
+ pause() {
2118
+ this[k] = !1, this[yt] = !0, this[_] = !1;
2119
+ }
2120
+ get destroyed() {
2121
+ return this[E];
2122
+ }
2123
+ get flowing() {
2124
+ return this[k];
2125
+ }
2126
+ get paused() {
2127
+ return this[yt];
2128
+ }
2129
+ [ye](t) {
2130
+ this[O] ? this[A] += 1 : this[A] += t.length, this[C].push(t);
2131
+ }
2132
+ [Wt]() {
2133
+ return this[O] ? this[A] -= 1 : this[A] -= this[C][0].length, this[C].shift();
2134
+ }
2135
+ [jt](t = !1) {
2136
+ do;
2137
+ while (this[as](this[Wt]()) && this[C].length);
2138
+ !t && !this[C].length && !this[G] && this.emit("drain");
2139
+ }
2140
+ [as](t) {
2141
+ return this.emit("data", t), this[k];
2142
+ }
2143
+ pipe(t, e) {
2144
+ if (this[E]) return t;
2145
+ this[_] = !1;
2146
+ let s = this[Y];
2147
+ return e = e || {}, t === os.stdout || t === os.stderr ? e.end = !1 : e.end = e.end !== !1, e.proxyErrors = !!e.proxyErrors, s ? e.end && t.end() : (this[T].push(e.proxyErrors ? new ke(this, t, e) : new Bt(this, t, e)), this[$] ? vt(() => this[nt]()) : this[nt]()), t;
2148
+ }
2149
+ unpipe(t) {
2150
+ let e = this[T].find((s) => s.dest === t);
2151
+ e && (this[T].length === 1 ? (this[k] && this[Q] === 0 && (this[k] = !1), this[T] = []) : this[T].splice(this[T].indexOf(e), 1), e.unpipe());
2152
+ }
2153
+ addListener(t, e) {
2154
+ return this.on(t, e);
2155
+ }
2156
+ on(t, e) {
2157
+ let s = super.on(t, e);
2158
+ if (t === "data") this[_] = !1, this[Q]++, !this[T].length && !this[k] && this[nt]();
2159
+ else if (t === "readable" && this[A] !== 0) super.emit("readable");
2160
+ else if (Oi(t) && this[Y]) super.emit(t), this.removeAllListeners(t);
2161
+ else if (t === "error" && this[bt]) {
2162
+ let i = e;
2163
+ this[$] ? vt(() => i.call(this, this[bt])) : i.call(this, this[bt]);
2164
+ }
2165
+ return s;
2166
+ }
2167
+ removeListener(t, e) {
2168
+ return this.off(t, e);
2169
+ }
2170
+ off(t, e) {
2171
+ let s = super.off(t, e);
2172
+ return t === "data" && (this[Q] = this.listeners("data").length, this[Q] === 0 && !this[_] && !this[T].length && (this[k] = !1)), s;
2173
+ }
2174
+ removeAllListeners(t) {
2175
+ let e = super.removeAllListeners(t);
2176
+ return (t === "data" || t === void 0) && (this[Q] = 0, !this[_] && !this[T].length && (this[k] = !1)), e;
2177
+ }
2178
+ get emittedEnd() {
2179
+ return this[Y];
2180
+ }
2181
+ [H]() {
2182
+ !this[zt] && !this[Y] && !this[E] && this[C].length === 0 && this[G] && (this[zt] = !0, this.emit("end"), this.emit("prefinish"), this.emit("finish"), this[Lt] && this.emit("close"), this[zt] = !1);
2183
+ }
2184
+ emit(t, ...e) {
2185
+ let s = e[0];
2186
+ if (t !== "error" && t !== "close" && t !== E && this[E]) return !1;
2187
+ if (t === "data") return !this[O] && !s ? !1 : this[$] ? (vt(() => this[ve](s)), !0) : this[ve](s);
2188
+ if (t === "end") return this[ls]();
2189
+ if (t === "close") {
2190
+ if (this[Lt] = !0, !this[Y] && !this[E]) return !1;
2191
+ let n = super.emit("close");
2192
+ return this.removeAllListeners("close"), n;
2193
+ } else if (t === "error") {
2194
+ this[bt] = s, super.emit(Se, s);
2195
+ let n = !this[St] || this.listeners("error").length ? super.emit("error", s) : !1;
2196
+ return this[H](), n;
2197
+ } else if (t === "resume") {
2198
+ let n = super.emit("resume");
2199
+ return this[H](), n;
2200
+ } else if (t === "finish" || t === "prefinish") {
2201
+ let n = super.emit(t);
2202
+ return this.removeAllListeners(t), n;
2203
+ }
2204
+ let i = super.emit(t, ...e);
2205
+ return this[H](), i;
2206
+ }
2207
+ [ve](t) {
2208
+ for (let s of this[T]) s.dest.write(t) === !1 && this.pause();
2209
+ let e = this[_] ? !1 : super.emit("data", t);
2210
+ return this[H](), e;
2211
+ }
2212
+ [ls]() {
2213
+ return this[Y] ? !1 : (this[Y] = !0, this.readable = !1, this[$] ? (vt(() => this[xe]()), !0) : this[xe]());
2214
+ }
2215
+ [xe]() {
2216
+ if (this[it]) {
2217
+ let e = this[it].end();
2218
+ if (e) {
2219
+ for (let s of this[T]) s.dest.write(e);
2220
+ this[_] || super.emit("data", e);
2221
+ }
2222
+ }
2223
+ for (let e of this[T]) e.end();
2224
+ let t = super.emit("end");
2225
+ return this.removeAllListeners("end"), t;
2226
+ }
2227
+ async collect() {
2228
+ let t = Object.assign([], { dataLength: 0 });
2229
+ this[O] || (t.dataLength = 0);
2230
+ let e = this.promise();
2231
+ return this.on("data", (s) => {
2232
+ t.push(s), this[O] || (t.dataLength += s.length);
2233
+ }), await e, t;
2234
+ }
2235
+ async concat() {
2236
+ if (this[O]) throw new Error("cannot concat in objectMode");
2237
+ let t = await this.collect();
2238
+ return this[z] ? t.join("") : Buffer.concat(t, t.dataLength);
2239
+ }
2240
+ async promise() {
2241
+ return new Promise((t, e) => {
2242
+ this.on(E, () => e(new Error("stream destroyed"))), this.on("error", (s) => e(s)), this.on("end", () => t());
2243
+ });
2244
+ }
2245
+ [Symbol.asyncIterator]() {
2246
+ this[_] = !1;
2247
+ let t = !1, e = async () => (this.pause(), t = !0, {
2248
+ value: void 0,
2249
+ done: !0
2250
+ });
2251
+ return {
2252
+ next: () => {
2253
+ if (t) return e();
2254
+ let i = this.read();
2255
+ if (i !== null) return Promise.resolve({
2256
+ done: !1,
2257
+ value: i
2258
+ });
2259
+ if (this[G]) return e();
2260
+ let n, o, a = (f) => {
2261
+ this.off("data", h), this.off("end", l), this.off(E, c), e(), o(f);
2262
+ }, h = (f) => {
2263
+ this.off("error", a), this.off("end", l), this.off(E, c), this.pause(), n({
2264
+ value: f,
2265
+ done: !!this[G]
2266
+ });
2267
+ }, l = () => {
2268
+ this.off("error", a), this.off("data", h), this.off(E, c), e(), n({
2269
+ done: !0,
2270
+ value: void 0
2271
+ });
2272
+ }, c = () => a(new Error("stream destroyed"));
2273
+ return new Promise((f, p) => {
2274
+ o = p, n = f, this.once(E, c), this.once("error", a), this.once("end", l), this.once("data", h);
2275
+ });
2276
+ },
2277
+ throw: e,
2278
+ return: e,
2279
+ [Symbol.asyncIterator]() {
2280
+ return this;
2281
+ },
2282
+ [Symbol.asyncDispose]: async () => {}
2283
+ };
2284
+ }
2285
+ [Symbol.iterator]() {
2286
+ this[_] = !1;
2287
+ let t = !1, e = () => (this.pause(), this.off(Se, e), this.off(E, e), this.off("end", e), t = !0, {
2288
+ done: !0,
2289
+ value: void 0
2290
+ }), s = () => {
2291
+ if (t) return e();
2292
+ let i = this.read();
2293
+ return i === null ? e() : {
2294
+ done: !1,
2295
+ value: i
2296
+ };
2297
+ };
2298
+ return this.once("end", e), this.once(Se, e), this.once(E, e), {
2299
+ next: s,
2300
+ throw: e,
2301
+ return: e,
2302
+ [Symbol.iterator]() {
2303
+ return this;
2304
+ },
2305
+ [Symbol.dispose]: () => {}
2306
+ };
2307
+ }
2308
+ destroy(t) {
2309
+ if (this[E]) return t ? this.emit("error", t) : this.emit(E), this;
2310
+ this[E] = !0, this[_] = !0, this[C].length = 0, this[A] = 0;
2311
+ let e = this;
2312
+ return typeof e.close == "function" && !this[Lt] && e.close(), t ? this.emit("error", t) : this.emit(E), this;
2313
+ }
2314
+ static get isStream() {
2315
+ return ki;
2316
+ }
2317
+ };
2318
+ var Bi = realpathSync.native;
2319
+ var Et = {
2320
+ lstatSync,
2321
+ readdir,
2322
+ readdirSync,
2323
+ readlinkSync,
2324
+ realpathSync: Bi,
2325
+ promises: {
2326
+ lstat,
2327
+ readdir: readdir$1,
2328
+ readlink,
2329
+ realpath
2330
+ }
2331
+ };
2332
+ var gs = (r) => !r || r === Et || r === $i ? Et : {
2333
+ ...Et,
2334
+ ...r,
2335
+ promises: {
2336
+ ...Et.promises,
2337
+ ...r.promises
2338
+ }
2339
+ };
2340
+ var qi = /^\\\\\?\\([a-z]:)\\?$/i;
2341
+ var Ki = /^\\\\\?\\UNC\\([^\\]+\\[^\\]+)\\?$/i;
2342
+ var Xi = /^\\\\[^\\?]+\\[^\\]+$/;
2343
+ var fs = (r) => r.replace(/\//g, "\\").replace(qi, "$1\\").replace(Ki, "\\\\$1\\").replace(Xi, "$&\\");
2344
+ var Vi = /^[\\/]{2}\?[\\/]unc[\\/][^\\/]+[\\/][^\\/]+(?:[\\/]|$)/i;
2345
+ var Yi = /^[\\/]{2}\?[\\/](?=[a-z]:)/i;
2346
+ var Zi = /^[\\/]{2}\?[\\/]unc(?=[\\/][^\\/]+[\\/][^\\/])/i;
2347
+ var Ji = /[\\/]/;
2348
+ var P = 0;
2349
+ var ws = 1;
2350
+ var bs = 2;
2351
+ var B = 4;
2352
+ var ys = 6;
2353
+ var Ss = 8;
2354
+ var tt = 10;
2355
+ var vs = 12;
2356
+ var N = 15;
2357
+ var xt = ~N;
2358
+ var Ae = 16;
2359
+ var us = 32;
2360
+ var kt = 64;
2361
+ var L = 128;
2362
+ var It = 256;
2363
+ var Gt = 512;
2364
+ var ds = kt | L | Gt;
2365
+ var Qi = 1023;
2366
+ var Re = (r) => r.isFile() ? Ss : r.isDirectory() ? B : r.isSymbolicLink() ? tt : r.isCharacterDevice() ? bs : r.isBlockDevice() ? ys : r.isSocket() ? vs : r.isFIFO() ? ws : P;
2367
+ var ps = new wt({ max: 4096 });
2368
+ var Ct = (r) => {
2369
+ let t = ps.get(r);
2370
+ if (t) return t;
2371
+ let e = r.normalize("NFKD");
2372
+ return ps.set(r, e), e;
2373
+ };
2374
+ var ms = new wt({ max: 4096 });
2375
+ var Ut = (r) => {
2376
+ let t = ms.get(r);
2377
+ if (t) return t;
2378
+ let e = Ct(r.toLowerCase());
2379
+ return ms.set(r, e), e;
2380
+ };
2381
+ var Ht = class extends wt {
2382
+ constructor() {
2383
+ super({ max: 256 });
2384
+ }
2385
+ };
2386
+ var Me = class extends wt {
2387
+ constructor(t = 16384) {
2388
+ super({
2389
+ maxSize: t,
2390
+ sizeCalculation: (e) => e.length + 1
2391
+ });
2392
+ }
2393
+ };
2394
+ var xs = Symbol("PathScurry setAsCwd");
2395
+ var M = class {
2396
+ name;
2397
+ root;
2398
+ roots;
2399
+ parent;
2400
+ nocase;
2401
+ isCWD = !1;
2402
+ #t;
2403
+ #i;
2404
+ get dev() {
2405
+ return this.#i;
2406
+ }
2407
+ #e;
2408
+ get mode() {
2409
+ return this.#e;
2410
+ }
2411
+ #o;
2412
+ get nlink() {
2413
+ return this.#o;
2414
+ }
2415
+ #r;
2416
+ get uid() {
2417
+ return this.#r;
2418
+ }
2419
+ #d;
2420
+ get gid() {
2421
+ return this.#d;
2422
+ }
2423
+ #c;
2424
+ get rdev() {
2425
+ return this.#c;
2426
+ }
2427
+ #p;
2428
+ get blksize() {
2429
+ return this.#p;
2430
+ }
2431
+ #h;
2432
+ get ino() {
2433
+ return this.#h;
2434
+ }
2435
+ #m;
2436
+ get size() {
2437
+ return this.#m;
2438
+ }
2439
+ #a;
2440
+ get blocks() {
2441
+ return this.#a;
2442
+ }
2443
+ #l;
2444
+ get atimeMs() {
2445
+ return this.#l;
2446
+ }
2447
+ #n;
2448
+ get mtimeMs() {
2449
+ return this.#n;
2450
+ }
2451
+ #w;
2452
+ get ctimeMs() {
2453
+ return this.#w;
2454
+ }
2455
+ #x;
2456
+ get birthtimeMs() {
2457
+ return this.#x;
2458
+ }
2459
+ #b;
2460
+ get atime() {
2461
+ return this.#b;
2462
+ }
2463
+ #f;
2464
+ get mtime() {
2465
+ return this.#f;
2466
+ }
2467
+ #v;
2468
+ get ctime() {
2469
+ return this.#v;
2470
+ }
2471
+ #y;
2472
+ get birthtime() {
2473
+ return this.#y;
2474
+ }
2475
+ #E;
2476
+ #k;
2477
+ #g;
2478
+ #S;
2479
+ #C;
2480
+ #O;
2481
+ #s;
2482
+ #F;
2483
+ #_;
2484
+ #R;
2485
+ get parentPath() {
2486
+ return (this.parent || this).fullpath();
2487
+ }
2488
+ get path() {
2489
+ return this.parentPath;
2490
+ }
2491
+ constructor(t, e = P, s, i, n, o, a) {
2492
+ this.name = t, this.#E = n ? Ut(t) : Ct(t), this.#s = e & Qi, this.nocase = n, this.roots = i, this.root = s || this, this.#F = o, this.#g = a.fullpath, this.#C = a.relative, this.#O = a.relativePosix, this.parent = a.parent, this.parent ? this.#t = this.parent.#t : this.#t = gs(a.fs);
2493
+ }
2494
+ get fs() {
2495
+ return this.#t;
2496
+ }
2497
+ depth() {
2498
+ return this.#k !== void 0 ? this.#k : this.parent ? this.#k = this.parent.depth() + 1 : this.#k = 0;
2499
+ }
2500
+ childrenCache() {
2501
+ return this.#F;
2502
+ }
2503
+ resolve(t) {
2504
+ if (!t) return this;
2505
+ let e = this.getRootString(t), i = t.substring(e.length).split(this.splitSep);
2506
+ return e ? this.getRoot(e).#D(i) : this.#D(i);
2507
+ }
2508
+ #D(t) {
2509
+ let e = this;
2510
+ for (let s of t) e = e.child(s);
2511
+ return e;
2512
+ }
2513
+ children() {
2514
+ let t = this.#F.get(this);
2515
+ if (t) return t;
2516
+ let e = Object.assign([], { provisional: 0 });
2517
+ return this.#F.set(this, e), this.#s &= ~Ae, e;
2518
+ }
2519
+ child(t, e) {
2520
+ if (t === "" || t === ".") return this;
2521
+ if (t === "..") return this.parent || this;
2522
+ let s = this.children(), i = this.nocase ? Ut(t) : Ct(t);
2523
+ for (let h of s) if (h.#E === i) return h;
2524
+ let n = this.parent ? this.sep : "", o = this.#g ? this.#g + n + t : void 0, a = this.newChild(t, P, {
2525
+ ...e,
2526
+ parent: this,
2527
+ fullpath: o
2528
+ });
2529
+ return this.canReaddir() || (a.#s |= L), s.push(a), a;
2530
+ }
2531
+ relative() {
2532
+ if (this.isCWD) return "";
2533
+ if (this.#C !== void 0) return this.#C;
2534
+ let t = this.name, e = this.parent;
2535
+ if (!e) return this.#C = this.name;
2536
+ let s = e.relative();
2537
+ return s + (!s || !e.parent ? "" : this.sep) + t;
2538
+ }
2539
+ relativePosix() {
2540
+ if (this.sep === "/") return this.relative();
2541
+ if (this.isCWD) return "";
2542
+ if (this.#O !== void 0) return this.#O;
2543
+ let t = this.name, e = this.parent;
2544
+ if (!e) return this.#O = this.fullpathPosix();
2545
+ let s = e.relativePosix();
2546
+ return s + (!s || !e.parent ? "" : "/") + t;
2547
+ }
2548
+ fullpath() {
2549
+ if (this.#g !== void 0) return this.#g;
2550
+ let t = this.name, e = this.parent;
2551
+ if (!e) return this.#g = this.name;
2552
+ let i = e.fullpath() + (e.parent ? this.sep : "") + t;
2553
+ return this.#g = i;
2554
+ }
2555
+ fullpathPosix() {
2556
+ if (this.#S !== void 0) return this.#S;
2557
+ if (this.sep === "/") return this.#S = this.fullpath();
2558
+ if (!this.parent) {
2559
+ let i = this.fullpath().replace(/\\/g, "/");
2560
+ return /^[a-z]:\//i.test(i) ? this.#S = `//?/${i}` : this.#S = i;
2561
+ }
2562
+ let t = this.parent, e = t.fullpathPosix(), s = e + (!e || !t.parent ? "" : "/") + this.name;
2563
+ return this.#S = s;
2564
+ }
2565
+ isUnknown() {
2566
+ return (this.#s & N) === P;
2567
+ }
2568
+ isType(t) {
2569
+ return this[`is${t}`]();
2570
+ }
2571
+ getType() {
2572
+ return this.isUnknown() ? "Unknown" : this.isDirectory() ? "Directory" : this.isFile() ? "File" : this.isSymbolicLink() ? "SymbolicLink" : this.isFIFO() ? "FIFO" : this.isCharacterDevice() ? "CharacterDevice" : this.isBlockDevice() ? "BlockDevice" : this.isSocket() ? "Socket" : "Unknown";
2573
+ }
2574
+ isFile() {
2575
+ return (this.#s & N) === Ss;
2576
+ }
2577
+ isDirectory() {
2578
+ return (this.#s & N) === B;
2579
+ }
2580
+ isCharacterDevice() {
2581
+ return (this.#s & N) === bs;
2582
+ }
2583
+ isBlockDevice() {
2584
+ return (this.#s & N) === ys;
2585
+ }
2586
+ isFIFO() {
2587
+ return (this.#s & N) === ws;
2588
+ }
2589
+ isSocket() {
2590
+ return (this.#s & N) === vs;
2591
+ }
2592
+ isSymbolicLink() {
2593
+ return (this.#s & tt) === tt;
2594
+ }
2595
+ lstatCached() {
2596
+ return this.#s & us ? this : void 0;
2597
+ }
2598
+ readlinkCached() {
2599
+ return this.#_;
2600
+ }
2601
+ realpathCached() {
2602
+ return this.#R;
2603
+ }
2604
+ readdirCached() {
2605
+ let t = this.children();
2606
+ return t.slice(0, t.provisional);
2607
+ }
2608
+ canReadlink() {
2609
+ if (this.#_) return !0;
2610
+ if (!this.parent) return !1;
2611
+ let t = this.#s & N;
2612
+ return !(t !== P && t !== tt || this.#s & It || this.#s & L);
2613
+ }
2614
+ calledReaddir() {
2615
+ return !!(this.#s & Ae);
2616
+ }
2617
+ isENOENT() {
2618
+ return !!(this.#s & L);
2619
+ }
2620
+ isNamed(t) {
2621
+ return this.nocase ? this.#E === Ut(t) : this.#E === Ct(t);
2622
+ }
2623
+ async readlink() {
2624
+ let t = this.#_;
2625
+ if (t) return t;
2626
+ if (this.canReadlink() && this.parent) try {
2627
+ let e = await this.#t.promises.readlink(this.fullpath()), s = (await this.parent.realpath())?.resolve(e);
2628
+ if (s) return this.#_ = s;
2629
+ } catch (e) {
2630
+ this.#T(e.code);
2631
+ return;
2632
+ }
2633
+ }
2634
+ readlinkSync() {
2635
+ let t = this.#_;
2636
+ if (t) return t;
2637
+ if (this.canReadlink() && this.parent) try {
2638
+ let e = this.#t.readlinkSync(this.fullpath()), s = this.parent.realpathSync()?.resolve(e);
2639
+ if (s) return this.#_ = s;
2640
+ } catch (e) {
2641
+ this.#T(e.code);
2642
+ return;
2643
+ }
2644
+ }
2645
+ #W(t) {
2646
+ this.#s |= Ae;
2647
+ for (let e = t.provisional; e < t.length; e++) {
2648
+ let s = t[e];
2649
+ s && s.#A();
2650
+ }
2651
+ }
2652
+ #A() {
2653
+ this.#s & L || (this.#s = (this.#s | L) & xt, this.#G());
2654
+ }
2655
+ #G() {
2656
+ let t = this.children();
2657
+ t.provisional = 0;
2658
+ for (let e of t) e.#A();
2659
+ }
2660
+ #P() {
2661
+ this.#s |= Gt, this.#N();
2662
+ }
2663
+ #N() {
2664
+ if (this.#s & kt) return;
2665
+ let t = this.#s;
2666
+ (t & N) === B && (t &= xt), this.#s = t | kt, this.#G();
2667
+ }
2668
+ #$(t = "") {
2669
+ t === "ENOTDIR" || t === "EPERM" ? this.#N() : t === "ENOENT" ? this.#A() : this.children().provisional = 0;
2670
+ }
2671
+ #M(t = "") {
2672
+ t === "ENOTDIR" ? this.parent.#N() : t === "ENOENT" && this.#A();
2673
+ }
2674
+ #T(t = "") {
2675
+ let e = this.#s;
2676
+ e |= It, t === "ENOENT" && (e |= L), (t === "EINVAL" || t === "UNKNOWN") && (e &= xt), this.#s = e, t === "ENOTDIR" && this.parent && this.parent.#N();
2677
+ }
2678
+ #B(t, e) {
2679
+ return this.#U(t, e) || this.#z(t, e);
2680
+ }
2681
+ #z(t, e) {
2682
+ let s = Re(t), i = this.newChild(t.name, s, { parent: this }), n = i.#s & N;
2683
+ return n !== B && n !== tt && n !== P && (i.#s |= kt), e.unshift(i), e.provisional++, i;
2684
+ }
2685
+ #U(t, e) {
2686
+ for (let s = e.provisional; s < e.length; s++) {
2687
+ let i = e[s];
2688
+ if ((this.nocase ? Ut(t.name) : Ct(t.name)) === i.#E) return this.#V(t, i, s, e);
2689
+ }
2690
+ }
2691
+ #V(t, e, s, i) {
2692
+ let n = e.name;
2693
+ return e.#s = e.#s & xt | Re(t), n !== t.name && (e.name = t.name), s !== i.provisional && (s === i.length - 1 ? i.pop() : i.splice(s, 1), i.unshift(e)), i.provisional++, e;
2694
+ }
2695
+ async lstat() {
2696
+ if ((this.#s & L) === 0) try {
2697
+ return this.#H(await this.#t.promises.lstat(this.fullpath())), this;
2698
+ } catch (t) {
2699
+ this.#M(t.code);
2700
+ }
2701
+ }
2702
+ lstatSync() {
2703
+ if ((this.#s & L) === 0) try {
2704
+ return this.#H(this.#t.lstatSync(this.fullpath())), this;
2705
+ } catch (t) {
2706
+ this.#M(t.code);
2707
+ }
2708
+ }
2709
+ #H(t) {
2710
+ let { atime: e, atimeMs: s, birthtime: i, birthtimeMs: n, blksize: o, blocks: a, ctime: h, ctimeMs: l, dev: c, gid: f, ino: p, mode: d, mtime: g, mtimeMs: u, nlink: w, rdev: m, size: b, uid: v } = t;
2711
+ this.#b = e, this.#l = s, this.#y = i, this.#x = n, this.#p = o, this.#a = a, this.#v = h, this.#w = l, this.#i = c, this.#d = f, this.#h = p, this.#e = d, this.#f = g, this.#n = u, this.#o = w, this.#c = m, this.#m = b, this.#r = v;
2712
+ let S = Re(t);
2713
+ this.#s = this.#s & xt | S | us, S !== P && S !== B && S !== tt && (this.#s |= kt);
2714
+ }
2715
+ #L = [];
2716
+ #u = !1;
2717
+ #q(t) {
2718
+ this.#u = !1;
2719
+ let e = this.#L.slice();
2720
+ this.#L.length = 0, e.forEach((s) => s(null, t));
2721
+ }
2722
+ readdirCB(t, e = !1) {
2723
+ if (!this.canReaddir()) {
2724
+ e ? t(null, []) : queueMicrotask(() => t(null, []));
2725
+ return;
2726
+ }
2727
+ let s = this.children();
2728
+ if (this.calledReaddir()) {
2729
+ let n = s.slice(0, s.provisional);
2730
+ e ? t(null, n) : queueMicrotask(() => t(null, n));
2731
+ return;
2732
+ }
2733
+ if (this.#L.push(t), this.#u) return;
2734
+ this.#u = !0;
2735
+ let i = this.fullpath();
2736
+ this.#t.readdir(i, { withFileTypes: !0 }, (n, o) => {
2737
+ if (n) this.#$(n.code), s.provisional = 0;
2738
+ else {
2739
+ for (let a of o) this.#B(a, s);
2740
+ this.#W(s);
2741
+ }
2742
+ this.#q(s.slice(0, s.provisional));
2743
+ });
2744
+ }
2745
+ #I;
2746
+ async readdir() {
2747
+ if (!this.canReaddir()) return [];
2748
+ let t = this.children();
2749
+ if (this.calledReaddir()) return t.slice(0, t.provisional);
2750
+ let e = this.fullpath();
2751
+ if (this.#I) await this.#I;
2752
+ else {
2753
+ let s = () => {};
2754
+ this.#I = new Promise((i) => s = i);
2755
+ try {
2756
+ for (let i of await this.#t.promises.readdir(e, { withFileTypes: !0 })) this.#B(i, t);
2757
+ this.#W(t);
2758
+ } catch (i) {
2759
+ this.#$(i.code), t.provisional = 0;
2760
+ }
2761
+ this.#I = void 0, s();
2762
+ }
2763
+ return t.slice(0, t.provisional);
2764
+ }
2765
+ readdirSync() {
2766
+ if (!this.canReaddir()) return [];
2767
+ let t = this.children();
2768
+ if (this.calledReaddir()) return t.slice(0, t.provisional);
2769
+ let e = this.fullpath();
2770
+ try {
2771
+ for (let s of this.#t.readdirSync(e, { withFileTypes: !0 })) this.#B(s, t);
2772
+ this.#W(t);
2773
+ } catch (s) {
2774
+ this.#$(s.code), t.provisional = 0;
2775
+ }
2776
+ return t.slice(0, t.provisional);
2777
+ }
2778
+ canReaddir() {
2779
+ if (this.#s & ds) return !1;
2780
+ let t = N & this.#s;
2781
+ return t === P || t === B || t === tt;
2782
+ }
2783
+ shouldWalk(t, e) {
2784
+ return (this.#s & B) === B && !(this.#s & ds) && !t.has(this) && (!e || e(this));
2785
+ }
2786
+ async realpath() {
2787
+ if (this.#R) return this.#R;
2788
+ if (!((Gt | It | L) & this.#s)) try {
2789
+ let t = await this.#t.promises.realpath(this.fullpath());
2790
+ return this.#R = this.resolve(t);
2791
+ } catch {
2792
+ this.#P();
2793
+ }
2794
+ }
2795
+ realpathSync() {
2796
+ if (this.#R) return this.#R;
2797
+ if (!((Gt | It | L) & this.#s)) try {
2798
+ let t = this.#t.realpathSync(this.fullpath());
2799
+ return this.#R = this.resolve(t);
2800
+ } catch {
2801
+ this.#P();
2802
+ }
2803
+ }
2804
+ [xs](t) {
2805
+ if (t === this) return;
2806
+ t.isCWD = !1, this.isCWD = !0;
2807
+ let e = new Set([]), s = [], i = this;
2808
+ for (; i && i.parent;) e.add(i), i.#C = s.join(this.sep), i.#O = s.join("/"), i = i.parent, s.push("..");
2809
+ for (i = t; i && i.parent && !e.has(i);) i.#C = void 0, i.#O = void 0, i = i.parent;
2810
+ }
2811
+ };
2812
+ var qt = class r extends M {
2813
+ sep = "\\";
2814
+ splitSep = Ji;
2815
+ constructor(t, e = P, s, i, n, o, a) {
2816
+ super(t, e, s, i, n, o, a);
2817
+ }
2818
+ newChild(t, e = P, s = {}) {
2819
+ return new r(t, e, this.root, this.roots, this.nocase, this.childrenCache(), s);
2820
+ }
2821
+ getRootString(t) {
2822
+ return Vi.exec(t)?.[0] ?? win32.parse(t).root;
2823
+ }
2824
+ getRoot(t) {
2825
+ if (t = fs(t.toUpperCase()), t === this.root.name || /^[\\/]$/.test(t)) return this.root;
2826
+ for (let [e, s] of Object.entries(this.roots)) if (this.sameRoot(t, e)) return this.roots[t] = s;
2827
+ return this.roots[t] = new rt(t, {
2828
+ nocase: this.nocase,
2829
+ fs: this.fs
2830
+ }).root;
2831
+ }
2832
+ sameRoot(t, e = this.root.name) {
2833
+ return fs(t.toUpperCase()) === e;
2834
+ }
2835
+ };
2836
+ var Kt = class r extends M {
2837
+ splitSep = "/";
2838
+ sep = "/";
2839
+ constructor(t, e = P, s, i, n, o, a) {
2840
+ super(t, e, s, i, n, o, a);
2841
+ }
2842
+ getRootString(t) {
2843
+ return t.startsWith("/") ? "/" : "";
2844
+ }
2845
+ getRoot(t) {
2846
+ return this.root;
2847
+ }
2848
+ newChild(t, e = P, s = {}) {
2849
+ return new r(t, e, this.root, this.roots, this.nocase, this.childrenCache(), s);
2850
+ }
2851
+ };
2852
+ var Xt = class {
2853
+ root;
2854
+ rootPath;
2855
+ roots;
2856
+ cwd;
2857
+ #t;
2858
+ #i;
2859
+ #e;
2860
+ nocase;
2861
+ #o;
2862
+ constructor(t = process.cwd(), e, s, { nocase: i, childrenCacheSize: n = 16384, fs: o = Et } = {}) {
2863
+ this.#o = gs(o), (t instanceof URL || t.startsWith("file://")) && (t = fileURLToPath(t));
2864
+ let a = e.resolve(t);
2865
+ this.roots = Object.create(null), this.rootPath = this.parseRootPath(a), this.#t = new Ht(), this.#i = new Ht(), this.#e = new Me(n);
2866
+ let h = a.substring(this.rootPath.length).split(s);
2867
+ if (h.length === 1 && !h[0] && h.pop(), i === void 0) throw new TypeError("must provide nocase setting to PathScurryBase ctor");
2868
+ this.nocase = i, this.root = this.newRoot(this.#o), this.roots[this.rootPath] = this.root;
2869
+ let l = this.root, c = h.length - 1, f = e.sep, p = this.rootPath, d = !1;
2870
+ for (let g of h) {
2871
+ let u = c--;
2872
+ l = l.child(g, {
2873
+ relative: new Array(u).fill("..").join(f),
2874
+ relativePosix: new Array(u).fill("..").join("/"),
2875
+ fullpath: p += (d ? "" : f) + g
2876
+ }), d = !0;
2877
+ }
2878
+ this.cwd = l;
2879
+ }
2880
+ depth(t = this.cwd) {
2881
+ return typeof t == "string" && (t = this.cwd.resolve(t)), t.depth();
2882
+ }
2883
+ childrenCache() {
2884
+ return this.#e;
2885
+ }
2886
+ resolve(...t) {
2887
+ let e = "";
2888
+ for (let n = t.length - 1; n >= 0; n--) {
2889
+ let o = t[n];
2890
+ if (!(!o || o === ".") && (e = e ? `${o}/${e}` : o, this.isAbsolute(o))) break;
2891
+ }
2892
+ let s = this.#t.get(e);
2893
+ if (s !== void 0) return s;
2894
+ let i = this.cwd.resolve(e).fullpath();
2895
+ return this.#t.set(e, i), i;
2896
+ }
2897
+ resolvePosix(...t) {
2898
+ let e = "";
2899
+ for (let n = t.length - 1; n >= 0; n--) {
2900
+ let o = t[n];
2901
+ if (!(!o || o === ".") && (e = e ? `${o}/${e}` : o, this.isAbsolute(o))) break;
2902
+ }
2903
+ let s = this.#i.get(e);
2904
+ if (s !== void 0) return s;
2905
+ let i = this.cwd.resolve(e).fullpathPosix();
2906
+ return this.#i.set(e, i), i;
2907
+ }
2908
+ relative(t = this.cwd) {
2909
+ return typeof t == "string" && (t = this.cwd.resolve(t)), t.relative();
2910
+ }
2911
+ relativePosix(t = this.cwd) {
2912
+ return typeof t == "string" && (t = this.cwd.resolve(t)), t.relativePosix();
2913
+ }
2914
+ basename(t = this.cwd) {
2915
+ return typeof t == "string" && (t = this.cwd.resolve(t)), t.name;
2916
+ }
2917
+ dirname(t = this.cwd) {
2918
+ return typeof t == "string" && (t = this.cwd.resolve(t)), (t.parent || t).fullpath();
2919
+ }
2920
+ async readdir(t = this.cwd, e = { withFileTypes: !0 }) {
2921
+ typeof t == "string" ? t = this.cwd.resolve(t) : t instanceof M || (e = t, t = this.cwd);
2922
+ let { withFileTypes: s } = e;
2923
+ if (t.canReaddir()) {
2924
+ let i = await t.readdir();
2925
+ return s ? i : i.map((n) => n.name);
2926
+ } else return [];
2927
+ }
2928
+ readdirSync(t = this.cwd, e = { withFileTypes: !0 }) {
2929
+ typeof t == "string" ? t = this.cwd.resolve(t) : t instanceof M || (e = t, t = this.cwd);
2930
+ let { withFileTypes: s = !0 } = e;
2931
+ return t.canReaddir() ? s ? t.readdirSync() : t.readdirSync().map((i) => i.name) : [];
2932
+ }
2933
+ async lstat(t = this.cwd) {
2934
+ return typeof t == "string" && (t = this.cwd.resolve(t)), t.lstat();
2935
+ }
2936
+ lstatSync(t = this.cwd) {
2937
+ return typeof t == "string" && (t = this.cwd.resolve(t)), t.lstatSync();
2938
+ }
2939
+ async readlink(t = this.cwd, { withFileTypes: e } = { withFileTypes: !1 }) {
2940
+ typeof t == "string" ? t = this.cwd.resolve(t) : t instanceof M || (e = t.withFileTypes, t = this.cwd);
2941
+ let s = await t.readlink();
2942
+ return e ? s : s?.fullpath();
2943
+ }
2944
+ readlinkSync(t = this.cwd, { withFileTypes: e } = { withFileTypes: !1 }) {
2945
+ typeof t == "string" ? t = this.cwd.resolve(t) : t instanceof M || (e = t.withFileTypes, t = this.cwd);
2946
+ let s = t.readlinkSync();
2947
+ return e ? s : s?.fullpath();
2948
+ }
2949
+ async realpath(t = this.cwd, { withFileTypes: e } = { withFileTypes: !1 }) {
2950
+ typeof t == "string" ? t = this.cwd.resolve(t) : t instanceof M || (e = t.withFileTypes, t = this.cwd);
2951
+ let s = await t.realpath();
2952
+ return e ? s : s?.fullpath();
2953
+ }
2954
+ realpathSync(t = this.cwd, { withFileTypes: e } = { withFileTypes: !1 }) {
2955
+ typeof t == "string" ? t = this.cwd.resolve(t) : t instanceof M || (e = t.withFileTypes, t = this.cwd);
2956
+ let s = t.realpathSync();
2957
+ return e ? s : s?.fullpath();
2958
+ }
2959
+ async walk(t = this.cwd, e = {}) {
2960
+ typeof t == "string" ? t = this.cwd.resolve(t) : t instanceof M || (e = t, t = this.cwd);
2961
+ let { withFileTypes: s = !0, follow: i = !1, filter: n, walkFilter: o } = e, a = [];
2962
+ (!n || n(t)) && a.push(s ? t : t.fullpath());
2963
+ let h = new Set(), l = (f, p) => {
2964
+ h.add(f), f.readdirCB((d, g) => {
2965
+ if (d) return p(d);
2966
+ let u = g.length;
2967
+ if (!u) return p();
2968
+ let w = () => {
2969
+ --u === 0 && p();
2970
+ };
2971
+ for (let m of g) (!n || n(m)) && a.push(s ? m : m.fullpath()), i && m.isSymbolicLink() ? m.realpath().then((b) => b?.isUnknown() ? b.lstat() : b).then((b) => b?.shouldWalk(h, o) ? l(b, w) : w()) : m.shouldWalk(h, o) ? l(m, w) : w();
2972
+ }, !0);
2973
+ }, c = t;
2974
+ return new Promise((f, p) => {
2975
+ l(c, (d) => {
2976
+ if (d) return p(d);
2977
+ f(a);
2978
+ });
2979
+ });
2980
+ }
2981
+ walkSync(t = this.cwd, e = {}) {
2982
+ typeof t == "string" ? t = this.cwd.resolve(t) : t instanceof M || (e = t, t = this.cwd);
2983
+ let { withFileTypes: s = !0, follow: i = !1, filter: n, walkFilter: o } = e, a = [];
2984
+ (!n || n(t)) && a.push(s ? t : t.fullpath());
2985
+ let h = new Set([t]);
2986
+ for (let l of h) {
2987
+ let c = l.readdirSync();
2988
+ for (let f of c) {
2989
+ (!n || n(f)) && a.push(s ? f : f.fullpath());
2990
+ let p = f;
2991
+ if (f.isSymbolicLink()) {
2992
+ if (!(i && (p = f.realpathSync()))) continue;
2993
+ p.isUnknown() && p.lstatSync();
2994
+ }
2995
+ p.shouldWalk(h, o) && h.add(p);
2996
+ }
2997
+ }
2998
+ return a;
2999
+ }
3000
+ [Symbol.asyncIterator]() {
3001
+ return this.iterate();
3002
+ }
3003
+ iterate(t = this.cwd, e = {}) {
3004
+ return typeof t == "string" ? t = this.cwd.resolve(t) : t instanceof M || (e = t, t = this.cwd), this.stream(t, e)[Symbol.asyncIterator]();
3005
+ }
3006
+ [Symbol.iterator]() {
3007
+ return this.iterateSync();
3008
+ }
3009
+ *iterateSync(t = this.cwd, e = {}) {
3010
+ typeof t == "string" ? t = this.cwd.resolve(t) : t instanceof M || (e = t, t = this.cwd);
3011
+ let { withFileTypes: s = !0, follow: i = !1, filter: n, walkFilter: o } = e;
3012
+ (!n || n(t)) && (yield s ? t : t.fullpath());
3013
+ let a = new Set([t]);
3014
+ for (let h of a) {
3015
+ let l = h.readdirSync();
3016
+ for (let c of l) {
3017
+ (!n || n(c)) && (yield s ? c : c.fullpath());
3018
+ let f = c;
3019
+ if (c.isSymbolicLink()) {
3020
+ if (!(i && (f = c.realpathSync()))) continue;
3021
+ f.isUnknown() && f.lstatSync();
3022
+ }
3023
+ f.shouldWalk(a, o) && a.add(f);
3024
+ }
3025
+ }
3026
+ }
3027
+ stream(t = this.cwd, e = {}) {
3028
+ typeof t == "string" ? t = this.cwd.resolve(t) : t instanceof M || (e = t, t = this.cwd);
3029
+ let { withFileTypes: s = !0, follow: i = !1, filter: n, walkFilter: o } = e, a = new Z({ objectMode: !0 });
3030
+ (!n || n(t)) && a.write(s ? t : t.fullpath());
3031
+ let h = new Set(), l = [t], c = 0, f = () => {
3032
+ let p = !1;
3033
+ for (; !p;) {
3034
+ let d = l.shift();
3035
+ if (!d) {
3036
+ c === 0 && a.end();
3037
+ return;
3038
+ }
3039
+ c++, h.add(d);
3040
+ let g = (w, m, b = !1) => {
3041
+ if (w) return a.emit("error", w);
3042
+ if (i && !b) {
3043
+ let v = [];
3044
+ for (let S of m) S.isSymbolicLink() && v.push(S.realpath().then((y) => y?.isUnknown() ? y.lstat() : y));
3045
+ if (v.length) {
3046
+ Promise.all(v).then(() => g(null, m, !0));
3047
+ return;
3048
+ }
3049
+ }
3050
+ for (let v of m) v && (!n || n(v)) && (a.write(s ? v : v.fullpath()) || (p = !0));
3051
+ c--;
3052
+ for (let v of m) {
3053
+ let S = v.realpathCached() || v;
3054
+ S.shouldWalk(h, o) && l.push(S);
3055
+ }
3056
+ p && !a.flowing ? a.once("drain", f) : u || f();
3057
+ }, u = !0;
3058
+ d.readdirCB(g, !0), u = !1;
3059
+ }
3060
+ };
3061
+ return f(), a;
3062
+ }
3063
+ streamSync(t = this.cwd, e = {}) {
3064
+ typeof t == "string" ? t = this.cwd.resolve(t) : t instanceof M || (e = t, t = this.cwd);
3065
+ let { withFileTypes: s = !0, follow: i = !1, filter: n, walkFilter: o } = e, a = new Z({ objectMode: !0 }), h = new Set();
3066
+ (!n || n(t)) && a.write(s ? t : t.fullpath());
3067
+ let l = [t], c = 0, f = () => {
3068
+ let p = !1;
3069
+ for (; !p;) {
3070
+ let d = l.shift();
3071
+ if (!d) {
3072
+ c === 0 && a.end();
3073
+ return;
3074
+ }
3075
+ c++, h.add(d);
3076
+ let g = d.readdirSync();
3077
+ for (let u of g) (!n || n(u)) && (a.write(s ? u : u.fullpath()) || (p = !0));
3078
+ c--;
3079
+ for (let u of g) {
3080
+ let w = u;
3081
+ if (u.isSymbolicLink()) {
3082
+ if (!(i && (w = u.realpathSync()))) continue;
3083
+ w.isUnknown() && w.lstatSync();
3084
+ }
3085
+ w.shouldWalk(h, o) && l.push(w);
3086
+ }
3087
+ }
3088
+ p && !a.flowing && a.once("drain", f);
3089
+ };
3090
+ return f(), a;
3091
+ }
3092
+ chdir(t = this.cwd) {
3093
+ let e = this.cwd;
3094
+ this.cwd = typeof t == "string" ? this.cwd.resolve(t) : t, this.cwd[xs](e);
3095
+ }
3096
+ };
3097
+ var rt = class extends Xt {
3098
+ sep = "\\";
3099
+ constructor(t = process.cwd(), e = {}) {
3100
+ let { nocase: s = !0 } = e;
3101
+ typeof t == "string" && !t.startsWith("file://") && (t = t.replace(Yi, "").replace(Zi, "\\")), super(t, win32, "\\", {
3102
+ ...e,
3103
+ nocase: s
3104
+ }), this.nocase = s;
3105
+ for (let i = this.cwd; i; i = i.parent) i.nocase = this.nocase;
3106
+ }
3107
+ parseRootPath(t) {
3108
+ return win32.parse(t).root.toUpperCase();
3109
+ }
3110
+ newRoot(t) {
3111
+ return new qt(this.rootPath, B, void 0, this.roots, this.nocase, this.childrenCache(), { fs: t });
3112
+ }
3113
+ isAbsolute(t) {
3114
+ return t.startsWith("/") || t.startsWith("\\") || /^[a-z]:(\/|\\)/i.test(t);
3115
+ }
3116
+ };
3117
+ var ot = class extends Xt {
3118
+ sep = "/";
3119
+ constructor(t = process.cwd(), e = {}) {
3120
+ let { nocase: s = !1 } = e;
3121
+ super(t, posix, "/", {
3122
+ ...e,
3123
+ nocase: s
3124
+ }), this.nocase = s;
3125
+ }
3126
+ parseRootPath(t) {
3127
+ return "/";
3128
+ }
3129
+ newRoot(t) {
3130
+ return new Kt(this.rootPath, B, void 0, this.roots, this.nocase, this.childrenCache(), { fs: t });
3131
+ }
3132
+ isAbsolute(t) {
3133
+ return t.startsWith("/");
3134
+ }
3135
+ };
3136
+ var At = class extends ot {
3137
+ constructor(t = process.cwd(), e = {}) {
3138
+ let { nocase: s = !0 } = e;
3139
+ super(t, {
3140
+ ...e,
3141
+ nocase: s
3142
+ });
3143
+ }
3144
+ };
3145
+ process.platform;
3146
+ var Es = process.platform === "win32" ? rt : process.platform === "darwin" ? At : ot;
3147
+ var tn = (r) => r.length >= 1;
3148
+ var en = (r) => r.length >= 1;
3149
+ var sn = Symbol.for("nodejs.util.inspect.custom");
3150
+ var ht = class r {
3151
+ #t;
3152
+ #i;
3153
+ #e;
3154
+ length;
3155
+ #o;
3156
+ #r;
3157
+ #d;
3158
+ #c;
3159
+ #p;
3160
+ #h;
3161
+ #m = !0;
3162
+ constructor(t, e, s, i) {
3163
+ if (!tn(t)) throw new TypeError("empty pattern list");
3164
+ if (!en(e)) throw new TypeError("empty glob list");
3165
+ if (e.length !== t.length) throw new TypeError("mismatched pattern list and glob list lengths");
3166
+ if (this.length = t.length, s < 0 || s >= this.length) throw new TypeError("index out of range");
3167
+ if (this.#t = t, this.#i = e, this.#e = s, this.#o = i, this.#e === 0) {
3168
+ if (this.isUNC()) {
3169
+ let n = this.#a() ? 6 : 4, o = this.#t.slice(0, n), a = this.#i.slice(0, n), h = this.#t.slice(n), l = this.#i.slice(n);
3170
+ h[0] === "" && (h.shift(), l.shift());
3171
+ let c = [...o, ""].join("/"), f = [...a, ""].join("/");
3172
+ this.#t = [c, ...h], this.#i = [f, ...l], this.length = this.#t.length;
3173
+ } else if (this.isDrive() || this.isAbsolute()) {
3174
+ let [n, ...o] = this.#t, [a, ...h] = this.#i;
3175
+ o[0] === "" && (o.shift(), h.shift());
3176
+ let l = `${n}/`, c = `${a}/`;
3177
+ this.#t = [l, ...o], this.#i = [c, ...h], this.length = this.#t.length;
3178
+ }
3179
+ }
3180
+ }
3181
+ [sn]() {
3182
+ return `Pattern <${this.#i.slice(this.#e).join("/")}>`;
3183
+ }
3184
+ pattern() {
3185
+ return this.#t[this.#e];
3186
+ }
3187
+ isString() {
3188
+ return typeof this.#t[this.#e] == "string";
3189
+ }
3190
+ isGlobstar() {
3191
+ return this.#t[this.#e] === x;
3192
+ }
3193
+ isMatcher() {
3194
+ return typeof this.#t[this.#e] == "object";
3195
+ }
3196
+ globString() {
3197
+ return this.#d = this.#d || (this.#e === 0 ? this.isAbsolute() ? this.#i[0] + this.#i.slice(1).join("/") : this.#i.join("/") : this.#i.slice(this.#e).join("/"));
3198
+ }
3199
+ hasMore() {
3200
+ return this.length > this.#e + 1;
3201
+ }
3202
+ rest() {
3203
+ return this.#r !== void 0 ? this.#r : this.hasMore() ? (this.#r = new r(this.#t, this.#i, this.#e + 1, this.#o), this.#r.#h = this.#h, this.#r.#p = this.#p, this.#r.#c = this.#c, this.#r) : this.#r = null;
3204
+ }
3205
+ #a() {
3206
+ let t = this.#t;
3207
+ return t[2] === "?" && typeof t[3] == "string" && /^unc$/i.test(t[3]);
3208
+ }
3209
+ isUNC() {
3210
+ let t = this.#t, e = this.#a() ? 4 : 2;
3211
+ return this.#p !== void 0 ? this.#p : this.#p = this.#o === "win32" && this.#e === 0 && t[0] === "" && t[1] === "" && typeof t[e] == "string" && !!t[e] && typeof t[e + 1] == "string" && !!t[e + 1];
3212
+ }
3213
+ isDrive() {
3214
+ let t = this.#t;
3215
+ return this.#c !== void 0 ? this.#c : this.#c = this.#o === "win32" && this.#e === 0 && this.length > 1 && typeof t[0] == "string" && /^[a-z]:$/i.test(t[0]);
3216
+ }
3217
+ isAbsolute() {
3218
+ let t = this.#t;
3219
+ return this.#h !== void 0 ? this.#h : this.#h = t[0] === "" && t.length > 1 || this.isDrive() || this.isUNC();
3220
+ }
3221
+ root() {
3222
+ let t = this.#t[0];
3223
+ return typeof t == "string" && this.isAbsolute() && this.#e === 0 ? t : "";
3224
+ }
3225
+ checkFollowGlobstar() {
3226
+ return !(this.#e === 0 || !this.isGlobstar() || !this.#m);
3227
+ }
3228
+ markFollowGlobstar() {
3229
+ return this.#e === 0 || !this.isGlobstar() || !this.#m ? !1 : (this.#m = !1, !0);
3230
+ }
3231
+ };
3232
+ var nn = typeof process == "object" && process && typeof process.platform == "string" ? process.platform : "linux";
3233
+ var at = class {
3234
+ relative;
3235
+ relativeChildren;
3236
+ absolute;
3237
+ absoluteChildren;
3238
+ platform;
3239
+ mmopts;
3240
+ slashRoot;
3241
+ constructor(t, { nobrace: e, nocase: s, noext: i, noglobstar: n, normalize: o, platform: a = nn, root: h, windowsPathsNoEscape: l, allowWindowsEscape: c }, f) {
3242
+ this.relative = [], this.absolute = [], this.relativeChildren = [], this.absoluteChildren = [], this.platform = a, l = !!l || c === !1, this.mmopts = {
3243
+ dot: !0,
3244
+ nobrace: e,
3245
+ nocase: s,
3246
+ noext: i,
3247
+ noglobstar: n,
3248
+ normalize: o,
3249
+ optimizationLevel: 2,
3250
+ platform: a,
3251
+ nocomment: !0,
3252
+ nonegate: !0,
3253
+ windowsPathsNoEscape: l
3254
+ };
3255
+ let p = f?.resolve(h ?? "/").fullpath() ?? "/";
3256
+ this.slashRoot = K(p.replace(/\\/g, "/").replace(/\/$/, ""), { windowsPathsNoEscape: l });
3257
+ for (let d of t) this.add(d);
3258
+ }
3259
+ add(t) {
3260
+ let e = new D(t, this.mmopts);
3261
+ for (let s = 0; s < e.set.length; s++) {
3262
+ let i = e.set[s], n = e.globParts[s];
3263
+ if (!i || !n) throw new Error("invalid pattern object");
3264
+ for (; i[0] === "." && n[0] === ".";) i.shift(), n.shift();
3265
+ let o = new ht(i, n, 0, this.platform), h = new D(o.root() === "/" ? `${this.slashRoot}/${o.rest()?.globString() ?? ""}` : o.globString(), this.mmopts), l = n[n.length - 1] === "**", c = o.isAbsolute();
3266
+ c ? this.absolute.push(h) : this.relative.push(h), l && (c ? this.absoluteChildren.push(h) : this.relativeChildren.push(h));
3267
+ }
3268
+ }
3269
+ ignored(t) {
3270
+ let e = t.fullpath(), s = `${e}/`, i = t.relative() || ".", n = `${i}/`;
3271
+ for (let o of this.relative) if (o.match(i) || o.match(n)) return !0;
3272
+ for (let o of this.absolute) if (o.match(e) || o.match(s)) return !0;
3273
+ return !1;
3274
+ }
3275
+ childrenIgnored(t) {
3276
+ let e = `${t.fullpath()}/`, s = `${t.relative() || "."}/`;
3277
+ for (let i of this.relativeChildren) if (i.match(s)) return !0;
3278
+ for (let i of this.absoluteChildren) if (i.match(e)) return !0;
3279
+ return !1;
3280
+ }
3281
+ };
3282
+ var Te = class r {
3283
+ parent;
3284
+ store;
3285
+ constructor(t) {
3286
+ this.parent = t;
3287
+ }
3288
+ copy() {
3289
+ return new r(this);
3290
+ }
3291
+ #t(t) {
3292
+ let e = this.store?.get(t);
3293
+ return e || !this.parent ? e : this.parent.#t(t);
3294
+ }
3295
+ hasWalked(t, e) {
3296
+ return !!this.#t(t.fullpath())?.has(e.globString());
3297
+ }
3298
+ storeWalked(t, e) {
3299
+ let s = t.fullpath(), i = this.#t(s);
3300
+ i ? i.add(e.globString()) : (this.store ??= new Map()).set(s, new Set([e.globString()]));
3301
+ }
3302
+ };
3303
+ var Rt = class r {
3304
+ static ABSOLUTE = 2;
3305
+ static IF_DIR = 1;
3306
+ store = new Map();
3307
+ add(t, e, s) {
3308
+ let i = (e ? r.ABSOLUTE : 0) | (s ? r.IF_DIR : 0), n = this.store.get(t);
3309
+ this.store.set(t, n === void 0 ? i : i & n);
3310
+ }
3311
+ };
3312
+ var Fe = class {
3313
+ store = new Map();
3314
+ add(t, e) {
3315
+ if (!t.canReaddir()) return;
3316
+ let s = this.store.get(t);
3317
+ s ? s.find((i) => i.globString() === e.globString()) || s.push(e) : this.store.set(t, [e]);
3318
+ }
3319
+ get(t) {
3320
+ let e = this.store.get(t);
3321
+ if (!e) throw new Error("attempting to walk unknown path");
3322
+ return e;
3323
+ }
3324
+ entries() {
3325
+ return this.keys().map((t) => [t, this.store.get(t)]);
3326
+ }
3327
+ keys() {
3328
+ return [...this.store.keys()].filter((t) => t.canReaddir());
3329
+ }
3330
+ };
3331
+ var Ot = class r {
3332
+ hasWalkedCache;
3333
+ matches = new Rt();
3334
+ subwalks = new Fe();
3335
+ patterns;
3336
+ follow;
3337
+ dot;
3338
+ opts;
3339
+ constructor(t, e) {
3340
+ this.opts = t, this.follow = !!t.follow, this.dot = !!t.dot, this.hasWalkedCache = e ? e.copy() : new Te();
3341
+ }
3342
+ processPatterns(t, e) {
3343
+ this.patterns = e;
3344
+ let s = e.map((i) => [t, i]);
3345
+ for (let [i, n] of s) {
3346
+ this.hasWalkedCache.storeWalked(i, n);
3347
+ let o = n.root(), a = n.isAbsolute() && this.opts.absolute !== !1;
3348
+ if (o) {
3349
+ i = i.resolve(o === "/" && this.opts.root !== void 0 ? this.opts.root : o);
3350
+ let f = n.rest();
3351
+ if (f) n = f;
3352
+ else {
3353
+ this.matches.add(i, !0, !1);
3354
+ continue;
3355
+ }
3356
+ }
3357
+ if (i.isENOENT()) continue;
3358
+ let h, l, c = !1;
3359
+ for (; typeof (h = n.pattern()) == "string" && (l = n.rest());) i = i.resolve(h), n = l, c = !0;
3360
+ if (h = n.pattern(), l = n.rest(), c) {
3361
+ if (this.hasWalkedCache.hasWalked(i, n)) continue;
3362
+ this.hasWalkedCache.storeWalked(i, n);
3363
+ }
3364
+ if (typeof h == "string") {
3365
+ let f = h === ".." || h === "" || h === ".";
3366
+ this.matches.add(i.resolve(h), a, f);
3367
+ continue;
3368
+ } else if (h === x) {
3369
+ (!i.isSymbolicLink() || this.follow || n.checkFollowGlobstar()) && this.subwalks.add(i, n);
3370
+ let f = l?.pattern(), p = l?.rest();
3371
+ if (!l || (f === "" || f === ".") && !p) this.matches.add(i, a, f === "" || f === ".");
3372
+ else if (f === "..") {
3373
+ let d = i.parent || i;
3374
+ p ? this.hasWalkedCache.hasWalked(d, p) || this.subwalks.add(d, p) : this.matches.add(d, a, !0);
3375
+ }
3376
+ } else typeof h == "object" && this.subwalks.add(i, n);
3377
+ }
3378
+ return this;
3379
+ }
3380
+ subwalkTargets() {
3381
+ return this.subwalks.keys();
3382
+ }
3383
+ child() {
3384
+ return new r(this.opts, this.hasWalkedCache);
3385
+ }
3386
+ filterEntries(t, e) {
3387
+ let s = this.subwalks.get(t), i = this.child();
3388
+ for (let n of e) for (let o of s) {
3389
+ let a = o.isAbsolute(), h = o.pattern(), l = o.rest();
3390
+ h === x ? i.testGlobstar(n, o, l, a) : typeof h == "object" ? i.testMatcher(n, h, l, a) : i.testString(n, h, l, a);
3391
+ }
3392
+ return i;
3393
+ }
3394
+ testGlobstar(t, e, s, i) {
3395
+ if ((this.dot || !t.name.startsWith(".")) && (e.hasMore() || this.matches.add(t, i, !1), t.canReaddir() && (this.follow || !t.isSymbolicLink() ? this.subwalks.add(t, e) : t.isSymbolicLink() && (s && e.checkFollowGlobstar() ? this.subwalks.add(t, s) : e.markFollowGlobstar() && this.subwalks.add(t, e)))), s) {
3396
+ let n = s.pattern();
3397
+ if (typeof n == "string" && n !== ".." && n !== "" && n !== ".") this.testString(t, n, s.rest(), i);
3398
+ else if (n === "..") {
3399
+ let o = t.parent || t;
3400
+ this.subwalks.add(o, s);
3401
+ } else typeof n == "object" && this.testMatcher(t, n, s.rest(), i);
3402
+ }
3403
+ }
3404
+ testMatcher(t, e, s, i) {
3405
+ e.testUnchecked(t.name) && (s ? this.subwalks.add(t, s) : this.matches.add(t, i, !1));
3406
+ }
3407
+ testString(t, e, s, i) {
3408
+ t.isNamed(e) && (s ? this.subwalks.add(t, s) : this.matches.add(t, i, !1));
3409
+ }
3410
+ };
3411
+ var { ABSOLUTE: Vt, IF_DIR: Yt } = Rt, rn = (r, t, e) => typeof r == "string" ? new at([r], t, e) : Array.isArray(r) ? new at(r, t, e) : r, Zt = class {
3412
+ path;
3413
+ patterns;
3414
+ opts;
3415
+ seen = new Set();
3416
+ paused = !1;
3417
+ aborted = !1;
3418
+ #t = [];
3419
+ #i;
3420
+ #e;
3421
+ signal;
3422
+ maxDepth;
3423
+ includeChildMatches;
3424
+ constructor(t, e, s) {
3425
+ if (this.patterns = t, this.path = e, this.opts = s, this.#e = !s.posix && s.platform === "win32" ? "\\" : "/", this.includeChildMatches = s.includeChildMatches !== !1, (s.ignore || !this.includeChildMatches) && (this.#i = rn(s.ignore ?? [], s, e), !this.includeChildMatches && typeof this.#i.add != "function")) throw new Error("cannot ignore child matches, ignore lacks add() method.");
3426
+ this.maxDepth = s.maxDepth || 1 / 0, s.signal && (this.signal = s.signal, this.signal.addEventListener("abort", () => {
3427
+ this.#t.length = 0;
3428
+ }));
3429
+ }
3430
+ #o(t) {
3431
+ return this.seen.has(t) || !!this.#i?.ignored?.(t);
3432
+ }
3433
+ #r(t) {
3434
+ return !!this.#i?.childrenIgnored?.(t);
3435
+ }
3436
+ pause() {
3437
+ this.paused = !0;
3438
+ }
3439
+ resume() {
3440
+ if (this.signal?.aborted) return;
3441
+ this.paused = !1;
3442
+ let t;
3443
+ for (; !this.paused && (t = this.#t.shift());) t();
3444
+ }
3445
+ onResume(t) {
3446
+ this.paused ? this.#t.push(t) : t();
3447
+ }
3448
+ async matchCheck(t, e) {
3449
+ if (e && this.opts.nodir) return;
3450
+ let s, i;
3451
+ if (this.opts.realpath) {
3452
+ if (s = t.realpathCached() || await t.realpath(), !s) return;
3453
+ i = s;
3454
+ } else i = t;
3455
+ let o = i.isUnknown() || this.opts.stat ? await i.lstat() : i;
3456
+ if (this.opts.follow && this.opts.nodir && o?.isSymbolicLink()) {
3457
+ let a = await o.realpath();
3458
+ a && (a.isUnknown() || this.opts.stat) && await a.lstat();
3459
+ }
3460
+ return this.matchCheckTest(o, e);
3461
+ }
3462
+ matchCheckTest(t, e) {
3463
+ return t && (this.maxDepth === 1 / 0 || t.depth() <= this.maxDepth) && (!e || t.canReaddir()) && (!this.opts.nodir || !t.isDirectory()) && (!this.opts.nodir || !this.opts.follow || !t.isSymbolicLink() || !t.realpathCached()?.isDirectory()) && !this.#o(t) ? t : void 0;
3464
+ }
3465
+ matchCheckSync(t, e) {
3466
+ if (e && this.opts.nodir) return;
3467
+ let s, i;
3468
+ if (this.opts.realpath) {
3469
+ if (s = t.realpathCached() || t.realpathSync(), !s) return;
3470
+ i = s;
3471
+ } else i = t;
3472
+ let o = i.isUnknown() || this.opts.stat ? i.lstatSync() : i;
3473
+ if (this.opts.follow && this.opts.nodir && o?.isSymbolicLink()) {
3474
+ let a = o.realpathSync();
3475
+ a && (a?.isUnknown() || this.opts.stat) && a.lstatSync();
3476
+ }
3477
+ return this.matchCheckTest(o, e);
3478
+ }
3479
+ matchFinish(t, e) {
3480
+ this.#o(t) || this.#d(t, e);
3481
+ }
3482
+ #d(t, e) {
3483
+ if (!this.includeChildMatches && this.#i?.add) {
3484
+ let n = `${t.relativePosix()}/**`;
3485
+ this.#i.add(n);
3486
+ }
3487
+ let s = this.opts.absolute === void 0 ? e : this.opts.absolute;
3488
+ this.seen.add(t);
3489
+ let i = this.opts.mark && t.isDirectory() ? this.#e : "";
3490
+ if (this.opts.withFileTypes) this.matchEmit(t);
3491
+ else if (s) {
3492
+ let n = this.opts.posix ? t.fullpathPosix() : t.fullpath();
3493
+ this.matchEmit(n + i);
3494
+ } else {
3495
+ let n = this.opts.posix ? t.relativePosix() : t.relative(), o = this.opts.dotRelative && !n.startsWith(`..${this.#e}`) ? `.${this.#e}` : "";
3496
+ this.matchEmit(n ? o + n + i : `.${i}`);
3497
+ }
3498
+ }
3499
+ async match(t, e, s) {
3500
+ let i = await this.matchCheck(t, s);
3501
+ i && this.matchFinish(i, e);
3502
+ }
3503
+ matchSync(t, e, s) {
3504
+ let i = this.matchCheckSync(t, s);
3505
+ i && this.#d(i, e);
3506
+ }
3507
+ walkCB(t, e, s) {
3508
+ if (this.signal?.aborted) return s();
3509
+ this.walkCB2(t, e, new Ot(this.opts), s);
3510
+ }
3511
+ walkCB2(t, e, s, i) {
3512
+ if (this.#r(t) || this.signal?.aborted) return i();
3513
+ if (this.paused) {
3514
+ this.onResume(() => this.walkCB2(t, e, s, i));
3515
+ return;
3516
+ }
3517
+ s.processPatterns(t, e);
3518
+ let n = 1, o = () => {
3519
+ --n === 0 && i();
3520
+ };
3521
+ for (let [a, h] of s.matches.store) this.#o(a) || (n++, this.match(a, !!(h & Vt), !!(h & Yt)).then(() => o()));
3522
+ for (let a of s.subwalkTargets()) {
3523
+ if (this.maxDepth !== 1 / 0 && a.depth() >= this.maxDepth) continue;
3524
+ n++;
3525
+ let h = a.readdirCached();
3526
+ a.calledReaddir() ? this.walkCB3(a, h, s, o) : a.readdirCB((l, c) => this.walkCB3(a, c, s, o), !0);
3527
+ }
3528
+ o();
3529
+ }
3530
+ walkCB3(t, e, s, i) {
3531
+ let n = s.filterEntries(t, e), o = 1, a = () => {
3532
+ --o === 0 && i();
3533
+ };
3534
+ for (let [h, l] of n.matches.store) this.#o(h) || (o++, this.match(h, !!(l & Vt), !!(l & Yt)).then(() => a()));
3535
+ for (let [h, l] of n.subwalks.entries()) o++, this.walkCB2(h, l, n.child(), a);
3536
+ a();
3537
+ }
3538
+ walkCBSync(t, e, s) {
3539
+ if (this.signal?.aborted) return s();
3540
+ this.walkCB2Sync(t, e, new Ot(this.opts), s);
3541
+ }
3542
+ walkCB2Sync(t, e, s, i) {
3543
+ if (this.#r(t) || this.signal?.aborted) return i();
3544
+ if (this.paused) {
3545
+ this.onResume(() => this.walkCB2Sync(t, e, s, i));
3546
+ return;
3547
+ }
3548
+ s.processPatterns(t, e);
3549
+ let n = 1, o = () => {
3550
+ --n === 0 && i();
3551
+ };
3552
+ for (let [a, h] of s.matches.store) this.#o(a) || this.matchSync(a, !!(h & Vt), !!(h & Yt));
3553
+ for (let a of s.subwalkTargets()) {
3554
+ if (this.maxDepth !== 1 / 0 && a.depth() >= this.maxDepth) continue;
3555
+ n++;
3556
+ let h = a.readdirSync();
3557
+ this.walkCB3Sync(a, h, s, o);
3558
+ }
3559
+ o();
3560
+ }
3561
+ walkCB3Sync(t, e, s, i) {
3562
+ let n = s.filterEntries(t, e), o = 1, a = () => {
3563
+ --o === 0 && i();
3564
+ };
3565
+ for (let [h, l] of n.matches.store) this.#o(h) || this.matchSync(h, !!(l & Vt), !!(l & Yt));
3566
+ for (let [h, l] of n.subwalks.entries()) o++, this.walkCB2Sync(h, l, n.child(), a);
3567
+ a();
3568
+ }
3569
+ }, Mt = class extends Zt {
3570
+ matches = [];
3571
+ constructor(t, e, s) {
3572
+ super(t, e, s);
3573
+ }
3574
+ matchEmit(t) {
3575
+ this.matches.push(t);
3576
+ }
3577
+ async walk() {
3578
+ if (this.signal?.aborted) throw this.signal.reason;
3579
+ return this.path.isUnknown() && await this.path.lstat(), await new Promise((t, e) => {
3580
+ this.walkCB(this.path, this.patterns, () => {
3581
+ this.signal?.aborted ? e(this.signal.reason) : t(this.matches);
3582
+ });
3583
+ }), this.matches;
3584
+ }
3585
+ walkSync() {
3586
+ if (this.signal?.aborted) throw this.signal.reason;
3587
+ return this.path.isUnknown() && this.path.lstatSync(), this.walkCBSync(this.path, this.patterns, () => {
3588
+ if (this.signal?.aborted) throw this.signal.reason;
3589
+ }), this.matches;
3590
+ }
3591
+ }, Tt = class extends Zt {
3592
+ results;
3593
+ constructor(t, e, s) {
3594
+ super(t, e, s), this.results = new Z({
3595
+ signal: this.signal,
3596
+ objectMode: !0
3597
+ }), this.results.on("drain", () => this.resume()), this.results.on("resume", () => this.resume());
3598
+ }
3599
+ matchEmit(t) {
3600
+ this.results.write(t), this.results.flowing || this.pause();
3601
+ }
3602
+ stream() {
3603
+ let t = this.path;
3604
+ return t.isUnknown() ? t.lstat().then(() => {
3605
+ this.walkCB(t, this.patterns, () => this.results.end());
3606
+ }) : this.walkCB(t, this.patterns, () => this.results.end()), this.results;
3607
+ }
3608
+ streamSync() {
3609
+ return this.path.isUnknown() && this.path.lstatSync(), this.walkCBSync(this.path, this.patterns, () => this.results.end()), this.results;
3610
+ }
3611
+ };
3612
+ var hn = typeof process == "object" && process && typeof process.platform == "string" ? process.platform : "linux";
3613
+ var j = class {
3614
+ absolute;
3615
+ cwd;
3616
+ root;
3617
+ dot;
3618
+ dotRelative;
3619
+ follow;
3620
+ ignore;
3621
+ magicalBraces;
3622
+ mark;
3623
+ matchBase;
3624
+ maxDepth;
3625
+ nobrace;
3626
+ nocase;
3627
+ nodir;
3628
+ noext;
3629
+ noglobstar;
3630
+ pattern;
3631
+ platform;
3632
+ realpath;
3633
+ scurry;
3634
+ stat;
3635
+ signal;
3636
+ windowsPathsNoEscape;
3637
+ withFileTypes;
3638
+ includeChildMatches;
3639
+ opts;
3640
+ patterns;
3641
+ constructor(t, e) {
3642
+ if (!e) throw new TypeError("glob options required");
3643
+ if (this.withFileTypes = !!e.withFileTypes, this.signal = e.signal, this.follow = !!e.follow, this.dot = !!e.dot, this.dotRelative = !!e.dotRelative, this.nodir = !!e.nodir, this.mark = !!e.mark, e.cwd ? (e.cwd instanceof URL || e.cwd.startsWith("file://")) && (e.cwd = fileURLToPath(e.cwd)) : this.cwd = "", this.cwd = e.cwd || "", this.root = e.root, this.magicalBraces = !!e.magicalBraces, this.nobrace = !!e.nobrace, this.noext = !!e.noext, this.realpath = !!e.realpath, this.absolute = e.absolute, this.includeChildMatches = e.includeChildMatches !== !1, this.noglobstar = !!e.noglobstar, this.matchBase = !!e.matchBase, this.maxDepth = typeof e.maxDepth == "number" ? e.maxDepth : 1 / 0, this.stat = !!e.stat, this.ignore = e.ignore, this.withFileTypes && this.absolute !== void 0) throw new Error("cannot set absolute and withFileTypes:true");
3644
+ let s = typeof t == "string" ? [t] : t;
3645
+ if (this.windowsPathsNoEscape = !!e.windowsPathsNoEscape || e.allowWindowsEscape === !1, this.windowsPathsNoEscape && (s = s.map((l) => l.replace(/\\/g, "/"))), this.matchBase) {
3646
+ if (e.noglobstar) throw new TypeError("base matching requires globstar");
3647
+ s = s.map((l) => l.includes("/") ? l : `./**/${l}`);
3648
+ }
3649
+ if (this.pattern = s, this.platform = e.platform || hn, this.opts = {
3650
+ ...e,
3651
+ platform: this.platform
3652
+ }, e.scurry) {
3653
+ if (this.scurry = e.scurry, e.nocase !== void 0 && e.nocase !== e.scurry.nocase) throw new Error("nocase option contradicts provided scurry option");
3654
+ } else {
3655
+ let l = e.platform === "win32" ? rt : e.platform === "darwin" ? At : e.platform ? ot : Es;
3656
+ this.scurry = new l(this.cwd, {
3657
+ nocase: e.nocase,
3658
+ fs: e.fs
3659
+ });
3660
+ }
3661
+ this.nocase = this.scurry.nocase;
3662
+ let i = this.platform === "darwin" || this.platform === "win32", n = {
3663
+ braceExpandMax: 1e4,
3664
+ ...e,
3665
+ dot: this.dot,
3666
+ matchBase: this.matchBase,
3667
+ nobrace: this.nobrace,
3668
+ nocase: this.nocase,
3669
+ nocaseMagicOnly: i,
3670
+ nocomment: !0,
3671
+ noext: this.noext,
3672
+ nonegate: !0,
3673
+ optimizationLevel: 2,
3674
+ platform: this.platform,
3675
+ windowsPathsNoEscape: this.windowsPathsNoEscape
3676
+ }, [a, h] = this.pattern.map((l) => new D(l, n)).reduce((l, c) => (l[0].push(...c.set), l[1].push(...c.globParts), l), [[], []]);
3677
+ this.patterns = a.map((l, c) => {
3678
+ let f = h[c];
3679
+ if (!f) throw new Error("invalid pattern object");
3680
+ return new ht(l, f, 0, this.platform);
3681
+ });
3682
+ }
3683
+ async walk() {
3684
+ return await new Mt(this.patterns, this.scurry.cwd, {
3685
+ ...this.opts,
3686
+ maxDepth: this.maxDepth !== 1 / 0 ? this.maxDepth + this.scurry.cwd.depth() : 1 / 0,
3687
+ platform: this.platform,
3688
+ nocase: this.nocase,
3689
+ includeChildMatches: this.includeChildMatches
3690
+ }).walk();
3691
+ }
3692
+ walkSync() {
3693
+ return new Mt(this.patterns, this.scurry.cwd, {
3694
+ ...this.opts,
3695
+ maxDepth: this.maxDepth !== 1 / 0 ? this.maxDepth + this.scurry.cwd.depth() : 1 / 0,
3696
+ platform: this.platform,
3697
+ nocase: this.nocase,
3698
+ includeChildMatches: this.includeChildMatches
3699
+ }).walkSync();
3700
+ }
3701
+ stream() {
3702
+ return new Tt(this.patterns, this.scurry.cwd, {
3703
+ ...this.opts,
3704
+ maxDepth: this.maxDepth !== 1 / 0 ? this.maxDepth + this.scurry.cwd.depth() : 1 / 0,
3705
+ platform: this.platform,
3706
+ nocase: this.nocase,
3707
+ includeChildMatches: this.includeChildMatches
3708
+ }).stream();
3709
+ }
3710
+ streamSync() {
3711
+ return new Tt(this.patterns, this.scurry.cwd, {
3712
+ ...this.opts,
3713
+ maxDepth: this.maxDepth !== 1 / 0 ? this.maxDepth + this.scurry.cwd.depth() : 1 / 0,
3714
+ platform: this.platform,
3715
+ nocase: this.nocase,
3716
+ includeChildMatches: this.includeChildMatches
3717
+ }).streamSync();
3718
+ }
3719
+ iterateSync() {
3720
+ return this.streamSync()[Symbol.iterator]();
3721
+ }
3722
+ [Symbol.iterator]() {
3723
+ return this.iterateSync();
3724
+ }
3725
+ iterate() {
3726
+ return this.stream()[Symbol.asyncIterator]();
3727
+ }
3728
+ [Symbol.asyncIterator]() {
3729
+ return this.iterate();
3730
+ }
3731
+ };
3732
+ var _e = (r, t = {}) => {
3733
+ for (let e of Array.isArray(r) ? r : [r]) if (new D(e, t).hasMagic()) return !0;
3734
+ return !1;
3735
+ };
3736
+ function Jt(r, t = {}) {
3737
+ return new j(r, t).streamSync();
3738
+ }
3739
+ function As(r, t = {}) {
3740
+ return new j(r, t).stream();
3741
+ }
3742
+ function Rs(r, t = {}) {
3743
+ return new j(r, t).walkSync();
3744
+ }
3745
+ async function ks(r, t = {}) {
3746
+ return new j(r, t).walk();
3747
+ }
3748
+ function Qt(r, t = {}) {
3749
+ return new j(r, t).iterateSync();
3750
+ }
3751
+ function Os(r, t = {}) {
3752
+ return new j(r, t).iterate();
3753
+ }
3754
+ var an = Jt;
3755
+ var ln = Object.assign(As, { sync: Jt });
3756
+ var cn = Qt;
3757
+ var fn = Object.assign(Os, { sync: Qt });
3758
+ var un = Object.assign(Rs, {
3759
+ stream: Jt,
3760
+ iterate: Qt
3761
+ });
3762
+ var Cs = Object.assign(ks, {
3763
+ glob: ks,
3764
+ globSync: Rs,
3765
+ sync: un,
3766
+ globStream: As,
3767
+ stream: ln,
3768
+ globStreamSync: Jt,
3769
+ streamSync: an,
3770
+ globIterate: Os,
3771
+ iterate: fn,
3772
+ globIterateSync: Qt,
3773
+ iterateSync: cn,
3774
+ Glob: j,
3775
+ hasMagic: _e,
3776
+ escape: K,
3777
+ unescape: st
3778
+ });
3779
+ Cs.glob = Cs;
3780
+ export { j as Glob, at as Ignore, K as escape, Cs as glob, Os as globIterate, Qt as globIterateSync, As as globStream, Jt as globStreamSync, Rs as globSync, _e as hasMagic, fn as iterate, cn as iterateSync, ln as stream, an as streamSync, un as sync, st as unescape };
3781
+
3782
+ //# sourceMappingURL=index.min-ClUfQ5ji.mjs.map