@elysiumjs/styx 0.5.0 → 0.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/styx.js CHANGED
@@ -1,106 +1,108 @@
1
1
  #!/usr/bin/env bun
2
2
  // @bun
3
- var w$=Object.create;var{getPrototypeOf:g$,defineProperty:$2,getOwnPropertyNames:v$}=Object;var y$=Object.prototype.hasOwnProperty;var O=(Y,$,Z)=>{Z=Y!=null?w$(g$(Y)):{};let H=$||!Y||!Y.__esModule?$2(Z,"default",{value:Y,enumerable:!0}):Z;for(let J of v$(Y))if(!y$.call(H,J))$2(H,J,{get:()=>Y[J],enumerable:!0});return H};var z=(Y,$)=>()=>($||Y(($={exports:{}}).exports,$),$.exports);var B=function(Y,$,Z,H){var J=arguments.length,U=J<3?$:H===null?H=Object.getOwnPropertyDescriptor($,Z):H,X;if(typeof Reflect==="object"&&typeof Reflect.decorate==="function")U=Reflect.decorate(Y,$,Z,H);else for(var Q=Y.length-1;Q>=0;Q--)if(X=Y[Q])U=(J<3?X(U):J>3?X($,Z,U):X($,Z))||U;return J>3&&U&&Object.defineProperty($,Z,U),U};var W=(Y,$)=>{if(typeof Reflect==="object"&&typeof Reflect.metadata==="function")return Reflect.metadata(Y,$)};var j1=import.meta.require;var S=z((BU,H2)=>{var{FORCE_COLOR:d$,NODE_DISABLE_COLORS:u$,TERM:c$}=process.env,R={enabled:!u$&&c$!=="dumb"&&d$!=="0",reset:E(0,0),bold:E(1,22),dim:E(2,22),italic:E(3,23),underline:E(4,24),inverse:E(7,27),hidden:E(8,28),strikethrough:E(9,29),black:E(30,39),red:E(31,39),green:E(32,39),yellow:E(33,39),blue:E(34,39),magenta:E(35,39),cyan:E(36,39),white:E(37,39),gray:E(90,39),grey:E(90,39),bgBlack:E(40,49),bgRed:E(41,49),bgGreen:E(42,49),bgYellow:E(43,49),bgBlue:E(44,49),bgMagenta:E(45,49),bgCyan:E(46,49),bgWhite:E(47,49)};function Z2(Y,$){let Z=0,H,J="",U="";for(;Z<Y.length;Z++)if(H=Y[Z],J+=H.open,U+=H.close,$.includes(H.close))$=$.replace(H.rgx,H.close+H.open);return J+$+U}function l$(Y,$){let Z={has:Y,keys:$};return Z.reset=R.reset.bind(Z),Z.bold=R.bold.bind(Z),Z.dim=R.dim.bind(Z),Z.italic=R.italic.bind(Z),Z.underline=R.underline.bind(Z),Z.inverse=R.inverse.bind(Z),Z.hidden=R.hidden.bind(Z),Z.strikethrough=R.strikethrough.bind(Z),Z.black=R.black.bind(Z),Z.red=R.red.bind(Z),Z.green=R.green.bind(Z),Z.yellow=R.yellow.bind(Z),Z.blue=R.blue.bind(Z),Z.magenta=R.magenta.bind(Z),Z.cyan=R.cyan.bind(Z),Z.white=R.white.bind(Z),Z.gray=R.gray.bind(Z),Z.grey=R.grey.bind(Z),Z.bgBlack=R.bgBlack.bind(Z),Z.bgRed=R.bgRed.bind(Z),Z.bgGreen=R.bgGreen.bind(Z),Z.bgYellow=R.bgYellow.bind(Z),Z.bgBlue=R.bgBlue.bind(Z),Z.bgMagenta=R.bgMagenta.bind(Z),Z.bgCyan=R.bgCyan.bind(Z),Z.bgWhite=R.bgWhite.bind(Z),Z}function E(Y,$){let Z={open:`\x1B[${Y}m`,close:`\x1B[${$}m`,rgx:new RegExp(`\\x1b\\[${$}m`,"g")};return function(H){if(this!==void 0&&this.has!==void 0)return this.has.includes(Y)||(this.has.push(Y),this.keys.push(Z)),H===void 0?this:R.enabled?Z2(this.keys,H+""):H+"";return H===void 0?l$([Y],[Z]):R.enabled?Z2([Z],H+""):H+""}}H2.exports=R});var J2=z((WU,U2)=>{U2.exports=(Y,$)=>{if(Y.meta&&Y.name!=="escape")return;if(Y.ctrl){if(Y.name==="a")return"first";if(Y.name==="c")return"abort";if(Y.name==="d")return"abort";if(Y.name==="e")return"last";if(Y.name==="g")return"reset"}if($){if(Y.name==="j")return"down";if(Y.name==="k")return"up"}if(Y.name==="return")return"submit";if(Y.name==="enter")return"submit";if(Y.name==="backspace")return"delete";if(Y.name==="delete")return"deleteForward";if(Y.name==="abort")return"abort";if(Y.name==="escape")return"exit";if(Y.name==="tab")return"next";if(Y.name==="pagedown")return"nextPage";if(Y.name==="pageup")return"prevPage";if(Y.name==="home")return"home";if(Y.name==="end")return"end";if(Y.name==="up")return"up";if(Y.name==="down")return"down";if(Y.name==="right")return"right";if(Y.name==="left")return"left";return!1}});var k1=z((RU,X2)=>{X2.exports=(Y)=>{let $=["[\\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("|"),Z=new RegExp($,"g");return typeof Y==="string"?Y.replace(Z,""):Y}});var F=z((LU,Q2)=>{var Y0={to(Y,$){if(!$)return`\x1B[${Y+1}G`;return`\x1B[${$+1};${Y+1}H`},move(Y,$){let Z="";if(Y<0)Z+=`\x1B[${-Y}D`;else if(Y>0)Z+=`\x1B[${Y}C`;if($<0)Z+=`\x1B[${-$}A`;else if($>0)Z+=`\x1B[${$}B`;return Z},up:(Y=1)=>`\x1B[${Y}A`,down:(Y=1)=>`\x1B[${Y}B`,forward:(Y=1)=>`\x1B[${Y}C`,backward:(Y=1)=>`\x1B[${Y}D`,nextLine:(Y=1)=>"\x1B[E".repeat(Y),prevLine:(Y=1)=>"\x1B[F".repeat(Y),left:"\x1B[G",hide:"\x1B[?25l",show:"\x1B[?25h",save:"\x1B7",restore:"\x1B8"},n$={up:(Y=1)=>"\x1B[S".repeat(Y),down:(Y=1)=>"\x1B[T".repeat(Y)},p$={screen:"\x1B[2J",up:(Y=1)=>"\x1B[1J".repeat(Y),down:(Y=1)=>"\x1B[J".repeat(Y),line:"\x1B[2K",lineEnd:"\x1B[K",lineStart:"\x1B[1K",lines(Y){let $="";for(let Z=0;Z<Y;Z++)$+=this.line+(Z<Y-1?Y0.up():"");if(Y)$+=Y0.left;return $}};Q2.exports={cursor:Y0,scroll:n$,erase:p$,beep:"\x07"}});var W2=z((EU,B2)=>{function m$(Y,$){var Z=typeof Symbol!=="undefined"&&Y[Symbol.iterator]||Y["@@iterator"];if(!Z){if(Array.isArray(Y)||(Z=i$(Y))||$&&Y&&typeof Y.length==="number"){if(Z)Y=Z;var H=0,J=function D(){};return{s:J,n:function D(){if(H>=Y.length)return{done:!0};return{done:!1,value:Y[H++]}},e:function D(K){throw K},f:J}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
4
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var U=!0,X=!1,Q;return{s:function D(){Z=Z.call(Y)},n:function D(){var K=Z.next();return U=K.done,K},e:function D(K){X=!0,Q=K},f:function D(){try{if(!U&&Z.return!=null)Z.return()}finally{if(X)throw Q}}}}function i$(Y,$){if(!Y)return;if(typeof Y==="string")return D2(Y,$);var Z=Object.prototype.toString.call(Y).slice(8,-1);if(Z==="Object"&&Y.constructor)Z=Y.constructor.name;if(Z==="Map"||Z==="Set")return Array.from(Y);if(Z==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(Z))return D2(Y,$)}function D2(Y,$){if($==null||$>Y.length)$=Y.length;for(var Z=0,H=new Array($);Z<$;Z++)H[Z]=Y[Z];return H}var o$=k1(),K2=F(),z2=K2.erase,s$=K2.cursor,t$=(Y)=>[...o$(Y)].length;B2.exports=function(Y,$){if(!$)return z2.line+s$.to(0);let Z=0,H=Y.split(/\r?\n/);var J=m$(H),U;try{for(J.s();!(U=J.n()).done;){let X=U.value;Z+=1+Math.floor(Math.max(t$(X)-1,0)/$)}}catch(X){J.e(X)}finally{J.f()}return z2.lines(Z)}});var $0=z((GU,R2)=>{var B1={arrowUp:"\u2191",arrowDown:"\u2193",arrowLeft:"\u2190",arrowRight:"\u2192",radioOn:"\u25C9",radioOff:"\u25EF",tick:"\u2714",cross:"\u2716",ellipsis:"\u2026",pointerSmall:"\u203A",line:"\u2500",pointer:"\u276F"},a$={arrowUp:B1.arrowUp,arrowDown:B1.arrowDown,arrowLeft:B1.arrowLeft,arrowRight:B1.arrowRight,radioOn:"(*)",radioOff:"( )",tick:"\u221A",cross:"\xD7",ellipsis:"...",pointerSmall:"\xBB",line:"\u2500",pointer:">"},r$=process.platform==="win32"?a$:B1;R2.exports=r$});var E2=z((SU,L2)=>{var U1=S(),$1=$0(),Z0=Object.freeze({password:{scale:1,render:(Y)=>"*".repeat(Y.length)},emoji:{scale:2,render:(Y)=>"\uD83D\uDE03".repeat(Y.length)},invisible:{scale:0,render:(Y)=>""},default:{scale:1,render:(Y)=>`${Y}`}}),e$=(Y)=>Z0[Y]||Z0.default,W1=Object.freeze({aborted:U1.red($1.cross),done:U1.green($1.tick),exited:U1.yellow($1.cross),default:U1.cyan("?")}),YZ=(Y,$,Z)=>$?W1.aborted:Z?W1.exited:Y?W1.done:W1.default,$Z=(Y)=>U1.gray(Y?$1.ellipsis:$1.pointerSmall),ZZ=(Y,$)=>U1.gray(Y?$?$1.pointerSmall:"+":$1.line);L2.exports={styles:Z0,render:e$,symbols:W1,symbol:YZ,delimiter:$Z,item:ZZ}});var S2=z((FU,G2)=>{var HZ=k1();G2.exports=function(Y,$){let Z=String(HZ(Y)||"").split(/\r?\n/);if(!$)return Z.length;return Z.map((H)=>Math.ceil(H.length/$)).reduce((H,J)=>H+J)}});var M2=z((MU,F2)=>{F2.exports=(Y,$={})=>{let Z=Number.isSafeInteger(parseInt($.margin))?new Array(parseInt($.margin)).fill(" ").join(""):$.margin||"",H=$.width;return(Y||"").split(/\r?\n/g).map((J)=>J.split(/\s+/g).reduce((U,X)=>{if(X.length+Z.length>=H||U[U.length-1].length+X.length+1<H)U[U.length-1]+=` ${X}`;else U.push(`${Z}${X}`);return U},[Z]).join(`
3
+ var n$=Object.create;var{getPrototypeOf:i$,defineProperty:J2,getOwnPropertyNames:m$}=Object;var o$=Object.prototype.hasOwnProperty;var O=(Y,$,Z)=>{Z=Y!=null?n$(i$(Y)):{};let H=$||!Y||!Y.__esModule?J2(Z,"default",{value:Y,enumerable:!0}):Z;for(let U of m$(Y))if(!o$.call(H,U))J2(H,U,{get:()=>Y[U],enumerable:!0});return H};var B=(Y,$)=>()=>($||Y(($={exports:{}}).exports,$),$.exports);var z=function(Y,$,Z,H){var U=arguments.length,X=U<3?$:H===null?H=Object.getOwnPropertyDescriptor($,Z):H,Q;if(typeof Reflect==="object"&&typeof Reflect.decorate==="function")X=Reflect.decorate(Y,$,Z,H);else for(var J=Y.length-1;J>=0;J--)if(Q=Y[J])X=(U<3?Q(X):U>3?Q($,Z,X):Q($,Z))||X;return U>3&&X&&Object.defineProperty($,Z,X),X};var K=(Y,$)=>{if(typeof Reflect==="object"&&typeof Reflect.metadata==="function")return Reflect.metadata(Y,$)};var b1=import.meta.require;var M=B((cU,W2)=>{var{FORCE_COLOR:$Z,NODE_DISABLE_COLORS:ZZ,TERM:HZ}=process.env,G={enabled:!ZZ&&HZ!=="dumb"&&$Z!=="0",reset:S(0,0),bold:S(1,22),dim:S(2,22),italic:S(3,23),underline:S(4,24),inverse:S(7,27),hidden:S(8,28),strikethrough:S(9,29),black:S(30,39),red:S(31,39),green:S(32,39),yellow:S(33,39),blue:S(34,39),magenta:S(35,39),cyan:S(36,39),white:S(37,39),gray:S(90,39),grey:S(90,39),bgBlack:S(40,49),bgRed:S(41,49),bgGreen:S(42,49),bgYellow:S(43,49),bgBlue:S(44,49),bgMagenta:S(45,49),bgCyan:S(46,49),bgWhite:S(47,49)};function K2(Y,$){let Z=0,H,U="",X="";for(;Z<Y.length;Z++)if(H=Y[Z],U+=H.open,X+=H.close,$.includes(H.close))$=$.replace(H.rgx,H.close+H.open);return U+$+X}function UZ(Y,$){let Z={has:Y,keys:$};return Z.reset=G.reset.bind(Z),Z.bold=G.bold.bind(Z),Z.dim=G.dim.bind(Z),Z.italic=G.italic.bind(Z),Z.underline=G.underline.bind(Z),Z.inverse=G.inverse.bind(Z),Z.hidden=G.hidden.bind(Z),Z.strikethrough=G.strikethrough.bind(Z),Z.black=G.black.bind(Z),Z.red=G.red.bind(Z),Z.green=G.green.bind(Z),Z.yellow=G.yellow.bind(Z),Z.blue=G.blue.bind(Z),Z.magenta=G.magenta.bind(Z),Z.cyan=G.cyan.bind(Z),Z.white=G.white.bind(Z),Z.gray=G.gray.bind(Z),Z.grey=G.grey.bind(Z),Z.bgBlack=G.bgBlack.bind(Z),Z.bgRed=G.bgRed.bind(Z),Z.bgGreen=G.bgGreen.bind(Z),Z.bgYellow=G.bgYellow.bind(Z),Z.bgBlue=G.bgBlue.bind(Z),Z.bgMagenta=G.bgMagenta.bind(Z),Z.bgCyan=G.bgCyan.bind(Z),Z.bgWhite=G.bgWhite.bind(Z),Z}function S(Y,$){let Z={open:`\x1B[${Y}m`,close:`\x1B[${$}m`,rgx:new RegExp(`\\x1b\\[${$}m`,"g")};return function(H){if(this!==void 0&&this.has!==void 0)return this.has.includes(Y)||(this.has.push(Y),this.keys.push(Z)),H===void 0?this:G.enabled?K2(this.keys,H+""):H+"";return H===void 0?UZ([Y],[Z]):G.enabled?K2([Z],H+""):H+""}}W2.exports=G});var E2=B((lU,B2)=>{B2.exports=(Y,$)=>{if(Y.meta&&Y.name!=="escape")return;if(Y.ctrl){if(Y.name==="a")return"first";if(Y.name==="c")return"abort";if(Y.name==="d")return"abort";if(Y.name==="e")return"last";if(Y.name==="g")return"reset"}if($){if(Y.name==="j")return"down";if(Y.name==="k")return"up"}if(Y.name==="return")return"submit";if(Y.name==="enter")return"submit";if(Y.name==="backspace")return"delete";if(Y.name==="delete")return"deleteForward";if(Y.name==="abort")return"abort";if(Y.name==="escape")return"exit";if(Y.name==="tab")return"next";if(Y.name==="pagedown")return"nextPage";if(Y.name==="pageup")return"prevPage";if(Y.name==="home")return"home";if(Y.name==="end")return"end";if(Y.name==="up")return"up";if(Y.name==="down")return"down";if(Y.name==="right")return"right";if(Y.name==="left")return"left";return!1}});var h1=B((pU,G2)=>{G2.exports=(Y)=>{let $=["[\\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("|"),Z=new RegExp($,"g");return typeof Y==="string"?Y.replace(Z,""):Y}});var F=B((nU,R2)=>{var K0={to(Y,$){if(!$)return`\x1B[${Y+1}G`;return`\x1B[${$+1};${Y+1}H`},move(Y,$){let Z="";if(Y<0)Z+=`\x1B[${-Y}D`;else if(Y>0)Z+=`\x1B[${Y}C`;if($<0)Z+=`\x1B[${-$}A`;else if($>0)Z+=`\x1B[${$}B`;return Z},up:(Y=1)=>`\x1B[${Y}A`,down:(Y=1)=>`\x1B[${Y}B`,forward:(Y=1)=>`\x1B[${Y}C`,backward:(Y=1)=>`\x1B[${Y}D`,nextLine:(Y=1)=>"\x1B[E".repeat(Y),prevLine:(Y=1)=>"\x1B[F".repeat(Y),left:"\x1B[G",hide:"\x1B[?25l",show:"\x1B[?25h",save:"\x1B7",restore:"\x1B8"},XZ={up:(Y=1)=>"\x1B[S".repeat(Y),down:(Y=1)=>"\x1B[T".repeat(Y)},QZ={screen:"\x1B[2J",up:(Y=1)=>"\x1B[1J".repeat(Y),down:(Y=1)=>"\x1B[J".repeat(Y),line:"\x1B[2K",lineEnd:"\x1B[K",lineStart:"\x1B[1K",lines(Y){let $="";for(let Z=0;Z<Y;Z++)$+=this.line+(Z<Y-1?K0.up():"");if(Y)$+=K0.left;return $}};R2.exports={cursor:K0,scroll:XZ,erase:QZ,beep:"\x07"}});var V2=B((iU,F2)=>{function JZ(Y,$){var Z=typeof Symbol!=="undefined"&&Y[Symbol.iterator]||Y["@@iterator"];if(!Z){if(Array.isArray(Y)||(Z=DZ(Y))||$&&Y&&typeof Y.length==="number"){if(Z)Y=Z;var H=0,U=function D(){};return{s:U,n:function D(){if(H>=Y.length)return{done:!0};return{done:!1,value:Y[H++]}},e:function D(W){throw W},f:U}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
4
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var X=!0,Q=!1,J;return{s:function D(){Z=Z.call(Y)},n:function D(){var W=Z.next();return X=W.done,W},e:function D(W){Q=!0,J=W},f:function D(){try{if(!X&&Z.return!=null)Z.return()}finally{if(Q)throw J}}}}function DZ(Y,$){if(!Y)return;if(typeof Y==="string")return L2(Y,$);var Z=Object.prototype.toString.call(Y).slice(8,-1);if(Z==="Object"&&Y.constructor)Z=Y.constructor.name;if(Z==="Map"||Z==="Set")return Array.from(Y);if(Z==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(Z))return L2(Y,$)}function L2(Y,$){if($==null||$>Y.length)$=Y.length;for(var Z=0,H=new Array($);Z<$;Z++)H[Z]=Y[Z];return H}var zZ=h1(),M2=F(),S2=M2.erase,KZ=M2.cursor,WZ=(Y)=>[...zZ(Y)].length;F2.exports=function(Y,$){if(!$)return S2.line+KZ.to(0);let Z=0,H=Y.split(/\r?\n/);var U=JZ(H),X;try{for(U.s();!(X=U.n()).done;){let Q=X.value;Z+=1+Math.floor(Math.max(WZ(Q)-1,0)/$)}}catch(Q){U.e(Q)}finally{U.f()}return S2.lines(Z)}});var W0=B((mU,O2)=>{var M1={arrowUp:"\u2191",arrowDown:"\u2193",arrowLeft:"\u2190",arrowRight:"\u2192",radioOn:"\u25C9",radioOff:"\u25EF",tick:"\u2714",cross:"\u2716",ellipsis:"\u2026",pointerSmall:"\u203A",line:"\u2500",pointer:"\u276F"},BZ={arrowUp:M1.arrowUp,arrowDown:M1.arrowDown,arrowLeft:M1.arrowLeft,arrowRight:M1.arrowRight,radioOn:"(*)",radioOff:"( )",tick:"\u221A",cross:"\xD7",ellipsis:"...",pointerSmall:"\xBB",line:"\u2500",pointer:">"},EZ=process.platform==="win32"?BZ:M1;O2.exports=EZ});var A2=B((oU,I2)=>{var W1=M(),z1=W0(),B0=Object.freeze({password:{scale:1,render:(Y)=>"*".repeat(Y.length)},emoji:{scale:2,render:(Y)=>"\uD83D\uDE03".repeat(Y.length)},invisible:{scale:0,render:(Y)=>""},default:{scale:1,render:(Y)=>`${Y}`}}),GZ=(Y)=>B0[Y]||B0.default,F1=Object.freeze({aborted:W1.red(z1.cross),done:W1.green(z1.tick),exited:W1.yellow(z1.cross),default:W1.cyan("?")}),RZ=(Y,$,Z)=>$?F1.aborted:Z?F1.exited:Y?F1.done:F1.default,LZ=(Y)=>W1.gray(Y?z1.ellipsis:z1.pointerSmall),SZ=(Y,$)=>W1.gray(Y?$?z1.pointerSmall:"+":z1.line);I2.exports={styles:B0,render:GZ,symbols:F1,symbol:RZ,delimiter:LZ,item:SZ}});var N2=B((tU,q2)=>{var MZ=h1();q2.exports=function(Y,$){let Z=String(MZ(Y)||"").split(/\r?\n/);if(!$)return Z.length;return Z.map((H)=>Math.ceil(H.length/$)).reduce((H,U)=>H+U)}});var T2=B((sU,P2)=>{P2.exports=(Y,$={})=>{let Z=Number.isSafeInteger(parseInt($.margin))?new Array(parseInt($.margin)).fill(" ").join(""):$.margin||"",H=$.width;return(Y||"").split(/\r?\n/g).map((U)=>U.split(/\s+/g).reduce((X,Q)=>{if(Q.length+Z.length>=H||X[X.length-1].length+Q.length+1<H)X[X.length-1]+=` ${Q}`;else X.push(`${Z}${Q}`);return X},[Z]).join(`
5
5
  `)).join(`
6
- `)}});var V2=z((OU,O2)=>{O2.exports=(Y,$,Z)=>{Z=Z||$;let H=Math.min($-Z,Y-Math.floor(Z/2));if(H<0)H=0;let J=Math.min(H+Z,$);return{startIndex:H,endIndex:J}}});var T=z((VU,I2)=>{I2.exports={action:J2(),clear:W2(),style:E2(),strip:k1(),figures:$0(),lines:S2(),wrap:M2(),entriesToDisplay:V2()}});var v=z((IU,N2)=>{var A2=j1("readline"),UZ=T(),JZ=UZ.action,XZ=j1("events"),q2=F(),QZ=q2.beep,DZ=q2.cursor,zZ=S();class C2 extends XZ{constructor(Y={}){super();this.firstRender=!0,this.in=Y.stdin||process.stdin,this.out=Y.stdout||process.stdout,this.onRender=(Y.onRender||(()=>{return})).bind(this);let $=A2.createInterface({input:this.in,escapeCodeTimeout:50});if(A2.emitKeypressEvents(this.in,$),this.in.isTTY)this.in.setRawMode(!0);let Z=["SelectPrompt","MultiselectPrompt"].indexOf(this.constructor.name)>-1,H=(J,U)=>{let X=JZ(U,Z);if(X===!1)this._&&this._(J,U);else if(typeof this[X]==="function")this[X](U);else this.bell()};this.close=()=>{if(this.out.write(DZ.show),this.in.removeListener("keypress",H),this.in.isTTY)this.in.setRawMode(!1);$.close(),this.emit(this.aborted?"abort":this.exited?"exit":"submit",this.value),this.closed=!0},this.in.on("keypress",H)}fire(){this.emit("state",{value:this.value,aborted:!!this.aborted,exited:!!this.exited})}bell(){this.out.write(QZ)}render(){if(this.onRender(zZ),this.firstRender)this.firstRender=!1}}N2.exports=C2});var b2=z((AU,_2)=>{function T2(Y,$,Z,H,J,U,X){try{var Q=Y[U](X),D=Q.value}catch(K){Z(K);return}if(Q.done)$(D);else Promise.resolve(D).then(H,J)}function P2(Y){return function(){var $=this,Z=arguments;return new Promise(function(H,J){var U=Y.apply($,Z);function X(D){T2(U,H,J,X,Q,"next",D)}function Q(D){T2(U,H,J,X,Q,"throw",D)}X(void 0)})}}var _1=S(),KZ=v(),j2=F(),BZ=j2.erase,R1=j2.cursor,b1=T(),H0=b1.style,U0=b1.clear,WZ=b1.lines,RZ=b1.figures;class k2 extends KZ{constructor(Y={}){super(Y);this.transform=H0.render(Y.style),this.scale=this.transform.scale,this.msg=Y.message,this.initial=Y.initial||"",this.validator=Y.validate||(()=>!0),this.value="",this.errorMsg=Y.error||"Please Enter A Valid Value",this.cursor=Number(!!this.initial),this.cursorOffset=0,this.clear=U0("",this.out.columns),this.render()}set value(Y){if(!Y&&this.initial)this.placeholder=!0,this.rendered=_1.gray(this.transform.render(this.initial));else this.placeholder=!1,this.rendered=this.transform.render(Y);this._value=Y,this.fire()}get value(){return this._value}reset(){this.value="",this.cursor=Number(!!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(`
7
- `),this.close()}validate(){var Y=this;return P2(function*(){let $=yield Y.validator(Y.value);if(typeof $==="string")Y.errorMsg=$,$=!1;Y.error=!$})()}submit(){var Y=this;return P2(function*(){if(Y.value=Y.value||Y.initial,Y.cursorOffset=0,Y.cursor=Y.rendered.length,yield Y.validate(),Y.error){Y.red=!0,Y.fire(),Y.render();return}Y.done=!0,Y.aborted=!1,Y.fire(),Y.render(),Y.out.write(`
8
- `),Y.close()})()}next(){if(!this.placeholder)return this.bell();this.value=this.initial,this.cursor=this.rendered.length,this.fire(),this.render()}moveCursor(Y){if(this.placeholder)return;this.cursor=this.cursor+Y,this.cursorOffset+=Y}_(Y,$){let Z=this.value.slice(0,this.cursor),H=this.value.slice(this.cursor);this.value=`${Z}${Y}${H}`,this.red=!1,this.cursor=this.placeholder?0:Z.length+1,this.render()}delete(){if(this.isCursorAtStart())return this.bell();let Y=this.value.slice(0,this.cursor-1),$=this.value.slice(this.cursor);if(this.value=`${Y}${$}`,this.red=!1,this.isCursorAtStart())this.cursorOffset=0;else this.cursorOffset++,this.moveCursor(-1);this.render()}deleteForward(){if(this.cursor*this.scale>=this.rendered.length||this.placeholder)return this.bell();let Y=this.value.slice(0,this.cursor),$=this.value.slice(this.cursor+1);if(this.value=`${Y}${$}`,this.red=!1,this.isCursorAtEnd())this.cursorOffset=0;else 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(){if(this.closed)return;if(!this.firstRender){if(this.outputError)this.out.write(R1.down(WZ(this.outputError,this.out.columns)-1)+U0(this.outputError,this.out.columns));this.out.write(U0(this.outputText,this.out.columns))}if(super.render(),this.outputError="",this.outputText=[H0.symbol(this.done,this.aborted),_1.bold(this.msg),H0.delimiter(this.done),this.red?_1.red(this.rendered):this.rendered].join(" "),this.error)this.outputError+=this.errorMsg.split(`
6
+ `)}});var j2=B((rU,C2)=>{C2.exports=(Y,$,Z)=>{Z=Z||$;let H=Math.min($-Z,Y-Math.floor(Z/2));if(H<0)H=0;let U=Math.min(H+Z,$);return{startIndex:H,endIndex:U}}});var x=B((aU,_2)=>{_2.exports={action:E2(),clear:V2(),style:A2(),strip:h1(),figures:W0(),lines:N2(),wrap:T2(),entriesToDisplay:j2()}});var p=B((eU,h2)=>{var k2=b1("readline"),FZ=x(),VZ=FZ.action,OZ=b1("events"),x2=F(),IZ=x2.beep,AZ=x2.cursor,qZ=M();class b2 extends OZ{constructor(Y={}){super();this.firstRender=!0,this.in=Y.stdin||process.stdin,this.out=Y.stdout||process.stdout,this.onRender=(Y.onRender||(()=>{return})).bind(this);let $=k2.createInterface({input:this.in,escapeCodeTimeout:50});if(k2.emitKeypressEvents(this.in,$),this.in.isTTY)this.in.setRawMode(!0);let Z=["SelectPrompt","MultiselectPrompt"].indexOf(this.constructor.name)>-1,H=(U,X)=>{let Q=VZ(X,Z);if(Q===!1)this._&&this._(U,X);else if(typeof this[Q]==="function")this[Q](X);else this.bell()};this.close=()=>{if(this.out.write(AZ.show),this.in.removeListener("keypress",H),this.in.isTTY)this.in.setRawMode(!1);$.close(),this.emit(this.aborted?"abort":this.exited?"exit":"submit",this.value),this.closed=!0},this.in.on("keypress",H)}fire(){this.emit("state",{value:this.value,aborted:!!this.aborted,exited:!!this.exited})}bell(){this.out.write(IZ)}render(){if(this.onRender(qZ),this.firstRender)this.firstRender=!1}}h2.exports=b2});var d2=B((Y5,y2)=>{function f2(Y,$,Z,H,U,X,Q){try{var J=Y[X](Q),D=J.value}catch(W){Z(W);return}if(J.done)$(D);else Promise.resolve(D).then(H,U)}function w2(Y){return function(){var $=this,Z=arguments;return new Promise(function(H,U){var X=Y.apply($,Z);function Q(D){f2(X,H,U,Q,J,"next",D)}function J(D){f2(X,H,U,Q,J,"throw",D)}Q(void 0)})}}var f1=M(),NZ=p(),v2=F(),PZ=v2.erase,V1=v2.cursor,w1=x(),E0=w1.style,G0=w1.clear,TZ=w1.lines,CZ=w1.figures;class g2 extends NZ{constructor(Y={}){super(Y);this.transform=E0.render(Y.style),this.scale=this.transform.scale,this.msg=Y.message,this.initial=Y.initial||"",this.validator=Y.validate||(()=>!0),this.value="",this.errorMsg=Y.error||"Please Enter A Valid Value",this.cursor=Number(!!this.initial),this.cursorOffset=0,this.clear=G0("",this.out.columns),this.render()}set value(Y){if(!Y&&this.initial)this.placeholder=!0,this.rendered=f1.gray(this.transform.render(this.initial));else this.placeholder=!1,this.rendered=this.transform.render(Y);this._value=Y,this.fire()}get value(){return this._value}reset(){this.value="",this.cursor=Number(!!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(`
7
+ `),this.close()}validate(){var Y=this;return w2(function*(){let $=yield Y.validator(Y.value);if(typeof $==="string")Y.errorMsg=$,$=!1;Y.error=!$})()}submit(){var Y=this;return w2(function*(){if(Y.value=Y.value||Y.initial,Y.cursorOffset=0,Y.cursor=Y.rendered.length,yield Y.validate(),Y.error){Y.red=!0,Y.fire(),Y.render();return}Y.done=!0,Y.aborted=!1,Y.fire(),Y.render(),Y.out.write(`
8
+ `),Y.close()})()}next(){if(!this.placeholder)return this.bell();this.value=this.initial,this.cursor=this.rendered.length,this.fire(),this.render()}moveCursor(Y){if(this.placeholder)return;this.cursor=this.cursor+Y,this.cursorOffset+=Y}_(Y,$){let Z=this.value.slice(0,this.cursor),H=this.value.slice(this.cursor);this.value=`${Z}${Y}${H}`,this.red=!1,this.cursor=this.placeholder?0:Z.length+1,this.render()}delete(){if(this.isCursorAtStart())return this.bell();let Y=this.value.slice(0,this.cursor-1),$=this.value.slice(this.cursor);if(this.value=`${Y}${$}`,this.red=!1,this.isCursorAtStart())this.cursorOffset=0;else this.cursorOffset++,this.moveCursor(-1);this.render()}deleteForward(){if(this.cursor*this.scale>=this.rendered.length||this.placeholder)return this.bell();let Y=this.value.slice(0,this.cursor),$=this.value.slice(this.cursor+1);if(this.value=`${Y}${$}`,this.red=!1,this.isCursorAtEnd())this.cursorOffset=0;else 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(){if(this.closed)return;if(!this.firstRender){if(this.outputError)this.out.write(V1.down(TZ(this.outputError,this.out.columns)-1)+G0(this.outputError,this.out.columns));this.out.write(G0(this.outputText,this.out.columns))}if(super.render(),this.outputError="",this.outputText=[E0.symbol(this.done,this.aborted),f1.bold(this.msg),E0.delimiter(this.done),this.red?f1.red(this.rendered):this.rendered].join(" "),this.error)this.outputError+=this.errorMsg.split(`
9
9
  `).reduce((Y,$,Z)=>Y+`
10
- ${Z?" ":RZ.pointerSmall} ${_1.red().italic($)}`,"");this.out.write(BZ.line+R1.to(0)+this.outputText+R1.save+this.outputError+R1.restore+R1.move(this.cursorOffset,0))}}_2.exports=k2});var g2=z((qU,w2)=>{var y=S(),LZ=v(),L1=T(),x2=L1.style,h2=L1.clear,x1=L1.figures,EZ=L1.wrap,GZ=L1.entriesToDisplay,SZ=F(),FZ=SZ.cursor;class f2 extends LZ{constructor(Y={}){super(Y);this.msg=Y.message,this.hint=Y.hint||"- Use arrow-keys. Return to submit.",this.warn=Y.warn||"- This option is disabled",this.cursor=Y.initial||0,this.choices=Y.choices.map(($,Z)=>{if(typeof $==="string")$={title:$,value:Z};return{title:$&&($.title||$.value||$),value:$&&($.value===void 0?Z:$.value),description:$&&$.description,selected:$&&$.selected,disabled:$&&$.disabled}}),this.optionsPerPage=Y.optionsPerPage||10,this.value=(this.choices[this.cursor]||{}).value,this.clear=h2("",this.out.columns),this.render()}moveCursor(Y){this.cursor=Y,this.value=this.choices[Y].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(`
10
+ ${Z?" ":CZ.pointerSmall} ${f1.red().italic($)}`,"");this.out.write(PZ.line+V1.to(0)+this.outputText+V1.save+this.outputError+V1.restore+V1.move(this.cursorOffset,0))}}y2.exports=g2});var n2=B(($5,p2)=>{var n=M(),jZ=p(),O1=x(),u2=O1.style,c2=O1.clear,v1=O1.figures,_Z=O1.wrap,kZ=O1.entriesToDisplay,xZ=F(),bZ=xZ.cursor;class l2 extends jZ{constructor(Y={}){super(Y);this.msg=Y.message,this.hint=Y.hint||"- Use arrow-keys. Return to submit.",this.warn=Y.warn||"- This option is disabled",this.cursor=Y.initial||0,this.choices=Y.choices.map(($,Z)=>{if(typeof $==="string")$={title:$,value:Z};return{title:$&&($.title||$.value||$),value:$&&($.value===void 0?Z:$.value),description:$&&$.description,selected:$&&$.selected,disabled:$&&$.disabled}}),this.optionsPerPage=Y.optionsPerPage||10,this.value=(this.choices[this.cursor]||{}).value,this.clear=c2("",this.out.columns),this.render()}moveCursor(Y){this.cursor=Y,this.value=this.choices[Y].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(`
11
11
  `),this.close()}submit(){if(!this.selection.disabled)this.done=!0,this.aborted=!1,this.fire(),this.render(),this.out.write(`
12
- `),this.close();else this.bell()}first(){this.moveCursor(0),this.render()}last(){this.moveCursor(this.choices.length-1),this.render()}up(){if(this.cursor===0)this.moveCursor(this.choices.length-1);else this.moveCursor(this.cursor-1);this.render()}down(){if(this.cursor===this.choices.length-1)this.moveCursor(0);else this.moveCursor(this.cursor+1);this.render()}next(){this.moveCursor((this.cursor+1)%this.choices.length),this.render()}_(Y,$){if(Y===" ")return this.submit()}get selection(){return this.choices[this.cursor]}render(){if(this.closed)return;if(this.firstRender)this.out.write(FZ.hide);else this.out.write(h2(this.outputText,this.out.columns));super.render();let Y=GZ(this.cursor,this.choices.length,this.optionsPerPage),$=Y.startIndex,Z=Y.endIndex;if(this.outputText=[x2.symbol(this.done,this.aborted),y.bold(this.msg),x2.delimiter(!1),this.done?this.selection.title:this.selection.disabled?y.yellow(this.warn):y.gray(this.hint)].join(" "),!this.done){this.outputText+=`
13
- `;for(let H=$;H<Z;H++){let J,U,X="",Q=this.choices[H];if(H===$&&$>0)U=x1.arrowUp;else if(H===Z-1&&Z<this.choices.length)U=x1.arrowDown;else U=" ";if(Q.disabled)J=this.cursor===H?y.gray().underline(Q.title):y.strikethrough().gray(Q.title),U=(this.cursor===H?y.bold().gray(x1.pointer)+" ":" ")+U;else if(J=this.cursor===H?y.cyan().underline(Q.title):Q.title,U=(this.cursor===H?y.cyan(x1.pointer)+" ":" ")+U,Q.description&&this.cursor===H){if(X=` - ${Q.description}`,U.length+J.length+X.length>=this.out.columns||Q.description.split(/\r?\n/).length>1)X=`
14
- `+EZ(Q.description,{margin:3,width:this.out.columns})}this.outputText+=`${U} ${J}${y.gray(X)}
15
- `}}this.out.write(this.outputText)}}w2.exports=f2});var n2=z((CU,l2)=>{var h1=S(),MZ=v(),d2=T(),v2=d2.style,OZ=d2.clear,u2=F(),y2=u2.cursor,VZ=u2.erase;class c2 extends MZ{constructor(Y={}){super(Y);this.msg=Y.message,this.value=!!Y.initial,this.active=Y.active||"on",this.inactive=Y.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(`
12
+ `),this.close();else this.bell()}first(){this.moveCursor(0),this.render()}last(){this.moveCursor(this.choices.length-1),this.render()}up(){if(this.cursor===0)this.moveCursor(this.choices.length-1);else this.moveCursor(this.cursor-1);this.render()}down(){if(this.cursor===this.choices.length-1)this.moveCursor(0);else this.moveCursor(this.cursor+1);this.render()}next(){this.moveCursor((this.cursor+1)%this.choices.length),this.render()}_(Y,$){if(Y===" ")return this.submit()}get selection(){return this.choices[this.cursor]}render(){if(this.closed)return;if(this.firstRender)this.out.write(bZ.hide);else this.out.write(c2(this.outputText,this.out.columns));super.render();let Y=kZ(this.cursor,this.choices.length,this.optionsPerPage),$=Y.startIndex,Z=Y.endIndex;if(this.outputText=[u2.symbol(this.done,this.aborted),n.bold(this.msg),u2.delimiter(!1),this.done?this.selection.title:this.selection.disabled?n.yellow(this.warn):n.gray(this.hint)].join(" "),!this.done){this.outputText+=`
13
+ `;for(let H=$;H<Z;H++){let U,X,Q="",J=this.choices[H];if(H===$&&$>0)X=v1.arrowUp;else if(H===Z-1&&Z<this.choices.length)X=v1.arrowDown;else X=" ";if(J.disabled)U=this.cursor===H?n.gray().underline(J.title):n.strikethrough().gray(J.title),X=(this.cursor===H?n.bold().gray(v1.pointer)+" ":" ")+X;else if(U=this.cursor===H?n.cyan().underline(J.title):J.title,X=(this.cursor===H?n.cyan(v1.pointer)+" ":" ")+X,J.description&&this.cursor===H){if(Q=` - ${J.description}`,X.length+U.length+Q.length>=this.out.columns||J.description.split(/\r?\n/).length>1)Q=`
14
+ `+_Z(J.description,{margin:3,width:this.out.columns})}this.outputText+=`${X} ${U}${n.gray(Q)}
15
+ `}}this.out.write(this.outputText)}}p2.exports=l2});var a2=B((Z5,r2)=>{var g1=M(),hZ=p(),o2=x(),i2=o2.style,fZ=o2.clear,t2=F(),m2=t2.cursor,wZ=t2.erase;class s2 extends hZ{constructor(Y={}){super(Y);this.msg=Y.message,this.value=!!Y.initial,this.active=Y.active||"on",this.inactive=Y.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(`
16
16
  `),this.close()}submit(){this.done=!0,this.aborted=!1,this.fire(),this.render(),this.out.write(`
17
- `),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()}_(Y,$){if(Y===" ")this.value=!this.value;else if(Y==="1")this.value=!0;else if(Y==="0")this.value=!1;else return this.bell();this.render()}render(){if(this.closed)return;if(this.firstRender)this.out.write(y2.hide);else this.out.write(OZ(this.outputText,this.out.columns));super.render(),this.outputText=[v2.symbol(this.done,this.aborted),h1.bold(this.msg),v2.delimiter(this.done),this.value?this.inactive:h1.cyan().underline(this.inactive),h1.gray("/"),this.value?h1.cyan().underline(this.active):this.active].join(" "),this.out.write(VZ.line+y2.to(0)+this.outputText)}}l2.exports=c2});var k=z((NU,p2)=>{class f1{constructor({token:Y,date:$,parts:Z,locales:H}){this.token=Y,this.date=$||new Date,this.parts=Z||[this],this.locales=H||{}}up(){}down(){}next(){let Y=this.parts.indexOf(this);return this.parts.find(($,Z)=>Z>Y&&$ instanceof f1)}setTo(Y){}prev(){let Y=[].concat(this.parts).reverse(),$=Y.indexOf(this);return Y.find((Z,H)=>H>$&&Z instanceof f1)}toString(){return String(this.date)}}p2.exports=f1});var o2=z((TU,i2)=>{var IZ=k();class m2 extends IZ{constructor(Y={}){super(Y)}up(){this.date.setHours((this.date.getHours()+12)%24)}down(){this.up()}toString(){let Y=this.date.getHours()>12?"pm":"am";return/\A/.test(this.token)?Y.toUpperCase():Y}}i2.exports=m2});var a2=z((PU,t2)=>{var AZ=k(),qZ=(Y)=>{return Y=Y%10,Y===1?"st":Y===2?"nd":Y===3?"rd":"th"};class s2 extends AZ{constructor(Y={}){super(Y)}up(){this.date.setDate(this.date.getDate()+1)}down(){this.date.setDate(this.date.getDate()-1)}setTo(Y){this.date.setDate(parseInt(Y.substr(-2)))}toString(){let Y=this.date.getDate(),$=this.date.getDay();return this.token==="DD"?String(Y).padStart(2,"0"):this.token==="Do"?Y+qZ(Y):this.token==="d"?$+1:this.token==="ddd"?this.locales.weekdaysShort[$]:this.token==="dddd"?this.locales.weekdays[$]:Y}}t2.exports=s2});var Y4=z((jU,e2)=>{var CZ=k();class r2 extends CZ{constructor(Y={}){super(Y)}up(){this.date.setHours(this.date.getHours()+1)}down(){this.date.setHours(this.date.getHours()-1)}setTo(Y){this.date.setHours(parseInt(Y.substr(-2)))}toString(){let Y=this.date.getHours();if(/h/.test(this.token))Y=Y%12||12;return this.token.length>1?String(Y).padStart(2,"0"):Y}}e2.exports=r2});var H4=z((kU,Z4)=>{var NZ=k();class $4 extends NZ{constructor(Y={}){super(Y)}up(){this.date.setMilliseconds(this.date.getMilliseconds()+1)}down(){this.date.setMilliseconds(this.date.getMilliseconds()-1)}setTo(Y){this.date.setMilliseconds(parseInt(Y.substr(-this.token.length)))}toString(){return String(this.date.getMilliseconds()).padStart(4,"0").substr(0,this.token.length)}}Z4.exports=$4});var X4=z((_U,J4)=>{var TZ=k();class U4 extends TZ{constructor(Y={}){super(Y)}up(){this.date.setMinutes(this.date.getMinutes()+1)}down(){this.date.setMinutes(this.date.getMinutes()-1)}setTo(Y){this.date.setMinutes(parseInt(Y.substr(-2)))}toString(){let Y=this.date.getMinutes();return this.token.length>1?String(Y).padStart(2,"0"):Y}}J4.exports=U4});var z4=z((bU,D4)=>{var PZ=k();class Q4 extends PZ{constructor(Y={}){super(Y)}up(){this.date.setMonth(this.date.getMonth()+1)}down(){this.date.setMonth(this.date.getMonth()-1)}setTo(Y){Y=parseInt(Y.substr(-2))-1,this.date.setMonth(Y<0?0:Y)}toString(){let Y=this.date.getMonth(),$=this.token.length;return $===2?String(Y+1).padStart(2,"0"):$===3?this.locales.monthsShort[Y]:$===4?this.locales.months[Y]:String(Y+1)}}D4.exports=Q4});var W4=z((xU,B4)=>{var jZ=k();class K4 extends jZ{constructor(Y={}){super(Y)}up(){this.date.setSeconds(this.date.getSeconds()+1)}down(){this.date.setSeconds(this.date.getSeconds()-1)}setTo(Y){this.date.setSeconds(parseInt(Y.substr(-2)))}toString(){let Y=this.date.getSeconds();return this.token.length>1?String(Y).padStart(2,"0"):Y}}B4.exports=K4});var E4=z((hU,L4)=>{var kZ=k();class R4 extends kZ{constructor(Y={}){super(Y)}up(){this.date.setFullYear(this.date.getFullYear()+1)}down(){this.date.setFullYear(this.date.getFullYear()-1)}setTo(Y){this.date.setFullYear(Y.substr(-4))}toString(){let Y=String(this.date.getFullYear()).padStart(4,"0");return this.token.length===2?Y.substr(-2):Y}}L4.exports=R4});var S4=z((fU,G4)=>{G4.exports={DatePart:k(),Meridiem:o2(),Day:a2(),Hours:Y4(),Milliseconds:H4(),Minutes:X4(),Month:z4(),Seconds:W4(),Year:E4()}});var P4=z((wU,T4)=>{function F4(Y,$,Z,H,J,U,X){try{var Q=Y[U](X),D=Q.value}catch(K){Z(K);return}if(Q.done)$(D);else Promise.resolve(D).then(H,J)}function M4(Y){return function(){var $=this,Z=arguments;return new Promise(function(H,J){var U=Y.apply($,Z);function X(D){F4(U,H,J,X,Q,"next",D)}function Q(D){F4(U,H,J,X,Q,"throw",D)}X(void 0)})}}var J0=S(),_Z=v(),X0=T(),O4=X0.style,V4=X0.clear,bZ=X0.figures,C4=F(),xZ=C4.erase,I4=C4.cursor,d=S4(),A4=d.DatePart,hZ=d.Meridiem,fZ=d.Day,wZ=d.Hours,gZ=d.Milliseconds,vZ=d.Minutes,yZ=d.Month,dZ=d.Seconds,uZ=d.Year,cZ=/\\(.)|"((?:\\["\\]|[^"])+)"|(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,q4={1:({token:Y})=>Y.replace(/\\(.)/g,"$1"),2:(Y)=>new fZ(Y),3:(Y)=>new yZ(Y),4:(Y)=>new uZ(Y),5:(Y)=>new hZ(Y),6:(Y)=>new wZ(Y),7:(Y)=>new vZ(Y),8:(Y)=>new dZ(Y),9:(Y)=>new gZ(Y)},lZ={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 N4 extends _Z{constructor(Y={}){super(Y);this.msg=Y.message,this.cursor=0,this.typed="",this.locales=Object.assign(lZ,Y.locales),this._date=Y.initial||new Date,this.errorMsg=Y.error||"Please Enter A Valid Value",this.validator=Y.validate||(()=>!0),this.mask=Y.mask||"YYYY-MM-DD HH:mm:ss",this.clear=V4("",this.out.columns),this.render()}get value(){return this.date}get date(){return this._date}set date(Y){if(Y)this._date.setTime(Y.getTime())}set mask(Y){let $;this.parts=[];while($=cZ.exec(Y)){let H=$.shift(),J=$.findIndex((U)=>U!=null);this.parts.push(J in q4?q4[J]({token:$[J]||H,date:this.date,parts:this.parts,locales:this.locales}):$[J]||H)}let Z=this.parts.reduce((H,J)=>{if(typeof J==="string"&&typeof H[H.length-1]==="string")H[H.length-1]+=J;else H.push(J);return H},[]);this.parts.splice(0),this.parts.push(...Z),this.reset()}moveCursor(Y){this.typed="",this.cursor=Y,this.fire()}reset(){this.moveCursor(this.parts.findIndex((Y)=>Y instanceof A4)),this.fire(),this.render()}exit(){this.abort()}abort(){this.done=this.aborted=!0,this.error=!1,this.fire(),this.render(),this.out.write(`
18
- `),this.close()}validate(){var Y=this;return M4(function*(){let $=yield Y.validator(Y.value);if(typeof $==="string")Y.errorMsg=$,$=!1;Y.error=!$})()}submit(){var Y=this;return M4(function*(){if(yield Y.validate(),Y.error){Y.color="red",Y.fire(),Y.render();return}Y.done=!0,Y.aborted=!1,Y.fire(),Y.render(),Y.out.write(`
19
- `),Y.close()})()}up(){this.typed="",this.parts[this.cursor].up(),this.render()}down(){this.typed="",this.parts[this.cursor].down(),this.render()}left(){let Y=this.parts[this.cursor].prev();if(Y==null)return this.bell();this.moveCursor(this.parts.indexOf(Y)),this.render()}right(){let Y=this.parts[this.cursor].next();if(Y==null)return this.bell();this.moveCursor(this.parts.indexOf(Y)),this.render()}next(){let Y=this.parts[this.cursor].next();this.moveCursor(Y?this.parts.indexOf(Y):this.parts.findIndex(($)=>$ instanceof A4)),this.render()}_(Y){if(/\d/.test(Y))this.typed+=Y,this.parts[this.cursor].setTo(this.typed),this.render()}render(){if(this.closed)return;if(this.firstRender)this.out.write(I4.hide);else this.out.write(V4(this.outputText,this.out.columns));if(super.render(),this.outputText=[O4.symbol(this.done,this.aborted),J0.bold(this.msg),O4.delimiter(!1),this.parts.reduce((Y,$,Z)=>Y.concat(Z===this.cursor&&!this.done?J0.cyan().underline($.toString()):$),[]).join("")].join(" "),this.error)this.outputText+=this.errorMsg.split(`
17
+ `),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()}_(Y,$){if(Y===" ")this.value=!this.value;else if(Y==="1")this.value=!0;else if(Y==="0")this.value=!1;else return this.bell();this.render()}render(){if(this.closed)return;if(this.firstRender)this.out.write(m2.hide);else this.out.write(fZ(this.outputText,this.out.columns));super.render(),this.outputText=[i2.symbol(this.done,this.aborted),g1.bold(this.msg),i2.delimiter(this.done),this.value?this.inactive:g1.cyan().underline(this.inactive),g1.gray("/"),this.value?g1.cyan().underline(this.active):this.active].join(" "),this.out.write(wZ.line+m2.to(0)+this.outputText)}}r2.exports=s2});var w=B((H5,e2)=>{class y1{constructor({token:Y,date:$,parts:Z,locales:H}){this.token=Y,this.date=$||new Date,this.parts=Z||[this],this.locales=H||{}}up(){}down(){}next(){let Y=this.parts.indexOf(this);return this.parts.find(($,Z)=>Z>Y&&$ instanceof y1)}setTo(Y){}prev(){let Y=[].concat(this.parts).reverse(),$=Y.indexOf(this);return Y.find((Z,H)=>H>$&&Z instanceof y1)}toString(){return String(this.date)}}e2.exports=y1});var Z4=B((U5,$4)=>{var vZ=w();class Y4 extends vZ{constructor(Y={}){super(Y)}up(){this.date.setHours((this.date.getHours()+12)%24)}down(){this.up()}toString(){let Y=this.date.getHours()>12?"pm":"am";return/\A/.test(this.token)?Y.toUpperCase():Y}}$4.exports=Y4});var X4=B((X5,U4)=>{var gZ=w(),yZ=(Y)=>{return Y=Y%10,Y===1?"st":Y===2?"nd":Y===3?"rd":"th"};class H4 extends gZ{constructor(Y={}){super(Y)}up(){this.date.setDate(this.date.getDate()+1)}down(){this.date.setDate(this.date.getDate()-1)}setTo(Y){this.date.setDate(parseInt(Y.substr(-2)))}toString(){let Y=this.date.getDate(),$=this.date.getDay();return this.token==="DD"?String(Y).padStart(2,"0"):this.token==="Do"?Y+yZ(Y):this.token==="d"?$+1:this.token==="ddd"?this.locales.weekdaysShort[$]:this.token==="dddd"?this.locales.weekdays[$]:Y}}U4.exports=H4});var D4=B((Q5,J4)=>{var dZ=w();class Q4 extends dZ{constructor(Y={}){super(Y)}up(){this.date.setHours(this.date.getHours()+1)}down(){this.date.setHours(this.date.getHours()-1)}setTo(Y){this.date.setHours(parseInt(Y.substr(-2)))}toString(){let Y=this.date.getHours();if(/h/.test(this.token))Y=Y%12||12;return this.token.length>1?String(Y).padStart(2,"0"):Y}}J4.exports=Q4});var W4=B((J5,K4)=>{var uZ=w();class z4 extends uZ{constructor(Y={}){super(Y)}up(){this.date.setMilliseconds(this.date.getMilliseconds()+1)}down(){this.date.setMilliseconds(this.date.getMilliseconds()-1)}setTo(Y){this.date.setMilliseconds(parseInt(Y.substr(-this.token.length)))}toString(){return String(this.date.getMilliseconds()).padStart(4,"0").substr(0,this.token.length)}}K4.exports=z4});var G4=B((D5,E4)=>{var cZ=w();class B4 extends cZ{constructor(Y={}){super(Y)}up(){this.date.setMinutes(this.date.getMinutes()+1)}down(){this.date.setMinutes(this.date.getMinutes()-1)}setTo(Y){this.date.setMinutes(parseInt(Y.substr(-2)))}toString(){let Y=this.date.getMinutes();return this.token.length>1?String(Y).padStart(2,"0"):Y}}E4.exports=B4});var S4=B((z5,L4)=>{var lZ=w();class R4 extends lZ{constructor(Y={}){super(Y)}up(){this.date.setMonth(this.date.getMonth()+1)}down(){this.date.setMonth(this.date.getMonth()-1)}setTo(Y){Y=parseInt(Y.substr(-2))-1,this.date.setMonth(Y<0?0:Y)}toString(){let Y=this.date.getMonth(),$=this.token.length;return $===2?String(Y+1).padStart(2,"0"):$===3?this.locales.monthsShort[Y]:$===4?this.locales.months[Y]:String(Y+1)}}L4.exports=R4});var V4=B((K5,F4)=>{var pZ=w();class M4 extends pZ{constructor(Y={}){super(Y)}up(){this.date.setSeconds(this.date.getSeconds()+1)}down(){this.date.setSeconds(this.date.getSeconds()-1)}setTo(Y){this.date.setSeconds(parseInt(Y.substr(-2)))}toString(){let Y=this.date.getSeconds();return this.token.length>1?String(Y).padStart(2,"0"):Y}}F4.exports=M4});var A4=B((W5,I4)=>{var nZ=w();class O4 extends nZ{constructor(Y={}){super(Y)}up(){this.date.setFullYear(this.date.getFullYear()+1)}down(){this.date.setFullYear(this.date.getFullYear()-1)}setTo(Y){this.date.setFullYear(Y.substr(-4))}toString(){let Y=String(this.date.getFullYear()).padStart(4,"0");return this.token.length===2?Y.substr(-2):Y}}I4.exports=O4});var N4=B((B5,q4)=>{q4.exports={DatePart:w(),Meridiem:Z4(),Day:X4(),Hours:D4(),Milliseconds:W4(),Minutes:G4(),Month:S4(),Seconds:V4(),Year:A4()}});var w4=B((E5,f4)=>{function P4(Y,$,Z,H,U,X,Q){try{var J=Y[X](Q),D=J.value}catch(W){Z(W);return}if(J.done)$(D);else Promise.resolve(D).then(H,U)}function T4(Y){return function(){var $=this,Z=arguments;return new Promise(function(H,U){var X=Y.apply($,Z);function Q(D){P4(X,H,U,Q,J,"next",D)}function J(D){P4(X,H,U,Q,J,"throw",D)}Q(void 0)})}}var R0=M(),iZ=p(),L0=x(),C4=L0.style,j4=L0.clear,mZ=L0.figures,b4=F(),oZ=b4.erase,_4=b4.cursor,i=N4(),k4=i.DatePart,tZ=i.Meridiem,sZ=i.Day,rZ=i.Hours,aZ=i.Milliseconds,eZ=i.Minutes,Y7=i.Month,$7=i.Seconds,Z7=i.Year,H7=/\\(.)|"((?:\\["\\]|[^"])+)"|(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,x4={1:({token:Y})=>Y.replace(/\\(.)/g,"$1"),2:(Y)=>new sZ(Y),3:(Y)=>new Y7(Y),4:(Y)=>new Z7(Y),5:(Y)=>new tZ(Y),6:(Y)=>new rZ(Y),7:(Y)=>new eZ(Y),8:(Y)=>new $7(Y),9:(Y)=>new aZ(Y)},U7={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 h4 extends iZ{constructor(Y={}){super(Y);this.msg=Y.message,this.cursor=0,this.typed="",this.locales=Object.assign(U7,Y.locales),this._date=Y.initial||new Date,this.errorMsg=Y.error||"Please Enter A Valid Value",this.validator=Y.validate||(()=>!0),this.mask=Y.mask||"YYYY-MM-DD HH:mm:ss",this.clear=j4("",this.out.columns),this.render()}get value(){return this.date}get date(){return this._date}set date(Y){if(Y)this._date.setTime(Y.getTime())}set mask(Y){let $;this.parts=[];while($=H7.exec(Y)){let H=$.shift(),U=$.findIndex((X)=>X!=null);this.parts.push(U in x4?x4[U]({token:$[U]||H,date:this.date,parts:this.parts,locales:this.locales}):$[U]||H)}let Z=this.parts.reduce((H,U)=>{if(typeof U==="string"&&typeof H[H.length-1]==="string")H[H.length-1]+=U;else H.push(U);return H},[]);this.parts.splice(0),this.parts.push(...Z),this.reset()}moveCursor(Y){this.typed="",this.cursor=Y,this.fire()}reset(){this.moveCursor(this.parts.findIndex((Y)=>Y instanceof k4)),this.fire(),this.render()}exit(){this.abort()}abort(){this.done=this.aborted=!0,this.error=!1,this.fire(),this.render(),this.out.write(`
18
+ `),this.close()}validate(){var Y=this;return T4(function*(){let $=yield Y.validator(Y.value);if(typeof $==="string")Y.errorMsg=$,$=!1;Y.error=!$})()}submit(){var Y=this;return T4(function*(){if(yield Y.validate(),Y.error){Y.color="red",Y.fire(),Y.render();return}Y.done=!0,Y.aborted=!1,Y.fire(),Y.render(),Y.out.write(`
19
+ `),Y.close()})()}up(){this.typed="",this.parts[this.cursor].up(),this.render()}down(){this.typed="",this.parts[this.cursor].down(),this.render()}left(){let Y=this.parts[this.cursor].prev();if(Y==null)return this.bell();this.moveCursor(this.parts.indexOf(Y)),this.render()}right(){let Y=this.parts[this.cursor].next();if(Y==null)return this.bell();this.moveCursor(this.parts.indexOf(Y)),this.render()}next(){let Y=this.parts[this.cursor].next();this.moveCursor(Y?this.parts.indexOf(Y):this.parts.findIndex(($)=>$ instanceof k4)),this.render()}_(Y){if(/\d/.test(Y))this.typed+=Y,this.parts[this.cursor].setTo(this.typed),this.render()}render(){if(this.closed)return;if(this.firstRender)this.out.write(_4.hide);else this.out.write(j4(this.outputText,this.out.columns));if(super.render(),this.outputText=[C4.symbol(this.done,this.aborted),R0.bold(this.msg),C4.delimiter(!1),this.parts.reduce((Y,$,Z)=>Y.concat(Z===this.cursor&&!this.done?R0.cyan().underline($.toString()):$),[]).join("")].join(" "),this.error)this.outputText+=this.errorMsg.split(`
20
20
  `).reduce((Y,$,Z)=>Y+`
21
- ${Z?" ":bZ.pointerSmall} ${J0.red().italic($)}`,"");this.out.write(xZ.line+I4.to(0)+this.outputText)}}T4.exports=N4});var w4=z((gU,f4)=>{function j4(Y,$,Z,H,J,U,X){try{var Q=Y[U](X),D=Q.value}catch(K){Z(K);return}if(Q.done)$(D);else Promise.resolve(D).then(H,J)}function k4(Y){return function(){var $=this,Z=arguments;return new Promise(function(H,J){var U=Y.apply($,Z);function X(D){j4(U,H,J,X,Q,"next",D)}function Q(D){j4(U,H,J,X,Q,"throw",D)}X(void 0)})}}var w1=S(),nZ=v(),x4=F(),g1=x4.cursor,pZ=x4.erase,v1=T(),Q0=v1.style,mZ=v1.figures,_4=v1.clear,iZ=v1.lines,oZ=/[0-9]/,D0=(Y)=>Y!==void 0,b4=(Y,$)=>{let Z=Math.pow(10,$);return Math.round(Y*Z)/Z};class h4 extends nZ{constructor(Y={}){super(Y);this.transform=Q0.render(Y.style),this.msg=Y.message,this.initial=D0(Y.initial)?Y.initial:"",this.float=!!Y.float,this.round=Y.round||2,this.inc=Y.increment||1,this.min=D0(Y.min)?Y.min:-1/0,this.max=D0(Y.max)?Y.max:1/0,this.errorMsg=Y.error||"Please Enter A Valid Value",this.validator=Y.validate||(()=>!0),this.color="cyan",this.value="",this.typed="",this.lastHit=0,this.render()}set value(Y){if(!Y&&Y!==0)this.placeholder=!0,this.rendered=w1.gray(this.transform.render(`${this.initial}`)),this._value="";else this.placeholder=!1,this.rendered=this.transform.render(`${b4(Y,this.round)}`),this._value=b4(Y,this.round);this.fire()}get value(){return this._value}parse(Y){return this.float?parseFloat(Y):parseInt(Y)}valid(Y){return Y==="-"||Y==="."&&this.float||oZ.test(Y)}reset(){this.typed="",this.value="",this.fire(),this.render()}exit(){this.abort()}abort(){let Y=this.value;this.value=Y!==""?Y:this.initial,this.done=this.aborted=!0,this.error=!1,this.fire(),this.render(),this.out.write(`
22
- `),this.close()}validate(){var Y=this;return k4(function*(){let $=yield Y.validator(Y.value);if(typeof $==="string")Y.errorMsg=$,$=!1;Y.error=!$})()}submit(){var Y=this;return k4(function*(){if(yield Y.validate(),Y.error){Y.color="red",Y.fire(),Y.render();return}let $=Y.value;Y.value=$!==""?$:Y.initial,Y.done=!0,Y.aborted=!1,Y.error=!1,Y.fire(),Y.render(),Y.out.write(`
23
- `),Y.close()})()}up(){if(this.typed="",this.value==="")this.value=this.min-this.inc;if(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;if(this.value<=this.min)return this.bell();this.value-=this.inc,this.color="cyan",this.fire(),this.render()}delete(){let Y=this.value.toString();if(Y.length===0)return this.bell();if(this.value=this.parse(Y=Y.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()}_(Y,$){if(!this.valid(Y))return this.bell();let Z=Date.now();if(Z-this.lastHit>1000)this.typed="";if(this.typed+=Y,this.lastHit=Z,this.color="cyan",Y===".")return this.fire();if(this.value=Math.min(this.parse(this.typed),this.max),this.value>this.max)this.value=this.max;if(this.value<this.min)this.value=this.min;this.fire(),this.render()}render(){if(this.closed)return;if(!this.firstRender){if(this.outputError)this.out.write(g1.down(iZ(this.outputError,this.out.columns)-1)+_4(this.outputError,this.out.columns));this.out.write(_4(this.outputText,this.out.columns))}if(super.render(),this.outputError="",this.outputText=[Q0.symbol(this.done,this.aborted),w1.bold(this.msg),Q0.delimiter(this.done),!this.done||!this.done&&!this.placeholder?w1[this.color]().underline(this.rendered):this.rendered].join(" "),this.error)this.outputError+=this.errorMsg.split(`
21
+ ${Z?" ":mZ.pointerSmall} ${R0.red().italic($)}`,"");this.out.write(oZ.line+_4.to(0)+this.outputText)}}f4.exports=h4});var p4=B((G5,l4)=>{function v4(Y,$,Z,H,U,X,Q){try{var J=Y[X](Q),D=J.value}catch(W){Z(W);return}if(J.done)$(D);else Promise.resolve(D).then(H,U)}function g4(Y){return function(){var $=this,Z=arguments;return new Promise(function(H,U){var X=Y.apply($,Z);function Q(D){v4(X,H,U,Q,J,"next",D)}function J(D){v4(X,H,U,Q,J,"throw",D)}Q(void 0)})}}var d1=M(),X7=p(),u4=F(),u1=u4.cursor,Q7=u4.erase,c1=x(),S0=c1.style,J7=c1.figures,y4=c1.clear,D7=c1.lines,z7=/[0-9]/,M0=(Y)=>Y!==void 0,d4=(Y,$)=>{let Z=Math.pow(10,$);return Math.round(Y*Z)/Z};class c4 extends X7{constructor(Y={}){super(Y);this.transform=S0.render(Y.style),this.msg=Y.message,this.initial=M0(Y.initial)?Y.initial:"",this.float=!!Y.float,this.round=Y.round||2,this.inc=Y.increment||1,this.min=M0(Y.min)?Y.min:-1/0,this.max=M0(Y.max)?Y.max:1/0,this.errorMsg=Y.error||"Please Enter A Valid Value",this.validator=Y.validate||(()=>!0),this.color="cyan",this.value="",this.typed="",this.lastHit=0,this.render()}set value(Y){if(!Y&&Y!==0)this.placeholder=!0,this.rendered=d1.gray(this.transform.render(`${this.initial}`)),this._value="";else this.placeholder=!1,this.rendered=this.transform.render(`${d4(Y,this.round)}`),this._value=d4(Y,this.round);this.fire()}get value(){return this._value}parse(Y){return this.float?parseFloat(Y):parseInt(Y)}valid(Y){return Y==="-"||Y==="."&&this.float||z7.test(Y)}reset(){this.typed="",this.value="",this.fire(),this.render()}exit(){this.abort()}abort(){let Y=this.value;this.value=Y!==""?Y:this.initial,this.done=this.aborted=!0,this.error=!1,this.fire(),this.render(),this.out.write(`
22
+ `),this.close()}validate(){var Y=this;return g4(function*(){let $=yield Y.validator(Y.value);if(typeof $==="string")Y.errorMsg=$,$=!1;Y.error=!$})()}submit(){var Y=this;return g4(function*(){if(yield Y.validate(),Y.error){Y.color="red",Y.fire(),Y.render();return}let $=Y.value;Y.value=$!==""?$:Y.initial,Y.done=!0,Y.aborted=!1,Y.error=!1,Y.fire(),Y.render(),Y.out.write(`
23
+ `),Y.close()})()}up(){if(this.typed="",this.value==="")this.value=this.min-this.inc;if(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;if(this.value<=this.min)return this.bell();this.value-=this.inc,this.color="cyan",this.fire(),this.render()}delete(){let Y=this.value.toString();if(Y.length===0)return this.bell();if(this.value=this.parse(Y=Y.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()}_(Y,$){if(!this.valid(Y))return this.bell();let Z=Date.now();if(Z-this.lastHit>1000)this.typed="";if(this.typed+=Y,this.lastHit=Z,this.color="cyan",Y===".")return this.fire();if(this.value=Math.min(this.parse(this.typed),this.max),this.value>this.max)this.value=this.max;if(this.value<this.min)this.value=this.min;this.fire(),this.render()}render(){if(this.closed)return;if(!this.firstRender){if(this.outputError)this.out.write(u1.down(D7(this.outputError,this.out.columns)-1)+y4(this.outputError,this.out.columns));this.out.write(y4(this.outputText,this.out.columns))}if(super.render(),this.outputError="",this.outputText=[S0.symbol(this.done,this.aborted),d1.bold(this.msg),S0.delimiter(this.done),!this.done||!this.done&&!this.placeholder?d1[this.color]().underline(this.rendered):this.rendered].join(" "),this.error)this.outputError+=this.errorMsg.split(`
24
24
  `).reduce((Y,$,Z)=>Y+`
25
- ${Z?" ":mZ.pointerSmall} ${w1.red().italic($)}`,"");this.out.write(pZ.line+g1.to(0)+this.outputText+g1.save+this.outputError+g1.restore)}}f4.exports=h4});var z0=z((vU,d4)=>{var _=S(),sZ=F(),tZ=sZ.cursor,aZ=v(),E1=T(),g4=E1.clear,s=E1.figures,v4=E1.style,rZ=E1.wrap,eZ=E1.entriesToDisplay;class y4 extends aZ{constructor(Y={}){super(Y);if(this.msg=Y.message,this.cursor=Y.cursor||0,this.scrollIndex=Y.cursor||0,this.hint=Y.hint||"",this.warn=Y.warn||"- This option is disabled -",this.minSelected=Y.min,this.showMinError=!1,this.maxChoices=Y.max,this.instructions=Y.instructions,this.optionsPerPage=Y.optionsPerPage||10,this.value=Y.choices.map(($,Z)=>{if(typeof $==="string")$={title:$,value:Z};return{title:$&&($.title||$.value||$),description:$&&$.description,value:$&&($.value===void 0?Z:$.value),selected:$&&$.selected,disabled:$&&$.disabled}}),this.clear=g4("",this.out.columns),!Y.overrideRender)this.render()}reset(){this.value.map((Y)=>!Y.selected),this.cursor=0,this.fire(),this.render()}selected(){return this.value.filter((Y)=>Y.selected)}exit(){this.abort()}abort(){this.done=this.aborted=!0,this.fire(),this.render(),this.out.write(`
25
+ ${Z?" ":J7.pointerSmall} ${d1.red().italic($)}`,"");this.out.write(Q7.line+u1.to(0)+this.outputText+u1.save+this.outputError+u1.restore)}}l4.exports=c4});var F0=B((R5,o4)=>{var v=M(),K7=F(),W7=K7.cursor,B7=p(),I1=x(),n4=I1.clear,H1=I1.figures,i4=I1.style,E7=I1.wrap,G7=I1.entriesToDisplay;class m4 extends B7{constructor(Y={}){super(Y);if(this.msg=Y.message,this.cursor=Y.cursor||0,this.scrollIndex=Y.cursor||0,this.hint=Y.hint||"",this.warn=Y.warn||"- This option is disabled -",this.minSelected=Y.min,this.showMinError=!1,this.maxChoices=Y.max,this.instructions=Y.instructions,this.optionsPerPage=Y.optionsPerPage||10,this.value=Y.choices.map(($,Z)=>{if(typeof $==="string")$={title:$,value:Z};return{title:$&&($.title||$.value||$),description:$&&$.description,value:$&&($.value===void 0?Z:$.value),selected:$&&$.selected,disabled:$&&$.disabled}}),this.clear=n4("",this.out.columns),!Y.overrideRender)this.render()}reset(){this.value.map((Y)=>!Y.selected),this.cursor=0,this.fire(),this.render()}selected(){return this.value.filter((Y)=>Y.selected)}exit(){this.abort()}abort(){this.done=this.aborted=!0,this.fire(),this.render(),this.out.write(`
26
26
  `),this.close()}submit(){let Y=this.value.filter(($)=>$.selected);if(this.minSelected&&Y.length<this.minSelected)this.showMinError=!0,this.render();else this.done=!0,this.aborted=!1,this.fire(),this.render(),this.out.write(`
27
27
  `),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(){if(this.cursor===0)this.cursor=this.value.length-1;else this.cursor--;this.render()}down(){if(this.cursor===this.value.length-1)this.cursor=0;else this.cursor++;this.render()}left(){this.value[this.cursor].selected=!1,this.render()}right(){if(this.value.filter((Y)=>Y.selected).length>=this.maxChoices)return this.bell();this.value[this.cursor].selected=!0,this.render()}handleSpaceToggle(){let Y=this.value[this.cursor];if(Y.selected)Y.selected=!1,this.render();else if(Y.disabled||this.value.filter(($)=>$.selected).length>=this.maxChoices)return this.bell();else Y.selected=!0,this.render()}toggleAll(){if(this.maxChoices!==void 0||this.value[this.cursor].disabled)return this.bell();let Y=!this.value[this.cursor].selected;this.value.filter(($)=>!$.disabled).forEach(($)=>$.selected=Y),this.render()}_(Y,$){if(Y===" ")this.handleSpaceToggle();else if(Y==="a")this.toggleAll();else return this.bell()}renderInstructions(){if(this.instructions===void 0||this.instructions){if(typeof this.instructions==="string")return this.instructions;return`
28
28
  Instructions:
29
- ${s.arrowUp}/${s.arrowDown}: Highlight option
30
- ${s.arrowLeft}/${s.arrowRight}/[space]: Toggle selection
29
+ ${H1.arrowUp}/${H1.arrowDown}: Highlight option
30
+ ${H1.arrowLeft}/${H1.arrowRight}/[space]: Toggle selection
31
31
  `+(this.maxChoices===void 0?` a: Toggle all
32
- `:"")+" enter/return: Complete answer"}return""}renderOption(Y,$,Z,H){let J=($.selected?_.green(s.radioOn):s.radioOff)+" "+H+" ",U,X;if($.disabled)U=Y===Z?_.gray().underline($.title):_.strikethrough().gray($.title);else if(U=Y===Z?_.cyan().underline($.title):$.title,Y===Z&&$.description){if(X=` - ${$.description}`,J.length+U.length+X.length>=this.out.columns||$.description.split(/\r?\n/).length>1)X=`
33
- `+rZ($.description,{margin:J.length,width:this.out.columns})}return J+U+_.gray(X||"")}paginateOptions(Y){if(Y.length===0)return _.red("No matches for this query.");let $=eZ(this.cursor,Y.length,this.optionsPerPage),Z=$.startIndex,H=$.endIndex,J,U=[];for(let X=Z;X<H;X++){if(X===Z&&Z>0)J=s.arrowUp;else if(X===H-1&&H<Y.length)J=s.arrowDown;else J=" ";U.push(this.renderOption(this.cursor,Y[X],X,J))}return`
34
- `+U.join(`
35
- `)}renderOptions(Y){if(!this.done)return this.paginateOptions(Y);return""}renderDoneOrInstructions(){if(this.done)return this.value.filter(($)=>$.selected).map(($)=>$.title).join(", ");let Y=[_.gray(this.hint),this.renderInstructions()];if(this.value[this.cursor].disabled)Y.push(_.yellow(this.warn));return Y.join(" ")}render(){if(this.closed)return;if(this.firstRender)this.out.write(tZ.hide);super.render();let Y=[v4.symbol(this.done,this.aborted),_.bold(this.msg),v4.delimiter(!1),this.renderDoneOrInstructions()].join(" ");if(this.showMinError)Y+=_.red(`You must select a minimum of ${this.minSelected} choices.`),this.showMinError=!1;Y+=this.renderOptions(this.value),this.out.write(this.clear+Y),this.clear=g4(Y,this.out.columns)}}d4.exports=y4});var o4=z((yU,i4)=>{function u4(Y,$,Z,H,J,U,X){try{var Q=Y[U](X),D=Q.value}catch(K){Z(K);return}if(Q.done)$(D);else Promise.resolve(D).then(H,J)}function YH(Y){return function(){var $=this,Z=arguments;return new Promise(function(H,J){var U=Y.apply($,Z);function X(D){u4(U,H,J,X,Q,"next",D)}function Q(D){u4(U,H,J,X,Q,"throw",D)}X(void 0)})}}var G1=S(),$H=v(),p4=F(),ZH=p4.erase,c4=p4.cursor,S1=T(),K0=S1.style,l4=S1.clear,B0=S1.figures,HH=S1.wrap,UH=S1.entriesToDisplay,n4=(Y,$)=>Y[$]&&(Y[$].value||Y[$].title||Y[$]),JH=(Y,$)=>Y[$]&&(Y[$].title||Y[$].value||Y[$]),XH=(Y,$)=>{let Z=Y.findIndex((H)=>H.value===$||H.title===$);return Z>-1?Z:void 0};class m4 extends $H{constructor(Y={}){super(Y);this.msg=Y.message,this.suggest=Y.suggest,this.choices=Y.choices,this.initial=typeof Y.initial==="number"?Y.initial:XH(Y.choices,Y.initial),this.select=this.initial||Y.cursor||0,this.i18n={noMatches:Y.noMatches||"no matches found"},this.fallback=Y.fallback||this.initial,this.clearFirst=Y.clearFirst||!1,this.suggestions=[],this.input="",this.limit=Y.limit||10,this.cursor=0,this.transform=K0.render(Y.style),this.scale=this.transform.scale,this.render=this.render.bind(this),this.complete=this.complete.bind(this),this.clear=l4("",this.out.columns),this.complete(this.render),this.render()}set fallback(Y){this._fb=Number.isSafeInteger(parseInt(Y))?parseInt(Y):Y}get fallback(){let Y;if(typeof this._fb==="number")Y=this.choices[this._fb];else if(typeof this._fb==="string")Y={title:this._fb};return Y||this._fb||{title:this.i18n.noMatches}}moveSelect(Y){if(this.select=Y,this.suggestions.length>0)this.value=n4(this.suggestions,Y);else this.value=this.fallback.value;this.fire()}complete(Y){var $=this;return YH(function*(){let Z=$.completing=$.suggest($.input,$.choices),H=yield Z;if($.completing!==Z)return;$.suggestions=H.map((U,X,Q)=>({title:JH(Q,X),value:n4(Q,X),description:U.description})),$.completing=!1;let J=Math.max(H.length-1,0);$.moveSelect(Math.min(J,$.select)),Y&&Y()})()}reset(){this.input="",this.complete(()=>{this.moveSelect(this.initial!==void 0?this.initial:0),this.render()}),this.render()}exit(){if(this.clearFirst&&this.input.length>0)this.reset();else this.done=this.exited=!0,this.aborted=!1,this.fire(),this.render(),this.out.write(`
32
+ `:"")+" enter/return: Complete answer"}return""}renderOption(Y,$,Z,H){let U=($.selected?v.green(H1.radioOn):H1.radioOff)+" "+H+" ",X,Q;if($.disabled)X=Y===Z?v.gray().underline($.title):v.strikethrough().gray($.title);else if(X=Y===Z?v.cyan().underline($.title):$.title,Y===Z&&$.description){if(Q=` - ${$.description}`,U.length+X.length+Q.length>=this.out.columns||$.description.split(/\r?\n/).length>1)Q=`
33
+ `+E7($.description,{margin:U.length,width:this.out.columns})}return U+X+v.gray(Q||"")}paginateOptions(Y){if(Y.length===0)return v.red("No matches for this query.");let $=G7(this.cursor,Y.length,this.optionsPerPage),Z=$.startIndex,H=$.endIndex,U,X=[];for(let Q=Z;Q<H;Q++){if(Q===Z&&Z>0)U=H1.arrowUp;else if(Q===H-1&&H<Y.length)U=H1.arrowDown;else U=" ";X.push(this.renderOption(this.cursor,Y[Q],Q,U))}return`
34
+ `+X.join(`
35
+ `)}renderOptions(Y){if(!this.done)return this.paginateOptions(Y);return""}renderDoneOrInstructions(){if(this.done)return this.value.filter(($)=>$.selected).map(($)=>$.title).join(", ");let Y=[v.gray(this.hint),this.renderInstructions()];if(this.value[this.cursor].disabled)Y.push(v.yellow(this.warn));return Y.join(" ")}render(){if(this.closed)return;if(this.firstRender)this.out.write(W7.hide);super.render();let Y=[i4.symbol(this.done,this.aborted),v.bold(this.msg),i4.delimiter(!1),this.renderDoneOrInstructions()].join(" ");if(this.showMinError)Y+=v.red(`You must select a minimum of ${this.minSelected} choices.`),this.showMinError=!1;Y+=this.renderOptions(this.value),this.out.write(this.clear+Y),this.clear=n4(Y,this.out.columns)}}o4.exports=m4});var Z9=B((L5,$9)=>{function t4(Y,$,Z,H,U,X,Q){try{var J=Y[X](Q),D=J.value}catch(W){Z(W);return}if(J.done)$(D);else Promise.resolve(D).then(H,U)}function R7(Y){return function(){var $=this,Z=arguments;return new Promise(function(H,U){var X=Y.apply($,Z);function Q(D){t4(X,H,U,Q,J,"next",D)}function J(D){t4(X,H,U,Q,J,"throw",D)}Q(void 0)})}}var A1=M(),L7=p(),e4=F(),S7=e4.erase,s4=e4.cursor,q1=x(),V0=q1.style,r4=q1.clear,O0=q1.figures,M7=q1.wrap,F7=q1.entriesToDisplay,a4=(Y,$)=>Y[$]&&(Y[$].value||Y[$].title||Y[$]),V7=(Y,$)=>Y[$]&&(Y[$].title||Y[$].value||Y[$]),O7=(Y,$)=>{let Z=Y.findIndex((H)=>H.value===$||H.title===$);return Z>-1?Z:void 0};class Y9 extends L7{constructor(Y={}){super(Y);this.msg=Y.message,this.suggest=Y.suggest,this.choices=Y.choices,this.initial=typeof Y.initial==="number"?Y.initial:O7(Y.choices,Y.initial),this.select=this.initial||Y.cursor||0,this.i18n={noMatches:Y.noMatches||"no matches found"},this.fallback=Y.fallback||this.initial,this.clearFirst=Y.clearFirst||!1,this.suggestions=[],this.input="",this.limit=Y.limit||10,this.cursor=0,this.transform=V0.render(Y.style),this.scale=this.transform.scale,this.render=this.render.bind(this),this.complete=this.complete.bind(this),this.clear=r4("",this.out.columns),this.complete(this.render),this.render()}set fallback(Y){this._fb=Number.isSafeInteger(parseInt(Y))?parseInt(Y):Y}get fallback(){let Y;if(typeof this._fb==="number")Y=this.choices[this._fb];else if(typeof this._fb==="string")Y={title:this._fb};return Y||this._fb||{title:this.i18n.noMatches}}moveSelect(Y){if(this.select=Y,this.suggestions.length>0)this.value=a4(this.suggestions,Y);else this.value=this.fallback.value;this.fire()}complete(Y){var $=this;return R7(function*(){let Z=$.completing=$.suggest($.input,$.choices),H=yield Z;if($.completing!==Z)return;$.suggestions=H.map((X,Q,J)=>({title:V7(J,Q),value:a4(J,Q),description:X.description})),$.completing=!1;let U=Math.max(H.length-1,0);$.moveSelect(Math.min(U,$.select)),Y&&Y()})()}reset(){this.input="",this.complete(()=>{this.moveSelect(this.initial!==void 0?this.initial:0),this.render()}),this.render()}exit(){if(this.clearFirst&&this.input.length>0)this.reset();else this.done=this.exited=!0,this.aborted=!1,this.fire(),this.render(),this.out.write(`
36
36
  `),this.close()}abort(){this.done=this.aborted=!0,this.exited=!1,this.fire(),this.render(),this.out.write(`
37
37
  `),this.close()}submit(){this.done=!0,this.aborted=this.exited=!1,this.fire(),this.render(),this.out.write(`
38
- `),this.close()}_(Y,$){let Z=this.input.slice(0,this.cursor),H=this.input.slice(this.cursor);this.input=`${Z}${Y}${H}`,this.cursor=Z.length+1,this.complete(this.render),this.render()}delete(){if(this.cursor===0)return this.bell();let Y=this.input.slice(0,this.cursor-1),$=this.input.slice(this.cursor);this.input=`${Y}${$}`,this.complete(this.render),this.cursor=this.cursor-1,this.render()}deleteForward(){if(this.cursor*this.scale>=this.rendered.length)return this.bell();let Y=this.input.slice(0,this.cursor),$=this.input.slice(this.cursor+1);this.input=`${Y}${$}`,this.complete(this.render),this.render()}first(){this.moveSelect(0),this.render()}last(){this.moveSelect(this.suggestions.length-1),this.render()}up(){if(this.select===0)this.moveSelect(this.suggestions.length-1);else this.moveSelect(this.select-1);this.render()}down(){if(this.select===this.suggestions.length-1)this.moveSelect(0);else this.moveSelect(this.select+1);this.render()}next(){if(this.select===this.suggestions.length-1)this.moveSelect(0);else 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(Y,$,Z,H){let J,U=Z?B0.arrowUp:H?B0.arrowDown:" ",X=$?G1.cyan().underline(Y.title):Y.title;if(U=($?G1.cyan(B0.pointer)+" ":" ")+U,Y.description){if(J=` - ${Y.description}`,U.length+X.length+J.length>=this.out.columns||Y.description.split(/\r?\n/).length>1)J=`
39
- `+HH(Y.description,{margin:3,width:this.out.columns})}return U+" "+X+G1.gray(J||"")}render(){if(this.closed)return;if(this.firstRender)this.out.write(c4.hide);else this.out.write(l4(this.outputText,this.out.columns));super.render();let Y=UH(this.select,this.choices.length,this.limit),$=Y.startIndex,Z=Y.endIndex;if(this.outputText=[K0.symbol(this.done,this.aborted,this.exited),G1.bold(this.msg),K0.delimiter(this.completing),this.done&&this.suggestions[this.select]?this.suggestions[this.select].title:this.rendered=this.transform.render(this.input)].join(" "),!this.done){let H=this.suggestions.slice($,Z).map((J,U)=>this.renderOption(J,this.select===U+$,U===0&&$>0,U+$===Z-1&&Z<this.choices.length)).join(`
38
+ `),this.close()}_(Y,$){let Z=this.input.slice(0,this.cursor),H=this.input.slice(this.cursor);this.input=`${Z}${Y}${H}`,this.cursor=Z.length+1,this.complete(this.render),this.render()}delete(){if(this.cursor===0)return this.bell();let Y=this.input.slice(0,this.cursor-1),$=this.input.slice(this.cursor);this.input=`${Y}${$}`,this.complete(this.render),this.cursor=this.cursor-1,this.render()}deleteForward(){if(this.cursor*this.scale>=this.rendered.length)return this.bell();let Y=this.input.slice(0,this.cursor),$=this.input.slice(this.cursor+1);this.input=`${Y}${$}`,this.complete(this.render),this.render()}first(){this.moveSelect(0),this.render()}last(){this.moveSelect(this.suggestions.length-1),this.render()}up(){if(this.select===0)this.moveSelect(this.suggestions.length-1);else this.moveSelect(this.select-1);this.render()}down(){if(this.select===this.suggestions.length-1)this.moveSelect(0);else this.moveSelect(this.select+1);this.render()}next(){if(this.select===this.suggestions.length-1)this.moveSelect(0);else 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(Y,$,Z,H){let U,X=Z?O0.arrowUp:H?O0.arrowDown:" ",Q=$?A1.cyan().underline(Y.title):Y.title;if(X=($?A1.cyan(O0.pointer)+" ":" ")+X,Y.description){if(U=` - ${Y.description}`,X.length+Q.length+U.length>=this.out.columns||Y.description.split(/\r?\n/).length>1)U=`
39
+ `+M7(Y.description,{margin:3,width:this.out.columns})}return X+" "+Q+A1.gray(U||"")}render(){if(this.closed)return;if(this.firstRender)this.out.write(s4.hide);else this.out.write(r4(this.outputText,this.out.columns));super.render();let Y=F7(this.select,this.choices.length,this.limit),$=Y.startIndex,Z=Y.endIndex;if(this.outputText=[V0.symbol(this.done,this.aborted,this.exited),A1.bold(this.msg),V0.delimiter(this.completing),this.done&&this.suggestions[this.select]?this.suggestions[this.select].title:this.rendered=this.transform.render(this.input)].join(" "),!this.done){let H=this.suggestions.slice($,Z).map((U,X)=>this.renderOption(U,this.select===X+$,X===0&&$>0,X+$===Z-1&&Z<this.choices.length)).join(`
40
40
  `);this.outputText+=`
41
- `+(H||G1.gray(this.fallback.title))}this.out.write(ZH.line+c4.to(0)+this.outputText)}}i4.exports=m4});var e4=z((dU,r4)=>{var u=S(),QH=F(),DH=QH.cursor,zH=z0(),W0=T(),s4=W0.clear,t4=W0.style,J1=W0.figures;class a4 extends zH{constructor(Y={}){Y.overrideRender=!0;super(Y);this.inputValue="",this.clear=s4("",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(){if(this.cursor===0)this.cursor=this.filteredOptions.length-1;else this.cursor--;this.render()}down(){if(this.cursor===this.filteredOptions.length-1)this.cursor=0;else this.cursor++;this.render()}left(){this.filteredOptions[this.cursor].selected=!1,this.render()}right(){if(this.value.filter((Y)=>Y.selected).length>=this.maxChoices)return this.bell();this.filteredOptions[this.cursor].selected=!0,this.render()}delete(){if(this.inputValue.length)this.inputValue=this.inputValue.substr(0,this.inputValue.length-1),this.updateFilteredOptions()}updateFilteredOptions(){let Y=this.filteredOptions[this.cursor];this.filteredOptions=this.value.filter((Z)=>{if(this.inputValue){if(typeof Z.title==="string"){if(Z.title.toLowerCase().includes(this.inputValue.toLowerCase()))return!0}if(typeof Z.value==="string"){if(Z.value.toLowerCase().includes(this.inputValue.toLowerCase()))return!0}return!1}return!0});let $=this.filteredOptions.findIndex((Z)=>Z===Y);this.cursor=$<0?0:$,this.render()}handleSpaceToggle(){let Y=this.filteredOptions[this.cursor];if(Y.selected)Y.selected=!1,this.render();else if(Y.disabled||this.value.filter(($)=>$.selected).length>=this.maxChoices)return this.bell();else Y.selected=!0,this.render()}handleInputChange(Y){this.inputValue=this.inputValue+Y,this.updateFilteredOptions()}_(Y,$){if(Y===" ")this.handleSpaceToggle();else this.handleInputChange(Y)}renderInstructions(){if(this.instructions===void 0||this.instructions){if(typeof this.instructions==="string")return this.instructions;return`
41
+ `+(H||A1.gray(this.fallback.title))}this.out.write(S7.line+s4.to(0)+this.outputText)}}$9.exports=Y9});var J9=B((S5,Q9)=>{var m=M(),I7=F(),A7=I7.cursor,q7=F0(),I0=x(),H9=I0.clear,U9=I0.style,B1=I0.figures;class X9 extends q7{constructor(Y={}){Y.overrideRender=!0;super(Y);this.inputValue="",this.clear=H9("",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(){if(this.cursor===0)this.cursor=this.filteredOptions.length-1;else this.cursor--;this.render()}down(){if(this.cursor===this.filteredOptions.length-1)this.cursor=0;else this.cursor++;this.render()}left(){this.filteredOptions[this.cursor].selected=!1,this.render()}right(){if(this.value.filter((Y)=>Y.selected).length>=this.maxChoices)return this.bell();this.filteredOptions[this.cursor].selected=!0,this.render()}delete(){if(this.inputValue.length)this.inputValue=this.inputValue.substr(0,this.inputValue.length-1),this.updateFilteredOptions()}updateFilteredOptions(){let Y=this.filteredOptions[this.cursor];this.filteredOptions=this.value.filter((Z)=>{if(this.inputValue){if(typeof Z.title==="string"){if(Z.title.toLowerCase().includes(this.inputValue.toLowerCase()))return!0}if(typeof Z.value==="string"){if(Z.value.toLowerCase().includes(this.inputValue.toLowerCase()))return!0}return!1}return!0});let $=this.filteredOptions.findIndex((Z)=>Z===Y);this.cursor=$<0?0:$,this.render()}handleSpaceToggle(){let Y=this.filteredOptions[this.cursor];if(Y.selected)Y.selected=!1,this.render();else if(Y.disabled||this.value.filter(($)=>$.selected).length>=this.maxChoices)return this.bell();else Y.selected=!0,this.render()}handleInputChange(Y){this.inputValue=this.inputValue+Y,this.updateFilteredOptions()}_(Y,$){if(Y===" ")this.handleSpaceToggle();else this.handleInputChange(Y)}renderInstructions(){if(this.instructions===void 0||this.instructions){if(typeof this.instructions==="string")return this.instructions;return`
42
42
  Instructions:
43
- ${J1.arrowUp}/${J1.arrowDown}: Highlight option
44
- ${J1.arrowLeft}/${J1.arrowRight}/[space]: Toggle selection
43
+ ${B1.arrowUp}/${B1.arrowDown}: Highlight option
44
+ ${B1.arrowLeft}/${B1.arrowRight}/[space]: Toggle selection
45
45
  [a,b,c]/delete: Filter choices
46
46
  enter/return: Complete answer
47
47
  `}return""}renderCurrentInput(){return`
48
- Filtered results for: ${this.inputValue?this.inputValue:u.gray("Enter something to filter")}
49
- `}renderOption(Y,$,Z){let H;if($.disabled)H=Y===Z?u.gray().underline($.title):u.strikethrough().gray($.title);else H=Y===Z?u.cyan().underline($.title):$.title;return($.selected?u.green(J1.radioOn):J1.radioOff)+" "+H}renderDoneOrInstructions(){if(this.done)return this.value.filter(($)=>$.selected).map(($)=>$.title).join(", ");let Y=[u.gray(this.hint),this.renderInstructions(),this.renderCurrentInput()];if(this.filteredOptions.length&&this.filteredOptions[this.cursor].disabled)Y.push(u.yellow(this.warn));return Y.join(" ")}render(){if(this.closed)return;if(this.firstRender)this.out.write(DH.hide);super.render();let Y=[t4.symbol(this.done,this.aborted),u.bold(this.msg),t4.delimiter(!1),this.renderDoneOrInstructions()].join(" ");if(this.showMinError)Y+=u.red(`You must select a minimum of ${this.minSelected} choices.`),this.showMinError=!1;Y+=this.renderOptions(this.filteredOptions),this.out.write(this.clear+Y),this.clear=s4(Y,this.out.columns)}}r4.exports=a4});var Q9=z((uU,X9)=>{var Y9=S(),KH=v(),H9=T(),$9=H9.style,BH=H9.clear,U9=F(),WH=U9.erase,Z9=U9.cursor;class J9 extends KH{constructor(Y={}){super(Y);this.msg=Y.message,this.value=Y.initial,this.initialValue=!!Y.initial,this.yesMsg=Y.yes||"yes",this.yesOption=Y.yesOption||"(Y/n)",this.noMsg=Y.no||"no",this.noOption=Y.noOption||"(y/N)",this.render()}reset(){this.value=this.initialValue,this.fire(),this.render()}exit(){this.abort()}abort(){this.done=this.aborted=!0,this.fire(),this.render(),this.out.write(`
48
+ Filtered results for: ${this.inputValue?this.inputValue:m.gray("Enter something to filter")}
49
+ `}renderOption(Y,$,Z){let H;if($.disabled)H=Y===Z?m.gray().underline($.title):m.strikethrough().gray($.title);else H=Y===Z?m.cyan().underline($.title):$.title;return($.selected?m.green(B1.radioOn):B1.radioOff)+" "+H}renderDoneOrInstructions(){if(this.done)return this.value.filter(($)=>$.selected).map(($)=>$.title).join(", ");let Y=[m.gray(this.hint),this.renderInstructions(),this.renderCurrentInput()];if(this.filteredOptions.length&&this.filteredOptions[this.cursor].disabled)Y.push(m.yellow(this.warn));return Y.join(" ")}render(){if(this.closed)return;if(this.firstRender)this.out.write(A7.hide);super.render();let Y=[U9.symbol(this.done,this.aborted),m.bold(this.msg),U9.delimiter(!1),this.renderDoneOrInstructions()].join(" ");if(this.showMinError)Y+=m.red(`You must select a minimum of ${this.minSelected} choices.`),this.showMinError=!1;Y+=this.renderOptions(this.filteredOptions),this.out.write(this.clear+Y),this.clear=H9(Y,this.out.columns)}}Q9.exports=X9});var R9=B((M5,G9)=>{var D9=M(),N7=p(),W9=x(),z9=W9.style,P7=W9.clear,B9=F(),T7=B9.erase,K9=B9.cursor;class E9 extends N7{constructor(Y={}){super(Y);this.msg=Y.message,this.value=Y.initial,this.initialValue=!!Y.initial,this.yesMsg=Y.yes||"yes",this.yesOption=Y.yesOption||"(Y/n)",this.noMsg=Y.no||"no",this.noOption=Y.noOption||"(y/N)",this.render()}reset(){this.value=this.initialValue,this.fire(),this.render()}exit(){this.abort()}abort(){this.done=this.aborted=!0,this.fire(),this.render(),this.out.write(`
50
50
  `),this.close()}submit(){this.value=this.value||!1,this.done=!0,this.aborted=!1,this.fire(),this.render(),this.out.write(`
51
- `),this.close()}_(Y,$){if(Y.toLowerCase()==="y")return this.value=!0,this.submit();if(Y.toLowerCase()==="n")return this.value=!1,this.submit();return this.bell()}render(){if(this.closed)return;if(this.firstRender)this.out.write(Z9.hide);else this.out.write(BH(this.outputText,this.out.columns));super.render(),this.outputText=[$9.symbol(this.done,this.aborted),Y9.bold(this.msg),$9.delimiter(this.done),this.done?this.value?this.yesMsg:this.noMsg:Y9.gray(this.initialValue?this.yesOption:this.noOption)].join(" "),this.out.write(WH.line+Z9.to(0)+this.outputText)}}X9.exports=J9});var z9=z((cU,D9)=>{D9.exports={TextPrompt:b2(),SelectPrompt:g2(),TogglePrompt:n2(),DatePrompt:P4(),NumberPrompt:w4(),MultiselectPrompt:z0(),AutocompletePrompt:o4(),AutocompleteMultiselectPrompt:e4(),ConfirmPrompt:Q9()}});var B9=z((K9)=>{var A=K9,RH=z9(),y1=(Y)=>Y;function b(Y,$,Z={}){return new Promise((H,J)=>{let U=new RH[Y]($),X=Z.onAbort||y1,Q=Z.onSubmit||y1,D=Z.onExit||y1;U.on("state",$.onState||y1),U.on("submit",(K)=>H(Q(K))),U.on("exit",(K)=>H(D(K))),U.on("abort",(K)=>J(X(K)))})}A.text=(Y)=>b("TextPrompt",Y);A.password=(Y)=>{return Y.style="password",A.text(Y)};A.invisible=(Y)=>{return Y.style="invisible",A.text(Y)};A.number=(Y)=>b("NumberPrompt",Y);A.date=(Y)=>b("DatePrompt",Y);A.confirm=(Y)=>b("ConfirmPrompt",Y);A.list=(Y)=>{let $=Y.separator||",";return b("TextPrompt",Y,{onSubmit:(Z)=>Z.split($).map((H)=>H.trim())})};A.toggle=(Y)=>b("TogglePrompt",Y);A.select=(Y)=>b("SelectPrompt",Y);A.multiselect=(Y)=>{Y.choices=[].concat(Y.choices||[]);let $=(Z)=>Z.filter((H)=>H.selected).map((H)=>H.value);return b("MultiselectPrompt",Y,{onAbort:$,onSubmit:$})};A.autocompleteMultiselect=(Y)=>{Y.choices=[].concat(Y.choices||[]);let $=(Z)=>Z.filter((H)=>H.selected).map((H)=>H.value);return b("AutocompleteMultiselectPrompt",Y,{onAbort:$,onSubmit:$})};var LH=(Y,$)=>Promise.resolve($.filter((Z)=>Z.title.slice(0,Y.length).toLowerCase()===Y.toLowerCase()));A.autocomplete=(Y)=>{return Y.suggest=Y.suggest||LH,Y.choices=[].concat(Y.choices||[]),b("AutocompletePrompt",Y)}});var M9=z((nU,F9)=>{function W9(Y,$){var Z=Object.keys(Y);if(Object.getOwnPropertySymbols){var H=Object.getOwnPropertySymbols(Y);if($)H=H.filter(function(J){return Object.getOwnPropertyDescriptor(Y,J).enumerable});Z.push.apply(Z,H)}return Z}function R9(Y){for(var $=1;$<arguments.length;$++){var Z=arguments[$]!=null?arguments[$]:{};if($%2)W9(Object(Z),!0).forEach(function(H){EH(Y,H,Z[H])});else if(Object.getOwnPropertyDescriptors)Object.defineProperties(Y,Object.getOwnPropertyDescriptors(Z));else W9(Object(Z)).forEach(function(H){Object.defineProperty(Y,H,Object.getOwnPropertyDescriptor(Z,H))})}return Y}function EH(Y,$,Z){if($ in Y)Object.defineProperty(Y,$,{value:Z,enumerable:!0,configurable:!0,writable:!0});else Y[$]=Z;return Y}function GH(Y,$){var Z=typeof Symbol!=="undefined"&&Y[Symbol.iterator]||Y["@@iterator"];if(!Z){if(Array.isArray(Y)||(Z=SH(Y))||$&&Y&&typeof Y.length==="number"){if(Z)Y=Z;var H=0,J=function D(){};return{s:J,n:function D(){if(H>=Y.length)return{done:!0};return{done:!1,value:Y[H++]}},e:function D(K){throw K},f:J}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
52
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var U=!0,X=!1,Q;return{s:function D(){Z=Z.call(Y)},n:function D(){var K=Z.next();return U=K.done,K},e:function D(K){X=!0,Q=K},f:function D(){try{if(!U&&Z.return!=null)Z.return()}finally{if(X)throw Q}}}}function SH(Y,$){if(!Y)return;if(typeof Y==="string")return L9(Y,$);var Z=Object.prototype.toString.call(Y).slice(8,-1);if(Z==="Object"&&Y.constructor)Z=Y.constructor.name;if(Z==="Map"||Z==="Set")return Array.from(Y);if(Z==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(Z))return L9(Y,$)}function L9(Y,$){if($==null||$>Y.length)$=Y.length;for(var Z=0,H=new Array($);Z<$;Z++)H[Z]=Y[Z];return H}function E9(Y,$,Z,H,J,U,X){try{var Q=Y[U](X),D=Q.value}catch(K){Z(K);return}if(Q.done)$(D);else Promise.resolve(D).then(H,J)}function G9(Y){return function(){var $=this,Z=arguments;return new Promise(function(H,J){var U=Y.apply($,Z);function X(D){E9(U,H,J,X,Q,"next",D)}function Q(D){E9(U,H,J,X,Q,"throw",D)}X(void 0)})}}var R0=B9(),FH=["suggest","format","onState","validate","onRender","type"],S9=()=>{};function t(){return L0.apply(this,arguments)}function L0(){return L0=G9(function*(Y=[],{onSubmit:$=S9,onCancel:Z=S9}={}){let H={},J=t._override||{};Y=[].concat(Y);let U,X,Q,D,K,e,Y1=function(){var o=G9(function*(g,P1,Y2=!1){if(!Y2&&g.validate&&g.validate(P1)!==!0)return;return g.format?yield g.format(P1,H):P1});return function g(P1,Y2){return o.apply(this,arguments)}}();var G=GH(Y),N;try{for(G.s();!(N=G.n()).done;){X=N.value;var T1=X;if(D=T1.name,K=T1.type,typeof K==="function")K=yield K(U,R9({},H),X),X.type=K;if(!K)continue;for(let o in X){if(FH.includes(o))continue;let g=X[o];X[o]=typeof g==="function"?yield g(U,R9({},H),e):g}if(e=X,typeof X.message!=="string")throw new Error("prompt message is required");var e0=X;if(D=e0.name,K=e0.type,R0[K]===void 0)throw new Error(`prompt type (${K}) is not defined`);if(J[X.name]!==void 0){if(U=yield Y1(X,J[X.name]),U!==void 0){H[D]=U;continue}}try{U=t._injected?MH(t._injected,X.initial):yield R0[K](X),H[D]=U=yield Y1(X,U,!0),Q=yield $(X,U,H)}catch(o){Q=!(yield Z(X,H))}if(Q)return H}}catch(o){G.e(o)}finally{G.f()}return H}),L0.apply(this,arguments)}function MH(Y,$){let Z=Y.shift();if(Z instanceof Error)throw Z;return Z===void 0?$:Z}function OH(Y){t._injected=(t._injected||[]).concat(Y)}function VH(Y){t._override=Object.assign({},Y)}F9.exports=Object.assign(t,{prompt:t,prompts:R0,inject:OH,override:VH})});var V9=z((pU,O9)=>{O9.exports=(Y,$)=>{if(Y.meta&&Y.name!=="escape")return;if(Y.ctrl){if(Y.name==="a")return"first";if(Y.name==="c")return"abort";if(Y.name==="d")return"abort";if(Y.name==="e")return"last";if(Y.name==="g")return"reset"}if($){if(Y.name==="j")return"down";if(Y.name==="k")return"up"}if(Y.name==="return")return"submit";if(Y.name==="enter")return"submit";if(Y.name==="backspace")return"delete";if(Y.name==="delete")return"deleteForward";if(Y.name==="abort")return"abort";if(Y.name==="escape")return"exit";if(Y.name==="tab")return"next";if(Y.name==="pagedown")return"nextPage";if(Y.name==="pageup")return"prevPage";if(Y.name==="home")return"home";if(Y.name==="end")return"end";if(Y.name==="up")return"up";if(Y.name==="down")return"down";if(Y.name==="right")return"right";if(Y.name==="left")return"left";return!1}});var d1=z((mU,I9)=>{I9.exports=(Y)=>{let $=["[\\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("|"),Z=new RegExp($,"g");return typeof Y==="string"?Y.replace(Z,""):Y}});var C9=z((iU,q9)=>{var IH=d1(),{erase:A9,cursor:AH}=F(),qH=(Y)=>[...IH(Y)].length;q9.exports=function(Y,$){if(!$)return A9.line+AH.to(0);let Z=0,H=Y.split(/\r?\n/);for(let J of H)Z+=1+Math.floor(Math.max(qH(J)-1,0)/$);return A9.lines(Z)}});var E0=z((oU,N9)=>{var F1={arrowUp:"\u2191",arrowDown:"\u2193",arrowLeft:"\u2190",arrowRight:"\u2192",radioOn:"\u25C9",radioOff:"\u25EF",tick:"\u2714",cross:"\u2716",ellipsis:"\u2026",pointerSmall:"\u203A",line:"\u2500",pointer:"\u276F"},CH={arrowUp:F1.arrowUp,arrowDown:F1.arrowDown,arrowLeft:F1.arrowLeft,arrowRight:F1.arrowRight,radioOn:"(*)",radioOff:"( )",tick:"\u221A",cross:"\xD7",ellipsis:"...",pointerSmall:"\xBB",line:"\u2500",pointer:">"},NH=process.platform==="win32"?CH:F1;N9.exports=NH});var P9=z((sU,T9)=>{var X1=S(),Z1=E0(),G0=Object.freeze({password:{scale:1,render:(Y)=>"*".repeat(Y.length)},emoji:{scale:2,render:(Y)=>"\uD83D\uDE03".repeat(Y.length)},invisible:{scale:0,render:(Y)=>""},default:{scale:1,render:(Y)=>`${Y}`}}),TH=(Y)=>G0[Y]||G0.default,M1=Object.freeze({aborted:X1.red(Z1.cross),done:X1.green(Z1.tick),exited:X1.yellow(Z1.cross),default:X1.cyan("?")}),PH=(Y,$,Z)=>$?M1.aborted:Z?M1.exited:Y?M1.done:M1.default,jH=(Y)=>X1.gray(Y?Z1.ellipsis:Z1.pointerSmall),kH=(Y,$)=>X1.gray(Y?$?Z1.pointerSmall:"+":Z1.line);T9.exports={styles:G0,render:TH,symbols:M1,symbol:PH,delimiter:jH,item:kH}});var k9=z((tU,j9)=>{var _H=d1();j9.exports=function(Y,$){let Z=String(_H(Y)||"").split(/\r?\n/);if(!$)return Z.length;return Z.map((H)=>Math.ceil(H.length/$)).reduce((H,J)=>H+J)}});var b9=z((aU,_9)=>{_9.exports=(Y,$={})=>{let Z=Number.isSafeInteger(parseInt($.margin))?new Array(parseInt($.margin)).fill(" ").join(""):$.margin||"",H=$.width;return(Y||"").split(/\r?\n/g).map((J)=>J.split(/\s+/g).reduce((U,X)=>{if(X.length+Z.length>=H||U[U.length-1].length+X.length+1<H)U[U.length-1]+=` ${X}`;else U.push(`${Z}${X}`);return U},[Z]).join(`
51
+ `),this.close()}_(Y,$){if(Y.toLowerCase()==="y")return this.value=!0,this.submit();if(Y.toLowerCase()==="n")return this.value=!1,this.submit();return this.bell()}render(){if(this.closed)return;if(this.firstRender)this.out.write(K9.hide);else this.out.write(P7(this.outputText,this.out.columns));super.render(),this.outputText=[z9.symbol(this.done,this.aborted),D9.bold(this.msg),z9.delimiter(this.done),this.done?this.value?this.yesMsg:this.noMsg:D9.gray(this.initialValue?this.yesOption:this.noOption)].join(" "),this.out.write(T7.line+K9.to(0)+this.outputText)}}G9.exports=E9});var S9=B((F5,L9)=>{L9.exports={TextPrompt:d2(),SelectPrompt:n2(),TogglePrompt:a2(),DatePrompt:w4(),NumberPrompt:p4(),MultiselectPrompt:F0(),AutocompletePrompt:Z9(),AutocompleteMultiselectPrompt:J9(),ConfirmPrompt:R9()}});var F9=B((M9)=>{var P=M9,C7=S9(),l1=(Y)=>Y;function g(Y,$,Z={}){return new Promise((H,U)=>{let X=new C7[Y]($),Q=Z.onAbort||l1,J=Z.onSubmit||l1,D=Z.onExit||l1;X.on("state",$.onState||l1),X.on("submit",(W)=>H(J(W))),X.on("exit",(W)=>H(D(W))),X.on("abort",(W)=>U(Q(W)))})}P.text=(Y)=>g("TextPrompt",Y);P.password=(Y)=>{return Y.style="password",P.text(Y)};P.invisible=(Y)=>{return Y.style="invisible",P.text(Y)};P.number=(Y)=>g("NumberPrompt",Y);P.date=(Y)=>g("DatePrompt",Y);P.confirm=(Y)=>g("ConfirmPrompt",Y);P.list=(Y)=>{let $=Y.separator||",";return g("TextPrompt",Y,{onSubmit:(Z)=>Z.split($).map((H)=>H.trim())})};P.toggle=(Y)=>g("TogglePrompt",Y);P.select=(Y)=>g("SelectPrompt",Y);P.multiselect=(Y)=>{Y.choices=[].concat(Y.choices||[]);let $=(Z)=>Z.filter((H)=>H.selected).map((H)=>H.value);return g("MultiselectPrompt",Y,{onAbort:$,onSubmit:$})};P.autocompleteMultiselect=(Y)=>{Y.choices=[].concat(Y.choices||[]);let $=(Z)=>Z.filter((H)=>H.selected).map((H)=>H.value);return g("AutocompleteMultiselectPrompt",Y,{onAbort:$,onSubmit:$})};var j7=(Y,$)=>Promise.resolve($.filter((Z)=>Z.title.slice(0,Y.length).toLowerCase()===Y.toLowerCase()));P.autocomplete=(Y)=>{return Y.suggest=Y.suggest||j7,Y.choices=[].concat(Y.choices||[]),g("AutocompletePrompt",Y)}});var T9=B((O5,P9)=>{function V9(Y,$){var Z=Object.keys(Y);if(Object.getOwnPropertySymbols){var H=Object.getOwnPropertySymbols(Y);if($)H=H.filter(function(U){return Object.getOwnPropertyDescriptor(Y,U).enumerable});Z.push.apply(Z,H)}return Z}function O9(Y){for(var $=1;$<arguments.length;$++){var Z=arguments[$]!=null?arguments[$]:{};if($%2)V9(Object(Z),!0).forEach(function(H){_7(Y,H,Z[H])});else if(Object.getOwnPropertyDescriptors)Object.defineProperties(Y,Object.getOwnPropertyDescriptors(Z));else V9(Object(Z)).forEach(function(H){Object.defineProperty(Y,H,Object.getOwnPropertyDescriptor(Z,H))})}return Y}function _7(Y,$,Z){if($ in Y)Object.defineProperty(Y,$,{value:Z,enumerable:!0,configurable:!0,writable:!0});else Y[$]=Z;return Y}function k7(Y,$){var Z=typeof Symbol!=="undefined"&&Y[Symbol.iterator]||Y["@@iterator"];if(!Z){if(Array.isArray(Y)||(Z=x7(Y))||$&&Y&&typeof Y.length==="number"){if(Z)Y=Z;var H=0,U=function D(){};return{s:U,n:function D(){if(H>=Y.length)return{done:!0};return{done:!1,value:Y[H++]}},e:function D(W){throw W},f:U}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
52
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var X=!0,Q=!1,J;return{s:function D(){Z=Z.call(Y)},n:function D(){var W=Z.next();return X=W.done,W},e:function D(W){Q=!0,J=W},f:function D(){try{if(!X&&Z.return!=null)Z.return()}finally{if(Q)throw J}}}}function x7(Y,$){if(!Y)return;if(typeof Y==="string")return I9(Y,$);var Z=Object.prototype.toString.call(Y).slice(8,-1);if(Z==="Object"&&Y.constructor)Z=Y.constructor.name;if(Z==="Map"||Z==="Set")return Array.from(Y);if(Z==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(Z))return I9(Y,$)}function I9(Y,$){if($==null||$>Y.length)$=Y.length;for(var Z=0,H=new Array($);Z<$;Z++)H[Z]=Y[Z];return H}function A9(Y,$,Z,H,U,X,Q){try{var J=Y[X](Q),D=J.value}catch(W){Z(W);return}if(J.done)$(D);else Promise.resolve(D).then(H,U)}function q9(Y){return function(){var $=this,Z=arguments;return new Promise(function(H,U){var X=Y.apply($,Z);function Q(D){A9(X,H,U,Q,J,"next",D)}function J(D){A9(X,H,U,Q,J,"throw",D)}Q(void 0)})}}var A0=F9(),b7=["suggest","format","onState","validate","onRender","type"],N9=()=>{};function U1(){return q0.apply(this,arguments)}function q0(){return q0=q9(function*(Y=[],{onSubmit:$=N9,onCancel:Z=N9}={}){let H={},U=U1._override||{};Y=[].concat(Y);let X,Q,J,D,W,I,C=function(){var k=q9(function*(j,f,D1=!1){if(!D1&&j.validate&&j.validate(f)!==!0)return;return j.format?yield j.format(f,H):f});return function j(f,D1){return k.apply(this,arguments)}}();var L=k7(Y),N;try{for(L.s();!(N=L.n()).done;){Q=N.value;var J1=Q;if(D=J1.name,W=J1.type,typeof W==="function")W=yield W(X,O9({},H),Q),Q.type=W;if(!W)continue;for(let k in Q){if(b7.includes(k))continue;let j=Q[k];Q[k]=typeof j==="function"?yield j(X,O9({},H),I):j}if(I=Q,typeof Q.message!=="string")throw new Error("prompt message is required");var x1=Q;if(D=x1.name,W=x1.type,A0[W]===void 0)throw new Error(`prompt type (${W}) is not defined`);if(U[Q.name]!==void 0){if(X=yield C(Q,U[Q.name]),X!==void 0){H[D]=X;continue}}try{X=U1._injected?h7(U1._injected,Q.initial):yield A0[W](Q),H[D]=X=yield C(Q,X,!0),J=yield $(Q,X,H)}catch(k){J=!(yield Z(Q,H))}if(J)return H}}catch(k){L.e(k)}finally{L.f()}return H}),q0.apply(this,arguments)}function h7(Y,$){let Z=Y.shift();if(Z instanceof Error)throw Z;return Z===void 0?$:Z}function f7(Y){U1._injected=(U1._injected||[]).concat(Y)}function w7(Y){U1._override=Object.assign({},Y)}P9.exports=Object.assign(U1,{prompt:U1,prompts:A0,inject:f7,override:w7})});var j9=B((I5,C9)=>{C9.exports=(Y,$)=>{if(Y.meta&&Y.name!=="escape")return;if(Y.ctrl){if(Y.name==="a")return"first";if(Y.name==="c")return"abort";if(Y.name==="d")return"abort";if(Y.name==="e")return"last";if(Y.name==="g")return"reset"}if($){if(Y.name==="j")return"down";if(Y.name==="k")return"up"}if(Y.name==="return")return"submit";if(Y.name==="enter")return"submit";if(Y.name==="backspace")return"delete";if(Y.name==="delete")return"deleteForward";if(Y.name==="abort")return"abort";if(Y.name==="escape")return"exit";if(Y.name==="tab")return"next";if(Y.name==="pagedown")return"nextPage";if(Y.name==="pageup")return"prevPage";if(Y.name==="home")return"home";if(Y.name==="end")return"end";if(Y.name==="up")return"up";if(Y.name==="down")return"down";if(Y.name==="right")return"right";if(Y.name==="left")return"left";return!1}});var p1=B((A5,_9)=>{_9.exports=(Y)=>{let $=["[\\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("|"),Z=new RegExp($,"g");return typeof Y==="string"?Y.replace(Z,""):Y}});var b9=B((q5,x9)=>{var v7=p1(),{erase:k9,cursor:g7}=F(),y7=(Y)=>[...v7(Y)].length;x9.exports=function(Y,$){if(!$)return k9.line+g7.to(0);let Z=0,H=Y.split(/\r?\n/);for(let U of H)Z+=1+Math.floor(Math.max(y7(U)-1,0)/$);return k9.lines(Z)}});var N0=B((N5,h9)=>{var N1={arrowUp:"\u2191",arrowDown:"\u2193",arrowLeft:"\u2190",arrowRight:"\u2192",radioOn:"\u25C9",radioOff:"\u25EF",tick:"\u2714",cross:"\u2716",ellipsis:"\u2026",pointerSmall:"\u203A",line:"\u2500",pointer:"\u276F"},d7={arrowUp:N1.arrowUp,arrowDown:N1.arrowDown,arrowLeft:N1.arrowLeft,arrowRight:N1.arrowRight,radioOn:"(*)",radioOff:"( )",tick:"\u221A",cross:"\xD7",ellipsis:"...",pointerSmall:"\xBB",line:"\u2500",pointer:">"},u7=process.platform==="win32"?d7:N1;h9.exports=u7});var w9=B((P5,f9)=>{var E1=M(),K1=N0(),P0=Object.freeze({password:{scale:1,render:(Y)=>"*".repeat(Y.length)},emoji:{scale:2,render:(Y)=>"\uD83D\uDE03".repeat(Y.length)},invisible:{scale:0,render:(Y)=>""},default:{scale:1,render:(Y)=>`${Y}`}}),c7=(Y)=>P0[Y]||P0.default,P1=Object.freeze({aborted:E1.red(K1.cross),done:E1.green(K1.tick),exited:E1.yellow(K1.cross),default:E1.cyan("?")}),l7=(Y,$,Z)=>$?P1.aborted:Z?P1.exited:Y?P1.done:P1.default,p7=(Y)=>E1.gray(Y?K1.ellipsis:K1.pointerSmall),n7=(Y,$)=>E1.gray(Y?$?K1.pointerSmall:"+":K1.line);f9.exports={styles:P0,render:c7,symbols:P1,symbol:l7,delimiter:p7,item:n7}});var g9=B((T5,v9)=>{var i7=p1();v9.exports=function(Y,$){let Z=String(i7(Y)||"").split(/\r?\n/);if(!$)return Z.length;return Z.map((H)=>Math.ceil(H.length/$)).reduce((H,U)=>H+U)}});var d9=B((C5,y9)=>{y9.exports=(Y,$={})=>{let Z=Number.isSafeInteger(parseInt($.margin))?new Array(parseInt($.margin)).fill(" ").join(""):$.margin||"",H=$.width;return(Y||"").split(/\r?\n/g).map((U)=>U.split(/\s+/g).reduce((X,Q)=>{if(Q.length+Z.length>=H||X[X.length-1].length+Q.length+1<H)X[X.length-1]+=` ${Q}`;else X.push(`${Z}${Q}`);return X},[Z]).join(`
53
53
  `)).join(`
54
- `)}});var h9=z((rU,x9)=>{x9.exports=(Y,$,Z)=>{Z=Z||$;let H=Math.min($-Z,Y-Math.floor(Z/2));if(H<0)H=0;let J=Math.min(H+Z,$);return{startIndex:H,endIndex:J}}});var P=z((eU,f9)=>{f9.exports={action:V9(),clear:C9(),style:P9(),strip:d1(),figures:E0(),lines:k9(),wrap:b9(),entriesToDisplay:h9()}});var c=z((Y5,v9)=>{var w9=j1("readline"),{action:bH}=P(),xH=j1("events"),{beep:hH,cursor:fH}=F(),wH=S();class g9 extends xH{constructor(Y={}){super();this.firstRender=!0,this.in=Y.stdin||process.stdin,this.out=Y.stdout||process.stdout,this.onRender=(Y.onRender||(()=>{return})).bind(this);let $=w9.createInterface({input:this.in,escapeCodeTimeout:50});if(w9.emitKeypressEvents(this.in,$),this.in.isTTY)this.in.setRawMode(!0);let Z=["SelectPrompt","MultiselectPrompt"].indexOf(this.constructor.name)>-1,H=(J,U)=>{let X=bH(U,Z);if(X===!1)this._&&this._(J,U);else if(typeof this[X]==="function")this[X](U);else this.bell()};this.close=()=>{if(this.out.write(fH.show),this.in.removeListener("keypress",H),this.in.isTTY)this.in.setRawMode(!1);$.close(),this.emit(this.aborted?"abort":this.exited?"exit":"submit",this.value),this.closed=!0},this.in.on("keypress",H)}fire(){this.emit("state",{value:this.value,aborted:!!this.aborted,exited:!!this.exited})}bell(){this.out.write(hH)}render(){if(this.onRender(wH),this.firstRender)this.firstRender=!1}}v9.exports=g9});var u9=z(($5,d9)=>{var u1=S(),gH=c(),{erase:vH,cursor:O1}=F(),{style:S0,clear:F0,lines:yH,figures:dH}=P();class y9 extends gH{constructor(Y={}){super(Y);this.transform=S0.render(Y.style),this.scale=this.transform.scale,this.msg=Y.message,this.initial=Y.initial||"",this.validator=Y.validate||(()=>!0),this.value="",this.errorMsg=Y.error||"Please Enter A Valid Value",this.cursor=Number(!!this.initial),this.cursorOffset=0,this.clear=F0("",this.out.columns),this.render()}set value(Y){if(!Y&&this.initial)this.placeholder=!0,this.rendered=u1.gray(this.transform.render(this.initial));else this.placeholder=!1,this.rendered=this.transform.render(Y);this._value=Y,this.fire()}get value(){return this._value}reset(){this.value="",this.cursor=Number(!!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(`
54
+ `)}});var c9=B((j5,u9)=>{u9.exports=(Y,$,Z)=>{Z=Z||$;let H=Math.min($-Z,Y-Math.floor(Z/2));if(H<0)H=0;let U=Math.min(H+Z,$);return{startIndex:H,endIndex:U}}});var b=B((_5,l9)=>{l9.exports={action:j9(),clear:b9(),style:w9(),strip:p1(),figures:N0(),lines:g9(),wrap:d9(),entriesToDisplay:c9()}});var o=B((k5,i9)=>{var p9=b1("readline"),{action:m7}=b(),o7=b1("events"),{beep:t7,cursor:s7}=F(),r7=M();class n9 extends o7{constructor(Y={}){super();this.firstRender=!0,this.in=Y.stdin||process.stdin,this.out=Y.stdout||process.stdout,this.onRender=(Y.onRender||(()=>{return})).bind(this);let $=p9.createInterface({input:this.in,escapeCodeTimeout:50});if(p9.emitKeypressEvents(this.in,$),this.in.isTTY)this.in.setRawMode(!0);let Z=["SelectPrompt","MultiselectPrompt"].indexOf(this.constructor.name)>-1,H=(U,X)=>{let Q=m7(X,Z);if(Q===!1)this._&&this._(U,X);else if(typeof this[Q]==="function")this[Q](X);else this.bell()};this.close=()=>{if(this.out.write(s7.show),this.in.removeListener("keypress",H),this.in.isTTY)this.in.setRawMode(!1);$.close(),this.emit(this.aborted?"abort":this.exited?"exit":"submit",this.value),this.closed=!0},this.in.on("keypress",H)}fire(){this.emit("state",{value:this.value,aborted:!!this.aborted,exited:!!this.exited})}bell(){this.out.write(t7)}render(){if(this.onRender(r7),this.firstRender)this.firstRender=!1}}i9.exports=n9});var t9=B((x5,o9)=>{var n1=M(),a7=o(),{erase:e7,cursor:T1}=F(),{style:T0,clear:C0,lines:YH,figures:$H}=b();class m9 extends a7{constructor(Y={}){super(Y);this.transform=T0.render(Y.style),this.scale=this.transform.scale,this.msg=Y.message,this.initial=Y.initial||"",this.validator=Y.validate||(()=>!0),this.value="",this.errorMsg=Y.error||"Please Enter A Valid Value",this.cursor=Number(!!this.initial),this.cursorOffset=0,this.clear=C0("",this.out.columns),this.render()}set value(Y){if(!Y&&this.initial)this.placeholder=!0,this.rendered=n1.gray(this.transform.render(this.initial));else this.placeholder=!1,this.rendered=this.transform.render(Y);this._value=Y,this.fire()}get value(){return this._value}reset(){this.value="",this.cursor=Number(!!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(`
55
55
  `),this.close()}async validate(){let Y=await this.validator(this.value);if(typeof Y==="string")this.errorMsg=Y,Y=!1;this.error=!Y}async submit(){if(this.value=this.value||this.initial,this.cursorOffset=0,this.cursor=this.rendered.length,await this.validate(),this.error){this.red=!0,this.fire(),this.render();return}this.done=!0,this.aborted=!1,this.fire(),this.render(),this.out.write(`
56
- `),this.close()}next(){if(!this.placeholder)return this.bell();this.value=this.initial,this.cursor=this.rendered.length,this.fire(),this.render()}moveCursor(Y){if(this.placeholder)return;this.cursor=this.cursor+Y,this.cursorOffset+=Y}_(Y,$){let Z=this.value.slice(0,this.cursor),H=this.value.slice(this.cursor);this.value=`${Z}${Y}${H}`,this.red=!1,this.cursor=this.placeholder?0:Z.length+1,this.render()}delete(){if(this.isCursorAtStart())return this.bell();let Y=this.value.slice(0,this.cursor-1),$=this.value.slice(this.cursor);if(this.value=`${Y}${$}`,this.red=!1,this.isCursorAtStart())this.cursorOffset=0;else this.cursorOffset++,this.moveCursor(-1);this.render()}deleteForward(){if(this.cursor*this.scale>=this.rendered.length||this.placeholder)return this.bell();let Y=this.value.slice(0,this.cursor),$=this.value.slice(this.cursor+1);if(this.value=`${Y}${$}`,this.red=!1,this.isCursorAtEnd())this.cursorOffset=0;else 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(){if(this.closed)return;if(!this.firstRender){if(this.outputError)this.out.write(O1.down(yH(this.outputError,this.out.columns)-1)+F0(this.outputError,this.out.columns));this.out.write(F0(this.outputText,this.out.columns))}if(super.render(),this.outputError="",this.outputText=[S0.symbol(this.done,this.aborted),u1.bold(this.msg),S0.delimiter(this.done),this.red?u1.red(this.rendered):this.rendered].join(" "),this.error)this.outputError+=this.errorMsg.split(`
56
+ `),this.close()}next(){if(!this.placeholder)return this.bell();this.value=this.initial,this.cursor=this.rendered.length,this.fire(),this.render()}moveCursor(Y){if(this.placeholder)return;this.cursor=this.cursor+Y,this.cursorOffset+=Y}_(Y,$){let Z=this.value.slice(0,this.cursor),H=this.value.slice(this.cursor);this.value=`${Z}${Y}${H}`,this.red=!1,this.cursor=this.placeholder?0:Z.length+1,this.render()}delete(){if(this.isCursorAtStart())return this.bell();let Y=this.value.slice(0,this.cursor-1),$=this.value.slice(this.cursor);if(this.value=`${Y}${$}`,this.red=!1,this.isCursorAtStart())this.cursorOffset=0;else this.cursorOffset++,this.moveCursor(-1);this.render()}deleteForward(){if(this.cursor*this.scale>=this.rendered.length||this.placeholder)return this.bell();let Y=this.value.slice(0,this.cursor),$=this.value.slice(this.cursor+1);if(this.value=`${Y}${$}`,this.red=!1,this.isCursorAtEnd())this.cursorOffset=0;else 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(){if(this.closed)return;if(!this.firstRender){if(this.outputError)this.out.write(T1.down(YH(this.outputError,this.out.columns)-1)+C0(this.outputError,this.out.columns));this.out.write(C0(this.outputText,this.out.columns))}if(super.render(),this.outputError="",this.outputText=[T0.symbol(this.done,this.aborted),n1.bold(this.msg),T0.delimiter(this.done),this.red?n1.red(this.rendered):this.rendered].join(" "),this.error)this.outputError+=this.errorMsg.split(`
57
57
  `).reduce((Y,$,Z)=>Y+`
58
- ${Z?" ":dH.pointerSmall} ${u1.red().italic($)}`,"");this.out.write(vH.line+O1.to(0)+this.outputText+O1.save+this.outputError+O1.restore+O1.move(this.cursorOffset,0))}}d9.exports=y9});var m9=z((Z5,p9)=>{var l=S(),uH=c(),{style:c9,clear:l9,figures:c1,wrap:cH,entriesToDisplay:lH}=P(),{cursor:nH}=F();class n9 extends uH{constructor(Y={}){super(Y);this.msg=Y.message,this.hint=Y.hint||"- Use arrow-keys. Return to submit.",this.warn=Y.warn||"- This option is disabled",this.cursor=Y.initial||0,this.choices=Y.choices.map(($,Z)=>{if(typeof $==="string")$={title:$,value:Z};return{title:$&&($.title||$.value||$),value:$&&($.value===void 0?Z:$.value),description:$&&$.description,selected:$&&$.selected,disabled:$&&$.disabled}}),this.optionsPerPage=Y.optionsPerPage||10,this.value=(this.choices[this.cursor]||{}).value,this.clear=l9("",this.out.columns),this.render()}moveCursor(Y){this.cursor=Y,this.value=this.choices[Y].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(`
58
+ ${Z?" ":$H.pointerSmall} ${n1.red().italic($)}`,"");this.out.write(e7.line+T1.to(0)+this.outputText+T1.save+this.outputError+T1.restore+T1.move(this.cursorOffset,0))}}o9.exports=m9});var YY=B((b5,e9)=>{var t=M(),ZH=o(),{style:s9,clear:r9,figures:i1,wrap:HH,entriesToDisplay:UH}=b(),{cursor:XH}=F();class a9 extends ZH{constructor(Y={}){super(Y);this.msg=Y.message,this.hint=Y.hint||"- Use arrow-keys. Return to submit.",this.warn=Y.warn||"- This option is disabled",this.cursor=Y.initial||0,this.choices=Y.choices.map(($,Z)=>{if(typeof $==="string")$={title:$,value:Z};return{title:$&&($.title||$.value||$),value:$&&($.value===void 0?Z:$.value),description:$&&$.description,selected:$&&$.selected,disabled:$&&$.disabled}}),this.optionsPerPage=Y.optionsPerPage||10,this.value=(this.choices[this.cursor]||{}).value,this.clear=r9("",this.out.columns),this.render()}moveCursor(Y){this.cursor=Y,this.value=this.choices[Y].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(`
59
59
  `),this.close()}submit(){if(!this.selection.disabled)this.done=!0,this.aborted=!1,this.fire(),this.render(),this.out.write(`
60
- `),this.close();else this.bell()}first(){this.moveCursor(0),this.render()}last(){this.moveCursor(this.choices.length-1),this.render()}up(){if(this.cursor===0)this.moveCursor(this.choices.length-1);else this.moveCursor(this.cursor-1);this.render()}down(){if(this.cursor===this.choices.length-1)this.moveCursor(0);else this.moveCursor(this.cursor+1);this.render()}next(){this.moveCursor((this.cursor+1)%this.choices.length),this.render()}_(Y,$){if(Y===" ")return this.submit()}get selection(){return this.choices[this.cursor]}render(){if(this.closed)return;if(this.firstRender)this.out.write(nH.hide);else this.out.write(l9(this.outputText,this.out.columns));super.render();let{startIndex:Y,endIndex:$}=lH(this.cursor,this.choices.length,this.optionsPerPage);if(this.outputText=[c9.symbol(this.done,this.aborted),l.bold(this.msg),c9.delimiter(!1),this.done?this.selection.title:this.selection.disabled?l.yellow(this.warn):l.gray(this.hint)].join(" "),!this.done){this.outputText+=`
61
- `;for(let Z=Y;Z<$;Z++){let H,J,U="",X=this.choices[Z];if(Z===Y&&Y>0)J=c1.arrowUp;else if(Z===$-1&&$<this.choices.length)J=c1.arrowDown;else J=" ";if(X.disabled)H=this.cursor===Z?l.gray().underline(X.title):l.strikethrough().gray(X.title),J=(this.cursor===Z?l.bold().gray(c1.pointer)+" ":" ")+J;else if(H=this.cursor===Z?l.cyan().underline(X.title):X.title,J=(this.cursor===Z?l.cyan(c1.pointer)+" ":" ")+J,X.description&&this.cursor===Z){if(U=` - ${X.description}`,J.length+H.length+U.length>=this.out.columns||X.description.split(/\r?\n/).length>1)U=`
62
- `+cH(X.description,{margin:3,width:this.out.columns})}this.outputText+=`${J} ${H}${l.gray(U)}
63
- `}}this.out.write(this.outputText)}}p9.exports=n9});var a9=z((H5,t9)=>{var l1=S(),pH=c(),{style:i9,clear:mH}=P(),{cursor:o9,erase:iH}=F();class s9 extends pH{constructor(Y={}){super(Y);this.msg=Y.message,this.value=!!Y.initial,this.active=Y.active||"on",this.inactive=Y.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(`
60
+ `),this.close();else this.bell()}first(){this.moveCursor(0),this.render()}last(){this.moveCursor(this.choices.length-1),this.render()}up(){if(this.cursor===0)this.moveCursor(this.choices.length-1);else this.moveCursor(this.cursor-1);this.render()}down(){if(this.cursor===this.choices.length-1)this.moveCursor(0);else this.moveCursor(this.cursor+1);this.render()}next(){this.moveCursor((this.cursor+1)%this.choices.length),this.render()}_(Y,$){if(Y===" ")return this.submit()}get selection(){return this.choices[this.cursor]}render(){if(this.closed)return;if(this.firstRender)this.out.write(XH.hide);else this.out.write(r9(this.outputText,this.out.columns));super.render();let{startIndex:Y,endIndex:$}=UH(this.cursor,this.choices.length,this.optionsPerPage);if(this.outputText=[s9.symbol(this.done,this.aborted),t.bold(this.msg),s9.delimiter(!1),this.done?this.selection.title:this.selection.disabled?t.yellow(this.warn):t.gray(this.hint)].join(" "),!this.done){this.outputText+=`
61
+ `;for(let Z=Y;Z<$;Z++){let H,U,X="",Q=this.choices[Z];if(Z===Y&&Y>0)U=i1.arrowUp;else if(Z===$-1&&$<this.choices.length)U=i1.arrowDown;else U=" ";if(Q.disabled)H=this.cursor===Z?t.gray().underline(Q.title):t.strikethrough().gray(Q.title),U=(this.cursor===Z?t.bold().gray(i1.pointer)+" ":" ")+U;else if(H=this.cursor===Z?t.cyan().underline(Q.title):Q.title,U=(this.cursor===Z?t.cyan(i1.pointer)+" ":" ")+U,Q.description&&this.cursor===Z){if(X=` - ${Q.description}`,U.length+H.length+X.length>=this.out.columns||Q.description.split(/\r?\n/).length>1)X=`
62
+ `+HH(Q.description,{margin:3,width:this.out.columns})}this.outputText+=`${U} ${H}${t.gray(X)}
63
+ `}}this.out.write(this.outputText)}}e9.exports=a9});var XY=B((h5,UY)=>{var m1=M(),QH=o(),{style:$Y,clear:JH}=b(),{cursor:ZY,erase:DH}=F();class HY extends QH{constructor(Y={}){super(Y);this.msg=Y.message,this.value=!!Y.initial,this.active=Y.active||"on",this.inactive=Y.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(`
64
64
  `),this.close()}submit(){this.done=!0,this.aborted=!1,this.fire(),this.render(),this.out.write(`
65
- `),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()}_(Y,$){if(Y===" ")this.value=!this.value;else if(Y==="1")this.value=!0;else if(Y==="0")this.value=!1;else return this.bell();this.render()}render(){if(this.closed)return;if(this.firstRender)this.out.write(o9.hide);else this.out.write(mH(this.outputText,this.out.columns));super.render(),this.outputText=[i9.symbol(this.done,this.aborted),l1.bold(this.msg),i9.delimiter(this.done),this.value?this.inactive:l1.cyan().underline(this.inactive),l1.gray("/"),this.value?l1.cyan().underline(this.active):this.active].join(" "),this.out.write(iH.line+o9.to(0)+this.outputText)}}t9.exports=s9});var x=z((U5,r9)=>{class n1{constructor({token:Y,date:$,parts:Z,locales:H}){this.token=Y,this.date=$||new Date,this.parts=Z||[this],this.locales=H||{}}up(){}down(){}next(){let Y=this.parts.indexOf(this);return this.parts.find(($,Z)=>Z>Y&&$ instanceof n1)}setTo(Y){}prev(){let Y=[].concat(this.parts).reverse(),$=Y.indexOf(this);return Y.find((Z,H)=>H>$&&Z instanceof n1)}toString(){return String(this.date)}}r9.exports=n1});var $Y=z((J5,YY)=>{var oH=x();class e9 extends oH{constructor(Y={}){super(Y)}up(){this.date.setHours((this.date.getHours()+12)%24)}down(){this.up()}toString(){let Y=this.date.getHours()>12?"pm":"am";return/\A/.test(this.token)?Y.toUpperCase():Y}}YY.exports=e9});var UY=z((X5,HY)=>{var sH=x(),tH=(Y)=>{return Y=Y%10,Y===1?"st":Y===2?"nd":Y===3?"rd":"th"};class ZY extends sH{constructor(Y={}){super(Y)}up(){this.date.setDate(this.date.getDate()+1)}down(){this.date.setDate(this.date.getDate()-1)}setTo(Y){this.date.setDate(parseInt(Y.substr(-2)))}toString(){let Y=this.date.getDate(),$=this.date.getDay();return this.token==="DD"?String(Y).padStart(2,"0"):this.token==="Do"?Y+tH(Y):this.token==="d"?$+1:this.token==="ddd"?this.locales.weekdaysShort[$]:this.token==="dddd"?this.locales.weekdays[$]:Y}}HY.exports=ZY});var QY=z((Q5,XY)=>{var aH=x();class JY extends aH{constructor(Y={}){super(Y)}up(){this.date.setHours(this.date.getHours()+1)}down(){this.date.setHours(this.date.getHours()-1)}setTo(Y){this.date.setHours(parseInt(Y.substr(-2)))}toString(){let Y=this.date.getHours();if(/h/.test(this.token))Y=Y%12||12;return this.token.length>1?String(Y).padStart(2,"0"):Y}}XY.exports=JY});var KY=z((D5,zY)=>{var rH=x();class DY extends rH{constructor(Y={}){super(Y)}up(){this.date.setMilliseconds(this.date.getMilliseconds()+1)}down(){this.date.setMilliseconds(this.date.getMilliseconds()-1)}setTo(Y){this.date.setMilliseconds(parseInt(Y.substr(-this.token.length)))}toString(){return String(this.date.getMilliseconds()).padStart(4,"0").substr(0,this.token.length)}}zY.exports=DY});var RY=z((z5,WY)=>{var eH=x();class BY extends eH{constructor(Y={}){super(Y)}up(){this.date.setMinutes(this.date.getMinutes()+1)}down(){this.date.setMinutes(this.date.getMinutes()-1)}setTo(Y){this.date.setMinutes(parseInt(Y.substr(-2)))}toString(){let Y=this.date.getMinutes();return this.token.length>1?String(Y).padStart(2,"0"):Y}}WY.exports=BY});var GY=z((K5,EY)=>{var Y7=x();class LY extends Y7{constructor(Y={}){super(Y)}up(){this.date.setMonth(this.date.getMonth()+1)}down(){this.date.setMonth(this.date.getMonth()-1)}setTo(Y){Y=parseInt(Y.substr(-2))-1,this.date.setMonth(Y<0?0:Y)}toString(){let Y=this.date.getMonth(),$=this.token.length;return $===2?String(Y+1).padStart(2,"0"):$===3?this.locales.monthsShort[Y]:$===4?this.locales.months[Y]:String(Y+1)}}EY.exports=LY});var MY=z((B5,FY)=>{var $7=x();class SY extends $7{constructor(Y={}){super(Y)}up(){this.date.setSeconds(this.date.getSeconds()+1)}down(){this.date.setSeconds(this.date.getSeconds()-1)}setTo(Y){this.date.setSeconds(parseInt(Y.substr(-2)))}toString(){let Y=this.date.getSeconds();return this.token.length>1?String(Y).padStart(2,"0"):Y}}FY.exports=SY});var IY=z((W5,VY)=>{var Z7=x();class OY extends Z7{constructor(Y={}){super(Y)}up(){this.date.setFullYear(this.date.getFullYear()+1)}down(){this.date.setFullYear(this.date.getFullYear()-1)}setTo(Y){this.date.setFullYear(Y.substr(-4))}toString(){let Y=String(this.date.getFullYear()).padStart(4,"0");return this.token.length===2?Y.substr(-2):Y}}VY.exports=OY});var qY=z((R5,AY)=>{AY.exports={DatePart:x(),Meridiem:$Y(),Day:UY(),Hours:QY(),Milliseconds:KY(),Minutes:RY(),Month:GY(),Seconds:MY(),Year:IY()}});var bY=z((L5,_Y)=>{var M0=S(),H7=c(),{style:CY,clear:NY,figures:U7}=P(),{erase:J7,cursor:TY}=F(),{DatePart:PY,Meridiem:X7,Day:Q7,Hours:D7,Milliseconds:z7,Minutes:K7,Month:B7,Seconds:W7,Year:R7}=qY(),L7=/\\(.)|"((?:\\["\\]|[^"])+)"|(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,jY={1:({token:Y})=>Y.replace(/\\(.)/g,"$1"),2:(Y)=>new Q7(Y),3:(Y)=>new B7(Y),4:(Y)=>new R7(Y),5:(Y)=>new X7(Y),6:(Y)=>new D7(Y),7:(Y)=>new K7(Y),8:(Y)=>new W7(Y),9:(Y)=>new z7(Y)},E7={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 kY extends H7{constructor(Y={}){super(Y);this.msg=Y.message,this.cursor=0,this.typed="",this.locales=Object.assign(E7,Y.locales),this._date=Y.initial||new Date,this.errorMsg=Y.error||"Please Enter A Valid Value",this.validator=Y.validate||(()=>!0),this.mask=Y.mask||"YYYY-MM-DD HH:mm:ss",this.clear=NY("",this.out.columns),this.render()}get value(){return this.date}get date(){return this._date}set date(Y){if(Y)this._date.setTime(Y.getTime())}set mask(Y){let $;this.parts=[];while($=L7.exec(Y)){let H=$.shift(),J=$.findIndex((U)=>U!=null);this.parts.push(J in jY?jY[J]({token:$[J]||H,date:this.date,parts:this.parts,locales:this.locales}):$[J]||H)}let Z=this.parts.reduce((H,J)=>{if(typeof J==="string"&&typeof H[H.length-1]==="string")H[H.length-1]+=J;else H.push(J);return H},[]);this.parts.splice(0),this.parts.push(...Z),this.reset()}moveCursor(Y){this.typed="",this.cursor=Y,this.fire()}reset(){this.moveCursor(this.parts.findIndex((Y)=>Y instanceof PY)),this.fire(),this.render()}exit(){this.abort()}abort(){this.done=this.aborted=!0,this.error=!1,this.fire(),this.render(),this.out.write(`
65
+ `),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()}_(Y,$){if(Y===" ")this.value=!this.value;else if(Y==="1")this.value=!0;else if(Y==="0")this.value=!1;else return this.bell();this.render()}render(){if(this.closed)return;if(this.firstRender)this.out.write(ZY.hide);else this.out.write(JH(this.outputText,this.out.columns));super.render(),this.outputText=[$Y.symbol(this.done,this.aborted),m1.bold(this.msg),$Y.delimiter(this.done),this.value?this.inactive:m1.cyan().underline(this.inactive),m1.gray("/"),this.value?m1.cyan().underline(this.active):this.active].join(" "),this.out.write(DH.line+ZY.to(0)+this.outputText)}}UY.exports=HY});var y=B((f5,QY)=>{class o1{constructor({token:Y,date:$,parts:Z,locales:H}){this.token=Y,this.date=$||new Date,this.parts=Z||[this],this.locales=H||{}}up(){}down(){}next(){let Y=this.parts.indexOf(this);return this.parts.find(($,Z)=>Z>Y&&$ instanceof o1)}setTo(Y){}prev(){let Y=[].concat(this.parts).reverse(),$=Y.indexOf(this);return Y.find((Z,H)=>H>$&&Z instanceof o1)}toString(){return String(this.date)}}QY.exports=o1});var zY=B((w5,DY)=>{var zH=y();class JY extends zH{constructor(Y={}){super(Y)}up(){this.date.setHours((this.date.getHours()+12)%24)}down(){this.up()}toString(){let Y=this.date.getHours()>12?"pm":"am";return/\A/.test(this.token)?Y.toUpperCase():Y}}DY.exports=JY});var BY=B((v5,WY)=>{var KH=y(),WH=(Y)=>{return Y=Y%10,Y===1?"st":Y===2?"nd":Y===3?"rd":"th"};class KY extends KH{constructor(Y={}){super(Y)}up(){this.date.setDate(this.date.getDate()+1)}down(){this.date.setDate(this.date.getDate()-1)}setTo(Y){this.date.setDate(parseInt(Y.substr(-2)))}toString(){let Y=this.date.getDate(),$=this.date.getDay();return this.token==="DD"?String(Y).padStart(2,"0"):this.token==="Do"?Y+WH(Y):this.token==="d"?$+1:this.token==="ddd"?this.locales.weekdaysShort[$]:this.token==="dddd"?this.locales.weekdays[$]:Y}}WY.exports=KY});var RY=B((g5,GY)=>{var BH=y();class EY extends BH{constructor(Y={}){super(Y)}up(){this.date.setHours(this.date.getHours()+1)}down(){this.date.setHours(this.date.getHours()-1)}setTo(Y){this.date.setHours(parseInt(Y.substr(-2)))}toString(){let Y=this.date.getHours();if(/h/.test(this.token))Y=Y%12||12;return this.token.length>1?String(Y).padStart(2,"0"):Y}}GY.exports=EY});var MY=B((y5,SY)=>{var EH=y();class LY extends EH{constructor(Y={}){super(Y)}up(){this.date.setMilliseconds(this.date.getMilliseconds()+1)}down(){this.date.setMilliseconds(this.date.getMilliseconds()-1)}setTo(Y){this.date.setMilliseconds(parseInt(Y.substr(-this.token.length)))}toString(){return String(this.date.getMilliseconds()).padStart(4,"0").substr(0,this.token.length)}}SY.exports=LY});var OY=B((d5,VY)=>{var GH=y();class FY extends GH{constructor(Y={}){super(Y)}up(){this.date.setMinutes(this.date.getMinutes()+1)}down(){this.date.setMinutes(this.date.getMinutes()-1)}setTo(Y){this.date.setMinutes(parseInt(Y.substr(-2)))}toString(){let Y=this.date.getMinutes();return this.token.length>1?String(Y).padStart(2,"0"):Y}}VY.exports=FY});var qY=B((u5,AY)=>{var RH=y();class IY extends RH{constructor(Y={}){super(Y)}up(){this.date.setMonth(this.date.getMonth()+1)}down(){this.date.setMonth(this.date.getMonth()-1)}setTo(Y){Y=parseInt(Y.substr(-2))-1,this.date.setMonth(Y<0?0:Y)}toString(){let Y=this.date.getMonth(),$=this.token.length;return $===2?String(Y+1).padStart(2,"0"):$===3?this.locales.monthsShort[Y]:$===4?this.locales.months[Y]:String(Y+1)}}AY.exports=IY});var TY=B((c5,PY)=>{var LH=y();class NY extends LH{constructor(Y={}){super(Y)}up(){this.date.setSeconds(this.date.getSeconds()+1)}down(){this.date.setSeconds(this.date.getSeconds()-1)}setTo(Y){this.date.setSeconds(parseInt(Y.substr(-2)))}toString(){let Y=this.date.getSeconds();return this.token.length>1?String(Y).padStart(2,"0"):Y}}PY.exports=NY});var _Y=B((l5,jY)=>{var SH=y();class CY extends SH{constructor(Y={}){super(Y)}up(){this.date.setFullYear(this.date.getFullYear()+1)}down(){this.date.setFullYear(this.date.getFullYear()-1)}setTo(Y){this.date.setFullYear(Y.substr(-4))}toString(){let Y=String(this.date.getFullYear()).padStart(4,"0");return this.token.length===2?Y.substr(-2):Y}}jY.exports=CY});var xY=B((p5,kY)=>{kY.exports={DatePart:y(),Meridiem:zY(),Day:BY(),Hours:RY(),Milliseconds:MY(),Minutes:OY(),Month:qY(),Seconds:TY(),Year:_Y()}});var dY=B((n5,yY)=>{var j0=M(),MH=o(),{style:bY,clear:hY,figures:FH}=b(),{erase:VH,cursor:fY}=F(),{DatePart:wY,Meridiem:OH,Day:IH,Hours:AH,Milliseconds:qH,Minutes:NH,Month:PH,Seconds:TH,Year:CH}=xY(),jH=/\\(.)|"((?:\\["\\]|[^"])+)"|(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,vY={1:({token:Y})=>Y.replace(/\\(.)/g,"$1"),2:(Y)=>new IH(Y),3:(Y)=>new PH(Y),4:(Y)=>new CH(Y),5:(Y)=>new OH(Y),6:(Y)=>new AH(Y),7:(Y)=>new NH(Y),8:(Y)=>new TH(Y),9:(Y)=>new qH(Y)},_H={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 gY extends MH{constructor(Y={}){super(Y);this.msg=Y.message,this.cursor=0,this.typed="",this.locales=Object.assign(_H,Y.locales),this._date=Y.initial||new Date,this.errorMsg=Y.error||"Please Enter A Valid Value",this.validator=Y.validate||(()=>!0),this.mask=Y.mask||"YYYY-MM-DD HH:mm:ss",this.clear=hY("",this.out.columns),this.render()}get value(){return this.date}get date(){return this._date}set date(Y){if(Y)this._date.setTime(Y.getTime())}set mask(Y){let $;this.parts=[];while($=jH.exec(Y)){let H=$.shift(),U=$.findIndex((X)=>X!=null);this.parts.push(U in vY?vY[U]({token:$[U]||H,date:this.date,parts:this.parts,locales:this.locales}):$[U]||H)}let Z=this.parts.reduce((H,U)=>{if(typeof U==="string"&&typeof H[H.length-1]==="string")H[H.length-1]+=U;else H.push(U);return H},[]);this.parts.splice(0),this.parts.push(...Z),this.reset()}moveCursor(Y){this.typed="",this.cursor=Y,this.fire()}reset(){this.moveCursor(this.parts.findIndex((Y)=>Y instanceof wY)),this.fire(),this.render()}exit(){this.abort()}abort(){this.done=this.aborted=!0,this.error=!1,this.fire(),this.render(),this.out.write(`
66
66
  `),this.close()}async validate(){let Y=await this.validator(this.value);if(typeof Y==="string")this.errorMsg=Y,Y=!1;this.error=!Y}async submit(){if(await this.validate(),this.error){this.color="red",this.fire(),this.render();return}this.done=!0,this.aborted=!1,this.fire(),this.render(),this.out.write(`
67
- `),this.close()}up(){this.typed="",this.parts[this.cursor].up(),this.render()}down(){this.typed="",this.parts[this.cursor].down(),this.render()}left(){let Y=this.parts[this.cursor].prev();if(Y==null)return this.bell();this.moveCursor(this.parts.indexOf(Y)),this.render()}right(){let Y=this.parts[this.cursor].next();if(Y==null)return this.bell();this.moveCursor(this.parts.indexOf(Y)),this.render()}next(){let Y=this.parts[this.cursor].next();this.moveCursor(Y?this.parts.indexOf(Y):this.parts.findIndex(($)=>$ instanceof PY)),this.render()}_(Y){if(/\d/.test(Y))this.typed+=Y,this.parts[this.cursor].setTo(this.typed),this.render()}render(){if(this.closed)return;if(this.firstRender)this.out.write(TY.hide);else this.out.write(NY(this.outputText,this.out.columns));if(super.render(),this.outputText=[CY.symbol(this.done,this.aborted),M0.bold(this.msg),CY.delimiter(!1),this.parts.reduce((Y,$,Z)=>Y.concat(Z===this.cursor&&!this.done?M0.cyan().underline($.toString()):$),[]).join("")].join(" "),this.error)this.outputText+=this.errorMsg.split(`
67
+ `),this.close()}up(){this.typed="",this.parts[this.cursor].up(),this.render()}down(){this.typed="",this.parts[this.cursor].down(),this.render()}left(){let Y=this.parts[this.cursor].prev();if(Y==null)return this.bell();this.moveCursor(this.parts.indexOf(Y)),this.render()}right(){let Y=this.parts[this.cursor].next();if(Y==null)return this.bell();this.moveCursor(this.parts.indexOf(Y)),this.render()}next(){let Y=this.parts[this.cursor].next();this.moveCursor(Y?this.parts.indexOf(Y):this.parts.findIndex(($)=>$ instanceof wY)),this.render()}_(Y){if(/\d/.test(Y))this.typed+=Y,this.parts[this.cursor].setTo(this.typed),this.render()}render(){if(this.closed)return;if(this.firstRender)this.out.write(fY.hide);else this.out.write(hY(this.outputText,this.out.columns));if(super.render(),this.outputText=[bY.symbol(this.done,this.aborted),j0.bold(this.msg),bY.delimiter(!1),this.parts.reduce((Y,$,Z)=>Y.concat(Z===this.cursor&&!this.done?j0.cyan().underline($.toString()):$),[]).join("")].join(" "),this.error)this.outputText+=this.errorMsg.split(`
68
68
  `).reduce((Y,$,Z)=>Y+`
69
- ${Z?" ":U7.pointerSmall} ${M0.red().italic($)}`,"");this.out.write(J7.line+TY.to(0)+this.outputText)}}_Y.exports=kY});var gY=z((E5,wY)=>{var p1=S(),G7=c(),{cursor:m1,erase:S7}=F(),{style:O0,figures:F7,clear:xY,lines:M7}=P(),O7=/[0-9]/,V0=(Y)=>Y!==void 0,hY=(Y,$)=>{let Z=Math.pow(10,$);return Math.round(Y*Z)/Z};class fY extends G7{constructor(Y={}){super(Y);this.transform=O0.render(Y.style),this.msg=Y.message,this.initial=V0(Y.initial)?Y.initial:"",this.float=!!Y.float,this.round=Y.round||2,this.inc=Y.increment||1,this.min=V0(Y.min)?Y.min:-1/0,this.max=V0(Y.max)?Y.max:1/0,this.errorMsg=Y.error||"Please Enter A Valid Value",this.validator=Y.validate||(()=>!0),this.color="cyan",this.value="",this.typed="",this.lastHit=0,this.render()}set value(Y){if(!Y&&Y!==0)this.placeholder=!0,this.rendered=p1.gray(this.transform.render(`${this.initial}`)),this._value="";else this.placeholder=!1,this.rendered=this.transform.render(`${hY(Y,this.round)}`),this._value=hY(Y,this.round);this.fire()}get value(){return this._value}parse(Y){return this.float?parseFloat(Y):parseInt(Y)}valid(Y){return Y==="-"||Y==="."&&this.float||O7.test(Y)}reset(){this.typed="",this.value="",this.fire(),this.render()}exit(){this.abort()}abort(){let Y=this.value;this.value=Y!==""?Y:this.initial,this.done=this.aborted=!0,this.error=!1,this.fire(),this.render(),this.out.write(`
69
+ ${Z?" ":FH.pointerSmall} ${j0.red().italic($)}`,"");this.out.write(VH.line+fY.to(0)+this.outputText)}}yY.exports=gY});var nY=B((i5,pY)=>{var t1=M(),kH=o(),{cursor:s1,erase:xH}=F(),{style:_0,figures:bH,clear:uY,lines:hH}=b(),fH=/[0-9]/,k0=(Y)=>Y!==void 0,cY=(Y,$)=>{let Z=Math.pow(10,$);return Math.round(Y*Z)/Z};class lY extends kH{constructor(Y={}){super(Y);this.transform=_0.render(Y.style),this.msg=Y.message,this.initial=k0(Y.initial)?Y.initial:"",this.float=!!Y.float,this.round=Y.round||2,this.inc=Y.increment||1,this.min=k0(Y.min)?Y.min:-1/0,this.max=k0(Y.max)?Y.max:1/0,this.errorMsg=Y.error||"Please Enter A Valid Value",this.validator=Y.validate||(()=>!0),this.color="cyan",this.value="",this.typed="",this.lastHit=0,this.render()}set value(Y){if(!Y&&Y!==0)this.placeholder=!0,this.rendered=t1.gray(this.transform.render(`${this.initial}`)),this._value="";else this.placeholder=!1,this.rendered=this.transform.render(`${cY(Y,this.round)}`),this._value=cY(Y,this.round);this.fire()}get value(){return this._value}parse(Y){return this.float?parseFloat(Y):parseInt(Y)}valid(Y){return Y==="-"||Y==="."&&this.float||fH.test(Y)}reset(){this.typed="",this.value="",this.fire(),this.render()}exit(){this.abort()}abort(){let Y=this.value;this.value=Y!==""?Y:this.initial,this.done=this.aborted=!0,this.error=!1,this.fire(),this.render(),this.out.write(`
70
70
  `),this.close()}async validate(){let Y=await this.validator(this.value);if(typeof Y==="string")this.errorMsg=Y,Y=!1;this.error=!Y}async submit(){if(await this.validate(),this.error){this.color="red",this.fire(),this.render();return}let Y=this.value;this.value=Y!==""?Y:this.initial,this.done=!0,this.aborted=!1,this.error=!1,this.fire(),this.render(),this.out.write(`
71
- `),this.close()}up(){if(this.typed="",this.value==="")this.value=this.min-this.inc;if(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;if(this.value<=this.min)return this.bell();this.value-=this.inc,this.color="cyan",this.fire(),this.render()}delete(){let Y=this.value.toString();if(Y.length===0)return this.bell();if(this.value=this.parse(Y=Y.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()}_(Y,$){if(!this.valid(Y))return this.bell();let Z=Date.now();if(Z-this.lastHit>1000)this.typed="";if(this.typed+=Y,this.lastHit=Z,this.color="cyan",Y===".")return this.fire();if(this.value=Math.min(this.parse(this.typed),this.max),this.value>this.max)this.value=this.max;if(this.value<this.min)this.value=this.min;this.fire(),this.render()}render(){if(this.closed)return;if(!this.firstRender){if(this.outputError)this.out.write(m1.down(M7(this.outputError,this.out.columns)-1)+xY(this.outputError,this.out.columns));this.out.write(xY(this.outputText,this.out.columns))}if(super.render(),this.outputError="",this.outputText=[O0.symbol(this.done,this.aborted),p1.bold(this.msg),O0.delimiter(this.done),!this.done||!this.done&&!this.placeholder?p1[this.color]().underline(this.rendered):this.rendered].join(" "),this.error)this.outputError+=this.errorMsg.split(`
71
+ `),this.close()}up(){if(this.typed="",this.value==="")this.value=this.min-this.inc;if(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;if(this.value<=this.min)return this.bell();this.value-=this.inc,this.color="cyan",this.fire(),this.render()}delete(){let Y=this.value.toString();if(Y.length===0)return this.bell();if(this.value=this.parse(Y=Y.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()}_(Y,$){if(!this.valid(Y))return this.bell();let Z=Date.now();if(Z-this.lastHit>1000)this.typed="";if(this.typed+=Y,this.lastHit=Z,this.color="cyan",Y===".")return this.fire();if(this.value=Math.min(this.parse(this.typed),this.max),this.value>this.max)this.value=this.max;if(this.value<this.min)this.value=this.min;this.fire(),this.render()}render(){if(this.closed)return;if(!this.firstRender){if(this.outputError)this.out.write(s1.down(hH(this.outputError,this.out.columns)-1)+uY(this.outputError,this.out.columns));this.out.write(uY(this.outputText,this.out.columns))}if(super.render(),this.outputError="",this.outputText=[_0.symbol(this.done,this.aborted),t1.bold(this.msg),_0.delimiter(this.done),!this.done||!this.done&&!this.placeholder?t1[this.color]().underline(this.rendered):this.rendered].join(" "),this.error)this.outputError+=this.errorMsg.split(`
72
72
  `).reduce((Y,$,Z)=>Y+`
73
- ${Z?" ":F7.pointerSmall} ${p1.red().italic($)}`,"");this.out.write(S7.line+m1.to(0)+this.outputText+m1.save+this.outputError+m1.restore)}}wY.exports=fY});var I0=z((G5,uY)=>{var h=S(),{cursor:V7}=F(),I7=c(),{clear:vY,figures:a,style:yY,wrap:A7,entriesToDisplay:q7}=P();class dY extends I7{constructor(Y={}){super(Y);if(this.msg=Y.message,this.cursor=Y.cursor||0,this.scrollIndex=Y.cursor||0,this.hint=Y.hint||"",this.warn=Y.warn||"- This option is disabled -",this.minSelected=Y.min,this.showMinError=!1,this.maxChoices=Y.max,this.instructions=Y.instructions,this.optionsPerPage=Y.optionsPerPage||10,this.value=Y.choices.map(($,Z)=>{if(typeof $==="string")$={title:$,value:Z};return{title:$&&($.title||$.value||$),description:$&&$.description,value:$&&($.value===void 0?Z:$.value),selected:$&&$.selected,disabled:$&&$.disabled}}),this.clear=vY("",this.out.columns),!Y.overrideRender)this.render()}reset(){this.value.map((Y)=>!Y.selected),this.cursor=0,this.fire(),this.render()}selected(){return this.value.filter((Y)=>Y.selected)}exit(){this.abort()}abort(){this.done=this.aborted=!0,this.fire(),this.render(),this.out.write(`
73
+ ${Z?" ":bH.pointerSmall} ${t1.red().italic($)}`,"");this.out.write(xH.line+s1.to(0)+this.outputText+s1.save+this.outputError+s1.restore)}}pY.exports=lY});var x0=B((m5,tY)=>{var d=M(),{cursor:wH}=F(),vH=o(),{clear:iY,figures:X1,style:mY,wrap:gH,entriesToDisplay:yH}=b();class oY extends vH{constructor(Y={}){super(Y);if(this.msg=Y.message,this.cursor=Y.cursor||0,this.scrollIndex=Y.cursor||0,this.hint=Y.hint||"",this.warn=Y.warn||"- This option is disabled -",this.minSelected=Y.min,this.showMinError=!1,this.maxChoices=Y.max,this.instructions=Y.instructions,this.optionsPerPage=Y.optionsPerPage||10,this.value=Y.choices.map(($,Z)=>{if(typeof $==="string")$={title:$,value:Z};return{title:$&&($.title||$.value||$),description:$&&$.description,value:$&&($.value===void 0?Z:$.value),selected:$&&$.selected,disabled:$&&$.disabled}}),this.clear=iY("",this.out.columns),!Y.overrideRender)this.render()}reset(){this.value.map((Y)=>!Y.selected),this.cursor=0,this.fire(),this.render()}selected(){return this.value.filter((Y)=>Y.selected)}exit(){this.abort()}abort(){this.done=this.aborted=!0,this.fire(),this.render(),this.out.write(`
74
74
  `),this.close()}submit(){let Y=this.value.filter(($)=>$.selected);if(this.minSelected&&Y.length<this.minSelected)this.showMinError=!0,this.render();else this.done=!0,this.aborted=!1,this.fire(),this.render(),this.out.write(`
75
75
  `),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(){if(this.cursor===0)this.cursor=this.value.length-1;else this.cursor--;this.render()}down(){if(this.cursor===this.value.length-1)this.cursor=0;else this.cursor++;this.render()}left(){this.value[this.cursor].selected=!1,this.render()}right(){if(this.value.filter((Y)=>Y.selected).length>=this.maxChoices)return this.bell();this.value[this.cursor].selected=!0,this.render()}handleSpaceToggle(){let Y=this.value[this.cursor];if(Y.selected)Y.selected=!1,this.render();else if(Y.disabled||this.value.filter(($)=>$.selected).length>=this.maxChoices)return this.bell();else Y.selected=!0,this.render()}toggleAll(){if(this.maxChoices!==void 0||this.value[this.cursor].disabled)return this.bell();let Y=!this.value[this.cursor].selected;this.value.filter(($)=>!$.disabled).forEach(($)=>$.selected=Y),this.render()}_(Y,$){if(Y===" ")this.handleSpaceToggle();else if(Y==="a")this.toggleAll();else return this.bell()}renderInstructions(){if(this.instructions===void 0||this.instructions){if(typeof this.instructions==="string")return this.instructions;return`
76
76
  Instructions:
77
- ${a.arrowUp}/${a.arrowDown}: Highlight option
78
- ${a.arrowLeft}/${a.arrowRight}/[space]: Toggle selection
77
+ ${X1.arrowUp}/${X1.arrowDown}: Highlight option
78
+ ${X1.arrowLeft}/${X1.arrowRight}/[space]: Toggle selection
79
79
  `+(this.maxChoices===void 0?` a: Toggle all
80
- `:"")+" enter/return: Complete answer"}return""}renderOption(Y,$,Z,H){let J=($.selected?h.green(a.radioOn):a.radioOff)+" "+H+" ",U,X;if($.disabled)U=Y===Z?h.gray().underline($.title):h.strikethrough().gray($.title);else if(U=Y===Z?h.cyan().underline($.title):$.title,Y===Z&&$.description){if(X=` - ${$.description}`,J.length+U.length+X.length>=this.out.columns||$.description.split(/\r?\n/).length>1)X=`
81
- `+A7($.description,{margin:J.length,width:this.out.columns})}return J+U+h.gray(X||"")}paginateOptions(Y){if(Y.length===0)return h.red("No matches for this query.");let{startIndex:$,endIndex:Z}=q7(this.cursor,Y.length,this.optionsPerPage),H,J=[];for(let U=$;U<Z;U++){if(U===$&&$>0)H=a.arrowUp;else if(U===Z-1&&Z<Y.length)H=a.arrowDown;else H=" ";J.push(this.renderOption(this.cursor,Y[U],U,H))}return`
82
- `+J.join(`
83
- `)}renderOptions(Y){if(!this.done)return this.paginateOptions(Y);return""}renderDoneOrInstructions(){if(this.done)return this.value.filter(($)=>$.selected).map(($)=>$.title).join(", ");let Y=[h.gray(this.hint),this.renderInstructions()];if(this.value[this.cursor].disabled)Y.push(h.yellow(this.warn));return Y.join(" ")}render(){if(this.closed)return;if(this.firstRender)this.out.write(V7.hide);super.render();let Y=[yY.symbol(this.done,this.aborted),h.bold(this.msg),yY.delimiter(!1),this.renderDoneOrInstructions()].join(" ");if(this.showMinError)Y+=h.red(`You must select a minimum of ${this.minSelected} choices.`),this.showMinError=!1;Y+=this.renderOptions(this.value),this.out.write(this.clear+Y),this.clear=vY(Y,this.out.columns)}}uY.exports=dY});var iY=z((S5,mY)=>{var V1=S(),C7=c(),{erase:N7,cursor:cY}=F(),{style:A0,clear:lY,figures:q0,wrap:T7,entriesToDisplay:P7}=P(),nY=(Y,$)=>Y[$]&&(Y[$].value||Y[$].title||Y[$]),j7=(Y,$)=>Y[$]&&(Y[$].title||Y[$].value||Y[$]),k7=(Y,$)=>{let Z=Y.findIndex((H)=>H.value===$||H.title===$);return Z>-1?Z:void 0};class pY extends C7{constructor(Y={}){super(Y);this.msg=Y.message,this.suggest=Y.suggest,this.choices=Y.choices,this.initial=typeof Y.initial==="number"?Y.initial:k7(Y.choices,Y.initial),this.select=this.initial||Y.cursor||0,this.i18n={noMatches:Y.noMatches||"no matches found"},this.fallback=Y.fallback||this.initial,this.clearFirst=Y.clearFirst||!1,this.suggestions=[],this.input="",this.limit=Y.limit||10,this.cursor=0,this.transform=A0.render(Y.style),this.scale=this.transform.scale,this.render=this.render.bind(this),this.complete=this.complete.bind(this),this.clear=lY("",this.out.columns),this.complete(this.render),this.render()}set fallback(Y){this._fb=Number.isSafeInteger(parseInt(Y))?parseInt(Y):Y}get fallback(){let Y;if(typeof this._fb==="number")Y=this.choices[this._fb];else if(typeof this._fb==="string")Y={title:this._fb};return Y||this._fb||{title:this.i18n.noMatches}}moveSelect(Y){if(this.select=Y,this.suggestions.length>0)this.value=nY(this.suggestions,Y);else this.value=this.fallback.value;this.fire()}async complete(Y){let $=this.completing=this.suggest(this.input,this.choices),Z=await $;if(this.completing!==$)return;this.suggestions=Z.map((J,U,X)=>({title:j7(X,U),value:nY(X,U),description:J.description})),this.completing=!1;let H=Math.max(Z.length-1,0);this.moveSelect(Math.min(H,this.select)),Y&&Y()}reset(){this.input="",this.complete(()=>{this.moveSelect(this.initial!==void 0?this.initial:0),this.render()}),this.render()}exit(){if(this.clearFirst&&this.input.length>0)this.reset();else this.done=this.exited=!0,this.aborted=!1,this.fire(),this.render(),this.out.write(`
80
+ `:"")+" enter/return: Complete answer"}return""}renderOption(Y,$,Z,H){let U=($.selected?d.green(X1.radioOn):X1.radioOff)+" "+H+" ",X,Q;if($.disabled)X=Y===Z?d.gray().underline($.title):d.strikethrough().gray($.title);else if(X=Y===Z?d.cyan().underline($.title):$.title,Y===Z&&$.description){if(Q=` - ${$.description}`,U.length+X.length+Q.length>=this.out.columns||$.description.split(/\r?\n/).length>1)Q=`
81
+ `+gH($.description,{margin:U.length,width:this.out.columns})}return U+X+d.gray(Q||"")}paginateOptions(Y){if(Y.length===0)return d.red("No matches for this query.");let{startIndex:$,endIndex:Z}=yH(this.cursor,Y.length,this.optionsPerPage),H,U=[];for(let X=$;X<Z;X++){if(X===$&&$>0)H=X1.arrowUp;else if(X===Z-1&&Z<Y.length)H=X1.arrowDown;else H=" ";U.push(this.renderOption(this.cursor,Y[X],X,H))}return`
82
+ `+U.join(`
83
+ `)}renderOptions(Y){if(!this.done)return this.paginateOptions(Y);return""}renderDoneOrInstructions(){if(this.done)return this.value.filter(($)=>$.selected).map(($)=>$.title).join(", ");let Y=[d.gray(this.hint),this.renderInstructions()];if(this.value[this.cursor].disabled)Y.push(d.yellow(this.warn));return Y.join(" ")}render(){if(this.closed)return;if(this.firstRender)this.out.write(wH.hide);super.render();let Y=[mY.symbol(this.done,this.aborted),d.bold(this.msg),mY.delimiter(!1),this.renderDoneOrInstructions()].join(" ");if(this.showMinError)Y+=d.red(`You must select a minimum of ${this.minSelected} choices.`),this.showMinError=!1;Y+=this.renderOptions(this.value),this.out.write(this.clear+Y),this.clear=iY(Y,this.out.columns)}}tY.exports=oY});var $$=B((o5,Y$)=>{var C1=M(),dH=o(),{erase:uH,cursor:sY}=F(),{style:b0,clear:rY,figures:h0,wrap:cH,entriesToDisplay:lH}=b(),aY=(Y,$)=>Y[$]&&(Y[$].value||Y[$].title||Y[$]),pH=(Y,$)=>Y[$]&&(Y[$].title||Y[$].value||Y[$]),nH=(Y,$)=>{let Z=Y.findIndex((H)=>H.value===$||H.title===$);return Z>-1?Z:void 0};class eY extends dH{constructor(Y={}){super(Y);this.msg=Y.message,this.suggest=Y.suggest,this.choices=Y.choices,this.initial=typeof Y.initial==="number"?Y.initial:nH(Y.choices,Y.initial),this.select=this.initial||Y.cursor||0,this.i18n={noMatches:Y.noMatches||"no matches found"},this.fallback=Y.fallback||this.initial,this.clearFirst=Y.clearFirst||!1,this.suggestions=[],this.input="",this.limit=Y.limit||10,this.cursor=0,this.transform=b0.render(Y.style),this.scale=this.transform.scale,this.render=this.render.bind(this),this.complete=this.complete.bind(this),this.clear=rY("",this.out.columns),this.complete(this.render),this.render()}set fallback(Y){this._fb=Number.isSafeInteger(parseInt(Y))?parseInt(Y):Y}get fallback(){let Y;if(typeof this._fb==="number")Y=this.choices[this._fb];else if(typeof this._fb==="string")Y={title:this._fb};return Y||this._fb||{title:this.i18n.noMatches}}moveSelect(Y){if(this.select=Y,this.suggestions.length>0)this.value=aY(this.suggestions,Y);else this.value=this.fallback.value;this.fire()}async complete(Y){let $=this.completing=this.suggest(this.input,this.choices),Z=await $;if(this.completing!==$)return;this.suggestions=Z.map((U,X,Q)=>({title:pH(Q,X),value:aY(Q,X),description:U.description})),this.completing=!1;let H=Math.max(Z.length-1,0);this.moveSelect(Math.min(H,this.select)),Y&&Y()}reset(){this.input="",this.complete(()=>{this.moveSelect(this.initial!==void 0?this.initial:0),this.render()}),this.render()}exit(){if(this.clearFirst&&this.input.length>0)this.reset();else this.done=this.exited=!0,this.aborted=!1,this.fire(),this.render(),this.out.write(`
84
84
  `),this.close()}abort(){this.done=this.aborted=!0,this.exited=!1,this.fire(),this.render(),this.out.write(`
85
85
  `),this.close()}submit(){this.done=!0,this.aborted=this.exited=!1,this.fire(),this.render(),this.out.write(`
86
- `),this.close()}_(Y,$){let Z=this.input.slice(0,this.cursor),H=this.input.slice(this.cursor);this.input=`${Z}${Y}${H}`,this.cursor=Z.length+1,this.complete(this.render),this.render()}delete(){if(this.cursor===0)return this.bell();let Y=this.input.slice(0,this.cursor-1),$=this.input.slice(this.cursor);this.input=`${Y}${$}`,this.complete(this.render),this.cursor=this.cursor-1,this.render()}deleteForward(){if(this.cursor*this.scale>=this.rendered.length)return this.bell();let Y=this.input.slice(0,this.cursor),$=this.input.slice(this.cursor+1);this.input=`${Y}${$}`,this.complete(this.render),this.render()}first(){this.moveSelect(0),this.render()}last(){this.moveSelect(this.suggestions.length-1),this.render()}up(){if(this.select===0)this.moveSelect(this.suggestions.length-1);else this.moveSelect(this.select-1);this.render()}down(){if(this.select===this.suggestions.length-1)this.moveSelect(0);else this.moveSelect(this.select+1);this.render()}next(){if(this.select===this.suggestions.length-1)this.moveSelect(0);else 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(Y,$,Z,H){let J,U=Z?q0.arrowUp:H?q0.arrowDown:" ",X=$?V1.cyan().underline(Y.title):Y.title;if(U=($?V1.cyan(q0.pointer)+" ":" ")+U,Y.description){if(J=` - ${Y.description}`,U.length+X.length+J.length>=this.out.columns||Y.description.split(/\r?\n/).length>1)J=`
87
- `+T7(Y.description,{margin:3,width:this.out.columns})}return U+" "+X+V1.gray(J||"")}render(){if(this.closed)return;if(this.firstRender)this.out.write(cY.hide);else this.out.write(lY(this.outputText,this.out.columns));super.render();let{startIndex:Y,endIndex:$}=P7(this.select,this.choices.length,this.limit);if(this.outputText=[A0.symbol(this.done,this.aborted,this.exited),V1.bold(this.msg),A0.delimiter(this.completing),this.done&&this.suggestions[this.select]?this.suggestions[this.select].title:this.rendered=this.transform.render(this.input)].join(" "),!this.done){let Z=this.suggestions.slice(Y,$).map((H,J)=>this.renderOption(H,this.select===J+Y,J===0&&Y>0,J+Y===$-1&&$<this.choices.length)).join(`
86
+ `),this.close()}_(Y,$){let Z=this.input.slice(0,this.cursor),H=this.input.slice(this.cursor);this.input=`${Z}${Y}${H}`,this.cursor=Z.length+1,this.complete(this.render),this.render()}delete(){if(this.cursor===0)return this.bell();let Y=this.input.slice(0,this.cursor-1),$=this.input.slice(this.cursor);this.input=`${Y}${$}`,this.complete(this.render),this.cursor=this.cursor-1,this.render()}deleteForward(){if(this.cursor*this.scale>=this.rendered.length)return this.bell();let Y=this.input.slice(0,this.cursor),$=this.input.slice(this.cursor+1);this.input=`${Y}${$}`,this.complete(this.render),this.render()}first(){this.moveSelect(0),this.render()}last(){this.moveSelect(this.suggestions.length-1),this.render()}up(){if(this.select===0)this.moveSelect(this.suggestions.length-1);else this.moveSelect(this.select-1);this.render()}down(){if(this.select===this.suggestions.length-1)this.moveSelect(0);else this.moveSelect(this.select+1);this.render()}next(){if(this.select===this.suggestions.length-1)this.moveSelect(0);else 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(Y,$,Z,H){let U,X=Z?h0.arrowUp:H?h0.arrowDown:" ",Q=$?C1.cyan().underline(Y.title):Y.title;if(X=($?C1.cyan(h0.pointer)+" ":" ")+X,Y.description){if(U=` - ${Y.description}`,X.length+Q.length+U.length>=this.out.columns||Y.description.split(/\r?\n/).length>1)U=`
87
+ `+cH(Y.description,{margin:3,width:this.out.columns})}return X+" "+Q+C1.gray(U||"")}render(){if(this.closed)return;if(this.firstRender)this.out.write(sY.hide);else this.out.write(rY(this.outputText,this.out.columns));super.render();let{startIndex:Y,endIndex:$}=lH(this.select,this.choices.length,this.limit);if(this.outputText=[b0.symbol(this.done,this.aborted,this.exited),C1.bold(this.msg),b0.delimiter(this.completing),this.done&&this.suggestions[this.select]?this.suggestions[this.select].title:this.rendered=this.transform.render(this.input)].join(" "),!this.done){let Z=this.suggestions.slice(Y,$).map((H,U)=>this.renderOption(H,this.select===U+Y,U===0&&Y>0,U+Y===$-1&&$<this.choices.length)).join(`
88
88
  `);this.outputText+=`
89
- `+(Z||V1.gray(this.fallback.title))}this.out.write(N7.line+cY.to(0)+this.outputText)}}mY.exports=pY});var rY=z((F5,aY)=>{var n=S(),{cursor:_7}=F(),b7=I0(),{clear:oY,style:sY,figures:Q1}=P();class tY extends b7{constructor(Y={}){Y.overrideRender=!0;super(Y);this.inputValue="",this.clear=oY("",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(){if(this.cursor===0)this.cursor=this.filteredOptions.length-1;else this.cursor--;this.render()}down(){if(this.cursor===this.filteredOptions.length-1)this.cursor=0;else this.cursor++;this.render()}left(){this.filteredOptions[this.cursor].selected=!1,this.render()}right(){if(this.value.filter((Y)=>Y.selected).length>=this.maxChoices)return this.bell();this.filteredOptions[this.cursor].selected=!0,this.render()}delete(){if(this.inputValue.length)this.inputValue=this.inputValue.substr(0,this.inputValue.length-1),this.updateFilteredOptions()}updateFilteredOptions(){let Y=this.filteredOptions[this.cursor];this.filteredOptions=this.value.filter((Z)=>{if(this.inputValue){if(typeof Z.title==="string"){if(Z.title.toLowerCase().includes(this.inputValue.toLowerCase()))return!0}if(typeof Z.value==="string"){if(Z.value.toLowerCase().includes(this.inputValue.toLowerCase()))return!0}return!1}return!0});let $=this.filteredOptions.findIndex((Z)=>Z===Y);this.cursor=$<0?0:$,this.render()}handleSpaceToggle(){let Y=this.filteredOptions[this.cursor];if(Y.selected)Y.selected=!1,this.render();else if(Y.disabled||this.value.filter(($)=>$.selected).length>=this.maxChoices)return this.bell();else Y.selected=!0,this.render()}handleInputChange(Y){this.inputValue=this.inputValue+Y,this.updateFilteredOptions()}_(Y,$){if(Y===" ")this.handleSpaceToggle();else this.handleInputChange(Y)}renderInstructions(){if(this.instructions===void 0||this.instructions){if(typeof this.instructions==="string")return this.instructions;return`
89
+ `+(Z||C1.gray(this.fallback.title))}this.out.write(uH.line+sY.to(0)+this.outputText)}}Y$.exports=eY});var Q$=B((t5,X$)=>{var s=M(),{cursor:iH}=F(),mH=x0(),{clear:Z$,style:H$,figures:G1}=b();class U$ extends mH{constructor(Y={}){Y.overrideRender=!0;super(Y);this.inputValue="",this.clear=Z$("",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(){if(this.cursor===0)this.cursor=this.filteredOptions.length-1;else this.cursor--;this.render()}down(){if(this.cursor===this.filteredOptions.length-1)this.cursor=0;else this.cursor++;this.render()}left(){this.filteredOptions[this.cursor].selected=!1,this.render()}right(){if(this.value.filter((Y)=>Y.selected).length>=this.maxChoices)return this.bell();this.filteredOptions[this.cursor].selected=!0,this.render()}delete(){if(this.inputValue.length)this.inputValue=this.inputValue.substr(0,this.inputValue.length-1),this.updateFilteredOptions()}updateFilteredOptions(){let Y=this.filteredOptions[this.cursor];this.filteredOptions=this.value.filter((Z)=>{if(this.inputValue){if(typeof Z.title==="string"){if(Z.title.toLowerCase().includes(this.inputValue.toLowerCase()))return!0}if(typeof Z.value==="string"){if(Z.value.toLowerCase().includes(this.inputValue.toLowerCase()))return!0}return!1}return!0});let $=this.filteredOptions.findIndex((Z)=>Z===Y);this.cursor=$<0?0:$,this.render()}handleSpaceToggle(){let Y=this.filteredOptions[this.cursor];if(Y.selected)Y.selected=!1,this.render();else if(Y.disabled||this.value.filter(($)=>$.selected).length>=this.maxChoices)return this.bell();else Y.selected=!0,this.render()}handleInputChange(Y){this.inputValue=this.inputValue+Y,this.updateFilteredOptions()}_(Y,$){if(Y===" ")this.handleSpaceToggle();else this.handleInputChange(Y)}renderInstructions(){if(this.instructions===void 0||this.instructions){if(typeof this.instructions==="string")return this.instructions;return`
90
90
  Instructions:
91
- ${Q1.arrowUp}/${Q1.arrowDown}: Highlight option
92
- ${Q1.arrowLeft}/${Q1.arrowRight}/[space]: Toggle selection
91
+ ${G1.arrowUp}/${G1.arrowDown}: Highlight option
92
+ ${G1.arrowLeft}/${G1.arrowRight}/[space]: Toggle selection
93
93
  [a,b,c]/delete: Filter choices
94
94
  enter/return: Complete answer
95
95
  `}return""}renderCurrentInput(){return`
96
- Filtered results for: ${this.inputValue?this.inputValue:n.gray("Enter something to filter")}
97
- `}renderOption(Y,$,Z){let H;if($.disabled)H=Y===Z?n.gray().underline($.title):n.strikethrough().gray($.title);else H=Y===Z?n.cyan().underline($.title):$.title;return($.selected?n.green(Q1.radioOn):Q1.radioOff)+" "+H}renderDoneOrInstructions(){if(this.done)return this.value.filter(($)=>$.selected).map(($)=>$.title).join(", ");let Y=[n.gray(this.hint),this.renderInstructions(),this.renderCurrentInput()];if(this.filteredOptions.length&&this.filteredOptions[this.cursor].disabled)Y.push(n.yellow(this.warn));return Y.join(" ")}render(){if(this.closed)return;if(this.firstRender)this.out.write(_7.hide);super.render();let Y=[sY.symbol(this.done,this.aborted),n.bold(this.msg),sY.delimiter(!1),this.renderDoneOrInstructions()].join(" ");if(this.showMinError)Y+=n.red(`You must select a minimum of ${this.minSelected} choices.`),this.showMinError=!1;Y+=this.renderOptions(this.filteredOptions),this.out.write(this.clear+Y),this.clear=oY(Y,this.out.columns)}}aY.exports=tY});var U$=z((M5,H$)=>{var eY=S(),x7=c(),{style:Y$,clear:h7}=P(),{erase:f7,cursor:$$}=F();class Z$ extends x7{constructor(Y={}){super(Y);this.msg=Y.message,this.value=Y.initial,this.initialValue=!!Y.initial,this.yesMsg=Y.yes||"yes",this.yesOption=Y.yesOption||"(Y/n)",this.noMsg=Y.no||"no",this.noOption=Y.noOption||"(y/N)",this.render()}reset(){this.value=this.initialValue,this.fire(),this.render()}exit(){this.abort()}abort(){this.done=this.aborted=!0,this.fire(),this.render(),this.out.write(`
96
+ Filtered results for: ${this.inputValue?this.inputValue:s.gray("Enter something to filter")}
97
+ `}renderOption(Y,$,Z){let H;if($.disabled)H=Y===Z?s.gray().underline($.title):s.strikethrough().gray($.title);else H=Y===Z?s.cyan().underline($.title):$.title;return($.selected?s.green(G1.radioOn):G1.radioOff)+" "+H}renderDoneOrInstructions(){if(this.done)return this.value.filter(($)=>$.selected).map(($)=>$.title).join(", ");let Y=[s.gray(this.hint),this.renderInstructions(),this.renderCurrentInput()];if(this.filteredOptions.length&&this.filteredOptions[this.cursor].disabled)Y.push(s.yellow(this.warn));return Y.join(" ")}render(){if(this.closed)return;if(this.firstRender)this.out.write(iH.hide);super.render();let Y=[H$.symbol(this.done,this.aborted),s.bold(this.msg),H$.delimiter(!1),this.renderDoneOrInstructions()].join(" ");if(this.showMinError)Y+=s.red(`You must select a minimum of ${this.minSelected} choices.`),this.showMinError=!1;Y+=this.renderOptions(this.filteredOptions),this.out.write(this.clear+Y),this.clear=Z$(Y,this.out.columns)}}X$.exports=U$});var B$=B((s5,W$)=>{var J$=M(),oH=o(),{style:D$,clear:tH}=b(),{erase:sH,cursor:z$}=F();class K$ extends oH{constructor(Y={}){super(Y);this.msg=Y.message,this.value=Y.initial,this.initialValue=!!Y.initial,this.yesMsg=Y.yes||"yes",this.yesOption=Y.yesOption||"(Y/n)",this.noMsg=Y.no||"no",this.noOption=Y.noOption||"(y/N)",this.render()}reset(){this.value=this.initialValue,this.fire(),this.render()}exit(){this.abort()}abort(){this.done=this.aborted=!0,this.fire(),this.render(),this.out.write(`
98
98
  `),this.close()}submit(){this.value=this.value||!1,this.done=!0,this.aborted=!1,this.fire(),this.render(),this.out.write(`
99
- `),this.close()}_(Y,$){if(Y.toLowerCase()==="y")return this.value=!0,this.submit();if(Y.toLowerCase()==="n")return this.value=!1,this.submit();return this.bell()}render(){if(this.closed)return;if(this.firstRender)this.out.write($$.hide);else this.out.write(h7(this.outputText,this.out.columns));super.render(),this.outputText=[Y$.symbol(this.done,this.aborted),eY.bold(this.msg),Y$.delimiter(this.done),this.done?this.value?this.yesMsg:this.noMsg:eY.gray(this.initialValue?this.yesOption:this.noOption)].join(" "),this.out.write(f7.line+$$.to(0)+this.outputText)}}H$.exports=Z$});var X$=z((O5,J$)=>{J$.exports={TextPrompt:u9(),SelectPrompt:m9(),TogglePrompt:a9(),DatePrompt:bY(),NumberPrompt:gY(),MultiselectPrompt:I0(),AutocompletePrompt:iY(),AutocompleteMultiselectPrompt:rY(),ConfirmPrompt:U$()}});var D$=z((Q$)=>{var q=Q$,w7=X$(),i1=(Y)=>Y;function f(Y,$,Z={}){return new Promise((H,J)=>{let U=new w7[Y]($),X=Z.onAbort||i1,Q=Z.onSubmit||i1,D=Z.onExit||i1;U.on("state",$.onState||i1),U.on("submit",(K)=>H(Q(K))),U.on("exit",(K)=>H(D(K))),U.on("abort",(K)=>J(X(K)))})}q.text=(Y)=>f("TextPrompt",Y);q.password=(Y)=>{return Y.style="password",q.text(Y)};q.invisible=(Y)=>{return Y.style="invisible",q.text(Y)};q.number=(Y)=>f("NumberPrompt",Y);q.date=(Y)=>f("DatePrompt",Y);q.confirm=(Y)=>f("ConfirmPrompt",Y);q.list=(Y)=>{let $=Y.separator||",";return f("TextPrompt",Y,{onSubmit:(Z)=>Z.split($).map((H)=>H.trim())})};q.toggle=(Y)=>f("TogglePrompt",Y);q.select=(Y)=>f("SelectPrompt",Y);q.multiselect=(Y)=>{Y.choices=[].concat(Y.choices||[]);let $=(Z)=>Z.filter((H)=>H.selected).map((H)=>H.value);return f("MultiselectPrompt",Y,{onAbort:$,onSubmit:$})};q.autocompleteMultiselect=(Y)=>{Y.choices=[].concat(Y.choices||[]);let $=(Z)=>Z.filter((H)=>H.selected).map((H)=>H.value);return f("AutocompleteMultiselectPrompt",Y,{onAbort:$,onSubmit:$})};var g7=(Y,$)=>Promise.resolve($.filter((Z)=>Z.title.slice(0,Y.length).toLowerCase()===Y.toLowerCase()));q.autocomplete=(Y)=>{return Y.suggest=Y.suggest||g7,Y.choices=[].concat(Y.choices||[]),f("AutocompletePrompt",Y)}});var B$=z((I5,K$)=>{var C0=D$(),v7=["suggest","format","onState","validate","onRender","type"],z$=()=>{};async function r(Y=[],{onSubmit:$=z$,onCancel:Z=z$}={}){let H={},J=r._override||{};Y=[].concat(Y);let U,X,Q,D,K,e,Y1=async(G,N,T1=!1)=>{if(!T1&&G.validate&&G.validate(N)!==!0)return;return G.format?await G.format(N,H):N};for(X of Y){if({name:D,type:K}=X,typeof K==="function")K=await K(U,{...H},X),X.type=K;if(!K)continue;for(let G in X){if(v7.includes(G))continue;let N=X[G];X[G]=typeof N==="function"?await N(U,{...H},e):N}if(e=X,typeof X.message!=="string")throw new Error("prompt message is required");if({name:D,type:K}=X,C0[K]===void 0)throw new Error(`prompt type (${K}) is not defined`);if(J[X.name]!==void 0){if(U=await Y1(X,J[X.name]),U!==void 0){H[D]=U;continue}}try{U=r._injected?y7(r._injected,X.initial):await C0[K](X),H[D]=U=await Y1(X,U,!0),Q=await $(X,U,H)}catch(G){Q=!await Z(X,H)}if(Q)return H}return H}function y7(Y,$){let Z=Y.shift();if(Z instanceof Error)throw Z;return Z===void 0?$:Z}function d7(Y){r._injected=(r._injected||[]).concat(Y)}function u7(Y){r._override=Object.assign({},Y)}K$.exports=Object.assign(r,{prompt:r,prompts:C0,inject:d7,override:u7})});var C=z((A5,W$)=>{function c7(Y){Y=(Array.isArray(Y)?Y:Y.split(".")).map(Number);let $=0,Z=process.versions.node.split(".").map(Number);for(;$<Y.length;$++){if(Z[$]>Y[$])return!1;if(Y[$]>Z[$])return!0}return!1}W$.exports=c7("8.6.0")?M9():B$()});var p=z((Q8,L$)=>{var l7=/\{([0-9a-zA-Z_]+)\}/g;L$.exports=n7;function n7(Y){var $;if(arguments.length===2&&typeof arguments[1]==="object")$=arguments[1];else{$=new Array(arguments.length-1);for(var Z=1;Z<arguments.length;++Z)$[Z-1]=arguments[Z]}if(!$||!$.hasOwnProperty)$={};return Y.replace(l7,function H(J,U,X){var Q;if(Y[X-1]==="{"&&Y[X+J.length]==="}")return U;else{if(Q=$.hasOwnProperty(U)?$[U]:null,Q===null||Q===void 0)return"";return Q}})}});import"reflect-metadata";var T0=O(C(),1);import{join as s7}from"path";import{Command as A1,CommandArgumentType as s1}from"@elysiumjs/core";var N0=(Y,$,Z="asc")=>{if(!Y)return[];let H=(U,X)=>`${$(U)}`.localeCompare($(X)),J=(U,X)=>`${$(X)}`.localeCompare($(U));return Y.slice().sort(Z==="desc"?J:H)};var R$=(Y)=>{if(!Y||Y.length===0)return"";let $=Y.toLowerCase();return $.substring(0,1).toUpperCase()+$.substring(1,$.length)};var M=(Y,$)=>{let Z=Y?.replace(/([A-Z])+/g,R$).split(/(?=[A-Z])|[\.\-\s_]/).map((J)=>J.toLowerCase())??[];if(Z.length===0)return"";if(Z.length===1)return Z[0];let H=Z.reduce((J,U)=>{return`${J}_${U.toLowerCase()}`});return $?.splitOnNumber===!1?H:H.replace(/([A-Za-z]{1}[0-9]{1})/,(J)=>`${J[0]}_${J[1]}`)};var D1=(Y)=>{let $=Y?.split(/[\.\-\s_]/).map((Z)=>Z.toLowerCase())??[];if($.length===0)return"";return $.map((Z)=>Z.charAt(0).toUpperCase()+Z.slice(1)).join("")};var o1=(Y,$=" ")=>{if(!Y)return"";let Z=$.replace(/[\W]{1}/g,"\\$&"),H=new RegExp(`^[${Z}]+|[${Z}]+$`,"g");return Y.replace(H,"")};var F$=O(p(),1);import{join as o7}from"path";import{existsSync as p7}from"fs";import{mkdir as m7,readdir as E$,rename as G$}from"fs/promises";import{dirname as S$,extname as i7,join as j}from"path";var V=()=>{return S$(Bun.fileURLToPath(import.meta.url))},m=()=>{let Y=process.cwd(),$=Y;while(!0){if(p7(j($,".elysiumrc")))return $;let Z=S$($);if($===Z)break;$=Z}return Y},I1=async(Y,$)=>{let Z=m();{let H=j(Z,"src","modules",Y);if(await m7(H,{recursive:!0}),$)if($==="root"){let J=await E$(j(Z,"src"));for(let U of J){if(["app.ts","env.ts","database","modules"].includes(U))continue;let X=j(Z,"src",U),Q=j(H,U==="main.module.ts"?`${Y}.module.ts`:U);await G$(X,Q)}}else{let J=j(Z,"src","modules",$);await G$(J,H)}}{let H=await Bun.file(j(Z,"package.json")).json();if(H.imports=H.imports??{},H.imports[`#${Y}/*`]=`./src/modules/${Y}/*.ts`,$&&$!=="root")delete H.imports[`#${$}/*`];await Bun.write(j(Z,"package.json"),JSON.stringify(H,null,2))}{let H=await Bun.file(j(Z,".elysiumrc")).json();if(H.mono=!1,H.modules=H.modules??{},H.modules[Y]=`./src/modules/${Y}`,$)delete H.modules[$];await Bun.write(j(Z,".elysiumrc"),JSON.stringify(H,null,2))}if($){let H=async(J)=>{let U=await E$(J,{withFileTypes:!0});for(let X of U){let Q=j(J,X.name);if(X.isDirectory())await H(Q);else if(i7(X.name)===".ts"){let D=await Bun.file(Q).text();if($==="root")D=D.replace(new RegExp(`(['"])#${$}/((?!(env|app|database(?:/|$))).*?)(['"])`,"g"),`$1#${Y}/$2$4`);else D=D.replace(new RegExp(`(['"])#${$}/`,"g"),`$1#${Y}/`);D=D.replace(new RegExp(`(['"])#${$}/main\\.module(['"])/g`,"g"),`$1#${Y}/${Y}.module$2`),D=D.replace(new RegExp(`(['"])#${$}/main\\.module\\.ts(['"])?/g`,"g"),`$1#${Y}/${Y}.module$2`),await Bun.write(Q,D)}}};await H(Z)}};var L=async()=>{let Y=Bun.file(o7(m(),".elysiumrc"));if(!Y.exists())throw new Error("Elysium config file not found.");return Y.json()};var I=async(Y)=>{let $=await L();if($.mono)return"./src";return $.modules[Y]};class P0 extends A1{static command="make:command";static description="Creates a new command.";async run(){if(!this.command||!this.name)return this.setup();let Y=await L(),$={module:this.module,name:this.name,command:this.command,description:this.description};if(!$.module&&!Y.mono){let Z=await T0.default({type:"select",name:"module",message:"Module:",choices:Object.keys(Y.modules??{}).map((H)=>({title:H,value:H}))});$.module=Z.module}return this.build($)}async setup(){let Y=await L(),Z=await T0.default([{type(){return Y.mono?null:"select"},name:"module",message:"Module:",choices(){return Object.keys(Y.modules??{}).map((H)=>({title:H,value:H}))}},{type:"text",name:"command",message:"Command Name:",initial:"user:say",validate(H){if(H.length<1)return"Command name cannot be empty";return!0}},{type:"text",name:"description",message:"Command Description:",initial:"Say something",validate(H){if(H.length<1)return"Command description cannot be empty";return!0}}],{onCancel:()=>{this.error("Operation cancelled."),process.exit(0)}});return Z.name=D1(Z.command.replaceAll(":","_")),this.build(Z)}async build(Y){if(!Y.name){this.error("Operation cancelled.");return}if(!Y.name.endsWith("Command"))Y.name+="Command";let $=Bun.file(s7(V(),"stubs/command.stub")),Z=F$.default(await $.text(),Y),H=Y.module?await I(Y.module):"./src",J=M(Y.name.replace("Command","")),U=Bun.file(`${H}/commands/${J}.command.ts`);await U.write(Z),this.success(`Command ${this.bold(U.name)} created successfully.`)}}B([A1.arg({description:"The name of the command to create",type:s1.STRING}),W("design:type",String)],P0.prototype,"name",void 0),B([A1.arg({description:"The module where the command will be created",type:s1.STRING}),W("design:type",String)],P0.prototype,"module",void 0),B([A1.arg({description:"The command to create",type:s1.STRING}),W("design:type",String)],P0.prototype,"command",void 0),B([A1.arg({description:"The description of the command",type:s1.STRING}),W("design:type",String)],P0.prototype,"description",void 0);var j0=O(C(),1);import{join as t7}from"path";import{Command as w,CommandArgumentType as i}from"@elysiumjs/core";var M$=O(p(),1);class k0 extends w{constructor(){super(...arguments);this.http=!1;this.wamp=!1;this.ws=!1;this.server=!1;this.request=!1;this.path="/users"}static command="make:controller";static description="Creates a new controller.";async run(){if(!this.name)return this.setup();let Y=await L(),$={module:this.module,type:"http",scope:"SERVER",name:this.name,path:this.path,realm:this.realm??"realm1"};if(!$.module&&!Y.mono){let Z=await j0.default({type:"select",name:"module",message:"Module:",choices:Object.keys(Y.modules??{}).map((H)=>({title:H,value:H}))});$.module=Z.module}if(this.http)$.type="http";else if(this.wamp)$.type="wamp";else if(this.ws)$.type="ws";if(this.server)$.scope="SERVER";else if(this.request)$.scope="REQUEST";return this.build($)}async setup(){let Y="http",$=await L(),H=await j0.default([{type(){return $.mono?null:"select"},name:"module",message:"Module:",choices(){return Object.keys($.modules??{}).map((J)=>({title:J,value:J}))}},{type:"select",name:"type",message:"Controller Type:",choices:[{title:"HTTP",value:"http"},{title:"WAMP",value:"wamp"},{title:"WebSocket",value:"ws"}]},{type:"text",name:"name",message:"Controller Name:",initial:"UserController",validate:(J)=>{if(J.length<1)return"Controller name cannot be empty";return!0}},{type:"text",name:"path",message(J,U){return Y=U.type,U.type==="wamp"?"Controller URL":"Controller Path:"},initial(J,U){return U.type==="wamp"?"ws://localhost:8000":"/users"},validate(J){if(Y==="wamp")return J.match(/^wss?:\/\//)?!0:"The URL must start with ws:// or wss://";if(J[0]!=="/")return"The path must start with a slash (/)";return!0}},{type(J,U){return U.type==="http"?"select":null},name:"scope",message:"Controller Scope:",choices:[{title:"SERVER",value:"SERVER",description:"An unique instance of the controller is created for the entire lifecycle of the server."},{title:"REQUEST",value:"REQUEST",description:"An instance of the controller is created for each request."}]},{type(J,U){return U.type==="wamp"?"text":null},name:"realm",message:"Controller Realm:",initial:"realm1",validate(J){if(J.length<1)return"Realm name cannot be empty";return!0}}],{onCancel:()=>{this.error("Operation cancelled."),process.exit(0)}});return this.build(H)}async build(Y){if(!Y.type||!Y.name||!Y.path){this.error("Operation cancelled.");return}if(!Y.name.endsWith("Controller"))Y.name+="Controller";let $=Bun.file(t7(V(),`stubs/${Y.type}.controller.stub`)),Z=M$.default(await $.text(),Y),H=Y.module?await I(Y.module):"./src",J=M(Y.name.replace("Controller","")),U=Bun.file(`${H}/controllers/${Y.type}/${J}.controller.ts`);await U.write(Z),this.success(`Controller ${this.bold(U.name)} created successfully.`)}}B([w.arg({description:"The name of the controller to create",type:i.STRING}),W("design:type",String)],k0.prototype,"name",void 0),B([w.arg({description:"The module where the controller will be created",type:i.STRING}),W("design:type",String)],k0.prototype,"module",void 0),B([w.arg({description:"Whether to create a HTTP controller",type:i.BOOLEAN,default:!1}),W("design:type",Boolean)],k0.prototype,"http",void 0),B([w.arg({description:"Whether to create a WAMP controller",type:i.BOOLEAN,default:!1}),W("design:type",Boolean)],k0.prototype,"wamp",void 0),B([w.arg({description:"Whether to create a WebSocket controller",type:i.BOOLEAN,default:!1}),W("design:type",Boolean)],k0.prototype,"ws",void 0),B([w.arg({description:"Whether to create a SERVER scope controller",type:i.BOOLEAN,default:!1}),W("design:type",Boolean)],k0.prototype,"server",void 0),B([w.arg({description:"Whether to create a REQUEST scope controller",type:i.BOOLEAN,default:!1}),W("design:type",Boolean)],k0.prototype,"request",void 0),B([w.arg({description:"The path or URL of the controller",type:i.STRING}),W("design:type",String)],k0.prototype,"path",void 0),B([w.arg({description:"The realm of the controller (only applicable to WAMP controllers)",type:i.STRING}),W("design:type",String)],k0.prototype,"realm",void 0);var _0=O(C(),1);import{join as a7}from"path";import{Command as q1,CommandArgumentType as t1}from"@elysiumjs/core";var O$=O(p(),1);class b0 extends q1{constructor(){super(...arguments);this.queue="default"}static command="make:job";static description="Creates a new job.";async run(){if(!this.name)return this.setup();let Y=await L(),$={module:this.module,name:this.name,alias:this.alias,queue:this.queue??"default"};if(!$.module&&!Y.mono){let Z=await _0.default({type:"select",name:"module",message:"Module:",choices:Object.keys(Y.modules??{}).map((H)=>({title:H,value:H}))});$.module=Z.module}return this.build($)}async setup(){let Y=await L(),Z=await _0.default([{type(){return Y.mono?null:"select"},name:"module",message:"Module:",choices(){return Object.keys(Y.modules??{}).map((H)=>({title:H,value:H}))}},{type:"text",name:"name",message:"Job Name:",initial:"SendEmailJob",validate(H){if(H.length<1)return"Job name cannot be empty";return!0}},{type:"text",name:"alias",message:"Job Alias:",initial(H,J){return J.name},validate(H){if(H.length<1)return"Job alias cannot be empty";return!0}},{type:"text",name:"queue",message:"Job Queue:",initial:"default"}],{onCancel:()=>{this.error("Operation cancelled."),process.exit(0)}});return this.build(Z)}async build(Y){if(!Y.name){this.error("Operation cancelled.");return}if(!Y.name.endsWith("Job"))Y.name+="Job";if(!Y.alias)Y.alias=Y.name;let $=Bun.file(a7(V(),"stubs/job.stub")),Z=O$.default(await $.text(),Y),H=Y.module?await I(Y.module):"./src",J=M(Y.name.replace("Job","")),U=Bun.file(`${H}/jobs/${J}.job.ts`);await U.write(Z),this.success(`Job ${this.bold(U.name)} created successfully.`)}}B([q1.arg({description:"The name of the job to create",type:t1.STRING}),W("design:type",String)],b0.prototype,"name",void 0),B([q1.arg({description:"The module where the job will be created",type:t1.STRING}),W("design:type",String)],b0.prototype,"module",void 0),B([q1.arg({description:"The alias of the job to create",type:t1.STRING}),W("design:type",String)],b0.prototype,"alias",void 0),B([q1.arg({description:"The name of the queue where the job will be dispatched",type:t1.STRING,default:"default"}),W("design:type",String)],b0.prototype,"queue",void 0);var h0=O(C(),1);import{join as r7}from"path";import{Command as x0,CommandArgumentType as V$}from"@elysiumjs/core";var I$=O(p(),1);class f0 extends x0{static command="make:middleware";static description="Creates a new middleware.";async run(){if(!this.name)return this.setup();let Y=await L(),$={module:this.module,name:this.name};if(!$.module&&!Y.mono){let Z=await h0.default({type:"select",name:"module",message:"Module:",choices:Object.keys(Y.modules??{}).map((H)=>({title:H,value:H}))});$.module=Z.module}return this.build($)}async setup(){let Y=await L(),Z=await h0.default([{type(){return Y.mono?null:"select"},name:"module",message:"Module:",choices(){return Object.keys(Y.modules??{}).map((H)=>({title:H,value:H}))}},{type:"text",name:"name",message:"Middleware Name:",initial:"AuthMiddleware",validate(H){if(H.length<1)return"Middleware name cannot be empty";return!0}}],{onCancel:()=>{this.error("Operation cancelled."),process.exit(0)}});return this.build(Z)}async build(Y){if(!Y.name){this.error("Operation cancelled.");return}if(!Y.name.endsWith("Middleware"))Y.name+="Middleware";let $=Bun.file(r7(V(),"stubs/middleware.stub")),Z=I$.default(await $.text(),Y),H=Y.module?await I(Y.module):"./src",J=M(Y.name.replace("Middleware","")),U=Bun.file(`${H}/middlewares/${J}.middleware.ts`);await U.write(Z),this.success(`Middleware ${this.bold(U.name)} created successfully.`)}}B([x0.arg({description:"The name of the middleware to create",type:V$.STRING}),W("design:type",String)],f0.prototype,"name",void 0),B([x0.arg({description:"The module where the middleware will be created",type:V$.STRING}),W("design:type",String)],f0.prototype,"module",void 0);var w0=O(C(),1);import{join as e7}from"path";import{Command as C1,CommandArgumentType as a1}from"@elysiumjs/core";var A$=O(p(),1);class g0 extends C1{constructor(){super(...arguments);this.supportTenancy=!1}static command="make:model";static description="Creates a new model.";async run(){if(!this.name||!this.tableName)return this.setup();let Y=await L(),$={module:this.module,table:this.tableName,name:this.name,supportTenancy:this.supportTenancy};if(!$.module&&!Y.mono){let Z=await w0.default({type:"select",name:"module",message:"Module:",choices:Object.keys(Y.modules??{}).map((H)=>({title:H,value:H}))},{onCancel:()=>process.exit(1)});$.module=Z.module}if(!$.name)$.name=o1(D1($.table),"s");return $.canonicalName=$.name,this.build($)}async setup(){let Y=await L(),Z=await w0.default([{type(){return Y.mono?null:"select"},name:"module",message:"Module:",choices(){return Object.keys(Y.modules??{}).map((H)=>({title:H,value:H}))}},{type:"text",name:"table",message:"Table Name:",initial:"users",validate(H){if(H.length<1)return"Table name cannot be empty";return!0}},{type:"text",name:"name",message:"Model Name:",initial(H,J){return o1(D1(J.table),"s")},validate(H){if(H.length<1)return"Model name cannot be empty";return!0}},{type:"select",name:"supportTenancy",message:"Support Tenancy:",choices:[{title:"Yes",value:!0,description:"The model supports multi-tenancy."},{title:"No",value:!1,description:"The model does not support multi-tenancy."}]}],{onCancel:()=>{this.error("Operation cancelled."),process.exit(0)}});return this.build(Z)}async build(Y){if(!Y.name){this.error("Operation cancelled.");return}if(!Y.name.endsWith("Model"))Y.name+="Model";Y.canonicalName=Y.name.replace("Model","");let $=Bun.file(e7(V(),"stubs/model.stub")),Z=A$.default(await $.text(),Y),H=Y.module?await I(Y.module):"./src",J=M(Y.name.replace("Model","")),U=Bun.file(`${H}/models/${J}.model.ts`);await U.write(Z),this.success(`Model ${this.bold(U.name)} created successfully.`)}}B([C1.arg({description:"The name of the model to create",type:a1.STRING}),W("design:type",String)],g0.prototype,"name",void 0),B([C1.arg({description:"The module where the model will be created",type:a1.STRING}),W("design:type",String)],g0.prototype,"module",void 0),B([C1.arg({name:"table",description:"The name of the table wrapped by the model",type:a1.STRING}),W("design:type",String)],g0.prototype,"tableName",void 0),B([C1.arg({name:"support-tenancy",description:"Support tenancy",type:a1.BOOLEAN,default:!1}),W("design:type",Boolean)],g0.prototype,"supportTenancy",void 0);var v0=O(C(),1);import{join as YU}from"path";import{Command as H1,CommandArgumentType as z1}from"@elysiumjs/core";var q$=O(p(),1);class y0 extends H1{constructor(){super(...arguments);this.factory=!1;this.singleton=!1}static command="make:repository";static description="Creates a new repository.";async run(){if(!this.name)return this.setup();let Y=await L(),$={module:this.module,name:this.name,alias:this.alias,scope:this.factory?"FACTORY":this.singleton?"SINGLETON":"SINGLETON",model:this.model};if(!$.module&&!Y.mono){let Z=await v0.default({type:"select",name:"module",message:"Module:",choices:Object.keys(Y.modules??{}).map((H)=>({title:H,value:H}))});$.module=Z.module}return this.build($)}async setup(){let Y=await L(),Z=await v0.default([{type(){return Y.mono?null:"select"},name:"module",message:"Module:",choices(){return Object.keys(Y.modules??{}).map((H)=>({title:H,value:H}))}},{type:"text",name:"name",message:"Repository Name:",initial:"UserRepository",validate(H){if(H.length<1)return"Repository name cannot be empty";return!0}},{type:"text",name:"model",message:"Model Name:",initial:"UserModel",validate(H){if(H.length<1)return"Model name cannot be empty";return!0}},{type:"text",name:"alias",message:"Repository Alias:",initial(H,J){return J.name},validate(H){if(H.length<1)return"Repository alias cannot be empty";return!0}},{type:"select",name:"scope",message:"Repository Scope:",choices:[{title:"SINGLETON",value:"SINGLETON",description:"A single instance of the repository is created."},{title:"FACTORY",value:"FACTORY",description:"A new instance of the repository is created each time it is injected."}]}],{onCancel:()=>{this.error("Operation cancelled."),process.exit(0)}});return this.build(Z)}async build(Y){if(!Y.name){this.error("Operation cancelled.");return}if(!Y.name.endsWith("Repository"))Y.name+="Repository";if(!Y.alias)Y.alias=Y.name;let $=Bun.file(YU(V(),"stubs/repository.stub")),Z=q$.default(await $.text(),{...Y,module:Y.module??"root",model_name:M(Y.model.replace("Model",""))}),H=Y.module?await I(Y.module):"./src",J=M(Y.name.replace("Repository","")),U=Bun.file(`${H}/repositories/${J}.repository.ts`);await U.write(Z),this.success(`Repository ${this.bold(U.name)} created successfully.`)}}B([H1.arg({description:"The name of the repository to create",type:z1.STRING}),W("design:type",String)],y0.prototype,"name",void 0),B([H1.arg({description:"The module where the repository will be created",type:z1.STRING}),W("design:type",String)],y0.prototype,"module",void 0),B([H1.arg({description:"The alias of the repository to create",type:z1.STRING}),W("design:type",String)],y0.prototype,"alias",void 0),B([H1.arg({description:"The model used by the repository",type:z1.STRING}),W("design:type",String)],y0.prototype,"model",void 0),B([H1.arg({description:"Create a factory repository",type:z1.BOOLEAN,default:!1}),W("design:type",Boolean)],y0.prototype,"factory",void 0),B([H1.arg({description:"Create a singleton repository",type:z1.BOOLEAN,default:!1}),W("design:type",Boolean)],y0.prototype,"singleton",void 0);var d0=O(C(),1);import{join as $U}from"path";import{Command as K1,CommandArgumentType as N1}from"@elysiumjs/core";var C$=O(p(),1);class u0 extends K1{constructor(){super(...arguments);this.factory=!1;this.singleton=!1}static command="make:service";static description="Creates a new service.";async run(){if(!this.name)return this.setup();let Y=await L(),$={module:this.module,name:this.name,alias:this.alias,scope:this.factory?"FACTORY":this.singleton?"SINGLETON":"SINGLETON"};if(!$.module&&!Y.mono){let Z=await d0.default({type:"select",name:"module",message:"Module:",choices:Object.keys(Y.modules??{}).map((H)=>({title:H,value:H}))});$.module=Z.module}return this.build($)}async setup(){let Y=await L(),Z=await d0.default([{type(){return Y.mono?null:"select"},name:"module",message:"Module:",choices(){return Object.keys(Y.modules??{}).map((H)=>({title:H,value:H}))}},{type:"text",name:"name",message:"Service Name:",initial:"UserService",validate(H){if(H.length<1)return"Service name cannot be empty";return!0}},{type:"text",name:"alias",message:"Service Alias:",initial(H,J){return J.name},validate(H){if(H.length<1)return"Service alias cannot be empty";return!0}},{type:"select",name:"scope",message:"Service Scope:",choices:[{title:"SINGLETON",value:"SINGLETON",description:"A single instance of the service is created."},{title:"FACTORY",value:"FACTORY",description:"A new instance of the service is created each time it is injected."}]}],{onCancel:()=>{this.error("Operation cancelled."),process.exit(0)}});return this.build(Z)}async build(Y){if(!Y.name){this.error("Operation cancelled.");return}if(!Y.name.endsWith("Service"))Y.name+="Service";if(!Y.alias)Y.alias=Y.name;let $=Bun.file($U(V(),"stubs/service.stub")),Z=C$.default(await $.text(),Y),H=Y.module?await I(Y.module):"./src",J=M(Y.name.replace("Service","")),U=Bun.file(`${H}/services/${J}.service.ts`);await U.write(Z),this.success(`Service ${this.bold(U.name)} created successfully.`)}}B([K1.arg({description:"The name of the service to create",type:N1.STRING}),W("design:type",String)],u0.prototype,"name",void 0),B([K1.arg({description:"The module where the service will be created",type:N1.STRING}),W("design:type",String)],u0.prototype,"module",void 0),B([K1.arg({description:"The alias of the service to create",type:N1.STRING}),W("design:type",String)],u0.prototype,"alias",void 0),B([K1.arg({description:"Create a factory service",type:N1.BOOLEAN,default:!1}),W("design:type",Boolean)],u0.prototype,"factory",void 0),B([K1.arg({description:"Create a singleton service",type:N1.BOOLEAN,default:!1}),W("design:type",Boolean)],u0.prototype,"singleton",void 0);var l0=O(C(),1);import{join as ZU}from"path";import{Command as c0,CommandArgumentType as N$}from"@elysiumjs/core";var T$=O(p(),1);class n0 extends c0{static command="make:validator";static description="Creates a new validator.";async run(){if(!this.name)return this.setup();let Y=await L(),$={module:this.module,name:this.name};if(!$.module&&!Y.mono){let Z=await l0.default({type:"select",name:"module",message:"Module:",choices:Object.keys(Y.modules??{}).map((H)=>({title:H,value:H}))});$.module=Z.module}return this.build($)}async setup(){let Y=await L(),Z=await l0.default([{type(){return Y.mono?null:"select"},name:"module",message:"Module:",choices(){return Object.keys(Y.modules??{}).map((H)=>({title:H,value:H}))}},{type:"text",name:"name",message:"Validator Name:",initial:"LoginValidator",validate(H){if(H.length<1)return"Validator name cannot be empty";return!0}}],{onCancel:()=>{this.error("Operation cancelled."),process.exit(0)}});return this.build(Z)}async build(Y){if(!Y.name){this.error("Operation cancelled.");return}if(!Y.name.endsWith("Validator"))Y.name+="Validator";if(!Y.request_name)Y.request_name=Y.name.replace("Validator","Request");let $=Bun.file(ZU(V(),"stubs/validator.stub")),Z=T$.default(await $.text(),Y),H=Y.module?await I(Y.module):"./src",J=M(Y.name.replace("Validator","")),U=Bun.file(`${H}/validators/${J}.validator.ts`);await U.write(Z),this.success(`Validator ${this.bold(U.name)} created successfully.`)}}B([c0.arg({description:"The name of the validator to create",type:N$.STRING}),W("design:type",String)],n0.prototype,"name",void 0),B([c0.arg({description:"The module where the validator will be created",type:N$.STRING}),W("design:type",String)],n0.prototype,"module",void 0);var j$=O(C(),1);import{exists as HU}from"fs/promises";import{Command as P$,CommandArgumentType as UU}from"@elysiumjs/core";class p0 extends P${static command="migration:generate";static description="Generates migration files.";async run(){if(!this.name){let H=await j$.default([{type:"text",name:"name",message:"Migration Name:",initial:"create_users_table",validate(J){if(J.length<1)return"Migration name cannot be empty";return!0}}],{onCancel:()=>{this.error("Operation cancelled."),process.exit(0)}});this.name=H.name}let Y=m(),$=`${Y}/src/database/schemas`;if(await HU(`${Y}/src/database/schema.ts`))$=`${Y}/src/database/schema.ts`;await Bun.$`bunx --bun drizzle-kit generate --dialect postgresql --schema ${$} --out ${Y}/src/database/migrations --prefix timestamp --name ${this.name}`;let Z=new Bun.Glob(`${Y}/src/database/migrations/**/*.sql`).scan();for await(let H of Z){let J=Bun.file(H),U=await J.text();await J.write(U.replace(/"public"\./gm,""))}}}B([P$.arg({description:"The name of the migration to create",type:UU.STRING}),W("design:type",String)],p0.prototype,"name",void 0);var b$=O(C(),1);import{basename as k$}from"path";import{Command as r1,CommandArgumentType as m0,Database as _$}from"@elysiumjs/core";class i0 extends r1{constructor(){super(...arguments);this.tenant="";this.connection="default";this.fresh=!1}static command="migration:run";static description="Generates migration files.";async run(){if(!_$.connectionExists(this.connection))return this.error(`Connection ${this.bold(this.connection)} does not exist.`),process.exit(1);let Y=_$.getConnection(this.connection).$client;await Y.connect(),await Y.begin(async($)=>{if(this.fresh)await $`DROP SCHEMA IF EXISTS ${$(this.tenant)} CASCADE;`,await $`CREATE SCHEMA ${$(this.tenant)};`;let[{schema_exists:Z}]=await $`SELECT EXISTS (
99
+ `),this.close()}_(Y,$){if(Y.toLowerCase()==="y")return this.value=!0,this.submit();if(Y.toLowerCase()==="n")return this.value=!1,this.submit();return this.bell()}render(){if(this.closed)return;if(this.firstRender)this.out.write(z$.hide);else this.out.write(tH(this.outputText,this.out.columns));super.render(),this.outputText=[D$.symbol(this.done,this.aborted),J$.bold(this.msg),D$.delimiter(this.done),this.done?this.value?this.yesMsg:this.noMsg:J$.gray(this.initialValue?this.yesOption:this.noOption)].join(" "),this.out.write(sH.line+z$.to(0)+this.outputText)}}W$.exports=K$});var G$=B((r5,E$)=>{E$.exports={TextPrompt:t9(),SelectPrompt:YY(),TogglePrompt:XY(),DatePrompt:dY(),NumberPrompt:nY(),MultiselectPrompt:x0(),AutocompletePrompt:$$(),AutocompleteMultiselectPrompt:Q$(),ConfirmPrompt:B$()}});var L$=B((R$)=>{var T=R$,rH=G$(),r1=(Y)=>Y;function u(Y,$,Z={}){return new Promise((H,U)=>{let X=new rH[Y]($),Q=Z.onAbort||r1,J=Z.onSubmit||r1,D=Z.onExit||r1;X.on("state",$.onState||r1),X.on("submit",(W)=>H(J(W))),X.on("exit",(W)=>H(D(W))),X.on("abort",(W)=>U(Q(W)))})}T.text=(Y)=>u("TextPrompt",Y);T.password=(Y)=>{return Y.style="password",T.text(Y)};T.invisible=(Y)=>{return Y.style="invisible",T.text(Y)};T.number=(Y)=>u("NumberPrompt",Y);T.date=(Y)=>u("DatePrompt",Y);T.confirm=(Y)=>u("ConfirmPrompt",Y);T.list=(Y)=>{let $=Y.separator||",";return u("TextPrompt",Y,{onSubmit:(Z)=>Z.split($).map((H)=>H.trim())})};T.toggle=(Y)=>u("TogglePrompt",Y);T.select=(Y)=>u("SelectPrompt",Y);T.multiselect=(Y)=>{Y.choices=[].concat(Y.choices||[]);let $=(Z)=>Z.filter((H)=>H.selected).map((H)=>H.value);return u("MultiselectPrompt",Y,{onAbort:$,onSubmit:$})};T.autocompleteMultiselect=(Y)=>{Y.choices=[].concat(Y.choices||[]);let $=(Z)=>Z.filter((H)=>H.selected).map((H)=>H.value);return u("AutocompleteMultiselectPrompt",Y,{onAbort:$,onSubmit:$})};var aH=(Y,$)=>Promise.resolve($.filter((Z)=>Z.title.slice(0,Y.length).toLowerCase()===Y.toLowerCase()));T.autocomplete=(Y)=>{return Y.suggest=Y.suggest||aH,Y.choices=[].concat(Y.choices||[]),u("AutocompletePrompt",Y)}});var F$=B((e5,M$)=>{var f0=L$(),eH=["suggest","format","onState","validate","onRender","type"],S$=()=>{};async function Q1(Y=[],{onSubmit:$=S$,onCancel:Z=S$}={}){let H={},U=Q1._override||{};Y=[].concat(Y);let X,Q,J,D,W,I,C=async(L,N,J1=!1)=>{if(!J1&&L.validate&&L.validate(N)!==!0)return;return L.format?await L.format(N,H):N};for(Q of Y){if({name:D,type:W}=Q,typeof W==="function")W=await W(X,{...H},Q),Q.type=W;if(!W)continue;for(let L in Q){if(eH.includes(L))continue;let N=Q[L];Q[L]=typeof N==="function"?await N(X,{...H},I):N}if(I=Q,typeof Q.message!=="string")throw new Error("prompt message is required");if({name:D,type:W}=Q,f0[W]===void 0)throw new Error(`prompt type (${W}) is not defined`);if(U[Q.name]!==void 0){if(X=await C(Q,U[Q.name]),X!==void 0){H[D]=X;continue}}try{X=Q1._injected?YU(Q1._injected,Q.initial):await f0[W](Q),H[D]=X=await C(Q,X,!0),J=await $(Q,X,H)}catch(L){J=!await Z(Q,H)}if(J)return H}return H}function YU(Y,$){let Z=Y.shift();if(Z instanceof Error)throw Z;return Z===void 0?$:Z}function $U(Y){Q1._injected=(Q1._injected||[]).concat(Y)}function ZU(Y){Q1._override=Object.assign({},Y)}M$.exports=Object.assign(Q1,{prompt:Q1,prompts:f0,inject:$U,override:ZU})});var _=B((Y8,V$)=>{function HU(Y){Y=(Array.isArray(Y)?Y:Y.split(".")).map(Number);let $=0,Z=process.versions.node.split(".").map(Number);for(;$<Y.length;$++){if(Z[$]>Y[$])return!1;if(Y[$]>Z[$])return!0}return!1}V$.exports=HU("8.6.0")?T9():F$()});var r=B((g8,I$)=>{var UU=/\{([0-9a-zA-Z_]+)\}/g;I$.exports=XU;function XU(Y){var $;if(arguments.length===2&&typeof arguments[1]==="object")$=arguments[1];else{$=new Array(arguments.length-1);for(var Z=1;Z<arguments.length;++Z)$[Z-1]=arguments[Z]}if(!$||!$.hasOwnProperty)$={};return Y.replace(UU,function H(U,X,Q){var J;if(Y[Q-1]==="{"&&Y[Q+U.length]==="}")return X;else{if(J=$.hasOwnProperty(X)?$[X]:null,J===null||J===void 0)return"";return J}})}});import"reflect-metadata";import"@elysiumjs/core";import{Command as t$}from"@elysiumjs/core";class E extends t${static dev=!0}import{Command as $1,CommandArgumentType as c,Redis as D2}from"@elysiumjs/core";import{JobStatus as Q0}from"@elysiumjs/heracles";class J0 extends E{constructor(){super(...arguments);this.redis="default";this.queues=[];this.dryRun=!1;this.verbose=!1;this.all=!1;this.keyPrefix="elysium:heracles";this.retention=3600;this.max=1000}static command="heracles:clean";static description="Clean up Redis streams by removing completed and failed jobs.";static dev=!1;async run(){try{if(!D2.connectionExists(this.redis))this.error(`Redis connection '${this.redis}' does not exist`),process.exit(1);let Y=D2.getConnection(this.redis);if(this.queues.length===0){let X=await Y.keys(`${this.keyPrefix}:stream:*`);this.queues=X.map((Q)=>Q.replace(`${this.keyPrefix}:stream:`,""))}if(this.verbose)this.write("=== Redis Stream Cleanup ==="),this.write(`- Redis connection: ${this.redis}`),this.write(`- Key prefix: ${this.keyPrefix}`),this.write(`- Queues to clean: ${this.queues.join(", ")||"none found"}`),this.write(`- Retention period: ${this.retention} seconds`),this.write(`- Maximum stream size: ${this.max}`),this.write(`- Dry run mode: ${this.dryRun?"Yes":"No"}`);if(this.queues.length===0){this.newLine(),this.error("No queues found to clean");return}let $=0,Z=0,H=0,U=this.spinner("Cleaning streams...");for(let X of this.queues){let Q=`${this.keyPrefix}:stream:${X}`,J;try{if(J=await Y.send("XLEN",[Q]),this.verbose)U.pause(`
100
+ Queue: ${X}`),U.pause(`- Current stream length: ${J}`)}catch(D){if(this.verbose)U.pause(`
101
+ Queue: ${X} - stream not found or empty`);continue}if(this.all){if(!this.dryRun){if(await Y.del(Q),$+=J,this.verbose)U.pause(`- Deleted entire stream (${J} entries)`)}else if(this.verbose)U.pause(`- Would delete entire stream (${J} entries)`)}else{if(this.retention>0){let D=await Y.keys(`${this.keyPrefix}:status:${X}:*`),W=[];for(let I of D){let C=await Y.send("HGET",[I,"status"]),L=await Y.send("HGET",[I,"updatedAt"]);if((C===Q0.COMPLETED||C===Q0.FAILED||C===Q0.CANCELLED)&&L&&parseInt(L)<Date.now()-this.retention*1000){let N=I.split(":").pop(),J1=await Y.send("HGET",[I,"messageId"]);if(J1)W.push(J1);else{let x1=await Y.send("XRANGE",[Q,"-","+","COUNT","1000"]);for(let[k,j]of x1){let f={};for(let D1=0;D1<j.length;D1+=2)f[j[D1]]=j[D1+1];if((f.jobId===N||k.includes(N))&&(f.type==="job:result"||f.type==="job:status"||f.type==="job:process"))W.push(k)}}if(!this.dryRun)await Y.send("DEL",[I]),H++}}if(W.length>0){if(this.verbose)U.pause(`- Found ${W.length} expired completed job entries`);if(!this.dryRun){for(let I=0;I<W.length;I+=100){let C=W.slice(I,I+100);await Y.send("XDEL",[Q,...C])}if($+=W.length,this.verbose)U.pause(`- Removed ${W.length} expired completed job entries from stream`)}else if(this.verbose)U.pause(`- Would remove ${W.length} expired completed job entries from stream`)}else if(this.verbose)U.pause("- No expired completed job entries found")}if(this.max>0&&J>this.max){if(!this.dryRun){if(await Y.send("XTRIM",[Q,"MAXLEN","~",this.max.toString()]),Z+=J-this.max,this.verbose)U.pause(`- Trimmed stream from ${J} to ~${this.max} entries`)}else if(this.verbose)U.pause(`- Would trim stream from ${J} to ~${this.max} entries`)}}}U.complete("Cleanup operation completed")}catch(Y){this.trace(Y,"Error cleaning up Redis streams"),process.exit(1)}}}z([$1.arg({name:"redis",required:!0,description:"Name of the Redis connection to use",type:c.STRING,default:"default"}),K("design:type",String)],J0.prototype,"redis",void 0),z([$1.arg({name:"queues",description:"List of queues to clean. If empty, all queues will be cleaned",type:c.ARRAY,arrayType:c.STRING,default:[]}),K("design:type",Array)],J0.prototype,"queues",void 0),z([$1.arg({name:"dry-run",description:"Show what would be removed without actually removing",type:c.BOOLEAN,default:!1}),K("design:type",Boolean)],J0.prototype,"dryRun",void 0),z([$1.arg({name:"verbose",description:"Enable verbose logging",type:c.BOOLEAN,default:!1}),K("design:type",Boolean)],J0.prototype,"verbose",void 0),z([$1.arg({name:"all",description:"Remove all entries, not only completed and failed jobs",type:c.BOOLEAN,default:!1}),K("design:type",Boolean)],J0.prototype,"all",void 0),z([$1.arg({name:"key-prefix",description:"Redis key prefix to clean",type:c.STRING,default:"elysium:heracles"}),K("design:type",String)],J0.prototype,"keyPrefix",void 0),z([$1.arg({name:"retention",description:"Number of seconds to retain completed jobs",type:c.NUMBER,default:3600}),K("design:type",Number)],J0.prototype,"retention",void 0),z([$1.arg({name:"max",description:"Maximum number of jobs to clean",type:c.NUMBER,default:1000}),K("design:type",Number)],J0.prototype,"max",void 0);import{Command as s$,ConsoleFormat as r$,InteractsWithConsole as a$,Service as z2}from"@elysiumjs/core";class D0 extends s${static command="heracles:list";static description="List all registered Heracles jobs and schedulers.";static dev=!1;async run(){let Y=z2.keys("elysium.heracles.job.*");if(Y.length===0)this.write("No registered jobs found.");else{this.title("Jobs:");for(let $ of Y){let Z=$.replace("elysium.heracles.job.",""),H=z2.get($),U=Z===H.name?" ":` (${H.name}) `;this.write(` ${this.format(Z,r$.CYAN)}${U}${"\u2219".repeat(a$.SPACE_WIDTH-Z.length-U.length)} ${H.description}`)}}}}import{Command as Z1,CommandArgumentType as l,Redis as e$}from"@elysiumjs/core";import{RedisWorker as YZ}from"@elysiumjs/heracles";class z0 extends E{constructor(){super(...arguments);this.id=null;this.queues=["default"];this.concurrency=1;this.redis="default";this.maxRetries=3;this.retryDelay=5000;this.pauseOnError=!1;this.verbose=!1}static command="heracles:work";static description="Start an Heracles worker for specific queues.";static dev=!1;async run(){if(this.verbose)this.write(`Starting Heracles worker with id ${this.id} for queues ${this.queues.join(", ")}`),this.write(` Concurrency: ${this.concurrency} jobs`),this.write(` Redis Connection: ${this.redis}`),this.write(` Max Retries: ${this.maxRetries}`),this.write(` Retry Delay: ${this.retryDelay}ms`),this.write(` Pause on Error: ${this.pauseOnError}`);if(!e$.connectionExists(this.redis))this.error(`Redis connection "${this.redis}" does not exist`),process.exit(1);let Y=new YZ(this.redis,{id:this.id});for(let Z of this.queues)await Y.createQueue({name:Z,concurrency:this.concurrency,maxRetries:this.maxRetries,retryDelay:this.retryDelay,pauseOnError:this.pauseOnError});let $=async()=>{if(this.verbose)this.write("Stopping worker gracefully...");if(await Y.stop(!1),this.verbose)this.write(`Worker "${Y.id}" stopped successfully`);process.exit(0)};if(process.on("SIGINT",$),process.on("SIGTERM",$),await Y.start(),this.verbose)this.write(`Worker "${Y.id}" started successfully`),this.write("Press Ctrl+C to stop the worker");await new Promise(()=>{})}}z([Z1.arg({name:"id",required:!0,description:"Unique identifier for this worker",type:l.STRING}),K("design:type",String)],z0.prototype,"id",void 0),z([Z1.arg({name:"queues",required:!0,description:"List of queues to work on",type:l.ARRAY,arrayType:l.STRING,default:["default"]}),K("design:type",Array)],z0.prototype,"queues",void 0),z([Z1.arg({name:"concurrency",required:!0,description:"Number of concurrent jobs to process",type:l.NUMBER,default:1}),K("design:type",Number)],z0.prototype,"concurrency",void 0),z([Z1.arg({name:"redis",required:!0,description:"Name of the Redis connection to use",type:l.STRING,default:"default"}),K("design:type",String)],z0.prototype,"redis",void 0),z([Z1.arg({name:"max-retries",required:!1,description:"Maximum retries for failed jobs before giving up",type:l.NUMBER,default:3}),K("design:type",Number)],z0.prototype,"maxRetries",void 0),z([Z1.arg({name:"retry-delay",required:!1,description:"Delay between retries in milliseconds",type:l.NUMBER,default:5000}),K("design:type",Number)],z0.prototype,"retryDelay",void 0),z([Z1.arg({name:"pause-on-error",required:!1,description:"Pause the worker when an error occurs",type:l.BOOLEAN,default:!1}),K("design:type",Boolean)],z0.prototype,"pauseOnError",void 0),z([Z1.arg({name:"verbose",required:!1,description:"Enable verbose logging",type:l.BOOLEAN,default:!1}),K("design:type",Boolean)],z0.prototype,"verbose",void 0);var v0=O(_(),1);import{join as KU}from"path";import{Command as e1,CommandArgumentType as Y0}from"@elysiumjs/core";var w0=(Y,$,Z="asc")=>{if(!Y)return[];let H=(X,Q)=>`${$(X)}`.localeCompare($(Q)),U=(X,Q)=>`${$(Q)}`.localeCompare($(X));return Y.slice().sort(Z==="desc"?U:H)};var O$=(Y)=>{if(!Y||Y.length===0)return"";let $=Y.toLowerCase();return $.substring(0,1).toUpperCase()+$.substring(1,$.length)};var V=(Y,$)=>{let Z=Y?.replace(/([A-Z])+/g,O$).split(/(?=[A-Z])|[\.\-\s_]/).map((U)=>U.toLowerCase())??[];if(Z.length===0)return"";if(Z.length===1)return Z[0];let H=Z.reduce((U,X)=>{return`${U}_${X.toLowerCase()}`});return $?.splitOnNumber===!1?H:H.replace(/([A-Za-z]{1}[0-9]{1})/,(U)=>`${U[0]}_${U[1]}`)};var R1=(Y)=>{let $=Y?.split(/[\.\-\s_]/).map((Z)=>Z.toLowerCase())??[];if($.length===0)return"";return $.map((Z)=>Z.charAt(0).toUpperCase()+Z.slice(1)).join("")};var a1=(Y,$=" ")=>{if(!Y)return"";let Z=$.replace(/[\W]{1}/g,"\\$&"),H=new RegExp(`^[${Z}]+|[${Z}]+$`,"g");return Y.replace(H,"")};var P$=O(r(),1);import{join as zU}from"path";import{existsSync as QU}from"fs";import{mkdir as JU,readdir as A$,rename as q$}from"fs/promises";import{dirname as N$,extname as DU,join as h}from"path";var A=()=>{return N$(Bun.fileURLToPath(import.meta.url))},a=()=>{let Y=process.cwd(),$=Y;while(!0){if(QU(h($,".elysiumrc")))return $;let Z=N$($);if($===Z)break;$=Z}return Y},j1=async(Y,$)=>{let Z=a();{let H=h(Z,"src","modules",Y);if(await JU(H,{recursive:!0}),$)if($==="root"){let U=await A$(h(Z,"src"));for(let X of U){if(["app.ts","env.ts","database","modules"].includes(X))continue;let Q=h(Z,"src",X),J=h(H,X==="main.module.ts"?`${Y}.module.ts`:X);await q$(Q,J)}}else{let U=h(Z,"src","modules",$);await q$(U,H)}}{let H=await Bun.file(h(Z,"package.json")).json();if(H.imports=H.imports??{},H.imports[`#${Y}/*`]=`./src/modules/${Y}/*.ts`,$&&$!=="root")delete H.imports[`#${$}/*`];await Bun.write(h(Z,"package.json"),JSON.stringify(H,null,2))}{let H=await Bun.file(h(Z,".elysiumrc")).json();if(H.mono=!1,H.modules=H.modules??{},H.modules[Y]=`./src/modules/${Y}`,$)delete H.modules[$];await Bun.write(h(Z,".elysiumrc"),JSON.stringify(H,null,2))}if($){let H=async(U)=>{let X=await A$(U,{withFileTypes:!0});for(let Q of X){let J=h(U,Q.name);if(Q.isDirectory())await H(J);else if(DU(Q.name)===".ts"){let D=await Bun.file(J).text();if($==="root")D=D.replace(new RegExp(`(['"])#${$}/((?!(env|app|database(?:/|$))).*?)(['"])`,"g"),`$1#${Y}/$2$4`);else D=D.replace(new RegExp(`(['"])#${$}/`,"g"),`$1#${Y}/`);D=D.replace(new RegExp(`(['"])#${$}/main\\.module(['"])/g`,"g"),`$1#${Y}/${Y}.module$2`),D=D.replace(new RegExp(`(['"])#${$}/main\\.module\\.ts(['"])?/g`,"g"),`$1#${Y}/${Y}.module$2`),await Bun.write(J,D)}}};await H(Z)}};var R=async()=>{let Y=Bun.file(zU(a(),".elysiumrc"));if(!Y.exists())throw new Error("Elysium config file not found.");return Y.json()};var q=async(Y)=>{let $=await R();if($.mono)return"./src";return $.modules[Y]};class g0 extends E{static command="make:command";static description="Creates a new command.";async run(){if(!this.command||!this.name)return this.setup();let Y=await R(),$={module:this.module,name:this.name,command:this.command,description:this.description};if(!$.module&&!Y.mono){let Z=await v0.default({type:"select",name:"module",message:"Module:",choices:Object.keys(Y.modules??{}).map((H)=>({title:H,value:H}))});$.module=Z.module}return this.build($)}async setup(){let Y=await R(),Z=await v0.default([{type(){return Y.mono?null:"select"},name:"module",message:"Module:",choices(){return Object.keys(Y.modules??{}).map((H)=>({title:H,value:H}))}},{type:"text",name:"command",message:"Command Name:",initial:"user:say",validate(H){if(H.length<1)return"Command name cannot be empty";return!0}},{type:"text",name:"description",message:"Command Description:",initial:"Say something",validate(H){if(H.length<1)return"Command description cannot be empty";return!0}}],{onCancel:()=>{this.error("Operation cancelled."),process.exit(0)}});return Z.name=R1(Z.command.replaceAll(":","_")),this.build(Z)}async build(Y){if(!Y.name){this.error("Operation cancelled.");return}if(!Y.name.endsWith("Command"))Y.name+="Command";let $=Bun.file(KU(A(),"stubs/command.stub")),Z=P$.default(await $.text(),Y),H=Y.module?await q(Y.module):"./src",U=V(Y.name.replace("Command","")),X=Bun.file(`${H}/commands/${U}.command.ts`);await X.write(Z),this.success(`Command ${this.bold(X.name)} created successfully.`)}}z([e1.arg({description:"The name of the command to create",type:Y0.STRING}),K("design:type",String)],g0.prototype,"name",void 0),z([e1.arg({description:"The module where the command will be created",type:Y0.STRING}),K("design:type",String)],g0.prototype,"module",void 0),z([e1.arg({description:"The command to create",type:Y0.STRING}),K("design:type",String)],g0.prototype,"command",void 0),z([e1.arg({description:"The description of the command",type:Y0.STRING}),K("design:type",String)],g0.prototype,"description",void 0);var y0=O(_(),1);import{join as WU}from"path";import{Command as e,CommandArgumentType as Y1}from"@elysiumjs/core";var T$=O(r(),1);class d0 extends E{constructor(){super(...arguments);this.http=!1;this.wamp=!1;this.ws=!1;this.server=!1;this.request=!1;this.path="/users"}static command="make:controller";static description="Creates a new controller.";async run(){if(!this.name)return this.setup();let Y=await R(),$={module:this.module,type:"http",scope:"SERVER",name:this.name,path:this.path,realm:this.realm??"realm1"};if(!$.module&&!Y.mono){let Z=await y0.default({type:"select",name:"module",message:"Module:",choices:Object.keys(Y.modules??{}).map((H)=>({title:H,value:H}))});$.module=Z.module}if(this.http)$.type="http";else if(this.wamp)$.type="wamp";else if(this.ws)$.type="ws";if(this.server)$.scope="SERVER";else if(this.request)$.scope="REQUEST";return this.build($)}async setup(){let Y="http",$=await R(),H=await y0.default([{type(){return $.mono?null:"select"},name:"module",message:"Module:",choices(){return Object.keys($.modules??{}).map((U)=>({title:U,value:U}))}},{type:"select",name:"type",message:"Controller Type:",choices:[{title:"HTTP",value:"http"},{title:"WAMP",value:"wamp"},{title:"WebSocket",value:"ws"}]},{type:"text",name:"name",message:"Controller Name:",initial:"UserController",validate:(U)=>{if(U.length<1)return"Controller name cannot be empty";return!0}},{type:"text",name:"path",message(U,X){return Y=X.type,X.type==="wamp"?"Controller URL":"Controller Path:"},initial(U,X){return X.type==="wamp"?"ws://localhost:8000":"/users"},validate(U){if(Y==="wamp")return U.match(/^wss?:\/\//)?!0:"The URL must start with ws:// or wss://";if(U[0]!=="/")return"The path must start with a slash (/)";return!0}},{type(U,X){return X.type==="http"?"select":null},name:"scope",message:"Controller Scope:",choices:[{title:"SERVER",value:"SERVER",description:"An unique instance of the controller is created for the entire lifecycle of the server."},{title:"REQUEST",value:"REQUEST",description:"An instance of the controller is created for each request."}]},{type(U,X){return X.type==="wamp"?"text":null},name:"realm",message:"Controller Realm:",initial:"realm1",validate(U){if(U.length<1)return"Realm name cannot be empty";return!0}}],{onCancel:()=>{this.error("Operation cancelled."),process.exit(0)}});return this.build(H)}async build(Y){if(!Y.type||!Y.name||!Y.path){this.error("Operation cancelled.");return}if(!Y.name.endsWith("Controller"))Y.name+="Controller";let $=Bun.file(WU(A(),`stubs/${Y.type}.controller.stub`)),Z=T$.default(await $.text(),Y),H=Y.module?await q(Y.module):"./src",U=V(Y.name.replace("Controller","")),X=Bun.file(`${H}/controllers/${Y.type}/${U}.controller.ts`);await X.write(Z),this.success(`Controller ${this.bold(X.name)} created successfully.`)}}z([e.arg({description:"The name of the controller to create",type:Y1.STRING}),K("design:type",String)],d0.prototype,"name",void 0),z([e.arg({description:"The module where the controller will be created",type:Y1.STRING}),K("design:type",String)],d0.prototype,"module",void 0),z([e.arg({description:"Whether to create a HTTP controller",type:Y1.BOOLEAN,default:!1}),K("design:type",Boolean)],d0.prototype,"http",void 0),z([e.arg({description:"Whether to create a WAMP controller",type:Y1.BOOLEAN,default:!1}),K("design:type",Boolean)],d0.prototype,"wamp",void 0),z([e.arg({description:"Whether to create a WebSocket controller",type:Y1.BOOLEAN,default:!1}),K("design:type",Boolean)],d0.prototype,"ws",void 0),z([e.arg({description:"Whether to create a SERVER scope controller",type:Y1.BOOLEAN,default:!1}),K("design:type",Boolean)],d0.prototype,"server",void 0),z([e.arg({description:"Whether to create a REQUEST scope controller",type:Y1.BOOLEAN,default:!1}),K("design:type",Boolean)],d0.prototype,"request",void 0),z([e.arg({description:"The path or URL of the controller",type:Y1.STRING}),K("design:type",String)],d0.prototype,"path",void 0),z([e.arg({description:"The realm of the controller (only applicable to WAMP controllers)",type:Y1.STRING}),K("design:type",String)],d0.prototype,"realm",void 0);var u0=O(_(),1);import{join as BU}from"path";import{Command as $0,CommandArgumentType as Z0}from"@elysiumjs/core";var C$=O(r(),1);class c0 extends E{constructor(){super(...arguments);this.queue="default"}static command="make:job";static description="Creates a new job.";async run(){if(!this.name)return this.setup();let Y=await R(),$={module:this.module,name:this.name,alias:this.alias,queue:this.queue??"default"};if(!$.module&&!Y.mono){let Z=await u0.default({type:"select",name:"module",message:"Module:",choices:Object.keys(Y.modules??{}).map((H)=>({title:H,value:H}))});$.module=Z.module}return this.build($)}async setup(){let Y=await R(),Z=await u0.default([{type(){return Y.mono?null:"select"},name:"module",message:"Module:",choices(){return Object.keys(Y.modules??{}).map((H)=>({title:H,value:H}))}},{type:"text",name:"name",message:"Job Name:",initial:"SendEmailJob",validate(H){if(H.length<1)return"Job name cannot be empty";return!0}},{type:"text",name:"alias",message:"Job Alias:",initial(H,U){return U.name},validate(H){if(H.length<1)return"Job alias cannot be empty";return!0}},{type:"text",name:"queue",message:"Job Queue:",initial:"default"}],{onCancel:()=>{this.error("Operation cancelled."),process.exit(0)}});return this.build(Z)}async build(Y){if(!Y.name){this.error("Operation cancelled.");return}if(!Y.name.endsWith("Job"))Y.name+="Job";if(!Y.alias)Y.alias=Y.name;let $=Bun.file(BU(A(),"stubs/job.stub")),Z=C$.default(await $.text(),Y),H=Y.module?await q(Y.module):"./src",U=V(Y.name.replace("Job","")),X=Bun.file(`${H}/jobs/${U}.job.ts`);await X.write(Z),this.success(`Job ${this.bold(X.name)} created successfully.`)}}z([$0.arg({description:"The name of the job to create",type:Z0.STRING}),K("design:type",String)],c0.prototype,"name",void 0),z([$0.arg({description:"The module where the job will be created",type:Z0.STRING}),K("design:type",String)],c0.prototype,"module",void 0),z([$0.arg({description:"The alias of the job to create",type:Z0.STRING}),K("design:type",String)],c0.prototype,"alias",void 0),z([$0.arg({description:"The name of the queue where the job will be dispatched",type:Z0.STRING,default:"default"}),K("design:type",String)],c0.prototype,"queue",void 0);var l0=O(_(),1);import{join as EU}from"path";import{Command as j$,CommandArgumentType as _$}from"@elysiumjs/core";var k$=O(r(),1);class p0 extends E{static command="make:middleware";static description="Creates a new middleware.";async run(){if(!this.name)return this.setup();let Y=await R(),$={module:this.module,name:this.name};if(!$.module&&!Y.mono){let Z=await l0.default({type:"select",name:"module",message:"Module:",choices:Object.keys(Y.modules??{}).map((H)=>({title:H,value:H}))});$.module=Z.module}return this.build($)}async setup(){let Y=await R(),Z=await l0.default([{type(){return Y.mono?null:"select"},name:"module",message:"Module:",choices(){return Object.keys(Y.modules??{}).map((H)=>({title:H,value:H}))}},{type:"text",name:"name",message:"Middleware Name:",initial:"AuthMiddleware",validate(H){if(H.length<1)return"Middleware name cannot be empty";return!0}}],{onCancel:()=>{this.error("Operation cancelled."),process.exit(0)}});return this.build(Z)}async build(Y){if(!Y.name){this.error("Operation cancelled.");return}if(!Y.name.endsWith("Middleware"))Y.name+="Middleware";let $=Bun.file(EU(A(),"stubs/middleware.stub")),Z=k$.default(await $.text(),Y),H=Y.module?await q(Y.module):"./src",U=V(Y.name.replace("Middleware","")),X=Bun.file(`${H}/middlewares/${U}.middleware.ts`);await X.write(Z),this.success(`Middleware ${this.bold(X.name)} created successfully.`)}}z([j$.arg({description:"The name of the middleware to create",type:_$.STRING}),K("design:type",String)],p0.prototype,"name",void 0),z([j$.arg({description:"The module where the middleware will be created",type:_$.STRING}),K("design:type",String)],p0.prototype,"module",void 0);var n0=O(_(),1);import{join as GU}from"path";import{Command as H0,CommandArgumentType as U0}from"@elysiumjs/core";var x$=O(r(),1);class i0 extends E{constructor(){super(...arguments);this.supportTenancy=!1}static command="make:model";static description="Creates a new model.";async run(){if(!this.name||!this.tableName)return this.setup();let Y=await R(),$={module:this.module,table:this.tableName,name:this.name,supportTenancy:this.supportTenancy};if(!$.module&&!Y.mono){let Z=await n0.default({type:"select",name:"module",message:"Module:",choices:Object.keys(Y.modules??{}).map((H)=>({title:H,value:H}))},{onCancel:()=>process.exit(1)});$.module=Z.module}if(!$.name)$.name=a1(R1($.table),"s");return $.canonicalName=$.name,this.build($)}async setup(){let Y=await R(),Z=await n0.default([{type(){return Y.mono?null:"select"},name:"module",message:"Module:",choices(){return Object.keys(Y.modules??{}).map((H)=>({title:H,value:H}))}},{type:"text",name:"table",message:"Table Name:",initial:"users",validate(H){if(H.length<1)return"Table name cannot be empty";return!0}},{type:"text",name:"name",message:"Model Name:",initial(H,U){return a1(R1(U.table),"s")},validate(H){if(H.length<1)return"Model name cannot be empty";return!0}},{type:"select",name:"supportTenancy",message:"Support Tenancy:",choices:[{title:"Yes",value:!0,description:"The model supports multi-tenancy."},{title:"No",value:!1,description:"The model does not support multi-tenancy."}]}],{onCancel:()=>{this.error("Operation cancelled."),process.exit(0)}});return this.build(Z)}async build(Y){if(!Y.name){this.error("Operation cancelled.");return}if(!Y.name.endsWith("Model"))Y.name+="Model";Y.canonicalName=Y.name.replace("Model","");let $=Bun.file(GU(A(),"stubs/model.stub")),Z=x$.default(await $.text(),Y),H=Y.module?await q(Y.module):"./src",U=V(Y.name.replace("Model","")),X=Bun.file(`${H}/models/${U}.model.ts`);await X.write(Z),this.success(`Model ${this.bold(X.name)} created successfully.`)}}z([H0.arg({description:"The name of the model to create",type:U0.STRING}),K("design:type",String)],i0.prototype,"name",void 0),z([H0.arg({description:"The module where the model will be created",type:U0.STRING}),K("design:type",String)],i0.prototype,"module",void 0),z([H0.arg({name:"table",description:"The name of the table wrapped by the model",type:U0.STRING}),K("design:type",String)],i0.prototype,"tableName",void 0),z([H0.arg({name:"support-tenancy",description:"Support tenancy",type:U0.BOOLEAN,default:!1}),K("design:type",Boolean)],i0.prototype,"supportTenancy",void 0);var m0=O(_(),1);import{join as RU}from"path";import{Command as L1,CommandArgumentType as S1}from"@elysiumjs/core";var b$=O(r(),1);class o0 extends E{constructor(){super(...arguments);this.factory=!1;this.singleton=!1}static command="make:repository";static description="Creates a new repository.";async run(){if(!this.name)return this.setup();let Y=await R(),$={module:this.module,name:this.name,alias:this.alias,scope:this.factory?"FACTORY":this.singleton?"SINGLETON":"SINGLETON",model:this.model};if(!$.module&&!Y.mono){let Z=await m0.default({type:"select",name:"module",message:"Module:",choices:Object.keys(Y.modules??{}).map((H)=>({title:H,value:H}))});$.module=Z.module}return this.build($)}async setup(){let Y=await R(),Z=await m0.default([{type(){return Y.mono?null:"select"},name:"module",message:"Module:",choices(){return Object.keys(Y.modules??{}).map((H)=>({title:H,value:H}))}},{type:"text",name:"name",message:"Repository Name:",initial:"UserRepository",validate(H){if(H.length<1)return"Repository name cannot be empty";return!0}},{type:"text",name:"model",message:"Model Name:",initial:"UserModel",validate(H){if(H.length<1)return"Model name cannot be empty";return!0}},{type:"text",name:"alias",message:"Repository Alias:",initial(H,U){return U.name},validate(H){if(H.length<1)return"Repository alias cannot be empty";return!0}},{type:"select",name:"scope",message:"Repository Scope:",choices:[{title:"SINGLETON",value:"SINGLETON",description:"A single instance of the repository is created."},{title:"FACTORY",value:"FACTORY",description:"A new instance of the repository is created each time it is injected."}]}],{onCancel:()=>{this.error("Operation cancelled."),process.exit(0)}});return this.build(Z)}async build(Y){if(!Y.name){this.error("Operation cancelled.");return}if(!Y.name.endsWith("Repository"))Y.name+="Repository";if(!Y.alias)Y.alias=Y.name;let $=Bun.file(RU(A(),"stubs/repository.stub")),Z=b$.default(await $.text(),{...Y,module:Y.module??"root",model_name:V(Y.model.replace("Model",""))}),H=Y.module?await q(Y.module):"./src",U=V(Y.name.replace("Repository","")),X=Bun.file(`${H}/repositories/${U}.repository.ts`);await X.write(Z),this.success(`Repository ${this.bold(X.name)} created successfully.`)}}z([L1.arg({description:"The name of the repository to create",type:S1.STRING}),K("design:type",String)],o0.prototype,"name",void 0),z([L1.arg({description:"The module where the repository will be created",type:S1.STRING}),K("design:type",String)],o0.prototype,"module",void 0),z([L1.arg({description:"The alias of the repository to create",type:S1.STRING}),K("design:type",String)],o0.prototype,"alias",void 0),z([L1.arg({description:"The model used by the repository",type:S1.STRING}),K("design:type",String)],o0.prototype,"model",void 0),z([L1.arg({description:"Create a factory repository",type:S1.BOOLEAN,default:!1}),K("design:type",Boolean)],o0.prototype,"factory",void 0),z([L1.arg({description:"Create a singleton repository",type:S1.BOOLEAN,default:!1}),K("design:type",Boolean)],o0.prototype,"singleton",void 0);var t0=O(_(),1);import{join as LU}from"path";import{Command as _1,CommandArgumentType as k1}from"@elysiumjs/core";var h$=O(r(),1);class s0 extends E{constructor(){super(...arguments);this.factory=!1;this.singleton=!1}static command="make:service";static description="Creates a new service.";async run(){if(!this.name)return this.setup();let Y=await R(),$={module:this.module,name:this.name,alias:this.alias,scope:this.factory?"FACTORY":this.singleton?"SINGLETON":"SINGLETON"};if(!$.module&&!Y.mono){let Z=await t0.default({type:"select",name:"module",message:"Module:",choices:Object.keys(Y.modules??{}).map((H)=>({title:H,value:H}))});$.module=Z.module}return this.build($)}async setup(){let Y=await R(),Z=await t0.default([{type(){return Y.mono?null:"select"},name:"module",message:"Module:",choices(){return Object.keys(Y.modules??{}).map((H)=>({title:H,value:H}))}},{type:"text",name:"name",message:"Service Name:",initial:"UserService",validate(H){if(H.length<1)return"Service name cannot be empty";return!0}},{type:"text",name:"alias",message:"Service Alias:",initial(H,U){return U.name},validate(H){if(H.length<1)return"Service alias cannot be empty";return!0}},{type:"select",name:"scope",message:"Service Scope:",choices:[{title:"SINGLETON",value:"SINGLETON",description:"A single instance of the service is created."},{title:"FACTORY",value:"FACTORY",description:"A new instance of the service is created each time it is injected."}]}],{onCancel:()=>{this.error("Operation cancelled."),process.exit(0)}});return this.build(Z)}async build(Y){if(!Y.name){this.error("Operation cancelled.");return}if(!Y.name.endsWith("Service"))Y.name+="Service";if(!Y.alias)Y.alias=Y.name;let $=Bun.file(LU(A(),"stubs/service.stub")),Z=h$.default(await $.text(),Y),H=Y.module?await q(Y.module):"./src",U=V(Y.name.replace("Service","")),X=Bun.file(`${H}/services/${U}.service.ts`);await X.write(Z),this.success(`Service ${this.bold(X.name)} created successfully.`)}}z([_1.arg({description:"The name of the service to create",type:k1.STRING}),K("design:type",String)],s0.prototype,"name",void 0),z([_1.arg({description:"The module where the service will be created",type:k1.STRING}),K("design:type",String)],s0.prototype,"module",void 0),z([_1.arg({description:"The alias of the service to create",type:k1.STRING}),K("design:type",String)],s0.prototype,"alias",void 0),z([_1.arg({description:"Create a factory service",type:k1.BOOLEAN,default:!1}),K("design:type",Boolean)],s0.prototype,"factory",void 0),z([_1.arg({description:"Create a singleton service",type:k1.BOOLEAN,default:!1}),K("design:type",Boolean)],s0.prototype,"singleton",void 0);var r0=O(_(),1);import{join as SU}from"path";import{Command as f$,CommandArgumentType as w$}from"@elysiumjs/core";var v$=O(r(),1);class a0 extends E{static command="make:validator";static description="Creates a new validator.";async run(){if(!this.name)return this.setup();let Y=await R(),$={module:this.module,name:this.name};if(!$.module&&!Y.mono){let Z=await r0.default({type:"select",name:"module",message:"Module:",choices:Object.keys(Y.modules??{}).map((H)=>({title:H,value:H}))});$.module=Z.module}return this.build($)}async setup(){let Y=await R(),Z=await r0.default([{type(){return Y.mono?null:"select"},name:"module",message:"Module:",choices(){return Object.keys(Y.modules??{}).map((H)=>({title:H,value:H}))}},{type:"text",name:"name",message:"Validator Name:",initial:"LoginValidator",validate(H){if(H.length<1)return"Validator name cannot be empty";return!0}}],{onCancel:()=>{this.error("Operation cancelled."),process.exit(0)}});return this.build(Z)}async build(Y){if(!Y.name){this.error("Operation cancelled.");return}if(!Y.name.endsWith("Validator"))Y.name+="Validator";if(!Y.request_name)Y.request_name=Y.name.replace("Validator","Request");let $=Bun.file(SU(A(),"stubs/validator.stub")),Z=v$.default(await $.text(),Y),H=Y.module?await q(Y.module):"./src",U=V(Y.name.replace("Validator","")),X=Bun.file(`${H}/validators/${U}.validator.ts`);await X.write(Z),this.success(`Validator ${this.bold(X.name)} created successfully.`)}}z([f$.arg({description:"The name of the validator to create",type:w$.STRING}),K("design:type",String)],a0.prototype,"name",void 0),z([f$.arg({description:"The module where the validator will be created",type:w$.STRING}),K("design:type",String)],a0.prototype,"module",void 0);var g$=O(_(),1);import{exists as MU}from"fs/promises";import{Command as FU,CommandArgumentType as VU}from"@elysiumjs/core";class e0 extends E{static command="migration:generate";static description="Generates migration files.";async run(){if(!this.name){let H=await g$.default([{type:"text",name:"name",message:"Migration Name:",initial:"create_users_table",validate(U){if(U.length<1)return"Migration name cannot be empty";return!0}}],{onCancel:()=>{this.error("Operation cancelled."),process.exit(0)}});this.name=H.name}let Y=a(),$=`${Y}/src/database/schemas`;if(await MU(`${Y}/src/database/schema.ts`))$=`${Y}/src/database/schema.ts`;await Bun.$`bunx --bun drizzle-kit generate --dialect postgresql --schema ${$} --out ${Y}/src/database/migrations --prefix timestamp --name ${this.name}`;let Z=new Bun.Glob(`${Y}/src/database/migrations/**/*.sql`).scan();for await(let H of Z){let U=Bun.file(H),X=await U.text();await U.write(X.replace(/"public"\./gm,""))}}}z([FU.arg({description:"The name of the migration to create",type:VU.STRING}),K("design:type",String)],e0.prototype,"name",void 0);var u$=O(_(),1);import{basename as y$}from"path";import{Command as Y2,CommandArgumentType as $2,Database as d$}from"@elysiumjs/core";class Z2 extends E{constructor(){super(...arguments);this.tenant="";this.connection="default";this.fresh=!1}static command="migration:run";static description="Generates migration files.";async run(){if(!d$.connectionExists(this.connection))return this.error(`Connection ${this.bold(this.connection)} does not exist.`),process.exit(1);let Y=d$.getConnection(this.connection).$client;await Y.connect(),await Y.begin(async($)=>{if(this.fresh)await $`DROP SCHEMA IF EXISTS ${$(this.tenant)} CASCADE;`,await $`CREATE SCHEMA ${$(this.tenant)};`;let[{schema_exists:Z}]=await $`SELECT EXISTS (
100
102
  SELECT schema_name
101
103
  FROM information_schema.schemata
102
104
  WHERE schema_name = ${this.tenant}
103
- ) AS schema_exists;`;if(!Z)if((await b$.default([{type:"confirm",name:"create",message:`Schema ${this.tenant} does not exist. Do you want to create it?`,initial:!0}],{onCancel:()=>{this.error("Operation cancelled."),process.exit(0)}})).create)await $`CREATE SCHEMA ${$(this.tenant)};`;else return this.error(`Schema ${this.bold(this.tenant)} creation cancelled.`),process.exit(1);await $`SET search_path TO ${$(this.tenant)};`;let[{table_exists:H}]=await $`SELECT EXISTS (
105
+ ) AS schema_exists;`;if(!Z)if((await u$.default([{type:"confirm",name:"create",message:`Schema ${this.tenant} does not exist. Do you want to create it?`,initial:!0}],{onCancel:()=>{this.error("Operation cancelled."),process.exit(0)}})).create)await $`CREATE SCHEMA ${$(this.tenant)};`;else return this.error(`Schema ${this.bold(this.tenant)} creation cancelled.`),process.exit(1);await $`SET search_path TO ${$(this.tenant)};`;let[{table_exists:H}]=await $`SELECT EXISTS (
104
106
  SELECT *
105
107
  FROM information_schema.tables
106
108
  WHERE table_name = 'elysium_migrations'
@@ -110,4 +112,4 @@ Filtered results for: ${this.inputValue?this.inputValue:n.gray("Enter something
110
112
  name TEXT NOT NULL,
111
113
  batch INTEGER NOT NULL,
112
114
  applied_at TIMESTAMP NOT NULL
113
- );`;let U=(await $`SELECT name FROM elysium_migrations;`).map((G)=>G.name),X=new Bun.Glob("./src/database/migrations/**/*.sql").scan({absolute:!0,onlyFiles:!0}),Q=await Array.fromAsync(X),D=N0(Q.filter((G)=>!U.includes(k$(G))),(G)=>G);if(D.length===0){this.success("No new migrations to apply.");return}let K=this.spinner(`Running migrations for tenant ${this.bold(this.tenant)}...`),[{max:e}]=await $`SELECT MAX(batch) + 1 AS max FROM elysium_migrations;`,Y1=e??0;for(let G of D){await $.file(G);let[{name:N}]=await $`INSERT INTO elysium_migrations (name, batch, applied_at) VALUES (${k$(G)}, ${Y1}, ${new Date}) RETURNING name;`;K.pause(`Migration ${this.bold(N)} applied successfully.`)}K.complete(`Migrations for tenant ${this.bold(this.tenant)} applied successfully.`)}),await Y.close()}}B([r1.arg({description:"The name of the tenant in which the migrations will be executed.",type:m0.STRING,required:!0}),W("design:type",String)],i0.prototype,"tenant",void 0),B([r1.arg({description:"The name of the connection to use.",type:m0.STRING,default:"default"}),W("design:type",String)],i0.prototype,"connection",void 0),B([r1.arg({description:"Drop the entire schema before running the migrations.",type:m0.BOOLEAN,default:!1}),W("design:type",Boolean)],i0.prototype,"fresh",void 0);var o0=O(C(),1);import{exists as JU,rmdir as XU}from"fs/promises";import{join as QU}from"path";import{Command as x$,CommandArgumentType as DU}from"@elysiumjs/core";class s0 extends x${static command="module:new";static description="Creates a new module.";module;convert=!1;async run(){let Y=await L();if(!this.name){let $=await o0.default({type:"text",name:"name",message:"New module name:",initial:"module",validate(Z){return Z.length>0?!0:"Module name cannot be empty"}},{onCancel:()=>process.exit(0)});this.name=M($.name)}if(Y.mono){let{module:$,convert:Z}=await o0.default([{type:"confirm",name:"convert",message:"This project is a mono-module project. Do you want to convert it to a multi-module project?",initial:!1},{type:(H)=>H?"text":null,name:"module",message:"Current module name:",initial:"main",validate(H){return H.length>0?!0:"Module name cannot be empty"}}],{onCancel:()=>process.exit(0)});if(!Z)return this.error("Operation cancelled. The project is left unchanged.");this.module=M($),this.convert=Z}if(this.convert){let $=QU(m(),"src","modules");if(await JU($))await XU($,{recursive:!0});await I1(this.module,"root"),this.success("Project converted to multi-module."),this.success(`Module '${this.module}' created.`)}await I1(this.name),this.success(`Module '${this.name}' created.`)}}B([x$.arg({description:"The name of the module to create",type:DU.STRING}),W("design:type",String)],s0.prototype,"name",void 0);var a0=O(C(),1);import{Command as t0,CommandArgumentType as h$}from"@elysiumjs/core";class r0 extends t0{static command="module:rename";static description="Renames a module.";async run(){if((await L()).mono)return this.error("This operation is not supported for mono-module projects.");if(!this.module){let{module:$}=await a0.default({type:"text",name:"module",message:"Module to rename:",validate:(Z)=>Z.length>0});this.module=$}if(!this.name){let{name:$}=await a0.default({type:"text",name:"name",message:"New module name:",initial:this.module,validate:(Z)=>Z.length>0});this.name=$}if(this.module===this.name)return this.info("Module name is the same as the current name.");await I1(this.name,this.module),this.success(`Module '${this.module}' renamed to '${this.name}'.`)}}B([t0.arg({description:"The module to rename",type:h$.STRING}),W("design:type",String)],r0.prototype,"module",void 0),B([t0.arg({description:"The new name of the module",type:h$.STRING}),W("design:type",String)],r0.prototype,"name",void 0);var zU=m(),{App:f$}=await import(`${zU}/src/app`);class e1 extends f${}e1=B([f$.register({commands:[P0,k0,b0,f0,g0,y0,u0,n0,p0,i0,s0,r0]})],e1);new e1;
115
+ );`;let X=(await $`SELECT name FROM elysium_migrations;`).map((L)=>L.name),Q=new Bun.Glob("./src/database/migrations/**/*.sql").scan({absolute:!0,onlyFiles:!0}),J=await Array.fromAsync(Q),D=w0(J.filter((L)=>!X.includes(y$(L))),(L)=>L);if(D.length===0){this.success("No new migrations to apply.");return}let W=this.spinner(`Running migrations for tenant ${this.bold(this.tenant)}...`),[{max:I}]=await $`SELECT MAX(batch) + 1 AS max FROM elysium_migrations;`,C=I??0;for(let L of D){await $.file(L);let[{name:N}]=await $`INSERT INTO elysium_migrations (name, batch, applied_at) VALUES (${y$(L)}, ${C}, ${new Date}) RETURNING name;`;W.pause(`Migration ${this.bold(N)} applied successfully.`)}W.complete(`Migrations for tenant ${this.bold(this.tenant)} applied successfully.`)}),await Y.close()}}z([Y2.arg({description:"The name of the tenant in which the migrations will be executed.",type:$2.STRING,required:!0}),K("design:type",String)],Z2.prototype,"tenant",void 0),z([Y2.arg({description:"The name of the connection to use.",type:$2.STRING,default:"default"}),K("design:type",String)],Z2.prototype,"connection",void 0),z([Y2.arg({description:"Drop the entire schema before running the migrations.",type:$2.BOOLEAN,default:!1}),K("design:type",Boolean)],Z2.prototype,"fresh",void 0);var H2=O(_(),1);import{exists as OU,rmdir as IU}from"fs/promises";import{join as AU}from"path";import{Command as qU,CommandArgumentType as NU}from"@elysiumjs/core";class U2 extends E{static command="module:new";static description="Creates a new module.";module;convert=!1;async run(){let Y=await R();if(!this.name){let $=await H2.default({type:"text",name:"name",message:"New module name:",initial:"module",validate(Z){return Z.length>0?!0:"Module name cannot be empty"}},{onCancel:()=>process.exit(0)});this.name=V($.name)}if(Y.mono){let{module:$,convert:Z}=await H2.default([{type:"confirm",name:"convert",message:"This project is a mono-module project. Do you want to convert it to a multi-module project?",initial:!1},{type:(H)=>H?"text":null,name:"module",message:"Current module name:",initial:"main",validate(H){return H.length>0?!0:"Module name cannot be empty"}}],{onCancel:()=>process.exit(0)});if(!Z)return this.error("Operation cancelled. The project is left unchanged.");this.module=V($),this.convert=Z}if(this.convert){let $=AU(a(),"src","modules");if(await OU($))await IU($,{recursive:!0});await j1(this.module,"root"),this.success("Project converted to multi-module."),this.success(`Module '${this.module}' created.`)}await j1(this.name),this.success(`Module '${this.name}' created.`)}}z([qU.arg({description:"The name of the module to create",type:NU.STRING}),K("design:type",String)],U2.prototype,"name",void 0);var X2=O(_(),1);import{Command as c$,CommandArgumentType as l$}from"@elysiumjs/core";class Q2 extends E{static command="module:rename";static description="Renames a module.";async run(){if((await R()).mono)return this.error("This operation is not supported for mono-module projects.");if(!this.module){let{module:$}=await X2.default({type:"text",name:"module",message:"Module to rename:",validate:(Z)=>Z.length>0});this.module=$}if(!this.name){let{name:$}=await X2.default({type:"text",name:"name",message:"New module name:",initial:this.module,validate:(Z)=>Z.length>0});this.name=$}if(this.module===this.name)return this.info("Module name is the same as the current name.");await j1(this.name,this.module),this.success(`Module '${this.module}' renamed to '${this.name}'.`)}}z([c$.arg({description:"The module to rename",type:l$.STRING}),K("design:type",String)],Q2.prototype,"module",void 0),z([c$.arg({description:"The new name of the module",type:l$.STRING}),K("design:type",String)],Q2.prototype,"name",void 0);var PU=a(),{App:p$}=await import(`${PU}/src/app`);class X0 extends p${}X0=z([p$.register({commands:[J0,D0,z0,g0,d0,c0,p0,i0,o0,s0,a0,e0,Z2,U2,Q2].filter((Y)=>ELYSIUM_BUILD?!Y.dev:!0)})],X0);new X0;