@vite-hub/kv 0.5.0 → 0.6.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.
Files changed (61) hide show
  1. package/README.md +2 -2
  2. package/dist/{batch--v0ri69O.js → batch-D-ib5_0P.js} +0 -1
  3. package/dist/{cli-CLomw9ml.d.ts → cli-BvVInMht.d.ts} +0 -6
  4. package/dist/cli.d.ts +2 -4
  5. package/dist/cli.js +5 -6
  6. package/dist/{cloudflare-env-Dl349h_9.js → cloudflare-env-Cpy3Bqdn.js} +3 -5
  7. package/dist/{cloudflare-env-lookup-Bs0VDpU5.js → cloudflare-env-lookup-Dgq5n1Aq.js} +1 -2
  8. package/dist/{cloudflare-kv-DQJhmGof.js → cloudflare-kv-Cp8HPUlJ.js} +8 -10
  9. package/dist/{cloudflare-kv-local-COjgHweC.js → cloudflare-kv-local-COoOI34K.js} +5 -6
  10. package/dist/{config-pfyPiPrI.js → config-_1oBDv2R.js} +7 -11
  11. package/dist/{create-storage-DQ1BbFqH.js → create-storage-DbWVAY9l.js} +9 -15
  12. package/dist/{cursor-history-CAT4mpP1.js → cursor-history-CMcEEnTO.js} +3 -4
  13. package/dist/{runtime/database.js → database-4iAg2GoV.js} +25 -52
  14. package/dist/{deno-kv-Cf0ZveeN.js → deno-kv-CatE7zSS.js} +4 -5
  15. package/dist/{dev-peer-CHafxbtj.js → dev-peer-D0vOxmrD.js} +1 -2
  16. package/dist/driver-BruahGvT.d.ts +13 -0
  17. package/dist/durability.d.ts +1 -3
  18. package/dist/durability.js +1 -2
  19. package/dist/{error-diagnostics-C4VTHInS.js → error-diagnostics-CuVl1nvE.js} +3 -4
  20. package/dist/{errors-BpiM-Vmh.js → errors-CJoAP4Bu.js} +4 -7
  21. package/dist/errors.d.ts +2 -6
  22. package/dist/errors.js +1 -2
  23. package/dist/fs-lite-DwbPkc-C.js +1 -0
  24. package/dist/{fs-lite-BTcBUP6B.js → fs-lite-DzTTR6R3.js} +3 -5
  25. package/dist/index.d.ts +1 -3
  26. package/dist/index.js +17 -21
  27. package/dist/{inspect-BIKQsqX4.js → inspect-BWMcVWD8.js} +2 -4
  28. package/dist/{invariant-DolT9EEx.js → invariant-Dj2R1eMr.js} +1 -2
  29. package/dist/{object-Da1zyPCR.js → object-CAK6UYR5.js} +1 -2
  30. package/dist/{operation-definition-CI2PJGqu.d.ts → operation-definition-CqZkx1Rm.d.ts} +0 -4
  31. package/dist/{operations-nAaONxzh.js → operations-BkVt17cd.js} +24 -25
  32. package/dist/{operations-CqKs7Ykc.js → operations-DSOTGwST.js} +7 -10
  33. package/dist/operations.d.ts +2 -8
  34. package/dist/operations.js +8 -12
  35. package/dist/{out-BbXG-yVX.js → out-By90R-Bo.js} +3345 -2394
  36. package/dist/{redis-shared-1M0IaguQ.js → redis-shared-CR3ANc_N.js} +2 -3
  37. package/dist/{request-log-Dj9Vw7qG.js → request-log-DllKQXj7.js} +1 -2
  38. package/dist/{results-D6jfPtCk.js → results-emgN7uDS.js} +1 -2
  39. package/dist/{rolldown-runtime-CMFfr-1z.js → rolldown-runtime-DegdyBIC.js} +2 -3
  40. package/dist/runtime/cloudflare-kv.d.ts +1 -3
  41. package/dist/runtime/cloudflare-kv.js +1 -2
  42. package/dist/runtime/cloudflare-request-env.d.ts +1 -3
  43. package/dist/runtime/cloudflare-request-env.js +2 -3
  44. package/dist/runtime/nitro-plugin.d.ts +1 -2
  45. package/dist/runtime/nitro-plugin.js +3 -4
  46. package/dist/runtime/redis-driver.d.ts +3 -5
  47. package/dist/runtime/redis-driver.js +6 -7
  48. package/dist/runtime/unstorage-driver.d.ts +2 -4
  49. package/dist/runtime/unstorage-driver.js +2 -3
  50. package/dist/runtime/upstash-driver.d.ts +3 -5
  51. package/dist/runtime/upstash-driver.js +6 -7
  52. package/dist/{types-Bj3EQoRg.d.ts → types-BUb0FcjM.d.ts} +0 -2
  53. package/dist/{types-Cp6IBhSN.d.ts → types-CPDL9enF.d.ts} +2 -4
  54. package/dist/{upstash-5sTbIR35.js → upstash-DeM3_U5H.js} +3 -4
  55. package/dist/{utils2-FozcTsmb.js → utils2-By8eee1x.js} +1 -2
  56. package/dist/vite.d.ts +3 -17
  57. package/dist/vite.js +1444 -923
  58. package/package.json +10 -15
  59. package/dist/driver-Du6Eh9p2.d.ts +0 -47
  60. package/dist/fs-lite-C8yXCVDM.js +0 -2
  61. package/dist/runtime/database.d.ts +0 -2
package/dist/vite.js CHANGED
@@ -1,12 +1,12 @@
1
- import { r as __toESM } from "./rolldown-runtime-CMFfr-1z.js";
2
- import { a as resolve$1, i as relative$1, n as relativeDefinitionFile, r as dirname$1 } from "./inspect-BIKQsqX4.js";
3
- import { C as resolveViteHubProjectRoot, N as writeViteHubDevServerFile, P as internalErrorDiagnostics, S as markViteConfigPlugin, b as hasNitroConfigContext, j as removeViteHubDevServerFile, k as readViteHubDevServerFile, p as operationRpcPath, r as collectOperationContributions, v as VITEHUB_PROJECT_ROOT, w as shouldSkipViteProviderBuild, x as isServerEnvironment, y as createNoExternalAddition } from "./operations-nAaONxzh.js";
4
- import { n as isRecordOrFunction, t as isRecord } from "./object-Da1zyPCR.js";
5
- import { n as invariantError, t as invariant } from "./invariant-DolT9EEx.js";
6
- import { n as kvErrorDiagnostics } from "./error-diagnostics-C4VTHInS.js";
7
- import { a as upstashUrlEnvNames, i as upstashTokenEnvNames, n as kvRedisEnvHint, o as resolveHostPreset, r as normalizeKVOptions } from "./config-pfyPiPrI.js";
8
- import { n as resolveUpstashRuntimeValues } from "./upstash-5sTbIR35.js";
9
- import { t as addViteHubDevPeerDevHandler } from "./dev-peer-CHafxbtj.js";
1
+ import { r as __toESM } from "./rolldown-runtime-DegdyBIC.js";
2
+ import { n as invariantError, t as invariant } from "./invariant-Dj2R1eMr.js";
3
+ import { a as resolve$1, i as relative$1, n as relativeDefinitionFile, r as dirname$1 } from "./inspect-BWMcVWD8.js";
4
+ import { t as addViteHubDevPeerDevHandler } from "./dev-peer-D0vOxmrD.js";
5
+ import { n as isRecordOrFunction, t as isRecord } from "./object-CAK6UYR5.js";
6
+ import { C as resolveViteHubProjectRoot, N as writeViteHubDevServerFile, P as internalErrorDiagnostics, S as markViteConfigPlugin, b as hasNitroConfigContext, j as removeViteHubDevServerFile, k as readViteHubDevServerFile, p as operationRpcPath, r as collectOperationContributions, v as VITEHUB_PROJECT_ROOT, w as shouldSkipViteProviderBuild, x as isServerEnvironment, y as createNoExternalAddition } from "./operations-BkVt17cd.js";
7
+ import { a as upstashUrlEnvNames, i as upstashTokenEnvNames, n as kvRedisEnvHint, o as resolveHostPreset, r as normalizeKVOptions } from "./config-_1oBDv2R.js";
8
+ import { n as kvErrorDiagnostics } from "./error-diagnostics-CuVl1nvE.js";
9
+ import { n as resolveUpstashRuntimeValues } from "./upstash-DeM3_U5H.js";
10
10
  import { createRequire, isBuiltin } from "node:module";
11
11
  import { access, copyFile, cp, mkdir, mkdtemp, readFile, readdir, realpath, rename, rm, rmdir, stat, writeFile } from "node:fs/promises";
12
12
  import { basename, dirname, isAbsolute, join, relative, resolve, sep } from "node:path";
@@ -15,7 +15,7 @@ import { formatDiagnostic } from "nostics";
15
15
  import { tmpdir } from "node:os";
16
16
  import { fileURLToPath, pathToFileURL } from "node:url";
17
17
  import { createHash } from "node:crypto";
18
- //#region ../internal/src/build/paths.ts
18
+ // ../internal/src/build/paths.ts
19
19
  function resolveRuntimeModule(packageDir, modulePath) {
20
20
  const distFile = resolve$1(packageDir, "dist", `${modulePath}.js`);
21
21
  return existsSync(distFile) ? distFile : resolve$1(packageDir, "src", `${modulePath}.ts`);
@@ -42,8 +42,7 @@ function findPackageDir(file) {
42
42
  function ownModule(importMetaUrl, modulePath) {
43
43
  return resolveRuntimeModule(findPackageDir(fileURLToPath(importMetaUrl)), modulePath);
44
44
  }
45
- //#endregion
46
- //#region ../internal/src/definition-catalog.ts
45
+ // ../internal/src/definition-catalog.ts
47
46
  /** `writeFileIfChangedSync` for async callers. */
48
47
  async function writeFileIfChanged(file, contents) {
49
48
  if (await readFile(file, "utf8").catch(() => void 0) === contents) return;
@@ -86,8 +85,7 @@ function createNitroServerKit(value = {}) {
86
85
  }
87
86
  };
88
87
  }
89
- //#endregion
90
- //#region ../internal/src/contributions.ts
88
+ // ../internal/src/contributions.ts
91
89
  function isThenable(value) {
92
90
  return typeof value.then === "function";
93
91
  }
@@ -114,8 +112,7 @@ async function flattenPluginOptions(plugins) {
114
112
  await flattenPlugins(plugins ?? [], flattened, /* @__PURE__ */ new Set());
115
113
  return flattened;
116
114
  }
117
- //#endregion
118
- //#region ../internal/src/operations-vite.ts
115
+ // ../internal/src/operations-vite.ts
119
116
  const owners$1 = /* @__PURE__ */ new Set([
120
117
  "@vite-hub/kv/vite",
121
118
  "@vite-hub/blob/vite",
@@ -183,14 +180,12 @@ async function installStandaloneOperationRpc(config, command, module) {
183
180
  kit.config.devHandlers = signed;
184
181
  Reflect.set(config, "nitro", kit.config);
185
182
  }
186
- //#endregion
187
- //#region ../internal/src/durability.ts
183
+ // ../internal/src/durability.ts
188
184
  /** The `durability` module next to the Vite plugin module at `importMetaUrl`, in source and in `dist`. */
189
185
  function durabilityModuleFile(importMetaUrl) {
190
186
  return fileURLToPath(new URL(importMetaUrl.endsWith(".ts") ? "./durability.ts" : "./durability.js", importMetaUrl));
191
187
  }
192
- //#endregion
193
- //#region src/vite-config.ts
188
+ // src/vite-config.ts
194
189
  const KV_VITE_PLUGIN_NAME = "@vite-hub/kv/vite";
195
190
  const KV_VIRTUAL_CONFIG_ID = "#vitehub/kv/config";
196
191
  function resolveKVViteConfig(kv, input = {}) {
@@ -208,8 +203,7 @@ function resolveKVViteConfig(kv, input = {}) {
208
203
  }) ?? false
209
204
  };
210
205
  }
211
- //#endregion
212
- //#region ../internal/src/build/client-output.ts
206
+ // ../internal/src/build/client-output.ts
213
207
  function hasStaticIndex(clientDir) {
214
208
  return existsSync(resolve$1(clientDir, "index.html"));
215
209
  }
@@ -246,8 +240,7 @@ async function copyClientOutput(clientDir, targetDir, excludedDirs = []) {
246
240
  filter
247
241
  });
248
242
  }
249
- //#endregion
250
- //#region ../internal/src/build/provider-output-config.ts
243
+ // ../internal/src/build/provider-output-config.ts
251
244
  function isProviderJsonArray(value, ancestors) {
252
245
  if (Object.getPrototypeOf(value) !== Array.prototype || ancestors.has(value)) return false;
253
246
  if (Reflect.ownKeys(value).length !== value.length + 1) return false;
@@ -385,13 +378,11 @@ async function cleanProviderOutputConfig(file, ownership) {
385
378
  if (!changed) return;
386
379
  await persistProviderJsonRecord(file, next, true);
387
380
  }
388
- //#endregion
389
- //#region ../internal/src/build/user-entry.ts
381
+ // ../internal/src/build/user-entry.ts
390
382
  function toSafeAppName(rootDir) {
391
383
  return basename(rootDir).replace(/[^a-z0-9-]+/gi, "-").replace(/-+/g, "-").replace(/^-|-$/g, "").toLowerCase();
392
384
  }
393
- //#endregion
394
- //#region ../internal/src/build/cloudflare.ts
385
+ // ../internal/src/build/cloudflare.ts
395
386
  function createDefaultCloudflareOutputRoot(rootDir) {
396
387
  return resolve(rootDir, "dist", toSafeAppName(rootDir));
397
388
  }
@@ -408,21 +399,23 @@ async function writeCloudflareWranglerConfig(options) {
408
399
  removeIfEmpty: true
409
400
  });
410
401
  }
411
- //#endregion
412
- //#region ../internal/src/build/bundle-options.ts
402
+ // ../internal/src/build/bundle-options.ts
413
403
  const encodedAliasPrefixMarker = "\0vitehub-prefix:";
414
404
  const encodedAliasExactMarker = "\0vitehub-exact:";
415
405
  /** Select the runtime constants from one resolved Vite configuration. */
416
406
  function resolveViteHubBundleDefines(config) {
417
407
  const defines = {};
418
- for (const name of ["__VITEHUB_PUBLIC_URL__", "__VITEHUB_APP_BASE_URL__"]) {
408
+ for (const name of [
409
+ "__VITEHUB_PUBLIC_URL__",
410
+ "__VITEHUB_APP_BASE_URL__",
411
+ "__VITEHUB_CONSOLE_URL__"
412
+ ]) {
419
413
  const value = config.define?.[name];
420
414
  if (typeof value === "string") defines[name] = value;
421
415
  }
422
416
  return defines;
423
417
  }
424
- //#endregion
425
- //#region ../internal/src/build/ast-walk.ts
418
+ // ../internal/src/build/ast-walk.ts
426
419
  /** The oxc parser grammar for a file, from its extension. Defaults to TypeScript. */
427
420
  function moduleLanguage(file) {
428
421
  if (/\.(?:c|m)?tsx$/i.test(file)) return "tsx";
@@ -445,8 +438,7 @@ function walk(node, visit, parent) {
445
438
  } else if (isNode(child)) walk(child, visit, node);
446
439
  }
447
440
  }
448
- //#endregion
449
- //#region ../internal/src/build/rolldown.ts
441
+ // ../internal/src/build/rolldown.ts
450
442
  const viteRawPrefix = "\0vitehub-vite-raw:";
451
443
  const markdownTemplatePrefix = "\0vitehub-markdown-template:";
452
444
  const markdownTemplateFileSuffix = ".template.md";
@@ -812,20 +804,20 @@ function createFileUrlPlugin() {
812
804
  }
813
805
  };
814
806
  }
815
- /**
816
- * Copies a `.wasm?module` import next to the bundle and keeps it as a relative `.wasm` import. Wrangler and Nitro load
817
- * such an import as a compiled WebAssembly module, which Workers need because they can't compile WebAssembly bytes.
818
- * Node.js compiles WebAssembly bytes, so there the import becomes the bytes of the file.
819
- */
820
807
  function createWasmModulePlugin(outdir, workingDir, copy) {
821
808
  return {
822
809
  name: "vitehub-wasm-module",
823
810
  async resolveId(source, importer, extra) {
824
- if (!source.endsWith(".wasm?module")) return;
825
- const resolved = await this.resolve(source.slice(0, -7), importerFor(importer, workingDir), {
811
+ const explicitModule = source.endsWith(".wasm?module");
812
+ if (!explicitModule && (!copy || !source.endsWith(".wasm") || extra.custom?.[skipMarkdownTemplateResolve])) return;
813
+ const path = explicitModule ? source.slice(0, -7) : source;
814
+ const resolved = await this.resolve(path, importerFor(importer, workingDir), {
826
815
  custom: extra.custom,
827
- kind: extra.kind
816
+ isEntry: extra.isEntry,
817
+ kind: extra.kind,
818
+ skipSelf: true
828
819
  });
820
+ if (!explicitModule && (!isFileResolution(resolved) || !resolved.id.endsWith(".wasm"))) return resolved ?? void 0;
829
821
  if (!isFileResolution(resolved)) this.error(`[vitehub] Could not resolve ${JSON.stringify(source)}.`);
830
822
  if (!copy) return resolved.id;
831
823
  const bytes = await readFile(resolved.id);
@@ -1043,8 +1035,7 @@ async function bundleEsmEntry(entryFile, outfile, options = {}) {
1043
1035
  await writeFile(outfile, chunk.code, { signal: options.signal });
1044
1036
  options.signal?.throwIfAborted();
1045
1037
  }
1046
- //#endregion
1047
- //#region ../../node_modules/.pnpm/balanced-match@4.0.4/node_modules/balanced-match/dist/esm/index.js
1038
+ // ../../node_modules/.pnpm/balanced-match@4.0.4/node_modules/balanced-match/dist/esm/index.js
1048
1039
  const balanced = (a, b, str) => {
1049
1040
  const ma = a instanceof RegExp ? maybeMatch(a, str) : a;
1050
1041
  const mb = b instanceof RegExp ? maybeMatch(b, str) : b;
@@ -1091,8 +1082,7 @@ const range = (a, b, str) => {
1091
1082
  }
1092
1083
  return result;
1093
1084
  };
1094
- //#endregion
1095
- //#region ../../node_modules/.pnpm/brace-expansion@5.0.12/node_modules/brace-expansion/dist/esm/index.js
1085
+ // ../../node_modules/.pnpm/brace-expansion@5.0.12/node_modules/brace-expansion/dist/esm/index.js
1096
1086
  const escSlash = "\0SLASH" + Math.random() + "\0";
1097
1087
  const escOpen = "\0OPEN" + Math.random() + "\0";
1098
1088
  const escClose = "\0CLOSE" + Math.random() + "\0";
@@ -1292,39 +1282,94 @@ function expand_(str, max, maxLength, maxDepth, depth, maxRewrites, isTop) {
1292
1282
  }
1293
1283
  return acc;
1294
1284
  }
1295
- //#endregion
1296
- //#region ../../node_modules/.pnpm/minimatch@10.2.6/node_modules/minimatch/dist/esm/assert-valid-pattern.js
1297
- const MAX_PATTERN_LENGTH = 65536;
1298
- const assertValidPattern = (pattern) => {
1299
- if (typeof pattern !== "string") throw new TypeError("invalid pattern");
1300
- if (pattern.length > MAX_PATTERN_LENGTH) throw new TypeError("pattern is too long");
1285
+ // ../../node_modules/.pnpm/@isaacs+nonrecursive-glob-match@1.1.0/node_modules/@isaacs/nonrecursive-glob-match/dist/esm/numeric-range.js
1286
+ const digit = (a, b) => a === b ? {
1287
+ t: "lit",
1288
+ ch: String(a)
1289
+ } : {
1290
+ t: "class",
1291
+ re: new RegExp(`^[${a}-${b}]$`)
1292
+ };
1293
+ const prefix = (d, alts) => alts.map((s) => [digit(d, d), ...s]);
1294
+ const fixed = (a, b) => {
1295
+ if (!a) return [[]];
1296
+ let lo = +a[0];
1297
+ let hi = +b[0];
1298
+ const ra = a.slice(1);
1299
+ const rb = b.slice(1);
1300
+ if (lo === hi) return prefix(lo, fixed(ra, rb));
1301
+ const zeros = "0".repeat(ra.length);
1302
+ const nines = "9".repeat(ra.length);
1303
+ const out = [];
1304
+ if (ra !== zeros) out.push(...prefix(lo++, fixed(ra, nines)));
1305
+ const last = rb === nines ? [] : prefix(hi--, fixed(zeros, rb));
1306
+ if (lo <= hi) out.push([digit(lo, hi), ...Array.from(ra, () => digit(0, 9))]);
1307
+ out.push(...last);
1308
+ return out;
1309
+ };
1310
+ const nonneg = (a, b, width) => {
1311
+ if (width) return fixed(String(a).padStart(width, "0"), String(b).padStart(width, "0"));
1312
+ const out = [];
1313
+ for (let len = String(a).length; len <= String(b).length; len++) {
1314
+ const lo = Math.max(a, len === 1 ? 0 : 10 ** (len - 1));
1315
+ const hi = Math.min(b, 10 ** len - 1);
1316
+ out.push(...fixed(String(lo), String(hi)));
1317
+ }
1318
+ return out;
1319
+ };
1320
+ /**
1321
+ * The strings that the bash brace expansion `{lo..hi}` makes, as
1322
+ * the alternatives of an `@(...)` extglob. Each one is a sequence of
1323
+ * digits and digit classes, so there are only a few of them, even for
1324
+ * a large range.
1325
+ *
1326
+ * If either end has a leading zero, such as `{01..10}`, each number
1327
+ * has leading zeros to make it as long as the longer end, counting a
1328
+ * `-` sign. So `{-05..3}` makes `-05` to `-01`, then `000` to `003`.
1329
+ *
1330
+ * Returns undefined if either end is not a safe integer.
1331
+ */
1332
+ const numericRange = (loStr, hiStr) => {
1333
+ let lo = Number(loStr);
1334
+ let hi = Number(hiStr);
1335
+ if (!Number.isSafeInteger(lo) || !Number.isSafeInteger(hi)) return;
1336
+ if (lo > hi) [lo, hi] = [hi, lo];
1337
+ const width = /^-?0\d/.test(loStr) || /^-?0\d/.test(hiStr) ? Math.max(loStr.length, hiStr.length) : 0;
1338
+ const out = [];
1339
+ if (lo < 0) {
1340
+ const neg = nonneg(Math.max(-hi, 1), -lo, width && width - 1);
1341
+ out.push(...neg.map((s) => [{
1342
+ t: "lit",
1343
+ ch: "-"
1344
+ }, ...s]));
1345
+ }
1346
+ if (hi >= 0) out.push(...nonneg(Math.max(lo, 0), hi, width));
1347
+ return out;
1301
1348
  };
1302
- //#endregion
1303
- //#region ../../node_modules/.pnpm/minimatch@10.2.6/node_modules/minimatch/dist/esm/brace-expressions.js
1349
+ // ../../node_modules/.pnpm/@isaacs+nonrecursive-glob-match@1.1.0/node_modules/@isaacs/nonrecursive-glob-match/dist/esm/parse-class.js
1304
1350
  const posixClasses = {
1305
- "[:alnum:]": ["\\p{L}\\p{Nl}\\p{Nd}", true],
1306
- "[:alpha:]": ["\\p{L}\\p{Nl}", true],
1307
- "[:ascii:]": ["\\x00-\\x7f", false],
1308
- "[:blank:]": ["\\p{Zs}\\t", true],
1309
- "[:cntrl:]": ["\\p{Cc}", true],
1310
- "[:digit:]": ["\\p{Nd}", true],
1311
- "[:graph:]": [
1312
- "\\p{Z}\\p{C}",
1313
- true,
1314
- true
1315
- ],
1316
- "[:lower:]": ["\\p{Ll}", true],
1351
+ "[:alnum:]": ["\\p{L}\\p{Nl}\\p{Nd}"],
1352
+ "[:alpha:]": ["\\p{L}\\p{Nl}"],
1353
+ "[:ascii:]": ["\\x00-\\x7f"],
1354
+ "[:blank:]": ["\\p{Zs}\\t"],
1355
+ "[:cntrl:]": ["\\p{Cc}"],
1356
+ "[:digit:]": ["\\p{Nd}"],
1357
+ "[:graph:]": ["\\p{Z}\\p{C}", true],
1358
+ "[:lower:]": ["\\p{Ll}"],
1317
1359
  "[:print:]": ["\\p{C}", true],
1318
- "[:punct:]": ["\\p{P}", true],
1319
- "[:space:]": ["\\p{Z}\\t\\r\\n\\v\\f", true],
1320
- "[:upper:]": ["\\p{Lu}", true],
1321
- "[:word:]": ["\\p{L}\\p{Nl}\\p{Nd}\\p{Pc}", true],
1322
- "[:xdigit:]": ["A-Fa-f0-9", false]
1360
+ "[:punct:]": ["\\p{P}\\p{S}"],
1361
+ "[:space:]": ["\\p{Z}\\t\\r\\n\\v\\f"],
1362
+ "[:upper:]": ["\\p{Lu}"],
1363
+ "[:word:]": ["\\p{L}\\p{Nl}\\p{Nd}\\p{Pc}"],
1364
+ "[:xdigit:]": ["A-Fa-f0-9"]
1323
1365
  };
1324
1366
  const braceEscape = (s) => s.replace(/[[\]\\-]/g, "\\$&");
1325
- const regexpEscape = (s) => s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
1326
- const rangesToString = (ranges) => ranges.join("");
1327
- const parseClass = (glob, position) => {
1367
+ const noMatch = /$./;
1368
+ const parseClass = (glob, position, nocase = false, form) => {
1369
+ const norm = (c) => {
1370
+ const n = form ? c.normalize(form) : c;
1371
+ return [...n].length === 1 ? n : c;
1372
+ };
1328
1373
  const pos = position;
1329
1374
  /* c8 ignore start */
1330
1375
  if (glob.charAt(pos) !== "[") throw new Error("not in a brace expression");
@@ -1333,13 +1378,12 @@ const parseClass = (glob, position) => {
1333
1378
  const negs = [];
1334
1379
  let i = pos + 1;
1335
1380
  let sawStart = false;
1336
- let uflag = false;
1337
1381
  let escaping = false;
1338
1382
  let negate = false;
1339
1383
  let endPos = pos;
1340
1384
  let rangeStart = "";
1341
1385
  WHILE: while (i < glob.length) {
1342
- const c = glob.charAt(i);
1386
+ const c = String.fromCodePoint(glob.codePointAt(i));
1343
1387
  if ((c === "!" || c === "^") && i === pos + 1) {
1344
1388
  negate = true;
1345
1389
  i++;
@@ -1358,607 +1402,659 @@ const parseClass = (glob, position) => {
1358
1402
  }
1359
1403
  }
1360
1404
  if (c === "[" && !escaping) {
1361
- for (const [cls, [unip, u, neg]] of Object.entries(posixClasses)) if (glob.startsWith(cls, i)) {
1362
- if (rangeStart) return [
1363
- "$.",
1364
- false,
1365
- glob.length - pos,
1366
- true
1367
- ];
1405
+ for (const [cls, [unip, neg]] of Object.entries(posixClasses)) if (glob.startsWith(cls, i)) {
1406
+ if (rangeStart) return [noMatch, glob.length - pos];
1368
1407
  i += cls.length;
1369
1408
  if (neg) negs.push(unip);
1370
1409
  else ranges.push(unip);
1371
- uflag = uflag || u;
1372
1410
  continue WHILE;
1373
1411
  }
1374
1412
  }
1375
1413
  escaping = false;
1414
+ const n = norm(c);
1376
1415
  if (rangeStart) {
1377
- if (c > rangeStart) ranges.push(braceEscape(rangeStart) + "-" + braceEscape(c));
1378
- else if (c === rangeStart) ranges.push(braceEscape(c));
1416
+ if (n.codePointAt(0) > rangeStart.codePointAt(0)) ranges.push(braceEscape(rangeStart) + "-" + braceEscape(n));
1417
+ else if (n === rangeStart) ranges.push(braceEscape(n));
1379
1418
  rangeStart = "";
1380
- i++;
1419
+ i += c.length;
1381
1420
  continue;
1382
1421
  }
1383
- if (glob.startsWith("-]", i + 1)) {
1384
- ranges.push(braceEscape(c + "-"));
1385
- i += 2;
1422
+ if (glob.startsWith("-]", i + c.length)) {
1423
+ ranges.push(braceEscape(n + "-"));
1424
+ i += c.length + 1;
1425
+ continue;
1426
+ }
1427
+ if (glob.startsWith("-", i + c.length)) {
1428
+ rangeStart = n;
1429
+ i += c.length + 1;
1430
+ continue;
1431
+ }
1432
+ ranges.push(braceEscape(n));
1433
+ i += c.length;
1434
+ }
1435
+ if (endPos < i) return [noMatch, 0];
1436
+ if (!ranges.length && !negs.length) return [noMatch, glob.length - pos];
1437
+ const sranges = "[" + (negate ? "^" : "") + ranges.join("") + "]";
1438
+ const snegs = "[" + (negate ? "" : "^") + negs.join("") + "]";
1439
+ const comb = "^" + (ranges.length && negs.length ? "(" + sranges + "|" + snegs + ")" : ranges.length ? sranges : snegs);
1440
+ return [new RegExp(comb, nocase ? "iu" : "u"), endPos - pos];
1441
+ };
1442
+ // ../../node_modules/.pnpm/@isaacs+nonrecursive-glob-match@1.1.0/node_modules/@isaacs/nonrecursive-glob-match/dist/esm/index.js
1443
+ const MATCH = {
1444
+ t: "match",
1445
+ id: 0
1446
+ };
1447
+ const extTypes = "!?+*@";
1448
+ const lit = (ch) => ({
1449
+ t: "lit",
1450
+ ch
1451
+ });
1452
+ const reEscape = (s) => s.replace(/[\\^$.*+?()[\]{}|/]/g, "\\$&");
1453
+ const newFoldRe = (s) => new RegExp(`^${reEscape(s)}$`, "iu");
1454
+ const foldCache = /* @__PURE__ */ new Map();
1455
+ const foldRe = (ch) => {
1456
+ let re = foldCache.get(ch);
1457
+ if (!re) {
1458
+ re = newFoldRe(ch);
1459
+ if (foldCache.size >= 1e3) foldCache.clear();
1460
+ foldCache.set(ch, re);
1461
+ }
1462
+ return re;
1463
+ };
1464
+ const litMatch = (l, c) => {
1465
+ if (c === l.ch) return true;
1466
+ if (!l.re) return false;
1467
+ const code = c.charCodeAt(0);
1468
+ if (code >= 128) return l.re.test(c);
1469
+ const ascii = l.ascii ??= /* @__PURE__ */ new Uint8Array(128);
1470
+ ascii[code] ||= l.re.test(c) ? 1 : 2;
1471
+ return ascii[code] === 1;
1472
+ };
1473
+ const tokenize = (p, nocase, noext, form, mark) => {
1474
+ const toks = [];
1475
+ for (let i = 0; i < p.length;) {
1476
+ const c = String.fromCodePoint(p.codePointAt(i));
1477
+ if (mark) {
1478
+ const m = c === "\\" && p.startsWith(mark, i + 1) ? 1 : 0;
1479
+ if (m || c === mark) {
1480
+ const start = i + m + mark.length;
1481
+ const end = p.indexOf(mark, start);
1482
+ const r = /^(-?\d+)\.\.(-?\d+)$/.exec(p.slice(start, end));
1483
+ const alts = end !== -1 && r && numericRange(r[1], r[2]);
1484
+ if (alts) {
1485
+ toks.push({
1486
+ t: "ext",
1487
+ type: "@",
1488
+ alts
1489
+ });
1490
+ i = end + mark.length;
1491
+ continue;
1492
+ }
1493
+ }
1494
+ }
1495
+ if (c === "\\") {
1496
+ const e = p.codePointAt(i + 1);
1497
+ const ch = e === void 0 ? c : String.fromCodePoint(e);
1498
+ toks.push(lit(ch));
1499
+ i += 1 + ch.length;
1386
1500
  continue;
1387
1501
  }
1388
- if (glob.startsWith("-", i + 1)) {
1389
- rangeStart = c;
1502
+ if (c === "[") {
1503
+ const [re, consumed] = parseClass(p, i, nocase, form);
1504
+ if (consumed) {
1505
+ toks.push({
1506
+ t: "class",
1507
+ re
1508
+ });
1509
+ i += consumed;
1510
+ continue;
1511
+ }
1512
+ }
1513
+ if (!noext && extTypes.includes(c) && p[i + 1] === "(") {
1514
+ toks.push({
1515
+ t: "open",
1516
+ type: c
1517
+ });
1390
1518
  i += 2;
1391
1519
  continue;
1392
1520
  }
1393
- ranges.push(braceEscape(c));
1394
- i++;
1521
+ toks.push(!noext && c === "|" ? { t: "bar" } : !noext && c === ")" ? { t: "close" } : c === "*" ? { t: "star" } : c === "?" ? { t: "any" } : lit(c));
1522
+ i += c.length;
1395
1523
  }
1396
- if (endPos < i) return [
1397
- "",
1398
- false,
1399
- 0,
1400
- false
1401
- ];
1402
- if (!ranges.length && !negs.length) return [
1403
- "$.",
1404
- false,
1405
- glob.length - pos,
1406
- true
1407
- ];
1408
- if (negs.length === 0 && ranges.length === 1 && /^\\?.$/.test(ranges[0]) && !negate) {
1409
- const r = ranges[0].length === 2 ? ranges[0].slice(-1) : ranges[0];
1410
- return [
1411
- regexpEscape(r),
1412
- false,
1413
- endPos - pos,
1414
- false
1415
- ];
1416
- }
1417
- const sranges = "[" + (negate ? "^" : "") + rangesToString(ranges) + "]";
1418
- const snegs = "[" + (negate ? "" : "^") + rangesToString(negs) + "]";
1419
- return [
1420
- ranges.length && negs.length ? "(" + sranges + "|" + snegs + ")" : ranges.length ? sranges : snegs,
1421
- uflag,
1422
- endPos - pos,
1423
- true
1424
- ];
1524
+ return toks;
1425
1525
  };
1426
- //#endregion
1427
- //#region ../../node_modules/.pnpm/minimatch@10.2.6/node_modules/minimatch/dist/esm/unescape.js
1428
- /**
1429
- * Un-escape a string that has been escaped with {@link escape}.
1430
- *
1431
- * If the {@link MinimatchOptions.windowsPathsNoEscape} option is used, then
1432
- * square-bracket escapes are removed, but not backslash escapes.
1433
- *
1434
- * For example, it will turn the string `'[*]'` into `*`, but it will not
1435
- * turn `'\\*'` into `'*'`, because `\` is a path separator in
1436
- * `windowsPathsNoEscape` mode.
1437
- *
1438
- * When `windowsPathsNoEscape` is not set, then both square-bracket escapes and
1439
- * backslash escapes are removed.
1440
- *
1441
- * Slashes (and backslashes in `windowsPathsNoEscape` mode) cannot be escaped
1442
- * or unescaped.
1443
- *
1444
- * When `magicalBraces` is not set, escapes of braces (`{` and `}`) will not be
1445
- * unescaped.
1446
- */
1447
- const unescape = (s, { windowsPathsNoEscape = false, magicalBraces = true } = {}) => {
1448
- if (magicalBraces) return windowsPathsNoEscape ? s.replace(/\[([^/\\])\]/g, "$1") : s.replace(/((?!\\).|^)\[([^/\\])\]/g, "$1$2").replace(/\\([^/])/g, "$1");
1449
- return windowsPathsNoEscape ? s.replace(/\[([^/\\{}])\]/g, "$1") : s.replace(/((?!\\).|^)\[([^/\\{}])\]/g, "$1$2").replace(/\\([^/{}])/g, "$1");
1526
+ const pair = (toks) => {
1527
+ const pairs = /* @__PURE__ */ new Map();
1528
+ const stack = [];
1529
+ toks.forEach((tok, i) => {
1530
+ if (tok.t === "open") stack.push(i);
1531
+ else if (tok.t === "close" && stack.length) pairs.set(stack.pop(), i);
1532
+ });
1533
+ return pairs;
1450
1534
  };
1451
- //#endregion
1452
- //#region ../../node_modules/.pnpm/minimatch@10.2.6/node_modules/minimatch/dist/esm/ast.js
1453
- var _a;
1454
- const types = /* @__PURE__ */ new Set([
1455
- "!",
1456
- "?",
1457
- "+",
1458
- "*",
1459
- "@"
1460
- ]);
1461
- const isExtglobType = (c) => types.has(c);
1462
- const isExtglobAST = (c) => isExtglobType(c.type);
1463
- const adoptionMap = /* @__PURE__ */ new Map([
1464
- ["!", ["@"]],
1465
- ["?", ["?", "@"]],
1466
- ["@", ["@"]],
1467
- ["*", [
1468
- "*",
1469
- "+",
1470
- "?",
1471
- "@"
1472
- ]],
1473
- ["+", ["+", "@"]]
1474
- ]);
1475
- const adoptionWithSpaceMap = /* @__PURE__ */ new Map([
1476
- ["!", ["?"]],
1477
- ["@", ["?"]],
1478
- ["+", ["?", "*"]]
1479
- ]);
1480
- const adoptionAnyMap = /* @__PURE__ */ new Map([
1481
- ["!", ["?", "@"]],
1482
- ["?", ["?", "@"]],
1483
- ["@", ["?", "@"]],
1484
- ["*", [
1485
- "*",
1486
- "+",
1487
- "?",
1488
- "@"
1489
- ]],
1490
- ["+", [
1491
- "+",
1492
- "@",
1493
- "?",
1494
- "*"
1495
- ]]
1496
- ]);
1497
- const usurpMap = /* @__PURE__ */ new Map([
1498
- ["!", /* @__PURE__ */ new Map([["!", "@"]])],
1499
- ["?", /* @__PURE__ */ new Map([["*", "*"], ["+", "*"]])],
1500
- ["@", /* @__PURE__ */ new Map([
1501
- ["!", "!"],
1502
- ["?", "?"],
1503
- ["@", "@"],
1504
- ["*", "*"],
1505
- ["+", "+"]
1506
- ])],
1507
- ["+", /* @__PURE__ */ new Map([["?", "*"], ["*", "*"]])]
1508
- ]);
1509
- const startNoTraversal = "(?!(?:^|/)\\.\\.?(?:$|/))";
1510
- const startNoDot = "(?!\\.)";
1511
- const addPatternStart = /* @__PURE__ */ new Set(["[", "."]);
1512
- const justDots = /* @__PURE__ */ new Set(["..", "."]);
1513
- const reSpecials = /* @__PURE__ */ new Set("().*{}+?[]^$\\!");
1514
- const regExpEscape$1 = (s) => s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
1515
- const qmark = "[^/]";
1516
- const star$1 = "[^/]*?";
1517
- const starNoEmpty = "[^/]+?";
1518
- let ID = 0;
1519
- var AST = class {
1520
- type;
1521
- #root;
1522
- #hasMagic;
1523
- #uflag = false;
1524
- #parts = [];
1525
- #parent;
1526
- #parentIndex;
1527
- #negs;
1528
- #filledNegs = false;
1529
- #options;
1530
- #toString;
1531
- #emptyExt = false;
1532
- id = ++ID;
1533
- get depth() {
1534
- return (this.#parent?.depth ?? -1) + 1;
1535
- }
1536
- [Symbol.for("nodejs.util.inspect.custom")]() {
1537
- return {
1538
- "@@type": "AST",
1539
- id: this.id,
1540
- type: this.type,
1541
- root: this.#root.id,
1542
- parent: this.#parent?.id,
1543
- depth: this.depth,
1544
- partsLength: this.#parts.length,
1545
- parts: this.#parts
1546
- };
1535
+ const build = (toks, pairs, start, end, top) => {
1536
+ let seq = [];
1537
+ const alts = [seq];
1538
+ for (let i = start; i < end; i++) {
1539
+ const tok = toks[i];
1540
+ const close = pairs.get(i);
1541
+ if (tok.t === "open" && close !== void 0) {
1542
+ const sub = build(toks, pairs, i + 1, close, false);
1543
+ seq.push({
1544
+ t: "ext",
1545
+ type: tok.type,
1546
+ alts: sub
1547
+ });
1548
+ i = close;
1549
+ } else if (tok.t === "bar" && !top) alts.push(seq = []);
1550
+ else if (tok.t === "open") seq.push(lit(tok.type), lit("("));
1551
+ else if (tok.t === "bar") seq.push(lit("|"));
1552
+ else if (tok.t === "close") seq.push(lit(")"));
1553
+ else seq.push(tok);
1554
+ }
1555
+ return alts;
1556
+ };
1557
+ const normalize = (items, form) => {
1558
+ const out = [];
1559
+ let run = "";
1560
+ const flush = () => {
1561
+ for (const ch of run.normalize(form)) out.push(lit(ch));
1562
+ run = "";
1563
+ };
1564
+ for (const it of items) {
1565
+ if (it.t === "lit") {
1566
+ run += it.ch;
1567
+ continue;
1568
+ }
1569
+ flush();
1570
+ out.push(it.t === "ext" ? {
1571
+ ...it,
1572
+ alts: it.alts.map((a) => normalize(a, form))
1573
+ } : it);
1547
1574
  }
1548
- constructor(type, parent, options = {}) {
1549
- this.type = type;
1550
- if (type) this.#hasMagic = true;
1551
- this.#parent = parent;
1552
- this.#root = this.#parent ? this.#parent.#root : this;
1553
- this.#options = this.#root === this ? options : this.#root.#options;
1554
- this.#negs = this.#root === this ? [] : this.#root.#negs;
1555
- if (type === "!" && !this.#root.#filledNegs) this.#negs.push(this);
1556
- this.#parentIndex = this.#parent ? this.#parent.#parts.length : 0;
1557
- }
1558
- get hasMagic() {
1559
- /* c8 ignore start */
1560
- if (this.#hasMagic !== void 0) return this.#hasMagic;
1561
- /* c8 ignore stop */
1562
- for (const p of this.#parts) {
1563
- if (typeof p === "string") continue;
1564
- if (p.type || p.hasMagic) return this.#hasMagic = true;
1575
+ flush();
1576
+ return out;
1577
+ };
1578
+ const compile = (items, nocase) => {
1579
+ let id = 1;
1580
+ const split = (out) => ({
1581
+ t: "split",
1582
+ id: id++,
1583
+ out
1584
+ });
1585
+ const seq = (items, next) => items.reduceRight((next, it) => item(it, next), next);
1586
+ const item = (it, next) => {
1587
+ switch (it.t) {
1588
+ case "lit":
1589
+ const re = nocase ? foldRe(it.ch) : void 0;
1590
+ return {
1591
+ t: "lit",
1592
+ id: id++,
1593
+ ch: it.ch,
1594
+ re,
1595
+ next
1596
+ };
1597
+ case "any":
1598
+ case "star": return {
1599
+ t: it.t,
1600
+ id: id++,
1601
+ next
1602
+ };
1603
+ case "class": return {
1604
+ t: "class",
1605
+ id: id++,
1606
+ re: it.re,
1607
+ next
1608
+ };
1609
+ }
1610
+ const alts = (next) => it.alts.map((a) => seq(a, next));
1611
+ switch (it.type) {
1612
+ case "@": return split(alts(next));
1613
+ case "?": return split([next, ...alts(next)]);
1614
+ case "!": return {
1615
+ t: "neg",
1616
+ id: id++,
1617
+ sub: split(alts(MATCH)),
1618
+ next
1619
+ };
1620
+ }
1621
+ const after = split([]);
1622
+ const entry = split(alts(after));
1623
+ after.out.push(next, entry);
1624
+ return it.type === "*" ? after : entry;
1625
+ };
1626
+ return [seq(items, MATCH), id];
1627
+ };
1628
+ const show = (start) => {
1629
+ const lines = [];
1630
+ const seen = /* @__PURE__ */ new Set();
1631
+ const ref = (n) => n.t === "match" ? "match" : String(n.id);
1632
+ const walk = (n, indent) => {
1633
+ if (n.t === "match" || seen.has(n)) return;
1634
+ seen.add(n);
1635
+ const line = (desc) => lines.push(`${indent}${n.id}: ${desc}`);
1636
+ switch (n.t) {
1637
+ case "split":
1638
+ line(`split -> ${n.out.map(ref).join(", ")}`);
1639
+ for (const o of n.out) walk(o, indent);
1640
+ return;
1641
+ case "neg":
1642
+ line(`!(${ref(n.sub)}) -> ${ref(n.next)}`);
1643
+ walk(n.sub, indent + " ");
1644
+ return walk(n.next, indent);
1645
+ case "lit":
1646
+ line(`${JSON.stringify(n.ch)} -> ${ref(n.next)}`);
1647
+ break;
1648
+ case "class":
1649
+ line(`${n.re} -> ${ref(n.next)}`);
1650
+ break;
1651
+ default: line(`${n.t === "any" ? "?" : "*"} -> ${ref(n.next)}`);
1565
1652
  }
1566
- return this.#hasMagic;
1653
+ walk(n.next, indent);
1654
+ };
1655
+ walk(start, "");
1656
+ return [`start -> ${ref(start)}`, ...lines].join("\n");
1657
+ };
1658
+ var State = class {
1659
+ gen;
1660
+ threads = [];
1661
+ match = false;
1662
+ runs = [];
1663
+ ids = [];
1664
+ constructor(gen) {
1665
+ this.gen = gen;
1666
+ }
1667
+ get dead() {
1668
+ return !this.threads.length && !this.match && !this.runs.length;
1567
1669
  }
1568
- toString() {
1569
- return this.#toString !== void 0 ? this.#toString : !this.type ? this.#toString = this.#parts.map((p) => String(p)).join("") : this.#toString = this.type + "(" + this.#parts.map((p) => String(p)).join("|") + ")";
1670
+ };
1671
+ const sameState = (a, b) => {
1672
+ if (a.ids.length !== b.ids.length) return false;
1673
+ if (a.runs.length !== b.runs.length) return false;
1674
+ if (a.ids.some((id, i) => id !== b.ids[i])) return false;
1675
+ return a.runs.every((r) => b.runs.some((o) => o.neg === r.neg && sameState(o.state, r.state)));
1676
+ };
1677
+ const marks = (size) => ({
1678
+ has: new Float64Array(size),
1679
+ seen: new Float64Array(size),
1680
+ gen: 0
1681
+ });
1682
+ var Sim = class {
1683
+ dots;
1684
+ dotStart;
1685
+ #marks;
1686
+ constructor(dots, dotStart, marks) {
1687
+ this.dots = dots;
1688
+ this.dotStart = dotStart;
1689
+ this.#marks = marks;
1690
+ }
1691
+ state() {
1692
+ return new State(++this.#marks.gen);
1693
+ }
1694
+ done(state) {
1695
+ state.ids = state.threads.map((n) => n.id).sort((a, b) => a - b);
1696
+ if (state.match) state.ids.unshift(MATCH.id);
1697
+ return state;
1698
+ }
1699
+ #visit(state, node) {
1700
+ const { seen } = this.#marks;
1701
+ if (seen[node.id] === state.gen) return false;
1702
+ seen[node.id] = state.gen;
1703
+ return true;
1570
1704
  }
1571
- #fillNegs() {
1572
- /* c8 ignore start */
1573
- if (this !== this.#root) throw new Error("should only call on root");
1574
- if (this.#filledNegs) return this;
1575
- /* c8 ignore stop */
1576
- this.toString();
1577
- this.#filledNegs = true;
1578
- let n;
1579
- while (n = this.#negs.pop()) {
1580
- if (n.type !== "!") continue;
1581
- let p = n;
1582
- let pp = p.#parent;
1583
- while (pp) {
1584
- for (let i = p.#parentIndex + 1; !pp.type && i < pp.#parts.length; i++) for (const part of n.#parts) {
1585
- /* c8 ignore start */
1586
- if (typeof part === "string") throw new Error("string part in extglob AST??");
1587
- /* c8 ignore stop */
1588
- part.copyIn(pp.#parts[i]);
1589
- }
1590
- p = pp;
1591
- pp = p.#parent;
1592
- }
1593
- }
1594
- return this;
1705
+ #addThread(state, node) {
1706
+ const { has } = this.#marks;
1707
+ if (has[node.id] === state.gen) return false;
1708
+ has[node.id] = state.gen;
1709
+ state.threads.push(node);
1710
+ return true;
1595
1711
  }
1596
- push(...parts) {
1597
- for (const p of parts) {
1598
- if (p === "") continue;
1599
- /* c8 ignore start */
1600
- if (typeof p !== "string" && !(p instanceof _a && p.#parent === this)) throw new Error("invalid part: " + p);
1601
- /* c8 ignore stop */
1602
- this.#parts.push(p);
1712
+ restricted(i, top) {
1713
+ return top && (this.dots || this.dotStart && i === 0);
1714
+ }
1715
+ add(state, node, i, top) {
1716
+ switch (node.t) {
1717
+ case "split":
1718
+ if (!this.#visit(state, node)) return;
1719
+ for (const o of node.out) this.add(state, o, i, top);
1720
+ return;
1721
+ case "neg":
1722
+ if (!this.#visit(state, node)) return;
1723
+ const sub = this.state();
1724
+ this.add(sub, node.sub, i, false);
1725
+ this.done(sub);
1726
+ return this.addRun(state, {
1727
+ t: "run",
1728
+ neg: node,
1729
+ state: sub
1730
+ }, i, top);
1731
+ case "star":
1732
+ if (this.restricted(i, top)) return;
1733
+ if (this.#addThread(state, node)) this.add(state, node.next, i, top);
1734
+ return;
1735
+ case "match":
1736
+ state.match = true;
1737
+ return;
1738
+ default: this.#addThread(state, node);
1603
1739
  }
1604
1740
  }
1605
- toJSON() {
1606
- const ret = this.type === null ? this.#parts.slice().map((p) => typeof p === "string" ? p : p.toJSON()) : [this.type, ...this.#parts.map((p) => p.toJSON())];
1607
- if (this.isStart() && !this.type) ret.unshift([]);
1608
- if (this.isEnd() && (this === this.#root || this.#root.#filledNegs && this.#parent?.type === "!")) ret.push({});
1609
- return ret;
1741
+ addRun(state, run, i, top) {
1742
+ for (const r of state.runs) if (r.neg === run.neg && sameState(r.state, run.state)) return;
1743
+ state.runs.push(run);
1744
+ if (!run.state.match) this.add(state, run.neg.next, i, top);
1610
1745
  }
1611
- isStart() {
1612
- if (this.#root === this) return true;
1613
- if (!this.#parent?.isStart()) return false;
1614
- if (this.#parentIndex === 0) return true;
1615
- const p = this.#parent;
1616
- for (let i = 0; i < this.#parentIndex; i++) {
1617
- const pp = p.#parts[i];
1618
- if (!(pp instanceof _a && pp.type === "!")) return false;
1746
+ step(state, c, i, top) {
1747
+ const next = this.state();
1748
+ for (const th of state.threads) switch (th.t) {
1749
+ case "lit":
1750
+ if (litMatch(th, c)) this.add(next, th.next, i + 1, top);
1751
+ break;
1752
+ case "any":
1753
+ if (!this.restricted(i, top)) this.add(next, th.next, i + 1, top);
1754
+ break;
1755
+ case "class":
1756
+ if (!this.restricted(i, top) && th.re.test(c)) this.add(next, th.next, i + 1, top);
1757
+ break;
1758
+ case "star": if (!this.restricted(i, top)) this.add(next, th, i + 1, top);
1619
1759
  }
1620
- return true;
1621
- }
1622
- isEnd() {
1623
- if (this.#root === this) return true;
1624
- if (this.#parent?.type === "!") return true;
1625
- if (!this.#parent?.isEnd()) return false;
1626
- if (!this.type) return this.#parent?.isEnd();
1627
- /* c8 ignore start */
1628
- const pl = this.#parent ? this.#parent.#parts.length : 0;
1629
- /* c8 ignore stop */
1630
- return this.#parentIndex === pl - 1;
1631
- }
1632
- copyIn(part) {
1633
- if (typeof part === "string") this.push(part);
1634
- else this.push(part.clone(this));
1635
- }
1636
- clone(parent) {
1637
- const c = new _a(this.type, parent);
1638
- for (const p of this.#parts) c.copyIn(p);
1639
- return c;
1640
- }
1641
- static #parseAST(str, ast, pos, opt, extDepth) {
1642
- const maxDepth = opt.maxExtglobRecursion ?? 2;
1643
- let escaping = false;
1644
- let inBrace = false;
1645
- let braceStart = -1;
1646
- let braceNeg = false;
1647
- if (ast.type === null) {
1648
- let i = pos;
1649
- let acc = "";
1650
- while (i < str.length) {
1651
- const c = str.charAt(i++);
1652
- if (escaping || c === "\\") {
1653
- escaping = !escaping;
1654
- acc += c;
1655
- continue;
1656
- }
1657
- if (inBrace) {
1658
- if (i === braceStart + 1) {
1659
- if (c === "^" || c === "!") braceNeg = true;
1660
- } else if (c === "]" && !(i === braceStart + 2 && braceNeg)) inBrace = false;
1661
- acc += c;
1662
- continue;
1663
- } else if (c === "[") {
1664
- inBrace = true;
1665
- braceStart = i;
1666
- braceNeg = false;
1667
- acc += c;
1668
- continue;
1669
- }
1670
- if (!opt.noext && isExtglobType(c) && str.charAt(i) === "(" && extDepth <= maxDepth) {
1671
- ast.push(acc);
1672
- acc = "";
1673
- const ext = new _a(c, ast);
1674
- i = _a.#parseAST(str, ext, i, opt, extDepth + 1);
1675
- ast.push(ext);
1676
- continue;
1677
- }
1678
- acc += c;
1679
- }
1680
- ast.push(acc);
1681
- return i;
1682
- }
1683
- let i = pos + 1;
1684
- let part = new _a(null, ast);
1685
- const parts = [];
1686
- let acc = "";
1687
- while (i < str.length) {
1688
- const c = str.charAt(i++);
1689
- if (escaping || c === "\\") {
1690
- escaping = !escaping;
1691
- acc += c;
1692
- continue;
1693
- }
1694
- if (inBrace) {
1695
- if (i === braceStart + 1) {
1696
- if (c === "^" || c === "!") braceNeg = true;
1697
- } else if (c === "]" && !(i === braceStart + 2 && braceNeg)) inBrace = false;
1698
- acc += c;
1699
- continue;
1700
- } else if (c === "[") {
1701
- inBrace = true;
1702
- braceStart = i;
1703
- braceNeg = false;
1704
- acc += c;
1760
+ if (!this.restricted(i, top)) for (const run of state.runs) {
1761
+ if (run.state.dead) {
1762
+ this.addRun(next, run, i + 1, top);
1705
1763
  continue;
1706
1764
  }
1707
- /* c8 ignore stop */
1708
- if (!opt.noext && isExtglobType(c) && str.charAt(i) === "(" && (extDepth <= maxDepth || ast && ast.#canAdoptType(c))) {
1709
- const depthAdd = ast && ast.#canAdoptType(c) ? 0 : 1;
1710
- part.push(acc);
1711
- acc = "";
1712
- const ext = new _a(c, part);
1713
- part.push(ext);
1714
- i = _a.#parseAST(str, ext, i, opt, extDepth + depthAdd);
1715
- continue;
1716
- }
1717
- if (c === "|") {
1718
- part.push(acc);
1719
- acc = "";
1720
- parts.push(part);
1721
- part = new _a(null, ast);
1722
- continue;
1723
- }
1724
- if (c === ")") {
1725
- if (acc === "" && ast.#parts.length === 0) ast.#emptyExt = true;
1726
- part.push(acc);
1727
- acc = "";
1728
- ast.push(...parts, part);
1729
- return i;
1730
- }
1731
- acc += c;
1732
- }
1733
- ast.type = null;
1734
- ast.#hasMagic = void 0;
1735
- ast.#parts = [str.substring(pos - 1)];
1736
- return i;
1737
- }
1738
- #canAdoptWithSpace(child) {
1739
- return this.#canAdopt(child, adoptionWithSpaceMap);
1740
- }
1741
- #canAdopt(child, map = adoptionMap) {
1742
- if (!child || typeof child !== "object" || child.type !== null || child.#parts.length !== 1 || this.type === null) return false;
1743
- const gc = child.#parts[0];
1744
- if (!gc || typeof gc !== "object" || gc.type === null) return false;
1745
- return this.#canAdoptType(gc.type, map);
1746
- }
1747
- #canAdoptType(c, map = adoptionAnyMap) {
1748
- return !!map.get(this.type)?.includes(c);
1749
- }
1750
- #adoptWithSpace(child, index) {
1751
- const gc = child.#parts[0];
1752
- const blank = new _a(null, gc, this.options);
1753
- blank.#parts.push("");
1754
- gc.push(blank);
1755
- this.#adopt(child, index);
1756
- }
1757
- #adopt(child, index) {
1758
- const gc = child.#parts[0];
1759
- this.#parts.splice(index, 1, ...gc.#parts);
1760
- for (const p of gc.#parts) if (typeof p === "object") p.#parent = this;
1761
- this.#toString = void 0;
1762
- }
1763
- #canUsurpType(c) {
1764
- return !!usurpMap.get(this.type)?.has(c);
1765
- }
1766
- #canUsurp(child) {
1767
- if (!child || typeof child !== "object" || child.type !== null || child.#parts.length !== 1 || this.type === null || this.#parts.length !== 1) return false;
1768
- const gc = child.#parts[0];
1769
- if (!gc || typeof gc !== "object" || gc.type === null) return false;
1770
- return this.#canUsurpType(gc.type);
1771
- }
1772
- #usurp(child) {
1773
- const m = usurpMap.get(this.type);
1774
- const gc = child.#parts[0];
1775
- const nt = m?.get(gc.type);
1776
- /* c8 ignore start - impossible */
1777
- if (!nt) return false;
1778
- /* c8 ignore stop */
1779
- this.#parts = gc.#parts;
1780
- for (const p of this.#parts) if (typeof p === "object") p.#parent = this;
1781
- this.type = nt;
1782
- this.#toString = void 0;
1783
- this.#emptyExt = false;
1784
- }
1785
- static fromGlob(pattern, options = {}) {
1786
- const ast = new _a(null, void 0, options);
1787
- _a.#parseAST(pattern, ast, 0, options, 0);
1788
- return ast;
1789
- }
1790
- toMMPattern() {
1791
- /* c8 ignore start */
1792
- if (this !== this.#root) return this.#root.toMMPattern();
1793
- /* c8 ignore stop */
1794
- const glob = this.toString();
1795
- const [re, body, hasMagic, uflag] = this.toRegExpSource();
1796
- if (!(hasMagic || this.#hasMagic || this.#options.nocase && !this.#options.nocaseMagicOnly && glob.toUpperCase() !== glob.toLowerCase())) return body;
1797
- const flags = (this.#options.nocase ? "i" : "") + (uflag ? "u" : "");
1798
- return Object.assign(new RegExp(`^${re}$`, flags), {
1799
- _src: re,
1800
- _glob: glob
1801
- });
1765
+ const sub = this.step(run.state, c, i, false);
1766
+ this.addRun(next, {
1767
+ t: "run",
1768
+ neg: run.neg,
1769
+ state: sub
1770
+ }, i + 1, top);
1771
+ }
1772
+ return this.done(next);
1802
1773
  }
1803
- get options() {
1804
- return this.#options;
1805
- }
1806
- toRegExpSource(allowDot) {
1807
- const dot = allowDot ?? !!this.#options.dot;
1808
- if (this.#root === this) {
1809
- this.#flatten();
1810
- this.#fillNegs();
1811
- }
1812
- if (!isExtglobAST(this)) {
1813
- const noEmpty = this.isStart() && this.isEnd() && !this.#parts.some((s) => typeof s !== "string");
1814
- const src = this.#parts.map((p) => {
1815
- const [re, _, hasMagic, uflag] = typeof p === "string" ? _a.#parseGlob(p, this.#hasMagic, noEmpty) : p.toRegExpSource(allowDot);
1816
- this.#hasMagic = this.#hasMagic || hasMagic;
1817
- this.#uflag = this.#uflag || uflag;
1818
- return re;
1819
- }).join("");
1820
- let start = "";
1821
- if (this.isStart()) {
1822
- if (typeof this.#parts[0] === "string") {
1823
- if (!(this.#parts.length === 1 && justDots.has(this.#parts[0]))) {
1824
- const aps = addPatternStart;
1825
- const needNoTrav = dot && aps.has(src.charAt(0)) || src.startsWith("\\.") && aps.has(src.charAt(2)) || src.startsWith("\\.\\.") && aps.has(src.charAt(4));
1826
- const needNoDot = !dot && !allowDot && aps.has(src.charAt(0));
1827
- start = needNoTrav ? startNoTraversal : needNoDot ? startNoDot : "";
1828
- }
1829
- }
1774
+ };
1775
+ const stateKey = (state) => {
1776
+ const ids = state.ids.join();
1777
+ if (!state.runs.length) return ids;
1778
+ return `${ids}|${state.runs.map((r) => `${r.neg.id}(${stateKey(r.state)})`).sort().join("|")}`;
1779
+ };
1780
+ const DFA_BUDGET = 1 << 18;
1781
+ var Dfa = class {
1782
+ #start;
1783
+ #states = /* @__PURE__ */ new Map();
1784
+ #size = 0;
1785
+ #plain;
1786
+ #dotStart;
1787
+ #sim;
1788
+ #dotSim;
1789
+ constructor(start, marks) {
1790
+ this.#start = start;
1791
+ this.#sim = new Sim(false, false, marks);
1792
+ this.#dotSim = new Sim(false, true, marks);
1793
+ }
1794
+ #make(state) {
1795
+ return {
1796
+ state,
1797
+ match: state.match,
1798
+ dead: state.dead,
1799
+ next: /* @__PURE__ */ new Map()
1800
+ };
1801
+ }
1802
+ #intern(state) {
1803
+ const key = stateKey(state);
1804
+ const found = this.#states.get(key);
1805
+ if (found) return found;
1806
+ if (this.#size > DFA_BUDGET) this.#clear();
1807
+ const d = this.#make(state);
1808
+ this.#states.set(key, d);
1809
+ this.#size += key.length + 1;
1810
+ return d;
1811
+ }
1812
+ #clear() {
1813
+ this.#states.clear();
1814
+ this.#size = 0;
1815
+ this.#plain = void 0;
1816
+ this.#dotStart = void 0;
1817
+ }
1818
+ start(dotStart) {
1819
+ if (dotStart) {
1820
+ if (this.#dotStart) return this.#dotStart;
1821
+ const state = this.#dotSim.state();
1822
+ this.#dotSim.add(state, this.#start, 0, true);
1823
+ return this.#dotStart = this.#make(this.#dotSim.done(state));
1824
+ }
1825
+ if (this.#plain) return this.#plain;
1826
+ const state = this.#sim.state();
1827
+ this.#sim.add(state, this.#start, 0, true);
1828
+ return this.#plain = this.#intern(this.#sim.done(state));
1829
+ }
1830
+ next(d, c) {
1831
+ const code = c.charCodeAt(0);
1832
+ const found = code < 128 ? void 0 : d.next.get(c);
1833
+ if (found) return found;
1834
+ const n = d === this.#dotStart ? this.#intern(this.#dotSim.step(d.state, c, 0, true)) : this.#intern(this.#sim.step(d.state, c, 1, true));
1835
+ if (code < 128) {
1836
+ if (!d.ascii) {
1837
+ d.ascii = new Array(128);
1838
+ this.#size += 128;
1830
1839
  }
1831
- let end = "";
1832
- if (this.isEnd() && this.#root.#filledNegs && this.#parent?.type === "!") end = "(?:$|\\/)";
1833
- return [
1834
- start + src + end,
1835
- unescape(src),
1836
- this.#hasMagic = !!this.#hasMagic,
1837
- this.#uflag
1838
- ];
1839
- }
1840
- const repeated = this.type === "*" || this.type === "+";
1841
- const start = this.type === "!" ? "(?:(?!(?:" : "(?:";
1842
- let body = this.#partsToRegExp(dot);
1843
- if (this.isStart() && this.isEnd() && !body && this.type !== "!") {
1844
- const s = this.toString();
1845
- const me = this;
1846
- me.#parts = [s];
1847
- me.type = null;
1848
- me.#hasMagic = void 0;
1849
- return [
1850
- s,
1851
- unescape(this.toString()),
1852
- false,
1853
- false
1854
- ];
1855
- }
1856
- let bodyDotAllowed = !repeated || allowDot || dot || false ? "" : this.#partsToRegExp(true);
1857
- if (bodyDotAllowed === body) bodyDotAllowed = "";
1858
- if (bodyDotAllowed) body = `(?:${body})(?:${bodyDotAllowed})*?`;
1859
- let final = "";
1860
- if (this.type === "!" && this.#emptyExt) final = (this.isStart() && !dot ? startNoDot : "") + starNoEmpty;
1861
- else {
1862
- const close = this.type === "!" ? "))" + (this.isStart() && !dot && !allowDot ? startNoDot : "") + "[^/]*?)" : this.type === "@" ? ")" : this.type === "?" ? ")?" : this.type === "+" && bodyDotAllowed ? ")" : this.type === "*" && bodyDotAllowed ? `)?` : `)${this.type}`;
1863
- final = start + body + close;
1864
- }
1865
- return [
1866
- final,
1867
- unescape(body),
1868
- this.#hasMagic = !!this.#hasMagic,
1869
- this.#uflag
1870
- ];
1840
+ d.ascii[code] = n;
1841
+ } else d.next.set(c, n);
1842
+ this.#size++;
1843
+ return n;
1871
1844
  }
1872
- #flatten() {
1873
- if (!isExtglobAST(this)) {
1874
- for (const p of this.#parts) if (typeof p === "object") p.#flatten();
1875
- } else {
1876
- let iterations = 0;
1877
- let done = false;
1878
- do {
1879
- done = true;
1880
- for (let i = 0; i < this.#parts.length; i++) {
1881
- const c = this.#parts[i];
1882
- if (typeof c === "object") {
1883
- c.#flatten();
1884
- if (this.#canAdopt(c)) {
1885
- done = false;
1886
- this.#adopt(c, i);
1887
- } else if (this.#canAdoptWithSpace(c)) {
1888
- done = false;
1889
- this.#adoptWithSpace(c, i);
1890
- } else if (this.#canUsurp(c)) {
1891
- done = false;
1892
- this.#usurp(c);
1893
- }
1894
- }
1895
- }
1896
- } while (!done && ++iterations < 10);
1845
+ };
1846
+ const linear = (start) => {
1847
+ const nodes = [];
1848
+ for (let n = start; n.t !== "match"; n = n.next) {
1849
+ if (n.t === "split" || n.t === "neg") return void 0;
1850
+ nodes.push(n);
1851
+ }
1852
+ return nodes;
1853
+ };
1854
+ const testLinear = (nodes, chars, start, end) => {
1855
+ let ni = 0;
1856
+ let ci = start;
1857
+ let starNi = -1;
1858
+ let starCi = 0;
1859
+ while (ci < end) {
1860
+ const n = nodes[ni];
1861
+ if (n?.t === "star") {
1862
+ starNi = ni++;
1863
+ starCi = ci;
1864
+ continue;
1897
1865
  }
1898
- this.#toString = void 0;
1866
+ const c = chars[ci];
1867
+ if (n && (n.t === "any" || n.t === "lit" && litMatch(n, c) || n.t === "class" && n.re.test(c))) {
1868
+ ni++;
1869
+ ci++;
1870
+ continue;
1871
+ }
1872
+ if (starNi === -1) return false;
1873
+ ni = starNi + 1;
1874
+ ci = ++starCi;
1899
1875
  }
1900
- #partsToRegExp(dot) {
1901
- return this.#parts.map((p) => {
1902
- /* c8 ignore start */
1903
- if (typeof p === "string") throw new Error("string type in extglob ast??");
1904
- /* c8 ignore stop */
1905
- const [re, _, _hasMagic, uflag] = p.toRegExpSource(dot);
1906
- this.#uflag = this.#uflag || uflag;
1907
- return re;
1908
- }).filter((p) => !(this.isStart() && this.isEnd()) || !!p).join("|");
1909
- }
1910
- static #parseGlob(glob, hasMagic, noEmpty = false) {
1911
- let escaping = false;
1912
- let re = "";
1913
- let uflag = false;
1914
- let inStar = false;
1915
- for (let i = 0; i < glob.length; i++) {
1916
- const c = glob.charAt(i);
1917
- if (escaping) {
1918
- escaping = false;
1919
- re += (reSpecials.has(c) ? "\\" : "") + c;
1920
- continue;
1876
+ while (nodes[ni]?.t === "star") ni++;
1877
+ return ni === nodes.length;
1878
+ };
1879
+ const lengths = (items) => {
1880
+ let min = 0;
1881
+ let max = 0;
1882
+ for (const it of items) {
1883
+ const [lo, hi] = itemLengths(it);
1884
+ min += lo;
1885
+ max += hi;
1886
+ }
1887
+ return [min, max];
1888
+ };
1889
+ const itemLengths = (it) => {
1890
+ if (it.t === "star") return [0, Infinity];
1891
+ if (it.t !== "ext") return [1, 1];
1892
+ if (it.type === "!") return [0, Infinity];
1893
+ const alts = it.alts.map(lengths);
1894
+ const min = Math.min(...alts.map((a) => a[0]));
1895
+ const max = Math.max(...alts.map((a) => a[1]));
1896
+ const loop = max === 0 ? 0 : Infinity;
1897
+ return it.type === "@" ? [min, max] : it.type === "?" ? [0, max] : it.type === "*" ? [0, loop] : [min, loop];
1898
+ };
1899
+ const hasAffix = (lits, chars, start) => {
1900
+ for (let j = 0; j < lits.length; j++) if (!litMatch(lits[j], chars[start + j])) return false;
1901
+ return true;
1902
+ };
1903
+ const slashOrSurrogate = /[/\ud800-\udfff]/;
1904
+ const surrogate = /[\ud800-\udfff]/;
1905
+ const codePoints = (s) => surrogate.test(s) ? [...s] : s;
1906
+ const noSlash = (s) => {
1907
+ if (s.includes("/")) throw new Error("can only match a single path portion, got: " + s);
1908
+ };
1909
+ var Matcher = class {
1910
+ pattern;
1911
+ options;
1912
+ #start;
1913
+ #size;
1914
+ #marks;
1915
+ #dotsSim;
1916
+ #literal;
1917
+ #literalFold = false;
1918
+ #literalRe;
1919
+ #linear;
1920
+ #wild = false;
1921
+ #min = 0;
1922
+ #max = Infinity;
1923
+ #prefix = [];
1924
+ #suffix = [];
1925
+ #prefixStr;
1926
+ #suffixStr;
1927
+ #affix = false;
1928
+ #dfa;
1929
+ #form;
1930
+ constructor(pattern, options = {}) {
1931
+ if (pattern.includes("/")) throw new Error("can only match a single path portion, got pattern: " + pattern);
1932
+ this.pattern = pattern;
1933
+ this.options = options;
1934
+ const { nocase = false, noext = false, normalize: n } = options;
1935
+ this.#form = n === true ? "NFC" : n || void 0;
1936
+ const literal = /^[?*+@]\(\)$/.test(pattern);
1937
+ const toks = tokenize(pattern, nocase, noext || literal, this.#form, options.rangeMark);
1938
+ let [items] = build(toks, pair(toks), 0, toks.length, true);
1939
+ if (this.#form) items = normalize(items, this.#form);
1940
+ const [start, size] = compile(items, nocase);
1941
+ this.#start = start;
1942
+ this.#size = size;
1943
+ if (items.every((it) => it.t === "lit")) {
1944
+ this.#literal = items.map((it) => it.ch).join("");
1945
+ this.#literalFold = nocase;
1946
+ } else {
1947
+ const lit = (it) => it.t !== "lit" ? void 0 : nocase ? {
1948
+ ch: it.ch,
1949
+ re: foldRe(it.ch)
1950
+ } : { ch: it.ch };
1951
+ for (const it of items) {
1952
+ const l = lit(it);
1953
+ if (!l) break;
1954
+ this.#prefix.push(l);
1921
1955
  }
1922
- if (c === "*") {
1923
- if (inStar) continue;
1924
- inStar = true;
1925
- re += noEmpty && /^[*]+$/.test(glob) ? starNoEmpty : star$1;
1926
- hasMagic = true;
1927
- continue;
1928
- } else inStar = false;
1929
- if (c === "\\") {
1930
- if (i === glob.length - 1) re += "\\\\";
1931
- else escaping = true;
1932
- continue;
1956
+ for (let j = items.length - 1; j >= 0; j--) {
1957
+ const l = lit(items[j]);
1958
+ if (!l) break;
1959
+ this.#suffix.unshift(l);
1933
1960
  }
1934
- if (c === "[") {
1935
- const [src, needUflag, consumed, magic] = parseClass(glob, i);
1936
- if (consumed) {
1937
- re += src;
1938
- uflag = uflag || needUflag;
1939
- i += consumed - 1;
1940
- hasMagic = hasMagic || magic;
1941
- continue;
1942
- }
1961
+ this.#affix = !!(this.#prefix.length || this.#suffix.length);
1962
+ if (!nocase) {
1963
+ this.#prefixStr = this.#prefix.map((l) => l.ch).join("");
1964
+ this.#suffixStr = this.#suffix.map((l) => l.ch).join("");
1943
1965
  }
1944
- if (c === "?") {
1945
- re += qmark;
1946
- hasMagic = true;
1947
- continue;
1966
+ this.#linear = linear(this.#start)?.slice(this.#prefix.length, -this.#suffix.length || void 0);
1967
+ this.#wild = !!this.#linear?.every((n) => n.t === "star" || n.t === "any");
1968
+ const [min, max] = lengths(items);
1969
+ this.#min = min;
1970
+ this.#max = max;
1971
+ }
1972
+ }
1973
+ test(s) {
1974
+ if (this.#form) {
1975
+ noSlash(s);
1976
+ return this.#test(s.normalize(this.#form));
1977
+ }
1978
+ if (slashOrSurrogate.test(s)) {
1979
+ noSlash(s);
1980
+ return this.#test(s, [...s]);
1981
+ }
1982
+ return this.#test(s, s);
1983
+ }
1984
+ /**
1985
+ * The same as {@link Matcher#test}, but the string is not checked
1986
+ * for `/` chars, so the result for a string that has one is not
1987
+ * defined. Only use it for a string that is known to be one path
1988
+ * portion, such as a part of a path that was split on `/`. It can
1989
+ * be faster, because some patterns do not need to look at each char
1990
+ * of the string.
1991
+ */
1992
+ testUnchecked(s) {
1993
+ return this.#test(this.#form ? s.normalize(this.#form) : s);
1994
+ }
1995
+ #test(s, chars) {
1996
+ if (this.#literal !== void 0) return this.#literalFold ? (this.#literalRe ??= newFoldRe(this.#literal)).test(s) : s === this.#literal;
1997
+ const min = this.#min;
1998
+ const max = this.#max;
1999
+ if (chars === void 0) {
2000
+ const most = s.length;
2001
+ const least = most + 1 >> 1;
2002
+ if (most < min || least > max) return false;
2003
+ if (least < min || most > max) chars = codePoints(s);
2004
+ }
2005
+ if (chars !== void 0 && (chars.length < min || chars.length > max)) return false;
2006
+ const prefix = this.#prefix.length;
2007
+ if (this.#affix) {
2008
+ if (this.#prefixStr !== void 0 && this.#suffixStr !== void 0) {
2009
+ if (!s.startsWith(this.#prefixStr) || !s.endsWith(this.#suffixStr)) return false;
2010
+ } else {
2011
+ chars ??= codePoints(s);
2012
+ const end = chars.length - this.#suffix.length;
2013
+ if (!hasAffix(this.#prefix, chars, 0) || !hasAffix(this.#suffix, chars, end)) return false;
1948
2014
  }
1949
- re += regExpEscape$1(c);
1950
2015
  }
1951
- return [
1952
- re,
1953
- unescape(glob),
1954
- !!hasMagic,
1955
- uflag
1956
- ];
2016
+ const dotStart = !this.options.dot && s.startsWith(".");
2017
+ if (this.#linear) {
2018
+ if (s === "." || s === "..") return false;
2019
+ if (dotStart && !prefix) return false;
2020
+ if (this.#wild) return true;
2021
+ chars ??= codePoints(s);
2022
+ const end = chars.length - this.#suffix.length;
2023
+ return testLinear(this.#linear, chars, prefix, end);
2024
+ }
2025
+ chars ??= codePoints(s);
2026
+ if (s === "." || s === "..") {
2027
+ this.#marks ??= marks(this.#size);
2028
+ const sim = this.#dotsSim ??= new Sim(true, false, this.#marks);
2029
+ const start = sim.state();
2030
+ sim.add(start, this.#start, 0, true);
2031
+ let state = sim.done(start);
2032
+ for (let i = 0; i < chars.length; i++) state = sim.step(state, chars[i], i, true);
2033
+ return state.match;
2034
+ }
2035
+ this.#marks ??= marks(this.#size);
2036
+ const dfa = this.#dfa ??= new Dfa(this.#start, this.#marks);
2037
+ let d = dfa.start(dotStart);
2038
+ const str = chars === s;
2039
+ for (let i = 0; i < chars.length; i++) {
2040
+ if (d.dead) return false;
2041
+ const code = str ? s.charCodeAt(i) : chars[i].charCodeAt(0);
2042
+ d = d.ascii?.[code] ?? dfa.next(d, chars[i]);
2043
+ }
2044
+ return d.match;
2045
+ }
2046
+ /** a readable listing of the state machine */
2047
+ toString() {
2048
+ return show(this.#start);
1957
2049
  }
1958
2050
  };
1959
- _a = AST;
1960
- //#endregion
1961
- //#region ../../node_modules/.pnpm/minimatch@10.2.6/node_modules/minimatch/dist/esm/escape.js
2051
+ // ../../node_modules/.pnpm/minimatch@11.0.9/node_modules/minimatch/dist/esm/assert-valid-pattern.js
2052
+ const MAX_PATTERN_LENGTH = 65536;
2053
+ const assertValidPattern = (pattern) => {
2054
+ if (typeof pattern !== "string") throw new TypeError("invalid pattern");
2055
+ if (pattern.length > MAX_PATTERN_LENGTH) throw new TypeError("pattern is too long");
2056
+ };
2057
+ // ../../node_modules/.pnpm/minimatch@11.0.9/node_modules/minimatch/dist/esm/escape.js
1962
2058
  /**
1963
2059
  * Escape all magic characters in a glob pattern.
1964
2060
  *
@@ -1970,68 +2066,154 @@ _a = AST;
1970
2066
  *
1971
2067
  * If the {@link MinimatchOptions.magicalBraces} option is used,
1972
2068
  * then braces (`{` and `}`) will be escaped.
2069
+ *
2070
+ * A leading `#` or `!` is escaped as well, so that the result is never a
2071
+ * comment or a negated pattern. In `windowsPathsNoEscape` mode, a leading
2072
+ * `!` is written as `@(!)`, because `[!` starts a negated class.
1973
2073
  */
1974
2074
  const escape = (s, { windowsPathsNoEscape = false, magicalBraces = false } = {}) => {
1975
- if (magicalBraces) return windowsPathsNoEscape ? s.replace(/[?*()[\]{}]/g, "[$&]") : s.replace(/[?*()[\]\\{}]/g, "\\$&");
1976
- return windowsPathsNoEscape ? s.replace(/[?*()[\]]/g, "[$&]") : s.replace(/[?*()[\]\\]/g, "\\$&");
1977
- };
1978
- //#endregion
1979
- //#region ../../node_modules/.pnpm/minimatch@10.2.6/node_modules/minimatch/dist/esm/index.js
1980
- const minimatch = (p, pattern, options = {}) => {
1981
- assertValidPattern(pattern);
1982
- if (!options.nocomment && pattern.charAt(0) === "#") return false;
1983
- return new Minimatch(pattern, options).match(p);
1984
- };
1985
- const starDotExtRE = /^\*+([^+@!?*[(]*)$/;
1986
- const starDotExtTest = (ext) => (f) => !f.startsWith(".") && f.endsWith(ext);
1987
- const starDotExtTestDot = (ext) => (f) => f.endsWith(ext);
1988
- const starDotExtTestNocase = (ext) => {
1989
- ext = ext.toLowerCase();
1990
- return (f) => !f.startsWith(".") && f.toLowerCase().endsWith(ext);
1991
- };
1992
- const starDotExtTestNocaseDot = (ext) => {
1993
- ext = ext.toLowerCase();
1994
- return (f) => f.toLowerCase().endsWith(ext);
2075
+ const e = magicalBraces ? windowsPathsNoEscape ? s.replace(/[?*()[\]{}]/g, "[$&]") : s.replace(/[?*()[\]\\{}]/g, "\\$&") : windowsPathsNoEscape ? s.replace(/[?*()[\]]/g, "[$&]") : s.replace(/[?*()[\]\\]/g, "\\$&");
2076
+ const c = e.charAt(0);
2077
+ if (c === "#") return (windowsPathsNoEscape ? "[#]" : "\\#") + e.slice(1);
2078
+ if (c === "!") return (windowsPathsNoEscape ? "@(!)" : "\\!") + e.slice(1);
2079
+ return e;
1995
2080
  };
1996
- const starDotStarRE = /^\*+\.\*+$/;
1997
- const starDotStarTest = (f) => !f.startsWith(".") && f.includes(".");
1998
- const starDotStarTestDot = (f) => f !== "." && f !== ".." && f.includes(".");
1999
- const dotStarRE = /^\.\*+$/;
2000
- const dotStarTest = (f) => f !== "." && f !== ".." && f.startsWith(".");
2001
- const starRE = /^\*+$/;
2002
- const starTest = (f) => f.length !== 0 && !f.startsWith(".");
2003
- const starTestDot = (f) => f.length !== 0 && f !== "." && f !== "..";
2004
- const qmarksRE = /^\?+([^+@!?*[(]*)?$/;
2005
- const qmarksTestNocase = ([$0, ext = ""]) => {
2006
- const noext = qmarksTestNoExt([$0]);
2007
- if (!ext) return noext;
2008
- ext = ext.toLowerCase();
2009
- return (f) => noext(f) && f.toLowerCase().endsWith(ext);
2081
+ // ../../node_modules/.pnpm/minimatch@11.0.9/node_modules/minimatch/dist/esm/unescape.js
2082
+ /**
2083
+ * Un-escape a string that has been escaped with {@link escape}.
2084
+ *
2085
+ * If the {@link MinimatchOptions.windowsPathsNoEscape} option is used, then
2086
+ * square-bracket escapes are removed, but not backslash escapes.
2087
+ *
2088
+ * For example, it will turn the string `'[*]'` into `*`, but it will not
2089
+ * turn `'\\*'` into `'*'`, because `\` is a path separator in
2090
+ * `windowsPathsNoEscape` mode.
2091
+ *
2092
+ * When `windowsPathsNoEscape` is not set, then both square-bracket escapes and
2093
+ * backslash escapes are removed.
2094
+ *
2095
+ * Slashes (and backslashes in `windowsPathsNoEscape` mode) cannot be escaped
2096
+ * or unescaped.
2097
+ *
2098
+ * When `magicalBraces` is not set, escapes of braces (`{` and `}`) will not be
2099
+ * unescaped.
2100
+ */
2101
+ const unescape = (s, { windowsPathsNoEscape = false, magicalBraces = true } = {}) => {
2102
+ if (windowsPathsNoEscape && s.startsWith("@(!)")) return "!" + unescape(s.slice(4), {
2103
+ windowsPathsNoEscape,
2104
+ magicalBraces
2105
+ });
2106
+ if (magicalBraces) return windowsPathsNoEscape ? s.replace(/\[([^/\\])\]/g, "$1") : s.replace(/((?!\\).|^)\[([^/\\])\]/g, "$1$2").replace(/\\([^/])/g, "$1");
2107
+ return windowsPathsNoEscape ? s.replace(/\[([^/\\{}])\]/g, "$1") : s.replace(/((?!\\).|^)\[([^/\\{}])\]/g, "$1$2").replace(/\\([^/{}])/g, "$1");
2010
2108
  };
2011
- const qmarksTestNocaseDot = ([$0, ext = ""]) => {
2012
- const noext = qmarksTestNoExtDot([$0]);
2013
- if (!ext) return noext;
2014
- ext = ext.toLowerCase();
2015
- return (f) => noext(f) && f.toLowerCase().endsWith(ext);
2109
+ // ../../node_modules/.pnpm/minimatch@11.0.9/node_modules/minimatch/dist/esm/index.js
2110
+ const DEFAULT_BRACE_EXPAND_MAX = 1e5;
2111
+ const DEFAULT_GLOB_STAR_RECURSION_MAX = 200;
2112
+ const AWE_KEY = "allowWindowsEscape";
2113
+ const minimatch = (p, pattern, options) => {
2114
+ assertValidPattern(pattern);
2115
+ if (!options?.nocomment && pattern.charAt(0) === "#") return false;
2116
+ return cachedMinimatch(pattern, options).match(p);
2016
2117
  };
2017
- const qmarksTestDot = ([$0, ext = ""]) => {
2018
- const noext = qmarksTestNoExtDot([$0]);
2019
- return !ext ? noext : (f) => noext(f) && f.endsWith(ext);
2118
+ let cache = /* @__PURE__ */ new Map();
2119
+ let oldCache = /* @__PURE__ */ new Map();
2120
+ let cacheSize = 0;
2121
+ let cacheTotalWeight = 0;
2122
+ const cacheMax = 256;
2123
+ const cacheMaxWeight = 32768;
2124
+ const cacheMaxEntryWeight = 4096;
2125
+ const cacheWeight = (mm) => {
2126
+ let w = mm.pattern.length;
2127
+ for (const s of mm.globSet) {
2128
+ w += s.length + 1;
2129
+ if (w > cacheMaxEntryWeight) break;
2130
+ }
2131
+ return w;
2020
2132
  };
2021
- const qmarksTest = ([$0, ext = ""]) => {
2022
- const noext = qmarksTestNoExt([$0]);
2023
- return !ext ? noext : (f) => noext(f) && f.endsWith(ext);
2133
+ const tri = (v) => v === void 0 ? 0 : v ? 2 : 1;
2134
+ const booleanWeights = new Map(Object.keys({
2135
+ nobrace: 0,
2136
+ nocomment: 0,
2137
+ nonegate: 0,
2138
+ noglobstar: 0,
2139
+ noext: 0,
2140
+ nonull: 0,
2141
+ partial: 0,
2142
+ dot: 0,
2143
+ nocase: 0,
2144
+ nocaseMagicOnly: 0,
2145
+ magicalBraces: 0,
2146
+ matchBase: 0,
2147
+ flipNegate: 0,
2148
+ preserveMultipleSlashes: 0,
2149
+ windowsNoMagicRoot: 0
2150
+ }).map((k, i) => [k, 24 * 3 ** i]));
2151
+ const optionsKey = (o) => {
2152
+ let n = 0;
2153
+ let wpe = false;
2154
+ for (const k in o) {
2155
+ const v = o[k];
2156
+ switch (k) {
2157
+ case "windowsPathsNoEscape":
2158
+ if (v) wpe = true;
2159
+ break;
2160
+ case AWE_KEY:
2161
+ if (v === false) wpe = true;
2162
+ break;
2163
+ case "platform": {
2164
+ const p = v || defaultPlatform;
2165
+ if (p === defaultPlatform) break;
2166
+ if (p === "darwin") n += 3;
2167
+ else if (p === "win32") n += 6;
2168
+ else if (p === "linux") n += 9;
2169
+ else return JSON.stringify(o);
2170
+ break;
2171
+ }
2172
+ case "optimizationLevel":
2173
+ if (v === void 0) break;
2174
+ n += v >= 2 ? 1 : v >= 1 ? 0 : 2;
2175
+ break;
2176
+ case "braceExpandMax":
2177
+ if (v !== void 0 && v !== DEFAULT_BRACE_EXPAND_MAX) return JSON.stringify(o);
2178
+ break;
2179
+ case "maxGlobstarRecursion":
2180
+ if (v !== void 0 && v !== DEFAULT_GLOB_STAR_RECURSION_MAX) return JSON.stringify(o);
2181
+ break;
2182
+ case "normalize":
2183
+ if (v !== void 0) return JSON.stringify(o);
2184
+ break;
2185
+ default: n += (booleanWeights.get(k) ?? 0) * tri(v);
2186
+ }
2187
+ }
2188
+ return wpe ? n + 12 : n;
2024
2189
  };
2025
- const qmarksTestNoExt = ([$0]) => {
2026
- const len = $0.length;
2027
- return (f) => f.length === len && !f.startsWith(".");
2190
+ const copyOptions = (o) => {
2191
+ const copy = {};
2192
+ for (const k in o) copy[k] = o[k];
2193
+ return copy;
2028
2194
  };
2029
- const qmarksTestNoExtDot = ([$0]) => {
2030
- const len = $0.length;
2031
- return (f) => f.length === len && f !== "." && f !== "..";
2195
+ const cachedMinimatch = (pattern, options) => {
2196
+ const key = options ? optionsKey(options) : 0;
2197
+ let mm = cache.get(key)?.get(pattern);
2198
+ if (mm) return mm;
2199
+ mm = oldCache.get(key)?.get(pattern) ?? new Minimatch(pattern, copyOptions(options));
2200
+ const weight = cacheWeight(mm);
2201
+ if (weight > cacheMaxEntryWeight) return mm;
2202
+ if (cacheSize >= cacheMax || cacheTotalWeight + weight > cacheMaxWeight) {
2203
+ oldCache = cache;
2204
+ cache = /* @__PURE__ */ new Map();
2205
+ cacheSize = 0;
2206
+ cacheTotalWeight = 0;
2207
+ }
2208
+ let byPattern = cache.get(key);
2209
+ if (!byPattern) cache.set(key, byPattern = /* @__PURE__ */ new Map());
2210
+ byPattern.set(pattern, mm);
2211
+ cacheSize++;
2212
+ cacheTotalWeight += weight;
2213
+ return mm;
2032
2214
  };
2033
2215
  /* c8 ignore start */
2034
- const defaultPlatform = typeof process === "object" && process ? typeof process.env === "object" && process.env && process.env.__MINIMATCH_TESTING_PLATFORM__ || process.platform : "posix";
2216
+ const defaultPlatform = typeof process === "object" && process ? process.env?.__MINIMATCH_TESTING_PLATFORM__ || process.platform : "posix";
2035
2217
  const path = {
2036
2218
  win32: { sep: "\\" },
2037
2219
  posix: { sep: "/" }
@@ -2039,10 +2221,10 @@ const path = {
2039
2221
  minimatch.sep = defaultPlatform === "win32" ? path.win32.sep : path.posix.sep;
2040
2222
  const GLOBSTAR = Symbol("globstar **");
2041
2223
  minimatch.GLOBSTAR = GLOBSTAR;
2042
- const star = "[^/]*?";
2043
- const twoStarDot = "(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?";
2044
- const twoStarNoDot = "(?:(?!(?:\\/|^)\\.).)*?";
2045
- const filter = (pattern, options = {}) => (p) => minimatch(p, pattern, options);
2224
+ const filter = (pattern, options) => {
2225
+ let mm;
2226
+ return (p) => (mm ??= cachedMinimatch(pattern, options)).match(p);
2227
+ };
2046
2228
  minimatch.filter = filter;
2047
2229
  const ext = (a, b = {}) => Object.assign({}, a, b);
2048
2230
  const defaults = (def) => {
@@ -2058,21 +2240,10 @@ const defaults = (def) => {
2058
2240
  return orig.defaults(ext(def, options)).Minimatch;
2059
2241
  }
2060
2242
  },
2061
- AST: class AST extends orig.AST {
2062
- /* c8 ignore start */
2063
- constructor(type, parent, options = {}) {
2064
- super(type, parent, ext(def, options));
2065
- }
2066
- /* c8 ignore stop */
2067
- static fromGlob(pattern, options = {}) {
2068
- return orig.AST.fromGlob(pattern, ext(def, options));
2069
- }
2070
- },
2071
2243
  unescape: (s, options = {}) => orig.unescape(s, ext(def, options)),
2072
2244
  escape: (s, options = {}) => orig.escape(s, ext(def, options)),
2073
2245
  filter: (pattern, options = {}) => orig.filter(pattern, ext(def, options)),
2074
2246
  defaults: (options) => orig.defaults(ext(def, options)),
2075
- makeRe: (pattern, options = {}) => orig.makeRe(pattern, ext(def, options)),
2076
2247
  braceExpand: (pattern, options = {}) => orig.braceExpand(pattern, ext(def, options)),
2077
2248
  match: (list, pattern, options = {}) => orig.match(list, pattern, ext(def, options)),
2078
2249
  sep: orig.sep,
@@ -2083,11 +2254,27 @@ minimatch.defaults = defaults;
2083
2254
  const braceExpand = (pattern, options = {}) => {
2084
2255
  assertValidPattern(pattern);
2085
2256
  if (options.nobrace || !/\{(?:(?!\{).)*\}/.test(pattern)) return [pattern];
2086
- return expand(pattern, { max: options.braceExpandMax });
2257
+ let p = pattern.replace(/\\\\/g, "\\\\\\\\");
2258
+ if (options.windowsPathsNoEscape || options[AWE_KEY] === false) p = p.replace(/\[([{}])\]/g, "[\\$1]");
2259
+ return expand(p, { max: options.braceExpandMax });
2087
2260
  };
2088
2261
  minimatch.braceExpand = braceExpand;
2089
- const makeRe = (pattern, options = {}) => new Minimatch(pattern, options).makeRe();
2090
- minimatch.makeRe = makeRe;
2262
+ const RANGE_MIN = 100;
2263
+ const rangeRe = /(?<![\\$])\{(-?\d+)\.\.(-?\d+)\}/g;
2264
+ const inRepeatOrNegExt = (portion, mark) => {
2265
+ const stack = [];
2266
+ for (let i = 0; i < portion.length; i++) {
2267
+ const c = portion.charAt(i);
2268
+ if (c === "\\") i++;
2269
+ else if (c === mark) {
2270
+ if (stack.some((t) => t !== "@" && t !== "?")) return true;
2271
+ } else if (portion.charAt(i + 1) === "(" && "!?+*@".includes(c)) {
2272
+ stack.push(c);
2273
+ i++;
2274
+ } else if (c === ")") stack.pop();
2275
+ }
2276
+ return false;
2277
+ };
2091
2278
  const match = (list, pattern, options = {}) => {
2092
2279
  const mm = new Minimatch(pattern, options);
2093
2280
  list = list.filter((f) => mm.match(f));
@@ -2096,7 +2283,114 @@ const match = (list, pattern, options = {}) => {
2096
2283
  };
2097
2284
  minimatch.match = match;
2098
2285
  const globMagic = /[?*]|[+@!]\(.*?\)|\[|\]/;
2099
- const regExpEscape = (s) => s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
2286
+ const classEnd = (pattern, start) => {
2287
+ let i = start + 1;
2288
+ if (pattern.charAt(i) === "!" || pattern.charAt(i) === "^") i++;
2289
+ let sawStart = false;
2290
+ for (; i < pattern.length; i++) {
2291
+ const c = pattern.charAt(i);
2292
+ if (c === "]" && sawStart) return i;
2293
+ sawStart = true;
2294
+ if (c === "\\") i++;
2295
+ }
2296
+ return -1;
2297
+ };
2298
+ const literal = (pattern, noext) => {
2299
+ if (!noext && (pattern === "+()" || pattern === "@()")) return pattern;
2300
+ let lit = "";
2301
+ for (let i = 0; i < pattern.length; i++) {
2302
+ const c = pattern.charAt(i);
2303
+ if (c === "\\") lit += pattern.charAt(++i) || c;
2304
+ else if (c === "*" || c === "?") return;
2305
+ else if (c === "[") {
2306
+ const close = classEnd(pattern, i);
2307
+ if (close === -1) {
2308
+ lit += c;
2309
+ continue;
2310
+ }
2311
+ let body = pattern.slice(i + 1, close);
2312
+ if (body.startsWith("\\")) body = body.slice(1);
2313
+ if ([...body].length !== 1 || "!^".includes(pattern.charAt(i + 1))) return;
2314
+ lit += body;
2315
+ i = close;
2316
+ } else if (!noext && "+@!".includes(c) && pattern.charAt(i + 1) === "(" && pattern.includes(")", i + 2)) return;
2317
+ else lit += c;
2318
+ }
2319
+ return lit;
2320
+ };
2321
+ const MAX_EXTGLOBS = 256;
2322
+ const extglobCount = (pattern) => {
2323
+ let n = 0;
2324
+ for (let i = 0; i < pattern.length - 1; i++) {
2325
+ const c = pattern.charAt(i);
2326
+ if (c === "\\") i++;
2327
+ else if ("+@!?*".includes(c) && pattern.charAt(i + 1) === "(") {
2328
+ n++;
2329
+ i++;
2330
+ }
2331
+ }
2332
+ return n;
2333
+ };
2334
+ const assertValidExtglobs = (pattern) => {
2335
+ if (extglobCount(pattern) > MAX_EXTGLOBS) throw new TypeError("pattern has too many extglobs");
2336
+ };
2337
+ const extSafe = (pattern) => {
2338
+ if (/^[?*+@]\(\)$/.test(pattern) || pattern.includes("[:")) return false;
2339
+ let depth = 0;
2340
+ for (let i = 0; i < pattern.length; i++) {
2341
+ const c = pattern.charAt(i);
2342
+ if (c === "\\") {
2343
+ if (++i === pattern.length) return false;
2344
+ } else if (c === "[") {
2345
+ const close = classEnd(pattern, i);
2346
+ if (close !== -1) i = close;
2347
+ } else if ("+@!?*".includes(c) && pattern.charAt(i + 1) === "(") {
2348
+ depth++;
2349
+ i++;
2350
+ } else if (c === ")") {
2351
+ if (!depth--) return false;
2352
+ } else if (c === "|" && !depth) return false;
2353
+ }
2354
+ return !depth;
2355
+ };
2356
+ let lastSplit;
2357
+ let lastChecked;
2358
+ const portionMatch = (p, f) => typeof p === "string" ? f === p : f !== "" && p.testUnchecked(f);
2359
+ const endIndex = (p, last, lastStart, prev, prevStart) => portionMatch(p, last) ? lastStart : prev !== void 0 && portionMatch(p, prev) ? prevStart : -1;
2360
+ const isDots = (p) => p === "." || p === "..";
2361
+ const isDrive = (p) => typeof p === "string" && /^[a-z]:$/i.test(p);
2362
+ const isLongUNC = (p) => typeof p === "string" && /^unc$/i.test(p);
2363
+ const uncHost = (p) => {
2364
+ if (p[0] !== "" || p[1] !== "") return -1;
2365
+ const h = p[2] !== "?" ? 2 : isLongUNC(p[3]) ? 4 : -1;
2366
+ const host = p[h];
2367
+ const share = p[h + 1];
2368
+ return h !== -1 && host !== void 0 && host !== "" && host !== GLOBSTAR && share !== void 0 && share !== "" && share !== GLOBSTAR ? h : -1;
2369
+ };
2370
+ const walkable = (p, dot) => !isDots(p) && (dot || !p.startsWith("."));
2371
+ const dotPortion = (f, start, end, dot, sep) => {
2372
+ for (let k = start; k < end;) {
2373
+ if (f.charCodeAt(k) === 46) {
2374
+ if (!dot) return true;
2375
+ const n = f.charCodeAt(k + 1) === 46 ? k + 2 : k + 1;
2376
+ if (n >= end || isSep(f.charCodeAt(n), sep)) return true;
2377
+ }
2378
+ const s = nextSep(f, k, sep);
2379
+ if (s === -1) return false;
2380
+ k = s + 1;
2381
+ while (k < end && isSep(f.charCodeAt(k), sep)) k++;
2382
+ }
2383
+ return false;
2384
+ };
2385
+ const isSep = (c, sep) => sep === "/" ? c === 47 : sep === "\\" ? c === 92 : c === 47 || c === 92;
2386
+ const nextSep = (f, from, sep) => {
2387
+ if (sep !== "both") return f.indexOf(sep, from);
2388
+ const s = f.indexOf("/", from);
2389
+ const b = f.indexOf("\\", from);
2390
+ return s === -1 ? b : b === -1 ? s : Math.min(s, b);
2391
+ };
2392
+ const lastSep = (f, from, sep) => sep !== "both" ? f.lastIndexOf(sep, from) : Math.max(f.lastIndexOf("/", from), f.lastIndexOf("\\", from));
2393
+ const PENDING = {};
2100
2394
  var Minimatch = class {
2101
2395
  options;
2102
2396
  set;
@@ -2115,20 +2409,28 @@ var Minimatch = class {
2115
2409
  platform;
2116
2410
  windowsNoMagicRoot;
2117
2411
  maxGlobstarRecursion;
2118
- regexp;
2412
+ #endCheck;
2413
+ #literalCheck;
2414
+ #level2;
2415
+ #form;
2416
+ #literals = [];
2417
+ #shapes = [];
2418
+ #endRows = [];
2419
+ #matchers = /* @__PURE__ */ new Map();
2420
+ #pending = false;
2421
+ #rangeMark;
2422
+ #globstarParts = /* @__PURE__ */ new WeakMap();
2119
2423
  constructor(pattern, options = {}) {
2120
2424
  assertValidPattern(pattern);
2121
2425
  options = options || {};
2122
2426
  this.options = options;
2123
- this.maxGlobstarRecursion = options.maxGlobstarRecursion ?? 200;
2427
+ this.maxGlobstarRecursion = options.maxGlobstarRecursion ?? DEFAULT_GLOB_STAR_RECURSION_MAX;
2124
2428
  this.pattern = pattern;
2125
2429
  this.platform = options.platform || defaultPlatform;
2126
2430
  this.isWindows = this.platform === "win32";
2127
- const awe = "allowWindowsEscape";
2128
- this.windowsPathsNoEscape = !!options.windowsPathsNoEscape || options[awe] === false;
2431
+ this.windowsPathsNoEscape = !!options.windowsPathsNoEscape || options[AWE_KEY] === false;
2129
2432
  if (this.windowsPathsNoEscape) this.pattern = this.pattern.replace(/\\/g, "/");
2130
2433
  this.preserveMultipleSlashes = !!options.preserveMultipleSlashes;
2131
- this.regexp = null;
2132
2434
  this.negate = false;
2133
2435
  this.nonegate = !!options.nonegate;
2134
2436
  this.comment = false;
@@ -2139,14 +2441,45 @@ var Minimatch = class {
2139
2441
  this.globSet = [];
2140
2442
  this.globParts = [];
2141
2443
  this.set = [];
2444
+ this.#endCheck = !this.preserveMultipleSlashes;
2445
+ this.#level2 = (options.optimizationLevel ?? 1) >= 2;
2446
+ const n = options.normalize;
2447
+ this.#form = n === true ? "NFC" : n || void 0;
2142
2448
  this.make();
2449
+ const drives = this.set.map((row) => this.#rootIndex(row));
2450
+ this.#endRows = this.set.map((row, r) => this.#endCheck && row.length - 1 > drives[r]);
2451
+ this.#literals = this.set.map((row, r) => {
2452
+ const end = this.#endRows[r] ? row.length - 1 : row.length;
2453
+ const lits = row.slice(drives[r] + 1, end).filter((p) => typeof p === "string" && !!p);
2454
+ return [...new Set(lits)];
2455
+ });
2456
+ this.#literalCheck = this.#literals.some((l) => l.length);
2457
+ this.#shapes = this.set.map((row, r) => {
2458
+ const [p0, p1, p2] = row;
2459
+ if (this.#endRows[r] && row.length === 2) {
2460
+ if (p0 === GLOBSTAR && p1 !== GLOBSTAR) return "tail";
2461
+ }
2462
+ if (this.#endRows[r] && options.matchBase && row.length === 1 && p0 !== GLOBSTAR && p0 !== "") return "base";
2463
+ if (!this.#endCheck || drives[r] !== -1) return void 0;
2464
+ if (row.length === 3 && p0 === GLOBSTAR && p2 === GLOBSTAR && p1 !== GLOBSTAR && p1 !== "" && this.maxGlobstarRecursion > 0) return "mid";
2465
+ if (row.length === 2 && p1 === GLOBSTAR && p0 !== GLOBSTAR && p0 !== "") return "head";
2466
+ });
2467
+ }
2468
+ #norm(p) {
2469
+ return this.#form ? p.normalize(this.#form) : p;
2470
+ }
2471
+ #rootIndex(row) {
2472
+ if (!this.isWindows) return -1;
2473
+ if (isDrive(row[0])) return 0;
2474
+ if (row[0] === "" && row[1] === "" && row[2] === "?" && isDrive(row[3])) return 3;
2475
+ const h = uncHost(row);
2476
+ return h === -1 ? -1 : h + 1;
2143
2477
  }
2144
2478
  hasMagic() {
2145
2479
  if (this.options.magicalBraces && this.set.length > 1) return true;
2146
2480
  for (const pattern of this.set) for (const part of pattern) if (typeof part !== "string") return true;
2147
2481
  return false;
2148
2482
  }
2149
- debug(..._) {}
2150
2483
  make() {
2151
2484
  const pattern = this.pattern;
2152
2485
  const options = this.options;
@@ -2159,28 +2492,108 @@ var Minimatch = class {
2159
2492
  return;
2160
2493
  }
2161
2494
  this.parseNegate();
2162
- this.globSet = [...new Set(this.braceExpand())];
2163
- if (options.debug) this.debug = (...args) => console.error(...args);
2164
- this.debug(this.pattern, this.globSet);
2165
- const rawGlobParts = this.globSet.map((s) => this.slashSplit(s));
2495
+ this.globSet = [...new Set(this.#expandBraces())];
2496
+ const rawGlobParts = this.globSet.map((s) => this.#slashSplit(s));
2166
2497
  this.globParts = this.preprocess(rawGlobParts);
2167
- this.debug(this.pattern, this.globParts);
2498
+ this.#pending = true;
2168
2499
  let set = this.globParts.map((s, _, __) => {
2169
2500
  if (this.isWindows && this.windowsNoMagicRoot) {
2170
- const isUNC = s[0] === "" && s[1] === "" && (s[2] === "?" || !globMagic.test(s[2])) && !globMagic.test(s[3]);
2501
+ const n = s[2] === "?" && isLongUNC(s[3]) ? 6 : 4;
2502
+ const isUNC = s[0] === "" && s[1] === "" && (s[2] === "?" || !globMagic.test(s[2])) && s.slice(3, n).every((p) => !globMagic.test(p));
2171
2503
  const isDrive = /^[a-z]:/i.test(s[0]);
2172
- if (isUNC) return [...s.slice(0, 4), ...s.slice(4).map((ss) => this.parse(ss))];
2173
- else if (isDrive) return [s[0], ...s.slice(1).map((ss) => this.parse(ss))];
2504
+ if (isUNC) return [...s.slice(0, n).map((p) => this.#norm(p)), ...s.slice(n).map((ss) => this.parse(ss))];
2505
+ else if (isDrive) return [this.#norm(s[0]), ...s.slice(1).map((ss) => this.parse(ss))];
2174
2506
  }
2175
2507
  return s.map((ss) => this.parse(ss));
2176
2508
  });
2177
- this.debug(this.pattern, set);
2178
2509
  this.set = set.filter((s) => s.indexOf(false) === -1);
2179
2510
  if (this.isWindows) for (let i = 0; i < this.set.length; i++) {
2180
2511
  const p = this.set[i];
2181
- if (p[0] === "" && p[1] === "" && this.globParts[i][2] === "?" && typeof p[3] === "string" && /^[a-z]:$/i.test(p[3])) p[2] = "?";
2512
+ if (p[0] === "" && p[1] === "" && this.globParts[i][2] === "?" && (isDrive(p[3]) || isLongUNC(this.globParts[i][3]))) {
2513
+ if (isLongUNC(this.globParts[i][3])) p[3] = "UNC";
2514
+ p[2] = "?";
2515
+ }
2516
+ }
2517
+ if (!options.noext) this.mergeRows();
2518
+ this.#pending = false;
2519
+ this.set.forEach((row, i) => {
2520
+ for (let k = 0; k < row.length; k++) if (row[k] === PENDING) row[k] = this.parse(this.globParts[i][k]);
2521
+ });
2522
+ }
2523
+ mergeRows() {
2524
+ let merged = true;
2525
+ while (merged) {
2526
+ merged = false;
2527
+ if (this.set.length < 2) return;
2528
+ let keys = this.#mergeKeys();
2529
+ const len = Math.max(0, ...this.set.map((r) => r.length));
2530
+ for (let k = 0; k < len; k++) {
2531
+ const groups = /* @__PURE__ */ new Map();
2532
+ const R = this.set.length + 1;
2533
+ this.set.forEach((row, i) => {
2534
+ if (!(row[k] instanceof Matcher || row[k] === PENDING) || !extSafe(this.globParts[i][k])) return;
2535
+ const { pre, suf } = keys[i];
2536
+ const key = pre[k] * R + suf[k + 1];
2537
+ const g = groups.get(key);
2538
+ if (g) g.push(i);
2539
+ else groups.set(key, [i]);
2540
+ });
2541
+ const drop = /* @__PURE__ */ new Set();
2542
+ for (const g of groups.values()) {
2543
+ if (g.length < 2) continue;
2544
+ const [first, ...rest] = g;
2545
+ const glob = `@(${g.map((i) => this.globParts[i][k]).join("|")})`;
2546
+ if (extglobCount(glob) > MAX_EXTGLOBS) continue;
2547
+ this.globParts[first][k] = glob;
2548
+ this.set[first][k] = this.parse(glob);
2549
+ for (const i of rest) drop.add(i);
2550
+ }
2551
+ if (drop.size) {
2552
+ merged = true;
2553
+ this.set = this.set.filter((_, i) => !drop.has(i));
2554
+ this.globParts = this.globParts.filter((_, i) => !drop.has(i));
2555
+ if (this.set.length < 2) return;
2556
+ keys = this.#mergeKeys();
2557
+ }
2558
+ }
2182
2559
  }
2183
- this.debug(this.pattern, this.set);
2560
+ }
2561
+ #mergeKeys() {
2562
+ const partIds = /* @__PURE__ */ new Map();
2563
+ const ids = this.globParts.map((parts) => parts.map((s) => {
2564
+ let id = partIds.get(s);
2565
+ if (id === void 0) partIds.set(s, id = partIds.size);
2566
+ return id;
2567
+ }));
2568
+ const P = partIds.size;
2569
+ const len = Math.max(0, ...ids.map((r) => r.length));
2570
+ const keys = ids.map((r) => ({
2571
+ pre: [0],
2572
+ suf: new Array(r.length + 1).fill(0)
2573
+ }));
2574
+ for (let k = 0; k < len; k++) {
2575
+ const m = /* @__PURE__ */ new Map();
2576
+ ids.forEach((r, i) => {
2577
+ if (k >= r.length) return;
2578
+ const { pre } = keys[i];
2579
+ const key = pre[k] * P + r[k];
2580
+ let id = m.get(key);
2581
+ if (id === void 0) m.set(key, id = m.size + 1);
2582
+ pre.push(id);
2583
+ });
2584
+ }
2585
+ for (let k = len - 1; k >= 0; k--) {
2586
+ const m = /* @__PURE__ */ new Map();
2587
+ ids.forEach((r, i) => {
2588
+ if (k >= r.length) return;
2589
+ const { suf } = keys[i];
2590
+ const key = suf[k + 1] * P + r[k];
2591
+ let id = m.get(key);
2592
+ if (id === void 0) m.set(key, id = m.size + 1);
2593
+ suf[k] = id;
2594
+ });
2595
+ }
2596
+ return keys;
2184
2597
  }
2185
2598
  preprocess(globParts) {
2186
2599
  if (this.options.noglobstar) {
@@ -2207,11 +2620,12 @@ var Minimatch = class {
2207
2620
  }
2208
2621
  levelOneOptimize(globParts) {
2209
2622
  return globParts.map((parts) => {
2623
+ const root = this.#rootIndex(parts) + 1;
2210
2624
  parts = parts.reduce((set, part) => {
2211
2625
  const prev = set[set.length - 1];
2212
2626
  if (part === "**" && prev === "**") return set;
2213
2627
  if (part === "..") {
2214
- if (prev && prev !== ".." && prev !== "." && prev !== "**") {
2628
+ if (set.length > root && prev && prev !== ".." && prev !== "." && prev !== "**") {
2215
2629
  set.pop();
2216
2630
  return set;
2217
2631
  }
@@ -2222,8 +2636,120 @@ var Minimatch = class {
2222
2636
  return parts.length === 0 ? [""] : parts;
2223
2637
  });
2224
2638
  }
2225
- levelTwoFileOptimize(parts) {
2226
- if (!Array.isArray(parts)) parts = this.slashSplit(parts);
2639
+ #canMatch(f) {
2640
+ const sep = !this.isWindows || !f.includes("\\") ? "/" : f.includes("/") ? "both" : "\\";
2641
+ let ends = this.#endCheck ? 0 : -1;
2642
+ let last = "";
2643
+ let lastStart = 0;
2644
+ let prev;
2645
+ let prevStart = 0;
2646
+ const dot = !!this.options.dot;
2647
+ ROWS: for (let r = 0; r < this.set.length; r++) {
2648
+ const row = this.set[r];
2649
+ const p = row[row.length - 1];
2650
+ let end = ends !== -1 && this.#endRows[r] && p !== GLOBSTAR;
2651
+ if (end && ends === 0) {
2652
+ const i = lastSep(f, f.length, sep);
2653
+ lastStart = i + 1;
2654
+ last = f.slice(lastStart);
2655
+ if (last === "" && i >= 0) {
2656
+ let j = i;
2657
+ while (j > 0 && isSep(f.charCodeAt(j - 1), sep)) j--;
2658
+ prevStart = j === 0 ? 0 : lastSep(f, j - 1, sep) + 1;
2659
+ prev = f.slice(prevStart, j);
2660
+ }
2661
+ const resolves = this.#level2 && (isDots(last) || last === "" && prev !== void 0 && isDots(prev));
2662
+ ends = resolves ? -1 : 1;
2663
+ end = !resolves;
2664
+ }
2665
+ let tailStart = -1;
2666
+ if (end && typeof p === "string") {
2667
+ tailStart = endIndex(p, last, lastStart, prev, prevStart);
2668
+ if (tailStart === -1) continue;
2669
+ }
2670
+ if (this.#literalCheck) {
2671
+ for (const l of this.#literals[r]) if (!f.includes(l)) continue ROWS;
2672
+ }
2673
+ if (end && typeof p === "object") {
2674
+ tailStart = endIndex(p, last, lastStart, prev, prevStart);
2675
+ if (tailStart === -1) continue;
2676
+ }
2677
+ const shape = this.#shapes[r];
2678
+ if (shape === "base" && end) return "yes";
2679
+ if (shape === "tail" && end) {
2680
+ if (this.#level2 && dotPortion(f, 0, tailStart, true, sep)) return "maybe";
2681
+ if (!dotPortion(f, 0, tailStart, dot, sep)) return "yes";
2682
+ continue;
2683
+ }
2684
+ if (shape === "mid" || shape === "head") {
2685
+ const m = this.#walk(f, row, shape === "head", dot, sep);
2686
+ if (m !== "no") return m;
2687
+ continue;
2688
+ }
2689
+ return "maybe";
2690
+ }
2691
+ return "no";
2692
+ }
2693
+ #matchShape(file, row, shape) {
2694
+ const dot = !!this.options.dot;
2695
+ const n = file.length;
2696
+ if (shape === "head") {
2697
+ if (n < 2 || !portionMatch(row[0], file[0])) return false;
2698
+ for (let i = 1; i < n; i++) if (!walkable(file[i], dot)) return false;
2699
+ return true;
2700
+ }
2701
+ const x = row[1];
2702
+ if (shape === "tail") {
2703
+ let t = n - 1;
2704
+ if (!portionMatch(x, file[t])) {
2705
+ if (file[t] !== "" || n === 1 || !portionMatch(x, file[--t])) return false;
2706
+ }
2707
+ for (let i = 0; i < t; i++) if (!walkable(file[i], dot)) return false;
2708
+ return true;
2709
+ }
2710
+ for (let k = 0; k < n; k++) {
2711
+ if (portionMatch(x, file[k]) && k + 1 < n) {
2712
+ let i = k + 1;
2713
+ while (i < n && walkable(file[i], dot)) i++;
2714
+ if (i === n) return true;
2715
+ }
2716
+ if (!walkable(file[k], dot)) return false;
2717
+ }
2718
+ return false;
2719
+ }
2720
+ #walk(f, row, head, dot, sep) {
2721
+ if (this.#level2 && dotPortion(f, 0, f.length, true, sep)) return "maybe";
2722
+ const x = row[head ? 0 : 1];
2723
+ let s = 0;
2724
+ for (let e = nextSep(f, s, sep); e !== -1; e = nextSep(f, s, sep)) {
2725
+ let next = e + 1;
2726
+ while (next < f.length && isSep(f.charCodeAt(next), sep)) next++;
2727
+ if ((typeof x === "string" ? e - s === x.length && f.startsWith(x, s) : e > s && x.testUnchecked(f.slice(s, e))) && !dotPortion(f, next, f.length, dot, sep)) return "yes";
2728
+ if (head || dotPortion(f, s, next, dot, sep)) return "no";
2729
+ s = next;
2730
+ }
2731
+ return "no";
2732
+ }
2733
+ #cachedSplit(f) {
2734
+ const last = lastSplit;
2735
+ return last?.f === f && last.isWindows === this.isWindows && last.preserveMultipleSlashes === this.preserveMultipleSlashes && last.normalize === this.#form ? last : void 0;
2736
+ }
2737
+ #split(f) {
2738
+ const { isWindows, preserveMultipleSlashes } = this;
2739
+ let parts = this.#slashSplit(isWindows ? f.split("\\").join("/") : f);
2740
+ const normalize = this.#form;
2741
+ if (normalize) parts = parts.map((p) => p.normalize(normalize));
2742
+ lastSplit = {
2743
+ f,
2744
+ isWindows,
2745
+ preserveMultipleSlashes,
2746
+ normalize,
2747
+ parts
2748
+ };
2749
+ return lastSplit;
2750
+ }
2751
+ #levelTwoFileOptimize(file) {
2752
+ const parts = [...file];
2227
2753
  let didSomething = false;
2228
2754
  do {
2229
2755
  didSomething = false;
@@ -2242,19 +2768,23 @@ var Minimatch = class {
2242
2768
  parts.pop();
2243
2769
  }
2244
2770
  }
2245
- let dd = 0;
2771
+ const root = this.#rootIndex(parts) + 1;
2772
+ let dd = root;
2246
2773
  while (-1 !== (dd = parts.indexOf("..", dd + 1))) {
2247
2774
  const p = parts[dd - 1];
2248
- if (p && p !== "." && p !== ".." && p !== "**" && !(this.isWindows && /^[a-z]:$/i.test(p))) {
2775
+ if (p && p !== "." && p !== ".." && p !== "**") {
2249
2776
  didSomething = true;
2250
2777
  parts.splice(dd - 1, 2);
2251
- dd -= 2;
2778
+ dd = Math.max(dd - 2, root);
2252
2779
  }
2253
2780
  }
2254
2781
  } while (didSomething);
2255
2782
  return parts.length === 0 ? [""] : parts;
2256
2783
  }
2257
2784
  firstPhasePreProcess(globParts) {
2785
+ const { braceExpandMax = DEFAULT_BRACE_EXPAND_MAX } = this.options;
2786
+ let splitCells = 0;
2787
+ const maxSplitCells = 1e6;
2258
2788
  let didSomething = false;
2259
2789
  do {
2260
2790
  didSomething = false;
@@ -2269,10 +2799,13 @@ var Minimatch = class {
2269
2799
  const p2 = parts[gs + 3];
2270
2800
  if (next !== "..") continue;
2271
2801
  if (!p || p === "." || p === ".." || !p2 || p2 === "." || p2 === "..") continue;
2802
+ const addedCells = parts.length - 1;
2803
+ if (globParts.length >= braceExpandMax || splitCells + addedCells > maxSplitCells) throw new RangeError(`optimizationLevel 2: too many patterns from '**/..'`);
2272
2804
  didSomething = true;
2273
2805
  parts.splice(gs, 1);
2274
2806
  const other = parts.slice(0);
2275
2807
  other[gs] = "**";
2808
+ splitCells += addedCells;
2276
2809
  globParts.push(other);
2277
2810
  gs--;
2278
2811
  }
@@ -2291,7 +2824,8 @@ var Minimatch = class {
2291
2824
  parts.pop();
2292
2825
  }
2293
2826
  }
2294
- let dd = 0;
2827
+ const root = this.#rootIndex(parts) + 1;
2828
+ let dd = root;
2295
2829
  while (-1 !== (dd = parts.indexOf("..", dd + 1))) {
2296
2830
  const p = parts[dd - 1];
2297
2831
  if (p && p !== "." && p !== ".." && p !== "**") {
@@ -2299,7 +2833,7 @@ var Minimatch = class {
2299
2833
  const splin = dd === 1 && parts[dd + 1] === "**" ? ["."] : [];
2300
2834
  parts.splice(dd - 1, 2, ...splin);
2301
2835
  if (parts.length === 0) parts.push("");
2302
- dd -= 2;
2836
+ dd = Math.max(dd - 2, root);
2303
2837
  }
2304
2838
  }
2305
2839
  }
@@ -2307,45 +2841,41 @@ var Minimatch = class {
2307
2841
  return globParts;
2308
2842
  }
2309
2843
  secondPhasePreProcess(globParts) {
2310
- for (let i = 0; i < globParts.length - 1; i++) for (let j = i + 1; j < globParts.length; j++) {
2311
- const matched = this.partsMatch(globParts[i], globParts[j], !this.preserveMultipleSlashes);
2312
- if (matched) {
2313
- globParts[i] = [];
2314
- globParts[j] = matched;
2315
- break;
2316
- }
2844
+ const keys = /* @__PURE__ */ new Set();
2845
+ const rows = globParts.filter((parts) => {
2846
+ const key = parts.join("/");
2847
+ if (keys.has(key)) return false;
2848
+ keys.add(key);
2849
+ return true;
2850
+ });
2851
+ const stars = /* @__PURE__ */ new Map();
2852
+ for (const parts of rows) {
2853
+ const s = [];
2854
+ for (let i = 0; i < parts.length; i++) if (parts[i] === "*") s.push(i);
2855
+ if (s.length) stars.set(s.join(","), s);
2317
2856
  }
2318
- return globParts.filter((gs) => gs.length);
2319
- }
2320
- partsMatch(a, b, emptyGSMatch = false) {
2321
- let ai = 0;
2322
- let bi = 0;
2323
- let result = [];
2324
- let which = "";
2325
- while (ai < a.length && bi < b.length) if (a[ai] === b[bi]) {
2326
- result.push(which === "b" ? b[bi] : a[ai]);
2327
- ai++;
2328
- bi++;
2329
- } else if (emptyGSMatch && a[ai] === "**" && b[bi] === a[ai + 1]) {
2330
- result.push(a[ai]);
2331
- ai++;
2332
- } else if (emptyGSMatch && b[bi] === "**" && a[ai] === b[bi + 1]) {
2333
- result.push(b[bi]);
2334
- bi++;
2335
- } else if (a[ai] === "*" && b[bi] && (this.options.dot || !b[bi].startsWith(".")) && b[bi] !== "**") {
2336
- if (which === "b") return false;
2337
- which = "a";
2338
- result.push(a[ai]);
2339
- ai++;
2340
- bi++;
2341
- } else if (b[bi] === "*" && a[ai] && (this.options.dot || !a[ai].startsWith(".")) && a[ai] !== "**") {
2342
- if (which === "a") return false;
2343
- which = "b";
2344
- result.push(b[bi]);
2345
- ai++;
2346
- bi++;
2347
- } else return false;
2348
- return a.length === b.length && result;
2857
+ if (!stars.size || rows.length * stars.size > 1e5) return rows;
2858
+ const { dot } = this.options;
2859
+ return rows.filter((parts) => {
2860
+ for (const s of stars.values()) {
2861
+ if (s[s.length - 1] >= parts.length) continue;
2862
+ const c = [...parts];
2863
+ let ok = true;
2864
+ let changed = false;
2865
+ for (const i of s) {
2866
+ const p = parts[i];
2867
+ if (p === "*") continue;
2868
+ if (!p || p === "**" || !dot && p.startsWith(".")) {
2869
+ ok = false;
2870
+ break;
2871
+ }
2872
+ c[i] = "*";
2873
+ changed = true;
2874
+ }
2875
+ if (ok && changed && keys.has(c.join("/"))) return false;
2876
+ }
2877
+ return true;
2878
+ });
2349
2879
  }
2350
2880
  parseNegate() {
2351
2881
  if (this.nonegate) return;
@@ -2359,10 +2889,22 @@ var Minimatch = class {
2359
2889
  if (negateOffset) this.pattern = pattern.slice(negateOffset);
2360
2890
  this.negate = negate;
2361
2891
  }
2362
- matchOne(file, pattern, partial = false) {
2892
+ #matchRow(file, resolved, pattern, partial) {
2363
2893
  let fileStartIndex = 0;
2364
2894
  let patternStartIndex = 0;
2365
- if (this.isWindows) {
2895
+ const fh = this.isWindows ? uncHost(resolved) : -1;
2896
+ const ph = fh === -1 ? -1 : uncHost(pattern);
2897
+ if (ph !== -1) {
2898
+ const host = pattern[ph];
2899
+ const share = pattern[ph + 1];
2900
+ if (typeof host !== "string" || typeof share !== "string") {
2901
+ fileStartIndex = fh;
2902
+ patternStartIndex = ph;
2903
+ } else if (resolved[fh].toLowerCase() === host.toLowerCase() && resolved[fh + 1].toLowerCase() === share.toLowerCase()) {
2904
+ fileStartIndex = fh + 2;
2905
+ patternStartIndex = ph + 2;
2906
+ }
2907
+ } else if (this.isWindows) {
2366
2908
  const fileDrive = typeof file[0] === "string" && /^[a-z]:$/i.test(file[0]);
2367
2909
  const fileUNC = !fileDrive && file[0] === "" && file[1] === "" && file[2] === "?" && /^[a-z]:$/i.test(file[3]);
2368
2910
  const patternDrive = typeof pattern[0] === "string" && /^[a-z]:$/i.test(pattern[0]);
@@ -2372,32 +2914,20 @@ var Minimatch = class {
2372
2914
  if (typeof fdi === "number" && typeof pdi === "number") {
2373
2915
  const [fd, pd] = [file[fdi], pattern[pdi]];
2374
2916
  if (fd.toLowerCase() === pd.toLowerCase()) {
2375
- pattern[pdi] = fd;
2376
- patternStartIndex = pdi;
2377
- fileStartIndex = fdi;
2917
+ patternStartIndex = pdi + 1;
2918
+ fileStartIndex = fdi + 1;
2378
2919
  }
2379
2920
  }
2380
2921
  }
2381
- const { optimizationLevel = 1 } = this.options;
2382
- if (optimizationLevel >= 2) file = this.levelTwoFileOptimize(file);
2922
+ file = resolved;
2383
2923
  if (pattern.includes(GLOBSTAR)) return this.#matchGlobstar(file, pattern, partial, fileStartIndex, patternStartIndex);
2384
2924
  return this.#matchOne(file, pattern, partial, fileStartIndex, patternStartIndex);
2385
2925
  }
2386
2926
  #matchGlobstar(file, pattern, partial, fileIndex, patternIndex) {
2387
- const firstgs = pattern.indexOf(GLOBSTAR, patternIndex);
2388
- const lastgs = pattern.lastIndexOf(GLOBSTAR);
2389
- const [head, body, tail] = partial ? [
2390
- pattern.slice(patternIndex, firstgs),
2391
- pattern.slice(firstgs + 1),
2392
- []
2393
- ] : [
2394
- pattern.slice(patternIndex, firstgs),
2395
- pattern.slice(firstgs + 1, lastgs),
2396
- pattern.slice(lastgs + 1)
2397
- ];
2927
+ const { head, body, tail, segments } = this.#getGlobstarParts(pattern, partial, patternIndex);
2398
2928
  if (head.length) {
2399
- const fileHead = file.slice(fileIndex, fileIndex + head.length);
2400
- if (!this.#matchOne(fileHead, head, partial, 0, 0)) return false;
2929
+ const headEnd = fileIndex + head.length;
2930
+ if (!this.#matchOne(file, head, partial, fileIndex, 0, headEnd)) return false;
2401
2931
  fileIndex += head.length;
2402
2932
  patternIndex += head.length;
2403
2933
  }
@@ -2422,67 +2952,86 @@ var Minimatch = class {
2422
2952
  }
2423
2953
  return partial || sawSome;
2424
2954
  }
2425
- const bodySegments = [[[], 0]];
2426
- let currentBody = bodySegments[0];
2955
+ return !!this.#matchGlobStarBodySections(file, segments, file.length - fileTailMatch, fileIndex, 0, partial, 0, !!fileTailMatch, /* @__PURE__ */ new Set());
2956
+ }
2957
+ #getGlobstarParts(pattern, partial, patternIndex) {
2958
+ let byStart = this.#globstarParts.get(pattern);
2959
+ if (!byStart) {
2960
+ byStart = [];
2961
+ this.#globstarParts.set(pattern, byStart);
2962
+ }
2963
+ const key = patternIndex * 2 + (partial ? 1 : 0);
2964
+ const found = byStart[key];
2965
+ if (found) return found;
2966
+ const firstgs = pattern.indexOf(GLOBSTAR, patternIndex);
2967
+ const lastgs = pattern.lastIndexOf(GLOBSTAR);
2968
+ const head = pattern.slice(patternIndex, firstgs);
2969
+ const body = pattern.slice(firstgs + 1, partial ? void 0 : lastgs);
2970
+ const tail = partial ? [] : pattern.slice(lastgs + 1);
2971
+ const segments = [[[], 0]];
2972
+ let current = segments[0];
2427
2973
  let nonGsParts = 0;
2428
2974
  const nonGsPartsSums = [0];
2429
2975
  for (const b of body) if (b === GLOBSTAR) {
2430
2976
  nonGsPartsSums.push(nonGsParts);
2431
- currentBody = [[], 0];
2432
- bodySegments.push(currentBody);
2977
+ current = [[], 0];
2978
+ segments.push(current);
2433
2979
  } else {
2434
- currentBody[0].push(b);
2980
+ current[0].push(b);
2435
2981
  nonGsParts++;
2436
2982
  }
2437
- let i = bodySegments.length - 1;
2438
- const fileLength = file.length - fileTailMatch;
2439
- for (const b of bodySegments) b[1] = fileLength - (nonGsPartsSums[i--] + b[0].length);
2440
- return !!this.#matchGlobStarBodySections(file, bodySegments, fileIndex, 0, partial, 0, !!fileTailMatch);
2983
+ segments.forEach((b, i) => {
2984
+ b[1] = nonGsParts - nonGsPartsSums[i];
2985
+ });
2986
+ const parts = {
2987
+ head,
2988
+ body,
2989
+ tail,
2990
+ segments
2991
+ };
2992
+ byStart[key] = parts;
2993
+ return parts;
2441
2994
  }
2442
- #matchGlobStarBodySections(file, bodySegments, fileIndex, bodyIndex, partial, globStarDepth, sawTail) {
2995
+ #matchGlobStarBodySections(file, bodySegments, fileLength, fileIndex, bodyIndex, partial, globStarDepth, sawTail, tried) {
2443
2996
  const bs = bodySegments[bodyIndex];
2444
2997
  if (!bs) {
2445
- for (let i = fileIndex; i < file.length; i++) {
2998
+ if (partial) return fileIndex >= fileLength || fileIndex === fileLength - 1 && file[fileIndex] === "";
2999
+ for (let i = fileIndex; i < fileLength; i++) {
2446
3000
  sawTail = true;
2447
3001
  const f = file[i];
2448
3002
  if (f === "." || f === ".." || !this.options.dot && f.startsWith(".")) return false;
2449
3003
  }
2450
3004
  return sawTail;
2451
3005
  }
2452
- const [body, after] = bs;
3006
+ const [body, need] = bs;
3007
+ const after = partial ? fileLength : fileLength - need;
2453
3008
  while (fileIndex <= after) {
2454
- if (this.#matchOne(file.slice(0, fileIndex + body.length), body, partial, fileIndex, 0) && globStarDepth < this.maxGlobstarRecursion) {
2455
- const sub = this.#matchGlobStarBodySections(file, bodySegments, fileIndex + body.length, bodyIndex + 1, partial, globStarDepth + 1, sawTail);
3009
+ const key = bodyIndex * (file.length + 1) + fileIndex;
3010
+ if (tried.has(key)) return false;
3011
+ tried.add(key);
3012
+ if (this.#matchOne(file, body, partial, fileIndex, 0, fileIndex + body.length) && globStarDepth < this.maxGlobstarRecursion) {
3013
+ const sub = this.#matchGlobStarBodySections(file, bodySegments, fileLength, fileIndex + body.length, bodyIndex + 1, partial, globStarDepth + 1, sawTail, tried);
2456
3014
  if (sub !== false) return sub;
2457
3015
  }
3016
+ if (fileIndex === after) break;
2458
3017
  const f = file[fileIndex];
2459
3018
  if (f === "." || f === ".." || !this.options.dot && f.startsWith(".")) return false;
2460
3019
  fileIndex++;
2461
3020
  }
2462
3021
  return partial || null;
2463
3022
  }
2464
- #matchOne(file, pattern, partial, fileIndex, patternIndex) {
3023
+ #matchOne(file, pattern, partial, fileIndex, patternIndex, fileEnd = file.length) {
2465
3024
  let fi;
2466
3025
  let pi;
2467
3026
  let pl;
2468
3027
  let fl;
2469
- for (fi = fileIndex, pi = patternIndex, fl = file.length, pl = pattern.length; fi < fl && pi < pl; fi++, pi++) {
2470
- this.debug("matchOne loop");
3028
+ for (fi = fileIndex, pi = patternIndex, fl = Math.min(fileEnd, file.length), pl = pattern.length; fi < fl && pi < pl; fi++, pi++) {
2471
3029
  let p = pattern[pi];
2472
3030
  let f = file[fi];
2473
- this.debug(pattern, p, f);
2474
3031
  /* c8 ignore start */
2475
3032
  if (p === false || p === GLOBSTAR) return false;
2476
3033
  /* c8 ignore stop */
2477
- let hit;
2478
- if (typeof p === "string") {
2479
- hit = f === p;
2480
- this.debug("string match", p, f, hit);
2481
- } else {
2482
- hit = p.test(f);
2483
- this.debug("pattern match", p, f, hit);
2484
- }
2485
- if (!hit) return false;
3034
+ if (!portionMatch(p, f)) return false;
2486
3035
  }
2487
3036
  if (fi === fl && pi === pl) return true;
2488
3037
  else if (fi === fl) return partial;
@@ -2493,92 +3042,83 @@ var Minimatch = class {
2493
3042
  braceExpand() {
2494
3043
  return braceExpand(this.pattern, this.options);
2495
3044
  }
3045
+ #expandBraces() {
3046
+ const { pattern } = this;
3047
+ if (this.options.nobrace) return this.braceExpand();
3048
+ let code = 57344;
3049
+ while (pattern.includes(String.fromCharCode(code))) if (++code > 63743) return this.braceExpand();
3050
+ const mark = String.fromCharCode(code);
3051
+ let found = false;
3052
+ const marked = pattern.replace(rangeRe, (m, lo, hi) => {
3053
+ const a = Number(lo);
3054
+ const b = Number(hi);
3055
+ if (!Number.isSafeInteger(a) || !Number.isSafeInteger(b) || Math.abs(a - b) + 1 < RANGE_MIN) return m;
3056
+ found = true;
3057
+ return `${mark}${lo}..${hi}${mark}`;
3058
+ });
3059
+ if (!found) return this.braceExpand();
3060
+ const set = braceExpand(marked, this.options);
3061
+ for (const p of set) for (const portion of p.split("/")) {
3062
+ const c = portion.indexOf("[");
3063
+ if (c !== -1 && c < portion.lastIndexOf(mark)) return this.braceExpand();
3064
+ if (!this.options.noext && inRepeatOrNegExt(portion, mark)) return this.braceExpand();
3065
+ }
3066
+ this.#rangeMark = mark;
3067
+ return set;
3068
+ }
2496
3069
  parse(pattern) {
2497
3070
  assertValidPattern(pattern);
2498
3071
  const options = this.options;
2499
3072
  if (pattern === "**") return GLOBSTAR;
2500
3073
  if (pattern === "") return "";
2501
- let m;
2502
- let fastTest = null;
2503
- if (m = pattern.match(starRE)) fastTest = options.dot ? starTestDot : starTest;
2504
- else if (m = pattern.match(starDotExtRE)) fastTest = (options.nocase ? options.dot ? starDotExtTestNocaseDot : starDotExtTestNocase : options.dot ? starDotExtTestDot : starDotExtTest)(m[1]);
2505
- else if (m = pattern.match(qmarksRE)) fastTest = (options.nocase ? options.dot ? qmarksTestNocaseDot : qmarksTestNocase : options.dot ? qmarksTestDot : qmarksTest)(m);
2506
- else if (m = pattern.match(starDotStarRE)) fastTest = options.dot ? starDotStarTestDot : starDotStarTest;
2507
- else if (m = pattern.match(dotStarRE)) fastTest = dotStarTest;
2508
- const re = AST.fromGlob(pattern, this.options).toMMPattern();
2509
- if (fastTest && typeof re === "object") Reflect.defineProperty(re, "test", { value: fastTest });
2510
- return re;
2511
- }
2512
- makeRe() {
2513
- if (this.regexp || this.regexp === false) return this.regexp;
2514
- const set = this.set;
2515
- if (!set.length) {
2516
- this.regexp = false;
2517
- return this.regexp;
2518
- }
2519
- const options = this.options;
2520
- const twoStar = options.noglobstar ? star : options.dot ? twoStarDot : twoStarNoDot;
2521
- const flags = new Set(options.nocase ? ["i"] : []);
2522
- let re = set.map((pattern) => {
2523
- const pp = pattern.map((p) => {
2524
- if (p instanceof RegExp) for (const f of p.flags.split("")) flags.add(f);
2525
- return typeof p === "string" ? regExpEscape(p) : p === GLOBSTAR ? GLOBSTAR : p._src;
2526
- });
2527
- pp.forEach((p, i) => {
2528
- const next = pp[i + 1];
2529
- const prev = pp[i - 1];
2530
- if (p !== GLOBSTAR || prev === GLOBSTAR) return;
2531
- if (prev === void 0) {
2532
- if (next !== void 0 && next !== GLOBSTAR) pp[i + 1] = "(?:\\/|" + twoStar + "\\/)?" + next;
2533
- else pp[i] = twoStar;
2534
- } else if (next === void 0) pp[i - 1] = prev + "(?:\\/|\\/" + twoStar + ")?";
2535
- else if (next !== GLOBSTAR) {
2536
- pp[i - 1] = prev + "(?:\\/|\\/" + twoStar + "\\/)" + next;
2537
- pp[i + 1] = GLOBSTAR;
2538
- }
3074
+ const { nocase, nocaseMagicOnly, noext = false, dot, normalize } = options;
3075
+ const rangeMark = this.#rangeMark;
3076
+ const lit = rangeMark && pattern.includes(rangeMark) ? void 0 : literal(pattern, noext);
3077
+ if (lit !== void 0 && !(nocase && !nocaseMagicOnly && pattern.toUpperCase() !== pattern.toLowerCase())) return this.#norm(lit);
3078
+ if (this.#pending) return PENDING;
3079
+ let m = this.#matchers.get(pattern);
3080
+ if (!m) {
3081
+ if (!noext) assertValidExtglobs(pattern);
3082
+ m = new Matcher(pattern, {
3083
+ nocase,
3084
+ noext,
3085
+ dot,
3086
+ normalize,
3087
+ ...rangeMark && { rangeMark }
2539
3088
  });
2540
- const filtered = pp.filter((p) => p !== GLOBSTAR);
2541
- if (this.partial && filtered.length >= 1) {
2542
- const prefixes = [];
2543
- for (let i = 1; i <= filtered.length; i++) prefixes.push(filtered.slice(0, i).join("/"));
2544
- return "(?:" + prefixes.join("|") + ")";
2545
- }
2546
- return filtered.join("/");
2547
- }).join("|");
2548
- const [open, close] = set.length > 1 ? ["(?:", ")"] : ["", ""];
2549
- re = "^" + open + re + close + "$";
2550
- if (this.partial) re = "^(?:\\/|" + open + re.slice(1, -1) + close + ")$";
2551
- if (this.negate) re = "^(?!" + re + ").+$";
2552
- try {
2553
- this.regexp = new RegExp(re, [...flags].join(""));
2554
- } catch {
2555
- this.regexp = false;
3089
+ this.#matchers.set(pattern, m);
2556
3090
  }
2557
- /* c8 ignore stop */
2558
- return this.regexp;
3091
+ return m;
2559
3092
  }
2560
- slashSplit(p) {
3093
+ #slashSplit(p) {
2561
3094
  if (this.preserveMultipleSlashes) return p.split("/");
2562
3095
  else if (this.isWindows && /^\/\/[^/]+/.test(p)) return ["", ...p.split(/\/+/)];
2563
3096
  else return p.split(/\/+/);
2564
3097
  }
2565
3098
  match(f, partial = this.partial) {
2566
- this.debug("match", f, this.pattern);
2567
3099
  if (this.comment) return false;
2568
3100
  if (this.empty) return f === "";
2569
3101
  if (f === "/" && partial) return true;
2570
3102
  const options = this.options;
2571
- if (this.isWindows) f = f.split("\\").join("/");
2572
- const ff = this.slashSplit(f);
2573
- this.debug(this.pattern, "split", ff);
3103
+ let split = this.#cachedSplit(f);
3104
+ if (!split) {
3105
+ if (!partial && !this.#form && (this.#endCheck || this.#literalCheck) && lastChecked !== f) {
3106
+ lastChecked = f;
3107
+ const can = this.#canMatch(f);
3108
+ if (can === "no") return options.flipNegate ? false : this.negate;
3109
+ if (can === "yes") return options.flipNegate ? true : !this.negate;
3110
+ }
3111
+ split = this.#split(f);
3112
+ }
3113
+ const ff = split.parts;
3114
+ const resolved = this.#level2 ? split.resolved ??= this.#levelTwoFileOptimize(ff) : ff;
2574
3115
  const set = this.set;
2575
- this.debug(this.pattern, "set", set);
2576
3116
  let filename = ff[ff.length - 1];
2577
3117
  if (!filename) for (let i = ff.length - 2; !filename && i >= 0; i--) filename = ff[i];
2578
- for (const pattern of set) {
2579
- let file = ff;
2580
- if (options.matchBase && pattern.length === 1) file = [filename];
2581
- if (this.matchOne(file, pattern, partial)) {
3118
+ for (let r = 0; r < set.length; r++) {
3119
+ const pattern = set[r];
3120
+ const shape = partial ? void 0 : this.#shapes[r];
3121
+ if (shape === "base" ? portionMatch(pattern[0], filename) : shape ? this.#matchShape(resolved, pattern, shape) : options.matchBase && pattern.length === 1 ? this.#matchRow([filename], [filename], pattern, partial) : this.#matchRow(ff, resolved, pattern, partial)) {
2582
3122
  if (options.flipNegate) return true;
2583
3123
  return !this.negate;
2584
3124
  }
@@ -2591,12 +3131,10 @@ var Minimatch = class {
2591
3131
  }
2592
3132
  };
2593
3133
  /* c8 ignore stop */
2594
- minimatch.AST = AST;
2595
3134
  minimatch.Minimatch = Minimatch;
2596
3135
  minimatch.escape = escape;
2597
3136
  minimatch.unescape = unescape;
2598
- //#endregion
2599
- //#region ../internal/src/build/runtime-package-files.ts
3137
+ // ../internal/src/build/runtime-package-files.ts
2600
3138
  const alwaysPublishedFile = /^(?:package\.json|(?:readme|copying|licen[cs]e)(?:\..*[^~$])?)$/i;
2601
3139
  const rootExcluded = /* @__PURE__ */ new Set([
2602
3140
  "package-lock.json",
@@ -2754,8 +3292,7 @@ async function copyRuntimePackageFiles(packageDir, targetDir) {
2754
3292
  await unlessGone(() => copyFile(join(packageDir, path), target));
2755
3293
  }
2756
3294
  }
2757
- //#endregion
2758
- //#region ../internal/src/build/provider-output-sources.ts
3295
+ // ../internal/src/build/provider-output-sources.ts
2759
3296
  /** Removes retained provider output after readers release it, tolerating transient filesystem contention. */
2760
3297
  async function removeProviderOutputArtifactDir(path) {
2761
3298
  await rm(path, {
@@ -2765,8 +3302,7 @@ async function removeProviderOutputArtifactDir(path) {
2765
3302
  retryDelay: 50
2766
3303
  });
2767
3304
  }
2768
- //#endregion
2769
- //#region ../internal/src/build/vercel-config.ts
3305
+ // ../internal/src/build/vercel-config.ts
2770
3306
  function createDefaultVercelOutputRoot(rootDir) {
2771
3307
  return resolve(rootDir, ".vercel", "output");
2772
3308
  }
@@ -2789,8 +3325,7 @@ function createNodeFunctionConfig(extra = {}) {
2789
3325
  ...extra
2790
3326
  };
2791
3327
  }
2792
- //#endregion
2793
- //#region ../internal/src/build/runtime-package-resolution.ts
3328
+ // ../internal/src/build/runtime-package-resolution.ts
2794
3329
  /** Locates package metadata through exports, an entry's ancestors, or the project's dependency roots. */
2795
3330
  function createRuntimePackageResolver(readPackageName) {
2796
3331
  return async (name, resolver, fromDir) => {
@@ -2831,8 +3366,7 @@ function isPackageResolutionMiss(error) {
2831
3366
  const code = error?.code;
2832
3367
  return code === "MODULE_NOT_FOUND" || code === "ERR_MODULE_NOT_FOUND" || code === "ERR_PACKAGE_PATH_NOT_EXPORTED";
2833
3368
  }
2834
- //#endregion
2835
- //#region ../internal/src/build/runtime-package-directory.ts
3369
+ // ../internal/src/build/runtime-package-directory.ts
2836
3370
  /** Update a staged copy, then publish it with rollback on failure or cancellation. */
2837
3371
  async function updateRuntimePackageDirectory(options) {
2838
3372
  const stagingRoot = await mkdtemp(join(dirname(options.directory), ".vitehub-runtime-packages-"));
@@ -2879,8 +3413,7 @@ async function updateRuntimePackageDirectory(options) {
2879
3413
  });
2880
3414
  }
2881
3415
  }
2882
- //#endregion
2883
- //#region ../internal/src/build/vercel-runtime-packages.ts
3416
+ // ../internal/src/build/vercel-runtime-packages.ts
2884
3417
  const runtimeExportConditions = /* @__PURE__ */ new Set([
2885
3418
  "default",
2886
3419
  "import",
@@ -3028,7 +3561,7 @@ async function copyTracedPackageFiles(name, resolver, packageDir, packageJsonPat
3028
3561
  return true;
3029
3562
  }
3030
3563
  async function loadNodeFileTrace() {
3031
- nodeFileTracePromise ??= import("./out-BbXG-yVX.js").then((m) => /* @__PURE__ */ __toESM(m.default, 1)).then(({ nodeFileTrace }) => nodeFileTrace);
3564
+ nodeFileTracePromise ??= import("./out-By90R-Bo.js").then((m) => /* @__PURE__ */ __toESM(m.default, 1)).then(({ nodeFileTrace }) => nodeFileTrace);
3032
3565
  return nodeFileTracePromise;
3033
3566
  }
3034
3567
  async function resolvePackageTraceEntries(name, resolver, packageDir, packageJson) {
@@ -3094,8 +3627,7 @@ function parsePackageJson(value, path) {
3094
3627
  if (typeof value !== "object" || value === null || Array.isArray(value)) throw internalErrorDiagnostics.INTERNAL_B0047({ message: `Expected ${path} to contain a JSON object.` });
3095
3628
  return value;
3096
3629
  }
3097
- //#endregion
3098
- //#region ../internal/src/build/provider-output-catalog.ts
3630
+ // ../internal/src/build/provider-output-catalog.ts
3099
3631
  var ProviderOutputCatalog = class {
3100
3632
  bundleDefines = {};
3101
3633
  #appliedCloudflareContributions = /* @__PURE__ */ new Map();
@@ -3323,8 +3855,7 @@ function useProviderOutputCatalog(config) {
3323
3855
  providerOutputCatalogs.set(config, catalog);
3324
3856
  return catalog;
3325
3857
  }
3326
- //#endregion
3327
- //#region ../internal/src/build/deployment-output.ts
3858
+ // ../internal/src/build/deployment-output.ts
3328
3859
  const providerDeploymentOutputRegistry = globalThis;
3329
3860
  const providerDeploymentOutputWrites = providerDeploymentOutputRegistry.__vitehubProviderDeploymentOutputWrites ??= /* @__PURE__ */ new Map();
3330
3861
  const providerDeploymentOutputFinalizations = providerDeploymentOutputRegistry.__vitehubProviderDeploymentOutputFinalizations ??= /* @__PURE__ */ new WeakMap();
@@ -4336,8 +4867,7 @@ async function finalizeProviderDeploymentOutputs(catalog, options = {}) {
4336
4867
  if (providerDeploymentOutputFinalizations.get(catalog) === active) providerDeploymentOutputFinalizations.delete(catalog);
4337
4868
  }
4338
4869
  }
4339
- //#endregion
4340
- //#region ../internal/src/hints.ts
4870
+ // ../internal/src/hints.ts
4341
4871
  /**
4342
4872
  * The file that lists the hints of the last build or dev server, relative to the project root. A hint is a warning
4343
4873
  * about something that works now and fails later, such as counts that stay in one server's memory. Agents and CI read
@@ -4415,8 +4945,7 @@ function startViteHubHints(config, owner = config) {
4415
4945
  started.add(owner);
4416
4946
  write(startRun(config));
4417
4947
  }
4418
- //#endregion
4419
- //#region ../internal/src/provision-state.ts
4948
+ // ../internal/src/provision-state.ts
4420
4949
  const PROVISION_STATE_FILE = ".vitehub/provision.json";
4421
4950
  function getProvisionStatePath(rootDir) {
4422
4951
  return resolve$1(rootDir, PROVISION_STATE_FILE);
@@ -4467,8 +4996,7 @@ function setOwn(target, key, value) {
4467
4996
  writable: true
4468
4997
  });
4469
4998
  }
4470
- //#endregion
4471
- //#region ../internal/src/vite-stage.ts
4999
+ // ../internal/src/vite-stage.ts
4472
5000
  /**
4473
5001
  * Vite's `loadEnv(mode, envDir, "")`: every `.env` value of the mode and the whole shell. With `DEBUG=vite:env`, Vite
4474
5002
  * logs that result to stderr, secrets included. loadEnv is synchronous, so this drops only the writes of this call.
@@ -4505,8 +5033,7 @@ function configureCloudflareKV(target, config, provisionState = {}) {
4505
5033
  });
4506
5034
  }
4507
5035
  }
4508
- //#endregion
4509
- //#region src/inspect.ts
5036
+ // src/inspect.ts
4510
5037
  function describeDevelopment(store) {
4511
5038
  switch (store.driver) {
4512
5039
  case "upstash": return "Remote. `vite dev` uses the real Upstash database, so writes change real data.";
@@ -4574,8 +5101,7 @@ function inspectKVResources(options, provisionRoot, env = process.env, hosting)
4574
5101
  };
4575
5102
  });
4576
5103
  }
4577
- //#endregion
4578
- //#region ../internal/src/host-credentials.ts
5104
+ // ../internal/src/host-credentials.ts
4579
5105
  /** Reads host credentials from environment variables only. Returns undefined when the token is not set. */
4580
5106
  function readHostCredentialsFromEnv(host, env) {
4581
5107
  switch (host) {
@@ -4609,8 +5135,7 @@ function trimmed(value) {
4609
5135
  const result = value?.trim();
4610
5136
  return result ? result : void 0;
4611
5137
  }
4612
- //#endregion
4613
- //#region ../internal/src/provider-failure.ts
5138
+ // ../internal/src/provider-failure.ts
4614
5139
  const cloudflareCodes = {
4615
5140
  d1: {},
4616
5141
  kv: { 10014: "conflict" },
@@ -4712,8 +5237,7 @@ function readProviderErrorCodes(body) {
4712
5237
  const errors = Reflect.get(body, "errors");
4713
5238
  return [error && typeof error === "object" ? Reflect.get(error, "code") : void 0, ...Array.isArray(errors) ? errors.map((entry) => entry && typeof entry === "object" ? Reflect.get(entry, "code") : void 0) : []].filter((code) => typeof code === "number" && Number.isFinite(code) || typeof code === "string" && /^[\w.-]{1,128}$/.test(code));
4714
5239
  }
4715
- //#endregion
4716
- //#region ../internal/src/provision.ts
5240
+ // ../internal/src/provision.ts
4717
5241
  /**
4718
5242
  * Whether a value from Provision State can appear in a copyable shell command as is.
4719
5243
  * The file is editable, so a hint shows a command only for plain names and ids.
@@ -4835,8 +5359,7 @@ async function listCloudflarePages(request, path, options) {
4835
5359
  } else if (options.perPage === void 0 || pageItems.length < options.perPage) return items;
4836
5360
  }
4837
5361
  }
4838
- //#endregion
4839
- //#region src/provision.ts
5362
+ // src/provision.ts
4840
5363
  const CLOUDFLARE_KV_NAMESPACE_LIST_PER_PAGE = 100;
4841
5364
  function parseNamespaces(value) {
4842
5365
  if (!Array.isArray(value)) throw kvErrorDiagnostics.KV_PROVISION_FAILED({ problem: "Cloudflare returned an invalid KV namespace list." });
@@ -4935,8 +5458,7 @@ function createKVCloudflareProvisionStep(resolveOptions) {
4935
5458
  }
4936
5459
  };
4937
5460
  }
4938
- //#endregion
4939
- //#region src/deployment-env.ts
5461
+ // src/deployment-env.ts
4940
5462
  const owners = ["kv"];
4941
5463
  const maskedRuntimeValue = "********";
4942
5464
  function entry(names) {
@@ -4961,8 +5483,7 @@ function kvDeploymentEnv(config) {
4961
5483
  if (!config) return [];
4962
5484
  return Object.values(config.stores ?? { default: config.store }).flatMap(storeEntries);
4963
5485
  }
4964
- //#endregion
4965
- //#region src/vite.ts
5486
+ // src/vite.ts
4966
5487
  const operationsModule = ownModule(import.meta.url, "operations");
4967
5488
  const RESOLVED_KV_VIRTUAL_CONFIG_ID = `\0${KV_VIRTUAL_CONFIG_ID}`;
4968
5489
  const RESOLVED_KV_RUNTIME_ID = `\0#vitehub/kv/runtime`;
@@ -5068,7 +5589,8 @@ function configureNitroCloudflareRequestEnv(nitro, kv) {
5068
5589
  const handlers = Array.isArray(nitro.handlers) ? nitro.handlers.filter((handler) => !(isRecord(handler) && handler.handler === KV_CLOUDFLARE_REQUEST_ENV_MIDDLEWARE)) : [];
5069
5590
  if (hasCloudflareKVStore(kv)) handlers.unshift({
5070
5591
  handler: KV_CLOUDFLARE_REQUEST_ENV_MIDDLEWARE,
5071
- middleware: true
5592
+ middleware: true,
5593
+ route: "/**"
5072
5594
  });
5073
5595
  if (handlers.length || Array.isArray(nitro.handlers)) nitro.handlers = handlers;
5074
5596
  }
@@ -5478,5 +6000,4 @@ function hubKV(options, input = {}) {
5478
6000
  }
5479
6001
  };
5480
6002
  }
5481
- //#endregion
5482
6003
  export { KV_VIRTUAL_CONFIG_ID, KV_VITE_PLUGIN_NAME, hubKV, hubKVOptionalPeerResolver, kvStorageDriver, resolveKVViteConfig };