hofii 0.1.2 → 0.1.3

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 +35 -32
  2. package/package.json +1 -1
package/dist/main.js CHANGED
@@ -1,55 +1,58 @@
1
1
  #!/usr/bin/env bun
2
2
  // @bun
3
- var bn=Object.create;var{getPrototypeOf:kn,defineProperty:it,getOwnPropertyNames:wn}=Object;var xn=Object.prototype.hasOwnProperty;function _n(e){return this[e]}var En,In,ut=(e,t,n)=>{var s=e!=null&&typeof e==="object";if(s){var r=t?En??=new WeakMap:In??=new WeakMap,i=r.get(e);if(i)return i}n=e!=null?bn(kn(e)):{};let o=t||!e||!e.__esModule?it(n,"default",{value:e,enumerable:!0}):n;if(e&&typeof e==="object"||typeof e==="function"){for(let a of wn(e))if(!xn.call(o,a))it(o,a,{get:_n.bind(e,a),enumerable:!0})}if(s)r.set(e,o);return o};var Sn=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var We=Sn(function(br,Ft){var Be={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"},rs={up:(e=1)=>"\x1B[S".repeat(e),down:(e=1)=>"\x1B[T".repeat(e)},is={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?Be.up():"");if(e)t+=Be.left;return t}};Ft.exports={cursor:Be,scroll:rs,erase:is,beep:"\x07"}});function je(e){return e==null?[]:Array.isArray(e)?e:[e]}function Cn(e,t,n,s){var r,i=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]=i==null?o:Array.isArray(i)?i.concat(o):[i,o]}function An(e,t){e=e||[],t=t||{};var n,s,r,i,o,a={_:[]},u=0,l=0,c=0,f=e.length;let h=t.alias!==void 0,v=t.unknown!==void 0,m=t.default!==void 0;if(t.alias=t.alias||{},t.string=je(t.string),t.boolean=je(t.boolean),h)for(n in t.alias){s=t.alias[n]=je(t.alias[n]);for(u=0;u<s.length;u++)(t.alias[s[u]]=s.concat(n)).splice(u,1)}for(u=t.boolean.length;u-- >0;){s=t.alias[t.boolean[u]]||[];for(l=s.length;l-- >0;)t.boolean.push(s[l])}for(u=t.string.length;u-- >0;){s=t.alias[t.string[u]]||[];for(l=s.length;l-- >0;)t.string.push(s[l])}if(m){for(n in t.default)if(i=typeof t.default[n],s=t.alias[n]=t.alias[n]||[],t[i]!==void 0){t[i].push(n);for(u=0;u<s.length;u++)t[i].push(s[u])}}let y=v?Object.keys(t.alias):[];for(u=0;u<f;u++){if(r=e[u],r==="--"){a._=a._.concat(e.slice(++u));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(i=r.substring(l+3),v&&!~y.indexOf(i))return t.unknown(r);a[i]=!1}else{for(c=l+1;c<r.length;c++)if(r.charCodeAt(c)===61)break;i=r.substring(l,c),o=r.substring(++c)||u+1===f||(""+e[u+1]).charCodeAt(0)===45||e[++u],s=l===2?[i]:i;for(c=0;c<s.length;c++){if(i=s[c],v&&!~y.indexOf(i))return t.unknown("-".repeat(l)+i);Cn(a,i,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 lt(e){return e.replace(/[<[].+/,"").trim()}function On(e){let t=/<([^>]+)>/g,n=/\[([^\]]+)\]/g,s=[],r=(a)=>{let u=!1,l=a[1];if(l.startsWith("..."))l=l.slice(3),u=!0;return{required:a[0].startsWith("<"),value:l,variadic:u}},i;while(i=t.exec(e))s.push(r(i));let o;while(o=n.exec(e))s.push(r(o));return s}function Mn(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,i)=>i!==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 ot(e){return e.sort((t,n)=>t.length>n.length?-1:1)[0]}function at(e,t){return e.length>=t?e:`${e}${" ".repeat(t-e.length)}`}function Dn(e){return e.replaceAll(/([a-z])-([a-z])/g,(t,n,s)=>n+s.toUpperCase())}function Fn(e,t,n){let s=e;for(let r=0;r<t.length;r++){let i=t[r];if(r===t.length-1){s[i]=n;return}if(s[i]==null){let o=+t[r+1]>-1;s[i]=o?[]:{}}s=s[i]}}function jn(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 Tn(e){let t=/([^\\/]+)$/.exec(e);return t?t[1]:""}function ct(e){return e.split(".").map((t,n)=>n===0?Dn(t):t).join(".")}var le=class extends Error{constructor(e){super(e);if(this.name="CACError",typeof Error.captureStackTrace!=="function")this.stack=Error(e).stack}},Rn=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=lt(e).split(",").map((s)=>{let r=s.trim().replace(/^-{1,2}/,"");if(r.startsWith("no-"))this.negated=!0,r=r.replace(/^no-/,"");return ct(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}},Te,ce;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";ce=`${process.platform}-${process.arch} ${e}-${process.version}`,Te=process.argv}else if(typeof navigator>"u")ce="unknown";else ce=`${navigator.platform} ${navigator.userAgent}`;var ft=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=lt(e),this.args=On(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 Rn(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 pt}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,i=[{body:`${e}${n?`/${n}`:""}`}];if(i.push({title:"Usage",body:` $ ${e} ${this.usageText||this.rawName}`}),(this.isGlobalCommand||this.isDefaultCommand)&&t.length>0){let a=ot(t.map((u)=>u.rawName));i.push({title:"Commands",body:t.map((u)=>` ${at(u.rawName,a.length)} ${u.description}`).join(`
3
+ var Sn=Object.create;var{getPrototypeOf:An,defineProperty:at,getOwnPropertyNames:Cn}=Object;var lt=Object.prototype.hasOwnProperty;function Mn(e){return this[e]}var On,Dn,ct=(e,t,n)=>{var s=e!=null&&typeof e==="object";if(s){var r=t?On??=new WeakMap:Dn??=new WeakMap,i=r.get(e);if(i)return i}n=e!=null?Sn(An(e)):{};let o=t||!e||!e.__esModule||!lt.call(e,"default")?at(n,"default",{value:e,enumerable:!0}):n;if(e&&typeof e==="object"||typeof e==="function"){for(let a of Cn(e))if(!lt.call(o,a))at(o,a,{get:Mn.bind(e,a),enumerable:!0})}if(s)r.set(e,o);return o};var Pn=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var Ke=Pn(function(Mr,Tt){var ze={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"},cs={up:(e=1)=>"\x1B[S".repeat(e),down:(e=1)=>"\x1B[T".repeat(e)},fs={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?ze.up():"");if(e)t+=ze.left;return t}};Tt.exports={cursor:ze,scroll:cs,erase:fs,beep:"\x07"}});function Te(e){return e==null?[]:Array.isArray(e)?e:[e]}function Fn(e,t,n,s){var r,i=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]=i==null?o:Array.isArray(i)?i.concat(o):[i,o]}function jn(e,t){e=e||[],t=t||{};var n,s,r,i,o,a={_:[]},u=0,l=0,c=0,f=e.length;let h=t.alias!==void 0,v=t.unknown!==void 0,m=t.default!==void 0;if(t.alias=t.alias||{},t.string=Te(t.string),t.boolean=Te(t.boolean),h)for(n in t.alias){s=t.alias[n]=Te(t.alias[n]);for(u=0;u<s.length;u++)(t.alias[s[u]]=s.concat(n)).splice(u,1)}for(u=t.boolean.length;u-- >0;){s=t.alias[t.boolean[u]]||[];for(l=s.length;l-- >0;)t.boolean.push(s[l])}for(u=t.string.length;u-- >0;){s=t.alias[t.string[u]]||[];for(l=s.length;l-- >0;)t.string.push(s[l])}if(m){for(n in t.default)if(i=typeof t.default[n],s=t.alias[n]=t.alias[n]||[],t[i]!==void 0){t[i].push(n);for(u=0;u<s.length;u++)t[i].push(s[u])}}let d=v?Object.keys(t.alias):[];for(u=0;u<f;u++){if(r=e[u],r==="--"){a._=a._.concat(e.slice(++u));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(i=r.substring(l+3),v&&!~d.indexOf(i))return t.unknown(r);a[i]=!1}else{for(c=l+1;c<r.length;c++)if(r.charCodeAt(c)===61)break;i=r.substring(l,c),o=r.substring(++c)||u+1===f||(""+e[u+1]).charCodeAt(0)===45||e[++u],s=l===2?[i]:i;for(c=0;c<s.length;c++){if(i=s[c],v&&!~d.indexOf(i))return t.unknown("-".repeat(l)+i);Fn(a,i,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 ht(e){return e.replace(/[<[].+/,"").trim()}function Rn(e){let t=/<([^>]+)>/g,n=/\[([^\]]+)\]/g,s=[],r=(a)=>{let u=!1,l=a[1];if(l.startsWith("..."))l=l.slice(3),u=!0;return{required:a[0].startsWith("<"),value:l,variadic:u}},i;while(i=t.exec(e))s.push(r(i));let o;while(o=n.exec(e))s.push(r(o));return s}function Tn(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,i)=>i!==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 ft(e){return e.sort((t,n)=>t.length>n.length?-1:1)[0]}function pt(e,t){return e.length>=t?e:`${e}${" ".repeat(t-e.length)}`}function Nn(e){return e.replaceAll(/([a-z])-([a-z])/g,(t,n,s)=>n+s.toUpperCase())}function Vn(e,t,n){let s=e;for(let r=0;r<t.length;r++){let i=t[r];if(r===t.length-1){s[i]=n;return}if(s[i]==null){let o=+t[r+1]>-1;s[i]=o?[]:{}}s=s[i]}}function Gn(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 Ln(e){let t=/([^\\/]+)$/.exec(e);return t?t[1]:""}function mt(e){return e.split(".").map((t,n)=>n===0?Nn(t):t).join(".")}var fe=class extends Error{constructor(e){super(e);if(this.name="CACError",typeof Error.captureStackTrace!=="function")this.stack=Error(e).stack}},qn=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=ht(e).split(",").map((s)=>{let r=s.trim().replace(/^-{1,2}/,"");if(r.startsWith("no-"))this.negated=!0,r=r.replace(/^no-/,"");return mt(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}},Ne,pe;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";pe=`${process.platform}-${process.arch} ${e}-${process.version}`,Ne=process.argv}else if(typeof navigator>"u")pe="unknown";else pe=`${navigator.platform} ${navigator.userAgent}`;var yt=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=ht(e),this.args=Rn(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 qn(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 dt}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,i=[{body:`${e}${n?`/${n}`:""}`}];if(i.push({title:"Usage",body:` $ ${e} ${this.usageText||this.rawName}`}),(this.isGlobalCommand||this.isDefaultCommand)&&t.length>0){let a=ft(t.map((u)=>u.rawName));i.push({title:"Commands",body:t.map((u)=>` ${pt(u.rawName,a.length)} ${u.description}`).join(`
4
4
  `)},{title:"For more info, run any command with the `--help` flag",body:t.map((u)=>` $ ${e}${u.name===""?"":` ${u.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=ot(o.map((u)=>u.rawName));i.push({title:"Options",body:o.map((u)=>` ${at(u.rawName,a.length)} ${u.description} ${u.config.default===void 0?"":`(default: ${u.config.default})`}`).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=ft(o.map((u)=>u.rawName));i.push({title:"Options",body:o.map((u)=>` ${pt(u.rawName,a.length)} ${u.description} ${u.config.default===void 0?"":`(default: ${u.config.default})`}`).join(`
6
6
  `)})}if(this.examples.length>0)i.push({title:"Examples",body:this.examples.map((a)=>{if(typeof a==="function")return a(e);return a}).join(`
7
7
  `)});if(r)i=r(i)||i;console.info(i.map((a)=>a.title?`${a.title}:
8
8
  ${a.body}`:a.body).join(`
9
9
 
10
- `))}outputVersion(){let{name:e}=this.cli,{versionNumber:t}=this.cli.globalCommand;if(t)console.info(`${e}/${t} ${ce}`)}checkRequiredArgs(){let e=this.args.filter((t)=>t.required).length;if(this.cli.args.length<e)throw new le(`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 le(`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 i=n.some((o)=>o.negated&&o.names.includes(s.name));if(r===!0||r===!1&&!i)throw new le(`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 le(`Unused args: ${this.cli.args.slice(e).map((t)=>`\`${t}\``).join(", ")}`)}},pt=class extends ft{constructor(e){super("@@global@@","",{},e)}},Pn=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 pt(this),this.globalCommand.usage("<command> [options]")}usage(e){return this.globalCommand.usage(e),this}command(e,t,n){let s=new ft(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(!Te)throw Error("No argv provided and runtime process argv is not available.");e=Te}if(this.rawArgs=e,!this.name)this.name=e[1]?Tn(e[1]):"cli";let n=!0;for(let r of this.commands){let i=this.mri(e.slice(2),r),o=i.args[0];if(r.isMatched(o)){n=!1;let a={...i,args:i.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 i=this.mri(e.slice(2),r);this.setParsedInfo(i,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=Mn(n),r=[],i=e.indexOf("--");if(i!==-1)r=e.slice(i+1),e=e.slice(0,i);let o=An(e,s);o=Object.keys(o).reduce((f,h)=>({...f,[ct(h)]:o[h]}),{_:[]});let a=o._,u={"--":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)u[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!=="_")Fn(u,f.split("."),o[f]),jn(u,c);return{args:a,options:u}}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,i)=>{if(r.variadic)s.push(e.slice(i));else s.push(e[i])}),s.push(t),n.commandAction.apply(this,s)}},ht=(e="")=>new Pn(e);import rr from"path";var fe,Nn={lang:void 0,message:void 0,abortEarly:void 0,abortPipeEarly:void 0};function dt(e){if(!e&&!fe)return Nn;return{lang:e?.lang??fe?.lang,message:e?.message,abortEarly:e?.abortEarly??fe?.abortEarly,abortPipeEarly:e?.abortPipeEarly??fe?.abortPipeEarly}}var Vn;function Ln(e){return Vn?.get(e)}var Gn;function qn(e){return Gn?.get(e)}var Un;function Bn(e,t){return Un?.get(e)?.get(t)}function Re(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 A(e,t,n,s,r){let i=r&&"input"in r?r.input:n.value,o=r?.expected??e.expects??null,a=r?.received??Re(i),u={kind:e.kind,type:e.type,input:i,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??Bn(e.reference,u.lang)??(l?qn(u.lang):null)??s.message??Ln(u.lang);if(c!==void 0)u.message=typeof c==="function"?c(u):c;if(l)n.typed=!1;if(n.issues)n.issues.push(u);else n.issues=[u]}var mt=new WeakMap;function F(e){let t=mt.get(e);if(!t)t={version:1,vendor:"valibot",validate(n){return e["~run"]({value:n},dt())}},mt.set(e,t);return t}function gt(e,t){let n=[...new Set(e)];if(n.length>1)return`(${n.join(` ${t} `)})`;return n[0]??"never"}var ee=class extends Error{constructor(e){super(e[0].message);this.name="ValiError",this.issues=e}};function vt(e,t,n){return typeof e.fallback==="function"?e.fallback(t,n):e.fallback}function Pe(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 F(this)},"~run"(n,s){let r=n.value;if(Array.isArray(r)){n.typed=!0,n.value=[];for(let i=0;i<r.length;i++){let o=r[i],a=this.item["~run"]({value:o},s);if(a.issues){let u={type:"array",origin:"value",input:r,key:i,value:o};for(let l of a.issues){if(l.path)l.path.unshift(u);else l.path=[u];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 A(this,"type",n,s);return n}}}function te(e){return{kind:"schema",type:"boolean",reference:te,expects:"boolean",async:!1,message:e,get "~standard"(){return F(this)},"~run"(t,n){if(typeof t.value==="boolean")t.typed=!0;else A(this,"type",t,n);return t}}}function Ne(e,t){return{kind:"schema",type:"literal",reference:Ne,expects:Re(e),async:!1,literal:e,message:t,get "~standard"(){return F(this)},"~run"(n,s){if(n.value===this.literal)n.typed=!0;else A(this,"type",n,s);return n}}}function K(e,t){return{kind:"schema",type:"object",reference:K,expects:"Object",async:!1,entries:e,message:t,get "~standard"(){return F(this)},"~run"(n,s){let r=n.value;if(r&&typeof r==="object"){n.typed=!0,n.value={};for(let i in this.entries){let o=this.entries[i];if(i in r||(o.type==="exact_optional"||o.type==="optional"||o.type==="nullish")&&o.default!==void 0){let a=i in r?r[i]:Pe(o),u=o["~run"]({value:a},s);if(u.issues){let l={type:"object",origin:"value",input:r,key:i,value:a};for(let c of u.issues){if(c.path)c.path.unshift(l);else c.path=[l];n.issues?.push(c)}if(!n.issues)n.issues=u.issues;if(s.abortEarly){n.typed=!1;break}}if(!u.typed)n.typed=!1;n.value[i]=u.value}else if(o.fallback!==void 0)n.value[i]=vt(o);else if(o.type!=="exact_optional"&&o.type!=="optional"&&o.type!=="nullish"){if(A(this,"key",n,s,{input:void 0,expected:`"${i}"`,path:[{type:"object",origin:"key",input:r,key:i,value:r[i]}]}),s.abortEarly)break}}}else A(this,"type",n,s);return n}}}function ne(e,t){return{kind:"schema",type:"optional",reference:ne,expects:`(${e.expects} | undefined)`,async:!1,wrapped:e,default:t,get "~standard"(){return F(this)},"~run"(n,s){if(n.value===void 0){if(this.default!==void 0)n.value=Pe(this,n,s);if(n.value===void 0)return n.typed=!0,n}return this.wrapped["~run"](n,s)}}}function se(e,t){return{kind:"schema",type:"picklist",reference:se,expects:gt(e.map(Re),"|"),async:!1,options:e,message:t,get "~standard"(){return F(this)},"~run"(n,s){if(this.options.includes(n.value))n.typed=!0;else A(this,"type",n,s);return n}}}function Ve(e,t){return{kind:"schema",type:"strict_object",reference:Ve,expects:"Object",async:!1,entries:e,message:t,get "~standard"(){return F(this)},"~run"(n,s){let r=n.value;if(r&&typeof r==="object"){n.typed=!0,n.value={};for(let i in this.entries){let o=this.entries[i];if(i in r||(o.type==="exact_optional"||o.type==="optional"||o.type==="nullish")&&o.default!==void 0){let a=i in r?r[i]:Pe(o),u=o["~run"]({value:a},s);if(u.issues){let l={type:"object",origin:"value",input:r,key:i,value:a};for(let c of u.issues){if(c.path)c.path.unshift(l);else c.path=[l];n.issues?.push(c)}if(!n.issues)n.issues=u.issues;if(s.abortEarly){n.typed=!1;break}}if(!u.typed)n.typed=!1;n.value[i]=u.value}else if(o.fallback!==void 0)n.value[i]=vt(o);else if(o.type!=="exact_optional"&&o.type!=="optional"&&o.type!=="nullish"){if(A(this,"key",n,s,{input:void 0,expected:`"${i}"`,path:[{type:"object",origin:"key",input:r,key:i,value:r[i]}]}),s.abortEarly)break}}if(!n.issues||!s.abortEarly){for(let i in r)if(!(i in this.entries)){A(this,"key",n,s,{input:i,expected:"never",path:[{type:"object",origin:"key",input:r,key:i,value:r[i]}]});break}}}else A(this,"type",n,s);return n}}}function j(e){return{kind:"schema",type:"string",reference:j,expects:"string",async:!1,message:e,get "~standard"(){return F(this)},"~run"(t,n){if(typeof t.value==="string")t.typed=!0;else A(this,"type",t,n);return t}}}function yt(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 re(e,t){return{kind:"schema",type:"union",reference:re,expects:gt(e.map((n)=>n.expects),"|"),async:!1,options:e,message:t,get "~standard"(){return F(this)},"~run"(n,s){let r,i,o;for(let a of this.options){let u=a["~run"]({value:n.value},s);if(u.typed)if(u.issues)if(i)i.push(u);else i=[u];else{r=u;break}else if(o)o.push(u);else o=[u]}if(r)return r;if(i){if(i.length===1)return i[0];A(this,"type",n,s,{issues:yt(i)}),n.typed=!0}else if(o?.length===1)return o[0];else A(this,"type",n,s,{issues:yt(o)});return n}}}function pe(e,t,n){let s=e["~run"]({value:t},dt(n));if(s.issues)throw new ee(s.issues);return s.value}function Le(e,t){let n={};for(let s in e.entries)n[s]=!t||t.includes(s)?ne(e.entries[s]):e.entries[s];return{...e,entries:n,get "~standard"(){return F(this)}}}import{stdout as ze,stdin as Tt}from"process";import*as W from"readline";import us from"readline";var $t=(()=>{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}})(),bt=(e)=>e===12288||e>=65281&&e<=65376||e>=65504&&e<=65510,kt=(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 Wn=/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]|\u001b\]8;[^;]*;.*?(?:\u0007|\u001b\u005c)/y,Hn=/[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y,wt=/(?:(?![\uFF61-\uFF9F\uFF00-\uFFEF])[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}\p{Script=Tangut}]){1,1000}/yu,zn=/\t{1,1000}/y,xt=/[\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,Kn=/(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y,Xn=/\p{M}+/gu,Jn={limit:1/0,ellipsis:""},_t=(e,t={},n={})=>{let s=t.limit??1/0,r=t.ellipsis??"",i=t?.ellipsisWidth??(r?_t(r,Jn,n).width:0),o=0,a=n.controlWidth??0,u=n.tabWidth??8,l=n.emojiWidth??2,c=2,f=n.regularWidth??1,h=n.wideWidth??2,v=[[Kn,f],[Wn,0],[Hn,a],[zn,u],[xt,l],[wt,h]],m=0,y=0,T=e.length,q=0,U=!1,M=T,R=Math.max(0,s-i),I=0,J=0,D=0,E=0;e:while(!0){if(J>I||y>=T&&y>m){let B=e.slice(I,J)||e.slice(m,y);q=0;for(let z of B.replaceAll(Xn,"")){let S=z.codePointAt(0)||0;if(bt(S))E=2;else if(kt(S))E=h;else E=f;if(D+E>R)M=Math.min(M,Math.max(I,m)+q);if(D+E>s){U=!0;break e}q+=z.length,D+=E}I=J=0}if(y>=T)break e;for(let B=0,z=v.length;B<z;B++){let[S,oe]=v[B];if(S.lastIndex=y,S.test(e)){if(q=S===wt?$t(e.slice(y,S.lastIndex)):S===xt?1:S.lastIndex-y,E=q*oe,D+E>R)M=Math.min(M,y+Math.floor((R-D)/oe));if(D+E>s){U=!0;break e}D+=E,I=m,J=y,y=m=S.lastIndex;continue e}}y+=1}return{width:U?R:D,index:U?M:T,truncated:U,ellipsed:U&&s>=i}},Et=_t;var Zn={limit:1/0,ellipsis:"",ellipsisWidth:0},Yn=(e,t={})=>Et(e,Zn,t).width,w=Yn;var me="\x1B",Ot="\x9B",Qn=39,qe="\x07",Mt="[",es="]",Dt="m",Ue=`${es}8;;`,It=new RegExp(`(?:\\${Mt}(?<code>\\d+)m|\\${Ue}(?<uri>.*)${qe})`,"y"),St=(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},Ct=(e)=>`${me}${Mt}${e}${Dt}`,At=(e)=>`${me}${Ue}${e}${qe}`,Ge=(e,t,n)=>{let s=t[Symbol.iterator](),r=!1,i=!1,o=e.at(-1),a=o===void 0?0:w(o),u=s.next(),l=s.next(),c=0;while(!u.done){let f=u.value,h=w(f);if(a+h<=n)e[e.length-1]+=f;else e.push(f),a=0;if(f===me||f===Ot)r=!0,i=t.startsWith(Ue,c+1);if(r){if(i){if(f===qe)r=!1,i=!1}else if(f===Dt)r=!1}else if(a+=h,a===n&&!l.done)e.push(""),a=0;u=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()},ts=(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("")},ns=(e,t,n={})=>{if(n.trim!==!1&&e.trim()==="")return"";let s="",r,i,o=e.split(" "),a=[""],u=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,u=w(y)}if(f!==0){if(u>=t&&(n.wordWrap===!1||n.trim===!1))a.push(""),u=0;if(u||n.trim===!1)a[a.length-1]+=" ",u++}let v=w(h);if(n.hard&&v>t){let m=t-u,y=1+Math.floor((v-m-1)/t);if(Math.floor((v-1)/t)<y)a.push("");Ge(a,h,t),u=w(a.at(-1)??"");continue}if(u+v>t&&u&&v){if(n.wordWrap===!1&&u<t){Ge(a,h,t),u=w(a.at(-1)??"");continue}a.push(""),u=0}if(u+v>t&&n.wordWrap===!1){Ge(a,h,t),u=w(a.at(-1)??"");continue}a[a.length-1]+=h,u+=v}if(n.trim!==!1)a=a.map((f)=>ts(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===me||h===Ot){It.lastIndex=f+1;let m=It.exec(l)?.groups;if(m?.code!==void 0){let y=Number.parseFloat(m.code);r=y===Qn?void 0:y}else if(m?.uri!==void 0)i=m.uri.length===0?void 0:m.uri}if(l[f+1]===`
12
- `){if(i)s+=At("");let v=r?St(r):void 0;if(r&&v)s+=Ct(v)}else if(h===`
13
- `){if(r&&St(r))s+=Ct(r);if(i)s+=At(i)}}return s},ss=/\r?\n/;function L(e,t,n){return String(e).normalize().split(ss).map((s)=>ns(s,t,n)).join(`
14
- `)}var k=ut(We(),1);import{ReadStream as jt}from"tty";var os=["up","down","left","right","space","enter","cancel"],as=["January","February","March","April","May","June","July","August","September","October","November","December"],_={actions:new Set(os),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:[...as],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 Ke(e,t){if(typeof e=="string")return _.aliases.get(e)===t;for(let n of e)if(n!==void 0&&Ke(n,t))return!0;return!1}function ls(e,t){if(e===t)return;let n=e.split(`
10
+ `))}outputVersion(){let{name:e}=this.cli,{versionNumber:t}=this.cli.globalCommand;if(t)console.info(`${e}/${t} ${pe}`)}checkRequiredArgs(){let e=this.args.filter((t)=>t.required).length;if(this.cli.args.length<e)throw new fe(`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 fe(`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 i=n.some((o)=>o.negated&&o.names.includes(s.name));if(r===!0||r===!1&&!i)throw new fe(`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 fe(`Unused args: ${this.cli.args.slice(e).map((t)=>`\`${t}\``).join(", ")}`)}},dt=class extends yt{constructor(e){super("@@global@@","",{},e)}},Un=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 dt(this),this.globalCommand.usage("<command> [options]")}usage(e){return this.globalCommand.usage(e),this}command(e,t,n){let s=new yt(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(!Ne)throw Error("No argv provided and runtime process argv is not available.");e=Ne}if(this.rawArgs=e,!this.name)this.name=e[1]?Ln(e[1]):"cli";let n=!0;for(let r of this.commands){let i=this.mri(e.slice(2),r),o=i.args[0];if(r.isMatched(o)){n=!1;let a={...i,args:i.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 i=this.mri(e.slice(2),r);this.setParsedInfo(i,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=Tn(n),r=[],i=e.indexOf("--");if(i!==-1)r=e.slice(i+1),e=e.slice(0,i);let o=jn(e,s);o=Object.keys(o).reduce((f,h)=>({...f,[mt(h)]:o[h]}),{_:[]});let a=o._,u={"--":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)u[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!=="_")Vn(u,f.split("."),o[f]),Gn(u,c);return{args:a,options:u}}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,i)=>{if(r.variadic)s.push(e.slice(i));else s.push(e[i])}),s.push(t),n.commandAction.apply(this,s)}},gt=(e="")=>new Un(e);import mr from"path";var he,Bn={lang:void 0,message:void 0,abortEarly:void 0,abortPipeEarly:void 0};function $t(e){if(!e&&!he)return Bn;return{lang:e?.lang??he?.lang,message:e?.message,abortEarly:e?.abortEarly??he?.abortEarly,abortPipeEarly:e?.abortPipeEarly??he?.abortPipeEarly}}var Wn;function Hn(e){return Wn?.get(e)}var zn;function Kn(e){return zn?.get(e)}var Xn;function Jn(e,t){return Xn?.get(e)?.get(t)}function Ve(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 C(e,t,n,s,r){let i=r&&"input"in r?r.input:n.value,o=r?.expected??e.expects??null,a=r?.received??Ve(i),u={kind:e.kind,type:e.type,input:i,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??Jn(e.reference,u.lang)??(l?Kn(u.lang):null)??s.message??Hn(u.lang);if(c!==void 0)u.message=typeof c==="function"?c(u):c;if(l)n.typed=!1;if(n.issues)n.issues.push(u);else n.issues=[u]}var vt=new WeakMap;function F(e){let t=vt.get(e);if(!t)t={version:1,vendor:"valibot",validate(n){return e["~run"]({value:n},$t())}},vt.set(e,t);return t}function bt(e,t){let n=[...new Set(e)];if(n.length>1)return`(${n.join(` ${t} `)})`;return n[0]??"never"}var te=class extends Error{constructor(e){super(e[0].message);this.name="ValiError",this.issues=e}};function wt(e,t,n){return typeof e.fallback==="function"?e.fallback(t,n):e.fallback}function Ge(e,t,n){return typeof e.default==="function"?e.default(t,n):e.default}function X(e,t){return{kind:"schema",type:"array",reference:X,expects:"Array",async:!1,item:e,message:t,get "~standard"(){return F(this)},"~run"(n,s){let r=n.value;if(Array.isArray(r)){n.typed=!0,n.value=[];for(let i=0;i<r.length;i++){let o=r[i],a=this.item["~run"]({value:o},s);if(a.issues){let u={type:"array",origin:"value",input:r,key:i,value:o};for(let l of a.issues){if(l.path)l.path.unshift(u);else l.path=[u];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 C(this,"type",n,s);return n}}}function ne(e){return{kind:"schema",type:"boolean",reference:ne,expects:"boolean",async:!1,message:e,get "~standard"(){return F(this)},"~run"(t,n){if(typeof t.value==="boolean")t.typed=!0;else C(this,"type",t,n);return t}}}function Le(e,t){return{kind:"schema",type:"literal",reference:Le,expects:Ve(e),async:!1,literal:e,message:t,get "~standard"(){return F(this)},"~run"(n,s){if(n.value===this.literal)n.typed=!0;else C(this,"type",n,s);return n}}}function J(e,t){return{kind:"schema",type:"object",reference:J,expects:"Object",async:!1,entries:e,message:t,get "~standard"(){return F(this)},"~run"(n,s){let r=n.value;if(r&&typeof r==="object"){n.typed=!0,n.value={};for(let i in this.entries){let o=this.entries[i];if(i in r||(o.type==="exact_optional"||o.type==="optional"||o.type==="nullish")&&o.default!==void 0){let a=i in r?r[i]:Ge(o),u=o["~run"]({value:a},s);if(u.issues){let l={type:"object",origin:"value",input:r,key:i,value:a};for(let c of u.issues){if(c.path)c.path.unshift(l);else c.path=[l];n.issues?.push(c)}if(!n.issues)n.issues=u.issues;if(s.abortEarly){n.typed=!1;break}}if(!u.typed)n.typed=!1;n.value[i]=u.value}else if(o.fallback!==void 0)n.value[i]=wt(o);else if(o.type!=="exact_optional"&&o.type!=="optional"&&o.type!=="nullish"){if(C(this,"key",n,s,{input:void 0,expected:`"${i}"`,path:[{type:"object",origin:"key",input:r,key:i,value:r[i]}]}),s.abortEarly)break}}}else C(this,"type",n,s);return n}}}function se(e,t){return{kind:"schema",type:"optional",reference:se,expects:`(${e.expects} | undefined)`,async:!1,wrapped:e,default:t,get "~standard"(){return F(this)},"~run"(n,s){if(n.value===void 0){if(this.default!==void 0)n.value=Ge(this,n,s);if(n.value===void 0)return n.typed=!0,n}return this.wrapped["~run"](n,s)}}}function re(e,t){return{kind:"schema",type:"picklist",reference:re,expects:bt(e.map(Ve),"|"),async:!1,options:e,message:t,get "~standard"(){return F(this)},"~run"(n,s){if(this.options.includes(n.value))n.typed=!0;else C(this,"type",n,s);return n}}}function qe(e,t){return{kind:"schema",type:"strict_object",reference:qe,expects:"Object",async:!1,entries:e,message:t,get "~standard"(){return F(this)},"~run"(n,s){let r=n.value;if(r&&typeof r==="object"){n.typed=!0,n.value={};for(let i in this.entries){let o=this.entries[i];if(i in r||(o.type==="exact_optional"||o.type==="optional"||o.type==="nullish")&&o.default!==void 0){let a=i in r?r[i]:Ge(o),u=o["~run"]({value:a},s);if(u.issues){let l={type:"object",origin:"value",input:r,key:i,value:a};for(let c of u.issues){if(c.path)c.path.unshift(l);else c.path=[l];n.issues?.push(c)}if(!n.issues)n.issues=u.issues;if(s.abortEarly){n.typed=!1;break}}if(!u.typed)n.typed=!1;n.value[i]=u.value}else if(o.fallback!==void 0)n.value[i]=wt(o);else if(o.type!=="exact_optional"&&o.type!=="optional"&&o.type!=="nullish"){if(C(this,"key",n,s,{input:void 0,expected:`"${i}"`,path:[{type:"object",origin:"key",input:r,key:i,value:r[i]}]}),s.abortEarly)break}}if(!n.issues||!s.abortEarly){for(let i in r)if(!(i in this.entries)){C(this,"key",n,s,{input:i,expected:"never",path:[{type:"object",origin:"key",input:r,key:i,value:r[i]}]});break}}}else C(this,"type",n,s);return n}}}function B(e){return{kind:"schema",type:"string",reference:B,expects:"string",async:!1,message:e,get "~standard"(){return F(this)},"~run"(t,n){if(typeof t.value==="string")t.typed=!0;else C(this,"type",t,n);return t}}}function kt(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 ie(e,t){return{kind:"schema",type:"union",reference:ie,expects:bt(e.map((n)=>n.expects),"|"),async:!1,options:e,message:t,get "~standard"(){return F(this)},"~run"(n,s){let r,i,o;for(let a of this.options){let u=a["~run"]({value:n.value},s);if(u.typed)if(u.issues)if(i)i.push(u);else i=[u];else{r=u;break}else if(o)o.push(u);else o=[u]}if(r)return r;if(i){if(i.length===1)return i[0];C(this,"type",n,s,{issues:kt(i)}),n.typed=!0}else if(o?.length===1)return o[0];else C(this,"type",n,s,{issues:kt(o)});return n}}}function me(e,t,n){let s=e["~run"]({value:t},$t(n));if(s.issues)throw new te(s.issues);return s.value}function Ue(e,t){let n={};for(let s in e.entries)n[s]=!t||t.includes(s)?se(e.entries[s]):e.entries[s];return{...e,entries:n,get "~standard"(){return F(this)}}}import{stdout as Je,stdin as Vt}from"process";import*as W from"readline";import ps from"readline";var xt=(()=>{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}})(),Et=(e)=>e===12288||e>=65281&&e<=65376||e>=65504&&e<=65510,_t=(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 Zn=/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]|\u001b\]8;[^;]*;.*?(?:\u0007|\u001b\u005c)/y,Yn=/[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y,It=/(?:(?![\uFF61-\uFF9F\uFF00-\uFFEF])[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}\p{Script=Tangut}]){1,1000}/yu,Qn=/\t{1,1000}/y,St=/[\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,es=/(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y,ts=/\p{M}+/gu,ns={limit:1/0,ellipsis:""},At=(e,t={},n={})=>{let s=t.limit??1/0,r=t.ellipsis??"",i=t?.ellipsisWidth??(r?At(r,ns,n).width:0),o=0,a=n.controlWidth??0,u=n.tabWidth??8,l=n.emojiWidth??2,c=2,f=n.regularWidth??1,h=n.wideWidth??2,v=[[es,f],[Zn,0],[Yn,a],[Qn,u],[St,l],[It,h]],m=0,d=0,j=e.length,L=0,q=!1,D=j,R=Math.max(0,s-i),I=0,Q=0,P=0,_=0;e:while(!0){if(Q>I||d>=j&&d>m){let U=e.slice(I,Q)||e.slice(m,d);L=0;for(let K of U.replaceAll(ts,"")){let S=K.codePointAt(0)||0;if(Et(S))_=2;else if(_t(S))_=h;else _=f;if(P+_>R)D=Math.min(D,Math.max(I,m)+L);if(P+_>s){q=!0;break e}L+=K.length,P+=_}I=Q=0}if(d>=j)break e;for(let U=0,K=v.length;U<K;U++){let[S,le]=v[U];if(S.lastIndex=d,S.test(e)){if(L=S===It?xt(e.slice(d,S.lastIndex)):S===St?1:S.lastIndex-d,_=L*le,P+_>R)D=Math.min(D,d+Math.floor((R-P)/le));if(P+_>s){q=!0;break e}P+=_,I=m,Q=d,d=m=S.lastIndex;continue e}}d+=1}return{width:q?R:P,index:q?D:j,truncated:q,ellipsed:q&&s>=i}},Ct=At;var ss={limit:1/0,ellipsis:"",ellipsisWidth:0},rs=(e,t={})=>Ct(e,ss,t).width,w=rs;var de="\x1B",Ft="\x9B",is=39,We="\x07",jt="[",us="]",Rt="m",He=`${us}8;;`,Mt=new RegExp(`(?:\\${jt}(?<code>\\d+)m|\\${He}(?<uri>.*)${We})`,"y"),Ot=(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},Dt=(e)=>`${de}${jt}${e}${Rt}`,Pt=(e)=>`${de}${He}${e}${We}`,Be=(e,t,n)=>{let s=t[Symbol.iterator](),r=!1,i=!1,o=e.at(-1),a=o===void 0?0:w(o),u=s.next(),l=s.next(),c=0;while(!u.done){let f=u.value,h=w(f);if(a+h<=n)e[e.length-1]+=f;else e.push(f),a=0;if(f===de||f===Ft)r=!0,i=t.startsWith(He,c+1);if(r){if(i){if(f===We)r=!1,i=!1}else if(f===Rt)r=!1}else if(a+=h,a===n&&!l.done)e.push(""),a=0;u=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()},os=(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("")},as=(e,t,n={})=>{if(n.trim!==!1&&e.trim()==="")return"";let s="",r,i,o=e.split(" "),a=[""],u=0;for(let f=0;f<o.length;f++){let h=o[f];if(n.trim!==!1){let m=a.at(-1)??"",d=m.trimStart();if(m.length!==d.length)a[a.length-1]=d,u=w(d)}if(f!==0){if(u>=t&&(n.wordWrap===!1||n.trim===!1))a.push(""),u=0;if(u||n.trim===!1)a[a.length-1]+=" ",u++}let v=w(h);if(n.hard&&v>t){let m=t-u,d=1+Math.floor((v-m-1)/t);if(Math.floor((v-1)/t)<d)a.push("");Be(a,h,t),u=w(a.at(-1)??"");continue}if(u+v>t&&u&&v){if(n.wordWrap===!1&&u<t){Be(a,h,t),u=w(a.at(-1)??"");continue}a.push(""),u=0}if(u+v>t&&n.wordWrap===!1){Be(a,h,t),u=w(a.at(-1)??"");continue}a[a.length-1]+=h,u+=v}if(n.trim!==!1)a=a.map((f)=>os(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===de||h===Ft){Mt.lastIndex=f+1;let m=Mt.exec(l)?.groups;if(m?.code!==void 0){let d=Number.parseFloat(m.code);r=d===is?void 0:d}else if(m?.uri!==void 0)i=m.uri.length===0?void 0:m.uri}if(l[f+1]===`
12
+ `){if(i)s+=Pt("");let v=r?Ot(r):void 0;if(r&&v)s+=Dt(v)}else if(h===`
13
+ `){if(r&&Ot(r))s+=Dt(r);if(i)s+=Pt(i)}}return s},ls=/\r?\n/;function V(e,t,n){return String(e).normalize().split(ls).map((s)=>as(s,t,n)).join(`
14
+ `)}var b=ct(Ke(),1);import{ReadStream as Nt}from"tty";var hs=["up","down","left","right","space","enter","cancel"],ms=["January","February","March","April","May","June","July","August","September","October","November","December"],E={actions:new Set(hs),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:[...ms],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 Ze(e,t){if(typeof e=="string")return E.aliases.get(e)===t;for(let n of e)if(n!==void 0&&Ze(n,t))return!0;return!1}function ys(e,t){if(e===t)return;let n=e.split(`
15
15
  `),s=t.split(`
16
- `),r=Math.max(n.length,s.length),i=[];for(let o=0;o<r;o++)n[o]!==s[o]&&i.push(o);return{lines:i,numLinesBefore:n.length,numLinesAfter:s.length,numLines:r}}var cs=globalThis.process.platform.startsWith("win"),He=Symbol("clack:cancel");function de(e){return e===He}function ye(e,t){let n=e;n.isTTY&&n.setRawMode(t)}function Rt({input:e=Tt,output:t=ze,overwrite:n=!0,hideCursor:s=!0}={}){let r=W.createInterface({input:e,output:t,prompt:"",tabSize:1});W.emitKeypressEvents(e,r),e instanceof jt&&e.isTTY&&e.setRawMode(!0);let i=(o,{name:a,sequence:u})=>{let l=String(o);if(Ke([l,a,u],"cancel")){s&&t.write(k.cursor.show),process.exit(0);return}if(!n)return;W.moveCursor(t,a==="return"?0:-1,a==="return"?-1:0,()=>{W.clearLine(t,1,()=>{e.once("keypress",i)})})};return s&&t.write(k.cursor.hide),e.once("keypress",i),()=>{e.off("keypress",i),s&&t.write(k.cursor.show),e instanceof jt&&e.isTTY&&!cs&&e.setRawMode(!1),r.terminal=!1,r.close()}}var ge=(e)=>("columns"in e)&&typeof e.columns=="number"?e.columns:80,Pt=(e)=>("rows"in e)&&typeof e.rows=="number"?e.rows:20;function Nt(e,t,n,s=n,r=n,i){let o=ge(e??ze);return L(t,o-n.length,{hard:!0,trim:!1}).split(`
16
+ `),r=Math.max(n.length,s.length),i=[];for(let o=0;o<r;o++)n[o]!==s[o]&&i.push(o);return{lines:i,numLinesBefore:n.length,numLinesAfter:s.length,numLines:r}}var ds=globalThis.process.platform.startsWith("win"),Xe=Symbol("clack:cancel");function ve(e){return e===Xe}function ge(e,t){let n=e;n.isTTY&&n.setRawMode(t)}function Gt({input:e=Vt,output:t=Je,overwrite:n=!0,hideCursor:s=!0}={}){let r=W.createInterface({input:e,output:t,prompt:"",tabSize:1});W.emitKeypressEvents(e,r),e instanceof Nt&&e.isTTY&&e.setRawMode(!0);let i=(o,{name:a,sequence:u})=>{let l=String(o);if(Ze([l,a,u],"cancel")){s&&t.write(b.cursor.show),process.exit(0);return}if(!n)return;W.moveCursor(t,a==="return"?0:-1,a==="return"?-1:0,()=>{W.clearLine(t,1,()=>{e.once("keypress",i)})})};return s&&t.write(b.cursor.hide),e.once("keypress",i),()=>{e.off("keypress",i),s&&t.write(b.cursor.show),e instanceof Nt&&e.isTTY&&!ds&&e.setRawMode(!1),r.terminal=!1,r.close()}}var ke=(e)=>("columns"in e)&&typeof e.columns=="number"?e.columns:80,Lt=(e)=>("rows"in e)&&typeof e.rows=="number"?e.rows:20;function qt(e,t,n,s=n,r=n,i){let o=ke(e??Je);return V(t,o-n.length,{hard:!0,trim:!1}).split(`
17
17
  `).map((a,u,l)=>{let c=i?i(a,u):a;return u===0?`${s}${c}`:u===l.length-1?`${r}${c}`:`${n}${c}`}).join(`
18
- `)}function Vt(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 Lt{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=Tt,output:s=ze,render:r,signal:i,...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=i,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(He);this._abortSignal.addEventListener("abort",()=>{this.state="cancel",this.close()},{once:!0})}this.rl=us.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),ye(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),ye(this.input,!1),e(this.value)}),this.once("cancel",()=>{this.output.write(k.cursor.show),this.output.off("resize",this.render),ye(this.input,!1),e(He)})})}_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=Vt(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")}Ke([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
- `),ye(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=ls(this._prevFrame,e),n=Pt(this.output);if(this.restoreCursor(),t){let s=Math.max(0,t.numLinesAfter-n),r=Math.max(0,t.numLinesBefore-n),i=t.lines.find((o)=>o>=s);if(i===void 0){this._prevFrame=e;return}if(t.lines.length===1){this.output.write(k.cursor.move(0,i-r)),this.output.write(k.erase.lines(1));let o=e.split(`
21
- `);this.output.write(o[i]),this._prevFrame=e,this.output.write(k.cursor.move(0,o.length-i-1));return}else if(t.lines.length>1){if(s<r)i=s;else{let a=i-r;a>0&&this.output.write(k.cursor.move(0,a))}this.output.write(k.erase.down());let o=e.split(`
18
+ `)}function Ut(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 Bt{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=Vt,output:s=Je,render:r,signal:i,...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=i,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(Xe);this._abortSignal.addEventListener("abort",()=>{this.state="cancel",this.close()},{once:!0})}this.rl=ps.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),ge(this.input,!0),this.output.on("resize",this.render),this.render(),this.once("submit",()=>{this.output.write(b.cursor.show),this.output.off("resize",this.render),ge(this.input,!1),e(this.value)}),this.once("cancel",()=>{this.output.write(b.cursor.show),this.output.off("resize",this.render),ge(this.input,!1),e(Xe)})})}_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&&E.aliases.has(t.name)&&this.emit("cursor",E.aliases.get(t.name)),E.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=Ut(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")}Ze([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
+ `),ge(this.input,!1),this.rl?.close(),this.rl=void 0,this.emit(`${this.state}`,this.value),this.unsubscribe()}restoreCursor(){let e=V(this._prevFrame,process.stdout.columns,{hard:!0,trim:!1}).split(`
20
+ `).length-1;this.output.write(b.cursor.move(-999,e*-1))}render(){let e=V(this._render(this)??"",process.stdout.columns,{hard:!0,trim:!1});if(e!==this._prevFrame){if(this.state==="initial")this.output.write(b.cursor.hide);else{let t=ys(this._prevFrame,e),n=Lt(this.output);if(this.restoreCursor(),t){let s=Math.max(0,t.numLinesAfter-n),r=Math.max(0,t.numLinesBefore-n),i=t.lines.find((o)=>o>=s);if(i===void 0){this._prevFrame=e;return}if(t.lines.length===1){this.output.write(b.cursor.move(0,i-r)),this.output.write(b.erase.lines(1));let o=e.split(`
21
+ `);this.output.write(o[i]),this._prevFrame=e,this.output.write(b.cursor.move(0,o.length-i-1));return}else if(t.lines.length>1){if(s<r)i=s;else{let a=i-r;a>0&&this.output.write(b.cursor.move(0,a))}this.output.write(b.erase.down());let o=e.split(`
22
22
  `).slice(i);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 Xe extends Lt{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 Nr}from"util";import O from"process";var ie=ut(We(),1);function fs(){if(O.platform!=="win32")return O.env.TERM!=="linux";return Boolean(O.env.CI)||Boolean(O.env.WT_SESSION)||Boolean(O.env.TERMINUS_SUBLIME)||O.env.ConEmuTask==="{cmd::Cmder}"||O.env.TERM_PROGRAM==="Terminus-Sublime"||O.env.TERM_PROGRAM==="vscode"||O.env.TERM==="xterm-256color"||O.env.TERM==="alacritty"||O.env.TERMINAL_EMULATOR==="JetBrains-JediTerm"}var Je=fs(),ps=()=>process.env.CI==="true";var d=(e,t)=>Je?e:t,hs=d("\u25C6","*"),Bt=d("\u25A0","x"),Wt=d("\u25B2","x"),ve=d("\u25C7","o"),ms=d("\u250C","T"),x=d("\u2502","|"),Ht=d("\u2514","\u2014"),qr=d("\u2510","T"),Ur=d("\u2518","\u2014"),Gt=d("\u25CF",">"),qt=d("\u25CB"," "),Br=d("\u25FB","[\u2022]"),Wr=d("\u25FC","[+]"),Hr=d("\u25FB","[ ]"),zr=d("\u25AA","\u2022"),Ut=d("\u2500","-"),ys=d("\u256E","+"),ds=d("\u251C","+"),gs=d("\u256F","+"),vs=d("\u2570","+"),Kr=d("\u256D","+"),$s=d("\u25CF","\u2022"),bs=d("\u25C6","*"),ks=d("\u25B2","!"),ws=d("\u25A0","x"),xs=(e)=>{switch(e){case"initial":case"active":return p("cyan",hs);case"cancel":return p("red",Bt);case"error":return p("yellow",Wt);case"submit":return p("green",ve)}};var zt=(e)=>{let t=e.active??"Yes",n=e.inactive??"No";return new Xe({active:t,inactive:n,signal:e.signal,input:e.input,output:e.output,initialValue:e.initialValue??!0,render(){let s=e.withGuide??_.withGuide,r=`${xs(this.state)} `,i=s?`${p("gray",x)} `:"",o=Nt(e.output,e.message,i,r),a=`${s?`${p("gray",x)}
23
+ `)),this._prevFrame=e;return}}this.output.write(b.erase.down())}this.output.write(e),this.state==="initial"&&(this.state="active"),this._prevFrame=e}}}class Ye extends Bt{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(b.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 Kr}from"util";import M from"process";var ue=ct(Ke(),1);function gs(){if(M.platform!=="win32")return M.env.TERM!=="linux";return Boolean(M.env.CI)||Boolean(M.env.WT_SESSION)||Boolean(M.env.TERMINUS_SUBLIME)||M.env.ConEmuTask==="{cmd::Cmder}"||M.env.TERM_PROGRAM==="Terminus-Sublime"||M.env.TERM_PROGRAM==="vscode"||M.env.TERM==="xterm-256color"||M.env.TERM==="alacritty"||M.env.TERMINAL_EMULATOR==="JetBrains-JediTerm"}var Qe=gs(),vs=()=>process.env.CI==="true";var g=(e,t)=>Qe?e:t,ks=g("\u25C6","*"),Kt=g("\u25A0","x"),Xt=g("\u25B2","x"),$e=g("\u25C7","o"),$s=g("\u250C","T"),x=g("\u2502","|"),Jt=g("\u2514","\u2014"),Yr=g("\u2510","T"),Qr=g("\u2518","\u2014"),Wt=g("\u25CF",">"),Ht=g("\u25CB"," "),ei=g("\u25FB","[\u2022]"),ti=g("\u25FC","[+]"),ni=g("\u25FB","[ ]"),si=g("\u25AA","\u2022"),zt=g("\u2500","-"),bs=g("\u256E","+"),ws=g("\u251C","+"),xs=g("\u256F","+"),Es=g("\u2570","+"),ri=g("\u256D","+"),_s=g("\u25CF","\u2022"),Is=g("\u25C6","*"),Ss=g("\u25B2","!"),As=g("\u25A0","x"),Cs=(e)=>{switch(e){case"initial":case"active":return p("cyan",ks);case"cancel":return p("red",Kt);case"error":return p("yellow",Xt);case"submit":return p("green",$e)}};var Zt=(e)=>{let t=e.active??"Yes",n=e.inactive??"No";return new Ye({active:t,inactive:n,signal:e.signal,input:e.input,output:e.output,initialValue:e.initialValue??!0,render(){let s=e.withGuide??E.withGuide,r=`${Cs(this.state)} `,i=s?`${p("gray",x)} `:"",o=qt(e.output,e.message,i,r),a=`${s?`${p("gray",x)}
24
24
  `:""}${o}
25
25
  `,u=this.value?t:n;switch(this.state){case"submit":{let l=s?`${p("gray",x)} `:"";return`${a}${l}${p("dim",u)}`}case"cancel":{let l=s?`${p("gray",x)} `:"";return`${a}${l}${p(["strikethrough","dim"],u)}${s?`
26
- ${p("gray",x)}`:""}`}default:{let l=s?`${p("cyan",x)} `:"",c=s?p("cyan",Ht):"";return`${a}${l}${this.value?`${p("green",Gt)} ${t}`:`${p("dim",qt)} ${p("dim",t)}`}${e.vertical?s?`
26
+ ${p("gray",x)}`:""}`}default:{let l=s?`${p("cyan",x)} `:"",c=s?p("cyan",Jt):"";return`${a}${l}${this.value?`${p("green",Wt)} ${t}`:`${p("dim",Ht)} ${p("dim",t)}`}${e.vertical?s?`
27
27
  ${p("cyan",x)} `:`
28
- `:` ${p("dim","/")} `}${this.value?`${p("dim",qt)} ${p("dim",n)}`:`${p("green",Gt)} ${n}`}
28
+ `:` ${p("dim","/")} `}${this.value?`${p("dim",Ht)} ${p("dim",n)}`:`${p("green",Wt)} ${n}`}
29
29
  ${c}
30
- `}}}}).prompt()};var Xr=[`${p("dim","\u2191/\u2193")} to navigate`,`${p("dim","Space:")} select`,`${p("dim","Enter:")} confirm`];var g={message:(e=[],{symbol:t=p("gray",x),secondarySymbol:n=p("gray",x),output:s=process.stdout,spacing:r=1,withGuide:i}={})=>{let o=[],a=i??_.withGuide,u=a?n:"",l=a?`${t} `:"",c=a?`${n} `:"";for(let h=0;h<r;h++)o.push(u);let f=Array.isArray(e)?e:e.split(`
30
+ `}}}}).prompt()};var ii=[`${p("dim","\u2191/\u2193")} to navigate`,`${p("dim","Space:")} select`,`${p("dim","Enter:")} confirm`];var y={message:(e=[],{symbol:t=p("gray",x),secondarySymbol:n=p("gray",x),output:s=process.stdout,spacing:r=1,withGuide:i}={})=>{let o=[],a=i??E.withGuide,u=a?n:"",l=a?`${t} `:"",c=a?`${n} `:"";for(let h=0;h<r;h++)o.push(u);let f=Array.isArray(e)?e:e.split(`
31
31
  `);if(f.length>0){let[h,...v]=f;h.length>0?o.push(`${l}${h}`):o.push(a?t:"");for(let m of v)m.length>0?o.push(`${c}${m}`):o.push(a?n:"")}s.write(`${o.join(`
32
32
  `)}
33
- `)},info:(e,t)=>{g.message(e,{...t,symbol:p("blue",$s)})},success:(e,t)=>{g.message(e,{...t,symbol:p("green",bs)})},step:(e,t)=>{g.message(e,{...t,symbol:p("green",ve)})},warn:(e,t)=>{g.message(e,{...t,symbol:p("yellow",ks)})},warning:(e,t)=>{g.warn(e,t)},error:(e,t)=>{g.message(e,{...t,symbol:p("red",ws)})}};var $e=(e="",t)=>{let n=t?.output??process.stdout,s=t?.withGuide??_.withGuide?`${p("gray",ms)} `:"";n.write(`${s}${e}
34
- `)},Kt=(e="",t)=>{let n=t?.output??process.stdout,s=t?.withGuide??_.withGuide?`${p("gray",x)}
35
- ${p("gray",Ht)} `:"";n.write(`${s}${e}
33
+ `)},info:(e,t)=>{y.message(e,{...t,symbol:p("blue",_s)})},success:(e,t)=>{y.message(e,{...t,symbol:p("green",Is)})},step:(e,t)=>{y.message(e,{...t,symbol:p("green",$e)})},warn:(e,t)=>{y.message(e,{...t,symbol:p("yellow",Ss)})},warning:(e,t)=>{y.warn(e,t)},error:(e,t)=>{y.message(e,{...t,symbol:p("red",As)})}};var be=(e="",t)=>{let n=t?.output??process.stdout,s=t?.withGuide??E.withGuide?`${p("gray",$s)} `:"";n.write(`${s}${e}
34
+ `)},Yt=(e="",t)=>{let n=t?.output??process.stdout,s=t?.withGuide??E.withGuide?`${p("gray",x)}
35
+ ${p("gray",Jt)} `:"";n.write(`${s}${e}
36
36
 
37
- `)};var _s=(e)=>e,Es=(e,t,n)=>{let s={hard:!0,trim:!1},r=L(e,t,s).split(`
38
- `),i=r.reduce((u,l)=>Math.max(w(l),u),0),o=r.map(n).reduce((u,l)=>Math.max(w(l),u),0),a=t-(o-i);return L(e,a,s)},be=(e="",t="",n)=>{let s=n?.output??O.stdout,r=n?.withGuide??_.withGuide,i=n?.format??_s,o=["",...Es(e,ge(s)-6,i).split(`
37
+ `)};var Ms=(e)=>e,Os=(e,t,n)=>{let s={hard:!0,trim:!1},r=V(e,t,s).split(`
38
+ `),i=r.reduce((u,l)=>Math.max(w(l),u),0),o=r.map(n).reduce((u,l)=>Math.max(w(l),u),0),a=t-(o-i);return V(e,a,s)},we=(e="",t="",n)=>{let s=n?.output??M.stdout,r=n?.withGuide??E.withGuide,i=n?.format??Ms,o=["",...Os(e,ke(s)-6,i).split(`
39
39
  `).map(i),""],a=w(t),u=Math.max(o.reduce((h,v)=>{let m=w(v);return m>h?m:h},0),a)+2,l=o.map((h)=>`${p("gray",x)} ${h}${" ".repeat(u-w(h))}${p("gray",x)}`).join(`
40
40
  `),c=r?`${p("gray",x)}
41
- `:"",f=r?ds:vs;s.write(`${c}${p("green",ve)} ${p("reset",t)} ${p("gray",Ut.repeat(Math.max(u-a-1,1))+ys)}
41
+ `:"",f=r?ws:Es;s.write(`${c}${p("green",$e)} ${p("reset",t)} ${p("gray",zt.repeat(Math.max(u-a-1,1))+bs)}
42
42
  ${l}
43
- ${p("gray",f+Ut.repeat(u+2)+gs)}
44
- `)};var Is=(e)=>p("magenta",e),ke=({indicator:e="dots",onCancel:t,output:n=process.stdout,cancelMessage:s,errorMessage:r,frames:i=Je?["\u25D2","\u25D0","\u25D3","\u25D1"]:["\u2022","o","O","0"],delay:o=Je?80:120,signal:a,...u}={})=>{let l=ps(),c,f,h=!1,v=!1,m="",y,T=performance.now(),q=ge(n),U=u?.styleFrame??Is,M=(b)=>{let C=b>1?r??_.messages.error:s??_.messages.cancel;v=b===1,h&&(Q(C,b),v&&typeof t=="function"&&t())},R=()=>M(2),I=()=>M(1),J=()=>{process.on("uncaughtExceptionMonitor",R),process.on("unhandledRejection",R),process.on("SIGINT",I),process.on("SIGTERM",I),process.on("exit",M),a&&a.addEventListener("abort",I)},D=()=>{process.removeListener("uncaughtExceptionMonitor",R),process.removeListener("unhandledRejection",R),process.removeListener("SIGINT",I),process.removeListener("SIGTERM",I),process.removeListener("exit",M),a&&a.removeEventListener("abort",I)},E=()=>{if(y===void 0)return;l&&n.write(`
45
- `);let b=L(y,q,{hard:!0,trim:!1}).split(`
46
- `);b.length>1&&n.write(ie.cursor.up(b.length-1)),n.write(ie.cursor.to(0)),n.write(ie.erase.down())},B=(b)=>b.replace(/\.+$/,""),z=(b)=>{let C=(performance.now()-b)/1000,P=Math.floor(C/60),N=Math.floor(C%60);return P>0?`[${P}m ${N}s]`:`[${N}s]`},S=u.withGuide??_.withGuide,oe=(b="")=>{h=!0,c=Rt({output:n}),m=B(b),T=performance.now(),S&&n.write(`${p("gray",x)}
47
- `);let C=0,P=0;J(),f=setInterval(()=>{if(l&&m===y)return;E(),y=m;let N=U(i[C]),ae;if(l)ae=`${N} ${m}...`;else if(e==="timer")ae=`${N} ${m} ${z(T)}`;else{let $n=".".repeat(Math.floor(P)).slice(0,3);ae=`${N} ${m}${$n}`}let vn=L(ae,q,{hard:!0,trim:!1});n.write(vn),C=C+1<i.length?C+1:0,P=P<4?P+0.125:0},o)},Q=(b="",C=0,P=!1)=>{if(!h)return;h=!1,clearInterval(f),E();let N=C===0?p("green",ve):C===1?p("red",Bt):p("red",Wt);m=b??m,P||(e==="timer"?n.write(`${N} ${m} ${z(T)}
43
+ ${p("gray",f+zt.repeat(u+2)+xs)}
44
+ `)};var Ds=(e)=>p("magenta",e),xe=({indicator:e="dots",onCancel:t,output:n=process.stdout,cancelMessage:s,errorMessage:r,frames:i=Qe?["\u25D2","\u25D0","\u25D3","\u25D1"]:["\u2022","o","O","0"],delay:o=Qe?80:120,signal:a,...u}={})=>{let l=vs(),c,f,h=!1,v=!1,m="",d,j=performance.now(),L=ke(n),q=u?.styleFrame??Ds,D=(k)=>{let A=k>1?r??E.messages.error:s??E.messages.cancel;v=k===1,h&&(ee(A,k),v&&typeof t=="function"&&t())},R=()=>D(2),I=()=>D(1),Q=()=>{process.on("uncaughtExceptionMonitor",R),process.on("unhandledRejection",R),process.on("SIGINT",I),process.on("SIGTERM",I),process.on("exit",D),a&&a.addEventListener("abort",I)},P=()=>{process.removeListener("uncaughtExceptionMonitor",R),process.removeListener("unhandledRejection",R),process.removeListener("SIGINT",I),process.removeListener("SIGTERM",I),process.removeListener("exit",D),a&&a.removeEventListener("abort",I)},_=()=>{if(d===void 0)return;l&&n.write(`
45
+ `);let k=V(d,L,{hard:!0,trim:!1}).split(`
46
+ `);k.length>1&&n.write(ue.cursor.up(k.length-1)),n.write(ue.cursor.to(0)),n.write(ue.erase.down())},U=(k)=>k.replace(/\.+$/,""),K=(k)=>{let A=(performance.now()-k)/1000,T=Math.floor(A/60),N=Math.floor(A%60);return T>0?`[${T}m ${N}s]`:`[${N}s]`},S=u.withGuide??E.withGuide,le=(k="")=>{h=!0,c=Gt({output:n}),m=U(k),j=performance.now(),S&&n.write(`${p("gray",x)}
47
+ `);let A=0,T=0;Q(),f=setInterval(()=>{if(l&&m===d)return;_(),d=m;let N=q(i[A]),ce;if(l)ce=`${N} ${m}...`;else if(e==="timer")ce=`${N} ${m} ${K(j)}`;else{let In=".".repeat(Math.floor(T)).slice(0,3);ce=`${N} ${m}${In}`}let _n=V(ce,L,{hard:!0,trim:!1});n.write(_n),A=A+1<i.length?A+1:0,T=T<4?T+0.125:0},o)},ee=(k="",A=0,T=!1)=>{if(!h)return;h=!1,clearInterval(f),_();let N=A===0?p("green",$e):A===1?p("red",Kt):p("red",Xt);m=k??m,T||(e==="timer"?n.write(`${N} ${m} ${K(j)}
48
48
  `):n.write(`${N} ${m}
49
- `)),D(),c()};return{start:oe,stop:(b="")=>Q(b,0),message:(b="")=>{m=B(b??m)},cancel:(b="")=>Q(b,1),error:(b="")=>Q(b,2),clear:()=>Q("",0,!0),get isCancelled(){return v}}},Jr={light:d("\u2500","-"),heavy:d("\u2501","="),block:d("\u2588","#")};var Zr=[`${p("dim","\u2191/\u2193")} to navigate`,`${p("dim","Enter:")} confirm`];var Yr=`${p("gray",x)} `;var{$:Ze}=globalThis.Bun;var Ss={pacman:["arch","endeavouros","manjaro","garuda","cachyos","arcolinux","rebornos","blendos","steamos","chimeraos"],dnf:["fedora","nobara","bazzite","ultramarine"]},Xt=(e)=>{for(let[t,n]of Object.entries(Ss))if(n.includes(e))return t;return null};var Jt={osName:void 0,osId:void 0,platform:"linux",packageManager:void 0,helperAur:null,isFlatpak:!1,flatpak:!1};function Y(e){return Jt[e]}function G(e,t){Jt[e]=t}async function Ye(e){try{return await Ze`which ${e}`.quiet(),!0}catch{return!1}}async function Cs(){let e=[];if(await Ye("yay"))e.push("yay");if(await Ye("paru"))e.push("paru");return e}async function As(){if(process.platform==="linux"){let e=await Ze`cat /etc/os-release | grep ^NAME`.quiet().text()||"",t=await Ze`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 we(){let{name:e="",id:t=""}=await As(),n=Xt(t),s=n==="pacman"?await Cs():null,r=await Ye("flatpak");if(G("osName",e),G("osId",t),G("flatpak",r),s)G("helperAur",s[0]);if(n)G("packageManager",n);return{osName:e,osId:t,packageManager:n,aurHelper:s,flatpak:r}}async function Zt(){$e("\uD83D\uDD0D Scanning system");let e=ke();e.start("Detecting environment...");let t=await we();return e.stop("Environment detected"),be([`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}),Kt("Scan completed"),t}import Yt from"path";import{homedir as Qt}from"os";function xe(e){if(e.startsWith("~"))return Yt.join(Qt(),e.slice(1));return Yt.resolve(e)}function Qe(){return Qt()}var Os=Le(K({flatpak:te(),backup:te(),aur_helper:se(["yay","paru"])})),Ms=K({source:j(),target:j(),sudo:ne(te())}),Ds=se(["aur","pacman"]),Fs=re([j(),V(j()),V(V(j()))]),js=K({name:j(),post_hooks:ne(Fs)}),en=V(re([j(),js])),Ts=K({manager:Ds,items:en}),Rs=K({manager:Ne("flatpak"),scope:se(["system","user"]),items:en}),_e=Le(Ve({imports:V(j()),settings:Os,packages:V(re([Rs,Ts])),symlinks:V(Ms)}));import Ie from"path";var H={defaultMerge:Symbol("deepmerge-ts: default merge"),skip:Symbol("deepmerge-ts: skip")},hi={defaultMerge:H.defaultMerge};function Ps(e,t){return t}function Ns(e,t){return e.filter((n)=>n!==void 0)}var tn;(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"})(tn||(tn={}));function nn(e){if(typeof e!=="object"||e===null)return 0;if(Array.isArray(e))return 2;if(Gs(e))return 1;if(e instanceof Set)return 3;if(e instanceof Map)return 4;return 5}function Vs(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 Ls(e,t){return typeof e==="object"&&Object.prototype.propertyIsEnumerable.call(e,t)}function rn(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 sn=["[object Object]","[object Module]"];function Gs(e){if(!sn.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"||!sn.includes(Object.prototype.toString.call(n)))return!1;if(!n.hasOwnProperty("isPrototypeOf"))return!1;return!0}function qs(e,t,n){let s={};for(let r of Vs(e)){let i=[];for(let u of e)if(Ls(u,r))i.push(u[r]);if(i.length===0)continue;let o=t.metaDataUpdater(n,{key:r,parents:e}),a=un(i,t,o);if(a===H.skip)continue;if(r==="__proto__")Object.defineProperty(s,r,{value:a,configurable:!0,enumerable:!0,writable:!0});else s[r]=a}return s}function Us(e){return e.flat()}function Bs(e){return new Set(rn(e))}function Ws(e){return new Map(rn(e))}function Hs(e){return e.at(-1)}var Ee={mergeRecords:qs,mergeArrays:Us,mergeSets:Bs,mergeMaps:Ws,mergeOthers:Hs};function ue(...e){return zs({})(...e)}function zs(e,t){let n=Ks(e,s);function s(...r){return un(r,n,t)}return s}function Ks(e,t){return{defaultMergeFunctions:Ee,mergeFunctions:{...Ee,...Object.fromEntries(Object.entries(e).filter(([n,s])=>Object.hasOwn(Ee,n)).map(([n,s])=>s===!1?[n,Ee.mergeOthers]:[n,s]))},metaDataUpdater:e.metaDataUpdater??Ps,deepmerge:t,useImplicitDefaultMerging:e.enableImplicitDefaultMerging??!1,filterValues:e.filterValues===!1?void 0:e.filterValues??Ns,actions:H}}function un(e,t,n){let s=t.filterValues?.(e,n)??e;if(s.length===0)return;if(s.length===1)return et(s,t,n);let r=nn(s[0]);if(r!==0&&r!==5)for(let i=1;i<s.length;i++){if(nn(s[i])===r)continue;return et(s,t,n)}switch(r){case 1:return Xs(s,t,n);case 2:return Js(s,t,n);case 3:return Zs(s,t,n);case 4:return Ys(s,t,n);default:return et(s,t,n)}}function Xs(e,t,n){let s=t.mergeFunctions.mergeRecords(e,t,n);if(s===H.defaultMerge||t.useImplicitDefaultMerging&&s===void 0&&t.mergeFunctions.mergeRecords!==t.defaultMergeFunctions.mergeRecords)return t.defaultMergeFunctions.mergeRecords(e,t,n);return s}function Js(e,t,n){let s=t.mergeFunctions.mergeArrays(e,t,n);if(s===H.defaultMerge||t.useImplicitDefaultMerging&&s===void 0&&t.mergeFunctions.mergeArrays!==t.defaultMergeFunctions.mergeArrays)return t.defaultMergeFunctions.mergeArrays(e);return s}function Zs(e,t,n){let s=t.mergeFunctions.mergeSets(e,t,n);if(s===H.defaultMerge||t.useImplicitDefaultMerging&&s===void 0&&t.mergeFunctions.mergeSets!==t.defaultMergeFunctions.mergeSets)return t.defaultMergeFunctions.mergeSets(e);return s}function Ys(e,t,n){let s=t.mergeFunctions.mergeMaps(e,t,n);if(s===H.defaultMerge||t.useImplicitDefaultMerging&&s===void 0&&t.mergeFunctions.mergeMaps!==t.defaultMergeFunctions.mergeMaps)return t.defaultMergeFunctions.mergeMaps(e);return s}function et(e,t,n){let s=t.mergeFunctions.mergeOthers(e,t,n);if(s===H.defaultMerge||t.useImplicitDefaultMerging&&s===void 0&&t.mergeFunctions.mergeOthers!==t.defaultMergeFunctions.mergeOthers)return t.defaultMergeFunctions.mergeOthers(e);return s}async function tt(e,t=new Set){let n=Ie.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),i;try{i=pe(_e,r)}catch(c){if(c instanceof ee)g.error(c.issues[0].message);process.exit(1)}let{imports:o=[],symlinks:a=[]}=i;delete i.imports;let u=Ie.dirname(n);i.symlinks=Qs(u,a);let l={};for(let c of o){let f=Ie.resolve(u,c),h=await tt(f,t);l=ue(l,h)}return ue(i,l)}function Qs(e,t){if(!t||t.length===0)return[];let n=[];for(let s of t){if(!s)continue;let{source:r,target:i}=s,o=Ie.resolve(e,r),a=xe(i);n.push({source:o,target:a})}return n}async function Se(e){let t=xe(e);g.step("Validating Configuration");let n=ke();n.start("Validating...");let s=await tt(t),r=pe(_e,s);return n.stop("Successfully validated with no errors!"),r}import sr from"path";var{deepEquals:er}=globalThis.Bun;import tr from"fs/promises";import Ce from"path";import nt from"fs/promises";var Ae={};function Oe(){return Ae}function on(e,t){Ae[e]=t}async function an(){let e=Ce.resolve(Qe(),".cache/hofii"),t=Ce.resolve(e,"hofii-lock.json");if(await nt.exists(t)){let n=await Bun.file(t).json();Object.assign(Ae,n.config)}}async function ln(){let e=Ce.resolve(Qe(),".cache/hofii");if(!await nt.exists(e))await nt.mkdir(e,{recursive:!0});let t={config:Ae};await Bun.write(Ce.resolve(e,"hofii-lock.json"),JSON.stringify(t,null,2))}import De from"fs/promises";async function Me({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,i=n.stderr==="pipe"?new Response(s.stderr).text():void 0,o=s.exited,[a,u,l]=await Promise.all([r,i,o]);if(l!==0)throw Error(t??`Error caused with exit code ${l}`);return{stdout:a,stderr:u,exitCode:l}}async function st(e,t,n=!1){if(n){if(Y("platform")!=="linux"){g.warn("Sudo only support in Linux");return}await Me({cmd:["sudo","ln","-s",e,t],errMsg:`Failed create symlink ${e+" -> "+t}`})}else await De.symlink(e,t)}async function rt(e,t=!1){if(t){if(Y("platform")!=="linux"){g.warn("Sudo only support in Linux");return}await Me({cmd:["sudo","rm",e],errMsg:`Failed remove symlink ${e}`})}else await De.unlink(e)}async function Fe(e){try{return await De.lstat(e)}catch(t){return null}}async function cn({oldPath:e,newPath:t,sudo:n=!1}){if(!await Fe(t))return;if(n){if(Y("platform")!=="linux"){g.warn("Sudo only support in Linux");return}await Me({cmd:["sudo","mv",e,t],errMsg:`Failed rename file ${e+" -> "+t}`})}else await De.rename(e,t)}async function hn(e){if(!e)return;let t=Y("settings")?.backup??!0,{added:n=[],removed:s=[]}=e,r=[],i=[];try{let o=pn(await Promise.allSettled(s.map(async(u)=>{let l=await Fe(u.target);if(!l){g.warn(`Target doesn't exist: ${u.target}, did you remove it manually?`),i.push(u);return}if(!l.isSymbolicLink()){g.warn(`${u.target} not a symlink, did you remove it manually?`),i.push(u);return}await rt(u.target,u.sudo),i.push(u),g.success(`Succesfully remove symlink ${u.target}`)}))),a=pn(await Promise.allSettled(n.map(async(u)=>{let l=await Fe(u.target);if(l){if(l.isSymbolicLink()){let c=await tr.readlink(u.target);if(c===u.source){await rt(u.target,u.sudo),await st(u.source,u.target,u.sudo),r.push(u),g.warn(`Recreate ${c} -> ${u.target}`);return}}if(t)await cn({oldPath:u.target,newPath:u.target+".bak",sudo:u.sudo});else{g.error(`Target already exists, skip create: ${u.target}`);return}}await st(u.source,u.target,u.sudo),r.push(u),g.success(`Succesfully create symlink ${u.source} -> ${u.target}`)})));for(let u of a)console.error(`Failed to add symlink: ${fn(u)}`);for(let u of o)console.error(`Failed to remove symlink: ${fn(u)}`);if(a.length>0||o.length>0)g.error(" [FATAL] Error caused while applying symlinks"),process.exitCode=1}catch(o){console.error(o),g.error(" [FATAL] Failed to apply symlinks"),process.exitCode=1}finally{let u=((Oe()??{}).symlinks??[]).filter((l)=>!i.some((c)=>er(c,l))).concat(r);g.info(`Updated symlinks state: ${u.length}`),on("symlinks",u)}}function fn(e){if(e instanceof Error)return`[${"code"in e?String(e.code):"ERROR"}] ${e.message}`;return`[ERROR] ${String(e)}`}function pn(e){return e.filter((t)=>t.status==="rejected")}var{deepEquals:mn}=globalThis.Bun;function nr(e,t){let n=t?.filter((r)=>!e?.some((i)=>mn(r,i,!0)))??[],s=e?.filter((r)=>!t?.some((i)=>mn(r,i,!0)))??[];return{added:n,removed:s}}function yn(e){let t=Oe();return{symlinks:nr(t.symlinks,e.symlinks)}}function dn(e){let{symlinks:t}=e;return[(()=>{let s=["SYMLINKS"],{added:r=[],removed:i=[]}=t;if(r?.length===0&&i?.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 i)s.push(` - [REMOVED] ${o.sudo?"(sudo) ":""}${o.source} -> ${o.target}`);return s.join(`
52
- `)})()].join("/n")}async function gn(e){let t=sr.join(e,"config.toml");G("configDir",e),await an(),$e("Switching configuration"),g.info("Scanning system environment..."),await we();let n=await Se(t);G("settings",ue(n.settings,{backup:!0}));let s=yn(n),r=dn(s);be(r,"Config To Apply");let i=await zt({message:"Apply config changes? (Please review the changes first!!)"});if(!i||de(i))g.warn("Config changes not applied."),process.exit(0);await hn(s.symlinks)}var X=ht("hofii");X.version("0.0.3");X.command("scan","Detect system environment").alias("s").action(async()=>{await Zt(),process.exit(0)});X.command("validate [dir]","Validate configuration files").alias("v").action(async(e)=>{await Se(e),process.exit(0)});X.command("switch [dir]","Switch to new configuration").alias("sw").action(async(e)=>{let t=rr.resolve(e);await gn(t)});try{if(process.argv.slice(2).length===0)X.outputHelp(),process.exit(0);X.help().parse(process.argv,{run:!1}),await X.runMatchedCommand()}catch(e){if(e instanceof ee){let t=e.issues.map((n)=>{let s=n.path.at(-1)?.input;return[`\u2717 ${n.message}`,` at: ${JSON.stringify(s)}`].join(`
49
+ `)),P(),c()};return{start:le,stop:(k="")=>ee(k,0),message:(k="")=>{m=U(k??m)},cancel:(k="")=>ee(k,1),error:(k="")=>ee(k,2),clear:()=>ee("",0,!0),get isCancelled(){return v}}},ui={light:g("\u2500","-"),heavy:g("\u2501","="),block:g("\u2588","#")};var oi=[`${p("dim","\u2191/\u2193")} to navigate`,`${p("dim","Enter:")} confirm`];var ai=`${p("gray",x)} `;var{$:et}=globalThis.Bun;var Ps={pacman:["arch","endeavouros","manjaro","garuda","cachyos","arcolinux","rebornos","blendos","steamos","chimeraos"],dnf:["fedora","nobara","bazzite","ultramarine"]},Qt=(e)=>{for(let[t,n]of Object.entries(Ps))if(n.includes(e))return t;return null};var en={osName:void 0,osId:void 0,platform:"linux",packageManager:void 0,helperAur:null,isFlatpak:!1,flatpak:!1};function H(e){return en[e]}function G(e,t){en[e]=t}async function tt(e){try{return await et`which ${e}`.quiet(),!0}catch{return!1}}async function Fs(){let e=[];if(await tt("yay"))e.push("yay");if(await tt("paru"))e.push("paru");return e}async function js(){if(process.platform==="linux"){let e=await et`cat /etc/os-release | grep ^NAME`.quiet().text()||"",t=await et`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 Ee(){let{name:e="",id:t=""}=await js(),n=Qt(t),s=n==="pacman"?await Fs():null,r=await tt("flatpak");if(G("osName",e),G("osId",t),G("flatpak",r),s)G("helperAur",s[0]);if(n)G("packageManager",n);return{osName:e,osId:t,packageManager:n,aurHelper:s,flatpak:r}}async function tn(){be("\uD83D\uDD0D Scanning system");let e=xe();e.start("Detecting environment...");let t=await Ee();return e.stop("Environment detected"),we([`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}),Yt("Scan completed"),t}import nn from"path";import{homedir as sn}from"os";function _e(e){if(e.startsWith("~"))return nn.join(sn(),e.slice(1));return nn.resolve(e)}function nt(){return sn()}var Rs=Ue(J({flatpak:ne(),backup:ne(),aur_helper:re(["yay","paru"])})),Ts=J({source:B(),target:B(),sudo:se(ne())}),Ns=re(["aur","pacman"]),Vs=ie([X(B())]),Gs=J({name:B(),post_hooks:se(Vs)}),rn=X(ie([B(),Gs])),Ls=J({manager:Ns,items:rn}),qs=J({manager:Le("flatpak"),scope:re(["system","user"]),items:rn}),Ie=Ue(qe({imports:X(B()),settings:Rs,packages:X(ie([qs,Ls])),symlinks:X(Ts)}));import Ae from"path";var z={defaultMerge:Symbol("deepmerge-ts: default merge"),skip:Symbol("deepmerge-ts: skip")},xi={defaultMerge:z.defaultMerge};function Us(e,t){return t}function Bs(e,t){return e.filter((n)=>n!==void 0)}var un;(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"})(un||(un={}));function on(e){if(typeof e!=="object"||e===null)return 0;if(Array.isArray(e))return 2;if(zs(e))return 1;if(e instanceof Set)return 3;if(e instanceof Map)return 4;return 5}function Ws(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 Hs(e,t){return typeof e==="object"&&Object.prototype.propertyIsEnumerable.call(e,t)}function ln(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 an=["[object Object]","[object Module]"];function zs(e){if(!an.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"||!an.includes(Object.prototype.toString.call(n)))return!1;if(!n.hasOwnProperty("isPrototypeOf"))return!1;return!0}function Ks(e,t,n){let s={};for(let r of Ws(e)){let i=[];for(let u of e)if(Hs(u,r))i.push(u[r]);if(i.length===0)continue;let o=t.metaDataUpdater(n,{key:r,parents:e}),a=cn(i,t,o);if(a===z.skip)continue;if(r==="__proto__")Object.defineProperty(s,r,{value:a,configurable:!0,enumerable:!0,writable:!0});else s[r]=a}return s}function Xs(e){return e.flat()}function Js(e){return new Set(ln(e))}function Zs(e){return new Map(ln(e))}function Ys(e){return e.at(-1)}var Se={mergeRecords:Ks,mergeArrays:Xs,mergeSets:Js,mergeMaps:Zs,mergeOthers:Ys};function oe(...e){return Qs({})(...e)}function Qs(e,t){let n=er(e,s);function s(...r){return cn(r,n,t)}return s}function er(e,t){return{defaultMergeFunctions:Se,mergeFunctions:{...Se,...Object.fromEntries(Object.entries(e).filter(([n,s])=>Object.hasOwn(Se,n)).map(([n,s])=>s===!1?[n,Se.mergeOthers]:[n,s]))},metaDataUpdater:e.metaDataUpdater??Us,deepmerge:t,useImplicitDefaultMerging:e.enableImplicitDefaultMerging??!1,filterValues:e.filterValues===!1?void 0:e.filterValues??Bs,actions:z}}function cn(e,t,n){let s=t.filterValues?.(e,n)??e;if(s.length===0)return;if(s.length===1)return st(s,t,n);let r=on(s[0]);if(r!==0&&r!==5)for(let i=1;i<s.length;i++){if(on(s[i])===r)continue;return st(s,t,n)}switch(r){case 1:return tr(s,t,n);case 2:return nr(s,t,n);case 3:return sr(s,t,n);case 4:return rr(s,t,n);default:return st(s,t,n)}}function tr(e,t,n){let s=t.mergeFunctions.mergeRecords(e,t,n);if(s===z.defaultMerge||t.useImplicitDefaultMerging&&s===void 0&&t.mergeFunctions.mergeRecords!==t.defaultMergeFunctions.mergeRecords)return t.defaultMergeFunctions.mergeRecords(e,t,n);return s}function nr(e,t,n){let s=t.mergeFunctions.mergeArrays(e,t,n);if(s===z.defaultMerge||t.useImplicitDefaultMerging&&s===void 0&&t.mergeFunctions.mergeArrays!==t.defaultMergeFunctions.mergeArrays)return t.defaultMergeFunctions.mergeArrays(e);return s}function sr(e,t,n){let s=t.mergeFunctions.mergeSets(e,t,n);if(s===z.defaultMerge||t.useImplicitDefaultMerging&&s===void 0&&t.mergeFunctions.mergeSets!==t.defaultMergeFunctions.mergeSets)return t.defaultMergeFunctions.mergeSets(e);return s}function rr(e,t,n){let s=t.mergeFunctions.mergeMaps(e,t,n);if(s===z.defaultMerge||t.useImplicitDefaultMerging&&s===void 0&&t.mergeFunctions.mergeMaps!==t.defaultMergeFunctions.mergeMaps)return t.defaultMergeFunctions.mergeMaps(e);return s}function st(e,t,n){let s=t.mergeFunctions.mergeOthers(e,t,n);if(s===z.defaultMerge||t.useImplicitDefaultMerging&&s===void 0&&t.mergeFunctions.mergeOthers!==t.defaultMergeFunctions.mergeOthers)return t.defaultMergeFunctions.mergeOthers(e);return s}async function rt(e,t=new Set){let n=Ae.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),i;try{i=me(Ie,r)}catch(c){if(c instanceof te)y.error(c.issues[0].message);process.exit(1)}let{imports:o=[],symlinks:a=[]}=i;delete i.imports;let u=Ae.dirname(n);i.symlinks=ir(u,a);let l={};for(let c of o){let f=Ae.resolve(u,c),h=await rt(f,t);l=oe(l,h)}return oe(i,l)}function ir(e,t){if(!t||t.length===0)return[];let n=[];for(let s of t){if(!s)continue;let{source:r,target:i}=s,o=Ae.resolve(e,r),a=_e(i);n.push({source:o,target:a})}return n}async function Ce(e){let t,n=_e(e);y.step("Validating Configuration");let s=xe();s.start("Validating...");try{let r=await rt(n);t=me(Ie,r)}catch(r){y.error(r instanceof Error?r.message:String(r)),s.stop("Validation failed");return}return s.stop("Successfully validated with no errors!"),t}import hr from"path";var{deepEquals:ur}=globalThis.Bun;import or from"fs/promises";import Me from"fs/promises";async function O({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,i=n.stderr==="pipe"?new Response(s.stderr).text():void 0,o=s.exited,[a,u,l]=await Promise.all([r,i,o]);if(l!==0)throw Error(t??`Error caused with exit code ${l}`);return{stdout:a,stderr:u,exitCode:l}}async function it(e,t,n=!1){if(n){if(H("platform")!=="linux"){y.warn("Sudo only support in Linux");return}await O({cmd:["sudo","ln","-s",e,t],errMsg:`Failed create symlink ${e+" -> "+t}`})}else await Me.symlink(e,t)}async function ut(e,t=!1){if(t){if(H("platform")!=="linux"){y.warn("Sudo only support in Linux");return}await O({cmd:["sudo","rm",e],errMsg:`Failed remove symlink ${e}`})}else await Me.unlink(e)}async function Oe(e){try{return await Me.lstat(e)}catch(t){return null}}async function fn({oldPath:e,newPath:t,sudo:n=!1}){if(!await Oe(t))return;if(n){if(H("platform")!=="linux"){y.warn("Sudo only support in Linux");return}await O({cmd:["sudo","mv",e,t],errMsg:`Failed rename file ${e+" -> "+t}`})}else await Me.rename(e,t)}import De from"path";import ot from"fs/promises";var Pe={};function Fe(){return Pe}function je(e,t){Pe[e]=t}async function pn(){let e=De.resolve(nt(),".cache/hofii"),t=De.resolve(e,"hofii-lock.json");if(await ot.exists(t)){let n=await Bun.file(t).json();Object.assign(Pe,n.config)}}async function hn(){let e=De.resolve(nt(),".cache/hofii");if(!await ot.exists(e))await ot.mkdir(e,{recursive:!0});let t={config:Pe};await Bun.write(De.resolve(e,"hofii-lock.json"),JSON.stringify(t,null,2))}async function dn(e){if(!e)return;let t=H("settings")?.backup??!0,{added:n=[],removed:s=[]}=e,r=[],i=[];try{let o=yn(await Promise.allSettled(s.map(async(u)=>{let l=await Oe(u.target);if(!l){y.warn(`Target doesn't exist: ${u.target}, did you remove it manually?`),i.push(u);return}if(!l.isSymbolicLink()){y.warn(`${u.target} not a symlink, did you remove it manually?`),i.push(u);return}await ut(u.target,u.sudo),i.push(u),y.success(`Succesfully remove symlink ${u.target}`)}))),a=yn(await Promise.allSettled(n.map(async(u)=>{let l=await Oe(u.target);if(l){if(l.isSymbolicLink()){let c=await or.readlink(u.target);if(c===u.source){await ut(u.target,u.sudo),await it(u.source,u.target,u.sudo),r.push(u),y.warn(`Recreate ${c} -> ${u.target}`);return}}if(t)await fn({oldPath:u.target,newPath:u.target+".bak",sudo:u.sudo});else{y.error(`Target already exists, skip create: ${u.target}`);return}}await it(u.source,u.target,u.sudo),r.push(u),y.success(`Succesfully create symlink ${u.source} -> ${u.target}`)})));for(let u of a)console.error(`Failed to add symlink: ${mn(u)}`);for(let u of o)console.error(`Failed to remove symlink: ${mn(u)}`);if(a.length>0||o.length>0)y.error(" [FATAL] Error caused while applying symlinks"),process.exitCode=1}catch(o){console.error(o),y.error(" [FATAL] Failed to apply symlinks"),process.exitCode=1}finally{let u=((Fe()??{}).symlinks??[]).filter((l)=>!i.some((c)=>ur(c,l))).concat(r);y.info(`Updated symlinks state: ${u.length}`),je("symlinks",u)}}function mn(e){if(e instanceof Error)return`[${"code"in e?String(e.code):"ERROR"}] ${e.message}`;return`[ERROR] ${String(e)}`}function yn(e){return e.filter((t)=>t.status==="rejected")}var{deepEquals:bn}=globalThis.Bun;var Re=H("helperAur");class ae{static async syncDatabase(){await O({cmd:["sudo","pacman","-Sy"],errMsg:"Failed to sync package database pacman"})}static async getInstalledPakcages(){let{stdout:e}=await O({cmd:["pacman","-Qqen"],opt:{stdout:"pipe"}});return e}static async install(e){if(!Re)return;let t=new Set(e);await O({cmd:[Re,"-S","--needed","--noconfirm",...t],errMsg:"Failed to install packages pacman"})}static async remove(e){if(!Re)return;let t=new Set(e);await O({cmd:[Re,"-R",...t],errMsg:"Failed to uninstall packages pacman"})}}var gn=["pacman"];async function ar(e){await O({cmd:e,errMsg:`Failed to execute post hooks: ${e.join(" ")}`})}function vn(e){let t={pacman:[]};for(let n of e??[])if(n.manager==="pacman"||n.manager==="aur")t.pacman.push(...n.items);return t}function kn(e){let t=[],n=[];for(let s of e){if(typeof s==="object"){let{name:r,post_hooks:i}=s;if(r.trim())t.push(r.trim());if(i)n.push(i);continue}t.push(s)}return{items:t,hooks:n}}async function lr(e){if(!e)return;try{let t=[];await ae.syncDatabase(),await ae.install(e.items),y.success("Successfully Installing Pacman Packages");for(let n of e.hooks)await ar(n),t.push(n);return e}catch(t){if(t instanceof Error)y.error(t.message);else console.error(t);return}}async function cr(e){if(!e)return;if(!e.items.length)return;await ae.remove(e.items)}async function $n(e){let{added:t,removed:n}=e,s=await lr(t.pacman);await cr(n.pacman);let r={};if(s)r.pacman=s,y.info("Metadata pacman Saved");je("packages",r)}function fr(e,t){let n=t?.filter((r)=>!e?.some((i)=>bn(r,i,!0)))??[],s=e?.filter((r)=>!t?.some((i)=>bn(r,i,!0)))??[];return{added:n,removed:s}}function pr(e,t){let n=e,s=Object.entries(vn(t)).reduce((o,[a,u])=>(o[a]=kn(u),o),{}),r={},i={};for(let o of gn){let a=[...new Set(s[o]?.items.filter((f)=>!n?.[o]?.items.includes(f))??[])],u=[...new Set(n?.[o]?.items.filter((f)=>!s?.[o]?.items.includes(f))??[])],l=s[o]?.hooks.filter((f)=>!n?.[o]?.hooks.includes(f))??[],c=n?.[o]?.hooks.filter((f)=>!s?.[o]?.hooks.includes(f))??[];r[o]={items:a,hooks:l},i[o]={items:u,hooks:c}}return{added:r,removed:i}}function wn(e){let t=Fe(),n=fr(t.symlinks,e.symlinks),s=pr(t.packages,e.packages);return{symlinks:n,packages:s}}function xn(e){let{symlinks:t,packages:n}=e,s=(()=>{let i=["SYMLINKS"],{added:o=[],removed:a=[]}=t;if(o?.length===0&&a?.length===0)return i.push(" - No changes to apply with symlinks"),i.join(`
51
+ `);for(let u of o)i.push(` - [ADDED] ${u.sudo?"(sudo) ":""}${u.source} -> ${u.target}`);for(let u of a)i.push(` - [REMOVED] ${u.sudo?"(sudo) ":""}${u.source} -> ${u.target}`);return i.join(`
52
+ `)})(),r=(()=>{let i=["PACKAGES"],{added:o={},removed:a={}}=n;for(let[u,l]of Object.entries(o)){for(let c of l.items)i.push(` - [ADDED] (${u}) -> ${c}`);for(let c of l.hooks)i.push(` - [ADDED] (${u}) -> ${c}`)}for(let[u,l]of Object.entries(a))for(let c of l.items)i.push(` - [REMOVED] (${u}) -> ${c}`);if(i.length===1)i.push(" - No changes to apply with packages");return i.join(`
53
+ `)})();return[s,r].join(`
54
+
55
+ `)}async function En(e){let t=hr.join(e,"config.toml");G("configDir",e),await pn(),be("Switching configuration"),y.info("Scanning system environment..."),await Ee();let n=await Ce(t);if(!n)process.exit(1);G("settings",oe(n.settings,{backup:!0}));let s=wn(n),r=xn(s);we(r,"Config To Apply");let i=await Zt({message:"Apply config changes? (Please review the changes first!!)"});if(!i||ve(i))y.warn("Config changes not applied."),process.exit(0);await dn(s.symlinks),await $n(s.packages)}var Y=gt("hofii");Y.version("0.0.3");Y.command("scan","Detect system environment").alias("s").action(async()=>{await tn(),process.exit(0)});Y.command("validate [dir]","Validate configuration files").alias("v").action(async(e)=>{await Ce(e),process.exit(0)});Y.command("switch [dir]","Switch to new configuration").alias("sw").action(async(e)=>{let t=mr.resolve(e);await En(t)});try{if(process.argv.slice(2).length===0)Y.outputHelp(),process.exit(0);Y.help().parse(process.argv,{run:!1}),await Y.runMatchedCommand()}catch(e){if(e instanceof te){let t=e.issues.map((n)=>{let s=n.path.at(-1)?.input;return[`\u2717 ${n.message}`,` at: ${JSON.stringify(s)}`].join(`
53
56
  `)}).join(`
54
57
 
55
- `);console.error(t)}console.error(e)}finally{await ln()}
58
+ `);console.error(t)}else if(e instanceof Error)console.log(e.message);else console.error(e)}finally{await hn()}
package/package.json CHANGED
@@ -25,5 +25,5 @@
25
25
  "deepmerge-ts": "^7.1.5",
26
26
  "valibot": "^1.4.2"
27
27
  },
28
- "version": "0.1.2"
28
+ "version": "0.1.3"
29
29
  }