nanos-lint 2.8.0 → 2.8.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.
@@ -1,11 +1,18 @@
1
1
  import { fileURLToPath } from "node:url";
2
+ import * as xi from "node:fs";
2
3
  import fs from "node:fs";
3
- import path from "node:path";
4
+ import path, { posix, win32 } from "node:path";
4
5
  import os from "node:os";
5
6
  import process$1 from "node:process";
6
7
  import childProcess, { execFile, execFileSync } from "node:child_process";
8
+ import crypto from "node:crypto";
7
9
  import { promisify, stripVTControlCharacters } from "node:util";
10
+ import Pe, { Readable } from "node:stream";
11
+ import { pipeline } from "node:stream/promises";
12
+ import { lstatSync, readdir, readdirSync, readlinkSync, realpathSync } from "fs";
13
+ import { lstat, readdir as readdir$1, readlink, realpath } from "node:fs/promises";
8
14
  import { EventEmitter } from "node:events";
15
+ import { StringDecoder } from "node:string_decoder";
9
16
  //#region src/logger.ts
10
17
  const LOG_LEVELS = [
11
18
  "silent",
@@ -1458,13 +1465,19 @@ function getPlatformInfo(version = FALLBACK_LUALS_VERSION) {
1458
1465
  //#endregion
1459
1466
  //#region src/luals/validation.ts
1460
1467
  /**
1461
- * Verifies that a LuaLS binary exists, has non-trivial size, and is executable.
1468
+ * Minimum plausible size of a downloaded LuaLS executable. Release assets are
1469
+ * several megabytes, so anything smaller is a truncated download or a stray
1470
+ * file. This floor only applies to binaries nanos-lint fetched itself: a
1471
+ * user-supplied `LUALS_BIN` may legitimately be a small wrapper script.
1462
1472
  */
1463
- function isBinaryValid(binaryPath) {
1464
- if (!fs.existsSync(binaryPath)) return false;
1473
+ const MIN_DOWNLOADED_BINARY_SIZE_BYTES = 1e5;
1474
+ /**
1475
+ * Runs `binaryPath --version` and checks that it reports a LuaLS version.
1476
+ * Shared by every binary validation path; the size heuristic stays separate
1477
+ * because only downloaded archives have a known-plausible size.
1478
+ */
1479
+ function reportsLuaLSVersion(binaryPath) {
1465
1480
  try {
1466
- const stats = fs.statSync(binaryPath);
1467
- if (!stats.isFile() || stats.size < 1e5) return false;
1468
1481
  const output = execFileSync(binaryPath, ["--version"], {
1469
1482
  timeout: 5e3,
1470
1483
  stdio: "pipe",
@@ -1476,6 +1489,60 @@ function isBinaryValid(binaryPath) {
1476
1489
  return false;
1477
1490
  }
1478
1491
  }
1492
+ /**
1493
+ * Verifies that a downloaded or cached LuaLS binary exists, has non-trivial
1494
+ * size, and is executable.
1495
+ */
1496
+ function isBinaryValid(binaryPath) {
1497
+ if (!fs.existsSync(binaryPath)) return false;
1498
+ try {
1499
+ const stats = fs.statSync(binaryPath);
1500
+ if (!stats.isFile() || stats.size < 1e5) return false;
1501
+ return reportsLuaLSVersion(binaryPath);
1502
+ } catch (err) {
1503
+ logger.debug(`[luals] Binary validation check failed for ${binaryPath}: ${err instanceof Error ? err.message : String(err)}`);
1504
+ return false;
1505
+ }
1506
+ }
1507
+ /**
1508
+ * Verifies that an explicitly configured binary is a regular file that runs and
1509
+ * reports a LuaLS version, without the downloaded-archive size heuristic so
1510
+ * wrapper scripts (`LUALS_BIN=/usr/local/bin/lua-language-server`) keep working.
1511
+ */
1512
+ function isBinaryRunnable(binaryPath) {
1513
+ try {
1514
+ if (!fs.statSync(binaryPath).isFile()) return false;
1515
+ } catch (err) {
1516
+ logger.debug(`[luals] Binary validation check failed for ${binaryPath}: ${err instanceof Error ? err.message : String(err)}`);
1517
+ return false;
1518
+ }
1519
+ return reportsLuaLSVersion(binaryPath);
1520
+ }
1521
+ /**
1522
+ * Validates an explicitly configured LuaLS binary (`LUALS_BIN` environment
1523
+ * variable or `--luals-bin` CLI option) and returns its path.
1524
+ *
1525
+ * Both are documented escape hatches, so a typo, a stale path, a directory or an
1526
+ * unrelated executable must fail with an actionable error instead of a
1527
+ * confusing low-level failure deep inside the check run (#26). Executables are
1528
+ * accepted as-is when `--version` reports a version, including the thin wrapper
1529
+ * scripts that Homebrew/mason-style installations put on `PATH`: the size floor
1530
+ * used for downloaded archives would reject those.
1531
+ *
1532
+ * @param binaryPath Path exactly as the user supplied it.
1533
+ * @param source Name of the setting being validated (`LUALS_BIN` / `--luals-bin`).
1534
+ */
1535
+ function assertValidLuaLSBinary(binaryPath, source) {
1536
+ let stats;
1537
+ try {
1538
+ stats = fs.statSync(binaryPath);
1539
+ } catch (err) {
1540
+ throw new LuaLSError(`${source} points to '${binaryPath}', which does not exist or cannot be read: ${err instanceof Error ? err.message : String(err)}`, "ERR_LUALS_BIN_INVALID", `Set ${source} to the full path of a lua-language-server executable, or leave it unset so nanos-lint resolves LuaLS automatically.`, { cause: err });
1541
+ }
1542
+ if (!stats.isFile()) throw new LuaLSError(`${source} points to '${binaryPath}', which is not a regular file (a directory or special file was found).`, "ERR_LUALS_BIN_INVALID", `Point ${source} at the lua-language-server executable itself, or leave it unset so nanos-lint resolves LuaLS automatically.`);
1543
+ if (!isBinaryRunnable(binaryPath)) throw new LuaLSError(`${source} points to '${binaryPath}', which is not a runnable LuaLS binary (running it with '--version' failed or printed no version).`, "ERR_LUALS_BIN_INVALID", `Verify ${source} points at a working lua-language-server executable or wrapper script, or leave it unset so nanos-lint resolves LuaLS automatically.`);
1544
+ return binaryPath;
1545
+ }
1479
1546
  //#endregion
1480
1547
  //#region src/luals/cache.ts
1481
1548
  function getBaseLuaLSCacheDir() {
@@ -1516,7 +1583,12 @@ function readLuaLSMetadata(baseCacheDir = getBaseLuaLSCacheDir()) {
1516
1583
  try {
1517
1584
  const content = fs.readFileSync(metaPath, "utf-8");
1518
1585
  const parsed = JSON.parse(content);
1519
- if (typeof parsed?.lastCheckedWeek === "string" && typeof parsed?.latestVersion === "string") return parsed;
1586
+ const rawVersion = parsed?.latestVersion;
1587
+ const safeVersion = typeof rawVersion === "string" ? sanitizeLuaLSVersion(rawVersion) : null;
1588
+ if (typeof parsed?.lastCheckedWeek === "string" && safeVersion !== null) return {
1589
+ ...parsed,
1590
+ latestVersion: safeVersion
1591
+ };
1520
1592
  try {
1521
1593
  fs.unlinkSync(metaPath);
1522
1594
  logger.warn(`[luals] Stale or invalid LuaLS metadata at ${metaPath} purged.`);
@@ -1656,6 +1728,44 @@ function findExistingLuaLSDir(version, baseCacheDir = getBaseLuaLSCacheDir()) {
1656
1728
  }
1657
1729
  //#endregion
1658
1730
  //#region src/luals/download.ts
1731
+ const DOWNLOAD_TIMEOUT_MS = 12e4;
1732
+ const MAX_ARCHIVE_SIZE_BYTES = 157286400;
1733
+ const ALLOWED_DOWNLOAD_DOMAINS = ["github.com", "githubusercontent.com"];
1734
+ /**
1735
+ * Validates that a download URL uses HTTPS and targets an allowlisted host.
1736
+ */
1737
+ function isAllowedDownloadUrl(urlString) {
1738
+ try {
1739
+ const parsed = new URL(urlString);
1740
+ if (parsed.protocol !== "https:") return false;
1741
+ const hostname = parsed.hostname.toLowerCase();
1742
+ return ALLOWED_DOWNLOAD_DOMAINS.some((domain) => hostname === domain || hostname.endsWith(`.${domain}`));
1743
+ } catch {
1744
+ return false;
1745
+ }
1746
+ }
1747
+ /** Chunk size used when hashing an archive, so a 150 MB asset is never buffered whole. */
1748
+ const HASH_CHUNK_SIZE_BYTES = 1048576;
1749
+ /**
1750
+ * Calculates the SHA-256 hash of a file on disk in bounded memory.
1751
+ */
1752
+ function computeFileSha256(filePath) {
1753
+ const hash = crypto.createHash("sha256");
1754
+ const fd = fs.openSync(filePath, "r");
1755
+ try {
1756
+ const buffer = Buffer.alloc(HASH_CHUNK_SIZE_BYTES);
1757
+ let position = 0;
1758
+ let bytesRead = fs.readSync(fd, buffer, 0, buffer.length, position);
1759
+ while (bytesRead > 0) {
1760
+ hash.update(buffer.subarray(0, bytesRead));
1761
+ position += bytesRead;
1762
+ bytesRead = fs.readSync(fd, buffer, 0, buffer.length, position);
1763
+ }
1764
+ } finally {
1765
+ fs.closeSync(fd);
1766
+ }
1767
+ return hash.digest("hex");
1768
+ }
1659
1769
  const execFileAsync$1 = promisify(execFile);
1660
1770
  /**
1661
1771
  * Escapes single quotes for safe PowerShell single-quoted string interpolation.
@@ -1663,6 +1773,17 @@ const execFileAsync$1 = promisify(execFile);
1663
1773
  function escapePowerShellSingleQuote(str) {
1664
1774
  return str.replace(/'/g, "''");
1665
1775
  }
1776
+ /**
1777
+ * Enforces a maximum byte count on an asynchronous download stream.
1778
+ */
1779
+ async function* limitDownloadStream(source) {
1780
+ let total = 0;
1781
+ for await (const chunk of source) {
1782
+ total += chunk.length;
1783
+ if (total > 157286400) throw new LuaLSError(`Download exceeded maximum allowed size of ${MAX_ARCHIVE_SIZE_BYTES} bytes`, "ERR_LUALS_DOWNLOAD", "Verify the LuaLS release asset size or specify a local binary with LUALS_BIN.");
1784
+ yield chunk;
1785
+ }
1786
+ }
1666
1787
  async function downloadAndExtractLuaLS(version = DEFAULT_LUALS_VERSION, targetDir, options) {
1667
1788
  const resolvedVersion = await resolveLuaLSVersion(version);
1668
1789
  const info = getPlatformInfo(resolvedVersion);
@@ -1697,195 +1818,3594 @@ async function downloadAndExtractLuaLS(version = DEFAULT_LUALS_VERSION, targetDi
1697
1818
  if (!options?.quiet) logger.info(`[luals] Reusing existing LuaLS ${resolvedVersion} installation from ${existingSourceDir}...`);
1698
1819
  fs.cpSync(existingSourceDir, tempDir, { recursive: true });
1699
1820
  } else {
1821
+ if (!isAllowedDownloadUrl(url)) throw new LuaLSError(`Refusing to download LuaLS from untrusted URL: ${url}`, "ERR_LUALS_DOWNLOAD", "Download URLs must use HTTPS and target an allowlisted GitHub host.");
1700
1822
  if (!options?.quiet) logger.info(`[luals] Downloading LuaLS ${resolvedVersion} from ${url}...`);
1701
1823
  let response = null;
1702
1824
  let lastErr = null;
1703
1825
  for (let attempt = 1; attempt <= 3; attempt++) {
1704
1826
  try {
1705
- const res = await fetch(url);
1827
+ const res = await fetch(url, { signal: AbortSignal.timeout(DOWNLOAD_TIMEOUT_MS) });
1828
+ if (res.url && !isAllowedDownloadUrl(res.url)) {
1829
+ await res.body?.cancel();
1830
+ throw new LuaLSError(`Redirect to untrusted URL blocked: ${res.url}`, "ERR_LUALS_DOWNLOAD", "Download redirects must stay on allowlisted HTTPS GitHub hosts.");
1831
+ }
1706
1832
  if (res.ok && res.body) {
1707
1833
  response = res;
1708
1834
  break;
1709
1835
  }
1710
- await res.body?.cancel();
1711
- lastErr = /* @__PURE__ */ new Error(`Failed to download ${url}: ${res.status} ${res.statusText}`);
1712
- } catch (err) {
1713
- lastErr = err;
1836
+ await res.body?.cancel();
1837
+ lastErr = /* @__PURE__ */ new Error(`Failed to download ${url}: ${res.status} ${res.statusText}`);
1838
+ } catch (err) {
1839
+ lastErr = err;
1840
+ }
1841
+ if (attempt < 3) await new Promise((resolve) => setTimeout(resolve, attempt * 1e3));
1842
+ }
1843
+ if (!response || !response.body) {
1844
+ if (lastErr instanceof LuaLSError) throw lastErr;
1845
+ throw new LuaLSError(`Failed to download LuaLS from ${url}${lastErr ? `: ${lastErr instanceof Error ? lastErr.message : String(lastErr)}` : ""}`, "ERR_LUALS_DOWNLOAD", "Check your network connection or specify a custom binary with LUALS_BIN.", { cause: lastErr });
1846
+ }
1847
+ const contentLengthHeader = response.headers?.get?.("content-length");
1848
+ if (contentLengthHeader) {
1849
+ const contentLength = parseInt(contentLengthHeader, 10);
1850
+ if (!isNaN(contentLength) && contentLength > 157286400) {
1851
+ await response.body.cancel();
1852
+ throw new LuaLSError(`Archive size (${contentLength} bytes) exceeds maximum limit (${MAX_ARCHIVE_SIZE_BYTES} bytes)`, "ERR_LUALS_DOWNLOAD", "Verify the LuaLS release asset size or specify a local binary with LUALS_BIN.");
1853
+ }
1854
+ }
1855
+ const fileStream = fs.createWriteStream(archivePath);
1856
+ try {
1857
+ const streamSource = typeof Readable.fromWeb === "function" && !("pipe" in response.body) ? Readable.fromWeb(response.body) : response.body;
1858
+ await pipeline(streamSource, limitDownloadStream, fileStream);
1859
+ } catch (streamErr) {
1860
+ try {
1861
+ if (fs.existsSync(archivePath)) fs.unlinkSync(archivePath);
1862
+ } catch (unlinkErr) {}
1863
+ if (streamErr instanceof LuaLSError) throw streamErr;
1864
+ throw new LuaLSError(`Failed to download LuaLS from ${url}: ${streamErr instanceof Error ? streamErr.message : String(streamErr)}`, "ERR_LUALS_DOWNLOAD", "Check your network connection or specify a custom binary with LUALS_BIN.", { cause: streamErr });
1865
+ }
1866
+ const archiveSha256 = computeFileSha256(archivePath);
1867
+ logger.info(`[luals] Downloaded ${info.assetName} (SHA-256 ${archiveSha256})`);
1868
+ if (!options?.quiet) logger.info(`[luals] Extracting to ${destDir}...`);
1869
+ try {
1870
+ const tarArgs = process.platform === "win32" ? [
1871
+ "-xf",
1872
+ archivePath,
1873
+ "-C",
1874
+ tempDir
1875
+ ] : [
1876
+ "-xf",
1877
+ archivePath,
1878
+ "--no-same-owner",
1879
+ "--no-same-permissions",
1880
+ "-C",
1881
+ tempDir
1882
+ ];
1883
+ await execFileAsync$1("tar", tarArgs);
1884
+ } catch (tarErr) {
1885
+ if (process.platform === "win32" && info.assetName.endsWith(".zip")) await execFileAsync$1("powershell.exe", [
1886
+ "-NoProfile",
1887
+ "-Command",
1888
+ `Expand-Archive -Path '${escapePowerShellSingleQuote(archivePath)}' -DestinationPath '${escapePowerShellSingleQuote(tempDir)}' -Force`
1889
+ ]);
1890
+ else throw tarErr;
1891
+ }
1892
+ try {
1893
+ fs.unlinkSync(archivePath);
1894
+ } catch (err) {
1895
+ logger.debug(`[luals] Failed to delete temporary archive ${archivePath}: ${err instanceof Error ? err.message : String(err)}`);
1896
+ }
1897
+ }
1898
+ const tempBinaryPath = path.join(tempDir, info.binaryRelativePath);
1899
+ if (!fs.existsSync(tempBinaryPath)) throw new LuaLSError(`Failed to extract valid LuaLS binary to expected path: ${tempBinaryPath}`, "ERR_LUALS_EXTRACT", "Run 'nanos-lint clean-cache' and ensure there is sufficient disk space.");
1900
+ const lstat = fs.lstatSync(tempBinaryPath);
1901
+ if (lstat.isSymbolicLink()) throw new LuaLSError(`Extracted binary at '${tempBinaryPath}' is a symbolic link. Refusing to chmod or execute archive-planted symlinks.`, "ERR_LUALS_EXTRACT", "Run 'nanos-lint clean-cache' and verify the LuaLS release integrity.");
1902
+ if (!lstat.isFile()) throw new LuaLSError(`Extracted binary at '${tempBinaryPath}' is not a regular file.`, "ERR_LUALS_EXTRACT", "Run 'nanos-lint clean-cache' and verify the LuaLS release integrity.");
1903
+ const realBinaryPath = fs.realpathSync(tempBinaryPath);
1904
+ const resolvedTemp = fs.realpathSync(tempDir);
1905
+ if (!realBinaryPath.startsWith(resolvedTemp + path.sep) && realBinaryPath !== resolvedTemp) throw new LuaLSError(`Extracted binary path escapes extraction directory: ${realBinaryPath}`, "ERR_LUALS_EXTRACT", "Run 'nanos-lint clean-cache' and verify the LuaLS release integrity.");
1906
+ if (process.platform !== "win32") try {
1907
+ fs.chmodSync(tempBinaryPath, 493);
1908
+ } catch (err) {
1909
+ logger.warn(`[luals] Failed to chmod binary at ${tempBinaryPath}: ${err instanceof Error ? err.message : String(err)}`);
1910
+ }
1911
+ if (lstat.size < 1e5) throw new LuaLSError(`Failed to extract valid LuaLS binary to expected path: ${tempBinaryPath}`, "ERR_LUALS_EXTRACT", "Run 'nanos-lint clean-cache' and ensure there is sufficient disk space.");
1912
+ if (!isBinaryValid(tempBinaryPath)) throw new LuaLSError(`Extracted LuaLS binary at ${tempBinaryPath} is invalid or non-functional.`, "ERR_LUALS_INVALID_BINARY", "Run 'nanos-lint clean-cache' to remove corrupted downloads or set LUALS_BIN to a custom binary.");
1913
+ fs.writeFileSync(path.join(tempDir, ".complete"), resolvedVersion, "utf-8");
1914
+ for (let attempt = 0; attempt < 5; attempt++) try {
1915
+ fs.renameSync(tempDir, destDir);
1916
+ break;
1917
+ } catch (renameErr) {
1918
+ if (fs.existsSync(binaryPath) && isBinaryValid(binaryPath)) {
1919
+ try {
1920
+ fs.rmSync(tempDir, {
1921
+ recursive: true,
1922
+ force: true
1923
+ });
1924
+ } catch (err) {
1925
+ logger.debug(`[luals] Failed to remove temp directory after concurrent promotion: ${err instanceof Error ? err.message : String(err)}`);
1926
+ }
1927
+ if (!options?.quiet) logger.info(`[luals] Ready: ${binaryPath}`);
1928
+ return binaryPath;
1929
+ }
1930
+ if (attempt < 4) await new Promise((resolve) => setTimeout(resolve, 100 * (attempt + 1)));
1931
+ else {
1932
+ if (fs.existsSync(destDir) && (!fs.existsSync(binaryPath) || !fs.existsSync(completeMarker))) try {
1933
+ fs.rmSync(destDir, {
1934
+ recursive: true,
1935
+ force: true
1936
+ });
1937
+ } catch (err) {
1938
+ logger.warn(`[luals] Failed to clean up broken destination directory ${destDir}: ${err instanceof Error ? err.message : String(err)}`);
1939
+ }
1940
+ throw renameErr;
1941
+ }
1942
+ }
1943
+ if (!options?.quiet) logger.info(`[luals] Ready: ${binaryPath}`);
1944
+ return binaryPath;
1945
+ } finally {
1946
+ if (fs.existsSync(tempDir)) try {
1947
+ fs.rmSync(tempDir, {
1948
+ recursive: true,
1949
+ force: true
1950
+ });
1951
+ } catch (err) {
1952
+ logger.debug(`[luals] Failed to clean up temporary directory ${tempDir}: ${err instanceof Error ? err.message : String(err)}`);
1953
+ }
1954
+ }
1955
+ }
1956
+ //#endregion
1957
+ //#region node_modules/glob/dist/esm/index.min.js
1958
+ var Gt = (n, t, e) => {
1959
+ let s = n instanceof RegExp ? ce(n, e) : n, i = t instanceof RegExp ? ce(t, e) : t, r = s !== null && i != null && ss(s, i, e);
1960
+ return r && {
1961
+ start: r[0],
1962
+ end: r[1],
1963
+ pre: e.slice(0, r[0]),
1964
+ body: e.slice(r[0] + s.length, r[1]),
1965
+ post: e.slice(r[1] + i.length)
1966
+ };
1967
+ };
1968
+ var ce = (n, t) => {
1969
+ let e = t.match(n);
1970
+ return e ? e[0] : null;
1971
+ };
1972
+ var ss = (n, t, e) => {
1973
+ let s, i, r, o, h, a = e.indexOf(n), l = e.indexOf(t, a + 1), u = a;
1974
+ if (a >= 0 && l > 0) {
1975
+ if (n === t) return [a, l];
1976
+ for (s = [], r = e.length; u >= 0 && !h;) {
1977
+ if (u === a) s.push(u), a = e.indexOf(n, u + 1);
1978
+ else if (s.length === 1) {
1979
+ let c = s.pop();
1980
+ c !== void 0 && (h = [c, l]);
1981
+ } else i = s.pop(), i !== void 0 && i < r && (r = i, o = l), l = e.indexOf(t, u + 1);
1982
+ u = a < l && a >= 0 ? a : l;
1983
+ }
1984
+ s.length && o !== void 0 && (h = [r, o]);
1985
+ }
1986
+ return h;
1987
+ };
1988
+ var fe = "\0SLASH" + Math.random() + "\0";
1989
+ var ue = "\0OPEN" + Math.random() + "\0";
1990
+ var qt = "\0CLOSE" + Math.random() + "\0";
1991
+ var de = "\0COMMA" + Math.random() + "\0";
1992
+ var pe = "\0PERIOD" + Math.random() + "\0";
1993
+ var is = new RegExp(fe, "g");
1994
+ var rs = new RegExp(ue, "g");
1995
+ var ns = new RegExp(qt, "g");
1996
+ var os$1 = new RegExp(de, "g");
1997
+ var hs = new RegExp(pe, "g");
1998
+ var as = /\\\\/g;
1999
+ var ls = /\\{/g;
2000
+ var cs = /\\}/g;
2001
+ var fs$1 = /\\,/g;
2002
+ var us = /\\./g;
2003
+ var ds = 1e5;
2004
+ function Ht(n) {
2005
+ return isNaN(n) ? n.charCodeAt(0) : parseInt(n, 10);
2006
+ }
2007
+ function ps(n) {
2008
+ return n.replace(as, fe).replace(ls, ue).replace(cs, qt).replace(fs$1, de).replace(us, pe);
2009
+ }
2010
+ function ms(n) {
2011
+ return n.replace(is, "\\").replace(rs, "{").replace(ns, "}").replace(os$1, ",").replace(hs, ".");
2012
+ }
2013
+ function me(n) {
2014
+ if (!n) return [""];
2015
+ let t = [], e = Gt("{", "}", n);
2016
+ if (!e) return n.split(",");
2017
+ let { pre: s, body: i, post: r } = e, o = s.split(",");
2018
+ o[o.length - 1] += "{" + i + "}";
2019
+ let h = me(r);
2020
+ return r.length && (o[o.length - 1] += h.shift(), o.push.apply(o, h)), t.push.apply(t, o), t;
2021
+ }
2022
+ function ge(n, t = {}) {
2023
+ if (!n) return [];
2024
+ let { max: e = ds } = t;
2025
+ return n.slice(0, 2) === "{}" && (n = "\\{\\}" + n.slice(2)), ht(ps(n), e, !0).map(ms);
2026
+ }
2027
+ function gs(n) {
2028
+ return "{" + n + "}";
2029
+ }
2030
+ function ws(n) {
2031
+ return /^-?0\d/.test(n);
2032
+ }
2033
+ function ys(n, t) {
2034
+ return n <= t;
2035
+ }
2036
+ function bs(n, t) {
2037
+ return n >= t;
2038
+ }
2039
+ function ht(n, t, e) {
2040
+ let s = [], i = Gt("{", "}", n);
2041
+ if (!i) return [n];
2042
+ let r = i.pre, o = i.post.length ? ht(i.post, t, !1) : [""];
2043
+ if (/\$$/.test(i.pre)) for (let h = 0; h < o.length && h < t; h++) {
2044
+ let a = r + "{" + i.body + "}" + o[h];
2045
+ s.push(a);
2046
+ }
2047
+ else {
2048
+ let h = /^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(i.body), a = /^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(i.body), l = h || a, u = i.body.indexOf(",") >= 0;
2049
+ if (!l && !u) return i.post.match(/,(?!,).*\}/) ? (n = i.pre + "{" + i.body + qt + i.post, ht(n, t, !0)) : [n];
2050
+ let c;
2051
+ if (l) c = i.body.split(/\.\./);
2052
+ else if (c = me(i.body), c.length === 1 && c[0] !== void 0 && (c = ht(c[0], t, !1).map(gs), c.length === 1)) return o.map((f) => i.pre + c[0] + f);
2053
+ let d;
2054
+ if (l && c[0] !== void 0 && c[1] !== void 0) {
2055
+ let f = Ht(c[0]), m = Ht(c[1]), p = Math.max(c[0].length, c[1].length), w = c.length === 3 && c[2] !== void 0 ? Math.abs(Ht(c[2])) : 1, g = ys;
2056
+ m < f && (w *= -1, g = bs);
2057
+ let E = c.some(ws);
2058
+ d = [];
2059
+ for (let y = f; g(y, m); y += w) {
2060
+ let b;
2061
+ if (a) b = String.fromCharCode(y), b === "\\" && (b = "");
2062
+ else if (b = String(y), E) {
2063
+ let z = p - b.length;
2064
+ if (z > 0) {
2065
+ let $ = new Array(z + 1).join("0");
2066
+ y < 0 ? b = "-" + $ + b.slice(1) : b = $ + b;
2067
+ }
2068
+ }
2069
+ d.push(b);
2070
+ }
2071
+ } else {
2072
+ d = [];
2073
+ for (let f = 0; f < c.length; f++) d.push.apply(d, ht(c[f], t, !1));
2074
+ }
2075
+ for (let f = 0; f < d.length; f++) for (let m = 0; m < o.length && s.length < t; m++) {
2076
+ let p = r + d[f] + o[m];
2077
+ (!e || l || p) && s.push(p);
2078
+ }
2079
+ }
2080
+ return s;
2081
+ }
2082
+ var at = (n) => {
2083
+ if (typeof n != "string") throw new TypeError("invalid pattern");
2084
+ if (n.length > 65536) throw new TypeError("pattern is too long");
2085
+ };
2086
+ var Ss = {
2087
+ "[:alnum:]": ["\\p{L}\\p{Nl}\\p{Nd}", !0],
2088
+ "[:alpha:]": ["\\p{L}\\p{Nl}", !0],
2089
+ "[:ascii:]": ["\\x00-\\x7f", !1],
2090
+ "[:blank:]": ["\\p{Zs}\\t", !0],
2091
+ "[:cntrl:]": ["\\p{Cc}", !0],
2092
+ "[:digit:]": ["\\p{Nd}", !0],
2093
+ "[:graph:]": [
2094
+ "\\p{Z}\\p{C}",
2095
+ !0,
2096
+ !0
2097
+ ],
2098
+ "[:lower:]": ["\\p{Ll}", !0],
2099
+ "[:print:]": ["\\p{C}", !0],
2100
+ "[:punct:]": ["\\p{P}", !0],
2101
+ "[:space:]": ["\\p{Z}\\t\\r\\n\\v\\f", !0],
2102
+ "[:upper:]": ["\\p{Lu}", !0],
2103
+ "[:word:]": ["\\p{L}\\p{Nl}\\p{Nd}\\p{Pc}", !0],
2104
+ "[:xdigit:]": ["A-Fa-f0-9", !1]
2105
+ };
2106
+ var lt = (n) => n.replace(/[[\]\\-]/g, "\\$&");
2107
+ var Es = (n) => n.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
2108
+ var we = (n) => n.join("");
2109
+ var ye = (n, t) => {
2110
+ let e = t;
2111
+ if (n.charAt(e) !== "[") throw new Error("not in a brace expression");
2112
+ let s = [], i = [], r = e + 1, o = !1, h = !1, a = !1, l = !1, u = e, c = "";
2113
+ t: for (; r < n.length;) {
2114
+ let p = n.charAt(r);
2115
+ if ((p === "!" || p === "^") && r === e + 1) {
2116
+ l = !0, r++;
2117
+ continue;
2118
+ }
2119
+ if (p === "]" && o && !a) {
2120
+ u = r + 1;
2121
+ break;
2122
+ }
2123
+ if (o = !0, p === "\\" && !a) {
2124
+ a = !0, r++;
2125
+ continue;
2126
+ }
2127
+ if (p === "[" && !a) {
2128
+ for (let [w, [g, S, E]] of Object.entries(Ss)) if (n.startsWith(w, r)) {
2129
+ if (c) return [
2130
+ "$.",
2131
+ !1,
2132
+ n.length - e,
2133
+ !0
2134
+ ];
2135
+ r += w.length, E ? i.push(g) : s.push(g), h = h || S;
2136
+ continue t;
2137
+ }
2138
+ }
2139
+ if (a = !1, c) {
2140
+ p > c ? s.push(lt(c) + "-" + lt(p)) : p === c && s.push(lt(p)), c = "", r++;
2141
+ continue;
2142
+ }
2143
+ if (n.startsWith("-]", r + 1)) {
2144
+ s.push(lt(p + "-")), r += 2;
2145
+ continue;
2146
+ }
2147
+ if (n.startsWith("-", r + 1)) {
2148
+ c = p, r += 2;
2149
+ continue;
2150
+ }
2151
+ s.push(lt(p)), r++;
2152
+ }
2153
+ if (u < r) return [
2154
+ "",
2155
+ !1,
2156
+ 0,
2157
+ !1
2158
+ ];
2159
+ if (!s.length && !i.length) return [
2160
+ "$.",
2161
+ !1,
2162
+ n.length - e,
2163
+ !0
2164
+ ];
2165
+ if (i.length === 0 && s.length === 1 && /^\\?.$/.test(s[0]) && !l) return [
2166
+ Es(s[0].length === 2 ? s[0].slice(-1) : s[0]),
2167
+ !1,
2168
+ u - e,
2169
+ !1
2170
+ ];
2171
+ let d = "[" + (l ? "^" : "") + we(s) + "]", f = "[" + (l ? "" : "^") + we(i) + "]";
2172
+ return [
2173
+ s.length && i.length ? "(" + d + "|" + f + ")" : s.length ? d : f,
2174
+ h,
2175
+ u - e,
2176
+ !0
2177
+ ];
2178
+ };
2179
+ var W = (n, { windowsPathsNoEscape: t = !1, magicalBraces: e = !0 } = {}) => e ? t ? n.replace(/\[([^\/\\])\]/g, "$1") : n.replace(/((?!\\).|^)\[([^\/\\])\]/g, "$1$2").replace(/\\([^\/])/g, "$1") : t ? n.replace(/\[([^\/\\{}])\]/g, "$1") : n.replace(/((?!\\).|^)\[([^\/\\{}])\]/g, "$1$2").replace(/\\([^\/{}])/g, "$1");
2180
+ var xs = /* @__PURE__ */ new Set([
2181
+ "!",
2182
+ "?",
2183
+ "+",
2184
+ "*",
2185
+ "@"
2186
+ ]);
2187
+ var be = (n) => xs.has(n);
2188
+ var vs = "(?!(?:^|/)\\.\\.?(?:$|/))";
2189
+ var Ct = "(?!\\.)";
2190
+ var Cs = /* @__PURE__ */ new Set(["[", "."]);
2191
+ var Ts = /* @__PURE__ */ new Set(["..", "."]);
2192
+ var As = /* @__PURE__ */ new Set("().*{}+?[]^$\\!");
2193
+ var ks = (n) => n.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
2194
+ var Kt = "[^/]";
2195
+ var Se = Kt + "*?";
2196
+ var Ee = Kt + "+?";
2197
+ var Q = class n {
2198
+ type;
2199
+ #t;
2200
+ #s;
2201
+ #n = !1;
2202
+ #r = [];
2203
+ #o;
2204
+ #S;
2205
+ #w;
2206
+ #c = !1;
2207
+ #h;
2208
+ #u;
2209
+ #f = !1;
2210
+ constructor(t, e, s = {}) {
2211
+ this.type = t, t && (this.#s = !0), this.#o = e, this.#t = this.#o ? this.#o.#t : this, this.#h = this.#t === this ? s : this.#t.#h, this.#w = this.#t === this ? [] : this.#t.#w, t === "!" && !this.#t.#c && this.#w.push(this), this.#S = this.#o ? this.#o.#r.length : 0;
2212
+ }
2213
+ get hasMagic() {
2214
+ if (this.#s !== void 0) return this.#s;
2215
+ for (let t of this.#r) if (typeof t != "string" && (t.type || t.hasMagic)) return this.#s = !0;
2216
+ return this.#s;
2217
+ }
2218
+ toString() {
2219
+ return this.#u !== void 0 ? this.#u : this.type ? this.#u = this.type + "(" + this.#r.map((t) => String(t)).join("|") + ")" : this.#u = this.#r.map((t) => String(t)).join("");
2220
+ }
2221
+ #a() {
2222
+ if (this !== this.#t) throw new Error("should only call on root");
2223
+ if (this.#c) return this;
2224
+ this.toString(), this.#c = !0;
2225
+ let t;
2226
+ for (; t = this.#w.pop();) {
2227
+ if (t.type !== "!") continue;
2228
+ let e = t, s = e.#o;
2229
+ for (; s;) {
2230
+ for (let i = e.#S + 1; !s.type && i < s.#r.length; i++) for (let r of t.#r) {
2231
+ if (typeof r == "string") throw new Error("string part in extglob AST??");
2232
+ r.copyIn(s.#r[i]);
2233
+ }
2234
+ e = s, s = e.#o;
2235
+ }
2236
+ }
2237
+ return this;
2238
+ }
2239
+ push(...t) {
2240
+ for (let e of t) if (e !== "") {
2241
+ if (typeof e != "string" && !(e instanceof n && e.#o === this)) throw new Error("invalid part: " + e);
2242
+ this.#r.push(e);
2243
+ }
2244
+ }
2245
+ toJSON() {
2246
+ let t = this.type === null ? this.#r.slice().map((e) => typeof e == "string" ? e : e.toJSON()) : [this.type, ...this.#r.map((e) => e.toJSON())];
2247
+ return this.isStart() && !this.type && t.unshift([]), this.isEnd() && (this === this.#t || this.#t.#c && this.#o?.type === "!") && t.push({}), t;
2248
+ }
2249
+ isStart() {
2250
+ if (this.#t === this) return !0;
2251
+ if (!this.#o?.isStart()) return !1;
2252
+ if (this.#S === 0) return !0;
2253
+ let t = this.#o;
2254
+ for (let e = 0; e < this.#S; e++) {
2255
+ let s = t.#r[e];
2256
+ if (!(s instanceof n && s.type === "!")) return !1;
2257
+ }
2258
+ return !0;
2259
+ }
2260
+ isEnd() {
2261
+ if (this.#t === this || this.#o?.type === "!") return !0;
2262
+ if (!this.#o?.isEnd()) return !1;
2263
+ if (!this.type) return this.#o?.isEnd();
2264
+ let t = this.#o ? this.#o.#r.length : 0;
2265
+ return this.#S === t - 1;
2266
+ }
2267
+ copyIn(t) {
2268
+ typeof t == "string" ? this.push(t) : this.push(t.clone(this));
2269
+ }
2270
+ clone(t) {
2271
+ let e = new n(this.type, t);
2272
+ for (let s of this.#r) e.copyIn(s);
2273
+ return e;
2274
+ }
2275
+ static #i(t, e, s, i) {
2276
+ let r = !1, o = !1, h = -1, a = !1;
2277
+ if (e.type === null) {
2278
+ let f = s, m = "";
2279
+ for (; f < t.length;) {
2280
+ let p = t.charAt(f++);
2281
+ if (r || p === "\\") {
2282
+ r = !r, m += p;
2283
+ continue;
2284
+ }
2285
+ if (o) {
2286
+ f === h + 1 ? (p === "^" || p === "!") && (a = !0) : p === "]" && !(f === h + 2 && a) && (o = !1), m += p;
2287
+ continue;
2288
+ } else if (p === "[") {
2289
+ o = !0, h = f, a = !1, m += p;
2290
+ continue;
2291
+ }
2292
+ if (!i.noext && be(p) && t.charAt(f) === "(") {
2293
+ e.push(m), m = "";
2294
+ let w = new n(p, e);
2295
+ f = n.#i(t, w, f, i), e.push(w);
2296
+ continue;
2297
+ }
2298
+ m += p;
2299
+ }
2300
+ return e.push(m), f;
2301
+ }
2302
+ let l = s + 1, u = new n(null, e), c = [], d = "";
2303
+ for (; l < t.length;) {
2304
+ let f = t.charAt(l++);
2305
+ if (r || f === "\\") {
2306
+ r = !r, d += f;
2307
+ continue;
2308
+ }
2309
+ if (o) {
2310
+ l === h + 1 ? (f === "^" || f === "!") && (a = !0) : f === "]" && !(l === h + 2 && a) && (o = !1), d += f;
2311
+ continue;
2312
+ } else if (f === "[") {
2313
+ o = !0, h = l, a = !1, d += f;
2314
+ continue;
2315
+ }
2316
+ if (be(f) && t.charAt(l) === "(") {
2317
+ u.push(d), d = "";
2318
+ let m = new n(f, u);
2319
+ u.push(m), l = n.#i(t, m, l, i);
2320
+ continue;
2321
+ }
2322
+ if (f === "|") {
2323
+ u.push(d), d = "", c.push(u), u = new n(null, e);
2324
+ continue;
2325
+ }
2326
+ if (f === ")") return d === "" && e.#r.length === 0 && (e.#f = !0), u.push(d), d = "", e.push(...c, u), l;
2327
+ d += f;
2328
+ }
2329
+ return e.type = null, e.#s = void 0, e.#r = [t.substring(s - 1)], l;
2330
+ }
2331
+ static fromGlob(t, e = {}) {
2332
+ let s = new n(null, void 0, e);
2333
+ return n.#i(t, s, 0, e), s;
2334
+ }
2335
+ toMMPattern() {
2336
+ if (this !== this.#t) return this.#t.toMMPattern();
2337
+ let t = this.toString(), [e, s, i, r] = this.toRegExpSource();
2338
+ if (!(i || this.#s || this.#h.nocase && !this.#h.nocaseMagicOnly && t.toUpperCase() !== t.toLowerCase())) return s;
2339
+ let h = (this.#h.nocase ? "i" : "") + (r ? "u" : "");
2340
+ return Object.assign(new RegExp(`^${e}$`, h), {
2341
+ _src: e,
2342
+ _glob: t
2343
+ });
2344
+ }
2345
+ get options() {
2346
+ return this.#h;
2347
+ }
2348
+ toRegExpSource(t) {
2349
+ let e = t ?? !!this.#h.dot;
2350
+ if (this.#t === this && this.#a(), !this.type) {
2351
+ let a = this.isStart() && this.isEnd() && !this.#r.some((f) => typeof f != "string"), l = this.#r.map((f) => {
2352
+ let [m, p, w, g] = typeof f == "string" ? n.#E(f, this.#s, a) : f.toRegExpSource(t);
2353
+ return this.#s = this.#s || w, this.#n = this.#n || g, m;
2354
+ }).join(""), u = "";
2355
+ if (this.isStart() && typeof this.#r[0] == "string" && !(this.#r.length === 1 && Ts.has(this.#r[0]))) {
2356
+ let m = Cs, p = e && m.has(l.charAt(0)) || l.startsWith("\\.") && m.has(l.charAt(2)) || l.startsWith("\\.\\.") && m.has(l.charAt(4)), w = !e && !t && m.has(l.charAt(0));
2357
+ u = p ? vs : w ? Ct : "";
2358
+ }
2359
+ let c = "";
2360
+ return this.isEnd() && this.#t.#c && this.#o?.type === "!" && (c = "(?:$|\\/)"), [
2361
+ u + l + c,
2362
+ W(l),
2363
+ this.#s = !!this.#s,
2364
+ this.#n
2365
+ ];
2366
+ }
2367
+ let s = this.type === "*" || this.type === "+", i = this.type === "!" ? "(?:(?!(?:" : "(?:", r = this.#d(e);
2368
+ if (this.isStart() && this.isEnd() && !r && this.type !== "!") {
2369
+ let a = this.toString();
2370
+ return this.#r = [a], this.type = null, this.#s = void 0, [
2371
+ a,
2372
+ W(this.toString()),
2373
+ !1,
2374
+ !1
2375
+ ];
2376
+ }
2377
+ let o = !s || t || e || !Ct ? "" : this.#d(!0);
2378
+ o === r && (o = ""), o && (r = `(?:${r})(?:${o})*?`);
2379
+ let h = "";
2380
+ if (this.type === "!" && this.#f) h = (this.isStart() && !e ? Ct : "") + Ee;
2381
+ else {
2382
+ let a = this.type === "!" ? "))" + (this.isStart() && !e && !t ? Ct : "") + Se + ")" : this.type === "@" ? ")" : this.type === "?" ? ")?" : this.type === "+" && o ? ")" : this.type === "*" && o ? ")?" : `)${this.type}`;
2383
+ h = i + r + a;
2384
+ }
2385
+ return [
2386
+ h,
2387
+ W(r),
2388
+ this.#s = !!this.#s,
2389
+ this.#n
2390
+ ];
2391
+ }
2392
+ #d(t) {
2393
+ return this.#r.map((e) => {
2394
+ if (typeof e == "string") throw new Error("string type in extglob ast??");
2395
+ let [s, i, r, o] = e.toRegExpSource(t);
2396
+ return this.#n = this.#n || o, s;
2397
+ }).filter((e) => !(this.isStart() && this.isEnd()) || !!e).join("|");
2398
+ }
2399
+ static #E(t, e, s = !1) {
2400
+ let i = !1, r = "", o = !1, h = !1;
2401
+ for (let a = 0; a < t.length; a++) {
2402
+ let l = t.charAt(a);
2403
+ if (i) {
2404
+ i = !1, r += (As.has(l) ? "\\" : "") + l;
2405
+ continue;
2406
+ }
2407
+ if (l === "*") {
2408
+ if (h) continue;
2409
+ h = !0, r += s && /^[*]+$/.test(t) ? Ee : Se, e = !0;
2410
+ continue;
2411
+ } else h = !1;
2412
+ if (l === "\\") {
2413
+ a === t.length - 1 ? r += "\\\\" : i = !0;
2414
+ continue;
2415
+ }
2416
+ if (l === "[") {
2417
+ let [u, c, d, f] = ye(t, a);
2418
+ if (d) {
2419
+ r += u, o = o || c, a += d - 1, e = e || f;
2420
+ continue;
2421
+ }
2422
+ }
2423
+ if (l === "?") {
2424
+ r += Kt, e = !0;
2425
+ continue;
2426
+ }
2427
+ r += ks(l);
2428
+ }
2429
+ return [
2430
+ r,
2431
+ W(t),
2432
+ !!e,
2433
+ o
2434
+ ];
2435
+ }
2436
+ };
2437
+ var tt = (n, { windowsPathsNoEscape: t = !1, magicalBraces: e = !1 } = {}) => e ? t ? n.replace(/[?*()[\]{}]/g, "[$&]") : n.replace(/[?*()[\]\\{}]/g, "\\$&") : t ? n.replace(/[?*()[\]]/g, "[$&]") : n.replace(/[?*()[\]\\]/g, "\\$&");
2438
+ var O = (n, t, e = {}) => (at(t), !e.nocomment && t.charAt(0) === "#" ? !1 : new D(t, e).match(n));
2439
+ var Rs = /^\*+([^+@!?\*\[\(]*)$/;
2440
+ var Os = (n) => (t) => !t.startsWith(".") && t.endsWith(n);
2441
+ var Fs = (n) => (t) => t.endsWith(n);
2442
+ var Ds = (n) => (n = n.toLowerCase(), (t) => !t.startsWith(".") && t.toLowerCase().endsWith(n));
2443
+ var Ms = (n) => (n = n.toLowerCase(), (t) => t.toLowerCase().endsWith(n));
2444
+ var Ns = /^\*+\.\*+$/;
2445
+ var _s = (n) => !n.startsWith(".") && n.includes(".");
2446
+ var Ls = (n) => n !== "." && n !== ".." && n.includes(".");
2447
+ var Ws = /^\.\*+$/;
2448
+ var Ps = (n) => n !== "." && n !== ".." && n.startsWith(".");
2449
+ var js = /^\*+$/;
2450
+ var Is = (n) => n.length !== 0 && !n.startsWith(".");
2451
+ var zs = (n) => n.length !== 0 && n !== "." && n !== "..";
2452
+ var Bs = /^\?+([^+@!?\*\[\(]*)?$/;
2453
+ var Us = ([n, t = ""]) => {
2454
+ let e = Ce([n]);
2455
+ return t ? (t = t.toLowerCase(), (s) => e(s) && s.toLowerCase().endsWith(t)) : e;
2456
+ };
2457
+ var $s = ([n, t = ""]) => {
2458
+ let e = Te([n]);
2459
+ return t ? (t = t.toLowerCase(), (s) => e(s) && s.toLowerCase().endsWith(t)) : e;
2460
+ };
2461
+ var Gs = ([n, t = ""]) => {
2462
+ let e = Te([n]);
2463
+ return t ? (s) => e(s) && s.endsWith(t) : e;
2464
+ };
2465
+ var Hs = ([n, t = ""]) => {
2466
+ let e = Ce([n]);
2467
+ return t ? (s) => e(s) && s.endsWith(t) : e;
2468
+ };
2469
+ var Ce = ([n]) => {
2470
+ let t = n.length;
2471
+ return (e) => e.length === t && !e.startsWith(".");
2472
+ };
2473
+ var Te = ([n]) => {
2474
+ let t = n.length;
2475
+ return (e) => e.length === t && e !== "." && e !== "..";
2476
+ };
2477
+ var Ae = typeof process == "object" && process ? typeof process.env == "object" && process.env && process.env.__MINIMATCH_TESTING_PLATFORM__ || process.platform : "posix";
2478
+ var xe = {
2479
+ win32: { sep: "\\" },
2480
+ posix: { sep: "/" }
2481
+ };
2482
+ O.sep = Ae === "win32" ? xe.win32.sep : xe.posix.sep;
2483
+ var A = Symbol("globstar **");
2484
+ O.GLOBSTAR = A;
2485
+ var Vs = "[^/]*?";
2486
+ var Ys = "(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?";
2487
+ var Xs = "(?:(?!(?:\\/|^)\\.).)*?";
2488
+ var Js = (n, t = {}) => (e) => O(e, n, t);
2489
+ O.filter = Js;
2490
+ var N = (n, t = {}) => Object.assign({}, n, t);
2491
+ var Zs = (n) => {
2492
+ if (!n || typeof n != "object" || !Object.keys(n).length) return O;
2493
+ let t = O;
2494
+ return Object.assign((s, i, r = {}) => t(s, i, N(n, r)), {
2495
+ Minimatch: class extends t.Minimatch {
2496
+ constructor(i, r = {}) {
2497
+ super(i, N(n, r));
2498
+ }
2499
+ static defaults(i) {
2500
+ return t.defaults(N(n, i)).Minimatch;
2501
+ }
2502
+ },
2503
+ AST: class extends t.AST {
2504
+ constructor(i, r, o = {}) {
2505
+ super(i, r, N(n, o));
2506
+ }
2507
+ static fromGlob(i, r = {}) {
2508
+ return t.AST.fromGlob(i, N(n, r));
2509
+ }
2510
+ },
2511
+ unescape: (s, i = {}) => t.unescape(s, N(n, i)),
2512
+ escape: (s, i = {}) => t.escape(s, N(n, i)),
2513
+ filter: (s, i = {}) => t.filter(s, N(n, i)),
2514
+ defaults: (s) => t.defaults(N(n, s)),
2515
+ makeRe: (s, i = {}) => t.makeRe(s, N(n, i)),
2516
+ braceExpand: (s, i = {}) => t.braceExpand(s, N(n, i)),
2517
+ match: (s, i, r = {}) => t.match(s, i, N(n, r)),
2518
+ sep: t.sep,
2519
+ GLOBSTAR: A
2520
+ });
2521
+ };
2522
+ O.defaults = Zs;
2523
+ var ke = (n, t = {}) => (at(n), t.nobrace || !/\{(?:(?!\{).)*\}/.test(n) ? [n] : ge(n, { max: t.braceExpandMax }));
2524
+ O.braceExpand = ke;
2525
+ var Qs = (n, t = {}) => new D(n, t).makeRe();
2526
+ O.makeRe = Qs;
2527
+ var ti = (n, t, e = {}) => {
2528
+ let s = new D(t, e);
2529
+ return n = n.filter((i) => s.match(i)), s.options.nonull && !n.length && n.push(t), n;
2530
+ };
2531
+ O.match = ti;
2532
+ var ve = /[?*]|[+@!]\(.*?\)|\[|\]/;
2533
+ var ei = (n) => n.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
2534
+ var D = class {
2535
+ options;
2536
+ set;
2537
+ pattern;
2538
+ windowsPathsNoEscape;
2539
+ nonegate;
2540
+ negate;
2541
+ comment;
2542
+ empty;
2543
+ preserveMultipleSlashes;
2544
+ partial;
2545
+ globSet;
2546
+ globParts;
2547
+ nocase;
2548
+ isWindows;
2549
+ platform;
2550
+ windowsNoMagicRoot;
2551
+ regexp;
2552
+ constructor(t, e = {}) {
2553
+ at(t), e = e || {}, this.options = e, this.pattern = t, this.platform = e.platform || Ae, this.isWindows = this.platform === "win32";
2554
+ let s = "allowWindowsEscape";
2555
+ this.windowsPathsNoEscape = !!e.windowsPathsNoEscape || e[s] === !1, this.windowsPathsNoEscape && (this.pattern = this.pattern.replace(/\\/g, "/")), this.preserveMultipleSlashes = !!e.preserveMultipleSlashes, this.regexp = null, this.negate = !1, this.nonegate = !!e.nonegate, this.comment = !1, this.empty = !1, this.partial = !!e.partial, this.nocase = !!this.options.nocase, this.windowsNoMagicRoot = e.windowsNoMagicRoot !== void 0 ? e.windowsNoMagicRoot : !!(this.isWindows && this.nocase), this.globSet = [], this.globParts = [], this.set = [], this.make();
2556
+ }
2557
+ hasMagic() {
2558
+ if (this.options.magicalBraces && this.set.length > 1) return !0;
2559
+ for (let t of this.set) for (let e of t) if (typeof e != "string") return !0;
2560
+ return !1;
2561
+ }
2562
+ debug(...t) {}
2563
+ make() {
2564
+ let t = this.pattern, e = this.options;
2565
+ if (!e.nocomment && t.charAt(0) === "#") {
2566
+ this.comment = !0;
2567
+ return;
2568
+ }
2569
+ if (!t) {
2570
+ this.empty = !0;
2571
+ return;
2572
+ }
2573
+ this.parseNegate(), this.globSet = [...new Set(this.braceExpand())], e.debug && (this.debug = (...r) => console.error(...r)), this.debug(this.pattern, this.globSet);
2574
+ let s = this.globSet.map((r) => this.slashSplit(r));
2575
+ this.globParts = this.preprocess(s), this.debug(this.pattern, this.globParts);
2576
+ let i = this.globParts.map((r, o, h) => {
2577
+ if (this.isWindows && this.windowsNoMagicRoot) {
2578
+ let a = r[0] === "" && r[1] === "" && (r[2] === "?" || !ve.test(r[2])) && !ve.test(r[3]), l = /^[a-z]:/i.test(r[0]);
2579
+ if (a) return [...r.slice(0, 4), ...r.slice(4).map((u) => this.parse(u))];
2580
+ if (l) return [r[0], ...r.slice(1).map((u) => this.parse(u))];
2581
+ }
2582
+ return r.map((a) => this.parse(a));
2583
+ });
2584
+ if (this.debug(this.pattern, i), this.set = i.filter((r) => r.indexOf(!1) === -1), this.isWindows) for (let r = 0; r < this.set.length; r++) {
2585
+ let o = this.set[r];
2586
+ o[0] === "" && o[1] === "" && this.globParts[r][2] === "?" && typeof o[3] == "string" && /^[a-z]:$/i.test(o[3]) && (o[2] = "?");
2587
+ }
2588
+ this.debug(this.pattern, this.set);
2589
+ }
2590
+ preprocess(t) {
2591
+ if (this.options.noglobstar) for (let s = 0; s < t.length; s++) for (let i = 0; i < t[s].length; i++) t[s][i] === "**" && (t[s][i] = "*");
2592
+ let { optimizationLevel: e = 1 } = this.options;
2593
+ return e >= 2 ? (t = this.firstPhasePreProcess(t), t = this.secondPhasePreProcess(t)) : e >= 1 ? t = this.levelOneOptimize(t) : t = this.adjascentGlobstarOptimize(t), t;
2594
+ }
2595
+ adjascentGlobstarOptimize(t) {
2596
+ return t.map((e) => {
2597
+ let s = -1;
2598
+ for (; (s = e.indexOf("**", s + 1)) !== -1;) {
2599
+ let i = s;
2600
+ for (; e[i + 1] === "**";) i++;
2601
+ i !== s && e.splice(s, i - s);
2602
+ }
2603
+ return e;
2604
+ });
2605
+ }
2606
+ levelOneOptimize(t) {
2607
+ return t.map((e) => (e = e.reduce((s, i) => {
2608
+ let r = s[s.length - 1];
2609
+ return i === "**" && r === "**" ? s : i === ".." && r && r !== ".." && r !== "." && r !== "**" ? (s.pop(), s) : (s.push(i), s);
2610
+ }, []), e.length === 0 ? [""] : e));
2611
+ }
2612
+ levelTwoFileOptimize(t) {
2613
+ Array.isArray(t) || (t = this.slashSplit(t));
2614
+ let e = !1;
2615
+ do {
2616
+ if (e = !1, !this.preserveMultipleSlashes) {
2617
+ for (let i = 1; i < t.length - 1; i++) {
2618
+ let r = t[i];
2619
+ i === 1 && r === "" && t[0] === "" || (r === "." || r === "") && (e = !0, t.splice(i, 1), i--);
2620
+ }
2621
+ t[0] === "." && t.length === 2 && (t[1] === "." || t[1] === "") && (e = !0, t.pop());
2622
+ }
2623
+ let s = 0;
2624
+ for (; (s = t.indexOf("..", s + 1)) !== -1;) {
2625
+ let i = t[s - 1];
2626
+ i && i !== "." && i !== ".." && i !== "**" && (e = !0, t.splice(s - 1, 2), s -= 2);
2627
+ }
2628
+ } while (e);
2629
+ return t.length === 0 ? [""] : t;
2630
+ }
2631
+ firstPhasePreProcess(t) {
2632
+ let e = !1;
2633
+ do {
2634
+ e = !1;
2635
+ for (let s of t) {
2636
+ let i = -1;
2637
+ for (; (i = s.indexOf("**", i + 1)) !== -1;) {
2638
+ let o = i;
2639
+ for (; s[o + 1] === "**";) o++;
2640
+ o > i && s.splice(i + 1, o - i);
2641
+ let h = s[i + 1], a = s[i + 2], l = s[i + 3];
2642
+ if (h !== ".." || !a || a === "." || a === ".." || !l || l === "." || l === "..") continue;
2643
+ e = !0, s.splice(i, 1);
2644
+ let u = s.slice(0);
2645
+ u[i] = "**", t.push(u), i--;
2646
+ }
2647
+ if (!this.preserveMultipleSlashes) {
2648
+ for (let o = 1; o < s.length - 1; o++) {
2649
+ let h = s[o];
2650
+ o === 1 && h === "" && s[0] === "" || (h === "." || h === "") && (e = !0, s.splice(o, 1), o--);
2651
+ }
2652
+ s[0] === "." && s.length === 2 && (s[1] === "." || s[1] === "") && (e = !0, s.pop());
2653
+ }
2654
+ let r = 0;
2655
+ for (; (r = s.indexOf("..", r + 1)) !== -1;) {
2656
+ let o = s[r - 1];
2657
+ if (o && o !== "." && o !== ".." && o !== "**") {
2658
+ e = !0;
2659
+ let a = r === 1 && s[r + 1] === "**" ? ["."] : [];
2660
+ s.splice(r - 1, 2, ...a), s.length === 0 && s.push(""), r -= 2;
2661
+ }
2662
+ }
2663
+ }
2664
+ } while (e);
2665
+ return t;
2666
+ }
2667
+ secondPhasePreProcess(t) {
2668
+ for (let e = 0; e < t.length - 1; e++) for (let s = e + 1; s < t.length; s++) {
2669
+ let i = this.partsMatch(t[e], t[s], !this.preserveMultipleSlashes);
2670
+ if (i) {
2671
+ t[e] = [], t[s] = i;
2672
+ break;
2673
+ }
2674
+ }
2675
+ return t.filter((e) => e.length);
2676
+ }
2677
+ partsMatch(t, e, s = !1) {
2678
+ let i = 0, r = 0, o = [], h = "";
2679
+ for (; i < t.length && r < e.length;) if (t[i] === e[r]) o.push(h === "b" ? e[r] : t[i]), i++, r++;
2680
+ else if (s && t[i] === "**" && e[r] === t[i + 1]) o.push(t[i]), i++;
2681
+ else if (s && e[r] === "**" && t[i] === e[r + 1]) o.push(e[r]), r++;
2682
+ else if (t[i] === "*" && e[r] && (this.options.dot || !e[r].startsWith(".")) && e[r] !== "**") {
2683
+ if (h === "b") return !1;
2684
+ h = "a", o.push(t[i]), i++, r++;
2685
+ } else if (e[r] === "*" && t[i] && (this.options.dot || !t[i].startsWith(".")) && t[i] !== "**") {
2686
+ if (h === "a") return !1;
2687
+ h = "b", o.push(e[r]), i++, r++;
2688
+ } else return !1;
2689
+ return t.length === e.length && o;
2690
+ }
2691
+ parseNegate() {
2692
+ if (this.nonegate) return;
2693
+ let t = this.pattern, e = !1, s = 0;
2694
+ for (let i = 0; i < t.length && t.charAt(i) === "!"; i++) e = !e, s++;
2695
+ s && (this.pattern = t.slice(s)), this.negate = e;
2696
+ }
2697
+ matchOne(t, e, s = !1) {
2698
+ let i = this.options;
2699
+ if (this.isWindows) {
2700
+ let p = typeof t[0] == "string" && /^[a-z]:$/i.test(t[0]), w = !p && t[0] === "" && t[1] === "" && t[2] === "?" && /^[a-z]:$/i.test(t[3]), g = typeof e[0] == "string" && /^[a-z]:$/i.test(e[0]), S = !g && e[0] === "" && e[1] === "" && e[2] === "?" && typeof e[3] == "string" && /^[a-z]:$/i.test(e[3]), E = w ? 3 : p ? 0 : void 0, y = S ? 3 : g ? 0 : void 0;
2701
+ if (typeof E == "number" && typeof y == "number") {
2702
+ let [b, z] = [t[E], e[y]];
2703
+ b.toLowerCase() === z.toLowerCase() && (e[y] = b, y > E ? e = e.slice(y) : E > y && (t = t.slice(E)));
2704
+ }
2705
+ }
2706
+ let { optimizationLevel: r = 1 } = this.options;
2707
+ r >= 2 && (t = this.levelTwoFileOptimize(t)), this.debug("matchOne", this, {
2708
+ file: t,
2709
+ pattern: e
2710
+ }), this.debug("matchOne", t.length, e.length);
2711
+ for (var o = 0, h = 0, a = t.length, l = e.length; o < a && h < l; o++, h++) {
2712
+ this.debug("matchOne loop");
2713
+ var u = e[h], c = t[o];
2714
+ if (this.debug(e, u, c), u === !1) return !1;
2715
+ if (u === A) {
2716
+ this.debug("GLOBSTAR", [
2717
+ e,
2718
+ u,
2719
+ c
2720
+ ]);
2721
+ var d = o, f = h + 1;
2722
+ if (f === l) {
2723
+ for (this.debug("** at the end"); o < a; o++) if (t[o] === "." || t[o] === ".." || !i.dot && t[o].charAt(0) === ".") return !1;
2724
+ return !0;
2725
+ }
2726
+ for (; d < a;) {
2727
+ var m = t[d];
2728
+ if (this.debug(`
2729
+ globstar while`, t, d, e, f, m), this.matchOne(t.slice(d), e.slice(f), s)) return this.debug("globstar found match!", d, a, m), !0;
2730
+ if (m === "." || m === ".." || !i.dot && m.charAt(0) === ".") {
2731
+ this.debug("dot detected!", t, d, e, f);
2732
+ break;
2733
+ }
2734
+ this.debug("globstar swallow a segment, and continue"), d++;
2735
+ }
2736
+ return !!(s && (this.debug(`
2737
+ >>> no match, partial?`, t, d, e, f), d === a));
2738
+ }
2739
+ let p;
2740
+ if (typeof u == "string" ? (p = c === u, this.debug("string match", u, c, p)) : (p = u.test(c), this.debug("pattern match", u, c, p)), !p) return !1;
2741
+ }
2742
+ if (o === a && h === l) return !0;
2743
+ if (o === a) return s;
2744
+ if (h === l) return o === a - 1 && t[o] === "";
2745
+ throw new Error("wtf?");
2746
+ }
2747
+ braceExpand() {
2748
+ return ke(this.pattern, this.options);
2749
+ }
2750
+ parse(t) {
2751
+ at(t);
2752
+ let e = this.options;
2753
+ if (t === "**") return A;
2754
+ if (t === "") return "";
2755
+ let s, i = null;
2756
+ (s = t.match(js)) ? i = e.dot ? zs : Is : (s = t.match(Rs)) ? i = (e.nocase ? e.dot ? Ms : Ds : e.dot ? Fs : Os)(s[1]) : (s = t.match(Bs)) ? i = (e.nocase ? e.dot ? $s : Us : e.dot ? Gs : Hs)(s) : (s = t.match(Ns)) ? i = e.dot ? Ls : _s : (s = t.match(Ws)) && (i = Ps);
2757
+ let r = Q.fromGlob(t, this.options).toMMPattern();
2758
+ return i && typeof r == "object" && Reflect.defineProperty(r, "test", { value: i }), r;
2759
+ }
2760
+ makeRe() {
2761
+ if (this.regexp || this.regexp === !1) return this.regexp;
2762
+ let t = this.set;
2763
+ if (!t.length) return this.regexp = !1, this.regexp;
2764
+ let e = this.options, s = e.noglobstar ? Vs : e.dot ? Ys : Xs, i = new Set(e.nocase ? ["i"] : []), r = t.map((a) => {
2765
+ let l = a.map((c) => {
2766
+ if (c instanceof RegExp) for (let d of c.flags.split("")) i.add(d);
2767
+ return typeof c == "string" ? ei(c) : c === A ? A : c._src;
2768
+ });
2769
+ l.forEach((c, d) => {
2770
+ let f = l[d + 1], m = l[d - 1];
2771
+ c !== A || m === A || (m === void 0 ? f !== void 0 && f !== A ? l[d + 1] = "(?:\\/|" + s + "\\/)?" + f : l[d] = s : f === void 0 ? l[d - 1] = m + "(?:\\/|\\/" + s + ")?" : f !== A && (l[d - 1] = m + "(?:\\/|\\/" + s + "\\/)" + f, l[d + 1] = A));
2772
+ });
2773
+ let u = l.filter((c) => c !== A);
2774
+ if (this.partial && u.length >= 1) {
2775
+ let c = [];
2776
+ for (let d = 1; d <= u.length; d++) c.push(u.slice(0, d).join("/"));
2777
+ return "(?:" + c.join("|") + ")";
2778
+ }
2779
+ return u.join("/");
2780
+ }).join("|"), [o, h] = t.length > 1 ? ["(?:", ")"] : ["", ""];
2781
+ r = "^" + o + r + h + "$", this.partial && (r = "^(?:\\/|" + o + r.slice(1, -1) + h + ")$"), this.negate && (r = "^(?!" + r + ").+$");
2782
+ try {
2783
+ this.regexp = new RegExp(r, [...i].join(""));
2784
+ } catch {
2785
+ this.regexp = !1;
2786
+ }
2787
+ return this.regexp;
2788
+ }
2789
+ slashSplit(t) {
2790
+ return this.preserveMultipleSlashes ? t.split("/") : this.isWindows && /^\/\/[^\/]+/.test(t) ? ["", ...t.split(/\/+/)] : t.split(/\/+/);
2791
+ }
2792
+ match(t, e = this.partial) {
2793
+ if (this.debug("match", t, this.pattern), this.comment) return !1;
2794
+ if (this.empty) return t === "";
2795
+ if (t === "/" && e) return !0;
2796
+ let s = this.options;
2797
+ this.isWindows && (t = t.split("\\").join("/"));
2798
+ let i = this.slashSplit(t);
2799
+ this.debug(this.pattern, "split", i);
2800
+ let r = this.set;
2801
+ this.debug(this.pattern, "set", r);
2802
+ let o = i[i.length - 1];
2803
+ if (!o) for (let h = i.length - 2; !o && h >= 0; h--) o = i[h];
2804
+ for (let h = 0; h < r.length; h++) {
2805
+ let a = r[h], l = i;
2806
+ if (s.matchBase && a.length === 1 && (l = [o]), this.matchOne(l, a, e)) return s.flipNegate ? !0 : !this.negate;
2807
+ }
2808
+ return s.flipNegate ? !1 : this.negate;
2809
+ }
2810
+ static defaults(t) {
2811
+ return O.defaults(t).Minimatch;
2812
+ }
2813
+ };
2814
+ O.AST = Q;
2815
+ O.Minimatch = D;
2816
+ O.escape = tt;
2817
+ O.unescape = W;
2818
+ var si = typeof performance == "object" && performance && typeof performance.now == "function" ? performance : Date;
2819
+ var Oe = /* @__PURE__ */ new Set();
2820
+ var Vt = typeof process == "object" && process ? process : {};
2821
+ var Fe = (n, t, e, s) => {
2822
+ typeof Vt.emitWarning == "function" ? Vt.emitWarning(n, t, e, s) : console.error(`[${e}] ${t}: ${n}`);
2823
+ };
2824
+ var At = globalThis.AbortController;
2825
+ var Re = globalThis.AbortSignal;
2826
+ if (typeof At > "u") {
2827
+ Re = class {
2828
+ onabort;
2829
+ _onabort = [];
2830
+ reason;
2831
+ aborted = !1;
2832
+ addEventListener(e, s) {
2833
+ this._onabort.push(s);
2834
+ }
2835
+ }, At = class {
2836
+ constructor() {
2837
+ t();
2838
+ }
2839
+ signal = new Re();
2840
+ abort(e) {
2841
+ if (!this.signal.aborted) {
2842
+ this.signal.reason = e, this.signal.aborted = !0;
2843
+ for (let s of this.signal._onabort) s(e);
2844
+ this.signal.onabort?.(e);
2845
+ }
2846
+ }
2847
+ };
2848
+ let n = Vt.env?.LRU_CACHE_IGNORE_AC_WARNING !== "1", t = () => {
2849
+ n && (n = !1, Fe("AbortController is not defined. If using lru-cache in node 14, load an AbortController polyfill from the `node-abort-controller` package. A minimal polyfill is provided for use by LRUCache.fetch(), but it should not be relied upon in other contexts (eg, passing it to other APIs that use AbortController/AbortSignal might have undesirable effects). You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.", "NO_ABORT_CONTROLLER", "ENOTSUP", t));
2850
+ };
2851
+ }
2852
+ var ii = (n) => !Oe.has(n);
2853
+ var q = (n) => n && n === Math.floor(n) && n > 0 && isFinite(n);
2854
+ var De = (n) => q(n) ? n <= Math.pow(2, 8) ? Uint8Array : n <= Math.pow(2, 16) ? Uint16Array : n <= Math.pow(2, 32) ? Uint32Array : n <= Number.MAX_SAFE_INTEGER ? Tt : null : null;
2855
+ var Tt = class extends Array {
2856
+ constructor(n) {
2857
+ super(n), this.fill(0);
2858
+ }
2859
+ };
2860
+ var ri = class ct {
2861
+ heap;
2862
+ length;
2863
+ static #t = !1;
2864
+ static create(t) {
2865
+ let e = De(t);
2866
+ if (!e) return [];
2867
+ ct.#t = !0;
2868
+ let s = new ct(t, e);
2869
+ return ct.#t = !1, s;
2870
+ }
2871
+ constructor(t, e) {
2872
+ if (!ct.#t) throw new TypeError("instantiate Stack using Stack.create(n)");
2873
+ this.heap = new e(t), this.length = 0;
2874
+ }
2875
+ push(t) {
2876
+ this.heap[this.length++] = t;
2877
+ }
2878
+ pop() {
2879
+ return this.heap[--this.length];
2880
+ }
2881
+ };
2882
+ var ft = class Me {
2883
+ #t;
2884
+ #s;
2885
+ #n;
2886
+ #r;
2887
+ #o;
2888
+ #S;
2889
+ #w;
2890
+ #c;
2891
+ get perf() {
2892
+ return this.#c;
2893
+ }
2894
+ ttl;
2895
+ ttlResolution;
2896
+ ttlAutopurge;
2897
+ updateAgeOnGet;
2898
+ updateAgeOnHas;
2899
+ allowStale;
2900
+ noDisposeOnSet;
2901
+ noUpdateTTL;
2902
+ maxEntrySize;
2903
+ sizeCalculation;
2904
+ noDeleteOnFetchRejection;
2905
+ noDeleteOnStaleGet;
2906
+ allowStaleOnFetchAbort;
2907
+ allowStaleOnFetchRejection;
2908
+ ignoreFetchAbort;
2909
+ #h;
2910
+ #u;
2911
+ #f;
2912
+ #a;
2913
+ #i;
2914
+ #d;
2915
+ #E;
2916
+ #b;
2917
+ #p;
2918
+ #R;
2919
+ #m;
2920
+ #C;
2921
+ #T;
2922
+ #g;
2923
+ #y;
2924
+ #x;
2925
+ #A;
2926
+ #e;
2927
+ #_;
2928
+ static unsafeExposeInternals(t) {
2929
+ return {
2930
+ starts: t.#T,
2931
+ ttls: t.#g,
2932
+ autopurgeTimers: t.#y,
2933
+ sizes: t.#C,
2934
+ keyMap: t.#f,
2935
+ keyList: t.#a,
2936
+ valList: t.#i,
2937
+ next: t.#d,
2938
+ prev: t.#E,
2939
+ get head() {
2940
+ return t.#b;
2941
+ },
2942
+ get tail() {
2943
+ return t.#p;
2944
+ },
2945
+ free: t.#R,
2946
+ isBackgroundFetch: (e) => t.#l(e),
2947
+ backgroundFetch: (e, s, i, r) => t.#U(e, s, i, r),
2948
+ moveToTail: (e) => t.#W(e),
2949
+ indexes: (e) => t.#F(e),
2950
+ rindexes: (e) => t.#D(e),
2951
+ isStale: (e) => t.#v(e)
2952
+ };
2953
+ }
2954
+ get max() {
2955
+ return this.#t;
2956
+ }
2957
+ get maxSize() {
2958
+ return this.#s;
2959
+ }
2960
+ get calculatedSize() {
2961
+ return this.#u;
2962
+ }
2963
+ get size() {
2964
+ return this.#h;
2965
+ }
2966
+ get fetchMethod() {
2967
+ return this.#S;
2968
+ }
2969
+ get memoMethod() {
2970
+ return this.#w;
2971
+ }
2972
+ get dispose() {
2973
+ return this.#n;
2974
+ }
2975
+ get onInsert() {
2976
+ return this.#r;
2977
+ }
2978
+ get disposeAfter() {
2979
+ return this.#o;
2980
+ }
2981
+ constructor(t) {
2982
+ let { max: e = 0, ttl: s, ttlResolution: i = 1, ttlAutopurge: r, updateAgeOnGet: o, updateAgeOnHas: h, allowStale: a, dispose: l, onInsert: u, disposeAfter: c, noDisposeOnSet: d, noUpdateTTL: f, maxSize: m = 0, maxEntrySize: p = 0, sizeCalculation: w, fetchMethod: g, memoMethod: S, noDeleteOnFetchRejection: E, noDeleteOnStaleGet: y, allowStaleOnFetchRejection: b, allowStaleOnFetchAbort: z, ignoreFetchAbort: $, perf: J } = t;
2983
+ if (J !== void 0 && typeof J?.now != "function") throw new TypeError("perf option must have a now() method if specified");
2984
+ if (this.#c = J ?? si, e !== 0 && !q(e)) throw new TypeError("max option must be a nonnegative integer");
2985
+ let Z = e ? De(e) : Array;
2986
+ if (!Z) throw new Error("invalid max value: " + e);
2987
+ if (this.#t = e, this.#s = m, this.maxEntrySize = p || this.#s, this.sizeCalculation = w, this.sizeCalculation) {
2988
+ if (!this.#s && !this.maxEntrySize) throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");
2989
+ if (typeof this.sizeCalculation != "function") throw new TypeError("sizeCalculation set to non-function");
2990
+ }
2991
+ if (S !== void 0 && typeof S != "function") throw new TypeError("memoMethod must be a function if defined");
2992
+ if (this.#w = S, g !== void 0 && typeof g != "function") throw new TypeError("fetchMethod must be a function if specified");
2993
+ if (this.#S = g, this.#A = !!g, this.#f = /* @__PURE__ */ new Map(), this.#a = new Array(e).fill(void 0), this.#i = new Array(e).fill(void 0), this.#d = new Z(e), this.#E = new Z(e), this.#b = 0, this.#p = 0, this.#R = ri.create(e), this.#h = 0, this.#u = 0, typeof l == "function" && (this.#n = l), typeof u == "function" && (this.#r = u), typeof c == "function" ? (this.#o = c, this.#m = []) : (this.#o = void 0, this.#m = void 0), this.#x = !!this.#n, this.#_ = !!this.#r, this.#e = !!this.#o, this.noDisposeOnSet = !!d, this.noUpdateTTL = !!f, this.noDeleteOnFetchRejection = !!E, this.allowStaleOnFetchRejection = !!b, this.allowStaleOnFetchAbort = !!z, this.ignoreFetchAbort = !!$, this.maxEntrySize !== 0) {
2994
+ if (this.#s !== 0 && !q(this.#s)) throw new TypeError("maxSize must be a positive integer if specified");
2995
+ if (!q(this.maxEntrySize)) throw new TypeError("maxEntrySize must be a positive integer if specified");
2996
+ this.#G();
2997
+ }
2998
+ if (this.allowStale = !!a, this.noDeleteOnStaleGet = !!y, this.updateAgeOnGet = !!o, this.updateAgeOnHas = !!h, this.ttlResolution = q(i) || i === 0 ? i : 1, this.ttlAutopurge = !!r, this.ttl = s || 0, this.ttl) {
2999
+ if (!q(this.ttl)) throw new TypeError("ttl must be a positive integer if specified");
3000
+ this.#M();
3001
+ }
3002
+ if (this.#t === 0 && this.ttl === 0 && this.#s === 0) throw new TypeError("At least one of max, maxSize, or ttl is required");
3003
+ if (!this.ttlAutopurge && !this.#t && !this.#s) {
3004
+ let $t = "LRU_CACHE_UNBOUNDED";
3005
+ ii($t) && (Oe.add($t), Fe("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.", "UnboundedCacheWarning", $t, Me));
3006
+ }
3007
+ }
3008
+ getRemainingTTL(t) {
3009
+ return this.#f.has(t) ? 1 / 0 : 0;
3010
+ }
3011
+ #M() {
3012
+ let t = new Tt(this.#t), e = new Tt(this.#t);
3013
+ this.#g = t, this.#T = e;
3014
+ let s = this.ttlAutopurge ? new Array(this.#t) : void 0;
3015
+ this.#y = s, this.#j = (o, h, a = this.#c.now()) => {
3016
+ if (e[o] = h !== 0 ? a : 0, t[o] = h, s?.[o] && (clearTimeout(s[o]), s[o] = void 0), h !== 0 && s) {
3017
+ let l = setTimeout(() => {
3018
+ this.#v(o) && this.#O(this.#a[o], "expire");
3019
+ }, h + 1);
3020
+ l.unref && l.unref(), s[o] = l;
3021
+ }
3022
+ }, this.#k = (o) => {
3023
+ e[o] = t[o] !== 0 ? this.#c.now() : 0;
3024
+ }, this.#N = (o, h) => {
3025
+ if (t[h]) {
3026
+ let a = t[h], l = e[h];
3027
+ if (!a || !l) return;
3028
+ o.ttl = a, o.start = l, o.now = i || r();
3029
+ o.remainingTTL = a - (o.now - l);
3030
+ }
3031
+ };
3032
+ let i = 0, r = () => {
3033
+ let o = this.#c.now();
3034
+ if (this.ttlResolution > 0) {
3035
+ i = o;
3036
+ let h = setTimeout(() => i = 0, this.ttlResolution);
3037
+ h.unref && h.unref();
3038
+ }
3039
+ return o;
3040
+ };
3041
+ this.getRemainingTTL = (o) => {
3042
+ let h = this.#f.get(o);
3043
+ if (h === void 0) return 0;
3044
+ let a = t[h], l = e[h];
3045
+ if (!a || !l) return 1 / 0;
3046
+ return a - ((i || r()) - l);
3047
+ }, this.#v = (o) => {
3048
+ let h = e[o], a = t[o];
3049
+ return !!a && !!h && (i || r()) - h > a;
3050
+ };
3051
+ }
3052
+ #k = () => {};
3053
+ #N = () => {};
3054
+ #j = () => {};
3055
+ #v = () => !1;
3056
+ #G() {
3057
+ let t = new Tt(this.#t);
3058
+ this.#u = 0, this.#C = t, this.#P = (e) => {
3059
+ this.#u -= t[e], t[e] = 0;
3060
+ }, this.#I = (e, s, i, r) => {
3061
+ if (this.#l(s)) return 0;
3062
+ if (!q(i)) if (r) {
3063
+ if (typeof r != "function") throw new TypeError("sizeCalculation must be a function");
3064
+ if (i = r(s, e), !q(i)) throw new TypeError("sizeCalculation return invalid (expect positive integer)");
3065
+ } else throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");
3066
+ return i;
3067
+ }, this.#L = (e, s, i) => {
3068
+ if (t[e] = s, this.#s) {
3069
+ let r = this.#s - t[e];
3070
+ for (; this.#u > r;) this.#B(!0);
3071
+ }
3072
+ this.#u += t[e], i && (i.entrySize = s, i.totalCalculatedSize = this.#u);
3073
+ };
3074
+ }
3075
+ #P = (t) => {};
3076
+ #L = (t, e, s) => {};
3077
+ #I = (t, e, s, i) => {
3078
+ if (s || i) throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");
3079
+ return 0;
3080
+ };
3081
+ *#F({ allowStale: t = this.allowStale } = {}) {
3082
+ if (this.#h) for (let e = this.#p; !(!this.#z(e) || ((t || !this.#v(e)) && (yield e), e === this.#b));) e = this.#E[e];
3083
+ }
3084
+ *#D({ allowStale: t = this.allowStale } = {}) {
3085
+ if (this.#h) for (let e = this.#b; !(!this.#z(e) || ((t || !this.#v(e)) && (yield e), e === this.#p));) e = this.#d[e];
3086
+ }
3087
+ #z(t) {
3088
+ return t !== void 0 && this.#f.get(this.#a[t]) === t;
3089
+ }
3090
+ *entries() {
3091
+ for (let t of this.#F()) this.#i[t] !== void 0 && this.#a[t] !== void 0 && !this.#l(this.#i[t]) && (yield [this.#a[t], this.#i[t]]);
3092
+ }
3093
+ *rentries() {
3094
+ for (let t of this.#D()) this.#i[t] !== void 0 && this.#a[t] !== void 0 && !this.#l(this.#i[t]) && (yield [this.#a[t], this.#i[t]]);
3095
+ }
3096
+ *keys() {
3097
+ for (let t of this.#F()) {
3098
+ let e = this.#a[t];
3099
+ e !== void 0 && !this.#l(this.#i[t]) && (yield e);
3100
+ }
3101
+ }
3102
+ *rkeys() {
3103
+ for (let t of this.#D()) {
3104
+ let e = this.#a[t];
3105
+ e !== void 0 && !this.#l(this.#i[t]) && (yield e);
3106
+ }
3107
+ }
3108
+ *values() {
3109
+ for (let t of this.#F()) this.#i[t] !== void 0 && !this.#l(this.#i[t]) && (yield this.#i[t]);
3110
+ }
3111
+ *rvalues() {
3112
+ for (let t of this.#D()) this.#i[t] !== void 0 && !this.#l(this.#i[t]) && (yield this.#i[t]);
3113
+ }
3114
+ [Symbol.iterator]() {
3115
+ return this.entries();
3116
+ }
3117
+ [Symbol.toStringTag] = "LRUCache";
3118
+ find(t, e = {}) {
3119
+ for (let s of this.#F()) {
3120
+ let i = this.#i[s], r = this.#l(i) ? i.__staleWhileFetching : i;
3121
+ if (r !== void 0 && t(r, this.#a[s], this)) return this.get(this.#a[s], e);
3122
+ }
3123
+ }
3124
+ forEach(t, e = this) {
3125
+ for (let s of this.#F()) {
3126
+ let i = this.#i[s], r = this.#l(i) ? i.__staleWhileFetching : i;
3127
+ r !== void 0 && t.call(e, r, this.#a[s], this);
3128
+ }
3129
+ }
3130
+ rforEach(t, e = this) {
3131
+ for (let s of this.#D()) {
3132
+ let i = this.#i[s], r = this.#l(i) ? i.__staleWhileFetching : i;
3133
+ r !== void 0 && t.call(e, r, this.#a[s], this);
3134
+ }
3135
+ }
3136
+ purgeStale() {
3137
+ let t = !1;
3138
+ for (let e of this.#D({ allowStale: !0 })) this.#v(e) && (this.#O(this.#a[e], "expire"), t = !0);
3139
+ return t;
3140
+ }
3141
+ info(t) {
3142
+ let e = this.#f.get(t);
3143
+ if (e === void 0) return;
3144
+ let s = this.#i[e], i = this.#l(s) ? s.__staleWhileFetching : s;
3145
+ if (i === void 0) return;
3146
+ let r = { value: i };
3147
+ if (this.#g && this.#T) {
3148
+ let o = this.#g[e], h = this.#T[e];
3149
+ if (o && h) r.ttl = o - (this.#c.now() - h), r.start = Date.now();
3150
+ }
3151
+ return this.#C && (r.size = this.#C[e]), r;
3152
+ }
3153
+ dump() {
3154
+ let t = [];
3155
+ for (let e of this.#F({ allowStale: !0 })) {
3156
+ let s = this.#a[e], i = this.#i[e], r = this.#l(i) ? i.__staleWhileFetching : i;
3157
+ if (r === void 0 || s === void 0) continue;
3158
+ let o = { value: r };
3159
+ if (this.#g && this.#T) {
3160
+ o.ttl = this.#g[e];
3161
+ let h = this.#c.now() - this.#T[e];
3162
+ o.start = Math.floor(Date.now() - h);
3163
+ }
3164
+ this.#C && (o.size = this.#C[e]), t.unshift([s, o]);
3165
+ }
3166
+ return t;
3167
+ }
3168
+ load(t) {
3169
+ this.clear();
3170
+ for (let [e, s] of t) {
3171
+ if (s.start) {
3172
+ let i = Date.now() - s.start;
3173
+ s.start = this.#c.now() - i;
3174
+ }
3175
+ this.set(e, s.value, s);
3176
+ }
3177
+ }
3178
+ set(t, e, s = {}) {
3179
+ if (e === void 0) return this.delete(t), this;
3180
+ let { ttl: i = this.ttl, start: r, noDisposeOnSet: o = this.noDisposeOnSet, sizeCalculation: h = this.sizeCalculation, status: a } = s, { noUpdateTTL: l = this.noUpdateTTL } = s, u = this.#I(t, e, s.size || 0, h);
3181
+ if (this.maxEntrySize && u > this.maxEntrySize) return a && (a.set = "miss", a.maxEntrySizeExceeded = !0), this.#O(t, "set"), this;
3182
+ let c = this.#h === 0 ? void 0 : this.#f.get(t);
3183
+ if (c === void 0) c = this.#h === 0 ? this.#p : this.#R.length !== 0 ? this.#R.pop() : this.#h === this.#t ? this.#B(!1) : this.#h, this.#a[c] = t, this.#i[c] = e, this.#f.set(t, c), this.#d[this.#p] = c, this.#E[c] = this.#p, this.#p = c, this.#h++, this.#L(c, u, a), a && (a.set = "add"), l = !1, this.#_ && this.#r?.(e, t, "add");
3184
+ else {
3185
+ this.#W(c);
3186
+ let d = this.#i[c];
3187
+ if (e !== d) {
3188
+ if (this.#A && this.#l(d)) {
3189
+ d.__abortController.abort(/* @__PURE__ */ new Error("replaced"));
3190
+ let { __staleWhileFetching: f } = d;
3191
+ f !== void 0 && !o && (this.#x && this.#n?.(f, t, "set"), this.#e && this.#m?.push([
3192
+ f,
3193
+ t,
3194
+ "set"
3195
+ ]));
3196
+ } else o || (this.#x && this.#n?.(d, t, "set"), this.#e && this.#m?.push([
3197
+ d,
3198
+ t,
3199
+ "set"
3200
+ ]));
3201
+ if (this.#P(c), this.#L(c, u, a), this.#i[c] = e, a) {
3202
+ a.set = "replace";
3203
+ let f = d && this.#l(d) ? d.__staleWhileFetching : d;
3204
+ f !== void 0 && (a.oldValue = f);
3205
+ }
3206
+ } else a && (a.set = "update");
3207
+ this.#_ && this.onInsert?.(e, t, e === d ? "update" : "replace");
3208
+ }
3209
+ if (i !== 0 && !this.#g && this.#M(), this.#g && (l || this.#j(c, i, r), a && this.#N(a, c)), !o && this.#e && this.#m) {
3210
+ let d = this.#m, f;
3211
+ for (; f = d?.shift();) this.#o?.(...f);
3212
+ }
3213
+ return this;
3214
+ }
3215
+ pop() {
3216
+ try {
3217
+ for (; this.#h;) {
3218
+ let t = this.#i[this.#b];
3219
+ if (this.#B(!0), this.#l(t)) {
3220
+ if (t.__staleWhileFetching) return t.__staleWhileFetching;
3221
+ } else if (t !== void 0) return t;
3222
+ }
3223
+ } finally {
3224
+ if (this.#e && this.#m) {
3225
+ let t = this.#m, e;
3226
+ for (; e = t?.shift();) this.#o?.(...e);
3227
+ }
3228
+ }
3229
+ }
3230
+ #B(t) {
3231
+ let e = this.#b, s = this.#a[e], i = this.#i[e];
3232
+ return this.#A && this.#l(i) ? i.__abortController.abort(/* @__PURE__ */ new Error("evicted")) : (this.#x || this.#e) && (this.#x && this.#n?.(i, s, "evict"), this.#e && this.#m?.push([
3233
+ i,
3234
+ s,
3235
+ "evict"
3236
+ ])), this.#P(e), this.#y?.[e] && (clearTimeout(this.#y[e]), this.#y[e] = void 0), t && (this.#a[e] = void 0, this.#i[e] = void 0, this.#R.push(e)), this.#h === 1 ? (this.#b = this.#p = 0, this.#R.length = 0) : this.#b = this.#d[e], this.#f.delete(s), this.#h--, e;
3237
+ }
3238
+ has(t, e = {}) {
3239
+ let { updateAgeOnHas: s = this.updateAgeOnHas, status: i } = e, r = this.#f.get(t);
3240
+ if (r !== void 0) {
3241
+ let o = this.#i[r];
3242
+ if (this.#l(o) && o.__staleWhileFetching === void 0) return !1;
3243
+ if (this.#v(r)) i && (i.has = "stale", this.#N(i, r));
3244
+ else return s && this.#k(r), i && (i.has = "hit", this.#N(i, r)), !0;
3245
+ } else i && (i.has = "miss");
3246
+ return !1;
3247
+ }
3248
+ peek(t, e = {}) {
3249
+ let { allowStale: s = this.allowStale } = e, i = this.#f.get(t);
3250
+ if (i === void 0 || !s && this.#v(i)) return;
3251
+ let r = this.#i[i];
3252
+ return this.#l(r) ? r.__staleWhileFetching : r;
3253
+ }
3254
+ #U(t, e, s, i) {
3255
+ let r = e === void 0 ? void 0 : this.#i[e];
3256
+ if (this.#l(r)) return r;
3257
+ let o = new At(), { signal: h } = s;
3258
+ h?.addEventListener("abort", () => o.abort(h.reason), { signal: o.signal });
3259
+ let a = {
3260
+ signal: o.signal,
3261
+ options: s,
3262
+ context: i
3263
+ }, l = (p, w = !1) => {
3264
+ let { aborted: g } = o.signal, S = s.ignoreFetchAbort && p !== void 0, E = s.ignoreFetchAbort || !!(s.allowStaleOnFetchAbort && p !== void 0);
3265
+ if (s.status && (g && !w ? (s.status.fetchAborted = !0, s.status.fetchError = o.signal.reason, S && (s.status.fetchAbortIgnored = !0)) : s.status.fetchResolved = !0), g && !S && !w) return c(o.signal.reason, E);
3266
+ let y = f, b = this.#i[e];
3267
+ return (b === f || S && w && b === void 0) && (p === void 0 ? y.__staleWhileFetching !== void 0 ? this.#i[e] = y.__staleWhileFetching : this.#O(t, "fetch") : (s.status && (s.status.fetchUpdated = !0), this.set(t, p, a.options))), p;
3268
+ }, u = (p) => (s.status && (s.status.fetchRejected = !0, s.status.fetchError = p), c(p, !1)), c = (p, w) => {
3269
+ let { aborted: g } = o.signal, S = g && s.allowStaleOnFetchAbort, E = S || s.allowStaleOnFetchRejection, y = E || s.noDeleteOnFetchRejection, b = f;
3270
+ if (this.#i[e] === f && (!y || !w && b.__staleWhileFetching === void 0 ? this.#O(t, "fetch") : S || (this.#i[e] = b.__staleWhileFetching)), E) return s.status && b.__staleWhileFetching !== void 0 && (s.status.returnedStale = !0), b.__staleWhileFetching;
3271
+ if (b.__returned === b) throw p;
3272
+ }, d = (p, w) => {
3273
+ let g = this.#S?.(t, r, a);
3274
+ g && g instanceof Promise && g.then((S) => p(S === void 0 ? void 0 : S), w), o.signal.addEventListener("abort", () => {
3275
+ (!s.ignoreFetchAbort || s.allowStaleOnFetchAbort) && (p(void 0), s.allowStaleOnFetchAbort && (p = (S) => l(S, !0)));
3276
+ });
3277
+ };
3278
+ s.status && (s.status.fetchDispatched = !0);
3279
+ let f = new Promise(d).then(l, u), m = Object.assign(f, {
3280
+ __abortController: o,
3281
+ __staleWhileFetching: r,
3282
+ __returned: void 0
3283
+ });
3284
+ return e === void 0 ? (this.set(t, m, {
3285
+ ...a.options,
3286
+ status: void 0
3287
+ }), e = this.#f.get(t)) : this.#i[e] = m, m;
3288
+ }
3289
+ #l(t) {
3290
+ if (!this.#A) return !1;
3291
+ let e = t;
3292
+ return !!e && e instanceof Promise && e.hasOwnProperty("__staleWhileFetching") && e.__abortController instanceof At;
3293
+ }
3294
+ async fetch(t, e = {}) {
3295
+ let { allowStale: s = this.allowStale, updateAgeOnGet: i = this.updateAgeOnGet, noDeleteOnStaleGet: r = this.noDeleteOnStaleGet, ttl: o = this.ttl, noDisposeOnSet: h = this.noDisposeOnSet, size: a = 0, sizeCalculation: l = this.sizeCalculation, noUpdateTTL: u = this.noUpdateTTL, noDeleteOnFetchRejection: c = this.noDeleteOnFetchRejection, allowStaleOnFetchRejection: d = this.allowStaleOnFetchRejection, ignoreFetchAbort: f = this.ignoreFetchAbort, allowStaleOnFetchAbort: m = this.allowStaleOnFetchAbort, context: p, forceRefresh: w = !1, status: g, signal: S } = e;
3296
+ if (!this.#A) return g && (g.fetch = "get"), this.get(t, {
3297
+ allowStale: s,
3298
+ updateAgeOnGet: i,
3299
+ noDeleteOnStaleGet: r,
3300
+ status: g
3301
+ });
3302
+ let E = {
3303
+ allowStale: s,
3304
+ updateAgeOnGet: i,
3305
+ noDeleteOnStaleGet: r,
3306
+ ttl: o,
3307
+ noDisposeOnSet: h,
3308
+ size: a,
3309
+ sizeCalculation: l,
3310
+ noUpdateTTL: u,
3311
+ noDeleteOnFetchRejection: c,
3312
+ allowStaleOnFetchRejection: d,
3313
+ allowStaleOnFetchAbort: m,
3314
+ ignoreFetchAbort: f,
3315
+ status: g,
3316
+ signal: S
3317
+ }, y = this.#f.get(t);
3318
+ if (y === void 0) {
3319
+ g && (g.fetch = "miss");
3320
+ let b = this.#U(t, y, E, p);
3321
+ return b.__returned = b;
3322
+ } else {
3323
+ let b = this.#i[y];
3324
+ if (this.#l(b)) {
3325
+ let Z = s && b.__staleWhileFetching !== void 0;
3326
+ return g && (g.fetch = "inflight", Z && (g.returnedStale = !0)), Z ? b.__staleWhileFetching : b.__returned = b;
3327
+ }
3328
+ let z = this.#v(y);
3329
+ if (!w && !z) return g && (g.fetch = "hit"), this.#W(y), i && this.#k(y), g && this.#N(g, y), b;
3330
+ let $ = this.#U(t, y, E, p), J = $.__staleWhileFetching !== void 0 && s;
3331
+ return g && (g.fetch = z ? "stale" : "refresh", J && z && (g.returnedStale = !0)), J ? $.__staleWhileFetching : $.__returned = $;
3332
+ }
3333
+ }
3334
+ async forceFetch(t, e = {}) {
3335
+ let s = await this.fetch(t, e);
3336
+ if (s === void 0) throw new Error("fetch() returned undefined");
3337
+ return s;
3338
+ }
3339
+ memo(t, e = {}) {
3340
+ let s = this.#w;
3341
+ if (!s) throw new Error("no memoMethod provided to constructor");
3342
+ let { context: i, forceRefresh: r, ...o } = e, h = this.get(t, o);
3343
+ if (!r && h !== void 0) return h;
3344
+ let a = s(t, h, {
3345
+ options: o,
3346
+ context: i
3347
+ });
3348
+ return this.set(t, a, o), a;
3349
+ }
3350
+ get(t, e = {}) {
3351
+ let { allowStale: s = this.allowStale, updateAgeOnGet: i = this.updateAgeOnGet, noDeleteOnStaleGet: r = this.noDeleteOnStaleGet, status: o } = e, h = this.#f.get(t);
3352
+ if (h !== void 0) {
3353
+ let a = this.#i[h], l = this.#l(a);
3354
+ return o && this.#N(o, h), this.#v(h) ? (o && (o.get = "stale"), l ? (o && s && a.__staleWhileFetching !== void 0 && (o.returnedStale = !0), s ? a.__staleWhileFetching : void 0) : (r || this.#O(t, "expire"), o && s && (o.returnedStale = !0), s ? a : void 0)) : (o && (o.get = "hit"), l ? a.__staleWhileFetching : (this.#W(h), i && this.#k(h), a));
3355
+ } else o && (o.get = "miss");
3356
+ }
3357
+ #$(t, e) {
3358
+ this.#E[e] = t, this.#d[t] = e;
3359
+ }
3360
+ #W(t) {
3361
+ t !== this.#p && (t === this.#b ? this.#b = this.#d[t] : this.#$(this.#E[t], this.#d[t]), this.#$(this.#p, t), this.#p = t);
3362
+ }
3363
+ delete(t) {
3364
+ return this.#O(t, "delete");
3365
+ }
3366
+ #O(t, e) {
3367
+ let s = !1;
3368
+ if (this.#h !== 0) {
3369
+ let i = this.#f.get(t);
3370
+ if (i !== void 0) if (this.#y?.[i] && (clearTimeout(this.#y?.[i]), this.#y[i] = void 0), s = !0, this.#h === 1) this.#H(e);
3371
+ else {
3372
+ this.#P(i);
3373
+ let r = this.#i[i];
3374
+ if (this.#l(r) ? r.__abortController.abort(/* @__PURE__ */ new Error("deleted")) : (this.#x || this.#e) && (this.#x && this.#n?.(r, t, e), this.#e && this.#m?.push([
3375
+ r,
3376
+ t,
3377
+ e
3378
+ ])), this.#f.delete(t), this.#a[i] = void 0, this.#i[i] = void 0, i === this.#p) this.#p = this.#E[i];
3379
+ else if (i === this.#b) this.#b = this.#d[i];
3380
+ else {
3381
+ let o = this.#E[i];
3382
+ this.#d[o] = this.#d[i];
3383
+ let h = this.#d[i];
3384
+ this.#E[h] = this.#E[i];
3385
+ }
3386
+ this.#h--, this.#R.push(i);
3387
+ }
3388
+ }
3389
+ if (this.#e && this.#m?.length) {
3390
+ let i = this.#m, r;
3391
+ for (; r = i?.shift();) this.#o?.(...r);
3392
+ }
3393
+ return s;
3394
+ }
3395
+ clear() {
3396
+ return this.#H("delete");
3397
+ }
3398
+ #H(t) {
3399
+ for (let e of this.#D({ allowStale: !0 })) {
3400
+ let s = this.#i[e];
3401
+ if (this.#l(s)) s.__abortController.abort(/* @__PURE__ */ new Error("deleted"));
3402
+ else {
3403
+ let i = this.#a[e];
3404
+ this.#x && this.#n?.(s, i, t), this.#e && this.#m?.push([
3405
+ s,
3406
+ i,
3407
+ t
3408
+ ]);
3409
+ }
3410
+ }
3411
+ if (this.#f.clear(), this.#i.fill(void 0), this.#a.fill(void 0), this.#g && this.#T) {
3412
+ this.#g.fill(0), this.#T.fill(0);
3413
+ for (let e of this.#y ?? []) e !== void 0 && clearTimeout(e);
3414
+ this.#y?.fill(void 0);
3415
+ }
3416
+ if (this.#C && this.#C.fill(0), this.#b = 0, this.#p = 0, this.#R.length = 0, this.#u = 0, this.#h = 0, this.#e && this.#m) {
3417
+ let e = this.#m, s;
3418
+ for (; s = e?.shift();) this.#o?.(...s);
3419
+ }
3420
+ }
3421
+ };
3422
+ var Ne = typeof process == "object" && process ? process : {
3423
+ stdout: null,
3424
+ stderr: null
3425
+ };
3426
+ var oi = (n) => !!n && typeof n == "object" && (n instanceof V || n instanceof Pe || hi(n) || ai(n));
3427
+ var hi = (n) => !!n && typeof n == "object" && n instanceof EventEmitter && typeof n.pipe == "function" && n.pipe !== Pe.Writable.prototype.pipe;
3428
+ var ai = (n) => !!n && typeof n == "object" && n instanceof EventEmitter && typeof n.write == "function" && typeof n.end == "function";
3429
+ var G = Symbol("EOF");
3430
+ var H = Symbol("maybeEmitEnd");
3431
+ var K = Symbol("emittedEnd");
3432
+ var kt = Symbol("emittingEnd");
3433
+ var ut = Symbol("emittedError");
3434
+ var Rt = Symbol("closed");
3435
+ var _e = Symbol("read");
3436
+ var Ot = Symbol("flush");
3437
+ var Le = Symbol("flushChunk");
3438
+ var P = Symbol("encoding");
3439
+ var et = Symbol("decoder");
3440
+ var v = Symbol("flowing");
3441
+ var dt = Symbol("paused");
3442
+ var st = Symbol("resume");
3443
+ var C = Symbol("buffer");
3444
+ var F = Symbol("pipes");
3445
+ var T = Symbol("bufferLength");
3446
+ var Yt = Symbol("bufferPush");
3447
+ var Ft = Symbol("bufferShift");
3448
+ var k = Symbol("objectMode");
3449
+ var x = Symbol("destroyed");
3450
+ var Xt = Symbol("error");
3451
+ var Jt = Symbol("emitData");
3452
+ var We = Symbol("emitEnd");
3453
+ var Zt = Symbol("emitEnd2");
3454
+ var B = Symbol("async");
3455
+ var Qt = Symbol("abort");
3456
+ var Dt = Symbol("aborted");
3457
+ var pt = Symbol("signal");
3458
+ var Y = Symbol("dataListeners");
3459
+ var M = Symbol("discarded");
3460
+ var mt = (n) => Promise.resolve().then(n);
3461
+ var li = (n) => n();
3462
+ var ci = (n) => n === "end" || n === "finish" || n === "prefinish";
3463
+ var fi = (n) => n instanceof ArrayBuffer || !!n && typeof n == "object" && n.constructor && n.constructor.name === "ArrayBuffer" && n.byteLength >= 0;
3464
+ var ui = (n) => !Buffer.isBuffer(n) && ArrayBuffer.isView(n);
3465
+ var Mt = class {
3466
+ src;
3467
+ dest;
3468
+ opts;
3469
+ ondrain;
3470
+ constructor(t, e, s) {
3471
+ this.src = t, this.dest = e, this.opts = s, this.ondrain = () => t[st](), this.dest.on("drain", this.ondrain);
3472
+ }
3473
+ unpipe() {
3474
+ this.dest.removeListener("drain", this.ondrain);
3475
+ }
3476
+ proxyErrors(t) {}
3477
+ end() {
3478
+ this.unpipe(), this.opts.end && this.dest.end();
3479
+ }
3480
+ };
3481
+ var te = class extends Mt {
3482
+ unpipe() {
3483
+ this.src.removeListener("error", this.proxyErrors), super.unpipe();
3484
+ }
3485
+ constructor(t, e, s) {
3486
+ super(t, e, s), this.proxyErrors = (i) => this.dest.emit("error", i), t.on("error", this.proxyErrors);
3487
+ }
3488
+ };
3489
+ var di = (n) => !!n.objectMode;
3490
+ var pi = (n) => !n.objectMode && !!n.encoding && n.encoding !== "buffer";
3491
+ var V = class extends EventEmitter {
3492
+ [v] = !1;
3493
+ [dt] = !1;
3494
+ [F] = [];
3495
+ [C] = [];
3496
+ [k];
3497
+ [P];
3498
+ [B];
3499
+ [et];
3500
+ [G] = !1;
3501
+ [K] = !1;
3502
+ [kt] = !1;
3503
+ [Rt] = !1;
3504
+ [ut] = null;
3505
+ [T] = 0;
3506
+ [x] = !1;
3507
+ [pt];
3508
+ [Dt] = !1;
3509
+ [Y] = 0;
3510
+ [M] = !1;
3511
+ writable = !0;
3512
+ readable = !0;
3513
+ constructor(...t) {
3514
+ let e = t[0] || {};
3515
+ if (super(), e.objectMode && typeof e.encoding == "string") throw new TypeError("Encoding and objectMode may not be used together");
3516
+ di(e) ? (this[k] = !0, this[P] = null) : pi(e) ? (this[P] = e.encoding, this[k] = !1) : (this[k] = !1, this[P] = null), this[B] = !!e.async, this[et] = this[P] ? new StringDecoder(this[P]) : null, e && e.debugExposeBuffer === !0 && Object.defineProperty(this, "buffer", { get: () => this[C] }), e && e.debugExposePipes === !0 && Object.defineProperty(this, "pipes", { get: () => this[F] });
3517
+ let { signal: s } = e;
3518
+ s && (this[pt] = s, s.aborted ? this[Qt]() : s.addEventListener("abort", () => this[Qt]()));
3519
+ }
3520
+ get bufferLength() {
3521
+ return this[T];
3522
+ }
3523
+ get encoding() {
3524
+ return this[P];
3525
+ }
3526
+ set encoding(t) {
3527
+ throw new Error("Encoding must be set at instantiation time");
3528
+ }
3529
+ setEncoding(t) {
3530
+ throw new Error("Encoding must be set at instantiation time");
3531
+ }
3532
+ get objectMode() {
3533
+ return this[k];
3534
+ }
3535
+ set objectMode(t) {
3536
+ throw new Error("objectMode must be set at instantiation time");
3537
+ }
3538
+ get async() {
3539
+ return this[B];
3540
+ }
3541
+ set async(t) {
3542
+ this[B] = this[B] || !!t;
3543
+ }
3544
+ [Qt]() {
3545
+ this[Dt] = !0, this.emit("abort", this[pt]?.reason), this.destroy(this[pt]?.reason);
3546
+ }
3547
+ get aborted() {
3548
+ return this[Dt];
3549
+ }
3550
+ set aborted(t) {}
3551
+ write(t, e, s) {
3552
+ if (this[Dt]) return !1;
3553
+ if (this[G]) throw new Error("write after end");
3554
+ if (this[x]) return this.emit("error", Object.assign(/* @__PURE__ */ new Error("Cannot call write after a stream was destroyed"), { code: "ERR_STREAM_DESTROYED" })), !0;
3555
+ typeof e == "function" && (s = e, e = "utf8"), e || (e = "utf8");
3556
+ let i = this[B] ? mt : li;
3557
+ if (!this[k] && !Buffer.isBuffer(t)) {
3558
+ if (ui(t)) t = Buffer.from(t.buffer, t.byteOffset, t.byteLength);
3559
+ else if (fi(t)) t = Buffer.from(t);
3560
+ else if (typeof t != "string") throw new Error("Non-contiguous data written to non-objectMode stream");
3561
+ }
3562
+ return this[k] ? (this[v] && this[T] !== 0 && this[Ot](!0), this[v] ? this.emit("data", t) : this[Yt](t), this[T] !== 0 && this.emit("readable"), s && i(s), this[v]) : t.length ? (typeof t == "string" && (e !== this[P] || this[et]?.lastNeed) && (t = Buffer.from(t, e)), Buffer.isBuffer(t) && this[P] && (t = this[et].write(t)), this[v] && this[T] !== 0 && this[Ot](!0), this[v] ? this.emit("data", t) : this[Yt](t), this[T] !== 0 && this.emit("readable"), s && i(s), this[v]) : (this[T] !== 0 && this.emit("readable"), s && i(s), this[v]);
3563
+ }
3564
+ read(t) {
3565
+ if (this[x]) return null;
3566
+ if (this[M] = !1, this[T] === 0 || t === 0 || t && t > this[T]) return this[H](), null;
3567
+ this[k] && (t = null), this[C].length > 1 && !this[k] && (this[C] = [this[P] ? this[C].join("") : Buffer.concat(this[C], this[T])]);
3568
+ let e = this[_e](t || null, this[C][0]);
3569
+ return this[H](), e;
3570
+ }
3571
+ [_e](t, e) {
3572
+ if (this[k]) this[Ft]();
3573
+ else {
3574
+ let s = e;
3575
+ t === s.length || t === null ? this[Ft]() : typeof s == "string" ? (this[C][0] = s.slice(t), e = s.slice(0, t), this[T] -= t) : (this[C][0] = s.subarray(t), e = s.subarray(0, t), this[T] -= t);
3576
+ }
3577
+ return this.emit("data", e), !this[C].length && !this[G] && this.emit("drain"), e;
3578
+ }
3579
+ end(t, e, s) {
3580
+ return typeof t == "function" && (s = t, t = void 0), typeof e == "function" && (s = e, e = "utf8"), t !== void 0 && this.write(t, e), s && this.once("end", s), this[G] = !0, this.writable = !1, (this[v] || !this[dt]) && this[H](), this;
3581
+ }
3582
+ [st]() {
3583
+ this[x] || (!this[Y] && !this[F].length && (this[M] = !0), this[dt] = !1, this[v] = !0, this.emit("resume"), this[C].length ? this[Ot]() : this[G] ? this[H]() : this.emit("drain"));
3584
+ }
3585
+ resume() {
3586
+ return this[st]();
3587
+ }
3588
+ pause() {
3589
+ this[v] = !1, this[dt] = !0, this[M] = !1;
3590
+ }
3591
+ get destroyed() {
3592
+ return this[x];
3593
+ }
3594
+ get flowing() {
3595
+ return this[v];
3596
+ }
3597
+ get paused() {
3598
+ return this[dt];
3599
+ }
3600
+ [Yt](t) {
3601
+ this[k] ? this[T] += 1 : this[T] += t.length, this[C].push(t);
3602
+ }
3603
+ [Ft]() {
3604
+ return this[k] ? this[T] -= 1 : this[T] -= this[C][0].length, this[C].shift();
3605
+ }
3606
+ [Ot](t = !1) {
3607
+ do ;
3608
+ while (this[Le](this[Ft]()) && this[C].length);
3609
+ !t && !this[C].length && !this[G] && this.emit("drain");
3610
+ }
3611
+ [Le](t) {
3612
+ return this.emit("data", t), this[v];
3613
+ }
3614
+ pipe(t, e) {
3615
+ if (this[x]) return t;
3616
+ this[M] = !1;
3617
+ let s = this[K];
3618
+ return e = e || {}, t === Ne.stdout || t === Ne.stderr ? e.end = !1 : e.end = e.end !== !1, e.proxyErrors = !!e.proxyErrors, s ? e.end && t.end() : (this[F].push(e.proxyErrors ? new te(this, t, e) : new Mt(this, t, e)), this[B] ? mt(() => this[st]()) : this[st]()), t;
3619
+ }
3620
+ unpipe(t) {
3621
+ let e = this[F].find((s) => s.dest === t);
3622
+ e && (this[F].length === 1 ? (this[v] && this[Y] === 0 && (this[v] = !1), this[F] = []) : this[F].splice(this[F].indexOf(e), 1), e.unpipe());
3623
+ }
3624
+ addListener(t, e) {
3625
+ return this.on(t, e);
3626
+ }
3627
+ on(t, e) {
3628
+ let s = super.on(t, e);
3629
+ if (t === "data") this[M] = !1, this[Y]++, !this[F].length && !this[v] && this[st]();
3630
+ else if (t === "readable" && this[T] !== 0) super.emit("readable");
3631
+ else if (ci(t) && this[K]) super.emit(t), this.removeAllListeners(t);
3632
+ else if (t === "error" && this[ut]) {
3633
+ let i = e;
3634
+ this[B] ? mt(() => i.call(this, this[ut])) : i.call(this, this[ut]);
3635
+ }
3636
+ return s;
3637
+ }
3638
+ removeListener(t, e) {
3639
+ return this.off(t, e);
3640
+ }
3641
+ off(t, e) {
3642
+ let s = super.off(t, e);
3643
+ return t === "data" && (this[Y] = this.listeners("data").length, this[Y] === 0 && !this[M] && !this[F].length && (this[v] = !1)), s;
3644
+ }
3645
+ removeAllListeners(t) {
3646
+ let e = super.removeAllListeners(t);
3647
+ return (t === "data" || t === void 0) && (this[Y] = 0, !this[M] && !this[F].length && (this[v] = !1)), e;
3648
+ }
3649
+ get emittedEnd() {
3650
+ return this[K];
3651
+ }
3652
+ [H]() {
3653
+ !this[kt] && !this[K] && !this[x] && this[C].length === 0 && this[G] && (this[kt] = !0, this.emit("end"), this.emit("prefinish"), this.emit("finish"), this[Rt] && this.emit("close"), this[kt] = !1);
3654
+ }
3655
+ emit(t, ...e) {
3656
+ let s = e[0];
3657
+ if (t !== "error" && t !== "close" && t !== x && this[x]) return !1;
3658
+ if (t === "data") return !this[k] && !s ? !1 : this[B] ? (mt(() => this[Jt](s)), !0) : this[Jt](s);
3659
+ if (t === "end") return this[We]();
3660
+ if (t === "close") {
3661
+ if (this[Rt] = !0, !this[K] && !this[x]) return !1;
3662
+ let r = super.emit("close");
3663
+ return this.removeAllListeners("close"), r;
3664
+ } else if (t === "error") {
3665
+ this[ut] = s, super.emit(Xt, s);
3666
+ let r = !this[pt] || this.listeners("error").length ? super.emit("error", s) : !1;
3667
+ return this[H](), r;
3668
+ } else if (t === "resume") {
3669
+ let r = super.emit("resume");
3670
+ return this[H](), r;
3671
+ } else if (t === "finish" || t === "prefinish") {
3672
+ let r = super.emit(t);
3673
+ return this.removeAllListeners(t), r;
3674
+ }
3675
+ let i = super.emit(t, ...e);
3676
+ return this[H](), i;
3677
+ }
3678
+ [Jt](t) {
3679
+ for (let s of this[F]) s.dest.write(t) === !1 && this.pause();
3680
+ let e = this[M] ? !1 : super.emit("data", t);
3681
+ return this[H](), e;
3682
+ }
3683
+ [We]() {
3684
+ return this[K] ? !1 : (this[K] = !0, this.readable = !1, this[B] ? (mt(() => this[Zt]()), !0) : this[Zt]());
3685
+ }
3686
+ [Zt]() {
3687
+ if (this[et]) {
3688
+ let e = this[et].end();
3689
+ if (e) {
3690
+ for (let s of this[F]) s.dest.write(e);
3691
+ this[M] || super.emit("data", e);
3692
+ }
3693
+ }
3694
+ for (let e of this[F]) e.end();
3695
+ let t = super.emit("end");
3696
+ return this.removeAllListeners("end"), t;
3697
+ }
3698
+ async collect() {
3699
+ let t = Object.assign([], { dataLength: 0 });
3700
+ this[k] || (t.dataLength = 0);
3701
+ let e = this.promise();
3702
+ return this.on("data", (s) => {
3703
+ t.push(s), this[k] || (t.dataLength += s.length);
3704
+ }), await e, t;
3705
+ }
3706
+ async concat() {
3707
+ if (this[k]) throw new Error("cannot concat in objectMode");
3708
+ let t = await this.collect();
3709
+ return this[P] ? t.join("") : Buffer.concat(t, t.dataLength);
3710
+ }
3711
+ async promise() {
3712
+ return new Promise((t, e) => {
3713
+ this.on(x, () => e(/* @__PURE__ */ new Error("stream destroyed"))), this.on("error", (s) => e(s)), this.on("end", () => t());
3714
+ });
3715
+ }
3716
+ [Symbol.asyncIterator]() {
3717
+ this[M] = !1;
3718
+ let t = !1, e = async () => (this.pause(), t = !0, {
3719
+ value: void 0,
3720
+ done: !0
3721
+ });
3722
+ return {
3723
+ next: () => {
3724
+ if (t) return e();
3725
+ let i = this.read();
3726
+ if (i !== null) return Promise.resolve({
3727
+ done: !1,
3728
+ value: i
3729
+ });
3730
+ if (this[G]) return e();
3731
+ let r, o, h = (c) => {
3732
+ this.off("data", a), this.off("end", l), this.off(x, u), e(), o(c);
3733
+ }, a = (c) => {
3734
+ this.off("error", h), this.off("end", l), this.off(x, u), this.pause(), r({
3735
+ value: c,
3736
+ done: !!this[G]
3737
+ });
3738
+ }, l = () => {
3739
+ this.off("error", h), this.off("data", a), this.off(x, u), e(), r({
3740
+ done: !0,
3741
+ value: void 0
3742
+ });
3743
+ }, u = () => h(/* @__PURE__ */ new Error("stream destroyed"));
3744
+ return new Promise((c, d) => {
3745
+ o = d, r = c, this.once(x, u), this.once("error", h), this.once("end", l), this.once("data", a);
3746
+ });
3747
+ },
3748
+ throw: e,
3749
+ return: e,
3750
+ [Symbol.asyncIterator]() {
3751
+ return this;
3752
+ },
3753
+ [Symbol.asyncDispose]: async () => {}
3754
+ };
3755
+ }
3756
+ [Symbol.iterator]() {
3757
+ this[M] = !1;
3758
+ let t = !1, e = () => (this.pause(), this.off(Xt, e), this.off(x, e), this.off("end", e), t = !0, {
3759
+ done: !0,
3760
+ value: void 0
3761
+ }), s = () => {
3762
+ if (t) return e();
3763
+ let i = this.read();
3764
+ return i === null ? e() : {
3765
+ done: !1,
3766
+ value: i
3767
+ };
3768
+ };
3769
+ return this.once("end", e), this.once(Xt, e), this.once(x, e), {
3770
+ next: s,
3771
+ throw: e,
3772
+ return: e,
3773
+ [Symbol.iterator]() {
3774
+ return this;
3775
+ },
3776
+ [Symbol.dispose]: () => {}
3777
+ };
3778
+ }
3779
+ destroy(t) {
3780
+ if (this[x]) return t ? this.emit("error", t) : this.emit(x), this;
3781
+ this[x] = !0, this[M] = !0, this[C].length = 0, this[T] = 0;
3782
+ let e = this;
3783
+ return typeof e.close == "function" && !this[Rt] && e.close(), t ? this.emit("error", t) : this.emit(x), this;
3784
+ }
3785
+ static get isStream() {
3786
+ return oi;
3787
+ }
3788
+ };
3789
+ var vi = realpathSync.native;
3790
+ var wt = {
3791
+ lstatSync,
3792
+ readdir,
3793
+ readdirSync,
3794
+ readlinkSync,
3795
+ realpathSync: vi,
3796
+ promises: {
3797
+ lstat,
3798
+ readdir: readdir$1,
3799
+ readlink,
3800
+ realpath
3801
+ }
3802
+ };
3803
+ var Ue = (n) => !n || n === wt || n === xi ? wt : {
3804
+ ...wt,
3805
+ ...n,
3806
+ promises: {
3807
+ ...wt.promises,
3808
+ ...n.promises || {}
3809
+ }
3810
+ };
3811
+ var $e = /^\\\\\?\\([a-z]:)\\?$/i;
3812
+ var Ri = (n) => n.replace(/\//g, "\\").replace($e, "$1\\");
3813
+ var Oi = /[\\\/]/;
3814
+ var L = 0;
3815
+ var Ge = 1;
3816
+ var He = 2;
3817
+ var U = 4;
3818
+ var qe = 6;
3819
+ var Ke = 8;
3820
+ var X = 10;
3821
+ var Ve = 12;
3822
+ var _ = 15;
3823
+ var gt = ~_;
3824
+ var se = 16;
3825
+ var je = 32;
3826
+ var yt = 64;
3827
+ var j = 128;
3828
+ var Nt = 256;
3829
+ var Lt = 512;
3830
+ var Ie = yt | j | Lt;
3831
+ var Fi = 1023;
3832
+ var ie = (n) => n.isFile() ? Ke : n.isDirectory() ? U : n.isSymbolicLink() ? X : n.isCharacterDevice() ? He : n.isBlockDevice() ? qe : n.isSocket() ? Ve : n.isFIFO() ? Ge : L;
3833
+ var ze = new ft({ max: 4096 });
3834
+ var bt = (n) => {
3835
+ let t = ze.get(n);
3836
+ if (t) return t;
3837
+ let e = n.normalize("NFKD");
3838
+ return ze.set(n, e), e;
3839
+ };
3840
+ var Be = new ft({ max: 4096 });
3841
+ var _t = (n) => {
3842
+ let t = Be.get(n);
3843
+ if (t) return t;
3844
+ let e = bt(n.toLowerCase());
3845
+ return Be.set(n, e), e;
3846
+ };
3847
+ var Wt = class extends ft {
3848
+ constructor() {
3849
+ super({ max: 256 });
3850
+ }
3851
+ };
3852
+ var ne = class extends ft {
3853
+ constructor(t = 16384) {
3854
+ super({
3855
+ maxSize: t,
3856
+ sizeCalculation: (e) => e.length + 1
3857
+ });
3858
+ }
3859
+ };
3860
+ var Ye = Symbol("PathScurry setAsCwd");
3861
+ var R = class {
3862
+ name;
3863
+ root;
3864
+ roots;
3865
+ parent;
3866
+ nocase;
3867
+ isCWD = !1;
3868
+ #t;
3869
+ #s;
3870
+ get dev() {
3871
+ return this.#s;
3872
+ }
3873
+ #n;
3874
+ get mode() {
3875
+ return this.#n;
3876
+ }
3877
+ #r;
3878
+ get nlink() {
3879
+ return this.#r;
3880
+ }
3881
+ #o;
3882
+ get uid() {
3883
+ return this.#o;
3884
+ }
3885
+ #S;
3886
+ get gid() {
3887
+ return this.#S;
3888
+ }
3889
+ #w;
3890
+ get rdev() {
3891
+ return this.#w;
3892
+ }
3893
+ #c;
3894
+ get blksize() {
3895
+ return this.#c;
3896
+ }
3897
+ #h;
3898
+ get ino() {
3899
+ return this.#h;
3900
+ }
3901
+ #u;
3902
+ get size() {
3903
+ return this.#u;
3904
+ }
3905
+ #f;
3906
+ get blocks() {
3907
+ return this.#f;
3908
+ }
3909
+ #a;
3910
+ get atimeMs() {
3911
+ return this.#a;
3912
+ }
3913
+ #i;
3914
+ get mtimeMs() {
3915
+ return this.#i;
3916
+ }
3917
+ #d;
3918
+ get ctimeMs() {
3919
+ return this.#d;
3920
+ }
3921
+ #E;
3922
+ get birthtimeMs() {
3923
+ return this.#E;
3924
+ }
3925
+ #b;
3926
+ get atime() {
3927
+ return this.#b;
3928
+ }
3929
+ #p;
3930
+ get mtime() {
3931
+ return this.#p;
3932
+ }
3933
+ #R;
3934
+ get ctime() {
3935
+ return this.#R;
3936
+ }
3937
+ #m;
3938
+ get birthtime() {
3939
+ return this.#m;
3940
+ }
3941
+ #C;
3942
+ #T;
3943
+ #g;
3944
+ #y;
3945
+ #x;
3946
+ #A;
3947
+ #e;
3948
+ #_;
3949
+ #M;
3950
+ #k;
3951
+ get parentPath() {
3952
+ return (this.parent || this).fullpath();
3953
+ }
3954
+ get path() {
3955
+ return this.parentPath;
3956
+ }
3957
+ constructor(t, e = L, s, i, r, o, h) {
3958
+ this.name = t, this.#C = r ? _t(t) : bt(t), this.#e = e & Fi, this.nocase = r, this.roots = i, this.root = s || this, this.#_ = o, this.#g = h.fullpath, this.#x = h.relative, this.#A = h.relativePosix, this.parent = h.parent, this.parent ? this.#t = this.parent.#t : this.#t = Ue(h.fs);
3959
+ }
3960
+ depth() {
3961
+ return this.#T !== void 0 ? this.#T : this.parent ? this.#T = this.parent.depth() + 1 : this.#T = 0;
3962
+ }
3963
+ childrenCache() {
3964
+ return this.#_;
3965
+ }
3966
+ resolve(t) {
3967
+ if (!t) return this;
3968
+ let e = this.getRootString(t), i = t.substring(e.length).split(this.splitSep);
3969
+ return e ? this.getRoot(e).#N(i) : this.#N(i);
3970
+ }
3971
+ #N(t) {
3972
+ let e = this;
3973
+ for (let s of t) e = e.child(s);
3974
+ return e;
3975
+ }
3976
+ children() {
3977
+ let t = this.#_.get(this);
3978
+ if (t) return t;
3979
+ let e = Object.assign([], { provisional: 0 });
3980
+ return this.#_.set(this, e), this.#e &= ~se, e;
3981
+ }
3982
+ child(t, e) {
3983
+ if (t === "" || t === ".") return this;
3984
+ if (t === "..") return this.parent || this;
3985
+ let s = this.children(), i = this.nocase ? _t(t) : bt(t);
3986
+ for (let a of s) if (a.#C === i) return a;
3987
+ let r = this.parent ? this.sep : "", o = this.#g ? this.#g + r + t : void 0, h = this.newChild(t, L, {
3988
+ ...e,
3989
+ parent: this,
3990
+ fullpath: o
3991
+ });
3992
+ return this.canReaddir() || (h.#e |= j), s.push(h), h;
3993
+ }
3994
+ relative() {
3995
+ if (this.isCWD) return "";
3996
+ if (this.#x !== void 0) return this.#x;
3997
+ let t = this.name, e = this.parent;
3998
+ if (!e) return this.#x = this.name;
3999
+ let s = e.relative();
4000
+ return s + (!s || !e.parent ? "" : this.sep) + t;
4001
+ }
4002
+ relativePosix() {
4003
+ if (this.sep === "/") return this.relative();
4004
+ if (this.isCWD) return "";
4005
+ if (this.#A !== void 0) return this.#A;
4006
+ let t = this.name, e = this.parent;
4007
+ if (!e) return this.#A = this.fullpathPosix();
4008
+ let s = e.relativePosix();
4009
+ return s + (!s || !e.parent ? "" : "/") + t;
4010
+ }
4011
+ fullpath() {
4012
+ if (this.#g !== void 0) return this.#g;
4013
+ let t = this.name, e = this.parent;
4014
+ if (!e) return this.#g = this.name;
4015
+ let i = e.fullpath() + (e.parent ? this.sep : "") + t;
4016
+ return this.#g = i;
4017
+ }
4018
+ fullpathPosix() {
4019
+ if (this.#y !== void 0) return this.#y;
4020
+ if (this.sep === "/") return this.#y = this.fullpath();
4021
+ if (!this.parent) {
4022
+ let i = this.fullpath().replace(/\\/g, "/");
4023
+ return /^[a-z]:\//i.test(i) ? this.#y = `//?/${i}` : this.#y = i;
4024
+ }
4025
+ let t = this.parent, e = t.fullpathPosix(), s = e + (!e || !t.parent ? "" : "/") + this.name;
4026
+ return this.#y = s;
4027
+ }
4028
+ isUnknown() {
4029
+ return (this.#e & _) === L;
4030
+ }
4031
+ isType(t) {
4032
+ return this[`is${t}`]();
4033
+ }
4034
+ getType() {
4035
+ return this.isUnknown() ? "Unknown" : this.isDirectory() ? "Directory" : this.isFile() ? "File" : this.isSymbolicLink() ? "SymbolicLink" : this.isFIFO() ? "FIFO" : this.isCharacterDevice() ? "CharacterDevice" : this.isBlockDevice() ? "BlockDevice" : this.isSocket() ? "Socket" : "Unknown";
4036
+ }
4037
+ isFile() {
4038
+ return (this.#e & _) === Ke;
4039
+ }
4040
+ isDirectory() {
4041
+ return (this.#e & _) === U;
4042
+ }
4043
+ isCharacterDevice() {
4044
+ return (this.#e & _) === He;
4045
+ }
4046
+ isBlockDevice() {
4047
+ return (this.#e & _) === qe;
4048
+ }
4049
+ isFIFO() {
4050
+ return (this.#e & _) === Ge;
4051
+ }
4052
+ isSocket() {
4053
+ return (this.#e & _) === Ve;
4054
+ }
4055
+ isSymbolicLink() {
4056
+ return (this.#e & X) === X;
4057
+ }
4058
+ lstatCached() {
4059
+ return this.#e & je ? this : void 0;
4060
+ }
4061
+ readlinkCached() {
4062
+ return this.#M;
4063
+ }
4064
+ realpathCached() {
4065
+ return this.#k;
4066
+ }
4067
+ readdirCached() {
4068
+ let t = this.children();
4069
+ return t.slice(0, t.provisional);
4070
+ }
4071
+ canReadlink() {
4072
+ if (this.#M) return !0;
4073
+ if (!this.parent) return !1;
4074
+ let t = this.#e & _;
4075
+ return !(t !== L && t !== X || this.#e & Nt || this.#e & j);
4076
+ }
4077
+ calledReaddir() {
4078
+ return !!(this.#e & se);
4079
+ }
4080
+ isENOENT() {
4081
+ return !!(this.#e & j);
4082
+ }
4083
+ isNamed(t) {
4084
+ return this.nocase ? this.#C === _t(t) : this.#C === bt(t);
4085
+ }
4086
+ async readlink() {
4087
+ let t = this.#M;
4088
+ if (t) return t;
4089
+ if (this.canReadlink() && this.parent) try {
4090
+ let e = await this.#t.promises.readlink(this.fullpath()), s = (await this.parent.realpath())?.resolve(e);
4091
+ if (s) return this.#M = s;
4092
+ } catch (e) {
4093
+ this.#D(e.code);
4094
+ return;
4095
+ }
4096
+ }
4097
+ readlinkSync() {
4098
+ let t = this.#M;
4099
+ if (t) return t;
4100
+ if (this.canReadlink() && this.parent) try {
4101
+ let e = this.#t.readlinkSync(this.fullpath()), s = this.parent.realpathSync()?.resolve(e);
4102
+ if (s) return this.#M = s;
4103
+ } catch (e) {
4104
+ this.#D(e.code);
4105
+ return;
4106
+ }
4107
+ }
4108
+ #j(t) {
4109
+ this.#e |= se;
4110
+ for (let e = t.provisional; e < t.length; e++) {
4111
+ let s = t[e];
4112
+ s && s.#v();
4113
+ }
4114
+ }
4115
+ #v() {
4116
+ this.#e & j || (this.#e = (this.#e | j) & gt, this.#G());
4117
+ }
4118
+ #G() {
4119
+ let t = this.children();
4120
+ t.provisional = 0;
4121
+ for (let e of t) e.#v();
4122
+ }
4123
+ #P() {
4124
+ this.#e |= Lt, this.#L();
4125
+ }
4126
+ #L() {
4127
+ if (this.#e & yt) return;
4128
+ let t = this.#e;
4129
+ (t & _) === U && (t &= gt), this.#e = t | yt, this.#G();
4130
+ }
4131
+ #I(t = "") {
4132
+ t === "ENOTDIR" || t === "EPERM" ? this.#L() : t === "ENOENT" ? this.#v() : this.children().provisional = 0;
4133
+ }
4134
+ #F(t = "") {
4135
+ t === "ENOTDIR" ? this.parent.#L() : t === "ENOENT" && this.#v();
4136
+ }
4137
+ #D(t = "") {
4138
+ let e = this.#e;
4139
+ e |= Nt, t === "ENOENT" && (e |= j), (t === "EINVAL" || t === "UNKNOWN") && (e &= gt), this.#e = e, t === "ENOTDIR" && this.parent && this.parent.#L();
4140
+ }
4141
+ #z(t, e) {
4142
+ return this.#U(t, e) || this.#B(t, e);
4143
+ }
4144
+ #B(t, e) {
4145
+ let s = ie(t), i = this.newChild(t.name, s, { parent: this }), r = i.#e & _;
4146
+ return r !== U && r !== X && r !== L && (i.#e |= yt), e.unshift(i), e.provisional++, i;
4147
+ }
4148
+ #U(t, e) {
4149
+ for (let s = e.provisional; s < e.length; s++) {
4150
+ let i = e[s];
4151
+ if ((this.nocase ? _t(t.name) : bt(t.name)) === i.#C) return this.#l(t, i, s, e);
4152
+ }
4153
+ }
4154
+ #l(t, e, s, i) {
4155
+ let r = e.name;
4156
+ return e.#e = e.#e & gt | ie(t), r !== t.name && (e.name = t.name), s !== i.provisional && (s === i.length - 1 ? i.pop() : i.splice(s, 1), i.unshift(e)), i.provisional++, e;
4157
+ }
4158
+ async lstat() {
4159
+ if ((this.#e & j) === 0) try {
4160
+ return this.#$(await this.#t.promises.lstat(this.fullpath())), this;
4161
+ } catch (t) {
4162
+ this.#F(t.code);
4163
+ }
4164
+ }
4165
+ lstatSync() {
4166
+ if ((this.#e & j) === 0) try {
4167
+ return this.#$(this.#t.lstatSync(this.fullpath())), this;
4168
+ } catch (t) {
4169
+ this.#F(t.code);
4170
+ }
4171
+ }
4172
+ #$(t) {
4173
+ let { atime: e, atimeMs: s, birthtime: i, birthtimeMs: r, blksize: o, blocks: h, ctime: a, ctimeMs: l, dev: u, gid: c, ino: d, mode: f, mtime: m, mtimeMs: p, nlink: w, rdev: g, size: S, uid: E } = t;
4174
+ this.#b = e, this.#a = s, this.#m = i, this.#E = r, this.#c = o, this.#f = h, this.#R = a, this.#d = l, this.#s = u, this.#S = c, this.#h = d, this.#n = f, this.#p = m, this.#i = p, this.#r = w, this.#w = g, this.#u = S, this.#o = E;
4175
+ let y = ie(t);
4176
+ this.#e = this.#e & gt | y | je, y !== L && y !== U && y !== X && (this.#e |= yt);
4177
+ }
4178
+ #W = [];
4179
+ #O = !1;
4180
+ #H(t) {
4181
+ this.#O = !1;
4182
+ let e = this.#W.slice();
4183
+ this.#W.length = 0, e.forEach((s) => s(null, t));
4184
+ }
4185
+ readdirCB(t, e = !1) {
4186
+ if (!this.canReaddir()) {
4187
+ e ? t(null, []) : queueMicrotask(() => t(null, []));
4188
+ return;
4189
+ }
4190
+ let s = this.children();
4191
+ if (this.calledReaddir()) {
4192
+ let r = s.slice(0, s.provisional);
4193
+ e ? t(null, r) : queueMicrotask(() => t(null, r));
4194
+ return;
4195
+ }
4196
+ if (this.#W.push(t), this.#O) return;
4197
+ this.#O = !0;
4198
+ let i = this.fullpath();
4199
+ this.#t.readdir(i, { withFileTypes: !0 }, (r, o) => {
4200
+ if (r) this.#I(r.code), s.provisional = 0;
4201
+ else {
4202
+ for (let h of o) this.#z(h, s);
4203
+ this.#j(s);
4204
+ }
4205
+ this.#H(s.slice(0, s.provisional));
4206
+ });
4207
+ }
4208
+ #q;
4209
+ async readdir() {
4210
+ if (!this.canReaddir()) return [];
4211
+ let t = this.children();
4212
+ if (this.calledReaddir()) return t.slice(0, t.provisional);
4213
+ let e = this.fullpath();
4214
+ if (this.#q) await this.#q;
4215
+ else {
4216
+ let s = () => {};
4217
+ this.#q = new Promise((i) => s = i);
4218
+ try {
4219
+ for (let i of await this.#t.promises.readdir(e, { withFileTypes: !0 })) this.#z(i, t);
4220
+ this.#j(t);
4221
+ } catch (i) {
4222
+ this.#I(i.code), t.provisional = 0;
4223
+ }
4224
+ this.#q = void 0, s();
4225
+ }
4226
+ return t.slice(0, t.provisional);
4227
+ }
4228
+ readdirSync() {
4229
+ if (!this.canReaddir()) return [];
4230
+ let t = this.children();
4231
+ if (this.calledReaddir()) return t.slice(0, t.provisional);
4232
+ let e = this.fullpath();
4233
+ try {
4234
+ for (let s of this.#t.readdirSync(e, { withFileTypes: !0 })) this.#z(s, t);
4235
+ this.#j(t);
4236
+ } catch (s) {
4237
+ this.#I(s.code), t.provisional = 0;
4238
+ }
4239
+ return t.slice(0, t.provisional);
4240
+ }
4241
+ canReaddir() {
4242
+ if (this.#e & Ie) return !1;
4243
+ let t = _ & this.#e;
4244
+ return t === L || t === U || t === X;
4245
+ }
4246
+ shouldWalk(t, e) {
4247
+ return (this.#e & U) === U && !(this.#e & Ie) && !t.has(this) && (!e || e(this));
4248
+ }
4249
+ async realpath() {
4250
+ if (this.#k) return this.#k;
4251
+ if (!((Lt | Nt | j) & this.#e)) try {
4252
+ let t = await this.#t.promises.realpath(this.fullpath());
4253
+ return this.#k = this.resolve(t);
4254
+ } catch {
4255
+ this.#P();
4256
+ }
4257
+ }
4258
+ realpathSync() {
4259
+ if (this.#k) return this.#k;
4260
+ if (!((Lt | Nt | j) & this.#e)) try {
4261
+ let t = this.#t.realpathSync(this.fullpath());
4262
+ return this.#k = this.resolve(t);
4263
+ } catch {
4264
+ this.#P();
4265
+ }
4266
+ }
4267
+ [Ye](t) {
4268
+ if (t === this) return;
4269
+ t.isCWD = !1, this.isCWD = !0;
4270
+ let e = /* @__PURE__ */ new Set([]), s = [], i = this;
4271
+ for (; i && i.parent;) e.add(i), i.#x = s.join(this.sep), i.#A = s.join("/"), i = i.parent, s.push("..");
4272
+ for (i = t; i && i.parent && !e.has(i);) i.#x = void 0, i.#A = void 0, i = i.parent;
4273
+ }
4274
+ };
4275
+ var Pt = class n extends R {
4276
+ sep = "\\";
4277
+ splitSep = Oi;
4278
+ constructor(t, e = L, s, i, r, o, h) {
4279
+ super(t, e, s, i, r, o, h);
4280
+ }
4281
+ newChild(t, e = L, s = {}) {
4282
+ return new n(t, e, this.root, this.roots, this.nocase, this.childrenCache(), s);
4283
+ }
4284
+ getRootString(t) {
4285
+ return win32.parse(t).root;
4286
+ }
4287
+ getRoot(t) {
4288
+ if (t = Ri(t.toUpperCase()), t === this.root.name) return this.root;
4289
+ for (let [e, s] of Object.entries(this.roots)) if (this.sameRoot(t, e)) return this.roots[t] = s;
4290
+ return this.roots[t] = new it(t, this).root;
4291
+ }
4292
+ sameRoot(t, e = this.root.name) {
4293
+ return t = t.toUpperCase().replace(/\//g, "\\").replace($e, "$1\\"), t === e;
4294
+ }
4295
+ };
4296
+ var jt = class n extends R {
4297
+ splitSep = "/";
4298
+ sep = "/";
4299
+ constructor(t, e = L, s, i, r, o, h) {
4300
+ super(t, e, s, i, r, o, h);
4301
+ }
4302
+ getRootString(t) {
4303
+ return t.startsWith("/") ? "/" : "";
4304
+ }
4305
+ getRoot(t) {
4306
+ return this.root;
4307
+ }
4308
+ newChild(t, e = L, s = {}) {
4309
+ return new n(t, e, this.root, this.roots, this.nocase, this.childrenCache(), s);
4310
+ }
4311
+ };
4312
+ var It = class {
4313
+ root;
4314
+ rootPath;
4315
+ roots;
4316
+ cwd;
4317
+ #t;
4318
+ #s;
4319
+ #n;
4320
+ nocase;
4321
+ #r;
4322
+ constructor(t = process.cwd(), e, s, { nocase: i, childrenCacheSize: r = 16384, fs: o = wt } = {}) {
4323
+ this.#r = Ue(o), (t instanceof URL || t.startsWith("file://")) && (t = fileURLToPath(t));
4324
+ let h = e.resolve(t);
4325
+ this.roots = Object.create(null), this.rootPath = this.parseRootPath(h), this.#t = new Wt(), this.#s = new Wt(), this.#n = new ne(r);
4326
+ let a = h.substring(this.rootPath.length).split(s);
4327
+ if (a.length === 1 && !a[0] && a.pop(), i === void 0) throw new TypeError("must provide nocase setting to PathScurryBase ctor");
4328
+ this.nocase = i, this.root = this.newRoot(this.#r), this.roots[this.rootPath] = this.root;
4329
+ let l = this.root, u = a.length - 1, c = e.sep, d = this.rootPath, f = !1;
4330
+ for (let m of a) {
4331
+ let p = u--;
4332
+ l = l.child(m, {
4333
+ relative: new Array(p).fill("..").join(c),
4334
+ relativePosix: new Array(p).fill("..").join("/"),
4335
+ fullpath: d += (f ? "" : c) + m
4336
+ }), f = !0;
4337
+ }
4338
+ this.cwd = l;
4339
+ }
4340
+ depth(t = this.cwd) {
4341
+ return typeof t == "string" && (t = this.cwd.resolve(t)), t.depth();
4342
+ }
4343
+ childrenCache() {
4344
+ return this.#n;
4345
+ }
4346
+ resolve(...t) {
4347
+ let e = "";
4348
+ for (let r = t.length - 1; r >= 0; r--) {
4349
+ let o = t[r];
4350
+ if (!(!o || o === ".") && (e = e ? `${o}/${e}` : o, this.isAbsolute(o))) break;
4351
+ }
4352
+ let s = this.#t.get(e);
4353
+ if (s !== void 0) return s;
4354
+ let i = this.cwd.resolve(e).fullpath();
4355
+ return this.#t.set(e, i), i;
4356
+ }
4357
+ resolvePosix(...t) {
4358
+ let e = "";
4359
+ for (let r = t.length - 1; r >= 0; r--) {
4360
+ let o = t[r];
4361
+ if (!(!o || o === ".") && (e = e ? `${o}/${e}` : o, this.isAbsolute(o))) break;
4362
+ }
4363
+ let s = this.#s.get(e);
4364
+ if (s !== void 0) return s;
4365
+ let i = this.cwd.resolve(e).fullpathPosix();
4366
+ return this.#s.set(e, i), i;
4367
+ }
4368
+ relative(t = this.cwd) {
4369
+ return typeof t == "string" && (t = this.cwd.resolve(t)), t.relative();
4370
+ }
4371
+ relativePosix(t = this.cwd) {
4372
+ return typeof t == "string" && (t = this.cwd.resolve(t)), t.relativePosix();
4373
+ }
4374
+ basename(t = this.cwd) {
4375
+ return typeof t == "string" && (t = this.cwd.resolve(t)), t.name;
4376
+ }
4377
+ dirname(t = this.cwd) {
4378
+ return typeof t == "string" && (t = this.cwd.resolve(t)), (t.parent || t).fullpath();
4379
+ }
4380
+ async readdir(t = this.cwd, e = { withFileTypes: !0 }) {
4381
+ typeof t == "string" ? t = this.cwd.resolve(t) : t instanceof R || (e = t, t = this.cwd);
4382
+ let { withFileTypes: s } = e;
4383
+ if (t.canReaddir()) {
4384
+ let i = await t.readdir();
4385
+ return s ? i : i.map((r) => r.name);
4386
+ } else return [];
4387
+ }
4388
+ readdirSync(t = this.cwd, e = { withFileTypes: !0 }) {
4389
+ typeof t == "string" ? t = this.cwd.resolve(t) : t instanceof R || (e = t, t = this.cwd);
4390
+ let { withFileTypes: s = !0 } = e;
4391
+ return t.canReaddir() ? s ? t.readdirSync() : t.readdirSync().map((i) => i.name) : [];
4392
+ }
4393
+ async lstat(t = this.cwd) {
4394
+ return typeof t == "string" && (t = this.cwd.resolve(t)), t.lstat();
4395
+ }
4396
+ lstatSync(t = this.cwd) {
4397
+ return typeof t == "string" && (t = this.cwd.resolve(t)), t.lstatSync();
4398
+ }
4399
+ async readlink(t = this.cwd, { withFileTypes: e } = { withFileTypes: !1 }) {
4400
+ typeof t == "string" ? t = this.cwd.resolve(t) : t instanceof R || (e = t.withFileTypes, t = this.cwd);
4401
+ let s = await t.readlink();
4402
+ return e ? s : s?.fullpath();
4403
+ }
4404
+ readlinkSync(t = this.cwd, { withFileTypes: e } = { withFileTypes: !1 }) {
4405
+ typeof t == "string" ? t = this.cwd.resolve(t) : t instanceof R || (e = t.withFileTypes, t = this.cwd);
4406
+ let s = t.readlinkSync();
4407
+ return e ? s : s?.fullpath();
4408
+ }
4409
+ async realpath(t = this.cwd, { withFileTypes: e } = { withFileTypes: !1 }) {
4410
+ typeof t == "string" ? t = this.cwd.resolve(t) : t instanceof R || (e = t.withFileTypes, t = this.cwd);
4411
+ let s = await t.realpath();
4412
+ return e ? s : s?.fullpath();
4413
+ }
4414
+ realpathSync(t = this.cwd, { withFileTypes: e } = { withFileTypes: !1 }) {
4415
+ typeof t == "string" ? t = this.cwd.resolve(t) : t instanceof R || (e = t.withFileTypes, t = this.cwd);
4416
+ let s = t.realpathSync();
4417
+ return e ? s : s?.fullpath();
4418
+ }
4419
+ async walk(t = this.cwd, e = {}) {
4420
+ typeof t == "string" ? t = this.cwd.resolve(t) : t instanceof R || (e = t, t = this.cwd);
4421
+ let { withFileTypes: s = !0, follow: i = !1, filter: r, walkFilter: o } = e, h = [];
4422
+ (!r || r(t)) && h.push(s ? t : t.fullpath());
4423
+ let a = /* @__PURE__ */ new Set(), l = (c, d) => {
4424
+ a.add(c), c.readdirCB((f, m) => {
4425
+ if (f) return d(f);
4426
+ let p = m.length;
4427
+ if (!p) return d();
4428
+ let w = () => {
4429
+ --p === 0 && d();
4430
+ };
4431
+ for (let g of m) (!r || r(g)) && h.push(s ? g : g.fullpath()), i && g.isSymbolicLink() ? g.realpath().then((S) => S?.isUnknown() ? S.lstat() : S).then((S) => S?.shouldWalk(a, o) ? l(S, w) : w()) : g.shouldWalk(a, o) ? l(g, w) : w();
4432
+ }, !0);
4433
+ }, u = t;
4434
+ return new Promise((c, d) => {
4435
+ l(u, (f) => {
4436
+ if (f) return d(f);
4437
+ c(h);
4438
+ });
4439
+ });
4440
+ }
4441
+ walkSync(t = this.cwd, e = {}) {
4442
+ typeof t == "string" ? t = this.cwd.resolve(t) : t instanceof R || (e = t, t = this.cwd);
4443
+ let { withFileTypes: s = !0, follow: i = !1, filter: r, walkFilter: o } = e, h = [];
4444
+ (!r || r(t)) && h.push(s ? t : t.fullpath());
4445
+ let a = /* @__PURE__ */ new Set([t]);
4446
+ for (let l of a) {
4447
+ let u = l.readdirSync();
4448
+ for (let c of u) {
4449
+ (!r || r(c)) && h.push(s ? c : c.fullpath());
4450
+ let d = c;
4451
+ if (c.isSymbolicLink()) {
4452
+ if (!(i && (d = c.realpathSync()))) continue;
4453
+ d.isUnknown() && d.lstatSync();
4454
+ }
4455
+ d.shouldWalk(a, o) && a.add(d);
4456
+ }
4457
+ }
4458
+ return h;
4459
+ }
4460
+ [Symbol.asyncIterator]() {
4461
+ return this.iterate();
4462
+ }
4463
+ iterate(t = this.cwd, e = {}) {
4464
+ return typeof t == "string" ? t = this.cwd.resolve(t) : t instanceof R || (e = t, t = this.cwd), this.stream(t, e)[Symbol.asyncIterator]();
4465
+ }
4466
+ [Symbol.iterator]() {
4467
+ return this.iterateSync();
4468
+ }
4469
+ *iterateSync(t = this.cwd, e = {}) {
4470
+ typeof t == "string" ? t = this.cwd.resolve(t) : t instanceof R || (e = t, t = this.cwd);
4471
+ let { withFileTypes: s = !0, follow: i = !1, filter: r, walkFilter: o } = e;
4472
+ (!r || r(t)) && (yield s ? t : t.fullpath());
4473
+ let h = /* @__PURE__ */ new Set([t]);
4474
+ for (let a of h) {
4475
+ let l = a.readdirSync();
4476
+ for (let u of l) {
4477
+ (!r || r(u)) && (yield s ? u : u.fullpath());
4478
+ let c = u;
4479
+ if (u.isSymbolicLink()) {
4480
+ if (!(i && (c = u.realpathSync()))) continue;
4481
+ c.isUnknown() && c.lstatSync();
4482
+ }
4483
+ c.shouldWalk(h, o) && h.add(c);
4484
+ }
4485
+ }
4486
+ }
4487
+ stream(t = this.cwd, e = {}) {
4488
+ typeof t == "string" ? t = this.cwd.resolve(t) : t instanceof R || (e = t, t = this.cwd);
4489
+ let { withFileTypes: s = !0, follow: i = !1, filter: r, walkFilter: o } = e, h = new V({ objectMode: !0 });
4490
+ (!r || r(t)) && h.write(s ? t : t.fullpath());
4491
+ let a = /* @__PURE__ */ new Set(), l = [t], u = 0, c = () => {
4492
+ let d = !1;
4493
+ for (; !d;) {
4494
+ let f = l.shift();
4495
+ if (!f) {
4496
+ u === 0 && h.end();
4497
+ return;
4498
+ }
4499
+ u++, a.add(f);
4500
+ let m = (w, g, S = !1) => {
4501
+ if (w) return h.emit("error", w);
4502
+ if (i && !S) {
4503
+ let E = [];
4504
+ for (let y of g) y.isSymbolicLink() && E.push(y.realpath().then((b) => b?.isUnknown() ? b.lstat() : b));
4505
+ if (E.length) {
4506
+ Promise.all(E).then(() => m(null, g, !0));
4507
+ return;
4508
+ }
4509
+ }
4510
+ for (let E of g) E && (!r || r(E)) && (h.write(s ? E : E.fullpath()) || (d = !0));
4511
+ u--;
4512
+ for (let E of g) {
4513
+ let y = E.realpathCached() || E;
4514
+ y.shouldWalk(a, o) && l.push(y);
4515
+ }
4516
+ d && !h.flowing ? h.once("drain", c) : p || c();
4517
+ }, p = !0;
4518
+ f.readdirCB(m, !0), p = !1;
4519
+ }
4520
+ };
4521
+ return c(), h;
4522
+ }
4523
+ streamSync(t = this.cwd, e = {}) {
4524
+ typeof t == "string" ? t = this.cwd.resolve(t) : t instanceof R || (e = t, t = this.cwd);
4525
+ let { withFileTypes: s = !0, follow: i = !1, filter: r, walkFilter: o } = e, h = new V({ objectMode: !0 }), a = /* @__PURE__ */ new Set();
4526
+ (!r || r(t)) && h.write(s ? t : t.fullpath());
4527
+ let l = [t], u = 0, c = () => {
4528
+ let d = !1;
4529
+ for (; !d;) {
4530
+ let f = l.shift();
4531
+ if (!f) {
4532
+ u === 0 && h.end();
4533
+ return;
4534
+ }
4535
+ u++, a.add(f);
4536
+ let m = f.readdirSync();
4537
+ for (let p of m) (!r || r(p)) && (h.write(s ? p : p.fullpath()) || (d = !0));
4538
+ u--;
4539
+ for (let p of m) {
4540
+ let w = p;
4541
+ if (p.isSymbolicLink()) {
4542
+ if (!(i && (w = p.realpathSync()))) continue;
4543
+ w.isUnknown() && w.lstatSync();
4544
+ }
4545
+ w.shouldWalk(a, o) && l.push(w);
1714
4546
  }
1715
- if (attempt < 3) await new Promise((resolve) => setTimeout(resolve, attempt * 1e3));
1716
- }
1717
- if (!response || !response.body) {
1718
- if (lastErr instanceof LuaLSError) throw lastErr;
1719
- throw new LuaLSError(`Failed to download LuaLS from ${url}${lastErr ? `: ${lastErr instanceof Error ? lastErr.message : String(lastErr)}` : ""}`, "ERR_LUALS_DOWNLOAD", "Check your network connection or specify a custom binary with LUALS_BIN.", { cause: lastErr });
1720
- }
1721
- const arrayBuffer = await response.arrayBuffer();
1722
- fs.writeFileSync(archivePath, Buffer.from(arrayBuffer));
1723
- if (!options?.quiet) logger.info(`[luals] Extracting to ${destDir}...`);
1724
- try {
1725
- await execFileAsync$1("tar", [
1726
- "-xf",
1727
- archivePath,
1728
- "-C",
1729
- tempDir
1730
- ]);
1731
- } catch (tarErr) {
1732
- if (process.platform === "win32" && info.assetName.endsWith(".zip")) await execFileAsync$1("powershell.exe", [
1733
- "-NoProfile",
1734
- "-Command",
1735
- `Expand-Archive -Path '${escapePowerShellSingleQuote(archivePath)}' -DestinationPath '${escapePowerShellSingleQuote(tempDir)}' -Force`
1736
- ]);
1737
- else throw tarErr;
1738
4547
  }
1739
- try {
1740
- fs.unlinkSync(archivePath);
1741
- } catch (err) {
1742
- logger.debug(`[luals] Failed to delete temporary archive ${archivePath}: ${err instanceof Error ? err.message : String(err)}`);
4548
+ d && !h.flowing && h.once("drain", c);
4549
+ };
4550
+ return c(), h;
4551
+ }
4552
+ chdir(t = this.cwd) {
4553
+ let e = this.cwd;
4554
+ this.cwd = typeof t == "string" ? this.cwd.resolve(t) : t, this.cwd[Ye](e);
4555
+ }
4556
+ };
4557
+ var it = class extends It {
4558
+ sep = "\\";
4559
+ constructor(t = process.cwd(), e = {}) {
4560
+ let { nocase: s = !0 } = e;
4561
+ super(t, win32, "\\", {
4562
+ ...e,
4563
+ nocase: s
4564
+ }), this.nocase = s;
4565
+ for (let i = this.cwd; i; i = i.parent) i.nocase = this.nocase;
4566
+ }
4567
+ parseRootPath(t) {
4568
+ return win32.parse(t).root.toUpperCase();
4569
+ }
4570
+ newRoot(t) {
4571
+ return new Pt(this.rootPath, U, void 0, this.roots, this.nocase, this.childrenCache(), { fs: t });
4572
+ }
4573
+ isAbsolute(t) {
4574
+ return t.startsWith("/") || t.startsWith("\\") || /^[a-z]:(\/|\\)/i.test(t);
4575
+ }
4576
+ };
4577
+ var rt = class extends It {
4578
+ sep = "/";
4579
+ constructor(t = process.cwd(), e = {}) {
4580
+ let { nocase: s = !1 } = e;
4581
+ super(t, posix, "/", {
4582
+ ...e,
4583
+ nocase: s
4584
+ }), this.nocase = s;
4585
+ }
4586
+ parseRootPath(t) {
4587
+ return "/";
4588
+ }
4589
+ newRoot(t) {
4590
+ return new jt(this.rootPath, U, void 0, this.roots, this.nocase, this.childrenCache(), { fs: t });
4591
+ }
4592
+ isAbsolute(t) {
4593
+ return t.startsWith("/");
4594
+ }
4595
+ };
4596
+ var St = class extends rt {
4597
+ constructor(t = process.cwd(), e = {}) {
4598
+ let { nocase: s = !0 } = e;
4599
+ super(t, {
4600
+ ...e,
4601
+ nocase: s
4602
+ });
4603
+ }
4604
+ };
4605
+ process.platform;
4606
+ var Xe = process.platform === "win32" ? it : process.platform === "darwin" ? St : rt;
4607
+ var Di = (n) => n.length >= 1;
4608
+ var Mi = (n) => n.length >= 1;
4609
+ var Ni = Symbol.for("nodejs.util.inspect.custom");
4610
+ var nt = class n {
4611
+ #t;
4612
+ #s;
4613
+ #n;
4614
+ length;
4615
+ #r;
4616
+ #o;
4617
+ #S;
4618
+ #w;
4619
+ #c;
4620
+ #h;
4621
+ #u = !0;
4622
+ constructor(t, e, s, i) {
4623
+ if (!Di(t)) throw new TypeError("empty pattern list");
4624
+ if (!Mi(e)) throw new TypeError("empty glob list");
4625
+ if (e.length !== t.length) throw new TypeError("mismatched pattern list and glob list lengths");
4626
+ if (this.length = t.length, s < 0 || s >= this.length) throw new TypeError("index out of range");
4627
+ if (this.#t = t, this.#s = e, this.#n = s, this.#r = i, this.#n === 0) {
4628
+ if (this.isUNC()) {
4629
+ let [r, o, h, a, ...l] = this.#t, [u, c, d, f, ...m] = this.#s;
4630
+ l[0] === "" && (l.shift(), m.shift());
4631
+ let p = [
4632
+ r,
4633
+ o,
4634
+ h,
4635
+ a,
4636
+ ""
4637
+ ].join("/"), w = [
4638
+ u,
4639
+ c,
4640
+ d,
4641
+ f,
4642
+ ""
4643
+ ].join("/");
4644
+ this.#t = [p, ...l], this.#s = [w, ...m], this.length = this.#t.length;
4645
+ } else if (this.isDrive() || this.isAbsolute()) {
4646
+ let [r, ...o] = this.#t, [h, ...a] = this.#s;
4647
+ o[0] === "" && (o.shift(), a.shift());
4648
+ let l = r + "/", u = h + "/";
4649
+ this.#t = [l, ...o], this.#s = [u, ...a], this.length = this.#t.length;
1743
4650
  }
1744
4651
  }
1745
- const tempBinaryPath = path.join(tempDir, info.binaryRelativePath);
1746
- if (process.platform !== "win32") try {
1747
- fs.chmodSync(tempBinaryPath, 493);
1748
- } catch (err) {
1749
- logger.warn(`[luals] Failed to chmod binary at ${tempBinaryPath}: ${err instanceof Error ? err.message : String(err)}`);
4652
+ }
4653
+ [Ni]() {
4654
+ return "Pattern <" + this.#s.slice(this.#n).join("/") + ">";
4655
+ }
4656
+ pattern() {
4657
+ return this.#t[this.#n];
4658
+ }
4659
+ isString() {
4660
+ return typeof this.#t[this.#n] == "string";
4661
+ }
4662
+ isGlobstar() {
4663
+ return this.#t[this.#n] === A;
4664
+ }
4665
+ isRegExp() {
4666
+ return this.#t[this.#n] instanceof RegExp;
4667
+ }
4668
+ globString() {
4669
+ return this.#S = this.#S || (this.#n === 0 ? this.isAbsolute() ? this.#s[0] + this.#s.slice(1).join("/") : this.#s.join("/") : this.#s.slice(this.#n).join("/"));
4670
+ }
4671
+ hasMore() {
4672
+ return this.length > this.#n + 1;
4673
+ }
4674
+ rest() {
4675
+ return this.#o !== void 0 ? this.#o : this.hasMore() ? (this.#o = new n(this.#t, this.#s, this.#n + 1, this.#r), this.#o.#h = this.#h, this.#o.#c = this.#c, this.#o.#w = this.#w, this.#o) : this.#o = null;
4676
+ }
4677
+ isUNC() {
4678
+ let t = this.#t;
4679
+ return this.#c !== void 0 ? this.#c : this.#c = this.#r === "win32" && this.#n === 0 && t[0] === "" && t[1] === "" && typeof t[2] == "string" && !!t[2] && typeof t[3] == "string" && !!t[3];
4680
+ }
4681
+ isDrive() {
4682
+ let t = this.#t;
4683
+ return this.#w !== void 0 ? this.#w : this.#w = this.#r === "win32" && this.#n === 0 && this.length > 1 && typeof t[0] == "string" && /^[a-z]:$/i.test(t[0]);
4684
+ }
4685
+ isAbsolute() {
4686
+ let t = this.#t;
4687
+ return this.#h !== void 0 ? this.#h : this.#h = t[0] === "" && t.length > 1 || this.isDrive() || this.isUNC();
4688
+ }
4689
+ root() {
4690
+ let t = this.#t[0];
4691
+ return typeof t == "string" && this.isAbsolute() && this.#n === 0 ? t : "";
4692
+ }
4693
+ checkFollowGlobstar() {
4694
+ return !(this.#n === 0 || !this.isGlobstar() || !this.#u);
4695
+ }
4696
+ markFollowGlobstar() {
4697
+ return this.#n === 0 || !this.isGlobstar() || !this.#u ? !1 : (this.#u = !1, !0);
4698
+ }
4699
+ };
4700
+ var _i = typeof process == "object" && process && typeof process.platform == "string" ? process.platform : "linux";
4701
+ var ot = class {
4702
+ relative;
4703
+ relativeChildren;
4704
+ absolute;
4705
+ absoluteChildren;
4706
+ platform;
4707
+ mmopts;
4708
+ constructor(t, { nobrace: e, nocase: s, noext: i, noglobstar: r, platform: o = _i }) {
4709
+ this.relative = [], this.absolute = [], this.relativeChildren = [], this.absoluteChildren = [], this.platform = o, this.mmopts = {
4710
+ dot: !0,
4711
+ nobrace: e,
4712
+ nocase: s,
4713
+ noext: i,
4714
+ noglobstar: r,
4715
+ optimizationLevel: 2,
4716
+ platform: o,
4717
+ nocomment: !0,
4718
+ nonegate: !0
4719
+ };
4720
+ for (let h of t) this.add(h);
4721
+ }
4722
+ add(t) {
4723
+ let e = new D(t, this.mmopts);
4724
+ for (let s = 0; s < e.set.length; s++) {
4725
+ let i = e.set[s], r = e.globParts[s];
4726
+ if (!i || !r) throw new Error("invalid pattern object");
4727
+ for (; i[0] === "." && r[0] === ".";) i.shift(), r.shift();
4728
+ let o = new nt(i, r, 0, this.platform), h = new D(o.globString(), this.mmopts), a = r[r.length - 1] === "**", l = o.isAbsolute();
4729
+ l ? this.absolute.push(h) : this.relative.push(h), a && (l ? this.absoluteChildren.push(h) : this.relativeChildren.push(h));
1750
4730
  }
1751
- if (!fs.existsSync(tempBinaryPath) || fs.statSync(tempBinaryPath).size < 1e5) throw new LuaLSError(`Failed to extract valid LuaLS binary to expected path: ${tempBinaryPath}`, "ERR_LUALS_EXTRACT", "Run 'nanos-lint clean-cache' and ensure there is sufficient disk space.");
1752
- if (!isBinaryValid(tempBinaryPath)) throw new LuaLSError(`Extracted LuaLS binary at ${tempBinaryPath} is invalid or non-functional.`, "ERR_LUALS_INVALID_BINARY", "Run 'nanos-lint clean-cache' to remove corrupted downloads or set LUALS_BIN to a custom binary.");
1753
- fs.writeFileSync(path.join(tempDir, ".complete"), resolvedVersion, "utf-8");
1754
- for (let attempt = 0; attempt < 5; attempt++) try {
1755
- fs.renameSync(tempDir, destDir);
1756
- break;
1757
- } catch (renameErr) {
1758
- if (fs.existsSync(binaryPath) && isBinaryValid(binaryPath)) {
1759
- try {
1760
- fs.rmSync(tempDir, {
1761
- recursive: true,
1762
- force: true
1763
- });
1764
- } catch (err) {
1765
- logger.debug(`[luals] Failed to remove temp directory after concurrent promotion: ${err instanceof Error ? err.message : String(err)}`);
4731
+ }
4732
+ ignored(t) {
4733
+ let e = t.fullpath(), s = `${e}/`, i = t.relative() || ".", r = `${i}/`;
4734
+ for (let o of this.relative) if (o.match(i) || o.match(r)) return !0;
4735
+ for (let o of this.absolute) if (o.match(e) || o.match(s)) return !0;
4736
+ return !1;
4737
+ }
4738
+ childrenIgnored(t) {
4739
+ let e = t.fullpath() + "/", s = (t.relative() || ".") + "/";
4740
+ for (let i of this.relativeChildren) if (i.match(s)) return !0;
4741
+ for (let i of this.absoluteChildren) if (i.match(e)) return !0;
4742
+ return !1;
4743
+ }
4744
+ };
4745
+ var oe = class n {
4746
+ store;
4747
+ constructor(t = /* @__PURE__ */ new Map()) {
4748
+ this.store = t;
4749
+ }
4750
+ copy() {
4751
+ return new n(new Map(this.store));
4752
+ }
4753
+ hasWalked(t, e) {
4754
+ return this.store.get(t.fullpath())?.has(e.globString());
4755
+ }
4756
+ storeWalked(t, e) {
4757
+ let s = t.fullpath(), i = this.store.get(s);
4758
+ i ? i.add(e.globString()) : this.store.set(s, /* @__PURE__ */ new Set([e.globString()]));
4759
+ }
4760
+ };
4761
+ var he = class {
4762
+ store = /* @__PURE__ */ new Map();
4763
+ add(t, e, s) {
4764
+ let i = (e ? 2 : 0) | (s ? 1 : 0), r = this.store.get(t);
4765
+ this.store.set(t, r === void 0 ? i : i & r);
4766
+ }
4767
+ entries() {
4768
+ return [...this.store.entries()].map(([t, e]) => [
4769
+ t,
4770
+ !!(e & 2),
4771
+ !!(e & 1)
4772
+ ]);
4773
+ }
4774
+ };
4775
+ var ae = class {
4776
+ store = /* @__PURE__ */ new Map();
4777
+ add(t, e) {
4778
+ if (!t.canReaddir()) return;
4779
+ let s = this.store.get(t);
4780
+ s ? s.find((i) => i.globString() === e.globString()) || s.push(e) : this.store.set(t, [e]);
4781
+ }
4782
+ get(t) {
4783
+ let e = this.store.get(t);
4784
+ if (!e) throw new Error("attempting to walk unknown path");
4785
+ return e;
4786
+ }
4787
+ entries() {
4788
+ return this.keys().map((t) => [t, this.store.get(t)]);
4789
+ }
4790
+ keys() {
4791
+ return [...this.store.keys()].filter((t) => t.canReaddir());
4792
+ }
4793
+ };
4794
+ var Et = class n {
4795
+ hasWalkedCache;
4796
+ matches = new he();
4797
+ subwalks = new ae();
4798
+ patterns;
4799
+ follow;
4800
+ dot;
4801
+ opts;
4802
+ constructor(t, e) {
4803
+ this.opts = t, this.follow = !!t.follow, this.dot = !!t.dot, this.hasWalkedCache = e ? e.copy() : new oe();
4804
+ }
4805
+ processPatterns(t, e) {
4806
+ this.patterns = e;
4807
+ let s = e.map((i) => [t, i]);
4808
+ for (let [i, r] of s) {
4809
+ this.hasWalkedCache.storeWalked(i, r);
4810
+ let o = r.root(), h = r.isAbsolute() && this.opts.absolute !== !1;
4811
+ if (o) {
4812
+ i = i.resolve(o === "/" && this.opts.root !== void 0 ? this.opts.root : o);
4813
+ let c = r.rest();
4814
+ if (c) r = c;
4815
+ else {
4816
+ this.matches.add(i, !0, !1);
4817
+ continue;
1766
4818
  }
1767
- if (!options?.quiet) logger.info(`[luals] Ready: ${binaryPath}`);
1768
- return binaryPath;
1769
4819
  }
1770
- if (attempt < 4) await new Promise((resolve) => setTimeout(resolve, 100 * (attempt + 1)));
1771
- else {
1772
- if (fs.existsSync(destDir) && (!fs.existsSync(binaryPath) || !fs.existsSync(completeMarker))) try {
1773
- fs.rmSync(destDir, {
1774
- recursive: true,
1775
- force: true
1776
- });
1777
- } catch (err) {
1778
- logger.warn(`[luals] Failed to clean up broken destination directory ${destDir}: ${err instanceof Error ? err.message : String(err)}`);
1779
- }
1780
- throw renameErr;
4820
+ if (i.isENOENT()) continue;
4821
+ let a, l, u = !1;
4822
+ for (; typeof (a = r.pattern()) == "string" && (l = r.rest());) i = i.resolve(a), r = l, u = !0;
4823
+ if (a = r.pattern(), l = r.rest(), u) {
4824
+ if (this.hasWalkedCache.hasWalked(i, r)) continue;
4825
+ this.hasWalkedCache.storeWalked(i, r);
1781
4826
  }
4827
+ if (typeof a == "string") {
4828
+ let c = a === ".." || a === "" || a === ".";
4829
+ this.matches.add(i.resolve(a), h, c);
4830
+ continue;
4831
+ } else if (a === A) {
4832
+ (!i.isSymbolicLink() || this.follow || r.checkFollowGlobstar()) && this.subwalks.add(i, r);
4833
+ let c = l?.pattern(), d = l?.rest();
4834
+ if (!l || (c === "" || c === ".") && !d) this.matches.add(i, h, c === "" || c === ".");
4835
+ else if (c === "..") {
4836
+ let f = i.parent || i;
4837
+ d ? this.hasWalkedCache.hasWalked(f, d) || this.subwalks.add(f, d) : this.matches.add(f, h, !0);
4838
+ }
4839
+ } else a instanceof RegExp && this.subwalks.add(i, r);
1782
4840
  }
1783
- if (!options?.quiet) logger.info(`[luals] Ready: ${binaryPath}`);
1784
- return binaryPath;
1785
- } finally {
1786
- if (fs.existsSync(tempDir)) try {
1787
- fs.rmSync(tempDir, {
1788
- recursive: true,
1789
- force: true
4841
+ return this;
4842
+ }
4843
+ subwalkTargets() {
4844
+ return this.subwalks.keys();
4845
+ }
4846
+ child() {
4847
+ return new n(this.opts, this.hasWalkedCache);
4848
+ }
4849
+ filterEntries(t, e) {
4850
+ let s = this.subwalks.get(t), i = this.child();
4851
+ for (let r of e) for (let o of s) {
4852
+ let h = o.isAbsolute(), a = o.pattern(), l = o.rest();
4853
+ a === A ? i.testGlobstar(r, o, l, h) : a instanceof RegExp ? i.testRegExp(r, a, l, h) : i.testString(r, a, l, h);
4854
+ }
4855
+ return i;
4856
+ }
4857
+ testGlobstar(t, e, s, i) {
4858
+ if ((this.dot || !t.name.startsWith(".")) && (e.hasMore() || this.matches.add(t, i, !1), t.canReaddir() && (this.follow || !t.isSymbolicLink() ? this.subwalks.add(t, e) : t.isSymbolicLink() && (s && e.checkFollowGlobstar() ? this.subwalks.add(t, s) : e.markFollowGlobstar() && this.subwalks.add(t, e)))), s) {
4859
+ let r = s.pattern();
4860
+ if (typeof r == "string" && r !== ".." && r !== "" && r !== ".") this.testString(t, r, s.rest(), i);
4861
+ else if (r === "..") {
4862
+ let o = t.parent || t;
4863
+ this.subwalks.add(o, s);
4864
+ } else r instanceof RegExp && this.testRegExp(t, r, s.rest(), i);
4865
+ }
4866
+ }
4867
+ testRegExp(t, e, s, i) {
4868
+ e.test(t.name) && (s ? this.subwalks.add(t, s) : this.matches.add(t, i, !1));
4869
+ }
4870
+ testString(t, e, s, i) {
4871
+ t.isNamed(e) && (s ? this.subwalks.add(t, s) : this.matches.add(t, i, !1));
4872
+ }
4873
+ };
4874
+ var Li = (n, t) => typeof n == "string" ? new ot([n], t) : Array.isArray(n) ? new ot(n, t) : n;
4875
+ var zt = class {
4876
+ path;
4877
+ patterns;
4878
+ opts;
4879
+ seen = /* @__PURE__ */ new Set();
4880
+ paused = !1;
4881
+ aborted = !1;
4882
+ #t = [];
4883
+ #s;
4884
+ #n;
4885
+ signal;
4886
+ maxDepth;
4887
+ includeChildMatches;
4888
+ constructor(t, e, s) {
4889
+ if (this.patterns = t, this.path = e, this.opts = s, this.#n = !s.posix && s.platform === "win32" ? "\\" : "/", this.includeChildMatches = s.includeChildMatches !== !1, (s.ignore || !this.includeChildMatches) && (this.#s = Li(s.ignore ?? [], s), !this.includeChildMatches && typeof this.#s.add != "function")) throw new Error("cannot ignore child matches, ignore lacks add() method.");
4890
+ this.maxDepth = s.maxDepth || 1 / 0, s.signal && (this.signal = s.signal, this.signal.addEventListener("abort", () => {
4891
+ this.#t.length = 0;
4892
+ }));
4893
+ }
4894
+ #r(t) {
4895
+ return this.seen.has(t) || !!this.#s?.ignored?.(t);
4896
+ }
4897
+ #o(t) {
4898
+ return !!this.#s?.childrenIgnored?.(t);
4899
+ }
4900
+ pause() {
4901
+ this.paused = !0;
4902
+ }
4903
+ resume() {
4904
+ if (this.signal?.aborted) return;
4905
+ this.paused = !1;
4906
+ let t;
4907
+ for (; !this.paused && (t = this.#t.shift());) t();
4908
+ }
4909
+ onResume(t) {
4910
+ this.signal?.aborted || (this.paused ? this.#t.push(t) : t());
4911
+ }
4912
+ async matchCheck(t, e) {
4913
+ if (e && this.opts.nodir) return;
4914
+ let s;
4915
+ if (this.opts.realpath) {
4916
+ if (s = t.realpathCached() || await t.realpath(), !s) return;
4917
+ t = s;
4918
+ }
4919
+ let r = t.isUnknown() || this.opts.stat ? await t.lstat() : t;
4920
+ if (this.opts.follow && this.opts.nodir && r?.isSymbolicLink()) {
4921
+ let o = await r.realpath();
4922
+ o && (o.isUnknown() || this.opts.stat) && await o.lstat();
4923
+ }
4924
+ return this.matchCheckTest(r, e);
4925
+ }
4926
+ matchCheckTest(t, e) {
4927
+ return t && (this.maxDepth === 1 / 0 || t.depth() <= this.maxDepth) && (!e || t.canReaddir()) && (!this.opts.nodir || !t.isDirectory()) && (!this.opts.nodir || !this.opts.follow || !t.isSymbolicLink() || !t.realpathCached()?.isDirectory()) && !this.#r(t) ? t : void 0;
4928
+ }
4929
+ matchCheckSync(t, e) {
4930
+ if (e && this.opts.nodir) return;
4931
+ let s;
4932
+ if (this.opts.realpath) {
4933
+ if (s = t.realpathCached() || t.realpathSync(), !s) return;
4934
+ t = s;
4935
+ }
4936
+ let r = t.isUnknown() || this.opts.stat ? t.lstatSync() : t;
4937
+ if (this.opts.follow && this.opts.nodir && r?.isSymbolicLink()) {
4938
+ let o = r.realpathSync();
4939
+ o && (o?.isUnknown() || this.opts.stat) && o.lstatSync();
4940
+ }
4941
+ return this.matchCheckTest(r, e);
4942
+ }
4943
+ matchFinish(t, e) {
4944
+ if (this.#r(t)) return;
4945
+ if (!this.includeChildMatches && this.#s?.add) {
4946
+ let r = `${t.relativePosix()}/**`;
4947
+ this.#s.add(r);
4948
+ }
4949
+ let s = this.opts.absolute === void 0 ? e : this.opts.absolute;
4950
+ this.seen.add(t);
4951
+ let i = this.opts.mark && t.isDirectory() ? this.#n : "";
4952
+ if (this.opts.withFileTypes) this.matchEmit(t);
4953
+ else if (s) {
4954
+ let r = this.opts.posix ? t.fullpathPosix() : t.fullpath();
4955
+ this.matchEmit(r + i);
4956
+ } else {
4957
+ let r = this.opts.posix ? t.relativePosix() : t.relative(), o = this.opts.dotRelative && !r.startsWith(".." + this.#n) ? "." + this.#n : "";
4958
+ this.matchEmit(r ? o + r + i : "." + i);
4959
+ }
4960
+ }
4961
+ async match(t, e, s) {
4962
+ let i = await this.matchCheck(t, s);
4963
+ i && this.matchFinish(i, e);
4964
+ }
4965
+ matchSync(t, e, s) {
4966
+ let i = this.matchCheckSync(t, s);
4967
+ i && this.matchFinish(i, e);
4968
+ }
4969
+ walkCB(t, e, s) {
4970
+ this.signal?.aborted && s(), this.walkCB2(t, e, new Et(this.opts), s);
4971
+ }
4972
+ walkCB2(t, e, s, i) {
4973
+ if (this.#o(t)) return i();
4974
+ if (this.signal?.aborted && i(), this.paused) {
4975
+ this.onResume(() => this.walkCB2(t, e, s, i));
4976
+ return;
4977
+ }
4978
+ s.processPatterns(t, e);
4979
+ let r = 1, o = () => {
4980
+ --r === 0 && i();
4981
+ };
4982
+ for (let [h, a, l] of s.matches.entries()) this.#r(h) || (r++, this.match(h, a, l).then(() => o()));
4983
+ for (let h of s.subwalkTargets()) {
4984
+ if (this.maxDepth !== 1 / 0 && h.depth() >= this.maxDepth) continue;
4985
+ r++;
4986
+ let a = h.readdirCached();
4987
+ h.calledReaddir() ? this.walkCB3(h, a, s, o) : h.readdirCB((l, u) => this.walkCB3(h, u, s, o), !0);
4988
+ }
4989
+ o();
4990
+ }
4991
+ walkCB3(t, e, s, i) {
4992
+ s = s.filterEntries(t, e);
4993
+ let r = 1, o = () => {
4994
+ --r === 0 && i();
4995
+ };
4996
+ for (let [h, a, l] of s.matches.entries()) this.#r(h) || (r++, this.match(h, a, l).then(() => o()));
4997
+ for (let [h, a] of s.subwalks.entries()) r++, this.walkCB2(h, a, s.child(), o);
4998
+ o();
4999
+ }
5000
+ walkCBSync(t, e, s) {
5001
+ this.signal?.aborted && s(), this.walkCB2Sync(t, e, new Et(this.opts), s);
5002
+ }
5003
+ walkCB2Sync(t, e, s, i) {
5004
+ if (this.#o(t)) return i();
5005
+ if (this.signal?.aborted && i(), this.paused) {
5006
+ this.onResume(() => this.walkCB2Sync(t, e, s, i));
5007
+ return;
5008
+ }
5009
+ s.processPatterns(t, e);
5010
+ let r = 1, o = () => {
5011
+ --r === 0 && i();
5012
+ };
5013
+ for (let [h, a, l] of s.matches.entries()) this.#r(h) || this.matchSync(h, a, l);
5014
+ for (let h of s.subwalkTargets()) {
5015
+ if (this.maxDepth !== 1 / 0 && h.depth() >= this.maxDepth) continue;
5016
+ r++;
5017
+ let a = h.readdirSync();
5018
+ this.walkCB3Sync(h, a, s, o);
5019
+ }
5020
+ o();
5021
+ }
5022
+ walkCB3Sync(t, e, s, i) {
5023
+ s = s.filterEntries(t, e);
5024
+ let r = 1, o = () => {
5025
+ --r === 0 && i();
5026
+ };
5027
+ for (let [h, a, l] of s.matches.entries()) this.#r(h) || this.matchSync(h, a, l);
5028
+ for (let [h, a] of s.subwalks.entries()) r++, this.walkCB2Sync(h, a, s.child(), o);
5029
+ o();
5030
+ }
5031
+ };
5032
+ var xt = class extends zt {
5033
+ matches = /* @__PURE__ */ new Set();
5034
+ constructor(t, e, s) {
5035
+ super(t, e, s);
5036
+ }
5037
+ matchEmit(t) {
5038
+ this.matches.add(t);
5039
+ }
5040
+ async walk() {
5041
+ if (this.signal?.aborted) throw this.signal.reason;
5042
+ return this.path.isUnknown() && await this.path.lstat(), await new Promise((t, e) => {
5043
+ this.walkCB(this.path, this.patterns, () => {
5044
+ this.signal?.aborted ? e(this.signal.reason) : t(this.matches);
5045
+ });
5046
+ }), this.matches;
5047
+ }
5048
+ walkSync() {
5049
+ if (this.signal?.aborted) throw this.signal.reason;
5050
+ return this.path.isUnknown() && this.path.lstatSync(), this.walkCBSync(this.path, this.patterns, () => {
5051
+ if (this.signal?.aborted) throw this.signal.reason;
5052
+ }), this.matches;
5053
+ }
5054
+ };
5055
+ var vt = class extends zt {
5056
+ results;
5057
+ constructor(t, e, s) {
5058
+ super(t, e, s), this.results = new V({
5059
+ signal: this.signal,
5060
+ objectMode: !0
5061
+ }), this.results.on("drain", () => this.resume()), this.results.on("resume", () => this.resume());
5062
+ }
5063
+ matchEmit(t) {
5064
+ this.results.write(t), this.results.flowing || this.pause();
5065
+ }
5066
+ stream() {
5067
+ let t = this.path;
5068
+ return t.isUnknown() ? t.lstat().then(() => {
5069
+ this.walkCB(t, this.patterns, () => this.results.end());
5070
+ }) : this.walkCB(t, this.patterns, () => this.results.end()), this.results;
5071
+ }
5072
+ streamSync() {
5073
+ return this.path.isUnknown() && this.path.lstatSync(), this.walkCBSync(this.path, this.patterns, () => this.results.end()), this.results;
5074
+ }
5075
+ };
5076
+ var Pi = typeof process == "object" && process && typeof process.platform == "string" ? process.platform : "linux";
5077
+ var I = class {
5078
+ absolute;
5079
+ cwd;
5080
+ root;
5081
+ dot;
5082
+ dotRelative;
5083
+ follow;
5084
+ ignore;
5085
+ magicalBraces;
5086
+ mark;
5087
+ matchBase;
5088
+ maxDepth;
5089
+ nobrace;
5090
+ nocase;
5091
+ nodir;
5092
+ noext;
5093
+ noglobstar;
5094
+ pattern;
5095
+ platform;
5096
+ realpath;
5097
+ scurry;
5098
+ stat;
5099
+ signal;
5100
+ windowsPathsNoEscape;
5101
+ withFileTypes;
5102
+ includeChildMatches;
5103
+ opts;
5104
+ patterns;
5105
+ constructor(t, e) {
5106
+ if (!e) throw new TypeError("glob options required");
5107
+ if (this.withFileTypes = !!e.withFileTypes, this.signal = e.signal, this.follow = !!e.follow, this.dot = !!e.dot, this.dotRelative = !!e.dotRelative, this.nodir = !!e.nodir, this.mark = !!e.mark, e.cwd ? (e.cwd instanceof URL || e.cwd.startsWith("file://")) && (e.cwd = fileURLToPath(e.cwd)) : this.cwd = "", this.cwd = e.cwd || "", this.root = e.root, this.magicalBraces = !!e.magicalBraces, this.nobrace = !!e.nobrace, this.noext = !!e.noext, this.realpath = !!e.realpath, this.absolute = e.absolute, this.includeChildMatches = e.includeChildMatches !== !1, this.noglobstar = !!e.noglobstar, this.matchBase = !!e.matchBase, this.maxDepth = typeof e.maxDepth == "number" ? e.maxDepth : 1 / 0, this.stat = !!e.stat, this.ignore = e.ignore, this.withFileTypes && this.absolute !== void 0) throw new Error("cannot set absolute and withFileTypes:true");
5108
+ if (typeof t == "string" && (t = [t]), this.windowsPathsNoEscape = !!e.windowsPathsNoEscape || e.allowWindowsEscape === !1, this.windowsPathsNoEscape && (t = t.map((a) => a.replace(/\\/g, "/"))), this.matchBase) {
5109
+ if (e.noglobstar) throw new TypeError("base matching requires globstar");
5110
+ t = t.map((a) => a.includes("/") ? a : `./**/${a}`);
5111
+ }
5112
+ if (this.pattern = t, this.platform = e.platform || Pi, this.opts = {
5113
+ ...e,
5114
+ platform: this.platform
5115
+ }, e.scurry) {
5116
+ if (this.scurry = e.scurry, e.nocase !== void 0 && e.nocase !== e.scurry.nocase) throw new Error("nocase option contradicts provided scurry option");
5117
+ } else {
5118
+ let a = e.platform === "win32" ? it : e.platform === "darwin" ? St : e.platform ? rt : Xe;
5119
+ this.scurry = new a(this.cwd, {
5120
+ nocase: e.nocase,
5121
+ fs: e.fs
1790
5122
  });
1791
- } catch (err) {
1792
- logger.debug(`[luals] Failed to clean up temporary directory ${tempDir}: ${err instanceof Error ? err.message : String(err)}`);
1793
5123
  }
5124
+ this.nocase = this.scurry.nocase;
5125
+ let s = this.platform === "darwin" || this.platform === "win32", i = {
5126
+ braceExpandMax: 1e4,
5127
+ ...e,
5128
+ dot: this.dot,
5129
+ matchBase: this.matchBase,
5130
+ nobrace: this.nobrace,
5131
+ nocase: this.nocase,
5132
+ nocaseMagicOnly: s,
5133
+ nocomment: !0,
5134
+ noext: this.noext,
5135
+ nonegate: !0,
5136
+ optimizationLevel: 2,
5137
+ platform: this.platform,
5138
+ windowsPathsNoEscape: this.windowsPathsNoEscape,
5139
+ debug: !!this.opts.debug
5140
+ }, [o, h] = this.pattern.map((a) => new D(a, i)).reduce((a, l) => (a[0].push(...l.set), a[1].push(...l.globParts), a), [[], []]);
5141
+ this.patterns = o.map((a, l) => {
5142
+ let u = h[l];
5143
+ if (!u) throw new Error("invalid pattern object");
5144
+ return new nt(a, u, 0, this.platform);
5145
+ });
5146
+ }
5147
+ async walk() {
5148
+ return [...await new xt(this.patterns, this.scurry.cwd, {
5149
+ ...this.opts,
5150
+ maxDepth: this.maxDepth !== 1 / 0 ? this.maxDepth + this.scurry.cwd.depth() : 1 / 0,
5151
+ platform: this.platform,
5152
+ nocase: this.nocase,
5153
+ includeChildMatches: this.includeChildMatches
5154
+ }).walk()];
5155
+ }
5156
+ walkSync() {
5157
+ return [...new xt(this.patterns, this.scurry.cwd, {
5158
+ ...this.opts,
5159
+ maxDepth: this.maxDepth !== 1 / 0 ? this.maxDepth + this.scurry.cwd.depth() : 1 / 0,
5160
+ platform: this.platform,
5161
+ nocase: this.nocase,
5162
+ includeChildMatches: this.includeChildMatches
5163
+ }).walkSync()];
5164
+ }
5165
+ stream() {
5166
+ return new vt(this.patterns, this.scurry.cwd, {
5167
+ ...this.opts,
5168
+ maxDepth: this.maxDepth !== 1 / 0 ? this.maxDepth + this.scurry.cwd.depth() : 1 / 0,
5169
+ platform: this.platform,
5170
+ nocase: this.nocase,
5171
+ includeChildMatches: this.includeChildMatches
5172
+ }).stream();
5173
+ }
5174
+ streamSync() {
5175
+ return new vt(this.patterns, this.scurry.cwd, {
5176
+ ...this.opts,
5177
+ maxDepth: this.maxDepth !== 1 / 0 ? this.maxDepth + this.scurry.cwd.depth() : 1 / 0,
5178
+ platform: this.platform,
5179
+ nocase: this.nocase,
5180
+ includeChildMatches: this.includeChildMatches
5181
+ }).streamSync();
5182
+ }
5183
+ iterateSync() {
5184
+ return this.streamSync()[Symbol.iterator]();
5185
+ }
5186
+ [Symbol.iterator]() {
5187
+ return this.iterateSync();
5188
+ }
5189
+ iterate() {
5190
+ return this.stream()[Symbol.asyncIterator]();
5191
+ }
5192
+ [Symbol.asyncIterator]() {
5193
+ return this.iterate();
1794
5194
  }
5195
+ };
5196
+ var le = (n, t = {}) => {
5197
+ Array.isArray(n) || (n = [n]);
5198
+ for (let e of n) if (new D(e, t).hasMagic()) return !0;
5199
+ return !1;
5200
+ };
5201
+ function Bt(n, t = {}) {
5202
+ return new I(n, t).streamSync();
1795
5203
  }
5204
+ function Qe(n, t = {}) {
5205
+ return new I(n, t).stream();
5206
+ }
5207
+ function ts(n, t = {}) {
5208
+ return new I(n, t).walkSync();
5209
+ }
5210
+ async function Je(n, t = {}) {
5211
+ return new I(n, t).walk();
5212
+ }
5213
+ function Ut(n, t = {}) {
5214
+ return new I(n, t).iterateSync();
5215
+ }
5216
+ function es(n, t = {}) {
5217
+ return new I(n, t).iterate();
5218
+ }
5219
+ var ji = Bt;
5220
+ var Ii = Object.assign(Qe, { sync: Bt });
5221
+ var zi = Ut;
5222
+ var Bi = Object.assign(es, { sync: Ut });
5223
+ var Ui = Object.assign(ts, {
5224
+ stream: Bt,
5225
+ iterate: Ut
5226
+ });
5227
+ var Ze = Object.assign(Je, {
5228
+ glob: Je,
5229
+ globSync: ts,
5230
+ sync: Ui,
5231
+ globStream: Qe,
5232
+ stream: Ii,
5233
+ globStreamSync: Bt,
5234
+ streamSync: ji,
5235
+ globIterate: es,
5236
+ iterate: Bi,
5237
+ globIterateSync: Ut,
5238
+ iterateSync: zi,
5239
+ Glob: I,
5240
+ hasMagic: le,
5241
+ escape: tt,
5242
+ unescape: W
5243
+ });
5244
+ Ze.glob = Ze;
1796
5245
  //#endregion
1797
5246
  //#region src/luals/files.ts
5247
+ /** Directories skipped unless the workspace config overrides `workspace.ignoreDir`. */
5248
+ const DEFAULT_IGNORE_DIRS = [
5249
+ ".git",
5250
+ ".vscode",
5251
+ ".nanos-lint",
5252
+ "node_modules"
5253
+ ];
5254
+ /** Candidate Lua files: LuaLS checks every `*.lua` file in the tree. */
5255
+ const LUA_FILE_PATTERN = "**/*.lua";
5256
+ /** `glob` rejects patterns longer than this, so they are dropped before matching. */
5257
+ const MAX_PATTERN_LENGTH = 65536;
5258
+ /**
5259
+ * Complexity budget per pattern. `minimatch` evaluates patterns through an AST
5260
+ * but still compiles them to regular expressions, so ambiguous wildcards inside
5261
+ * one path segment can backtrack, and brace groups expand combinatorially
5262
+ * (`{a,b}` repeated 16 times is 65 536 alternatives). A hostile or accidental
5263
+ * `.luarc.json` could otherwise stall the file walk, so patterns beyond the
5264
+ * budget are skipped with a warning instead of being matched.
5265
+ *
5266
+ * The ambiguity of one segment grows like `C(segment length, wildcards)`, so the
5267
+ * per-segment cap is what keeps matching cheap. `**\/*a*a*a*a\/*a*a*a*a\/*a*a*a*a\/*a*a*a*z.lua`
5268
+ * (4 wildcards per segment) stays within a 4-wildcard cap yet costs ~5 ms per
5269
+ * candidate file — ~100 s on a 20 000-file tree — while two wildcards per
5270
+ * segment cost `C(60, 2) = 1 770` splits, hundreds of times less. The budget is
5271
+ * deliberately far below what minimatch can parse: every realistic pattern
5272
+ * (`**\/*.{bak,tmp}`, `**\/node_modules\/**`, `**\/item-[0-9].lua`,
5273
+ * `**\/*.min.*`) needs at most two wildcards in any one segment.
5274
+ */
5275
+ const MAX_WILDCARDS_PER_SEGMENT = 2;
5276
+ const MAX_TOTAL_WILDCARDS = 12;
5277
+ const MAX_BRACE_ALTERNATIVES = 256;
5278
+ /** Counts wildcard tokens (`*`, `?`, character classes and brace groups). */
5279
+ function countWildcards(value) {
5280
+ let count = 0;
5281
+ for (const char of value) if (char === "*" || char === "?" || char === "[" || char === "{") count += 1;
5282
+ return count;
5283
+ }
5284
+ /**
5285
+ * Upper bound of the alternatives brace expansion would produce; `1` when the
5286
+ * pattern has no brace groups. Nested groups count towards their parent, which
5287
+ * over-estimates on purpose so the bound stays safe.
5288
+ */
5289
+ function estimateBraceAlternatives(pattern) {
5290
+ const pending = [];
5291
+ let estimate = 1;
5292
+ for (const char of pattern) if (char === "{") pending.push(0);
5293
+ else if (char === "}" && pending.length > 0) {
5294
+ const alternatives = (pending.pop() ?? 0) + 1;
5295
+ estimate *= alternatives;
5296
+ if (pending.length > 0) pending[pending.length - 1] = (pending[pending.length - 1] ?? 0) + alternatives - 1;
5297
+ } else if (char === "," && pending.length > 0) pending[pending.length - 1] = (pending[pending.length - 1] ?? 0) + 1;
5298
+ return estimate;
5299
+ }
5300
+ /** Returns `false` when matching the pattern could become pathologically slow. */
5301
+ function isPatternWithinBudget(pattern) {
5302
+ if (estimateBraceAlternatives(pattern) > MAX_BRACE_ALTERNATIVES) return false;
5303
+ if (countWildcards(pattern) > MAX_TOTAL_WILDCARDS) return false;
5304
+ return pattern.split("/").every((segment) => countWildcards(segment) <= MAX_WILDCARDS_PER_SEGMENT);
5305
+ }
5306
+ /**
5307
+ * Normalizes one user-supplied pattern (`workspace.ignoreDir`, `files.exclude`
5308
+ * or a built-in default) into the slash-separated form `glob` expects.
5309
+ * Backslashes are accepted as separators so Windows-authored `.luarc.json`
5310
+ * files keep working, and trailing slashes are dropped so `vendor/` behaves
5311
+ * exactly like `vendor`. Patterns that cannot be matched (`""`, `"."`, NUL
5312
+ * bytes, oversized input, absolute paths, or non-string JSON values) are
5313
+ * rejected instead of being handed to `glob`.
5314
+ */
5315
+ function normalizePattern(pattern) {
5316
+ if (typeof pattern !== "string") return null;
5317
+ const normalized = pattern.trim().replace(/\\/g, "/").replace(/\/+$/, "");
5318
+ if (!normalized || normalized === "." || normalized.length > MAX_PATTERN_LENGTH || normalized.includes("\0") || isAbsolutePattern(normalized)) return null;
5319
+ return normalized;
5320
+ }
5321
+ /** Drive-letter prefixes, recognized on every platform (not just Windows). */
5322
+ const WINDOWS_ABSOLUTE_PATTERN = /^[A-Za-z]:\//;
5323
+ /**
5324
+ * `workspace.ignoreDir` / `files.exclude` entries are workspace-relative in
5325
+ * LuaLS, and `glob` matches ignore patterns against walk-relative paths. An
5326
+ * absolute entry is therefore unusable, and `glob` anchors it on some platforms
5327
+ * but not others (a macOS `/var` -> `/private/var` walk root or a Windows drive
5328
+ * letter behave differently again), so it is skipped to keep one `.luarc.json`
5329
+ * behaving identically on Linux, macOS and Windows.
5330
+ */
5331
+ function isAbsolutePattern(normalized) {
5332
+ return path.posix.isAbsolute(normalized) || WINDOWS_ABSOLUTE_PATTERN.test(normalized);
5333
+ }
5334
+ /**
5335
+ * Expands one LuaLS pattern into the equivalent `glob` ignore patterns:
5336
+ *
5337
+ * - basename-only patterns (`*.lua`, `vendor`) match at any depth, so the
5338
+ * `**\/`-prefixed variants are added (mirrors LuaLS `matchBase` semantics);
5339
+ * - a pattern also excludes everything below a matching directory, which is
5340
+ * what the trailing `/**` variant expresses;
5341
+ * - the pattern itself is always kept so an exact file or directory match
5342
+ * works as written.
5343
+ */
5344
+ function expandIgnorePattern(pattern) {
5345
+ return pattern.includes("/") ? [pattern, `${pattern}/**`] : [`**/${pattern}`, `**/${pattern}/**`];
5346
+ }
5347
+ /** Normalizes and expands a list of LuaLS patterns into `glob` ignore patterns. */
5348
+ function toIgnorePatterns(patterns) {
5349
+ const ignore = [];
5350
+ for (const raw of patterns) {
5351
+ const normalized = normalizePattern(raw);
5352
+ if (!normalized) {
5353
+ logger.debug(`[luals] Skipping unusable glob pattern "${String(raw)}" while counting checked files.`);
5354
+ continue;
5355
+ }
5356
+ if (!isPatternWithinBudget(normalized)) {
5357
+ logger.warn(`[luals] Skipping glob pattern "${raw}": it is too complex to match safely and would slow down file counting.`);
5358
+ continue;
5359
+ }
5360
+ ignore.push(...expandIgnorePattern(normalized));
5361
+ }
5362
+ return ignore;
5363
+ }
1798
5364
  /**
1799
- * Counts candidate Lua files within targetPath, taking ignoreDir and files.exclude into account.
5365
+ * Counts candidate Lua files within targetPath, taking `workspace.ignoreDir`
5366
+ * and `files.exclude` into account.
5367
+ *
5368
+ * Traversal and matching are delegated to the bundled `glob` package, whose
5369
+ * `minimatch` matcher understands the full glob syntax LuaLS accepts (brace
5370
+ * expansion, character classes, `**`, `?`) instead of the hand-rolled
5371
+ * glob-to-regex translation used before. Combined with the pattern budgets
5372
+ * above, this keeps the count predictable for adversarial configurations
5373
+ * while remaining consistent with LuaLS exclude semantics (#27).
1800
5374
  */
1801
5375
  function countCheckedFiles(targetPath, configPath) {
1802
- const absPath = path.resolve(targetPath);
5376
+ let absPath = path.resolve(targetPath);
1803
5377
  if (!fs.existsSync(absPath)) return 0;
5378
+ try {
5379
+ absPath = fs.realpathSync.native(absPath);
5380
+ } catch {
5381
+ try {
5382
+ absPath = fs.realpathSync(absPath);
5383
+ } catch (err) {}
5384
+ }
1804
5385
  if (fs.statSync(absPath).isFile()) return absPath.toLowerCase().endsWith(".lua") ? 1 : 0;
1805
- let ignoreDirs = [
1806
- ".git",
1807
- ".vscode",
1808
- ".nanos-lint",
1809
- "node_modules"
1810
- ];
5386
+ let ignoreDirs = DEFAULT_IGNORE_DIRS;
1811
5387
  let excludePatterns = [];
1812
5388
  if (configPath && fs.existsSync(configPath)) try {
1813
5389
  const cfg = JSON.parse(fs.readFileSync(configPath, "utf-8"));
1814
- if (cfg.workspace?.ignoreDir) ignoreDirs = cfg.workspace.ignoreDir;
1815
- if (cfg.files?.exclude) excludePatterns = cfg.files.exclude;
5390
+ if (Array.isArray(cfg.workspace?.ignoreDir)) ignoreDirs = cfg.workspace.ignoreDir;
5391
+ if (Array.isArray(cfg.files?.exclude)) excludePatterns = cfg.files.exclude;
1816
5392
  } catch (err) {
1817
5393
  logger.warn(`[luals] Failed to parse config file for file counting at ${configPath}: ${err instanceof Error ? err.message : String(err)}`);
1818
5394
  }
1819
- const normIgnoreDirs = new Set(ignoreDirs.map((d) => d.replace(/\\/g, "/").toLowerCase()));
1820
- function isExcluded(relPath) {
1821
- const norm = relPath.replace(/\\/g, "/");
1822
- const baseName = path.posix.basename(norm);
1823
- for (const pat of excludePatterns) {
1824
- const normPat = pat.replace(/\\/g, "/");
1825
- if (norm === normPat || baseName === normPat) return true;
1826
- if (normPat.endsWith("/**")) {
1827
- const dir = normPat.slice(0, -3);
1828
- if (norm === dir || norm.startsWith(`${dir}/`)) return true;
1829
- }
1830
- if (norm.startsWith(`${normPat}/`)) return true;
1831
- if (normPat.includes("*") || normPat.includes("?")) {
1832
- if (!normPat.includes("/")) {
1833
- const baseRegexStr = "^" + normPat.replace(/[.+^${}()|[\]\\]/g, "\\$&").replace(/\*/g, ".*").replace(/\?/g, ".") + "$";
1834
- try {
1835
- if (new RegExp(baseRegexStr, "i").test(baseName)) return true;
1836
- } catch (err) {
1837
- logger.debug(`[luals] Invalid regex for pattern "${normPat}": ${err instanceof Error ? err.message : String(err)}`);
1838
- }
1839
- }
1840
- let regexStr = normPat;
1841
- const hasLeadingDoubleStar = regexStr.startsWith("**/");
1842
- if (hasLeadingDoubleStar) regexStr = regexStr.slice(3);
1843
- const hasTrailingDoubleStar = regexStr.endsWith("/**");
1844
- if (hasTrailingDoubleStar) regexStr = regexStr.slice(0, -3);
1845
- let escaped = regexStr.replace(/[.+^${}()|[\]\\]/g, "\\$&").replace(/\/\*\*\//g, "/(?:.*/)?").replace(/\*\*/g, ".*").replace(/(?<!\.)\*/g, "[^/]*").replace(/\?/g, "[^/]");
1846
- if (hasLeadingDoubleStar) escaped = `(?:^|.*/)${escaped}`;
1847
- if (hasTrailingDoubleStar) escaped = `${escaped}(?:/.*)?`;
1848
- try {
1849
- if (new RegExp(`^${escaped}$`, "i").test(norm)) return true;
1850
- } catch (err) {
1851
- logger.debug(`[luals] Invalid glob regex for pattern "${normPat}": ${err instanceof Error ? err.message : String(err)}`);
1852
- }
1853
- }
1854
- }
1855
- return false;
1856
- }
1857
- let count = 0;
1858
- function walk(currentDir, relDir = "") {
1859
- let entries;
1860
- try {
1861
- entries = fs.readdirSync(currentDir, { withFileTypes: true });
1862
- } catch (err) {
1863
- logger.debug(`[luals] Failed to read directory ${currentDir}: ${err instanceof Error ? err.message : String(err)}`);
1864
- return;
1865
- }
1866
- for (const entry of entries) {
1867
- const name = entry.name;
1868
- const relPath = relDir ? `${relDir}/${name}` : name;
1869
- const fullPath = path.join(currentDir, name);
1870
- if (entry.isDirectory() || entry.isSymbolicLink() && (() => {
1871
- try {
1872
- return fs.statSync(fullPath).isDirectory();
1873
- } catch (err) {
1874
- logger.debug(`[luals] Failed to stat symlink target ${fullPath}: ${err instanceof Error ? err.message : String(err)}`);
1875
- return false;
1876
- }
1877
- })()) {
1878
- const lowerName = name.toLowerCase();
1879
- if (normIgnoreDirs.has(lowerName) || normIgnoreDirs.has(relPath.toLowerCase())) continue;
1880
- if (isExcluded(relPath) || isExcluded(`${relPath}/**`)) continue;
1881
- walk(fullPath, relPath);
1882
- } else if (entry.isFile() && name.toLowerCase().endsWith(".lua")) {
1883
- if (!isExcluded(relPath)) count++;
1884
- }
1885
- }
5395
+ const ignore = [...toIgnorePatterns(ignoreDirs), ...toIgnorePatterns(excludePatterns)];
5396
+ try {
5397
+ return ts(LUA_FILE_PATTERN, {
5398
+ cwd: absPath,
5399
+ ignore,
5400
+ dot: true,
5401
+ nocase: true,
5402
+ follow: false,
5403
+ withFileTypes: true
5404
+ }).filter((entry) => entry.isFile()).length;
5405
+ } catch (err) {
5406
+ logger.warn(`[luals] Failed to walk ${absPath} while counting checked files: ${err instanceof Error ? err.message : String(err)}`);
5407
+ return 0;
1886
5408
  }
1887
- walk(absPath);
1888
- return count;
1889
5409
  }
1890
5410
  //#endregion
1891
5411
  //#region src/luals/runner.ts
@@ -1896,7 +5416,7 @@ function isOfflineError(err) {
1896
5416
  return /offline|enotfound|eai_again|econnrefused|etimedout|fetch failed/i.test(msg);
1897
5417
  }
1898
5418
  async function resolveLuaLSBinary(version = DEFAULT_LUALS_VERSION, options) {
1899
- if (process.env.LUALS_BIN && fs.existsSync(process.env.LUALS_BIN)) return process.env.LUALS_BIN;
5419
+ if (process.env.LUALS_BIN) return assertValidLuaLSBinary(process.env.LUALS_BIN, "LUALS_BIN");
1900
5420
  if (options?.reuseExisting !== false && (!version || version === "latest")) {
1901
5421
  const defaultInfo = getPlatformInfo(FALLBACK_LUALS_VERSION);
1902
5422
  const defaultBundledPath = path.join(getPackageRoot(), defaultInfo.binaryRelativePath);
@@ -1985,10 +5505,15 @@ async function resolveLuaLSBinary(version = DEFAULT_LUALS_VERSION, options) {
1985
5505
  }
1986
5506
  const currentWeek = getIsoWeek();
1987
5507
  const metadata = readLuaLSMetadata(baseCacheDir);
1988
- if (options?.reuseExisting !== false && metadata && metadata.lastCheckedWeek === currentWeek && metadata.latestVersion) {
1989
- const info = getPlatformInfo(metadata.latestVersion);
1990
- const cachedPath = path.join(getCacheDir(metadata.latestVersion, baseCacheDir), info.binaryRelativePath);
1991
- if (isBinaryValid(cachedPath)) return cachedPath;
5508
+ const safeLatest = metadata?.latestVersion ? sanitizeLuaLSVersion(metadata.latestVersion) : null;
5509
+ if (options?.reuseExisting !== false && metadata && metadata.lastCheckedWeek === currentWeek && safeLatest) {
5510
+ const info = getPlatformInfo(safeLatest);
5511
+ const targetDir = path.resolve(getCacheDir(safeLatest, baseCacheDir));
5512
+ const resolvedBase = path.resolve(baseCacheDir);
5513
+ if (targetDir.startsWith(resolvedBase + path.sep) || targetDir === resolvedBase) {
5514
+ const cachedPath = path.join(targetDir, info.binaryRelativePath);
5515
+ if (isBinaryValid(cachedPath)) return cachedPath;
5516
+ }
1992
5517
  }
1993
5518
  const cachedVersions = options?.reuseExisting !== false ? listCachedLuaLSVersions(baseCacheDir) : [];
1994
5519
  const firstCachedVersion = cachedVersions[0];
@@ -2055,7 +5580,7 @@ async function runLuaLSCheck(targetPath, configPath, options) {
2055
5580
  logger.debug(`[luals] Failed to resolve native realpath for target: ${err instanceof Error ? err.message : String(err)}`);
2056
5581
  }
2057
5582
  if (!fs.existsSync(absoluteTarget)) throw new LuaLSError(`Target path does not exist: ${targetPath}`, "ERR_TARGET_NOT_FOUND", "Verify that the target path exists and is accessible.");
2058
- const binary = options.lualsBin || await resolveLuaLSBinary(options.lualsVersion, { quiet: options.quiet });
5583
+ const binary = options.lualsBin ? assertValidLuaLSBinary(options.lualsBin, "--luals-bin") : await resolveLuaLSBinary(options.lualsVersion, { quiet: options.quiet });
2059
5584
  let checkDir = absoluteTarget;
2060
5585
  let targetFileOnly = null;
2061
5586
  if (fs.statSync(absoluteTarget).isFile()) {
@@ -5291,9 +8816,10 @@ function readAnnotationsMetadata(cacheDir = getAnnotationsCacheDir()) {
5291
8816
  }
5292
8817
  return null;
5293
8818
  }
8819
+ const MIN_ANNOTATIONS_SIZE_BYTES = 1e3;
5294
8820
  /**
5295
- * Verifies that an annotations file exists, is a regular file, is of non-trivial size (>= 1000 bytes),
5296
- * and begins with valid Lua comments or nanos world definitions.
8821
+ * Verifies that an annotations file exists, is a regular file, is of non-trivial size (>= MIN_ANNOTATIONS_SIZE_BYTES),
8822
+ * and begins with valid LuaLS metadata or nanos world definitions.
5297
8823
  */
5298
8824
  function isAnnotationsValid(filePath) {
5299
8825
  if (!fs.existsSync(filePath)) return false;
@@ -5301,11 +8827,11 @@ function isAnnotationsValid(filePath) {
5301
8827
  const stat = fs.statSync(filePath);
5302
8828
  if (!stat.isFile() || stat.size < 1e3) return false;
5303
8829
  const fd = fs.openSync(filePath, "r");
5304
- const buffer = Buffer.alloc(256);
5305
- const bytesRead = fs.readSync(fd, buffer, 0, 256, 0);
8830
+ const buffer = Buffer.alloc(512);
8831
+ const bytesRead = fs.readSync(fd, buffer, 0, 512, 0);
5306
8832
  fs.closeSync(fd);
5307
8833
  const header = buffer.toString("utf-8", 0, bytesRead).trimStart();
5308
- return header.startsWith("--") || header.includes("nanos world");
8834
+ return header.startsWith("---@meta") || header.includes("nanos world") || header.includes("nanos-world");
5309
8835
  } catch (err) {
5310
8836
  logger.debug(`[annotations] Annotation validation failed for ${filePath}: ${err instanceof Error ? err.message : String(err)}`);
5311
8837
  return false;
@@ -5328,8 +8854,16 @@ async function fetchLatestCommitId() {
5328
8854
  }
5329
8855
  return null;
5330
8856
  }
5331
- async function fetchRawAnnotationsContent() {
5332
- const res = await fetch(RAW_ANNOTATIONS_URL, {
8857
+ /**
8858
+ * Returns raw annotations URL, pinned to commit SHA if provided and valid.
8859
+ */
8860
+ function getRawAnnotationsUrl(commitSha) {
8861
+ if (commitSha && /^[0-9a-fA-F]{7,40}$/.test(commitSha)) return `https://raw.githubusercontent.com/${DOCGEN_REPO}/${commitSha}/annotations.lua`;
8862
+ return RAW_ANNOTATIONS_URL;
8863
+ }
8864
+ async function fetchRawAnnotationsContent(commitSha) {
8865
+ const url = getRawAnnotationsUrl(commitSha);
8866
+ const res = await fetch(url, {
5333
8867
  headers: { "User-Agent": "nanos-lint" },
5334
8868
  signal: AbortSignal.timeout(15e3)
5335
8869
  });
@@ -5393,7 +8927,7 @@ async function downloadAndCacheAnnotations(commitId, cacheDir = getAnnotationsCa
5393
8927
  if (commitId && commitId !== "unknown") logger.info(`[annotations] Downloading nanos world API annotations (${commitId.slice(0, 7)})...`);
5394
8928
  else logger.info("[annotations] Downloading nanos world API annotations...");
5395
8929
  }
5396
- const content = await fetchRawAnnotationsContent();
8930
+ const content = await fetchRawAnnotationsContent(commitId);
5397
8931
  const tempAnnotationsPath = path.join(tempDir, ANNOTATIONS_FILENAME);
5398
8932
  fs.writeFileSync(tempAnnotationsPath, content, "utf-8");
5399
8933
  const { dateStr, dateObj } = getTodayDateString();
@@ -5405,7 +8939,7 @@ async function downloadAndCacheAnnotations(commitId, cacheDir = getAnnotationsCa
5405
8939
  const tempMetaPath = path.join(tempDir, METADATA_FILENAME);
5406
8940
  fs.writeFileSync(tempMetaPath, JSON.stringify(metadata, null, 2), "utf-8");
5407
8941
  const existingMeta = readAnnotationsMetadata(cacheDir);
5408
- if (existingMeta && existingMeta.commitId === commitId && fs.existsSync(finalAnnotationsPath) && fs.statSync(finalAnnotationsPath).size >= 1e3) return finalAnnotationsPath;
8942
+ if (existingMeta && existingMeta.commitId === commitId && fs.existsSync(finalAnnotationsPath) && isAnnotationsValid(finalAnnotationsPath)) return finalAnnotationsPath;
5409
8943
  const oldAnnotationsExists = fs.existsSync(finalAnnotationsPath);
5410
8944
  const oldMetaExists = fs.existsSync(finalMetaPath);
5411
8945
  if (oldAnnotationsExists || oldMetaExists) {
@@ -5446,6 +8980,26 @@ async function downloadAndCacheAnnotations(commitId, cacheDir = getAnnotationsCa
5446
8980
  }
5447
8981
  }
5448
8982
  }
8983
+ function validateCustomAnnotationsPath(filePath, source) {
8984
+ const resolved = path.resolve(filePath);
8985
+ if (!fs.existsSync(resolved)) {
8986
+ if (source === "custom") throw new AnnotationsError(`Custom annotations file not found: ${resolved}`, "ERR_ANNOTATIONS_NOT_FOUND", "Verify that the path specified in --annotations exists and is accessible.");
8987
+ else throw new AnnotationsError(`Annotations file specified in environment not found: ${resolved}`, "ERR_ANNOTATIONS_ENV_NOT_FOUND", "Verify that the path specified in NANOS_ANNOTATIONS_PATH or NANOS_ANNOTATIONS exists.");
8988
+ }
8989
+ const stat = fs.statSync(resolved);
8990
+ if (!stat.isFile()) throw new AnnotationsError(source === "custom" ? `Custom annotations path is not a file: ${resolved}` : `Annotations path specified in environment is not a file: ${resolved}`, "ERR_ANNOTATIONS_NOT_A_FILE", source === "custom" ? "Verify that the path specified in --annotations points to a regular file, not a directory." : "Verify that the path specified in NANOS_ANNOTATIONS_PATH or NANOS_ANNOTATIONS points to a regular file, not a directory.");
8991
+ if (stat.size === 0) throw new AnnotationsError(source === "custom" ? `Custom annotations file is empty: ${resolved}` : `Annotations file specified in environment is empty: ${resolved}`, "ERR_ANNOTATIONS_INVALID", source === "custom" ? "Verify that the path specified in --annotations is a valid non-empty Lua annotations file." : "Verify that the path specified in NANOS_ANNOTATIONS_PATH or NANOS_ANNOTATIONS is a valid non-empty Lua annotations file.");
8992
+ try {
8993
+ const fd = fs.openSync(resolved, "r");
8994
+ const buffer = Buffer.alloc(Math.min(stat.size, 512));
8995
+ const bytesRead = fs.readSync(fd, buffer, 0, buffer.length, 0);
8996
+ fs.closeSync(fd);
8997
+ if (buffer.subarray(0, bytesRead).includes(0)) throw new AnnotationsError(source === "custom" ? `Custom annotations file appears to be a binary file: ${resolved}` : `Annotations file specified in environment appears to be a binary file: ${resolved}`, "ERR_ANNOTATIONS_INVALID", "Verify that the annotations file is a valid Lua text annotations file.");
8998
+ } catch (err) {
8999
+ if (err instanceof AnnotationsError) throw err;
9000
+ }
9001
+ return resolved;
9002
+ }
5449
9003
  /**
5450
9004
  * Resolves the nanos world annotations.lua definitions file path.
5451
9005
  * Resolution precedence:
@@ -5455,17 +9009,9 @@ async function downloadAndCacheAnnotations(commitId, cacheDir = getAnnotationsCa
5455
9009
  * 4. User cache (checked once per day from upstream GitHub)
5456
9010
  */
5457
9011
  async function resolveAnnotations(options = {}) {
5458
- if (options.customPath) {
5459
- const resolved = path.resolve(options.customPath);
5460
- if (!fs.existsSync(resolved)) throw new AnnotationsError(`Custom annotations file not found: ${resolved}`, "ERR_ANNOTATIONS_NOT_FOUND", "Verify that the path specified in --annotations exists and is accessible.");
5461
- return resolved;
5462
- }
9012
+ if (options.customPath) return validateCustomAnnotationsPath(options.customPath, "custom");
5463
9013
  const envPath = process.env.NANOS_ANNOTATIONS_PATH || process.env.NANOS_ANNOTATIONS;
5464
- if (envPath) {
5465
- const resolved = path.resolve(envPath);
5466
- if (!fs.existsSync(resolved)) throw new AnnotationsError(`Annotations file specified in environment not found: ${resolved}`, "ERR_ANNOTATIONS_ENV_NOT_FOUND", "Verify that the path specified in NANOS_ANNOTATIONS_PATH or NANOS_ANNOTATIONS exists.");
5467
- return resolved;
5468
- }
9014
+ if (envPath) return validateCustomAnnotationsPath(envPath, "env");
5469
9015
  const bundled = path.join(getPackageRoot(), "annotations.lua");
5470
9016
  if (fs.existsSync(bundled) && isAnnotationsValid(bundled)) return bundled;
5471
9017
  const cacheDir = options.cacheDir ?? getAnnotationsCacheDir();
@@ -5845,6 +9391,6 @@ if (isDirectExecution()) runCLI().then((code) => {
5845
9391
  process.exit(1);
5846
9392
  });
5847
9393
  //#endregion
5848
- export { fetchLatestLuaLSVersionFromGitHub as $, pluralize as A, logger as At, getBaseLuaLSCacheDir as B, updateLastCheckedDate as C, systemPaths as Ct, formatReport as D, LOG_LEVEL_PRIORITY as Dt, formatProblemSummary as E, LOG_LEVELS as Et, downloadAndExtractLuaLS as F, listCachedLuaLSVersionDirs as G, getIsoWeek as H, escapePowerShellSingleQuote as I, writeLuaLSMetadata as J, listCachedLuaLSVersions as K, LUALS_METADATA_FILENAME as L, resolveLuaLSBinary as M, runLuaLSCheck as N, formatSeverityBadge as O, Logger as Ot, countCheckedFiles as P, FALLBACK_LUALS_VERSION as Q, cleanupOldCachedLuaLSVersions as R, resolveAnnotations as S, getDirectorySize as St, formatPretty as T, DEFAULT_LOG_LEVEL as Tt, getLegacyCacheDir as U, getCacheDir as V, getLuaLSMetadataPath as W, getPlatformInfo as X, isBinaryValid as Y, DEFAULT_LUALS_VERSION as Z, getAnnotationsMetadataFilePath as _, ConfigError as _t, formatCacheStatusPretty as a, getDefaultTemplatePath as at, isAnnotationsValid as b, cleanCache as bt, DOCGEN_BRANCH as c, initWorkspace as ct, METADATA_FILENAME as d, parseJsonc as dt, resolveLatestLuaLSVersion as et, RAW_ANNOTATIONS_URL as f, resolveWorkspaceConfig as ft, getAnnotationsCacheDir as g, CacheError as gt, fetchRawAnnotationsContent as h, AnnotationsError as ht, runCLI as i, getDefaultAnnotationsPath as it, shouldEnableColor as j, parseLogLevel as jt, getColors as k, isValidLogLevel as kt, DOCGEN_REPO as l, loadConfigFile as lt, fetchLatestCommitId as m, stripTrailingSlashes as mt, createProgram as n, sanitizeLuaLSVersion as nt, getCacheStatus as o, getDefinitionsDir as ot, downloadAndCacheAnnotations as p, stripJsonComments as pt, readLuaLSMetadata as q, isDirectExecution as r, VALID_LUALS_DIAGNOSTIC_CODES as rt, ANNOTATIONS_FILENAME as s, getPackageRoot as st, collectIgnorePatterns as t, resolveLuaLSVersion as tt, GITHUB_COMMITS_API as u, mergeConfigs as ut, getCachedAnnotationsFilePath as v, LuaLSError as vt, formatGitHubAnnotations as w, fileUriToPath as wt, readAnnotationsMetadata as x, formatBytes as xt, getTodayDateString as y, NanosLintError as yt, findExistingLuaLSDir as z };
9394
+ export { listCachedLuaLSVersionDirs as $, formatSeverityBadge as A, NanosLintError as At, computeFileSha256 as B, isValidLogLevel as Bt, readAnnotationsMetadata as C, resolveWorkspaceConfig as Ct, formatPretty as D, CacheError as Dt, formatGitHubAnnotations as E, AnnotationsError as Et, runLuaLSCheck as F, fileUriToPath as Ft, LUALS_METADATA_FILENAME as G, escapePowerShellSingleQuote as H, parseLogLevel as Ht, countCheckedFiles as I, DEFAULT_LOG_LEVEL as It, getBaseLuaLSCacheDir as J, cleanupOldCachedLuaLSVersions as K, ALLOWED_DOWNLOAD_DOMAINS as L, LOG_LEVELS as Lt, pluralize as M, formatBytes as Mt, shouldEnableColor as N, getDirectorySize as Nt, formatProblemSummary as O, ConfigError as Ot, resolveLuaLSBinary as P, systemPaths as Pt, getLuaLSMetadataPath as Q, DOWNLOAD_TIMEOUT_MS as R, LOG_LEVEL_PRIORITY as Rt, isAnnotationsValid as S, parseJsonc as St, updateLastCheckedDate as T, stripTrailingSlashes as Tt, isAllowedDownloadUrl as U, downloadAndExtractLuaLS as V, logger as Vt, limitDownloadStream as W, getIsoWeek as X, getCacheDir as Y, getLegacyCacheDir as Z, getAnnotationsCacheDir as _, getDefinitionsDir as _t, formatCacheStatusPretty as a, isBinaryRunnable as at, getRawAnnotationsUrl as b, loadConfigFile as bt, DOCGEN_BRANCH as c, DEFAULT_LUALS_VERSION as ct, METADATA_FILENAME as d, resolveLatestLuaLSVersion as dt, listCachedLuaLSVersions as et, MIN_ANNOTATIONS_SIZE_BYTES as f, resolveLuaLSVersion as ft, fetchRawAnnotationsContent as g, getDefaultTemplatePath as gt, fetchLatestCommitId as h, getDefaultAnnotationsPath as ht, runCLI as i, assertValidLuaLSBinary as it, getColors as j, cleanCache as jt, formatReport as k, LuaLSError as kt, DOCGEN_REPO as l, FALLBACK_LUALS_VERSION as lt, downloadAndCacheAnnotations as m, VALID_LUALS_DIAGNOSTIC_CODES as mt, createProgram as n, writeLuaLSMetadata as nt, getCacheStatus as o, isBinaryValid as ot, RAW_ANNOTATIONS_URL as p, sanitizeLuaLSVersion as pt, findExistingLuaLSDir as q, isDirectExecution as r, MIN_DOWNLOADED_BINARY_SIZE_BYTES as rt, ANNOTATIONS_FILENAME as s, getPlatformInfo as st, collectIgnorePatterns as t, readLuaLSMetadata as tt, GITHUB_COMMITS_API as u, fetchLatestLuaLSVersionFromGitHub as ut, getAnnotationsMetadataFilePath as v, getPackageRoot as vt, resolveAnnotations as w, stripJsonComments as wt, getTodayDateString as x, mergeConfigs as xt, getCachedAnnotationsFilePath as y, initWorkspace as yt, MAX_ARCHIVE_SIZE_BYTES as z, Logger as zt };
5849
9395
 
5850
- //# sourceMappingURL=cli-DGez8MSI.js.map
9396
+ //# sourceMappingURL=cli-BAy_Ztvh.js.map