hofii 0.0.31 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/main.js +48 -54
  2. package/package.json +1 -1
package/dist/main.js CHANGED
@@ -1,61 +1,55 @@
1
1
  #!/usr/bin/env bun
2
2
  // @bun
3
- var C9=Object.create;var{getPrototypeOf:R9,defineProperty:U1,getOwnPropertyNames:A9}=Object;var E9=Object.prototype.hasOwnProperty;function D9(Z){return this[Z]}var I9,x9,L1=(Z,J,Q)=>{var F=Z!=null&&typeof Z==="object";if(F){var Y=J?I9??=new WeakMap:x9??=new WeakMap,H=Y.get(Z);if(H)return H}Q=Z!=null?C9(R9(Z)):{};let z=J||!Z||!Z.__esModule?U1(Q,"default",{value:Z,enumerable:!0}):Q;for(let U of A9(Z))if(!E9.call(z,U))U1(z,U,{get:D9.bind(Z,U),enumerable:!0});if(F)Y.set(Z,z);return z};var T9=(Z,J)=>()=>(J||Z((J={exports:{}}).exports,J),J.exports);var c0=T9((h6,f1)=>{var g0={to(Z,J){if(!J)return`\x1B[${Z+1}G`;return`\x1B[${J+1};${Z+1}H`},move(Z,J){let Q="";if(Z<0)Q+=`\x1B[${-Z}D`;else if(Z>0)Q+=`\x1B[${Z}C`;if(J<0)Q+=`\x1B[${-J}A`;else if(J>0)Q+=`\x1B[${J}B`;return Q},up:(Z=1)=>`\x1B[${Z}A`,down:(Z=1)=>`\x1B[${Z}B`,forward:(Z=1)=>`\x1B[${Z}C`,backward:(Z=1)=>`\x1B[${Z}D`,nextLine:(Z=1)=>"\x1B[E".repeat(Z),prevLine:(Z=1)=>"\x1B[F".repeat(Z),left:"\x1B[G",hide:"\x1B[?25l",show:"\x1B[?25h",save:"\x1B7",restore:"\x1B8"},U8={up:(Z=1)=>"\x1B[S".repeat(Z),down:(Z=1)=>"\x1B[T".repeat(Z)},L8={screen:"\x1B[2J",up:(Z=1)=>"\x1B[1J".repeat(Z),down:(Z=1)=>"\x1B[J".repeat(Z),line:"\x1B[2K",lineEnd:"\x1B[K",lineStart:"\x1B[1K",lines(Z){let J="";for(let Q=0;Q<Z;Q++)J+=this.line+(Q<Z-1?g0.up():"");if(Z)J+=g0.left;return J}};f1.exports={cursor:g0,scroll:U8,erase:L8,beep:"\x07"}});function S0(Z){return Z==null?[]:Array.isArray(Z)?Z:[Z]}function S9(Z,J,Q,F){var Y,H=Z[J],z=~F.string.indexOf(J)?Q==null||Q===!0?"":String(Q):typeof Q==="boolean"?Q:~F.boolean.indexOf(J)?Q==="false"?!1:Q==="true"||(Z._.push((Y=+Q,Y*0===0)?Y:Q),!!Q):(Y=+Q,Y*0===0)?Y:Q;Z[J]=H==null?z:Array.isArray(H)?H.concat(z):[H,z]}function k9(Z,J){Z=Z||[],J=J||{};var Q,F,Y,H,z,U={_:[]},W=0,L=0,K=0,X=Z.length;let M=J.alias!==void 0,N=J.unknown!==void 0,j=J.default!==void 0;if(J.alias=J.alias||{},J.string=S0(J.string),J.boolean=S0(J.boolean),M)for(Q in J.alias){F=J.alias[Q]=S0(J.alias[Q]);for(W=0;W<F.length;W++)(J.alias[F[W]]=F.concat(Q)).splice(W,1)}for(W=J.boolean.length;W-- >0;){F=J.alias[J.boolean[W]]||[];for(L=F.length;L-- >0;)J.boolean.push(F[L])}for(W=J.string.length;W-- >0;){F=J.alias[J.string[W]]||[];for(L=F.length;L-- >0;)J.string.push(F[L])}if(j){for(Q in J.default)if(H=typeof J.default[Q],F=J.alias[Q]=J.alias[Q]||[],J[H]!==void 0){J[H].push(Q);for(W=0;W<F.length;W++)J[H].push(F[W])}}let w=N?Object.keys(J.alias):[];for(W=0;W<X;W++){if(Y=Z[W],Y==="--"){U._=U._.concat(Z.slice(++W));break}for(L=0;L<Y.length;L++)if(Y.charCodeAt(L)!==45)break;if(L===0)U._.push(Y);else if(Y.substring(L,L+3)==="no-"){if(H=Y.substring(L+3),N&&!~w.indexOf(H))return J.unknown(Y);U[H]=!1}else{for(K=L+1;K<Y.length;K++)if(Y.charCodeAt(K)===61)break;H=Y.substring(L,K),z=Y.substring(++K)||W+1===X||(""+Z[W+1]).charCodeAt(0)===45||Z[++W],F=L===2?[H]:H;for(K=0;K<F.length;K++){if(H=F[K],N&&!~w.indexOf(H))return J.unknown("-".repeat(L)+H);S9(U,H,K+1<F.length||z,J)}}}if(j){for(Q in J.default)if(U[Q]===void 0)U[Q]=J.default[Q]}if(M)for(Q in U){F=J.alias[Q]||[];while(F.length>0)U[F.shift()]=U[Q]}return U}function M1(Z){return Z.replace(/[<[].+/,"").trim()}function h9(Z){let J=/<([^>]+)>/g,Q=/\[([^\]]+)\]/g,F=[],Y=(U)=>{let W=!1,L=U[1];if(L.startsWith("..."))L=L.slice(3),W=!0;return{required:U[0].startsWith("<"),value:L,variadic:W}},H;while(H=J.exec(Z))F.push(Y(H));let z;while(z=Q.exec(Z))F.push(Y(z));return F}function v9(Z){let J={alias:{},boolean:[]};for(let[Q,F]of Z.entries()){if(F.names.length>1)J.alias[F.names[0]]=F.names.slice(1);if(F.isBoolean)if(F.negated){if(!Z.some((Y,H)=>{return H!==Q&&Y.names.some((z)=>F.names.includes(z))&&typeof Y.required==="boolean"}))J.boolean.push(F.names[0])}else J.boolean.push(F.names[0])}return J}function K1(Z){return Z.sort((J,Q)=>{return J.length>Q.length?-1:1})[0]}function X1(Z,J){return Z.length>=J?Z:`${Z}${" ".repeat(J-Z.length)}`}function _9(Z){return Z.replaceAll(/([a-z])-([a-z])/g,(J,Q,F)=>{return Q+F.toUpperCase()})}function f9(Z,J,Q){let F=Z;for(let Y=0;Y<J.length;Y++){let H=J[Y];if(Y===J.length-1){F[H]=Q;return}if(F[H]==null){let z=+J[Y+1]>-1;F[H]=z?[]:{}}F=F[H]}}function y9(Z,J){for(let Q of Object.keys(J)){let F=J[Q];if(F.shouldTransform){if(Z[Q]=[Z[Q]].flat(),typeof F.transformFunction==="function")Z[Q]=Z[Q].map(F.transformFunction)}}}function $9(Z){let J=/([^\\/]+)$/.exec(Z);return J?J[1]:""}function G1(Z){return Z.split(".").map((J,Q)=>{return Q===0?_9(J):J}).join(".")}var U0=class extends Error{constructor(Z){super(Z);if(this.name="CACError",typeof Error.captureStackTrace!=="function")this.stack=Error(Z).stack}},p9=class{rawName;description;name;names;isBoolean;required;config;negated;constructor(Z,J,Q){if(this.rawName=Z,this.description=J,this.config=Object.assign({},Q),Z=Z.replaceAll(".*",""),this.negated=!1,this.names=M1(Z).split(",").map((F)=>{let Y=F.trim().replace(/^-{1,2}/,"");if(Y.startsWith("no-"))this.negated=!0,Y=Y.replace(/^no-/,"");return G1(Y)}).sort((F,Y)=>F.length>Y.length?1:-1),this.name=this.names.at(-1),this.negated&&this.config.default==null)this.config.default=!0;if(Z.includes("<"))this.required=!0;else if(Z.includes("["))this.required=!1;else this.isBoolean=!0}},k0,L0;if(typeof process<"u"){let Z;if(typeof Deno<"u"&&typeof Deno.version?.deno==="string")Z="deno";else if(typeof Bun<"u"&&typeof Bun.version==="string")Z="bun";else Z="node";L0=`${process.platform}-${process.arch} ${Z}-${process.version}`,k0=process.argv}else if(typeof navigator>"u")L0="unknown";else L0=`${navigator.platform} ${navigator.userAgent}`;var j1=class{rawName;description;config;cli;options;aliasNames;name;args;commandAction;usageText;versionNumber;examples;helpCallback;globalCommand;constructor(Z,J,Q={},F){this.rawName=Z,this.description=J,this.config=Q,this.cli=F,this.options=[],this.aliasNames=[],this.name=M1(Z),this.args=h9(Z),this.examples=[]}usage(Z){return this.usageText=Z,this}allowUnknownOptions(){return this.config.allowUnknownOptions=!0,this}ignoreOptionDefaultValue(){return this.config.ignoreOptionDefaultValue=!0,this}version(Z,J="-v, --version"){return this.versionNumber=Z,this.option(J,"Display version number"),this}example(Z){return this.examples.push(Z),this}option(Z,J,Q){let F=new p9(Z,J,Q);return this.options.push(F),this}alias(Z){return this.aliasNames.push(Z),this}action(Z){return this.commandAction=Z,this}isMatched(Z){return this.name===Z||this.aliasNames.includes(Z)}get isDefaultCommand(){return this.name===""||this.aliasNames.includes("!")}get isGlobalCommand(){return this instanceof N1}hasOption(Z){return Z=Z.split(".")[0],this.options.find((J)=>{return J.names.includes(Z)})}outputHelp(){let{name:Z,commands:J}=this.cli,{versionNumber:Q,options:F,helpCallback:Y}=this.cli.globalCommand,H=[{body:`${Z}${Q?`/${Q}`:""}`}];if(H.push({title:"Usage",body:` $ ${Z} ${this.usageText||this.rawName}`}),(this.isGlobalCommand||this.isDefaultCommand)&&J.length>0){let U=K1(J.map((W)=>W.rawName));H.push({title:"Commands",body:J.map((W)=>{return` ${X1(W.rawName,U.length)} ${W.description}`}).join(`
4
- `)},{title:"For more info, run any command with the `--help` flag",body:J.map((W)=>` $ ${Z}${W.name===""?"":` ${W.name}`} --help`).join(`
5
- `)})}let z=this.isGlobalCommand?F:[...this.options,...F||[]];if(!this.isGlobalCommand&&!this.isDefaultCommand)z=z.filter((U)=>U.name!=="version");if(z.length>0){let U=K1(z.map((W)=>W.rawName));H.push({title:"Options",body:z.map((W)=>{return` ${X1(W.rawName,U.length)} ${W.description} ${W.config.default===void 0?"":`(default: ${W.config.default})`}`}).join(`
6
- `)})}if(this.examples.length>0)H.push({title:"Examples",body:this.examples.map((U)=>{if(typeof U==="function")return U(Z);return U}).join(`
7
- `)});if(Y)H=Y(H)||H;console.info(H.map((U)=>{return U.title?`${U.title}:
8
- ${U.body}`:U.body}).join(`
3
+ var dn=Object.create;var{getPrototypeOf:gn,defineProperty:nt,getOwnPropertyNames:vn}=Object;var $n=Object.prototype.hasOwnProperty;function bn(e){return this[e]}var kn,wn,st=(e,t,n)=>{var s=e!=null&&typeof e==="object";if(s){var r=t?kn??=new WeakMap:wn??=new WeakMap,u=r.get(e);if(u)return u}n=e!=null?dn(gn(e)):{};let o=t||!e||!e.__esModule?nt(n,"default",{value:e,enumerable:!0}):n;if(e&&typeof e==="object"||typeof e==="function"){for(let a of vn(e))if(!$n.call(o,a))nt(o,a,{get:bn.bind(e,a),enumerable:!0})}if(s)r.set(e,o);return o};var xn=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var Ge=xn(function(vr,Ot){var Le={to(e,t){if(!t)return`\x1B[${e+1}G`;return`\x1B[${t+1};${e+1}H`},move(e,t){let n="";if(e<0)n+=`\x1B[${-e}D`;else if(e>0)n+=`\x1B[${e}C`;if(t<0)n+=`\x1B[${-t}A`;else if(t>0)n+=`\x1B[${t}B`;return n},up:(e=1)=>`\x1B[${e}A`,down:(e=1)=>`\x1B[${e}B`,forward:(e=1)=>`\x1B[${e}C`,backward:(e=1)=>`\x1B[${e}D`,nextLine:(e=1)=>"\x1B[E".repeat(e),prevLine:(e=1)=>"\x1B[F".repeat(e),left:"\x1B[G",hide:"\x1B[?25l",show:"\x1B[?25h",save:"\x1B7",restore:"\x1B8"},ts={up:(e=1)=>"\x1B[S".repeat(e),down:(e=1)=>"\x1B[T".repeat(e)},ns={screen:"\x1B[2J",up:(e=1)=>"\x1B[1J".repeat(e),down:(e=1)=>"\x1B[J".repeat(e),line:"\x1B[2K",lineEnd:"\x1B[K",lineStart:"\x1B[1K",lines(e){let t="";for(let n=0;n<e;n++)t+=this.line+(n<e-1?Le.up():"");if(e)t+=Le.left;return t}};Ot.exports={cursor:Le,scroll:ts,erase:ns,beep:"\x07"}});function Me(e){return e==null?[]:Array.isArray(e)?e:[e]}function _n(e,t,n,s){var r,u=e[t],o=~s.string.indexOf(t)?n==null||n===!0?"":String(n):typeof n==="boolean"?n:~s.boolean.indexOf(t)?n==="false"?!1:n==="true"||(e._.push((r=+n,r*0===0)?r:n),!!n):(r=+n,r*0===0)?r:n;e[t]=u==null?o:Array.isArray(u)?u.concat(o):[u,o]}function En(e,t){e=e||[],t=t||{};var n,s,r,u,o,a={_:[]},i=0,l=0,c=0,f=e.length;let h=t.alias!==void 0,g=t.unknown!==void 0,m=t.default!==void 0;if(t.alias=t.alias||{},t.string=Me(t.string),t.boolean=Me(t.boolean),h)for(n in t.alias){s=t.alias[n]=Me(t.alias[n]);for(i=0;i<s.length;i++)(t.alias[s[i]]=s.concat(n)).splice(i,1)}for(i=t.boolean.length;i-- >0;){s=t.alias[t.boolean[i]]||[];for(l=s.length;l-- >0;)t.boolean.push(s[l])}for(i=t.string.length;i-- >0;){s=t.alias[t.string[i]]||[];for(l=s.length;l-- >0;)t.string.push(s[l])}if(m){for(n in t.default)if(u=typeof t.default[n],s=t.alias[n]=t.alias[n]||[],t[u]!==void 0){t[u].push(n);for(i=0;i<s.length;i++)t[u].push(s[i])}}let y=g?Object.keys(t.alias):[];for(i=0;i<f;i++){if(r=e[i],r==="--"){a._=a._.concat(e.slice(++i));break}for(l=0;l<r.length;l++)if(r.charCodeAt(l)!==45)break;if(l===0)a._.push(r);else if(r.substring(l,l+3)==="no-"){if(u=r.substring(l+3),g&&!~y.indexOf(u))return t.unknown(r);a[u]=!1}else{for(c=l+1;c<r.length;c++)if(r.charCodeAt(c)===61)break;u=r.substring(l,c),o=r.substring(++c)||i+1===f||(""+e[i+1]).charCodeAt(0)===45||e[++i],s=l===2?[u]:u;for(c=0;c<s.length;c++){if(u=s[c],g&&!~y.indexOf(u))return t.unknown("-".repeat(l)+u);_n(a,u,c+1<s.length||o,t)}}}if(m){for(n in t.default)if(a[n]===void 0)a[n]=t.default[n]}if(h)for(n in a){s=t.alias[n]||[];while(s.length>0)a[s.shift()]=a[n]}return a}function ut(e){return e.replace(/[<[].+/,"").trim()}function In(e){let t=/<([^>]+)>/g,n=/\[([^\]]+)\]/g,s=[],r=(a)=>{let i=!1,l=a[1];if(l.startsWith("..."))l=l.slice(3),i=!0;return{required:a[0].startsWith("<"),value:l,variadic:i}},u;while(u=t.exec(e))s.push(r(u));let o;while(o=n.exec(e))s.push(r(o));return s}function Sn(e){let t={alias:{},boolean:[]};for(let[n,s]of e.entries()){if(s.names.length>1)t.alias[s.names[0]]=s.names.slice(1);if(s.isBoolean)if(s.negated){if(!e.some((r,u)=>u!==n&&r.names.some((o)=>s.names.includes(o))&&typeof r.required==="boolean"))t.boolean.push(s.names[0])}else t.boolean.push(s.names[0])}return t}function rt(e){return e.sort((t,n)=>t.length>n.length?-1:1)[0]}function it(e,t){return e.length>=t?e:`${e}${" ".repeat(t-e.length)}`}function Cn(e){return e.replaceAll(/([a-z])-([a-z])/g,(t,n,s)=>n+s.toUpperCase())}function An(e,t,n){let s=e;for(let r=0;r<t.length;r++){let u=t[r];if(r===t.length-1){s[u]=n;return}if(s[u]==null){let o=+t[r+1]>-1;s[u]=o?[]:{}}s=s[u]}}function On(e,t){for(let n of Object.keys(t)){let s=t[n];if(s.shouldTransform){if(e[n]=[e[n]].flat(),typeof s.transformFunction==="function")e[n]=e[n].map(s.transformFunction)}}}function Mn(e){let t=/([^\\/]+)$/.exec(e);return t?t[1]:""}function ot(e){return e.split(".").map((t,n)=>n===0?Cn(t):t).join(".")}var ae=class extends Error{constructor(e){super(e);if(this.name="CACError",typeof Error.captureStackTrace!=="function")this.stack=Error(e).stack}},Dn=class{rawName;description;name;names;isBoolean;required;config;negated;constructor(e,t,n){if(this.rawName=e,this.description=t,this.config=Object.assign({},n),e=e.replaceAll(".*",""),this.negated=!1,this.names=ut(e).split(",").map((s)=>{let r=s.trim().replace(/^-{1,2}/,"");if(r.startsWith("no-"))this.negated=!0,r=r.replace(/^no-/,"");return ot(r)}).sort((s,r)=>s.length>r.length?1:-1),this.name=this.names.at(-1),this.negated&&this.config.default==null)this.config.default=!0;if(e.includes("<"))this.required=!0;else if(e.includes("["))this.required=!1;else this.isBoolean=!0}},De,le;if(typeof process<"u"){let e;if(typeof Deno<"u"&&typeof Deno.version?.deno==="string")e="deno";else if(typeof Bun<"u"&&typeof Bun.version==="string")e="bun";else e="node";le=`${process.platform}-${process.arch} ${e}-${process.version}`,De=process.argv}else if(typeof navigator>"u")le="unknown";else le=`${navigator.platform} ${navigator.userAgent}`;var at=class{rawName;description;config;cli;options;aliasNames;name;args;commandAction;usageText;versionNumber;examples;helpCallback;globalCommand;constructor(e,t,n={},s){this.rawName=e,this.description=t,this.config=n,this.cli=s,this.options=[],this.aliasNames=[],this.name=ut(e),this.args=In(e),this.examples=[]}usage(e){return this.usageText=e,this}allowUnknownOptions(){return this.config.allowUnknownOptions=!0,this}ignoreOptionDefaultValue(){return this.config.ignoreOptionDefaultValue=!0,this}version(e,t="-v, --version"){return this.versionNumber=e,this.option(t,"Display version number"),this}example(e){return this.examples.push(e),this}option(e,t,n){let s=new Dn(e,t,n);return this.options.push(s),this}alias(e){return this.aliasNames.push(e),this}action(e){return this.commandAction=e,this}isMatched(e){return this.name===e||this.aliasNames.includes(e)}get isDefaultCommand(){return this.name===""||this.aliasNames.includes("!")}get isGlobalCommand(){return this instanceof lt}hasOption(e){return e=e.split(".")[0],this.options.find((t)=>t.names.includes(e))}outputHelp(){let{name:e,commands:t}=this.cli,{versionNumber:n,options:s,helpCallback:r}=this.cli.globalCommand,u=[{body:`${e}${n?`/${n}`:""}`}];if(u.push({title:"Usage",body:` $ ${e} ${this.usageText||this.rawName}`}),(this.isGlobalCommand||this.isDefaultCommand)&&t.length>0){let a=rt(t.map((i)=>i.rawName));u.push({title:"Commands",body:t.map((i)=>` ${it(i.rawName,a.length)} ${i.description}`).join(`
4
+ `)},{title:"For more info, run any command with the `--help` flag",body:t.map((i)=>` $ ${e}${i.name===""?"":` ${i.name}`} --help`).join(`
5
+ `)})}let o=this.isGlobalCommand?s:[...this.options,...s||[]];if(!this.isGlobalCommand&&!this.isDefaultCommand)o=o.filter((a)=>a.name!=="version");if(o.length>0){let a=rt(o.map((i)=>i.rawName));u.push({title:"Options",body:o.map((i)=>` ${it(i.rawName,a.length)} ${i.description} ${i.config.default===void 0?"":`(default: ${i.config.default})`}`).join(`
6
+ `)})}if(this.examples.length>0)u.push({title:"Examples",body:this.examples.map((a)=>{if(typeof a==="function")return a(e);return a}).join(`
7
+ `)});if(r)u=r(u)||u;console.info(u.map((a)=>a.title?`${a.title}:
8
+ ${a.body}`:a.body).join(`
9
9
 
10
- `))}outputVersion(){let{name:Z}=this.cli,{versionNumber:J}=this.cli.globalCommand;if(J)console.info(`${Z}/${J} ${L0}`)}checkRequiredArgs(){let Z=this.args.filter((J)=>J.required).length;if(this.cli.args.length<Z)throw new U0(`missing required args for command \`${this.rawName}\``)}checkUnknownOptions(){let{options:Z,globalCommand:J}=this.cli;if(!this.config.allowUnknownOptions){for(let Q of Object.keys(Z))if(Q!=="--"&&!this.hasOption(Q)&&!J.hasOption(Q))throw new U0(`Unknown option \`${Q.length>1?`--${Q}`:`-${Q}`}\``)}}checkOptionValue(){let{options:Z,globalCommand:J}=this.cli,Q=[...J.options,...this.options];for(let F of Q){let Y=Z[F.name.split(".")[0]];if(F.required){let H=Q.some((z)=>z.negated&&z.names.includes(F.name));if(Y===!0||Y===!1&&!H)throw new U0(`option \`${F.rawName}\` value is missing`)}}}checkUnusedArgs(){let Z=this.args.some((J)=>J.variadic)?1/0:this.args.length;if(Z<this.cli.args.length)throw new U0(`Unused args: ${this.cli.args.slice(Z).map((J)=>`\`${J}\``).join(", ")}`)}},N1=class extends j1{constructor(Z){super("@@global@@","",{},Z)}},g9=class extends EventTarget{name;commands;globalCommand;matchedCommand;matchedCommandName;rawArgs;args;options;showHelpOnExit;showVersionOnExit;constructor(Z=""){super();this.name=Z,this.commands=[],this.rawArgs=[],this.args=[],this.options={},this.globalCommand=new N1(this),this.globalCommand.usage("<command> [options]")}usage(Z){return this.globalCommand.usage(Z),this}command(Z,J,Q){let F=new j1(Z,J||"",Q,this);return F.globalCommand=this.globalCommand,this.commands.push(F),F}option(Z,J,Q){return this.globalCommand.option(Z,J,Q),this}help(Z){return this.globalCommand.option("-h, --help","Display this message"),this.globalCommand.helpCallback=Z,this.showHelpOnExit=!0,this}version(Z,J="-v, --version"){return this.globalCommand.version(Z,J),this.showVersionOnExit=!0,this}example(Z){return this.globalCommand.example(Z),this}outputHelp(){if(this.matchedCommand)this.matchedCommand.outputHelp();else this.globalCommand.outputHelp()}outputVersion(){this.globalCommand.outputVersion()}setParsedInfo({args:Z,options:J},Q,F){if(this.args=Z,this.options=J,Q)this.matchedCommand=Q;if(F)this.matchedCommandName=F;return this}unsetMatchedCommand(){this.matchedCommand=void 0,this.matchedCommandName=void 0}parse(Z,{run:J=!0}={}){if(!Z){if(!k0)throw Error("No argv provided and runtime process argv is not available.");Z=k0}if(this.rawArgs=Z,!this.name)this.name=Z[1]?$9(Z[1]):"cli";let Q=!0;for(let Y of this.commands){let H=this.mri(Z.slice(2),Y),z=H.args[0];if(Y.isMatched(z)){Q=!1;let U={...H,args:H.args.slice(1)};this.setParsedInfo(U,Y,z),this.dispatchEvent(new CustomEvent(`command:${z}`,{detail:Y}))}}if(Q){for(let Y of this.commands)if(Y.isDefaultCommand){Q=!1;let H=this.mri(Z.slice(2),Y);this.setParsedInfo(H,Y),this.dispatchEvent(new CustomEvent("command:!",{detail:Y}))}}if(Q){let Y=this.mri(Z.slice(2));this.setParsedInfo(Y)}if(this.options.help&&this.showHelpOnExit)this.outputHelp(),J=!1,this.unsetMatchedCommand();if(this.options.version&&this.showVersionOnExit&&this.matchedCommandName==null)this.outputVersion(),J=!1,this.unsetMatchedCommand();let F={args:this.args,options:this.options};if(J)this.runMatchedCommand();if(!this.matchedCommand&&this.args[0])this.dispatchEvent(new CustomEvent("command:*",{detail:this.args[0]}));return F}mri(Z,J){let Q=[...this.globalCommand.options,...J?J.options:[]],F=v9(Q),Y=[],H=Z.indexOf("--");if(H!==-1)Y=Z.slice(H+1),Z=Z.slice(0,H);let z=k9(Z,F);z=Object.keys(z).reduce((X,M)=>{return{...X,[G1(M)]:z[M]}},{_:[]});let U=z._,W={"--":Y},L=J&&J.config.ignoreOptionDefaultValue?J.config.ignoreOptionDefaultValue:this.globalCommand.config.ignoreOptionDefaultValue,K=Object.create(null);for(let X of Q){if(!L&&X.config.default!==void 0)for(let M of X.names)W[M]=X.config.default;if(Array.isArray(X.config.type)&&K[X.name]===void 0)K[X.name]=Object.create(null),K[X.name].shouldTransform=!0,K[X.name].transformFunction=X.config.type[0]}for(let X of Object.keys(z))if(X!=="_")f9(W,X.split("."),z[X]),y9(W,K);return{args:U,options:W}}runMatchedCommand(){let{args:Z,options:J,matchedCommand:Q}=this;if(!Q||!Q.commandAction)return;Q.checkUnknownOptions(),Q.checkOptionValue(),Q.checkRequiredArgs(),Q.checkUnusedArgs();let F=[];return Q.args.forEach((Y,H)=>{if(Y.variadic)F.push(Z.slice(H));else F.push(Z[H])}),F.push(J),Q.commandAction.apply(this,F)}},w1=(Z="")=>new g9(Z);import V6 from"path";var K0,c9={lang:void 0,message:void 0,abortEarly:void 0,abortPipeEarly:void 0};function q1(Z){if(!Z&&!K0)return c9;return{lang:Z?.lang??K0?.lang,message:Z?.message,abortEarly:Z?.abortEarly??K0?.abortEarly,abortPipeEarly:Z?.abortPipeEarly??K0?.abortPipeEarly}}var l9;function m9(Z){return l9?.get(Z)}var u9;function r9(Z){return u9?.get(Z)}var o9;function n9(Z,J){return o9?.get(Z)?.get(J)}function h0(Z){let J=typeof Z;if(J==="string")return`"${Z}"`;if(J==="number"||J==="bigint"||J==="boolean")return`${Z}`;if(J==="object"||J==="function")return(Z&&Object.getPrototypeOf(Z)?.constructor?.name)??"null";return J}function f(Z,J,Q,F,Y){let H=Y&&"input"in Y?Y.input:Q.value,z=Y?.expected??Z.expects??null,U=Y?.received??h0(H),W={kind:Z.kind,type:Z.type,input:H,expected:z,received:U,message:`Invalid ${J}: ${z?`Expected ${z} but r`:"R"}eceived ${U}`,requirement:Z.requirement,path:Y?.path,issues:Y?.issues,lang:F.lang,abortEarly:F.abortEarly,abortPipeEarly:F.abortPipeEarly},L=Z.kind==="schema",K=Y?.message??Z.message??n9(Z.reference,W.lang)??(L?r9(W.lang):null)??F.message??m9(W.lang);if(K!==void 0)W.message=typeof K==="function"?K(W):K;if(L)Q.typed=!1;if(Q.issues)Q.issues.push(W);else Q.issues=[W]}var V1=new WeakMap;function y(Z){let J=V1.get(Z);if(!J)J={version:1,vendor:"valibot",validate(Q){return Z["~run"]({value:Q},q1())}},V1.set(Z,J);return J}function P1(Z,J){let Q=[...new Set(Z)];if(Q.length>1)return`(${Q.join(` ${J} `)})`;return Q[0]??"never"}var v0=class extends Error{constructor(Z){super(Z[0].message);this.name="ValiError",this.issues=Z}};function i9(Z,J,Q){return typeof Z.fallback==="function"?Z.fallback(J,Q):Z.fallback}function O1(Z,J,Q){return typeof Z.default==="function"?Z.default(J,Q):Z.default}function $(Z,J){return{kind:"schema",type:"array",reference:$,expects:"Array",async:!1,item:Z,message:J,get "~standard"(){return y(this)},"~run"(Q,F){let Y=Q.value;if(Array.isArray(Y)){Q.typed=!0,Q.value=[];for(let H=0;H<Y.length;H++){let z=Y[H],U=this.item["~run"]({value:z},F);if(U.issues){let W={type:"array",origin:"value",input:Y,key:H,value:z};for(let L of U.issues){if(L.path)L.path.unshift(W);else L.path=[W];Q.issues?.push(L)}if(!Q.issues)Q.issues=U.issues;if(F.abortEarly){Q.typed=!1;break}}if(!U.typed)Q.typed=!1;Q.value.push(U.value)}}else f(this,"type",Q,F);return Q}}}function t(Z){return{kind:"schema",type:"boolean",reference:t,expects:"boolean",async:!1,message:Z,get "~standard"(){return y(this)},"~run"(J,Q){if(typeof J.value==="boolean")J.typed=!0;else f(this,"type",J,Q);return J}}}function _0(Z,J){return{kind:"schema",type:"literal",reference:_0,expects:h0(Z),async:!1,literal:Z,message:J,get "~standard"(){return y(this)},"~run"(Q,F){if(Q.value===this.literal)Q.typed=!0;else f(this,"type",Q,F);return Q}}}function u(Z,J){return{kind:"schema",type:"object",reference:u,expects:"Object",async:!1,entries:Z,message:J,get "~standard"(){return y(this)},"~run"(Q,F){let Y=Q.value;if(Y&&typeof Y==="object"){Q.typed=!0,Q.value={};for(let H in this.entries){let z=this.entries[H];if(H in Y||(z.type==="exact_optional"||z.type==="optional"||z.type==="nullish")&&z.default!==void 0){let U=H in Y?Y[H]:O1(z),W=z["~run"]({value:U},F);if(W.issues){let L={type:"object",origin:"value",input:Y,key:H,value:U};for(let K of W.issues){if(K.path)K.path.unshift(L);else K.path=[L];Q.issues?.push(K)}if(!Q.issues)Q.issues=W.issues;if(F.abortEarly){Q.typed=!1;break}}if(!W.typed)Q.typed=!1;Q.value[H]=W.value}else if(z.fallback!==void 0)Q.value[H]=i9(z);else if(z.type!=="exact_optional"&&z.type!=="optional"&&z.type!=="nullish"){if(f(this,"key",Q,F,{input:void 0,expected:`"${H}"`,path:[{type:"object",origin:"key",input:Y,key:H,value:Y[H]}]}),F.abortEarly)break}}}else f(this,"type",Q,F);return Q}}}function Z0(Z,J){return{kind:"schema",type:"optional",reference:Z0,expects:`(${Z.expects} | undefined)`,async:!1,wrapped:Z,default:J,get "~standard"(){return y(this)},"~run"(Q,F){if(Q.value===void 0){if(this.default!==void 0)Q.value=O1(this,Q,F);if(Q.value===void 0)return Q.typed=!0,Q}return this.wrapped["~run"](Q,F)}}}function J0(Z,J){return{kind:"schema",type:"picklist",reference:J0,expects:P1(Z.map(h0),"|"),async:!1,options:Z,message:J,get "~standard"(){return y(this)},"~run"(Q,F){if(this.options.includes(Q.value))Q.typed=!0;else f(this,"type",Q,F);return Q}}}function S(Z){return{kind:"schema",type:"string",reference:S,expects:"string",async:!1,message:Z,get "~standard"(){return y(this)},"~run"(J,Q){if(typeof J.value==="string")J.typed=!0;else f(this,"type",J,Q);return J}}}function B1(Z){let J;if(Z)for(let Q of Z)if(J)for(let F of Q.issues)J.push(F);else J=Q.issues;return J}function Q0(Z,J){return{kind:"schema",type:"union",reference:Q0,expects:P1(Z.map((Q)=>Q.expects),"|"),async:!1,options:Z,message:J,get "~standard"(){return y(this)},"~run"(Q,F){let Y,H,z;for(let U of this.options){let W=U["~run"]({value:Q.value},F);if(W.typed)if(W.issues)if(H)H.push(W);else H=[W];else{Y=W;break}else if(z)z.push(W);else z=[W]}if(Y)return Y;if(H){if(H.length===1)return H[0];f(this,"type",Q,F,{issues:B1(H)}),Q.typed=!0}else if(z?.length===1)return z[0];else f(this,"type",Q,F,{issues:B1(z)});return Q}}}function X0(Z,J,Q){let F=Z["~run"]({value:J},q1(Q));if(F.issues)throw new v0(F.issues);return F.value}function f0(Z,J){let Q={};for(let F in Z.entries)Q[F]=!J||J.includes(F)?Z0(Z.entries[F]):Z.entries[F];return{...Z,entries:Q,get "~standard"(){return y(this)}}}import{styleText as m0}from"util";import{stdout as n0,stdin as g1}from"process";import*as r from"readline";import K8 from"readline";var b1=(()=>{let Z=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g;return(J)=>{let Q=0;Z.lastIndex=0;while(Z.test(J))Q+=1;return J.length-Q}})(),C1=(Z)=>{return Z===12288||Z>=65281&&Z<=65376||Z>=65504&&Z<=65510},R1=(Z)=>{return Z===8987||Z===9001||Z>=12272&&Z<=12287||Z>=12289&&Z<=12350||Z>=12441&&Z<=12543||Z>=12549&&Z<=12591||Z>=12593&&Z<=12686||Z>=12688&&Z<=12771||Z>=12783&&Z<=12830||Z>=12832&&Z<=12871||Z>=12880&&Z<=19903||Z>=65040&&Z<=65049||Z>=65072&&Z<=65106||Z>=65108&&Z<=65126||Z>=65128&&Z<=65131||Z>=127488&&Z<=127490||Z>=127504&&Z<=127547||Z>=127552&&Z<=127560||Z>=131072&&Z<=196605||Z>=196608&&Z<=262141};var d9=/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]|\u001b\]8;[^;]*;.*?(?:\u0007|\u001b\u005c)/y,s9=/[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y,A1=/(?:(?![\uFF61-\uFF9F\uFF00-\uFFEF])[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}\p{Script=Tangut}]){1,1000}/yu,a9=/\t{1,1000}/y,E1=/[\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,e9=/(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y,t9=/\p{M}+/gu,Z8={limit:1/0,ellipsis:""},D1=(Z,J={},Q={})=>{let F=J.limit??1/0,Y=J.ellipsis??"",H=J?.ellipsisWidth??(Y?D1(Y,Z8,Q).width:0),z=0,U=Q.controlWidth??0,W=Q.tabWidth??8,L=Q.emojiWidth??2,K=2,X=Q.regularWidth??1,M=Q.wideWidth??2,N=[[e9,X],[d9,0],[s9,U],[a9,W],[E1,L],[A1,M]],j=0,w=0,k=Z.length,c=0,l=!1,x=k,h=Math.max(0,F-H),A=0,s=0,T=0,R=0;Z:while(!0){if(s>A||w>=k&&w>j){let m=Z.slice(A,s)||Z.slice(j,w);c=0;for(let i of m.replaceAll(t9,"")){let E=i.codePointAt(0)||0;if(C1(E))R=2;else if(R1(E))R=M;else R=X;if(T+R>h)x=Math.min(x,Math.max(A,j)+c);if(T+R>F){l=!0;break Z}c+=i.length,T+=R}A=s=0}if(w>=k)break Z;for(let m=0,i=N.length;m<i;m++){let[E,W0]=N[m];if(E.lastIndex=w,E.test(Z)){if(c=E===A1?b1(Z.slice(w,E.lastIndex)):E===E1?1:E.lastIndex-w,R=c*W0,T+R>h)x=Math.min(x,w+Math.floor((h-T)/W0));if(T+R>F){l=!0;break Z}T+=R,A=j,s=w,w=j=E.lastIndex;continue Z}}w+=1}return{width:l?h:T,index:l?x:k,truncated:l,ellipsed:l&&F>=H}},I1=D1;var J8={limit:1/0,ellipsis:"",ellipsisWidth:0},Q8=(Z,J={})=>{return I1(Z,J8,J).width},b=Q8;var G0="\x1B",h1="\x9B",F8=39,$0="\x07",v1="[",Y8="]",_1="m",p0=`${Y8}8;;`,x1=new RegExp(`(?:\\${v1}(?<code>\\d+)m|\\${p0}(?<uri>.*)${$0})`,"y"),T1=(Z)=>{if(Z>=30&&Z<=37)return 39;if(Z>=90&&Z<=97)return 39;if(Z>=40&&Z<=47)return 49;if(Z>=100&&Z<=107)return 49;if(Z===1||Z===2)return 22;if(Z===3)return 23;if(Z===4)return 24;if(Z===7)return 27;if(Z===8)return 28;if(Z===9)return 29;if(Z===0)return 0;return},S1=(Z)=>`${G0}${v1}${Z}${_1}`,k1=(Z)=>`${G0}${p0}${Z}${$0}`,y0=(Z,J,Q)=>{let F=J[Symbol.iterator](),Y=!1,H=!1,z=Z.at(-1),U=z===void 0?0:b(z),W=F.next(),L=F.next(),K=0;while(!W.done){let X=W.value,M=b(X);if(U+M<=Q)Z[Z.length-1]+=X;else Z.push(X),U=0;if(X===G0||X===h1)Y=!0,H=J.startsWith(p0,K+1);if(Y){if(H){if(X===$0)Y=!1,H=!1}else if(X===_1)Y=!1}else if(U+=M,U===Q&&!L.done)Z.push(""),U=0;W=L,L=F.next(),K+=X.length}if(z=Z.at(-1),!U&&z!==void 0&&z.length&&Z.length>1)Z[Z.length-2]+=Z.pop()},H8=(Z)=>{let J=Z.split(" "),Q=J.length;while(Q){if(b(J[Q-1]))break;Q--}if(Q===J.length)return Z;return J.slice(0,Q).join(" ")+J.slice(Q).join("")},W8=(Z,J,Q={})=>{if(Q.trim!==!1&&Z.trim()==="")return"";let F="",Y,H,z=Z.split(" "),U=[""],W=0;for(let X=0;X<z.length;X++){let M=z[X];if(Q.trim!==!1){let j=U.at(-1)??"",w=j.trimStart();if(j.length!==w.length)U[U.length-1]=w,W=b(w)}if(X!==0){if(W>=J&&(Q.wordWrap===!1||Q.trim===!1))U.push(""),W=0;if(W||Q.trim===!1)U[U.length-1]+=" ",W++}let N=b(M);if(Q.hard&&N>J){let j=J-W,w=1+Math.floor((N-j-1)/J);if(Math.floor((N-1)/J)<w)U.push("");y0(U,M,J),W=b(U.at(-1)??"");continue}if(W+N>J&&W&&N){if(Q.wordWrap===!1&&W<J){y0(U,M,J),W=b(U.at(-1)??"");continue}U.push(""),W=0}if(W+N>J&&Q.wordWrap===!1){y0(U,M,J),W=b(U.at(-1)??"");continue}U[U.length-1]+=M,W+=N}if(Q.trim!==!1)U=U.map((X)=>H8(X));let L=U.join(`
11
- `),K=!1;for(let X=0;X<L.length;X++){let M=L[X];if(F+=M,!K){if(K=M>="\uD800"&&M<="\uDBFF",K)continue}else K=!1;if(M===G0||M===h1){x1.lastIndex=X+1;let j=x1.exec(L)?.groups;if(j?.code!==void 0){let w=Number.parseFloat(j.code);Y=w===F8?void 0:w}else if(j?.uri!==void 0)H=j.uri.length===0?void 0:j.uri}if(L[X+1]===`
12
- `){if(H)F+=k1("");let N=Y?T1(Y):void 0;if(Y&&N)F+=S1(N)}else if(M===`
13
- `){if(Y&&T1(Y))F+=S1(Y);if(H)F+=k1(H)}}return F},z8=/\r?\n/;function p(Z,J,Q){return String(Z).normalize().split(z8).map((F)=>W8(F,J,Q)).join(`
14
- `)}var P=L1(c0(),1);import{ReadStream as y1}from"tty";function u0(Z,J,Q){if(!Q.some((z)=>!z.disabled))return Z;let F=Z+J,Y=Math.max(Q.length-1,0),H=F<0?Y:F>Y?0:F;return Q[H]?.disabled?u0(H,J<0?-1:1,Q):H}function j0(Z,J,Q,F){let Y=F.split(`
15
- `),H=0,z=Z;for(let W of Y){if(z<=W.length)break;z-=W.length+1,H++}for(H=Math.max(0,Math.min(Y.length-1,H+Q)),z=Math.min(z,Y[H].length)+J;z<0&&H>0;)H--,z+=Y[H].length+1;for(;z>Y[H].length&&H<Y.length-1;)z-=Y[H].length+1,H++;z=Math.max(0,Math.min(Y[H].length,z));let U=0;for(let W=0;W<H;W++)U+=Y[W].length+1;return U+z}var X8=["up","down","left","right","space","enter","cancel"],M8=["January","February","March","April","May","June","July","August","September","October","November","December"],O={actions:new Set(X8),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:[...M8],messages:{required:"Please enter a valid date",invalidMonth:"There are only 12 months in a year",invalidDay:(Z,J)=>`There are only ${Z} days in ${J}`,afterMin:(Z)=>`Date must be on or after ${Z.toISOString().slice(0,10)}`,beforeMax:(Z)=>`Date must be on or before ${Z.toISOString().slice(0,10)}`}}};function i0(Z,J){if(typeof Z=="string")return O.aliases.get(Z)===J;for(let Q of Z)if(Q!==void 0&&i0(Q,J))return!0;return!1}function G8(Z,J){if(Z===J)return;let Q=Z.split(`
16
- `),F=J.split(`
17
- `),Y=Math.max(Q.length,F.length),H=[];for(let z=0;z<Y;z++)Q[z]!==F[z]&&H.push(z);return{lines:H,numLinesBefore:Q.length,numLinesAfter:F.length,numLines:Y}}var j8=globalThis.process.platform.startsWith("win"),r0=Symbol("clack:cancel");function V0(Z){return Z===r0}function N0(Z,J){let Q=Z;Q.isTTY&&Q.setRawMode(J)}function c1({input:Z=g1,output:J=n0,overwrite:Q=!0,hideCursor:F=!0}={}){let Y=r.createInterface({input:Z,output:J,prompt:"",tabSize:1});r.emitKeypressEvents(Z,Y),Z instanceof y1&&Z.isTTY&&Z.setRawMode(!0);let H=(z,{name:U,sequence:W})=>{let L=String(z);if(i0([L,U,W],"cancel")){F&&J.write(P.cursor.show),process.exit(0);return}if(!Q)return;r.moveCursor(J,U==="return"?0:-1,U==="return"?-1:0,()=>{r.clearLine(J,1,()=>{Z.once("keypress",H)})})};return F&&J.write(P.cursor.hide),Z.once("keypress",H),()=>{Z.off("keypress",H),F&&J.write(P.cursor.show),Z instanceof y1&&Z.isTTY&&!j8&&Z.setRawMode(!1),Y.terminal=!1,Y.close()}}var B0=(Z)=>("columns"in Z)&&typeof Z.columns=="number"?Z.columns:80,l1=(Z)=>("rows"in Z)&&typeof Z.rows=="number"?Z.rows:20;function m1(Z,J,Q,F=Q,Y=Q,H){let z=B0(Z??n0);return p(J,z-Q.length,{hard:!0,trim:!1}).split(`
18
- `).map((U,W,L)=>{let K=H?H(U,W):U;return W===0?`${F}${K}`:W===L.length-1?`${Y}${K}`:`${Q}${K}`}).join(`
19
- `)}function u1(Z,J){if("~standard"in Z){let Q=Z["~standard"].validate(J);if(Q instanceof Promise)throw TypeError("Schema validation must be synchronous. Update `validate()` and remove any asynchronous logic.");return Q.issues?.at(0)?.message}return Z(J)}class a{input;output;_abortSignal;rl;opts;_render;_track=!1;_prevFrame="";_subscribers=new Map;_cursor=0;state="initial";error="";value;userInput="";constructor(Z,J=!0){let{input:Q=g1,output:F=n0,render:Y,signal:H,...z}=Z;this.opts=z,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=J,this._abortSignal=H,this.input=Q,this.output=F}unsubscribe(){this._subscribers.clear()}setSubscriber(Z,J){let Q=this._subscribers.get(Z)??[];Q.push(J),this._subscribers.set(Z,Q)}on(Z,J){this.setSubscriber(Z,{cb:J})}once(Z,J){this.setSubscriber(Z,{cb:J,once:!0})}emit(Z,...J){let Q=this._subscribers.get(Z)??[],F=[];for(let Y of Q)Y.cb(...J),Y.once&&F.push(()=>Q.splice(Q.indexOf(Y),1));for(let Y of F)Y()}prompt(){return new Promise((Z)=>{if(this._abortSignal){if(this._abortSignal.aborted)return this.state="cancel",this.close(),Z(r0);this._abortSignal.addEventListener("abort",()=>{this.state="cancel",this.close()},{once:!0})}this.rl=K8.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),N0(this.input,!0),this.output.on("resize",this.render),this.render(),this.once("submit",()=>{this.output.write(P.cursor.show),this.output.off("resize",this.render),N0(this.input,!1),Z(this.value)}),this.once("cancel",()=>{this.output.write(P.cursor.show),this.output.off("resize",this.render),N0(this.input,!1),Z(r0)})})}_isActionKey(Z,J){return Z==="\t"}_shouldSubmit(Z,J){return!0}_setValue(Z){this.value=Z,this.emit("value",this.value)}_setUserInput(Z,J){this.userInput=Z??"",this.emit("userInput",this.userInput),J&&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(Z,J){if(this._track&&J.name!=="return"&&(J.name&&this._isActionKey(Z,J)&&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"),J?.name&&(!this._track&&O.aliases.has(J.name)&&this.emit("cursor",O.aliases.get(J.name)),O.actions.has(J.name)&&this.emit("cursor",J.name)),Z&&(Z.toLowerCase()==="y"||Z.toLowerCase()==="n")&&this.emit("confirm",Z.toLowerCase()==="y"),this.emit("key",Z,J),J?.name==="return"&&this._shouldSubmit(Z,J)){if(this.opts.validate){let Q=u1(this.opts.validate,this.value);Q&&(this.error=Q instanceof Error?Q.message:Q,this.state="error",this.rl?.write(this.userInput))}this.state!=="error"&&(this.state="submit")}i0([Z,J?.name,J?.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(`
20
- `),N0(this.input,!1),this.rl?.close(),this.rl=void 0,this.emit(`${this.state}`,this.value),this.unsubscribe()}restoreCursor(){let Z=p(this._prevFrame,process.stdout.columns,{hard:!0,trim:!1}).split(`
21
- `).length-1;this.output.write(P.cursor.move(-999,Z*-1))}render(){let Z=p(this._render(this)??"",process.stdout.columns,{hard:!0,trim:!1});if(Z!==this._prevFrame){if(this.state==="initial")this.output.write(P.cursor.hide);else{let J=G8(this._prevFrame,Z),Q=l1(this.output);if(this.restoreCursor(),J){let F=Math.max(0,J.numLinesAfter-Q),Y=Math.max(0,J.numLinesBefore-Q),H=J.lines.find((z)=>z>=F);if(H===void 0){this._prevFrame=Z;return}if(J.lines.length===1){this.output.write(P.cursor.move(0,H-Y)),this.output.write(P.erase.lines(1));let z=Z.split(`
22
- `);this.output.write(z[H]),this._prevFrame=Z,this.output.write(P.cursor.move(0,z.length-H-1));return}else if(J.lines.length>1){if(F<Y)H=F;else{let U=H-Y;U>0&&this.output.write(P.cursor.move(0,U))}this.output.write(P.erase.down());let z=Z.split(`
23
- `).slice(H);this.output.write(z.join(`
24
- `)),this._prevFrame=Z;return}}this.output.write(P.erase.down())}this.output.write(Z),this.state==="initial"&&(this.state="active"),this._prevFrame=Z}}}function N8(Z,J){if(Z===void 0||J.length===0)return 0;let Q=J.findIndex((F)=>F.value===Z);return Q!==-1?Q:0}function w8(Z,J){return(J.label??String(J.value)).toLowerCase().includes(Z.toLowerCase())}function V8(Z,J){if(J)return Z?J:J[0]}var B8=class extends a{filteredOptions;multiple;isNavigating=!1;selectedValues=[];focusedValue;#J=0;#Y="";#Z;#H;#z;get cursor(){return this.#J}get userInputWithCursor(){if(!this.userInput)return m0(["inverse","hidden"],"_");if(this._cursor>=this.userInput.length)return`${this.userInput}\u2588`;let J=this.userInput.slice(0,this.cursor),Q=this.userInput.slice(this.cursor,this.cursor+1),F=this.userInput.slice(this.cursor+1);return`${J}${m0("inverse",Q)}${F}`}get options(){return typeof this.#H=="function"?this.#H():this.#H}constructor(J){super(J),this.#H=J.options,this.#z=J.placeholder;let Q=this.options;this.filteredOptions=[...Q],this.multiple=J.multiple===!0,this.#Z=typeof J.options=="function"?J.filter:J.filter??w8;let F;if(J.initialValue&&Array.isArray(J.initialValue)?this.multiple?F=J.initialValue:F=J.initialValue.slice(0,1):!this.multiple&&this.options.length>0&&(F=[this.options[0]?.value]),F)for(let Y of F){let H=Q.findIndex((z)=>z.value===Y);H!==-1&&(this.toggleSelected(Y),this.#J=H)}this.focusedValue=this.options[this.#J]?.value,this.on("key",(Y,H)=>this.#Q(Y,H)),this.on("userInput",(Y)=>this.#F(Y))}_isActionKey(J,Q){return J==="\t"||this.multiple&&this.isNavigating&&Q.name==="space"&&J!==void 0&&J!==""}#Q(J,Q){let F=Q.name==="up",Y=Q.name==="down",H=Q.name==="return",z=this.userInput===""||this.userInput==="\t",U=this.#z,W=this.options,L=U!==void 0&&U!==""&&W.some((K)=>!K.disabled&&(this.#Z?this.#Z(U,K):!0));if(Q.name==="tab"&&z&&L){this.userInput==="\t"&&this._clearUserInput(),this._setUserInput(U,!0),this.isNavigating=!1;return}F||Y?(this.#J=u0(this.#J,F?-1:1,this.filteredOptions),this.focusedValue=this.filteredOptions[this.#J]?.value,this.multiple||(this.selectedValues=[this.focusedValue]),this.isNavigating=!0):H?this.value=V8(this.multiple,this.selectedValues):this.multiple?this.focusedValue!==void 0&&(Q.name==="tab"||this.isNavigating&&Q.name==="space")?this.toggleSelected(this.focusedValue):this.isNavigating=!1:(this.focusedValue&&(this.selectedValues=[this.focusedValue]),this.isNavigating=!1)}deselectAll(){this.selectedValues=[]}toggleSelected(J){this.filteredOptions.length!==0&&(this.multiple?this.selectedValues.includes(J)?this.selectedValues=this.selectedValues.filter((Q)=>Q!==J):this.selectedValues=[...this.selectedValues,J]:this.selectedValues=[J])}#F(J){if(J!==this.#Y){this.#Y=J;let Q=this.options;J&&this.#Z?this.filteredOptions=Q.filter((H)=>this.#Z?.(J,H)):this.filteredOptions=[...Q];let F=N8(this.focusedValue,this.filteredOptions);this.#J=u0(F,0,this.filteredOptions);let Y=this.filteredOptions[this.#J];Y&&!Y.disabled?this.focusedValue=Y.value:this.focusedValue=void 0,this.multiple||(this.focusedValue!==void 0?this.toggleSelected(this.focusedValue):this.deselectAll())}}};class d0 extends a{get cursor(){return this.value?0:1}get _value(){return this.cursor===0}constructor(Z){super(Z,!1),this.value=!!Z.initialValue,this.on("userInput",()=>{this.value=this._value}),this.on("confirm",(J)=>{this.output.write(P.cursor.move(0,-1)),this.value=J,this.state="submit",this.close()}),this.on("cursor",()=>{this.value=!this.value})}}var q8={Y:{type:"year",len:4},M:{type:"month",len:2},D:{type:"day",len:2}};function $1(Z){return[...Z].map((J)=>q8[J])}function P8(Z){let J=new Intl.DateTimeFormat(Z,{year:"numeric",month:"2-digit",day:"2-digit"}).formatToParts(new Date(2000,0,15)),Q=[],F="/";for(let Y of J)Y.type==="literal"?F=Y.value.trim()||Y.value:(Y.type==="year"||Y.type==="month"||Y.type==="day")&&Q.push({type:Y.type,len:Y.type==="year"?4:2});return{segments:Q,separator:F}}function l0(Z){return Number.parseInt((Z||"0").replace(/_/g,"0"),10)||0}function w0(Z){return{year:l0(Z.year),month:l0(Z.month),day:l0(Z.day)}}function o0(Z,J){return new Date(Z||2001,J||1,0).getDate()}function r1(Z){let{year:J,month:Q,day:F}=w0(Z);if(!J||J<0||J>9999||!Q||Q<1||Q>12||!F||F<1)return;let Y=new Date(Date.UTC(J,Q-1,F));if(!(Y.getUTCFullYear()!==J||Y.getUTCMonth()!==Q-1||Y.getUTCDate()!==F))return{year:J,month:Q,day:F}}function p1(Z){let J=r1(Z);return J?new Date(Date.UTC(J.year,J.month-1,J.day)):void 0}function O8(Z,J,Q,F){let Y=Q?{year:Q.getUTCFullYear(),month:Q.getUTCMonth()+1,day:Q.getUTCDate()}:null,H=F?{year:F.getUTCFullYear(),month:F.getUTCMonth()+1,day:F.getUTCDate()}:null;return Z==="year"?{min:Y?.year??1,max:H?.year??9999}:Z==="month"?{min:Y&&J.year===Y.year?Y.month:1,max:H&&J.year===H.year?H.month:12}:{min:Y&&J.year===Y.year&&J.month===Y.month?Y.day:1,max:H&&J.year===H.year&&J.month===H.month?H.day:o0(J.year,J.month)}}class o1 extends a{#J;#Y;#Z;#H;#z;#Q={segmentIndex:0,positionInSegment:0};#F=!0;#W=null;inlineError="";get segmentCursor(){return{...this.#Q}}get segmentValues(){return{...this.#Z}}get segments(){return this.#J}get separator(){return this.#Y}get formattedValue(){return this.#X(this.#Z)}#X(Z){return this.#J.map((J)=>Z[J.type]).join(this.#Y)}#U(){this._setUserInput(this.#X(this.#Z)),this._setValue(p1(this.#Z)??void 0)}constructor(Z){let J=Z.format?{segments:$1(Z.format),separator:Z.separator??"/"}:P8(Z.locale),Q=Z.separator??J.separator,F=Z.format?$1(Z.format):J.segments,Y=Z.initialValue??Z.defaultValue,H=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:"__"},z=F.map((U)=>H[U.type]).join(Q);super({...Z,initialUserInput:z},!1),this.#J=F,this.#Y=Q,this.#Z=H,this.#H=Z.minDate,this.#z=Z.maxDate,this.#U(),this.on("cursor",(U)=>this.#j(U)),this.on("key",(U,W)=>this.#N(U,W)),this.on("finalize",()=>this.#w(Z))}#L(){let Z=Math.max(0,Math.min(this.#Q.segmentIndex,this.#J.length-1)),J=this.#J[Z];if(J)return this.#Q.positionInSegment=Math.max(0,Math.min(this.#Q.positionInSegment,J.len-1)),{segment:J,index:Z}}#K(Z){this.inlineError="",this.#W=null;let J=this.#L();J&&(this.#Q.segmentIndex=Math.max(0,Math.min(this.#J.length-1,J.index+Z)),this.#Q.positionInSegment=0,this.#F=!0)}#M(Z){let J=this.#L();if(!J)return;let{segment:Q}=J,F=this.#Z[Q.type],Y=!F||F.replace(/_/g,"")==="",H=Number.parseInt((F||"0").replace(/_/g,"0"),10)||0,z=O8(Q.type,w0(this.#Z),this.#H,this.#z),U;Y?U=Z===1?z.min:z.max:U=Math.max(Math.min(z.max,H+Z),z.min),this.#Z={...this.#Z,[Q.type]:U.toString().padStart(Q.len,"0")},this.#F=!0,this.#W=null,this.#U()}#j(Z){if(Z)switch(Z){case"right":return this.#K(1);case"left":return this.#K(-1);case"up":return this.#M(1);case"down":return this.#M(-1)}}#N(Z,J){if(J?.name==="backspace"||J?.sequence==="\x7F"||J?.sequence==="\b"||Z==="\x7F"||Z==="\b"){this.inlineError="";let Q=this.#L();if(!Q)return;if(!this.#Z[Q.segment.type].replace(/_/g,"")){this.#K(-1);return}this.#Z[Q.segment.type]="_".repeat(Q.segment.len),this.#F=!0,this.#Q.positionInSegment=0,this.#U();return}if(J?.name==="tab"){this.inlineError="";let Q=this.#L();if(!Q)return;let F=J.shift?-1:1,Y=Q.index+F;Y>=0&&Y<this.#J.length&&(this.#Q.segmentIndex=Y,this.#Q.positionInSegment=0,this.#F=!0);return}if(Z&&/^[0-9]$/.test(Z)){let Q=this.#L();if(!Q)return;let{segment:F}=Q,Y=!this.#Z[F.type].replace(/_/g,"");if(this.#F&&this.#W!==null&&!Y){let M=this.#W+Z,N={...this.#Z,[F.type]:M},j=this.#G(N,F);if(j){this.inlineError=j,this.#W=null,this.#F=!1;return}this.inlineError="",this.#Z[F.type]=M,this.#W=null,this.#F=!1,this.#U(),Q.index<this.#J.length-1&&(this.#Q.segmentIndex=Q.index+1,this.#Q.positionInSegment=0,this.#F=!0);return}this.#F&&!Y&&(this.#Z[F.type]="_".repeat(F.len),this.#Q.positionInSegment=0),this.#F=!1,this.#W=null;let H=this.#Z[F.type],z=H.indexOf("_"),U=z>=0?z:Math.min(this.#Q.positionInSegment,F.len-1);if(U<0||U>=F.len)return;let W=H.slice(0,U)+Z+H.slice(U+1),L=!1;if(U===0&&H==="__"&&(F.type==="month"||F.type==="day")){let M=Number.parseInt(Z,10);W=`0${Z}`,L=M<=(F.type==="month"?1:2)}if(F.type==="year"&&(W=(H.replace(/_/g,"")+Z).padStart(F.len,"_")),!W.includes("_")){let M={...this.#Z,[F.type]:W},N=this.#G(M,F);if(N){this.inlineError=N;return}}this.inlineError="",this.#Z[F.type]=W;let K=W.includes("_")?void 0:r1(this.#Z);if(K){let{year:M,month:N}=K,j=o0(M,N);this.#Z={year:String(Math.max(0,Math.min(9999,M))).padStart(4,"0"),month:String(Math.max(1,Math.min(12,N))).padStart(2,"0"),day:String(Math.max(1,Math.min(j,K.day))).padStart(2,"0")}}this.#U();let X=W.indexOf("_");L?(this.#F=!0,this.#W=Z):X>=0?this.#Q.positionInSegment=X:z>=0&&Q.index<this.#J.length-1?(this.#Q.segmentIndex=Q.index+1,this.#Q.positionInSegment=0,this.#F=!0):this.#Q.positionInSegment=Math.min(U+1,F.len-1)}}#G(Z,J){let{month:Q,day:F}=w0(Z);if(J.type==="month"&&(Q<0||Q>12))return O.date.messages.invalidMonth;if(J.type==="day"&&(F<0||F>31))return O.date.messages.invalidDay(31,"any month")}#w(Z){let{year:J,month:Q,day:F}=w0(this.#Z);if(J&&Q&&F){let Y=o0(J,Q);this.#Z={...this.#Z,day:String(Math.min(F,Y)).padStart(2,"0")}}this.value=p1(this.#Z)??Z.defaultValue??void 0}}var b8=class extends a{options;cursor=0;#J;getGroupItems(J){return this.options.filter((Q)=>Q.group===J)}isGroupSelected(J){let Q=this.getGroupItems(J),F=this.value;return F===void 0?!1:Q.every((Y)=>F.includes(Y.value))}toggleValue(){let J=this.options[this.cursor];if(J!==void 0)if(this.value===void 0&&(this.value=[]),J.group===!0){let Q=J.value,F=this.getGroupItems(Q);this.isGroupSelected(Q)?this.value=this.value.filter((Y)=>F.findIndex((H)=>H.value===Y)===-1):this.value=[...this.value,...F.map((Y)=>Y.value)],this.value=Array.from(new Set(this.value))}else{let Q=this.value.includes(J.value);this.value=Q?this.value.filter((F)=>F!==J.value):[...this.value,J.value]}}constructor(J){super(J,!1);let{options:Q}=J;this.#J=J.selectableGroups!==!1,this.options=Object.entries(Q).flatMap(([F,Y])=>[{value:F,group:!0,label:F},...Y.map((H)=>({...H,group:F}))]),this.value=[...J.initialValues??[]],this.cursor=Math.max(this.options.findIndex(({value:F})=>F===J.cursorAt),this.#J?0:1),this.on("cursor",(F)=>{switch(F){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.#J&&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.#J&&Y&&(this.cursor=this.cursor===this.options.length-1?0:this.cursor+1);break}case"space":this.toggleValue();break}})}},C8=new Set(["up","down","left","right"]);class n1 extends a{#J=!1;#Y;focused="editor";get userInputWithCursor(){if(this.state==="submit")return this.userInput;let Z=this.userInput;if(this.cursor>=Z.length)return`${Z}\u2588`;let J=Z.slice(0,this.cursor),Q=Z.slice(this.cursor,this.cursor+1),F=Z.slice(this.cursor+1);return Q===`
25
- `?`${J}\u2588
26
- ${F}`:`${J}${m0("inverse",Q)}${F}`}get cursor(){return this._cursor}#Z(Z){if(this.userInput.length===0){this._setUserInput(Z);return}this._setUserInput(this.userInput.slice(0,this.cursor)+Z+this.userInput.slice(this.cursor))}#H(Z){let J=this.value??"";switch(Z){case"up":this._cursor=j0(this._cursor,0,-1,J);return;case"down":this._cursor=j0(this._cursor,0,1,J);return;case"left":this._cursor=j0(this._cursor,-1,0,J);return;case"right":this._cursor=j0(this._cursor,1,0,J);return}}_shouldSubmit(Z,J){if(this.#Y)return this.focused==="submit"?!0:(this.#Z(`
27
- `),this._cursor++,!1);let Q=this.#J;return this.#J=!0,Q&&this.cursor===this.userInput.length?(this.userInput[this.cursor-1]===`
28
- `&&(this._setUserInput(this.userInput.slice(0,this.cursor-1)+this.userInput.slice(this.cursor)),this._cursor--),!0):(this.#Z(`
29
- `),this._cursor++,!1)}constructor(Z){let J=Z.initialUserInput??Z.initialValue;super({...Z,initialUserInput:J},!1),J!==void 0&&(this._cursor=J.length),this.#Y=Z.showSubmit??!1,this.on("key",(Q,F)=>{if(F?.name&&C8.has(F.name)){this.#J=!1,this.#H(F.name);return}if(Q==="\t"&&this.#Y){this.focused=this.focused==="editor"?"submit":"editor";return}if(F?.name!=="return"){if(this.#J=!1,F?.name==="backspace"&&this.cursor>0){this._setUserInput(this.userInput.slice(0,this.cursor-1)+this.userInput.slice(this.cursor)),this._cursor--;return}if(F?.name==="delete"&&this.cursor<this.userInput.length){this._setUserInput(this.userInput.slice(0,this.cursor)+this.userInput.slice(this.cursor+1));return}Q&&(this.#Y&&this.focused==="submit"&&(this.focused="editor"),this.#Z(Q??""),this._cursor++)}}),this.on("userInput",(Q)=>{this._setValue(Q)}),this.on("finalize",()=>{this.value||(this.value=Z.defaultValue),this.value===void 0&&(this.value="")})}}import{styleText as G,stripVTControlCharacters as i6}from"util";import I from"process";var F0=L1(c0(),1);function R8(){if(I.platform!=="win32")return I.env.TERM!=="linux";return Boolean(I.env.CI)||Boolean(I.env.WT_SESSION)||Boolean(I.env.TERMINUS_SUBLIME)||I.env.ConEmuTask==="{cmd::Cmder}"||I.env.TERM_PROGRAM==="Terminus-Sublime"||I.env.TERM_PROGRAM==="vscode"||I.env.TERM==="xterm-256color"||I.env.TERM==="alacritty"||I.env.TERMINAL_EMULATOR==="JetBrains-JediTerm"}var s0=R8(),A8=()=>process.env.CI==="true";var V=(Z,J)=>s0?Z:J,E8=V("\u25C6","*"),a1=V("\u25A0","x"),e1=V("\u25B2","x"),q0=V("\u25C7","o"),D8=V("\u250C","T"),C=V("\u2502","|"),t1=V("\u2514","\u2014"),e6=V("\u2510","T"),t6=V("\u2518","\u2014"),i1=V("\u25CF",">"),d1=V("\u25CB"," "),Z7=V("\u25FB","[\u2022]"),J7=V("\u25FC","[+]"),Q7=V("\u25FB","[ ]"),F7=V("\u25AA","\u2022"),s1=V("\u2500","-"),I8=V("\u256E","+"),x8=V("\u251C","+"),T8=V("\u256F","+"),S8=V("\u2570","+"),Y7=V("\u256D","+"),k8=V("\u25CF","\u2022"),h8=V("\u25C6","*"),v8=V("\u25B2","!"),_8=V("\u25A0","x"),f8=(Z)=>{switch(Z){case"initial":case"active":return G("cyan",E8);case"cancel":return G("red",a1);case"error":return G("yellow",e1);case"submit":return G("green",q0)}};var Z9=(Z)=>{let J=Z.active??"Yes",Q=Z.inactive??"No";return new d0({active:J,inactive:Q,signal:Z.signal,input:Z.input,output:Z.output,initialValue:Z.initialValue??!0,render(){let F=Z.withGuide??O.withGuide,Y=`${f8(this.state)} `,H=F?`${G("gray",C)} `:"",z=m1(Z.output,Z.message,H,Y),U=`${F?`${G("gray",C)}
30
- `:""}${z}
31
- `,W=this.value?J:Q;switch(this.state){case"submit":{let L=F?`${G("gray",C)} `:"";return`${U}${L}${G("dim",W)}`}case"cancel":{let L=F?`${G("gray",C)} `:"";return`${U}${L}${G(["strikethrough","dim"],W)}${F?`
32
- ${G("gray",C)}`:""}`}default:{let L=F?`${G("cyan",C)} `:"",K=F?G("cyan",t1):"";return`${U}${L}${this.value?`${G("green",i1)} ${J}`:`${G("dim",d1)} ${G("dim",J)}`}${Z.vertical?F?`
33
- ${G("cyan",C)} `:`
34
- `:` ${G("dim","/")} `}${this.value?`${G("dim",d1)} ${G("dim",Q)}`:`${G("green",i1)} ${Q}`}
35
- ${K}
36
- `}}}}).prompt()};var H7=[`${G("dim","\u2191/\u2193")} to navigate`,`${G("dim","Space:")} select`,`${G("dim","Enter:")} confirm`];var B={message:(Z=[],{symbol:J=G("gray",C),secondarySymbol:Q=G("gray",C),output:F=process.stdout,spacing:Y=1,withGuide:H}={})=>{let z=[],U=H??O.withGuide,W=U?Q:"",L=U?`${J} `:"",K=U?`${Q} `:"";for(let M=0;M<Y;M++)z.push(W);let X=Array.isArray(Z)?Z:Z.split(`
37
- `);if(X.length>0){let[M,...N]=X;M.length>0?z.push(`${L}${M}`):z.push(U?J:"");for(let j of N)j.length>0?z.push(`${K}${j}`):z.push(U?Q:"")}F.write(`${z.join(`
10
+ `))}outputVersion(){let{name:e}=this.cli,{versionNumber:t}=this.cli.globalCommand;if(t)console.info(`${e}/${t} ${le}`)}checkRequiredArgs(){let e=this.args.filter((t)=>t.required).length;if(this.cli.args.length<e)throw new ae(`missing required args for command \`${this.rawName}\``)}checkUnknownOptions(){let{options:e,globalCommand:t}=this.cli;if(!this.config.allowUnknownOptions){for(let n of Object.keys(e))if(n!=="--"&&!this.hasOption(n)&&!t.hasOption(n))throw new ae(`Unknown option \`${n.length>1?`--${n}`:`-${n}`}\``)}}checkOptionValue(){let{options:e,globalCommand:t}=this.cli,n=[...t.options,...this.options];for(let s of n){let r=e[s.name.split(".")[0]];if(s.required){let u=n.some((o)=>o.negated&&o.names.includes(s.name));if(r===!0||r===!1&&!u)throw new ae(`option \`${s.rawName}\` value is missing`)}}}checkUnusedArgs(){let e=this.args.some((t)=>t.variadic)?1/0:this.args.length;if(e<this.cli.args.length)throw new ae(`Unused args: ${this.cli.args.slice(e).map((t)=>`\`${t}\``).join(", ")}`)}},lt=class extends at{constructor(e){super("@@global@@","",{},e)}},Fn=class extends EventTarget{name;commands;globalCommand;matchedCommand;matchedCommandName;rawArgs;args;options;showHelpOnExit;showVersionOnExit;constructor(e=""){super();this.name=e,this.commands=[],this.rawArgs=[],this.args=[],this.options={},this.globalCommand=new lt(this),this.globalCommand.usage("<command> [options]")}usage(e){return this.globalCommand.usage(e),this}command(e,t,n){let s=new at(e,t||"",n,this);return s.globalCommand=this.globalCommand,this.commands.push(s),s}option(e,t,n){return this.globalCommand.option(e,t,n),this}help(e){return this.globalCommand.option("-h, --help","Display this message"),this.globalCommand.helpCallback=e,this.showHelpOnExit=!0,this}version(e,t="-v, --version"){return this.globalCommand.version(e,t),this.showVersionOnExit=!0,this}example(e){return this.globalCommand.example(e),this}outputHelp(){if(this.matchedCommand)this.matchedCommand.outputHelp();else this.globalCommand.outputHelp()}outputVersion(){this.globalCommand.outputVersion()}setParsedInfo({args:e,options:t},n,s){if(this.args=e,this.options=t,n)this.matchedCommand=n;if(s)this.matchedCommandName=s;return this}unsetMatchedCommand(){this.matchedCommand=void 0,this.matchedCommandName=void 0}parse(e,{run:t=!0}={}){if(!e){if(!De)throw Error("No argv provided and runtime process argv is not available.");e=De}if(this.rawArgs=e,!this.name)this.name=e[1]?Mn(e[1]):"cli";let n=!0;for(let r of this.commands){let u=this.mri(e.slice(2),r),o=u.args[0];if(r.isMatched(o)){n=!1;let a={...u,args:u.args.slice(1)};this.setParsedInfo(a,r,o),this.dispatchEvent(new CustomEvent(`command:${o}`,{detail:r}))}}if(n){for(let r of this.commands)if(r.isDefaultCommand){n=!1;let u=this.mri(e.slice(2),r);this.setParsedInfo(u,r),this.dispatchEvent(new CustomEvent("command:!",{detail:r}))}}if(n){let r=this.mri(e.slice(2));this.setParsedInfo(r)}if(this.options.help&&this.showHelpOnExit)this.outputHelp(),t=!1,this.unsetMatchedCommand();if(this.options.version&&this.showVersionOnExit&&this.matchedCommandName==null)this.outputVersion(),t=!1,this.unsetMatchedCommand();let s={args:this.args,options:this.options};if(t)this.runMatchedCommand();if(!this.matchedCommand&&this.args[0])this.dispatchEvent(new CustomEvent("command:*",{detail:this.args[0]}));return s}mri(e,t){let n=[...this.globalCommand.options,...t?t.options:[]],s=Sn(n),r=[],u=e.indexOf("--");if(u!==-1)r=e.slice(u+1),e=e.slice(0,u);let o=En(e,s);o=Object.keys(o).reduce((f,h)=>({...f,[ot(h)]:o[h]}),{_:[]});let a=o._,i={"--":r},l=t&&t.config.ignoreOptionDefaultValue?t.config.ignoreOptionDefaultValue:this.globalCommand.config.ignoreOptionDefaultValue,c=Object.create(null);for(let f of n){if(!l&&f.config.default!==void 0)for(let h of f.names)i[h]=f.config.default;if(Array.isArray(f.config.type)&&c[f.name]===void 0)c[f.name]=Object.create(null),c[f.name].shouldTransform=!0,c[f.name].transformFunction=f.config.type[0]}for(let f of Object.keys(o))if(f!=="_")An(i,f.split("."),o[f]),On(i,c);return{args:a,options:i}}runMatchedCommand(){let{args:e,options:t,matchedCommand:n}=this;if(!n||!n.commandAction)return;n.checkUnknownOptions(),n.checkOptionValue(),n.checkRequiredArgs(),n.checkUnusedArgs();let s=[];return n.args.forEach((r,u)=>{if(r.variadic)s.push(e.slice(u));else s.push(e[u])}),s.push(t),n.commandAction.apply(this,s)}},ct=(e="")=>new Fn(e);import nr from"path";var ce,jn={lang:void 0,message:void 0,abortEarly:void 0,abortPipeEarly:void 0};function ht(e){if(!e&&!ce)return jn;return{lang:e?.lang??ce?.lang,message:e?.message,abortEarly:e?.abortEarly??ce?.abortEarly,abortPipeEarly:e?.abortPipeEarly??ce?.abortPipeEarly}}var Tn;function Rn(e){return Tn?.get(e)}var Pn;function Nn(e){return Pn?.get(e)}var Vn;function Ln(e,t){return Vn?.get(e)?.get(t)}function Fe(e){let t=typeof e;if(t==="string")return`"${e}"`;if(t==="number"||t==="bigint"||t==="boolean")return`${e}`;if(t==="object"||t==="function")return(e&&Object.getPrototypeOf(e)?.constructor?.name)??"null";return t}function P(e,t,n,s,r){let u=r&&"input"in r?r.input:n.value,o=r?.expected??e.expects??null,a=r?.received??Fe(u),i={kind:e.kind,type:e.type,input:u,expected:o,received:a,message:`Invalid ${t}: ${o?`Expected ${o} but r`:"R"}eceived ${a}`,requirement:e.requirement,path:r?.path,issues:r?.issues,lang:s.lang,abortEarly:s.abortEarly,abortPipeEarly:s.abortPipeEarly},l=e.kind==="schema",c=r?.message??e.message??Ln(e.reference,i.lang)??(l?Nn(i.lang):null)??s.message??Rn(i.lang);if(c!==void 0)i.message=typeof c==="function"?c(i):c;if(l)n.typed=!1;if(n.issues)n.issues.push(i);else n.issues=[i]}var ft=new WeakMap;function N(e){let t=ft.get(e);if(!t)t={version:1,vendor:"valibot",validate(n){return e["~run"]({value:n},ht())}},ft.set(e,t);return t}function mt(e,t){let n=[...new Set(e)];if(n.length>1)return`(${n.join(` ${t} `)})`;return n[0]??"never"}var je=class extends Error{constructor(e){super(e[0].message);this.name="ValiError",this.issues=e}};function Gn(e,t,n){return typeof e.fallback==="function"?e.fallback(t,n):e.fallback}function yt(e,t,n){return typeof e.default==="function"?e.default(t,n):e.default}function V(e,t){return{kind:"schema",type:"array",reference:V,expects:"Array",async:!1,item:e,message:t,get "~standard"(){return N(this)},"~run"(n,s){let r=n.value;if(Array.isArray(r)){n.typed=!0,n.value=[];for(let u=0;u<r.length;u++){let o=r[u],a=this.item["~run"]({value:o},s);if(a.issues){let i={type:"array",origin:"value",input:r,key:u,value:o};for(let l of a.issues){if(l.path)l.path.unshift(i);else l.path=[i];n.issues?.push(l)}if(!n.issues)n.issues=a.issues;if(s.abortEarly){n.typed=!1;break}}if(!a.typed)n.typed=!1;n.value.push(a.value)}}else P(this,"type",n,s);return n}}}function Q(e){return{kind:"schema",type:"boolean",reference:Q,expects:"boolean",async:!1,message:e,get "~standard"(){return N(this)},"~run"(t,n){if(typeof t.value==="boolean")t.typed=!0;else P(this,"type",t,n);return t}}}function Te(e,t){return{kind:"schema",type:"literal",reference:Te,expects:Fe(e),async:!1,literal:e,message:t,get "~standard"(){return N(this)},"~run"(n,s){if(n.value===this.literal)n.typed=!0;else P(this,"type",n,s);return n}}}function z(e,t){return{kind:"schema",type:"object",reference:z,expects:"Object",async:!1,entries:e,message:t,get "~standard"(){return N(this)},"~run"(n,s){let r=n.value;if(r&&typeof r==="object"){n.typed=!0,n.value={};for(let u in this.entries){let o=this.entries[u];if(u in r||(o.type==="exact_optional"||o.type==="optional"||o.type==="nullish")&&o.default!==void 0){let a=u in r?r[u]:yt(o),i=o["~run"]({value:a},s);if(i.issues){let l={type:"object",origin:"value",input:r,key:u,value:a};for(let c of i.issues){if(c.path)c.path.unshift(l);else c.path=[l];n.issues?.push(c)}if(!n.issues)n.issues=i.issues;if(s.abortEarly){n.typed=!1;break}}if(!i.typed)n.typed=!1;n.value[u]=i.value}else if(o.fallback!==void 0)n.value[u]=Gn(o);else if(o.type!=="exact_optional"&&o.type!=="optional"&&o.type!=="nullish"){if(P(this,"key",n,s,{input:void 0,expected:`"${u}"`,path:[{type:"object",origin:"key",input:r,key:u,value:r[u]}]}),s.abortEarly)break}}}else P(this,"type",n,s);return n}}}function ee(e,t){return{kind:"schema",type:"optional",reference:ee,expects:`(${e.expects} | undefined)`,async:!1,wrapped:e,default:t,get "~standard"(){return N(this)},"~run"(n,s){if(n.value===void 0){if(this.default!==void 0)n.value=yt(this,n,s);if(n.value===void 0)return n.typed=!0,n}return this.wrapped["~run"](n,s)}}}function te(e,t){return{kind:"schema",type:"picklist",reference:te,expects:mt(e.map(Fe),"|"),async:!1,options:e,message:t,get "~standard"(){return N(this)},"~run"(n,s){if(this.options.includes(n.value))n.typed=!0;else P(this,"type",n,s);return n}}}function D(e){return{kind:"schema",type:"string",reference:D,expects:"string",async:!1,message:e,get "~standard"(){return N(this)},"~run"(t,n){if(typeof t.value==="string")t.typed=!0;else P(this,"type",t,n);return t}}}function pt(e){let t;if(e)for(let n of e)if(t)for(let s of n.issues)t.push(s);else t=n.issues;return t}function ne(e,t){return{kind:"schema",type:"union",reference:ne,expects:mt(e.map((n)=>n.expects),"|"),async:!1,options:e,message:t,get "~standard"(){return N(this)},"~run"(n,s){let r,u,o;for(let a of this.options){let i=a["~run"]({value:n.value},s);if(i.typed)if(i.issues)if(u)u.push(i);else u=[i];else{r=i;break}else if(o)o.push(i);else o=[i]}if(r)return r;if(u){if(u.length===1)return u[0];P(this,"type",n,s,{issues:pt(u)}),n.typed=!0}else if(o?.length===1)return o[0];else P(this,"type",n,s,{issues:pt(o)});return n}}}function fe(e,t,n){let s=e["~run"]({value:t},ht(n));if(s.issues)throw new je(s.issues);return s.value}function Re(e,t){let n={};for(let s in e.entries)n[s]=!t||t.includes(s)?ee(e.entries[s]):e.entries[s];return{...e,entries:n,get "~standard"(){return N(this)}}}import{stdout as Ue,stdin as Dt}from"process";import*as H from"readline";import ss from"readline";var dt=(()=>{let e=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g;return(t)=>{let n=0;e.lastIndex=0;while(e.test(t))n+=1;return t.length-n}})(),gt=(e)=>e===12288||e>=65281&&e<=65376||e>=65504&&e<=65510,vt=(e)=>e===8987||e===9001||e>=12272&&e<=12287||e>=12289&&e<=12350||e>=12441&&e<=12543||e>=12549&&e<=12591||e>=12593&&e<=12686||e>=12688&&e<=12771||e>=12783&&e<=12830||e>=12832&&e<=12871||e>=12880&&e<=19903||e>=65040&&e<=65049||e>=65072&&e<=65106||e>=65108&&e<=65126||e>=65128&&e<=65131||e>=127488&&e<=127490||e>=127504&&e<=127547||e>=127552&&e<=127560||e>=131072&&e<=196605||e>=196608&&e<=262141;var qn=/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]|\u001b\]8;[^;]*;.*?(?:\u0007|\u001b\u005c)/y,Un=/[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y,$t=/(?:(?![\uFF61-\uFF9F\uFF00-\uFFEF])[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}\p{Script=Tangut}]){1,1000}/yu,Bn=/\t{1,1000}/y,bt=/[\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,Wn=/(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y,zn=/\p{M}+/gu,Hn={limit:1/0,ellipsis:""},kt=(e,t={},n={})=>{let s=t.limit??1/0,r=t.ellipsis??"",u=t?.ellipsisWidth??(r?kt(r,Hn,n).width:0),o=0,a=n.controlWidth??0,i=n.tabWidth??8,l=n.emojiWidth??2,c=2,f=n.regularWidth??1,h=n.wideWidth??2,g=[[Wn,f],[qn,0],[Un,a],[Bn,i],[bt,l],[$t,h]],m=0,y=0,F=e.length,U=0,B=!1,O=F,j=Math.max(0,s-u),I=0,Z=0,M=0,E=0;e:while(!0){if(Z>I||y>=F&&y>m){let W=e.slice(I,Z)||e.slice(m,y);U=0;for(let X of W.replaceAll(zn,"")){let S=X.codePointAt(0)||0;if(gt(S))E=2;else if(vt(S))E=h;else E=f;if(M+E>j)O=Math.min(O,Math.max(I,m)+U);if(M+E>s){B=!0;break e}U+=X.length,M+=E}I=Z=0}if(y>=F)break e;for(let W=0,X=g.length;W<X;W++){let[S,ue]=g[W];if(S.lastIndex=y,S.test(e)){if(U=S===$t?dt(e.slice(y,S.lastIndex)):S===bt?1:S.lastIndex-y,E=U*ue,M+E>j)O=Math.min(O,y+Math.floor((j-M)/ue));if(M+E>s){B=!0;break e}M+=E,I=m,Z=y,y=m=S.lastIndex;continue e}}y+=1}return{width:B?j:M,index:B?O:F,truncated:B,ellipsed:B&&s>=u}},wt=kt;var Kn={limit:1/0,ellipsis:"",ellipsisWidth:0},Xn=(e,t={})=>wt(e,Kn,t).width,w=Xn;var he="\x1B",St="\x9B",Jn=39,Ne="\x07",Ct="[",Zn="]",At="m",Ve=`${Zn}8;;`,xt=new RegExp(`(?:\\${Ct}(?<code>\\d+)m|\\${Ve}(?<uri>.*)${Ne})`,"y"),_t=(e)=>{if(e>=30&&e<=37)return 39;if(e>=90&&e<=97)return 39;if(e>=40&&e<=47)return 49;if(e>=100&&e<=107)return 49;if(e===1||e===2)return 22;if(e===3)return 23;if(e===4)return 24;if(e===7)return 27;if(e===8)return 28;if(e===9)return 29;if(e===0)return 0;return},Et=(e)=>`${he}${Ct}${e}${At}`,It=(e)=>`${he}${Ve}${e}${Ne}`,Pe=(e,t,n)=>{let s=t[Symbol.iterator](),r=!1,u=!1,o=e.at(-1),a=o===void 0?0:w(o),i=s.next(),l=s.next(),c=0;while(!i.done){let f=i.value,h=w(f);if(a+h<=n)e[e.length-1]+=f;else e.push(f),a=0;if(f===he||f===St)r=!0,u=t.startsWith(Ve,c+1);if(r){if(u){if(f===Ne)r=!1,u=!1}else if(f===At)r=!1}else if(a+=h,a===n&&!l.done)e.push(""),a=0;i=l,l=s.next(),c+=f.length}if(o=e.at(-1),!a&&o!==void 0&&o.length&&e.length>1)e[e.length-2]+=e.pop()},Yn=(e)=>{let t=e.split(" "),n=t.length;while(n){if(w(t[n-1]))break;n--}if(n===t.length)return e;return t.slice(0,n).join(" ")+t.slice(n).join("")},Qn=(e,t,n={})=>{if(n.trim!==!1&&e.trim()==="")return"";let s="",r,u,o=e.split(" "),a=[""],i=0;for(let f=0;f<o.length;f++){let h=o[f];if(n.trim!==!1){let m=a.at(-1)??"",y=m.trimStart();if(m.length!==y.length)a[a.length-1]=y,i=w(y)}if(f!==0){if(i>=t&&(n.wordWrap===!1||n.trim===!1))a.push(""),i=0;if(i||n.trim===!1)a[a.length-1]+=" ",i++}let g=w(h);if(n.hard&&g>t){let m=t-i,y=1+Math.floor((g-m-1)/t);if(Math.floor((g-1)/t)<y)a.push("");Pe(a,h,t),i=w(a.at(-1)??"");continue}if(i+g>t&&i&&g){if(n.wordWrap===!1&&i<t){Pe(a,h,t),i=w(a.at(-1)??"");continue}a.push(""),i=0}if(i+g>t&&n.wordWrap===!1){Pe(a,h,t),i=w(a.at(-1)??"");continue}a[a.length-1]+=h,i+=g}if(n.trim!==!1)a=a.map((f)=>Yn(f));let l=a.join(`
11
+ `),c=!1;for(let f=0;f<l.length;f++){let h=l[f];if(s+=h,!c){if(c=h>="\uD800"&&h<="\uDBFF",c)continue}else c=!1;if(h===he||h===St){xt.lastIndex=f+1;let m=xt.exec(l)?.groups;if(m?.code!==void 0){let y=Number.parseFloat(m.code);r=y===Jn?void 0:y}else if(m?.uri!==void 0)u=m.uri.length===0?void 0:m.uri}if(l[f+1]===`
12
+ `){if(u)s+=It("");let g=r?_t(r):void 0;if(r&&g)s+=Et(g)}else if(h===`
13
+ `){if(r&&_t(r))s+=Et(r);if(u)s+=It(u)}}return s},es=/\r?\n/;function L(e,t,n){return String(e).normalize().split(es).map((s)=>Qn(s,t,n)).join(`
14
+ `)}var k=st(Ge(),1);import{ReadStream as Mt}from"tty";var rs=["up","down","left","right","space","enter","cancel"],is=["January","February","March","April","May","June","July","August","September","October","November","December"],_={actions:new Set(rs),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:[...is],messages:{required:"Please enter a valid date",invalidMonth:"There are only 12 months in a year",invalidDay:(e,t)=>`There are only ${e} days in ${t}`,afterMin:(e)=>`Date must be on or after ${e.toISOString().slice(0,10)}`,beforeMax:(e)=>`Date must be on or before ${e.toISOString().slice(0,10)}`}}};function Be(e,t){if(typeof e=="string")return _.aliases.get(e)===t;for(let n of e)if(n!==void 0&&Be(n,t))return!0;return!1}function us(e,t){if(e===t)return;let n=e.split(`
15
+ `),s=t.split(`
16
+ `),r=Math.max(n.length,s.length),u=[];for(let o=0;o<r;o++)n[o]!==s[o]&&u.push(o);return{lines:u,numLinesBefore:n.length,numLinesAfter:s.length,numLines:r}}var os=globalThis.process.platform.startsWith("win"),qe=Symbol("clack:cancel");function ye(e){return e===qe}function me(e,t){let n=e;n.isTTY&&n.setRawMode(t)}function Ft({input:e=Dt,output:t=Ue,overwrite:n=!0,hideCursor:s=!0}={}){let r=H.createInterface({input:e,output:t,prompt:"",tabSize:1});H.emitKeypressEvents(e,r),e instanceof Mt&&e.isTTY&&e.setRawMode(!0);let u=(o,{name:a,sequence:i})=>{let l=String(o);if(Be([l,a,i],"cancel")){s&&t.write(k.cursor.show),process.exit(0);return}if(!n)return;H.moveCursor(t,a==="return"?0:-1,a==="return"?-1:0,()=>{H.clearLine(t,1,()=>{e.once("keypress",u)})})};return s&&t.write(k.cursor.hide),e.once("keypress",u),()=>{e.off("keypress",u),s&&t.write(k.cursor.show),e instanceof Mt&&e.isTTY&&!os&&e.setRawMode(!1),r.terminal=!1,r.close()}}var de=(e)=>("columns"in e)&&typeof e.columns=="number"?e.columns:80,jt=(e)=>("rows"in e)&&typeof e.rows=="number"?e.rows:20;function Tt(e,t,n,s=n,r=n,u){let o=de(e??Ue);return L(t,o-n.length,{hard:!0,trim:!1}).split(`
17
+ `).map((a,i,l)=>{let c=u?u(a,i):a;return i===0?`${s}${c}`:i===l.length-1?`${r}${c}`:`${n}${c}`}).join(`
18
+ `)}function Rt(e,t){if("~standard"in e){let n=e["~standard"].validate(t);if(n instanceof Promise)throw TypeError("Schema validation must be synchronous. Update `validate()` and remove any asynchronous logic.");return n.issues?.at(0)?.message}return e(t)}class Pt{input;output;_abortSignal;rl;opts;_render;_track=!1;_prevFrame="";_subscribers=new Map;_cursor=0;state="initial";error="";value;userInput="";constructor(e,t=!0){let{input:n=Dt,output:s=Ue,render:r,signal:u,...o}=e;this.opts=o,this.onKeypress=this.onKeypress.bind(this),this.close=this.close.bind(this),this.render=this.render.bind(this),this._render=r.bind(this),this._track=t,this._abortSignal=u,this.input=n,this.output=s}unsubscribe(){this._subscribers.clear()}setSubscriber(e,t){let n=this._subscribers.get(e)??[];n.push(t),this._subscribers.set(e,n)}on(e,t){this.setSubscriber(e,{cb:t})}once(e,t){this.setSubscriber(e,{cb:t,once:!0})}emit(e,...t){let n=this._subscribers.get(e)??[],s=[];for(let r of n)r.cb(...t),r.once&&s.push(()=>n.splice(n.indexOf(r),1));for(let r of s)r()}prompt(){return new Promise((e)=>{if(this._abortSignal){if(this._abortSignal.aborted)return this.state="cancel",this.close(),e(qe);this._abortSignal.addEventListener("abort",()=>{this.state="cancel",this.close()},{once:!0})}this.rl=ss.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),me(this.input,!0),this.output.on("resize",this.render),this.render(),this.once("submit",()=>{this.output.write(k.cursor.show),this.output.off("resize",this.render),me(this.input,!1),e(this.value)}),this.once("cancel",()=>{this.output.write(k.cursor.show),this.output.off("resize",this.render),me(this.input,!1),e(qe)})})}_isActionKey(e,t){return e==="\t"}_shouldSubmit(e,t){return!0}_setValue(e){this.value=e,this.emit("value",this.value)}_setUserInput(e,t){this.userInput=e??"",this.emit("userInput",this.userInput),t&&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(e,t){if(this._track&&t.name!=="return"&&(t.name&&this._isActionKey(e,t)&&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"),t?.name&&(!this._track&&_.aliases.has(t.name)&&this.emit("cursor",_.aliases.get(t.name)),_.actions.has(t.name)&&this.emit("cursor",t.name)),e&&(e.toLowerCase()==="y"||e.toLowerCase()==="n")&&this.emit("confirm",e.toLowerCase()==="y"),this.emit("key",e,t),t?.name==="return"&&this._shouldSubmit(e,t)){if(this.opts.validate){let n=Rt(this.opts.validate,this.value);n&&(this.error=n instanceof Error?n.message:n,this.state="error",this.rl?.write(this.userInput))}this.state!=="error"&&(this.state="submit")}Be([e,t?.name,t?.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(`
19
+ `),me(this.input,!1),this.rl?.close(),this.rl=void 0,this.emit(`${this.state}`,this.value),this.unsubscribe()}restoreCursor(){let e=L(this._prevFrame,process.stdout.columns,{hard:!0,trim:!1}).split(`
20
+ `).length-1;this.output.write(k.cursor.move(-999,e*-1))}render(){let e=L(this._render(this)??"",process.stdout.columns,{hard:!0,trim:!1});if(e!==this._prevFrame){if(this.state==="initial")this.output.write(k.cursor.hide);else{let t=us(this._prevFrame,e),n=jt(this.output);if(this.restoreCursor(),t){let s=Math.max(0,t.numLinesAfter-n),r=Math.max(0,t.numLinesBefore-n),u=t.lines.find((o)=>o>=s);if(u===void 0){this._prevFrame=e;return}if(t.lines.length===1){this.output.write(k.cursor.move(0,u-r)),this.output.write(k.erase.lines(1));let o=e.split(`
21
+ `);this.output.write(o[u]),this._prevFrame=e,this.output.write(k.cursor.move(0,o.length-u-1));return}else if(t.lines.length>1){if(s<r)u=s;else{let a=u-r;a>0&&this.output.write(k.cursor.move(0,a))}this.output.write(k.erase.down());let o=e.split(`
22
+ `).slice(u);this.output.write(o.join(`
23
+ `)),this._prevFrame=e;return}}this.output.write(k.erase.down())}this.output.write(e),this.state==="initial"&&(this.state="active"),this._prevFrame=e}}}class We extends Pt{get cursor(){return this.value?0:1}get _value(){return this.cursor===0}constructor(e){super(e,!1),this.value=!!e.initialValue,this.on("userInput",()=>{this.value=this._value}),this.on("confirm",(t)=>{this.output.write(k.cursor.move(0,-1)),this.value=t,this.state="submit",this.close()}),this.on("cursor",()=>{this.value=!this.value})}}import{styleText as p,stripVTControlCharacters as Rr}from"util";import A from"process";var se=st(Ge(),1);function as(){if(A.platform!=="win32")return A.env.TERM!=="linux";return Boolean(A.env.CI)||Boolean(A.env.WT_SESSION)||Boolean(A.env.TERMINUS_SUBLIME)||A.env.ConEmuTask==="{cmd::Cmder}"||A.env.TERM_PROGRAM==="Terminus-Sublime"||A.env.TERM_PROGRAM==="vscode"||A.env.TERM==="xterm-256color"||A.env.TERM==="alacritty"||A.env.TERMINAL_EMULATOR==="JetBrains-JediTerm"}var ze=as(),ls=()=>process.env.CI==="true";var d=(e,t)=>ze?e:t,cs=d("\u25C6","*"),Gt=d("\u25A0","x"),qt=d("\u25B2","x"),ge=d("\u25C7","o"),fs=d("\u250C","T"),x=d("\u2502","|"),Ut=d("\u2514","\u2014"),Lr=d("\u2510","T"),Gr=d("\u2518","\u2014"),Nt=d("\u25CF",">"),Vt=d("\u25CB"," "),qr=d("\u25FB","[\u2022]"),Ur=d("\u25FC","[+]"),Br=d("\u25FB","[ ]"),Wr=d("\u25AA","\u2022"),Lt=d("\u2500","-"),ps=d("\u256E","+"),hs=d("\u251C","+"),ms=d("\u256F","+"),ys=d("\u2570","+"),zr=d("\u256D","+"),ds=d("\u25CF","\u2022"),gs=d("\u25C6","*"),vs=d("\u25B2","!"),$s=d("\u25A0","x"),bs=(e)=>{switch(e){case"initial":case"active":return p("cyan",cs);case"cancel":return p("red",Gt);case"error":return p("yellow",qt);case"submit":return p("green",ge)}};var Bt=(e)=>{let t=e.active??"Yes",n=e.inactive??"No";return new We({active:t,inactive:n,signal:e.signal,input:e.input,output:e.output,initialValue:e.initialValue??!0,render(){let s=e.withGuide??_.withGuide,r=`${bs(this.state)} `,u=s?`${p("gray",x)} `:"",o=Tt(e.output,e.message,u,r),a=`${s?`${p("gray",x)}
24
+ `:""}${o}
25
+ `,i=this.value?t:n;switch(this.state){case"submit":{let l=s?`${p("gray",x)} `:"";return`${a}${l}${p("dim",i)}`}case"cancel":{let l=s?`${p("gray",x)} `:"";return`${a}${l}${p(["strikethrough","dim"],i)}${s?`
26
+ ${p("gray",x)}`:""}`}default:{let l=s?`${p("cyan",x)} `:"",c=s?p("cyan",Ut):"";return`${a}${l}${this.value?`${p("green",Nt)} ${t}`:`${p("dim",Vt)} ${p("dim",t)}`}${e.vertical?s?`
27
+ ${p("cyan",x)} `:`
28
+ `:` ${p("dim","/")} `}${this.value?`${p("dim",Vt)} ${p("dim",n)}`:`${p("green",Nt)} ${n}`}
29
+ ${c}
30
+ `}}}}).prompt()};var Hr=[`${p("dim","\u2191/\u2193")} to navigate`,`${p("dim","Space:")} select`,`${p("dim","Enter:")} confirm`];var v={message:(e=[],{symbol:t=p("gray",x),secondarySymbol:n=p("gray",x),output:s=process.stdout,spacing:r=1,withGuide:u}={})=>{let o=[],a=u??_.withGuide,i=a?n:"",l=a?`${t} `:"",c=a?`${n} `:"";for(let h=0;h<r;h++)o.push(i);let f=Array.isArray(e)?e:e.split(`
31
+ `);if(f.length>0){let[h,...g]=f;h.length>0?o.push(`${l}${h}`):o.push(a?t:"");for(let m of g)m.length>0?o.push(`${c}${m}`):o.push(a?n:"")}s.write(`${o.join(`
38
32
  `)}
39
- `)},info:(Z,J)=>{B.message(Z,{...J,symbol:G("blue",k8)})},success:(Z,J)=>{B.message(Z,{...J,symbol:G("green",h8)})},step:(Z,J)=>{B.message(Z,{...J,symbol:G("green",q0)})},warn:(Z,J)=>{B.message(Z,{...J,symbol:G("yellow",v8)})},warning:(Z,J)=>{B.warn(Z,J)},error:(Z,J)=>{B.message(Z,{...J,symbol:G("red",_8)})}};var P0=(Z="",J)=>{let Q=J?.output??process.stdout,F=J?.withGuide??O.withGuide?`${G("gray",D8)} `:"";Q.write(`${F}${Z}
40
- `)},J9=(Z="",J)=>{let Q=J?.output??process.stdout,F=J?.withGuide??O.withGuide?`${G("gray",C)}
41
- ${G("gray",t1)} `:"";Q.write(`${F}${Z}
33
+ `)},info:(e,t)=>{v.message(e,{...t,symbol:p("blue",ds)})},success:(e,t)=>{v.message(e,{...t,symbol:p("green",gs)})},step:(e,t)=>{v.message(e,{...t,symbol:p("green",ge)})},warn:(e,t)=>{v.message(e,{...t,symbol:p("yellow",vs)})},warning:(e,t)=>{v.warn(e,t)},error:(e,t)=>{v.message(e,{...t,symbol:p("red",$s)})}};var ve=(e="",t)=>{let n=t?.output??process.stdout,s=t?.withGuide??_.withGuide?`${p("gray",fs)} `:"";n.write(`${s}${e}
34
+ `)},Wt=(e="",t)=>{let n=t?.output??process.stdout,s=t?.withGuide??_.withGuide?`${p("gray",x)}
35
+ ${p("gray",Ut)} `:"";n.write(`${s}${e}
42
36
 
43
- `)};var y8=(Z)=>Z,$8=(Z,J,Q)=>{let F={hard:!0,trim:!1},Y=p(Z,J,F).split(`
44
- `),H=Y.reduce((W,L)=>Math.max(b(L),W),0),z=Y.map(Q).reduce((W,L)=>Math.max(b(L),W),0),U=J-(z-H);return p(Z,U,F)},O0=(Z="",J="",Q)=>{let F=Q?.output??I.stdout,Y=Q?.withGuide??O.withGuide,H=Q?.format??y8,z=["",...$8(Z,B0(F)-6,H).split(`
45
- `).map(H),""],U=b(J),W=Math.max(z.reduce((M,N)=>{let j=b(N);return j>M?j:M},0),U)+2,L=z.map((M)=>`${G("gray",C)} ${M}${" ".repeat(W-b(M))}${G("gray",C)}`).join(`
46
- `),K=Y?`${G("gray",C)}
47
- `:"",X=Y?x8:S8;F.write(`${K}${G("green",q0)} ${G("reset",J)} ${G("gray",s1.repeat(Math.max(W-U-1,1))+I8)}
48
- ${L}
49
- ${G("gray",X+s1.repeat(W+2)+T8)}
50
- `)};var p8=(Z)=>G("magenta",Z),b0=({indicator:Z="dots",onCancel:J,output:Q=process.stdout,cancelMessage:F,errorMessage:Y,frames:H=s0?["\u25D2","\u25D0","\u25D3","\u25D1"]:["\u2022","o","O","0"],delay:z=s0?80:120,signal:U,...W}={})=>{let L=A8(),K,X,M=!1,N=!1,j="",w,k=performance.now(),c=B0(Q),l=W?.styleFrame??p8,x=(q)=>{let D=q>1?Y??O.messages.error:F??O.messages.cancel;N=q===1,M&&(e(D,q),N&&typeof J=="function"&&J())},h=()=>x(2),A=()=>x(1),s=()=>{process.on("uncaughtExceptionMonitor",h),process.on("unhandledRejection",h),process.on("SIGINT",A),process.on("SIGTERM",A),process.on("exit",x),U&&U.addEventListener("abort",A)},T=()=>{process.removeListener("uncaughtExceptionMonitor",h),process.removeListener("unhandledRejection",h),process.removeListener("SIGINT",A),process.removeListener("SIGTERM",A),process.removeListener("exit",x),U&&U.removeEventListener("abort",A)},R=()=>{if(w===void 0)return;L&&Q.write(`
51
- `);let q=p(w,c,{hard:!0,trim:!1}).split(`
52
- `);q.length>1&&Q.write(F0.cursor.up(q.length-1)),Q.write(F0.cursor.to(0)),Q.write(F0.erase.down())},m=(q)=>q.replace(/\.+$/,""),i=(q)=>{let D=(performance.now()-q)/1000,v=Math.floor(D/60),_=Math.floor(D%60);return v>0?`[${v}m ${_}s]`:`[${_}s]`},E=W.withGuide??O.withGuide,W0=(q="")=>{M=!0,K=c1({output:Q}),j=m(q),k=performance.now(),E&&Q.write(`${G("gray",C)}
53
- `);let D=0,v=0;s(),X=setInterval(()=>{if(L&&j===w)return;R(),w=j;let _=l(H[D]),z0;if(L)z0=`${_} ${j}...`;else if(Z==="timer")z0=`${_} ${j} ${i(k)}`;else{let b9=".".repeat(Math.floor(v)).slice(0,3);z0=`${_} ${j}${b9}`}let O9=p(z0,c,{hard:!0,trim:!1});Q.write(O9),D=D+1<H.length?D+1:0,v=v<4?v+0.125:0},z)},e=(q="",D=0,v=!1)=>{if(!M)return;M=!1,clearInterval(X),R();let _=D===0?G("green",q0):D===1?G("red",a1):G("red",e1);j=q??j,v||(Z==="timer"?Q.write(`${_} ${j} ${i(k)}
54
- `):Q.write(`${_} ${j}
55
- `)),T(),K()};return{start:W0,stop:(q="")=>e(q,0),message:(q="")=>{j=m(q??j)},cancel:(q="")=>e(q,1),error:(q="")=>e(q,2),clear:()=>e("",0,!0),get isCancelled(){return N}}},W7={light:V("\u2500","-"),heavy:V("\u2501","="),block:V("\u2588","#")};var z7=[`${G("dim","\u2191/\u2193")} to navigate`,`${G("dim","Enter:")} confirm`];var U7=`${G("gray",C)} `;var{$:a0}=globalThis.Bun;var g8={pacman:["arch","endeavouros","manjaro","garuda","cachyos","arcolinux","rebornos","blendos","steamos","chimeraos"],dnf:["fedora","nobara","bazzite","ultramarine"]},Q9=(Z)=>{for(let[J,Q]of Object.entries(g8))if(Q.includes(Z))return J;return null};var F9={osName:void 0,osId:void 0,platform:"linux",packageManager:void 0,helperAur:null,isFlatpak:!1,flatpak:!1};function o(Z){return F9[Z]}function g(Z,J){F9[Z]=J}async function e0(Z){try{return await a0`which ${Z}`.quiet(),!0}catch{return!1}}async function c8(){let Z=[];if(await e0("yay"))Z.push("yay");if(await e0("paru"))Z.push("paru");return Z}async function l8(){if(process.platform==="linux"){let Z=await a0`cat /etc/os-release | grep ^NAME`.quiet().text()||"",J=await a0`cat /etc/os-release | grep ^ID`.quiet().text()||"",Q=Z.trim().slice(5).replace(/"/g,"");return{id:J.trim().slice(3).replace(/"/g,""),name:Q}}return{id:"unknown",name:"unknown"}}async function C0(){let{name:Z="",id:J=""}=await l8(),Q=Q9(J),F=Q==="pacman"?await c8():null,Y=await e0("flatpak");if(g("osName",Z),g("osId",J),g("flatpak",Y),F)g("helperAur",F[0]);if(Q)g("packageManager",Q);return{osName:Z,osId:J,packageManager:Q,aurHelper:F,flatpak:Y}}async function Y9(){P0("\uD83D\uDD0D Scanning system");let Z=b0();Z.start("Detecting environment...");let J=await C0();return Z.stop("Environment detected"),O0([`OS ${J.osName} (${J.osId})`,`Package Manager ${J.packageManager}`,J.aurHelper?`AUR Helper ${J.aurHelper}`:null,`Flatpak ${J.flatpak?"Enabled":"Disabled"}`].filter(Boolean).join(`
56
- `),"System Environment",{withGuide:!0}),J9("Scan completed"),J}import H9 from"path";import{homedir as m8}from"os";function R0(Z){if(Z.startsWith("~"))return H9.join(m8(),Z.slice(1));return H9.resolve(Z)}var u8=f0(u({flatpak:t(),backup:t(),aur_helper:J0(["yay","paru"])})),r8=u({source:S(),target:S(),sudo:Z0(t())}),o8=J0(["aur","pacman"]),n8=Q0([S(),$(S()),$($(S()))]),i8=u({name:S(),post_hooks:Z0(n8)}),W9=$(Q0([S(),i8])),d8=u({manager:o8,items:W9}),s8=u({manager:_0("flatpak"),scope:J0(["system","user"]),items:W9}),A0=f0(u({imports:$(S()),settings:u8,packages:$(Q0([s8,d8])),symlinks:$(r8)}));import D0 from"path";var n={defaultMerge:Symbol("deepmerge-ts: default merge"),skip:Symbol("deepmerge-ts: skip")},C7={defaultMerge:n.defaultMerge};function a8(Z,J){return J}function e8(Z,J){return Z.filter((Q)=>Q!==void 0)}var z9;(function(Z){Z[Z.NOT=0]="NOT",Z[Z.RECORD=1]="RECORD",Z[Z.ARRAY=2]="ARRAY",Z[Z.SET=3]="SET",Z[Z.MAP=4]="MAP",Z[Z.OTHER=5]="OTHER"})(z9||(z9={}));function U9(Z){if(typeof Z!=="object"||Z===null)return 0;if(Array.isArray(Z))return 2;if(J6(Z))return 1;if(Z instanceof Set)return 3;if(Z instanceof Map)return 4;return 5}function t8(Z){let J=new Set;for(let Q of Z)for(let F of[...Object.keys(Q),...Object.getOwnPropertySymbols(Q)])J.add(F);return J}function Z6(Z,J){return typeof Z==="object"&&Object.prototype.propertyIsEnumerable.call(Z,J)}function K9(Z){let J=0,Q=Z[0]?.[Symbol.iterator]();return{[Symbol.iterator](){return{next(){do{if(Q===void 0)return{done:!0,value:void 0};let F=Q.next();if(F.done===!0){J+=1,Q=Z[J]?.[Symbol.iterator]();continue}return{done:!1,value:F.value}}while(!0)}}}}}var L9=["[object Object]","[object Module]"];function J6(Z){if(!L9.includes(Object.prototype.toString.call(Z)))return!1;let{constructor:J}=Z;if(J===void 0)return!0;let Q=J.prototype;if(Q===null||typeof Q!=="object"||!L9.includes(Object.prototype.toString.call(Q)))return!1;if(!Q.hasOwnProperty("isPrototypeOf"))return!1;return!0}function Q6(Z,J,Q){let F={};for(let Y of t8(Z)){let H=[];for(let W of Z)if(Z6(W,Y))H.push(W[Y]);if(H.length===0)continue;let z=J.metaDataUpdater(Q,{key:Y,parents:Z}),U=X9(H,J,z);if(U===n.skip)continue;if(Y==="__proto__")Object.defineProperty(F,Y,{value:U,configurable:!0,enumerable:!0,writable:!0});else F[Y]=U}return F}function F6(Z){return Z.flat()}function Y6(Z){return new Set(K9(Z))}function H6(Z){return new Map(K9(Z))}function W6(Z){return Z.at(-1)}var E0={mergeRecords:Q6,mergeArrays:F6,mergeSets:Y6,mergeMaps:H6,mergeOthers:W6};function H0(...Z){return z6({})(...Z)}function z6(Z,J){let Q=U6(Z,F);function F(...Y){return X9(Y,Q,J)}return F}function U6(Z,J){return{defaultMergeFunctions:E0,mergeFunctions:{...E0,...Object.fromEntries(Object.entries(Z).filter(([Q,F])=>Object.hasOwn(E0,Q)).map(([Q,F])=>F===!1?[Q,E0.mergeOthers]:[Q,F]))},metaDataUpdater:Z.metaDataUpdater??a8,deepmerge:J,useImplicitDefaultMerging:Z.enableImplicitDefaultMerging??!1,filterValues:Z.filterValues===!1?void 0:Z.filterValues??e8,actions:n}}function X9(Z,J,Q){let F=J.filterValues?.(Z,Q)??Z;if(F.length===0)return;if(F.length===1)return t0(F,J,Q);let Y=U9(F[0]);if(Y!==0&&Y!==5)for(let H=1;H<F.length;H++){if(U9(F[H])===Y)continue;return t0(F,J,Q)}switch(Y){case 1:return L6(F,J,Q);case 2:return K6(F,J,Q);case 3:return X6(F,J,Q);case 4:return M6(F,J,Q);default:return t0(F,J,Q)}}function L6(Z,J,Q){let F=J.mergeFunctions.mergeRecords(Z,J,Q);if(F===n.defaultMerge||J.useImplicitDefaultMerging&&F===void 0&&J.mergeFunctions.mergeRecords!==J.defaultMergeFunctions.mergeRecords)return J.defaultMergeFunctions.mergeRecords(Z,J,Q);return F}function K6(Z,J,Q){let F=J.mergeFunctions.mergeArrays(Z,J,Q);if(F===n.defaultMerge||J.useImplicitDefaultMerging&&F===void 0&&J.mergeFunctions.mergeArrays!==J.defaultMergeFunctions.mergeArrays)return J.defaultMergeFunctions.mergeArrays(Z);return F}function X6(Z,J,Q){let F=J.mergeFunctions.mergeSets(Z,J,Q);if(F===n.defaultMerge||J.useImplicitDefaultMerging&&F===void 0&&J.mergeFunctions.mergeSets!==J.defaultMergeFunctions.mergeSets)return J.defaultMergeFunctions.mergeSets(Z);return F}function M6(Z,J,Q){let F=J.mergeFunctions.mergeMaps(Z,J,Q);if(F===n.defaultMerge||J.useImplicitDefaultMerging&&F===void 0&&J.mergeFunctions.mergeMaps!==J.defaultMergeFunctions.mergeMaps)return J.defaultMergeFunctions.mergeMaps(Z);return F}function t0(Z,J,Q){let F=J.mergeFunctions.mergeOthers(Z,J,Q);if(F===n.defaultMerge||J.useImplicitDefaultMerging&&F===void 0&&J.mergeFunctions.mergeOthers!==J.defaultMergeFunctions.mergeOthers)return J.defaultMergeFunctions.mergeOthers(Z);return F}async function Z1(Z,J=new Set){let Q=D0.resolve(Z);if(J.has(Q))throw Error(`Circular dependency detected: ${Q}`);J.add(Q);let F=await Bun.file(Q).text(),Y=Bun.TOML.parse(F),H=X0(A0,Y),{imports:z=[],symlinks:U=[]}=H;delete H.imports;let W=D0.dirname(Q);H.symlinks=G6(W,U);let L={};for(let K of z){let X=D0.resolve(W,K),M=await Z1(X,J);L=H0(L,M)}return H0(H,L)}function G6(Z,J){if(!J||J.length===0)return[];let Q=[];for(let F of J){if(!F)continue;let{source:Y,target:H}=F,z=D0.resolve(Z,Y),U=R0(H);Q.push({source:z,target:U})}return Q}async function I0(Z){let J=R0(Z);B.step("Validating Configuration");let Q=b0();Q.start("Validating...");let F=await Z1(J),Y=X0(A0,F);return Q.stop("Successfully validated with no errors!"),Y}import w6 from"path";var{deepEquals:N9}=globalThis.Bun;import J1 from"path";import Q1 from"fs/promises";var x0={};function T0(){return x0}function M9(Z,J){x0[Z]=J}async function G9(Z){let J=Z??o("configDir"),Q=J1.resolve(J||".",".state/hofii-lock.json");if(await Q1.exists(Q)){let F=await Bun.file(Q).json();Object.assign(x0,F.config)}}async function j9(){let Z=J1.resolve(o("configDir")||".",".state");if(!await Q1.exists(Z))await Q1.mkdir(Z,{recursive:!0});let J={config:x0};await Bun.write(J1.resolve(Z,"hofii-lock.json"),JSON.stringify(J,null,2))}function j6(Z,J){let Q=J?.filter((Y)=>!Z?.some((H)=>N9(Y,H,!0))),F=Z?.filter((Y)=>!J?.some((H)=>N9(Y,H,!0)));return{added:Q,removed:F}}function w9(Z){let J=T0();return{symlinks:j6(J.symlinks,Z.symlinks)}}import V9 from"fs/promises";var{deepEquals:N6}=globalThis.Bun;import Y1 from"fs/promises";async function F1({cmd:Z,errMsg:J,opt:Q={stdin:"inherit",stdout:"inherit",stderr:"inherit"}}){let F=Bun.spawn(Z,{stdin:Q.stdin,stdout:Q.stdout,stderr:Q.stderr}),Y=Q.stdout==="pipe"?new Response(F.stdout).text():void 0,H=Q.stderr==="pipe"?new Response(F.stderr).text():void 0,z=F.exited,[U,W,L]=await Promise.all([Y,H,z]);if(L!==0)throw Error(J??`Error caused with exit code ${L}`);return{stdout:U,stderr:W,exitCode:L}}async function H1(Z,J,Q=!1){if(Q){if(o("platform")!=="linux"){B.warn("Sudo only support in Linux");return}await F1({cmd:["sudo","ln","-s",Z,J],errMsg:`Failed create symlink ${Z+" -> "+J}`})}else await Y1.symlink(Z,J)}async function W1(Z,J=!1){if(J){if(o("platform")!=="linux"){B.warn("Sudo only support in Linux");return}await F1({cmd:["sudo","rm",Z],errMsg:`Failed remove symlink ${Z}`})}else await Y1.unlink(Z)}async function z1(Z){try{return await Y1.lstat(Z)}catch(J){return null}}async function q9(Z){if(!Z)return;let J=o("settings")?.backup??"",{added:Q=[],removed:F=[]}=Z,Y=[],H=[];try{let z=(await Promise.allSettled(F.map(async(W)=>{let L=await z1(W.target);if(!L){B.warn(`Target doesn't exist: ${W.target}, did you remove it manually?`),H.push(W);return}if(!L.isSymbolicLink()){B.warn(`File ${W.target} not a symlink, did you remove it manually?`),H.push(W);return}await W1(W.target,W.sudo),H.push(W),B.success(`Succesfully remove symlink ${W.target}`)}))).filter((W)=>W.status==="rejected"),U=(await Promise.allSettled(Q.map(async(W)=>{let L=await z1(W.target),K=await V9.readlink(W.target);if(L)if(L.isSymbolicLink()&&K===W.source){await W1(W.target,W.sudo),await H1(W.source,W.target,W.sudo),Y.push(W),B.warn(`Recreate ${K} -> ${W.target}`);return}else if(J)await V9.rename(W.target,W.target+".bak");else{B.error(`Target already exists, skip create: ${W.target}`);return}await H1(W.source,W.target,W.sudo),Y.push(W),B.success(`Succesfully create symlink ${W.source} -> ${W.target}`)}))).filter((W)=>W.status==="rejected");for(let W of U)console.error(`Failed to add symlink: ${B9(W)}`);for(let W of z)console.error(`Failed to remove symlink: ${B9(W)}`);if(U.length>0||z.length>0)B.error(" [FATAL] Failed to apply symlinks"),process.exitCode=1}catch(z){console.error(z),B.error(" [FATAL] Failed to apply symlinks"),process.exitCode=1}finally{let W=((T0()??{}).symlinks??[]).filter((L)=>!H.some((K)=>N6(K,L))).concat(Y);B.info(`Updated symlinks state: ${W.length}`),M9("symlinks",W)}}function B9(Z){if(Z instanceof Error)return`[${"code"in Z?String(Z.code):"ERROR"}] ${Z.message}`;return`[ERROR] ${String(Z)}`}async function P9(Z){let J=w6.join(Z,"config.toml");g("configDir",Z),await G9(Z),P0("Switching configuration"),B.info("Scanning system environment..."),await C0();let Q=await I0(J);g("settings",H0(Q.settings,{backup:!0}));let F=w9(Q);O0((()=>{let z=["SYMLINKS"],U=F.symlinks,{added:W=[],removed:L=[]}=U;if(W?.length===0&&L?.length===0)return z.push(" - No changes to apply with symlinks"),z.join(`
57
- `);for(let K of W)z.push(` - [ADDED] ${K.sudo?"(sudo) ":""}${K.source} -> ${K.target}`);for(let K of L)z.push(` - [REMOVED] ${K.sudo?"(sudo) ":""}${K.source} -> ${K.target}`);return z.join(`
58
- `)})(),"Config To Apply");let H=await Z9({message:"Apply config changes? (Please review the changes first!!)"});if(!H||V0(H))B.warn("Config changes not applied."),process.exit(0);await q9(F.symlinks)}var d=w1("hofii");d.version("0.0.3");d.command("scan","Detect system environment").alias("s").action(async()=>{await Y9(),process.exit(0)});d.command("validate [dir]","Validate configuration files").alias("v").action(async(Z)=>{await I0(Z),process.exit(0)});d.command("switch [dir]","Switch to new configuration").alias("sw").action(async(Z)=>{let J=V6.resolve(Z);await P9(J)});try{if(process.argv.slice(2).length===0)d.outputHelp(),process.exit(0);d.help().parse(process.argv,{run:!1}),await d.runMatchedCommand()}catch(Z){if(Z instanceof v0){let J=Z.issues.map((Q)=>{let F=Q.path.at(-1)?.input;return[`\u2717 ${Q.message}`,` at: ${JSON.stringify(F)}`].join(`
37
+ `)};var ks=(e)=>e,ws=(e,t,n)=>{let s={hard:!0,trim:!1},r=L(e,t,s).split(`
38
+ `),u=r.reduce((i,l)=>Math.max(w(l),i),0),o=r.map(n).reduce((i,l)=>Math.max(w(l),i),0),a=t-(o-u);return L(e,a,s)},$e=(e="",t="",n)=>{let s=n?.output??A.stdout,r=n?.withGuide??_.withGuide,u=n?.format??ks,o=["",...ws(e,de(s)-6,u).split(`
39
+ `).map(u),""],a=w(t),i=Math.max(o.reduce((h,g)=>{let m=w(g);return m>h?m:h},0),a)+2,l=o.map((h)=>`${p("gray",x)} ${h}${" ".repeat(i-w(h))}${p("gray",x)}`).join(`
40
+ `),c=r?`${p("gray",x)}
41
+ `:"",f=r?hs:ys;s.write(`${c}${p("green",ge)} ${p("reset",t)} ${p("gray",Lt.repeat(Math.max(i-a-1,1))+ps)}
42
+ ${l}
43
+ ${p("gray",f+Lt.repeat(i+2)+ms)}
44
+ `)};var xs=(e)=>p("magenta",e),be=({indicator:e="dots",onCancel:t,output:n=process.stdout,cancelMessage:s,errorMessage:r,frames:u=ze?["\u25D2","\u25D0","\u25D3","\u25D1"]:["\u2022","o","O","0"],delay:o=ze?80:120,signal:a,...i}={})=>{let l=ls(),c,f,h=!1,g=!1,m="",y,F=performance.now(),U=de(n),B=i?.styleFrame??xs,O=(b)=>{let C=b>1?r??_.messages.error:s??_.messages.cancel;g=b===1,h&&(Y(C,b),g&&typeof t=="function"&&t())},j=()=>O(2),I=()=>O(1),Z=()=>{process.on("uncaughtExceptionMonitor",j),process.on("unhandledRejection",j),process.on("SIGINT",I),process.on("SIGTERM",I),process.on("exit",O),a&&a.addEventListener("abort",I)},M=()=>{process.removeListener("uncaughtExceptionMonitor",j),process.removeListener("unhandledRejection",j),process.removeListener("SIGINT",I),process.removeListener("SIGTERM",I),process.removeListener("exit",O),a&&a.removeEventListener("abort",I)},E=()=>{if(y===void 0)return;l&&n.write(`
45
+ `);let b=L(y,U,{hard:!0,trim:!1}).split(`
46
+ `);b.length>1&&n.write(se.cursor.up(b.length-1)),n.write(se.cursor.to(0)),n.write(se.erase.down())},W=(b)=>b.replace(/\.+$/,""),X=(b)=>{let C=(performance.now()-b)/1000,T=Math.floor(C/60),R=Math.floor(C%60);return T>0?`[${T}m ${R}s]`:`[${R}s]`},S=i.withGuide??_.withGuide,ue=(b="")=>{h=!0,c=Ft({output:n}),m=W(b),F=performance.now(),S&&n.write(`${p("gray",x)}
47
+ `);let C=0,T=0;Z(),f=setInterval(()=>{if(l&&m===y)return;E(),y=m;let R=B(u[C]),oe;if(l)oe=`${R} ${m}...`;else if(e==="timer")oe=`${R} ${m} ${X(F)}`;else{let yn=".".repeat(Math.floor(T)).slice(0,3);oe=`${R} ${m}${yn}`}let mn=L(oe,U,{hard:!0,trim:!1});n.write(mn),C=C+1<u.length?C+1:0,T=T<4?T+0.125:0},o)},Y=(b="",C=0,T=!1)=>{if(!h)return;h=!1,clearInterval(f),E();let R=C===0?p("green",ge):C===1?p("red",Gt):p("red",qt);m=b??m,T||(e==="timer"?n.write(`${R} ${m} ${X(F)}
48
+ `):n.write(`${R} ${m}
49
+ `)),M(),c()};return{start:ue,stop:(b="")=>Y(b,0),message:(b="")=>{m=W(b??m)},cancel:(b="")=>Y(b,1),error:(b="")=>Y(b,2),clear:()=>Y("",0,!0),get isCancelled(){return g}}},Kr={light:d("\u2500","-"),heavy:d("\u2501","="),block:d("\u2588","#")};var Xr=[`${p("dim","\u2191/\u2193")} to navigate`,`${p("dim","Enter:")} confirm`];var Jr=`${p("gray",x)} `;var{$:He}=globalThis.Bun;var _s={pacman:["arch","endeavouros","manjaro","garuda","cachyos","arcolinux","rebornos","blendos","steamos","chimeraos"],dnf:["fedora","nobara","bazzite","ultramarine"]},zt=(e)=>{for(let[t,n]of Object.entries(_s))if(n.includes(e))return t;return null};var Ht={osName:void 0,osId:void 0,platform:"linux",packageManager:void 0,helperAur:null,isFlatpak:!1,flatpak:!1};function G(e){return Ht[e]}function q(e,t){Ht[e]=t}async function Ke(e){try{return await He`which ${e}`.quiet(),!0}catch{return!1}}async function Es(){let e=[];if(await Ke("yay"))e.push("yay");if(await Ke("paru"))e.push("paru");return e}async function Is(){if(process.platform==="linux"){let e=await He`cat /etc/os-release | grep ^NAME`.quiet().text()||"",t=await He`cat /etc/os-release | grep ^ID`.quiet().text()||"",n=e.trim().slice(5).replace(/"/g,"");return{id:t.trim().slice(3).replace(/"/g,""),name:n}}return{id:"unknown",name:"unknown"}}async function ke(){let{name:e="",id:t=""}=await Is(),n=zt(t),s=n==="pacman"?await Es():null,r=await Ke("flatpak");if(q("osName",e),q("osId",t),q("flatpak",r),s)q("helperAur",s[0]);if(n)q("packageManager",n);return{osName:e,osId:t,packageManager:n,aurHelper:s,flatpak:r}}async function Kt(){ve("\uD83D\uDD0D Scanning system");let e=be();e.start("Detecting environment...");let t=await ke();return e.stop("Environment detected"),$e([`OS ${t.osName} (${t.osId})`,`Package Manager ${t.packageManager}`,t.aurHelper?`AUR Helper ${t.aurHelper}`:null,`Flatpak ${t.flatpak?"Enabled":"Disabled"}`].filter(Boolean).join(`
50
+ `),"System Environment",{withGuide:!0}),Wt("Scan completed"),t}import Xt from"path";import{homedir as Ss}from"os";function we(e){if(e.startsWith("~"))return Xt.join(Ss(),e.slice(1));return Xt.resolve(e)}var Cs=Re(z({flatpak:Q(),backup:Q(),aur_helper:te(["yay","paru"])})),As=z({source:D(),target:D(),sudo:ee(Q())}),Os=te(["aur","pacman"]),Ms=ne([D(),V(D()),V(V(D()))]),Ds=z({name:D(),post_hooks:ee(Ms)}),Jt=V(ne([D(),Ds])),Fs=z({manager:Os,items:Jt}),js=z({manager:Te("flatpak"),scope:te(["system","user"]),items:Jt}),xe=Re(z({imports:V(D()),settings:Cs,packages:V(ne([js,Fs])),symlinks:V(As)}));import Ee from"path";var K={defaultMerge:Symbol("deepmerge-ts: default merge"),skip:Symbol("deepmerge-ts: skip")},fi={defaultMerge:K.defaultMerge};function Ts(e,t){return t}function Rs(e,t){return e.filter((n)=>n!==void 0)}var Zt;(function(e){e[e.NOT=0]="NOT",e[e.RECORD=1]="RECORD",e[e.ARRAY=2]="ARRAY",e[e.SET=3]="SET",e[e.MAP=4]="MAP",e[e.OTHER=5]="OTHER"})(Zt||(Zt={}));function Yt(e){if(typeof e!=="object"||e===null)return 0;if(Array.isArray(e))return 2;if(Vs(e))return 1;if(e instanceof Set)return 3;if(e instanceof Map)return 4;return 5}function Ps(e){let t=new Set;for(let n of e)for(let s of[...Object.keys(n),...Object.getOwnPropertySymbols(n)])t.add(s);return t}function Ns(e,t){return typeof e==="object"&&Object.prototype.propertyIsEnumerable.call(e,t)}function en(e){let t=0,n=e[0]?.[Symbol.iterator]();return{[Symbol.iterator](){return{next(){do{if(n===void 0)return{done:!0,value:void 0};let s=n.next();if(s.done===!0){t+=1,n=e[t]?.[Symbol.iterator]();continue}return{done:!1,value:s.value}}while(!0)}}}}}var Qt=["[object Object]","[object Module]"];function Vs(e){if(!Qt.includes(Object.prototype.toString.call(e)))return!1;let{constructor:t}=e;if(t===void 0)return!0;let n=t.prototype;if(n===null||typeof n!=="object"||!Qt.includes(Object.prototype.toString.call(n)))return!1;if(!n.hasOwnProperty("isPrototypeOf"))return!1;return!0}function Ls(e,t,n){let s={};for(let r of Ps(e)){let u=[];for(let i of e)if(Ns(i,r))u.push(i[r]);if(u.length===0)continue;let o=t.metaDataUpdater(n,{key:r,parents:e}),a=tn(u,t,o);if(a===K.skip)continue;if(r==="__proto__")Object.defineProperty(s,r,{value:a,configurable:!0,enumerable:!0,writable:!0});else s[r]=a}return s}function Gs(e){return e.flat()}function qs(e){return new Set(en(e))}function Us(e){return new Map(en(e))}function Bs(e){return e.at(-1)}var _e={mergeRecords:Ls,mergeArrays:Gs,mergeSets:qs,mergeMaps:Us,mergeOthers:Bs};function ie(...e){return Ws({})(...e)}function Ws(e,t){let n=zs(e,s);function s(...r){return tn(r,n,t)}return s}function zs(e,t){return{defaultMergeFunctions:_e,mergeFunctions:{..._e,...Object.fromEntries(Object.entries(e).filter(([n,s])=>Object.hasOwn(_e,n)).map(([n,s])=>s===!1?[n,_e.mergeOthers]:[n,s]))},metaDataUpdater:e.metaDataUpdater??Ts,deepmerge:t,useImplicitDefaultMerging:e.enableImplicitDefaultMerging??!1,filterValues:e.filterValues===!1?void 0:e.filterValues??Rs,actions:K}}function tn(e,t,n){let s=t.filterValues?.(e,n)??e;if(s.length===0)return;if(s.length===1)return Xe(s,t,n);let r=Yt(s[0]);if(r!==0&&r!==5)for(let u=1;u<s.length;u++){if(Yt(s[u])===r)continue;return Xe(s,t,n)}switch(r){case 1:return Hs(s,t,n);case 2:return Ks(s,t,n);case 3:return Xs(s,t,n);case 4:return Js(s,t,n);default:return Xe(s,t,n)}}function Hs(e,t,n){let s=t.mergeFunctions.mergeRecords(e,t,n);if(s===K.defaultMerge||t.useImplicitDefaultMerging&&s===void 0&&t.mergeFunctions.mergeRecords!==t.defaultMergeFunctions.mergeRecords)return t.defaultMergeFunctions.mergeRecords(e,t,n);return s}function Ks(e,t,n){let s=t.mergeFunctions.mergeArrays(e,t,n);if(s===K.defaultMerge||t.useImplicitDefaultMerging&&s===void 0&&t.mergeFunctions.mergeArrays!==t.defaultMergeFunctions.mergeArrays)return t.defaultMergeFunctions.mergeArrays(e);return s}function Xs(e,t,n){let s=t.mergeFunctions.mergeSets(e,t,n);if(s===K.defaultMerge||t.useImplicitDefaultMerging&&s===void 0&&t.mergeFunctions.mergeSets!==t.defaultMergeFunctions.mergeSets)return t.defaultMergeFunctions.mergeSets(e);return s}function Js(e,t,n){let s=t.mergeFunctions.mergeMaps(e,t,n);if(s===K.defaultMerge||t.useImplicitDefaultMerging&&s===void 0&&t.mergeFunctions.mergeMaps!==t.defaultMergeFunctions.mergeMaps)return t.defaultMergeFunctions.mergeMaps(e);return s}function Xe(e,t,n){let s=t.mergeFunctions.mergeOthers(e,t,n);if(s===K.defaultMerge||t.useImplicitDefaultMerging&&s===void 0&&t.mergeFunctions.mergeOthers!==t.defaultMergeFunctions.mergeOthers)return t.defaultMergeFunctions.mergeOthers(e);return s}async function Je(e,t=new Set){let n=Ee.resolve(e);if(t.has(n))throw Error(`Circular dependency detected: ${n}`);t.add(n);let s=await Bun.file(n).text(),r=Bun.TOML.parse(s),u=fe(xe,r),{imports:o=[],symlinks:a=[]}=u;delete u.imports;let i=Ee.dirname(n);u.symlinks=Zs(i,a);let l={};for(let c of o){let f=Ee.resolve(i,c),h=await Je(f,t);l=ie(l,h)}return ie(u,l)}function Zs(e,t){if(!t||t.length===0)return[];let n=[];for(let s of t){if(!s)continue;let{source:r,target:u}=s,o=Ee.resolve(e,r),a=we(u);n.push({source:o,target:a})}return n}async function Ie(e){let t=we(e);v.step("Validating Configuration");let n=be();n.start("Validating...");let s=await Je(t),r=fe(xe,s);return n.stop("Successfully validated with no errors!"),r}import tr from"path";var{deepEquals:un}=globalThis.Bun;import Ze from"path";import Ye from"fs/promises";var Se={};function Ce(){return Se}function nn(e,t){Se[e]=t}async function sn(e){let t=e??G("configDir"),n=Ze.resolve(t||".",".state/hofii-lock.json");if(await Ye.exists(n)){let s=await Bun.file(n).json();Object.assign(Se,s.config)}}async function rn(){let e=Ze.resolve(G("configDir")||".",".state");if(!await Ye.exists(e))await Ye.mkdir(e,{recursive:!0});let t={config:Se};await Bun.write(Ze.resolve(e,"hofii-lock.json"),JSON.stringify(t,null,2))}function Ys(e,t){let n=t?.filter((r)=>!e?.some((u)=>un(r,u,!0)))??[],s=e?.filter((r)=>!t?.some((u)=>un(r,u,!0)))??[];return{added:n,removed:s}}function on(e){let t=Ce();return{symlinks:Ys(t.symlinks,e.symlinks)}}function an(e){let{symlinks:t}=e;return[(()=>{let s=["SYMLINKS"],{added:r=[],removed:u=[]}=t;if(r?.length===0&&u?.length===0)return s.push(" - No changes to apply with symlinks"),s.join(`
51
+ `);for(let o of r)s.push(` - [ADDED] ${o.sudo?"(sudo) ":""}${o.source} -> ${o.target}`);for(let o of u)s.push(` - [REMOVED] ${o.sudo?"(sudo) ":""}${o.source} -> ${o.target}`);return s.join(`
52
+ `)})()].join("/n")}var{deepEquals:Qs}=globalThis.Bun;import er from"fs/promises";import Oe from"fs/promises";async function Ae({cmd:e,errMsg:t,opt:n={stdin:"inherit",stdout:"inherit",stderr:"inherit"}}){let s=Bun.spawn(e,{stdin:n.stdin,stdout:n.stdout,stderr:n.stderr}),r=n.stdout==="pipe"?new Response(s.stdout).text():void 0,u=n.stderr==="pipe"?new Response(s.stderr).text():void 0,o=s.exited,[a,i,l]=await Promise.all([r,u,o]);if(l!==0)throw Error(t??`Error caused with exit code ${l}`);return{stdout:a,stderr:i,exitCode:l}}async function Qe(e,t,n=!1){if(n){if(G("platform")!=="linux"){v.warn("Sudo only support in Linux");return}await Ae({cmd:["sudo","ln","-s",e,t],errMsg:`Failed create symlink ${e+" -> "+t}`})}else await Oe.symlink(e,t)}async function et(e,t=!1){if(t){if(G("platform")!=="linux"){v.warn("Sudo only support in Linux");return}await Ae({cmd:["sudo","rm",e],errMsg:`Failed remove symlink ${e}`})}else await Oe.unlink(e)}async function tt(e){try{return await Oe.lstat(e)}catch(t){return null}}async function ln({oldPath:e,newPath:t,sudo:n=!1}){if(n){if(G("platform")!=="linux"){v.warn("Sudo only support in Linux");return}await Ae({cmd:["sudo","mv",e,t],errMsg:`Failed rename file ${e+" -> "+t}`})}else await Oe.rename(e,t)}async function pn(e){if(!e)return;let t=G("settings")?.backup??!0,{added:n=[],removed:s=[]}=e,r=[],u=[];try{let o=fn(await Promise.allSettled(s.map(async(i)=>{let l=await tt(i.target);if(!l){v.warn(`Target doesn't exist: ${i.target}, did you remove it manually?`),u.push(i);return}if(!l.isSymbolicLink()){v.warn(`${i.target} not a symlink, did you remove it manually?`),u.push(i);return}await et(i.target,i.sudo),u.push(i),v.success(`Succesfully remove symlink ${i.target}`)}))),a=fn(await Promise.allSettled(n.map(async(i)=>{let l=await tt(i.target);if(l){if(l.isSymbolicLink()){let c=await er.readlink(i.target);if(c===i.source){await et(i.target,i.sudo),await Qe(i.source,i.target,i.sudo),r.push(i),v.warn(`Recreate ${c} -> ${i.target}`);return}}if(t)await ln({oldPath:i.target,newPath:i.target+".bak",sudo:i.sudo});else{v.error(`Target already exists, skip create: ${i.target}`);return}}await Qe(i.source,i.target,i.sudo),r.push(i),v.success(`Succesfully create symlink ${i.source} -> ${i.target}`)})));for(let i of a)console.error(`Failed to add symlink: ${cn(i)}`);for(let i of o)console.error(`Failed to remove symlink: ${cn(i)}`);if(a.length>0||o.length>0)v.error(" [FATAL] Error caused while applying symlinks"),process.exitCode=1}catch(o){console.error(o),v.error(" [FATAL] Failed to apply symlinks"),process.exitCode=1}finally{let i=((Ce()??{}).symlinks??[]).filter((l)=>!u.some((c)=>Qs(c,l))).concat(r);v.info(`Updated symlinks state: ${i.length}`),nn("symlinks",i)}}function cn(e){if(e instanceof Error)return`[${"code"in e?String(e.code):"ERROR"}] ${e.message}`;return`[ERROR] ${String(e)}`}function fn(e){return e.filter((t)=>t.status==="rejected")}async function hn(e){let t=tr.join(e,"config.toml");q("configDir",e),await sn(e),ve("Switching configuration"),v.info("Scanning system environment..."),await ke();let n=await Ie(t);q("settings",ie(n.settings,{backup:!0}));let s=on(n),r=an(s);$e(r,"Config To Apply");let u=await Bt({message:"Apply config changes? (Please review the changes first!!)"});if(!u||ye(u))v.warn("Config changes not applied."),process.exit(0);await pn(s.symlinks)}var J=ct("hofii");J.version("0.0.3");J.command("scan","Detect system environment").alias("s").action(async()=>{await Kt(),process.exit(0)});J.command("validate [dir]","Validate configuration files").alias("v").action(async(e)=>{await Ie(e),process.exit(0)});J.command("switch [dir]","Switch to new configuration").alias("sw").action(async(e)=>{let t=nr.resolve(e);await hn(t)});try{if(process.argv.slice(2).length===0)J.outputHelp(),process.exit(0);J.help().parse(process.argv,{run:!1}),await J.runMatchedCommand()}catch(e){if(e instanceof je){let t=e.issues.map((n)=>{let s=n.path.at(-1)?.input;return[`\u2717 ${n.message}`,` at: ${JSON.stringify(s)}`].join(`
59
53
  `)}).join(`
60
54
 
61
- `);console.error(J)}process.exit(1)}finally{await j9()}
55
+ `);console.error(t)}console.error(e)}finally{await rn()}
package/package.json CHANGED
@@ -26,5 +26,5 @@
26
26
  "deepmerge-ts": "^7.1.5",
27
27
  "valibot": "^1.4.2"
28
28
  },
29
- "version": "0.0.31"
29
+ "version": "0.1.0"
30
30
  }