UNPKG

curtains

Version:

Build beautiful HTML presentations from Markdown with custom styling, containers, and keyboard navigation

27 lines 516 kB
#!/usr/bin/env node "use strict";var Fy=Object.create;var Fr=Object.defineProperty;var Vy=Object.getOwnPropertyDescriptor;var qy=Object.getOwnPropertyNames;var Hy=Object.getPrototypeOf,By=Object.prototype.hasOwnProperty;var a=(e,t)=>Fr(e,"name",{value:t,configurable:!0});var St=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Ke=(e,t)=>{for(var n in t)Fr(e,n,{get:t[n],enumerable:!0})},Hm=(e,t,n,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of qy(t))!By.call(e,r)&&r!==n&&Fr(e,r,{get:()=>t[r],enumerable:!(i=Vy(t,r))||i.enumerable});return e};var Vr=(e,t,n)=>(n=e!=null?Fy(Hy(e)):{},Hm(t||!e||!e.__esModule?Fr(n,"default",{value:e,enumerable:!0}):n,e)),Wy=e=>Hm(Fr({},"__esModule",{value:!0}),e);var qr=St(Ho=>{var Gn=class extends Error{static{a(this,"CommanderError")}constructor(t,n,i){super(i),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=n,this.exitCode=t,this.nestedError=void 0}},qo=class extends Gn{static{a(this,"InvalidArgumentError")}constructor(t){super(1,"commander.invalidArgument",t),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}};Ho.CommanderError=Gn;Ho.InvalidArgumentError=qo});var Jn=St(Wo=>{var{InvalidArgumentError:Gy}=qr(),Bo=class{static{a(this,"Argument")}constructor(t,n){switch(this.description=n||"",this.variadic=!1,this.parseArg=void 0,this.defaultValue=void 0,this.defaultValueDescription=void 0,this.argChoices=void 0,t[0]){case"<":this.required=!0,this._name=t.slice(1,-1);break;case"[":this.required=!1,this._name=t.slice(1,-1);break;default:this.required=!0,this._name=t;break}this._name.length>3&&this._name.slice(-3)==="..."&&(this.variadic=!0,this._name=this._name.slice(0,-3))}name(){return this._name}_concatValue(t,n){return n===this.defaultValue||!Array.isArray(n)?[t]:n.concat(t)}default(t,n){return this.defaultValue=t,this.defaultValueDescription=n,this}argParser(t){return this.parseArg=t,this}choices(t){return this.argChoices=t.slice(),this.parseArg=(n,i)=>{if(!this.argChoices.includes(n))throw new Gy(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._concatValue(n,i):n},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}};function Jy(e){let t=e.name()+(e.variadic===!0?"...":"");return e.required?"<"+t+">":"["+t+"]"}a(Jy,"humanReadableArgName");Wo.Argument=Bo;Wo.humanReadableArgName=Jy});var Ko=St(Jo=>{var{humanReadableArgName:Ky}=Jn(),Go=class{static{a(this,"Help")}constructor(){this.helpWidth=void 0,this.minWidthToWrap=40,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}prepareContext(t){this.helpWidth=this.helpWidth??t.helpWidth??80}visibleCommands(t){let n=t.commands.filter(r=>!r._hidden),i=t._getHelpCommand();return i&&!i._hidden&&n.push(i),this.sortSubcommands&&n.sort((r,o)=>r.name().localeCompare(o.name())),n}compareOptions(t,n){let i=a(r=>r.short?r.short.replace(/^-/,""):r.long.replace(/^--/,""),"getSortKey");return i(t).localeCompare(i(n))}visibleOptions(t){let n=t.options.filter(r=>!r.hidden),i=t._getHelpOption();if(i&&!i.hidden){let r=i.short&&t._findOption(i.short),o=i.long&&t._findOption(i.long);!r&&!o?n.push(i):i.long&&!o?n.push(t.createOption(i.long,i.description)):i.short&&!r&&n.push(t.createOption(i.short,i.description))}return this.sortOptions&&n.sort(this.compareOptions),n}visibleGlobalOptions(t){if(!this.showGlobalOptions)return[];let n=[];for(let i=t.parent;i;i=i.parent){let r=i.options.filter(o=>!o.hidden);n.push(...r)}return this.sortOptions&&n.sort(this.compareOptions),n}visibleArguments(t){return t._argsDescription&&t.registeredArguments.forEach(n=>{n.description=n.description||t._argsDescription[n.name()]||""}),t.registeredArguments.find(n=>n.description)?t.registeredArguments:[]}subcommandTerm(t){let n=t.registeredArguments.map(i=>Ky(i)).join(" ");return t._name+(t._aliases[0]?"|"+t._aliases[0]:"")+(t.options.length?" [options]":"")+(n?" "+n:"")}optionTerm(t){return t.flags}argumentTerm(t){return t.name()}longestSubcommandTermLength(t,n){return n.visibleCommands(t).reduce((i,r)=>Math.max(i,this.displayWidth(n.styleSubcommandTerm(n.subcommandTerm(r)))),0)}longestOptionTermLength(t,n){return n.visibleOptions(t).reduce((i,r)=>Math.max(i,this.displayWidth(n.styleOptionTerm(n.optionTerm(r)))),0)}longestGlobalOptionTermLength(t,n){return n.visibleGlobalOptions(t).reduce((i,r)=>Math.max(i,this.displayWidth(n.styleOptionTerm(n.optionTerm(r)))),0)}longestArgumentTermLength(t,n){return n.visibleArguments(t).reduce((i,r)=>Math.max(i,this.displayWidth(n.styleArgumentTerm(n.argumentTerm(r)))),0)}commandUsage(t){let n=t._name;t._aliases[0]&&(n=n+"|"+t._aliases[0]);let i="";for(let r=t.parent;r;r=r.parent)i=r.name()+" "+i;return i+n+" "+t.usage()}commandDescription(t){return t.description()}subcommandDescription(t){return t.summary()||t.description()}optionDescription(t){let n=[];if(t.argChoices&&n.push(`choices: ${t.argChoices.map(i=>JSON.stringify(i)).join(", ")}`),t.defaultValue!==void 0&&(t.required||t.optional||t.isBoolean()&&typeof t.defaultValue=="boolean")&&n.push(`default: ${t.defaultValueDescription||JSON.stringify(t.defaultValue)}`),t.presetArg!==void 0&&t.optional&&n.push(`preset: ${JSON.stringify(t.presetArg)}`),t.envVar!==void 0&&n.push(`env: ${t.envVar}`),n.length>0){let i=`(${n.join(", ")})`;return t.description?`${t.description} ${i}`:i}return t.description}argumentDescription(t){let n=[];if(t.argChoices&&n.push(`choices: ${t.argChoices.map(i=>JSON.stringify(i)).join(", ")}`),t.defaultValue!==void 0&&n.push(`default: ${t.defaultValueDescription||JSON.stringify(t.defaultValue)}`),n.length>0){let i=`(${n.join(", ")})`;return t.description?`${t.description} ${i}`:i}return t.description}formatItemList(t,n,i){return n.length===0?[]:[i.styleTitle(t),...n,""]}groupItems(t,n,i){let r=new Map;return t.forEach(o=>{let s=i(o);r.has(s)||r.set(s,[])}),n.forEach(o=>{let s=i(o);r.has(s)||r.set(s,[]),r.get(s).push(o)}),r}formatHelp(t,n){let i=n.padWidth(t,n),r=n.helpWidth??80;function o(p,h){return n.formatItem(p,i,h,n)}a(o,"callFormatItem");let s=[`${n.styleTitle("Usage:")} ${n.styleUsage(n.commandUsage(t))}`,""],u=n.commandDescription(t);u.length>0&&(s=s.concat([n.boxWrap(n.styleCommandDescription(u),r),""]));let l=n.visibleArguments(t).map(p=>o(n.styleArgumentTerm(n.argumentTerm(p)),n.styleArgumentDescription(n.argumentDescription(p))));if(s=s.concat(this.formatItemList("Arguments:",l,n)),this.groupItems(t.options,n.visibleOptions(t),p=>p.helpGroupHeading??"Options:").forEach((p,h)=>{let d=p.map(g=>o(n.styleOptionTerm(n.optionTerm(g)),n.styleOptionDescription(n.optionDescription(g))));s=s.concat(this.formatItemList(h,d,n))}),n.showGlobalOptions){let p=n.visibleGlobalOptions(t).map(h=>o(n.styleOptionTerm(n.optionTerm(h)),n.styleOptionDescription(n.optionDescription(h))));s=s.concat(this.formatItemList("Global Options:",p,n))}return this.groupItems(t.commands,n.visibleCommands(t),p=>p.helpGroup()||"Commands:").forEach((p,h)=>{let d=p.map(g=>o(n.styleSubcommandTerm(n.subcommandTerm(g)),n.styleSubcommandDescription(n.subcommandDescription(g))));s=s.concat(this.formatItemList(h,d,n))}),s.join(` `)}displayWidth(t){return Bm(t).length}styleTitle(t){return t}styleUsage(t){return t.split(" ").map(n=>n==="[options]"?this.styleOptionText(n):n==="[command]"?this.styleSubcommandText(n):n[0]==="["||n[0]==="<"?this.styleArgumentText(n):this.styleCommandText(n)).join(" ")}styleCommandDescription(t){return this.styleDescriptionText(t)}styleOptionDescription(t){return this.styleDescriptionText(t)}styleSubcommandDescription(t){return this.styleDescriptionText(t)}styleArgumentDescription(t){return this.styleDescriptionText(t)}styleDescriptionText(t){return t}styleOptionTerm(t){return this.styleOptionText(t)}styleSubcommandTerm(t){return t.split(" ").map(n=>n==="[options]"?this.styleOptionText(n):n[0]==="["||n[0]==="<"?this.styleArgumentText(n):this.styleSubcommandText(n)).join(" ")}styleArgumentTerm(t){return this.styleArgumentText(t)}styleOptionText(t){return t}styleArgumentText(t){return t}styleSubcommandText(t){return t}styleCommandText(t){return t}padWidth(t,n){return Math.max(n.longestOptionTermLength(t,n),n.longestGlobalOptionTermLength(t,n),n.longestSubcommandTermLength(t,n),n.longestArgumentTermLength(t,n))}preformatted(t){return/\n[^\S\r\n]/.test(t)}formatItem(t,n,i,r){let s=" ".repeat(2);if(!i)return s+t;let u=t.padEnd(n+t.length-r.displayWidth(t)),l=2,m=(this.helpWidth??80)-n-l-2,p;return m<this.minWidthToWrap||r.preformatted(i)?p=i:p=r.boxWrap(i,m).replace(/\n/g,` `+" ".repeat(n+l)),s+u+" ".repeat(l)+p.replace(/\n/g,` ${s}`)}boxWrap(t,n){if(n<this.minWidthToWrap)return t;let i=t.split(/\r\n|\n/),r=/[\s]*[^\s]+/g,o=[];return i.forEach(s=>{let u=s.match(r);if(u===null){o.push("");return}let l=[u.shift()],c=this.displayWidth(l[0]);u.forEach(m=>{let p=this.displayWidth(m);if(c+p<=n){l.push(m),c+=p;return}o.push(l.join(""));let h=m.trimStart();l=[h],c=this.displayWidth(h)}),o.push(l.join(""))}),o.join(` `)}};function Bm(e){let t=/\x1b\[\d*(;\d*)*m/g;return e.replace(t,"")}a(Bm,"stripColor");Jo.Help=Go;Jo.stripColor=Bm});var ea=St(Yo=>{var{InvalidArgumentError:Xy}=qr(),Xo=class{static{a(this,"Option")}constructor(t,n){this.flags=t,this.description=n||"",this.required=t.includes("<"),this.optional=t.includes("["),this.variadic=/\w\.\.\.[>\]]$/.test(t),this.mandatory=!1;let i=Qy(t);this.short=i.shortFlag,this.long=i.longFlag,this.negate=!1,this.long&&(this.negate=this.long.startsWith("--no-")),this.defaultValue=void 0,this.defaultValueDescription=void 0,this.presetArg=void 0,this.envVar=void 0,this.parseArg=void 0,this.hidden=!1,this.argChoices=void 0,this.conflictsWith=[],this.implied=void 0,this.helpGroupHeading=void 0}default(t,n){return this.defaultValue=t,this.defaultValueDescription=n,this}preset(t){return this.presetArg=t,this}conflicts(t){return this.conflictsWith=this.conflictsWith.concat(t),this}implies(t){let n=t;return typeof t=="string"&&(n={[t]:!0}),this.implied=Object.assign(this.implied||{},n),this}env(t){return this.envVar=t,this}argParser(t){return this.parseArg=t,this}makeOptionMandatory(t=!0){return this.mandatory=!!t,this}hideHelp(t=!0){return this.hidden=!!t,this}_concatValue(t,n){return n===this.defaultValue||!Array.isArray(n)?[t]:n.concat(t)}choices(t){return this.argChoices=t.slice(),this.parseArg=(n,i)=>{if(!this.argChoices.includes(n))throw new Xy(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._concatValue(n,i):n},this}name(){return this.long?this.long.replace(/^--/,""):this.short.replace(/^-/,"")}attributeName(){return this.negate?Wm(this.name().replace(/^no-/,"")):Wm(this.name())}helpGroup(t){return this.helpGroupHeading=t,this}is(t){return this.short===t||this.long===t}isBoolean(){return!this.required&&!this.optional&&!this.negate}},Qo=class{static{a(this,"DualOptions")}constructor(t){this.positiveOptions=new Map,this.negativeOptions=new Map,this.dualOptions=new Set,t.forEach(n=>{n.negate?this.negativeOptions.set(n.attributeName(),n):this.positiveOptions.set(n.attributeName(),n)}),this.negativeOptions.forEach((n,i)=>{this.positiveOptions.has(i)&&this.dualOptions.add(i)})}valueFromOption(t,n){let i=n.attributeName();if(!this.dualOptions.has(i))return!0;let r=this.negativeOptions.get(i).presetArg,o=r!==void 0?r:!1;return n.negate===(o===t)}};function Wm(e){return e.split("-").reduce((t,n)=>t+n[0].toUpperCase()+n.slice(1))}a(Wm,"camelcase");function Qy(e){let t,n,i=/^-[^-]$/,r=/^--[^-]/,o=e.split(/[ |,]+/).concat("guard");if(i.test(o[0])&&(t=o.shift()),r.test(o[0])&&(n=o.shift()),!t&&i.test(o[0])&&(t=o.shift()),!t&&r.test(o[0])&&(t=n,n=o.shift()),o[0].startsWith("-")){let s=o[0],u=`option creation failed due to '${s}' in option flags '${e}'`;throw/^-[^-][^-]/.test(s)?new Error(`${u} - a short flag is a single dash and a single character - either use a single dash and a single character (for a short flag) - or use a double dash for a long option (and can have two, like '--ws, --workspace')`):i.test(s)?new Error(`${u} - too many short flags`):r.test(s)?new Error(`${u} - too many long flags`):new Error(`${u} - unrecognised flag format`)}if(t===void 0&&n===void 0)throw new Error(`option creation failed due to no flags found in '${e}'.`);return{shortFlag:t,longFlag:n}}a(Qy,"splitOptionFlags");Yo.Option=Xo;Yo.DualOptions=Qo});var Jm=St(Gm=>{function Yy(e,t){if(Math.abs(e.length-t.length)>3)return Math.max(e.length,t.length);let n=[];for(let i=0;i<=e.length;i++)n[i]=[i];for(let i=0;i<=t.length;i++)n[0][i]=i;for(let i=1;i<=t.length;i++)for(let r=1;r<=e.length;r++){let o=1;e[r-1]===t[i-1]?o=0:o=1,n[r][i]=Math.min(n[r-1][i]+1,n[r][i-1]+1,n[r-1][i-1]+o),r>1&&i>1&&e[r-1]===t[i-2]&&e[r-2]===t[i-1]&&(n[r][i]=Math.min(n[r][i],n[r-2][i-2]+1))}return n[e.length][t.length]}a(Yy,"editDistance");function eb(e,t){if(!t||t.length===0)return"";t=Array.from(new Set(t));let n=e.startsWith("--");n&&(e=e.slice(2),t=t.map(s=>s.slice(2)));let i=[],r=3,o=.4;return t.forEach(s=>{if(s.length<=1)return;let u=Yy(e,s),l=Math.max(e.length,s.length);(l-u)/l>o&&(u<r?(r=u,i=[s]):u===r&&i.push(s))}),i.sort((s,u)=>s.localeCompare(u)),n&&(i=i.map(s=>`--${s}`)),i.length>1?` (Did you mean one of ${i.join(", ")}?)`:i.length===1?` (Did you mean ${i[0]}?)`:""}a(eb,"suggestSimilar");Gm.suggestSimilar=eb});var Ym=St(oa=>{var tb=require("node:events").EventEmitter,ta=require("node:child_process"),ut=require("node:path"),Kn=require("node:fs"),Q=require("node:process"),{Argument:rb,humanReadableArgName:nb}=Jn(),{CommanderError:ra}=qr(),{Help:ib,stripColor:ob}=Ko(),{Option:Km,DualOptions:ab}=ea(),{suggestSimilar:Xm}=Jm(),na=class e extends tb{static{a(this,"Command")}constructor(t){super(),this.commands=[],this.options=[],this.parent=null,this._allowUnknownOption=!1,this._allowExcessArguments=!1,this.registeredArguments=[],this._args=this.registeredArguments,this.args=[],this.rawArgs=[],this.processedArgs=[],this._scriptPath=null,this._name=t||"",this._optionValues={},this._optionValueSources={},this._storeOptionsAsProperties=!1,this._actionHandler=null,this._executableHandler=!1,this._executableFile=null,this._executableDir=null,this._defaultCommandName=null,this._exitCallback=null,this._aliases=[],this._combineFlagAndOptionalValue=!0,this._description="",this._summary="",this._argsDescription=void 0,this._enablePositionalOptions=!1,this._passThroughOptions=!1,this._lifeCycleHooks={},this._showHelpAfterError=!1,this._showSuggestionAfterError=!0,this._savedState=null,this._outputConfiguration={writeOut:a(n=>Q.stdout.write(n),"writeOut"),writeErr:a(n=>Q.stderr.write(n),"writeErr"),outputError:a((n,i)=>i(n),"outputError"),getOutHelpWidth:a(()=>Q.stdout.isTTY?Q.stdout.columns:void 0,"getOutHelpWidth"),getErrHelpWidth:a(()=>Q.stderr.isTTY?Q.stderr.columns:void 0,"getErrHelpWidth"),getOutHasColors:a(()=>ia()??(Q.stdout.isTTY&&Q.stdout.hasColors?.()),"getOutHasColors"),getErrHasColors:a(()=>ia()??(Q.stderr.isTTY&&Q.stderr.hasColors?.()),"getErrHasColors"),stripColor:a(n=>ob(n),"stripColor")},this._hidden=!1,this._helpOption=void 0,this._addImplicitHelpCommand=void 0,this._helpCommand=void 0,this._helpConfiguration={},this._helpGroupHeading=void 0,this._defaultCommandGroup=void 0,this._defaultOptionGroup=void 0}copyInheritedSettings(t){return this._outputConfiguration=t._outputConfiguration,this._helpOption=t._helpOption,this._helpCommand=t._helpCommand,this._helpConfiguration=t._helpConfiguration,this._exitCallback=t._exitCallback,this._storeOptionsAsProperties=t._storeOptionsAsProperties,this._combineFlagAndOptionalValue=t._combineFlagAndOptionalValue,this._allowExcessArguments=t._allowExcessArguments,this._enablePositionalOptions=t._enablePositionalOptions,this._showHelpAfterError=t._showHelpAfterError,this._showSuggestionAfterError=t._showSuggestionAfterError,this}_getCommandAndAncestors(){let t=[];for(let n=this;n;n=n.parent)t.push(n);return t}command(t,n,i){let r=n,o=i;typeof r=="object"&&r!==null&&(o=r,r=null),o=o||{};let[,s,u]=t.match(/([^ ]+) *(.*)/),l=this.createCommand(s);return r&&(l.description(r),l._executableHandler=!0),o.isDefault&&(this._defaultCommandName=l._name),l._hidden=!!(o.noHelp||o.hidden),l._executableFile=o.executableFile||null,u&&l.arguments(u),this._registerCommand(l),l.parent=this,l.copyInheritedSettings(this),r?this:l}createCommand(t){return new e(t)}createHelp(){return Object.assign(new ib,this.configureHelp())}configureHelp(t){return t===void 0?this._helpConfiguration:(this._helpConfiguration=t,this)}configureOutput(t){return t===void 0?this._outputConfiguration:(this._outputConfiguration=Object.assign({},this._outputConfiguration,t),this)}showHelpAfterError(t=!0){return typeof t!="string"&&(t=!!t),this._showHelpAfterError=t,this}showSuggestionAfterError(t=!0){return this._showSuggestionAfterError=!!t,this}addCommand(t,n){if(!t._name)throw new Error(`Command passed to .addCommand() must have a name - specify the name in Command constructor or using .name()`);return n=n||{},n.isDefault&&(this._defaultCommandName=t._name),(n.noHelp||n.hidden)&&(t._hidden=!0),this._registerCommand(t),t.parent=this,t._checkForBrokenPassThrough(),this}createArgument(t,n){return new rb(t,n)}argument(t,n,i,r){let o=this.createArgument(t,n);return typeof i=="function"?o.default(r).argParser(i):o.default(i),this.addArgument(o),this}arguments(t){return t.trim().split(/ +/).forEach(n=>{this.argument(n)}),this}addArgument(t){let n=this.registeredArguments.slice(-1)[0];if(n&&n.variadic)throw new Error(`only the last argument can be variadic '${n.name()}'`);if(t.required&&t.defaultValue!==void 0&&t.parseArg===void 0)throw new Error(`a default value for a required argument is never used: '${t.name()}'`);return this.registeredArguments.push(t),this}helpCommand(t,n){if(typeof t=="boolean")return this._addImplicitHelpCommand=t,t&&this._defaultCommandGroup&&this._initCommandGroup(this._getHelpCommand()),this;let i=t??"help [command]",[,r,o]=i.match(/([^ ]+) *(.*)/),s=n??"display help for command",u=this.createCommand(r);return u.helpOption(!1),o&&u.arguments(o),s&&u.description(s),this._addImplicitHelpCommand=!0,this._helpCommand=u,(t||n)&&this._initCommandGroup(u),this}addHelpCommand(t,n){return typeof t!="object"?(this.helpCommand(t,n),this):(this._addImplicitHelpCommand=!0,this._helpCommand=t,this._initCommandGroup(t),this)}_getHelpCommand(){return this._addImplicitHelpCommand??(this.commands.length&&!this._actionHandler&&!this._findCommand("help"))?(this._helpCommand===void 0&&this.helpCommand(void 0,void 0),this._helpCommand):null}hook(t,n){let i=["preSubcommand","preAction","postAction"];if(!i.includes(t))throw new Error(`Unexpected value for event passed to hook : '${t}'. Expecting one of '${i.join("', '")}'`);return this._lifeCycleHooks[t]?this._lifeCycleHooks[t].push(n):this._lifeCycleHooks[t]=[n],this}exitOverride(t){return t?this._exitCallback=t:this._exitCallback=n=>{if(n.code!=="commander.executeSubCommandAsync")throw n},this}_exit(t,n,i){this._exitCallback&&this._exitCallback(new ra(t,n,i)),Q.exit(t)}action(t){let n=a(i=>{let r=this.registeredArguments.length,o=i.slice(0,r);return this._storeOptionsAsProperties?o[r]=this:o[r]=this.opts(),o.push(this),t.apply(this,o)},"listener");return this._actionHandler=n,this}createOption(t,n){return new Km(t,n)}_callParseArg(t,n,i,r){try{return t.parseArg(n,i)}catch(o){if(o.code==="commander.invalidArgument"){let s=`${r} ${o.message}`;this.error(s,{exitCode:o.exitCode,code:o.code})}throw o}}_registerOption(t){let n=t.short&&this._findOption(t.short)||t.long&&this._findOption(t.long);if(n){let i=t.long&&this._findOption(t.long)?t.long:t.short;throw new Error(`Cannot add option '${t.flags}'${this._name&&` to command '${this._name}'`} due to conflicting flag '${i}' - already used by option '${n.flags}'`)}this._initOptionGroup(t),this.options.push(t)}_registerCommand(t){let n=a(r=>[r.name()].concat(r.aliases()),"knownBy"),i=n(t).find(r=>this._findCommand(r));if(i){let r=n(this._findCommand(i)).join("|"),o=n(t).join("|");throw new Error(`cannot add command '${o}' as already have command '${r}'`)}this._initCommandGroup(t),this.commands.push(t)}addOption(t){this._registerOption(t);let n=t.name(),i=t.attributeName();if(t.negate){let o=t.long.replace(/^--no-/,"--");this._findOption(o)||this.setOptionValueWithSource(i,t.defaultValue===void 0?!0:t.defaultValue,"default")}else t.defaultValue!==void 0&&this.setOptionValueWithSource(i,t.defaultValue,"default");let r=a((o,s,u)=>{o==null&&t.presetArg!==void 0&&(o=t.presetArg);let l=this.getOptionValue(i);o!==null&&t.parseArg?o=this._callParseArg(t,o,l,s):o!==null&&t.variadic&&(o=t._concatValue(o,l)),o==null&&(t.negate?o=!1:t.isBoolean()||t.optional?o=!0:o=""),this.setOptionValueWithSource(i,o,u)},"handleOptionValue");return this.on("option:"+n,o=>{let s=`error: option '${t.flags}' argument '${o}' is invalid.`;r(o,s,"cli")}),t.envVar&&this.on("optionEnv:"+n,o=>{let s=`error: option '${t.flags}' value '${o}' from env '${t.envVar}' is invalid.`;r(o,s,"env")}),this}_optionEx(t,n,i,r,o){if(typeof n=="object"&&n instanceof Km)throw new Error("To add an Option object use addOption() instead of option() or requiredOption()");let s=this.createOption(n,i);if(s.makeOptionMandatory(!!t.mandatory),typeof r=="function")s.default(o).argParser(r);else if(r instanceof RegExp){let u=r;r=a((l,c)=>{let m=u.exec(l);return m?m[0]:c},"fn"),s.default(o).argParser(r)}else s.default(r);return this.addOption(s)}option(t,n,i,r){return this._optionEx({},t,n,i,r)}requiredOption(t,n,i,r){return this._optionEx({mandatory:!0},t,n,i,r)}combineFlagAndOptionalValue(t=!0){return this._combineFlagAndOptionalValue=!!t,this}allowUnknownOption(t=!0){return this._allowUnknownOption=!!t,this}allowExcessArguments(t=!0){return this._allowExcessArguments=!!t,this}enablePositionalOptions(t=!0){return this._enablePositionalOptions=!!t,this}passThroughOptions(t=!0){return this._passThroughOptions=!!t,this._checkForBrokenPassThrough(),this}_checkForBrokenPassThrough(){if(this.parent&&this._passThroughOptions&&!this.parent._enablePositionalOptions)throw new Error(`passThroughOptions cannot be used for '${this._name}' without turning on enablePositionalOptions for parent command(s)`)}storeOptionsAsProperties(t=!0){if(this.options.length)throw new Error("call .storeOptionsAsProperties() before adding options");if(Object.keys(this._optionValues).length)throw new Error("call .storeOptionsAsProperties() before setting option values");return this._storeOptionsAsProperties=!!t,this}getOptionValue(t){return this._storeOptionsAsProperties?this[t]:this._optionValues[t]}setOptionValue(t,n){return this.setOptionValueWithSource(t,n,void 0)}setOptionValueWithSource(t,n,i){return this._storeOptionsAsProperties?this[t]=n:this._optionValues[t]=n,this._optionValueSources[t]=i,this}getOptionValueSource(t){return this._optionValueSources[t]}getOptionValueSourceWithGlobals(t){let n;return this._getCommandAndAncestors().forEach(i=>{i.getOptionValueSource(t)!==void 0&&(n=i.getOptionValueSource(t))}),n}_prepareUserArgs(t,n){if(t!==void 0&&!Array.isArray(t))throw new Error("first parameter to parse must be array or undefined");if(n=n||{},t===void 0&&n.from===void 0){Q.versions?.electron&&(n.from="electron");let r=Q.execArgv??[];(r.includes("-e")||r.includes("--eval")||r.includes("-p")||r.includes("--print"))&&(n.from="eval")}t===void 0&&(t=Q.argv),this.rawArgs=t.slice();let i;switch(n.from){case void 0:case"node":this._scriptPath=t[1],i=t.slice(2);break;case"electron":Q.defaultApp?(this._scriptPath=t[1],i=t.slice(2)):i=t.slice(1);break;case"user":i=t.slice(0);break;case"eval":i=t.slice(1);break;default:throw new Error(`unexpected parse option { from: '${n.from}' }`)}return!this._name&&this._scriptPath&&this.nameFromFilename(this._scriptPath),this._name=this._name||"program",i}parse(t,n){this._prepareForParse();let i=this._prepareUserArgs(t,n);return this._parseCommand([],i),this}async parseAsync(t,n){this._prepareForParse();let i=this._prepareUserArgs(t,n);return await this._parseCommand([],i),this}_prepareForParse(){this._savedState===null?this.saveStateBeforeParse():this.restoreStateBeforeParse()}saveStateBeforeParse(){this._savedState={_name:this._name,_optionValues:{...this._optionValues},_optionValueSources:{...this._optionValueSources}}}restoreStateBeforeParse(){if(this._storeOptionsAsProperties)throw new Error(`Can not call parse again when storeOptionsAsProperties is true. - either make a new Command for each call to parse, or stop storing options as properties`);this._name=this._savedState._name,this._scriptPath=null,this.rawArgs=[],this._optionValues={...this._savedState._optionValues},this._optionValueSources={...this._savedState._optionValueSources},this.args=[],this.processedArgs=[]}_checkForMissingExecutable(t,n,i){if(Kn.existsSync(t))return;let r=n?`searched for local subcommand relative to directory '${n}'`:"no directory for search for local subcommand, use .executableDir() to supply a custom directory",o=`'${t}' does not exist - if '${i}' is not meant to be an executable command, remove description parameter from '.command()' and use '.description()' instead - if the default executable name is not suitable, use the executableFile option to supply a custom name or path - ${r}`;throw new Error(o)}_executeSubCommand(t,n){n=n.slice();let i=!1,r=[".js",".ts",".tsx",".mjs",".cjs"];function o(m,p){let h=ut.resolve(m,p);if(Kn.existsSync(h))return h;if(r.includes(ut.extname(p)))return;let d=r.find(g=>Kn.existsSync(`${h}${g}`));if(d)return`${h}${d}`}a(o,"findFile"),this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let s=t._executableFile||`${this._name}-${t._name}`,u=this._executableDir||"";if(this._scriptPath){let m;try{m=Kn.realpathSync(this._scriptPath)}catch{m=this._scriptPath}u=ut.resolve(ut.dirname(m),u)}if(u){let m=o(u,s);if(!m&&!t._executableFile&&this._scriptPath){let p=ut.basename(this._scriptPath,ut.extname(this._scriptPath));p!==this._name&&(m=o(u,`${p}-${t._name}`))}s=m||s}i=r.includes(ut.extname(s));let l;Q.platform!=="win32"?i?(n.unshift(s),n=Qm(Q.execArgv).concat(n),l=ta.spawn(Q.argv[0],n,{stdio:"inherit"})):l=ta.spawn(s,n,{stdio:"inherit"}):(this._checkForMissingExecutable(s,u,t._name),n.unshift(s),n=Qm(Q.execArgv).concat(n),l=ta.spawn(Q.execPath,n,{stdio:"inherit"})),l.killed||["SIGUSR1","SIGUSR2","SIGTERM","SIGINT","SIGHUP"].forEach(p=>{Q.on(p,()=>{l.killed===!1&&l.exitCode===null&&l.kill(p)})});let c=this._exitCallback;l.on("close",m=>{m=m??1,c?c(new ra(m,"commander.executeSubCommandAsync","(close)")):Q.exit(m)}),l.on("error",m=>{if(m.code==="ENOENT")this._checkForMissingExecutable(s,u,t._name);else if(m.code==="EACCES")throw new Error(`'${s}' not executable`);if(!c)Q.exit(1);else{let p=new ra(1,"commander.executeSubCommandAsync","(error)");p.nestedError=m,c(p)}}),this.runningCommand=l}_dispatchSubcommand(t,n,i){let r=this._findCommand(t);r||this.help({error:!0}),r._prepareForParse();let o;return o=this._chainOrCallSubCommandHook(o,r,"preSubcommand"),o=this._chainOrCall(o,()=>{if(r._executableHandler)this._executeSubCommand(r,n.concat(i));else return r._parseCommand(n,i)}),o}_dispatchHelpCommand(t){t||this.help();let n=this._findCommand(t);return n&&!n._executableHandler&&n.help(),this._dispatchSubcommand(t,[],[this._getHelpOption()?.long??this._getHelpOption()?.short??"--help"])}_checkNumberOfArguments(){this.registeredArguments.forEach((t,n)=>{t.required&&this.args[n]==null&&this.missingArgument(t.name())}),!(this.registeredArguments.length>0&&this.registeredArguments[this.registeredArguments.length-1].variadic)&&this.args.length>this.registeredArguments.length&&this._excessArguments(this.args)}_processArguments(){let t=a((i,r,o)=>{let s=r;if(r!==null&&i.parseArg){let u=`error: command-argument value '${r}' is invalid for argument '${i.name()}'.`;s=this._callParseArg(i,r,o,u)}return s},"myParseArg");this._checkNumberOfArguments();let n=[];this.registeredArguments.forEach((i,r)=>{let o=i.defaultValue;i.variadic?r<this.args.length?(o=this.args.slice(r),i.parseArg&&(o=o.reduce((s,u)=>t(i,u,s),i.defaultValue))):o===void 0&&(o=[]):r<this.args.length&&(o=this.args[r],i.parseArg&&(o=t(i,o,i.defaultValue))),n[r]=o}),this.processedArgs=n}_chainOrCall(t,n){return t&&t.then&&typeof t.then=="function"?t.then(()=>n()):n()}_chainOrCallHooks(t,n){let i=t,r=[];return this._getCommandAndAncestors().reverse().filter(o=>o._lifeCycleHooks[n]!==void 0).forEach(o=>{o._lifeCycleHooks[n].forEach(s=>{r.push({hookedCommand:o,callback:s})})}),n==="postAction"&&r.reverse(),r.forEach(o=>{i=this._chainOrCall(i,()=>o.callback(o.hookedCommand,this))}),i}_chainOrCallSubCommandHook(t,n,i){let r=t;return this._lifeCycleHooks[i]!==void 0&&this._lifeCycleHooks[i].forEach(o=>{r=this._chainOrCall(r,()=>o(this,n))}),r}_parseCommand(t,n){let i=this.parseOptions(n);if(this._parseOptionsEnv(),this._parseOptionsImplied(),t=t.concat(i.operands),n=i.unknown,this.args=t.concat(n),t&&this._findCommand(t[0]))return this._dispatchSubcommand(t[0],t.slice(1),n);if(this._getHelpCommand()&&t[0]===this._getHelpCommand().name())return this._dispatchHelpCommand(t[1]);if(this._defaultCommandName)return this._outputHelpIfRequested(n),this._dispatchSubcommand(this._defaultCommandName,t,n);this.commands.length&&this.args.length===0&&!this._actionHandler&&!this._defaultCommandName&&this.help({error:!0}),this._outputHelpIfRequested(i.unknown),this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let r=a(()=>{i.unknown.length>0&&this.unknownOption(i.unknown[0])},"checkForUnknownOptions"),o=`command:${this.name()}`;if(this._actionHandler){r(),this._processArguments();let s;return s=this._chainOrCallHooks(s,"preAction"),s=this._chainOrCall(s,()=>this._actionHandler(this.processedArgs)),this.parent&&(s=this._chainOrCall(s,()=>{this.parent.emit(o,t,n)})),s=this._chainOrCallHooks(s,"postAction"),s}if(this.parent&&this.parent.listenerCount(o))r(),this._processArguments(),this.parent.emit(o,t,n);else if(t.length){if(this._findCommand("*"))return this._dispatchSubcommand("*",t,n);this.listenerCount("command:*")?this.emit("command:*",t,n):this.commands.length?this.unknownCommand():(r(),this._processArguments())}else this.commands.length?(r(),this.help({error:!0})):(r(),this._processArguments())}_findCommand(t){if(t)return this.commands.find(n=>n._name===t||n._aliases.includes(t))}_findOption(t){return this.options.find(n=>n.is(t))}_checkForMissingMandatoryOptions(){this._getCommandAndAncestors().forEach(t=>{t.options.forEach(n=>{n.mandatory&&t.getOptionValue(n.attributeName())===void 0&&t.missingMandatoryOptionValue(n)})})}_checkForConflictingLocalOptions(){let t=this.options.filter(i=>{let r=i.attributeName();return this.getOptionValue(r)===void 0?!1:this.getOptionValueSource(r)!=="default"});t.filter(i=>i.conflictsWith.length>0).forEach(i=>{let r=t.find(o=>i.conflictsWith.includes(o.attributeName()));r&&this._conflictingOption(i,r)})}_checkForConflictingOptions(){this._getCommandAndAncestors().forEach(t=>{t._checkForConflictingLocalOptions()})}parseOptions(t){let n=[],i=[],r=n,o=t.slice();function s(c){return c.length>1&&c[0]==="-"}a(s,"maybeOption");let u=a(c=>/^-\d*\.?\d+(e[+-]?\d+)?$/.test(c)?!this._getCommandAndAncestors().some(m=>m.options.map(p=>p.short).some(p=>/^-\d$/.test(p))):!1,"negativeNumberArg"),l=null;for(;o.length;){let c=o.shift();if(c==="--"){r===i&&r.push(c),r.push(...o);break}if(l&&(!s(c)||u(c))){this.emit(`option:${l.name()}`,c);continue}if(l=null,s(c)){let m=this._findOption(c);if(m){if(m.required){let p=o.shift();p===void 0&&this.optionMissingArgument(m),this.emit(`option:${m.name()}`,p)}else if(m.optional){let p=null;o.length>0&&(!s(o[0])||u(o[0]))&&(p=o.shift()),this.emit(`option:${m.name()}`,p)}else this.emit(`option:${m.name()}`);l=m.variadic?m:null;continue}}if(c.length>2&&c[0]==="-"&&c[1]!=="-"){let m=this._findOption(`-${c[1]}`);if(m){m.required||m.optional&&this._combineFlagAndOptionalValue?this.emit(`option:${m.name()}`,c.slice(2)):(this.emit(`option:${m.name()}`),o.unshift(`-${c.slice(2)}`));continue}}if(/^--[^=]+=/.test(c)){let m=c.indexOf("="),p=this._findOption(c.slice(0,m));if(p&&(p.required||p.optional)){this.emit(`option:${p.name()}`,c.slice(m+1));continue}}if(r===n&&s(c)&&!(this.commands.length===0&&u(c))&&(r=i),(this._enablePositionalOptions||this._passThroughOptions)&&n.length===0&&i.length===0){if(this._findCommand(c)){n.push(c),o.length>0&&i.push(...o);break}else if(this._getHelpCommand()&&c===this._getHelpCommand().name()){n.push(c),o.length>0&&n.push(...o);break}else if(this._defaultCommandName){i.push(c),o.length>0&&i.push(...o);break}}if(this._passThroughOptions){r.push(c),o.length>0&&r.push(...o);break}r.push(c)}return{operands:n,unknown:i}}opts(){if(this._storeOptionsAsProperties){let t={},n=this.options.length;for(let i=0;i<n;i++){let r=this.options[i].attributeName();t[r]=r===this._versionOptionName?this._version:this[r]}return t}return this._optionValues}optsWithGlobals(){return this._getCommandAndAncestors().reduce((t,n)=>Object.assign(t,n.opts()),{})}error(t,n){this._outputConfiguration.outputError(`${t} `,this._outputConfiguration.writeErr),typeof this._showHelpAfterError=="string"?this._outputConfiguration.writeErr(`${this._showHelpAfterError} `):this._showHelpAfterError&&(this._outputConfiguration.writeErr(` `),this.outputHelp({error:!0}));let i=n||{},r=i.exitCode||1,o=i.code||"commander.error";this._exit(r,o,t)}_parseOptionsEnv(){this.options.forEach(t=>{if(t.envVar&&t.envVar in Q.env){let n=t.attributeName();(this.getOptionValue(n)===void 0||["default","config","env"].includes(this.getOptionValueSource(n)))&&(t.required||t.optional?this.emit(`optionEnv:${t.name()}`,Q.env[t.envVar]):this.emit(`optionEnv:${t.name()}`))}})}_parseOptionsImplied(){let t=new ab(this.options),n=a(i=>this.getOptionValue(i)!==void 0&&!["default","implied"].includes(this.getOptionValueSource(i)),"hasCustomOptionValue");this.options.filter(i=>i.implied!==void 0&&n(i.attributeName())&&t.valueFromOption(this.getOptionValue(i.attributeName()),i)).forEach(i=>{Object.keys(i.implied).filter(r=>!n(r)).forEach(r=>{this.setOptionValueWithSource(r,i.implied[r],"implied")})})}missingArgument(t){let n=`error: missing required argument '${t}'`;this.error(n,{code:"commander.missingArgument"})}optionMissingArgument(t){let n=`error: option '${t.flags}' argument missing`;this.error(n,{code:"commander.optionMissingArgument"})}missingMandatoryOptionValue(t){let n=`error: required option '${t.flags}' not specified`;this.error(n,{code:"commander.missingMandatoryOptionValue"})}_conflictingOption(t,n){let i=a(s=>{let u=s.attributeName(),l=this.getOptionValue(u),c=this.options.find(p=>p.negate&&u===p.attributeName()),m=this.options.find(p=>!p.negate&&u===p.attributeName());return c&&(c.presetArg===void 0&&l===!1||c.presetArg!==void 0&&l===c.presetArg)?c:m||s},"findBestOptionFromValue"),r=a(s=>{let u=i(s),l=u.attributeName();return this.getOptionValueSource(l)==="env"?`environment variable '${u.envVar}'`:`option '${u.flags}'`},"getErrorMessage"),o=`error: ${r(t)} cannot be used with ${r(n)}`;this.error(o,{code:"commander.conflictingOption"})}unknownOption(t){if(this._allowUnknownOption)return;let n="";if(t.startsWith("--")&&this._showSuggestionAfterError){let r=[],o=this;do{let s=o.createHelp().visibleOptions(o).filter(u=>u.long).map(u=>u.long);r=r.concat(s),o=o.parent}while(o&&!o._enablePositionalOptions);n=Xm(t,r)}let i=`error: unknown option '${t}'${n}`;this.error(i,{code:"commander.unknownOption"})}_excessArguments(t){if(this._allowExcessArguments)return;let n=this.registeredArguments.length,i=n===1?"":"s",o=`error: too many arguments${this.parent?` for '${this.name()}'`:""}. Expected ${n} argument${i} but got ${t.length}.`;this.error(o,{code:"commander.excessArguments"})}unknownCommand(){let t=this.args[0],n="";if(this._showSuggestionAfterError){let r=[];this.createHelp().visibleCommands(this).forEach(o=>{r.push(o.name()),o.alias()&&r.push(o.alias())}),n=Xm(t,r)}let i=`error: unknown command '${t}'${n}`;this.error(i,{code:"commander.unknownCommand"})}version(t,n,i){if(t===void 0)return this._version;this._version=t,n=n||"-V, --version",i=i||"output the version number";let r=this.createOption(n,i);return this._versionOptionName=r.attributeName(),this._registerOption(r),this.on("option:"+r.name(),()=>{this._outputConfiguration.writeOut(`${t} `),this._exit(0,"commander.version",t)}),this}description(t,n){return t===void 0&&n===void 0?this._description:(this._description=t,n&&(this._argsDescription=n),this)}summary(t){return t===void 0?this._summary:(this._summary=t,this)}alias(t){if(t===void 0)return this._aliases[0];let n=this;if(this.commands.length!==0&&this.commands[this.commands.length-1]._executableHandler&&(n=this.commands[this.commands.length-1]),t===n._name)throw new Error("Command alias can't be the same as its name");let i=this.parent?._findCommand(t);if(i){let r=[i.name()].concat(i.aliases()).join("|");throw new Error(`cannot add alias '${t}' to command '${this.name()}' as already have command '${r}'`)}return n._aliases.push(t),this}aliases(t){return t===void 0?this._aliases:(t.forEach(n=>this.alias(n)),this)}usage(t){if(t===void 0){if(this._usage)return this._usage;let n=this.registeredArguments.map(i=>nb(i));return[].concat(this.options.length||this._helpOption!==null?"[options]":[],this.commands.length?"[command]":[],this.registeredArguments.length?n:[]).join(" ")}return this._usage=t,this}name(t){return t===void 0?this._name:(this._name=t,this)}helpGroup(t){return t===void 0?this._helpGroupHeading??"":(this._helpGroupHeading=t,this)}commandsGroup(t){return t===void 0?this._defaultCommandGroup??"":(this._defaultCommandGroup=t,this)}optionsGroup(t){return t===void 0?this._defaultOptionGroup??"":(this._defaultOptionGroup=t,this)}_initOptionGroup(t){this._defaultOptionGroup&&!t.helpGroupHeading&&t.helpGroup(this._defaultOptionGroup)}_initCommandGroup(t){this._defaultCommandGroup&&!t.helpGroup()&&t.helpGroup(this._defaultCommandGroup)}nameFromFilename(t){return this._name=ut.basename(t,ut.extname(t)),this}executableDir(t){return t===void 0?this._executableDir:(this._executableDir=t,this)}helpInformation(t){let n=this.createHelp(),i=this._getOutputContext(t);n.prepareContext({error:i.error,helpWidth:i.helpWidth,outputHasColors:i.hasColors});let r=n.formatHelp(this,n);return i.hasColors?r:this._outputConfiguration.stripColor(r)}_getOutputContext(t){t=t||{};let n=!!t.error,i,r,o;return n?(i=a(u=>this._outputConfiguration.writeErr(u),"baseWrite"),r=this._outputConfiguration.getErrHasColors(),o=this._outputConfiguration.getErrHelpWidth()):(i=a(u=>this._outputConfiguration.writeOut(u),"baseWrite"),r=this._outputConfiguration.getOutHasColors(),o=this._outputConfiguration.getOutHelpWidth()),{error:n,write:a(u=>(r||(u=this._outputConfiguration.stripColor(u)),i(u)),"write"),hasColors:r,helpWidth:o}}outputHelp(t){let n;typeof t=="function"&&(n=t,t=void 0);let i=this._getOutputContext(t),r={error:i.error,write:i.write,command:this};this._getCommandAndAncestors().reverse().forEach(s=>s.emit("beforeAllHelp",r)),this.emit("beforeHelp",r);let o=this.helpInformation({error:i.error});if(n&&(o=n(o),typeof o!="string"&&!Buffer.isBuffer(o)))throw new Error("outputHelp callback must return a string or a Buffer");i.write(o),this._getHelpOption()?.long&&this.emit(this._getHelpOption().long),this.emit("afterHelp",r),this._getCommandAndAncestors().forEach(s=>s.emit("afterAllHelp",r))}helpOption(t,n){return typeof t=="boolean"?(t?(this._helpOption===null&&(this._helpOption=void 0),this._defaultOptionGroup&&this._initOptionGroup(this._getHelpOption())):this._helpOption=null,this):(this._helpOption=this.createOption(t??"-h, --help",n??"display help for command"),(t||n)&&this._initOptionGroup(this._helpOption),this)}_getHelpOption(){return this._helpOption===void 0&&this.helpOption(void 0,void 0),this._helpOption}addHelpOption(t){return this._helpOption=t,this._initOptionGroup(t),this}help(t){this.outputHelp(t);let n=Number(Q.exitCode??0);n===0&&t&&typeof t!="function"&&t.error&&(n=1),this._exit(n,"commander.help","(outputHelp)")}addHelpText(t,n){let i=["beforeAll","before","after","afterAll"];if(!i.includes(t))throw new Error(`Unexpected value for position to addHelpText. Expecting one of '${i.join("', '")}'`);let r=`${t}Help`;return this.on(r,o=>{let s;typeof n=="function"?s=n({error:o.error,command:o.command}):s=n,s&&o.write(`${s} `)}),this}_outputHelpIfRequested(t){let n=this._getHelpOption();n&&t.find(r=>n.is(r))&&(this.outputHelp(),this._exit(0,"commander.helpDisplayed","(outputHelp)"))}};function Qm(e){return e.map(t=>{if(!t.startsWith("--inspect"))return t;let n,i="127.0.0.1",r="9229",o;return(o=t.match(/^(--inspect(-brk)?)$/))!==null?n=o[1]:(o=t.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))!==null?(n=o[1],/^\d+$/.test(o[3])?r=o[3]:i=o[3]):(o=t.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null&&(n=o[1],i=o[3],r=o[4]),n&&r!=="0"?`${n}=${i}:${parseInt(r)+1}`:t})}a(Qm,"incrementNodeInspectorPort");function ia(){if(Q.env.NO_COLOR||Q.env.FORCE_COLOR==="0"||Q.env.FORCE_COLOR==="false")return!1;if(Q.env.FORCE_COLOR||Q.env.CLICOLOR_FORCE!==void 0)return!0}a(ia,"useColor");oa.Command=na;oa.useColor=ia});var nf=St(Le=>{var{Argument:ef}=Jn(),{Command:aa}=Ym(),{CommanderError:sb,InvalidArgumentError:tf}=qr(),{Help:ub}=Ko(),{Option:rf}=ea();Le.program=new aa;Le.createCommand=e=>new aa(e);Le.createOption=(e,t)=>new rf(e,t);Le.createArgument=(e,t)=>new ef(e,t);Le.Command=aa;Le.Option=rf;Le.Argument=ef;Le.Help=ub;Le.CommanderError=sb;Le.InvalidArgumentError=tf;Le.InvalidOptionArgumentError=tf});var _g=St((UL,kg)=>{"use strict";var $o=Object.prototype.hasOwnProperty,Sg=Object.prototype.toString,hg=Object.defineProperty,gg=Object.getOwnPropertyDescriptor,yg=a(function(t){return typeof Array.isArray=="function"?Array.isArray(t):Sg.call(t)==="[object Array]"},"isArray"),bg=a(function(t){if(!t||Sg.call(t)!=="[object Object]")return!1;var n=$o.call(t,"constructor"),i=t.constructor&&t.constructor.prototype&&$o.call(t.constructor.prototype,"isPrototypeOf");if(t.constructor&&!n&&!i)return!1;var r;for(r in t);return typeof r>"u"||$o.call(t,r)},"isPlainObject"),xg=a(function(t,n){hg&&n.name==="__proto__"?hg(t,n.name,{enumerable:!0,configurable:!0,value:n.newValue,writable:!0}):t[n.name]=n.newValue},"setProperty"),vg=a(function(t,n){if(n==="__proto__")if($o.call(t,n)){if(gg)return gg(t,n).value}else return;return t[n]},"getProperty");kg.exports=a(function e(){var t,n,i,r,o,s,u=arguments[0],l=1,c=arguments.length,m=!1;for(typeof u=="boolean"&&(m=u,u=arguments[1]||{},l=2),(u==null||typeof u!="object"&&typeof u!="function")&&(u={});l<c;++l)if(t=arguments[l],t!=null)for(n in t)i=vg(u,n),r=vg(t,n),u!==r&&(m&&r&&(bg(r)||(o=yg(r)))?(o?(o=!1,s=i&&yg(i)?i:[]):s=i&&bg(i)?i:{},xg(u,{name:n,newValue:e(m,s,r)})):typeof r<"u"&&xg(u,{name:n,newValue:r}));return u},"extend")});var aE={};Ke(aE,{main:()=>Py,parseCLI:()=>Ny,setupCLI:()=>Ay});module.exports=Wy(aE);var of=Vr(nf(),1),{program:SE,createCommand:kE,createArgument:_E,createOption:wE,CommanderError:$E,InvalidArgumentError:zE,InvalidOptionArgumentError:IE,Command:af,Argument:EE,Option:CE,Help:OE}=of.default;var Gd=require("crypto");var Pd=require("crypto");var Pe={};Ke(Pe,{$brand:()=>ua,$input:()=>ml,$output:()=>pl,NEVER:()=>sa,TimePrecision:()=>hl,ZodAny:()=>qf,ZodArray:()=>Gf,ZodBase64:()=>Ac,ZodBase64URL:()=>Nc,ZodBigInt:()=>Cn,ZodBigIntFormat:()=>Dc,ZodBoolean:()=>En,ZodCIDRv4:()=>Oc,ZodCIDRv6:()=>Tc,ZodCUID:()=>_c,ZodCUID2:()=>wc,ZodCatch:()=>fd,ZodCodec:()=>Bc,ZodCustom:()=>to,ZodCustomStringFormat:()=>zn,ZodDate:()=>Qi,ZodDefault:()=>sd,ZodDiscriminatedUnion:()=>Jf,ZodE164:()=>Pc,ZodEmail:()=>vc,ZodEmoji:()=>Sc,ZodEnum:()=>wn,ZodError:()=>Av,ZodFile:()=>id,ZodFirstPartyTypeKind:()=>Wc,ZodFunction:()=>kd,ZodGUID:()=>Wi,ZodIPv4:()=>Ec,ZodIPv6:()=>Cc,ZodISODate:()=>Vi,ZodISODateTime:()=>Fi,ZodISODuration:()=>Hi,ZodISOTime:()=>qi,ZodIntersection:()=>Kf,ZodIssueCode:()=>VS,ZodJWT:()=>jc,ZodKSUID:()=>Ic,ZodLazy:()=>xd,ZodLiteral:()=>nd,ZodMap:()=>td,ZodNaN:()=>hd,ZodNanoID:()=>kc,ZodNever:()=>Bf,ZodNonOptional:()=>qc,ZodNull:()=>Ff,ZodNullable:()=>ad,ZodNumber:()=>In,ZodNumberFormat:()=>xr,ZodObject:()=>eo,ZodOptional:()=>Vc,ZodPipe:()=>Hc,ZodPrefault:()=>ld,ZodPromise:()=>Sd,ZodReadonly:()=>gd,ZodRealError:()=>Ie,ZodRecord:()=>Zc,ZodSet:()=>rd,ZodString:()=>$n,ZodStringFormat:()=>ne,ZodSuccess:()=>md,ZodSymbol:()=>Zf,ZodTemplateLiteral:()=>bd,ZodTransform:()=>od,ZodTuple:()=>Qf,ZodType:()=>q,ZodULID:()=>$c,ZodURL:()=>Xi,ZodUUID:()=>ft,ZodUndefined:()=>Mf,ZodUnion:()=>Lc,ZodUnknown:()=>Hf,ZodVoid:()=>Wf,ZodXID:()=>zc,_ZodString:()=>xc,_default:()=>ud,_function:()=>DS,any:()=>gS,array:()=>Yi,base64:()=>Yv,base64url:()=>eS,bigint:()=>pS,boolean:()=>Uf,catch:()=>dd,check:()=>RS,cidrv4:()=>Xv,cidrv6:()=>Qv,clone:()=>_e,codec:()=>NS,coerce:()=>Gc,config:()=>ce,core:()=>mt,cuid:()=>qv,cuid2:()=>Hv,custom:()=>LS,date:()=>bS,decode:()=>cc,decodeAsync:()=>mc,discriminatedUnion:()=>_S,e164:()=>tS,email:()=>Pv,emoji:()=>Fv,encode:()=>lc,encodeAsync:()=>pc,endsWith:()=>yn,enum:()=>Mc,file:()=>CS,flattenError:()=>Yr,float32:()=>sS,float64:()=>uS,formatError:()=>en,function:()=>DS,getErrorMap:()=>HS,globalRegistry:()=>Qe,gt:()=>ct,gte:()=>ze,guid:()=>jv,hash:()=>aS,hex:()=>oS,hostname:()=>iS,httpUrl:()=>Mv,includes:()=>hn,instanceof:()=>US,int:()=>bc,int32:()=>lS,int64:()=>mS,intersection:()=>Xf,ipv4:()=>Jv,ipv6:()=>Kv,iso:()=>Bi,json:()=>MS,jwt:()=>rS,keyof:()=>xS,ksuid:()=>Gv,lazy:()=>vd,length:()=>gr,literal:()=>ES,locales:()=>un,looseObject:()=>kS,lowercase:()=>fn,lt:()=>lt,lte:()=>Ze,map:()=>$S,maxLength:()=>hr,maxSize:()=>dr,mime:()=>bn,minLength:()=>Et,minSize:()=>qt,multipleOf:()=>Vt,nan:()=>AS,nanoid:()=>Vv,nativeEnum:()=>IS,negative:()=>ql,never:()=>Rc,nonnegative:()=>Bl,nonoptional:()=>pd,nonpositive:()=>Hl,normalize:()=>xn,null:()=>Vf,nullable:()=>Ji,nullish:()=>OS,number:()=>Lf,object:()=>vS,optional:()=>Gi,overwrite:()=>pt,parse:()=>oc,parseAsync:()=>ac,partialRecord:()=>wS,pipe:()=>Ki,positive:()=>Vl,prefault:()=>cd,preprocess:()=>FS,prettifyError:()=>xa,promise:()=>jS,property:()=>Wl,readonly:()=>yd,record:()=>ed,refine:()=>_d,regex:()=>mn,regexes:()=>Ue,registry:()=>Si,safeDecode:()=>dc,safeDecodeAsync:()=>gc,safeEncode:()=>fc,safeEncodeAsync:()=>hc,safeParse:()=>sc,safeParseAsync:()=>uc,set:()=>zS,setErrorMap:()=>qS,size:()=>pn,startsWith:()=>gn,strictObject:()=>SS,string:()=>yc,stringFormat:()=>nS,stringbool:()=>ZS,success:()=>TS,superRefine:()=>wd,symbol:()=>dS,templateLiteral:()=>PS,toJSONSchema:()=>ec,toLowerCase:()=>Sn,toUpperCase:()=>kn,transform:()=>Fc,treeifyError:()=>ba,trim:()=>vn,tuple:()=>Yf,uint32:()=>cS,uint64:()=>fS,ulid:()=>Bv,undefined:()=>hS,union:()=>Uc,unknown:()=>br,uppercase:()=>dn,url:()=>Zv,util:()=>O,uuid:()=>Dv,uuidv4:()=>Rv,uuidv6:()=>Lv,uuidv7:()=>Uv,void:()=>yS,xid:()=>Wv});var mt={};Ke(mt,{$ZodAny:()=>Ws,$ZodArray:()=>Qs,$ZodAsyncError:()=>We,$ZodBase64:()=>Rs,$ZodBase64URL:()=>Ls,$ZodBigInt:()=>bi,$ZodBigIntFormat:()=>Vs,$ZodBoolean:()=>on,$ZodCIDRv4:()=>Ps,$ZodCIDRv6:()=>js,$ZodCUID:()=>_s,$ZodCUID2:()=>ws,$ZodCatch:()=>hu,$ZodCheck:()=>oe,$ZodCheckBigIntFormat:()=>Ya,$ZodCheckEndsWith:()=>ps,$ZodCheckGreaterThan:()=>pi,$ZodCheckIncludes:()=>ls,$ZodCheckLengthEquals:()=>os,$ZodCheckLessThan:()=>ci,$ZodCheckLowerCase:()=>ss,$ZodCheckMaxLength:()=>ns,$ZodCheckMaxSize:()=>es,$ZodCheckMimeType:()=>fs,$ZodCheckMinLength:()=>is,$ZodCheckMinSize:()=>ts,$ZodCheckMultipleOf:()=>Xa,$ZodCheckNumberFormat:()=>Qa,$ZodCheckOverwrite:()=>ds,$ZodCheckProperty:()=>ms,$ZodCheckRegex:()=>as,$ZodCheckSizeEquals:()=>rs,$ZodCheckStartsWith:()=>cs,$ZodCheckStringFormat:()=>mr,$ZodCheckUpperCase:()=>us,$ZodCodec:()=>an,$ZodCustom:()=>_u,$ZodCustomStringFormat:()=>Ms,$ZodDate:()=>Xs,$ZodDefault:()=>pu,$ZodDiscriminatedUnion:()=>eu,$ZodE164:()=>Us,$ZodEmail:()=>xs,$ZodEmoji:()=>Ss,$ZodEncodeError:()=>kt,$ZodEnum:()=>ou,$ZodError:()=>Qr,$ZodFile:()=>su,$ZodFunction:()=>vu,$ZodGUID:()=>ys,$ZodIPv4:()=>As,$ZodIPv6:()=>Ns,$ZodISODate:()=>Cs,$ZodISODateTime:()=>Es,$ZodISODuration:()=>Ts,$ZodISOTime:()=>Os,$ZodIntersection:()=>tu,$ZodJWT:()=>Zs,$ZodKSUID:()=>Is,$ZodLazy:()=>ku,$ZodLiteral:()=>au,$ZodMap:()=>nu,$ZodNaN:()=>gu,$ZodNanoID:()=>ks,$ZodNever:()=>Js,$ZodNonOptional:()=>fu,$ZodNull:()=>Bs,$ZodNullable:()=>cu,$ZodNumber:()=>yi,$ZodNumberFormat:()=>Fs,$ZodObject:()=>Tf,$ZodObjectJIT:()=>Ys,$ZodOptional:()=>lu,$ZodPipe:()=>yu,$ZodPrefault:()=>mu,$ZodPromise:()=>Su,$ZodReadonly:()=>bu,$ZodRealError:()=>$e,$ZodRecord:()=>ru,$ZodRegistry:()=>fr,$ZodSet:()=>iu,$ZodString:()=>Ft,$ZodStringFormat:()=>re,$ZodSuccess:()=>du,$ZodSymbol:()=>qs,$ZodTemplateLiteral:()=>xu,$ZodTransform:()=>uu,$ZodTuple:()=>vi,$ZodType:()=>Z,$ZodULID:()=>$s,$ZodURL:()=>vs,$ZodUUID:()=>bs,$ZodUndefined:()=>Hs,$ZodUnion:()=>xi,$ZodUnknown:()=>Gs,$ZodVoid:()=>Ks,$ZodXID:()=>zs,$brand:()=>ua,$constructor:()=>x,$input:()=>ml,$output:()=>pl,Doc:()=>nn,JSONSchema:()=>jf,JSONSchemaGenerator:()=>_n,NEVER:()=>sa,TimePrecision:()=>hl,_any:()=>Dl,_array:()=>Gl,_base64:()=>Li,_base64url:()=>Ui,_bigint:()=>Cl,_boolean:()=>Il,_catch:()=>$v,_check:()=>Pf,_cidrv4:()=>Di,_cidrv6:()=>Ri,_coercedBigint:()=>Ol,_coercedBoolean:()=>El,_coercedDate:()=>Ml,_coercedNumber:()=>Sl,_coercedString:()=>dl,_cuid:()=>Ci,_cuid2:()=>Oi,_custom:()=>Kl,_date:()=>Zl,_decode:()=>ri,_decodeAsync:()=>ii,_default:()=>kv,_discriminatedUnion:()=>cv,_e164:()=>Zi,_email:()=>ki,_emoji:()=>Ii,_encode:()=>ti,_encodeAsync:()=>ni,_endsWith:()=>yn,_enum:()=>gv,_file:()=>Jl,_float32:()=>_l,_float64:()=>wl,_gt:()=>ct,_gte:()=>ze,_guid:()=>ln,_includes:()=>hn,_int:()=>kl,_int32:()=>$l,_int64:()=>Tl,_intersection:()=>pv,_ipv4:()=>Pi,_ipv6:()=>ji,_isoDate:()=>yl,_isoDateTime:()=>gl,_isoDuration:()=>xl,_isoTime:()=>bl,_jwt:()=>Mi,_ksuid:()=>Ni,_lazy:()=>Cv,_length:()=>gr,_literal:()=>bv,_lowercase:()=>fn,_lt:()=>lt,_lte:()=>Ze,_map:()=>dv,_max:()=>Ze,_maxLength:()=>hr,_maxSize:()=>dr,_mime:()=>bn,_min:()=>ze,_minLength:()=>Et,_minSize:()=>qt,_multipleOf:()=>Vt,_nan:()=>Fl,_nanoid:()=>Ei,_nativeEnum:()=>yv,_negative:()=>ql,_never:()=>Ll,_nonnegative:()=>Bl,_n