UNPKG

ccusage

Version:

Usage analysis tool for Claude Code

1,625 lines 138 kB
import { A as object, C as boolean, F as string, M as parse$2, P as safeParse, R as union, S as array, _ as requestIdSchema, a as createDailyDate, b as versionSchema, c as createSessionId, f as isoTimestampSchema, g as projectPathSchema, h as monthlyDateSchema, i as createBucket, j as optional, k as number, l as createWeeklyDate, m as modelNameSchema, o as createMonthlyDate, p as messageIdSchema, r as activityDateSchema, s as createProjectPath, u as dailyDateSchema, v as sessionIdSchema, x as weeklyDateSchema, z as getTotalTokens } from "./_types-BFL_bTNX.js"; import { n as logger } from "./logger-B6CjbhRV.js"; import { createRequire } from "node:module"; import * as nativeFs from "node:fs"; import b, { createReadStream } from "node:fs"; import a, { readFile, stat } from "node:fs/promises"; import path, { basename, dirname, normalize, posix, relative, resolve, sep } from "node:path"; import process$1 from "node:process"; import { createInterface } from "node:readline"; import F, { homedir } from "node:os"; import { fileURLToPath } from "node:url"; var __create = Object.create; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __getProtoOf = Object.getPrototypeOf; var __hasOwnProp = Object.prototype.hasOwnProperty; var __commonJSMin = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports); var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n$1 = keys.length, key; i < n$1; i++) { key = keys[i]; if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: ((k$1) => from[k$1]).bind(null, key), enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod)); var __require$1 = /* @__PURE__ */ createRequire(import.meta.url); function toArray(array$1) { array$1 = array$1 ?? []; return Array.isArray(array$1) ? array$1 : [array$1]; } const isFailure = (result) => "Failure" === result.type; const isPromise = (value) => "object" == typeof value && null !== value && "then" in value && "function" == typeof value.then && "catch" in value && "function" == typeof value.catch; const andThen = (fn) => (result) => { const apply = (r) => { if (isFailure(r)) return r; return fn(r.value); }; return isPromise(result) ? result.then(apply) : apply(result); }; const andThrough = (fn) => (result) => { const apply = (r) => { if (isFailure(r)) return r; const next = fn(r.value); if (isPromise(next)) return next.then((n$1) => { if (isFailure(n$1)) return n$1; return r; }); if (isFailure(next)) return next; return r; }; return isPromise(result) ? result.then(apply) : apply(result); }; const isSuccess = (result) => "Success" === result.type; const succeed = (...args) => { if (args.length <= 0) return { type: "Success" }; const value = args[0]; if (isPromise(value)) return value.then((value$1) => ({ type: "Success", value: value$1 })); return { type: "Success", value }; }; const fail = (...args) => { if (args.length <= 0) return { type: "Failure" }; const error = args[0]; if (isPromise(error)) return error.then((error$1) => ({ type: "Failure", error: error$1 })); return { type: "Failure", error }; }; const inspect = (fn) => (result) => { const apply = (r) => { if (isSuccess(r)) fn(r.value); return r; }; return isPromise(result) ? result.then(apply) : apply(result); }; const inspectError = (fn) => (result) => { const apply = (r) => { if (isFailure(r)) fn(r.error); return r; }; return isPromise(result) ? result.then(apply) : apply(result); }; const isResult = (result) => "object" == typeof result && null !== result && "type" in result && ("Success" === result.type && "value" in result || "Failure" === result.type && "error" in result); const map = (fn) => (result) => { const apply = (r) => { if (isFailure(r)) return r; return succeed(fn(r.value)); }; if (isPromise(result)) return result.then(apply); return apply(result); }; const orElse = (fn) => (result) => { const apply = (r) => { if (isSuccess(r)) return r; return fn(r.error); }; return isPromise(result) ? result.then(apply) : apply(result); }; const pipe = (value, ...functions) => { let next = value; for (const func of functions) next = func(next); return next; }; const try_ = (options) => { if (isPromise(options.try)) { if ("safe" in options && options.safe) return succeed(options.try); return options.try.then((value) => succeed(value), (error) => fail(options.catch(error))); } return (...args) => { try { const output = options.try(...args); if (isPromise(output)) { const promise$1 = succeed(output); if ("safe" in options && options.safe) return promise$1; return promise$1.catch((error) => fail(options.catch(error))); } return succeed(output); } catch (error) { if ("safe" in options && options.safe) throw error; return fail(options.catch(error)); } }; }; const unwrap = (...args) => { const firstArgument = args[0]; if (isResult(firstArgument) || isPromise(firstArgument)) { const result = firstArgument; const hasDefault$1 = 2 === args.length; const defaultValue$1 = hasDefault$1 ? args[1] : void 0; const apply = (r) => { if (isFailure(r)) { if (hasDefault$1) return defaultValue$1; throw r.error; } return r.value; }; return isPromise(result) ? result.then(apply) : apply(result); } const hasDefault = 1 === args.length; const defaultValue = hasDefault ? args[0] : void 0; return (result) => { const apply = (r) => { if (isFailure(r)) { if (hasDefault) return defaultValue; throw r.error; } return r.value; }; return isPromise(result) ? result.then(apply) : apply(result); }; }; function groupBy(arr, getKeyFromItem) { const result = {}; for (let i = 0; i < arr.length; i++) { const item = arr[i]; const key = getKeyFromItem(item); if (!Object.hasOwn(result, key)) result[key] = []; result[key].push(item); } return result; } function uniq(arr) { return Array.from(new Set(arr)); } var d = Object.defineProperty; var n = (s, t) => d(s, "name", { value: t, configurable: !0 }); typeof Symbol.asyncDispose != "symbol" && Object.defineProperty(Symbol, "asyncDispose", { configurable: !1, enumerable: !1, writable: !1, value: Symbol.for("asyncDispose") }); var P = class { static { n(this, "FsFixture"); } path; constructor(t) { this.path = t; } getPath(...t) { return path.join(this.path, ...t); } exists(t = "") { return a.access(this.getPath(t)).then(() => !0, () => !1); } rm(t = "") { return a.rm(this.getPath(t), { recursive: !0, force: !0 }); } cp(t, r, i) { return r ? r.endsWith(path.sep) && (r += path.basename(t)) : r = path.basename(t), a.cp(t, this.getPath(r), i); } mkdir(t) { return a.mkdir(this.getPath(t), { recursive: !0 }); } writeFile(t, r) { return a.writeFile(this.getPath(t), r); } writeJson(t, r) { return this.writeFile(t, JSON.stringify(r, null, 2)); } readFile(t, r) { return a.readFile(this.getPath(t), r); } async [Symbol.asyncDispose]() { await this.rm(); } }; const v = b.realpathSync(F.tmpdir()), D = `fs-fixture-${Date.now()}-${process.pid}`; let m = 0; const j = n(() => (m += 1, m), "getId"); var u = class { static { n(this, "Path"); } path; constructor(t) { this.path = t; } }; var f$1 = class extends u { static { n(this, "Directory"); } }; var y = class extends u { static { n(this, "File"); } content; constructor(t, r) { super(t), this.content = r; } }; var l = class { static { n(this, "Symlink"); } target; type; path; constructor(t, r) { this.target = t, this.type = r; } }; const w = n((s, t, r) => { const i = []; for (const p in s) { if (!Object.hasOwn(s, p)) continue; const e = path.join(t, p); let o = s[p]; if (typeof o == "function") { const g = Object.assign(Object.create(r), { filePath: e }), h = o(g); if (h instanceof l) { h.path = e, i.push(h); continue; } else o = h; } typeof o == "string" ? i.push(new y(e, o)) : i.push(new f$1(e), ...w(o, e, r)); } return i; }, "flattenFileTree"); n(async (s, t) => { const r = t?.tempDir ? path.resolve(t.tempDir) : v, i = path.join(r, `${D}-${j()}/`); if (await a.mkdir(i, { recursive: !0 }), s) { if (typeof s == "string") await a.cp(s, i, { recursive: !0, filter: t?.templateFilter }); else if (typeof s == "object") { const p = { fixturePath: i, getPath: n((...e) => path.join(i, ...e), "getPath"), symlink: n((e, o) => new l(e, o), "symlink") }; await Promise.all(w(s, i, p).map(async (e) => { e instanceof f$1 ? await a.mkdir(e.path, { recursive: !0 }) : e instanceof l ? (await a.mkdir(path.dirname(e.path), { recursive: !0 }), await a.symlink(e.target, e.path, e.type)) : e instanceof y && (await a.mkdir(path.dirname(e.path), { recursive: !0 }), await a.writeFile(e.path, e.content)); })); } } return new P(i); }, "createFixture"); async function isType(fsStatType, statsMethodName, filePath) { if (typeof filePath !== "string") throw new TypeError(`Expected a string, got ${typeof filePath}`); try { return (await a[fsStatType](filePath))[statsMethodName](); } catch (error) { if (error.code === "ENOENT") return false; throw error; } } function isTypeSync(fsStatType, statsMethodName, filePath) { if (typeof filePath !== "string") throw new TypeError(`Expected a string, got ${typeof filePath}`); try { return b[fsStatType](filePath)[statsMethodName](); } catch (error) { if (error.code === "ENOENT") return false; throw error; } } isType.bind(void 0, "stat", "isFile"); isType.bind(void 0, "stat", "isDirectory"); isType.bind(void 0, "lstat", "isSymbolicLink"); isTypeSync.bind(void 0, "statSync", "isFile"); const isDirectorySync = isTypeSync.bind(void 0, "statSync", "isDirectory"); isTypeSync.bind(void 0, "lstatSync", "isSymbolicLink"); var __require = /* @__PURE__ */ createRequire(import.meta.url); function cleanPath(path$1) { let normalized = normalize(path$1); if (normalized.length > 1 && normalized[normalized.length - 1] === sep) normalized = normalized.substring(0, normalized.length - 1); return normalized; } const SLASHES_REGEX = /[\\/]/g; function convertSlashes(path$1, separator) { return path$1.replace(SLASHES_REGEX, separator); } const WINDOWS_ROOT_DIR_REGEX = /^[a-z]:[\\/]$/i; function isRootDirectory(path$1) { return path$1 === "/" || WINDOWS_ROOT_DIR_REGEX.test(path$1); } function normalizePath(path$1, options) { const { resolvePaths, normalizePath: normalizePath$1, pathSeparator } = options; const pathNeedsCleaning = process.platform === "win32" && path$1.includes("/") || path$1.startsWith("."); if (resolvePaths) path$1 = resolve(path$1); if (normalizePath$1 || pathNeedsCleaning) path$1 = cleanPath(path$1); if (path$1 === ".") return ""; return convertSlashes(path$1[path$1.length - 1] !== pathSeparator ? path$1 + pathSeparator : path$1, pathSeparator); } function joinPathWithBasePath(filename, directoryPath) { return directoryPath + filename; } function joinPathWithRelativePath(root, options) { return function(filename, directoryPath) { if (directoryPath.startsWith(root)) return directoryPath.slice(root.length) + filename; else return convertSlashes(relative(root, directoryPath), options.pathSeparator) + options.pathSeparator + filename; }; } function joinPath(filename) { return filename; } function joinDirectoryPath(filename, directoryPath, separator) { return directoryPath + filename + separator; } function build$7(root, options) { const { relativePaths, includeBasePath } = options; return relativePaths && root ? joinPathWithRelativePath(root, options) : includeBasePath ? joinPathWithBasePath : joinPath; } function pushDirectoryWithRelativePath(root) { return function(directoryPath, paths) { paths.push(directoryPath.substring(root.length) || "."); }; } function pushDirectoryFilterWithRelativePath(root) { return function(directoryPath, paths, filters) { const relativePath = directoryPath.substring(root.length) || "."; if (filters.every((filter) => filter(relativePath, true))) paths.push(relativePath); }; } const pushDirectory = (directoryPath, paths) => { paths.push(directoryPath || "."); }; const pushDirectoryFilter = (directoryPath, paths, filters) => { const path$1 = directoryPath || "."; if (filters.every((filter) => filter(path$1, true))) paths.push(path$1); }; const empty$2 = () => {}; function build$6(root, options) { const { includeDirs, filters, relativePaths } = options; if (!includeDirs) return empty$2; if (relativePaths) return filters && filters.length ? pushDirectoryFilterWithRelativePath(root) : pushDirectoryWithRelativePath(root); return filters && filters.length ? pushDirectoryFilter : pushDirectory; } const pushFileFilterAndCount = (filename, _paths, counts, filters) => { if (filters.every((filter) => filter(filename, false))) counts.files++; }; const pushFileFilter = (filename, paths, _counts, filters) => { if (filters.every((filter) => filter(filename, false))) paths.push(filename); }; const pushFileCount = (_filename, _paths, counts, _filters) => { counts.files++; }; const pushFile = (filename, paths) => { paths.push(filename); }; const empty$1 = () => {}; function build$5(options) { const { excludeFiles, filters, onlyCounts } = options; if (excludeFiles) return empty$1; if (filters && filters.length) return onlyCounts ? pushFileFilterAndCount : pushFileFilter; else if (onlyCounts) return pushFileCount; else return pushFile; } const getArray = (paths) => { return paths; }; const getArrayGroup = () => { return [""].slice(0, 0); }; function build$4(options) { return options.group ? getArrayGroup : getArray; } const groupFiles = (groups, directory, files) => { groups.push({ directory, files, dir: directory }); }; const empty = () => {}; function build$3(options) { return options.group ? groupFiles : empty; } const resolveSymlinksAsync = function(path$1, state, callback$1) { const { queue, fs, options: { suppressErrors } } = state; queue.enqueue(); fs.realpath(path$1, (error, resolvedPath) => { if (error) return queue.dequeue(suppressErrors ? null : error, state); fs.stat(resolvedPath, (error$1, stat$1) => { if (error$1) return queue.dequeue(suppressErrors ? null : error$1, state); if (stat$1.isDirectory() && isRecursive(path$1, resolvedPath, state)) return queue.dequeue(null, state); callback$1(stat$1, resolvedPath); queue.dequeue(null, state); }); }); }; const resolveSymlinks = function(path$1, state, callback$1) { const { queue, fs, options: { suppressErrors } } = state; queue.enqueue(); try { const resolvedPath = fs.realpathSync(path$1); const stat$1 = fs.statSync(resolvedPath); if (stat$1.isDirectory() && isRecursive(path$1, resolvedPath, state)) return; callback$1(stat$1, resolvedPath); } catch (e) { if (!suppressErrors) throw e; } }; function build$2(options, isSynchronous) { if (!options.resolveSymlinks || options.excludeSymlinks) return null; return isSynchronous ? resolveSymlinks : resolveSymlinksAsync; } function isRecursive(path$1, resolved, state) { if (state.options.useRealPaths) return isRecursiveUsingRealPaths(resolved, state); let parent = dirname(path$1); let depth$1 = 1; while (parent !== state.root && depth$1 < 2) { const resolvedPath = state.symlinks.get(parent); if (!!resolvedPath && (resolvedPath === resolved || resolvedPath.startsWith(resolved) || resolved.startsWith(resolvedPath))) depth$1++; else parent = dirname(parent); } state.symlinks.set(path$1, resolved); return depth$1 > 1; } function isRecursiveUsingRealPaths(resolved, state) { return state.visited.includes(resolved + state.options.pathSeparator); } const onlyCountsSync = (state) => { return state.counts; }; const groupsSync = (state) => { return state.groups; }; const defaultSync = (state) => { return state.paths; }; const limitFilesSync = (state) => { return state.paths.slice(0, state.options.maxFiles); }; const onlyCountsAsync = (state, error, callback$1) => { report(error, callback$1, state.counts, state.options.suppressErrors); return null; }; const defaultAsync = (state, error, callback$1) => { report(error, callback$1, state.paths, state.options.suppressErrors); return null; }; const limitFilesAsync = (state, error, callback$1) => { report(error, callback$1, state.paths.slice(0, state.options.maxFiles), state.options.suppressErrors); return null; }; const groupsAsync = (state, error, callback$1) => { report(error, callback$1, state.groups, state.options.suppressErrors); return null; }; function report(error, callback$1, output, suppressErrors) { if (error && !suppressErrors) callback$1(error, output); else callback$1(null, output); } function build$1(options, isSynchronous) { const { onlyCounts, group, maxFiles } = options; if (onlyCounts) return isSynchronous ? onlyCountsSync : onlyCountsAsync; else if (group) return isSynchronous ? groupsSync : groupsAsync; else if (maxFiles) return isSynchronous ? limitFilesSync : limitFilesAsync; else return isSynchronous ? defaultSync : defaultAsync; } const readdirOpts = { withFileTypes: true }; const walkAsync = (state, crawlPath, directoryPath, currentDepth, callback$1) => { state.queue.enqueue(); if (currentDepth < 0) return state.queue.dequeue(null, state); const { fs } = state; state.visited.push(crawlPath); state.counts.directories++; fs.readdir(crawlPath || ".", readdirOpts, (error, entries = []) => { callback$1(entries, directoryPath, currentDepth); state.queue.dequeue(state.options.suppressErrors ? null : error, state); }); }; const walkSync = (state, crawlPath, directoryPath, currentDepth, callback$1) => { const { fs } = state; if (currentDepth < 0) return; state.visited.push(crawlPath); state.counts.directories++; let entries = []; try { entries = fs.readdirSync(crawlPath || ".", readdirOpts); } catch (e) { if (!state.options.suppressErrors) throw e; } callback$1(entries, directoryPath, currentDepth); }; function build(isSynchronous) { return isSynchronous ? walkSync : walkAsync; } var Queue = class { count = 0; constructor(onQueueEmpty) { this.onQueueEmpty = onQueueEmpty; } enqueue() { this.count++; return this.count; } dequeue(error, output) { if (this.onQueueEmpty && (--this.count <= 0 || error)) { this.onQueueEmpty(error, output); if (error) { output.controller.abort(); this.onQueueEmpty = void 0; } } } }; var Counter = class { _files = 0; _directories = 0; set files(num) { this._files = num; } get files() { return this._files; } set directories(num) { this._directories = num; } get directories() { return this._directories; } /* c8 ignore next 3 */ get dirs() { return this._directories; } }; var Aborter = class { aborted = false; abort() { this.aborted = true; } }; var Walker = class { root; isSynchronous; state; joinPath; pushDirectory; pushFile; getArray; groupFiles; resolveSymlink; walkDirectory; callbackInvoker; constructor(root, options, callback$1) { this.isSynchronous = !callback$1; this.callbackInvoker = build$1(options, this.isSynchronous); this.root = normalizePath(root, options); this.state = { root: isRootDirectory(this.root) ? this.root : this.root.slice(0, -1), paths: [""].slice(0, 0), groups: [], counts: new Counter(), options, queue: new Queue((error, state) => this.callbackInvoker(state, error, callback$1)), symlinks: /* @__PURE__ */ new Map(), visited: [""].slice(0, 0), controller: new Aborter(), fs: options.fs || nativeFs }; this.joinPath = build$7(this.root, options); this.pushDirectory = build$6(this.root, options); this.pushFile = build$5(options); this.getArray = build$4(options); this.groupFiles = build$3(options); this.resolveSymlink = build$2(options, this.isSynchronous); this.walkDirectory = build(this.isSynchronous); } start() { this.pushDirectory(this.root, this.state.paths, this.state.options.filters); this.walkDirectory(this.state, this.root, this.root, this.state.options.maxDepth, this.walk); return this.isSynchronous ? this.callbackInvoker(this.state, null) : null; } walk = (entries, directoryPath, depth$1) => { const { paths, options: { filters, resolveSymlinks: resolveSymlinks$1, excludeSymlinks, exclude, maxFiles, signal, useRealPaths, pathSeparator }, controller } = this.state; if (controller.aborted || signal && signal.aborted || maxFiles && paths.length > maxFiles) return; const files = this.getArray(this.state.paths); for (let i = 0; i < entries.length; ++i) { const entry = entries[i]; if (entry.isFile() || entry.isSymbolicLink() && !resolveSymlinks$1 && !excludeSymlinks) { const filename = this.joinPath(entry.name, directoryPath); this.pushFile(filename, files, this.state.counts, filters); } else if (entry.isDirectory()) { let path$1 = joinDirectoryPath(entry.name, directoryPath, this.state.options.pathSeparator); if (exclude && exclude(entry.name, path$1)) continue; this.pushDirectory(path$1, paths, filters); this.walkDirectory(this.state, path$1, path$1, depth$1 - 1, this.walk); } else if (this.resolveSymlink && entry.isSymbolicLink()) { let path$1 = joinPathWithBasePath(entry.name, directoryPath); this.resolveSymlink(path$1, this.state, (stat$1, resolvedPath) => { if (stat$1.isDirectory()) { resolvedPath = normalizePath(resolvedPath, this.state.options); if (exclude && exclude(entry.name, useRealPaths ? resolvedPath : path$1 + pathSeparator)) return; this.walkDirectory(this.state, resolvedPath, useRealPaths ? resolvedPath : path$1 + pathSeparator, depth$1 - 1, this.walk); } else { resolvedPath = useRealPaths ? resolvedPath : path$1; const filename = basename(resolvedPath); const directoryPath$1 = normalizePath(dirname(resolvedPath), this.state.options); resolvedPath = this.joinPath(filename, directoryPath$1); this.pushFile(resolvedPath, files, this.state.counts, filters); } }); } } this.groupFiles(this.state.groups, directoryPath, files); }; }; function promise(root, options) { return new Promise((resolve$1, reject) => { callback(root, options, (err, output) => { if (err) return reject(err); resolve$1(output); }); }); } function callback(root, options, callback$1) { new Walker(root, options, callback$1).start(); } function sync(root, options) { return new Walker(root, options).start(); } var APIBuilder = class { constructor(root, options) { this.root = root; this.options = options; } withPromise() { return promise(this.root, this.options); } withCallback(cb) { callback(this.root, this.options, cb); } sync() { return sync(this.root, this.options); } }; let pm = null; /* c8 ignore next 6 */ try { __require.resolve("picomatch"); pm = __require("picomatch"); } catch {} var Builder = class { globCache = {}; options = { maxDepth: Infinity, suppressErrors: true, pathSeparator: sep, filters: [] }; globFunction; constructor(options) { this.options = { ...this.options, ...options }; this.globFunction = this.options.globFunction; } group() { this.options.group = true; return this; } withPathSeparator(separator) { this.options.pathSeparator = separator; return this; } withBasePath() { this.options.includeBasePath = true; return this; } withRelativePaths() { this.options.relativePaths = true; return this; } withDirs() { this.options.includeDirs = true; return this; } withMaxDepth(depth$1) { this.options.maxDepth = depth$1; return this; } withMaxFiles(limit) { this.options.maxFiles = limit; return this; } withFullPaths() { this.options.resolvePaths = true; this.options.includeBasePath = true; return this; } withErrors() { this.options.suppressErrors = false; return this; } withSymlinks({ resolvePaths = true } = {}) { this.options.resolveSymlinks = true; this.options.useRealPaths = resolvePaths; return this.withFullPaths(); } withAbortSignal(signal) { this.options.signal = signal; return this; } normalize() { this.options.normalizePath = true; return this; } filter(predicate) { this.options.filters.push(predicate); return this; } onlyDirs() { this.options.excludeFiles = true; this.options.includeDirs = true; return this; } exclude(predicate) { this.options.exclude = predicate; return this; } onlyCounts() { this.options.onlyCounts = true; return this; } crawl(root) { return new APIBuilder(root || ".", this.options); } withGlobFunction(fn) { this.globFunction = fn; return this; } /* c8 ignore next 4 */ crawlWithOptions(root, options) { this.options = { ...this.options, ...options }; return new APIBuilder(root || ".", this.options); } glob(...patterns) { if (this.globFunction) return this.globWithOptions(patterns); return this.globWithOptions(patterns, ...[{ dot: true }]); } globWithOptions(patterns, ...options) { const globFn = this.globFunction || pm; /* c8 ignore next 5 */ if (!globFn) throw new Error("Please specify a glob function to use glob matching."); var isMatch = this.globCache[patterns.join("\0")]; if (!isMatch) { isMatch = globFn(patterns, ...options); this.globCache[patterns.join("\0")] = isMatch; } this.options.filters.push((path$1) => isMatch(path$1)); return this; } }; var require_constants = /* @__PURE__ */ __commonJSMin(((exports, module) => { const WIN_SLASH = "\\\\/"; const WIN_NO_SLASH = `[^${WIN_SLASH}]`; const DOT_LITERAL = "\\."; const PLUS_LITERAL = "\\+"; const QMARK_LITERAL = "\\?"; const SLASH_LITERAL = "\\/"; const ONE_CHAR = "(?=.)"; const QMARK = "[^/]"; const END_ANCHOR = `(?:${SLASH_LITERAL}|$)`; const START_ANCHOR = `(?:^|${SLASH_LITERAL})`; const DOTS_SLASH = `${DOT_LITERAL}{1,2}${END_ANCHOR}`; const POSIX_CHARS = { DOT_LITERAL, PLUS_LITERAL, QMARK_LITERAL, SLASH_LITERAL, ONE_CHAR, QMARK, END_ANCHOR, DOTS_SLASH, NO_DOT: `(?!${DOT_LITERAL})`, NO_DOTS: `(?!${START_ANCHOR}${DOTS_SLASH})`, NO_DOT_SLASH: `(?!${DOT_LITERAL}{0,1}${END_ANCHOR})`, NO_DOTS_SLASH: `(?!${DOTS_SLASH})`, QMARK_NO_DOT: `[^.${SLASH_LITERAL}]`, STAR: `${QMARK}*?`, START_ANCHOR, SEP: "/" }; const WINDOWS_CHARS = { ...POSIX_CHARS, SLASH_LITERAL: `[${WIN_SLASH}]`, QMARK: WIN_NO_SLASH, STAR: `${WIN_NO_SLASH}*?`, DOTS_SLASH: `${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$)`, NO_DOT: `(?!${DOT_LITERAL})`, NO_DOTS: `(?!(?:^|[${WIN_SLASH}])${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$))`, NO_DOT_SLASH: `(?!${DOT_LITERAL}{0,1}(?:[${WIN_SLASH}]|$))`, NO_DOTS_SLASH: `(?!${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$))`, QMARK_NO_DOT: `[^.${WIN_SLASH}]`, START_ANCHOR: `(?:^|[${WIN_SLASH}])`, END_ANCHOR: `(?:[${WIN_SLASH}]|$)`, SEP: "\\" }; module.exports = { MAX_LENGTH: 1024 * 64, POSIX_REGEX_SOURCE: { alnum: "a-zA-Z0-9", alpha: "a-zA-Z", ascii: "\\x00-\\x7F", blank: " \\t", cntrl: "\\x00-\\x1F\\x7F", digit: "0-9", graph: "\\x21-\\x7E", lower: "a-z", print: "\\x20-\\x7E ", punct: "\\-!\"#$%&'()\\*+,./:;<=>?@[\\]^_`{|}~", space: " \\t\\r\\n\\v\\f", upper: "A-Z", word: "A-Za-z0-9_", xdigit: "A-Fa-f0-9" }, REGEX_BACKSLASH: /\\(?![*+?^${}(|)[\]])/g, REGEX_NON_SPECIAL_CHARS: /^[^@![\].,$*+?^{}()|\\/]+/, REGEX_SPECIAL_CHARS: /[-*+?.^${}(|)[\]]/, REGEX_SPECIAL_CHARS_BACKREF: /(\\?)((\W)(\3*))/g, REGEX_SPECIAL_CHARS_GLOBAL: /([-*+?.^${}(|)[\]])/g, REGEX_REMOVE_BACKSLASH: /(?:\[.*?[^\\]\]|\\(?=.))/g, REPLACEMENTS: { __proto__: null, "***": "*", "**/**": "**", "**/**/**": "**" }, CHAR_0: 48, CHAR_9: 57, CHAR_UPPERCASE_A: 65, CHAR_LOWERCASE_A: 97, CHAR_UPPERCASE_Z: 90, CHAR_LOWERCASE_Z: 122, CHAR_LEFT_PARENTHESES: 40, CHAR_RIGHT_PARENTHESES: 41, CHAR_ASTERISK: 42, CHAR_AMPERSAND: 38, CHAR_AT: 64, CHAR_BACKWARD_SLASH: 92, CHAR_CARRIAGE_RETURN: 13, CHAR_CIRCUMFLEX_ACCENT: 94, CHAR_COLON: 58, CHAR_COMMA: 44, CHAR_DOT: 46, CHAR_DOUBLE_QUOTE: 34, CHAR_EQUAL: 61, CHAR_EXCLAMATION_MARK: 33, CHAR_FORM_FEED: 12, CHAR_FORWARD_SLASH: 47, CHAR_GRAVE_ACCENT: 96, CHAR_HASH: 35, CHAR_HYPHEN_MINUS: 45, CHAR_LEFT_ANGLE_BRACKET: 60, CHAR_LEFT_CURLY_BRACE: 123, CHAR_LEFT_SQUARE_BRACKET: 91, CHAR_LINE_FEED: 10, CHAR_NO_BREAK_SPACE: 160, CHAR_PERCENT: 37, CHAR_PLUS: 43, CHAR_QUESTION_MARK: 63, CHAR_RIGHT_ANGLE_BRACKET: 62, CHAR_RIGHT_CURLY_BRACE: 125, CHAR_RIGHT_SQUARE_BRACKET: 93, CHAR_SEMICOLON: 59, CHAR_SINGLE_QUOTE: 39, CHAR_SPACE: 32, CHAR_TAB: 9, CHAR_UNDERSCORE: 95, CHAR_VERTICAL_LINE: 124, CHAR_ZERO_WIDTH_NOBREAK_SPACE: 65279, extglobChars(chars) { return { "!": { type: "negate", open: "(?:(?!(?:", close: `))${chars.STAR})` }, "?": { type: "qmark", open: "(?:", close: ")?" }, "+": { type: "plus", open: "(?:", close: ")+" }, "*": { type: "star", open: "(?:", close: ")*" }, "@": { type: "at", open: "(?:", close: ")" } }; }, globChars(win32) { return win32 === true ? WINDOWS_CHARS : POSIX_CHARS; } }; })); var require_utils = /* @__PURE__ */ __commonJSMin(((exports) => { const { REGEX_BACKSLASH, REGEX_REMOVE_BACKSLASH, REGEX_SPECIAL_CHARS, REGEX_SPECIAL_CHARS_GLOBAL } = require_constants(); exports.isObject = (val) => val !== null && typeof val === "object" && !Array.isArray(val); exports.hasRegexChars = (str) => REGEX_SPECIAL_CHARS.test(str); exports.isRegexChar = (str) => str.length === 1 && exports.hasRegexChars(str); exports.escapeRegex = (str) => str.replace(REGEX_SPECIAL_CHARS_GLOBAL, "\\$1"); exports.toPosixSlashes = (str) => str.replace(REGEX_BACKSLASH, "/"); exports.isWindows = () => { if (typeof navigator !== "undefined" && navigator.platform) { const platform = navigator.platform.toLowerCase(); return platform === "win32" || platform === "windows"; } if (typeof process !== "undefined" && process.platform) return process.platform === "win32"; return false; }; exports.removeBackslashes = (str) => { return str.replace(REGEX_REMOVE_BACKSLASH, (match) => { return match === "\\" ? "" : match; }); }; exports.escapeLast = (input, char, lastIdx) => { const idx = input.lastIndexOf(char, lastIdx); if (idx === -1) return input; if (input[idx - 1] === "\\") return exports.escapeLast(input, char, idx - 1); return `${input.slice(0, idx)}\\${input.slice(idx)}`; }; exports.removePrefix = (input, state = {}) => { let output = input; if (output.startsWith("./")) { output = output.slice(2); state.prefix = "./"; } return output; }; exports.wrapOutput = (input, state = {}, options = {}) => { let output = `${options.contains ? "" : "^"}(?:${input})${options.contains ? "" : "$"}`; if (state.negated === true) output = `(?:^(?!${output}).*$)`; return output; }; exports.basename = (path$1, { windows } = {}) => { const segs = path$1.split(windows ? /[\\/]/ : "/"); const last = segs[segs.length - 1]; if (last === "") return segs[segs.length - 2]; return last; }; })); var require_scan = /* @__PURE__ */ __commonJSMin(((exports, module) => { const utils$3 = require_utils(); const { CHAR_ASTERISK, CHAR_AT, CHAR_BACKWARD_SLASH, CHAR_COMMA, CHAR_DOT, CHAR_EXCLAMATION_MARK, CHAR_FORWARD_SLASH, CHAR_LEFT_CURLY_BRACE, CHAR_LEFT_PARENTHESES, CHAR_LEFT_SQUARE_BRACKET, CHAR_PLUS, CHAR_QUESTION_MARK, CHAR_RIGHT_CURLY_BRACE, CHAR_RIGHT_PARENTHESES, CHAR_RIGHT_SQUARE_BRACKET } = require_constants(); const isPathSeparator = (code) => { return code === CHAR_FORWARD_SLASH || code === CHAR_BACKWARD_SLASH; }; const depth = (token) => { if (token.isPrefix !== true) token.depth = token.isGlobstar ? Infinity : 1; }; const scan$1 = (input, options) => { const opts = options || {}; const length = input.length - 1; const scanToEnd = opts.parts === true || opts.scanToEnd === true; const slashes = []; const tokens = []; const parts = []; let str = input; let index = -1; let start = 0; let lastIndex = 0; let isBrace = false; let isBracket = false; let isGlob = false; let isExtglob = false; let isGlobstar = false; let braceEscaped = false; let backslashes = false; let negated = false; let negatedExtglob = false; let finished = false; let braces = 0; let prev; let code; let token = { value: "", depth: 0, isGlob: false }; const eos = () => index >= length; const peek = () => str.charCodeAt(index + 1); const advance = () => { prev = code; return str.charCodeAt(++index); }; while (index < length) { code = advance(); let next; if (code === CHAR_BACKWARD_SLASH) { backslashes = token.backslashes = true; code = advance(); if (code === CHAR_LEFT_CURLY_BRACE) braceEscaped = true; continue; } if (braceEscaped === true || code === CHAR_LEFT_CURLY_BRACE) { braces++; while (eos() !== true && (code = advance())) { if (code === CHAR_BACKWARD_SLASH) { backslashes = token.backslashes = true; advance(); continue; } if (code === CHAR_LEFT_CURLY_BRACE) { braces++; continue; } if (braceEscaped !== true && code === CHAR_DOT && (code = advance()) === CHAR_DOT) { isBrace = token.isBrace = true; isGlob = token.isGlob = true; finished = true; if (scanToEnd === true) continue; break; } if (braceEscaped !== true && code === CHAR_COMMA) { isBrace = token.isBrace = true; isGlob = token.isGlob = true; finished = true; if (scanToEnd === true) continue; break; } if (code === CHAR_RIGHT_CURLY_BRACE) { braces--; if (braces === 0) { braceEscaped = false; isBrace = token.isBrace = true; finished = true; break; } } } if (scanToEnd === true) continue; break; } if (code === CHAR_FORWARD_SLASH) { slashes.push(index); tokens.push(token); token = { value: "", depth: 0, isGlob: false }; if (finished === true) continue; if (prev === CHAR_DOT && index === start + 1) { start += 2; continue; } lastIndex = index + 1; continue; } if (opts.noext !== true) { if ((code === CHAR_PLUS || code === CHAR_AT || code === CHAR_ASTERISK || code === CHAR_QUESTION_MARK || code === CHAR_EXCLAMATION_MARK) === true && peek() === CHAR_LEFT_PARENTHESES) { isGlob = token.isGlob = true; isExtglob = token.isExtglob = true; finished = true; if (code === CHAR_EXCLAMATION_MARK && index === start) negatedExtglob = true; if (scanToEnd === true) { while (eos() !== true && (code = advance())) { if (code === CHAR_BACKWARD_SLASH) { backslashes = token.backslashes = true; code = advance(); continue; } if (code === CHAR_RIGHT_PARENTHESES) { isGlob = token.isGlob = true; finished = true; break; } } continue; } break; } } if (code === CHAR_ASTERISK) { if (prev === CHAR_ASTERISK) isGlobstar = token.isGlobstar = true; isGlob = token.isGlob = true; finished = true; if (scanToEnd === true) continue; break; } if (code === CHAR_QUESTION_MARK) { isGlob = token.isGlob = true; finished = true; if (scanToEnd === true) continue; break; } if (code === CHAR_LEFT_SQUARE_BRACKET) { while (eos() !== true && (next = advance())) { if (next === CHAR_BACKWARD_SLASH) { backslashes = token.backslashes = true; advance(); continue; } if (next === CHAR_RIGHT_SQUARE_BRACKET) { isBracket = token.isBracket = true; isGlob = token.isGlob = true; finished = true; break; } } if (scanToEnd === true) continue; break; } if (opts.nonegate !== true && code === CHAR_EXCLAMATION_MARK && index === start) { negated = token.negated = true; start++; continue; } if (opts.noparen !== true && code === CHAR_LEFT_PARENTHESES) { isGlob = token.isGlob = true; if (scanToEnd === true) { while (eos() !== true && (code = advance())) { if (code === CHAR_LEFT_PARENTHESES) { backslashes = token.backslashes = true; code = advance(); continue; } if (code === CHAR_RIGHT_PARENTHESES) { finished = true; break; } } continue; } break; } if (isGlob === true) { finished = true; if (scanToEnd === true) continue; break; } } if (opts.noext === true) { isExtglob = false; isGlob = false; } let base = str; let prefix = ""; let glob$1 = ""; if (start > 0) { prefix = str.slice(0, start); str = str.slice(start); lastIndex -= start; } if (base && isGlob === true && lastIndex > 0) { base = str.slice(0, lastIndex); glob$1 = str.slice(lastIndex); } else if (isGlob === true) { base = ""; glob$1 = str; } else base = str; if (base && base !== "" && base !== "/" && base !== str) { if (isPathSeparator(base.charCodeAt(base.length - 1))) base = base.slice(0, -1); } if (opts.unescape === true) { if (glob$1) glob$1 = utils$3.removeBackslashes(glob$1); if (base && backslashes === true) base = utils$3.removeBackslashes(base); } const state = { prefix, input, start, base, glob: glob$1, isBrace, isBracket, isGlob, isExtglob, isGlobstar, negated, negatedExtglob }; if (opts.tokens === true) { state.maxDepth = 0; if (!isPathSeparator(code)) tokens.push(token); state.tokens = tokens; } if (opts.parts === true || opts.tokens === true) { let prevIndex; for (let idx = 0; idx < slashes.length; idx++) { const n$1 = prevIndex ? prevIndex + 1 : start; const i = slashes[idx]; const value = input.slice(n$1, i); if (opts.tokens) { if (idx === 0 && start !== 0) { tokens[idx].isPrefix = true; tokens[idx].value = prefix; } else tokens[idx].value = value; depth(tokens[idx]); state.maxDepth += tokens[idx].depth; } if (idx !== 0 || value !== "") parts.push(value); prevIndex = i; } if (prevIndex && prevIndex + 1 < input.length) { const value = input.slice(prevIndex + 1); parts.push(value); if (opts.tokens) { tokens[tokens.length - 1].value = value; depth(tokens[tokens.length - 1]); state.maxDepth += tokens[tokens.length - 1].depth; } } state.slashes = slashes; state.parts = parts; } return state; }; module.exports = scan$1; })); var require_parse = /* @__PURE__ */ __commonJSMin(((exports, module) => { const constants$1 = require_constants(); const utils$2 = require_utils(); const { MAX_LENGTH, POSIX_REGEX_SOURCE, REGEX_NON_SPECIAL_CHARS, REGEX_SPECIAL_CHARS_BACKREF, REPLACEMENTS } = constants$1; const expandRange = (args, options) => { if (typeof options.expandRange === "function") return options.expandRange(...args, options); args.sort(); const value = `[${args.join("-")}]`; try { new RegExp(value); } catch (ex) { return args.map((v$1) => utils$2.escapeRegex(v$1)).join(".."); } return value; }; const syntaxError = (type, char) => { return `Missing ${type}: "${char}" - use "\\\\${char}" to match literal characters`; }; const parse$1 = (input, options) => { if (typeof input !== "string") throw new TypeError("Expected a string"); input = REPLACEMENTS[input] || input; const opts = { ...options }; const max = typeof opts.maxLength === "number" ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH; let len = input.length; if (len > max) throw new SyntaxError(`Input length: ${len}, exceeds maximum allowed length: ${max}`); const bos = { type: "bos", value: "", output: opts.prepend || "" }; const tokens = [bos]; const capture = opts.capture ? "" : "?:"; const PLATFORM_CHARS = constants$1.globChars(opts.windows); const EXTGLOB_CHARS = constants$1.extglobChars(PLATFORM_CHARS); const { DOT_LITERAL: DOT_LITERAL$1, PLUS_LITERAL: PLUS_LITERAL$1, SLASH_LITERAL: SLASH_LITERAL$1, ONE_CHAR: ONE_CHAR$1, DOTS_SLASH: DOTS_SLASH$1, NO_DOT, NO_DOT_SLASH, NO_DOTS_SLASH, QMARK: QMARK$1, QMARK_NO_DOT, STAR, START_ANCHOR: START_ANCHOR$1 } = PLATFORM_CHARS; const globstar = (opts$1) => { return `(${capture}(?:(?!${START_ANCHOR$1}${opts$1.dot ? DOTS_SLASH$1 : DOT_LITERAL$1}).)*?)`; }; const nodot = opts.dot ? "" : NO_DOT; const qmarkNoDot = opts.dot ? QMARK$1 : QMARK_NO_DOT; let star = opts.bash === true ? globstar(opts) : STAR; if (opts.capture) star = `(${star})`; if (typeof opts.noext === "boolean") opts.noextglob = opts.noext; const state = { input, index: -1, start: 0, dot: opts.dot === true, consumed: "", output: "", prefix: "", backtrack: false, negated: false, brackets: 0, braces: 0, parens: 0, quotes: 0, globstar: false, tokens }; input = utils$2.removePrefix(input, state); len = input.length; const extglobs = []; const braces = []; const stack = []; let prev = bos; let value; const eos = () => state.index === len - 1; const peek = state.peek = (n$1 = 1) => input[state.index + n$1]; const advance = state.advance = () => input[++state.index] || ""; const remaining = () => input.slice(state.index + 1); const consume = (value$1 = "", num = 0) => { state.consumed += value$1; state.index += num; }; const append = (token) => { state.output += token.output != null ? token.output : token.value; consume(token.value); }; const negate = () => { let count = 1; while (peek() === "!" && (peek(2) !== "(" || peek(3) === "?")) { advance(); state.start++; count++; } if (count % 2 === 0) return false; state.negated = true; state.start++; return true; }; const increment = (type) => { state[type]++; stack.push(type); }; const decrement = (type) => { state[type]--; stack.pop(); }; const push = (tok) => { if (prev.type === "globstar") { const isBrace = state.braces > 0 && (tok.type === "comma" || tok.type === "brace"); const isExtglob = tok.extglob === true || extglobs.length && (tok.type === "pipe" || tok.type === "paren"); if (tok.type !== "slash" && tok.type !== "paren" && !isBrace && !isExtglob) { state.output = state.output.slice(0, -prev.output.length); prev.type = "star"; prev.value = "*"; prev.output = star; state.output += prev.output; } } if (extglobs.length && tok.type !== "paren") extglobs[extglobs.length - 1].inner += tok.value; if (tok.value || tok.output) append(tok); if (prev && prev.type === "text" && tok.type === "text") { prev.output = (prev.output || prev.value) + tok.value; prev.value += tok.value; return; } tok.prev = prev; tokens.push(tok); prev = tok; }; const extglobOpen = (type, value$1) => { const token = { ...EXTGLOB_CHARS[value$1], conditions: 1, inner: "" }; token.prev = prev; token.parens = state.parens; token.output = state.output; const output = (opts.capture ? "(" : "") + token.open; increment("parens"); push({ type, value: value$1, output: state.output ? "" : ONE_CHAR$1 }); push({ type: "paren", extglob: true, value: advance(), output }); extglobs.push(token); }; const extglobClose = (token) => { let output = token.close + (opts.capture ? ")" : ""); let rest; if (token.type === "negate") { let extglobStar = star; if (token.inner && token.inner.length > 1 && token.inner.includes("/")) extglobStar = globstar(opts); if (extglobStar !== star || eos() || /^\)+$/.test(remaining())) output = token.close = `)$))${extglobStar}`; if (token.inner.includes("*") && (rest = remaining()) && /^\.[^\\/.]+$/.test(rest)) output = token.close = `)${parse$1(rest, { ...options, fastpaths: false }).output})${extglobStar})`; if (token.prev.type === "bos") state.negatedExtglob = true; } push({ type: "paren", extglob: true, value, output }); decrement("parens"); }; if (opts.fastpaths !== false && !/(^[*!]|[/()[\]{}"])/.test(input)) { let backslashes = false; let output = input.replace(REGEX_SPECIAL_CHARS_BACKREF, (m$1, esc, chars, first, rest, index) => { if (first === "\\") { backslashes = true; return m$1; } if (first === "?") { if (esc) return esc + first + (rest ? QMARK$1.repeat(rest.length) : ""); if (index === 0) return qmarkNoDot + (rest ? QMARK$1.repeat(rest.length) : ""); return QMARK$1.repeat(chars.length); } if (first === ".") return DOT_LITERAL$1.repeat(chars.length); if (first === "*") { if (esc) return esc + first + (rest ? star : ""); return star; } return esc ? m$1 : `\\${m$1}`; }); if (backslashes === true) if (opts.unescape === true) output = output.replace(/\\/g, ""); else output = output.replace(/\\+/g, (m$1) => { return m$1.length % 2 === 0 ? "\\\\" : m$1 ? "\\" : ""; }); if (output === input && opts.contains === true) { state.output = input; return state; } state.output = utils$2.wrapOutput(output, state, options); return state; } while (!eos()) { value = advance(); if (value === "\0") continue; if (value === "\\") { const next = peek(); if (next === "/" && opts.bash !== true) continue; if (next === "." || next === ";") continue; if (!next) { value += "\\"; push({ type: "text", value }); continue; } const match = /^\\+/.exec(remaining()); let slashes = 0; if (match && match[0].length > 2) { slashes = match[0].length; state.index += slashes; if (slashes % 2 !== 0) value += "\\"; } if (opts.unescape === true) value = advance(); else value += advance(); if (state.brackets === 0) { push({ type: "text", value }); continue; } } if (state.brackets > 0 && (value !== "]" || prev.value === "[" || prev.value === "[^")) { if (opts.posix !== false && value === ":") { const inner = prev.value.slice(1); if (inner.includes("[")) { prev.posix = true; if (inner.includes(":")) { const idx = prev.value.lastIndexOf("["); const pre = prev.value.slice(0, idx); const posix$1 = POSIX_REGEX_SOURCE[prev.value.slice(idx + 2)]; if (posix$1) { prev.value = pre + posix$1; state.backtrack = true; advance(); if (!bos.output && tokens.indexOf(prev) === 1) bos.output = ONE_CHAR$1; continue; } } } } if (value === "[" && peek() !== ":" || value === "-" && peek() === "]") value = `\\${value}`; if (value === "]" && (prev.value === "[" || prev.value === "[^")) value = `\\${value}`; if (opts.posix === true && value === "!" && prev.value === "[") value = "^"; prev.value += value; append({ value }); continue; } if (state.quotes === 1 && value !== "\"") { value = utils$2.escapeRegex(value); prev.value += value; append({ value }); continue; } if (value === "\"") { state.quotes = state.quotes === 1 ? 0 : 1; if (opts.keepQuotes === true) push({ type: "text", value }); continue; } if (value === "(") { increment("parens"); push({ type: "paren", value }); continue; } if (value === ")") { if (state.parens === 0 && opts.strictBrackets === true) throw new SyntaxError(syntaxError("opening", "(")); const extglob = extglobs[extglobs.length - 1]; if (extglob && state.parens === extglob.parens + 1) { extglobClose(extglobs.pop()); continue; } push({ type: "paren", value, output: state.parens ? ")" : "\\)" }); decrement("parens"); continue; } if (value === "[") { if (opts.nobracket === true || !remaining().includes("]")) { if (opts.nobracket !== true && opts.strictBrackets === true) throw new SyntaxError(syntaxError("closing", "]")); value = `\\${value}`; } else increment("brackets"); push({ type: "bracket", value }); continue; } if (value === "]") { if (opts.nobracket === true || prev && prev.type === "bracket" && prev.value.length === 1) { push({ type: "text", value, output: `\\${value}` }); continue; } if (state.brackets === 0) { if (opts.strictBrackets === true) throw new SyntaxError(syntaxError("opening", "[")); push({ type: "text", value, output: `\\${value}` }); continue; } decrement("brackets"); const prevValue = prev.value.slice(1); if (prev.posix !== true && prevValue[0] === "^" && !prevValue.includes("/")) value = `/${value}`; prev.value += value; append({ value }); if (opts.literalBrackets === false || utils$2.hasRegexChars(prevValue)) continue; const escaped = utils$2.escapeRegex(prev.value); state.output = state.output.slice(0, -prev.value.length); if (opts.literalBrackets === true) { state.output += escaped; prev.value = escaped; continue; } prev.value = `(${capture}${escaped}|${prev.value})`; state.output += prev.value; continue; } if (value === "{" && opts.nobrace !== true) { increment("braces"); const open = { type: "brace", value