@visulima/cerebro 2.1.5 → 3.0.0-alpha.2
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.
- package/CHANGELOG.md +39 -0
- package/LICENSE.md +1649 -153
- package/README.md +28 -21
- package/dist/commands/readme-command.js +3 -3
- package/dist/index.js +1 -1
- package/dist/packem_shared/Cerebro-aPZjbfzf.js +4 -0
- package/dist/packem_shared/{VisulimaError--04oA1Oy.js → VisulimaError-BJideSBf.js} +2 -2
- package/package.json +9 -8
- package/dist/packem_shared/Cerebro-CQZ9sj4S.js +0 -4
package/README.md
CHANGED
|
@@ -1,26 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
<h3>Visulima Cerebro</h3>
|
|
3
|
-
<p>
|
|
4
|
-
Cerebro is a delightful toolkit for building cross-runtime command-line interfaces (CLIs) for Node.js, Deno, and Bun, built on top of
|
|
1
|
+
<!-- START_PACKAGE_OG_IMAGE_PLACEHOLDER -->
|
|
5
2
|
|
|
6
|
-
|
|
7
|
-
[@visulima/colorize](https://github.com/visulima/visulima/tree/main/packages/colorize),
|
|
8
|
-
[@visulima/command-line-args](https://github.com/visulima/visulima/tree/main/packages/command-line-args),
|
|
9
|
-
[@visulima/tabular](https://github.com/visulima/visulima/tree/main/packages/tabular) and
|
|
10
|
-
[fastest-levenshtein](https://github.com/ka-weihe/fastest-levenshtein)
|
|
3
|
+
<a href="https://www.anolilab.com/open-source" align="center">
|
|
11
4
|
|
|
12
|
-
<
|
|
5
|
+
<img src="__assets__/package-og.svg" alt="cerebro" />
|
|
13
6
|
|
|
14
|
-
|
|
7
|
+
</a>
|
|
15
8
|
|
|
16
|
-
|
|
17
|
-
|
|
9
|
+
<h3 align="center">A delightful toolkit for building cross-runtime CLIs for Node.js, Deno, and Bun.</h3>
|
|
10
|
+
|
|
11
|
+
<!-- END_PACKAGE_OG_IMAGE_PLACEHOLDER -->
|
|
18
12
|
|
|
19
13
|
<br />
|
|
20
14
|
|
|
21
15
|
<div align="center">
|
|
22
16
|
|
|
23
|
-
[![typescript-image]
|
|
17
|
+
[![typescript-image][typescript-badge]][typescript-url]
|
|
18
|
+
[![mit licence][license-badge]][license]
|
|
19
|
+
[![npm downloads][npm-downloads-badge]][npm-downloads]
|
|
20
|
+
[![Chat][chat-badge]][chat]
|
|
21
|
+
[![PRs Welcome][prs-welcome-badge]][prs-welcome]
|
|
24
22
|
|
|
25
23
|
</div>
|
|
26
24
|
|
|
@@ -428,14 +426,23 @@ If you would like to help take a look at the [list of issues](https://github.com
|
|
|
428
426
|
- [commander.js](https://github.com/tj/commander.js) - node.js command-line interfaces made easy
|
|
429
427
|
- [yargs](https://www.npmjs.com/package/yargs) - yargs the modern, pirate-themed successor to optimist.
|
|
430
428
|
|
|
429
|
+
## Made with ❤️ at Anolilab
|
|
430
|
+
|
|
431
|
+
This is an open source project and will always remain free to use. If you think it's cool, please star it 🌟. [Anolilab](https://www.anolilab.com/open-source) is a Development and AI Studio. Contact us at [hello@anolilab.com](mailto:hello@anolilab.com) if you need any help with these technologies or just want to say hi!
|
|
432
|
+
|
|
431
433
|
## License
|
|
432
434
|
|
|
433
|
-
The visulima package is open-sourced software licensed under the [MIT][license
|
|
435
|
+
The visulima package is open-sourced software licensed under the [MIT][license]
|
|
434
436
|
|
|
435
|
-
|
|
437
|
+
<!-- badges -->
|
|
436
438
|
|
|
437
|
-
[
|
|
438
|
-
[license
|
|
439
|
-
[
|
|
440
|
-
[npm-
|
|
441
|
-
[
|
|
439
|
+
[license-badge]: https://img.shields.io/npm/l/@visulima/cerebro?style=for-the-badge
|
|
440
|
+
[license]: https://github.com/visulima/visulima/blob/main/LICENSE
|
|
441
|
+
[npm-downloads-badge]: https://img.shields.io/npm/dm/@visulima/cerebro?style=for-the-badge
|
|
442
|
+
[npm-downloads]: https://www.npmjs.com/package/@visulima/cerebro
|
|
443
|
+
[prs-welcome-badge]: https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=for-the-badge
|
|
444
|
+
[prs-welcome]: https://github.com/visulima/visulima/blob/main/.github/CONTRIBUTING.md
|
|
445
|
+
[chat-badge]: https://img.shields.io/discord/932323359193186354.svg?style=for-the-badge
|
|
446
|
+
[chat]: https://discord.gg/TtFJY8xkFK
|
|
447
|
+
[typescript-badge]: https://img.shields.io/badge/Typescript-294E80.svg?style=for-the-badge&logo=typescript
|
|
448
|
+
[typescript-url]: https://www.typescriptlang.org/
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var
|
|
1
|
+
var O=Object.defineProperty;var f=(e,n)=>O(e,"name",{value:n,configurable:!0});import{createRequire as L}from"node:module";import G from"github-slugger";import{p as U}from"../packem_shared/index-DQ3pvLQH.js";import{g as F,a as M,b as W,c as z}from"../packem_shared/runtime-process-G-n-wOub.js";const N=L(import.meta.url),g=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,w=f(e=>{if(typeof g<"u"&&g.versions&&g.versions.node){const[n,t]=g.versions.node.split(".").map(Number);if(n>22||n===22&&t>=3||n===20&&t>=16)return g.getBuiltinModule(e)}return N(e)},"__cjs_getBuiltinModule"),{existsSync:E}=w("node:fs"),{readFile:T,mkdir:k,writeFile:B}=w("node:fs/promises"),{resolve:v,join:V,dirname:q}=w("node:path");var H=Object.defineProperty,d=f((e,n)=>H(e,"name",{value:n,configurable:!0}),"d");const I=new G,b=I.slug,J=d(e=>e.filter(Boolean),"compact"),K=d((e,n)=>{const t=new Set,a=[];for(const r of e){const i=n(r);t.has(i)||(t.add(i),a.push(r))}return a},"uniqBy"),D=d((e,n)=>{const t=(e.commandPath?[...e.commandPath,e.name]:[e.name]).join(" ");if(e.argument){const a=e.argument.name?.toUpperCase()??"ARG",r=e.argument.required?a:`[${a}]`;return`${n} ${t} ${r}`}return`${n} ${t}`},"formatCommandUsage"),Q=d((e,n)=>{if(!Array.isArray(e.env)||e.env.length===0)return;const t=e.env.filter(a=>!a.hidden);t.length>0&&n.push({content:t.map(a=>[a.name,a.description??""]),header:" Environment Variables "})},"addEnvironmentVariables"),X=d((e,n)=>{const t=[],a=(e.commandPath?[...e.commandPath,e.name]:[e.name]).join(" "),r=!!e.argument,i=!!e.options;if(t.push({content:`${n} ${a}${r?" [positional arguments]":""}${i?" [options]":""}`,header:" Usage "}),e.description&&t.push({content:e.description,header:" Description "}),e.argument&&t.push({header:"Command Positional Arguments",isArgument:!0,optionList:[e.argument]}),Array.isArray(e.options)&&e.options.length>0&&t.push({header:" Command Options ",optionList:e.options.filter(o=>typeof o=="object"&&o!==null&&(!("hidden"in o)||!o.hidden))}),Q(e,t),e.alias!==void 0&&e.alias.length>0){const o=Array.isArray(e.alias)?e.alias:[e.alias];t.splice(1,0,{content:o,header:"Alias(es)"})}return Array.isArray(e.examples)&&e.examples.length>0&&t.push({content:e.examples,header:"Examples"}),U(t)},"formatCommandHelp"),Y=d((e,n)=>{const t=e.description?.trim().split(`
|
|
2
2
|
`)[0]??"",a=D(e,n),r=X(e,n);return J([`## \`${a}\``,t,`\`\`\`
|
|
3
3
|
${r.trim()}
|
|
4
4
|
\`\`\``]).join(`
|
|
@@ -26,11 +26,11 @@ USAGE
|
|
|
26
26
|
`).replaceAll("\r",`
|
|
27
27
|
`),"normalizeLineEndings"),te=d(async e=>{const n=A(e);return(await Promise.all(n.split(`
|
|
28
28
|
`).filter(t=>t.startsWith("# ")).map(t=>t.trim().slice(2)).map(async t=>`* [${t}](#${await b(t)})`))).join(`
|
|
29
|
-
`)},"generateTableOfContents"),P=d(e=>e.replaceAll(/[.*+?^${}()|[\]\\]/g,String.raw`\$&`),"escapeRegex"),y=d((e,n,t)=>{const a=A(e),r=`<!-- ${n} -->`,i=`<!-- ${n}stop -->`;if(a.includes(r)&&a.includes(i)){const o=P(r),s=P(i),l=new RegExp(`${o}(
|
|
29
|
+
`)},"generateTableOfContents"),P=d(e=>e.replaceAll(/[.*+?^${}()|[\]\\]/g,String.raw`\$&`),"escapeRegex"),y=d((e,n,t)=>{const a=A(e),r=`<!-- ${n} -->`,i=`<!-- ${n}stop -->`;if(a.includes(r)&&a.includes(i)){const o=P(r),s=P(i),l=new RegExp(String.raw`${o}(.|\n)*${s}`,"m");return a.replace(l,`${r}
|
|
30
30
|
${t}
|
|
31
31
|
${i}`)}return a.replace(r,`${r}
|
|
32
32
|
${t}
|
|
33
|
-
${i}`)},"replaceTag"),se={description:"Generate README documentation for CLI commands",execute:d(async({logger:e,options:n,runtime:t})=>{const a=t.getCliName(),r=t.getPackageName()??a,i=t.getPackageVersion(),o=F().node??"unknown",s={aliases:n?.aliases,dryRun:n?.dryRun,multi:n?.multi,nestedTopicsDepth:n?.nestedTopicsDepth,outputDir:n?.outputDir??"docs",readmePath:n?.readmePath??"README.md",repositoryPrefix:n?.repositoryPrefix,version:n?.version??i??void 0},l=t.getCommands(),$=[...l.values()].filter(m=>!m.hidden).filter(m=>s.aliases?!0:m.name===l.get(m.name)?.name).toSorted((m,h)=>{const _=m.commandPath?[...m.commandPath,m.name].join(" "):m.name,
|
|
33
|
+
${i}`)},"replaceTag"),se={description:"Generate README documentation for CLI commands",execute:d(async({logger:e,options:n,runtime:t})=>{const a=t.getCliName(),r=t.getPackageName()??a,i=t.getPackageVersion(),o=F().node??"unknown",s={aliases:n?.aliases,dryRun:n?.dryRun,multi:n?.multi,nestedTopicsDepth:n?.nestedTopicsDepth,outputDir:n?.outputDir??"docs",readmePath:n?.readmePath??"README.md",repositoryPrefix:n?.repositoryPrefix,version:n?.version??i??void 0},l=t.getCommands(),$=[...l.values()].filter(m=>!m.hidden).filter(m=>s.aliases?!0:m.name===l.get(m.name)?.name).toSorted((m,h)=>{const _=m.commandPath?[...m.commandPath,m.name].join(" "):m.name,S=h.commandPath?[...h.commandPath,h.name].join(" "):h.name;return _.localeCompare(S)}),p=K($,m=>m.commandPath?[...m.commandPath,m.name].join(" "):m.name);e.debug(`Processing ${p.length} commands for README generation`);let c;const u=v(M(),s.readmePath??"README.md");if(E(u)){const m=await T(u,"utf8");c=A(m)}else e.warn(`README file not found at ${u}, creating template`),c=`# ${r}
|
|
34
34
|
|
|
35
35
|
<!-- usage -->
|
|
36
36
|
<!-- usagestop -->
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var t=Object.defineProperty;var o=(r,e)=>t(r,"name",{value:e,configurable:!0});import{Cli as a}from"./packem_shared/Cerebro-
|
|
1
|
+
var t=Object.defineProperty;var o=(r,e)=>t(r,"name",{value:e,configurable:!0});import{Cli as a}from"./packem_shared/Cerebro-aPZjbfzf.js";import{VERBOSITY_DEBUG as V,VERBOSITY_NORMAL as b,VERBOSITY_QUIET as c,VERBOSITY_VERBOSE as f}from"./packem_shared/VERBOSITY_QUIET-XPultrIA.js";import{p as I}from"./packem_shared/isVisulimaError-jVZgumOU-C4fgdbWg.js";var E=Object.defineProperty,O=o((r,e)=>E(r,"name",{value:e,configurable:!0}),"t");const p=O((r,e)=>new a(r,e),"createCerebro");export{a as Cerebro,V as VERBOSITY_DEBUG,b as VERBOSITY_NORMAL,c as VERBOSITY_QUIET,f as VERBOSITY_VERBOSE,I as VisulimaError,p as createCerebro};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
var It=Object.defineProperty;var $=(t,e)=>It(t,"name",{value:e,configurable:!0});import{createRequire as St}from"node:module";import{o as Vt,D as Tt}from"./help-command-CIRIXN03.js";import{VERBOSITY_DEBUG as W,POSITIONALS_KEY as te,VERBOSITY_QUIET as Rt,VERBOSITY_VERBOSE as Dt,VERBOSITY_NORMAL as Ne}from"./VERBOSITY_QUIET-XPultrIA.js";import{c as k}from"./cerebro-error-BnJTixb2.js";import{d as q,f as Ee,e as ie,o as xe,a as Bt,h as zt,i as Wt}from"./runtime-process-G-n-wOub.js";import{distance as Ft}from"fastest-levenshtein";const Ut=St(import.meta.url),Y=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Mt=$(t=>{if(typeof Y<"u"&&Y.versions&&Y.versions.node){const[e,n]=Y.versions.node.split(".").map(Number);if(e>22||e===22&&n>=3||e===20&&n>=16)return Y.getBuiltinModule(t)}return Ut(t)},"__cjs_getBuiltinModule"),{createRequire:qt}=Mt("node:module");var Gt=Object.defineProperty,Ht=$((t,e)=>Gt(t,"name",{value:e,configurable:!0}),"t$9");let D=class extends k{static{$(this,"a")}static{Ht(this,"CommandNotFoundError")}commandName;constructor(e,n=[]){const a=`Command "${e}" not found${n.length>0?`. Did you mean: ${n.join(", ")}?`:""}`;super(a,"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 Kt=Object.defineProperty,Yt=$((t,e)=>Kt(t,"name",{value:e,configurable:!0}),"e$6");let Qe=class extends k{static{$(this,"o")}static{Yt(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 Jt=Object.defineProperty,Qt=$((t,e)=>Jt(t,"name",{value:e,configurable:!0}),"e$5");let Zt=class extends k{static{$(this,"o")}static{Qt(this,"PluginError")}pluginName;constructor(e,n,a){super(`Plugin "${e}" error: ${n}`,"PLUGIN_ERROR",{originalError:a,pluginName:e}),this.name="PluginError",this.pluginName=e,a&&(this.cause=a)}};var Xt=Object.defineProperty,je=$((t,e)=>Xt(t,"name",{value:e,configurable:!0}),"d$6");let en=class{static{$(this,"p")}static{je(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`);q().CEREBRO_OUTPUT_LEVEL===String(W)&&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 ${n.length} plugin(s)...`);for(const a of n)if(typeof a.init=="function"){this.logger.debug(`initializing plugin: ${a.name}`);try{await a.init(e)}catch(o){const i=new Zt(a.name,`Failed to initialize: ${o instanceof Error?o.message:String(o)}`,o instanceof Error?o:void 0);throw this.logger.error(i.message),i}}this.initialized=!0}async executeLifecycle(e,n,a){if(!this.initialized)throw new Error("PluginManager not initialized");if(this.plugins.size===0)return;const o=this.getDependencyOrder();for(const i of o){const u=i[e];if(typeof u=="function"){this.logger.debug(`executing ${e} hook for plugin: ${i.name}`);try{await(e==="afterCommand"?u(n,a):u(n))}catch(s){throw this.logger.error(`Error in ${e} hook for plugin "${i.name}":`,s),s}}}}async executeErrorHandlers(e,n){if(!this.initialized||this.plugins.size===0)return;const a=this.getDependencyOrder();for(const o of a)if(typeof o.onError=="function"){this.logger.debug(`executing error handler for plugin: ${o.name}`);try{await o.onError(e,n)}catch(i){this.logger.error(`Error in error handler for plugin "${o.name}":`,i)}}}getDependencyOrder(){if(this.cachedDependencyOrder!==void 0)return this.cachedDependencyOrder;const e=[],n=new Set,a=new Set,o=je(i=>{if(n.has(i))return;if(a.has(i))throw new Error(`Circular dependency detected involving plugin "${i}"`);const u=this.plugins.get(i);if(!u)throw new Error(`Plugin "${i}" not found`);if(a.add(i),u.dependencies)for(const s of u.dependencies)o(s);a.delete(i),n.add(i),e.push(u)},"visit");for(const i of this.plugins.keys())o(i);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 tn=Object.defineProperty,nn=$((t,e)=>tn(t,"name",{value:e,configurable:!0}),"n$b");const X=nn(t=>t.type?.name==="Boolean","optionIsBoolean");var an=Object.defineProperty,Ze=$((t,e)=>an(t,"name",{value:e,configurable:!0}),"p$b");const rn=Ze(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"),on=Ze(t=>(X(t)||(t.typeLabel=t.typeLabel??rn(t),t.defaultOption&&(t.typeLabel=`${t.typeLabel} (D)`),t.required&&(t.typeLabel=`${t.typeLabel} (R)`)),t),"mapOptionTypeLabel");var sn=Object.defineProperty,Xe=$((t,e)=>sn(t,"name",{value:e,configurable:!0}),"e$3");const ln=new RegExp(/^-([^\d-])$/),cn=new RegExp(/^--(\S+)/),un=new RegExp(/^-([^\d-]{2,})$/),pn=Xe(t=>ln.test(t)||cn.test(t)||un.test(t),"isOption"),fn=Xe((t,e)=>{const n=e[0]&&pn(e[0])||e.length===0?null:e.shift()??null;if(!t.includes(n)){const a=new Error(`Command not recognised: ${n}`);throw a.command=n,a.name="INVALID_COMMAND",a}return{argv:e,command:n}},"commandLineCommands");var hn=Object.defineProperty,et=$((t,e)=>hn(t,"name",{value:e,configurable:!0}),"i$a"),dn=Object.defineProperty,tt=et((t,e)=>dn(t,"name",{value:e,configurable:!0}),"i"),mn=Object.defineProperty,nt=tt((t,e)=>mn(t,"name",{value:e,configurable:!0}),"s"),gn=Object.defineProperty,it=nt((t,e)=>gn(t,"name",{value:e,configurable:!0}),"i"),vn=Object.defineProperty,at=it((t,e)=>vn(t,"name",{value:e,configurable:!0}),"t");at(t=>t instanceof Error&&t.type==="VisulimaError","isVisulimaError");class re extends Error{static{$(this,"v")}static{et(this,"g")}static{tt(this,"p")}static{nt(this,"V")}static{it(this,"VisulimaError")}static{at(this,"VisulimaError")}loc;title;hint;type="VisulimaError";constructor({cause:e,hint:n,location:a,message:o,name:i,stack:u,title:s}){super(o,{cause:e}),this.title=s,this.name=i,this.stack=u??this.stack,this.loc=a,this.hint=n}setLocation(e){this.loc=e}setName(e){this.name=e}setMessage(e){this.message=e}setHint(e){this.hint=e}}var yn=Object.defineProperty,rt=$((t,e)=>yn(t,"name",{value:e,configurable:!0}),"o$b"),wn=Object.defineProperty,ot=rt((t,e)=>wn(t,"name",{value:e,configurable:!0}),"o"),bn=Object.defineProperty,$n=ot((t,e)=>bn(t,"name",{value:e,configurable:!0}),"i");let On=class st extends re{static{$(this,"a")}static{rt(this,"a")}static{ot(this,"t")}static{$n(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,st.prototype)}};var En=Object.defineProperty,lt=$((t,e)=>En(t,"name",{value:e,configurable:!0}),"t$7"),An=Object.defineProperty,ct=lt((t,e)=>An(t,"name",{value:e,configurable:!0}),"e"),Pn=Object.defineProperty,Cn=ct((t,e)=>Pn(t,"name",{value:e,configurable:!0}),"e");let _e=class ut extends re{static{$(this,"n")}static{lt(this,"n")}static{ct(this,"o")}static{Cn(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,ut.prototype)}};var kn=Object.defineProperty,pt=$((t,e)=>kn(t,"name",{value:e,configurable:!0}),"a$6"),Nn=Object.defineProperty,ft=pt((t,e)=>Nn(t,"name",{value:e,configurable:!0}),"a"),xn=Object.defineProperty,jn=ft((t,e)=>xn(t,"name",{value:e,configurable:!0}),"o");let _n=class ht extends re{static{$(this,"n")}static{pt(this,"o")}static{ft(this,"e")}static{jn(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,ht.prototype)}};var Ln=Object.defineProperty,dt=$((t,e)=>Ln(t,"name",{value:e,configurable:!0}),"i$7"),In=Object.defineProperty,mt=dt((t,e)=>In(t,"name",{value:e,configurable:!0}),"i"),Sn=Object.defineProperty,Un=mt((t,e)=>Sn(t,"name",{value:e,configurable:!0}),"i");let j=class gt extends re{static{$(this,"a")}static{dt(this,"o")}static{mt(this,"e")}static{Un(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,gt.prototype)}};var Mn=Object.defineProperty,Vn=$((t,e)=>Mn(t,"name",{value:e,configurable:!0}),"T$1"),Tn=Object.defineProperty,H=Vn((t,e)=>Tn(t,"name",{value:e,configurable:!0}),"P"),Rn=Object.defineProperty,oe=H((t,e)=>Rn(t,"name",{value:e,configurable:!0}),"o");const Le=oe(t=>t===Boolean||typeof t=="function"&&t.name?.startsWith("Boolean"),"isBooleanType"),Ie=oe(t=>t===Number||typeof t=="function"&&t.name==="Number","isNumberType"),Se=oe(t=>t===String||typeof t=="function"&&t.name==="String","isStringType"),Dn=oe((t,e)=>Array.isArray(t)?Le(e)?t.map(Boolean):Ie(e)?t.map(Number):Se(e)?t.map(String):t.map(n=>e(String(n))):t===null?null:Le(e)?!!t:Ie(e)?Number(t):Se(e)?String(t):e(String(t)),"convertValue");var Bn=Object.defineProperty,zn=H((t,e)=>Bn(t,"name",{value:e,configurable:!0}),"e");const x=zn((t,e,n,...a)=>{t&&console.debug(`[command-line-args:${n}] ${e}`,...a)},"debug");var Wn=Object.defineProperty,T=H((t,e)=>Wn(t,"name",{value:e,configurable:!0}),"A");const Fn=/-([a-z])/g,me=T(t=>t===Boolean||typeof t=="function"&&t.name?.startsWith("Boolean"),"isBooleanType"),qn=T(t=>t.codePointAt(0)===95,"isSpecialKey"),Ue=T((t,e)=>Array.isArray(t)?[...t,...e]:[t,...e],"appendToArrayMultiple"),Me=T(t=>t==="__proto__"||t==="constructor"||t==="prototype","isUnsafeKey"),Ve=T((t,e,n,a=!1)=>{t[e]===void 0?t[e]=a?[n]:n:a&&Array.isArray(t[e])?t[e].push(n):t[e]=[t[e],n]},"createOrAppendArray"),Gn=T((t,e,n,a,o)=>{let i=e.get(t)||n.get(t);if(!i&&a){const u=t.toLowerCase();i=a.get(u)||o?.get(u)}return i},"getDefinition"),Hn=T((t,e,n,a)=>{const o=n.debug||!1;x(o,"resolveArgs called with options:","resolver",{partial:n.partial,stopAtFirstUnknown:n.stopAtFirstUnknown}),x(o,"Starting argument resolution","resolver"),x(o,"Tokens:","resolver",t),x(o,"Definitions:","resolver",e),x(o,"Processing tokens...","resolver");const i=new Map,u=new Map,s=n.caseInsensitive?new Map:void 0,g=n.caseInsensitive?new Map:void 0,r=n.camelCase?new Map:void 0,p=n.camelCase?new Map:void 0;for(const f of e)if(i.set(f.name,f),f.alias&&u.set(f.alias,f),n.caseInsensitive&&s&&(s.set(f.name.toLowerCase(),f),f.alias&&g&&g.set(f.alias.toLowerCase(),f)),n.camelCase&&r&&p){const m=f.name.replaceAll(Fn,(v,y)=>y.toUpperCase());r.set(f.name,m),p.set(m,f.name)}const c={},l={},d=[],h=new Set;let O=!1;const b=e.find(f=>f.defaultOption),w=e.some(f=>f.group),P=e.some(f=>f.type===Number);for(let f=0;f<t.length;f++){const m=t[f];if(m.kind==="option-terminator"){c._unknown=a.slice(m.index),O=!0;break}if(m.kind==="option"&&m.name){let v=Gn(m.name,i,u,s,g);if(!v&&m.value===void 0&&P&&/^\d+$/.test(m.name)){const A=e.find(I=>I.type===Number);A&&(v=A,m.value=m.name,m.name=A.name)}const y=v?v.name:m.name,E=v&&v.multiple,N=v&&v.lazyMultiple;if(l[y]!==void 0&&!E&&!N&&!n.partial)throw new On(y);if(!v&&n.partial){const A=m.rawName||`--${m.name}${m.value!==void 0&&m.inlineValue?`=${m.value}`:""}`;d.push({index:m.index,value:A});continue}if(!v&&n.stopAtFirstUnknown){c._unknown=a.slice(m.index);break}if(!v&&!n.partial)throw new _e(m.name);if(m.value===void 0){const A=t[f+1],I=A&&A.kind==="option"&&!("name"in A)&&A.value!==void 0,L=A&&v&&!(v.type&&me(v.type))&&(A.kind==="positional"||I),Lt=v&&v.defaultOption&&!v.multiple&&!v.lazyMultiple;if(L&&(!v?.defaultOption||Lt))if(E){let S=f+1;const de=[];for(;S<t.length&&(t[S].kind==="positional"||t[S].kind==="option"&&!("name"in t[S])&&t[S].value!==void 0);)de.push(t[S].value),h.add(t[S].index),S++;l[y]=l[y]===void 0?de:Ue(l[y],de),f=S-1}else N?(Ve(l,y,A.value,!0),h.add(A.index),f++):(l[y]=A.value,h.add(A.index),f++);else v&&v.type&&me(v.type)?Ve(l,y,!0,E):l[y]=E?[]:null}else{let{value:A}=m;if(v&&v.type&&me(v.type))switch(A){case"":{if(n.partial)l._unknown||(l._unknown=[]),l._unknown.push(`${m.rawName||`--${m.name}`}${m.value?`=${m.value}`:""}`),A=!0;else throw new _e(m.name);break}case"false":{A=!1;break}case"true":{A=!0;break}default:A=!0}const I=A===void 0?[]:[A];if(E){let L=f+1;for(;L<t.length&&t[L].kind==="positional";)I.push(t[L].value),h.add(t[L].index),L++;f=L-1}l[y]===void 0?l[y]=E||N?I:A:E||N?l[y]=Ue(l[y],I):l[y]=A}}else if(m.kind==="positional"&&n.stopAtFirstUnknown&&!h.has(m.index)){x(o,`Found unconsumed positional token at index ${m.index}, stopping processing`,"resolver"),c._unknown=a.slice(m.index);break}}for(const[f,m]of Object.entries(l)){const v=i.get(f);v&&(v.multiple||v.lazyMultiple)&&!Array.isArray(m)&&(l[f]=[m])}if(b){const f=[],m=[];for(const v of t)v.kind==="positional"&&!h.has(v.index)&&(f.push(v.value),m.push(v));if(f.length>0){const v=l[b.name],y=b.multiple||b.lazyMultiple;v===void 0?y?(m.forEach(E=>h.add(E.index)),l[b.name]=f):(h.add(m[0].index),l[b.name]=f[0]):y&&(m.forEach(E=>h.add(E.index)),l[b.name]=Array.isArray(v)?[...f,...v]:[...f,v])}}if(!n.partial){for(const f of t)if(f.kind==="positional"&&!h.has(f.index))throw new _n(a[f.index])}if(n.partial&&!n.stopAtFirstUnknown){const f=[...d];if(l._unknown){const m=new Map;for(const[v,y]of a.entries())m.set(y,v);for(const v of l._unknown){const y=m.get(v);y!==void 0&&f.push({index:y,value:v})}}for(const m of t)m.kind==="positional"&&!h.has(m.index)&&f.push({index:m.index,value:a[m.index]});f.length>0&&(f.sort((m,v)=>m.index-v.index),c._unknown=f.map(m=>m.value))}if(n.stopAtFirstUnknown&&!O){const f=t.findIndex(y=>y.kind==="option"&&!i.has(y.name||"")&&!u.has(y.name||"")&&(!n.caseInsensitive||!s?.has(y.name?.toLowerCase()||"")&&!g?.has(y.name?.toLowerCase()||""))),m=t.findIndex(y=>y.kind==="positional"&&!h.has(y.index));let v=-1;if(f!==-1&&m!==-1?v=Math.min(f,m):f!==-1?v=f:m!==-1&&(v=m),v>=0){const y=t[v].index;c._unknown=a.slice(y)}}else d.length>0&&!n.partial&&(c._unknown=d.map(f=>f.value));for(const[f,m]of Object.entries(l)){const v=n.camelCase&&r?.get(f)||f,y=i.get(f);c[v]=y&&y.type?Dn(m,y.type):m===void 0?null:m}for(const f of e){const m=n.camelCase&&r?.get(f.name)||f.name;!(m in c)&&f.defaultValue!==void 0&&(f.multiple||f.lazyMultiple?c[m]=Array.isArray(f.defaultValue)?[...f.defaultValue]:[f.defaultValue]:c[m]=f.defaultValue)}if(w){const f={},m={},v={};for(const E of e)if(E.group){const N=Array.isArray(E.group)?E.group:[E.group];for(const A of N)Me(A)||f[A]||(f[A]={})}for(const E of Object.keys(c))if(!qn(E)){m[E]=c[E];let N=E;n.camelCase&&(N=p?.get(E)||E);const A=i.get(N);if(A&&A.group){const I=Array.isArray(A.group)?A.group:[A.group];for(const L of I)Me(L)||f[L]&&(f[L][E]=c[E])}else v[E]=c[E]}const y={_all:m};for(const[E,N]of Object.entries(f))y[E]=N;Object.keys(v).length>0&&(y._none=v),c._unknown&&(y._unknown=c._unknown),Object.keys(c).forEach(E=>delete c[E]),Object.assign(c,y)}return x(o,"Final parsed result:","resolver",c),c},"resolveArgs");var Kn=Object.defineProperty,R=H((t,e)=>Kn(t,"name",{value:e,configurable:!0}),"l");const V="-".codePointAt(0),M="=",Yn=M.codePointAt(0),Jn="--",Qn="-",Zn="--",vt=R(t=>t.length>2&&t.startsWith(Zn),"hasLongOptionPrefix"),Xn=R(t=>vt(t)&&!t.includes(M,3),"isLongOption"),ei=R(t=>vt(t)&&t.includes(M,3),"isLongOptionAndValue"),ti=R(t=>t!==void 0&&t.length>0&&t.codePointAt(0)!==V,"hasOptionValue"),ni=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"),ii=R(t=>!(t.length<=2||t.codePointAt(0)!==V||t.codePointAt(1)===V),"isShortOptionGroup"),ai=R(t=>{const e=[],n=[...t];let a=-1,o=0;for(;n.length>0;){const i=n.shift();if(i===void 0)break;const u=n[0];if(o>0?o--:a++,i===Jn){e.push({index:a,kind:"option-terminator"});const s=n.map((g,r)=>({index:a+r+1,kind:"positional",value:g}));e.push(...s),a+=n.length;break}if(ni(i)){const s=i.charAt(1);let g,r;o?(e.push({index:a,inlineValue:r,kind:"option",name:s,rawName:i,value:g}),o===1&&ti(u)&&(g=n.shift(),e.push({index:a,inlineValue:r,kind:"option",value:g}))):e.push({index:a,inlineValue:r,kind:"option",name:s,rawName:i,value:g}),g!==void 0&&++a;continue}if(ii(i)&&!i.includes(M)){const s=[];let g="",r=!1;for(let p=1;p<i.length;p++){const c=i.charAt(p);r?g+=c:c.codePointAt(0)===Yn?r=!0:s.push(`${Qn}${c}`)}if(r)if(s.length>0){const p=s.pop();s.push(`${p}=${g}`)}else s.push(g);n.unshift(...s),o=s.length;continue}if(Xn(i)){const s=i.slice(2);e.push({index:a,kind:"option",name:s,rawName:i});continue}if(ei(i)){const s=i.indexOf(M),g=i.slice(2,s),r=i.slice(s+1);e.push({index:a,inlineValue:!0,kind:"option",name:g,rawName:i,value:r});continue}if(i.length>2&&i.codePointAt(0)===V&&i.codePointAt(1)!==V&&i.includes(M)){const s=i.indexOf(M),g=i.charAt(1),r=i.slice(s+1);e.push({index:a,inlineValue:!0,kind:"option",name:g,rawName:i,value:r});continue}e.push({index:a,kind:"positional",value:i})}return e},"parseArgsTokens");var ri=Object.defineProperty,Pe=H((t,e)=>ri(t,"name",{value:e,configurable:!0}),"d");const oi=Pe(t=>t&&(t===Boolean||typeof t=="function"&&t.name?.startsWith("Boolean")),"isBooleanType"),si=Pe(t=>typeof t=="function","isValidCustomTypeFunction"),li=Pe((t,e,n)=>{const a=n?.debug||!1;x(a,"Validating definitions:","validation",t,"caseInsensitive:",e);const o=new Set,i=new Set,u=new Set,s=new Set;let g=0;for(const r of t){if(x(a,"Checking definition:","validation",r),!r.name)throw x(a,"Validation failed: name is required","validation"),new j("Invalid option definition: name is required");if(typeof r.name!="string")throw new j("Invalid option definition: name must be a string");if(r.name.trim()==="")throw new j("Invalid option definition: name cannot be empty");const p=e?r.name.toLowerCase():"";if(o.has(r.name)||e&&u.has(p))throw new j(`Invalid option definition: duplicate name '${r.name}'`);if(i.has(r.name)||e&&s.has(p))throw new j(`Invalid option definition: name '${r.name}' conflicts with an existing alias`);if(o.add(r.name),e&&u.add(p),r.alias!==void 0){if(typeof r.alias!="string")throw new j("Invalid option definition: alias must be a string");if(r.alias.length!==1)throw new j("Invalid option definition: alias must be a single character");if(/\d/.test(r.alias))throw new j("Invalid option definition: alias cannot be numeric");if(r.alias==="-")throw new j('Invalid option definition: alias cannot be "-"');const c=e?r.alias.toLowerCase():"";if(i.has(r.alias)||e&&s.has(c))throw new j(`Invalid option definition: duplicate alias '${r.alias}'`);if(o.has(r.alias)||e&&u.has(c))throw new j(`Invalid option definition: alias '${r.alias}' conflicts with an existing option name`);i.add(r.alias),e&&s.add(c)}if(r.defaultOption&&(g++,r.type!==void 0&&oi(r.type)))throw new j("Invalid option definition: defaultOption cannot be Boolean type");if(r.type!==void 0&&!(r.type===Boolean||r.type===Number||r.type===String||typeof r.type=="function"&&si(r.type)))throw new j("Invalid option definition: invalid type")}if(g>1)throw x(a,"Validation failed: multiple defaultOptions not allowed","validation"),new j("Invalid option definition: multiple defaultOptions not allowed");x(a,"Validation completed successfully","validation")},"validateDefinitions");var ci=Object.defineProperty,ui=H((t,e)=>ci(t,"name",{value:e,configurable:!0}),"O");const pi=ui((t,e={})=>{const n=e.debug||!1;x(n,"Starting command-line-args parsing","index"),x(n,"Options:","index",e);const a={...e};a.stopAtFirstUnknown&&(a.partial=!0);const o=Array.isArray(t)?t:[t];x(n,"Normalized definitions:","index",o),li(o,a.caseInsensitive,n?a:void 0);let{argv:i}=a;if(!i&&(i=process.argv.slice(2),process.execArgv?.length)){const r=new Set(process.execArgv);i=i.filter(p=>!r.has(p))}x(n,"Using argv:","index",i);let u=i;a.caseInsensitive&&i&&(u=i.map(r=>{if(r.startsWith("--")){const p=r.indexOf("="),c=(p===-1?r.slice(2):r.slice(2,p)).toLowerCase();return p===-1?`--${c}`:`--${c}${r.slice(p)}`}if(r.startsWith("-")&&!r.startsWith("--")&&r.length>1){const p=r.slice(1).split("=",2),c=p[0],l=p[1];if(!c)return r;const d=c.toLowerCase();return l===void 0?`-${d}`:`-${d}=${l}`}return r}));const s=ai((u??i??[]).map(String));x(n,"Tokenized arguments:","index",s);const g=Hn(s,o,a,i??[]);return x(n,"Command-line-args parsing completed","index"),g},"commandLineArgs");var fi=Object.defineProperty,hi=$((t,e)=>fi(t,"name",{value:e,configurable:!0}),"m$6");let di=class{static{$(this,"a")}static{hi(this,"EmptyToolbox")}result;argv;options;argument;command;commandName;env;logger;runtime;constructor(e,n){this.commandName=e,this.command=n}};var mi=Object.defineProperty,gi=$((t,e)=>mi(t,"name",{value:e,configurable:!0}),"f$4");const vi=/^-{1,2}(\w+)(=(.+))?$/,yt=gi((t,e,n,a)=>{const o=vi.exec(t);if(o==null)return{};const i=o[1];if(!i)return{};const u=n&&a?n.get(i)??a.get(i):e.find(s=>s.name===i||s.alias===i);return u!==void 0?{argName:u.name,argValue:o[3],option:u}:{}},"getParameterOption");var yi=Object.defineProperty,Ae=$((t,e)=>yi(t,"name",{value:e,configurable:!0}),"e$2");const Te=Ae((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"),wi=new Set(["0","1","false","true"]),bi=Ae((t,e,n,a)=>{if(e.length===0||t.length===0)return{};const o=Ae((i,u)=>{const{argName:s,argValue:g,option:r}=yt(u,e,n,a),{lastOption:p}=i;return r&&X(r)&&g&&s?i.partial[s]=Te(g,r):i.lastName&&p&&X(p)&&wi.has(u)&&(i.partial[i.lastName]=Te(u,p)),{lastName:s,lastOption:r,partial:i.partial}},"getBooleanValue");return t.reduce(o,{partial:{}}).partial},"getBooleanValues");var $i=Object.defineProperty,Re=$((t,e)=>$i(t,"name",{value:e,configurable:!0}),"s$8");const Oi=new Set(["0","1","false","true"]),Ei=Re((t,e,n,a)=>{if(e.length===0||t.length===0)return t;const o=Re((i,u)=>{const{argValue:s,option:g}=yt(u,e,n,a),{lastOption:r}=i;if(r&&X(r)&&Oi.has(u)){const{args:p}=i;return{args:p.slice(0,-1)}}return g&&X(g)&&s?{args:i.args}:{args:[...i.args,u],lastOption:g}},"removeBooleanArguments");return t.reduce(o,{args:[]}).args},"removeBooleanValues");var Ai=Object.defineProperty,Pi=$((t,e)=>Ai(t,"name",{value:e,configurable:!0}),"o$8");const De=Pi(t=>{const e=new Map;for(const n of t){const a=e.get(n.name);a?e.set(n.name,{...a,...n}):e.set(n.name,n)}return[...e.values()]},"mergeArguments");var Ci=Object.defineProperty,se=$((t,e)=>Ci(t,"name",{value:e,configurable:!0}),"o$7");const ki=se(t=>{if(t===void 0)return;const e=t.toLowerCase().trim();return e==="true"||e==="1"||e==="yes"||e==="on"},"transformBooleanEnv"),Ni=se((t,e)=>{if(!t.type)return e;if(e!==void 0){if(t.type===Boolean||typeof t.type=="function"&&t.type.name==="Boolean")return ki(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"),xi=se(t=>t.toLowerCase().replaceAll(/_./g,e=>e[1]?.toUpperCase()??e).replace(/^[A-Z]/,e=>e.toLowerCase()),"toCamelCase"),ji=se(t=>{if(!t||t.length===0)return{};const e={},n=q();for(const a of t){const o=n[a.name],i=Ni(a,o),u=i===void 0?a.defaultValue:i,s=xi(a.name);e[s]=u}return e},"processEnvVariables");var _i=Object.defineProperty,le=$((t,e)=>_i(t,"name",{value:e,configurable:!0}),"l$a");const Li=le(t=>{const e=new Map,n=new Map;for(const a of t)if(e.set(a.name,a),a.alias){const o=Array.isArray(a.alias)?a.alias:[a.alias];for(const i of o)n.set(i,a)}return{optionMapByAlias:n,optionMapByName:e}},"buildOptionMaps"),Ii=le((t,e,n,a)=>{const o=new di(t.name,t),{_all:i,positionals:u}=e,s=Object.keys(n).length>0?{...i,...n}:i;te in s&&delete s[te],o.argument=u?.[te]??[];const g=Object.keys(a).length>0;return o.options=g?{...s,...a}:s,o.env=ji(t.env),o},"prepareToolbox"),Si=le((t,e,n)=>{const a=t.options??[],o=a.length>0;let i=De(o?[...a,...n]:n);if(i.length>0){for(const r of i)if(r.multiple&&r.lazyMultiple)throw new Error(`Argument "${r.name}" cannot have both multiple and lazyMultiple options, please choose one.`)}t.argument&&(i=[{defaultOption:!0,description:t.argument?.description,group:"positionals",multiple:!0,name:te,type:t.argument?.type,typeLabel:t.argument?.typeLabel},...i]);let u,s;if(o){const{optionMapByAlias:r,optionMapByName:p}=Li(a);u=Ei(e,a,p,r),s=bi(e,a,p,r)}else u=e,s={};const g=pi(i,{argv:u,camelCase:!0,partial:!0,stopAtFirstUnknown:!0});return{arguments_:i,booleanValues:s,parsedArgs:g}},"processCommandArgs"),B=le(async(t,e,n)=>await t.execute(e),"executeCommand");var Ui=Object.defineProperty,Mi=$((t,e)=>Ui(t,"name",{value:e,configurable:!0}),"n$6");let Vi=class extends k{static{$(this,"s")}static{Mi(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 Ti=Object.defineProperty,Ri=$((t,e)=>Ti(t,"name",{value:e,configurable:!0}),"t$5");const Be=Ri((t,e,n=!1)=>{const a=[];for(const o of t)if(!(!n&&!o.required)&&e[o.name]===void 0){if(o.type?.name==="Boolean"){e[o.name]=!1;continue}a.push(o)}return a},"listMissingArguments");var Di=Object.defineProperty,wt=$((t,e)=>Di(t,"name",{value:e,configurable:!0}),"n$5");const Bi=wt((t,e)=>e.includes(t)?!0:Math.abs(t.length-e.length)>t.length/2?!1:Ft(t,e)<=t.length/3,"isSimilar"),F=wt((t,e)=>{const n=t.toLowerCase();return e.filter(a=>Bi(a.toLowerCase(),n))},"findAlternatives");var zi=Object.defineProperty,ce=$((t,e)=>zi(t,"name",{value:e,configurable:!0}),"a$2");const Wi=ce((t,e)=>{const n=[];if(t._unknown&&t._unknown.forEach(a=>{const o=a.startsWith("--");let i=`Found unknown ${o?"option":"argument"} "${a}"`;if(o){const u=F(a.replace("--",""),(e.options??[]).map(s=>s.name));if(u.length>0){const[s,...g]=u.map(r=>`--${r}`);i+=g.length>0?`, did you mean ${s} or ${g.join(", ")}?`:`, did you mean ${s}?`}}n.push(i)}),n.length>0)throw new Error(n.join(`
|
|
2
|
+
`))},"validateUnknownOptions"),Fi=ce((t,e,n)=>{const a=n.__requiredOptions__?Be(n.__requiredOptions__,e,!0):Be(t,e,!1);if(a.length>0)throw new Vi(n.name,a.map(o=>o.name));e._unknown&&e._unknown.length>0&&!n.argument&&Wi(e,n)},"validateRequiredOptions"),qi=ce((t,e,n)=>{const a=n.__conflictingOptions__??t.filter(o=>o.conflicts!==void 0);if(a.length>0){const o=a.find(i=>Array.isArray(i.conflicts)?i.conflicts.some(u=>e[u]!==void 0)&&e[i.name]!==void 0:e[i.conflicts]!==void 0&&e[i.name]!==void 0);if(o)throw new Qe(o.name,typeof o.conflicts=="string"?o.conflicts:o.conflicts?.[0]??"unknown")}},"validateConflictingOptions"),Gi=ce(t=>{if(!Array.isArray(t.options))return;const e=new Map,n=new Map;for(const o of t.options){if(o.name){const i=e.get(o.name)??[];i.push(o),e.set(o.name,i)}if(typeof o.alias=="string"&&o.alias.length>0){const i=n.get(o.alias)??[];i.push(o),n.set(o.alias,i)}else if(Array.isArray(o.alias)){for(const i of o.alias)if(i.length>0){const u=n.get(i)??[];u.push(o),n.set(i,u)}}}const a=[];for(const[o,i]of e)i.length>1&&a.push(`Duplicate option name "${o}" in command "${t.name}": ${JSON.stringify(i)}`);for(const[o,i]of n)i.length>1&&a.push(`Duplicate option alias "-${o}" used by options ${i.map(u=>`"${u.name}"`).join(", ")} in command "${t.name}"`);if(a.length>0)throw new Error(a.join(`
|
|
3
|
+
`))},"validateDuplicateOptions");var Hi=Object.defineProperty,Ce=$((t,e)=>Hi(t,"name",{value:e,configurable:!0}),"r$7");const Ki=Ce((t,e)=>{if(e.length===0)return{argv:[],commandPath:void 0};const n=[];for(let a=1;a<=e.length;a+=1){const o=e[a-1];if(o===void 0)break;n.push(o);const i=n.join(" ");if(t.has(i))return{argv:e.slice(a),commandPath:[...n]}}return{argv:e,commandPath:void 0}},"parseNestedCommand"),J=Ce(t=>t.join(" "),"getCommandPathKey"),Yi=Ce((t,e)=>e&&e.length>0?[...e,t]:[t],"getFullCommandPath");var Ji=Object.defineProperty,Qi=$((t,e)=>Ji(t,"name",{value:e,configurable:!0}),"p$4"),Zi=Object.defineProperty,bt=Qi((t,e)=>Zi(t,"name",{value:e,configurable:!0}),"e"),Xi=Object.defineProperty,ea=bt((t,e)=>Xi(t,"name",{value:e,configurable:!0}),"E");const $t=String.raw,ze=$t`\p{Emoji}(?:\p{EMod}|[\u{E0020}-\u{E007E}]+\u{E007F}|\uFE0F?\u20E3?)`,ta=ea(()=>new RegExp($t`\p{RI}{2}|(?)${ze}(?:\u200D${ze})*`,"gu"),"default");var na=Object.defineProperty,ia=bt((t,e)=>na(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 G=ta(),aa=/[-_./\s]+/g,Z=/(\u001B\[[0-9;]*[a-z])/i,We=new RegExp("\\p{Script=Arabic}","u"),ra=new RegExp("\\p{Script=Bengali}","u"),z=new RegExp("\\p{Script=Cyrillic}","u"),oa=new RegExp("\\p{Script=Devanagari}","u"),sa=new RegExp("\\p{Script=Ethiopic}","u"),ge=new RegExp("\\p{Script=Greek}","u"),la=new RegExp("\\p{Script=Greek}+|\\p{Script=Latin}+|[^\\p{Script=Greek}\\p{Script=Latin}]+","gu"),ca=new RegExp("\\p{Script=Gujarati}","u"),ua=new RegExp("\\p{Script=Gurmukhi}","u"),Fe=new RegExp("\\p{Script=Hangul}","u"),qe=new RegExp("\\p{Script=Hebrew}","u"),pa=new RegExp("\\p{Script=Hiragana}","u"),Ge=new RegExp("\\p{Script=Han}","u"),fa=new RegExp("\\p{Script=Kannada}","u"),ha=new RegExp("\\p{Script=Katakana}","u"),da=new RegExp("\\p{Script=Khmer}","u"),ma=new RegExp("\\p{Script=Lao}","u"),_=new RegExp("\\p{Script=Latin}","u"),ga=new RegExp("\\p{Script=Malayalam}","u"),va=new RegExp("\\p{Script=Myanmar}","u"),ya=new RegExp("\\p{Script=Oriya}","u"),wa=new RegExp("\\p{Script=Sinhala}","u"),ba=new RegExp("\\p{Script=Tamil}","u"),$a=new RegExp("\\p{Script=Telugu}","u"),Oa=new RegExp("\\p{Script=Thai}","u"),Ea=new RegExp("\\p{Script=Tibetan}","u"),He=/[\u02BB\u02BC\u0027]/u,Aa=ia(t=>t.replace(G,""),"stripEmoji");var Pa=Object.defineProperty,Ot=$((t,e)=>Pa(t,"name",{value:e,configurable:!0}),"i$6"),Ca=Object.defineProperty,Et=Ot((t,e)=>Ca(t,"name",{value:e,configurable:!0}),"r"),ka=Object.defineProperty,Na=Et((t,e)=>ka(t,"name",{value:e,configurable:!0}),"c");let At=class{static{$(this,"l")}static{Ot(this,"y")}static{Et(this,"s")}static{Na(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(a=>a!==e);else if(this.cache.size>=this.capacity){const a=this.keyOrder.shift();a!==void 0&&this.cache.delete(a)}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 xa=Object.defineProperty,ja=$((t,e)=>xa(t,"name",{value:e,configurable:!0}),"r$5"),_a=Object.defineProperty,La=ja((t,e)=>_a(t,"name",{value:e,configurable:!0}),"a"),Ia=Object.defineProperty,Sa=La((t,e)=>Ia(t,"name",{value:e,configurable:!0}),"s");const Ua=Sa((t,e)=>typeof t!="string"||t===""?"":(e?.locale?t[0].toLocaleLowerCase(e.locale):t[0].toLowerCase())+t.slice(1),"lowerFirst");var Ma=Object.defineProperty,Va=$((t,e)=>Ma(t,"name",{value:e,configurable:!0}),"I"),Ta=Object.defineProperty,ue=Va((t,e)=>Ta(t,"name",{value:e,configurable:!0}),"j");const Ra=qt(import.meta.url),Q=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Da=ue(t=>{if(typeof Q<"u"&&Q.versions&&Q.versions.node){const[e,n]=Q.versions.node.split(".").map(Number);if(e>22||e===22&&n>=3||e===20&&n>=16)return Q.getBuiltinModule(t)}return Ra(t)},"__cjs_getBuiltinModule"),{stripVTControlCharacters:Ba}=Da("node:util");var za=Object.defineProperty,Wa=ue((t,e)=>za(t,"name",{value:e,configurable:!0}),"g");const ve=new At(1e3),Fa=Wa(t=>{const e=t.join("");if(ve.has(e))return ve.get(e);const n=t.map(o=>o.replaceAll(/[.*+?^${}()|[\]\\]/g,String.raw`\$&`)).join("|"),a=new RegExp(n,"g");return ve.set(e,a),a},"getSeparatorsRegex");var qa=Object.defineProperty,Ga=ue((t,e)=>qa(t,"name",{value:e,configurable:!0}),"t");const Ha=Ga(t=>{const e=[];let n=0,a;for(G.lastIndex=0;(a=G.exec(t))!==null;)a.index>n&&e.push(t.slice(n,a.index)),e.push(a[0]),n=G.lastIndex;return n<t.length&&e.push(t.slice(n)),e.filter(Boolean)},"splitByEmoji");var Ka=Object.defineProperty,C=ue((t,e)=>Ka(t,"name",{value:e,configurable:!0}),"u");const Pt=new Uint8Array(128),Ct=new Uint8Array(128),kt=new Uint8Array(128);for(let t=0;t<128;t++)Pt[t]=t>=65&&t<=90?1:0,Ct[t]=t>=97&&t<=122?1:0,kt[t]=t>=48&&t<=57?1:0;const ye=C(t=>Pt[t],"isUpper"),Ke=C(t=>Ct[t],"isLower"),we=C(t=>kt[t],"isDigit"),U=C((t,e,n,a,o)=>{if(t.length===0)return[];let i=!1;for(const c of Object.values(e))if(c(t[0])){i=!0;break}if(!i&&!n)return[t];const u=[...t],s=[];let g=u[0],r="other";for(const[c,l]of Object.entries(e))if(l(u[0])){r=c;break}let p=n&&a?u[0]===u[0].toLocaleUpperCase(a):!1;for(let c=1;c<u.length;c++){const l=u[c];let d="other";for(const[b,w]of Object.entries(e))if(w(l)){d=b;break}const h=n&&a?l===l.toLocaleUpperCase(a):!1;let O=!1;o?O=o(r,d,p,h,l,c,u):(r!==d&&r!=="other"&&d!=="other"&&(O=!0),n&&d!=="other"&&!p&&h&&(O=!0)),O?(s.push(g),g=l):g+=l,r=d,n&&(p=h)}return g&&g.length>0&&s.push(g),s.length>0?s:[t]},"handleScriptTransitions"),Ya=C((t,e,n,a)=>{if(n.size===0)return e;for(const o of n)if(t.startsWith(o,e))return a.push(o),e+o.length;return e},"detectAndProcessAcronym"),Nt=C((t,e=new Set)=>{if(t.length===0)return[];if(t.toUpperCase()===t)return[t];let n=0;const a=[],o=t.length;for(let i=1;i<o;i++){const u=Ya(t,n,e,a);if(u!==n){n=u,i=n-1;continue}const s=t.codePointAt(i-1),g=t.codePointAt(i),r=s&&s<128&&ye(s),p=g&&g<128&&ye(g),c=s&&s<128&&Ke(s),l=s&&s<128&&we(s),d=g&&g<128&&we(g);if(c&&p){a.push(t.slice(n,i)),n=i;continue}if(l&&!d||!l&&d){a.push(t.slice(n,i)),n=i;continue}if(d&&!l){let h=!1,O=!1;if(i+1<o){const b=t.codePointAt(i+1);h=b&&b<128&&ye(b),O=b&&b<128&&we(b)}if(!O&&h){a.push(t.slice(n,i),t.slice(i,i+1)),n=i+1;continue}}if(i+1<o){const h=t.codePointAt(i+1),O=h&&h<128&&Ke(h);if(r&&p&&O){const b=t.slice(n,i+1);e.has(b)||(a.push(t.slice(n,i)),n=i)}}}return n<o&&a.push(t.slice(n)),a.filter(i=>i!=="")},"splitCamelCaseFast"),xt=C((t,e,n)=>{if(t.length===0)return[];const a=t===t.toLocaleUpperCase(e);if(e.startsWith("de")){if(!a&&t.replaceAll("ß","SS")===t.toLocaleUpperCase(e))return[t];const r=[...t],p=r.length,c=[];let l=r[0],d=r[0]===r[0].toLocaleUpperCase(e),h=d,O=d?0:-1;for(let b=1;b<p;b++){const w=r[b],P=w===w.toLocaleUpperCase(e);if(P===d)l+=w;else if(P)l&&l.length>0&&(c.push(l),l=w),h=!0,O=b;else{if(h&&b-O>1){const f=r[b-1],m=l.slice(0,-1);m&&m.length>0&&c.push(m),l=f+w}else l+=w;h=!1,O=-1}d=P}return l&&l.length>0&&c.push(l),c}if(e.startsWith("uk")||e.startsWith("ru")||e.startsWith("bg")||e.startsWith("sr")||e.startsWith("mk")||e.startsWith("be")){if(!z.test(t)&&!_.test(t))return[t];const r=[...t],p=r.length,c=[];let l=r[0];const d=r[0];let h;z.test(d)?h=1:_.test(d)?h=2:h=0;let O=d===d.toLocaleUpperCase(e);for(let w=1;w<p;w++){const P=r[w];let f;z.test(P)?f=1:_.test(P)?f=2:f=0;const m=P===P.toLocaleUpperCase(e);h!==f&&(h===1||h===2)&&(f===1||f===2)||f===h&&!O&&m?(c.push(l),l=P):l+=P,h=f,O=m}l&&l.length>0&&c.push(l);const b=[];for(let w=0;w<c.length;w++)w<c.length-1&&c[w].length===1&&_.test(c[w])&&z.test(c[w+1][0])?(b.push(c[w]+c[w+1]),w+=1):b.push(c[w]);return b}if(e.startsWith("el")){if(!ge.test(t)&&!_.test(t))return[t];const r=t.match(la)??[t],p=[];if(r.length===1){const c=r[0];if(!c||!ge.test(c[0])||c.length===1)return[c||t]}for(const c of r){if(!c)continue;if(!ge.test(c[0])||c.length===1){p.push(c);continue}const l=c.length;let d=c[0],h=c[0]===c[0].toLocaleUpperCase(e);for(let O=1;O<l;O++){const b=c[O],w=b===b.toLocaleUpperCase(e);!h&&w?(p.push(d),d=b):d+=b,h=w}d&&p.push(d)}return p}if(e.startsWith("ja")||e.startsWith("ko")){const r=e.startsWith("ja"),p=r?{hiragana:C(l=>pa.test(l),"hiragana"),kanji:C(l=>Ge.test(l),"kanji"),katakana:C(l=>ha.test(l),"katakana"),latin:C(l=>_.test(l),"latin")}:{hangul:C(l=>Fe.test(l),"hangul"),latin:C(l=>_.test(l),"latin")},c=new Set(["が","で","と","に","の","は","へ","も","や","を"]);if(r){const l=U(t,p,!1,e,(h,O)=>h==="hiragana"&&O==="katakana"||h==="katakana"&&O==="hiragana"||h==="hiragana"&&O==="latin"||h==="katakana"&&O==="latin"||h==="kanji"&&O==="latin"||h==="latin"&&(O==="hiragana"||O==="katakana"||O==="kanji")),d=[];for(const h of l)h.length===1&&c.has(h)&&d.length>0?d[d.length-1]+=h:d.push(h);return d.length>0?d:[t]}return U(t,p,!1,e,(l,d)=>l==="hangul"&&d==="latin"||l==="latin"&&d==="hangul")}if(e.startsWith("sl")){const r=[...t],p=r.length,c=[];let l=r[0],d=r[0]===r[0].toLocaleUpperCase(e);for(let h=1;h<p;h++){const O=r[h],b=O===O.toLocaleUpperCase(e),w=/[ČŠŽĐ]/i.test(O),P=h<p-1&&r[h+1]===r[h+1].toLocaleUpperCase(e);!d&&b||w&&P?(c.push(l),l=O,w&&P&&(c.push(l),l="")):l+=O,d=b}return l&&l.length>0&&c.push(l),c}if(e.startsWith("zh"))return U(t,{han:C(r=>Ge.test(r),"han"),latin:C(r=>_.test(r),"latin")},!1,e);if(["ar","fa","he","ur"].includes(e.split("-")[0])){const r=C(p=>qe.test(p)||We.test(p),"isRtlChar");return U(t,{latin:C(p=>_.test(p),"latin"),rtl:C(p=>r(p),"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 r=C(p=>oa.test(p)||ra.test(p)||ca.test(p)||ua.test(p)||fa.test(p)||ba.test(p)||$a.test(p)||ga.test(p)||wa.test(p)||Oa.test(p)||ma.test(p)||Ea.test(p)||va.test(p)||sa.test(p)||da.test(p)||ya.test(p),"isIndicChar");return U(t,{indic:C(p=>r(p),"indic"),latin:C(p=>_.test(p),"latin")},!1,e)}if(["be","bg","ru","sr","uk"].includes(e))return U(t,{cyrillic:C(r=>z.test(r),"cyrillic"),latin:C(r=>_.test(r),"latin")},!0,e);if(["ar","fa","he"].includes(e))return U(t,{latin:C(r=>_.test(r),"latin"),rtl:C(r=>qe.test(r)||We.test(r),"rtl")},!1,e);if(e.startsWith("ko"))return U(t,{hangul:C(r=>Fe.test(r),"hangul"),latin:C(r=>_.test(r),"latin")},!1,e);if(e.startsWith("uz")){if(!z.test(t)&&!_.test(t))return[t];const r=[...t],p=r.length,c=[];let l=r[0],d=r[0]===r[0].toLocaleUpperCase(e);for(let h=1;h<p;h++){const O=r[h],b=O===O.toLocaleUpperCase(e);if(He.test(O)||He.test(r[h-1])){l+=O;continue}!d&&b?(c.push(l),l=O):l+=O,d=b}return l&&l.length>0&&c.push(l),c}const o=[...t],i=o.length,u=[];let s=o[0],g=o[0]===o[0].toLocaleUpperCase(e);for(const r of n)if(t.startsWith(r)){u.push(r),s=o[r.length],g=s===s.toLocaleUpperCase(e);break}for(let r=1;r<i;r++){const p=o[r],c=p===p.toLocaleUpperCase(e);let l=0;for(const d of n)if(t.startsWith(d,r)){u.push(s,d),l=d.length,s="";const h=d[d.length-1];h&&(g=h===h.toLocaleUpperCase(e));break}if(l>0){r+=l-1;continue}!g&&c?(u.push(s),s=p):s+=p,g=c}return s&&u.push(s),u},"splitCamelCaseLocale"),Ja=C((t,e,n)=>{const a=[],o=Z.test(t)?t.split(Z).filter(Boolean):[t];for(const i of o)if(Z.test(i))a.push(i);else{const u=G.test(i)?Ha(i).filter(Boolean):[i];for(const s of u)if(G.test(s))a.push(s);else if(e){const g=e.toLowerCase().split("-")[0];a.push(...xt(s,g,n))}else a.push(...Nt(s,n))}return a},"processTextWithAnsiEmoji"),Qa=C((t,e={})=>{if(!t||typeof t!="string")return[];const{handleAnsi:n=!1,handleEmoji:a=!1,knownAcronyms:o=[],locale:i,normalize:u=!1,separators:s,stripAnsi:g=!1,stripEmoji:r=!1}=e,p=new Set([...o].toSorted((w,P)=>P.length-w.length));let c=t;g&&(c=Ba(c)),r&&(c=Aa(c));let l;Array.isArray(s)?l=Fa(s):s instanceof RegExp?l=s:l=aa;const d=[];let h=c;const O=l.flags.includes("g")?l:new RegExp(l.source,`${l.flags}g`);for(;h.length>0;){const w=O.exec(h);if(!w){h===".."?d.push(".."):h==="."?d.push("."):h.length>0&&d.push(h);break}const P=w.index,f=w[0],m=f.length,v=h.slice(0,P),y=h.slice(P+m);if(f.startsWith("../"))d.push(".."),h=h.slice(P+3);else if(f.startsWith("./"))d.push("."),h=h.slice(P+2);else if(P===0&&f==="..")d.push(".."),h=h.slice(2);else if(P===0&&f===".")d.push("."),h=h.slice(1);else{v.length>0&&d.push(v);let E=0;for(;(E=f.indexOf("../",E))!==-1;)d.push(".."),E+=3;for(E=0;(E=f.indexOf("./",E))!==-1;)(E===0||f[E-1]!==".")&&d.push("."),E+=2;let N=y;for(;N.startsWith("../");)d.push(".."),N=N.slice(3);for(;N.startsWith("./");)d.push("."),N=N.slice(2);if(N===".."){d.push("..");break}else if(N==="."){d.push(".");break}else h=N}O.lastIndex=0}if(d.length===0){const w=c.split(l).filter(Boolean);d.push(...w)}let b=[];for(const w of d)n||a?b.push(...Ja(w,i,p)):i?b.push(...xt(w,i,p)):b.push(...Nt(w,p));return u&&(b=b.map(w=>p.has(w)?w:i&&w===w.toLocaleUpperCase(i)?w[0]+w.slice(1).toLocaleLowerCase(i):w.toUpperCase()===w&&!p.has(w)?w.slice(0,1)+w.slice(1).toLowerCase():w)),b},"splitByCase");var Za=Object.defineProperty,Xa=$((t,e)=>Za(t,"name",{value:e,configurable:!0}),"r$4"),er=Object.defineProperty,tr=Xa((t,e)=>er(t,"name",{value:e,configurable:!0}),"o"),nr=Object.defineProperty,ir=tr((t,e)=>nr(t,"name",{value:e,configurable:!0}),"s");const ar=ir((t,e)=>typeof t!="string"||t===""?"":(e?.locale?t[0].toLocaleUpperCase(e.locale):t[0].toUpperCase())+t.slice(1),"upperFirst");var rr=Object.defineProperty,or=$((t,e)=>rr(t,"name",{value:e,configurable:!0}),"r$3"),sr=Object.defineProperty,lr=or((t,e)=>sr(t,"name",{value:e,configurable:!0}),"r"),cr=Object.defineProperty,ur=lr((t,e)=>cr(t,"name",{value:e,configurable:!0}),"n");const pr=ur((t,e)=>`${t}::${e?.joiner??""}::${e?.locale??""}::${e?.knownAcronyms?.join(",")??""}::${e?.normalize?"true":"false"}`,"generateCacheKey");var fr=Object.defineProperty,hr=$((t,e)=>fr(t,"name",{value:e,configurable:!0}),"i$4"),dr=Object.defineProperty,mr=hr((t,e)=>dr(t,"name",{value:e,configurable:!0}),"a"),gr=Object.defineProperty,vr=mr((t,e)=>gr(t,"name",{value:e,configurable:!0}),"l");const yr=vr((t,e)=>{const{length:n}=t;if(n===0)return"";if(n===1)return t[0];const a=[];let o="",i="";for(let u=0;u<n;u++){const s=t[u];if(Z.test(s)){o?(a.push(o+i+s),o="",i=""):(a.length>0&&a.push(e),o=s);continue}o?(i&&(i+=e),i+=s):(a.length>0&&a.push(e),a.push(s))}return a.join("")},"joinSegments");var wr=Object.defineProperty,br=$((t,e)=>wr(t,"name",{value:e,configurable:!0}),"r$2"),$r=Object.defineProperty,Or=br((t,e)=>$r(t,"name",{value:e,configurable:!0}),"a"),Er=Object.defineProperty,Ar=Or((t,e)=>Er(t,"name",{value:e,configurable:!0}),"t");const Pr=Ar(t=>t.replaceAll(/(?<![a-zß])SS(?![a-z])/g,"ß"),"normalizeGermanEszett");var Cr=Object.defineProperty,kr=$((t,e)=>Cr(t,"name",{value:e,configurable:!0}),"l$2"),Nr=Object.defineProperty,xr=kr((t,e)=>Nr(t,"name",{value:e,configurable:!0}),"n"),jr=Object.defineProperty,_r=xr((t,e)=>jr(t,"name",{value:e,configurable:!0}),"l");const Lr=new At(1e3),jt=_r((t,e)=>{if(typeof t!="string"||!t)return"";const n=e?.cache??!1,a=e?.cacheStore??Lr;let o;if(n&&(o=pr(t,e)),n&&o&&a.has(o))return a.get(o);let i=!0;const u=yr(Qa(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=>e?.handleAnsi&&Z.test(s)?s:(s=e?.locale?.startsWith("de")?Pr(s):s,s=e?.locale?s.toLocaleLowerCase(e.locale):s.toLowerCase(),i?(i=!1,Ua(s,e)):ar(s,e))),"");return n&&o&&a.set(o,u),u},"camelCase");var Ir=Object.defineProperty,pe=$((t,e)=>Ir(t,"name",{value:e,configurable:!0}),"a");const Sr=pe(t=>{t.options?.forEach(e=>{e.__camelCaseName__=jt(e.name)})},"processOptionNames"),Ur=pe(t=>{if(!Array.isArray(t.options)||t.options.length===0)return;const e=new Set;for(const a of t.options)e.add(a.name);const n=[];for(const a of t.options)if(a.name.startsWith("no-")){const o=a.name.replace("no-","");if(!e.has(o)){if(a.type!==Boolean)throw new Error(`Cannot add negated option "${a.name}" to command "${t.name}" because it is not a boolean.`);const i={...a,defaultValue:a.defaultValue===void 0?!0:!a.defaultValue,name:o};n.push(i),e.add(o)}}n.length>0&&t.options.push(...n)},"addNegatableOptions"),Mr=pe((t,e)=>{if(!e.options||e.options.length===0)return;const n=t.options,a=new Map;for(const i of e.options)if(i.name.startsWith("no-")){const u=jt(i.name);a.set(u,i)}const o=Object.keys(n).filter(i=>a.has(i));if(o.length!==0)for(const i of o){const u=i.charAt(2);if(!u)continue;const s=u.toLowerCase()+i.slice(3),g=a.get(i);g&&(g.__negated__=!0),n[s]=!n[i],Reflect.deleteProperty(n,i)}},"mapNegatableOptions"),Vr=pe((t,e)=>{if(!e.options||e.options.length===0)return;const n=new Map;for(const o of e.options)o.__camelCaseName__&&o.__negated__===void 0&&o.implies!==void 0&&n.set(o.__camelCaseName__,o);if(n.size===0)return;const a=t.options;for(const o of Object.keys(a)){const i=n.get(o);if(i?.implies){const u=i.implies;for(const[s,g]of Object.entries(u))a[s]===void 0&&(a[s]=g)}}},"mapImpliedOptions");var Tr=Object.defineProperty,fe=$((t,e)=>Tr(t,"name",{value:e,configurable:!0}),"e$1");const Rr=fe(()=>!!process.versions.electron,"isElectronApp"),Dr=fe(()=>Rr()&&!process.defaultApp,"isBundledElectronApp"),Br=fe(()=>Dr()?0:1,"getProcessArgvBinIndex"),zr=fe(t=>t.slice(Br()+1),"hideBin");var Wr=Object.defineProperty,_t=$((t,e)=>Wr(t,"name",{value:e,configurable:!0}),"s$2");const Fr=" ",qr=_t((t,e)=>t===e?!0:t.length!==e.length?!1:t.every((n,a)=>n===e[a]),"equals"),Gr=_t(t=>{if(typeof t=="string")return t.split(Fr);const e=Ee();return qr(t,e)?zr(t):t},"parseRawCommand");var Hr=Object.defineProperty,be=$((t,e)=>Hr(t,"name",{value:e,configurable:!0}),"r");const Kr=be(t=>{const e=be(i=>{t.error(`Uncaught exception: ${i.message||i}`),i.stack&&t.error(i.stack),ie(1)},"uncaughtExceptionHandler"),n=be((i,u)=>{if(i instanceof Error)t.error(`Promise rejection: ${i.message||i}`),i.stack&&t.error(i.stack);else{let s;if(typeof i=="string")s=i;else try{s=JSON.stringify(i)}catch{s=String(i)}t.error(`Promise rejection: ${s}`)}ie(1)},"unhandledRejectionHandler"),a=xe("uncaughtException",e),o=xe("unhandledRejection",n);return()=>{a(),o()}},"registerExceptionHandler");var Yr=Object.defineProperty,K=$((t,e)=>Yr(t,"name",{value:e,configurable:!0}),"e");const ae=100,ke=K((t,e)=>{if(typeof t!="string"||t.trim().length===0)throw new k(`${e} must be a non-empty string`,"INVALID_INPUT",{fieldName:e,value:t});return t.trim()},"validateNonEmptyString"),Ye=K((t,e)=>{if(!Array.isArray(t)||!t.every(n=>typeof n=="string"))throw new k(`${e} must be an array of strings`,"INVALID_INPUT",{fieldName:e,value:t});return t},"validateStringArray");K((t,e)=>{if(typeof t!="function")throw new k(`${e} must be a function`,"INVALID_INPUT",{fieldName:e,value:t});return t},"validateFunction");const $e=K((t,e)=>{if(typeof t!="object"||t===null)throw new k(`${e} must be an object`,"INVALID_INPUT",{fieldName:e,value:t});return t},"validateObject"),ee=K(t=>{const e=ke(t,"Command name");if(e.length>ae)throw new k(`Command name is too long (maximum ${ae} characters)`,"INVALID_COMMAND_NAME",{commandName:e,length:e.length});if(e.includes("..")||e.includes("/")||e.includes("\\")||e.includes(";")||e.includes("|")||e.includes("&"))throw new k(`Command name "${e}" contains invalid characters`,"INVALID_COMMAND_NAME",{commandName:e});if(!/^[a-z][\w-]*$/i.test(e))throw new k(`Command name "${e}" must start with a letter and contain only letters, numbers, hyphens, and underscores`,"INVALID_COMMAND_NAME",{commandName:e});return e},"validateCommandName");K(t=>{const e=ke(t,"Plugin name");if(e.length>ae)throw new k(`Plugin name is too long (maximum ${ae} characters)`,"INVALID_PLUGIN_NAME",{length:e.length,pluginName:e});if(e.includes("..")||e.includes("/")||e.includes("\\")||e.includes(";")||e.includes("|")||e.includes("&"))throw new k(`Plugin name "${e}" contains invalid characters`,"INVALID_PLUGIN_NAME",{pluginName:e});if(!/^[a-z][\w-]*$/i.test(e))throw new k(`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 Jr=Object.defineProperty,he=$((t,e)=>Jr(t,"name",{value:e,configurable:!0}),"s");const Qr=new Set([`
|
|
4
|
+
`,"\r"," ","\0",'"',"$","&","'","(",")",";","<",">","[","\\","]","`","{","|","}"]),Zr=he(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 10000 characters)");for(const e of t)if(Qr.has(e))throw new Error(`Argument contains dangerous character: ${e}`);return t.trim()},"sanitizeArgument"),Je=he(t=>{if(!Array.isArray(t))throw new TypeError("Arguments must be an array");if(t.length>100)throw new Error("Too many arguments (maximum 100)");return t.map(e=>Zr(e))},"sanitizeArguments");he(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("/")||/^[A-Z]:/i.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 yo{static{$(this,"RateLimiter")}static{he(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(),a=this.attempts.get(e);return!a||n>a.resetTime?(this.attempts.set(e,{count:1,resetTime:n+this.windowMs}),this.cleanup(n),!0):a.count>=this.maxAttempts?!1:(a.count+=1,!0)}reset(e){this.attempts.delete(e)}cleanup(e){for(const[n,a]of this.attempts.entries())e>a.resetTime&&this.attempts.delete(n)}}var Xr=Object.defineProperty,ne=$((t,e)=>Xr(t,"name",{value:e,configurable:!0}),"_");const eo=/^-([^\d-])$/,to=/^--(\S+)/,no=/^-([^\d-]{2,})$/,Oe=ne(t=>eo.test(t)||to.test(t)||no.test(t),"isOption");class wo{static{$(this,"Cli")}static{ne(this,"Cli")}#t;#e;#r;#c;#g;#u;#v;#o;#n;#i;#p;#s;#l;#f=!1;#y;#w=!1;#h;#d;#m;#E(){return this.#h===void 0&&(this.#h=[...this.#i.keys()]),this.#h}#b(){return this.#d===void 0&&(this.#d=[...this.#n.keys()]),this.#d}#a(){return this.#m===void 0&&(this.#m=[...this.#E(),...this.#b()]),this.#m}#A(){this.#h=void 0,this.#d=void 0,this.#m=void 0}#$(){if(this.#r===void 0){const e=Gr(this.#e.argv);this.#r=Je(e),this.#P()}return this.#r}#P(){if(!this.#r)return;const e=q();let n=!1;for(const a of this.#r){if(a==="--quiet"||a==="-q"){e.CEREBRO_OUTPUT_LEVEL=String(Rt),n=!0;break}if(a==="--verbose"||a==="-v"){e.CEREBRO_OUTPUT_LEVEL=String(Dt),n=!0;break}if(a==="--debug"||a==="-vvv"){e.CEREBRO_OUTPUT_LEVEL=String(W),n=!0;break}}n||(e.CEREBRO_OUTPUT_LEVEL=Object.hasOwn(e,"DEBUG")?String(W):String(Ne))}#C(){this.#w||(this.#y=Kr(this.#t),this.#w=!0)}#O(e,n,a,o){this.#t.debug(`command '${o}' found, parsing command args: ${n.join(", ")}`);const{arguments_:i,booleanValues:u,parsedArgs:s}=Si(e,n,Vt),g=Object.keys(u).length>0?{...s,_all:{...s._all,...u}}:s;Fi(i,g,e);const r=Ii(e,s,u,a);r.runtime=this,r.argv=this.#$();const p=e.options&&e.options.length>0;if(p&&e.options){const c=e.options.filter(l=>l.name.startsWith("no-"));for(const l of c){const d=l.name.replace("no-",""),h=`--${l.name}`,O=`--${d}`,b=n.includes(h),w=n.includes(O);if(b&&w)throw new Qe(d,l.name)}}return p&&(Mr(r,e),Vr(r,e)),qi(i,r.options,e),q().CEREBRO_OUTPUT_LEVEL===String(W)&&(this.#t.debug("command options parsed from options:"),this.#t.debug(JSON.stringify(r.options,null,2)),this.#t.debug("command argument parsed from argument:"),this.#t.debug(JSON.stringify(r.argument,null,2))),{arguments_:i,booleanValues:u,commandArgs:g,parsedArgs:s,toolbox:r}}constructor(e,n={}){if(typeof e!="string"||e.trim().length===0)throw new k("CLI name must be a non-empty string","INVALID_INPUT",{cliName:e});this.#g=e.trim();const a=n.argv??Ee(),o=n.cwd??Bt();if(this.#e={...n,argv:a,cwd:o},this.#e.argv&&!Array.isArray(this.#e.argv))throw new k("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 k("CLI cwd option must be a string","INVALID_INPUT",{cwd:this.#e.cwd});if(this.#e.packageName&&typeof this.#e.packageName!="string")throw new k("CLI packageName option must be a string","INVALID_INPUT",{packageName:this.#e.packageName});if(this.#e.packageVersion&&typeof this.#e.packageVersion!="string")throw new k("CLI packageVersion option must be a string","INVALID_INPUT",{packageVersion:this.#e.packageVersion});const i=q();if(i.CEREBRO_OUTPUT_LEVEL=String(Ne),typeof this.#e.logger=="object"){const u=["debug","error","info","log","warn"],s=[],g=this.#e.logger;for(const r of u)typeof g[r]!="function"&&s.push(r);if(s.length>0)throw new k(`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:ne((...u)=>{i.CEREBRO_OUTPUT_LEVEL===String(W)&&console.debug(...u)},"debug")};this.#u=this.#e.packageVersion,this.#v=this.#e.packageName,this.#c=this.#e.cwd,this.#s="help",this.#l={},this.#n=new Map,this.#i=new Map,this.#p=new Map}setCommandSection(e){return this.#l=e,this}getCommandSection(){return this.#l.header||(this.#l.header=`${this.#g}${this.#u?` v${this.#u}`:""}`),this.#l}setDefaultCommand(e){return this.#s=e,this}get defaultCommand(){return this.#s}addCommand(e){$e(e,"Command"),ee(e.name),e.alias&&(typeof e.alias=="string"?ee(e.alias):Ye(e.alias,"Command alias").forEach(o=>ee(o))),e.argument&&$e(e.argument,"Command argument"),e.options&&$e(e.options,"Command options"),e.commandPath&&(Ye(e.commandPath,"Command commandPath"),e.commandPath.forEach(o=>{ee(o)}));const n=Yi(e.name,e.commandPath),a=J(n);if(this.#i.has(a))throw new k(`Command with path "${a}" already exists`,"DUPLICATE_COMMAND",{commandName:e.name,commandPath:e.commandPath});if(this.#n.has(e.name)&&!e.commandPath)throw new k(`Command with name "${e.name}" already exists`,"DUPLICATE_COMMAND",{commandName:e.name});if(e.options)for(const o of e.options)on(o);if(Gi(e),Ur(e),Sr(e),e.options&&(e.__conflictingOptions__=e.options.filter(o=>o.conflicts!==void 0),e.__requiredOptions__=e.options.filter(o=>o.required===!0)),this.#n.set(e.name,e),this.#i.set(a,n),this.#p.set(a,e),this.#A(),e.alias!==void 0){const o=typeof e.alias=="string"?[e.alias]:e.alias;for(const i of o){if(q().CEREBRO_OUTPUT_LEVEL===String(W)&&this.#t.debug("adding alias",i),this.#n.has(i))throw new k(`Command alias "${i}" conflicts with existing command`,"DUPLICATE_COMMAND",{alias:i,commandName:e.name});this.#n.set(i,e)}}return this}addPlugin(e){return this.getPluginManager().register(e),this}getPluginManager(){return this.#o?this.#o:(this.#o=new en(this.#t),this.#o.register({description:"Attaches the logger to the toolbox",execute:ne(e=>{e.logger=this.#t},"execute"),name:"logger"}),this.#o)}getCliName(){return this.#g}getPackageVersion(){return this.#u}getPackageName(){return this.#v}getCommands(){return this.#n}getCwd(){return this.#c}dispose(){this.#y?.()}async run(e={}){const{autoDispose:n=!0,shouldExitProcess:a=!0,...o}=e;this.#n.has("help")||this.addCommand(new Tt(this.#n));const i=this.#b(),u=this.#i;this.#C();const s=this.#$();let g,r=[...s];const p=zt(),c=Wt(),l=Ee();this.#t.debug(`process.execPath: ${p}`),this.#t.debug(`process.execArgv: ${c.join(" ")}`),this.#t.debug(`process.argv: ${l.join(" ")}`);const d=Ki(u,[...s]);if(d.commandPath)g=d.commandPath,r=d.argv;else{if(s.length>1&&s[0]&&s[1]&&!Oe(s[0])&&!Oe(s[1])){const y=[];let E=0;for(;E<s.length;){const A=s[E];if(!A||Oe(A))break;y.push(A),E+=1}const N=J(y);if(y[0]&&!i.includes(y[0])){const A=this.#a(),I=F(N,A);throw new D(N,I)}}let v;try{v=fn([null,...i],[...s])}catch(y){if(y instanceof Error&&y.name==="INVALID_COMMAND"&&"command"in y){const E=y.command,N=this.#a(),A=F(E,N);throw new D(E,A)}throw y}v.command&&(g=[v.command],r=v.argv)}if(!g)if(this.#s)g=[this.#s];else{const v=this.#a();throw new D("",v)}const h=J(g),O=this.#i.get(h);let b;if(O){if(b=this.#p.get(h),!b||J(O)!==h){const v=this.#a(),y=F(h,v);throw new D(h,y)}}else{const v=g[g.length-1];if(b=v?this.#n.get(v):void 0,!b){const y=this.#a(),E=F(h,y);throw new D(h,E)}}if(typeof b.execute!="function")return this.#t.error(`Command "${b.name}" has no function to execute.`),a?ie(1):void 0;const w=r,{commandArgs:P,toolbox:f}=this.#O(b,w,o,h),m=this.getPluginManager();try{!this.#f&&m.hasPlugins()&&(await m.init({cli:this,cwd:this.#c,logger:this.#t}),this.#f=!0),await m.executeLifecycle("execute",f),await m.executeLifecycle("beforeCommand",f);let v;if(P.global?.help){const y=this.#n.get("help");if(!y)throw new k("Help command not found","COMMAND_NOT_FOUND");v=await B(y,f,P)}else if(P.global?.version||P.global?.V){const y=this.#n.get("version");if(!y)throw new k("Version command not found","COMMAND_NOT_FOUND");v=await B(y,f,P)}else v=await B(b,f,P);return await m.executeLifecycle("afterCommand",f,v),a?ie(0):void 0}catch(v){throw await m.executeErrorHandlers(v,f),v}finally{n&&this.dispose()}}async runCommand(e,n={}){const{argv:a=[],...o}=n;ke(e,"Command name");const i=e.split(" ").filter(Boolean),u=J(i),s=this.#i.get(u)?this.#p.get(u):this.#n.get(e);if(!s){const l=this.#a(),d=F(u||e,l);throw new D(e,d)}if(typeof s.execute!="function")throw new k(`Command "${s.name}" has no function to execute`,"INVALID_COMMAND",{commandName:s.name});const g=[...Je(a)];this.#t.debug(`running command '${e}' programmatically with args: ${g.join(", ")}`);const{commandArgs:r,toolbox:p}=this.#O(s,g,o,u||e),c=this.getPluginManager();try{!this.#f&&c.hasPlugins()&&(await c.init({cli:this,cwd:this.#c,logger:this.#t}),this.#f=!0),await c.executeLifecycle("execute",p),await c.executeLifecycle("beforeCommand",p);let l;if(r.global?.help){const d=this.#n.get("help");if(!d)throw new k("Help command not found","COMMAND_NOT_FOUND");l=await B(d,p,r)}else if(r.global?.version||r.global?.V){const d=this.#n.get("version");if(!d)throw new k("Version command not found","COMMAND_NOT_FOUND");l=await B(d,p,r)}else l=await B(s,p,r);return await c.executeLifecycle("afterCommand",p,l),l}catch(l){throw await c.executeErrorHandlers(l,p),l}}}export{wo as Cli};
|
|
@@ -29,7 +29,7 @@ Exception class:
|
|
|
29
29
|
${r.name}
|
|
30
30
|
|
|
31
31
|
Exception message:
|
|
32
|
-
${r.message}`,"aiPrompt");var ie=Object.defineProperty,se=s((e,r)=>ie(e,"name",{value:r,configurable:!0}),"o$
|
|
32
|
+
${r.message}`,"aiPrompt");var ie=Object.defineProperty,se=s((e,r)=>ie(e,"name",{value:r,configurable:!0}),"o$5"),ue=Object.defineProperty,ce=se((e,r)=>ue(e,"name",{value:r,configurable:!0}),"i"),le=Object.defineProperty,C=ce((e,r)=>le(e,"name",{value:r,configurable:!0}),"i");const T=C((e,r,t)=>{const n=t.indexOf(e);if(n===-1)return"";const o=n+e.length,a=t.indexOf(r,o);return a===-1?"":t.slice(o,a).trim()},"between"),xr=C(e=>{const r=T("FIX","ENDFIX",e);if(!r)return["No solution found.",'Provide this response to the Maintainer of <a href="https://github.com/visulima/visulima/issues/new?assignees=&labels=s%3A+pending+triage%2Cc%3A+bug&projects=&template=bug_report.yml" target="_blank" rel="noopener noreferrer" class="text-blue-500 hover:underline inline-flex items-center text-sm">@visulima/error</a>.',`"${e}"`].join("</br></br>");const t=T("LINKS","ENDLINKS",e).split(`
|
|
33
33
|
`).map(n=>JSON.parse(n));return`${r.replaceAll(/"([^"]*)"(\s|\.)/g,"<code>$1</code> ")}
|
|
34
34
|
|
|
35
35
|
## Links
|
|
@@ -72,5 +72,5 @@ ${o.match.md}`).join(`
|
|
|
72
72
|
|
|
73
73
|
---
|
|
74
74
|
|
|
75
|
-
`);return n===""?void 0:{body:n,header:"### Potential fixes detected"}}catch{return}},"handle"),name:"ruleBasedHints",priority:0};var Pe=Object.defineProperty,xe=s((e,r)=>Pe(e,"name",{value:r,configurable:!0}),"a$
|
|
75
|
+
`);return n===""?void 0:{body:n,header:"### Potential fixes detected"}}catch{return}},"handle"),name:"ruleBasedHints",priority:0};var Pe=Object.defineProperty,xe=s((e,r)=>Pe(e,"name",{value:r,configurable:!0}),"a$4"),ke=Object.defineProperty,we=xe((e,r)=>ke(e,"name",{value:r,configurable:!0}),"a"),Ne=Object.defineProperty,Ae=we((e,r)=>Ne(e,"name",{value:r,configurable:!0}),"e");const Nr=Ae(()=>{if(!Error.captureStackTrace)return;const e=new Error;return Error.captureStackTrace(e),e.stack},"captureRawStackTrace");var Te=Object.defineProperty,_=s((e,r)=>Te(e,"name",{value:r,configurable:!0}),"r"),Ie=Object.defineProperty,D=_((e,r)=>Ie(e,"name",{value:r,configurable:!0}),"o"),Ce=Object.defineProperty,_e=D((e,r)=>Ce(e,"name",{value:r,configurable:!0}),"e");function d(e){if(typeof e!="object"||e===null)return!1;const r=Object.getPrototypeOf(e);return(r===null||r===Object.prototype||Object.getPrototypeOf(r)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}s(d,"o$2");_(d,"i");D(d,"r");_e(d,"isPlainObject");var De=Object.defineProperty,Je=s((e,r)=>De(e,"name",{value:r,configurable:!0}),"E$1"),Le=Object.defineProperty,Re=Je((e,r)=>Le(e,"name",{value:r,configurable:!0}),"E"),Fe=Object.defineProperty,j=Re((e,r)=>Fe(e,"name",{value:r,configurable:!0}),"n");const y=new Map([["Error",Error],["EvalError",EvalError],["RangeError",RangeError],["ReferenceError",ReferenceError],["SyntaxError",SyntaxError],["TypeError",TypeError],["URIError",URIError]]);typeof AggregateError<"u"&&y.set("AggregateError",AggregateError);const Ar=j((e,r)=>{let t;try{t=new e}catch(o){throw new Error(`The error constructor "${e.name}" is not compatible`,{cause:o})}const n=r??t.name;if(y.has(n))throw new Error(`The error constructor "${n}" is already known.`);y.set(n,e)},"addKnownErrorConstructor");j(()=>new Map(y),"getKnownErrorConstructors");const J=j(e=>y.get(e),"getErrorConstructor"),k=j(e=>e!==null&&typeof e=="object"&&typeof e.name=="string"&&typeof e.message=="string"&&(J(e.name)!==void 0||e.name==="Error"),"isErrorLike");var Me=Object.defineProperty,L=s((e,r)=>Me(e,"name",{value:r,configurable:!0}),"t$1"),Ve=Object.defineProperty,R=L((e,r)=>Ve(e,"name",{value:r,configurable:!0}),"t"),Ue=Object.defineProperty,qe=R((e,r)=>Ue(e,"name",{value:r,configurable:!0}),"s");let p=class extends Error{static{s(this,"i")}static{L(this,"c")}static{R(this,"e")}static{qe(this,"NonError")}constructor(r){super(r),this.name="NonError"}};var ze=Object.defineProperty,Be=s((e,r)=>ze(e,"name",{value:r,configurable:!0}),"d$1"),Ke=Object.defineProperty,Ye=Be((e,r)=>Ke(e,"name",{value:r,configurable:!0}),"d"),He=Object.defineProperty,c=Ye((e,r)=>He(e,"name",{value:r,configurable:!0}),"o");const Xe={maxDepth:Number.POSITIVE_INFINITY},F=c((e,r,t=0)=>k(e)?w(e,r,t):r.maxDepth!==void 0&&t>=r.maxDepth?new p(JSON.stringify(e)):new p(JSON.stringify(e)),"deserializePlainObject"),We=c((e,r,t,n,o)=>{const a=r.map(i=>S(i,n,o+1));return new e(a,t)},"reconstructAggregateError"),w=c((e,r,t)=>{if(r.maxDepth!==void 0&&t>=r.maxDepth)return new p(JSON.stringify(e));const{cause:n,errors:o,message:a,name:i,stack:m,...E}=e,N=J(i)||Error,l=i==="AggregateError"&&Array.isArray(o)?We(N,o,a,r,t):new N(a);return!l.name&&i&&(l.name=i),a!==void 0&&(l.message=a),m&&(l.stack=m),Ge(l,E,n,i,r,t),n!==void 0&&(l.cause=S(n,r,t+1)),Qe(l,e),l},"reconstructError"),S=c((e,r,t)=>d(e)?F(e,r,t):Array.isArray(e)?e.map(n=>S(n,r,t)):e,"deserializeValue"),Ge=c((e,r,t,n,o,a)=>{const i=e;for(const[m,E]of Object.entries(r))if(!(m==="cause"&&t!==void 0)){if(m==="errors"&&n==="AggregateError")continue;i[m]=S(E,o,a+1)}},"restoreErrorProperties"),Qe=c((e,r)=>{const t=new Set(["message","name","stack"]);for(const n of Object.keys(r))t.add(n);for(const n of t)if(n in e){const o=Object.getOwnPropertyDescriptor(e,n);o&&!o.enumerable&&Object.defineProperty(e,n,{...o,enumerable:!0})}},"makePropertiesEnumerable"),I=c(e=>new p(JSON.stringify(e)),"handlePrimitive"),Ze=c(e=>new p(JSON.stringify(e)),"handleArray"),er=c((e,r)=>k(e)?w(e,r,0):F(e,r),"handlePlainObject"),Ir=c((e,r={})=>{const t={...Xe,...r};return e instanceof Error?e:e===null?I(null):typeof e=="string"||typeof e=="number"||typeof e=="boolean"?I(e):Array.isArray(e)?Ze(e):k(e)?w(e,t,0):d(e)?er(e,t):new p(JSON.stringify(e))},"deserialize");var rr=Object.defineProperty,tr=s((e,r)=>rr(e,"name",{value:r,configurable:!0}),"a"),nr=Object.defineProperty,M=tr((e,r)=>nr(e,"name",{value:r,configurable:!0}),"n");const or=Y(import.meta.url),b=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,ar=M(e=>{if(typeof b<"u"&&b.versions&&b.versions.node){const[r,t]=b.versions.node.split(".").map(Number);if(r>22||r===22&&t>=3||r===20&&t>=16)return b.getBuiltinModule(e)}return or(e)},"__cjs_getBuiltinModule"),{inspect:ir}=ar("node:util");var sr=Object.defineProperty,ur=M((e,r)=>sr(e,"name",{value:r,configurable:!0}),"a");const Cr=ur(e=>{const r=new Set,t=[];let n=e;for(;n;){if(r.has(n)){console.error(`Circular reference detected in error causes: ${ir(e)}`);break}if(t.push(n),r.add(n),!n.cause)break;n=n.cause}return t},"getErrorCauses");var cr=Object.defineProperty,lr=s((e,r)=>cr(e,"name",{value:r,configurable:!0}),"l"),fr=Object.defineProperty,mr=lr((e,r)=>fr(e,"name",{value:r,configurable:!0}),"f");const pr=Object.create({},{cause:{enumerable:!0,value:void 0,writable:!0},code:{enumerable:!0,value:void 0,writable:!0},errors:{enumerable:!0,value:void 0,writable:!0},message:{enumerable:!0,value:void 0,writable:!0},name:{enumerable:!0,value:void 0,writable:!0},stack:{enumerable:!0,value:void 0,writable:!0}});var dr=Object.defineProperty,O=mr((e,r)=>dr(e,"name",{value:r,configurable:!0}),"c");const P=new WeakSet,gr=O(e=>{P.add(e);const r=e.toJSON();return P.delete(e),r},"toJSON"),V=O((e,r,t,n)=>{if(e&&e instanceof Uint8Array&&e.constructor.name==="Buffer")return"[object Buffer]";if(e!==null&&typeof e=="object"&&typeof e.pipe=="function")return"[object Stream]";if(e instanceof Error)return r.includes(e)?"[Circular]":(t+=1,$(e,n,r,t));if(n.useToJSON&&typeof e.toJSON=="function")return e.toJSON();if(typeof e=="object"&&e instanceof Date)return e.toISOString();if(typeof e=="function")return`[Function: ${e.name||"anonymous"}]`;if(d(e)){if(t+=1,n.maxDepth&&t>=n.maxDepth)return{};const o={};for(const a in e)o[a]=V(e[a],r,t,n);return o}try{return e}catch{return"[Not Available]"}},"serializeValue"),$=O((e,r,t,n)=>{if(t.push(e),r.maxDepth===0)return{};if(r.useToJSON&&typeof e.toJSON=="function"&&!P.has(e))return gr(e);const o=Object.create(pr);if(o.name=Object.prototype.toString.call(e.constructor)==="[object Function]"?e.constructor.name:e.name,o.message=e.message,o.stack=e.stack,Array.isArray(e.errors)){const a=[];for(const i of e.errors){if(!(i instanceof Error))throw new TypeError("All errors in the 'errors' property must be instances of Error");if(t.includes(i))return o.errors=[],o;a.push($(i,r,t,n))}o.errors=a}e.cause instanceof Error&&!t.includes(e.cause)&&(o.cause=$(e.cause,r,t,n));for(const a in e)if(o[a]===void 0){const i=e[a];o[a]=V(i,t,n,r)}if(Array.isArray(r.exclude)&&r.exclude.length>0)for(const a of r.exclude)try{delete o[a]}catch{}return o},"_serialize"),_r=O((e,r={})=>$(e,{exclude:r.exclude??[],maxDepth:r.maxDepth??Number.POSITIVE_INFINITY,useToJSON:r.useToJSON??!1},[],0),"serialize");var br=Object.defineProperty,yr=s((e,r)=>br(e,"name",{value:r,configurable:!0}),"o"),hr=Object.defineProperty,vr=yr((e,r)=>hr(e,"name",{value:r,configurable:!0}),"n"),$r=Object.defineProperty,U=vr((e,r)=>$r(e,"name",{value:r,configurable:!0}),"s");const jr=U(e=>{const r=e.methodName&&e.methodName!=="<unknown>"?`${e.methodName} `:"",t=e.file??"<unknown>",n=e.line??0,o=e.column??0;return r.trim()?` at ${r}(${t}:${n}:${o})`:` at ${t}:${n}:${o}`},"formatStackFrameLine"),Dr=U((e,r)=>{const t=[];if(r?.header&&(r.header.name||r.header.message)){const n=String(r.header.name||"Error"),o=String(r.header.message||"");t.push(`${n}${o?": ":""}${o}`)}for(const n of e)t.push(jr(n));return t.join(`
|
|
76
76
|
`)},"formatStacktrace");export{Rr as CODE_FRAME_POINTER,p as NonError,qr as VisulimaError,Ar as addKnownErrorConstructor,Pr as aiPrompt,xr as aiSolutionResponse,Nr as captureRawStackTrace,Fr as codeFrame,Ir as deserializeError,kr as errorHintFinder,jr as formatStackFrameLine,Dr as formatStacktrace,Cr as getErrorCauses,Er as indexToLineColumn,k as isErrorLike,zr as isVisulimaError,Mr as parseStacktrace,Vr as renderError,wr as ruleBasedFinder,_r as serializeError};
|
package/package.json
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@visulima/cerebro",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0-alpha.2",
|
|
4
4
|
"description": "A delightful toolkit for building cross-runtime CLIs for Node.js, Deno, and Bun.",
|
|
5
5
|
"keywords": [
|
|
6
|
+
"visulima",
|
|
6
7
|
"command",
|
|
7
8
|
"line",
|
|
8
9
|
"class",
|
|
@@ -37,7 +38,7 @@
|
|
|
37
38
|
"repository": {
|
|
38
39
|
"type": "git",
|
|
39
40
|
"url": "git+https://github.com/visulima/visulima.git",
|
|
40
|
-
"directory": "packages/cerebro"
|
|
41
|
+
"directory": "packages/terminal/cerebro"
|
|
41
42
|
},
|
|
42
43
|
"funding": [
|
|
43
44
|
{
|
|
@@ -102,15 +103,15 @@
|
|
|
102
103
|
"LICENSE.md"
|
|
103
104
|
],
|
|
104
105
|
"dependencies": {
|
|
105
|
-
"@visulima/colorize": "
|
|
106
|
-
"@visulima/tabular": "
|
|
106
|
+
"@visulima/colorize": "2.0.0-alpha.2",
|
|
107
|
+
"@visulima/tabular": "4.0.0-alpha.2",
|
|
107
108
|
"fastest-levenshtein": "^1.0.16"
|
|
108
109
|
},
|
|
109
110
|
"peerDependencies": {
|
|
110
111
|
"@bomb.sh/tab": "^0.0.7",
|
|
111
|
-
"@visulima/boxen": "
|
|
112
|
-
"@visulima/find-cache-dir": "
|
|
113
|
-
"@visulima/pail": "
|
|
112
|
+
"@visulima/boxen": "3.0.0-alpha.2",
|
|
113
|
+
"@visulima/find-cache-dir": "3.0.0-alpha.1",
|
|
114
|
+
"@visulima/pail": "4.0.0-alpha.2",
|
|
114
115
|
"github-slugger": "2.0.0"
|
|
115
116
|
},
|
|
116
117
|
"peerDependenciesMeta": {
|
|
@@ -131,7 +132,7 @@
|
|
|
131
132
|
}
|
|
132
133
|
},
|
|
133
134
|
"engines": {
|
|
134
|
-
"node": ">=
|
|
135
|
+
"node": ">=22.13 <=25.x"
|
|
135
136
|
},
|
|
136
137
|
"os": [
|
|
137
138
|
"darwin",
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
var It=Object.defineProperty;var b=(t,e)=>It(t,"name",{value:e,configurable:!0});import{createRequire as St}from"node:module";import{o as Vt,D as Tt}from"./help-command-CIRIXN03.js";import{VERBOSITY_DEBUG as W,POSITIONALS_KEY as te,VERBOSITY_QUIET as Rt,VERBOSITY_VERBOSE as Dt,VERBOSITY_NORMAL as Ne}from"./VERBOSITY_QUIET-XPultrIA.js";import{c as P}from"./cerebro-error-BnJTixb2.js";import{d as q,f as Ae,e as ie,o as je,a as Bt,h as zt,i as Wt}from"./runtime-process-G-n-wOub.js";import{distance as Ft}from"fastest-levenshtein";const Ut=St(import.meta.url),Y=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Mt=b(t=>{if(typeof Y<"u"&&Y.versions&&Y.versions.node){const[e,n]=Y.versions.node.split(".").map(Number);if(e>22||e===22&&n>=3||e===20&&n>=16)return Y.getBuiltinModule(t)}return Ut(t)},"__cjs_getBuiltinModule"),{createRequire:qt}=Mt("node:module");var Gt=Object.defineProperty,Ht=b((t,e)=>Gt(t,"name",{value:e,configurable:!0}),"t$9");let D=class extends P{static{b(this,"a")}static{Ht(this,"CommandNotFoundError")}commandName;constructor(e,n=[]){const a=`Command "${e}" not found${n.length>0?`. Did you mean: ${n.join(", ")}?`:""}`;super(a,"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 Kt=Object.defineProperty,Yt=b((t,e)=>Kt(t,"name",{value:e,configurable:!0}),"e$7");let Ze=class extends P{static{b(this,"o")}static{Yt(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 Jt=Object.defineProperty,Zt=b((t,e)=>Jt(t,"name",{value:e,configurable:!0}),"e$6");let Qt=class extends P{static{b(this,"o")}static{Zt(this,"PluginError")}pluginName;constructor(e,n,a){super(`Plugin "${e}" error: ${n}`,"PLUGIN_ERROR",{originalError:a,pluginName:e}),this.name="PluginError",this.pluginName=e,a&&(this.cause=a)}};var Xt=Object.defineProperty,xe=b((t,e)=>Xt(t,"name",{value:e,configurable:!0}),"d$5");let en=class{static{b(this,"p")}static{xe(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`);q().CEREBRO_OUTPUT_LEVEL===String(W)&&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 ${n.length} plugin(s)...`);for(const a of n)if(typeof a.init=="function"){this.logger.debug(`initializing plugin: ${a.name}`);try{await a.init(e)}catch(r){const i=new Qt(a.name,`Failed to initialize: ${r instanceof Error?r.message:String(r)}`,r instanceof Error?r:void 0);throw this.logger.error(i.message),i}}this.initialized=!0}async executeLifecycle(e,n,a){if(!this.initialized)throw new Error("PluginManager not initialized");if(this.plugins.size===0)return;const r=this.getDependencyOrder();for(const i of r){const c=i[e];if(typeof c=="function"){this.logger.debug(`executing ${e} hook for plugin: ${i.name}`);try{await(e==="afterCommand"?c(n,a):c(n))}catch(s){throw this.logger.error(`Error in ${e} hook for plugin "${i.name}":`,s),s}}}}async executeErrorHandlers(e,n){if(!this.initialized||this.plugins.size===0)return;const a=this.getDependencyOrder();for(const r of a)if(typeof r.onError=="function"){this.logger.debug(`executing error handler for plugin: ${r.name}`);try{await r.onError(e,n)}catch(i){this.logger.error(`Error in error handler for plugin "${r.name}":`,i)}}}getDependencyOrder(){if(this.cachedDependencyOrder!==void 0)return this.cachedDependencyOrder;const e=[],n=new Set,a=new Set,r=xe(i=>{if(n.has(i))return;if(a.has(i))throw new Error(`Circular dependency detected involving plugin "${i}"`);const c=this.plugins.get(i);if(!c)throw new Error(`Plugin "${i}" not found`);if(a.add(i),c.dependencies)for(const s of c.dependencies)r(s);a.delete(i),n.add(i),e.push(c)},"visit");for(const i of this.plugins.keys())r(i);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 tn=Object.defineProperty,nn=b((t,e)=>tn(t,"name",{value:e,configurable:!0}),"n$b");const X=nn(t=>t.type?.name==="Boolean","optionIsBoolean");var an=Object.defineProperty,Qe=b((t,e)=>an(t,"name",{value:e,configurable:!0}),"p$b");const on=Qe(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"),rn=Qe(t=>(X(t)||(t.typeLabel=t.typeLabel??on(t),t.defaultOption&&(t.typeLabel=`${t.typeLabel} (D)`),t.required&&(t.typeLabel=`${t.typeLabel} (R)`)),t),"mapOptionTypeLabel");var sn=Object.defineProperty,Xe=b((t,e)=>sn(t,"name",{value:e,configurable:!0}),"e$4");const ln=new RegExp(/^-([^\d-])$/),cn=new RegExp(/^--(\S+)/),un=new RegExp(/^-([^\d-]{2,})$/),pn=Xe(t=>ln.test(t)||cn.test(t)||un.test(t),"isOption"),fn=Xe((t,e)=>{const n=e[0]&&pn(e[0])||e.length===0?null:e.shift()??null;if(!t.includes(n)){const a=new Error(`Command not recognised: ${n}`);throw a.command=n,a.name="INVALID_COMMAND",a}return{argv:e,command:n}},"commandLineCommands");var hn=Object.defineProperty,et=b((t,e)=>hn(t,"name",{value:e,configurable:!0}),"i$a"),dn=Object.defineProperty,tt=et((t,e)=>dn(t,"name",{value:e,configurable:!0}),"i"),mn=Object.defineProperty,nt=tt((t,e)=>mn(t,"name",{value:e,configurable:!0}),"s"),gn=Object.defineProperty,it=nt((t,e)=>gn(t,"name",{value:e,configurable:!0}),"i"),vn=Object.defineProperty,at=it((t,e)=>vn(t,"name",{value:e,configurable:!0}),"t");at(t=>t instanceof Error&&t.type==="VisulimaError","isVisulimaError");class oe extends Error{static{b(this,"v")}static{et(this,"g")}static{tt(this,"p")}static{nt(this,"V")}static{it(this,"VisulimaError")}static{at(this,"VisulimaError")}loc;title;hint;type="VisulimaError";constructor({cause:e,hint:n,location:a,message:r,name:i,stack:c,title:s}){super(r,{cause:e}),this.title=s,this.name=i,this.stack=c??this.stack,this.loc=a,this.hint=n}setLocation(e){this.loc=e}setName(e){this.name=e}setMessage(e){this.message=e}setHint(e){this.hint=e}}var yn=Object.defineProperty,ot=b((t,e)=>yn(t,"name",{value:e,configurable:!0}),"o$b"),wn=Object.defineProperty,rt=ot((t,e)=>wn(t,"name",{value:e,configurable:!0}),"o"),bn=Object.defineProperty,$n=rt((t,e)=>bn(t,"name",{value:e,configurable:!0}),"i");let On=class st extends oe{static{b(this,"a")}static{ot(this,"a")}static{rt(this,"t")}static{$n(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,st.prototype)}};var An=Object.defineProperty,lt=b((t,e)=>An(t,"name",{value:e,configurable:!0}),"t$7"),En=Object.defineProperty,ct=lt((t,e)=>En(t,"name",{value:e,configurable:!0}),"e"),Pn=Object.defineProperty,Cn=ct((t,e)=>Pn(t,"name",{value:e,configurable:!0}),"e");let _e=class ut extends oe{static{b(this,"n")}static{lt(this,"n")}static{ct(this,"o")}static{Cn(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,ut.prototype)}};var kn=Object.defineProperty,pt=b((t,e)=>kn(t,"name",{value:e,configurable:!0}),"a$6"),Nn=Object.defineProperty,ft=pt((t,e)=>Nn(t,"name",{value:e,configurable:!0}),"a"),jn=Object.defineProperty,xn=ft((t,e)=>jn(t,"name",{value:e,configurable:!0}),"o");let _n=class ht extends oe{static{b(this,"n")}static{pt(this,"o")}static{ft(this,"e")}static{xn(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,ht.prototype)}};var Ln=Object.defineProperty,dt=b((t,e)=>Ln(t,"name",{value:e,configurable:!0}),"i$7"),In=Object.defineProperty,mt=dt((t,e)=>In(t,"name",{value:e,configurable:!0}),"i"),Sn=Object.defineProperty,Un=mt((t,e)=>Sn(t,"name",{value:e,configurable:!0}),"i");let x=class gt extends oe{static{b(this,"a")}static{dt(this,"o")}static{mt(this,"e")}static{Un(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,gt.prototype)}};var Mn=Object.defineProperty,Vn=b((t,e)=>Mn(t,"name",{value:e,configurable:!0}),"T$1"),Tn=Object.defineProperty,H=Vn((t,e)=>Tn(t,"name",{value:e,configurable:!0}),"P"),Rn=Object.defineProperty,re=H((t,e)=>Rn(t,"name",{value:e,configurable:!0}),"o");const Le=re(t=>t===Boolean||typeof t=="function"&&t.name?.startsWith("Boolean"),"isBooleanType"),Ie=re(t=>t===Number||typeof t=="function"&&t.name==="Number","isNumberType"),Se=re(t=>t===String||typeof t=="function"&&t.name==="String","isStringType"),Dn=re((t,e)=>Array.isArray(t)?Le(e)?t.map(Boolean):Ie(e)?t.map(Number):Se(e)?t.map(String):t.map(n=>e(String(n))):t===null?null:Le(e)?!!t:Ie(e)?Number(t):Se(e)?String(t):e(String(t)),"convertValue");var Bn=Object.defineProperty,zn=H((t,e)=>Bn(t,"name",{value:e,configurable:!0}),"e");const N=zn((t,e,n,...a)=>{t&&console.debug(`[command-line-args:${n}] ${e}`,...a)},"debug");var Wn=Object.defineProperty,T=H((t,e)=>Wn(t,"name",{value:e,configurable:!0}),"A");const Fn=/-([a-z])/g,me=T(t=>t===Boolean||typeof t=="function"&&t.name?.startsWith("Boolean"),"isBooleanType"),qn=T(t=>t.codePointAt(0)===95,"isSpecialKey"),Ue=T((t,e)=>Array.isArray(t)?[...t,...e]:[t,...e],"appendToArrayMultiple"),Me=T(t=>t==="__proto__"||t==="constructor"||t==="prototype","isUnsafeKey"),Ve=T((t,e,n,a=!1)=>{t[e]===void 0?t[e]=a?[n]:n:a&&Array.isArray(t[e])?t[e].push(n):t[e]=[t[e],n]},"createOrAppendArray"),Gn=T((t,e,n,a,r)=>{let i=e.get(t)||n.get(t);if(!i&&a){const c=t.toLowerCase();i=a.get(c)||r?.get(c)}return i},"getDefinition"),Hn=T((t,e,n,a)=>{const r=n.debug||!1;N(r,"resolveArgs called with options:","resolver",{partial:n.partial,stopAtFirstUnknown:n.stopAtFirstUnknown}),N(r,"Starting argument resolution","resolver"),N(r,"Tokens:","resolver",t),N(r,"Definitions:","resolver",e),N(r,"Processing tokens...","resolver");const i=new Map,c=new Map,s=n.caseInsensitive?new Map:void 0,g=n.caseInsensitive?new Map:void 0,o=n.camelCase?new Map:void 0,p=n.camelCase?new Map:void 0;for(const f of e)if(i.set(f.name,f),f.alias&&c.set(f.alias,f),n.caseInsensitive&&s&&(s.set(f.name.toLowerCase(),f),f.alias&&g&&g.set(f.alias.toLowerCase(),f)),n.camelCase&&o&&p){const h=f.name.replaceAll(Fn,(m,w)=>w.toUpperCase());o.set(f.name,h),p.set(h,f.name)}const u={},l={},d=[],y=new Set;let v=!1;const $=e.find(f=>f.defaultOption),C=e.some(f=>f.group),k=e.some(f=>f.type===Number);for(let f=0;f<t.length;f++){const h=t[f];if(h.kind==="option-terminator"){u._unknown=a.slice(h.index),v=!0;break}if(h.kind==="option"&&h.name){let m=Gn(h.name,i,c,s,g);if(!m&&h.value===void 0&&k&&/^\d+$/.test(h.name)){const O=e.find(I=>I.type===Number);O&&(m=O,h.value=h.name,h.name=O.name)}const w=m?m.name:h.name,A=m&&m.multiple,j=m&&m.lazyMultiple;if(l[w]!==void 0&&!A&&!j&&!n.partial)throw new On(w);if(!m&&n.partial){const O=h.rawName||`--${h.name}${h.value!==void 0&&h.inlineValue?`=${h.value}`:""}`;d.push({index:h.index,value:O});continue}if(!m&&n.stopAtFirstUnknown){u._unknown=a.slice(h.index);break}if(!m&&!n.partial)throw new _e(h.name);if(h.value===void 0){const O=t[f+1],I=O&&O.kind==="option"&&!("name"in O)&&O.value!==void 0,L=O&&m&&!(m.type&&me(m.type))&&(O.kind==="positional"||I),Lt=m&&m.defaultOption&&!m.multiple&&!m.lazyMultiple;if(L&&(!m?.defaultOption||Lt))if(A){let S=f+1;const de=[];for(;S<t.length&&(t[S].kind==="positional"||t[S].kind==="option"&&!("name"in t[S])&&t[S].value!==void 0);)de.push(t[S].value),y.add(t[S].index),S++;l[w]=l[w]===void 0?de:Ue(l[w],de),f=S-1}else j?(Ve(l,w,O.value,!0),y.add(O.index),f++):(l[w]=O.value,y.add(O.index),f++);else m&&m.type&&me(m.type)?Ve(l,w,!0,A):l[w]=A?[]:null}else{let{value:O}=h;if(m&&m.type&&me(m.type))switch(O){case"":{if(n.partial)l._unknown||(l._unknown=[]),l._unknown.push(`${h.rawName||`--${h.name}`}${h.value?`=${h.value}`:""}`),O=!0;else throw new _e(h.name);break}case"false":{O=!1;break}case"true":{O=!0;break}default:O=!0}const I=O===void 0?[]:[O];if(A){let L=f+1;for(;L<t.length&&t[L].kind==="positional";)I.push(t[L].value),y.add(t[L].index),L++;f=L-1}l[w]===void 0?l[w]=A||j?I:O:A||j?l[w]=Ue(l[w],I):l[w]=O}}else if(h.kind==="positional"&&n.stopAtFirstUnknown&&!y.has(h.index)){N(r,`Found unconsumed positional token at index ${h.index}, stopping processing`,"resolver"),u._unknown=a.slice(h.index);break}}for(const[f,h]of Object.entries(l)){const m=i.get(f);m&&(m.multiple||m.lazyMultiple)&&!Array.isArray(h)&&(l[f]=[h])}if($){const f=[],h=[];for(const m of t)m.kind==="positional"&&!y.has(m.index)&&(f.push(m.value),h.push(m));if(f.length>0){const m=l[$.name],w=$.multiple||$.lazyMultiple;m===void 0?w?(h.forEach(A=>y.add(A.index)),l[$.name]=f):(y.add(h[0].index),l[$.name]=f[0]):w&&(h.forEach(A=>y.add(A.index)),l[$.name]=Array.isArray(m)?[...f,...m]:[...f,m])}}if(!n.partial){for(const f of t)if(f.kind==="positional"&&!y.has(f.index))throw new _n(a[f.index])}if(n.partial&&!n.stopAtFirstUnknown){const f=[...d];if(l._unknown){const h=new Map;for(const[m,w]of a.entries())h.set(w,m);for(const m of l._unknown){const w=h.get(m);w!==void 0&&f.push({index:w,value:m})}}for(const h of t)h.kind==="positional"&&!y.has(h.index)&&f.push({index:h.index,value:a[h.index]});f.length>0&&(f.sort((h,m)=>h.index-m.index),u._unknown=f.map(h=>h.value))}if(n.stopAtFirstUnknown&&!v){const f=t.findIndex(w=>w.kind==="option"&&!i.has(w.name||"")&&!c.has(w.name||"")&&(!n.caseInsensitive||!s?.has(w.name?.toLowerCase()||"")&&!g?.has(w.name?.toLowerCase()||""))),h=t.findIndex(w=>w.kind==="positional"&&!y.has(w.index));let m=-1;if(f!==-1&&h!==-1?m=Math.min(f,h):f!==-1?m=f:h!==-1&&(m=h),m>=0){const w=t[m].index;u._unknown=a.slice(w)}}else d.length>0&&!n.partial&&(u._unknown=d.map(f=>f.value));for(const[f,h]of Object.entries(l)){const m=n.camelCase&&o?.get(f)||f,w=i.get(f);u[m]=w&&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;!(h in u)&&f.defaultValue!==void 0&&(f.multiple||f.lazyMultiple?u[h]=Array.isArray(f.defaultValue)?[...f.defaultValue]:[f.defaultValue]:u[h]=f.defaultValue)}if(C){const f={},h={},m={};for(const A of e)if(A.group){const j=Array.isArray(A.group)?A.group:[A.group];for(const O of j)Me(O)||f[O]||(f[O]={})}for(const A of Object.keys(u))if(!qn(A)){h[A]=u[A];let j=A;n.camelCase&&(j=p?.get(A)||A);const O=i.get(j);if(O&&O.group){const I=Array.isArray(O.group)?O.group:[O.group];for(const L of I)Me(L)||f[L]&&(f[L][A]=u[A])}else m[A]=u[A]}const w={_all:h};for(const[A,j]of Object.entries(f))w[A]=j;Object.keys(m).length>0&&(w._none=m),u._unknown&&(w._unknown=u._unknown),Object.keys(u).forEach(A=>delete u[A]),Object.assign(u,w)}return N(r,"Final parsed result:","resolver",u),u},"resolveArgs");var Kn=Object.defineProperty,R=H((t,e)=>Kn(t,"name",{value:e,configurable:!0}),"l");const V="-".codePointAt(0),M="=",Yn=M.codePointAt(0),Jn="--",Zn="-",Qn="--",vt=R(t=>t.length>2&&t.startsWith(Qn),"hasLongOptionPrefix"),Xn=R(t=>vt(t)&&!t.includes(M,3),"isLongOption"),ei=R(t=>vt(t)&&t.includes(M,3),"isLongOptionAndValue"),ti=R(t=>t!==void 0&&t.length>0&&t.codePointAt(0)!==V,"hasOptionValue"),ni=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"),ii=R(t=>!(t.length<=2||t.codePointAt(0)!==V||t.codePointAt(1)===V),"isShortOptionGroup"),ai=R(t=>{const e=[],n=[...t];let a=-1,r=0;for(;n.length>0;){const i=n.shift();if(i===void 0)break;const c=n[0];if(r>0?r--:a++,i===Jn){e.push({index:a,kind:"option-terminator"});const s=n.map((g,o)=>({index:a+o+1,kind:"positional",value:g}));e.push(...s),a+=n.length;break}if(ni(i)){const s=i.charAt(1);let g,o;r?(e.push({index:a,inlineValue:o,kind:"option",name:s,rawName:i,value:g}),r===1&&ti(c)&&(g=n.shift(),e.push({index:a,inlineValue:o,kind:"option",value:g}))):e.push({index:a,inlineValue:o,kind:"option",name:s,rawName:i,value:g}),g!==void 0&&++a;continue}if(ii(i)&&!i.includes(M)){const s=[];let g="",o=!1;for(let p=1;p<i.length;p++){const u=i.charAt(p);o?g+=u:u.codePointAt(0)===Yn?o=!0:s.push(`${Zn}${u}`)}if(o)if(s.length>0){const p=s.pop();s.push(`${p}=${g}`)}else s.push(g);n.unshift(...s),r=s.length;continue}if(Xn(i)){const s=i.slice(2);e.push({index:a,kind:"option",name:s,rawName:i});continue}if(ei(i)){const s=i.indexOf(M),g=i.slice(2,s),o=i.slice(s+1);e.push({index:a,inlineValue:!0,kind:"option",name:g,rawName:i,value:o});continue}if(i.length>2&&i.codePointAt(0)===V&&i.codePointAt(1)!==V&&i.includes(M)){const s=i.indexOf(M),g=i.charAt(1),o=i.slice(s+1);e.push({index:a,inlineValue:!0,kind:"option",name:g,rawName:i,value:o});continue}e.push({index:a,kind:"positional",value:i})}return e},"parseArgsTokens");var oi=Object.defineProperty,Pe=H((t,e)=>oi(t,"name",{value:e,configurable:!0}),"d");const ri=Pe(t=>t&&(t===Boolean||typeof t=="function"&&t.name?.startsWith("Boolean")),"isBooleanType"),si=Pe(t=>typeof t=="function","isValidCustomTypeFunction"),li=Pe((t,e,n)=>{const a=n?.debug||!1;N(a,"Validating definitions:","validation",t,"caseInsensitive:",e);const r=new Set,i=new Set,c=new Set,s=new Set;let g=0;for(const o of t){if(N(a,"Checking definition:","validation",o),!o.name)throw N(a,"Validation failed: name is required","validation"),new x("Invalid option definition: name is required");if(typeof o.name!="string")throw new x("Invalid option definition: name must be a string");if(o.name.trim()==="")throw new x("Invalid option definition: name cannot be empty");const p=e?o.name.toLowerCase():"";if(r.has(o.name)||e&&c.has(p))throw new x(`Invalid option definition: duplicate name '${o.name}'`);if(i.has(o.name)||e&&s.has(p))throw new x(`Invalid option definition: name '${o.name}' conflicts with an existing alias`);if(r.add(o.name),e&&c.add(p),o.alias!==void 0){if(typeof o.alias!="string")throw new x("Invalid option definition: alias must be a string");if(o.alias.length!==1)throw new x("Invalid option definition: alias must be a single character");if(/\d/.test(o.alias))throw new x("Invalid option definition: alias cannot be numeric");if(o.alias==="-")throw new x('Invalid option definition: alias cannot be "-"');const u=e?o.alias.toLowerCase():"";if(i.has(o.alias)||e&&s.has(u))throw new x(`Invalid option definition: duplicate alias '${o.alias}'`);if(r.has(o.alias)||e&&c.has(u))throw new x(`Invalid option definition: alias '${o.alias}' conflicts with an existing option name`);i.add(o.alias),e&&s.add(u)}if(o.defaultOption&&(g++,o.type!==void 0&&ri(o.type)))throw new x("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"&&si(o.type)))throw new x("Invalid option definition: invalid type")}if(g>1)throw N(a,"Validation failed: multiple defaultOptions not allowed","validation"),new x("Invalid option definition: multiple defaultOptions not allowed");N(a,"Validation completed successfully","validation")},"validateDefinitions");var ci=Object.defineProperty,ui=H((t,e)=>ci(t,"name",{value:e,configurable:!0}),"O");const pi=ui((t,e={})=>{const n=e.debug||!1;N(n,"Starting command-line-args parsing","index"),N(n,"Options:","index",e);const a={...e};a.stopAtFirstUnknown&&(a.partial=!0);const r=Array.isArray(t)?t:[t];N(n,"Normalized definitions:","index",r),li(r,a.caseInsensitive,n?a:void 0);let{argv:i}=a;if(!i&&(i=process.argv.slice(2),process.execArgv?.length)){const o=new Set(process.execArgv);i=i.filter(p=>!o.has(p))}N(n,"Using argv:","index",i);let c=i;a.caseInsensitive&&i&&(c=i.map(o=>{if(o.startsWith("--")){const p=o.indexOf("="),u=(p===-1?o.slice(2):o.slice(2,p)).toLowerCase();return p===-1?`--${u}`:`--${u}${o.slice(p)}`}if(o.startsWith("-")&&!o.startsWith("--")&&o.length>1){const p=o.slice(1).split("=",2),u=p[0],l=p[1];if(!u)return o;const d=u.toLowerCase();return l===void 0?`-${d}`:`-${d}=${l}`}return o}));const s=ai((c??i??[]).map(String));N(n,"Tokenized arguments:","index",s);const g=Hn(s,r,a,i??[]);return N(n,"Command-line-args parsing completed","index"),g},"commandLineArgs");var fi=Object.defineProperty,hi=b((t,e)=>fi(t,"name",{value:e,configurable:!0}),"m$5");let di=class{static{b(this,"a")}static{hi(this,"EmptyToolbox")}result;argv;options;argument;command;commandName;env;logger;runtime;constructor(e,n){this.commandName=e,this.command=n}};var mi=Object.defineProperty,gi=b((t,e)=>mi(t,"name",{value:e,configurable:!0}),"f$3");const vi=/^-{1,2}(\w+)(=(.+))?$/,yt=gi((t,e,n,a)=>{const r=vi.exec(t);if(r==null)return{};const i=r[1];if(!i)return{};const c=n&&a?n.get(i)??a.get(i):e.find(s=>s.name===i||s.alias===i);return c!==void 0?{argName:c.name,argValue:r[3],option:c}:{}},"getParameterOption");var yi=Object.defineProperty,Ee=b((t,e)=>yi(t,"name",{value:e,configurable:!0}),"e$3");const Te=Ee((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"),wi=new Set(["0","1","false","true"]),bi=Ee((t,e,n,a)=>{if(e.length===0||t.length===0)return{};const r=Ee((i,c)=>{const{argName:s,argValue:g,option:o}=yt(c,e,n,a),{lastOption:p}=i;return o&&X(o)&&g&&s?i.partial[s]=Te(g,o):i.lastName&&p&&X(p)&&wi.has(c)&&(i.partial[i.lastName]=Te(c,p)),{lastName:s,lastOption:o,partial:i.partial}},"getBooleanValue");return t.reduce(r,{partial:{}}).partial},"getBooleanValues");var $i=Object.defineProperty,Re=b((t,e)=>$i(t,"name",{value:e,configurable:!0}),"e$2");const Oi=new Set(["0","1","false","true"]),Ai=Re((t,e,n,a)=>{if(e.length===0||t.length===0)return t;const r=Re((i,c)=>{const{argValue:s,option:g}=yt(c,e,n,a),{lastOption:o}=i;if(o&&X(o)&&Oi.has(c)){const{args:u}=i;return{args:u.slice(0,-1)}}if(g&&X(g)&&s)return{args:i.args};const p=[...i.args];return p.push(c),{args:p,lastOption:g}},"removeBooleanArguments");return t.reduce(r,{args:[]}).args},"removeBooleanValues");var Ei=Object.defineProperty,Pi=b((t,e)=>Ei(t,"name",{value:e,configurable:!0}),"o$8");const De=Pi(t=>{const e=new Map;for(const n of t){const a=e.get(n.name);a?e.set(n.name,{...a,...n}):e.set(n.name,n)}return[...e.values()]},"mergeArguments");var Ci=Object.defineProperty,se=b((t,e)=>Ci(t,"name",{value:e,configurable:!0}),"o$7");const ki=se(t=>{if(t===void 0)return;const e=t.toLowerCase().trim();return e==="true"||e==="1"||e==="yes"||e==="on"},"transformBooleanEnv"),Ni=se((t,e)=>{if(!t.type)return e;if(e!==void 0){if(t.type===Boolean||typeof t.type=="function"&&t.type.name==="Boolean")return ki(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"),ji=se(t=>t.toLowerCase().replaceAll(/_./g,e=>e[1]?.toUpperCase()??e).replace(/^[A-Z]/,e=>e.toLowerCase()),"toCamelCase"),xi=se(t=>{if(!t||t.length===0)return{};const e={},n=q();for(const a of t){const r=n[a.name],i=Ni(a,r),c=i===void 0?a.defaultValue:i,s=ji(a.name);e[s]=c}return e},"processEnvVariables");var _i=Object.defineProperty,le=b((t,e)=>_i(t,"name",{value:e,configurable:!0}),"l$a");const Li=le(t=>{const e=new Map,n=new Map;for(const a of t)if(e.set(a.name,a),a.alias){const r=Array.isArray(a.alias)?a.alias:[a.alias];for(const i of r)n.set(i,a)}return{optionMapByAlias:n,optionMapByName:e}},"buildOptionMaps"),Ii=le((t,e,n,a)=>{const r=new di(t.name,t),{_all:i,positionals:c}=e,s=Object.keys(n).length>0?{...i,...n}:i;te in s&&delete s[te],r.argument=c?.[te]??[];const g=Object.keys(a).length>0;return r.options=g?{...s,...a}:s,r.env=xi(t.env),r},"prepareToolbox"),Si=le((t,e,n)=>{const a=t.options??[],r=a.length>0;let i=De(r?[...a,...n]:n);if(i.length>0){for(const o of i)if(o.multiple&&o.lazyMultiple)throw new Error(`Argument "${o.name}" cannot have both multiple and lazyMultiple options, please choose one.`)}t.argument&&(i=[{defaultOption:!0,description:t.argument?.description,group:"positionals",multiple:!0,name:te,type:t.argument?.type,typeLabel:t.argument?.typeLabel},...i]);let c,s;if(r){const{optionMapByAlias:o,optionMapByName:p}=Li(a);c=Ai(e,a,p,o),s=bi(e,a,p,o)}else c=e,s={};const g=pi(i,{argv:c,camelCase:!0,partial:!0,stopAtFirstUnknown:!0});return{arguments_:i,booleanValues:s,parsedArgs:g}},"processCommandArgs"),B=le(async(t,e,n)=>await t.execute(e),"executeCommand");var Ui=Object.defineProperty,Mi=b((t,e)=>Ui(t,"name",{value:e,configurable:!0}),"n$6");let Vi=class extends P{static{b(this,"s")}static{Mi(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 Ti=Object.defineProperty,Ri=b((t,e)=>Ti(t,"name",{value:e,configurable:!0}),"t$5");const Be=Ri((t,e,n=!1)=>{const a=[];for(const r of t)if(!(!n&&!r.required)&&e[r.name]===void 0){if(r.type?.name==="Boolean"){e[r.name]=!1;continue}a.push(r)}return a},"listMissingArguments");var Di=Object.defineProperty,wt=b((t,e)=>Di(t,"name",{value:e,configurable:!0}),"n$5");const Bi=wt((t,e)=>e.includes(t)?!0:Math.abs(t.length-e.length)>t.length/2?!1:Ft(t,e)<=t.length/3,"isSimilar"),F=wt((t,e)=>{const n=t.toLowerCase();return e.filter(a=>Bi(a.toLowerCase(),n))},"findAlternatives");var zi=Object.defineProperty,ce=b((t,e)=>zi(t,"name",{value:e,configurable:!0}),"a$2");const Wi=ce((t,e)=>{const n=[];if(t._unknown&&t._unknown.forEach(a=>{const r=a.startsWith("--");let i=`Found unknown ${r?"option":"argument"} "${a}"`;if(r){const c=F(a.replace("--",""),(e.options??[]).map(s=>s.name));if(c.length>0){const[s,...g]=c.map(o=>`--${o}`);i+=g.length>0?`, did you mean ${s} or ${g.join(", ")}?`:`, did you mean ${s}?`}}n.push(i)}),n.length>0)throw new Error(n.join(`
|
|
2
|
-
`))},"validateUnknownOptions"),Fi=ce((t,e,n)=>{const a=n.__requiredOptions__?Be(n.__requiredOptions__,e,!0):Be(t,e,!1);if(a.length>0)throw new Vi(n.name,a.map(r=>r.name));e._unknown&&e._unknown.length>0&&!n.argument&&Wi(e,n)},"validateRequiredOptions"),qi=ce((t,e,n)=>{const a=n.__conflictingOptions__??t.filter(r=>r.conflicts!==void 0);if(a.length>0){const r=a.find(i=>Array.isArray(i.conflicts)?i.conflicts.some(c=>e[c]!==void 0)&&e[i.name]!==void 0:e[i.conflicts]!==void 0&&e[i.name]!==void 0);if(r)throw new Ze(r.name,typeof r.conflicts=="string"?r.conflicts:r.conflicts?.[0]??"unknown")}},"validateConflictingOptions"),Gi=ce(t=>{if(!Array.isArray(t.options))return;const e=new Map,n=new Map;for(const r of t.options){if(r.name){const i=e.get(r.name)??[];i.push(r),e.set(r.name,i)}if(typeof r.alias=="string"&&r.alias.length>0){const i=n.get(r.alias)??[];i.push(r),n.set(r.alias,i)}else if(Array.isArray(r.alias)){for(const i of r.alias)if(i.length>0){const c=n.get(i)??[];c.push(r),n.set(i,c)}}}const a=[];for(const[r,i]of e)i.length>1&&a.push(`Duplicate option name "${r}" in command "${t.name}": ${JSON.stringify(i)}`);for(const[r,i]of n)i.length>1&&a.push(`Duplicate option alias "-${r}" used by options ${i.map(c=>`"${c.name}"`).join(", ")} in command "${t.name}"`);if(a.length>0)throw new Error(a.join(`
|
|
3
|
-
`))},"validateDuplicateOptions");var Hi=Object.defineProperty,Ce=b((t,e)=>Hi(t,"name",{value:e,configurable:!0}),"r$7");const Ki=Ce((t,e)=>{if(e.length===0)return{argv:[],commandPath:void 0};const n=[];for(let a=1;a<=e.length;a+=1){const r=e[a-1];if(r===void 0)break;n.push(r);const i=n.join(" ");if(t.has(i))return{argv:e.slice(a),commandPath:[...n]}}return{argv:e,commandPath:void 0}},"parseNestedCommand"),J=Ce(t=>t.join(" "),"getCommandPathKey"),Yi=Ce((t,e)=>e&&e.length>0?[...e,t]:[t],"getFullCommandPath");var Ji=Object.defineProperty,Zi=b((t,e)=>Ji(t,"name",{value:e,configurable:!0}),"p$4"),Qi=Object.defineProperty,bt=Zi((t,e)=>Qi(t,"name",{value:e,configurable:!0}),"e"),Xi=Object.defineProperty,ea=bt((t,e)=>Xi(t,"name",{value:e,configurable:!0}),"E");const $t=String.raw,ze=$t`\p{Emoji}(?:\p{EMod}|[\u{E0020}-\u{E007E}]+\u{E007F}|\uFE0F?\u20E3?)`,ta=ea(()=>new RegExp($t`\p{RI}{2}|(?)${ze}(?:\u200D${ze})*`,"gu"),"default");var na=Object.defineProperty,ia=bt((t,e)=>na(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 G=ta(),aa=/[-_./\s]+/g,Q=/(\u001B\[[0-9;]*[a-z])/i,We=new RegExp("\\p{Script=Arabic}","u"),oa=new RegExp("\\p{Script=Bengali}","u"),z=new RegExp("\\p{Script=Cyrillic}","u"),ra=new RegExp("\\p{Script=Devanagari}","u"),sa=new RegExp("\\p{Script=Ethiopic}","u"),ge=new RegExp("\\p{Script=Greek}","u"),la=new RegExp("\\p{Script=Greek}+|\\p{Script=Latin}+|[^\\p{Script=Greek}\\p{Script=Latin}]+","gu"),ca=new RegExp("\\p{Script=Gujarati}","u"),ua=new RegExp("\\p{Script=Gurmukhi}","u"),Fe=new RegExp("\\p{Script=Hangul}","u"),qe=new RegExp("\\p{Script=Hebrew}","u"),pa=new RegExp("\\p{Script=Hiragana}","u"),Ge=new RegExp("\\p{Script=Han}","u"),fa=new RegExp("\\p{Script=Kannada}","u"),ha=new RegExp("\\p{Script=Katakana}","u"),da=new RegExp("\\p{Script=Khmer}","u"),ma=new RegExp("\\p{Script=Lao}","u"),_=new RegExp("\\p{Script=Latin}","u"),ga=new RegExp("\\p{Script=Malayalam}","u"),va=new RegExp("\\p{Script=Myanmar}","u"),ya=new RegExp("\\p{Script=Oriya}","u"),wa=new RegExp("\\p{Script=Sinhala}","u"),ba=new RegExp("\\p{Script=Tamil}","u"),$a=new RegExp("\\p{Script=Telugu}","u"),Oa=new RegExp("\\p{Script=Thai}","u"),Aa=new RegExp("\\p{Script=Tibetan}","u"),He=/[\u02BB\u02BC\u0027]/u,Ea=ia(t=>t.replace(G,""),"stripEmoji");var Pa=Object.defineProperty,Ot=b((t,e)=>Pa(t,"name",{value:e,configurable:!0}),"i$6"),Ca=Object.defineProperty,At=Ot((t,e)=>Ca(t,"name",{value:e,configurable:!0}),"r"),ka=Object.defineProperty,Na=At((t,e)=>ka(t,"name",{value:e,configurable:!0}),"c");let Et=class{static{b(this,"l")}static{Ot(this,"y")}static{At(this,"s")}static{Na(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(a=>a!==e);else if(this.cache.size>=this.capacity){const a=this.keyOrder.shift();a!==void 0&&this.cache.delete(a)}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 ja=Object.defineProperty,xa=b((t,e)=>ja(t,"name",{value:e,configurable:!0}),"r$5"),_a=Object.defineProperty,La=xa((t,e)=>_a(t,"name",{value:e,configurable:!0}),"a"),Ia=Object.defineProperty,Sa=La((t,e)=>Ia(t,"name",{value:e,configurable:!0}),"s");const Ua=Sa((t,e)=>typeof t!="string"||t===""?"":(e?.locale?t[0].toLocaleLowerCase(e.locale):t[0].toLowerCase())+t.slice(1),"lowerFirst");var Ma=Object.defineProperty,Va=b((t,e)=>Ma(t,"name",{value:e,configurable:!0}),"S"),Ta=Object.defineProperty,ue=Va((t,e)=>Ta(t,"name",{value:e,configurable:!0}),"m");const Ra=qt(import.meta.url),Z=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Da=ue(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 Ra(t)},"__cjs_getBuiltinModule"),{stripVTControlCharacters:Ba}=Da("node:util");var za=Object.defineProperty,Wa=ue((t,e)=>za(t,"name",{value:e,configurable:!0}),"g");const ve=new Et(1e3),Fa=Wa(t=>{const e=t.join("");if(ve.has(e))return ve.get(e);const n=t.map(r=>r.replaceAll(/[.*+?^${}()|[\]\\]/g,String.raw`\$&`)).join("|"),a=new RegExp(n,"g");return ve.set(e,a),a},"getSeparatorsRegex");var qa=Object.defineProperty,Ga=ue((t,e)=>qa(t,"name",{value:e,configurable:!0}),"t");const Ha=Ga(t=>{const e=[];let n=0,a;for(G.lastIndex=0;(a=G.exec(t))!==null;)a.index>n&&e.push(t.slice(n,a.index)),e.push(a[0]),n=G.lastIndex;return n<t.length&&e.push(t.slice(n)),e.filter(Boolean)},"splitByEmoji");var Ka=Object.defineProperty,E=ue((t,e)=>Ka(t,"name",{value:e,configurable:!0}),"u");const Pt=new Uint8Array(128),Ct=new Uint8Array(128),kt=new Uint8Array(128);for(let t=0;t<128;t++)Pt[t]=t>=65&&t<=90?1:0,Ct[t]=t>=97&&t<=122?1:0,kt[t]=t>=48&&t<=57?1:0;const ye=E(t=>Pt[t],"isUpper"),Ke=E(t=>Ct[t],"isLower"),we=E(t=>kt[t],"isDigit"),U=E((t,e,n,a,r)=>{if(t.length===0)return[];let i=!1;for(const u of Object.values(e))if(u(t[0])){i=!0;break}if(!i&&!n)return[t];const c=[...t],s=[];let g=c[0],o="other";for(const[u,l]of Object.entries(e))if(l(c[0])){o=u;break}let p=n&&a?c[0]===c[0].toLocaleUpperCase(a):!1;for(let u=1;u<c.length;u++){const l=c[u];let d="other";for(const[$,C]of Object.entries(e))if(C(l)){d=$;break}const y=n&&a?l===l.toLocaleUpperCase(a):!1;let v=!1;r?v=r(o,d,p,y,l,u,c):(o!==d&&o!=="other"&&d!=="other"&&(v=!0),n&&d!=="other"&&!p&&y&&(v=!0)),v?(s.push(g),g=l):g+=l,o=d,n&&(p=y)}return g&&g.length>0&&s.push(g),s.length>0?s:[t]},"handleScriptTransitions"),Nt=E((t,e=new Set)=>{if(t.length===0)return[];if(t.toUpperCase()===t)return[t];let n=0;const a=[],r=t.length;for(let i=1;i<r;i++){const c=t.codePointAt(i-1),s=t.codePointAt(i);if(e.size>0){for(const d of e)if(t.startsWith(d,n)){a.push(d),n+=d.length,i=n-1;break}if(i<n)continue}const g=c&&c<128&&ye(c),o=s&&s<128&&ye(s),p=c&&c<128&&Ke(c),u=c&&c<128&&we(c),l=s&&s<128&&we(s);if(p&&o){a.push(t.slice(n,i)),n=i;continue}if(u&&!l||!u&&l){a.push(t.slice(n,i)),n=i;continue}if(l&&!u){let d=!1,y=!1;if(i+1<r){const v=t.codePointAt(i+1);d=v&&v<128&&ye(v),y=v&&v<128&&we(v)}if(!y&&d){a.push(t.slice(n,i),t.slice(i,i+1)),n=i+1;continue}}if(i+1<r){const d=t.codePointAt(i+1),y=d&&d<128&&Ke(d);if(g&&o&&y){const v=t.slice(n,i+1);e.has(v)||(a.push(t.slice(n,i)),n=i)}}}return n<r&&a.push(t.slice(n)),a.filter(i=>i!=="")},"splitCamelCaseFast"),jt=E((t,e,n)=>{if(t.length===0)return[];const a=t===t.toLocaleUpperCase(e);if(e.startsWith("de")){if(!a&&t.replaceAll("ß","SS")===t.toLocaleUpperCase(e))return[t];const o=[...t],p=o.length,u=[];let l=o[0],d=o[0]===o[0].toLocaleUpperCase(e),y=d,v=d?0:-1;for(let $=1;$<p;$++){const C=o[$],k=C===C.toLocaleUpperCase(e);if(k===d)l+=C;else if(k)l&&l.length>0&&(u.push(l),l=C),y=!0,v=$;else{if(y&&$-v>1){const f=o[$-1],h=l.slice(0,-1);h&&h.length>0&&u.push(h),l=f+C}else l+=C;y=!1,v=-1}d=k}return l&&l.length>0&&u.push(l),u}if(e.startsWith("uk")||e.startsWith("ru")||e.startsWith("bg")||e.startsWith("sr")||e.startsWith("mk")||e.startsWith("be")){if(!z.test(t)&&!_.test(t))return[t];const o=[...t],p=o.length,u=[];let l=o[0],d=z.test(o[0])?1:_.test(o[0])?2:0,y=o[0]===o[0].toLocaleUpperCase(e);for(let $=1;$<p;$++){const C=o[$],k=z.test(C)?1:_.test(C)?2:0,f=C===C.toLocaleUpperCase(e);d!==k&&(d===1||d===2)&&(k===1||k===2)||k===d&&!y&&f?(u.push(l),l=C):l+=C,d=k,y=f}l&&l.length>0&&u.push(l);const v=[];for(let $=0;$<u.length;$++)$<u.length-1&&u[$].length===1&&_.test(u[$])&&z.test(u[$+1][0])?(v.push(u[$]+u[$+1]),$+=1):v.push(u[$]);return v}if(e.startsWith("el")){if(!ge.test(t)&&!_.test(t))return[t];const o=t.match(la)??[t],p=[];if(o.length===1){const u=o[0];if(!u||!ge.test(u[0])||u.length===1)return[u||t]}for(const u of o){if(!u)continue;if(!ge.test(u[0])||u.length===1){p.push(u);continue}const l=u.length;let d=u[0],y=u[0]===u[0].toLocaleUpperCase(e);for(let v=1;v<l;v++){const $=u[v],C=$===$.toLocaleUpperCase(e);!y&&C?(p.push(d),d=$):d+=$,y=C}d&&p.push(d)}return p}if(e.startsWith("ja")||e.startsWith("ko")){const o=e.startsWith("ja"),p=o?{hiragana:E(l=>pa.test(l),"hiragana"),kanji:E(l=>Ge.test(l),"kanji"),katakana:E(l=>ha.test(l),"katakana"),latin:E(l=>_.test(l),"latin")}:{hangul:E(l=>Fe.test(l),"hangul"),latin:E(l=>_.test(l),"latin")},u=new Set(["が","で","と","に","の","は","へ","も","や","を"]);if(o){const l=U(t,p,!1,e,(y,v)=>y==="hiragana"&&v==="katakana"||y==="katakana"&&v==="hiragana"||y==="hiragana"&&v==="latin"||y==="katakana"&&v==="latin"||y==="kanji"&&v==="latin"||y==="latin"&&(v==="hiragana"||v==="katakana"||v==="kanji")),d=[];for(const y of l)y.length===1&&u.has(y)&&d.length>0?d[d.length-1]+=y:d.push(y);return d.length>0?d:[t]}return U(t,p,!1,e,(l,d)=>l==="hangul"&&d==="latin"||l==="latin"&&d==="hangul")}if(e.startsWith("sl")){const o=[...t],p=o.length,u=[];let l=o[0],d=o[0]===o[0].toLocaleUpperCase(e);for(let y=1;y<p;y++){const v=o[y],$=v===v.toLocaleUpperCase(e),C=/[ČŠŽĐ]/i.test(v),k=y<p-1&&o[y+1]===o[y+1].toLocaleUpperCase(e);!d&&$||C&&k?(u.push(l),l=v,C&&k&&(u.push(l),l="")):l+=v,d=$}return l&&l.length>0&&u.push(l),u}if(e.startsWith("zh"))return U(t,{han:E(o=>Ge.test(o),"han"),latin:E(o=>_.test(o),"latin")},!1,e);if(["ar","fa","he","ur"].includes(e.split("-")[0])){const o=E(p=>qe.test(p)||We.test(p),"isRtlChar");return U(t,{latin:E(p=>_.test(p),"latin"),rtl:E(p=>o(p),"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=E(p=>ra.test(p)||oa.test(p)||ca.test(p)||ua.test(p)||fa.test(p)||ba.test(p)||$a.test(p)||ga.test(p)||wa.test(p)||Oa.test(p)||ma.test(p)||Aa.test(p)||va.test(p)||sa.test(p)||da.test(p)||ya.test(p),"isIndicChar");return U(t,{indic:E(p=>o(p),"indic"),latin:E(p=>_.test(p),"latin")},!1,e)}if(["be","bg","ru","sr","uk"].includes(e))return U(t,{cyrillic:E(o=>z.test(o),"cyrillic"),latin:E(o=>_.test(o),"latin")},!0,e);if(["ar","fa","he"].includes(e))return U(t,{latin:E(o=>_.test(o),"latin"),rtl:E(o=>qe.test(o)||We.test(o),"rtl")},!1,e);if(e.startsWith("ko"))return U(t,{hangul:E(o=>Fe.test(o),"hangul"),latin:E(o=>_.test(o),"latin")},!1,e);if(e.startsWith("uz")){if(!z.test(t)&&!_.test(t))return[t];const o=[...t],p=o.length,u=[];let l=o[0],d=o[0]===o[0].toLocaleUpperCase(e);for(let y=1;y<p;y++){const v=o[y],$=v===v.toLocaleUpperCase(e);if(He.test(v)||He.test(o[y-1])){l+=v;continue}!d&&$?(u.push(l),l=v):l+=v,d=$}return l&&l.length>0&&u.push(l),u}const r=[...t],i=r.length,c=[];let s=r[0],g=r[0]===r[0].toLocaleUpperCase(e);for(const o of n)if(t.startsWith(o)){c.push(o),s=r[o.length],g=s===s.toLocaleUpperCase(e);break}for(let o=1;o<i;o++){const p=r[o],u=p===p.toLocaleUpperCase(e);let l=!1;for(const d of n)if(t.startsWith(d,o)){c.push(s,d),o+=d.length-1,s="",l=!0;break}l||(!g&&u?(c.push(s),s=p):s+=p,g=u)}return s&&c.push(s),c},"splitCamelCaseLocale"),Ya=E((t,e,n)=>{const a=[],r=Q.test(t)?t.split(Q).filter(Boolean):[t];for(const i of r)if(Q.test(i))a.push(i);else{const c=G.test(i)?Ha(i).filter(Boolean):[i];for(const s of c)if(G.test(s))a.push(s);else if(e){const g=e.toLowerCase().split("-")[0];a.push(...jt(s,g,n))}else a.push(...Nt(s,n))}return a},"processTextWithAnsiEmoji"),Ja=E((t,e={})=>{if(!t||typeof t!="string")return[];const{handleAnsi:n=!1,handleEmoji:a=!1,knownAcronyms:r=[],locale:i,normalize:c=!1,separators:s,stripAnsi:g=!1,stripEmoji:o=!1}=e,p=new Set([...r].sort((v,$)=>$.length-v.length));let u=t;g&&(u=Ba(u)),o&&(u=Ea(u));const l=Array.isArray(s)?Fa(s):s instanceof RegExp?s:aa,d=u.split(l).filter(Boolean);let y=[];for(const v of d)n||a?y.push(...Ya(v,i,p)):i?y.push(...jt(v,i,p)):y.push(...Nt(v,p));return c&&(y=y.map(v=>p.has(v)?v:i&&v===v.toLocaleUpperCase(i)?v[0]+v.slice(1).toLocaleLowerCase(i):v.toUpperCase()===v&&!p.has(v)?v.slice(0,1)+v.slice(1).toLowerCase():v)),y},"splitByCase");var Za=Object.defineProperty,Qa=b((t,e)=>Za(t,"name",{value:e,configurable:!0}),"r$4"),Xa=Object.defineProperty,eo=Qa((t,e)=>Xa(t,"name",{value:e,configurable:!0}),"o"),to=Object.defineProperty,no=eo((t,e)=>to(t,"name",{value:e,configurable:!0}),"s");const io=no((t,e)=>typeof t!="string"||t===""?"":(e?.locale?t[0].toLocaleUpperCase(e.locale):t[0].toUpperCase())+t.slice(1),"upperFirst");var ao=Object.defineProperty,oo=b((t,e)=>ao(t,"name",{value:e,configurable:!0}),"r$3"),ro=Object.defineProperty,so=oo((t,e)=>ro(t,"name",{value:e,configurable:!0}),"r"),lo=Object.defineProperty,co=so((t,e)=>lo(t,"name",{value:e,configurable:!0}),"n");const uo=co((t,e)=>`${t}::${e?.joiner??""}::${e?.locale??""}::${e?.knownAcronyms?.join(",")??""}::${e?.normalize?"true":"false"}`,"generateCacheKey");var po=Object.defineProperty,fo=b((t,e)=>po(t,"name",{value:e,configurable:!0}),"i$4"),ho=Object.defineProperty,mo=fo((t,e)=>ho(t,"name",{value:e,configurable:!0}),"a"),go=Object.defineProperty,vo=mo((t,e)=>go(t,"name",{value:e,configurable:!0}),"l");const yo=vo((t,e)=>{const{length:n}=t;if(n===0)return"";if(n===1)return t[0];const a=[];let r="",i="";for(let c=0;c<n;c++){const s=t[c];if(Q.test(s)){r?(a.push(r+i+s),r="",i=""):(a.length>0&&a.push(e),r=s);continue}r?(i&&(i+=e),i+=s):(a.length>0&&a.push(e),a.push(s))}return a.join("")},"joinSegments");var wo=Object.defineProperty,bo=b((t,e)=>wo(t,"name",{value:e,configurable:!0}),"r$2"),$o=Object.defineProperty,Oo=bo((t,e)=>$o(t,"name",{value:e,configurable:!0}),"a"),Ao=Object.defineProperty,Eo=Oo((t,e)=>Ao(t,"name",{value:e,configurable:!0}),"t");const Po=Eo(t=>t.replaceAll(/(?<![a-zß])SS(?![a-z])/g,"ß"),"normalizeGermanEszett");var Co=Object.defineProperty,ko=b((t,e)=>Co(t,"name",{value:e,configurable:!0}),"l$2"),No=Object.defineProperty,jo=ko((t,e)=>No(t,"name",{value:e,configurable:!0}),"n"),xo=Object.defineProperty,_o=jo((t,e)=>xo(t,"name",{value:e,configurable:!0}),"l");const Lo=new Et(1e3),xt=_o((t,e)=>{if(typeof t!="string"||!t)return"";const n=e?.cache??!1,a=e?.cacheStore??Lo;let r;if(n&&(r=uo(t,e)),n&&r&&a.has(r))return a.get(r);let i=!0;const c=yo(Ja(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=>e?.handleAnsi&&Q.test(s)?s:(s=e?.locale?.startsWith("de")?Po(s):s,s=e?.locale?s.toLocaleLowerCase(e.locale):s.toLowerCase(),i?(i=!1,Ua(s,e)):io(s,e))),"");return n&&r&&a.set(r,c),c},"camelCase");var Io=Object.defineProperty,pe=b((t,e)=>Io(t,"name",{value:e,configurable:!0}),"a");const So=pe(t=>{t.options?.forEach(e=>{e.__camelCaseName__=xt(e.name)})},"processOptionNames"),Uo=pe(t=>{if(!Array.isArray(t.options)||t.options.length===0)return;const e=new Set;for(const a of t.options)e.add(a.name);const n=[];for(const a of t.options)if(a.name.startsWith("no-")){const r=a.name.replace("no-","");if(!e.has(r)){if(a.type!==Boolean)throw new Error(`Cannot add negated option "${a.name}" to command "${t.name}" because it is not a boolean.`);const i={...a,defaultValue:a.defaultValue===void 0?!0:!a.defaultValue,name:r};n.push(i),e.add(r)}}n.length>0&&t.options.push(...n)},"addNegatableOptions"),Mo=pe((t,e)=>{if(!e.options||e.options.length===0)return;const n=t.options,a=new Map;for(const i of e.options)if(i.name.startsWith("no-")){const c=xt(i.name);a.set(c,i)}const r=Object.keys(n).filter(i=>a.has(i));if(r.length!==0)for(const i of r){const c=i.charAt(2);if(!c)continue;const s=c.toLowerCase()+i.slice(3),g=a.get(i);g&&(g.__negated__=!0),n[s]=!n[i],Reflect.deleteProperty(n,i)}},"mapNegatableOptions"),Vo=pe((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 a=t.options;for(const r of Object.keys(a)){const i=n.get(r);if(i?.implies){const c=i.implies;for(const[s,g]of Object.entries(c))a[s]===void 0&&(a[s]=g)}}},"mapImpliedOptions");var To=Object.defineProperty,fe=b((t,e)=>To(t,"name",{value:e,configurable:!0}),"e$1");const Ro=fe(()=>!!process.versions.electron,"isElectronApp"),Do=fe(()=>Ro()&&!process.defaultApp,"isBundledElectronApp"),Bo=fe(()=>Do()?0:1,"getProcessArgvBinIndex"),zo=fe(t=>t.slice(Bo()+1),"hideBin");var Wo=Object.defineProperty,_t=b((t,e)=>Wo(t,"name",{value:e,configurable:!0}),"s$2");const Fo=" ",qo=_t((t,e)=>t===e?!0:t.length!==e.length?!1:t.every((n,a)=>n===e[a]),"equals"),Go=_t(t=>{if(typeof t=="string")return t.split(Fo);const e=Ae();return qo(t,e)?zo(t):t},"parseRawCommand");var Ho=Object.defineProperty,be=b((t,e)=>Ho(t,"name",{value:e,configurable:!0}),"r");const Ko=be(t=>{const e=be(i=>{t.error(`Uncaught exception: ${i.message||i}`),i.stack&&t.error(i.stack),ie(1)},"uncaughtExceptionHandler"),n=be((i,c)=>{if(i instanceof Error)t.error(`Promise rejection: ${i.message||i}`),i.stack&&t.error(i.stack);else{let s;if(typeof i=="string")s=i;else try{s=JSON.stringify(i)}catch{s=String(i)}t.error(`Promise rejection: ${s}`)}ie(1)},"unhandledRejectionHandler"),a=je("uncaughtException",e),r=je("unhandledRejection",n);return()=>{a(),r()}},"registerExceptionHandler");var Yo=Object.defineProperty,K=b((t,e)=>Yo(t,"name",{value:e,configurable:!0}),"e");const ae=100,ke=K((t,e)=>{if(typeof t!="string"||t.trim().length===0)throw new P(`${e} must be a non-empty string`,"INVALID_INPUT",{fieldName:e,value:t});return t.trim()},"validateNonEmptyString"),Ye=K((t,e)=>{if(!Array.isArray(t)||!t.every(n=>typeof n=="string"))throw new P(`${e} must be an array of strings`,"INVALID_INPUT",{fieldName:e,value:t});return t},"validateStringArray");K((t,e)=>{if(typeof t!="function")throw new P(`${e} must be a function`,"INVALID_INPUT",{fieldName:e,value:t});return t},"validateFunction");const $e=K((t,e)=>{if(typeof t!="object"||t===null)throw new P(`${e} must be an object`,"INVALID_INPUT",{fieldName:e,value:t});return t},"validateObject"),ee=K(t=>{const e=ke(t,"Command name");if(e.length>ae)throw new P(`Command name is too long (maximum ${ae} characters)`,"INVALID_COMMAND_NAME",{commandName:e,length:e.length});if(e.includes("..")||e.includes("/")||e.includes("\\")||e.includes(";")||e.includes("|")||e.includes("&"))throw new P(`Command name "${e}" contains invalid characters`,"INVALID_COMMAND_NAME",{commandName:e});if(!/^[a-z][\w-]*$/i.test(e))throw new P(`Command name "${e}" must start with a letter and contain only letters, numbers, hyphens, and underscores`,"INVALID_COMMAND_NAME",{commandName:e});return e},"validateCommandName");K(t=>{const e=ke(t,"Plugin name");if(e.length>ae)throw new P(`Plugin name is too long (maximum ${ae} characters)`,"INVALID_PLUGIN_NAME",{length:e.length,pluginName:e});if(e.includes("..")||e.includes("/")||e.includes("\\")||e.includes(";")||e.includes("|")||e.includes("&"))throw new P(`Plugin name "${e}" contains invalid characters`,"INVALID_PLUGIN_NAME",{pluginName:e});if(!/^[a-z][\w-]*$/i.test(e))throw new P(`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 Jo=Object.defineProperty,he=b((t,e)=>Jo(t,"name",{value:e,configurable:!0}),"s");const Zo=new Set([`
|
|
4
|
-
`,"\r"," ","\0",'"',"$","&","'","(",")",";","<",">","[","\\","]","`","{","|","}"]),Qo=he(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 10000 characters)");for(const e of t)if(Zo.has(e))throw new Error(`Argument contains dangerous character: ${e}`);return t.trim()},"sanitizeArgument"),Je=he(t=>{if(!Array.isArray(t))throw new TypeError("Arguments must be an array");if(t.length>100)throw new Error("Too many arguments (maximum 100)");return t.map(e=>Qo(e))},"sanitizeArguments");he(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("/")||/^[A-Z]:/i.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 vr{static{b(this,"RateLimiter")}static{he(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(),a=this.attempts.get(e);return!a||n>a.resetTime?(this.attempts.set(e,{count:1,resetTime:n+this.windowMs}),this.cleanup(n),!0):a.count>=this.maxAttempts?!1:(a.count+=1,!0)}reset(e){this.attempts.delete(e)}cleanup(e){for(const[n,a]of this.attempts.entries())e>a.resetTime&&this.attempts.delete(n)}}var Xo=Object.defineProperty,ne=b((t,e)=>Xo(t,"name",{value:e,configurable:!0}),"_");const er=/^-([^\d-])$/,tr=/^--(\S+)/,nr=/^-([^\d-]{2,})$/,Oe=ne(t=>er.test(t)||tr.test(t)||nr.test(t),"isOption");class yr{static{b(this,"Cli")}static{ne(this,"Cli")}#t;#e;#o;#c;#g;#u;#v;#r;#n;#i;#p;#s;#l;#f=!1;#y;#w=!1;#h;#d;#m;#A(){return this.#h===void 0&&(this.#h=[...this.#i.keys()]),this.#h}#b(){return this.#d===void 0&&(this.#d=[...this.#n.keys()]),this.#d}#a(){return this.#m===void 0&&(this.#m=[...this.#A(),...this.#b()]),this.#m}#E(){this.#h=void 0,this.#d=void 0,this.#m=void 0}#$(){if(this.#o===void 0){const e=Go(this.#e.argv);this.#o=Je(e),this.#P()}return this.#o}#P(){if(!this.#o)return;const e=q();let n=!1;for(const a of this.#o){if(a==="--quiet"||a==="-q"){e.CEREBRO_OUTPUT_LEVEL=String(Rt),n=!0;break}if(a==="--verbose"||a==="-v"){e.CEREBRO_OUTPUT_LEVEL=String(Dt),n=!0;break}if(a==="--debug"||a==="-vvv"){e.CEREBRO_OUTPUT_LEVEL=String(W),n=!0;break}}n||(e.CEREBRO_OUTPUT_LEVEL=Object.hasOwn(e,"DEBUG")?String(W):String(Ne))}#C(){this.#w||(this.#y=Ko(this.#t),this.#w=!0)}#O(e,n,a,r){this.#t.debug(`command '${r}' found, parsing command args: ${n.join(", ")}`);const{arguments_:i,booleanValues:c,parsedArgs:s}=Si(e,n,Vt),g=Object.keys(c).length>0?{...s,_all:{...s._all,...c}}:s;Fi(i,g,e);const o=Ii(e,s,c,a);o.runtime=this,o.argv=this.#$();const p=e.options&&e.options.length>0;if(p&&e.options){const u=e.options.filter(l=>l.name.startsWith("no-"));for(const l of u){const d=l.name.replace("no-",""),y=`--${l.name}`,v=`--${d}`,$=n.includes(y),C=n.includes(v);if($&&C)throw new Ze(d,l.name)}}return p&&(Mo(o,e),Vo(o,e)),qi(i,o.options,e),q().CEREBRO_OUTPUT_LEVEL===String(W)&&(this.#t.debug("command options parsed from options:"),this.#t.debug(JSON.stringify(o.options,null,2)),this.#t.debug("command argument parsed from argument:"),this.#t.debug(JSON.stringify(o.argument,null,2))),{arguments_:i,booleanValues:c,commandArgs:g,parsedArgs:s,toolbox:o}}constructor(e,n={}){if(typeof e!="string"||e.trim().length===0)throw new P("CLI name must be a non-empty string","INVALID_INPUT",{cliName:e});this.#g=e.trim();const a=n.argv??Ae(),r=n.cwd??Bt();if(this.#e={...n,argv:a,cwd:r},this.#e.argv&&!Array.isArray(this.#e.argv))throw new P("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 P("CLI cwd option must be a string","INVALID_INPUT",{cwd:this.#e.cwd});if(this.#e.packageName&&typeof this.#e.packageName!="string")throw new P("CLI packageName option must be a string","INVALID_INPUT",{packageName:this.#e.packageName});if(this.#e.packageVersion&&typeof this.#e.packageVersion!="string")throw new P("CLI packageVersion option must be a string","INVALID_INPUT",{packageVersion:this.#e.packageVersion});const i=q();if(i.CEREBRO_OUTPUT_LEVEL=String(Ne),typeof this.#e.logger=="object"){const c=["debug","error","info","log","warn"],s=[],g=this.#e.logger;for(const o of c)typeof g[o]!="function"&&s.push(o);if(s.length>0)throw new P(`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:ne((...c)=>{i.CEREBRO_OUTPUT_LEVEL===String(W)&&console.debug(...c)},"debug")};this.#u=this.#e.packageVersion,this.#v=this.#e.packageName,this.#c=this.#e.cwd,this.#s="help",this.#l={},this.#n=new Map,this.#i=new Map,this.#p=new Map}setCommandSection(e){return this.#l=e,this}getCommandSection(){return this.#l.header||(this.#l.header=`${this.#g}${this.#u?` v${this.#u}`:""}`),this.#l}setDefaultCommand(e){return this.#s=e,this}get defaultCommand(){return this.#s}addCommand(e){$e(e,"Command"),ee(e.name),e.alias&&(typeof e.alias=="string"?ee(e.alias):Ye(e.alias,"Command alias").forEach(r=>ee(r))),e.argument&&$e(e.argument,"Command argument"),e.options&&$e(e.options,"Command options"),e.commandPath&&(Ye(e.commandPath,"Command commandPath"),e.commandPath.forEach(r=>{ee(r)}));const n=Yi(e.name,e.commandPath),a=J(n);if(this.#i.has(a))throw new P(`Command with path "${a}" already exists`,"DUPLICATE_COMMAND",{commandName:e.name,commandPath:e.commandPath});if(this.#n.has(e.name)&&!e.commandPath)throw new P(`Command with name "${e.name}" already exists`,"DUPLICATE_COMMAND",{commandName:e.name});if(e.options)for(const r of e.options)rn(r);if(Gi(e),Uo(e),So(e),e.options&&(e.__conflictingOptions__=e.options.filter(r=>r.conflicts!==void 0),e.__requiredOptions__=e.options.filter(r=>r.required===!0)),this.#n.set(e.name,e),this.#i.set(a,n),this.#p.set(a,e),this.#E(),e.alias!==void 0){const r=typeof e.alias=="string"?[e.alias]:e.alias;for(const i of r){if(q().CEREBRO_OUTPUT_LEVEL===String(W)&&this.#t.debug("adding alias",i),this.#n.has(i))throw new P(`Command alias "${i}" conflicts with existing command`,"DUPLICATE_COMMAND",{alias:i,commandName:e.name});this.#n.set(i,e)}}return this}addPlugin(e){return this.getPluginManager().register(e),this}getPluginManager(){return this.#r?this.#r:(this.#r=new en(this.#t),this.#r.register({description:"Attaches the logger to the toolbox",execute:ne(e=>{e.logger=this.#t},"execute"),name:"logger"}),this.#r)}getCliName(){return this.#g}getPackageVersion(){return this.#u}getPackageName(){return this.#v}getCommands(){return this.#n}getCwd(){return this.#c}dispose(){this.#y?.()}async run(e={}){const{autoDispose:n=!0,shouldExitProcess:a=!0,...r}=e;this.#n.has("help")||this.addCommand(new Tt(this.#n));const i=this.#b(),c=this.#i;this.#C();const s=this.#$();let g,o=[...s];const p=zt(),u=Wt(),l=Ae();this.#t.debug(`process.execPath: ${p}`),this.#t.debug(`process.execArgv: ${u.join(" ")}`),this.#t.debug(`process.argv: ${l.join(" ")}`);const d=Ki(c,[...s]);if(d.commandPath)g=d.commandPath,o=d.argv;else{if(s.length>1&&s[0]&&s[1]&&!Oe(s[0])&&!Oe(s[1])){const w=[];let A=0;for(;A<s.length;){const O=s[A];if(!O||Oe(O))break;w.push(O),A+=1}const j=J(w);if(w[0]&&!i.includes(w[0])){const O=this.#a(),I=F(j,O);throw new D(j,I)}}let m;try{m=fn([null,...i],[...s])}catch(w){if(w instanceof Error&&w.name==="INVALID_COMMAND"&&"command"in w){const A=w.command,j=this.#a(),O=F(A,j);throw new D(A,O)}throw w}m.command&&(g=[m.command],o=m.argv)}if(!g)if(this.#s)g=[this.#s];else{const m=this.#a();throw new D("",m)}const y=J(g),v=this.#i.get(y);let $;if(v){if($=this.#p.get(y),!$||J(v)!==y){const m=this.#a(),w=F(y,m);throw new D(y,w)}}else{const m=g[g.length-1];if($=m?this.#n.get(m):void 0,!$){const w=this.#a(),A=F(y,w);throw new D(y,A)}}if(typeof $.execute!="function")return this.#t.error(`Command "${$.name}" has no function to execute.`),a?ie(1):void 0;const C=o,{commandArgs:k,toolbox:f}=this.#O($,C,r,y),h=this.getPluginManager();try{!this.#f&&h.hasPlugins()&&(await h.init({cli:this,cwd:this.#c,logger:this.#t}),this.#f=!0),await h.executeLifecycle("execute",f),await h.executeLifecycle("beforeCommand",f);let m;if(k.global?.help){const w=this.#n.get("help");if(!w)throw new P("Help command not found","COMMAND_NOT_FOUND");m=await B(w,f,k)}else if(k.global?.version||k.global?.V){const w=this.#n.get("version");if(!w)throw new P("Version command not found","COMMAND_NOT_FOUND");m=await B(w,f,k)}else m=await B($,f,k);return await h.executeLifecycle("afterCommand",f,m),a?ie(0):void 0}catch(m){throw await h.executeErrorHandlers(m,f),m}finally{n&&this.dispose()}}async runCommand(e,n={}){const{argv:a=[],...r}=n;ke(e,"Command name");const i=e.split(" ").filter(Boolean),c=J(i),s=this.#i.get(c)?this.#p.get(c):this.#n.get(e);if(!s){const l=this.#a(),d=F(c||e,l);throw new D(e,d)}if(typeof s.execute!="function")throw new P(`Command "${s.name}" has no function to execute`,"INVALID_COMMAND",{commandName:s.name});const g=[...Je(a)];this.#t.debug(`running command '${e}' programmatically with args: ${g.join(", ")}`);const{commandArgs:o,toolbox:p}=this.#O(s,g,r,c||e),u=this.getPluginManager();try{!this.#f&&u.hasPlugins()&&(await u.init({cli:this,cwd:this.#c,logger:this.#t}),this.#f=!0),await u.executeLifecycle("execute",p),await u.executeLifecycle("beforeCommand",p);let l;if(o.global?.help){const d=this.#n.get("help");if(!d)throw new P("Help command not found","COMMAND_NOT_FOUND");l=await B(d,p,o)}else if(o.global?.version||o.global?.V){const d=this.#n.get("version");if(!d)throw new P("Version command not found","COMMAND_NOT_FOUND");l=await B(d,p,o)}else l=await B(s,p,o);return await u.executeLifecycle("afterCommand",p,l),l}catch(l){throw await u.executeErrorHandlers(l,p),l}}}export{yr as Cli};
|