@vite-hub/workflow 0.5.0 → 0.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. package/dist/{app-2Y7sBAG6.js → app-DXUHElAz.js} +2 -3
  2. package/dist/{app-BojnC_yf.d.ts → app-wkVFd7m-.d.ts} +0 -2
  3. package/dist/{client-CgBcDlGn.js → client-CbBg4HlH.js} +17 -22
  4. package/dist/{cloudflare-Datj_znU.js → cloudflare-Sgywkm1N.js} +3 -5
  5. package/dist/{cloudflare-env-CGLx7lUd.js → cloudflare-env-DHhzRZOs.js} +2 -4
  6. package/dist/cloudflare-env-lookup-BqomAHN5.d.ts +2 -0
  7. package/dist/{cloudflare-shared-CTqh_a2s.d.ts → cloudflare-shared-B9cY3-jD.d.ts} +1 -3
  8. package/dist/{config-z1651xc2.js → config-CizNRTMi.js} +4 -7
  9. package/dist/definition.d.ts +2 -4
  10. package/dist/definition.js +3 -4
  11. package/dist/{delay-CHN4tv3i.js → delay-CtT3442d.js} +2 -3
  12. package/dist/{dev-recorder-CTN5Fkao.js → dev-recorder-Dltdmlkv.js} +1 -2
  13. package/dist/durability.d.ts +2 -4
  14. package/dist/durability.js +2 -3
  15. package/dist/{error-diagnostics-DMeaFmQD.js → error-diagnostics--2cV_ER1.js} +1 -2
  16. package/dist/{error-diagnostics-C0KyI408.js → error-diagnostics-kKXseq8d.js} +5 -2
  17. package/dist/{errors-D-fNDVg0.d.ts → errors-CJZuvOcx.d.ts} +0 -2
  18. package/dist/{errors-BNxEeeCO.js → errors-CZf7oz4k.js} +1 -2
  19. package/dist/index.d.ts +2 -8
  20. package/dist/index.js +5 -6
  21. package/dist/{inspect-B72iFyj-.js → inspect-NBCAwsxi.js} +1 -2
  22. package/dist/{object-Da1zyPCR.js → object-CAK6UYR5.js} +1 -2
  23. package/dist/{openworkflow-BoaENgh9.d.ts → openworkflow-CdKbUGGa.d.ts} +1 -3
  24. package/dist/{openworkflow-defaults-DDig2M4s.js → openworkflow-defaults-DfQWtSRU.js} +2 -4
  25. package/dist/{openworkflow-storage-Dj9zUAsk.js → openworkflow-storage-Dde_f0es.js} +1 -2
  26. package/dist/openworkflow.js +1 -2
  27. package/dist/{operation-definition-CI2PJGqu.d.ts → operation-definition-CqZkx1Rm.d.ts} +0 -4
  28. package/dist/{operations-CYntpf-T.js → operations-BBTmDm2H.js} +8 -10
  29. package/dist/operations.d.ts +2 -6
  30. package/dist/operations.js +8 -13
  31. package/dist/{out-DxLKolA0.js → out-r9T3bhTE.js} +2933 -2301
  32. package/dist/{rolldown-runtime-B4iAMlE-.js → rolldown-runtime-DYf_mQCB.js} +2 -3
  33. package/dist/{run-error-Ctn50EYz.js → run-error-8p4BtTMv.js} +5 -7
  34. package/dist/{run-failed-gVGo1BaF.js → run-failed-BcSjSU2t.js} +1 -2
  35. package/dist/runtime/cloudflare-runner.d.ts +3 -5
  36. package/dist/runtime/cloudflare-runner.js +6 -7
  37. package/dist/runtime/cloudflare-shared.d.ts +2 -2
  38. package/dist/runtime/cloudflare-shared.js +1 -2
  39. package/dist/runtime/cloudflare-vite.d.ts +5 -7
  40. package/dist/runtime/cloudflare-vite.js +5 -7
  41. package/dist/runtime/dev-runs.d.ts +1 -3
  42. package/dist/runtime/dev-runs.js +2 -3
  43. package/dist/runtime/execute.d.ts +3 -5
  44. package/dist/runtime/execute.js +5 -6
  45. package/dist/runtime/openworkflow-worker.d.ts +3 -4
  46. package/dist/runtime/openworkflow-worker.js +5 -6
  47. package/dist/runtime/openworkflow.d.ts +1 -1
  48. package/dist/runtime/openworkflow.js +8 -9
  49. package/dist/runtime/state.d.ts +2 -4
  50. package/dist/runtime/state.js +4 -5
  51. package/dist/runtime/vercel-vite.d.ts +3 -6
  52. package/dist/runtime/vercel-vite.js +4 -6
  53. package/dist/{signals-C1iolifd.js → signals-BHQdxoJo.js} +2 -3
  54. package/dist/{types-BWPHeugk.d.ts → types-DvYcvbPG.d.ts} +0 -2
  55. package/dist/{vercel-BIkBFrQQ.js → vercel-Cw_Z9-j4.js} +5 -6
  56. package/dist/vite.d.ts +2 -24
  57. package/dist/vite.js +1435 -924
  58. package/package.json +13 -13
  59. package/dist/cloudflare-env-lookup-CfX6wZKb.d.ts +0 -4
package/dist/vite.js CHANGED
@@ -1,14 +1,14 @@
1
- import { i as __toESM, n as __exportAll } from "./rolldown-runtime-B4iAMlE-.js";
2
- import { n as isRecordOrFunction, t as isRecord } from "./object-Da1zyPCR.js";
3
- import { t as workflowErrorDiagnostics } from "./error-diagnostics-DMeaFmQD.js";
1
+ import { i as __toESM, n as __exportAll } from "./rolldown-runtime-DYf_mQCB.js";
2
+ import { n as invariant, r as invariantError, t as defaultOpenWorkflowSqlitePath } from "./openworkflow-defaults-DfQWtSRU.js";
4
3
  import { workflowDurabilityUrl } from "./durability.js";
5
- import { i as getLegacyCloudflareWorkflowClassName, r as getCloudflareWorkflowClassName, t as createCloudflareWorkflowBindings } from "./cloudflare-Datj_znU.js";
6
- import { t as internalErrorDiagnostics } from "./error-diagnostics-C0KyI408.js";
7
- import { n as getHostingProvider, r as normalizeHosting, t as normalizeWorkflowOptions } from "./config-z1651xc2.js";
8
- import { a as workflowStartAtKey, n as generatedNativeEntryKey } from "./delay-CHN4tv3i.js";
4
+ import { t as internalErrorDiagnostics } from "./error-diagnostics-kKXseq8d.js";
5
+ import { n as isRecordOrFunction, t as isRecord } from "./object-CAK6UYR5.js";
6
+ import { n as getHostingProvider, r as normalizeHosting, t as normalizeWorkflowOptions } from "./config-CizNRTMi.js";
7
+ import { r as relativeDefinitionFile } from "./inspect-NBCAwsxi.js";
8
+ import { i as getLegacyCloudflareWorkflowClassName, r as getCloudflareWorkflowClassName, t as createCloudflareWorkflowBindings } from "./cloudflare-Sgywkm1N.js";
9
+ import { t as workflowErrorDiagnostics } from "./error-diagnostics--2cV_ER1.js";
9
10
  import { resolveWorkflowStepOptions, toStepPropertyName } from "./runtime/execute.js";
10
- import { n as invariant, r as invariantError, t as defaultOpenWorkflowSqlitePath } from "./openworkflow-defaults-DDig2M4s.js";
11
- import { r as relativeDefinitionFile } from "./inspect-B72iFyj-.js";
11
+ import { a as workflowStartAtKey, n as generatedNativeEntryKey } from "./delay-CtT3442d.js";
12
12
  import { builtinModules, createRequire, isBuiltin } from "node:module";
13
13
  import { dirname, normalize, relative, resolve } from "pathe";
14
14
  import { fileURLToPath, pathToFileURL } from "node:url";
@@ -19,13 +19,12 @@ import { access, chmod, copyFile, cp, lstat, mkdir, mkdtemp, readFile, readdir,
19
19
  import { tmpdir } from "node:os";
20
20
  import { parseSync } from "vite";
21
21
  import { build, buildSync, transform } from "esbuild";
22
- //#region ../internal/src/durability.ts
22
+ // ../internal/src/durability.ts
23
23
  /** The `durability` module next to the Vite plugin module at `importMetaUrl`, in source and in `dist`. */
24
24
  function durabilityModuleFile(importMetaUrl) {
25
25
  return fileURLToPath(new URL(importMetaUrl.endsWith(".ts") ? "./durability.ts" : "./durability.js", importMetaUrl));
26
26
  }
27
- //#endregion
28
- //#region ../internal/src/build/paths.ts
27
+ // ../internal/src/build/paths.ts
29
28
  function generatedDirSegments(productName) {
30
29
  return [".vitehub", productName];
31
30
  }
@@ -71,8 +70,7 @@ function realpathIfExists(path) {
71
70
  return resolve(path);
72
71
  }
73
72
  }
74
- //#endregion
75
- //#region src/internal/runtime-modules.ts
73
+ // src/internal/runtime-modules.ts
76
74
  /**
77
75
  * The file path of a Workflow runtime module. Generated code imports it by path, so it needs no package export.
78
76
  * Schedule and Agent output receive these paths from the Workflow plugin.
@@ -80,8 +78,7 @@ function realpathIfExists(path) {
80
78
  function workflowRuntimeModule(name) {
81
79
  return ownModule(import.meta.url, `runtime/${name}`);
82
80
  }
83
- //#endregion
84
- //#region ../internal/src/build/bundle-options.ts
81
+ // ../internal/src/build/bundle-options.ts
85
82
  const encodedAliasPrefixMarker = "\0vitehub-prefix:";
86
83
  const encodedAliasExactMarker = "\0vitehub-exact:";
87
84
  function encodeProviderOutputAliases(configAliases) {
@@ -106,8 +103,7 @@ function resolveViteHubBundleDefines(config) {
106
103
  }
107
104
  return defines;
108
105
  }
109
- //#endregion
110
- //#region ../internal/src/build/client-output.ts
106
+ // ../internal/src/build/client-output.ts
111
107
  function hasStaticIndex(clientDir) {
112
108
  return existsSync(resolve(clientDir, "index.html"));
113
109
  }
@@ -144,8 +140,7 @@ async function copyClientOutput(clientDir, targetDir, excludedDirs = []) {
144
140
  filter
145
141
  });
146
142
  }
147
- //#endregion
148
- //#region ../internal/src/build/provider-output-config.ts
143
+ // ../internal/src/build/provider-output-config.ts
149
144
  function isProviderJsonArray(value, ancestors) {
150
145
  if (Object.getPrototypeOf(value) !== Array.prototype || ancestors.has(value)) return false;
151
146
  if (Reflect.ownKeys(value).length !== value.length + 1) return false;
@@ -283,8 +278,7 @@ async function cleanProviderOutputConfig(file, ownership) {
283
278
  if (!changed) return;
284
279
  await persistProviderJsonRecord(file, next, true);
285
280
  }
286
- //#endregion
287
- //#region ../internal/src/build/user-entry.ts
281
+ // ../internal/src/build/user-entry.ts
288
282
  function toSafeAppName(rootDir) {
289
283
  return basename(rootDir).replace(/[^a-z0-9-]+/gi, "-").replace(/-+/g, "-").replace(/^-|-$/g, "").toLowerCase();
290
284
  }
@@ -303,8 +297,7 @@ function resolveUserAppEntry(rootDir, options = {}) {
303
297
  const srcSubdir = options.srcSubdir ?? "src";
304
298
  return names.map((name) => resolve$1(rootDir, srcSubdir, name)).find(existsSync);
305
299
  }
306
- //#endregion
307
- //#region ../internal/src/build/cloudflare.ts
300
+ // ../internal/src/build/cloudflare.ts
308
301
  const defaultCloudflareCompatibilityDate = "2026-04-20";
309
302
  const cloudflareRuntimeExternal = "cloudflare:*";
310
303
  function createDefaultCloudflareOutputRoot(rootDir) {
@@ -323,8 +316,7 @@ async function writeCloudflareWranglerConfig(options) {
323
316
  removeIfEmpty: true
324
317
  });
325
318
  }
326
- //#endregion
327
- //#region ../internal/src/build/ast-walk.ts
319
+ // ../internal/src/build/ast-walk.ts
328
320
  /** The oxc parser grammar for a file, from its extension. Defaults to TypeScript. */
329
321
  function moduleLanguage(file) {
330
322
  if (/\.(?:c|m)?tsx$/i.test(file)) return "tsx";
@@ -347,8 +339,7 @@ function walk(node, visit, parent) {
347
339
  } else if (isNode(child)) walk(child, visit, node);
348
340
  }
349
341
  }
350
- //#endregion
351
- //#region ../internal/src/build/rolldown.ts
342
+ // ../internal/src/build/rolldown.ts
352
343
  const viteRawPrefix = "\0vitehub-vite-raw:";
353
344
  const markdownTemplatePrefix = "\0vitehub-markdown-template:";
354
345
  const markdownTemplateFileSuffix$1 = ".template.md";
@@ -945,8 +936,7 @@ async function bundleEsmEntry(entryFile, outfile, options = {}) {
945
936
  await writeFile(outfile, chunk.code, { signal: options.signal });
946
937
  options.signal?.throwIfAborted();
947
938
  }
948
- //#endregion
949
- //#region ../../node_modules/.pnpm/balanced-match@4.0.4/node_modules/balanced-match/dist/esm/index.js
939
+ // ../../node_modules/.pnpm/balanced-match@4.0.4/node_modules/balanced-match/dist/esm/index.js
950
940
  const balanced = (a, b, str) => {
951
941
  const ma = a instanceof RegExp ? maybeMatch(a, str) : a;
952
942
  const mb = b instanceof RegExp ? maybeMatch(b, str) : b;
@@ -993,8 +983,7 @@ const range = (a, b, str) => {
993
983
  }
994
984
  return result;
995
985
  };
996
- //#endregion
997
- //#region ../../node_modules/.pnpm/brace-expansion@5.0.12/node_modules/brace-expansion/dist/esm/index.js
986
+ // ../../node_modules/.pnpm/brace-expansion@5.0.12/node_modules/brace-expansion/dist/esm/index.js
998
987
  const escSlash = "\0SLASH" + Math.random() + "\0";
999
988
  const escOpen = "\0OPEN" + Math.random() + "\0";
1000
989
  const escClose = "\0CLOSE" + Math.random() + "\0";
@@ -1194,39 +1183,94 @@ function expand_(str, max, maxLength, maxDepth, depth, maxRewrites, isTop) {
1194
1183
  }
1195
1184
  return acc;
1196
1185
  }
1197
- //#endregion
1198
- //#region ../../node_modules/.pnpm/minimatch@10.2.6/node_modules/minimatch/dist/esm/assert-valid-pattern.js
1199
- const MAX_PATTERN_LENGTH = 65536;
1200
- const assertValidPattern = (pattern) => {
1201
- if (typeof pattern !== "string") throw new TypeError("invalid pattern");
1202
- if (pattern.length > MAX_PATTERN_LENGTH) throw new TypeError("pattern is too long");
1186
+ // ../../node_modules/.pnpm/@isaacs+nonrecursive-glob-match@1.1.0/node_modules/@isaacs/nonrecursive-glob-match/dist/esm/numeric-range.js
1187
+ const digit = (a, b) => a === b ? {
1188
+ t: "lit",
1189
+ ch: String(a)
1190
+ } : {
1191
+ t: "class",
1192
+ re: new RegExp(`^[${a}-${b}]$`)
1193
+ };
1194
+ const prefix = (d, alts) => alts.map((s) => [digit(d, d), ...s]);
1195
+ const fixed = (a, b) => {
1196
+ if (!a) return [[]];
1197
+ let lo = +a[0];
1198
+ let hi = +b[0];
1199
+ const ra = a.slice(1);
1200
+ const rb = b.slice(1);
1201
+ if (lo === hi) return prefix(lo, fixed(ra, rb));
1202
+ const zeros = "0".repeat(ra.length);
1203
+ const nines = "9".repeat(ra.length);
1204
+ const out = [];
1205
+ if (ra !== zeros) out.push(...prefix(lo++, fixed(ra, nines)));
1206
+ const last = rb === nines ? [] : prefix(hi--, fixed(zeros, rb));
1207
+ if (lo <= hi) out.push([digit(lo, hi), ...Array.from(ra, () => digit(0, 9))]);
1208
+ out.push(...last);
1209
+ return out;
1210
+ };
1211
+ const nonneg = (a, b, width) => {
1212
+ if (width) return fixed(String(a).padStart(width, "0"), String(b).padStart(width, "0"));
1213
+ const out = [];
1214
+ for (let len = String(a).length; len <= String(b).length; len++) {
1215
+ const lo = Math.max(a, len === 1 ? 0 : 10 ** (len - 1));
1216
+ const hi = Math.min(b, 10 ** len - 1);
1217
+ out.push(...fixed(String(lo), String(hi)));
1218
+ }
1219
+ return out;
1203
1220
  };
1204
- //#endregion
1205
- //#region ../../node_modules/.pnpm/minimatch@10.2.6/node_modules/minimatch/dist/esm/brace-expressions.js
1221
+ /**
1222
+ * The strings that the bash brace expansion `{lo..hi}` makes, as
1223
+ * the alternatives of an `@(...)` extglob. Each one is a sequence of
1224
+ * digits and digit classes, so there are only a few of them, even for
1225
+ * a large range.
1226
+ *
1227
+ * If either end has a leading zero, such as `{01..10}`, each number
1228
+ * has leading zeros to make it as long as the longer end, counting a
1229
+ * `-` sign. So `{-05..3}` makes `-05` to `-01`, then `000` to `003`.
1230
+ *
1231
+ * Returns undefined if either end is not a safe integer.
1232
+ */
1233
+ const numericRange = (loStr, hiStr) => {
1234
+ let lo = Number(loStr);
1235
+ let hi = Number(hiStr);
1236
+ if (!Number.isSafeInteger(lo) || !Number.isSafeInteger(hi)) return;
1237
+ if (lo > hi) [lo, hi] = [hi, lo];
1238
+ const width = /^-?0\d/.test(loStr) || /^-?0\d/.test(hiStr) ? Math.max(loStr.length, hiStr.length) : 0;
1239
+ const out = [];
1240
+ if (lo < 0) {
1241
+ const neg = nonneg(Math.max(-hi, 1), -lo, width && width - 1);
1242
+ out.push(...neg.map((s) => [{
1243
+ t: "lit",
1244
+ ch: "-"
1245
+ }, ...s]));
1246
+ }
1247
+ if (hi >= 0) out.push(...nonneg(Math.max(lo, 0), hi, width));
1248
+ return out;
1249
+ };
1250
+ // ../../node_modules/.pnpm/@isaacs+nonrecursive-glob-match@1.1.0/node_modules/@isaacs/nonrecursive-glob-match/dist/esm/parse-class.js
1206
1251
  const posixClasses = {
1207
- "[:alnum:]": ["\\p{L}\\p{Nl}\\p{Nd}", true],
1208
- "[:alpha:]": ["\\p{L}\\p{Nl}", true],
1209
- "[:ascii:]": ["\\x00-\\x7f", false],
1210
- "[:blank:]": ["\\p{Zs}\\t", true],
1211
- "[:cntrl:]": ["\\p{Cc}", true],
1212
- "[:digit:]": ["\\p{Nd}", true],
1213
- "[:graph:]": [
1214
- "\\p{Z}\\p{C}",
1215
- true,
1216
- true
1217
- ],
1218
- "[:lower:]": ["\\p{Ll}", true],
1252
+ "[:alnum:]": ["\\p{L}\\p{Nl}\\p{Nd}"],
1253
+ "[:alpha:]": ["\\p{L}\\p{Nl}"],
1254
+ "[:ascii:]": ["\\x00-\\x7f"],
1255
+ "[:blank:]": ["\\p{Zs}\\t"],
1256
+ "[:cntrl:]": ["\\p{Cc}"],
1257
+ "[:digit:]": ["\\p{Nd}"],
1258
+ "[:graph:]": ["\\p{Z}\\p{C}", true],
1259
+ "[:lower:]": ["\\p{Ll}"],
1219
1260
  "[:print:]": ["\\p{C}", true],
1220
- "[:punct:]": ["\\p{P}", true],
1221
- "[:space:]": ["\\p{Z}\\t\\r\\n\\v\\f", true],
1222
- "[:upper:]": ["\\p{Lu}", true],
1223
- "[:word:]": ["\\p{L}\\p{Nl}\\p{Nd}\\p{Pc}", true],
1224
- "[:xdigit:]": ["A-Fa-f0-9", false]
1261
+ "[:punct:]": ["\\p{P}\\p{S}"],
1262
+ "[:space:]": ["\\p{Z}\\t\\r\\n\\v\\f"],
1263
+ "[:upper:]": ["\\p{Lu}"],
1264
+ "[:word:]": ["\\p{L}\\p{Nl}\\p{Nd}\\p{Pc}"],
1265
+ "[:xdigit:]": ["A-Fa-f0-9"]
1225
1266
  };
1226
1267
  const braceEscape = (s) => s.replace(/[[\]\\-]/g, "\\$&");
1227
- const regexpEscape = (s) => s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
1228
- const rangesToString = (ranges) => ranges.join("");
1229
- const parseClass = (glob, position) => {
1268
+ const noMatch = /$./;
1269
+ const parseClass = (glob, position, nocase = false, form) => {
1270
+ const norm = (c) => {
1271
+ const n = form ? c.normalize(form) : c;
1272
+ return [...n].length === 1 ? n : c;
1273
+ };
1230
1274
  const pos = position;
1231
1275
  /* c8 ignore start */
1232
1276
  if (glob.charAt(pos) !== "[") throw new Error("not in a brace expression");
@@ -1235,13 +1279,12 @@ const parseClass = (glob, position) => {
1235
1279
  const negs = [];
1236
1280
  let i = pos + 1;
1237
1281
  let sawStart = false;
1238
- let uflag = false;
1239
1282
  let escaping = false;
1240
1283
  let negate = false;
1241
1284
  let endPos = pos;
1242
1285
  let rangeStart = "";
1243
1286
  WHILE: while (i < glob.length) {
1244
- const c = glob.charAt(i);
1287
+ const c = String.fromCodePoint(glob.codePointAt(i));
1245
1288
  if ((c === "!" || c === "^") && i === pos + 1) {
1246
1289
  negate = true;
1247
1290
  i++;
@@ -1260,607 +1303,659 @@ const parseClass = (glob, position) => {
1260
1303
  }
1261
1304
  }
1262
1305
  if (c === "[" && !escaping) {
1263
- for (const [cls, [unip, u, neg]] of Object.entries(posixClasses)) if (glob.startsWith(cls, i)) {
1264
- if (rangeStart) return [
1265
- "$.",
1266
- false,
1267
- glob.length - pos,
1268
- true
1269
- ];
1306
+ for (const [cls, [unip, neg]] of Object.entries(posixClasses)) if (glob.startsWith(cls, i)) {
1307
+ if (rangeStart) return [noMatch, glob.length - pos];
1270
1308
  i += cls.length;
1271
1309
  if (neg) negs.push(unip);
1272
1310
  else ranges.push(unip);
1273
- uflag = uflag || u;
1274
1311
  continue WHILE;
1275
1312
  }
1276
1313
  }
1277
1314
  escaping = false;
1315
+ const n = norm(c);
1278
1316
  if (rangeStart) {
1279
- if (c > rangeStart) ranges.push(braceEscape(rangeStart) + "-" + braceEscape(c));
1280
- else if (c === rangeStart) ranges.push(braceEscape(c));
1317
+ if (n.codePointAt(0) > rangeStart.codePointAt(0)) ranges.push(braceEscape(rangeStart) + "-" + braceEscape(n));
1318
+ else if (n === rangeStart) ranges.push(braceEscape(n));
1281
1319
  rangeStart = "";
1282
- i++;
1320
+ i += c.length;
1283
1321
  continue;
1284
1322
  }
1285
- if (glob.startsWith("-]", i + 1)) {
1286
- ranges.push(braceEscape(c + "-"));
1287
- i += 2;
1323
+ if (glob.startsWith("-]", i + c.length)) {
1324
+ ranges.push(braceEscape(n + "-"));
1325
+ i += c.length + 1;
1288
1326
  continue;
1289
1327
  }
1290
- if (glob.startsWith("-", i + 1)) {
1291
- rangeStart = c;
1292
- i += 2;
1328
+ if (glob.startsWith("-", i + c.length)) {
1329
+ rangeStart = n;
1330
+ i += c.length + 1;
1293
1331
  continue;
1294
1332
  }
1295
- ranges.push(braceEscape(c));
1296
- i++;
1333
+ ranges.push(braceEscape(n));
1334
+ i += c.length;
1297
1335
  }
1298
- if (endPos < i) return [
1299
- "",
1300
- false,
1301
- 0,
1302
- false
1303
- ];
1304
- if (!ranges.length && !negs.length) return [
1305
- "$.",
1306
- false,
1307
- glob.length - pos,
1308
- true
1309
- ];
1310
- if (negs.length === 0 && ranges.length === 1 && /^\\?.$/.test(ranges[0]) && !negate) {
1311
- const r = ranges[0].length === 2 ? ranges[0].slice(-1) : ranges[0];
1312
- return [
1313
- regexpEscape(r),
1314
- false,
1315
- endPos - pos,
1316
- false
1317
- ];
1336
+ if (endPos < i) return [noMatch, 0];
1337
+ if (!ranges.length && !negs.length) return [noMatch, glob.length - pos];
1338
+ const sranges = "[" + (negate ? "^" : "") + ranges.join("") + "]";
1339
+ const snegs = "[" + (negate ? "" : "^") + negs.join("") + "]";
1340
+ const comb = "^" + (ranges.length && negs.length ? "(" + sranges + "|" + snegs + ")" : ranges.length ? sranges : snegs);
1341
+ return [new RegExp(comb, nocase ? "iu" : "u"), endPos - pos];
1342
+ };
1343
+ // ../../node_modules/.pnpm/@isaacs+nonrecursive-glob-match@1.1.0/node_modules/@isaacs/nonrecursive-glob-match/dist/esm/index.js
1344
+ const MATCH = {
1345
+ t: "match",
1346
+ id: 0
1347
+ };
1348
+ const extTypes = "!?+*@";
1349
+ const lit = (ch) => ({
1350
+ t: "lit",
1351
+ ch
1352
+ });
1353
+ const reEscape = (s) => s.replace(/[\\^$.*+?()[\]{}|/]/g, "\\$&");
1354
+ const newFoldRe = (s) => new RegExp(`^${reEscape(s)}$`, "iu");
1355
+ const foldCache = /* @__PURE__ */ new Map();
1356
+ const foldRe = (ch) => {
1357
+ let re = foldCache.get(ch);
1358
+ if (!re) {
1359
+ re = newFoldRe(ch);
1360
+ if (foldCache.size >= 1e3) foldCache.clear();
1361
+ foldCache.set(ch, re);
1362
+ }
1363
+ return re;
1364
+ };
1365
+ const litMatch = (l, c) => {
1366
+ if (c === l.ch) return true;
1367
+ if (!l.re) return false;
1368
+ const code = c.charCodeAt(0);
1369
+ if (code >= 128) return l.re.test(c);
1370
+ const ascii = l.ascii ??= /* @__PURE__ */ new Uint8Array(128);
1371
+ ascii[code] ||= l.re.test(c) ? 1 : 2;
1372
+ return ascii[code] === 1;
1373
+ };
1374
+ const tokenize = (p, nocase, noext, form, mark) => {
1375
+ const toks = [];
1376
+ for (let i = 0; i < p.length;) {
1377
+ const c = String.fromCodePoint(p.codePointAt(i));
1378
+ if (mark) {
1379
+ const m = c === "\\" && p.startsWith(mark, i + 1) ? 1 : 0;
1380
+ if (m || c === mark) {
1381
+ const start = i + m + mark.length;
1382
+ const end = p.indexOf(mark, start);
1383
+ const r = /^(-?\d+)\.\.(-?\d+)$/.exec(p.slice(start, end));
1384
+ const alts = end !== -1 && r && numericRange(r[1], r[2]);
1385
+ if (alts) {
1386
+ toks.push({
1387
+ t: "ext",
1388
+ type: "@",
1389
+ alts
1390
+ });
1391
+ i = end + mark.length;
1392
+ continue;
1393
+ }
1394
+ }
1395
+ }
1396
+ if (c === "\\") {
1397
+ const e = p.codePointAt(i + 1);
1398
+ const ch = e === void 0 ? c : String.fromCodePoint(e);
1399
+ toks.push(lit(ch));
1400
+ i += 1 + ch.length;
1401
+ continue;
1402
+ }
1403
+ if (c === "[") {
1404
+ const [re, consumed] = parseClass(p, i, nocase, form);
1405
+ if (consumed) {
1406
+ toks.push({
1407
+ t: "class",
1408
+ re
1409
+ });
1410
+ i += consumed;
1411
+ continue;
1412
+ }
1413
+ }
1414
+ if (!noext && extTypes.includes(c) && p[i + 1] === "(") {
1415
+ toks.push({
1416
+ t: "open",
1417
+ type: c
1418
+ });
1419
+ i += 2;
1420
+ continue;
1421
+ }
1422
+ toks.push(!noext && c === "|" ? { t: "bar" } : !noext && c === ")" ? { t: "close" } : c === "*" ? { t: "star" } : c === "?" ? { t: "any" } : lit(c));
1423
+ i += c.length;
1318
1424
  }
1319
- const sranges = "[" + (negate ? "^" : "") + rangesToString(ranges) + "]";
1320
- const snegs = "[" + (negate ? "" : "^") + rangesToString(negs) + "]";
1321
- return [
1322
- ranges.length && negs.length ? "(" + sranges + "|" + snegs + ")" : ranges.length ? sranges : snegs,
1323
- uflag,
1324
- endPos - pos,
1325
- true
1326
- ];
1425
+ return toks;
1327
1426
  };
1328
- //#endregion
1329
- //#region ../../node_modules/.pnpm/minimatch@10.2.6/node_modules/minimatch/dist/esm/unescape.js
1330
- /**
1331
- * Un-escape a string that has been escaped with {@link escape}.
1332
- *
1333
- * If the {@link MinimatchOptions.windowsPathsNoEscape} option is used, then
1334
- * square-bracket escapes are removed, but not backslash escapes.
1335
- *
1336
- * For example, it will turn the string `'[*]'` into `*`, but it will not
1337
- * turn `'\\*'` into `'*'`, because `\` is a path separator in
1338
- * `windowsPathsNoEscape` mode.
1339
- *
1340
- * When `windowsPathsNoEscape` is not set, then both square-bracket escapes and
1341
- * backslash escapes are removed.
1342
- *
1343
- * Slashes (and backslashes in `windowsPathsNoEscape` mode) cannot be escaped
1344
- * or unescaped.
1345
- *
1346
- * When `magicalBraces` is not set, escapes of braces (`{` and `}`) will not be
1347
- * unescaped.
1348
- */
1349
- const unescape = (s, { windowsPathsNoEscape = false, magicalBraces = true } = {}) => {
1350
- if (magicalBraces) return windowsPathsNoEscape ? s.replace(/\[([^/\\])\]/g, "$1") : s.replace(/((?!\\).|^)\[([^/\\])\]/g, "$1$2").replace(/\\([^/])/g, "$1");
1351
- return windowsPathsNoEscape ? s.replace(/\[([^/\\{}])\]/g, "$1") : s.replace(/((?!\\).|^)\[([^/\\{}])\]/g, "$1$2").replace(/\\([^/{}])/g, "$1");
1427
+ const pair = (toks) => {
1428
+ const pairs = /* @__PURE__ */ new Map();
1429
+ const stack = [];
1430
+ toks.forEach((tok, i) => {
1431
+ if (tok.t === "open") stack.push(i);
1432
+ else if (tok.t === "close" && stack.length) pairs.set(stack.pop(), i);
1433
+ });
1434
+ return pairs;
1352
1435
  };
1353
- //#endregion
1354
- //#region ../../node_modules/.pnpm/minimatch@10.2.6/node_modules/minimatch/dist/esm/ast.js
1355
- var _a;
1356
- const types = /* @__PURE__ */ new Set([
1357
- "!",
1358
- "?",
1359
- "+",
1360
- "*",
1361
- "@"
1362
- ]);
1363
- const isExtglobType = (c) => types.has(c);
1364
- const isExtglobAST = (c) => isExtglobType(c.type);
1365
- const adoptionMap = /* @__PURE__ */ new Map([
1366
- ["!", ["@"]],
1367
- ["?", ["?", "@"]],
1368
- ["@", ["@"]],
1369
- ["*", [
1370
- "*",
1371
- "+",
1372
- "?",
1373
- "@"
1374
- ]],
1375
- ["+", ["+", "@"]]
1376
- ]);
1377
- const adoptionWithSpaceMap = /* @__PURE__ */ new Map([
1378
- ["!", ["?"]],
1379
- ["@", ["?"]],
1380
- ["+", ["?", "*"]]
1381
- ]);
1382
- const adoptionAnyMap = /* @__PURE__ */ new Map([
1383
- ["!", ["?", "@"]],
1384
- ["?", ["?", "@"]],
1385
- ["@", ["?", "@"]],
1386
- ["*", [
1387
- "*",
1388
- "+",
1389
- "?",
1390
- "@"
1391
- ]],
1392
- ["+", [
1393
- "+",
1394
- "@",
1395
- "?",
1396
- "*"
1397
- ]]
1398
- ]);
1399
- const usurpMap = /* @__PURE__ */ new Map([
1400
- ["!", /* @__PURE__ */ new Map([["!", "@"]])],
1401
- ["?", /* @__PURE__ */ new Map([["*", "*"], ["+", "*"]])],
1402
- ["@", /* @__PURE__ */ new Map([
1403
- ["!", "!"],
1404
- ["?", "?"],
1405
- ["@", "@"],
1406
- ["*", "*"],
1407
- ["+", "+"]
1408
- ])],
1409
- ["+", /* @__PURE__ */ new Map([["?", "*"], ["*", "*"]])]
1410
- ]);
1411
- const startNoTraversal = "(?!(?:^|/)\\.\\.?(?:$|/))";
1412
- const startNoDot = "(?!\\.)";
1413
- const addPatternStart = /* @__PURE__ */ new Set(["[", "."]);
1414
- const justDots = /* @__PURE__ */ new Set(["..", "."]);
1415
- const reSpecials = /* @__PURE__ */ new Set("().*{}+?[]^$\\!");
1416
- const regExpEscape$1 = (s) => s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
1417
- const qmark = "[^/]";
1418
- const star$1 = "[^/]*?";
1419
- const starNoEmpty = "[^/]+?";
1420
- let ID = 0;
1421
- var AST = class {
1422
- type;
1423
- #root;
1424
- #hasMagic;
1425
- #uflag = false;
1426
- #parts = [];
1427
- #parent;
1428
- #parentIndex;
1429
- #negs;
1430
- #filledNegs = false;
1431
- #options;
1432
- #toString;
1433
- #emptyExt = false;
1434
- id = ++ID;
1435
- get depth() {
1436
- return (this.#parent?.depth ?? -1) + 1;
1437
- }
1438
- [Symbol.for("nodejs.util.inspect.custom")]() {
1439
- return {
1440
- "@@type": "AST",
1441
- id: this.id,
1442
- type: this.type,
1443
- root: this.#root.id,
1444
- parent: this.#parent?.id,
1445
- depth: this.depth,
1446
- partsLength: this.#parts.length,
1447
- parts: this.#parts
1448
- };
1436
+ const build$1 = (toks, pairs, start, end, top) => {
1437
+ let seq = [];
1438
+ const alts = [seq];
1439
+ for (let i = start; i < end; i++) {
1440
+ const tok = toks[i];
1441
+ const close = pairs.get(i);
1442
+ if (tok.t === "open" && close !== void 0) {
1443
+ const sub = build$1(toks, pairs, i + 1, close, false);
1444
+ seq.push({
1445
+ t: "ext",
1446
+ type: tok.type,
1447
+ alts: sub
1448
+ });
1449
+ i = close;
1450
+ } else if (tok.t === "bar" && !top) alts.push(seq = []);
1451
+ else if (tok.t === "open") seq.push(lit(tok.type), lit("("));
1452
+ else if (tok.t === "bar") seq.push(lit("|"));
1453
+ else if (tok.t === "close") seq.push(lit(")"));
1454
+ else seq.push(tok);
1455
+ }
1456
+ return alts;
1457
+ };
1458
+ const normalize$1 = (items, form) => {
1459
+ const out = [];
1460
+ let run = "";
1461
+ const flush = () => {
1462
+ for (const ch of run.normalize(form)) out.push(lit(ch));
1463
+ run = "";
1464
+ };
1465
+ for (const it of items) {
1466
+ if (it.t === "lit") {
1467
+ run += it.ch;
1468
+ continue;
1469
+ }
1470
+ flush();
1471
+ out.push(it.t === "ext" ? {
1472
+ ...it,
1473
+ alts: it.alts.map((a) => normalize$1(a, form))
1474
+ } : it);
1449
1475
  }
1450
- constructor(type, parent, options = {}) {
1451
- this.type = type;
1452
- if (type) this.#hasMagic = true;
1453
- this.#parent = parent;
1454
- this.#root = this.#parent ? this.#parent.#root : this;
1455
- this.#options = this.#root === this ? options : this.#root.#options;
1456
- this.#negs = this.#root === this ? [] : this.#root.#negs;
1457
- if (type === "!" && !this.#root.#filledNegs) this.#negs.push(this);
1458
- this.#parentIndex = this.#parent ? this.#parent.#parts.length : 0;
1459
- }
1460
- get hasMagic() {
1461
- /* c8 ignore start */
1462
- if (this.#hasMagic !== void 0) return this.#hasMagic;
1463
- /* c8 ignore stop */
1464
- for (const p of this.#parts) {
1465
- if (typeof p === "string") continue;
1466
- if (p.type || p.hasMagic) return this.#hasMagic = true;
1476
+ flush();
1477
+ return out;
1478
+ };
1479
+ const compile = (items, nocase) => {
1480
+ let id = 1;
1481
+ const split = (out) => ({
1482
+ t: "split",
1483
+ id: id++,
1484
+ out
1485
+ });
1486
+ const seq = (items, next) => items.reduceRight((next, it) => item(it, next), next);
1487
+ const item = (it, next) => {
1488
+ switch (it.t) {
1489
+ case "lit":
1490
+ const re = nocase ? foldRe(it.ch) : void 0;
1491
+ return {
1492
+ t: "lit",
1493
+ id: id++,
1494
+ ch: it.ch,
1495
+ re,
1496
+ next
1497
+ };
1498
+ case "any":
1499
+ case "star": return {
1500
+ t: it.t,
1501
+ id: id++,
1502
+ next
1503
+ };
1504
+ case "class": return {
1505
+ t: "class",
1506
+ id: id++,
1507
+ re: it.re,
1508
+ next
1509
+ };
1510
+ }
1511
+ const alts = (next) => it.alts.map((a) => seq(a, next));
1512
+ switch (it.type) {
1513
+ case "@": return split(alts(next));
1514
+ case "?": return split([next, ...alts(next)]);
1515
+ case "!": return {
1516
+ t: "neg",
1517
+ id: id++,
1518
+ sub: split(alts(MATCH)),
1519
+ next
1520
+ };
1521
+ }
1522
+ const after = split([]);
1523
+ const entry = split(alts(after));
1524
+ after.out.push(next, entry);
1525
+ return it.type === "*" ? after : entry;
1526
+ };
1527
+ return [seq(items, MATCH), id];
1528
+ };
1529
+ const show = (start) => {
1530
+ const lines = [];
1531
+ const seen = /* @__PURE__ */ new Set();
1532
+ const ref = (n) => n.t === "match" ? "match" : String(n.id);
1533
+ const walk = (n, indent) => {
1534
+ if (n.t === "match" || seen.has(n)) return;
1535
+ seen.add(n);
1536
+ const line = (desc) => lines.push(`${indent}${n.id}: ${desc}`);
1537
+ switch (n.t) {
1538
+ case "split":
1539
+ line(`split -> ${n.out.map(ref).join(", ")}`);
1540
+ for (const o of n.out) walk(o, indent);
1541
+ return;
1542
+ case "neg":
1543
+ line(`!(${ref(n.sub)}) -> ${ref(n.next)}`);
1544
+ walk(n.sub, indent + " ");
1545
+ return walk(n.next, indent);
1546
+ case "lit":
1547
+ line(`${JSON.stringify(n.ch)} -> ${ref(n.next)}`);
1548
+ break;
1549
+ case "class":
1550
+ line(`${n.re} -> ${ref(n.next)}`);
1551
+ break;
1552
+ default: line(`${n.t === "any" ? "?" : "*"} -> ${ref(n.next)}`);
1467
1553
  }
1468
- return this.#hasMagic;
1554
+ walk(n.next, indent);
1555
+ };
1556
+ walk(start, "");
1557
+ return [`start -> ${ref(start)}`, ...lines].join("\n");
1558
+ };
1559
+ var State = class {
1560
+ gen;
1561
+ threads = [];
1562
+ match = false;
1563
+ runs = [];
1564
+ ids = [];
1565
+ constructor(gen) {
1566
+ this.gen = gen;
1567
+ }
1568
+ get dead() {
1569
+ return !this.threads.length && !this.match && !this.runs.length;
1469
1570
  }
1470
- toString() {
1471
- 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("|") + ")";
1571
+ };
1572
+ const sameState = (a, b) => {
1573
+ if (a.ids.length !== b.ids.length) return false;
1574
+ if (a.runs.length !== b.runs.length) return false;
1575
+ if (a.ids.some((id, i) => id !== b.ids[i])) return false;
1576
+ return a.runs.every((r) => b.runs.some((o) => o.neg === r.neg && sameState(o.state, r.state)));
1577
+ };
1578
+ const marks = (size) => ({
1579
+ has: new Float64Array(size),
1580
+ seen: new Float64Array(size),
1581
+ gen: 0
1582
+ });
1583
+ var Sim = class {
1584
+ dots;
1585
+ dotStart;
1586
+ #marks;
1587
+ constructor(dots, dotStart, marks) {
1588
+ this.dots = dots;
1589
+ this.dotStart = dotStart;
1590
+ this.#marks = marks;
1591
+ }
1592
+ state() {
1593
+ return new State(++this.#marks.gen);
1594
+ }
1595
+ done(state) {
1596
+ state.ids = state.threads.map((n) => n.id).sort((a, b) => a - b);
1597
+ if (state.match) state.ids.unshift(MATCH.id);
1598
+ return state;
1599
+ }
1600
+ #visit(state, node) {
1601
+ const { seen } = this.#marks;
1602
+ if (seen[node.id] === state.gen) return false;
1603
+ seen[node.id] = state.gen;
1604
+ return true;
1472
1605
  }
1473
- #fillNegs() {
1474
- /* c8 ignore start */
1475
- if (this !== this.#root) throw new Error("should only call on root");
1476
- if (this.#filledNegs) return this;
1477
- /* c8 ignore stop */
1478
- this.toString();
1479
- this.#filledNegs = true;
1480
- let n;
1481
- while (n = this.#negs.pop()) {
1482
- if (n.type !== "!") continue;
1483
- let p = n;
1484
- let pp = p.#parent;
1485
- while (pp) {
1486
- for (let i = p.#parentIndex + 1; !pp.type && i < pp.#parts.length; i++) for (const part of n.#parts) {
1487
- /* c8 ignore start */
1488
- if (typeof part === "string") throw new Error("string part in extglob AST??");
1489
- /* c8 ignore stop */
1490
- part.copyIn(pp.#parts[i]);
1491
- }
1492
- p = pp;
1493
- pp = p.#parent;
1494
- }
1495
- }
1496
- return this;
1606
+ #addThread(state, node) {
1607
+ const { has } = this.#marks;
1608
+ if (has[node.id] === state.gen) return false;
1609
+ has[node.id] = state.gen;
1610
+ state.threads.push(node);
1611
+ return true;
1497
1612
  }
1498
- push(...parts) {
1499
- for (const p of parts) {
1500
- if (p === "") continue;
1501
- /* c8 ignore start */
1502
- if (typeof p !== "string" && !(p instanceof _a && p.#parent === this)) throw new Error("invalid part: " + p);
1503
- /* c8 ignore stop */
1504
- this.#parts.push(p);
1613
+ restricted(i, top) {
1614
+ return top && (this.dots || this.dotStart && i === 0);
1615
+ }
1616
+ add(state, node, i, top) {
1617
+ switch (node.t) {
1618
+ case "split":
1619
+ if (!this.#visit(state, node)) return;
1620
+ for (const o of node.out) this.add(state, o, i, top);
1621
+ return;
1622
+ case "neg":
1623
+ if (!this.#visit(state, node)) return;
1624
+ const sub = this.state();
1625
+ this.add(sub, node.sub, i, false);
1626
+ this.done(sub);
1627
+ return this.addRun(state, {
1628
+ t: "run",
1629
+ neg: node,
1630
+ state: sub
1631
+ }, i, top);
1632
+ case "star":
1633
+ if (this.restricted(i, top)) return;
1634
+ if (this.#addThread(state, node)) this.add(state, node.next, i, top);
1635
+ return;
1636
+ case "match":
1637
+ state.match = true;
1638
+ return;
1639
+ default: this.#addThread(state, node);
1505
1640
  }
1506
1641
  }
1507
- toJSON() {
1508
- const ret = this.type === null ? this.#parts.slice().map((p) => typeof p === "string" ? p : p.toJSON()) : [this.type, ...this.#parts.map((p) => p.toJSON())];
1509
- if (this.isStart() && !this.type) ret.unshift([]);
1510
- if (this.isEnd() && (this === this.#root || this.#root.#filledNegs && this.#parent?.type === "!")) ret.push({});
1511
- return ret;
1642
+ addRun(state, run, i, top) {
1643
+ for (const r of state.runs) if (r.neg === run.neg && sameState(r.state, run.state)) return;
1644
+ state.runs.push(run);
1645
+ if (!run.state.match) this.add(state, run.neg.next, i, top);
1512
1646
  }
1513
- isStart() {
1514
- if (this.#root === this) return true;
1515
- if (!this.#parent?.isStart()) return false;
1516
- if (this.#parentIndex === 0) return true;
1517
- const p = this.#parent;
1518
- for (let i = 0; i < this.#parentIndex; i++) {
1519
- const pp = p.#parts[i];
1520
- if (!(pp instanceof _a && pp.type === "!")) return false;
1647
+ step(state, c, i, top) {
1648
+ const next = this.state();
1649
+ for (const th of state.threads) switch (th.t) {
1650
+ case "lit":
1651
+ if (litMatch(th, c)) this.add(next, th.next, i + 1, top);
1652
+ break;
1653
+ case "any":
1654
+ if (!this.restricted(i, top)) this.add(next, th.next, i + 1, top);
1655
+ break;
1656
+ case "class":
1657
+ if (!this.restricted(i, top) && th.re.test(c)) this.add(next, th.next, i + 1, top);
1658
+ break;
1659
+ case "star": if (!this.restricted(i, top)) this.add(next, th, i + 1, top);
1521
1660
  }
1522
- return true;
1523
- }
1524
- isEnd() {
1525
- if (this.#root === this) return true;
1526
- if (this.#parent?.type === "!") return true;
1527
- if (!this.#parent?.isEnd()) return false;
1528
- if (!this.type) return this.#parent?.isEnd();
1529
- /* c8 ignore start */
1530
- const pl = this.#parent ? this.#parent.#parts.length : 0;
1531
- /* c8 ignore stop */
1532
- return this.#parentIndex === pl - 1;
1533
- }
1534
- copyIn(part) {
1535
- if (typeof part === "string") this.push(part);
1536
- else this.push(part.clone(this));
1537
- }
1538
- clone(parent) {
1539
- const c = new _a(this.type, parent);
1540
- for (const p of this.#parts) c.copyIn(p);
1541
- return c;
1542
- }
1543
- static #parseAST(str, ast, pos, opt, extDepth) {
1544
- const maxDepth = opt.maxExtglobRecursion ?? 2;
1545
- let escaping = false;
1546
- let inBrace = false;
1547
- let braceStart = -1;
1548
- let braceNeg = false;
1549
- if (ast.type === null) {
1550
- let i = pos;
1551
- let acc = "";
1552
- while (i < str.length) {
1553
- const c = str.charAt(i++);
1554
- if (escaping || c === "\\") {
1555
- escaping = !escaping;
1556
- acc += c;
1557
- continue;
1558
- }
1559
- if (inBrace) {
1560
- if (i === braceStart + 1) {
1561
- if (c === "^" || c === "!") braceNeg = true;
1562
- } else if (c === "]" && !(i === braceStart + 2 && braceNeg)) inBrace = false;
1563
- acc += c;
1564
- continue;
1565
- } else if (c === "[") {
1566
- inBrace = true;
1567
- braceStart = i;
1568
- braceNeg = false;
1569
- acc += c;
1570
- continue;
1571
- }
1572
- if (!opt.noext && isExtglobType(c) && str.charAt(i) === "(" && extDepth <= maxDepth) {
1573
- ast.push(acc);
1574
- acc = "";
1575
- const ext = new _a(c, ast);
1576
- i = _a.#parseAST(str, ext, i, opt, extDepth + 1);
1577
- ast.push(ext);
1578
- continue;
1579
- }
1580
- acc += c;
1581
- }
1582
- ast.push(acc);
1583
- return i;
1584
- }
1585
- let i = pos + 1;
1586
- let part = new _a(null, ast);
1587
- const parts = [];
1588
- let acc = "";
1589
- while (i < str.length) {
1590
- const c = str.charAt(i++);
1591
- if (escaping || c === "\\") {
1592
- escaping = !escaping;
1593
- acc += c;
1594
- continue;
1595
- }
1596
- if (inBrace) {
1597
- if (i === braceStart + 1) {
1598
- if (c === "^" || c === "!") braceNeg = true;
1599
- } else if (c === "]" && !(i === braceStart + 2 && braceNeg)) inBrace = false;
1600
- acc += c;
1601
- continue;
1602
- } else if (c === "[") {
1603
- inBrace = true;
1604
- braceStart = i;
1605
- braceNeg = false;
1606
- acc += c;
1661
+ if (!this.restricted(i, top)) for (const run of state.runs) {
1662
+ if (run.state.dead) {
1663
+ this.addRun(next, run, i + 1, top);
1607
1664
  continue;
1608
1665
  }
1609
- /* c8 ignore stop */
1610
- if (!opt.noext && isExtglobType(c) && str.charAt(i) === "(" && (extDepth <= maxDepth || ast && ast.#canAdoptType(c))) {
1611
- const depthAdd = ast && ast.#canAdoptType(c) ? 0 : 1;
1612
- part.push(acc);
1613
- acc = "";
1614
- const ext = new _a(c, part);
1615
- part.push(ext);
1616
- i = _a.#parseAST(str, ext, i, opt, extDepth + depthAdd);
1617
- continue;
1618
- }
1619
- if (c === "|") {
1620
- part.push(acc);
1621
- acc = "";
1622
- parts.push(part);
1623
- part = new _a(null, ast);
1624
- continue;
1625
- }
1626
- if (c === ")") {
1627
- if (acc === "" && ast.#parts.length === 0) ast.#emptyExt = true;
1628
- part.push(acc);
1629
- acc = "";
1630
- ast.push(...parts, part);
1631
- return i;
1632
- }
1633
- acc += c;
1634
- }
1635
- ast.type = null;
1636
- ast.#hasMagic = void 0;
1637
- ast.#parts = [str.substring(pos - 1)];
1638
- return i;
1639
- }
1640
- #canAdoptWithSpace(child) {
1641
- return this.#canAdopt(child, adoptionWithSpaceMap);
1642
- }
1643
- #canAdopt(child, map = adoptionMap) {
1644
- if (!child || typeof child !== "object" || child.type !== null || child.#parts.length !== 1 || this.type === null) return false;
1645
- const gc = child.#parts[0];
1646
- if (!gc || typeof gc !== "object" || gc.type === null) return false;
1647
- return this.#canAdoptType(gc.type, map);
1648
- }
1649
- #canAdoptType(c, map = adoptionAnyMap) {
1650
- return !!map.get(this.type)?.includes(c);
1651
- }
1652
- #adoptWithSpace(child, index) {
1653
- const gc = child.#parts[0];
1654
- const blank = new _a(null, gc, this.options);
1655
- blank.#parts.push("");
1656
- gc.push(blank);
1657
- this.#adopt(child, index);
1658
- }
1659
- #adopt(child, index) {
1660
- const gc = child.#parts[0];
1661
- this.#parts.splice(index, 1, ...gc.#parts);
1662
- for (const p of gc.#parts) if (typeof p === "object") p.#parent = this;
1663
- this.#toString = void 0;
1664
- }
1665
- #canUsurpType(c) {
1666
- return !!usurpMap.get(this.type)?.has(c);
1667
- }
1668
- #canUsurp(child) {
1669
- if (!child || typeof child !== "object" || child.type !== null || child.#parts.length !== 1 || this.type === null || this.#parts.length !== 1) return false;
1670
- const gc = child.#parts[0];
1671
- if (!gc || typeof gc !== "object" || gc.type === null) return false;
1672
- return this.#canUsurpType(gc.type);
1673
- }
1674
- #usurp(child) {
1675
- const m = usurpMap.get(this.type);
1676
- const gc = child.#parts[0];
1677
- const nt = m?.get(gc.type);
1678
- /* c8 ignore start - impossible */
1679
- if (!nt) return false;
1680
- /* c8 ignore stop */
1681
- this.#parts = gc.#parts;
1682
- for (const p of this.#parts) if (typeof p === "object") p.#parent = this;
1683
- this.type = nt;
1684
- this.#toString = void 0;
1685
- this.#emptyExt = false;
1686
- }
1687
- static fromGlob(pattern, options = {}) {
1688
- const ast = new _a(null, void 0, options);
1689
- _a.#parseAST(pattern, ast, 0, options, 0);
1690
- return ast;
1691
- }
1692
- toMMPattern() {
1693
- /* c8 ignore start */
1694
- if (this !== this.#root) return this.#root.toMMPattern();
1695
- /* c8 ignore stop */
1696
- const glob = this.toString();
1697
- const [re, body, hasMagic, uflag] = this.toRegExpSource();
1698
- if (!(hasMagic || this.#hasMagic || this.#options.nocase && !this.#options.nocaseMagicOnly && glob.toUpperCase() !== glob.toLowerCase())) return body;
1699
- const flags = (this.#options.nocase ? "i" : "") + (uflag ? "u" : "");
1700
- return Object.assign(new RegExp(`^${re}$`, flags), {
1701
- _src: re,
1702
- _glob: glob
1703
- });
1666
+ const sub = this.step(run.state, c, i, false);
1667
+ this.addRun(next, {
1668
+ t: "run",
1669
+ neg: run.neg,
1670
+ state: sub
1671
+ }, i + 1, top);
1672
+ }
1673
+ return this.done(next);
1704
1674
  }
1705
- get options() {
1706
- return this.#options;
1707
- }
1708
- toRegExpSource(allowDot) {
1709
- const dot = allowDot ?? !!this.#options.dot;
1710
- if (this.#root === this) {
1711
- this.#flatten();
1712
- this.#fillNegs();
1713
- }
1714
- if (!isExtglobAST(this)) {
1715
- const noEmpty = this.isStart() && this.isEnd() && !this.#parts.some((s) => typeof s !== "string");
1716
- const src = this.#parts.map((p) => {
1717
- const [re, _, hasMagic, uflag] = typeof p === "string" ? _a.#parseGlob(p, this.#hasMagic, noEmpty) : p.toRegExpSource(allowDot);
1718
- this.#hasMagic = this.#hasMagic || hasMagic;
1719
- this.#uflag = this.#uflag || uflag;
1720
- return re;
1721
- }).join("");
1722
- let start = "";
1723
- if (this.isStart()) {
1724
- if (typeof this.#parts[0] === "string") {
1725
- if (!(this.#parts.length === 1 && justDots.has(this.#parts[0]))) {
1726
- const aps = addPatternStart;
1727
- const needNoTrav = dot && aps.has(src.charAt(0)) || src.startsWith("\\.") && aps.has(src.charAt(2)) || src.startsWith("\\.\\.") && aps.has(src.charAt(4));
1728
- const needNoDot = !dot && !allowDot && aps.has(src.charAt(0));
1729
- start = needNoTrav ? startNoTraversal : needNoDot ? startNoDot : "";
1730
- }
1731
- }
1675
+ };
1676
+ const stateKey = (state) => {
1677
+ const ids = state.ids.join();
1678
+ if (!state.runs.length) return ids;
1679
+ return `${ids}|${state.runs.map((r) => `${r.neg.id}(${stateKey(r.state)})`).sort().join("|")}`;
1680
+ };
1681
+ const DFA_BUDGET = 1 << 18;
1682
+ var Dfa = class {
1683
+ #start;
1684
+ #states = /* @__PURE__ */ new Map();
1685
+ #size = 0;
1686
+ #plain;
1687
+ #dotStart;
1688
+ #sim;
1689
+ #dotSim;
1690
+ constructor(start, marks) {
1691
+ this.#start = start;
1692
+ this.#sim = new Sim(false, false, marks);
1693
+ this.#dotSim = new Sim(false, true, marks);
1694
+ }
1695
+ #make(state) {
1696
+ return {
1697
+ state,
1698
+ match: state.match,
1699
+ dead: state.dead,
1700
+ next: /* @__PURE__ */ new Map()
1701
+ };
1702
+ }
1703
+ #intern(state) {
1704
+ const key = stateKey(state);
1705
+ const found = this.#states.get(key);
1706
+ if (found) return found;
1707
+ if (this.#size > DFA_BUDGET) this.#clear();
1708
+ const d = this.#make(state);
1709
+ this.#states.set(key, d);
1710
+ this.#size += key.length + 1;
1711
+ return d;
1712
+ }
1713
+ #clear() {
1714
+ this.#states.clear();
1715
+ this.#size = 0;
1716
+ this.#plain = void 0;
1717
+ this.#dotStart = void 0;
1718
+ }
1719
+ start(dotStart) {
1720
+ if (dotStart) {
1721
+ if (this.#dotStart) return this.#dotStart;
1722
+ const state = this.#dotSim.state();
1723
+ this.#dotSim.add(state, this.#start, 0, true);
1724
+ return this.#dotStart = this.#make(this.#dotSim.done(state));
1725
+ }
1726
+ if (this.#plain) return this.#plain;
1727
+ const state = this.#sim.state();
1728
+ this.#sim.add(state, this.#start, 0, true);
1729
+ return this.#plain = this.#intern(this.#sim.done(state));
1730
+ }
1731
+ next(d, c) {
1732
+ const code = c.charCodeAt(0);
1733
+ const found = code < 128 ? void 0 : d.next.get(c);
1734
+ if (found) return found;
1735
+ 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));
1736
+ if (code < 128) {
1737
+ if (!d.ascii) {
1738
+ d.ascii = new Array(128);
1739
+ this.#size += 128;
1732
1740
  }
1733
- let end = "";
1734
- if (this.isEnd() && this.#root.#filledNegs && this.#parent?.type === "!") end = "(?:$|\\/)";
1735
- return [
1736
- start + src + end,
1737
- unescape(src),
1738
- this.#hasMagic = !!this.#hasMagic,
1739
- this.#uflag
1740
- ];
1741
- }
1742
- const repeated = this.type === "*" || this.type === "+";
1743
- const start = this.type === "!" ? "(?:(?!(?:" : "(?:";
1744
- let body = this.#partsToRegExp(dot);
1745
- if (this.isStart() && this.isEnd() && !body && this.type !== "!") {
1746
- const s = this.toString();
1747
- const me = this;
1748
- me.#parts = [s];
1749
- me.type = null;
1750
- me.#hasMagic = void 0;
1751
- return [
1752
- s,
1753
- unescape(this.toString()),
1754
- false,
1755
- false
1756
- ];
1741
+ d.ascii[code] = n;
1742
+ } else d.next.set(c, n);
1743
+ this.#size++;
1744
+ return n;
1745
+ }
1746
+ };
1747
+ const linear = (start) => {
1748
+ const nodes = [];
1749
+ for (let n = start; n.t !== "match"; n = n.next) {
1750
+ if (n.t === "split" || n.t === "neg") return void 0;
1751
+ nodes.push(n);
1752
+ }
1753
+ return nodes;
1754
+ };
1755
+ const testLinear = (nodes, chars, start, end) => {
1756
+ let ni = 0;
1757
+ let ci = start;
1758
+ let starNi = -1;
1759
+ let starCi = 0;
1760
+ while (ci < end) {
1761
+ const n = nodes[ni];
1762
+ if (n?.t === "star") {
1763
+ starNi = ni++;
1764
+ starCi = ci;
1765
+ continue;
1757
1766
  }
1758
- let bodyDotAllowed = !repeated || allowDot || dot || false ? "" : this.#partsToRegExp(true);
1759
- if (bodyDotAllowed === body) bodyDotAllowed = "";
1760
- if (bodyDotAllowed) body = `(?:${body})(?:${bodyDotAllowed})*?`;
1761
- let final = "";
1762
- if (this.type === "!" && this.#emptyExt) final = (this.isStart() && !dot ? startNoDot : "") + starNoEmpty;
1763
- else {
1764
- const close = this.type === "!" ? "))" + (this.isStart() && !dot && !allowDot ? startNoDot : "") + "[^/]*?)" : this.type === "@" ? ")" : this.type === "?" ? ")?" : this.type === "+" && bodyDotAllowed ? ")" : this.type === "*" && bodyDotAllowed ? `)?` : `)${this.type}`;
1765
- final = start + body + close;
1767
+ const c = chars[ci];
1768
+ if (n && (n.t === "any" || n.t === "lit" && litMatch(n, c) || n.t === "class" && n.re.test(c))) {
1769
+ ni++;
1770
+ ci++;
1771
+ continue;
1766
1772
  }
1767
- return [
1768
- final,
1769
- unescape(body),
1770
- this.#hasMagic = !!this.#hasMagic,
1771
- this.#uflag
1772
- ];
1773
+ if (starNi === -1) return false;
1774
+ ni = starNi + 1;
1775
+ ci = ++starCi;
1773
1776
  }
1774
- #flatten() {
1775
- if (!isExtglobAST(this)) {
1776
- for (const p of this.#parts) if (typeof p === "object") p.#flatten();
1777
+ while (nodes[ni]?.t === "star") ni++;
1778
+ return ni === nodes.length;
1779
+ };
1780
+ const lengths = (items) => {
1781
+ let min = 0;
1782
+ let max = 0;
1783
+ for (const it of items) {
1784
+ const [lo, hi] = itemLengths(it);
1785
+ min += lo;
1786
+ max += hi;
1787
+ }
1788
+ return [min, max];
1789
+ };
1790
+ const itemLengths = (it) => {
1791
+ if (it.t === "star") return [0, Infinity];
1792
+ if (it.t !== "ext") return [1, 1];
1793
+ if (it.type === "!") return [0, Infinity];
1794
+ const alts = it.alts.map(lengths);
1795
+ const min = Math.min(...alts.map((a) => a[0]));
1796
+ const max = Math.max(...alts.map((a) => a[1]));
1797
+ const loop = max === 0 ? 0 : Infinity;
1798
+ return it.type === "@" ? [min, max] : it.type === "?" ? [0, max] : it.type === "*" ? [0, loop] : [min, loop];
1799
+ };
1800
+ const hasAffix = (lits, chars, start) => {
1801
+ for (let j = 0; j < lits.length; j++) if (!litMatch(lits[j], chars[start + j])) return false;
1802
+ return true;
1803
+ };
1804
+ const slashOrSurrogate = /[/\ud800-\udfff]/;
1805
+ const surrogate = /[\ud800-\udfff]/;
1806
+ const codePoints = (s) => surrogate.test(s) ? [...s] : s;
1807
+ const noSlash = (s) => {
1808
+ if (s.includes("/")) throw new Error("can only match a single path portion, got: " + s);
1809
+ };
1810
+ var Matcher = class {
1811
+ pattern;
1812
+ options;
1813
+ #start;
1814
+ #size;
1815
+ #marks;
1816
+ #dotsSim;
1817
+ #literal;
1818
+ #literalFold = false;
1819
+ #literalRe;
1820
+ #linear;
1821
+ #wild = false;
1822
+ #min = 0;
1823
+ #max = Infinity;
1824
+ #prefix = [];
1825
+ #suffix = [];
1826
+ #prefixStr;
1827
+ #suffixStr;
1828
+ #affix = false;
1829
+ #dfa;
1830
+ #form;
1831
+ constructor(pattern, options = {}) {
1832
+ if (pattern.includes("/")) throw new Error("can only match a single path portion, got pattern: " + pattern);
1833
+ this.pattern = pattern;
1834
+ this.options = options;
1835
+ const { nocase = false, noext = false, normalize: n } = options;
1836
+ this.#form = n === true ? "NFC" : n || void 0;
1837
+ const literal = /^[?*+@]\(\)$/.test(pattern);
1838
+ const toks = tokenize(pattern, nocase, noext || literal, this.#form, options.rangeMark);
1839
+ let [items] = build$1(toks, pair(toks), 0, toks.length, true);
1840
+ if (this.#form) items = normalize$1(items, this.#form);
1841
+ const [start, size] = compile(items, nocase);
1842
+ this.#start = start;
1843
+ this.#size = size;
1844
+ if (items.every((it) => it.t === "lit")) {
1845
+ this.#literal = items.map((it) => it.ch).join("");
1846
+ this.#literalFold = nocase;
1777
1847
  } else {
1778
- let iterations = 0;
1779
- let done = false;
1780
- do {
1781
- done = true;
1782
- for (let i = 0; i < this.#parts.length; i++) {
1783
- const c = this.#parts[i];
1784
- if (typeof c === "object") {
1785
- c.#flatten();
1786
- if (this.#canAdopt(c)) {
1787
- done = false;
1788
- this.#adopt(c, i);
1789
- } else if (this.#canAdoptWithSpace(c)) {
1790
- done = false;
1791
- this.#adoptWithSpace(c, i);
1792
- } else if (this.#canUsurp(c)) {
1793
- done = false;
1794
- this.#usurp(c);
1795
- }
1796
- }
1797
- }
1798
- } while (!done && ++iterations < 10);
1799
- }
1800
- this.#toString = void 0;
1801
- }
1802
- #partsToRegExp(dot) {
1803
- return this.#parts.map((p) => {
1804
- /* c8 ignore start */
1805
- if (typeof p === "string") throw new Error("string type in extglob ast??");
1806
- /* c8 ignore stop */
1807
- const [re, _, _hasMagic, uflag] = p.toRegExpSource(dot);
1808
- this.#uflag = this.#uflag || uflag;
1809
- return re;
1810
- }).filter((p) => !(this.isStart() && this.isEnd()) || !!p).join("|");
1811
- }
1812
- static #parseGlob(glob, hasMagic, noEmpty = false) {
1813
- let escaping = false;
1814
- let re = "";
1815
- let uflag = false;
1816
- let inStar = false;
1817
- for (let i = 0; i < glob.length; i++) {
1818
- const c = glob.charAt(i);
1819
- if (escaping) {
1820
- escaping = false;
1821
- re += (reSpecials.has(c) ? "\\" : "") + c;
1822
- continue;
1848
+ const lit = (it) => it.t !== "lit" ? void 0 : nocase ? {
1849
+ ch: it.ch,
1850
+ re: foldRe(it.ch)
1851
+ } : { ch: it.ch };
1852
+ for (const it of items) {
1853
+ const l = lit(it);
1854
+ if (!l) break;
1855
+ this.#prefix.push(l);
1823
1856
  }
1824
- if (c === "*") {
1825
- if (inStar) continue;
1826
- inStar = true;
1827
- re += noEmpty && /^[*]+$/.test(glob) ? starNoEmpty : star$1;
1828
- hasMagic = true;
1829
- continue;
1830
- } else inStar = false;
1831
- if (c === "\\") {
1832
- if (i === glob.length - 1) re += "\\\\";
1833
- else escaping = true;
1834
- continue;
1857
+ for (let j = items.length - 1; j >= 0; j--) {
1858
+ const l = lit(items[j]);
1859
+ if (!l) break;
1860
+ this.#suffix.unshift(l);
1835
1861
  }
1836
- if (c === "[") {
1837
- const [src, needUflag, consumed, magic] = parseClass(glob, i);
1838
- if (consumed) {
1839
- re += src;
1840
- uflag = uflag || needUflag;
1841
- i += consumed - 1;
1842
- hasMagic = hasMagic || magic;
1843
- continue;
1844
- }
1862
+ this.#affix = !!(this.#prefix.length || this.#suffix.length);
1863
+ if (!nocase) {
1864
+ this.#prefixStr = this.#prefix.map((l) => l.ch).join("");
1865
+ this.#suffixStr = this.#suffix.map((l) => l.ch).join("");
1845
1866
  }
1846
- if (c === "?") {
1847
- re += qmark;
1848
- hasMagic = true;
1849
- continue;
1867
+ this.#linear = linear(this.#start)?.slice(this.#prefix.length, -this.#suffix.length || void 0);
1868
+ this.#wild = !!this.#linear?.every((n) => n.t === "star" || n.t === "any");
1869
+ const [min, max] = lengths(items);
1870
+ this.#min = min;
1871
+ this.#max = max;
1872
+ }
1873
+ }
1874
+ test(s) {
1875
+ if (this.#form) {
1876
+ noSlash(s);
1877
+ return this.#test(s.normalize(this.#form));
1878
+ }
1879
+ if (slashOrSurrogate.test(s)) {
1880
+ noSlash(s);
1881
+ return this.#test(s, [...s]);
1882
+ }
1883
+ return this.#test(s, s);
1884
+ }
1885
+ /**
1886
+ * The same as {@link Matcher#test}, but the string is not checked
1887
+ * for `/` chars, so the result for a string that has one is not
1888
+ * defined. Only use it for a string that is known to be one path
1889
+ * portion, such as a part of a path that was split on `/`. It can
1890
+ * be faster, because some patterns do not need to look at each char
1891
+ * of the string.
1892
+ */
1893
+ testUnchecked(s) {
1894
+ return this.#test(this.#form ? s.normalize(this.#form) : s);
1895
+ }
1896
+ #test(s, chars) {
1897
+ if (this.#literal !== void 0) return this.#literalFold ? (this.#literalRe ??= newFoldRe(this.#literal)).test(s) : s === this.#literal;
1898
+ const min = this.#min;
1899
+ const max = this.#max;
1900
+ if (chars === void 0) {
1901
+ const most = s.length;
1902
+ const least = most + 1 >> 1;
1903
+ if (most < min || least > max) return false;
1904
+ if (least < min || most > max) chars = codePoints(s);
1905
+ }
1906
+ if (chars !== void 0 && (chars.length < min || chars.length > max)) return false;
1907
+ const prefix = this.#prefix.length;
1908
+ if (this.#affix) {
1909
+ if (this.#prefixStr !== void 0 && this.#suffixStr !== void 0) {
1910
+ if (!s.startsWith(this.#prefixStr) || !s.endsWith(this.#suffixStr)) return false;
1911
+ } else {
1912
+ chars ??= codePoints(s);
1913
+ const end = chars.length - this.#suffix.length;
1914
+ if (!hasAffix(this.#prefix, chars, 0) || !hasAffix(this.#suffix, chars, end)) return false;
1850
1915
  }
1851
- re += regExpEscape$1(c);
1852
1916
  }
1853
- return [
1854
- re,
1855
- unescape(glob),
1856
- !!hasMagic,
1857
- uflag
1858
- ];
1917
+ const dotStart = !this.options.dot && s.startsWith(".");
1918
+ if (this.#linear) {
1919
+ if (s === "." || s === "..") return false;
1920
+ if (dotStart && !prefix) return false;
1921
+ if (this.#wild) return true;
1922
+ chars ??= codePoints(s);
1923
+ const end = chars.length - this.#suffix.length;
1924
+ return testLinear(this.#linear, chars, prefix, end);
1925
+ }
1926
+ chars ??= codePoints(s);
1927
+ if (s === "." || s === "..") {
1928
+ this.#marks ??= marks(this.#size);
1929
+ const sim = this.#dotsSim ??= new Sim(true, false, this.#marks);
1930
+ const start = sim.state();
1931
+ sim.add(start, this.#start, 0, true);
1932
+ let state = sim.done(start);
1933
+ for (let i = 0; i < chars.length; i++) state = sim.step(state, chars[i], i, true);
1934
+ return state.match;
1935
+ }
1936
+ this.#marks ??= marks(this.#size);
1937
+ const dfa = this.#dfa ??= new Dfa(this.#start, this.#marks);
1938
+ let d = dfa.start(dotStart);
1939
+ const str = chars === s;
1940
+ for (let i = 0; i < chars.length; i++) {
1941
+ if (d.dead) return false;
1942
+ const code = str ? s.charCodeAt(i) : chars[i].charCodeAt(0);
1943
+ d = d.ascii?.[code] ?? dfa.next(d, chars[i]);
1944
+ }
1945
+ return d.match;
1946
+ }
1947
+ /** a readable listing of the state machine */
1948
+ toString() {
1949
+ return show(this.#start);
1859
1950
  }
1860
1951
  };
1861
- _a = AST;
1862
- //#endregion
1863
- //#region ../../node_modules/.pnpm/minimatch@10.2.6/node_modules/minimatch/dist/esm/escape.js
1952
+ // ../../node_modules/.pnpm/minimatch@11.0.9/node_modules/minimatch/dist/esm/assert-valid-pattern.js
1953
+ const MAX_PATTERN_LENGTH = 65536;
1954
+ const assertValidPattern = (pattern) => {
1955
+ if (typeof pattern !== "string") throw new TypeError("invalid pattern");
1956
+ if (pattern.length > MAX_PATTERN_LENGTH) throw new TypeError("pattern is too long");
1957
+ };
1958
+ // ../../node_modules/.pnpm/minimatch@11.0.9/node_modules/minimatch/dist/esm/escape.js
1864
1959
  /**
1865
1960
  * Escape all magic characters in a glob pattern.
1866
1961
  *
@@ -1872,68 +1967,154 @@ _a = AST;
1872
1967
  *
1873
1968
  * If the {@link MinimatchOptions.magicalBraces} option is used,
1874
1969
  * then braces (`{` and `}`) will be escaped.
1970
+ *
1971
+ * A leading `#` or `!` is escaped as well, so that the result is never a
1972
+ * comment or a negated pattern. In `windowsPathsNoEscape` mode, a leading
1973
+ * `!` is written as `@(!)`, because `[!` starts a negated class.
1875
1974
  */
1876
1975
  const escape = (s, { windowsPathsNoEscape = false, magicalBraces = false } = {}) => {
1877
- if (magicalBraces) return windowsPathsNoEscape ? s.replace(/[?*()[\]{}]/g, "[$&]") : s.replace(/[?*()[\]\\{}]/g, "\\$&");
1878
- return windowsPathsNoEscape ? s.replace(/[?*()[\]]/g, "[$&]") : s.replace(/[?*()[\]\\]/g, "\\$&");
1879
- };
1880
- //#endregion
1881
- //#region ../../node_modules/.pnpm/minimatch@10.2.6/node_modules/minimatch/dist/esm/index.js
1882
- const minimatch = (p, pattern, options = {}) => {
1883
- assertValidPattern(pattern);
1884
- if (!options.nocomment && pattern.charAt(0) === "#") return false;
1885
- return new Minimatch(pattern, options).match(p);
1976
+ const e = magicalBraces ? windowsPathsNoEscape ? s.replace(/[?*()[\]{}]/g, "[$&]") : s.replace(/[?*()[\]\\{}]/g, "\\$&") : windowsPathsNoEscape ? s.replace(/[?*()[\]]/g, "[$&]") : s.replace(/[?*()[\]\\]/g, "\\$&");
1977
+ const c = e.charAt(0);
1978
+ if (c === "#") return (windowsPathsNoEscape ? "[#]" : "\\#") + e.slice(1);
1979
+ if (c === "!") return (windowsPathsNoEscape ? "@(!)" : "\\!") + e.slice(1);
1980
+ return e;
1886
1981
  };
1887
- const starDotExtRE = /^\*+([^+@!?*[(]*)$/;
1888
- const starDotExtTest = (ext) => (f) => !f.startsWith(".") && f.endsWith(ext);
1889
- const starDotExtTestDot = (ext) => (f) => f.endsWith(ext);
1890
- const starDotExtTestNocase = (ext) => {
1891
- ext = ext.toLowerCase();
1892
- return (f) => !f.startsWith(".") && f.toLowerCase().endsWith(ext);
1893
- };
1894
- const starDotExtTestNocaseDot = (ext) => {
1895
- ext = ext.toLowerCase();
1896
- return (f) => f.toLowerCase().endsWith(ext);
1897
- };
1898
- const starDotStarRE = /^\*+\.\*+$/;
1899
- const starDotStarTest = (f) => !f.startsWith(".") && f.includes(".");
1900
- const starDotStarTestDot = (f) => f !== "." && f !== ".." && f.includes(".");
1901
- const dotStarRE = /^\.\*+$/;
1902
- const dotStarTest = (f) => f !== "." && f !== ".." && f.startsWith(".");
1903
- const starRE = /^\*+$/;
1904
- const starTest = (f) => f.length !== 0 && !f.startsWith(".");
1905
- const starTestDot = (f) => f.length !== 0 && f !== "." && f !== "..";
1906
- const qmarksRE = /^\?+([^+@!?*[(]*)?$/;
1907
- const qmarksTestNocase = ([$0, ext = ""]) => {
1908
- const noext = qmarksTestNoExt([$0]);
1909
- if (!ext) return noext;
1910
- ext = ext.toLowerCase();
1911
- return (f) => noext(f) && f.toLowerCase().endsWith(ext);
1982
+ // ../../node_modules/.pnpm/minimatch@11.0.9/node_modules/minimatch/dist/esm/unescape.js
1983
+ /**
1984
+ * Un-escape a string that has been escaped with {@link escape}.
1985
+ *
1986
+ * If the {@link MinimatchOptions.windowsPathsNoEscape} option is used, then
1987
+ * square-bracket escapes are removed, but not backslash escapes.
1988
+ *
1989
+ * For example, it will turn the string `'[*]'` into `*`, but it will not
1990
+ * turn `'\\*'` into `'*'`, because `\` is a path separator in
1991
+ * `windowsPathsNoEscape` mode.
1992
+ *
1993
+ * When `windowsPathsNoEscape` is not set, then both square-bracket escapes and
1994
+ * backslash escapes are removed.
1995
+ *
1996
+ * Slashes (and backslashes in `windowsPathsNoEscape` mode) cannot be escaped
1997
+ * or unescaped.
1998
+ *
1999
+ * When `magicalBraces` is not set, escapes of braces (`{` and `}`) will not be
2000
+ * unescaped.
2001
+ */
2002
+ const unescape = (s, { windowsPathsNoEscape = false, magicalBraces = true } = {}) => {
2003
+ if (windowsPathsNoEscape && s.startsWith("@(!)")) return "!" + unescape(s.slice(4), {
2004
+ windowsPathsNoEscape,
2005
+ magicalBraces
2006
+ });
2007
+ if (magicalBraces) return windowsPathsNoEscape ? s.replace(/\[([^/\\])\]/g, "$1") : s.replace(/((?!\\).|^)\[([^/\\])\]/g, "$1$2").replace(/\\([^/])/g, "$1");
2008
+ return windowsPathsNoEscape ? s.replace(/\[([^/\\{}])\]/g, "$1") : s.replace(/((?!\\).|^)\[([^/\\{}])\]/g, "$1$2").replace(/\\([^/{}])/g, "$1");
1912
2009
  };
1913
- const qmarksTestNocaseDot = ([$0, ext = ""]) => {
1914
- const noext = qmarksTestNoExtDot([$0]);
1915
- if (!ext) return noext;
1916
- ext = ext.toLowerCase();
1917
- return (f) => noext(f) && f.toLowerCase().endsWith(ext);
2010
+ // ../../node_modules/.pnpm/minimatch@11.0.9/node_modules/minimatch/dist/esm/index.js
2011
+ const DEFAULT_BRACE_EXPAND_MAX = 1e5;
2012
+ const DEFAULT_GLOB_STAR_RECURSION_MAX = 200;
2013
+ const AWE_KEY = "allowWindowsEscape";
2014
+ const minimatch = (p, pattern, options) => {
2015
+ assertValidPattern(pattern);
2016
+ if (!options?.nocomment && pattern.charAt(0) === "#") return false;
2017
+ return cachedMinimatch(pattern, options).match(p);
1918
2018
  };
1919
- const qmarksTestDot = ([$0, ext = ""]) => {
1920
- const noext = qmarksTestNoExtDot([$0]);
1921
- return !ext ? noext : (f) => noext(f) && f.endsWith(ext);
2019
+ let cache = /* @__PURE__ */ new Map();
2020
+ let oldCache = /* @__PURE__ */ new Map();
2021
+ let cacheSize = 0;
2022
+ let cacheTotalWeight = 0;
2023
+ const cacheMax = 256;
2024
+ const cacheMaxWeight = 32768;
2025
+ const cacheMaxEntryWeight = 4096;
2026
+ const cacheWeight = (mm) => {
2027
+ let w = mm.pattern.length;
2028
+ for (const s of mm.globSet) {
2029
+ w += s.length + 1;
2030
+ if (w > cacheMaxEntryWeight) break;
2031
+ }
2032
+ return w;
1922
2033
  };
1923
- const qmarksTest = ([$0, ext = ""]) => {
1924
- const noext = qmarksTestNoExt([$0]);
1925
- return !ext ? noext : (f) => noext(f) && f.endsWith(ext);
2034
+ const tri = (v) => v === void 0 ? 0 : v ? 2 : 1;
2035
+ const booleanWeights = new Map(Object.keys({
2036
+ nobrace: 0,
2037
+ nocomment: 0,
2038
+ nonegate: 0,
2039
+ noglobstar: 0,
2040
+ noext: 0,
2041
+ nonull: 0,
2042
+ partial: 0,
2043
+ dot: 0,
2044
+ nocase: 0,
2045
+ nocaseMagicOnly: 0,
2046
+ magicalBraces: 0,
2047
+ matchBase: 0,
2048
+ flipNegate: 0,
2049
+ preserveMultipleSlashes: 0,
2050
+ windowsNoMagicRoot: 0
2051
+ }).map((k, i) => [k, 24 * 3 ** i]));
2052
+ const optionsKey = (o) => {
2053
+ let n = 0;
2054
+ let wpe = false;
2055
+ for (const k in o) {
2056
+ const v = o[k];
2057
+ switch (k) {
2058
+ case "windowsPathsNoEscape":
2059
+ if (v) wpe = true;
2060
+ break;
2061
+ case AWE_KEY:
2062
+ if (v === false) wpe = true;
2063
+ break;
2064
+ case "platform": {
2065
+ const p = v || defaultPlatform;
2066
+ if (p === defaultPlatform) break;
2067
+ if (p === "darwin") n += 3;
2068
+ else if (p === "win32") n += 6;
2069
+ else if (p === "linux") n += 9;
2070
+ else return JSON.stringify(o);
2071
+ break;
2072
+ }
2073
+ case "optimizationLevel":
2074
+ if (v === void 0) break;
2075
+ n += v >= 2 ? 1 : v >= 1 ? 0 : 2;
2076
+ break;
2077
+ case "braceExpandMax":
2078
+ if (v !== void 0 && v !== DEFAULT_BRACE_EXPAND_MAX) return JSON.stringify(o);
2079
+ break;
2080
+ case "maxGlobstarRecursion":
2081
+ if (v !== void 0 && v !== DEFAULT_GLOB_STAR_RECURSION_MAX) return JSON.stringify(o);
2082
+ break;
2083
+ case "normalize":
2084
+ if (v !== void 0) return JSON.stringify(o);
2085
+ break;
2086
+ default: n += (booleanWeights.get(k) ?? 0) * tri(v);
2087
+ }
2088
+ }
2089
+ return wpe ? n + 12 : n;
1926
2090
  };
1927
- const qmarksTestNoExt = ([$0]) => {
1928
- const len = $0.length;
1929
- return (f) => f.length === len && !f.startsWith(".");
2091
+ const copyOptions = (o) => {
2092
+ const copy = {};
2093
+ for (const k in o) copy[k] = o[k];
2094
+ return copy;
1930
2095
  };
1931
- const qmarksTestNoExtDot = ([$0]) => {
1932
- const len = $0.length;
1933
- return (f) => f.length === len && f !== "." && f !== "..";
2096
+ const cachedMinimatch = (pattern, options) => {
2097
+ const key = options ? optionsKey(options) : 0;
2098
+ let mm = cache.get(key)?.get(pattern);
2099
+ if (mm) return mm;
2100
+ mm = oldCache.get(key)?.get(pattern) ?? new Minimatch(pattern, copyOptions(options));
2101
+ const weight = cacheWeight(mm);
2102
+ if (weight > cacheMaxEntryWeight) return mm;
2103
+ if (cacheSize >= cacheMax || cacheTotalWeight + weight > cacheMaxWeight) {
2104
+ oldCache = cache;
2105
+ cache = /* @__PURE__ */ new Map();
2106
+ cacheSize = 0;
2107
+ cacheTotalWeight = 0;
2108
+ }
2109
+ let byPattern = cache.get(key);
2110
+ if (!byPattern) cache.set(key, byPattern = /* @__PURE__ */ new Map());
2111
+ byPattern.set(pattern, mm);
2112
+ cacheSize++;
2113
+ cacheTotalWeight += weight;
2114
+ return mm;
1934
2115
  };
1935
2116
  /* c8 ignore start */
1936
- const defaultPlatform = typeof process === "object" && process ? typeof process.env === "object" && process.env && process.env.__MINIMATCH_TESTING_PLATFORM__ || process.platform : "posix";
2117
+ const defaultPlatform = typeof process === "object" && process ? process.env?.__MINIMATCH_TESTING_PLATFORM__ || process.platform : "posix";
1937
2118
  const path = {
1938
2119
  win32: { sep: "\\" },
1939
2120
  posix: { sep: "/" }
@@ -1941,10 +2122,10 @@ const path = {
1941
2122
  minimatch.sep = defaultPlatform === "win32" ? path.win32.sep : path.posix.sep;
1942
2123
  const GLOBSTAR = Symbol("globstar **");
1943
2124
  minimatch.GLOBSTAR = GLOBSTAR;
1944
- const star = "[^/]*?";
1945
- const twoStarDot = "(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?";
1946
- const twoStarNoDot = "(?:(?!(?:\\/|^)\\.).)*?";
1947
- const filter = (pattern, options = {}) => (p) => minimatch(p, pattern, options);
2125
+ const filter = (pattern, options) => {
2126
+ let mm;
2127
+ return (p) => (mm ??= cachedMinimatch(pattern, options)).match(p);
2128
+ };
1948
2129
  minimatch.filter = filter;
1949
2130
  const ext = (a, b = {}) => Object.assign({}, a, b);
1950
2131
  const defaults = (def) => {
@@ -1960,21 +2141,10 @@ const defaults = (def) => {
1960
2141
  return orig.defaults(ext(def, options)).Minimatch;
1961
2142
  }
1962
2143
  },
1963
- AST: class AST extends orig.AST {
1964
- /* c8 ignore start */
1965
- constructor(type, parent, options = {}) {
1966
- super(type, parent, ext(def, options));
1967
- }
1968
- /* c8 ignore stop */
1969
- static fromGlob(pattern, options = {}) {
1970
- return orig.AST.fromGlob(pattern, ext(def, options));
1971
- }
1972
- },
1973
2144
  unescape: (s, options = {}) => orig.unescape(s, ext(def, options)),
1974
2145
  escape: (s, options = {}) => orig.escape(s, ext(def, options)),
1975
2146
  filter: (pattern, options = {}) => orig.filter(pattern, ext(def, options)),
1976
2147
  defaults: (options) => orig.defaults(ext(def, options)),
1977
- makeRe: (pattern, options = {}) => orig.makeRe(pattern, ext(def, options)),
1978
2148
  braceExpand: (pattern, options = {}) => orig.braceExpand(pattern, ext(def, options)),
1979
2149
  match: (list, pattern, options = {}) => orig.match(list, pattern, ext(def, options)),
1980
2150
  sep: orig.sep,
@@ -1985,11 +2155,27 @@ minimatch.defaults = defaults;
1985
2155
  const braceExpand = (pattern, options = {}) => {
1986
2156
  assertValidPattern(pattern);
1987
2157
  if (options.nobrace || !/\{(?:(?!\{).)*\}/.test(pattern)) return [pattern];
1988
- return expand(pattern, { max: options.braceExpandMax });
2158
+ let p = pattern.replace(/\\\\/g, "\\\\\\\\");
2159
+ if (options.windowsPathsNoEscape || options[AWE_KEY] === false) p = p.replace(/\[([{}])\]/g, "[\\$1]");
2160
+ return expand(p, { max: options.braceExpandMax });
1989
2161
  };
1990
2162
  minimatch.braceExpand = braceExpand;
1991
- const makeRe = (pattern, options = {}) => new Minimatch(pattern, options).makeRe();
1992
- minimatch.makeRe = makeRe;
2163
+ const RANGE_MIN = 100;
2164
+ const rangeRe = /(?<![\\$])\{(-?\d+)\.\.(-?\d+)\}/g;
2165
+ const inRepeatOrNegExt = (portion, mark) => {
2166
+ const stack = [];
2167
+ for (let i = 0; i < portion.length; i++) {
2168
+ const c = portion.charAt(i);
2169
+ if (c === "\\") i++;
2170
+ else if (c === mark) {
2171
+ if (stack.some((t) => t !== "@" && t !== "?")) return true;
2172
+ } else if (portion.charAt(i + 1) === "(" && "!?+*@".includes(c)) {
2173
+ stack.push(c);
2174
+ i++;
2175
+ } else if (c === ")") stack.pop();
2176
+ }
2177
+ return false;
2178
+ };
1993
2179
  const match = (list, pattern, options = {}) => {
1994
2180
  const mm = new Minimatch(pattern, options);
1995
2181
  list = list.filter((f) => mm.match(f));
@@ -1998,7 +2184,114 @@ const match = (list, pattern, options = {}) => {
1998
2184
  };
1999
2185
  minimatch.match = match;
2000
2186
  const globMagic = /[?*]|[+@!]\(.*?\)|\[|\]/;
2001
- const regExpEscape = (s) => s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
2187
+ const classEnd = (pattern, start) => {
2188
+ let i = start + 1;
2189
+ if (pattern.charAt(i) === "!" || pattern.charAt(i) === "^") i++;
2190
+ let sawStart = false;
2191
+ for (; i < pattern.length; i++) {
2192
+ const c = pattern.charAt(i);
2193
+ if (c === "]" && sawStart) return i;
2194
+ sawStart = true;
2195
+ if (c === "\\") i++;
2196
+ }
2197
+ return -1;
2198
+ };
2199
+ const literal = (pattern, noext) => {
2200
+ if (!noext && (pattern === "+()" || pattern === "@()")) return pattern;
2201
+ let lit = "";
2202
+ for (let i = 0; i < pattern.length; i++) {
2203
+ const c = pattern.charAt(i);
2204
+ if (c === "\\") lit += pattern.charAt(++i) || c;
2205
+ else if (c === "*" || c === "?") return;
2206
+ else if (c === "[") {
2207
+ const close = classEnd(pattern, i);
2208
+ if (close === -1) {
2209
+ lit += c;
2210
+ continue;
2211
+ }
2212
+ let body = pattern.slice(i + 1, close);
2213
+ if (body.startsWith("\\")) body = body.slice(1);
2214
+ if ([...body].length !== 1 || "!^".includes(pattern.charAt(i + 1))) return;
2215
+ lit += body;
2216
+ i = close;
2217
+ } else if (!noext && "+@!".includes(c) && pattern.charAt(i + 1) === "(" && pattern.includes(")", i + 2)) return;
2218
+ else lit += c;
2219
+ }
2220
+ return lit;
2221
+ };
2222
+ const MAX_EXTGLOBS = 256;
2223
+ const extglobCount = (pattern) => {
2224
+ let n = 0;
2225
+ for (let i = 0; i < pattern.length - 1; i++) {
2226
+ const c = pattern.charAt(i);
2227
+ if (c === "\\") i++;
2228
+ else if ("+@!?*".includes(c) && pattern.charAt(i + 1) === "(") {
2229
+ n++;
2230
+ i++;
2231
+ }
2232
+ }
2233
+ return n;
2234
+ };
2235
+ const assertValidExtglobs = (pattern) => {
2236
+ if (extglobCount(pattern) > MAX_EXTGLOBS) throw new TypeError("pattern has too many extglobs");
2237
+ };
2238
+ const extSafe = (pattern) => {
2239
+ if (/^[?*+@]\(\)$/.test(pattern) || pattern.includes("[:")) return false;
2240
+ let depth = 0;
2241
+ for (let i = 0; i < pattern.length; i++) {
2242
+ const c = pattern.charAt(i);
2243
+ if (c === "\\") {
2244
+ if (++i === pattern.length) return false;
2245
+ } else if (c === "[") {
2246
+ const close = classEnd(pattern, i);
2247
+ if (close !== -1) i = close;
2248
+ } else if ("+@!?*".includes(c) && pattern.charAt(i + 1) === "(") {
2249
+ depth++;
2250
+ i++;
2251
+ } else if (c === ")") {
2252
+ if (!depth--) return false;
2253
+ } else if (c === "|" && !depth) return false;
2254
+ }
2255
+ return !depth;
2256
+ };
2257
+ let lastSplit;
2258
+ let lastChecked;
2259
+ const portionMatch = (p, f) => typeof p === "string" ? f === p : f !== "" && p.testUnchecked(f);
2260
+ const endIndex = (p, last, lastStart, prev, prevStart) => portionMatch(p, last) ? lastStart : prev !== void 0 && portionMatch(p, prev) ? prevStart : -1;
2261
+ const isDots = (p) => p === "." || p === "..";
2262
+ const isDrive = (p) => typeof p === "string" && /^[a-z]:$/i.test(p);
2263
+ const isLongUNC = (p) => typeof p === "string" && /^unc$/i.test(p);
2264
+ const uncHost = (p) => {
2265
+ if (p[0] !== "" || p[1] !== "") return -1;
2266
+ const h = p[2] !== "?" ? 2 : isLongUNC(p[3]) ? 4 : -1;
2267
+ const host = p[h];
2268
+ const share = p[h + 1];
2269
+ return h !== -1 && host !== void 0 && host !== "" && host !== GLOBSTAR && share !== void 0 && share !== "" && share !== GLOBSTAR ? h : -1;
2270
+ };
2271
+ const walkable = (p, dot) => !isDots(p) && (dot || !p.startsWith("."));
2272
+ const dotPortion = (f, start, end, dot, sep) => {
2273
+ for (let k = start; k < end;) {
2274
+ if (f.charCodeAt(k) === 46) {
2275
+ if (!dot) return true;
2276
+ const n = f.charCodeAt(k + 1) === 46 ? k + 2 : k + 1;
2277
+ if (n >= end || isSep(f.charCodeAt(n), sep)) return true;
2278
+ }
2279
+ const s = nextSep(f, k, sep);
2280
+ if (s === -1) return false;
2281
+ k = s + 1;
2282
+ while (k < end && isSep(f.charCodeAt(k), sep)) k++;
2283
+ }
2284
+ return false;
2285
+ };
2286
+ const isSep = (c, sep) => sep === "/" ? c === 47 : sep === "\\" ? c === 92 : c === 47 || c === 92;
2287
+ const nextSep = (f, from, sep) => {
2288
+ if (sep !== "both") return f.indexOf(sep, from);
2289
+ const s = f.indexOf("/", from);
2290
+ const b = f.indexOf("\\", from);
2291
+ return s === -1 ? b : b === -1 ? s : Math.min(s, b);
2292
+ };
2293
+ const lastSep = (f, from, sep) => sep !== "both" ? f.lastIndexOf(sep, from) : Math.max(f.lastIndexOf("/", from), f.lastIndexOf("\\", from));
2294
+ const PENDING = {};
2002
2295
  var Minimatch = class {
2003
2296
  options;
2004
2297
  set;
@@ -2017,20 +2310,28 @@ var Minimatch = class {
2017
2310
  platform;
2018
2311
  windowsNoMagicRoot;
2019
2312
  maxGlobstarRecursion;
2020
- regexp;
2313
+ #endCheck;
2314
+ #literalCheck;
2315
+ #level2;
2316
+ #form;
2317
+ #literals = [];
2318
+ #shapes = [];
2319
+ #endRows = [];
2320
+ #matchers = /* @__PURE__ */ new Map();
2321
+ #pending = false;
2322
+ #rangeMark;
2323
+ #globstarParts = /* @__PURE__ */ new WeakMap();
2021
2324
  constructor(pattern, options = {}) {
2022
2325
  assertValidPattern(pattern);
2023
2326
  options = options || {};
2024
2327
  this.options = options;
2025
- this.maxGlobstarRecursion = options.maxGlobstarRecursion ?? 200;
2328
+ this.maxGlobstarRecursion = options.maxGlobstarRecursion ?? DEFAULT_GLOB_STAR_RECURSION_MAX;
2026
2329
  this.pattern = pattern;
2027
2330
  this.platform = options.platform || defaultPlatform;
2028
2331
  this.isWindows = this.platform === "win32";
2029
- const awe = "allowWindowsEscape";
2030
- this.windowsPathsNoEscape = !!options.windowsPathsNoEscape || options[awe] === false;
2332
+ this.windowsPathsNoEscape = !!options.windowsPathsNoEscape || options[AWE_KEY] === false;
2031
2333
  if (this.windowsPathsNoEscape) this.pattern = this.pattern.replace(/\\/g, "/");
2032
2334
  this.preserveMultipleSlashes = !!options.preserveMultipleSlashes;
2033
- this.regexp = null;
2034
2335
  this.negate = false;
2035
2336
  this.nonegate = !!options.nonegate;
2036
2337
  this.comment = false;
@@ -2041,14 +2342,45 @@ var Minimatch = class {
2041
2342
  this.globSet = [];
2042
2343
  this.globParts = [];
2043
2344
  this.set = [];
2345
+ this.#endCheck = !this.preserveMultipleSlashes;
2346
+ this.#level2 = (options.optimizationLevel ?? 1) >= 2;
2347
+ const n = options.normalize;
2348
+ this.#form = n === true ? "NFC" : n || void 0;
2044
2349
  this.make();
2350
+ const drives = this.set.map((row) => this.#rootIndex(row));
2351
+ this.#endRows = this.set.map((row, r) => this.#endCheck && row.length - 1 > drives[r]);
2352
+ this.#literals = this.set.map((row, r) => {
2353
+ const end = this.#endRows[r] ? row.length - 1 : row.length;
2354
+ const lits = row.slice(drives[r] + 1, end).filter((p) => typeof p === "string" && !!p);
2355
+ return [...new Set(lits)];
2356
+ });
2357
+ this.#literalCheck = this.#literals.some((l) => l.length);
2358
+ this.#shapes = this.set.map((row, r) => {
2359
+ const [p0, p1, p2] = row;
2360
+ if (this.#endRows[r] && row.length === 2) {
2361
+ if (p0 === GLOBSTAR && p1 !== GLOBSTAR) return "tail";
2362
+ }
2363
+ if (this.#endRows[r] && options.matchBase && row.length === 1 && p0 !== GLOBSTAR && p0 !== "") return "base";
2364
+ if (!this.#endCheck || drives[r] !== -1) return void 0;
2365
+ if (row.length === 3 && p0 === GLOBSTAR && p2 === GLOBSTAR && p1 !== GLOBSTAR && p1 !== "" && this.maxGlobstarRecursion > 0) return "mid";
2366
+ if (row.length === 2 && p1 === GLOBSTAR && p0 !== GLOBSTAR && p0 !== "") return "head";
2367
+ });
2368
+ }
2369
+ #norm(p) {
2370
+ return this.#form ? p.normalize(this.#form) : p;
2371
+ }
2372
+ #rootIndex(row) {
2373
+ if (!this.isWindows) return -1;
2374
+ if (isDrive(row[0])) return 0;
2375
+ if (row[0] === "" && row[1] === "" && row[2] === "?" && isDrive(row[3])) return 3;
2376
+ const h = uncHost(row);
2377
+ return h === -1 ? -1 : h + 1;
2045
2378
  }
2046
2379
  hasMagic() {
2047
2380
  if (this.options.magicalBraces && this.set.length > 1) return true;
2048
2381
  for (const pattern of this.set) for (const part of pattern) if (typeof part !== "string") return true;
2049
2382
  return false;
2050
2383
  }
2051
- debug(..._) {}
2052
2384
  make() {
2053
2385
  const pattern = this.pattern;
2054
2386
  const options = this.options;
@@ -2061,28 +2393,108 @@ var Minimatch = class {
2061
2393
  return;
2062
2394
  }
2063
2395
  this.parseNegate();
2064
- this.globSet = [...new Set(this.braceExpand())];
2065
- if (options.debug) this.debug = (...args) => console.error(...args);
2066
- this.debug(this.pattern, this.globSet);
2067
- const rawGlobParts = this.globSet.map((s) => this.slashSplit(s));
2396
+ this.globSet = [...new Set(this.#expandBraces())];
2397
+ const rawGlobParts = this.globSet.map((s) => this.#slashSplit(s));
2068
2398
  this.globParts = this.preprocess(rawGlobParts);
2069
- this.debug(this.pattern, this.globParts);
2399
+ this.#pending = true;
2070
2400
  let set = this.globParts.map((s, _, __) => {
2071
2401
  if (this.isWindows && this.windowsNoMagicRoot) {
2072
- const isUNC = s[0] === "" && s[1] === "" && (s[2] === "?" || !globMagic.test(s[2])) && !globMagic.test(s[3]);
2402
+ const n = s[2] === "?" && isLongUNC(s[3]) ? 6 : 4;
2403
+ const isUNC = s[0] === "" && s[1] === "" && (s[2] === "?" || !globMagic.test(s[2])) && s.slice(3, n).every((p) => !globMagic.test(p));
2073
2404
  const isDrive = /^[a-z]:/i.test(s[0]);
2074
- if (isUNC) return [...s.slice(0, 4), ...s.slice(4).map((ss) => this.parse(ss))];
2075
- else if (isDrive) return [s[0], ...s.slice(1).map((ss) => this.parse(ss))];
2405
+ if (isUNC) return [...s.slice(0, n).map((p) => this.#norm(p)), ...s.slice(n).map((ss) => this.parse(ss))];
2406
+ else if (isDrive) return [this.#norm(s[0]), ...s.slice(1).map((ss) => this.parse(ss))];
2076
2407
  }
2077
2408
  return s.map((ss) => this.parse(ss));
2078
2409
  });
2079
- this.debug(this.pattern, set);
2080
2410
  this.set = set.filter((s) => s.indexOf(false) === -1);
2081
2411
  if (this.isWindows) for (let i = 0; i < this.set.length; i++) {
2082
2412
  const p = this.set[i];
2083
- if (p[0] === "" && p[1] === "" && this.globParts[i][2] === "?" && typeof p[3] === "string" && /^[a-z]:$/i.test(p[3])) p[2] = "?";
2413
+ if (p[0] === "" && p[1] === "" && this.globParts[i][2] === "?" && (isDrive(p[3]) || isLongUNC(this.globParts[i][3]))) {
2414
+ if (isLongUNC(this.globParts[i][3])) p[3] = "UNC";
2415
+ p[2] = "?";
2416
+ }
2417
+ }
2418
+ if (!options.noext) this.mergeRows();
2419
+ this.#pending = false;
2420
+ this.set.forEach((row, i) => {
2421
+ for (let k = 0; k < row.length; k++) if (row[k] === PENDING) row[k] = this.parse(this.globParts[i][k]);
2422
+ });
2423
+ }
2424
+ mergeRows() {
2425
+ let merged = true;
2426
+ while (merged) {
2427
+ merged = false;
2428
+ if (this.set.length < 2) return;
2429
+ let keys = this.#mergeKeys();
2430
+ const len = Math.max(0, ...this.set.map((r) => r.length));
2431
+ for (let k = 0; k < len; k++) {
2432
+ const groups = /* @__PURE__ */ new Map();
2433
+ const R = this.set.length + 1;
2434
+ this.set.forEach((row, i) => {
2435
+ if (!(row[k] instanceof Matcher || row[k] === PENDING) || !extSafe(this.globParts[i][k])) return;
2436
+ const { pre, suf } = keys[i];
2437
+ const key = pre[k] * R + suf[k + 1];
2438
+ const g = groups.get(key);
2439
+ if (g) g.push(i);
2440
+ else groups.set(key, [i]);
2441
+ });
2442
+ const drop = /* @__PURE__ */ new Set();
2443
+ for (const g of groups.values()) {
2444
+ if (g.length < 2) continue;
2445
+ const [first, ...rest] = g;
2446
+ const glob = `@(${g.map((i) => this.globParts[i][k]).join("|")})`;
2447
+ if (extglobCount(glob) > MAX_EXTGLOBS) continue;
2448
+ this.globParts[first][k] = glob;
2449
+ this.set[first][k] = this.parse(glob);
2450
+ for (const i of rest) drop.add(i);
2451
+ }
2452
+ if (drop.size) {
2453
+ merged = true;
2454
+ this.set = this.set.filter((_, i) => !drop.has(i));
2455
+ this.globParts = this.globParts.filter((_, i) => !drop.has(i));
2456
+ if (this.set.length < 2) return;
2457
+ keys = this.#mergeKeys();
2458
+ }
2459
+ }
2460
+ }
2461
+ }
2462
+ #mergeKeys() {
2463
+ const partIds = /* @__PURE__ */ new Map();
2464
+ const ids = this.globParts.map((parts) => parts.map((s) => {
2465
+ let id = partIds.get(s);
2466
+ if (id === void 0) partIds.set(s, id = partIds.size);
2467
+ return id;
2468
+ }));
2469
+ const P = partIds.size;
2470
+ const len = Math.max(0, ...ids.map((r) => r.length));
2471
+ const keys = ids.map((r) => ({
2472
+ pre: [0],
2473
+ suf: new Array(r.length + 1).fill(0)
2474
+ }));
2475
+ for (let k = 0; k < len; k++) {
2476
+ const m = /* @__PURE__ */ new Map();
2477
+ ids.forEach((r, i) => {
2478
+ if (k >= r.length) return;
2479
+ const { pre } = keys[i];
2480
+ const key = pre[k] * P + r[k];
2481
+ let id = m.get(key);
2482
+ if (id === void 0) m.set(key, id = m.size + 1);
2483
+ pre.push(id);
2484
+ });
2485
+ }
2486
+ for (let k = len - 1; k >= 0; k--) {
2487
+ const m = /* @__PURE__ */ new Map();
2488
+ ids.forEach((r, i) => {
2489
+ if (k >= r.length) return;
2490
+ const { suf } = keys[i];
2491
+ const key = suf[k + 1] * P + r[k];
2492
+ let id = m.get(key);
2493
+ if (id === void 0) m.set(key, id = m.size + 1);
2494
+ suf[k] = id;
2495
+ });
2084
2496
  }
2085
- this.debug(this.pattern, this.set);
2497
+ return keys;
2086
2498
  }
2087
2499
  preprocess(globParts) {
2088
2500
  if (this.options.noglobstar) {
@@ -2109,11 +2521,12 @@ var Minimatch = class {
2109
2521
  }
2110
2522
  levelOneOptimize(globParts) {
2111
2523
  return globParts.map((parts) => {
2524
+ const root = this.#rootIndex(parts) + 1;
2112
2525
  parts = parts.reduce((set, part) => {
2113
2526
  const prev = set[set.length - 1];
2114
2527
  if (part === "**" && prev === "**") return set;
2115
2528
  if (part === "..") {
2116
- if (prev && prev !== ".." && prev !== "." && prev !== "**") {
2529
+ if (set.length > root && prev && prev !== ".." && prev !== "." && prev !== "**") {
2117
2530
  set.pop();
2118
2531
  return set;
2119
2532
  }
@@ -2124,8 +2537,120 @@ var Minimatch = class {
2124
2537
  return parts.length === 0 ? [""] : parts;
2125
2538
  });
2126
2539
  }
2127
- levelTwoFileOptimize(parts) {
2128
- if (!Array.isArray(parts)) parts = this.slashSplit(parts);
2540
+ #canMatch(f) {
2541
+ const sep = !this.isWindows || !f.includes("\\") ? "/" : f.includes("/") ? "both" : "\\";
2542
+ let ends = this.#endCheck ? 0 : -1;
2543
+ let last = "";
2544
+ let lastStart = 0;
2545
+ let prev;
2546
+ let prevStart = 0;
2547
+ const dot = !!this.options.dot;
2548
+ ROWS: for (let r = 0; r < this.set.length; r++) {
2549
+ const row = this.set[r];
2550
+ const p = row[row.length - 1];
2551
+ let end = ends !== -1 && this.#endRows[r] && p !== GLOBSTAR;
2552
+ if (end && ends === 0) {
2553
+ const i = lastSep(f, f.length, sep);
2554
+ lastStart = i + 1;
2555
+ last = f.slice(lastStart);
2556
+ if (last === "" && i >= 0) {
2557
+ let j = i;
2558
+ while (j > 0 && isSep(f.charCodeAt(j - 1), sep)) j--;
2559
+ prevStart = j === 0 ? 0 : lastSep(f, j - 1, sep) + 1;
2560
+ prev = f.slice(prevStart, j);
2561
+ }
2562
+ const resolves = this.#level2 && (isDots(last) || last === "" && prev !== void 0 && isDots(prev));
2563
+ ends = resolves ? -1 : 1;
2564
+ end = !resolves;
2565
+ }
2566
+ let tailStart = -1;
2567
+ if (end && typeof p === "string") {
2568
+ tailStart = endIndex(p, last, lastStart, prev, prevStart);
2569
+ if (tailStart === -1) continue;
2570
+ }
2571
+ if (this.#literalCheck) {
2572
+ for (const l of this.#literals[r]) if (!f.includes(l)) continue ROWS;
2573
+ }
2574
+ if (end && typeof p === "object") {
2575
+ tailStart = endIndex(p, last, lastStart, prev, prevStart);
2576
+ if (tailStart === -1) continue;
2577
+ }
2578
+ const shape = this.#shapes[r];
2579
+ if (shape === "base" && end) return "yes";
2580
+ if (shape === "tail" && end) {
2581
+ if (this.#level2 && dotPortion(f, 0, tailStart, true, sep)) return "maybe";
2582
+ if (!dotPortion(f, 0, tailStart, dot, sep)) return "yes";
2583
+ continue;
2584
+ }
2585
+ if (shape === "mid" || shape === "head") {
2586
+ const m = this.#walk(f, row, shape === "head", dot, sep);
2587
+ if (m !== "no") return m;
2588
+ continue;
2589
+ }
2590
+ return "maybe";
2591
+ }
2592
+ return "no";
2593
+ }
2594
+ #matchShape(file, row, shape) {
2595
+ const dot = !!this.options.dot;
2596
+ const n = file.length;
2597
+ if (shape === "head") {
2598
+ if (n < 2 || !portionMatch(row[0], file[0])) return false;
2599
+ for (let i = 1; i < n; i++) if (!walkable(file[i], dot)) return false;
2600
+ return true;
2601
+ }
2602
+ const x = row[1];
2603
+ if (shape === "tail") {
2604
+ let t = n - 1;
2605
+ if (!portionMatch(x, file[t])) {
2606
+ if (file[t] !== "" || n === 1 || !portionMatch(x, file[--t])) return false;
2607
+ }
2608
+ for (let i = 0; i < t; i++) if (!walkable(file[i], dot)) return false;
2609
+ return true;
2610
+ }
2611
+ for (let k = 0; k < n; k++) {
2612
+ if (portionMatch(x, file[k]) && k + 1 < n) {
2613
+ let i = k + 1;
2614
+ while (i < n && walkable(file[i], dot)) i++;
2615
+ if (i === n) return true;
2616
+ }
2617
+ if (!walkable(file[k], dot)) return false;
2618
+ }
2619
+ return false;
2620
+ }
2621
+ #walk(f, row, head, dot, sep) {
2622
+ if (this.#level2 && dotPortion(f, 0, f.length, true, sep)) return "maybe";
2623
+ const x = row[head ? 0 : 1];
2624
+ let s = 0;
2625
+ for (let e = nextSep(f, s, sep); e !== -1; e = nextSep(f, s, sep)) {
2626
+ let next = e + 1;
2627
+ while (next < f.length && isSep(f.charCodeAt(next), sep)) next++;
2628
+ 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";
2629
+ if (head || dotPortion(f, s, next, dot, sep)) return "no";
2630
+ s = next;
2631
+ }
2632
+ return "no";
2633
+ }
2634
+ #cachedSplit(f) {
2635
+ const last = lastSplit;
2636
+ return last?.f === f && last.isWindows === this.isWindows && last.preserveMultipleSlashes === this.preserveMultipleSlashes && last.normalize === this.#form ? last : void 0;
2637
+ }
2638
+ #split(f) {
2639
+ const { isWindows, preserveMultipleSlashes } = this;
2640
+ let parts = this.#slashSplit(isWindows ? f.split("\\").join("/") : f);
2641
+ const normalize = this.#form;
2642
+ if (normalize) parts = parts.map((p) => p.normalize(normalize));
2643
+ lastSplit = {
2644
+ f,
2645
+ isWindows,
2646
+ preserveMultipleSlashes,
2647
+ normalize,
2648
+ parts
2649
+ };
2650
+ return lastSplit;
2651
+ }
2652
+ #levelTwoFileOptimize(file) {
2653
+ const parts = [...file];
2129
2654
  let didSomething = false;
2130
2655
  do {
2131
2656
  didSomething = false;
@@ -2144,19 +2669,23 @@ var Minimatch = class {
2144
2669
  parts.pop();
2145
2670
  }
2146
2671
  }
2147
- let dd = 0;
2672
+ const root = this.#rootIndex(parts) + 1;
2673
+ let dd = root;
2148
2674
  while (-1 !== (dd = parts.indexOf("..", dd + 1))) {
2149
2675
  const p = parts[dd - 1];
2150
- if (p && p !== "." && p !== ".." && p !== "**" && !(this.isWindows && /^[a-z]:$/i.test(p))) {
2676
+ if (p && p !== "." && p !== ".." && p !== "**") {
2151
2677
  didSomething = true;
2152
2678
  parts.splice(dd - 1, 2);
2153
- dd -= 2;
2679
+ dd = Math.max(dd - 2, root);
2154
2680
  }
2155
2681
  }
2156
2682
  } while (didSomething);
2157
2683
  return parts.length === 0 ? [""] : parts;
2158
2684
  }
2159
2685
  firstPhasePreProcess(globParts) {
2686
+ const { braceExpandMax = DEFAULT_BRACE_EXPAND_MAX } = this.options;
2687
+ let splitCells = 0;
2688
+ const maxSplitCells = 1e6;
2160
2689
  let didSomething = false;
2161
2690
  do {
2162
2691
  didSomething = false;
@@ -2171,10 +2700,13 @@ var Minimatch = class {
2171
2700
  const p2 = parts[gs + 3];
2172
2701
  if (next !== "..") continue;
2173
2702
  if (!p || p === "." || p === ".." || !p2 || p2 === "." || p2 === "..") continue;
2703
+ const addedCells = parts.length - 1;
2704
+ if (globParts.length >= braceExpandMax || splitCells + addedCells > maxSplitCells) throw new RangeError(`optimizationLevel 2: too many patterns from '**/..'`);
2174
2705
  didSomething = true;
2175
2706
  parts.splice(gs, 1);
2176
2707
  const other = parts.slice(0);
2177
2708
  other[gs] = "**";
2709
+ splitCells += addedCells;
2178
2710
  globParts.push(other);
2179
2711
  gs--;
2180
2712
  }
@@ -2193,7 +2725,8 @@ var Minimatch = class {
2193
2725
  parts.pop();
2194
2726
  }
2195
2727
  }
2196
- let dd = 0;
2728
+ const root = this.#rootIndex(parts) + 1;
2729
+ let dd = root;
2197
2730
  while (-1 !== (dd = parts.indexOf("..", dd + 1))) {
2198
2731
  const p = parts[dd - 1];
2199
2732
  if (p && p !== "." && p !== ".." && p !== "**") {
@@ -2201,7 +2734,7 @@ var Minimatch = class {
2201
2734
  const splin = dd === 1 && parts[dd + 1] === "**" ? ["."] : [];
2202
2735
  parts.splice(dd - 1, 2, ...splin);
2203
2736
  if (parts.length === 0) parts.push("");
2204
- dd -= 2;
2737
+ dd = Math.max(dd - 2, root);
2205
2738
  }
2206
2739
  }
2207
2740
  }
@@ -2209,45 +2742,41 @@ var Minimatch = class {
2209
2742
  return globParts;
2210
2743
  }
2211
2744
  secondPhasePreProcess(globParts) {
2212
- for (let i = 0; i < globParts.length - 1; i++) for (let j = i + 1; j < globParts.length; j++) {
2213
- const matched = this.partsMatch(globParts[i], globParts[j], !this.preserveMultipleSlashes);
2214
- if (matched) {
2215
- globParts[i] = [];
2216
- globParts[j] = matched;
2217
- break;
2745
+ const keys = /* @__PURE__ */ new Set();
2746
+ const rows = globParts.filter((parts) => {
2747
+ const key = parts.join("/");
2748
+ if (keys.has(key)) return false;
2749
+ keys.add(key);
2750
+ return true;
2751
+ });
2752
+ const stars = /* @__PURE__ */ new Map();
2753
+ for (const parts of rows) {
2754
+ const s = [];
2755
+ for (let i = 0; i < parts.length; i++) if (parts[i] === "*") s.push(i);
2756
+ if (s.length) stars.set(s.join(","), s);
2757
+ }
2758
+ if (!stars.size || rows.length * stars.size > 1e5) return rows;
2759
+ const { dot } = this.options;
2760
+ return rows.filter((parts) => {
2761
+ for (const s of stars.values()) {
2762
+ if (s[s.length - 1] >= parts.length) continue;
2763
+ const c = [...parts];
2764
+ let ok = true;
2765
+ let changed = false;
2766
+ for (const i of s) {
2767
+ const p = parts[i];
2768
+ if (p === "*") continue;
2769
+ if (!p || p === "**" || !dot && p.startsWith(".")) {
2770
+ ok = false;
2771
+ break;
2772
+ }
2773
+ c[i] = "*";
2774
+ changed = true;
2775
+ }
2776
+ if (ok && changed && keys.has(c.join("/"))) return false;
2218
2777
  }
2219
- }
2220
- return globParts.filter((gs) => gs.length);
2221
- }
2222
- partsMatch(a, b, emptyGSMatch = false) {
2223
- let ai = 0;
2224
- let bi = 0;
2225
- let result = [];
2226
- let which = "";
2227
- while (ai < a.length && bi < b.length) if (a[ai] === b[bi]) {
2228
- result.push(which === "b" ? b[bi] : a[ai]);
2229
- ai++;
2230
- bi++;
2231
- } else if (emptyGSMatch && a[ai] === "**" && b[bi] === a[ai + 1]) {
2232
- result.push(a[ai]);
2233
- ai++;
2234
- } else if (emptyGSMatch && b[bi] === "**" && a[ai] === b[bi + 1]) {
2235
- result.push(b[bi]);
2236
- bi++;
2237
- } else if (a[ai] === "*" && b[bi] && (this.options.dot || !b[bi].startsWith(".")) && b[bi] !== "**") {
2238
- if (which === "b") return false;
2239
- which = "a";
2240
- result.push(a[ai]);
2241
- ai++;
2242
- bi++;
2243
- } else if (b[bi] === "*" && a[ai] && (this.options.dot || !a[ai].startsWith(".")) && a[ai] !== "**") {
2244
- if (which === "a") return false;
2245
- which = "b";
2246
- result.push(b[bi]);
2247
- ai++;
2248
- bi++;
2249
- } else return false;
2250
- return a.length === b.length && result;
2778
+ return true;
2779
+ });
2251
2780
  }
2252
2781
  parseNegate() {
2253
2782
  if (this.nonegate) return;
@@ -2261,10 +2790,22 @@ var Minimatch = class {
2261
2790
  if (negateOffset) this.pattern = pattern.slice(negateOffset);
2262
2791
  this.negate = negate;
2263
2792
  }
2264
- matchOne(file, pattern, partial = false) {
2793
+ #matchRow(file, resolved, pattern, partial) {
2265
2794
  let fileStartIndex = 0;
2266
2795
  let patternStartIndex = 0;
2267
- if (this.isWindows) {
2796
+ const fh = this.isWindows ? uncHost(resolved) : -1;
2797
+ const ph = fh === -1 ? -1 : uncHost(pattern);
2798
+ if (ph !== -1) {
2799
+ const host = pattern[ph];
2800
+ const share = pattern[ph + 1];
2801
+ if (typeof host !== "string" || typeof share !== "string") {
2802
+ fileStartIndex = fh;
2803
+ patternStartIndex = ph;
2804
+ } else if (resolved[fh].toLowerCase() === host.toLowerCase() && resolved[fh + 1].toLowerCase() === share.toLowerCase()) {
2805
+ fileStartIndex = fh + 2;
2806
+ patternStartIndex = ph + 2;
2807
+ }
2808
+ } else if (this.isWindows) {
2268
2809
  const fileDrive = typeof file[0] === "string" && /^[a-z]:$/i.test(file[0]);
2269
2810
  const fileUNC = !fileDrive && file[0] === "" && file[1] === "" && file[2] === "?" && /^[a-z]:$/i.test(file[3]);
2270
2811
  const patternDrive = typeof pattern[0] === "string" && /^[a-z]:$/i.test(pattern[0]);
@@ -2274,32 +2815,20 @@ var Minimatch = class {
2274
2815
  if (typeof fdi === "number" && typeof pdi === "number") {
2275
2816
  const [fd, pd] = [file[fdi], pattern[pdi]];
2276
2817
  if (fd.toLowerCase() === pd.toLowerCase()) {
2277
- pattern[pdi] = fd;
2278
- patternStartIndex = pdi;
2279
- fileStartIndex = fdi;
2818
+ patternStartIndex = pdi + 1;
2819
+ fileStartIndex = fdi + 1;
2280
2820
  }
2281
2821
  }
2282
2822
  }
2283
- const { optimizationLevel = 1 } = this.options;
2284
- if (optimizationLevel >= 2) file = this.levelTwoFileOptimize(file);
2823
+ file = resolved;
2285
2824
  if (pattern.includes(GLOBSTAR)) return this.#matchGlobstar(file, pattern, partial, fileStartIndex, patternStartIndex);
2286
2825
  return this.#matchOne(file, pattern, partial, fileStartIndex, patternStartIndex);
2287
2826
  }
2288
2827
  #matchGlobstar(file, pattern, partial, fileIndex, patternIndex) {
2289
- const firstgs = pattern.indexOf(GLOBSTAR, patternIndex);
2290
- const lastgs = pattern.lastIndexOf(GLOBSTAR);
2291
- const [head, body, tail] = partial ? [
2292
- pattern.slice(patternIndex, firstgs),
2293
- pattern.slice(firstgs + 1),
2294
- []
2295
- ] : [
2296
- pattern.slice(patternIndex, firstgs),
2297
- pattern.slice(firstgs + 1, lastgs),
2298
- pattern.slice(lastgs + 1)
2299
- ];
2828
+ const { head, body, tail, segments } = this.#getGlobstarParts(pattern, partial, patternIndex);
2300
2829
  if (head.length) {
2301
- const fileHead = file.slice(fileIndex, fileIndex + head.length);
2302
- if (!this.#matchOne(fileHead, head, partial, 0, 0)) return false;
2830
+ const headEnd = fileIndex + head.length;
2831
+ if (!this.#matchOne(file, head, partial, fileIndex, 0, headEnd)) return false;
2303
2832
  fileIndex += head.length;
2304
2833
  patternIndex += head.length;
2305
2834
  }
@@ -2324,67 +2853,86 @@ var Minimatch = class {
2324
2853
  }
2325
2854
  return partial || sawSome;
2326
2855
  }
2327
- const bodySegments = [[[], 0]];
2328
- let currentBody = bodySegments[0];
2856
+ return !!this.#matchGlobStarBodySections(file, segments, file.length - fileTailMatch, fileIndex, 0, partial, 0, !!fileTailMatch, /* @__PURE__ */ new Set());
2857
+ }
2858
+ #getGlobstarParts(pattern, partial, patternIndex) {
2859
+ let byStart = this.#globstarParts.get(pattern);
2860
+ if (!byStart) {
2861
+ byStart = [];
2862
+ this.#globstarParts.set(pattern, byStart);
2863
+ }
2864
+ const key = patternIndex * 2 + (partial ? 1 : 0);
2865
+ const found = byStart[key];
2866
+ if (found) return found;
2867
+ const firstgs = pattern.indexOf(GLOBSTAR, patternIndex);
2868
+ const lastgs = pattern.lastIndexOf(GLOBSTAR);
2869
+ const head = pattern.slice(patternIndex, firstgs);
2870
+ const body = pattern.slice(firstgs + 1, partial ? void 0 : lastgs);
2871
+ const tail = partial ? [] : pattern.slice(lastgs + 1);
2872
+ const segments = [[[], 0]];
2873
+ let current = segments[0];
2329
2874
  let nonGsParts = 0;
2330
2875
  const nonGsPartsSums = [0];
2331
2876
  for (const b of body) if (b === GLOBSTAR) {
2332
2877
  nonGsPartsSums.push(nonGsParts);
2333
- currentBody = [[], 0];
2334
- bodySegments.push(currentBody);
2878
+ current = [[], 0];
2879
+ segments.push(current);
2335
2880
  } else {
2336
- currentBody[0].push(b);
2881
+ current[0].push(b);
2337
2882
  nonGsParts++;
2338
2883
  }
2339
- let i = bodySegments.length - 1;
2340
- const fileLength = file.length - fileTailMatch;
2341
- for (const b of bodySegments) b[1] = fileLength - (nonGsPartsSums[i--] + b[0].length);
2342
- return !!this.#matchGlobStarBodySections(file, bodySegments, fileIndex, 0, partial, 0, !!fileTailMatch);
2884
+ segments.forEach((b, i) => {
2885
+ b[1] = nonGsParts - nonGsPartsSums[i];
2886
+ });
2887
+ const parts = {
2888
+ head,
2889
+ body,
2890
+ tail,
2891
+ segments
2892
+ };
2893
+ byStart[key] = parts;
2894
+ return parts;
2343
2895
  }
2344
- #matchGlobStarBodySections(file, bodySegments, fileIndex, bodyIndex, partial, globStarDepth, sawTail) {
2896
+ #matchGlobStarBodySections(file, bodySegments, fileLength, fileIndex, bodyIndex, partial, globStarDepth, sawTail, tried) {
2345
2897
  const bs = bodySegments[bodyIndex];
2346
2898
  if (!bs) {
2347
- for (let i = fileIndex; i < file.length; i++) {
2899
+ if (partial) return fileIndex >= fileLength || fileIndex === fileLength - 1 && file[fileIndex] === "";
2900
+ for (let i = fileIndex; i < fileLength; i++) {
2348
2901
  sawTail = true;
2349
2902
  const f = file[i];
2350
2903
  if (f === "." || f === ".." || !this.options.dot && f.startsWith(".")) return false;
2351
2904
  }
2352
2905
  return sawTail;
2353
2906
  }
2354
- const [body, after] = bs;
2907
+ const [body, need] = bs;
2908
+ const after = partial ? fileLength : fileLength - need;
2355
2909
  while (fileIndex <= after) {
2356
- if (this.#matchOne(file.slice(0, fileIndex + body.length), body, partial, fileIndex, 0) && globStarDepth < this.maxGlobstarRecursion) {
2357
- const sub = this.#matchGlobStarBodySections(file, bodySegments, fileIndex + body.length, bodyIndex + 1, partial, globStarDepth + 1, sawTail);
2910
+ const key = bodyIndex * (file.length + 1) + fileIndex;
2911
+ if (tried.has(key)) return false;
2912
+ tried.add(key);
2913
+ if (this.#matchOne(file, body, partial, fileIndex, 0, fileIndex + body.length) && globStarDepth < this.maxGlobstarRecursion) {
2914
+ const sub = this.#matchGlobStarBodySections(file, bodySegments, fileLength, fileIndex + body.length, bodyIndex + 1, partial, globStarDepth + 1, sawTail, tried);
2358
2915
  if (sub !== false) return sub;
2359
2916
  }
2917
+ if (fileIndex === after) break;
2360
2918
  const f = file[fileIndex];
2361
2919
  if (f === "." || f === ".." || !this.options.dot && f.startsWith(".")) return false;
2362
2920
  fileIndex++;
2363
2921
  }
2364
2922
  return partial || null;
2365
2923
  }
2366
- #matchOne(file, pattern, partial, fileIndex, patternIndex) {
2924
+ #matchOne(file, pattern, partial, fileIndex, patternIndex, fileEnd = file.length) {
2367
2925
  let fi;
2368
2926
  let pi;
2369
2927
  let pl;
2370
2928
  let fl;
2371
- for (fi = fileIndex, pi = patternIndex, fl = file.length, pl = pattern.length; fi < fl && pi < pl; fi++, pi++) {
2372
- this.debug("matchOne loop");
2929
+ for (fi = fileIndex, pi = patternIndex, fl = Math.min(fileEnd, file.length), pl = pattern.length; fi < fl && pi < pl; fi++, pi++) {
2373
2930
  let p = pattern[pi];
2374
2931
  let f = file[fi];
2375
- this.debug(pattern, p, f);
2376
2932
  /* c8 ignore start */
2377
2933
  if (p === false || p === GLOBSTAR) return false;
2378
2934
  /* c8 ignore stop */
2379
- let hit;
2380
- if (typeof p === "string") {
2381
- hit = f === p;
2382
- this.debug("string match", p, f, hit);
2383
- } else {
2384
- hit = p.test(f);
2385
- this.debug("pattern match", p, f, hit);
2386
- }
2387
- if (!hit) return false;
2935
+ if (!portionMatch(p, f)) return false;
2388
2936
  }
2389
2937
  if (fi === fl && pi === pl) return true;
2390
2938
  else if (fi === fl) return partial;
@@ -2395,92 +2943,83 @@ var Minimatch = class {
2395
2943
  braceExpand() {
2396
2944
  return braceExpand(this.pattern, this.options);
2397
2945
  }
2946
+ #expandBraces() {
2947
+ const { pattern } = this;
2948
+ if (this.options.nobrace) return this.braceExpand();
2949
+ let code = 57344;
2950
+ while (pattern.includes(String.fromCharCode(code))) if (++code > 63743) return this.braceExpand();
2951
+ const mark = String.fromCharCode(code);
2952
+ let found = false;
2953
+ const marked = pattern.replace(rangeRe, (m, lo, hi) => {
2954
+ const a = Number(lo);
2955
+ const b = Number(hi);
2956
+ if (!Number.isSafeInteger(a) || !Number.isSafeInteger(b) || Math.abs(a - b) + 1 < RANGE_MIN) return m;
2957
+ found = true;
2958
+ return `${mark}${lo}..${hi}${mark}`;
2959
+ });
2960
+ if (!found) return this.braceExpand();
2961
+ const set = braceExpand(marked, this.options);
2962
+ for (const p of set) for (const portion of p.split("/")) {
2963
+ const c = portion.indexOf("[");
2964
+ if (c !== -1 && c < portion.lastIndexOf(mark)) return this.braceExpand();
2965
+ if (!this.options.noext && inRepeatOrNegExt(portion, mark)) return this.braceExpand();
2966
+ }
2967
+ this.#rangeMark = mark;
2968
+ return set;
2969
+ }
2398
2970
  parse(pattern) {
2399
2971
  assertValidPattern(pattern);
2400
2972
  const options = this.options;
2401
2973
  if (pattern === "**") return GLOBSTAR;
2402
2974
  if (pattern === "") return "";
2403
- let m;
2404
- let fastTest = null;
2405
- if (m = pattern.match(starRE)) fastTest = options.dot ? starTestDot : starTest;
2406
- else if (m = pattern.match(starDotExtRE)) fastTest = (options.nocase ? options.dot ? starDotExtTestNocaseDot : starDotExtTestNocase : options.dot ? starDotExtTestDot : starDotExtTest)(m[1]);
2407
- else if (m = pattern.match(qmarksRE)) fastTest = (options.nocase ? options.dot ? qmarksTestNocaseDot : qmarksTestNocase : options.dot ? qmarksTestDot : qmarksTest)(m);
2408
- else if (m = pattern.match(starDotStarRE)) fastTest = options.dot ? starDotStarTestDot : starDotStarTest;
2409
- else if (m = pattern.match(dotStarRE)) fastTest = dotStarTest;
2410
- const re = AST.fromGlob(pattern, this.options).toMMPattern();
2411
- if (fastTest && typeof re === "object") Reflect.defineProperty(re, "test", { value: fastTest });
2412
- return re;
2413
- }
2414
- makeRe() {
2415
- if (this.regexp || this.regexp === false) return this.regexp;
2416
- const set = this.set;
2417
- if (!set.length) {
2418
- this.regexp = false;
2419
- return this.regexp;
2420
- }
2421
- const options = this.options;
2422
- const twoStar = options.noglobstar ? star : options.dot ? twoStarDot : twoStarNoDot;
2423
- const flags = new Set(options.nocase ? ["i"] : []);
2424
- let re = set.map((pattern) => {
2425
- const pp = pattern.map((p) => {
2426
- if (p instanceof RegExp) for (const f of p.flags.split("")) flags.add(f);
2427
- return typeof p === "string" ? regExpEscape(p) : p === GLOBSTAR ? GLOBSTAR : p._src;
2428
- });
2429
- pp.forEach((p, i) => {
2430
- const next = pp[i + 1];
2431
- const prev = pp[i - 1];
2432
- if (p !== GLOBSTAR || prev === GLOBSTAR) return;
2433
- if (prev === void 0) {
2434
- if (next !== void 0 && next !== GLOBSTAR) pp[i + 1] = "(?:\\/|" + twoStar + "\\/)?" + next;
2435
- else pp[i] = twoStar;
2436
- } else if (next === void 0) pp[i - 1] = prev + "(?:\\/|\\/" + twoStar + ")?";
2437
- else if (next !== GLOBSTAR) {
2438
- pp[i - 1] = prev + "(?:\\/|\\/" + twoStar + "\\/)" + next;
2439
- pp[i + 1] = GLOBSTAR;
2440
- }
2975
+ const { nocase, nocaseMagicOnly, noext = false, dot, normalize } = options;
2976
+ const rangeMark = this.#rangeMark;
2977
+ const lit = rangeMark && pattern.includes(rangeMark) ? void 0 : literal(pattern, noext);
2978
+ if (lit !== void 0 && !(nocase && !nocaseMagicOnly && pattern.toUpperCase() !== pattern.toLowerCase())) return this.#norm(lit);
2979
+ if (this.#pending) return PENDING;
2980
+ let m = this.#matchers.get(pattern);
2981
+ if (!m) {
2982
+ if (!noext) assertValidExtglobs(pattern);
2983
+ m = new Matcher(pattern, {
2984
+ nocase,
2985
+ noext,
2986
+ dot,
2987
+ normalize,
2988
+ ...rangeMark && { rangeMark }
2441
2989
  });
2442
- const filtered = pp.filter((p) => p !== GLOBSTAR);
2443
- if (this.partial && filtered.length >= 1) {
2444
- const prefixes = [];
2445
- for (let i = 1; i <= filtered.length; i++) prefixes.push(filtered.slice(0, i).join("/"));
2446
- return "(?:" + prefixes.join("|") + ")";
2447
- }
2448
- return filtered.join("/");
2449
- }).join("|");
2450
- const [open, close] = set.length > 1 ? ["(?:", ")"] : ["", ""];
2451
- re = "^" + open + re + close + "$";
2452
- if (this.partial) re = "^(?:\\/|" + open + re.slice(1, -1) + close + ")$";
2453
- if (this.negate) re = "^(?!" + re + ").+$";
2454
- try {
2455
- this.regexp = new RegExp(re, [...flags].join(""));
2456
- } catch {
2457
- this.regexp = false;
2990
+ this.#matchers.set(pattern, m);
2458
2991
  }
2459
- /* c8 ignore stop */
2460
- return this.regexp;
2992
+ return m;
2461
2993
  }
2462
- slashSplit(p) {
2994
+ #slashSplit(p) {
2463
2995
  if (this.preserveMultipleSlashes) return p.split("/");
2464
2996
  else if (this.isWindows && /^\/\/[^/]+/.test(p)) return ["", ...p.split(/\/+/)];
2465
2997
  else return p.split(/\/+/);
2466
2998
  }
2467
2999
  match(f, partial = this.partial) {
2468
- this.debug("match", f, this.pattern);
2469
3000
  if (this.comment) return false;
2470
3001
  if (this.empty) return f === "";
2471
3002
  if (f === "/" && partial) return true;
2472
3003
  const options = this.options;
2473
- if (this.isWindows) f = f.split("\\").join("/");
2474
- const ff = this.slashSplit(f);
2475
- this.debug(this.pattern, "split", ff);
3004
+ let split = this.#cachedSplit(f);
3005
+ if (!split) {
3006
+ if (!partial && !this.#form && (this.#endCheck || this.#literalCheck) && lastChecked !== f) {
3007
+ lastChecked = f;
3008
+ const can = this.#canMatch(f);
3009
+ if (can === "no") return options.flipNegate ? false : this.negate;
3010
+ if (can === "yes") return options.flipNegate ? true : !this.negate;
3011
+ }
3012
+ split = this.#split(f);
3013
+ }
3014
+ const ff = split.parts;
3015
+ const resolved = this.#level2 ? split.resolved ??= this.#levelTwoFileOptimize(ff) : ff;
2476
3016
  const set = this.set;
2477
- this.debug(this.pattern, "set", set);
2478
3017
  let filename = ff[ff.length - 1];
2479
3018
  if (!filename) for (let i = ff.length - 2; !filename && i >= 0; i--) filename = ff[i];
2480
- for (const pattern of set) {
2481
- let file = ff;
2482
- if (options.matchBase && pattern.length === 1) file = [filename];
2483
- if (this.matchOne(file, pattern, partial)) {
3019
+ for (let r = 0; r < set.length; r++) {
3020
+ const pattern = set[r];
3021
+ const shape = partial ? void 0 : this.#shapes[r];
3022
+ 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)) {
2484
3023
  if (options.flipNegate) return true;
2485
3024
  return !this.negate;
2486
3025
  }
@@ -2493,12 +3032,10 @@ var Minimatch = class {
2493
3032
  }
2494
3033
  };
2495
3034
  /* c8 ignore stop */
2496
- minimatch.AST = AST;
2497
3035
  minimatch.Minimatch = Minimatch;
2498
3036
  minimatch.escape = escape;
2499
3037
  minimatch.unescape = unescape;
2500
- //#endregion
2501
- //#region ../internal/src/build/runtime-package-files.ts
3038
+ // ../internal/src/build/runtime-package-files.ts
2502
3039
  const alwaysPublishedFile = /^(?:package\.json|(?:readme|copying|licen[cs]e)(?:\..*[^~$])?)$/i;
2503
3040
  const rootExcluded = /* @__PURE__ */ new Set([
2504
3041
  "package-lock.json",
@@ -2682,8 +3219,7 @@ async function copyRuntimePackageFiles(packageDir, targetDir) {
2682
3219
  await unlessGone(() => copyFile(join(packageDir, path), target));
2683
3220
  }
2684
3221
  }
2685
- //#endregion
2686
- //#region ../internal/src/build/scan-module.ts
3222
+ // ../internal/src/build/scan-module.ts
2687
3223
  /**
2688
3224
  * Reads facts from JavaScript and TypeScript modules at build and dev time. The scanner parses each module once with
2689
3225
  * the oxc parser that Vite ships through Rolldown, and never runs it. Values that are not static literals read as
@@ -2692,12 +3228,8 @@ async function copyRuntimePackageFiles(packageDir, targetDir) {
2692
3228
  var scan_module_exports = /* @__PURE__ */ __exportAll({
2693
3229
  dynamic: () => dynamic,
2694
3230
  exportNames: () => exportNames,
2695
- maskLiterals: () => maskLiterals,
2696
- objectProperties: () => objectProperties,
2697
3231
  scanModule: () => scanModule,
2698
- staticValue: () => staticValue,
2699
- unwrapExpression: () => unwrapExpression,
2700
- walk: () => walk
3232
+ staticValue: () => staticValue
2701
3233
  });
2702
3234
  /** The value of an expression that the scanner cannot read without running the module. */
2703
3235
  const dynamic = Symbol("dynamic");
@@ -2857,8 +3389,7 @@ function maskLiterals(module) {
2857
3389
  for (const span of literalSpans(module)) for (let index = span.start; index < span.end; index++) if (!isLineTerminator(output[index] ?? "")) output[index] = " ";
2858
3390
  return output.join("");
2859
3391
  }
2860
- //#endregion
2861
- //#region ../internal/src/build/provider-output-sources.ts
3392
+ // ../internal/src/build/provider-output-sources.ts
2862
3393
  function escapeRegExp(value) {
2863
3394
  return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
2864
3395
  }
@@ -3940,8 +4471,7 @@ async function retainProviderOutputSources(options) {
3940
4471
  return root ? resolve$1(retainedRoots.get(root), relative$1(root, resolvedPath)) : path;
3941
4472
  } };
3942
4473
  }
3943
- //#endregion
3944
- //#region ../internal/src/build/vercel-config.ts
4474
+ // ../internal/src/build/vercel-config.ts
3945
4475
  function createDefaultVercelOutputRoot(rootDir) {
3946
4476
  return resolve$1(rootDir, ".vercel", "output");
3947
4477
  }
@@ -3964,8 +4494,7 @@ function createNodeFunctionConfig(extra = {}) {
3964
4494
  ...extra
3965
4495
  };
3966
4496
  }
3967
- //#endregion
3968
- //#region ../internal/src/build/runtime-package-resolution.ts
4497
+ // ../internal/src/build/runtime-package-resolution.ts
3969
4498
  /** Locates package metadata through exports, an entry's ancestors, or the project's dependency roots. */
3970
4499
  function createRuntimePackageResolver(readPackageName) {
3971
4500
  return async (name, resolver, fromDir) => {
@@ -4006,8 +4535,7 @@ function isPackageResolutionMiss(error) {
4006
4535
  const code = error?.code;
4007
4536
  return code === "MODULE_NOT_FOUND" || code === "ERR_MODULE_NOT_FOUND" || code === "ERR_PACKAGE_PATH_NOT_EXPORTED";
4008
4537
  }
4009
- //#endregion
4010
- //#region ../internal/src/build/runtime-package-directory.ts
4538
+ // ../internal/src/build/runtime-package-directory.ts
4011
4539
  /** Update a staged copy, then publish it with rollback on failure or cancellation. */
4012
4540
  async function updateRuntimePackageDirectory(options) {
4013
4541
  const stagingRoot = await mkdtemp(join(dirname$1(options.directory), ".vitehub-runtime-packages-"));
@@ -4054,8 +4582,7 @@ async function updateRuntimePackageDirectory(options) {
4054
4582
  });
4055
4583
  }
4056
4584
  }
4057
- //#endregion
4058
- //#region ../internal/src/build/vercel-runtime-packages.ts
4585
+ // ../internal/src/build/vercel-runtime-packages.ts
4059
4586
  const runtimeExportConditions = /* @__PURE__ */ new Set([
4060
4587
  "default",
4061
4588
  "import",
@@ -4209,7 +4736,7 @@ async function copyTracedPackageFiles(name, resolver, packageDir, packageJsonPat
4209
4736
  return true;
4210
4737
  }
4211
4738
  async function loadNodeFileTrace() {
4212
- nodeFileTracePromise ??= import("./out-DxLKolA0.js").then((m) => /* @__PURE__ */ __toESM(m.default, 1)).then(({ nodeFileTrace }) => nodeFileTrace);
4739
+ nodeFileTracePromise ??= import("./out-r9T3bhTE.js").then((m) => /* @__PURE__ */ __toESM(m.default, 1)).then(({ nodeFileTrace }) => nodeFileTrace);
4213
4740
  return nodeFileTracePromise;
4214
4741
  }
4215
4742
  async function resolvePackageTraceEntries(name, resolver, packageDir, packageJson) {
@@ -4275,8 +4802,7 @@ function parsePackageJson(value, path) {
4275
4802
  if (typeof value !== "object" || value === null || Array.isArray(value)) throw internalErrorDiagnostics.INTERNAL_B0047({ message: `Expected ${path} to contain a JSON object.` });
4276
4803
  return value;
4277
4804
  }
4278
- //#endregion
4279
- //#region ../internal/src/build/provider-output-catalog.ts
4805
+ // ../internal/src/build/provider-output-catalog.ts
4280
4806
  var ProviderOutputCatalog = class {
4281
4807
  bundleDefines = {};
4282
4808
  #appliedCloudflareContributions = /* @__PURE__ */ new Map();
@@ -4516,8 +5042,7 @@ function getVercelRuntimePackages(catalog, product, generation) {
4516
5042
  const contribution = catalog?.runtimeContribution(product, generation);
4517
5043
  return contribution?.owner === "blob" ? contribution.vercelRuntimePackages ?? [] : [];
4518
5044
  }
4519
- //#endregion
4520
- //#region ../internal/src/build/vite.ts
5045
+ // ../internal/src/build/vite.ts
4521
5046
  async function collectViteHubProviderImportAliases(plugins) {
4522
5047
  return Object.assign({}, ...await Promise.all(plugins.map(async (plugin) => await plugin.vitehub?.providerOutput?.getImportAliases?.() ?? {})));
4523
5048
  }
@@ -4646,8 +5171,7 @@ function isMissingProjectMarker(error) {
4646
5171
  const code = error.code;
4647
5172
  return code === "ENOENT" || code === "ENOTDIR";
4648
5173
  }
4649
- //#endregion
4650
- //#region ../internal/src/build/deployment-output.ts
5174
+ // ../internal/src/build/deployment-output.ts
4651
5175
  const providerDeploymentOutputRegistry = globalThis;
4652
5176
  const providerDeploymentOutputWrites = providerDeploymentOutputRegistry.__vitehubProviderDeploymentOutputWrites ??= /* @__PURE__ */ new Map();
4653
5177
  const providerDeploymentOutputFinalizations = providerDeploymentOutputRegistry.__vitehubProviderDeploymentOutputFinalizations ??= /* @__PURE__ */ new WeakMap();
@@ -5691,8 +6215,7 @@ function createNitroServerKit(value = {}) {
5691
6215
  }
5692
6216
  };
5693
6217
  }
5694
- //#endregion
5695
- //#region ../internal/src/runtime/request-log.ts
6218
+ // ../internal/src/runtime/request-log.ts
5696
6219
  /**
5697
6220
  * A short name for the cause of a failure, safe to put in a log field: the string `code` of the error, such as
5698
6221
  * `ENOSPC` or a ViteHub diagnostic code, else its class name. Never the message, which can hold paths or values.
@@ -5704,8 +6227,7 @@ function errorCode(error) {
5704
6227
  const name = Reflect.get(error, "name");
5705
6228
  return typeof name === "string" && name && name !== "Error" ? name : void 0;
5706
6229
  }
5707
- //#endregion
5708
- //#region src/deployment-env.ts
6230
+ // src/deployment-env.ts
5709
6231
  const owners = ["workflow"];
5710
6232
  function entry(names, required, secret, hasDefault) {
5711
6233
  return {
@@ -5747,8 +6269,7 @@ function workflowDeploymentEnv(workflow) {
5747
6269
  ...schema
5748
6270
  ];
5749
6271
  }
5750
- //#endregion
5751
- //#region ../internal/src/definition-catalog.ts
6272
+ // ../internal/src/definition-catalog.ts
5752
6273
  const sourceFilePattern$2 = /\.(?:c|m)?[jt]sx?$/i;
5753
6274
  const declarationFilePattern = /\.d\.(?:c|m)?[jt]sx?$/i;
5754
6275
  const testFilePattern = /\.(?:test|spec)\.(?:c|m)?[jt]sx?$/i;
@@ -5883,8 +6404,7 @@ function scanDirectoryDefinitions(feature, source) {
5883
6404
  function discoverDefinitions(feature, sources) {
5884
6405
  return mergeDefinitions(feature, ...sources.map((source) => source.kind === "suffix" ? scanSuffixDefinitions(feature, source) : scanDirectoryDefinitions(feature, source)));
5885
6406
  }
5886
- //#endregion
5887
- //#region src/discovery.ts
6407
+ // src/discovery.ts
5888
6408
  const workflowSuffixPattern = /\.workflow\.(?:c|m)?[jt]s$/i;
5889
6409
  const agentSuffixPattern = /\.agent\.(?:c|m)?[jt]s$/i;
5890
6410
  const sourceFilePattern$1 = /\.(?:c|m)?[jt]s$/i;
@@ -6218,18 +6738,15 @@ function discoverWorkflowDefinitions(options) {
6218
6738
  source: "vite-suffix"
6219
6739
  }) })]), discoverFlatServerWorkflowDefinitions(serverScanDirs, "server-workflows"), folderDefinitions, options.mode === "standalone" ? [] : discoverAgentWorkflowDefinitions(roots, serverScanDirs));
6220
6740
  }
6221
- //#endregion
6222
- //#region src/internal/runtime-type.ts
6741
+ // src/internal/runtime-type.ts
6223
6742
  function isRuntimeRecord(value) {
6224
6743
  return typeof value === "object" && value !== null && !Array.isArray(value);
6225
6744
  }
6226
- //#endregion
6227
- //#region ../internal/src/agent-workflow.ts
6745
+ // ../internal/src/agent-workflow.ts
6228
6746
  function getAgentInvocationRecoveryWorkflowName(agentWorkflowName) {
6229
6747
  return `vitehub-agent-invocation-recovery-${agentWorkflowName}`;
6230
6748
  }
6231
- //#endregion
6232
- //#region ../internal/src/build/colocated-agent-files.ts
6749
+ // ../internal/src/build/colocated-agent-files.ts
6233
6750
  function isFolderAgentEntry(file) {
6234
6751
  if (!/^(?:agent|index)\.(?:c|m)?[jt]s$/i.test(basename(file))) return false;
6235
6752
  return !(basename(file).toLowerCase().startsWith("agent.") && basename(dirname$1(file)) === "agents" && basename(dirname$1(dirname$1(file))) === "server");
@@ -6267,8 +6784,7 @@ function readColocatedAgentFiles(handler, directoryName) {
6267
6784
  visit(root);
6268
6785
  return Object.keys(files).length ? files : void 0;
6269
6786
  }
6270
- //#endregion
6271
- //#region ../internal/src/build/esbuild.ts
6787
+ // ../internal/src/build/esbuild.ts
6272
6788
  const viteRawNamespace = "vitehub-vite-raw";
6273
6789
  const viteMarkdownTemplateNamespace = "vitehub-markdown-template";
6274
6790
  const markdownTemplateFileSuffix = ".template.md";
@@ -6431,8 +6947,7 @@ async function bundleEsbuildEntry(bundle, entryFile, outfile, options = {}) {
6431
6947
  tsconfigRaw: options.tsconfigRaw
6432
6948
  });
6433
6949
  }
6434
- //#endregion
6435
- //#region src/internal/step-options.ts
6950
+ // src/internal/step-options.ts
6436
6951
  const optionNames = ["retries", "timeout"];
6437
6952
  /**
6438
6953
  * Reads the `retries` and `timeout` exports of a step file from its source, without running it. The build checks them,
@@ -6464,8 +6979,7 @@ async function readWorkflowStepOptions(file) {
6464
6979
  resolveWorkflowStepOptions(file, options);
6465
6980
  return options;
6466
6981
  }
6467
- //#endregion
6468
- //#region src/internal/vite-build.ts
6982
+ // src/internal/vite-build.ts
6469
6983
  function resolveVercelWorkflowWorld(workflowApi) {
6470
6984
  const workflowCore = createRequire(workflowApi).resolve("@workflow/core");
6471
6985
  return createRequire(workflowCore).resolve("@workflow/world-vercel");
@@ -7260,7 +7774,9 @@ async function createCloudflareWorkflowNitroConfig(options) {
7260
7774
  }, options.serverDirs, options.includeUserAppEntry, options.transformRegistry);
7261
7775
  if (!artifacts.providerDefinitions.length) return options.nitro;
7262
7776
  const nitro = { ...options.nitro };
7263
- const middlewareFile = resolve$1(ensureGeneratedDir(options.rootDir, productName), "nitro-middleware.ts");
7777
+ const middlewareDir = resolve$1(options.rootDir, ".vitehub", "nitro", productName);
7778
+ const middlewareFile = resolve$1(middlewareDir, "cloudflare-middleware.ts");
7779
+ await mkdir(middlewareDir, { recursive: true });
7264
7780
  await writeFile(middlewareFile, [
7265
7781
  "import { defineMiddleware } from \"nitro\"",
7266
7782
  "import { env, waitUntil } from \"cloudflare:workers\"",
@@ -8025,8 +8541,7 @@ async function generateWorkflowProviderOutputs(options, write) {
8025
8541
  if (write) return await generateProviderOutputsWithinLock(options, write);
8026
8542
  return await withProviderDeploymentOutputLock(options.rootDir, async (lockedWrite) => await generateProviderOutputsWithinLock(options, lockedWrite));
8027
8543
  }
8028
- //#endregion
8029
- //#region src/inspect.ts
8544
+ // src/inspect.ts
8030
8545
  function summarizeWorkflowDefinition(projectRoot, definition) {
8031
8546
  return {
8032
8547
  fields: [...definition.agentIdentity ? [{
@@ -8083,8 +8598,7 @@ const workflowConsoleSection = {
8083
8598
  notice: "Workflow run history is not exposed by ViteHub's provider-independent Workflow contract yet."
8084
8599
  }
8085
8600
  };
8086
- //#endregion
8087
- //#region src/internal/dev-registry.ts
8601
+ // src/internal/dev-registry.ts
8088
8602
  const workflowDevGeneratedDir = ".vitehub/nitro/workflow";
8089
8603
  const workflowTestSetupFile = "test-setup.mjs";
8090
8604
  const generatedFilesSeparatePerCommand = {
@@ -8219,8 +8733,7 @@ async function writeWorkflowDevRegistryFiles(options) {
8219
8733
  plugin: options.pluginPath ?? plugin
8220
8734
  };
8221
8735
  }
8222
- //#endregion
8223
- //#region src/internal/registry-types.ts
8736
+ // src/internal/registry-types.ts
8224
8737
  const workflowTypesFile = ".vitehub/workflow.d.ts";
8225
8738
  const sourceFilePattern = /\.(?:c|m)?[jt]s$/i;
8226
8739
  const javaScriptFilePattern = /\.(?:c|m)?js$/i;
@@ -8271,8 +8784,7 @@ async function writeWorkflowTypes(root, definitions, importBase = "@vite-hub/wor
8271
8784
  await mkdir(dirname(file), { recursive: true });
8272
8785
  await writeFile(file, contents, "utf8");
8273
8786
  }
8274
- //#endregion
8275
- //#region src/vite.ts
8787
+ // src/vite.ts
8276
8788
  function agentWorkflowModules(plugins) {
8277
8789
  for (const plugin of [plugins].flat(Infinity)) {
8278
8790
  const modules = plugin?.vitehub?.agent?.workflowModules;
@@ -8913,5 +9425,4 @@ function hubWorkflow(workflow, internalOptions = {}) {
8913
9425
  }
8914
9426
  };
8915
9427
  }
8916
- //#endregion
8917
9428
  export { createWorkflowTypes, discoverWorkflowDefinitions, hubWorkflow, inspectWorkflowDefinitions, inspectWorkflowResources, workflowConsoleSection, workflowRuntimeModule };