@vazco/uniforms-cli
Version:
CLI for uniforms
32 lines • 221 kB
JavaScript
var So=(s,t,r)=>{if(!t.has(s))throw TypeError("Cannot "+r)};var te=(s,t,r)=>(So(s,t,"read from private field"),r?r.call(s):t.get(s)),Ke=(s,t,r)=>{if(t.has(s))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(s):t.set(s,r)},Ce=(s,t,r,n)=>(So(s,t,"write to private field"),n?n.call(s,r):t.set(s,r),r);var Le,Zt,qt,Vr,kt,Kt,Xt,yl,ge,_l;import hh from"node:events";import ch,{execSync as $r}from"node:child_process";import me,{join as vo,dirname as dh}from"node:path";import Y,{readdirSync as Co,existsSync as Ro,rmSync as fh,mkdirSync as mh}from"node:fs";import ph from"node:process";import To from"readline";import Po from"events";import Nt from"node:http";import gh from"node:https";import Pt from"node:zlib";import Re,{PassThrough as xr,pipeline as Ot}from"node:stream";import{Buffer as ne}from"node:buffer";import{types as qr,promisify as bh,deprecate as kr}from"node:util";import{format as yh}from"node:url";import{isIP as _h}from"node:net";import wh from"node:os";var Ai=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Sh(s){return s&&s.__esModule&&Object.prototype.hasOwnProperty.call(s,"default")?s.default:s}var pe={},Vt={},At={};let Oo=class extends Error{constructor(t,r,n){super(n),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=r,this.exitCode=t,this.nestedError=void 0}},vh=class extends Oo{constructor(t){super(1,"commander.invalidArgument",t),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}};At.CommanderError=Oo,At.InvalidArgumentError=vh;const{InvalidArgumentError:Ch}=At;let Rh=class{constructor(t,r){switch(this.description=r||"",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,r){return r===this.defaultValue||!Array.isArray(r)?[t]:r.concat(t)}default(t,r){return this.defaultValue=t,this.defaultValueDescription=r,this}argParser(t){return this.parseArg=t,this}choices(t){return this.argChoices=t.slice(),this.parseArg=(r,n)=>{if(!this.argChoices.includes(r))throw new Ch(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._concatValue(r,n):r},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}};function Th(s){const t=s.name()+(s.variadic===!0?"...":"");return s.required?"<"+t+">":"["+t+"]"}Vt.Argument=Rh,Vt.humanReadableArgName=Th;var Ao={},Ei={};const{humanReadableArgName:Ph}=Vt;let Oh=class{constructor(){this.helpWidth=void 0,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}visibleCommands(t){const r=t.commands.filter(o=>!o._hidden),n=t._getHelpCommand();return n&&!n._hidden&&r.push(n),this.sortSubcommands&&r.sort((o,u)=>o.name().localeCompare(u.name())),r}compareOptions(t,r){const n=o=>o.short?o.short.replace(/^-/,""):o.long.replace(/^--/,"");return n(t).localeCompare(n(r))}visibleOptions(t){const r=t.options.filter(o=>!o.hidden),n=t._getHelpOption();if(n&&!n.hidden){const o=n.short&&t._findOption(n.short),u=n.long&&t._findOption(n.long);!o&&!u?r.push(n):n.long&&!u?r.push(t.createOption(n.long,n.description)):n.short&&!o&&r.push(t.createOption(n.short,n.description))}return this.sortOptions&&r.sort(this.compareOptions),r}visibleGlobalOptions(t){if(!this.showGlobalOptions)return[];const r=[];for(let n=t.parent;n;n=n.parent){const o=n.options.filter(u=>!u.hidden);r.push(...o)}return this.sortOptions&&r.sort(this.compareOptions),r}visibleArguments(t){return t._argsDescription&&t.registeredArguments.forEach(r=>{r.description=r.description||t._argsDescription[r.name()]||""}),t.registeredArguments.find(r=>r.description)?t.registeredArguments:[]}subcommandTerm(t){const r=t.registeredArguments.map(n=>Ph(n)).join(" ");return t._name+(t._aliases[0]?"|"+t._aliases[0]:"")+(t.options.length?" [options]":"")+(r?" "+r:"")}optionTerm(t){return t.flags}argumentTerm(t){return t.name()}longestSubcommandTermLength(t,r){return r.visibleCommands(t).reduce((n,o)=>Math.max(n,r.subcommandTerm(o).length),0)}longestOptionTermLength(t,r){return r.visibleOptions(t).reduce((n,o)=>Math.max(n,r.optionTerm(o).length),0)}longestGlobalOptionTermLength(t,r){return r.visibleGlobalOptions(t).reduce((n,o)=>Math.max(n,r.optionTerm(o).length),0)}longestArgumentTermLength(t,r){return r.visibleArguments(t).reduce((n,o)=>Math.max(n,r.argumentTerm(o).length),0)}commandUsage(t){let r=t._name;t._aliases[0]&&(r=r+"|"+t._aliases[0]);let n="";for(let o=t.parent;o;o=o.parent)n=o.name()+" "+n;return n+r+" "+t.usage()}commandDescription(t){return t.description()}subcommandDescription(t){return t.summary()||t.description()}optionDescription(t){const r=[];return t.argChoices&&r.push(`choices: ${t.argChoices.map(n=>JSON.stringify(n)).join(", ")}`),t.defaultValue!==void 0&&(t.required||t.optional||t.isBoolean()&&typeof t.defaultValue=="boolean")&&r.push(`default: ${t.defaultValueDescription||JSON.stringify(t.defaultValue)}`),t.presetArg!==void 0&&t.optional&&r.push(`preset: ${JSON.stringify(t.presetArg)}`),t.envVar!==void 0&&r.push(`env: ${t.envVar}`),r.length>0?`${t.description} (${r.join(", ")})`:t.description}argumentDescription(t){const r=[];if(t.argChoices&&r.push(`choices: ${t.argChoices.map(n=>JSON.stringify(n)).join(", ")}`),t.defaultValue!==void 0&&r.push(`default: ${t.defaultValueDescription||JSON.stringify(t.defaultValue)}`),r.length>0){const n=`(${r.join(", ")})`;return t.description?`${t.description} ${n}`:n}return t.description}formatHelp(t,r){const n=r.padWidth(t,r),o=r.helpWidth||80,u=2,l=2;function y(m,R){if(R){const v=`${m.padEnd(n+l)}${R}`;return r.wrap(v,o-u,n+l)}return m}function c(m){return m.join(`
`).replace(/^/gm," ".repeat(u))}let d=[`Usage: ${r.commandUsage(t)}`,""];const h=r.commandDescription(t);h.length>0&&(d=d.concat([r.wrap(h,o,0),""]));const g=r.visibleArguments(t).map(m=>y(r.argumentTerm(m),r.argumentDescription(m)));g.length>0&&(d=d.concat(["Arguments:",c(g),""]));const p=r.visibleOptions(t).map(m=>y(r.optionTerm(m),r.optionDescription(m)));if(p.length>0&&(d=d.concat(["Options:",c(p),""])),this.showGlobalOptions){const m=r.visibleGlobalOptions(t).map(R=>y(r.optionTerm(R),r.optionDescription(R)));m.length>0&&(d=d.concat(["Global Options:",c(m),""]))}const b=r.visibleCommands(t).map(m=>y(r.subcommandTerm(m),r.subcommandDescription(m)));return b.length>0&&(d=d.concat(["Commands:",c(b),""])),d.join(`
`)}padWidth(t,r){return Math.max(r.longestOptionTermLength(t,r),r.longestGlobalOptionTermLength(t,r),r.longestSubcommandTermLength(t,r),r.longestArgumentTermLength(t,r))}wrap(t,r,n,o=40){const u=" \\f\\t\\v\xA0\u1680\u2000-\u200A\u202F\u205F\u3000\uFEFF",l=new RegExp(`[\\n][${u}]+`);if(t.match(l))return t;const y=r-n;if(y<o)return t;const c=t.slice(0,n),d=t.slice(n).replace(`\r
`,`
`),h=" ".repeat(n),p="\\s\u200B",b=new RegExp(`
|.{1,${y-1}}([${p}]|$)|[^${p}]+?([${p}]|$)`,"g"),m=d.match(b)||[];return c+m.map((R,v)=>R===`
`?"":(v>0?h:"")+R.trimEnd()).join(`
`)}};Ei.Help=Oh;var Mr={};const{InvalidArgumentError:Ah}=At;let Eh=class{constructor(t,r){this.flags=t,this.description=r||"",this.required=t.includes("<"),this.optional=t.includes("["),this.variadic=/\w\.\.\.[>\]]$/.test(t),this.mandatory=!1;const n=qh(t);this.short=n.shortFlag,this.long=n.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}default(t,r){return this.defaultValue=t,this.defaultValueDescription=r,this}preset(t){return this.presetArg=t,this}conflicts(t){return this.conflictsWith=this.conflictsWith.concat(t),this}implies(t){let r=t;return typeof t=="string"&&(r={[t]:!0}),this.implied=Object.assign(this.implied||{},r),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,r){return r===this.defaultValue||!Array.isArray(r)?[t]:r.concat(t)}choices(t){return this.argChoices=t.slice(),this.parseArg=(r,n)=>{if(!this.argChoices.includes(r))throw new Ah(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._concatValue(r,n):r},this}name(){return this.long?this.long.replace(/^--/,""):this.short.replace(/^-/,"")}attributeName(){return xh(this.name().replace(/^no-/,""))}is(t){return this.short===t||this.long===t}isBoolean(){return!this.required&&!this.optional&&!this.negate}},$h=class{constructor(t){this.positiveOptions=new Map,this.negativeOptions=new Map,this.dualOptions=new Set,t.forEach(r=>{r.negate?this.negativeOptions.set(r.attributeName(),r):this.positiveOptions.set(r.attributeName(),r)}),this.negativeOptions.forEach((r,n)=>{this.positiveOptions.has(n)&&this.dualOptions.add(n)})}valueFromOption(t,r){const n=r.attributeName();if(!this.dualOptions.has(n))return!0;const o=this.negativeOptions.get(n).presetArg,u=o!==void 0?o:!1;return r.negate===(u===t)}};function xh(s){return s.split("-").reduce((t,r)=>t+r[0].toUpperCase()+r.slice(1))}function qh(s){let t,r;const n=s.split(/[ |,]+/);return n.length>1&&!/^[[<]/.test(n[1])&&(t=n.shift()),r=n.shift(),!t&&/^-[^-]$/.test(r)&&(t=r,r=void 0),{shortFlag:t,longFlag:r}}Mr.Option=Eh,Mr.DualOptions=$h;var Eo={};const $o=3;function kh(s,t){if(Math.abs(s.length-t.length)>$o)return Math.max(s.length,t.length);const r=[];for(let n=0;n<=s.length;n++)r[n]=[n];for(let n=0;n<=t.length;n++)r[0][n]=n;for(let n=1;n<=t.length;n++)for(let o=1;o<=s.length;o++){let u=1;s[o-1]===t[n-1]?u=0:u=1,r[o][n]=Math.min(r[o-1][n]+1,r[o][n-1]+1,r[o-1][n-1]+u),o>1&&n>1&&s[o-1]===t[n-2]&&s[o-2]===t[n-1]&&(r[o][n]=Math.min(r[o][n],r[o-2][n-2]+1))}return r[s.length][t.length]}function Mh(s,t){if(!t||t.length===0)return"";t=Array.from(new Set(t));const r=s.startsWith("--");r&&(s=s.slice(2),t=t.map(l=>l.slice(2)));let n=[],o=$o;const u=.4;return t.forEach(l=>{if(l.length<=1)return;const y=kh(s,l),c=Math.max(s.length,l.length);(c-y)/c>u&&(y<o?(o=y,n=[l]):y===o&&n.push(l))}),n.sort((l,y)=>l.localeCompare(y)),r&&(n=n.map(l=>`--${l}`)),n.length>1?`
(Did you mean one of ${n.join(", ")}?)`:n.length===1?`
(Did you mean ${n[0]}?)`:""}Eo.suggestSimilar=Mh;const Ih=hh.EventEmitter,$i=ch,De=me,xi=Y,N=ph,{Argument:Dh,humanReadableArgName:Bh}=Vt,{CommanderError:qi}=At,{Help:jh}=Ei,{Option:xo,DualOptions:Fh}=Mr,{suggestSimilar:qo}=Eo;let Wh=class wl extends Ih{constructor(t){super(),this.commands=[],this.options=[],this.parent=null,this._allowUnknownOption=!1,this._allowExcessArguments=!0,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._outputConfiguration={writeOut:r=>N.stdout.write(r),writeErr:r=>N.stderr.write(r),getOutHelpWidth:()=>N.stdout.isTTY?N.stdout.columns:void 0,getErrHelpWidth:()=>N.stderr.isTTY?N.stderr.columns:void 0,outputError:(r,n)=>n(r)},this._hidden=!1,this._helpOption=void 0,this._addImplicitHelpCommand=void 0,this._helpCommand=void 0,this._helpConfiguration={}}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(){const t=[];for(let r=this;r;r=r.parent)t.push(r);return t}command(t,r,n){let o=r,u=n;typeof o=="object"&&o!==null&&(u=o,o=null),u=u||{};const[,l,y]=t.match(/([^ ]+) *(.*)/),c=this.createCommand(l);return o&&(c.description(o),c._executableHandler=!0),u.isDefault&&(this._defaultCommandName=c._name),c._hidden=!!(u.noHelp||u.hidden),c._executableFile=u.executableFile||null,y&&c.arguments(y),this._registerCommand(c),c.parent=this,c.copyInheritedSettings(this),o?this:c}createCommand(t){return new wl(t)}createHelp(){return Object.assign(new jh,this.configureHelp())}configureHelp(t){return t===void 0?this._helpConfiguration:(this._helpConfiguration=t,this)}configureOutput(t){return t===void 0?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,r){if(!t._name)throw new Error(`Command passed to .addCommand() must have a name
- specify the name in Command constructor or using .name()`);return r=r||{},r.isDefault&&(this._defaultCommandName=t._name),(r.noHelp||r.hidden)&&(t._hidden=!0),this._registerCommand(t),t.parent=this,t._checkForBrokenPassThrough(),this}createArgument(t,r){return new Dh(t,r)}argument(t,r,n,o){const u=this.createArgument(t,r);return typeof n=="function"?u.default(o).argParser(n):u.default(n),this.addArgument(u),this}arguments(t){return t.trim().split(/ +/).forEach(r=>{this.argument(r)}),this}addArgument(t){const r=this.registeredArguments.slice(-1)[0];if(r&&r.variadic)throw new Error(`only the last argument can be variadic '${r.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,r){if(typeof t=="boolean")return this._addImplicitHelpCommand=t,this;t=t??"help [command]";const[,n,o]=t.match(/([^ ]+) *(.*)/),u=r??"display help for command",l=this.createCommand(n);return l.helpOption(!1),o&&l.arguments(o),u&&l.description(u),this._addImplicitHelpCommand=!0,this._helpCommand=l,this}addHelpCommand(t,r){return typeof t!="object"?(this.helpCommand(t,r),this):(this._addImplicitHelpCommand=!0,this._helpCommand=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,r){const n=["preSubcommand","preAction","postAction"];if(!n.includes(t))throw new Error(`Unexpected value for event passed to hook : '${t}'.
Expecting one of '${n.join("', '")}'`);return this._lifeCycleHooks[t]?this._lifeCycleHooks[t].push(r):this._lifeCycleHooks[t]=[r],this}exitOverride(t){return t?this._exitCallback=t:this._exitCallback=r=>{if(r.code!=="commander.executeSubCommandAsync")throw r},this}_exit(t,r,n){this._exitCallback&&this._exitCallback(new qi(t,r,n)),N.exit(t)}action(t){const r=n=>{const o=this.registeredArguments.length,u=n.slice(0,o);return this._storeOptionsAsProperties?u[o]=this:u[o]=this.opts(),u.push(this),t.apply(this,u)};return this._actionHandler=r,this}createOption(t,r){return new xo(t,r)}_callParseArg(t,r,n,o){try{return t.parseArg(r,n)}catch(u){if(u.code==="commander.invalidArgument"){const l=`${o} ${u.message}`;this.error(l,{exitCode:u.exitCode,code:u.code})}throw u}}_registerOption(t){const r=t.short&&this._findOption(t.short)||t.long&&this._findOption(t.long);if(r){const n=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 '${n}'
- already used by option '${r.flags}'`)}this.options.push(t)}_registerCommand(t){const r=o=>[o.name()].concat(o.aliases()),n=r(t).find(o=>this._findCommand(o));if(n){const o=r(this._findCommand(n)).join("|"),u=r(t).join("|");throw new Error(`cannot add command '${u}' as already have command '${o}'`)}this.commands.push(t)}addOption(t){this._registerOption(t);const r=t.name(),n=t.attributeName();if(t.negate){const u=t.long.replace(/^--no-/,"--");this._findOption(u)||this.setOptionValueWithSource(n,t.defaultValue===void 0?!0:t.defaultValue,"default")}else t.defaultValue!==void 0&&this.setOptionValueWithSource(n,t.defaultValue,"default");const o=(u,l,y)=>{u==null&&t.presetArg!==void 0&&(u=t.presetArg);const c=this.getOptionValue(n);u!==null&&t.parseArg?u=this._callParseArg(t,u,c,l):u!==null&&t.variadic&&(u=t._concatValue(u,c)),u==null&&(t.negate?u=!1:t.isBoolean()||t.optional?u=!0:u=""),this.setOptionValueWithSource(n,u,y)};return this.on("option:"+r,u=>{const l=`error: option '${t.flags}' argument '${u}' is invalid.`;o(u,l,"cli")}),t.envVar&&this.on("optionEnv:"+r,u=>{const l=`error: option '${t.flags}' value '${u}' from env '${t.envVar}' is invalid.`;o(u,l,"env")}),this}_optionEx(t,r,n,o,u){if(typeof r=="object"&&r instanceof xo)throw new Error("To add an Option object use addOption() instead of option() or requiredOption()");const l=this.createOption(r,n);if(l.makeOptionMandatory(!!t.mandatory),typeof o=="function")l.default(u).argParser(o);else if(o instanceof RegExp){const y=o;o=(c,d)=>{const h=y.exec(c);return h?h[0]:d},l.default(u).argParser(o)}else l.default(o);return this.addOption(l)}option(t,r,n,o){return this._optionEx({},t,r,n,o)}requiredOption(t,r,n,o){return this._optionEx({mandatory:!0},t,r,n,o)}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,r){return this.setOptionValueWithSource(t,r,void 0)}setOptionValueWithSource(t,r,n){return this._storeOptionsAsProperties?this[t]=r:this._optionValues[t]=r,this._optionValueSources[t]=n,this}getOptionValueSource(t){return this._optionValueSources[t]}getOptionValueSourceWithGlobals(t){let r;return this._getCommandAndAncestors().forEach(n=>{n.getOptionValueSource(t)!==void 0&&(r=n.getOptionValueSource(t))}),r}_prepareUserArgs(t,r){if(t!==void 0&&!Array.isArray(t))throw new Error("first parameter to parse must be array or undefined");if(r=r||{},t===void 0&&r.from===void 0){N.versions?.electron&&(r.from="electron");const o=N.execArgv??[];(o.includes("-e")||o.includes("--eval")||o.includes("-p")||o.includes("--print"))&&(r.from="eval")}t===void 0&&(t=N.argv),this.rawArgs=t.slice();let n;switch(r.from){case void 0:case"node":this._scriptPath=t[1],n=t.slice(2);break;case"electron":N.defaultApp?(this._scriptPath=t[1],n=t.slice(2)):n=t.slice(1);break;case"user":n=t.slice(0);break;case"eval":n=t.slice(1);break;default:throw new Error(`unexpected parse option { from: '${r.from}' }`)}return!this._name&&this._scriptPath&&this.nameFromFilename(this._scriptPath),this._name=this._name||"program",n}parse(t,r){const n=this._prepareUserArgs(t,r);return this._parseCommand([],n),this}async parseAsync(t,r){const n=this._prepareUserArgs(t,r);return await this._parseCommand([],n),this}_executeSubCommand(t,r){r=r.slice();let n=!1;const o=[".js",".ts",".tsx",".mjs",".cjs"];function u(h,g){const p=De.resolve(h,g);if(xi.existsSync(p))return p;if(o.includes(De.extname(g)))return;const b=o.find(m=>xi.existsSync(`${p}${m}`));if(b)return`${p}${b}`}this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let l=t._executableFile||`${this._name}-${t._name}`,y=this._executableDir||"";if(this._scriptPath){let h;try{h=xi.realpathSync(this._scriptPath)}catch{h=this._scriptPath}y=De.resolve(De.dirname(h),y)}if(y){let h=u(y,l);if(!h&&!t._executableFile&&this._scriptPath){const g=De.basename(this._scriptPath,De.extname(this._scriptPath));g!==this._name&&(h=u(y,`${g}-${t._name}`))}l=h||l}n=o.includes(De.extname(l));let c;N.platform!=="win32"?n?(r.unshift(l),r=ko(N.execArgv).concat(r),c=$i.spawn(N.argv[0],r,{stdio:"inherit"})):c=$i.spawn(l,r,{stdio:"inherit"}):(r.unshift(l),r=ko(N.execArgv).concat(r),c=$i.spawn(N.execPath,r,{stdio:"inherit"})),c.killed||["SIGUSR1","SIGUSR2","SIGTERM","SIGINT","SIGHUP"].forEach(g=>{N.on(g,()=>{c.killed===!1&&c.exitCode===null&&c.kill(g)})});const d=this._exitCallback;c.on("close",h=>{h=h??1,d?d(new qi(h,"commander.executeSubCommandAsync","(close)")):N.exit(h)}),c.on("error",h=>{if(h.code==="ENOENT"){const g=y?`searched for local subcommand relative to directory '${y}'`:"no directory for search for local subcommand, use .executableDir() to supply a custom directory",p=`'${l}' does not exist
- if '${t._name}' 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
- ${g}`;throw new Error(p)}else if(h.code==="EACCES")throw new Error(`'${l}' not executable`);if(!d)N.exit(1);else{const g=new qi(1,"commander.executeSubCommandAsync","(error)");g.nestedError=h,d(g)}}),this.runningCommand=c}_dispatchSubcommand(t,r,n){const o=this._findCommand(t);o||this.help({error:!0});let u;return u=this._chainOrCallSubCommandHook(u,o,"preSubcommand"),u=this._chainOrCall(u,()=>{if(o._executableHandler)this._executeSubCommand(o,r.concat(n));else return o._parseCommand(r,n)}),u}_dispatchHelpCommand(t){t||this.help();const r=this._findCommand(t);return r&&!r._executableHandler&&r.help(),this._dispatchSubcommand(t,[],[this._getHelpOption()?.long??this._getHelpOption()?.short??"--help"])}_checkNumberOfArguments(){this.registeredArguments.forEach((t,r)=>{t.required&&this.args[r]==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(){const t=(n,o,u)=>{let l=o;if(o!==null&&n.parseArg){const y=`error: command-argument value '${o}' is invalid for argument '${n.name()}'.`;l=this._callParseArg(n,o,u,y)}return l};this._checkNumberOfArguments();const r=[];this.registeredArguments.forEach((n,o)=>{let u=n.defaultValue;n.variadic?o<this.args.length?(u=this.args.slice(o),n.parseArg&&(u=u.reduce((l,y)=>t(n,y,l),n.defaultValue))):u===void 0&&(u=[]):o<this.args.length&&(u=this.args[o],n.parseArg&&(u=t(n,u,n.defaultValue))),r[o]=u}),this.processedArgs=r}_chainOrCall(t,r){return t&&t.then&&typeof t.then=="function"?t.then(()=>r()):r()}_chainOrCallHooks(t,r){let n=t;const o=[];return this._getCommandAndAncestors().reverse().filter(u=>u._lifeCycleHooks[r]!==void 0).forEach(u=>{u._lifeCycleHooks[r].forEach(l=>{o.push({hookedCommand:u,callback:l})})}),r==="postAction"&&o.reverse(),o.forEach(u=>{n=this._chainOrCall(n,()=>u.callback(u.hookedCommand,this))}),n}_chainOrCallSubCommandHook(t,r,n){let o=t;return this._lifeCycleHooks[n]!==void 0&&this._lifeCycleHooks[n].forEach(u=>{o=this._chainOrCall(o,()=>u(this,r))}),o}_parseCommand(t,r){const n=this.parseOptions(r);if(this._parseOptionsEnv(),this._parseOptionsImplied(),t=t.concat(n.operands),r=n.unknown,this.args=t.concat(r),t&&this._findCommand(t[0]))return this._dispatchSubcommand(t[0],t.slice(1),r);if(this._getHelpCommand()&&t[0]===this._getHelpCommand().name())return this._dispatchHelpCommand(t[1]);if(this._defaultCommandName)return this._outputHelpIfRequested(r),this._dispatchSubcommand(this._defaultCommandName,t,r);this.commands.length&&this.args.length===0&&!this._actionHandler&&!this._defaultCommandName&&this.help({error:!0}),this._outputHelpIfRequested(n.unknown),this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();const o=()=>{n.unknown.length>0&&this.unknownOption(n.unknown[0])},u=`command:${this.name()}`;if(this._actionHandler){o(),this._processArguments();let l;return l=this._chainOrCallHooks(l,"preAction"),l=this._chainOrCall(l,()=>this._actionHandler(this.processedArgs)),this.parent&&(l=this._chainOrCall(l,()=>{this.parent.emit(u,t,r)})),l=this._chainOrCallHooks(l,"postAction"),l}if(this.parent&&this.parent.listenerCount(u))o(),this._processArguments(),this.parent.emit(u,t,r);else if(t.length){if(this._findCommand("*"))return this._dispatchSubcommand("*",t,r);this.listenerCount("command:*")?this.emit("command:*",t,r):this.commands.length?this.unknownCommand():(o(),this._processArguments())}else this.commands.length?(o(),this.help({error:!0})):(o(),this._processArguments())}_findCommand(t){if(t)return this.commands.find(r=>r._name===t||r._aliases.includes(t))}_findOption(t){return this.options.find(r=>r.is(t))}_checkForMissingMandatoryOptions(){this._getCommandAndAncestors().forEach(t=>{t.options.forEach(r=>{r.mandatory&&t.getOptionValue(r.attributeName())===void 0&&t.missingMandatoryOptionValue(r)})})}_checkForConflictingLocalOptions(){const t=this.options.filter(n=>{const o=n.attributeName();return this.getOptionValue(o)===void 0?!1:this.getOptionValueSource(o)!=="default"});t.filter(n=>n.conflictsWith.length>0).forEach(n=>{const o=t.find(u=>n.conflictsWith.includes(u.attributeName()));o&&this._conflictingOption(n,o)})}_checkForConflictingOptions(){this._getCommandAndAncestors().forEach(t=>{t._checkForConflictingLocalOptions()})}parseOptions(t){const r=[],n=[];let o=r;const u=t.slice();function l(c){return c.length>1&&c[0]==="-"}let y=null;for(;u.length;){const c=u.shift();if(c==="--"){o===n&&o.push(c),o.push(...u);break}if(y&&!l(c)){this.emit(`option:${y.name()}`,c);continue}if(y=null,l(c)){const d=this._findOption(c);if(d){if(d.required){const h=u.shift();h===void 0&&this.optionMissingArgument(d),this.emit(`option:${d.name()}`,h)}else if(d.optional){let h=null;u.length>0&&!l(u[0])&&(h=u.shift()),this.emit(`option:${d.name()}`,h)}else this.emit(`option:${d.name()}`);y=d.variadic?d:null;continue}}if(c.length>2&&c[0]==="-"&&c[1]!=="-"){const d=this._findOption(`-${c[1]}`);if(d){d.required||d.optional&&this._combineFlagAndOptionalValue?this.emit(`option:${d.name()}`,c.slice(2)):(this.emit(`option:${d.name()}`),u.unshift(`-${c.slice(2)}`));continue}}if(/^--[^=]+=/.test(c)){const d=c.indexOf("="),h=this._findOption(c.slice(0,d));if(h&&(h.required||h.optional)){this.emit(`option:${h.name()}`,c.slice(d+1));continue}}if(l(c)&&(o=n),(this._enablePositionalOptions||this._passThroughOptions)&&r.length===0&&n.length===0){if(this._findCommand(c)){r.push(c),u.length>0&&n.push(...u);break}else if(this._getHelpCommand()&&c===this._getHelpCommand().name()){r.push(c),u.length>0&&r.push(...u);break}else if(this._defaultCommandName){n.push(c),u.length>0&&n.push(...u);break}}if(this._passThroughOptions){o.push(c),u.length>0&&o.push(...u);break}o.push(c)}return{operands:r,unknown:n}}opts(){if(this._storeOptionsAsProperties){const t={},r=this.options.length;for(let n=0;n<r;n++){const o=this.options[n].attributeName();t[o]=o===this._versionOptionName?this._version:this[o]}return t}return this._optionValues}optsWithGlobals(){return this._getCommandAndAncestors().reduce((t,r)=>Object.assign(t,r.opts()),{})}error(t,r){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}));const n=r||{},o=n.exitCode||1,u=n.code||"commander.error";this._exit(o,u,t)}_parseOptionsEnv(){this.options.forEach(t=>{if(t.envVar&&t.envVar in N.env){const r=t.attributeName();(this.getOptionValue(r)===void 0||["default","config","env"].includes(this.getOptionValueSource(r)))&&(t.required||t.optional?this.emit(`optionEnv:${t.name()}`,N.env[t.envVar]):this.emit(`optionEnv:${t.name()}`))}})}_parseOptionsImplied(){const t=new Fh(this.options),r=n=>this.getOptionValue(n)!==void 0&&!["default","implied"].includes(this.getOptionValueSource(n));this.options.filter(n=>n.implied!==void 0&&r(n.attributeName())&&t.valueFromOption(this.getOptionValue(n.attributeName()),n)).forEach(n=>{Object.keys(n.implied).filter(o=>!r(o)).forEach(o=>{this.setOptionValueWithSource(o,n.implied[o],"implied")})})}missingArgument(t){const r=`error: missing required argument '${t}'`;this.error(r,{code:"commander.missingArgument"})}optionMissingArgument(t){const r=`error: option '${t.flags}' argument missing`;this.error(r,{code:"commander.optionMissingArgument"})}missingMandatoryOptionValue(t){const r=`error: required option '${t.flags}' not specified`;this.error(r,{code:"commander.missingMandatoryOptionValue"})}_conflictingOption(t,r){const n=l=>{const y=l.attributeName(),c=this.getOptionValue(y),d=this.options.find(g=>g.negate&&y===g.attributeName()),h=this.options.find(g=>!g.negate&&y===g.attributeName());return d&&(d.presetArg===void 0&&c===!1||d.presetArg!==void 0&&c===d.presetArg)?d:h||l},o=l=>{const y=n(l),c=y.attributeName();return this.getOptionValueSource(c)==="env"?`environment variable '${y.envVar}'`:`option '${y.flags}'`},u=`error: ${o(t)} cannot be used with ${o(r)}`;this.error(u,{code:"commander.conflictingOption"})}unknownOption(t){if(this._allowUnknownOption)return;let r="";if(t.startsWith("--")&&this._showSuggestionAfterError){let o=[],u=this;do{const l=u.createHelp().visibleOptions(u).filter(y=>y.long).map(y=>y.long);o=o.concat(l),u=u.parent}while(u&&!u._enablePositionalOptions);r=qo(t,o)}const n=`error: unknown option '${t}'${r}`;this.error(n,{code:"commander.unknownOption"})}_excessArguments(t){if(this._allowExcessArguments)return;const r=this.registeredArguments.length,n=r===1?"":"s",u=`error: too many arguments${this.parent?` for '${this.name()}'`:""}. Expected ${r} argument${n} but got ${t.length}.`;this.error(u,{code:"commander.excessArguments"})}unknownCommand(){const t=this.args[0];let r="";if(this._showSuggestionAfterError){const o=[];this.createHelp().visibleCommands(this).forEach(u=>{o.push(u.name()),u.alias()&&o.push(u.alias())}),r=qo(t,o)}const n=`error: unknown command '${t}'${r}`;this.error(n,{code:"commander.unknownCommand"})}version(t,r,n){if(t===void 0)return this._version;this._version=t,r=r||"-V, --version",n=n||"output the version number";const o=this.createOption(r,n);return this._versionOptionName=o.attributeName(),this._registerOption(o),this.on("option:"+o.name(),()=>{this._outputConfiguration.writeOut(`${t}
`),this._exit(0,"commander.version",t)}),this}description(t,r){return t===void 0&&r===void 0?this._description:(this._description=t,r&&(this._argsDescription=r),this)}summary(t){return t===void 0?this._summary:(this._summary=t,this)}alias(t){if(t===void 0)return this._aliases[0];let r=this;if(this.commands.length!==0&&this.commands[this.commands.length-1]._executableHandler&&(r=this.commands[this.commands.length-1]),t===r._name)throw new Error("Command alias can't be the same as its name");const n=this.parent?._findCommand(t);if(n){const o=[n.name()].concat(n.aliases()).join("|");throw new Error(`cannot add alias '${t}' to command '${this.name()}' as already have command '${o}'`)}return r._aliases.push(t),this}aliases(t){return t===void 0?this._aliases:(t.forEach(r=>this.alias(r)),this)}usage(t){if(t===void 0){if(this._usage)return this._usage;const r=this.registeredArguments.map(n=>Bh(n));return[].concat(this.options.length||this._helpOption!==null?"[options]":[],this.commands.length?"[command]":[],this.registeredArguments.length?r:[]).join(" ")}return this._usage=t,this}name(t){return t===void 0?this._name:(this._name=t,this)}nameFromFilename(t){return this._name=De.basename(t,De.extname(t)),this}executableDir(t){return t===void 0?this._executableDir:(this._executableDir=t,this)}helpInformation(t){const r=this.createHelp();return r.helpWidth===void 0&&(r.helpWidth=t&&t.error?this._outputConfiguration.getErrHelpWidth():this._outputConfiguration.getOutHelpWidth()),r.formatHelp(this,r)}_getHelpContext(t){t=t||{};const r={error:!!t.error};let n;return r.error?n=o=>this._outputConfiguration.writeErr(o):n=o=>this._outputConfiguration.writeOut(o),r.write=t.write||n,r.command=this,r}outputHelp(t){let r;typeof t=="function"&&(r=t,t=void 0);const n=this._getHelpContext(t);this._getCommandAndAncestors().reverse().forEach(u=>u.emit("beforeAllHelp",n)),this.emit("beforeHelp",n);let o=this.helpInformation(n);if(r&&(o=r(o),typeof o!="string"&&!Buffer.isBuffer(o)))throw new Error("outputHelp callback must return a string or a Buffer");n.write(o),this._getHelpOption()?.long&&this.emit(this._getHelpOption().long),this.emit("afterHelp",n),this._getCommandAndAncestors().forEach(u=>u.emit("afterAllHelp",n))}helpOption(t,r){return typeof t=="boolean"?(t?this._helpOption=this._helpOption??void 0:this._helpOption=null,this):(t=t??"-h, --help",r=r??"display help for command",this._helpOption=this.createOption(t,r),this)}_getHelpOption(){return this._helpOption===void 0&&this.helpOption(void 0,void 0),this._helpOption}addHelpOption(t){return this._helpOption=t,this}help(t){this.outputHelp(t);let r=N.exitCode||0;r===0&&t&&typeof t!="function"&&t.error&&(r=1),this._exit(r,"commander.help","(outputHelp)")}addHelpText(t,r){const n=["beforeAll","before","after","afterAll"];if(!n.includes(t))throw new Error(`Unexpected value for position to addHelpText.
Expecting one of '${n.join("', '")}'`);const o=`${t}Help`;return this.on(o,u=>{let l;typeof r=="function"?l=r({error:u.error,command:u.command}):l=r,l&&u.write(`${l}
`)}),this}_outputHelpIfRequested(t){const r=this._getHelpOption();r&&t.find(o=>r.is(o))&&(this.outputHelp(),this._exit(0,"commander.helpDisplayed","(outputHelp)"))}};function ko(s){return s.map(t=>{if(!t.startsWith("--inspect"))return t;let r,n="127.0.0.1",o="9229",u;return(u=t.match(/^(--inspect(-brk)?)$/))!==null?r=u[1]:(u=t.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))!==null?(r=u[1],/^\d+$/.test(u[3])?o=u[3]:n=u[3]):(u=t.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null&&(r=u[1],n=u[3],o=u[4]),r&&o!=="0"?`${r}=${n}:${parseInt(o)+1}`:t})}Ao.Command=Wh;const{Argument:Mo}=Vt,{Command:ki}=Ao,{CommanderError:Lh,InvalidArgumentError:Io}=At,{Help:Hh}=Ei,{Option:Do}=Mr;pe.program=new ki,pe.createCommand=s=>new ki(s),pe.createOption=(s,t)=>new Do(s,t),pe.createArgument=(s,t)=>new Mo(s,t),pe.Command=ki,pe.Option=Do,pe.Argument=Mo,pe.Help=Hh,pe.CommanderError=Lh,pe.InvalidArgumentError=Io,pe.InvalidOptionArgumentError=Io;const{program:Of,createCommand:Af,createArgument:Ef,createOption:$f,CommanderError:xf,InvalidArgumentError:qf,InvalidOptionArgumentError:kf,Command:Ir,Argument:Mf,Option:If,Help:Df}=pe,zh="1.0.0";var Mi={},Ii,Bo;function V(){if(Bo)return Ii;Bo=1;const{FORCE_COLOR:s,NODE_DISABLE_COLORS:t,TERM:r}=process.env,n={enabled:!t&&r!=="dumb"&&s!=="0",reset:l(0,0),bold:l(1,22),dim:l(2,22),italic:l(3,23),underline:l(4,24),inverse:l(7,27),hidden:l(8,28),strikethrough:l(9,29),black:l(30,39),red:l(31,39),green:l(32,39),yellow:l(33,39),blue:l(34,39),magenta:l(35,39),cyan:l(36,39),white:l(37,39),gray:l(90,39),grey:l(90,39),bgBlack:l(40,49),bgRed:l(41,49),bgGreen:l(42,49),bgYellow:l(43,49),bgBlue:l(44,49),bgMagenta:l(45,49),bgCyan:l(46,49),bgWhite:l(47,49)};function o(y,c){let d=0,h,g="",p="";for(;d<y.length;d++)h=y[d],g+=h.open,p+=h.close,c.includes(h.close)&&(c=c.replace(h.rgx,h.close+h.open));return g+c+p}function u(y,c){let d={has:y,keys:c};return d.reset=n.reset.bind(d),d.bold=n.bold.bind(d),d.dim=n.dim.bind(d),d.italic=n.italic.bind(d),d.underline=n.underline.bind(d),d.inverse=n.inverse.bind(d),d.hidden=n.hidden.bind(d),d.strikethrough=n.strikethrough.bind(d),d.black=n.black.bind(d),d.red=n.red.bind(d),d.green=n.green.bind(d),d.yellow=n.yellow.bind(d),d.blue=n.blue.bind(d),d.magenta=n.magenta.bind(d),d.cyan=n.cyan.bind(d),d.white=n.white.bind(d),d.gray=n.gray.bind(d),d.grey=n.grey.bind(d),d.bgBlack=n.bgBlack.bind(d),d.bgRed=n.bgRed.bind(d),d.bgGreen=n.bgGreen.bind(d),d.bgYellow=n.bgYellow.bind(d),d.bgBlue=n.bgBlue.bind(d),d.bgMagenta=n.bgMagenta.bind(d),d.bgCyan=n.bgCyan.bind(d),d.bgWhite=n.bgWhite.bind(d),d}function l(y,c){let d={open:`\x1B[${y}m`,close:`\x1B[${c}m`,rgx:new RegExp(`\\x1b\\[${c}m`,"g")};return function(h){return this!==void 0&&this.has!==void 0?(this.has.includes(y)||(this.has.push(y),this.keys.push(d)),h===void 0?this:n.enabled?o(this.keys,h+""):h+""):h===void 0?u([y],[d]):n.enabled?o([d],h+""):h+""}}return Ii=n,Ii}var Di,jo;function Nh(){return jo||(jo=1,Di=(s,t)=>{if(!(s.meta&&s.name!=="escape")){if(s.ctrl){if(s.name==="a")return"first";if(s.name==="c"||s.name==="d")return"abort";if(s.name==="e")return"last";if(s.name==="g")return"reset"}if(t){if(s.name==="j")return"down";if(s.name==="k")return"up"}return s.name==="return"||s.name==="enter"?"submit":s.name==="backspace"?"delete":s.name==="delete"?"deleteForward":s.name==="abort"?"abort":s.name==="escape"?"exit":s.name==="tab"?"next":s.name==="pagedown"?"nextPage":s.name==="pageup"?"prevPage":s.name==="home"?"home":s.name==="end"?"end":s.name==="up"?"up":s.name==="down"?"down":s.name==="right"?"right":s.name==="left"?"left":!1}}),Di}var Bi,Fo;function ji(){return Fo||(Fo=1,Bi=s=>{const t=["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PRZcf-ntqry=><~]))"].join("|"),r=new RegExp(t,"g");return typeof s=="string"?s.replace(r,""):s}),Bi}var Fi,Wo;function U(){if(Wo)return Fi;Wo=1;const s="\x1B",t=`${s}[`,r="\x07",n={to(l,y){return y?`${t}${y+1};${l+1}H`:`${t}${l+1}G`},move(l,y){let c="";return l<0?c+=`${t}${-l}D`:l>0&&(c+=`${t}${l}C`),y<0?c+=`${t}${-y}A`:y>0&&(c+=`${t}${y}B`),c},up:(l=1)=>`${t}${l}A`,down:(l=1)=>`${t}${l}B`,forward:(l=1)=>`${t}${l}C`,backward:(l=1)=>`${t}${l}D`,nextLine:(l=1)=>`${t}E`.repeat(l),prevLine:(l=1)=>`${t}F`.repeat(l),left:`${t}G`,hide:`${t}?25l`,show:`${t}?25h`,save:`${s}7`,restore:`${s}8`},o={up:(l=1)=>`${t}S`.repeat(l),down:(l=1)=>`${t}T`.repeat(l)},u={screen:`${t}2J`,up:(l=1)=>`${t}1J`.repeat(l),down:(l=1)=>`${t}J`.repeat(l),line:`${t}2K`,lineEnd:`${t}K`,lineStart:`${t}1K`,lines(l){let y="";for(let c=0;c<l;c++)y+=this.line+(c<l-1?n.up():"");return l&&(y+=n.left),y}};return Fi={cursor:n,scroll:o,erase:u,beep:r},Fi}var Wi,Lo;function Vh(){if(Lo)return Wi;Lo=1;function s(c,d){var h=typeof Symbol<"u"&&c[Symbol.iterator]||c["@@iterator"];if(!h){if(Array.isArray(c)||(h=t(c))||d&&c&&typeof c.length=="number"){h&&(c=h);var g=0,p=function(){};return{s:p,n:function(){return g>=c.length?{done:!0}:{done:!1,value:c[g++]}},e:function(S){throw S},f:p}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var b=!0,m=!1,R;return{s:function(){h=h.call(c)},n:function(){var S=h.next();return b=S.done,S},e:function(S){m=!0,R=S},f:function(){try{!b&&h.return!=null&&h.return()}finally{if(m)throw R}}}}function t(c,d){if(c){if(typeof c=="string")return r(c,d);var h=Object.prototype.toString.call(c).slice(8,-1);if(h==="Object"&&c.constructor&&(h=c.constructor.name),h==="Map"||h==="Set")return Array.from(c);if(h==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(h))return r(c,d)}}function r(c,d){(d==null||d>c.length)&&(d=c.length);for(var h=0,g=new Array(d);h<d;h++)g[h]=c[h];return g}const n=ji(),o=U(),u=o.erase,l=o.cursor,y=c=>[...n(c)].length;return Wi=function(c,d){if(!d)return u.line+l.to(0);let h=0;const g=c.split(/\r?\n/);var p=s(g),b;try{for(p.s();!(b=p.n()).done;){let m=b.value;h+=1+Math.floor(Math.max(y(m)-1,0)/d)}}catch(m){p.e(m)}finally{p.f()}return u.lines(h)},Wi}var Li,Ho;function zo(){if(Ho)return Li;Ho=1;const s={arrowUp:"\u2191",arrowDown:"\u2193",arrowLeft:"\u2190",arrowRight:"\u2192",radioOn:"\u25C9",radioOff:"\u25EF",tick:"\u2714",cross:"\u2716",ellipsis:"\u2026",pointerSmall:"\u203A",line:"\u2500",pointer:"\u276F"},t={arrowUp:s.arrowUp,arrowDown:s.arrowDown,arrowLeft:s.arrowLeft,arrowRight:s.arrowRight,radioOn:"(*)",radioOff:"( )",tick:"\u221A",cross:"\xD7",ellipsis:"...",pointerSmall:"\xBB",line:"\u2500",pointer:">"};return Li=process.platform==="win32"?t:s,Li}var Hi,No;function Uh(){if(No)return Hi;No=1;const s=V(),t=zo(),r=Object.freeze({password:{scale:1,render:c=>"*".repeat(c.length)},emoji:{scale:2,render:c=>"\u{1F603}".repeat(c.length)},invisible:{scale:0,render:c=>""},default:{scale:1,render:c=>`${c}`}}),n=c=>r[c]||r.default,o=Object.freeze({aborted:s.red(t.cross),done:s.green(t.tick),exited:s.yellow(t.cross),default:s.cyan("?")});return Hi={styles:r,render:n,symbols:o,symbol:(c,d,h)=>d?o.aborted:h?o.exited:c?o.done:o.default,delimiter:c=>s.gray(c?t.ellipsis:t.pointerSmall),item:(c,d)=>s.gray(c?d?t.pointerSmall:"+":t.line)},Hi}var zi,Vo;function Yh(){if(Vo)return zi;Vo=1;const s=ji();return zi=function(t,r){let n=String(s(t)||"").split(/\r?\n/);return r?n.map(o=>Math.ceil(o.length/r)).reduce((o,u)=>o+u):n.length},zi}var Ni,Uo;function Gh(){return Uo||(Uo=1,Ni=(s,t={})=>{const r=Number.isSafeInteger(parseInt(t.margin))?new Array(parseInt(t.margin)).fill(" ").join(""):t.margin||"",n=t.width;return(s||"").split(/\r?\n/g).map(o=>o.split(/\s+/g).reduce((u,l)=>(l.length+r.length>=n||u[u.length-1].length+l.length+1<n?u[u.length-1]+=` ${l}`:u.push(`${r}${l}`),u),[r]).join(`
`)).join(`
`)}),Ni}var Vi,Yo;function Qh(){return Yo||(Yo=1,Vi=(s,t,r)=>{r=r||t;let n=Math.min(t-r,s-Math.floor(r/2));n<0&&(n=0);let o=Math.min(n+r,t);return{startIndex:n,endIndex:o}}),Vi}var Ui,Go;function Te(){return Go||(Go=1,Ui={action:Nh(),clear:Vh(),style:Uh(),strip:ji(),figures:zo(),lines:Yh(),wrap:Gh(),entriesToDisplay:Qh()}),Ui}var Yi,Qo;function Xe(){if(Qo)return Yi;Qo=1;const s=To,t=Te(),r=t.action,n=Po,o=U(),u=o.beep,l=o.cursor,y=V();class c extends n{constructor(h={}){super(),this.firstRender=!0,this.in=h.stdin||process.stdin,this.out=h.stdout||process.stdout,this.onRender=(h.onRender||(()=>{})).bind(this);const g=s.createInterface({input:this.in,escapeCodeTimeout:50});s.emitKeypressEvents(this.in,g),this.in.isTTY&&this.in.setRawMode(!0);const p=["SelectPrompt","MultiselectPrompt"].indexOf(this.constructor.name)>-1,b=(m,R)=>{let v=r(R,p);v===!1?this._&&this._(m,R):typeof this[v]=="function"?this[v](R):this.bell()};this.close=()=>{this.out.write(l.show),this.in.removeListener("keypress",b),this.in.isTTY&&this.in.setRawMode(!1),g.close(),this.emit(this.aborted?"abort":this.exited?"exit":"submit",this.value),this.closed=!0},this.in.on("keypress",b)}fire(){this.emit("state",{value:this.value,aborted:!!this.aborted,exited:!!this.exited})}bell(){this.out.write(u)}render(){this.onRender(y),this.firstRender&&(this.firstRender=!1)}}return Yi=c,Yi}var Gi,Jo;function Jh(){if(Jo)return Gi;Jo=1;function s(b,m,R,v,S,w,T){try{var A=b[w](T),O=A.value}catch(E){R(E);return}A.done?m(O):Promise.resolve(O).then(v,S)}function t(b){return function(){var m=this,R=arguments;return new Promise(function(v,S){var w=b.apply(m,R);function T(O){s(w,v,S,T,A,"next",O)}function A(O){s(w,v,S,T,A,"throw",O)}T(void 0)})}}const r=V(),n=Xe(),o=U(),u=o.erase,l=o.cursor,y=Te(),c=y.style,d=y.clear,h=y.lines,g=y.figures;class p extends n{constructor(m={}){super(m),this.transform=c.render(m.style),this.scale=this.transform.scale,this.msg=m.message,this.initial=m.initial||"",this.validator=m.validate||(()=>!0),this.value="",this.errorMsg=m.error||"Please Enter A Valid Value",this.cursor=+!!this.initial,this.cursorOffset=0,this.clear=d("",this.out.columns),this.render()}set value(m){!m&&this.initial?(this.placeholder=!0,this.rendered=r.gray(this.transform.render(this.initial))):(this.placeholder=!1,this.rendered=this.transform.render(m)),this._value=m,this.fire()}get value(){return this._value}reset(){this.value="",this.cursor=+!!this.initial,this.cursorOffset=0,this.fire(),this.render()}exit(){this.abort()}abort(){this.value=this.value||this.initial,this.done=this.aborted=!0,this.error=!1,this.red=!1,this.fire(),this.render(),this.out.write(`
`),this.close()}validate(){var m=this;return t(function*(){let R=yield m.validator(m.value);typeof R=="string"&&(m.errorMsg=R,R=!1),m.error=!R})()}submit(){var m=this;return t(function*(){if(m.value=m.value||m.initial,m.cursorOffset=0,m.cursor=m.rendered.length,yield m.validate(),m.error){m.red=!0,m.fire(),m.render();return}m.done=!0,m.aborted=!1,m.fire(),m.render(),m.out.write(`
`),m.close()})()}next(){if(!this.placeholder)return this.bell();this.value=this.initial,this.cursor=this.rendered.length,this.fire(),this.render()}moveCursor(m){this.placeholder||(this.cursor=this.cursor+m,this.cursorOffset+=m)}_(m,R){let v=this.value.slice(0,this.cursor),S=this.value.slice(this.cursor);this.value=`${v}${m}${S}`,this.red=!1,this.cursor=this.placeholder?0:v.length+1,this.render()}delete(){if(this.isCursorAtStart())return this.bell();let m=this.value.slice(0,this.cursor-1),R=this.value.slice(this.cursor);this.value=`${m}${R}`,this.red=!1,this.isCursorAtStart()?this.cursorOffset=0:(this.cursorOffset++,this.moveCursor(-1)),this.render()}deleteForward(){if(this.cursor*this.scale>=this.rendered.length||this.placeholder)return this.bell();let m=this.value.slice(0,this.cursor),R=this.value.slice(this.cursor+1);this.value=`${m}${R}`,this.red=!1,this.isCursorAtEnd()?this.cursorOffset=0:this.cursorOffset++,this.render()}first(){this.cursor=0,this.render()}last(){this.cursor=this.value.length,this.render()}left(){if(this.cursor<=0||this.placeholder)return this.bell();this.moveCursor(-1),this.render()}right(){if(this.cursor*this.scale>=this.rendered.length||this.placeholder)return this.bell();this.moveCursor(1),this.render()}isCursorAtStart(){return this.cursor===0||this.placeholder&&this.cursor===1}isCursorAtEnd(){return this.cursor===this.rendered.length||this.placeholder&&this.cursor===this.rendered.length+1}render(){this.closed||(this.firstRender||(this.outputError&&this.out.write(l.down(h(this.outputError,this.out.columns)-1)+d(this.outputError,this.out.columns)),this.out.write(d(this.outputText,this.out.columns))),super.render(),this.outputError="",this.outputText=[c.symbol(this.done,this.aborted),r.bold(this.msg),c.delimiter(this.done),this.red?r.red(this.rendered):this.rendered].join(" "),this.error&&(this.outputError+=this.errorMsg.split(`
`).reduce((m,R,v)=>m+`
${v?" ":g.pointerSmall} ${r.red().italic(R)}`,"")),this.out.write(u.line+l.to(0)+this.outputText+l.save+this.outputError+l.restore+l.move(this.cursorOffset,0)))}}return Gi=p,Gi}var Qi,Zo;function Zh(){if(Zo)return Qi;Zo=1;const s=V(),t=Xe(),r=Te(),n=r.style,o=r.clear,u=r.figures,l=r.wrap,y=r.entriesToDisplay,c=U(),d=c.cursor;class h extends t{constructor(p={}){super(p),this.msg=p.message,this.hint=p.hint||"- Use arrow-keys. Return to submit.",this.warn=p.warn||"- This option is disabled",this.cursor=p.initial||0,this.choices=p.choices.map((b,m)=>(typeof b=="string"&&(b={title:b,value:m}),{title:b&&(b.title||b.value||b),value:b&&(b.value===void 0?m:b.value),description:b&&b.description,selected:b&&b.selected,disabled:b&&b.disabled})),this.optionsPerPage=p.optionsPerPage||10,this.value=(this.choices[this.cursor]||{}).value,this.clear=o("",this.out.columns),this.render()}moveCursor(p){this.cursor=p,this.value=this.choices[p].value,this.fire()}reset(){this.moveCursor(0),this.fire(),this.render()}exit(){this.abort()}abort(){this.done=this.aborted=!0,this.fire(),this.render(),this.out.write(`
`),this.close()}submit(){this.selection.disabled?this.bell():(this.done=!0,this.aborted=!1,this.fire(),this.render(),this.out.write(`
`),this.close())}first(){this.moveCursor(0),this.render()}last(){this.moveCursor(this.choices.length-1),this.render()}up(){this.cursor===0?this.moveCursor(this.choices.length-1):this.moveCursor(this.cursor-1),this.render()}down(){this.cursor===this.choices.length-1?this.moveCursor(0):this.moveCursor(this.cursor+1),this.render()}next(){this.moveCursor((this.cursor+1)%this.choices.length),this.render()}_(p,b){if(p===" ")return this.submit()}get selection(){return this.choices[this.cursor]}render(){if(this.closed)return;this.firstRender?this.out.write(d.hide):this.out.write(o(this.outputText,this.out.columns)),super.render();let p=y(this.cursor,this.choices.length,this.optionsPerPage),b=p.startIndex,m=p.endIndex;if(this.outputText=[n.symbol(this.done,this.aborted),s.bold(this.msg),n.delimiter(!1),this.done?this.selection.title:this.selection.disabled?s.yellow(this.warn):s.gray(this.hint)].join(" "),!this.done){this.outputText+=`
`;for(let R=b;R<m;R++){let v,S,w="",T=this.choices[R];R===b&&b>0?S=u.arrowUp:R===m-1&&m<this.choices.length?S=u.arrowDown:S=" ",T.disabled?(v=this.cursor===R?s.gray().underline(T.title):s.strikethrough().gray(T.title),S=(this.cursor===R?s.bold().gray(u.pointer)+" ":" ")+S):(v=this.cursor===R?s.cyan().underline(T.title):T.title,S=(this.cursor===R?s.cyan(u.pointer)+" ":" ")+S,T.description&&this.cursor===R&&(w=` - ${T.description}`,(S.length+v.length+w.length>=this.out.co