@vite-hub/schedule 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 (49) hide show
  1. package/dist/{console-DueeEBcM.d.ts → console-BdlDJUfS.d.ts} +1 -5
  2. package/dist/{cron-C1l3TquN.js → cron-BT3ef48f.js} +2 -4
  3. package/dist/definition.d.ts +2 -4
  4. package/dist/definition.js +4 -5
  5. package/dist/{due-n120-_nz.js → due-D-0trD1g.js} +2 -3
  6. package/dist/durability.d.ts +1 -3
  7. package/dist/durability.js +1 -2
  8. package/dist/{error-diagnostics-DTmP6baC.js → error-diagnostics-B1AaIGWP.js} +1 -2
  9. package/dist/{error-diagnostics-C0KyI408.js → error-diagnostics-kKXseq8d.js} +5 -2
  10. package/dist/index.d.ts +3 -13
  11. package/dist/index.js +5 -7
  12. package/dist/{inspect-DTfAo5gS.js → inspect-CW0qwt9p.js} +2 -4
  13. package/dist/{kv-storage-2kZtP2CC.js → kv-storage-Dsr3TL9c.js} +1 -2
  14. package/dist/{kv-storage-Bm9aYLfZ.d.ts → kv-storage-hI2IOjb5.d.ts} +0 -2
  15. package/dist/{object-Da1zyPCR.js → object-CAK6UYR5.js} +1 -2
  16. package/dist/{operation-definition-CI2PJGqu.d.ts → operation-definition-CqZkx1Rm.d.ts} +0 -4
  17. package/dist/{operations-DlrK9mlH.js → operations-BTUQeba1.js} +7 -8
  18. package/dist/operations.d.ts +2 -6
  19. package/dist/operations.js +8 -13
  20. package/dist/os.d.ts +0 -8
  21. package/dist/os.js +13 -22
  22. package/dist/{out-BbXG-yVX.js → out-By90R-Bo.js} +3345 -2394
  23. package/dist/{rolldown-runtime-CMFfr-1z.js → rolldown-runtime-DegdyBIC.js} +2 -3
  24. package/dist/runtime/console.d.ts +2 -4
  25. package/dist/runtime/console.js +2 -3
  26. package/dist/runtime/kv.d.ts +2 -4
  27. package/dist/runtime/kv.js +2 -3
  28. package/dist/runtime/process.d.ts +1 -3
  29. package/dist/runtime/process.js +10 -13
  30. package/dist/runtime/state.d.ts +1 -1
  31. package/dist/runtime/state.js +1 -2
  32. package/dist/runtime/static.d.ts +1 -1
  33. package/dist/runtime/static.js +2 -2
  34. package/dist/runtime.d.ts +5 -7
  35. package/dist/runtime.js +5 -5
  36. package/dist/{started-BWWr7Ufw.js → started-B1Se_Iwo.js} +6 -7
  37. package/dist/{started-BXdWMdji.js → started-Bzvr4t5f.js} +6 -7
  38. package/dist/{started-errors-BMg04lL3.js → started-errors-IG9DlT2A.js} +6 -9
  39. package/dist/{started-name-DudQ0fsR.js → started-name-w6n9uDdt.js} +1 -2
  40. package/dist/{state-CJKAhskJ.d.ts → state-BDEDVlyr.d.ts} +1 -5
  41. package/dist/{state-BjWnxyhv.js → state-BZLy46UJ.js} +4 -6
  42. package/dist/{static-BgoOCoe5.js → static-Bg7Jj92L.js} +11 -18
  43. package/dist/{static-CcBWx1kU.d.ts → static-DeRvJqcQ.d.ts} +1 -5
  44. package/dist/{store-CZHZfttA.d.ts → store-CEv3cScg.d.ts} +2 -6
  45. package/dist/{time-zone-SBldrUgt.js → time-zone-pMp_g8Uu.js} +1 -2
  46. package/dist/{types-Cw5LjPuc.d.ts → types-DTVPVY5O.d.ts} +0 -2
  47. package/dist/vite.d.ts +3 -19
  48. package/dist/vite.js +1456 -927
  49. package/package.json +9 -9
package/dist/vite.js CHANGED
@@ -1,12 +1,12 @@
1
- import { r as __toESM } from "./rolldown-runtime-CMFfr-1z.js";
2
- import { t as isIanaTimeZone } from "./time-zone-SBldrUgt.js";
3
- import { n as isRecordOrFunction, t as isRecord$1 } from "./object-Da1zyPCR.js";
4
- import { t as scheduleErrorDiagnostics } from "./error-diagnostics-DTmP6baC.js";
5
- import { t as internalErrorDiagnostics } from "./error-diagnostics-C0KyI408.js";
6
- import { i as timeZoneOffsetMinutes, t as cronWithWeekdayNames } from "./due-n120-_nz.js";
7
- import { t as startedSchedulesTickName } from "./started-name-DudQ0fsR.js";
8
- import { a as relative$1, i as isAbsolute$1, n as relativeDefinitionFile, o as resolve$1, r as dirname$1 } from "./inspect-DTfAo5gS.js";
9
- import { a as parseCronFields, l as invariant, u as invariantError } from "./cron-C1l3TquN.js";
1
+ import { r as __toESM } from "./rolldown-runtime-DegdyBIC.js";
2
+ import { a as parseCronFields, l as invariant, u as invariantError } from "./cron-BT3ef48f.js";
3
+ import { a as relative$1, i as isAbsolute$1, n as relativeDefinitionFile, o as resolve$1, r as dirname$1 } from "./inspect-CW0qwt9p.js";
4
+ import { t as internalErrorDiagnostics } from "./error-diagnostics-kKXseq8d.js";
5
+ import { n as isRecordOrFunction, t as isRecord$1 } from "./object-CAK6UYR5.js";
6
+ import { t as scheduleErrorDiagnostics } from "./error-diagnostics-B1AaIGWP.js";
7
+ import { t as startedSchedulesTickName } from "./started-name-w6n9uDdt.js";
8
+ import { t as isIanaTimeZone } from "./time-zone-pMp_g8Uu.js";
9
+ import { i as timeZoneOffsetMinutes, t as cronWithWeekdayNames } from "./due-D-0trD1g.js";
10
10
  import { scheduleConsoleTiming } from "./runtime/console.js";
11
11
  import { builtinModules, createRequire, isBuiltin } from "node:module";
12
12
  import { formatDiagnostic } from "nostics";
@@ -19,7 +19,7 @@ import { access, chmod, copyFile, cp, lstat, mkdir, mkdtemp, readFile, readdir,
19
19
  import { createHash, randomUUID } from "node:crypto";
20
20
  import { isDeepStrictEqual } from "node:util";
21
21
  import { parseSync } from "vite";
22
- //#region ../internal/src/build/vite.ts
22
+ // ../internal/src/build/vite.ts
23
23
  async function prepareViteHubProviderSources(plugins, sources) {
24
24
  for (const plugin of plugins) await plugin.vitehub?.providerOutput?.prepareSources?.(sources);
25
25
  }
@@ -149,8 +149,7 @@ function isMissingProjectMarker(error) {
149
149
  const code = error.code;
150
150
  return code === "ENOENT" || code === "ENOTDIR";
151
151
  }
152
- //#endregion
153
- //#region ../internal/src/build/paths.ts
152
+ // ../internal/src/build/paths.ts
154
153
  function generatedDirSegments(productName) {
155
154
  return [".vitehub", productName];
156
155
  }
@@ -196,8 +195,7 @@ function realpathIfExists(path) {
196
195
  return resolve$1(path);
197
196
  }
198
197
  }
199
- //#endregion
200
- //#region ../internal/src/build/client-output.ts
198
+ // ../internal/src/build/client-output.ts
201
199
  function hasStaticIndex(clientDir) {
202
200
  return existsSync(resolve$1(clientDir, "index.html"));
203
201
  }
@@ -234,8 +232,7 @@ async function copyClientOutput(clientDir, targetDir, excludedDirs = []) {
234
232
  filter
235
233
  });
236
234
  }
237
- //#endregion
238
- //#region ../internal/src/build/provider-output-config.ts
235
+ // ../internal/src/build/provider-output-config.ts
239
236
  function isProviderJsonArray(value, ancestors) {
240
237
  if (Object.getPrototypeOf(value) !== Array.prototype || ancestors.has(value)) return false;
241
238
  if (Reflect.ownKeys(value).length !== value.length + 1) return false;
@@ -373,8 +370,7 @@ async function cleanProviderOutputConfig(file, ownership) {
373
370
  if (!changed) return;
374
371
  await persistProviderJsonRecord(file, next, true);
375
372
  }
376
- //#endregion
377
- //#region ../internal/src/build/user-entry.ts
373
+ // ../internal/src/build/user-entry.ts
378
374
  function toSafeAppName(rootDir) {
379
375
  return basename(rootDir).replace(/[^a-z0-9-]+/gi, "-").replace(/-+/g, "-").replace(/^-|-$/g, "").toLowerCase();
380
376
  }
@@ -395,8 +391,7 @@ async function writeCloudflareWranglerConfig(options) {
395
391
  removeIfEmpty: true
396
392
  });
397
393
  }
398
- //#endregion
399
- //#region ../internal/src/build/bundle-options.ts
394
+ // ../internal/src/build/bundle-options.ts
400
395
  const encodedAliasPrefixMarker = "\0vitehub-prefix:";
401
396
  const encodedAliasExactMarker = "\0vitehub-exact:";
402
397
  function encodeProviderOutputAliases(configAliases) {
@@ -415,14 +410,17 @@ function encodeProviderOutputAliases(configAliases) {
415
410
  /** Select the runtime constants from one resolved Vite configuration. */
416
411
  function resolveViteHubBundleDefines(config) {
417
412
  const defines = {};
418
- for (const name of ["__VITEHUB_PUBLIC_URL__", "__VITEHUB_APP_BASE_URL__"]) {
413
+ for (const name of [
414
+ "__VITEHUB_PUBLIC_URL__",
415
+ "__VITEHUB_APP_BASE_URL__",
416
+ "__VITEHUB_CONSOLE_URL__"
417
+ ]) {
419
418
  const value = config.define?.[name];
420
419
  if (typeof value === "string") defines[name] = value;
421
420
  }
422
421
  return defines;
423
422
  }
424
- //#endregion
425
- //#region ../internal/src/build/ast-walk.ts
423
+ // ../internal/src/build/ast-walk.ts
426
424
  /** The oxc parser grammar for a file, from its extension. Defaults to TypeScript. */
427
425
  function moduleLanguage(file) {
428
426
  if (/\.(?:c|m)?tsx$/i.test(file)) return "tsx";
@@ -445,8 +443,7 @@ function walk(node, visit, parent) {
445
443
  } else if (isNode(child)) walk(child, visit, node);
446
444
  }
447
445
  }
448
- //#endregion
449
- //#region ../internal/src/build/rolldown.ts
446
+ // ../internal/src/build/rolldown.ts
450
447
  const viteRawPrefix = "\0vitehub-vite-raw:";
451
448
  const markdownTemplatePrefix = "\0vitehub-markdown-template:";
452
449
  const markdownTemplateFileSuffix = ".template.md";
@@ -812,20 +809,20 @@ function createFileUrlPlugin() {
812
809
  }
813
810
  };
814
811
  }
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
812
  function createWasmModulePlugin(outdir, workingDir, copy) {
821
813
  return {
822
814
  name: "vitehub-wasm-module",
823
815
  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), {
816
+ const explicitModule = source.endsWith(".wasm?module");
817
+ if (!explicitModule && (!copy || !source.endsWith(".wasm") || extra.custom?.[skipMarkdownTemplateResolve])) return;
818
+ const path = explicitModule ? source.slice(0, -7) : source;
819
+ const resolved = await this.resolve(path, importerFor(importer, workingDir), {
826
820
  custom: extra.custom,
827
- kind: extra.kind
821
+ isEntry: extra.isEntry,
822
+ kind: extra.kind,
823
+ skipSelf: true
828
824
  });
825
+ if (!explicitModule && (!isFileResolution(resolved) || !resolved.id.endsWith(".wasm"))) return resolved ?? void 0;
829
826
  if (!isFileResolution(resolved)) this.error(`[vitehub] Could not resolve ${JSON.stringify(source)}.`);
830
827
  if (!copy) return resolved.id;
831
828
  const bytes = await readFile(resolved.id);
@@ -1043,8 +1040,7 @@ async function bundleEsmEntry(entryFile, outfile, options = {}) {
1043
1040
  await writeFile(outfile, chunk.code, { signal: options.signal });
1044
1041
  options.signal?.throwIfAborted();
1045
1042
  }
1046
- //#endregion
1047
- //#region ../../node_modules/.pnpm/balanced-match@4.0.4/node_modules/balanced-match/dist/esm/index.js
1043
+ // ../../node_modules/.pnpm/balanced-match@4.0.4/node_modules/balanced-match/dist/esm/index.js
1048
1044
  const balanced = (a, b, str) => {
1049
1045
  const ma = a instanceof RegExp ? maybeMatch(a, str) : a;
1050
1046
  const mb = b instanceof RegExp ? maybeMatch(b, str) : b;
@@ -1091,8 +1087,7 @@ const range = (a, b, str) => {
1091
1087
  }
1092
1088
  return result;
1093
1089
  };
1094
- //#endregion
1095
- //#region ../../node_modules/.pnpm/brace-expansion@5.0.12/node_modules/brace-expansion/dist/esm/index.js
1090
+ // ../../node_modules/.pnpm/brace-expansion@5.0.12/node_modules/brace-expansion/dist/esm/index.js
1096
1091
  const escSlash = "\0SLASH" + Math.random() + "\0";
1097
1092
  const escOpen = "\0OPEN" + Math.random() + "\0";
1098
1093
  const escClose = "\0CLOSE" + Math.random() + "\0";
@@ -1292,39 +1287,94 @@ function expand_(str, max, maxLength, maxDepth, depth, maxRewrites, isTop) {
1292
1287
  }
1293
1288
  return acc;
1294
1289
  }
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");
1290
+ // ../../node_modules/.pnpm/@isaacs+nonrecursive-glob-match@1.1.0/node_modules/@isaacs/nonrecursive-glob-match/dist/esm/numeric-range.js
1291
+ const digit = (a, b) => a === b ? {
1292
+ t: "lit",
1293
+ ch: String(a)
1294
+ } : {
1295
+ t: "class",
1296
+ re: new RegExp(`^[${a}-${b}]$`)
1297
+ };
1298
+ const prefix = (d, alts) => alts.map((s) => [digit(d, d), ...s]);
1299
+ const fixed = (a, b) => {
1300
+ if (!a) return [[]];
1301
+ let lo = +a[0];
1302
+ let hi = +b[0];
1303
+ const ra = a.slice(1);
1304
+ const rb = b.slice(1);
1305
+ if (lo === hi) return prefix(lo, fixed(ra, rb));
1306
+ const zeros = "0".repeat(ra.length);
1307
+ const nines = "9".repeat(ra.length);
1308
+ const out = [];
1309
+ if (ra !== zeros) out.push(...prefix(lo++, fixed(ra, nines)));
1310
+ const last = rb === nines ? [] : prefix(hi--, fixed(zeros, rb));
1311
+ if (lo <= hi) out.push([digit(lo, hi), ...Array.from(ra, () => digit(0, 9))]);
1312
+ out.push(...last);
1313
+ return out;
1314
+ };
1315
+ const nonneg = (a, b, width) => {
1316
+ if (width) return fixed(String(a).padStart(width, "0"), String(b).padStart(width, "0"));
1317
+ const out = [];
1318
+ for (let len = String(a).length; len <= String(b).length; len++) {
1319
+ const lo = Math.max(a, len === 1 ? 0 : 10 ** (len - 1));
1320
+ const hi = Math.min(b, 10 ** len - 1);
1321
+ out.push(...fixed(String(lo), String(hi)));
1322
+ }
1323
+ return out;
1324
+ };
1325
+ /**
1326
+ * The strings that the bash brace expansion `{lo..hi}` makes, as
1327
+ * the alternatives of an `@(...)` extglob. Each one is a sequence of
1328
+ * digits and digit classes, so there are only a few of them, even for
1329
+ * a large range.
1330
+ *
1331
+ * If either end has a leading zero, such as `{01..10}`, each number
1332
+ * has leading zeros to make it as long as the longer end, counting a
1333
+ * `-` sign. So `{-05..3}` makes `-05` to `-01`, then `000` to `003`.
1334
+ *
1335
+ * Returns undefined if either end is not a safe integer.
1336
+ */
1337
+ const numericRange = (loStr, hiStr) => {
1338
+ let lo = Number(loStr);
1339
+ let hi = Number(hiStr);
1340
+ if (!Number.isSafeInteger(lo) || !Number.isSafeInteger(hi)) return;
1341
+ if (lo > hi) [lo, hi] = [hi, lo];
1342
+ const width = /^-?0\d/.test(loStr) || /^-?0\d/.test(hiStr) ? Math.max(loStr.length, hiStr.length) : 0;
1343
+ const out = [];
1344
+ if (lo < 0) {
1345
+ const neg = nonneg(Math.max(-hi, 1), -lo, width && width - 1);
1346
+ out.push(...neg.map((s) => [{
1347
+ t: "lit",
1348
+ ch: "-"
1349
+ }, ...s]));
1350
+ }
1351
+ if (hi >= 0) out.push(...nonneg(Math.max(lo, 0), hi, width));
1352
+ return out;
1301
1353
  };
1302
- //#endregion
1303
- //#region ../../node_modules/.pnpm/minimatch@10.2.6/node_modules/minimatch/dist/esm/brace-expressions.js
1354
+ // ../../node_modules/.pnpm/@isaacs+nonrecursive-glob-match@1.1.0/node_modules/@isaacs/nonrecursive-glob-match/dist/esm/parse-class.js
1304
1355
  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],
1356
+ "[:alnum:]": ["\\p{L}\\p{Nl}\\p{Nd}"],
1357
+ "[:alpha:]": ["\\p{L}\\p{Nl}"],
1358
+ "[:ascii:]": ["\\x00-\\x7f"],
1359
+ "[:blank:]": ["\\p{Zs}\\t"],
1360
+ "[:cntrl:]": ["\\p{Cc}"],
1361
+ "[:digit:]": ["\\p{Nd}"],
1362
+ "[:graph:]": ["\\p{Z}\\p{C}", true],
1363
+ "[:lower:]": ["\\p{Ll}"],
1317
1364
  "[: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]
1365
+ "[:punct:]": ["\\p{P}\\p{S}"],
1366
+ "[:space:]": ["\\p{Z}\\t\\r\\n\\v\\f"],
1367
+ "[:upper:]": ["\\p{Lu}"],
1368
+ "[:word:]": ["\\p{L}\\p{Nl}\\p{Nd}\\p{Pc}"],
1369
+ "[:xdigit:]": ["A-Fa-f0-9"]
1323
1370
  };
1324
1371
  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) => {
1372
+ const noMatch = /$./;
1373
+ const parseClass = (glob, position, nocase = false, form) => {
1374
+ const norm = (c) => {
1375
+ const n = form ? c.normalize(form) : c;
1376
+ return [...n].length === 1 ? n : c;
1377
+ };
1328
1378
  const pos = position;
1329
1379
  /* c8 ignore start */
1330
1380
  if (glob.charAt(pos) !== "[") throw new Error("not in a brace expression");
@@ -1333,13 +1383,12 @@ const parseClass = (glob, position) => {
1333
1383
  const negs = [];
1334
1384
  let i = pos + 1;
1335
1385
  let sawStart = false;
1336
- let uflag = false;
1337
1386
  let escaping = false;
1338
1387
  let negate = false;
1339
1388
  let endPos = pos;
1340
1389
  let rangeStart = "";
1341
1390
  WHILE: while (i < glob.length) {
1342
- const c = glob.charAt(i);
1391
+ const c = String.fromCodePoint(glob.codePointAt(i));
1343
1392
  if ((c === "!" || c === "^") && i === pos + 1) {
1344
1393
  negate = true;
1345
1394
  i++;
@@ -1358,607 +1407,659 @@ const parseClass = (glob, position) => {
1358
1407
  }
1359
1408
  }
1360
1409
  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
- ];
1410
+ for (const [cls, [unip, neg]] of Object.entries(posixClasses)) if (glob.startsWith(cls, i)) {
1411
+ if (rangeStart) return [noMatch, glob.length - pos];
1368
1412
  i += cls.length;
1369
1413
  if (neg) negs.push(unip);
1370
1414
  else ranges.push(unip);
1371
- uflag = uflag || u;
1372
1415
  continue WHILE;
1373
1416
  }
1374
1417
  }
1375
1418
  escaping = false;
1419
+ const n = norm(c);
1376
1420
  if (rangeStart) {
1377
- if (c > rangeStart) ranges.push(braceEscape(rangeStart) + "-" + braceEscape(c));
1378
- else if (c === rangeStart) ranges.push(braceEscape(c));
1421
+ if (n.codePointAt(0) > rangeStart.codePointAt(0)) ranges.push(braceEscape(rangeStart) + "-" + braceEscape(n));
1422
+ else if (n === rangeStart) ranges.push(braceEscape(n));
1379
1423
  rangeStart = "";
1380
- i++;
1424
+ i += c.length;
1381
1425
  continue;
1382
1426
  }
1383
- if (glob.startsWith("-]", i + 1)) {
1384
- ranges.push(braceEscape(c + "-"));
1385
- i += 2;
1427
+ if (glob.startsWith("-]", i + c.length)) {
1428
+ ranges.push(braceEscape(n + "-"));
1429
+ i += c.length + 1;
1386
1430
  continue;
1387
1431
  }
1388
- if (glob.startsWith("-", i + 1)) {
1389
- rangeStart = c;
1390
- i += 2;
1432
+ if (glob.startsWith("-", i + c.length)) {
1433
+ rangeStart = n;
1434
+ i += c.length + 1;
1391
1435
  continue;
1392
1436
  }
1393
- ranges.push(braceEscape(c));
1394
- i++;
1437
+ ranges.push(braceEscape(n));
1438
+ i += c.length;
1395
1439
  }
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
- ];
1440
+ if (endPos < i) return [noMatch, 0];
1441
+ if (!ranges.length && !negs.length) return [noMatch, glob.length - pos];
1442
+ const sranges = "[" + (negate ? "^" : "") + ranges.join("") + "]";
1443
+ const snegs = "[" + (negate ? "" : "^") + negs.join("") + "]";
1444
+ const comb = "^" + (ranges.length && negs.length ? "(" + sranges + "|" + snegs + ")" : ranges.length ? sranges : snegs);
1445
+ return [new RegExp(comb, nocase ? "iu" : "u"), endPos - pos];
1446
+ };
1447
+ // ../../node_modules/.pnpm/@isaacs+nonrecursive-glob-match@1.1.0/node_modules/@isaacs/nonrecursive-glob-match/dist/esm/index.js
1448
+ const MATCH = {
1449
+ t: "match",
1450
+ id: 0
1451
+ };
1452
+ const extTypes = "!?+*@";
1453
+ const lit = (ch) => ({
1454
+ t: "lit",
1455
+ ch
1456
+ });
1457
+ const reEscape = (s) => s.replace(/[\\^$.*+?()[\]{}|/]/g, "\\$&");
1458
+ const newFoldRe = (s) => new RegExp(`^${reEscape(s)}$`, "iu");
1459
+ const foldCache = /* @__PURE__ */ new Map();
1460
+ const foldRe = (ch) => {
1461
+ let re = foldCache.get(ch);
1462
+ if (!re) {
1463
+ re = newFoldRe(ch);
1464
+ if (foldCache.size >= 1e3) foldCache.clear();
1465
+ foldCache.set(ch, re);
1466
+ }
1467
+ return re;
1468
+ };
1469
+ const litMatch = (l, c) => {
1470
+ if (c === l.ch) return true;
1471
+ if (!l.re) return false;
1472
+ const code = c.charCodeAt(0);
1473
+ if (code >= 128) return l.re.test(c);
1474
+ const ascii = l.ascii ??= /* @__PURE__ */ new Uint8Array(128);
1475
+ ascii[code] ||= l.re.test(c) ? 1 : 2;
1476
+ return ascii[code] === 1;
1477
+ };
1478
+ const tokenize = (p, nocase, noext, form, mark) => {
1479
+ const toks = [];
1480
+ for (let i = 0; i < p.length;) {
1481
+ const c = String.fromCodePoint(p.codePointAt(i));
1482
+ if (mark) {
1483
+ const m = c === "\\" && p.startsWith(mark, i + 1) ? 1 : 0;
1484
+ if (m || c === mark) {
1485
+ const start = i + m + mark.length;
1486
+ const end = p.indexOf(mark, start);
1487
+ const r = /^(-?\d+)\.\.(-?\d+)$/.exec(p.slice(start, end));
1488
+ const alts = end !== -1 && r && numericRange(r[1], r[2]);
1489
+ if (alts) {
1490
+ toks.push({
1491
+ t: "ext",
1492
+ type: "@",
1493
+ alts
1494
+ });
1495
+ i = end + mark.length;
1496
+ continue;
1497
+ }
1498
+ }
1499
+ }
1500
+ if (c === "\\") {
1501
+ const e = p.codePointAt(i + 1);
1502
+ const ch = e === void 0 ? c : String.fromCodePoint(e);
1503
+ toks.push(lit(ch));
1504
+ i += 1 + ch.length;
1505
+ continue;
1506
+ }
1507
+ if (c === "[") {
1508
+ const [re, consumed] = parseClass(p, i, nocase, form);
1509
+ if (consumed) {
1510
+ toks.push({
1511
+ t: "class",
1512
+ re
1513
+ });
1514
+ i += consumed;
1515
+ continue;
1516
+ }
1517
+ }
1518
+ if (!noext && extTypes.includes(c) && p[i + 1] === "(") {
1519
+ toks.push({
1520
+ t: "open",
1521
+ type: c
1522
+ });
1523
+ i += 2;
1524
+ continue;
1525
+ }
1526
+ toks.push(!noext && c === "|" ? { t: "bar" } : !noext && c === ")" ? { t: "close" } : c === "*" ? { t: "star" } : c === "?" ? { t: "any" } : lit(c));
1527
+ i += c.length;
1416
1528
  }
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
- ];
1529
+ return toks;
1425
1530
  };
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");
1531
+ const pair = (toks) => {
1532
+ const pairs = /* @__PURE__ */ new Map();
1533
+ const stack = [];
1534
+ toks.forEach((tok, i) => {
1535
+ if (tok.t === "open") stack.push(i);
1536
+ else if (tok.t === "close" && stack.length) pairs.set(stack.pop(), i);
1537
+ });
1538
+ return pairs;
1450
1539
  };
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
- };
1540
+ const build = (toks, pairs, start, end, top) => {
1541
+ let seq = [];
1542
+ const alts = [seq];
1543
+ for (let i = start; i < end; i++) {
1544
+ const tok = toks[i];
1545
+ const close = pairs.get(i);
1546
+ if (tok.t === "open" && close !== void 0) {
1547
+ const sub = build(toks, pairs, i + 1, close, false);
1548
+ seq.push({
1549
+ t: "ext",
1550
+ type: tok.type,
1551
+ alts: sub
1552
+ });
1553
+ i = close;
1554
+ } else if (tok.t === "bar" && !top) alts.push(seq = []);
1555
+ else if (tok.t === "open") seq.push(lit(tok.type), lit("("));
1556
+ else if (tok.t === "bar") seq.push(lit("|"));
1557
+ else if (tok.t === "close") seq.push(lit(")"));
1558
+ else seq.push(tok);
1559
+ }
1560
+ return alts;
1561
+ };
1562
+ const normalize$1 = (items, form) => {
1563
+ const out = [];
1564
+ let run = "";
1565
+ const flush = () => {
1566
+ for (const ch of run.normalize(form)) out.push(lit(ch));
1567
+ run = "";
1568
+ };
1569
+ for (const it of items) {
1570
+ if (it.t === "lit") {
1571
+ run += it.ch;
1572
+ continue;
1573
+ }
1574
+ flush();
1575
+ out.push(it.t === "ext" ? {
1576
+ ...it,
1577
+ alts: it.alts.map((a) => normalize$1(a, form))
1578
+ } : it);
1547
1579
  }
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;
1580
+ flush();
1581
+ return out;
1582
+ };
1583
+ const compile = (items, nocase) => {
1584
+ let id = 1;
1585
+ const split = (out) => ({
1586
+ t: "split",
1587
+ id: id++,
1588
+ out
1589
+ });
1590
+ const seq = (items, next) => items.reduceRight((next, it) => item(it, next), next);
1591
+ const item = (it, next) => {
1592
+ switch (it.t) {
1593
+ case "lit":
1594
+ const re = nocase ? foldRe(it.ch) : void 0;
1595
+ return {
1596
+ t: "lit",
1597
+ id: id++,
1598
+ ch: it.ch,
1599
+ re,
1600
+ next
1601
+ };
1602
+ case "any":
1603
+ case "star": return {
1604
+ t: it.t,
1605
+ id: id++,
1606
+ next
1607
+ };
1608
+ case "class": return {
1609
+ t: "class",
1610
+ id: id++,
1611
+ re: it.re,
1612
+ next
1613
+ };
1614
+ }
1615
+ const alts = (next) => it.alts.map((a) => seq(a, next));
1616
+ switch (it.type) {
1617
+ case "@": return split(alts(next));
1618
+ case "?": return split([next, ...alts(next)]);
1619
+ case "!": return {
1620
+ t: "neg",
1621
+ id: id++,
1622
+ sub: split(alts(MATCH)),
1623
+ next
1624
+ };
1565
1625
  }
1566
- return this.#hasMagic;
1626
+ const after = split([]);
1627
+ const entry = split(alts(after));
1628
+ after.out.push(next, entry);
1629
+ return it.type === "*" ? after : entry;
1630
+ };
1631
+ return [seq(items, MATCH), id];
1632
+ };
1633
+ const show = (start) => {
1634
+ const lines = [];
1635
+ const seen = /* @__PURE__ */ new Set();
1636
+ const ref = (n) => n.t === "match" ? "match" : String(n.id);
1637
+ const walk = (n, indent) => {
1638
+ if (n.t === "match" || seen.has(n)) return;
1639
+ seen.add(n);
1640
+ const line = (desc) => lines.push(`${indent}${n.id}: ${desc}`);
1641
+ switch (n.t) {
1642
+ case "split":
1643
+ line(`split -> ${n.out.map(ref).join(", ")}`);
1644
+ for (const o of n.out) walk(o, indent);
1645
+ return;
1646
+ case "neg":
1647
+ line(`!(${ref(n.sub)}) -> ${ref(n.next)}`);
1648
+ walk(n.sub, indent + " ");
1649
+ return walk(n.next, indent);
1650
+ case "lit":
1651
+ line(`${JSON.stringify(n.ch)} -> ${ref(n.next)}`);
1652
+ break;
1653
+ case "class":
1654
+ line(`${n.re} -> ${ref(n.next)}`);
1655
+ break;
1656
+ default: line(`${n.t === "any" ? "?" : "*"} -> ${ref(n.next)}`);
1657
+ }
1658
+ walk(n.next, indent);
1659
+ };
1660
+ walk(start, "");
1661
+ return [`start -> ${ref(start)}`, ...lines].join("\n");
1662
+ };
1663
+ var State = class {
1664
+ gen;
1665
+ threads = [];
1666
+ match = false;
1667
+ runs = [];
1668
+ ids = [];
1669
+ constructor(gen) {
1670
+ this.gen = gen;
1671
+ }
1672
+ get dead() {
1673
+ return !this.threads.length && !this.match && !this.runs.length;
1567
1674
  }
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("|") + ")";
1675
+ };
1676
+ const sameState = (a, b) => {
1677
+ if (a.ids.length !== b.ids.length) return false;
1678
+ if (a.runs.length !== b.runs.length) return false;
1679
+ if (a.ids.some((id, i) => id !== b.ids[i])) return false;
1680
+ return a.runs.every((r) => b.runs.some((o) => o.neg === r.neg && sameState(o.state, r.state)));
1681
+ };
1682
+ const marks = (size) => ({
1683
+ has: new Float64Array(size),
1684
+ seen: new Float64Array(size),
1685
+ gen: 0
1686
+ });
1687
+ var Sim = class {
1688
+ dots;
1689
+ dotStart;
1690
+ #marks;
1691
+ constructor(dots, dotStart, marks) {
1692
+ this.dots = dots;
1693
+ this.dotStart = dotStart;
1694
+ this.#marks = marks;
1695
+ }
1696
+ state() {
1697
+ return new State(++this.#marks.gen);
1698
+ }
1699
+ done(state) {
1700
+ state.ids = state.threads.map((n) => n.id).sort((a, b) => a - b);
1701
+ if (state.match) state.ids.unshift(MATCH.id);
1702
+ return state;
1703
+ }
1704
+ #visit(state, node) {
1705
+ const { seen } = this.#marks;
1706
+ if (seen[node.id] === state.gen) return false;
1707
+ seen[node.id] = state.gen;
1708
+ return true;
1570
1709
  }
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;
1710
+ #addThread(state, node) {
1711
+ const { has } = this.#marks;
1712
+ if (has[node.id] === state.gen) return false;
1713
+ has[node.id] = state.gen;
1714
+ state.threads.push(node);
1715
+ return true;
1595
1716
  }
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);
1717
+ restricted(i, top) {
1718
+ return top && (this.dots || this.dotStart && i === 0);
1719
+ }
1720
+ add(state, node, i, top) {
1721
+ switch (node.t) {
1722
+ case "split":
1723
+ if (!this.#visit(state, node)) return;
1724
+ for (const o of node.out) this.add(state, o, i, top);
1725
+ return;
1726
+ case "neg":
1727
+ if (!this.#visit(state, node)) return;
1728
+ const sub = this.state();
1729
+ this.add(sub, node.sub, i, false);
1730
+ this.done(sub);
1731
+ return this.addRun(state, {
1732
+ t: "run",
1733
+ neg: node,
1734
+ state: sub
1735
+ }, i, top);
1736
+ case "star":
1737
+ if (this.restricted(i, top)) return;
1738
+ if (this.#addThread(state, node)) this.add(state, node.next, i, top);
1739
+ return;
1740
+ case "match":
1741
+ state.match = true;
1742
+ return;
1743
+ default: this.#addThread(state, node);
1603
1744
  }
1604
1745
  }
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;
1746
+ addRun(state, run, i, top) {
1747
+ for (const r of state.runs) if (r.neg === run.neg && sameState(r.state, run.state)) return;
1748
+ state.runs.push(run);
1749
+ if (!run.state.match) this.add(state, run.neg.next, i, top);
1610
1750
  }
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;
1751
+ step(state, c, i, top) {
1752
+ const next = this.state();
1753
+ for (const th of state.threads) switch (th.t) {
1754
+ case "lit":
1755
+ if (litMatch(th, c)) this.add(next, th.next, i + 1, top);
1756
+ break;
1757
+ case "any":
1758
+ if (!this.restricted(i, top)) this.add(next, th.next, i + 1, top);
1759
+ break;
1760
+ case "class":
1761
+ if (!this.restricted(i, top) && th.re.test(c)) this.add(next, th.next, i + 1, top);
1762
+ break;
1763
+ case "star": if (!this.restricted(i, top)) this.add(next, th, i + 1, top);
1619
1764
  }
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;
1765
+ if (!this.restricted(i, top)) for (const run of state.runs) {
1766
+ if (run.state.dead) {
1767
+ this.addRun(next, run, i + 1, top);
1692
1768
  continue;
1693
1769
  }
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;
1705
- continue;
1706
- }
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
- });
1770
+ const sub = this.step(run.state, c, i, false);
1771
+ this.addRun(next, {
1772
+ t: "run",
1773
+ neg: run.neg,
1774
+ state: sub
1775
+ }, i + 1, top);
1776
+ }
1777
+ return this.done(next);
1802
1778
  }
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
- }
1779
+ };
1780
+ const stateKey = (state) => {
1781
+ const ids = state.ids.join();
1782
+ if (!state.runs.length) return ids;
1783
+ return `${ids}|${state.runs.map((r) => `${r.neg.id}(${stateKey(r.state)})`).sort().join("|")}`;
1784
+ };
1785
+ const DFA_BUDGET = 1 << 18;
1786
+ var Dfa = class {
1787
+ #start;
1788
+ #states = /* @__PURE__ */ new Map();
1789
+ #size = 0;
1790
+ #plain;
1791
+ #dotStart;
1792
+ #sim;
1793
+ #dotSim;
1794
+ constructor(start, marks) {
1795
+ this.#start = start;
1796
+ this.#sim = new Sim(false, false, marks);
1797
+ this.#dotSim = new Sim(false, true, marks);
1798
+ }
1799
+ #make(state) {
1800
+ return {
1801
+ state,
1802
+ match: state.match,
1803
+ dead: state.dead,
1804
+ next: /* @__PURE__ */ new Map()
1805
+ };
1806
+ }
1807
+ #intern(state) {
1808
+ const key = stateKey(state);
1809
+ const found = this.#states.get(key);
1810
+ if (found) return found;
1811
+ if (this.#size > DFA_BUDGET) this.#clear();
1812
+ const d = this.#make(state);
1813
+ this.#states.set(key, d);
1814
+ this.#size += key.length + 1;
1815
+ return d;
1816
+ }
1817
+ #clear() {
1818
+ this.#states.clear();
1819
+ this.#size = 0;
1820
+ this.#plain = void 0;
1821
+ this.#dotStart = void 0;
1822
+ }
1823
+ start(dotStart) {
1824
+ if (dotStart) {
1825
+ if (this.#dotStart) return this.#dotStart;
1826
+ const state = this.#dotSim.state();
1827
+ this.#dotSim.add(state, this.#start, 0, true);
1828
+ return this.#dotStart = this.#make(this.#dotSim.done(state));
1829
+ }
1830
+ if (this.#plain) return this.#plain;
1831
+ const state = this.#sim.state();
1832
+ this.#sim.add(state, this.#start, 0, true);
1833
+ return this.#plain = this.#intern(this.#sim.done(state));
1834
+ }
1835
+ next(d, c) {
1836
+ const code = c.charCodeAt(0);
1837
+ const found = code < 128 ? void 0 : d.next.get(c);
1838
+ if (found) return found;
1839
+ 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));
1840
+ if (code < 128) {
1841
+ if (!d.ascii) {
1842
+ d.ascii = new Array(128);
1843
+ this.#size += 128;
1830
1844
  }
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
- ];
1845
+ d.ascii[code] = n;
1846
+ } else d.next.set(c, n);
1847
+ this.#size++;
1848
+ return n;
1871
1849
  }
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);
1850
+ };
1851
+ const linear = (start) => {
1852
+ const nodes = [];
1853
+ for (let n = start; n.t !== "match"; n = n.next) {
1854
+ if (n.t === "split" || n.t === "neg") return void 0;
1855
+ nodes.push(n);
1856
+ }
1857
+ return nodes;
1858
+ };
1859
+ const testLinear = (nodes, chars, start, end) => {
1860
+ let ni = 0;
1861
+ let ci = start;
1862
+ let starNi = -1;
1863
+ let starCi = 0;
1864
+ while (ci < end) {
1865
+ const n = nodes[ni];
1866
+ if (n?.t === "star") {
1867
+ starNi = ni++;
1868
+ starCi = ci;
1869
+ continue;
1870
+ }
1871
+ const c = chars[ci];
1872
+ if (n && (n.t === "any" || n.t === "lit" && litMatch(n, c) || n.t === "class" && n.re.test(c))) {
1873
+ ni++;
1874
+ ci++;
1875
+ continue;
1897
1876
  }
1898
- this.#toString = void 0;
1877
+ if (starNi === -1) return false;
1878
+ ni = starNi + 1;
1879
+ ci = ++starCi;
1899
1880
  }
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;
1881
+ while (nodes[ni]?.t === "star") ni++;
1882
+ return ni === nodes.length;
1883
+ };
1884
+ const lengths = (items) => {
1885
+ let min = 0;
1886
+ let max = 0;
1887
+ for (const it of items) {
1888
+ const [lo, hi] = itemLengths(it);
1889
+ min += lo;
1890
+ max += hi;
1891
+ }
1892
+ return [min, max];
1893
+ };
1894
+ const itemLengths = (it) => {
1895
+ if (it.t === "star") return [0, Infinity];
1896
+ if (it.t !== "ext") return [1, 1];
1897
+ if (it.type === "!") return [0, Infinity];
1898
+ const alts = it.alts.map(lengths);
1899
+ const min = Math.min(...alts.map((a) => a[0]));
1900
+ const max = Math.max(...alts.map((a) => a[1]));
1901
+ const loop = max === 0 ? 0 : Infinity;
1902
+ return it.type === "@" ? [min, max] : it.type === "?" ? [0, max] : it.type === "*" ? [0, loop] : [min, loop];
1903
+ };
1904
+ const hasAffix = (lits, chars, start) => {
1905
+ for (let j = 0; j < lits.length; j++) if (!litMatch(lits[j], chars[start + j])) return false;
1906
+ return true;
1907
+ };
1908
+ const slashOrSurrogate = /[/\ud800-\udfff]/;
1909
+ const surrogate = /[\ud800-\udfff]/;
1910
+ const codePoints = (s) => surrogate.test(s) ? [...s] : s;
1911
+ const noSlash = (s) => {
1912
+ if (s.includes("/")) throw new Error("can only match a single path portion, got: " + s);
1913
+ };
1914
+ var Matcher = class {
1915
+ pattern;
1916
+ options;
1917
+ #start;
1918
+ #size;
1919
+ #marks;
1920
+ #dotsSim;
1921
+ #literal;
1922
+ #literalFold = false;
1923
+ #literalRe;
1924
+ #linear;
1925
+ #wild = false;
1926
+ #min = 0;
1927
+ #max = Infinity;
1928
+ #prefix = [];
1929
+ #suffix = [];
1930
+ #prefixStr;
1931
+ #suffixStr;
1932
+ #affix = false;
1933
+ #dfa;
1934
+ #form;
1935
+ constructor(pattern, options = {}) {
1936
+ if (pattern.includes("/")) throw new Error("can only match a single path portion, got pattern: " + pattern);
1937
+ this.pattern = pattern;
1938
+ this.options = options;
1939
+ const { nocase = false, noext = false, normalize: n } = options;
1940
+ this.#form = n === true ? "NFC" : n || void 0;
1941
+ const literal = /^[?*+@]\(\)$/.test(pattern);
1942
+ const toks = tokenize(pattern, nocase, noext || literal, this.#form, options.rangeMark);
1943
+ let [items] = build(toks, pair(toks), 0, toks.length, true);
1944
+ if (this.#form) items = normalize$1(items, this.#form);
1945
+ const [start, size] = compile(items, nocase);
1946
+ this.#start = start;
1947
+ this.#size = size;
1948
+ if (items.every((it) => it.t === "lit")) {
1949
+ this.#literal = items.map((it) => it.ch).join("");
1950
+ this.#literalFold = nocase;
1951
+ } else {
1952
+ const lit = (it) => it.t !== "lit" ? void 0 : nocase ? {
1953
+ ch: it.ch,
1954
+ re: foldRe(it.ch)
1955
+ } : { ch: it.ch };
1956
+ for (const it of items) {
1957
+ const l = lit(it);
1958
+ if (!l) break;
1959
+ this.#prefix.push(l);
1921
1960
  }
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;
1961
+ for (let j = items.length - 1; j >= 0; j--) {
1962
+ const l = lit(items[j]);
1963
+ if (!l) break;
1964
+ this.#suffix.unshift(l);
1933
1965
  }
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
- }
1966
+ this.#affix = !!(this.#prefix.length || this.#suffix.length);
1967
+ if (!nocase) {
1968
+ this.#prefixStr = this.#prefix.map((l) => l.ch).join("");
1969
+ this.#suffixStr = this.#suffix.map((l) => l.ch).join("");
1943
1970
  }
1944
- if (c === "?") {
1945
- re += qmark;
1946
- hasMagic = true;
1947
- continue;
1971
+ this.#linear = linear(this.#start)?.slice(this.#prefix.length, -this.#suffix.length || void 0);
1972
+ this.#wild = !!this.#linear?.every((n) => n.t === "star" || n.t === "any");
1973
+ const [min, max] = lengths(items);
1974
+ this.#min = min;
1975
+ this.#max = max;
1976
+ }
1977
+ }
1978
+ test(s) {
1979
+ if (this.#form) {
1980
+ noSlash(s);
1981
+ return this.#test(s.normalize(this.#form));
1982
+ }
1983
+ if (slashOrSurrogate.test(s)) {
1984
+ noSlash(s);
1985
+ return this.#test(s, [...s]);
1986
+ }
1987
+ return this.#test(s, s);
1988
+ }
1989
+ /**
1990
+ * The same as {@link Matcher#test}, but the string is not checked
1991
+ * for `/` chars, so the result for a string that has one is not
1992
+ * defined. Only use it for a string that is known to be one path
1993
+ * portion, such as a part of a path that was split on `/`. It can
1994
+ * be faster, because some patterns do not need to look at each char
1995
+ * of the string.
1996
+ */
1997
+ testUnchecked(s) {
1998
+ return this.#test(this.#form ? s.normalize(this.#form) : s);
1999
+ }
2000
+ #test(s, chars) {
2001
+ if (this.#literal !== void 0) return this.#literalFold ? (this.#literalRe ??= newFoldRe(this.#literal)).test(s) : s === this.#literal;
2002
+ const min = this.#min;
2003
+ const max = this.#max;
2004
+ if (chars === void 0) {
2005
+ const most = s.length;
2006
+ const least = most + 1 >> 1;
2007
+ if (most < min || least > max) return false;
2008
+ if (least < min || most > max) chars = codePoints(s);
2009
+ }
2010
+ if (chars !== void 0 && (chars.length < min || chars.length > max)) return false;
2011
+ const prefix = this.#prefix.length;
2012
+ if (this.#affix) {
2013
+ if (this.#prefixStr !== void 0 && this.#suffixStr !== void 0) {
2014
+ if (!s.startsWith(this.#prefixStr) || !s.endsWith(this.#suffixStr)) return false;
2015
+ } else {
2016
+ chars ??= codePoints(s);
2017
+ const end = chars.length - this.#suffix.length;
2018
+ if (!hasAffix(this.#prefix, chars, 0) || !hasAffix(this.#suffix, chars, end)) return false;
1948
2019
  }
1949
- re += regExpEscape$1(c);
1950
2020
  }
1951
- return [
1952
- re,
1953
- unescape(glob),
1954
- !!hasMagic,
1955
- uflag
1956
- ];
2021
+ const dotStart = !this.options.dot && s.startsWith(".");
2022
+ if (this.#linear) {
2023
+ if (s === "." || s === "..") return false;
2024
+ if (dotStart && !prefix) return false;
2025
+ if (this.#wild) return true;
2026
+ chars ??= codePoints(s);
2027
+ const end = chars.length - this.#suffix.length;
2028
+ return testLinear(this.#linear, chars, prefix, end);
2029
+ }
2030
+ chars ??= codePoints(s);
2031
+ if (s === "." || s === "..") {
2032
+ this.#marks ??= marks(this.#size);
2033
+ const sim = this.#dotsSim ??= new Sim(true, false, this.#marks);
2034
+ const start = sim.state();
2035
+ sim.add(start, this.#start, 0, true);
2036
+ let state = sim.done(start);
2037
+ for (let i = 0; i < chars.length; i++) state = sim.step(state, chars[i], i, true);
2038
+ return state.match;
2039
+ }
2040
+ this.#marks ??= marks(this.#size);
2041
+ const dfa = this.#dfa ??= new Dfa(this.#start, this.#marks);
2042
+ let d = dfa.start(dotStart);
2043
+ const str = chars === s;
2044
+ for (let i = 0; i < chars.length; i++) {
2045
+ if (d.dead) return false;
2046
+ const code = str ? s.charCodeAt(i) : chars[i].charCodeAt(0);
2047
+ d = d.ascii?.[code] ?? dfa.next(d, chars[i]);
2048
+ }
2049
+ return d.match;
2050
+ }
2051
+ /** a readable listing of the state machine */
2052
+ toString() {
2053
+ return show(this.#start);
1957
2054
  }
1958
2055
  };
1959
- _a = AST;
1960
- //#endregion
1961
- //#region ../../node_modules/.pnpm/minimatch@10.2.6/node_modules/minimatch/dist/esm/escape.js
2056
+ // ../../node_modules/.pnpm/minimatch@11.0.9/node_modules/minimatch/dist/esm/assert-valid-pattern.js
2057
+ const MAX_PATTERN_LENGTH = 65536;
2058
+ const assertValidPattern = (pattern) => {
2059
+ if (typeof pattern !== "string") throw new TypeError("invalid pattern");
2060
+ if (pattern.length > MAX_PATTERN_LENGTH) throw new TypeError("pattern is too long");
2061
+ };
2062
+ // ../../node_modules/.pnpm/minimatch@11.0.9/node_modules/minimatch/dist/esm/escape.js
1962
2063
  /**
1963
2064
  * Escape all magic characters in a glob pattern.
1964
2065
  *
@@ -1970,68 +2071,154 @@ _a = AST;
1970
2071
  *
1971
2072
  * If the {@link MinimatchOptions.magicalBraces} option is used,
1972
2073
  * then braces (`{` and `}`) will be escaped.
2074
+ *
2075
+ * A leading `#` or `!` is escaped as well, so that the result is never a
2076
+ * comment or a negated pattern. In `windowsPathsNoEscape` mode, a leading
2077
+ * `!` is written as `@(!)`, because `[!` starts a negated class.
1973
2078
  */
1974
2079
  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);
2080
+ const e = magicalBraces ? windowsPathsNoEscape ? s.replace(/[?*()[\]{}]/g, "[$&]") : s.replace(/[?*()[\]\\{}]/g, "\\$&") : windowsPathsNoEscape ? s.replace(/[?*()[\]]/g, "[$&]") : s.replace(/[?*()[\]\\]/g, "\\$&");
2081
+ const c = e.charAt(0);
2082
+ if (c === "#") return (windowsPathsNoEscape ? "[#]" : "\\#") + e.slice(1);
2083
+ if (c === "!") return (windowsPathsNoEscape ? "@(!)" : "\\!") + e.slice(1);
2084
+ return e;
1991
2085
  };
1992
- const starDotExtTestNocaseDot = (ext) => {
1993
- ext = ext.toLowerCase();
1994
- return (f) => f.toLowerCase().endsWith(ext);
1995
- };
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);
2086
+ // ../../node_modules/.pnpm/minimatch@11.0.9/node_modules/minimatch/dist/esm/unescape.js
2087
+ /**
2088
+ * Un-escape a string that has been escaped with {@link escape}.
2089
+ *
2090
+ * If the {@link MinimatchOptions.windowsPathsNoEscape} option is used, then
2091
+ * square-bracket escapes are removed, but not backslash escapes.
2092
+ *
2093
+ * For example, it will turn the string `'[*]'` into `*`, but it will not
2094
+ * turn `'\\*'` into `'*'`, because `\` is a path separator in
2095
+ * `windowsPathsNoEscape` mode.
2096
+ *
2097
+ * When `windowsPathsNoEscape` is not set, then both square-bracket escapes and
2098
+ * backslash escapes are removed.
2099
+ *
2100
+ * Slashes (and backslashes in `windowsPathsNoEscape` mode) cannot be escaped
2101
+ * or unescaped.
2102
+ *
2103
+ * When `magicalBraces` is not set, escapes of braces (`{` and `}`) will not be
2104
+ * unescaped.
2105
+ */
2106
+ const unescape = (s, { windowsPathsNoEscape = false, magicalBraces = true } = {}) => {
2107
+ if (windowsPathsNoEscape && s.startsWith("@(!)")) return "!" + unescape(s.slice(4), {
2108
+ windowsPathsNoEscape,
2109
+ magicalBraces
2110
+ });
2111
+ if (magicalBraces) return windowsPathsNoEscape ? s.replace(/\[([^/\\])\]/g, "$1") : s.replace(/((?!\\).|^)\[([^/\\])\]/g, "$1$2").replace(/\\([^/])/g, "$1");
2112
+ return windowsPathsNoEscape ? s.replace(/\[([^/\\{}])\]/g, "$1") : s.replace(/((?!\\).|^)\[([^/\\{}])\]/g, "$1$2").replace(/\\([^/{}])/g, "$1");
2010
2113
  };
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);
2114
+ // ../../node_modules/.pnpm/minimatch@11.0.9/node_modules/minimatch/dist/esm/index.js
2115
+ const DEFAULT_BRACE_EXPAND_MAX = 1e5;
2116
+ const DEFAULT_GLOB_STAR_RECURSION_MAX = 200;
2117
+ const AWE_KEY = "allowWindowsEscape";
2118
+ const minimatch = (p, pattern, options) => {
2119
+ assertValidPattern(pattern);
2120
+ if (!options?.nocomment && pattern.charAt(0) === "#") return false;
2121
+ return cachedMinimatch(pattern, options).match(p);
2016
2122
  };
2017
- const qmarksTestDot = ([$0, ext = ""]) => {
2018
- const noext = qmarksTestNoExtDot([$0]);
2019
- return !ext ? noext : (f) => noext(f) && f.endsWith(ext);
2123
+ let cache = /* @__PURE__ */ new Map();
2124
+ let oldCache = /* @__PURE__ */ new Map();
2125
+ let cacheSize = 0;
2126
+ let cacheTotalWeight = 0;
2127
+ const cacheMax = 256;
2128
+ const cacheMaxWeight = 32768;
2129
+ const cacheMaxEntryWeight = 4096;
2130
+ const cacheWeight = (mm) => {
2131
+ let w = mm.pattern.length;
2132
+ for (const s of mm.globSet) {
2133
+ w += s.length + 1;
2134
+ if (w > cacheMaxEntryWeight) break;
2135
+ }
2136
+ return w;
2020
2137
  };
2021
- const qmarksTest = ([$0, ext = ""]) => {
2022
- const noext = qmarksTestNoExt([$0]);
2023
- return !ext ? noext : (f) => noext(f) && f.endsWith(ext);
2138
+ const tri = (v) => v === void 0 ? 0 : v ? 2 : 1;
2139
+ const booleanWeights = new Map(Object.keys({
2140
+ nobrace: 0,
2141
+ nocomment: 0,
2142
+ nonegate: 0,
2143
+ noglobstar: 0,
2144
+ noext: 0,
2145
+ nonull: 0,
2146
+ partial: 0,
2147
+ dot: 0,
2148
+ nocase: 0,
2149
+ nocaseMagicOnly: 0,
2150
+ magicalBraces: 0,
2151
+ matchBase: 0,
2152
+ flipNegate: 0,
2153
+ preserveMultipleSlashes: 0,
2154
+ windowsNoMagicRoot: 0
2155
+ }).map((k, i) => [k, 24 * 3 ** i]));
2156
+ const optionsKey = (o) => {
2157
+ let n = 0;
2158
+ let wpe = false;
2159
+ for (const k in o) {
2160
+ const v = o[k];
2161
+ switch (k) {
2162
+ case "windowsPathsNoEscape":
2163
+ if (v) wpe = true;
2164
+ break;
2165
+ case AWE_KEY:
2166
+ if (v === false) wpe = true;
2167
+ break;
2168
+ case "platform": {
2169
+ const p = v || defaultPlatform;
2170
+ if (p === defaultPlatform) break;
2171
+ if (p === "darwin") n += 3;
2172
+ else if (p === "win32") n += 6;
2173
+ else if (p === "linux") n += 9;
2174
+ else return JSON.stringify(o);
2175
+ break;
2176
+ }
2177
+ case "optimizationLevel":
2178
+ if (v === void 0) break;
2179
+ n += v >= 2 ? 1 : v >= 1 ? 0 : 2;
2180
+ break;
2181
+ case "braceExpandMax":
2182
+ if (v !== void 0 && v !== DEFAULT_BRACE_EXPAND_MAX) return JSON.stringify(o);
2183
+ break;
2184
+ case "maxGlobstarRecursion":
2185
+ if (v !== void 0 && v !== DEFAULT_GLOB_STAR_RECURSION_MAX) return JSON.stringify(o);
2186
+ break;
2187
+ case "normalize":
2188
+ if (v !== void 0) return JSON.stringify(o);
2189
+ break;
2190
+ default: n += (booleanWeights.get(k) ?? 0) * tri(v);
2191
+ }
2192
+ }
2193
+ return wpe ? n + 12 : n;
2024
2194
  };
2025
- const qmarksTestNoExt = ([$0]) => {
2026
- const len = $0.length;
2027
- return (f) => f.length === len && !f.startsWith(".");
2195
+ const copyOptions = (o) => {
2196
+ const copy = {};
2197
+ for (const k in o) copy[k] = o[k];
2198
+ return copy;
2028
2199
  };
2029
- const qmarksTestNoExtDot = ([$0]) => {
2030
- const len = $0.length;
2031
- return (f) => f.length === len && f !== "." && f !== "..";
2200
+ const cachedMinimatch = (pattern, options) => {
2201
+ const key = options ? optionsKey(options) : 0;
2202
+ let mm = cache.get(key)?.get(pattern);
2203
+ if (mm) return mm;
2204
+ mm = oldCache.get(key)?.get(pattern) ?? new Minimatch(pattern, copyOptions(options));
2205
+ const weight = cacheWeight(mm);
2206
+ if (weight > cacheMaxEntryWeight) return mm;
2207
+ if (cacheSize >= cacheMax || cacheTotalWeight + weight > cacheMaxWeight) {
2208
+ oldCache = cache;
2209
+ cache = /* @__PURE__ */ new Map();
2210
+ cacheSize = 0;
2211
+ cacheTotalWeight = 0;
2212
+ }
2213
+ let byPattern = cache.get(key);
2214
+ if (!byPattern) cache.set(key, byPattern = /* @__PURE__ */ new Map());
2215
+ byPattern.set(pattern, mm);
2216
+ cacheSize++;
2217
+ cacheTotalWeight += weight;
2218
+ return mm;
2032
2219
  };
2033
2220
  /* c8 ignore start */
2034
- const defaultPlatform = typeof process === "object" && process ? typeof process.env === "object" && process.env && process.env.__MINIMATCH_TESTING_PLATFORM__ || process.platform : "posix";
2221
+ const defaultPlatform = typeof process === "object" && process ? process.env?.__MINIMATCH_TESTING_PLATFORM__ || process.platform : "posix";
2035
2222
  const path = {
2036
2223
  win32: { sep: "\\" },
2037
2224
  posix: { sep: "/" }
@@ -2039,10 +2226,10 @@ const path = {
2039
2226
  minimatch.sep = defaultPlatform === "win32" ? path.win32.sep : path.posix.sep;
2040
2227
  const GLOBSTAR = Symbol("globstar **");
2041
2228
  minimatch.GLOBSTAR = GLOBSTAR;
2042
- const star = "[^/]*?";
2043
- const twoStarDot = "(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?";
2044
- const twoStarNoDot = "(?:(?!(?:\\/|^)\\.).)*?";
2045
- const filter = (pattern, options = {}) => (p) => minimatch(p, pattern, options);
2229
+ const filter = (pattern, options) => {
2230
+ let mm;
2231
+ return (p) => (mm ??= cachedMinimatch(pattern, options)).match(p);
2232
+ };
2046
2233
  minimatch.filter = filter;
2047
2234
  const ext = (a, b = {}) => Object.assign({}, a, b);
2048
2235
  const defaults = (def) => {
@@ -2058,21 +2245,10 @@ const defaults = (def) => {
2058
2245
  return orig.defaults(ext(def, options)).Minimatch;
2059
2246
  }
2060
2247
  },
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
2248
  unescape: (s, options = {}) => orig.unescape(s, ext(def, options)),
2072
2249
  escape: (s, options = {}) => orig.escape(s, ext(def, options)),
2073
2250
  filter: (pattern, options = {}) => orig.filter(pattern, ext(def, options)),
2074
2251
  defaults: (options) => orig.defaults(ext(def, options)),
2075
- makeRe: (pattern, options = {}) => orig.makeRe(pattern, ext(def, options)),
2076
2252
  braceExpand: (pattern, options = {}) => orig.braceExpand(pattern, ext(def, options)),
2077
2253
  match: (list, pattern, options = {}) => orig.match(list, pattern, ext(def, options)),
2078
2254
  sep: orig.sep,
@@ -2083,11 +2259,27 @@ minimatch.defaults = defaults;
2083
2259
  const braceExpand = (pattern, options = {}) => {
2084
2260
  assertValidPattern(pattern);
2085
2261
  if (options.nobrace || !/\{(?:(?!\{).)*\}/.test(pattern)) return [pattern];
2086
- return expand(pattern, { max: options.braceExpandMax });
2262
+ let p = pattern.replace(/\\\\/g, "\\\\\\\\");
2263
+ if (options.windowsPathsNoEscape || options[AWE_KEY] === false) p = p.replace(/\[([{}])\]/g, "[\\$1]");
2264
+ return expand(p, { max: options.braceExpandMax });
2087
2265
  };
2088
2266
  minimatch.braceExpand = braceExpand;
2089
- const makeRe = (pattern, options = {}) => new Minimatch(pattern, options).makeRe();
2090
- minimatch.makeRe = makeRe;
2267
+ const RANGE_MIN = 100;
2268
+ const rangeRe = /(?<![\\$])\{(-?\d+)\.\.(-?\d+)\}/g;
2269
+ const inRepeatOrNegExt = (portion, mark) => {
2270
+ const stack = [];
2271
+ for (let i = 0; i < portion.length; i++) {
2272
+ const c = portion.charAt(i);
2273
+ if (c === "\\") i++;
2274
+ else if (c === mark) {
2275
+ if (stack.some((t) => t !== "@" && t !== "?")) return true;
2276
+ } else if (portion.charAt(i + 1) === "(" && "!?+*@".includes(c)) {
2277
+ stack.push(c);
2278
+ i++;
2279
+ } else if (c === ")") stack.pop();
2280
+ }
2281
+ return false;
2282
+ };
2091
2283
  const match = (list, pattern, options = {}) => {
2092
2284
  const mm = new Minimatch(pattern, options);
2093
2285
  list = list.filter((f) => mm.match(f));
@@ -2096,7 +2288,114 @@ const match = (list, pattern, options = {}) => {
2096
2288
  };
2097
2289
  minimatch.match = match;
2098
2290
  const globMagic = /[?*]|[+@!]\(.*?\)|\[|\]/;
2099
- const regExpEscape = (s) => s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
2291
+ const classEnd = (pattern, start) => {
2292
+ let i = start + 1;
2293
+ if (pattern.charAt(i) === "!" || pattern.charAt(i) === "^") i++;
2294
+ let sawStart = false;
2295
+ for (; i < pattern.length; i++) {
2296
+ const c = pattern.charAt(i);
2297
+ if (c === "]" && sawStart) return i;
2298
+ sawStart = true;
2299
+ if (c === "\\") i++;
2300
+ }
2301
+ return -1;
2302
+ };
2303
+ const literal = (pattern, noext) => {
2304
+ if (!noext && (pattern === "+()" || pattern === "@()")) return pattern;
2305
+ let lit = "";
2306
+ for (let i = 0; i < pattern.length; i++) {
2307
+ const c = pattern.charAt(i);
2308
+ if (c === "\\") lit += pattern.charAt(++i) || c;
2309
+ else if (c === "*" || c === "?") return;
2310
+ else if (c === "[") {
2311
+ const close = classEnd(pattern, i);
2312
+ if (close === -1) {
2313
+ lit += c;
2314
+ continue;
2315
+ }
2316
+ let body = pattern.slice(i + 1, close);
2317
+ if (body.startsWith("\\")) body = body.slice(1);
2318
+ if ([...body].length !== 1 || "!^".includes(pattern.charAt(i + 1))) return;
2319
+ lit += body;
2320
+ i = close;
2321
+ } else if (!noext && "+@!".includes(c) && pattern.charAt(i + 1) === "(" && pattern.includes(")", i + 2)) return;
2322
+ else lit += c;
2323
+ }
2324
+ return lit;
2325
+ };
2326
+ const MAX_EXTGLOBS = 256;
2327
+ const extglobCount = (pattern) => {
2328
+ let n = 0;
2329
+ for (let i = 0; i < pattern.length - 1; i++) {
2330
+ const c = pattern.charAt(i);
2331
+ if (c === "\\") i++;
2332
+ else if ("+@!?*".includes(c) && pattern.charAt(i + 1) === "(") {
2333
+ n++;
2334
+ i++;
2335
+ }
2336
+ }
2337
+ return n;
2338
+ };
2339
+ const assertValidExtglobs = (pattern) => {
2340
+ if (extglobCount(pattern) > MAX_EXTGLOBS) throw new TypeError("pattern has too many extglobs");
2341
+ };
2342
+ const extSafe = (pattern) => {
2343
+ if (/^[?*+@]\(\)$/.test(pattern) || pattern.includes("[:")) return false;
2344
+ let depth = 0;
2345
+ for (let i = 0; i < pattern.length; i++) {
2346
+ const c = pattern.charAt(i);
2347
+ if (c === "\\") {
2348
+ if (++i === pattern.length) return false;
2349
+ } else if (c === "[") {
2350
+ const close = classEnd(pattern, i);
2351
+ if (close !== -1) i = close;
2352
+ } else if ("+@!?*".includes(c) && pattern.charAt(i + 1) === "(") {
2353
+ depth++;
2354
+ i++;
2355
+ } else if (c === ")") {
2356
+ if (!depth--) return false;
2357
+ } else if (c === "|" && !depth) return false;
2358
+ }
2359
+ return !depth;
2360
+ };
2361
+ let lastSplit;
2362
+ let lastChecked;
2363
+ const portionMatch = (p, f) => typeof p === "string" ? f === p : f !== "" && p.testUnchecked(f);
2364
+ const endIndex = (p, last, lastStart, prev, prevStart) => portionMatch(p, last) ? lastStart : prev !== void 0 && portionMatch(p, prev) ? prevStart : -1;
2365
+ const isDots = (p) => p === "." || p === "..";
2366
+ const isDrive = (p) => typeof p === "string" && /^[a-z]:$/i.test(p);
2367
+ const isLongUNC = (p) => typeof p === "string" && /^unc$/i.test(p);
2368
+ const uncHost = (p) => {
2369
+ if (p[0] !== "" || p[1] !== "") return -1;
2370
+ const h = p[2] !== "?" ? 2 : isLongUNC(p[3]) ? 4 : -1;
2371
+ const host = p[h];
2372
+ const share = p[h + 1];
2373
+ return h !== -1 && host !== void 0 && host !== "" && host !== GLOBSTAR && share !== void 0 && share !== "" && share !== GLOBSTAR ? h : -1;
2374
+ };
2375
+ const walkable = (p, dot) => !isDots(p) && (dot || !p.startsWith("."));
2376
+ const dotPortion = (f, start, end, dot, sep) => {
2377
+ for (let k = start; k < end;) {
2378
+ if (f.charCodeAt(k) === 46) {
2379
+ if (!dot) return true;
2380
+ const n = f.charCodeAt(k + 1) === 46 ? k + 2 : k + 1;
2381
+ if (n >= end || isSep(f.charCodeAt(n), sep)) return true;
2382
+ }
2383
+ const s = nextSep(f, k, sep);
2384
+ if (s === -1) return false;
2385
+ k = s + 1;
2386
+ while (k < end && isSep(f.charCodeAt(k), sep)) k++;
2387
+ }
2388
+ return false;
2389
+ };
2390
+ const isSep = (c, sep) => sep === "/" ? c === 47 : sep === "\\" ? c === 92 : c === 47 || c === 92;
2391
+ const nextSep = (f, from, sep) => {
2392
+ if (sep !== "both") return f.indexOf(sep, from);
2393
+ const s = f.indexOf("/", from);
2394
+ const b = f.indexOf("\\", from);
2395
+ return s === -1 ? b : b === -1 ? s : Math.min(s, b);
2396
+ };
2397
+ const lastSep = (f, from, sep) => sep !== "both" ? f.lastIndexOf(sep, from) : Math.max(f.lastIndexOf("/", from), f.lastIndexOf("\\", from));
2398
+ const PENDING = {};
2100
2399
  var Minimatch = class {
2101
2400
  options;
2102
2401
  set;
@@ -2115,20 +2414,28 @@ var Minimatch = class {
2115
2414
  platform;
2116
2415
  windowsNoMagicRoot;
2117
2416
  maxGlobstarRecursion;
2118
- regexp;
2417
+ #endCheck;
2418
+ #literalCheck;
2419
+ #level2;
2420
+ #form;
2421
+ #literals = [];
2422
+ #shapes = [];
2423
+ #endRows = [];
2424
+ #matchers = /* @__PURE__ */ new Map();
2425
+ #pending = false;
2426
+ #rangeMark;
2427
+ #globstarParts = /* @__PURE__ */ new WeakMap();
2119
2428
  constructor(pattern, options = {}) {
2120
2429
  assertValidPattern(pattern);
2121
2430
  options = options || {};
2122
2431
  this.options = options;
2123
- this.maxGlobstarRecursion = options.maxGlobstarRecursion ?? 200;
2432
+ this.maxGlobstarRecursion = options.maxGlobstarRecursion ?? DEFAULT_GLOB_STAR_RECURSION_MAX;
2124
2433
  this.pattern = pattern;
2125
2434
  this.platform = options.platform || defaultPlatform;
2126
2435
  this.isWindows = this.platform === "win32";
2127
- const awe = "allowWindowsEscape";
2128
- this.windowsPathsNoEscape = !!options.windowsPathsNoEscape || options[awe] === false;
2436
+ this.windowsPathsNoEscape = !!options.windowsPathsNoEscape || options[AWE_KEY] === false;
2129
2437
  if (this.windowsPathsNoEscape) this.pattern = this.pattern.replace(/\\/g, "/");
2130
2438
  this.preserveMultipleSlashes = !!options.preserveMultipleSlashes;
2131
- this.regexp = null;
2132
2439
  this.negate = false;
2133
2440
  this.nonegate = !!options.nonegate;
2134
2441
  this.comment = false;
@@ -2139,14 +2446,45 @@ var Minimatch = class {
2139
2446
  this.globSet = [];
2140
2447
  this.globParts = [];
2141
2448
  this.set = [];
2449
+ this.#endCheck = !this.preserveMultipleSlashes;
2450
+ this.#level2 = (options.optimizationLevel ?? 1) >= 2;
2451
+ const n = options.normalize;
2452
+ this.#form = n === true ? "NFC" : n || void 0;
2142
2453
  this.make();
2454
+ const drives = this.set.map((row) => this.#rootIndex(row));
2455
+ this.#endRows = this.set.map((row, r) => this.#endCheck && row.length - 1 > drives[r]);
2456
+ this.#literals = this.set.map((row, r) => {
2457
+ const end = this.#endRows[r] ? row.length - 1 : row.length;
2458
+ const lits = row.slice(drives[r] + 1, end).filter((p) => typeof p === "string" && !!p);
2459
+ return [...new Set(lits)];
2460
+ });
2461
+ this.#literalCheck = this.#literals.some((l) => l.length);
2462
+ this.#shapes = this.set.map((row, r) => {
2463
+ const [p0, p1, p2] = row;
2464
+ if (this.#endRows[r] && row.length === 2) {
2465
+ if (p0 === GLOBSTAR && p1 !== GLOBSTAR) return "tail";
2466
+ }
2467
+ if (this.#endRows[r] && options.matchBase && row.length === 1 && p0 !== GLOBSTAR && p0 !== "") return "base";
2468
+ if (!this.#endCheck || drives[r] !== -1) return void 0;
2469
+ if (row.length === 3 && p0 === GLOBSTAR && p2 === GLOBSTAR && p1 !== GLOBSTAR && p1 !== "" && this.maxGlobstarRecursion > 0) return "mid";
2470
+ if (row.length === 2 && p1 === GLOBSTAR && p0 !== GLOBSTAR && p0 !== "") return "head";
2471
+ });
2472
+ }
2473
+ #norm(p) {
2474
+ return this.#form ? p.normalize(this.#form) : p;
2475
+ }
2476
+ #rootIndex(row) {
2477
+ if (!this.isWindows) return -1;
2478
+ if (isDrive(row[0])) return 0;
2479
+ if (row[0] === "" && row[1] === "" && row[2] === "?" && isDrive(row[3])) return 3;
2480
+ const h = uncHost(row);
2481
+ return h === -1 ? -1 : h + 1;
2143
2482
  }
2144
2483
  hasMagic() {
2145
2484
  if (this.options.magicalBraces && this.set.length > 1) return true;
2146
2485
  for (const pattern of this.set) for (const part of pattern) if (typeof part !== "string") return true;
2147
2486
  return false;
2148
2487
  }
2149
- debug(..._) {}
2150
2488
  make() {
2151
2489
  const pattern = this.pattern;
2152
2490
  const options = this.options;
@@ -2159,28 +2497,108 @@ var Minimatch = class {
2159
2497
  return;
2160
2498
  }
2161
2499
  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));
2500
+ this.globSet = [...new Set(this.#expandBraces())];
2501
+ const rawGlobParts = this.globSet.map((s) => this.#slashSplit(s));
2166
2502
  this.globParts = this.preprocess(rawGlobParts);
2167
- this.debug(this.pattern, this.globParts);
2503
+ this.#pending = true;
2168
2504
  let set = this.globParts.map((s, _, __) => {
2169
2505
  if (this.isWindows && this.windowsNoMagicRoot) {
2170
- const isUNC = s[0] === "" && s[1] === "" && (s[2] === "?" || !globMagic.test(s[2])) && !globMagic.test(s[3]);
2506
+ const n = s[2] === "?" && isLongUNC(s[3]) ? 6 : 4;
2507
+ const isUNC = s[0] === "" && s[1] === "" && (s[2] === "?" || !globMagic.test(s[2])) && s.slice(3, n).every((p) => !globMagic.test(p));
2171
2508
  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))];
2509
+ if (isUNC) return [...s.slice(0, n).map((p) => this.#norm(p)), ...s.slice(n).map((ss) => this.parse(ss))];
2510
+ else if (isDrive) return [this.#norm(s[0]), ...s.slice(1).map((ss) => this.parse(ss))];
2174
2511
  }
2175
2512
  return s.map((ss) => this.parse(ss));
2176
2513
  });
2177
- this.debug(this.pattern, set);
2178
2514
  this.set = set.filter((s) => s.indexOf(false) === -1);
2179
2515
  if (this.isWindows) for (let i = 0; i < this.set.length; i++) {
2180
2516
  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] = "?";
2517
+ if (p[0] === "" && p[1] === "" && this.globParts[i][2] === "?" && (isDrive(p[3]) || isLongUNC(this.globParts[i][3]))) {
2518
+ if (isLongUNC(this.globParts[i][3])) p[3] = "UNC";
2519
+ p[2] = "?";
2520
+ }
2182
2521
  }
2183
- this.debug(this.pattern, this.set);
2522
+ if (!options.noext) this.mergeRows();
2523
+ this.#pending = false;
2524
+ this.set.forEach((row, i) => {
2525
+ for (let k = 0; k < row.length; k++) if (row[k] === PENDING) row[k] = this.parse(this.globParts[i][k]);
2526
+ });
2527
+ }
2528
+ mergeRows() {
2529
+ let merged = true;
2530
+ while (merged) {
2531
+ merged = false;
2532
+ if (this.set.length < 2) return;
2533
+ let keys = this.#mergeKeys();
2534
+ const len = Math.max(0, ...this.set.map((r) => r.length));
2535
+ for (let k = 0; k < len; k++) {
2536
+ const groups = /* @__PURE__ */ new Map();
2537
+ const R = this.set.length + 1;
2538
+ this.set.forEach((row, i) => {
2539
+ if (!(row[k] instanceof Matcher || row[k] === PENDING) || !extSafe(this.globParts[i][k])) return;
2540
+ const { pre, suf } = keys[i];
2541
+ const key = pre[k] * R + suf[k + 1];
2542
+ const g = groups.get(key);
2543
+ if (g) g.push(i);
2544
+ else groups.set(key, [i]);
2545
+ });
2546
+ const drop = /* @__PURE__ */ new Set();
2547
+ for (const g of groups.values()) {
2548
+ if (g.length < 2) continue;
2549
+ const [first, ...rest] = g;
2550
+ const glob = `@(${g.map((i) => this.globParts[i][k]).join("|")})`;
2551
+ if (extglobCount(glob) > MAX_EXTGLOBS) continue;
2552
+ this.globParts[first][k] = glob;
2553
+ this.set[first][k] = this.parse(glob);
2554
+ for (const i of rest) drop.add(i);
2555
+ }
2556
+ if (drop.size) {
2557
+ merged = true;
2558
+ this.set = this.set.filter((_, i) => !drop.has(i));
2559
+ this.globParts = this.globParts.filter((_, i) => !drop.has(i));
2560
+ if (this.set.length < 2) return;
2561
+ keys = this.#mergeKeys();
2562
+ }
2563
+ }
2564
+ }
2565
+ }
2566
+ #mergeKeys() {
2567
+ const partIds = /* @__PURE__ */ new Map();
2568
+ const ids = this.globParts.map((parts) => parts.map((s) => {
2569
+ let id = partIds.get(s);
2570
+ if (id === void 0) partIds.set(s, id = partIds.size);
2571
+ return id;
2572
+ }));
2573
+ const P = partIds.size;
2574
+ const len = Math.max(0, ...ids.map((r) => r.length));
2575
+ const keys = ids.map((r) => ({
2576
+ pre: [0],
2577
+ suf: new Array(r.length + 1).fill(0)
2578
+ }));
2579
+ for (let k = 0; k < len; k++) {
2580
+ const m = /* @__PURE__ */ new Map();
2581
+ ids.forEach((r, i) => {
2582
+ if (k >= r.length) return;
2583
+ const { pre } = keys[i];
2584
+ const key = pre[k] * P + r[k];
2585
+ let id = m.get(key);
2586
+ if (id === void 0) m.set(key, id = m.size + 1);
2587
+ pre.push(id);
2588
+ });
2589
+ }
2590
+ for (let k = len - 1; k >= 0; k--) {
2591
+ const m = /* @__PURE__ */ new Map();
2592
+ ids.forEach((r, i) => {
2593
+ if (k >= r.length) return;
2594
+ const { suf } = keys[i];
2595
+ const key = suf[k + 1] * P + r[k];
2596
+ let id = m.get(key);
2597
+ if (id === void 0) m.set(key, id = m.size + 1);
2598
+ suf[k] = id;
2599
+ });
2600
+ }
2601
+ return keys;
2184
2602
  }
2185
2603
  preprocess(globParts) {
2186
2604
  if (this.options.noglobstar) {
@@ -2207,11 +2625,12 @@ var Minimatch = class {
2207
2625
  }
2208
2626
  levelOneOptimize(globParts) {
2209
2627
  return globParts.map((parts) => {
2628
+ const root = this.#rootIndex(parts) + 1;
2210
2629
  parts = parts.reduce((set, part) => {
2211
2630
  const prev = set[set.length - 1];
2212
2631
  if (part === "**" && prev === "**") return set;
2213
2632
  if (part === "..") {
2214
- if (prev && prev !== ".." && prev !== "." && prev !== "**") {
2633
+ if (set.length > root && prev && prev !== ".." && prev !== "." && prev !== "**") {
2215
2634
  set.pop();
2216
2635
  return set;
2217
2636
  }
@@ -2222,8 +2641,120 @@ var Minimatch = class {
2222
2641
  return parts.length === 0 ? [""] : parts;
2223
2642
  });
2224
2643
  }
2225
- levelTwoFileOptimize(parts) {
2226
- if (!Array.isArray(parts)) parts = this.slashSplit(parts);
2644
+ #canMatch(f) {
2645
+ const sep = !this.isWindows || !f.includes("\\") ? "/" : f.includes("/") ? "both" : "\\";
2646
+ let ends = this.#endCheck ? 0 : -1;
2647
+ let last = "";
2648
+ let lastStart = 0;
2649
+ let prev;
2650
+ let prevStart = 0;
2651
+ const dot = !!this.options.dot;
2652
+ ROWS: for (let r = 0; r < this.set.length; r++) {
2653
+ const row = this.set[r];
2654
+ const p = row[row.length - 1];
2655
+ let end = ends !== -1 && this.#endRows[r] && p !== GLOBSTAR;
2656
+ if (end && ends === 0) {
2657
+ const i = lastSep(f, f.length, sep);
2658
+ lastStart = i + 1;
2659
+ last = f.slice(lastStart);
2660
+ if (last === "" && i >= 0) {
2661
+ let j = i;
2662
+ while (j > 0 && isSep(f.charCodeAt(j - 1), sep)) j--;
2663
+ prevStart = j === 0 ? 0 : lastSep(f, j - 1, sep) + 1;
2664
+ prev = f.slice(prevStart, j);
2665
+ }
2666
+ const resolves = this.#level2 && (isDots(last) || last === "" && prev !== void 0 && isDots(prev));
2667
+ ends = resolves ? -1 : 1;
2668
+ end = !resolves;
2669
+ }
2670
+ let tailStart = -1;
2671
+ if (end && typeof p === "string") {
2672
+ tailStart = endIndex(p, last, lastStart, prev, prevStart);
2673
+ if (tailStart === -1) continue;
2674
+ }
2675
+ if (this.#literalCheck) {
2676
+ for (const l of this.#literals[r]) if (!f.includes(l)) continue ROWS;
2677
+ }
2678
+ if (end && typeof p === "object") {
2679
+ tailStart = endIndex(p, last, lastStart, prev, prevStart);
2680
+ if (tailStart === -1) continue;
2681
+ }
2682
+ const shape = this.#shapes[r];
2683
+ if (shape === "base" && end) return "yes";
2684
+ if (shape === "tail" && end) {
2685
+ if (this.#level2 && dotPortion(f, 0, tailStart, true, sep)) return "maybe";
2686
+ if (!dotPortion(f, 0, tailStart, dot, sep)) return "yes";
2687
+ continue;
2688
+ }
2689
+ if (shape === "mid" || shape === "head") {
2690
+ const m = this.#walk(f, row, shape === "head", dot, sep);
2691
+ if (m !== "no") return m;
2692
+ continue;
2693
+ }
2694
+ return "maybe";
2695
+ }
2696
+ return "no";
2697
+ }
2698
+ #matchShape(file, row, shape) {
2699
+ const dot = !!this.options.dot;
2700
+ const n = file.length;
2701
+ if (shape === "head") {
2702
+ if (n < 2 || !portionMatch(row[0], file[0])) return false;
2703
+ for (let i = 1; i < n; i++) if (!walkable(file[i], dot)) return false;
2704
+ return true;
2705
+ }
2706
+ const x = row[1];
2707
+ if (shape === "tail") {
2708
+ let t = n - 1;
2709
+ if (!portionMatch(x, file[t])) {
2710
+ if (file[t] !== "" || n === 1 || !portionMatch(x, file[--t])) return false;
2711
+ }
2712
+ for (let i = 0; i < t; i++) if (!walkable(file[i], dot)) return false;
2713
+ return true;
2714
+ }
2715
+ for (let k = 0; k < n; k++) {
2716
+ if (portionMatch(x, file[k]) && k + 1 < n) {
2717
+ let i = k + 1;
2718
+ while (i < n && walkable(file[i], dot)) i++;
2719
+ if (i === n) return true;
2720
+ }
2721
+ if (!walkable(file[k], dot)) return false;
2722
+ }
2723
+ return false;
2724
+ }
2725
+ #walk(f, row, head, dot, sep) {
2726
+ if (this.#level2 && dotPortion(f, 0, f.length, true, sep)) return "maybe";
2727
+ const x = row[head ? 0 : 1];
2728
+ let s = 0;
2729
+ for (let e = nextSep(f, s, sep); e !== -1; e = nextSep(f, s, sep)) {
2730
+ let next = e + 1;
2731
+ while (next < f.length && isSep(f.charCodeAt(next), sep)) next++;
2732
+ 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";
2733
+ if (head || dotPortion(f, s, next, dot, sep)) return "no";
2734
+ s = next;
2735
+ }
2736
+ return "no";
2737
+ }
2738
+ #cachedSplit(f) {
2739
+ const last = lastSplit;
2740
+ return last?.f === f && last.isWindows === this.isWindows && last.preserveMultipleSlashes === this.preserveMultipleSlashes && last.normalize === this.#form ? last : void 0;
2741
+ }
2742
+ #split(f) {
2743
+ const { isWindows, preserveMultipleSlashes } = this;
2744
+ let parts = this.#slashSplit(isWindows ? f.split("\\").join("/") : f);
2745
+ const normalize = this.#form;
2746
+ if (normalize) parts = parts.map((p) => p.normalize(normalize));
2747
+ lastSplit = {
2748
+ f,
2749
+ isWindows,
2750
+ preserveMultipleSlashes,
2751
+ normalize,
2752
+ parts
2753
+ };
2754
+ return lastSplit;
2755
+ }
2756
+ #levelTwoFileOptimize(file) {
2757
+ const parts = [...file];
2227
2758
  let didSomething = false;
2228
2759
  do {
2229
2760
  didSomething = false;
@@ -2242,19 +2773,23 @@ var Minimatch = class {
2242
2773
  parts.pop();
2243
2774
  }
2244
2775
  }
2245
- let dd = 0;
2776
+ const root = this.#rootIndex(parts) + 1;
2777
+ let dd = root;
2246
2778
  while (-1 !== (dd = parts.indexOf("..", dd + 1))) {
2247
2779
  const p = parts[dd - 1];
2248
- if (p && p !== "." && p !== ".." && p !== "**" && !(this.isWindows && /^[a-z]:$/i.test(p))) {
2780
+ if (p && p !== "." && p !== ".." && p !== "**") {
2249
2781
  didSomething = true;
2250
2782
  parts.splice(dd - 1, 2);
2251
- dd -= 2;
2783
+ dd = Math.max(dd - 2, root);
2252
2784
  }
2253
2785
  }
2254
2786
  } while (didSomething);
2255
2787
  return parts.length === 0 ? [""] : parts;
2256
2788
  }
2257
2789
  firstPhasePreProcess(globParts) {
2790
+ const { braceExpandMax = DEFAULT_BRACE_EXPAND_MAX } = this.options;
2791
+ let splitCells = 0;
2792
+ const maxSplitCells = 1e6;
2258
2793
  let didSomething = false;
2259
2794
  do {
2260
2795
  didSomething = false;
@@ -2269,10 +2804,13 @@ var Minimatch = class {
2269
2804
  const p2 = parts[gs + 3];
2270
2805
  if (next !== "..") continue;
2271
2806
  if (!p || p === "." || p === ".." || !p2 || p2 === "." || p2 === "..") continue;
2807
+ const addedCells = parts.length - 1;
2808
+ if (globParts.length >= braceExpandMax || splitCells + addedCells > maxSplitCells) throw new RangeError(`optimizationLevel 2: too many patterns from '**/..'`);
2272
2809
  didSomething = true;
2273
2810
  parts.splice(gs, 1);
2274
2811
  const other = parts.slice(0);
2275
2812
  other[gs] = "**";
2813
+ splitCells += addedCells;
2276
2814
  globParts.push(other);
2277
2815
  gs--;
2278
2816
  }
@@ -2291,7 +2829,8 @@ var Minimatch = class {
2291
2829
  parts.pop();
2292
2830
  }
2293
2831
  }
2294
- let dd = 0;
2832
+ const root = this.#rootIndex(parts) + 1;
2833
+ let dd = root;
2295
2834
  while (-1 !== (dd = parts.indexOf("..", dd + 1))) {
2296
2835
  const p = parts[dd - 1];
2297
2836
  if (p && p !== "." && p !== ".." && p !== "**") {
@@ -2299,7 +2838,7 @@ var Minimatch = class {
2299
2838
  const splin = dd === 1 && parts[dd + 1] === "**" ? ["."] : [];
2300
2839
  parts.splice(dd - 1, 2, ...splin);
2301
2840
  if (parts.length === 0) parts.push("");
2302
- dd -= 2;
2841
+ dd = Math.max(dd - 2, root);
2303
2842
  }
2304
2843
  }
2305
2844
  }
@@ -2307,45 +2846,41 @@ var Minimatch = class {
2307
2846
  return globParts;
2308
2847
  }
2309
2848
  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;
2849
+ const keys = /* @__PURE__ */ new Set();
2850
+ const rows = globParts.filter((parts) => {
2851
+ const key = parts.join("/");
2852
+ if (keys.has(key)) return false;
2853
+ keys.add(key);
2854
+ return true;
2855
+ });
2856
+ const stars = /* @__PURE__ */ new Map();
2857
+ for (const parts of rows) {
2858
+ const s = [];
2859
+ for (let i = 0; i < parts.length; i++) if (parts[i] === "*") s.push(i);
2860
+ if (s.length) stars.set(s.join(","), s);
2861
+ }
2862
+ if (!stars.size || rows.length * stars.size > 1e5) return rows;
2863
+ const { dot } = this.options;
2864
+ return rows.filter((parts) => {
2865
+ for (const s of stars.values()) {
2866
+ if (s[s.length - 1] >= parts.length) continue;
2867
+ const c = [...parts];
2868
+ let ok = true;
2869
+ let changed = false;
2870
+ for (const i of s) {
2871
+ const p = parts[i];
2872
+ if (p === "*") continue;
2873
+ if (!p || p === "**" || !dot && p.startsWith(".")) {
2874
+ ok = false;
2875
+ break;
2876
+ }
2877
+ c[i] = "*";
2878
+ changed = true;
2879
+ }
2880
+ if (ok && changed && keys.has(c.join("/"))) return false;
2316
2881
  }
2317
- }
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;
2882
+ return true;
2883
+ });
2349
2884
  }
2350
2885
  parseNegate() {
2351
2886
  if (this.nonegate) return;
@@ -2359,10 +2894,22 @@ var Minimatch = class {
2359
2894
  if (negateOffset) this.pattern = pattern.slice(negateOffset);
2360
2895
  this.negate = negate;
2361
2896
  }
2362
- matchOne(file, pattern, partial = false) {
2897
+ #matchRow(file, resolved, pattern, partial) {
2363
2898
  let fileStartIndex = 0;
2364
2899
  let patternStartIndex = 0;
2365
- if (this.isWindows) {
2900
+ const fh = this.isWindows ? uncHost(resolved) : -1;
2901
+ const ph = fh === -1 ? -1 : uncHost(pattern);
2902
+ if (ph !== -1) {
2903
+ const host = pattern[ph];
2904
+ const share = pattern[ph + 1];
2905
+ if (typeof host !== "string" || typeof share !== "string") {
2906
+ fileStartIndex = fh;
2907
+ patternStartIndex = ph;
2908
+ } else if (resolved[fh].toLowerCase() === host.toLowerCase() && resolved[fh + 1].toLowerCase() === share.toLowerCase()) {
2909
+ fileStartIndex = fh + 2;
2910
+ patternStartIndex = ph + 2;
2911
+ }
2912
+ } else if (this.isWindows) {
2366
2913
  const fileDrive = typeof file[0] === "string" && /^[a-z]:$/i.test(file[0]);
2367
2914
  const fileUNC = !fileDrive && file[0] === "" && file[1] === "" && file[2] === "?" && /^[a-z]:$/i.test(file[3]);
2368
2915
  const patternDrive = typeof pattern[0] === "string" && /^[a-z]:$/i.test(pattern[0]);
@@ -2372,32 +2919,20 @@ var Minimatch = class {
2372
2919
  if (typeof fdi === "number" && typeof pdi === "number") {
2373
2920
  const [fd, pd] = [file[fdi], pattern[pdi]];
2374
2921
  if (fd.toLowerCase() === pd.toLowerCase()) {
2375
- pattern[pdi] = fd;
2376
- patternStartIndex = pdi;
2377
- fileStartIndex = fdi;
2922
+ patternStartIndex = pdi + 1;
2923
+ fileStartIndex = fdi + 1;
2378
2924
  }
2379
2925
  }
2380
2926
  }
2381
- const { optimizationLevel = 1 } = this.options;
2382
- if (optimizationLevel >= 2) file = this.levelTwoFileOptimize(file);
2927
+ file = resolved;
2383
2928
  if (pattern.includes(GLOBSTAR)) return this.#matchGlobstar(file, pattern, partial, fileStartIndex, patternStartIndex);
2384
2929
  return this.#matchOne(file, pattern, partial, fileStartIndex, patternStartIndex);
2385
2930
  }
2386
2931
  #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
- ];
2932
+ const { head, body, tail, segments } = this.#getGlobstarParts(pattern, partial, patternIndex);
2398
2933
  if (head.length) {
2399
- const fileHead = file.slice(fileIndex, fileIndex + head.length);
2400
- if (!this.#matchOne(fileHead, head, partial, 0, 0)) return false;
2934
+ const headEnd = fileIndex + head.length;
2935
+ if (!this.#matchOne(file, head, partial, fileIndex, 0, headEnd)) return false;
2401
2936
  fileIndex += head.length;
2402
2937
  patternIndex += head.length;
2403
2938
  }
@@ -2422,67 +2957,86 @@ var Minimatch = class {
2422
2957
  }
2423
2958
  return partial || sawSome;
2424
2959
  }
2425
- const bodySegments = [[[], 0]];
2426
- let currentBody = bodySegments[0];
2960
+ return !!this.#matchGlobStarBodySections(file, segments, file.length - fileTailMatch, fileIndex, 0, partial, 0, !!fileTailMatch, /* @__PURE__ */ new Set());
2961
+ }
2962
+ #getGlobstarParts(pattern, partial, patternIndex) {
2963
+ let byStart = this.#globstarParts.get(pattern);
2964
+ if (!byStart) {
2965
+ byStart = [];
2966
+ this.#globstarParts.set(pattern, byStart);
2967
+ }
2968
+ const key = patternIndex * 2 + (partial ? 1 : 0);
2969
+ const found = byStart[key];
2970
+ if (found) return found;
2971
+ const firstgs = pattern.indexOf(GLOBSTAR, patternIndex);
2972
+ const lastgs = pattern.lastIndexOf(GLOBSTAR);
2973
+ const head = pattern.slice(patternIndex, firstgs);
2974
+ const body = pattern.slice(firstgs + 1, partial ? void 0 : lastgs);
2975
+ const tail = partial ? [] : pattern.slice(lastgs + 1);
2976
+ const segments = [[[], 0]];
2977
+ let current = segments[0];
2427
2978
  let nonGsParts = 0;
2428
2979
  const nonGsPartsSums = [0];
2429
2980
  for (const b of body) if (b === GLOBSTAR) {
2430
2981
  nonGsPartsSums.push(nonGsParts);
2431
- currentBody = [[], 0];
2432
- bodySegments.push(currentBody);
2982
+ current = [[], 0];
2983
+ segments.push(current);
2433
2984
  } else {
2434
- currentBody[0].push(b);
2985
+ current[0].push(b);
2435
2986
  nonGsParts++;
2436
2987
  }
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);
2988
+ segments.forEach((b, i) => {
2989
+ b[1] = nonGsParts - nonGsPartsSums[i];
2990
+ });
2991
+ const parts = {
2992
+ head,
2993
+ body,
2994
+ tail,
2995
+ segments
2996
+ };
2997
+ byStart[key] = parts;
2998
+ return parts;
2441
2999
  }
2442
- #matchGlobStarBodySections(file, bodySegments, fileIndex, bodyIndex, partial, globStarDepth, sawTail) {
3000
+ #matchGlobStarBodySections(file, bodySegments, fileLength, fileIndex, bodyIndex, partial, globStarDepth, sawTail, tried) {
2443
3001
  const bs = bodySegments[bodyIndex];
2444
3002
  if (!bs) {
2445
- for (let i = fileIndex; i < file.length; i++) {
3003
+ if (partial) return fileIndex >= fileLength || fileIndex === fileLength - 1 && file[fileIndex] === "";
3004
+ for (let i = fileIndex; i < fileLength; i++) {
2446
3005
  sawTail = true;
2447
3006
  const f = file[i];
2448
3007
  if (f === "." || f === ".." || !this.options.dot && f.startsWith(".")) return false;
2449
3008
  }
2450
3009
  return sawTail;
2451
3010
  }
2452
- const [body, after] = bs;
3011
+ const [body, need] = bs;
3012
+ const after = partial ? fileLength : fileLength - need;
2453
3013
  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);
3014
+ const key = bodyIndex * (file.length + 1) + fileIndex;
3015
+ if (tried.has(key)) return false;
3016
+ tried.add(key);
3017
+ if (this.#matchOne(file, body, partial, fileIndex, 0, fileIndex + body.length) && globStarDepth < this.maxGlobstarRecursion) {
3018
+ const sub = this.#matchGlobStarBodySections(file, bodySegments, fileLength, fileIndex + body.length, bodyIndex + 1, partial, globStarDepth + 1, sawTail, tried);
2456
3019
  if (sub !== false) return sub;
2457
3020
  }
3021
+ if (fileIndex === after) break;
2458
3022
  const f = file[fileIndex];
2459
3023
  if (f === "." || f === ".." || !this.options.dot && f.startsWith(".")) return false;
2460
3024
  fileIndex++;
2461
3025
  }
2462
3026
  return partial || null;
2463
3027
  }
2464
- #matchOne(file, pattern, partial, fileIndex, patternIndex) {
3028
+ #matchOne(file, pattern, partial, fileIndex, patternIndex, fileEnd = file.length) {
2465
3029
  let fi;
2466
3030
  let pi;
2467
3031
  let pl;
2468
3032
  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");
3033
+ for (fi = fileIndex, pi = patternIndex, fl = Math.min(fileEnd, file.length), pl = pattern.length; fi < fl && pi < pl; fi++, pi++) {
2471
3034
  let p = pattern[pi];
2472
3035
  let f = file[fi];
2473
- this.debug(pattern, p, f);
2474
3036
  /* c8 ignore start */
2475
3037
  if (p === false || p === GLOBSTAR) return false;
2476
3038
  /* 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;
3039
+ if (!portionMatch(p, f)) return false;
2486
3040
  }
2487
3041
  if (fi === fl && pi === pl) return true;
2488
3042
  else if (fi === fl) return partial;
@@ -2493,92 +3047,83 @@ var Minimatch = class {
2493
3047
  braceExpand() {
2494
3048
  return braceExpand(this.pattern, this.options);
2495
3049
  }
3050
+ #expandBraces() {
3051
+ const { pattern } = this;
3052
+ if (this.options.nobrace) return this.braceExpand();
3053
+ let code = 57344;
3054
+ while (pattern.includes(String.fromCharCode(code))) if (++code > 63743) return this.braceExpand();
3055
+ const mark = String.fromCharCode(code);
3056
+ let found = false;
3057
+ const marked = pattern.replace(rangeRe, (m, lo, hi) => {
3058
+ const a = Number(lo);
3059
+ const b = Number(hi);
3060
+ if (!Number.isSafeInteger(a) || !Number.isSafeInteger(b) || Math.abs(a - b) + 1 < RANGE_MIN) return m;
3061
+ found = true;
3062
+ return `${mark}${lo}..${hi}${mark}`;
3063
+ });
3064
+ if (!found) return this.braceExpand();
3065
+ const set = braceExpand(marked, this.options);
3066
+ for (const p of set) for (const portion of p.split("/")) {
3067
+ const c = portion.indexOf("[");
3068
+ if (c !== -1 && c < portion.lastIndexOf(mark)) return this.braceExpand();
3069
+ if (!this.options.noext && inRepeatOrNegExt(portion, mark)) return this.braceExpand();
3070
+ }
3071
+ this.#rangeMark = mark;
3072
+ return set;
3073
+ }
2496
3074
  parse(pattern) {
2497
3075
  assertValidPattern(pattern);
2498
3076
  const options = this.options;
2499
3077
  if (pattern === "**") return GLOBSTAR;
2500
3078
  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
- }
3079
+ const { nocase, nocaseMagicOnly, noext = false, dot, normalize } = options;
3080
+ const rangeMark = this.#rangeMark;
3081
+ const lit = rangeMark && pattern.includes(rangeMark) ? void 0 : literal(pattern, noext);
3082
+ if (lit !== void 0 && !(nocase && !nocaseMagicOnly && pattern.toUpperCase() !== pattern.toLowerCase())) return this.#norm(lit);
3083
+ if (this.#pending) return PENDING;
3084
+ let m = this.#matchers.get(pattern);
3085
+ if (!m) {
3086
+ if (!noext) assertValidExtglobs(pattern);
3087
+ m = new Matcher(pattern, {
3088
+ nocase,
3089
+ noext,
3090
+ dot,
3091
+ normalize,
3092
+ ...rangeMark && { rangeMark }
2539
3093
  });
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;
3094
+ this.#matchers.set(pattern, m);
2556
3095
  }
2557
- /* c8 ignore stop */
2558
- return this.regexp;
3096
+ return m;
2559
3097
  }
2560
- slashSplit(p) {
3098
+ #slashSplit(p) {
2561
3099
  if (this.preserveMultipleSlashes) return p.split("/");
2562
3100
  else if (this.isWindows && /^\/\/[^/]+/.test(p)) return ["", ...p.split(/\/+/)];
2563
3101
  else return p.split(/\/+/);
2564
3102
  }
2565
3103
  match(f, partial = this.partial) {
2566
- this.debug("match", f, this.pattern);
2567
3104
  if (this.comment) return false;
2568
3105
  if (this.empty) return f === "";
2569
3106
  if (f === "/" && partial) return true;
2570
3107
  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);
3108
+ let split = this.#cachedSplit(f);
3109
+ if (!split) {
3110
+ if (!partial && !this.#form && (this.#endCheck || this.#literalCheck) && lastChecked !== f) {
3111
+ lastChecked = f;
3112
+ const can = this.#canMatch(f);
3113
+ if (can === "no") return options.flipNegate ? false : this.negate;
3114
+ if (can === "yes") return options.flipNegate ? true : !this.negate;
3115
+ }
3116
+ split = this.#split(f);
3117
+ }
3118
+ const ff = split.parts;
3119
+ const resolved = this.#level2 ? split.resolved ??= this.#levelTwoFileOptimize(ff) : ff;
2574
3120
  const set = this.set;
2575
- this.debug(this.pattern, "set", set);
2576
3121
  let filename = ff[ff.length - 1];
2577
3122
  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)) {
3123
+ for (let r = 0; r < set.length; r++) {
3124
+ const pattern = set[r];
3125
+ const shape = partial ? void 0 : this.#shapes[r];
3126
+ 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
3127
  if (options.flipNegate) return true;
2583
3128
  return !this.negate;
2584
3129
  }
@@ -2591,12 +3136,10 @@ var Minimatch = class {
2591
3136
  }
2592
3137
  };
2593
3138
  /* c8 ignore stop */
2594
- minimatch.AST = AST;
2595
3139
  minimatch.Minimatch = Minimatch;
2596
3140
  minimatch.escape = escape;
2597
3141
  minimatch.unescape = unescape;
2598
- //#endregion
2599
- //#region ../internal/src/build/runtime-package-files.ts
3142
+ // ../internal/src/build/runtime-package-files.ts
2600
3143
  const alwaysPublishedFile = /^(?:package\.json|(?:readme|copying|licen[cs]e)(?:\..*[^~$])?)$/i;
2601
3144
  const rootExcluded = /* @__PURE__ */ new Set([
2602
3145
  "package-lock.json",
@@ -2780,8 +3323,7 @@ async function copyRuntimePackageFiles(packageDir, targetDir) {
2780
3323
  await unlessGone(() => copyFile(join(packageDir, path), target));
2781
3324
  }
2782
3325
  }
2783
- //#endregion
2784
- //#region ../internal/src/build/scan-module.ts
3326
+ // ../internal/src/build/scan-module.ts
2785
3327
  /**
2786
3328
  * Reads facts from JavaScript and TypeScript modules at build and dev time. The scanner parses each module once with
2787
3329
  * the oxc parser that Vite ships through Rolldown, and never runs it. Values that are not static literals read as
@@ -2993,8 +3535,7 @@ function maskLiterals(module) {
2993
3535
  for (const span of literalSpans(module)) for (let index = span.start; index < span.end; index++) if (!isLineTerminator(output[index] ?? "")) output[index] = " ";
2994
3536
  return output.join("");
2995
3537
  }
2996
- //#endregion
2997
- //#region ../internal/src/build/provider-output-sources.ts
3538
+ // ../internal/src/build/provider-output-sources.ts
2998
3539
  function escapeRegExp(value) {
2999
3540
  return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
3000
3541
  }
@@ -4076,8 +4617,7 @@ async function retainProviderOutputSources(options) {
4076
4617
  return root ? resolve(retainedRoots.get(root), relative(root, resolvedPath)) : path;
4077
4618
  } };
4078
4619
  }
4079
- //#endregion
4080
- //#region ../internal/src/build/vercel-config.ts
4620
+ // ../internal/src/build/vercel-config.ts
4081
4621
  function createDefaultVercelOutputRoot(rootDir) {
4082
4622
  return resolve(rootDir, ".vercel", "output");
4083
4623
  }
@@ -4100,8 +4640,7 @@ function createNodeFunctionConfig(extra = {}) {
4100
4640
  ...extra
4101
4641
  };
4102
4642
  }
4103
- //#endregion
4104
- //#region ../internal/src/build/runtime-package-resolution.ts
4643
+ // ../internal/src/build/runtime-package-resolution.ts
4105
4644
  /** Locates package metadata through exports, an entry's ancestors, or the project's dependency roots. */
4106
4645
  function createRuntimePackageResolver(readPackageName) {
4107
4646
  return async (name, resolver, fromDir) => {
@@ -4142,8 +4681,7 @@ function isPackageResolutionMiss(error) {
4142
4681
  const code = error?.code;
4143
4682
  return code === "MODULE_NOT_FOUND" || code === "ERR_MODULE_NOT_FOUND" || code === "ERR_PACKAGE_PATH_NOT_EXPORTED";
4144
4683
  }
4145
- //#endregion
4146
- //#region ../internal/src/build/runtime-package-directory.ts
4684
+ // ../internal/src/build/runtime-package-directory.ts
4147
4685
  /** Update a staged copy, then publish it with rollback on failure or cancellation. */
4148
4686
  async function updateRuntimePackageDirectory(options) {
4149
4687
  const stagingRoot = await mkdtemp(join(dirname(options.directory), ".vitehub-runtime-packages-"));
@@ -4190,8 +4728,7 @@ async function updateRuntimePackageDirectory(options) {
4190
4728
  });
4191
4729
  }
4192
4730
  }
4193
- //#endregion
4194
- //#region ../internal/src/build/vercel-runtime-packages.ts
4731
+ // ../internal/src/build/vercel-runtime-packages.ts
4195
4732
  const runtimeExportConditions = /* @__PURE__ */ new Set([
4196
4733
  "default",
4197
4734
  "import",
@@ -4339,7 +4876,7 @@ async function copyTracedPackageFiles(name, resolver, packageDir, packageJsonPat
4339
4876
  return true;
4340
4877
  }
4341
4878
  async function loadNodeFileTrace() {
4342
- nodeFileTracePromise ??= import("./out-BbXG-yVX.js").then((m) => /* @__PURE__ */ __toESM(m.default, 1)).then(({ nodeFileTrace }) => nodeFileTrace);
4879
+ nodeFileTracePromise ??= import("./out-By90R-Bo.js").then((m) => /* @__PURE__ */ __toESM(m.default, 1)).then(({ nodeFileTrace }) => nodeFileTrace);
4343
4880
  return nodeFileTracePromise;
4344
4881
  }
4345
4882
  async function resolvePackageTraceEntries(name, resolver, packageDir, packageJson) {
@@ -4405,8 +4942,7 @@ function parsePackageJson(value, path) {
4405
4942
  if (typeof value !== "object" || value === null || Array.isArray(value)) throw internalErrorDiagnostics.INTERNAL_B0047({ message: `Expected ${path} to contain a JSON object.` });
4406
4943
  return value;
4407
4944
  }
4408
- //#endregion
4409
- //#region ../internal/src/build/provider-output-catalog.ts
4945
+ // ../internal/src/build/provider-output-catalog.ts
4410
4946
  var ProviderOutputCatalog = class {
4411
4947
  bundleDefines = {};
4412
4948
  #appliedCloudflareContributions = /* @__PURE__ */ new Map();
@@ -4634,8 +5170,7 @@ function useProviderOutputCatalog(config) {
4634
5170
  providerOutputCatalogs.set(config, catalog);
4635
5171
  return catalog;
4636
5172
  }
4637
- //#endregion
4638
- //#region ../internal/src/build/deployment-output.ts
5173
+ // ../internal/src/build/deployment-output.ts
4639
5174
  const providerDeploymentOutputRegistry = globalThis;
4640
5175
  const providerDeploymentOutputWrites = providerDeploymentOutputRegistry.__vitehubProviderDeploymentOutputWrites ??= /* @__PURE__ */ new Map();
4641
5176
  const providerDeploymentOutputFinalizations = providerDeploymentOutputRegistry.__vitehubProviderDeploymentOutputFinalizations ??= /* @__PURE__ */ new WeakMap();
@@ -5647,14 +6182,12 @@ async function finalizeProviderDeploymentOutputs(catalog, options = {}) {
5647
6182
  if (providerDeploymentOutputFinalizations.get(catalog) === active) providerDeploymentOutputFinalizations.delete(catalog);
5648
6183
  }
5649
6184
  }
5650
- //#endregion
5651
- //#region ../internal/src/durability.ts
6185
+ // ../internal/src/durability.ts
5652
6186
  /** The `durability` module next to the Vite plugin module at `importMetaUrl`, in source and in `dist`. */
5653
6187
  function durabilityModuleFile(importMetaUrl) {
5654
6188
  return fileURLToPath(new URL(importMetaUrl.endsWith(".ts") ? "./durability.ts" : "./durability.js", importMetaUrl));
5655
6189
  }
5656
- //#endregion
5657
- //#region ../internal/src/definition-catalog.ts
6190
+ // ../internal/src/definition-catalog.ts
5658
6191
  const sourceFilePattern = /\.(?:c|m)?[jt]sx?$/i;
5659
6192
  const declarationFilePattern = /\.d\.(?:c|m)?[jt]sx?$/i;
5660
6193
  const testFilePattern = /\.(?:test|spec)\.(?:c|m)?[jt]sx?$/i;
@@ -5813,8 +6346,7 @@ async function writeFileIfChanged(file, contents) {
5813
6346
  await mkdir(resolve$1(file, ".."), { recursive: true });
5814
6347
  await writeFile(file, contents, "utf8");
5815
6348
  }
5816
- //#endregion
5817
- //#region ../internal/src/hints.ts
6349
+ // ../internal/src/hints.ts
5818
6350
  /**
5819
6351
  * The file that lists the hints of the last build or dev server, relative to the project root. A hint is a warning
5820
6352
  * about something that works now and fails later, such as counts that stay in one server's memory. Agents and CI read
@@ -5902,8 +6434,7 @@ function hostFromNitroPreset(value) {
5902
6434
  if (normalized === "node" || normalized.startsWith("node-")) return "node";
5903
6435
  if (normalized.startsWith("vercel")) return "vercel";
5904
6436
  }
5905
- //#endregion
5906
- //#region ../internal/src/hosting.ts
6437
+ // ../internal/src/hosting.ts
5907
6438
  /**
5908
6439
  * Returns the Nitro preset name that this build targets, as the developer wrote it.
5909
6440
  * The order is `nitro.preset`, `hosting`, `NITRO_PRESET`, `SERVER_PRESET`, then `VITEHUB_HOST`.
@@ -5953,8 +6484,7 @@ function createNitroServerKit(value = {}) {
5953
6484
  }
5954
6485
  };
5955
6486
  }
5956
- //#endregion
5957
- //#region src/deployment-env.ts
6487
+ // src/deployment-env.ts
5958
6488
  /**
5959
6489
  * The variables that Schedules read on the deployed host. The Vercel cron handler refuses every request until
5960
6490
  * `CRON_SECRET` is set, so it is required. Cloudflare cron triggers and the Process Runtime read none.
@@ -5969,8 +6499,7 @@ function scheduleDeploymentEnv(definitions, context) {
5969
6499
  owners: ["schedule"]
5970
6500
  }];
5971
6501
  }
5972
- //#endregion
5973
- //#region ../internal/src/contributions.ts
6502
+ // ../internal/src/contributions.ts
5974
6503
  const unnamedPlugin = "unnamed plugin";
5975
6504
  function isNonEmptyString(value) {
5976
6505
  return String(value) === value && value.length > 0;
@@ -6075,8 +6604,7 @@ function readContribution(entry, plugin, options, fail) {
6075
6604
  ...base
6076
6605
  };
6077
6606
  }
6078
- //#endregion
6079
- //#region src/contributions.ts
6607
+ // src/contributions.ts
6080
6608
  const scheduleNamePattern = /^[a-z0-9][a-z0-9._-]*(?:\/[a-z0-9][a-z0-9._-]*)*$/i;
6081
6609
  /** Error for a Schedule name with two definitions. Both sources are named so the user knows which to rename. */
6082
6610
  function duplicateScheduleError(name, first, second) {
@@ -6105,8 +6633,7 @@ async function collectScheduleContributions(plugins, context) {
6105
6633
  }
6106
6634
  return contributions;
6107
6635
  }
6108
- //#endregion
6109
- //#region src/discovery.ts
6636
+ // src/discovery.ts
6110
6637
  /** Discovery source of Schedule Definitions that Vite plugins contribute through `vitehub.schedules`. */
6111
6638
  const contributedScheduleSource = "vite-plugin-contribution";
6112
6639
  /**
@@ -6270,13 +6797,11 @@ function discoverScheduleDefinitions(options) {
6270
6797
  function discoverStartableScheduleDefinitions(options) {
6271
6798
  return discoverAllScheduleDefinitions(options).filter((definition) => definition.startable);
6272
6799
  }
6273
- //#endregion
6274
- //#region src/integrations/vercel.ts
6800
+ // src/integrations/vercel.ts
6275
6801
  function getVercelSchedulePath(name) {
6276
6802
  return `/api/vitehub/schedules/vercel/${name.replace(/[^a-z0-9/_-]+/gi, "_")}`;
6277
6803
  }
6278
- //#endregion
6279
- //#region src/internal/time-zone-cron.ts
6804
+ // src/internal/time-zone-cron.ts
6280
6805
  const dayMs = 864e5;
6281
6806
  const dayMinutes = 1440;
6282
6807
  const sampledDays = 732;
@@ -6337,8 +6862,7 @@ function expandCron(cron, offsets) {
6337
6862
  })}`;
6338
6863
  return `${time} * * *`;
6339
6864
  }
6340
- //#endregion
6341
- //#region src/internal/provider-output.ts
6865
+ // src/internal/provider-output.ts
6342
6866
  const schedulePackageName = "@vite-hub/schedule";
6343
6867
  const scheduleStaticRuntimeImport = "@vite-hub/schedule/runtime/static";
6344
6868
  const productName = "schedule";
@@ -6639,14 +7163,23 @@ function netlifyScheduleFunctionNames(definitions) {
6639
7163
  }
6640
7164
  return names;
6641
7165
  }
6642
- function renderDenoCronEntry(file, registryFile, crons, runtimeImport = scheduleStaticRuntimeImport, timeZoneCrons = {}) {
6643
- const scheduleCrons = [...crons.entries()].sort(([left], [right]) => left.localeCompare(right)).map(([name, cron], index) => {
6644
- const cronId = index.toString(36);
7166
+ const englishBuildHostOrder = new Intl.Collator("en-US");
7167
+ const denoCronNameLength = 64;
7168
+ function denoCronNames(scheduleNames) {
7169
+ const sorted = [...scheduleNames].sort((left, right) => englishBuildHostOrder.compare(left, right) || (left < right ? -1 : left > right ? 1 : 0));
7170
+ return new Map(sorted.map((name, index) => {
7171
+ const indexedName = `vitehub-${index.toString(36)}-${name}`;
7172
+ if (/^[a-z0-9 _-]*$/i.test(name) && indexedName.length <= denoCronNameLength) return [name, indexedName];
6645
7173
  const safeName = [...name].map((character) => /^[a-z0-9 _-]$/i.test(character) ? character : "_").join("");
6646
- const cronNamePrefix = `vitehub-${cronId}-`;
7174
+ return [name, `${`vitehub_${createHash("sha256").update(name).digest("hex").slice(0, 12)}-`}${safeName}`.slice(0, denoCronNameLength)];
7175
+ }));
7176
+ }
7177
+ function renderDenoCronEntry(file, registryFile, crons, runtimeImport = scheduleStaticRuntimeImport, timeZoneCrons = {}) {
7178
+ const scheduleCrons = [...denoCronNames(crons.keys())].map(([name, cronName]) => {
7179
+ const cron = crons.get(name);
6647
7180
  return {
6648
7181
  cron,
6649
- cronName: `${cronNamePrefix}${safeName.slice(0, 64 - cronNamePrefix.length)}`,
7182
+ cronName,
6650
7183
  denoCron: cronWithWeekdayNames(cron),
6651
7184
  inTimeZone: Object.hasOwn(timeZoneCrons, name),
6652
7185
  name
@@ -7254,8 +7787,7 @@ async function generateProviderOutputsWithinLock(options) {
7254
7787
  throw error;
7255
7788
  }
7256
7789
  }
7257
- //#endregion
7258
- //#region src/inspect.ts
7790
+ // src/inspect.ts
7259
7791
  function inspectTimeZone(timeZone) {
7260
7792
  return timeZone === null ? "Not a static string" : timeZone ?? "UTC";
7261
7793
  }
@@ -7406,8 +7938,7 @@ const scheduleConsoleSection = {
7406
7938
  notice: "The host runs each Schedule on its cron, in its time zone (UTC by default). A Definition without cron runs when code starts it with `startSchedule()`; each started Schedule has its own row. Static Definitions with `manual: true` can also run from the Console or `vitehub schedule run`."
7407
7939
  }
7408
7940
  };
7409
- //#endregion
7410
- //#region src/internal/registry-module.ts
7941
+ // src/internal/registry-module.ts
7411
7942
  /**
7412
7943
  * Renders the `#vitehub/schedule/registry` virtual module. A virtual module has no directory, so a relative import would
7413
7944
  * resolve against the Vite root, which is the app directory under Nuxt. Each definition is imported by its absolute
@@ -7424,8 +7955,7 @@ function renderScheduleRegistryModule(definitions) {
7424
7955
  ""
7425
7956
  ].join("\n");
7426
7957
  }
7427
- //#endregion
7428
- //#region src/vite.ts
7958
+ // src/vite.ts
7429
7959
  async function readScheduleDefinitionCrons(definitions) {
7430
7960
  return await readRuntimeDefinitionCrons(definitions);
7431
7961
  }
@@ -8245,5 +8775,4 @@ function hubSchedule(options = {}) {
8245
8775
  };
8246
8776
  return inspectable;
8247
8777
  }
8248
- //#endregion
8249
8778
  export { collectScheduleContributions, contributedScheduleSource, createScheduleNitroConfig, discoverScheduleDefinitions, discoverStartableScheduleDefinitions, hubSchedule, inspectScheduleDefinitions, readScheduleDefinitionCrons, scheduleConsoleSection };