@visulima/cerebro 3.0.0-alpha.13 → 3.0.0-alpha.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/LICENSE.md +92 -91
  3. package/dist/commands/completion-command.d.ts +1 -1
  4. package/dist/commands/completion-command.js +5 -204
  5. package/dist/commands/help-command.d.ts +1 -1
  6. package/dist/commands/help-command.js +1 -262
  7. package/dist/commands/readme-command.d.ts +1 -1
  8. package/dist/commands/readme-command.js +32 -317
  9. package/dist/commands/version-command.d.ts +1 -1
  10. package/dist/commands/version-command.js +1 -18
  11. package/dist/index.d.ts +2 -2
  12. package/dist/index.js +1 -8
  13. package/dist/logger/create-pail-logger.js +1 -34
  14. package/dist/packem_chunks/has-new-version.js +1 -264
  15. package/dist/packem_shared/Cerebro-Cnr7AGMP.js +4 -0
  16. package/dist/packem_shared/VERBOSITY_QUIET-XPultrIA.js +1 -0
  17. package/dist/packem_shared/VisulimaError-Bh91XNXu.js +76 -0
  18. package/dist/packem_shared/cerebro-error-BnJTixb2.js +1 -0
  19. package/dist/packem_shared/index-B0BiusY7.js +6 -0
  20. package/dist/packem_shared/isVisulimaError-jVZgumOU-C4fgdbWg.js +1 -0
  21. package/dist/packem_shared/lazyNamed-DOmefeJM.js +1 -0
  22. package/dist/packem_shared/{plugin-manager.d-Du-YXFui.d.ts → plugin-manager.d-Dz-wu1tI.d.ts} +3 -0
  23. package/dist/packem_shared/renderError-B_XyYPKJ-B65kP-Ou.js +24 -0
  24. package/dist/packem_shared/runtime-process-DKHFvYkv.js +1 -0
  25. package/dist/plugins/error-handler-plugin.d.ts +1 -1
  26. package/dist/plugins/error-handler-plugin.js +1 -648
  27. package/dist/plugins/runtime-version-check-plugin.d.ts +1 -1
  28. package/dist/plugins/runtime-version-check-plugin.js +1 -77
  29. package/dist/plugins/update-notifier/update-notifier-plugin.d.ts +1 -1
  30. package/dist/plugins/update-notifier/update-notifier-plugin.js +1 -517
  31. package/dist/util/general/compile-cache.js +1 -16
  32. package/dist/util/general/heap-tuning.js +1 -91
  33. package/package.json +23 -23
  34. package/dist/packem_shared/Cerebro-C1h3DXwy.js +0 -3509
  35. package/dist/packem_shared/VERBOSITY_QUIET-Dp46zlLW.js +0 -10
  36. package/dist/packem_shared/VisulimaError-DA7QsCxH.js +0 -34
  37. package/dist/packem_shared/cerebro-error-GmJ3jN7Q.js +0 -16
  38. package/dist/packem_shared/index--1UArng3.js +0 -267
  39. package/dist/packem_shared/lazyNamed-B278Tf9_.js +0 -6
  40. package/dist/packem_shared/runtime-process-B6ZplyWn.js +0 -187
@@ -1,18 +1 @@
1
- const versionCommand = {
2
- alias: ["v", "V"],
3
- description: "Output the version number",
4
- execute: ({ logger, runtime }) => {
5
- const version = runtime.getPackageVersion();
6
- if (version === void 0) {
7
- logger.warn("Unknown version");
8
- logger.debug("The version number was not provided by the cli constructor.");
9
- } else {
10
- logger.info(version);
11
- }
12
- },
13
- name: "version",
14
- options: [],
15
- usage: []
16
- };
17
-
18
- export { versionCommand as default };
1
+ var t=Object.defineProperty;var r=(e,n)=>t(e,"name",{value:n,configurable:!0});var i=Object.defineProperty,a=r((e,n)=>i(e,"name",{value:n,configurable:!0}),"s");const u={alias:["v","V"],description:"Output the version number",execute:a(({logger:e,runtime:n})=>{const o=n.getPackageVersion();o===void 0?(e.warn("Unknown version"),e.debug("The version number was not provided by the cli constructor.")):e.info(o)},"execute"),name:"version",options:[],usage:[]};export{u as default};
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { a as CommandSection, O as OptionDefinition, C as Command, P as Plugin, b as PluginManager, c as CliRunOptions, R as RunCommandOptions, d as Cli$1, L as LazyCommandModule } from "./packem_shared/plugin-manager.d-Du-YXFui.js";
2
- export { type A as ArgumentDefinition, type e as CommandExecute, type E as EnvDefinition, type f as OutputType, type g as PluginContext, type T as Toolbox, type V as VERBOSITY_LEVEL } from "./packem_shared/plugin-manager.d-Du-YXFui.js";
1
+ import { a as CommandSection, O as OptionDefinition, C as Command, P as Plugin, b as PluginManager, c as CliRunOptions, R as RunCommandOptions, d as Cli$1, L as LazyCommandModule } from "./packem_shared/plugin-manager.d-Dz-wu1tI.js";
2
+ export { type A as ArgumentDefinition, type e as CommandExecute, type E as EnvDefinition, type f as OutputType, type g as PluginContext, type T as Toolbox, type V as VERBOSITY_LEVEL } from "./packem_shared/plugin-manager.d-Dz-wu1tI.js";
3
3
  export { V as VisulimaError } from "./packem_shared/index.d-Br8HpP0A.js";
4
4
  import '@visulima/tabular';
5
5
  type CliOptions<T extends Console = Console> = {
package/dist/index.js CHANGED
@@ -1,8 +1 @@
1
- import { Cli } from './packem_shared/Cerebro-C1h3DXwy.js';
2
- export { VERBOSITY_DEBUG, VERBOSITY_NORMAL, VERBOSITY_QUIET, VERBOSITY_VERBOSE } from './packem_shared/VERBOSITY_QUIET-Dp46zlLW.js';
3
- export { lazyNamed } from './packem_shared/lazyNamed-B278Tf9_.js';
4
- export { VisulimaError } from './packem_shared/VisulimaError-DA7QsCxH.js';
5
-
6
- const createCerebro = (name, options) => new Cli(name, options);
7
-
8
- export { Cli as Cerebro, createCerebro };
1
+ var a=Object.defineProperty;var o=(r,e)=>a(r,"name",{value:e,configurable:!0});import{Cli as t}from"./packem_shared/Cerebro-Cnr7AGMP.js";import{VERBOSITY_DEBUG as R,VERBOSITY_NORMAL as V,VERBOSITY_QUIET as b,VERBOSITY_VERBOSE as c}from"./packem_shared/VERBOSITY_QUIET-XPultrIA.js";import{lazyNamed as n}from"./packem_shared/lazyNamed-DOmefeJM.js";import{p as S}from"./packem_shared/isVisulimaError-jVZgumOU-C4fgdbWg.js";var E=Object.defineProperty,m=o((r,e)=>E(r,"name",{value:e,configurable:!0}),"t");const f=m((r,e)=>new t(r,e),"createCerebro");export{t as Cerebro,R as VERBOSITY_DEBUG,V as VERBOSITY_NORMAL,b as VERBOSITY_QUIET,c as VERBOSITY_VERBOSE,S as VisulimaError,f as createCerebro,n as lazyNamed};
@@ -1,34 +1 @@
1
- import CallerProcessor from '@visulima/pail/processor/caller';
2
- import MessageFormatterProcessor from '@visulima/pail/processor/message-formatter';
3
- import { createPail } from '@visulima/pail/server';
4
- import { VERBOSITY_DEBUG, VERBOSITY_QUIET } from '../packem_shared/VERBOSITY_QUIET-Dp46zlLW.js';
5
- import { d as getEnv } from '../packem_shared/runtime-process-B6ZplyWn.js';
6
-
7
- const createPailLogger = (options) => {
8
- const cerebroLevelToPailLevel = {
9
- 16: "informational",
10
- 32: "informational",
11
- 64: "trace",
12
- 128: "debug",
13
- 256: "debug"
14
- };
15
- const processors = [new MessageFormatterProcessor()];
16
- const env = getEnv();
17
- const outputLevel = env.CEREBRO_OUTPUT_LEVEL;
18
- if (outputLevel === String(128) || outputLevel === String(VERBOSITY_DEBUG)) {
19
- processors.push(new CallerProcessor());
20
- }
21
- const envLogLevel = (outputLevel && cerebroLevelToPailLevel[outputLevel]) ?? "informational";
22
- const loggerOptions = {
23
- ...options,
24
- logLevel: options?.logLevel ?? envLogLevel,
25
- processors: options?.processors ? [...processors, ...options.processors] : processors
26
- };
27
- const logger = createPail(loggerOptions);
28
- if (outputLevel === String(VERBOSITY_QUIET)) {
29
- logger.disable();
30
- }
31
- return logger;
32
- };
33
-
34
- export { createPailLogger as default };
1
+ var l=Object.defineProperty;var i=(o,r)=>l(o,"name",{value:r,configurable:!0});import m from"@visulima/pail/processor/caller";import c from"@visulima/pail/processor/message-formatter";import{createPail as f}from"@visulima/pail/server";import{VERBOSITY_DEBUG as g,VERBOSITY_QUIET as p}from"../packem_shared/VERBOSITY_QUIET-XPultrIA.js";import{d as E}from"../packem_shared/runtime-process-DKHFvYkv.js";var u=Object.defineProperty,d=i((o,r)=>u(o,"name",{value:r,configurable:!0}),"i");const B=d(o=>{const r={16:"informational",32:"informational",64:"trace",128:"debug",256:"debug"},t=[new c],e=E().CEREBRO_OUTPUT_LEVEL;(e===String(128)||e===String(g))&&t.push(new m);const n=(e&&r[e])??"informational",s={...o,logLevel:o?.logLevel??n,processors:o?.processors?[...t,...o.processors]:t},a=f(s);return e===String(p)&&a.disable(),a},"createPailLogger");export{B as default};
@@ -1,264 +1 @@
1
- import { createRequire as __cjs_createRequire } from "node:module";
2
-
3
- const __cjs_require = __cjs_createRequire(import.meta.url);
4
-
5
- const __cjs_getProcess = typeof globalThis !== "undefined" && typeof globalThis.process !== "undefined" ? globalThis.process : process;
6
-
7
- const __cjs_getBuiltinModule = (module) => {
8
- // Check if we're in Node.js and version supports getBuiltinModule
9
- if (typeof __cjs_getProcess !== "undefined" && __cjs_getProcess.versions && __cjs_getProcess.versions.node) {
10
- const [major, minor] = __cjs_getProcess.versions.node.split(".").map(Number);
11
- // Node.js 20.16.0+ and 22.3.0+
12
- if (major > 22 || (major === 22 && minor >= 3) || (major === 20 && minor >= 16)) {
13
- return __cjs_getProcess.getBuiltinModule(module);
14
- }
15
- }
16
- // Fallback to createRequire
17
- return __cjs_require(module);
18
- };
19
-
20
- const {
21
- existsSync,
22
- readFileSync,
23
- mkdirSync,
24
- writeFileSync
25
- } = __cjs_getBuiltinModule("node:fs");
26
- import { findCacheDirSync } from '@visulima/find-cache-dir';
27
- import { C as CerebroError } from '../packem_shared/cerebro-error-GmJ3jN7Q.js';
28
- const {
29
- get
30
- } = __cjs_getBuiltinModule("node:https");
31
-
32
- const semverGt = (version1, version2) => {
33
- const v1Components = version1.split(".").map(Number);
34
- const v2Components = version2.split(".").map(Number);
35
- for (const [index, v1Component] of v1Components.entries()) {
36
- if (v1Component > v2Components[index]) {
37
- return true;
38
- }
39
- if (v1Component < v2Components[index]) {
40
- return false;
41
- }
42
- }
43
- return false;
44
- };
45
-
46
- const DRIVE_LETTER_START_RE = /^[A-Z]:\//i;
47
- const normalizeWindowsPath = (input = "") => {
48
- if (!input) {
49
- return input;
50
- }
51
- return input.replaceAll("\\", "/").replace(DRIVE_LETTER_START_RE, (r) => r.toUpperCase());
52
- };
53
- const UNC_REGEX = /^[/\\]{2}/;
54
- const IS_ABSOLUTE_RE = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Z]:[/\\]/i;
55
- const DRIVE_LETTER_RE = /^[A-Z]:$/i;
56
- const TRAILING_SLASH_RE = /\/$/;
57
- const normalizeString = (path2, allowAboveRoot) => {
58
- let result = "";
59
- let lastSegmentLength = 0;
60
- let lastSlash = -1;
61
- let dots = 0;
62
- let char;
63
- for (let index = 0; index <= path2.length; ++index) {
64
- if (index < path2.length) {
65
- char = path2[index];
66
- } else if (char === "/") {
67
- break;
68
- } else {
69
- char = "/";
70
- }
71
- if (char === "/") {
72
- if (lastSlash === index - 1 || dots === 1) ;
73
- else if (dots === 2) {
74
- if (result.length < 2 || lastSegmentLength !== 2 || !result.endsWith(".") || result.at(-2) !== ".") {
75
- if (result.length > 2) {
76
- const lastSlashIndex = result.lastIndexOf("/");
77
- if (lastSlashIndex === -1) {
78
- result = "";
79
- lastSegmentLength = 0;
80
- } else {
81
- result = result.slice(0, lastSlashIndex);
82
- lastSegmentLength = result.length - 1 - result.lastIndexOf("/");
83
- }
84
- lastSlash = index;
85
- dots = 0;
86
- continue;
87
- } else if (result.length > 0) {
88
- result = "";
89
- lastSegmentLength = 0;
90
- lastSlash = index;
91
- dots = 0;
92
- continue;
93
- }
94
- }
95
- if (allowAboveRoot) {
96
- result += result.length > 0 ? "/.." : "..";
97
- lastSegmentLength = 2;
98
- }
99
- } else {
100
- if (result.length > 0) {
101
- result += `/${path2.slice(lastSlash + 1, index)}`;
102
- } else {
103
- result = path2.slice(lastSlash + 1, index);
104
- }
105
- lastSegmentLength = index - lastSlash - 1;
106
- }
107
- lastSlash = index;
108
- dots = 0;
109
- } else if (char === "." && dots !== -1) {
110
- ++dots;
111
- } else {
112
- dots = -1;
113
- }
114
- }
115
- return result;
116
- };
117
- const isAbsolute = (path2) => IS_ABSOLUTE_RE.test(path2);
118
- const normalize = function(path2) {
119
- if (path2.length === 0) {
120
- return ".";
121
- }
122
- path2 = normalizeWindowsPath(path2);
123
- const isUNCPath = UNC_REGEX.exec(path2);
124
- const isPathAbsolute = isAbsolute(path2);
125
- const trailingSeparator = path2.at(-1) === "/";
126
- path2 = normalizeString(path2, !isPathAbsolute);
127
- if (path2.length === 0) {
128
- if (isPathAbsolute) {
129
- return "/";
130
- }
131
- return trailingSeparator ? "./" : ".";
132
- }
133
- if (trailingSeparator) {
134
- path2 += "/";
135
- }
136
- if (DRIVE_LETTER_RE.test(path2)) {
137
- path2 += "/";
138
- }
139
- if (isUNCPath) {
140
- if (!isPathAbsolute) {
141
- return `//./${path2}`;
142
- }
143
- return `//${path2}`;
144
- }
145
- return isPathAbsolute && !isAbsolute(path2) ? `/${path2}` : path2;
146
- };
147
- const join = (...segments) => {
148
- let path2 = "";
149
- for (const seg of segments) {
150
- if (!seg) {
151
- continue;
152
- }
153
- if (path2.length > 0) {
154
- const pathTrailing = path2.at(-1) === "/";
155
- const segLeading = seg[0] === "/";
156
- const both = pathTrailing && segLeading;
157
- if (both) {
158
- path2 += seg.slice(1);
159
- } else {
160
- path2 += pathTrailing || segLeading ? seg : `/${seg}`;
161
- }
162
- } else {
163
- path2 += seg;
164
- }
165
- }
166
- return normalize(path2);
167
- };
168
- const dirname = (path2) => {
169
- const segments = normalizeWindowsPath(path2).replace(TRAILING_SLASH_RE, "").split("/").slice(0, -1);
170
- if (segments.length === 1 && DRIVE_LETTER_RE.test(segments[0])) {
171
- segments[0] = `${segments[0]}/`;
172
- }
173
- return segments.join("/") || (isAbsolute(path2) ? "/" : ".");
174
- };
175
-
176
- class UpdateNotifierError extends CerebroError {
177
- constructor(message, code = "UPDATE_NOTIFIER_ERROR", context) {
178
- super(message, code, context);
179
- this.name = "UpdateNotifierError";
180
- }
181
- }
182
-
183
- const FILE_NAME = "last-update-check.json";
184
- const getConfigFile = (packageName) => {
185
- const cacheDirectory = findCacheDirSync(packageName);
186
- if (cacheDirectory === void 0) {
187
- throw new UpdateNotifierError("Could not find cache directory", "CACHE_DIRECTORY_NOT_FOUND", { packageName });
188
- }
189
- return join(cacheDirectory, FILE_NAME);
190
- };
191
- const getLastUpdate = (packageName) => {
192
- const configFile = getConfigFile(packageName);
193
- try {
194
- if (!existsSync(configFile)) {
195
- return void 0;
196
- }
197
- const { lastUpdateCheck } = JSON.parse(readFileSync(configFile, "utf8"));
198
- return lastUpdateCheck;
199
- } catch {
200
- return void 0;
201
- }
202
- };
203
- const saveLastUpdate = (packageName) => {
204
- const configFile = getConfigFile(packageName);
205
- const configDirectory = dirname(configFile);
206
- if (!existsSync(configDirectory)) {
207
- mkdirSync(configDirectory, { recursive: true });
208
- }
209
- writeFileSync(configFile, JSON.stringify({ lastUpdateCheck: Date.now() }));
210
- };
211
-
212
- const getDistributionVersion = async (packageName, distributionTag, registryUrl) => {
213
- const url = registryUrl.replace("__NAME__", packageName);
214
- return await new Promise((resolve, reject) => {
215
- get(url, (message) => {
216
- let body = "";
217
- message.on("data", (chunk) => body += String(chunk));
218
- message.on("end", () => {
219
- try {
220
- const json = JSON.parse(body);
221
- const version = json[distributionTag];
222
- if (!version) {
223
- reject(new UpdateNotifierError("Error getting version", "VERSION_FETCH_ERROR", { distributionTag, packageName }));
224
- }
225
- resolve(version);
226
- } catch {
227
- reject(new UpdateNotifierError("Could not parse version response", "VERSION_PARSE_ERROR", { distributionTag, packageName }));
228
- }
229
- });
230
- }).on("error", (error) => {
231
- reject(error);
232
- });
233
- });
234
- };
235
-
236
- const hasNewVersion = async ({
237
- alwaysRun,
238
- debug,
239
- distTag: distributionTag = "latest",
240
- pkg,
241
- registryUrl = "https://registry.npmjs.org/-/package/__NAME__/dist-tags",
242
- updateCheckInterval = 1e3 * 60 * 60 * 24
243
- }) => {
244
- const lastUpdateCheck = getLastUpdate(pkg.name);
245
- if (alwaysRun || !lastUpdateCheck || lastUpdateCheck < Date.now() - updateCheckInterval) {
246
- const latestVersion = await getDistributionVersion(pkg.name, distributionTag, registryUrl);
247
- saveLastUpdate(pkg.name);
248
- if (semverGt(latestVersion, pkg.version)) {
249
- return latestVersion;
250
- }
251
- if (debug) {
252
- console.error(`Latest version (${latestVersion}) not newer than current version (${pkg.version})`);
253
- }
254
- } else if (debug) {
255
- console.error(
256
- `Too recent to check for a new update. simpleUpdateNotifier() interval set to ${String(updateCheckInterval)}ms but only ${String(
257
- Date.now() - lastUpdateCheck
258
- )}ms since last check.`
259
- );
260
- }
261
- return void 0;
262
- };
263
-
264
- export { hasNewVersion as default };
1
+ var Xt=Object.defineProperty;var _=(r,a)=>Xt(r,"name",{value:a,configurable:!0});import{createRequire as en}from"node:module";import{findCacheDirSync as sn}from"@visulima/find-cache-dir";import{c as an}from"../packem_shared/cerebro-error-BnJTixb2.js";const tn=en(import.meta.url),U=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,ve=_(r=>{if(typeof U<"u"&&U.versions&&U.versions.node){const[a,i]=U.versions.node.split(".").map(Number);if(a>22||a===22&&i>=3||a===20&&i>=16)return U.getBuiltinModule(r)}return tn(r)},"__cjs_getBuiltinModule"),{existsSync:be,readFileSync:nn,mkdirSync:rn,writeFileSync:on}=ve("node:fs"),{get:cn}=ve("node:https");var un=Object.defineProperty,ln=_((r,a)=>un(r,"name",{value:a,configurable:!0}),"o$1");const fn=ln((r,a)=>{const i=r.split(".").map(Number),f=a.split(".").map(Number);for(const[d,h]of i.entries()){if(h>f[d])return!0;if(h<f[d])return!1}return!1},"semverGt");var pn=Object.defineProperty,gn=_((r,a)=>pn(r,"name",{value:a,configurable:!0}),"$e"),dn=Object.defineProperty,H=gn((r,a)=>dn(r,"name",{value:a,configurable:!0}),"W"),hn=Object.defineProperty,u=H((r,a)=>hn(r,"name",{value:a,configurable:!0}),"u$1");let xe=u(()=>{var r=(()=>{var a=Object.defineProperty,i=Object.getOwnPropertyDescriptor,f=Object.getOwnPropertyNames,d=Object.prototype.hasOwnProperty,h=u((e,t)=>{for(var n in t)a(e,n,{get:t[n],enumerable:!0})},"ne"),$=u((e,t,n,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of f(t))!d.call(e,o)&&o!==n&&a(e,o,{get:u(()=>t[o],"get"),enumerable:!(s=i(t,o))||s.enumerable});return e},"ae"),m=u(e=>$(a({},"__esModule",{value:!0}),e),"oe"),y={};h(y,{zeptomatch:u(()=>me,"zeptomatch")});var K=u(e=>{const t=new Set,n=[e];for(let s=0;s<n.length;s++){const o=n[s];if(t.has(o))continue;t.add(o);const{children:c}=o;if(c?.length)for(let l=0,g=c.length;l<g;l++)n.push(c[l])}return Array.from(t)},"M"),Ee=u(e=>{let t="";const n=K(e);for(let s=0,o=n.length;s<o;s++){const c=n[s];if(!c.regex)continue;const l=c.regex.flags;if(t||(t=l),t!==l)throw new Error(`Inconsistent RegExp flags used: "${t}" and "${l}"`)}return t},"se"),Q=u((e,t,n)=>{const s=n.get(e);if(s!==void 0)return s;const o=e.partial??t;let c="";if(e.regex&&(c+=o?"(?:$|":"",c+=e.regex.source),e.children?.length){const l=Re(e.children.map(g=>Q(g,t,n)).filter(Boolean));if(l?.length){const g=e.children.some(C=>!C.regex||!(C.partial??t)),v=l.length>1||o&&(!c.length||g);c+=v?o?"(?:$|":"(?:":"",c+=l.join("|"),c+=v?")":""}}return e.regex&&(c+=o?")":""),n.set(e,c),c},"O"),ke=u((e,t)=>{const n=new Map,s=K(e);for(let o=s.length-1;o>=0;o--){const c=Q(s[o],t,n);if(!(o>0))return c}return""},"ie"),Re=u(e=>Array.from(new Set(e)),"ue"),D=u((e,t,n)=>D.compile(e,n).test(t),"R");D.compile=(e,t)=>{const n=t?.partial??!1,s=ke(e,n),o=Ee(e);return new RegExp(`^(?:${s})$`,o)};var Me=D,Ae=u((e,t)=>{const n=Me.compile(e,t),s=`${n.source.slice(0,-1)}[\\\\/]?$`,o=n.flags;return new RegExp(s,o)},"le"),Ne=Ae,Se=u(e=>{const t=e.map(s=>s.source).join("|")||"$^",n=e[0]?.flags;return new RegExp(t,n)},"ve"),Pe=Se,X=u(e=>Array.isArray(e),"j"),P=u(e=>typeof e=="function","_"),ze=u(e=>e.length===0,"he"),Ce=(()=>{const{toString:e}=Function.prototype,t=/(?:^\(\s*(?:[^,.()]|\.(?!\.\.))*\s*\)\s*=>|^\s*[a-zA-Z$_][a-zA-Z0-9$_]*\s*=>)/;return n=>(n.length===0||n.length===1)&&t.test(e.call(n))})(),Ie=u(e=>typeof e=="number","de"),Ue=u(e=>typeof e=="object"&&e!==null,"xe"),Te=u(e=>e instanceof RegExp,"me"),Be=(()=>{const e=/\\\(|\((?!\?(?::|=|!|<=|<!))/;return t=>e.test(t.source)})(),De=(()=>{const e=/^[a-zA-Z0-9_-]+$/;return t=>e.test(t.source)&&!t.flags.includes("i")})(),ee=u(e=>typeof e=="string","A"),O=u(e=>e===void 0,"f"),Fe=u(e=>{const t=new Map;return n=>{const s=t.get(n);if(s!==void 0)return s;const o=e(n);return t.set(n,o),o}},"ye"),te=u((e,t,n={})=>{const s={cache:{},input:e,index:0,indexBacktrackMax:0,options:n,output:[]},o=E(t)(s),c=Math.max(s.index,s.indexBacktrackMax);if(o&&s.index===e.length)return s.output;throw new Error(`Failed to parse at index ${c}`)},"I"),p=u((e,t)=>X(e)?Le(e,t):ee(e)?ne(e,t):qe(e,t),"i"),Le=u((e,t)=>{const n={};for(const s of e){if(s.length!==1)throw new Error(`Invalid character: "${s}"`);const o=s.charCodeAt(0);n[o]=!0}return s=>{const o=s.input;let c=s.index,l=c;for(;l<o.length&&o.charCodeAt(l)in n;)l+=1;if(l>c){if(!O(t)&&!s.options.silent){const g=o.slice(c,l),v=P(t)?t(g,o,`${c}`):t;O(v)||s.output.push(v)}s.index=l}return!0}},"we"),qe=u((e,t)=>{if(De(e))return ne(e.source,t);{const n=e.source,s=e.flags.replace(/y|$/,"y"),o=new RegExp(n,s);return Be(e)&&P(t)&&!Ce(t)?We(o,t):Ze(o,t)}},"$e"),We=u((e,t)=>n=>{const s=n.index,o=n.input;e.lastIndex=s;const c=e.exec(o);if(c){const l=e.lastIndex;if(!n.options.silent){const g=t(...c,o,`${s}`);O(g)||n.output.push(g)}return n.index=l,!0}else return!1},"Ee"),Ze=u((e,t)=>n=>{const s=n.index,o=n.input;if(e.lastIndex=s,e.test(o)){const c=e.lastIndex;if(!O(t)&&!n.options.silent){const l=P(t)?t(o.slice(s,c),o,`${s}`):t;O(l)||n.output.push(l)}return n.index=c,!0}else return!1},"Ce"),ne=u((e,t)=>n=>{const s=n.index,o=n.input;if(o.startsWith(e,s)){if(!O(t)&&!n.options.silent){const c=P(t)?t(e,o,`${s}`):t;O(c)||n.output.push(c)}return n.index+=e.length,!0}else return!1},"F"),F=u((e,t,n,s)=>{const o=E(e),c=t>1;return q(L(oe(l=>{let g=0;for(;g<n;){const v=l.index;if(!o(l)||(g+=1,l.index===v))break}return g>=t},c),s))},"k"),re=u((e,t)=>F(e,0,1,t),"L"),B=u((e,t)=>F(e,0,1/0,t),"$"),Ve=u((e,t)=>F(e,1,1/0,t),"Re"),A=u((e,t)=>{const n=e.map(E);return q(L(oe(s=>{for(let o=0,c=n.length;o<c;o++)if(!n[o](s))return!1;return!0}),t))},"x"),w=u((e,t)=>{const n=e.map(E);return q(L(s=>{for(let o=0,c=n.length;o<c;o++)if(n[o](s))return!0;return!1},t))},"p"),oe=u((e,t=!0,n=!1)=>{const s=E(e);return t?o=>{const c=o.index,l=o.output.length,g=s(o);return!g&&!n&&(o.indexBacktrackMax=Math.max(o.indexBacktrackMax,o.index)),(!g||n)&&(o.index=c,o.output.length!==l&&(o.output.length=l)),g}:s},"q"),L=u((e,t)=>{const n=E(e);return t?s=>{if(s.options.silent)return n(s);const o=s.output.length;if(n(s)){const c=s.output.splice(o,1/0),l=t(c);return O(l)||s.output.push(l),!0}else return!1}:n},"B"),q=(()=>{let e=0;return t=>{const n=E(t),s=e+=1;return o=>{var c;if(o.options.memoization===!1)return n(o);const l=o.index,g=(c=o.cache)[s]||(c[s]={indexMax:-1,queue:[]}),v=g.queue;if(l<=g.indexMax){const I=g.store||(g.store=new Map);if(v.length){for(let S=0,Yt=v.length;S<Yt;S+=2){const Kt=v[S*2],Qt=v[S*2+1];I.set(Kt,Qt)}v.length=0}const j=I.get(l);if(j===!1)return!1;if(Ie(j))return o.index=j,!0;if(j)return o.index=j.index,j.output?.length&&o.output.push(...j.output),!0}const C=o.output.length,Ht=n(o);if(g.indexMax=Math.max(g.indexMax,l),Ht){const I=o.index,j=o.output.length;if(j>C){const S=o.output.slice(C,j);v.push(l,{index:I,output:S})}else v.push(l,I);return!0}else return v.push(l,!1),!1}}})(),se=u(e=>{let t;return n=>(t||(t=E(e())),t(n))},"G"),E=Fe(e=>{if(P(e))return ze(e)?se(e):e;if(ee(e)||Te(e))return p(e);if(X(e))return A(e);if(Ue(e))return w(Object.values(e));throw new Error("Invalid rule")}),R=u(e=>e,"d"),Ge=u(e=>typeof e=="string","ke"),Je=u(e=>{const t=new WeakMap,n=new WeakMap;return(s,o)=>{const c=o?.partial?n:t,l=c.get(s);if(l!==void 0)return l;const g=e(s,o);return c.set(s,g),g}},"Be"),He=u(e=>{const t={},n={};return(s,o)=>{const c=o?.partial?n:t;return c[s]??(c[s]=e(s,o))}},"Pe"),Ye=p(/\\./,R),Ke=p(/./,R),Qe=p(/\*\*\*+/,"*"),Xe=p(/([^/{[(!])\*\*/,(e,t)=>`${t}*`),et=p(/(^|.)\*\*(?=[^*/)\]}])/,(e,t)=>`${t}*`),tt=B(w([Ye,Qe,Xe,et,Ke])),nt=tt,rt=u(e=>te(e,nt,{memoization:!1}).join(""),"Ie"),ot=rt,ae="abcdefghijklmnopqrstuvwxyz",st=u(e=>{let t="";for(;e>0;){const n=(e-1)%26;t=ae[n]+t,e=Math.floor((e-1)/26)}return t},"Le"),ie=u(e=>{let t=0;for(let n=0,s=e.length;n<s;n++)t=t*26+ae.indexOf(e[n])+1;return t},"V"),W=u((e,t)=>{if(t<e)return W(t,e);const n=[];for(;e<=t;)n.push(e++);return n},"b"),at=u((e,t,n)=>W(e,t).map(s=>String(s).padStart(n,"0")),"qe"),ce=u((e,t)=>W(ie(e),ie(t)).map(st),"W"),x=u(e=>({partial:!1,regex:new RegExp(e,"s"),children:[]}),"c"),z=u(e=>({children:e}),"y"),N=(()=>{const e=u((t,n,s)=>{if(s.has(t))return;s.add(t);const{children:o}=t;if(!o.length)o.push(n);else for(let c=0,l=o.length;c<l;c++)e(o[c],n,s)},"e");return t=>{if(!t.length)return z([]);for(let n=t.length-1;n>=1;n--){const s=new Set,o=t[n-1],c=t[n];e(o,c,s)}return t[0]}})(),k=u(()=>({regex:new RegExp("[\\\\/]","s"),children:[]}),"g"),it=p(/\\./,x),ct=p(/[$.*+?^(){}[\]\|]/,e=>x(`\\${e}`)),ut=p(/[\\\/]/,k),lt=p(/[^$.*+?^(){}[\]\|\\\/]+/,x),ft=p(/^(?:!!)*!(.*)$/,(e,t)=>x(`(?!^${me.compile(t).source}$).*?`)),pt=p(/^(!!)+/),gt=w([ft,pt]),dt=p(/\/(\*\*\/)+/,()=>z([N([k(),x(".+?"),k()]),k()])),ht=p(/^(\*\*\/)+/,()=>z([x("^"),N([x(".*?"),k()])])),mt=p(/\/(\*\*)$/,()=>z([N([k(),x(".*?")]),x("$")])),xt=p(/\*\*/,()=>x(".*?")),ue=w([dt,ht,mt,xt]),$t=p(/\*\/(?!\*\*\/|\*$)/,()=>N([x("[^\\\\/]*?"),k()])),vt=p(/\*/,()=>x("[^\\\\/]*")),le=w([$t,vt]),fe=p("?",()=>x("[^\\\\/]")),bt=p("[",R),yt=p("]",R),wt=p(/[!^]/,"^\\\\/"),jt=p(/[a-z]-[a-z]|[0-9]-[0-9]/i,R),_t=p(/\\./,R),Ot=p(/[$.*+?^(){}[\|]/,e=>`\\${e}`),Et=p(/[\\\/]/,"\\\\/"),kt=p(/[^$.*+?^(){}[\]\|\\\/]+/,R),Rt=w([_t,Ot,Et,jt,kt]),pe=A([bt,re(wt),B(Rt),yt],e=>x(e.join(""))),Mt=p("{","(?:"),At=p("}",")"),Nt=p(/(\d+)\.\.(\d+)/,(e,t,n)=>at(+t,+n,Math.min(t.length,n.length)).join("|")),St=p(/([a-z]+)\.\.([a-z]+)/,(e,t,n)=>ce(t,n).join("|")),Pt=p(/([A-Z]+)\.\.([A-Z]+)/,(e,t,n)=>ce(t.toLowerCase(),n.toLowerCase()).join("|").toUpperCase()),zt=w([Nt,St,Pt]),ge=A([Mt,zt,At],e=>x(e.join(""))),Ct=p("{"),It=p("}"),Ut=p(","),Tt=p(/\\./,x),Bt=p(/[$.*+?^(){[\]\|]/,e=>x(`\\${e}`)),Dt=p(/[\\\/]/,k),Ft=p(/[^$.*+?^(){}[\]\|\\\/,]+/,x),Lt=se(()=>he),qt=p("",()=>x("(?:)")),Wt=Ve(w([ue,le,fe,pe,ge,Lt,Tt,Bt,Dt,Ft]),N),de=w([Wt,qt]),he=A([Ct,re(A([de,B(A([Ut,de]))])),It],z),Zt=B(w([gt,ue,le,fe,pe,ge,he,it,ct,ut,lt]),N),Vt=Zt,Gt=u(e=>te(e,Vt,{memoization:!1})[0],"kr"),Jt=Gt,Z=u((e,t,n)=>Z.compile(e,n).test(t),"N");Z.compile=(()=>{const e=He((n,s)=>Ne(Jt(ot(n)),s)),t=Je((n,s)=>Pe(n.map(o=>e(o,s))));return(n,s)=>Ge(n)?e(n,s):t(n,s)})();var me=Z;return m(y)})();return r.default||r},"_lazyMatch"),V;const mn=u((r,a)=>(V||(V=xe(),xe=null),V(r,a)),"default");var xn=Object.defineProperty,$n=H((r,a)=>xn(r,"name",{value:a,configurable:!0}),"t$1");const vn=/^[A-Z]:\//i,M=$n((r="")=>r&&r.replaceAll("\\","/").replace(vn,a=>a.toUpperCase()),"normalizeWindowsPath");var bn=Object.defineProperty,b=H((r,a)=>bn(r,"name",{value:a,configurable:!0}),"r");const yn=/^[/\\]{2}/,wn=/^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Z]:[/\\]/i,ye=/^[A-Z]:$/i,$e=/^\/([A-Z]:)?$/i,jn=/.(\.[^./]+)$/,_n=/^[/\\]|^[a-z]:[/\\]/i,On=/\/$/,En=b(()=>typeof process.cwd=="function"?process.cwd().replaceAll("\\","/"):"/","cwd"),we=b((r,a)=>{let i="",f=0,d=-1,h=0,$;for(let m=0;m<=r.length;++m){if(m<r.length)$=r[m];else{if($==="/")break;$="/"}if($==="/"){if(!(d===m-1||h===1))if(h===2){if(i.length<2||f!==2||!i.endsWith(".")||i.at(-2)!=="."){if(i.length>2){const y=i.lastIndexOf("/");y===-1?(i="",f=0):(i=i.slice(0,y),f=i.length-1-i.lastIndexOf("/")),d=m,h=0;continue}else if(i.length>0){i="",f=0,d=m,h=0;continue}}a&&(i+=i.length>0?"/..":"..",f=2)}else i.length>0?i+=`/${r.slice(d+1,m)}`:i=r.slice(d+1,m),f=m-d-1;d=m,h=0}else $==="."&&h!==-1?++h:h=-1}return i},"normalizeString"),T=b(r=>wn.test(r),"isAbsolute"),je=b(function(r){if(r.length===0)return".";r=M(r);const a=yn.exec(r),i=T(r),f=r.at(-1)==="/";return r=we(r,!i),r.length===0?i?"/":f?"./":".":(f&&(r+="/"),ye.test(r)&&(r+="/"),a?i?`//${r}`:`//./${r}`:i&&!T(r)?`/${r}`:r)},"normalize"),kn=b((...r)=>{let a="";for(const i of r)if(i)if(a.length>0){const f=a.at(-1)==="/",d=i[0]==="/";f&&d?a+=i.slice(1):a+=f||d?i:`/${i}`}else a+=i;return je(a)},"join"),G=b(function(...r){r=r.map(f=>M(f));let a="",i=!1;for(let f=r.length-1;f>=-1&&!i;f--){const d=f>=0?r[f]:En();!d||d.length===0||(a=`${d}/${a}`,i=T(d))}return a=we(a,!i),i&&!T(a)?`/${a}`:a.length>0?a:"."},"resolve");b(function(r){return M(r)},"toNamespacedPath");const Rn=b(function(r){return jn.exec(M(r))?.[1]??""},"extname");b(function(r,a){const i=G(r).replace($e,"$1").split("/"),f=G(a).replace($e,"$1").split("/");if(f[0][1]===":"&&i[0][1]===":"&&i[0]!==f[0])return f.join("/");const d=[...i];for(const h of d){if(f[0]!==h)break;i.shift(),f.shift()}return[...i.map(()=>".."),...f].join("/")},"relative");const _e=b(r=>{const a=M(r).replace(On,"").split("/").slice(0,-1);return a.length===1&&ye.test(a[0])&&(a[0]=`${a[0]}/`),a.join("/")||(T(r)?"/":".")},"dirname");b(function(r){const a=[r.root,r.dir,r.base??r.name+r.ext].filter(Boolean);return M(r.root?G(...a):a.join("/"))},"format");const Mn=b((r,a)=>{const i=M(r).split("/").pop();return a&&i.endsWith(a)?i.slice(0,-a.length):i},"basename");b(function(r){const a=_n.exec(r)?.[0]?.replaceAll("\\","/")??"",i=Mn(r),f=Rn(i);return{base:i,dir:_e(r),ext:f,name:i.slice(0,i.length-f.length),root:a}},"parse");b((r,a)=>mn(a,je(r)),"matchesGlob");var An=Object.defineProperty,Nn=_((r,a)=>An(r,"name",{value:a,configurable:!0}),"e");let J=class extends an{static{_(this,"p")}static{Nn(this,"UpdateNotifierError")}constructor(a,i="UPDATE_NOTIFIER_ERROR",f){super(a,i,f),this.name="UpdateNotifierError"}};var Sn=Object.defineProperty,Y=_((r,a)=>Sn(r,"name",{value:a,configurable:!0}),"n");const Pn="last-update-check.json",Oe=Y(r=>{const a=sn(r);if(a===void 0)throw new J("Could not find cache directory","CACHE_DIRECTORY_NOT_FOUND",{packageName:r});return kn(a,Pn)},"getConfigFile"),zn=Y(r=>{const a=Oe(r);try{if(!be(a))return;const{lastUpdateCheck:i}=JSON.parse(nn(a,"utf8"));return i}catch{return}},"getLastUpdate"),Cn=Y(r=>{const a=Oe(r),i=_e(a);be(i)||rn(i,{recursive:!0}),on(a,JSON.stringify({lastUpdateCheck:Date.now()}))},"saveLastUpdate");var In=Object.defineProperty,Un=_((r,a)=>In(r,"name",{value:a,configurable:!0}),"g$1");const Tn=Un(async(r,a,i)=>{const f=i.replace("__NAME__",r);return await new Promise((d,h)=>{cn(f,$=>{let m="";$.on("data",y=>m+=String(y)),$.on("end",()=>{try{const y=JSON.parse(m)[a];y||h(new J("Error getting version","VERSION_FETCH_ERROR",{distributionTag:a,packageName:r})),d(y)}catch{h(new J("Could not parse version response","VERSION_PARSE_ERROR",{distributionTag:a,packageName:r}))}})}).on("error",$=>{h($)})})},"getDistributionVersion");var Bn=Object.defineProperty,Dn=_((r,a)=>Bn(r,"name",{value:a,configurable:!0}),"i");const Vn=Dn(async({alwaysRun:r,debug:a,distTag:i="latest",pkg:f,registryUrl:d="https://registry.npmjs.org/-/package/__NAME__/dist-tags",updateCheckInterval:h=1e3*60*60*24})=>{const $=zn(f.name);if(r||!$||$<Date.now()-h){const m=await Tn(f.name,i,d);if(Cn(f.name),fn(m,f.version))return m;a&&console.error(`Latest version (${m}) not newer than current version (${f.version})`)}else a&&console.error(`Too recent to check for a new update. simpleUpdateNotifier() interval set to ${String(h)}ms but only ${String(Date.now()-$)}ms since last check.`)},"hasNewVersion");export{Vn as default};
@@ -0,0 +1,4 @@
1
+ var Tt=Object.defineProperty;var O=(t,e)=>Tt(t,"name",{value:e,configurable:!0});import{createRequire as Vt}from"node:module";import{VERBOSITY_DEBUG as F,POSITIONALS_KEY as ie,VERBOSITY_QUIET as Bt,VERBOSITY_VERBOSE as zt,VERBOSITY_NORMAL as je}from"./VERBOSITY_QUIET-XPultrIA.js";import{c as C}from"./cerebro-error-BnJTixb2.js";import{d as G,h as Ce,e as re,o as Le,a as Wt,i as Ft,f as qt}from"./runtime-process-DKHFvYkv.js";import{distance as Gt}from"fastest-levenshtein";const Dt=Vt(import.meta.url),J=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Rt=O(t=>{if(typeof J<"u"&&J.versions&&J.versions.node){const[e,n]=J.versions.node.split(".").map(Number);if(e>22||e===22&&n>=3||e===20&&n>=16)return J.getBuiltinModule(t)}return Dt(t)},"__cjs_getBuiltinModule"),{createRequire:Ht}=Rt("node:module"),ne=[{description:"Turn on verbose output",group:"global",name:"verbose",type:Boolean},{description:"Turn on debugging output",group:"global",name:"debug",type:Boolean},{alias:"h",description:"Print out helpful usage information",group:"global",name:"help",type:Boolean},{alias:"q",description:"Silence output",group:"global",name:"quiet",type:Boolean},{alias:"V",description:"Print version info",group:"global",name:"version",type:Boolean},{description:"Turn off colored output",group:"global",name:"no-color",type:Boolean},{description:"Force colored output",group:"global",name:"color",type:Boolean}];var Kt=Object.defineProperty,Yt=O((t,e)=>Kt(t,"name",{value:e,configurable:!0}),"t$9");let B=class extends C{static{O(this,"a")}static{Yt(this,"CommandNotFoundError")}commandName;constructor(e,n=[]){const i=`Command "${e}" not found${n.length>0?`. Did you mean: ${n.join(", ")}?`:""}`;super(i,"COMMAND_NOT_FOUND",{commandName:e,suggestions:n}),this.name="CommandNotFoundError",this.commandName=e,n.length>0&&(this.hint=`Try one of these commands: ${n.join(", ")}`)}};var Jt=Object.defineProperty,Qt=O((t,e)=>Jt(t,"name",{value:e,configurable:!0}),"e$7");let nt=class extends C{static{O(this,"o")}static{Qt(this,"ConflictingOptionsError")}option1;option2;constructor(e,n){super(`Options "${e}" and "${n}" cannot be used together`,"CONFLICTING_OPTIONS",{option1:e,option2:n}),this.name="ConflictingOptionsError",this.option1=e,this.option2=n,this.hint=`Remove either --${e} or --${n}`}};var Zt=Object.defineProperty,Xt=O((t,e)=>Zt(t,"name",{value:e,configurable:!0}),"e$6");let en=class extends C{static{O(this,"o")}static{Xt(this,"PluginError")}pluginName;constructor(e,n,i){super(`Plugin "${e}" error: ${n}`,"PLUGIN_ERROR",{originalError:i,pluginName:e}),this.name="PluginError",this.pluginName=e,i&&(this.cause=i)}};var tn=Object.defineProperty,Ie=O((t,e)=>tn(t,"name",{value:e,configurable:!0}),"d$7");let nn=class{static{O(this,"p")}static{Ie(this,"PluginManager")}logger;plugins=new Map;initialized=!1;cachedDependencyOrder=void 0;constructor(e){this.logger=e}hasPlugins(){return this.plugins.size>0}register(e){if(this.initialized)throw new Error(`Cannot register plugin "${e.name}" after initialization`);if(this.plugins.has(e.name))throw new Error(`Plugin "${e.name}" is already registered`);G().CEREBRO_OUTPUT_LEVEL===String(F)&&this.logger.debug(`registering plugin: ${e.name}`),this.plugins.set(e.name,e),this.cachedDependencyOrder=void 0}async init(e){if(this.initialized)throw new Error("PluginManager already initialized");if(this.plugins.size===0){this.logger.debug("no plugins registered, skipping initialization"),this.initialized=!0;return}this.validateDependencies();const n=this.getDependencyOrder();this.logger.debug(`initializing ${String(n.length)} plugin(s)...`);for(const i of n)if(typeof i.init=="function"){this.logger.debug(`initializing plugin: ${i.name}`);try{await i.init(e)}catch(r){const a=new en(i.name,`Failed to initialize: ${r instanceof Error?r.message:String(r)}`,r instanceof Error?r:void 0);throw this.logger.error(a.message),a}}this.initialized=!0}async executeLifecycle(e,n,i){if(!this.initialized)throw new Error("PluginManager not initialized");if(this.plugins.size===0)return;const r=this.getDependencyOrder();for(const a of r){const c=a[e];if(typeof c=="function"){this.logger.debug(`executing ${e} hook for plugin: ${a.name}`);try{await(e==="afterCommand"?c(n,i):c(n))}catch(s){throw this.logger.error(`Error in ${e} hook for plugin "${a.name}":`,s),s}}}}async executeErrorHandlers(e,n){if(!this.initialized||this.plugins.size===0)return;const i=this.getDependencyOrder();for(const r of i)if(typeof r.onError=="function"){this.logger.debug(`executing error handler for plugin: ${r.name}`);try{await r.onError(e,n)}catch(a){this.logger.error(`Error in error handler for plugin "${r.name}":`,a)}}}getDependencyOrder(){if(this.cachedDependencyOrder!==void 0)return this.cachedDependencyOrder;const e=[],n=new Set,i=new Set,r=Ie(a=>{if(n.has(a))return;if(i.has(a))throw new Error(`Circular dependency detected involving plugin "${a}"`);const c=this.plugins.get(a);if(!c)throw new Error(`Plugin "${a}" not found`);if(i.add(a),c.dependencies)for(const s of c.dependencies)r(s);i.delete(a),n.add(a),e.push(c)},"visit");for(const a of this.plugins.keys())r(a);return this.cachedDependencyOrder=e,e}validateDependencies(){for(const e of this.plugins.values())if(e.dependencies){for(const n of e.dependencies)if(!this.plugins.has(n))throw new Error(`Plugin "${e.name}" depends on "${n}" which is not registered`)}}};var an=Object.defineProperty,on=O((t,e)=>an(t,"name",{value:e,configurable:!0}),"n$c");const ee=on(t=>t.type?.name==="Boolean","optionIsBoolean");var rn=Object.defineProperty,at=O((t,e)=>rn(t,"name",{value:e,configurable:!0}),"p$8");const sn=at(t=>{let e=t.type?t.type.name.toLowerCase():"string";const n=t.multiple??t.lazyMultiple?"[]":"";return e&&(e=e==="boolean"?"":`{underline ${e}${n}}`),e},"getTypeLabel"),Se=at(t=>(ee(t)||(t.typeLabel=t.typeLabel??sn(t),t.defaultOption&&(t.typeLabel=`${t.typeLabel} (D)`),t.required&&(t.typeLabel=`${t.typeLabel} (R)`)),t),"mapOptionTypeLabel");var ln=Object.defineProperty,it=O((t,e)=>ln(t,"name",{value:e,configurable:!0}),"e$4");const cn=new RegExp(/^-([^\d-])$/),un=new RegExp(/^--(\S+)/),pn=new RegExp(/^-([^\d-]{2,})$/),fn=it(t=>cn.test(t)||un.test(t)||pn.test(t),"isOption"),dn=it((t,e)=>{const n=e[0]&&fn(e[0])||e.length===0?null:e.shift()??null;if(!t.includes(n)){const i=new Error(`Command not recognised: ${String(n)}`);throw i.command=n,i.name="INVALID_COMMAND",i}return{argv:e,command:n}},"commandLineCommands");var hn=Object.defineProperty,ot=O((t,e)=>hn(t,"name",{value:e,configurable:!0}),"i$b"),mn=Object.defineProperty,rt=ot((t,e)=>mn(t,"name",{value:e,configurable:!0}),"i"),gn=Object.defineProperty,st=rt((t,e)=>gn(t,"name",{value:e,configurable:!0}),"i");st(t=>t instanceof Error&&t.type==="VisulimaError","isVisulimaError");let le=class extends Error{static{O(this,"p")}static{ot(this,"E")}static{rt(this,"m")}static{st(this,"VisulimaError")}loc;title;hint;type="VisulimaError";constructor({cause:e,hint:n,location:i,message:r,name:a,stack:c,title:s}){super(r,{cause:e}),this.title=s,this.name=a,this.stack=c??this.stack,this.loc=i,this.hint=n}setLocation(e){this.loc=e}setName(e){this.name=e}setMessage(e){this.message=e}setHint(e){this.hint=e}};var vn=Object.defineProperty,lt=O((t,e)=>vn(t,"name",{value:e,configurable:!0}),"o$b"),wn=Object.defineProperty,ct=lt((t,e)=>wn(t,"name",{value:e,configurable:!0}),"o"),yn=Object.defineProperty,bn=ct((t,e)=>yn(t,"name",{value:e,configurable:!0}),"i");let $n=class ut extends le{static{O(this,"a")}static{lt(this,"a")}static{ct(this,"t")}static{bn(this,"AlreadySetError")}optionName;constructor(e){super({cause:void 0,hint:`Remove the duplicate option '${e}' from your command line arguments.`,location:void 0,message:`Option '${e}' is already set`,name:"ALREADY_SET",stack:void 0,title:"Option Already Set"}),this.optionName=e,Object.setPrototypeOf(this,ut.prototype)}};var On=Object.defineProperty,pt=O((t,e)=>On(t,"name",{value:e,configurable:!0}),"t$7"),En=Object.defineProperty,ft=pt((t,e)=>En(t,"name",{value:e,configurable:!0}),"e"),Pn=Object.defineProperty,An=ft((t,e)=>Pn(t,"name",{value:e,configurable:!0}),"e");let Ue=class dt extends le{static{O(this,"n")}static{pt(this,"n")}static{ft(this,"o")}static{An(this,"UnknownOptionError")}optionName;constructor(e){super({cause:void 0,hint:`Check your option definitions or remove the unknown option '${e}' from your command line arguments.`,location:void 0,message:`Unknown option: --${e}`,name:"UNKNOWN_OPTION",stack:void 0,title:"Unknown Option"}),this.optionName=`--${e}`,Object.setPrototypeOf(this,dt.prototype)}};var Cn=Object.defineProperty,ht=O((t,e)=>Cn(t,"name",{value:e,configurable:!0}),"a$a"),Nn=Object.defineProperty,mt=ht((t,e)=>Nn(t,"name",{value:e,configurable:!0}),"a"),xn=Object.defineProperty,kn=mt((t,e)=>xn(t,"name",{value:e,configurable:!0}),"o");let _n=class gt extends le{static{O(this,"n")}static{ht(this,"o")}static{mt(this,"e")}static{kn(this,"UnknownValueError")}value;constructor(e){super({hint:"Use a defined option or add a defaultOption to capture this value.",message:`Unknown value: ${e}`,name:"UNKNOWN_VALUE",title:"Unknown Value"}),this.value=e,Object.setPrototypeOf(this,gt.prototype)}};var jn=Object.defineProperty,vt=O((t,e)=>jn(t,"name",{value:e,configurable:!0}),"i$8"),Ln=Object.defineProperty,wt=vt((t,e)=>Ln(t,"name",{value:e,configurable:!0}),"i"),In=Object.defineProperty,Sn=wt((t,e)=>In(t,"name",{value:e,configurable:!0}),"i");let j=class yt extends le{static{O(this,"a")}static{vt(this,"o")}static{wt(this,"e")}static{Sn(this,"InvalidDefinitionsError")}constructor(e,n){super({cause:void 0,hint:n,location:void 0,message:e,name:"INVALID_DEFINITIONS",stack:void 0,title:"Invalid Option Definition"}),Object.setPrototypeOf(this,yt.prototype)}};var Un=Object.defineProperty,Mn=O((t,e)=>Un(t,"name",{value:e,configurable:!0}),"z$1"),Tn=Object.defineProperty,K=Mn((t,e)=>Tn(t,"name",{value:e,configurable:!0}),"S"),Vn=Object.defineProperty,ce=K((t,e)=>Vn(t,"name",{value:e,configurable:!0}),"o");const Me=ce(t=>t===Boolean||typeof t=="function"&&t.name.startsWith("Boolean"),"isBooleanType"),Te=ce(t=>t===Number||typeof t=="function"&&t.name==="Number","isNumberType"),Ve=ce(t=>t===String||typeof t=="function"&&t.name==="String","isStringType"),Dn=ce((t,e)=>Array.isArray(t)?Me(e)?t.map(Boolean):Te(e)?t.map(Number):Ve(e)?t.map(String):t.map(n=>e(String(n))):t===null?null:Me(e)?!!t:Te(e)?Number(t):Ve(e)?typeof t=="string"?t:String(t):e(typeof t=="string"?t:String(t)),"convertValue");var Rn=Object.defineProperty,Bn=K((t,e)=>Rn(t,"name",{value:e,configurable:!0}),"e");const _=Bn((t,e,n,...i)=>{t&&console.debug(`[command-line-args:${n}] ${e}`,...i)},"debug");var zn=Object.defineProperty,D=K((t,e)=>zn(t,"name",{value:e,configurable:!0}),"h$1");const Wn=/-([a-z])/g,Fn=/^\d+$/,ve=D(t=>t===Boolean||typeof t=="function"&&t.name.startsWith("Boolean"),"isBooleanType"),qn=D(t=>t.codePointAt(0)===95,"isSpecialKey"),De=D((t,e)=>Array.isArray(t)?[...t,...e]:[t,...e],"appendToArrayMultiple"),Re=D(t=>t==="__proto__"||t==="constructor"||t==="prototype","isUnsafeKey"),Be=D((t,e,n,i=!1)=>{t[e]===void 0?t[e]=i?[n]:n:i&&Array.isArray(t[e])?t[e].push(n):t[e]=[t[e],n]},"createOrAppendArray"),Gn=D((t,e,n,i,r)=>{let a=e.get(t)??n.get(t);if(!a&&i){const c=t.toLowerCase();a=i.get(c)??r?.get(c)}return a},"getDefinition"),Hn=D((t,e,n,i)=>{const r=n.debug??!1;_(r,"resolveArgs called with options:","resolver",{partial:n.partial,stopAtFirstUnknown:n.stopAtFirstUnknown}),_(r,"Starting argument resolution","resolver"),_(r,"Tokens:","resolver",t),_(r,"Definitions:","resolver",e),_(r,"Processing tokens...","resolver");const a=new Map,c=new Map,s=n.caseInsensitive?new Map:void 0,m=n.caseInsensitive?new Map:void 0,o=n.camelCase?new Map:void 0,u=n.camelCase?new Map:void 0;for(const f of e)if(a.set(f.name,f),f.alias&&c.set(f.alias,f),n.caseInsensitive&&s&&(s.set(f.name.toLowerCase(),f),f.alias&&m&&m.set(f.alias.toLowerCase(),f)),n.camelCase&&o&&u){const h=f.name.replaceAll(Wn,(v,w)=>w.toUpperCase());o.set(f.name,h),u.set(h,f.name)}const d={},l={},g=[],p=new Set;let b=!1;const $=e.find(f=>f.defaultOption),y=e.some(f=>f.group),P=e.some(f=>f.type===Number);for(let f=0;f<t.length;f++){const h=t[f];if(h.kind==="option-terminator"){d._unknown=i.slice(h.index),b=!0;break}if(h.kind==="option"&&h.name){let v=Gn(h.name,a,c,s,m);if(!v&&h.value===void 0&&P&&Fn.test(h.name)){const A=e.find(S=>S.type===Number);A&&(v=A,h.value=h.name,h.name=A.name)}const w=v?v.name:h.name,E=v?.multiple,k=v?.lazyMultiple;if(l[w]!==void 0&&!E&&!k&&!n.partial)throw new $n(w);if(!v&&n.partial){const A=h.rawName??`--${h.name}${h.value!==void 0&&h.inlineValue?`=${h.value}`:""}`;g.push({index:h.index,value:A});continue}if(!v&&n.stopAtFirstUnknown){d._unknown=i.slice(h.index);break}if(!v&&!n.partial)throw new Ue(h.name);if(h.value===void 0){const A=t[f+1],S=A?.kind==="option"&&!("name"in A)&&A.value!==void 0,I=A&&v&&!(v.type&&ve(v.type))&&(A.kind==="positional"||S),Mt=v&&v.defaultOption&&!v.multiple&&!v.lazyMultiple;if(I&&(!v?.defaultOption||Mt))if(E){let U=f+1;const ge=[];for(;U<t.length&&(t[U].kind==="positional"||t[U].kind==="option"&&!("name"in t[U])&&t[U].value!==void 0);)ge.push(t[U].value),p.add(t[U].index),U++;l[w]=l[w]===void 0?ge:De(l[w],ge),f=U-1}else k?(Be(l,w,A.value,!0),p.add(A.index),f++):(l[w]=A.value,p.add(A.index),f++);else v?.type&&ve(v.type)?Be(l,w,!0,E):l[w]=E?[]:null}else{let{value:A}=h;if(v?.type&&ve(v.type))switch(A){case"":{if(n.partial)l._unknown??=[],l._unknown.push(`${h.rawName??`--${h.name}`}${h.value?`=${h.value}`:""}`),A=!0;else throw new Ue(h.name);break}case"false":{A=!1;break}case"true":{A=!0;break}default:A=!0}const S=[A];if(E){let I=f+1;for(;I<t.length&&t[I].kind==="positional";)S.push(t[I].value),p.add(t[I].index),I++;f=I-1}l[w]===void 0?l[w]=E||k?S:A:E||k?l[w]=De(l[w],S):l[w]=A}}else if(h.kind==="positional"&&n.stopAtFirstUnknown&&!p.has(h.index)&&!$){_(r,`Found unconsumed positional token at index ${String(h.index)}, stopping processing`,"resolver"),d._unknown=i.slice(h.index);break}}for(const[f,h]of Object.entries(l)){const v=a.get(f);v&&(v.multiple||v.lazyMultiple)&&!Array.isArray(h)&&(l[f]=[h])}let N=Number.POSITIVE_INFINITY;if(n.stopAtFirstUnknown&&!b){for(const f of t)if(f.kind==="option"&&!a.has(f.name??"")&&!c.has(f.name??"")&&(!n.caseInsensitive||!s?.has(f.name?.toLowerCase()??"")&&!m?.has(f.name?.toLowerCase()??""))){N=f.index;break}}if($){const f=[],h=[];for(const v of t)v.kind==="positional"&&!p.has(v.index)&&v.index<N&&(f.push(v.value),h.push(v));if(f.length>0){const v=l[$.name],w=$.multiple??$.lazyMultiple;v===void 0?w?(h.forEach(E=>p.add(E.index)),l[$.name]=f):(p.add(h[0].index),l[$.name]=f[0]):w&&(h.forEach(E=>p.add(E.index)),l[$.name]=Array.isArray(v)?[...f,...v]:[...f,v])}}if(!n.partial){for(const f of t)if(f.kind==="positional"&&!p.has(f.index))throw new _n(i[f.index])}if(n.partial&&!n.stopAtFirstUnknown){const f=[...g];if(l._unknown){const h=new Map;for(const[v,w]of i.entries())h.set(w,v);for(const v of l._unknown){const w=h.get(v);w!==void 0&&f.push({index:w,value:v})}}for(const h of t)h.kind==="positional"&&!p.has(h.index)&&f.push({index:h.index,value:i[h.index]});f.length>0&&(f.sort((h,v)=>h.index-v.index),d._unknown=f.map(h=>h.value))}if(n.stopAtFirstUnknown&&!b){const f=t.findIndex(w=>w.kind==="option"&&!a.has(w.name??"")&&!c.has(w.name??"")&&(!n.caseInsensitive||!s?.has(w.name?.toLowerCase()??"")&&!m?.has(w.name?.toLowerCase()??""))),h=t.findIndex(w=>w.kind==="positional"&&!p.has(w.index));let v=-1;if(f!==-1&&h!==-1?v=Math.min(f,h):f!==-1?v=f:h!==-1&&(v=h),v>=0){const w=t[v].index;d._unknown=i.slice(w)}}else g.length>0&&!n.partial&&(d._unknown=g.map(f=>f.value));for(const[f,h]of Object.entries(l)){const v=n.camelCase?o?.get(f)??f:f,w=a.get(f);d[v]=w?.type?Dn(h,w.type):h===void 0?null:h}for(const f of e){const h=n.camelCase?o?.get(f.name)??f.name:f.name;!(h in d)&&f.defaultValue!==void 0&&(f.multiple??f.lazyMultiple?d[h]=Array.isArray(f.defaultValue)?[...f.defaultValue]:[f.defaultValue]:d[h]=f.defaultValue)}if(y){const f={},h={},v={};for(const E of e)if(E.group){const k=Array.isArray(E.group)?E.group:[E.group];for(const A of k)Re(A)||(f[A]??={})}for(const E of Object.keys(d))if(!qn(E)){h[E]=d[E];let k=E;n.camelCase&&(k=u?.get(E)??E);const A=a.get(k);if(A?.group){const S=Array.isArray(A.group)?A.group:[A.group];for(const I of S)Re(I)||f[I]&&(f[I][E]=d[E])}else v[E]=d[E]}const w={_all:h};for(const[E,k]of Object.entries(f))w[E]=k;Object.keys(v).length>0&&(w._none=v),d._unknown&&(w._unknown=d._unknown),Object.keys(d).forEach(E=>delete d[E]),Object.assign(d,w)}return _(r,"Final parsed result:","resolver",d),d},"resolveArgs");var Kn=Object.defineProperty,R=K((t,e)=>Kn(t,"name",{value:e,configurable:!0}),"l");const V="-".codePointAt(0),T="=",Yn=T.codePointAt(0),Jn="--",Qn="-",Zn="--",bt=R(t=>t.length>2&&t.startsWith(Zn),"hasLongOptionPrefix"),Xn=R(t=>bt(t)&&!t.includes(T,3),"isLongOption"),ea=R(t=>bt(t)&&t.includes(T,3),"isLongOptionAndValue"),ta=R(t=>t!==void 0&&t.length>0&&t.codePointAt(0)!==V,"hasOptionValue"),na=R(t=>{if(t.length!==2||t.codePointAt(0)!==V||t.codePointAt(1)===V)return!1;const e=t.codePointAt(1);return e!==void 0&&(e<48||e>57)},"isShortOption"),aa=R(t=>!(t.length<=2||t.codePointAt(0)!==V||t.codePointAt(1)===V),"isShortOptionGroup"),ia=R(t=>{const e=[],n=[...t];let i=-1,r=0;for(;n.length>0;){const a=n.shift();if(a===void 0)break;const c=n[0];if(r>0?r--:i++,a===Jn){e.push({index:i,kind:"option-terminator"});const s=n.map((m,o)=>({index:i+o+1,kind:"positional",value:m}));e.push(...s),i+=n.length;break}if(na(a)){const s=a.charAt(1);let m;r?(e.push({index:i,kind:"option",name:s,rawName:a,value:m}),r===1&&ta(c)&&(m=n.shift(),e.push({index:i,kind:"option",value:m}))):e.push({index:i,kind:"option",name:s,rawName:a,value:m}),m!==void 0&&++i;continue}if(aa(a)&&!a.includes(T)){const s=[];let m="",o=!1;for(let u=1;u<a.length;u++){const d=a.charAt(u);o?m+=d:d.codePointAt(0)===Yn?o=!0:s.push(`${Qn}${d}`)}if(o)if(s.length>0){const u=s.pop();s.push(`${u}=${m}`)}else s.push(m);n.unshift(...s),r=s.length;continue}if(Xn(a)){const s=a.slice(2);e.push({index:i,kind:"option",name:s,rawName:a});continue}if(ea(a)){const s=a.indexOf(T),m=a.slice(2,s),o=a.slice(s+1);e.push({index:i,inlineValue:!0,kind:"option",name:m,rawName:a,value:o});continue}if(a.length>2&&a.codePointAt(0)===V&&a.codePointAt(1)!==V&&a.includes(T)){const s=a.indexOf(T),m=a.charAt(1),o=a.slice(s+1);e.push({index:i,inlineValue:!0,kind:"option",name:m,rawName:a,value:o});continue}e.push({index:i,kind:"positional",value:a})}return e},"parseArgsTokens");var oa=Object.defineProperty,xe=K((t,e)=>oa(t,"name",{value:e,configurable:!0}),"d");const ra=/\d/,sa=xe(t=>t!=null&&(t===Boolean||typeof t=="function"&&t.name.startsWith("Boolean")),"isBooleanType"),la=xe(t=>typeof t=="function","isValidCustomTypeFunction"),ca=xe((t,e,n)=>{const i=n?.debug??!1;_(i,"Validating definitions:","validation",t,"caseInsensitive:",e);const r=new Set,a=new Set,c=new Set,s=new Set;let m=0;for(const o of t){if(_(i,"Checking definition:","validation",o),!o.name)throw _(i,"Validation failed: name is required","validation"),new j("Invalid option definition: name is required");if(typeof o.name!="string")throw new j("Invalid option definition: name must be a string");if(o.name.trim()==="")throw new j("Invalid option definition: name cannot be empty");const u=e?o.name.toLowerCase():"";if(r.has(o.name)||e&&c.has(u))throw new j(`Invalid option definition: duplicate name '${o.name}'`);if(a.has(o.name)||e&&s.has(u))throw new j(`Invalid option definition: name '${o.name}' conflicts with an existing alias`);if(r.add(o.name),e&&c.add(u),o.alias!==void 0){if(typeof o.alias!="string")throw new j("Invalid option definition: alias must be a string");if(o.alias.length!==1)throw new j("Invalid option definition: alias must be a single character");if(ra.test(o.alias))throw new j("Invalid option definition: alias cannot be numeric");if(o.alias==="-")throw new j('Invalid option definition: alias cannot be "-"');const d=e?o.alias.toLowerCase():"";if(a.has(o.alias)||e&&s.has(d))throw new j(`Invalid option definition: duplicate alias '${o.alias}'`);if(r.has(o.alias)||e&&c.has(d))throw new j(`Invalid option definition: alias '${o.alias}' conflicts with an existing option name`);a.add(o.alias),e&&s.add(d)}if(o.defaultOption&&(m++,o.type!==void 0&&sa(o.type)))throw new j("Invalid option definition: defaultOption cannot be Boolean type");if(o.type!==void 0&&!(o.type===Boolean||o.type===Number||o.type===String||typeof o.type=="function"&&la(o.type)))throw new j("Invalid option definition: invalid type")}if(m>1)throw _(i,"Validation failed: multiple defaultOptions not allowed","validation"),new j("Invalid option definition: multiple defaultOptions not allowed");_(i,"Validation completed successfully","validation")},"validateDefinitions");var ua=Object.defineProperty,pa=K((t,e)=>ua(t,"name",{value:e,configurable:!0}),"O");const fa=pa((t,e={})=>{const n=e.debug??!1;_(n,"Starting command-line-args parsing","index"),_(n,"Options:","index",e);const i={...e};i.stopAtFirstUnknown&&(i.partial=!0);const r=Array.isArray(t)?t:[t];_(n,"Normalized definitions:","index",r),ca(r,i.caseInsensitive,n?i:void 0);let{argv:a}=i;if(!a&&(a=process.argv.slice(2),process.execArgv.length>0)){const o=new Set(process.execArgv);a=a.filter(u=>!o.has(u))}_(n,"Using argv:","index",a);let c=a;i.caseInsensitive&&(c=a.map(o=>{if(o.startsWith("--")){const u=o.indexOf("="),d=(u===-1?o.slice(2):o.slice(2,u)).toLowerCase();return u===-1?`--${d}`:`--${d}${o.slice(u)}`}if(o.startsWith("-")&&!o.startsWith("--")&&o.length>1){const u=o.slice(1).split("=",2),d=u[0],l=u[1];if(!d)return o;const g=d.toLowerCase();return l===void 0?`-${g}`:`-${g}=${l}`}return o}));const s=ia(c.map(String));_(n,"Tokenized arguments:","index",s);const m=Hn(s,r,i,a);return _(n,"Command-line-args parsing completed","index"),m},"commandLineArgs");var da=Object.defineProperty,ha=O((t,e)=>da(t,"name",{value:e,configurable:!0}),"n$8");let ma=class{static{O(this,"a")}static{ha(this,"EmptyToolbox")}result;argv;options;argument;command;commandName;env;logger;runtime;rawUnknown;constructor(e,n){this.commandName=e,this.command=n}};var ga=Object.defineProperty,va=O((t,e)=>ga(t,"name",{value:e,configurable:!0}),"n$7");let we=class extends C{static{O(this,"i")}static{va(this,"CommandLoaderError")}commandName;constructor(e,n,i){super(`Failed to load command "${e}": ${n}`,"COMMAND_LOADER_ERROR",{commandName:e,reason:n}),this.name="CommandLoaderError",this.commandName=e,this.hint="Ensure the loader resolves to a module with a default export that is the command handler function.",i!==void 0&&(this.cause=i)}};var wa=Object.defineProperty,ya=O((t,e)=>wa(t,"name",{value:e,configurable:!0}),"f$5");const ba=/^-{1,2}(\w+)(=(.+))?$/,$t=ya((t,e,n,i)=>{const r=ba.exec(t);if(r===null)return{};const a=r[1];if(!a)return{};const c=n&&i?n.get(a)??i.get(a):e.find(s=>s.name===a||s.alias===a);return c!==void 0?{argName:c.name,argValue:r[3],option:c}:{}},"getParameterOption");var $a=Object.defineProperty,Ne=O((t,e)=>$a(t,"name",{value:e,configurable:!0}),"e$3");const ze=Ne((t,e)=>{if(e.type===void 0)return t;if(e.type.name==="Boolean"){if(t==="true"||t==="1")return e.type(!0);if(t==="false"||t==="0")return e.type(!1)}return e.type(t)},"convertType"),Oa=new Set(["0","1","false","true"]),Ea=Ne((t,e,n,i)=>{if(e.length===0||t.length===0)return{};const r=Ne((a,c)=>{const{argName:s,argValue:m,option:o}=$t(c,e,n,i),{lastOption:u}=a;return o&&ee(o)&&m&&s?a.partial[s]=ze(m,o):a.lastName&&u&&ee(u)&&Oa.has(c)&&(a.partial[a.lastName]=ze(c,u)),{lastName:s,lastOption:o,partial:a.partial}},"getBooleanValue");return t.reduce(r,{partial:{}}).partial},"getBooleanValues");var Pa=Object.defineProperty,We=O((t,e)=>Pa(t,"name",{value:e,configurable:!0}),"s$8");const Aa=new Set(["0","1","false","true"]),Ca=We((t,e,n,i)=>{if(e.length===0||t.length===0)return t;const r=We((a,c)=>{const{argValue:s,option:m}=$t(c,e,n,i),{lastOption:o}=a;if(o&&ee(o)&&Aa.has(c)){const{args:u}=a;return{args:u.slice(0,-1)}}return m&&ee(m)&&s?{args:a.args}:{args:[...a.args,c],lastOption:m}},"removeBooleanArguments");return t.reduce(r,{args:[]}).args},"removeBooleanValues");var Na=Object.defineProperty,xa=O((t,e)=>Na(t,"name",{value:e,configurable:!0}),"o$8");const Fe=xa(t=>{const e=new Map;for(const n of t){const i=e.get(n.name);i?e.set(n.name,{...i,...n}):e.set(n.name,n)}return[...e.values()]},"mergeArguments");var ka=Object.defineProperty,ue=O((t,e)=>ka(t,"name",{value:e,configurable:!0}),"o$7");const _a=ue(t=>{if(t===void 0)return;const e=t.toLowerCase().trim();return e==="true"||e==="1"||e==="yes"||e==="on"},"transformBooleanEnv"),ja=ue((t,e)=>{if(!t.type)return e;if(e!==void 0){if(t.type===Boolean||typeof t.type=="function"&&t.type.name==="Boolean")return _a(e);if(t.type===Number||typeof t.type=="function"&&t.type.name==="Number"){const n=Number.parseFloat(e);return Number.isNaN(n)?void 0:n}return t.type===String||typeof t.type=="function"&&t.type.name==="String"?e:t.type(e)}},"transformEnvValue"),La=/_./g,Ia=/^[A-Z]/,Sa=ue(t=>t.toLowerCase().replaceAll(La,e=>e[1]?.toUpperCase()??e).replace(Ia,e=>e.toLowerCase()),"toCamelCase"),Ua=ue(t=>{if(!t||t.length===0)return{};const e={},n=G();for(const i of t){const r=n[i.name],a=ja(i,r),c=a===void 0?i.defaultValue:a,s=Sa(i.name);e[s]=c}return e},"processEnvVariables");var Ma=Object.defineProperty,te=O((t,e)=>Ma(t,"name",{value:e,configurable:!0}),"a$5");const Ta=te(t=>{const e=new Map,n=new Map;for(const i of t)if(e.set(i.name,i),i.alias){const r=Array.isArray(i.alias)?i.alias:[i.alias];for(const a of r)n.set(a,i)}return{optionMapByAlias:n,optionMapByName:e}},"buildOptionMaps"),Va=te(async t=>{if(typeof t.__resolvedExecute__=="function")return t.__resolvedExecute__;if(typeof t.loader!="function")throw new we(t.name,"no execute or loader defined");let e;try{e=await t.loader()}catch(i){throw new we(t.name,i instanceof Error?i.message:String(i),i)}const n=e.default;if(typeof n!="function")throw new we(t.name,"loader did not return a module with a default-exported handler function");return t.__resolvedExecute__=n,n},"loadLazyHandler"),Da=te((t,e,n,i)=>{const r=new ma(t.name,t),{_all:a,_unknown:c,positionals:s}=e,m=Object.keys(n).length>0?{...a,...n}:a;ie in m&&delete m[ie],r.argument=s?.[ie]??[],r.rawUnknown=[...c??[]];const o=Object.keys(i).length>0;return r.options=o?{...m,...i}:m,r.env=Ua(t.env),r},"prepareToolbox"),Ra=te((t,e,n)=>{const i=t.options??[],r=i.length>0;let a=Fe(r?[...i,...n]:n);if(a.length>0){for(const o of a)if(o.multiple&&o.lazyMultiple)throw new Error(`Argument "${o.name}" cannot have both multiple and lazyMultiple options, please choose one.`)}t.argument&&(a=[{defaultOption:!0,description:t.argument.description,group:"positionals",multiple:!0,name:ie,type:t.argument.type,typeLabel:t.argument.typeLabel},...a]);let c,s;if(r){const{optionMapByAlias:o,optionMapByName:u}=Ta(i);c=Ca(e,i,u,o),s=Ea(e,i,u,o)}else c=e,s={};const m=fa(a,{argv:c,camelCase:!0,partial:!0,stopAtFirstUnknown:!0});return{arguments_:a,booleanValues:s,parsedArgs:m}},"processCommandArgs"),z=te(async(t,e,n)=>typeof t.execute=="function"?t.execute(e):(await Va(t))(e),"executeCommand");var Ba=Object.defineProperty,za=O((t,e)=>Ba(t,"name",{value:e,configurable:!0}),"n$6");let Wa=class extends C{static{O(this,"s")}static{za(this,"CommandValidationError")}commandName;missingOptions;constructor(e,n){super(`Command "${e}" is missing required options: ${n.join(", ")}`,"COMMAND_VALIDATION_ERROR",{commandName:e,missingOptions:n}),this.name="CommandValidationError",this.commandName=e,this.missingOptions=n,this.hint=`Provide the following required options: ${n.join(", ")}`}};var Fa=Object.defineProperty,qa=O((t,e)=>Fa(t,"name",{value:e,configurable:!0}),"t$5");const qe=qa((t,e,n=!1)=>{const i=[];for(const r of t)if(!(!n&&!r.required)&&e[r.name]===void 0){if(r.type?.name==="Boolean"){e[r.name]=!1;continue}i.push(r)}return i},"listMissingArguments");var Ga=Object.defineProperty,Ot=O((t,e)=>Ga(t,"name",{value:e,configurable:!0}),"n$5");const Ha=Ot((t,e)=>e.includes(t)?!0:Math.abs(t.length-e.length)>t.length/2?!1:Gt(t,e)<=t.length/3,"isSimilar"),q=Ot((t,e)=>{const n=t.toLowerCase();return e.filter(i=>Ha(i.toLowerCase(),n))},"findAlternatives");var Ka=Object.defineProperty,pe=O((t,e)=>Ka(t,"name",{value:e,configurable:!0}),"a$4");const Ya=pe((t,e)=>{const n=[];if(t._unknown&&t._unknown.forEach(i=>{const r=i.startsWith("--");let a=`Found unknown ${r?"option":"argument"} "${i}"`;if(r){const c=q(i.replace("--",""),(e.options??[]).map(s=>s.name));if(c.length>0){const[s,...m]=c.map(o=>`--${o}`);a+=m.length>0?`, did you mean ${s??""} or ${m.join(", ")}?`:`, did you mean ${s??""}?`}}n.push(a)}),n.length>0)throw new Error(n.join(`
2
+ `))},"validateUnknownOptions"),Ja=pe((t,e,n)=>{const i=n.__requiredOptions__,r=i?qe(i,e,!0):qe(t,e,!1);if(r.length>0)throw new Wa(n.name,r.map(a=>a.name));e._unknown&&e._unknown.length>0&&!n.argument&&Ya(e,n)},"validateRequiredOptions"),Qa=pe((t,e,n)=>{const i=n.__conflictingOptions__??t.filter(r=>r.conflicts!==void 0);if(i.length>0){const r=i.find(a=>Array.isArray(a.conflicts)?a.conflicts.some(c=>e[c]!==void 0)&&e[a.name]!==void 0:e[a.conflicts]!==void 0&&e[a.name]!==void 0);if(r)throw new nt(r.name,typeof r.conflicts=="string"?r.conflicts:r.conflicts?.[0]??"unknown")}},"validateConflictingOptions"),Za=pe(t=>{if(!Array.isArray(t.options))return;const e=new Map,n=new Map;for(const r of t.options){if(r.name){const a=e.get(r.name)??[];a.push(r),e.set(r.name,a)}if(typeof r.alias=="string"&&r.alias.length>0){const a=n.get(r.alias)??[];a.push(r),n.set(r.alias,a)}else if(Array.isArray(r.alias)){for(const a of r.alias)if(a.length>0){const c=n.get(a)??[];c.push(r),n.set(a,c)}}}const i=[];for(const[r,a]of e)a.length>1&&i.push(`Duplicate option name "${r}" in command "${t.name}": ${JSON.stringify(a)}`);for(const[r,a]of n)a.length>1&&i.push(`Duplicate option alias "-${r}" used by options ${a.map(c=>`"${c.name}"`).join(", ")} in command "${t.name}"`);if(i.length>0)throw new Error(i.join(`
3
+ `))},"validateDuplicateOptions");var Xa=Object.defineProperty,ke=O((t,e)=>Xa(t,"name",{value:e,configurable:!0}),"s$4");const ei=ke((t,e)=>{if(e.length===0)return{argv:[],commandPath:void 0};const n=[];let i;for(let r=1;r<=e.length;r+=1){const a=e[r-1];if(a===void 0||a.startsWith("-"))break;n.push(a);const c=n.join(" ");t.has(c)&&(i={commandPath:[...n],depth:r})}return i?{argv:e.slice(i.depth),commandPath:i.commandPath}:{argv:e,commandPath:void 0}},"parseNestedCommand"),Q=ke(t=>t.join(" "),"getCommandPathKey"),ti=ke((t,e)=>e&&e.length>0?[...e,t]:[t],"getFullCommandPath");var ni=Object.defineProperty,ai=O((t,e)=>ni(t,"name",{value:e,configurable:!0}),"p$4"),ii=Object.defineProperty,Et=ai((t,e)=>ii(t,"name",{value:e,configurable:!0}),"e"),oi=Object.defineProperty,ri=Et((t,e)=>oi(t,"name",{value:e,configurable:!0}),"E");const Pt=String.raw,Ge=Pt`\p{Emoji}(?:\p{EMod}|[\u{E0020}-\u{E007E}]+\u{E007F}|\uFE0F?\u20E3?)`,si=ri(()=>new RegExp(Pt`\p{RI}{2}|(?![#*\d](?!\uFE0F?\u20E3))${Ge}(?:\u200D${Ge})*`,"gu"),"default");var li=Object.defineProperty,ci=Et((t,e)=>li(t,"name",{value:e,configurable:!0}),"p");Object.freeze(new Map([[0,0],[1,22],[2,22],[3,23],[4,24],[7,27],[8,28],[9,29],[30,39],[31,39],[32,39],[33,39],[34,39],[35,39],[36,39],[37,39],[40,49],[41,49],[42,49],[43,49],[44,49],[45,49],[46,49],[47,49],[90,39]]));const H=si(),ui=/[-_./\s]+/g,X=/(\u001B\[[0-9;]*[a-z])/i,He=new RegExp("\\p{Script=Arabic}","u"),pi=new RegExp("\\p{Script=Bengali}","u"),W=new RegExp("\\p{Script=Cyrillic}","u"),fi=new RegExp("\\p{Script=Devanagari}","u"),di=new RegExp("\\p{Script=Ethiopic}","u"),ye=new RegExp("\\p{Script=Greek}","u"),Ke=new RegExp("\\p{Script=Greek}+|\\p{Script=Latin}+|[^\\p{Script=Greek}\\p{Script=Latin}]+","gu"),hi=new RegExp("\\p{Script=Gujarati}","u"),mi=new RegExp("\\p{Script=Gurmukhi}","u"),Ye=new RegExp("\\p{Script=Hangul}","u"),Je=new RegExp("\\p{Script=Hebrew}","u"),gi=new RegExp("\\p{Script=Hiragana}","u"),Qe=new RegExp("\\p{Script=Han}","u"),vi=new RegExp("\\p{Script=Kannada}","u"),wi=new RegExp("\\p{Script=Katakana}","u"),yi=new RegExp("\\p{Script=Khmer}","u"),bi=new RegExp("\\p{Script=Lao}","u"),L=new RegExp("\\p{Script=Latin}","u"),$i=new RegExp("\\p{Script=Malayalam}","u"),Oi=new RegExp("\\p{Script=Myanmar}","u"),Ei=new RegExp("\\p{Script=Oriya}","u"),Pi=new RegExp("\\p{Script=Sinhala}","u"),Ai=new RegExp("\\p{Script=Tamil}","u"),Ci=new RegExp("\\p{Script=Telugu}","u"),Ni=new RegExp("\\p{Script=Thai}","u"),xi=new RegExp("\\p{Script=Tibetan}","u"),Ze=/[\u02BB\u02BC\u0027]/u,ki=ci(t=>t.replace(H,""),"stripEmoji");var _i=Object.defineProperty,At=O((t,e)=>_i(t,"name",{value:e,configurable:!0}),"i$5"),ji=Object.defineProperty,Ct=At((t,e)=>ji(t,"name",{value:e,configurable:!0}),"r"),Li=Object.defineProperty,Ii=Ct((t,e)=>Li(t,"name",{value:e,configurable:!0}),"c");let Nt=class{static{O(this,"l")}static{At(this,"y")}static{Ct(this,"s")}static{Ii(this,"LRUCache")}capacity;cache;keyOrder;constructor(e){this.capacity=e,this.cache=new Map,this.keyOrder=[]}get(e){if(this.cache.has(e))return this.keyOrder=this.keyOrder.filter(n=>n!==e),this.keyOrder.push(e),this.cache.get(e)}has(e){return this.cache.has(e)}set(e,n){if(this.cache.has(e))this.keyOrder=this.keyOrder.filter(i=>i!==e);else if(this.cache.size>=this.capacity){const i=this.keyOrder.shift();i!==void 0&&this.cache.delete(i)}this.cache.set(e,n),this.keyOrder.push(e)}delete(e){this.cache.delete(e),this.keyOrder=this.keyOrder.filter(n=>n!==e)}clear(){this.cache.clear(),this.keyOrder=[]}size(){return this.cache.size}};var Si=Object.defineProperty,Ui=O((t,e)=>Si(t,"name",{value:e,configurable:!0}),"r$5"),Mi=Object.defineProperty,Ti=Ui((t,e)=>Mi(t,"name",{value:e,configurable:!0}),"a"),Vi=Object.defineProperty,Di=Ti((t,e)=>Vi(t,"name",{value:e,configurable:!0}),"s");const Ri=Di((t,e)=>typeof t!="string"||t===""?"":(e?.locale?t[0].toLocaleLowerCase(e.locale):t[0].toLowerCase())+t.slice(1),"lowerFirst");var Bi=Object.defineProperty,zi=O((t,e)=>Bi(t,"name",{value:e,configurable:!0}),"I"),Wi=Object.defineProperty,fe=zi((t,e)=>Wi(t,"name",{value:e,configurable:!0}),"W");const Fi=Ht(import.meta.url),Z=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,qi=fe(t=>{if(typeof Z<"u"&&Z.versions&&Z.versions.node){const[e,n]=Z.versions.node.split(".").map(Number);if(e>22||e===22&&n>=3||e===20&&n>=16)return Z.getBuiltinModule(t)}return Fi(t)},"__cjs_getBuiltinModule"),{stripVTControlCharacters:Gi}=qi("node:util");var Hi=Object.defineProperty,Ki=fe((t,e)=>Hi(t,"name",{value:e,configurable:!0}),"g");const be=new Nt(1e3),Yi=/[.*+?^${}()|[\]\\]/g,Ji=Ki(t=>{const e=t.join("");if(be.has(e))return be.get(e);const n=t.map(r=>r.replaceAll(Yi,String.raw`\$&`)).join("|"),i=new RegExp(n,"g");return be.set(e,i),i},"getSeparatorsRegex");var Qi=Object.defineProperty,Zi=fe((t,e)=>Qi(t,"name",{value:e,configurable:!0}),"t");const Xi=Zi(t=>{const e=[];let n=0,i;for(H.lastIndex=0;(i=H.exec(t))!==null;)i.index>n&&e.push(t.slice(n,i.index)),e.push(i[0]),n=H.lastIndex;return n<t.length&&e.push(t.slice(n)),e.filter(Boolean)},"splitByEmoji");var eo=Object.defineProperty,x=fe((t,e)=>eo(t,"name",{value:e,configurable:!0}),"u");const to=/[ČŠŽĐ]/i,xt=new Uint8Array(128),kt=new Uint8Array(128),_t=new Uint8Array(128);for(let t=0;t<128;t++)xt[t]=t>=65&&t<=90?1:0,kt[t]=t>=97&&t<=122?1:0,_t[t]=t>=48&&t<=57?1:0;const $e=x(t=>xt[t],"isUpper"),Xe=x(t=>kt[t],"isLower"),Oe=x(t=>_t[t],"isDigit"),M=x((t,e,n,i,r)=>{if(t.length===0)return[];let a=!1;const c=Object.values(e);for(const g of c)if(g(t[0])){a=!0;break}if(!a&&!n)return[t];const s=[...t],m=[];let o=s[0],u="other";const d=Object.entries(e);for(const g of d){const[p,b]=g;if(b(s[0])){u=p;break}}let l=n&&i?s[0]===s[0].toLocaleUpperCase(i):!1;for(let g=1;g<s.length;g++){const p=s[g];let b="other";for(const P of d){const[N,f]=P;if(f(p)){b=N;break}}const $=n&&i?p===p.toLocaleUpperCase(i):!1;let y=!1;r?y=r(u,b,l,$,p,g,s):(u!==b&&u!=="other"&&b!=="other"&&(y=!0),n&&b!=="other"&&!l&&$&&(y=!0)),y?(m.push(o),o=p):o+=p,u=b,n&&(l=$)}return o&&o.length>0&&m.push(o),m.length>0?m:[t]},"handleScriptTransitions"),no=x((t,e,n,i)=>{if(n.size===0)return e;for(const r of n)if(t.startsWith(r,e))return i.push(r),e+r.length;return e},"detectAndProcessAcronym"),jt=x((t,e=new Set)=>{if(t.length===0)return[];if(t.toUpperCase()===t)return[t];let n=0;const i=[],r=t.length;for(let a=1;a<r;a++){const c=no(t,n,e,i);if(c!==n){n=c,a=n-1;continue}const s=t.codePointAt(a-1),m=t.codePointAt(a),o=s&&s<128&&$e(s),u=m&&m<128&&$e(m),d=s&&s<128&&Xe(s),l=s&&s<128&&Oe(s),g=m&&m<128&&Oe(m);if(d&&u){i.push(t.slice(n,a)),n=a;continue}if(l&&!g||!l&&g){i.push(t.slice(n,a)),n=a;continue}if(g&&!l){let p=!1,b=!1;if(a+1<r){const $=t.codePointAt(a+1);p=$&&$<128&&$e($),b=$&&$<128&&Oe($)}if(!b&&p){i.push(t.slice(n,a),t.slice(a,a+1)),n=a+1;continue}}if(a+1<r){const p=t.codePointAt(a+1),b=p&&p<128&&Xe(p);if(o&&u&&b){const $=t.slice(n,a+1);e.has($)||(i.push(t.slice(n,a)),n=a)}}}return n<r&&i.push(t.slice(n)),i.filter(a=>a!=="")},"splitCamelCaseFast"),Lt=x((t,e,n)=>{if(t.length===0)return[];const i=t===t.toLocaleUpperCase(e);if(e.startsWith("de")){if(!i&&t.replaceAll("ß","SS")===t.toLocaleUpperCase(e))return[t];const o=[...t],u=o.length,d=[];let l=o[0],g=o[0]===o[0].toLocaleUpperCase(e),p=g,b=g?0:-1;for(let $=1;$<u;$++){const y=o[$],P=y===y.toLocaleUpperCase(e);if(P===g)l+=y;else if(P)l&&l.length>0&&(d.push(l),l=y),p=!0,b=$;else{if(p&&$-b>1){const N=o[$-1],f=l.slice(0,-1);f&&f.length>0&&d.push(f),l=N+y}else l+=y;p=!1,b=-1}g=P}return l&&l.length>0&&d.push(l),d}if(e.startsWith("uk")||e.startsWith("ru")||e.startsWith("bg")||e.startsWith("sr")||e.startsWith("mk")||e.startsWith("be")){if(!W.test(t)&&!L.test(t))return[t];const o=[...t],u=o.length,d=[];let l=o[0];const g=o[0];let p;W.test(g)?p=1:L.test(g)?p=2:p=0;let b=g===g.toLocaleUpperCase(e);for(let y=1;y<u;y++){const P=o[y];let N;W.test(P)?N=1:L.test(P)?N=2:N=0;const f=P===P.toLocaleUpperCase(e);p!==N&&(p===1||p===2)&&(N===1||N===2)||N===p&&!b&&f?(d.push(l),l=P):l+=P,p=N,b=f}l&&l.length>0&&d.push(l);const $=[];for(let y=0;y<d.length;y++)y<d.length-1&&d[y].length===1&&L.test(d[y])&&W.test(d[y+1][0])?($.push(d[y]+d[y+1]),y+=1):$.push(d[y]);return $}if(e.startsWith("el")){if(!ye.test(t)&&!L.test(t))return[t];const o=[];Ke.lastIndex=0;let u;for(;(u=Ke.exec(t))!==null;)o.push(u[0]);o.length===0&&o.push(t);const d=[];if(o.length===1){const l=o[0];if(!l||!ye.test(l[0])||l.length===1)return[l??t]}for(const l of o){if(!l)continue;if(!ye.test(l[0])||l.length===1){d.push(l);continue}const g=l.length;let p=l[0],b=l[0]===l[0].toLocaleUpperCase(e);for(let $=1;$<g;$++){const y=l[$],P=y===y.toLocaleUpperCase(e);!b&&P?(d.push(p),p=y):p+=y,b=P}p&&d.push(p)}return d}if(e.startsWith("ja")||e.startsWith("ko")){const o=e.startsWith("ja"),u=o?{hiragana:x(l=>gi.test(l),"hiragana"),kanji:x(l=>Qe.test(l),"kanji"),katakana:x(l=>wi.test(l),"katakana"),latin:x(l=>L.test(l),"latin")}:{hangul:x(l=>Ye.test(l),"hangul"),latin:x(l=>L.test(l),"latin")},d=new Set(["が","で","と","に","の","は","へ","も","や","を"]);if(o){const l=M(t,u,!1,e,(p,b)=>p==="hiragana"&&b==="katakana"||p==="katakana"&&b==="hiragana"||p==="hiragana"&&b==="latin"||p==="katakana"&&b==="latin"||p==="kanji"&&b==="latin"||p==="latin"&&(b==="hiragana"||b==="katakana"||b==="kanji")),g=[];for(const p of l){const b=p;b.length===1&&d.has(b)&&g.length>0?g[g.length-1]=g.at(-1)+b:g.push(b)}return g.length>0?g:[t]}return M(t,u,!1,e,(l,g)=>l==="hangul"&&g==="latin"||l==="latin"&&g==="hangul")}if(e.startsWith("sl")){const o=[...t],u=o.length,d=[];let l=o[0],g=o[0]===o[0].toLocaleUpperCase(e);for(let p=1;p<u;p++){const b=o[p],$=b===b.toLocaleUpperCase(e),y=to.test(b),P=p<u-1&&o[p+1]===o[p+1].toLocaleUpperCase(e);!g&&$||y&&P?(d.push(l),l=b,y&&P&&(d.push(l),l="")):l+=b,g=$}return l&&l.length>0&&d.push(l),d}if(e.startsWith("zh"))return M(t,{han:x(o=>Qe.test(o),"han"),latin:x(o=>L.test(o),"latin")},!1,e);if(["ar","fa","he","ur"].includes(e.split("-")[0])){const o=x(u=>Je.test(u)||He.test(u),"isRtlChar");return M(t,{latin:x(u=>L.test(u),"latin"),rtl:x(u=>o(u),"rtl")},!1,e)}if(["am","bn","gu","hi","km","kn","lo","ml","mr","ne","or","pa","si","ta","te","th"].includes(e.split("-")[0])){const o=x(u=>fi.test(u)||pi.test(u)||hi.test(u)||mi.test(u)||vi.test(u)||Ai.test(u)||Ci.test(u)||$i.test(u)||Pi.test(u)||Ni.test(u)||bi.test(u)||xi.test(u)||Oi.test(u)||di.test(u)||yi.test(u)||Ei.test(u),"isIndicChar");return M(t,{indic:x(u=>o(u),"indic"),latin:x(u=>L.test(u),"latin")},!1,e)}if(["be","bg","ru","sr","uk"].includes(e))return M(t,{cyrillic:x(o=>W.test(o),"cyrillic"),latin:x(o=>L.test(o),"latin")},!0,e);if(["ar","fa","he"].includes(e))return M(t,{latin:x(o=>L.test(o),"latin"),rtl:x(o=>Je.test(o)||He.test(o),"rtl")},!1,e);if(e.startsWith("ko"))return M(t,{hangul:x(o=>Ye.test(o),"hangul"),latin:x(o=>L.test(o),"latin")},!1,e);if(e.startsWith("uz")){if(!W.test(t)&&!L.test(t))return[t];const o=[...t],u=o.length,d=[];let l=o[0],g=o[0]===o[0].toLocaleUpperCase(e);for(let p=1;p<u;p++){const b=o[p],$=b===b.toLocaleUpperCase(e);if(Ze.test(b)||Ze.test(o[p-1])){l+=b;continue}!g&&$?(d.push(l),l=b):l+=b,g=$}return l&&l.length>0&&d.push(l),d}const r=[...t],a=r.length,c=[];let s=r[0],m=r[0]===r[0].toLocaleUpperCase(e);for(const o of n)if(t.startsWith(o)){c.push(o),s=r[o.length],m=s===s.toLocaleUpperCase(e);break}for(let o=1;o<a;o++){const u=r[o],d=u===u.toLocaleUpperCase(e);let l=0;for(const g of n)if(t.startsWith(g,o)){c.push(s,g),l=g.length,s="";const p=g.at(-1);p&&(m=p===p.toLocaleUpperCase(e));break}if(l>0){o+=l-1;continue}!m&&d?(c.push(s),s=u):s+=u,m=d}return s&&c.push(s),c},"splitCamelCaseLocale"),ao=x((t,e,n)=>{const i=[],r=X.test(t)?t.split(X).filter(Boolean):[t];for(const a of r){const c=a;if(X.test(c))i.push(c);else{const s=H.test(c)?Xi(c).filter(Boolean):[c];for(const m of s)if(H.test(m))i.push(m);else if(e){const o=e.toLowerCase().split("-")[0];i.push(...Lt(m,o,n))}else i.push(...jt(m,n))}}return i},"processTextWithAnsiEmoji"),io=x((t,e={})=>{if(!t||typeof t!="string")return[];const{handleAnsi:n=!1,handleEmoji:i=!1,knownAcronyms:r=[],locale:a,normalize:c=!1,separators:s,stripAnsi:m=!1,stripEmoji:o=!1}=e,u=new Set([...r].toSorted((y,P)=>P.length-y.length));let d=t;m&&(d=Gi(d)),o&&(d=ki(d));let l;Array.isArray(s)?l=Ji(s):s instanceof RegExp?l=s:l=ui;const g=[];let p=d;const b=l.flags.includes("g")?l:new RegExp(l.source,`${l.flags}g`);for(;p.length>0;){const y=b.exec(p);if(!y){p===".."?g.push(".."):p==="."?g.push("."):p.length>0&&g.push(p);break}const P=y.index,N=y[0],f=N.length,h=p.slice(0,P),v=p.slice(P+f);if(N.startsWith("../"))g.push(".."),p=p.slice(P+3);else if(N.startsWith("./"))g.push("."),p=p.slice(P+2);else if(P===0&&N==="..")g.push(".."),p=p.slice(2);else if(P===0&&N===".")g.push("."),p=p.slice(1);else{h.length>0&&g.push(h);let w=0;for(;(w=N.indexOf("../",w))!==-1;)g.push(".."),w+=3;for(w=0;(w=N.indexOf("./",w))!==-1;)(w===0||N[w-1]!==".")&&g.push("."),w+=2;let E=v;for(;E.startsWith("../");)g.push(".."),E=E.slice(3);for(;E.startsWith("./");)g.push("."),E=E.slice(2);if(E===".."){g.push("..");break}else if(E==="."){g.push(".");break}else p=E}b.lastIndex=0}if(g.length===0){const y=d.split(l).filter(Boolean);g.push(...y)}let $=[];for(const y of g)n||i?$.push(...ao(y,a,u)):a?$.push(...Lt(y,a,u)):$.push(...jt(y,u));return c&&($=$.map(y=>u.has(y)?y:a&&y===y.toLocaleUpperCase(a)?y[0]+y.slice(1).toLocaleLowerCase(a):y.toUpperCase()===y&&!u.has(y)?y.slice(0,1)+y.slice(1).toLowerCase():y)),$},"splitByCase");var oo=Object.defineProperty,ro=O((t,e)=>oo(t,"name",{value:e,configurable:!0}),"r$4"),so=Object.defineProperty,lo=ro((t,e)=>so(t,"name",{value:e,configurable:!0}),"o"),co=Object.defineProperty,uo=lo((t,e)=>co(t,"name",{value:e,configurable:!0}),"s");const po=uo((t,e)=>typeof t!="string"||t===""?"":(e?.locale?t[0].toLocaleUpperCase(e.locale):t[0].toUpperCase())+t.slice(1),"upperFirst");var fo=Object.defineProperty,ho=O((t,e)=>fo(t,"name",{value:e,configurable:!0}),"r$3"),mo=Object.defineProperty,go=ho((t,e)=>mo(t,"name",{value:e,configurable:!0}),"r"),vo=Object.defineProperty,wo=go((t,e)=>vo(t,"name",{value:e,configurable:!0}),"n");const yo=wo((t,e)=>`${t}::${e?.joiner??""}::${e?.locale??""}::${e?.knownAcronyms?.join(",")??""}::${e?.normalize?"true":"false"}`,"generateCacheKey");var bo=Object.defineProperty,$o=O((t,e)=>bo(t,"name",{value:e,configurable:!0}),"i$3"),Oo=Object.defineProperty,Eo=$o((t,e)=>Oo(t,"name",{value:e,configurable:!0}),"f"),Po=Object.defineProperty,Ao=Eo((t,e)=>Po(t,"name",{value:e,configurable:!0}),"l");const Co=Ao((t,e)=>{const{length:n}=t;if(n===0)return"";if(n===1)return t[0];const i=[];let r="",a="";for(let c=0;c<n;c++){const s=t[c];if(X.test(s)){r?(i.push(r+a+s),r="",a=""):(i.length>0&&i.push(e),r=s);continue}r?(a&&(a+=e),a+=s):(i.length>0&&i.push(e),i.push(s))}return i.join("")},"joinSegments");var No=Object.defineProperty,xo=O((t,e)=>No(t,"name",{value:e,configurable:!0}),"r$2"),ko=Object.defineProperty,_o=xo((t,e)=>ko(t,"name",{value:e,configurable:!0}),"a"),jo=Object.defineProperty,Lo=_o((t,e)=>jo(t,"name",{value:e,configurable:!0}),"e");const Io=/(?<![a-zß])SS(?![a-z])/g,So=Lo(t=>t.replaceAll(Io,"ß"),"normalizeGermanEszett");var Uo=Object.defineProperty,Mo=O((t,e)=>Uo(t,"name",{value:e,configurable:!0}),"c$2"),To=Object.defineProperty,Vo=Mo((t,e)=>To(t,"name",{value:e,configurable:!0}),"c"),Do=Object.defineProperty,Ro=Vo((t,e)=>Do(t,"name",{value:e,configurable:!0}),"o");const Bo=new Nt(1e3),It=Ro((t,e)=>{if(typeof t!="string"||!t)return"";const n=e?.cache??!1,i=e?.cacheStore??Bo;let r;if(n&&(r=yo(t,e)),n&&r&&i.has(r))return i.get(r);let a=!0;const c=Co(io(t,{handleAnsi:e?.handleAnsi,handleEmoji:e?.handleEmoji,knownAcronyms:e?.knownAcronyms,locale:e?.locale,normalize:e?.normalize,separators:void 0,stripAnsi:e?.stripAnsi,stripEmoji:e?.stripEmoji}).map(s=>{if(e?.handleAnsi&&X.test(s))return s;const m=e?.locale?.startsWith("de")?So(s):s,o=e?.locale?m.toLocaleLowerCase(e.locale):m.toLowerCase();return a?(a=!1,Ri(o,e)):po(o,e)}),"");return n&&r&&i.set(r,c),c},"camelCase");var zo=Object.defineProperty,de=O((t,e)=>zo(t,"name",{value:e,configurable:!0}),"a$2");const Wo=de(t=>{t.options?.forEach(e=>{e.__camelCaseName__=It(e.name)})},"processOptionNames"),Fo=de(t=>{if(!Array.isArray(t.options)||t.options.length===0)return;const e=new Set;for(const i of t.options)e.add(i.name);const n=[];for(const i of t.options)if(i.name.startsWith("no-")){const r=i.name.replace("no-","");if(!e.has(r)){if(i.type!==Boolean)throw new Error(`Cannot add negated option "${i.name}" to command "${t.name}" because it is not a boolean.`);const a={...i,defaultValue:i.defaultValue===void 0?!0:!i.defaultValue,name:r};n.push(a),e.add(r)}}n.length>0&&t.options.push(...n)},"addNegatableOptions"),qo=de((t,e)=>{if(!e.options||e.options.length===0)return;const{options:n}=t,i=new Map;for(const a of e.options)if(a.name.startsWith("no-")){const c=It(a.name);i.set(c,a)}const r=Object.keys(n).filter(a=>i.has(a));if(r.length!==0)for(const a of r){const c=a.charAt(2);if(!c)continue;const s=c.toLowerCase()+a.slice(3),m=i.get(a);m&&(m.__negated__=!0),n[s]=!n[a],Reflect.deleteProperty(n,a)}},"mapNegatableOptions"),Go=de((t,e)=>{if(!e.options||e.options.length===0)return;const n=new Map;for(const r of e.options)r.__camelCaseName__&&r.__negated__===void 0&&r.implies!==void 0&&n.set(r.__camelCaseName__,r);if(n.size===0)return;const{options:i}=t;for(const r of Object.keys(i)){const a=n.get(r);if(a?.implies){const{implies:c}=a;for(const[s,m]of Object.entries(c))i[s]===void 0&&(i[s]=m)}}},"mapImpliedOptions");var Ho=Object.defineProperty,he=O((t,e)=>Ho(t,"name",{value:e,configurable:!0}),"e$2");const Ko=he(()=>!!process.versions.electron,"isElectronApp"),Yo=he(()=>Ko()&&!process.defaultApp,"isBundledElectronApp"),Jo=he(()=>Yo()?0:1,"getProcessArgvBinIndex"),Qo=he(t=>t.slice(Jo()+1),"hideBin");var Zo=Object.defineProperty,St=O((t,e)=>Zo(t,"name",{value:e,configurable:!0}),"e$1");const Xo=" ",er=St((t,e)=>t===e?!0:t.length!==e.length?!1:t.every((n,i)=>n===e[i]),"equals"),tr=St(t=>{if(typeof t=="string")return t.split(Xo);const e=Ce();return er(t,e)?Qo(t):t},"parseRawCommand");var nr=Object.defineProperty,Ee=O((t,e)=>nr(t,"name",{value:e,configurable:!0}),"r");const ar=Ee(t=>{const e=Ee(a=>{t.error(`Uncaught exception: ${a.message||a}`),a.stack&&t.error(a.stack),re(1)},"uncaughtExceptionHandler"),n=Ee((a,c)=>{if(a instanceof Error)t.error(`Promise rejection: ${a.message||a}`),a.stack&&t.error(a.stack);else{let s;if(typeof a=="string")s=a;else try{s=JSON.stringify(a)}catch{s=String(a)}t.error(`Promise rejection: ${s}`)}re(1)},"unhandledRejectionHandler"),i=Le("uncaughtException",e),r=Le("unhandledRejection",n);return()=>{i(),r()}},"registerExceptionHandler");var ir=Object.defineProperty,Y=O((t,e)=>ir(t,"name",{value:e,configurable:!0}),"e");const se=100,Ut=/^[a-z][\w-]*$/i,_e=Y((t,e)=>{if(typeof t!="string"||t.trim().length===0)throw new C(`${e} must be a non-empty string`,"INVALID_INPUT",{fieldName:e,value:t});return t.trim()},"validateNonEmptyString"),et=Y((t,e)=>{if(!Array.isArray(t)||!t.every(n=>typeof n=="string"))throw new C(`${e} must be an array of strings`,"INVALID_INPUT",{fieldName:e,value:t});return t},"validateStringArray");Y((t,e)=>{if(typeof t!="function")throw new C(`${e} must be a function`,"INVALID_INPUT",{fieldName:e,value:t});return t},"validateFunction");const Pe=Y((t,e)=>{if(typeof t!="object"||t===null)throw new C(`${e} must be an object`,"INVALID_INPUT",{fieldName:e,value:t});return t},"validateObject"),ae=Y(t=>{const e=_e(t,"Command name");if(e.length>se)throw new C(`Command name is too long (maximum ${String(se)} characters)`,"INVALID_COMMAND_NAME",{commandName:e,length:e.length});if(e.includes("..")||e.includes("/")||e.includes("\\")||e.includes(";")||e.includes("|")||e.includes("&"))throw new C(`Command name "${e}" contains invalid characters`,"INVALID_COMMAND_NAME",{commandName:e});if(!Ut.test(e))throw new C(`Command name "${e}" must start with a letter and contain only letters, numbers, hyphens, and underscores`,"INVALID_COMMAND_NAME",{commandName:e});return e},"validateCommandName");Y(t=>{const e=_e(t,"Plugin name");if(e.length>se)throw new C(`Plugin name is too long (maximum ${String(se)} characters)`,"INVALID_PLUGIN_NAME",{length:e.length,pluginName:e});if(e.includes("..")||e.includes("/")||e.includes("\\")||e.includes(";")||e.includes("|")||e.includes("&"))throw new C(`Plugin name "${e}" contains invalid characters`,"INVALID_PLUGIN_NAME",{pluginName:e});if(!Ut.test(e))throw new C(`Plugin name "${e}" must start with a letter and contain only letters, numbers, hyphens, and underscores`,"INVALID_PLUGIN_NAME",{pluginName:e});return e},"validatePluginName");var or=Object.defineProperty,me=O((t,e)=>or(t,"name",{value:e,configurable:!0}),"s");const rr=new Set([`
4
+ `,"\r"," ","\0",'"',"$","&","'","(",")",";","<",">","[","\\","]","`","{","|","}"]),sr=/^[A-Z]:/i,lr=me(t=>{if(typeof t!="string")throw new TypeError("Argument must be a string");if(t.length>1e4)throw new Error(`Argument is too long (maximum ${String(1e4)} characters)`);for(const e of t)if(rr.has(e))throw new Error(`Argument contains dangerous character: ${e}`);return t.trim()},"sanitizeArgument"),tt=me(t=>{if(!Array.isArray(t))throw new TypeError("Arguments must be an array");if(t.length>100)throw new Error(`Too many arguments (maximum ${String(100)})`);return t.map(e=>lr(e))},"sanitizeArguments");me(t=>{if(typeof t!="string")throw new TypeError("Path must be a string");const e=t.trim();if(e.includes("..")||e.includes("../")||e.includes("..\\"))throw new Error("Path contains directory traversal sequences");if(e.startsWith("/")||sr.test(e))throw new Error("Absolute paths are not allowed");if(e.length>1e3)throw new Error("Path is too long");return e},"validateSafePath");class xr{static{O(this,"RateLimiter")}static{me(this,"RateLimiter")}attempts=new Map;maxAttempts;windowMs;constructor(e=5,n=6e4){if(e<=0||n<=0)throw new Error("maxAttempts and windowMs must be positive numbers");this.maxAttempts=e,this.windowMs=n}checkLimit(e){const n=Date.now(),i=this.attempts.get(e);return!i||n>i.resetTime?(this.attempts.set(e,{count:1,resetTime:n+this.windowMs}),this.cleanup(n),!0):i.count>=this.maxAttempts?!1:(i.count+=1,!0)}reset(e){this.attempts.delete(e)}cleanup(e){for(const[n,i]of this.attempts.entries())e>i.resetTime&&this.attempts.delete(n)}}var cr=Object.defineProperty,oe=O((t,e)=>cr(t,"name",{value:e,configurable:!0}),"T");const ur=/^-([^\d-])$/,pr=/^--(\S+)/,fr=/^-([^\d-]{2,})$/,Ae=oe(t=>ur.test(t)||pr.test(t)||fr.test(t),"isOption");class kr{static{O(this,"Cli")}static{oe(this,"Cli")}#t;#e;#o;#c;#v;#u;#w;#r;#n;#a;#p;#s;#l;#f=!1;#y;#b=!1;#d;#h;#m;#g=[];#A(){return this.#d===void 0&&(this.#d=[...this.#a.keys()]),this.#d}#$(){return this.#h===void 0&&(this.#h=[...this.#n.keys()]),this.#h}#i(){return this.#m===void 0&&(this.#m=[...this.#A(),...this.#$()]),this.#m}#O(){return this.#g.length===0?ne:[...ne,...this.#g]}#C(){this.#d=void 0,this.#h=void 0,this.#m=void 0}#E(){if(this.#o===void 0){const e=tr(this.#e.argv);this.#o=tt(e),this.#N()}return this.#o}#N(){if(!this.#o)return;const e=G();let n=!1;for(const i of this.#o){if(i==="--quiet"||i==="-q"){e.CEREBRO_OUTPUT_LEVEL=String(Bt),n=!0;break}if(i==="--verbose"||i==="-v"){e.CEREBRO_OUTPUT_LEVEL=String(zt),n=!0;break}if(i==="--debug"||i==="-vvv"){e.CEREBRO_OUTPUT_LEVEL=String(F),n=!0;break}}n||(e.CEREBRO_OUTPUT_LEVEL=Object.hasOwn(e,"DEBUG")?String(F):String(je))}#x(){this.#b||(this.#y=ar(this.#t),this.#b=!0)}#P(e,n,i,r){this.#t.debug(`command '${r}' found, parsing command args: ${n.join(", ")}`);const{arguments_:a,booleanValues:c,parsedArgs:s}=Ra(e,n,this.#O()),m=Object.keys(c).length>0;let o=s;m&&(o={...s,_all:{...s._all,...c}}),Ja(a,o,e);const u=Da(e,s,c,i);u.runtime=this,u.argv=this.#E();const d=e.options&&e.options.length>0;if(d&&e.options){const l=e.options.filter(g=>g.name.startsWith("no-"));for(const g of l){const p=g.name.replace("no-",""),b=`--${g.name}`,$=`--${p}`,y=n.includes(b),P=n.includes($);if(y&&P)throw new nt(p,g.name)}}return d&&(qo(u,e),Go(u,e)),Qa(a,u.options,e),G().CEREBRO_OUTPUT_LEVEL===String(F)&&(this.#t.debug("command options parsed from options:"),this.#t.debug(JSON.stringify(u.options,null,2)),this.#t.debug("command argument parsed from argument:"),this.#t.debug(JSON.stringify(u.argument,null,2))),{arguments_:a,booleanValues:c,commandArgs:o,parsedArgs:s,toolbox:u}}constructor(e,n={}){if(typeof e!="string"||e.trim().length===0)throw new C("CLI name must be a non-empty string","INVALID_INPUT",{cliName:e});this.#v=e.trim();const i=n.argv??Ce(),r=n.cwd??Wt();if(this.#e={...n,argv:i,cwd:r},this.#e.argv&&!Array.isArray(this.#e.argv))throw new C("CLI argv option must be an array of strings","INVALID_INPUT",{argv:this.#e.argv});if(this.#e.cwd&&typeof this.#e.cwd!="string")throw new C("CLI cwd option must be a string","INVALID_INPUT",{cwd:this.#e.cwd});if(this.#e.packageName&&typeof this.#e.packageName!="string")throw new C("CLI packageName option must be a string","INVALID_INPUT",{packageName:this.#e.packageName});if(this.#e.packageVersion&&typeof this.#e.packageVersion!="string")throw new C("CLI packageVersion option must be a string","INVALID_INPUT",{packageVersion:this.#e.packageVersion});const a=G();if(a.CEREBRO_OUTPUT_LEVEL=String(je),typeof this.#e.logger=="object"){const c=["debug","error","info","log","warn"],s=[],m=this.#e.logger;for(const o of c)typeof m[o]!="function"&&s.push(o);if(s.length>0)throw new C(`Logger object is missing required methods: ${s.join(", ")}`,"INVALID_INPUT",{logger:this.#e.logger,missingMethods:s});this.#t=this.#e.logger}else this.#t={...console,debug:oe((...c)=>{a.CEREBRO_OUTPUT_LEVEL===String(F)&&console.debug(...c)},"debug")};this.#u=this.#e.packageVersion,this.#w=this.#e.packageName,this.#c=this.#e.cwd,this.#s="help",this.#l={},this.#n=new Map,this.#a=new Map,this.#p=new Map}setCommandSection(e){return this.#l=e,this}getCommandSection(){return this.#l.header||(this.#l.header=`${this.#v}${this.#u?` v${this.#u}`:""}`),this.#l}setDefaultCommand(e){return this.#s=e,this}get defaultCommand(){return this.#s}addCommand(e){Pe(e,"Command"),ae(e.name);const n=typeof e.execute=="function",i=typeof e.loader=="function";if(n&&i)throw new C(`Command "${e.name}" cannot define both "execute" and "loader" — choose one`,"INVALID_COMMAND",{commandName:e.name});if(!n&&!i)throw new C(`Command "${e.name}" must define either "execute" or "loader"`,"INVALID_COMMAND",{commandName:e.name});e.alias&&(typeof e.alias=="string"?ae(e.alias):et(e.alias,"Command alias").forEach(c=>ae(c))),e.argument&&Pe(e.argument,"Command argument"),e.options&&Pe(e.options,"Command options"),e.commandPath&&(et(e.commandPath,"Command commandPath"),e.commandPath.forEach(c=>{ae(c)}));const r=ti(e.name,e.commandPath),a=Q(r);if(this.#a.has(a))throw new C(`Command with path "${a}" already exists`,"DUPLICATE_COMMAND",{commandName:e.name,commandPath:e.commandPath});if(this.#n.has(e.name)&&!e.commandPath)throw new C(`Command with name "${e.name}" already exists`,"DUPLICATE_COMMAND",{commandName:e.name});if(e.options)for(const c of e.options)Se(c);if(Za(e),Fo(e),Wo(e),e.options&&(e.__conflictingOptions__=e.options.filter(c=>c.conflicts!==void 0),e.__requiredOptions__=e.options.filter(c=>c.required===!0)),this.#n.set(e.name,e),this.#a.set(a,r),this.#p.set(a,e),this.#C(),e.alias!==void 0){const c=typeof e.alias=="string"?[e.alias]:e.alias;for(const s of c){if(G().CEREBRO_OUTPUT_LEVEL===String(F)&&this.#t.debug("adding alias",s),this.#n.has(s))throw new C(`Command alias "${s}" conflicts with existing command`,"DUPLICATE_COMMAND",{alias:s,commandName:e.name});this.#n.set(s,e)}}return this}addGlobalOption(e){const n=e,i=new Set(ne.map(a=>a.name)),r=new Set(ne.map(a=>a.alias).filter(Boolean));if(i.has(n.name))throw new C(`Cannot add global option "--${n.name}": it conflicts with a built-in global option`,"DUPLICATE_OPTION",{optionName:n.name});if(n.alias&&r.has(n.alias))throw new C(`Cannot add global option with alias "-${n.alias}": it conflicts with a built-in global option alias`,"DUPLICATE_OPTION",{alias:n.alias,optionName:n.name});if(new Set(this.#g.map(a=>a.name)).has(n.name))throw new C(`Global option "--${n.name}" has already been added`,"DUPLICATE_OPTION",{optionName:n.name});return n.group="global",Se(n),this.#g.push(n),this}getGlobalOptions(){return this.#O()}addPlugin(e){return this.getPluginManager().register(e),this}getPluginManager(){return this.#r?this.#r:(this.#r=new nn(this.#t),this.#r.register({description:"Attaches the logger to the toolbox",execute:oe(e=>{e.logger=this.#t},"execute"),name:"logger"}),this.#r)}getCliName(){return this.#v}getPackageVersion(){return this.#u}getPackageName(){return this.#w}getCommands(){return this.#n}getCwd(){return this.#c}dispose(){this.#y?.()}async run(e={}){const{autoDispose:n=!0,shouldExitProcess:i=!0,...r}=e;if(!this.#n.has("help")){const{default:h}=await import("../commands/help-command.js");this.addCommand(new h(this.#n))}const a=this.#$(),c=this.#a;this.#x();const s=this.#E();let m,o=[...s];const u=Ft(),d=qt(),l=Ce();this.#t.debug(`process.execPath: ${u}`),this.#t.debug(`process.execArgv: ${d.join(" ")}`),this.#t.debug(`process.argv: ${l.join(" ")}`);const g=ei(c,[...s]);if(g.commandPath)m=g.commandPath,o=g.argv;else{if(s.length>1&&s[0]&&s[1]&&!Ae(s[0])&&!Ae(s[1])){const v=[];let w=0;for(;w<s.length;){const k=s[w];if(!k||Ae(k))break;v.push(k),w+=1}const E=Q(v);if(v[0]&&!a.includes(v[0])){const k=this.#i(),A=q(E,k);throw new B(E,A)}}let h;try{h=dn([null,...a],[...s])}catch(v){if(v instanceof Error&&v.name==="INVALID_COMMAND"&&"command"in v){const w=v.command,E=this.#i(),k=q(w,E);throw new B(w,k)}throw v}h.command&&(m=[h.command],o=h.argv)}if(!m)if(this.#s)m=[this.#s];else{const h=this.#i();throw new B("",h)}const p=Q(m),b=this.#a.get(p);let $;if(b){if($=this.#p.get(p),!$||Q(b)!==p){const h=this.#i(),v=q(p,h);throw new B(p,v)}}else{const h=m.at(-1);if($=h?this.#n.get(h):void 0,!$){const v=this.#i(),w=q(p,v);throw new B(p,w)}}if(typeof $.execute!="function"&&typeof $.loader!="function")return this.#t.error(`Command "${$.name}" has no function to execute.`),i?re(1):void 0;const y=o,{commandArgs:P,toolbox:N}=this.#P($,y,r,p),f=this.getPluginManager();try{!this.#f&&f.hasPlugins()&&(await f.init({cli:this,cwd:this.#c,logger:this.#t}),this.#f=!0),await f.executeLifecycle("execute",N),await f.executeLifecycle("beforeCommand",N);let h;const v=P.global;if(v?.help){const w=this.#n.get("help");if(!w)throw new C("Help command not found","COMMAND_NOT_FOUND");h=await z(w,N,P)}else if(v?.version??v?.V){const w=this.#n.get("version");if(!w)throw new C("Version command not found","COMMAND_NOT_FOUND");h=await z(w,N,P)}else h=await z($,N,P);return await f.executeLifecycle("afterCommand",N,h),i?re(0):void 0}catch(h){throw await f.executeErrorHandlers(h,N),h}finally{n&&this.dispose()}}async runCommand(e,n={}){const{argv:i=[],...r}=n;_e(e,"Command name");const a=e.split(" ").filter(Boolean),c=Q(a),s=this.#a.get(c)?this.#p.get(c):this.#n.get(e);if(!s){const l=this.#i(),g=q(c||e,l);throw new B(e,g)}if(typeof s.execute!="function"&&typeof s.loader!="function")throw new C(`Command "${s.name}" has no function to execute`,"INVALID_COMMAND",{commandName:s.name});const m=[...tt(i)];this.#t.debug(`running command '${e}' programmatically with args: ${m.join(", ")}`);const{commandArgs:o,toolbox:u}=this.#P(s,m,r,c||e),d=this.getPluginManager();try{!this.#f&&d.hasPlugins()&&(await d.init({cli:this,cwd:this.#c,logger:this.#t}),this.#f=!0),await d.executeLifecycle("execute",u),await d.executeLifecycle("beforeCommand",u);let l;const g=o.global;if(g?.help){const p=this.#n.get("help");if(!p)throw new C("Help command not found","COMMAND_NOT_FOUND");l=await z(p,u,o)}else if(g?.version??g?.V){const p=this.#n.get("version");if(!p)throw new C("Version command not found","COMMAND_NOT_FOUND");l=await z(p,u,o)}else l=await z(s,u,o);return await d.executeLifecycle("afterCommand",u,l),l}catch(l){throw await d.executeErrorHandlers(l,u),l}}}export{kr as Cli};
@@ -0,0 +1 @@
1
+ const O=1,T=2,E=4,I=16,R=32,U=64,_=128,S="positionals";export{O as OUTPUT_NORMAL,E as OUTPUT_PLAIN,T as OUTPUT_RAW,S as POSITIONALS_KEY,_ as VERBOSITY_DEBUG,R as VERBOSITY_NORMAL,I as VERBOSITY_QUIET,U as VERBOSITY_VERBOSE};