e2e-ai 1.4.3 → 1.5.1

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