@visulima/cerebro 2.0.3 → 2.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. package/CHANGELOG.md +39 -0
  2. package/LICENSE.md +2375 -8
  3. package/README.md +279 -24
  4. package/dist/cli.d.ts +203 -0
  5. package/dist/commands/completion-command.d.ts +6 -6
  6. package/dist/commands/help-command.d.ts +6 -8
  7. package/dist/commands/help-command.js +1 -1
  8. package/dist/commands/readme-command.d.ts +6 -6
  9. package/dist/commands/version-command.d.ts +3 -6
  10. package/dist/constants.d.ts +29 -0
  11. package/dist/default-env.d.ts +7 -0
  12. package/dist/default-options.d.ts +3 -0
  13. package/dist/empty-toolbox.d.ts +15 -0
  14. package/dist/errors/cerebro-error.d.ts +10 -0
  15. package/dist/errors/command-not-found-error.d.ts +9 -0
  16. package/dist/errors/command-validation-error.d.ts +10 -0
  17. package/dist/errors/completion-error.d.ts +9 -0
  18. package/dist/errors/conflicting-options-error.d.ts +10 -0
  19. package/dist/errors/plugin-error.d.ts +9 -0
  20. package/dist/errors/update-notifier-error.d.ts +7 -0
  21. package/dist/index.d.ts +94 -50
  22. package/dist/index.js +1 -1
  23. package/dist/logger/create-pail-logger.d.ts +8 -5
  24. package/dist/logger/create-pail-logger.js +1 -1
  25. package/dist/packem_chunks/has-new-version.js +1 -1
  26. package/dist/packem_shared/{Cerebro-C23kXfEn.js → Cerebro-BqHqYEQJ.js} +3 -3
  27. package/dist/packem_shared/{help-command-C_CdZQSd.js → help-command-Ddt6rdio.js} +1 -1
  28. package/dist/plugin-manager.d.ts +53 -0
  29. package/dist/plugins/error-handler-plugin.d.ts +16 -10
  30. package/dist/plugins/runtime-version-check-plugin.d.ts +15 -10
  31. package/dist/plugins/update-notifier/cache.d.ts +11 -0
  32. package/dist/plugins/update-notifier/get-distribution-version.d.ts +2 -0
  33. package/dist/plugins/update-notifier/has-new-version.d.ts +14 -0
  34. package/dist/plugins/update-notifier/update-notifier-plugin.d.ts +9 -21
  35. package/dist/types/cli.d.ts +105 -0
  36. package/dist/types/command-line-usage.d.ts +37 -0
  37. package/dist/types/command.d.ts +136 -0
  38. package/dist/types/option-types.d.ts +83 -0
  39. package/dist/types/options.d.ts +4 -0
  40. package/dist/types/plugin.d.ts +53 -0
  41. package/dist/types/toolbox.d.ts +96 -0
  42. package/dist/util/arg-processing/get-boolean-values.d.ts +7 -0
  43. package/dist/util/arg-processing/get-parameter-option.d.ts +7 -0
  44. package/dist/util/arg-processing/map-option-type-label.d.ts +3 -0
  45. package/dist/util/arg-processing/option-is-boolean.d.ts +9 -0
  46. package/dist/util/arg-processing/remove-boolean-values.d.ts +9 -0
  47. package/dist/util/command-line-commands.d.ts +10 -0
  48. package/dist/util/command-line-usage/get-terminal-width.d.ts +7 -0
  49. package/dist/util/command-line-usage/index.d.ts +3 -0
  50. package/dist/util/command-line-usage/section/base-section.d.ts +8 -0
  51. package/dist/util/command-line-usage/section/content-section.d.ts +65 -0
  52. package/dist/util/command-line-usage/section/option-list-section.d.ts +44 -0
  53. package/dist/util/command-processing/command-processor.d.ts +37 -0
  54. package/dist/util/command-processing/command-validation.d.ts +17 -0
  55. package/dist/util/command-processing/nested-command-parser.d.ts +25 -0
  56. package/dist/util/command-processing/option-processor.d.ts +44 -0
  57. package/dist/util/data-processing/list-missing-arguments.d.ts +15 -0
  58. package/dist/util/data-processing/merge-arguments.d.ts +7 -0
  59. package/dist/util/general/find-alternatives.d.ts +8 -0
  60. package/dist/util/general/hide-bin.d.ts +2 -0
  61. package/dist/util/general/parse-raw-command.d.ts +7 -0
  62. package/dist/util/general/register-exception-handler.d.ts +9 -0
  63. package/dist/util/general/runtime-process.d.ts +65 -0
  64. package/dist/util/general/semver-gt.d.ts +2 -0
  65. package/dist/util/general/validate-input.d.ts +24 -0
  66. package/dist/util/process-env-variables.d.ts +9 -0
  67. package/dist/util/security.d.ts +58 -0
  68. package/dist/util/text-processing/template-format.d.ts +5 -0
  69. package/package.json +6 -6
  70. package/dist/packem_shared/index.d-BkzZomTF.d.ts +0 -65
  71. package/dist/packem_shared/plugin-manager-BjEuiNxv.d.ts +0 -147
@@ -1,4 +1,4 @@
1
- var _t=Object.defineProperty;var b=(t,e)=>_t(t,"name",{value:e,configurable:!0});import{createRequire as Lt}from"node:module";import{o as Ut,O as Mt}from"./help-command-C_CdZQSd.js";import{VERBOSITY_DEBUG as W,POSITIONALS_KEY as te,VERBOSITY_QUIET as Vt,VERBOSITY_VERBOSE as Tt,VERBOSITY_NORMAL as Ne}from"./VERBOSITY_QUIET-XPultrIA.js";import{c as E}from"./cerebro-error-BnJTixb2.js";import{d as q,f as Pe,e as ie,o as je,a as Rt,h as Dt,i as Bt}from"./runtime-process-G-n-wOub.js";import{distance as zt}from"fastest-levenshtein";const It=Lt(import.meta.url),Y=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,St=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 It(t)},"__cjs_getBuiltinModule"),{createRequire:Wt}=St("node:module");var Ft=Object.defineProperty,qt=b((t,e)=>Ft(t,"name",{value:e,configurable:!0}),"t$9");let D=class extends E{static{b(this,"a")}static{qt(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 Gt=Object.defineProperty,Ht=b((t,e)=>Gt(t,"name",{value:e,configurable:!0}),"e$7");let Kt=class extends E{static{b(this,"o")}static{Ht(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 Yt=Object.defineProperty,xe=b((t,e)=>Yt(t,"name",{value:e,configurable:!0}),"d$4");let Jt=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 Kt(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 Zt=Object.defineProperty,Qt=b((t,e)=>Zt(t,"name",{value:e,configurable:!0}),"n$c");const X=Qt(t=>t.type?.name==="Boolean","optionIsBoolean");var Xt=Object.defineProperty,Ze=b((t,e)=>Xt(t,"name",{value:e,configurable:!0}),"p$b");const en=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"),tn=Ze(t=>(X(t)||(t.typeLabel=t.typeLabel??en(t),t.defaultOption&&(t.typeLabel=`${t.typeLabel} (D)`),t.required&&(t.typeLabel=`${t.typeLabel} (R)`)),t),"mapOptionTypeLabel");var nn=Object.defineProperty,Qe=b((t,e)=>nn(t,"name",{value:e,configurable:!0}),"e$5");const an=new RegExp(/^-([^\d-])$/),on=new RegExp(/^--(\S+)/),rn=new RegExp(/^-([^\d-]{2,})$/),sn=Qe(t=>an.test(t)||on.test(t)||rn.test(t),"isOption"),ln=Qe((t,e)=>{const n=e[0]&&sn(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 cn=Object.defineProperty,Xe=b((t,e)=>cn(t,"name",{value:e,configurable:!0}),"i$a"),un=Object.defineProperty,et=Xe((t,e)=>un(t,"name",{value:e,configurable:!0}),"i"),pn=Object.defineProperty,tt=et((t,e)=>pn(t,"name",{value:e,configurable:!0}),"s"),fn=Object.defineProperty,nt=tt((t,e)=>fn(t,"name",{value:e,configurable:!0}),"i"),dn=Object.defineProperty,it=nt((t,e)=>dn(t,"name",{value:e,configurable:!0}),"t");it(t=>t instanceof Error&&t.type==="VisulimaError","isVisulimaError");class oe extends Error{static{b(this,"v")}static{Xe(this,"g")}static{et(this,"p")}static{tt(this,"V")}static{nt(this,"VisulimaError")}static{it(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 hn=Object.defineProperty,at=b((t,e)=>hn(t,"name",{value:e,configurable:!0}),"o$c"),mn=Object.defineProperty,ot=at((t,e)=>mn(t,"name",{value:e,configurable:!0}),"o"),gn=Object.defineProperty,vn=ot((t,e)=>gn(t,"name",{value:e,configurable:!0}),"i");let yn=class rt extends oe{static{b(this,"a")}static{at(this,"a")}static{ot(this,"t")}static{vn(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,rt.prototype)}};var wn=Object.defineProperty,st=b((t,e)=>wn(t,"name",{value:e,configurable:!0}),"t$7"),bn=Object.defineProperty,lt=st((t,e)=>bn(t,"name",{value:e,configurable:!0}),"e"),$n=Object.defineProperty,On=lt((t,e)=>$n(t,"name",{value:e,configurable:!0}),"e");let _e=class ct extends oe{static{b(this,"n")}static{st(this,"n")}static{lt(this,"o")}static{On(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,ct.prototype)}};var Pn=Object.defineProperty,ut=b((t,e)=>Pn(t,"name",{value:e,configurable:!0}),"a$6"),An=Object.defineProperty,pt=ut((t,e)=>An(t,"name",{value:e,configurable:!0}),"a"),En=Object.defineProperty,Cn=pt((t,e)=>En(t,"name",{value:e,configurable:!0}),"o");let kn=class ft extends oe{static{b(this,"n")}static{ut(this,"o")}static{pt(this,"e")}static{Cn(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,ft.prototype)}};var Nn=Object.defineProperty,dt=b((t,e)=>Nn(t,"name",{value:e,configurable:!0}),"i$7"),jn=Object.defineProperty,ht=dt((t,e)=>jn(t,"name",{value:e,configurable:!0}),"i"),xn=Object.defineProperty,_n=ht((t,e)=>xn(t,"name",{value:e,configurable:!0}),"i");let x=class mt extends oe{static{b(this,"a")}static{dt(this,"o")}static{ht(this,"e")}static{_n(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,mt.prototype)}};var Ln=Object.defineProperty,In=b((t,e)=>Ln(t,"name",{value:e,configurable:!0}),"T$1"),Sn=Object.defineProperty,H=In((t,e)=>Sn(t,"name",{value:e,configurable:!0}),"P"),Un=Object.defineProperty,re=H((t,e)=>Un(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"),Mn=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 Vn=Object.defineProperty,Tn=H((t,e)=>Vn(t,"name",{value:e,configurable:!0}),"e");const N=Tn((t,e,n,...a)=>{t&&console.debug(`[command-line-args:${n}] ${e}`,...a)},"debug");var Rn=Object.defineProperty,T=H((t,e)=>Rn(t,"name",{value:e,configurable:!0}),"A");const Dn=/-([a-z])/g,me=T(t=>t===Boolean||typeof t=="function"&&t.name?.startsWith("Boolean"),"isBooleanType"),Bn=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"),zn=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"),Wn=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 d=f.name.replaceAll(Dn,(h,w)=>w.toUpperCase());o.set(f.name,d),p.set(d,f.name)}const u={},l={},m=[],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 d=t[f];if(d.kind==="option-terminator"){u._unknown=a.slice(d.index),v=!0;break}if(d.kind==="option"&&d.name){let h=zn(d.name,i,c,s,g);if(!h&&d.value===void 0&&k&&/^\d+$/.test(d.name)){const O=e.find(I=>I.type===Number);O&&(h=O,d.value=d.name,d.name=O.name)}const w=h?h.name:d.name,P=h&&h.multiple,j=h&&h.lazyMultiple;if(l[w]!==void 0&&!P&&!j&&!n.partial)throw new yn(w);if(!h&&n.partial){const O=d.rawName||`--${d.name}${d.value!==void 0&&d.inlineValue?`=${d.value}`:""}`;m.push({index:d.index,value:O});continue}if(!h&&n.stopAtFirstUnknown){u._unknown=a.slice(d.index);break}if(!h&&!n.partial)throw new _e(d.name);if(d.value===void 0){const O=t[f+1],I=O&&O.kind==="option"&&!("name"in O)&&O.value!==void 0,L=O&&h&&!(h.type&&me(h.type))&&(O.kind==="positional"||I),xt=h&&h.defaultOption&&!h.multiple&&!h.lazyMultiple;if(L&&(!h?.defaultOption||xt))if(P){let S=f+1;const he=[];for(;S<t.length&&(t[S].kind==="positional"||t[S].kind==="option"&&!("name"in t[S])&&t[S].value!==void 0);)he.push(t[S].value),y.add(t[S].index),S++;l[w]=l[w]===void 0?he:Ue(l[w],he),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 h&&h.type&&me(h.type)?Ve(l,w,!0,P):l[w]=P?[]:null}else{let{value:O}=d;if(h&&h.type&&me(h.type))switch(O){case"":{if(n.partial)l._unknown||(l._unknown=[]),l._unknown.push(`${d.rawName||`--${d.name}`}${d.value?`=${d.value}`:""}`),O=!0;else throw new _e(d.name);break}case"false":{O=!1;break}case"true":{O=!0;break}default:O=!0}const I=O===void 0?[]:[O];if(P){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]=P||j?I:O:P||j?l[w]=Ue(l[w],I):l[w]=O}}else if(d.kind==="positional"&&n.stopAtFirstUnknown&&!y.has(d.index)){N(r,`Found unconsumed positional token at index ${d.index}, stopping processing`,"resolver"),u._unknown=a.slice(d.index);break}}for(const[f,d]of Object.entries(l)){const h=i.get(f);h&&(h.multiple||h.lazyMultiple)&&!Array.isArray(d)&&(l[f]=[d])}if($){const f=[],d=[];for(const h of t)h.kind==="positional"&&!y.has(h.index)&&(f.push(h.value),d.push(h));if(f.length>0){const h=l[$.name],w=$.multiple||$.lazyMultiple;h===void 0?w?(d.forEach(P=>y.add(P.index)),l[$.name]=f):(y.add(d[0].index),l[$.name]=f[0]):w&&(d.forEach(P=>y.add(P.index)),l[$.name]=Array.isArray(h)?[...f,...h]:[...f,h])}}if(!n.partial){for(const f of t)if(f.kind==="positional"&&!y.has(f.index))throw new kn(a[f.index])}if(n.partial&&!n.stopAtFirstUnknown){const f=[...m];if(l._unknown){const d=new Map;for(const[h,w]of a.entries())d.set(w,h);for(const h of l._unknown){const w=d.get(h);w!==void 0&&f.push({index:w,value:h})}}for(const d of t)d.kind==="positional"&&!y.has(d.index)&&f.push({index:d.index,value:a[d.index]});f.length>0&&(f.sort((d,h)=>d.index-h.index),u._unknown=f.map(d=>d.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()||""))),d=t.findIndex(w=>w.kind==="positional"&&!y.has(w.index));let h=-1;if(f!==-1&&d!==-1?h=Math.min(f,d):f!==-1?h=f:d!==-1&&(h=d),h>=0){const w=t[h].index;u._unknown=a.slice(w)}}else m.length>0&&!n.partial&&(u._unknown=m.map(f=>f.value));for(const[f,d]of Object.entries(l)){const h=n.camelCase&&o?.get(f)||f,w=i.get(f);u[h]=w&&w.type?Mn(d,w.type):d===void 0?null:d}for(const f of e){const d=n.camelCase&&o?.get(f.name)||f.name;!(d in u)&&f.defaultValue!==void 0&&(f.multiple||f.lazyMultiple?u[d]=Array.isArray(f.defaultValue)?[...f.defaultValue]:[f.defaultValue]:u[d]=f.defaultValue)}if(C){const f={},d={},h={};for(const P of e)if(P.group){const j=Array.isArray(P.group)?P.group:[P.group];for(const O of j)Me(O)||f[O]||(f[O]={})}for(const P of Object.keys(u))if(!Bn(P)){d[P]=u[P];let j=P;n.camelCase&&(j=p?.get(P)||P);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][P]=u[P])}else h[P]=u[P]}const w={_all:d};for(const[P,j]of Object.entries(f))w[P]=j;Object.keys(h).length>0&&(w._none=h),u._unknown&&(w._unknown=u._unknown),Object.keys(u).forEach(P=>delete u[P]),Object.assign(u,w)}return N(r,"Final parsed result:","resolver",u),u},"resolveArgs");var Fn=Object.defineProperty,R=H((t,e)=>Fn(t,"name",{value:e,configurable:!0}),"l");const V="-".codePointAt(0),M="=",qn=M.codePointAt(0),Gn="--",Hn="-",Kn="--",gt=R(t=>t.length>2&&t.startsWith(Kn),"hasLongOptionPrefix"),Yn=R(t=>gt(t)&&!t.includes(M,3),"isLongOption"),Jn=R(t=>gt(t)&&t.includes(M,3),"isLongOptionAndValue"),Zn=R(t=>t!==void 0&&t.length>0&&t.codePointAt(0)!==V,"hasOptionValue"),Qn=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"),Xn=R(t=>!(t.length<=2||t.codePointAt(0)!==V||t.codePointAt(1)===V),"isShortOptionGroup"),ei=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===Gn){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(Qn(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&&Zn(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(Xn(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)===qn?o=!0:s.push(`${Hn}${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(Yn(i)){const s=i.slice(2);e.push({index:a,kind:"option",name:s,rawName:i});continue}if(Jn(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 ti=Object.defineProperty,Ee=H((t,e)=>ti(t,"name",{value:e,configurable:!0}),"d");const ni=Ee(t=>t&&(t===Boolean||typeof t=="function"&&t.name?.startsWith("Boolean")),"isBooleanType"),ii=Ee(t=>typeof t=="function","isValidCustomTypeFunction"),ai=Ee((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&&ni(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"&&ii(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 oi=Object.defineProperty,ri=H((t,e)=>oi(t,"name",{value:e,configurable:!0}),"g");const si=ri((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),ai(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 m=u.toLowerCase();return l===void 0?`-${m}`:`-${m}=${l}`}return o}));const s=ei((c??i??[]).map(String));N(n,"Tokenized arguments:","index",s);const g=Wn(s,r,a,i??[]);return N(n,"Command-line-args parsing completed","index"),g},"commandLineArgs");var li=Object.defineProperty,ci=b((t,e)=>li(t,"name",{value:e,configurable:!0}),"m$4");let ui=class{static{b(this,"a")}static{ci(this,"EmptyToolbox")}result;argv;options;argument;command;commandName;env;logger;runtime;constructor(e,n){this.commandName=e,this.command=n}};var pi=Object.defineProperty,fi=b((t,e)=>pi(t,"name",{value:e,configurable:!0}),"f$3");const di=/^-{1,2}(\w+)(=(.+))?$/,vt=fi((t,e,n,a)=>{const r=di.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 hi=Object.defineProperty,Ae=b((t,e)=>hi(t,"name",{value:e,configurable:!0}),"e$4");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"),mi=new Set(["0","1","false","true"]),gi=Ae((t,e,n,a)=>{if(e.length===0||t.length===0)return{};const r=Ae((i,c)=>{const{argName:s,argValue:g,option:o}=vt(c,e,n,a),{lastOption:p}=i;return o&&X(o)&&g&&s?i.partial[s]=Te(g,o):i.lastName&&p&&X(p)&&mi.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 vi=Object.defineProperty,Re=b((t,e)=>vi(t,"name",{value:e,configurable:!0}),"e$3");const yi=new Set(["0","1","false","true"]),wi=Re((t,e,n,a)=>{if(e.length===0||t.length===0)return t;const r=Re((i,c)=>{const{argValue:s,option:g}=vt(c,e,n,a),{lastOption:o}=i;if(o&&X(o)&&yi.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 bi=Object.defineProperty,$i=b((t,e)=>bi(t,"name",{value:e,configurable:!0}),"o$9");const De=$i(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 Oi=Object.defineProperty,se=b((t,e)=>Oi(t,"name",{value:e,configurable:!0}),"o$8");const Pi=se(t=>{if(t===void 0)return;const e=t.toLowerCase().trim();return e==="true"||e==="1"||e==="yes"||e==="on"},"transformBooleanEnv"),Ai=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 Pi(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"),Ei=se(t=>t.toLowerCase().replaceAll(/_./g,e=>e[1]?.toUpperCase()??e).replace(/^[A-Z]/,e=>e.toLowerCase()),"toCamelCase"),Ci=se(t=>{if(!t||t.length===0)return{};const e={},n=q();for(const a of t){const r=n[a.name],i=Ai(a,r),c=i===void 0?a.defaultValue:i,s=Ei(a.name);e[s]=c}return e},"processEnvVariables");var ki=Object.defineProperty,le=b((t,e)=>ki(t,"name",{value:e,configurable:!0}),"l$b");const Ni=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"),ji=le((t,e,n,a)=>{const r=new ui(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=Ci(t.env),r},"prepareToolbox"),xi=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}=Ni(a);c=wi(e,a,p,o),s=gi(e,a,p,o)}else c=e,s={};const g=si(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 _i=Object.defineProperty,Li=b((t,e)=>_i(t,"name",{value:e,configurable:!0}),"n$7");let Ii=class extends E{static{b(this,"s")}static{Li(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 Si=Object.defineProperty,Ui=b((t,e)=>Si(t,"name",{value:e,configurable:!0}),"e$2");let Mi=class extends E{static{b(this,"o")}static{Ui(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 Vi=Object.defineProperty,Ti=b((t,e)=>Vi(t,"name",{value:e,configurable:!0}),"t$5");const Be=Ti((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 Ri=Object.defineProperty,yt=b((t,e)=>Ri(t,"name",{value:e,configurable:!0}),"n$5");const Di=yt((t,e)=>e.includes(t)?!0:Math.abs(t.length-e.length)>t.length/2?!1:zt(t,e)<=t.length/3,"isSimilar"),F=yt((t,e)=>{const n=t.toLowerCase();return e.filter(a=>Di(a.toLowerCase(),n))},"findAlternatives");var Bi=Object.defineProperty,ce=b((t,e)=>Bi(t,"name",{value:e,configurable:!0}),"a$2");const zi=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(`
1
+ var _t=Object.defineProperty;var b=(t,e)=>_t(t,"name",{value:e,configurable:!0});import{createRequire as Lt}from"node:module";import{o as Ut,A as Mt}from"./help-command-Ddt6rdio.js";import{VERBOSITY_DEBUG as W,POSITIONALS_KEY as te,VERBOSITY_QUIET as Vt,VERBOSITY_VERBOSE as Tt,VERBOSITY_NORMAL as ke}from"./VERBOSITY_QUIET-XPultrIA.js";import{c as E}from"./cerebro-error-BnJTixb2.js";import{d as q,f as Pe,e as ie,o as je,a as Rt,h as Dt,i as Bt}from"./runtime-process-G-n-wOub.js";import{distance as zt}from"fastest-levenshtein";const It=Lt(import.meta.url),Y=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,St=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 It(t)},"__cjs_getBuiltinModule"),{createRequire:Wt}=St("node:module");var Ft=Object.defineProperty,qt=b((t,e)=>Ft(t,"name",{value:e,configurable:!0}),"t$9");let D=class extends E{static{b(this,"a")}static{qt(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 Gt=Object.defineProperty,Ht=b((t,e)=>Gt(t,"name",{value:e,configurable:!0}),"e$7");let Kt=class extends E{static{b(this,"o")}static{Ht(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 Yt=Object.defineProperty,xe=b((t,e)=>Yt(t,"name",{value:e,configurable:!0}),"d$4");let Jt=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 Kt(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 Zt=Object.defineProperty,Qt=b((t,e)=>Zt(t,"name",{value:e,configurable:!0}),"n$c");const X=Qt(t=>t.type?.name==="Boolean","optionIsBoolean");var Xt=Object.defineProperty,Ze=b((t,e)=>Xt(t,"name",{value:e,configurable:!0}),"p$b");const en=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"),tn=Ze(t=>(X(t)||(t.typeLabel=t.typeLabel??en(t),t.defaultOption&&(t.typeLabel=`${t.typeLabel} (D)`),t.required&&(t.typeLabel=`${t.typeLabel} (R)`)),t),"mapOptionTypeLabel");var nn=Object.defineProperty,Qe=b((t,e)=>nn(t,"name",{value:e,configurable:!0}),"e$5");const an=new RegExp(/^-([^\d-])$/),on=new RegExp(/^--(\S+)/),rn=new RegExp(/^-([^\d-]{2,})$/),sn=Qe(t=>an.test(t)||on.test(t)||rn.test(t),"isOption"),ln=Qe((t,e)=>{const n=e[0]&&sn(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 cn=Object.defineProperty,Xe=b((t,e)=>cn(t,"name",{value:e,configurable:!0}),"i$a"),un=Object.defineProperty,et=Xe((t,e)=>un(t,"name",{value:e,configurable:!0}),"i"),pn=Object.defineProperty,tt=et((t,e)=>pn(t,"name",{value:e,configurable:!0}),"s"),fn=Object.defineProperty,nt=tt((t,e)=>fn(t,"name",{value:e,configurable:!0}),"i"),hn=Object.defineProperty,it=nt((t,e)=>hn(t,"name",{value:e,configurable:!0}),"t");it(t=>t instanceof Error&&t.type==="VisulimaError","isVisulimaError");class oe extends Error{static{b(this,"v")}static{Xe(this,"g")}static{et(this,"p")}static{tt(this,"V")}static{nt(this,"VisulimaError")}static{it(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 dn=Object.defineProperty,at=b((t,e)=>dn(t,"name",{value:e,configurable:!0}),"o$c"),mn=Object.defineProperty,ot=at((t,e)=>mn(t,"name",{value:e,configurable:!0}),"o"),gn=Object.defineProperty,vn=ot((t,e)=>gn(t,"name",{value:e,configurable:!0}),"i");let yn=class rt extends oe{static{b(this,"a")}static{at(this,"a")}static{ot(this,"t")}static{vn(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,rt.prototype)}};var wn=Object.defineProperty,st=b((t,e)=>wn(t,"name",{value:e,configurable:!0}),"t$7"),bn=Object.defineProperty,lt=st((t,e)=>bn(t,"name",{value:e,configurable:!0}),"e"),$n=Object.defineProperty,On=lt((t,e)=>$n(t,"name",{value:e,configurable:!0}),"e");let _e=class ct extends oe{static{b(this,"n")}static{st(this,"n")}static{lt(this,"o")}static{On(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,ct.prototype)}};var Pn=Object.defineProperty,ut=b((t,e)=>Pn(t,"name",{value:e,configurable:!0}),"a$6"),An=Object.defineProperty,pt=ut((t,e)=>An(t,"name",{value:e,configurable:!0}),"a"),En=Object.defineProperty,Cn=pt((t,e)=>En(t,"name",{value:e,configurable:!0}),"o");let Nn=class ft extends oe{static{b(this,"n")}static{ut(this,"o")}static{pt(this,"e")}static{Cn(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,ft.prototype)}};var kn=Object.defineProperty,ht=b((t,e)=>kn(t,"name",{value:e,configurable:!0}),"i$7"),jn=Object.defineProperty,dt=ht((t,e)=>jn(t,"name",{value:e,configurable:!0}),"i"),xn=Object.defineProperty,_n=dt((t,e)=>xn(t,"name",{value:e,configurable:!0}),"i");let x=class mt extends oe{static{b(this,"a")}static{ht(this,"o")}static{dt(this,"e")}static{_n(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,mt.prototype)}};var Ln=Object.defineProperty,In=b((t,e)=>Ln(t,"name",{value:e,configurable:!0}),"T$1"),Sn=Object.defineProperty,H=In((t,e)=>Sn(t,"name",{value:e,configurable:!0}),"P"),Un=Object.defineProperty,re=H((t,e)=>Un(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"),Mn=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 Vn=Object.defineProperty,Tn=H((t,e)=>Vn(t,"name",{value:e,configurable:!0}),"e");const k=Tn((t,e,n,...a)=>{t&&console.debug(`[command-line-args:${n}] ${e}`,...a)},"debug");var Rn=Object.defineProperty,T=H((t,e)=>Rn(t,"name",{value:e,configurable:!0}),"A");const Dn=/-([a-z])/g,me=T(t=>t===Boolean||typeof t=="function"&&t.name?.startsWith("Boolean"),"isBooleanType"),Bn=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"),zn=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"),Wn=T((t,e,n,a)=>{const r=n.debug||!1;k(r,"resolveArgs called with options:","resolver",{partial:n.partial,stopAtFirstUnknown:n.stopAtFirstUnknown}),k(r,"Starting argument resolution","resolver"),k(r,"Tokens:","resolver",t),k(r,"Definitions:","resolver",e),k(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(Dn,(d,w)=>w.toUpperCase());o.set(f.name,h),p.set(h,f.name)}const u={},l={},m=[],y=new Set;let v=!1;const $=e.find(f=>f.defaultOption),C=e.some(f=>f.group),N=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 d=zn(h.name,i,c,s,g);if(!d&&h.value===void 0&&N&&/^\d+$/.test(h.name)){const O=e.find(I=>I.type===Number);O&&(d=O,h.value=h.name,h.name=O.name)}const w=d?d.name:h.name,P=d&&d.multiple,j=d&&d.lazyMultiple;if(l[w]!==void 0&&!P&&!j&&!n.partial)throw new yn(w);if(!d&&n.partial){const O=h.rawName||`--${h.name}${h.value!==void 0&&h.inlineValue?`=${h.value}`:""}`;m.push({index:h.index,value:O});continue}if(!d&&n.stopAtFirstUnknown){u._unknown=a.slice(h.index);break}if(!d&&!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&&d&&!(d.type&&me(d.type))&&(O.kind==="positional"||I),xt=d&&d.defaultOption&&!d.multiple&&!d.lazyMultiple;if(L&&(!d?.defaultOption||xt))if(P){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 d&&d.type&&me(d.type)?Ve(l,w,!0,P):l[w]=P?[]:null}else{let{value:O}=h;if(d&&d.type&&me(d.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(P){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]=P||j?I:O:P||j?l[w]=Ue(l[w],I):l[w]=O}}else if(h.kind==="positional"&&n.stopAtFirstUnknown&&!y.has(h.index)){k(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 d=i.get(f);d&&(d.multiple||d.lazyMultiple)&&!Array.isArray(h)&&(l[f]=[h])}if($){const f=[],h=[];for(const d of t)d.kind==="positional"&&!y.has(d.index)&&(f.push(d.value),h.push(d));if(f.length>0){const d=l[$.name],w=$.multiple||$.lazyMultiple;d===void 0?w?(h.forEach(P=>y.add(P.index)),l[$.name]=f):(y.add(h[0].index),l[$.name]=f[0]):w&&(h.forEach(P=>y.add(P.index)),l[$.name]=Array.isArray(d)?[...f,...d]:[...f,d])}}if(!n.partial){for(const f of t)if(f.kind==="positional"&&!y.has(f.index))throw new Nn(a[f.index])}if(n.partial&&!n.stopAtFirstUnknown){const f=[...m];if(l._unknown){const h=new Map;for(const[d,w]of a.entries())h.set(w,d);for(const d of l._unknown){const w=h.get(d);w!==void 0&&f.push({index:w,value:d})}}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,d)=>h.index-d.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 d=-1;if(f!==-1&&h!==-1?d=Math.min(f,h):f!==-1?d=f:h!==-1&&(d=h),d>=0){const w=t[d].index;u._unknown=a.slice(w)}}else m.length>0&&!n.partial&&(u._unknown=m.map(f=>f.value));for(const[f,h]of Object.entries(l)){const d=n.camelCase&&o?.get(f)||f,w=i.get(f);u[d]=w&&w.type?Mn(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={},d={};for(const P of e)if(P.group){const j=Array.isArray(P.group)?P.group:[P.group];for(const O of j)Me(O)||f[O]||(f[O]={})}for(const P of Object.keys(u))if(!Bn(P)){h[P]=u[P];let j=P;n.camelCase&&(j=p?.get(P)||P);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][P]=u[P])}else d[P]=u[P]}const w={_all:h};for(const[P,j]of Object.entries(f))w[P]=j;Object.keys(d).length>0&&(w._none=d),u._unknown&&(w._unknown=u._unknown),Object.keys(u).forEach(P=>delete u[P]),Object.assign(u,w)}return k(r,"Final parsed result:","resolver",u),u},"resolveArgs");var Fn=Object.defineProperty,R=H((t,e)=>Fn(t,"name",{value:e,configurable:!0}),"l");const V="-".codePointAt(0),M="=",qn=M.codePointAt(0),Gn="--",Hn="-",Kn="--",gt=R(t=>t.length>2&&t.startsWith(Kn),"hasLongOptionPrefix"),Yn=R(t=>gt(t)&&!t.includes(M,3),"isLongOption"),Jn=R(t=>gt(t)&&t.includes(M,3),"isLongOptionAndValue"),Zn=R(t=>t!==void 0&&t.length>0&&t.codePointAt(0)!==V,"hasOptionValue"),Qn=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"),Xn=R(t=>!(t.length<=2||t.codePointAt(0)!==V||t.codePointAt(1)===V),"isShortOptionGroup"),ei=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===Gn){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(Qn(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&&Zn(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(Xn(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)===qn?o=!0:s.push(`${Hn}${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(Yn(i)){const s=i.slice(2);e.push({index:a,kind:"option",name:s,rawName:i});continue}if(Jn(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 ti=Object.defineProperty,Ee=H((t,e)=>ti(t,"name",{value:e,configurable:!0}),"d");const ni=Ee(t=>t&&(t===Boolean||typeof t=="function"&&t.name?.startsWith("Boolean")),"isBooleanType"),ii=Ee(t=>typeof t=="function","isValidCustomTypeFunction"),ai=Ee((t,e,n)=>{const a=n?.debug||!1;k(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(k(a,"Checking definition:","validation",o),!o.name)throw k(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&&ni(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"&&ii(o.type)))throw new x("Invalid option definition: invalid type")}if(g>1)throw k(a,"Validation failed: multiple defaultOptions not allowed","validation"),new x("Invalid option definition: multiple defaultOptions not allowed");k(a,"Validation completed successfully","validation")},"validateDefinitions");var oi=Object.defineProperty,ri=H((t,e)=>oi(t,"name",{value:e,configurable:!0}),"O");const si=ri((t,e={})=>{const n=e.debug||!1;k(n,"Starting command-line-args parsing","index"),k(n,"Options:","index",e);const a={...e};a.stopAtFirstUnknown&&(a.partial=!0);const r=Array.isArray(t)?t:[t];k(n,"Normalized definitions:","index",r),ai(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))}k(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 m=u.toLowerCase();return l===void 0?`-${m}`:`-${m}=${l}`}return o}));const s=ei((c??i??[]).map(String));k(n,"Tokenized arguments:","index",s);const g=Wn(s,r,a,i??[]);return k(n,"Command-line-args parsing completed","index"),g},"commandLineArgs");var li=Object.defineProperty,ci=b((t,e)=>li(t,"name",{value:e,configurable:!0}),"m$4");let ui=class{static{b(this,"a")}static{ci(this,"EmptyToolbox")}result;argv;options;argument;command;commandName;env;logger;runtime;constructor(e,n){this.commandName=e,this.command=n}};var pi=Object.defineProperty,fi=b((t,e)=>pi(t,"name",{value:e,configurable:!0}),"f$3");const hi=/^-{1,2}(\w+)(=(.+))?$/,vt=fi((t,e,n,a)=>{const r=hi.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 di=Object.defineProperty,Ae=b((t,e)=>di(t,"name",{value:e,configurable:!0}),"e$4");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"),mi=new Set(["0","1","false","true"]),gi=Ae((t,e,n,a)=>{if(e.length===0||t.length===0)return{};const r=Ae((i,c)=>{const{argName:s,argValue:g,option:o}=vt(c,e,n,a),{lastOption:p}=i;return o&&X(o)&&g&&s?i.partial[s]=Te(g,o):i.lastName&&p&&X(p)&&mi.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 vi=Object.defineProperty,Re=b((t,e)=>vi(t,"name",{value:e,configurable:!0}),"e$3");const yi=new Set(["0","1","false","true"]),wi=Re((t,e,n,a)=>{if(e.length===0||t.length===0)return t;const r=Re((i,c)=>{const{argValue:s,option:g}=vt(c,e,n,a),{lastOption:o}=i;if(o&&X(o)&&yi.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 bi=Object.defineProperty,$i=b((t,e)=>bi(t,"name",{value:e,configurable:!0}),"o$9");const De=$i(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 Oi=Object.defineProperty,se=b((t,e)=>Oi(t,"name",{value:e,configurable:!0}),"o$8");const Pi=se(t=>{if(t===void 0)return;const e=t.toLowerCase().trim();return e==="true"||e==="1"||e==="yes"||e==="on"},"transformBooleanEnv"),Ai=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 Pi(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"),Ei=se(t=>t.toLowerCase().replaceAll(/_./g,e=>e[1]?.toUpperCase()??e).replace(/^[A-Z]/,e=>e.toLowerCase()),"toCamelCase"),Ci=se(t=>{if(!t||t.length===0)return{};const e={},n=q();for(const a of t){const r=n[a.name],i=Ai(a,r),c=i===void 0?a.defaultValue:i,s=Ei(a.name);e[s]=c}return e},"processEnvVariables");var Ni=Object.defineProperty,le=b((t,e)=>Ni(t,"name",{value:e,configurable:!0}),"l$b");const ki=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"),ji=le((t,e,n,a)=>{const r=new ui(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=Ci(t.env),r},"prepareToolbox"),xi=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}=ki(a);c=wi(e,a,p,o),s=gi(e,a,p,o)}else c=e,s={};const g=si(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 _i=Object.defineProperty,Li=b((t,e)=>_i(t,"name",{value:e,configurable:!0}),"n$7");let Ii=class extends E{static{b(this,"s")}static{Li(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 Si=Object.defineProperty,Ui=b((t,e)=>Si(t,"name",{value:e,configurable:!0}),"e$2");let Mi=class extends E{static{b(this,"o")}static{Ui(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 Vi=Object.defineProperty,Ti=b((t,e)=>Vi(t,"name",{value:e,configurable:!0}),"t$5");const Be=Ti((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 Ri=Object.defineProperty,yt=b((t,e)=>Ri(t,"name",{value:e,configurable:!0}),"n$5");const Di=yt((t,e)=>e.includes(t)?!0:Math.abs(t.length-e.length)>t.length/2?!1:zt(t,e)<=t.length/3,"isSimilar"),F=yt((t,e)=>{const n=t.toLowerCase();return e.filter(a=>Di(a.toLowerCase(),n))},"findAlternatives");var Bi=Object.defineProperty,ce=b((t,e)=>Bi(t,"name",{value:e,configurable:!0}),"a$2");const zi=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
2
  `))},"validateUnknownOptions"),Wi=ce((t,e,n)=>{const a=n.__requiredOptions__?Be(n.__requiredOptions__,e,!0):Be(t,e,!1);if(a.length>0)throw new Ii(n.name,a.map(r=>r.name));e._unknown&&e._unknown.length>0&&!n.argument&&zi(e,n)},"validateRequiredOptions"),Fi=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 Mi(r.name,typeof r.conflicts=="string"?r.conflicts:r.conflicts?.[0]??"unknown")}},"validateConflictingOptions"),qi=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 Gi=Object.defineProperty,Ce=b((t,e)=>Gi(t,"name",{value:e,configurable:!0}),"r$7");const Hi=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"),Ki=Ce((t,e)=>e&&e.length>0?[...e,t]:[t],"getFullCommandPath");var Yi=Object.defineProperty,Ji=b((t,e)=>Yi(t,"name",{value:e,configurable:!0}),"p$4"),Zi=Object.defineProperty,wt=Ji((t,e)=>Zi(t,"name",{value:e,configurable:!0}),"R"),Qi=Object.defineProperty,Xi=wt((t,e)=>Qi(t,"name",{value:e,configurable:!0}),"E");const bt=String.raw,ze=bt`\p{Emoji}(?:\p{EMod}|[\u{E0020}-\u{E007E}]+\u{E007F}|\uFE0F?\u20E3?)`,ea=Xi(()=>new RegExp(bt`\p{RI}{2}|(?![#*\d](?!\uFE0F?\u20E3))${ze}(?:\u200D${ze})*`,"gu"),"default");var ta=Object.defineProperty,na=wt((t,e)=>ta(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=ea(),ia=/[-_./\s]+/g,Q=/(\u001B\[[0-9;]*[a-z])/i,We=new RegExp("\\p{Script=Arabic}","u"),aa=new RegExp("\\p{Script=Bengali}","u"),z=new RegExp("\\p{Script=Cyrillic}","u"),oa=new RegExp("\\p{Script=Devanagari}","u"),ra=new RegExp("\\p{Script=Ethiopic}","u"),ge=new RegExp("\\p{Script=Greek}","u"),sa=new RegExp("\\p{Script=Greek}+|\\p{Script=Latin}+|[^\\p{Script=Greek}\\p{Script=Latin}]+","gu"),la=new RegExp("\\p{Script=Gujarati}","u"),ca=new RegExp("\\p{Script=Gurmukhi}","u"),Fe=new RegExp("\\p{Script=Hangul}","u"),qe=new RegExp("\\p{Script=Hebrew}","u"),ua=new RegExp("\\p{Script=Hiragana}","u"),Ge=new RegExp("\\p{Script=Han}","u"),pa=new RegExp("\\p{Script=Kannada}","u"),fa=new RegExp("\\p{Script=Katakana}","u"),da=new RegExp("\\p{Script=Khmer}","u"),ha=new RegExp("\\p{Script=Lao}","u"),_=new RegExp("\\p{Script=Latin}","u"),ma=new RegExp("\\p{Script=Malayalam}","u"),ga=new RegExp("\\p{Script=Myanmar}","u"),va=new RegExp("\\p{Script=Oriya}","u"),ya=new RegExp("\\p{Script=Sinhala}","u"),wa=new RegExp("\\p{Script=Tamil}","u"),ba=new RegExp("\\p{Script=Telugu}","u"),$a=new RegExp("\\p{Script=Thai}","u"),Oa=new RegExp("\\p{Script=Tibetan}","u"),He=/[\u02BB\u02BC\u0027]/u,Pa=na(t=>t.replace(G,""),"stripEmoji");var Aa=Object.defineProperty,$t=b((t,e)=>Aa(t,"name",{value:e,configurable:!0}),"i$6"),Ea=Object.defineProperty,Ot=$t((t,e)=>Ea(t,"name",{value:e,configurable:!0}),"r"),Ca=Object.defineProperty,ka=Ot((t,e)=>Ca(t,"name",{value:e,configurable:!0}),"c");let Pt=class{static{b(this,"l")}static{$t(this,"y")}static{Ot(this,"s")}static{ka(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 Na=Object.defineProperty,ja=b((t,e)=>Na(t,"name",{value:e,configurable:!0}),"r$5"),xa=Object.defineProperty,_a=ja((t,e)=>xa(t,"name",{value:e,configurable:!0}),"a"),La=Object.defineProperty,Ia=_a((t,e)=>La(t,"name",{value:e,configurable:!0}),"s");const Sa=Ia((t,e)=>typeof t!="string"||t===""?"":(e?.locale?t[0].toLocaleLowerCase(e.locale):t[0].toLowerCase())+t.slice(1),"lowerFirst");var Ua=Object.defineProperty,Ma=b((t,e)=>Ua(t,"name",{value:e,configurable:!0}),"S"),Va=Object.defineProperty,ue=Ma((t,e)=>Va(t,"name",{value:e,configurable:!0}),"m");const Ta=Wt(import.meta.url),Z=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Ra=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 Ta(t)},"__cjs_getBuiltinModule"),{stripVTControlCharacters:Da}=Ra("node:util");var Ba=Object.defineProperty,za=ue((t,e)=>Ba(t,"name",{value:e,configurable:!0}),"g");const ve=new Pt(1e3),Wa=za(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 Fa=Object.defineProperty,qa=ue((t,e)=>Fa(t,"name",{value:e,configurable:!0}),"t");const Ga=qa(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 Ha=Object.defineProperty,A=ue((t,e)=>Ha(t,"name",{value:e,configurable:!0}),"u");const At=new Uint8Array(128),Et=new Uint8Array(128),Ct=new Uint8Array(128);for(let t=0;t<128;t++)At[t]=t>=65&&t<=90?1:0,Et[t]=t>=97&&t<=122?1:0,Ct[t]=t>=48&&t<=57?1:0;const ye=A(t=>At[t],"isUpper"),Ke=A(t=>Et[t],"isLower"),we=A(t=>Ct[t],"isDigit"),U=A((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 m="other";for(const[$,C]of Object.entries(e))if(C(l)){m=$;break}const y=n&&a?l===l.toLocaleUpperCase(a):!1;let v=!1;r?v=r(o,m,p,y,l,u,c):(o!==m&&o!=="other"&&m!=="other"&&(v=!0),n&&m!=="other"&&!p&&y&&(v=!0)),v?(s.push(g),g=l):g+=l,o=m,n&&(p=y)}return g&&g.length>0&&s.push(g),s.length>0?s:[t]},"handleScriptTransitions"),kt=A((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 m of e)if(t.startsWith(m,n)){a.push(m),n+=m.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 m=!1,y=!1;if(i+1<r){const v=t.codePointAt(i+1);m=v&&v<128&&ye(v),y=v&&v<128&&we(v)}if(!y&&m){a.push(t.slice(n,i),t.slice(i,i+1)),n=i+1;continue}}if(i+1<r){const m=t.codePointAt(i+1),y=m&&m<128&&Ke(m);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"),Nt=A((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],m=o[0]===o[0].toLocaleUpperCase(e),y=m,v=m?0:-1;for(let $=1;$<p;$++){const C=o[$],k=C===C.toLocaleUpperCase(e);if(k===m)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],d=l.slice(0,-1);d&&d.length>0&&u.push(d),l=f+C}else l+=C;y=!1,v=-1}m=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],m=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);m!==k&&(m===1||m===2)&&(k===1||k===2)||k===m&&!y&&f?(u.push(l),l=C):l+=C,m=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(sa)??[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 m=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(m),m=$):m+=$,y=C}m&&p.push(m)}return p}if(e.startsWith("ja")||e.startsWith("ko")){const o=e.startsWith("ja"),p=o?{hiragana:A(l=>ua.test(l),"hiragana"),kanji:A(l=>Ge.test(l),"kanji"),katakana:A(l=>fa.test(l),"katakana"),latin:A(l=>_.test(l),"latin")}:{hangul:A(l=>Fe.test(l),"hangul"),latin:A(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")),m=[];for(const y of l)y.length===1&&u.has(y)&&m.length>0?m[m.length-1]+=y:m.push(y);return m.length>0?m:[t]}return U(t,p,!1,e,(l,m)=>l==="hangul"&&m==="latin"||l==="latin"&&m==="hangul")}if(e.startsWith("sl")){const o=[...t],p=o.length,u=[];let l=o[0],m=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);!m&&$||C&&k?(u.push(l),l=v,C&&k&&(u.push(l),l="")):l+=v,m=$}return l&&l.length>0&&u.push(l),u}if(e.startsWith("zh"))return U(t,{han:A(o=>Ge.test(o),"han"),latin:A(o=>_.test(o),"latin")},!1,e);if(["ar","fa","he","ur"].includes(e.split("-")[0])){const o=A(p=>qe.test(p)||We.test(p),"isRtlChar");return U(t,{latin:A(p=>_.test(p),"latin"),rtl:A(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=A(p=>oa.test(p)||aa.test(p)||la.test(p)||ca.test(p)||pa.test(p)||wa.test(p)||ba.test(p)||ma.test(p)||ya.test(p)||$a.test(p)||ha.test(p)||Oa.test(p)||ga.test(p)||ra.test(p)||da.test(p)||va.test(p),"isIndicChar");return U(t,{indic:A(p=>o(p),"indic"),latin:A(p=>_.test(p),"latin")},!1,e)}if(["be","bg","ru","sr","uk"].includes(e))return U(t,{cyrillic:A(o=>z.test(o),"cyrillic"),latin:A(o=>_.test(o),"latin")},!0,e);if(["ar","fa","he"].includes(e))return U(t,{latin:A(o=>_.test(o),"latin"),rtl:A(o=>qe.test(o)||We.test(o),"rtl")},!1,e);if(e.startsWith("ko"))return U(t,{hangul:A(o=>Fe.test(o),"hangul"),latin:A(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],m=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}!m&&$?(u.push(l),l=v):l+=v,m=$}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 m of n)if(t.startsWith(m,o)){c.push(s,m),o+=m.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"),Ka=A((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)?Ga(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(...Nt(s,g,n))}else a.push(...kt(s,n))}return a},"processTextWithAnsiEmoji"),Ya=A((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=Da(u)),o&&(u=Pa(u));const l=Array.isArray(s)?Wa(s):s instanceof RegExp?s:ia,m=u.split(l).filter(Boolean);let y=[];for(const v of m)n||a?y.push(...Ka(v,i,p)):i?y.push(...Nt(v,i,p)):y.push(...kt(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 Ja=Object.defineProperty,Za=b((t,e)=>Ja(t,"name",{value:e,configurable:!0}),"r$4"),Qa=Object.defineProperty,Xa=Za((t,e)=>Qa(t,"name",{value:e,configurable:!0}),"o"),eo=Object.defineProperty,to=Xa((t,e)=>eo(t,"name",{value:e,configurable:!0}),"s");const no=to((t,e)=>typeof t!="string"||t===""?"":(e?.locale?t[0].toLocaleUpperCase(e.locale):t[0].toUpperCase())+t.slice(1),"upperFirst");var io=Object.defineProperty,ao=b((t,e)=>io(t,"name",{value:e,configurable:!0}),"r$3"),oo=Object.defineProperty,ro=ao((t,e)=>oo(t,"name",{value:e,configurable:!0}),"r"),so=Object.defineProperty,lo=ro((t,e)=>so(t,"name",{value:e,configurable:!0}),"n");const co=lo((t,e)=>`${t}::${e?.joiner??""}::${e?.locale??""}::${e?.knownAcronyms?.join(",")??""}::${e?.normalize?"true":"false"}`,"generateCacheKey");var uo=Object.defineProperty,po=b((t,e)=>uo(t,"name",{value:e,configurable:!0}),"i$4"),fo=Object.defineProperty,ho=po((t,e)=>fo(t,"name",{value:e,configurable:!0}),"a"),mo=Object.defineProperty,go=ho((t,e)=>mo(t,"name",{value:e,configurable:!0}),"l");const vo=go((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 yo=Object.defineProperty,wo=b((t,e)=>yo(t,"name",{value:e,configurable:!0}),"r$2"),bo=Object.defineProperty,$o=wo((t,e)=>bo(t,"name",{value:e,configurable:!0}),"a"),Oo=Object.defineProperty,Po=$o((t,e)=>Oo(t,"name",{value:e,configurable:!0}),"t");const Ao=Po(t=>t.replaceAll(/(?<![a-zß])SS(?![a-z])/g,"ß"),"normalizeGermanEszett");var Eo=Object.defineProperty,Co=b((t,e)=>Eo(t,"name",{value:e,configurable:!0}),"l$3"),ko=Object.defineProperty,No=Co((t,e)=>ko(t,"name",{value:e,configurable:!0}),"n"),jo=Object.defineProperty,xo=No((t,e)=>jo(t,"name",{value:e,configurable:!0}),"l");const _o=new Pt(1e3),Lo=xo((t,e)=>{if(typeof t!="string"||!t)return"";const n=e?.cache??!1,a=e?.cacheStore??_o;let r;if(n&&(r=co(t,e)),n&&r&&a.has(r))return a.get(r);let i=!0;const c=vo(Ya(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")?Ao(s):s,s=e?.locale?s.toLocaleLowerCase(e.locale):s.toLowerCase(),i?(i=!1,Sa(s,e)):no(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__=Lo(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=Object.keys(n).filter(i=>i.startsWith("no-"));if(a.length===0)return;const r=new Map;for(const i of e.options)r.set(i.name,i);for(const i of a){const c=i.replace(/^no-/,""),s=r.get(c);s&&(s.__negated__=!0),n[c]=!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,jt=b((t,e)=>Wo(t,"name",{value:e,configurable:!0}),"s$2");const Fo=" ",qo=jt((t,e)=>t===e?!0:t.length!==e.length?!1:t.every((n,a)=>n===e[a]),"equals"),Go=jt(t=>{if(typeof t=="string")return t.split(Fo);const e=Pe();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 E(`${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 E(`${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 E(`${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 E(`${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 E(`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 E(`Command name "${e}" contains invalid characters`,"INVALID_COMMAND_NAME",{commandName:e});if(!/^[a-z][\w-]*$/i.test(e))throw new E(`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 E(`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 E(`Plugin name "${e}" contains invalid characters`,"INVALID_PLUGIN_NAME",{pluginName:e});if(!/^[a-z][\w-]*$/i.test(e))throw new E(`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,de=b((t,e)=>Jo(t,"name",{value:e,configurable:!0}),"s");const Zo=new Set([`
4
- `,"\r"," ","\0",'"',"$","&","'","(",")",";","<",">","[","\\","]","`","{","|","}"]),Qo=de(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=de(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");de(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{de(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}),"x");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;#d;#h;#m;#P(){return this.#d===void 0&&(this.#d=[...this.#i.keys()]),this.#d}#b(){return this.#h===void 0&&(this.#h=[...this.#n.keys()]),this.#h}#a(){return this.#m===void 0&&(this.#m=[...this.#P(),...this.#b()]),this.#m}#A(){this.#d=void 0,this.#h=void 0,this.#m=void 0}#$(){if(this.#o===void 0){const e=Go(this.#e.argv);this.#o=Je(e),this.#E()}return this.#o}#E(){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(Vt),n=!0;break}if(a==="--verbose"||a==="-v"){e.CEREBRO_OUTPUT_LEVEL=String(Tt),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}=xi(e,n,Ut),g=Object.keys(c).length>0?{...s,_all:{...s._all,...c}}:s;Wi(i,g,e);const o=ji(e,s,c,a);return o.runtime=this,o.argv=this.#$(),e.options&&e.options.length>0&&(Mo(o,e),Vo(o,e)),Fi(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 E("CLI name must be a non-empty string","INVALID_INPUT",{cliName:e});this.#g=e.trim();const a=n.argv??Pe(),r=n.cwd??Rt();if(this.#e={...n,argv:a,cwd:r},this.#e.argv&&!Array.isArray(this.#e.argv))throw new E("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 E("CLI cwd option must be a string","INVALID_INPUT",{cwd:this.#e.cwd});if(this.#e.packageName&&typeof this.#e.packageName!="string")throw new E("CLI packageName option must be a string","INVALID_INPUT",{packageName:this.#e.packageName});if(this.#e.packageVersion&&typeof this.#e.packageVersion!="string")throw new E("CLI packageVersion option must be a string","INVALID_INPUT",{packageVersion:this.#e.packageVersion});const i=q();i.CEREBRO_OUTPUT_LEVEL=String(Ne),typeof this.#e.logger=="object"?this.#t=this.#e.logger: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=Ki(e.name,e.commandPath),a=J(n);if(this.#i.has(a))throw new E(`Command with path "${a}" already exists`,"DUPLICATE_COMMAND",{commandName:e.name,commandPath:e.commandPath});if(this.#n.has(e.name)&&!e.commandPath)throw new E(`Command with name "${e.name}" already exists`,"DUPLICATE_COMMAND",{commandName:e.name});if(e.options)for(const r of e.options)tn(r);if(qi(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.#A(),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 E(`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 Jt(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 Mt(this.#n));const i=this.#b(),c=this.#i;this.#C();const s=this.#$();let g,o=[...s];const p=Dt(),u=Bt(),l=Pe();this.#t.debug(`process.execPath: ${p}`),this.#t.debug(`process.execArgv: ${u.join(" ")}`),this.#t.debug(`process.argv: ${l.join(" ")}`);const m=Hi(c,[...s]);if(m.commandPath)g=m.commandPath,o=m.argv;else{if(s.length>1&&s[0]&&s[1]&&!Oe(s[0])&&!Oe(s[1])){const w=[];let P=0;for(;P<s.length;){const O=s[P];if(!O||Oe(O))break;w.push(O),P+=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 h;try{h=ln([null,...i],[...s])}catch(w){if(w instanceof Error&&w.name==="INVALID_COMMAND"&&"command"in w){const P=w.command,j=this.#a(),O=F(P,j);throw new D(P,O)}throw w}h.command&&(g=[h.command],o=h.argv)}if(!g)if(this.#s)g=[this.#s];else{const h=this.#a();throw new D("",h)}const y=J(g),v=this.#i.get(y);let $;if(v){if($=this.#p.get(y),!$||J(v)!==y){const h=this.#a(),w=F(y,h);throw new D(y,w)}}else{const h=g[g.length-1];if($=h?this.#n.get(h):void 0,!$){const w=this.#a(),P=F(y,w);throw new D(y,P)}}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),d=this.getPluginManager();try{!this.#f&&d.hasPlugins()&&(await d.init({cli:this,cwd:this.#c,logger:this.#t}),this.#f=!0),await d.executeLifecycle("execute",f),await d.executeLifecycle("beforeCommand",f);let h;if(k.global?.help){const w=this.#n.get("help");if(!w)throw new E("Help command not found","COMMAND_NOT_FOUND");h=await B(w,f,k)}else if(k.global?.version||k.global?.V){const w=this.#n.get("version");if(!w)throw new E("Version command not found","COMMAND_NOT_FOUND");h=await B(w,f,k)}else h=await B($,f,k);return await d.executeLifecycle("afterCommand",f,h),a?ie(0):void 0}catch(h){throw await d.executeErrorHandlers(h,f),h}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(),m=F(c||e,l);throw new D(e,m)}if(typeof s.execute!="function")throw new E(`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 m=this.#n.get("help");if(!m)throw new E("Help command not found","COMMAND_NOT_FOUND");l=await B(m,p,o)}else if(o.global?.version||o.global?.V){const m=this.#n.get("version");if(!m)throw new E("Version command not found","COMMAND_NOT_FOUND");l=await B(m,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};
3
+ `))},"validateDuplicateOptions");var Gi=Object.defineProperty,Ce=b((t,e)=>Gi(t,"name",{value:e,configurable:!0}),"r$7");const Hi=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"),Ki=Ce((t,e)=>e&&e.length>0?[...e,t]:[t],"getFullCommandPath");var Yi=Object.defineProperty,Ji=b((t,e)=>Yi(t,"name",{value:e,configurable:!0}),"p$4"),Zi=Object.defineProperty,wt=Ji((t,e)=>Zi(t,"name",{value:e,configurable:!0}),"e"),Qi=Object.defineProperty,Xi=wt((t,e)=>Qi(t,"name",{value:e,configurable:!0}),"E");const bt=String.raw,ze=bt`\p{Emoji}(?:\p{EMod}|[\u{E0020}-\u{E007E}]+\u{E007F}|\uFE0F?\u20E3?)`,ea=Xi(()=>new RegExp(bt`\p{RI}{2}|(?![#*\d](?!\uFE0F?\u20E3))${ze}(?:\u200D${ze})*`,"gu"),"default");var ta=Object.defineProperty,na=wt((t,e)=>ta(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=ea(),ia=/[-_./\s]+/g,Q=/(\u001B\[[0-9;]*[a-z])/i,We=new RegExp("\\p{Script=Arabic}","u"),aa=new RegExp("\\p{Script=Bengali}","u"),z=new RegExp("\\p{Script=Cyrillic}","u"),oa=new RegExp("\\p{Script=Devanagari}","u"),ra=new RegExp("\\p{Script=Ethiopic}","u"),ge=new RegExp("\\p{Script=Greek}","u"),sa=new RegExp("\\p{Script=Greek}+|\\p{Script=Latin}+|[^\\p{Script=Greek}\\p{Script=Latin}]+","gu"),la=new RegExp("\\p{Script=Gujarati}","u"),ca=new RegExp("\\p{Script=Gurmukhi}","u"),Fe=new RegExp("\\p{Script=Hangul}","u"),qe=new RegExp("\\p{Script=Hebrew}","u"),ua=new RegExp("\\p{Script=Hiragana}","u"),Ge=new RegExp("\\p{Script=Han}","u"),pa=new RegExp("\\p{Script=Kannada}","u"),fa=new RegExp("\\p{Script=Katakana}","u"),ha=new RegExp("\\p{Script=Khmer}","u"),da=new RegExp("\\p{Script=Lao}","u"),_=new RegExp("\\p{Script=Latin}","u"),ma=new RegExp("\\p{Script=Malayalam}","u"),ga=new RegExp("\\p{Script=Myanmar}","u"),va=new RegExp("\\p{Script=Oriya}","u"),ya=new RegExp("\\p{Script=Sinhala}","u"),wa=new RegExp("\\p{Script=Tamil}","u"),ba=new RegExp("\\p{Script=Telugu}","u"),$a=new RegExp("\\p{Script=Thai}","u"),Oa=new RegExp("\\p{Script=Tibetan}","u"),He=/[\u02BB\u02BC\u0027]/u,Pa=na(t=>t.replace(G,""),"stripEmoji");var Aa=Object.defineProperty,$t=b((t,e)=>Aa(t,"name",{value:e,configurable:!0}),"i$6"),Ea=Object.defineProperty,Ot=$t((t,e)=>Ea(t,"name",{value:e,configurable:!0}),"r"),Ca=Object.defineProperty,Na=Ot((t,e)=>Ca(t,"name",{value:e,configurable:!0}),"c");let Pt=class{static{b(this,"l")}static{$t(this,"y")}static{Ot(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 ka=Object.defineProperty,ja=b((t,e)=>ka(t,"name",{value:e,configurable:!0}),"r$5"),xa=Object.defineProperty,_a=ja((t,e)=>xa(t,"name",{value:e,configurable:!0}),"a"),La=Object.defineProperty,Ia=_a((t,e)=>La(t,"name",{value:e,configurable:!0}),"s");const Sa=Ia((t,e)=>typeof t!="string"||t===""?"":(e?.locale?t[0].toLocaleLowerCase(e.locale):t[0].toLowerCase())+t.slice(1),"lowerFirst");var Ua=Object.defineProperty,Ma=b((t,e)=>Ua(t,"name",{value:e,configurable:!0}),"S"),Va=Object.defineProperty,ue=Ma((t,e)=>Va(t,"name",{value:e,configurable:!0}),"m");const Ta=Wt(import.meta.url),Z=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Ra=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 Ta(t)},"__cjs_getBuiltinModule"),{stripVTControlCharacters:Da}=Ra("node:util");var Ba=Object.defineProperty,za=ue((t,e)=>Ba(t,"name",{value:e,configurable:!0}),"g");const ve=new Pt(1e3),Wa=za(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 Fa=Object.defineProperty,qa=ue((t,e)=>Fa(t,"name",{value:e,configurable:!0}),"t");const Ga=qa(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 Ha=Object.defineProperty,A=ue((t,e)=>Ha(t,"name",{value:e,configurable:!0}),"u");const At=new Uint8Array(128),Et=new Uint8Array(128),Ct=new Uint8Array(128);for(let t=0;t<128;t++)At[t]=t>=65&&t<=90?1:0,Et[t]=t>=97&&t<=122?1:0,Ct[t]=t>=48&&t<=57?1:0;const ye=A(t=>At[t],"isUpper"),Ke=A(t=>Et[t],"isLower"),we=A(t=>Ct[t],"isDigit"),U=A((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 m="other";for(const[$,C]of Object.entries(e))if(C(l)){m=$;break}const y=n&&a?l===l.toLocaleUpperCase(a):!1;let v=!1;r?v=r(o,m,p,y,l,u,c):(o!==m&&o!=="other"&&m!=="other"&&(v=!0),n&&m!=="other"&&!p&&y&&(v=!0)),v?(s.push(g),g=l):g+=l,o=m,n&&(p=y)}return g&&g.length>0&&s.push(g),s.length>0?s:[t]},"handleScriptTransitions"),Nt=A((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 m of e)if(t.startsWith(m,n)){a.push(m),n+=m.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 m=!1,y=!1;if(i+1<r){const v=t.codePointAt(i+1);m=v&&v<128&&ye(v),y=v&&v<128&&we(v)}if(!y&&m){a.push(t.slice(n,i),t.slice(i,i+1)),n=i+1;continue}}if(i+1<r){const m=t.codePointAt(i+1),y=m&&m<128&&Ke(m);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"),kt=A((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],m=o[0]===o[0].toLocaleUpperCase(e),y=m,v=m?0:-1;for(let $=1;$<p;$++){const C=o[$],N=C===C.toLocaleUpperCase(e);if(N===m)l+=C;else if(N)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}m=N}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],m=z.test(o[0])?1:_.test(o[0])?2:0,y=o[0]===o[0].toLocaleUpperCase(e);for(let $=1;$<p;$++){const C=o[$],N=z.test(C)?1:_.test(C)?2:0,f=C===C.toLocaleUpperCase(e);m!==N&&(m===1||m===2)&&(N===1||N===2)||N===m&&!y&&f?(u.push(l),l=C):l+=C,m=N,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(sa)??[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 m=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(m),m=$):m+=$,y=C}m&&p.push(m)}return p}if(e.startsWith("ja")||e.startsWith("ko")){const o=e.startsWith("ja"),p=o?{hiragana:A(l=>ua.test(l),"hiragana"),kanji:A(l=>Ge.test(l),"kanji"),katakana:A(l=>fa.test(l),"katakana"),latin:A(l=>_.test(l),"latin")}:{hangul:A(l=>Fe.test(l),"hangul"),latin:A(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")),m=[];for(const y of l)y.length===1&&u.has(y)&&m.length>0?m[m.length-1]+=y:m.push(y);return m.length>0?m:[t]}return U(t,p,!1,e,(l,m)=>l==="hangul"&&m==="latin"||l==="latin"&&m==="hangul")}if(e.startsWith("sl")){const o=[...t],p=o.length,u=[];let l=o[0],m=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),N=y<p-1&&o[y+1]===o[y+1].toLocaleUpperCase(e);!m&&$||C&&N?(u.push(l),l=v,C&&N&&(u.push(l),l="")):l+=v,m=$}return l&&l.length>0&&u.push(l),u}if(e.startsWith("zh"))return U(t,{han:A(o=>Ge.test(o),"han"),latin:A(o=>_.test(o),"latin")},!1,e);if(["ar","fa","he","ur"].includes(e.split("-")[0])){const o=A(p=>qe.test(p)||We.test(p),"isRtlChar");return U(t,{latin:A(p=>_.test(p),"latin"),rtl:A(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=A(p=>oa.test(p)||aa.test(p)||la.test(p)||ca.test(p)||pa.test(p)||wa.test(p)||ba.test(p)||ma.test(p)||ya.test(p)||$a.test(p)||da.test(p)||Oa.test(p)||ga.test(p)||ra.test(p)||ha.test(p)||va.test(p),"isIndicChar");return U(t,{indic:A(p=>o(p),"indic"),latin:A(p=>_.test(p),"latin")},!1,e)}if(["be","bg","ru","sr","uk"].includes(e))return U(t,{cyrillic:A(o=>z.test(o),"cyrillic"),latin:A(o=>_.test(o),"latin")},!0,e);if(["ar","fa","he"].includes(e))return U(t,{latin:A(o=>_.test(o),"latin"),rtl:A(o=>qe.test(o)||We.test(o),"rtl")},!1,e);if(e.startsWith("ko"))return U(t,{hangul:A(o=>Fe.test(o),"hangul"),latin:A(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],m=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}!m&&$?(u.push(l),l=v):l+=v,m=$}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 m of n)if(t.startsWith(m,o)){c.push(s,m),o+=m.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"),Ka=A((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)?Ga(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(...kt(s,g,n))}else a.push(...Nt(s,n))}return a},"processTextWithAnsiEmoji"),Ya=A((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=Da(u)),o&&(u=Pa(u));const l=Array.isArray(s)?Wa(s):s instanceof RegExp?s:ia,m=u.split(l).filter(Boolean);let y=[];for(const v of m)n||a?y.push(...Ka(v,i,p)):i?y.push(...kt(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 Ja=Object.defineProperty,Za=b((t,e)=>Ja(t,"name",{value:e,configurable:!0}),"r$4"),Qa=Object.defineProperty,Xa=Za((t,e)=>Qa(t,"name",{value:e,configurable:!0}),"o"),eo=Object.defineProperty,to=Xa((t,e)=>eo(t,"name",{value:e,configurable:!0}),"s");const no=to((t,e)=>typeof t!="string"||t===""?"":(e?.locale?t[0].toLocaleUpperCase(e.locale):t[0].toUpperCase())+t.slice(1),"upperFirst");var io=Object.defineProperty,ao=b((t,e)=>io(t,"name",{value:e,configurable:!0}),"r$3"),oo=Object.defineProperty,ro=ao((t,e)=>oo(t,"name",{value:e,configurable:!0}),"r"),so=Object.defineProperty,lo=ro((t,e)=>so(t,"name",{value:e,configurable:!0}),"n");const co=lo((t,e)=>`${t}::${e?.joiner??""}::${e?.locale??""}::${e?.knownAcronyms?.join(",")??""}::${e?.normalize?"true":"false"}`,"generateCacheKey");var uo=Object.defineProperty,po=b((t,e)=>uo(t,"name",{value:e,configurable:!0}),"i$4"),fo=Object.defineProperty,ho=po((t,e)=>fo(t,"name",{value:e,configurable:!0}),"a"),mo=Object.defineProperty,go=ho((t,e)=>mo(t,"name",{value:e,configurable:!0}),"l");const vo=go((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 yo=Object.defineProperty,wo=b((t,e)=>yo(t,"name",{value:e,configurable:!0}),"r$2"),bo=Object.defineProperty,$o=wo((t,e)=>bo(t,"name",{value:e,configurable:!0}),"a"),Oo=Object.defineProperty,Po=$o((t,e)=>Oo(t,"name",{value:e,configurable:!0}),"t");const Ao=Po(t=>t.replaceAll(/(?<![a-zß])SS(?![a-z])/g,"ß"),"normalizeGermanEszett");var Eo=Object.defineProperty,Co=b((t,e)=>Eo(t,"name",{value:e,configurable:!0}),"l$3"),No=Object.defineProperty,ko=Co((t,e)=>No(t,"name",{value:e,configurable:!0}),"n"),jo=Object.defineProperty,xo=ko((t,e)=>jo(t,"name",{value:e,configurable:!0}),"l");const _o=new Pt(1e3),Lo=xo((t,e)=>{if(typeof t!="string"||!t)return"";const n=e?.cache??!1,a=e?.cacheStore??_o;let r;if(n&&(r=co(t,e)),n&&r&&a.has(r))return a.get(r);let i=!0;const c=vo(Ya(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")?Ao(s):s,s=e?.locale?s.toLocaleLowerCase(e.locale):s.toLowerCase(),i?(i=!1,Sa(s,e)):no(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__=Lo(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=Object.keys(n).filter(i=>i.startsWith("no-"));if(a.length===0)return;const r=new Map;for(const i of e.options)r.set(i.name,i);for(const i of a){const c=i.replace(/^no-/,""),s=r.get(c);s&&(s.__negated__=!0),n[c]=!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,jt=b((t,e)=>Wo(t,"name",{value:e,configurable:!0}),"s$2");const Fo=" ",qo=jt((t,e)=>t===e?!0:t.length!==e.length?!1:t.every((n,a)=>n===e[a]),"equals"),Go=jt(t=>{if(typeof t=="string")return t.split(Fo);const e=Pe();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,Ne=K((t,e)=>{if(typeof t!="string"||t.trim().length===0)throw new E(`${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 E(`${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 E(`${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 E(`${e} must be an object`,"INVALID_INPUT",{fieldName:e,value:t});return t},"validateObject"),ee=K(t=>{const e=Ne(t,"Command name");if(e.length>ae)throw new E(`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 E(`Command name "${e}" contains invalid characters`,"INVALID_COMMAND_NAME",{commandName:e});if(!/^[a-z][\w-]*$/i.test(e))throw new E(`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=Ne(t,"Plugin name");if(e.length>ae)throw new E(`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 E(`Plugin name "${e}" contains invalid characters`,"INVALID_PLUGIN_NAME",{pluginName:e});if(!/^[a-z][\w-]*$/i.test(e))throw new E(`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}),"N");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;#P(){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.#P(),...this.#b()]),this.#m}#A(){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.#E()}return this.#o}#E(){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(Vt),n=!0;break}if(a==="--verbose"||a==="-v"){e.CEREBRO_OUTPUT_LEVEL=String(Tt),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(ke))}#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}=xi(e,n,Ut),g=Object.keys(c).length>0?{...s,_all:{...s._all,...c}}:s;Wi(i,g,e);const o=ji(e,s,c,a);return o.runtime=this,o.argv=this.#$(),e.options&&e.options.length>0&&(Mo(o,e),Vo(o,e)),Fi(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 E("CLI name must be a non-empty string","INVALID_INPUT",{cliName:e});this.#g=e.trim();const a=n.argv??Pe(),r=n.cwd??Rt();if(this.#e={...n,argv:a,cwd:r},this.#e.argv&&!Array.isArray(this.#e.argv))throw new E("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 E("CLI cwd option must be a string","INVALID_INPUT",{cwd:this.#e.cwd});if(this.#e.packageName&&typeof this.#e.packageName!="string")throw new E("CLI packageName option must be a string","INVALID_INPUT",{packageName:this.#e.packageName});if(this.#e.packageVersion&&typeof this.#e.packageVersion!="string")throw new E("CLI packageVersion option must be a string","INVALID_INPUT",{packageVersion:this.#e.packageVersion});const i=q();if(i.CEREBRO_OUTPUT_LEVEL=String(ke),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 E(`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=Ki(e.name,e.commandPath),a=J(n);if(this.#i.has(a))throw new E(`Command with path "${a}" already exists`,"DUPLICATE_COMMAND",{commandName:e.name,commandPath:e.commandPath});if(this.#n.has(e.name)&&!e.commandPath)throw new E(`Command with name "${e.name}" already exists`,"DUPLICATE_COMMAND",{commandName:e.name});if(e.options)for(const r of e.options)tn(r);if(qi(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.#A(),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 E(`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 Jt(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 Mt(this.#n));const i=this.#b(),c=this.#i;this.#C();const s=this.#$();let g,o=[...s];const p=Dt(),u=Bt(),l=Pe();this.#t.debug(`process.execPath: ${p}`),this.#t.debug(`process.execArgv: ${u.join(" ")}`),this.#t.debug(`process.argv: ${l.join(" ")}`);const m=Hi(c,[...s]);if(m.commandPath)g=m.commandPath,o=m.argv;else{if(s.length>1&&s[0]&&s[1]&&!Oe(s[0])&&!Oe(s[1])){const w=[];let P=0;for(;P<s.length;){const O=s[P];if(!O||Oe(O))break;w.push(O),P+=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 d;try{d=ln([null,...i],[...s])}catch(w){if(w instanceof Error&&w.name==="INVALID_COMMAND"&&"command"in w){const P=w.command,j=this.#a(),O=F(P,j);throw new D(P,O)}throw w}d.command&&(g=[d.command],o=d.argv)}if(!g)if(this.#s)g=[this.#s];else{const d=this.#a();throw new D("",d)}const y=J(g),v=this.#i.get(y);let $;if(v){if($=this.#p.get(y),!$||J(v)!==y){const d=this.#a(),w=F(y,d);throw new D(y,w)}}else{const d=g[g.length-1];if($=d?this.#n.get(d):void 0,!$){const w=this.#a(),P=F(y,w);throw new D(y,P)}}if(typeof $.execute!="function")return this.#t.error(`Command "${$.name}" has no function to execute.`),a?ie(1):void 0;const C=o,{commandArgs:N,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 d;if(N.global?.help){const w=this.#n.get("help");if(!w)throw new E("Help command not found","COMMAND_NOT_FOUND");d=await B(w,f,N)}else if(N.global?.version||N.global?.V){const w=this.#n.get("version");if(!w)throw new E("Version command not found","COMMAND_NOT_FOUND");d=await B(w,f,N)}else d=await B($,f,N);return await h.executeLifecycle("afterCommand",f,d),a?ie(0):void 0}catch(d){throw await h.executeErrorHandlers(d,f),d}finally{n&&this.dispose()}}async runCommand(e,n={}){const{argv:a=[],...r}=n;Ne(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(),m=F(c||e,l);throw new D(e,m)}if(typeof s.execute!="function")throw new E(`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 m=this.#n.get("help");if(!m)throw new E("Help command not found","COMMAND_NOT_FOUND");l=await B(m,p,o)}else if(o.global?.version||o.global?.V){const m=this.#n.get("version");if(!m)throw new E("Version command not found","COMMAND_NOT_FOUND");l=await B(m,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};
@@ -1 +1 @@
1
- var E=Object.defineProperty;var g=(i,r)=>E(i,"name",{value:r,configurable:!0});import{green as d,inverse as s,cyan as c,yellow as f}from"@visulima/colorize";import{f as y,p as $}from"./index-DQ3pvLQH.js";const O=[{defaultValue:"32",description:"Controls the verbosity level of output. Valid values: '16' (quiet), '32' (normal), '64' (verbose), '128' (debug)",name:"CEREBRO_OUTPUT_LEVEL",type:String},{description:"Sets the minimum required Node.js version. Overrides the default minimum version check",name:"CEREBRO_MIN_NODE_VERSION",type:Number},{defaultValue:!1,description:"When set, disables the update notifier check",name:"NO_UPDATE_NOTIFIER",type:Boolean},{description:"Standard Node.js environment variable. When set to 'test', disables update notifier",name:"NODE_ENV",type:String},{defaultValue:!1,description:"When set, enables debug output (same as --debug flag)",name:"DEBUG",type:Boolean},{description:"Sets the terminal width for table rendering. Useful for testing and consistent output",name:"CEREBRO_TERMINAL_WIDTH",type:Number}],C=[{description:"Turn on verbose output",group:"global",name:"verbose",type:Boolean},{description:"Turn on debugging output",group:"global",name:"debug",type:Boolean},{alias:"h",description:"Print out helpful usage information",group:"global",name:"help",type:Boolean},{alias:"q",description:"Silence output",group:"global",name:"quiet",type:Boolean},{alias:"V",description:"Print version info",group:"global",name:"version",type:Boolean},{description:"Turn off colored output",group:"global",name:"no-color",type:Boolean},{description:"Force colored output",group:"global",name:"color",type:Boolean}];var N=Object.defineProperty,u=g((i,r)=>N(i,"name",{value:r,configurable:!0}),"p");const b="__Other",v=u(i=>i.charAt(0).toUpperCase()+i.slice(1),"upperFirstChar"),A=u((i,r,p,t)=>{i.debug("no command given, printing general help...");let n=[...new Set(p.values())].filter(e=>!e.hidden);t&&(n=n.filter(e=>e.group===t));const a=n.reduce((e,o)=>{const l=o.group??b;return e[l]||(e[l]=[]),e[l].push(o),e},{}),m=u(e=>e.map(o=>{let l="";typeof o.alias=="string"?l=o.alias:Array.isArray(o.alias)&&(l=o.alias.join(", ")),l!==""&&(l=` [${l}]`);let h=o.name;return o.commandPath&&o.commandPath.length>0&&(h=`${o.commandPath.join(" ")} ${o.name}`),[`${d(h)}${l}`,o.description??""]}),"buildCommandList");(i?.raw??i.log)($([{content:`${c(r.getCliName())} ${d("<command>")} [positional arguments] ${f("[options]")}`,header:s.cyan(" Usage ")},...Object.keys(a).map(e=>{const o=t?` ${v(t)}`:"";return{content:m(a[e]),header:e===b||t?s.green(` Available${o} Commands `):` ${s.green(` ${v(e)} `)}`}}),p.has("help")?{header:s.yellow(" Command Options "),optionList:p.get("help").options?.filter(e=>!e.hidden)}:void 0,{header:s.yellow(" Global Options "),optionList:C},{content:O.filter(e=>!e.hidden).map(e=>[e.name,e.description??""]),header:s.magenta(" Environment Variables ")},{content:`Run "${c(r.getCliName())} ${d("help <command>")}" or "${c(r.getCliName())} ${d("<command>")} ${f("--help")}" for help with a specific command.`,raw:!0}].filter(Boolean)))},"printGeneralHelp"),B=u((i,r,p,t)=>{let n=p.get(t);if(!n)for(const e of p.values()){const o=e.commandPath?[...e.commandPath,e.name]:[e.name];if(o[o.length-1]===t||o.join(" ")===t){n=e;break}}if(!n){i.error(`Command "${t}" not found`);return}const a=[],m=(n.commandPath?[...n.commandPath,n.name]:[n.name]).join(" ");if(a.push({content:`${c(r.getCliName())} ${d(m)}${n.argument?" [positional arguments]":""}${n.options?" [options]":""}`,header:s.cyan(" Usage ")}),n.description&&a.push({content:n.description,header:s.green(" Description ")}),n.argument&&a.push({header:"Command Positional Arguments",isArgument:!0,optionList:[n.argument]}),Array.isArray(n.options)&&n.options.length>0&&a.push({header:s.yellow(" Command Options "),optionList:n.options.filter(e=>!e.hidden)}),a.push({header:s.yellow(" Global Options "),optionList:C}),Array.isArray(n.env)&&n.env.length>0){const e=n.env.filter(o=>!o.hidden);e.length>0&&a.push({content:e.map(o=>[o.name,o.description??""]),header:s.magenta(" Environment Variables ")})}if(n.alias!==void 0&&n.alias.length>0){let e=n.alias;typeof n.alias=="string"&&(e=[n.alias]),a.splice(1,0,{content:e,header:"Alias(es)"})}Array.isArray(n.examples)&&n.examples.length>0&&a.push({content:n.examples,header:"Examples"}),(i?.raw??i.log)($(a))},"printCommandHelp");class R{static{g(this,"O")}static{u(this,"HelpCommand")}name="help";options=[{description:"Display only the specified group",name:"group",type:String}];commands;constructor(r){this.commands=r}execute(r){const{commandName:p,logger:t,options:n,runtime:a}=r,{footer:m,header:e}=a.getCommandSection();e&&(t?.raw??t.log)(y(e)),p==="help"?A(t,a,this.commands,typeof n?.group=="string"?n.group:void 0):B(t,a,this.commands,p),m&&(t?.raw??t.log)(y(m))}}export{R as O,C as o};
1
+ var E=Object.defineProperty;var g=(i,r)=>E(i,"name",{value:r,configurable:!0});import{green as d,inverse as s,cyan as c,yellow as f}from"@visulima/colorize";import{f as y,p as $}from"./index-DQ3pvLQH.js";const O=[{defaultValue:"32",description:"Controls the verbosity level of output. Valid values: '16' (quiet), '32' (normal), '64' (verbose), '128' (debug)",name:"CEREBRO_OUTPUT_LEVEL",type:String},{description:"Sets the minimum required Node.js version. Overrides the default minimum version check",name:"CEREBRO_MIN_NODE_VERSION",type:Number},{defaultValue:!1,description:"When set, disables the update notifier check",name:"NO_UPDATE_NOTIFIER",type:Boolean},{description:"Standard Node.js environment variable. When set to 'test', disables update notifier",name:"NODE_ENV",type:String},{defaultValue:!1,description:"When set, enables debug output (same as --debug flag)",name:"DEBUG",type:Boolean},{description:"Sets the terminal width for table rendering. Useful for testing and consistent output",name:"CEREBRO_TERMINAL_WIDTH",type:Number}],C=[{description:"Turn on verbose output",group:"global",name:"verbose",type:Boolean},{description:"Turn on debugging output",group:"global",name:"debug",type:Boolean},{alias:"h",description:"Print out helpful usage information",group:"global",name:"help",type:Boolean},{alias:"q",description:"Silence output",group:"global",name:"quiet",type:Boolean},{alias:"V",description:"Print version info",group:"global",name:"version",type:Boolean},{description:"Turn off colored output",group:"global",name:"no-color",type:Boolean},{description:"Force colored output",group:"global",name:"color",type:Boolean}];var N=Object.defineProperty,u=g((i,r)=>N(i,"name",{value:r,configurable:!0}),"p");const b="__Other",v=u(i=>i.charAt(0).toUpperCase()+i.slice(1),"upperFirstChar"),A=u((i,r,p,t)=>{i.debug("no command given, printing general help...");let n=[...new Set(p.values())].filter(e=>!e.hidden);t&&(n=n.filter(e=>e.group===t));const a=n.reduce((e,o)=>{const l=o.group??b;return e[l]||(e[l]=[]),e[l].push(o),e},{}),m=u(e=>e.map(o=>{let l="";typeof o.alias=="string"?l=o.alias:Array.isArray(o.alias)&&(l=o.alias.join(", ")),l!==""&&(l=` [${l}]`);let h=o.name;return o.commandPath&&o.commandPath.length>0&&(h=`${o.commandPath.join(" ")} ${o.name}`),[`${d(h)}${l}`,o.description??""]}),"buildCommandList");(i?.raw??i.log)($([{content:`${c(r.getCliName())} ${d("<command>")} [positional arguments] ${f("[options]")}`,header:s.cyan(" Usage ")},...Object.keys(a).map(e=>{const o=t?` ${v(t)}`:"";return{content:m(a[e]),header:e===b||t?s.green(` Available${o} Commands `):` ${s.green(` ${v(e)} `)}`}}),p.has("help")?{header:s.yellow(" Command Options "),optionList:p.get("help").options?.filter(e=>!e.hidden)}:void 0,{header:s.yellow(" Global Options "),optionList:C},{content:O.filter(e=>!e.hidden).map(e=>[e.name,e.description??""]),header:s.magenta(" Environment Variables ")},{content:`Run "${c(r.getCliName())} ${d("help <command>")}" or "${c(r.getCliName())} ${d("<command>")} ${f("--help")}" for help with a specific command.`,raw:!0}].filter(Boolean)))},"printGeneralHelp"),w=u((i,r,p,t)=>{let n=p.get(t);if(!n)for(const e of p.values()){const o=e.commandPath?[...e.commandPath,e.name]:[e.name];if(o[o.length-1]===t||o.join(" ")===t){n=e;break}}if(!n){i.error(`Command "${t}" not found`);return}const a=[],m=(n.commandPath?[...n.commandPath,n.name]:[n.name]).join(" ");if(a.push({content:`${c(r.getCliName())} ${d(m)}${n.argument?" [positional arguments]":""}${n.options?" [options]":""}`,header:s.cyan(" Usage ")}),n.description&&a.push({content:n.description,header:s.green(" Description ")}),n.argument&&a.push({header:"Command Positional Arguments",isArgument:!0,optionList:[n.argument]}),Array.isArray(n.options)&&n.options.length>0&&a.push({header:s.yellow(" Command Options "),optionList:n.options.filter(e=>!e.hidden)}),a.push({header:s.yellow(" Global Options "),optionList:C}),Array.isArray(n.env)&&n.env.length>0){const e=n.env.filter(o=>!o.hidden);e.length>0&&a.push({content:e.map(o=>[o.name,o.description??""]),header:s.magenta(" Environment Variables ")})}if(n.alias!==void 0&&n.alias.length>0){let e=n.alias;typeof n.alias=="string"&&(e=[n.alias]),a.splice(1,0,{content:e,header:"Alias(es)"})}Array.isArray(n.examples)&&n.examples.length>0&&a.push({content:n.examples,header:"Examples"}),(i?.raw??i.log)($(a))},"printCommandHelp");class R{static{g(this,"A")}static{u(this,"HelpCommand")}name="help";options=[{description:"Display only the specified group",name:"group",type:String}];commands=new Map;constructor(r){this.commands=r}execute(r){const{commandName:p,logger:t,options:n,runtime:a}=r,{footer:m,header:e}=a.getCommandSection();e&&(t?.raw??t.log)(y(e)),p==="help"?A(t,a,this.commands,typeof n?.group=="string"?n.group:void 0):w(t,a,this.commands,p),m&&(t?.raw??t.log)(y(m))}}export{R as A,C as o};
@@ -0,0 +1,53 @@
1
+ import type { Plugin, PluginContext } from "./types/plugin.d.ts";
2
+ import type { Toolbox } from "./types/toolbox.d.ts";
3
+ type Logger = Console;
4
+ /**
5
+ * Manages plugin lifecycle and execution
6
+ */
7
+ declare class PluginManager<T extends Logger = Logger> {
8
+ private readonly logger;
9
+ private readonly plugins;
10
+ private initialized;
11
+ private cachedDependencyOrder;
12
+ constructor(logger: T);
13
+ /**
14
+ * Checks if any plugins are registered.
15
+ * @returns True if at least one plugin is registered
16
+ */
17
+ hasPlugins(): boolean;
18
+ /**
19
+ * Registers a plugin.
20
+ * @param plugin The plugin to register
21
+ * @throws {Error} If plugin name is already registered or dependencies are invalid
22
+ */
23
+ register(plugin: Plugin): void;
24
+ /**
25
+ * Initializes all registered plugins.
26
+ * @param context The plugin context for initialization
27
+ */
28
+ init(context: PluginContext): Promise<void>;
29
+ /**
30
+ * Executes a specific lifecycle hook for all plugins.
31
+ * @param hook The lifecycle hook name
32
+ * @param toolbox The command toolbox (for command-specific hooks)
33
+ * @param result The command result (for afterCommand hook)
34
+ */
35
+ executeLifecycle(hook: "beforeCommand" | "afterCommand" | "execute", toolbox: Toolbox, result?: unknown): Promise<void>;
36
+ /**
37
+ * Executes error handlers for all plugins.
38
+ * @param error The error that occurred
39
+ * @param toolbox The command toolbox
40
+ */
41
+ executeErrorHandlers(error: Error, toolbox: Toolbox): Promise<void>;
42
+ /**
43
+ * Gets all registered plugins in dependency order.
44
+ * @returns Array of plugins sorted by dependencies
45
+ */
46
+ getDependencyOrder(): Plugin[];
47
+ /**
48
+ * Validates that all plugin dependencies exist.
49
+ * @throws {Error} If any dependencies are missing
50
+ */
51
+ private validateDependencies;
52
+ }
53
+ export default PluginManager;
@@ -1,15 +1,21 @@
1
- import { O as Options$1 } from '../packem_shared/index.d-BkzZomTF.js';
2
- import { P as Plugin } from '../packem_shared/plugin-manager-BjEuiNxv.js';
3
- import '@visulima/tabular';
4
-
5
- type ErrorHandlerOptions = {
1
+ import type { RenderErrorOptions } from "@visulima/error";
2
+ import type { Plugin } from "../types/plugin.d.ts";
3
+ export type ErrorHandlerOptions = {
4
+ /** Show detailed error information including stack traces and code frames (default: false) */
6
5
  detailed?: boolean;
6
+ /** Exit process after handling error (default: true) */
7
7
  exitOnError?: boolean;
8
+ /** Custom error formatter function */
8
9
  formatter?: (error: Error) => string;
10
+ /** Whether to log errors (default: true) */
9
11
  logErrors?: boolean;
10
- renderOptions?: Partial<Options$1>;
12
+ /** Options for renderError from \@visulima/error (only used when detailed is true) */
13
+ renderOptions?: Partial<RenderErrorOptions>;
11
14
  };
12
- declare const errorHandlerPlugin: (options?: ErrorHandlerOptions) => Plugin;
13
-
14
- export { errorHandlerPlugin };
15
- export type { ErrorHandlerOptions };
15
+ /**
16
+ * Create an error handler plugin for enhanced error reporting.
17
+ * Uses \@visulima/error for beautiful error formatting with code frames and stack traces.
18
+ * @param options Error handler configuration options
19
+ * @returns Plugin instance
20
+ */
21
+ export declare const errorHandlerPlugin: (options?: ErrorHandlerOptions) => Plugin;
@@ -1,18 +1,23 @@
1
- import { P as Plugin } from '../packem_shared/plugin-manager-BjEuiNxv.js';
2
- import '@visulima/tabular';
3
-
4
- type RuntimeType = "bun" | "deno" | "node";
5
- type RuntimeVersionRequirement = {
1
+ import type { Plugin } from "../types/plugin.d.ts";
2
+ export type RuntimeType = "bun" | "deno" | "node";
3
+ export type RuntimeVersionRequirement = {
4
+ /** Minimum version required */
6
5
  minVersion: number;
7
6
  };
8
- type RuntimeVersionCheckOptions = {
7
+ export type RuntimeVersionCheckOptions = {
8
+ /** Runtime version requirements for specific runtimes */
9
9
  runtimes?: {
10
+ /** Minimum Bun version requirement */
10
11
  bun?: RuntimeVersionRequirement;
12
+ /** Minimum Deno version requirement */
11
13
  deno?: RuntimeVersionRequirement;
14
+ /** Minimum Node.js version requirement */
12
15
  node?: RuntimeVersionRequirement;
13
16
  };
14
17
  };
15
- declare const runtimeVersionCheckPlugin: (options?: RuntimeVersionCheckOptions) => Plugin;
16
-
17
- export { runtimeVersionCheckPlugin };
18
- export type { RuntimeType, RuntimeVersionCheckOptions, RuntimeVersionRequirement };
18
+ /**
19
+ * Create a runtime version check plugin that supports Node.js, Bun, and Deno.
20
+ * @param options Configuration for runtime version requirements
21
+ * @returns Plugin instance that validates runtime version on initialization
22
+ */
23
+ export declare const runtimeVersionCheckPlugin: (options?: RuntimeVersionCheckOptions) => Plugin;
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Retrieves the last update check timestamp for the specified package.
3
+ * @param packageName
4
+ * @returns - The timestamp of the last update check, or undefined if the check failed.
5
+ */
6
+ export declare const getLastUpdate: (packageName: string) => number | undefined;
7
+ /**
8
+ * Saves the last update time for a given package.
9
+ * @param packageName
10
+ */
11
+ export declare const saveLastUpdate: (packageName: string) => void;
@@ -0,0 +1,2 @@
1
+ declare const getDistributionVersion: (packageName: string, distributionTag: string, registryUrl: string) => Promise<string>;
2
+ export default getDistributionVersion;
@@ -0,0 +1,14 @@
1
+ declare const hasNewVersion: ({ alwaysRun, debug, distTag: distributionTag, pkg, registryUrl, updateCheckInterval, }: UpdateNotifierOptions) => Promise<string | undefined>;
2
+ export type UpdateNotifierOptions = {
3
+ alwaysRun?: boolean;
4
+ debug?: boolean;
5
+ distTag?: string;
6
+ pkg: {
7
+ name: string;
8
+ version: string;
9
+ };
10
+ registryUrl?: string;
11
+ shouldNotifyInNpmScript?: boolean;
12
+ updateCheckInterval?: number;
13
+ };
14
+ export default hasNewVersion;
@@ -1,21 +1,9 @@
1
- import { P as Plugin } from '../../packem_shared/plugin-manager-BjEuiNxv.js';
2
- import '@visulima/tabular';
3
-
4
- type UpdateNotifierOptions = {
5
- alwaysRun?: boolean;
6
- debug?: boolean;
7
- distTag?: string;
8
- pkg: {
9
- name: string;
10
- version: string;
11
- };
12
- registryUrl?: string;
13
- shouldNotifyInNpmScript?: boolean;
14
- updateCheckInterval?: number;
15
- };
16
-
17
- type UpdateNotifierPluginOptions = Partial<Omit<UpdateNotifierOptions, "debug" | "pkg">>;
18
- declare const updateNotifierPlugin: (options?: UpdateNotifierPluginOptions) => Plugin;
19
-
20
- export { updateNotifierPlugin };
21
- export type { UpdateNotifierPluginOptions };
1
+ import type { Plugin } from "../../types/plugin.d.ts";
2
+ import type { UpdateNotifierOptions } from "./has-new-version.d.ts";
3
+ export type UpdateNotifierPluginOptions = Partial<Omit<UpdateNotifierOptions, "debug" | "pkg">>;
4
+ /**
5
+ * Create an update notifier plugin that checks for package updates.
6
+ * @param options Update notifier configuration options.
7
+ * @returns Plugin instance.
8
+ */
9
+ export declare const updateNotifierPlugin: (options?: UpdateNotifierPluginOptions) => Plugin;