e2e-ai 1.2.0 → 1.4.0

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.
package/dist/cli.js CHANGED
@@ -1,14 +1,13 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
- loadAgent,
4
- scanCodebase
5
- } from "./cli-g7cc13w2.js";
3
+ loadAgent
4
+ } from "./cli-98db6h2q.js";
6
5
  import {
7
6
  getPackageRoot,
8
7
  getProjectRoot,
9
8
  loadConfig
10
- } from "./cli-ba9d3pdp.js";
11
- import"./cli-ph82pe4b.js";
9
+ } from "./cli-kx32qnf3.js";
10
+ import"./cli-fgp618yt.js";
12
11
  import {
13
12
  __commonJS,
14
13
  __export,
@@ -9057,10 +9056,11 @@ var import_picocolors2 = __toESM(require_picocolors(), 1);
9057
9056
  function registerInit(program2) {
9058
9057
  program2.command("init").description("Initialize e2e-ai configuration for your project").option("--non-interactive", "Skip interactive prompts, use defaults").action(async (cmdOpts) => {
9059
9058
  const projectRoot = getProjectRoot();
9059
+ const e2eDir = join13(projectRoot, ".e2e-ai");
9060
9060
  header("e2e-ai init");
9061
9061
  const answers = cmdOpts?.nonInteractive ? getDefaultAnswers() : await askConfigQuestions();
9062
9062
  const config = buildConfigFromAnswers(answers);
9063
- const configPath = join13(projectRoot, "e2e-ai.config.ts");
9063
+ const configPath = join13(e2eDir, "config.ts");
9064
9064
  if (fileExists(configPath)) {
9065
9065
  warn(`Config already exists: ${configPath}`);
9066
9066
  const overwrite = cmdOpts?.nonInteractive ? false : await dist_default4({ message: "Overwrite existing config?", default: false });
@@ -9074,28 +9074,15 @@ function registerInit(program2) {
9074
9074
  writeFile(configPath, generateConfigFile(config));
9075
9075
  success(`Config written: ${configPath}`);
9076
9076
  }
9077
- const spinner = createSpinner();
9078
- spinner.start("Scanning codebase for test patterns...");
9079
- const scan = await scanCodebase(projectRoot);
9080
- spinner.stop();
9081
- if (scan.testFiles.length === 0 && scan.configFiles.length === 0) {
9082
- warn("No test files found. Scan results will be minimal.");
9083
- } else {
9084
- info(`Found ${scan.testFiles.length} test files, ${scan.configFiles.length} config files`);
9085
- }
9086
- const instructionsContent = generateInstructionsFile(scan);
9087
- const instructionsPath = join13(projectRoot, "e2e-ai.instructions.md");
9088
- writeFile(instructionsPath, instructionsContent);
9089
- success(`Instructions written: ${instructionsPath}`);
9090
- const copiedCount = await copyAgentsToLocal(projectRoot, !!cmdOpts?.nonInteractive);
9077
+ await copyAgentsToLocal(projectRoot, !!cmdOpts?.nonInteractive);
9091
9078
  console.log("");
9092
9079
  success(`Initialization complete!
9093
9080
  `);
9094
9081
  console.log(import_picocolors2.default.bold("Next steps:"));
9095
- console.log(` 1. Open ${import_picocolors2.default.cyan("e2e-ai.instructions.md")} with your AI tool`);
9082
+ console.log(` 1. Use the ${import_picocolors2.default.cyan("init-agent")} in your AI tool to generate ${import_picocolors2.default.cyan(".e2e-ai/context.md")}`);
9083
+ console.log(` (or use the MCP server: ${import_picocolors2.default.cyan("e2e_ai_scan_codebase")} + ${import_picocolors2.default.cyan("e2e_ai_read_agent")})`);
9096
9084
  console.log(` 2. Review the generated ${import_picocolors2.default.cyan(".e2e-ai/context.md")}`);
9097
- console.log(` 3. Customize agents in ${import_picocolors2.default.cyan(".e2e-ai/agents/")} if needed`);
9098
- console.log(` 4. Run: ${import_picocolors2.default.cyan("e2e-ai run --key PROJ-101")}`);
9085
+ console.log(` 3. Run: ${import_picocolors2.default.cyan("e2e-ai run --key PROJ-101")}`);
9099
9086
  });
9100
9087
  }
9101
9088
  function getDefaultAnswers() {
@@ -9157,8 +9144,7 @@ function buildConfigFromAnswers(answers) {
9157
9144
  inputSource: answers.inputSource,
9158
9145
  outputTarget: answers.outputTarget,
9159
9146
  voice: { enabled: answers.voiceEnabled },
9160
- llm: { provider: answers.provider },
9161
- contextFile: ".e2e-ai/context.md"
9147
+ llm: { provider: answers.provider }
9162
9148
  };
9163
9149
  if (answers.baseUrl) {
9164
9150
  config.baseUrl = answers.baseUrl;
@@ -9190,127 +9176,6 @@ function generateConfigFile(config) {
9190
9176
  return lines.join(`
9191
9177
  `);
9192
9178
  }
9193
- function generateInstructionsFile(scan) {
9194
- const packageRoot = getPackageRoot();
9195
- const sections = [];
9196
- sections.push(`# e2e-ai: Context Generation Instructions
9197
-
9198
- This file was generated by \`e2e-ai init\`. It contains everything an AI tool needs to generate \`.e2e-ai/context.md\` for your project.
9199
-
9200
- ## How to Use
9201
-
9202
- 1. Open this file in your AI tool (Claude Code, Cursor, Gemini CLI, etc.)
9203
- 2. Ask it to follow these instructions to generate \`.e2e-ai/context.md\`
9204
- 3. Review the generated file and adjust as needed
9205
-
9206
- Alternatively, if the e2e-ai MCP server is configured, your AI tool can call \`e2e_ai_scan_codebase\` and \`e2e_ai_validate_context\` directly.
9207
-
9208
- ---`);
9209
- sections.push(`## Task
9210
-
9211
- Scan this codebase and generate a file at \`.e2e-ai/context.md\` that documents the project's test infrastructure, conventions, and patterns. This context file is consumed by downstream AI agents (scenario, generator, refiner, healer, QA) to produce Playwright tests that match the project's existing style.`);
9212
- sections.push(`## Codebase Scan Results
9213
-
9214
- The following was pre-computed during \`e2e-ai init\`:
9215
-
9216
- ### Test Files (${scan.testFiles.length} found)
9217
- ${scan.testFiles.length > 0 ? scan.testFiles.slice(0, 20).map((f) => `- \`${f}\``).join(`
9218
- `) : "_No test files found_"}
9219
- ${scan.testFiles.length > 20 ? `
9220
- _(${scan.testFiles.length - 20} more not shown)_` : ""}
9221
-
9222
- ### Config Files
9223
- ${scan.configFiles.length > 0 ? scan.configFiles.map((f) => `- \`${f}\``).join(`
9224
- `) : "_None found_"}
9225
-
9226
- ### Fixture Files
9227
- ${scan.fixtureFiles.length > 0 ? scan.fixtureFiles.slice(0, 10).map((f) => `- \`${f}\``).join(`
9228
- `) : "_None found_"}
9229
-
9230
- ### Feature Files
9231
- ${scan.featureFiles.length > 0 ? scan.featureFiles.slice(0, 20).map((f) => `- \`${f}\``).join(`
9232
- `) : "_None found_"}
9233
-
9234
- ### Path Aliases (from tsconfig.json)
9235
- ${Object.keys(scan.tsconfigPaths).length > 0 ? Object.entries(scan.tsconfigPaths).map(([alias, targets]) => `- \`${alias}\` -> \`${targets.join(", ")}\``).join(`
9236
- `) : "_None configured_"}
9237
-
9238
- ### Playwright Config
9239
- ${scan.playwrightConfig ? `Found: \`${scan.playwrightConfig}\`` : "_Not found_"}
9240
-
9241
- ### Sample Test Content
9242
- ${scan.sampleTestContent ? "```typescript\n" + scan.sampleTestContent + "\n```" : "_No sample available_"}`);
9243
- let agentChecklist = "";
9244
- try {
9245
- const agentContent = readFileSync2(join13(packageRoot, "agents", "init-agent.md"), "utf-8");
9246
- const bodyMatch = agentContent.match(/^---\n[\s\S]*?\n---\n([\s\S]*)$/);
9247
- if (bodyMatch) {
9248
- agentChecklist = bodyMatch[1].trim();
9249
- }
9250
- } catch {}
9251
- if (agentChecklist) {
9252
- sections.push(`## What to Look For
9253
-
9254
- The following guidance comes from the e2e-ai init agent:
9255
-
9256
- ${agentChecklist}`);
9257
- }
9258
- sections.push(`## Output Format
9259
-
9260
- The generated \`.e2e-ai/context.md\` MUST contain these sections:
9261
-
9262
- \`\`\`markdown
9263
- # Project Context for e2e-ai
9264
-
9265
- ## Application
9266
- <name, description, tech stack, base URL>
9267
-
9268
- ## Test Infrastructure
9269
- <fixtures, helpers, auth pattern>
9270
-
9271
- ## Feature Methods
9272
- <method signatures grouped by module>
9273
-
9274
- ## Import Conventions
9275
- <path aliases, standard imports>
9276
-
9277
- ## Selector Conventions
9278
- <preferred selector strategies, patterns>
9279
-
9280
- ## Test Structure Template
9281
- <code template showing standard test layout>
9282
-
9283
- ## Utility Patterns
9284
- <timeouts, waits, assertion patterns>
9285
- \`\`\`
9286
-
9287
- All sections are required. The file should be 100-300 lines, self-contained, and use actual code from the project (not generic Playwright examples).`);
9288
- sections.push(`## How Context is Used
9289
-
9290
- Each pipeline agent reads \`.e2e-ai/context.md\` to understand project conventions:
9291
-
9292
- | Agent | Uses context for |
9293
- |-------|-----------------|
9294
- | **scenario-agent** | Structuring test steps to match project patterns |
9295
- | **playwright-generator-agent** | Generating code with correct imports, fixtures, selectors |
9296
- | **refactor-agent** | Applying project-specific refactoring patterns |
9297
- | **self-healing-agent** | Understanding expected test structure when fixing failures |
9298
- | **qa-testcase-agent** | Formatting QA documentation to match conventions |`);
9299
- let exampleContent = "";
9300
- try {
9301
- exampleContent = readFileSync2(join13(packageRoot, "templates", "e2e-ai.context.example.md"), "utf-8");
9302
- } catch {}
9303
- if (exampleContent) {
9304
- sections.push(`## Complete Example
9305
-
9306
- Below is a full example of a well-structured context file:
9307
-
9308
- ${exampleContent}`);
9309
- }
9310
- return sections.join(`
9311
-
9312
- `);
9313
- }
9314
9179
  async function copyAgentsToLocal(projectRoot, nonInteractive) {
9315
9180
  const packageRoot = getPackageRoot();
9316
9181
  const sourceDir = join13(packageRoot, "agents");
@@ -9351,6 +9216,3892 @@ async function copyAgentsToLocal(projectRoot, nonInteractive) {
9351
9216
  return agentFiles.length;
9352
9217
  }
9353
9218
 
9219
+ // src/commands/scan.ts
9220
+ import { join as join15 } from "node:path";
9221
+
9222
+ // src/scanner/scanner.ts
9223
+ import { readFileSync as readFileSync4, existsSync as existsSync3, mkdirSync as mkdirSync2, writeFileSync as writeFileSync2 } from "node:fs";
9224
+ import { resolve, relative as relative2 } from "node:path";
9225
+ import { createHash } from "node:crypto";
9226
+
9227
+ // node_modules/glob/dist/esm/index.min.js
9228
+ import { fileURLToPath as Wi } from "node:url";
9229
+ import { posix as mi, win32 as re } from "node:path";
9230
+ import { fileURLToPath as gi } from "node:url";
9231
+ import { lstatSync as wi, readdir as yi, readdirSync as bi, readlinkSync as Si, realpathSync as Ei } from "fs";
9232
+ import * as xi from "node:fs";
9233
+ import { lstat as Ci, readdir as Ti, readlink as Ai, realpath as ki } from "node:fs/promises";
9234
+ import { EventEmitter as ee } from "node:events";
9235
+ import Pe from "node:stream";
9236
+ import { StringDecoder as ni } from "node:string_decoder";
9237
+ var Gt = (n, t, e) => {
9238
+ 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);
9239
+ 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) };
9240
+ };
9241
+ var ce = (n, t) => {
9242
+ let e = t.match(n);
9243
+ return e ? e[0] : null;
9244
+ };
9245
+ var ss = (n, t, e) => {
9246
+ let s, i, r, o, h, a = e.indexOf(n), l = e.indexOf(t, a + 1), u = a;
9247
+ if (a >= 0 && l > 0) {
9248
+ if (n === t)
9249
+ return [a, l];
9250
+ for (s = [], r = e.length;u >= 0 && !h; ) {
9251
+ if (u === a)
9252
+ s.push(u), a = e.indexOf(n, u + 1);
9253
+ else if (s.length === 1) {
9254
+ let c = s.pop();
9255
+ c !== undefined && (h = [c, l]);
9256
+ } else
9257
+ i = s.pop(), i !== undefined && i < r && (r = i, o = l), l = e.indexOf(t, u + 1);
9258
+ u = a < l && a >= 0 ? a : l;
9259
+ }
9260
+ s.length && o !== undefined && (h = [r, o]);
9261
+ }
9262
+ return h;
9263
+ };
9264
+ var fe = "\x00SLASH" + Math.random() + "\x00";
9265
+ var ue = "\x00OPEN" + Math.random() + "\x00";
9266
+ var qt = "\x00CLOSE" + Math.random() + "\x00";
9267
+ var de = "\x00COMMA" + Math.random() + "\x00";
9268
+ var pe = "\x00PERIOD" + Math.random() + "\x00";
9269
+ var is = new RegExp(fe, "g");
9270
+ var rs = new RegExp(ue, "g");
9271
+ var ns = new RegExp(qt, "g");
9272
+ var os2 = new RegExp(de, "g");
9273
+ var hs = new RegExp(pe, "g");
9274
+ var as = /\\\\/g;
9275
+ var ls = /\\{/g;
9276
+ var cs = /\\}/g;
9277
+ var fs = /\\,/g;
9278
+ var us = /\\./g;
9279
+ var ds = 1e5;
9280
+ function Ht(n) {
9281
+ return isNaN(n) ? n.charCodeAt(0) : parseInt(n, 10);
9282
+ }
9283
+ function ps(n) {
9284
+ return n.replace(as, fe).replace(ls, ue).replace(cs, qt).replace(fs, de).replace(us, pe);
9285
+ }
9286
+ function ms(n) {
9287
+ return n.replace(is, "\\").replace(rs, "{").replace(ns, "}").replace(os2, ",").replace(hs, ".");
9288
+ }
9289
+ function me(n) {
9290
+ if (!n)
9291
+ return [""];
9292
+ let t = [], e = Gt("{", "}", n);
9293
+ if (!e)
9294
+ return n.split(",");
9295
+ let { pre: s, body: i, post: r } = e, o = s.split(",");
9296
+ o[o.length - 1] += "{" + i + "}";
9297
+ let h = me(r);
9298
+ return r.length && (o[o.length - 1] += h.shift(), o.push.apply(o, h)), t.push.apply(t, o), t;
9299
+ }
9300
+ function ge(n, t = {}) {
9301
+ if (!n)
9302
+ return [];
9303
+ let { max: e = ds } = t;
9304
+ return n.slice(0, 2) === "{}" && (n = "\\{\\}" + n.slice(2)), ht(ps(n), e, true).map(ms);
9305
+ }
9306
+ function gs(n) {
9307
+ return "{" + n + "}";
9308
+ }
9309
+ function ws(n) {
9310
+ return /^-?0\d/.test(n);
9311
+ }
9312
+ function ys(n, t) {
9313
+ return n <= t;
9314
+ }
9315
+ function bs(n, t) {
9316
+ return n >= t;
9317
+ }
9318
+ function ht(n, t, e) {
9319
+ let s = [], i = Gt("{", "}", n);
9320
+ if (!i)
9321
+ return [n];
9322
+ let r = i.pre, o = i.post.length ? ht(i.post, t, false) : [""];
9323
+ if (/\$$/.test(i.pre))
9324
+ for (let h = 0;h < o.length && h < t; h++) {
9325
+ let a = r + "{" + i.body + "}" + o[h];
9326
+ s.push(a);
9327
+ }
9328
+ else {
9329
+ 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;
9330
+ if (!l && !u)
9331
+ return i.post.match(/,(?!,).*\}/) ? (n = i.pre + "{" + i.body + qt + i.post, ht(n, t, true)) : [n];
9332
+ let c;
9333
+ if (l)
9334
+ c = i.body.split(/\.\./);
9335
+ else if (c = me(i.body), c.length === 1 && c[0] !== undefined && (c = ht(c[0], t, false).map(gs), c.length === 1))
9336
+ return o.map((f) => i.pre + c[0] + f);
9337
+ let d;
9338
+ if (l && c[0] !== undefined && c[1] !== undefined) {
9339
+ 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;
9340
+ m < f && (w *= -1, g = bs);
9341
+ let E = c.some(ws);
9342
+ d = [];
9343
+ for (let y = f;g(y, m); y += w) {
9344
+ let b;
9345
+ if (a)
9346
+ b = String.fromCharCode(y), b === "\\" && (b = "");
9347
+ else if (b = String(y), E) {
9348
+ let z = p - b.length;
9349
+ if (z > 0) {
9350
+ let $ = new Array(z + 1).join("0");
9351
+ y < 0 ? b = "-" + $ + b.slice(1) : b = $ + b;
9352
+ }
9353
+ }
9354
+ d.push(b);
9355
+ }
9356
+ } else {
9357
+ d = [];
9358
+ for (let f = 0;f < c.length; f++)
9359
+ d.push.apply(d, ht(c[f], t, false));
9360
+ }
9361
+ for (let f = 0;f < d.length; f++)
9362
+ for (let m = 0;m < o.length && s.length < t; m++) {
9363
+ let p = r + d[f] + o[m];
9364
+ (!e || l || p) && s.push(p);
9365
+ }
9366
+ }
9367
+ return s;
9368
+ }
9369
+ var at = (n) => {
9370
+ if (typeof n != "string")
9371
+ throw new TypeError("invalid pattern");
9372
+ if (n.length > 65536)
9373
+ throw new TypeError("pattern is too long");
9374
+ };
9375
+ 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] };
9376
+ var lt = (n) => n.replace(/[[\]\\-]/g, "\\$&");
9377
+ var Es = (n) => n.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
9378
+ var we = (n) => n.join("");
9379
+ var ye = (n, t) => {
9380
+ let e = t;
9381
+ if (n.charAt(e) !== "[")
9382
+ throw new Error("not in a brace expression");
9383
+ let s = [], i = [], r = e + 1, o = false, h = false, a = false, l = false, u = e, c = "";
9384
+ t:
9385
+ for (;r < n.length; ) {
9386
+ let p = n.charAt(r);
9387
+ if ((p === "!" || p === "^") && r === e + 1) {
9388
+ l = true, r++;
9389
+ continue;
9390
+ }
9391
+ if (p === "]" && o && !a) {
9392
+ u = r + 1;
9393
+ break;
9394
+ }
9395
+ if (o = true, p === "\\" && !a) {
9396
+ a = true, r++;
9397
+ continue;
9398
+ }
9399
+ if (p === "[" && !a) {
9400
+ for (let [w, [g, S, E]] of Object.entries(Ss))
9401
+ if (n.startsWith(w, r)) {
9402
+ if (c)
9403
+ return ["$.", false, n.length - e, true];
9404
+ r += w.length, E ? i.push(g) : s.push(g), h = h || S;
9405
+ continue t;
9406
+ }
9407
+ }
9408
+ if (a = false, c) {
9409
+ p > c ? s.push(lt(c) + "-" + lt(p)) : p === c && s.push(lt(p)), c = "", r++;
9410
+ continue;
9411
+ }
9412
+ if (n.startsWith("-]", r + 1)) {
9413
+ s.push(lt(p + "-")), r += 2;
9414
+ continue;
9415
+ }
9416
+ if (n.startsWith("-", r + 1)) {
9417
+ c = p, r += 2;
9418
+ continue;
9419
+ }
9420
+ s.push(lt(p)), r++;
9421
+ }
9422
+ if (u < r)
9423
+ return ["", false, 0, false];
9424
+ if (!s.length && !i.length)
9425
+ return ["$.", false, n.length - e, true];
9426
+ if (i.length === 0 && s.length === 1 && /^\\?.$/.test(s[0]) && !l) {
9427
+ let p = s[0].length === 2 ? s[0].slice(-1) : s[0];
9428
+ return [Es(p), false, u - e, false];
9429
+ }
9430
+ let d = "[" + (l ? "^" : "") + we(s) + "]", f = "[" + (l ? "" : "^") + we(i) + "]";
9431
+ return [s.length && i.length ? "(" + d + "|" + f + ")" : s.length ? d : f, h, u - e, true];
9432
+ };
9433
+ 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");
9434
+ var xs = new Set(["!", "?", "+", "*", "@"]);
9435
+ var be = (n) => xs.has(n);
9436
+ var vs = "(?!(?:^|/)\\.\\.?(?:$|/))";
9437
+ var Ct = "(?!\\.)";
9438
+ var Cs = new Set(["[", "."]);
9439
+ var Ts = new Set(["..", "."]);
9440
+ var As = new Set("().*{}+?[]^$\\!");
9441
+ var ks = (n) => n.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
9442
+ var Kt = "[^/]";
9443
+ var Se = Kt + "*?";
9444
+ var Ee = Kt + "+?";
9445
+ var Q = class n {
9446
+ type;
9447
+ #t;
9448
+ #s;
9449
+ #n = false;
9450
+ #r = [];
9451
+ #o;
9452
+ #S;
9453
+ #w;
9454
+ #c = false;
9455
+ #h;
9456
+ #u;
9457
+ #f = false;
9458
+ constructor(t, e, s = {}) {
9459
+ 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;
9460
+ }
9461
+ get hasMagic() {
9462
+ if (this.#s !== undefined)
9463
+ return this.#s;
9464
+ for (let t of this.#r)
9465
+ if (typeof t != "string" && (t.type || t.hasMagic))
9466
+ return this.#s = true;
9467
+ return this.#s;
9468
+ }
9469
+ toString() {
9470
+ 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("");
9471
+ }
9472
+ #a() {
9473
+ if (this !== this.#t)
9474
+ throw new Error("should only call on root");
9475
+ if (this.#c)
9476
+ return this;
9477
+ this.toString(), this.#c = true;
9478
+ let t;
9479
+ for (;t = this.#w.pop(); ) {
9480
+ if (t.type !== "!")
9481
+ continue;
9482
+ let e = t, s = e.#o;
9483
+ for (;s; ) {
9484
+ for (let i = e.#S + 1;!s.type && i < s.#r.length; i++)
9485
+ for (let r of t.#r) {
9486
+ if (typeof r == "string")
9487
+ throw new Error("string part in extglob AST??");
9488
+ r.copyIn(s.#r[i]);
9489
+ }
9490
+ e = s, s = e.#o;
9491
+ }
9492
+ }
9493
+ return this;
9494
+ }
9495
+ push(...t) {
9496
+ for (let e of t)
9497
+ if (e !== "") {
9498
+ if (typeof e != "string" && !(e instanceof n && e.#o === this))
9499
+ throw new Error("invalid part: " + e);
9500
+ this.#r.push(e);
9501
+ }
9502
+ }
9503
+ toJSON() {
9504
+ let t = this.type === null ? this.#r.slice().map((e) => typeof e == "string" ? e : e.toJSON()) : [this.type, ...this.#r.map((e) => e.toJSON())];
9505
+ return this.isStart() && !this.type && t.unshift([]), this.isEnd() && (this === this.#t || this.#t.#c && this.#o?.type === "!") && t.push({}), t;
9506
+ }
9507
+ isStart() {
9508
+ if (this.#t === this)
9509
+ return true;
9510
+ if (!this.#o?.isStart())
9511
+ return false;
9512
+ if (this.#S === 0)
9513
+ return true;
9514
+ let t = this.#o;
9515
+ for (let e = 0;e < this.#S; e++) {
9516
+ let s = t.#r[e];
9517
+ if (!(s instanceof n && s.type === "!"))
9518
+ return false;
9519
+ }
9520
+ return true;
9521
+ }
9522
+ isEnd() {
9523
+ if (this.#t === this || this.#o?.type === "!")
9524
+ return true;
9525
+ if (!this.#o?.isEnd())
9526
+ return false;
9527
+ if (!this.type)
9528
+ return this.#o?.isEnd();
9529
+ let t = this.#o ? this.#o.#r.length : 0;
9530
+ return this.#S === t - 1;
9531
+ }
9532
+ copyIn(t) {
9533
+ typeof t == "string" ? this.push(t) : this.push(t.clone(this));
9534
+ }
9535
+ clone(t) {
9536
+ let e = new n(this.type, t);
9537
+ for (let s of this.#r)
9538
+ e.copyIn(s);
9539
+ return e;
9540
+ }
9541
+ static #i(t, e, s, i) {
9542
+ let r = false, o = false, h = -1, a = false;
9543
+ if (e.type === null) {
9544
+ let f = s, m = "";
9545
+ for (;f < t.length; ) {
9546
+ let p = t.charAt(f++);
9547
+ if (r || p === "\\") {
9548
+ r = !r, m += p;
9549
+ continue;
9550
+ }
9551
+ if (o) {
9552
+ f === h + 1 ? (p === "^" || p === "!") && (a = true) : p === "]" && !(f === h + 2 && a) && (o = false), m += p;
9553
+ continue;
9554
+ } else if (p === "[") {
9555
+ o = true, h = f, a = false, m += p;
9556
+ continue;
9557
+ }
9558
+ if (!i.noext && be(p) && t.charAt(f) === "(") {
9559
+ e.push(m), m = "";
9560
+ let w = new n(p, e);
9561
+ f = n.#i(t, w, f, i), e.push(w);
9562
+ continue;
9563
+ }
9564
+ m += p;
9565
+ }
9566
+ return e.push(m), f;
9567
+ }
9568
+ let l = s + 1, u = new n(null, e), c = [], d = "";
9569
+ for (;l < t.length; ) {
9570
+ let f = t.charAt(l++);
9571
+ if (r || f === "\\") {
9572
+ r = !r, d += f;
9573
+ continue;
9574
+ }
9575
+ if (o) {
9576
+ l === h + 1 ? (f === "^" || f === "!") && (a = true) : f === "]" && !(l === h + 2 && a) && (o = false), d += f;
9577
+ continue;
9578
+ } else if (f === "[") {
9579
+ o = true, h = l, a = false, d += f;
9580
+ continue;
9581
+ }
9582
+ if (be(f) && t.charAt(l) === "(") {
9583
+ u.push(d), d = "";
9584
+ let m = new n(f, u);
9585
+ u.push(m), l = n.#i(t, m, l, i);
9586
+ continue;
9587
+ }
9588
+ if (f === "|") {
9589
+ u.push(d), d = "", c.push(u), u = new n(null, e);
9590
+ continue;
9591
+ }
9592
+ if (f === ")")
9593
+ return d === "" && e.#r.length === 0 && (e.#f = true), u.push(d), d = "", e.push(...c, u), l;
9594
+ d += f;
9595
+ }
9596
+ return e.type = null, e.#s = undefined, e.#r = [t.substring(s - 1)], l;
9597
+ }
9598
+ static fromGlob(t, e = {}) {
9599
+ let s = new n(null, undefined, e);
9600
+ return n.#i(t, s, 0, e), s;
9601
+ }
9602
+ toMMPattern() {
9603
+ if (this !== this.#t)
9604
+ return this.#t.toMMPattern();
9605
+ let t = this.toString(), [e, s, i, r] = this.toRegExpSource();
9606
+ if (!(i || this.#s || this.#h.nocase && !this.#h.nocaseMagicOnly && t.toUpperCase() !== t.toLowerCase()))
9607
+ return s;
9608
+ let h = (this.#h.nocase ? "i" : "") + (r ? "u" : "");
9609
+ return Object.assign(new RegExp(`^${e}$`, h), { _src: e, _glob: t });
9610
+ }
9611
+ get options() {
9612
+ return this.#h;
9613
+ }
9614
+ toRegExpSource(t) {
9615
+ let e = t ?? !!this.#h.dot;
9616
+ if (this.#t === this && this.#a(), !this.type) {
9617
+ let a = this.isStart() && this.isEnd() && !this.#r.some((f) => typeof f != "string"), l = this.#r.map((f) => {
9618
+ let [m, p, w, g] = typeof f == "string" ? n.#E(f, this.#s, a) : f.toRegExpSource(t);
9619
+ return this.#s = this.#s || w, this.#n = this.#n || g, m;
9620
+ }).join(""), u = "";
9621
+ if (this.isStart() && typeof this.#r[0] == "string" && !(this.#r.length === 1 && Ts.has(this.#r[0]))) {
9622
+ 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));
9623
+ u = p ? vs : w ? Ct : "";
9624
+ }
9625
+ let c = "";
9626
+ return this.isEnd() && this.#t.#c && this.#o?.type === "!" && (c = "(?:$|\\/)"), [u + l + c, W(l), this.#s = !!this.#s, this.#n];
9627
+ }
9628
+ let s = this.type === "*" || this.type === "+", i = this.type === "!" ? "(?:(?!(?:" : "(?:", r = this.#d(e);
9629
+ if (this.isStart() && this.isEnd() && !r && this.type !== "!") {
9630
+ let a = this.toString();
9631
+ return this.#r = [a], this.type = null, this.#s = undefined, [a, W(this.toString()), false, false];
9632
+ }
9633
+ let o = !s || t || e || !Ct ? "" : this.#d(true);
9634
+ o === r && (o = ""), o && (r = `(?:${r})(?:${o})*?`);
9635
+ let h = "";
9636
+ if (this.type === "!" && this.#f)
9637
+ h = (this.isStart() && !e ? Ct : "") + Ee;
9638
+ else {
9639
+ let a = this.type === "!" ? "))" + (this.isStart() && !e && !t ? Ct : "") + Se + ")" : this.type === "@" ? ")" : this.type === "?" ? ")?" : this.type === "+" && o ? ")" : this.type === "*" && o ? ")?" : `)${this.type}`;
9640
+ h = i + r + a;
9641
+ }
9642
+ return [h, W(r), this.#s = !!this.#s, this.#n];
9643
+ }
9644
+ #d(t) {
9645
+ return this.#r.map((e) => {
9646
+ if (typeof e == "string")
9647
+ throw new Error("string type in extglob ast??");
9648
+ let [s, i, r, o] = e.toRegExpSource(t);
9649
+ return this.#n = this.#n || o, s;
9650
+ }).filter((e) => !(this.isStart() && this.isEnd()) || !!e).join("|");
9651
+ }
9652
+ static #E(t, e, s = false) {
9653
+ let i = false, r = "", o = false, h = false;
9654
+ for (let a = 0;a < t.length; a++) {
9655
+ let l = t.charAt(a);
9656
+ if (i) {
9657
+ i = false, r += (As.has(l) ? "\\" : "") + l;
9658
+ continue;
9659
+ }
9660
+ if (l === "*") {
9661
+ if (h)
9662
+ continue;
9663
+ h = true, r += s && /^[*]+$/.test(t) ? Ee : Se, e = true;
9664
+ continue;
9665
+ } else
9666
+ h = false;
9667
+ if (l === "\\") {
9668
+ a === t.length - 1 ? r += "\\\\" : i = true;
9669
+ continue;
9670
+ }
9671
+ if (l === "[") {
9672
+ let [u, c, d, f] = ye(t, a);
9673
+ if (d) {
9674
+ r += u, o = o || c, a += d - 1, e = e || f;
9675
+ continue;
9676
+ }
9677
+ }
9678
+ if (l === "?") {
9679
+ r += Kt, e = true;
9680
+ continue;
9681
+ }
9682
+ r += ks(l);
9683
+ }
9684
+ return [r, W(t), !!e, o];
9685
+ }
9686
+ };
9687
+ var tt = (n2, { windowsPathsNoEscape: t = false, magicalBraces: e = false } = {}) => e ? t ? n2.replace(/[?*()[\]{}]/g, "[$&]") : n2.replace(/[?*()[\]\\{}]/g, "\\$&") : t ? n2.replace(/[?*()[\]]/g, "[$&]") : n2.replace(/[?*()[\]\\]/g, "\\$&");
9688
+ var O = (n2, t, e = {}) => (at(t), !e.nocomment && t.charAt(0) === "#" ? false : new D(t, e).match(n2));
9689
+ var Rs = /^\*+([^+@!?\*\[\(]*)$/;
9690
+ var Os = (n2) => (t) => !t.startsWith(".") && t.endsWith(n2);
9691
+ var Fs = (n2) => (t) => t.endsWith(n2);
9692
+ var Ds = (n2) => (n2 = n2.toLowerCase(), (t) => !t.startsWith(".") && t.toLowerCase().endsWith(n2));
9693
+ var Ms = (n2) => (n2 = n2.toLowerCase(), (t) => t.toLowerCase().endsWith(n2));
9694
+ var Ns = /^\*+\.\*+$/;
9695
+ var _s = (n2) => !n2.startsWith(".") && n2.includes(".");
9696
+ var Ls = (n2) => n2 !== "." && n2 !== ".." && n2.includes(".");
9697
+ var Ws = /^\.\*+$/;
9698
+ var Ps = (n2) => n2 !== "." && n2 !== ".." && n2.startsWith(".");
9699
+ var js = /^\*+$/;
9700
+ var Is = (n2) => n2.length !== 0 && !n2.startsWith(".");
9701
+ var zs = (n2) => n2.length !== 0 && n2 !== "." && n2 !== "..";
9702
+ var Bs = /^\?+([^+@!?\*\[\(]*)?$/;
9703
+ var Us = ([n2, t = ""]) => {
9704
+ let e = Ce([n2]);
9705
+ return t ? (t = t.toLowerCase(), (s) => e(s) && s.toLowerCase().endsWith(t)) : e;
9706
+ };
9707
+ var $s = ([n2, t = ""]) => {
9708
+ let e = Te([n2]);
9709
+ return t ? (t = t.toLowerCase(), (s) => e(s) && s.toLowerCase().endsWith(t)) : e;
9710
+ };
9711
+ var Gs = ([n2, t = ""]) => {
9712
+ let e = Te([n2]);
9713
+ return t ? (s) => e(s) && s.endsWith(t) : e;
9714
+ };
9715
+ var Hs = ([n2, t = ""]) => {
9716
+ let e = Ce([n2]);
9717
+ return t ? (s) => e(s) && s.endsWith(t) : e;
9718
+ };
9719
+ var Ce = ([n2]) => {
9720
+ let t = n2.length;
9721
+ return (e) => e.length === t && !e.startsWith(".");
9722
+ };
9723
+ var Te = ([n2]) => {
9724
+ let t = n2.length;
9725
+ return (e) => e.length === t && e !== "." && e !== "..";
9726
+ };
9727
+ var Ae = typeof process == "object" && process ? typeof process.env == "object" && process.env && process.env.__MINIMATCH_TESTING_PLATFORM__ || process.platform : "posix";
9728
+ var xe = { win32: { sep: "\\" }, posix: { sep: "/" } };
9729
+ var qs = Ae === "win32" ? xe.win32.sep : xe.posix.sep;
9730
+ O.sep = qs;
9731
+ var A = Symbol("globstar **");
9732
+ O.GLOBSTAR = A;
9733
+ var Ks = "[^/]";
9734
+ var Vs = Ks + "*?";
9735
+ var Ys = "(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?";
9736
+ var Xs = "(?:(?!(?:\\/|^)\\.).)*?";
9737
+ var Js = (n2, t = {}) => (e) => O(e, n2, t);
9738
+ O.filter = Js;
9739
+ var N = (n2, t = {}) => Object.assign({}, n2, t);
9740
+ var Zs = (n2) => {
9741
+ if (!n2 || typeof n2 != "object" || !Object.keys(n2).length)
9742
+ return O;
9743
+ let t = O;
9744
+ return Object.assign((s, i, r = {}) => t(s, i, N(n2, r)), { Minimatch: class extends t.Minimatch {
9745
+ constructor(i, r = {}) {
9746
+ super(i, N(n2, r));
9747
+ }
9748
+ static defaults(i) {
9749
+ return t.defaults(N(n2, i)).Minimatch;
9750
+ }
9751
+ }, AST: class extends t.AST {
9752
+ constructor(i, r, o = {}) {
9753
+ super(i, r, N(n2, o));
9754
+ }
9755
+ static fromGlob(i, r = {}) {
9756
+ return t.AST.fromGlob(i, N(n2, r));
9757
+ }
9758
+ }, 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 });
9759
+ };
9760
+ O.defaults = Zs;
9761
+ var ke = (n2, t = {}) => (at(n2), t.nobrace || !/\{(?:(?!\{).)*\}/.test(n2) ? [n2] : ge(n2, { max: t.braceExpandMax }));
9762
+ O.braceExpand = ke;
9763
+ var Qs = (n2, t = {}) => new D(n2, t).makeRe();
9764
+ O.makeRe = Qs;
9765
+ var ti = (n2, t, e = {}) => {
9766
+ let s = new D(t, e);
9767
+ return n2 = n2.filter((i) => s.match(i)), s.options.nonull && !n2.length && n2.push(t), n2;
9768
+ };
9769
+ O.match = ti;
9770
+ var ve = /[?*]|[+@!]\(.*?\)|\[|\]/;
9771
+ var ei = (n2) => n2.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
9772
+ var D = class {
9773
+ options;
9774
+ set;
9775
+ pattern;
9776
+ windowsPathsNoEscape;
9777
+ nonegate;
9778
+ negate;
9779
+ comment;
9780
+ empty;
9781
+ preserveMultipleSlashes;
9782
+ partial;
9783
+ globSet;
9784
+ globParts;
9785
+ nocase;
9786
+ isWindows;
9787
+ platform;
9788
+ windowsNoMagicRoot;
9789
+ regexp;
9790
+ constructor(t, e = {}) {
9791
+ at(t), e = e || {}, this.options = e, this.pattern = t, this.platform = e.platform || Ae, this.isWindows = this.platform === "win32";
9792
+ let s = "allowWindowsEscape";
9793
+ 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();
9794
+ }
9795
+ hasMagic() {
9796
+ if (this.options.magicalBraces && this.set.length > 1)
9797
+ return true;
9798
+ for (let t of this.set)
9799
+ for (let e of t)
9800
+ if (typeof e != "string")
9801
+ return true;
9802
+ return false;
9803
+ }
9804
+ debug(...t) {}
9805
+ make() {
9806
+ let t = this.pattern, e = this.options;
9807
+ if (!e.nocomment && t.charAt(0) === "#") {
9808
+ this.comment = true;
9809
+ return;
9810
+ }
9811
+ if (!t) {
9812
+ this.empty = true;
9813
+ return;
9814
+ }
9815
+ this.parseNegate(), this.globSet = [...new Set(this.braceExpand())], e.debug && (this.debug = (...r) => console.error(...r)), this.debug(this.pattern, this.globSet);
9816
+ let s = this.globSet.map((r) => this.slashSplit(r));
9817
+ this.globParts = this.preprocess(s), this.debug(this.pattern, this.globParts);
9818
+ let i = this.globParts.map((r, o, h) => {
9819
+ if (this.isWindows && this.windowsNoMagicRoot) {
9820
+ let a = r[0] === "" && r[1] === "" && (r[2] === "?" || !ve.test(r[2])) && !ve.test(r[3]), l = /^[a-z]:/i.test(r[0]);
9821
+ if (a)
9822
+ return [...r.slice(0, 4), ...r.slice(4).map((u) => this.parse(u))];
9823
+ if (l)
9824
+ return [r[0], ...r.slice(1).map((u) => this.parse(u))];
9825
+ }
9826
+ return r.map((a) => this.parse(a));
9827
+ });
9828
+ if (this.debug(this.pattern, i), this.set = i.filter((r) => r.indexOf(false) === -1), this.isWindows)
9829
+ for (let r = 0;r < this.set.length; r++) {
9830
+ let o = this.set[r];
9831
+ o[0] === "" && o[1] === "" && this.globParts[r][2] === "?" && typeof o[3] == "string" && /^[a-z]:$/i.test(o[3]) && (o[2] = "?");
9832
+ }
9833
+ this.debug(this.pattern, this.set);
9834
+ }
9835
+ preprocess(t) {
9836
+ if (this.options.noglobstar)
9837
+ for (let s = 0;s < t.length; s++)
9838
+ for (let i = 0;i < t[s].length; i++)
9839
+ t[s][i] === "**" && (t[s][i] = "*");
9840
+ let { optimizationLevel: e = 1 } = this.options;
9841
+ return e >= 2 ? (t = this.firstPhasePreProcess(t), t = this.secondPhasePreProcess(t)) : e >= 1 ? t = this.levelOneOptimize(t) : t = this.adjascentGlobstarOptimize(t), t;
9842
+ }
9843
+ adjascentGlobstarOptimize(t) {
9844
+ return t.map((e) => {
9845
+ let s = -1;
9846
+ for (;(s = e.indexOf("**", s + 1)) !== -1; ) {
9847
+ let i = s;
9848
+ for (;e[i + 1] === "**"; )
9849
+ i++;
9850
+ i !== s && e.splice(s, i - s);
9851
+ }
9852
+ return e;
9853
+ });
9854
+ }
9855
+ levelOneOptimize(t) {
9856
+ return t.map((e) => (e = e.reduce((s, i) => {
9857
+ let r = s[s.length - 1];
9858
+ return i === "**" && r === "**" ? s : i === ".." && r && r !== ".." && r !== "." && r !== "**" ? (s.pop(), s) : (s.push(i), s);
9859
+ }, []), e.length === 0 ? [""] : e));
9860
+ }
9861
+ levelTwoFileOptimize(t) {
9862
+ Array.isArray(t) || (t = this.slashSplit(t));
9863
+ let e = false;
9864
+ do {
9865
+ if (e = false, !this.preserveMultipleSlashes) {
9866
+ for (let i = 1;i < t.length - 1; i++) {
9867
+ let r = t[i];
9868
+ i === 1 && r === "" && t[0] === "" || (r === "." || r === "") && (e = true, t.splice(i, 1), i--);
9869
+ }
9870
+ t[0] === "." && t.length === 2 && (t[1] === "." || t[1] === "") && (e = true, t.pop());
9871
+ }
9872
+ let s = 0;
9873
+ for (;(s = t.indexOf("..", s + 1)) !== -1; ) {
9874
+ let i = t[s - 1];
9875
+ i && i !== "." && i !== ".." && i !== "**" && (e = true, t.splice(s - 1, 2), s -= 2);
9876
+ }
9877
+ } while (e);
9878
+ return t.length === 0 ? [""] : t;
9879
+ }
9880
+ firstPhasePreProcess(t) {
9881
+ let e = false;
9882
+ do {
9883
+ e = false;
9884
+ for (let s of t) {
9885
+ let i = -1;
9886
+ for (;(i = s.indexOf("**", i + 1)) !== -1; ) {
9887
+ let o = i;
9888
+ for (;s[o + 1] === "**"; )
9889
+ o++;
9890
+ o > i && s.splice(i + 1, o - i);
9891
+ let h = s[i + 1], a = s[i + 2], l = s[i + 3];
9892
+ if (h !== ".." || !a || a === "." || a === ".." || !l || l === "." || l === "..")
9893
+ continue;
9894
+ e = true, s.splice(i, 1);
9895
+ let u = s.slice(0);
9896
+ u[i] = "**", t.push(u), i--;
9897
+ }
9898
+ if (!this.preserveMultipleSlashes) {
9899
+ for (let o = 1;o < s.length - 1; o++) {
9900
+ let h = s[o];
9901
+ o === 1 && h === "" && s[0] === "" || (h === "." || h === "") && (e = true, s.splice(o, 1), o--);
9902
+ }
9903
+ s[0] === "." && s.length === 2 && (s[1] === "." || s[1] === "") && (e = true, s.pop());
9904
+ }
9905
+ let r = 0;
9906
+ for (;(r = s.indexOf("..", r + 1)) !== -1; ) {
9907
+ let o = s[r - 1];
9908
+ if (o && o !== "." && o !== ".." && o !== "**") {
9909
+ e = true;
9910
+ let a = r === 1 && s[r + 1] === "**" ? ["."] : [];
9911
+ s.splice(r - 1, 2, ...a), s.length === 0 && s.push(""), r -= 2;
9912
+ }
9913
+ }
9914
+ }
9915
+ } while (e);
9916
+ return t;
9917
+ }
9918
+ secondPhasePreProcess(t) {
9919
+ for (let e = 0;e < t.length - 1; e++)
9920
+ for (let s = e + 1;s < t.length; s++) {
9921
+ let i = this.partsMatch(t[e], t[s], !this.preserveMultipleSlashes);
9922
+ if (i) {
9923
+ t[e] = [], t[s] = i;
9924
+ break;
9925
+ }
9926
+ }
9927
+ return t.filter((e) => e.length);
9928
+ }
9929
+ partsMatch(t, e, s = false) {
9930
+ let i = 0, r = 0, o = [], h = "";
9931
+ for (;i < t.length && r < e.length; )
9932
+ if (t[i] === e[r])
9933
+ o.push(h === "b" ? e[r] : t[i]), i++, r++;
9934
+ else if (s && t[i] === "**" && e[r] === t[i + 1])
9935
+ o.push(t[i]), i++;
9936
+ else if (s && e[r] === "**" && t[i] === e[r + 1])
9937
+ o.push(e[r]), r++;
9938
+ else if (t[i] === "*" && e[r] && (this.options.dot || !e[r].startsWith(".")) && e[r] !== "**") {
9939
+ if (h === "b")
9940
+ return false;
9941
+ h = "a", o.push(t[i]), i++, r++;
9942
+ } else if (e[r] === "*" && t[i] && (this.options.dot || !t[i].startsWith(".")) && t[i] !== "**") {
9943
+ if (h === "a")
9944
+ return false;
9945
+ h = "b", o.push(e[r]), i++, r++;
9946
+ } else
9947
+ return false;
9948
+ return t.length === e.length && o;
9949
+ }
9950
+ parseNegate() {
9951
+ if (this.nonegate)
9952
+ return;
9953
+ let t = this.pattern, e = false, s = 0;
9954
+ for (let i = 0;i < t.length && t.charAt(i) === "!"; i++)
9955
+ e = !e, s++;
9956
+ s && (this.pattern = t.slice(s)), this.negate = e;
9957
+ }
9958
+ matchOne(t, e, s = false) {
9959
+ let i = this.options;
9960
+ if (this.isWindows) {
9961
+ 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;
9962
+ if (typeof E == "number" && typeof y == "number") {
9963
+ let [b, z] = [t[E], e[y]];
9964
+ b.toLowerCase() === z.toLowerCase() && (e[y] = b, y > E ? e = e.slice(y) : E > y && (t = t.slice(E)));
9965
+ }
9966
+ }
9967
+ let { optimizationLevel: r = 1 } = this.options;
9968
+ r >= 2 && (t = this.levelTwoFileOptimize(t)), this.debug("matchOne", this, { file: t, pattern: e }), this.debug("matchOne", t.length, e.length);
9969
+ for (var o = 0, h = 0, a = t.length, l = e.length;o < a && h < l; o++, h++) {
9970
+ this.debug("matchOne loop");
9971
+ var u = e[h], c = t[o];
9972
+ if (this.debug(e, u, c), u === false)
9973
+ return false;
9974
+ if (u === A) {
9975
+ this.debug("GLOBSTAR", [e, u, c]);
9976
+ var d = o, f = h + 1;
9977
+ if (f === l) {
9978
+ for (this.debug("** at the end");o < a; o++)
9979
+ if (t[o] === "." || t[o] === ".." || !i.dot && t[o].charAt(0) === ".")
9980
+ return false;
9981
+ return true;
9982
+ }
9983
+ for (;d < a; ) {
9984
+ var m = t[d];
9985
+ if (this.debug(`
9986
+ globstar while`, t, d, e, f, m), this.matchOne(t.slice(d), e.slice(f), s))
9987
+ return this.debug("globstar found match!", d, a, m), true;
9988
+ if (m === "." || m === ".." || !i.dot && m.charAt(0) === ".") {
9989
+ this.debug("dot detected!", t, d, e, f);
9990
+ break;
9991
+ }
9992
+ this.debug("globstar swallow a segment, and continue"), d++;
9993
+ }
9994
+ return !!(s && (this.debug(`
9995
+ >>> no match, partial?`, t, d, e, f), d === a));
9996
+ }
9997
+ let p;
9998
+ 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)
9999
+ return false;
10000
+ }
10001
+ if (o === a && h === l)
10002
+ return true;
10003
+ if (o === a)
10004
+ return s;
10005
+ if (h === l)
10006
+ return o === a - 1 && t[o] === "";
10007
+ throw new Error("wtf?");
10008
+ }
10009
+ braceExpand() {
10010
+ return ke(this.pattern, this.options);
10011
+ }
10012
+ parse(t) {
10013
+ at(t);
10014
+ let e = this.options;
10015
+ if (t === "**")
10016
+ return A;
10017
+ if (t === "")
10018
+ return "";
10019
+ let s, i = null;
10020
+ (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);
10021
+ let r = Q.fromGlob(t, this.options).toMMPattern();
10022
+ return i && typeof r == "object" && Reflect.defineProperty(r, "test", { value: i }), r;
10023
+ }
10024
+ makeRe() {
10025
+ if (this.regexp || this.regexp === false)
10026
+ return this.regexp;
10027
+ let t = this.set;
10028
+ if (!t.length)
10029
+ return this.regexp = false, this.regexp;
10030
+ let e = this.options, s = e.noglobstar ? Vs : e.dot ? Ys : Xs, i = new Set(e.nocase ? ["i"] : []), r = t.map((a) => {
10031
+ let l = a.map((c) => {
10032
+ if (c instanceof RegExp)
10033
+ for (let d of c.flags.split(""))
10034
+ i.add(d);
10035
+ return typeof c == "string" ? ei(c) : c === A ? A : c._src;
10036
+ });
10037
+ l.forEach((c, d) => {
10038
+ let f = l[d + 1], m = l[d - 1];
10039
+ 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));
10040
+ });
10041
+ let u = l.filter((c) => c !== A);
10042
+ if (this.partial && u.length >= 1) {
10043
+ let c = [];
10044
+ for (let d = 1;d <= u.length; d++)
10045
+ c.push(u.slice(0, d).join("/"));
10046
+ return "(?:" + c.join("|") + ")";
10047
+ }
10048
+ return u.join("/");
10049
+ }).join("|"), [o, h] = t.length > 1 ? ["(?:", ")"] : ["", ""];
10050
+ r = "^" + o + r + h + "$", this.partial && (r = "^(?:\\/|" + o + r.slice(1, -1) + h + ")$"), this.negate && (r = "^(?!" + r + ").+$");
10051
+ try {
10052
+ this.regexp = new RegExp(r, [...i].join(""));
10053
+ } catch {
10054
+ this.regexp = false;
10055
+ }
10056
+ return this.regexp;
10057
+ }
10058
+ slashSplit(t) {
10059
+ return this.preserveMultipleSlashes ? t.split("/") : this.isWindows && /^\/\/[^\/]+/.test(t) ? ["", ...t.split(/\/+/)] : t.split(/\/+/);
10060
+ }
10061
+ match(t, e = this.partial) {
10062
+ if (this.debug("match", t, this.pattern), this.comment)
10063
+ return false;
10064
+ if (this.empty)
10065
+ return t === "";
10066
+ if (t === "/" && e)
10067
+ return true;
10068
+ let s = this.options;
10069
+ this.isWindows && (t = t.split("\\").join("/"));
10070
+ let i = this.slashSplit(t);
10071
+ this.debug(this.pattern, "split", i);
10072
+ let r = this.set;
10073
+ this.debug(this.pattern, "set", r);
10074
+ let o = i[i.length - 1];
10075
+ if (!o)
10076
+ for (let h = i.length - 2;!o && h >= 0; h--)
10077
+ o = i[h];
10078
+ for (let h = 0;h < r.length; h++) {
10079
+ let a = r[h], l = i;
10080
+ if (s.matchBase && a.length === 1 && (l = [o]), this.matchOne(l, a, e))
10081
+ return s.flipNegate ? true : !this.negate;
10082
+ }
10083
+ return s.flipNegate ? false : this.negate;
10084
+ }
10085
+ static defaults(t) {
10086
+ return O.defaults(t).Minimatch;
10087
+ }
10088
+ };
10089
+ O.AST = Q;
10090
+ O.Minimatch = D;
10091
+ O.escape = tt;
10092
+ O.unescape = W;
10093
+ var si = typeof performance == "object" && performance && typeof performance.now == "function" ? performance : Date;
10094
+ var Oe = new Set;
10095
+ var Vt = typeof process == "object" && process ? process : {};
10096
+ var Fe = (n2, t, e, s) => {
10097
+ typeof Vt.emitWarning == "function" ? Vt.emitWarning(n2, t, e, s) : console.error(`[${e}] ${t}: ${n2}`);
10098
+ };
10099
+ var At = globalThis.AbortController;
10100
+ var Re = globalThis.AbortSignal;
10101
+ if (typeof At > "u") {
10102
+ Re = class {
10103
+ onabort;
10104
+ _onabort = [];
10105
+ reason;
10106
+ aborted = false;
10107
+ addEventListener(e, s) {
10108
+ this._onabort.push(s);
10109
+ }
10110
+ }, At = class {
10111
+ constructor() {
10112
+ t();
10113
+ }
10114
+ signal = new Re;
10115
+ abort(e) {
10116
+ if (!this.signal.aborted) {
10117
+ this.signal.reason = e, this.signal.aborted = true;
10118
+ for (let s of this.signal._onabort)
10119
+ s(e);
10120
+ this.signal.onabort?.(e);
10121
+ }
10122
+ }
10123
+ };
10124
+ let n2 = Vt.env?.LRU_CACHE_IGNORE_AC_WARNING !== "1", t = () => {
10125
+ 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));
10126
+ };
10127
+ }
10128
+ var ii = (n2) => !Oe.has(n2);
10129
+ var q = (n2) => n2 && n2 === Math.floor(n2) && n2 > 0 && isFinite(n2);
10130
+ 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;
10131
+ var Tt = class extends Array {
10132
+ constructor(n2) {
10133
+ super(n2), this.fill(0);
10134
+ }
10135
+ };
10136
+ var ri = class ct {
10137
+ heap;
10138
+ length;
10139
+ static #t = false;
10140
+ static create(t) {
10141
+ let e = De(t);
10142
+ if (!e)
10143
+ return [];
10144
+ ct.#t = true;
10145
+ let s = new ct(t, e);
10146
+ return ct.#t = false, s;
10147
+ }
10148
+ constructor(t, e) {
10149
+ if (!ct.#t)
10150
+ throw new TypeError("instantiate Stack using Stack.create(n)");
10151
+ this.heap = new e(t), this.length = 0;
10152
+ }
10153
+ push(t) {
10154
+ this.heap[this.length++] = t;
10155
+ }
10156
+ pop() {
10157
+ return this.heap[--this.length];
10158
+ }
10159
+ };
10160
+ var ft = class Me {
10161
+ #t;
10162
+ #s;
10163
+ #n;
10164
+ #r;
10165
+ #o;
10166
+ #S;
10167
+ #w;
10168
+ #c;
10169
+ get perf() {
10170
+ return this.#c;
10171
+ }
10172
+ ttl;
10173
+ ttlResolution;
10174
+ ttlAutopurge;
10175
+ updateAgeOnGet;
10176
+ updateAgeOnHas;
10177
+ allowStale;
10178
+ noDisposeOnSet;
10179
+ noUpdateTTL;
10180
+ maxEntrySize;
10181
+ sizeCalculation;
10182
+ noDeleteOnFetchRejection;
10183
+ noDeleteOnStaleGet;
10184
+ allowStaleOnFetchAbort;
10185
+ allowStaleOnFetchRejection;
10186
+ ignoreFetchAbort;
10187
+ #h;
10188
+ #u;
10189
+ #f;
10190
+ #a;
10191
+ #i;
10192
+ #d;
10193
+ #E;
10194
+ #b;
10195
+ #p;
10196
+ #R;
10197
+ #m;
10198
+ #C;
10199
+ #T;
10200
+ #g;
10201
+ #y;
10202
+ #x;
10203
+ #A;
10204
+ #e;
10205
+ #_;
10206
+ static unsafeExposeInternals(t) {
10207
+ 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() {
10208
+ return t.#b;
10209
+ }, get tail() {
10210
+ return t.#p;
10211
+ }, 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) };
10212
+ }
10213
+ get max() {
10214
+ return this.#t;
10215
+ }
10216
+ get maxSize() {
10217
+ return this.#s;
10218
+ }
10219
+ get calculatedSize() {
10220
+ return this.#u;
10221
+ }
10222
+ get size() {
10223
+ return this.#h;
10224
+ }
10225
+ get fetchMethod() {
10226
+ return this.#S;
10227
+ }
10228
+ get memoMethod() {
10229
+ return this.#w;
10230
+ }
10231
+ get dispose() {
10232
+ return this.#n;
10233
+ }
10234
+ get onInsert() {
10235
+ return this.#r;
10236
+ }
10237
+ get disposeAfter() {
10238
+ return this.#o;
10239
+ }
10240
+ constructor(t) {
10241
+ 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;
10242
+ if (J !== undefined && typeof J?.now != "function")
10243
+ throw new TypeError("perf option must have a now() method if specified");
10244
+ if (this.#c = J ?? si, e !== 0 && !q(e))
10245
+ throw new TypeError("max option must be a nonnegative integer");
10246
+ let Z = e ? De(e) : Array;
10247
+ if (!Z)
10248
+ throw new Error("invalid max value: " + e);
10249
+ if (this.#t = e, this.#s = m, this.maxEntrySize = p || this.#s, this.sizeCalculation = w, this.sizeCalculation) {
10250
+ if (!this.#s && !this.maxEntrySize)
10251
+ throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");
10252
+ if (typeof this.sizeCalculation != "function")
10253
+ throw new TypeError("sizeCalculation set to non-function");
10254
+ }
10255
+ if (S !== undefined && typeof S != "function")
10256
+ throw new TypeError("memoMethod must be a function if defined");
10257
+ if (this.#w = S, g !== undefined && typeof g != "function")
10258
+ throw new TypeError("fetchMethod must be a function if specified");
10259
+ 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) {
10260
+ if (this.#s !== 0 && !q(this.#s))
10261
+ throw new TypeError("maxSize must be a positive integer if specified");
10262
+ if (!q(this.maxEntrySize))
10263
+ throw new TypeError("maxEntrySize must be a positive integer if specified");
10264
+ this.#G();
10265
+ }
10266
+ 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) {
10267
+ if (!q(this.ttl))
10268
+ throw new TypeError("ttl must be a positive integer if specified");
10269
+ this.#M();
10270
+ }
10271
+ if (this.#t === 0 && this.ttl === 0 && this.#s === 0)
10272
+ throw new TypeError("At least one of max, maxSize, or ttl is required");
10273
+ if (!this.ttlAutopurge && !this.#t && !this.#s) {
10274
+ let $t = "LRU_CACHE_UNBOUNDED";
10275
+ ii($t) && (Oe.add($t), Fe("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.", "UnboundedCacheWarning", $t, Me));
10276
+ }
10277
+ }
10278
+ getRemainingTTL(t) {
10279
+ return this.#f.has(t) ? 1 / 0 : 0;
10280
+ }
10281
+ #M() {
10282
+ let t = new Tt(this.#t), e = new Tt(this.#t);
10283
+ this.#g = t, this.#T = e;
10284
+ let s = this.ttlAutopurge ? new Array(this.#t) : undefined;
10285
+ this.#y = s, this.#j = (o, h, a = this.#c.now()) => {
10286
+ if (e[o] = h !== 0 ? a : 0, t[o] = h, s?.[o] && (clearTimeout(s[o]), s[o] = undefined), h !== 0 && s) {
10287
+ let l = setTimeout(() => {
10288
+ this.#v(o) && this.#O(this.#a[o], "expire");
10289
+ }, h + 1);
10290
+ l.unref && l.unref(), s[o] = l;
10291
+ }
10292
+ }, this.#k = (o) => {
10293
+ e[o] = t[o] !== 0 ? this.#c.now() : 0;
10294
+ }, this.#N = (o, h) => {
10295
+ if (t[h]) {
10296
+ let a = t[h], l = e[h];
10297
+ if (!a || !l)
10298
+ return;
10299
+ o.ttl = a, o.start = l, o.now = i || r();
10300
+ let u = o.now - l;
10301
+ o.remainingTTL = a - u;
10302
+ }
10303
+ };
10304
+ let i = 0, r = () => {
10305
+ let o = this.#c.now();
10306
+ if (this.ttlResolution > 0) {
10307
+ i = o;
10308
+ let h = setTimeout(() => i = 0, this.ttlResolution);
10309
+ h.unref && h.unref();
10310
+ }
10311
+ return o;
10312
+ };
10313
+ this.getRemainingTTL = (o) => {
10314
+ let h = this.#f.get(o);
10315
+ if (h === undefined)
10316
+ return 0;
10317
+ let a = t[h], l = e[h];
10318
+ if (!a || !l)
10319
+ return 1 / 0;
10320
+ let u = (i || r()) - l;
10321
+ return a - u;
10322
+ }, this.#v = (o) => {
10323
+ let h = e[o], a = t[o];
10324
+ return !!a && !!h && (i || r()) - h > a;
10325
+ };
10326
+ }
10327
+ #k = () => {};
10328
+ #N = () => {};
10329
+ #j = () => {};
10330
+ #v = () => false;
10331
+ #G() {
10332
+ let t = new Tt(this.#t);
10333
+ this.#u = 0, this.#C = t, this.#P = (e) => {
10334
+ this.#u -= t[e], t[e] = 0;
10335
+ }, this.#I = (e, s, i, r) => {
10336
+ if (this.#l(s))
10337
+ return 0;
10338
+ if (!q(i))
10339
+ if (r) {
10340
+ if (typeof r != "function")
10341
+ throw new TypeError("sizeCalculation must be a function");
10342
+ if (i = r(s, e), !q(i))
10343
+ throw new TypeError("sizeCalculation return invalid (expect positive integer)");
10344
+ } else
10345
+ throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");
10346
+ return i;
10347
+ }, this.#L = (e, s, i) => {
10348
+ if (t[e] = s, this.#s) {
10349
+ let r = this.#s - t[e];
10350
+ for (;this.#u > r; )
10351
+ this.#B(true);
10352
+ }
10353
+ this.#u += t[e], i && (i.entrySize = s, i.totalCalculatedSize = this.#u);
10354
+ };
10355
+ }
10356
+ #P = (t) => {};
10357
+ #L = (t, e, s) => {};
10358
+ #I = (t, e, s, i) => {
10359
+ if (s || i)
10360
+ throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");
10361
+ return 0;
10362
+ };
10363
+ *#F({ allowStale: t = this.allowStale } = {}) {
10364
+ if (this.#h)
10365
+ for (let e = this.#p;!(!this.#z(e) || ((t || !this.#v(e)) && (yield e), e === this.#b)); )
10366
+ e = this.#E[e];
10367
+ }
10368
+ *#D({ allowStale: t = this.allowStale } = {}) {
10369
+ if (this.#h)
10370
+ for (let e = this.#b;!(!this.#z(e) || ((t || !this.#v(e)) && (yield e), e === this.#p)); )
10371
+ e = this.#d[e];
10372
+ }
10373
+ #z(t) {
10374
+ return t !== undefined && this.#f.get(this.#a[t]) === t;
10375
+ }
10376
+ *entries() {
10377
+ for (let t of this.#F())
10378
+ this.#i[t] !== undefined && this.#a[t] !== undefined && !this.#l(this.#i[t]) && (yield [this.#a[t], this.#i[t]]);
10379
+ }
10380
+ *rentries() {
10381
+ for (let t of this.#D())
10382
+ this.#i[t] !== undefined && this.#a[t] !== undefined && !this.#l(this.#i[t]) && (yield [this.#a[t], this.#i[t]]);
10383
+ }
10384
+ *keys() {
10385
+ for (let t of this.#F()) {
10386
+ let e = this.#a[t];
10387
+ e !== undefined && !this.#l(this.#i[t]) && (yield e);
10388
+ }
10389
+ }
10390
+ *rkeys() {
10391
+ for (let t of this.#D()) {
10392
+ let e = this.#a[t];
10393
+ e !== undefined && !this.#l(this.#i[t]) && (yield e);
10394
+ }
10395
+ }
10396
+ *values() {
10397
+ for (let t of this.#F())
10398
+ this.#i[t] !== undefined && !this.#l(this.#i[t]) && (yield this.#i[t]);
10399
+ }
10400
+ *rvalues() {
10401
+ for (let t of this.#D())
10402
+ this.#i[t] !== undefined && !this.#l(this.#i[t]) && (yield this.#i[t]);
10403
+ }
10404
+ [Symbol.iterator]() {
10405
+ return this.entries();
10406
+ }
10407
+ [Symbol.toStringTag] = "LRUCache";
10408
+ find(t, e = {}) {
10409
+ for (let s of this.#F()) {
10410
+ let i = this.#i[s], r = this.#l(i) ? i.__staleWhileFetching : i;
10411
+ if (r !== undefined && t(r, this.#a[s], this))
10412
+ return this.get(this.#a[s], e);
10413
+ }
10414
+ }
10415
+ forEach(t, e = this) {
10416
+ for (let s of this.#F()) {
10417
+ let i = this.#i[s], r = this.#l(i) ? i.__staleWhileFetching : i;
10418
+ r !== undefined && t.call(e, r, this.#a[s], this);
10419
+ }
10420
+ }
10421
+ rforEach(t, e = this) {
10422
+ for (let s of this.#D()) {
10423
+ let i = this.#i[s], r = this.#l(i) ? i.__staleWhileFetching : i;
10424
+ r !== undefined && t.call(e, r, this.#a[s], this);
10425
+ }
10426
+ }
10427
+ purgeStale() {
10428
+ let t = false;
10429
+ for (let e of this.#D({ allowStale: true }))
10430
+ this.#v(e) && (this.#O(this.#a[e], "expire"), t = true);
10431
+ return t;
10432
+ }
10433
+ info(t) {
10434
+ let e = this.#f.get(t);
10435
+ if (e === undefined)
10436
+ return;
10437
+ let s = this.#i[e], i = this.#l(s) ? s.__staleWhileFetching : s;
10438
+ if (i === undefined)
10439
+ return;
10440
+ let r = { value: i };
10441
+ if (this.#g && this.#T) {
10442
+ let o = this.#g[e], h = this.#T[e];
10443
+ if (o && h) {
10444
+ let a = o - (this.#c.now() - h);
10445
+ r.ttl = a, r.start = Date.now();
10446
+ }
10447
+ }
10448
+ return this.#C && (r.size = this.#C[e]), r;
10449
+ }
10450
+ dump() {
10451
+ let t = [];
10452
+ for (let e of this.#F({ allowStale: true })) {
10453
+ let s = this.#a[e], i = this.#i[e], r = this.#l(i) ? i.__staleWhileFetching : i;
10454
+ if (r === undefined || s === undefined)
10455
+ continue;
10456
+ let o = { value: r };
10457
+ if (this.#g && this.#T) {
10458
+ o.ttl = this.#g[e];
10459
+ let h = this.#c.now() - this.#T[e];
10460
+ o.start = Math.floor(Date.now() - h);
10461
+ }
10462
+ this.#C && (o.size = this.#C[e]), t.unshift([s, o]);
10463
+ }
10464
+ return t;
10465
+ }
10466
+ load(t) {
10467
+ this.clear();
10468
+ for (let [e, s] of t) {
10469
+ if (s.start) {
10470
+ let i = Date.now() - s.start;
10471
+ s.start = this.#c.now() - i;
10472
+ }
10473
+ this.set(e, s.value, s);
10474
+ }
10475
+ }
10476
+ set(t, e, s = {}) {
10477
+ if (e === undefined)
10478
+ return this.delete(t), this;
10479
+ 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);
10480
+ if (this.maxEntrySize && u > this.maxEntrySize)
10481
+ return a && (a.set = "miss", a.maxEntrySizeExceeded = true), this.#O(t, "set"), this;
10482
+ let c = this.#h === 0 ? undefined : this.#f.get(t);
10483
+ if (c === undefined)
10484
+ 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");
10485
+ else {
10486
+ this.#W(c);
10487
+ let d = this.#i[c];
10488
+ if (e !== d) {
10489
+ if (this.#A && this.#l(d)) {
10490
+ d.__abortController.abort(new Error("replaced"));
10491
+ let { __staleWhileFetching: f } = d;
10492
+ f !== undefined && !o && (this.#x && this.#n?.(f, t, "set"), this.#e && this.#m?.push([f, t, "set"]));
10493
+ } else
10494
+ o || (this.#x && this.#n?.(d, t, "set"), this.#e && this.#m?.push([d, t, "set"]));
10495
+ if (this.#P(c), this.#L(c, u, a), this.#i[c] = e, a) {
10496
+ a.set = "replace";
10497
+ let f = d && this.#l(d) ? d.__staleWhileFetching : d;
10498
+ f !== undefined && (a.oldValue = f);
10499
+ }
10500
+ } else
10501
+ a && (a.set = "update");
10502
+ this.#_ && this.onInsert?.(e, t, e === d ? "update" : "replace");
10503
+ }
10504
+ 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) {
10505
+ let d = this.#m, f;
10506
+ for (;f = d?.shift(); )
10507
+ this.#o?.(...f);
10508
+ }
10509
+ return this;
10510
+ }
10511
+ pop() {
10512
+ try {
10513
+ for (;this.#h; ) {
10514
+ let t = this.#i[this.#b];
10515
+ if (this.#B(true), this.#l(t)) {
10516
+ if (t.__staleWhileFetching)
10517
+ return t.__staleWhileFetching;
10518
+ } else if (t !== undefined)
10519
+ return t;
10520
+ }
10521
+ } finally {
10522
+ if (this.#e && this.#m) {
10523
+ let t = this.#m, e;
10524
+ for (;e = t?.shift(); )
10525
+ this.#o?.(...e);
10526
+ }
10527
+ }
10528
+ }
10529
+ #B(t) {
10530
+ let e = this.#b, s = this.#a[e], i = this.#i[e];
10531
+ 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;
10532
+ }
10533
+ has(t, e = {}) {
10534
+ let { updateAgeOnHas: s = this.updateAgeOnHas, status: i } = e, r = this.#f.get(t);
10535
+ if (r !== undefined) {
10536
+ let o = this.#i[r];
10537
+ if (this.#l(o) && o.__staleWhileFetching === undefined)
10538
+ return false;
10539
+ if (this.#v(r))
10540
+ i && (i.has = "stale", this.#N(i, r));
10541
+ else
10542
+ return s && this.#k(r), i && (i.has = "hit", this.#N(i, r)), true;
10543
+ } else
10544
+ i && (i.has = "miss");
10545
+ return false;
10546
+ }
10547
+ peek(t, e = {}) {
10548
+ let { allowStale: s = this.allowStale } = e, i = this.#f.get(t);
10549
+ if (i === undefined || !s && this.#v(i))
10550
+ return;
10551
+ let r = this.#i[i];
10552
+ return this.#l(r) ? r.__staleWhileFetching : r;
10553
+ }
10554
+ #U(t, e, s, i) {
10555
+ let r = e === undefined ? undefined : this.#i[e];
10556
+ if (this.#l(r))
10557
+ return r;
10558
+ let o = new At, { signal: h } = s;
10559
+ h?.addEventListener("abort", () => o.abort(h.reason), { signal: o.signal });
10560
+ let a = { signal: o.signal, options: s, context: i }, l = (p, w = false) => {
10561
+ let { aborted: g } = o.signal, S = s.ignoreFetchAbort && p !== undefined, E = s.ignoreFetchAbort || !!(s.allowStaleOnFetchAbort && p !== undefined);
10562
+ 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)
10563
+ return c(o.signal.reason, E);
10564
+ let y = f, b = this.#i[e];
10565
+ 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;
10566
+ }, u = (p) => (s.status && (s.status.fetchRejected = true, s.status.fetchError = p), c(p, false)), c = (p, w) => {
10567
+ let { aborted: g } = o.signal, S = g && s.allowStaleOnFetchAbort, E = S || s.allowStaleOnFetchRejection, y = E || s.noDeleteOnFetchRejection, b = f;
10568
+ if (this.#i[e] === f && (!y || !w && b.__staleWhileFetching === undefined ? this.#O(t, "fetch") : S || (this.#i[e] = b.__staleWhileFetching)), E)
10569
+ return s.status && b.__staleWhileFetching !== undefined && (s.status.returnedStale = true), b.__staleWhileFetching;
10570
+ if (b.__returned === b)
10571
+ throw p;
10572
+ }, d = (p, w) => {
10573
+ let g = this.#S?.(t, r, a);
10574
+ g && g instanceof Promise && g.then((S) => p(S === undefined ? undefined : S), w), o.signal.addEventListener("abort", () => {
10575
+ (!s.ignoreFetchAbort || s.allowStaleOnFetchAbort) && (p(undefined), s.allowStaleOnFetchAbort && (p = (S) => l(S, true)));
10576
+ });
10577
+ };
10578
+ s.status && (s.status.fetchDispatched = true);
10579
+ let f = new Promise(d).then(l, u), m = Object.assign(f, { __abortController: o, __staleWhileFetching: r, __returned: undefined });
10580
+ return e === undefined ? (this.set(t, m, { ...a.options, status: undefined }), e = this.#f.get(t)) : this.#i[e] = m, m;
10581
+ }
10582
+ #l(t) {
10583
+ if (!this.#A)
10584
+ return false;
10585
+ let e = t;
10586
+ return !!e && e instanceof Promise && e.hasOwnProperty("__staleWhileFetching") && e.__abortController instanceof At;
10587
+ }
10588
+ async fetch(t, e = {}) {
10589
+ 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;
10590
+ if (!this.#A)
10591
+ return g && (g.fetch = "get"), this.get(t, { allowStale: s, updateAgeOnGet: i, noDeleteOnStaleGet: r, status: g });
10592
+ 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);
10593
+ if (y === undefined) {
10594
+ g && (g.fetch = "miss");
10595
+ let b = this.#U(t, y, E, p);
10596
+ return b.__returned = b;
10597
+ } else {
10598
+ let b = this.#i[y];
10599
+ if (this.#l(b)) {
10600
+ let Z = s && b.__staleWhileFetching !== undefined;
10601
+ return g && (g.fetch = "inflight", Z && (g.returnedStale = true)), Z ? b.__staleWhileFetching : b.__returned = b;
10602
+ }
10603
+ let z = this.#v(y);
10604
+ if (!w && !z)
10605
+ return g && (g.fetch = "hit"), this.#W(y), i && this.#k(y), g && this.#N(g, y), b;
10606
+ let $ = this.#U(t, y, E, p), J = $.__staleWhileFetching !== undefined && s;
10607
+ return g && (g.fetch = z ? "stale" : "refresh", J && z && (g.returnedStale = true)), J ? $.__staleWhileFetching : $.__returned = $;
10608
+ }
10609
+ }
10610
+ async forceFetch(t, e = {}) {
10611
+ let s = await this.fetch(t, e);
10612
+ if (s === undefined)
10613
+ throw new Error("fetch() returned undefined");
10614
+ return s;
10615
+ }
10616
+ memo(t, e = {}) {
10617
+ let s = this.#w;
10618
+ if (!s)
10619
+ throw new Error("no memoMethod provided to constructor");
10620
+ let { context: i, forceRefresh: r, ...o } = e, h = this.get(t, o);
10621
+ if (!r && h !== undefined)
10622
+ return h;
10623
+ let a = s(t, h, { options: o, context: i });
10624
+ return this.set(t, a, o), a;
10625
+ }
10626
+ get(t, e = {}) {
10627
+ let { allowStale: s = this.allowStale, updateAgeOnGet: i = this.updateAgeOnGet, noDeleteOnStaleGet: r = this.noDeleteOnStaleGet, status: o } = e, h = this.#f.get(t);
10628
+ if (h !== undefined) {
10629
+ let a = this.#i[h], l = this.#l(a);
10630
+ 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));
10631
+ } else
10632
+ o && (o.get = "miss");
10633
+ }
10634
+ #$(t, e) {
10635
+ this.#E[e] = t, this.#d[t] = e;
10636
+ }
10637
+ #W(t) {
10638
+ 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);
10639
+ }
10640
+ delete(t) {
10641
+ return this.#O(t, "delete");
10642
+ }
10643
+ #O(t, e) {
10644
+ let s = false;
10645
+ if (this.#h !== 0) {
10646
+ let i = this.#f.get(t);
10647
+ if (i !== undefined)
10648
+ if (this.#y?.[i] && (clearTimeout(this.#y?.[i]), this.#y[i] = undefined), s = true, this.#h === 1)
10649
+ this.#H(e);
10650
+ else {
10651
+ this.#P(i);
10652
+ let r = this.#i[i];
10653
+ 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)
10654
+ this.#p = this.#E[i];
10655
+ else if (i === this.#b)
10656
+ this.#b = this.#d[i];
10657
+ else {
10658
+ let o = this.#E[i];
10659
+ this.#d[o] = this.#d[i];
10660
+ let h = this.#d[i];
10661
+ this.#E[h] = this.#E[i];
10662
+ }
10663
+ this.#h--, this.#R.push(i);
10664
+ }
10665
+ }
10666
+ if (this.#e && this.#m?.length) {
10667
+ let i = this.#m, r;
10668
+ for (;r = i?.shift(); )
10669
+ this.#o?.(...r);
10670
+ }
10671
+ return s;
10672
+ }
10673
+ clear() {
10674
+ return this.#H("delete");
10675
+ }
10676
+ #H(t) {
10677
+ for (let e of this.#D({ allowStale: true })) {
10678
+ let s = this.#i[e];
10679
+ if (this.#l(s))
10680
+ s.__abortController.abort(new Error("deleted"));
10681
+ else {
10682
+ let i = this.#a[e];
10683
+ this.#x && this.#n?.(s, i, t), this.#e && this.#m?.push([s, i, t]);
10684
+ }
10685
+ }
10686
+ if (this.#f.clear(), this.#i.fill(undefined), this.#a.fill(undefined), this.#g && this.#T) {
10687
+ this.#g.fill(0), this.#T.fill(0);
10688
+ for (let e of this.#y ?? [])
10689
+ e !== undefined && clearTimeout(e);
10690
+ this.#y?.fill(undefined);
10691
+ }
10692
+ 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) {
10693
+ let e = this.#m, s;
10694
+ for (;s = e?.shift(); )
10695
+ this.#o?.(...s);
10696
+ }
10697
+ }
10698
+ };
10699
+ var Ne = typeof process == "object" && process ? process : { stdout: null, stderr: null };
10700
+ var oi = (n2) => !!n2 && typeof n2 == "object" && (n2 instanceof V || n2 instanceof Pe || hi(n2) || ai(n2));
10701
+ var hi = (n2) => !!n2 && typeof n2 == "object" && n2 instanceof ee && typeof n2.pipe == "function" && n2.pipe !== Pe.Writable.prototype.pipe;
10702
+ var ai = (n2) => !!n2 && typeof n2 == "object" && n2 instanceof ee && typeof n2.write == "function" && typeof n2.end == "function";
10703
+ var G = Symbol("EOF");
10704
+ var H = Symbol("maybeEmitEnd");
10705
+ var K = Symbol("emittedEnd");
10706
+ var kt = Symbol("emittingEnd");
10707
+ var ut = Symbol("emittedError");
10708
+ var Rt = Symbol("closed");
10709
+ var _e = Symbol("read");
10710
+ var Ot = Symbol("flush");
10711
+ var Le = Symbol("flushChunk");
10712
+ var P = Symbol("encoding");
10713
+ var et = Symbol("decoder");
10714
+ var v = Symbol("flowing");
10715
+ var dt = Symbol("paused");
10716
+ var st = Symbol("resume");
10717
+ var C = Symbol("buffer");
10718
+ var F = Symbol("pipes");
10719
+ var T = Symbol("bufferLength");
10720
+ var Yt = Symbol("bufferPush");
10721
+ var Ft = Symbol("bufferShift");
10722
+ var k = Symbol("objectMode");
10723
+ var x = Symbol("destroyed");
10724
+ var Xt = Symbol("error");
10725
+ var Jt = Symbol("emitData");
10726
+ var We = Symbol("emitEnd");
10727
+ var Zt = Symbol("emitEnd2");
10728
+ var B = Symbol("async");
10729
+ var Qt = Symbol("abort");
10730
+ var Dt = Symbol("aborted");
10731
+ var pt = Symbol("signal");
10732
+ var Y = Symbol("dataListeners");
10733
+ var M = Symbol("discarded");
10734
+ var mt = (n2) => Promise.resolve().then(n2);
10735
+ var li = (n2) => n2();
10736
+ var ci = (n2) => n2 === "end" || n2 === "finish" || n2 === "prefinish";
10737
+ var fi = (n2) => n2 instanceof ArrayBuffer || !!n2 && typeof n2 == "object" && n2.constructor && n2.constructor.name === "ArrayBuffer" && n2.byteLength >= 0;
10738
+ var ui = (n2) => !Buffer.isBuffer(n2) && ArrayBuffer.isView(n2);
10739
+ var Mt = class {
10740
+ src;
10741
+ dest;
10742
+ opts;
10743
+ ondrain;
10744
+ constructor(t, e, s) {
10745
+ this.src = t, this.dest = e, this.opts = s, this.ondrain = () => t[st](), this.dest.on("drain", this.ondrain);
10746
+ }
10747
+ unpipe() {
10748
+ this.dest.removeListener("drain", this.ondrain);
10749
+ }
10750
+ proxyErrors(t) {}
10751
+ end() {
10752
+ this.unpipe(), this.opts.end && this.dest.end();
10753
+ }
10754
+ };
10755
+ var te = class extends Mt {
10756
+ unpipe() {
10757
+ this.src.removeListener("error", this.proxyErrors), super.unpipe();
10758
+ }
10759
+ constructor(t, e, s) {
10760
+ super(t, e, s), this.proxyErrors = (i) => this.dest.emit("error", i), t.on("error", this.proxyErrors);
10761
+ }
10762
+ };
10763
+ var di = (n2) => !!n2.objectMode;
10764
+ var pi = (n2) => !n2.objectMode && !!n2.encoding && n2.encoding !== "buffer";
10765
+ var V = class extends ee {
10766
+ [v] = false;
10767
+ [dt] = false;
10768
+ [F] = [];
10769
+ [C] = [];
10770
+ [k];
10771
+ [P];
10772
+ [B];
10773
+ [et];
10774
+ [G] = false;
10775
+ [K] = false;
10776
+ [kt] = false;
10777
+ [Rt] = false;
10778
+ [ut] = null;
10779
+ [T] = 0;
10780
+ [x] = false;
10781
+ [pt];
10782
+ [Dt] = false;
10783
+ [Y] = 0;
10784
+ [M] = false;
10785
+ writable = true;
10786
+ readable = true;
10787
+ constructor(...t) {
10788
+ let e = t[0] || {};
10789
+ if (super(), e.objectMode && typeof e.encoding == "string")
10790
+ throw new TypeError("Encoding and objectMode may not be used together");
10791
+ 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] });
10792
+ let { signal: s } = e;
10793
+ s && (this[pt] = s, s.aborted ? this[Qt]() : s.addEventListener("abort", () => this[Qt]()));
10794
+ }
10795
+ get bufferLength() {
10796
+ return this[T];
10797
+ }
10798
+ get encoding() {
10799
+ return this[P];
10800
+ }
10801
+ set encoding(t) {
10802
+ throw new Error("Encoding must be set at instantiation time");
10803
+ }
10804
+ setEncoding(t) {
10805
+ throw new Error("Encoding must be set at instantiation time");
10806
+ }
10807
+ get objectMode() {
10808
+ return this[k];
10809
+ }
10810
+ set objectMode(t) {
10811
+ throw new Error("objectMode must be set at instantiation time");
10812
+ }
10813
+ get async() {
10814
+ return this[B];
10815
+ }
10816
+ set async(t) {
10817
+ this[B] = this[B] || !!t;
10818
+ }
10819
+ [Qt]() {
10820
+ this[Dt] = true, this.emit("abort", this[pt]?.reason), this.destroy(this[pt]?.reason);
10821
+ }
10822
+ get aborted() {
10823
+ return this[Dt];
10824
+ }
10825
+ set aborted(t) {}
10826
+ write(t, e, s) {
10827
+ if (this[Dt])
10828
+ return false;
10829
+ if (this[G])
10830
+ throw new Error("write after end");
10831
+ if (this[x])
10832
+ return this.emit("error", Object.assign(new Error("Cannot call write after a stream was destroyed"), { code: "ERR_STREAM_DESTROYED" })), true;
10833
+ typeof e == "function" && (s = e, e = "utf8"), e || (e = "utf8");
10834
+ let i = this[B] ? mt : li;
10835
+ if (!this[k] && !Buffer.isBuffer(t)) {
10836
+ if (ui(t))
10837
+ t = Buffer.from(t.buffer, t.byteOffset, t.byteLength);
10838
+ else if (fi(t))
10839
+ t = Buffer.from(t);
10840
+ else if (typeof t != "string")
10841
+ throw new Error("Non-contiguous data written to non-objectMode stream");
10842
+ }
10843
+ 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]);
10844
+ }
10845
+ read(t) {
10846
+ if (this[x])
10847
+ return null;
10848
+ if (this[M] = false, this[T] === 0 || t === 0 || t && t > this[T])
10849
+ return this[H](), null;
10850
+ this[k] && (t = null), this[C].length > 1 && !this[k] && (this[C] = [this[P] ? this[C].join("") : Buffer.concat(this[C], this[T])]);
10851
+ let e = this[_e](t || null, this[C][0]);
10852
+ return this[H](), e;
10853
+ }
10854
+ [_e](t, e) {
10855
+ if (this[k])
10856
+ this[Ft]();
10857
+ else {
10858
+ let s = e;
10859
+ 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);
10860
+ }
10861
+ return this.emit("data", e), !this[C].length && !this[G] && this.emit("drain"), e;
10862
+ }
10863
+ end(t, e, s) {
10864
+ 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;
10865
+ }
10866
+ [st]() {
10867
+ 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"));
10868
+ }
10869
+ resume() {
10870
+ return this[st]();
10871
+ }
10872
+ pause() {
10873
+ this[v] = false, this[dt] = true, this[M] = false;
10874
+ }
10875
+ get destroyed() {
10876
+ return this[x];
10877
+ }
10878
+ get flowing() {
10879
+ return this[v];
10880
+ }
10881
+ get paused() {
10882
+ return this[dt];
10883
+ }
10884
+ [Yt](t) {
10885
+ this[k] ? this[T] += 1 : this[T] += t.length, this[C].push(t);
10886
+ }
10887
+ [Ft]() {
10888
+ return this[k] ? this[T] -= 1 : this[T] -= this[C][0].length, this[C].shift();
10889
+ }
10890
+ [Ot](t = false) {
10891
+ do
10892
+ ;
10893
+ while (this[Le](this[Ft]()) && this[C].length);
10894
+ !t && !this[C].length && !this[G] && this.emit("drain");
10895
+ }
10896
+ [Le](t) {
10897
+ return this.emit("data", t), this[v];
10898
+ }
10899
+ pipe(t, e) {
10900
+ if (this[x])
10901
+ return t;
10902
+ this[M] = false;
10903
+ let s = this[K];
10904
+ 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;
10905
+ }
10906
+ unpipe(t) {
10907
+ let e = this[F].find((s) => s.dest === t);
10908
+ 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());
10909
+ }
10910
+ addListener(t, e) {
10911
+ return this.on(t, e);
10912
+ }
10913
+ on(t, e) {
10914
+ let s = super.on(t, e);
10915
+ if (t === "data")
10916
+ this[M] = false, this[Y]++, !this[F].length && !this[v] && this[st]();
10917
+ else if (t === "readable" && this[T] !== 0)
10918
+ super.emit("readable");
10919
+ else if (ci(t) && this[K])
10920
+ super.emit(t), this.removeAllListeners(t);
10921
+ else if (t === "error" && this[ut]) {
10922
+ let i = e;
10923
+ this[B] ? mt(() => i.call(this, this[ut])) : i.call(this, this[ut]);
10924
+ }
10925
+ return s;
10926
+ }
10927
+ removeListener(t, e) {
10928
+ return this.off(t, e);
10929
+ }
10930
+ off(t, e) {
10931
+ let s = super.off(t, e);
10932
+ return t === "data" && (this[Y] = this.listeners("data").length, this[Y] === 0 && !this[M] && !this[F].length && (this[v] = false)), s;
10933
+ }
10934
+ removeAllListeners(t) {
10935
+ let e = super.removeAllListeners(t);
10936
+ return (t === "data" || t === undefined) && (this[Y] = 0, !this[M] && !this[F].length && (this[v] = false)), e;
10937
+ }
10938
+ get emittedEnd() {
10939
+ return this[K];
10940
+ }
10941
+ [H]() {
10942
+ !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);
10943
+ }
10944
+ emit(t, ...e) {
10945
+ let s = e[0];
10946
+ if (t !== "error" && t !== "close" && t !== x && this[x])
10947
+ return false;
10948
+ if (t === "data")
10949
+ return !this[k] && !s ? false : this[B] ? (mt(() => this[Jt](s)), true) : this[Jt](s);
10950
+ if (t === "end")
10951
+ return this[We]();
10952
+ if (t === "close") {
10953
+ if (this[Rt] = true, !this[K] && !this[x])
10954
+ return false;
10955
+ let r = super.emit("close");
10956
+ return this.removeAllListeners("close"), r;
10957
+ } else if (t === "error") {
10958
+ this[ut] = s, super.emit(Xt, s);
10959
+ let r = !this[pt] || this.listeners("error").length ? super.emit("error", s) : false;
10960
+ return this[H](), r;
10961
+ } else if (t === "resume") {
10962
+ let r = super.emit("resume");
10963
+ return this[H](), r;
10964
+ } else if (t === "finish" || t === "prefinish") {
10965
+ let r = super.emit(t);
10966
+ return this.removeAllListeners(t), r;
10967
+ }
10968
+ let i = super.emit(t, ...e);
10969
+ return this[H](), i;
10970
+ }
10971
+ [Jt](t) {
10972
+ for (let s of this[F])
10973
+ s.dest.write(t) === false && this.pause();
10974
+ let e = this[M] ? false : super.emit("data", t);
10975
+ return this[H](), e;
10976
+ }
10977
+ [We]() {
10978
+ return this[K] ? false : (this[K] = true, this.readable = false, this[B] ? (mt(() => this[Zt]()), true) : this[Zt]());
10979
+ }
10980
+ [Zt]() {
10981
+ if (this[et]) {
10982
+ let e = this[et].end();
10983
+ if (e) {
10984
+ for (let s of this[F])
10985
+ s.dest.write(e);
10986
+ this[M] || super.emit("data", e);
10987
+ }
10988
+ }
10989
+ for (let e of this[F])
10990
+ e.end();
10991
+ let t = super.emit("end");
10992
+ return this.removeAllListeners("end"), t;
10993
+ }
10994
+ async collect() {
10995
+ let t = Object.assign([], { dataLength: 0 });
10996
+ this[k] || (t.dataLength = 0);
10997
+ let e = this.promise();
10998
+ return this.on("data", (s) => {
10999
+ t.push(s), this[k] || (t.dataLength += s.length);
11000
+ }), await e, t;
11001
+ }
11002
+ async concat() {
11003
+ if (this[k])
11004
+ throw new Error("cannot concat in objectMode");
11005
+ let t = await this.collect();
11006
+ return this[P] ? t.join("") : Buffer.concat(t, t.dataLength);
11007
+ }
11008
+ async promise() {
11009
+ return new Promise((t, e) => {
11010
+ this.on(x, () => e(new Error("stream destroyed"))), this.on("error", (s) => e(s)), this.on("end", () => t());
11011
+ });
11012
+ }
11013
+ [Symbol.asyncIterator]() {
11014
+ this[M] = false;
11015
+ let t = false, e = async () => (this.pause(), t = true, { value: undefined, done: true });
11016
+ return { next: () => {
11017
+ if (t)
11018
+ return e();
11019
+ let i = this.read();
11020
+ if (i !== null)
11021
+ return Promise.resolve({ done: false, value: i });
11022
+ if (this[G])
11023
+ return e();
11024
+ let r, o, h = (c) => {
11025
+ this.off("data", a), this.off("end", l), this.off(x, u), e(), o(c);
11026
+ }, a = (c) => {
11027
+ this.off("error", h), this.off("end", l), this.off(x, u), this.pause(), r({ value: c, done: !!this[G] });
11028
+ }, l = () => {
11029
+ this.off("error", h), this.off("data", a), this.off(x, u), e(), r({ done: true, value: undefined });
11030
+ }, u = () => h(new Error("stream destroyed"));
11031
+ return new Promise((c, d) => {
11032
+ o = d, r = c, this.once(x, u), this.once("error", h), this.once("end", l), this.once("data", a);
11033
+ });
11034
+ }, throw: e, return: e, [Symbol.asyncIterator]() {
11035
+ return this;
11036
+ }, [Symbol.asyncDispose]: async () => {} };
11037
+ }
11038
+ [Symbol.iterator]() {
11039
+ this[M] = false;
11040
+ 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 = () => {
11041
+ if (t)
11042
+ return e();
11043
+ let i = this.read();
11044
+ return i === null ? e() : { done: false, value: i };
11045
+ };
11046
+ return this.once("end", e), this.once(Xt, e), this.once(x, e), { next: s, throw: e, return: e, [Symbol.iterator]() {
11047
+ return this;
11048
+ }, [Symbol.dispose]: () => {} };
11049
+ }
11050
+ destroy(t) {
11051
+ if (this[x])
11052
+ return t ? this.emit("error", t) : this.emit(x), this;
11053
+ this[x] = true, this[M] = true, this[C].length = 0, this[T] = 0;
11054
+ let e = this;
11055
+ return typeof e.close == "function" && !this[Rt] && e.close(), t ? this.emit("error", t) : this.emit(x), this;
11056
+ }
11057
+ static get isStream() {
11058
+ return oi;
11059
+ }
11060
+ };
11061
+ var vi = Ei.native;
11062
+ var wt = { lstatSync: wi, readdir: yi, readdirSync: bi, readlinkSync: Si, realpathSync: vi, promises: { lstat: Ci, readdir: Ti, readlink: Ai, realpath: ki } };
11063
+ var Ue = (n2) => !n2 || n2 === wt || n2 === xi ? wt : { ...wt, ...n2, promises: { ...wt.promises, ...n2.promises || {} } };
11064
+ var $e = /^\\\\\?\\([a-z]:)\\?$/i;
11065
+ var Ri = (n2) => n2.replace(/\//g, "\\").replace($e, "$1\\");
11066
+ var Oi = /[\\\/]/;
11067
+ var L = 0;
11068
+ var Ge = 1;
11069
+ var He = 2;
11070
+ var U = 4;
11071
+ var qe = 6;
11072
+ var Ke = 8;
11073
+ var X = 10;
11074
+ var Ve = 12;
11075
+ var _ = 15;
11076
+ var gt = ~_;
11077
+ var se = 16;
11078
+ var je = 32;
11079
+ var yt = 64;
11080
+ var j = 128;
11081
+ var Nt = 256;
11082
+ var Lt = 512;
11083
+ var Ie = yt | j | Lt;
11084
+ var Fi = 1023;
11085
+ 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;
11086
+ var ze = new ft({ max: 2 ** 12 });
11087
+ var bt = (n2) => {
11088
+ let t = ze.get(n2);
11089
+ if (t)
11090
+ return t;
11091
+ let e = n2.normalize("NFKD");
11092
+ return ze.set(n2, e), e;
11093
+ };
11094
+ var Be = new ft({ max: 2 ** 12 });
11095
+ var _t = (n2) => {
11096
+ let t = Be.get(n2);
11097
+ if (t)
11098
+ return t;
11099
+ let e = bt(n2.toLowerCase());
11100
+ return Be.set(n2, e), e;
11101
+ };
11102
+ var Wt = class extends ft {
11103
+ constructor() {
11104
+ super({ max: 256 });
11105
+ }
11106
+ };
11107
+ var ne = class extends ft {
11108
+ constructor(t = 16 * 1024) {
11109
+ super({ maxSize: t, sizeCalculation: (e) => e.length + 1 });
11110
+ }
11111
+ };
11112
+ var Ye = Symbol("PathScurry setAsCwd");
11113
+ var R = class {
11114
+ name;
11115
+ root;
11116
+ roots;
11117
+ parent;
11118
+ nocase;
11119
+ isCWD = false;
11120
+ #t;
11121
+ #s;
11122
+ get dev() {
11123
+ return this.#s;
11124
+ }
11125
+ #n;
11126
+ get mode() {
11127
+ return this.#n;
11128
+ }
11129
+ #r;
11130
+ get nlink() {
11131
+ return this.#r;
11132
+ }
11133
+ #o;
11134
+ get uid() {
11135
+ return this.#o;
11136
+ }
11137
+ #S;
11138
+ get gid() {
11139
+ return this.#S;
11140
+ }
11141
+ #w;
11142
+ get rdev() {
11143
+ return this.#w;
11144
+ }
11145
+ #c;
11146
+ get blksize() {
11147
+ return this.#c;
11148
+ }
11149
+ #h;
11150
+ get ino() {
11151
+ return this.#h;
11152
+ }
11153
+ #u;
11154
+ get size() {
11155
+ return this.#u;
11156
+ }
11157
+ #f;
11158
+ get blocks() {
11159
+ return this.#f;
11160
+ }
11161
+ #a;
11162
+ get atimeMs() {
11163
+ return this.#a;
11164
+ }
11165
+ #i;
11166
+ get mtimeMs() {
11167
+ return this.#i;
11168
+ }
11169
+ #d;
11170
+ get ctimeMs() {
11171
+ return this.#d;
11172
+ }
11173
+ #E;
11174
+ get birthtimeMs() {
11175
+ return this.#E;
11176
+ }
11177
+ #b;
11178
+ get atime() {
11179
+ return this.#b;
11180
+ }
11181
+ #p;
11182
+ get mtime() {
11183
+ return this.#p;
11184
+ }
11185
+ #R;
11186
+ get ctime() {
11187
+ return this.#R;
11188
+ }
11189
+ #m;
11190
+ get birthtime() {
11191
+ return this.#m;
11192
+ }
11193
+ #C;
11194
+ #T;
11195
+ #g;
11196
+ #y;
11197
+ #x;
11198
+ #A;
11199
+ #e;
11200
+ #_;
11201
+ #M;
11202
+ #k;
11203
+ get parentPath() {
11204
+ return (this.parent || this).fullpath();
11205
+ }
11206
+ get path() {
11207
+ return this.parentPath;
11208
+ }
11209
+ constructor(t, e = L, s, i, r, o, h) {
11210
+ 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);
11211
+ }
11212
+ depth() {
11213
+ return this.#T !== undefined ? this.#T : this.parent ? this.#T = this.parent.depth() + 1 : this.#T = 0;
11214
+ }
11215
+ childrenCache() {
11216
+ return this.#_;
11217
+ }
11218
+ resolve(t) {
11219
+ if (!t)
11220
+ return this;
11221
+ let e = this.getRootString(t), i = t.substring(e.length).split(this.splitSep);
11222
+ return e ? this.getRoot(e).#N(i) : this.#N(i);
11223
+ }
11224
+ #N(t) {
11225
+ let e = this;
11226
+ for (let s of t)
11227
+ e = e.child(s);
11228
+ return e;
11229
+ }
11230
+ children() {
11231
+ let t = this.#_.get(this);
11232
+ if (t)
11233
+ return t;
11234
+ let e = Object.assign([], { provisional: 0 });
11235
+ return this.#_.set(this, e), this.#e &= ~se, e;
11236
+ }
11237
+ child(t, e) {
11238
+ if (t === "" || t === ".")
11239
+ return this;
11240
+ if (t === "..")
11241
+ return this.parent || this;
11242
+ let s = this.children(), i = this.nocase ? _t(t) : bt(t);
11243
+ for (let a of s)
11244
+ if (a.#C === i)
11245
+ return a;
11246
+ let r = this.parent ? this.sep : "", o = this.#g ? this.#g + r + t : undefined, h = this.newChild(t, L, { ...e, parent: this, fullpath: o });
11247
+ return this.canReaddir() || (h.#e |= j), s.push(h), h;
11248
+ }
11249
+ relative() {
11250
+ if (this.isCWD)
11251
+ return "";
11252
+ if (this.#x !== undefined)
11253
+ return this.#x;
11254
+ let t = this.name, e = this.parent;
11255
+ if (!e)
11256
+ return this.#x = this.name;
11257
+ let s = e.relative();
11258
+ return s + (!s || !e.parent ? "" : this.sep) + t;
11259
+ }
11260
+ relativePosix() {
11261
+ if (this.sep === "/")
11262
+ return this.relative();
11263
+ if (this.isCWD)
11264
+ return "";
11265
+ if (this.#A !== undefined)
11266
+ return this.#A;
11267
+ let t = this.name, e = this.parent;
11268
+ if (!e)
11269
+ return this.#A = this.fullpathPosix();
11270
+ let s = e.relativePosix();
11271
+ return s + (!s || !e.parent ? "" : "/") + t;
11272
+ }
11273
+ fullpath() {
11274
+ if (this.#g !== undefined)
11275
+ return this.#g;
11276
+ let t = this.name, e = this.parent;
11277
+ if (!e)
11278
+ return this.#g = this.name;
11279
+ let i = e.fullpath() + (e.parent ? this.sep : "") + t;
11280
+ return this.#g = i;
11281
+ }
11282
+ fullpathPosix() {
11283
+ if (this.#y !== undefined)
11284
+ return this.#y;
11285
+ if (this.sep === "/")
11286
+ return this.#y = this.fullpath();
11287
+ if (!this.parent) {
11288
+ let i = this.fullpath().replace(/\\/g, "/");
11289
+ return /^[a-z]:\//i.test(i) ? this.#y = `//?/${i}` : this.#y = i;
11290
+ }
11291
+ let t = this.parent, e = t.fullpathPosix(), s = e + (!e || !t.parent ? "" : "/") + this.name;
11292
+ return this.#y = s;
11293
+ }
11294
+ isUnknown() {
11295
+ return (this.#e & _) === L;
11296
+ }
11297
+ isType(t) {
11298
+ return this[`is${t}`]();
11299
+ }
11300
+ getType() {
11301
+ 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";
11302
+ }
11303
+ isFile() {
11304
+ return (this.#e & _) === Ke;
11305
+ }
11306
+ isDirectory() {
11307
+ return (this.#e & _) === U;
11308
+ }
11309
+ isCharacterDevice() {
11310
+ return (this.#e & _) === He;
11311
+ }
11312
+ isBlockDevice() {
11313
+ return (this.#e & _) === qe;
11314
+ }
11315
+ isFIFO() {
11316
+ return (this.#e & _) === Ge;
11317
+ }
11318
+ isSocket() {
11319
+ return (this.#e & _) === Ve;
11320
+ }
11321
+ isSymbolicLink() {
11322
+ return (this.#e & X) === X;
11323
+ }
11324
+ lstatCached() {
11325
+ return this.#e & je ? this : undefined;
11326
+ }
11327
+ readlinkCached() {
11328
+ return this.#M;
11329
+ }
11330
+ realpathCached() {
11331
+ return this.#k;
11332
+ }
11333
+ readdirCached() {
11334
+ let t = this.children();
11335
+ return t.slice(0, t.provisional);
11336
+ }
11337
+ canReadlink() {
11338
+ if (this.#M)
11339
+ return true;
11340
+ if (!this.parent)
11341
+ return false;
11342
+ let t = this.#e & _;
11343
+ return !(t !== L && t !== X || this.#e & Nt || this.#e & j);
11344
+ }
11345
+ calledReaddir() {
11346
+ return !!(this.#e & se);
11347
+ }
11348
+ isENOENT() {
11349
+ return !!(this.#e & j);
11350
+ }
11351
+ isNamed(t) {
11352
+ return this.nocase ? this.#C === _t(t) : this.#C === bt(t);
11353
+ }
11354
+ async readlink() {
11355
+ let t = this.#M;
11356
+ if (t)
11357
+ return t;
11358
+ if (this.canReadlink() && this.parent)
11359
+ try {
11360
+ let e = await this.#t.promises.readlink(this.fullpath()), s = (await this.parent.realpath())?.resolve(e);
11361
+ if (s)
11362
+ return this.#M = s;
11363
+ } catch (e) {
11364
+ this.#D(e.code);
11365
+ return;
11366
+ }
11367
+ }
11368
+ readlinkSync() {
11369
+ let t = this.#M;
11370
+ if (t)
11371
+ return t;
11372
+ if (this.canReadlink() && this.parent)
11373
+ try {
11374
+ let e = this.#t.readlinkSync(this.fullpath()), s = this.parent.realpathSync()?.resolve(e);
11375
+ if (s)
11376
+ return this.#M = s;
11377
+ } catch (e) {
11378
+ this.#D(e.code);
11379
+ return;
11380
+ }
11381
+ }
11382
+ #j(t) {
11383
+ this.#e |= se;
11384
+ for (let e = t.provisional;e < t.length; e++) {
11385
+ let s = t[e];
11386
+ s && s.#v();
11387
+ }
11388
+ }
11389
+ #v() {
11390
+ this.#e & j || (this.#e = (this.#e | j) & gt, this.#G());
11391
+ }
11392
+ #G() {
11393
+ let t = this.children();
11394
+ t.provisional = 0;
11395
+ for (let e of t)
11396
+ e.#v();
11397
+ }
11398
+ #P() {
11399
+ this.#e |= Lt, this.#L();
11400
+ }
11401
+ #L() {
11402
+ if (this.#e & yt)
11403
+ return;
11404
+ let t = this.#e;
11405
+ (t & _) === U && (t &= gt), this.#e = t | yt, this.#G();
11406
+ }
11407
+ #I(t = "") {
11408
+ t === "ENOTDIR" || t === "EPERM" ? this.#L() : t === "ENOENT" ? this.#v() : this.children().provisional = 0;
11409
+ }
11410
+ #F(t = "") {
11411
+ t === "ENOTDIR" ? this.parent.#L() : t === "ENOENT" && this.#v();
11412
+ }
11413
+ #D(t = "") {
11414
+ let e = this.#e;
11415
+ e |= Nt, t === "ENOENT" && (e |= j), (t === "EINVAL" || t === "UNKNOWN") && (e &= gt), this.#e = e, t === "ENOTDIR" && this.parent && this.parent.#L();
11416
+ }
11417
+ #z(t, e) {
11418
+ return this.#U(t, e) || this.#B(t, e);
11419
+ }
11420
+ #B(t, e) {
11421
+ let s = ie(t), i = this.newChild(t.name, s, { parent: this }), r = i.#e & _;
11422
+ return r !== U && r !== X && r !== L && (i.#e |= yt), e.unshift(i), e.provisional++, i;
11423
+ }
11424
+ #U(t, e) {
11425
+ for (let s = e.provisional;s < e.length; s++) {
11426
+ let i = e[s];
11427
+ if ((this.nocase ? _t(t.name) : bt(t.name)) === i.#C)
11428
+ return this.#l(t, i, s, e);
11429
+ }
11430
+ }
11431
+ #l(t, e, s, i) {
11432
+ let r = e.name;
11433
+ 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;
11434
+ }
11435
+ async lstat() {
11436
+ if ((this.#e & j) === 0)
11437
+ try {
11438
+ return this.#$(await this.#t.promises.lstat(this.fullpath())), this;
11439
+ } catch (t) {
11440
+ this.#F(t.code);
11441
+ }
11442
+ }
11443
+ lstatSync() {
11444
+ if ((this.#e & j) === 0)
11445
+ try {
11446
+ return this.#$(this.#t.lstatSync(this.fullpath())), this;
11447
+ } catch (t) {
11448
+ this.#F(t.code);
11449
+ }
11450
+ }
11451
+ #$(t) {
11452
+ 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;
11453
+ 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;
11454
+ let y = ie(t);
11455
+ this.#e = this.#e & gt | y | je, y !== L && y !== U && y !== X && (this.#e |= yt);
11456
+ }
11457
+ #W = [];
11458
+ #O = false;
11459
+ #H(t) {
11460
+ this.#O = false;
11461
+ let e = this.#W.slice();
11462
+ this.#W.length = 0, e.forEach((s) => s(null, t));
11463
+ }
11464
+ readdirCB(t, e = false) {
11465
+ if (!this.canReaddir()) {
11466
+ e ? t(null, []) : queueMicrotask(() => t(null, []));
11467
+ return;
11468
+ }
11469
+ let s = this.children();
11470
+ if (this.calledReaddir()) {
11471
+ let r = s.slice(0, s.provisional);
11472
+ e ? t(null, r) : queueMicrotask(() => t(null, r));
11473
+ return;
11474
+ }
11475
+ if (this.#W.push(t), this.#O)
11476
+ return;
11477
+ this.#O = true;
11478
+ let i = this.fullpath();
11479
+ this.#t.readdir(i, { withFileTypes: true }, (r, o) => {
11480
+ if (r)
11481
+ this.#I(r.code), s.provisional = 0;
11482
+ else {
11483
+ for (let h of o)
11484
+ this.#z(h, s);
11485
+ this.#j(s);
11486
+ }
11487
+ this.#H(s.slice(0, s.provisional));
11488
+ });
11489
+ }
11490
+ #q;
11491
+ async readdir() {
11492
+ if (!this.canReaddir())
11493
+ return [];
11494
+ let t = this.children();
11495
+ if (this.calledReaddir())
11496
+ return t.slice(0, t.provisional);
11497
+ let e = this.fullpath();
11498
+ if (this.#q)
11499
+ await this.#q;
11500
+ else {
11501
+ let s = () => {};
11502
+ this.#q = new Promise((i) => s = i);
11503
+ try {
11504
+ for (let i of await this.#t.promises.readdir(e, { withFileTypes: true }))
11505
+ this.#z(i, t);
11506
+ this.#j(t);
11507
+ } catch (i) {
11508
+ this.#I(i.code), t.provisional = 0;
11509
+ }
11510
+ this.#q = undefined, s();
11511
+ }
11512
+ return t.slice(0, t.provisional);
11513
+ }
11514
+ readdirSync() {
11515
+ if (!this.canReaddir())
11516
+ return [];
11517
+ let t = this.children();
11518
+ if (this.calledReaddir())
11519
+ return t.slice(0, t.provisional);
11520
+ let e = this.fullpath();
11521
+ try {
11522
+ for (let s of this.#t.readdirSync(e, { withFileTypes: true }))
11523
+ this.#z(s, t);
11524
+ this.#j(t);
11525
+ } catch (s) {
11526
+ this.#I(s.code), t.provisional = 0;
11527
+ }
11528
+ return t.slice(0, t.provisional);
11529
+ }
11530
+ canReaddir() {
11531
+ if (this.#e & Ie)
11532
+ return false;
11533
+ let t = _ & this.#e;
11534
+ return t === L || t === U || t === X;
11535
+ }
11536
+ shouldWalk(t, e) {
11537
+ return (this.#e & U) === U && !(this.#e & Ie) && !t.has(this) && (!e || e(this));
11538
+ }
11539
+ async realpath() {
11540
+ if (this.#k)
11541
+ return this.#k;
11542
+ if (!((Lt | Nt | j) & this.#e))
11543
+ try {
11544
+ let t = await this.#t.promises.realpath(this.fullpath());
11545
+ return this.#k = this.resolve(t);
11546
+ } catch {
11547
+ this.#P();
11548
+ }
11549
+ }
11550
+ realpathSync() {
11551
+ if (this.#k)
11552
+ return this.#k;
11553
+ if (!((Lt | Nt | j) & this.#e))
11554
+ try {
11555
+ let t = this.#t.realpathSync(this.fullpath());
11556
+ return this.#k = this.resolve(t);
11557
+ } catch {
11558
+ this.#P();
11559
+ }
11560
+ }
11561
+ [Ye](t) {
11562
+ if (t === this)
11563
+ return;
11564
+ t.isCWD = false, this.isCWD = true;
11565
+ let e = new Set([]), s = [], i = this;
11566
+ for (;i && i.parent; )
11567
+ e.add(i), i.#x = s.join(this.sep), i.#A = s.join("/"), i = i.parent, s.push("..");
11568
+ for (i = t;i && i.parent && !e.has(i); )
11569
+ i.#x = undefined, i.#A = undefined, i = i.parent;
11570
+ }
11571
+ };
11572
+ var Pt = class n2 extends R {
11573
+ sep = "\\";
11574
+ splitSep = Oi;
11575
+ constructor(t, e = L, s, i, r, o, h) {
11576
+ super(t, e, s, i, r, o, h);
11577
+ }
11578
+ newChild(t, e = L, s = {}) {
11579
+ return new n2(t, e, this.root, this.roots, this.nocase, this.childrenCache(), s);
11580
+ }
11581
+ getRootString(t) {
11582
+ return re.parse(t).root;
11583
+ }
11584
+ getRoot(t) {
11585
+ if (t = Ri(t.toUpperCase()), t === this.root.name)
11586
+ return this.root;
11587
+ for (let [e, s] of Object.entries(this.roots))
11588
+ if (this.sameRoot(t, e))
11589
+ return this.roots[t] = s;
11590
+ return this.roots[t] = new it(t, this).root;
11591
+ }
11592
+ sameRoot(t, e = this.root.name) {
11593
+ return t = t.toUpperCase().replace(/\//g, "\\").replace($e, "$1\\"), t === e;
11594
+ }
11595
+ };
11596
+ var jt = class n3 extends R {
11597
+ splitSep = "/";
11598
+ sep = "/";
11599
+ constructor(t, e = L, s, i, r, o, h) {
11600
+ super(t, e, s, i, r, o, h);
11601
+ }
11602
+ getRootString(t) {
11603
+ return t.startsWith("/") ? "/" : "";
11604
+ }
11605
+ getRoot(t) {
11606
+ return this.root;
11607
+ }
11608
+ newChild(t, e = L, s = {}) {
11609
+ return new n3(t, e, this.root, this.roots, this.nocase, this.childrenCache(), s);
11610
+ }
11611
+ };
11612
+ var It = class {
11613
+ root;
11614
+ rootPath;
11615
+ roots;
11616
+ cwd;
11617
+ #t;
11618
+ #s;
11619
+ #n;
11620
+ nocase;
11621
+ #r;
11622
+ constructor(t = process.cwd(), e, s, { nocase: i, childrenCacheSize: r = 16 * 1024, fs: o = wt } = {}) {
11623
+ this.#r = Ue(o), (t instanceof URL || t.startsWith("file://")) && (t = gi(t));
11624
+ let h = e.resolve(t);
11625
+ this.roots = Object.create(null), this.rootPath = this.parseRootPath(h), this.#t = new Wt, this.#s = new Wt, this.#n = new ne(r);
11626
+ let a = h.substring(this.rootPath.length).split(s);
11627
+ if (a.length === 1 && !a[0] && a.pop(), i === undefined)
11628
+ throw new TypeError("must provide nocase setting to PathScurryBase ctor");
11629
+ this.nocase = i, this.root = this.newRoot(this.#r), this.roots[this.rootPath] = this.root;
11630
+ let l = this.root, u = a.length - 1, c = e.sep, d = this.rootPath, f = false;
11631
+ for (let m of a) {
11632
+ let p = u--;
11633
+ l = l.child(m, { relative: new Array(p).fill("..").join(c), relativePosix: new Array(p).fill("..").join("/"), fullpath: d += (f ? "" : c) + m }), f = true;
11634
+ }
11635
+ this.cwd = l;
11636
+ }
11637
+ depth(t = this.cwd) {
11638
+ return typeof t == "string" && (t = this.cwd.resolve(t)), t.depth();
11639
+ }
11640
+ childrenCache() {
11641
+ return this.#n;
11642
+ }
11643
+ resolve(...t) {
11644
+ let e = "";
11645
+ for (let r = t.length - 1;r >= 0; r--) {
11646
+ let o = t[r];
11647
+ if (!(!o || o === ".") && (e = e ? `${o}/${e}` : o, this.isAbsolute(o)))
11648
+ break;
11649
+ }
11650
+ let s = this.#t.get(e);
11651
+ if (s !== undefined)
11652
+ return s;
11653
+ let i = this.cwd.resolve(e).fullpath();
11654
+ return this.#t.set(e, i), i;
11655
+ }
11656
+ resolvePosix(...t) {
11657
+ let e = "";
11658
+ for (let r = t.length - 1;r >= 0; r--) {
11659
+ let o = t[r];
11660
+ if (!(!o || o === ".") && (e = e ? `${o}/${e}` : o, this.isAbsolute(o)))
11661
+ break;
11662
+ }
11663
+ let s = this.#s.get(e);
11664
+ if (s !== undefined)
11665
+ return s;
11666
+ let i = this.cwd.resolve(e).fullpathPosix();
11667
+ return this.#s.set(e, i), i;
11668
+ }
11669
+ relative(t = this.cwd) {
11670
+ return typeof t == "string" && (t = this.cwd.resolve(t)), t.relative();
11671
+ }
11672
+ relativePosix(t = this.cwd) {
11673
+ return typeof t == "string" && (t = this.cwd.resolve(t)), t.relativePosix();
11674
+ }
11675
+ basename(t = this.cwd) {
11676
+ return typeof t == "string" && (t = this.cwd.resolve(t)), t.name;
11677
+ }
11678
+ dirname(t = this.cwd) {
11679
+ return typeof t == "string" && (t = this.cwd.resolve(t)), (t.parent || t).fullpath();
11680
+ }
11681
+ async readdir(t = this.cwd, e = { withFileTypes: true }) {
11682
+ typeof t == "string" ? t = this.cwd.resolve(t) : t instanceof R || (e = t, t = this.cwd);
11683
+ let { withFileTypes: s } = e;
11684
+ if (t.canReaddir()) {
11685
+ let i = await t.readdir();
11686
+ return s ? i : i.map((r) => r.name);
11687
+ } else
11688
+ return [];
11689
+ }
11690
+ readdirSync(t = this.cwd, e = { withFileTypes: true }) {
11691
+ typeof t == "string" ? t = this.cwd.resolve(t) : t instanceof R || (e = t, t = this.cwd);
11692
+ let { withFileTypes: s = true } = e;
11693
+ return t.canReaddir() ? s ? t.readdirSync() : t.readdirSync().map((i) => i.name) : [];
11694
+ }
11695
+ async lstat(t = this.cwd) {
11696
+ return typeof t == "string" && (t = this.cwd.resolve(t)), t.lstat();
11697
+ }
11698
+ lstatSync(t = this.cwd) {
11699
+ return typeof t == "string" && (t = this.cwd.resolve(t)), t.lstatSync();
11700
+ }
11701
+ async readlink(t = this.cwd, { withFileTypes: e } = { withFileTypes: false }) {
11702
+ typeof t == "string" ? t = this.cwd.resolve(t) : t instanceof R || (e = t.withFileTypes, t = this.cwd);
11703
+ let s = await t.readlink();
11704
+ return e ? s : s?.fullpath();
11705
+ }
11706
+ readlinkSync(t = this.cwd, { withFileTypes: e } = { withFileTypes: false }) {
11707
+ typeof t == "string" ? t = this.cwd.resolve(t) : t instanceof R || (e = t.withFileTypes, t = this.cwd);
11708
+ let s = t.readlinkSync();
11709
+ return e ? s : s?.fullpath();
11710
+ }
11711
+ async realpath(t = this.cwd, { withFileTypes: e } = { withFileTypes: false }) {
11712
+ typeof t == "string" ? t = this.cwd.resolve(t) : t instanceof R || (e = t.withFileTypes, t = this.cwd);
11713
+ let s = await t.realpath();
11714
+ return e ? s : s?.fullpath();
11715
+ }
11716
+ realpathSync(t = this.cwd, { withFileTypes: e } = { withFileTypes: false }) {
11717
+ typeof t == "string" ? t = this.cwd.resolve(t) : t instanceof R || (e = t.withFileTypes, t = this.cwd);
11718
+ let s = t.realpathSync();
11719
+ return e ? s : s?.fullpath();
11720
+ }
11721
+ async walk(t = this.cwd, e = {}) {
11722
+ typeof t == "string" ? t = this.cwd.resolve(t) : t instanceof R || (e = t, t = this.cwd);
11723
+ let { withFileTypes: s = true, follow: i = false, filter: r, walkFilter: o } = e, h = [];
11724
+ (!r || r(t)) && h.push(s ? t : t.fullpath());
11725
+ let a = new Set, l = (c, d) => {
11726
+ a.add(c), c.readdirCB((f, m) => {
11727
+ if (f)
11728
+ return d(f);
11729
+ let p = m.length;
11730
+ if (!p)
11731
+ return d();
11732
+ let w = () => {
11733
+ --p === 0 && d();
11734
+ };
11735
+ for (let g of m)
11736
+ (!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();
11737
+ }, true);
11738
+ }, u = t;
11739
+ return new Promise((c, d) => {
11740
+ l(u, (f) => {
11741
+ if (f)
11742
+ return d(f);
11743
+ c(h);
11744
+ });
11745
+ });
11746
+ }
11747
+ walkSync(t = this.cwd, e = {}) {
11748
+ typeof t == "string" ? t = this.cwd.resolve(t) : t instanceof R || (e = t, t = this.cwd);
11749
+ let { withFileTypes: s = true, follow: i = false, filter: r, walkFilter: o } = e, h = [];
11750
+ (!r || r(t)) && h.push(s ? t : t.fullpath());
11751
+ let a = new Set([t]);
11752
+ for (let l of a) {
11753
+ let u = l.readdirSync();
11754
+ for (let c of u) {
11755
+ (!r || r(c)) && h.push(s ? c : c.fullpath());
11756
+ let d = c;
11757
+ if (c.isSymbolicLink()) {
11758
+ if (!(i && (d = c.realpathSync())))
11759
+ continue;
11760
+ d.isUnknown() && d.lstatSync();
11761
+ }
11762
+ d.shouldWalk(a, o) && a.add(d);
11763
+ }
11764
+ }
11765
+ return h;
11766
+ }
11767
+ [Symbol.asyncIterator]() {
11768
+ return this.iterate();
11769
+ }
11770
+ iterate(t = this.cwd, e = {}) {
11771
+ return typeof t == "string" ? t = this.cwd.resolve(t) : t instanceof R || (e = t, t = this.cwd), this.stream(t, e)[Symbol.asyncIterator]();
11772
+ }
11773
+ [Symbol.iterator]() {
11774
+ return this.iterateSync();
11775
+ }
11776
+ *iterateSync(t = this.cwd, e = {}) {
11777
+ typeof t == "string" ? t = this.cwd.resolve(t) : t instanceof R || (e = t, t = this.cwd);
11778
+ let { withFileTypes: s = true, follow: i = false, filter: r, walkFilter: o } = e;
11779
+ (!r || r(t)) && (yield s ? t : t.fullpath());
11780
+ let h = new Set([t]);
11781
+ for (let a of h) {
11782
+ let l = a.readdirSync();
11783
+ for (let u of l) {
11784
+ (!r || r(u)) && (yield s ? u : u.fullpath());
11785
+ let c = u;
11786
+ if (u.isSymbolicLink()) {
11787
+ if (!(i && (c = u.realpathSync())))
11788
+ continue;
11789
+ c.isUnknown() && c.lstatSync();
11790
+ }
11791
+ c.shouldWalk(h, o) && h.add(c);
11792
+ }
11793
+ }
11794
+ }
11795
+ stream(t = this.cwd, e = {}) {
11796
+ typeof t == "string" ? t = this.cwd.resolve(t) : t instanceof R || (e = t, t = this.cwd);
11797
+ let { withFileTypes: s = true, follow: i = false, filter: r, walkFilter: o } = e, h = new V({ objectMode: true });
11798
+ (!r || r(t)) && h.write(s ? t : t.fullpath());
11799
+ let a = new Set, l = [t], u = 0, c = () => {
11800
+ let d = false;
11801
+ for (;!d; ) {
11802
+ let f = l.shift();
11803
+ if (!f) {
11804
+ u === 0 && h.end();
11805
+ return;
11806
+ }
11807
+ u++, a.add(f);
11808
+ let m = (w, g, S = false) => {
11809
+ if (w)
11810
+ return h.emit("error", w);
11811
+ if (i && !S) {
11812
+ let E = [];
11813
+ for (let y of g)
11814
+ y.isSymbolicLink() && E.push(y.realpath().then((b) => b?.isUnknown() ? b.lstat() : b));
11815
+ if (E.length) {
11816
+ Promise.all(E).then(() => m(null, g, true));
11817
+ return;
11818
+ }
11819
+ }
11820
+ for (let E of g)
11821
+ E && (!r || r(E)) && (h.write(s ? E : E.fullpath()) || (d = true));
11822
+ u--;
11823
+ for (let E of g) {
11824
+ let y = E.realpathCached() || E;
11825
+ y.shouldWalk(a, o) && l.push(y);
11826
+ }
11827
+ d && !h.flowing ? h.once("drain", c) : p || c();
11828
+ }, p = true;
11829
+ f.readdirCB(m, true), p = false;
11830
+ }
11831
+ };
11832
+ return c(), h;
11833
+ }
11834
+ streamSync(t = this.cwd, e = {}) {
11835
+ typeof t == "string" ? t = this.cwd.resolve(t) : t instanceof R || (e = t, t = this.cwd);
11836
+ let { withFileTypes: s = true, follow: i = false, filter: r, walkFilter: o } = e, h = new V({ objectMode: true }), a = new Set;
11837
+ (!r || r(t)) && h.write(s ? t : t.fullpath());
11838
+ let l = [t], u = 0, c = () => {
11839
+ let d = false;
11840
+ for (;!d; ) {
11841
+ let f = l.shift();
11842
+ if (!f) {
11843
+ u === 0 && h.end();
11844
+ return;
11845
+ }
11846
+ u++, a.add(f);
11847
+ let m = f.readdirSync();
11848
+ for (let p of m)
11849
+ (!r || r(p)) && (h.write(s ? p : p.fullpath()) || (d = true));
11850
+ u--;
11851
+ for (let p of m) {
11852
+ let w = p;
11853
+ if (p.isSymbolicLink()) {
11854
+ if (!(i && (w = p.realpathSync())))
11855
+ continue;
11856
+ w.isUnknown() && w.lstatSync();
11857
+ }
11858
+ w.shouldWalk(a, o) && l.push(w);
11859
+ }
11860
+ }
11861
+ d && !h.flowing && h.once("drain", c);
11862
+ };
11863
+ return c(), h;
11864
+ }
11865
+ chdir(t = this.cwd) {
11866
+ let e = this.cwd;
11867
+ this.cwd = typeof t == "string" ? this.cwd.resolve(t) : t, this.cwd[Ye](e);
11868
+ }
11869
+ };
11870
+ var it = class extends It {
11871
+ sep = "\\";
11872
+ constructor(t = process.cwd(), e = {}) {
11873
+ let { nocase: s = true } = e;
11874
+ super(t, re, "\\", { ...e, nocase: s }), this.nocase = s;
11875
+ for (let i = this.cwd;i; i = i.parent)
11876
+ i.nocase = this.nocase;
11877
+ }
11878
+ parseRootPath(t) {
11879
+ return re.parse(t).root.toUpperCase();
11880
+ }
11881
+ newRoot(t) {
11882
+ return new Pt(this.rootPath, U, undefined, this.roots, this.nocase, this.childrenCache(), { fs: t });
11883
+ }
11884
+ isAbsolute(t) {
11885
+ return t.startsWith("/") || t.startsWith("\\") || /^[a-z]:(\/|\\)/i.test(t);
11886
+ }
11887
+ };
11888
+ var rt = class extends It {
11889
+ sep = "/";
11890
+ constructor(t = process.cwd(), e = {}) {
11891
+ let { nocase: s = false } = e;
11892
+ super(t, mi, "/", { ...e, nocase: s }), this.nocase = s;
11893
+ }
11894
+ parseRootPath(t) {
11895
+ return "/";
11896
+ }
11897
+ newRoot(t) {
11898
+ return new jt(this.rootPath, U, undefined, this.roots, this.nocase, this.childrenCache(), { fs: t });
11899
+ }
11900
+ isAbsolute(t) {
11901
+ return t.startsWith("/");
11902
+ }
11903
+ };
11904
+ var St = class extends rt {
11905
+ constructor(t = process.cwd(), e = {}) {
11906
+ let { nocase: s = true } = e;
11907
+ super(t, { ...e, nocase: s });
11908
+ }
11909
+ };
11910
+ var Cr = process.platform === "win32" ? Pt : jt;
11911
+ var Xe = process.platform === "win32" ? it : process.platform === "darwin" ? St : rt;
11912
+ var Di = (n4) => n4.length >= 1;
11913
+ var Mi = (n4) => n4.length >= 1;
11914
+ var Ni = Symbol.for("nodejs.util.inspect.custom");
11915
+ var nt = class n4 {
11916
+ #t;
11917
+ #s;
11918
+ #n;
11919
+ length;
11920
+ #r;
11921
+ #o;
11922
+ #S;
11923
+ #w;
11924
+ #c;
11925
+ #h;
11926
+ #u = true;
11927
+ constructor(t, e, s, i) {
11928
+ if (!Di(t))
11929
+ throw new TypeError("empty pattern list");
11930
+ if (!Mi(e))
11931
+ throw new TypeError("empty glob list");
11932
+ if (e.length !== t.length)
11933
+ throw new TypeError("mismatched pattern list and glob list lengths");
11934
+ if (this.length = t.length, s < 0 || s >= this.length)
11935
+ throw new TypeError("index out of range");
11936
+ if (this.#t = t, this.#s = e, this.#n = s, this.#r = i, this.#n === 0) {
11937
+ if (this.isUNC()) {
11938
+ let [r, o, h, a, ...l] = this.#t, [u, c, d, f, ...m] = this.#s;
11939
+ l[0] === "" && (l.shift(), m.shift());
11940
+ let p = [r, o, h, a, ""].join("/"), w = [u, c, d, f, ""].join("/");
11941
+ this.#t = [p, ...l], this.#s = [w, ...m], this.length = this.#t.length;
11942
+ } else if (this.isDrive() || this.isAbsolute()) {
11943
+ let [r, ...o] = this.#t, [h, ...a] = this.#s;
11944
+ o[0] === "" && (o.shift(), a.shift());
11945
+ let l = r + "/", u = h + "/";
11946
+ this.#t = [l, ...o], this.#s = [u, ...a], this.length = this.#t.length;
11947
+ }
11948
+ }
11949
+ }
11950
+ [Ni]() {
11951
+ return "Pattern <" + this.#s.slice(this.#n).join("/") + ">";
11952
+ }
11953
+ pattern() {
11954
+ return this.#t[this.#n];
11955
+ }
11956
+ isString() {
11957
+ return typeof this.#t[this.#n] == "string";
11958
+ }
11959
+ isGlobstar() {
11960
+ return this.#t[this.#n] === A;
11961
+ }
11962
+ isRegExp() {
11963
+ return this.#t[this.#n] instanceof RegExp;
11964
+ }
11965
+ globString() {
11966
+ 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("/"));
11967
+ }
11968
+ hasMore() {
11969
+ return this.length > this.#n + 1;
11970
+ }
11971
+ rest() {
11972
+ 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;
11973
+ }
11974
+ isUNC() {
11975
+ let t = this.#t;
11976
+ 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];
11977
+ }
11978
+ isDrive() {
11979
+ let t = this.#t;
11980
+ 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]);
11981
+ }
11982
+ isAbsolute() {
11983
+ let t = this.#t;
11984
+ return this.#h !== undefined ? this.#h : this.#h = t[0] === "" && t.length > 1 || this.isDrive() || this.isUNC();
11985
+ }
11986
+ root() {
11987
+ let t = this.#t[0];
11988
+ return typeof t == "string" && this.isAbsolute() && this.#n === 0 ? t : "";
11989
+ }
11990
+ checkFollowGlobstar() {
11991
+ return !(this.#n === 0 || !this.isGlobstar() || !this.#u);
11992
+ }
11993
+ markFollowGlobstar() {
11994
+ return this.#n === 0 || !this.isGlobstar() || !this.#u ? false : (this.#u = false, true);
11995
+ }
11996
+ };
11997
+ var _i = typeof process == "object" && process && typeof process.platform == "string" ? process.platform : "linux";
11998
+ var ot = class {
11999
+ relative;
12000
+ relativeChildren;
12001
+ absolute;
12002
+ absoluteChildren;
12003
+ platform;
12004
+ mmopts;
12005
+ constructor(t, { nobrace: e, nocase: s, noext: i, noglobstar: r, platform: o = _i }) {
12006
+ 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 };
12007
+ for (let h of t)
12008
+ this.add(h);
12009
+ }
12010
+ add(t) {
12011
+ let e = new D(t, this.mmopts);
12012
+ for (let s = 0;s < e.set.length; s++) {
12013
+ let i = e.set[s], r = e.globParts[s];
12014
+ if (!i || !r)
12015
+ throw new Error("invalid pattern object");
12016
+ for (;i[0] === "." && r[0] === "."; )
12017
+ i.shift(), r.shift();
12018
+ let o = new nt(i, r, 0, this.platform), h = new D(o.globString(), this.mmopts), a = r[r.length - 1] === "**", l = o.isAbsolute();
12019
+ l ? this.absolute.push(h) : this.relative.push(h), a && (l ? this.absoluteChildren.push(h) : this.relativeChildren.push(h));
12020
+ }
12021
+ }
12022
+ ignored(t) {
12023
+ let e = t.fullpath(), s = `${e}/`, i = t.relative() || ".", r = `${i}/`;
12024
+ for (let o of this.relative)
12025
+ if (o.match(i) || o.match(r))
12026
+ return true;
12027
+ for (let o of this.absolute)
12028
+ if (o.match(e) || o.match(s))
12029
+ return true;
12030
+ return false;
12031
+ }
12032
+ childrenIgnored(t) {
12033
+ let e = t.fullpath() + "/", s = (t.relative() || ".") + "/";
12034
+ for (let i of this.relativeChildren)
12035
+ if (i.match(s))
12036
+ return true;
12037
+ for (let i of this.absoluteChildren)
12038
+ if (i.match(e))
12039
+ return true;
12040
+ return false;
12041
+ }
12042
+ };
12043
+ var oe = class n5 {
12044
+ store;
12045
+ constructor(t = new Map) {
12046
+ this.store = t;
12047
+ }
12048
+ copy() {
12049
+ return new n5(new Map(this.store));
12050
+ }
12051
+ hasWalked(t, e) {
12052
+ return this.store.get(t.fullpath())?.has(e.globString());
12053
+ }
12054
+ storeWalked(t, e) {
12055
+ let s = t.fullpath(), i = this.store.get(s);
12056
+ i ? i.add(e.globString()) : this.store.set(s, new Set([e.globString()]));
12057
+ }
12058
+ };
12059
+ var he = class {
12060
+ store = new Map;
12061
+ add(t, e, s) {
12062
+ let i = (e ? 2 : 0) | (s ? 1 : 0), r = this.store.get(t);
12063
+ this.store.set(t, r === undefined ? i : i & r);
12064
+ }
12065
+ entries() {
12066
+ return [...this.store.entries()].map(([t, e]) => [t, !!(e & 2), !!(e & 1)]);
12067
+ }
12068
+ };
12069
+ var ae = class {
12070
+ store = new Map;
12071
+ add(t, e) {
12072
+ if (!t.canReaddir())
12073
+ return;
12074
+ let s = this.store.get(t);
12075
+ s ? s.find((i) => i.globString() === e.globString()) || s.push(e) : this.store.set(t, [e]);
12076
+ }
12077
+ get(t) {
12078
+ let e = this.store.get(t);
12079
+ if (!e)
12080
+ throw new Error("attempting to walk unknown path");
12081
+ return e;
12082
+ }
12083
+ entries() {
12084
+ return this.keys().map((t) => [t, this.store.get(t)]);
12085
+ }
12086
+ keys() {
12087
+ return [...this.store.keys()].filter((t) => t.canReaddir());
12088
+ }
12089
+ };
12090
+ var Et = class n6 {
12091
+ hasWalkedCache;
12092
+ matches = new he;
12093
+ subwalks = new ae;
12094
+ patterns;
12095
+ follow;
12096
+ dot;
12097
+ opts;
12098
+ constructor(t, e) {
12099
+ this.opts = t, this.follow = !!t.follow, this.dot = !!t.dot, this.hasWalkedCache = e ? e.copy() : new oe;
12100
+ }
12101
+ processPatterns(t, e) {
12102
+ this.patterns = e;
12103
+ let s = e.map((i) => [t, i]);
12104
+ for (let [i, r] of s) {
12105
+ this.hasWalkedCache.storeWalked(i, r);
12106
+ let o = r.root(), h = r.isAbsolute() && this.opts.absolute !== false;
12107
+ if (o) {
12108
+ i = i.resolve(o === "/" && this.opts.root !== undefined ? this.opts.root : o);
12109
+ let c = r.rest();
12110
+ if (c)
12111
+ r = c;
12112
+ else {
12113
+ this.matches.add(i, true, false);
12114
+ continue;
12115
+ }
12116
+ }
12117
+ if (i.isENOENT())
12118
+ continue;
12119
+ let a, l, u = false;
12120
+ for (;typeof (a = r.pattern()) == "string" && (l = r.rest()); )
12121
+ i = i.resolve(a), r = l, u = true;
12122
+ if (a = r.pattern(), l = r.rest(), u) {
12123
+ if (this.hasWalkedCache.hasWalked(i, r))
12124
+ continue;
12125
+ this.hasWalkedCache.storeWalked(i, r);
12126
+ }
12127
+ if (typeof a == "string") {
12128
+ let c = a === ".." || a === "" || a === ".";
12129
+ this.matches.add(i.resolve(a), h, c);
12130
+ continue;
12131
+ } else if (a === A) {
12132
+ (!i.isSymbolicLink() || this.follow || r.checkFollowGlobstar()) && this.subwalks.add(i, r);
12133
+ let c = l?.pattern(), d = l?.rest();
12134
+ if (!l || (c === "" || c === ".") && !d)
12135
+ this.matches.add(i, h, c === "" || c === ".");
12136
+ else if (c === "..") {
12137
+ let f = i.parent || i;
12138
+ d ? this.hasWalkedCache.hasWalked(f, d) || this.subwalks.add(f, d) : this.matches.add(f, h, true);
12139
+ }
12140
+ } else
12141
+ a instanceof RegExp && this.subwalks.add(i, r);
12142
+ }
12143
+ return this;
12144
+ }
12145
+ subwalkTargets() {
12146
+ return this.subwalks.keys();
12147
+ }
12148
+ child() {
12149
+ return new n6(this.opts, this.hasWalkedCache);
12150
+ }
12151
+ filterEntries(t, e) {
12152
+ let s = this.subwalks.get(t), i = this.child();
12153
+ for (let r of e)
12154
+ for (let o of s) {
12155
+ let h = o.isAbsolute(), a = o.pattern(), l = o.rest();
12156
+ a === A ? i.testGlobstar(r, o, l, h) : a instanceof RegExp ? i.testRegExp(r, a, l, h) : i.testString(r, a, l, h);
12157
+ }
12158
+ return i;
12159
+ }
12160
+ testGlobstar(t, e, s, i) {
12161
+ 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) {
12162
+ let r = s.pattern();
12163
+ if (typeof r == "string" && r !== ".." && r !== "" && r !== ".")
12164
+ this.testString(t, r, s.rest(), i);
12165
+ else if (r === "..") {
12166
+ let o = t.parent || t;
12167
+ this.subwalks.add(o, s);
12168
+ } else
12169
+ r instanceof RegExp && this.testRegExp(t, r, s.rest(), i);
12170
+ }
12171
+ }
12172
+ testRegExp(t, e, s, i) {
12173
+ e.test(t.name) && (s ? this.subwalks.add(t, s) : this.matches.add(t, i, false));
12174
+ }
12175
+ testString(t, e, s, i) {
12176
+ t.isNamed(e) && (s ? this.subwalks.add(t, s) : this.matches.add(t, i, false));
12177
+ }
12178
+ };
12179
+ var Li = (n7, t) => typeof n7 == "string" ? new ot([n7], t) : Array.isArray(n7) ? new ot(n7, t) : n7;
12180
+ var zt = class {
12181
+ path;
12182
+ patterns;
12183
+ opts;
12184
+ seen = new Set;
12185
+ paused = false;
12186
+ aborted = false;
12187
+ #t = [];
12188
+ #s;
12189
+ #n;
12190
+ signal;
12191
+ maxDepth;
12192
+ includeChildMatches;
12193
+ constructor(t, e, s) {
12194
+ 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")) {
12195
+ let i = "cannot ignore child matches, ignore lacks add() method.";
12196
+ throw new Error(i);
12197
+ }
12198
+ this.maxDepth = s.maxDepth || 1 / 0, s.signal && (this.signal = s.signal, this.signal.addEventListener("abort", () => {
12199
+ this.#t.length = 0;
12200
+ }));
12201
+ }
12202
+ #r(t) {
12203
+ return this.seen.has(t) || !!this.#s?.ignored?.(t);
12204
+ }
12205
+ #o(t) {
12206
+ return !!this.#s?.childrenIgnored?.(t);
12207
+ }
12208
+ pause() {
12209
+ this.paused = true;
12210
+ }
12211
+ resume() {
12212
+ if (this.signal?.aborted)
12213
+ return;
12214
+ this.paused = false;
12215
+ let t;
12216
+ for (;!this.paused && (t = this.#t.shift()); )
12217
+ t();
12218
+ }
12219
+ onResume(t) {
12220
+ this.signal?.aborted || (this.paused ? this.#t.push(t) : t());
12221
+ }
12222
+ async matchCheck(t, e) {
12223
+ if (e && this.opts.nodir)
12224
+ return;
12225
+ let s;
12226
+ if (this.opts.realpath) {
12227
+ if (s = t.realpathCached() || await t.realpath(), !s)
12228
+ return;
12229
+ t = s;
12230
+ }
12231
+ let r = t.isUnknown() || this.opts.stat ? await t.lstat() : t;
12232
+ if (this.opts.follow && this.opts.nodir && r?.isSymbolicLink()) {
12233
+ let o = await r.realpath();
12234
+ o && (o.isUnknown() || this.opts.stat) && await o.lstat();
12235
+ }
12236
+ return this.matchCheckTest(r, e);
12237
+ }
12238
+ matchCheckTest(t, e) {
12239
+ 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;
12240
+ }
12241
+ matchCheckSync(t, e) {
12242
+ if (e && this.opts.nodir)
12243
+ return;
12244
+ let s;
12245
+ if (this.opts.realpath) {
12246
+ if (s = t.realpathCached() || t.realpathSync(), !s)
12247
+ return;
12248
+ t = s;
12249
+ }
12250
+ let r = t.isUnknown() || this.opts.stat ? t.lstatSync() : t;
12251
+ if (this.opts.follow && this.opts.nodir && r?.isSymbolicLink()) {
12252
+ let o = r.realpathSync();
12253
+ o && (o?.isUnknown() || this.opts.stat) && o.lstatSync();
12254
+ }
12255
+ return this.matchCheckTest(r, e);
12256
+ }
12257
+ matchFinish(t, e) {
12258
+ if (this.#r(t))
12259
+ return;
12260
+ if (!this.includeChildMatches && this.#s?.add) {
12261
+ let r = `${t.relativePosix()}/**`;
12262
+ this.#s.add(r);
12263
+ }
12264
+ let s = this.opts.absolute === undefined ? e : this.opts.absolute;
12265
+ this.seen.add(t);
12266
+ let i = this.opts.mark && t.isDirectory() ? this.#n : "";
12267
+ if (this.opts.withFileTypes)
12268
+ this.matchEmit(t);
12269
+ else if (s) {
12270
+ let r = this.opts.posix ? t.fullpathPosix() : t.fullpath();
12271
+ this.matchEmit(r + i);
12272
+ } else {
12273
+ let r = this.opts.posix ? t.relativePosix() : t.relative(), o = this.opts.dotRelative && !r.startsWith(".." + this.#n) ? "." + this.#n : "";
12274
+ this.matchEmit(r ? o + r + i : "." + i);
12275
+ }
12276
+ }
12277
+ async match(t, e, s) {
12278
+ let i = await this.matchCheck(t, s);
12279
+ i && this.matchFinish(i, e);
12280
+ }
12281
+ matchSync(t, e, s) {
12282
+ let i = this.matchCheckSync(t, s);
12283
+ i && this.matchFinish(i, e);
12284
+ }
12285
+ walkCB(t, e, s) {
12286
+ this.signal?.aborted && s(), this.walkCB2(t, e, new Et(this.opts), s);
12287
+ }
12288
+ walkCB2(t, e, s, i) {
12289
+ if (this.#o(t))
12290
+ return i();
12291
+ if (this.signal?.aborted && i(), this.paused) {
12292
+ this.onResume(() => this.walkCB2(t, e, s, i));
12293
+ return;
12294
+ }
12295
+ s.processPatterns(t, e);
12296
+ let r = 1, o = () => {
12297
+ --r === 0 && i();
12298
+ };
12299
+ for (let [h, a, l] of s.matches.entries())
12300
+ this.#r(h) || (r++, this.match(h, a, l).then(() => o()));
12301
+ for (let h of s.subwalkTargets()) {
12302
+ if (this.maxDepth !== 1 / 0 && h.depth() >= this.maxDepth)
12303
+ continue;
12304
+ r++;
12305
+ let a = h.readdirCached();
12306
+ h.calledReaddir() ? this.walkCB3(h, a, s, o) : h.readdirCB((l, u) => this.walkCB3(h, u, s, o), true);
12307
+ }
12308
+ o();
12309
+ }
12310
+ walkCB3(t, e, s, i) {
12311
+ s = s.filterEntries(t, e);
12312
+ let r = 1, o = () => {
12313
+ --r === 0 && i();
12314
+ };
12315
+ for (let [h, a, l] of s.matches.entries())
12316
+ this.#r(h) || (r++, this.match(h, a, l).then(() => o()));
12317
+ for (let [h, a] of s.subwalks.entries())
12318
+ r++, this.walkCB2(h, a, s.child(), o);
12319
+ o();
12320
+ }
12321
+ walkCBSync(t, e, s) {
12322
+ this.signal?.aborted && s(), this.walkCB2Sync(t, e, new Et(this.opts), s);
12323
+ }
12324
+ walkCB2Sync(t, e, s, i) {
12325
+ if (this.#o(t))
12326
+ return i();
12327
+ if (this.signal?.aborted && i(), this.paused) {
12328
+ this.onResume(() => this.walkCB2Sync(t, e, s, i));
12329
+ return;
12330
+ }
12331
+ s.processPatterns(t, e);
12332
+ let r = 1, o = () => {
12333
+ --r === 0 && i();
12334
+ };
12335
+ for (let [h, a, l] of s.matches.entries())
12336
+ this.#r(h) || this.matchSync(h, a, l);
12337
+ for (let h of s.subwalkTargets()) {
12338
+ if (this.maxDepth !== 1 / 0 && h.depth() >= this.maxDepth)
12339
+ continue;
12340
+ r++;
12341
+ let a = h.readdirSync();
12342
+ this.walkCB3Sync(h, a, s, o);
12343
+ }
12344
+ o();
12345
+ }
12346
+ walkCB3Sync(t, e, s, i) {
12347
+ s = s.filterEntries(t, e);
12348
+ let r = 1, o = () => {
12349
+ --r === 0 && i();
12350
+ };
12351
+ for (let [h, a, l] of s.matches.entries())
12352
+ this.#r(h) || this.matchSync(h, a, l);
12353
+ for (let [h, a] of s.subwalks.entries())
12354
+ r++, this.walkCB2Sync(h, a, s.child(), o);
12355
+ o();
12356
+ }
12357
+ };
12358
+ var xt = class extends zt {
12359
+ matches = new Set;
12360
+ constructor(t, e, s) {
12361
+ super(t, e, s);
12362
+ }
12363
+ matchEmit(t) {
12364
+ this.matches.add(t);
12365
+ }
12366
+ async walk() {
12367
+ if (this.signal?.aborted)
12368
+ throw this.signal.reason;
12369
+ return this.path.isUnknown() && await this.path.lstat(), await new Promise((t, e) => {
12370
+ this.walkCB(this.path, this.patterns, () => {
12371
+ this.signal?.aborted ? e(this.signal.reason) : t(this.matches);
12372
+ });
12373
+ }), this.matches;
12374
+ }
12375
+ walkSync() {
12376
+ if (this.signal?.aborted)
12377
+ throw this.signal.reason;
12378
+ return this.path.isUnknown() && this.path.lstatSync(), this.walkCBSync(this.path, this.patterns, () => {
12379
+ if (this.signal?.aborted)
12380
+ throw this.signal.reason;
12381
+ }), this.matches;
12382
+ }
12383
+ };
12384
+ var vt = class extends zt {
12385
+ results;
12386
+ constructor(t, e, s) {
12387
+ 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());
12388
+ }
12389
+ matchEmit(t) {
12390
+ this.results.write(t), this.results.flowing || this.pause();
12391
+ }
12392
+ stream() {
12393
+ let t = this.path;
12394
+ return t.isUnknown() ? t.lstat().then(() => {
12395
+ this.walkCB(t, this.patterns, () => this.results.end());
12396
+ }) : this.walkCB(t, this.patterns, () => this.results.end()), this.results;
12397
+ }
12398
+ streamSync() {
12399
+ return this.path.isUnknown() && this.path.lstatSync(), this.walkCBSync(this.path, this.patterns, () => this.results.end()), this.results;
12400
+ }
12401
+ };
12402
+ var Pi = typeof process == "object" && process && typeof process.platform == "string" ? process.platform : "linux";
12403
+ var I = class {
12404
+ absolute;
12405
+ cwd;
12406
+ root;
12407
+ dot;
12408
+ dotRelative;
12409
+ follow;
12410
+ ignore;
12411
+ magicalBraces;
12412
+ mark;
12413
+ matchBase;
12414
+ maxDepth;
12415
+ nobrace;
12416
+ nocase;
12417
+ nodir;
12418
+ noext;
12419
+ noglobstar;
12420
+ pattern;
12421
+ platform;
12422
+ realpath;
12423
+ scurry;
12424
+ stat;
12425
+ signal;
12426
+ windowsPathsNoEscape;
12427
+ withFileTypes;
12428
+ includeChildMatches;
12429
+ opts;
12430
+ patterns;
12431
+ constructor(t, e) {
12432
+ if (!e)
12433
+ throw new TypeError("glob options required");
12434
+ 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)
12435
+ throw new Error("cannot set absolute and withFileTypes:true");
12436
+ if (typeof t == "string" && (t = [t]), this.windowsPathsNoEscape = !!e.windowsPathsNoEscape || e.allowWindowsEscape === false, this.windowsPathsNoEscape && (t = t.map((a) => a.replace(/\\/g, "/"))), this.matchBase) {
12437
+ if (e.noglobstar)
12438
+ throw new TypeError("base matching requires globstar");
12439
+ t = t.map((a) => a.includes("/") ? a : `./**/${a}`);
12440
+ }
12441
+ if (this.pattern = t, this.platform = e.platform || Pi, this.opts = { ...e, platform: this.platform }, e.scurry) {
12442
+ if (this.scurry = e.scurry, e.nocase !== undefined && e.nocase !== e.scurry.nocase)
12443
+ throw new Error("nocase option contradicts provided scurry option");
12444
+ } else {
12445
+ let a = e.platform === "win32" ? it : e.platform === "darwin" ? St : e.platform ? rt : Xe;
12446
+ this.scurry = new a(this.cwd, { nocase: e.nocase, fs: e.fs });
12447
+ }
12448
+ this.nocase = this.scurry.nocase;
12449
+ 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), [[], []]);
12450
+ this.patterns = o.map((a, l) => {
12451
+ let u = h[l];
12452
+ if (!u)
12453
+ throw new Error("invalid pattern object");
12454
+ return new nt(a, u, 0, this.platform);
12455
+ });
12456
+ }
12457
+ async walk() {
12458
+ 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()];
12459
+ }
12460
+ walkSync() {
12461
+ 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()];
12462
+ }
12463
+ stream() {
12464
+ 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();
12465
+ }
12466
+ streamSync() {
12467
+ 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();
12468
+ }
12469
+ iterateSync() {
12470
+ return this.streamSync()[Symbol.iterator]();
12471
+ }
12472
+ [Symbol.iterator]() {
12473
+ return this.iterateSync();
12474
+ }
12475
+ iterate() {
12476
+ return this.stream()[Symbol.asyncIterator]();
12477
+ }
12478
+ [Symbol.asyncIterator]() {
12479
+ return this.iterate();
12480
+ }
12481
+ };
12482
+ var le = (n7, t = {}) => {
12483
+ Array.isArray(n7) || (n7 = [n7]);
12484
+ for (let e of n7)
12485
+ if (new D(e, t).hasMagic())
12486
+ return true;
12487
+ return false;
12488
+ };
12489
+ function Bt(n7, t = {}) {
12490
+ return new I(n7, t).streamSync();
12491
+ }
12492
+ function Qe(n7, t = {}) {
12493
+ return new I(n7, t).stream();
12494
+ }
12495
+ function ts(n7, t = {}) {
12496
+ return new I(n7, t).walkSync();
12497
+ }
12498
+ async function Je(n7, t = {}) {
12499
+ return new I(n7, t).walk();
12500
+ }
12501
+ function Ut(n7, t = {}) {
12502
+ return new I(n7, t).iterateSync();
12503
+ }
12504
+ function es(n7, t = {}) {
12505
+ return new I(n7, t).iterate();
12506
+ }
12507
+ var ji = Bt;
12508
+ var Ii = Object.assign(Qe, { sync: Bt });
12509
+ var zi = Ut;
12510
+ var Bi = Object.assign(es, { sync: Ut });
12511
+ var Ui = Object.assign(ts, { stream: Bt, iterate: Ut });
12512
+ 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 });
12513
+ Ze.glob = Ze;
12514
+
12515
+ // src/scanner/parsers/typescript.ts
12516
+ class TypeScriptParser {
12517
+ extensions = [".ts", ".tsx", ".js", ".jsx"];
12518
+ async parse(filePath, content) {
12519
+ const lines = content.split(`
12520
+ `);
12521
+ const imports = this.extractImports(content);
12522
+ const exports = this.extractExports(content);
12523
+ const components = this.extractComponents(filePath, content);
12524
+ const hooks = this.extractHooks(filePath, content);
12525
+ const file = {
12526
+ path: filePath,
12527
+ language: filePath.endsWith(".tsx") || filePath.endsWith(".jsx") ? "tsx" : "typescript",
12528
+ lines: lines.length,
12529
+ exports,
12530
+ imports
12531
+ };
12532
+ const dependencies = imports.map((imp) => ({
12533
+ from: filePath,
12534
+ to: imp.source,
12535
+ specifiers: imp.specifiers
12536
+ }));
12537
+ return {
12538
+ file,
12539
+ routes: [],
12540
+ components,
12541
+ hooks,
12542
+ dependencies
12543
+ };
12544
+ }
12545
+ extractImports(content) {
12546
+ const imports = [];
12547
+ const importRegex = /^import\s+(?:(?:(\w+)|(\{[^}]+\})|\*\s+as\s+(\w+))\s+from\s+)?["']([^"']+)["']/gm;
12548
+ let match;
12549
+ while ((match = importRegex.exec(content)) !== null) {
12550
+ const defaultImport = match[1];
12551
+ const namedImports = match[2];
12552
+ const namespaceImport = match[3];
12553
+ const source = match[4];
12554
+ const specifiers = [];
12555
+ let isDefault = false;
12556
+ if (defaultImport) {
12557
+ specifiers.push(defaultImport);
12558
+ isDefault = true;
12559
+ }
12560
+ if (namedImports) {
12561
+ const names = namedImports.replace(/[{}]/g, "").split(",").map((s) => s.trim().split(/\s+as\s+/)[0].trim()).filter(Boolean);
12562
+ specifiers.push(...names);
12563
+ }
12564
+ if (namespaceImport) {
12565
+ specifiers.push(`* as ${namespaceImport}`);
12566
+ }
12567
+ imports.push({ source, specifiers, isDefault });
12568
+ }
12569
+ return imports;
12570
+ }
12571
+ extractExports(content) {
12572
+ const exports = [];
12573
+ const namedExportRegex = /^export\s+(?:default\s+)?(?:async\s+)?(?:function|const|let|var|class|type|interface|enum)\s+(\w+)/gm;
12574
+ let match;
12575
+ while ((match = namedExportRegex.exec(content)) !== null) {
12576
+ exports.push(match[1]);
12577
+ }
12578
+ if (/^export\s+default\s+/m.test(content)) {
12579
+ if (!exports.includes("default")) {
12580
+ exports.push("default");
12581
+ }
12582
+ }
12583
+ const reExportRegex = /^export\s+\{([^}]+)\}/gm;
12584
+ while ((match = reExportRegex.exec(content)) !== null) {
12585
+ const names = match[1].split(",").map((s) => s.trim().split(/\s+as\s+/).pop()?.trim()).filter((s) => !!s);
12586
+ exports.push(...names);
12587
+ }
12588
+ return [...new Set(exports)];
12589
+ }
12590
+ extractComponents(filePath, content) {
12591
+ const components = [];
12592
+ const isTSX = filePath.endsWith(".tsx") || filePath.endsWith(".jsx");
12593
+ if (!isTSX && !content.includes("React.createElement"))
12594
+ return components;
12595
+ const funcComponentRegex = /(?:export\s+(?:default\s+)?)?(?:async\s+)?function\s+([A-Z]\w+)\s*\(([^)]*)\)/g;
12596
+ const arrowComponentRegex = /(?:export\s+(?:default\s+)?)?(?:const|let)\s+([A-Z]\w+)\s*(?::\s*\w+(?:<[^>]+>)?\s*)?=\s*(?:\([^)]*\)|(\w+))\s*(?::\s*\w+(?:<[^>]+>)?\s*)?=>/g;
12597
+ let match;
12598
+ while ((match = funcComponentRegex.exec(content)) !== null) {
12599
+ const name = match[1];
12600
+ const paramsStr = match[2];
12601
+ components.push({
12602
+ name,
12603
+ filePath,
12604
+ props: this.extractPropsFromParams(paramsStr, content),
12605
+ isExported: content.includes("export") && content.substring(Math.max(0, match.index - 30), match.index + match[0].length).includes("export"),
12606
+ hasJSX: true,
12607
+ hookCalls: this.extractHookCalls(content, match.index)
12608
+ });
12609
+ }
12610
+ while ((match = arrowComponentRegex.exec(content)) !== null) {
12611
+ const name = match[1];
12612
+ components.push({
12613
+ name,
12614
+ filePath,
12615
+ props: this.extractPropsFromContext(name, content),
12616
+ isExported: content.substring(Math.max(0, match.index - 20), match.index + match[0].length).includes("export"),
12617
+ hasJSX: true,
12618
+ hookCalls: this.extractHookCalls(content, match.index)
12619
+ });
12620
+ }
12621
+ return components;
12622
+ }
12623
+ extractPropsFromParams(paramsStr, _content) {
12624
+ if (!paramsStr.trim())
12625
+ return [];
12626
+ const destructured = paramsStr.match(/\{\s*([^}]+)\s*\}/);
12627
+ if (destructured) {
12628
+ return destructured[1].split(",").map((p) => p.trim().split(/[=:]/)[0].trim()).filter(Boolean);
12629
+ }
12630
+ const typed = paramsStr.match(/(\w+)\s*:\s*(\w+)/);
12631
+ if (typed) {
12632
+ return [typed[1]];
12633
+ }
12634
+ return [];
12635
+ }
12636
+ extractPropsFromContext(componentName, content) {
12637
+ const propsTypeRegex = new RegExp(`(?:interface|type)\\s+${componentName}Props\\s*(?:=\\s*)?\\{([^}]+)\\}`);
12638
+ const match = content.match(propsTypeRegex);
12639
+ if (match) {
12640
+ return match[1].split(/[;\n]/).map((line) => line.trim().split(/[?:]/)[0].trim()).filter(Boolean);
12641
+ }
12642
+ return [];
12643
+ }
12644
+ extractHookCalls(content, startIndex) {
12645
+ const hookCalls = [];
12646
+ const bodyStart = content.indexOf("{", startIndex);
12647
+ if (bodyStart === -1)
12648
+ return hookCalls;
12649
+ let depth = 0;
12650
+ let bodyEnd = bodyStart;
12651
+ for (let i = bodyStart;i < content.length; i++) {
12652
+ if (content[i] === "{")
12653
+ depth++;
12654
+ if (content[i] === "}")
12655
+ depth--;
12656
+ if (depth === 0) {
12657
+ bodyEnd = i;
12658
+ break;
12659
+ }
12660
+ }
12661
+ const body = content.substring(bodyStart, bodyEnd);
12662
+ const hookRegex = /\b(use\w+)\s*\(/g;
12663
+ let match;
12664
+ while ((match = hookRegex.exec(body)) !== null) {
12665
+ if (!hookCalls.includes(match[1])) {
12666
+ hookCalls.push(match[1]);
12667
+ }
12668
+ }
12669
+ return hookCalls;
12670
+ }
12671
+ extractHooks(filePath, content) {
12672
+ const hooks = [];
12673
+ const hookDefRegex = /(?:export\s+)?(?:function|const)\s+(use[A-Z]\w+)/g;
12674
+ let match;
12675
+ while ((match = hookDefRegex.exec(content)) !== null) {
12676
+ const name = match[1];
12677
+ const bodyStart = content.indexOf("{", match.index);
12678
+ if (bodyStart === -1)
12679
+ continue;
12680
+ const deps = [];
12681
+ let depth = 0;
12682
+ let bodyEnd = bodyStart;
12683
+ for (let i = bodyStart;i < content.length; i++) {
12684
+ if (content[i] === "{")
12685
+ depth++;
12686
+ if (content[i] === "}")
12687
+ depth--;
12688
+ if (depth === 0) {
12689
+ bodyEnd = i;
12690
+ break;
12691
+ }
12692
+ }
12693
+ const body = content.substring(bodyStart, bodyEnd);
12694
+ const depRegex = /\b(use\w+)\s*\(/g;
12695
+ let depMatch;
12696
+ while ((depMatch = depRegex.exec(body)) !== null) {
12697
+ if (depMatch[1] !== name && !deps.includes(depMatch[1])) {
12698
+ deps.push(depMatch[1]);
12699
+ }
12700
+ }
12701
+ hooks.push({
12702
+ name,
12703
+ filePath,
12704
+ isCustom: true,
12705
+ dependencies: deps
12706
+ });
12707
+ }
12708
+ return hooks;
12709
+ }
12710
+ }
12711
+
12712
+ // src/scanner/extractors/routes.ts
12713
+ import { readdirSync as readdirSync3, statSync, readFileSync as readFileSync3 } from "node:fs";
12714
+ import { join as join14, relative, basename as basename3, dirname as dirname4 } from "node:path";
12715
+ function extractRoutes(scanDir) {
12716
+ const routes = [];
12717
+ const appDirs = ["app", "src/app"].map((d) => join14(scanDir, d));
12718
+ for (const appDir of appDirs) {
12719
+ try {
12720
+ if (statSync(appDir).isDirectory()) {
12721
+ extractAppRouterRoutes(appDir, appDir, routes);
12722
+ }
12723
+ } catch {}
12724
+ }
12725
+ const pagesDirs = ["pages", "src/pages"].map((d) => join14(scanDir, d));
12726
+ for (const pagesDir of pagesDirs) {
12727
+ try {
12728
+ if (statSync(pagesDir).isDirectory()) {
12729
+ extractPagesRouterRoutes(pagesDir, pagesDir, routes);
12730
+ }
12731
+ } catch {}
12732
+ }
12733
+ return routes;
12734
+ }
12735
+ function extractAppRouterRoutes(dir, baseDir, routes) {
12736
+ const entries = readdirSync3(dir, { withFileTypes: true });
12737
+ for (const entry of entries) {
12738
+ const fullPath = join14(dir, entry.name);
12739
+ if (entry.isDirectory()) {
12740
+ extractAppRouterRoutes(fullPath, baseDir, routes);
12741
+ continue;
12742
+ }
12743
+ const name = basename3(entry.name, entry.name.substring(entry.name.indexOf(".")));
12744
+ const ext = entry.name.substring(entry.name.indexOf("."));
12745
+ if (![".ts", ".tsx", ".js", ".jsx"].some((e) => entry.name.endsWith(e)))
12746
+ continue;
12747
+ if (name === "page") {
12748
+ const routePath = dirToRoutePath(relative(baseDir, dir));
12749
+ const layoutFile = findLayoutFile(dir, baseDir);
12750
+ routes.push({
12751
+ path: routePath,
12752
+ filePath: relative(process.cwd(), fullPath),
12753
+ isDynamic: routePath.includes("["),
12754
+ layoutFile: layoutFile ? relative(process.cwd(), layoutFile) : undefined
12755
+ });
12756
+ }
12757
+ if (name === "route") {
12758
+ const routePath = dirToRoutePath(relative(baseDir, dir));
12759
+ const methods = extractApiMethods(fullPath);
12760
+ for (const method of methods) {
12761
+ routes.push({
12762
+ path: routePath,
12763
+ filePath: relative(process.cwd(), fullPath),
12764
+ method,
12765
+ isDynamic: routePath.includes("[")
12766
+ });
12767
+ }
12768
+ }
12769
+ }
12770
+ }
12771
+ function extractPagesRouterRoutes(dir, baseDir, routes) {
12772
+ const entries = readdirSync3(dir, { withFileTypes: true });
12773
+ for (const entry of entries) {
12774
+ const fullPath = join14(dir, entry.name);
12775
+ if (entry.isDirectory()) {
12776
+ if (entry.name === "api") {
12777
+ extractPagesApiRoutes(fullPath, baseDir, routes);
12778
+ } else {
12779
+ extractPagesRouterRoutes(fullPath, baseDir, routes);
12780
+ }
12781
+ continue;
12782
+ }
12783
+ if (![".ts", ".tsx", ".js", ".jsx"].some((e) => entry.name.endsWith(e)))
12784
+ continue;
12785
+ if (entry.name.startsWith("_"))
12786
+ continue;
12787
+ const name = basename3(entry.name).replace(/\.(ts|tsx|js|jsx)$/, "");
12788
+ const relDir = relative(baseDir, dir);
12789
+ const routePath = `/${relDir ? relDir + "/" : ""}${name === "index" ? "" : name}`.replace(/\/+/g, "/") || "/";
12790
+ routes.push({
12791
+ path: routePath,
12792
+ filePath: relative(process.cwd(), fullPath),
12793
+ isDynamic: routePath.includes("[")
12794
+ });
12795
+ }
12796
+ }
12797
+ function extractPagesApiRoutes(dir, baseDir, routes) {
12798
+ const entries = readdirSync3(dir, { withFileTypes: true });
12799
+ for (const entry of entries) {
12800
+ const fullPath = join14(dir, entry.name);
12801
+ if (entry.isDirectory()) {
12802
+ extractPagesApiRoutes(fullPath, baseDir, routes);
12803
+ continue;
12804
+ }
12805
+ if (![".ts", ".tsx", ".js", ".jsx"].some((e) => entry.name.endsWith(e)))
12806
+ continue;
12807
+ const name = basename3(entry.name).replace(/\.(ts|tsx|js|jsx)$/, "");
12808
+ const relDir = relative(baseDir, dir);
12809
+ const routePath = `/${relDir ? relDir + "/" : ""}${name === "index" ? "" : name}`.replace(/\/+/g, "/");
12810
+ routes.push({
12811
+ path: routePath,
12812
+ filePath: relative(process.cwd(), fullPath),
12813
+ method: "handler",
12814
+ isDynamic: routePath.includes("[")
12815
+ });
12816
+ }
12817
+ }
12818
+ function dirToRoutePath(relPath) {
12819
+ if (!relPath)
12820
+ return "/";
12821
+ const cleaned = relPath.split("/").filter((segment) => !segment.startsWith("(")).join("/");
12822
+ return `/${cleaned}` || "/";
12823
+ }
12824
+ function findLayoutFile(dir, baseDir) {
12825
+ let current = dir;
12826
+ while (current.startsWith(baseDir)) {
12827
+ for (const ext of [".tsx", ".ts", ".jsx", ".js"]) {
12828
+ const layoutPath = join14(current, `layout${ext}`);
12829
+ try {
12830
+ statSync(layoutPath);
12831
+ return layoutPath;
12832
+ } catch {}
12833
+ }
12834
+ current = dirname4(current);
12835
+ }
12836
+ return;
12837
+ }
12838
+ function extractApiMethods(filePath) {
12839
+ try {
12840
+ const content = readFileSync3(filePath, "utf-8");
12841
+ const methods = [];
12842
+ const methodRegex = /export\s+(?:async\s+)?function\s+(GET|POST|PUT|PATCH|DELETE|HEAD|OPTIONS)\b/g;
12843
+ let match;
12844
+ while ((match = methodRegex.exec(content)) !== null) {
12845
+ methods.push(match[1]);
12846
+ }
12847
+ return methods.length > 0 ? methods : ["handler"];
12848
+ } catch {
12849
+ return ["handler"];
12850
+ }
12851
+ }
12852
+ // src/scanner/scanner.ts
12853
+ async function runStage1(config) {
12854
+ const scanDir = resolve(config.scanDir);
12855
+ const cacheDir = resolve(config.cacheDir, "ast");
12856
+ mkdirSync2(cacheDir, { recursive: true });
12857
+ const manifestPath = resolve(cacheDir, "manifest.json");
12858
+ let manifest = { files: {} };
12859
+ if (existsSync3(manifestPath)) {
12860
+ try {
12861
+ manifest = JSON.parse(readFileSync4(manifestPath, "utf-8"));
12862
+ } catch {
12863
+ manifest = { files: {} };
12864
+ }
12865
+ }
12866
+ const files = collectFiles(scanDir, config.include, config.exclude);
12867
+ verbose(`Found ${files.length} files to scan`);
12868
+ const parser = new TypeScriptParser;
12869
+ const allFiles = [];
12870
+ const allComponents = [];
12871
+ const allHooks = [];
12872
+ const allDependencies = [];
12873
+ let totalLines = 0;
12874
+ let cachedCount = 0;
12875
+ for (const filePath of files) {
12876
+ const content = readFileSync4(filePath, "utf-8");
12877
+ const hash = createHash("md5").update(content).digest("hex");
12878
+ const relPath = relative2(process.cwd(), filePath);
12879
+ const cached = manifest.files[relPath];
12880
+ if (cached && cached.hash === hash) {
12881
+ const cacheFile = resolve(cacheDir, cached.resultFile);
12882
+ if (existsSync3(cacheFile)) {
12883
+ try {
12884
+ const cachedResult = JSON.parse(readFileSync4(cacheFile, "utf-8"));
12885
+ allFiles.push(cachedResult.file);
12886
+ allComponents.push(...cachedResult.components);
12887
+ allHooks.push(...cachedResult.hooks);
12888
+ allDependencies.push(...cachedResult.dependencies);
12889
+ totalLines += cachedResult.file.lines;
12890
+ cachedCount++;
12891
+ continue;
12892
+ } catch {}
12893
+ }
12894
+ }
12895
+ const result = await parser.parse(relPath, content);
12896
+ allFiles.push(result.file);
12897
+ allComponents.push(...result.components);
12898
+ allHooks.push(...result.hooks);
12899
+ allDependencies.push(...result.dependencies);
12900
+ totalLines += result.file.lines;
12901
+ const resultFile = `${hash}.json`;
12902
+ writeFileSync2(resolve(cacheDir, resultFile), JSON.stringify({
12903
+ file: result.file,
12904
+ components: result.components,
12905
+ hooks: result.hooks,
12906
+ dependencies: result.dependencies
12907
+ }));
12908
+ manifest.files[relPath] = { hash, resultFile };
12909
+ }
12910
+ writeFileSync2(manifestPath, JSON.stringify(manifest, null, 2));
12911
+ if (cachedCount > 0) {
12912
+ verbose(`${cachedCount} files from cache, ${files.length - cachedCount} re-parsed`);
12913
+ }
12914
+ const routes = extractRoutes(scanDir);
12915
+ verbose(`Found ${routes.length} routes`);
12916
+ verbose(`Found ${allComponents.length} components`);
12917
+ verbose(`Found ${allHooks.length} custom hooks`);
12918
+ return {
12919
+ version: "1.0",
12920
+ scannedAt: new Date().toISOString(),
12921
+ language: "typescript",
12922
+ stats: { totalFiles: files.length, totalLines },
12923
+ files: allFiles,
12924
+ routes,
12925
+ components: allComponents,
12926
+ hooks: allHooks,
12927
+ dependencies: allDependencies
12928
+ };
12929
+ }
12930
+ function collectFiles(dir, includePatterns, excludePatterns) {
12931
+ const files = [];
12932
+ for (const pattern of includePatterns) {
12933
+ const matches = ts(pattern, {
12934
+ cwd: dir,
12935
+ absolute: true,
12936
+ ignore: excludePatterns
12937
+ });
12938
+ files.push(...matches);
12939
+ }
12940
+ return [...new Set(files)].sort();
12941
+ }
12942
+
12943
+ // src/commands/scan.ts
12944
+ function registerScan(program2) {
12945
+ program2.command("scan").description("Scan codebase AST (routes, components, hooks, imports)").option("--output <file>", "Write output to specific file").option("--scan-dir <dir>", "Directory to scan (default: from config)").option("--no-cache", "Disable file-level caching").action(async (opts) => {
12946
+ const ctx = await resolveCommandContext(program2);
12947
+ const root = ctx.paths.projectRoot;
12948
+ const scanDir = opts.scanDir ?? ctx.config.scanner.scanDir;
12949
+ const cacheDir = join15(root, ctx.config.scanner.cacheDir);
12950
+ const scanConfig = {
12951
+ scanDir: join15(root, scanDir),
12952
+ include: ctx.config.scanner.include,
12953
+ exclude: ctx.config.scanner.exclude,
12954
+ cacheDir: opts.cache === false ? join15(cacheDir, `no-cache-${Date.now()}`) : cacheDir
12955
+ };
12956
+ const spinner = createSpinner();
12957
+ spinner.start("Scanning codebase...");
12958
+ const ast = await runStage1(scanConfig);
12959
+ spinner.stop();
12960
+ const outputPath = opts.output ?? (ctx.key ? join15(ctx.paths.workingDir, ctx.key, "ast-scan.json") : join15(root, ".e2e-ai", "ast-scan.json"));
12961
+ writeFile(outputPath, JSON.stringify(ast, null, 2));
12962
+ success(`AST written to ${outputPath}`);
12963
+ info(` Files: ${ast.stats.totalFiles} (${ast.stats.totalLines} lines)`);
12964
+ info(` Routes: ${ast.routes.length}`);
12965
+ info(` Components: ${ast.components.length}`);
12966
+ info(` Hooks: ${ast.hooks.length}`);
12967
+ });
12968
+ }
12969
+
12970
+ // src/commands/push.ts
12971
+ import { join as join16 } from "node:path";
12972
+
12973
+ // src/scanner/push.ts
12974
+ async function pushToApi(payload, apiUrl, apiKey) {
12975
+ const response = await fetch(apiUrl, {
12976
+ method: "POST",
12977
+ headers: {
12978
+ "Content-Type": "application/json",
12979
+ Authorization: `Bearer ${apiKey}`
12980
+ },
12981
+ body: JSON.stringify(payload)
12982
+ });
12983
+ if (!response.ok) {
12984
+ const body = await response.text();
12985
+ throw new Error(`Push failed (${response.status}): ${body}`);
12986
+ }
12987
+ return response.json();
12988
+ }
12989
+
12990
+ // src/commands/push.ts
12991
+ function registerPush(program2) {
12992
+ program2.command("push [input]").description("Push QA map to remote API").option("--commit-sha <sha>", "Git commit SHA to associate").action(async (inputArg, opts) => {
12993
+ const ctx = await resolveCommandContext(program2);
12994
+ const apiUrl = ctx.config.push?.apiUrl ?? process.env.E2E_AI_API_URL;
12995
+ const apiKey = ctx.config.push?.apiKey ?? process.env.E2E_AI_API_KEY;
12996
+ if (!apiUrl) {
12997
+ error("No push.apiUrl configured. Set it in e2e-ai.config.ts or E2E_AI_API_URL env var.");
12998
+ process.exit(1);
12999
+ }
13000
+ if (!apiKey) {
13001
+ error("No push.apiKey configured. Set it in e2e-ai.config.ts or E2E_AI_API_KEY env var.");
13002
+ process.exit(1);
13003
+ }
13004
+ const root = ctx.paths.projectRoot;
13005
+ let inputPath;
13006
+ if (inputArg) {
13007
+ inputPath = join16(root, inputArg);
13008
+ } else if (ctx.key) {
13009
+ inputPath = join16(ctx.paths.workingDir, ctx.key, "qa-map.json");
13010
+ } else {
13011
+ inputPath = join16(root, ".e2e-ai", "qa-map.json");
13012
+ }
13013
+ if (!fileExists(inputPath)) {
13014
+ error(`QA map not found: ${inputPath}`);
13015
+ process.exit(1);
13016
+ }
13017
+ const payload = JSON.parse(readFile(inputPath));
13018
+ if (opts?.commitSha) {
13019
+ payload.commitSha = opts.commitSha;
13020
+ }
13021
+ info(`Pushing: ${payload.features.length} features, ${payload.workflows.length} workflows, ${payload.scenarios.length} scenarios`);
13022
+ const spinner = createSpinner();
13023
+ spinner.start("Pushing to API...");
13024
+ const result = await pushToApi(payload, apiUrl, apiKey);
13025
+ spinner.stop();
13026
+ success("Push successful!");
13027
+ info(` Version: ${result.version} (schema v${result.schemaVersion})`);
13028
+ info(` Auto-linked scenarios: ${result.stats.autoLinkedScenarios}`);
13029
+ });
13030
+ }
13031
+
13032
+ // src/commands/analyze.ts
13033
+ import { join as join17 } from "node:path";
13034
+ function registerAnalyze(program2) {
13035
+ program2.command("analyze [input]").description("Analyze AST scan with AI to generate QA map (features, workflows, scenarios)").option("--output <file>", "Write QA map to specific file").option("--skip-scenarios", "Only run feature analysis (skip scenario generation)").action(async (inputArg, opts) => {
13036
+ const ctx = await resolveCommandContext(program2);
13037
+ const root = ctx.paths.projectRoot;
13038
+ let inputPath;
13039
+ if (inputArg) {
13040
+ inputPath = join17(root, inputArg);
13041
+ } else if (ctx.key) {
13042
+ inputPath = join17(ctx.paths.workingDir, ctx.key, "ast-scan.json");
13043
+ } else {
13044
+ inputPath = join17(root, ".e2e-ai", "ast-scan.json");
13045
+ }
13046
+ if (!fileExists(inputPath)) {
13047
+ error(`AST scan not found: ${inputPath}. Run "e2e-ai scan" first.`);
13048
+ process.exit(1);
13049
+ }
13050
+ const ast = JSON.parse(readFile(inputPath));
13051
+ const spinner = createSpinner();
13052
+ spinner.start("Analyzing features and workflows...");
13053
+ const featureAgent = loadAgent("feature-analyzer-agent", ctx.config);
13054
+ const featureResponse = await callLLM({
13055
+ provider: ctx.provider,
13056
+ model: ctx.model ?? featureAgent.config.model,
13057
+ systemPrompt: featureAgent.systemPrompt,
13058
+ userMessage: JSON.stringify({ ast }),
13059
+ maxTokens: featureAgent.config.maxTokens,
13060
+ temperature: featureAgent.config.temperature,
13061
+ jsonMode: true
13062
+ });
13063
+ spinner.stop();
13064
+ const qaMap = JSON.parse(extractJSON(featureResponse.content));
13065
+ if (!qaMap?.features) {
13066
+ error("Feature analysis failed: invalid response");
13067
+ process.exit(1);
13068
+ }
13069
+ success(`Identified ${qaMap.features.length} features, ${qaMap.workflows.length} workflows, ${qaMap.components.length} components`);
13070
+ let finalPayload = qaMap;
13071
+ if (!opts?.skipScenarios) {
13072
+ spinner.start("Generating test scenarios...");
13073
+ const scenarioAgent = loadAgent("scenario-planner-agent", ctx.config);
13074
+ const scenarioResponse = await callLLM({
13075
+ provider: ctx.provider,
13076
+ model: ctx.model ?? scenarioAgent.config.model,
13077
+ systemPrompt: scenarioAgent.systemPrompt,
13078
+ userMessage: JSON.stringify(qaMap),
13079
+ maxTokens: scenarioAgent.config.maxTokens,
13080
+ temperature: scenarioAgent.config.temperature,
13081
+ jsonMode: true
13082
+ });
13083
+ spinner.stop();
13084
+ try {
13085
+ finalPayload = JSON.parse(extractJSON(scenarioResponse.content));
13086
+ } catch {
13087
+ warn("Scenario generation returned invalid JSON, using feature map only");
13088
+ finalPayload = { ...qaMap, scenarios: [] };
13089
+ }
13090
+ if (!finalPayload?.scenarios) {
13091
+ warn("Scenario generation returned no scenarios, using feature map only");
13092
+ finalPayload = { ...qaMap, scenarios: [] };
13093
+ } else {
13094
+ success(`Generated ${finalPayload.scenarios.length} scenarios`);
13095
+ }
13096
+ } else {
13097
+ finalPayload = { ...qaMap, scenarios: [] };
13098
+ }
13099
+ const outputPath = opts?.output ?? (ctx.key ? join17(ctx.paths.workingDir, ctx.key, "qa-map.json") : join17(root, ".e2e-ai", "qa-map.json"));
13100
+ writeFile(outputPath, JSON.stringify(finalPayload, null, 2));
13101
+ success(`QA map written to ${outputPath}`);
13102
+ });
13103
+ }
13104
+
9354
13105
  // src/cli.ts
9355
13106
  var program2 = new Command;
9356
13107
  program2.name("e2e-ai").description("AI-powered E2E test automation pipeline").version("1.0.0").option("-k, --key <KEY>", "Issue key (e.g., PROJ-101, LIN-42)").option("--provider <provider>", "LLM provider (openai|anthropic)", process.env.AI_PROVIDER).option("--model <model>", "LLM model override", process.env.AI_MODEL).option("-v, --verbose", "Verbose output").option("--no-voice", "Disable voice recording").option("--no-trace", "Disable trace replay").hook("preAction", () => {
@@ -9371,4 +13122,7 @@ registerTest(program2);
9371
13122
  registerHeal(program2);
9372
13123
  registerQa(program2);
9373
13124
  registerRun(program2);
13125
+ registerScan(program2);
13126
+ registerPush(program2);
13127
+ registerAnalyze(program2);
9374
13128
  program2.parse();