imba
Version:
14 lines • 390 kB
JavaScript
var Ua=Object.create,ie=Object.defineProperty,$a=Object.getPrototypeOf,za=Object.prototype.hasOwnProperty,Ma=Object.getOwnPropertyNames,Ha=Object.getOwnPropertyDescriptor;var Wa=p=>ie(p,"__esModule",{value:!0});var h=(p,e)=>()=>(e||(e={exports:{}},p(e.exports,e)),e.exports);var Ga=(p,e,a)=>{if(e&&typeof e=="object"||typeof e=="function")for(let d of Ma(e))!za.call(p,d)&&d!=="default"&&ie(p,d,{get:()=>e[d],enumerable:!(a=Ha(e,d))||a.enumerable});return p},S1=p=>Ga(Wa(ie(p!=null?Ua($a(p)):{},"default",p&&p.__esModule&&"default"in p?{get:()=>p.default,enumerable:!0}:{value:p,enumerable:!0})),p);var Me=h((u4,F1)=>{"use strict";var Ka=process.env.TERM_PROGRAM==="Hyper",Za=process.platform==="win32",Ue=process.platform==="linux",te={ballotDisabled:"☒",ballotOff:"☐",ballotOn:"☑",bullet:"•",bulletWhite:"◦",fullBlock:"█",heart:"❤",identicalTo:"≡",line:"─",mark:"※",middot:"·",minus:"-",multiplication:"×",obelus:"÷",pencilDownRight:"✎",pencilRight:"✏",pencilUpRight:"✐",percent:"%",pilcrow2:"❡",pilcrow:"¶",plusMinus:"±",section:"§",starsOff:"☆",starsOn:"★",upDownArrow:"↕"},$e=Object.assign({},te,{check:"√",cross:"×",ellipsisLarge:"...",ellipsis:"...",info:"i",question:"?",questionSmall:"?",pointer:">",pointerSmall:"»",radioOff:"( )",radioOn:"(*)",warning:"‼"}),ze=Object.assign({},te,{ballotCross:"✘",check:"✔",cross:"✖",ellipsisLarge:"⋯",ellipsis:"…",info:"ℹ",question:"?",questionFull:"?",questionSmall:"﹖",pointer:Ue?"▸":"❯",pointerSmall:Ue?"‣":"›",radioOff:"◯",radioOn:"◉",warning:"⚠"});F1.exports=Za&&!Ka?$e:ze;Reflect.defineProperty(F1.exports,"common",{enumerable:!1,value:te});Reflect.defineProperty(F1.exports,"windows",{enumerable:!1,value:$e});Reflect.defineProperty(F1.exports,"other",{enumerable:!1,value:ze})});var H=h((h4,se)=>{"use strict";var Ja=p=>p!==null&&typeof p=="object"&&!Array.isArray(p),Ya=/[\u001b\u009b][[\]#;?()]*(?:(?:(?:[^\W_]*;?[^\W_]*)\u0007)|(?:(?:[0-9]{1,4}(;[0-9]{0,4})*)?[~0-9=<>cf-nqrtyA-PRZ]))/g,He=()=>{let p={enabled:!0,visible:!0,styles:{},keys:{}};"FORCE_COLOR"in process.env&&(p.enabled=process.env.FORCE_COLOR!=="0");let e=t=>{let s=t.open=`[${t.codes[0]}m`,m=t.close=`[${t.codes[1]}m`,l=t.regex=new RegExp(`\\u001b\\[${t.codes[1]}m`,"g");return t.wrap=(r,o)=>{r.includes(m)&&(r=r.replace(l,m+s));let n=s+r+m;return o?n.replace(/\r*\n/g,`${m}$&${s}`):n},t},a=(t,s,m)=>typeof t=="function"?t(s):t.wrap(s,m),d=(t,s)=>{if(t===""||t==null)return"";if(p.enabled===!1)return t;if(p.visible===!1)return"";let m=""+t,l=m.includes(`
`),r=s.length;for(r>0&&s.includes("unstyle")&&(s=[...new Set(["unstyle",...s])].reverse());r-- >0;)m=a(p.styles[s[r]],m,l);return m},i=(t,s,m)=>{p.styles[t]=e({name:t,codes:s}),(p.keys[m]||(p.keys[m]=[])).push(t),Reflect.defineProperty(p,t,{configurable:!0,enumerable:!0,set(r){p.alias(t,r)},get(){let r=o=>d(o,r.stack);return Reflect.setPrototypeOf(r,p),r.stack=this.stack?this.stack.concat(t):[t],r}})};return i("reset",[0,0],"modifier"),i("bold",[1,22],"modifier"),i("dim",[2,22],"modifier"),i("italic",[3,23],"modifier"),i("underline",[4,24],"modifier"),i("inverse",[7,27],"modifier"),i("hidden",[8,28],"modifier"),i("strikethrough",[9,29],"modifier"),i("black",[30,39],"color"),i("red",[31,39],"color"),i("green",[32,39],"color"),i("yellow",[33,39],"color"),i("blue",[34,39],"color"),i("magenta",[35,39],"color"),i("cyan",[36,39],"color"),i("white",[37,39],"color"),i("gray",[90,39],"color"),i("grey",[90,39],"color"),i("bgBlack",[40,49],"bg"),i("bgRed",[41,49],"bg"),i("bgGreen",[42,49],"bg"),i("bgYellow",[43,49],"bg"),i("bgBlue",[44,49],"bg"),i("bgMagenta",[45,49],"bg"),i("bgCyan",[46,49],"bg"),i("bgWhite",[47,49],"bg"),i("blackBright",[90,39],"bright"),i("redBright",[91,39],"bright"),i("greenBright",[92,39],"bright"),i("yellowBright",[93,39],"bright"),i("blueBright",[94,39],"bright"),i("magentaBright",[95,39],"bright"),i("cyanBright",[96,39],"bright"),i("whiteBright",[97,39],"bright"),i("bgBlackBright",[100,49],"bgBright"),i("bgRedBright",[101,49],"bgBright"),i("bgGreenBright",[102,49],"bgBright"),i("bgYellowBright",[103,49],"bgBright"),i("bgBlueBright",[104,49],"bgBright"),i("bgMagentaBright",[105,49],"bgBright"),i("bgCyanBright",[106,49],"bgBright"),i("bgWhiteBright",[107,49],"bgBright"),p.ansiRegex=Ya,p.hasColor=p.hasAnsi=t=>(p.ansiRegex.lastIndex=0,typeof t=="string"&&t!==""&&p.ansiRegex.test(t)),p.alias=(t,s)=>{let m=typeof s=="string"?p[s]:s;if(typeof m!="function")throw new TypeError("Expected alias to be the name of an existing color (string) or a function");m.stack||(Reflect.defineProperty(m,"name",{value:t}),p.styles[t]=m,m.stack=[t]),Reflect.defineProperty(p,t,{configurable:!0,enumerable:!0,set(l){p.alias(t,l)},get(){let l=r=>d(r,l.stack);return Reflect.setPrototypeOf(l,p),l.stack=this.stack?this.stack.concat(m.stack):m.stack,l}})},p.theme=t=>{if(!Ja(t))throw new TypeError("Expected theme to be an object");for(let s of Object.keys(t))p.alias(s,t[s]);return p},p.alias("unstyle",t=>typeof t=="string"&&t!==""?(p.ansiRegex.lastIndex=0,t.replace(p.ansiRegex,"")):""),p.alias("noop",t=>t),p.none=p.clear=p.noop,p.stripColor=p.unstyle,p.symbols=Me(),p.define=i,p};se.exports=He();se.exports.create=He});var R=h(b=>{"use strict";var Qa=Object.prototype.toString,$=H(),We=!1,le=[],Ge={yellow:"blue",cyan:"red",green:"magenta",black:"white",blue:"yellow",red:"cyan",magenta:"green",white:"black"};b.longest=(p,e)=>p.reduce((a,d)=>Math.max(a,e?d[e].length:d.length),0);b.hasColor=p=>!!p&&$.hasColor(p);var H1=b.isObject=p=>p!==null&&typeof p=="object"&&!Array.isArray(p);b.nativeType=p=>Qa.call(p).slice(8,-1).toLowerCase().replace(/\s/g,"");b.isAsyncFn=p=>b.nativeType(p)==="asyncfunction";b.isPrimitive=p=>p!=null&&typeof p!="object"&&typeof p!="function";b.resolve=(p,e,...a)=>typeof e=="function"?e.call(p,...a):e;b.scrollDown=(p=[])=>[...p.slice(1),p[0]];b.scrollUp=(p=[])=>[p.pop(),...p];b.reorder=(p=[])=>{let e=p.slice();return e.sort((a,d)=>a.index>d.index?1:a.index<d.index?-1:0),e};b.swap=(p,e,a)=>{let d=p.length,i=a===d?0:a<0?d-1:a,t=p[e];p[e]=p[i],p[i]=t};b.width=(p,e=80)=>{let a=p&&p.columns?p.columns:e;return p&&typeof p.getWindowSize=="function"&&(a=p.getWindowSize()[0]),process.platform==="win32"?a-1:a};b.height=(p,e=20)=>{let a=p&&p.rows?p.rows:e;return p&&typeof p.getWindowSize=="function"&&(a=p.getWindowSize()[1]),a};b.wordWrap=(p,e={})=>{if(!p)return p;typeof e=="number"&&(e={width:e});let{indent:a="",newline:d=`
`+a,width:i=80}=e;i-=((d+a).match(/[^\S\n]/g)||[]).length;let s=`.{1,${i}}([\\s\\u200B]+|$)|[^\\s\\u200B]+?([\\s\\u200B]+|$)`,m=p.trim(),l=new RegExp(s,"g"),r=m.match(l)||[];return r=r.map(o=>o.replace(/\n$/,"")),e.padEnd&&(r=r.map(o=>o.padEnd(i," "))),e.padStart&&(r=r.map(o=>o.padStart(i," "))),a+r.join(d)};b.unmute=p=>{let e=p.stack.find(d=>$.keys.color.includes(d));return e?$[e]:p.stack.find(d=>d.slice(2)==="bg")?$[e.slice(2)]:d=>d};b.pascal=p=>p?p[0].toUpperCase()+p.slice(1):"";b.inverse=p=>{if(!p||!p.stack)return p;let e=p.stack.find(d=>$.keys.color.includes(d));if(e){let d=$["bg"+b.pascal(e)];return d?d.black:p}let a=p.stack.find(d=>d.slice(0,2)==="bg");return a?$[a.slice(2).toLowerCase()]||p:$.none};b.complement=p=>{if(!p||!p.stack)return p;let e=p.stack.find(d=>$.keys.color.includes(d)),a=p.stack.find(d=>d.slice(0,2)==="bg");if(e&&!a)return $[Ge[e]||e];if(a){let d=a.slice(2).toLowerCase(),i=Ge[d];return i&&$["bg"+b.pascal(i)]||p}return $.none};b.meridiem=p=>{let e=p.getHours(),a=p.getMinutes(),d=e>=12?"pm":"am";e=e%12;let i=e===0?12:e,t=a<10?"0"+a:a;return i+":"+t+" "+d};b.set=(p={},e="",a)=>e.split(".").reduce((d,i,t,s)=>{let m=s.length-1>t?d[i]||{}:a;return!b.isObject(m)&&t<s.length-1&&(m={}),d[i]=m},p);b.get=(p={},e="",a)=>{let d=p[e]==null?e.split(".").reduce((i,t)=>i&&i[t],p):p[e];return d==null?a:d};b.mixin=(p,e)=>{if(!H1(p))return e;if(!H1(e))return p;for(let a of Object.keys(e)){let d=Object.getOwnPropertyDescriptor(e,a);if(d.hasOwnProperty("value"))if(p.hasOwnProperty(a)&&H1(d.value)){let i=Object.getOwnPropertyDescriptor(p,a);H1(i.value)?p[a]=b.merge({},p[a],e[a]):Reflect.defineProperty(p,a,d)}else Reflect.defineProperty(p,a,d);else Reflect.defineProperty(p,a,d)}return p};b.merge=(...p)=>{let e={};for(let a of p)b.mixin(e,a);return e};b.mixinEmitter=(p,e)=>{let a=e.constructor.prototype;for(let d of Object.keys(a)){let i=a[d];typeof i=="function"?b.define(p,d,i.bind(e)):b.define(p,d,i)}};b.onExit=p=>{let e=(a,d)=>{We||(We=!0,le.forEach(i=>i()),a===!0&&process.exit(128+d))};le.length===0&&(process.once("SIGTERM",e.bind(null,!0,15)),process.once("SIGINT",e.bind(null,!0,2)),process.once("exit",e)),le.push(p)};b.define=(p,e,a)=>{Reflect.defineProperty(p,e,{value:a})};b.defineExport=(p,e,a)=>{let d;Reflect.defineProperty(p,e,{enumerable:!0,configurable:!0,set(i){d=i},get(){return d?d():a()}})}});var Ke=h(D1=>{"use strict";D1.ctrl={a:"first",b:"backward",c:"cancel",d:"deleteForward",e:"last",f:"forward",g:"reset",i:"tab",k:"cutForward",l:"reset",n:"newItem",m:"cancel",j:"submit",p:"search",r:"remove",s:"save",u:"undo",w:"cutLeft",x:"toggleCursor",v:"paste"};D1.shift={up:"shiftUp",down:"shiftDown",left:"shiftLeft",right:"shiftRight",tab:"prev"};D1.fn={up:"pageUp",down:"pageDown",left:"pageLeft",right:"pageRight",delete:"deleteForward"};D1.option={b:"backward",f:"forward",d:"cutRight",left:"cutLeft",up:"altUp",down:"altDown"};D1.keys={pageup:"pageUp",pagedown:"pageDown",home:"home",end:"end",cancel:"cancel",delete:"deleteForward",backspace:"delete",down:"down",enter:"submit",escape:"cancel",left:"left",space:"space",number:"number",return:"submit",right:"right",tab:"next",up:"up"}});var Ye=h((v4,Ze)=>{"use strict";var Je=require("readline"),Xa=Ke(),ed=/^(?:\x1b)([a-zA-Z0-9])$/,pd=/^(?:\x1b+)(O|N|\[|\[\[)(?:(\d+)(?:;(\d+))?([~^$])|(?:1;)?(\d+)?([a-zA-Z]))/,ad={OP:"f1",OQ:"f2",OR:"f3",OS:"f4","[11~":"f1","[12~":"f2","[13~":"f3","[14~":"f4","[[A":"f1","[[B":"f2","[[C":"f3","[[D":"f4","[[E":"f5","[15~":"f5","[17~":"f6","[18~":"f7","[19~":"f8","[20~":"f9","[21~":"f10","[23~":"f11","[24~":"f12","[A":"up","[B":"down","[C":"right","[D":"left","[E":"clear","[F":"end","[H":"home",OA:"up",OB:"down",OC:"right",OD:"left",OE:"clear",OF:"end",OH:"home","[1~":"home","[2~":"insert","[3~":"delete","[4~":"end","[5~":"pageup","[6~":"pagedown","[[5~":"pageup","[[6~":"pagedown","[7~":"home","[8~":"end","[a":"up","[b":"down","[c":"right","[d":"left","[e":"clear","[2$":"insert","[3$":"delete","[5$":"pageup","[6$":"pagedown","[7$":"home","[8$":"end",Oa:"up",Ob:"down",Oc:"right",Od:"left",Oe:"clear","[2^":"insert","[3^":"delete","[5^":"pageup","[6^":"pagedown","[7^":"home","[8^":"end","[Z":"tab"};function dd(p){return["[a","[b","[c","[d","[e","[2$","[3$","[5$","[6$","[7$","[8$","[Z"].includes(p)}function id(p){return["Oa","Ob","Oc","Od","Oe","[2^","[3^","[5^","[6^","[7^","[8^"].includes(p)}var W1=(p="",e={})=>{let a,d={name:e.name,ctrl:!1,meta:!1,shift:!1,option:!1,sequence:p,raw:p,...e};if(Buffer.isBuffer(p)?p[0]>127&&p[1]===void 0?(p[0]-=128,p=""+String(p)):p=String(p):p!==void 0&&typeof p!="string"?p=String(p):p||(p=d.sequence||""),d.sequence=d.sequence||p||d.name,p==="\r")d.raw=void 0,d.name="return";else if(p===`
`)d.name="enter";else if(p===" ")d.name="tab";else if(p==="\b"||p===""||p===""||p==="\b")d.name="backspace",d.meta=p.charAt(0)==="";else if(p===""||p==="")d.name="escape",d.meta=p.length===2;else if(p===" "||p===" ")d.name="space",d.meta=p.length===2;else if(p<="")d.name=String.fromCharCode(p.charCodeAt(0)+"a".charCodeAt(0)-1),d.ctrl=!0;else if(p.length===1&&p>="0"&&p<="9")d.name="number";else if(p.length===1&&p>="a"&&p<="z")d.name=p;else if(p.length===1&&p>="A"&&p<="Z")d.name=p.toLowerCase(),d.shift=!0;else if(a=ed.exec(p))d.meta=!0,d.shift=/^[A-Z]$/.test(a[1]);else if(a=pd.exec(p)){let i=[...p];i[0]===""&&i[1]===""&&(d.option=!0);let t=[a[1],a[2],a[4],a[6]].filter(Boolean).join(""),s=(a[3]||a[5]||1)-1;d.ctrl=!!(s&4),d.meta=!!(s&10),d.shift=!!(s&1),d.code=t,d.name=ad[t],d.shift=dd(t)||d.shift,d.ctrl=id(t)||d.ctrl}return d};W1.listen=(p={},e)=>{let{stdin:a}=p;if(!a||a!==process.stdin&&!a.isTTY)throw new Error("Invalid stream passed");let d=Je.createInterface({terminal:!0,input:a});Je.emitKeypressEvents(a,d);let i=(m,l)=>e(m,W1(m,l),d),t=a.isRaw;return a.isTTY&&a.setRawMode(!0),a.on("keypress",i),d.resume(),()=>{a.isTTY&&a.setRawMode(t),a.removeListener("keypress",i),d.pause(),d.close()}};W1.action=(p,e,a)=>{let d={...Xa,...a};return e.ctrl?(e.action=d.ctrl[e.name],e):e.option&&d.option?(e.action=d.option[e.name],e):e.shift?(e.action=d.shift[e.name],e):(e.action=d.keys[e.name],e)};Ze.exports=W1});var Xe=h((w4,Qe)=>{"use strict";Qe.exports=p=>{p.timers=p.timers||{};let e=p.options.timers;if(!!e)for(let a of Object.keys(e)){let d=e[a];typeof d=="number"&&(d={interval:d}),td(p,a,d)}};function td(p,e,a={}){let d=p.timers[e]={name:e,start:Date.now(),ms:0,tick:0},i=a.interval||120;d.frames=a.frames||[],d.loading=!0;let t=setInterval(()=>{d.ms=Date.now()-d.start,d.tick++,p.render()},i);return d.stop=()=>{d.loading=!1,clearInterval(t)},Reflect.defineProperty(d,"interval",{value:t}),p.once("close",()=>d.stop()),d.stop}});var ap=h((g4,ep)=>{"use strict";var{define:sd,width:ld}=R(),pp=class{constructor(e){let a=e.options;sd(this,"_prompt",e),this.type=e.type,this.name=e.name,this.message="",this.header="",this.footer="",this.error="",this.hint="",this.input="",this.cursor=0,this.index=0,this.lines=0,this.tick=0,this.prompt="",this.buffer="",this.width=ld(a.stdout||process.stdout),Object.assign(this,a),this.name=this.name||this.message,this.message=this.message||this.name,this.symbols=e.symbols,this.styles=e.styles,this.required=new Set,this.cancelled=!1,this.submitted=!1}clone(){let e={...this};return e.status=this.status,e.buffer=Buffer.from(e.buffer),delete e.clone,e}set color(e){this._color=e}get color(){let e=this.prompt.styles;if(this.cancelled)return e.cancelled;if(this.submitted)return e.submitted;let a=this._color||e[this.status];return typeof a=="function"?a:e.pending}set loading(e){this._loading=e}get loading(){return typeof this._loading=="boolean"?this._loading:this.loadingChoices?"choices":!1}get status(){return this.cancelled?"cancelled":this.submitted?"submitted":"pending"}};ep.exports=pp});var ip=h((b4,dp)=>{"use strict";var me=R(),q=H(),re={default:q.noop,noop:q.noop,set inverse(p){this._inverse=p},get inverse(){return this._inverse||me.inverse(this.primary)},set complement(p){this._complement=p},get complement(){return this._complement||me.complement(this.primary)},primary:q.cyan,success:q.green,danger:q.magenta,strong:q.bold,warning:q.yellow,muted:q.dim,disabled:q.gray,dark:q.dim.gray,underline:q.underline,set info(p){this._info=p},get info(){return this._info||this.primary},set em(p){this._em=p},get em(){return this._em||this.primary.underline},set heading(p){this._heading=p},get heading(){return this._heading||this.muted.underline},set pending(p){this._pending=p},get pending(){return this._pending||this.primary},set submitted(p){this._submitted=p},get submitted(){return this._submitted||this.success},set cancelled(p){this._cancelled=p},get cancelled(){return this._cancelled||this.danger},set typing(p){this._typing=p},get typing(){return this._typing||this.dim},set placeholder(p){this._placeholder=p},get placeholder(){return this._placeholder||this.primary.dim},set highlight(p){this._highlight=p},get highlight(){return this._highlight||this.inverse}};re.merge=(p={})=>{p.styles&&typeof p.styles.enabled=="boolean"&&(q.enabled=p.styles.enabled),p.styles&&typeof p.styles.visible=="boolean"&&(q.visible=p.styles.visible);let e=me.merge({},re,p.styles);delete e.merge;for(let a of Object.keys(q))e.hasOwnProperty(a)||Reflect.defineProperty(e,a,{get:()=>q[a]});for(let a of Object.keys(q.styles))e.hasOwnProperty(a)||Reflect.defineProperty(e,a,{get:()=>q[a]});return e};dp.exports=re});var sp=h((y4,tp)=>{"use strict";var ne=process.platform==="win32",p1=H(),md=R(),oe={...p1.symbols,upDownDoubleArrow:"⇕",upDownDoubleArrow2:"⬍",upDownArrow:"↕",asterisk:"*",asterism:"⁂",bulletWhite:"◦",electricArrow:"⌁",ellipsisLarge:"⋯",ellipsisSmall:"…",fullBlock:"█",identicalTo:"≡",indicator:p1.symbols.check,leftAngle:"‹",mark:"※",minus:"−",multiplication:"×",obelus:"÷",percent:"%",pilcrow:"¶",pilcrow2:"❡",pencilUpRight:"✐",pencilDownRight:"✎",pencilRight:"✏",plus:"+",plusMinus:"±",pointRight:"☞",rightAngle:"›",section:"§",hexagon:{off:"⬡",on:"⬢",disabled:"⬢"},ballot:{on:"☑",off:"☐",disabled:"☒"},stars:{on:"★",off:"☆",disabled:"☆"},folder:{on:"▼",off:"▶",disabled:"▶"},prefix:{pending:p1.symbols.question,submitted:p1.symbols.check,cancelled:p1.symbols.cross},separator:{pending:p1.symbols.pointerSmall,submitted:p1.symbols.middot,cancelled:p1.symbols.middot},radio:{off:ne?"( )":"◯",on:ne?"(*)":"◉",disabled:ne?"(|)":"Ⓘ"},numbers:["⓪","①","②","③","④","⑤","⑥","⑦","⑧","⑨","⑩","⑪","⑫","⑬","⑭","⑮","⑯","⑰","⑱","⑲","⑳","㉑","㉒","㉓","㉔","㉕","㉖","㉗","㉘","㉙","㉚","㉛","㉜","㉝","㉞","㉟","㊱","㊲","㊳","㊴","㊵","㊶","㊷","㊸","㊹","㊺","㊻","㊼","㊽","㊾","㊿"]};oe.merge=p=>{let e=md.merge({},p1.symbols,oe,p.symbols);return delete e.merge,e};tp.exports=oe});var mp=h((_4,lp)=>{"use strict";var rd=ip(),nd=sp(),od=R();lp.exports=p=>{p.options=od.merge({},p.options.theme,p.options),p.symbols=nd.merge(p.options),p.styles=rd.merge(p.options)}});var hp=h((rp,np)=>{"use strict";var op=process.env.TERM_PROGRAM==="Apple_Terminal",ud=H(),ue=R(),W=np.exports=rp,V="[",up="\x07",he=!1,s1=W.code={bell:up,beep:up,beginning:`${V}G`,down:`${V}J`,esc:V,getPosition:`${V}6n`,hide:`${V}?25l`,line:`${V}2K`,lineEnd:`${V}K`,lineStart:`${V}1K`,restorePosition:V+(op?"8":"u"),savePosition:V+(op?"7":"s"),screen:`${V}2J`,show:`${V}?25h`,up:`${V}1J`},v1=W.cursor={get hidden(){return he},hide(){return he=!0,s1.hide},show(){return he=!1,s1.show},forward:(p=1)=>`${V}${p}C`,backward:(p=1)=>`${V}${p}D`,nextLine:(p=1)=>`${V}E`.repeat(p),prevLine:(p=1)=>`${V}F`.repeat(p),up:(p=1)=>p?`${V}${p}A`:"",down:(p=1)=>p?`${V}${p}B`:"",right:(p=1)=>p?`${V}${p}C`:"",left:(p=1)=>p?`${V}${p}D`:"",to(p,e){return e?`${V}${e+1};${p+1}H`:`${V}${p+1}G`},move(p=0,e=0){let a="";return a+=p<0?v1.left(-p):p>0?v1.right(p):"",a+=e<0?v1.up(-e):e>0?v1.down(e):"",a},restore(p={}){let{after:e,cursor:a,initial:d,input:i,prompt:t,size:s,value:m}=p;if(d=ue.isPrimitive(d)?String(d):"",i=ue.isPrimitive(i)?String(i):"",m=ue.isPrimitive(m)?String(m):"",s){let l=W.cursor.up(s)+W.cursor.to(t.length),r=i.length-a;return r>0&&(l+=W.cursor.left(r)),l}if(m||e){let l=!i&&!!d?-d.length:-i.length+a;return e&&(l-=e.length),i===""&&d&&!t.includes(d)&&(l+=d.length),W.cursor.move(l)}}},ce=W.erase={screen:s1.screen,up:s1.up,down:s1.down,line:s1.line,lineEnd:s1.lineEnd,lineStart:s1.lineStart,lines(p){let e="";for(let a=0;a<p;a++)e+=W.erase.line+(a<p-1?W.cursor.up(1):"");return p&&(e+=W.code.beginning),e}};W.clear=(p="",e=process.stdout.columns)=>{if(!e)return ce.line+v1.to(0);let a=t=>[...ud.unstyle(t)].length,d=p.split(/\r?\n/),i=0;for(let t of d)i+=1+Math.floor(Math.max(a(t)-1,0)/e);return(ce.line+v1.prevLine()).repeat(i-1)+ce.line+v1.to(0)}});var V1=h((N4,cp)=>{"use strict";var hd=require("events"),fp=H(),fe=Ye(),cd=Xe(),fd=ap(),vd=mp(),I=R(),w1=hp(),G1=class extends hd{constructor(e={}){super();this.name=e.name,this.type=e.type,this.options=e,vd(this),cd(this),this.state=new fd(this),this.initial=[e.initial,e.default].find(a=>a!=null),this.stdout=e.stdout||process.stdout,this.stdin=e.stdin||process.stdin,this.scale=e.scale||1,this.term=this.options.term||process.env.TERM_PROGRAM,this.margin=gd(this.options.margin),this.setMaxListeners(0),wd(this)}async keypress(e,a={}){this.keypressed=!0;let d=fe.action(e,fe(e,a),this.options.actions);this.state.keypress=d,this.emit("keypress",e,d),this.emit("state",this.state.clone());let i=this.options[d.action]||this[d.action]||this.dispatch;if(typeof i=="function")return await i.call(this,e,d);this.alert()}alert(){delete this.state.alert,this.options.show===!1?this.emit("alert"):this.stdout.write(w1.code.beep)}cursorHide(){this.stdout.write(w1.cursor.hide()),I.onExit(()=>this.cursorShow())}cursorShow(){this.stdout.write(w1.cursor.show())}write(e){!e||(this.stdout&&this.state.show!==!1&&this.stdout.write(e),this.state.buffer+=e)}clear(e=0){let a=this.state.buffer;this.state.buffer="",!(!a&&!e||this.options.show===!1)&&this.stdout.write(w1.cursor.down(e)+w1.clear(a,this.width))}restore(){if(this.state.closed||this.options.show===!1)return;let{prompt:e,after:a,rest:d}=this.sections(),{cursor:i,initial:t="",input:s="",value:m=""}=this,l=this.state.size=d.length,r={after:a,cursor:i,initial:t,input:s,prompt:e,size:l,value:m},o=w1.cursor.restore(r);o&&this.stdout.write(o)}sections(){let{buffer:e,input:a,prompt:d}=this.state;d=fp.unstyle(d);let i=fp.unstyle(e),t=i.indexOf(d),s=i.slice(0,t),l=i.slice(t).split(`
`),r=l[0],o=l[l.length-1],S=(d+(a?" "+a:"")).length,v=S<r.length?r.slice(S+1):"";return{header:s,prompt:r,after:v,rest:l.slice(1),last:o}}async submit(){this.state.submitted=!0,this.state.validating=!0,this.options.onSubmit&&await this.options.onSubmit.call(this,this.name,this.value,this);let e=this.state.error||await this.validate(this.value,this.state);if(e!==!0){let a=`
`+this.symbols.pointer+" ";typeof e=="string"?a+=e.trim():a+="Invalid input",this.state.error=`
`+this.styles.danger(a),this.state.submitted=!1,await this.render(),await this.alert(),this.state.validating=!1,this.state.error=void 0;return}this.state.validating=!1,await this.render(),await this.close(),this.value=await this.result(this.value),this.emit("submit",this.value)}async cancel(e){this.state.cancelled=this.state.submitted=!0,await this.render(),await this.close(),typeof this.options.onCancel=="function"&&await this.options.onCancel.call(this,this.name,this.value,this),this.emit("cancel",await this.error(e))}async close(){this.state.closed=!0;try{let e=this.sections(),a=Math.ceil(e.prompt.length/this.width);e.rest&&this.write(w1.cursor.down(e.rest.length)),this.write(`
`.repeat(a))}catch(e){}this.emit("close")}start(){!this.stop&&this.options.show!==!1&&(this.stop=fe.listen(this,this.keypress.bind(this)),this.once("close",this.stop))}async skip(){return this.skipped=this.options.skip===!0,typeof this.options.skip=="function"&&(this.skipped=await this.options.skip.call(this,this.name,this.value)),this.skipped}async initialize(){let{format:e,options:a,result:d}=this;if(this.format=()=>e.call(this,this.value),this.result=()=>d.call(this,this.value),typeof a.initial=="function"&&(this.initial=await a.initial.call(this,this)),typeof a.onRun=="function"&&await a.onRun.call(this,this),typeof a.onSubmit=="function"){let i=a.onSubmit.bind(this),t=this.submit.bind(this);delete this.options.onSubmit,this.submit=async()=>(await i(this.name,this.value,this),t())}await this.start(),await this.render()}render(){throw new Error("expected prompt to have a custom render method")}run(){return new Promise(async(e,a)=>{if(this.once("submit",e),this.once("cancel",a),await this.skip())return this.render=()=>{},this.submit();await this.initialize(),this.emit("run")})}async element(e,a,d){let{options:i,state:t,symbols:s,timers:m}=this,l=m&&m[e];t.timer=l;let r=i[e]||t[e]||s[e],o=a&&a[e]!=null?a[e]:await r;if(o==="")return o;let n=await this.resolve(o,t,a,d);return!n&&a&&a[e]?this.resolve(r,t,a,d):n}async prefix(){let e=await this.element("prefix")||this.symbols,a=this.timers&&this.timers.prefix,d=this.state;return d.timer=a,I.isObject(e)&&(e=e[d.status]||e.pending),I.hasColor(e)?e:(this.styles[d.status]||this.styles.pending)(e)}async message(){let e=await this.element("message");return I.hasColor(e)?e:this.styles.strong(e)}async separator(){let e=await this.element("separator")||this.symbols,a=this.timers&&this.timers.separator,d=this.state;d.timer=a;let i=e[d.status]||e.pending||d.separator,t=await this.resolve(i,d);return I.isObject(t)&&(t=t[d.status]||t.pending),I.hasColor(t)?t:this.styles.muted(t)}async pointer(e,a){let d=await this.element("pointer",e,a);if(typeof d=="string"&&I.hasColor(d))return d;if(d){let i=this.styles,t=this.index===a,s=t?i.primary:r=>r,m=await this.resolve(d[t?"on":"off"]||d,this.state),l=I.hasColor(m)?m:s(m);return t?l:" ".repeat(m.length)}}async indicator(e,a){let d=await this.element("indicator",e,a);if(typeof d=="string"&&I.hasColor(d))return d;if(d){let i=this.styles,t=e.enabled===!0,s=t?i.success:i.dark,m=d[t?"on":"off"]||d;return I.hasColor(m)?m:s(m)}return""}body(){return null}footer(){if(this.state.status==="pending")return this.element("footer")}header(){if(this.state.status==="pending")return this.element("header")}async hint(){if(this.state.status==="pending"&&!this.isValue(this.state.input)){let e=await this.element("hint");return I.hasColor(e)?e:this.styles.muted(e)}}error(e){return this.state.submitted?"":e||this.state.error}format(e){return e}result(e){return e}validate(e){return this.options.required===!0?this.isValue(e):!0}isValue(e){return e!=null&&e!==""}resolve(e,...a){return I.resolve(this,e,...a)}get base(){return G1.prototype}get style(){return this.styles[this.state.status]}get height(){return this.options.rows||I.height(this.stdout,25)}get width(){return this.options.columns||I.width(this.stdout,80)}get size(){return{width:this.width,height:this.height}}set cursor(e){this.state.cursor=e}get cursor(){return this.state.cursor}set input(e){this.state.input=e}get input(){return this.state.input}set value(e){this.state.value=e}get value(){let{input:e,value:a}=this.state,d=[a,e].find(this.isValue.bind(this));return this.isValue(d)?d:this.initial}static get prompt(){return e=>new this(e).run()}};function wd(p){let e=i=>p[i]===void 0||typeof p[i]=="function",a=["actions","choices","initial","margin","roles","styles","symbols","theme","timers","value"],d=["body","footer","error","header","hint","indicator","message","prefix","separator","skip"];for(let i of Object.keys(p.options)){if(a.includes(i)||/^on[A-Z]/.test(i))continue;let t=p.options[i];typeof t=="function"&&e(i)?d.includes(i)||(p[i]=t.bind(p)):typeof p[i]!="function"&&(p[i]=t)}}function gd(p){typeof p=="number"&&(p=[p,p,p,p]);let e=[].concat(p||[]),a=i=>i%2==0?`
`:" ",d=[];for(let i=0;i<4;i++){let t=a(i);e[i]?d.push(t.repeat(e[i])):d.push("")}return d}cp.exports=G1});var gp=h((S4,vp)=>{"use strict";var bd=R(),wp={default(p,e){return e},checkbox(p,e){throw new Error("checkbox role is not implemented yet")},editable(p,e){throw new Error("editable role is not implemented yet")},expandable(p,e){throw new Error("expandable role is not implemented yet")},heading(p,e){return e.disabled="",e.indicator=[e.indicator," "].find(a=>a!=null),e.message=e.message||"",e},input(p,e){throw new Error("input role is not implemented yet")},option(p,e){return wp.default(p,e)},radio(p,e){throw new Error("radio role is not implemented yet")},separator(p,e){return e.disabled="",e.indicator=[e.indicator," "].find(a=>a!=null),e.message=e.message||p.symbols.line.repeat(5),e},spacer(p,e){return e}};vp.exports=(p,e={})=>{let a=bd.merge({},wp,e.roles);return a[p]||a.default}});var k1=h((D4,bp)=>{"use strict";var yd=H(),_d=V1(),Nd=gp(),K1=R(),{reorder:ve,scrollUp:Sd,scrollDown:Dd,isObject:yp,swap:Vd}=K1,_p=class extends _d{constructor(e){super(e);this.cursorHide(),this.maxSelected=e.maxSelected||Infinity,this.multiple=e.multiple||!1,this.initial=e.initial||0,this.delay=e.delay||0,this.longest=0,this.num=""}async initialize(){typeof this.options.initial=="function"&&(this.initial=await this.options.initial.call(this)),await this.reset(!0),await super.initialize()}async reset(){let{choices:e,initial:a,autofocus:d,suggest:i}=this.options;if(this.state._choices=[],this.state.choices=[],this.choices=await Promise.all(await this.toChoices(e)),this.choices.forEach(t=>t.enabled=!1),typeof i!="function"&&this.selectable.length===0)throw new Error("At least one choice must be selectable");yp(a)&&(a=Object.keys(a)),Array.isArray(a)?(d!=null&&(this.index=this.findIndex(d)),a.forEach(t=>this.enable(this.find(t))),await this.render()):(d!=null&&(a=d),typeof a=="string"&&(a=this.findIndex(a)),typeof a=="number"&&a>-1&&(this.index=Math.max(0,Math.min(a,this.choices.length)),this.enable(this.find(this.index)))),this.isDisabled(this.focused)&&await this.down()}async toChoices(e,a){this.state.loadingChoices=!0;let d=[],i=0,t=async(s,m)=>{typeof s=="function"&&(s=await s.call(this)),s instanceof Promise&&(s=await s);for(let l=0;l<s.length;l++){let r=s[l]=await this.toChoice(s[l],i++,m);d.push(r),r.choices&&await t(r.choices,r)}return d};return t(e,a).then(s=>(this.state.loadingChoices=!1,s))}async toChoice(e,a,d){if(typeof e=="function"&&(e=await e.call(this,this)),e instanceof Promise&&(e=await e),typeof e=="string"&&(e={name:e}),e.normalized)return e;e.normalized=!0;let i=e.value;if(e=Nd(e.role,this.options)(this,e),typeof e.disabled=="string"&&!e.hint&&(e.hint=e.disabled,e.disabled=!0),e.disabled===!0&&e.hint==null&&(e.hint="(disabled)"),e.index!=null)return e;e.name=e.name||e.key||e.title||e.value||e.message,e.message=e.message||e.name||"",e.value=[e.value,e.name].find(this.isValue.bind(this)),e.input="",e.index=a,e.cursor=0,K1.define(e,"parent",d),e.level=d?d.level+1:1,e.indent==null&&(e.indent=d?d.indent+" ":e.indent||""),e.path=d?d.path+"."+e.name:e.name,e.enabled=!!(this.multiple&&!this.isDisabled(e)&&(e.enabled||this.isSelected(e))),this.isDisabled(e)||(this.longest=Math.max(this.longest,yd.unstyle(e.message).length));let s={...e};return e.reset=(m=s.input,l=s.value)=>{for(let r of Object.keys(s))e[r]=s[r];e.input=m,e.value=l},i==null&&typeof e.initial=="function"&&(e.input=await e.initial.call(this,this.state,e,a)),e}async onChoice(e,a){this.emit("choice",e,a,this),typeof e.onChoice=="function"&&await e.onChoice.call(this,this.state,e,a)}async addChoice(e,a,d){let i=await this.toChoice(e,a,d);return this.choices.push(i),this.index=this.choices.length-1,this.limit=this.choices.length,i}async newItem(e,a,d){let i={name:"New choice name?",editable:!0,newChoice:!0,...e},t=await this.addChoice(i,a,d);return t.updateChoice=()=>{delete t.newChoice,t.name=t.message=t.input,t.input="",t.cursor=0},this.render()}indent(e){return e.indent==null?e.level>1?" ".repeat(e.level-1):"":e.indent}dispatch(e,a){if(this.multiple&&this[a.name])return this[a.name]();this.alert()}focus(e,a){return typeof a!="boolean"&&(a=e.enabled),a&&!e.enabled&&this.selected.length>=this.maxSelected?this.alert():(this.index=e.index,e.enabled=a&&!this.isDisabled(e),e)}space(){return this.multiple?(this.toggle(this.focused),this.render()):this.alert()}a(){if(this.maxSelected<this.choices.length)return this.alert();let e=this.selectable.every(a=>a.enabled);return this.choices.forEach(a=>a.enabled=!e),this.render()}i(){return this.choices.length-this.selected.length>this.maxSelected?this.alert():(this.choices.forEach(e=>e.enabled=!e.enabled),this.render())}g(e=this.focused){return this.choices.some(a=>!!a.parent)?(this.toggle(e.parent&&!e.choices?e.parent:e),this.render()):this.a()}toggle(e,a){if(!e.enabled&&this.selected.length>=this.maxSelected)return this.alert();typeof a!="boolean"&&(a=!e.enabled),e.enabled=a,e.choices&&e.choices.forEach(i=>this.toggle(i,a));let d=e.parent;for(;d;){let i=d.choices.filter(t=>this.isDisabled(t));d.enabled=i.every(t=>t.enabled===!0),d=d.parent}return Np(this,this.choices),this.emit("toggle",e,this),e}enable(e){return this.selected.length>=this.maxSelected?this.alert():(e.enabled=!this.isDisabled(e),e.choices&&e.choices.forEach(this.enable.bind(this)),e)}disable(e){return e.enabled=!1,e.choices&&e.choices.forEach(this.disable.bind(this)),e}number(e){this.num+=e;let a=d=>{let i=Number(d);if(i>this.choices.length-1)return this.alert();let t=this.focused,s=this.choices.find(m=>i===m.index);if(!s.enabled&&this.selected.length>=this.maxSelected)return this.alert();if(this.visible.indexOf(s)===-1){let m=ve(this.choices),l=m.indexOf(s);if(t.index>l){let r=m.slice(l,l+this.limit),o=m.filter(n=>!r.includes(n));this.choices=r.concat(o)}else{let r=l-this.limit+1;this.choices=m.slice(r).concat(m.slice(0,r))}}return this.index=this.choices.indexOf(s),this.toggle(this.focused),this.render()};return clearTimeout(this.numberTimeout),new Promise(d=>{let i=this.choices.length,t=this.num,s=(m=!1,l)=>{clearTimeout(this.numberTimeout),m&&(l=a(t)),this.num="",d(l)};if(t==="0"||t.length===1&&Number(t+"0")>i)return s(!0);if(Number(t)>i)return s(!1,this.alert());this.numberTimeout=setTimeout(()=>s(!0),this.delay)})}home(){return this.choices=ve(this.choices),this.index=0,this.render()}end(){let e=this.choices.length-this.limit,a=ve(this.choices);return this.choices=a.slice(e).concat(a.slice(0,e)),this.index=this.limit-1,this.render()}first(){return this.index=0,this.render()}last(){return this.index=this.visible.length-1,this.render()}prev(){return this.visible.length<=1?this.alert():this.up()}next(){return this.visible.length<=1?this.alert():this.down()}right(){return this.cursor>=this.input.length?this.alert():(this.cursor++,this.render())}left(){return this.cursor<=0?this.alert():(this.cursor--,this.render())}up(){let e=this.choices.length,a=this.visible.length,d=this.index;return this.options.scroll===!1&&d===0?this.alert():e>a&&d===0?this.scrollUp():(this.index=(d-1%e+e)%e,this.isDisabled()?this.up():this.render())}down(){let e=this.choices.length,a=this.visible.length,d=this.index;return this.options.scroll===!1&&d===a-1?this.alert():e>a&&d===a-1?this.scrollDown():(this.index=(d+1)%e,this.isDisabled()?this.down():this.render())}scrollUp(e=0){return this.choices=Sd(this.choices),this.index=e,this.isDisabled()?this.up():this.render()}scrollDown(e=this.visible.length-1){return this.choices=Dd(this.choices),this.index=e,this.isDisabled()?this.down():this.render()}async shiftUp(){if(this.options.sort===!0){this.sorting=!0,this.swap(this.index-1),await this.up(),this.sorting=!1;return}return this.scrollUp(this.index)}async shiftDown(){if(this.options.sort===!0){this.sorting=!0,this.swap(this.index+1),await this.down(),this.sorting=!1;return}return this.scrollDown(this.index)}pageUp(){return this.visible.length<=1?this.alert():(this.limit=Math.max(this.limit-1,0),this.index=Math.min(this.limit-1,this.index),this._limit=this.limit,this.isDisabled()?this.up():this.render())}pageDown(){return this.visible.length>=this.choices.length?this.alert():(this.index=Math.max(0,this.index),this.limit=Math.min(this.limit+1,this.choices.length),this._limit=this.limit,this.isDisabled()?this.down():this.render())}swap(e){Vd(this.choices,this.index,e)}isDisabled(e=this.focused){return e&&["disabled","collapsed","hidden","completing","readonly"].some(d=>e[d]===!0)?!0:e&&e.role==="heading"}isEnabled(e=this.focused){if(Array.isArray(e))return e.every(a=>this.isEnabled(a));if(e.choices){let a=e.choices.filter(d=>!this.isDisabled(d));return e.enabled&&a.every(d=>this.isEnabled(d))}return e.enabled&&!this.isDisabled(e)}isChoice(e,a){return e.name===a||e.index===Number(a)}isSelected(e){return Array.isArray(this.initial)?this.initial.some(a=>this.isChoice(e,a)):this.isChoice(e,this.initial)}map(e=[],a="value"){return[].concat(e||[]).reduce((d,i)=>(d[i]=this.find(i,a),d),{})}filter(e,a){let d=(m,l)=>[m.name,l].includes(e),i=typeof e=="function"?e:d,s=(this.options.multiple?this.state._choices:this.choices).filter(i);return a?s.map(m=>m[a]):s}find(e,a){if(yp(e))return a?e[a]:e;let d=(s,m)=>[s.name,m].includes(e),i=typeof e=="function"?e:d,t=this.choices.find(i);if(t)return a?t[a]:t}findIndex(e){return this.choices.indexOf(this.find(e))}async submit(){let e=this.focused;if(!e)return this.alert();if(e.newChoice)return e.input?(e.updateChoice(),this.render()):this.alert();if(this.choices.some(s=>s.newChoice))return this.alert();let{reorder:a,sort:d}=this.options,i=this.multiple===!0,t=this.selected;return t===void 0?this.alert():(Array.isArray(t)&&a!==!1&&d!==!0&&(t=K1.reorder(t)),this.value=i?t.map(s=>s.name):t.name,super.submit())}set choices(e=[]){this.state._choices=this.state._choices||[],this.state.choices=e;for(let a of e)this.state._choices.some(d=>d.name===a.name)||this.state._choices.push(a);if(!this._initial&&this.options.initial){this._initial=!0;let a=this.initial;if(typeof a=="string"||typeof a=="number"){let d=this.find(a);d&&(this.initial=d.index,this.focus(d,!0))}}}get choices(){return Np(this,this.state.choices||[])}set visible(e){this.state.visible=e}get visible(){return(this.state.visible||this.choices).slice(0,this.limit)}set limit(e){this.state.limit=e}get limit(){let{state:e,options:a,choices:d}=this,i=e.limit||this._limit||a.limit||d.length;return Math.min(i,this.height)}set value(e){super.value=e}get value(){return typeof super.value!="string"&&super.value===this.initial?this.input:super.value}set index(e){this.state.index=e}get index(){return Math.max(0,this.state?this.state.index:0)}get enabled(){return this.filter(this.isEnabled.bind(this))}get focused(){let e=this.choices[this.index];return e&&this.state.submitted&&this.multiple!==!0&&(e.enabled=!0),e}get selectable(){return this.choices.filter(e=>!this.isDisabled(e))}get selected(){return this.multiple?this.enabled:this.focused}};function Np(p,e){if(e instanceof Promise)return e;if(typeof e=="function"){if(K1.isAsyncFn(e))return e;e=e.call(p,p)}for(let a of e){if(Array.isArray(a.choices)){let d=a.choices.filter(i=>!p.isDisabled(i));a.enabled=d.every(i=>i.enabled===!0)}p.isDisabled(a)===!0&&delete a.enabled}return e}bp.exports=_p});var l1=h((V4,Sp)=>{"use strict";var Td=k1(),we=R(),Dp=class extends Td{constructor(e){super(e);this.emptyError=this.options.emptyError||"No items were selected"}async dispatch(e,a){if(this.multiple)return this[a.name]?await this[a.name](e,a):await super.dispatch(e,a);this.alert()}separator(){if(this.options.separator)return super.separator();let e=this.styles.muted(this.symbols.ellipsis);return this.state.submitted?super.separator():e}pointer(e,a){return!this.multiple||this.options.pointer?super.pointer(e,a):""}indicator(e,a){return this.multiple?super.indicator(e,a):""}choiceMessage(e,a){let d=this.resolve(e.message,this.state,e,a);return e.role==="heading"&&!we.hasColor(d)&&(d=this.styles.strong(d)),this.resolve(d,this.state,e,a)}choiceSeparator(){return":"}async renderChoice(e,a){await this.onChoice(e,a);let d=this.index===a,i=await this.pointer(e,a),t=await this.indicator(e,a)+(e.pad||""),s=await this.resolve(e.hint,this.state,e,a);s&&!we.hasColor(s)&&(s=this.styles.muted(s));let m=this.indent(e),l=await this.choiceMessage(e,a),r=()=>[this.margin[3],m+i+t,l,this.margin[1],s].filter(Boolean).join(" ");return e.role==="heading"?r():e.disabled?(we.hasColor(l)||(l=this.styles.disabled(l)),r()):(d&&(l=this.styles.em(l)),r())}async renderChoices(){if(this.state.loading==="choices")return this.styles.warning("Loading choices");if(this.state.submitted)return"";let e=this.visible.map(async(t,s)=>await this.renderChoice(t,s)),a=await Promise.all(e);a.length||a.push(this.styles.danger("No matching choices"));let d=this.margin[0]+a.join(`
`),i;return this.options.choicesHeader&&(i=await this.resolve(this.options.choicesHeader,this.state)),[i,d].filter(Boolean).join(`
`)}format(){return!this.state.submitted||this.state.cancelled?"":Array.isArray(this.selected)?this.selected.map(e=>this.styles.primary(e.name)).join(", "):this.styles.primary(this.selected.name)}async render(){let{submitted:e,size:a}=this.state,d="",i=await this.header(),t=await this.prefix(),s=await this.separator(),m=await this.message();this.options.promptLine!==!1&&(d=[t,m,s,""].join(" "),this.state.prompt=d);let l=await this.format(),r=await this.error()||await this.hint(),o=await this.renderChoices(),n=await this.footer();l&&(d+=l),r&&!d.includes(r)&&(d+=" "+r),e&&!l&&!o.trim()&&this.multiple&&this.emptyError!=null&&(d+=this.styles.danger(this.emptyError)),this.clear(a),this.write([i,d,o,n].filter(Boolean).join(`
`)),this.write(this.margin[2]),this.restore()}};Sp.exports=Dp});var xp=h((T4,Vp)=>{"use strict";var xd=l1(),Cd=(p,e)=>{let a=p.toLowerCase();return d=>{let t=d.toLowerCase().indexOf(a),s=e(d.slice(t,t+a.length));return t>=0?d.slice(0,t)+s+d.slice(t+a.length):d}},Tp=class extends xd{constructor(e){super(e);this.cursorShow()}moveCursor(e){this.state.cursor+=e}dispatch(e){return this.append(e)}space(e){return this.options.multiple?super.space(e):this.append(e)}append(e){let{cursor:a,input:d}=this.state;return this.input=d.slice(0,a)+e+d.slice(a),this.moveCursor(1),this.complete()}delete(){let{cursor:e,input:a}=this.state;return a?(this.input=a.slice(0,e-1)+a.slice(e),this.moveCursor(-1),this.complete()):this.alert()}deleteForward(){let{cursor:e,input:a}=this.state;return a[e]===void 0?this.alert():(this.input=`${a}`.slice(0,e)+`${a}`.slice(e+1),this.complete())}number(e){return this.append(e)}async complete(){this.completing=!0,this.choices=await this.suggest(this.input,this.state._choices),this.state.limit=void 0,this.index=Math.min(Math.max(this.visible.length-1,0),this.index),await this.render(),this.completing=!1}suggest(e=this.input,a=this.state._choices){if(typeof this.options.suggest=="function")return this.options.suggest.call(this,e,a);let d=e.toLowerCase();return a.filter(i=>i.message.toLowerCase().includes(d))}pointer(){return""}format(){if(!this.focused)return this.input;if(this.options.multiple&&this.state.submitted)return this.selected.map(e=>this.styles.primary(e.message)).join(", ");if(this.state.submitted){let e=this.value=this.input=this.focused.value;return this.styles.primary(e)}return this.input}async render(){if(this.state.status!=="pending")return super.render();let e=this.options.highlight?this.options.highlight.bind(this):this.styles.placeholder,a=Cd(this.input,e),d=this.choices;this.choices=d.map(i=>({...i,message:a(i.message)})),await super.render(),this.choices=d}submit(){return this.options.multiple&&(this.value=this.selected.map(e=>e.name)),super.submit()}};Vp.exports=Tp});var be=h((x4,Cp)=>{"use strict";var ge=R();Cp.exports=(p,e={})=>{p.cursorHide();let{input:a="",initial:d="",pos:i,showCursor:t=!0,color:s}=e,m=s||p.styles.placeholder,l=ge.inverse(p.styles.primary),r=y=>l(p.styles.black(y)),o=a,n=" ",S=r(n);if(p.blink&&p.blink.off===!0&&(r=y=>y,S=""),t&&i===0&&d===""&&a==="")return r(n);if(t&&i===0&&(a===d||a===""))return r(d[0])+m(d.slice(1));d=ge.isPrimitive(d)?`${d}`:"",a=ge.isPrimitive(a)?`${a}`:"";let v=d&&d.startsWith(a)&&d!==a,u=v?r(d[a.length]):S;if(i!==a.length&&t===!0&&(o=a.slice(0,i)+r(a[i])+a.slice(i+1),u=""),t===!1&&(u=""),v){let y=p.styles.unstyle(o+u);return o+u+m(d.slice(y.length))}return o+u}});var Z1=h((C4,Ap)=>{"use strict";var Ad=H(),Ed=l1(),Bd=be(),Ep=class extends Ed{constructor(e){super({...e,multiple:!0});this.type="form",this.initial=this.options.initial,this.align=[this.options.align,"right"].find(a=>a!=null),this.emptyError="",this.values={}}async reset(e){return await super.reset(),e===!0&&(this._index=this.index),this.index=this._index,this.values={},this.choices.forEach(a=>a.reset&&a.reset()),this.render()}dispatch(e){return!!e&&this.append(e)}append(e){let a=this.focused;if(!a)return this.alert();let{cursor:d,input:i}=a;return a.value=a.input=i.slice(0,d)+e+i.slice(d),a.cursor++,this.render()}delete(){let e=this.focused;if(!e||e.cursor<=0)return this.alert();let{cursor:a,input:d}=e;return e.value=e.input=d.slice(0,a-1)+d.slice(a),e.cursor--,this.render()}deleteForward(){let e=this.focused;if(!e)return this.alert();let{cursor:a,input:d}=e;if(d[a]===void 0)return this.alert();let i=`${d}`.slice(0,a)+`${d}`.slice(a+1);return e.value=e.input=i,this.render()}right(){let e=this.focused;return e?e.cursor>=e.input.length?this.alert():(e.cursor++,this.render()):this.alert()}left(){let e=this.focused;return e?e.cursor<=0?this.alert():(e.cursor--,this.render()):this.alert()}space(e,a){return this.dispatch(e,a)}number(e,a){return this.dispatch(e,a)}next(){let e=this.focused;if(!e)return this.alert();let{initial:a,input:d}=e;return a&&a.startsWith(d)&&d!==a?(e.value=e.input=a,e.cursor=e.value.length,this.render()):super.next()}prev(){let e=this.focused;return e?e.cursor===0?super.prev():(e.value=e.input="",e.cursor=0,this.render()):this.alert()}separator(){return""}format(e){return this.state.submitted?"":super.format(e)}pointer(){return""}indicator(e){return e.input?"⦿":"⊙"}async choiceSeparator(e,a){let d=await this.resolve(e.separator,this.state,e,a)||":";return d?" "+this.styles.disabled(d):""}async renderChoice(e,a){await this.onChoice(e,a);let{state:d,styles:i}=this,{cursor:t,initial:s="",name:m,hint:l,input:r=""}=e,{muted:o,submitted:n,primary:S,danger:v}=i,u=l,y=this.index===a,D=e.validate||(()=>!0),c=await this.choiceSeparator(e,a),f=e.message;this.align==="right"&&(f=f.padStart(this.longest+1," ")),this.align==="left"&&(f=f.padEnd(this.longest+1," "));let w=this.values[m]=r||s,_=r?"success":"dark";await D.call(e,w,this.state)!==!0&&(_="danger");let k=i[_](await this.indicator(e,a))+(e.pad||""),M1=this.indent(e),c1=()=>[M1,k,f+c,r,u].filter(Boolean).join(" ");if(d.submitted)return f=Ad.unstyle(f),r=n(r),u="",c1();if(e.format)r=await e.format.call(this,r,e,a);else{let de=this.styles.muted;r=Bd(this,{input:r,initial:s,pos:t,showCursor:y,color:de})}return this.isValue(r)||(r=this.styles.muted(this.symbols.ellipsis)),e.result&&(this.values[m]=await e.result.call(this,w,e,a)),y&&(f=S(f)),e.error?r+=(r?" ":"")+v(e.error.trim()):e.hint&&(r+=(r?" ":"")+o(e.hint.trim())),c1()}async submit(){return this.value=this.values,super.base.submit.call(this)}};Ap.exports=Ep});var ye=h((A4,Bp)=>{"use strict";var Pd=Z1(),Od=()=>{throw new Error("expected prompt to have a custom authenticate method")},Pp=(p=Od)=>{class e extends Pd{constructor(d){super(d)}async submit(){this.value=await p.call(this,this.values,this.state),super.base.submit.call(this)}static create(d){return Pp(d)}}return e};Bp.exports=Pp()});var kp=h((E4,Op)=>{"use strict";var Fd=ye();function kd(p,e){return p.username===this.options.username&&p.password===this.options.password}var Fp=(p=kd)=>{let e=[{name:"username",message:"username"},{name:"password",message:"password",format(d){return this.options.showPassword?d:(this.state.submitted?this.styles.primary:this.styles.muted)(this.symbols.asterisk.repeat(d.length))}}];class a extends Fd.create(p){constructor(i){super({...i,choices:e})}static create(i){return Fp(i)}}return a};Op.exports=Fp()});var J1=h((B4,qp)=>{"use strict";var qd=V1(),{isPrimitive:Rd,hasColor:Ld}=R(),Rp=class extends qd{constructor(e){super(e);this.cursorHide()}async initialize(){let e=await this.resolve(this.initial,this.state);this.input=await this.cast(e),await super.initialize()}dispatch(e){return this.isValue(e)?(this.input=e,this.submit()):this.alert()}format(e){let{styles:a,state:d}=this;return d.submitted?a.success(e):a.primary(e)}cast(e){return this.isTrue(e)}isTrue(e){return/^[ty1]/i.test(e)}isFalse(e){return/^[fn0]/i.test(e)}isValue(e){return Rd(e)&&(this.isTrue(e)||this.isFalse(e))}async hint(){if(this.state.status==="pending"){let e=await this.element("hint");return Ld(e)?e:this.styles.muted(e)}}async render(){let{input:e,size:a}=this.state,d=await this.prefix(),i=await this.separator(),t=await this.message(),s=this.styles.muted(this.default),m=[d,t,s,i].filter(Boolean).join(" ");this.state.prompt=m;let l=await this.header(),r=this.value=this.cast(e),o=await this.format(r),n=await this.error()||await this.hint(),S=await this.footer();n&&!m.includes(n)&&(o+=" "+n),m+=" "+o,this.clear(a),this.write([l,m,S].filter(Boolean).join(`
`)),this.restore()}set value(e){super.value=e}get value(){return this.cast(super.value)}};qp.exports=Rp});var jp=h((P4,Lp)=>{"use strict";var Id=J1(),Ip=class extends Id{constructor(e){super(e);this.default=this.options.default||(this.initial?"(Y/n)":"(y/N)")}};Lp.exports=Ip});var zp=h((O4,Up)=>{"use strict";var jd=l1(),Ud=Z1(),T1=Ud.prototype,$p=class extends jd{constructor(e){super({...e,multiple:!0});this.align=[this.options.align,"left"].find(a=>a!=null),this.emptyError="",this.values={}}dispatch(e,a){let d=this.focused,i=d.parent||{};return!d.editable&&!i.editable&&(e==="a"||e==="i")?super[e]():T1.dispatch.call(this,e,a)}append(e,a){return T1.append.call(this,e,a)}delete(e,a){return T1.delete.call(this,e,a)}space(e){return this.focused.editable?this.append(e):super.space()}number(e){return this.focused.editable?this.append(e):super.number(e)}next(){return this.focused.editable?T1.next.call(this):super.next()}prev(){return this.focused.editable?T1.prev.call(this):super.prev()}async indicator(e,a){let d=e.indicator||"",i=e.editable?d:super.indicator(e,a);return await this.resolve(i,this.state,e,a)||""}indent(e){return e.role==="heading"?"":e.editable?" ":" "}async renderChoice(e,a){return e.indent="",e.editable?T1.renderChoice.call(this,e,a):super.renderChoice(e,a)}error(){return""}footer(){return this.state.error}async validate(){let e=!0;for(let a of this.choices){if(typeof a.validate!="function"||a.role==="heading")continue;let d=a.parent?this.value[a.parent.name]:this.value;if(a.editable?d=a.value===a.name?a.initial||"":a.value:this.isDisabled(a)||(d=a.enabled===!0),e=await a.validate(d,this.state),e!==!0)break}return e!==!0&&(this.state.error=typeof e=="string"?e:"Invalid Input"),e}submit(){if(this.focused.newChoice===!0)return super.submit();if(this.choices.some(e=>e.newChoice))return this.alert();this.value={};for(let e of this.choices){let a=e.parent?this.value[e.parent.name]:this.value;if(e.role==="heading"){this.value[e.name]={};continue}e.editable?a[e.name]=e.value===e.name?e.initial||"":e.value:this.isDisabled(e)||(a[e.name]=e.enabled===!0)}return this.base.submit.call(this)}};Up.exports=$p});var g1=h((F4,Mp)=>{"use strict";var $d=V1(),zd=be(),{isPrimitive:Md}=R(),Hp=class extends $d{constructor(e){super(e);this.initial=Md(this.initial)?String(this.initial):"",this.initial&&this.cursorHide(),this.state.prevCursor=0,this.state.clipboard=[]}async keypress(e,a={}){let d=this.state.prevKeypress;return this.state.prevKeypress=a,this.options.multiline===!0&&a.name==="return"&&(!d||d.name!=="return")?this.append(`
`,a):super.keypress(e,a)}moveCursor(e){this.cursor+=e}reset(){return this.input=this.value="",this.cursor=0,this.render()}dispatch(e,a){if(!e||a.ctrl||a.code)return this.alert();this.app