@capgo/cli
Version:
A CLI to upload to capgo servers
79 lines (77 loc) • 4.5 MB
JavaScript
#!/usr/bin/env node
import{createRequire as THQ}from"node:module";var VHQ=Object.create;var{getPrototypeOf:EHQ,defineProperty:YP,getOwnPropertyNames:NOA,getOwnPropertyDescriptor:RHQ}=Object,LOA=Object.prototype.hasOwnProperty;function VOA(A){return this[A]}var jHQ,wHQ,lA=(A,Q,B)=>{var $=A!=null&&typeof A==="object";if($){var J=Q?jHQ??=new WeakMap:wHQ??=new WeakMap,Y=J.get(A);if(Y)return Y}B=A!=null?VHQ(EHQ(A)):{};let X=Q||!A||!A.__esModule?YP(B,"default",{value:A,enumerable:!0}):B;for(let G of NOA(A))if(!LOA.call(X,G))YP(X,G,{get:VOA.bind(A,G),enumerable:!0});if($)J.set(A,X);return X},TK=(A)=>{var Q=(MOA??=new WeakMap).get(A),B;if(Q)return Q;if(Q=YP({},"__esModule",{value:!0}),A&&typeof A==="object"||typeof A==="function"){for(var $ of NOA(A))if(!LOA.call(Q,$))YP(Q,$,{get:VOA.bind(A,$),enumerable:!(B=RHQ(A,$))||B.enumerable})}return MOA.set(A,Q),Q},MOA,t=(A,Q)=>()=>(Q||A((Q={exports:{}}).exports,Q),Q.exports);var _HQ=(A)=>A;function PHQ(A,Q){this[A]=_HQ.bind(null,Q)}var HJ=(A,Q)=>{for(var B in Q)YP(A,B,{get:Q[B],enumerable:!0,configurable:!0,set:PHQ.bind(Q,B)})};var fA=(A,Q)=>()=>(A&&(Q=A(A=0)),Q);var XQ=THQ(import.meta.url);var EOA,ROA=(A)=>{return A===12288||A>=65281&&A<=65376||A>=65504&&A<=65510},jOA=(A)=>{return A===8987||A===9001||A>=12272&&A<=12287||A>=12289&&A<=12350||A>=12441&&A<=12543||A>=12549&&A<=12591||A>=12593&&A<=12686||A>=12688&&A<=12771||A>=12783&&A<=12830||A>=12832&&A<=12871||A>=12880&&A<=19903||A>=65040&&A<=65049||A>=65072&&A<=65106||A>=65108&&A<=65126||A>=65128&&A<=65131||A>=127488&&A<=127490||A>=127504&&A<=127547||A>=127552&&A<=127560||A>=131072&&A<=196605||A>=196608&&A<=262141};var wOA=fA(()=>{EOA=(()=>{let A=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g;return(Q)=>{let B=0;A.lastIndex=0;while(A.test(Q))B+=1;return Q.length-B}})()});var kHQ,SHQ,_OA,xHQ,POA,bHQ,fHQ,vHQ,TOA=(A,Q={},B={})=>{let $=Q.limit??1/0,J=Q.ellipsis??"",Y=Q?.ellipsisWidth??(J?TOA(J,vHQ,B).width:0),X=0,G=B.controlWidth??0,W=B.tabWidth??8,K=B.emojiWidth??2,H=2,D=B.regularWidth??1,F=B.wideWidth??2,U=[[bHQ,D],[kHQ,0],[SHQ,G],[xHQ,W],[POA,K],[_OA,F]],z=0,I=0,O=A.length,V=0,E=!1,M=O,N=Math.max(0,$-Y),R=0,T=0,x=0,c=0;A:while(!0){if(T>R||I>=O&&I>z){let l=A.slice(R,T)||A.slice(z,I);V=0;for(let f of l.replaceAll(fHQ,"")){let h=f.codePointAt(0)||0;if(ROA(h))c=2;else if(jOA(h))c=F;else c=D;if(x+c>N)M=Math.min(M,Math.max(R,z)+V);if(x+c>$){E=!0;break A}V+=f.length,x+=c}R=T=0}if(I>=O)break A;for(let l=0,f=U.length;l<f;l++){let[h,i]=U[l];if(h.lastIndex=I,h.test(A)){if(V=h===_OA?EOA(A.slice(I,h.lastIndex)):h===POA?1:h.lastIndex-I,c=V*i,x+c>N)M=Math.min(M,I+Math.floor((N-x)/i));if(x+c>$){E=!0;break A}x+=c,R=z,T=I,I=z=h.lastIndex;continue A}}I+=1}return{width:E?N:x,index:E?M:O,truncated:E,ellipsed:E&&$>=Y}},kOA;var SOA=fA(()=>{wOA();kHQ=/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]|\u001b\]8;[^;]*;.*?(?:\u0007|\u001b\u005c)/y,SHQ=/[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y,_OA=/(?:(?![\uFF61-\uFF9F\uFF00-\uFFEF])[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}\p{Script=Tangut}]){1,1000}/yu,xHQ=/\t{1,1000}/y,POA=/[\u{1F1E6}-\u{1F1FF}]{2}|\u{1F3F4}[\u{E0061}-\u{E007A}]{2}[\u{E0030}-\u{E0039}\u{E0061}-\u{E007A}]{1,3}\u{E007F}|(?:\p{Emoji}\uFE0F\u20E3?|\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation})(?:\u200D(?:\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation}|\p{Emoji}\uFE0F\u20E3?))*/yu,bHQ=/(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y,fHQ=/\p{M}+/gu,vHQ={limit:1/0,ellipsis:""},kOA=TOA});var gHQ,yHQ=(A,Q={})=>{return kOA(A,gHQ,Q).width},GH;var z1A=fA(()=>{SOA();gHQ={limit:1/0,ellipsis:"",ellipsisWidth:0},GH=yHQ});function D2(A,Q,B){return String(A).normalize().split(dHQ).map(($)=>cHQ($,Q,B)).join(`
`)}var Dm="\x1B",gOA="",hHQ=39,C1A="\x07",yOA="[",uHQ="]",hOA="m",O1A,xOA,bOA=(A)=>{if(A>=30&&A<=37)return 39;if(A>=90&&A<=97)return 39;if(A>=40&&A<=47)return 49;if(A>=100&&A<=107)return 49;if(A===1||A===2)return 22;if(A===3)return 23;if(A===4)return 24;if(A===7)return 27;if(A===8)return 28;if(A===9)return 29;if(A===0)return 0;return},fOA=(A)=>`${Dm}${yOA}${A}${hOA}`,vOA=(A)=>`${Dm}${O1A}${A}${C1A}`,I1A=(A,Q,B)=>{let $=Q[Symbol.iterator](),J=!1,Y=!1,X=A.at(-1),G=X===void 0?0:GH(X),W=$.next(),K=$.next(),H=0;while(!W.done){let D=W.value,F=GH(D);if(G+F<=B)A[A.length-1]+=D;else A.push(D),G=0;if(D===Dm||D===gOA)J=!0,Y=Q.startsWith(O1A,H+1);if(J){if(Y){if(D===C1A)J=!1,Y=!1}else if(D===hOA)J=!1}else if(G+=F,G===B&&!K.done)A.push(""),G=0;W=K,K=$.next(),H+=D.length}if(X=A.at(-1),!G&&X!==void 0&&X.length&&A.length>1)A[A.length-2]+=A.pop()},mHQ=(A)=>{let Q=A.split(" "),B=Q.length;while(B){if(GH(Q[B-1]))break;B--}if(B===Q.length)return A;return Q.slice(0,B).join(" ")+Q.slice(B).join("")},cHQ=(A,Q,B={})=>{if(B.trim!==!1&&A.trim()==="")return"";let $="",J,Y,X=A.split(" "),G=[""],W=0;for(let D=0;D<X.length;D++){let F=X[D];if(B.trim!==!1){let z=G.at(-1)??"",I=z.trimStart();if(z.length!==I.length)G[G.length-1]=I,W=GH(I)}if(D!==0){if(W>=Q&&(B.wordWrap===!1||B.trim===!1))G.push(""),W=0;if(W||B.trim===!1)G[G.length-1]+=" ",W++}let U=GH(F);if(B.hard&&U>Q){let z=Q-W,I=1+Math.floor((U-z-1)/Q);if(Math.floor((U-1)/Q)<I)G.push("");I1A(G,F,Q),W=GH(G.at(-1)??"");continue}if(W+U>Q&&W&&U){if(B.wordWrap===!1&&W<Q){I1A(G,F,Q),W=GH(G.at(-1)??"");continue}G.push(""),W=0}if(W+U>Q&&B.wordWrap===!1){I1A(G,F,Q),W=GH(G.at(-1)??"");continue}G[G.length-1]+=F,W+=U}if(B.trim!==!1)G=G.map((D)=>mHQ(D));let K=G.join(`
`),H=!1;for(let D=0;D<K.length;D++){let F=K[D];if($+=F,!H){if(H=F>="\uD800"&&F<="\uDBFF",H)continue}else H=!1;if(F===Dm||F===gOA){xOA.lastIndex=D+1;let z=xOA.exec(K)?.groups;if(z?.code!==void 0){let I=Number.parseFloat(z.code);J=I===hHQ?void 0:I}else if(z?.uri!==void 0)Y=z.uri.length===0?void 0:z.uri}if(K[D+1]===`
`){if(Y)$+=vOA("");let U=J?bOA(J):void 0;if(J&&U)$+=fOA(U)}else if(F===`
`){if(J&&bOA(J))$+=fOA(J);if(Y)$+=vOA(Y)}}return $},dHQ;var M1A=fA(()=>{z1A();O1A=`${uHQ}8;;`,xOA=new RegExp(`(?:\\${yOA}(?<code>\\d+)m|\\${O1A}(?<uri>.*)${C1A})`,"y"),dHQ=/\r?\n/});var L1A=t((YE0,uOA)=>{var N1A={to(A,Q){if(!Q)return`\x1B[${A+1}G`;return`\x1B[${Q+1};${A+1}H`},move(A,Q){let B="";if(A<0)B+=`\x1B[${-A}D`;else if(A>0)B+=`\x1B[${A}C`;if(Q<0)B+=`\x1B[${-Q}A`;else if(Q>0)B+=`\x1B[${Q}B`;return B},up:(A=1)=>`\x1B[${A}A`,down:(A=1)=>`\x1B[${A}B`,forward:(A=1)=>`\x1B[${A}C`,backward:(A=1)=>`\x1B[${A}D`,nextLine:(A=1)=>"\x1B[E".repeat(A),prevLine:(A=1)=>"\x1B[F".repeat(A),left:"\x1B[G",hide:"\x1B[?25l",show:"\x1B[?25h",save:"\x1B7",restore:"\x1B8"},lHQ={up:(A=1)=>"\x1B[S".repeat(A),down:(A=1)=>"\x1B[T".repeat(A)},pHQ={screen:"\x1B[2J",up:(A=1)=>"\x1B[1J".repeat(A),down:(A=1)=>"\x1B[J".repeat(A),line:"\x1B[2K",lineEnd:"\x1B[K",lineStart:"\x1B[1K",lines(A){let Q="";for(let B=0;B<A;B++)Q+=this.line+(B<A-1?N1A.up():"");if(A)Q+=N1A.left;return Q}};uOA.exports={cursor:N1A,scroll:lHQ,erase:pHQ,beep:"\x07"}});import{styleText as HL}from"node:util";import{stdout as j1A,stdin as lOA}from"node:process";import*as F2 from"node:readline";import iHQ from"node:readline";import{ReadStream as mOA}from"node:tty";function ZL(A,Q,B){if(!B.some((X)=>!X.disabled))return A;let $=A+Q,J=Math.max(B.length-1,0),Y=$<0?J:$>J?0:$;return B[Y].disabled?ZL(Y,Q<0?-1:1,B):Y}function Fm(A,Q,B,$){let J=$.split(`
`),Y=0,X=A;for(let W of J){if(X<=W.length)break;X-=W.length+1,Y++}for(Y=Math.max(0,Math.min(J.length-1,Y+B)),X=Math.min(X,J[Y].length)+Q;X<0&&Y>0;)Y--,X+=J[Y].length+1;for(;X>J[Y].length&&Y<J.length-1;)X-=J[Y].length+1,Y++;X=Math.max(0,Math.min(J[Y].length,X));let G=0;for(let W=0;W<Y;W++)G+=J[W].length+1;return G+X}function w1A(A,Q){if(typeof A=="string")return qJ.aliases.get(A)===Q;for(let B of A)if(B!==void 0&&w1A(B,Q))return!0;return!1}function oHQ(A,Q){if(A===Q)return;let B=A.split(`
`),$=Q.split(`
`),J=Math.max(B.length,$.length),Y=[];for(let X=0;X<J;X++)B[X]!==$[X]&&Y.push(X);return{lines:Y,numLinesBefore:B.length,numLinesAfter:$.length,numLines:J}}function D1(A){return A===E1A}function Um(A,Q){let B=A;B.isTTY&&B.setRawMode(Q)}function pOA({input:A=lOA,output:Q=j1A,overwrite:B=!0,hideCursor:$=!0}={}){let J=F2.createInterface({input:A,output:Q,prompt:"",tabSize:1});F2.emitKeypressEvents(A,J),A instanceof mOA&&A.isTTY&&A.setRawMode(!0);let Y=(X,{name:G,sequence:W})=>{let K=String(X);if(w1A([K,G,W],"cancel")){$&&Q.write(ZY.cursor.show),process.exit(0);return}if(!B)return;F2.moveCursor(Q,G==="return"?0:-1,G==="return"?-1:0,()=>{F2.clearLine(Q,1,()=>{A.once("keypress",Y)})})};return $&&Q.write(ZY.cursor.hide),A.once("keypress",Y),()=>{A.off("keypress",Y),$&&Q.write(ZY.cursor.show),A instanceof mOA&&A.isTTY&&!rHQ&&A.setRawMode(!1),J.terminal=!1,J.close()}}function XP(A,Q,B,$=B,J=B,Y){let X=Im(A??j1A);return D2(Q,X-B.length,{hard:!0,trim:!1}).split(`
`).map((G,W,K)=>{let H=Y?Y(G,W):G;return W===0?`${$}${H}`:W===K.length-1?`${J}${H}`:`${B}${H}`}).join(`
`)}function iOA(A,Q){if("~standard"in A){let B=A["~standard"].validate(Q);if(B instanceof Promise)throw TypeError("Schema validation must be synchronous. Update `validate()` and remove any asynchronous logic.");return B.issues?.at(0)?.message}return A(Q)}class Pq{input;output;_abortSignal;rl;opts;_render;_track=!1;_prevFrame="";_subscribers=new Map;_cursor=0;state="initial";error="";value;userInput="";constructor(A,Q=!0){let{input:B=lOA,output:$=j1A,render:J,signal:Y,...X}=A;this.opts=X,this.onKeypress=this.onKeypress.bind(this),this.close=this.close.bind(this),this.render=this.render.bind(this),this._render=J.bind(this),this._track=Q,this._abortSignal=Y,this.input=B,this.output=$}unsubscribe(){this._subscribers.clear()}setSubscriber(A,Q){let B=this._subscribers.get(A)??[];B.push(Q),this._subscribers.set(A,B)}on(A,Q){this.setSubscriber(A,{cb:Q})}once(A,Q){this.setSubscriber(A,{cb:Q,once:!0})}emit(A,...Q){let B=this._subscribers.get(A)??[],$=[];for(let J of B)J.cb(...Q),J.once&&$.push(()=>B.splice(B.indexOf(J),1));for(let J of $)J()}prompt(){return new Promise((A)=>{if(this._abortSignal){if(this._abortSignal.aborted)return this.state="cancel",this.close(),A(E1A);this._abortSignal.addEventListener("abort",()=>{this.state="cancel",this.close()},{once:!0})}this.rl=iHQ.createInterface({input:this.input,tabSize:2,prompt:"",escapeCodeTimeout:50,terminal:!0}),this.rl.prompt(),this.opts.initialUserInput!==void 0&&this._setUserInput(this.opts.initialUserInput,!0),this.input.on("keypress",this.onKeypress),Um(this.input,!0),this.output.on("resize",this.render),this.render(),this.once("submit",()=>{this.output.write(ZY.cursor.show),this.output.off("resize",this.render),Um(this.input,!1),A(this.value)}),this.once("cancel",()=>{this.output.write(ZY.cursor.show),this.output.off("resize",this.render),Um(this.input,!1),A(E1A)})})}_isActionKey(A,Q){return A==="\t"}_shouldSubmit(A,Q){return!0}_setValue(A){this.value=A,this.emit("value",this.value)}_setUserInput(A,Q){this.userInput=A??"",this.emit("userInput",this.userInput),Q&&this._track&&this.rl&&(this.rl.write(this.userInput),this._cursor=this.rl.cursor)}_clearUserInput(){this.rl?.write(null,{ctrl:!0,name:"u"}),this._setUserInput("")}onKeypress(A,Q){if(this._track&&Q.name!=="return"&&(Q.name&&this._isActionKey(A,Q)&&this.rl?.write(null,{ctrl:!0,name:"h"}),this._cursor=this.rl?.cursor??0,this._setUserInput(this.rl?.line)),this.state==="error"&&(this.state="active"),Q?.name&&(!this._track&&qJ.aliases.has(Q.name)&&this.emit("cursor",qJ.aliases.get(Q.name)),qJ.actions.has(Q.name)&&this.emit("cursor",Q.name)),A&&(A.toLowerCase()==="y"||A.toLowerCase()==="n")&&this.emit("confirm",A.toLowerCase()==="y"),this.emit("key",A,Q),Q?.name==="return"&&this._shouldSubmit(A,Q)){if(this.opts.validate){let B=iOA(this.opts.validate,this.value);B&&(this.error=B instanceof Error?B.message:B,this.state="error",this.rl?.write(this.userInput))}this.state!=="error"&&(this.state="submit")}w1A([A,Q?.name,Q?.sequence],"cancel")&&(this.state="cancel"),(this.state==="submit"||this.state==="cancel")&&this.emit("finalize"),this.render(),(this.state==="submit"||this.state==="cancel")&&this.close()}close(){this.input.unpipe(),this.input.removeListener("keypress",this.onKeypress),this.output.write(`
`),Um(this.input,!1),this.rl?.close(),this.rl=void 0,this.emit(`${this.state}`,this.value),this.unsubscribe()}restoreCursor(){let A=D2(this._prevFrame,process.stdout.columns,{hard:!0,trim:!1}).split(`
`).length-1;this.output.write(ZY.cursor.move(-999,A*-1))}render(){let A=D2(this._render(this)??"",process.stdout.columns,{hard:!0,trim:!1});if(A!==this._prevFrame){if(this.state==="initial")this.output.write(ZY.cursor.hide);else{let Q=oHQ(this._prevFrame,A),B=_1A(this.output);if(this.restoreCursor(),Q){let $=Math.max(0,Q.numLinesAfter-B),J=Math.max(0,Q.numLinesBefore-B),Y=Q.lines.find((X)=>X>=$);if(Y===void 0){this._prevFrame=A;return}if(Q.lines.length===1){this.output.write(ZY.cursor.move(0,Y-J)),this.output.write(ZY.erase.lines(1));let X=A.split(`
`);this.output.write(X[Y]),this._prevFrame=A,this.output.write(ZY.cursor.move(0,X.length-Y-1));return}else if(Q.lines.length>1){if($<J)Y=$;else{let G=Y-J;G>0&&this.output.write(ZY.cursor.move(0,G))}this.output.write(ZY.erase.down());let X=A.split(`
`).slice(Y);this.output.write(X.join(`
`)),this._prevFrame=A;return}}this.output.write(ZY.erase.down())}this.output.write(A),this.state==="initial"&&(this.state="active"),this._prevFrame=A}}}function sHQ(A,Q){if(A===void 0||Q.length===0)return 0;let B=Q.findIndex(($)=>$.value===A);return B!==-1?B:0}function tHQ(A,Q){return(Q.label??String(Q.value)).toLowerCase().includes(A.toLowerCase())}function eHQ(A,Q){if(Q)return A?Q:Q[0]}function cOA(A){return[...A].map((Q)=>Q3Q[Q])}function B3Q(A){let Q=new Intl.DateTimeFormat(A,{year:"numeric",month:"2-digit",day:"2-digit"}).formatToParts(new Date(2000,0,15)),B=[],$="/";for(let J of Q)J.type==="literal"?$=J.value.trim()||J.value:(J.type==="year"||J.type==="month"||J.type==="day")&&B.push({type:J.type,len:J.type==="year"?4:2});return{segments:B,separator:$}}function V1A(A){return Number.parseInt((A||"0").replace(/_/g,"0"),10)||0}function zm(A){return{year:V1A(A.year),month:V1A(A.month),day:V1A(A.day)}}function R1A(A,Q){return new Date(A||2001,Q||1,0).getDate()}function nOA(A){let{year:Q,month:B,day:$}=zm(A);if(!Q||Q<0||Q>9999||!B||B<1||B>12||!$||$<1)return;let J=new Date(Date.UTC(Q,B-1,$));if(!(J.getUTCFullYear()!==Q||J.getUTCMonth()!==B-1||J.getUTCDate()!==$))return{year:Q,month:B,day:$}}function dOA(A){let Q=nOA(A);return Q?new Date(Date.UTC(Q.year,Q.month-1,Q.day)):void 0}function $3Q(A,Q,B,$){let J=B?{year:B.getUTCFullYear(),month:B.getUTCMonth()+1,day:B.getUTCDate()}:null,Y=$?{year:$.getUTCFullYear(),month:$.getUTCMonth()+1,day:$.getUTCDate()}:null;return A==="year"?{min:J?.year??1,max:Y?.year??9999}:A==="month"?{min:J&&Q.year===J.year?J.month:1,max:Y&&Q.year===Y.year?Y.month:12}:{min:J&&Q.year===J.year&&Q.month===J.month?J.day:1,max:Y&&Q.year===Y.year&&Q.month===Y.month?Y.day:R1A(Q.year,Q.month)}}var ZY,nHQ,aHQ,qJ,rHQ,E1A,Im=(A)=>("columns"in A)&&typeof A.columns=="number"?A.columns:80,_1A=(A)=>("rows"in A)&&typeof A.rows=="number"?A.rows:20,A3Q,P1A,Q3Q,aOA,J3Q,Y3Q,oOA,T1A,k1A,S1A;var x1A=fA(()=>{M1A();ZY=lA(L1A(),1);nHQ=["up","down","left","right","space","enter","cancel"],aHQ=["January","February","March","April","May","June","July","August","September","October","November","December"],qJ={actions:new Set(nHQ),aliases:new Map([["k","up"],["j","down"],["h","left"],["l","right"],["\x03","cancel"],["escape","cancel"]]),messages:{cancel:"Canceled",error:"Something went wrong"},withGuide:!0,date:{monthNames:[...aHQ],messages:{required:"Please enter a valid date",invalidMonth:"There are only 12 months in a year",invalidDay:(A,Q)=>`There are only ${A} days in ${Q}`,afterMin:(A)=>`Date must be on or after ${A.toISOString().slice(0,10)}`,beforeMax:(A)=>`Date must be on or before ${A.toISOString().slice(0,10)}`}}};rHQ=globalThis.process.platform.startsWith("win"),E1A=Symbol("clack:cancel");A3Q=class extends Pq{filteredOptions;multiple;isNavigating=!1;selectedValues=[];focusedValue;#A=0;#Q="";#B;#$;#J;get cursor(){return this.#A}get userInputWithCursor(){if(!this.userInput)return HL(["inverse","hidden"],"_");if(this._cursor>=this.userInput.length)return`${this.userInput}█`;let Q=this.userInput.slice(0,this._cursor),[B,...$]=this.userInput.slice(this._cursor);return`${Q}${HL("inverse",B)}${$.join("")}`}get options(){return typeof this.#$=="function"?this.#$():this.#$}constructor(Q){super(Q),this.#$=Q.options,this.#J=Q.placeholder;let B=this.options;this.filteredOptions=[...B],this.multiple=Q.multiple===!0,this.#B=typeof Q.options=="function"?Q.filter:Q.filter??tHQ;let $;if(Q.initialValue&&Array.isArray(Q.initialValue)?this.multiple?$=Q.initialValue:$=Q.initialValue.slice(0,1):!this.multiple&&this.options.length>0&&($=[this.options[0].value]),$)for(let J of $){let Y=B.findIndex((X)=>X.value===J);Y!==-1&&(this.toggleSelected(J),this.#A=Y)}this.focusedValue=this.options[this.#A]?.value,this.on("key",(J,Y)=>this.#Y(J,Y)),this.on("userInput",(J)=>this.#X(J))}_isActionKey(Q,B){return Q==="\t"||this.multiple&&this.isNavigating&&B.name==="space"&&Q!==void 0&&Q!==""}#Y(Q,B){let $=B.name==="up",J=B.name==="down",Y=B.name==="return",X=this.userInput===""||this.userInput==="\t",G=this.#J,W=this.options,K=G!==void 0&&G!==""&&W.some((H)=>!H.disabled&&(this.#B?this.#B(G,H):!0));if(B.name==="tab"&&X&&K){this.userInput==="\t"&&this._clearUserInput(),this._setUserInput(G,!0),this.isNavigating=!1;return}$||J?(this.#A=ZL(this.#A,$?-1:1,this.filteredOptions),this.focusedValue=this.filteredOptions[this.#A]?.value,this.multiple||(this.selectedValues=[this.focusedValue]),this.isNavigating=!0):Y?this.value=eHQ(this.multiple,this.selectedValues):this.multiple?this.focusedValue!==void 0&&(B.name==="tab"||this.isNavigating&&B.name==="space")?this.toggleSelected(this.focusedValue):this.isNavigating=!1:(this.focusedValue&&(this.selectedValues=[this.focusedValue]),this.isNavigating=!1)}deselectAll(){this.selectedValues=[]}toggleSelected(Q){this.filteredOptions.length!==0&&(this.multiple?this.selectedValues.includes(Q)?this.selectedValues=this.selectedValues.filter((B)=>B!==Q):this.selectedValues=[...this.selectedValues,Q]:this.selectedValues=[Q])}#X(Q){if(Q!==this.#Q){this.#Q=Q;let B=this.options;Q&&this.#B?this.filteredOptions=B.filter((Y)=>this.#B?.(Q,Y)):this.filteredOptions=[...B];let $=sHQ(this.focusedValue,this.filteredOptions);this.#A=ZL($,0,this.filteredOptions);let J=this.filteredOptions[this.#A];J&&!J.disabled?this.focusedValue=J.value:this.focusedValue=void 0,this.multiple||(this.focusedValue!==void 0?this.toggleSelected(this.focusedValue):this.deselectAll())}}};P1A=class P1A extends Pq{get cursor(){return this.value?0:1}get _value(){return this.cursor===0}constructor(A){super(A,!1),this.value=!!A.initialValue,this.on("userInput",()=>{this.value=this._value}),this.on("confirm",(Q)=>{this.output.write(ZY.cursor.move(0,-1)),this.value=Q,this.state="submit",this.close()}),this.on("cursor",()=>{this.value=!this.value})}};Q3Q={Y:{type:"year",len:4},M:{type:"month",len:2},D:{type:"day",len:2}};aOA=class aOA extends Pq{#A;#Q;#B;#$;#J;#Y={segmentIndex:0,positionInSegment:0};#X=!0;#G=null;inlineError="";get segmentCursor(){return{...this.#Y}}get segmentValues(){return{...this.#B}}get segments(){return this.#A}get separator(){return this.#Q}get formattedValue(){return this.#K(this.#B)}#K(A){return this.#A.map((Q)=>A[Q.type]).join(this.#Q)}#Z(){this._setUserInput(this.#K(this.#B)),this._setValue(dOA(this.#B)??void 0)}constructor(A){let Q=A.format?{segments:cOA(A.format),separator:A.separator??"/"}:B3Q(A.locale),B=A.separator??Q.separator,$=A.format?cOA(A.format):Q.segments,J=A.initialValue??A.defaultValue,Y=J?{year:String(J.getUTCFullYear()).padStart(4,"0"),month:String(J.getUTCMonth()+1).padStart(2,"0"),day:String(J.getUTCDate()).padStart(2,"0")}:{year:"____",month:"__",day:"__"},X=$.map((G)=>Y[G.type]).join(B);super({...A,initialUserInput:X},!1),this.#A=$,this.#Q=B,this.#B=Y,this.#$=A.minDate,this.#J=A.maxDate,this.#Z(),this.on("cursor",(G)=>this.#F(G)),this.on("key",(G,W)=>this.#U(G,W)),this.on("finalize",()=>this.#z(A))}#H(){let A=Math.max(0,Math.min(this.#Y.segmentIndex,this.#A.length-1)),Q=this.#A[A];if(Q)return this.#Y.positionInSegment=Math.max(0,Math.min(this.#Y.positionInSegment,Q.len-1)),{segment:Q,index:A}}#q(A){this.inlineError="",this.#G=null;let Q=this.#H();Q&&(this.#Y.segmentIndex=Math.max(0,Math.min(this.#A.length-1,Q.index+A)),this.#Y.positionInSegment=0,this.#X=!0)}#W(A){let Q=this.#H();if(!Q)return;let{segment:B}=Q,$=this.#B[B.type],J=!$||$.replace(/_/g,"")==="",Y=Number.parseInt(($||"0").replace(/_/g,"0"),10)||0,X=$3Q(B.type,zm(this.#B),this.#$,this.#J),G;J?G=A===1?X.min:X.max:G=Math.max(Math.min(X.max,Y+A),X.min),this.#B={...this.#B,[B.type]:G.toString().padStart(B.len,"0")},this.#X=!0,this.#G=null,this.#Z()}#F(A){if(A)switch(A){case"right":return this.#q(1);case"left":return this.#q(-1);case"up":return this.#W(1);case"down":return this.#W(-1)}}#U(A,Q){if(Q?.name==="backspace"||Q?.sequence===""||Q?.sequence==="\b"||A===""||A==="\b"){this.inlineError="";let B=this.#H();if(!B)return;if(!this.#B[B.segment.type].replace(/_/g,"")){this.#q(-1);return}this.#B[B.segment.type]="_".repeat(B.segment.len),this.#X=!0,this.#Y.positionInSegment=0,this.#Z();return}if(Q?.name==="tab"){this.inlineError="";let B=this.#H();if(!B)return;let $=Q.shift?-1:1,J=B.index+$;J>=0&&J<this.#A.length&&(this.#Y.segmentIndex=J,this.#Y.positionInSegment=0,this.#X=!0);return}if(A&&/^[0-9]$/.test(A)){let B=this.#H();if(!B)return;let{segment:$}=B,J=!this.#B[$.type].replace(/_/g,"");if(this.#X&&this.#G!==null&&!J){let F=this.#G+A,U={...this.#B,[$.type]:F},z=this.#D(U,$);if(z){this.inlineError=z,this.#G=null,this.#X=!1;return}this.inlineError="",this.#B[$.type]=F,this.#G=null,this.#X=!1,this.#Z(),B.index<this.#A.length-1&&(this.#Y.segmentIndex=B.index+1,this.#Y.positionInSegment=0,this.#X=!0);return}this.#X&&!J&&(this.#B[$.type]="_".repeat($.len),this.#Y.positionInSegment=0),this.#X=!1,this.#G=null;let Y=this.#B[$.type],X=Y.indexOf("_"),G=X>=0?X:Math.min(this.#Y.positionInSegment,$.len-1);if(G<0||G>=$.len)return;let W=Y.slice(0,G)+A+Y.slice(G+1),K=!1;if(G===0&&Y==="__"&&($.type==="month"||$.type==="day")){let F=Number.parseInt(A,10);W=`0${A}`,K=F<=($.type==="month"?1:2)}if($.type==="year"&&(W=(Y.replace(/_/g,"")+A).padStart($.len,"_")),!W.includes("_")){let F={...this.#B,[$.type]:W},U=this.#D(F,$);if(U){this.inlineError=U;return}}this.inlineError="",this.#B[$.type]=W;let H=W.includes("_")?void 0:nOA(this.#B);if(H){let{year:F,month:U}=H,z=R1A(F,U);this.#B={year:String(Math.max(0,Math.min(9999,F))).padStart(4,"0"),month:String(Math.max(1,Math.min(12,U))).padStart(2,"0"),day:String(Math.max(1,Math.min(z,H.day))).padStart(2,"0")}}this.#Z();let D=W.indexOf("_");K?(this.#X=!0,this.#G=A):D>=0?this.#Y.positionInSegment=D:X>=0&&B.index<this.#A.length-1?(this.#Y.segmentIndex=B.index+1,this.#Y.positionInSegment=0,this.#X=!0):this.#Y.positionInSegment=Math.min(G+1,$.len-1)}}#D(A,Q){let{month:B,day:$}=zm(A);if(Q.type==="month"&&(B<0||B>12))return qJ.date.messages.invalidMonth;if(Q.type==="day"&&($<0||$>31))return qJ.date.messages.invalidDay(31,"any month")}#z(A){let{year:Q,month:B,day:$}=zm(this.#B);if(Q&&B&&$){let J=R1A(Q,B);this.#B={...this.#B,day:String(Math.min($,J)).padStart(2,"0")}}this.value=dOA(this.#B)??A.defaultValue??void 0}};J3Q=class extends Pq{options;cursor=0;#A;getGroupItems(Q){return this.options.filter((B)=>B.group===Q)}isGroupSelected(Q){let B=this.getGroupItems(Q),$=this.value;return $===void 0?!1:B.every((J)=>$.includes(J.value))}toggleValue(){let Q=this.options[this.cursor];if(this.value===void 0&&(this.value=[]),Q.group===!0){let B=Q.value,$=this.getGroupItems(B);this.isGroupSelected(B)?this.value=this.value.filter((J)=>$.findIndex((Y)=>Y.value===J)===-1):this.value=[...this.value,...$.map((J)=>J.value)],this.value=Array.from(new Set(this.value))}else{let B=this.value.includes(Q.value);this.value=B?this.value.filter(($)=>$!==Q.value):[...this.value,Q.value]}}constructor(Q){super(Q,!1);let{options:B}=Q;this.#A=Q.selectableGroups!==!1,this.options=Object.entries(B).flatMap(([$,J])=>[{value:$,group:!0,label:$},...J.map((Y)=>({...Y,group:$}))]),this.value=[...Q.initialValues??[]],this.cursor=Math.max(this.options.findIndex(({value:$})=>$===Q.cursorAt),this.#A?0:1),this.on("cursor",($)=>{switch($){case"left":case"up":{this.cursor=this.cursor===0?this.options.length-1:this.cursor-1;let J=this.options[this.cursor]?.group===!0;!this.#A&&J&&(this.cursor=this.cursor===0?this.options.length-1:this.cursor-1);break}case"down":case"right":{this.cursor=this.cursor===this.options.length-1?0:this.cursor+1;let J=this.options[this.cursor]?.group===!0;!this.#A&&J&&(this.cursor=this.cursor===this.options.length-1?0:this.cursor+1);break}case"space":this.toggleValue();break}})}},Y3Q=new Set(["up","down","left","right"]);oOA=class oOA extends Pq{#A=!1;#Q;focused="editor";get userInputWithCursor(){if(this.state==="submit")return this.userInput;let A=this.userInput;if(this.cursor>=A.length)return`${A}█`;let Q=A.slice(0,this.cursor),B=A[this.cursor],$=A.slice(this.cursor+1);return B===`
`?`${Q}█
${$}`:`${Q}${HL("inverse",B)}${$}`}get cursor(){return this._cursor}#B(A){if(this.userInput.length===0){this._setUserInput(A);return}this._setUserInput(this.userInput.slice(0,this.cursor)+A+this.userInput.slice(this.cursor))}#$(A){let Q=this.value??"";switch(A){case"up":this._cursor=Fm(this._cursor,0,-1,Q);return;case"down":this._cursor=Fm(this._cursor,0,1,Q);return;case"left":this._cursor=Fm(this._cursor,-1,0,Q);return;case"right":this._cursor=Fm(this._cursor,1,0,Q);return}}_shouldSubmit(A,Q){if(this.#Q)return this.focused==="submit"?!0:(this.#B(`
`),this._cursor++,!1);let B=this.#A;return this.#A=!0,B?(this.userInput[this.cursor-1]===`
`&&(this._setUserInput(this.userInput.slice(0,this.cursor-1)+this.userInput.slice(this.cursor)),this._cursor--),!0):(this.#B(`
`),this._cursor++,!1)}constructor(A){super(A,!1),this.#Q=A.showSubmit??!1,this.on("key",(Q,B)=>{if(B?.name&&Y3Q.has(B.name)){this.#$(B.name);return}if(Q==="\t"&&this.#Q){this.focused=this.focused==="editor"?"submit":"editor";return}if(B?.name!=="return"){if(this.#A=!1,B?.name==="backspace"&&this.cursor>0){this._setUserInput(this.userInput.slice(0,this.cursor-1)+this.userInput.slice(this.cursor)),this._cursor--;return}if(B?.name==="delete"&&this.cursor<this.userInput.length){this._setUserInput(this.userInput.slice(0,this.cursor)+this.userInput.slice(this.cursor+1));return}Q&&(this.#Q&&this.focused==="submit"&&(this.focused="editor"),this.#B(Q??""),this._cursor++)}}),this.on("userInput",(Q)=>{this._setValue(Q)}),this.on("finalize",()=>{this.value||(this.value=A.defaultValue),this.value===void 0&&(this.value="")})}};T1A=class T1A extends Pq{_mask="•";get cursor(){return this._cursor}get masked(){return this.userInput.replaceAll(/./g,this._mask)}get userInputWithCursor(){if(this.state==="submit"||this.state==="cancel")return this.masked;let A=this.userInput;if(this.cursor>=A.length)return`${this.masked}${HL(["inverse","hidden"],"_")}`;let Q=this.masked,B=Q.slice(0,this.cursor),$=Q.slice(this.cursor);return`${B}${HL("inverse",$[0])}${$.slice(1)}`}clear(){this._clearUserInput()}constructor({mask:A,...Q}){super(Q),this._mask=A??"•",this.on("userInput",(B)=>{this._setValue(B)})}};k1A=class k1A extends Pq{options;cursor=0;get _selectedValue(){return this.options[this.cursor]}changeValue(){this.value=this._selectedValue.value}constructor(A){super(A,!1),this.options=A.options;let Q=this.options.findIndex(({value:$})=>$===A.initialValue),B=Q===-1?0:Q;this.cursor=this.options[B].disabled?ZL(B,1,this.options):B,this.changeValue(),this.on("cursor",($)=>{switch($){case"left":case"up":this.cursor=ZL(this.cursor,-1,this.options);break;case"down":case"right":this.cursor=ZL(this.cursor,1,this.options);break}this.changeValue()})}};S1A=class S1A extends Pq{get userInputWithCursor(){if(this.state==="submit")return this.userInput;let A=this.userInput;if(this.cursor>=A.length)return`${this.userInput}█`;let Q=A.slice(0,this.cursor),[B,...$]=A.slice(this.cursor);return`${Q}${HL("inverse",B)}${$.join("")}`}get cursor(){return this._cursor}constructor(A){super({...A,initialUserInput:A.initialUserInput??A.initialValue}),this.on("userInput",(Q)=>{this._setValue(Q)}),this.on("finalize",()=>{this.value||(this.value=A.defaultValue),this.value===void 0&&(this.value="")})}}});import{styleText as M0,stripVTControlCharacters as IE0}from"node:util";import kK from"node:process";function X3Q(){if(kK.platform!=="win32")return kK.env.TERM!=="linux";return Boolean(kK.env.CI)||Boolean(kK.env.WT_SESSION)||Boolean(kK.env.TERMINUS_SUBLIME)||kK.env.ConEmuTask==="{cmd::Cmder}"||kK.env.TERM_PROGRAM==="Terminus-Sublime"||kK.env.TERM_PROGRAM==="vscode"||kK.env.TERM==="xterm-256color"||kK.env.TERM==="alacritty"||kK.env.TERMINAL_EMULATOR==="JetBrains-JediTerm"}var GP,b1A,G3Q=()=>process.env.CI==="true",B4=(A,Q)=>b1A?A:Q,W3Q,sOA,tOA,v1A,K3Q,U$,U2,NE0,LE0,f1A,Om,VE0,EE0,RE0,Z3Q,jE0,wE0,_E0,PE0,TE0,kE0,H3Q,q3Q,D3Q,F3Q,Mm=(A)=>{switch(A){case"initial":case"active":return M0("cyan",W3Q);case"cancel":return M0("red",sOA);case"error":return M0("yellow",tOA);case"submit":return M0("green",v1A)}},U3Q=(A)=>{switch(A){case"initial":case"active":return M0("cyan",U$);case"cancel":return M0("red",U$);case"error":return M0("yellow",U$);case"submit":return M0("green",U$)}},rOA=(A,Q,B,$,J,Y=!1)=>{let X=Q,G=0;if(Y)for(let W=$-1;W>=B&&(X-=A[W].length,G++,!(X<=J));W--);else for(let W=B;W<$&&(X-=A[W].length,G++,!(X<=J));W++);return{lineCount:X,removals:G}},z3Q=({cursor:A,options:Q,style:B,output:$=process.stdout,maxItems:J=Number.POSITIVE_INFINITY,columnPadding:Y=0,rowPadding:X=4})=>{let G=Im($)-Y,W=_1A($),K=M0("dim","..."),H=Math.max(W-X,0),D=Math.max(Math.min(J,H),5),F=0;A>=D-3&&(F=Math.max(Math.min(A-D+3,Q.length-D),0));let U=D<Q.length&&F>0,z=D<Q.length&&F+D<Q.length,I=Math.min(F+D,Q.length),O=[],V=0;U&&V++,z&&V++;let E=F+(U?1:0),M=I-(z?1:0);for(let R=E;R<M;R++){let T=D2(B(Q[R],R===A),G,{hard:!0,trim:!1}).split(`
`);O.push(T),V+=T.length}if(V>H){let R=0,T=0,x=V,c=A-E,l=H,f=()=>rOA(O,x,0,c,l),h=()=>rOA(O,x,c+1,O.length,l,!0);U?({lineCount:x,removals:R}=f(),x>l&&(z||(l-=1),{lineCount:x,removals:T}=h())):(z||(l-=1),{lineCount:x,removals:T}=h(),x>l&&(l-=1,{lineCount:x,removals:R}=f())),R>0&&(U=!0,O.splice(0,R)),T>0&&(z=!0,O.splice(O.length-T,T))}let N=[];U&&N.push(K);for(let R of O)for(let T of R)N.push(T);return z&&N.push(K),N},c$=(A)=>{let Q=A.active??"Yes",B=A.inactive??"No";return new P1A({active:Q,inactive:B,signal:A.signal,input:A.input,output:A.output,initialValue:A.initialValue??!0,render(){let $=A.withGuide??qJ.withGuide,J=`${Mm(this.state)} `,Y=$?`${M0("gray",U$)} `:"",X=XP(A.output,A.message,Y,J),G=`${$?`${M0("gray",U$)}
`:""}${X}
`,W=this.value?Q:B;switch(this.state){case"submit":{let K=$?`${M0("gray",U$)} `:"";return`${G}${K}${M0("dim",W)}`}case"cancel":{let K=$?`${M0("gray",U$)} `:"";return`${G}${K}${M0(["strikethrough","dim"],W)}${$?`
${M0("gray",U$)}`:""}`}default:{let K=$?`${M0("cyan",U$)} `:"",H=$?M0("cyan",U2):"";return`${G}${K}${this.value?`${M0("green",f1A)} ${Q}`:`${M0("dim",Om)} ${M0("dim",Q)}`}${A.vertical?$?`
${M0("cyan",U$)} `:`
`:` ${M0("dim","/")} `}${this.value?`${M0("dim",Om)} ${M0("dim",B)}`:`${M0("green",f1A)} ${B}`}
${H}
`}}}}).prompt()},_,eOA=(A="",Q)=>{let B=Q?.output??process.stdout,$=Q?.withGuide??qJ.withGuide?`${M0("gray",U2)} `:"";B.write(`${$}${M0("red",A)}
`)},BB=(A="",Q)=>{let B=Q?.output??process.stdout,$=Q?.withGuide??qJ.withGuide?`${M0("gray",K3Q)} `:"";B.write(`${$}${A}
`)},$B=(A="",Q)=>{let B=Q?.output??process.stdout,$=Q?.withGuide??qJ.withGuide?`${M0("gray",U$)}
${M0("gray",U2)} `:"";B.write(`${$}${A}
`)},AMA=(A)=>new T1A({validate:A.validate,mask:A.mask??Z3Q,signal:A.signal,input:A.input,output:A.output,render(){let Q=A.withGuide??qJ.withGuide,B=`${Q?`${M0("gray",U$)}
`:""}${Mm(this.state)} ${A.message}
`,$=this.userInputWithCursor,J=this.masked;switch(this.state){case"error":{let Y=Q?`${M0("yellow",U$)} `:"",X=Q?`${M0("yellow",U2)} `:"",G=J??"";return A.clearOnError&&this.clear(),`${B.trim()}
${Y}${G}
${X}${M0("yellow",this.error)}
`}case"submit":{let Y=Q?`${M0("gray",U$)} `:"",X=J?M0("dim",J):"";return`${B}${Y}${X}`}case"cancel":{let Y=Q?`${M0("gray",U$)} `:"",X=J?M0(["strikethrough","dim"],J):"";return`${B}${Y}${X}${J&&Q?`
${M0("gray",U$)}`:""}`}default:{let Y=Q?`${M0("cyan",U$)} `:"",X=Q?M0("cyan",U2):"";return`${B}${Y}${$}
${X}
`}}}}).prompt(),I3Q=(A)=>M0("magenta",A),P$=({indicator:A="dots",onCancel:Q,output:B=process.stdout,cancelMessage:$,errorMessage:J,frames:Y=b1A?["◒","◐","◓","◑"]:["•","o","O","0"],delay:X=b1A?80:120,signal:G,...W}={})=>{let K=G3Q(),H,D,F=!1,U=!1,z="",I,O=performance.now(),V=Im(B),E=W?.styleFrame??I3Q,M=(DA)=>{let o=DA>1?J??qJ.messages.error:$??qJ.messages.cancel;U=DA===1,F&&(r(o,DA),U&&typeof Q=="function"&&Q())},N=()=>M(2),R=()=>M(1),T=()=>{process.on("uncaughtExceptionMonitor",N),process.on("unhandledRejection",N),process.on("SIGINT",R),process.on("SIGTERM",R),process.on("exit",M),G&&G.addEventListener("abort",R)},x=()=>{process.removeListener("uncaughtExceptionMonitor",N),process.removeListener("unhandledRejection",N),process.removeListener("SIGINT",R),process.removeListener("SIGTERM",R),process.removeListener("exit",M),G&&G.removeEventListener("abort",R)},c=()=>{if(I===void 0)return;K&&B.write(`
`);let DA=D2(I,V,{hard:!0,trim:!1}).split(`
`);DA.length>1&&B.write(GP.cursor.up(DA.length-1)),B.write(GP.cursor.to(0)),B.write(GP.erase.down())},l=(DA)=>DA.replace(/\.+$/,""),f=(DA)=>{let o=(performance.now()-DA)/1000,y=Math.floor(o/60),v=Math.floor(o%60);return y>0?`[${y}m ${v}s]`:`[${v}s]`},h=W.withGuide??qJ.withGuide,i=(DA="")=>{F=!0,H=pOA({output:B}),z=l(DA),O=performance.now(),h&&B.write(`${M0("gray",U$)}
`);let o=0,y=0;T(),D=setInterval(()=>{if(K&&z===I)return;c(),I=z;let v=E(Y[o]),S;if(K)S=`${v} ${z}...`;else if(A==="timer")S=`${v} ${z} ${f(O)}`;else{let g=".".repeat(Math.floor(y)).slice(0,3);S=`${v} ${z}${g}`}let m=D2(S,V,{hard:!0,trim:!1});B.write(m),o=o+1<Y.length?o+1:0,y=y<4?y+0.125:0},X)},r=(DA="",o=0,y=!1)=>{if(!F)return;F=!1,clearInterval(D),c();let v=o===0?M0("green",v1A):o===1?M0("red",sOA):M0("red",tOA);z=DA??z,y||(A==="timer"?B.write(`${v} ${z} ${f(O)}
`):B.write(`${v} ${z}
`)),x(),H()};return{start:i,stop:(DA="")=>r(DA,0),message:(DA="")=>{z=l(DA??z)},cancel:(DA="")=>r(DA,1),error:(DA="")=>r(DA,2),clear:()=>r("",0,!0),get isCancelled(){return U}}},SE0,Cm=(A,Q)=>A.includes(`
`)?A.split(`
`).map((B)=>Q(B)).join(`
`):Q(A),c9=(A)=>{let Q=(B,$)=>{let J=B.label??String(B.value);switch($){case"disabled":return`${M0("gray",Om)} ${Cm(J,(Y)=>M0("gray",Y))}${B.hint?` ${M0("dim",`(${B.hint??"disabled"})`)}`:""}`;case"selected":return`${Cm(J,(Y)=>M0("dim",Y))}`;case"active":return`${M0("green",f1A)} ${J}${B.hint?` ${M0("dim",`(${B.hint})`)}`:""}`;case"cancelled":return`${Cm(J,(Y)=>M0(["strikethrough","dim"],Y))}`;default:return`${M0("dim",Om)} ${Cm(J,(Y)=>M0("dim",Y))}`}};return new k1A({options:A.options,signal:A.signal,input:A.input,output:A.output,initialValue:A.initialValue,render(){let B=A.withGuide??qJ.withGuide,$=`${Mm(this.state)} `,J=`${U3Q(this.state)} `,Y=XP(A.output,A.message,J,$),X=`${B?`${M0("gray",U$)}
`:""}${Y}
`;switch(this.state){case"submit":{let G=B?`${M0("gray",U$)} `:"",W=XP(A.output,Q(this.options[this.cursor],"selected"),G);return`${X}${W}`}case"cancel":{let G=B?`${M0("gray",U$)} `:"",W=XP(A.output,Q(this.options[this.cursor],"cancelled"),G);return`${X}${W}${B?`
${M0("gray",U$)}`:""}`}default:{let G=B?`${M0("cyan",U$)} `:"",W=B?M0("cyan",U2):"",K=X.split(`
`).length,H=B?2:1;return`${X}${G}${z3Q({output:A.output,cursor:this.cursor,options:this.options,maxItems:A.maxItems,columnPadding:G.length,rowPadding:K+H,style:(D,F)=>Q(D,D.disabled?"disabled":F?"active":"inactive")}).join(`
${G}`)}
${W}
`}}}}).prompt()},xE0,z2=(A)=>new S1A({validate:A.validate,placeholder:A.placeholder,defaultValue:A.defaultValue,initialValue:A.initialValue,output:A.output,signal:A.signal,input:A.input,render(){let Q=A?.withGuide??qJ.withGuide,B=`${`${Q?`${M0("gray",U$)}
`:""}${Mm(this.state)} `}${A.message}
`,$=A.placeholder?M0("inverse",A.placeholder[0])+M0("dim",A.placeholder.slice(1)):M0(["inverse","hidden"],"_"),J=this.userInput?this.userInputWithCursor:$,Y=this.value??"";switch(this.state){case"error":{let X=this.error?` ${M0("yellow",this.error)}`:"",G=Q?`${M0("yellow",U$)} `:"",W=Q?M0("yellow",U2):"";return`${B.trim()}
${G}${J}
${W}${X}
`}case"submit":{let X=Y?` ${M0("dim",Y)}`:"",G=Q?M0("gray",U$):"";return`${B}${G}${X}`}case"cancel":{let X=Y?` ${M0(["strikethrough","dim"],Y)}`:"",G=Q?M0("gray",U$):"";return`${B}${G}${X}${Y.trim()?`
${G}`:""}`}default:{let X=Q?`${M0("cyan",U$)} `:"",G=Q?M0("cyan",U2):"";return`${B}${X}${J}
${G}
`}}}}).prompt();var gB=fA(()=>{x1A();x1A();M1A();z1A();GP=lA(L1A(),1);b1A=X3Q(),W3Q=B4("◆","*"),sOA=B4("■","x"),tOA=B4("▲","x"),v1A=B4("◇","o"),K3Q=B4("┌","T"),U$=B4("│","|"),U2=B4("└","—"),NE0=B4("┐","T"),LE0=B4("┘","—"),f1A=B4("●",">"),Om=B4("○"," "),VE0=B4("◻","[•]"),EE0=B4("◼","[+]"),RE0=B4("◻","[ ]"),Z3Q=B4("▪","•"),jE0=B4("─","-"),wE0=B4("╮","+"),_E0=B4("├","+"),PE0=B4("╯","+"),TE0=B4("╰","+"),kE0=B4("╭","+"),H3Q=B4("●","•"),q3Q=B4("◆","*"),D3Q=B4("▲","!"),F3Q=B4("■","x"),_={message:(A=[],{symbol:Q=M0("gray",U$),secondarySymbol:B=M0("gray",U$),output:$=process.stdout,spacing:J=1,withGuide:Y}={})=>{let X=[],G=Y??qJ.withGuide,W=G?B:"",K=G?`${Q} `:"",H=G?`${B} `:"";for(let F=0;F<J;F++)X.push(W);let D=Array.isArray(A)?A:A.split(`
`);if(D.length>0){let[F,...U]=D;F.length>0?X.push(`${K}${F}`):X.push(G?Q:"");for(let z of U)z.length>0?X.push(`${H}${z}`):X.push(G?B:"")}$.write(`${X.join(`
`)}
`)},info:(A,Q)=>{_.message(A,{...Q,symbol:M0("blue",H3Q)})},success:(A,Q)=>{_.message(A,{...Q,symbol:M0("green",q3Q)})},step:(A,Q)=>{_.message(A,{...Q,symbol:M0("green",v1A)})},warn:(A,Q)=>{_.message(A,{...Q,symbol:M0("yellow",D3Q)})},warning:(A,Q)=>{_.warn(A,Q)},error:(A,Q)=>{_.message(A,{...Q,symbol:M0("red",F3Q)})}},SE0={light:B4("─","-"),heavy:B4("━","="),block:B4("█","#")},xE0=`${M0("gray",U$)} `});var WP=t((C3Q)=>{class g1A extends Error{constructor(A,Q,B){super(B);Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=Q,this.exitCode=A,this.nestedError=void 0}}class QMA extends g1A{constructor(A){super(1,"commander.invalidArgument",A);Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}}C3Q.CommanderError=g1A;C3Q.InvalidArgumentError=QMA});var Nm=t((V3Q)=>{var{InvalidArgumentError:N3Q}=WP();class BMA{constructor(A,Q){switch(this.description=Q||"",this.variadic=!1,this.parseArg=void 0,this.defaultValue=void 0,this.defaultValueDescription=void 0,this.argChoices=void 0,A[0]){case"<":this.required=!0,this._name=A.slice(1,-1);break;case"[":this.required=!1,this._name=A.slice(1,-1);break;default:this.required=!0,this._name=A;break}if(this._name.endsWith("..."))this.variadic=!0,this._name=this._name.slice(0,-3)}name(){return this._name}_collectValue(A,Q){if(Q===this.defaultValue||!Array.isArray(Q))return[A];return Q.push(A),Q}default(A,Q){return this.defaultValue=A,this.defaultValueDescription=Q,this}argParser(A){return this.parseArg=A,this}choices(A){return this.argChoices=A.slice(),this.parseArg=(Q,B)=>{if(!this.argChoices.includes(Q))throw new N3Q(`Allowed choices are ${this.argChoices.join(", ")}.`);if(this.variadic)return this._collectValue(Q,B);return Q},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}}function L3Q(A){let Q=A.name()+(A.variadic===!0?"...":"");return A.required?"<"+Q+">":"["+Q+"]"}V3Q.Argument=BMA;V3Q.humanReadableArgName=L3Q});var y1A=t((w3Q)=>{var{humanReadableArgName:j3Q}=Nm();class $MA{constructor(){this.helpWidth=void 0,this.minWidthToWrap=40,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}prepareContext(A){this.helpWidth=this.helpWidth??A.helpWidth??80}visibleCommands(A){let Q=A.commands.filter(($)=>!$._hidden),B=A._getHelpCommand();if(B&&!B._hidden)Q.push(B);if(this.sortSubcommands)Q.sort(($,J)=>{return $.name().localeCompare(J.name())});return Q}compareOptions(A,Q){let B=($)=>{return $.short?$.short.replace(/^-/,""):$.long.replace(/^--/,"")};return B(A).localeCompare(B(Q))}visibleOptions(A){let Q=A.options.filter(($)=>!$.hidden),B=A._getHelpOption();if(B&&!B.hidden){let $=B.short&&A._findOption(B.short),J=B.long&&A._findOption(B.long);if(!$&&!J)Q.push(B);else if(B.long&&!J)Q.push(A.createOption(B.long,B.description));else if(B.short&&!$)Q.push(A.createOption(B.short,B.description))}if(this.sortOptions)Q.sort(this.compareOptions);return Q}visibleGlobalOptions(A){if(!this.showGlobalOptions)return[];let Q=[];for(let B=A.parent;B;B=B.parent){let $=B.options.filter((J)=>!J.hidden);Q.push(...$)}if(this.sortOptions)Q.sort(this.compareOptions);return Q}visibleArguments(A){if(A._argsDescription)A.registeredArguments.forEach((Q)=>{Q.description=Q.description||A._argsDescription[Q.name()]||""});if(A.registeredArguments.find((Q)=>Q.description))return A.registeredArguments;return[]}subcommandTerm(A){let Q=A.registeredArguments.map((B)=>j3Q(B)).join(" ");return A._name+(A._aliases[0]?"|"+A._aliases[0]:"")+(A.options.length?" [options]":"")+(Q?" "+Q:"")}optionTerm(A){return A.flags}argumentTerm(A){return A.name()}longestSubcommandTermLength(A,Q){return Q.visibleCommands(A).reduce((B,$)=>{return Math.max(B,this.displayWidth(Q.styleSubcommandTerm(Q.subcommandTerm($))))},0)}longestOptionTermLength(A,Q){return Q.visibleOptions(A).reduce((B,$)=>{return Math.max(B,this.displayWidth(Q.styleOptionTerm(Q.optionTerm($))))},0)}longestGlobalOptionTermLength(A,Q){return Q.visibleGlobalOptions(A).reduce((B,$)=>{return Math.max(B,this.displayWidth(Q.styleOptionTerm(Q.optionTerm($))))},0)}longestArgumentTermLength(A,Q){return Q.visibleArguments(A).reduce((B,$)=>{return Math.max(B,this.displayWidth(Q.styleArgumentTerm(Q.argumentTerm($))))},0)}commandUsage(A){let Q=A._name;if(A._aliases[0])Q=Q+"|"+A._aliases[0];let B="";for(let $=A.parent;$;$=$.parent)B=$.name()+" "+B;return B+Q+" "+A.usage()}commandDescription(A){return A.description()}subcommandDescription(A){return A.summary()||A.description()}optionDescription(A){let Q=[];if(A.argChoices)Q.push(`choices: ${A.argChoices.map((B)=>JSON.stringify(B)).join(", ")}`);if(A.defaultValue!==void 0){if(A.required||A.optional||A.isBoolean()&&typeof A.defaultValue==="boolean")Q.push(`default: ${A.defaultValueDescription||JSON.stringify(A.defaultValue)}`)}if(A.presetArg!==void 0&&A.optional)Q.push(`preset: ${JSON.stringify(A.presetArg)}`);if(A.envVar!==void 0)Q.push(`env: ${A.envVar}`);if(Q.length>0){let B=`(${Q.join(", ")})`;if(A.description)return`${A.description} ${B}`;return B}return A.description}argumentDescription(A){let Q=[];if(A.argChoices)Q.push(`choices: ${A.argChoices.map((B)=>JSON.stringify(B)).join(", ")}`);if(A.defaultValue!==void 0)Q.push(`default: ${A.defaultValueDescription||JSON.stringify(A.defaultValue)}`);if(Q.length>0){let B=`(${Q.join(", ")})`;if(A.description)return`${A.description} ${B}`;return B}return A.description}formatItemList(A,Q,B){if(Q.length===0)return[];return[B.styleTitle(A),...Q,""]}groupItems(A,Q,B){let $=new Map;return A.forEach((J)=>{let Y=B(J);if(!$.has(Y))$.set(Y,[])}),Q.forEach((J)=>{let Y=B(J);if(!$.has(Y))$.set(Y,[]);$.get(Y).push(J)}),$}formatHelp(A,Q){let B=Q.padWidth(A,Q),$=Q.helpWidth??80;function J(H,D){return Q.formatItem(H,B,D,Q)}let Y=[`${Q.styleTitle("Usage:")} ${Q.styleUsage(Q.commandUsage(A))}`,""],X=Q.commandDescription(A);if(X.length>0)Y=Y.concat([Q.boxWrap(Q.styleCommandDescription(X),$),""]);let G=Q.visibleArguments(A).map((H)=>{return J(Q.styleArgumentTerm(Q.argumentTerm(H)),Q.styleArgumentDescription(Q.argumentDescription(H)))});if(Y=Y.concat(this.formatItemList("Arguments:",G,Q)),this.groupItems(A.options,Q.visibleOptions(A),(H)=>H.helpGroupHeading??"Options:").forEach((H,D)=>{let F=H.map((U)=>{return J(Q.styleOptionTerm(Q.optionTerm(U)),Q.styleOptionDescription(Q.optionDescription(U)))});Y=Y.concat(this.formatItemList(D,F,Q))}),Q.showGlobalOptions){let H=Q.visibleGlobalOptions(A).map((D)=>{return J(Q.styleOptionTerm(Q.optionTerm(D)),Q.styleOptionDescription(Q.optionDescription(D)))});Y=Y.concat(this.formatItemList("Global Options:",H,Q))}return this.groupItems(A.commands,Q.visibleCommands(A),(H)=>H.helpGroup()||"Commands:").forEach((H,D)=>{let F=H.map((U)=>{return J(Q.styleSubcommandTerm(Q.subcommandTerm(U)),Q.styleSubcommandDescription(Q.subcommandDescription(U)))});Y=Y.concat(this.formatItemList(D,F,Q))}),Y.join(`
`)}displayWidth(A){return JMA(A).length}styleTitle(A){return A}styleUsage(A){return A.split(" ").map((Q)=>{if(Q==="[options]")return this.styleOptionText(Q);if(Q==="[command]")return this.styleSubcommandText(Q);if(Q[0]==="["||Q[0]==="<")return this.styleArgumentText(Q);return this.styleCommandText(Q)}).join(" ")}styleCommandDescription(A){return this.styleDescriptionText(A)}styleOptionDescription(A){return this.styleDescriptionText(A)}styleSubcommandDescription(A){return this.styleDescriptionText(A)}styleArgumentDescription(A){return this.styleDescriptionText(A)}styleDescriptionText(A){return A}styleOptionTerm(A){return this.styleOptionText(A)}styleSubcommandTerm(A){return A.split(" ").map((Q)=>{if(Q==="[options]")return this.styleOptionText(Q);if(Q[0]==="["||Q[0]==="<")return this.styleArgumentText(Q);return this.styleSubcommandText(Q)}).join(" ")}styleArgumentTerm(A){return this.styleArgumentText(A)}styleOptionText(A){return A}styleArgumentText(A){return A}styleSubcommandText(A){return A}styleCommandText(A){return A}padWidth(A,Q){return Math.max(Q.longestOptionTermLength(A,Q),Q.longestGlobalOptionTermLength(A,Q),Q.longestSubcommandTermLength(A,Q),Q.longestArgumentTermLength(A,Q))}preformatted(A){return/\n[^\S\r\n]/.test(A)}formatItem(A,Q,B,$){let Y=" ".repeat(2);if(!B)return Y+A;let X=A.padEnd(Q+A.length-$.displayWidth(A)),G=2,K=(this.helpWidth??80)-Q-G-2,H;if(K<this.minWidthToWrap||$.preformatted(B))H=B;else H=$.boxWrap(B,K).replace(/\n/g,`
`+" ".repeat(Q+G));return Y+X+" ".repeat(G)+H.replace(/\n/g,`
${Y}`)}boxWrap(A,Q){if(Q<this.minWidthToWrap)return A;let B=A.split(/\r\n|\n/),$=/[\s]*[^\s]+/g,J=[];return B.forEach((Y)=>{let X=Y.match($);if(X===null){J.push("");return}let G=[X.shift()],W=this.displayWidth(G[0]);X.forEach((K)=>{let H=this.displayWidth(K);if(W+H<=Q){G.push(K),W+=H;return}J.push(G.join(""));let D=K.trimStart();G=[D],W=this.displayWidth(D)}),J.push(G.join(""))}),J.join(`
`)}}function JMA(A){let Q=/\x1b\[\d*(;\d*)*m/g;return A.replace(Q,"")}w3Q.Help=$MA;w3Q.stripColor=JMA});var h1A=t((S3Q)=>{var{InvalidArgumentError:T3Q}=WP();class XMA{constructor(A,Q){this.flags=A,this.description=Q||"",this.required=A.includes("<"),this.optional=A.includes("["),this.variadic=/\w\.\.\.[>\]]$/.test(A),this.mandatory=!1;let B=k3Q(A);if(this.short=B.shortFlag,this.long=B.longFlag,this.negate=!1,this.long)this.negate=this.long.startsWith("--no-");this.defaultValue=void 0,this.defaultValueDescription=void 0,this.presetArg=void 0,this.envVar=void 0,this.parseArg=void 0,this.hidden=!1,this.argChoices=void 0,this.conflictsWith=[],this.implied=void 0,this.helpGroupHeading=void 0}default(A,Q){return this.defaultValue=A,this.defaultValueDescription=Q,this}preset(A){return this.presetArg=A,this}conflicts(A){return this.conflictsWith=this.conflictsWith.concat(A),this}implies(A){let Q=A;if(typeof A==="string")Q={[A]:!0};return this.implied=Object.assign(this.implied||{},Q),this}env(A){return this.envVar=A,this}argParser(A){return this.parseArg=A,this}makeOptionMandatory(A=!0){return this.mandatory=!!A,this}hideHelp(A=!0){return this.hidden=!!A,this}_collectValue(A,Q){if(Q===this.defaultValue||!Array.isArray(Q))return[A];return Q.push(A),Q}choices(A){return this.argChoices=A.slice(),this.parseArg=(Q,B)=>{if(!this.argChoices.includes(Q))throw new T3Q(`Allowed choices are ${this.argChoices.join(", ")}.`);if(this.variadic)return this._collectValue(Q,B);return Q},this}name(){if(this.long)return this.long.replace(/^--/,"");return this.short.replace(/^-/,"")}attributeName(){if(this.negate)return YMA(this.name().replace(/^no-/,""));return YMA(this.name())}helpGroup(A){return this.helpGroupHeading=A,this}is(A){return this.short===A||this.long===A}isBoolean(){return!this.required&&!this.optional&&!this.negate}}class GMA{constructor(A){this.positiveOptions=new Map,this.negativeOptions=new Map,this.dualOptions=new Set,A.forEach((Q)=>{if(Q.negate)this.negativeOptions.set(Q.attributeName(),Q);else this.positiveOptions.set(Q.attributeName(),Q)}),this.negativeOptions.forEach((Q,B)=>{if(this.positiveOptions.has(B))this.dualOptions.add(B)})}valueFromOption(A,Q){let B=Q.attributeName();if(!this.dualOptions.has(B))return!0;let $=this.negativeOptions.get(B).presetArg,J=$!==void 0?$:!1;return Q.negate===(J===A)}}function YMA(A){return A.split("-").reduce((Q,B)=>{return Q+B[0].toUpperCase()+B.slice(1)})}function k3Q(A){let Q,B,$=/^-[^-]$/,J=/^--[^-]/,Y=A.split(/[ |,]+/).concat("guard");if($.test(Y[0]))Q=Y.shift();if(J.test(Y[0]))B=Y.shift();if(!Q&&$.test(Y[0]))Q=Y.shift();if(!Q&&J.test(Y[0]))Q=B,B=Y.shift();if(Y[0].startsWith("-")){let X=Y[0],G=`option creation failed due to '${X}' in option flags '${A}'`;if(/^-[^-][^-]/.test(X))throw Error(`${G}
- a short flag is a single dash and a single character
- either use a single dash and a single character (for a short flag)
- or use a double dash for a long option (and can have two, like '--ws, --workspace')`);if($.test(X))throw Error(`${G}
- too many short flags`);if(J.test(X))throw Error(`${G}
- too many long flags`);throw Error(`${G}
- unrecognised flag format`)}if(Q===void 0&&B===void 0)throw Error(`option creation failed due to no flags found in '${A}'.`);return{shortFlag:Q,longFlag:B}}S3Q.Option=XMA;S3Q.DualOptions=GMA});var WMA=t((g3Q)=>{function f3Q(A,Q){if(Math.abs(A.length-Q.length)>3)return Math.max(A.length,Q.length);let B=[];for(let $=0;$<=A.length;$++)B[$]=[$];for(let $=0;$<=Q.length;$++)B[0][$]=$;for(let $=1;$<=Q.length;$++)for(let J=1;J<=A.length;J++){let Y=1;if(A[J-1]===Q[$-1])Y=0;else Y=1;if(B[J][$]