UNPKG

99.3 kBJavaScriptView Raw
1var Is=Object.create,Re=Object.defineProperty,zs=Object.getPrototypeOf,Ds=Object.prototype.hasOwnProperty,Ms=Object.getOwnPropertyNames,Ns=Object.getOwnPropertyDescriptor;var Fs=i=>Re(i,"__esModule",{value:!0});var m=(i,e)=>()=>(e||(e={exports:{}},i(e.exports,e)),e.exports);var Us=(i,e,t)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of Ms(e))!Ds.call(i,s)&&s!=="default"&&Re(i,s,{get:()=>e[s],enumerable:!(t=Ns(e,s))||t.enumerable});return i},N=i=>Us(Fs(Re(i!=null?Is(zs(i)):{},"default",i&&i.__esModule&&"default"in i?{get:()=>i.default,enumerable:!0}:{value:i,enumerable:!0})),i);var gt=m(($n,me)=>{"use strict";var Hs=process.env.TERM_PROGRAM==="Hyper",Vs=process.platform==="win32",dt=process.platform==="linux",Le={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:"↕"},pt=Object.assign({},Le,{check:"√",cross:"×",ellipsisLarge:"...",ellipsis:"...",info:"i",question:"?",questionSmall:"?",pointer:">",pointerSmall:"»",radioOff:"( )",radioOn:"(*)",warning:"‼"}),mt=Object.assign({},Le,{ballotCross:"✘",check:"✔",cross:"✖",ellipsisLarge:"⋯",ellipsis:"…",info:"ℹ",question:"?",questionFull:"?",questionSmall:"﹖",pointer:dt?"▸":"❯",pointerSmall:dt?"‣":"›",radioOff:"◯",radioOn:"◉",warning:"⚠"});me.exports=Vs&&!Hs?pt:mt;Reflect.defineProperty(me.exports,"common",{enumerable:!1,value:Le});Reflect.defineProperty(me.exports,"windows",{enumerable:!1,value:pt});Reflect.defineProperty(me.exports,"other",{enumerable:!1,value:mt})});var _=m((qn,_e)=>{"use strict";var Gs=i=>i!==null&&typeof i=="object"&&!Array.isArray(i),Ws=/[\u001b\u009b][[\]#;?()]*(?:(?:(?:[^\W_]*;?[^\W_]*)\u0007)|(?:(?:[0-9]{1,4}(;[0-9]{0,4})*)?[~0-9=<>cf-nqrtyA-PRZ]))/g,yt=()=>{let i={enabled:!0,visible:!0,styles:{},keys:{}};"FORCE_COLOR"in process.env&&(i.enabled=process.env.FORCE_COLOR!=="0");let e=n=>{let l=n.open=`[${n.codes[0]}m`,o=n.close=`[${n.codes[1]}m`,a=n.regex=new RegExp(`\\u001b\\[${n.codes[1]}m`,"g");return n.wrap=(u,c)=>{u.includes(o)&&(u=u.replace(a,o+l));let h=l+u+o;return c?h.replace(/\r*\n/g,`${o}$&${l}`):h},n},t=(n,l,o)=>typeof n=="function"?n(l):n.wrap(l,o),s=(n,l)=>{if(n===""||n==null)return"";if(i.enabled===!1)return n;if(i.visible===!1)return"";let o=""+n,a=o.includes(`
2`),u=l.length;for(u>0&&l.includes("unstyle")&&(l=[...new Set(["unstyle",...l])].reverse());u-- >0;)o=t(i.styles[l[u]],o,a);return o},r=(n,l,o)=>{i.styles[n]=e({name:n,codes:l}),(i.keys[o]||(i.keys[o]=[])).push(n),Reflect.defineProperty(i,n,{configurable:!0,enumerable:!0,set(u){i.alias(n,u)},get(){let u=c=>s(c,u.stack);return Reflect.setPrototypeOf(u,i),u.stack=this.stack?this.stack.concat(n):[n],u}})};return r("reset",[0,0],"modifier"),r("bold",[1,22],"modifier"),r("dim",[2,22],"modifier"),r("italic",[3,23],"modifier"),r("underline",[4,24],"modifier"),r("inverse",[7,27],"modifier"),r("hidden",[8,28],"modifier"),r("strikethrough",[9,29],"modifier"),r("black",[30,39],"color"),r("red",[31,39],"color"),r("green",[32,39],"color"),r("yellow",[33,39],"color"),r("blue",[34,39],"color"),r("magenta",[35,39],"color"),r("cyan",[36,39],"color"),r("white",[37,39],"color"),r("gray",[90,39],"color"),r("grey",[90,39],"color"),r("bgBlack",[40,49],"bg"),r("bgRed",[41,49],"bg"),r("bgGreen",[42,49],"bg"),r("bgYellow",[43,49],"bg"),r("bgBlue",[44,49],"bg"),r("bgMagenta",[45,49],"bg"),r("bgCyan",[46,49],"bg"),r("bgWhite",[47,49],"bg"),r("blackBright",[90,39],"bright"),r("redBright",[91,39],"bright"),r("greenBright",[92,39],"bright"),r("yellowBright",[93,39],"bright"),r("blueBright",[94,39],"bright"),r("magentaBright",[95,39],"bright"),r("cyanBright",[96,39],"bright"),r("whiteBright",[97,39],"bright"),r("bgBlackBright",[100,49],"bgBright"),r("bgRedBright",[101,49],"bgBright"),r("bgGreenBright",[102,49],"bgBright"),r("bgYellowBright",[103,49],"bgBright"),r("bgBlueBright",[104,49],"bgBright"),r("bgMagentaBright",[105,49],"bgBright"),r("bgCyanBright",[106,49],"bgBright"),r("bgWhiteBright",[107,49],"bgBright"),i.ansiRegex=Ws,i.hasColor=i.hasAnsi=n=>(i.ansiRegex.lastIndex=0,typeof n=="string"&&n!==""&&i.ansiRegex.test(n)),i.alias=(n,l)=>{let o=typeof l=="string"?i[l]:l;if(typeof o!="function")throw new TypeError("Expected alias to be the name of an existing color (string) or a function");o.stack||(Reflect.defineProperty(o,"name",{value:n}),i.styles[n]=o,o.stack=[n]),Reflect.defineProperty(i,n,{configurable:!0,enumerable:!0,set(a){i.alias(n,a)},get(){let a=u=>s(u,a.stack);return Reflect.setPrototypeOf(a,i),a.stack=this.stack?this.stack.concat(o.stack):o.stack,a}})},i.theme=n=>{if(!Gs(n))throw new TypeError("Expected theme to be an object");for(let l of Object.keys(n))i.alias(l,n[l]);return i},i.alias("unstyle",n=>typeof n=="string"&&n!==""?(i.ansiRegex.lastIndex=0,n.replace(i.ansiRegex,"")):""),i.alias("noop",n=>n),i.none=i.clear=i.noop,i.stripColor=i.unstyle,i.symbols=gt(),i.define=r,i};_e.exports=yt();_e.exports.create=yt});var q=m(b=>{"use strict";var Ks=Object.prototype.toString,A=_(),bt=!1,Ie=[],wt={yellow:"blue",cyan:"red",green:"magenta",black:"white",blue:"yellow",red:"cyan",magenta:"green",white:"black"};b.longest=(i,e)=>i.reduce((t,s)=>Math.max(t,e?s[e].length:s.length),0);b.hasColor=i=>!!i&&A.hasColor(i);var ke=b.isObject=i=>i!==null&&typeof i=="object"&&!Array.isArray(i);b.nativeType=i=>Ks.call(i).slice(8,-1).toLowerCase().replace(/\s/g,"");b.isAsyncFn=i=>b.nativeType(i)==="asyncfunction";b.isPrimitive=i=>i!=null&&typeof i!="object"&&typeof i!="function";b.resolve=(i,e,...t)=>typeof e=="function"?e.call(i,...t):e;b.scrollDown=(i=[])=>[...i.slice(1),i[0]];b.scrollUp=(i=[])=>[i.pop(),...i];b.reorder=(i=[])=>{let e=i.slice();return e.sort((t,s)=>t.index>s.index?1:t.index<s.index?-1:0),e};b.swap=(i,e,t)=>{let s=i.length,r=t===s?0:t<0?s-1:t,n=i[e];i[e]=i[r],i[r]=n};b.width=(i,e=80)=>{let t=i&&i.columns?i.columns:e;return i&&typeof i.getWindowSize=="function"&&(t=i.getWindowSize()[0]),process.platform==="win32"?t-1:t};b.height=(i,e=20)=>{let t=i&&i.rows?i.rows:e;return i&&typeof i.getWindowSize=="function"&&(t=i.getWindowSize()[1]),t};b.wordWrap=(i,e={})=>{if(!i)return i;typeof e=="number"&&(e={width:e});let{indent:t="",newline:s=`
3`+t,width:r=80}=e;r-=((s+t).match(/[^\S\n]/g)||[]).length;let l=`.{1,${r}}([\\s\\u200B]+|$)|[^\\s\\u200B]+?([\\s\\u200B]+|$)`,o=i.trim(),a=new RegExp(l,"g"),u=o.match(a)||[];return u=u.map(c=>c.replace(/\n$/,"")),e.padEnd&&(u=u.map(c=>c.padEnd(r," "))),e.padStart&&(u=u.map(c=>c.padStart(r," "))),t+u.join(s)};b.unmute=i=>{let e=i.stack.find(s=>A.keys.color.includes(s));return e?A[e]:i.stack.find(s=>s.slice(2)==="bg")?A[e.slice(2)]:s=>s};b.pascal=i=>i?i[0].toUpperCase()+i.slice(1):"";b.inverse=i=>{if(!i||!i.stack)return i;let e=i.stack.find(s=>A.keys.color.includes(s));if(e){let s=A["bg"+b.pascal(e)];return s?s.black:i}let t=i.stack.find(s=>s.slice(0,2)==="bg");return t?A[t.slice(2).toLowerCase()]||i:A.none};b.complement=i=>{if(!i||!i.stack)return i;let e=i.stack.find(s=>A.keys.color.includes(s)),t=i.stack.find(s=>s.slice(0,2)==="bg");if(e&&!t)return A[wt[e]||e];if(t){let s=t.slice(2).toLowerCase(),r=wt[s];return r&&A["bg"+b.pascal(r)]||i}return A.none};b.meridiem=i=>{let e=i.getHours(),t=i.getMinutes(),s=e>=12?"pm":"am";e=e%12;let r=e===0?12:e,n=t<10?"0"+t:t;return r+":"+n+" "+s};b.set=(i={},e="",t)=>e.split(".").reduce((s,r,n,l)=>{let o=l.length-1>n?s[r]||{}:t;return!b.isObject(o)&&n<l.length-1&&(o={}),s[r]=o},i);b.get=(i={},e="",t)=>{let s=i[e]==null?e.split(".").reduce((r,n)=>r&&r[n],i):i[e];return s==null?t:s};b.mixin=(i,e)=>{if(!ke(i))return e;if(!ke(e))return i;for(let t of Object.keys(e)){let s=Object.getOwnPropertyDescriptor(e,t);if(s.hasOwnProperty("value"))if(i.hasOwnProperty(t)&&ke(s.value)){let r=Object.getOwnPropertyDescriptor(i,t);ke(r.value)?i[t]=b.merge({},i[t],e[t]):Reflect.defineProperty(i,t,s)}else Reflect.defineProperty(i,t,s);else Reflect.defineProperty(i,t,s)}return i};b.merge=(...i)=>{let e={};for(let t of i)b.mixin(e,t);return e};b.mixinEmitter=(i,e)=>{let t=e.constructor.prototype;for(let s of Object.keys(t)){let r=t[s];typeof r=="function"?b.define(i,s,r.bind(e)):b.define(i,s,r)}};b.onExit=i=>{let e=(t,s)=>{bt||(bt=!0,Ie.forEach(r=>r()),t===!0&&process.exit(128+s))};Ie.length===0&&(process.once("SIGTERM",e.bind(null,!0,15)),process.once("SIGINT",e.bind(null,!0,2)),process.once("exit",e)),Ie.push(i)};b.define=(i,e,t)=>{Reflect.defineProperty(i,e,{value:t})};b.defineExport=(i,e,t)=>{let s;Reflect.defineProperty(i,e,{enumerable:!0,configurable:!0,set(r){s=r},get(){return s?s():t()}})}});var vt=m(ae=>{"use strict";ae.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"};ae.shift={up:"shiftUp",down:"shiftDown",left:"shiftLeft",right:"shiftRight",tab:"prev"};ae.fn={up:"pageUp",down:"pageDown",left:"pageLeft",right:"pageRight",delete:"deleteForward"};ae.option={b:"backward",f:"forward",d:"cutRight",left:"cutLeft",up:"altUp",down:"altDown"};ae.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 kt=m((An,xt)=>{"use strict";var St=require("readline"),Zs=vt(),Ys=/^(?:\x1b)([a-zA-Z0-9])$/,Js=/^(?:\x1b+)(O|N|\[|\[\[)(?:(\d+)(?:;(\d+))?([~^$])|(?:1;)?(\d+)?([a-zA-Z]))/,Qs={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 Xs(i){return["[a","[b","[c","[d","[e","[2$","[3$","[5$","[6$","[7$","[8$","[Z"].includes(i)}function er(i){return["Oa","Ob","Oc","Od","Oe","[2^","[3^","[5^","[6^","[7^","[8^"].includes(i)}var Ce=(i="",e={})=>{let t,s={name:e.name,ctrl:!1,meta:!1,shift:!1,option:!1,sequence:i,raw:i,...e};if(Buffer.isBuffer(i)?i[0]>127&&i[1]===void 0?(i[0]-=128,i=""+String(i)):i=String(i):i!==void 0&&typeof i!="string"?i=String(i):i||(i=s.sequence||""),s.sequence=s.sequence||i||s.name,i==="\r")s.raw=void 0,s.name="return";else if(i===`
4`)s.name="enter";else if(i===" ")s.name="tab";else if(i==="\b"||i===""||i===""||i==="\b")s.name="backspace",s.meta=i.charAt(0)==="";else if(i===""||i==="")s.name="escape",s.meta=i.length===2;else if(i===" "||i===" ")s.name="space",s.meta=i.length===2;else if(i<="")s.name=String.fromCharCode(i.charCodeAt(0)+"a".charCodeAt(0)-1),s.ctrl=!0;else if(i.length===1&&i>="0"&&i<="9")s.name="number";else if(i.length===1&&i>="a"&&i<="z")s.name=i;else if(i.length===1&&i>="A"&&i<="Z")s.name=i.toLowerCase(),s.shift=!0;else if(t=Ys.exec(i))s.meta=!0,s.shift=/^[A-Z]$/.test(t[1]);else if(t=Js.exec(i)){let r=[...i];r[0]===""&&r[1]===""&&(s.option=!0);let n=[t[1],t[2],t[4],t[6]].filter(Boolean).join(""),l=(t[3]||t[5]||1)-1;s.ctrl=!!(l&4),s.meta=!!(l&10),s.shift=!!(l&1),s.code=n,s.name=Qs[n],s.shift=Xs(n)||s.shift,s.ctrl=er(n)||s.ctrl}return s};Ce.listen=(i={},e)=>{let{stdin:t}=i;if(!t||t!==process.stdin&&!t.isTTY)throw new Error("Invalid stream passed");let s=St.createInterface({terminal:!0,input:t});St.emitKeypressEvents(t,s);let r=(o,a)=>e(o,Ce(o,a),s),n=t.isRaw;return t.isTTY&&t.setRawMode(!0),t.on("keypress",r),s.resume(),()=>{t.isTTY&&t.setRawMode(n),t.removeListener("keypress",r),s.pause(),s.close()}};Ce.action=(i,e,t)=>{let s={...Zs,...t};return e.ctrl?(e.action=s.ctrl[e.name],e):e.option&&s.option?(e.action=s.option[e.name],e):e.shift?(e.action=s.shift[e.name],e):(e.action=s.keys[e.name],e)};xt.exports=Ce});var Pt=m((Rn,Ct)=>{"use strict";Ct.exports=i=>{i.timers=i.timers||{};let e=i.options.timers;if(!!e)for(let t of Object.keys(e)){let s=e[t];typeof s=="number"&&(s={interval:s}),tr(i,t,s)}};function tr(i,e,t={}){let s=i.timers[e]={name:e,start:Date.now(),ms:0,tick:0},r=t.interval||120;s.frames=t.frames||[],s.loading=!0;let n=setInterval(()=>{s.ms=Date.now()-s.start,s.tick++,i.render()},r);return s.stop=()=>{s.loading=!1,clearInterval(n)},Reflect.defineProperty(s,"interval",{value:n}),i.once("close",()=>s.stop()),s.stop}});var Bt=m((Ln,Ot)=>{"use strict";var{define:ir,width:sr}=q(),Et=class{constructor(e){let t=e.options;ir(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=sr(t.stdout||process.stdout),Object.assign(this,t),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 t=this._color||e[this.status];return typeof t=="function"?t: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"}};Ot.exports=Et});var qt=m((_n,$t)=>{"use strict";var ze=q(),$=_(),De={default:$.noop,noop:$.noop,set inverse(i){this._inverse=i},get inverse(){return this._inverse||ze.inverse(this.primary)},set complement(i){this._complement=i},get complement(){return this._complement||ze.complement(this.primary)},primary:$.cyan,success:$.green,danger:$.magenta,strong:$.bold,warning:$.yellow,muted:$.dim,disabled:$.gray,dark:$.dim.gray,underline:$.underline,set info(i){this._info=i},get info(){return this._info||this.primary},set em(i){this._em=i},get em(){return this._em||this.primary.underline},set heading(i){this._heading=i},get heading(){return this._heading||this.muted.underline},set pending(i){this._pending=i},get pending(){return this._pending||this.primary},set submitted(i){this._submitted=i},get submitted(){return this._submitted||this.success},set cancelled(i){this._cancelled=i},get cancelled(){return this._cancelled||this.danger},set typing(i){this._typing=i},get typing(){return this._typing||this.dim},set placeholder(i){this._placeholder=i},get placeholder(){return this._placeholder||this.primary.dim},set highlight(i){this._highlight=i},get highlight(){return this._highlight||this.inverse}};De.merge=(i={})=>{i.styles&&typeof i.styles.enabled=="boolean"&&($.enabled=i.styles.enabled),i.styles&&typeof i.styles.visible=="boolean"&&($.visible=i.styles.visible);let e=ze.merge({},De,i.styles);delete e.merge;for(let t of Object.keys($))e.hasOwnProperty(t)||Reflect.defineProperty(e,t,{get:()=>$[t]});for(let t of Object.keys($.styles))e.hasOwnProperty(t)||Reflect.defineProperty(e,t,{get:()=>$[t]});return e};$t.exports=De});var Tt=m((In,jt)=>{"use strict";var Me=process.platform==="win32",U=_(),rr=q(),Ne={...U.symbols,upDownDoubleArrow:"⇕",upDownDoubleArrow2:"⬍",upDownArrow:"↕",asterisk:"*",asterism:"⁂",bulletWhite:"◦",electricArrow:"⌁",ellipsisLarge:"⋯",ellipsisSmall:"…",fullBlock:"█",identicalTo:"≡",indicator:U.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:U.symbols.question,submitted:U.symbols.check,cancelled:U.symbols.cross},separator:{pending:U.symbols.pointerSmall,submitted:U.symbols.middot,cancelled:U.symbols.middot},radio:{off:Me?"( )":"◯",on:Me?"(*)":"◉",disabled:Me?"(|)":"Ⓘ"},numbers:["⓪","①","②","③","④","⑤","⑥","⑦","⑧","⑨","⑩","⑪","⑫","⑬","⑭","⑮","⑯","⑰","⑱","⑲","⑳","㉑","㉒","㉓","㉔","㉕","㉖","㉗","㉘","㉙","㉚","㉛","㉜","㉝","㉞","㉟","㊱","㊲","㊳","㊴","㊵","㊶","㊷","㊸","㊹","㊺","㊻","㊼","㊽","㊾","㊿"]};Ne.merge=i=>{let e=rr.merge({},U.symbols,Ne,i.symbols);return delete e.merge,e};jt.exports=Ne});var Rt=m((zn,At)=>{"use strict";var nr=qt(),lr=Tt(),or=q();At.exports=i=>{i.options=or.merge({},i.options.theme,i.options),i.symbols=lr.merge(i.options),i.styles=nr.merge(i.options)}});var Dt=m((Lt,_t)=>{"use strict";var It=process.env.TERM_PROGRAM==="Apple_Terminal",ar=_(),Fe=q(),I=_t.exports=Lt,k="[",zt="\x07",Ue=!1,W=I.code={bell:zt,beep:zt,beginning:`${k}G`,down:`${k}J`,esc:k,getPosition:`${k}6n`,hide:`${k}?25l`,line:`${k}2K`,lineEnd:`${k}K`,lineStart:`${k}1K`,restorePosition:k+(It?"8":"u"),savePosition:k+(It?"7":"s"),screen:`${k}2J`,show:`${k}?25h`,up:`${k}1J`},se=I.cursor={get hidden(){return Ue},hide(){return Ue=!0,W.hide},show(){return Ue=!1,W.show},forward:(i=1)=>`${k}${i}C`,backward:(i=1)=>`${k}${i}D`,nextLine:(i=1)=>`${k}E`.repeat(i),prevLine:(i=1)=>`${k}F`.repeat(i),up:(i=1)=>i?`${k}${i}A`:"",down:(i=1)=>i?`${k}${i}B`:"",right:(i=1)=>i?`${k}${i}C`:"",left:(i=1)=>i?`${k}${i}D`:"",to(i,e){return e?`${k}${e+1};${i+1}H`:`${k}${i+1}G`},move(i=0,e=0){let t="";return t+=i<0?se.left(-i):i>0?se.right(i):"",t+=e<0?se.up(-e):e>0?se.down(e):"",t},restore(i={}){let{after:e,cursor:t,initial:s,input:r,prompt:n,size:l,value:o}=i;if(s=Fe.isPrimitive(s)?String(s):"",r=Fe.isPrimitive(r)?String(r):"",o=Fe.isPrimitive(o)?String(o):"",l){let a=I.cursor.up(l)+I.cursor.to(n.length),u=r.length-t;return u>0&&(a+=I.cursor.left(u)),a}if(o||e){let a=!r&&!!s?-s.length:-r.length+t;return e&&(a-=e.length),r===""&&s&&!n.includes(s)&&(a+=s.length),I.cursor.move(a)}}},He=I.erase={screen:W.screen,up:W.up,down:W.down,line:W.line,lineEnd:W.lineEnd,lineStart:W.lineStart,lines(i){let e="";for(let t=0;t<i;t++)e+=I.erase.line+(t<i-1?I.cursor.up(1):"");return i&&(e+=I.code.beginning),e}};I.clear=(i="",e=process.stdout.columns)=>{if(!e)return He.line+se.to(0);let t=n=>[...ar.unstyle(n)].length,s=i.split(/\r?\n/),r=0;for(let n of s)r+=1+Math.floor(Math.max(t(n)-1,0)/e);return(He.line+se.prevLine()).repeat(r-1)+He.line+se.to(0)}});var ue=m((Dn,Mt)=>{"use strict";var ur=require("events"),Nt=_(),Ve=kt(),hr=Pt(),cr=Bt(),fr=Rt(),T=q(),re=Dt(),Pe=class extends ur{constructor(e={}){super();this.name=e.name,this.type=e.type,this.options=e,fr(this),hr(this),this.state=new cr(this),this.initial=[e.initial,e.default].find(t=>t!=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=pr(this.options.margin),this.setMaxListeners(0),dr(this)}async keypress(e,t={}){this.keypressed=!0;let s=Ve.action(e,Ve(e,t),this.options.actions);this.state.keypress=s,this.emit("keypress",e,s),this.emit("state",this.state.clone());let r=this.options[s.action]||this[s.action]||this.dispatch;if(typeof r=="function")return await r.call(this,e,s);this.alert()}alert(){delete this.state.alert,this.options.show===!1?this.emit("alert"):this.stdout.write(re.code.beep)}cursorHide(){this.stdout.write(re.cursor.hide()),T.onExit(()=>this.cursorShow())}cursorShow(){this.stdout.write(re.cursor.show())}write(e){!e||(this.stdout&&this.state.show!==!1&&this.stdout.write(e),this.state.buffer+=e)}clear(e=0){let t=this.state.buffer;this.state.buffer="",!(!t&&!e||this.options.show===!1)&&this.stdout.write(re.cursor.down(e)+re.clear(t,this.width))}restore(){if(this.state.closed||this.options.show===!1)return;let{prompt:e,after:t,rest:s}=this.sections(),{cursor:r,initial:n="",input:l="",value:o=""}=this,a=this.state.size=s.length,u={after:t,cursor:r,initial:n,input:l,prompt:e,size:a,value:o},c=re.cursor.restore(u);c&&this.stdout.write(c)}sections(){let{buffer:e,input:t,prompt:s}=this.state;s=Nt.unstyle(s);let r=Nt.unstyle(e),n=r.indexOf(s),l=r.slice(0,n),a=r.slice(n).split(`
5`),u=a[0],c=a[a.length-1],x=(s+(t?" "+t:"")).length,g=x<u.length?u.slice(x+1):"";return{header:l,prompt:u,after:g,rest:a.slice(1),last:c}}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 t=`
6`+this.symbols.pointer+" ";typeof e=="string"?t+=e.trim():t+="Invalid input",this.state.error=`
7`+this.styles.danger(t),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(),t=Math.ceil(e.prompt.length/this.width);e.rest&&this.write(re.cursor.down(e.rest.length)),this.write(`
8`.repeat(t))}catch(e){}this.emit("close")}start(){!this.stop&&this.options.show!==!1&&(this.stop=Ve.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:t,result:s}=this;if(this.format=()=>e.call(this,this.value),this.result=()=>s.call(this,this.value),typeof t.initial=="function"&&(this.initial=await t.initial.call(this,this)),typeof t.onRun=="function"&&await t.onRun.call(this,this),typeof t.onSubmit=="function"){let r=t.onSubmit.bind(this),n=this.submit.bind(this);delete this.options.onSubmit,this.submit=async()=>(await r(this.name,this.value,this),n())}await this.start(),await this.render()}render(){throw new Error("expected prompt to have a custom render method")}run(){return new Promise(async(e,t)=>{if(this.once("submit",e),this.once("cancel",t),await this.skip())return this.render=()=>{},this.submit();await this.initialize(),this.emit("run")})}async element(e,t,s){let{options:r,state:n,symbols:l,timers:o}=this,a=o&&o[e];n.timer=a;let u=r[e]||n[e]||l[e],c=t&&t[e]!=null?t[e]:await u;if(c==="")return c;let h=await this.resolve(c,n,t,s);return!h&&t&&t[e]?this.resolve(u,n,t,s):h}async prefix(){let e=await this.element("prefix")||this.symbols,t=this.timers&&this.timers.prefix,s=this.state;return s.timer=t,T.isObject(e)&&(e=e[s.status]||e.pending),T.hasColor(e)?e:(this.styles[s.status]||this.styles.pending)(e)}async message(){let e=await this.element("message");return T.hasColor(e)?e:this.styles.strong(e)}async separator(){let e=await this.element("separator")||this.symbols,t=this.timers&&this.timers.separator,s=this.state;s.timer=t;let r=e[s.status]||e.pending||s.separator,n=await this.resolve(r,s);return T.isObject(n)&&(n=n[s.status]||n.pending),T.hasColor(n)?n:this.styles.muted(n)}async pointer(e,t){let s=await this.element("pointer",e,t);if(typeof s=="string"&&T.hasColor(s))return s;if(s){let r=this.styles,n=this.index===t,l=n?r.primary:u=>u,o=await this.resolve(s[n?"on":"off"]||s,this.state),a=T.hasColor(o)?o:l(o);return n?a:" ".repeat(o.length)}}async indicator(e,t){let s=await this.element("indicator",e,t);if(typeof s=="string"&&T.hasColor(s))return s;if(s){let r=this.styles,n=e.enabled===!0,l=n?r.success:r.dark,o=s[n?"on":"off"]||s;return T.hasColor(o)?o:l(o)}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 T.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,...t){return T.resolve(this,e,...t)}get base(){return Pe.prototype}get style(){return this.styles[this.state.status]}get height(){return this.options.rows||T.height(this.stdout,25)}get width(){return this.options.columns||T.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:t}=this.state,s=[t,e].find(this.isValue.bind(this));return this.isValue(s)?s:this.initial}static get prompt(){return e=>new this(e).run()}};function dr(i){let e=r=>i[r]===void 0||typeof i[r]=="function",t=["actions","choices","initial","margin","roles","styles","symbols","theme","timers","value"],s=["body","footer","error","header","hint","indicator","message","prefix","separator","skip"];for(let r of Object.keys(i.options)){if(t.includes(r)||/^on[A-Z]/.test(r))continue;let n=i.options[r];typeof n=="function"&&e(r)?s.includes(r)||(i[r]=n.bind(i)):typeof i[r]!="function"&&(i[r]=n)}}function pr(i){typeof i=="number"&&(i=[i,i,i,i]);let e=[].concat(i||[]),t=r=>r%2==0?`
9`:" ",s=[];for(let r=0;r<4;r++){let n=t(r);e[r]?s.push(n.repeat(e[r])):s.push("")}return s}Mt.exports=Pe});var Ht=m((Mn,Ft)=>{"use strict";var mr=q(),Ut={default(i,e){return e},checkbox(i,e){throw new Error("checkbox role is not implemented yet")},editable(i,e){throw new Error("editable role is not implemented yet")},expandable(i,e){throw new Error("expandable role is not implemented yet")},heading(i,e){return e.disabled="",e.indicator=[e.indicator," "].find(t=>t!=null),e.message=e.message||"",e},input(i,e){throw new Error("input role is not implemented yet")},option(i,e){return Ut.default(i,e)},radio(i,e){throw new Error("radio role is not implemented yet")},separator(i,e){return e.disabled="",e.indicator=[e.indicator," "].find(t=>t!=null),e.message=e.message||i.symbols.line.repeat(5),e},spacer(i,e){return e}};Ft.exports=(i,e={})=>{let t=mr.merge({},Ut,e.roles);return t[i]||t.default}});var ge=m((Nn,Vt)=>{"use strict";var gr=_(),yr=ue(),br=Ht(),Oe=q(),{reorder:Ge,scrollUp:wr,scrollDown:vr,isObject:Gt,swap:xr}=Oe,Wt=class extends yr{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:t,autofocus:s,suggest:r}=this.options;if(this.state._choices=[],this.state.choices=[],this.choices=await Promise.all(await this.toChoices(e)),this.choices.forEach(n=>n.enabled=!1),typeof r!="function"&&this.selectable.length===0)throw new Error("At least one choice must be selectable");Gt(t)&&(t=Object.keys(t)),Array.isArray(t)?(s!=null&&(this.index=this.findIndex(s)),t.forEach(n=>this.enable(this.find(n))),await this.render()):(s!=null&&(t=s),typeof t=="string"&&(t=this.findIndex(t)),typeof t=="number"&&t>-1&&(this.index=Math.max(0,Math.min(t,this.choices.length)),this.enable(this.find(this.index)))),this.isDisabled(this.focused)&&await this.down()}async toChoices(e,t){this.state.loadingChoices=!0;let s=[],r=0,n=async(l,o)=>{typeof l=="function"&&(l=await l.call(this)),l instanceof Promise&&(l=await l);for(let a=0;a<l.length;a++){let u=l[a]=await this.toChoice(l[a],r++,o);s.push(u),u.choices&&await n(u.choices,u)}return s};return n(e,t).then(l=>(this.state.loadingChoices=!1,l))}async toChoice(e,t,s){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 r=e.value;if(e=br(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=t,e.cursor=0,Oe.define(e,"parent",s),e.level=s?s.level+1:1,e.indent==null&&(e.indent=s?s.indent+" ":e.indent||""),e.path=s?s.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,gr.unstyle(e.message).length));let l={...e};return e.reset=(o=l.input,a=l.value)=>{for(let u of Object.keys(l))e[u]=l[u];e.input=o,e.value=a},r==null&&typeof e.initial=="function"&&(e.input=await e.initial.call(this,this.state,e,t)),e}async onChoice(e,t){this.emit("choice",e,t,this),typeof e.onChoice=="function"&&await e.onChoice.call(this,this.state,e,t)}async addChoice(e,t,s){let r=await this.toChoice(e,t,s);return this.choices.push(r),this.index=this.choices.length-1,this.limit=this.choices.length,r}async newItem(e,t,s){let r={name:"New choice name?",editable:!0,newChoice:!0,...e},n=await this.addChoice(r,t,s);return n.updateChoice=()=>{delete n.newChoice,n.name=n.message=n.input,n.input="",n.cursor=0},this.render()}indent(e){return e.indent==null?e.level>1?" ".repeat(e.level-1):"":e.indent}dispatch(e,t){if(this.multiple&&this[t.name])return this[t.name]();this.alert()}focus(e,t){return typeof t!="boolean"&&(t=e.enabled),t&&!e.enabled&&this.selected.length>=this.maxSelected?this.alert():(this.index=e.index,e.enabled=t&&!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(t=>t.enabled);return this.choices.forEach(t=>t.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(t=>!!t.parent)?(this.toggle(e.parent&&!e.choices?e.parent:e),this.render()):this.a()}toggle(e,t){if(!e.enabled&&this.selected.length>=this.maxSelected)return this.alert();typeof t!="boolean"&&(t=!e.enabled),e.enabled=t,e.choices&&e.choices.forEach(r=>this.toggle(r,t));let s=e.parent;for(;s;){let r=s.choices.filter(n=>this.isDisabled(n));s.enabled=r.every(n=>n.enabled===!0),s=s.parent}return Kt(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 t=s=>{let r=Number(s);if(r>this.choices.length-1)return this.alert();let n=this.focused,l=this.choices.find(o=>r===o.index);if(!l.enabled&&this.selected.length>=this.maxSelected)return this.alert();if(this.visible.indexOf(l)===-1){let o=Ge(this.choices),a=o.indexOf(l);if(n.index>a){let u=o.slice(a,a+this.limit),c=o.filter(h=>!u.includes(h));this.choices=u.concat(c)}else{let u=a-this.limit+1;this.choices=o.slice(u).concat(o.slice(0,u))}}return this.index=this.choices.indexOf(l),this.toggle(this.focused),this.render()};return clearTimeout(this.numberTimeout),new Promise(s=>{let r=this.choices.length,n=this.num,l=(o=!1,a)=>{clearTimeout(this.numberTimeout),o&&(a=t(n)),this.num="",s(a)};if(n==="0"||n.length===1&&Number(n+"0")>r)return l(!0);if(Number(n)>r)return l(!1,this.alert());this.numberTimeout=setTimeout(()=>l(!0),this.delay)})}home(){return this.choices=Ge(this.choices),this.index=0,this.render()}end(){let e=this.choices.length-this.limit,t=Ge(this.choices);return this.choices=t.slice(e).concat(t.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,t=this.visible.length,s=this.index;return this.options.scroll===!1&&s===0?this.alert():e>t&&s===0?this.scrollUp():(this.index=(s-1%e+e)%e,this.isDisabled()?this.up():this.render())}down(){let e=this.choices.length,t=this.visible.length,s=this.index;return this.options.scroll===!1&&s===t-1?this.alert():e>t&&s===t-1?this.scrollDown():(this.index=(s+1)%e,this.isDisabled()?this.down():this.render())}scrollUp(e=0){return this.choices=wr(this.choices),this.index=e,this.isDisabled()?this.up():this.render()}scrollDown(e=this.visible.length-1){return this.choices=vr(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){xr(this.choices,this.index,e)}isDisabled(e=this.focused){return e&&["disabled","collapsed","hidden","completing","readonly"].some(s=>e[s]===!0)?!0:e&&e.role==="heading"}isEnabled(e=this.focused){if(Array.isArray(e))return e.every(t=>this.isEnabled(t));if(e.choices){let t=e.choices.filter(s=>!this.isDisabled(s));return e.enabled&&t.every(s=>this.isEnabled(s))}return e.enabled&&!this.isDisabled(e)}isChoice(e,t){return e.name===t||e.index===Number(t)}isSelected(e){return Array.isArray(this.initial)?this.initial.some(t=>this.isChoice(e,t)):this.isChoice(e,this.initial)}map(e=[],t="value"){return[].concat(e||[]).reduce((s,r)=>(s[r]=this.find(r,t),s),{})}filter(e,t){let s=(o,a)=>[o.name,a].includes(e),r=typeof e=="function"?e:s,l=(this.options.multiple?this.state._choices:this.choices).filter(r);return t?l.map(o=>o[t]):l}find(e,t){if(Gt(e))return t?e[t]:e;let s=(l,o)=>[l.name,o].includes(e),r=typeof e=="function"?e:s,n=this.choices.find(r);if(n)return t?n[t]:n}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(l=>l.newChoice))return this.alert();let{reorder:t,sort:s}=this.options,r=this.multiple===!0,n=this.selected;return n===void 0?this.alert():(Array.isArray(n)&&t!==!1&&s!==!0&&(n=Oe.reorder(n)),this.value=r?n.map(l=>l.name):n.name,super.submit())}set choices(e=[]){this.state._choices=this.state._choices||[],this.state.choices=e;for(let t of e)this.state._choices.some(s=>s.name===t.name)||this.state._choices.push(t);if(!this._initial&&this.options.initial){this._initial=!0;let t=this.initial;if(typeof t=="string"||typeof t=="number"){let s=this.find(t);s&&(this.initial=s.index,this.focus(s,!0))}}}get choices(){return Kt(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:t,choices:s}=this,r=e.limit||this._limit||t.limit||s.length;return Math.min(r,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 Kt(i,e){if(e instanceof Promise)return e;if(typeof e=="function"){if(Oe.isAsyncFn(e))return e;e=e.call(i,i)}for(let t of e){if(Array.isArray(t.choices)){let s=t.choices.filter(r=>!i.isDisabled(r));t.enabled=s.every(r=>r.enabled===!0)}i.isDisabled(t)===!0&&delete t.enabled}return e}Vt.exports=Wt});var K=m((Fn,Zt)=>{"use strict";var Sr=ge(),We=q(),Yt=class extends Sr{constructor(e){super(e);this.emptyError=this.options.emptyError||"No items were selected"}async dispatch(e,t){if(this.multiple)return this[t.name]?await this[t.name](e,t):await super.dispatch(e,t);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,t){return!this.multiple||this.options.pointer?super.pointer(e,t):""}indicator(e,t){return this.multiple?super.indicator(e,t):""}choiceMessage(e,t){let s=this.resolve(e.message,this.state,e,t);return e.role==="heading"&&!We.hasColor(s)&&(s=this.styles.strong(s)),this.resolve(s,this.state,e,t)}choiceSeparator(){return":"}async renderChoice(e,t){await this.onChoice(e,t);let s=this.index===t,r=await this.pointer(e,t),n=await this.indicator(e,t)+(e.pad||""),l=await this.resolve(e.hint,this.state,e,t);l&&!We.hasColor(l)&&(l=this.styles.muted(l));let o=this.indent(e),a=await this.choiceMessage(e,t),u=()=>[this.margin[3],o+r+n,a,this.margin[1],l].filter(Boolean).join(" ");return e.role==="heading"?u():e.disabled?(We.hasColor(a)||(a=this.styles.disabled(a)),u()):(s&&(a=this.styles.em(a)),u())}async renderChoices(){if(this.state.loading==="choices")return this.styles.warning("Loading choices");if(this.state.submitted)return"";let e=this.visible.map(async(n,l)=>await this.renderChoice(n,l)),t=await Promise.all(e);t.length||t.push(this.styles.danger("No matching choices"));let s=this.margin[0]+t.join(`
10`),r;return this.options.choicesHeader&&(r=await this.resolve(this.options.choicesHeader,this.state)),[r,s].filter(Boolean).join(`
11`)}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:t}=this.state,s="",r=await this.header(),n=await this.prefix(),l=await this.separator(),o=await this.message();this.options.promptLine!==!1&&(s=[n,o,l,""].join(" "),this.state.prompt=s);let a=await this.format(),u=await this.error()||await this.hint(),c=await this.renderChoices(),h=await this.footer();a&&(s+=a),u&&!s.includes(u)&&(s+=" "+u),e&&!a&&!c.trim()&&this.multiple&&this.emptyError!=null&&(s+=this.styles.danger(this.emptyError)),this.clear(t),this.write([r,s,c,h].filter(Boolean).join(`
12`)),this.write(this.margin[2]),this.restore()}};Zt.exports=Yt});var Xt=m((Un,Jt)=>{"use strict";var kr=K(),Cr=(i,e)=>{let t=i.toLowerCase();return s=>{let n=s.toLowerCase().indexOf(t),l=e(s.slice(n,n+t.length));return n>=0?s.slice(0,n)+l+s.slice(n+t.length):s}},Qt=class extends kr{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:t,input:s}=this.state;return this.input=s.slice(0,t)+e+s.slice(t),this.moveCursor(1),this.complete()}delete(){let{cursor:e,input:t}=this.state;return t?(this.input=t.slice(0,e-1)+t.slice(e),this.moveCursor(-1),this.complete()):this.alert()}deleteForward(){let{cursor:e,input:t}=this.state;return t[e]===void 0?this.alert():(this.input=`${t}`.slice(0,e)+`${t}`.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,t=this.state._choices){if(typeof this.options.suggest=="function")return this.options.suggest.call(this,e,t);let s=e.toLowerCase();return t.filter(r=>r.message.toLowerCase().includes(s))}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,t=Cr(this.input,e),s=this.choices;this.choices=s.map(r=>({...r,message:t(r.message)})),await super.render(),this.choices=s}submit(){return this.options.multiple&&(this.value=this.selected.map(e=>e.name)),super.submit()}};Jt.exports=Qt});var Ze=m((Hn,ei)=>{"use strict";var Ke=q();ei.exports=(i,e={})=>{i.cursorHide();let{input:t="",initial:s="",pos:r,showCursor:n=!0,color:l}=e,o=l||i.styles.placeholder,a=Ke.inverse(i.styles.primary),u=w=>a(i.styles.black(w)),c=t,h=" ",x=u(h);if(i.blink&&i.blink.off===!0&&(u=w=>w,x=""),n&&r===0&&s===""&&t==="")return u(h);if(n&&r===0&&(t===s||t===""))return u(s[0])+o(s.slice(1));s=Ke.isPrimitive(s)?`${s}`:"",t=Ke.isPrimitive(t)?`${t}`:"";let g=s&&s.startsWith(t)&&s!==t,f=g?u(s[t.length]):x;if(r!==t.length&&n===!0&&(c=t.slice(0,r)+u(t[r])+t.slice(r+1),f=""),n===!1&&(f=""),g){let w=i.styles.unstyle(c+f);return c+f+o(s.slice(w.length))}return c+f}});var Ee=m((Vn,ti)=>{"use strict";var Pr=_(),Or=K(),Er=Ze(),ii=class extends Or{constructor(e){super({...e,multiple:!0});this.type="form",this.initial=this.options.initial,this.align=[this.options.align,"right"].find(t=>t!=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(t=>t.reset&&t.reset()),this.render()}dispatch(e){return!!e&&this.append(e)}append(e){let t=this.focused;if(!t)return this.alert();let{cursor:s,input:r}=t;return t.value=t.input=r.slice(0,s)+e+r.slice(s),t.cursor++,this.render()}delete(){let e=this.focused;if(!e||e.cursor<=0)return this.alert();let{cursor:t,input:s}=e;return e.value=e.input=s.slice(0,t-1)+s.slice(t),e.cursor--,this.render()}deleteForward(){let e=this.focused;if(!e)return this.alert();let{cursor:t,input:s}=e;if(s[t]===void 0)return this.alert();let r=`${s}`.slice(0,t)+`${s}`.slice(t+1);return e.value=e.input=r,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,t){return this.dispatch(e,t)}number(e,t){return this.dispatch(e,t)}next(){let e=this.focused;if(!e)return this.alert();let{initial:t,input:s}=e;return t&&t.startsWith(s)&&s!==t?(e.value=e.input=t,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,t){let s=await this.resolve(e.separator,this.state,e,t)||":";return s?" "+this.styles.disabled(s):""}async renderChoice(e,t){await this.onChoice(e,t);let{state:s,styles:r}=this,{cursor:n,initial:l="",name:o,hint:a,input:u=""}=e,{muted:c,submitted:h,primary:x,danger:g}=r,f=a,w=this.index===t,S=e.validate||(()=>!0),d=await this.choiceSeparator(e,t),p=e.message;this.align==="right"&&(p=p.padStart(this.longest+1," ")),this.align==="left"&&(p=p.padEnd(this.longest+1," "));let y=this.values[o]=u||l,v=u?"success":"dark";await S.call(e,y,this.state)!==!0&&(v="danger");let B=r[v](await this.indicator(e,t))+(e.pad||""),Se=this.indent(e),te=()=>[Se,B,p+d,u,f].filter(Boolean).join(" ");if(s.submitted)return p=Pr.unstyle(p),u=h(u),f="",te();if(e.format)u=await e.format.call(this,u,e,t);else{let Ae=this.styles.muted;u=Er(this,{input:u,initial:l,pos:n,showCursor:w,color:Ae})}return this.isValue(u)||(u=this.styles.muted(this.symbols.ellipsis)),e.result&&(this.values[o]=await e.result.call(this,y,e,t)),w&&(p=x(p)),e.error?u+=(u?" ":"")+g(e.error.trim()):e.hint&&(u+=(u?" ":"")+c(e.hint.trim())),te()}async submit(){return this.value=this.values,super.base.submit.call(this)}};ti.exports=ii});var Ye=m((Gn,si)=>{"use strict";var Br=Ee(),$r=()=>{throw new Error("expected prompt to have a custom authenticate method")},ri=(i=$r)=>{class e extends Br{constructor(s){super(s)}async submit(){this.value=await i.call(this,this.values,this.state),super.base.submit.call(this)}static create(s){return ri(s)}}return e};si.exports=ri()});var oi=m((Wn,ni)=>{"use strict";var qr=Ye();function jr(i,e){return i.username===this.options.username&&i.password===this.options.password}var li=(i=jr)=>{let e=[{name:"username",message:"username"},{name:"password",message:"password",format(s){return this.options.showPassword?s:(this.state.submitted?this.styles.primary:this.styles.muted)(this.symbols.asterisk.repeat(s.length))}}];class t extends qr.create(i){constructor(r){super({...r,choices:e})}static create(r){return li(r)}}return t};ni.exports=li()});var Be=m((Kn,ai)=>{"use strict";var Tr=ue(),{isPrimitive:Ar,hasColor:Rr}=q(),ui=class extends Tr{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:t,state:s}=this;return s.submitted?t.success(e):t.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 Ar(e)&&(this.isTrue(e)||this.isFalse(e))}async hint(){if(this.state.status==="pending"){let e=await this.element("hint");return Rr(e)?e:this.styles.muted(e)}}async render(){let{input:e,size:t}=this.state,s=await this.prefix(),r=await this.separator(),n=await this.message(),l=this.styles.muted(this.default),o=[s,n,l,r].filter(Boolean).join(" ");this.state.prompt=o;let a=await this.header(),u=this.value=this.cast(e),c=await this.format(u),h=await this.error()||await this.hint(),x=await this.footer();h&&!o.includes(h)&&(c+=" "+h),o+=" "+c,this.clear(t),this.write([a,o,x].filter(Boolean).join(`
13`)),this.restore()}set value(e){super.value=e}get value(){return this.cast(super.value)}};ai.exports=ui});var fi=m((Zn,hi)=>{"use strict";var Lr=Be(),ci=class extends Lr{constructor(e){super(e);this.default=this.options.default||(this.initial?"(Y/n)":"(y/N)")}};hi.exports=ci});var mi=m((Yn,di)=>{"use strict";var _r=K(),Ir=Ee(),he=Ir.prototype,pi=class extends _r{constructor(e){super({...e,multiple:!0});this.align=[this.options.align,"left"].find(t=>t!=null),this.emptyError="",this.values={}}dispatch(e,t){let s=this.focused,r=s.parent||{};return!s.editable&&!r.editable&&(e==="a"||e==="i")?super[e]():he.dispatch.call(this,e,t)}append(e,t){return he.append.call(this,e,t)}delete(e,t){return he.delete.call(this,e,t)}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?he.next.call(this):super.next()}prev(){return this.focused.editable?he.prev.call(this):super.prev()}async indicator(e,t){let s=e.indicator||"",r=e.editable?s:super.indicator(e,t);return await this.resolve(r,this.state,e,t)||""}indent(e){return e.role==="heading"?"":e.editable?" ":" "}async renderChoice(e,t){return e.indent="",e.editable?he.renderChoice.call(this,e,t):super.renderChoice(e,t)}error(){return""}footer(){return this.state.error}async validate(){let e=!0;for(let t of this.choices){if(typeof t.validate!="function"||t.role==="heading")continue;let s=t.parent?this.value[t.parent.name]:this.value;if(t.editable?s=t.value===t.name?t.initial||"":t.value:this.isDisabled(t)||(s=t.enabled===!0),e=await t.validate(s,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 t=e.parent?this.value[e.parent.name]:this.value;if(e.role==="heading"){this.value[e.name]={};continue}e.editable?t[e.name]=e.value===e.name?e.initial||"":e.value:this.isDisabled(e)||(t[e.name]=e.enabled===!0)}return this.base.submit.call(this)}};di.exports=pi});var ne=m((Jn,gi)=>{"use strict";var zr=ue(),Dr=Ze(),{isPrimitive:Mr}=q(),yi=class extends zr{constructor(e){super(e);this.initial=Mr(this.initial)?String(this.initial):"",this.initial&&this.cursorHide(),this.state.prevCursor=0,this.state.clipboard=[]}async keypress(e,t={}){let s=this.state.prevKeypress;return this.state.prevKeypress=t,this.options.multiline===!0&&t.name==="return"&&(!s||s.name!=="return")?this.append(`
14`,t):super.keypress(e,t)}moveCursor(e){this.cursor+=e}reset(){return this.input=this.value="",this.cursor=0,this.render()}dispatch(e,t){if(!e||t.ctrl||t.code)return this.alert();this.append(e)}append(e){let{cursor:t,input:s}=this.state;this.input=`${s}`.slice(0,t)+e+`${s}`.slice(t),this.moveCursor(String(e).length),this.render()}insert(e){this.append(e)}delete(){let{cursor:e,input:t}=this.state;if(e<=0)return this.alert();this.input=`${t}`.slice(0,e-1)+`${t}`.slice(e),this.moveCursor(-1),this.render()}deleteForward(){let{cursor:e,input:t}=this.state;if(t[e]===void 0)return this.alert();this.input=`${t}`.slice(0,e)+`${t}`.slice(e+1),this.render()}cutForward(){let e=this.cursor;if(this.input.length<=e)return this.alert();this.state.clipboard.push(this.input.slice(e)),this.input=this.input.slice(0,e),this.render()}cutLeft(){let e=this.cursor;if(e===0)return this.alert();let t=this.input.slice(0,e),s=this.input.slice(e),r=t.split(" ");this.state.clipboard.push(r.pop()),this.input=r.join(" "),this.cursor=this.input.length,this.input+=s,this.render()}paste(){if(!this.state.clipboard.length)return this.alert();this.insert(this.state.clipboard.pop()),this.render()}toggleCursor(){this.state.prevCursor?(this.cursor=this.state.prevCursor,this.state.prevCursor=0):(this.state.prevCursor=this.cursor,this.cursor=0),this.render()}first(){this.cursor=0,this.render()}last(){this.cursor=this.input.length-1,this.render()}next(){let e=this.initial!=null?String(this.initial):"";if(!e||!e.startsWith(this.input))return this.alert();this.input=this.initial,this.cursor=this.initial.length,this.render()}prev(){if(!this.input)return this.alert();this.reset()}backward(){return this.left()}forward(){return this.right()}right(){return this.cursor>=this.input.length?this.alert():(this.moveCursor(1),this.render())}left(){return this.cursor<=0?this.alert():(this.moveCursor(-1),this.render())}isValue(e){return!!e}async format(e=this.value){let t=await this.resolve(this.initial,this.state);return this.state.submitted?this.styles.submitted(e||t):Dr(this,{input:e,initial:t,pos:this.cursor})}async render(){let e=this.state.size,t=await this.prefix(),s=await this.separator(),r=await this.message(),n=[t,r,s].filter(Boolean).join(" ");this.state.prompt=n;let l=await this.header(),o=await this.format(),a=await this.error()||await this.hint(),u=await this.footer();a&&!o.includes(a)&&(o+=" "+a),n+=" "+o,this.clear(e),this.write([l,n,u].filter(Boolean).join(`
15`)),this.restore()}};gi.exports=yi});var wi=m((Qn,bi)=>{"use strict";var Nr=i=>i.filter((e,t)=>i.lastIndexOf(e)===t),$e=i=>Nr(i).filter(Boolean);bi.exports=(i,e={},t="")=>{let{past:s=[],present:r=""}=e,n,l;switch(i){case"prev":case"undo":return n=s.slice(0,s.length-1),l=s[s.length-1]||"",{past:$e([t,...n]),present:l};case"next":case"redo":return n=s.slice(1),l=s[0]||"",{past:$e([...n,t]),present:l};case"save":return{past:$e([...s,t]),present:""};case"remove":return l=$e(s.filter(o=>o!==t)),r="",l.length&&(r=l.pop()),{past:l,present:r};default:throw new Error(`Invalid action: "${i}"`)}}});var Je=m((Xn,vi)=>{"use strict";var Fr=ne(),xi=wi(),Si=class extends Fr{constructor(e){super(e);let t=this.options.history;if(t&&t.store){let s=t.values||this.initial;this.autosave=!!t.autosave,this.store=t.store,this.data=this.store.get("values")||{past:[],present:s},this.initial=this.data.present||this.data.past[this.data.past.length-1]}}completion(e){return this.store?(this.data=xi(e,this.data,this.input),this.data.present?(this.input=this.data.present,this.cursor=this.input.length,this.render()):this.alert()):this.alert()}altUp(){return this.completion("prev")}altDown(){return this.completion("next")}prev(){return this.save(),super.prev()}save(){!this.store||(this.data=xi("save",this.data,this.input),this.store.set("values",this.data))}submit(){return this.store&&this.autosave===!0&&this.save(),super.submit()}};vi.exports=Si});var Pi=m((el,ki)=>{"use strict";var Ur=ne(),Ci=class extends Ur{format(){return""}};ki.exports=Ci});var Bi=m((tl,Oi)=>{"use strict";var Hr=ne(),Ei=class extends Hr{constructor(e={}){super(e);this.sep=this.options.separator||/, */,this.initial=e.initial||""}split(e=this.value){return e?String(e).split(this.sep):[]}format(){let e=this.state.submitted?this.styles.primary:t=>t;return this.list.map(e).join(", ")}async submit(e){let t=this.state.error||await this.validate(this.list,this.state);return t!==!0?(this.state.error=t,super.submit()):(this.value=this.list,super.submit())}get list(){return this.split()}};Oi.exports=Ei});var ji=m((il,$i)=>{"use strict";var Vr=K(),qi=class extends Vr{constructor(e){super({...e,multiple:!0})}};$i.exports=qi});var Qe=m((sl,Ti)=>{"use strict";var Gr=ne(),Ai=class extends Gr{constructor(e={}){super({style:"number",...e});this.min=this.isValue(e.min)?this.toNumber(e.min):-Infinity,this.max=this.isValue(e.max)?this.toNumber(e.max):Infinity,this.delay=e.delay!=null?e.delay:1e3,this.float=e.float!==!1,this.round=e.round===!0||e.float===!1,this.major=e.major||10,this.minor=e.minor||1,this.initial=e.initial!=null?e.initial:"",this.input=String(this.initial),this.cursor=this.input.length,this.cursorShow()}append(e){return!/[-+.]/.test(e)||e==="."&&this.input.includes(".")?this.alert("invalid number"):super.append(e)}number(e){return super.append(e)}next(){return this.input&&this.input!==this.initial?this.alert():this.isValue(this.initial)?(this.input=this.initial,this.cursor=String(this.initial).length,this.render()):this.alert()}up(e){let t=e||this.minor,s=this.toNumber(this.input);return s>this.max+t?this.alert():(this.input=`${s+t}`,this.render())}down(e){let t=e||this.minor,s=this.toNumber(this.input);return s<this.min-t?this.alert():(this.input=`${s-t}`,this.render())}shiftDown(){return this.down(this.major)}shiftUp(){return this.up(this.major)}format(e=this.input){return typeof this.options.format=="function"?this.options.format.call(this,e):this.styles.info(e)}toNumber(e=""){return this.float?+e:Math.round(+e)}isValue(e){return/^[-+]?[0-9]+((\.)|(\.[0-9]+))?$/.test(e)}submit(){let e=[this.input,this.initial].find(t=>this.isValue(t));return this.value=this.toNumber(e||0),super.submit()}};Ti.exports=Ai});var Li=m((rl,Ri)=>{Ri.exports=Qe()});var zi=m((nl,_i)=>{"use strict";var Wr=ne(),Ii=class extends Wr{constructor(e){super(e);this.cursorShow()}format(e=this.input){return this.keypressed?(this.state.submitted?this.styles.primary:this.styles.muted)(this.symbols.asterisk.repeat(e.length)):""}};_i.exports=Ii});var Fi=m((ll,Di)=>{"use strict";var Kr=_(),Zr=ge(),Mi=q(),Ni=class extends Zr{constructor(e={}){super(e);this.widths=[].concat(e.messageWidth||50),this.align=[].concat(e.align||"left"),this.linebreak=e.linebreak||!1,this.edgeLength=e.edgeLength||3,this.newline=e.newline||`
16 `;let t=e.startNumber||1;typeof this.scale=="number"&&(this.scaleKey=!1,this.scale=Array(this.scale).fill(0).map((s,r)=>({name:r+t})))}async reset(){return this.tableized=!1,await super.reset(),this.render()}tableize(){if(this.tableized===!0)return;this.tableized=!0;let e=0;for(let t of this.choices){e=Math.max(e,t.message.length),t.scaleIndex=t.initial||2,t.scale=[];for(let s=0;s<this.scale.length;s++)t.scale.push({index:s})}this.widths[0]=Math.min(this.widths[0],e+3)}async dispatch(e,t){if(this.multiple)return this[t.name]?await this[t.name](e,t):await super.dispatch(e,t);this.alert()}heading(e,t,s){return this.styles.strong(e)}separator(){return this.styles.muted(this.symbols.ellipsis)}right(){let e=this.focused;return e.scaleIndex>=this.scale.length-1?this.alert():(e.scaleIndex++,this.render())}left(){let e=this.focused;return e.scaleIndex<=0?this.alert():(e.scaleIndex--,this.render())}indent(){return""}format(){return this.state.submitted?this.choices.map(t=>this.styles.info(t.index)).join(", "):""}pointer(){return""}renderScaleKey(){if(this.scaleKey===!1||this.state.submitted)return"";let e=this.scale.map(s=>` ${s.name} - ${s.message}`);return["",...e].map(s=>this.styles.muted(s)).join(`
17`)}renderScaleHeading(e){let t=this.scale.map(a=>a.name);typeof this.options.renderScaleHeading=="function"&&(t=this.options.renderScaleHeading.call(this,e));let s=this.scaleLength-t.join("").length,r=Math.round(s/(t.length-1)),l=t.map(a=>this.styles.strong(a)).join(" ".repeat(r)),o=" ".repeat(this.widths[0]);return this.margin[3]+o+this.margin[1]+l}scaleIndicator(e,t,s){if(typeof this.options.scaleIndicator=="function")return this.options.scaleIndicator.call(this,e,t,s);let r=e.scaleIndex===t.index;return t.disabled?this.styles.hint(this.symbols.radio.disabled):r?this.styles.success(this.symbols.radio.on):this.symbols.radio.off}renderScale(e,t){let s=e.scale.map(n=>this.scaleIndicator(e,n,t)),r=this.term==="Hyper"?"":" ";return s.join(r+this.symbols.line.repeat(this.edgeLength))}async renderChoice(e,t){await this.onChoice(e,t);let s=this.index===t,r=await this.pointer(e,t),n=await e.hint;n&&!Mi.hasColor(n)&&(n=this.styles.muted(n));let l=f=>this.margin[3]+f.replace(/\s+$/,"").padEnd(this.widths[0]," "),o=this.newline,a=this.indent(e),u=await this.resolve(e.message,this.state,e,t),c=await this.renderScale(e,t),h=this.margin[1]+this.margin[3];this.scaleLength=Kr.unstyle(c).length,this.widths[0]=Math.min(this.widths[0],this.width-this.scaleLength-h.length);let g=Mi.wordWrap(u,{width:this.widths[0],newline:o}).split(`
18`).map(f=>l(f)+this.margin[1]);return s&&(c=this.styles.info(c),g=g.map(f=>this.styles.info(f))),g[0]+=c,this.linebreak&&g.push(""),[a+r,g.join(`
19`)].filter(Boolean)}async renderChoices(){if(this.state.submitted)return"";this.tableize();let e=this.visible.map(async(r,n)=>await this.renderChoice(r,n)),t=await Promise.all(e),s=await this.renderScaleHeading();return this.margin[0]+[s,...t.map(r=>r.join(" "))].join(`
20`)}async render(){let{submitted:e,size:t}=this.state,s=await this.prefix(),r=await this.separator(),n=await this.message(),l="";this.options.promptLine!==!1&&(l=[s,n,r,""].join(" "),this.state.prompt=l);let o=await this.header(),a=await this.format(),u=await this.renderScaleKey(),c=await this.error()||await this.hint(),h=await this.renderChoices(),x=await this.footer(),g=this.emptyError;a&&(l+=a),c&&!l.includes(c)&&(l+=" "+c),e&&!a&&!h.trim()&&this.multiple&&g!=null&&(l+=this.styles.danger(g)),this.clear(t),this.write([o,l,u,h,x].filter(Boolean).join(`
21`)),this.state.submitted||this.write(this.margin[2]),this.restore()}submit(){this.value={};for(let e of this.choices)this.value[e.name]=e.scaleIndex;return this.base.submit.call(this)}};Di.exports=Ni});var Gi=m((ol,Ui)=>{"use strict";var Hi=_(),Yr=(i="")=>typeof i=="string"?i.replace(/^['"]|['"]$/g,""):"",Vi=class{constructor(e){this.name=e.key,this.field=e.field||{},this.value=Yr(e.initial||this.field.initial||""),this.message=e.message||this.name,this.cursor=0,this.input="",this.lines=[]}},Jr=async(i={},e={},t=s=>s)=>{let s=new Set,r=i.fields||[],n=i.template,l=[],o=[],a=[],u=1;typeof n=="function"&&(n=await n());let c=-1,h=()=>n[++c],x=()=>n[c+1],g=f=>{f.line=u,l.push(f)};for(g({type:"bos",value:""});c<n.length-1;){let f=h();if(/^[^\S\n ]$/.test(f)){g({type:"text",value:f});continue}if(f===`
22`){g({type:"newline",value:f}),u++;continue}if(f==="\\"){f+=h(),g({type:"text",value:f});continue}if((f==="$"||f==="#"||f==="{")&&x()==="{"){f+=h();let d={type:"template",open:f,inner:"",close:"",value:f},p;for(;p=h();){if(p==="}"){x()==="}"&&(p+=h()),d.value+=p,d.close=p;break}p===":"?(d.initial="",d.key=d.inner):d.initial!==void 0&&(d.initial+=p),d.value+=p,d.inner+=p}d.template=d.open+(d.initial||d.inner)+d.close,d.key=d.key||d.inner,e.hasOwnProperty(d.key)&&(d.initial=e[d.key]),d=t(d),g(d),a.push(d.key),s.add(d.key);let y=o.find(v=>v.name===d.key);d.field=r.find(v=>v.name===d.key),y||(y=new Vi(d),o.push(y)),y.lines.push(d.line-1);continue}let w=l[l.length-1];w.type==="text"&&w.line===u?w.value+=f:g({type:"text",value:f})}return g({type:"eos",value:""}),{input:n,tabstops:l,unique:s,keys:a,items:o}};Ui.exports=async i=>{let e=i.options,t=new Set(e.required===!0?[]:e.required||[]),s={...e.values,...e.initial},{tabstops:r,items:n,keys:l}=await Jr(e,s),o=Xe("result",i,e),a=Xe("format",i,e),u=Xe("validate",i,e,!0),c=i.isValue.bind(i);return async(h={},x=!1)=>{let g=0;h.required=t,h.items=n,h.keys=l,h.output="";let f=async(p,y,v,P)=>{let B=await u(p,y,v,P);return B===!1?"Invalid field "+v.name:B};for(let p of r){let y=p.value,v=p.key;if(p.type!=="template"){y&&(h.output+=y);continue}if(p.type==="template"){let P=n.find(ie=>ie.name===v);e.required===!0&&h.required.add(P.name);let B=[P.input,h.values[P.value],P.value,y].find(c),te=(P.field||{}).message||p.inner;if(x){let ie=await f(h.values[v],h,P,g);if(ie&&typeof ie=="string"||ie===!1){h.invalid.set(v,ie);continue}h.invalid.delete(v);let _s=await o(h.values[v],h,P,g);h.output+=Hi.unstyle(_s);continue}P.placeholder=!1;let Ae=y;y=await a(y,h,P,g),B!==y?(h.values[v]=B,y=i.styles.typing(B),h.missing.delete(te)):(h.values[v]=void 0,B=`<${te}>`,y=i.styles.primary(B),P.placeholder=!0,h.required.has(v)&&h.missing.add(te)),h.missing.has(te)&&h.validating&&(y=i.styles.warning(B)),h.invalid.has(v)&&h.validating&&(y=i.styles.danger(B)),g===h.index&&(Ae!==y?y=i.styles.underline(y):y=i.styles.heading(Hi.unstyle(y))),g++}y&&(h.output+=y)}let w=h.output.split(`
23`).map(p=>" "+p),S=n.length,d=0;for(let p of n)h.invalid.has(p.name)&&p.lines.forEach(y=>{w[y][0]===" "&&(w[y]=h.styles.danger(h.symbols.bullet)+w[y].slice(1))}),i.isValue(h.values[p.name])&&d++;return h.completed=(d/S*100).toFixed(0),h.output=w.join(`
24`),h.output}};function Xe(i,e,t,s){return(r,n,l,o)=>typeof l.field[i]=="function"?l.field[i].call(e,r,n,l,o):[s,r].find(a=>e.isValue(a))}});var Zi=m((al,Wi)=>{"use strict";var Qr=_(),Xr=Gi(),en=ue(),Ki=class extends en{constructor(e){super(e);this.cursorHide(),this.reset(!0)}async initialize(){this.interpolate=await Xr(this),await super.initialize()}async reset(e){this.state.keys=[],this.state.invalid=new Map,this.state.missing=new Set,this.state.completed=0,this.state.values={},e!==!0&&(await this.initialize(),await this.render())}moveCursor(e){let t=this.getItem();this.cursor+=e,t.cursor+=e}dispatch(e,t){if(!t.code&&!t.ctrl&&e!=null&&this.getItem()){this.append(e,t);return}this.alert()}append(e,t){let s=this.getItem(),r=s.input.slice(0,this.cursor),n=s.input.slice(this.cursor);this.input=s.input=`${r}${e}${n}`,this.moveCursor(1),this.render()}delete(){let e=this.getItem();if(this.cursor<=0||!e.input)return this.alert();let t=e.input.slice(this.cursor),s=e.input.slice(0,this.cursor-1);this.input=e.input=`${s}${t}`,this.moveCursor(-1),this.render()}increment(e){return e>=this.state.keys.length-1?0:e+1}decrement(e){return e<=0?this.state.keys.length-1:e-1}first(){this.state.index=0,this.render()}last(){this.state.index=this.state.keys.length-1,this.render()}right(){if(this.cursor>=this.input.length)return this.alert();this.moveCursor(1),this.render()}left(){if(this.cursor<=0)return this.alert();this.moveCursor(-1),this.render()}prev(){this.state.index=this.decrement(this.state.index),this.getItem(),this.render()}next(){this.state.index=this.increment(this.state.index),this.getItem(),this.render()}up(){this.prev()}down(){this.next()}format(e){let t=this.state.completed<100?this.styles.warning:this.styles.success;return this.state.submitted===!0&&this.state.completed!==100&&(t=this.styles.danger),t(`${this.state.completed}% completed`)}async render(){let{index:e,keys:t=[],submitted:s,size:r}=this.state,n=[this.options.newline,`
25`].find(p=>p!=null),l=await this.prefix(),o=await this.separator(),a=await this.message(),u=[l,a,o].filter(Boolean).join(" ");this.state.prompt=u;let c=await this.header(),h=await this.error()||"",x=await this.hint()||"",g=s?"":await this.interpolate(this.state),f=this.state.key=t[e]||"",w=await this.format(f),S=await this.footer();w&&(u+=" "+w),x&&!w&&this.state.completed===0&&(u+=" "+x),this.clear(r);let d=[c,u,g,S,h.trim()];this.write(d.filter(Boolean).join(n)),this.restore()}getItem(e){let{items:t,keys:s,index:r}=this.state,n=t.find(l=>l.name===s[r]);return n&&n.input!=null&&(this.input=n.input,this.cursor=n.cursor),n}async submit(){typeof this.interpolate!="function"&&await this.initialize(),await this.interpolate(this.state,!0);let{invalid:e,missing:t,output:s,values:r}=this.state;if(e.size){let o="";for(let[a,u]of e)o+=`Invalid ${a}: ${u}
26`;return this.state.error=o,super.submit()}if(t.size)return this.state.error="Required: "+[...t.keys()].join(", "),super.submit();let l=Qr.unstyle(s).split(`
27`).map(o=>o.slice(1)).join(`
28`);return this.value={values:r,result:l},super.submit()}};Wi.exports=Ki});var Qi=m((ul,Yi)=>{"use strict";var tn="(Use <shift>+<up/down> to sort)",sn=K(),Ji=class extends sn{constructor(e){super({...e,reorder:!1,sort:!0,multiple:!0});this.state.hint=[this.options.hint,tn].find(this.isValue.bind(this))}indicator(){return""}async renderChoice(e,t){let s=await super.renderChoice(e,t),r=this.symbols.identicalTo+" ",n=this.index===t&&this.sorting?this.styles.muted(r):" ";return this.options.drag===!1&&(n=""),this.options.numbered===!0?n+`${t+1} - `+s:n+s}get selected(){return this.choices}submit(){return this.value=this.choices.map(e=>e.value),super.submit()}};Yi.exports=Ji});var ts=m((hl,Xi)=>{"use strict";var rn=ge(),es=class extends rn{constructor(e={}){super(e);if(this.emptyError=e.emptyError||"No items were selected",this.term=process.env.TERM_PROGRAM,!this.options.header){let t=["","4 - Strongly Agree","3 - Agree","2 - Neutral","1 - Disagree","0 - Strongly Disagree",""];t=t.map(s=>this.styles.muted(s)),this.state.header=t.join(`
29 `)}}async toChoices(...e){if(this.createdScales)return!1;this.createdScales=!0;let t=await super.toChoices(...e);for(let s of t)s.scale=nn(5,this.options),s.scaleIdx=2;return t}dispatch(){this.alert()}space(){let e=this.focused,t=e.scale[e.scaleIdx],s=t.selected;return e.scale.forEach(r=>r.selected=!1),t.selected=!s,this.render()}indicator(){return""}pointer(){return""}separator(){return this.styles.muted(this.symbols.ellipsis)}right(){let e=this.focused;return e.scaleIdx>=e.scale.length-1?this.alert():(e.scaleIdx++,this.render())}left(){let e=this.focused;return e.scaleIdx<=0?this.alert():(e.scaleIdx--,this.render())}indent(){return" "}async renderChoice(e,t){await this.onChoice(e,t);let s=this.index===t,r=this.term==="Hyper",n=r?9:8,l=r?"":" ",o=this.symbols.line.repeat(n),a=" ".repeat(n+(r?0:1)),u=y=>(y?this.styles.success("◉"):"◯")+l,c=t+1+".",h=s?this.styles.heading:this.styles.noop,x=await this.resolve(e.message,this.state,e,t),g=this.indent(e),f=g+e.scale.map((y,v)=>u(v===e.scaleIdx)).join(o),w=y=>y===e.scaleIdx?h(y):y,S=g+e.scale.map((y,v)=>w(v)).join(a),d=()=>[c,x].filter(Boolean).join(" "),p=()=>[d(),f,S," "].filter(Boolean).join(`
30`);return s&&(f=this.styles.cyan(f),S=this.styles.cyan(S)),p()}async renderChoices(){if(this.state.submitted)return"";let e=this.visible.map(async(s,r)=>await this.renderChoice(s,r)),t=await Promise.all(e);return t.length||t.push(this.styles.danger("No matching choices")),t.join(`
31`)}format(){return this.state.submitted?this.choices.map(t=>this.styles.info(t.scaleIdx)).join(", "):""}async render(){let{submitted:e,size:t}=this.state,s=await this.prefix(),r=await this.separator(),n=await this.message(),l=[s,n,r].filter(Boolean).join(" ");this.state.prompt=l;let o=await this.header(),a=await this.format(),u=await this.error()||await this.hint(),c=await this.renderChoices(),h=await this.footer();(a||!u)&&(l+=" "+a),u&&!l.includes(u)&&(l+=" "+u),e&&!a&&!c&&this.multiple&&this.type!=="form"&&(l+=this.styles.danger(this.emptyError)),this.clear(t),this.write([l,o,c,h].filter(Boolean).join(`
32`)),this.restore()}submit(){this.value={};for(let e of this.choices)this.value[e.name]=e.scaleIdx;return this.base.submit.call(this)}};function nn(i,e={}){if(Array.isArray(e.scale))return e.scale.map(s=>({...s}));let t=[];for(let s=1;s<i+1;s++)t.push({i:s,selected:!1});return t}Xi.exports=es});var ss=m((cl,is)=>{is.exports=Je()});var ls=m((fl,rs)=>{"use strict";var ln=Be(),ns=class extends ln{async initialize(){await super.initialize(),this.value=this.initial=!!this.options.initial,this.disabled=this.options.disabled||"no",this.enabled=this.options.enabled||"yes",await this.render()}reset(){this.value=this.initial,this.render()}delete(){this.alert()}toggle(){this.value=!this.value,this.render()}enable(){if(this.value===!0)return this.alert();this.value=!0,this.render()}disable(){if(this.value===!1)return this.alert();this.value=!1,this.render()}up(){this.toggle()}down(){this.toggle()}right(){this.toggle()}left(){this.toggle()}next(){this.toggle()}prev(){this.toggle()}dispatch(e="",t){switch(e.toLowerCase()){case" ":return this.toggle();case"1":case"y":case"t":return this.enable();case"0":case"n":case"f":return this.disable();default:return this.alert()}}format(){let e=s=>this.styles.primary.underline(s);return[this.value?this.disabled:e(this.disabled),this.value?e(this.enabled):this.enabled].join(this.styles.muted(" / "))}async render(){let{size:e}=this.state,t=await this.header(),s=await this.prefix(),r=await this.separator(),n=await this.message(),l=await this.format(),o=await this.error()||await this.hint(),a=await this.footer(),u=[s,n,r,l].join(" ");this.state.prompt=u,o&&!u.includes(o)&&(u+=" "+o),this.clear(e),this.write([t,u,a].filter(Boolean).join(`
33`)),this.write(this.margin[2]),this.restore()}};rs.exports=ns});var us=m((dl,os)=>{"use strict";var on=K(),as=class extends on{constructor(e){super(e);if(typeof this.options.correctChoice!="number"||this.options.correctChoice<0)throw new Error("Please specify the index of the correct answer from the list of choices")}async toChoices(e,t){let s=await super.toChoices(e,t);if(s.length<2)throw new Error("Please give at least two choices to the user");if(this.options.correctChoice>s.length)throw new Error("Please specify the index of the correct answer from the list of choices");return s}check(e){return e.index===this.options.correctChoice}async result(e){return{selectedAnswer:e,correctAnswer:this.options.choices[this.options.correctChoice].value,correct:await this.check(this.state)}}};os.exports=as});var cs=m(et=>{"use strict";var hs=q(),O=(i,e)=>{hs.defineExport(et,i,e),hs.defineExport(et,i.toLowerCase(),e)};O("AutoComplete",()=>Xt());O("BasicAuth",()=>oi());O("Confirm",()=>fi());O("Editable",()=>mi());O("Form",()=>Ee());O("Input",()=>Je());O("Invisible",()=>Pi());O("List",()=>Bi());O("MultiSelect",()=>ji());O("Numeral",()=>Li());O("Password",()=>zi());O("Scale",()=>Fi());O("Select",()=>K());O("Snippet",()=>Zi());O("Sort",()=>Qi());O("Survey",()=>ts());O("Text",()=>ss());O("Toggle",()=>ls());O("Quiz",()=>us())});var ds=m((ml,fs)=>{fs.exports={ArrayPrompt:ge(),AuthPrompt:Ye(),BooleanPrompt:Be(),NumberPrompt:Qe(),StringPrompt:ne()}});var gs=m((gl,ps)=>{"use strict";var ms=require("assert"),tt=require("events"),Z=q(),F=class extends tt{constructor(e,t){super();this.options=Z.merge({},e),this.answers={...t}}register(e,t){if(Z.isObject(e)){for(let r of Object.keys(e))this.register(r,e[r]);return this}ms.equal(typeof t,"function","expected a function");let s=e.toLowerCase();return t.prototype instanceof this.Prompt?this.prompts[s]=t:this.prompts[s]=t(this.Prompt,this),this}async prompt(e=[]){for(let t of[].concat(e))try{typeof t=="function"&&(t=await t.call(this)),await this.ask(Z.merge({},this.options,t))}catch(s){return Promise.reject(s)}return this.answers}async ask(e){typeof e=="function"&&(e=await e.call(this));let t=Z.merge({},this.options,e),{type:s,name:r}=e,{set:n,get:l}=Z;if(typeof s=="function"&&(s=await s.call(this,e,this.answers)),!s)return this.answers[r];ms(this.prompts[s],`Prompt "${s}" is not registered`);let o=new this.prompts[s](t),a=l(this.answers,r);o.state.answers=this.answers,o.enquirer=this,r&&o.on("submit",c=>{this.emit("answer",r,c,o),n(this.answers,r,c)});let u=o.emit.bind(o);return o.emit=(...c)=>(this.emit.call(this,...c),u(...c)),this.emit("prompt",o,this),t.autofill&&a!=null?(o.value=o.input=a,t.autofill==="show"&&await o.submit()):a=o.value=await o.run(),a}use(e){return e.call(this,this),this}set Prompt(e){this._Prompt=e}get Prompt(){return this._Prompt||this.constructor.Prompt}get prompts(){return this.constructor.prompts}static set Prompt(e){this._Prompt=e}static get Prompt(){return this._Prompt||ue()}static get prompts(){return cs()}static get types(){return ds()}static get prompt(){let e=(t,...s)=>{let r=new this(...s),n=r.emit.bind(r);return r.emit=(...l)=>(e.emit(...l),n(...l)),r.prompt(t)};return Z.mixinEmitter(e,new tt),e}};Z.mixinEmitter(F,new tt);var it=F.prompts;for(let i of Object.keys(it)){let e=i.toLowerCase(),t=s=>new it[i](s).run();F.prompt[e]=t,F[e]=t,F[i]||Reflect.defineProperty(F,i,{get:()=>it[i]})}var ye=i=>{Z.defineExport(F,i,()=>F.types[i])};ye("ArrayPrompt");ye("AuthPrompt");ye("BooleanPrompt");ye("NumberPrompt");ye("StringPrompt");ps.exports=F});var ee=N(gs()),As=N(require("child_process")),pe=N(require("path")),Te=N(require("fs"));var st=N(require("perf_hooks")),ce=Symbol.for("#spinner"),an=Symbol.for("#ctime"),ys=Symbol.for("#IMBA_OPTIONS"),un={reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],inverse:[7,27],hidden:[8,28],strikethrough:[9,29],black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],gray:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},z={bold:function(i){return""+i+""},red:function(i){return""+i+""},green:function(i){return""+i+""},yellow:function(i){return""+i+""},blue:function(i){return""+i+""},gray:function(i){return""+i+""},white:function(i){return""+i+""},f:function(i,e){let t=un[i];return"["+t[0]+"m"+e+"["+t[1]+"m"}};z.warn=z.yellow;z.error=z.red;var be=process.platform!=="win32"||process.env.CI||process.env.TERM==="xterm-256color",hn={info:z.f("yellowBright",be?"ℹ":"i"),success:z.green(be?"✔":"√"),warning:z.yellow(be?"⚠":"!!"),error:z.red(be?"×":"✖"),debug:z.blue(be?"ℹ":"i")},bs=["debug","info","success","warning","error","silent"],cn={"-1":"socket","4":"ip4","6":"ip6"};function fn(i){let e=z.f;return i=i.replace(/https?\:[^\s\n\)\]]+/g,function(t){return e("blueBright",t)}),i=i.replace(/^[\t\s]*\>[^\n]+/gm,function(t){return e("bold",t)}),i=i.replace(/\t/g," "),i=i.replace(/^/gm," "),i}function ws(i,...e){let t=z.f;return i=i.replace(/\%([\w\.]+)/g,function(s,r){let n=e.shift();if(r=="markdown")return fn(n);if(r=="kb")return t("dim",(n/1e3).toFixed(1)+"kb");if(r=="path"||r=="bold")return t("bold",n);if(r=="dim")return t("dim",n);if(r=="address"){let l=cn[n.addressType];return n.port?t("blueBright",[n.address||"http://127.0.0.1",n.port].join(":")):t("blueBright",l)}else{if(r=="ms")return t("yellow",Math.round(n)+"ms");if(r=="d")return t("blueBright",n);if(r=="red")return t("redBright",n);if(r=="green")return t("greenBright",n);if(r=="yellow")return t("yellowBright",n);if(r=="ref")return t("yellowBright","#"+(n.id||n));if(r=="elapsed"){n!=null&&e.unshift(n);let l=st.performance.now();return t("yellow",Math.round(l)+"ms")}else if(r=="heap"){n!=null&&e.unshift(n);let l=process.memoryUsage().heapUsed/1024/1024;return t("yellow",l.toFixed(2)+"mb")}else return n}}),[i,...e]}var vs=null,xs=null,Ss=class{static get main(){return xs||(xs=new this)}constructor({prefix:e=null,loglevel:t}={}){this[an]=Date.now(),this.prefix=e?ws(...e)[0]:"",this.loglevel=t||process.env.IMBA_LOGLEVEL||globalThis[ys]&&globalThis[ys].loglevel||"info"}write(e,...t){if(bs.indexOf(e)<bs.indexOf(this.loglevel))return this;let s=hn[e]||e,[r,...n]=ws(...t);return this.prefix&&(r=this.prefix+r),this[ce]&&this[ce].isSpinning?(e=="success"&&(this[ce].clear(),console.log(s+" "+r,...n),this[ce].frame()),this[ce].text=r):console.log(s+" "+r,...n)}debug(...e){return this.write("debug",...e)}log(...e){return this.write("info",...e)}info(...e){return this.write("info",...e)}warn(...e){return this.write("warn",...e)}error(...e){return this.write("error",...e)}success(...e){return this.write("success",...e)}ts(...e){return this.write("debug",...e,st.performance.now())}spinner(){}get[ce](){return vs}get proxy(){var e=this;let t=function(...s){return e.info(...s)};return t.info=this.info.bind(this),t.warn=this.warn.bind(this),t.error=this.error.bind(this),t.debug=this.debug.bind(this),t.success=this.success.bind(this),t.ts=this.ts.bind(this),t.logger=this,t}async time(e,t){let s=Date.now();if(t){let r=await t();return this.info(""+e+" %ms",Date.now()-s),r}}},le=new Ss().proxy;var R=N(require("stream")),rt=N(require("http")),qe=N(require("url")),ks=N(require("https")),Y=N(require("zlib")),dn=R.default.Readable,H=Symbol("buffer"),nt=Symbol("type"),oe=class{constructor(){this[nt]="";let e=arguments[0],t=arguments[1],s=[],r=0;if(e){let l=e,o=Number(l.length);for(let a=0;a<o;a++){let u=l[a],c;u instanceof Buffer?c=u:ArrayBuffer.isView(u)?c=Buffer.from(u.buffer,u.byteOffset,u.byteLength):u instanceof ArrayBuffer?c=Buffer.from(u):u instanceof oe?c=u[H]:c=Buffer.from(typeof u=="string"?u:String(u)),r+=c.length,s.push(c)}}this[H]=Buffer.concat(s);let n=t&&t.type!==void 0&&String(t.type).toLowerCase();n&&!/[^\u0020-\u007E]/.test(n)&&(this[nt]=n)}get size(){return this[H].length}get type(){return this[nt]}text(){return Promise.resolve(this[H].toString())}arrayBuffer(){let e=this[H],t=e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength);return Promise.resolve(t)}stream(){let e=new dn;return e._read=function(){},e.push(this[H]),e.push(null),e}toString(){return"[object Blob]"}slice(){let e=this.size,t=arguments[0],s=arguments[1],r,n;t===void 0?r=0:t<0?r=Math.max(e+t,0):r=Math.min(t,e),s===void 0?n=e:s<0?n=Math.max(e+s,0):n=Math.min(s,e);let l=Math.max(n-r,0),a=this[H].slice(r,r+l),u=new oe([],{type:arguments[2]});return u[H]=a,u}};Object.defineProperties(oe.prototype,{size:{enumerable:!0},type:{enumerable:!0},slice:{enumerable:!0}});Object.defineProperty(oe.prototype,Symbol.toStringTag,{value:"Blob",writable:!1,enumerable:!1,configurable:!0});function j(i,e,t){Error.call(this,i),this.message=i,this.type=e,t&&(this.code=this.errno=t.code),Error.captureStackTrace(this,this.constructor)}j.prototype=Object.create(Error.prototype);j.prototype.constructor=j;j.prototype.name="FetchError";var lt;try{lt=require("encoding").convert}catch(i){}var V=Symbol("Body internals"),Cs=R.default.PassThrough;function E(i){var e=this,t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},s=t.size;let r=s===void 0?0:s;var n=t.timeout;let l=n===void 0?0:n;i==null?i=null:Ps(i)?i=Buffer.from(i.toString()):we(i)||Buffer.isBuffer(i)||(Object.prototype.toString.call(i)==="[object ArrayBuffer]"?i=Buffer.from(i):ArrayBuffer.isView(i)?i=Buffer.from(i.buffer,i.byteOffset,i.byteLength):i instanceof R.default||(i=Buffer.from(String(i)))),this[V]={body:i,disturbed:!1,error:null},this.size=r,this.timeout=l,i instanceof R.default&&i.on("error",function(o){let a=o.name==="AbortError"?o:new j(`Invalid response body while trying to fetch ${e.url}: ${o.message}`,"system",o);e[V].error=a})}E.prototype={get body(){return this[V].body},get bodyUsed(){return this[V].disturbed},arrayBuffer(){return fe.call(this).then(function(i){return i.buffer.slice(i.byteOffset,i.byteOffset+i.byteLength)})},blob(){let i=this.headers&&this.headers.get("content-type")||"";return fe.call(this).then(function(e){return Object.assign(new oe([],{type:i.toLowerCase()}),{[H]:e})})},json(){var i=this;return fe.call(this).then(function(e){try{return JSON.parse(e.toString())}catch(t){return E.Promise.reject(new j(`invalid json response body at ${i.url} reason: ${t.message}`,"invalid-json"))}})},text(){return fe.call(this).then(function(i){return i.toString()})},buffer(){return fe.call(this)},textConverted(){var i=this;return fe.call(this).then(function(e){return pn(e,i.headers)})}};Object.defineProperties(E.prototype,{body:{enumerable:!0},bodyUsed:{enumerable:!0},arrayBuffer:{enumerable:!0},blob:{enumerable:!0},json:{enumerable:!0},text:{enumerable:!0}});E.mixIn=function(i){for(let e of Object.getOwnPropertyNames(E.prototype))if(!(e in i)){let t=Object.getOwnPropertyDescriptor(E.prototype,e);Object.defineProperty(i,e,t)}};function fe(){var i=this;if(this[V].disturbed)return E.Promise.reject(new TypeError(`body used already for: ${this.url}`));if(this[V].disturbed=!0,this[V].error)return E.Promise.reject(this[V].error);let e=this.body;if(e===null)return E.Promise.resolve(Buffer.alloc(0));if(we(e)&&(e=e.stream()),Buffer.isBuffer(e))return E.Promise.resolve(e);if(!(e instanceof R.default))return E.Promise.resolve(Buffer.alloc(0));let t=[],s=0,r=!1;return new E.Promise(function(n,l){let o;i.timeout&&(o=setTimeout(function(){r=!0,l(new j(`Response timeout while trying to fetch ${i.url} (over ${i.timeout}ms)`,"body-timeout"))},i.timeout)),e.on("error",function(a){a.name==="AbortError"?(r=!0,l(a)):l(new j(`Invalid response body while trying to fetch ${i.url}: ${a.message}`,"system",a))}),e.on("data",function(a){if(!(r||a===null)){if(i.size&&s+a.length>i.size){r=!0,l(new j(`content size at ${i.url} over limit: ${i.size}`,"max-size"));return}s+=a.length,t.push(a)}}),e.on("end",function(){if(!r){clearTimeout(o);try{n(Buffer.concat(t,s))}catch(a){l(new j(`Could not create Buffer from response body for ${i.url}: ${a.message}`,"system",a))}}})})}function pn(i,e){if(typeof lt!="function")throw new Error("The package `encoding` must be installed to use the textConverted() function");let t=e.get("content-type"),s="utf-8",r,n;return t&&(r=/charset=([^;]*)/i.exec(t)),n=i.slice(0,1024).toString(),!r&&n&&(r=/<meta.+?charset=(['"])(.+?)\1/i.exec(n)),!r&&n&&(r=/<meta[\s]+?http-equiv=(['"])content-type\1[\s]+?content=(['"])(.+?)\2/i.exec(n),r||(r=/<meta[\s]+?content=(['"])(.+?)\1[\s]+?http-equiv=(['"])content-type\3/i.exec(n),r&&r.pop()),r&&(r=/charset=(.*)/i.exec(r.pop()))),!r&&n&&(r=/<\?xml.+?encoding=(['"])(.+?)\1/i.exec(n)),r&&(s=r.pop(),(s==="gb2312"||s==="gbk")&&(s="gb18030")),lt(i,"UTF-8",s).toString()}function Ps(i){return typeof i!="object"||typeof i.append!="function"||typeof i.delete!="function"||typeof i.get!="function"||typeof i.getAll!="function"||typeof i.has!="function"||typeof i.set!="function"?!1:i.constructor.name==="URLSearchParams"||Object.prototype.toString.call(i)==="[object URLSearchParams]"||typeof i.sort=="function"}function we(i){return typeof i=="object"&&typeof i.arrayBuffer=="function"&&typeof i.type=="string"&&typeof i.stream=="function"&&typeof i.constructor=="function"&&typeof i.constructor.name=="string"&&/^(Blob|File)$/.test(i.constructor.name)&&/^(Blob|File)$/.test(i[Symbol.toStringTag])}function Os(i){let e,t,s=i.body;if(i.bodyUsed)throw new Error("cannot clone body after it is used");return s instanceof R.default&&typeof s.getBoundary!="function"&&(e=new Cs,t=new Cs,s.pipe(e),s.pipe(t),i[V].body=e,s=t),s}function Es(i){return i===null?null:typeof i=="string"?"text/plain;charset=UTF-8":Ps(i)?"application/x-www-form-urlencoded;charset=UTF-8":we(i)?i.type||null:Buffer.isBuffer(i)||Object.prototype.toString.call(i)==="[object ArrayBuffer]"||ArrayBuffer.isView(i)?null:typeof i.getBoundary=="function"?`multipart/form-data;boundary=${i.getBoundary()}`:i instanceof R.default?null:"text/plain;charset=UTF-8"}function Bs(i){let e=i.body;return e===null?0:we(e)?e.size:Buffer.isBuffer(e)?e.length:e&&typeof e.getLengthSync=="function"&&(e._lengthRetrievers&&e._lengthRetrievers.length==0||e.hasKnownLength&&e.hasKnownLength())?e.getLengthSync():null}function mn(i,e){let t=e.body;t===null?i.end():we(t)?t.stream().pipe(i):Buffer.isBuffer(t)?(i.write(t),i.end()):t.pipe(i)}E.Promise=global.Promise;var $s=/[^\^_`a-zA-Z\-0-9!#$%&'*+.|~]/,ot=/[^\t\x20-\x7e\x80-\xff]/;function ve(i){if(i=`${i}`,$s.test(i)||i==="")throw new TypeError(`${i} is not a legal HTTP header name`)}function qs(i){if(i=`${i}`,ot.test(i))throw new TypeError(`${i} is not a legal HTTP header value`)}function de(i,e){e=e.toLowerCase();for(let t in i)if(t.toLowerCase()===e)return t}var C=Symbol("map"),L=class{constructor(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:void 0;if(this[C]=Object.create(null),e instanceof L){let t=e.raw(),s=Object.keys(t);for(let r of s)for(let n of t[r])this.append(r,n);return}if(e!=null)if(typeof e=="object"){let t=e[Symbol.iterator];if(t!=null){if(typeof t!="function")throw new TypeError("Header pairs must be iterable");let s=[];for(let r of e){if(typeof r!="object"||typeof r[Symbol.iterator]!="function")throw new TypeError("Each header pair must be iterable");s.push(Array.from(r))}for(let r of s){if(r.length!==2)throw new TypeError("Each header pair must be a name/value tuple");this.append(r[0],r[1])}}else for(let s of Object.keys(e)){let r=e[s];this.append(s,r)}}else throw new TypeError("Provided initializer must be an object")}get(e){e=`${e}`,ve(e);let t=de(this[C],e);return t===void 0?null:this[C][t].join(", ")}forEach(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:void 0,s=at(this),r=0;for(;r<s.length;){var n=s[r];let l=n[0],o=n[1];e.call(t,o,l,this),s=at(this),r++}}set(e,t){e=`${e}`,t=`${t}`,ve(e),qs(t);let s=de(this[C],e);this[C][s!==void 0?s:e]=[t]}append(e,t){e=`${e}`,t=`${t}`,ve(e),qs(t);let s=de(this[C],e);s!==void 0?this[C][s].push(t):this[C][e]=[t]}has(e){return e=`${e}`,ve(e),de(this[C],e)!==void 0}delete(e){e=`${e}`,ve(e);let t=de(this[C],e);t!==void 0&&delete this[C][t]}raw(){return this[C]}keys(){return ut(this,"key")}values(){return ut(this,"value")}[Symbol.iterator](){return ut(this,"key+value")}};L.prototype.entries=L.prototype[Symbol.iterator];Object.defineProperty(L.prototype,Symbol.toStringTag,{value:"Headers",writable:!1,enumerable:!1,configurable:!0});Object.defineProperties(L.prototype,{get:{enumerable:!0},forEach:{enumerable:!0},set:{enumerable:!0},append:{enumerable:!0},has:{enumerable:!0},delete:{enumerable:!0},keys:{enumerable:!0},values:{enumerable:!0},entries:{enumerable:!0}});function at(i){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"key+value";return Object.keys(i[C]).sort().map(e==="key"?function(s){return s.toLowerCase()}:e==="value"?function(s){return i[C][s].join(", ")}:function(s){return[s.toLowerCase(),i[C][s].join(", ")]})}var ht=Symbol("internal");function ut(i,e){let t=Object.create(ct);return t[ht]={target:i,kind:e,index:0},t}var ct=Object.setPrototypeOf({next(){if(!this||Object.getPrototypeOf(this)!==ct)throw new TypeError("Value of `this` is not a HeadersIterator");var i=this[ht];let e=i.target,t=i.kind,s=i.index,r=at(e,t),n=r.length;return s>=n?{value:void 0,done:!0}:(this[ht].index=s+1,{value:r[s],done:!1})}},Object.getPrototypeOf(Object.getPrototypeOf([][Symbol.iterator]())));Object.defineProperty(ct,Symbol.toStringTag,{value:"HeadersIterator",writable:!1,enumerable:!1,configurable:!0});function gn(i){let e=Object.assign({__proto__:null},i[C]),t=de(i[C],"Host");return t!==void 0&&(e[t]=e[t][0]),e}function yn(i){let e=new L;for(let t of Object.keys(i))if(!$s.test(t))if(Array.isArray(i[t]))for(let s of i[t])ot.test(s)||(e[C][t]===void 0?e[C][t]=[s]:e[C][t].push(s));else ot.test(i[t])||(e[C][t]=[i[t]]);return e}var J=Symbol("Response internals"),bn=rt.default.STATUS_CODES,D=class{constructor(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:null,t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};E.call(this,e,t);let s=t.status||200,r=new L(t.headers);if(e!=null&&!r.has("Content-Type")){let n=Es(e);n&&r.append("Content-Type",n)}this[J]={url:t.url,status:s,statusText:t.statusText||bn[s],headers:r,counter:t.counter}}get url(){return this[J].url||""}get status(){return this[J].status}get ok(){return this[J].status>=200&&this[J].status<300}get redirected(){return this[J].counter>0}get statusText(){return this[J].statusText}get headers(){return this[J].headers}clone(){return new D(Os(this),{url:this.url,status:this.status,statusText:this.statusText,headers:this.headers,ok:this.ok,redirected:this.redirected})}};E.mixIn(D.prototype);Object.defineProperties(D.prototype,{url:{enumerable:!0},status:{enumerable:!0},ok:{enumerable:!0},redirected:{enumerable:!0},statusText:{enumerable:!0},headers:{enumerable:!0},clone:{enumerable:!0}});Object.defineProperty(D.prototype,Symbol.toStringTag,{value:"Response",writable:!1,enumerable:!1,configurable:!0});var G=Symbol("Request internals"),ft=qe.default.parse,wn=qe.default.format,vn="destroy"in R.default.Readable.prototype;function je(i){return typeof i=="object"&&typeof i[G]=="object"}function xn(i){let e=i&&typeof i=="object"&&Object.getPrototypeOf(i);return!!(e&&e.constructor.name==="AbortSignal")}var Q=class{constructor(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},s;je(e)?s=ft(e.url):(e&&e.href?s=ft(e.href):s=ft(`${e}`),e={});let r=t.method||e.method||"GET";if(r=r.toUpperCase(),(t.body!=null||je(e)&&e.body!==null)&&(r==="GET"||r==="HEAD"))throw new TypeError("Request with GET/HEAD method cannot have body");let n=t.body!=null?t.body:je(e)&&e.body!==null?Os(e):null;E.call(this,n,{timeout:t.timeout||e.timeout||0,size:t.size||e.size||0});let l=new L(t.headers||e.headers||{});if(n!=null&&!l.has("Content-Type")){let a=Es(n);a&&l.append("Content-Type",a)}let o=je(e)?e.signal:null;if("signal"in t&&(o=t.signal),o!=null&&!xn(o))throw new TypeError("Expected signal to be an instanceof AbortSignal");this[G]={method:r,redirect:t.redirect||e.redirect||"follow",headers:l,parsedURL:s,signal:o},this.follow=t.follow!==void 0?t.follow:e.follow!==void 0?e.follow:20,this.compress=t.compress!==void 0?t.compress:e.compress!==void 0?e.compress:!0,this.counter=t.counter||e.counter||0,this.agent=t.agent||e.agent}get method(){return this[G].method}get url(){return wn(this[G].parsedURL)}get headers(){return this[G].headers}get redirect(){return this[G].redirect}get signal(){return this[G].signal}clone(){return new Q(this)}};E.mixIn(Q.prototype);Object.defineProperty(Q.prototype,Symbol.toStringTag,{value:"Request",writable:!1,enumerable:!1,configurable:!0});Object.defineProperties(Q.prototype,{method:{enumerable:!0},url:{enumerable:!0},headers:{enumerable:!0},redirect:{enumerable:!0},clone:{enumerable:!0},signal:{enumerable:!0}});function Sn(i){let e=i[G].parsedURL,t=new L(i[G].headers);if(t.has("Accept")||t.set("Accept","*/*"),!e.protocol||!e.hostname)throw new TypeError("Only absolute URLs are supported");if(!/^https?:$/.test(e.protocol))throw new TypeError("Only HTTP(S) protocols are supported");if(i.signal&&i.body instanceof R.default.Readable&&!vn)throw new Error("Cancellation of streamed requests with AbortSignal is not supported in node < 8");let s=null;if(i.body==null&&/^(POST|PUT)$/i.test(i.method)&&(s="0"),i.body!=null){let n=Bs(i);typeof n=="number"&&(s=String(n))}s&&t.set("Content-Length",s),t.has("User-Agent")||t.set("User-Agent","node-fetch/1.0 (+https://github.com/bitinn/node-fetch)"),i.compress&&!t.has("Accept-Encoding")&&t.set("Accept-Encoding","gzip,deflate");let r=i.agent;return typeof r=="function"&&(r=r(e)),!t.has("Connection")&&!r&&t.set("Connection","close"),Object.assign({},e,{method:i.method,headers:gn(t),agent:r})}function xe(i){Error.call(this,i),this.type="aborted",this.message=i,Error.captureStackTrace(this,this.constructor)}xe.prototype=Object.create(Error.prototype);xe.prototype.constructor=xe;xe.prototype.name="AbortError";var js=R.default.PassThrough,kn=qe.default.resolve;function X(i,e){if(!X.Promise)throw new Error("native promise missing, set fetch.Promise to your favorite alternative");return E.Promise=X.Promise,new X.Promise(function(t,s){let r=new Q(i,e),n=Sn(r),l=(n.protocol==="https:"?ks.default:rt.default).request,o=r.signal,a=null,u=function(){let w=new xe("The user aborted a request.");s(w),r.body&&r.body instanceof R.default.Readable&&r.body.destroy(w),!(!a||!a.body)&&a.body.emit("error",w)};if(o&&o.aborted){u();return}let c=function(){u(),g()},h=l(n),x;o&&o.addEventListener("abort",c);function g(){h.abort(),o&&o.removeEventListener("abort",c),clearTimeout(x)}r.timeout&&h.once("socket",function(f){x=setTimeout(function(){s(new j(`network timeout at: ${r.url}`,"request-timeout")),g()},r.timeout)}),h.on("error",function(f){s(new j(`request to ${r.url} failed, reason: ${f.message}`,"system",f)),g()}),h.on("response",function(f){clearTimeout(x);let w=yn(f.headers);if(X.isRedirect(f.statusCode)){let v=w.get("Location"),P=v===null?null:kn(r.url,v);switch(r.redirect){case"error":s(new j(`uri requested responds with a redirect, redirect mode is set to error: ${r.url}`,"no-redirect")),g();return;case"manual":if(P!==null)try{w.set("Location",P)}catch(Se){s(Se)}break;case"follow":if(P===null)break;if(r.counter>=r.follow){s(new j(`maximum redirect reached at: ${r.url}`,"max-redirect")),g();return}let B={headers:new L(r.headers),follow:r.follow,counter:r.counter+1,agent:r.agent,compress:r.compress,method:r.method,body:r.body,signal:r.signal,timeout:r.timeout,size:r.size};if(f.statusCode!==303&&r.body&&Bs(r)===null){s(new j("Cannot follow redirect with body being a readable stream","unsupported-redirect")),g();return}(f.statusCode===303||(f.statusCode===301||f.statusCode===302)&&r.method==="POST")&&(B.method="GET",B.body=void 0,B.headers.delete("content-length")),t(X(new Q(P,B))),g();return}}f.once("end",function(){o&&o.removeEventListener("abort",c)});let S=f.pipe(new js),d={url:r.url,status:f.statusCode,statusText:f.statusMessage,headers:w,size:r.size,timeout:r.timeout,counter:r.counter},p=w.get("Content-Encoding");if(!r.compress||r.method==="HEAD"||p===null||f.statusCode===204||f.statusCode===304){a=new D(S,d),t(a);return}let y={flush:Y.default.Z_SYNC_FLUSH,finishFlush:Y.default.Z_SYNC_FLUSH};if(p=="gzip"||p=="x-gzip"){S=S.pipe(Y.default.createGunzip(y)),a=new D(S,d),t(a);return}if(p=="deflate"||p=="x-deflate"){f.pipe(new js).once("data",function(P){(P[0]&15)==8?S=S.pipe(Y.default.createInflate()):S=S.pipe(Y.default.createInflateRaw()),a=new D(S,d),t(a)});return}if(p=="br"&&typeof Y.default.createBrotliDecompress=="function"){S=S.pipe(Y.default.createBrotliDecompress()),a=new D(S,d),t(a);return}a=new D(S,d),t(a)}),mn(h,r)})}X.isRedirect=function(i){return i===301||i===302||i===303||i===307||i===308};X.Promise=global.Promise;var Ts=X;var Rs=Symbol.for("#init");async function Ls(i){if(i.match(/^https?\:/))return(await Ts(i)).json();let e=Te.default.readFileSync(pe.default.resolve(i,"package.json"),"utf-8");return JSON.parse(e)}function Cn(i,e){let t=JSON.stringify(e,null,2);return Te.default.writeFileSync(pe.default.resolve(i,"package.json"),t)}var Pn=pe.default.resolve(__dirname,".."),Sl=Ls(Pn),On=[["base-template","Application with client-side scripts"],["electron-template","Electron application"]].map(function([i,e]){return{name:i,hint:e}}),M=new class{constructor(i=null){this[Rs](i)}[Rs](i=null){var e;this.cwd=i&&(e=i.cwd)!==void 0?e:process.cwd()}set status(i){le.info(i)}ok(i,e={}){return new ee.Confirm(Object.assign({name:"question",message:i},e)).run()}select(i,e,t={}){return new ee.Select(Object.assign({type:"select",message:i,choices:e},t)).run()}input(i,e={}){return new ee.Input(Object.assign({message:i},e)).run()}exec(i,e={}){return(0,As.execSync)(i,Object.assign({cwd:this.cwd},e)).toString().trim()}package(i={}){return new ee.Snippet({name:"username",message:"Fill out the fields in package.json",required:!1,fields:[{name:"name",message:"project",initial:i.name},{name:"version",initial:"1.0.0"},{name:"author_name",message:"Author Name",initial:"Author Name"}],template:'{\n "name": "${name}",\n "repository": "${username}/${name}",\n "description": "${description}",\n "version": "${version}",\n "homepage": "https://github.com/${username}/${name}",\n "author": "${author_name} (https://github.com/${username})",\n "license": "${license:ISC}"\n}'}).run()}};async function En(){var i;try{let e=await M.select("Choose your template",On),t="https://github.com/imba/imba-"+e,s=await Ls("https://raw.githubusercontent.com/imba/imba-"+e+"/master/package.json"),r=process.argv[2]||"";r||(r=await M.input("Name your project",{initial:"hello-imba"}));let n=await M.ok("Configure package.json?"),l={name:r};if(n){let a="",u=await M.package({name:r,description:s.description});l=JSON.parse(u.result),l.repository[0]=="/"&&(i=l.repository,delete l.repository)}let o=pe.default.resolve(l.name);if(await M.ok("Create project in directory: "+o+"?",{initial:!0})){le.info("Generating files from template"),await M.exec("git clone --depth 1 "+t+' "'+o+'"'),M.cwd=o,await Te.default.rmdirSync(pe.default.resolve(o,".git"),{recursive:!0}),await M.exec("git init .");let a=Object.assign({},s,l);Cn(o,a),le.info("Installing dependencies"),await M.exec("npm install imba"),await M.exec("npm install"),l.repository&&(le.info("add origin https://github.com/"+l.repository+".git"),await M.exec("git remote add origin https://github.com/"+l.repository+".git"));let u=`
34Install the vscode extension for the optimal experience:
35 https://marketplace.visualstudio.com/items?itemName=scrimba.vsimba
36
37Join the imba community on discord for help and friendly discussions:
38 https://discord.gg/mkcbkRw
39
40Get started:
41
42 > cd `+l.name+`
43 > npm start
44`;return le.success(`Finished setting up project!
45%markdown`,u)}}catch(e){return le.error(`Something went wrong during creation
46 Please report at https://github.com/imba/imba/issues`)}}En();