create-cocos-plugin
Version:
> **Compatibility Note:** > create-cocos-plugin dependens on Vite. Vite requires [Node.js](https://nodejs.org/en/) version 18+, 20+. However, some templates require a higher Node.js version to work, please upgrade if your package manager warns about it.
47 lines • 100 kB
JavaScript
import q from"node:fs";import F from"node:path";import{fileURLToPath as qt}from"node:url";import xi from"child_process";import X from"path";import Q from"fs";import Rt from"readline";import Dt from"events";var Si=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function ee(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var W={exports:{}},te,It;function $i(){if(It)return te;It=1,te=r,r.sync=h;var e=Q;function t(p,i){var g=i.pathExt!==void 0?i.pathExt:process.env.PATHEXT;if(!g||(g=g.split(";"),g.indexOf("")!==-1))return!0;for(var l=0;l<g.length;l++){var u=g[l].toLowerCase();if(u&&p.substr(-u.length).toLowerCase()===u)return!0}return!1}function n(p,i,g){return!p.isSymbolicLink()&&!p.isFile()?!1:t(i,g)}function r(p,i,g){e.stat(p,function(l,u){g(l,l?!1:n(u,p,i))})}function h(p,i){return n(e.statSync(p),p,i)}return te}var re,At;function Mi(){if(At)return re;At=1,re=t,t.sync=n;var e=Q;function t(p,i,g){e.stat(p,function(l,u){g(l,l?!1:r(u,i))})}function n(p,i){return r(e.statSync(p),i)}function r(p,i){return p.isFile()&&h(p,i)}function h(p,i){var g=p.mode,l=p.uid,u=p.gid,s=i.uid!==void 0?i.uid:process.getuid&&process.getuid(),d=i.gid!==void 0?i.gid:process.getgid&&process.getgid(),c=parseInt("100",8),o=parseInt("010",8),a=parseInt("001",8),w=c|o,v=g&a||g&o&&u===d||g&c&&l===s||g&w&&s===0;return v}return re}var J;process.platform==="win32"||Si.TESTING_WINDOWS?J=$i():J=Mi();var Oi=ie;ie.sync=Pi;function ie(e,t,n){if(typeof t=="function"&&(n=t,t={}),!n){if(typeof Promise!="function")throw new TypeError("callback not provided");return new Promise(function(r,h){ie(e,t||{},function(p,i){p?h(p):r(i)})})}J(e,t||{},function(r,h){r&&(r.code==="EACCES"||t&&t.ignoreErrors)&&(r=null,h=!1),n(r,h)})}function Pi(e,t){try{return J.sync(e,t||{})}catch(n){if(t&&t.ignoreErrors||n.code==="EACCES")return!1;throw n}}const G=process.platform==="win32"||process.env.OSTYPE==="cygwin"||process.env.OSTYPE==="msys",jt=X,Ti=G?";":":",Ft=Oi,Nt=e=>Object.assign(new Error(`not found: ${e}`),{code:"ENOENT"}),Yt=(e,t)=>{const n=t.colon||Ti,r=e.match(/\//)||G&&e.match(/\\/)?[""]:[...G?[process.cwd()]:[],...(t.path||process.env.PATH||"").split(n)],h=G?t.pathExt||process.env.PATHEXT||".EXE;.CMD;.BAT;.COM":"",p=G?h.split(n):[""];return G&&e.indexOf(".")!==-1&&p[0]!==""&&p.unshift(""),{pathEnv:r,pathExt:p,pathExtExe:h}},Ht=(e,t,n)=>{typeof t=="function"&&(n=t,t={}),t||(t={});const{pathEnv:r,pathExt:h,pathExtExe:p}=Yt(e,t),i=[],g=u=>new Promise((s,d)=>{if(u===r.length)return t.all&&i.length?s(i):d(Nt(e));const c=r[u],o=/^".*"$/.test(c)?c.slice(1,-1):c,a=jt.join(o,e),w=!o&&/^\.[\\\/]/.test(e)?e.slice(0,2)+a:a;s(l(w,u,0))}),l=(u,s,d)=>new Promise((c,o)=>{if(d===h.length)return c(g(s+1));const a=h[d];Ft(u+a,{pathExt:p},(w,v)=>{if(!w&&v)if(t.all)i.push(u+a);else return c(u+a);return c(l(u,s,d+1))})});return n?g(0).then(u=>n(null,u),n):g(0)},Ei=(e,t)=>{t=t||{};const{pathEnv:n,pathExt:r,pathExtExe:h}=Yt(e,t),p=[];for(let i=0;i<n.length;i++){const g=n[i],l=/^".*"$/.test(g)?g.slice(1,-1):g,u=jt.join(l,e),s=!l&&/^\.[\\\/]/.test(e)?e.slice(0,2)+u:u;for(let d=0;d<r.length;d++){const c=s+r[d];try{if(Ft.sync(c,{pathExt:h}))if(t.all)p.push(c);else return c}catch{}}}if(t.all&&p.length)return p;if(t.nothrow)return null;throw Nt(e)};var Ci=Ht;Ht.sync=Ei;var se={exports:{}};const kt=(e={})=>{const t=e.env||process.env;return(e.platform||process.platform)!=="win32"?"PATH":Object.keys(t).reverse().find(r=>r.toUpperCase()==="PATH")||"Path"};se.exports=kt,se.exports.default=kt;var _i=se.exports;const Lt=X,qi=Ci,Ri=_i;function Vt(e,t){const n=e.options.env||process.env,r=process.cwd(),h=e.options.cwd!=null,p=h&&process.chdir!==void 0&&!process.chdir.disabled;if(p)try{process.chdir(e.options.cwd)}catch{}let i;try{i=qi.sync(e.command,{path:n[Ri({env:n})],pathExt:t?Lt.delimiter:void 0})}catch{}finally{p&&process.chdir(r)}return i&&(i=Lt.resolve(h?e.options.cwd:"",i)),i}function Di(e){return Vt(e)||Vt(e,!0)}var Ii=Di,ne={};const oe=/([()\][%!^"`<>&|;, *?])/g;function Ai(e){return e=e.replace(oe,"^$1"),e}function ji(e,t){return e=`${e}`,e=e.replace(/(?=(\\+?)?)\1"/g,'$1$1\\"'),e=e.replace(/(?=(\\+?)?)\1$/,"$1$1"),e=`"${e}"`,e=e.replace(oe,"^$1"),t&&(e=e.replace(oe,"^$1")),e}ne.command=Ai,ne.argument=ji;var Fi=/^#!(.*)/;const Ni=Fi;var Yi=(e="")=>{const t=e.match(Ni);if(!t)return null;const[n,r]=t[0].replace(/#! ?/,"").split(" "),h=n.split("/").pop();return h==="env"?r:r?`${h} ${r}`:h};const le=Q,Hi=Yi;function ki(e){const n=Buffer.alloc(150);let r;try{r=le.openSync(e,"r"),le.readSync(r,n,0,150,0),le.closeSync(r)}catch{}return Hi(n.toString())}var Li=ki;const Vi=X,Bt=Ii,Ut=ne,Bi=Li,Ui=process.platform==="win32",Wi=/\.(?:com|exe)$/i,Gi=/node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;function zi(e){e.file=Bt(e);const t=e.file&&Bi(e.file);return t?(e.args.unshift(e.file),e.command=t,Bt(e)):e.file}function Ji(e){if(!Ui)return e;const t=zi(e),n=!Wi.test(t);if(e.options.forceShell||n){const r=Gi.test(t);e.command=Vi.normalize(e.command),e.command=Ut.command(e.command),e.args=e.args.map(p=>Ut.argument(p,r));const h=[e.command].concat(e.args).join(" ");e.args=["/d","/s","/c",`"${h}"`],e.command=process.env.comspec||"cmd.exe",e.options.windowsVerbatimArguments=!0}return e}function Ki(e,t,n){t&&!Array.isArray(t)&&(n=t,t=null),t=t?t.slice(0):[],n=Object.assign({},n);const r={command:e,args:t,options:n,file:void 0,original:{command:e,args:t}};return n.shell?r:Ji(r)}var Zi=Ki;const he=process.platform==="win32";function ue(e,t){return Object.assign(new Error(`${t} ${e.command} ENOENT`),{code:"ENOENT",errno:"ENOENT",syscall:`${t} ${e.command}`,path:e.command,spawnargs:e.args})}function Xi(e,t){if(!he)return;const n=e.emit;e.emit=function(r,h){if(r==="exit"){const p=Wt(h,t);if(p)return n.call(e,"error",p)}return n.apply(e,arguments)}}function Wt(e,t){return he&&e===1&&!t.file?ue(t.original,"spawn"):null}function Qi(e,t){return he&&e===1&&!t.file?ue(t.original,"spawnSync"):null}var es={hookChildProcess:Xi,verifyENOENT:Wt,verifyENOENTSync:Qi,notFoundError:ue};const Gt=xi,ae=Zi,ce=es;function zt(e,t,n){const r=ae(e,t,n),h=Gt.spawn(r.command,r.args,r.options);return ce.hookChildProcess(h,r),h}function ts(e,t,n){const r=ae(e,t,n),h=Gt.spawnSync(r.command,r.args,r.options);return h.error=h.error||ce.verifyENOENTSync(h.status,r),h}W.exports=zt,W.exports.spawn=zt,W.exports.sync=ts,W.exports._parse=ae,W.exports._enoent=ce;var rs=W.exports;const is=ee(rs);function ss(e,t){var n=e;t.slice(0,-1).forEach(function(h){n=n[h]||{}});var r=t[t.length-1];return r in n}function Jt(e){return typeof e=="number"||/^0x[0-9a-f]+$/i.test(e)?!0:/^[-+]?(?:\d+(?:\.\d*)?|\.\d+)(e[-+]?\d+)?$/.test(e)}function Kt(e,t){return t==="constructor"&&typeof e[t]=="function"||t==="__proto__"}var ns=function(e,t){t||(t={});var n={bools:{},strings:{},unknownFn:null};typeof t.unknown=="function"&&(n.unknownFn=t.unknown),typeof t.boolean=="boolean"&&t.boolean?n.allBools=!0:[].concat(t.boolean).filter(Boolean).forEach(function(y){n.bools[y]=!0});var r={};function h(y){return r[y].some(function(x){return n.bools[x]})}Object.keys(t.alias||{}).forEach(function(y){r[y]=[].concat(t.alias[y]),r[y].forEach(function(x){r[x]=[y].concat(r[y].filter(function(S){return x!==S}))})}),[].concat(t.string).filter(Boolean).forEach(function(y){n.strings[y]=!0,r[y]&&[].concat(r[y]).forEach(function(x){n.strings[x]=!0})});var p=t.default||{},i={_:[]};function g(y,x){return n.allBools&&/^--[^=]+$/.test(x)||n.strings[y]||n.bools[y]||r[y]}function l(y,x,S){for(var $=y,P=0;P<x.length-1;P++){var M=x[P];if(Kt($,M))return;$[M]===void 0&&($[M]={}),($[M]===Object.prototype||$[M]===Number.prototype||$[M]===String.prototype)&&($[M]={}),$[M]===Array.prototype&&($[M]=[]),$=$[M]}var O=x[x.length-1];Kt($,O)||(($===Object.prototype||$===Number.prototype||$===String.prototype)&&($={}),$===Array.prototype&&($=[]),$[O]===void 0||n.bools[O]||typeof $[O]=="boolean"?$[O]=S:Array.isArray($[O])?$[O].push(S):$[O]=[$[O],S])}function u(y,x,S){if(!(S&&n.unknownFn&&!g(y,S)&&n.unknownFn(S)===!1)){var $=!n.strings[y]&&Jt(x)?Number(x):x;l(i,y.split("."),$),(r[y]||[]).forEach(function(P){l(i,P.split("."),$)})}}Object.keys(n.bools).forEach(function(y){u(y,p[y]===void 0?!1:p[y])});var s=[];e.indexOf("--")!==-1&&(s=e.slice(e.indexOf("--")+1),e=e.slice(0,e.indexOf("--")));for(var d=0;d<e.length;d++){var c=e[d],o,a;if(/^--.+=/.test(c)){var w=c.match(/^--([^=]+)=([\s\S]*)$/);o=w[1];var v=w[2];n.bools[o]&&(v=v!=="false"),u(o,v,c)}else if(/^--no-.+/.test(c))o=c.match(/^--no-(.+)/)[1],u(o,!1,c);else if(/^--.+/.test(c))o=c.match(/^--(.+)/)[1],a=e[d+1],a!==void 0&&!/^(-|--)[^-]/.test(a)&&!n.bools[o]&&!n.allBools&&(!r[o]||!h(o))?(u(o,a,c),d+=1):/^(true|false)$/.test(a)?(u(o,a==="true",c),d+=1):u(o,n.strings[o]?"":!0,c);else if(/^-[^-]+/.test(c)){for(var f=c.slice(1,-1).split(""),m=!1,b=0;b<f.length;b++){if(a=c.slice(b+2),a==="-"){u(f[b],a,c);continue}if(/[A-Za-z]/.test(f[b])&&a[0]==="="){u(f[b],a.slice(1),c),m=!0;break}if(/[A-Za-z]/.test(f[b])&&/-?\d+(\.\d*)?(e-?\d+)?$/.test(a)){u(f[b],a,c),m=!0;break}if(f[b+1]&&f[b+1].match(/\W/)){u(f[b],c.slice(b+2),c),m=!0;break}else u(f[b],n.strings[f[b]]?"":!0,c)}o=c.slice(-1)[0],!m&&o!=="-"&&(e[d+1]&&!/^(-|--)[^-]/.test(e[d+1])&&!n.bools[o]&&(!r[o]||!h(o))?(u(o,e[d+1],c),d+=1):e[d+1]&&/^(true|false)$/.test(e[d+1])?(u(o,e[d+1]==="true",c),d+=1):u(o,n.strings[o]?"":!0,c))}else if((!n.unknownFn||n.unknownFn(c)!==!1)&&i._.push(n.strings._||!Jt(c)?c:Number(c)),t.stopEarly){i._.push.apply(i._,e.slice(d+1));break}}return Object.keys(p).forEach(function(y){ss(i,y.split("."))||(l(i,y.split("."),p[y]),(r[y]||[]).forEach(function(x){l(i,x.split("."),p[y])}))}),t["--"]?i["--"]=s.slice():s.forEach(function(y){i._.push(y)}),i};const os=ee(ns);var de={exports:{}};let K=process||{},Zt=K.argv||[],Z=K.env||{},ls=!(Z.NO_COLOR||Zt.includes("--no-color"))&&(!!Z.FORCE_COLOR||Zt.includes("--color")||K.platform==="win32"||(K.stdout||{}).isTTY&&Z.TERM!=="dumb"||!!Z.CI),hs=(e,t,n=e)=>r=>{let h=""+r,p=h.indexOf(t,e.length);return~p?e+us(h,t,n,p)+t:e+h+t},us=(e,t,n,r)=>{let h="",p=0;do h+=e.substring(p,r)+n,p=r+t.length,r=e.indexOf(t,p);while(~r);return h+e.substring(p)},Xt=(e=ls)=>{let t=e?hs:()=>String;return{isColorSupported:e,reset:t("\x1B[0m","\x1B[0m"),bold:t("\x1B[1m","\x1B[22m","\x1B[22m\x1B[1m"),dim:t("\x1B[2m","\x1B[22m","\x1B[22m\x1B[2m"),italic:t("\x1B[3m","\x1B[23m"),underline:t("\x1B[4m","\x1B[24m"),inverse:t("\x1B[7m","\x1B[27m"),hidden:t("\x1B[8m","\x1B[28m"),strikethrough:t("\x1B[9m","\x1B[29m"),black:t("\x1B[30m","\x1B[39m"),red:t("\x1B[31m","\x1B[39m"),green:t("\x1B[32m","\x1B[39m"),yellow:t("\x1B[33m","\x1B[39m"),blue:t("\x1B[34m","\x1B[39m"),magenta:t("\x1B[35m","\x1B[39m"),cyan:t("\x1B[36m","\x1B[39m"),white:t("\x1B[37m","\x1B[39m"),gray:t("\x1B[90m","\x1B[39m"),bgBlack:t("\x1B[40m","\x1B[49m"),bgRed:t("\x1B[41m","\x1B[49m"),bgGreen:t("\x1B[42m","\x1B[49m"),bgYellow:t("\x1B[43m","\x1B[49m"),bgBlue:t("\x1B[44m","\x1B[49m"),bgMagenta:t("\x1B[45m","\x1B[49m"),bgCyan:t("\x1B[46m","\x1B[49m"),bgWhite:t("\x1B[47m","\x1B[49m"),blackBright:t("\x1B[90m","\x1B[39m"),redBright:t("\x1B[91m","\x1B[39m"),greenBright:t("\x1B[92m","\x1B[39m"),yellowBright:t("\x1B[93m","\x1B[39m"),blueBright:t("\x1B[94m","\x1B[39m"),magentaBright:t("\x1B[95m","\x1B[39m"),cyanBright:t("\x1B[96m","\x1B[39m"),whiteBright:t("\x1B[97m","\x1B[39m"),bgBlackBright:t("\x1B[100m","\x1B[49m"),bgRedBright:t("\x1B[101m","\x1B[49m"),bgGreenBright:t("\x1B[102m","\x1B[49m"),bgYellowBright:t("\x1B[103m","\x1B[49m"),bgBlueBright:t("\x1B[104m","\x1B[49m"),bgMagentaBright:t("\x1B[105m","\x1B[49m"),bgCyanBright:t("\x1B[106m","\x1B[49m"),bgWhiteBright:t("\x1B[107m","\x1B[49m")}};de.exports=Xt(),de.exports.createColors=Xt;var A=de.exports,fe={},pe,Qt;function E(){if(Qt)return pe;Qt=1;const{FORCE_COLOR:e,NODE_DISABLE_COLORS:t,TERM:n}=process.env,r={enabled:!t&&n!=="dumb"&&e!=="0",reset:i(0,0),bold:i(1,22),dim:i(2,22),italic:i(3,23),underline:i(4,24),inverse:i(7,27),hidden:i(8,28),strikethrough:i(9,29),black:i(30,39),red:i(31,39),green:i(32,39),yellow:i(33,39),blue:i(34,39),magenta:i(35,39),cyan:i(36,39),white:i(37,39),gray:i(90,39),grey:i(90,39),bgBlack:i(40,49),bgRed:i(41,49),bgGreen:i(42,49),bgYellow:i(43,49),bgBlue:i(44,49),bgMagenta:i(45,49),bgCyan:i(46,49),bgWhite:i(47,49)};function h(g,l){let u=0,s,d="",c="";for(;u<g.length;u++)s=g[u],d+=s.open,c+=s.close,l.includes(s.close)&&(l=l.replace(s.rgx,s.close+s.open));return d+l+c}function p(g,l){let u={has:g,keys:l};return u.reset=r.reset.bind(u),u.bold=r.bold.bind(u),u.dim=r.dim.bind(u),u.italic=r.italic.bind(u),u.underline=r.underline.bind(u),u.inverse=r.inverse.bind(u),u.hidden=r.hidden.bind(u),u.strikethrough=r.strikethrough.bind(u),u.black=r.black.bind(u),u.red=r.red.bind(u),u.green=r.green.bind(u),u.yellow=r.yellow.bind(u),u.blue=r.blue.bind(u),u.magenta=r.magenta.bind(u),u.cyan=r.cyan.bind(u),u.white=r.white.bind(u),u.gray=r.gray.bind(u),u.grey=r.grey.bind(u),u.bgBlack=r.bgBlack.bind(u),u.bgRed=r.bgRed.bind(u),u.bgGreen=r.bgGreen.bind(u),u.bgYellow=r.bgYellow.bind(u),u.bgBlue=r.bgBlue.bind(u),u.bgMagenta=r.bgMagenta.bind(u),u.bgCyan=r.bgCyan.bind(u),u.bgWhite=r.bgWhite.bind(u),u}function i(g,l){let u={open:`\x1B[${g}m`,close:`\x1B[${l}m`,rgx:new RegExp(`\\x1b\\[${l}m`,"g")};return function(s){return this!==void 0&&this.has!==void 0?(this.has.includes(g)||(this.has.push(g),this.keys.push(u)),s===void 0?this:r.enabled?h(this.keys,s+""):s+""):s===void 0?p([g],[u]):r.enabled?h([u],s+""):s+""}}return pe=r,pe}var me,er;function as(){return er||(er=1,me=(e,t)=>{if(!(e.meta&&e.name!=="escape")){if(e.ctrl){if(e.name==="a")return"first";if(e.name==="c"||e.name==="d")return"abort";if(e.name==="e")return"last";if(e.name==="g")return"reset"}if(t){if(e.name==="j")return"down";if(e.name==="k")return"up"}return e.name==="return"||e.name==="enter"?"submit":e.name==="backspace"?"delete":e.name==="delete"?"deleteForward":e.name==="abort"?"abort":e.name==="escape"?"exit":e.name==="tab"?"next":e.name==="pagedown"?"nextPage":e.name==="pageup"?"prevPage":e.name==="home"?"home":e.name==="end"?"end":e.name==="up"?"up":e.name==="down"?"down":e.name==="right"?"right":e.name==="left"?"left":!1}}),me}var ge,tr;function ve(){return tr||(tr=1,ge=e=>{const t=["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PRZcf-ntqry=><~]))"].join("|"),n=new RegExp(t,"g");return typeof e=="string"?e.replace(n,""):e}),ge}var be,rr;function C(){if(rr)return be;rr=1;const e="\x1B",t=`${e}[`,n="\x07",r={to(i,g){return g?`${t}${g+1};${i+1}H`:`${t}${i+1}G`},move(i,g){let l="";return i<0?l+=`${t}${-i}D`:i>0&&(l+=`${t}${i}C`),g<0?l+=`${t}${-g}A`:g>0&&(l+=`${t}${g}B`),l},up:(i=1)=>`${t}${i}A`,down:(i=1)=>`${t}${i}B`,forward:(i=1)=>`${t}${i}C`,backward:(i=1)=>`${t}${i}D`,nextLine:(i=1)=>`${t}E`.repeat(i),prevLine:(i=1)=>`${t}F`.repeat(i),left:`${t}G`,hide:`${t}?25l`,show:`${t}?25h`,save:`${e}7`,restore:`${e}8`},h={up:(i=1)=>`${t}S`.repeat(i),down:(i=1)=>`${t}T`.repeat(i)},p={screen:`${t}2J`,up:(i=1)=>`${t}1J`.repeat(i),down:(i=1)=>`${t}J`.repeat(i),line:`${t}2K`,lineEnd:`${t}K`,lineStart:`${t}1K`,lines(i){let g="";for(let l=0;l<i;l++)g+=this.line+(l<i-1?r.up():"");return i&&(g+=r.left),g}};return be={cursor:r,scroll:h,erase:p,beep:n},be}var we,ir;function cs(){if(ir)return we;ir=1;function e(l,u){var s=typeof Symbol<"u"&&l[Symbol.iterator]||l["@@iterator"];if(!s){if(Array.isArray(l)||(s=t(l))||u&&l&&typeof l.length=="number"){s&&(l=s);var d=0,c=function(){};return{s:c,n:function(){return d>=l.length?{done:!0}:{done:!1,value:l[d++]}},e:function(f){throw f},f:c}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var o=!0,a=!1,w;return{s:function(){s=s.call(l)},n:function(){var f=s.next();return o=f.done,f},e:function(f){a=!0,w=f},f:function(){try{!o&&s.return!=null&&s.return()}finally{if(a)throw w}}}}function t(l,u){if(l){if(typeof l=="string")return n(l,u);var s=Object.prototype.toString.call(l).slice(8,-1);if(s==="Object"&&l.constructor&&(s=l.constructor.name),s==="Map"||s==="Set")return Array.from(l);if(s==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(s))return n(l,u)}}function n(l,u){(u==null||u>l.length)&&(u=l.length);for(var s=0,d=new Array(u);s<u;s++)d[s]=l[s];return d}const r=ve(),h=C(),p=h.erase,i=h.cursor,g=l=>[...r(l)].length;return we=function(l,u){if(!u)return p.line+i.to(0);let s=0;const d=l.split(/\r?\n/);var c=e(d),o;try{for(c.s();!(o=c.n()).done;){let a=o.value;s+=1+Math.floor(Math.max(g(a)-1,0)/u)}}catch(a){c.e(a)}finally{c.f()}return p.lines(s)},we}var ye,sr;function nr(){if(sr)return ye;sr=1;const e={arrowUp:"\u2191",arrowDown:"\u2193",arrowLeft:"\u2190",arrowRight:"\u2192",radioOn:"\u25C9",radioOff:"\u25EF",tick:"\u2714",cross:"\u2716",ellipsis:"\u2026",pointerSmall:"\u203A",line:"\u2500",pointer:"\u276F"},t={arrowUp:e.arrowUp,arrowDown:e.arrowDown,arrowLeft:e.arrowLeft,arrowRight:e.arrowRight,radioOn:"(*)",radioOff:"( )",tick:"\u221A",cross:"\xD7",ellipsis:"...",pointerSmall:"\xBB",line:"\u2500",pointer:">"};return ye=process.platform==="win32"?t:e,ye}var xe,or;function ds(){if(or)return xe;or=1;const e=E(),t=nr(),n=Object.freeze({password:{scale:1,render:l=>"*".repeat(l.length)},emoji:{scale:2,render:l=>"\u{1F603}".repeat(l.length)},invisible:{scale:0,render:l=>""},default:{scale:1,render:l=>`${l}`}}),r=l=>n[l]||n.default,h=Object.freeze({aborted:e.red(t.cross),done:e.green(t.tick),exited:e.yellow(t.cross),default:e.cyan("?")});return xe={styles:n,render:r,symbols:h,symbol:(l,u,s)=>u?h.aborted:s?h.exited:l?h.done:h.default,delimiter:l=>e.gray(l?t.ellipsis:t.pointerSmall),item:(l,u)=>e.gray(l?u?t.pointerSmall:"+":t.line)},xe}var Se,lr;function fs(){if(lr)return Se;lr=1;const e=ve();return Se=function(t,n){let r=String(e(t)||"").split(/\r?\n/);return n?r.map(h=>Math.ceil(h.length/n)).reduce((h,p)=>h+p):r.length},Se}var $e,hr;function ps(){return hr||(hr=1,$e=(e,t={})=>{const n=Number.isSafeInteger(parseInt(t.margin))?new Array(parseInt(t.margin)).fill(" ").join(""):t.margin||"",r=t.width;return(e||"").split(/\r?\n/g).map(h=>h.split(/\s+/g).reduce((p,i)=>(i.length+n.length>=r||p[p.length-1].length+i.length+1<r?p[p.length-1]+=` ${i}`:p.push(`${n}${i}`),p),[n]).join(`
`)).join(`
`)}),$e}var Me,ur;function ms(){return ur||(ur=1,Me=(e,t,n)=>{n=n||t;let r=Math.min(t-n,e-Math.floor(n/2));r<0&&(r=0);let h=Math.min(r+n,t);return{startIndex:r,endIndex:h}}),Me}var Oe,ar;function Y(){return ar||(ar=1,Oe={action:as(),clear:cs(),style:ds(),strip:ve(),figures:nr(),lines:fs(),wrap:ps(),entriesToDisplay:ms()}),Oe}var Pe,cr;function V(){if(cr)return Pe;cr=1;const e=Rt,t=Y(),n=t.action,r=Dt,h=C(),p=h.beep,i=h.cursor,g=E();class l extends r{constructor(s={}){super(),this.firstRender=!0,this.in=s.stdin||process.stdin,this.out=s.stdout||process.stdout,this.onRender=(s.onRender||(()=>{})).bind(this);const d=e.createInterface({input:this.in,escapeCodeTimeout:50});e.emitKeypressEvents(this.in,d),this.in.isTTY&&this.in.setRawMode(!0);const c=["SelectPrompt","MultiselectPrompt"].indexOf(this.constructor.name)>-1,o=(a,w)=>{let v=n(w,c);v===!1?this._&&this._(a,w):typeof this[v]=="function"?this[v](w):this.bell()};this.close=()=>{this.out.write(i.show),this.in.removeListener("keypress",o),this.in.isTTY&&this.in.setRawMode(!1),d.close(),this.emit(this.aborted?"abort":this.exited?"exit":"submit",this.value),this.closed=!0},this.in.on("keypress",o)}fire(){this.emit("state",{value:this.value,aborted:!!this.aborted,exited:!!this.exited})}bell(){this.out.write(p)}render(){this.onRender(g),this.firstRender&&(this.firstRender=!1)}}return Pe=l,Pe}var Te,dr;function gs(){if(dr)return Te;dr=1;function e(o,a,w,v,f,m,b){try{var y=o[m](b),x=y.value}catch(S){w(S);return}y.done?a(x):Promise.resolve(x).then(v,f)}function t(o){return function(){var a=this,w=arguments;return new Promise(function(v,f){var m=o.apply(a,w);function b(x){e(m,v,f,b,y,"next",x)}function y(x){e(m,v,f,b,y,"throw",x)}b(void 0)})}}const n=E(),r=V(),h=C(),p=h.erase,i=h.cursor,g=Y(),l=g.style,u=g.clear,s=g.lines,d=g.figures;class c extends r{constructor(a={}){super(a),this.transform=l.render(a.style),this.scale=this.transform.scale,this.msg=a.message,this.initial=a.initial||"",this.validator=a.validate||(()=>!0),this.value="",this.errorMsg=a.error||"Please Enter A Valid Value",this.cursor=+!!this.initial,this.cursorOffset=0,this.clear=u("",this.out.columns),this.render()}set value(a){!a&&this.initial?(this.placeholder=!0,this.rendered=n.gray(this.transform.render(this.initial))):(this.placeholder=!1,this.rendered=this.transform.render(a)),this._value=a,this.fire()}get value(){return this._value}reset(){this.value="",this.cursor=+!!this.initial,this.cursorOffset=0,this.fire(),this.render()}exit(){this.abort()}abort(){this.value=this.value||this.initial,this.done=this.aborted=!0,this.error=!1,this.red=!1,this.fire(),this.render(),this.out.write(`
`),this.close()}validate(){var a=this;return t(function*(){let w=yield a.validator(a.value);typeof w=="string"&&(a.errorMsg=w,w=!1),a.error=!w})()}submit(){var a=this;return t(function*(){if(a.value=a.value||a.initial,a.cursorOffset=0,a.cursor=a.rendered.length,yield a.validate(),a.error){a.red=!0,a.fire(),a.render();return}a.done=!0,a.aborted=!1,a.fire(),a.render(),a.out.write(`
`),a.close()})()}next(){if(!this.placeholder)return this.bell();this.value=this.initial,this.cursor=this.rendered.length,this.fire(),this.render()}moveCursor(a){this.placeholder||(this.cursor=this.cursor+a,this.cursorOffset+=a)}_(a,w){let v=this.value.slice(0,this.cursor),f=this.value.slice(this.cursor);this.value=`${v}${a}${f}`,this.red=!1,this.cursor=this.placeholder?0:v.length+1,this.render()}delete(){if(this.isCursorAtStart())return this.bell();let a=this.value.slice(0,this.cursor-1),w=this.value.slice(this.cursor);this.value=`${a}${w}`,this.red=!1,this.isCursorAtStart()?this.cursorOffset=0:(this.cursorOffset++,this.moveCursor(-1)),this.render()}deleteForward(){if(this.cursor*this.scale>=this.rendered.length||this.placeholder)return this.bell();let a=this.value.slice(0,this.cursor),w=this.value.slice(this.cursor+1);this.value=`${a}${w}`,this.red=!1,this.isCursorAtEnd()?this.cursorOffset=0:this.cursorOffset++,this.render()}first(){this.cursor=0,this.render()}last(){this.cursor=this.value.length,this.render()}left(){if(this.cursor<=0||this.placeholder)return this.bell();this.moveCursor(-1),this.render()}right(){if(this.cursor*this.scale>=this.rendered.length||this.placeholder)return this.bell();this.moveCursor(1),this.render()}isCursorAtStart(){return this.cursor===0||this.placeholder&&this.cursor===1}isCursorAtEnd(){return this.cursor===this.rendered.length||this.placeholder&&this.cursor===this.rendered.length+1}render(){this.closed||(this.firstRender||(this.outputError&&this.out.write(i.down(s(this.outputError,this.out.columns)-1)+u(this.outputError,this.out.columns)),this.out.write(u(this.outputText,this.out.columns))),super.render(),this.outputError="",this.outputText=[l.symbol(this.done,this.aborted),n.bold(this.msg),l.delimiter(this.done),this.red?n.red(this.rendered):this.rendered].join(" "),this.error&&(this.outputError+=this.errorMsg.split(`
`).reduce((a,w,v)=>a+`
${v?" ":d.pointerSmall} ${n.red().italic(w)}`,"")),this.out.write(p.line+i.to(0)+this.outputText+i.save+this.outputError+i.restore+i.move(this.cursorOffset,0)))}}return Te=c,Te}var Ee,fr;function vs(){if(fr)return Ee;fr=1;const e=E(),t=V(),n=Y(),r=n.style,h=n.clear,p=n.figures,i=n.wrap,g=n.entriesToDisplay,l=C(),u=l.cursor;class s extends t{constructor(c={}){super(c),this.msg=c.message,this.hint=c.hint||"- Use arrow-keys. Return to submit.",this.warn=c.warn||"- This option is disabled",this.cursor=c.initial||0,this.choices=c.choices.map((o,a)=>(typeof o=="string"&&(o={title:o,value:a}),{title:o&&(o.title||o.value||o),value:o&&(o.value===void 0?a:o.value),description:o&&o.description,selected:o&&o.selected,disabled:o&&o.disabled})),this.optionsPerPage=c.optionsPerPage||10,this.value=(this.choices[this.cursor]||{}).value,this.clear=h("",this.out.columns),this.render()}moveCursor(c){this.cursor=c,this.value=this.choices[c].value,this.fire()}reset(){this.moveCursor(0),this.fire(),this.render()}exit(){this.abort()}abort(){this.done=this.aborted=!0,this.fire(),this.render(),this.out.write(`
`),this.close()}submit(){this.selection.disabled?this.bell():(this.done=!0,this.aborted=!1,this.fire(),this.render(),this.out.write(`
`),this.close())}first(){this.moveCursor(0),this.render()}last(){this.moveCursor(this.choices.length-1),this.render()}up(){this.cursor===0?this.moveCursor(this.choices.length-1):this.moveCursor(this.cursor-1),this.render()}down(){this.cursor===this.choices.length-1?this.moveCursor(0):this.moveCursor(this.cursor+1),this.render()}next(){this.moveCursor((this.cursor+1)%this.choices.length),this.render()}_(c,o){if(c===" ")return this.submit()}get selection(){return this.choices[this.cursor]}render(){if(this.closed)return;this.firstRender?this.out.write(u.hide):this.out.write(h(this.outputText,this.out.columns)),super.render();let c=g(this.cursor,this.choices.length,this.optionsPerPage),o=c.startIndex,a=c.endIndex;if(this.outputText=[r.symbol(this.done,this.aborted),e.bold(this.msg),r.delimiter(!1),this.done?this.selection.title:this.selection.disabled?e.yellow(this.warn):e.gray(this.hint)].join(" "),!this.done){this.outputText+=`
`;for(let w=o;w<a;w++){let v,f,m="",b=this.choices[w];w===o&&o>0?f=p.arrowUp:w===a-1&&a<this.choices.length?f=p.arrowDown:f=" ",b.disabled?(v=this.cursor===w?e.gray().underline(b.title):e.strikethrough().gray(b.title),f=(this.cursor===w?e.bold().gray(p.pointer)+" ":" ")+f):(v=this.cursor===w?e.cyan().underline(b.title):b.title,f=(this.cursor===w?e.cyan(p.pointer)+" ":" ")+f,b.description&&this.cursor===w&&(m=` - ${b.description}`,(f.length+v.length+m.length>=this.out.columns||b.description.split(/\r?\n/).length>1)&&(m=`
`+i(b.description,{margin:3,width:this.out.columns})))),this.outputText+=`${f} ${v}${e.gray(m)}
`}}this.out.write(this.outputText)}}return Ee=s,Ee}var Ce,pr;function bs(){if(pr)return Ce;pr=1;const e=E(),t=V(),n=Y(),r=n.style,h=n.clear,p=C(),i=p.cursor,g=p.erase;class l extends t{constructor(s={}){super(s),this.msg=s.message,this.value=!!s.initial,this.active=s.active||"on",this.inactive=s.inactive||"off",this.initialValue=this.value,this.render()}reset(){this.value=this.initialValue,this.fire(),this.render()}exit(){this.abort()}abort(){this.done=this.aborted=!0,this.fire(),this.render(),this.out.write(`
`),this.close()}submit(){this.done=!0,this.aborted=!1,this.fire(),this.render(),this.out.write(`
`),this.close()}deactivate(){if(this.value===!1)return this.bell();this.value=!1,this.render()}activate(){if(this.value===!0)return this.bell();this.value=!0,this.render()}delete(){this.deactivate()}left(){this.deactivate()}right(){this.activate()}down(){this.deactivate()}up(){this.activate()}next(){this.value=!this.value,this.fire(),this.render()}_(s,d){if(s===" ")this.value=!this.value;else if(s==="1")this.value=!0;else if(s==="0")this.value=!1;else return this.bell();this.render()}render(){this.closed||(this.firstRender?this.out.write(i.hide):this.out.write(h(this.outputText,this.out.columns)),super.render(),this.outputText=[r.symbol(this.done,this.aborted),e.bold(this.msg),r.delimiter(this.done),this.value?this.inactive:e.cyan().underline(this.inactive),e.gray("/"),this.value?e.cyan().underline(this.active):this.active].join(" "),this.out.write(g.line+i.to(0)+this.outputText))}}return Ce=l,Ce}var _e,mr;function k(){if(mr)return _e;mr=1;class e{constructor({token:n,date:r,parts:h,locales:p}){this.token=n,this.date=r||new Date,this.parts=h||[this],this.locales=p||{}}up(){}down(){}next(){const n=this.parts.indexOf(this);return this.parts.find((r,h)=>h>n&&r instanceof e)}setTo(n){}prev(){let n=[].concat(this.parts).reverse();const r=n.indexOf(this);return n.find((h,p)=>p>r&&h instanceof e)}toString(){return String(this.date)}}return _e=e,_e}var qe,gr;function ws(){if(gr)return qe;gr=1;const e=k();class t extends e{constructor(r={}){super(r)}up(){this.date.setHours((this.date.getHours()+12)%24)}down(){this.up()}toString(){let r=this.date.getHours()>12?"pm":"am";return/\A/.test(this.token)?r.toUpperCase():r}}return qe=t,qe}var Re,vr;function ys(){if(vr)return Re;vr=1;const e=k(),t=r=>(r=r%10,r===1?"st":r===2?"nd":r===3?"rd":"th");class n extends e{constructor(h={}){super(h)}up(){this.date.setDate(this.date.getDate()+1)}down(){this.date.setDate(this.date.getDate()-1)}setTo(h){this.date.setDate(parseInt(h.substr(-2)))}toString(){let h=this.date.getDate(),p=this.date.getDay();return this.token==="DD"?String(h).padStart(2,"0"):this.token==="Do"?h+t(h):this.token==="d"?p+1:this.token==="ddd"?this.locales.weekdaysShort[p]:this.token==="dddd"?this.locales.weekdays[p]:h}}return Re=n,Re}var De,br;function xs(){if(br)return De;br=1;const e=k();class t extends e{constructor(r={}){super(r)}up(){this.date.setHours(this.date.getHours()+1)}down(){this.date.setHours(this.date.getHours()-1)}setTo(r){this.date.setHours(parseInt(r.substr(-2)))}toString(){let r=this.date.getHours();return/h/.test(this.token)&&(r=r%12||12),this.token.length>1?String(r).padStart(2,"0"):r}}return De=t,De}var Ie,wr;function Ss(){if(wr)return Ie;wr=1;const e=k();class t extends e{constructor(r={}){super(r)}up(){this.date.setMilliseconds(this.date.getMilliseconds()+1)}down(){this.date.setMilliseconds(this.date.getMilliseconds()-1)}setTo(r){this.date.setMilliseconds(parseInt(r.substr(-this.token.length)))}toString(){return String(this.date.getMilliseconds()).padStart(4,"0").substr(0,this.token.length)}}return Ie=t,Ie}var Ae,yr;function $s(){if(yr)return Ae;yr=1;const e=k();class t extends e{constructor(r={}){super(r)}up(){this.date.setMinutes(this.date.getMinutes()+1)}down(){this.date.setMinutes(this.date.getMinutes()-1)}setTo(r){this.date.setMinutes(parseInt(r.substr(-2)))}toString(){let r=this.date.getMinutes();return this.token.length>1?String(r).padStart(2,"0"):r}}return Ae=t,Ae}var je,xr;function Ms(){if(xr)return je;xr=1;const e=k();class t extends e{constructor(r={}){super(r)}up(){this.date.setMonth(this.date.getMonth()+1)}down(){this.date.setMonth(this.date.getMonth()-1)}setTo(r){r=parseInt(r.substr(-2))-1,this.date.setMonth(r<0?0:r)}toString(){let r=this.date.getMonth(),h=this.token.length;return h===2?String(r+1).padStart(2,"0"):h===3?this.locales.monthsShort[r]:h===4?this.locales.months[r]:String(r+1)}}return je=t,je}var Fe,Sr;function Os(){if(Sr)return Fe;Sr=1;const e=k();class t extends e{constructor(r={}){super(r)}up(){this.date.setSeconds(this.date.getSeconds()+1)}down(){this.date.setSeconds(this.date.getSeconds()-1)}setTo(r){this.date.setSeconds(parseInt(r.substr(-2)))}toString(){let r=this.date.getSeconds();return this.token.length>1?String(r).padStart(2,"0"):r}}return Fe=t,Fe}var Ne,$r;function Ps(){if($r)return Ne;$r=1;const e=k();class t extends e{constructor(r={}){super(r)}up(){this.date.setFullYear(this.date.getFullYear()+1)}down(){this.date.setFullYear(this.date.getFullYear()-1)}setTo(r){this.date.setFullYear(r.substr(-4))}toString(){let r=String(this.date.getFullYear()).padStart(4,"0");return this.token.length===2?r.substr(-2):r}}return Ne=t,Ne}var Ye,Mr;function Ts(){return Mr||(Mr=1,Ye={DatePart:k(),Meridiem:ws(),Day:ys(),Hours:xs(),Milliseconds:Ss(),Minutes:$s(),Month:Ms(),Seconds:Os(),Year:Ps()}),Ye}var He,Or;function Es(){if(Or)return He;Or=1;function e(M,O,T,I,_,R,N){try{var j=M[R](N),D=j.value}catch(U){T(U);return}j.done?O(D):Promise.resolve(D).then(I,_)}function t(M){return function(){var O=this,T=arguments;return new Promise(function(I,_){var R=M.apply(O,T);function N(D){e(R,I,_,N,j,"next",D)}function j(D){e(R,I,_,N,j,"throw",D)}N(void 0)})}}const n=E(),r=V(),h=Y(),p=h.style,i=h.clear,g=h.figures,l=C(),u=l.erase,s=l.cursor,d=Ts(),c=d.DatePart,o=d.Meridiem,a=d.Day,w=d.Hours,v=d.Milliseconds,f=d.Minutes,m=d.Month,b=d.Seconds,y=d.Year,x=/\\(.)|"((?:\\["\\]|[^"])+)"|(D[Do]?|d{3,4}|d)|(M{1,4})|(YY(?:YY)?)|([aA])|([Hh]{1,2})|(m{1,2})|(s{1,2})|(S{1,4})|./g,S={1:({token:M})=>M.replace(/\\(.)/g,"$1"),2:M=>new a(M),3:M=>new m(M),4:M=>new y(M),5:M=>new o(M),6:M=>new w(M),7:M=>new f(M),8:M=>new b(M),9:M=>new v(M)},$={months:"January,February,March,April,May,June,July,August,September,October,November,December".split(","),monthsShort:"Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec".split(","),weekdays:"Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday".split(","),weekdaysShort:"Sun,Mon,Tue,Wed,Thu,Fri,Sat".split(",")};class P extends r{constructor(O={}){super(O),this.msg=O.message,this.cursor=0,this.typed="",this.locales=Object.assign($,O.locales),this._date=O.initial||new Date,this.errorMsg=O.error||"Please Enter A Valid Value",this.validator=O.validate||(()=>!0),this.mask=O.mask||"YYYY-MM-DD HH:mm:ss",this.clear=i("",this.out.columns),this.render()}get value(){return this.date}get date(){return this._date}set date(O){O&&this._date.setTime(O.getTime())}set mask(O){let T;for(this.parts=[];T=x.exec(O);){let _=T.shift(),R=T.findIndex(N=>N!=null);this.parts.push(R in S?S[R]({token:T[R]||_,date:this.date,parts:this.parts,locales:this.locales}):T[R]||_)}let I=this.parts.reduce((_,R)=>(typeof R=="string"&&typeof _[_.length-1]=="string"?_[_.length-1]+=R:_.push(R),_),[]);this.parts.splice(0),this.parts.push(...I),this.reset()}moveCursor(O){this.typed="",this.cursor=O,this.fire()}reset(){this.moveCursor(this.parts.findIndex(O=>O instanceof c)),this.fire(),this.render()}exit(){this.abort()}abort(){this.done=this.aborted=!0,this.error=!1,this.fire(),this.render(),this.out.write(`
`),this.close()}validate(){var O=this;return t(function*(){let T=yield O.validator(O.value);typeof T=="string"&&(O.errorMsg=T,T=!1),O.error=!T})()}submit(){var O=this;return t(function*(){if(yield O.validate(),O.error){O.color="red",O.fire(),O.render();return}O.done=!0,O.aborted=!1,O.fire(),O.render(),O.out.write(`
`),O.close()})()}up(){this.typed="",this.parts[this.cursor].up(),this.render()}down(){this.typed="",this.parts[this.cursor].down(),this.render()}left(){let O=this.parts[this.cursor].prev();if(O==null)return this.bell();this.moveCursor(this.parts.indexOf(O)),this.render()}right(){let O=this.parts[this.cursor].next();if(O==null)return this.bell();this.moveCursor(this.parts.indexOf(O)),this.render()}next(){let O=this.parts[this.cursor].next();this.moveCursor(O?this.parts.indexOf(O):this.parts.findIndex(T=>T instanceof c)),this.render()}_(O){/\d/.test(O)&&(this.typed+=O,this.parts[this.cursor].setTo(this.typed),this.render())}render(){this.closed||(this.firstRender?this.out.write(s.hide):this.out.write(i(this.outputText,this.out.columns)),super.render(),this.outputText=[p.symbol(this.done,this.aborted),n.bold(this.msg),p.delimiter(!1),this.parts.reduce((O,T,I)=>O.concat(I===this.cursor&&!this.done?n.cyan().underline(T.toString()):T),[]).join("")].join(" "),this.error&&(this.outputText+=this.errorMsg.split(`
`).reduce((O,T,I)=>O+`
${I?" ":g.pointerSmall} ${n.red().italic(T)}`,"")),this.out.write(u.line+s.to(0)+this.outputText))}}return He=P,He}var ke,Pr;function Cs(){if(Pr)return ke;Pr=1;function e(v,f,m,b,y,x,S){try{var $=v[x](S),P=$.value}catch(M){m(M);return}$.done?f(P):Promise.resolve(P).then(b,y)}function t(v){return function(){var f=this,m=arguments;return new Promise(function(b,y){var x=v.apply(f,m);function S(P){e(x,b,y,S,$,"next",P)}function $(P){e(x,b,y,S,$,"throw",P)}S(void 0)})}}const n=E(),r=V(),h=C(),p=h.cursor,i=h.erase,g=Y(),l=g.style,u=g.figures,s=g.clear,d=g.lines,c=/[0-9]/,o=v=>v!==void 0,a=(v,f)=>{let m=Math.pow(10,f);return Math.round(v*m)/m};class w extends r{constructor(f={}){super(f),this.transform=l.render(f.style),this.msg=f.message,this.initial=o(f.initial)?f.initial:"",this.float=!!f.float,this.round=f.round||2,this.inc=f.increment||1,this.min=o(f.min)?f.min:-1/0,this.max=o(f.max)?f.max:1/0,this.errorMsg=f.error||"Please Enter A Valid Value",this.validator=f.validate||(()=>!0),this.color="cyan",this.value="",this.typed="",this.lastHit=0,this.render()}set value(f){!f&&f!==0?(this.placeholder=!0,this.rendered=n.gray(this.transform.render(`${this.initial}`)),this._value=""):(this.placeholder=!1,this.rendered=this.transform.render(`${a(f,this.round)}`),this._value=a(f,this.round)),this.fire()}get value(){return this._value}parse(f){return this.float?parseFloat(f):parseInt(f)}valid(f){return f==="-"||f==="."&&this.float||c.test(f)}reset(){this.typed="",this.value="",this.fire(),this.render()}exit(){this.abort()}abort(){let f=this.value;this.value=f!==""?f:this.initial,this.done=this.aborted=!0,this.error=!1,this.fire(),this.render(),this.out.write(`
`),this.close()}validate(){var f=this;return t(function*(){let m=yield f.validator(f.value);typeof m=="string"&&(f.errorMsg=m,m=!1),f.error=!m})()}submit(){var f=this;return t(function*(){if(yield f.validate(),f.error){f.color="red",f.fire(),f.render();return}let m=f.value;f.value=m!==""?m:f.initial,f.done=!0,f.aborted=!1,f.error=!1,f.fire(),f.render(),f.out.write(`
`),f.close()})()}up(){if(this.typed="",this.value===""&&(this.value=this.min-this.inc),this.value>=this.max)return this.bell();this.value+=this.inc,this.color="cyan",this.fire(),this.render()}down(){if(this.typed="",this.value===""&&(this.value=this.min+this.inc),this.value<=this.min)return this.bell();this.value-=this.inc,this.color="cyan",this.fire(),this.render()}delete(){let f=this.value.toString();if(f.length===0)return this.bell();this.value=this.parse(f=f.slice(0,-1))||"",this.value!==""&&this.value<this.min&&(this.value=this.min),this.color="cyan",this.fire(),this.render()}next(){this.value=this.initial,this.fire(),this.render()}_(f,m){if(!this.valid(f))return this.bell();const b=Date.now();if(b-this.lastHit>1e3&&(this.typed=""),this.typed+=f,this.lastHit=b,this.color="cyan",f===".")return this.fire();this.value=Math.min(this.parse(this.typed),this.max),this.value>this.max&&(this.value=this.max),this.value<this.min&&(this.value=this.min),this.fire(),this.render()}render(){this.closed||(this.firstRender||(this.outputError&&this.out.write(p.down(d(this.outputError,this.out.columns)-1)+s(this.outputError,this.out.columns)),this.out.write(s(this.outputText,this.out.columns))),super.render(),this.outputError="",this.outputText=[l.symbol(this.done,this.aborted),n.bold(this.msg),l.delimiter(this.done),!this.done||!this.done&&!this.placeholder?n[this.color]().underline(this.rendered):this.rendered].join(" "),this.error&&(this.outputError+=this.errorMsg.split(`
`).reduce((f,m,b)=>f+`
${b?" ":u.pointerSmall} ${n.red().italic(m)}`,"")),this.out.write(i.line+p.to(0)+this.outputText+p.save+this.outputError+p.restore))}}return ke=w,ke}var Le,Tr;function Er(){if(Tr)return Le;Tr=1;const e=E(),t=C(),n=t.cursor,r=V(),h=Y(),p=h.clear,i=h.figures,g=h.style,l=h.wrap,u=h.entriesToDisplay;class s extends r{constructor(c={}){super(c),this.msg=c.message,this.cursor=c.cursor||0,this.scrollIndex=c.cursor||0,this.hint=c.hint||"",this.warn=c.warn||"- This option is disabled -",this.minSelected=c.min,this.showMinError=!1,this.maxChoices=c.max,this.instructions=c.instructions,this.optionsPerPage=c.optionsPerPage||10,this.value=c.choices.map((o,a)=>(typeof o=="string"&&(o={title:o,value:a}),{title:o&&(o.title||o.value||o),description:o&&o.description,value:o&&(o.value===void 0?a:o.value),selected:o&&o.selected,disabled:o&&o.disabled})),this.clear=p("",this.out.columns),c.overrideRender||this.render()}reset(){this.value.map(c=>!c.selected),this.cursor=0,this.fire(),this.render()}selected(){return this.value.filter(c=>c.selected)}exit(){this.abort()}abort(){this.done=this.aborted=!0,this.fire(),this.render(),this.out.write(`
`),this.close()}submit(){const c=this.value.filter(o=>o.selected);this.minSelected&&c.length<this.minSelected?(this.showMinError=!0,this.render()):(this.done=!0,this.aborted=!1,this.fire(),this.render(),this.out.write(`
`),this.close())}first(){this.cursor=0,this.render()}last(){this.cursor=this.value.length-1,this.render()}next(){this.cursor=(this.cursor+1)%this.value.length,this.render()}up(){this.cursor===0?this.cursor=this.value.length-1:this.cursor--,this.render()}down(){this.cursor===this.value.length-1?this.cursor=0:this.cursor++,this.render()}left(){this.value[this.cursor].selected=!1,this.render()}right(){if(this.value.filter(c=>c.selected).length>=this.maxChoices)return this.bell();this.value[this.cursor].selected=!0,this.render()}handleSpaceToggle(){const c=this.value[this.cursor];if(c.selected)c.selected=!1,this.render();else{if(c.disabled||this.value.filter(o=>o.selected).length>=this.maxChoices)return this.bell();c.selected=!0,this.render()}}toggleAll(){if(this.maxChoices!==void 0||this.value[this.cursor].disabled)return this.bell();const c=!this.value[this.cursor].selected;this.value.filter(o=>!o.disabled).forEach(o=>o.selected=c),this.render()}_(c,o){if(c===" ")this.handleSpaceToggle();else if(c==="a")this.toggleAll();else return this.bell()}renderInstructions(){return this.instructions===void 0||this.instructions?typeof this.instructions=="string"?this.instructions:`
Instructions:
${i.arrowUp}/${i.arrowDown}: Highlight option
${i.arrowLeft}/${i.arrowRight}/[space]: Toggle selection
`+(this.maxChoices===void 0?` a: Toggle all
`:"")+" enter/return: Complete answer":""}renderOption(c,o,a,w){const v=(o.selected?e.green(i.radioOn):i.radioOff)+" "+w+" ";let f,m;return o.disabled?f=c===a?e.gray().underline(o.title):e.strikethrough().gray(o.title):(f=c===a?e.cyan().underline(o.title):o.title,c===a&&o.description&&(m=` - ${o.description}`,(v.length+f.length+m.length>=this.out.columns||o.description.split(/\r?\n/).length>1)&&(m=`
`+l(o.description,{margin:v.length,width:this.out.columns})))),v+f+e.gray(m||"")}paginateOptions(c){if(c.length===0)return e.red("No matches for this query.");let o=u(this.cursor,c.length,this.optionsPerPage),a=o.startIndex,w=o.endIndex,v,f=[];for(let m=a;m<w;m++)m===a&&a>0?v=i.arrowUp:m===w-1&&w<c.length?v=i.arrowDown:v=" ",f.push(this.renderOption(this.cursor,c[m],m,v));return`
`+f.join(`
`)}renderOptions(c){return this.done?"":this.paginateOptions(c)}renderDoneOrInstructions(){if(this.done)return this.value.filter(o=>o.selected).map(o=>o.title).join(", ");const c=[e.gray(this.hint),this.renderInstructions()];return this.value[this.cursor].disabled&&c.push(e.yellow(this.warn)),c.join(" ")}render(){if(this.closed)return;this.firstRender&&this.out.write(n.hide),super.render();let c=[g.symbol(this.done,this.aborted),e.bold(this.msg),g.delimiter(!1),this.renderDoneOrInstructions()].join(" ");this.showMinError&&(c+=e.red(`You must select a minimum of ${this.minSelected} choices.`),this.showMinError=!1),c+=this.renderOptions(this.value),this.out.write(this.clear+c),this.clear=p(c,this.out.columns)}}return Le=s,Le}var Ve,Cr;function _s(){if(Cr)return Ve;Cr=1;function e(f,m,b,y,x,S,$){try{var P=f[S]($),M=P.value}catch(O){b(O);return}P.done?m(M):Promise.resolve(M).then(y,x)}function t(f){return function(){var m=this,b=arguments;return new Promise(function(y,x){var S=f.apply(m,b);function $(M){e(S,y,x,$,P,"next",M)}function P(M){e(S,y,x,$,P,"throw",M)}$(void 0)})}}const n=E(),r=V(),h=C(),p=h.erase,i=h.cursor,g=Y(),l=g.style,u=g.clear,s=g.figures,d=g.wrap,c=g.entriesToDisplay,o=(f,m)=>f[m]&&(f[m].value||f[m].title||f[m]),a=(f,m)=>f[m]&&(f[m].title||f[m].value||f[m]),w=(f,m)=>{const b=f.findIndex(y=>y.value===m||y.title===m);return b>-1?b:void 0};class v extends r{constructor(m={}){super(m),this.msg=m.message,this.suggest=m.suggest,this.choices=m.choices,this.initial=typeof m.initial=="number"?m.initial:w(m.choices,m.initial),this.select=this.initial||m.cursor||0,this.i18n={noMatches:m.noMatches||"no matches found"},this.fallback=m.fallback||this.initial,this.clearFirst=m.clearFirst||!1,this.suggestions=[],this.input="",this.limit=m.limit||10,this.cursor=0,this.transform=l.render(m.style),this.scale=this.transform.scale,this.render=this.render.bind(this),this.complete=this.complete.bind(this),this.clear=u("",this.out.columns),this.complete(this.render),this.render()}set fallback(m){this._fb=Number.isSafeInteger(parseInt(m))?parseInt(m):m}get fallback(){let m;return typeof this._fb=="number"?m=this.choices[this._fb]:typeof this._fb=="string"&&(m={title:this._fb}),m||this._fb||{title:this.i18n.noMatches}}moveSelect(m){this.select=m,this.suggestions.length>0?this.value=o(this.suggestions,m):this.value=this.fallback.value,this.fire()}complete(m){var b=this;return t(function*(){const y=b.completing=b.suggest(b.input,b.choices),x=yield y;if(b.completing!==y)return;b.suggestions=x.map(($,P,M)=>({title:a(M,P),value:o(M,P),description:$.description})),b.completing=!1;const S=Math.max(x.length-1,0);b.moveSelect(Math.min(S,b.select)),m&&m()})()}reset(){this.input="",this.complete(()=>{this.moveSelect(this.initial!==void 0?this.initial:0),this.render()}),this.render()}exit(){this.clearFirst&&this.input.length>0?this.reset():(this.done=this.exited=!0,this.aborted=!1,this.fire(),this.render(),this.out.write(`
`),this.close())}abort(){this.done=this.aborted=!0,this.exited=!1,this.fire(),this.render(),this.out.write(`
`),this.close()}submit(){this.done=!0,this.aborted=this.exited=!1,this.fire(),this.render(),this.out.write(`
`),this.close()}_(m,b){let y=this.input.slice(0,this.cursor),x=this.input.slice(this.cursor);this.input=`${y}${m}${x}`,this.cursor=y.length+1,this.complete(this.render),this.render()}delete(){if(this.cursor===0)return this.bell();let m=this.input.slice(0,this.cursor-1),b=this.input.slice(this.cursor);this.input=`${m}${b}`,this.complete(this.render),this.cursor=this.cursor-1,this.render()}deleteForward(){if(this.cursor*this.scale>=this.rendered.length)return this.bell();let m=this.input.slice(0,this.cursor),b=this.input.slice(this.cursor+1);this.input=`${m}${b}`,this.complete(this.render),this.render()}first(){this.moveSelect(0),this.render()}last(){this.moveSelect(this.suggestions.length-1),this.render()}up(){this.select===0?this.moveSelect(this.suggestions.length-1):this.moveSelect(this.select-1),this.render()}down(){this.select===this.suggestions.length-1?this.moveSelect(0):this.moveSelect(this.select+1),this.render()}next(){this.select===this.suggestions.length-1?this.moveSelect(0):this.moveSelect(this.select+1),this.render()}nextPage(){this.moveSelect(Math.min(this.select+this.limit,this.suggestions.length-1)),this.render()}prevPage(){this.moveSelect(Math.max(this.select-this.limit,0)),this.render()}left(){if(this.cursor<=0)return this.bell();this.cursor=this.cursor-1,this.render()}right(){if(this.cursor*this.scale>=this.rendered.length)return this.bell();this.cursor=this.cursor+1,this.render()}renderOption(m,b,y,x){let S,$=y?s.arrowUp:x?s.arrowDown:" ",P=b?n.cyan().underline(m.title):m.title;return $=(b?n.cyan(s.pointer)+" ":" ")+$,m.description&&(S=` - ${m.description}`,($.length+P.length+S.length>=this.out.columns||m.description.split(/\r?\n/).length>1)&&(S=`
`+d(m.description,{margin:3,width:this.out.columns}))),$+" "+P+n.gray(S||"")}render(){if(this.closed)return;this.firstRender?this.out.write(i.hide):this.out.write(u(this.outputText,this.out.columns)),super.render();let m=c(this.select,this.choices.length,this.limit),b=m.startIndex,y=m.endIndex;if(this.outputText=[l.symbol(this.done,this.aborted,this.exited),n.bold(this.msg),l.delimiter(this.completing),this.done&&this.suggestions[this.select]?this.suggestions[this.select].title:this.rendered=this.transform.render(this.input)].join(" "),!this.done){const x=this.suggestions.slice(b,y).map((S,$)=>this.renderOption(S,this.select===$+b,$===0&&b>0,$+b===y-1&&y<this.choices.length)).join(`
`);this.outputText+=`
`+(x||n.gray(this.fallback.title))}this.out.write(p.line+i.to(0)+this.outputText)}}return Ve=v,Ve}var Be,_r;function qs(){if(_r)return Be;_r=1;const e=E(),t=C(),n=t.cursor,r=Er(),h=Y(),p=h.clear,i=h.style,g=h.figures;class l extends r{constructor(s={}){s.overrideRender=!0,super(s),this.inputValue="",this.clear=p("",this.out.columns),this.filteredOptions=this.value,this.render()}last(){this.cursor=this.filteredOptions.length-1,this.render()}next(){this.cursor=(this.cursor+1)%this.filteredOptions.length,this.render()}up(){this.cursor===0?this.cursor=this.filteredOptions.length-1:this.cursor--,this.render()}down(){this.cursor===this.filteredOptions.length-1?this.cursor=0:this.cursor++,this.render()}left(){this.filteredOptions[this.cursor].selected=!1,this.render()}right(){if(this.value.filter(s=>s.selected).length>=this.maxChoices)return this.bell();this.filteredOptions[this.cursor].selected=!0,this.render()}delete(){this.inputValue.length&&(this.inputValue=this.inputValue.substr(0,this.inputValue.length-1),this.updateFilteredOptions())}updateFilteredOptions(){const s=this.filteredOptions[this.cursor];this.filteredOptions=this.value.filter(c=>this.inputValue?!!(typeof c.title=="string"&&c.title.toLowerCase().includes(this.inputValue.toLowerCase())||typeof c.value=="string"&&c.value.toLowerCase().includes(this.inputValue.toLowerCase())):!0);const d=this.filteredOptions.findIndex(c=>c===s);this.cursor=d<0?0:d,this.render()}handleSpaceToggle(){const s=this.filteredOptions[this.cursor];if(s.selected)s.selected=!1,this.render();else{if(s.disabled||this.value.filter(d=>d.selected).length>=this.maxChoices)return this.bell();s.selected=!0,this.render()}}handleInputChange(s){this.inputValue=this.inputValue+s,this.updateFilteredOptions()}_(s,d){s===" "?this.handleSpaceToggle():this.handleInputChange(s)}renderInstructions(){return this.instructions===void 0||this.instructions?typeof this.instructions=="string"?this.instructions:`
Instructions:
${g.arrowUp}/${g.arrowDown}: Highlight option
${g.arrowLeft}/${g.arrowRight}/[space]: Toggle selection
[a,b,c]/delete: Filter choices
enter/return: Complete answer
`:""}renderCurrentInput(){return`
Filtered results for: ${this.inputValue?this.inputValue:e.gray("Enter something to filter")}
`}renderOption(s,d,c){let o;return d.d