UNPKG

@capgo/cli

Version:
70 lines (68 loc) 4.65 MB
#!/usr/bin/env node import{createRequire as WWQ}from"node:module";var $WQ=Object.create;var{getPrototypeOf:JWQ,defineProperty:rP,getOwnPropertyNames:uCA,getOwnPropertyDescriptor:YWQ}=Object,mCA=Object.prototype.hasOwnProperty;function cCA(A){return this[A]}var ZWQ,XWQ,AQ=(A,Q,B)=>{var $=A!=null&&typeof A==="object";if($){var J=Q?ZWQ??=new WeakMap:XWQ??=new WeakMap,Y=J.get(A);if(Y)return Y}B=A!=null?$WQ(JWQ(A)):{};let Z=Q||!A||!A.__esModule?rP(B,"default",{value:A,enumerable:!0}):B;for(let X of uCA(A))if(!mCA.call(Z,X))rP(Z,X,{get:cCA.bind(A,X),enumerable:!0});if($)J.set(A,Z);return Z},PK=(A)=>{var Q=(hCA??=new WeakMap).get(A),B;if(Q)return Q;if(Q=rP({},"__esModule",{value:!0}),A&&typeof A==="object"||typeof A==="function"){for(var $ of uCA(A))if(!mCA.call(Q,$))rP(Q,$,{get:cCA.bind(A,$),enumerable:!(B=YWQ(A,$))||B.enumerable})}return hCA.set(A,Q),Q},hCA,DA=(A,Q)=>()=>(Q||A((Q={exports:{}}).exports,Q),Q.exports);var GWQ=(A)=>A;function KWQ(A,Q){this[A]=GWQ.bind(null,Q)}var $J=(A,Q)=>{for(var B in Q)rP(A,B,{get:Q[B],enumerable:!0,configurable:!0,set:KWQ.bind(Q,B)})};var uA=(A,Q)=>()=>(A&&(Q=A(A=0)),Q);var VQ=WWQ(import.meta.url);var dCA,lCA=(A)=>{return A===12288||A>=65281&&A<=65376||A>=65504&&A<=65510},pCA=(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 iCA=uA(()=>{dCA=(()=>{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 HWQ,FWQ,nCA,DWQ,aCA,UWQ,zWQ,qWQ,oCA=(A,Q={},B={})=>{let $=Q.limit??1/0,J=Q.ellipsis??"",Y=Q?.ellipsisWidth??(J?oCA(J,qWQ,B).width:0),Z=0,X=B.controlWidth??0,G=B.tabWidth??8,K=B.emojiWidth??2,W=2,F=B.regularWidth??1,U=B.wideWidth??2,z=[[UWQ,F],[HWQ,0],[FWQ,X],[DWQ,G],[aCA,K],[nCA,U]],q=0,I=0,M=A.length,N=0,V=!1,C=M,L=Math.max(0,$-Y),R=0,j=0,w=0,k=0;A:while(!0){if(j>R||I>=M&&I>q){let u=A.slice(R,j)||A.slice(q,I);N=0;for(let y of u.replaceAll(zWQ,"")){let g=y.codePointAt(0)||0;if(lCA(g))k=2;else if(pCA(g))k=U;else k=F;if(w+k>L)C=Math.min(C,Math.max(R,q)+N);if(w+k>$){V=!0;break A}N+=y.length,w+=k}R=j=0}if(I>=M)break A;for(let u=0,y=z.length;u<y;u++){let[g,c]=z[u];if(g.lastIndex=I,g.test(A)){if(N=g===nCA?dCA(A.slice(I,g.lastIndex)):g===aCA?1:g.lastIndex-I,k=N*c,w+k>L)C=Math.min(C,I+Math.floor((L-w)/c));if(w+k>$){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?C:M,truncated:V,ellipsed:V&&$>=Y}},rCA;var sCA=uA(()=>{iCA();HWQ=/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]|\u001b\]8;[^;]*;.*?(?:\u0007|\u001b\u005c)/y,FWQ=/[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y,nCA=/(?:(?![\uFF61-\uFF9F\uFF00-\uFFEF])[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}\p{Script=Tangut}]){1,1000}/yu,DWQ=/\t{1,1000}/y,aCA=/[\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,UWQ=/(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y,zWQ=/\p{M}+/gu,qWQ={limit:1/0,ellipsis:""},rCA=oCA});var IWQ,MWQ=(A,Q={})=>{return rCA(A,IWQ,Q).width},QH;var Y1A=uA(()=>{sCA();IWQ={limit:1/0,ellipsis:"",ellipsisWidth:0},QH=MWQ});function D2(A,Q,B){return String(A).normalize().split(VWQ).map(($)=>NWQ($,Q,B)).join(` `)}var ku="\x1B",BLA="›",OWQ=39,X1A="\x07",$LA="[",CWQ="]",JLA="m",G1A,tCA,eCA=(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},ALA=(A)=>`${ku}${$LA}${A}${JLA}`,QLA=(A)=>`${ku}${G1A}${A}${X1A}`,Z1A=(A,Q,B)=>{let $=Q[Symbol.iterator](),J=!1,Y=!1,Z=A.at(-1),X=Z===void 0?0:QH(Z),G=$.next(),K=$.next(),W=0;while(!G.done){let F=G.value,U=QH(F);if(X+U<=B)A[A.length-1]+=F;else A.push(F),X=0;if(F===ku||F===BLA)J=!0,Y=Q.startsWith(G1A,W+1);if(J){if(Y){if(F===X1A)J=!1,Y=!1}else if(F===JLA)J=!1}else if(X+=U,X===B&&!K.done)A.push(""),X=0;G=K,K=$.next(),W+=F.length}if(Z=A.at(-1),!X&&Z!==void 0&&Z.length&&A.length>1)A[A.length-2]+=A.pop()},LWQ=(A)=>{let Q=A.split(" "),B=Q.length;while(B){if(QH(Q[B-1]))break;B--}if(B===Q.length)return A;return Q.slice(0,B).join(" ")+Q.slice(B).join("")},NWQ=(A,Q,B={})=>{if(B.trim!==!1&&A.trim()==="")return"";let $="",J,Y,Z=A.split(" "),X=[""],G=0;for(let F=0;F<Z.length;F++){let U=Z[F];if(B.trim!==!1){let q=X.at(-1)??"",I=q.trimStart();if(q.length!==I.length)X[X.length-1]=I,G=QH(I)}if(F!==0){if(G>=Q&&(B.wordWrap===!1||B.trim===!1))X.push(""),G=0;if(G||B.trim===!1)X[X.length-1]+=" ",G++}let z=QH(U);if(B.hard&&z>Q){let q=Q-G,I=1+Math.floor((z-q-1)/Q);if(Math.floor((z-1)/Q)<I)X.push("");Z1A(X,U,Q),G=QH(X.at(-1)??"");continue}if(G+z>Q&&G&&z){if(B.wordWrap===!1&&G<Q){Z1A(X,U,Q),G=QH(X.at(-1)??"");continue}X.push(""),G=0}if(G+z>Q&&B.wordWrap===!1){Z1A(X,U,Q),G=QH(X.at(-1)??"");continue}X[X.length-1]+=U,G+=z}if(B.trim!==!1)X=X.map((F)=>LWQ(F));let K=X.join(` `),W=!1;for(let F=0;F<K.length;F++){let U=K[F];if($+=U,!W){if(W=U>="\uD800"&&U<="\uDBFF",W)continue}else W=!1;if(U===ku||U===BLA){tCA.lastIndex=F+1;let q=tCA.exec(K)?.groups;if(q?.code!==void 0){let I=Number.parseFloat(q.code);J=I===OWQ?void 0:I}else if(q?.uri!==void 0)Y=q.uri.length===0?void 0:q.uri}if(K[F+1]===` `){if(Y)$+=QLA("");let z=J?eCA(J):void 0;if(J&&z)$+=ALA(z)}else if(U===` `){if(J&&eCA(J))$+=ALA(J);if(Y)$+=QLA(Y)}}return $},VWQ;var K1A=uA(()=>{Y1A();G1A=`${CWQ}8;;`,tCA=new RegExp(`(?:\\${$LA}(?<code>\\d+)m|\\${G1A}(?<uri>.*)${X1A})`,"y"),VWQ=/\r?\n/});var H1A=DA((GM0,YLA)=>{var W1A={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"},EWQ={up:(A=1)=>"\x1B[S".repeat(A),down:(A=1)=>"\x1B[T".repeat(A)},RWQ={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?W1A.up():"");if(A)Q+=W1A.left;return Q}};YLA.exports={cursor:W1A,scroll:EWQ,erase:RWQ,beep:"\x07"}});import{styleText as UN}from"node:util";import{stdout as z1A,stdin as KLA}from"node:process";import*as U2 from"node:readline";import jWQ from"node:readline";import{ReadStream as ZLA}from"node:tty";function DN(A,Q,B){if(!B.some((Z)=>!Z.disabled))return A;let $=A+Q,J=Math.max(B.length-1,0),Y=$<0?J:$>J?0:$;return B[Y]?.disabled?DN(Y,Q<0?-1:1,B):Y}function Su(A,Q,B,$){let J=$.split(` `),Y=0,Z=A;for(let G of J){if(Z<=G.length)break;Z-=G.length+1,Y++}for(Y=Math.max(0,Math.min(J.length-1,Y+B)),Z=Math.min(Z,J[Y].length)+Q;Z<0&&Y>0;)Y--,Z+=J[Y].length+1;for(;Z>J[Y].length&&Y<J.length-1;)Z-=J[Y].length+1,Y++;Z=Math.max(0,Math.min(J[Y].length,Z));let X=0;for(let G=0;G<Y;G++)X+=J[G].length+1;return X+Z}function q1A(A,Q){if(typeof A=="string")return wJ.aliases.get(A)===Q;for(let B of A)if(B!==void 0&&q1A(B,Q))return!0;return!1}function _WQ(A,Q){if(A===Q)return;let B=A.split(` `),$=Q.split(` `),J=Math.max(B.length,$.length),Y=[];for(let Z=0;Z<J;Z++)B[Z]!==$[Z]&&Y.push(Z);return{lines:Y,numLinesBefore:B.length,numLinesAfter:$.length,numLines:J}}function x1(A){return A===D1A}function bu(A,Q){let B=A;B.isTTY&&B.setRawMode(Q)}function WLA({input:A=KLA,output:Q=z1A,overwrite:B=!0,hideCursor:$=!0}={}){let J=U2.createInterface({input:A,output:Q,prompt:"",tabSize:1});U2.emitKeypressEvents(A,J),A instanceof ZLA&&A.isTTY&&A.setRawMode(!0);let Y=(Z,{name:X,sequence:G})=>{let K=String(Z);if(q1A([K,X,G],"cancel")){$&&Q.write(qY.cursor.show),process.exit(0);return}if(!B)return;U2.moveCursor(Q,X==="return"?0:-1,X==="return"?-1:0,()=>{U2.clearLine(Q,1,()=>{A.once("keypress",Y)})})};return $&&Q.write(qY.cursor.hide),A.once("keypress",Y),()=>{A.off("keypress",Y),$&&Q.write(qY.cursor.show),A instanceof ZLA&&A.isTTY&&!TWQ&&A.setRawMode(!1),J.terminal=!1,J.close()}}function sP(A,Q,B,$=B,J=B,Y){let Z=fu(A??z1A);return D2(Q,Z-B.length,{hard:!0,trim:!1}).split(` `).map((X,G,K)=>{let W=Y?Y(X,G):X;return G===0?`${$}${W}`:G===K.length-1?`${J}${W}`:`${B}${W}`}).join(` `)}function HLA(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 EF{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=KLA,output:$=z1A,render:J,signal:Y,...Z}=A;this.opts=Z,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(D1A);this._abortSignal.addEventListener("abort",()=>{this.state="cancel",this.close()},{once:!0})}this.rl=jWQ.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),bu(this.input,!0),this.output.on("resize",this.render),this.render(),this.once("submit",()=>{this.output.write(qY.cursor.show),this.output.off("resize",this.render),bu(this.input,!1),A(this.value)}),this.once("cancel",()=>{this.output.write(qY.cursor.show),this.output.off("resize",this.render),bu(this.input,!1),A(D1A)})})}_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&&wJ.aliases.has(Q.name)&&this.emit("cursor",wJ.aliases.get(Q.name)),wJ.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=HLA(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")}q1A([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(` `),bu(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(qY.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(qY.cursor.hide);else{let Q=_WQ(this._prevFrame,A),B=I1A(this.output);if(this.restoreCursor(),Q){let $=Math.max(0,Q.numLinesAfter-B),J=Math.max(0,Q.numLinesBefore-B),Y=Q.lines.find((Z)=>Z>=$);if(Y===void 0){this._prevFrame=A;return}if(Q.lines.length===1){this.output.write(qY.cursor.move(0,Y-J)),this.output.write(qY.erase.lines(1));let Z=A.split(` `);this.output.write(Z[Y]),this._prevFrame=A,this.output.write(qY.cursor.move(0,Z.length-Y-1));return}else if(Q.lines.length>1){if($<J)Y=$;else{let X=Y-J;X>0&&this.output.write(qY.cursor.move(0,X))}this.output.write(qY.erase.down());let Z=A.split(` `).slice(Y);this.output.write(Z.join(` `)),this._prevFrame=A;return}}this.output.write(qY.erase.down())}this.output.write(A),this.state==="initial"&&(this.state="active"),this._prevFrame=A}}}function kWQ(A,Q){if(A===void 0||Q.length===0)return 0;let B=Q.findIndex(($)=>$.value===A);return B!==-1?B:0}function SWQ(A,Q){return(Q.label??String(Q.value)).toLowerCase().includes(A.toLowerCase())}function bWQ(A,Q){if(Q)return A?Q:Q[0]}function XLA(A){return[...A].map((Q)=>fWQ[Q])}function vWQ(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 F1A(A){return Number.parseInt((A||"0").replace(/_/g,"0"),10)||0}function xu(A){return{year:F1A(A.year),month:F1A(A.month),day:F1A(A.day)}}function U1A(A,Q){return new Date(A||2001,Q||1,0).getDate()}function FLA(A){let{year:Q,month:B,day:$}=xu(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 GLA(A){let Q=FLA(A);return Q?new Date(Date.UTC(Q.year,Q.month-1,Q.day)):void 0}function yWQ(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:U1A(Q.year,Q.month)}}var qY,wWQ,PWQ,wJ,TWQ,D1A,fu=(A)=>("columns"in A)&&typeof A.columns=="number"?A.columns:80,I1A=(A)=>("rows"in A)&&typeof A.rows=="number"?A.rows:20,xWQ,M1A,fWQ,DLA,gWQ,hWQ,ULA,zLA,qLA,O1A;var C1A=uA(()=>{K1A();qY=AQ(H1A(),1);wWQ=["up","down","left","right","space","enter","cancel"],PWQ=["January","February","March","April","May","June","July","August","September","October","November","December"],wJ={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:[...PWQ],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)}`}}};TWQ=globalThis.process.platform.startsWith("win"),D1A=Symbol("clack:cancel");xWQ=class extends EF{filteredOptions;multiple;isNavigating=!1;selectedValues=[];focusedValue;#A=0;#Q="";#B;#$;#J;get cursor(){return this.#A}get userInputWithCursor(){if(!this.userInput)return UN(["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),$=this.userInput.slice(this.cursor+1);return`${Q}${UN("inverse",B)}${$}`}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??SWQ;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((Z)=>Z.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.#Z(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",Z=this.userInput===""||this.userInput==="\t",X=this.#J,G=this.options,K=X!==void 0&&X!==""&&G.some((W)=>!W.disabled&&(this.#B?this.#B(X,W):!0));if(B.name==="tab"&&Z&&K){this.userInput==="\t"&&this._clearUserInput(),this._setUserInput(X,!0),this.isNavigating=!1;return}$||J?(this.#A=DN(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=bWQ(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])}#Z(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 $=kWQ(this.focusedValue,this.filteredOptions);this.#A=DN($,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())}}};M1A=class M1A extends EF{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(qY.cursor.move(0,-1)),this.value=Q,this.state="submit",this.close()}),this.on("cursor",()=>{this.value=!this.value})}};fWQ={Y:{type:"year",len:4},M:{type:"month",len:2},D:{type:"day",len:2}};DLA=class DLA extends EF{#A;#Q;#B;#$;#J;#Y={segmentIndex:0,positionInSegment:0};#Z=!0;#X=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)}#W(){this._setUserInput(this.#K(this.#B)),this._setValue(GLA(this.#B)??void 0)}constructor(A){let Q=A.format?{segments:XLA(A.format),separator:A.separator??"/"}:vWQ(A.locale),B=A.separator??Q.separator,$=A.format?XLA(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:"__"},Z=$.map((X)=>Y[X.type]).join(B);super({...A,initialUserInput:Z},!1),this.#A=$,this.#Q=B,this.#B=Y,this.#$=A.minDate,this.#J=A.maxDate,this.#W(),this.on("cursor",(X)=>this.#U(X)),this.on("key",(X,G)=>this.#z(X,G)),this.on("finalize",()=>this.#q(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}}#F(A){this.inlineError="",this.#X=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.#Z=!0)}#G(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,Z=yWQ(B.type,xu(this.#B),this.#$,this.#J),X;J?X=A===1?Z.min:Z.max:X=Math.max(Math.min(Z.max,Y+A),Z.min),this.#B={...this.#B,[B.type]:X.toString().padStart(B.len,"0")},this.#Z=!0,this.#X=null,this.#W()}#U(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)}}#z(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.#Z=!0,this.#Y.positionInSegment=0,this.#W();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.#Z=!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.#Z&&this.#X!==null&&!J){let U=this.#X+A,z={...this.#B,[$.type]:U},q=this.#D(z,$);if(q){this.inlineError=q,this.#X=null,this.#Z=!1;return}this.inlineError="",this.#B[$.type]=U,this.#X=null,this.#Z=!1,this.#W(),B.index<this.#A.length-1&&(this.#Y.segmentIndex=B.index+1,this.#Y.positionInSegment=0,this.#Z=!0);return}this.#Z&&!J&&(this.#B[$.type]="_".repeat($.len),this.#Y.positionInSegment=0),this.#Z=!1,this.#X=null;let Y=this.#B[$.type],Z=Y.indexOf("_"),X=Z>=0?Z:Math.min(this.#Y.positionInSegment,$.len-1);if(X<0||X>=$.len)return;let G=Y.slice(0,X)+A+Y.slice(X+1),K=!1;if(X===0&&Y==="__"&&($.type==="month"||$.type==="day")){let U=Number.parseInt(A,10);G=`0${A}`,K=U<=($.type==="month"?1:2)}if($.type==="year"&&(G=(Y.replace(/_/g,"")+A).padStart($.len,"_")),!G.includes("_")){let U={...this.#B,[$.type]:G},z=this.#D(U,$);if(z){this.inlineError=z;return}}this.inlineError="",this.#B[$.type]=G;let W=G.includes("_")?void 0:FLA(this.#B);if(W){let{year:U,month:z}=W,q=U1A(U,z);this.#B={year:String(Math.max(0,Math.min(9999,U))).padStart(4,"0"),month:String(Math.max(1,Math.min(12,z))).padStart(2,"0"),day:String(Math.max(1,Math.min(q,W.day))).padStart(2,"0")}}this.#W();let F=G.indexOf("_");K?(this.#Z=!0,this.#X=A):F>=0?this.#Y.positionInSegment=F:Z>=0&&B.index<this.#A.length-1?(this.#Y.segmentIndex=B.index+1,this.#Y.positionInSegment=0,this.#Z=!0):this.#Y.positionInSegment=Math.min(X+1,$.len-1)}}#D(A,Q){let{month:B,day:$}=xu(A);if(Q.type==="month"&&(B<0||B>12))return wJ.date.messages.invalidMonth;if(Q.type==="day"&&($<0||$>31))return wJ.date.messages.invalidDay(31,"any month")}#q(A){let{year:Q,month:B,day:$}=xu(this.#B);if(Q&&B&&$){let J=U1A(Q,B);this.#B={...this.#B,day:String(Math.min($,J)).padStart(2,"0")}}this.value=GLA(this.#B)??A.defaultValue??void 0}};gWQ=class extends EF{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(Q!==void 0)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}})}},hWQ=new Set(["up","down","left","right"]);ULA=class ULA extends EF{#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),$=A.slice(this.cursor+1);return B===` `?`${Q}█ ${$}`:`${Q}${UN("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=Su(this._cursor,0,-1,Q);return;case"down":this._cursor=Su(this._cursor,0,1,Q);return;case"left":this._cursor=Su(this._cursor,-1,0,Q);return;case"right":this._cursor=Su(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,$)=>{if($?.name&&hWQ.has($.name)){this.#A=!1,this.#$($.name);return}if(B==="\t"&&this.#Q){this.focused=this.focused==="editor"?"submit":"editor";return}if($?.name!=="return"){if(this.#A=!1,$?.name==="backspace"&&this.cursor>0){this._setUserInput(this.userInput.slice(0,this.cursor-1)+this.userInput.slice(this.cursor)),this._cursor--;return}if($?.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="")})}};zLA=class extends EF{_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}${UN(["inverse","hidden"],"_")}`;let B=this.masked,$=B.slice(0,this.cursor),J=B.slice(this.cursor,this.cursor+1),Y=B.slice(this.cursor+1);return`${$}${UN("inverse",J)}${Y}`}clear(){this._clearUserInput()}constructor({mask:Q,...B}){super(B),this._mask=Q??"•",this.on("userInput",($)=>{this._setValue($)}),this.on("finalize",()=>{this.value===void 0&&(this.value="")})}},qLA=class extends EF{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:J})=>J===Q.initialValue),$=B===-1?0:B;this.cursor=this.options[$]?.disabled?DN($,1,this.options):$,this.changeValue(),this.on("cursor",(J)=>{switch(J){case"left":case"up":this.cursor=DN(this.cursor,-1,this.options);break;case"down":case"right":this.cursor=DN(this.cursor,1,this.options);break}this.changeValue()})}};O1A=class O1A extends EF{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),$=A.slice(this.cursor+1);return`${Q}${UN("inverse",B)}${$}`}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 V0,stripVTControlCharacters as CM0}from"node:util";import _K from"node:process";function uWQ(){if(_K.platform!=="win32")return _K.env.TERM!=="linux";return Boolean(_K.env.CI)||Boolean(_K.env.WT_SESSION)||Boolean(_K.env.TERMINUS_SUBLIME)||_K.env.ConEmuTask==="{cmd::Cmder}"||_K.env.TERM_PROGRAM==="Terminus-Sublime"||_K.env.TERM_PROGRAM==="vscode"||_K.env.TERM==="xterm-256color"||_K.env.TERM==="alacritty"||_K.env.TERMINAL_EMULATOR==="JetBrains-JediTerm"}function rWQ(A,Q){let B=[`${Q?`${V0("cyan",E4)} `:""}${A.join(" • ")}`];return Q&&B.push(V0("cyan",RF)),B}var tP,L1A,mWQ=()=>process.env.CI==="true",U6=(A,Q)=>L1A?A:Q,cWQ,MLA,OLA,V1A,dWQ,E4,RF,EM0,RM0,N1A,yu,jM0,wM0,PM0,lWQ,_M0,TM0,kM0,SM0,bM0,xM0,pWQ,iWQ,nWQ,aWQ,gu=(A)=>{switch(A){case"initial":case"active":return V0("cyan",cWQ);case"cancel":return V0("red",MLA);case"error":return V0("yellow",OLA);case"submit":return V0("green",V1A)}},oWQ=(A)=>{switch(A){case"initial":case"active":return V0("cyan",E4);case"cancel":return V0("red",E4);case"error":return V0("yellow",E4);case"submit":return V0("green",E4)}},ILA=(A,Q,B,$,J,Y=!1)=>{let Z=Q,X=0;if(Y)for(let G=$-1;G>=B;G--){let K=A[G];if(K&&(Z-=K.length),X++,Z<=J)break}else for(let G=B;G<$;G++){let K=A[G];if(K&&(Z-=K.length),X++,Z<=J)break}return{lineCount:Z,removals:X}},sWQ=({cursor:A,options:Q,style:B,output:$=process.stdout,maxItems:J=Number.POSITIVE_INFINITY,columnPadding:Y=0,rowPadding:Z=4})=>{let X=fu($)-Y,G=I1A($),K=V0("dim","..."),W=Math.max(G-Z,0),F=Math.max(Math.min(J,W),5),U=0;A>=F-3&&(U=Math.max(Math.min(A-F+3,Q.length-F),0));let z=F<Q.length&&U>0,q=F<Q.length&&U+F<Q.length,I=Math.min(U+F,Q.length),M=[],N=0;z&&N++,q&&N++;let V=U+(z?1:0),C=I-(q?1:0);for(let R=V;R<C;R++){let j=Q[R],w=j?B(j,R===A):"",k=D2(w,X,{hard:!0,trim:!1}).split(` `);M.push(k),N+=k.length}if(N>W){let R=0,j=0,w=N,k=A-V,u=W,y=()=>ILA(M,w,0,k,u),g=()=>ILA(M,w,k+1,M.length,u,!0);z?({lineCount:w,removals:R}=y(),w>u&&(q||(u-=1),{lineCount:w,removals:j}=g())):(q||(u-=1),{lineCount:w,removals:j}=g(),w>u&&(u-=1,{lineCount:w,removals:R}=y())),R>0&&(z=!0,M.splice(0,R)),j>0&&(q=!0,M.splice(M.length-j,j))}let L=[];z&&L.push(K);for(let R of M)for(let j of R)L.push(j);return q&&L.push(K),L},A6=(A)=>{let Q=A.active??"Yes",B=A.inactive??"No";return new M1A({active:Q,inactive:B,signal:A.signal,input:A.input,output:A.output,initialValue:A.initialValue??!0,render(){let $=A.withGuide??wJ.withGuide,J=`${gu(this.state)} `,Y=$?`${V0("gray",E4)} `:"",Z=sP(A.output,A.message,Y,J),X=`${$?`${V0("gray",E4)} `:""}${Z} `,G=this.value?Q:B;switch(this.state){case"submit":{let K=$?`${V0("gray",E4)} `:"";return`${X}${K}${V0("dim",G)}`}case"cancel":{let K=$?`${V0("gray",E4)} `:"";return`${X}${K}${V0(["strikethrough","dim"],G)}${$?` ${V0("gray",E4)}`:""}`}default:{let K=$?`${V0("cyan",E4)} `:"",W=$?V0("cyan",RF):"";return`${X}${K}${this.value?`${V0("green",N1A)} ${Q}`:`${V0("dim",yu)} ${V0("dim",Q)}`}${A.vertical?$?` ${V0("cyan",E4)} `:` `:` ${V0("dim","/")} `}${this.value?`${V0("dim",yu)} ${V0("dim",B)}`:`${V0("green",N1A)} ${B}`} ${W} `}}}}).prompt()},fM0,f,CLA=(A="",Q)=>{let B=Q?.output??process.stdout,$=Q?.withGuide??wJ.withGuide?`${V0("gray",RF)} `:"";B.write(`${$}${V0("red",A)} `)},DB=(A="",Q)=>{let B=Q?.output??process.stdout,$=Q?.withGuide??wJ.withGuide?`${V0("gray",dWQ)} `:"";B.write(`${$}${A} `)},OB=(A="",Q)=>{let B=Q?.output??process.stdout,$=Q?.withGuide??wJ.withGuide?`${V0("gray",E4)} ${V0("gray",RF)} `:"";B.write(`${$}${A} `)},LLA=(A)=>new zLA({validate:A.validate,mask:A.mask??lWQ,signal:A.signal,input:A.input,output:A.output,render(){let Q=A.withGuide??wJ.withGuide,B=`${Q?`${V0("gray",E4)} `:""}${gu(this.state)} ${A.message} `,$=this.userInputWithCursor,J=this.masked;switch(this.state){case"error":{let Y=Q?`${V0("yellow",E4)} `:"",Z=Q?`${V0("yellow",RF)} `:"",X=J??"";return A.clearOnError&&this.clear(),`${B.trim()} ${Y}${X} ${Z}${V0("yellow",this.error)} `}case"submit":{let Y=Q?`${V0("gray",E4)} `:"",Z=J?V0("dim",J):"";return`${B}${Y}${Z}`}case"cancel":{let Y=Q?`${V0("gray",E4)} `:"",Z=J?V0(["strikethrough","dim"],J):"";return`${B}${Y}${Z}${J&&Q?` ${V0("gray",E4)}`:""}`}default:{let Y=Q?`${V0("cyan",E4)} `:"",Z=Q?V0("cyan",RF):"";return`${B}${Y}${$} ${Z} `}}}}).prompt(),tWQ=(A)=>V0("magenta",A),z6=({indicator:A="dots",onCancel:Q,output:B=process.stdout,cancelMessage:$,errorMessage:J,frames:Y=L1A?["◒","◐","◓","◑"]:["•","o","O","0"],delay:Z=L1A?80:120,signal:X,...G}={})=>{let K=mWQ(),W,F,U=!1,z=!1,q="",I,M=performance.now(),N=fu(B),V=G?.styleFrame??tWQ,C=(UA)=>{let e=UA>1?J??wJ.messages.error:$??wJ.messages.cancel;z=UA===1,U&&(r(e,UA),z&&typeof Q=="function"&&Q())},L=()=>C(2),R=()=>C(1),j=()=>{process.on("uncaughtExceptionMonitor",L),process.on("unhandledRejection",L),process.on("SIGINT",R),process.on("SIGTERM",R),process.on("exit",C),X&&X.addEventListener("abort",R)},w=()=>{process.removeListener("uncaughtExceptionMonitor",L),process.removeListener("unhandledRejection",L),process.removeListener("SIGINT",R),process.removeListener("SIGTERM",R),process.removeListener("exit",C),X&&X.removeEventListener("abort",R)},k=()=>{if(I===void 0)return;K&&B.write(` `);let UA=D2(I,N,{hard:!0,trim:!1}).split(` `);UA.length>1&&B.write(tP.cursor.up(UA.length-1)),B.write(tP.cursor.to(0)),B.write(tP.erase.down())},u=(UA)=>UA.replace(/\.+$/,""),y=(UA)=>{let e=(performance.now()-UA)/1000,l=Math.floor(e/60),m=Math.floor(e%60);return l>0?`[${l}m ${m}s]`:`[${m}s]`},g=G.withGuide??wJ.withGuide,c=(UA="")=>{U=!0,W=WLA({output:B}),q=u(UA),M=performance.now(),g&&B.write(`${V0("gray",E4)} `);let e=0,l=0;j(),F=setInterval(()=>{if(K&&q===I)return;k(),I=q;let m=V(Y[e]),b;if(K)b=`${m} ${q}...`;else if(A==="timer")b=`${m} ${q} ${y(M)}`;else{let S=".".repeat(Math.floor(l)).slice(0,3);b=`${m} ${q}${S}`}let i=D2(b,N,{hard:!0,trim:!1});B.write(i),e=e+1<Y.length?e+1:0,l=l<4?l+0.125:0},Z)},r=(UA="",e=0,l=!1)=>{if(!U)return;U=!1,clearInterval(F),k();let m=e===0?V0("green",V1A):e===1?V0("red",MLA):V0("red",OLA);q=UA??q,l||(A==="timer"?B.write(`${m} ${q} ${y(M)} `):B.write(`${m} ${q} `)),w(),W()};return{start:c,stop:(UA="")=>r(UA,0),message:(UA="")=>{q=u(UA??q)},cancel:(UA="")=>r(UA,1),error:(UA="")=>r(UA,2),clear:()=>r("",0,!0),get isCancelled(){return z}}},vM0,eWQ,vu=(A,Q)=>A.includes(` `)?A.split(` `).map((B)=>Q(B)).join(` `):Q(A),JJ=(A)=>{let Q=($,J)=>{if($===void 0)return"";let Y=$.label??String($.value);switch(J){case"disabled":return`${V0("gray",yu)} ${vu(Y,(Z)=>V0("gray",Z))}${$.hint?` ${V0("dim",`(${$.hint??"disabled"})`)}`:""}`;case"selected":return`${vu(Y,(Z)=>V0("dim",Z))}`;case"active":return`${V0("green",N1A)} ${Y}${$.hint?` ${V0("dim",`(${$.hint})`)}`:""}`;case"cancelled":return`${vu(Y,(Z)=>V0(["strikethrough","dim"],Z))}`;default:return`${V0("dim",yu)} ${vu(Y,(Z)=>V0("dim",Z))}`}},B=A.showInstructions??!0;return new qLA({options:A.options,signal:A.signal,input:A.input,output:A.output,initialValue:A.initialValue,render(){let $=A.withGuide??wJ.withGuide,J=`${gu(this.state)} `,Y=`${oWQ(this.state)} `,Z=sP(A.output,A.message,Y,J),X=`${$?`${V0("gray",E4)} `:""}${Z} `;switch(this.state){case"submit":{let G=$?`${V0("gray",E4)} `:"",K=sP(A.output,Q(this.options[this.cursor],"selected"),G);return`${X}${K}`}case"cancel":{let G=$?`${V0("gray",E4)} `:"",K=sP(A.output,Q(this.options[this.cursor],"cancelled"),G);return`${X}${K}${$?` ${V0("gray",E4)}`:""}`}default:{let G=$?`${V0("cyan",E4)} `:"",K=X.split(` `).length,W=B?rWQ(eWQ,$):$?[V0("cyan",RF)]:[],F=W.join(` `),U=W.length+1;return`${X}${G}${sWQ({output:A.output,cursor:this.cursor,options:this.options,maxItems:A.maxItems,columnPadding:G.length,rowPadding:K+U,style:(z,q)=>Q(z,z.disabled?"disabled":q?"active":"inactive")}).join(` ${G}`)} ${F} `}}}}).prompt()},yM0,z2=(A)=>new O1A({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??wJ.withGuide,B=`${`${Q?`${V0("gray",E4)} `:""}${gu(this.state)} `}${A.message} `,$=A.placeholder&&A.placeholder.length>0?V0("inverse",A.placeholder[0])+V0("dim",A.placeholder.slice(1)):V0(["inverse","hidden"],"_"),J=this.userInput?this.userInputWithCursor:$,Y=this.value??"";switch(this.state){case"error":{let Z=this.error?` ${V0("yellow",this.error)}`:"",X=Q?`${V0("yellow",E4)} `:"",G=Q?V0("yellow",RF):"";return`${B.trim()} ${X}${J} ${G}${Z} `}case"submit":{let Z=Y?` ${V0("dim",Y)}`:"",X=Q?V0("gray",E4):"";return`${B}${X}${Z}`}case"cancel":{let Z=Y?` ${V0(["strikethrough","dim"],Y)}`:"",X=Q?V0("gray",E4):"";return`${B}${X}${Z}${Y.trim()?` ${X}`:""}`}default:{let Z=Q?`${V0("cyan",E4)} `:"",X=Q?V0("cyan",RF):"";return`${B}${Z}${J} ${X} `}}}}).prompt();var hB=uA(()=>{C1A();C1A();K1A();Y1A();tP=AQ(H1A(),1);L1A=uWQ(),cWQ=U6("◆","*"),MLA=U6("■","x"),OLA=U6("▲","x"),V1A=U6("◇","o"),dWQ=U6("┌","T"),E4=U6("│","|"),RF=U6("└","—"),EM0=U6("┐","T"),RM0=U6("┘","—"),N1A=U6("●",">"),yu=U6("○"," "),jM0=U6("◻","[•]"),wM0=U6("◼","[+]"),PM0=U6("◻","[ ]"),lWQ=U6("▪","•"),_M0=U6("─","-"),TM0=U6("╮","+"),kM0=U6("├","+"),SM0=U6("╯","+"),bM0=U6("╰","+"),xM0=U6("╭","+"),pWQ=U6("●","•"),iWQ=U6("◆","*"),nWQ=U6("▲","!"),aWQ=U6("■","x");fM0=[`${V0("dim","↑/↓")} to navigate`,`${V0("dim","Space:")} select`,`${V0("dim","Enter:")} confirm`],f={message:(A=[],{symbol:Q=V0("gray",E4),secondarySymbol:B=V0("gray",E4),output:$=process.stdout,spacing:J=1,withGuide:Y}={})=>{let Z=[],X=Y??wJ.withGuide,G=X?B:"",K=X?`${Q} `:"",W=X?`${B} `:"";for(let U=0;U<J;U++)Z.push(G);let F=Array.isArray(A)?A:A.split(` `);if(F.length>0){let[U,...z]=F;U.length>0?Z.push(`${K}${U}`):Z.push(X?Q:"");for(let q of z)q.length>0?Z.push(`${W}${q}`):Z.push(X?B:"")}$.write(`${Z.join(` `)} `)},info:(A,Q)=>{f.message(A,{...Q,symbol:V0("blue",pWQ)})},success:(A,Q)=>{f.message(A,{...Q,symbol:V0("green",iWQ)})},step:(A,Q)=>{f.message(A,{...Q,symbol:V0("green",V1A)})},warn:(A,Q)=>{f.message(A,{...Q,symbol:V0("yellow",nWQ)})},warning:(A,Q)=>{f.warn(A,Q)},error:(A,Q)=>{f.message(A,{...Q,symbol:V0("red",aWQ)})}},vM0={light:U6("─","-"),heavy:U6("━","="),block:U6("█","#")},eWQ=[`${V0("dim","↑/↓")} to navigate`,`${V0("dim","Enter:")} confirm`],yM0=`${V0("gray",E4)} `});var I6;var QX=uA(()=>{I6={name:"@capgo/cli",type:"module",version:"8.33.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:package-json-guard":"bun test/test-package-json-guard.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:auto-bump-version && bun run test:auto-bump-ai-diff && 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:package-json-guard && 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 &