vite-plus 1.4.0 → 1.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (111) hide show
  1. package/binding/index.cjs +116 -55
  2. package/binding/index.d.cts +31 -0
  3. package/dist/{agent-D8oxxhVR.js → agent-CowvWq3j.js} +2 -2
  4. package/dist/bin.js +30 -8
  5. package/dist/config/bin.js +5 -5
  6. package/dist/{constants-DRUnJ_Dz.js → constants-D5f7inVN.js} +6 -2
  7. package/dist/create/bin.js +115 -65
  8. package/dist/{define-config-Cv2P6NT2.cjs → define-config-BGCfAiIo.cjs} +35 -3
  9. package/dist/{define-config-rPhYIFSn.d.ts → define-config-BrvHRi-G.d.ts} +30 -2
  10. package/dist/{define-config-ChwJcu5e.js → define-config-XKYhw0xH.js} +30 -5
  11. package/dist/define-config.cjs +2 -1
  12. package/dist/define-config.d.ts +2 -2
  13. package/dist/define-config.js +1 -1
  14. package/dist/{editor-ClL78D8u.js → editor-BVaNnIey.js} +1266 -884
  15. package/dist/hooks/bin.js +2 -2
  16. package/dist/{hooks-xRcJPc-O.js → hooks-w_e2whkQ.js} +40 -21
  17. package/dist/index.cjs +4 -3
  18. package/dist/index.d.ts +2 -2
  19. package/dist/index.js +2 -2
  20. package/dist/lint-plugins.cjs +1 -1
  21. package/dist/migration/bin.js +1302 -311
  22. package/dist/migration/compat/worker.js +1 -1
  23. package/dist/{oxlint-plugin-config-BVpqYdcC.js → oxlint-plugin-config-5hVqz4kj.js} +1 -1
  24. package/dist/oxlint-plugin.js +29 -4
  25. package/dist/pack-bin.js +2 -2
  26. package/dist/{package-DzsomcUD.js → package-DLUCo6L_.js} +1 -1
  27. package/dist/{prompts-GL1vj0wk.js → prompts-DLpJGhfK.js} +3 -3
  28. package/dist/register.d.ts +1 -0
  29. package/dist/register.js +12 -0
  30. package/dist/{report-DLHO30yZ.js → report-BEdpIQvC.js} +2 -0
  31. package/dist/{resolve-vite-config-Dn5896A4.js → resolve-vite-config-D-JtjGRa.js} +2 -2
  32. package/dist/{resolve-vite-config-QO6cC0SP.js → resolve-vite-config-D7IUZYKq.js} +1 -1
  33. package/dist/script-esm-hooks.d.ts +5 -2
  34. package/dist/script-esm-hooks.js +5 -2
  35. package/dist/script-preload.cjs +24 -1
  36. package/dist/script-register.js +7 -2
  37. package/dist/script-watch.js +135 -41
  38. package/dist/staged/bin.js +2 -2
  39. package/dist/sync-versions/bin.js +1 -1
  40. package/dist/toolchain.js +14 -14
  41. package/dist/toolchain.json +14 -14
  42. package/dist/{tsconfig-LE_mAwe_.js → tsconfig-D3DiCiW6.js} +2 -2
  43. package/dist/{tsconfig-Do6MAG_f.js → tsconfig-DLERIAbF.js} +1 -1
  44. package/dist/version.js +2 -2
  45. package/dist/versions.js +7 -7
  46. package/docs/config/check.md +2 -0
  47. package/docs/config/fmt.md +1 -1
  48. package/docs/config/lint.md +1 -1
  49. package/docs/config/run.md +6 -2
  50. package/docs/config/staged.md +1 -1
  51. package/docs/guide/check.md +5 -1
  52. package/docs/guide/ci.md +2 -2
  53. package/docs/guide/create.md +1 -1
  54. package/docs/guide/env.md +1 -1
  55. package/docs/guide/global-cli.md +13 -9
  56. package/docs/guide/homebrew.md +127 -0
  57. package/docs/guide/ide-integration.md +1 -3
  58. package/docs/guide/implode.md +5 -3
  59. package/docs/guide/index.md +4 -4
  60. package/docs/guide/local-cli.md +22 -1
  61. package/docs/guide/migrate-rules.md +81 -22
  62. package/docs/guide/migrate.md +9 -9
  63. package/docs/guide/package-management/add.md +84 -0
  64. package/docs/guide/package-management/approve-builds.md +48 -0
  65. package/docs/guide/package-management/audit.md +39 -0
  66. package/docs/guide/package-management/cache.md +53 -0
  67. package/docs/guide/package-management/ci.md +28 -0
  68. package/docs/guide/package-management/config.md +119 -0
  69. package/docs/guide/package-management/dedupe.md +32 -0
  70. package/docs/guide/package-management/deprecate.md +39 -0
  71. package/docs/guide/package-management/dist-tag.md +61 -0
  72. package/docs/guide/package-management/dlx.md +40 -0
  73. package/docs/guide/package-management/fund.md +32 -0
  74. package/docs/guide/package-management/global-packages.md +32 -0
  75. package/docs/guide/package-management/index.md +78 -0
  76. package/docs/guide/package-management/info.md +35 -0
  77. package/docs/guide/package-management/install.md +89 -0
  78. package/docs/guide/package-management/licenses.md +42 -0
  79. package/docs/guide/package-management/link.md +29 -0
  80. package/docs/guide/package-management/list.md +60 -0
  81. package/docs/guide/package-management/login.md +34 -0
  82. package/docs/guide/package-management/logout.md +34 -0
  83. package/docs/guide/package-management/outdated.md +60 -0
  84. package/docs/guide/package-management/owner.md +79 -0
  85. package/docs/guide/package-management/pack.md +40 -0
  86. package/docs/guide/package-management/package-manager-selection.md +60 -0
  87. package/docs/guide/package-management/patch-commit.md +27 -0
  88. package/docs/guide/package-management/patch.md +29 -0
  89. package/docs/guide/package-management/ping.md +32 -0
  90. package/docs/guide/package-management/pkg.md +88 -0
  91. package/docs/guide/package-management/prune.md +34 -0
  92. package/docs/guide/package-management/publish.md +61 -0
  93. package/docs/guide/package-management/rebuild.md +31 -0
  94. package/docs/guide/package-management/remove.md +47 -0
  95. package/docs/guide/package-management/search.md +38 -0
  96. package/docs/guide/package-management/stage.md +175 -0
  97. package/docs/guide/package-management/team.md +140 -0
  98. package/docs/guide/package-management/token.md +87 -0
  99. package/docs/guide/package-management/unlink.md +33 -0
  100. package/docs/guide/package-management/update.md +62 -0
  101. package/docs/guide/package-management/version.md +36 -0
  102. package/docs/guide/package-management/whoami.md +30 -0
  103. package/docs/guide/package-management/why.md +55 -0
  104. package/docs/guide/run.md +23 -1
  105. package/docs/guide/test.md +1 -1
  106. package/docs/guide/troubleshooting.md +1 -1
  107. package/docs/guide/upgrade.md +12 -6
  108. package/docs/guide/vitest-v5.md +2 -2
  109. package/docs/guide/vpx.md +45 -5
  110. package/package.json +40 -34
  111. package/docs/guide/package-management.md +0 -269
@@ -1,20 +1,20 @@
1
1
  import { r as __toESM } from "./rolldown-runtime-DegdyBIC.js";
2
2
  import { t as documentationUrl$1 } from "./documentation-cv_y0Auv.js";
3
- import { a as SETUP_VP_VERSION, c as VITEST_VERSION, d as VITE_PLUS_OVERRIDE_PACKAGES, f as VITE_PLUS_VERSION, l as VITE_CONFIG_FILES, m as isForceOverrideMode, n as BASEURL_TSCONFIG_WARNING, o as TSDOWN_MIGRATION_SKILL_URL, s as VITEST_AGE_GATE_EXEMPT_PACKAGES, u as VITE_PLUS_NAME } from "./constants-DRUnJ_Dz.js";
4
- import { a as ensureVitePlusImportRuleDefaults, i as createDefaultVitePlusLintConfig, t as PREFER_VITE_PLUS_IMPORTS_RULE } from "./oxlint-plugin-config-BVpqYdcC.js";
3
+ import { a as SETUP_VP_VERSION, c as VITEST_VERSION, d as VITE_PLUS_OVERRIDE_PACKAGES, f as VITE_PLUS_VERSION, l as VITE_CONFIG_FILES, m as isForceOverrideMode, n as BASEURL_TSCONFIG_WARNING, o as TSDOWN_MIGRATION_SKILL_URL, s as VITEST_AGE_GATE_EXEMPT_PACKAGES, u as VITE_PLUS_NAME } from "./constants-D5f7inVN.js";
4
+ import { a as ensureVitePlusImportRuleDefaults, i as createDefaultVitePlusLintConfig, t as PREFER_VITE_PLUS_IMPORTS_RULE } from "./oxlint-plugin-config-5hVqz4kj.js";
5
5
  import { a as writeJsonFile, c as modify, i as readJsonFile, l as parse, n as editJsonFile, o as applyEdits, r as isJsonFile, t as detectFormattingOptions } from "./json-kl84kDyH.js";
6
- import { c as getNpmRegistry, n as detectPackageMetadata, r as getScopeFromPackageName, s as fetchNpmResource } from "./package-DzsomcUD.js";
6
+ import { c as getNpmRegistry, n as detectPackageMetadata, r as getScopeFromPackageName, s as fetchNpmResource } from "./package-DLUCo6L_.js";
7
7
  import { n as isAlignableVitestEcosystemPackage } from "./vitest-ecosystem-BeEYz-qF.js";
8
- import { C as confirm, E as multiselect, M as isCancel, O as select, S as normalize$2, T as log$1, _ as getSpinner, b as coerce, d as readYamlFile, f as scalarString, g as getSilentSpinner, t as cancelAndExit, u as editYamlFile, y as PackageManager } from "./prompts-GL1vj0wk.js";
8
+ import { C as confirm, E as multiselect, M as isCancel, O as select, S as normalize$3, T as log$1, _ as getSpinner, b as coerce, d as readYamlFile, f as scalarString, g as getSilentSpinner, t as cancelAndExit, u as editYamlFile, y as PackageManager } from "./prompts-DLpJGhfK.js";
9
9
  import { _ as isGreaterThanOrEqual, h as compareReversed, v as isLessThanOrEqual } from "./comparison-CmVirWIW-UlEf2maz.js";
10
10
  import { s as satisfies, t as extractOverrideTargetName } from "./package-overrides-Ci8GXouY.js";
11
- import { l as displayRelative, u as rulesDir } from "./agent-D8oxxhVR.js";
12
- import { n as addMigrationWarning, t as addManualStep } from "./report-DLHO30yZ.js";
11
+ import { l as displayRelative, u as rulesDir } from "./agent-CowvWq3j.js";
12
+ import { n as addMigrationWarning, t as addManualStep } from "./report-BEdpIQvC.js";
13
13
  import { a as require_cross_spawn, i as runCommandSilently, n as getVpCommand } from "./command-rY79K5NI.js";
14
14
  import { t as require_dist } from "./dist-Bs0SObNC.js";
15
- import { a as hasBaseUrlInTsconfig, c as hasVitestTypesInTsconfig, l as removeDeprecatedTsconfigFalseOption, n as findTsconfigFiles, s as hasTypesToRewriteInTsconfig, u as rewriteTypesInTsconfig } from "./tsconfig-LE_mAwe_.js";
15
+ import { a as hasBaseUrlInTsconfig, c as hasVitestTypesInTsconfig, l as removeDeprecatedTsconfigFalseOption, n as findTsconfigFiles, s as hasTypesToRewriteInTsconfig, u as rewriteTypesInTsconfig } from "./tsconfig-D3DiCiW6.js";
16
16
  import { t as require_picomatch } from "./picomatch-DEUoj81q.js";
17
- import { a as findUnsafeHookInstallPath, n as SUPPORTED_GIT_HOOK_NAMES, o as hookScript, t as HOOK_STUB_SCRIPT } from "./hooks-xRcJPc-O.js";
17
+ import { a as findUnsafeHookInstallPath, n as SUPPORTED_GIT_HOOK_NAMES, o as hookScript, t as HOOK_STUB_SCRIPT } from "./hooks-w_e2whkQ.js";
18
18
  import path from "node:path";
19
19
  import { fileURLToPath } from "node:url";
20
20
  import { ResolverFactory, analyzeMigrationSource, detectWorkspace, getVpDirs, hasConfigKey, mergeJsonConfig, mergeTsdownConfig, migrateTaskCacheConfig, parseConfigArgs, parseLiteralCommands, rewriteEslint, rewriteImportsInDirectory, rewritePrettier, rewriteScripts, wrapLazyPlugins } from "../binding/index.js";
@@ -257,6 +257,64 @@ const PRETTIER_CONFIG_FILES = [
257
257
  "prettier.config.cts",
258
258
  "prettier.config.mts"
259
259
  ];
260
+ const CONFIG_SCRIPT_EXTENSIONS = [
261
+ "js",
262
+ "mjs",
263
+ "cjs",
264
+ "ts",
265
+ "mts",
266
+ "cts"
267
+ ];
268
+ const MIGRATION_WARNING_DETECTIONS = [
269
+ {
270
+ packageName: "rollup",
271
+ configFiles: CONFIG_SCRIPT_EXTENSIONS.map((extension) => `rollup.config.${extension}`),
272
+ warning: "Rollup configuration detected. Rollup is API-compatible with Rolldown and can be migrated first before migrating further to tsdown or Vite. Once migrated to tsdown or Vite, re-run vp migrate."
273
+ },
274
+ {
275
+ packageName: "rolldown",
276
+ configFiles: CONFIG_SCRIPT_EXTENSIONS.map((extension) => `rolldown.config.${extension}`),
277
+ warning: "Rolldown configuration detected. Rolldown can be migrated to tsdown or Vite, and it is recommended to do so. Once migrated, re-run vp migrate."
278
+ },
279
+ {
280
+ packageName: "jest",
281
+ configFiles: [...CONFIG_SCRIPT_EXTENSIONS.map((extension) => `jest.config.${extension}`), "jest.config.json"],
282
+ packageJsonField: "jest",
283
+ warning: "Jest configuration detected. Vitest is highly compatible with Jest, and so we recommend migrating. See the Vitest Jest migration guide: https://vitest.dev/guide/migration/jest, then re-run vp migrate."
284
+ }
285
+ ];
286
+ function hasDependency(packageJson, packageName) {
287
+ return [
288
+ "dependencies",
289
+ "devDependencies",
290
+ "optionalDependencies"
291
+ ].some((field) => {
292
+ const dependencies = packageJson[field];
293
+ return typeof dependencies === "object" && dependencies !== null && packageName in dependencies;
294
+ });
295
+ }
296
+ /**
297
+ * Detect tools that have a direct migration path worth showing before the
298
+ * regular Vite+ migration steps run.
299
+ */
300
+ function detectMigrationWarnings(projectPath, packages = []) {
301
+ const projectPaths = [projectPath, ...packages.map((workspacePackage) => path.join(projectPath, workspacePackage.path))];
302
+ const detected = /* @__PURE__ */ new Set();
303
+ let rootPackageJson;
304
+ for (const currentPath of projectPaths) {
305
+ const packageJsonPath = path.join(currentPath, "package.json");
306
+ if (!fs.existsSync(packageJsonPath)) continue;
307
+ let packageJson;
308
+ try {
309
+ packageJson = JSON.parse(fs.readFileSync(packageJsonPath, "utf8"));
310
+ } catch {
311
+ continue;
312
+ }
313
+ if (currentPath === projectPath) rootPackageJson = packageJson;
314
+ for (const detection of MIGRATION_WARNING_DETECTIONS) if ((hasDependency(packageJson, detection.packageName) || currentPath !== projectPath && rootPackageJson !== void 0 && hasDependency(rootPackageJson, detection.packageName)) && (detection.configFiles.some((configFile) => fs.existsSync(path.join(currentPath, configFile))) || "packageJsonField" in detection && Object.hasOwn(packageJson, detection.packageJsonField))) detected.add(detection.warning);
315
+ }
316
+ return MIGRATION_WARNING_DETECTIONS.map(({ warning }) => warning).filter((warning) => detected.has(warning));
317
+ }
260
318
  function detectConfigs(projectPath) {
261
319
  const configs = {};
262
320
  for (const config of VITE_CONFIG_FILES) if (fs.existsSync(path.join(projectPath, config))) {
@@ -431,7 +489,7 @@ async function resolveOxlintMigrateVersion(oxlintVersion) {
431
489
  if (!response.ok) return oxlintVersion;
432
490
  const packument = await response.json();
433
491
  if (packument.versions && Object.hasOwn(packument.versions, oxlintVersion)) return oxlintVersion;
434
- const candidates = Object.keys(packument.versions ?? {}).filter((version) => normalize$2(version) && isLessThanOrEqual(version, oxlintVersion));
492
+ const candidates = Object.keys(packument.versions ?? {}).filter((version) => normalize$3(version) && isLessThanOrEqual(version, oxlintVersion));
435
493
  return candidates.length > 0 ? candidates.toSorted(compareReversed)[0] : oxlintVersion;
436
494
  } catch {
437
495
  return oxlintVersion;
@@ -1865,7 +1923,7 @@ function vitestEcosystemCatalogReferencesPending(pkg, catalogDependencyResolver)
1865
1923
  pkg.optionalDependencies
1866
1924
  ]) {
1867
1925
  if (!dependencies) continue;
1868
- for (const [name, spec] of Object.entries(dependencies)) if (isAlignableVitestEcosystemPackage(name) && spec.startsWith("catalog:") && catalogDependencyResolver(spec, name) !== "5.0.5") return true;
1926
+ for (const [name, spec] of Object.entries(dependencies)) if (isAlignableVitestEcosystemPackage(name) && spec.startsWith("catalog:") && catalogDependencyResolver(spec, name) !== "5.1.0") return true;
1869
1927
  }
1870
1928
  return false;
1871
1929
  }
@@ -1960,7 +2018,7 @@ const range = (a, b, str) => {
1960
2018
  }
1961
2019
  return result;
1962
2020
  };
1963
- // ../../node_modules/.pnpm/brace-expansion@5.0.3/node_modules/brace-expansion/dist/esm/index.js
2021
+ // ../../node_modules/.pnpm/brace-expansion@5.0.12/node_modules/brace-expansion/dist/esm/index.js
1964
2022
  const escSlash = "\0SLASH" + Math.random() + "\0";
1965
2023
  const escOpen = "\0OPEN" + Math.random() + "\0";
1966
2024
  const escClose = "\0CLOSE" + Math.random() + "\0";
@@ -1975,8 +2033,11 @@ const slashPattern = /\\\\/g;
1975
2033
  const openPattern = /\\{/g;
1976
2034
  const closePattern = /\\}/g;
1977
2035
  const commaPattern = /\\,/g;
1978
- const periodPattern = /\\./g;
2036
+ const periodPattern = /\\\./g;
1979
2037
  const EXPANSION_MAX = 1e5;
2038
+ const EXPANSION_MAX_LENGTH = 4e6;
2039
+ const EXPANSION_MAX_DEPTH = 1e3;
2040
+ const EXPANSION_MAX_REWRITES = 1e3;
1980
2041
  function numeric(str) {
1981
2042
  return !isNaN(str) ? parseInt(str, 10) : str.charCodeAt(0);
1982
2043
  }
@@ -1986,32 +2047,43 @@ function escapeBraces(str) {
1986
2047
  function unescapeBraces(str) {
1987
2048
  return str.replace(escSlashPattern, "\\").replace(escOpenPattern, "{").replace(escClosePattern, "}").replace(escCommaPattern, ",").replace(escPeriodPattern, ".");
1988
2049
  }
2050
+ function pushAll(target, items) {
2051
+ for (let i = 0; i < items.length; i++) target.push(items[i]);
2052
+ }
1989
2053
  /**
1990
2054
  * Basically just str.split(","), but handling cases
1991
2055
  * where we have nested braced sections, which should be
1992
2056
  * treated as individual members, like {a,{b,c},d}
1993
2057
  */
1994
2058
  function parseCommaParts(str) {
1995
- if (!str) return [""];
1996
2059
  const parts = [];
1997
- const m = balanced("{", "}", str);
1998
- if (!m) return str.split(",");
1999
- const { pre, body, post } = m;
2000
- const p = pre.split(",");
2001
- p[p.length - 1] += "{" + body + "}";
2002
- const postParts = parseCommaParts(post);
2003
- if (post.length) {
2004
- p[p.length - 1] += postParts.shift();
2005
- p.push.apply(p, postParts);
2006
- }
2007
- parts.push.apply(parts, p);
2008
- return parts;
2060
+ let carry = "";
2061
+ for (;;) {
2062
+ const m = balanced("{", "}", str);
2063
+ if (!m) {
2064
+ const tail = str.split(",");
2065
+ tail[0] = carry + tail[0];
2066
+ pushAll(parts, tail);
2067
+ return parts;
2068
+ }
2069
+ const { pre, body, post } = m;
2070
+ const p = pre.split(",");
2071
+ p[0] = carry + p[0];
2072
+ p[p.length - 1] += "{" + body + "}";
2073
+ if (!post.length) {
2074
+ pushAll(parts, p);
2075
+ return parts;
2076
+ }
2077
+ carry = p.pop();
2078
+ pushAll(parts, p);
2079
+ str = post;
2080
+ }
2009
2081
  }
2010
2082
  function expand(str, options = {}) {
2011
2083
  if (!str) return [];
2012
- const { max = EXPANSION_MAX } = options;
2084
+ const { max = EXPANSION_MAX, maxLength = EXPANSION_MAX_LENGTH, maxDepth = EXPANSION_MAX_DEPTH, maxRewrites = EXPANSION_MAX_REWRITES } = options;
2013
2085
  if (str.slice(0, 2) === "{}") str = "\\{\\}" + str.slice(2);
2014
- return expand_(escapeBraces(str), max, true).map(unescapeBraces);
2086
+ return expand_(escapeBraces(str), max, maxLength, maxDepth, 0, maxRewrites, true).map(unescapeBraces);
2015
2087
  }
2016
2088
  function embrace(str) {
2017
2089
  return "{" + str + "}";
@@ -2025,112 +2097,151 @@ function lte(i, y) {
2025
2097
  function gte(i, y) {
2026
2098
  return i >= y;
2027
2099
  }
2028
- function expand_(str, max, isTop) {
2029
- /** @type {string[]} */
2030
- const expansions = [];
2031
- const m = balanced("{", "}", str);
2032
- if (!m) return [str];
2033
- const pre = m.pre;
2034
- const post = m.post.length ? expand_(m.post, max, false) : [""];
2035
- if (/\$$/.test(m.pre)) for (let k = 0; k < post.length && k < max; k++) {
2036
- const expansion = pre + "{" + m.body + "}" + post[k];
2037
- expansions.push(expansion);
2100
+ function combine(acc, pre, values, max, maxLength, dropEmpties) {
2101
+ const out = [];
2102
+ let length = 0;
2103
+ for (let a = 0; a < acc.length; a++) for (let v = 0; v < values.length; v++) {
2104
+ if (out.length >= max) return out;
2105
+ const expansion = acc[a] + pre + values[v];
2106
+ if (dropEmpties && !expansion) continue;
2107
+ if (length + expansion.length > maxLength) return out;
2108
+ out.push(expansion);
2109
+ length += expansion.length;
2038
2110
  }
2039
- else {
2111
+ return out;
2112
+ }
2113
+ function expandSequence(body, isAlphaSequence, max, maxLength) {
2114
+ const n = body.split(/\.\./);
2115
+ const N = [];
2116
+ /* c8 ignore start */
2117
+ if (n[0] === void 0 || n[1] === void 0) return N;
2118
+ /* c8 ignore stop */
2119
+ const x = numeric(n[0]);
2120
+ const y = numeric(n[1]);
2121
+ const width = Math.max(n[0].length, n[1].length);
2122
+ let incr = n.length === 3 && n[2] !== void 0 ? Math.max(Math.abs(numeric(n[2])), 1) : 1;
2123
+ let test = lte;
2124
+ if (y < x) {
2125
+ incr *= -1;
2126
+ test = gte;
2127
+ }
2128
+ const pad = n.some(isPadded);
2129
+ let length = 0;
2130
+ for (let i = x; test(i, y) && N.length < max; i += incr) {
2131
+ let c;
2132
+ if (isAlphaSequence) {
2133
+ c = String.fromCharCode(i);
2134
+ if (c === "\\") c = "";
2135
+ } else {
2136
+ c = String(i);
2137
+ if (pad) {
2138
+ const need = width - c.length;
2139
+ if (need > 0) {
2140
+ const z = new Array(need + 1).join("0");
2141
+ if (i < 0) c = "-" + z + c.slice(1);
2142
+ else c = z + c;
2143
+ }
2144
+ }
2145
+ }
2146
+ if (length + c.length > maxLength) break;
2147
+ N.push(c);
2148
+ length += c.length;
2149
+ }
2150
+ return N;
2151
+ }
2152
+ function expand_(str, max, maxLength, maxDepth, depth, maxRewrites, isTop) {
2153
+ if (depth > maxDepth) return [str];
2154
+ let acc = [""];
2155
+ let rewrites = 0;
2156
+ let dropEmpties = false;
2157
+ let firstGroup = true;
2158
+ for (;;) {
2159
+ const m = balanced("{", "}", str);
2160
+ if (!m) return combine(acc, str, [""], max, maxLength, dropEmpties);
2161
+ const pre = m.pre;
2162
+ if (/\$$/.test(pre)) {
2163
+ acc = combine(acc, pre + "{" + m.body + "}", [""], max, maxLength, dropEmpties && !m.post.length);
2164
+ firstGroup = false;
2165
+ if (!m.post.length) break;
2166
+ str = m.post;
2167
+ continue;
2168
+ }
2040
2169
  const isNumericSequence = /^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(m.body);
2041
2170
  const isAlphaSequence = /^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(m.body);
2042
2171
  const isSequence = isNumericSequence || isAlphaSequence;
2043
2172
  const isOptions = m.body.indexOf(",") >= 0;
2044
2173
  if (!isSequence && !isOptions) {
2045
- if (m.post.match(/,(?!,).*\}/)) {
2174
+ if (rewrites < maxRewrites && m.post.match(/,(?!,).*\}/)) {
2175
+ rewrites++;
2046
2176
  str = m.pre + "{" + m.body + escClose + m.post;
2047
- return expand_(str, max, true);
2177
+ isTop = true;
2178
+ continue;
2048
2179
  }
2049
- return [str];
2180
+ return combine(acc, pre + "{" + m.body + "}" + m.post, [""], max, maxLength, dropEmpties);
2050
2181
  }
2051
- let n;
2052
- if (isSequence) n = m.body.split(/\.\./);
2182
+ if (firstGroup) {
2183
+ dropEmpties = isTop && !isSequence;
2184
+ firstGroup = false;
2185
+ }
2186
+ let values;
2187
+ if (isSequence) values = expandSequence(m.body, isAlphaSequence, max, maxLength);
2053
2188
  else {
2054
- n = parseCommaParts(m.body);
2189
+ let n = parseCommaParts(m.body);
2055
2190
  if (n.length === 1 && n[0] !== void 0) {
2056
- n = expand_(n[0], max, false).map(embrace);
2191
+ n = expand_(n[0], max, maxLength, maxDepth, depth + 1, maxRewrites, false).map(embrace);
2057
2192
  /* c8 ignore start */
2058
- if (n.length === 1) return post.map((p) => m.pre + n[0] + p);
2059
- }
2060
- }
2061
- let N;
2062
- if (isSequence && n[0] !== void 0 && n[1] !== void 0) {
2063
- const x = numeric(n[0]);
2064
- const y = numeric(n[1]);
2065
- const width = Math.max(n[0].length, n[1].length);
2066
- let incr = n.length === 3 && n[2] !== void 0 ? Math.abs(numeric(n[2])) : 1;
2067
- let test = lte;
2068
- if (y < x) {
2069
- incr *= -1;
2070
- test = gte;
2193
+ if (n.length === 1) {
2194
+ acc = combine(acc, pre + n[0], [""], max, maxLength, dropEmpties && !m.post.length);
2195
+ if (!m.post.length) break;
2196
+ str = m.post;
2197
+ continue;
2198
+ }
2071
2199
  }
2072
- const pad = n.some(isPadded);
2073
- N = [];
2074
- for (let i = x; test(i, y); i += incr) {
2075
- let c;
2076
- if (isAlphaSequence) {
2077
- c = String.fromCharCode(i);
2078
- if (c === "\\") c = "";
2079
- } else {
2080
- c = String(i);
2081
- if (pad) {
2082
- const need = width - c.length;
2083
- if (need > 0) {
2084
- const z = new Array(need + 1).join("0");
2085
- if (i < 0) c = "-" + z + c.slice(1);
2086
- else c = z + c;
2087
- }
2088
- }
2200
+ let dropsEmpties = dropEmpties && !m.post.length && !pre;
2201
+ for (let d = 0; dropsEmpties && d < acc.length; d++) if (acc[d]) dropsEmpties = false;
2202
+ values = [];
2203
+ let valuesLength = 0;
2204
+ outer: for (let j = 0; j < n.length; j++) {
2205
+ const expanded = expand_(n[j], max, maxLength, maxDepth, depth + 1, maxRewrites, false);
2206
+ for (let k = 0; k < expanded.length; k++) {
2207
+ const v = expanded[k];
2208
+ if (dropsEmpties && !v) continue;
2209
+ if (values.length >= max || valuesLength + v.length > maxLength) break outer;
2210
+ values.push(v);
2211
+ valuesLength += v.length;
2089
2212
  }
2090
- N.push(c);
2091
2213
  }
2092
- } else {
2093
- N = [];
2094
- for (let j = 0; j < n.length; j++) N.push.apply(N, expand_(n[j], max, false));
2095
- }
2096
- for (let j = 0; j < N.length; j++) for (let k = 0; k < post.length && expansions.length < max; k++) {
2097
- const expansion = pre + N[j] + post[k];
2098
- if (!isTop || isSequence || expansion) expansions.push(expansion);
2099
2214
  }
2215
+ acc = combine(acc, pre, values, max, maxLength, dropEmpties && !m.post.length);
2216
+ if (!m.post.length) break;
2217
+ str = m.post;
2100
2218
  }
2101
- return expansions;
2219
+ return acc;
2102
2220
  }
2103
- // ../../node_modules/.pnpm/minimatch@10.2.4/node_modules/minimatch/dist/esm/assert-valid-pattern.js
2104
- const MAX_PATTERN_LENGTH = 65536;
2105
- const assertValidPattern = (pattern) => {
2106
- if (typeof pattern !== "string") throw new TypeError("invalid pattern");
2107
- if (pattern.length > MAX_PATTERN_LENGTH) throw new TypeError("pattern is too long");
2108
- };
2109
- // ../../node_modules/.pnpm/minimatch@10.2.4/node_modules/minimatch/dist/esm/brace-expressions.js
2221
+ // ../../node_modules/.pnpm/@isaacs+nonrecursive-glob-match@1.0.3/node_modules/@isaacs/nonrecursive-glob-match/dist/esm/parse-class.js
2110
2222
  const posixClasses = {
2111
- "[:alnum:]": ["\\p{L}\\p{Nl}\\p{Nd}", true],
2112
- "[:alpha:]": ["\\p{L}\\p{Nl}", true],
2113
- "[:ascii:]": ["\\x00-\\x7f", false],
2114
- "[:blank:]": ["\\p{Zs}\\t", true],
2115
- "[:cntrl:]": ["\\p{Cc}", true],
2116
- "[:digit:]": ["\\p{Nd}", true],
2117
- "[:graph:]": [
2118
- "\\p{Z}\\p{C}",
2119
- true,
2120
- true
2121
- ],
2122
- "[:lower:]": ["\\p{Ll}", true],
2223
+ "[:alnum:]": ["\\p{L}\\p{Nl}\\p{Nd}"],
2224
+ "[:alpha:]": ["\\p{L}\\p{Nl}"],
2225
+ "[:ascii:]": ["\\x00-\\x7f"],
2226
+ "[:blank:]": ["\\p{Zs}\\t"],
2227
+ "[:cntrl:]": ["\\p{Cc}"],
2228
+ "[:digit:]": ["\\p{Nd}"],
2229
+ "[:graph:]": ["\\p{Z}\\p{C}", true],
2230
+ "[:lower:]": ["\\p{Ll}"],
2123
2231
  "[:print:]": ["\\p{C}", true],
2124
- "[:punct:]": ["\\p{P}", true],
2125
- "[:space:]": ["\\p{Z}\\t\\r\\n\\v\\f", true],
2126
- "[:upper:]": ["\\p{Lu}", true],
2127
- "[:word:]": ["\\p{L}\\p{Nl}\\p{Nd}\\p{Pc}", true],
2128
- "[:xdigit:]": ["A-Fa-f0-9", false]
2232
+ "[:punct:]": ["\\p{P}\\p{S}"],
2233
+ "[:space:]": ["\\p{Z}\\t\\r\\n\\v\\f"],
2234
+ "[:upper:]": ["\\p{Lu}"],
2235
+ "[:word:]": ["\\p{L}\\p{Nl}\\p{Nd}\\p{Pc}"],
2236
+ "[:xdigit:]": ["A-Fa-f0-9"]
2129
2237
  };
2130
2238
  const braceEscape = (s) => s.replace(/[[\]\\-]/g, "\\$&");
2131
- const regexpEscape = (s) => s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
2132
- const rangesToString = (ranges) => ranges.join("");
2133
- const parseClass = (glob, position) => {
2239
+ const noMatch = /$./;
2240
+ const parseClass = (glob, position, nocase = false, form) => {
2241
+ const norm = (c) => {
2242
+ const n = form ? c.normalize(form) : c;
2243
+ return [...n].length === 1 ? n : c;
2244
+ };
2134
2245
  const pos = position;
2135
2246
  /* c8 ignore start */
2136
2247
  if (glob.charAt(pos) !== "[") throw new Error("not in a brace expression");
@@ -2139,13 +2250,12 @@ const parseClass = (glob, position) => {
2139
2250
  const negs = [];
2140
2251
  let i = pos + 1;
2141
2252
  let sawStart = false;
2142
- let uflag = false;
2143
2253
  let escaping = false;
2144
2254
  let negate = false;
2145
2255
  let endPos = pos;
2146
2256
  let rangeStart = "";
2147
2257
  WHILE: while (i < glob.length) {
2148
- const c = glob.charAt(i);
2258
+ const c = String.fromCodePoint(glob.codePointAt(i));
2149
2259
  if ((c === "!" || c === "^") && i === pos + 1) {
2150
2260
  negate = true;
2151
2261
  i++;
@@ -2164,606 +2274,641 @@ const parseClass = (glob, position) => {
2164
2274
  }
2165
2275
  }
2166
2276
  if (c === "[" && !escaping) {
2167
- for (const [cls, [unip, u, neg]] of Object.entries(posixClasses)) if (glob.startsWith(cls, i)) {
2168
- if (rangeStart) return [
2169
- "$.",
2170
- false,
2171
- glob.length - pos,
2172
- true
2173
- ];
2277
+ for (const [cls, [unip, neg]] of Object.entries(posixClasses)) if (glob.startsWith(cls, i)) {
2278
+ if (rangeStart) return [noMatch, glob.length - pos];
2174
2279
  i += cls.length;
2175
2280
  if (neg) negs.push(unip);
2176
2281
  else ranges.push(unip);
2177
- uflag = uflag || u;
2178
2282
  continue WHILE;
2179
2283
  }
2180
2284
  }
2181
2285
  escaping = false;
2286
+ const n = norm(c);
2182
2287
  if (rangeStart) {
2183
- if (c > rangeStart) ranges.push(braceEscape(rangeStart) + "-" + braceEscape(c));
2184
- else if (c === rangeStart) ranges.push(braceEscape(c));
2288
+ if (n.codePointAt(0) > rangeStart.codePointAt(0)) ranges.push(braceEscape(rangeStart) + "-" + braceEscape(n));
2289
+ else if (n === rangeStart) ranges.push(braceEscape(n));
2185
2290
  rangeStart = "";
2186
- i++;
2291
+ i += c.length;
2187
2292
  continue;
2188
2293
  }
2189
- if (glob.startsWith("-]", i + 1)) {
2190
- ranges.push(braceEscape(c + "-"));
2191
- i += 2;
2294
+ if (glob.startsWith("-]", i + c.length)) {
2295
+ ranges.push(braceEscape(n + "-"));
2296
+ i += c.length + 1;
2192
2297
  continue;
2193
2298
  }
2194
- if (glob.startsWith("-", i + 1)) {
2195
- rangeStart = c;
2196
- i += 2;
2299
+ if (glob.startsWith("-", i + c.length)) {
2300
+ rangeStart = n;
2301
+ i += c.length + 1;
2197
2302
  continue;
2198
2303
  }
2199
- ranges.push(braceEscape(c));
2200
- i++;
2304
+ ranges.push(braceEscape(n));
2305
+ i += c.length;
2201
2306
  }
2202
- if (endPos < i) return [
2203
- "",
2204
- false,
2205
- 0,
2206
- false
2207
- ];
2208
- if (!ranges.length && !negs.length) return [
2209
- "$.",
2210
- false,
2211
- glob.length - pos,
2212
- true
2213
- ];
2214
- if (negs.length === 0 && ranges.length === 1 && /^\\?.$/.test(ranges[0]) && !negate) {
2215
- const r = ranges[0].length === 2 ? ranges[0].slice(-1) : ranges[0];
2216
- return [
2217
- regexpEscape(r),
2218
- false,
2219
- endPos - pos,
2220
- false
2221
- ];
2222
- }
2223
- const sranges = "[" + (negate ? "^" : "") + rangesToString(ranges) + "]";
2224
- const snegs = "[" + (negate ? "" : "^") + rangesToString(negs) + "]";
2225
- return [
2226
- ranges.length && negs.length ? "(" + sranges + "|" + snegs + ")" : ranges.length ? sranges : snegs,
2227
- uflag,
2228
- endPos - pos,
2229
- true
2230
- ];
2307
+ if (endPos < i) return [noMatch, 0];
2308
+ if (!ranges.length && !negs.length) return [noMatch, glob.length - pos];
2309
+ const sranges = "[" + (negate ? "^" : "") + ranges.join("") + "]";
2310
+ const snegs = "[" + (negate ? "" : "^") + negs.join("") + "]";
2311
+ const comb = "^" + (ranges.length && negs.length ? "(" + sranges + "|" + snegs + ")" : ranges.length ? sranges : snegs);
2312
+ return [new RegExp(comb, nocase ? "iu" : "u"), endPos - pos];
2231
2313
  };
2232
- // ../../node_modules/.pnpm/minimatch@10.2.4/node_modules/minimatch/dist/esm/unescape.js
2233
- /**
2234
- * Un-escape a string that has been escaped with {@link escape}.
2235
- *
2236
- * If the {@link MinimatchOptions.windowsPathsNoEscape} option is used, then
2237
- * square-bracket escapes are removed, but not backslash escapes.
2238
- *
2239
- * For example, it will turn the string `'[*]'` into `*`, but it will not
2240
- * turn `'\\*'` into `'*'`, because `\` is a path separator in
2241
- * `windowsPathsNoEscape` mode.
2242
- *
2243
- * When `windowsPathsNoEscape` is not set, then both square-bracket escapes and
2244
- * backslash escapes are removed.
2245
- *
2246
- * Slashes (and backslashes in `windowsPathsNoEscape` mode) cannot be escaped
2247
- * or unescaped.
2248
- *
2249
- * When `magicalBraces` is not set, escapes of braces (`{` and `}`) will not be
2250
- * unescaped.
2251
- */
2252
- const unescape = (s, { windowsPathsNoEscape = false, magicalBraces = true } = {}) => {
2253
- if (magicalBraces) return windowsPathsNoEscape ? s.replace(/\[([^\/\\])\]/g, "$1") : s.replace(/((?!\\).|^)\[([^\/\\])\]/g, "$1$2").replace(/\\([^\/])/g, "$1");
2254
- return windowsPathsNoEscape ? s.replace(/\[([^\/\\{}])\]/g, "$1") : s.replace(/((?!\\).|^)\[([^\/\\{}])\]/g, "$1$2").replace(/\\([^\/{}])/g, "$1");
2314
+ // ../../node_modules/.pnpm/@isaacs+nonrecursive-glob-match@1.0.3/node_modules/@isaacs/nonrecursive-glob-match/dist/esm/index.js
2315
+ const MATCH = {
2316
+ t: "match",
2317
+ id: 0
2255
2318
  };
2256
- // ../../node_modules/.pnpm/minimatch@10.2.4/node_modules/minimatch/dist/esm/ast.js
2257
- var _a;
2258
- const types = /* @__PURE__ */ new Set([
2259
- "!",
2260
- "?",
2261
- "+",
2262
- "*",
2263
- "@"
2264
- ]);
2265
- const isExtglobType = (c) => types.has(c);
2266
- const isExtglobAST = (c) => isExtglobType(c.type);
2267
- const adoptionMap = /* @__PURE__ */ new Map([
2268
- ["!", ["@"]],
2269
- ["?", ["?", "@"]],
2270
- ["@", ["@"]],
2271
- ["*", [
2272
- "*",
2273
- "+",
2274
- "?",
2275
- "@"
2276
- ]],
2277
- ["+", ["+", "@"]]
2278
- ]);
2279
- const adoptionWithSpaceMap = /* @__PURE__ */ new Map([
2280
- ["!", ["?"]],
2281
- ["@", ["?"]],
2282
- ["+", ["?", "*"]]
2283
- ]);
2284
- const adoptionAnyMap = /* @__PURE__ */ new Map([
2285
- ["!", ["?", "@"]],
2286
- ["?", ["?", "@"]],
2287
- ["@", ["?", "@"]],
2288
- ["*", [
2289
- "*",
2290
- "+",
2291
- "?",
2292
- "@"
2293
- ]],
2294
- ["+", [
2295
- "+",
2296
- "@",
2297
- "?",
2298
- "*"
2299
- ]]
2300
- ]);
2301
- const usurpMap = /* @__PURE__ */ new Map([
2302
- ["!", /* @__PURE__ */ new Map([["!", "@"]])],
2303
- ["?", /* @__PURE__ */ new Map([["*", "*"], ["+", "*"]])],
2304
- ["@", /* @__PURE__ */ new Map([
2305
- ["!", "!"],
2306
- ["?", "?"],
2307
- ["@", "@"],
2308
- ["*", "*"],
2309
- ["+", "+"]
2310
- ])],
2311
- ["+", /* @__PURE__ */ new Map([["?", "*"], ["*", "*"]])]
2312
- ]);
2313
- const startNoTraversal = "(?!(?:^|/)\\.\\.?(?:$|/))";
2314
- const startNoDot = "(?!\\.)";
2315
- const addPatternStart = /* @__PURE__ */ new Set(["[", "."]);
2316
- const justDots = /* @__PURE__ */ new Set(["..", "."]);
2317
- const reSpecials = /* @__PURE__ */ new Set("().*{}+?[]^$\\!");
2318
- const regExpEscape$1 = (s) => s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
2319
- const qmark = "[^/]";
2320
- const star$1 = "[^/]*?";
2321
- const starNoEmpty = "[^/]+?";
2322
- let ID = 0;
2323
- var AST = class {
2324
- type;
2325
- #root;
2326
- #hasMagic;
2327
- #uflag = false;
2328
- #parts = [];
2329
- #parent;
2330
- #parentIndex;
2331
- #negs;
2332
- #filledNegs = false;
2333
- #options;
2334
- #toString;
2335
- #emptyExt = false;
2336
- id = ++ID;
2337
- get depth() {
2338
- return (this.#parent?.depth ?? -1) + 1;
2339
- }
2340
- [Symbol.for("nodejs.util.inspect.custom")]() {
2341
- return {
2342
- "@@type": "AST",
2343
- id: this.id,
2344
- type: this.type,
2345
- root: this.#root.id,
2346
- parent: this.#parent?.id,
2347
- depth: this.depth,
2348
- partsLength: this.#parts.length,
2349
- parts: this.#parts
2350
- };
2351
- }
2352
- constructor(type, parent, options = {}) {
2353
- this.type = type;
2354
- if (type) this.#hasMagic = true;
2355
- this.#parent = parent;
2356
- this.#root = this.#parent ? this.#parent.#root : this;
2357
- this.#options = this.#root === this ? options : this.#root.#options;
2358
- this.#negs = this.#root === this ? [] : this.#root.#negs;
2359
- if (type === "!" && !this.#root.#filledNegs) this.#negs.push(this);
2360
- this.#parentIndex = this.#parent ? this.#parent.#parts.length : 0;
2361
- }
2362
- get hasMagic() {
2363
- /* c8 ignore start */
2364
- if (this.#hasMagic !== void 0) return this.#hasMagic;
2365
- /* c8 ignore stop */
2366
- for (const p of this.#parts) {
2367
- if (typeof p === "string") continue;
2368
- if (p.type || p.hasMagic) return this.#hasMagic = true;
2319
+ const extTypes = "!?+*@";
2320
+ const lit = (ch) => ({
2321
+ t: "lit",
2322
+ ch
2323
+ });
2324
+ const reEscape = (s) => s.replace(/[\\^$.*+?()[\]{}|/]/g, "\\$&");
2325
+ const newFoldRe = (s) => new RegExp(`^${reEscape(s)}$`, "iu");
2326
+ const foldCache = /* @__PURE__ */ new Map();
2327
+ const foldRe = (ch) => {
2328
+ let re = foldCache.get(ch);
2329
+ if (!re) {
2330
+ re = newFoldRe(ch);
2331
+ if (foldCache.size >= 1e3) foldCache.clear();
2332
+ foldCache.set(ch, re);
2333
+ }
2334
+ return re;
2335
+ };
2336
+ const litMatch = (l, c) => {
2337
+ if (c === l.ch) return true;
2338
+ if (!l.re) return false;
2339
+ const code = c.charCodeAt(0);
2340
+ if (code >= 128) return l.re.test(c);
2341
+ const ascii = l.ascii ??= /* @__PURE__ */ new Uint8Array(128);
2342
+ ascii[code] ||= l.re.test(c) ? 1 : 2;
2343
+ return ascii[code] === 1;
2344
+ };
2345
+ const tokenize = (p, nocase, noext, form) => {
2346
+ const toks = [];
2347
+ for (let i = 0; i < p.length;) {
2348
+ const c = String.fromCodePoint(p.codePointAt(i));
2349
+ if (c === "\\") {
2350
+ const e = p.codePointAt(i + 1);
2351
+ const ch = e === void 0 ? c : String.fromCodePoint(e);
2352
+ toks.push(lit(ch));
2353
+ i += 1 + ch.length;
2354
+ continue;
2369
2355
  }
2370
- return this.#hasMagic;
2371
- }
2372
- toString() {
2373
- if (this.#toString !== void 0) return this.#toString;
2374
- if (!this.type) return this.#toString = this.#parts.map((p) => String(p)).join("");
2375
- else return this.#toString = this.type + "(" + this.#parts.map((p) => String(p)).join("|") + ")";
2376
- }
2377
- #fillNegs() {
2378
- /* c8 ignore start */
2379
- if (this !== this.#root) throw new Error("should only call on root");
2380
- if (this.#filledNegs) return this;
2381
- /* c8 ignore stop */
2382
- this.toString();
2383
- this.#filledNegs = true;
2384
- let n;
2385
- while (n = this.#negs.pop()) {
2386
- if (n.type !== "!") continue;
2387
- let p = n;
2388
- let pp = p.#parent;
2389
- while (pp) {
2390
- for (let i = p.#parentIndex + 1; !pp.type && i < pp.#parts.length; i++) for (const part of n.#parts) {
2391
- /* c8 ignore start */
2392
- if (typeof part === "string") throw new Error("string part in extglob AST??");
2393
- /* c8 ignore stop */
2394
- part.copyIn(pp.#parts[i]);
2395
- }
2396
- p = pp;
2397
- pp = p.#parent;
2356
+ if (c === "[") {
2357
+ const [re, consumed] = parseClass(p, i, nocase, form);
2358
+ if (consumed) {
2359
+ toks.push({
2360
+ t: "class",
2361
+ re
2362
+ });
2363
+ i += consumed;
2364
+ continue;
2398
2365
  }
2399
2366
  }
2400
- return this;
2401
- }
2402
- push(...parts) {
2403
- for (const p of parts) {
2404
- if (p === "") continue;
2405
- /* c8 ignore start */
2406
- if (typeof p !== "string" && !(p instanceof _a && p.#parent === this)) throw new Error("invalid part: " + p);
2407
- /* c8 ignore stop */
2408
- this.#parts.push(p);
2367
+ if (!noext && extTypes.includes(c) && p[i + 1] === "(") {
2368
+ toks.push({
2369
+ t: "open",
2370
+ type: c
2371
+ });
2372
+ i += 2;
2373
+ continue;
2409
2374
  }
2375
+ toks.push(!noext && c === "|" ? { t: "bar" } : !noext && c === ")" ? { t: "close" } : c === "*" ? { t: "star" } : c === "?" ? { t: "any" } : lit(c));
2376
+ i += c.length;
2410
2377
  }
2411
- toJSON() {
2412
- const ret = this.type === null ? this.#parts.slice().map((p) => typeof p === "string" ? p : p.toJSON()) : [this.type, ...this.#parts.map((p) => p.toJSON())];
2413
- if (this.isStart() && !this.type) ret.unshift([]);
2414
- if (this.isEnd() && (this === this.#root || this.#root.#filledNegs && this.#parent?.type === "!")) ret.push({});
2415
- return ret;
2378
+ return toks;
2379
+ };
2380
+ const pair = (toks) => {
2381
+ const pairs = /* @__PURE__ */ new Map();
2382
+ const stack = [];
2383
+ toks.forEach((tok, i) => {
2384
+ if (tok.t === "open") stack.push(i);
2385
+ else if (tok.t === "close" && stack.length) pairs.set(stack.pop(), i);
2386
+ });
2387
+ return pairs;
2388
+ };
2389
+ const build$8 = (toks, pairs, start, end, top) => {
2390
+ let seq = [];
2391
+ const alts = [seq];
2392
+ for (let i = start; i < end; i++) {
2393
+ const tok = toks[i];
2394
+ const close = pairs.get(i);
2395
+ if (tok.t === "open" && close !== void 0) {
2396
+ const sub = build$8(toks, pairs, i + 1, close, false);
2397
+ seq.push({
2398
+ t: "ext",
2399
+ type: tok.type,
2400
+ alts: sub
2401
+ });
2402
+ i = close;
2403
+ } else if (tok.t === "bar" && !top) alts.push(seq = []);
2404
+ else if (tok.t === "open") seq.push(lit(tok.type), lit("("));
2405
+ else if (tok.t === "bar") seq.push(lit("|"));
2406
+ else if (tok.t === "close") seq.push(lit(")"));
2407
+ else seq.push(tok);
2408
+ }
2409
+ return alts;
2410
+ };
2411
+ const normalize$2 = (items, form) => {
2412
+ const out = [];
2413
+ let run = "";
2414
+ const flush = () => {
2415
+ for (const ch of run.normalize(form)) out.push(lit(ch));
2416
+ run = "";
2417
+ };
2418
+ for (const it of items) {
2419
+ if (it.t === "lit") {
2420
+ run += it.ch;
2421
+ continue;
2422
+ }
2423
+ flush();
2424
+ out.push(it.t === "ext" ? {
2425
+ ...it,
2426
+ alts: it.alts.map((a) => normalize$2(a, form))
2427
+ } : it);
2416
2428
  }
2417
- isStart() {
2418
- if (this.#root === this) return true;
2419
- if (!this.#parent?.isStart()) return false;
2420
- if (this.#parentIndex === 0) return true;
2421
- const p = this.#parent;
2422
- for (let i = 0; i < this.#parentIndex; i++) {
2423
- const pp = p.#parts[i];
2424
- if (!(pp instanceof _a && pp.type === "!")) return false;
2429
+ flush();
2430
+ return out;
2431
+ };
2432
+ const compile = (items, nocase) => {
2433
+ let id = 1;
2434
+ const split = (out) => ({
2435
+ t: "split",
2436
+ id: id++,
2437
+ out
2438
+ });
2439
+ const seq = (items, next) => items.reduceRight((next, it) => item(it, next), next);
2440
+ const item = (it, next) => {
2441
+ switch (it.t) {
2442
+ case "lit":
2443
+ const re = nocase ? foldRe(it.ch) : void 0;
2444
+ return {
2445
+ t: "lit",
2446
+ id: id++,
2447
+ ch: it.ch,
2448
+ re,
2449
+ next
2450
+ };
2451
+ case "any":
2452
+ case "star": return {
2453
+ t: it.t,
2454
+ id: id++,
2455
+ next
2456
+ };
2457
+ case "class": return {
2458
+ t: "class",
2459
+ id: id++,
2460
+ re: it.re,
2461
+ next
2462
+ };
2425
2463
  }
2464
+ const alts = (next) => it.alts.map((a) => seq(a, next));
2465
+ switch (it.type) {
2466
+ case "@": return split(alts(next));
2467
+ case "?": return split([next, ...alts(next)]);
2468
+ case "!": return {
2469
+ t: "neg",
2470
+ id: id++,
2471
+ sub: split(alts(MATCH)),
2472
+ next
2473
+ };
2474
+ }
2475
+ const after = split([]);
2476
+ const entry = split(alts(after));
2477
+ after.out.push(next, entry);
2478
+ return it.type === "*" ? after : entry;
2479
+ };
2480
+ return [seq(items, MATCH), id];
2481
+ };
2482
+ const show = (start) => {
2483
+ const lines = [];
2484
+ const seen = /* @__PURE__ */ new Set();
2485
+ const ref = (n) => n.t === "match" ? "match" : String(n.id);
2486
+ const walk = (n, indent) => {
2487
+ if (n.t === "match" || seen.has(n)) return;
2488
+ seen.add(n);
2489
+ const line = (desc) => lines.push(`${indent}${n.id}: ${desc}`);
2490
+ switch (n.t) {
2491
+ case "split":
2492
+ line(`split -> ${n.out.map(ref).join(", ")}`);
2493
+ for (const o of n.out) walk(o, indent);
2494
+ return;
2495
+ case "neg":
2496
+ line(`!(${ref(n.sub)}) -> ${ref(n.next)}`);
2497
+ walk(n.sub, indent + " ");
2498
+ return walk(n.next, indent);
2499
+ case "lit":
2500
+ line(`${JSON.stringify(n.ch)} -> ${ref(n.next)}`);
2501
+ break;
2502
+ case "class":
2503
+ line(`${n.re} -> ${ref(n.next)}`);
2504
+ break;
2505
+ default: line(`${n.t === "any" ? "?" : "*"} -> ${ref(n.next)}`);
2506
+ }
2507
+ walk(n.next, indent);
2508
+ };
2509
+ walk(start, "");
2510
+ return [`start -> ${ref(start)}`, ...lines].join("\n");
2511
+ };
2512
+ var State = class {
2513
+ gen;
2514
+ threads = [];
2515
+ match = false;
2516
+ runs = [];
2517
+ ids = [];
2518
+ constructor(gen) {
2519
+ this.gen = gen;
2520
+ }
2521
+ get dead() {
2522
+ return !this.threads.length && !this.match && !this.runs.length;
2523
+ }
2524
+ };
2525
+ const sameState = (a, b) => {
2526
+ if (a.ids.length !== b.ids.length) return false;
2527
+ if (a.runs.length !== b.runs.length) return false;
2528
+ if (a.ids.some((id, i) => id !== b.ids[i])) return false;
2529
+ return a.runs.every((r) => b.runs.some((o) => o.neg === r.neg && sameState(o.state, r.state)));
2530
+ };
2531
+ const marks = (size) => ({
2532
+ has: new Float64Array(size),
2533
+ seen: new Float64Array(size),
2534
+ gen: 0
2535
+ });
2536
+ var Sim = class {
2537
+ dots;
2538
+ dotStart;
2539
+ #marks;
2540
+ constructor(dots, dotStart, marks) {
2541
+ this.dots = dots;
2542
+ this.dotStart = dotStart;
2543
+ this.#marks = marks;
2544
+ }
2545
+ state() {
2546
+ return new State(++this.#marks.gen);
2547
+ }
2548
+ done(state) {
2549
+ state.ids = state.threads.map((n) => n.id).sort((a, b) => a - b);
2550
+ if (state.match) state.ids.unshift(MATCH.id);
2551
+ return state;
2552
+ }
2553
+ #visit(state, node) {
2554
+ const { seen } = this.#marks;
2555
+ if (seen[node.id] === state.gen) return false;
2556
+ seen[node.id] = state.gen;
2426
2557
  return true;
2427
2558
  }
2428
- isEnd() {
2429
- if (this.#root === this) return true;
2430
- if (this.#parent?.type === "!") return true;
2431
- if (!this.#parent?.isEnd()) return false;
2432
- if (!this.type) return this.#parent?.isEnd();
2433
- /* c8 ignore start */
2434
- const pl = this.#parent ? this.#parent.#parts.length : 0;
2435
- /* c8 ignore stop */
2436
- return this.#parentIndex === pl - 1;
2437
- }
2438
- copyIn(part) {
2439
- if (typeof part === "string") this.push(part);
2440
- else this.push(part.clone(this));
2441
- }
2442
- clone(parent) {
2443
- const c = new _a(this.type, parent);
2444
- for (const p of this.#parts) c.copyIn(p);
2445
- return c;
2446
- }
2447
- static #parseAST(str, ast, pos, opt, extDepth) {
2448
- const maxDepth = opt.maxExtglobRecursion ?? 2;
2449
- let escaping = false;
2450
- let inBrace = false;
2451
- let braceStart = -1;
2452
- let braceNeg = false;
2453
- if (ast.type === null) {
2454
- let i = pos;
2455
- let acc = "";
2456
- while (i < str.length) {
2457
- const c = str.charAt(i++);
2458
- if (escaping || c === "\\") {
2459
- escaping = !escaping;
2460
- acc += c;
2461
- continue;
2462
- }
2463
- if (inBrace) {
2464
- if (i === braceStart + 1) {
2465
- if (c === "^" || c === "!") braceNeg = true;
2466
- } else if (c === "]" && !(i === braceStart + 2 && braceNeg)) inBrace = false;
2467
- acc += c;
2468
- continue;
2469
- } else if (c === "[") {
2470
- inBrace = true;
2471
- braceStart = i;
2472
- braceNeg = false;
2473
- acc += c;
2474
- continue;
2475
- }
2476
- if (!opt.noext && isExtglobType(c) && str.charAt(i) === "(" && extDepth <= maxDepth) {
2477
- ast.push(acc);
2478
- acc = "";
2479
- const ext = new _a(c, ast);
2480
- i = _a.#parseAST(str, ext, i, opt, extDepth + 1);
2481
- ast.push(ext);
2482
- continue;
2483
- }
2484
- acc += c;
2485
- }
2486
- ast.push(acc);
2487
- return i;
2488
- }
2489
- let i = pos + 1;
2490
- let part = new _a(null, ast);
2491
- const parts = [];
2492
- let acc = "";
2493
- while (i < str.length) {
2494
- const c = str.charAt(i++);
2495
- if (escaping || c === "\\") {
2496
- escaping = !escaping;
2497
- acc += c;
2498
- continue;
2499
- }
2500
- if (inBrace) {
2501
- if (i === braceStart + 1) {
2502
- if (c === "^" || c === "!") braceNeg = true;
2503
- } else if (c === "]" && !(i === braceStart + 2 && braceNeg)) inBrace = false;
2504
- acc += c;
2505
- continue;
2506
- } else if (c === "[") {
2507
- inBrace = true;
2508
- braceStart = i;
2509
- braceNeg = false;
2510
- acc += c;
2511
- continue;
2512
- }
2513
- /* c8 ignore stop */
2514
- if (!opt.noext && isExtglobType(c) && str.charAt(i) === "(" && (extDepth <= maxDepth || ast && ast.#canAdoptType(c))) {
2515
- const depthAdd = ast && ast.#canAdoptType(c) ? 0 : 1;
2516
- part.push(acc);
2517
- acc = "";
2518
- const ext = new _a(c, part);
2519
- part.push(ext);
2520
- i = _a.#parseAST(str, ext, i, opt, extDepth + depthAdd);
2521
- continue;
2522
- }
2523
- if (c === "|") {
2524
- part.push(acc);
2525
- acc = "";
2526
- parts.push(part);
2527
- part = new _a(null, ast);
2559
+ #addThread(state, node) {
2560
+ const { has } = this.#marks;
2561
+ if (has[node.id] === state.gen) return false;
2562
+ has[node.id] = state.gen;
2563
+ state.threads.push(node);
2564
+ return true;
2565
+ }
2566
+ restricted(i, top) {
2567
+ return top && (this.dots || this.dotStart && i === 0);
2568
+ }
2569
+ add(state, node, i, top) {
2570
+ switch (node.t) {
2571
+ case "split":
2572
+ if (!this.#visit(state, node)) return;
2573
+ for (const o of node.out) this.add(state, o, i, top);
2574
+ return;
2575
+ case "neg":
2576
+ if (!this.#visit(state, node)) return;
2577
+ const sub = this.state();
2578
+ this.add(sub, node.sub, i, false);
2579
+ this.done(sub);
2580
+ return this.addRun(state, {
2581
+ t: "run",
2582
+ neg: node,
2583
+ state: sub
2584
+ }, i, top);
2585
+ case "star":
2586
+ if (this.restricted(i, top)) return;
2587
+ if (this.#addThread(state, node)) this.add(state, node.next, i, top);
2588
+ return;
2589
+ case "match":
2590
+ state.match = true;
2591
+ return;
2592
+ default: this.#addThread(state, node);
2593
+ }
2594
+ }
2595
+ addRun(state, run, i, top) {
2596
+ for (const r of state.runs) if (r.neg === run.neg && sameState(r.state, run.state)) return;
2597
+ state.runs.push(run);
2598
+ if (!run.state.match) this.add(state, run.neg.next, i, top);
2599
+ }
2600
+ step(state, c, i, top) {
2601
+ const next = this.state();
2602
+ for (const th of state.threads) switch (th.t) {
2603
+ case "lit":
2604
+ if (litMatch(th, c)) this.add(next, th.next, i + 1, top);
2605
+ break;
2606
+ case "any":
2607
+ if (!this.restricted(i, top)) this.add(next, th.next, i + 1, top);
2608
+ break;
2609
+ case "class":
2610
+ if (!this.restricted(i, top) && th.re.test(c)) this.add(next, th.next, i + 1, top);
2611
+ break;
2612
+ case "star": if (!this.restricted(i, top)) this.add(next, th, i + 1, top);
2613
+ }
2614
+ if (!this.restricted(i, top)) for (const run of state.runs) {
2615
+ if (run.state.dead) {
2616
+ this.addRun(next, run, i + 1, top);
2528
2617
  continue;
2529
2618
  }
2530
- if (c === ")") {
2531
- if (acc === "" && ast.#parts.length === 0) ast.#emptyExt = true;
2532
- part.push(acc);
2533
- acc = "";
2534
- ast.push(...parts, part);
2535
- return i;
2536
- }
2537
- acc += c;
2538
- }
2539
- ast.type = null;
2540
- ast.#hasMagic = void 0;
2541
- ast.#parts = [str.substring(pos - 1)];
2542
- return i;
2543
- }
2544
- #canAdoptWithSpace(child) {
2545
- return this.#canAdopt(child, adoptionWithSpaceMap);
2546
- }
2547
- #canAdopt(child, map = adoptionMap) {
2548
- if (!child || typeof child !== "object" || child.type !== null || child.#parts.length !== 1 || this.type === null) return false;
2549
- const gc = child.#parts[0];
2550
- if (!gc || typeof gc !== "object" || gc.type === null) return false;
2551
- return this.#canAdoptType(gc.type, map);
2552
- }
2553
- #canAdoptType(c, map = adoptionAnyMap) {
2554
- return !!map.get(this.type)?.includes(c);
2555
- }
2556
- #adoptWithSpace(child, index) {
2557
- const gc = child.#parts[0];
2558
- const blank = new _a(null, gc, this.options);
2559
- blank.#parts.push("");
2560
- gc.push(blank);
2561
- this.#adopt(child, index);
2562
- }
2563
- #adopt(child, index) {
2564
- const gc = child.#parts[0];
2565
- this.#parts.splice(index, 1, ...gc.#parts);
2566
- for (const p of gc.#parts) if (typeof p === "object") p.#parent = this;
2567
- this.#toString = void 0;
2568
- }
2569
- #canUsurpType(c) {
2570
- return !!usurpMap.get(this.type)?.has(c);
2571
- }
2572
- #canUsurp(child) {
2573
- if (!child || typeof child !== "object" || child.type !== null || child.#parts.length !== 1 || this.type === null || this.#parts.length !== 1) return false;
2574
- const gc = child.#parts[0];
2575
- if (!gc || typeof gc !== "object" || gc.type === null) return false;
2576
- return this.#canUsurpType(gc.type);
2577
- }
2578
- #usurp(child) {
2579
- const m = usurpMap.get(this.type);
2580
- const gc = child.#parts[0];
2581
- const nt = m?.get(gc.type);
2582
- /* c8 ignore start - impossible */
2583
- if (!nt) return false;
2584
- /* c8 ignore stop */
2585
- this.#parts = gc.#parts;
2586
- for (const p of this.#parts) if (typeof p === "object") p.#parent = this;
2587
- this.type = nt;
2588
- this.#toString = void 0;
2589
- this.#emptyExt = false;
2590
- }
2591
- static fromGlob(pattern, options = {}) {
2592
- const ast = new _a(null, void 0, options);
2593
- _a.#parseAST(pattern, ast, 0, options, 0);
2594
- return ast;
2595
- }
2596
- toMMPattern() {
2597
- /* c8 ignore start */
2598
- if (this !== this.#root) return this.#root.toMMPattern();
2599
- /* c8 ignore stop */
2600
- const glob = this.toString();
2601
- const [re, body, hasMagic, uflag] = this.toRegExpSource();
2602
- if (!(hasMagic || this.#hasMagic || this.#options.nocase && !this.#options.nocaseMagicOnly && glob.toUpperCase() !== glob.toLowerCase())) return body;
2603
- const flags = (this.#options.nocase ? "i" : "") + (uflag ? "u" : "");
2604
- return Object.assign(new RegExp(`^${re}$`, flags), {
2605
- _src: re,
2606
- _glob: glob
2607
- });
2619
+ const sub = this.step(run.state, c, i, false);
2620
+ this.addRun(next, {
2621
+ t: "run",
2622
+ neg: run.neg,
2623
+ state: sub
2624
+ }, i + 1, top);
2625
+ }
2626
+ return this.done(next);
2608
2627
  }
2609
- get options() {
2610
- return this.#options;
2611
- }
2612
- toRegExpSource(allowDot) {
2613
- const dot = allowDot ?? !!this.#options.dot;
2614
- if (this.#root === this) {
2615
- this.#flatten();
2616
- this.#fillNegs();
2617
- }
2618
- if (!isExtglobAST(this)) {
2619
- const noEmpty = this.isStart() && this.isEnd() && !this.#parts.some((s) => typeof s !== "string");
2620
- const src = this.#parts.map((p) => {
2621
- const [re, _, hasMagic, uflag] = typeof p === "string" ? _a.#parseGlob(p, this.#hasMagic, noEmpty) : p.toRegExpSource(allowDot);
2622
- this.#hasMagic = this.#hasMagic || hasMagic;
2623
- this.#uflag = this.#uflag || uflag;
2624
- return re;
2625
- }).join("");
2626
- let start = "";
2627
- if (this.isStart()) {
2628
- if (typeof this.#parts[0] === "string") {
2629
- if (!(this.#parts.length === 1 && justDots.has(this.#parts[0]))) {
2630
- const aps = addPatternStart;
2631
- const needNoTrav = dot && aps.has(src.charAt(0)) || src.startsWith("\\.") && aps.has(src.charAt(2)) || src.startsWith("\\.\\.") && aps.has(src.charAt(4));
2632
- const needNoDot = !dot && !allowDot && aps.has(src.charAt(0));
2633
- start = needNoTrav ? startNoTraversal : needNoDot ? startNoDot : "";
2634
- }
2635
- }
2628
+ };
2629
+ const stateKey = (state) => {
2630
+ const ids = state.ids.join();
2631
+ if (!state.runs.length) return ids;
2632
+ return `${ids}|${state.runs.map((r) => `${r.neg.id}(${stateKey(r.state)})`).sort().join("|")}`;
2633
+ };
2634
+ const DFA_BUDGET = 1 << 18;
2635
+ var Dfa = class {
2636
+ #start;
2637
+ #states = /* @__PURE__ */ new Map();
2638
+ #size = 0;
2639
+ #plain;
2640
+ #dotStart;
2641
+ #sim;
2642
+ #dotSim;
2643
+ constructor(start, marks) {
2644
+ this.#start = start;
2645
+ this.#sim = new Sim(false, false, marks);
2646
+ this.#dotSim = new Sim(false, true, marks);
2647
+ }
2648
+ #make(state) {
2649
+ return {
2650
+ state,
2651
+ match: state.match,
2652
+ dead: state.dead,
2653
+ next: /* @__PURE__ */ new Map()
2654
+ };
2655
+ }
2656
+ #intern(state) {
2657
+ const key = stateKey(state);
2658
+ const found = this.#states.get(key);
2659
+ if (found) return found;
2660
+ if (this.#size > DFA_BUDGET) this.#clear();
2661
+ const d = this.#make(state);
2662
+ this.#states.set(key, d);
2663
+ this.#size += key.length + 1;
2664
+ return d;
2665
+ }
2666
+ #clear() {
2667
+ this.#states.clear();
2668
+ this.#size = 0;
2669
+ this.#plain = void 0;
2670
+ this.#dotStart = void 0;
2671
+ }
2672
+ start(dotStart) {
2673
+ if (dotStart) {
2674
+ if (this.#dotStart) return this.#dotStart;
2675
+ const state = this.#dotSim.state();
2676
+ this.#dotSim.add(state, this.#start, 0, true);
2677
+ return this.#dotStart = this.#make(this.#dotSim.done(state));
2678
+ }
2679
+ if (this.#plain) return this.#plain;
2680
+ const state = this.#sim.state();
2681
+ this.#sim.add(state, this.#start, 0, true);
2682
+ return this.#plain = this.#intern(this.#sim.done(state));
2683
+ }
2684
+ next(d, c) {
2685
+ const code = c.charCodeAt(0);
2686
+ const found = code < 128 ? void 0 : d.next.get(c);
2687
+ if (found) return found;
2688
+ 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));
2689
+ if (code < 128) {
2690
+ if (!d.ascii) {
2691
+ d.ascii = new Array(128);
2692
+ this.#size += 128;
2636
2693
  }
2637
- let end = "";
2638
- if (this.isEnd() && this.#root.#filledNegs && this.#parent?.type === "!") end = "(?:$|\\/)";
2639
- return [
2640
- start + src + end,
2641
- unescape(src),
2642
- this.#hasMagic = !!this.#hasMagic,
2643
- this.#uflag
2644
- ];
2645
- }
2646
- const repeated = this.type === "*" || this.type === "+";
2647
- const start = this.type === "!" ? "(?:(?!(?:" : "(?:";
2648
- let body = this.#partsToRegExp(dot);
2649
- if (this.isStart() && this.isEnd() && !body && this.type !== "!") {
2650
- const s = this.toString();
2651
- const me = this;
2652
- me.#parts = [s];
2653
- me.type = null;
2654
- me.#hasMagic = void 0;
2655
- return [
2656
- s,
2657
- unescape(this.toString()),
2658
- false,
2659
- false
2660
- ];
2661
- }
2662
- let bodyDotAllowed = !repeated || allowDot || dot || false ? "" : this.#partsToRegExp(true);
2663
- if (bodyDotAllowed === body) bodyDotAllowed = "";
2664
- if (bodyDotAllowed) body = `(?:${body})(?:${bodyDotAllowed})*?`;
2665
- let final = "";
2666
- if (this.type === "!" && this.#emptyExt) final = (this.isStart() && !dot ? startNoDot : "") + starNoEmpty;
2667
- else {
2668
- const close = this.type === "!" ? "))" + (this.isStart() && !dot && !allowDot ? startNoDot : "") + "[^/]*?)" : this.type === "@" ? ")" : this.type === "?" ? ")?" : this.type === "+" && bodyDotAllowed ? ")" : this.type === "*" && bodyDotAllowed ? `)?` : `)${this.type}`;
2669
- final = start + body + close;
2670
- }
2671
- return [
2672
- final,
2673
- unescape(body),
2674
- this.#hasMagic = !!this.#hasMagic,
2675
- this.#uflag
2676
- ];
2694
+ d.ascii[code] = n;
2695
+ } else d.next.set(c, n);
2696
+ this.#size++;
2697
+ return n;
2677
2698
  }
2678
- #flatten() {
2679
- if (!isExtglobAST(this)) {
2680
- for (const p of this.#parts) if (typeof p === "object") p.#flatten();
2681
- } else {
2682
- let iterations = 0;
2683
- let done = false;
2684
- do {
2685
- done = true;
2686
- for (let i = 0; i < this.#parts.length; i++) {
2687
- const c = this.#parts[i];
2688
- if (typeof c === "object") {
2689
- c.#flatten();
2690
- if (this.#canAdopt(c)) {
2691
- done = false;
2692
- this.#adopt(c, i);
2693
- } else if (this.#canAdoptWithSpace(c)) {
2694
- done = false;
2695
- this.#adoptWithSpace(c, i);
2696
- } else if (this.#canUsurp(c)) {
2697
- done = false;
2698
- this.#usurp(c);
2699
- }
2700
- }
2701
- }
2702
- } while (!done && ++iterations < 10);
2699
+ };
2700
+ const linear = (start) => {
2701
+ const nodes = [];
2702
+ for (let n = start; n.t !== "match"; n = n.next) {
2703
+ if (n.t === "split" || n.t === "neg") return void 0;
2704
+ nodes.push(n);
2705
+ }
2706
+ return nodes;
2707
+ };
2708
+ const testLinear = (nodes, chars, start, end) => {
2709
+ let ni = 0;
2710
+ let ci = start;
2711
+ let starNi = -1;
2712
+ let starCi = 0;
2713
+ while (ci < end) {
2714
+ const n = nodes[ni];
2715
+ if (n?.t === "star") {
2716
+ starNi = ni++;
2717
+ starCi = ci;
2718
+ continue;
2719
+ }
2720
+ const c = chars[ci];
2721
+ if (n && (n.t === "any" || n.t === "lit" && litMatch(n, c) || n.t === "class" && n.re.test(c))) {
2722
+ ni++;
2723
+ ci++;
2724
+ continue;
2703
2725
  }
2704
- this.#toString = void 0;
2726
+ if (starNi === -1) return false;
2727
+ ni = starNi + 1;
2728
+ ci = ++starCi;
2705
2729
  }
2706
- #partsToRegExp(dot) {
2707
- return this.#parts.map((p) => {
2708
- /* c8 ignore start */
2709
- if (typeof p === "string") throw new Error("string type in extglob ast??");
2710
- /* c8 ignore stop */
2711
- const [re, _, _hasMagic, uflag] = p.toRegExpSource(dot);
2712
- this.#uflag = this.#uflag || uflag;
2713
- return re;
2714
- }).filter((p) => !(this.isStart() && this.isEnd()) || !!p).join("|");
2715
- }
2716
- static #parseGlob(glob, hasMagic, noEmpty = false) {
2717
- let escaping = false;
2718
- let re = "";
2719
- let uflag = false;
2720
- let inStar = false;
2721
- for (let i = 0; i < glob.length; i++) {
2722
- const c = glob.charAt(i);
2723
- if (escaping) {
2724
- escaping = false;
2725
- re += (reSpecials.has(c) ? "\\" : "") + c;
2726
- continue;
2730
+ while (nodes[ni]?.t === "star") ni++;
2731
+ return ni === nodes.length;
2732
+ };
2733
+ const lengths = (items) => {
2734
+ let min = 0;
2735
+ let max = 0;
2736
+ for (const it of items) {
2737
+ const [lo, hi] = itemLengths(it);
2738
+ min += lo;
2739
+ max += hi;
2740
+ }
2741
+ return [min, max];
2742
+ };
2743
+ const itemLengths = (it) => {
2744
+ if (it.t === "star") return [0, Infinity];
2745
+ if (it.t !== "ext") return [1, 1];
2746
+ if (it.type === "!") return [0, Infinity];
2747
+ const alts = it.alts.map(lengths);
2748
+ const min = Math.min(...alts.map((a) => a[0]));
2749
+ const max = Math.max(...alts.map((a) => a[1]));
2750
+ const loop = max === 0 ? 0 : Infinity;
2751
+ return it.type === "@" ? [min, max] : it.type === "?" ? [0, max] : it.type === "*" ? [0, loop] : [min, loop];
2752
+ };
2753
+ const hasAffix = (lits, chars, start) => {
2754
+ for (let j = 0; j < lits.length; j++) if (!litMatch(lits[j], chars[start + j])) return false;
2755
+ return true;
2756
+ };
2757
+ const slashOrSurrogate = /[/\ud800-\udfff]/;
2758
+ const surrogate = /[\ud800-\udfff]/;
2759
+ const codePoints = (s) => surrogate.test(s) ? [...s] : s;
2760
+ const noSlash = (s) => {
2761
+ if (s.includes("/")) throw new Error("can only match a single path portion, got: " + s);
2762
+ };
2763
+ var Matcher = class {
2764
+ pattern;
2765
+ options;
2766
+ #start;
2767
+ #size;
2768
+ #marks;
2769
+ #dotsSim;
2770
+ #literal;
2771
+ #literalFold = false;
2772
+ #literalRe;
2773
+ #linear;
2774
+ #wild = false;
2775
+ #min = 0;
2776
+ #max = Infinity;
2777
+ #prefix = [];
2778
+ #suffix = [];
2779
+ #prefixStr;
2780
+ #suffixStr;
2781
+ #affix = false;
2782
+ #dfa;
2783
+ #form;
2784
+ constructor(pattern, options = {}) {
2785
+ if (pattern.includes("/")) throw new Error("can only match a single path portion, got pattern: " + pattern);
2786
+ this.pattern = pattern;
2787
+ this.options = options;
2788
+ const { nocase = false, noext = false, normalize: n } = options;
2789
+ this.#form = n === true ? "NFC" : n || void 0;
2790
+ const literal = /^[?*+@]\(\)$/.test(pattern);
2791
+ const toks = tokenize(pattern, nocase, noext || literal, this.#form);
2792
+ let [items] = build$8(toks, pair(toks), 0, toks.length, true);
2793
+ if (this.#form) items = normalize$2(items, this.#form);
2794
+ const [start, size] = compile(items, nocase);
2795
+ this.#start = start;
2796
+ this.#size = size;
2797
+ if (items.every((it) => it.t === "lit")) {
2798
+ this.#literal = items.map((it) => it.ch).join("");
2799
+ this.#literalFold = nocase;
2800
+ } else {
2801
+ const lit = (it) => it.t !== "lit" ? void 0 : nocase ? {
2802
+ ch: it.ch,
2803
+ re: foldRe(it.ch)
2804
+ } : { ch: it.ch };
2805
+ for (const it of items) {
2806
+ const l = lit(it);
2807
+ if (!l) break;
2808
+ this.#prefix.push(l);
2727
2809
  }
2728
- if (c === "*") {
2729
- if (inStar) continue;
2730
- inStar = true;
2731
- re += noEmpty && /^[*]+$/.test(glob) ? starNoEmpty : star$1;
2732
- hasMagic = true;
2733
- continue;
2734
- } else inStar = false;
2735
- if (c === "\\") {
2736
- if (i === glob.length - 1) re += "\\\\";
2737
- else escaping = true;
2738
- continue;
2810
+ for (let j = items.length - 1; j >= 0; j--) {
2811
+ const l = lit(items[j]);
2812
+ if (!l) break;
2813
+ this.#suffix.unshift(l);
2739
2814
  }
2740
- if (c === "[") {
2741
- const [src, needUflag, consumed, magic] = parseClass(glob, i);
2742
- if (consumed) {
2743
- re += src;
2744
- uflag = uflag || needUflag;
2745
- i += consumed - 1;
2746
- hasMagic = hasMagic || magic;
2747
- continue;
2748
- }
2815
+ this.#affix = !!(this.#prefix.length || this.#suffix.length);
2816
+ if (!nocase) {
2817
+ this.#prefixStr = this.#prefix.map((l) => l.ch).join("");
2818
+ this.#suffixStr = this.#suffix.map((l) => l.ch).join("");
2749
2819
  }
2750
- if (c === "?") {
2751
- re += qmark;
2752
- hasMagic = true;
2753
- continue;
2820
+ this.#linear = linear(this.#start)?.slice(this.#prefix.length, -this.#suffix.length || void 0);
2821
+ this.#wild = !!this.#linear?.every((n) => n.t === "star" || n.t === "any");
2822
+ const [min, max] = lengths(items);
2823
+ this.#min = min;
2824
+ this.#max = max;
2825
+ }
2826
+ }
2827
+ test(s) {
2828
+ if (this.#form) {
2829
+ noSlash(s);
2830
+ return this.#test(s.normalize(this.#form));
2831
+ }
2832
+ if (slashOrSurrogate.test(s)) {
2833
+ noSlash(s);
2834
+ return this.#test(s, [...s]);
2835
+ }
2836
+ return this.#test(s, s);
2837
+ }
2838
+ /**
2839
+ * The same as {@link Matcher#test}, but the string is not checked
2840
+ * for `/` chars, so the result for a string that has one is not
2841
+ * defined. Only use it for a string that is known to be one path
2842
+ * portion, such as a part of a path that was split on `/`. It can
2843
+ * be faster, because some patterns do not need to look at each char
2844
+ * of the string.
2845
+ */
2846
+ testUnchecked(s) {
2847
+ return this.#test(this.#form ? s.normalize(this.#form) : s);
2848
+ }
2849
+ #test(s, chars) {
2850
+ if (this.#literal !== void 0) return this.#literalFold ? (this.#literalRe ??= newFoldRe(this.#literal)).test(s) : s === this.#literal;
2851
+ const min = this.#min;
2852
+ const max = this.#max;
2853
+ if (chars === void 0) {
2854
+ const most = s.length;
2855
+ const least = most + 1 >> 1;
2856
+ if (most < min || least > max) return false;
2857
+ if (least < min || most > max) chars = codePoints(s);
2858
+ }
2859
+ if (chars !== void 0 && (chars.length < min || chars.length > max)) return false;
2860
+ const prefix = this.#prefix.length;
2861
+ if (this.#affix) {
2862
+ if (this.#prefixStr !== void 0 && this.#suffixStr !== void 0) {
2863
+ if (!s.startsWith(this.#prefixStr) || !s.endsWith(this.#suffixStr)) return false;
2864
+ } else {
2865
+ chars ??= codePoints(s);
2866
+ const end = chars.length - this.#suffix.length;
2867
+ if (!hasAffix(this.#prefix, chars, 0) || !hasAffix(this.#suffix, chars, end)) return false;
2754
2868
  }
2755
- re += regExpEscape$1(c);
2756
2869
  }
2757
- return [
2758
- re,
2759
- unescape(glob),
2760
- !!hasMagic,
2761
- uflag
2762
- ];
2870
+ const dotStart = !this.options.dot && s.startsWith(".");
2871
+ if (this.#linear) {
2872
+ if (s === "." || s === "..") return false;
2873
+ if (dotStart && !prefix) return false;
2874
+ if (this.#wild) return true;
2875
+ chars ??= codePoints(s);
2876
+ const end = chars.length - this.#suffix.length;
2877
+ return testLinear(this.#linear, chars, prefix, end);
2878
+ }
2879
+ chars ??= codePoints(s);
2880
+ if (s === "." || s === "..") {
2881
+ this.#marks ??= marks(this.#size);
2882
+ const sim = this.#dotsSim ??= new Sim(true, false, this.#marks);
2883
+ const start = sim.state();
2884
+ sim.add(start, this.#start, 0, true);
2885
+ let state = sim.done(start);
2886
+ for (let i = 0; i < chars.length; i++) state = sim.step(state, chars[i], i, true);
2887
+ return state.match;
2888
+ }
2889
+ this.#marks ??= marks(this.#size);
2890
+ const dfa = this.#dfa ??= new Dfa(this.#start, this.#marks);
2891
+ let d = dfa.start(dotStart);
2892
+ const str = chars === s;
2893
+ for (let i = 0; i < chars.length; i++) {
2894
+ if (d.dead) return false;
2895
+ const code = str ? s.charCodeAt(i) : chars[i].charCodeAt(0);
2896
+ d = d.ascii?.[code] ?? dfa.next(d, chars[i]);
2897
+ }
2898
+ return d.match;
2899
+ }
2900
+ /** a readable listing of the state machine */
2901
+ toString() {
2902
+ return show(this.#start);
2763
2903
  }
2764
2904
  };
2765
- _a = AST;
2766
- // ../../node_modules/.pnpm/minimatch@10.2.4/node_modules/minimatch/dist/esm/escape.js
2905
+ // ../../node_modules/.pnpm/minimatch@11.0.4/node_modules/minimatch/dist/esm/assert-valid-pattern.js
2906
+ const MAX_PATTERN_LENGTH = 65536;
2907
+ const assertValidPattern = (pattern) => {
2908
+ if (typeof pattern !== "string") throw new TypeError("invalid pattern");
2909
+ if (pattern.length > MAX_PATTERN_LENGTH) throw new TypeError("pattern is too long");
2910
+ };
2911
+ // ../../node_modules/.pnpm/minimatch@11.0.4/node_modules/minimatch/dist/esm/escape.js
2767
2912
  /**
2768
2913
  * Escape all magic characters in a glob pattern.
2769
2914
  *
@@ -2780,62 +2925,51 @@ const escape = (s, { windowsPathsNoEscape = false, magicalBraces = false } = {})
2780
2925
  if (magicalBraces) return windowsPathsNoEscape ? s.replace(/[?*()[\]{}]/g, "[$&]") : s.replace(/[?*()[\]\\{}]/g, "\\$&");
2781
2926
  return windowsPathsNoEscape ? s.replace(/[?*()[\]]/g, "[$&]") : s.replace(/[?*()[\]\\]/g, "\\$&");
2782
2927
  };
2783
- // ../../node_modules/.pnpm/minimatch@10.2.4/node_modules/minimatch/dist/esm/index.js
2928
+ // ../../node_modules/.pnpm/minimatch@11.0.4/node_modules/minimatch/dist/esm/unescape.js
2929
+ /**
2930
+ * Un-escape a string that has been escaped with {@link escape}.
2931
+ *
2932
+ * If the {@link MinimatchOptions.windowsPathsNoEscape} option is used, then
2933
+ * square-bracket escapes are removed, but not backslash escapes.
2934
+ *
2935
+ * For example, it will turn the string `'[*]'` into `*`, but it will not
2936
+ * turn `'\\*'` into `'*'`, because `\` is a path separator in
2937
+ * `windowsPathsNoEscape` mode.
2938
+ *
2939
+ * When `windowsPathsNoEscape` is not set, then both square-bracket escapes and
2940
+ * backslash escapes are removed.
2941
+ *
2942
+ * Slashes (and backslashes in `windowsPathsNoEscape` mode) cannot be escaped
2943
+ * or unescaped.
2944
+ *
2945
+ * When `magicalBraces` is not set, escapes of braces (`{` and `}`) will not be
2946
+ * unescaped.
2947
+ */
2948
+ const unescape = (s, { windowsPathsNoEscape = false, magicalBraces = true } = {}) => {
2949
+ if (magicalBraces) return windowsPathsNoEscape ? s.replace(/\[([^/\\])\]/g, "$1") : s.replace(/((?!\\).|^)\[([^/\\])\]/g, "$1$2").replace(/\\([^/])/g, "$1");
2950
+ return windowsPathsNoEscape ? s.replace(/\[([^/\\{}])\]/g, "$1") : s.replace(/((?!\\).|^)\[([^/\\{}])\]/g, "$1$2").replace(/\\([^/{}])/g, "$1");
2951
+ };
2952
+ // ../../node_modules/.pnpm/minimatch@11.0.4/node_modules/minimatch/dist/esm/index.js
2784
2953
  const minimatch = (p, pattern, options = {}) => {
2785
2954
  assertValidPattern(pattern);
2786
2955
  if (!options.nocomment && pattern.charAt(0) === "#") return false;
2787
- return new Minimatch(pattern, options).match(p);
2788
- };
2789
- const starDotExtRE = /^\*+([^+@!?\*\[\(]*)$/;
2790
- const starDotExtTest = (ext) => (f) => !f.startsWith(".") && f.endsWith(ext);
2791
- const starDotExtTestDot = (ext) => (f) => f.endsWith(ext);
2792
- const starDotExtTestNocase = (ext) => {
2793
- ext = ext.toLowerCase();
2794
- return (f) => !f.startsWith(".") && f.toLowerCase().endsWith(ext);
2795
- };
2796
- const starDotExtTestNocaseDot = (ext) => {
2797
- ext = ext.toLowerCase();
2798
- return (f) => f.toLowerCase().endsWith(ext);
2799
- };
2800
- const starDotStarRE = /^\*+\.\*+$/;
2801
- const starDotStarTest = (f) => !f.startsWith(".") && f.includes(".");
2802
- const starDotStarTestDot = (f) => f !== "." && f !== ".." && f.includes(".");
2803
- const dotStarRE = /^\.\*+$/;
2804
- const dotStarTest = (f) => f !== "." && f !== ".." && f.startsWith(".");
2805
- const starRE = /^\*+$/;
2806
- const starTest = (f) => f.length !== 0 && !f.startsWith(".");
2807
- const starTestDot = (f) => f.length !== 0 && f !== "." && f !== "..";
2808
- const qmarksRE = /^\?+([^+@!?\*\[\(]*)?$/;
2809
- const qmarksTestNocase = ([$0, ext = ""]) => {
2810
- const noext = qmarksTestNoExt([$0]);
2811
- if (!ext) return noext;
2812
- ext = ext.toLowerCase();
2813
- return (f) => noext(f) && f.toLowerCase().endsWith(ext);
2814
- };
2815
- const qmarksTestNocaseDot = ([$0, ext = ""]) => {
2816
- const noext = qmarksTestNoExtDot([$0]);
2817
- if (!ext) return noext;
2818
- ext = ext.toLowerCase();
2819
- return (f) => noext(f) && f.toLowerCase().endsWith(ext);
2820
- };
2821
- const qmarksTestDot = ([$0, ext = ""]) => {
2822
- const noext = qmarksTestNoExtDot([$0]);
2823
- return !ext ? noext : (f) => noext(f) && f.endsWith(ext);
2824
- };
2825
- const qmarksTest = ([$0, ext = ""]) => {
2826
- const noext = qmarksTestNoExt([$0]);
2827
- return !ext ? noext : (f) => noext(f) && f.endsWith(ext);
2956
+ return cachedMinimatch(pattern, options).match(p);
2828
2957
  };
2829
- const qmarksTestNoExt = ([$0]) => {
2830
- const len = $0.length;
2831
- return (f) => f.length === len && !f.startsWith(".");
2832
- };
2833
- const qmarksTestNoExtDot = ([$0]) => {
2834
- const len = $0.length;
2835
- return (f) => f.length === len && f !== "." && f !== "..";
2958
+ const cache = /* @__PURE__ */ new Map();
2959
+ const cacheMax = 256;
2960
+ const cachedMinimatch = (pattern, options) => {
2961
+ const key = pattern + "\0" + JSON.stringify(options);
2962
+ let mm = cache.get(key);
2963
+ if (mm) cache.delete(key);
2964
+ else {
2965
+ mm = new Minimatch(pattern, { ...options });
2966
+ if (cache.size >= cacheMax) cache.delete(cache.keys().next().value);
2967
+ }
2968
+ cache.set(key, mm);
2969
+ return mm;
2836
2970
  };
2837
2971
  /* c8 ignore start */
2838
- const defaultPlatform = typeof process === "object" && process ? typeof process.env === "object" && process.env && process.env.__MINIMATCH_TESTING_PLATFORM__ || process.platform : "posix";
2972
+ const defaultPlatform = typeof process === "object" && process ? process.env?.__MINIMATCH_TESTING_PLATFORM__ || process.platform : "posix";
2839
2973
  const path$1 = {
2840
2974
  win32: { sep: "\\" },
2841
2975
  posix: { sep: "/" }
@@ -2843,9 +2977,6 @@ const path$1 = {
2843
2977
  minimatch.sep = defaultPlatform === "win32" ? path$1.win32.sep : path$1.posix.sep;
2844
2978
  const GLOBSTAR = Symbol("globstar **");
2845
2979
  minimatch.GLOBSTAR = GLOBSTAR;
2846
- const star = "[^/]*?";
2847
- const twoStarDot = "(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?";
2848
- const twoStarNoDot = "(?:(?!(?:\\/|^)\\.).)*?";
2849
2980
  const filter = (pattern, options = {}) => (p) => minimatch(p, pattern, options);
2850
2981
  minimatch.filter = filter;
2851
2982
  const ext = (a, b = {}) => Object.assign({}, a, b);
@@ -2862,21 +2993,10 @@ const defaults = (def) => {
2862
2993
  return orig.defaults(ext(def, options)).Minimatch;
2863
2994
  }
2864
2995
  },
2865
- AST: class AST extends orig.AST {
2866
- /* c8 ignore start */
2867
- constructor(type, parent, options = {}) {
2868
- super(type, parent, ext(def, options));
2869
- }
2870
- /* c8 ignore stop */
2871
- static fromGlob(pattern, options = {}) {
2872
- return orig.AST.fromGlob(pattern, ext(def, options));
2873
- }
2874
- },
2875
2996
  unescape: (s, options = {}) => orig.unescape(s, ext(def, options)),
2876
2997
  escape: (s, options = {}) => orig.escape(s, ext(def, options)),
2877
2998
  filter: (pattern, options = {}) => orig.filter(pattern, ext(def, options)),
2878
2999
  defaults: (options) => orig.defaults(ext(def, options)),
2879
- makeRe: (pattern, options = {}) => orig.makeRe(pattern, ext(def, options)),
2880
3000
  braceExpand: (pattern, options = {}) => orig.braceExpand(pattern, ext(def, options)),
2881
3001
  match: (list, pattern, options = {}) => orig.match(list, pattern, ext(def, options)),
2882
3002
  sep: orig.sep,
@@ -2890,8 +3010,6 @@ const braceExpand = (pattern, options = {}) => {
2890
3010
  return expand(pattern, { max: options.braceExpandMax });
2891
3011
  };
2892
3012
  minimatch.braceExpand = braceExpand;
2893
- const makeRe = (pattern, options = {}) => new Minimatch(pattern, options).makeRe();
2894
- minimatch.makeRe = makeRe;
2895
3013
  const match = (list, pattern, options = {}) => {
2896
3014
  const mm = new Minimatch(pattern, options);
2897
3015
  list = list.filter((f) => mm.match(f));
@@ -2900,7 +3018,98 @@ const match = (list, pattern, options = {}) => {
2900
3018
  };
2901
3019
  minimatch.match = match;
2902
3020
  const globMagic = /[?*]|[+@!]\(.*?\)|\[|\]/;
2903
- const regExpEscape = (s) => s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
3021
+ const classEnd = (pattern, start) => {
3022
+ let i = start + 1;
3023
+ if (pattern.charAt(i) === "!" || pattern.charAt(i) === "^") i++;
3024
+ let sawStart = false;
3025
+ for (; i < pattern.length; i++) {
3026
+ const c = pattern.charAt(i);
3027
+ if (c === "]" && sawStart) return i;
3028
+ sawStart = true;
3029
+ if (c === "\\") i++;
3030
+ }
3031
+ return -1;
3032
+ };
3033
+ const literal = (pattern, noext) => {
3034
+ if (!noext && (pattern === "+()" || pattern === "@()")) return pattern;
3035
+ let lit = "";
3036
+ for (let i = 0; i < pattern.length; i++) {
3037
+ const c = pattern.charAt(i);
3038
+ if (c === "\\") lit += pattern.charAt(++i) || c;
3039
+ else if (c === "*" || c === "?") return;
3040
+ else if (c === "[") {
3041
+ const close = classEnd(pattern, i);
3042
+ if (close === -1) {
3043
+ lit += c;
3044
+ continue;
3045
+ }
3046
+ let body = pattern.slice(i + 1, close);
3047
+ if (body.startsWith("\\")) body = body.slice(1);
3048
+ if ([...body].length !== 1 || "!^".includes(pattern.charAt(i + 1))) return;
3049
+ lit += body;
3050
+ i = close;
3051
+ } else if (!noext && "+@!".includes(c) && pattern.charAt(i + 1) === "(" && pattern.includes(")", i + 2)) return;
3052
+ else lit += c;
3053
+ }
3054
+ return lit;
3055
+ };
3056
+ const extSafe = (pattern) => {
3057
+ if (/^[?*+@]\(\)$/.test(pattern) || pattern.includes("[:")) return false;
3058
+ let depth = 0;
3059
+ for (let i = 0; i < pattern.length; i++) {
3060
+ const c = pattern.charAt(i);
3061
+ if (c === "\\") {
3062
+ if (++i === pattern.length) return false;
3063
+ } else if (c === "[") {
3064
+ const close = classEnd(pattern, i);
3065
+ if (close !== -1) i = close;
3066
+ } else if ("+@!?*".includes(c) && pattern.charAt(i + 1) === "(") {
3067
+ depth++;
3068
+ i++;
3069
+ } else if (c === ")") {
3070
+ if (!depth--) return false;
3071
+ } else if (c === "|" && !depth) return false;
3072
+ }
3073
+ return !depth;
3074
+ };
3075
+ let lastSplit;
3076
+ let lastChecked;
3077
+ const portionMatch = (p, f) => typeof p === "string" ? f === p : f !== "" && p.testUnchecked(f);
3078
+ const endIndex = (p, last, lastStart, prev, prevStart) => portionMatch(p, last) ? lastStart : prev !== void 0 && portionMatch(p, prev) ? prevStart : -1;
3079
+ const isDots = (p) => p === "." || p === "..";
3080
+ const isDrive = (p) => typeof p === "string" && /^[a-z]:$/i.test(p);
3081
+ const isLongUNC = (p) => typeof p === "string" && /^unc$/i.test(p);
3082
+ const uncHost = (p) => {
3083
+ if (p[0] !== "" || p[1] !== "") return -1;
3084
+ const h = p[2] !== "?" ? 2 : isLongUNC(p[3]) ? 4 : -1;
3085
+ const host = p[h];
3086
+ const share = p[h + 1];
3087
+ return h !== -1 && host !== void 0 && host !== "" && host !== GLOBSTAR && share !== void 0 && share !== "" && share !== GLOBSTAR ? h : -1;
3088
+ };
3089
+ const walkable = (p, dot) => !isDots(p) && (dot || !p.startsWith("."));
3090
+ const dotPortion = (f, start, end, dot, sep) => {
3091
+ for (let k = start; k < end;) {
3092
+ if (f.charCodeAt(k) === 46) {
3093
+ if (!dot) return true;
3094
+ const n = f.charCodeAt(k + 1) === 46 ? k + 2 : k + 1;
3095
+ if (n >= end || isSep(f.charCodeAt(n), sep)) return true;
3096
+ }
3097
+ const s = nextSep(f, k, sep);
3098
+ if (s === -1) return false;
3099
+ k = s + 1;
3100
+ while (k < end && isSep(f.charCodeAt(k), sep)) k++;
3101
+ }
3102
+ return false;
3103
+ };
3104
+ const isSep = (c, sep) => sep === "/" ? c === 47 : sep === "\\" ? c === 92 : c === 47 || c === 92;
3105
+ const nextSep = (f, from, sep) => {
3106
+ if (sep !== "both") return f.indexOf(sep, from);
3107
+ const s = f.indexOf("/", from);
3108
+ const b = f.indexOf("\\", from);
3109
+ return s === -1 ? b : b === -1 ? s : Math.min(s, b);
3110
+ };
3111
+ const lastSep = (f, from, sep) => sep !== "both" ? f.lastIndexOf(sep, from) : Math.max(f.lastIndexOf("/", from), f.lastIndexOf("\\", from));
3112
+ const PENDING = {};
2904
3113
  var Minimatch = class {
2905
3114
  options;
2906
3115
  set;
@@ -2919,7 +3128,16 @@ var Minimatch = class {
2919
3128
  platform;
2920
3129
  windowsNoMagicRoot;
2921
3130
  maxGlobstarRecursion;
2922
- regexp;
3131
+ #endCheck;
3132
+ #literalCheck;
3133
+ #level2;
3134
+ #form;
3135
+ #literals = [];
3136
+ #shapes = [];
3137
+ #endRows = [];
3138
+ #matchers = /* @__PURE__ */ new Map();
3139
+ #pending = false;
3140
+ #globstarParts = /* @__PURE__ */ new WeakMap();
2923
3141
  constructor(pattern, options = {}) {
2924
3142
  assertValidPattern(pattern);
2925
3143
  options = options || {};
@@ -2932,7 +3150,6 @@ var Minimatch = class {
2932
3150
  this.windowsPathsNoEscape = !!options.windowsPathsNoEscape || options[awe] === false;
2933
3151
  if (this.windowsPathsNoEscape) this.pattern = this.pattern.replace(/\\/g, "/");
2934
3152
  this.preserveMultipleSlashes = !!options.preserveMultipleSlashes;
2935
- this.regexp = null;
2936
3153
  this.negate = false;
2937
3154
  this.nonegate = !!options.nonegate;
2938
3155
  this.comment = false;
@@ -2943,14 +3160,45 @@ var Minimatch = class {
2943
3160
  this.globSet = [];
2944
3161
  this.globParts = [];
2945
3162
  this.set = [];
3163
+ this.#endCheck = !this.preserveMultipleSlashes;
3164
+ this.#level2 = (options.optimizationLevel ?? 1) >= 2;
3165
+ const n = options.normalize;
3166
+ this.#form = n === true ? "NFC" : n || void 0;
2946
3167
  this.make();
3168
+ const drives = this.set.map((row) => this.#rootIndex(row));
3169
+ this.#endRows = this.set.map((row, r) => this.#endCheck && row.length - 1 > drives[r]);
3170
+ this.#literals = this.set.map((row, r) => {
3171
+ const end = this.#endRows[r] ? row.length - 1 : row.length;
3172
+ const lits = row.slice(drives[r] + 1, end).filter((p) => typeof p === "string" && !!p);
3173
+ return [...new Set(lits)];
3174
+ });
3175
+ this.#literalCheck = this.#literals.some((l) => l.length);
3176
+ this.#shapes = this.set.map((row, r) => {
3177
+ const [p0, p1, p2] = row;
3178
+ if (this.#endRows[r] && row.length === 2) {
3179
+ if (p0 === GLOBSTAR && p1 !== GLOBSTAR) return "tail";
3180
+ }
3181
+ if (this.#endRows[r] && options.matchBase && row.length === 1 && p0 !== GLOBSTAR && p0 !== "") return "base";
3182
+ if (!this.#endCheck || drives[r] !== -1) return void 0;
3183
+ if (row.length === 3 && p0 === GLOBSTAR && p2 === GLOBSTAR && p1 !== GLOBSTAR && p1 !== "" && this.maxGlobstarRecursion > 0) return "mid";
3184
+ if (row.length === 2 && p1 === GLOBSTAR && p0 !== GLOBSTAR && p0 !== "") return "head";
3185
+ });
3186
+ }
3187
+ #norm(p) {
3188
+ return this.#form ? p.normalize(this.#form) : p;
3189
+ }
3190
+ #rootIndex(row) {
3191
+ if (!this.isWindows) return -1;
3192
+ if (isDrive(row[0])) return 0;
3193
+ if (row[0] === "" && row[1] === "" && row[2] === "?" && isDrive(row[3])) return 3;
3194
+ const h = uncHost(row);
3195
+ return h === -1 ? -1 : h + 1;
2947
3196
  }
2948
3197
  hasMagic() {
2949
3198
  if (this.options.magicalBraces && this.set.length > 1) return true;
2950
3199
  for (const pattern of this.set) for (const part of pattern) if (typeof part !== "string") return true;
2951
3200
  return false;
2952
3201
  }
2953
- debug(..._) {}
2954
3202
  make() {
2955
3203
  const pattern = this.pattern;
2956
3204
  const options = this.options;
@@ -2964,31 +3212,69 @@ var Minimatch = class {
2964
3212
  }
2965
3213
  this.parseNegate();
2966
3214
  this.globSet = [...new Set(this.braceExpand())];
2967
- if (options.debug) this.debug = (...args) => console.error(...args);
2968
- this.debug(this.pattern, this.globSet);
2969
- const rawGlobParts = this.globSet.map((s) => this.slashSplit(s));
3215
+ const rawGlobParts = this.globSet.map((s) => this.#slashSplit(s));
2970
3216
  this.globParts = this.preprocess(rawGlobParts);
2971
- this.debug(this.pattern, this.globParts);
3217
+ this.#pending = true;
2972
3218
  let set = this.globParts.map((s, _, __) => {
2973
3219
  if (this.isWindows && this.windowsNoMagicRoot) {
2974
- const isUNC = s[0] === "" && s[1] === "" && (s[2] === "?" || !globMagic.test(s[2])) && !globMagic.test(s[3]);
3220
+ const n = s[2] === "?" && isLongUNC(s[3]) ? 6 : 4;
3221
+ const isUNC = s[0] === "" && s[1] === "" && (s[2] === "?" || !globMagic.test(s[2])) && s.slice(3, n).every((p) => !globMagic.test(p));
2975
3222
  const isDrive = /^[a-z]:/i.test(s[0]);
2976
- if (isUNC) return [...s.slice(0, 4), ...s.slice(4).map((ss) => this.parse(ss))];
2977
- else if (isDrive) return [s[0], ...s.slice(1).map((ss) => this.parse(ss))];
3223
+ if (isUNC) return [...s.slice(0, n).map((p) => this.#norm(p)), ...s.slice(n).map((ss) => this.parse(ss))];
3224
+ else if (isDrive) return [this.#norm(s[0]), ...s.slice(1).map((ss) => this.parse(ss))];
2978
3225
  }
2979
3226
  return s.map((ss) => this.parse(ss));
2980
3227
  });
2981
- this.debug(this.pattern, set);
2982
3228
  this.set = set.filter((s) => s.indexOf(false) === -1);
2983
3229
  if (this.isWindows) for (let i = 0; i < this.set.length; i++) {
2984
3230
  const p = this.set[i];
2985
- if (p[0] === "" && p[1] === "" && this.globParts[i][2] === "?" && typeof p[3] === "string" && /^[a-z]:$/i.test(p[3])) p[2] = "?";
3231
+ if (p[0] === "" && p[1] === "" && this.globParts[i][2] === "?" && (isDrive(p[3]) || isLongUNC(this.globParts[i][3]))) {
3232
+ if (isLongUNC(this.globParts[i][3])) p[3] = "UNC";
3233
+ p[2] = "?";
3234
+ }
3235
+ }
3236
+ if (!options.noext) this.mergeRows();
3237
+ this.#pending = false;
3238
+ this.set.forEach((row, i) => {
3239
+ for (let k = 0; k < row.length; k++) if (row[k] === PENDING) row[k] = this.parse(this.globParts[i][k]);
3240
+ });
3241
+ }
3242
+ mergeRows() {
3243
+ let merged = true;
3244
+ while (merged) {
3245
+ merged = false;
3246
+ const len = Math.max(0, ...this.set.map((r) => r.length));
3247
+ for (let k = 0; k < len; k++) {
3248
+ const groups = /* @__PURE__ */ new Map();
3249
+ this.set.forEach((row, i) => {
3250
+ if (!(row[k] instanceof Matcher || row[k] === PENDING) || !extSafe(this.globParts[i][k])) return;
3251
+ const parts = [...this.globParts[i]];
3252
+ parts[k] = "";
3253
+ const key = `${row.length}/${parts.join("/")}`;
3254
+ const g = groups.get(key);
3255
+ if (g) g.push(i);
3256
+ else groups.set(key, [i]);
3257
+ });
3258
+ const drop = /* @__PURE__ */ new Set();
3259
+ for (const g of groups.values()) {
3260
+ if (g.length < 2) continue;
3261
+ const [first, ...rest] = g;
3262
+ const glob = `@(${g.map((i) => this.globParts[i][k]).join("|")})`;
3263
+ this.globParts[first][k] = glob;
3264
+ this.set[first][k] = this.parse(glob);
3265
+ for (const i of rest) drop.add(i);
3266
+ }
3267
+ if (drop.size) {
3268
+ merged = true;
3269
+ this.set = this.set.filter((_, i) => !drop.has(i));
3270
+ this.globParts = this.globParts.filter((_, i) => !drop.has(i));
3271
+ }
3272
+ }
2986
3273
  }
2987
- this.debug(this.pattern, this.set);
2988
3274
  }
2989
3275
  preprocess(globParts) {
2990
3276
  if (this.options.noglobstar) {
2991
- for (let i = 0; i < globParts.length; i++) for (let j = 0; j < globParts[i].length; j++) if (globParts[i][j] === "**") globParts[i][j] = "*";
3277
+ for (const partset of globParts) for (let j = 0; j < partset.length; j++) if (partset[j] === "**") partset[j] = "*";
2992
3278
  }
2993
3279
  const { optimizationLevel = 1 } = this.options;
2994
3280
  if (optimizationLevel >= 2) {
@@ -3011,11 +3297,12 @@ var Minimatch = class {
3011
3297
  }
3012
3298
  levelOneOptimize(globParts) {
3013
3299
  return globParts.map((parts) => {
3300
+ const root = this.#rootIndex(parts) + 1;
3014
3301
  parts = parts.reduce((set, part) => {
3015
3302
  const prev = set[set.length - 1];
3016
3303
  if (part === "**" && prev === "**") return set;
3017
3304
  if (part === "..") {
3018
- if (prev && prev !== ".." && prev !== "." && prev !== "**") {
3305
+ if (set.length > root && prev && prev !== ".." && prev !== "." && prev !== "**") {
3019
3306
  set.pop();
3020
3307
  return set;
3021
3308
  }
@@ -3026,8 +3313,120 @@ var Minimatch = class {
3026
3313
  return parts.length === 0 ? [""] : parts;
3027
3314
  });
3028
3315
  }
3029
- levelTwoFileOptimize(parts) {
3030
- if (!Array.isArray(parts)) parts = this.slashSplit(parts);
3316
+ #canMatch(f) {
3317
+ const sep = !this.isWindows || !f.includes("\\") ? "/" : f.includes("/") ? "both" : "\\";
3318
+ let ends = this.#endCheck ? 0 : -1;
3319
+ let last = "";
3320
+ let lastStart = 0;
3321
+ let prev;
3322
+ let prevStart = 0;
3323
+ const dot = !!this.options.dot;
3324
+ ROWS: for (let r = 0; r < this.set.length; r++) {
3325
+ const row = this.set[r];
3326
+ const p = row[row.length - 1];
3327
+ let end = ends !== -1 && this.#endRows[r] && p !== GLOBSTAR;
3328
+ if (end && ends === 0) {
3329
+ const i = lastSep(f, f.length, sep);
3330
+ lastStart = i + 1;
3331
+ last = f.slice(lastStart);
3332
+ if (last === "" && i >= 0) {
3333
+ let j = i;
3334
+ while (j > 0 && isSep(f.charCodeAt(j - 1), sep)) j--;
3335
+ prevStart = j === 0 ? 0 : lastSep(f, j - 1, sep) + 1;
3336
+ prev = f.slice(prevStart, j);
3337
+ }
3338
+ const resolves = this.#level2 && (isDots(last) || last === "" && prev !== void 0 && isDots(prev));
3339
+ ends = resolves ? -1 : 1;
3340
+ end = !resolves;
3341
+ }
3342
+ let tailStart = -1;
3343
+ if (end && typeof p === "string") {
3344
+ tailStart = endIndex(p, last, lastStart, prev, prevStart);
3345
+ if (tailStart === -1) continue;
3346
+ }
3347
+ if (this.#literalCheck) {
3348
+ for (const l of this.#literals[r]) if (!f.includes(l)) continue ROWS;
3349
+ }
3350
+ if (end && typeof p === "object") {
3351
+ tailStart = endIndex(p, last, lastStart, prev, prevStart);
3352
+ if (tailStart === -1) continue;
3353
+ }
3354
+ const shape = this.#shapes[r];
3355
+ if (shape === "base" && end) return "yes";
3356
+ if (shape === "tail" && end) {
3357
+ if (this.#level2 && dotPortion(f, 0, tailStart, true, sep)) return "maybe";
3358
+ if (!dotPortion(f, 0, tailStart, dot, sep)) return "yes";
3359
+ continue;
3360
+ }
3361
+ if (shape === "mid" || shape === "head") {
3362
+ const m = this.#walk(f, row, shape === "head", dot, sep);
3363
+ if (m !== "no") return m;
3364
+ continue;
3365
+ }
3366
+ return "maybe";
3367
+ }
3368
+ return "no";
3369
+ }
3370
+ #matchShape(file, row, shape) {
3371
+ const dot = !!this.options.dot;
3372
+ const n = file.length;
3373
+ if (shape === "head") {
3374
+ if (n < 2 || !portionMatch(row[0], file[0])) return false;
3375
+ for (let i = 1; i < n; i++) if (!walkable(file[i], dot)) return false;
3376
+ return true;
3377
+ }
3378
+ const x = row[1];
3379
+ if (shape === "tail") {
3380
+ let t = n - 1;
3381
+ if (!portionMatch(x, file[t])) {
3382
+ if (file[t] !== "" || n === 1 || !portionMatch(x, file[--t])) return false;
3383
+ }
3384
+ for (let i = 0; i < t; i++) if (!walkable(file[i], dot)) return false;
3385
+ return true;
3386
+ }
3387
+ for (let k = 0; k < n; k++) {
3388
+ if (portionMatch(x, file[k]) && k + 1 < n) {
3389
+ let i = k + 1;
3390
+ while (i < n && walkable(file[i], dot)) i++;
3391
+ if (i === n) return true;
3392
+ }
3393
+ if (!walkable(file[k], dot)) return false;
3394
+ }
3395
+ return false;
3396
+ }
3397
+ #walk(f, row, head, dot, sep) {
3398
+ if (this.#level2 && dotPortion(f, 0, f.length, true, sep)) return "maybe";
3399
+ const x = row[head ? 0 : 1];
3400
+ let s = 0;
3401
+ for (let e = nextSep(f, s, sep); e !== -1; e = nextSep(f, s, sep)) {
3402
+ let next = e + 1;
3403
+ while (next < f.length && isSep(f.charCodeAt(next), sep)) next++;
3404
+ 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";
3405
+ if (head || dotPortion(f, s, next, dot, sep)) return "no";
3406
+ s = next;
3407
+ }
3408
+ return "no";
3409
+ }
3410
+ #cachedSplit(f) {
3411
+ const last = lastSplit;
3412
+ return last?.f === f && last.isWindows === this.isWindows && last.preserveMultipleSlashes === this.preserveMultipleSlashes && last.normalize === this.#form ? last : void 0;
3413
+ }
3414
+ #split(f) {
3415
+ const { isWindows, preserveMultipleSlashes } = this;
3416
+ let parts = this.#slashSplit(isWindows ? f.split("\\").join("/") : f);
3417
+ const normalize = this.#form;
3418
+ if (normalize) parts = parts.map((p) => p.normalize(normalize));
3419
+ lastSplit = {
3420
+ f,
3421
+ isWindows,
3422
+ preserveMultipleSlashes,
3423
+ normalize,
3424
+ parts
3425
+ };
3426
+ return lastSplit;
3427
+ }
3428
+ #levelTwoFileOptimize(file) {
3429
+ const parts = [...file];
3031
3430
  let didSomething = false;
3032
3431
  do {
3033
3432
  didSomething = false;
@@ -3046,19 +3445,21 @@ var Minimatch = class {
3046
3445
  parts.pop();
3047
3446
  }
3048
3447
  }
3049
- let dd = 0;
3448
+ const root = this.#rootIndex(parts) + 1;
3449
+ let dd = root;
3050
3450
  while (-1 !== (dd = parts.indexOf("..", dd + 1))) {
3051
3451
  const p = parts[dd - 1];
3052
3452
  if (p && p !== "." && p !== ".." && p !== "**") {
3053
3453
  didSomething = true;
3054
3454
  parts.splice(dd - 1, 2);
3055
- dd -= 2;
3455
+ dd = Math.max(dd - 2, root);
3056
3456
  }
3057
3457
  }
3058
3458
  } while (didSomething);
3059
3459
  return parts.length === 0 ? [""] : parts;
3060
3460
  }
3061
3461
  firstPhasePreProcess(globParts) {
3462
+ const { braceExpandMax = 1e5 } = this.options;
3062
3463
  let didSomething = false;
3063
3464
  do {
3064
3465
  didSomething = false;
@@ -3072,7 +3473,7 @@ var Minimatch = class {
3072
3473
  const p = parts[gs + 2];
3073
3474
  const p2 = parts[gs + 3];
3074
3475
  if (next !== "..") continue;
3075
- if (!p || p === "." || p === ".." || !p2 || p2 === "." || p2 === "..") continue;
3476
+ if (!p || p === "." || p === ".." || !p2 || p2 === "." || p2 === ".." || globParts.length >= braceExpandMax) continue;
3076
3477
  didSomething = true;
3077
3478
  parts.splice(gs, 1);
3078
3479
  const other = parts.slice(0);
@@ -3095,7 +3496,8 @@ var Minimatch = class {
3095
3496
  parts.pop();
3096
3497
  }
3097
3498
  }
3098
- let dd = 0;
3499
+ const root = this.#rootIndex(parts) + 1;
3500
+ let dd = root;
3099
3501
  while (-1 !== (dd = parts.indexOf("..", dd + 1))) {
3100
3502
  const p = parts[dd - 1];
3101
3503
  if (p && p !== "." && p !== ".." && p !== "**") {
@@ -3103,7 +3505,7 @@ var Minimatch = class {
3103
3505
  const splin = dd === 1 && parts[dd + 1] === "**" ? ["."] : [];
3104
3506
  parts.splice(dd - 1, 2, ...splin);
3105
3507
  if (parts.length === 0) parts.push("");
3106
- dd -= 2;
3508
+ dd = Math.max(dd - 2, root);
3107
3509
  }
3108
3510
  }
3109
3511
  }
@@ -3111,6 +3513,7 @@ var Minimatch = class {
3111
3513
  return globParts;
3112
3514
  }
3113
3515
  secondPhasePreProcess(globParts) {
3516
+ if (globParts.length > 1e3) return globParts;
3114
3517
  for (let i = 0; i < globParts.length - 1; i++) for (let j = i + 1; j < globParts.length; j++) {
3115
3518
  const matched = this.partsMatch(globParts[i], globParts[j], !this.preserveMultipleSlashes);
3116
3519
  if (matched) {
@@ -3163,10 +3566,22 @@ var Minimatch = class {
3163
3566
  if (negateOffset) this.pattern = pattern.slice(negateOffset);
3164
3567
  this.negate = negate;
3165
3568
  }
3166
- matchOne(file, pattern, partial = false) {
3569
+ #matchRow(file, resolved, pattern, partial) {
3167
3570
  let fileStartIndex = 0;
3168
3571
  let patternStartIndex = 0;
3169
- if (this.isWindows) {
3572
+ const fh = this.isWindows ? uncHost(resolved) : -1;
3573
+ const ph = fh === -1 ? -1 : uncHost(pattern);
3574
+ if (ph !== -1) {
3575
+ const host = pattern[ph];
3576
+ const share = pattern[ph + 1];
3577
+ if (typeof host !== "string" || typeof share !== "string") {
3578
+ fileStartIndex = fh;
3579
+ patternStartIndex = ph;
3580
+ } else if (resolved[fh].toLowerCase() === host.toLowerCase() && resolved[fh + 1].toLowerCase() === share.toLowerCase()) {
3581
+ fileStartIndex = fh + 2;
3582
+ patternStartIndex = ph + 2;
3583
+ }
3584
+ } else if (this.isWindows) {
3170
3585
  const fileDrive = typeof file[0] === "string" && /^[a-z]:$/i.test(file[0]);
3171
3586
  const fileUNC = !fileDrive && file[0] === "" && file[1] === "" && file[2] === "?" && /^[a-z]:$/i.test(file[3]);
3172
3587
  const patternDrive = typeof pattern[0] === "string" && /^[a-z]:$/i.test(pattern[0]);
@@ -3176,32 +3591,20 @@ var Minimatch = class {
3176
3591
  if (typeof fdi === "number" && typeof pdi === "number") {
3177
3592
  const [fd, pd] = [file[fdi], pattern[pdi]];
3178
3593
  if (fd.toLowerCase() === pd.toLowerCase()) {
3179
- pattern[pdi] = fd;
3180
- patternStartIndex = pdi;
3181
- fileStartIndex = fdi;
3594
+ patternStartIndex = pdi + 1;
3595
+ fileStartIndex = fdi + 1;
3182
3596
  }
3183
3597
  }
3184
3598
  }
3185
- const { optimizationLevel = 1 } = this.options;
3186
- if (optimizationLevel >= 2) file = this.levelTwoFileOptimize(file);
3599
+ file = resolved;
3187
3600
  if (pattern.includes(GLOBSTAR)) return this.#matchGlobstar(file, pattern, partial, fileStartIndex, patternStartIndex);
3188
3601
  return this.#matchOne(file, pattern, partial, fileStartIndex, patternStartIndex);
3189
3602
  }
3190
3603
  #matchGlobstar(file, pattern, partial, fileIndex, patternIndex) {
3191
- const firstgs = pattern.indexOf(GLOBSTAR, patternIndex);
3192
- const lastgs = pattern.lastIndexOf(GLOBSTAR);
3193
- const [head, body, tail] = partial ? [
3194
- pattern.slice(patternIndex, firstgs),
3195
- pattern.slice(firstgs + 1),
3196
- []
3197
- ] : [
3198
- pattern.slice(patternIndex, firstgs),
3199
- pattern.slice(firstgs + 1, lastgs),
3200
- pattern.slice(lastgs + 1)
3201
- ];
3604
+ const { head, body, tail, segments } = this.#getGlobstarParts(pattern, partial, patternIndex);
3202
3605
  if (head.length) {
3203
- const fileHead = file.slice(fileIndex, fileIndex + head.length);
3204
- if (!this.#matchOne(fileHead, head, partial, 0, 0)) return false;
3606
+ const headEnd = fileIndex + head.length;
3607
+ if (!this.#matchOne(file, head, partial, fileIndex, 0, headEnd)) return false;
3205
3608
  fileIndex += head.length;
3206
3609
  patternIndex += head.length;
3207
3610
  }
@@ -3226,67 +3629,86 @@ var Minimatch = class {
3226
3629
  }
3227
3630
  return partial || sawSome;
3228
3631
  }
3229
- const bodySegments = [[[], 0]];
3230
- let currentBody = bodySegments[0];
3632
+ return !!this.#matchGlobStarBodySections(file, segments, file.length - fileTailMatch, fileIndex, 0, partial, 0, !!fileTailMatch, /* @__PURE__ */ new Set());
3633
+ }
3634
+ #getGlobstarParts(pattern, partial, patternIndex) {
3635
+ let byStart = this.#globstarParts.get(pattern);
3636
+ if (!byStart) {
3637
+ byStart = [];
3638
+ this.#globstarParts.set(pattern, byStart);
3639
+ }
3640
+ const key = patternIndex * 2 + (partial ? 1 : 0);
3641
+ const found = byStart[key];
3642
+ if (found) return found;
3643
+ const firstgs = pattern.indexOf(GLOBSTAR, patternIndex);
3644
+ const lastgs = pattern.lastIndexOf(GLOBSTAR);
3645
+ const head = pattern.slice(patternIndex, firstgs);
3646
+ const body = pattern.slice(firstgs + 1, partial ? void 0 : lastgs);
3647
+ const tail = partial ? [] : pattern.slice(lastgs + 1);
3648
+ const segments = [[[], 0]];
3649
+ let current = segments[0];
3231
3650
  let nonGsParts = 0;
3232
3651
  const nonGsPartsSums = [0];
3233
3652
  for (const b of body) if (b === GLOBSTAR) {
3234
3653
  nonGsPartsSums.push(nonGsParts);
3235
- currentBody = [[], 0];
3236
- bodySegments.push(currentBody);
3654
+ current = [[], 0];
3655
+ segments.push(current);
3237
3656
  } else {
3238
- currentBody[0].push(b);
3657
+ current[0].push(b);
3239
3658
  nonGsParts++;
3240
3659
  }
3241
- let i = bodySegments.length - 1;
3242
- const fileLength = file.length - fileTailMatch;
3243
- for (const b of bodySegments) b[1] = fileLength - (nonGsPartsSums[i--] + b[0].length);
3244
- return !!this.#matchGlobStarBodySections(file, bodySegments, fileIndex, 0, partial, 0, !!fileTailMatch);
3660
+ segments.forEach((b, i) => {
3661
+ b[1] = nonGsParts - nonGsPartsSums[i];
3662
+ });
3663
+ const parts = {
3664
+ head,
3665
+ body,
3666
+ tail,
3667
+ segments
3668
+ };
3669
+ byStart[key] = parts;
3670
+ return parts;
3245
3671
  }
3246
- #matchGlobStarBodySections(file, bodySegments, fileIndex, bodyIndex, partial, globStarDepth, sawTail) {
3672
+ #matchGlobStarBodySections(file, bodySegments, fileLength, fileIndex, bodyIndex, partial, globStarDepth, sawTail, tried) {
3247
3673
  const bs = bodySegments[bodyIndex];
3248
3674
  if (!bs) {
3249
- for (let i = fileIndex; i < file.length; i++) {
3675
+ if (partial) return fileIndex >= fileLength || fileIndex === fileLength - 1 && file[fileIndex] === "";
3676
+ for (let i = fileIndex; i < fileLength; i++) {
3250
3677
  sawTail = true;
3251
3678
  const f = file[i];
3252
3679
  if (f === "." || f === ".." || !this.options.dot && f.startsWith(".")) return false;
3253
3680
  }
3254
3681
  return sawTail;
3255
3682
  }
3256
- const [body, after] = bs;
3683
+ const [body, need] = bs;
3684
+ const after = partial ? fileLength : fileLength - need;
3257
3685
  while (fileIndex <= after) {
3258
- if (this.#matchOne(file.slice(0, fileIndex + body.length), body, partial, fileIndex, 0) && globStarDepth < this.maxGlobstarRecursion) {
3259
- const sub = this.#matchGlobStarBodySections(file, bodySegments, fileIndex + body.length, bodyIndex + 1, partial, globStarDepth + 1, sawTail);
3686
+ const key = bodyIndex * (file.length + 1) + fileIndex;
3687
+ if (tried.has(key)) return false;
3688
+ tried.add(key);
3689
+ if (this.#matchOne(file, body, partial, fileIndex, 0, fileIndex + body.length) && globStarDepth < this.maxGlobstarRecursion) {
3690
+ const sub = this.#matchGlobStarBodySections(file, bodySegments, fileLength, fileIndex + body.length, bodyIndex + 1, partial, globStarDepth + 1, sawTail, tried);
3260
3691
  if (sub !== false) return sub;
3261
3692
  }
3693
+ if (fileIndex === after) break;
3262
3694
  const f = file[fileIndex];
3263
3695
  if (f === "." || f === ".." || !this.options.dot && f.startsWith(".")) return false;
3264
3696
  fileIndex++;
3265
3697
  }
3266
3698
  return partial || null;
3267
3699
  }
3268
- #matchOne(file, pattern, partial, fileIndex, patternIndex) {
3700
+ #matchOne(file, pattern, partial, fileIndex, patternIndex, fileEnd = file.length) {
3269
3701
  let fi;
3270
3702
  let pi;
3271
3703
  let pl;
3272
3704
  let fl;
3273
- for (fi = fileIndex, pi = patternIndex, fl = file.length, pl = pattern.length; fi < fl && pi < pl; fi++, pi++) {
3274
- this.debug("matchOne loop");
3705
+ for (fi = fileIndex, pi = patternIndex, fl = Math.min(fileEnd, file.length), pl = pattern.length; fi < fl && pi < pl; fi++, pi++) {
3275
3706
  let p = pattern[pi];
3276
3707
  let f = file[fi];
3277
- this.debug(pattern, p, f);
3278
3708
  /* c8 ignore start */
3279
3709
  if (p === false || p === GLOBSTAR) return false;
3280
3710
  /* c8 ignore stop */
3281
- let hit;
3282
- if (typeof p === "string") {
3283
- hit = f === p;
3284
- this.debug("string match", p, f, hit);
3285
- } else {
3286
- hit = p.test(f);
3287
- this.debug("pattern match", p, f, hit);
3288
- }
3289
- if (!hit) return false;
3711
+ if (!portionMatch(p, f)) return false;
3290
3712
  }
3291
3713
  if (fi === fl && pi === pl) return true;
3292
3714
  else if (fi === fl) return partial;
@@ -3302,88 +3724,51 @@ var Minimatch = class {
3302
3724
  const options = this.options;
3303
3725
  if (pattern === "**") return GLOBSTAR;
3304
3726
  if (pattern === "") return "";
3305
- let m;
3306
- let fastTest = null;
3307
- if (m = pattern.match(starRE)) fastTest = options.dot ? starTestDot : starTest;
3308
- else if (m = pattern.match(starDotExtRE)) fastTest = (options.nocase ? options.dot ? starDotExtTestNocaseDot : starDotExtTestNocase : options.dot ? starDotExtTestDot : starDotExtTest)(m[1]);
3309
- else if (m = pattern.match(qmarksRE)) fastTest = (options.nocase ? options.dot ? qmarksTestNocaseDot : qmarksTestNocase : options.dot ? qmarksTestDot : qmarksTest)(m);
3310
- else if (m = pattern.match(starDotStarRE)) fastTest = options.dot ? starDotStarTestDot : starDotStarTest;
3311
- else if (m = pattern.match(dotStarRE)) fastTest = dotStarTest;
3312
- const re = AST.fromGlob(pattern, this.options).toMMPattern();
3313
- if (fastTest && typeof re === "object") Reflect.defineProperty(re, "test", { value: fastTest });
3314
- return re;
3315
- }
3316
- makeRe() {
3317
- if (this.regexp || this.regexp === false) return this.regexp;
3318
- const set = this.set;
3319
- if (!set.length) {
3320
- this.regexp = false;
3321
- return this.regexp;
3322
- }
3323
- const options = this.options;
3324
- const twoStar = options.noglobstar ? star : options.dot ? twoStarDot : twoStarNoDot;
3325
- const flags = new Set(options.nocase ? ["i"] : []);
3326
- let re = set.map((pattern) => {
3327
- const pp = pattern.map((p) => {
3328
- if (p instanceof RegExp) for (const f of p.flags.split("")) flags.add(f);
3329
- return typeof p === "string" ? regExpEscape(p) : p === GLOBSTAR ? GLOBSTAR : p._src;
3330
- });
3331
- pp.forEach((p, i) => {
3332
- const next = pp[i + 1];
3333
- const prev = pp[i - 1];
3334
- if (p !== GLOBSTAR || prev === GLOBSTAR) return;
3335
- if (prev === void 0) {
3336
- if (next !== void 0 && next !== GLOBSTAR) pp[i + 1] = "(?:\\/|" + twoStar + "\\/)?" + next;
3337
- else pp[i] = twoStar;
3338
- } else if (next === void 0) pp[i - 1] = prev + "(?:\\/|\\/" + twoStar + ")?";
3339
- else if (next !== GLOBSTAR) {
3340
- pp[i - 1] = prev + "(?:\\/|\\/" + twoStar + "\\/)" + next;
3341
- pp[i + 1] = GLOBSTAR;
3342
- }
3727
+ const { nocase, nocaseMagicOnly, noext = false, dot, normalize } = options;
3728
+ const lit = literal(pattern, noext);
3729
+ if (lit !== void 0 && !(nocase && !nocaseMagicOnly && pattern.toUpperCase() !== pattern.toLowerCase())) return this.#norm(lit);
3730
+ if (this.#pending) return PENDING;
3731
+ let m = this.#matchers.get(pattern);
3732
+ if (!m) {
3733
+ m = new Matcher(pattern, {
3734
+ nocase,
3735
+ noext,
3736
+ dot,
3737
+ normalize
3343
3738
  });
3344
- const filtered = pp.filter((p) => p !== GLOBSTAR);
3345
- if (this.partial && filtered.length >= 1) {
3346
- const prefixes = [];
3347
- for (let i = 1; i <= filtered.length; i++) prefixes.push(filtered.slice(0, i).join("/"));
3348
- return "(?:" + prefixes.join("|") + ")";
3349
- }
3350
- return filtered.join("/");
3351
- }).join("|");
3352
- const [open, close] = set.length > 1 ? ["(?:", ")"] : ["", ""];
3353
- re = "^" + open + re + close + "$";
3354
- if (this.partial) re = "^(?:\\/|" + open + re.slice(1, -1) + close + ")$";
3355
- if (this.negate) re = "^(?!" + re + ").+$";
3356
- try {
3357
- this.regexp = new RegExp(re, [...flags].join(""));
3358
- } catch (ex) {
3359
- this.regexp = false;
3739
+ this.#matchers.set(pattern, m);
3360
3740
  }
3361
- /* c8 ignore stop */
3362
- return this.regexp;
3741
+ return m;
3363
3742
  }
3364
- slashSplit(p) {
3743
+ #slashSplit(p) {
3365
3744
  if (this.preserveMultipleSlashes) return p.split("/");
3366
- else if (this.isWindows && /^\/\/[^\/]+/.test(p)) return ["", ...p.split(/\/+/)];
3745
+ else if (this.isWindows && /^\/\/[^/]+/.test(p)) return ["", ...p.split(/\/+/)];
3367
3746
  else return p.split(/\/+/);
3368
3747
  }
3369
3748
  match(f, partial = this.partial) {
3370
- this.debug("match", f, this.pattern);
3371
3749
  if (this.comment) return false;
3372
3750
  if (this.empty) return f === "";
3373
3751
  if (f === "/" && partial) return true;
3374
3752
  const options = this.options;
3375
- if (this.isWindows) f = f.split("\\").join("/");
3376
- const ff = this.slashSplit(f);
3377
- this.debug(this.pattern, "split", ff);
3753
+ let split = this.#cachedSplit(f);
3754
+ if (!split) {
3755
+ if (!partial && !this.#form && (this.#endCheck || this.#literalCheck) && lastChecked !== f) {
3756
+ lastChecked = f;
3757
+ const can = this.#canMatch(f);
3758
+ if (can === "no") return options.flipNegate ? false : this.negate;
3759
+ if (can === "yes") return options.flipNegate ? true : !this.negate;
3760
+ }
3761
+ split = this.#split(f);
3762
+ }
3763
+ const ff = split.parts;
3764
+ const resolved = this.#level2 ? split.resolved ??= this.#levelTwoFileOptimize(ff) : ff;
3378
3765
  const set = this.set;
3379
- this.debug(this.pattern, "set", set);
3380
3766
  let filename = ff[ff.length - 1];
3381
3767
  if (!filename) for (let i = ff.length - 2; !filename && i >= 0; i--) filename = ff[i];
3382
- for (let i = 0; i < set.length; i++) {
3383
- const pattern = set[i];
3384
- let file = ff;
3385
- if (options.matchBase && pattern.length === 1) file = [filename];
3386
- if (this.matchOne(file, pattern, partial)) {
3768
+ for (let r = 0; r < set.length; r++) {
3769
+ const pattern = set[r];
3770
+ const shape = partial ? void 0 : this.#shapes[r];
3771
+ 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)) {
3387
3772
  if (options.flipNegate) return true;
3388
3773
  return !this.negate;
3389
3774
  }
@@ -3396,7 +3781,6 @@ var Minimatch = class {
3396
3781
  }
3397
3782
  };
3398
3783
  /* c8 ignore stop */
3399
- minimatch.AST = AST;
3400
3784
  minimatch.Minimatch = Minimatch;
3401
3785
  minimatch.escape = escape;
3402
3786
  minimatch.unescape = unescape;
@@ -5128,7 +5512,7 @@ function sourceTreeMatches(projectPath, matchesContent, options = {}) {
5128
5512
  if (entry.isDirectory()) {
5129
5513
  if (skipDirs.has(entry.name)) continue;
5130
5514
  if (scanDir(entryPath, false)) return true;
5131
- } else if (entry.isFile() && ![".pnp.cjs", ".pnp.loader.mjs"].includes(entry.name) && (extensions.has(path.extname(entry.name)) || options.includeExtensionless && path.extname(entry.name) === "" || options.includePackageReferences && entry.name === "package.json")) try {
5515
+ } else if (entry.isFile() && ![".pnp.cjs", ".pnp.loader.mjs"].includes(entry.name) && (extensions.has(path.extname(entry.name)) || options.fileNamePattern?.test(entry.name) || options.includeExtensionless && path.extname(entry.name) === "" || options.includePackageReferences && entry.name === "package.json")) try {
5132
5516
  let content = fs.readFileSync(entryPath, "utf8");
5133
5517
  if (entry.name === "package.json") {
5134
5518
  const pkg = JSON.parse(content);
@@ -5278,7 +5662,7 @@ function isSemanticVitePlusOverrideSpec(dependencyName, spec) {
5278
5662
  if (!spec) return false;
5279
5663
  if (isLegacyWrapperSpec(spec)) return false;
5280
5664
  if (spec === VITE_PLUS_OVERRIDE_PACKAGES[dependencyName]) return true;
5281
- if (dependencyName === "@vitest/browser" && spec === "5.0.5") return true;
5665
+ if (dependencyName === "@vitest/browser" && spec === "5.1.0") return true;
5282
5666
  return false;
5283
5667
  }
5284
5668
  function overrideSpecSatisfiesVitePlus(dependencyName, spec, catalogDependencyResolver) {
@@ -7014,7 +7398,7 @@ function migrateNodeVersionManagerFile(projectPath, detection, report) {
7014
7398
  const nodeVersionPath = path.join(projectPath, ".node-version");
7015
7399
  const { voltaNodeVersion } = detection;
7016
7400
  const resolvedVersion = voltaNodeVersion === "lts" ? "lts/*" : voltaNodeVersion;
7017
- if (!normalize$2(resolvedVersion) && resolvedVersion !== "lts/*") {
7401
+ if (!normalize$3(resolvedVersion) && resolvedVersion !== "lts/*") {
7018
7402
  warnMigration(`package.json volta.node "${voltaNodeVersion}" is not an exact version. Pin an exact version (e.g. ${voltaNodeVersion}.0 or run \`volta pin node@${voltaNodeVersion}\`) then re-run migration.`, report);
7019
7403
  return false;
7020
7404
  }
@@ -7318,9 +7702,7 @@ const ZED_SETTINGS = {
7318
7702
  lsp: {
7319
7703
  oxlint: { initialization_options: { settings: {
7320
7704
  run: "onType",
7321
- fixKind: "safe_fix",
7322
- typeAware: true,
7323
- unusedDisableDirectives: "deny"
7705
+ fixKind: "safe_fix"
7324
7706
  } } },
7325
7707
  oxfmt: { initialization_options: { settings: {
7326
7708
  "fmt.configPath": "./vite.config.ts",
@@ -7654,4 +8036,4 @@ function resolveEditorIds(editors) {
7654
8036
  const uniqueEditorIds = [...new Set(editorIds)];
7655
8037
  return uniqueEditorIds.length === 0 ? void 0 : uniqueEditorIds;
7656
8038
  }
7657
- export { promptTsupMigration as $, detectVitePlusBootstrapPending as A, isBingoTemplate as B, removeMigratedOxlintConfigs as C, warnMigration as Ct, mergeViteConfigFiles as D, mergeTsdownConfigFile as E, detectYarnPnpMode as F, initGitRepository as G, updateWorkspaceConfig as H, createCatalogDependencyResolver as I, detectFramework as J, extractOverrideParentSegments as K, supportsCatalog as L, sourceTreeMatches as M, usesWebdriverioProvider as N, retryPreservedOxlintConfigs as O, configureYarnNodeModulesMode as P, migrateTsupToTsdown as Q, detectWorkspace$1 as R, prepareOxlintConfigs as S, readPackageJsonIfExists as St, injectLintTypeCheckDefaults as T, minimatch as U, updatePackageJsonWithDeps as V, findGitRoot as W, confirmTsupMigration as X, hasFrameworkShim as Y, detectTsupProject as Z, hasExistingViteHooksPolicy as _, WEBDRIVERIO_PROVIDER as _t, selectEditors as a, warnPackageLevelPrettier as at, preflightGitHooksSetup as b, getCommandStartIndex as bt, rewriteMonorepoProject as c, detectIncompatibleEslintIntegration as ct, finalizeCoreMigrationForExistingVitePlus as d, warnIncompatibleEslintIntegration as dt, warnMissingTsupConfig as et, detectNodeVersionManagerFile as f, warnLegacyEslintConfig as ft, detectLegacyGitHooksMigrationCandidate as g, SHELL_STATE_COMMANDS as gt, setPackageManager as h, RETENTION_SCAN_SKIP_DIRS as ht, selectEditor as i, promptPrettierMigration as it, ensureVitePlusBootstrap as j, collectToolchainVersionChanges as k, rewriteStandaloneProject as l, migrateEslintToOxlint as lt, migrateSetupVpVersion as m, LINT_STAGED_JSON_CONFIG_FILES as mt, detectExistingEditors as n, detectPrettierProject as nt, writeEditorConfigs as o, confirmEslintMigration as ot, migrateNodeVersionManagerFile as p, warnPackageLevelEslint as pt, addFrameworkShim as q, isJsonLikeFile as r, migratePrettierToOxfmt as rt, rewriteMonorepo as s, detectEslintProject as st, detectEditorConflicts as t, confirmPrettierMigration as tt, detectPendingCoreMigration as u, promptEslintMigration as ut, installGitHooks as v, checkViteVersion as vt, injectCreateDefaultTemplate as w, shouldSkipStagedMigrationForHooks as x, isPlainRecord as xt, isViteHooksSetupComplete as y, checkVitestVersion as yt, discoverWorkspacePackages as z };
8039
+ export { promptTsupMigration as $, detectVitePlusBootstrapPending as A, isBingoTemplate as B, removeMigratedOxlintConfigs as C, readPackageJsonIfExists as Ct, mergeViteConfigFiles as D, mergeTsdownConfigFile as E, detectYarnPnpMode as F, initGitRepository as G, updateWorkspaceConfig as H, createCatalogDependencyResolver as I, detectFramework as J, extractOverrideParentSegments as K, supportsCatalog as L, sourceTreeMatches as M, usesWebdriverioProvider as N, retryPreservedOxlintConfigs as O, configureYarnNodeModulesMode as P, migrateTsupToTsdown as Q, detectWorkspace$1 as R, prepareOxlintConfigs as S, isPlainRecord as St, injectLintTypeCheckDefaults as T, minimatch as U, updatePackageJsonWithDeps as V, findGitRoot as W, confirmTsupMigration as X, hasFrameworkShim as Y, detectTsupProject as Z, hasExistingViteHooksPolicy as _, SHELL_STATE_COMMANDS as _t, selectEditors as a, warnPackageLevelPrettier as at, preflightGitHooksSetup as b, checkVitestVersion as bt, rewriteMonorepoProject as c, detectIncompatibleEslintIntegration as ct, finalizeCoreMigrationForExistingVitePlus as d, warnIncompatibleEslintIntegration as dt, warnMissingTsupConfig as et, detectNodeVersionManagerFile as f, warnLegacyEslintConfig as ft, detectLegacyGitHooksMigrationCandidate as g, RETENTION_SCAN_SKIP_DIRS as gt, setPackageManager as h, LINT_STAGED_JSON_CONFIG_FILES as ht, selectEditor as i, promptPrettierMigration as it, ensureVitePlusBootstrap as j, collectToolchainVersionChanges as k, rewriteStandaloneProject as l, migrateEslintToOxlint as lt, migrateSetupVpVersion as m, detectMigrationWarnings as mt, detectExistingEditors as n, detectPrettierProject as nt, writeEditorConfigs as o, confirmEslintMigration as ot, migrateNodeVersionManagerFile as p, warnPackageLevelEslint as pt, addFrameworkShim as q, isJsonLikeFile as r, migratePrettierToOxfmt as rt, rewriteMonorepo as s, detectEslintProject as st, detectEditorConflicts as t, confirmPrettierMigration as tt, detectPendingCoreMigration as u, promptEslintMigration as ut, installGitHooks as v, WEBDRIVERIO_PROVIDER as vt, injectCreateDefaultTemplate as w, warnMigration as wt, shouldSkipStagedMigrationForHooks as x, getCommandStartIndex as xt, isViteHooksSetupComplete as y, checkViteVersion as yt, discoverWorkspacePackages as z };