@flapcode/cli 1.3.1 → 1.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/flapcode.cjs +67 -67
  2. package/package.json +1 -1
package/dist/flapcode.cjs CHANGED
@@ -1,48 +1,48 @@
1
1
  #!/usr/bin/env node
2
- var $a=Object.create;var Ji=Object.defineProperty;var Aa=Object.getOwnPropertyDescriptor;var Pa=Object.getOwnPropertyNames;var Ea=Object.getPrototypeOf,qa=Object.prototype.hasOwnProperty;var c=(i,e)=>()=>(e||i((e={exports:{}}).exports,e),e.exports);var Ta=(i,e,t,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of Pa(e))!qa.call(i,r)&&r!==t&&Ji(i,r,{get:()=>e[r],enumerable:!(s=Aa(e,r))||s.enumerable});return i};var $=(i,e,t)=>(t=i!=null?$a(Ea(i)):{},Ta(e||!i||!i.__esModule?Ji(t,"default",{value:i,enumerable:!0}):t,i));var Ce=c(ht=>{var Fe=class extends Error{constructor(e,t,s){super(s),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=t,this.exitCode=e,this.nestedError=void 0}},lt=class extends Fe{constructor(e){super(1,"commander.invalidArgument",e),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}};ht.CommanderError=Fe;ht.InvalidArgumentError=lt});var Re=c(ct=>{var{InvalidArgumentError:ka}=Ce(),ut=class{constructor(e,t){switch(this.description=t||"",this.variadic=!1,this.parseArg=void 0,this.defaultValue=void 0,this.defaultValueDescription=void 0,this.argChoices=void 0,e[0]){case"<":this.required=!0,this._name=e.slice(1,-1);break;case"[":this.required=!1,this._name=e.slice(1,-1);break;default:this.required=!0,this._name=e;break}this._name.length>3&&this._name.slice(-3)==="..."&&(this.variadic=!0,this._name=this._name.slice(0,-3))}name(){return this._name}_concatValue(e,t){return t===this.defaultValue||!Array.isArray(t)?[e]:t.concat(e)}default(e,t){return this.defaultValue=e,this.defaultValueDescription=t,this}argParser(e){return this.parseArg=e,this}choices(e){return this.argChoices=e.slice(),this.parseArg=(t,s)=>{if(!this.argChoices.includes(t))throw new ka(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._concatValue(t,s):t},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}};function Ma(i){let e=i.name()+(i.variadic===!0?"...":"");return i.required?"<"+e+">":"["+e+"]"}ct.Argument=ut;ct.humanReadableArgName=Ma});var ft=c(Ki=>{var{humanReadableArgName:Ia}=Re(),dt=class{constructor(){this.helpWidth=void 0,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}visibleCommands(e){let t=e.commands.filter(r=>!r._hidden),s=e._getHelpCommand();return s&&!s._hidden&&t.push(s),this.sortSubcommands&&t.sort((r,n)=>r.name().localeCompare(n.name())),t}compareOptions(e,t){let s=r=>r.short?r.short.replace(/^-/,""):r.long.replace(/^--/,"");return s(e).localeCompare(s(t))}visibleOptions(e){let t=e.options.filter(r=>!r.hidden),s=e._getHelpOption();if(s&&!s.hidden){let r=s.short&&e._findOption(s.short),n=s.long&&e._findOption(s.long);!r&&!n?t.push(s):s.long&&!n?t.push(e.createOption(s.long,s.description)):s.short&&!r&&t.push(e.createOption(s.short,s.description))}return this.sortOptions&&t.sort(this.compareOptions),t}visibleGlobalOptions(e){if(!this.showGlobalOptions)return[];let t=[];for(let s=e.parent;s;s=s.parent){let r=s.options.filter(n=>!n.hidden);t.push(...r)}return this.sortOptions&&t.sort(this.compareOptions),t}visibleArguments(e){return e._argsDescription&&e.registeredArguments.forEach(t=>{t.description=t.description||e._argsDescription[t.name()]||""}),e.registeredArguments.find(t=>t.description)?e.registeredArguments:[]}subcommandTerm(e){let t=e.registeredArguments.map(s=>Ia(s)).join(" ");return e._name+(e._aliases[0]?"|"+e._aliases[0]:"")+(e.options.length?" [options]":"")+(t?" "+t:"")}optionTerm(e){return e.flags}argumentTerm(e){return e.name()}longestSubcommandTermLength(e,t){return t.visibleCommands(e).reduce((s,r)=>Math.max(s,t.subcommandTerm(r).length),0)}longestOptionTermLength(e,t){return t.visibleOptions(e).reduce((s,r)=>Math.max(s,t.optionTerm(r).length),0)}longestGlobalOptionTermLength(e,t){return t.visibleGlobalOptions(e).reduce((s,r)=>Math.max(s,t.optionTerm(r).length),0)}longestArgumentTermLength(e,t){return t.visibleArguments(e).reduce((s,r)=>Math.max(s,t.argumentTerm(r).length),0)}commandUsage(e){let t=e._name;e._aliases[0]&&(t=t+"|"+e._aliases[0]);let s="";for(let r=e.parent;r;r=r.parent)s=r.name()+" "+s;return s+t+" "+e.usage()}commandDescription(e){return e.description()}subcommandDescription(e){return e.summary()||e.description()}optionDescription(e){let t=[];return e.argChoices&&t.push(`choices: ${e.argChoices.map(s=>JSON.stringify(s)).join(", ")}`),e.defaultValue!==void 0&&(e.required||e.optional||e.isBoolean()&&typeof e.defaultValue=="boolean")&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),e.presetArg!==void 0&&e.optional&&t.push(`preset: ${JSON.stringify(e.presetArg)}`),e.envVar!==void 0&&t.push(`env: ${e.envVar}`),t.length>0?`${e.description} (${t.join(", ")})`:e.description}argumentDescription(e){let t=[];if(e.argChoices&&t.push(`choices: ${e.argChoices.map(s=>JSON.stringify(s)).join(", ")}`),e.defaultValue!==void 0&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),t.length>0){let s=`(${t.join(", ")})`;return e.description?`${e.description} ${s}`:s}return e.description}formatHelp(e,t){let s=t.padWidth(e,t),r=t.helpWidth||80,n=2,o=2;function a(b,q){if(q){let T=`${b.padEnd(s+o)}${q}`;return t.wrap(T,r-n,s+o)}return b}function l(b){return b.join(`
2
+ var Aa=Object.create;var Ki=Object.defineProperty;var Pa=Object.getOwnPropertyDescriptor;var Ea=Object.getOwnPropertyNames;var qa=Object.getPrototypeOf,Ta=Object.prototype.hasOwnProperty;var c=(i,e)=>()=>(e||i((e={exports:{}}).exports,e),e.exports);var ka=(i,e,t,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of Ea(e))!Ta.call(i,r)&&r!==t&&Ki(i,r,{get:()=>e[r],enumerable:!(s=Pa(e,r))||s.enumerable});return i};var $=(i,e,t)=>(t=i!=null?Aa(qa(i)):{},ka(e||!i||!i.__esModule?Ki(t,"default",{value:i,enumerable:!0}):t,i));var xe=c(lt=>{var He=class extends Error{constructor(e,t,s){super(s),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=t,this.exitCode=e,this.nestedError=void 0}},at=class extends He{constructor(e){super(1,"commander.invalidArgument",e),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}};lt.CommanderError=He;lt.InvalidArgumentError=at});var Fe=c(ut=>{var{InvalidArgumentError:Ma}=xe(),ht=class{constructor(e,t){switch(this.description=t||"",this.variadic=!1,this.parseArg=void 0,this.defaultValue=void 0,this.defaultValueDescription=void 0,this.argChoices=void 0,e[0]){case"<":this.required=!0,this._name=e.slice(1,-1);break;case"[":this.required=!1,this._name=e.slice(1,-1);break;default:this.required=!0,this._name=e;break}this._name.length>3&&this._name.slice(-3)==="..."&&(this.variadic=!0,this._name=this._name.slice(0,-3))}name(){return this._name}_concatValue(e,t){return t===this.defaultValue||!Array.isArray(t)?[e]:t.concat(e)}default(e,t){return this.defaultValue=e,this.defaultValueDescription=t,this}argParser(e){return this.parseArg=e,this}choices(e){return this.argChoices=e.slice(),this.parseArg=(t,s)=>{if(!this.argChoices.includes(t))throw new Ma(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._concatValue(t,s):t},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}};function Ia(i){let e=i.name()+(i.variadic===!0?"...":"");return i.required?"<"+e+">":"["+e+"]"}ut.Argument=ht;ut.humanReadableArgName=Ia});var dt=c(zi=>{var{humanReadableArgName:Da}=Fe(),ct=class{constructor(){this.helpWidth=void 0,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}visibleCommands(e){let t=e.commands.filter(r=>!r._hidden),s=e._getHelpCommand();return s&&!s._hidden&&t.push(s),this.sortSubcommands&&t.sort((r,n)=>r.name().localeCompare(n.name())),t}compareOptions(e,t){let s=r=>r.short?r.short.replace(/^-/,""):r.long.replace(/^--/,"");return s(e).localeCompare(s(t))}visibleOptions(e){let t=e.options.filter(r=>!r.hidden),s=e._getHelpOption();if(s&&!s.hidden){let r=s.short&&e._findOption(s.short),n=s.long&&e._findOption(s.long);!r&&!n?t.push(s):s.long&&!n?t.push(e.createOption(s.long,s.description)):s.short&&!r&&t.push(e.createOption(s.short,s.description))}return this.sortOptions&&t.sort(this.compareOptions),t}visibleGlobalOptions(e){if(!this.showGlobalOptions)return[];let t=[];for(let s=e.parent;s;s=s.parent){let r=s.options.filter(n=>!n.hidden);t.push(...r)}return this.sortOptions&&t.sort(this.compareOptions),t}visibleArguments(e){return e._argsDescription&&e.registeredArguments.forEach(t=>{t.description=t.description||e._argsDescription[t.name()]||""}),e.registeredArguments.find(t=>t.description)?e.registeredArguments:[]}subcommandTerm(e){let t=e.registeredArguments.map(s=>Da(s)).join(" ");return e._name+(e._aliases[0]?"|"+e._aliases[0]:"")+(e.options.length?" [options]":"")+(t?" "+t:"")}optionTerm(e){return e.flags}argumentTerm(e){return e.name()}longestSubcommandTermLength(e,t){return t.visibleCommands(e).reduce((s,r)=>Math.max(s,t.subcommandTerm(r).length),0)}longestOptionTermLength(e,t){return t.visibleOptions(e).reduce((s,r)=>Math.max(s,t.optionTerm(r).length),0)}longestGlobalOptionTermLength(e,t){return t.visibleGlobalOptions(e).reduce((s,r)=>Math.max(s,t.optionTerm(r).length),0)}longestArgumentTermLength(e,t){return t.visibleArguments(e).reduce((s,r)=>Math.max(s,t.argumentTerm(r).length),0)}commandUsage(e){let t=e._name;e._aliases[0]&&(t=t+"|"+e._aliases[0]);let s="";for(let r=e.parent;r;r=r.parent)s=r.name()+" "+s;return s+t+" "+e.usage()}commandDescription(e){return e.description()}subcommandDescription(e){return e.summary()||e.description()}optionDescription(e){let t=[];return e.argChoices&&t.push(`choices: ${e.argChoices.map(s=>JSON.stringify(s)).join(", ")}`),e.defaultValue!==void 0&&(e.required||e.optional||e.isBoolean()&&typeof e.defaultValue=="boolean")&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),e.presetArg!==void 0&&e.optional&&t.push(`preset: ${JSON.stringify(e.presetArg)}`),e.envVar!==void 0&&t.push(`env: ${e.envVar}`),t.length>0?`${e.description} (${t.join(", ")})`:e.description}argumentDescription(e){let t=[];if(e.argChoices&&t.push(`choices: ${e.argChoices.map(s=>JSON.stringify(s)).join(", ")}`),e.defaultValue!==void 0&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),t.length>0){let s=`(${t.join(", ")})`;return e.description?`${e.description} ${s}`:s}return e.description}formatHelp(e,t){let s=t.padWidth(e,t),r=t.helpWidth||80,n=2,o=2;function a(b,q){if(q){let T=`${b.padEnd(s+o)}${q}`;return t.wrap(T,r-n,s+o)}return b}function l(b){return b.join(`
3
3
  `).replace(/^/gm," ".repeat(n))}let h=[`Usage: ${t.commandUsage(e)}`,""],d=t.commandDescription(e);d.length>0&&(h=h.concat([t.wrap(d,r,0),""]));let f=t.visibleArguments(e).map(b=>a(t.argumentTerm(b),t.argumentDescription(b)));f.length>0&&(h=h.concat(["Arguments:",l(f),""]));let p=t.visibleOptions(e).map(b=>a(t.optionTerm(b),t.optionDescription(b)));if(p.length>0&&(h=h.concat(["Options:",l(p),""])),this.showGlobalOptions){let b=t.visibleGlobalOptions(e).map(q=>a(t.optionTerm(q),t.optionDescription(q)));b.length>0&&(h=h.concat(["Global Options:",l(b),""]))}let O=t.visibleCommands(e).map(b=>a(t.subcommandTerm(b),t.subcommandDescription(b)));return O.length>0&&(h=h.concat(["Commands:",l(O),""])),h.join(`
4
4
  `)}padWidth(e,t){return Math.max(t.longestOptionTermLength(e,t),t.longestGlobalOptionTermLength(e,t),t.longestSubcommandTermLength(e,t),t.longestArgumentTermLength(e,t))}wrap(e,t,s,r=40){let n=" \\f\\t\\v\xA0\u1680\u2000-\u200A\u202F\u205F\u3000\uFEFF",o=new RegExp(`[\\n][${n}]+`);if(e.match(o))return e;let a=t-s;if(a<r)return e;let l=e.slice(0,s),h=e.slice(s).replace(`\r
5
5
  `,`
6
6
  `),d=" ".repeat(s),p="\\s\u200B",O=new RegExp(`
7
7
  |.{1,${a-1}}([${p}]|$)|[^${p}]+?([${p}]|$)`,"g"),b=h.match(O)||[];return l+b.map((q,T)=>q===`
8
8
  `?"":(T>0?d:"")+q.trimEnd()).join(`
9
- `)}};Ki.Help=dt});var bt=c(gt=>{var{InvalidArgumentError:Da}=Ce(),pt=class{constructor(e,t){this.flags=e,this.description=t||"",this.required=e.includes("<"),this.optional=e.includes("["),this.variadic=/\w\.\.\.[>\]]$/.test(e),this.mandatory=!1;let s=Va(e);this.short=s.shortFlag,this.long=s.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(e,t){return this.defaultValue=e,this.defaultValueDescription=t,this}preset(e){return this.presetArg=e,this}conflicts(e){return this.conflictsWith=this.conflictsWith.concat(e),this}implies(e){let t=e;return typeof e=="string"&&(t={[e]:!0}),this.implied=Object.assign(this.implied||{},t),this}env(e){return this.envVar=e,this}argParser(e){return this.parseArg=e,this}makeOptionMandatory(e=!0){return this.mandatory=!!e,this}hideHelp(e=!0){return this.hidden=!!e,this}_concatValue(e,t){return t===this.defaultValue||!Array.isArray(t)?[e]:t.concat(e)}choices(e){return this.argChoices=e.slice(),this.parseArg=(t,s)=>{if(!this.argChoices.includes(t))throw new Da(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._concatValue(t,s):t},this}name(){return this.long?this.long.replace(/^--/,""):this.short.replace(/^-/,"")}attributeName(){return ja(this.name().replace(/^no-/,""))}is(e){return this.short===e||this.long===e}isBoolean(){return!this.required&&!this.optional&&!this.negate}},mt=class{constructor(e){this.positiveOptions=new Map,this.negativeOptions=new Map,this.dualOptions=new Set,e.forEach(t=>{t.negate?this.negativeOptions.set(t.attributeName(),t):this.positiveOptions.set(t.attributeName(),t)}),this.negativeOptions.forEach((t,s)=>{this.positiveOptions.has(s)&&this.dualOptions.add(s)})}valueFromOption(e,t){let s=t.attributeName();if(!this.dualOptions.has(s))return!0;let r=this.negativeOptions.get(s).presetArg,n=r!==void 0?r:!1;return t.negate===(n===e)}};function ja(i){return i.split("-").reduce((e,t)=>e+t[0].toUpperCase()+t.slice(1))}function Va(i){let e,t,s=i.split(/[ |,]+/);return s.length>1&&!/^[[<]/.test(s[1])&&(e=s.shift()),t=s.shift(),!e&&/^-[^-]$/.test(t)&&(e=t,t=void 0),{shortFlag:e,longFlag:t}}gt.Option=pt;gt.DualOptions=mt});var Zi=c(zi=>{function Ha(i,e){if(Math.abs(i.length-e.length)>3)return Math.max(i.length,e.length);let t=[];for(let s=0;s<=i.length;s++)t[s]=[s];for(let s=0;s<=e.length;s++)t[0][s]=s;for(let s=1;s<=e.length;s++)for(let r=1;r<=i.length;r++){let n=1;i[r-1]===e[s-1]?n=0:n=1,t[r][s]=Math.min(t[r-1][s]+1,t[r][s-1]+1,t[r-1][s-1]+n),r>1&&s>1&&i[r-1]===e[s-2]&&i[r-2]===e[s-1]&&(t[r][s]=Math.min(t[r][s],t[r-2][s-2]+1))}return t[i.length][e.length]}function Fa(i,e){if(!e||e.length===0)return"";e=Array.from(new Set(e));let t=i.startsWith("--");t&&(i=i.slice(2),e=e.map(o=>o.slice(2)));let s=[],r=3,n=.4;return e.forEach(o=>{if(o.length<=1)return;let a=Ha(i,o),l=Math.max(i.length,o.length);(l-a)/l>n&&(a<r?(r=a,s=[o]):a===r&&s.push(o))}),s.sort((o,a)=>o.localeCompare(a)),t&&(s=s.map(o=>`--${o}`)),s.length>1?`
9
+ `)}};zi.Help=ct});var gt=c(mt=>{var{InvalidArgumentError:ja}=xe(),ft=class{constructor(e,t){this.flags=e,this.description=t||"",this.required=e.includes("<"),this.optional=e.includes("["),this.variadic=/\w\.\.\.[>\]]$/.test(e),this.mandatory=!1;let s=Ha(e);this.short=s.shortFlag,this.long=s.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(e,t){return this.defaultValue=e,this.defaultValueDescription=t,this}preset(e){return this.presetArg=e,this}conflicts(e){return this.conflictsWith=this.conflictsWith.concat(e),this}implies(e){let t=e;return typeof e=="string"&&(t={[e]:!0}),this.implied=Object.assign(this.implied||{},t),this}env(e){return this.envVar=e,this}argParser(e){return this.parseArg=e,this}makeOptionMandatory(e=!0){return this.mandatory=!!e,this}hideHelp(e=!0){return this.hidden=!!e,this}_concatValue(e,t){return t===this.defaultValue||!Array.isArray(t)?[e]:t.concat(e)}choices(e){return this.argChoices=e.slice(),this.parseArg=(t,s)=>{if(!this.argChoices.includes(t))throw new ja(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._concatValue(t,s):t},this}name(){return this.long?this.long.replace(/^--/,""):this.short.replace(/^-/,"")}attributeName(){return Va(this.name().replace(/^no-/,""))}is(e){return this.short===e||this.long===e}isBoolean(){return!this.required&&!this.optional&&!this.negate}},pt=class{constructor(e){this.positiveOptions=new Map,this.negativeOptions=new Map,this.dualOptions=new Set,e.forEach(t=>{t.negate?this.negativeOptions.set(t.attributeName(),t):this.positiveOptions.set(t.attributeName(),t)}),this.negativeOptions.forEach((t,s)=>{this.positiveOptions.has(s)&&this.dualOptions.add(s)})}valueFromOption(e,t){let s=t.attributeName();if(!this.dualOptions.has(s))return!0;let r=this.negativeOptions.get(s).presetArg,n=r!==void 0?r:!1;return t.negate===(n===e)}};function Va(i){return i.split("-").reduce((e,t)=>e+t[0].toUpperCase()+t.slice(1))}function Ha(i){let e,t,s=i.split(/[ |,]+/);return s.length>1&&!/^[[<]/.test(s[1])&&(e=s.shift()),t=s.shift(),!e&&/^-[^-]$/.test(t)&&(e=t,t=void 0),{shortFlag:e,longFlag:t}}mt.Option=ft;mt.DualOptions=pt});var Xi=c(Zi=>{function Fa(i,e){if(Math.abs(i.length-e.length)>3)return Math.max(i.length,e.length);let t=[];for(let s=0;s<=i.length;s++)t[s]=[s];for(let s=0;s<=e.length;s++)t[0][s]=s;for(let s=1;s<=e.length;s++)for(let r=1;r<=i.length;r++){let n=1;i[r-1]===e[s-1]?n=0:n=1,t[r][s]=Math.min(t[r-1][s]+1,t[r][s-1]+1,t[r-1][s-1]+n),r>1&&s>1&&i[r-1]===e[s-2]&&i[r-2]===e[s-1]&&(t[r][s]=Math.min(t[r][s],t[r-2][s-2]+1))}return t[i.length][e.length]}function Ra(i,e){if(!e||e.length===0)return"";e=Array.from(new Set(e));let t=i.startsWith("--");t&&(i=i.slice(2),e=e.map(o=>o.slice(2)));let s=[],r=3,n=.4;return e.forEach(o=>{if(o.length<=1)return;let a=Fa(i,o),l=Math.max(i.length,o.length);(l-a)/l>n&&(a<r?(r=a,s=[o]):a===r&&s.push(o))}),s.sort((o,a)=>o.localeCompare(a)),t&&(s=s.map(o=>`--${o}`)),s.length>1?`
10
10
  (Did you mean one of ${s.join(", ")}?)`:s.length===1?`
11
- (Did you mean ${s[0]}?)`:""}zi.suggestSimilar=Fa});var is=c(ts=>{var Ra=require("node:events").EventEmitter,wt=require("node:child_process"),W=require("node:path"),yt=require("node:fs"),C=require("node:process"),{Argument:Na,humanReadableArgName:La}=Re(),{CommanderError:_t}=Ce(),{Help:Ga}=ft(),{Option:Xi,DualOptions:Ba}=bt(),{suggestSimilar:Qi}=Zi(),vt=class i extends Ra{constructor(e){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=e||"",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:t=>C.stdout.write(t),writeErr:t=>C.stderr.write(t),getOutHelpWidth:()=>C.stdout.isTTY?C.stdout.columns:void 0,getErrHelpWidth:()=>C.stderr.isTTY?C.stderr.columns:void 0,outputError:(t,s)=>s(t)},this._hidden=!1,this._helpOption=void 0,this._addImplicitHelpCommand=void 0,this._helpCommand=void 0,this._helpConfiguration={}}copyInheritedSettings(e){return this._outputConfiguration=e._outputConfiguration,this._helpOption=e._helpOption,this._helpCommand=e._helpCommand,this._helpConfiguration=e._helpConfiguration,this._exitCallback=e._exitCallback,this._storeOptionsAsProperties=e._storeOptionsAsProperties,this._combineFlagAndOptionalValue=e._combineFlagAndOptionalValue,this._allowExcessArguments=e._allowExcessArguments,this._enablePositionalOptions=e._enablePositionalOptions,this._showHelpAfterError=e._showHelpAfterError,this._showSuggestionAfterError=e._showSuggestionAfterError,this}_getCommandAndAncestors(){let e=[];for(let t=this;t;t=t.parent)e.push(t);return e}command(e,t,s){let r=t,n=s;typeof r=="object"&&r!==null&&(n=r,r=null),n=n||{};let[,o,a]=e.match(/([^ ]+) *(.*)/),l=this.createCommand(o);return r&&(l.description(r),l._executableHandler=!0),n.isDefault&&(this._defaultCommandName=l._name),l._hidden=!!(n.noHelp||n.hidden),l._executableFile=n.executableFile||null,a&&l.arguments(a),this._registerCommand(l),l.parent=this,l.copyInheritedSettings(this),r?this:l}createCommand(e){return new i(e)}createHelp(){return Object.assign(new Ga,this.configureHelp())}configureHelp(e){return e===void 0?this._helpConfiguration:(this._helpConfiguration=e,this)}configureOutput(e){return e===void 0?this._outputConfiguration:(Object.assign(this._outputConfiguration,e),this)}showHelpAfterError(e=!0){return typeof e!="string"&&(e=!!e),this._showHelpAfterError=e,this}showSuggestionAfterError(e=!0){return this._showSuggestionAfterError=!!e,this}addCommand(e,t){if(!e._name)throw new Error(`Command passed to .addCommand() must have a name
12
- - specify the name in Command constructor or using .name()`);return t=t||{},t.isDefault&&(this._defaultCommandName=e._name),(t.noHelp||t.hidden)&&(e._hidden=!0),this._registerCommand(e),e.parent=this,e._checkForBrokenPassThrough(),this}createArgument(e,t){return new Na(e,t)}argument(e,t,s,r){let n=this.createArgument(e,t);return typeof s=="function"?n.default(r).argParser(s):n.default(s),this.addArgument(n),this}arguments(e){return e.trim().split(/ +/).forEach(t=>{this.argument(t)}),this}addArgument(e){let t=this.registeredArguments.slice(-1)[0];if(t&&t.variadic)throw new Error(`only the last argument can be variadic '${t.name()}'`);if(e.required&&e.defaultValue!==void 0&&e.parseArg===void 0)throw new Error(`a default value for a required argument is never used: '${e.name()}'`);return this.registeredArguments.push(e),this}helpCommand(e,t){if(typeof e=="boolean")return this._addImplicitHelpCommand=e,this;e=e??"help [command]";let[,s,r]=e.match(/([^ ]+) *(.*)/),n=t??"display help for command",o=this.createCommand(s);return o.helpOption(!1),r&&o.arguments(r),n&&o.description(n),this._addImplicitHelpCommand=!0,this._helpCommand=o,this}addHelpCommand(e,t){return typeof e!="object"?(this.helpCommand(e,t),this):(this._addImplicitHelpCommand=!0,this._helpCommand=e,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(e,t){let s=["preSubcommand","preAction","postAction"];if(!s.includes(e))throw new Error(`Unexpected value for event passed to hook : '${e}'.
13
- Expecting one of '${s.join("', '")}'`);return this._lifeCycleHooks[e]?this._lifeCycleHooks[e].push(t):this._lifeCycleHooks[e]=[t],this}exitOverride(e){return e?this._exitCallback=e:this._exitCallback=t=>{if(t.code!=="commander.executeSubCommandAsync")throw t},this}_exit(e,t,s){this._exitCallback&&this._exitCallback(new _t(e,t,s)),C.exit(e)}action(e){let t=s=>{let r=this.registeredArguments.length,n=s.slice(0,r);return this._storeOptionsAsProperties?n[r]=this:n[r]=this.opts(),n.push(this),e.apply(this,n)};return this._actionHandler=t,this}createOption(e,t){return new Xi(e,t)}_callParseArg(e,t,s,r){try{return e.parseArg(t,s)}catch(n){if(n.code==="commander.invalidArgument"){let o=`${r} ${n.message}`;this.error(o,{exitCode:n.exitCode,code:n.code})}throw n}}_registerOption(e){let t=e.short&&this._findOption(e.short)||e.long&&this._findOption(e.long);if(t){let s=e.long&&this._findOption(e.long)?e.long:e.short;throw new Error(`Cannot add option '${e.flags}'${this._name&&` to command '${this._name}'`} due to conflicting flag '${s}'
14
- - already used by option '${t.flags}'`)}this.options.push(e)}_registerCommand(e){let t=r=>[r.name()].concat(r.aliases()),s=t(e).find(r=>this._findCommand(r));if(s){let r=t(this._findCommand(s)).join("|"),n=t(e).join("|");throw new Error(`cannot add command '${n}' as already have command '${r}'`)}this.commands.push(e)}addOption(e){this._registerOption(e);let t=e.name(),s=e.attributeName();if(e.negate){let n=e.long.replace(/^--no-/,"--");this._findOption(n)||this.setOptionValueWithSource(s,e.defaultValue===void 0?!0:e.defaultValue,"default")}else e.defaultValue!==void 0&&this.setOptionValueWithSource(s,e.defaultValue,"default");let r=(n,o,a)=>{n==null&&e.presetArg!==void 0&&(n=e.presetArg);let l=this.getOptionValue(s);n!==null&&e.parseArg?n=this._callParseArg(e,n,l,o):n!==null&&e.variadic&&(n=e._concatValue(n,l)),n==null&&(e.negate?n=!1:e.isBoolean()||e.optional?n=!0:n=""),this.setOptionValueWithSource(s,n,a)};return this.on("option:"+t,n=>{let o=`error: option '${e.flags}' argument '${n}' is invalid.`;r(n,o,"cli")}),e.envVar&&this.on("optionEnv:"+t,n=>{let o=`error: option '${e.flags}' value '${n}' from env '${e.envVar}' is invalid.`;r(n,o,"env")}),this}_optionEx(e,t,s,r,n){if(typeof t=="object"&&t instanceof Xi)throw new Error("To add an Option object use addOption() instead of option() or requiredOption()");let o=this.createOption(t,s);if(o.makeOptionMandatory(!!e.mandatory),typeof r=="function")o.default(n).argParser(r);else if(r instanceof RegExp){let a=r;r=(l,h)=>{let d=a.exec(l);return d?d[0]:h},o.default(n).argParser(r)}else o.default(r);return this.addOption(o)}option(e,t,s,r){return this._optionEx({},e,t,s,r)}requiredOption(e,t,s,r){return this._optionEx({mandatory:!0},e,t,s,r)}combineFlagAndOptionalValue(e=!0){return this._combineFlagAndOptionalValue=!!e,this}allowUnknownOption(e=!0){return this._allowUnknownOption=!!e,this}allowExcessArguments(e=!0){return this._allowExcessArguments=!!e,this}enablePositionalOptions(e=!0){return this._enablePositionalOptions=!!e,this}passThroughOptions(e=!0){return this._passThroughOptions=!!e,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(e=!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=!!e,this}getOptionValue(e){return this._storeOptionsAsProperties?this[e]:this._optionValues[e]}setOptionValue(e,t){return this.setOptionValueWithSource(e,t,void 0)}setOptionValueWithSource(e,t,s){return this._storeOptionsAsProperties?this[e]=t:this._optionValues[e]=t,this._optionValueSources[e]=s,this}getOptionValueSource(e){return this._optionValueSources[e]}getOptionValueSourceWithGlobals(e){let t;return this._getCommandAndAncestors().forEach(s=>{s.getOptionValueSource(e)!==void 0&&(t=s.getOptionValueSource(e))}),t}_prepareUserArgs(e,t){if(e!==void 0&&!Array.isArray(e))throw new Error("first parameter to parse must be array or undefined");if(t=t||{},e===void 0&&t.from===void 0){C.versions?.electron&&(t.from="electron");let r=C.execArgv??[];(r.includes("-e")||r.includes("--eval")||r.includes("-p")||r.includes("--print"))&&(t.from="eval")}e===void 0&&(e=C.argv),this.rawArgs=e.slice();let s;switch(t.from){case void 0:case"node":this._scriptPath=e[1],s=e.slice(2);break;case"electron":C.defaultApp?(this._scriptPath=e[1],s=e.slice(2)):s=e.slice(1);break;case"user":s=e.slice(0);break;case"eval":s=e.slice(1);break;default:throw new Error(`unexpected parse option { from: '${t.from}' }`)}return!this._name&&this._scriptPath&&this.nameFromFilename(this._scriptPath),this._name=this._name||"program",s}parse(e,t){let s=this._prepareUserArgs(e,t);return this._parseCommand([],s),this}async parseAsync(e,t){let s=this._prepareUserArgs(e,t);return await this._parseCommand([],s),this}_executeSubCommand(e,t){t=t.slice();let s=!1,r=[".js",".ts",".tsx",".mjs",".cjs"];function n(d,f){let p=W.resolve(d,f);if(yt.existsSync(p))return p;if(r.includes(W.extname(f)))return;let O=r.find(b=>yt.existsSync(`${p}${b}`));if(O)return`${p}${O}`}this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let o=e._executableFile||`${this._name}-${e._name}`,a=this._executableDir||"";if(this._scriptPath){let d;try{d=yt.realpathSync(this._scriptPath)}catch{d=this._scriptPath}a=W.resolve(W.dirname(d),a)}if(a){let d=n(a,o);if(!d&&!e._executableFile&&this._scriptPath){let f=W.basename(this._scriptPath,W.extname(this._scriptPath));f!==this._name&&(d=n(a,`${f}-${e._name}`))}o=d||o}s=r.includes(W.extname(o));let l;C.platform!=="win32"?s?(t.unshift(o),t=es(C.execArgv).concat(t),l=wt.spawn(C.argv[0],t,{stdio:"inherit"})):l=wt.spawn(o,t,{stdio:"inherit"}):(t.unshift(o),t=es(C.execArgv).concat(t),l=wt.spawn(C.execPath,t,{stdio:"inherit"})),l.killed||["SIGUSR1","SIGUSR2","SIGTERM","SIGINT","SIGHUP"].forEach(f=>{C.on(f,()=>{l.killed===!1&&l.exitCode===null&&l.kill(f)})});let h=this._exitCallback;l.on("close",d=>{d=d??1,h?h(new _t(d,"commander.executeSubCommandAsync","(close)")):C.exit(d)}),l.on("error",d=>{if(d.code==="ENOENT"){let f=a?`searched for local subcommand relative to directory '${a}'`:"no directory for search for local subcommand, use .executableDir() to supply a custom directory",p=`'${o}' does not exist
11
+ (Did you mean ${s[0]}?)`:""}Zi.suggestSimilar=Ra});var ss=c(is=>{var Na=require("node:events").EventEmitter,bt=require("node:child_process"),W=require("node:path"),wt=require("node:fs"),C=require("node:process"),{Argument:La,humanReadableArgName:Ga}=Fe(),{CommanderError:yt}=xe(),{Help:Ba}=dt(),{Option:Qi,DualOptions:Ya}=gt(),{suggestSimilar:es}=Xi(),_t=class i extends Na{constructor(e){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=e||"",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:t=>C.stdout.write(t),writeErr:t=>C.stderr.write(t),getOutHelpWidth:()=>C.stdout.isTTY?C.stdout.columns:void 0,getErrHelpWidth:()=>C.stderr.isTTY?C.stderr.columns:void 0,outputError:(t,s)=>s(t)},this._hidden=!1,this._helpOption=void 0,this._addImplicitHelpCommand=void 0,this._helpCommand=void 0,this._helpConfiguration={}}copyInheritedSettings(e){return this._outputConfiguration=e._outputConfiguration,this._helpOption=e._helpOption,this._helpCommand=e._helpCommand,this._helpConfiguration=e._helpConfiguration,this._exitCallback=e._exitCallback,this._storeOptionsAsProperties=e._storeOptionsAsProperties,this._combineFlagAndOptionalValue=e._combineFlagAndOptionalValue,this._allowExcessArguments=e._allowExcessArguments,this._enablePositionalOptions=e._enablePositionalOptions,this._showHelpAfterError=e._showHelpAfterError,this._showSuggestionAfterError=e._showSuggestionAfterError,this}_getCommandAndAncestors(){let e=[];for(let t=this;t;t=t.parent)e.push(t);return e}command(e,t,s){let r=t,n=s;typeof r=="object"&&r!==null&&(n=r,r=null),n=n||{};let[,o,a]=e.match(/([^ ]+) *(.*)/),l=this.createCommand(o);return r&&(l.description(r),l._executableHandler=!0),n.isDefault&&(this._defaultCommandName=l._name),l._hidden=!!(n.noHelp||n.hidden),l._executableFile=n.executableFile||null,a&&l.arguments(a),this._registerCommand(l),l.parent=this,l.copyInheritedSettings(this),r?this:l}createCommand(e){return new i(e)}createHelp(){return Object.assign(new Ba,this.configureHelp())}configureHelp(e){return e===void 0?this._helpConfiguration:(this._helpConfiguration=e,this)}configureOutput(e){return e===void 0?this._outputConfiguration:(Object.assign(this._outputConfiguration,e),this)}showHelpAfterError(e=!0){return typeof e!="string"&&(e=!!e),this._showHelpAfterError=e,this}showSuggestionAfterError(e=!0){return this._showSuggestionAfterError=!!e,this}addCommand(e,t){if(!e._name)throw new Error(`Command passed to .addCommand() must have a name
12
+ - specify the name in Command constructor or using .name()`);return t=t||{},t.isDefault&&(this._defaultCommandName=e._name),(t.noHelp||t.hidden)&&(e._hidden=!0),this._registerCommand(e),e.parent=this,e._checkForBrokenPassThrough(),this}createArgument(e,t){return new La(e,t)}argument(e,t,s,r){let n=this.createArgument(e,t);return typeof s=="function"?n.default(r).argParser(s):n.default(s),this.addArgument(n),this}arguments(e){return e.trim().split(/ +/).forEach(t=>{this.argument(t)}),this}addArgument(e){let t=this.registeredArguments.slice(-1)[0];if(t&&t.variadic)throw new Error(`only the last argument can be variadic '${t.name()}'`);if(e.required&&e.defaultValue!==void 0&&e.parseArg===void 0)throw new Error(`a default value for a required argument is never used: '${e.name()}'`);return this.registeredArguments.push(e),this}helpCommand(e,t){if(typeof e=="boolean")return this._addImplicitHelpCommand=e,this;e=e??"help [command]";let[,s,r]=e.match(/([^ ]+) *(.*)/),n=t??"display help for command",o=this.createCommand(s);return o.helpOption(!1),r&&o.arguments(r),n&&o.description(n),this._addImplicitHelpCommand=!0,this._helpCommand=o,this}addHelpCommand(e,t){return typeof e!="object"?(this.helpCommand(e,t),this):(this._addImplicitHelpCommand=!0,this._helpCommand=e,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(e,t){let s=["preSubcommand","preAction","postAction"];if(!s.includes(e))throw new Error(`Unexpected value for event passed to hook : '${e}'.
13
+ Expecting one of '${s.join("', '")}'`);return this._lifeCycleHooks[e]?this._lifeCycleHooks[e].push(t):this._lifeCycleHooks[e]=[t],this}exitOverride(e){return e?this._exitCallback=e:this._exitCallback=t=>{if(t.code!=="commander.executeSubCommandAsync")throw t},this}_exit(e,t,s){this._exitCallback&&this._exitCallback(new yt(e,t,s)),C.exit(e)}action(e){let t=s=>{let r=this.registeredArguments.length,n=s.slice(0,r);return this._storeOptionsAsProperties?n[r]=this:n[r]=this.opts(),n.push(this),e.apply(this,n)};return this._actionHandler=t,this}createOption(e,t){return new Qi(e,t)}_callParseArg(e,t,s,r){try{return e.parseArg(t,s)}catch(n){if(n.code==="commander.invalidArgument"){let o=`${r} ${n.message}`;this.error(o,{exitCode:n.exitCode,code:n.code})}throw n}}_registerOption(e){let t=e.short&&this._findOption(e.short)||e.long&&this._findOption(e.long);if(t){let s=e.long&&this._findOption(e.long)?e.long:e.short;throw new Error(`Cannot add option '${e.flags}'${this._name&&` to command '${this._name}'`} due to conflicting flag '${s}'
14
+ - already used by option '${t.flags}'`)}this.options.push(e)}_registerCommand(e){let t=r=>[r.name()].concat(r.aliases()),s=t(e).find(r=>this._findCommand(r));if(s){let r=t(this._findCommand(s)).join("|"),n=t(e).join("|");throw new Error(`cannot add command '${n}' as already have command '${r}'`)}this.commands.push(e)}addOption(e){this._registerOption(e);let t=e.name(),s=e.attributeName();if(e.negate){let n=e.long.replace(/^--no-/,"--");this._findOption(n)||this.setOptionValueWithSource(s,e.defaultValue===void 0?!0:e.defaultValue,"default")}else e.defaultValue!==void 0&&this.setOptionValueWithSource(s,e.defaultValue,"default");let r=(n,o,a)=>{n==null&&e.presetArg!==void 0&&(n=e.presetArg);let l=this.getOptionValue(s);n!==null&&e.parseArg?n=this._callParseArg(e,n,l,o):n!==null&&e.variadic&&(n=e._concatValue(n,l)),n==null&&(e.negate?n=!1:e.isBoolean()||e.optional?n=!0:n=""),this.setOptionValueWithSource(s,n,a)};return this.on("option:"+t,n=>{let o=`error: option '${e.flags}' argument '${n}' is invalid.`;r(n,o,"cli")}),e.envVar&&this.on("optionEnv:"+t,n=>{let o=`error: option '${e.flags}' value '${n}' from env '${e.envVar}' is invalid.`;r(n,o,"env")}),this}_optionEx(e,t,s,r,n){if(typeof t=="object"&&t instanceof Qi)throw new Error("To add an Option object use addOption() instead of option() or requiredOption()");let o=this.createOption(t,s);if(o.makeOptionMandatory(!!e.mandatory),typeof r=="function")o.default(n).argParser(r);else if(r instanceof RegExp){let a=r;r=(l,h)=>{let d=a.exec(l);return d?d[0]:h},o.default(n).argParser(r)}else o.default(r);return this.addOption(o)}option(e,t,s,r){return this._optionEx({},e,t,s,r)}requiredOption(e,t,s,r){return this._optionEx({mandatory:!0},e,t,s,r)}combineFlagAndOptionalValue(e=!0){return this._combineFlagAndOptionalValue=!!e,this}allowUnknownOption(e=!0){return this._allowUnknownOption=!!e,this}allowExcessArguments(e=!0){return this._allowExcessArguments=!!e,this}enablePositionalOptions(e=!0){return this._enablePositionalOptions=!!e,this}passThroughOptions(e=!0){return this._passThroughOptions=!!e,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(e=!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=!!e,this}getOptionValue(e){return this._storeOptionsAsProperties?this[e]:this._optionValues[e]}setOptionValue(e,t){return this.setOptionValueWithSource(e,t,void 0)}setOptionValueWithSource(e,t,s){return this._storeOptionsAsProperties?this[e]=t:this._optionValues[e]=t,this._optionValueSources[e]=s,this}getOptionValueSource(e){return this._optionValueSources[e]}getOptionValueSourceWithGlobals(e){let t;return this._getCommandAndAncestors().forEach(s=>{s.getOptionValueSource(e)!==void 0&&(t=s.getOptionValueSource(e))}),t}_prepareUserArgs(e,t){if(e!==void 0&&!Array.isArray(e))throw new Error("first parameter to parse must be array or undefined");if(t=t||{},e===void 0&&t.from===void 0){C.versions?.electron&&(t.from="electron");let r=C.execArgv??[];(r.includes("-e")||r.includes("--eval")||r.includes("-p")||r.includes("--print"))&&(t.from="eval")}e===void 0&&(e=C.argv),this.rawArgs=e.slice();let s;switch(t.from){case void 0:case"node":this._scriptPath=e[1],s=e.slice(2);break;case"electron":C.defaultApp?(this._scriptPath=e[1],s=e.slice(2)):s=e.slice(1);break;case"user":s=e.slice(0);break;case"eval":s=e.slice(1);break;default:throw new Error(`unexpected parse option { from: '${t.from}' }`)}return!this._name&&this._scriptPath&&this.nameFromFilename(this._scriptPath),this._name=this._name||"program",s}parse(e,t){let s=this._prepareUserArgs(e,t);return this._parseCommand([],s),this}async parseAsync(e,t){let s=this._prepareUserArgs(e,t);return await this._parseCommand([],s),this}_executeSubCommand(e,t){t=t.slice();let s=!1,r=[".js",".ts",".tsx",".mjs",".cjs"];function n(d,f){let p=W.resolve(d,f);if(wt.existsSync(p))return p;if(r.includes(W.extname(f)))return;let O=r.find(b=>wt.existsSync(`${p}${b}`));if(O)return`${p}${O}`}this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let o=e._executableFile||`${this._name}-${e._name}`,a=this._executableDir||"";if(this._scriptPath){let d;try{d=wt.realpathSync(this._scriptPath)}catch{d=this._scriptPath}a=W.resolve(W.dirname(d),a)}if(a){let d=n(a,o);if(!d&&!e._executableFile&&this._scriptPath){let f=W.basename(this._scriptPath,W.extname(this._scriptPath));f!==this._name&&(d=n(a,`${f}-${e._name}`))}o=d||o}s=r.includes(W.extname(o));let l;C.platform!=="win32"?s?(t.unshift(o),t=ts(C.execArgv).concat(t),l=bt.spawn(C.argv[0],t,{stdio:"inherit"})):l=bt.spawn(o,t,{stdio:"inherit"}):(t.unshift(o),t=ts(C.execArgv).concat(t),l=bt.spawn(C.execPath,t,{stdio:"inherit"})),l.killed||["SIGUSR1","SIGUSR2","SIGTERM","SIGINT","SIGHUP"].forEach(f=>{C.on(f,()=>{l.killed===!1&&l.exitCode===null&&l.kill(f)})});let h=this._exitCallback;l.on("close",d=>{d=d??1,h?h(new yt(d,"commander.executeSubCommandAsync","(close)")):C.exit(d)}),l.on("error",d=>{if(d.code==="ENOENT"){let f=a?`searched for local subcommand relative to directory '${a}'`:"no directory for search for local subcommand, use .executableDir() to supply a custom directory",p=`'${o}' does not exist
15
15
  - if '${e._name}' is not meant to be an executable command, remove description parameter from '.command()' and use '.description()' instead
16
16
  - if the default executable name is not suitable, use the executableFile option to supply a custom name or path
17
- - ${f}`;throw new Error(p)}else if(d.code==="EACCES")throw new Error(`'${o}' not executable`);if(!h)C.exit(1);else{let f=new _t(1,"commander.executeSubCommandAsync","(error)");f.nestedError=d,h(f)}}),this.runningCommand=l}_dispatchSubcommand(e,t,s){let r=this._findCommand(e);r||this.help({error:!0});let n;return n=this._chainOrCallSubCommandHook(n,r,"preSubcommand"),n=this._chainOrCall(n,()=>{if(r._executableHandler)this._executeSubCommand(r,t.concat(s));else return r._parseCommand(t,s)}),n}_dispatchHelpCommand(e){e||this.help();let t=this._findCommand(e);return t&&!t._executableHandler&&t.help(),this._dispatchSubcommand(e,[],[this._getHelpOption()?.long??this._getHelpOption()?.short??"--help"])}_checkNumberOfArguments(){this.registeredArguments.forEach((e,t)=>{e.required&&this.args[t]==null&&this.missingArgument(e.name())}),!(this.registeredArguments.length>0&&this.registeredArguments[this.registeredArguments.length-1].variadic)&&this.args.length>this.registeredArguments.length&&this._excessArguments(this.args)}_processArguments(){let e=(s,r,n)=>{let o=r;if(r!==null&&s.parseArg){let a=`error: command-argument value '${r}' is invalid for argument '${s.name()}'.`;o=this._callParseArg(s,r,n,a)}return o};this._checkNumberOfArguments();let t=[];this.registeredArguments.forEach((s,r)=>{let n=s.defaultValue;s.variadic?r<this.args.length?(n=this.args.slice(r),s.parseArg&&(n=n.reduce((o,a)=>e(s,a,o),s.defaultValue))):n===void 0&&(n=[]):r<this.args.length&&(n=this.args[r],s.parseArg&&(n=e(s,n,s.defaultValue))),t[r]=n}),this.processedArgs=t}_chainOrCall(e,t){return e&&e.then&&typeof e.then=="function"?e.then(()=>t()):t()}_chainOrCallHooks(e,t){let s=e,r=[];return this._getCommandAndAncestors().reverse().filter(n=>n._lifeCycleHooks[t]!==void 0).forEach(n=>{n._lifeCycleHooks[t].forEach(o=>{r.push({hookedCommand:n,callback:o})})}),t==="postAction"&&r.reverse(),r.forEach(n=>{s=this._chainOrCall(s,()=>n.callback(n.hookedCommand,this))}),s}_chainOrCallSubCommandHook(e,t,s){let r=e;return this._lifeCycleHooks[s]!==void 0&&this._lifeCycleHooks[s].forEach(n=>{r=this._chainOrCall(r,()=>n(this,t))}),r}_parseCommand(e,t){let s=this.parseOptions(t);if(this._parseOptionsEnv(),this._parseOptionsImplied(),e=e.concat(s.operands),t=s.unknown,this.args=e.concat(t),e&&this._findCommand(e[0]))return this._dispatchSubcommand(e[0],e.slice(1),t);if(this._getHelpCommand()&&e[0]===this._getHelpCommand().name())return this._dispatchHelpCommand(e[1]);if(this._defaultCommandName)return this._outputHelpIfRequested(t),this._dispatchSubcommand(this._defaultCommandName,e,t);this.commands.length&&this.args.length===0&&!this._actionHandler&&!this._defaultCommandName&&this.help({error:!0}),this._outputHelpIfRequested(s.unknown),this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let r=()=>{s.unknown.length>0&&this.unknownOption(s.unknown[0])},n=`command:${this.name()}`;if(this._actionHandler){r(),this._processArguments();let o;return o=this._chainOrCallHooks(o,"preAction"),o=this._chainOrCall(o,()=>this._actionHandler(this.processedArgs)),this.parent&&(o=this._chainOrCall(o,()=>{this.parent.emit(n,e,t)})),o=this._chainOrCallHooks(o,"postAction"),o}if(this.parent&&this.parent.listenerCount(n))r(),this._processArguments(),this.parent.emit(n,e,t);else if(e.length){if(this._findCommand("*"))return this._dispatchSubcommand("*",e,t);this.listenerCount("command:*")?this.emit("command:*",e,t):this.commands.length?this.unknownCommand():(r(),this._processArguments())}else this.commands.length?(r(),this.help({error:!0})):(r(),this._processArguments())}_findCommand(e){if(e)return this.commands.find(t=>t._name===e||t._aliases.includes(e))}_findOption(e){return this.options.find(t=>t.is(e))}_checkForMissingMandatoryOptions(){this._getCommandAndAncestors().forEach(e=>{e.options.forEach(t=>{t.mandatory&&e.getOptionValue(t.attributeName())===void 0&&e.missingMandatoryOptionValue(t)})})}_checkForConflictingLocalOptions(){let e=this.options.filter(s=>{let r=s.attributeName();return this.getOptionValue(r)===void 0?!1:this.getOptionValueSource(r)!=="default"});e.filter(s=>s.conflictsWith.length>0).forEach(s=>{let r=e.find(n=>s.conflictsWith.includes(n.attributeName()));r&&this._conflictingOption(s,r)})}_checkForConflictingOptions(){this._getCommandAndAncestors().forEach(e=>{e._checkForConflictingLocalOptions()})}parseOptions(e){let t=[],s=[],r=t,n=e.slice();function o(l){return l.length>1&&l[0]==="-"}let a=null;for(;n.length;){let l=n.shift();if(l==="--"){r===s&&r.push(l),r.push(...n);break}if(a&&!o(l)){this.emit(`option:${a.name()}`,l);continue}if(a=null,o(l)){let h=this._findOption(l);if(h){if(h.required){let d=n.shift();d===void 0&&this.optionMissingArgument(h),this.emit(`option:${h.name()}`,d)}else if(h.optional){let d=null;n.length>0&&!o(n[0])&&(d=n.shift()),this.emit(`option:${h.name()}`,d)}else this.emit(`option:${h.name()}`);a=h.variadic?h:null;continue}}if(l.length>2&&l[0]==="-"&&l[1]!=="-"){let h=this._findOption(`-${l[1]}`);if(h){h.required||h.optional&&this._combineFlagAndOptionalValue?this.emit(`option:${h.name()}`,l.slice(2)):(this.emit(`option:${h.name()}`),n.unshift(`-${l.slice(2)}`));continue}}if(/^--[^=]+=/.test(l)){let h=l.indexOf("="),d=this._findOption(l.slice(0,h));if(d&&(d.required||d.optional)){this.emit(`option:${d.name()}`,l.slice(h+1));continue}}if(o(l)&&(r=s),(this._enablePositionalOptions||this._passThroughOptions)&&t.length===0&&s.length===0){if(this._findCommand(l)){t.push(l),n.length>0&&s.push(...n);break}else if(this._getHelpCommand()&&l===this._getHelpCommand().name()){t.push(l),n.length>0&&t.push(...n);break}else if(this._defaultCommandName){s.push(l),n.length>0&&s.push(...n);break}}if(this._passThroughOptions){r.push(l),n.length>0&&r.push(...n);break}r.push(l)}return{operands:t,unknown:s}}opts(){if(this._storeOptionsAsProperties){let e={},t=this.options.length;for(let s=0;s<t;s++){let r=this.options[s].attributeName();e[r]=r===this._versionOptionName?this._version:this[r]}return e}return this._optionValues}optsWithGlobals(){return this._getCommandAndAncestors().reduce((e,t)=>Object.assign(e,t.opts()),{})}error(e,t){this._outputConfiguration.outputError(`${e}
17
+ - ${f}`;throw new Error(p)}else if(d.code==="EACCES")throw new Error(`'${o}' not executable`);if(!h)C.exit(1);else{let f=new yt(1,"commander.executeSubCommandAsync","(error)");f.nestedError=d,h(f)}}),this.runningCommand=l}_dispatchSubcommand(e,t,s){let r=this._findCommand(e);r||this.help({error:!0});let n;return n=this._chainOrCallSubCommandHook(n,r,"preSubcommand"),n=this._chainOrCall(n,()=>{if(r._executableHandler)this._executeSubCommand(r,t.concat(s));else return r._parseCommand(t,s)}),n}_dispatchHelpCommand(e){e||this.help();let t=this._findCommand(e);return t&&!t._executableHandler&&t.help(),this._dispatchSubcommand(e,[],[this._getHelpOption()?.long??this._getHelpOption()?.short??"--help"])}_checkNumberOfArguments(){this.registeredArguments.forEach((e,t)=>{e.required&&this.args[t]==null&&this.missingArgument(e.name())}),!(this.registeredArguments.length>0&&this.registeredArguments[this.registeredArguments.length-1].variadic)&&this.args.length>this.registeredArguments.length&&this._excessArguments(this.args)}_processArguments(){let e=(s,r,n)=>{let o=r;if(r!==null&&s.parseArg){let a=`error: command-argument value '${r}' is invalid for argument '${s.name()}'.`;o=this._callParseArg(s,r,n,a)}return o};this._checkNumberOfArguments();let t=[];this.registeredArguments.forEach((s,r)=>{let n=s.defaultValue;s.variadic?r<this.args.length?(n=this.args.slice(r),s.parseArg&&(n=n.reduce((o,a)=>e(s,a,o),s.defaultValue))):n===void 0&&(n=[]):r<this.args.length&&(n=this.args[r],s.parseArg&&(n=e(s,n,s.defaultValue))),t[r]=n}),this.processedArgs=t}_chainOrCall(e,t){return e&&e.then&&typeof e.then=="function"?e.then(()=>t()):t()}_chainOrCallHooks(e,t){let s=e,r=[];return this._getCommandAndAncestors().reverse().filter(n=>n._lifeCycleHooks[t]!==void 0).forEach(n=>{n._lifeCycleHooks[t].forEach(o=>{r.push({hookedCommand:n,callback:o})})}),t==="postAction"&&r.reverse(),r.forEach(n=>{s=this._chainOrCall(s,()=>n.callback(n.hookedCommand,this))}),s}_chainOrCallSubCommandHook(e,t,s){let r=e;return this._lifeCycleHooks[s]!==void 0&&this._lifeCycleHooks[s].forEach(n=>{r=this._chainOrCall(r,()=>n(this,t))}),r}_parseCommand(e,t){let s=this.parseOptions(t);if(this._parseOptionsEnv(),this._parseOptionsImplied(),e=e.concat(s.operands),t=s.unknown,this.args=e.concat(t),e&&this._findCommand(e[0]))return this._dispatchSubcommand(e[0],e.slice(1),t);if(this._getHelpCommand()&&e[0]===this._getHelpCommand().name())return this._dispatchHelpCommand(e[1]);if(this._defaultCommandName)return this._outputHelpIfRequested(t),this._dispatchSubcommand(this._defaultCommandName,e,t);this.commands.length&&this.args.length===0&&!this._actionHandler&&!this._defaultCommandName&&this.help({error:!0}),this._outputHelpIfRequested(s.unknown),this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let r=()=>{s.unknown.length>0&&this.unknownOption(s.unknown[0])},n=`command:${this.name()}`;if(this._actionHandler){r(),this._processArguments();let o;return o=this._chainOrCallHooks(o,"preAction"),o=this._chainOrCall(o,()=>this._actionHandler(this.processedArgs)),this.parent&&(o=this._chainOrCall(o,()=>{this.parent.emit(n,e,t)})),o=this._chainOrCallHooks(o,"postAction"),o}if(this.parent&&this.parent.listenerCount(n))r(),this._processArguments(),this.parent.emit(n,e,t);else if(e.length){if(this._findCommand("*"))return this._dispatchSubcommand("*",e,t);this.listenerCount("command:*")?this.emit("command:*",e,t):this.commands.length?this.unknownCommand():(r(),this._processArguments())}else this.commands.length?(r(),this.help({error:!0})):(r(),this._processArguments())}_findCommand(e){if(e)return this.commands.find(t=>t._name===e||t._aliases.includes(e))}_findOption(e){return this.options.find(t=>t.is(e))}_checkForMissingMandatoryOptions(){this._getCommandAndAncestors().forEach(e=>{e.options.forEach(t=>{t.mandatory&&e.getOptionValue(t.attributeName())===void 0&&e.missingMandatoryOptionValue(t)})})}_checkForConflictingLocalOptions(){let e=this.options.filter(s=>{let r=s.attributeName();return this.getOptionValue(r)===void 0?!1:this.getOptionValueSource(r)!=="default"});e.filter(s=>s.conflictsWith.length>0).forEach(s=>{let r=e.find(n=>s.conflictsWith.includes(n.attributeName()));r&&this._conflictingOption(s,r)})}_checkForConflictingOptions(){this._getCommandAndAncestors().forEach(e=>{e._checkForConflictingLocalOptions()})}parseOptions(e){let t=[],s=[],r=t,n=e.slice();function o(l){return l.length>1&&l[0]==="-"}let a=null;for(;n.length;){let l=n.shift();if(l==="--"){r===s&&r.push(l),r.push(...n);break}if(a&&!o(l)){this.emit(`option:${a.name()}`,l);continue}if(a=null,o(l)){let h=this._findOption(l);if(h){if(h.required){let d=n.shift();d===void 0&&this.optionMissingArgument(h),this.emit(`option:${h.name()}`,d)}else if(h.optional){let d=null;n.length>0&&!o(n[0])&&(d=n.shift()),this.emit(`option:${h.name()}`,d)}else this.emit(`option:${h.name()}`);a=h.variadic?h:null;continue}}if(l.length>2&&l[0]==="-"&&l[1]!=="-"){let h=this._findOption(`-${l[1]}`);if(h){h.required||h.optional&&this._combineFlagAndOptionalValue?this.emit(`option:${h.name()}`,l.slice(2)):(this.emit(`option:${h.name()}`),n.unshift(`-${l.slice(2)}`));continue}}if(/^--[^=]+=/.test(l)){let h=l.indexOf("="),d=this._findOption(l.slice(0,h));if(d&&(d.required||d.optional)){this.emit(`option:${d.name()}`,l.slice(h+1));continue}}if(o(l)&&(r=s),(this._enablePositionalOptions||this._passThroughOptions)&&t.length===0&&s.length===0){if(this._findCommand(l)){t.push(l),n.length>0&&s.push(...n);break}else if(this._getHelpCommand()&&l===this._getHelpCommand().name()){t.push(l),n.length>0&&t.push(...n);break}else if(this._defaultCommandName){s.push(l),n.length>0&&s.push(...n);break}}if(this._passThroughOptions){r.push(l),n.length>0&&r.push(...n);break}r.push(l)}return{operands:t,unknown:s}}opts(){if(this._storeOptionsAsProperties){let e={},t=this.options.length;for(let s=0;s<t;s++){let r=this.options[s].attributeName();e[r]=r===this._versionOptionName?this._version:this[r]}return e}return this._optionValues}optsWithGlobals(){return this._getCommandAndAncestors().reduce((e,t)=>Object.assign(e,t.opts()),{})}error(e,t){this._outputConfiguration.outputError(`${e}
18
18
  `,this._outputConfiguration.writeErr),typeof this._showHelpAfterError=="string"?this._outputConfiguration.writeErr(`${this._showHelpAfterError}
19
19
  `):this._showHelpAfterError&&(this._outputConfiguration.writeErr(`
20
- `),this.outputHelp({error:!0}));let s=t||{},r=s.exitCode||1,n=s.code||"commander.error";this._exit(r,n,e)}_parseOptionsEnv(){this.options.forEach(e=>{if(e.envVar&&e.envVar in C.env){let t=e.attributeName();(this.getOptionValue(t)===void 0||["default","config","env"].includes(this.getOptionValueSource(t)))&&(e.required||e.optional?this.emit(`optionEnv:${e.name()}`,C.env[e.envVar]):this.emit(`optionEnv:${e.name()}`))}})}_parseOptionsImplied(){let e=new Ba(this.options),t=s=>this.getOptionValue(s)!==void 0&&!["default","implied"].includes(this.getOptionValueSource(s));this.options.filter(s=>s.implied!==void 0&&t(s.attributeName())&&e.valueFromOption(this.getOptionValue(s.attributeName()),s)).forEach(s=>{Object.keys(s.implied).filter(r=>!t(r)).forEach(r=>{this.setOptionValueWithSource(r,s.implied[r],"implied")})})}missingArgument(e){let t=`error: missing required argument '${e}'`;this.error(t,{code:"commander.missingArgument"})}optionMissingArgument(e){let t=`error: option '${e.flags}' argument missing`;this.error(t,{code:"commander.optionMissingArgument"})}missingMandatoryOptionValue(e){let t=`error: required option '${e.flags}' not specified`;this.error(t,{code:"commander.missingMandatoryOptionValue"})}_conflictingOption(e,t){let s=o=>{let a=o.attributeName(),l=this.getOptionValue(a),h=this.options.find(f=>f.negate&&a===f.attributeName()),d=this.options.find(f=>!f.negate&&a===f.attributeName());return h&&(h.presetArg===void 0&&l===!1||h.presetArg!==void 0&&l===h.presetArg)?h:d||o},r=o=>{let a=s(o),l=a.attributeName();return this.getOptionValueSource(l)==="env"?`environment variable '${a.envVar}'`:`option '${a.flags}'`},n=`error: ${r(e)} cannot be used with ${r(t)}`;this.error(n,{code:"commander.conflictingOption"})}unknownOption(e){if(this._allowUnknownOption)return;let t="";if(e.startsWith("--")&&this._showSuggestionAfterError){let r=[],n=this;do{let o=n.createHelp().visibleOptions(n).filter(a=>a.long).map(a=>a.long);r=r.concat(o),n=n.parent}while(n&&!n._enablePositionalOptions);t=Qi(e,r)}let s=`error: unknown option '${e}'${t}`;this.error(s,{code:"commander.unknownOption"})}_excessArguments(e){if(this._allowExcessArguments)return;let t=this.registeredArguments.length,s=t===1?"":"s",n=`error: too many arguments${this.parent?` for '${this.name()}'`:""}. Expected ${t} argument${s} but got ${e.length}.`;this.error(n,{code:"commander.excessArguments"})}unknownCommand(){let e=this.args[0],t="";if(this._showSuggestionAfterError){let r=[];this.createHelp().visibleCommands(this).forEach(n=>{r.push(n.name()),n.alias()&&r.push(n.alias())}),t=Qi(e,r)}let s=`error: unknown command '${e}'${t}`;this.error(s,{code:"commander.unknownCommand"})}version(e,t,s){if(e===void 0)return this._version;this._version=e,t=t||"-V, --version",s=s||"output the version number";let r=this.createOption(t,s);return this._versionOptionName=r.attributeName(),this._registerOption(r),this.on("option:"+r.name(),()=>{this._outputConfiguration.writeOut(`${e}
21
- `),this._exit(0,"commander.version",e)}),this}description(e,t){return e===void 0&&t===void 0?this._description:(this._description=e,t&&(this._argsDescription=t),this)}summary(e){return e===void 0?this._summary:(this._summary=e,this)}alias(e){if(e===void 0)return this._aliases[0];let t=this;if(this.commands.length!==0&&this.commands[this.commands.length-1]._executableHandler&&(t=this.commands[this.commands.length-1]),e===t._name)throw new Error("Command alias can't be the same as its name");let s=this.parent?._findCommand(e);if(s){let r=[s.name()].concat(s.aliases()).join("|");throw new Error(`cannot add alias '${e}' to command '${this.name()}' as already have command '${r}'`)}return t._aliases.push(e),this}aliases(e){return e===void 0?this._aliases:(e.forEach(t=>this.alias(t)),this)}usage(e){if(e===void 0){if(this._usage)return this._usage;let t=this.registeredArguments.map(s=>La(s));return[].concat(this.options.length||this._helpOption!==null?"[options]":[],this.commands.length?"[command]":[],this.registeredArguments.length?t:[]).join(" ")}return this._usage=e,this}name(e){return e===void 0?this._name:(this._name=e,this)}nameFromFilename(e){return this._name=W.basename(e,W.extname(e)),this}executableDir(e){return e===void 0?this._executableDir:(this._executableDir=e,this)}helpInformation(e){let t=this.createHelp();return t.helpWidth===void 0&&(t.helpWidth=e&&e.error?this._outputConfiguration.getErrHelpWidth():this._outputConfiguration.getOutHelpWidth()),t.formatHelp(this,t)}_getHelpContext(e){e=e||{};let t={error:!!e.error},s;return t.error?s=r=>this._outputConfiguration.writeErr(r):s=r=>this._outputConfiguration.writeOut(r),t.write=e.write||s,t.command=this,t}outputHelp(e){let t;typeof e=="function"&&(t=e,e=void 0);let s=this._getHelpContext(e);this._getCommandAndAncestors().reverse().forEach(n=>n.emit("beforeAllHelp",s)),this.emit("beforeHelp",s);let r=this.helpInformation(s);if(t&&(r=t(r),typeof r!="string"&&!Buffer.isBuffer(r)))throw new Error("outputHelp callback must return a string or a Buffer");s.write(r),this._getHelpOption()?.long&&this.emit(this._getHelpOption().long),this.emit("afterHelp",s),this._getCommandAndAncestors().forEach(n=>n.emit("afterAllHelp",s))}helpOption(e,t){return typeof e=="boolean"?(e?this._helpOption=this._helpOption??void 0:this._helpOption=null,this):(e=e??"-h, --help",t=t??"display help for command",this._helpOption=this.createOption(e,t),this)}_getHelpOption(){return this._helpOption===void 0&&this.helpOption(void 0,void 0),this._helpOption}addHelpOption(e){return this._helpOption=e,this}help(e){this.outputHelp(e);let t=C.exitCode||0;t===0&&e&&typeof e!="function"&&e.error&&(t=1),this._exit(t,"commander.help","(outputHelp)")}addHelpText(e,t){let s=["beforeAll","before","after","afterAll"];if(!s.includes(e))throw new Error(`Unexpected value for position to addHelpText.
20
+ `),this.outputHelp({error:!0}));let s=t||{},r=s.exitCode||1,n=s.code||"commander.error";this._exit(r,n,e)}_parseOptionsEnv(){this.options.forEach(e=>{if(e.envVar&&e.envVar in C.env){let t=e.attributeName();(this.getOptionValue(t)===void 0||["default","config","env"].includes(this.getOptionValueSource(t)))&&(e.required||e.optional?this.emit(`optionEnv:${e.name()}`,C.env[e.envVar]):this.emit(`optionEnv:${e.name()}`))}})}_parseOptionsImplied(){let e=new Ya(this.options),t=s=>this.getOptionValue(s)!==void 0&&!["default","implied"].includes(this.getOptionValueSource(s));this.options.filter(s=>s.implied!==void 0&&t(s.attributeName())&&e.valueFromOption(this.getOptionValue(s.attributeName()),s)).forEach(s=>{Object.keys(s.implied).filter(r=>!t(r)).forEach(r=>{this.setOptionValueWithSource(r,s.implied[r],"implied")})})}missingArgument(e){let t=`error: missing required argument '${e}'`;this.error(t,{code:"commander.missingArgument"})}optionMissingArgument(e){let t=`error: option '${e.flags}' argument missing`;this.error(t,{code:"commander.optionMissingArgument"})}missingMandatoryOptionValue(e){let t=`error: required option '${e.flags}' not specified`;this.error(t,{code:"commander.missingMandatoryOptionValue"})}_conflictingOption(e,t){let s=o=>{let a=o.attributeName(),l=this.getOptionValue(a),h=this.options.find(f=>f.negate&&a===f.attributeName()),d=this.options.find(f=>!f.negate&&a===f.attributeName());return h&&(h.presetArg===void 0&&l===!1||h.presetArg!==void 0&&l===h.presetArg)?h:d||o},r=o=>{let a=s(o),l=a.attributeName();return this.getOptionValueSource(l)==="env"?`environment variable '${a.envVar}'`:`option '${a.flags}'`},n=`error: ${r(e)} cannot be used with ${r(t)}`;this.error(n,{code:"commander.conflictingOption"})}unknownOption(e){if(this._allowUnknownOption)return;let t="";if(e.startsWith("--")&&this._showSuggestionAfterError){let r=[],n=this;do{let o=n.createHelp().visibleOptions(n).filter(a=>a.long).map(a=>a.long);r=r.concat(o),n=n.parent}while(n&&!n._enablePositionalOptions);t=es(e,r)}let s=`error: unknown option '${e}'${t}`;this.error(s,{code:"commander.unknownOption"})}_excessArguments(e){if(this._allowExcessArguments)return;let t=this.registeredArguments.length,s=t===1?"":"s",n=`error: too many arguments${this.parent?` for '${this.name()}'`:""}. Expected ${t} argument${s} but got ${e.length}.`;this.error(n,{code:"commander.excessArguments"})}unknownCommand(){let e=this.args[0],t="";if(this._showSuggestionAfterError){let r=[];this.createHelp().visibleCommands(this).forEach(n=>{r.push(n.name()),n.alias()&&r.push(n.alias())}),t=es(e,r)}let s=`error: unknown command '${e}'${t}`;this.error(s,{code:"commander.unknownCommand"})}version(e,t,s){if(e===void 0)return this._version;this._version=e,t=t||"-V, --version",s=s||"output the version number";let r=this.createOption(t,s);return this._versionOptionName=r.attributeName(),this._registerOption(r),this.on("option:"+r.name(),()=>{this._outputConfiguration.writeOut(`${e}
21
+ `),this._exit(0,"commander.version",e)}),this}description(e,t){return e===void 0&&t===void 0?this._description:(this._description=e,t&&(this._argsDescription=t),this)}summary(e){return e===void 0?this._summary:(this._summary=e,this)}alias(e){if(e===void 0)return this._aliases[0];let t=this;if(this.commands.length!==0&&this.commands[this.commands.length-1]._executableHandler&&(t=this.commands[this.commands.length-1]),e===t._name)throw new Error("Command alias can't be the same as its name");let s=this.parent?._findCommand(e);if(s){let r=[s.name()].concat(s.aliases()).join("|");throw new Error(`cannot add alias '${e}' to command '${this.name()}' as already have command '${r}'`)}return t._aliases.push(e),this}aliases(e){return e===void 0?this._aliases:(e.forEach(t=>this.alias(t)),this)}usage(e){if(e===void 0){if(this._usage)return this._usage;let t=this.registeredArguments.map(s=>Ga(s));return[].concat(this.options.length||this._helpOption!==null?"[options]":[],this.commands.length?"[command]":[],this.registeredArguments.length?t:[]).join(" ")}return this._usage=e,this}name(e){return e===void 0?this._name:(this._name=e,this)}nameFromFilename(e){return this._name=W.basename(e,W.extname(e)),this}executableDir(e){return e===void 0?this._executableDir:(this._executableDir=e,this)}helpInformation(e){let t=this.createHelp();return t.helpWidth===void 0&&(t.helpWidth=e&&e.error?this._outputConfiguration.getErrHelpWidth():this._outputConfiguration.getOutHelpWidth()),t.formatHelp(this,t)}_getHelpContext(e){e=e||{};let t={error:!!e.error},s;return t.error?s=r=>this._outputConfiguration.writeErr(r):s=r=>this._outputConfiguration.writeOut(r),t.write=e.write||s,t.command=this,t}outputHelp(e){let t;typeof e=="function"&&(t=e,e=void 0);let s=this._getHelpContext(e);this._getCommandAndAncestors().reverse().forEach(n=>n.emit("beforeAllHelp",s)),this.emit("beforeHelp",s);let r=this.helpInformation(s);if(t&&(r=t(r),typeof r!="string"&&!Buffer.isBuffer(r)))throw new Error("outputHelp callback must return a string or a Buffer");s.write(r),this._getHelpOption()?.long&&this.emit(this._getHelpOption().long),this.emit("afterHelp",s),this._getCommandAndAncestors().forEach(n=>n.emit("afterAllHelp",s))}helpOption(e,t){return typeof e=="boolean"?(e?this._helpOption=this._helpOption??void 0:this._helpOption=null,this):(e=e??"-h, --help",t=t??"display help for command",this._helpOption=this.createOption(e,t),this)}_getHelpOption(){return this._helpOption===void 0&&this.helpOption(void 0,void 0),this._helpOption}addHelpOption(e){return this._helpOption=e,this}help(e){this.outputHelp(e);let t=C.exitCode||0;t===0&&e&&typeof e!="function"&&e.error&&(t=1),this._exit(t,"commander.help","(outputHelp)")}addHelpText(e,t){let s=["beforeAll","before","after","afterAll"];if(!s.includes(e))throw new Error(`Unexpected value for position to addHelpText.
22
22
  Expecting one of '${s.join("', '")}'`);let r=`${e}Help`;return this.on(r,n=>{let o;typeof t=="function"?o=t({error:n.error,command:n.command}):o=t,o&&n.write(`${o}
23
- `)}),this}_outputHelpIfRequested(e){let t=this._getHelpOption();t&&e.find(r=>t.is(r))&&(this.outputHelp(),this._exit(0,"commander.helpDisplayed","(outputHelp)"))}};function es(i){return i.map(e=>{if(!e.startsWith("--inspect"))return e;let t,s="127.0.0.1",r="9229",n;return(n=e.match(/^(--inspect(-brk)?)$/))!==null?t=n[1]:(n=e.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))!==null?(t=n[1],/^\d+$/.test(n[3])?r=n[3]:s=n[3]):(n=e.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null&&(t=n[1],s=n[3],r=n[4]),t&&r!=="0"?`${t}=${s}:${parseInt(r)+1}`:e})}ts.Command=vt});var os=c(k=>{var{Argument:ss}=Re(),{Command:xt}=is(),{CommanderError:Ya,InvalidArgumentError:rs}=Ce(),{Help:Ua}=ft(),{Option:ns}=bt();k.program=new xt;k.createCommand=i=>new xt(i);k.createOption=(i,e)=>new ns(i,e);k.createArgument=(i,e)=>new ss(i,e);k.Command=xt;k.Option=ns;k.Argument=ss;k.Help=Ua;k.CommanderError=Ya;k.InvalidArgumentError=rs;k.InvalidOptionArgumentError=rs});var _=c((Fc,ms)=>{"use strict";var{FORCE_COLOR:Ja,NODE_DISABLE_COLORS:Ka,TERM:za}=process.env,g={enabled:!Ka&&za!=="dumb"&&Ja!=="0",reset:y(0,0),bold:y(1,22),dim:y(2,22),italic:y(3,23),underline:y(4,24),inverse:y(7,27),hidden:y(8,28),strikethrough:y(9,29),black:y(30,39),red:y(31,39),green:y(32,39),yellow:y(33,39),blue:y(34,39),magenta:y(35,39),cyan:y(36,39),white:y(37,39),gray:y(90,39),grey:y(90,39),bgBlack:y(40,49),bgRed:y(41,49),bgGreen:y(42,49),bgYellow:y(43,49),bgBlue:y(44,49),bgMagenta:y(45,49),bgCyan:y(46,49),bgWhite:y(47,49)};function ps(i,e){let t=0,s,r="",n="";for(;t<i.length;t++)s=i[t],r+=s.open,n+=s.close,e.includes(s.close)&&(e=e.replace(s.rgx,s.close+s.open));return r+e+n}function Za(i,e){let t={has:i,keys:e};return t.reset=g.reset.bind(t),t.bold=g.bold.bind(t),t.dim=g.dim.bind(t),t.italic=g.italic.bind(t),t.underline=g.underline.bind(t),t.inverse=g.inverse.bind(t),t.hidden=g.hidden.bind(t),t.strikethrough=g.strikethrough.bind(t),t.black=g.black.bind(t),t.red=g.red.bind(t),t.green=g.green.bind(t),t.yellow=g.yellow.bind(t),t.blue=g.blue.bind(t),t.magenta=g.magenta.bind(t),t.cyan=g.cyan.bind(t),t.white=g.white.bind(t),t.gray=g.gray.bind(t),t.grey=g.grey.bind(t),t.bgBlack=g.bgBlack.bind(t),t.bgRed=g.bgRed.bind(t),t.bgGreen=g.bgGreen.bind(t),t.bgYellow=g.bgYellow.bind(t),t.bgBlue=g.bgBlue.bind(t),t.bgMagenta=g.bgMagenta.bind(t),t.bgCyan=g.bgCyan.bind(t),t.bgWhite=g.bgWhite.bind(t),t}function y(i,e){let t={open:`\x1B[${i}m`,close:`\x1B[${e}m`,rgx:new RegExp(`\\x1b\\[${e}m`,"g")};return function(s){return this!==void 0&&this.has!==void 0?(this.has.includes(i)||(this.has.push(i),this.keys.push(t)),s===void 0?this:g.enabled?ps(this.keys,s+""):s+""):s===void 0?Za([i],[t]):g.enabled?ps([t],s+""):s+""}}ms.exports=g});var bs=c((Rc,gs)=>{"use strict";gs.exports=(i,e)=>{if(!(i.meta&&i.name!=="escape")){if(i.ctrl){if(i.name==="a")return"first";if(i.name==="c"||i.name==="d")return"abort";if(i.name==="e")return"last";if(i.name==="g")return"reset"}if(e){if(i.name==="j")return"down";if(i.name==="k")return"up"}return i.name==="return"||i.name==="enter"?"submit":i.name==="backspace"?"delete":i.name==="delete"?"deleteForward":i.name==="abort"?"abort":i.name==="escape"?"exit":i.name==="tab"?"next":i.name==="pagedown"?"nextPage":i.name==="pageup"?"prevPage":i.name==="home"?"home":i.name==="end"?"end":i.name==="up"?"up":i.name==="down"?"down":i.name==="right"?"right":i.name==="left"?"left":!1}}});var Ne=c((Nc,ws)=>{"use strict";ws.exports=i=>{let e=["[\\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("|"),t=new RegExp(e,"g");return typeof i=="string"?i.replace(t,""):i}});var x=c((Lc,ys)=>{"use strict";var Ot="\x1B",v=`${Ot}[`,Xa="\x07",St={to(i,e){return e?`${v}${e+1};${i+1}H`:`${v}${i+1}G`},move(i,e){let t="";return i<0?t+=`${v}${-i}D`:i>0&&(t+=`${v}${i}C`),e<0?t+=`${v}${-e}A`:e>0&&(t+=`${v}${e}B`),t},up:(i=1)=>`${v}${i}A`,down:(i=1)=>`${v}${i}B`,forward:(i=1)=>`${v}${i}C`,backward:(i=1)=>`${v}${i}D`,nextLine:(i=1)=>`${v}E`.repeat(i),prevLine:(i=1)=>`${v}F`.repeat(i),left:`${v}G`,hide:`${v}?25l`,show:`${v}?25h`,save:`${Ot}7`,restore:`${Ot}8`},Qa={up:(i=1)=>`${v}S`.repeat(i),down:(i=1)=>`${v}T`.repeat(i)},el={screen:`${v}2J`,up:(i=1)=>`${v}1J`.repeat(i),down:(i=1)=>`${v}J`.repeat(i),line:`${v}2K`,lineEnd:`${v}K`,lineStart:`${v}1K`,lines(i){let e="";for(let t=0;t<i;t++)e+=this.line+(t<i-1?St.up():"");return i&&(e+=St.left),e}};ys.exports={cursor:St,scroll:Qa,erase:el,beep:Xa}});var Os=c((Gc,Cs)=>{"use strict";function tl(i,e){var t=typeof Symbol<"u"&&i[Symbol.iterator]||i["@@iterator"];if(!t){if(Array.isArray(i)||(t=il(i))||e&&i&&typeof i.length=="number"){t&&(i=t);var s=0,r=function(){};return{s:r,n:function(){return s>=i.length?{done:!0}:{done:!1,value:i[s++]}},e:function(h){throw h},f:r}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
24
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var n=!0,o=!1,a;return{s:function(){t=t.call(i)},n:function(){var h=t.next();return n=h.done,h},e:function(h){o=!0,a=h},f:function(){try{!n&&t.return!=null&&t.return()}finally{if(o)throw a}}}}function il(i,e){if(i){if(typeof i=="string")return _s(i,e);var t=Object.prototype.toString.call(i).slice(8,-1);if(t==="Object"&&i.constructor&&(t=i.constructor.name),t==="Map"||t==="Set")return Array.from(i);if(t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return _s(i,e)}}function _s(i,e){(e==null||e>i.length)&&(e=i.length);for(var t=0,s=new Array(e);t<e;t++)s[t]=i[t];return s}var sl=Ne(),xs=x(),vs=xs.erase,rl=xs.cursor,nl=i=>[...sl(i)].length;Cs.exports=function(i,e){if(!e)return vs.line+rl.to(0);let t=0,s=i.split(/\r?\n/);var r=tl(s),n;try{for(r.s();!(n=r.n()).done;){let o=n.value;t+=1+Math.floor(Math.max(nl(o)-1,0)/e)}}catch(o){r.e(o)}finally{r.f()}return vs.lines(t)}});var $t=c((Bc,Ss)=>{"use strict";var Oe={arrowUp:"\u2191",arrowDown:"\u2193",arrowLeft:"\u2190",arrowRight:"\u2192",radioOn:"\u25C9",radioOff:"\u25EF",tick:"\u2714",cross:"\u2716",ellipsis:"\u2026",pointerSmall:"\u203A",line:"\u2500",pointer:"\u276F"},ol={arrowUp:Oe.arrowUp,arrowDown:Oe.arrowDown,arrowLeft:Oe.arrowLeft,arrowRight:Oe.arrowRight,radioOn:"(*)",radioOff:"( )",tick:"\u221A",cross:"\xD7",ellipsis:"...",pointerSmall:"\xBB",line:"\u2500",pointer:">"},al=process.platform==="win32"?ol:Oe;Ss.exports=al});var As=c((Yc,$s)=>{"use strict";var pe=_(),ue=$t(),At=Object.freeze({password:{scale:1,render:i=>"*".repeat(i.length)},emoji:{scale:2,render:i=>"\u{1F603}".repeat(i.length)},invisible:{scale:0,render:i=>""},default:{scale:1,render:i=>`${i}`}}),ll=i=>At[i]||At.default,Se=Object.freeze({aborted:pe.red(ue.cross),done:pe.green(ue.tick),exited:pe.yellow(ue.cross),default:pe.cyan("?")}),hl=(i,e,t)=>e?Se.aborted:t?Se.exited:i?Se.done:Se.default,ul=i=>pe.gray(i?ue.ellipsis:ue.pointerSmall),cl=(i,e)=>pe.gray(i?e?ue.pointerSmall:"+":ue.line);$s.exports={styles:At,render:ll,symbols:Se,symbol:hl,delimiter:ul,item:cl}});var Es=c((Uc,Ps)=>{"use strict";var dl=Ne();Ps.exports=function(i,e){let t=String(dl(i)||"").split(/\r?\n/);return e?t.map(s=>Math.ceil(s.length/e)).reduce((s,r)=>s+r):t.length}});var Ts=c((Wc,qs)=>{"use strict";qs.exports=(i,e={})=>{let t=Number.isSafeInteger(parseInt(e.margin))?new Array(parseInt(e.margin)).fill(" ").join(""):e.margin||"",s=e.width;return(i||"").split(/\r?\n/g).map(r=>r.split(/\s+/g).reduce((n,o)=>(o.length+t.length>=s||n[n.length-1].length+o.length+1<s?n[n.length-1]+=` ${o}`:n.push(`${t}${o}`),n),[t]).join(`
23
+ `)}),this}_outputHelpIfRequested(e){let t=this._getHelpOption();t&&e.find(r=>t.is(r))&&(this.outputHelp(),this._exit(0,"commander.helpDisplayed","(outputHelp)"))}};function ts(i){return i.map(e=>{if(!e.startsWith("--inspect"))return e;let t,s="127.0.0.1",r="9229",n;return(n=e.match(/^(--inspect(-brk)?)$/))!==null?t=n[1]:(n=e.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))!==null?(t=n[1],/^\d+$/.test(n[3])?r=n[3]:s=n[3]):(n=e.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null&&(t=n[1],s=n[3],r=n[4]),t&&r!=="0"?`${t}=${s}:${parseInt(r)+1}`:e})}is.Command=_t});var as=c(k=>{var{Argument:rs}=Fe(),{Command:vt}=ss(),{CommanderError:Ua,InvalidArgumentError:ns}=xe(),{Help:Wa}=dt(),{Option:os}=gt();k.program=new vt;k.createCommand=i=>new vt(i);k.createOption=(i,e)=>new os(i,e);k.createArgument=(i,e)=>new rs(i,e);k.Command=vt;k.Option=os;k.Argument=rs;k.Help=Wa;k.CommanderError=Ua;k.InvalidArgumentError=ns;k.InvalidOptionArgumentError=ns});var _=c((Rc,gs)=>{"use strict";var{FORCE_COLOR:Ka,NODE_DISABLE_COLORS:za,TERM:Za}=process.env,g={enabled:!za&&Za!=="dumb"&&Ka!=="0",reset:y(0,0),bold:y(1,22),dim:y(2,22),italic:y(3,23),underline:y(4,24),inverse:y(7,27),hidden:y(8,28),strikethrough:y(9,29),black:y(30,39),red:y(31,39),green:y(32,39),yellow:y(33,39),blue:y(34,39),magenta:y(35,39),cyan:y(36,39),white:y(37,39),gray:y(90,39),grey:y(90,39),bgBlack:y(40,49),bgRed:y(41,49),bgGreen:y(42,49),bgYellow:y(43,49),bgBlue:y(44,49),bgMagenta:y(45,49),bgCyan:y(46,49),bgWhite:y(47,49)};function ms(i,e){let t=0,s,r="",n="";for(;t<i.length;t++)s=i[t],r+=s.open,n+=s.close,e.includes(s.close)&&(e=e.replace(s.rgx,s.close+s.open));return r+e+n}function Xa(i,e){let t={has:i,keys:e};return t.reset=g.reset.bind(t),t.bold=g.bold.bind(t),t.dim=g.dim.bind(t),t.italic=g.italic.bind(t),t.underline=g.underline.bind(t),t.inverse=g.inverse.bind(t),t.hidden=g.hidden.bind(t),t.strikethrough=g.strikethrough.bind(t),t.black=g.black.bind(t),t.red=g.red.bind(t),t.green=g.green.bind(t),t.yellow=g.yellow.bind(t),t.blue=g.blue.bind(t),t.magenta=g.magenta.bind(t),t.cyan=g.cyan.bind(t),t.white=g.white.bind(t),t.gray=g.gray.bind(t),t.grey=g.grey.bind(t),t.bgBlack=g.bgBlack.bind(t),t.bgRed=g.bgRed.bind(t),t.bgGreen=g.bgGreen.bind(t),t.bgYellow=g.bgYellow.bind(t),t.bgBlue=g.bgBlue.bind(t),t.bgMagenta=g.bgMagenta.bind(t),t.bgCyan=g.bgCyan.bind(t),t.bgWhite=g.bgWhite.bind(t),t}function y(i,e){let t={open:`\x1B[${i}m`,close:`\x1B[${e}m`,rgx:new RegExp(`\\x1b\\[${e}m`,"g")};return function(s){return this!==void 0&&this.has!==void 0?(this.has.includes(i)||(this.has.push(i),this.keys.push(t)),s===void 0?this:g.enabled?ms(this.keys,s+""):s+""):s===void 0?Xa([i],[t]):g.enabled?ms([t],s+""):s+""}}gs.exports=g});var ws=c((Nc,bs)=>{"use strict";bs.exports=(i,e)=>{if(!(i.meta&&i.name!=="escape")){if(i.ctrl){if(i.name==="a")return"first";if(i.name==="c"||i.name==="d")return"abort";if(i.name==="e")return"last";if(i.name==="g")return"reset"}if(e){if(i.name==="j")return"down";if(i.name==="k")return"up"}return i.name==="return"||i.name==="enter"?"submit":i.name==="backspace"?"delete":i.name==="delete"?"deleteForward":i.name==="abort"?"abort":i.name==="escape"?"exit":i.name==="tab"?"next":i.name==="pagedown"?"nextPage":i.name==="pageup"?"prevPage":i.name==="home"?"home":i.name==="end"?"end":i.name==="up"?"up":i.name==="down"?"down":i.name==="right"?"right":i.name==="left"?"left":!1}}});var Re=c((Lc,ys)=>{"use strict";ys.exports=i=>{let e=["[\\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("|"),t=new RegExp(e,"g");return typeof i=="string"?i.replace(t,""):i}});var x=c((Gc,_s)=>{"use strict";var Ct="\x1B",v=`${Ct}[`,Qa="\x07",Ot={to(i,e){return e?`${v}${e+1};${i+1}H`:`${v}${i+1}G`},move(i,e){let t="";return i<0?t+=`${v}${-i}D`:i>0&&(t+=`${v}${i}C`),e<0?t+=`${v}${-e}A`:e>0&&(t+=`${v}${e}B`),t},up:(i=1)=>`${v}${i}A`,down:(i=1)=>`${v}${i}B`,forward:(i=1)=>`${v}${i}C`,backward:(i=1)=>`${v}${i}D`,nextLine:(i=1)=>`${v}E`.repeat(i),prevLine:(i=1)=>`${v}F`.repeat(i),left:`${v}G`,hide:`${v}?25l`,show:`${v}?25h`,save:`${Ct}7`,restore:`${Ct}8`},el={up:(i=1)=>`${v}S`.repeat(i),down:(i=1)=>`${v}T`.repeat(i)},tl={screen:`${v}2J`,up:(i=1)=>`${v}1J`.repeat(i),down:(i=1)=>`${v}J`.repeat(i),line:`${v}2K`,lineEnd:`${v}K`,lineStart:`${v}1K`,lines(i){let e="";for(let t=0;t<i;t++)e+=this.line+(t<i-1?Ot.up():"");return i&&(e+=Ot.left),e}};_s.exports={cursor:Ot,scroll:el,erase:tl,beep:Qa}});var Ss=c((Bc,Os)=>{"use strict";function il(i,e){var t=typeof Symbol<"u"&&i[Symbol.iterator]||i["@@iterator"];if(!t){if(Array.isArray(i)||(t=sl(i))||e&&i&&typeof i.length=="number"){t&&(i=t);var s=0,r=function(){};return{s:r,n:function(){return s>=i.length?{done:!0}:{done:!1,value:i[s++]}},e:function(h){throw h},f:r}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
24
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var n=!0,o=!1,a;return{s:function(){t=t.call(i)},n:function(){var h=t.next();return n=h.done,h},e:function(h){o=!0,a=h},f:function(){try{!n&&t.return!=null&&t.return()}finally{if(o)throw a}}}}function sl(i,e){if(i){if(typeof i=="string")return vs(i,e);var t=Object.prototype.toString.call(i).slice(8,-1);if(t==="Object"&&i.constructor&&(t=i.constructor.name),t==="Map"||t==="Set")return Array.from(i);if(t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return vs(i,e)}}function vs(i,e){(e==null||e>i.length)&&(e=i.length);for(var t=0,s=new Array(e);t<e;t++)s[t]=i[t];return s}var rl=Re(),Cs=x(),xs=Cs.erase,nl=Cs.cursor,ol=i=>[...rl(i)].length;Os.exports=function(i,e){if(!e)return xs.line+nl.to(0);let t=0,s=i.split(/\r?\n/);var r=il(s),n;try{for(r.s();!(n=r.n()).done;){let o=n.value;t+=1+Math.floor(Math.max(ol(o)-1,0)/e)}}catch(o){r.e(o)}finally{r.f()}return xs.lines(t)}});var St=c((Yc,$s)=>{"use strict";var Ce={arrowUp:"\u2191",arrowDown:"\u2193",arrowLeft:"\u2190",arrowRight:"\u2192",radioOn:"\u25C9",radioOff:"\u25EF",tick:"\u2714",cross:"\u2716",ellipsis:"\u2026",pointerSmall:"\u203A",line:"\u2500",pointer:"\u276F"},al={arrowUp:Ce.arrowUp,arrowDown:Ce.arrowDown,arrowLeft:Ce.arrowLeft,arrowRight:Ce.arrowRight,radioOn:"(*)",radioOff:"( )",tick:"\u221A",cross:"\xD7",ellipsis:"...",pointerSmall:"\xBB",line:"\u2500",pointer:">"},ll=process.platform==="win32"?al:Ce;$s.exports=ll});var Ps=c((Uc,As)=>{"use strict";var me=_(),ue=St(),$t=Object.freeze({password:{scale:1,render:i=>"*".repeat(i.length)},emoji:{scale:2,render:i=>"\u{1F603}".repeat(i.length)},invisible:{scale:0,render:i=>""},default:{scale:1,render:i=>`${i}`}}),hl=i=>$t[i]||$t.default,Oe=Object.freeze({aborted:me.red(ue.cross),done:me.green(ue.tick),exited:me.yellow(ue.cross),default:me.cyan("?")}),ul=(i,e,t)=>e?Oe.aborted:t?Oe.exited:i?Oe.done:Oe.default,cl=i=>me.gray(i?ue.ellipsis:ue.pointerSmall),dl=(i,e)=>me.gray(i?e?ue.pointerSmall:"+":ue.line);As.exports={styles:$t,render:hl,symbols:Oe,symbol:ul,delimiter:cl,item:dl}});var qs=c((Wc,Es)=>{"use strict";var fl=Re();Es.exports=function(i,e){let t=String(fl(i)||"").split(/\r?\n/);return e?t.map(s=>Math.ceil(s.length/e)).reduce((s,r)=>s+r):t.length}});var ks=c((Jc,Ts)=>{"use strict";Ts.exports=(i,e={})=>{let t=Number.isSafeInteger(parseInt(e.margin))?new Array(parseInt(e.margin)).fill(" ").join(""):e.margin||"",s=e.width;return(i||"").split(/\r?\n/g).map(r=>r.split(/\s+/g).reduce((n,o)=>(o.length+t.length>=s||n[n.length-1].length+o.length+1<s?n[n.length-1]+=` ${o}`:n.push(`${t}${o}`),n),[t]).join(`
25
25
  `)).join(`
26
- `)}});var Ms=c((Jc,ks)=>{"use strict";ks.exports=(i,e,t)=>{t=t||e;let s=Math.min(e-t,i-Math.floor(t/2));s<0&&(s=0);let r=Math.min(s+t,e);return{startIndex:s,endIndex:r}}});var D=c((Kc,Is)=>{"use strict";Is.exports={action:bs(),clear:Os(),style:As(),strip:Ne(),figures:$t(),lines:Es(),wrap:Ts(),entriesToDisplay:Ms()}});var J=c((zc,Vs)=>{"use strict";var Ds=require("readline"),fl=D(),pl=fl.action,ml=require("events"),js=x(),gl=js.beep,bl=js.cursor,wl=_(),Pt=class extends ml{constructor(e={}){super(),this.firstRender=!0,this.in=e.stdin||process.stdin,this.out=e.stdout||process.stdout,this.onRender=(e.onRender||(()=>{})).bind(this);let t=Ds.createInterface({input:this.in,escapeCodeTimeout:50});Ds.emitKeypressEvents(this.in,t),this.in.isTTY&&this.in.setRawMode(!0);let s=["SelectPrompt","MultiselectPrompt"].indexOf(this.constructor.name)>-1,r=(n,o)=>{let a=pl(o,s);a===!1?this._&&this._(n,o):typeof this[a]=="function"?this[a](o):this.bell()};this.close=()=>{this.out.write(bl.show),this.in.removeListener("keypress",r),this.in.isTTY&&this.in.setRawMode(!1),t.close(),this.emit(this.aborted?"abort":this.exited?"exit":"submit",this.value),this.closed=!0},this.in.on("keypress",r)}fire(){this.emit("state",{value:this.value,aborted:!!this.aborted,exited:!!this.exited})}bell(){this.out.write(gl)}render(){this.onRender(wl),this.firstRender&&(this.firstRender=!1)}};Vs.exports=Pt});var Ls=c((Zc,Ns)=>{"use strict";function Hs(i,e,t,s,r,n,o){try{var a=i[n](o),l=a.value}catch(h){t(h);return}a.done?e(l):Promise.resolve(l).then(s,r)}function Fs(i){return function(){var e=this,t=arguments;return new Promise(function(s,r){var n=i.apply(e,t);function o(l){Hs(n,s,r,o,a,"next",l)}function a(l){Hs(n,s,r,o,a,"throw",l)}o(void 0)})}}var Le=_(),yl=J(),Rs=x(),_l=Rs.erase,$e=Rs.cursor,Ge=D(),Et=Ge.style,qt=Ge.clear,vl=Ge.lines,xl=Ge.figures,Tt=class extends yl{constructor(e={}){super(e),this.transform=Et.render(e.style),this.scale=this.transform.scale,this.msg=e.message,this.initial=e.initial||"",this.validator=e.validate||(()=>!0),this.value="",this.errorMsg=e.error||"Please Enter A Valid Value",this.cursor=+!!this.initial,this.cursorOffset=0,this.clear=qt("",this.out.columns),this.render()}set value(e){!e&&this.initial?(this.placeholder=!0,this.rendered=Le.gray(this.transform.render(this.initial))):(this.placeholder=!1,this.rendered=this.transform.render(e)),this._value=e,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(`
27
- `),this.close()}validate(){var e=this;return Fs(function*(){let t=yield e.validator(e.value);typeof t=="string"&&(e.errorMsg=t,t=!1),e.error=!t})()}submit(){var e=this;return Fs(function*(){if(e.value=e.value||e.initial,e.cursorOffset=0,e.cursor=e.rendered.length,yield e.validate(),e.error){e.red=!0,e.fire(),e.render();return}e.done=!0,e.aborted=!1,e.fire(),e.render(),e.out.write(`
28
- `),e.close()})()}next(){if(!this.placeholder)return this.bell();this.value=this.initial,this.cursor=this.rendered.length,this.fire(),this.render()}moveCursor(e){this.placeholder||(this.cursor=this.cursor+e,this.cursorOffset+=e)}_(e,t){let s=this.value.slice(0,this.cursor),r=this.value.slice(this.cursor);this.value=`${s}${e}${r}`,this.red=!1,this.cursor=this.placeholder?0:s.length+1,this.render()}delete(){if(this.isCursorAtStart())return this.bell();let e=this.value.slice(0,this.cursor-1),t=this.value.slice(this.cursor);this.value=`${e}${t}`,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 e=this.value.slice(0,this.cursor),t=this.value.slice(this.cursor+1);this.value=`${e}${t}`,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($e.down(vl(this.outputError,this.out.columns)-1)+qt(this.outputError,this.out.columns)),this.out.write(qt(this.outputText,this.out.columns))),super.render(),this.outputError="",this.outputText=[Et.symbol(this.done,this.aborted),Le.bold(this.msg),Et.delimiter(this.done),this.red?Le.red(this.rendered):this.rendered].join(" "),this.error&&(this.outputError+=this.errorMsg.split(`
26
+ `)}});var Is=c((Kc,Ms)=>{"use strict";Ms.exports=(i,e,t)=>{t=t||e;let s=Math.min(e-t,i-Math.floor(t/2));s<0&&(s=0);let r=Math.min(s+t,e);return{startIndex:s,endIndex:r}}});var D=c((zc,Ds)=>{"use strict";Ds.exports={action:ws(),clear:Ss(),style:Ps(),strip:Re(),figures:St(),lines:qs(),wrap:ks(),entriesToDisplay:Is()}});var J=c((Zc,Hs)=>{"use strict";var js=require("readline"),pl=D(),ml=pl.action,gl=require("events"),Vs=x(),bl=Vs.beep,wl=Vs.cursor,yl=_(),At=class extends gl{constructor(e={}){super(),this.firstRender=!0,this.in=e.stdin||process.stdin,this.out=e.stdout||process.stdout,this.onRender=(e.onRender||(()=>{})).bind(this);let t=js.createInterface({input:this.in,escapeCodeTimeout:50});js.emitKeypressEvents(this.in,t),this.in.isTTY&&this.in.setRawMode(!0);let s=["SelectPrompt","MultiselectPrompt"].indexOf(this.constructor.name)>-1,r=(n,o)=>{let a=ml(o,s);a===!1?this._&&this._(n,o):typeof this[a]=="function"?this[a](o):this.bell()};this.close=()=>{this.out.write(wl.show),this.in.removeListener("keypress",r),this.in.isTTY&&this.in.setRawMode(!1),t.close(),this.emit(this.aborted?"abort":this.exited?"exit":"submit",this.value),this.closed=!0},this.in.on("keypress",r)}fire(){this.emit("state",{value:this.value,aborted:!!this.aborted,exited:!!this.exited})}bell(){this.out.write(bl)}render(){this.onRender(yl),this.firstRender&&(this.firstRender=!1)}};Hs.exports=At});var Gs=c((Xc,Ls)=>{"use strict";function Fs(i,e,t,s,r,n,o){try{var a=i[n](o),l=a.value}catch(h){t(h);return}a.done?e(l):Promise.resolve(l).then(s,r)}function Rs(i){return function(){var e=this,t=arguments;return new Promise(function(s,r){var n=i.apply(e,t);function o(l){Fs(n,s,r,o,a,"next",l)}function a(l){Fs(n,s,r,o,a,"throw",l)}o(void 0)})}}var Ne=_(),_l=J(),Ns=x(),vl=Ns.erase,Se=Ns.cursor,Le=D(),Pt=Le.style,Et=Le.clear,xl=Le.lines,Cl=Le.figures,qt=class extends _l{constructor(e={}){super(e),this.transform=Pt.render(e.style),this.scale=this.transform.scale,this.msg=e.message,this.initial=e.initial||"",this.validator=e.validate||(()=>!0),this.value="",this.errorMsg=e.error||"Please Enter A Valid Value",this.cursor=+!!this.initial,this.cursorOffset=0,this.clear=Et("",this.out.columns),this.render()}set value(e){!e&&this.initial?(this.placeholder=!0,this.rendered=Ne.gray(this.transform.render(this.initial))):(this.placeholder=!1,this.rendered=this.transform.render(e)),this._value=e,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(`
27
+ `),this.close()}validate(){var e=this;return Rs(function*(){let t=yield e.validator(e.value);typeof t=="string"&&(e.errorMsg=t,t=!1),e.error=!t})()}submit(){var e=this;return Rs(function*(){if(e.value=e.value||e.initial,e.cursorOffset=0,e.cursor=e.rendered.length,yield e.validate(),e.error){e.red=!0,e.fire(),e.render();return}e.done=!0,e.aborted=!1,e.fire(),e.render(),e.out.write(`
28
+ `),e.close()})()}next(){if(!this.placeholder)return this.bell();this.value=this.initial,this.cursor=this.rendered.length,this.fire(),this.render()}moveCursor(e){this.placeholder||(this.cursor=this.cursor+e,this.cursorOffset+=e)}_(e,t){let s=this.value.slice(0,this.cursor),r=this.value.slice(this.cursor);this.value=`${s}${e}${r}`,this.red=!1,this.cursor=this.placeholder?0:s.length+1,this.render()}delete(){if(this.isCursorAtStart())return this.bell();let e=this.value.slice(0,this.cursor-1),t=this.value.slice(this.cursor);this.value=`${e}${t}`,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 e=this.value.slice(0,this.cursor),t=this.value.slice(this.cursor+1);this.value=`${e}${t}`,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(Se.down(xl(this.outputError,this.out.columns)-1)+Et(this.outputError,this.out.columns)),this.out.write(Et(this.outputText,this.out.columns))),super.render(),this.outputError="",this.outputText=[Pt.symbol(this.done,this.aborted),Ne.bold(this.msg),Pt.delimiter(this.done),this.red?Ne.red(this.rendered):this.rendered].join(" "),this.error&&(this.outputError+=this.errorMsg.split(`
29
29
  `).reduce((e,t,s)=>e+`
30
- ${s?" ":xl.pointerSmall} ${Le.red().italic(t)}`,"")),this.out.write(_l.line+$e.to(0)+this.outputText+$e.save+this.outputError+$e.restore+$e.move(this.cursorOffset,0)))}};Ns.exports=Tt});var Us=c((Xc,Ys)=>{"use strict";var K=_(),Cl=J(),Ae=D(),Gs=Ae.style,Bs=Ae.clear,Be=Ae.figures,Ol=Ae.wrap,Sl=Ae.entriesToDisplay,$l=x(),Al=$l.cursor,kt=class extends Cl{constructor(e={}){super(e),this.msg=e.message,this.hint=e.hint||"- Use arrow-keys. Return to submit.",this.warn=e.warn||"- This option is disabled",this.cursor=e.initial||0,this.choices=e.choices.map((t,s)=>(typeof t=="string"&&(t={title:t,value:s}),{title:t&&(t.title||t.value||t),value:t&&(t.value===void 0?s:t.value),description:t&&t.description,selected:t&&t.selected,disabled:t&&t.disabled})),this.optionsPerPage=e.optionsPerPage||10,this.value=(this.choices[this.cursor]||{}).value,this.clear=Bs("",this.out.columns),this.render()}moveCursor(e){this.cursor=e,this.value=this.choices[e].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(`
30
+ ${s?" ":Cl.pointerSmall} ${Ne.red().italic(t)}`,"")),this.out.write(vl.line+Se.to(0)+this.outputText+Se.save+this.outputError+Se.restore+Se.move(this.cursorOffset,0)))}};Ls.exports=qt});var Ws=c((Qc,Us)=>{"use strict";var K=_(),Ol=J(),$e=D(),Bs=$e.style,Ys=$e.clear,Ge=$e.figures,Sl=$e.wrap,$l=$e.entriesToDisplay,Al=x(),Pl=Al.cursor,Tt=class extends Ol{constructor(e={}){super(e),this.msg=e.message,this.hint=e.hint||"- Use arrow-keys. Return to submit.",this.warn=e.warn||"- This option is disabled",this.cursor=e.initial||0,this.choices=e.choices.map((t,s)=>(typeof t=="string"&&(t={title:t,value:s}),{title:t&&(t.title||t.value||t),value:t&&(t.value===void 0?s:t.value),description:t&&t.description,selected:t&&t.selected,disabled:t&&t.disabled})),this.optionsPerPage=e.optionsPerPage||10,this.value=(this.choices[this.cursor]||{}).value,this.clear=Ys("",this.out.columns),this.render()}moveCursor(e){this.cursor=e,this.value=this.choices[e].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(`
31
31
  `),this.close()}submit(){this.selection.disabled?this.bell():(this.done=!0,this.aborted=!1,this.fire(),this.render(),this.out.write(`
32
- `),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()}_(e,t){if(e===" ")return this.submit()}get selection(){return this.choices[this.cursor]}render(){if(this.closed)return;this.firstRender?this.out.write(Al.hide):this.out.write(Bs(this.outputText,this.out.columns)),super.render();let e=Sl(this.cursor,this.choices.length,this.optionsPerPage),t=e.startIndex,s=e.endIndex;if(this.outputText=[Gs.symbol(this.done,this.aborted),K.bold(this.msg),Gs.delimiter(!1),this.done?this.selection.title:this.selection.disabled?K.yellow(this.warn):K.gray(this.hint)].join(" "),!this.done){this.outputText+=`
33
- `;for(let r=t;r<s;r++){let n,o,a="",l=this.choices[r];r===t&&t>0?o=Be.arrowUp:r===s-1&&s<this.choices.length?o=Be.arrowDown:o=" ",l.disabled?(n=this.cursor===r?K.gray().underline(l.title):K.strikethrough().gray(l.title),o=(this.cursor===r?K.bold().gray(Be.pointer)+" ":" ")+o):(n=this.cursor===r?K.cyan().underline(l.title):l.title,o=(this.cursor===r?K.cyan(Be.pointer)+" ":" ")+o,l.description&&this.cursor===r&&(a=` - ${l.description}`,(o.length+n.length+a.length>=this.out.columns||l.description.split(/\r?\n/).length>1)&&(a=`
34
- `+Ol(l.description,{margin:3,width:this.out.columns})))),this.outputText+=`${o} ${n}${K.gray(a)}
35
- `}}this.out.write(this.outputText)}};Ys.exports=kt});var Xs=c((Qc,Zs)=>{"use strict";var Ye=_(),Pl=J(),Ks=D(),Ws=Ks.style,El=Ks.clear,zs=x(),Js=zs.cursor,ql=zs.erase,Mt=class extends Pl{constructor(e={}){super(e),this.msg=e.message,this.value=!!e.initial,this.active=e.active||"on",this.inactive=e.inactive||"off",this.initialValue=this.value,this.render()}reset(){this.value=this.initialValue,this.fire(),this.render()}exit(){this.abort()}abort(){this.done=this.aborted=!0,this.fire(),this.render(),this.out.write(`
32
+ `),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()}_(e,t){if(e===" ")return this.submit()}get selection(){return this.choices[this.cursor]}render(){if(this.closed)return;this.firstRender?this.out.write(Pl.hide):this.out.write(Ys(this.outputText,this.out.columns)),super.render();let e=$l(this.cursor,this.choices.length,this.optionsPerPage),t=e.startIndex,s=e.endIndex;if(this.outputText=[Bs.symbol(this.done,this.aborted),K.bold(this.msg),Bs.delimiter(!1),this.done?this.selection.title:this.selection.disabled?K.yellow(this.warn):K.gray(this.hint)].join(" "),!this.done){this.outputText+=`
33
+ `;for(let r=t;r<s;r++){let n,o,a="",l=this.choices[r];r===t&&t>0?o=Ge.arrowUp:r===s-1&&s<this.choices.length?o=Ge.arrowDown:o=" ",l.disabled?(n=this.cursor===r?K.gray().underline(l.title):K.strikethrough().gray(l.title),o=(this.cursor===r?K.bold().gray(Ge.pointer)+" ":" ")+o):(n=this.cursor===r?K.cyan().underline(l.title):l.title,o=(this.cursor===r?K.cyan(Ge.pointer)+" ":" ")+o,l.description&&this.cursor===r&&(a=` - ${l.description}`,(o.length+n.length+a.length>=this.out.columns||l.description.split(/\r?\n/).length>1)&&(a=`
34
+ `+Sl(l.description,{margin:3,width:this.out.columns})))),this.outputText+=`${o} ${n}${K.gray(a)}
35
+ `}}this.out.write(this.outputText)}};Us.exports=Tt});var Qs=c((ed,Xs)=>{"use strict";var Be=_(),El=J(),zs=D(),Js=zs.style,ql=zs.clear,Zs=x(),Ks=Zs.cursor,Tl=Zs.erase,kt=class extends El{constructor(e={}){super(e),this.msg=e.message,this.value=!!e.initial,this.active=e.active||"on",this.inactive=e.inactive||"off",this.initialValue=this.value,this.render()}reset(){this.value=this.initialValue,this.fire(),this.render()}exit(){this.abort()}abort(){this.done=this.aborted=!0,this.fire(),this.render(),this.out.write(`
36
36
  `),this.close()}submit(){this.done=!0,this.aborted=!1,this.fire(),this.render(),this.out.write(`
37
- `),this.close()}deactivate(){if(this.value===!1)return this.bell();this.value=!1,this.render()}activate(){if(this.value===!0)return this.bell();this.value=!0,this.render()}delete(){this.deactivate()}left(){this.deactivate()}right(){this.activate()}down(){this.deactivate()}up(){this.activate()}next(){this.value=!this.value,this.fire(),this.render()}_(e,t){if(e===" ")this.value=!this.value;else if(e==="1")this.value=!0;else if(e==="0")this.value=!1;else return this.bell();this.render()}render(){this.closed||(this.firstRender?this.out.write(Js.hide):this.out.write(El(this.outputText,this.out.columns)),super.render(),this.outputText=[Ws.symbol(this.done,this.aborted),Ye.bold(this.msg),Ws.delimiter(this.done),this.value?this.inactive:Ye.cyan().underline(this.inactive),Ye.gray("/"),this.value?Ye.cyan().underline(this.active):this.active].join(" "),this.out.write(ql.line+Js.to(0)+this.outputText))}};Zs.exports=Mt});var F=c((ed,Qs)=>{"use strict";var It=class i{constructor({token:e,date:t,parts:s,locales:r}){this.token=e,this.date=t||new Date,this.parts=s||[this],this.locales=r||{}}up(){}down(){}next(){let e=this.parts.indexOf(this);return this.parts.find((t,s)=>s>e&&t instanceof i)}setTo(e){}prev(){let e=[].concat(this.parts).reverse(),t=e.indexOf(this);return e.find((s,r)=>r>t&&s instanceof i)}toString(){return String(this.date)}};Qs.exports=It});var tr=c((td,er)=>{"use strict";var Tl=F(),Dt=class extends Tl{constructor(e={}){super(e)}up(){this.date.setHours((this.date.getHours()+12)%24)}down(){this.up()}toString(){let e=this.date.getHours()>12?"pm":"am";return/\A/.test(this.token)?e.toUpperCase():e}};er.exports=Dt});var sr=c((id,ir)=>{"use strict";var kl=F(),Ml=i=>(i=i%10,i===1?"st":i===2?"nd":i===3?"rd":"th"),jt=class extends kl{constructor(e={}){super(e)}up(){this.date.setDate(this.date.getDate()+1)}down(){this.date.setDate(this.date.getDate()-1)}setTo(e){this.date.setDate(parseInt(e.substr(-2)))}toString(){let e=this.date.getDate(),t=this.date.getDay();return this.token==="DD"?String(e).padStart(2,"0"):this.token==="Do"?e+Ml(e):this.token==="d"?t+1:this.token==="ddd"?this.locales.weekdaysShort[t]:this.token==="dddd"?this.locales.weekdays[t]:e}};ir.exports=jt});var nr=c((sd,rr)=>{"use strict";var Il=F(),Vt=class extends Il{constructor(e={}){super(e)}up(){this.date.setHours(this.date.getHours()+1)}down(){this.date.setHours(this.date.getHours()-1)}setTo(e){this.date.setHours(parseInt(e.substr(-2)))}toString(){let e=this.date.getHours();return/h/.test(this.token)&&(e=e%12||12),this.token.length>1?String(e).padStart(2,"0"):e}};rr.exports=Vt});var ar=c((rd,or)=>{"use strict";var Dl=F(),Ht=class extends Dl{constructor(e={}){super(e)}up(){this.date.setMilliseconds(this.date.getMilliseconds()+1)}down(){this.date.setMilliseconds(this.date.getMilliseconds()-1)}setTo(e){this.date.setMilliseconds(parseInt(e.substr(-this.token.length)))}toString(){return String(this.date.getMilliseconds()).padStart(4,"0").substr(0,this.token.length)}};or.exports=Ht});var hr=c((nd,lr)=>{"use strict";var jl=F(),Ft=class extends jl{constructor(e={}){super(e)}up(){this.date.setMinutes(this.date.getMinutes()+1)}down(){this.date.setMinutes(this.date.getMinutes()-1)}setTo(e){this.date.setMinutes(parseInt(e.substr(-2)))}toString(){let e=this.date.getMinutes();return this.token.length>1?String(e).padStart(2,"0"):e}};lr.exports=Ft});var cr=c((od,ur)=>{"use strict";var Vl=F(),Rt=class extends Vl{constructor(e={}){super(e)}up(){this.date.setMonth(this.date.getMonth()+1)}down(){this.date.setMonth(this.date.getMonth()-1)}setTo(e){e=parseInt(e.substr(-2))-1,this.date.setMonth(e<0?0:e)}toString(){let e=this.date.getMonth(),t=this.token.length;return t===2?String(e+1).padStart(2,"0"):t===3?this.locales.monthsShort[e]:t===4?this.locales.months[e]:String(e+1)}};ur.exports=Rt});var fr=c((ad,dr)=>{"use strict";var Hl=F(),Nt=class extends Hl{constructor(e={}){super(e)}up(){this.date.setSeconds(this.date.getSeconds()+1)}down(){this.date.setSeconds(this.date.getSeconds()-1)}setTo(e){this.date.setSeconds(parseInt(e.substr(-2)))}toString(){let e=this.date.getSeconds();return this.token.length>1?String(e).padStart(2,"0"):e}};dr.exports=Nt});var mr=c((ld,pr)=>{"use strict";var Fl=F(),Lt=class extends Fl{constructor(e={}){super(e)}up(){this.date.setFullYear(this.date.getFullYear()+1)}down(){this.date.setFullYear(this.date.getFullYear()-1)}setTo(e){this.date.setFullYear(e.substr(-4))}toString(){let e=String(this.date.getFullYear()).padStart(4,"0");return this.token.length===2?e.substr(-2):e}};pr.exports=Lt});var br=c((hd,gr)=>{"use strict";gr.exports={DatePart:F(),Meridiem:tr(),Day:sr(),Hours:nr(),Milliseconds:ar(),Minutes:hr(),Month:cr(),Seconds:fr(),Year:mr()}});var Ar=c((ud,$r)=>{"use strict";function wr(i,e,t,s,r,n,o){try{var a=i[n](o),l=a.value}catch(h){t(h);return}a.done?e(l):Promise.resolve(l).then(s,r)}function yr(i){return function(){var e=this,t=arguments;return new Promise(function(s,r){var n=i.apply(e,t);function o(l){wr(n,s,r,o,a,"next",l)}function a(l){wr(n,s,r,o,a,"throw",l)}o(void 0)})}}var Gt=_(),Rl=J(),Yt=D(),_r=Yt.style,vr=Yt.clear,Nl=Yt.figures,Sr=x(),Ll=Sr.erase,xr=Sr.cursor,z=br(),Cr=z.DatePart,Gl=z.Meridiem,Bl=z.Day,Yl=z.Hours,Ul=z.Milliseconds,Wl=z.Minutes,Jl=z.Month,Kl=z.Seconds,zl=z.Year,Zl=/\\(.)|"((?:\\["\\]|[^"])+)"|(D[Do]?|d{3,4}|d)|(M{1,4})|(YY(?:YY)?)|([aA])|([Hh]{1,2})|(m{1,2})|(s{1,2})|(S{1,4})|./g,Or={1:({token:i})=>i.replace(/\\(.)/g,"$1"),2:i=>new Bl(i),3:i=>new Jl(i),4:i=>new zl(i),5:i=>new Gl(i),6:i=>new Yl(i),7:i=>new Wl(i),8:i=>new Kl(i),9:i=>new Ul(i)},Xl={months:"January,February,March,April,May,June,July,August,September,October,November,December".split(","),monthsShort:"Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec".split(","),weekdays:"Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday".split(","),weekdaysShort:"Sun,Mon,Tue,Wed,Thu,Fri,Sat".split(",")},Bt=class extends Rl{constructor(e={}){super(e),this.msg=e.message,this.cursor=0,this.typed="",this.locales=Object.assign(Xl,e.locales),this._date=e.initial||new Date,this.errorMsg=e.error||"Please Enter A Valid Value",this.validator=e.validate||(()=>!0),this.mask=e.mask||"YYYY-MM-DD HH:mm:ss",this.clear=vr("",this.out.columns),this.render()}get value(){return this.date}get date(){return this._date}set date(e){e&&this._date.setTime(e.getTime())}set mask(e){let t;for(this.parts=[];t=Zl.exec(e);){let r=t.shift(),n=t.findIndex(o=>o!=null);this.parts.push(n in Or?Or[n]({token:t[n]||r,date:this.date,parts:this.parts,locales:this.locales}):t[n]||r)}let s=this.parts.reduce((r,n)=>(typeof n=="string"&&typeof r[r.length-1]=="string"?r[r.length-1]+=n:r.push(n),r),[]);this.parts.splice(0),this.parts.push(...s),this.reset()}moveCursor(e){this.typed="",this.cursor=e,this.fire()}reset(){this.moveCursor(this.parts.findIndex(e=>e instanceof Cr)),this.fire(),this.render()}exit(){this.abort()}abort(){this.done=this.aborted=!0,this.error=!1,this.fire(),this.render(),this.out.write(`
38
- `),this.close()}validate(){var e=this;return yr(function*(){let t=yield e.validator(e.value);typeof t=="string"&&(e.errorMsg=t,t=!1),e.error=!t})()}submit(){var e=this;return yr(function*(){if(yield e.validate(),e.error){e.color="red",e.fire(),e.render();return}e.done=!0,e.aborted=!1,e.fire(),e.render(),e.out.write(`
39
- `),e.close()})()}up(){this.typed="",this.parts[this.cursor].up(),this.render()}down(){this.typed="",this.parts[this.cursor].down(),this.render()}left(){let e=this.parts[this.cursor].prev();if(e==null)return this.bell();this.moveCursor(this.parts.indexOf(e)),this.render()}right(){let e=this.parts[this.cursor].next();if(e==null)return this.bell();this.moveCursor(this.parts.indexOf(e)),this.render()}next(){let e=this.parts[this.cursor].next();this.moveCursor(e?this.parts.indexOf(e):this.parts.findIndex(t=>t instanceof Cr)),this.render()}_(e){/\d/.test(e)&&(this.typed+=e,this.parts[this.cursor].setTo(this.typed),this.render())}render(){this.closed||(this.firstRender?this.out.write(xr.hide):this.out.write(vr(this.outputText,this.out.columns)),super.render(),this.outputText=[_r.symbol(this.done,this.aborted),Gt.bold(this.msg),_r.delimiter(!1),this.parts.reduce((e,t,s)=>e.concat(s===this.cursor&&!this.done?Gt.cyan().underline(t.toString()):t),[]).join("")].join(" "),this.error&&(this.outputText+=this.errorMsg.split(`
37
+ `),this.close()}deactivate(){if(this.value===!1)return this.bell();this.value=!1,this.render()}activate(){if(this.value===!0)return this.bell();this.value=!0,this.render()}delete(){this.deactivate()}left(){this.deactivate()}right(){this.activate()}down(){this.deactivate()}up(){this.activate()}next(){this.value=!this.value,this.fire(),this.render()}_(e,t){if(e===" ")this.value=!this.value;else if(e==="1")this.value=!0;else if(e==="0")this.value=!1;else return this.bell();this.render()}render(){this.closed||(this.firstRender?this.out.write(Ks.hide):this.out.write(ql(this.outputText,this.out.columns)),super.render(),this.outputText=[Js.symbol(this.done,this.aborted),Be.bold(this.msg),Js.delimiter(this.done),this.value?this.inactive:Be.cyan().underline(this.inactive),Be.gray("/"),this.value?Be.cyan().underline(this.active):this.active].join(" "),this.out.write(Tl.line+Ks.to(0)+this.outputText))}};Xs.exports=kt});var F=c((td,er)=>{"use strict";var Mt=class i{constructor({token:e,date:t,parts:s,locales:r}){this.token=e,this.date=t||new Date,this.parts=s||[this],this.locales=r||{}}up(){}down(){}next(){let e=this.parts.indexOf(this);return this.parts.find((t,s)=>s>e&&t instanceof i)}setTo(e){}prev(){let e=[].concat(this.parts).reverse(),t=e.indexOf(this);return e.find((s,r)=>r>t&&s instanceof i)}toString(){return String(this.date)}};er.exports=Mt});var ir=c((id,tr)=>{"use strict";var kl=F(),It=class extends kl{constructor(e={}){super(e)}up(){this.date.setHours((this.date.getHours()+12)%24)}down(){this.up()}toString(){let e=this.date.getHours()>12?"pm":"am";return/\A/.test(this.token)?e.toUpperCase():e}};tr.exports=It});var rr=c((sd,sr)=>{"use strict";var Ml=F(),Il=i=>(i=i%10,i===1?"st":i===2?"nd":i===3?"rd":"th"),Dt=class extends Ml{constructor(e={}){super(e)}up(){this.date.setDate(this.date.getDate()+1)}down(){this.date.setDate(this.date.getDate()-1)}setTo(e){this.date.setDate(parseInt(e.substr(-2)))}toString(){let e=this.date.getDate(),t=this.date.getDay();return this.token==="DD"?String(e).padStart(2,"0"):this.token==="Do"?e+Il(e):this.token==="d"?t+1:this.token==="ddd"?this.locales.weekdaysShort[t]:this.token==="dddd"?this.locales.weekdays[t]:e}};sr.exports=Dt});var or=c((rd,nr)=>{"use strict";var Dl=F(),jt=class extends Dl{constructor(e={}){super(e)}up(){this.date.setHours(this.date.getHours()+1)}down(){this.date.setHours(this.date.getHours()-1)}setTo(e){this.date.setHours(parseInt(e.substr(-2)))}toString(){let e=this.date.getHours();return/h/.test(this.token)&&(e=e%12||12),this.token.length>1?String(e).padStart(2,"0"):e}};nr.exports=jt});var lr=c((nd,ar)=>{"use strict";var jl=F(),Vt=class extends jl{constructor(e={}){super(e)}up(){this.date.setMilliseconds(this.date.getMilliseconds()+1)}down(){this.date.setMilliseconds(this.date.getMilliseconds()-1)}setTo(e){this.date.setMilliseconds(parseInt(e.substr(-this.token.length)))}toString(){return String(this.date.getMilliseconds()).padStart(4,"0").substr(0,this.token.length)}};ar.exports=Vt});var ur=c((od,hr)=>{"use strict";var Vl=F(),Ht=class extends Vl{constructor(e={}){super(e)}up(){this.date.setMinutes(this.date.getMinutes()+1)}down(){this.date.setMinutes(this.date.getMinutes()-1)}setTo(e){this.date.setMinutes(parseInt(e.substr(-2)))}toString(){let e=this.date.getMinutes();return this.token.length>1?String(e).padStart(2,"0"):e}};hr.exports=Ht});var dr=c((ad,cr)=>{"use strict";var Hl=F(),Ft=class extends Hl{constructor(e={}){super(e)}up(){this.date.setMonth(this.date.getMonth()+1)}down(){this.date.setMonth(this.date.getMonth()-1)}setTo(e){e=parseInt(e.substr(-2))-1,this.date.setMonth(e<0?0:e)}toString(){let e=this.date.getMonth(),t=this.token.length;return t===2?String(e+1).padStart(2,"0"):t===3?this.locales.monthsShort[e]:t===4?this.locales.months[e]:String(e+1)}};cr.exports=Ft});var pr=c((ld,fr)=>{"use strict";var Fl=F(),Rt=class extends Fl{constructor(e={}){super(e)}up(){this.date.setSeconds(this.date.getSeconds()+1)}down(){this.date.setSeconds(this.date.getSeconds()-1)}setTo(e){this.date.setSeconds(parseInt(e.substr(-2)))}toString(){let e=this.date.getSeconds();return this.token.length>1?String(e).padStart(2,"0"):e}};fr.exports=Rt});var gr=c((hd,mr)=>{"use strict";var Rl=F(),Nt=class extends Rl{constructor(e={}){super(e)}up(){this.date.setFullYear(this.date.getFullYear()+1)}down(){this.date.setFullYear(this.date.getFullYear()-1)}setTo(e){this.date.setFullYear(e.substr(-4))}toString(){let e=String(this.date.getFullYear()).padStart(4,"0");return this.token.length===2?e.substr(-2):e}};mr.exports=Nt});var wr=c((ud,br)=>{"use strict";br.exports={DatePart:F(),Meridiem:ir(),Day:rr(),Hours:or(),Milliseconds:lr(),Minutes:ur(),Month:dr(),Seconds:pr(),Year:gr()}});var Pr=c((cd,Ar)=>{"use strict";function yr(i,e,t,s,r,n,o){try{var a=i[n](o),l=a.value}catch(h){t(h);return}a.done?e(l):Promise.resolve(l).then(s,r)}function _r(i){return function(){var e=this,t=arguments;return new Promise(function(s,r){var n=i.apply(e,t);function o(l){yr(n,s,r,o,a,"next",l)}function a(l){yr(n,s,r,o,a,"throw",l)}o(void 0)})}}var Lt=_(),Nl=J(),Bt=D(),vr=Bt.style,xr=Bt.clear,Ll=Bt.figures,$r=x(),Gl=$r.erase,Cr=$r.cursor,z=wr(),Or=z.DatePart,Bl=z.Meridiem,Yl=z.Day,Ul=z.Hours,Wl=z.Milliseconds,Jl=z.Minutes,Kl=z.Month,zl=z.Seconds,Zl=z.Year,Xl=/\\(.)|"((?:\\["\\]|[^"])+)"|(D[Do]?|d{3,4}|d)|(M{1,4})|(YY(?:YY)?)|([aA])|([Hh]{1,2})|(m{1,2})|(s{1,2})|(S{1,4})|./g,Sr={1:({token:i})=>i.replace(/\\(.)/g,"$1"),2:i=>new Yl(i),3:i=>new Kl(i),4:i=>new Zl(i),5:i=>new Bl(i),6:i=>new Ul(i),7:i=>new Jl(i),8:i=>new zl(i),9:i=>new Wl(i)},Ql={months:"January,February,March,April,May,June,July,August,September,October,November,December".split(","),monthsShort:"Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec".split(","),weekdays:"Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday".split(","),weekdaysShort:"Sun,Mon,Tue,Wed,Thu,Fri,Sat".split(",")},Gt=class extends Nl{constructor(e={}){super(e),this.msg=e.message,this.cursor=0,this.typed="",this.locales=Object.assign(Ql,e.locales),this._date=e.initial||new Date,this.errorMsg=e.error||"Please Enter A Valid Value",this.validator=e.validate||(()=>!0),this.mask=e.mask||"YYYY-MM-DD HH:mm:ss",this.clear=xr("",this.out.columns),this.render()}get value(){return this.date}get date(){return this._date}set date(e){e&&this._date.setTime(e.getTime())}set mask(e){let t;for(this.parts=[];t=Xl.exec(e);){let r=t.shift(),n=t.findIndex(o=>o!=null);this.parts.push(n in Sr?Sr[n]({token:t[n]||r,date:this.date,parts:this.parts,locales:this.locales}):t[n]||r)}let s=this.parts.reduce((r,n)=>(typeof n=="string"&&typeof r[r.length-1]=="string"?r[r.length-1]+=n:r.push(n),r),[]);this.parts.splice(0),this.parts.push(...s),this.reset()}moveCursor(e){this.typed="",this.cursor=e,this.fire()}reset(){this.moveCursor(this.parts.findIndex(e=>e instanceof Or)),this.fire(),this.render()}exit(){this.abort()}abort(){this.done=this.aborted=!0,this.error=!1,this.fire(),this.render(),this.out.write(`
38
+ `),this.close()}validate(){var e=this;return _r(function*(){let t=yield e.validator(e.value);typeof t=="string"&&(e.errorMsg=t,t=!1),e.error=!t})()}submit(){var e=this;return _r(function*(){if(yield e.validate(),e.error){e.color="red",e.fire(),e.render();return}e.done=!0,e.aborted=!1,e.fire(),e.render(),e.out.write(`
39
+ `),e.close()})()}up(){this.typed="",this.parts[this.cursor].up(),this.render()}down(){this.typed="",this.parts[this.cursor].down(),this.render()}left(){let e=this.parts[this.cursor].prev();if(e==null)return this.bell();this.moveCursor(this.parts.indexOf(e)),this.render()}right(){let e=this.parts[this.cursor].next();if(e==null)return this.bell();this.moveCursor(this.parts.indexOf(e)),this.render()}next(){let e=this.parts[this.cursor].next();this.moveCursor(e?this.parts.indexOf(e):this.parts.findIndex(t=>t instanceof Or)),this.render()}_(e){/\d/.test(e)&&(this.typed+=e,this.parts[this.cursor].setTo(this.typed),this.render())}render(){this.closed||(this.firstRender?this.out.write(Cr.hide):this.out.write(xr(this.outputText,this.out.columns)),super.render(),this.outputText=[vr.symbol(this.done,this.aborted),Lt.bold(this.msg),vr.delimiter(!1),this.parts.reduce((e,t,s)=>e.concat(s===this.cursor&&!this.done?Lt.cyan().underline(t.toString()):t),[]).join("")].join(" "),this.error&&(this.outputText+=this.errorMsg.split(`
40
40
  `).reduce((e,t,s)=>e+`
41
- ${s?" ":Nl.pointerSmall} ${Gt.red().italic(t)}`,"")),this.out.write(Ll.line+xr.to(0)+this.outputText))}};$r.exports=Bt});var Ir=c((cd,Mr)=>{"use strict";function Pr(i,e,t,s,r,n,o){try{var a=i[n](o),l=a.value}catch(h){t(h);return}a.done?e(l):Promise.resolve(l).then(s,r)}function Er(i){return function(){var e=this,t=arguments;return new Promise(function(s,r){var n=i.apply(e,t);function o(l){Pr(n,s,r,o,a,"next",l)}function a(l){Pr(n,s,r,o,a,"throw",l)}o(void 0)})}}var Ue=_(),Ql=J(),kr=x(),We=kr.cursor,eh=kr.erase,Je=D(),Ut=Je.style,th=Je.figures,qr=Je.clear,ih=Je.lines,sh=/[0-9]/,Wt=i=>i!==void 0,Tr=(i,e)=>{let t=Math.pow(10,e);return Math.round(i*t)/t},Jt=class extends Ql{constructor(e={}){super(e),this.transform=Ut.render(e.style),this.msg=e.message,this.initial=Wt(e.initial)?e.initial:"",this.float=!!e.float,this.round=e.round||2,this.inc=e.increment||1,this.min=Wt(e.min)?e.min:-1/0,this.max=Wt(e.max)?e.max:1/0,this.errorMsg=e.error||"Please Enter A Valid Value",this.validator=e.validate||(()=>!0),this.color="cyan",this.value="",this.typed="",this.lastHit=0,this.render()}set value(e){!e&&e!==0?(this.placeholder=!0,this.rendered=Ue.gray(this.transform.render(`${this.initial}`)),this._value=""):(this.placeholder=!1,this.rendered=this.transform.render(`${Tr(e,this.round)}`),this._value=Tr(e,this.round)),this.fire()}get value(){return this._value}parse(e){return this.float?parseFloat(e):parseInt(e)}valid(e){return e==="-"||e==="."&&this.float||sh.test(e)}reset(){this.typed="",this.value="",this.fire(),this.render()}exit(){this.abort()}abort(){let e=this.value;this.value=e!==""?e:this.initial,this.done=this.aborted=!0,this.error=!1,this.fire(),this.render(),this.out.write(`
42
- `),this.close()}validate(){var e=this;return Er(function*(){let t=yield e.validator(e.value);typeof t=="string"&&(e.errorMsg=t,t=!1),e.error=!t})()}submit(){var e=this;return Er(function*(){if(yield e.validate(),e.error){e.color="red",e.fire(),e.render();return}let t=e.value;e.value=t!==""?t:e.initial,e.done=!0,e.aborted=!1,e.error=!1,e.fire(),e.render(),e.out.write(`
43
- `),e.close()})()}up(){if(this.typed="",this.value===""&&(this.value=this.min-this.inc),this.value>=this.max)return this.bell();this.value+=this.inc,this.color="cyan",this.fire(),this.render()}down(){if(this.typed="",this.value===""&&(this.value=this.min+this.inc),this.value<=this.min)return this.bell();this.value-=this.inc,this.color="cyan",this.fire(),this.render()}delete(){let e=this.value.toString();if(e.length===0)return this.bell();this.value=this.parse(e=e.slice(0,-1))||"",this.value!==""&&this.value<this.min&&(this.value=this.min),this.color="cyan",this.fire(),this.render()}next(){this.value=this.initial,this.fire(),this.render()}_(e,t){if(!this.valid(e))return this.bell();let s=Date.now();if(s-this.lastHit>1e3&&(this.typed=""),this.typed+=e,this.lastHit=s,this.color="cyan",e===".")return this.fire();this.value=Math.min(this.parse(this.typed),this.max),this.value>this.max&&(this.value=this.max),this.value<this.min&&(this.value=this.min),this.fire(),this.render()}render(){this.closed||(this.firstRender||(this.outputError&&this.out.write(We.down(ih(this.outputError,this.out.columns)-1)+qr(this.outputError,this.out.columns)),this.out.write(qr(this.outputText,this.out.columns))),super.render(),this.outputError="",this.outputText=[Ut.symbol(this.done,this.aborted),Ue.bold(this.msg),Ut.delimiter(this.done),!this.done||!this.done&&!this.placeholder?Ue[this.color]().underline(this.rendered):this.rendered].join(" "),this.error&&(this.outputError+=this.errorMsg.split(`
41
+ ${s?" ":Ll.pointerSmall} ${Lt.red().italic(t)}`,"")),this.out.write(Gl.line+Cr.to(0)+this.outputText))}};Ar.exports=Gt});var Dr=c((dd,Ir)=>{"use strict";function Er(i,e,t,s,r,n,o){try{var a=i[n](o),l=a.value}catch(h){t(h);return}a.done?e(l):Promise.resolve(l).then(s,r)}function qr(i){return function(){var e=this,t=arguments;return new Promise(function(s,r){var n=i.apply(e,t);function o(l){Er(n,s,r,o,a,"next",l)}function a(l){Er(n,s,r,o,a,"throw",l)}o(void 0)})}}var Ye=_(),eh=J(),Mr=x(),Ue=Mr.cursor,th=Mr.erase,We=D(),Yt=We.style,ih=We.figures,Tr=We.clear,sh=We.lines,rh=/[0-9]/,Ut=i=>i!==void 0,kr=(i,e)=>{let t=Math.pow(10,e);return Math.round(i*t)/t},Wt=class extends eh{constructor(e={}){super(e),this.transform=Yt.render(e.style),this.msg=e.message,this.initial=Ut(e.initial)?e.initial:"",this.float=!!e.float,this.round=e.round||2,this.inc=e.increment||1,this.min=Ut(e.min)?e.min:-1/0,this.max=Ut(e.max)?e.max:1/0,this.errorMsg=e.error||"Please Enter A Valid Value",this.validator=e.validate||(()=>!0),this.color="cyan",this.value="",this.typed="",this.lastHit=0,this.render()}set value(e){!e&&e!==0?(this.placeholder=!0,this.rendered=Ye.gray(this.transform.render(`${this.initial}`)),this._value=""):(this.placeholder=!1,this.rendered=this.transform.render(`${kr(e,this.round)}`),this._value=kr(e,this.round)),this.fire()}get value(){return this._value}parse(e){return this.float?parseFloat(e):parseInt(e)}valid(e){return e==="-"||e==="."&&this.float||rh.test(e)}reset(){this.typed="",this.value="",this.fire(),this.render()}exit(){this.abort()}abort(){let e=this.value;this.value=e!==""?e:this.initial,this.done=this.aborted=!0,this.error=!1,this.fire(),this.render(),this.out.write(`
42
+ `),this.close()}validate(){var e=this;return qr(function*(){let t=yield e.validator(e.value);typeof t=="string"&&(e.errorMsg=t,t=!1),e.error=!t})()}submit(){var e=this;return qr(function*(){if(yield e.validate(),e.error){e.color="red",e.fire(),e.render();return}let t=e.value;e.value=t!==""?t:e.initial,e.done=!0,e.aborted=!1,e.error=!1,e.fire(),e.render(),e.out.write(`
43
+ `),e.close()})()}up(){if(this.typed="",this.value===""&&(this.value=this.min-this.inc),this.value>=this.max)return this.bell();this.value+=this.inc,this.color="cyan",this.fire(),this.render()}down(){if(this.typed="",this.value===""&&(this.value=this.min+this.inc),this.value<=this.min)return this.bell();this.value-=this.inc,this.color="cyan",this.fire(),this.render()}delete(){let e=this.value.toString();if(e.length===0)return this.bell();this.value=this.parse(e=e.slice(0,-1))||"",this.value!==""&&this.value<this.min&&(this.value=this.min),this.color="cyan",this.fire(),this.render()}next(){this.value=this.initial,this.fire(),this.render()}_(e,t){if(!this.valid(e))return this.bell();let s=Date.now();if(s-this.lastHit>1e3&&(this.typed=""),this.typed+=e,this.lastHit=s,this.color="cyan",e===".")return this.fire();this.value=Math.min(this.parse(this.typed),this.max),this.value>this.max&&(this.value=this.max),this.value<this.min&&(this.value=this.min),this.fire(),this.render()}render(){this.closed||(this.firstRender||(this.outputError&&this.out.write(Ue.down(sh(this.outputError,this.out.columns)-1)+Tr(this.outputError,this.out.columns)),this.out.write(Tr(this.outputText,this.out.columns))),super.render(),this.outputError="",this.outputText=[Yt.symbol(this.done,this.aborted),Ye.bold(this.msg),Yt.delimiter(this.done),!this.done||!this.done&&!this.placeholder?Ye[this.color]().underline(this.rendered):this.rendered].join(" "),this.error&&(this.outputError+=this.errorMsg.split(`
44
44
  `).reduce((e,t,s)=>e+`
45
- ${s?" ":th.pointerSmall} ${Ue.red().italic(t)}`,"")),this.out.write(eh.line+We.to(0)+this.outputText+We.save+this.outputError+We.restore))}};Mr.exports=Jt});var zt=c((dd,Vr)=>{"use strict";var R=_(),rh=x(),nh=rh.cursor,oh=J(),Pe=D(),Dr=Pe.clear,re=Pe.figures,jr=Pe.style,ah=Pe.wrap,lh=Pe.entriesToDisplay,Kt=class extends oh{constructor(e={}){super(e),this.msg=e.message,this.cursor=e.cursor||0,this.scrollIndex=e.cursor||0,this.hint=e.hint||"",this.warn=e.warn||"- This option is disabled -",this.minSelected=e.min,this.showMinError=!1,this.maxChoices=e.max,this.instructions=e.instructions,this.optionsPerPage=e.optionsPerPage||10,this.value=e.choices.map((t,s)=>(typeof t=="string"&&(t={title:t,value:s}),{title:t&&(t.title||t.value||t),description:t&&t.description,value:t&&(t.value===void 0?s:t.value),selected:t&&t.selected,disabled:t&&t.disabled})),this.clear=Dr("",this.out.columns),e.overrideRender||this.render()}reset(){this.value.map(e=>!e.selected),this.cursor=0,this.fire(),this.render()}selected(){return this.value.filter(e=>e.selected)}exit(){this.abort()}abort(){this.done=this.aborted=!0,this.fire(),this.render(),this.out.write(`
45
+ ${s?" ":ih.pointerSmall} ${Ye.red().italic(t)}`,"")),this.out.write(th.line+Ue.to(0)+this.outputText+Ue.save+this.outputError+Ue.restore))}};Ir.exports=Wt});var Kt=c((fd,Hr)=>{"use strict";var R=_(),nh=x(),oh=nh.cursor,ah=J(),Ae=D(),jr=Ae.clear,re=Ae.figures,Vr=Ae.style,lh=Ae.wrap,hh=Ae.entriesToDisplay,Jt=class extends ah{constructor(e={}){super(e),this.msg=e.message,this.cursor=e.cursor||0,this.scrollIndex=e.cursor||0,this.hint=e.hint||"",this.warn=e.warn||"- This option is disabled -",this.minSelected=e.min,this.showMinError=!1,this.maxChoices=e.max,this.instructions=e.instructions,this.optionsPerPage=e.optionsPerPage||10,this.value=e.choices.map((t,s)=>(typeof t=="string"&&(t={title:t,value:s}),{title:t&&(t.title||t.value||t),description:t&&t.description,value:t&&(t.value===void 0?s:t.value),selected:t&&t.selected,disabled:t&&t.disabled})),this.clear=jr("",this.out.columns),e.overrideRender||this.render()}reset(){this.value.map(e=>!e.selected),this.cursor=0,this.fire(),this.render()}selected(){return this.value.filter(e=>e.selected)}exit(){this.abort()}abort(){this.done=this.aborted=!0,this.fire(),this.render(),this.out.write(`
46
46
  `),this.close()}submit(){let e=this.value.filter(t=>t.selected);this.minSelected&&e.length<this.minSelected?(this.showMinError=!0,this.render()):(this.done=!0,this.aborted=!1,this.fire(),this.render(),this.out.write(`
47
47
  `),this.close())}first(){this.cursor=0,this.render()}last(){this.cursor=this.value.length-1,this.render()}next(){this.cursor=(this.cursor+1)%this.value.length,this.render()}up(){this.cursor===0?this.cursor=this.value.length-1:this.cursor--,this.render()}down(){this.cursor===this.value.length-1?this.cursor=0:this.cursor++,this.render()}left(){this.value[this.cursor].selected=!1,this.render()}right(){if(this.value.filter(e=>e.selected).length>=this.maxChoices)return this.bell();this.value[this.cursor].selected=!0,this.render()}handleSpaceToggle(){let e=this.value[this.cursor];if(e.selected)e.selected=!1,this.render();else{if(e.disabled||this.value.filter(t=>t.selected).length>=this.maxChoices)return this.bell();e.selected=!0,this.render()}}toggleAll(){if(this.maxChoices!==void 0||this.value[this.cursor].disabled)return this.bell();let e=!this.value[this.cursor].selected;this.value.filter(t=>!t.disabled).forEach(t=>t.selected=e),this.render()}_(e,t){if(e===" ")this.handleSpaceToggle();else if(e==="a")this.toggleAll();else return this.bell()}renderInstructions(){return this.instructions===void 0||this.instructions?typeof this.instructions=="string"?this.instructions:`
48
48
  Instructions:
@@ -50,47 +50,47 @@ Instructions:
50
50
  ${re.arrowLeft}/${re.arrowRight}/[space]: Toggle selection
51
51
  `+(this.maxChoices===void 0?` a: Toggle all
52
52
  `:"")+" enter/return: Complete answer":""}renderOption(e,t,s,r){let n=(t.selected?R.green(re.radioOn):re.radioOff)+" "+r+" ",o,a;return t.disabled?o=e===s?R.gray().underline(t.title):R.strikethrough().gray(t.title):(o=e===s?R.cyan().underline(t.title):t.title,e===s&&t.description&&(a=` - ${t.description}`,(n.length+o.length+a.length>=this.out.columns||t.description.split(/\r?\n/).length>1)&&(a=`
53
- `+ah(t.description,{margin:n.length,width:this.out.columns})))),n+o+R.gray(a||"")}paginateOptions(e){if(e.length===0)return R.red("No matches for this query.");let t=lh(this.cursor,e.length,this.optionsPerPage),s=t.startIndex,r=t.endIndex,n,o=[];for(let a=s;a<r;a++)a===s&&s>0?n=re.arrowUp:a===r-1&&r<e.length?n=re.arrowDown:n=" ",o.push(this.renderOption(this.cursor,e[a],a,n));return`
53
+ `+lh(t.description,{margin:n.length,width:this.out.columns})))),n+o+R.gray(a||"")}paginateOptions(e){if(e.length===0)return R.red("No matches for this query.");let t=hh(this.cursor,e.length,this.optionsPerPage),s=t.startIndex,r=t.endIndex,n,o=[];for(let a=s;a<r;a++)a===s&&s>0?n=re.arrowUp:a===r-1&&r<e.length?n=re.arrowDown:n=" ",o.push(this.renderOption(this.cursor,e[a],a,n));return`
54
54
  `+o.join(`
55
- `)}renderOptions(e){return this.done?"":this.paginateOptions(e)}renderDoneOrInstructions(){if(this.done)return this.value.filter(t=>t.selected).map(t=>t.title).join(", ");let e=[R.gray(this.hint),this.renderInstructions()];return this.value[this.cursor].disabled&&e.push(R.yellow(this.warn)),e.join(" ")}render(){if(this.closed)return;this.firstRender&&this.out.write(nh.hide),super.render();let e=[jr.symbol(this.done,this.aborted),R.bold(this.msg),jr.delimiter(!1),this.renderDoneOrInstructions()].join(" ");this.showMinError&&(e+=R.red(`You must select a minimum of ${this.minSelected} choices.`),this.showMinError=!1),e+=this.renderOptions(this.value),this.out.write(this.clear+e),this.clear=Dr(e,this.out.columns)}};Vr.exports=Kt});var Br=c((fd,Gr)=>{"use strict";function Hr(i,e,t,s,r,n,o){try{var a=i[n](o),l=a.value}catch(h){t(h);return}a.done?e(l):Promise.resolve(l).then(s,r)}function hh(i){return function(){var e=this,t=arguments;return new Promise(function(s,r){var n=i.apply(e,t);function o(l){Hr(n,s,r,o,a,"next",l)}function a(l){Hr(n,s,r,o,a,"throw",l)}o(void 0)})}}var Ee=_(),uh=J(),Lr=x(),ch=Lr.erase,Fr=Lr.cursor,qe=D(),Zt=qe.style,Rr=qe.clear,Xt=qe.figures,dh=qe.wrap,fh=qe.entriesToDisplay,Nr=(i,e)=>i[e]&&(i[e].value||i[e].title||i[e]),ph=(i,e)=>i[e]&&(i[e].title||i[e].value||i[e]),mh=(i,e)=>{let t=i.findIndex(s=>s.value===e||s.title===e);return t>-1?t:void 0},Qt=class extends uh{constructor(e={}){super(e),this.msg=e.message,this.suggest=e.suggest,this.choices=e.choices,this.initial=typeof e.initial=="number"?e.initial:mh(e.choices,e.initial),this.select=this.initial||e.cursor||0,this.i18n={noMatches:e.noMatches||"no matches found"},this.fallback=e.fallback||this.initial,this.clearFirst=e.clearFirst||!1,this.suggestions=[],this.input="",this.limit=e.limit||10,this.cursor=0,this.transform=Zt.render(e.style),this.scale=this.transform.scale,this.render=this.render.bind(this),this.complete=this.complete.bind(this),this.clear=Rr("",this.out.columns),this.complete(this.render),this.render()}set fallback(e){this._fb=Number.isSafeInteger(parseInt(e))?parseInt(e):e}get fallback(){let e;return typeof this._fb=="number"?e=this.choices[this._fb]:typeof this._fb=="string"&&(e={title:this._fb}),e||this._fb||{title:this.i18n.noMatches}}moveSelect(e){this.select=e,this.suggestions.length>0?this.value=Nr(this.suggestions,e):this.value=this.fallback.value,this.fire()}complete(e){var t=this;return hh(function*(){let s=t.completing=t.suggest(t.input,t.choices),r=yield s;if(t.completing!==s)return;t.suggestions=r.map((o,a,l)=>({title:ph(l,a),value:Nr(l,a),description:o.description})),t.completing=!1;let n=Math.max(r.length-1,0);t.moveSelect(Math.min(n,t.select)),e&&e()})()}reset(){this.input="",this.complete(()=>{this.moveSelect(this.initial!==void 0?this.initial:0),this.render()}),this.render()}exit(){this.clearFirst&&this.input.length>0?this.reset():(this.done=this.exited=!0,this.aborted=!1,this.fire(),this.render(),this.out.write(`
55
+ `)}renderOptions(e){return this.done?"":this.paginateOptions(e)}renderDoneOrInstructions(){if(this.done)return this.value.filter(t=>t.selected).map(t=>t.title).join(", ");let e=[R.gray(this.hint),this.renderInstructions()];return this.value[this.cursor].disabled&&e.push(R.yellow(this.warn)),e.join(" ")}render(){if(this.closed)return;this.firstRender&&this.out.write(oh.hide),super.render();let e=[Vr.symbol(this.done,this.aborted),R.bold(this.msg),Vr.delimiter(!1),this.renderDoneOrInstructions()].join(" ");this.showMinError&&(e+=R.red(`You must select a minimum of ${this.minSelected} choices.`),this.showMinError=!1),e+=this.renderOptions(this.value),this.out.write(this.clear+e),this.clear=jr(e,this.out.columns)}};Hr.exports=Jt});var Yr=c((pd,Br)=>{"use strict";function Fr(i,e,t,s,r,n,o){try{var a=i[n](o),l=a.value}catch(h){t(h);return}a.done?e(l):Promise.resolve(l).then(s,r)}function uh(i){return function(){var e=this,t=arguments;return new Promise(function(s,r){var n=i.apply(e,t);function o(l){Fr(n,s,r,o,a,"next",l)}function a(l){Fr(n,s,r,o,a,"throw",l)}o(void 0)})}}var Pe=_(),ch=J(),Gr=x(),dh=Gr.erase,Rr=Gr.cursor,Ee=D(),zt=Ee.style,Nr=Ee.clear,Zt=Ee.figures,fh=Ee.wrap,ph=Ee.entriesToDisplay,Lr=(i,e)=>i[e]&&(i[e].value||i[e].title||i[e]),mh=(i,e)=>i[e]&&(i[e].title||i[e].value||i[e]),gh=(i,e)=>{let t=i.findIndex(s=>s.value===e||s.title===e);return t>-1?t:void 0},Xt=class extends ch{constructor(e={}){super(e),this.msg=e.message,this.suggest=e.suggest,this.choices=e.choices,this.initial=typeof e.initial=="number"?e.initial:gh(e.choices,e.initial),this.select=this.initial||e.cursor||0,this.i18n={noMatches:e.noMatches||"no matches found"},this.fallback=e.fallback||this.initial,this.clearFirst=e.clearFirst||!1,this.suggestions=[],this.input="",this.limit=e.limit||10,this.cursor=0,this.transform=zt.render(e.style),this.scale=this.transform.scale,this.render=this.render.bind(this),this.complete=this.complete.bind(this),this.clear=Nr("",this.out.columns),this.complete(this.render),this.render()}set fallback(e){this._fb=Number.isSafeInteger(parseInt(e))?parseInt(e):e}get fallback(){let e;return typeof this._fb=="number"?e=this.choices[this._fb]:typeof this._fb=="string"&&(e={title:this._fb}),e||this._fb||{title:this.i18n.noMatches}}moveSelect(e){this.select=e,this.suggestions.length>0?this.value=Lr(this.suggestions,e):this.value=this.fallback.value,this.fire()}complete(e){var t=this;return uh(function*(){let s=t.completing=t.suggest(t.input,t.choices),r=yield s;if(t.completing!==s)return;t.suggestions=r.map((o,a,l)=>({title:mh(l,a),value:Lr(l,a),description:o.description})),t.completing=!1;let n=Math.max(r.length-1,0);t.moveSelect(Math.min(n,t.select)),e&&e()})()}reset(){this.input="",this.complete(()=>{this.moveSelect(this.initial!==void 0?this.initial:0),this.render()}),this.render()}exit(){this.clearFirst&&this.input.length>0?this.reset():(this.done=this.exited=!0,this.aborted=!1,this.fire(),this.render(),this.out.write(`
56
56
  `),this.close())}abort(){this.done=this.aborted=!0,this.exited=!1,this.fire(),this.render(),this.out.write(`
57
57
  `),this.close()}submit(){this.done=!0,this.aborted=this.exited=!1,this.fire(),this.render(),this.out.write(`
58
- `),this.close()}_(e,t){let s=this.input.slice(0,this.cursor),r=this.input.slice(this.cursor);this.input=`${s}${e}${r}`,this.cursor=s.length+1,this.complete(this.render),this.render()}delete(){if(this.cursor===0)return this.bell();let e=this.input.slice(0,this.cursor-1),t=this.input.slice(this.cursor);this.input=`${e}${t}`,this.complete(this.render),this.cursor=this.cursor-1,this.render()}deleteForward(){if(this.cursor*this.scale>=this.rendered.length)return this.bell();let e=this.input.slice(0,this.cursor),t=this.input.slice(this.cursor+1);this.input=`${e}${t}`,this.complete(this.render),this.render()}first(){this.moveSelect(0),this.render()}last(){this.moveSelect(this.suggestions.length-1),this.render()}up(){this.select===0?this.moveSelect(this.suggestions.length-1):this.moveSelect(this.select-1),this.render()}down(){this.select===this.suggestions.length-1?this.moveSelect(0):this.moveSelect(this.select+1),this.render()}next(){this.select===this.suggestions.length-1?this.moveSelect(0):this.moveSelect(this.select+1),this.render()}nextPage(){this.moveSelect(Math.min(this.select+this.limit,this.suggestions.length-1)),this.render()}prevPage(){this.moveSelect(Math.max(this.select-this.limit,0)),this.render()}left(){if(this.cursor<=0)return this.bell();this.cursor=this.cursor-1,this.render()}right(){if(this.cursor*this.scale>=this.rendered.length)return this.bell();this.cursor=this.cursor+1,this.render()}renderOption(e,t,s,r){let n,o=s?Xt.arrowUp:r?Xt.arrowDown:" ",a=t?Ee.cyan().underline(e.title):e.title;return o=(t?Ee.cyan(Xt.pointer)+" ":" ")+o,e.description&&(n=` - ${e.description}`,(o.length+a.length+n.length>=this.out.columns||e.description.split(/\r?\n/).length>1)&&(n=`
59
- `+dh(e.description,{margin:3,width:this.out.columns}))),o+" "+a+Ee.gray(n||"")}render(){if(this.closed)return;this.firstRender?this.out.write(Fr.hide):this.out.write(Rr(this.outputText,this.out.columns)),super.render();let e=fh(this.select,this.choices.length,this.limit),t=e.startIndex,s=e.endIndex;if(this.outputText=[Zt.symbol(this.done,this.aborted,this.exited),Ee.bold(this.msg),Zt.delimiter(this.completing),this.done&&this.suggestions[this.select]?this.suggestions[this.select].title:this.rendered=this.transform.render(this.input)].join(" "),!this.done){let r=this.suggestions.slice(t,s).map((n,o)=>this.renderOption(n,this.select===o+t,o===0&&t>0,o+t===s-1&&s<this.choices.length)).join(`
58
+ `),this.close()}_(e,t){let s=this.input.slice(0,this.cursor),r=this.input.slice(this.cursor);this.input=`${s}${e}${r}`,this.cursor=s.length+1,this.complete(this.render),this.render()}delete(){if(this.cursor===0)return this.bell();let e=this.input.slice(0,this.cursor-1),t=this.input.slice(this.cursor);this.input=`${e}${t}`,this.complete(this.render),this.cursor=this.cursor-1,this.render()}deleteForward(){if(this.cursor*this.scale>=this.rendered.length)return this.bell();let e=this.input.slice(0,this.cursor),t=this.input.slice(this.cursor+1);this.input=`${e}${t}`,this.complete(this.render),this.render()}first(){this.moveSelect(0),this.render()}last(){this.moveSelect(this.suggestions.length-1),this.render()}up(){this.select===0?this.moveSelect(this.suggestions.length-1):this.moveSelect(this.select-1),this.render()}down(){this.select===this.suggestions.length-1?this.moveSelect(0):this.moveSelect(this.select+1),this.render()}next(){this.select===this.suggestions.length-1?this.moveSelect(0):this.moveSelect(this.select+1),this.render()}nextPage(){this.moveSelect(Math.min(this.select+this.limit,this.suggestions.length-1)),this.render()}prevPage(){this.moveSelect(Math.max(this.select-this.limit,0)),this.render()}left(){if(this.cursor<=0)return this.bell();this.cursor=this.cursor-1,this.render()}right(){if(this.cursor*this.scale>=this.rendered.length)return this.bell();this.cursor=this.cursor+1,this.render()}renderOption(e,t,s,r){let n,o=s?Zt.arrowUp:r?Zt.arrowDown:" ",a=t?Pe.cyan().underline(e.title):e.title;return o=(t?Pe.cyan(Zt.pointer)+" ":" ")+o,e.description&&(n=` - ${e.description}`,(o.length+a.length+n.length>=this.out.columns||e.description.split(/\r?\n/).length>1)&&(n=`
59
+ `+fh(e.description,{margin:3,width:this.out.columns}))),o+" "+a+Pe.gray(n||"")}render(){if(this.closed)return;this.firstRender?this.out.write(Rr.hide):this.out.write(Nr(this.outputText,this.out.columns)),super.render();let e=ph(this.select,this.choices.length,this.limit),t=e.startIndex,s=e.endIndex;if(this.outputText=[zt.symbol(this.done,this.aborted,this.exited),Pe.bold(this.msg),zt.delimiter(this.completing),this.done&&this.suggestions[this.select]?this.suggestions[this.select].title:this.rendered=this.transform.render(this.input)].join(" "),!this.done){let r=this.suggestions.slice(t,s).map((n,o)=>this.renderOption(n,this.select===o+t,o===0&&t>0,o+t===s-1&&s<this.choices.length)).join(`
60
60
  `);this.outputText+=`
61
- `+(r||Ee.gray(this.fallback.title))}this.out.write(ch.line+Fr.to(0)+this.outputText)}};Gr.exports=Qt});var Jr=c((pd,Wr)=>{"use strict";var Z=_(),gh=x(),bh=gh.cursor,wh=zt(),ti=D(),Yr=ti.clear,Ur=ti.style,me=ti.figures,ei=class extends wh{constructor(e={}){e.overrideRender=!0,super(e),this.inputValue="",this.clear=Yr("",this.out.columns),this.filteredOptions=this.value,this.render()}last(){this.cursor=this.filteredOptions.length-1,this.render()}next(){this.cursor=(this.cursor+1)%this.filteredOptions.length,this.render()}up(){this.cursor===0?this.cursor=this.filteredOptions.length-1:this.cursor--,this.render()}down(){this.cursor===this.filteredOptions.length-1?this.cursor=0:this.cursor++,this.render()}left(){this.filteredOptions[this.cursor].selected=!1,this.render()}right(){if(this.value.filter(e=>e.selected).length>=this.maxChoices)return this.bell();this.filteredOptions[this.cursor].selected=!0,this.render()}delete(){this.inputValue.length&&(this.inputValue=this.inputValue.substr(0,this.inputValue.length-1),this.updateFilteredOptions())}updateFilteredOptions(){let e=this.filteredOptions[this.cursor];this.filteredOptions=this.value.filter(s=>this.inputValue?!!(typeof s.title=="string"&&s.title.toLowerCase().includes(this.inputValue.toLowerCase())||typeof s.value=="string"&&s.value.toLowerCase().includes(this.inputValue.toLowerCase())):!0);let t=this.filteredOptions.findIndex(s=>s===e);this.cursor=t<0?0:t,this.render()}handleSpaceToggle(){let e=this.filteredOptions[this.cursor];if(e.selected)e.selected=!1,this.render();else{if(e.disabled||this.value.filter(t=>t.selected).length>=this.maxChoices)return this.bell();e.selected=!0,this.render()}}handleInputChange(e){this.inputValue=this.inputValue+e,this.updateFilteredOptions()}_(e,t){e===" "?this.handleSpaceToggle():this.handleInputChange(e)}renderInstructions(){return this.instructions===void 0||this.instructions?typeof this.instructions=="string"?this.instructions:`
61
+ `+(r||Pe.gray(this.fallback.title))}this.out.write(dh.line+Rr.to(0)+this.outputText)}};Br.exports=Xt});var Kr=c((md,Jr)=>{"use strict";var Z=_(),bh=x(),wh=bh.cursor,yh=Kt(),ei=D(),Ur=ei.clear,Wr=ei.style,ge=ei.figures,Qt=class extends yh{constructor(e={}){e.overrideRender=!0,super(e),this.inputValue="",this.clear=Ur("",this.out.columns),this.filteredOptions=this.value,this.render()}last(){this.cursor=this.filteredOptions.length-1,this.render()}next(){this.cursor=(this.cursor+1)%this.filteredOptions.length,this.render()}up(){this.cursor===0?this.cursor=this.filteredOptions.length-1:this.cursor--,this.render()}down(){this.cursor===this.filteredOptions.length-1?this.cursor=0:this.cursor++,this.render()}left(){this.filteredOptions[this.cursor].selected=!1,this.render()}right(){if(this.value.filter(e=>e.selected).length>=this.maxChoices)return this.bell();this.filteredOptions[this.cursor].selected=!0,this.render()}delete(){this.inputValue.length&&(this.inputValue=this.inputValue.substr(0,this.inputValue.length-1),this.updateFilteredOptions())}updateFilteredOptions(){let e=this.filteredOptions[this.cursor];this.filteredOptions=this.value.filter(s=>this.inputValue?!!(typeof s.title=="string"&&s.title.toLowerCase().includes(this.inputValue.toLowerCase())||typeof s.value=="string"&&s.value.toLowerCase().includes(this.inputValue.toLowerCase())):!0);let t=this.filteredOptions.findIndex(s=>s===e);this.cursor=t<0?0:t,this.render()}handleSpaceToggle(){let e=this.filteredOptions[this.cursor];if(e.selected)e.selected=!1,this.render();else{if(e.disabled||this.value.filter(t=>t.selected).length>=this.maxChoices)return this.bell();e.selected=!0,this.render()}}handleInputChange(e){this.inputValue=this.inputValue+e,this.updateFilteredOptions()}_(e,t){e===" "?this.handleSpaceToggle():this.handleInputChange(e)}renderInstructions(){return this.instructions===void 0||this.instructions?typeof this.instructions=="string"?this.instructions:`
62
62
  Instructions:
63
- ${me.arrowUp}/${me.arrowDown}: Highlight option
64
- ${me.arrowLeft}/${me.arrowRight}/[space]: Toggle selection
63
+ ${ge.arrowUp}/${ge.arrowDown}: Highlight option
64
+ ${ge.arrowLeft}/${ge.arrowRight}/[space]: Toggle selection
65
65
  [a,b,c]/delete: Filter choices
66
66
  enter/return: Complete answer
67
67
  `:""}renderCurrentInput(){return`
68
68
  Filtered results for: ${this.inputValue?this.inputValue:Z.gray("Enter something to filter")}
69
- `}renderOption(e,t,s){let r;return t.disabled?r=e===s?Z.gray().underline(t.title):Z.strikethrough().gray(t.title):r=e===s?Z.cyan().underline(t.title):t.title,(t.selected?Z.green(me.radioOn):me.radioOff)+" "+r}renderDoneOrInstructions(){if(this.done)return this.value.filter(t=>t.selected).map(t=>t.title).join(", ");let e=[Z.gray(this.hint),this.renderInstructions(),this.renderCurrentInput()];return this.filteredOptions.length&&this.filteredOptions[this.cursor].disabled&&e.push(Z.yellow(this.warn)),e.join(" ")}render(){if(this.closed)return;this.firstRender&&this.out.write(bh.hide),super.render();let e=[Ur.symbol(this.done,this.aborted),Z.bold(this.msg),Ur.delimiter(!1),this.renderDoneOrInstructions()].join(" ");this.showMinError&&(e+=Z.red(`You must select a minimum of ${this.minSelected} choices.`),this.showMinError=!1),e+=this.renderOptions(this.filteredOptions),this.out.write(this.clear+e),this.clear=Yr(e,this.out.columns)}};Wr.exports=ei});var tn=c((md,en)=>{"use strict";var Kr=_(),yh=J(),Xr=D(),zr=Xr.style,_h=Xr.clear,Qr=x(),vh=Qr.erase,Zr=Qr.cursor,ii=class extends yh{constructor(e={}){super(e),this.msg=e.message,this.value=e.initial,this.initialValue=!!e.initial,this.yesMsg=e.yes||"yes",this.yesOption=e.yesOption||"(Y/n)",this.noMsg=e.no||"no",this.noOption=e.noOption||"(y/N)",this.render()}reset(){this.value=this.initialValue,this.fire(),this.render()}exit(){this.abort()}abort(){this.done=this.aborted=!0,this.fire(),this.render(),this.out.write(`
69
+ `}renderOption(e,t,s){let r;return t.disabled?r=e===s?Z.gray().underline(t.title):Z.strikethrough().gray(t.title):r=e===s?Z.cyan().underline(t.title):t.title,(t.selected?Z.green(ge.radioOn):ge.radioOff)+" "+r}renderDoneOrInstructions(){if(this.done)return this.value.filter(t=>t.selected).map(t=>t.title).join(", ");let e=[Z.gray(this.hint),this.renderInstructions(),this.renderCurrentInput()];return this.filteredOptions.length&&this.filteredOptions[this.cursor].disabled&&e.push(Z.yellow(this.warn)),e.join(" ")}render(){if(this.closed)return;this.firstRender&&this.out.write(wh.hide),super.render();let e=[Wr.symbol(this.done,this.aborted),Z.bold(this.msg),Wr.delimiter(!1),this.renderDoneOrInstructions()].join(" ");this.showMinError&&(e+=Z.red(`You must select a minimum of ${this.minSelected} choices.`),this.showMinError=!1),e+=this.renderOptions(this.filteredOptions),this.out.write(this.clear+e),this.clear=Ur(e,this.out.columns)}};Jr.exports=Qt});var sn=c((gd,tn)=>{"use strict";var zr=_(),_h=J(),Qr=D(),Zr=Qr.style,vh=Qr.clear,en=x(),xh=en.erase,Xr=en.cursor,ti=class extends _h{constructor(e={}){super(e),this.msg=e.message,this.value=e.initial,this.initialValue=!!e.initial,this.yesMsg=e.yes||"yes",this.yesOption=e.yesOption||"(Y/n)",this.noMsg=e.no||"no",this.noOption=e.noOption||"(y/N)",this.render()}reset(){this.value=this.initialValue,this.fire(),this.render()}exit(){this.abort()}abort(){this.done=this.aborted=!0,this.fire(),this.render(),this.out.write(`
70
70
  `),this.close()}submit(){this.value=this.value||!1,this.done=!0,this.aborted=!1,this.fire(),this.render(),this.out.write(`
71
- `),this.close()}_(e,t){return e.toLowerCase()==="y"?(this.value=!0,this.submit()):e.toLowerCase()==="n"?(this.value=!1,this.submit()):this.bell()}render(){this.closed||(this.firstRender?this.out.write(Zr.hide):this.out.write(_h(this.outputText,this.out.columns)),super.render(),this.outputText=[zr.symbol(this.done,this.aborted),Kr.bold(this.msg),zr.delimiter(this.done),this.done?this.value?this.yesMsg:this.noMsg:Kr.gray(this.initialValue?this.yesOption:this.noOption)].join(" "),this.out.write(vh.line+Zr.to(0)+this.outputText))}};en.exports=ii});var rn=c((gd,sn)=>{"use strict";sn.exports={TextPrompt:Ls(),SelectPrompt:Us(),TogglePrompt:Xs(),DatePrompt:Ar(),NumberPrompt:Ir(),MultiselectPrompt:zt(),AutocompletePrompt:Br(),AutocompleteMultiselectPrompt:Jr(),ConfirmPrompt:tn()}});var on=c(nn=>{"use strict";var A=nn,xh=rn(),Ke=i=>i;function N(i,e,t={}){return new Promise((s,r)=>{let n=new xh[i](e),o=t.onAbort||Ke,a=t.onSubmit||Ke,l=t.onExit||Ke;n.on("state",e.onState||Ke),n.on("submit",h=>s(a(h))),n.on("exit",h=>s(l(h))),n.on("abort",h=>r(o(h)))})}A.text=i=>N("TextPrompt",i);A.password=i=>(i.style="password",A.text(i));A.invisible=i=>(i.style="invisible",A.text(i));A.number=i=>N("NumberPrompt",i);A.date=i=>N("DatePrompt",i);A.confirm=i=>N("ConfirmPrompt",i);A.list=i=>{let e=i.separator||",";return N("TextPrompt",i,{onSubmit:t=>t.split(e).map(s=>s.trim())})};A.toggle=i=>N("TogglePrompt",i);A.select=i=>N("SelectPrompt",i);A.multiselect=i=>{i.choices=[].concat(i.choices||[]);let e=t=>t.filter(s=>s.selected).map(s=>s.value);return N("MultiselectPrompt",i,{onAbort:e,onSubmit:e})};A.autocompleteMultiselect=i=>{i.choices=[].concat(i.choices||[]);let e=t=>t.filter(s=>s.selected).map(s=>s.value);return N("AutocompleteMultiselectPrompt",i,{onAbort:e,onSubmit:e})};var Ch=(i,e)=>Promise.resolve(e.filter(t=>t.title.slice(0,i.length).toLowerCase()===i.toLowerCase()));A.autocomplete=i=>(i.suggest=i.suggest||Ch,i.choices=[].concat(i.choices||[]),N("AutocompletePrompt",i))});var pn=c((wd,fn)=>{"use strict";function an(i,e){var t=Object.keys(i);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(i);e&&(s=s.filter(function(r){return Object.getOwnPropertyDescriptor(i,r).enumerable})),t.push.apply(t,s)}return t}function ln(i){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?an(Object(t),!0).forEach(function(s){Oh(i,s,t[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(i,Object.getOwnPropertyDescriptors(t)):an(Object(t)).forEach(function(s){Object.defineProperty(i,s,Object.getOwnPropertyDescriptor(t,s))})}return i}function Oh(i,e,t){return e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function Sh(i,e){var t=typeof Symbol<"u"&&i[Symbol.iterator]||i["@@iterator"];if(!t){if(Array.isArray(i)||(t=$h(i))||e&&i&&typeof i.length=="number"){t&&(i=t);var s=0,r=function(){};return{s:r,n:function(){return s>=i.length?{done:!0}:{done:!1,value:i[s++]}},e:function(h){throw h},f:r}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
72
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var n=!0,o=!1,a;return{s:function(){t=t.call(i)},n:function(){var h=t.next();return n=h.done,h},e:function(h){o=!0,a=h},f:function(){try{!n&&t.return!=null&&t.return()}finally{if(o)throw a}}}}function $h(i,e){if(i){if(typeof i=="string")return hn(i,e);var t=Object.prototype.toString.call(i).slice(8,-1);if(t==="Object"&&i.constructor&&(t=i.constructor.name),t==="Map"||t==="Set")return Array.from(i);if(t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return hn(i,e)}}function hn(i,e){(e==null||e>i.length)&&(e=i.length);for(var t=0,s=new Array(e);t<e;t++)s[t]=i[t];return s}function un(i,e,t,s,r,n,o){try{var a=i[n](o),l=a.value}catch(h){t(h);return}a.done?e(l):Promise.resolve(l).then(s,r)}function cn(i){return function(){var e=this,t=arguments;return new Promise(function(s,r){var n=i.apply(e,t);function o(l){un(n,s,r,o,a,"next",l)}function a(l){un(n,s,r,o,a,"throw",l)}o(void 0)})}}var si=on(),Ah=["suggest","format","onState","validate","onRender","type"],dn=()=>{};function ne(){return ri.apply(this,arguments)}function ri(){return ri=cn(function*(i=[],{onSubmit:e=dn,onCancel:t=dn}={}){let s={},r=ne._override||{};i=[].concat(i);let n,o,a,l,h,d,f=function(){var T=cn(function*(U,He,Wi=!1){if(!(!Wi&&U.validate&&U.validate(He)!==!0))return U.format?yield U.format(He,s):He});return function(He,Wi){return T.apply(this,arguments)}}();var p=Sh(i),O;try{for(p.s();!(O=p.n()).done;){o=O.value;var b=o;if(l=b.name,h=b.type,typeof h=="function"&&(h=yield h(n,ln({},s),o),o.type=h),!!h){for(let T in o){if(Ah.includes(T))continue;let U=o[T];o[T]=typeof U=="function"?yield U(n,ln({},s),d):U}if(d=o,typeof o.message!="string")throw new Error("prompt message is required");var q=o;if(l=q.name,h=q.type,si[h]===void 0)throw new Error(`prompt type (${h}) is not defined`);if(r[o.name]!==void 0&&(n=yield f(o,r[o.name]),n!==void 0)){s[l]=n;continue}try{n=ne._injected?Ph(ne._injected,o.initial):yield si[h](o),s[l]=n=yield f(o,n,!0),a=yield e(o,n,s)}catch{a=!(yield t(o,s))}if(a)return s}}}catch(T){p.e(T)}finally{p.f()}return s}),ri.apply(this,arguments)}function Ph(i,e){let t=i.shift();if(t instanceof Error)throw t;return t===void 0?e:t}function Eh(i){ne._injected=(ne._injected||[]).concat(i)}function qh(i){ne._override=Object.assign({},i)}fn.exports=Object.assign(ne,{prompt:ne,prompts:si,inject:Eh,override:qh})});var gn=c((yd,mn)=>{"use strict";mn.exports=(i,e)=>{if(!(i.meta&&i.name!=="escape")){if(i.ctrl){if(i.name==="a")return"first";if(i.name==="c"||i.name==="d")return"abort";if(i.name==="e")return"last";if(i.name==="g")return"reset"}if(e){if(i.name==="j")return"down";if(i.name==="k")return"up"}return i.name==="return"||i.name==="enter"?"submit":i.name==="backspace"?"delete":i.name==="delete"?"deleteForward":i.name==="abort"?"abort":i.name==="escape"?"exit":i.name==="tab"?"next":i.name==="pagedown"?"nextPage":i.name==="pageup"?"prevPage":i.name==="home"?"home":i.name==="end"?"end":i.name==="up"?"up":i.name==="down"?"down":i.name==="right"?"right":i.name==="left"?"left":!1}}});var ze=c((_d,bn)=>{"use strict";bn.exports=i=>{let e=["[\\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("|"),t=new RegExp(e,"g");return typeof i=="string"?i.replace(t,""):i}});var _n=c((vd,yn)=>{"use strict";var Th=ze(),{erase:wn,cursor:kh}=x(),Mh=i=>[...Th(i)].length;yn.exports=function(i,e){if(!e)return wn.line+kh.to(0);let t=0,s=i.split(/\r?\n/);for(let r of s)t+=1+Math.floor(Math.max(Mh(r)-1,0)/e);return wn.lines(t)}});var ni=c((xd,vn)=>{"use strict";var Te={arrowUp:"\u2191",arrowDown:"\u2193",arrowLeft:"\u2190",arrowRight:"\u2192",radioOn:"\u25C9",radioOff:"\u25EF",tick:"\u2714",cross:"\u2716",ellipsis:"\u2026",pointerSmall:"\u203A",line:"\u2500",pointer:"\u276F"},Ih={arrowUp:Te.arrowUp,arrowDown:Te.arrowDown,arrowLeft:Te.arrowLeft,arrowRight:Te.arrowRight,radioOn:"(*)",radioOff:"( )",tick:"\u221A",cross:"\xD7",ellipsis:"...",pointerSmall:"\xBB",line:"\u2500",pointer:">"},Dh=process.platform==="win32"?Ih:Te;vn.exports=Dh});var Cn=c((Cd,xn)=>{"use strict";var ge=_(),ce=ni(),oi=Object.freeze({password:{scale:1,render:i=>"*".repeat(i.length)},emoji:{scale:2,render:i=>"\u{1F603}".repeat(i.length)},invisible:{scale:0,render:i=>""},default:{scale:1,render:i=>`${i}`}}),jh=i=>oi[i]||oi.default,ke=Object.freeze({aborted:ge.red(ce.cross),done:ge.green(ce.tick),exited:ge.yellow(ce.cross),default:ge.cyan("?")}),Vh=(i,e,t)=>e?ke.aborted:t?ke.exited:i?ke.done:ke.default,Hh=i=>ge.gray(i?ce.ellipsis:ce.pointerSmall),Fh=(i,e)=>ge.gray(i?e?ce.pointerSmall:"+":ce.line);xn.exports={styles:oi,render:jh,symbols:ke,symbol:Vh,delimiter:Hh,item:Fh}});var Sn=c((Od,On)=>{"use strict";var Rh=ze();On.exports=function(i,e){let t=String(Rh(i)||"").split(/\r?\n/);return e?t.map(s=>Math.ceil(s.length/e)).reduce((s,r)=>s+r):t.length}});var An=c((Sd,$n)=>{"use strict";$n.exports=(i,e={})=>{let t=Number.isSafeInteger(parseInt(e.margin))?new Array(parseInt(e.margin)).fill(" ").join(""):e.margin||"",s=e.width;return(i||"").split(/\r?\n/g).map(r=>r.split(/\s+/g).reduce((n,o)=>(o.length+t.length>=s||n[n.length-1].length+o.length+1<s?n[n.length-1]+=` ${o}`:n.push(`${t}${o}`),n),[t]).join(`
71
+ `),this.close()}_(e,t){return e.toLowerCase()==="y"?(this.value=!0,this.submit()):e.toLowerCase()==="n"?(this.value=!1,this.submit()):this.bell()}render(){this.closed||(this.firstRender?this.out.write(Xr.hide):this.out.write(vh(this.outputText,this.out.columns)),super.render(),this.outputText=[Zr.symbol(this.done,this.aborted),zr.bold(this.msg),Zr.delimiter(this.done),this.done?this.value?this.yesMsg:this.noMsg:zr.gray(this.initialValue?this.yesOption:this.noOption)].join(" "),this.out.write(xh.line+Xr.to(0)+this.outputText))}};tn.exports=ti});var nn=c((bd,rn)=>{"use strict";rn.exports={TextPrompt:Gs(),SelectPrompt:Ws(),TogglePrompt:Qs(),DatePrompt:Pr(),NumberPrompt:Dr(),MultiselectPrompt:Kt(),AutocompletePrompt:Yr(),AutocompleteMultiselectPrompt:Kr(),ConfirmPrompt:sn()}});var an=c(on=>{"use strict";var A=on,Ch=nn(),Je=i=>i;function N(i,e,t={}){return new Promise((s,r)=>{let n=new Ch[i](e),o=t.onAbort||Je,a=t.onSubmit||Je,l=t.onExit||Je;n.on("state",e.onState||Je),n.on("submit",h=>s(a(h))),n.on("exit",h=>s(l(h))),n.on("abort",h=>r(o(h)))})}A.text=i=>N("TextPrompt",i);A.password=i=>(i.style="password",A.text(i));A.invisible=i=>(i.style="invisible",A.text(i));A.number=i=>N("NumberPrompt",i);A.date=i=>N("DatePrompt",i);A.confirm=i=>N("ConfirmPrompt",i);A.list=i=>{let e=i.separator||",";return N("TextPrompt",i,{onSubmit:t=>t.split(e).map(s=>s.trim())})};A.toggle=i=>N("TogglePrompt",i);A.select=i=>N("SelectPrompt",i);A.multiselect=i=>{i.choices=[].concat(i.choices||[]);let e=t=>t.filter(s=>s.selected).map(s=>s.value);return N("MultiselectPrompt",i,{onAbort:e,onSubmit:e})};A.autocompleteMultiselect=i=>{i.choices=[].concat(i.choices||[]);let e=t=>t.filter(s=>s.selected).map(s=>s.value);return N("AutocompleteMultiselectPrompt",i,{onAbort:e,onSubmit:e})};var Oh=(i,e)=>Promise.resolve(e.filter(t=>t.title.slice(0,i.length).toLowerCase()===i.toLowerCase()));A.autocomplete=i=>(i.suggest=i.suggest||Oh,i.choices=[].concat(i.choices||[]),N("AutocompletePrompt",i))});var mn=c((yd,pn)=>{"use strict";function ln(i,e){var t=Object.keys(i);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(i);e&&(s=s.filter(function(r){return Object.getOwnPropertyDescriptor(i,r).enumerable})),t.push.apply(t,s)}return t}function hn(i){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?ln(Object(t),!0).forEach(function(s){Sh(i,s,t[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(i,Object.getOwnPropertyDescriptors(t)):ln(Object(t)).forEach(function(s){Object.defineProperty(i,s,Object.getOwnPropertyDescriptor(t,s))})}return i}function Sh(i,e,t){return e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function $h(i,e){var t=typeof Symbol<"u"&&i[Symbol.iterator]||i["@@iterator"];if(!t){if(Array.isArray(i)||(t=Ah(i))||e&&i&&typeof i.length=="number"){t&&(i=t);var s=0,r=function(){};return{s:r,n:function(){return s>=i.length?{done:!0}:{done:!1,value:i[s++]}},e:function(h){throw h},f:r}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
72
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var n=!0,o=!1,a;return{s:function(){t=t.call(i)},n:function(){var h=t.next();return n=h.done,h},e:function(h){o=!0,a=h},f:function(){try{!n&&t.return!=null&&t.return()}finally{if(o)throw a}}}}function Ah(i,e){if(i){if(typeof i=="string")return un(i,e);var t=Object.prototype.toString.call(i).slice(8,-1);if(t==="Object"&&i.constructor&&(t=i.constructor.name),t==="Map"||t==="Set")return Array.from(i);if(t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return un(i,e)}}function un(i,e){(e==null||e>i.length)&&(e=i.length);for(var t=0,s=new Array(e);t<e;t++)s[t]=i[t];return s}function cn(i,e,t,s,r,n,o){try{var a=i[n](o),l=a.value}catch(h){t(h);return}a.done?e(l):Promise.resolve(l).then(s,r)}function dn(i){return function(){var e=this,t=arguments;return new Promise(function(s,r){var n=i.apply(e,t);function o(l){cn(n,s,r,o,a,"next",l)}function a(l){cn(n,s,r,o,a,"throw",l)}o(void 0)})}}var ii=an(),Ph=["suggest","format","onState","validate","onRender","type"],fn=()=>{};function ne(){return si.apply(this,arguments)}function si(){return si=dn(function*(i=[],{onSubmit:e=fn,onCancel:t=fn}={}){let s={},r=ne._override||{};i=[].concat(i);let n,o,a,l,h,d,f=function(){var T=dn(function*(U,Ve,Ji=!1){if(!(!Ji&&U.validate&&U.validate(Ve)!==!0))return U.format?yield U.format(Ve,s):Ve});return function(Ve,Ji){return T.apply(this,arguments)}}();var p=$h(i),O;try{for(p.s();!(O=p.n()).done;){o=O.value;var b=o;if(l=b.name,h=b.type,typeof h=="function"&&(h=yield h(n,hn({},s),o),o.type=h),!!h){for(let T in o){if(Ph.includes(T))continue;let U=o[T];o[T]=typeof U=="function"?yield U(n,hn({},s),d):U}if(d=o,typeof o.message!="string")throw new Error("prompt message is required");var q=o;if(l=q.name,h=q.type,ii[h]===void 0)throw new Error(`prompt type (${h}) is not defined`);if(r[o.name]!==void 0&&(n=yield f(o,r[o.name]),n!==void 0)){s[l]=n;continue}try{n=ne._injected?Eh(ne._injected,o.initial):yield ii[h](o),s[l]=n=yield f(o,n,!0),a=yield e(o,n,s)}catch{a=!(yield t(o,s))}if(a)return s}}}catch(T){p.e(T)}finally{p.f()}return s}),si.apply(this,arguments)}function Eh(i,e){let t=i.shift();if(t instanceof Error)throw t;return t===void 0?e:t}function qh(i){ne._injected=(ne._injected||[]).concat(i)}function Th(i){ne._override=Object.assign({},i)}pn.exports=Object.assign(ne,{prompt:ne,prompts:ii,inject:qh,override:Th})});var bn=c((_d,gn)=>{"use strict";gn.exports=(i,e)=>{if(!(i.meta&&i.name!=="escape")){if(i.ctrl){if(i.name==="a")return"first";if(i.name==="c"||i.name==="d")return"abort";if(i.name==="e")return"last";if(i.name==="g")return"reset"}if(e){if(i.name==="j")return"down";if(i.name==="k")return"up"}return i.name==="return"||i.name==="enter"?"submit":i.name==="backspace"?"delete":i.name==="delete"?"deleteForward":i.name==="abort"?"abort":i.name==="escape"?"exit":i.name==="tab"?"next":i.name==="pagedown"?"nextPage":i.name==="pageup"?"prevPage":i.name==="home"?"home":i.name==="end"?"end":i.name==="up"?"up":i.name==="down"?"down":i.name==="right"?"right":i.name==="left"?"left":!1}}});var Ke=c((vd,wn)=>{"use strict";wn.exports=i=>{let e=["[\\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("|"),t=new RegExp(e,"g");return typeof i=="string"?i.replace(t,""):i}});var vn=c((xd,_n)=>{"use strict";var kh=Ke(),{erase:yn,cursor:Mh}=x(),Ih=i=>[...kh(i)].length;_n.exports=function(i,e){if(!e)return yn.line+Mh.to(0);let t=0,s=i.split(/\r?\n/);for(let r of s)t+=1+Math.floor(Math.max(Ih(r)-1,0)/e);return yn.lines(t)}});var ri=c((Cd,xn)=>{"use strict";var qe={arrowUp:"\u2191",arrowDown:"\u2193",arrowLeft:"\u2190",arrowRight:"\u2192",radioOn:"\u25C9",radioOff:"\u25EF",tick:"\u2714",cross:"\u2716",ellipsis:"\u2026",pointerSmall:"\u203A",line:"\u2500",pointer:"\u276F"},Dh={arrowUp:qe.arrowUp,arrowDown:qe.arrowDown,arrowLeft:qe.arrowLeft,arrowRight:qe.arrowRight,radioOn:"(*)",radioOff:"( )",tick:"\u221A",cross:"\xD7",ellipsis:"...",pointerSmall:"\xBB",line:"\u2500",pointer:">"},jh=process.platform==="win32"?Dh:qe;xn.exports=jh});var On=c((Od,Cn)=>{"use strict";var be=_(),ce=ri(),ni=Object.freeze({password:{scale:1,render:i=>"*".repeat(i.length)},emoji:{scale:2,render:i=>"\u{1F603}".repeat(i.length)},invisible:{scale:0,render:i=>""},default:{scale:1,render:i=>`${i}`}}),Vh=i=>ni[i]||ni.default,Te=Object.freeze({aborted:be.red(ce.cross),done:be.green(ce.tick),exited:be.yellow(ce.cross),default:be.cyan("?")}),Hh=(i,e,t)=>e?Te.aborted:t?Te.exited:i?Te.done:Te.default,Fh=i=>be.gray(i?ce.ellipsis:ce.pointerSmall),Rh=(i,e)=>be.gray(i?e?ce.pointerSmall:"+":ce.line);Cn.exports={styles:ni,render:Vh,symbols:Te,symbol:Hh,delimiter:Fh,item:Rh}});var $n=c((Sd,Sn)=>{"use strict";var Nh=Ke();Sn.exports=function(i,e){let t=String(Nh(i)||"").split(/\r?\n/);return e?t.map(s=>Math.ceil(s.length/e)).reduce((s,r)=>s+r):t.length}});var Pn=c(($d,An)=>{"use strict";An.exports=(i,e={})=>{let t=Number.isSafeInteger(parseInt(e.margin))?new Array(parseInt(e.margin)).fill(" ").join(""):e.margin||"",s=e.width;return(i||"").split(/\r?\n/g).map(r=>r.split(/\s+/g).reduce((n,o)=>(o.length+t.length>=s||n[n.length-1].length+o.length+1<s?n[n.length-1]+=` ${o}`:n.push(`${t}${o}`),n),[t]).join(`
73
73
  `)).join(`
74
- `)}});var En=c(($d,Pn)=>{"use strict";Pn.exports=(i,e,t)=>{t=t||e;let s=Math.min(e-t,i-Math.floor(t/2));s<0&&(s=0);let r=Math.min(s+t,e);return{startIndex:s,endIndex:r}}});var j=c((Ad,qn)=>{"use strict";qn.exports={action:gn(),clear:_n(),style:Cn(),strip:ze(),figures:ni(),lines:Sn(),wrap:An(),entriesToDisplay:En()}});var X=c((Pd,kn)=>{"use strict";var Tn=require("readline"),{action:Nh}=j(),Lh=require("events"),{beep:Gh,cursor:Bh}=x(),Yh=_(),ai=class extends Lh{constructor(e={}){super(),this.firstRender=!0,this.in=e.stdin||process.stdin,this.out=e.stdout||process.stdout,this.onRender=(e.onRender||(()=>{})).bind(this);let t=Tn.createInterface({input:this.in,escapeCodeTimeout:50});Tn.emitKeypressEvents(this.in,t),this.in.isTTY&&this.in.setRawMode(!0);let s=["SelectPrompt","MultiselectPrompt"].indexOf(this.constructor.name)>-1,r=(n,o)=>{let a=Nh(o,s);a===!1?this._&&this._(n,o):typeof this[a]=="function"?this[a](o):this.bell()};this.close=()=>{this.out.write(Bh.show),this.in.removeListener("keypress",r),this.in.isTTY&&this.in.setRawMode(!1),t.close(),this.emit(this.aborted?"abort":this.exited?"exit":"submit",this.value),this.closed=!0},this.in.on("keypress",r)}fire(){this.emit("state",{value:this.value,aborted:!!this.aborted,exited:!!this.exited})}bell(){this.out.write(Gh)}render(){this.onRender(Yh),this.firstRender&&(this.firstRender=!1)}};kn.exports=ai});var In=c((Ed,Mn)=>{var Ze=_(),Uh=X(),{erase:Wh,cursor:Me}=x(),{style:li,clear:hi,lines:Jh,figures:Kh}=j(),ui=class extends Uh{constructor(e={}){super(e),this.transform=li.render(e.style),this.scale=this.transform.scale,this.msg=e.message,this.initial=e.initial||"",this.validator=e.validate||(()=>!0),this.value="",this.errorMsg=e.error||"Please Enter A Valid Value",this.cursor=+!!this.initial,this.cursorOffset=0,this.clear=hi("",this.out.columns),this.render()}set value(e){!e&&this.initial?(this.placeholder=!0,this.rendered=Ze.gray(this.transform.render(this.initial))):(this.placeholder=!1,this.rendered=this.transform.render(e)),this._value=e,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(`
74
+ `)}});var qn=c((Ad,En)=>{"use strict";En.exports=(i,e,t)=>{t=t||e;let s=Math.min(e-t,i-Math.floor(t/2));s<0&&(s=0);let r=Math.min(s+t,e);return{startIndex:s,endIndex:r}}});var j=c((Pd,Tn)=>{"use strict";Tn.exports={action:bn(),clear:vn(),style:On(),strip:Ke(),figures:ri(),lines:$n(),wrap:Pn(),entriesToDisplay:qn()}});var X=c((Ed,Mn)=>{"use strict";var kn=require("readline"),{action:Lh}=j(),Gh=require("events"),{beep:Bh,cursor:Yh}=x(),Uh=_(),oi=class extends Gh{constructor(e={}){super(),this.firstRender=!0,this.in=e.stdin||process.stdin,this.out=e.stdout||process.stdout,this.onRender=(e.onRender||(()=>{})).bind(this);let t=kn.createInterface({input:this.in,escapeCodeTimeout:50});kn.emitKeypressEvents(this.in,t),this.in.isTTY&&this.in.setRawMode(!0);let s=["SelectPrompt","MultiselectPrompt"].indexOf(this.constructor.name)>-1,r=(n,o)=>{let a=Lh(o,s);a===!1?this._&&this._(n,o):typeof this[a]=="function"?this[a](o):this.bell()};this.close=()=>{this.out.write(Yh.show),this.in.removeListener("keypress",r),this.in.isTTY&&this.in.setRawMode(!1),t.close(),this.emit(this.aborted?"abort":this.exited?"exit":"submit",this.value),this.closed=!0},this.in.on("keypress",r)}fire(){this.emit("state",{value:this.value,aborted:!!this.aborted,exited:!!this.exited})}bell(){this.out.write(Bh)}render(){this.onRender(Uh),this.firstRender&&(this.firstRender=!1)}};Mn.exports=oi});var Dn=c((qd,In)=>{var ze=_(),Wh=X(),{erase:Jh,cursor:ke}=x(),{style:ai,clear:li,lines:Kh,figures:zh}=j(),hi=class extends Wh{constructor(e={}){super(e),this.transform=ai.render(e.style),this.scale=this.transform.scale,this.msg=e.message,this.initial=e.initial||"",this.validator=e.validate||(()=>!0),this.value="",this.errorMsg=e.error||"Please Enter A Valid Value",this.cursor=+!!this.initial,this.cursorOffset=0,this.clear=li("",this.out.columns),this.render()}set value(e){!e&&this.initial?(this.placeholder=!0,this.rendered=ze.gray(this.transform.render(this.initial))):(this.placeholder=!1,this.rendered=this.transform.render(e)),this._value=e,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(`
75
75
  `),this.close()}async validate(){let e=await this.validator(this.value);typeof e=="string"&&(this.errorMsg=e,e=!1),this.error=!e}async submit(){if(this.value=this.value||this.initial,this.cursorOffset=0,this.cursor=this.rendered.length,await this.validate(),this.error){this.red=!0,this.fire(),this.render();return}this.done=!0,this.aborted=!1,this.fire(),this.render(),this.out.write(`
76
- `),this.close()}next(){if(!this.placeholder)return this.bell();this.value=this.initial,this.cursor=this.rendered.length,this.fire(),this.render()}moveCursor(e){this.placeholder||(this.cursor=this.cursor+e,this.cursorOffset+=e)}_(e,t){let s=this.value.slice(0,this.cursor),r=this.value.slice(this.cursor);this.value=`${s}${e}${r}`,this.red=!1,this.cursor=this.placeholder?0:s.length+1,this.render()}delete(){if(this.isCursorAtStart())return this.bell();let e=this.value.slice(0,this.cursor-1),t=this.value.slice(this.cursor);this.value=`${e}${t}`,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 e=this.value.slice(0,this.cursor),t=this.value.slice(this.cursor+1);this.value=`${e}${t}`,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(Me.down(Jh(this.outputError,this.out.columns)-1)+hi(this.outputError,this.out.columns)),this.out.write(hi(this.outputText,this.out.columns))),super.render(),this.outputError="",this.outputText=[li.symbol(this.done,this.aborted),Ze.bold(this.msg),li.delimiter(this.done),this.red?Ze.red(this.rendered):this.rendered].join(" "),this.error&&(this.outputError+=this.errorMsg.split(`
76
+ `),this.close()}next(){if(!this.placeholder)return this.bell();this.value=this.initial,this.cursor=this.rendered.length,this.fire(),this.render()}moveCursor(e){this.placeholder||(this.cursor=this.cursor+e,this.cursorOffset+=e)}_(e,t){let s=this.value.slice(0,this.cursor),r=this.value.slice(this.cursor);this.value=`${s}${e}${r}`,this.red=!1,this.cursor=this.placeholder?0:s.length+1,this.render()}delete(){if(this.isCursorAtStart())return this.bell();let e=this.value.slice(0,this.cursor-1),t=this.value.slice(this.cursor);this.value=`${e}${t}`,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 e=this.value.slice(0,this.cursor),t=this.value.slice(this.cursor+1);this.value=`${e}${t}`,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(ke.down(Kh(this.outputError,this.out.columns)-1)+li(this.outputError,this.out.columns)),this.out.write(li(this.outputText,this.out.columns))),super.render(),this.outputError="",this.outputText=[ai.symbol(this.done,this.aborted),ze.bold(this.msg),ai.delimiter(this.done),this.red?ze.red(this.rendered):this.rendered].join(" "),this.error&&(this.outputError+=this.errorMsg.split(`
77
77
  `).reduce((e,t,s)=>e+`
78
- ${s?" ":Kh.pointerSmall} ${Ze.red().italic(t)}`,"")),this.out.write(Wh.line+Me.to(0)+this.outputText+Me.save+this.outputError+Me.restore+Me.move(this.cursorOffset,0)))}};Mn.exports=ui});var Hn=c((qd,Vn)=>{"use strict";var Q=_(),zh=X(),{style:Dn,clear:jn,figures:Xe,wrap:Zh,entriesToDisplay:Xh}=j(),{cursor:Qh}=x(),ci=class extends zh{constructor(e={}){super(e),this.msg=e.message,this.hint=e.hint||"- Use arrow-keys. Return to submit.",this.warn=e.warn||"- This option is disabled",this.cursor=e.initial||0,this.choices=e.choices.map((t,s)=>(typeof t=="string"&&(t={title:t,value:s}),{title:t&&(t.title||t.value||t),value:t&&(t.value===void 0?s:t.value),description:t&&t.description,selected:t&&t.selected,disabled:t&&t.disabled})),this.optionsPerPage=e.optionsPerPage||10,this.value=(this.choices[this.cursor]||{}).value,this.clear=jn("",this.out.columns),this.render()}moveCursor(e){this.cursor=e,this.value=this.choices[e].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(`
78
+ ${s?" ":zh.pointerSmall} ${ze.red().italic(t)}`,"")),this.out.write(Jh.line+ke.to(0)+this.outputText+ke.save+this.outputError+ke.restore+ke.move(this.cursorOffset,0)))}};In.exports=hi});var Fn=c((Td,Hn)=>{"use strict";var Q=_(),Zh=X(),{style:jn,clear:Vn,figures:Ze,wrap:Xh,entriesToDisplay:Qh}=j(),{cursor:eu}=x(),ui=class extends Zh{constructor(e={}){super(e),this.msg=e.message,this.hint=e.hint||"- Use arrow-keys. Return to submit.",this.warn=e.warn||"- This option is disabled",this.cursor=e.initial||0,this.choices=e.choices.map((t,s)=>(typeof t=="string"&&(t={title:t,value:s}),{title:t&&(t.title||t.value||t),value:t&&(t.value===void 0?s:t.value),description:t&&t.description,selected:t&&t.selected,disabled:t&&t.disabled})),this.optionsPerPage=e.optionsPerPage||10,this.value=(this.choices[this.cursor]||{}).value,this.clear=Vn("",this.out.columns),this.render()}moveCursor(e){this.cursor=e,this.value=this.choices[e].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(`
79
79
  `),this.close()}submit(){this.selection.disabled?this.bell():(this.done=!0,this.aborted=!1,this.fire(),this.render(),this.out.write(`
80
- `),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()}_(e,t){if(e===" ")return this.submit()}get selection(){return this.choices[this.cursor]}render(){if(this.closed)return;this.firstRender?this.out.write(Qh.hide):this.out.write(jn(this.outputText,this.out.columns)),super.render();let{startIndex:e,endIndex:t}=Xh(this.cursor,this.choices.length,this.optionsPerPage);if(this.outputText=[Dn.symbol(this.done,this.aborted),Q.bold(this.msg),Dn.delimiter(!1),this.done?this.selection.title:this.selection.disabled?Q.yellow(this.warn):Q.gray(this.hint)].join(" "),!this.done){this.outputText+=`
81
- `;for(let s=e;s<t;s++){let r,n,o="",a=this.choices[s];s===e&&e>0?n=Xe.arrowUp:s===t-1&&t<this.choices.length?n=Xe.arrowDown:n=" ",a.disabled?(r=this.cursor===s?Q.gray().underline(a.title):Q.strikethrough().gray(a.title),n=(this.cursor===s?Q.bold().gray(Xe.pointer)+" ":" ")+n):(r=this.cursor===s?Q.cyan().underline(a.title):a.title,n=(this.cursor===s?Q.cyan(Xe.pointer)+" ":" ")+n,a.description&&this.cursor===s&&(o=` - ${a.description}`,(n.length+r.length+o.length>=this.out.columns||a.description.split(/\r?\n/).length>1)&&(o=`
82
- `+Zh(a.description,{margin:3,width:this.out.columns})))),this.outputText+=`${n} ${r}${Q.gray(o)}
83
- `}}this.out.write(this.outputText)}};Vn.exports=ci});var Ln=c((Td,Nn)=>{var Qe=_(),eu=X(),{style:Fn,clear:tu}=j(),{cursor:Rn,erase:iu}=x(),di=class extends eu{constructor(e={}){super(e),this.msg=e.message,this.value=!!e.initial,this.active=e.active||"on",this.inactive=e.inactive||"off",this.initialValue=this.value,this.render()}reset(){this.value=this.initialValue,this.fire(),this.render()}exit(){this.abort()}abort(){this.done=this.aborted=!0,this.fire(),this.render(),this.out.write(`
80
+ `),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()}_(e,t){if(e===" ")return this.submit()}get selection(){return this.choices[this.cursor]}render(){if(this.closed)return;this.firstRender?this.out.write(eu.hide):this.out.write(Vn(this.outputText,this.out.columns)),super.render();let{startIndex:e,endIndex:t}=Qh(this.cursor,this.choices.length,this.optionsPerPage);if(this.outputText=[jn.symbol(this.done,this.aborted),Q.bold(this.msg),jn.delimiter(!1),this.done?this.selection.title:this.selection.disabled?Q.yellow(this.warn):Q.gray(this.hint)].join(" "),!this.done){this.outputText+=`
81
+ `;for(let s=e;s<t;s++){let r,n,o="",a=this.choices[s];s===e&&e>0?n=Ze.arrowUp:s===t-1&&t<this.choices.length?n=Ze.arrowDown:n=" ",a.disabled?(r=this.cursor===s?Q.gray().underline(a.title):Q.strikethrough().gray(a.title),n=(this.cursor===s?Q.bold().gray(Ze.pointer)+" ":" ")+n):(r=this.cursor===s?Q.cyan().underline(a.title):a.title,n=(this.cursor===s?Q.cyan(Ze.pointer)+" ":" ")+n,a.description&&this.cursor===s&&(o=` - ${a.description}`,(n.length+r.length+o.length>=this.out.columns||a.description.split(/\r?\n/).length>1)&&(o=`
82
+ `+Xh(a.description,{margin:3,width:this.out.columns})))),this.outputText+=`${n} ${r}${Q.gray(o)}
83
+ `}}this.out.write(this.outputText)}};Hn.exports=ui});var Gn=c((kd,Ln)=>{var Xe=_(),tu=X(),{style:Rn,clear:iu}=j(),{cursor:Nn,erase:su}=x(),ci=class extends tu{constructor(e={}){super(e),this.msg=e.message,this.value=!!e.initial,this.active=e.active||"on",this.inactive=e.inactive||"off",this.initialValue=this.value,this.render()}reset(){this.value=this.initialValue,this.fire(),this.render()}exit(){this.abort()}abort(){this.done=this.aborted=!0,this.fire(),this.render(),this.out.write(`
84
84
  `),this.close()}submit(){this.done=!0,this.aborted=!1,this.fire(),this.render(),this.out.write(`
85
- `),this.close()}deactivate(){if(this.value===!1)return this.bell();this.value=!1,this.render()}activate(){if(this.value===!0)return this.bell();this.value=!0,this.render()}delete(){this.deactivate()}left(){this.deactivate()}right(){this.activate()}down(){this.deactivate()}up(){this.activate()}next(){this.value=!this.value,this.fire(),this.render()}_(e,t){if(e===" ")this.value=!this.value;else if(e==="1")this.value=!0;else if(e==="0")this.value=!1;else return this.bell();this.render()}render(){this.closed||(this.firstRender?this.out.write(Rn.hide):this.out.write(tu(this.outputText,this.out.columns)),super.render(),this.outputText=[Fn.symbol(this.done,this.aborted),Qe.bold(this.msg),Fn.delimiter(this.done),this.value?this.inactive:Qe.cyan().underline(this.inactive),Qe.gray("/"),this.value?Qe.cyan().underline(this.active):this.active].join(" "),this.out.write(iu.line+Rn.to(0)+this.outputText))}};Nn.exports=di});var L=c((kd,Gn)=>{"use strict";var fi=class i{constructor({token:e,date:t,parts:s,locales:r}){this.token=e,this.date=t||new Date,this.parts=s||[this],this.locales=r||{}}up(){}down(){}next(){let e=this.parts.indexOf(this);return this.parts.find((t,s)=>s>e&&t instanceof i)}setTo(e){}prev(){let e=[].concat(this.parts).reverse(),t=e.indexOf(this);return e.find((s,r)=>r>t&&s instanceof i)}toString(){return String(this.date)}};Gn.exports=fi});var Yn=c((Md,Bn)=>{"use strict";var su=L(),pi=class extends su{constructor(e={}){super(e)}up(){this.date.setHours((this.date.getHours()+12)%24)}down(){this.up()}toString(){let e=this.date.getHours()>12?"pm":"am";return/\A/.test(this.token)?e.toUpperCase():e}};Bn.exports=pi});var Wn=c((Id,Un)=>{"use strict";var ru=L(),nu=i=>(i=i%10,i===1?"st":i===2?"nd":i===3?"rd":"th"),mi=class extends ru{constructor(e={}){super(e)}up(){this.date.setDate(this.date.getDate()+1)}down(){this.date.setDate(this.date.getDate()-1)}setTo(e){this.date.setDate(parseInt(e.substr(-2)))}toString(){let e=this.date.getDate(),t=this.date.getDay();return this.token==="DD"?String(e).padStart(2,"0"):this.token==="Do"?e+nu(e):this.token==="d"?t+1:this.token==="ddd"?this.locales.weekdaysShort[t]:this.token==="dddd"?this.locales.weekdays[t]:e}};Un.exports=mi});var Kn=c((Dd,Jn)=>{"use strict";var ou=L(),gi=class extends ou{constructor(e={}){super(e)}up(){this.date.setHours(this.date.getHours()+1)}down(){this.date.setHours(this.date.getHours()-1)}setTo(e){this.date.setHours(parseInt(e.substr(-2)))}toString(){let e=this.date.getHours();return/h/.test(this.token)&&(e=e%12||12),this.token.length>1?String(e).padStart(2,"0"):e}};Jn.exports=gi});var Zn=c((jd,zn)=>{"use strict";var au=L(),bi=class extends au{constructor(e={}){super(e)}up(){this.date.setMilliseconds(this.date.getMilliseconds()+1)}down(){this.date.setMilliseconds(this.date.getMilliseconds()-1)}setTo(e){this.date.setMilliseconds(parseInt(e.substr(-this.token.length)))}toString(){return String(this.date.getMilliseconds()).padStart(4,"0").substr(0,this.token.length)}};zn.exports=bi});var Qn=c((Vd,Xn)=>{"use strict";var lu=L(),wi=class extends lu{constructor(e={}){super(e)}up(){this.date.setMinutes(this.date.getMinutes()+1)}down(){this.date.setMinutes(this.date.getMinutes()-1)}setTo(e){this.date.setMinutes(parseInt(e.substr(-2)))}toString(){let e=this.date.getMinutes();return this.token.length>1?String(e).padStart(2,"0"):e}};Xn.exports=wi});var to=c((Hd,eo)=>{"use strict";var hu=L(),yi=class extends hu{constructor(e={}){super(e)}up(){this.date.setMonth(this.date.getMonth()+1)}down(){this.date.setMonth(this.date.getMonth()-1)}setTo(e){e=parseInt(e.substr(-2))-1,this.date.setMonth(e<0?0:e)}toString(){let e=this.date.getMonth(),t=this.token.length;return t===2?String(e+1).padStart(2,"0"):t===3?this.locales.monthsShort[e]:t===4?this.locales.months[e]:String(e+1)}};eo.exports=yi});var so=c((Fd,io)=>{"use strict";var uu=L(),_i=class extends uu{constructor(e={}){super(e)}up(){this.date.setSeconds(this.date.getSeconds()+1)}down(){this.date.setSeconds(this.date.getSeconds()-1)}setTo(e){this.date.setSeconds(parseInt(e.substr(-2)))}toString(){let e=this.date.getSeconds();return this.token.length>1?String(e).padStart(2,"0"):e}};io.exports=_i});var no=c((Rd,ro)=>{"use strict";var cu=L(),vi=class extends cu{constructor(e={}){super(e)}up(){this.date.setFullYear(this.date.getFullYear()+1)}down(){this.date.setFullYear(this.date.getFullYear()-1)}setTo(e){this.date.setFullYear(e.substr(-4))}toString(){let e=String(this.date.getFullYear()).padStart(4,"0");return this.token.length===2?e.substr(-2):e}};ro.exports=vi});var ao=c((Nd,oo)=>{"use strict";oo.exports={DatePart:L(),Meridiem:Yn(),Day:Wn(),Hours:Kn(),Milliseconds:Zn(),Minutes:Qn(),Month:to(),Seconds:so(),Year:no()}});var mo=c((Ld,po)=>{"use strict";var xi=_(),du=X(),{style:lo,clear:ho,figures:fu}=j(),{erase:pu,cursor:uo}=x(),{DatePart:co,Meridiem:mu,Day:gu,Hours:bu,Milliseconds:wu,Minutes:yu,Month:_u,Seconds:vu,Year:xu}=ao(),Cu=/\\(.)|"((?:\\["\\]|[^"])+)"|(D[Do]?|d{3,4}|d)|(M{1,4})|(YY(?:YY)?)|([aA])|([Hh]{1,2})|(m{1,2})|(s{1,2})|(S{1,4})|./g,fo={1:({token:i})=>i.replace(/\\(.)/g,"$1"),2:i=>new gu(i),3:i=>new _u(i),4:i=>new xu(i),5:i=>new mu(i),6:i=>new bu(i),7:i=>new yu(i),8:i=>new vu(i),9:i=>new wu(i)},Ou={months:"January,February,March,April,May,June,July,August,September,October,November,December".split(","),monthsShort:"Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec".split(","),weekdays:"Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday".split(","),weekdaysShort:"Sun,Mon,Tue,Wed,Thu,Fri,Sat".split(",")},Ci=class extends du{constructor(e={}){super(e),this.msg=e.message,this.cursor=0,this.typed="",this.locales=Object.assign(Ou,e.locales),this._date=e.initial||new Date,this.errorMsg=e.error||"Please Enter A Valid Value",this.validator=e.validate||(()=>!0),this.mask=e.mask||"YYYY-MM-DD HH:mm:ss",this.clear=ho("",this.out.columns),this.render()}get value(){return this.date}get date(){return this._date}set date(e){e&&this._date.setTime(e.getTime())}set mask(e){let t;for(this.parts=[];t=Cu.exec(e);){let r=t.shift(),n=t.findIndex(o=>o!=null);this.parts.push(n in fo?fo[n]({token:t[n]||r,date:this.date,parts:this.parts,locales:this.locales}):t[n]||r)}let s=this.parts.reduce((r,n)=>(typeof n=="string"&&typeof r[r.length-1]=="string"?r[r.length-1]+=n:r.push(n),r),[]);this.parts.splice(0),this.parts.push(...s),this.reset()}moveCursor(e){this.typed="",this.cursor=e,this.fire()}reset(){this.moveCursor(this.parts.findIndex(e=>e instanceof co)),this.fire(),this.render()}exit(){this.abort()}abort(){this.done=this.aborted=!0,this.error=!1,this.fire(),this.render(),this.out.write(`
85
+ `),this.close()}deactivate(){if(this.value===!1)return this.bell();this.value=!1,this.render()}activate(){if(this.value===!0)return this.bell();this.value=!0,this.render()}delete(){this.deactivate()}left(){this.deactivate()}right(){this.activate()}down(){this.deactivate()}up(){this.activate()}next(){this.value=!this.value,this.fire(),this.render()}_(e,t){if(e===" ")this.value=!this.value;else if(e==="1")this.value=!0;else if(e==="0")this.value=!1;else return this.bell();this.render()}render(){this.closed||(this.firstRender?this.out.write(Nn.hide):this.out.write(iu(this.outputText,this.out.columns)),super.render(),this.outputText=[Rn.symbol(this.done,this.aborted),Xe.bold(this.msg),Rn.delimiter(this.done),this.value?this.inactive:Xe.cyan().underline(this.inactive),Xe.gray("/"),this.value?Xe.cyan().underline(this.active):this.active].join(" "),this.out.write(su.line+Nn.to(0)+this.outputText))}};Ln.exports=ci});var L=c((Md,Bn)=>{"use strict";var di=class i{constructor({token:e,date:t,parts:s,locales:r}){this.token=e,this.date=t||new Date,this.parts=s||[this],this.locales=r||{}}up(){}down(){}next(){let e=this.parts.indexOf(this);return this.parts.find((t,s)=>s>e&&t instanceof i)}setTo(e){}prev(){let e=[].concat(this.parts).reverse(),t=e.indexOf(this);return e.find((s,r)=>r>t&&s instanceof i)}toString(){return String(this.date)}};Bn.exports=di});var Un=c((Id,Yn)=>{"use strict";var ru=L(),fi=class extends ru{constructor(e={}){super(e)}up(){this.date.setHours((this.date.getHours()+12)%24)}down(){this.up()}toString(){let e=this.date.getHours()>12?"pm":"am";return/\A/.test(this.token)?e.toUpperCase():e}};Yn.exports=fi});var Jn=c((Dd,Wn)=>{"use strict";var nu=L(),ou=i=>(i=i%10,i===1?"st":i===2?"nd":i===3?"rd":"th"),pi=class extends nu{constructor(e={}){super(e)}up(){this.date.setDate(this.date.getDate()+1)}down(){this.date.setDate(this.date.getDate()-1)}setTo(e){this.date.setDate(parseInt(e.substr(-2)))}toString(){let e=this.date.getDate(),t=this.date.getDay();return this.token==="DD"?String(e).padStart(2,"0"):this.token==="Do"?e+ou(e):this.token==="d"?t+1:this.token==="ddd"?this.locales.weekdaysShort[t]:this.token==="dddd"?this.locales.weekdays[t]:e}};Wn.exports=pi});var zn=c((jd,Kn)=>{"use strict";var au=L(),mi=class extends au{constructor(e={}){super(e)}up(){this.date.setHours(this.date.getHours()+1)}down(){this.date.setHours(this.date.getHours()-1)}setTo(e){this.date.setHours(parseInt(e.substr(-2)))}toString(){let e=this.date.getHours();return/h/.test(this.token)&&(e=e%12||12),this.token.length>1?String(e).padStart(2,"0"):e}};Kn.exports=mi});var Xn=c((Vd,Zn)=>{"use strict";var lu=L(),gi=class extends lu{constructor(e={}){super(e)}up(){this.date.setMilliseconds(this.date.getMilliseconds()+1)}down(){this.date.setMilliseconds(this.date.getMilliseconds()-1)}setTo(e){this.date.setMilliseconds(parseInt(e.substr(-this.token.length)))}toString(){return String(this.date.getMilliseconds()).padStart(4,"0").substr(0,this.token.length)}};Zn.exports=gi});var eo=c((Hd,Qn)=>{"use strict";var hu=L(),bi=class extends hu{constructor(e={}){super(e)}up(){this.date.setMinutes(this.date.getMinutes()+1)}down(){this.date.setMinutes(this.date.getMinutes()-1)}setTo(e){this.date.setMinutes(parseInt(e.substr(-2)))}toString(){let e=this.date.getMinutes();return this.token.length>1?String(e).padStart(2,"0"):e}};Qn.exports=bi});var io=c((Fd,to)=>{"use strict";var uu=L(),wi=class extends uu{constructor(e={}){super(e)}up(){this.date.setMonth(this.date.getMonth()+1)}down(){this.date.setMonth(this.date.getMonth()-1)}setTo(e){e=parseInt(e.substr(-2))-1,this.date.setMonth(e<0?0:e)}toString(){let e=this.date.getMonth(),t=this.token.length;return t===2?String(e+1).padStart(2,"0"):t===3?this.locales.monthsShort[e]:t===4?this.locales.months[e]:String(e+1)}};to.exports=wi});var ro=c((Rd,so)=>{"use strict";var cu=L(),yi=class extends cu{constructor(e={}){super(e)}up(){this.date.setSeconds(this.date.getSeconds()+1)}down(){this.date.setSeconds(this.date.getSeconds()-1)}setTo(e){this.date.setSeconds(parseInt(e.substr(-2)))}toString(){let e=this.date.getSeconds();return this.token.length>1?String(e).padStart(2,"0"):e}};so.exports=yi});var oo=c((Nd,no)=>{"use strict";var du=L(),_i=class extends du{constructor(e={}){super(e)}up(){this.date.setFullYear(this.date.getFullYear()+1)}down(){this.date.setFullYear(this.date.getFullYear()-1)}setTo(e){this.date.setFullYear(e.substr(-4))}toString(){let e=String(this.date.getFullYear()).padStart(4,"0");return this.token.length===2?e.substr(-2):e}};no.exports=_i});var lo=c((Ld,ao)=>{"use strict";ao.exports={DatePart:L(),Meridiem:Un(),Day:Jn(),Hours:zn(),Milliseconds:Xn(),Minutes:eo(),Month:io(),Seconds:ro(),Year:oo()}});var go=c((Gd,mo)=>{"use strict";var vi=_(),fu=X(),{style:ho,clear:uo,figures:pu}=j(),{erase:mu,cursor:co}=x(),{DatePart:fo,Meridiem:gu,Day:bu,Hours:wu,Milliseconds:yu,Minutes:_u,Month:vu,Seconds:xu,Year:Cu}=lo(),Ou=/\\(.)|"((?:\\["\\]|[^"])+)"|(D[Do]?|d{3,4}|d)|(M{1,4})|(YY(?:YY)?)|([aA])|([Hh]{1,2})|(m{1,2})|(s{1,2})|(S{1,4})|./g,po={1:({token:i})=>i.replace(/\\(.)/g,"$1"),2:i=>new bu(i),3:i=>new vu(i),4:i=>new Cu(i),5:i=>new gu(i),6:i=>new wu(i),7:i=>new _u(i),8:i=>new xu(i),9:i=>new yu(i)},Su={months:"January,February,March,April,May,June,July,August,September,October,November,December".split(","),monthsShort:"Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec".split(","),weekdays:"Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday".split(","),weekdaysShort:"Sun,Mon,Tue,Wed,Thu,Fri,Sat".split(",")},xi=class extends fu{constructor(e={}){super(e),this.msg=e.message,this.cursor=0,this.typed="",this.locales=Object.assign(Su,e.locales),this._date=e.initial||new Date,this.errorMsg=e.error||"Please Enter A Valid Value",this.validator=e.validate||(()=>!0),this.mask=e.mask||"YYYY-MM-DD HH:mm:ss",this.clear=uo("",this.out.columns),this.render()}get value(){return this.date}get date(){return this._date}set date(e){e&&this._date.setTime(e.getTime())}set mask(e){let t;for(this.parts=[];t=Ou.exec(e);){let r=t.shift(),n=t.findIndex(o=>o!=null);this.parts.push(n in po?po[n]({token:t[n]||r,date:this.date,parts:this.parts,locales:this.locales}):t[n]||r)}let s=this.parts.reduce((r,n)=>(typeof n=="string"&&typeof r[r.length-1]=="string"?r[r.length-1]+=n:r.push(n),r),[]);this.parts.splice(0),this.parts.push(...s),this.reset()}moveCursor(e){this.typed="",this.cursor=e,this.fire()}reset(){this.moveCursor(this.parts.findIndex(e=>e instanceof fo)),this.fire(),this.render()}exit(){this.abort()}abort(){this.done=this.aborted=!0,this.error=!1,this.fire(),this.render(),this.out.write(`
86
86
  `),this.close()}async validate(){let e=await this.validator(this.value);typeof e=="string"&&(this.errorMsg=e,e=!1),this.error=!e}async submit(){if(await this.validate(),this.error){this.color="red",this.fire(),this.render();return}this.done=!0,this.aborted=!1,this.fire(),this.render(),this.out.write(`
87
- `),this.close()}up(){this.typed="",this.parts[this.cursor].up(),this.render()}down(){this.typed="",this.parts[this.cursor].down(),this.render()}left(){let e=this.parts[this.cursor].prev();if(e==null)return this.bell();this.moveCursor(this.parts.indexOf(e)),this.render()}right(){let e=this.parts[this.cursor].next();if(e==null)return this.bell();this.moveCursor(this.parts.indexOf(e)),this.render()}next(){let e=this.parts[this.cursor].next();this.moveCursor(e?this.parts.indexOf(e):this.parts.findIndex(t=>t instanceof co)),this.render()}_(e){/\d/.test(e)&&(this.typed+=e,this.parts[this.cursor].setTo(this.typed),this.render())}render(){this.closed||(this.firstRender?this.out.write(uo.hide):this.out.write(ho(this.outputText,this.out.columns)),super.render(),this.outputText=[lo.symbol(this.done,this.aborted),xi.bold(this.msg),lo.delimiter(!1),this.parts.reduce((e,t,s)=>e.concat(s===this.cursor&&!this.done?xi.cyan().underline(t.toString()):t),[]).join("")].join(" "),this.error&&(this.outputText+=this.errorMsg.split(`
87
+ `),this.close()}up(){this.typed="",this.parts[this.cursor].up(),this.render()}down(){this.typed="",this.parts[this.cursor].down(),this.render()}left(){let e=this.parts[this.cursor].prev();if(e==null)return this.bell();this.moveCursor(this.parts.indexOf(e)),this.render()}right(){let e=this.parts[this.cursor].next();if(e==null)return this.bell();this.moveCursor(this.parts.indexOf(e)),this.render()}next(){let e=this.parts[this.cursor].next();this.moveCursor(e?this.parts.indexOf(e):this.parts.findIndex(t=>t instanceof fo)),this.render()}_(e){/\d/.test(e)&&(this.typed+=e,this.parts[this.cursor].setTo(this.typed),this.render())}render(){this.closed||(this.firstRender?this.out.write(co.hide):this.out.write(uo(this.outputText,this.out.columns)),super.render(),this.outputText=[ho.symbol(this.done,this.aborted),vi.bold(this.msg),ho.delimiter(!1),this.parts.reduce((e,t,s)=>e.concat(s===this.cursor&&!this.done?vi.cyan().underline(t.toString()):t),[]).join("")].join(" "),this.error&&(this.outputText+=this.errorMsg.split(`
88
88
  `).reduce((e,t,s)=>e+`
89
- ${s?" ":fu.pointerSmall} ${xi.red().italic(t)}`,"")),this.out.write(pu.line+uo.to(0)+this.outputText))}};po.exports=Ci});var yo=c((Gd,wo)=>{var et=_(),Su=X(),{cursor:tt,erase:$u}=x(),{style:Oi,figures:Au,clear:go,lines:Pu}=j(),Eu=/[0-9]/,Si=i=>i!==void 0,bo=(i,e)=>{let t=Math.pow(10,e);return Math.round(i*t)/t},$i=class extends Su{constructor(e={}){super(e),this.transform=Oi.render(e.style),this.msg=e.message,this.initial=Si(e.initial)?e.initial:"",this.float=!!e.float,this.round=e.round||2,this.inc=e.increment||1,this.min=Si(e.min)?e.min:-1/0,this.max=Si(e.max)?e.max:1/0,this.errorMsg=e.error||"Please Enter A Valid Value",this.validator=e.validate||(()=>!0),this.color="cyan",this.value="",this.typed="",this.lastHit=0,this.render()}set value(e){!e&&e!==0?(this.placeholder=!0,this.rendered=et.gray(this.transform.render(`${this.initial}`)),this._value=""):(this.placeholder=!1,this.rendered=this.transform.render(`${bo(e,this.round)}`),this._value=bo(e,this.round)),this.fire()}get value(){return this._value}parse(e){return this.float?parseFloat(e):parseInt(e)}valid(e){return e==="-"||e==="."&&this.float||Eu.test(e)}reset(){this.typed="",this.value="",this.fire(),this.render()}exit(){this.abort()}abort(){let e=this.value;this.value=e!==""?e:this.initial,this.done=this.aborted=!0,this.error=!1,this.fire(),this.render(),this.out.write(`
89
+ ${s?" ":pu.pointerSmall} ${vi.red().italic(t)}`,"")),this.out.write(mu.line+co.to(0)+this.outputText))}};mo.exports=xi});var _o=c((Bd,yo)=>{var Qe=_(),$u=X(),{cursor:et,erase:Au}=x(),{style:Ci,figures:Pu,clear:bo,lines:Eu}=j(),qu=/[0-9]/,Oi=i=>i!==void 0,wo=(i,e)=>{let t=Math.pow(10,e);return Math.round(i*t)/t},Si=class extends $u{constructor(e={}){super(e),this.transform=Ci.render(e.style),this.msg=e.message,this.initial=Oi(e.initial)?e.initial:"",this.float=!!e.float,this.round=e.round||2,this.inc=e.increment||1,this.min=Oi(e.min)?e.min:-1/0,this.max=Oi(e.max)?e.max:1/0,this.errorMsg=e.error||"Please Enter A Valid Value",this.validator=e.validate||(()=>!0),this.color="cyan",this.value="",this.typed="",this.lastHit=0,this.render()}set value(e){!e&&e!==0?(this.placeholder=!0,this.rendered=Qe.gray(this.transform.render(`${this.initial}`)),this._value=""):(this.placeholder=!1,this.rendered=this.transform.render(`${wo(e,this.round)}`),this._value=wo(e,this.round)),this.fire()}get value(){return this._value}parse(e){return this.float?parseFloat(e):parseInt(e)}valid(e){return e==="-"||e==="."&&this.float||qu.test(e)}reset(){this.typed="",this.value="",this.fire(),this.render()}exit(){this.abort()}abort(){let e=this.value;this.value=e!==""?e:this.initial,this.done=this.aborted=!0,this.error=!1,this.fire(),this.render(),this.out.write(`
90
90
  `),this.close()}async validate(){let e=await this.validator(this.value);typeof e=="string"&&(this.errorMsg=e,e=!1),this.error=!e}async submit(){if(await this.validate(),this.error){this.color="red",this.fire(),this.render();return}let e=this.value;this.value=e!==""?e:this.initial,this.done=!0,this.aborted=!1,this.error=!1,this.fire(),this.render(),this.out.write(`
91
- `),this.close()}up(){if(this.typed="",this.value===""&&(this.value=this.min-this.inc),this.value>=this.max)return this.bell();this.value+=this.inc,this.color="cyan",this.fire(),this.render()}down(){if(this.typed="",this.value===""&&(this.value=this.min+this.inc),this.value<=this.min)return this.bell();this.value-=this.inc,this.color="cyan",this.fire(),this.render()}delete(){let e=this.value.toString();if(e.length===0)return this.bell();this.value=this.parse(e=e.slice(0,-1))||"",this.value!==""&&this.value<this.min&&(this.value=this.min),this.color="cyan",this.fire(),this.render()}next(){this.value=this.initial,this.fire(),this.render()}_(e,t){if(!this.valid(e))return this.bell();let s=Date.now();if(s-this.lastHit>1e3&&(this.typed=""),this.typed+=e,this.lastHit=s,this.color="cyan",e===".")return this.fire();this.value=Math.min(this.parse(this.typed),this.max),this.value>this.max&&(this.value=this.max),this.value<this.min&&(this.value=this.min),this.fire(),this.render()}render(){this.closed||(this.firstRender||(this.outputError&&this.out.write(tt.down(Pu(this.outputError,this.out.columns)-1)+go(this.outputError,this.out.columns)),this.out.write(go(this.outputText,this.out.columns))),super.render(),this.outputError="",this.outputText=[Oi.symbol(this.done,this.aborted),et.bold(this.msg),Oi.delimiter(this.done),!this.done||!this.done&&!this.placeholder?et[this.color]().underline(this.rendered):this.rendered].join(" "),this.error&&(this.outputError+=this.errorMsg.split(`
91
+ `),this.close()}up(){if(this.typed="",this.value===""&&(this.value=this.min-this.inc),this.value>=this.max)return this.bell();this.value+=this.inc,this.color="cyan",this.fire(),this.render()}down(){if(this.typed="",this.value===""&&(this.value=this.min+this.inc),this.value<=this.min)return this.bell();this.value-=this.inc,this.color="cyan",this.fire(),this.render()}delete(){let e=this.value.toString();if(e.length===0)return this.bell();this.value=this.parse(e=e.slice(0,-1))||"",this.value!==""&&this.value<this.min&&(this.value=this.min),this.color="cyan",this.fire(),this.render()}next(){this.value=this.initial,this.fire(),this.render()}_(e,t){if(!this.valid(e))return this.bell();let s=Date.now();if(s-this.lastHit>1e3&&(this.typed=""),this.typed+=e,this.lastHit=s,this.color="cyan",e===".")return this.fire();this.value=Math.min(this.parse(this.typed),this.max),this.value>this.max&&(this.value=this.max),this.value<this.min&&(this.value=this.min),this.fire(),this.render()}render(){this.closed||(this.firstRender||(this.outputError&&this.out.write(et.down(Eu(this.outputError,this.out.columns)-1)+bo(this.outputError,this.out.columns)),this.out.write(bo(this.outputText,this.out.columns))),super.render(),this.outputError="",this.outputText=[Ci.symbol(this.done,this.aborted),Qe.bold(this.msg),Ci.delimiter(this.done),!this.done||!this.done&&!this.placeholder?Qe[this.color]().underline(this.rendered):this.rendered].join(" "),this.error&&(this.outputError+=this.errorMsg.split(`
92
92
  `).reduce((e,t,s)=>e+`
93
- ${s?" ":Au.pointerSmall} ${et.red().italic(t)}`,"")),this.out.write($u.line+tt.to(0)+this.outputText+tt.save+this.outputError+tt.restore))}};wo.exports=$i});var Pi=c((Bd,xo)=>{"use strict";var G=_(),{cursor:qu}=x(),Tu=X(),{clear:_o,figures:oe,style:vo,wrap:ku,entriesToDisplay:Mu}=j(),Ai=class extends Tu{constructor(e={}){super(e),this.msg=e.message,this.cursor=e.cursor||0,this.scrollIndex=e.cursor||0,this.hint=e.hint||"",this.warn=e.warn||"- This option is disabled -",this.minSelected=e.min,this.showMinError=!1,this.maxChoices=e.max,this.instructions=e.instructions,this.optionsPerPage=e.optionsPerPage||10,this.value=e.choices.map((t,s)=>(typeof t=="string"&&(t={title:t,value:s}),{title:t&&(t.title||t.value||t),description:t&&t.description,value:t&&(t.value===void 0?s:t.value),selected:t&&t.selected,disabled:t&&t.disabled})),this.clear=_o("",this.out.columns),e.overrideRender||this.render()}reset(){this.value.map(e=>!e.selected),this.cursor=0,this.fire(),this.render()}selected(){return this.value.filter(e=>e.selected)}exit(){this.abort()}abort(){this.done=this.aborted=!0,this.fire(),this.render(),this.out.write(`
93
+ ${s?" ":Pu.pointerSmall} ${Qe.red().italic(t)}`,"")),this.out.write(Au.line+et.to(0)+this.outputText+et.save+this.outputError+et.restore))}};yo.exports=Si});var Ai=c((Yd,Co)=>{"use strict";var G=_(),{cursor:Tu}=x(),ku=X(),{clear:vo,figures:oe,style:xo,wrap:Mu,entriesToDisplay:Iu}=j(),$i=class extends ku{constructor(e={}){super(e),this.msg=e.message,this.cursor=e.cursor||0,this.scrollIndex=e.cursor||0,this.hint=e.hint||"",this.warn=e.warn||"- This option is disabled -",this.minSelected=e.min,this.showMinError=!1,this.maxChoices=e.max,this.instructions=e.instructions,this.optionsPerPage=e.optionsPerPage||10,this.value=e.choices.map((t,s)=>(typeof t=="string"&&(t={title:t,value:s}),{title:t&&(t.title||t.value||t),description:t&&t.description,value:t&&(t.value===void 0?s:t.value),selected:t&&t.selected,disabled:t&&t.disabled})),this.clear=vo("",this.out.columns),e.overrideRender||this.render()}reset(){this.value.map(e=>!e.selected),this.cursor=0,this.fire(),this.render()}selected(){return this.value.filter(e=>e.selected)}exit(){this.abort()}abort(){this.done=this.aborted=!0,this.fire(),this.render(),this.out.write(`
94
94
  `),this.close()}submit(){let e=this.value.filter(t=>t.selected);this.minSelected&&e.length<this.minSelected?(this.showMinError=!0,this.render()):(this.done=!0,this.aborted=!1,this.fire(),this.render(),this.out.write(`
95
95
  `),this.close())}first(){this.cursor=0,this.render()}last(){this.cursor=this.value.length-1,this.render()}next(){this.cursor=(this.cursor+1)%this.value.length,this.render()}up(){this.cursor===0?this.cursor=this.value.length-1:this.cursor--,this.render()}down(){this.cursor===this.value.length-1?this.cursor=0:this.cursor++,this.render()}left(){this.value[this.cursor].selected=!1,this.render()}right(){if(this.value.filter(e=>e.selected).length>=this.maxChoices)return this.bell();this.value[this.cursor].selected=!0,this.render()}handleSpaceToggle(){let e=this.value[this.cursor];if(e.selected)e.selected=!1,this.render();else{if(e.disabled||this.value.filter(t=>t.selected).length>=this.maxChoices)return this.bell();e.selected=!0,this.render()}}toggleAll(){if(this.maxChoices!==void 0||this.value[this.cursor].disabled)return this.bell();let e=!this.value[this.cursor].selected;this.value.filter(t=>!t.disabled).forEach(t=>t.selected=e),this.render()}_(e,t){if(e===" ")this.handleSpaceToggle();else if(e==="a")this.toggleAll();else return this.bell()}renderInstructions(){return this.instructions===void 0||this.instructions?typeof this.instructions=="string"?this.instructions:`
96
96
  Instructions:
@@ -98,38 +98,38 @@ Instructions:
98
98
  ${oe.arrowLeft}/${oe.arrowRight}/[space]: Toggle selection
99
99
  `+(this.maxChoices===void 0?` a: Toggle all
100
100
  `:"")+" enter/return: Complete answer":""}renderOption(e,t,s,r){let n=(t.selected?G.green(oe.radioOn):oe.radioOff)+" "+r+" ",o,a;return t.disabled?o=e===s?G.gray().underline(t.title):G.strikethrough().gray(t.title):(o=e===s?G.cyan().underline(t.title):t.title,e===s&&t.description&&(a=` - ${t.description}`,(n.length+o.length+a.length>=this.out.columns||t.description.split(/\r?\n/).length>1)&&(a=`
101
- `+ku(t.description,{margin:n.length,width:this.out.columns})))),n+o+G.gray(a||"")}paginateOptions(e){if(e.length===0)return G.red("No matches for this query.");let{startIndex:t,endIndex:s}=Mu(this.cursor,e.length,this.optionsPerPage),r,n=[];for(let o=t;o<s;o++)o===t&&t>0?r=oe.arrowUp:o===s-1&&s<e.length?r=oe.arrowDown:r=" ",n.push(this.renderOption(this.cursor,e[o],o,r));return`
101
+ `+Mu(t.description,{margin:n.length,width:this.out.columns})))),n+o+G.gray(a||"")}paginateOptions(e){if(e.length===0)return G.red("No matches for this query.");let{startIndex:t,endIndex:s}=Iu(this.cursor,e.length,this.optionsPerPage),r,n=[];for(let o=t;o<s;o++)o===t&&t>0?r=oe.arrowUp:o===s-1&&s<e.length?r=oe.arrowDown:r=" ",n.push(this.renderOption(this.cursor,e[o],o,r));return`
102
102
  `+n.join(`
103
- `)}renderOptions(e){return this.done?"":this.paginateOptions(e)}renderDoneOrInstructions(){if(this.done)return this.value.filter(t=>t.selected).map(t=>t.title).join(", ");let e=[G.gray(this.hint),this.renderInstructions()];return this.value[this.cursor].disabled&&e.push(G.yellow(this.warn)),e.join(" ")}render(){if(this.closed)return;this.firstRender&&this.out.write(qu.hide),super.render();let e=[vo.symbol(this.done,this.aborted),G.bold(this.msg),vo.delimiter(!1),this.renderDoneOrInstructions()].join(" ");this.showMinError&&(e+=G.red(`You must select a minimum of ${this.minSelected} choices.`),this.showMinError=!1),e+=this.renderOptions(this.value),this.out.write(this.clear+e),this.clear=_o(e,this.out.columns)}};xo.exports=Ai});var Ao=c((Yd,$o)=>{"use strict";var Ie=_(),Iu=X(),{erase:Du,cursor:Co}=x(),{style:Ei,clear:Oo,figures:qi,wrap:ju,entriesToDisplay:Vu}=j(),So=(i,e)=>i[e]&&(i[e].value||i[e].title||i[e]),Hu=(i,e)=>i[e]&&(i[e].title||i[e].value||i[e]),Fu=(i,e)=>{let t=i.findIndex(s=>s.value===e||s.title===e);return t>-1?t:void 0},Ti=class extends Iu{constructor(e={}){super(e),this.msg=e.message,this.suggest=e.suggest,this.choices=e.choices,this.initial=typeof e.initial=="number"?e.initial:Fu(e.choices,e.initial),this.select=this.initial||e.cursor||0,this.i18n={noMatches:e.noMatches||"no matches found"},this.fallback=e.fallback||this.initial,this.clearFirst=e.clearFirst||!1,this.suggestions=[],this.input="",this.limit=e.limit||10,this.cursor=0,this.transform=Ei.render(e.style),this.scale=this.transform.scale,this.render=this.render.bind(this),this.complete=this.complete.bind(this),this.clear=Oo("",this.out.columns),this.complete(this.render),this.render()}set fallback(e){this._fb=Number.isSafeInteger(parseInt(e))?parseInt(e):e}get fallback(){let e;return typeof this._fb=="number"?e=this.choices[this._fb]:typeof this._fb=="string"&&(e={title:this._fb}),e||this._fb||{title:this.i18n.noMatches}}moveSelect(e){this.select=e,this.suggestions.length>0?this.value=So(this.suggestions,e):this.value=this.fallback.value,this.fire()}async complete(e){let t=this.completing=this.suggest(this.input,this.choices),s=await t;if(this.completing!==t)return;this.suggestions=s.map((n,o,a)=>({title:Hu(a,o),value:So(a,o),description:n.description})),this.completing=!1;let r=Math.max(s.length-1,0);this.moveSelect(Math.min(r,this.select)),e&&e()}reset(){this.input="",this.complete(()=>{this.moveSelect(this.initial!==void 0?this.initial:0),this.render()}),this.render()}exit(){this.clearFirst&&this.input.length>0?this.reset():(this.done=this.exited=!0,this.aborted=!1,this.fire(),this.render(),this.out.write(`
103
+ `)}renderOptions(e){return this.done?"":this.paginateOptions(e)}renderDoneOrInstructions(){if(this.done)return this.value.filter(t=>t.selected).map(t=>t.title).join(", ");let e=[G.gray(this.hint),this.renderInstructions()];return this.value[this.cursor].disabled&&e.push(G.yellow(this.warn)),e.join(" ")}render(){if(this.closed)return;this.firstRender&&this.out.write(Tu.hide),super.render();let e=[xo.symbol(this.done,this.aborted),G.bold(this.msg),xo.delimiter(!1),this.renderDoneOrInstructions()].join(" ");this.showMinError&&(e+=G.red(`You must select a minimum of ${this.minSelected} choices.`),this.showMinError=!1),e+=this.renderOptions(this.value),this.out.write(this.clear+e),this.clear=vo(e,this.out.columns)}};Co.exports=$i});var Po=c((Ud,Ao)=>{"use strict";var Me=_(),Du=X(),{erase:ju,cursor:Oo}=x(),{style:Pi,clear:So,figures:Ei,wrap:Vu,entriesToDisplay:Hu}=j(),$o=(i,e)=>i[e]&&(i[e].value||i[e].title||i[e]),Fu=(i,e)=>i[e]&&(i[e].title||i[e].value||i[e]),Ru=(i,e)=>{let t=i.findIndex(s=>s.value===e||s.title===e);return t>-1?t:void 0},qi=class extends Du{constructor(e={}){super(e),this.msg=e.message,this.suggest=e.suggest,this.choices=e.choices,this.initial=typeof e.initial=="number"?e.initial:Ru(e.choices,e.initial),this.select=this.initial||e.cursor||0,this.i18n={noMatches:e.noMatches||"no matches found"},this.fallback=e.fallback||this.initial,this.clearFirst=e.clearFirst||!1,this.suggestions=[],this.input="",this.limit=e.limit||10,this.cursor=0,this.transform=Pi.render(e.style),this.scale=this.transform.scale,this.render=this.render.bind(this),this.complete=this.complete.bind(this),this.clear=So("",this.out.columns),this.complete(this.render),this.render()}set fallback(e){this._fb=Number.isSafeInteger(parseInt(e))?parseInt(e):e}get fallback(){let e;return typeof this._fb=="number"?e=this.choices[this._fb]:typeof this._fb=="string"&&(e={title:this._fb}),e||this._fb||{title:this.i18n.noMatches}}moveSelect(e){this.select=e,this.suggestions.length>0?this.value=$o(this.suggestions,e):this.value=this.fallback.value,this.fire()}async complete(e){let t=this.completing=this.suggest(this.input,this.choices),s=await t;if(this.completing!==t)return;this.suggestions=s.map((n,o,a)=>({title:Fu(a,o),value:$o(a,o),description:n.description})),this.completing=!1;let r=Math.max(s.length-1,0);this.moveSelect(Math.min(r,this.select)),e&&e()}reset(){this.input="",this.complete(()=>{this.moveSelect(this.initial!==void 0?this.initial:0),this.render()}),this.render()}exit(){this.clearFirst&&this.input.length>0?this.reset():(this.done=this.exited=!0,this.aborted=!1,this.fire(),this.render(),this.out.write(`
104
104
  `),this.close())}abort(){this.done=this.aborted=!0,this.exited=!1,this.fire(),this.render(),this.out.write(`
105
105
  `),this.close()}submit(){this.done=!0,this.aborted=this.exited=!1,this.fire(),this.render(),this.out.write(`
106
- `),this.close()}_(e,t){let s=this.input.slice(0,this.cursor),r=this.input.slice(this.cursor);this.input=`${s}${e}${r}`,this.cursor=s.length+1,this.complete(this.render),this.render()}delete(){if(this.cursor===0)return this.bell();let e=this.input.slice(0,this.cursor-1),t=this.input.slice(this.cursor);this.input=`${e}${t}`,this.complete(this.render),this.cursor=this.cursor-1,this.render()}deleteForward(){if(this.cursor*this.scale>=this.rendered.length)return this.bell();let e=this.input.slice(0,this.cursor),t=this.input.slice(this.cursor+1);this.input=`${e}${t}`,this.complete(this.render),this.render()}first(){this.moveSelect(0),this.render()}last(){this.moveSelect(this.suggestions.length-1),this.render()}up(){this.select===0?this.moveSelect(this.suggestions.length-1):this.moveSelect(this.select-1),this.render()}down(){this.select===this.suggestions.length-1?this.moveSelect(0):this.moveSelect(this.select+1),this.render()}next(){this.select===this.suggestions.length-1?this.moveSelect(0):this.moveSelect(this.select+1),this.render()}nextPage(){this.moveSelect(Math.min(this.select+this.limit,this.suggestions.length-1)),this.render()}prevPage(){this.moveSelect(Math.max(this.select-this.limit,0)),this.render()}left(){if(this.cursor<=0)return this.bell();this.cursor=this.cursor-1,this.render()}right(){if(this.cursor*this.scale>=this.rendered.length)return this.bell();this.cursor=this.cursor+1,this.render()}renderOption(e,t,s,r){let n,o=s?qi.arrowUp:r?qi.arrowDown:" ",a=t?Ie.cyan().underline(e.title):e.title;return o=(t?Ie.cyan(qi.pointer)+" ":" ")+o,e.description&&(n=` - ${e.description}`,(o.length+a.length+n.length>=this.out.columns||e.description.split(/\r?\n/).length>1)&&(n=`
107
- `+ju(e.description,{margin:3,width:this.out.columns}))),o+" "+a+Ie.gray(n||"")}render(){if(this.closed)return;this.firstRender?this.out.write(Co.hide):this.out.write(Oo(this.outputText,this.out.columns)),super.render();let{startIndex:e,endIndex:t}=Vu(this.select,this.choices.length,this.limit);if(this.outputText=[Ei.symbol(this.done,this.aborted,this.exited),Ie.bold(this.msg),Ei.delimiter(this.completing),this.done&&this.suggestions[this.select]?this.suggestions[this.select].title:this.rendered=this.transform.render(this.input)].join(" "),!this.done){let s=this.suggestions.slice(e,t).map((r,n)=>this.renderOption(r,this.select===n+e,n===0&&e>0,n+e===t-1&&t<this.choices.length)).join(`
106
+ `),this.close()}_(e,t){let s=this.input.slice(0,this.cursor),r=this.input.slice(this.cursor);this.input=`${s}${e}${r}`,this.cursor=s.length+1,this.complete(this.render),this.render()}delete(){if(this.cursor===0)return this.bell();let e=this.input.slice(0,this.cursor-1),t=this.input.slice(this.cursor);this.input=`${e}${t}`,this.complete(this.render),this.cursor=this.cursor-1,this.render()}deleteForward(){if(this.cursor*this.scale>=this.rendered.length)return this.bell();let e=this.input.slice(0,this.cursor),t=this.input.slice(this.cursor+1);this.input=`${e}${t}`,this.complete(this.render),this.render()}first(){this.moveSelect(0),this.render()}last(){this.moveSelect(this.suggestions.length-1),this.render()}up(){this.select===0?this.moveSelect(this.suggestions.length-1):this.moveSelect(this.select-1),this.render()}down(){this.select===this.suggestions.length-1?this.moveSelect(0):this.moveSelect(this.select+1),this.render()}next(){this.select===this.suggestions.length-1?this.moveSelect(0):this.moveSelect(this.select+1),this.render()}nextPage(){this.moveSelect(Math.min(this.select+this.limit,this.suggestions.length-1)),this.render()}prevPage(){this.moveSelect(Math.max(this.select-this.limit,0)),this.render()}left(){if(this.cursor<=0)return this.bell();this.cursor=this.cursor-1,this.render()}right(){if(this.cursor*this.scale>=this.rendered.length)return this.bell();this.cursor=this.cursor+1,this.render()}renderOption(e,t,s,r){let n,o=s?Ei.arrowUp:r?Ei.arrowDown:" ",a=t?Me.cyan().underline(e.title):e.title;return o=(t?Me.cyan(Ei.pointer)+" ":" ")+o,e.description&&(n=` - ${e.description}`,(o.length+a.length+n.length>=this.out.columns||e.description.split(/\r?\n/).length>1)&&(n=`
107
+ `+Vu(e.description,{margin:3,width:this.out.columns}))),o+" "+a+Me.gray(n||"")}render(){if(this.closed)return;this.firstRender?this.out.write(Oo.hide):this.out.write(So(this.outputText,this.out.columns)),super.render();let{startIndex:e,endIndex:t}=Hu(this.select,this.choices.length,this.limit);if(this.outputText=[Pi.symbol(this.done,this.aborted,this.exited),Me.bold(this.msg),Pi.delimiter(this.completing),this.done&&this.suggestions[this.select]?this.suggestions[this.select].title:this.rendered=this.transform.render(this.input)].join(" "),!this.done){let s=this.suggestions.slice(e,t).map((r,n)=>this.renderOption(r,this.select===n+e,n===0&&e>0,n+e===t-1&&t<this.choices.length)).join(`
108
108
  `);this.outputText+=`
109
- `+(s||Ie.gray(this.fallback.title))}this.out.write(Du.line+Co.to(0)+this.outputText)}};$o.exports=Ti});var To=c((Ud,qo)=>{"use strict";var ee=_(),{cursor:Ru}=x(),Nu=Pi(),{clear:Po,style:Eo,figures:be}=j(),ki=class extends Nu{constructor(e={}){e.overrideRender=!0,super(e),this.inputValue="",this.clear=Po("",this.out.columns),this.filteredOptions=this.value,this.render()}last(){this.cursor=this.filteredOptions.length-1,this.render()}next(){this.cursor=(this.cursor+1)%this.filteredOptions.length,this.render()}up(){this.cursor===0?this.cursor=this.filteredOptions.length-1:this.cursor--,this.render()}down(){this.cursor===this.filteredOptions.length-1?this.cursor=0:this.cursor++,this.render()}left(){this.filteredOptions[this.cursor].selected=!1,this.render()}right(){if(this.value.filter(e=>e.selected).length>=this.maxChoices)return this.bell();this.filteredOptions[this.cursor].selected=!0,this.render()}delete(){this.inputValue.length&&(this.inputValue=this.inputValue.substr(0,this.inputValue.length-1),this.updateFilteredOptions())}updateFilteredOptions(){let e=this.filteredOptions[this.cursor];this.filteredOptions=this.value.filter(s=>this.inputValue?!!(typeof s.title=="string"&&s.title.toLowerCase().includes(this.inputValue.toLowerCase())||typeof s.value=="string"&&s.value.toLowerCase().includes(this.inputValue.toLowerCase())):!0);let t=this.filteredOptions.findIndex(s=>s===e);this.cursor=t<0?0:t,this.render()}handleSpaceToggle(){let e=this.filteredOptions[this.cursor];if(e.selected)e.selected=!1,this.render();else{if(e.disabled||this.value.filter(t=>t.selected).length>=this.maxChoices)return this.bell();e.selected=!0,this.render()}}handleInputChange(e){this.inputValue=this.inputValue+e,this.updateFilteredOptions()}_(e,t){e===" "?this.handleSpaceToggle():this.handleInputChange(e)}renderInstructions(){return this.instructions===void 0||this.instructions?typeof this.instructions=="string"?this.instructions:`
109
+ `+(s||Me.gray(this.fallback.title))}this.out.write(ju.line+Oo.to(0)+this.outputText)}};Ao.exports=qi});var ko=c((Wd,To)=>{"use strict";var ee=_(),{cursor:Nu}=x(),Lu=Ai(),{clear:Eo,style:qo,figures:we}=j(),Ti=class extends Lu{constructor(e={}){e.overrideRender=!0,super(e),this.inputValue="",this.clear=Eo("",this.out.columns),this.filteredOptions=this.value,this.render()}last(){this.cursor=this.filteredOptions.length-1,this.render()}next(){this.cursor=(this.cursor+1)%this.filteredOptions.length,this.render()}up(){this.cursor===0?this.cursor=this.filteredOptions.length-1:this.cursor--,this.render()}down(){this.cursor===this.filteredOptions.length-1?this.cursor=0:this.cursor++,this.render()}left(){this.filteredOptions[this.cursor].selected=!1,this.render()}right(){if(this.value.filter(e=>e.selected).length>=this.maxChoices)return this.bell();this.filteredOptions[this.cursor].selected=!0,this.render()}delete(){this.inputValue.length&&(this.inputValue=this.inputValue.substr(0,this.inputValue.length-1),this.updateFilteredOptions())}updateFilteredOptions(){let e=this.filteredOptions[this.cursor];this.filteredOptions=this.value.filter(s=>this.inputValue?!!(typeof s.title=="string"&&s.title.toLowerCase().includes(this.inputValue.toLowerCase())||typeof s.value=="string"&&s.value.toLowerCase().includes(this.inputValue.toLowerCase())):!0);let t=this.filteredOptions.findIndex(s=>s===e);this.cursor=t<0?0:t,this.render()}handleSpaceToggle(){let e=this.filteredOptions[this.cursor];if(e.selected)e.selected=!1,this.render();else{if(e.disabled||this.value.filter(t=>t.selected).length>=this.maxChoices)return this.bell();e.selected=!0,this.render()}}handleInputChange(e){this.inputValue=this.inputValue+e,this.updateFilteredOptions()}_(e,t){e===" "?this.handleSpaceToggle():this.handleInputChange(e)}renderInstructions(){return this.instructions===void 0||this.instructions?typeof this.instructions=="string"?this.instructions:`
110
110
  Instructions:
111
- ${be.arrowUp}/${be.arrowDown}: Highlight option
112
- ${be.arrowLeft}/${be.arrowRight}/[space]: Toggle selection
111
+ ${we.arrowUp}/${we.arrowDown}: Highlight option
112
+ ${we.arrowLeft}/${we.arrowRight}/[space]: Toggle selection
113
113
  [a,b,c]/delete: Filter choices
114
114
  enter/return: Complete answer
115
115
  `:""}renderCurrentInput(){return`
116
116
  Filtered results for: ${this.inputValue?this.inputValue:ee.gray("Enter something to filter")}
117
- `}renderOption(e,t,s){let r;return t.disabled?r=e===s?ee.gray().underline(t.title):ee.strikethrough().gray(t.title):r=e===s?ee.cyan().underline(t.title):t.title,(t.selected?ee.green(be.radioOn):be.radioOff)+" "+r}renderDoneOrInstructions(){if(this.done)return this.value.filter(t=>t.selected).map(t=>t.title).join(", ");let e=[ee.gray(this.hint),this.renderInstructions(),this.renderCurrentInput()];return this.filteredOptions.length&&this.filteredOptions[this.cursor].disabled&&e.push(ee.yellow(this.warn)),e.join(" ")}render(){if(this.closed)return;this.firstRender&&this.out.write(Ru.hide),super.render();let e=[Eo.symbol(this.done,this.aborted),ee.bold(this.msg),Eo.delimiter(!1),this.renderDoneOrInstructions()].join(" ");this.showMinError&&(e+=ee.red(`You must select a minimum of ${this.minSelected} choices.`),this.showMinError=!1),e+=this.renderOptions(this.filteredOptions),this.out.write(this.clear+e),this.clear=Po(e,this.out.columns)}};qo.exports=ki});var jo=c((Wd,Do)=>{var ko=_(),Lu=X(),{style:Mo,clear:Gu}=j(),{erase:Bu,cursor:Io}=x(),Mi=class extends Lu{constructor(e={}){super(e),this.msg=e.message,this.value=e.initial,this.initialValue=!!e.initial,this.yesMsg=e.yes||"yes",this.yesOption=e.yesOption||"(Y/n)",this.noMsg=e.no||"no",this.noOption=e.noOption||"(y/N)",this.render()}reset(){this.value=this.initialValue,this.fire(),this.render()}exit(){this.abort()}abort(){this.done=this.aborted=!0,this.fire(),this.render(),this.out.write(`
117
+ `}renderOption(e,t,s){let r;return t.disabled?r=e===s?ee.gray().underline(t.title):ee.strikethrough().gray(t.title):r=e===s?ee.cyan().underline(t.title):t.title,(t.selected?ee.green(we.radioOn):we.radioOff)+" "+r}renderDoneOrInstructions(){if(this.done)return this.value.filter(t=>t.selected).map(t=>t.title).join(", ");let e=[ee.gray(this.hint),this.renderInstructions(),this.renderCurrentInput()];return this.filteredOptions.length&&this.filteredOptions[this.cursor].disabled&&e.push(ee.yellow(this.warn)),e.join(" ")}render(){if(this.closed)return;this.firstRender&&this.out.write(Nu.hide),super.render();let e=[qo.symbol(this.done,this.aborted),ee.bold(this.msg),qo.delimiter(!1),this.renderDoneOrInstructions()].join(" ");this.showMinError&&(e+=ee.red(`You must select a minimum of ${this.minSelected} choices.`),this.showMinError=!1),e+=this.renderOptions(this.filteredOptions),this.out.write(this.clear+e),this.clear=Eo(e,this.out.columns)}};To.exports=Ti});var Vo=c((Jd,jo)=>{var Mo=_(),Gu=X(),{style:Io,clear:Bu}=j(),{erase:Yu,cursor:Do}=x(),ki=class extends Gu{constructor(e={}){super(e),this.msg=e.message,this.value=e.initial,this.initialValue=!!e.initial,this.yesMsg=e.yes||"yes",this.yesOption=e.yesOption||"(Y/n)",this.noMsg=e.no||"no",this.noOption=e.noOption||"(y/N)",this.render()}reset(){this.value=this.initialValue,this.fire(),this.render()}exit(){this.abort()}abort(){this.done=this.aborted=!0,this.fire(),this.render(),this.out.write(`
118
118
  `),this.close()}submit(){this.value=this.value||!1,this.done=!0,this.aborted=!1,this.fire(),this.render(),this.out.write(`
119
- `),this.close()}_(e,t){return e.toLowerCase()==="y"?(this.value=!0,this.submit()):e.toLowerCase()==="n"?(this.value=!1,this.submit()):this.bell()}render(){this.closed||(this.firstRender?this.out.write(Io.hide):this.out.write(Gu(this.outputText,this.out.columns)),super.render(),this.outputText=[Mo.symbol(this.done,this.aborted),ko.bold(this.msg),Mo.delimiter(this.done),this.done?this.value?this.yesMsg:this.noMsg:ko.gray(this.initialValue?this.yesOption:this.noOption)].join(" "),this.out.write(Bu.line+Io.to(0)+this.outputText))}};Do.exports=Mi});var Ho=c((Jd,Vo)=>{"use strict";Vo.exports={TextPrompt:In(),SelectPrompt:Hn(),TogglePrompt:Ln(),DatePrompt:mo(),NumberPrompt:yo(),MultiselectPrompt:Pi(),AutocompletePrompt:Ao(),AutocompleteMultiselectPrompt:To(),ConfirmPrompt:jo()}});var Ro=c(Fo=>{"use strict";var P=Fo,Yu=Ho(),it=i=>i;function B(i,e,t={}){return new Promise((s,r)=>{let n=new Yu[i](e),o=t.onAbort||it,a=t.onSubmit||it,l=t.onExit||it;n.on("state",e.onState||it),n.on("submit",h=>s(a(h))),n.on("exit",h=>s(l(h))),n.on("abort",h=>r(o(h)))})}P.text=i=>B("TextPrompt",i);P.password=i=>(i.style="password",P.text(i));P.invisible=i=>(i.style="invisible",P.text(i));P.number=i=>B("NumberPrompt",i);P.date=i=>B("DatePrompt",i);P.confirm=i=>B("ConfirmPrompt",i);P.list=i=>{let e=i.separator||",";return B("TextPrompt",i,{onSubmit:t=>t.split(e).map(s=>s.trim())})};P.toggle=i=>B("TogglePrompt",i);P.select=i=>B("SelectPrompt",i);P.multiselect=i=>{i.choices=[].concat(i.choices||[]);let e=t=>t.filter(s=>s.selected).map(s=>s.value);return B("MultiselectPrompt",i,{onAbort:e,onSubmit:e})};P.autocompleteMultiselect=i=>{i.choices=[].concat(i.choices||[]);let e=t=>t.filter(s=>s.selected).map(s=>s.value);return B("AutocompleteMultiselectPrompt",i,{onAbort:e,onSubmit:e})};var Uu=(i,e)=>Promise.resolve(e.filter(t=>t.title.slice(0,i.length).toLowerCase()===i.toLowerCase()));P.autocomplete=i=>(i.suggest=i.suggest||Uu,i.choices=[].concat(i.choices||[]),B("AutocompletePrompt",i))});var Go=c((zd,Lo)=>{"use strict";var Ii=Ro(),Wu=["suggest","format","onState","validate","onRender","type"],No=()=>{};async function ae(i=[],{onSubmit:e=No,onCancel:t=No}={}){let s={},r=ae._override||{};i=[].concat(i);let n,o,a,l,h,d,f=async(p,O,b=!1)=>{if(!(!b&&p.validate&&p.validate(O)!==!0))return p.format?await p.format(O,s):O};for(o of i)if({name:l,type:h}=o,typeof h=="function"&&(h=await h(n,{...s},o),o.type=h),!!h){for(let p in o){if(Wu.includes(p))continue;let O=o[p];o[p]=typeof O=="function"?await O(n,{...s},d):O}if(d=o,typeof o.message!="string")throw new Error("prompt message is required");if({name:l,type:h}=o,Ii[h]===void 0)throw new Error(`prompt type (${h}) is not defined`);if(r[o.name]!==void 0&&(n=await f(o,r[o.name]),n!==void 0)){s[l]=n;continue}try{n=ae._injected?Ju(ae._injected,o.initial):await Ii[h](o),s[l]=n=await f(o,n,!0),a=await e(o,n,s)}catch{a=!await t(o,s)}if(a)return s}return s}function Ju(i,e){let t=i.shift();if(t instanceof Error)throw t;return t===void 0?e:t}function Ku(i){ae._injected=(ae._injected||[]).concat(i)}function zu(i){ae._override=Object.assign({},i)}Lo.exports=Object.assign(ae,{prompt:ae,prompts:Ii,inject:Ku,override:zu})});var De=c((Zd,Bo)=>{function Zu(i){i=(Array.isArray(i)?i:i.split(".")).map(Number);let e=0,t=process.versions.node.split(".").map(Number);for(;e<i.length;e++){if(t[e]>i[e])return!1;if(i[e]>t[e])return!0}return!1}Bo.exports=Zu("8.6.0")?pn():Go()});var as=$(os(),1),{program:Ac,createCommand:Pc,createArgument:Ec,createOption:qc,CommanderError:Tc,InvalidArgumentError:kc,InvalidOptionArgumentError:Mc,Command:ls,Argument:Ic,Option:Dc,Help:jc}=as.default;var Ct,us,cs,ds,fs=!0;typeof process<"u"&&({FORCE_COLOR:Ct,NODE_DISABLE_COLORS:us,NO_COLOR:cs,TERM:ds}=process.env||{},fs=process.stdout&&process.stdout.isTTY);var m={enabled:!us&&cs==null&&ds!=="dumb"&&(Ct!=null&&Ct!=="0"||fs),reset:w(0,0),bold:w(1,22),dim:w(2,22),italic:w(3,23),underline:w(4,24),inverse:w(7,27),hidden:w(8,28),strikethrough:w(9,29),black:w(30,39),red:w(31,39),green:w(32,39),yellow:w(33,39),blue:w(34,39),magenta:w(35,39),cyan:w(36,39),white:w(37,39),gray:w(90,39),grey:w(90,39),bgBlack:w(40,49),bgRed:w(41,49),bgGreen:w(42,49),bgYellow:w(43,49),bgBlue:w(44,49),bgMagenta:w(45,49),bgCyan:w(46,49),bgWhite:w(47,49)};function hs(i,e){let t=0,s,r="",n="";for(;t<i.length;t++)s=i[t],r+=s.open,n+=s.close,~e.indexOf(s.close)&&(e=e.replace(s.rgx,s.close+s.open));return r+e+n}function Wa(i,e){let t={has:i,keys:e};return t.reset=m.reset.bind(t),t.bold=m.bold.bind(t),t.dim=m.dim.bind(t),t.italic=m.italic.bind(t),t.underline=m.underline.bind(t),t.inverse=m.inverse.bind(t),t.hidden=m.hidden.bind(t),t.strikethrough=m.strikethrough.bind(t),t.black=m.black.bind(t),t.red=m.red.bind(t),t.green=m.green.bind(t),t.yellow=m.yellow.bind(t),t.blue=m.blue.bind(t),t.magenta=m.magenta.bind(t),t.cyan=m.cyan.bind(t),t.white=m.white.bind(t),t.gray=m.gray.bind(t),t.grey=m.grey.bind(t),t.bgBlack=m.bgBlack.bind(t),t.bgRed=m.bgRed.bind(t),t.bgGreen=m.bgGreen.bind(t),t.bgYellow=m.bgYellow.bind(t),t.bgBlue=m.bgBlue.bind(t),t.bgMagenta=m.bgMagenta.bind(t),t.bgCyan=m.bgCyan.bind(t),t.bgWhite=m.bgWhite.bind(t),t}function w(i,e){let t={open:`\x1B[${i}m`,close:`\x1B[${e}m`,rgx:new RegExp(`\\x1b\\[${e}m`,"g")};return function(s){return this!==void 0&&this.has!==void 0?(~this.has.indexOf(i)||(this.has.push(i),this.keys.push(t)),s===void 0?this:m.enabled?hs(this.keys,s+""):s+""):s===void 0?Wa([i],[t]):m.enabled?hs([t],s+""):s+""}}var u=m;var st=$(De(),1),Vi=$(require("node:readline"),1);var de=$(require("node:fs"),1),we=$(require("node:path"),1),Uo=$(require("node:os"),1),Xu=we.default.join(Uo.default.homedir(),".flapcode"),Qu=we.default.join(Xu,"config.json"),ec=we.default.join(process.cwd(),".flapcode"),Yo=we.default.join(ec,"config.json"),Di={api_base:"https://flapcode.com",api_token:null,current_claude_account:null,current_codex_account:null};function S(){let i=Jo();if(!de.default.existsSync(i))return{...Di};try{return{...Di,...JSON.parse(de.default.readFileSync(i,"utf8"))}}catch{return{...Di}}}function V(i){let e=Jo(),t=we.default.dirname(e);de.default.existsSync(t)||de.default.mkdirSync(t,{recursive:!0});let s=S();de.default.writeFileSync(e,JSON.stringify({...s,...i},null,2),"utf8")}function Wo(){V({api_token:null})}function Jo(){return de.default.existsSync(Yo)?Yo:Qu}var le=class extends Error{constructor(e,t){super(e),this.statusCode=t}};async function je(i,e={}){let t=S();if(!t.api_token)throw new le("\u672A\u767B\u5F55\uFF0C\u8BF7\u5148\u8FD0\u884C flapcode login",401);let s=`${t.api_base}${i}`,r=await fetch(s,{...e,headers:{Authorization:`Bearer ${t.api_token}`,"Content-Type":"application/json",...e.headers}}),n=await r.json().catch(()=>({statusMessage:r.statusText}));if(!r.ok)throw new le(n.statusMessage||n.message||`HTTP ${r.status}`,r.status);return n}async function tc(i,e={}){let s=`${S().api_base}${i}`,r=await fetch(s,{...e,headers:{"Content-Type":"application/json",...e.headers}}),n=await r.json().catch(()=>({statusMessage:r.statusText}));if(!r.ok)throw new le(n.statusMessage||n.message||`HTTP ${r.status}`,r.status);return n}async function H(i){return je(`/api/cli/accounts?provider=${i}`)}async function te(i,e){let t=e?`?provider=${i}&account_email=${encodeURIComponent(e)}`:`?provider=${i}`;return je(`/api/cli/config${t}`)}async function Ko(){return je("/api/cli/me")}async function zo(i,e){let t=await tc("/api/auth/login",{method:"POST",body:JSON.stringify({email:i,password:e})});if(t?.code!==0||!t?.data?.token)throw new le(t?.message||"\u767B\u5F55\u5931\u8D25",401);return t.data}async function Zo(i){let t=`${S().api_base}/api/user/get-api-token`,s=await fetch(t,{method:"GET",headers:{Authorization:`Bearer ${i}`,"Content-Type":"application/json"}}),r=await s.json().catch(()=>({statusMessage:s.statusText}));if(!s.ok)throw new le(r.statusMessage||r.message||`HTTP ${s.status}`,s.status);if(r?.code!==0||!r?.data?.api_token)throw new le(r?.message||"\u83B7\u53D6 API Token \u5931\u8D25",500);return r.data.api_token}async function Xo(i={}){if(S().api_token)if(console.log(u.yellow("\u5DF2\u767B\u5F55\u3002\u5982\u9700\u91CD\u65B0\u767B\u5F55\uFF0C\u8BF7\u5148\u8FD0\u884C flapcode logout")),i.token)console.log(u.dim("\u68C0\u6D4B\u5230 --token\uFF0C\u8986\u76D6\u73B0\u6709 token"));else{let{confirm:n}=await(0,st.default)({type:"confirm",name:"confirm",message:"\u662F\u5426\u8986\u76D6\u73B0\u6709 token\uFF1F",initial:!1});if(!n)return}let t=i.token?.trim(),s=i.email?.trim(),r;if(!t&&s&&(r=await ji("\u8BF7\u8F93\u5165\u767B\u5F55\u5BC6\u7801: ")),!t&&!s&&(await sc()==="password"?(s=(await rc("\u8BF7\u8F93\u5165\u767B\u5F55\u90AE\u7BB1: ")).trim(),r=await ji("\u8BF7\u8F93\u5165\u767B\u5F55\u5BC6\u7801: ")):t=await ji("\u8BF7\u7C98\u8D34 Flapcode API Token\uFF08\u53EF\u5728\u201C\u4E2A\u4EBA\u4E2D\u5FC3\u201D -> \u201CAPI \u8BBF\u95EE\u4EE4\u724C\u201D\u4E2D\u83B7\u53D6\uFF09: ")),!t&&s){if(!r){console.log(u.red("\u5DF2\u53D6\u6D88"));return}let n=await zo(s,r);t=await Zo(n.token)}if(!t){console.log(u.red("\u5DF2\u53D6\u6D88"));return}V({api_token:t});try{let n=await je("/api/cli/me");await ic(),console.log(u.green(`\u2713 \u767B\u5F55\u6210\u529F\uFF01\u5F53\u524D\u7528\u6237\uFF1A${n.email??n.username??JSON.stringify(n)}`))}catch(n){V({api_token:null}),console.error(u.red(`\u2717 Token \u9A8C\u8BC1\u5931\u8D25\uFF1A${n.message}`)),process.exit(1)}}async function ic(){let i=S(),e={};if(!i.current_claude_account){let t=await H("claude").catch(()=>[]);t.length>0&&(e.current_claude_account=t[0].account_email)}if(!i.current_codex_account){let t=await H("codex").catch(()=>[]);t.length>0&&(e.current_codex_account=t[0].account_email)}Object.keys(e).length>0&&V(e)}async function sc(){return(await(0,st.default)({type:"select",name:"mode",message:"\u9009\u62E9\u767B\u5F55\u65B9\u5F0F",choices:[{title:"API Token",value:"token"},{title:"\u90AE\u7BB1\u548C\u5BC6\u7801",value:"password"}],initial:0})).mode??"token"}async function rc(i){return await new Promise(e=>{let t=Vi.default.createInterface({input:process.stdin,output:process.stdout});t.question(i,s=>{t.close(),process.stdin.isTTY&&process.stdin.pause(),e(s)})})}async function ji(i){return!process.stdin.isTTY||!process.stdout.isTTY?(await(0,st.default)({type:"password",name:"token",message:i.trim(),validate:t=>t.trim().length>0||"\u4E0D\u80FD\u4E3A\u7A7A"})).token?.trim():await new Promise(e=>{let t=process.stdin,s=process.stdout,r=t.isRaw===!0,n="";Vi.default.emitKeypressEvents(t),t.setRawMode(!0),t.resume(),s.write(i);let o=(l,h)=>{if(h?.ctrl&&h.name==="c"&&(a(),s.write(`
119
+ `),this.close()}_(e,t){return e.toLowerCase()==="y"?(this.value=!0,this.submit()):e.toLowerCase()==="n"?(this.value=!1,this.submit()):this.bell()}render(){this.closed||(this.firstRender?this.out.write(Do.hide):this.out.write(Bu(this.outputText,this.out.columns)),super.render(),this.outputText=[Io.symbol(this.done,this.aborted),Mo.bold(this.msg),Io.delimiter(this.done),this.done?this.value?this.yesMsg:this.noMsg:Mo.gray(this.initialValue?this.yesOption:this.noOption)].join(" "),this.out.write(Yu.line+Do.to(0)+this.outputText))}};jo.exports=ki});var Fo=c((Kd,Ho)=>{"use strict";Ho.exports={TextPrompt:Dn(),SelectPrompt:Fn(),TogglePrompt:Gn(),DatePrompt:go(),NumberPrompt:_o(),MultiselectPrompt:Ai(),AutocompletePrompt:Po(),AutocompleteMultiselectPrompt:ko(),ConfirmPrompt:Vo()}});var No=c(Ro=>{"use strict";var P=Ro,Uu=Fo(),tt=i=>i;function B(i,e,t={}){return new Promise((s,r)=>{let n=new Uu[i](e),o=t.onAbort||tt,a=t.onSubmit||tt,l=t.onExit||tt;n.on("state",e.onState||tt),n.on("submit",h=>s(a(h))),n.on("exit",h=>s(l(h))),n.on("abort",h=>r(o(h)))})}P.text=i=>B("TextPrompt",i);P.password=i=>(i.style="password",P.text(i));P.invisible=i=>(i.style="invisible",P.text(i));P.number=i=>B("NumberPrompt",i);P.date=i=>B("DatePrompt",i);P.confirm=i=>B("ConfirmPrompt",i);P.list=i=>{let e=i.separator||",";return B("TextPrompt",i,{onSubmit:t=>t.split(e).map(s=>s.trim())})};P.toggle=i=>B("TogglePrompt",i);P.select=i=>B("SelectPrompt",i);P.multiselect=i=>{i.choices=[].concat(i.choices||[]);let e=t=>t.filter(s=>s.selected).map(s=>s.value);return B("MultiselectPrompt",i,{onAbort:e,onSubmit:e})};P.autocompleteMultiselect=i=>{i.choices=[].concat(i.choices||[]);let e=t=>t.filter(s=>s.selected).map(s=>s.value);return B("AutocompleteMultiselectPrompt",i,{onAbort:e,onSubmit:e})};var Wu=(i,e)=>Promise.resolve(e.filter(t=>t.title.slice(0,i.length).toLowerCase()===i.toLowerCase()));P.autocomplete=i=>(i.suggest=i.suggest||Wu,i.choices=[].concat(i.choices||[]),B("AutocompletePrompt",i))});var Bo=c((Zd,Go)=>{"use strict";var Mi=No(),Ju=["suggest","format","onState","validate","onRender","type"],Lo=()=>{};async function ae(i=[],{onSubmit:e=Lo,onCancel:t=Lo}={}){let s={},r=ae._override||{};i=[].concat(i);let n,o,a,l,h,d,f=async(p,O,b=!1)=>{if(!(!b&&p.validate&&p.validate(O)!==!0))return p.format?await p.format(O,s):O};for(o of i)if({name:l,type:h}=o,typeof h=="function"&&(h=await h(n,{...s},o),o.type=h),!!h){for(let p in o){if(Ju.includes(p))continue;let O=o[p];o[p]=typeof O=="function"?await O(n,{...s},d):O}if(d=o,typeof o.message!="string")throw new Error("prompt message is required");if({name:l,type:h}=o,Mi[h]===void 0)throw new Error(`prompt type (${h}) is not defined`);if(r[o.name]!==void 0&&(n=await f(o,r[o.name]),n!==void 0)){s[l]=n;continue}try{n=ae._injected?Ku(ae._injected,o.initial):await Mi[h](o),s[l]=n=await f(o,n,!0),a=await e(o,n,s)}catch{a=!await t(o,s)}if(a)return s}return s}function Ku(i,e){let t=i.shift();if(t instanceof Error)throw t;return t===void 0?e:t}function zu(i){ae._injected=(ae._injected||[]).concat(i)}function Zu(i){ae._override=Object.assign({},i)}Go.exports=Object.assign(ae,{prompt:ae,prompts:Mi,inject:zu,override:Zu})});var Ie=c((Xd,Yo)=>{function Xu(i){i=(Array.isArray(i)?i:i.split(".")).map(Number);let e=0,t=process.versions.node.split(".").map(Number);for(;e<i.length;e++){if(t[e]>i[e])return!1;if(i[e]>t[e])return!0}return!1}Yo.exports=Xu("8.6.0")?mn():Bo()});var ls=$(as(),1),{program:Pc,createCommand:Ec,createArgument:qc,createOption:Tc,CommanderError:kc,InvalidArgumentError:Mc,InvalidOptionArgumentError:Ic,Command:hs,Argument:Dc,Option:jc,Help:Vc}=ls.default;var xt,cs,ds,fs,ps=!0;typeof process<"u"&&({FORCE_COLOR:xt,NODE_DISABLE_COLORS:cs,NO_COLOR:ds,TERM:fs}=process.env||{},ps=process.stdout&&process.stdout.isTTY);var m={enabled:!cs&&ds==null&&fs!=="dumb"&&(xt!=null&&xt!=="0"||ps),reset:w(0,0),bold:w(1,22),dim:w(2,22),italic:w(3,23),underline:w(4,24),inverse:w(7,27),hidden:w(8,28),strikethrough:w(9,29),black:w(30,39),red:w(31,39),green:w(32,39),yellow:w(33,39),blue:w(34,39),magenta:w(35,39),cyan:w(36,39),white:w(37,39),gray:w(90,39),grey:w(90,39),bgBlack:w(40,49),bgRed:w(41,49),bgGreen:w(42,49),bgYellow:w(43,49),bgBlue:w(44,49),bgMagenta:w(45,49),bgCyan:w(46,49),bgWhite:w(47,49)};function us(i,e){let t=0,s,r="",n="";for(;t<i.length;t++)s=i[t],r+=s.open,n+=s.close,~e.indexOf(s.close)&&(e=e.replace(s.rgx,s.close+s.open));return r+e+n}function Ja(i,e){let t={has:i,keys:e};return t.reset=m.reset.bind(t),t.bold=m.bold.bind(t),t.dim=m.dim.bind(t),t.italic=m.italic.bind(t),t.underline=m.underline.bind(t),t.inverse=m.inverse.bind(t),t.hidden=m.hidden.bind(t),t.strikethrough=m.strikethrough.bind(t),t.black=m.black.bind(t),t.red=m.red.bind(t),t.green=m.green.bind(t),t.yellow=m.yellow.bind(t),t.blue=m.blue.bind(t),t.magenta=m.magenta.bind(t),t.cyan=m.cyan.bind(t),t.white=m.white.bind(t),t.gray=m.gray.bind(t),t.grey=m.grey.bind(t),t.bgBlack=m.bgBlack.bind(t),t.bgRed=m.bgRed.bind(t),t.bgGreen=m.bgGreen.bind(t),t.bgYellow=m.bgYellow.bind(t),t.bgBlue=m.bgBlue.bind(t),t.bgMagenta=m.bgMagenta.bind(t),t.bgCyan=m.bgCyan.bind(t),t.bgWhite=m.bgWhite.bind(t),t}function w(i,e){let t={open:`\x1B[${i}m`,close:`\x1B[${e}m`,rgx:new RegExp(`\\x1b\\[${e}m`,"g")};return function(s){return this!==void 0&&this.has!==void 0?(~this.has.indexOf(i)||(this.has.push(i),this.keys.push(t)),s===void 0?this:m.enabled?us(this.keys,s+""):s+""):s===void 0?Ja([i],[t]):m.enabled?us([t],s+""):s+""}}var u=m;var it=$(Ie(),1),ji=$(require("node:readline"),1);var de=$(require("node:fs"),1),ye=$(require("node:path"),1),Wo=$(require("node:os"),1),Qu=ye.default.join(Wo.default.homedir(),".flapcode"),ec=ye.default.join(Qu,"config.json"),tc=ye.default.join(process.cwd(),".flapcode"),Uo=ye.default.join(tc,"config.json"),Ii={api_base:"https://flapcode.com",api_token:null,current_claude_account:null,current_codex_account:null};function S(){let i=Ko();if(!de.default.existsSync(i))return{...Ii};try{return{...Ii,...JSON.parse(de.default.readFileSync(i,"utf8"))}}catch{return{...Ii}}}function V(i){let e=Ko(),t=ye.default.dirname(e);de.default.existsSync(t)||de.default.mkdirSync(t,{recursive:!0});let s=S();de.default.writeFileSync(e,JSON.stringify({...s,...i},null,2),"utf8")}function Jo(){V({api_token:null})}function Ko(){return de.default.existsSync(Uo)?Uo:ec}var le=class extends Error{constructor(e,t){super(e),this.statusCode=t}};async function De(i,e={}){let t=S();if(!t.api_token)throw new le("\u672A\u767B\u5F55\uFF0C\u8BF7\u5148\u8FD0\u884C flapcode login",401);let s=`${t.api_base}${i}`,r=await fetch(s,{...e,headers:{Authorization:`Bearer ${t.api_token}`,"Content-Type":"application/json",...e.headers}}),n=await r.json().catch(()=>({statusMessage:r.statusText}));if(!r.ok)throw new le(n.statusMessage||n.message||`HTTP ${r.status}`,r.status);return n}async function ic(i,e={}){let s=`${S().api_base}${i}`,r=await fetch(s,{...e,headers:{"Content-Type":"application/json",...e.headers}}),n=await r.json().catch(()=>({statusMessage:r.statusText}));if(!r.ok)throw new le(n.statusMessage||n.message||`HTTP ${r.status}`,r.status);return n}async function H(i){return De(`/api/cli/accounts?provider=${i}`)}async function te(i,e){let t=e?`?provider=${i}&account_email=${encodeURIComponent(e)}`:`?provider=${i}`;return De(`/api/cli/config${t}`)}async function zo(){return De("/api/cli/me")}async function Zo(i,e){let t=await ic("/api/auth/login",{method:"POST",body:JSON.stringify({email:i,password:e})});if(t?.code!==0||!t?.data?.token)throw new le(t?.message||"\u767B\u5F55\u5931\u8D25",401);return t.data}async function Xo(i){let t=`${S().api_base}/api/user/get-api-token`,s=await fetch(t,{method:"GET",headers:{Authorization:`Bearer ${i}`,"Content-Type":"application/json"}}),r=await s.json().catch(()=>({statusMessage:s.statusText}));if(!s.ok)throw new le(r.statusMessage||r.message||`HTTP ${s.status}`,s.status);if(r?.code!==0||!r?.data?.api_token)throw new le(r?.message||"\u83B7\u53D6 API Token \u5931\u8D25",500);return r.data.api_token}async function Qo(i={}){if(S().api_token)if(console.log(u.yellow("\u5DF2\u767B\u5F55\u3002\u5982\u9700\u91CD\u65B0\u767B\u5F55\uFF0C\u8BF7\u5148\u8FD0\u884C flapcode logout")),i.token)console.log(u.dim("\u68C0\u6D4B\u5230 --token\uFF0C\u8986\u76D6\u73B0\u6709 token"));else{let{confirm:n}=await(0,it.default)({type:"confirm",name:"confirm",message:"\u662F\u5426\u8986\u76D6\u73B0\u6709 token\uFF1F",initial:!1});if(!n)return}let t=i.token?.trim(),s=i.email?.trim(),r;if(!t&&s&&(r=await Di("\u8BF7\u8F93\u5165\u767B\u5F55\u5BC6\u7801: ")),!t&&!s&&(await rc()==="password"?(s=(await nc("\u8BF7\u8F93\u5165\u767B\u5F55\u90AE\u7BB1: ")).trim(),r=await Di("\u8BF7\u8F93\u5165\u767B\u5F55\u5BC6\u7801: ")):t=await Di("\u8BF7\u7C98\u8D34 Flapcode API Token\uFF08\u53EF\u5728\u201C\u4E2A\u4EBA\u4E2D\u5FC3\u201D -> \u201CAPI \u8BBF\u95EE\u4EE4\u724C\u201D\u4E2D\u83B7\u53D6\uFF09: ")),!t&&s){if(!r){console.log(u.red("\u5DF2\u53D6\u6D88"));return}let n=await Zo(s,r);t=await Xo(n.token)}if(!t){console.log(u.red("\u5DF2\u53D6\u6D88"));return}V({api_token:t});try{let n=await De("/api/cli/me");await sc(),console.log(u.green(`\u2713 \u767B\u5F55\u6210\u529F\uFF01\u5F53\u524D\u7528\u6237\uFF1A${n.email??n.username??JSON.stringify(n)}`))}catch(n){V({api_token:null}),console.error(u.red(`\u2717 Token \u9A8C\u8BC1\u5931\u8D25\uFF1A${n.message}`)),process.exit(1)}}async function sc(){let i=S(),e={};if(!i.current_claude_account){let t=await H("claude").catch(()=>[]);t.length>0&&(e.current_claude_account=t[0].account_email)}if(!i.current_codex_account){let t=await H("codex").catch(()=>[]);t.length>0&&(e.current_codex_account=t[0].account_email)}Object.keys(e).length>0&&V(e)}async function rc(){return(await(0,it.default)({type:"select",name:"mode",message:"\u9009\u62E9\u767B\u5F55\u65B9\u5F0F",choices:[{title:"API Token",value:"token"},{title:"\u90AE\u7BB1\u548C\u5BC6\u7801",value:"password"}],initial:0})).mode??"token"}async function nc(i){return await new Promise(e=>{let t=ji.default.createInterface({input:process.stdin,output:process.stdout});t.question(i,s=>{t.close(),process.stdin.isTTY&&process.stdin.pause(),e(s)})})}async function Di(i){return!process.stdin.isTTY||!process.stdout.isTTY?(await(0,it.default)({type:"password",name:"token",message:i.trim(),validate:t=>t.trim().length>0||"\u4E0D\u80FD\u4E3A\u7A7A"})).token?.trim():await new Promise(e=>{let t=process.stdin,s=process.stdout,r=t.isRaw===!0,n="";ji.default.emitKeypressEvents(t),t.setRawMode(!0),t.resume(),s.write(i);let o=(l,h)=>{if(h?.ctrl&&h.name==="c"&&(a(),s.write(`
120
120
  `),process.exit(130)),h?.name==="escape"){a(),s.write(`
121
121
  `),e("");return}if(h?.name==="return"||h?.name==="enter"){a(),s.write(`
122
- `),e(n.trim());return}if(h?.name==="backspace"){if(!n.length)return;n=n.slice(0,-1),s.write("\b \b");return}!l||h?.ctrl||h?.meta||(n+=l,s.write("*"))};function a(){t.off("keypress",o),t.isTTY&&t.setRawMode(r),t.pause()}t.on("keypress",o)})}var Qo=$(De(),1);async function ea(){if(!S().api_token){console.log(u.yellow("\u5F53\u524D\u672A\u767B\u5F55"));return}let{confirm:e}=await(0,Qo.default)({type:"confirm",name:"confirm",message:"\u786E\u8BA4\u9000\u51FA\u767B\u5F55\uFF1F",initial:!1});if(!e){console.log("\u5DF2\u53D6\u6D88");return}Wo(),console.log(u.green("\u2713 \u5DF2\u9000\u51FA\u767B\u5F55"))}var ye=require("node:child_process"),nc="https://registry.npmjs.org";function _e(){try{(0,ye.execSync)("npm --version",{stdio:"ignore"})}catch{throw new Error("\u672A\u627E\u5230 npm\uFF0C\u8BF7\u5148\u5B89\u88C5 Node.js\uFF08https://nodejs.org\uFF09")}}function rt(i){try{let e=(0,ye.execSync)("npm list -g --depth=0 --json",{encoding:"utf8"}),t=JSON.parse(e);return i in(t.dependencies||{})}catch{return!1}}function ve(i){let e=(0,ye.spawnSync)("npm",["install","-g",i],{stdio:"inherit",encoding:"utf8"});if(e.status!==0)throw new Error(`npm install -g ${i} \u5931\u8D25\uFF08exit code ${e.status}\uFF09`)}function xe(i){try{let e=(0,ye.execSync)("npm list -g --depth=0 --json",{encoding:"utf8"});return JSON.parse(e).dependencies?.[i]?.version??null}catch{return null}}async function ta(i){try{let e=await fetch(`${nc}/${encodeURIComponent(i)}`,{headers:{Accept:"application/json"}});return e.ok?(await e.json())?.["dist-tags"]?.latest??null:null}catch{return null}}function ia(i,e){let t=String(i||"").split(".").map(n=>Number.parseInt(n,10)||0),s=String(e||"").split(".").map(n=>Number.parseInt(n,10)||0),r=Math.max(t.length,s.length);for(let n=0;n<r;n+=1){let o=t[n]??0,a=s[n]??0;if(o>a)return 1;if(o<a)return-1}return 0}var sa=require("node:child_process"),M=$(require("node:fs"),1),ra=$(require("node:os"),1),ie=$(require("node:path"),1),oc=ie.default.join("@anthropic-ai","claude-code");function ac(){return process.platform!=="linux"?null:process.arch==="x64"?ie.default.join("node_modules","@anthropic-ai","claude-code-linux-x64","claude"):process.arch==="arm64"?ie.default.join("node_modules","@anthropic-ai","claude-code-linux-arm64","claude"):null}function lc(){try{return(0,sa.execSync)("npm root -g",{encoding:"utf8"}).trim()}catch{return null}}function Hi(){let i=[],e=new Set,t=(a,l)=>{!a||e.has(a)||M.default.existsSync(a)&&(e.add(a),i.push({path:a,type:l}))},s=lc(),r=ac();if(s){let a=ie.default.join(s,oc);t(ie.default.join(a,"cli.js"),"js"),r&&t(ie.default.join(a,r),"binary")}let n=process.env.XDG_BIN_HOME||ie.default.join(ra.default.homedir(),".local","bin"),o=ie.default.join(n,"claude");if(M.default.existsSync(o)){let a=o;try{a=M.default.realpathSync(o)}catch{}t(a,"binary")}if(i.length===0){let a=r?"\uFF08\u5DF2\u5C1D\u8BD5 npm root -g \u4E0B\u7684 cli.js / \u539F\u751F binary\uFF0C\u4EE5\u53CA ~/.local/bin/claude\uFF09":"\uFF08\u5DF2\u5C1D\u8BD5 npm root -g \u4E0B\u7684 cli.js \u4E0E ~/.local/bin/claude\uFF1B\u5F53\u524D\u5E73\u53F0\u6682\u672A\u652F\u6301 npm \u5305\u5185\u7684\u539F\u751F binary patch\uFF09";throw new Error(`\u627E\u4E0D\u5230 claude-code \u5B89\u88C5\u76EE\u6807 ${a}\uFF0C\u8BF7\u5148\u8FD0\u884C flapcode claude install`)}return i}function na(i){let e=`${i}.bak`;M.default.existsSync(e)||M.default.copyFileSync(i,e)}function hc(i,e){let t=M.default.readFileSync(i,"utf8");if(e.every(({from:r})=>!t.includes(r)))return{patched:!1,alreadyPatched:!0};na(i);for(let{from:r,to:n}of e)t.includes(r)&&(t=t.split(r).join(n));return M.default.writeFileSync(i,t,"utf8"),{patched:!0,alreadyPatched:!1}}function uc(i,e){let t=M.default.readFileSync(i),s=[],r=[];for(let{from:o,to:a}of e){let l=Buffer.from(o,"utf8"),h=Buffer.from(a,"utf8");if(l.length!==h.length){r.push({from:o,to:a,fromBytes:l.length,toBytes:h.length,reason:"length-mismatch"});continue}s.push({fromBuf:l,toBuf:h})}if(s.length===0)return{patched:!1,alreadyPatched:!1,skippedRules:r};if(s.every(({fromBuf:o})=>!t.includes(o)))return{patched:!1,alreadyPatched:!0,skippedRules:r};na(i);for(let{fromBuf:o,toBuf:a}of s){let l=0;for(;(l=t.indexOf(o,l))!==-1;)a.copy(t,l),l+=a.length}return M.default.writeFileSync(i,t),{patched:!0,alreadyPatched:!1,skippedRules:r}}function oa(i){let e=Hi(),t=!1,s=!0,r=new Map;for(let{path:n,type:o}of e){let a=o==="binary"?uc(n,i):hc(n,i);if(a.patched&&(t=!0),a.alreadyPatched||(s=!1),a.skippedRules)for(let l of a.skippedRules)r.has(l.from)||r.set(l.from,l)}return{patched:t,alreadyPatched:!t&&s,skippedBinaryRules:[...r.values()]}}function aa({path:i,type:e}){try{return e==="binary"?M.default.readFileSync(i):M.default.readFileSync(i,"utf8")}catch{return null}}function la(i,e){return i===null?!1:Buffer.isBuffer(i)?i.includes(Buffer.from(e,"utf8")):i.includes(e)}function ha(i){let e;try{e=Hi()}catch{return null}let t=e.map(aa);return i.map(({from:s,to:r})=>({from:s,to:r,applied:t.every(n=>!la(n,s))}))}function ua(){try{let i=Hi();return i.length===0?!1:i.every(e=>la(aa(e),"gate.flapcode.com"))}catch{return!1}}var cc="@flapcode/cli",dc=10;async function da(){let i=S();if(await fc(),!i.api_token){console.log(),console.log(u.red("\u2717 \u672A\u767B\u5F55")+" \u2192 \u8FD0\u884C flapcode login");return}let e="...";try{let s=await Ko();e=s.email??s.username??"(\u672A\u77E5)",E("\u767B\u5F55\u72B6\u6001",u.green("\u2713 \u5DF2\u767B\u5F55"),u.dim(e))}catch(s){E("\u767B\u5F55\u72B6\u6001",u.red("\u2717 \u767B\u5F55\u5931\u6548"),u.dim(s.message))}fe("\u767B\u5F55\u7F51\u7AD9",i.api_base),console.log(u.bold(`
123
- Claude Code`));let t=xe("@anthropic-ai/claude-code");if(t?E("\u5B89\u88C5\u72B6\u6001",u.green("\u2713 \u5DF2\u5B89\u88C5"),`v${t}`):E("\u5B89\u88C5\u72B6\u6001",u.yellow("\u2717 \u672A\u5B89\u88C5"),"\u2192 \u8FD0\u884C flapcode claude install"),i.current_claude_account?fe("\u5F53\u524D\u8D26\u53F7",u.cyan(i.current_claude_account)):fe("\u5F53\u524D\u8D26\u53F7",u.dim("\u672A\u8BBE\u7F6E")),t)try{if(ua())return E("Patch",u.green("\u2713 \u5DF2\u751F\u6548")),ca(i);let r=(i.current_claude_account?await te("claude",i.current_claude_account).catch(()=>null):null)?.patch_rules;r?.length?ha(r)?.every(a=>a.applied)?E("Patch",u.green("\u2713 \u5DF2\u751F\u6548")):E("Patch",u.yellow("\u2717 \u672A\u751F\u6548"),"\u2192 \u8FD0\u884C flapcode claude patch"):i.current_claude_account?E("Patch",u.dim("\u672A\u77E5"),"\uFF08\u65E0\u6CD5\u83B7\u53D6 patch \u89C4\u5219\uFF09"):E("Patch",u.dim("\u672A\u77E5"),"\uFF08\u672A\u8BBE\u7F6E Claude \u8D26\u53F7\uFF0C\u65E0\u6CD5\u83B7\u53D6 patch \u89C4\u5219\uFF09")}catch{E("Patch",u.dim("\u672A\u77E5"),"\uFF08\u68C0\u67E5\u5931\u8D25\uFF09")}ca(i)}async function fc(){console.log(u.bold("Flapcode CLI")),E("\u5F53\u524D\u7248\u672C",u.green("\u2713 \u5DF2\u5B89\u88C5"),"v1.3.1");let i=await ta(cc);if(!i){fe("\u6700\u65B0\u7248\u672C",u.dim("\u68C0\u67E5\u5931\u8D25\u6216\u7F51\u7EDC\u4E0D\u53EF\u7528"));return}fe("\u6700\u65B0\u7248\u672C",`v${i}`),ia("1.3.1",i)<0&&E("\u5347\u7EA7\u63D0\u793A",u.yellow("\u21BB \u53EF\u5347\u7EA7"),"\u8FD0\u884C flapcode update")}function ca(i){console.log(u.bold(`
124
- Codex`));let e=xe("@openai/codex");e?E("\u5B89\u88C5\u72B6\u6001",u.green("\u2713 \u5DF2\u5B89\u88C5"),`v${e}`):E("\u5B89\u88C5\u72B6\u6001",u.yellow("\u2717 \u672A\u5B89\u88C5"),"\u2192 \u8FD0\u884C flapcode codex install"),i.current_codex_account?fe("\u5F53\u524D\u8D26\u53F7",u.cyan(i.current_codex_account)):fe("\u5F53\u524D\u8D26\u53F7",u.dim("\u672A\u8BBE\u7F6E")),console.log()}function fe(i,e){let t=fa(i);console.log(` ${u.dim(t)} ${e}`)}function E(i,e,t=""){let s=fa(i);console.log(` ${u.dim(s)} ${e}${t?` ${t}`:""}`)}function fa(i){let e=`${i}:`,t=pc(e),s=Math.max(1,dc-t);return`${e}${" ".repeat(s)}`}function pc(i){let e=0;for(let t of i)e+=mc(t)?2:1;return e}function mc(i){return/[^\u0000-\u00ff]/.test(i)}async function pa(i){let e=i.provider??null,t=S(),s=e?[e]:["claude","codex"],r=!1;for(let n of s){let o;try{o=await H(n)}catch(l){console.error(u.red(`\u2717 \u83B7\u53D6 ${n} \u8D26\u53F7\u5931\u8D25\uFF1A${l.message}`));continue}if(!Array.isArray(o)||o.length===0){console.log(u.yellow(` ${n}\uFF1A\u6682\u65E0\u53EF\u7528\u8D26\u53F7`));continue}console.log(u.bold(`
122
+ `),e(n.trim());return}if(h?.name==="backspace"){if(!n.length)return;n=n.slice(0,-1),s.write("\b \b");return}!l||h?.ctrl||h?.meta||(n+=l,s.write("*"))};function a(){t.off("keypress",o),t.isTTY&&t.setRawMode(r),t.pause()}t.on("keypress",o)})}var ea=$(Ie(),1);async function ta(){if(!S().api_token){console.log(u.yellow("\u5F53\u524D\u672A\u767B\u5F55"));return}let{confirm:e}=await(0,ea.default)({type:"confirm",name:"confirm",message:"\u786E\u8BA4\u9000\u51FA\u767B\u5F55\uFF1F",initial:!1});if(!e){console.log("\u5DF2\u53D6\u6D88");return}Jo(),console.log(u.green("\u2713 \u5DF2\u9000\u51FA\u767B\u5F55"))}var fe=require("node:child_process"),oc="https://registry.npmjs.org";function _e(){try{(0,fe.execSync)("npm --version",{stdio:"ignore"})}catch{throw new Error("\u672A\u627E\u5230 npm\uFF0C\u8BF7\u5148\u5B89\u88C5 Node.js\uFF08https://nodejs.org\uFF09")}}function st(i){try{let e=(0,fe.execSync)("npm list -g --depth=0 --json",{encoding:"utf8"}),t=JSON.parse(e);return i in(t.dependencies||{})}catch{return!1}}function ve(i){let e=(0,fe.spawnSync)("npm",["install","-g",i],{stdio:"inherit",encoding:"utf8"});if(e.status!==0)throw new Error(`npm install -g ${i} \u5931\u8D25\uFF08exit code ${e.status}\uFF09`)}function Vi(i){try{return(0,fe.execSync)(`${i} --version`,{encoding:"utf8",timeout:5e3,stdio:["ignore","pipe","ignore"]}).trim().match(/\d+\.\d+\.\d+/)?.[0]??null}catch{return null}}function Hi(i){try{let e=(0,fe.execSync)("npm list -g --depth=0 --json",{encoding:"utf8"});return JSON.parse(e).dependencies?.[i]?.version??null}catch{return null}}async function ia(i){try{let e=await fetch(`${oc}/${encodeURIComponent(i)}`,{headers:{Accept:"application/json"}});return e.ok?(await e.json())?.["dist-tags"]?.latest??null:null}catch{return null}}function sa(i,e){let t=String(i||"").split(".").map(n=>Number.parseInt(n,10)||0),s=String(e||"").split(".").map(n=>Number.parseInt(n,10)||0),r=Math.max(t.length,s.length);for(let n=0;n<r;n+=1){let o=t[n]??0,a=s[n]??0;if(o>a)return 1;if(o<a)return-1}return 0}var ra=require("node:child_process"),M=$(require("node:fs"),1),na=$(require("node:os"),1),ie=$(require("node:path"),1),ac=ie.default.join("@anthropic-ai","claude-code");function lc(){return process.platform!=="linux"?null:process.arch==="x64"?ie.default.join("node_modules","@anthropic-ai","claude-code-linux-x64","claude"):process.arch==="arm64"?ie.default.join("node_modules","@anthropic-ai","claude-code-linux-arm64","claude"):null}function hc(){try{return(0,ra.execSync)("npm root -g",{encoding:"utf8"}).trim()}catch{return null}}function Fi(){let i=[],e=new Set,t=(a,l)=>{!a||e.has(a)||M.default.existsSync(a)&&(e.add(a),i.push({path:a,type:l}))},s=hc(),r=lc();if(s){let a=ie.default.join(s,ac);t(ie.default.join(a,"cli.js"),"js"),r&&t(ie.default.join(a,r),"binary")}let n=process.env.XDG_BIN_HOME||ie.default.join(na.default.homedir(),".local","bin"),o=ie.default.join(n,"claude");if(M.default.existsSync(o)){let a=o;try{a=M.default.realpathSync(o)}catch{}t(a,"binary")}if(i.length===0){let a=r?"\uFF08\u5DF2\u5C1D\u8BD5 npm root -g \u4E0B\u7684 cli.js / \u539F\u751F binary\uFF0C\u4EE5\u53CA ~/.local/bin/claude\uFF09":"\uFF08\u5DF2\u5C1D\u8BD5 npm root -g \u4E0B\u7684 cli.js \u4E0E ~/.local/bin/claude\uFF1B\u5F53\u524D\u5E73\u53F0\u6682\u672A\u652F\u6301 npm \u5305\u5185\u7684\u539F\u751F binary patch\uFF09";throw new Error(`\u627E\u4E0D\u5230 claude-code \u5B89\u88C5\u76EE\u6807 ${a}\uFF0C\u8BF7\u5148\u8FD0\u884C flapcode claude install`)}return i}function oa(i){let e=`${i}.bak`;M.default.existsSync(e)||M.default.copyFileSync(i,e)}function uc(i,e){let t=M.default.readFileSync(i,"utf8");if(e.every(({from:r})=>!t.includes(r)))return{patched:!1,alreadyPatched:!0};oa(i);for(let{from:r,to:n}of e)t.includes(r)&&(t=t.split(r).join(n));return M.default.writeFileSync(i,t,"utf8"),{patched:!0,alreadyPatched:!1}}function cc(i,e){let t=M.default.readFileSync(i),s=[],r=[];for(let{from:o,to:a}of e){let l=Buffer.from(o,"utf8"),h=Buffer.from(a,"utf8");if(l.length!==h.length){r.push({from:o,to:a,fromBytes:l.length,toBytes:h.length,reason:"length-mismatch"});continue}s.push({fromBuf:l,toBuf:h})}if(s.length===0)return{patched:!1,alreadyPatched:!1,skippedRules:r};if(s.every(({fromBuf:o})=>!t.includes(o)))return{patched:!1,alreadyPatched:!0,skippedRules:r};oa(i);for(let{fromBuf:o,toBuf:a}of s){let l=0;for(;(l=t.indexOf(o,l))!==-1;)a.copy(t,l),l+=a.length}return M.default.writeFileSync(i,t),{patched:!0,alreadyPatched:!1,skippedRules:r}}function aa(i){let e=Fi(),t=!1,s=!0,r=new Map;for(let{path:n,type:o}of e){let a=o==="binary"?cc(n,i):uc(n,i);if(a.patched&&(t=!0),a.alreadyPatched||(s=!1),a.skippedRules)for(let l of a.skippedRules)r.has(l.from)||r.set(l.from,l)}return{patched:t,alreadyPatched:!t&&s,skippedBinaryRules:[...r.values()]}}function la({path:i,type:e}){try{return e==="binary"?M.default.readFileSync(i):M.default.readFileSync(i,"utf8")}catch{return null}}function ha(i,e){return i===null?!1:Buffer.isBuffer(i)?i.includes(Buffer.from(e,"utf8")):i.includes(e)}function ua(i){let e;try{e=Fi()}catch{return null}let t=e.map(la);return i.map(({from:s,to:r})=>({from:s,to:r,applied:t.every(n=>!ha(n,s))}))}function ca(){try{let i=Fi();return i.length===0?!1:i.every(e=>ha(la(e),"gate.flapcode.com"))}catch{return!1}}var dc="@flapcode/cli",fc=10;async function fa(){let i=S();if(await pc(),!i.api_token){console.log(),console.log(u.red("\u2717 \u672A\u767B\u5F55")+" \u2192 \u8FD0\u884C flapcode login");return}let e="...";try{let s=await zo();e=s.email??s.username??"(\u672A\u77E5)",E("\u767B\u5F55\u72B6\u6001",u.green("\u2713 \u5DF2\u767B\u5F55"),u.dim(e))}catch(s){E("\u767B\u5F55\u72B6\u6001",u.red("\u2717 \u767B\u5F55\u5931\u6548"),u.dim(s.message))}pe("\u767B\u5F55\u7F51\u7AD9",i.api_base),console.log(u.bold(`
123
+ Claude Code`));let t=Vi("claude");if(t?E("\u5B89\u88C5\u72B6\u6001",u.green("\u2713 \u5DF2\u5B89\u88C5"),`v${t}`):E("\u5B89\u88C5\u72B6\u6001",u.yellow("\u2717 \u672A\u5B89\u88C5"),"\u2192 \u8FD0\u884C flapcode claude install"),i.current_claude_account?pe("\u5F53\u524D\u8D26\u53F7",u.cyan(i.current_claude_account)):pe("\u5F53\u524D\u8D26\u53F7",u.dim("\u672A\u8BBE\u7F6E")),t)try{if(ca())return E("Patch",u.green("\u2713 \u5DF2\u751F\u6548")),da(i);let r=(i.current_claude_account?await te("claude",i.current_claude_account).catch(()=>null):null)?.patch_rules;r?.length?ua(r)?.every(a=>a.applied)?E("Patch",u.green("\u2713 \u5DF2\u751F\u6548")):E("Patch",u.yellow("\u2717 \u672A\u751F\u6548"),"\u2192 \u8FD0\u884C flapcode claude patch"):i.current_claude_account?E("Patch",u.dim("\u672A\u77E5"),"\uFF08\u65E0\u6CD5\u83B7\u53D6 patch \u89C4\u5219\uFF09"):E("Patch",u.dim("\u672A\u77E5"),"\uFF08\u672A\u8BBE\u7F6E Claude \u8D26\u53F7\uFF0C\u65E0\u6CD5\u83B7\u53D6 patch \u89C4\u5219\uFF09")}catch{E("Patch",u.dim("\u672A\u77E5"),"\uFF08\u68C0\u67E5\u5931\u8D25\uFF09")}da(i)}async function pc(){console.log(u.bold("Flapcode CLI")),E("\u5F53\u524D\u7248\u672C",u.green("\u2713 \u5DF2\u5B89\u88C5"),"v1.3.3");let i=await ia(dc);if(!i){pe("\u6700\u65B0\u7248\u672C",u.dim("\u68C0\u67E5\u5931\u8D25\u6216\u7F51\u7EDC\u4E0D\u53EF\u7528"));return}pe("\u6700\u65B0\u7248\u672C",`v${i}`),sa("1.3.3",i)<0&&E("\u5347\u7EA7\u63D0\u793A",u.yellow("\u21BB \u53EF\u5347\u7EA7"),"\u8FD0\u884C flapcode update")}function da(i){console.log(u.bold(`
124
+ Codex`));let e=Vi("codex");e?E("\u5B89\u88C5\u72B6\u6001",u.green("\u2713 \u5DF2\u5B89\u88C5"),`v${e}`):E("\u5B89\u88C5\u72B6\u6001",u.yellow("\u2717 \u672A\u5B89\u88C5"),"\u2192 \u8FD0\u884C flapcode codex install"),i.current_codex_account?pe("\u5F53\u524D\u8D26\u53F7",u.cyan(i.current_codex_account)):pe("\u5F53\u524D\u8D26\u53F7",u.dim("\u672A\u8BBE\u7F6E")),console.log()}function pe(i,e){let t=pa(i);console.log(` ${u.dim(t)} ${e}`)}function E(i,e,t=""){let s=pa(i);console.log(` ${u.dim(s)} ${e}${t?` ${t}`:""}`)}function pa(i){let e=`${i}:`,t=mc(e),s=Math.max(1,fc-t);return`${e}${" ".repeat(s)}`}function mc(i){let e=0;for(let t of i)e+=gc(t)?2:1;return e}function gc(i){return/[^\u0000-\u00ff]/.test(i)}async function ma(i){let e=i.provider??null,t=S(),s=e?[e]:["claude","codex"],r=!1;for(let n of s){let o;try{o=await H(n)}catch(l){console.error(u.red(`\u2717 \u83B7\u53D6 ${n} \u8D26\u53F7\u5931\u8D25\uFF1A${l.message}`));continue}if(!Array.isArray(o)||o.length===0){console.log(u.yellow(` ${n}\uFF1A\u6682\u65E0\u53EF\u7528\u8D26\u53F7`));continue}console.log(u.bold(`
125
125
  ${n.toUpperCase()} \u8D26\u53F7`));let a=n==="claude"?t.current_claude_account:t.current_codex_account;o.forEach((l,h)=>{let d=l.account_email===a,f=d?u.green("* "):" ",p=u.dim(`[${h+1}]`),O=d?u.green(l.account_email):l.account_email,b=l.plan_name?u.dim(` (${l.plan_name})`):"",q=l.expires_at?u.dim(` \u5230\u671F: ${new Date(l.expires_at).toLocaleDateString()}`):"";console.log(`${f}${p} ${O}${b}${q}`)}),r=!0}r||console.log(u.yellow(`
126
- \u6CA1\u6709\u53EF\u7528\u8D26\u53F7\u3002\u8BF7\u786E\u8BA4\u5DF2\u767B\u5F55\u5E76\u62E5\u6709\u6709\u6548\u8BA2\u9605\u3002`))}var nt="@flapcode/cli";async function ma(){_e();let i=xe(nt);console.log(i?`${u.dim("\u5F53\u524D\u5168\u5C40\u7248\u672C:")} v${i}`:u.yellow("\u672A\u68C0\u6D4B\u5230\u5168\u5C40\u5B89\u88C5\u7684 Flapcode CLI\uFF0C\u5C06\u76F4\u63A5\u5B89\u88C5\u6700\u65B0\u7248\u672C")),console.log(u.cyan(`
127
- \u6B63\u5728\u6267\u884C npm install -g ${nt}@latest
128
- `)),ve(`${nt}@latest`);let e=xe(nt);console.log(e?`
126
+ \u6CA1\u6709\u53EF\u7528\u8D26\u53F7\u3002\u8BF7\u786E\u8BA4\u5DF2\u767B\u5F55\u5E76\u62E5\u6709\u6709\u6548\u8BA2\u9605\u3002`))}var rt="@flapcode/cli";async function ga(){_e();let i=Hi(rt);console.log(i?`${u.dim("\u5F53\u524D\u5168\u5C40\u7248\u672C:")} v${i}`:u.yellow("\u672A\u68C0\u6D4B\u5230\u5168\u5C40\u5B89\u88C5\u7684 Flapcode CLI\uFF0C\u5C06\u76F4\u63A5\u5B89\u88C5\u6700\u65B0\u7248\u672C")),console.log(u.cyan(`
127
+ \u6B63\u5728\u6267\u884C npm install -g ${rt}@latest
128
+ `)),ve(`${rt}@latest`);let e=Hi(rt);console.log(e?`
129
129
  ${u.green("\u2713")} Flapcode CLI \u5DF2\u66F4\u65B0\u5230 v${e}`:`
130
- ${u.green("\u2713")} Flapcode CLI \u66F4\u65B0\u5B8C\u6210`)}var Bi=$(De(),1);var I=$(require("node:fs"),1),he=$(require("node:path"),1),ga=$(require("node:os"),1);function ba(i={}){let e=he.default.join(ot(),".claude"),t=he.default.join(e,"settings.json");I.default.mkdirSync(e,{recursive:!0});let s={};if(I.default.existsSync(t))try{s=JSON.parse(I.default.readFileSync(t,"utf8"))}catch{}let r={...s,...i};return i.env&&(r.env={...s.env??{},...i.env}),I.default.writeFileSync(t,JSON.stringify(r,null,2),"utf8"),t}function Fi(i){let e=he.default.join(ot(),".claude.json"),t={};if(I.default.existsSync(e))try{t=JSON.parse(I.default.readFileSync(e,"utf8"))}catch{}return t.oauthAccount={accountUuid:i.account_uuid,emailAddress:i.email,organizationId:i.org_uuid??t.oauthAccount?.organizationId??""},I.default.writeFileSync(e,JSON.stringify(t,null,2),"utf8"),e}function Ri(i){let e=he.default.join(ot(),".codex");I.default.mkdirSync(e,{recursive:!0});let t=he.default.join(e,"auth.json");return I.default.writeFileSync(t,JSON.stringify({OPENAI_API_KEY:i.api_token},null,2),"utf8"),t}function Ni(i){let e=he.default.join(ot(),".codex");I.default.mkdirSync(e,{recursive:!0});let t=he.default.join(e,"config.toml"),s=i.provider_name??"openai",n=[`model = "${i.model??"o4-mini"}"`,`model_provider = "${s}"`,'model_reasoning_effort = "medium"',"disable_response_storage = true","",`[model_providers.${s}]`,`name = "${s}"`,`base_url = "${i.base_url}"`,'wire_api = "responses"',""].join(`
131
- `);return I.default.writeFileSync(t,n,"utf8"),t}function ot(){return ga.default.homedir()}var Gi="@anthropic-ai/claude-code",gc="2.1.112",Li=`${Gi}@${gc}`;async function wa(){_e(),rt(Gi)?console.log(u.dim(`${Gi} \u5DF2\u5B89\u88C5\uFF0C\u8DF3\u8FC7`)):(console.log(u.cyan(`\u6B63\u5728\u5B89\u88C5 ${Li}...`)),ve(Li),console.log(u.green(`\u2713 ${Li} \u5B89\u88C5\u5B8C\u6210`)));let i=await bc("claude");if(!i)return;console.log(u.dim("\u6B63\u5728\u62C9\u53D6\u914D\u7F6E..."));let e=await te("claude",i.account_email);await va(e.patch_rules),ba(e.settings??{}),Fi(e.account),V({current_claude_account:i.account_email}),console.log(u.green(`
130
+ ${u.green("\u2713")} Flapcode CLI \u66F4\u65B0\u5B8C\u6210`)}var Yi=$(Ie(),1);var I=$(require("node:fs"),1),he=$(require("node:path"),1),ba=$(require("node:os"),1);function wa(i={}){let e=he.default.join(nt(),".claude"),t=he.default.join(e,"settings.json");I.default.mkdirSync(e,{recursive:!0});let s={};if(I.default.existsSync(t))try{s=JSON.parse(I.default.readFileSync(t,"utf8"))}catch{}let r={...s,...i};return i.env&&(r.env={...s.env??{},...i.env}),I.default.writeFileSync(t,JSON.stringify(r,null,2),"utf8"),t}function Ri(i){let e=he.default.join(nt(),".claude.json"),t={};if(I.default.existsSync(e))try{t=JSON.parse(I.default.readFileSync(e,"utf8"))}catch{}return t.oauthAccount={accountUuid:i.account_uuid,emailAddress:i.email,organizationId:i.org_uuid??t.oauthAccount?.organizationId??""},I.default.writeFileSync(e,JSON.stringify(t,null,2),"utf8"),e}function Ni(i){let e=he.default.join(nt(),".codex");I.default.mkdirSync(e,{recursive:!0});let t=he.default.join(e,"auth.json");return I.default.writeFileSync(t,JSON.stringify({OPENAI_API_KEY:i.api_token},null,2),"utf8"),t}function Li(i){let e=he.default.join(nt(),".codex");I.default.mkdirSync(e,{recursive:!0});let t=he.default.join(e,"config.toml"),s=i.provider_name??"openai",n=[`model = "${i.model??"o4-mini"}"`,`model_provider = "${s}"`,'model_reasoning_effort = "medium"',"disable_response_storage = true","",`[model_providers.${s}]`,`name = "${s}"`,`base_url = "${i.base_url}"`,'wire_api = "responses"',""].join(`
131
+ `);return I.default.writeFileSync(t,n,"utf8"),t}function nt(){return ba.default.homedir()}var Bi="@anthropic-ai/claude-code",bc="2.1.112",Gi=`${Bi}@${bc}`;async function ya(){_e(),st(Bi)?console.log(u.dim(`${Bi} \u5DF2\u5B89\u88C5\uFF0C\u8DF3\u8FC7`)):(console.log(u.cyan(`\u6B63\u5728\u5B89\u88C5 ${Gi}...`)),ve(Gi),console.log(u.green(`\u2713 ${Gi} \u5B89\u88C5\u5B8C\u6210`)));let i=await wc("claude");if(!i)return;console.log(u.dim("\u6B63\u5728\u62C9\u53D6\u914D\u7F6E..."));let e=await te("claude",i.account_email);await xa(e.patch_rules),wa(e.settings??{}),Ri(e.account),V({current_claude_account:i.account_email}),console.log(u.green(`
132
132
  \u2713 Claude Code \u914D\u7F6E\u5B8C\u6210\uFF01`)),console.log(` \u8D26\u53F7: ${u.cyan(i.account_email)}`),console.log(` \u8FD0\u884C ${u.bold("claude")} \u5373\u53EF\u5F00\u59CB\u4F7F\u7528
133
- `)}async function ya(){let i=S();console.log(u.dim("\u6B63\u5728\u62C9\u53D6 patch \u89C4\u5219..."));let e=await te("claude",i.current_claude_account);await va(e.patch_rules)}async function _a(i){let e=i;if(!e||/^\d+$/.test(e)){let s=await H("claude");(!Array.isArray(s)||s.length===0)&&(console.error(u.red("\u2717 \u6CA1\u6709\u53EF\u7528\u7684 Claude \u8D26\u53F7")),process.exit(1));let r=/^\d+$/.test(e)?parseInt(e,10)-1:null;if(r!==null)(r<0||r>=s.length)&&(console.error(u.red(`\u2717 \u5E8F\u53F7 ${e} \u8D85\u51FA\u8303\u56F4\uFF08\u5171 ${s.length} \u4E2A\u8D26\u53F7\uFF09`)),process.exit(1)),e=s[r].account_email;else{let n=await(0,Bi.default)({type:"select",name:"email",message:"\u9009\u62E9 Claude \u8D26\u53F7",choices:s.map(o=>({title:o.account_email,value:o.account_email}))});if(!n.email){console.log("\u5DF2\u53D6\u6D88");return}e=n.email}}console.log(u.dim(`\u6B63\u5728\u5207\u6362\u5230 ${e}...`));let t=await te("claude",e);Fi(t.account),V({current_claude_account:e}),console.log(u.green(`\u2713 \u5DF2\u5207\u6362\u5230 ${e}`))}async function bc(i){let e;try{e=await H(i)}catch(n){console.error(u.red(`\u2717 \u83B7\u53D6\u8D26\u53F7\u5217\u8868\u5931\u8D25\uFF1A${n.message}`)),process.exit(1)}if((!Array.isArray(e)||e.length===0)&&(console.error(u.red("\u2717 \u6CA1\u6709\u53EF\u7528\u8D26\u53F7\uFF0C\u8BF7\u786E\u8BA4\u8BA2\u9605\u6709\u6548")),process.exit(1)),e.length===1)return console.log(u.dim(`\u4F7F\u7528\u8D26\u53F7: ${e[0].account_email}`)),e[0];let s=S().current_claude_account,{email:r}=await(0,Bi.default)({type:"select",name:"email",message:"\u9009\u62E9\u8981\u4F7F\u7528\u7684 Claude \u8D26\u53F7",choices:e.map(n=>({title:n.account_email+(n.plan_name?` (${n.plan_name})`:""),value:n.account_email,selected:n.account_email===s}))});return r?e.find(n=>n.account_email===r):(console.log("\u5DF2\u53D6\u6D88"),null)}async function va(i){if(!i?.length){console.log(u.dim("\u670D\u52A1\u7AEF\u672A\u4E0B\u53D1 patch \u89C4\u5219\uFF0C\u8DF3\u8FC7"));return}console.log(u.dim("\u6B63\u5728\u5E94\u7528 patch..."));let{patched:e,alreadyPatched:t,skippedBinaryRules:s}=oa(i);if(t?console.log(u.dim("Patch \u5DF2\u751F\u6548\uFF0C\u65E0\u9700\u91CD\u590D\u64CD\u4F5C")):e&&console.log(u.green("\u2713 Patch \u5E94\u7528\u6210\u529F")),s?.length)for(let{from:r,to:n,fromBytes:o,toBytes:a}of s)console.log(u.yellow(`\u26A0 binary \u8DF3\u8FC7\u89C4\u5219 '${r}' \u2192 '${n}' (${o} \u2192 ${a} bytes \u4E0D\u7B49\u957F)`))}var xa=$(require("node:fs"),1),Yi=$(De(),1);var Ve="@openai/codex";async function Ca(){_e(),rt(Ve)?console.log(u.dim(`${Ve} \u5DF2\u5B89\u88C5\uFF0C\u8DF3\u8FC7`)):(console.log(u.cyan(`\u6B63\u5728\u5B89\u88C5 ${Ve}...`)),ve(Ve),console.log(u.green(`\u2713 ${Ve} \u5B89\u88C5\u5B8C\u6210`)));let i=await wc();if(!i)return;console.log(u.dim("\u6B63\u5728\u62C9\u53D6\u914D\u7F6E..."));let e=await te("codex",i.account_email),t=Ri({api_token:e.api_token}),s=Ni({base_url:e.base_url,provider_name:e.provider_name,model:e.model});at(t,"Codex auth.json"),at(s,"Codex config.toml"),V({current_codex_account:i.account_email}),console.log(u.green(`
133
+ `)}async function _a(){let i=S();console.log(u.dim("\u6B63\u5728\u62C9\u53D6 patch \u89C4\u5219..."));let e=await te("claude",i.current_claude_account);await xa(e.patch_rules)}async function va(i){let e=i;if(!e||/^\d+$/.test(e)){let s=await H("claude");(!Array.isArray(s)||s.length===0)&&(console.error(u.red("\u2717 \u6CA1\u6709\u53EF\u7528\u7684 Claude \u8D26\u53F7")),process.exit(1));let r=/^\d+$/.test(e)?parseInt(e,10)-1:null;if(r!==null)(r<0||r>=s.length)&&(console.error(u.red(`\u2717 \u5E8F\u53F7 ${e} \u8D85\u51FA\u8303\u56F4\uFF08\u5171 ${s.length} \u4E2A\u8D26\u53F7\uFF09`)),process.exit(1)),e=s[r].account_email;else{let n=await(0,Yi.default)({type:"select",name:"email",message:"\u9009\u62E9 Claude \u8D26\u53F7",choices:s.map(o=>({title:o.account_email,value:o.account_email}))});if(!n.email){console.log("\u5DF2\u53D6\u6D88");return}e=n.email}}console.log(u.dim(`\u6B63\u5728\u5207\u6362\u5230 ${e}...`));let t=await te("claude",e);Ri(t.account),V({current_claude_account:e}),console.log(u.green(`\u2713 \u5DF2\u5207\u6362\u5230 ${e}`))}async function wc(i){let e;try{e=await H(i)}catch(n){console.error(u.red(`\u2717 \u83B7\u53D6\u8D26\u53F7\u5217\u8868\u5931\u8D25\uFF1A${n.message}`)),process.exit(1)}if((!Array.isArray(e)||e.length===0)&&(console.error(u.red("\u2717 \u6CA1\u6709\u53EF\u7528\u8D26\u53F7\uFF0C\u8BF7\u786E\u8BA4\u8BA2\u9605\u6709\u6548")),process.exit(1)),e.length===1)return console.log(u.dim(`\u4F7F\u7528\u8D26\u53F7: ${e[0].account_email}`)),e[0];let s=S().current_claude_account,{email:r}=await(0,Yi.default)({type:"select",name:"email",message:"\u9009\u62E9\u8981\u4F7F\u7528\u7684 Claude \u8D26\u53F7",choices:e.map(n=>({title:n.account_email+(n.plan_name?` (${n.plan_name})`:""),value:n.account_email,selected:n.account_email===s}))});return r?e.find(n=>n.account_email===r):(console.log("\u5DF2\u53D6\u6D88"),null)}async function xa(i){if(!i?.length){console.log(u.dim("\u670D\u52A1\u7AEF\u672A\u4E0B\u53D1 patch \u89C4\u5219\uFF0C\u8DF3\u8FC7"));return}console.log(u.dim("\u6B63\u5728\u5E94\u7528 patch..."));let{patched:e,alreadyPatched:t,skippedBinaryRules:s}=aa(i);if(t?console.log(u.dim("Patch \u5DF2\u751F\u6548\uFF0C\u65E0\u9700\u91CD\u590D\u64CD\u4F5C")):e&&console.log(u.green("\u2713 Patch \u5E94\u7528\u6210\u529F")),s?.length)for(let{from:r,to:n,fromBytes:o,toBytes:a}of s)console.log(u.yellow(`\u26A0 binary \u8DF3\u8FC7\u89C4\u5219 '${r}' \u2192 '${n}' (${o} \u2192 ${a} bytes \u4E0D\u7B49\u957F)`))}var Ca=$(require("node:fs"),1),Ui=$(Ie(),1);var je="@openai/codex";async function Oa(){_e(),st(je)?console.log(u.dim(`${je} \u5DF2\u5B89\u88C5\uFF0C\u8DF3\u8FC7`)):(console.log(u.cyan(`\u6B63\u5728\u5B89\u88C5 ${je}...`)),ve(je),console.log(u.green(`\u2713 ${je} \u5B89\u88C5\u5B8C\u6210`)));let i=await yc();if(!i)return;console.log(u.dim("\u6B63\u5728\u62C9\u53D6\u914D\u7F6E..."));let e=await te("codex",i.account_email),t=Ni({api_token:e.api_token}),s=Li({base_url:e.base_url,provider_name:e.provider_name,model:e.model});ot(t,"Codex auth.json"),ot(s,"Codex config.toml"),V({current_codex_account:i.account_email}),console.log(u.green(`
134
134
  \u2713 Codex \u914D\u7F6E\u5B8C\u6210\uFF01`)),console.log(` \u8D26\u53F7: ${u.cyan(i.account_email)}`),console.log(` Auth: ${u.dim(t)}`),console.log(` Config: ${u.dim(s)}`),console.log(` \u8FD0\u884C ${u.bold("codex")} \u5373\u53EF\u5F00\u59CB\u4F7F\u7528
135
- `)}async function Oa(i){let e=i;if(!e||/^\d+$/.test(e)){let n=await H("codex");(!Array.isArray(n)||n.length===0)&&(console.error(u.red("\u2717 \u6CA1\u6709\u53EF\u7528\u7684 Codex \u8D26\u53F7")),process.exit(1));let o=/^\d+$/.test(e)?parseInt(e,10)-1:null;if(o!==null)(o<0||o>=n.length)&&(console.error(u.red(`\u2717 \u5E8F\u53F7 ${e} \u8D85\u51FA\u8303\u56F4\uFF08\u5171 ${n.length} \u4E2A\u8D26\u53F7\uFF09`)),process.exit(1)),e=n[o].account_email;else{let a=await(0,Yi.default)({type:"select",name:"email",message:"\u9009\u62E9 Codex \u8D26\u53F7",choices:n.map(l=>({title:l.account_email,value:l.account_email}))});if(!a.email){console.log("\u5DF2\u53D6\u6D88");return}e=a.email}}console.log(u.dim(`\u6B63\u5728\u5207\u6362\u5230 ${e}...`));let t=await te("codex",e),s=Ri({api_token:t.api_token}),r=Ni({base_url:t.base_url,provider_name:t.provider_name,model:t.model});at(s,"Codex auth.json"),at(r,"Codex config.toml"),V({current_codex_account:e}),console.log(u.green(`\u2713 \u5DF2\u5207\u6362\u5230 ${e}`)),console.log(` Auth: ${u.dim(s)}`),console.log(` Config: ${u.dim(r)}`)}async function wc(){let i;try{i=await H("codex")}catch(r){console.error(u.red(`\u2717 \u83B7\u53D6\u8D26\u53F7\u5217\u8868\u5931\u8D25\uFF1A${r.message}`)),process.exit(1)}if((!Array.isArray(i)||i.length===0)&&(console.error(u.red("\u2717 \u6CA1\u6709\u53EF\u7528\u8D26\u53F7\uFF0C\u8BF7\u786E\u8BA4\u8BA2\u9605\u6709\u6548")),process.exit(1)),i.length===1)return console.log(u.dim(`\u4F7F\u7528\u8D26\u53F7: ${i[0].account_email}`)),i[0];let t=S().current_codex_account,{email:s}=await(0,Yi.default)({type:"select",name:"email",message:"\u9009\u62E9\u8981\u4F7F\u7528\u7684 Codex \u8D26\u53F7",choices:i.map(r=>({title:r.account_email+(r.plan_name?` (${r.plan_name})`:""),value:r.account_email,selected:r.account_email===t}))});return s?i.find(r=>r.account_email===s):(console.log("\u5DF2\u53D6\u6D88"),null)}function at(i,e){if(!xa.default.existsSync(i))throw new Error(`${e} \u5199\u5165\u5931\u8D25\uFF1A${i}`)}var se=new ls;se.name("flapcode").description("Flapcode CLI \u2014 \u7EDF\u4E00\u7BA1\u7406 Claude Code / Codex \u5B89\u88C5\u4E0E\u8D26\u53F7\u914D\u7F6E").version("1.3.1","-v, --version","\u663E\u793A\u7248\u672C\u53F7");se.command("login").description("\u4F7F\u7528 API Token \u6216\u90AE\u7BB1\u767B\u5F55").option("--token <token>","\u975E\u4EA4\u4E92\u6A21\u5F0F\u4E0B\u76F4\u63A5\u4F20\u5165 API Token").option("--email <email>","\u4F7F\u7528\u90AE\u7BB1\u767B\u5F55").action(Y(Xo));se.command("logout").description("\u9000\u51FA\u767B\u5F55\uFF0C\u6E05\u9664\u672C\u5730\u914D\u7F6E").action(Y(ea));se.command("status").description("\u663E\u793A\u5F53\u524D\u7528\u6237\u3001\u8D26\u53F7\u3001CC/Codex \u7248\u672C\u53CA patch \u72B6\u6001").action(Y(da));se.command("update").description("\u5347\u7EA7 Flapcode CLI \u5230\u6700\u65B0\u7248\u672C").action(Y(ma));se.command("accounts").description("\u5217\u51FA\u5F53\u524D\u7528\u6237\u53EF\u7528\u7684\u8D26\u53F7").option("--provider <provider>","\u8FC7\u6EE4 provider\uFF08claude \u6216 codex\uFF09").action(Y(pa));var Ui=se.command("claude").description("\u7BA1\u7406 Claude Code");Ui.command("install").description("\u9996\u6B21\u5B8C\u6574\u914D\u7F6E\uFF1A\u5B89\u88C5 CC + patch + \u5199\u914D\u7F6E\u6587\u4EF6").action(Y(wa));Ui.command("patch").description("\u4EC5\u91CD\u6253 patch\uFF08\u5E94\u5BF9 CC \u5347\u7EA7\u540E URL \u88AB\u8986\u76D6\uFF09").action(Y(ya));Ui.command("use [account]").description("\u5207\u6362 Claude \u8D26\u53F7\uFF08\u4F20 email \u6216\u5E8F\u53F7\uFF0C\u7559\u7A7A\u8FDB\u884C\u4EA4\u4E92\u9009\u62E9\uFF09").action(Y(_a));var Sa=se.command("codex").description("\u7BA1\u7406 Codex");Sa.command("install").description("\u9996\u6B21\u5B8C\u6574\u914D\u7F6E\uFF1A\u5B89\u88C5 Codex + \u5199\u914D\u7F6E\u6587\u4EF6").action(Y(Ca));Sa.command("use [account]").description("\u5207\u6362 Codex \u8D26\u53F7\uFF08\u4F20 email \u6216\u5E8F\u53F7\uFF0C\u7559\u7A7A\u8FDB\u884C\u4EA4\u4E92\u9009\u62E9\uFF09").action(Y(Oa));se.parse();function Y(i){return async(...e)=>{try{await i(...e)}catch(t){console.error(u.red(`\u2717 ${t.message}`)),process.env.DEBUG&&console.error(t),process.exit(1)}}}
135
+ `)}async function Sa(i){let e=i;if(!e||/^\d+$/.test(e)){let n=await H("codex");(!Array.isArray(n)||n.length===0)&&(console.error(u.red("\u2717 \u6CA1\u6709\u53EF\u7528\u7684 Codex \u8D26\u53F7")),process.exit(1));let o=/^\d+$/.test(e)?parseInt(e,10)-1:null;if(o!==null)(o<0||o>=n.length)&&(console.error(u.red(`\u2717 \u5E8F\u53F7 ${e} \u8D85\u51FA\u8303\u56F4\uFF08\u5171 ${n.length} \u4E2A\u8D26\u53F7\uFF09`)),process.exit(1)),e=n[o].account_email;else{let a=await(0,Ui.default)({type:"select",name:"email",message:"\u9009\u62E9 Codex \u8D26\u53F7",choices:n.map(l=>({title:l.account_email,value:l.account_email}))});if(!a.email){console.log("\u5DF2\u53D6\u6D88");return}e=a.email}}console.log(u.dim(`\u6B63\u5728\u5207\u6362\u5230 ${e}...`));let t=await te("codex",e),s=Ni({api_token:t.api_token}),r=Li({base_url:t.base_url,provider_name:t.provider_name,model:t.model});ot(s,"Codex auth.json"),ot(r,"Codex config.toml"),V({current_codex_account:e}),console.log(u.green(`\u2713 \u5DF2\u5207\u6362\u5230 ${e}`)),console.log(` Auth: ${u.dim(s)}`),console.log(` Config: ${u.dim(r)}`)}async function yc(){let i;try{i=await H("codex")}catch(r){console.error(u.red(`\u2717 \u83B7\u53D6\u8D26\u53F7\u5217\u8868\u5931\u8D25\uFF1A${r.message}`)),process.exit(1)}if((!Array.isArray(i)||i.length===0)&&(console.error(u.red("\u2717 \u6CA1\u6709\u53EF\u7528\u8D26\u53F7\uFF0C\u8BF7\u786E\u8BA4\u8BA2\u9605\u6709\u6548")),process.exit(1)),i.length===1)return console.log(u.dim(`\u4F7F\u7528\u8D26\u53F7: ${i[0].account_email}`)),i[0];let t=S().current_codex_account,{email:s}=await(0,Ui.default)({type:"select",name:"email",message:"\u9009\u62E9\u8981\u4F7F\u7528\u7684 Codex \u8D26\u53F7",choices:i.map(r=>({title:r.account_email+(r.plan_name?` (${r.plan_name})`:""),value:r.account_email,selected:r.account_email===t}))});return s?i.find(r=>r.account_email===s):(console.log("\u5DF2\u53D6\u6D88"),null)}function ot(i,e){if(!Ca.default.existsSync(i))throw new Error(`${e} \u5199\u5165\u5931\u8D25\uFF1A${i}`)}var se=new hs;se.name("flapcode").description("Flapcode CLI \u2014 \u7EDF\u4E00\u7BA1\u7406 Claude Code / Codex \u5B89\u88C5\u4E0E\u8D26\u53F7\u914D\u7F6E").version("1.3.3","-v, --version","\u663E\u793A\u7248\u672C\u53F7");se.command("login").description("\u4F7F\u7528 API Token \u6216\u90AE\u7BB1\u767B\u5F55").option("--token <token>","\u975E\u4EA4\u4E92\u6A21\u5F0F\u4E0B\u76F4\u63A5\u4F20\u5165 API Token").option("--email <email>","\u4F7F\u7528\u90AE\u7BB1\u767B\u5F55").action(Y(Qo));se.command("logout").description("\u9000\u51FA\u767B\u5F55\uFF0C\u6E05\u9664\u672C\u5730\u914D\u7F6E").action(Y(ta));se.command("status").description("\u663E\u793A\u5F53\u524D\u7528\u6237\u3001\u8D26\u53F7\u3001CC/Codex \u7248\u672C\u53CA patch \u72B6\u6001").action(Y(fa));se.command("update").description("\u5347\u7EA7 Flapcode CLI \u5230\u6700\u65B0\u7248\u672C").action(Y(ga));se.command("accounts").description("\u5217\u51FA\u5F53\u524D\u7528\u6237\u53EF\u7528\u7684\u8D26\u53F7").option("--provider <provider>","\u8FC7\u6EE4 provider\uFF08claude \u6216 codex\uFF09").action(Y(ma));var Wi=se.command("claude").description("\u7BA1\u7406 Claude Code");Wi.command("install").description("\u9996\u6B21\u5B8C\u6574\u914D\u7F6E\uFF1A\u5B89\u88C5 CC + patch + \u5199\u914D\u7F6E\u6587\u4EF6").action(Y(ya));Wi.command("patch").description("\u4EC5\u91CD\u6253 patch\uFF08\u5E94\u5BF9 CC \u5347\u7EA7\u540E URL \u88AB\u8986\u76D6\uFF09").action(Y(_a));Wi.command("use [account]").description("\u5207\u6362 Claude \u8D26\u53F7\uFF08\u4F20 email \u6216\u5E8F\u53F7\uFF0C\u7559\u7A7A\u8FDB\u884C\u4EA4\u4E92\u9009\u62E9\uFF09").action(Y(va));var $a=se.command("codex").description("\u7BA1\u7406 Codex");$a.command("install").description("\u9996\u6B21\u5B8C\u6574\u914D\u7F6E\uFF1A\u5B89\u88C5 Codex + \u5199\u914D\u7F6E\u6587\u4EF6").action(Y(Oa));$a.command("use [account]").description("\u5207\u6362 Codex \u8D26\u53F7\uFF08\u4F20 email \u6216\u5E8F\u53F7\uFF0C\u7559\u7A7A\u8FDB\u884C\u4EA4\u4E92\u9009\u62E9\uFF09").action(Y(Sa));se.parse();function Y(i){return async(...e)=>{try{await i(...e)}catch(t){console.error(u.red(`\u2717 ${t.message}`)),process.env.DEBUG&&console.error(t),process.exit(1)}}}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flapcode/cli",
3
- "version": "1.3.1",
3
+ "version": "1.3.3",
4
4
  "description": "Flapcode CLI - 统一管理 Claude Code / Codex 安装与账号配置",
5
5
  "type": "module",
6
6
  "bin": {