UNPKG

@capgo/cli

Version:
70 lines (68 loc) 4.53 MB
#!/usr/bin/env node import{createRequire as nKQ}from"node:module";var mKQ=Object.create;var{getPrototypeOf:uKQ,defineProperty:GT,getOwnPropertyNames:sUA,getOwnPropertyDescriptor:cKQ}=Object,rUA=Object.prototype.hasOwnProperty;function tUA(A){return this[A]}var dKQ,lKQ,eA=(A,Q,B)=>{var J=A!=null&&typeof A==="object";if(J){var Y=Q?dKQ??=new WeakMap:lKQ??=new WeakMap,Z=Y.get(A);if(Z)return Z}B=A!=null?mKQ(uKQ(A)):{};let X=Q||!A||!A.__esModule?GT(B,"default",{value:A,enumerable:!0}):B;for(let $ of sUA(A))if(!rUA.call(X,$))GT(X,$,{get:tUA.bind(A,$),enumerable:!0});if(J)Y.set(A,X);return X},cK=(A)=>{var Q=(aUA??=new WeakMap).get(A),B;if(Q)return Q;if(Q=GT({},"__esModule",{value:!0}),A&&typeof A==="object"||typeof A==="function"){for(var J of sUA(A))if(!rUA.call(Q,J))GT(Q,J,{get:tUA.bind(A,J),enumerable:!(B=cKQ(A,J))||B.enumerable})}return aUA.set(A,Q),Q},aUA,HA=(A,Q)=>()=>(Q||A((Q={exports:{}}).exports,Q),Q.exports);var pKQ=(A)=>A;function iKQ(A,Q){this[A]=pKQ.bind(null,Q)}var I$=(A,Q)=>{for(var B in Q)GT(A,B,{get:Q[B],enumerable:!0,configurable:!0,set:iKQ.bind(Q,B)})};var SA=(A,Q)=>()=>(A&&(Q=A(A=0)),Q);var MQ=nKQ(import.meta.url);var eUA,AIA=(A)=>{return A===12288||A>=65281&&A<=65376||A>=65504&&A<=65510},QIA=(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 BIA=SA(()=>{eUA=(()=>{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 oKQ,aKQ,JIA,sKQ,YIA,rKQ,tKQ,eKQ,ZIA=(A,Q={},B={})=>{let J=Q.limit??1/0,Y=Q.ellipsis??"",Z=Q?.ellipsisWidth??(Y?ZIA(Y,eKQ,B).width:0),X=0,$=B.controlWidth??0,G=B.tabWidth??8,K=B.emojiWidth??2,W=2,F=B.regularWidth??1,D=B.wideWidth??2,U=[[rKQ,F],[oKQ,0],[aKQ,$],[sKQ,G],[YIA,K],[JIA,D]],q=0,I=0,C=A.length,N=0,V=!1,O=C,L=Math.max(0,J-Z),R=0,j=0,w=0,k=0;A:while(!0){if(j>R||I>=C&&I>q){let m=A.slice(R,j)||A.slice(q,I);N=0;for(let y of m.replaceAll(tKQ,"")){let g=y.codePointAt(0)||0;if(AIA(g))k=2;else if(QIA(g))k=D;else k=F;if(w+k>L)O=Math.min(O,Math.max(R,q)+N);if(w+k>J){V=!0;break A}N+=y.length,w+=k}R=j=0}if(I>=C)break A;for(let m=0,y=U.length;m<y;m++){let[g,l]=U[m];if(g.lastIndex=I,g.test(A)){if(N=g===JIA?eUA(A.slice(I,g.lastIndex)):g===YIA?1:g.lastIndex-I,k=N*l,w+k>L)O=Math.min(O,I+Math.floor((L-w)/l));if(w+k>J){V=!0;break A}w+=k,R=q,j=I,I=q=g.lastIndex;continue A}}I+=1}return{width:V?L:w,index:V?O:C,truncated:V,ellipsed:V&&J>=Z}},XIA;var $IA=SA(()=>{BIA();oKQ=/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]|\u001b\]8;[^;]*;.*?(?:\u0007|\u001b\u005c)/y,aKQ=/[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y,JIA=/(?:(?![\uFF61-\uFF9F\uFF00-\uFFEF])[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}\p{Script=Tangut}]){1,1000}/yu,sKQ=/\t{1,1000}/y,YIA=/[\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,rKQ=/(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y,tKQ=/\p{M}+/gu,eKQ={limit:1/0,ellipsis:""},XIA=ZIA});var AWQ,QWQ=(A,Q={})=>{return XIA(A,AWQ,Q).width},MH;var jBA=SA(()=>{$IA();AWQ={limit:1/0,ellipsis:"",ellipsisWidth:0},MH=QWQ});function kD(A,Q,B){return String(A).normalize().split(XWQ).map((J)=>ZWQ(J,Q,B)).join(` `)}var am="\x1B",FIA="›",BWQ=39,PBA="\x07",zIA="[",JWQ="]",DIA="m",TBA,GIA,KIA=(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},WIA=(A)=>`${am}${zIA}${A}${DIA}`,HIA=(A)=>`${am}${TBA}${A}${PBA}`,wBA=(A,Q,B)=>{let J=Q[Symbol.iterator](),Y=!1,Z=!1,X=A.at(-1),$=X===void 0?0:MH(X),G=J.next(),K=J.next(),W=0;while(!G.done){let F=G.value,D=MH(F);if($+D<=B)A[A.length-1]+=F;else A.push(F),$=0;if(F===am||F===FIA)Y=!0,Z=Q.startsWith(TBA,W+1);if(Y){if(Z){if(F===PBA)Y=!1,Z=!1}else if(F===DIA)Y=!1}else if($+=D,$===B&&!K.done)A.push(""),$=0;G=K,K=J.next(),W+=F.length}if(X=A.at(-1),!$&&X!==void 0&&X.length&&A.length>1)A[A.length-2]+=A.pop()},YWQ=(A)=>{let Q=A.split(" "),B=Q.length;while(B){if(MH(Q[B-1]))break;B--}if(B===Q.length)return A;return Q.slice(0,B).join(" ")+Q.slice(B).join("")},ZWQ=(A,Q,B={})=>{if(B.trim!==!1&&A.trim()==="")return"";let J="",Y,Z,X=A.split(" "),$=[""],G=0;for(let F=0;F<X.length;F++){let D=X[F];if(B.trim!==!1){let q=$.at(-1)??"",I=q.trimStart();if(q.length!==I.length)$[$.length-1]=I,G=MH(I)}if(F!==0){if(G>=Q&&(B.wordWrap===!1||B.trim===!1))$.push(""),G=0;if(G||B.trim===!1)$[$.length-1]+=" ",G++}let U=MH(D);if(B.hard&&U>Q){let q=Q-G,I=1+Math.floor((U-q-1)/Q);if(Math.floor((U-1)/Q)<I)$.push("");wBA($,D,Q),G=MH($.at(-1)??"");continue}if(G+U>Q&&G&&U){if(B.wordWrap===!1&&G<Q){wBA($,D,Q),G=MH($.at(-1)??"");continue}$.push(""),G=0}if(G+U>Q&&B.wordWrap===!1){wBA($,D,Q),G=MH($.at(-1)??"");continue}$[$.length-1]+=D,G+=U}if(B.trim!==!1)$=$.map((F)=>YWQ(F));let K=$.join(` `),W=!1;for(let F=0;F<K.length;F++){let D=K[F];if(J+=D,!W){if(W=D>="\uD800"&&D<="\uDBFF",W)continue}else W=!1;if(D===am||D===FIA){GIA.lastIndex=F+1;let q=GIA.exec(K)?.groups;if(q?.code!==void 0){let I=Number.parseFloat(q.code);Y=I===BWQ?void 0:I}else if(q?.uri!==void 0)Z=q.uri.length===0?void 0:q.uri}if(K[F+1]===` `){if(Z)J+=HIA("");let U=Y?KIA(Y):void 0;if(Y&&U)J+=WIA(U)}else if(D===` `){if(Y&&KIA(Y))J+=WIA(Y);if(Z)J+=HIA(Z)}}return J},XWQ;var _BA=SA(()=>{jBA();TBA=`${JWQ}8;;`,GIA=new RegExp(`(?:\\${zIA}(?<code>\\d+)m|\\${TBA}(?<uri>.*)${PBA})`,"y"),XWQ=/\r?\n/});var kBA=HA((xC0,qIA)=>{var SBA={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"},$WQ={up:(A=1)=>"\x1B[S".repeat(A),down:(A=1)=>"\x1B[T".repeat(A)},GWQ={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?SBA.up():"");if(A)Q+=SBA.left;return Q}};qIA.exports={cursor:SBA,scroll:$WQ,erase:GWQ,beep:"\x07"}});import{styleText as jN}from"node:util";import{stdout as yBA,stdin as MIA}from"node:process";import*as bD from"node:readline";import KWQ from"node:readline";import{ReadStream as UIA}from"node:tty";function RN(A,Q,B){if(!B.some((X)=>!X.disabled))return A;let J=A+Q,Y=Math.max(B.length-1,0),Z=J<0?Y:J>Y?0:J;return B[Z]?.disabled?RN(Z,Q<0?-1:1,B):Z}function sm(A,Q,B,J){let Y=J.split(` `),Z=0,X=A;for(let G of Y){if(X<=G.length)break;X-=G.length+1,Z++}for(Z=Math.max(0,Math.min(Y.length-1,Z+B)),X=Math.min(X,Y[Z].length)+Q;X<0&&Z>0;)Z--,X+=Y[Z].length+1;for(;X>Y[Z].length&&Z<Y.length-1;)X-=Y[Z].length+1,Z++;X=Math.max(0,Math.min(Y[Z].length,X));let $=0;for(let G=0;G<Z;G++)$+=Y[G].length+1;return $+X}function vBA(A,Q){if(typeof A=="string")return x5.aliases.get(A)===Q;for(let B of A)if(B!==void 0&&vBA(B,Q))return!0;return!1}function FWQ(A,Q){if(A===Q)return;let B=A.split(` `),J=Q.split(` `),Y=Math.max(B.length,J.length),Z=[];for(let X=0;X<Y;X++)B[X]!==J[X]&&Z.push(X);return{lines:Z,numLinesBefore:B.length,numLinesAfter:J.length,numLines:Y}}function w1(A){return A===xBA}function rm(A,Q){let B=A;B.isTTY&&B.setRawMode(Q)}function OIA({input:A=MIA,output:Q=yBA,overwrite:B=!0,hideCursor:J=!0}={}){let Y=bD.createInterface({input:A,output:Q,prompt:"",tabSize:1});bD.emitKeypressEvents(A,Y),A instanceof UIA&&A.isTTY&&A.setRawMode(!0);let Z=(X,{name:$,sequence:G})=>{let K=String(X);if(vBA([K,$,G],"cancel")){J&&Q.write(w7.cursor.show),process.exit(0);return}if(!B)return;bD.moveCursor(Q,$==="return"?0:-1,$==="return"?-1:0,()=>{bD.clearLine(Q,1,()=>{A.once("keypress",Z)})})};return J&&Q.write(w7.cursor.hide),A.once("keypress",Z),()=>{A.off("keypress",Z),J&&Q.write(w7.cursor.show),A instanceof UIA&&A.isTTY&&!zWQ&&A.setRawMode(!1),Y.terminal=!1,Y.close()}}function KT(A,Q,B,J=B,Y=B,Z){let X=em(A??yBA);return kD(Q,X-B.length,{hard:!0,trim:!1}).split(` `).map(($,G,K)=>{let W=Z?Z($,G):$;return G===0?`${J}${W}`:G===K.length-1?`${Y}${W}`:`${B}${W}`}).join(` `)}function LIA(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 mF{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=MIA,output:J=yBA,render:Y,signal:Z,...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=Y.bind(this),this._track=Q,this._abortSignal=Z,this.input=B,this.output=J}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)??[],J=[];for(let Y of B)Y.cb(...Q),Y.once&&J.push(()=>B.splice(B.indexOf(Y),1));for(let Y of J)Y()}prompt(){return new Promise((A)=>{if(this._abortSignal){if(this._abortSignal.aborted)return this.state="cancel",this.close(),A(xBA);this._abortSignal.addEventListener("abort",()=>{this.state="cancel",this.close()},{once:!0})}this.rl=KWQ.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),rm(this.input,!0),this.output.on("resize",this.render),this.render(),this.once("submit",()=>{this.output.write(w7.cursor.show),this.output.off("resize",this.render),rm(this.input,!1),A(this.value)}),this.once("cancel",()=>{this.output.write(w7.cursor.show),this.output.off("resize",this.render),rm(this.input,!1),A(xBA)})})}_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&&x5.aliases.has(Q.name)&&this.emit("cursor",x5.aliases.get(Q.name)),x5.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=LIA(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")}vBA([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(` `),rm(this.input,!1),this.rl?.close(),this.rl=void 0,this.emit(`${this.state}`,this.value),this.unsubscribe()}restoreCursor(){let A=kD(this._prevFrame,process.stdout.columns,{hard:!0,trim:!1}).split(` `).length-1;this.output.write(w7.cursor.move(-999,A*-1))}render(){let A=kD(this._render(this)??"",process.stdout.columns,{hard:!0,trim:!1});if(A!==this._prevFrame){if(this.state==="initial")this.output.write(w7.cursor.hide);else{let Q=FWQ(this._prevFrame,A),B=gBA(this.output);if(this.restoreCursor(),Q){let J=Math.max(0,Q.numLinesAfter-B),Y=Math.max(0,Q.numLinesBefore-B),Z=Q.lines.find((X)=>X>=J);if(Z===void 0){this._prevFrame=A;return}if(Q.lines.length===1){this.output.write(w7.cursor.move(0,Z-Y)),this.output.write(w7.erase.lines(1));let X=A.split(` `);this.output.write(X[Z]),this._prevFrame=A,this.output.write(w7.cursor.move(0,X.length-Z-1));return}else if(Q.lines.length>1){if(J<Y)Z=J;else{let $=Z-Y;$>0&&this.output.write(w7.cursor.move(0,$))}this.output.write(w7.erase.down());let X=A.split(` `).slice(Z);this.output.write(X.join(` `)),this._prevFrame=A;return}}this.output.write(w7.erase.down())}this.output.write(A),this.state==="initial"&&(this.state="active"),this._prevFrame=A}}}function DWQ(A,Q){if(A===void 0||Q.length===0)return 0;let B=Q.findIndex((J)=>J.value===A);return B!==-1?B:0}function qWQ(A,Q){return(Q.label??String(Q.value)).toLowerCase().includes(A.toLowerCase())}function UWQ(A,Q){if(Q)return A?Q:Q[0]}function IIA(A){return[...A].map((Q)=>CWQ[Q])}function MWQ(A){let Q=new Intl.DateTimeFormat(A,{year:"numeric",month:"2-digit",day:"2-digit"}).formatToParts(new Date(2000,0,15)),B=[],J="/";for(let Y of Q)Y.type==="literal"?J=Y.value.trim()||Y.value:(Y.type==="year"||Y.type==="month"||Y.type==="day")&&B.push({type:Y.type,len:Y.type==="year"?4:2});return{segments:B,separator:J}}function bBA(A){return Number.parseInt((A||"0").replace(/_/g,"0"),10)||0}function tm(A){return{year:bBA(A.year),month:bBA(A.month),day:bBA(A.day)}}function fBA(A,Q){return new Date(A||2001,Q||1,0).getDate()}function NIA(A){let{year:Q,month:B,day:J}=tm(A);if(!Q||Q<0||Q>9999||!B||B<1||B>12||!J||J<1)return;let Y=new Date(Date.UTC(Q,B-1,J));if(!(Y.getUTCFullYear()!==Q||Y.getUTCMonth()!==B-1||Y.getUTCDate()!==J))return{year:Q,month:B,day:J}}function CIA(A){let Q=NIA(A);return Q?new Date(Date.UTC(Q.year,Q.month-1,Q.day)):void 0}function OWQ(A,Q,B,J){let Y=B?{year:B.getUTCFullYear(),month:B.getUTCMonth()+1,day:B.getUTCDate()}:null,Z=J?{year:J.getUTCFullYear(),month:J.getUTCMonth()+1,day:J.getUTCDate()}:null;return A==="year"?{min:Y?.year??1,max:Z?.year??9999}:A==="month"?{min:Y&&Q.year===Y.year?Y.month:1,max:Z&&Q.year===Z.year?Z.month:12}:{min:Y&&Q.year===Y.year&&Q.month===Y.month?Y.day:1,max:Z&&Q.year===Z.year&&Q.month===Z.month?Z.day:fBA(Q.year,Q.month)}}var w7,WWQ,HWQ,x5,zWQ,xBA,em=(A)=>("columns"in A)&&typeof A.columns=="number"?A.columns:80,gBA=(A)=>("rows"in A)&&typeof A.rows=="number"?A.rows:20,IWQ,hBA,CWQ,VIA,LWQ,NWQ,EIA,RIA,jIA,mBA;var uBA=SA(()=>{_BA();w7=eA(kBA(),1);WWQ=["up","down","left","right","space","enter","cancel"],HWQ=["January","February","March","April","May","June","July","August","September","October","November","December"],x5={actions:new Set(WWQ),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:[...HWQ],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)}`}}};zWQ=globalThis.process.platform.startsWith("win"),xBA=Symbol("clack:cancel");IWQ=class extends mF{filteredOptions;multiple;isNavigating=!1;selectedValues=[];focusedValue;#A=0;#Q="";#B;#J;#Y;get cursor(){return this.#A}get userInputWithCursor(){if(!this.userInput)return jN(["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,this.cursor+1),J=this.userInput.slice(this.cursor+1);return`${Q}${jN("inverse",B)}${J}`}get options(){return typeof this.#J=="function"?this.#J():this.#J}constructor(Q){super(Q),this.#J=Q.options,this.#Y=Q.placeholder;let B=this.options;this.filteredOptions=[...B],this.multiple=Q.multiple===!0,this.#B=typeof Q.options=="function"?Q.filter:Q.filter??qWQ;let J;if(Q.initialValue&&Array.isArray(Q.initialValue)?this.multiple?J=Q.initialValue:J=Q.initialValue.slice(0,1):!this.multiple&&this.options.length>0&&(J=[this.options[0]?.value]),J)for(let Y of J){let Z=B.findIndex((X)=>X.value===Y);Z!==-1&&(this.toggleSelected(Y),this.#A=Z)}this.focusedValue=this.options[this.#A]?.value,this.on("key",(Y,Z)=>this.#Z(Y,Z)),this.on("userInput",(Y)=>this.#X(Y))}_isActionKey(Q,B){return Q==="\t"||this.multiple&&this.isNavigating&&B.name==="space"&&Q!==void 0&&Q!==""}#Z(Q,B){let J=B.name==="up",Y=B.name==="down",Z=B.name==="return",X=this.userInput===""||this.userInput==="\t",$=this.#Y,G=this.options,K=$!==void 0&&$!==""&&G.some((W)=>!W.disabled&&(this.#B?this.#B($,W):!0));if(B.name==="tab"&&X&&K){this.userInput==="\t"&&this._clearUserInput(),this._setUserInput($,!0),this.isNavigating=!1;return}J||Y?(this.#A=RN(this.#A,J?-1:1,this.filteredOptions),this.focusedValue=this.filteredOptions[this.#A]?.value,this.multiple||(this.selectedValues=[this.focusedValue]),this.isNavigating=!0):Z?this.value=UWQ(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((Z)=>this.#B?.(Q,Z)):this.filteredOptions=[...B];let J=DWQ(this.focusedValue,this.filteredOptions);this.#A=RN(J,0,this.filteredOptions);let Y=this.filteredOptions[this.#A];Y&&!Y.disabled?this.focusedValue=Y.value:this.focusedValue=void 0,this.multiple||(this.focusedValue!==void 0?this.toggleSelected(this.focusedValue):this.deselectAll())}}};hBA=class hBA extends mF{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(w7.cursor.move(0,-1)),this.value=Q,this.state="submit",this.close()}),this.on("cursor",()=>{this.value=!this.value})}};CWQ={Y:{type:"year",len:4},M:{type:"month",len:2},D:{type:"day",len:2}};VIA=class VIA extends mF{#A;#Q;#B;#J;#Y;#Z={segmentIndex:0,positionInSegment:0};#X=!0;#$=null;inlineError="";get segmentCursor(){return{...this.#Z}}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)}#W(){this._setUserInput(this.#K(this.#B)),this._setValue(CIA(this.#B)??void 0)}constructor(A){let Q=A.format?{segments:IIA(A.format),separator:A.separator??"/"}:MWQ(A.locale),B=A.separator??Q.separator,J=A.format?IIA(A.format):Q.segments,Y=A.initialValue??A.defaultValue,Z=Y?{year:String(Y.getUTCFullYear()).padStart(4,"0"),month:String(Y.getUTCMonth()+1).padStart(2,"0"),day:String(Y.getUTCDate()).padStart(2,"0")}:{year:"____",month:"__",day:"__"},X=J.map(($)=>Z[$.type]).join(B);super({...A,initialUserInput:X},!1),this.#A=J,this.#Q=B,this.#B=Z,this.#J=A.minDate,this.#Y=A.maxDate,this.#W(),this.on("cursor",($)=>this.#D($)),this.on("key",($,G)=>this.#q($,G)),this.on("finalize",()=>this.#U(A))}#H(){let A=Math.max(0,Math.min(this.#Z.segmentIndex,this.#A.length-1)),Q=this.#A[A];if(Q)return this.#Z.positionInSegment=Math.max(0,Math.min(this.#Z.positionInSegment,Q.len-1)),{segment:Q,index:A}}#F(A){this.inlineError="",this.#$=null;let Q=this.#H();Q&&(this.#Z.segmentIndex=Math.max(0,Math.min(this.#A.length-1,Q.index+A)),this.#Z.positionInSegment=0,this.#X=!0)}#G(A){let Q=this.#H();if(!Q)return;let{segment:B}=Q,J=this.#B[B.type],Y=!J||J.replace(/_/g,"")==="",Z=Number.parseInt((J||"0").replace(/_/g,"0"),10)||0,X=OWQ(B.type,tm(this.#B),this.#J,this.#Y),$;Y?$=A===1?X.min:X.max:$=Math.max(Math.min(X.max,Z+A),X.min),this.#B={...this.#B,[B.type]:$.toString().padStart(B.len,"0")},this.#X=!0,this.#$=null,this.#W()}#D(A){if(A)switch(A){case"right":return this.#F(1);case"left":return this.#F(-1);case"up":return this.#G(1);case"down":return this.#G(-1)}}#q(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.#F(-1);return}this.#B[B.segment.type]="_".repeat(B.segment.len),this.#X=!0,this.#Z.positionInSegment=0,this.#W();return}if(Q?.name==="tab"){this.inlineError="";let B=this.#H();if(!B)return;let J=Q.shift?-1:1,Y=B.index+J;Y>=0&&Y<this.#A.length&&(this.#Z.segmentIndex=Y,this.#Z.positionInSegment=0,this.#X=!0);return}if(A&&/^[0-9]$/.test(A)){let B=this.#H();if(!B)return;let{segment:J}=B,Y=!this.#B[J.type].replace(/_/g,"");if(this.#X&&this.#$!==null&&!Y){let D=this.#$+A,U={...this.#B,[J.type]:D},q=this.#z(U,J);if(q){this.inlineError=q,this.#$=null,this.#X=!1;return}this.inlineError="",this.#B[J.type]=D,this.#$=null,this.#X=!1,this.#W(),B.index<this.#A.length-1&&(this.#Z.segmentIndex=B.index+1,this.#Z.positionInSegment=0,this.#X=!0);return}this.#X&&!Y&&(this.#B[J.type]="_".repeat(J.len),this.#Z.positionInSegment=0),this.#X=!1,this.#$=null;let Z=this.#B[J.type],X=Z.indexOf("_"),$=X>=0?X:Math.min(this.#Z.positionInSegment,J.len-1);if($<0||$>=J.len)return;let G=Z.slice(0,$)+A+Z.slice($+1),K=!1;if($===0&&Z==="__"&&(J.type==="month"||J.type==="day")){let D=Number.parseInt(A,10);G=`0${A}`,K=D<=(J.type==="month"?1:2)}if(J.type==="year"&&(G=(Z.replace(/_/g,"")+A).padStart(J.len,"_")),!G.includes("_")){let D={...this.#B,[J.type]:G},U=this.#z(D,J);if(U){this.inlineError=U;return}}this.inlineError="",this.#B[J.type]=G;let W=G.includes("_")?void 0:NIA(this.#B);if(W){let{year:D,month:U}=W,q=fBA(D,U);this.#B={year:String(Math.max(0,Math.min(9999,D))).padStart(4,"0"),month:String(Math.max(1,Math.min(12,U))).padStart(2,"0"),day:String(Math.max(1,Math.min(q,W.day))).padStart(2,"0")}}this.#W();let F=G.indexOf("_");K?(this.#X=!0,this.#$=A):F>=0?this.#Z.positionInSegment=F:X>=0&&B.index<this.#A.length-1?(this.#Z.segmentIndex=B.index+1,this.#Z.positionInSegment=0,this.#X=!0):this.#Z.positionInSegment=Math.min($+1,J.len-1)}}#z(A,Q){let{month:B,day:J}=tm(A);if(Q.type==="month"&&(B<0||B>12))return x5.date.messages.invalidMonth;if(Q.type==="day"&&(J<0||J>31))return x5.date.messages.invalidDay(31,"any month")}#U(A){let{year:Q,month:B,day:J}=tm(this.#B);if(Q&&B&&J){let Y=fBA(Q,B);this.#B={...this.#B,day:String(Math.min(J,Y)).padStart(2,"0")}}this.value=CIA(this.#B)??A.defaultValue??void 0}};LWQ=class extends mF{options;cursor=0;#A;getGroupItems(Q){return this.options.filter((B)=>B.group===Q)}isGroupSelected(Q){let B=this.getGroupItems(Q),J=this.value;return J===void 0?!1:B.every((Y)=>J.includes(Y.value))}toggleValue(){let Q=this.options[this.cursor];if(Q!==void 0)if(this.value===void 0&&(this.value=[]),Q.group===!0){let B=Q.value,J=this.getGroupItems(B);this.isGroupSelected(B)?this.value=this.value.filter((Y)=>J.findIndex((Z)=>Z.value===Y)===-1):this.value=[...this.value,...J.map((Y)=>Y.value)],this.value=Array.from(new Set(this.value))}else{let B=this.value.includes(Q.value);this.value=B?this.value.filter((J)=>J!==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,Y])=>[{value:J,group:!0,label:J},...Y.map((Z)=>({...Z,group:J}))]),this.value=[...Q.initialValues??[]],this.cursor=Math.max(this.options.findIndex(({value:J})=>J===Q.cursorAt),this.#A?0:1),this.on("cursor",(J)=>{switch(J){case"left":case"up":{this.cursor=this.cursor===0?this.options.length-1:this.cursor-1;let Y=this.options[this.cursor]?.group===!0;!this.#A&&Y&&(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 Y=this.options[this.cursor]?.group===!0;!this.#A&&Y&&(this.cursor=this.cursor===this.options.length-1?0:this.cursor+1);break}case"space":this.toggleValue();break}})}},NWQ=new Set(["up","down","left","right"]);EIA=class EIA extends mF{#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.slice(this.cursor,this.cursor+1),J=A.slice(this.cursor+1);return B===` `?`${Q}█ ${J}`:`${Q}${jN("inverse",B)}${J}`}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))}#J(A){let Q=this.value??"";switch(A){case"up":this._cursor=sm(this._cursor,0,-1,Q);return;case"down":this._cursor=sm(this._cursor,0,1,Q);return;case"left":this._cursor=sm(this._cursor,-1,0,Q);return;case"right":this._cursor=sm(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.cursor===this.userInput.length?(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){let Q=A.initialUserInput??A.initialValue;super({...A,initialUserInput:Q},!1),Q!==void 0&&(this._cursor=Q.length),this.#Q=A.showSubmit??!1,this.on("key",(B,J)=>{if(J?.name&&NWQ.has(J.name)){this.#A=!1,this.#J(J.name);return}if(B==="\t"&&this.#Q){this.focused=this.focused==="editor"?"submit":"editor";return}if(J?.name!=="return"){if(this.#A=!1,J?.name==="backspace"&&this.cursor>0){this._setUserInput(this.userInput.slice(0,this.cursor-1)+this.userInput.slice(this.cursor)),this._cursor--;return}if(J?.name==="delete"&&this.cursor<this.userInput.length){this._setUserInput(this.userInput.slice(0,this.cursor)+this.userInput.slice(this.cursor+1));return}B&&(this.#Q&&this.focused==="submit"&&(this.focused="editor"),this.#B(B??""),this._cursor++)}}),this.on("userInput",(B)=>{this._setValue(B)}),this.on("finalize",()=>{this.value||(this.value=A.defaultValue),this.value===void 0&&(this.value="")})}};RIA=class extends mF{_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 Q=this.userInput;if(this.cursor>=Q.length)return`${this.masked}${jN(["inverse","hidden"],"_")}`;let B=this.masked,J=B.slice(0,this.cursor),Y=B.slice(this.cursor,this.cursor+1),Z=B.slice(this.cursor+1);return`${J}${jN("inverse",Y)}${Z}`}clear(){this._clearUserInput()}constructor({mask:Q,...B}){super(B),this._mask=Q??"•",this.on("userInput",(J)=>{this._setValue(J)}),this.on("finalize",()=>{this.value===void 0&&(this.value="")})}},jIA=class extends mF{options;cursor=0;get _selectedValue(){return this.options[this.cursor]}changeValue(){let Q=this._selectedValue;this.value=Q===void 0?void 0:Q.value}constructor(Q){super(Q,!1),this.options=Q.options;let B=this.options.findIndex(({value:Y})=>Y===Q.initialValue),J=B===-1?0:B;this.cursor=this.options[J]?.disabled?RN(J,1,this.options):J,this.changeValue(),this.on("cursor",(Y)=>{switch(Y){case"left":case"up":this.cursor=RN(this.cursor,-1,this.options);break;case"down":case"right":this.cursor=RN(this.cursor,1,this.options);break}this.changeValue()})}};mBA=class mBA extends mF{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,this.cursor+1),J=A.slice(this.cursor+1);return`${Q}${jN("inverse",B)}${J}`}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 I0,stripVTControlCharacters as iC0}from"node:util";import dK from"node:process";function VWQ(){if(dK.platform!=="win32")return dK.env.TERM!=="linux";return Boolean(dK.env.CI)||Boolean(dK.env.WT_SESSION)||Boolean(dK.env.TERMINUS_SUBLIME)||dK.env.ConEmuTask==="{cmd::Cmder}"||dK.env.TERM_PROGRAM==="Terminus-Sublime"||dK.env.TERM_PROGRAM==="vscode"||dK.env.TERM==="xterm-256color"||dK.env.TERM==="alacritty"||dK.env.TERMINAL_EMULATOR==="JetBrains-JediTerm"}function bWQ(A,Q){let B=[`${Q?`${I0("cyan",j9)} `:""}${A.join(" • ")}`];return Q&&B.push(I0("cyan",uF)),B}var WT,cBA,EWQ=()=>process.env.CI==="true",I4=(A,Q)=>cBA?A:Q,RWQ,PIA,TIA,lBA,jWQ,j9,uF,sC0,rC0,dBA,Qu,tC0,eC0,AM0,wWQ,QM0,BM0,JM0,YM0,ZM0,XM0,PWQ,TWQ,_WQ,SWQ,Bu=(A)=>{switch(A){case"initial":case"active":return I0("cyan",RWQ);case"cancel":return I0("red",PIA);case"error":return I0("yellow",TIA);case"submit":return I0("green",lBA)}},kWQ=(A)=>{switch(A){case"initial":case"active":return I0("cyan",j9);case"cancel":return I0("red",j9);case"error":return I0("yellow",j9);case"submit":return I0("green",j9)}},wIA=(A,Q,B,J,Y,Z=!1)=>{let X=Q,$=0;if(Z)for(let G=J-1;G>=B;G--){let K=A[G];if(K&&(X-=K.length),$++,X<=Y)break}else for(let G=B;G<J;G++){let K=A[G];if(K&&(X-=K.length),$++,X<=Y)break}return{lineCount:X,removals:$}},xWQ=({cursor:A,options:Q,style:B,output:J=process.stdout,maxItems:Y=Number.POSITIVE_INFINITY,columnPadding:Z=0,rowPadding:X=4})=>{let $=em(J)-Z,G=gBA(J),K=I0("dim","..."),W=Math.max(G-X,0),F=Math.max(Math.min(Y,W),5),D=0;A>=F-3&&(D=Math.max(Math.min(A-F+3,Q.length-F),0));let U=F<Q.length&&D>0,q=F<Q.length&&D+F<Q.length,I=Math.min(D+F,Q.length),C=[],N=0;U&&N++,q&&N++;let V=D+(U?1:0),O=I-(q?1:0);for(let R=V;R<O;R++){let j=Q[R],w=j?B(j,R===A):"",k=kD(w,$,{hard:!0,trim:!1}).split(` `);C.push(k),N+=k.length}if(N>W){let R=0,j=0,w=N,k=A-V,m=W,y=()=>wIA(C,w,0,k,m),g=()=>wIA(C,w,k+1,C.length,m,!0);U?({lineCount:w,removals:R}=y(),w>m&&(q||(m-=1),{lineCount:w,removals:j}=g())):(q||(m-=1),{lineCount:w,removals:j}=g(),w>m&&(m-=1,{lineCount:w,removals:R}=y())),R>0&&(U=!0,C.splice(0,R)),j>0&&(q=!0,C.splice(C.length-j,j))}let L=[];U&&L.push(K);for(let R of C)for(let j of R)L.push(j);return q&&L.push(K),L},B4=(A)=>{let Q=A.active??"Yes",B=A.inactive??"No";return new hBA({active:Q,inactive:B,signal:A.signal,input:A.input,output:A.output,initialValue:A.initialValue??!0,render(){let J=A.withGuide??x5.withGuide,Y=`${Bu(this.state)} `,Z=J?`${I0("gray",j9)} `:"",X=KT(A.output,A.message,Z,Y),$=`${J?`${I0("gray",j9)} `:""}${X} `,G=this.value?Q:B;switch(this.state){case"submit":{let K=J?`${I0("gray",j9)} `:"";return`${$}${K}${I0("dim",G)}`}case"cancel":{let K=J?`${I0("gray",j9)} `:"";return`${$}${K}${I0(["strikethrough","dim"],G)}${J?` ${I0("gray",j9)}`:""}`}default:{let K=J?`${I0("cyan",j9)} `:"",W=J?I0("cyan",uF):"";return`${$}${K}${this.value?`${I0("green",dBA)} ${Q}`:`${I0("dim",Qu)} ${I0("dim",Q)}`}${A.vertical?J?` ${I0("cyan",j9)} `:` `:` ${I0("dim","/")} `}${this.value?`${I0("dim",Qu)} ${I0("dim",B)}`:`${I0("green",dBA)} ${B}`} ${W} `}}}}).prompt()},$M0,_,_IA=(A="",Q)=>{let B=Q?.output??process.stdout,J=Q?.withGuide??x5.withGuide?`${I0("gray",uF)} `:"";B.write(`${J}${I0("red",A)} `)},GB=(A="",Q)=>{let B=Q?.output??process.stdout,J=Q?.withGuide??x5.withGuide?`${I0("gray",jWQ)} `:"";B.write(`${J}${A} `)},KB=(A="",Q)=>{let B=Q?.output??process.stdout,J=Q?.withGuide??x5.withGuide?`${I0("gray",j9)} ${I0("gray",uF)} `:"";B.write(`${J}${A} `)},SIA=(A)=>new RIA({validate:A.validate,mask:A.mask??wWQ,signal:A.signal,input:A.input,output:A.output,render(){let Q=A.withGuide??x5.withGuide,B=`${Q?`${I0("gray",j9)} `:""}${Bu(this.state)} ${A.message} `,J=this.userInputWithCursor,Y=this.masked;switch(this.state){case"error":{let Z=Q?`${I0("yellow",j9)} `:"",X=Q?`${I0("yellow",uF)} `:"",$=Y??"";return A.clearOnError&&this.clear(),`${B.trim()} ${Z}${$} ${X}${I0("yellow",this.error)} `}case"submit":{let Z=Q?`${I0("gray",j9)} `:"",X=Y?I0("dim",Y):"";return`${B}${Z}${X}`}case"cancel":{let Z=Q?`${I0("gray",j9)} `:"",X=Y?I0(["strikethrough","dim"],Y):"";return`${B}${Z}${X}${Y&&Q?` ${I0("gray",j9)}`:""}`}default:{let Z=Q?`${I0("cyan",j9)} `:"",X=Q?I0("cyan",uF):"";return`${B}${Z}${J} ${X} `}}}}).prompt(),fWQ=(A)=>I0("magenta",A),H9=({indicator:A="dots",onCancel:Q,output:B=process.stdout,cancelMessage:J,errorMessage:Y,frames:Z=cBA?["◒","◐","◓","◑"]:["•","o","O","0"],delay:X=cBA?80:120,signal:$,...G}={})=>{let K=EWQ(),W,F,D=!1,U=!1,q="",I,C=performance.now(),N=em(B),V=G?.styleFrame??fWQ,O=(WA)=>{let t=WA>1?Y??x5.messages.error:J??x5.messages.cancel;U=WA===1,D&&(s(t,WA),U&&typeof Q=="function"&&Q())},L=()=>O(2),R=()=>O(1),j=()=>{process.on("uncaughtExceptionMonitor",L),process.on("unhandledRejection",L),process.on("SIGINT",R),process.on("SIGTERM",R),process.on("exit",O),$&&$.addEventListener("abort",R)},w=()=>{process.removeListener("uncaughtExceptionMonitor",L),process.removeListener("unhandledRejection",L),process.removeListener("SIGINT",R),process.removeListener("SIGTERM",R),process.removeListener("exit",O),$&&$.removeEventListener("abort",R)},k=()=>{if(I===void 0)return;K&&B.write(` `);let WA=kD(I,N,{hard:!0,trim:!1}).split(` `);WA.length>1&&B.write(WT.cursor.up(WA.length-1)),B.write(WT.cursor.to(0)),B.write(WT.erase.down())},m=(WA)=>WA.replace(/\.+$/,""),y=(WA)=>{let t=(performance.now()-WA)/1000,p=Math.floor(t/60),u=Math.floor(t%60);return p>0?`[${p}m ${u}s]`:`[${u}s]`},g=G.withGuide??x5.withGuide,l=(WA="")=>{D=!0,W=OIA({output:B}),q=m(WA),C=performance.now(),g&&B.write(`${I0("gray",j9)} `);let t=0,p=0;j(),F=setInterval(()=>{if(K&&q===I)return;k(),I=q;let u=V(Z[t]),x;if(K)x=`${u} ${q}...`;else if(A==="timer")x=`${u} ${q} ${y(C)}`;else{let b=".".repeat(Math.floor(p)).slice(0,3);x=`${u} ${q}${b}`}let d=kD(x,N,{hard:!0,trim:!1});B.write(d),t=t+1<Z.length?t+1:0,p=p<4?p+0.125:0},X)},s=(WA="",t=0,p=!1)=>{if(!D)return;D=!1,clearInterval(F),k();let u=t===0?I0("green",lBA):t===1?I0("red",PIA):I0("red",TIA);q=WA??q,p||(A==="timer"?B.write(`${u} ${q} ${y(C)} `):B.write(`${u} ${q} `)),w(),W()};return{start:l,stop:(WA="")=>s(WA,0),message:(WA="")=>{q=m(WA??q)},cancel:(WA="")=>s(WA,1),error:(WA="")=>s(WA,2),clear:()=>s("",0,!0),get isCancelled(){return U}}},GM0,yWQ,Au=(A,Q)=>A.includes(` `)?A.split(` `).map((B)=>Q(B)).join(` `):Q(A),$5=(A)=>{let Q=(J,Y)=>{if(J===void 0)return"";let Z=J.label??String(J.value);switch(Y){case"disabled":return`${I0("gray",Qu)} ${Au(Z,(X)=>I0("gray",X))}${J.hint?` ${I0("dim",`(${J.hint??"disabled"})`)}`:""}`;case"selected":return`${Au(Z,(X)=>I0("dim",X))}`;case"active":return`${I0("green",dBA)} ${Z}${J.hint?` ${I0("dim",`(${J.hint})`)}`:""}`;case"cancelled":return`${Au(Z,(X)=>I0(["strikethrough","dim"],X))}`;default:return`${I0("dim",Qu)} ${Au(Z,(X)=>I0("dim",X))}`}},B=A.showInstructions??!0;return new jIA({options:A.options,signal:A.signal,input:A.input,output:A.output,initialValue:A.initialValue,render(){let J=A.withGuide??x5.withGuide,Y=`${Bu(this.state)} `,Z=`${kWQ(this.state)} `,X=KT(A.output,A.message,Z,Y),$=`${J?`${I0("gray",j9)} `:""}${X} `;switch(this.state){case"submit":{let G=J?`${I0("gray",j9)} `:"",K=KT(A.output,Q(this.options[this.cursor],"selected"),G);return`${$}${K}`}case"cancel":{let G=J?`${I0("gray",j9)} `:"",K=KT(A.output,Q(this.options[this.cursor],"cancelled"),G);return`${$}${K}${J?` ${I0("gray",j9)}`:""}`}default:{let G=J?`${I0("cyan",j9)} `:"",K=$.split(` `).length,W=B?bWQ(yWQ,J):J?[I0("cyan",uF)]:[],F=W.join(` `),D=W.length+1;return`${$}${G}${xWQ({output:A.output,cursor:this.cursor,options:this.options,maxItems:A.maxItems,columnPadding:G.length,rowPadding:K+D,style:(U,q)=>Q(U,U.disabled?"disabled":q?"active":"inactive")}).join(` ${G}`)} ${F} `}}}}).prompt()},KM0,xD=(A)=>new mBA({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??x5.withGuide,B=`${`${Q?`${I0("gray",j9)} `:""}${Bu(this.state)} `}${A.message} `,J=A.placeholder&&A.placeholder.length>0?I0("inverse",A.placeholder[0])+I0("dim",A.placeholder.slice(1)):I0(["inverse","hidden"],"_"),Y=this.userInput?this.userInputWithCursor:J,Z=this.value??"";switch(this.state){case"error":{let X=this.error?` ${I0("yellow",this.error)}`:"",$=Q?`${I0("yellow",j9)} `:"",G=Q?I0("yellow",uF):"";return`${B.trim()} ${$}${Y} ${G}${X} `}case"submit":{let X=Z?` ${I0("dim",Z)}`:"",$=Q?I0("gray",j9):"";return`${B}${$}${X}`}case"cancel":{let X=Z?` ${I0(["strikethrough","dim"],Z)}`:"",$=Q?I0("gray",j9):"";return`${B}${$}${X}${Z.trim()?` ${$}`:""}`}default:{let X=Q?`${I0("cyan",j9)} `:"",$=Q?I0("cyan",uF):"";return`${B}${X}${Y} ${$} `}}}}).prompt();var hB=SA(()=>{uBA();uBA();_BA();jBA();WT=eA(kBA(),1);cBA=VWQ(),RWQ=I4("◆","*"),PIA=I4("■","x"),TIA=I4("▲","x"),lBA=I4("◇","o"),jWQ=I4("┌","T"),j9=I4("│","|"),uF=I4("└","—"),sC0=I4("┐","T"),rC0=I4("┘","—"),dBA=I4("●",">"),Qu=I4("○"," "),tC0=I4("◻","[•]"),eC0=I4("◼","[+]"),AM0=I4("◻","[ ]"),wWQ=I4("▪","•"),QM0=I4("─","-"),BM0=I4("╮","+"),JM0=I4("├","+"),YM0=I4("╯","+"),ZM0=I4("╰","+"),XM0=I4("╭","+"),PWQ=I4("●","•"),TWQ=I4("◆","*"),_WQ=I4("▲","!"),SWQ=I4("■","x");$M0=[`${I0("dim","↑/↓")} to navigate`,`${I0("dim","Space:")} select`,`${I0("dim","Enter:")} confirm`],_={message:(A=[],{symbol:Q=I0("gray",j9),secondarySymbol:B=I0("gray",j9),output:J=process.stdout,spacing:Y=1,withGuide:Z}={})=>{let X=[],$=Z??x5.withGuide,G=$?B:"",K=$?`${Q} `:"",W=$?`${B} `:"";for(let D=0;D<Y;D++)X.push(G);let F=Array.isArray(A)?A:A.split(` `);if(F.length>0){let[D,...U]=F;D.length>0?X.push(`${K}${D}`):X.push($?Q:"");for(let q of U)q.length>0?X.push(`${W}${q}`):X.push($?B:"")}J.write(`${X.join(` `)} `)},info:(A,Q)=>{_.message(A,{...Q,symbol:I0("blue",PWQ)})},success:(A,Q)=>{_.message(A,{...Q,symbol:I0("green",TWQ)})},step:(A,Q)=>{_.message(A,{...Q,symbol:I0("green",lBA)})},warn:(A,Q)=>{_.message(A,{...Q,symbol:I0("yellow",_WQ)})},warning:(A,Q)=>{_.warn(A,Q)},error:(A,Q)=>{_.message(A,{...Q,symbol:I0("red",SWQ)})}},GM0={light:I4("─","-"),heavy:I4("━","="),block:I4("█","#")},yWQ=[`${I0("dim","↑/↓")} to navigate`,`${I0("dim","Enter:")} confirm`],KM0=`${I0("gray",j9)} `});var w4;var qG=SA(()=>{w4={name:"@capgo/cli",type:"module",version:"8.29.1",description:"A CLI to upload to capgo servers",author:"Martin martin@capgo.app",license:"Apache 2.0",homepage:"https://github.com/Cap-go/capgo/tree/main/cli#readme",repository:{type:"git",url:"git+https://github.com/Cap-go/capgo.git",directory:"cli"},bugs:{url:"https://github.com/Cap-go/capgo/issues"},keywords:["appflow alternative","ionic","capacitor","auto update","live update","capgo","cli","upload","capgo-cli","sdk","tanstack-intent"],exports:{".":{import:"./dist/index.js",require:"./dist/index.js"},"./sdk":{types:"./dist/src/sdk.d.ts",import:"./dist/src/sdk.js"}},main:"dist/index.js",types:"dist/src/index.d.ts",bin:{capgo:"dist/index.js"},files:["!skills/_artifacts","dist","skills"],engines:{npm:">=8.0.0",node:">=20.0.0"},scripts:{build:"tsc && bun build.mjs",dev:"NODE_ENV=development ncc build","no-debug":"node dist/index.js","dev-build":"SUPA_DB=development ncc build",pack:"pkg",types:"bunx --bun supabase gen types typescript --project-id=xvwzpoazmxkqosrdewyv > src/types/supabase.types.ts",typecheck:"tsgo --project tsconfig.tsgo.json --noEmit",lint:"bun run lint:ox","lint:ox":"oxlint --config ../.oxlintrc.json src","lint:fix":"oxlint --config ../.oxlintrc.json --fix src","check-posix-paths":"node test/check-posix-paths.js","generate-docs":"node dist/index.js generate-docs README.md","test:bundle":"bun test/test-bundle.mjs","test:prescan":"bun test test/prescan/","test:functional":"bun test/test-functional.mjs","test:semver":"bun test/test-semver-validation.mjs","test:version-edge-cases":"bun test/test-version-validation.mjs","test:regex":"bun test/test-regex-validation.mjs","test:upload":"bun test/test-upload-validation.mjs","test:fail-on-incompatible":"bun test/test-fail-on-incompatible.mjs","test:native-dependencies":"bun test/test-native-dependencies.mjs","test:credentials":"bun test/test-credentials.mjs","test:asc-key-protocol":"bun test/test-asc-key-protocol.mjs","test:credentials-validation":"bun test/test-credentials-validation.mjs","test:android-service-account-validation":"bun test/test-android-service-account-validation.mjs","test:build-zip-filter":"bun test/test-build-zip-filter.mjs","test:checksum":"bun test/test-checksum-algorithm.mjs","test:build-needed":"bun test/test-build-needed.mjs","test:ci-prompts":"bun test/test-ci-prompts.mjs","test:ci-secrets":"bun test/test-ci-secrets.mjs","test:android-onboarding-progress":"bun test/test-android-onboarding-progress.mjs","test:onboarding-telemetry":"bun test/test-onboarding-telemetry.mjs","test:v2-event-migration":"bun test/test-v2-event-migration.mjs","test:analytics":"bun test/test-analytics.mjs","test:analytics-error-category":"bun test/test-analytics-error-category.mjs","test:analytics-org-resolver":"bun test/test-analytics-org-resolver.mjs","test:supabase-perf":"bun test/test-supabase-perf.mjs","test:preview-qr":"bun test/test-preview-qr.mjs","test:mcp-analytics":"bun test/test-mcp-analytics.mjs","test:mcp-instructions":"bun test/test-mcp-instructions.mjs","test:mcp-stdout-guard":"bun test/test-mcp-stdout-guard.mjs","test:mcp-platform-select":"bun test/test-mcp-platform-select.mjs","test:mcp-explain-scopes":"bun test/test-mcp-explain-scopes.mjs","test:mcp-oauth-reopen":"bun test/test-mcp-oauth-reopen.mjs","test:mcp-broker-oauth":"bun test/test-mcp-broker-oauth.mjs","test:mcp-broker-session":"bun test/test-mcp-broker-session.mjs","test:mcp-credentials-manage":"bun test/test-mcp-credentials-manage.mjs","test:mcp-resume-prompt":"bun test/test-mcp-resume-prompt.mjs","test:mcp-build-job":"bun test/test-mcp-build-job.mjs","test:mcp-build-tools":"bun test/test-mcp-build-tools.mjs","test:app-created-source":"bun test/test-app-created-source.mjs","test:doctor-analytics":"bun test/test-doctor-analytics.mjs","test:posthog-exception":"bun test/test-posthog-exception.mjs","test:onboarding-recovery":"bun test/test-onboarding-recovery.mjs","test:onboarding-progress":"bun test/test-onboarding-progress.mjs","test:onboarding-run-targets":"bun test/test-onboarding-run-targets.mjs","test:run-device-command":"bun test/test-run-device-command.mjs","test:init-app-conflict":"bun test/test-init-app-conflict.mjs","test:init-guardrails":"bun test/test-init-guardrails.mjs","test:init-replay":"bun test/test-init-replay.mjs","test:capacitor-config-target":"bun test/test-capacitor-config-target.mjs","test:init-monorepo-targeting":"bun run test:capacitor-config-target && bun test/test-init-monorepo-targeting.mjs","test:prompt-preferences":"bun test/test-prompt-preferences.mjs","test:esm-sdk":"node test/test-sdk-esm.mjs","test:auth-session":"bun test/test-auth-session.mjs","test:mcp":"node test/test-mcp.mjs","test:mcp-no-key-handshake":"node test/test-mcp-no-key-handshake.mjs","test:version-detection":"node test/test-get-installed-version.mjs","test:version-detection:setup":"./test/fixtures/setup-test-projects.sh","test:platform-paths":"bun test/test-platform-paths.mjs","test:project-type-detection":"bun test/test-project-type-detection.mjs","test:payload-split":"bun test/test-payload-split.mjs","test:macos-signing":"bun test/test-macos-signing.mjs","test:helper-dce":"bash scripts/check-helper-dce.sh","test:apple-api-import-helpers":"bun test/test-apple-api-import-helpers.mjs","test:apple-api-verify-key":"bun test/test-apple-api-verify-key.mjs","test:bundle-id-detector":"bun test/test-bundle-id-detector.mjs","test:apple-api-app-list":"bun test/test-apple-api-app-list.mjs","test:apple-api-cert-create":"bun test/test-apple-api-cert-create.mjs","test:app-verification":"bun test/test-app-verification.mjs","test:pbxproj-parser":"bun test/test-pbxproj-parser.mjs","test:manifest-path-encoding":"bun test/test-manifest-path-encoding.mjs","test:self-update":"bun test/test-self-update.mjs","test:update-prompt":"bun test/test-update-prompt.mjs","test:android-tail-engine":"bun test/test-android-tail-engine.mjs","test:android-tail-render":"bun test/test-android-tail-render.mjs","test:android-tail-routing":"bun test/test-android-tail-routing.mjs","test:dev-gate-stripped":"bun test/test-dev-gate-stripped.mjs","test:frame-fit-ios-shared":"bun test/test-frame-fit-ios-shared.mjs","test:ios-confirm-app-id":"bun test/test-ios-confirm-app-id.mjs","test:ios-create-new":"bun test/test-ios-create-new.mjs","test:ios-e2e":"bun test/test-ios-e2e.mjs","test:ios-flow-contract":"bun test/test-ios-flow-contract.mjs","test:ios-import-discovery":"bun test/test-ios-import-discovery.mjs","test:ios-import-export":"bun test/test-ios-import-export.mjs","test:ios-import-pickers":"bun test/test-ios-import-pickers.mjs","test:ios-import-recovery":"bun test/test-ios-import-recovery.mjs","test:ios-recovery":"bun test/test-ios-recovery.mjs","test:ios-resume":"bun test/test-ios-resume.mjs","test:ios-tail-handoff":"bun test/test-ios-tail-handoff.mjs","test:ios-tui-render":"bun test/test-ios-tui-render.mjs","test:p8-error":"bun test/test-p8-error.mjs","test:ios-tui-routing":"bun test/test-ios-tui-routing.mjs","test:ios-updater-sync-validation":"bun test/test-ios-updater-sync-validation.mjs","test:ios-verify-app":"bun test/test-ios-verify-app.mjs","test:ios-marketing-version":"bun test/test-ios-marketing-version.mjs","test:platform-flow-contract":"bun test/test-platform-flow-contract.mjs","test:tail-engine-shared":"bun test/test-tail-engine-shared.mjs",test:"bun run build && bun run test:helper-dce && bun run test:version-detection:setup && bun run test:bundle && bun run test:functional && bun run test:semver && bun run test:version-edge-cases && bun run test:regex && bun run test:upload && bun run test:fail-on-incompatible && bun run test:native-dependencies && bun run test:credentials && bun run test:credentials-validation && bun run test:android-service-account-validation && bun run test:build-zip-filter && bun run test:checksum && bun run test:build-needed && bun run test:ci-prompts && bun run test:ci-secrets && bun run test:android-onboarding-progress && bun run test:onboarding-telemetry && bun run test:v2-event-migration && bun run test:analytics && bun run test:analytics-error-category && bun run test:analytics-org-resolver && bun run test:supabase-perf && bun run test:preview-qr && bun run test:app-set-options && bun run test:mcp-analytics && bun run test:mcp-instructions && bun run test:mcp-live-update-onboarding && bun run test:mcp-stdout-guard && bun run test:mcp-platform-select && bun run test:mcp-explain-scopes && bun run test:mcp-oauth-reopen && bun run test:mcp-broker-oauth && bun run test:mcp-broker-session && bun run test:mcp-credentials-manage && bun run test:mcp-resume-prompt && bun run test:mcp-build-job && bun run test:mcp-build-tools && bun run test:app-created-source && bun run test:doctor-analytics && bun run test:posthog-exception && bun run test:build-platform-selection && bun run test:onboarding-recovery && bun run test:onboarding-progress && bun run test:onboarding-run-targets && bun run test:run-device-command && bun run test:init-monorepo-targeting && bun run test:init-app-conflict && bun run test:init-guardrails && bun run test:init-replay && bun run test:prompt-preferences && bun run test:esm-sdk && bun run test:mcp && bun run test:mcp-no-key-handshake && bun run test:auth-session && bun run test:version-detection && bun run test:platform-paths && bun run test:project-type-detection && bun run test:payload-split && bun run test:manifest-path-encoding && bun run test:macos-signing && bun run test:asc-key-protocol && bun run test:apple-api-import-helpers && bun run test:apple-api-verify-key && bun run test:bundle-id-detector && bun run test:apple-api-app-list && bun run test:app-verification && bun run test:pbxproj-parser && bun run test:ai-log-capture && bun run test:ai-analyze-flow && bun run test:cicd-failure-help && bun run test:ai-sse-parser && bun run test:ai-render-markdown && bun run test:ai-stream-markdown && bun run test:ai-onboarding-mode && bun run test:ai-fit && bun run test:platform-layout && bun run test:frame-fit && bun run test:onboarding-min-size && bun run test:min-size-gate && bun run test:shell-size-gate && bun run test:build-log-sanitize && bun run test:build-output-viewport && bun run test:diff-viewer-viewport && bun run test:build-complete-exit && bun run test:ai-analyze-stream && bun run test:support-mailto && bun run test:support-redact && bun run test:support-internal-log && bun run test:support-help-menu && bun run test:support-contact && bun run test:support-upload-prompt && bun run test:support-bundle-files && bun run test:self-update && bun run test:update-prompt && bun run test:apple-api-cert-create && bun run test:android-tail-engine && bun run test:android-tail-render && bun run test:android-tail-routing && bun run test:dev-gate-stripped && bun run test:frame-fit-ios-shared && bun run test:ios-confirm-app-id && bun run test:ios-create-new && bun run test:ios-e2e && bun run test:ios-flow-contract && bun run test:ios-import-discovery && bun run test:ios-import-export && bun run test:ios-import-pickers && bun run test:ios-import-recovery && bun run test:ios-recovery && bun run test:ios-resume && bun run test:ios-tail-handoff && bun run test:ios-tui-render && bun run te