domani 0.4.0 → 0.4.4

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/domani.cjs +180 -180
  2. package/package.json +1 -1
package/dist/domani.cjs CHANGED
@@ -1,245 +1,245 @@
1
1
  #!/usr/bin/env node
2
- "use strict";var $o=Object.create;var qi=Object.defineProperty;var yo=Object.getOwnPropertyDescriptor;var bo=Object.getOwnPropertyNames;var vo=Object.getPrototypeOf,wo=Object.prototype.hasOwnProperty;var Pe=(e,t)=>()=>(e&&(t=e(e=0)),t);var st=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Rt=(e,t)=>{for(var i in t)qi(e,i,{get:t[i],enumerable:!0})},_o=(e,t,i,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of bo(t))!wo.call(e,n)&&n!==i&&qi(e,n,{get:()=>t[n],enumerable:!(s=yo(t,n))||s.enumerable});return e};var F=(e,t,i)=>(i=e!=null?$o(vo(e)):{},_o(t||!e||!e.__esModule?qi(i,"default",{value:e,enumerable:!0}):i,e));var Wt=st(Hi=>{var si=class extends Error{constructor(t,i,s){super(s),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=i,this.exitCode=t,this.nestedError=void 0}},Wi=class extends si{constructor(t){super(1,"commander.invalidArgument",t),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}};Hi.CommanderError=si;Hi.InvalidArgumentError=Wi});var ni=st(Bi=>{var{InvalidArgumentError:xo}=Wt(),Ji=class{constructor(t,i){switch(this.description=i||"",this.variadic=!1,this.parseArg=void 0,this.defaultValue=void 0,this.defaultValueDescription=void 0,this.argChoices=void 0,t[0]){case"<":this.required=!0,this._name=t.slice(1,-1);break;case"[":this.required=!1,this._name=t.slice(1,-1);break;default:this.required=!0,this._name=t;break}this._name.length>3&&this._name.slice(-3)==="..."&&(this.variadic=!0,this._name=this._name.slice(0,-3))}name(){return this._name}_concatValue(t,i){return i===this.defaultValue||!Array.isArray(i)?[t]:i.concat(t)}default(t,i){return this.defaultValue=t,this.defaultValueDescription=i,this}argParser(t){return this.parseArg=t,this}choices(t){return this.argChoices=t.slice(),this.parseArg=(i,s)=>{if(!this.argChoices.includes(i))throw new xo(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._concatValue(i,s):i},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}};function ko(e){let t=e.name()+(e.variadic===!0?"...":"");return e.required?"<"+t+">":"["+t+"]"}Bi.Argument=Ji;Bi.humanReadableArgName=ko});var Ki=st(Yi=>{var{humanReadableArgName:jo}=ni(),Gi=class{constructor(){this.helpWidth=void 0,this.minWidthToWrap=40,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}prepareContext(t){this.helpWidth=this.helpWidth??t.helpWidth??80}visibleCommands(t){let i=t.commands.filter(n=>!n._hidden),s=t._getHelpCommand();return s&&!s._hidden&&i.push(s),this.sortSubcommands&&i.sort((n,r)=>n.name().localeCompare(r.name())),i}compareOptions(t,i){let s=n=>n.short?n.short.replace(/^-/,""):n.long.replace(/^--/,"");return s(t).localeCompare(s(i))}visibleOptions(t){let i=t.options.filter(n=>!n.hidden),s=t._getHelpOption();if(s&&!s.hidden){let n=s.short&&t._findOption(s.short),r=s.long&&t._findOption(s.long);!n&&!r?i.push(s):s.long&&!r?i.push(t.createOption(s.long,s.description)):s.short&&!n&&i.push(t.createOption(s.short,s.description))}return this.sortOptions&&i.sort(this.compareOptions),i}visibleGlobalOptions(t){if(!this.showGlobalOptions)return[];let i=[];for(let s=t.parent;s;s=s.parent){let n=s.options.filter(r=>!r.hidden);i.push(...n)}return this.sortOptions&&i.sort(this.compareOptions),i}visibleArguments(t){return t._argsDescription&&t.registeredArguments.forEach(i=>{i.description=i.description||t._argsDescription[i.name()]||""}),t.registeredArguments.find(i=>i.description)?t.registeredArguments:[]}subcommandTerm(t){let i=t.registeredArguments.map(s=>jo(s)).join(" ");return t._name+(t._aliases[0]?"|"+t._aliases[0]:"")+(t.options.length?" [options]":"")+(i?" "+i:"")}optionTerm(t){return t.flags}argumentTerm(t){return t.name()}longestSubcommandTermLength(t,i){return i.visibleCommands(t).reduce((s,n)=>Math.max(s,this.displayWidth(i.styleSubcommandTerm(i.subcommandTerm(n)))),0)}longestOptionTermLength(t,i){return i.visibleOptions(t).reduce((s,n)=>Math.max(s,this.displayWidth(i.styleOptionTerm(i.optionTerm(n)))),0)}longestGlobalOptionTermLength(t,i){return i.visibleGlobalOptions(t).reduce((s,n)=>Math.max(s,this.displayWidth(i.styleOptionTerm(i.optionTerm(n)))),0)}longestArgumentTermLength(t,i){return i.visibleArguments(t).reduce((s,n)=>Math.max(s,this.displayWidth(i.styleArgumentTerm(i.argumentTerm(n)))),0)}commandUsage(t){let i=t._name;t._aliases[0]&&(i=i+"|"+t._aliases[0]);let s="";for(let n=t.parent;n;n=n.parent)s=n.name()+" "+s;return s+i+" "+t.usage()}commandDescription(t){return t.description()}subcommandDescription(t){return t.summary()||t.description()}optionDescription(t){let i=[];return t.argChoices&&i.push(`choices: ${t.argChoices.map(s=>JSON.stringify(s)).join(", ")}`),t.defaultValue!==void 0&&(t.required||t.optional||t.isBoolean()&&typeof t.defaultValue=="boolean")&&i.push(`default: ${t.defaultValueDescription||JSON.stringify(t.defaultValue)}`),t.presetArg!==void 0&&t.optional&&i.push(`preset: ${JSON.stringify(t.presetArg)}`),t.envVar!==void 0&&i.push(`env: ${t.envVar}`),i.length>0?`${t.description} (${i.join(", ")})`:t.description}argumentDescription(t){let i=[];if(t.argChoices&&i.push(`choices: ${t.argChoices.map(s=>JSON.stringify(s)).join(", ")}`),t.defaultValue!==void 0&&i.push(`default: ${t.defaultValueDescription||JSON.stringify(t.defaultValue)}`),i.length>0){let s=`(${i.join(", ")})`;return t.description?`${t.description} ${s}`:s}return t.description}formatHelp(t,i){let s=i.padWidth(t,i),n=i.helpWidth??80;function r(p,g){return i.formatItem(p,s,g,i)}let o=[`${i.styleTitle("Usage:")} ${i.styleUsage(i.commandUsage(t))}`,""],a=i.commandDescription(t);a.length>0&&(o=o.concat([i.boxWrap(i.styleCommandDescription(a),n),""]));let l=i.visibleArguments(t).map(p=>r(i.styleArgumentTerm(i.argumentTerm(p)),i.styleArgumentDescription(i.argumentDescription(p))));l.length>0&&(o=o.concat([i.styleTitle("Arguments:"),...l,""]));let c=i.visibleOptions(t).map(p=>r(i.styleOptionTerm(i.optionTerm(p)),i.styleOptionDescription(i.optionDescription(p))));if(c.length>0&&(o=o.concat([i.styleTitle("Options:"),...c,""])),i.showGlobalOptions){let p=i.visibleGlobalOptions(t).map(g=>r(i.styleOptionTerm(i.optionTerm(g)),i.styleOptionDescription(i.optionDescription(g))));p.length>0&&(o=o.concat([i.styleTitle("Global Options:"),...p,""]))}let u=i.visibleCommands(t).map(p=>r(i.styleSubcommandTerm(i.subcommandTerm(p)),i.styleSubcommandDescription(i.subcommandDescription(p))));return u.length>0&&(o=o.concat([i.styleTitle("Commands:"),...u,""])),o.join(`
3
- `)}displayWidth(t){return rn(t).length}styleTitle(t){return t}styleUsage(t){return t.split(" ").map(i=>i==="[options]"?this.styleOptionText(i):i==="[command]"?this.styleSubcommandText(i):i[0]==="["||i[0]==="<"?this.styleArgumentText(i):this.styleCommandText(i)).join(" ")}styleCommandDescription(t){return this.styleDescriptionText(t)}styleOptionDescription(t){return this.styleDescriptionText(t)}styleSubcommandDescription(t){return this.styleDescriptionText(t)}styleArgumentDescription(t){return this.styleDescriptionText(t)}styleDescriptionText(t){return t}styleOptionTerm(t){return this.styleOptionText(t)}styleSubcommandTerm(t){return t.split(" ").map(i=>i==="[options]"?this.styleOptionText(i):i[0]==="["||i[0]==="<"?this.styleArgumentText(i):this.styleSubcommandText(i)).join(" ")}styleArgumentTerm(t){return this.styleArgumentText(t)}styleOptionText(t){return t}styleArgumentText(t){return t}styleSubcommandText(t){return t}styleCommandText(t){return t}padWidth(t,i){return Math.max(i.longestOptionTermLength(t,i),i.longestGlobalOptionTermLength(t,i),i.longestSubcommandTermLength(t,i),i.longestArgumentTermLength(t,i))}preformatted(t){return/\n[^\S\r\n]/.test(t)}formatItem(t,i,s,n){let o=" ".repeat(2);if(!s)return o+t;let a=t.padEnd(i+t.length-n.displayWidth(t)),l=2,u=(this.helpWidth??80)-i-l-2,p;return u<this.minWidthToWrap||n.preformatted(s)?p=s:p=n.boxWrap(s,u).replace(/\n/g,`
4
- `+" ".repeat(i+l)),o+a+" ".repeat(l)+p.replace(/\n/g,`
5
- ${o}`)}boxWrap(t,i){if(i<this.minWidthToWrap)return t;let s=t.split(/\r\n|\n/),n=/[\s]*[^\s]+/g,r=[];return s.forEach(o=>{let a=o.match(n);if(a===null){r.push("");return}let l=[a.shift()],c=this.displayWidth(l[0]);a.forEach(u=>{let p=this.displayWidth(u);if(c+p<=i){l.push(u),c+=p;return}r.push(l.join(""));let g=u.trimStart();l=[g],c=this.displayWidth(g)}),r.push(l.join(""))}),r.join(`
6
- `)}};function rn(e){let t=/\x1b\[\d*(;\d*)*m/g;return e.replace(t,"")}Yi.Help=Gi;Yi.stripColor=rn});var Qi=st(Zi=>{var{InvalidArgumentError:So}=Wt(),zi=class{constructor(t,i){this.flags=t,this.description=i||"",this.required=t.includes("<"),this.optional=t.includes("["),this.variadic=/\w\.\.\.[>\]]$/.test(t),this.mandatory=!1;let s=Co(t);this.short=s.shortFlag,this.long=s.longFlag,this.negate=!1,this.long&&(this.negate=this.long.startsWith("--no-")),this.defaultValue=void 0,this.defaultValueDescription=void 0,this.presetArg=void 0,this.envVar=void 0,this.parseArg=void 0,this.hidden=!1,this.argChoices=void 0,this.conflictsWith=[],this.implied=void 0}default(t,i){return this.defaultValue=t,this.defaultValueDescription=i,this}preset(t){return this.presetArg=t,this}conflicts(t){return this.conflictsWith=this.conflictsWith.concat(t),this}implies(t){let i=t;return typeof t=="string"&&(i={[t]:!0}),this.implied=Object.assign(this.implied||{},i),this}env(t){return this.envVar=t,this}argParser(t){return this.parseArg=t,this}makeOptionMandatory(t=!0){return this.mandatory=!!t,this}hideHelp(t=!0){return this.hidden=!!t,this}_concatValue(t,i){return i===this.defaultValue||!Array.isArray(i)?[t]:i.concat(t)}choices(t){return this.argChoices=t.slice(),this.parseArg=(i,s)=>{if(!this.argChoices.includes(i))throw new So(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._concatValue(i,s):i},this}name(){return this.long?this.long.replace(/^--/,""):this.short.replace(/^-/,"")}attributeName(){return this.negate?on(this.name().replace(/^no-/,"")):on(this.name())}is(t){return this.short===t||this.long===t}isBoolean(){return!this.required&&!this.optional&&!this.negate}},Xi=class{constructor(t){this.positiveOptions=new Map,this.negativeOptions=new Map,this.dualOptions=new Set,t.forEach(i=>{i.negate?this.negativeOptions.set(i.attributeName(),i):this.positiveOptions.set(i.attributeName(),i)}),this.negativeOptions.forEach((i,s)=>{this.positiveOptions.has(s)&&this.dualOptions.add(s)})}valueFromOption(t,i){let s=i.attributeName();if(!this.dualOptions.has(s))return!0;let n=this.negativeOptions.get(s).presetArg,r=n!==void 0?n:!1;return i.negate===(r===t)}};function on(e){return e.split("-").reduce((t,i)=>t+i[0].toUpperCase()+i.slice(1))}function Co(e){let t,i,s=/^-[^-]$/,n=/^--[^-]/,r=e.split(/[ |,]+/).concat("guard");if(s.test(r[0])&&(t=r.shift()),n.test(r[0])&&(i=r.shift()),!t&&s.test(r[0])&&(t=r.shift()),!t&&n.test(r[0])&&(t=i,i=r.shift()),r[0].startsWith("-")){let o=r[0],a=`option creation failed due to '${o}' in option flags '${e}'`;throw/^-[^-][^-]/.test(o)?new Error(`${a}
2
+ "use strict";var bo=Object.create;var qs=Object.defineProperty;var vo=Object.getOwnPropertyDescriptor;var wo=Object.getOwnPropertyNames;var _o=Object.getPrototypeOf,xo=Object.prototype.hasOwnProperty;var De=(e,t)=>()=>(e&&(t=e(e=0)),t);var it=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),It=(e,t)=>{for(var s in t)qs(e,s,{get:t[s],enumerable:!0})},ko=(e,t,s,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of wo(t))!xo.call(e,n)&&n!==s&&qs(e,n,{get:()=>t[n],enumerable:!(i=vo(t,n))||i.enumerable});return e};var U=(e,t,s)=>(s=e!=null?bo(_o(e)):{},ko(t||!e||!e.__esModule?qs(s,"default",{value:e,enumerable:!0}):s,e));var Wt=it(Hs=>{var ns=class extends Error{constructor(t,s,i){super(i),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=s,this.exitCode=t,this.nestedError=void 0}},Ws=class extends ns{constructor(t){super(1,"commander.invalidArgument",t),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}};Hs.CommanderError=ns;Hs.InvalidArgumentError=Ws});var rs=it(Bs=>{var{InvalidArgumentError:jo}=Wt(),Js=class{constructor(t,s){switch(this.description=s||"",this.variadic=!1,this.parseArg=void 0,this.defaultValue=void 0,this.defaultValueDescription=void 0,this.argChoices=void 0,t[0]){case"<":this.required=!0,this._name=t.slice(1,-1);break;case"[":this.required=!1,this._name=t.slice(1,-1);break;default:this.required=!0,this._name=t;break}this._name.length>3&&this._name.slice(-3)==="..."&&(this.variadic=!0,this._name=this._name.slice(0,-3))}name(){return this._name}_concatValue(t,s){return s===this.defaultValue||!Array.isArray(s)?[t]:s.concat(t)}default(t,s){return this.defaultValue=t,this.defaultValueDescription=s,this}argParser(t){return this.parseArg=t,this}choices(t){return this.argChoices=t.slice(),this.parseArg=(s,i)=>{if(!this.argChoices.includes(s))throw new jo(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._concatValue(s,i):s},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}};function So(e){let t=e.name()+(e.variadic===!0?"...":"");return e.required?"<"+t+">":"["+t+"]"}Bs.Argument=Js;Bs.humanReadableArgName=So});var Ks=it(Ys=>{var{humanReadableArgName:Co}=rs(),Gs=class{constructor(){this.helpWidth=void 0,this.minWidthToWrap=40,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}prepareContext(t){this.helpWidth=this.helpWidth??t.helpWidth??80}visibleCommands(t){let s=t.commands.filter(n=>!n._hidden),i=t._getHelpCommand();return i&&!i._hidden&&s.push(i),this.sortSubcommands&&s.sort((n,r)=>n.name().localeCompare(r.name())),s}compareOptions(t,s){let i=n=>n.short?n.short.replace(/^-/,""):n.long.replace(/^--/,"");return i(t).localeCompare(i(s))}visibleOptions(t){let s=t.options.filter(n=>!n.hidden),i=t._getHelpOption();if(i&&!i.hidden){let n=i.short&&t._findOption(i.short),r=i.long&&t._findOption(i.long);!n&&!r?s.push(i):i.long&&!r?s.push(t.createOption(i.long,i.description)):i.short&&!n&&s.push(t.createOption(i.short,i.description))}return this.sortOptions&&s.sort(this.compareOptions),s}visibleGlobalOptions(t){if(!this.showGlobalOptions)return[];let s=[];for(let i=t.parent;i;i=i.parent){let n=i.options.filter(r=>!r.hidden);s.push(...n)}return this.sortOptions&&s.sort(this.compareOptions),s}visibleArguments(t){return t._argsDescription&&t.registeredArguments.forEach(s=>{s.description=s.description||t._argsDescription[s.name()]||""}),t.registeredArguments.find(s=>s.description)?t.registeredArguments:[]}subcommandTerm(t){let s=t.registeredArguments.map(i=>Co(i)).join(" ");return t._name+(t._aliases[0]?"|"+t._aliases[0]:"")+(t.options.length?" [options]":"")+(s?" "+s:"")}optionTerm(t){return t.flags}argumentTerm(t){return t.name()}longestSubcommandTermLength(t,s){return s.visibleCommands(t).reduce((i,n)=>Math.max(i,this.displayWidth(s.styleSubcommandTerm(s.subcommandTerm(n)))),0)}longestOptionTermLength(t,s){return s.visibleOptions(t).reduce((i,n)=>Math.max(i,this.displayWidth(s.styleOptionTerm(s.optionTerm(n)))),0)}longestGlobalOptionTermLength(t,s){return s.visibleGlobalOptions(t).reduce((i,n)=>Math.max(i,this.displayWidth(s.styleOptionTerm(s.optionTerm(n)))),0)}longestArgumentTermLength(t,s){return s.visibleArguments(t).reduce((i,n)=>Math.max(i,this.displayWidth(s.styleArgumentTerm(s.argumentTerm(n)))),0)}commandUsage(t){let s=t._name;t._aliases[0]&&(s=s+"|"+t._aliases[0]);let i="";for(let n=t.parent;n;n=n.parent)i=n.name()+" "+i;return i+s+" "+t.usage()}commandDescription(t){return t.description()}subcommandDescription(t){return t.summary()||t.description()}optionDescription(t){let s=[];return t.argChoices&&s.push(`choices: ${t.argChoices.map(i=>JSON.stringify(i)).join(", ")}`),t.defaultValue!==void 0&&(t.required||t.optional||t.isBoolean()&&typeof t.defaultValue=="boolean")&&s.push(`default: ${t.defaultValueDescription||JSON.stringify(t.defaultValue)}`),t.presetArg!==void 0&&t.optional&&s.push(`preset: ${JSON.stringify(t.presetArg)}`),t.envVar!==void 0&&s.push(`env: ${t.envVar}`),s.length>0?`${t.description} (${s.join(", ")})`:t.description}argumentDescription(t){let s=[];if(t.argChoices&&s.push(`choices: ${t.argChoices.map(i=>JSON.stringify(i)).join(", ")}`),t.defaultValue!==void 0&&s.push(`default: ${t.defaultValueDescription||JSON.stringify(t.defaultValue)}`),s.length>0){let i=`(${s.join(", ")})`;return t.description?`${t.description} ${i}`:i}return t.description}formatHelp(t,s){let i=s.padWidth(t,s),n=s.helpWidth??80;function r(p,g){return s.formatItem(p,i,g,s)}let o=[`${s.styleTitle("Usage:")} ${s.styleUsage(s.commandUsage(t))}`,""],a=s.commandDescription(t);a.length>0&&(o=o.concat([s.boxWrap(s.styleCommandDescription(a),n),""]));let l=s.visibleArguments(t).map(p=>r(s.styleArgumentTerm(s.argumentTerm(p)),s.styleArgumentDescription(s.argumentDescription(p))));l.length>0&&(o=o.concat([s.styleTitle("Arguments:"),...l,""]));let d=s.visibleOptions(t).map(p=>r(s.styleOptionTerm(s.optionTerm(p)),s.styleOptionDescription(s.optionDescription(p))));if(d.length>0&&(o=o.concat([s.styleTitle("Options:"),...d,""])),s.showGlobalOptions){let p=s.visibleGlobalOptions(t).map(g=>r(s.styleOptionTerm(s.optionTerm(g)),s.styleOptionDescription(s.optionDescription(g))));p.length>0&&(o=o.concat([s.styleTitle("Global Options:"),...p,""]))}let u=s.visibleCommands(t).map(p=>r(s.styleSubcommandTerm(s.subcommandTerm(p)),s.styleSubcommandDescription(s.subcommandDescription(p))));return u.length>0&&(o=o.concat([s.styleTitle("Commands:"),...u,""])),o.join(`
3
+ `)}displayWidth(t){return ln(t).length}styleTitle(t){return t}styleUsage(t){return t.split(" ").map(s=>s==="[options]"?this.styleOptionText(s):s==="[command]"?this.styleSubcommandText(s):s[0]==="["||s[0]==="<"?this.styleArgumentText(s):this.styleCommandText(s)).join(" ")}styleCommandDescription(t){return this.styleDescriptionText(t)}styleOptionDescription(t){return this.styleDescriptionText(t)}styleSubcommandDescription(t){return this.styleDescriptionText(t)}styleArgumentDescription(t){return this.styleDescriptionText(t)}styleDescriptionText(t){return t}styleOptionTerm(t){return this.styleOptionText(t)}styleSubcommandTerm(t){return t.split(" ").map(s=>s==="[options]"?this.styleOptionText(s):s[0]==="["||s[0]==="<"?this.styleArgumentText(s):this.styleSubcommandText(s)).join(" ")}styleArgumentTerm(t){return this.styleArgumentText(t)}styleOptionText(t){return t}styleArgumentText(t){return t}styleSubcommandText(t){return t}styleCommandText(t){return t}padWidth(t,s){return Math.max(s.longestOptionTermLength(t,s),s.longestGlobalOptionTermLength(t,s),s.longestSubcommandTermLength(t,s),s.longestArgumentTermLength(t,s))}preformatted(t){return/\n[^\S\r\n]/.test(t)}formatItem(t,s,i,n){let o=" ".repeat(2);if(!i)return o+t;let a=t.padEnd(s+t.length-n.displayWidth(t)),l=2,u=(this.helpWidth??80)-s-l-2,p;return u<this.minWidthToWrap||n.preformatted(i)?p=i:p=n.boxWrap(i,u).replace(/\n/g,`
4
+ `+" ".repeat(s+l)),o+a+" ".repeat(l)+p.replace(/\n/g,`
5
+ ${o}`)}boxWrap(t,s){if(s<this.minWidthToWrap)return t;let i=t.split(/\r\n|\n/),n=/[\s]*[^\s]+/g,r=[];return i.forEach(o=>{let a=o.match(n);if(a===null){r.push("");return}let l=[a.shift()],d=this.displayWidth(l[0]);a.forEach(u=>{let p=this.displayWidth(u);if(d+p<=s){l.push(u),d+=p;return}r.push(l.join(""));let g=u.trimStart();l=[g],d=this.displayWidth(g)}),r.push(l.join(""))}),r.join(`
6
+ `)}};function ln(e){let t=/\x1b\[\d*(;\d*)*m/g;return e.replace(t,"")}Ys.Help=Gs;Ys.stripColor=ln});var Qs=it(Zs=>{var{InvalidArgumentError:Oo}=Wt(),zs=class{constructor(t,s){this.flags=t,this.description=s||"",this.required=t.includes("<"),this.optional=t.includes("["),this.variadic=/\w\.\.\.[>\]]$/.test(t),this.mandatory=!1;let i=Ro(t);this.short=i.shortFlag,this.long=i.longFlag,this.negate=!1,this.long&&(this.negate=this.long.startsWith("--no-")),this.defaultValue=void 0,this.defaultValueDescription=void 0,this.presetArg=void 0,this.envVar=void 0,this.parseArg=void 0,this.hidden=!1,this.argChoices=void 0,this.conflictsWith=[],this.implied=void 0}default(t,s){return this.defaultValue=t,this.defaultValueDescription=s,this}preset(t){return this.presetArg=t,this}conflicts(t){return this.conflictsWith=this.conflictsWith.concat(t),this}implies(t){let s=t;return typeof t=="string"&&(s={[t]:!0}),this.implied=Object.assign(this.implied||{},s),this}env(t){return this.envVar=t,this}argParser(t){return this.parseArg=t,this}makeOptionMandatory(t=!0){return this.mandatory=!!t,this}hideHelp(t=!0){return this.hidden=!!t,this}_concatValue(t,s){return s===this.defaultValue||!Array.isArray(s)?[t]:s.concat(t)}choices(t){return this.argChoices=t.slice(),this.parseArg=(s,i)=>{if(!this.argChoices.includes(s))throw new Oo(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._concatValue(s,i):s},this}name(){return this.long?this.long.replace(/^--/,""):this.short.replace(/^-/,"")}attributeName(){return this.negate?cn(this.name().replace(/^no-/,"")):cn(this.name())}is(t){return this.short===t||this.long===t}isBoolean(){return!this.required&&!this.optional&&!this.negate}},Xs=class{constructor(t){this.positiveOptions=new Map,this.negativeOptions=new Map,this.dualOptions=new Set,t.forEach(s=>{s.negate?this.negativeOptions.set(s.attributeName(),s):this.positiveOptions.set(s.attributeName(),s)}),this.negativeOptions.forEach((s,i)=>{this.positiveOptions.has(i)&&this.dualOptions.add(i)})}valueFromOption(t,s){let i=s.attributeName();if(!this.dualOptions.has(i))return!0;let n=this.negativeOptions.get(i).presetArg,r=n!==void 0?n:!1;return s.negate===(r===t)}};function cn(e){return e.split("-").reduce((t,s)=>t+s[0].toUpperCase()+s.slice(1))}function Ro(e){let t,s,i=/^-[^-]$/,n=/^--[^-]/,r=e.split(/[ |,]+/).concat("guard");if(i.test(r[0])&&(t=r.shift()),n.test(r[0])&&(s=r.shift()),!t&&i.test(r[0])&&(t=r.shift()),!t&&n.test(r[0])&&(t=s,s=r.shift()),r[0].startsWith("-")){let o=r[0],a=`option creation failed due to '${o}' in option flags '${e}'`;throw/^-[^-][^-]/.test(o)?new Error(`${a}
7
7
  - a short flag is a single dash and a single character
8
8
  - either use a single dash and a single character (for a short flag)
9
- - or use a double dash for a long option (and can have two, like '--ws, --workspace')`):s.test(o)?new Error(`${a}
9
+ - or use a double dash for a long option (and can have two, like '--ws, --workspace')`):i.test(o)?new Error(`${a}
10
10
  - too many short flags`):n.test(o)?new Error(`${a}
11
11
  - too many long flags`):new Error(`${a}
12
- - unrecognised flag format`)}if(t===void 0&&i===void 0)throw new Error(`option creation failed due to no flags found in '${e}'.`);return{shortFlag:t,longFlag:i}}Zi.Option=zi;Zi.DualOptions=Xi});var ln=st(an=>{function Oo(e,t){if(Math.abs(e.length-t.length)>3)return Math.max(e.length,t.length);let i=[];for(let s=0;s<=e.length;s++)i[s]=[s];for(let s=0;s<=t.length;s++)i[0][s]=s;for(let s=1;s<=t.length;s++)for(let n=1;n<=e.length;n++){let r=1;e[n-1]===t[s-1]?r=0:r=1,i[n][s]=Math.min(i[n-1][s]+1,i[n][s-1]+1,i[n-1][s-1]+r),n>1&&s>1&&e[n-1]===t[s-2]&&e[n-2]===t[s-1]&&(i[n][s]=Math.min(i[n][s],i[n-2][s-2]+1))}return i[e.length][t.length]}function Ao(e,t){if(!t||t.length===0)return"";t=Array.from(new Set(t));let i=e.startsWith("--");i&&(e=e.slice(2),t=t.map(o=>o.slice(2)));let s=[],n=3,r=.4;return t.forEach(o=>{if(o.length<=1)return;let a=Oo(e,o),l=Math.max(e.length,o.length);(l-a)/l>r&&(a<n?(n=a,s=[o]):a===n&&s.push(o))}),s.sort((o,a)=>o.localeCompare(a)),i&&(s=s.map(o=>`--${o}`)),s.length>1?`
13
- (Did you mean one of ${s.join(", ")}?)`:s.length===1?`
14
- (Did you mean ${s[0]}?)`:""}an.suggestSimilar=Ao});var mn=st(ns=>{var Ro=require("node:events").EventEmitter,es=require("node:child_process"),nt=require("node:path"),ri=require("node:fs"),ie=require("node:process"),{Argument:Eo,humanReadableArgName:Io}=ni(),{CommanderError:ts}=Wt(),{Help:To,stripColor:Po}=Ki(),{Option:cn,DualOptions:Do}=Qi(),{suggestSimilar:dn}=ln(),is=class e extends Ro{constructor(t){super(),this.commands=[],this.options=[],this.parent=null,this._allowUnknownOption=!1,this._allowExcessArguments=!1,this.registeredArguments=[],this._args=this.registeredArguments,this.args=[],this.rawArgs=[],this.processedArgs=[],this._scriptPath=null,this._name=t||"",this._optionValues={},this._optionValueSources={},this._storeOptionsAsProperties=!1,this._actionHandler=null,this._executableHandler=!1,this._executableFile=null,this._executableDir=null,this._defaultCommandName=null,this._exitCallback=null,this._aliases=[],this._combineFlagAndOptionalValue=!0,this._description="",this._summary="",this._argsDescription=void 0,this._enablePositionalOptions=!1,this._passThroughOptions=!1,this._lifeCycleHooks={},this._showHelpAfterError=!1,this._showSuggestionAfterError=!0,this._savedState=null,this._outputConfiguration={writeOut:i=>ie.stdout.write(i),writeErr:i=>ie.stderr.write(i),outputError:(i,s)=>s(i),getOutHelpWidth:()=>ie.stdout.isTTY?ie.stdout.columns:void 0,getErrHelpWidth:()=>ie.stderr.isTTY?ie.stderr.columns:void 0,getOutHasColors:()=>ss()??(ie.stdout.isTTY&&ie.stdout.hasColors?.()),getErrHasColors:()=>ss()??(ie.stderr.isTTY&&ie.stderr.hasColors?.()),stripColor:i=>Po(i)},this._hidden=!1,this._helpOption=void 0,this._addImplicitHelpCommand=void 0,this._helpCommand=void 0,this._helpConfiguration={}}copyInheritedSettings(t){return this._outputConfiguration=t._outputConfiguration,this._helpOption=t._helpOption,this._helpCommand=t._helpCommand,this._helpConfiguration=t._helpConfiguration,this._exitCallback=t._exitCallback,this._storeOptionsAsProperties=t._storeOptionsAsProperties,this._combineFlagAndOptionalValue=t._combineFlagAndOptionalValue,this._allowExcessArguments=t._allowExcessArguments,this._enablePositionalOptions=t._enablePositionalOptions,this._showHelpAfterError=t._showHelpAfterError,this._showSuggestionAfterError=t._showSuggestionAfterError,this}_getCommandAndAncestors(){let t=[];for(let i=this;i;i=i.parent)t.push(i);return t}command(t,i,s){let n=i,r=s;typeof n=="object"&&n!==null&&(r=n,n=null),r=r||{};let[,o,a]=t.match(/([^ ]+) *(.*)/),l=this.createCommand(o);return n&&(l.description(n),l._executableHandler=!0),r.isDefault&&(this._defaultCommandName=l._name),l._hidden=!!(r.noHelp||r.hidden),l._executableFile=r.executableFile||null,a&&l.arguments(a),this._registerCommand(l),l.parent=this,l.copyInheritedSettings(this),n?this:l}createCommand(t){return new e(t)}createHelp(){return Object.assign(new To,this.configureHelp())}configureHelp(t){return t===void 0?this._helpConfiguration:(this._helpConfiguration=t,this)}configureOutput(t){return t===void 0?this._outputConfiguration:(Object.assign(this._outputConfiguration,t),this)}showHelpAfterError(t=!0){return typeof t!="string"&&(t=!!t),this._showHelpAfterError=t,this}showSuggestionAfterError(t=!0){return this._showSuggestionAfterError=!!t,this}addCommand(t,i){if(!t._name)throw new Error(`Command passed to .addCommand() must have a name
15
- - specify the name in Command constructor or using .name()`);return i=i||{},i.isDefault&&(this._defaultCommandName=t._name),(i.noHelp||i.hidden)&&(t._hidden=!0),this._registerCommand(t),t.parent=this,t._checkForBrokenPassThrough(),this}createArgument(t,i){return new Eo(t,i)}argument(t,i,s,n){let r=this.createArgument(t,i);return typeof s=="function"?r.default(n).argParser(s):r.default(s),this.addArgument(r),this}arguments(t){return t.trim().split(/ +/).forEach(i=>{this.argument(i)}),this}addArgument(t){let i=this.registeredArguments.slice(-1)[0];if(i&&i.variadic)throw new Error(`only the last argument can be variadic '${i.name()}'`);if(t.required&&t.defaultValue!==void 0&&t.parseArg===void 0)throw new Error(`a default value for a required argument is never used: '${t.name()}'`);return this.registeredArguments.push(t),this}helpCommand(t,i){if(typeof t=="boolean")return this._addImplicitHelpCommand=t,this;t=t??"help [command]";let[,s,n]=t.match(/([^ ]+) *(.*)/),r=i??"display help for command",o=this.createCommand(s);return o.helpOption(!1),n&&o.arguments(n),r&&o.description(r),this._addImplicitHelpCommand=!0,this._helpCommand=o,this}addHelpCommand(t,i){return typeof t!="object"?(this.helpCommand(t,i),this):(this._addImplicitHelpCommand=!0,this._helpCommand=t,this)}_getHelpCommand(){return this._addImplicitHelpCommand??(this.commands.length&&!this._actionHandler&&!this._findCommand("help"))?(this._helpCommand===void 0&&this.helpCommand(void 0,void 0),this._helpCommand):null}hook(t,i){let s=["preSubcommand","preAction","postAction"];if(!s.includes(t))throw new Error(`Unexpected value for event passed to hook : '${t}'.
16
- Expecting one of '${s.join("', '")}'`);return this._lifeCycleHooks[t]?this._lifeCycleHooks[t].push(i):this._lifeCycleHooks[t]=[i],this}exitOverride(t){return t?this._exitCallback=t:this._exitCallback=i=>{if(i.code!=="commander.executeSubCommandAsync")throw i},this}_exit(t,i,s){this._exitCallback&&this._exitCallback(new ts(t,i,s)),ie.exit(t)}action(t){let i=s=>{let n=this.registeredArguments.length,r=s.slice(0,n);return this._storeOptionsAsProperties?r[n]=this:r[n]=this.opts(),r.push(this),t.apply(this,r)};return this._actionHandler=i,this}createOption(t,i){return new cn(t,i)}_callParseArg(t,i,s,n){try{return t.parseArg(i,s)}catch(r){if(r.code==="commander.invalidArgument"){let o=`${n} ${r.message}`;this.error(o,{exitCode:r.exitCode,code:r.code})}throw r}}_registerOption(t){let i=t.short&&this._findOption(t.short)||t.long&&this._findOption(t.long);if(i){let s=t.long&&this._findOption(t.long)?t.long:t.short;throw new Error(`Cannot add option '${t.flags}'${this._name&&` to command '${this._name}'`} due to conflicting flag '${s}'
17
- - already used by option '${i.flags}'`)}this.options.push(t)}_registerCommand(t){let i=n=>[n.name()].concat(n.aliases()),s=i(t).find(n=>this._findCommand(n));if(s){let n=i(this._findCommand(s)).join("|"),r=i(t).join("|");throw new Error(`cannot add command '${r}' as already have command '${n}'`)}this.commands.push(t)}addOption(t){this._registerOption(t);let i=t.name(),s=t.attributeName();if(t.negate){let r=t.long.replace(/^--no-/,"--");this._findOption(r)||this.setOptionValueWithSource(s,t.defaultValue===void 0?!0:t.defaultValue,"default")}else t.defaultValue!==void 0&&this.setOptionValueWithSource(s,t.defaultValue,"default");let n=(r,o,a)=>{r==null&&t.presetArg!==void 0&&(r=t.presetArg);let l=this.getOptionValue(s);r!==null&&t.parseArg?r=this._callParseArg(t,r,l,o):r!==null&&t.variadic&&(r=t._concatValue(r,l)),r==null&&(t.negate?r=!1:t.isBoolean()||t.optional?r=!0:r=""),this.setOptionValueWithSource(s,r,a)};return this.on("option:"+i,r=>{let o=`error: option '${t.flags}' argument '${r}' is invalid.`;n(r,o,"cli")}),t.envVar&&this.on("optionEnv:"+i,r=>{let o=`error: option '${t.flags}' value '${r}' from env '${t.envVar}' is invalid.`;n(r,o,"env")}),this}_optionEx(t,i,s,n,r){if(typeof i=="object"&&i instanceof cn)throw new Error("To add an Option object use addOption() instead of option() or requiredOption()");let o=this.createOption(i,s);if(o.makeOptionMandatory(!!t.mandatory),typeof n=="function")o.default(r).argParser(n);else if(n instanceof RegExp){let a=n;n=(l,c)=>{let u=a.exec(l);return u?u[0]:c},o.default(r).argParser(n)}else o.default(n);return this.addOption(o)}option(t,i,s,n){return this._optionEx({},t,i,s,n)}requiredOption(t,i,s,n){return this._optionEx({mandatory:!0},t,i,s,n)}combineFlagAndOptionalValue(t=!0){return this._combineFlagAndOptionalValue=!!t,this}allowUnknownOption(t=!0){return this._allowUnknownOption=!!t,this}allowExcessArguments(t=!0){return this._allowExcessArguments=!!t,this}enablePositionalOptions(t=!0){return this._enablePositionalOptions=!!t,this}passThroughOptions(t=!0){return this._passThroughOptions=!!t,this._checkForBrokenPassThrough(),this}_checkForBrokenPassThrough(){if(this.parent&&this._passThroughOptions&&!this.parent._enablePositionalOptions)throw new Error(`passThroughOptions cannot be used for '${this._name}' without turning on enablePositionalOptions for parent command(s)`)}storeOptionsAsProperties(t=!0){if(this.options.length)throw new Error("call .storeOptionsAsProperties() before adding options");if(Object.keys(this._optionValues).length)throw new Error("call .storeOptionsAsProperties() before setting option values");return this._storeOptionsAsProperties=!!t,this}getOptionValue(t){return this._storeOptionsAsProperties?this[t]:this._optionValues[t]}setOptionValue(t,i){return this.setOptionValueWithSource(t,i,void 0)}setOptionValueWithSource(t,i,s){return this._storeOptionsAsProperties?this[t]=i:this._optionValues[t]=i,this._optionValueSources[t]=s,this}getOptionValueSource(t){return this._optionValueSources[t]}getOptionValueSourceWithGlobals(t){let i;return this._getCommandAndAncestors().forEach(s=>{s.getOptionValueSource(t)!==void 0&&(i=s.getOptionValueSource(t))}),i}_prepareUserArgs(t,i){if(t!==void 0&&!Array.isArray(t))throw new Error("first parameter to parse must be array or undefined");if(i=i||{},t===void 0&&i.from===void 0){ie.versions?.electron&&(i.from="electron");let n=ie.execArgv??[];(n.includes("-e")||n.includes("--eval")||n.includes("-p")||n.includes("--print"))&&(i.from="eval")}t===void 0&&(t=ie.argv),this.rawArgs=t.slice();let s;switch(i.from){case void 0:case"node":this._scriptPath=t[1],s=t.slice(2);break;case"electron":ie.defaultApp?(this._scriptPath=t[1],s=t.slice(2)):s=t.slice(1);break;case"user":s=t.slice(0);break;case"eval":s=t.slice(1);break;default:throw new Error(`unexpected parse option { from: '${i.from}' }`)}return!this._name&&this._scriptPath&&this.nameFromFilename(this._scriptPath),this._name=this._name||"program",s}parse(t,i){this._prepareForParse();let s=this._prepareUserArgs(t,i);return this._parseCommand([],s),this}async parseAsync(t,i){this._prepareForParse();let s=this._prepareUserArgs(t,i);return await this._parseCommand([],s),this}_prepareForParse(){this._savedState===null?this.saveStateBeforeParse():this.restoreStateBeforeParse()}saveStateBeforeParse(){this._savedState={_name:this._name,_optionValues:{...this._optionValues},_optionValueSources:{...this._optionValueSources}}}restoreStateBeforeParse(){if(this._storeOptionsAsProperties)throw new Error(`Can not call parse again when storeOptionsAsProperties is true.
18
- - either make a new Command for each call to parse, or stop storing options as properties`);this._name=this._savedState._name,this._scriptPath=null,this.rawArgs=[],this._optionValues={...this._savedState._optionValues},this._optionValueSources={...this._savedState._optionValueSources},this.args=[],this.processedArgs=[]}_checkForMissingExecutable(t,i,s){if(ri.existsSync(t))return;let n=i?`searched for local subcommand relative to directory '${i}'`:"no directory for search for local subcommand, use .executableDir() to supply a custom directory",r=`'${t}' does not exist
19
- - if '${s}' is not meant to be an executable command, remove description parameter from '.command()' and use '.description()' instead
12
+ - unrecognised flag format`)}if(t===void 0&&s===void 0)throw new Error(`option creation failed due to no flags found in '${e}'.`);return{shortFlag:t,longFlag:s}}Zs.Option=zs;Zs.DualOptions=Xs});var un=it(dn=>{function Ao(e,t){if(Math.abs(e.length-t.length)>3)return Math.max(e.length,t.length);let s=[];for(let i=0;i<=e.length;i++)s[i]=[i];for(let i=0;i<=t.length;i++)s[0][i]=i;for(let i=1;i<=t.length;i++)for(let n=1;n<=e.length;n++){let r=1;e[n-1]===t[i-1]?r=0:r=1,s[n][i]=Math.min(s[n-1][i]+1,s[n][i-1]+1,s[n-1][i-1]+r),n>1&&i>1&&e[n-1]===t[i-2]&&e[n-2]===t[i-1]&&(s[n][i]=Math.min(s[n][i],s[n-2][i-2]+1))}return s[e.length][t.length]}function Eo(e,t){if(!t||t.length===0)return"";t=Array.from(new Set(t));let s=e.startsWith("--");s&&(e=e.slice(2),t=t.map(o=>o.slice(2)));let i=[],n=3,r=.4;return t.forEach(o=>{if(o.length<=1)return;let a=Ao(e,o),l=Math.max(e.length,o.length);(l-a)/l>r&&(a<n?(n=a,i=[o]):a===n&&i.push(o))}),i.sort((o,a)=>o.localeCompare(a)),s&&(i=i.map(o=>`--${o}`)),i.length>1?`
13
+ (Did you mean one of ${i.join(", ")}?)`:i.length===1?`
14
+ (Did you mean ${i[0]}?)`:""}dn.suggestSimilar=Eo});var hn=it(ni=>{var Io=require("node:events").EventEmitter,ei=require("node:child_process"),nt=require("node:path"),os=require("node:fs"),se=require("node:process"),{Argument:To,humanReadableArgName:Po}=rs(),{CommanderError:ti}=Wt(),{Help:Do,stripColor:No}=Ks(),{Option:mn,DualOptions:Fo}=Qs(),{suggestSimilar:fn}=un(),si=class e extends Io{constructor(t){super(),this.commands=[],this.options=[],this.parent=null,this._allowUnknownOption=!1,this._allowExcessArguments=!1,this.registeredArguments=[],this._args=this.registeredArguments,this.args=[],this.rawArgs=[],this.processedArgs=[],this._scriptPath=null,this._name=t||"",this._optionValues={},this._optionValueSources={},this._storeOptionsAsProperties=!1,this._actionHandler=null,this._executableHandler=!1,this._executableFile=null,this._executableDir=null,this._defaultCommandName=null,this._exitCallback=null,this._aliases=[],this._combineFlagAndOptionalValue=!0,this._description="",this._summary="",this._argsDescription=void 0,this._enablePositionalOptions=!1,this._passThroughOptions=!1,this._lifeCycleHooks={},this._showHelpAfterError=!1,this._showSuggestionAfterError=!0,this._savedState=null,this._outputConfiguration={writeOut:s=>se.stdout.write(s),writeErr:s=>se.stderr.write(s),outputError:(s,i)=>i(s),getOutHelpWidth:()=>se.stdout.isTTY?se.stdout.columns:void 0,getErrHelpWidth:()=>se.stderr.isTTY?se.stderr.columns:void 0,getOutHasColors:()=>ii()??(se.stdout.isTTY&&se.stdout.hasColors?.()),getErrHasColors:()=>ii()??(se.stderr.isTTY&&se.stderr.hasColors?.()),stripColor:s=>No(s)},this._hidden=!1,this._helpOption=void 0,this._addImplicitHelpCommand=void 0,this._helpCommand=void 0,this._helpConfiguration={}}copyInheritedSettings(t){return this._outputConfiguration=t._outputConfiguration,this._helpOption=t._helpOption,this._helpCommand=t._helpCommand,this._helpConfiguration=t._helpConfiguration,this._exitCallback=t._exitCallback,this._storeOptionsAsProperties=t._storeOptionsAsProperties,this._combineFlagAndOptionalValue=t._combineFlagAndOptionalValue,this._allowExcessArguments=t._allowExcessArguments,this._enablePositionalOptions=t._enablePositionalOptions,this._showHelpAfterError=t._showHelpAfterError,this._showSuggestionAfterError=t._showSuggestionAfterError,this}_getCommandAndAncestors(){let t=[];for(let s=this;s;s=s.parent)t.push(s);return t}command(t,s,i){let n=s,r=i;typeof n=="object"&&n!==null&&(r=n,n=null),r=r||{};let[,o,a]=t.match(/([^ ]+) *(.*)/),l=this.createCommand(o);return n&&(l.description(n),l._executableHandler=!0),r.isDefault&&(this._defaultCommandName=l._name),l._hidden=!!(r.noHelp||r.hidden),l._executableFile=r.executableFile||null,a&&l.arguments(a),this._registerCommand(l),l.parent=this,l.copyInheritedSettings(this),n?this:l}createCommand(t){return new e(t)}createHelp(){return Object.assign(new Do,this.configureHelp())}configureHelp(t){return t===void 0?this._helpConfiguration:(this._helpConfiguration=t,this)}configureOutput(t){return t===void 0?this._outputConfiguration:(Object.assign(this._outputConfiguration,t),this)}showHelpAfterError(t=!0){return typeof t!="string"&&(t=!!t),this._showHelpAfterError=t,this}showSuggestionAfterError(t=!0){return this._showSuggestionAfterError=!!t,this}addCommand(t,s){if(!t._name)throw new Error(`Command passed to .addCommand() must have a name
15
+ - specify the name in Command constructor or using .name()`);return s=s||{},s.isDefault&&(this._defaultCommandName=t._name),(s.noHelp||s.hidden)&&(t._hidden=!0),this._registerCommand(t),t.parent=this,t._checkForBrokenPassThrough(),this}createArgument(t,s){return new To(t,s)}argument(t,s,i,n){let r=this.createArgument(t,s);return typeof i=="function"?r.default(n).argParser(i):r.default(i),this.addArgument(r),this}arguments(t){return t.trim().split(/ +/).forEach(s=>{this.argument(s)}),this}addArgument(t){let s=this.registeredArguments.slice(-1)[0];if(s&&s.variadic)throw new Error(`only the last argument can be variadic '${s.name()}'`);if(t.required&&t.defaultValue!==void 0&&t.parseArg===void 0)throw new Error(`a default value for a required argument is never used: '${t.name()}'`);return this.registeredArguments.push(t),this}helpCommand(t,s){if(typeof t=="boolean")return this._addImplicitHelpCommand=t,this;t=t??"help [command]";let[,i,n]=t.match(/([^ ]+) *(.*)/),r=s??"display help for command",o=this.createCommand(i);return o.helpOption(!1),n&&o.arguments(n),r&&o.description(r),this._addImplicitHelpCommand=!0,this._helpCommand=o,this}addHelpCommand(t,s){return typeof t!="object"?(this.helpCommand(t,s),this):(this._addImplicitHelpCommand=!0,this._helpCommand=t,this)}_getHelpCommand(){return this._addImplicitHelpCommand??(this.commands.length&&!this._actionHandler&&!this._findCommand("help"))?(this._helpCommand===void 0&&this.helpCommand(void 0,void 0),this._helpCommand):null}hook(t,s){let i=["preSubcommand","preAction","postAction"];if(!i.includes(t))throw new Error(`Unexpected value for event passed to hook : '${t}'.
16
+ Expecting one of '${i.join("', '")}'`);return this._lifeCycleHooks[t]?this._lifeCycleHooks[t].push(s):this._lifeCycleHooks[t]=[s],this}exitOverride(t){return t?this._exitCallback=t:this._exitCallback=s=>{if(s.code!=="commander.executeSubCommandAsync")throw s},this}_exit(t,s,i){this._exitCallback&&this._exitCallback(new ti(t,s,i)),se.exit(t)}action(t){let s=i=>{let n=this.registeredArguments.length,r=i.slice(0,n);return this._storeOptionsAsProperties?r[n]=this:r[n]=this.opts(),r.push(this),t.apply(this,r)};return this._actionHandler=s,this}createOption(t,s){return new mn(t,s)}_callParseArg(t,s,i,n){try{return t.parseArg(s,i)}catch(r){if(r.code==="commander.invalidArgument"){let o=`${n} ${r.message}`;this.error(o,{exitCode:r.exitCode,code:r.code})}throw r}}_registerOption(t){let s=t.short&&this._findOption(t.short)||t.long&&this._findOption(t.long);if(s){let i=t.long&&this._findOption(t.long)?t.long:t.short;throw new Error(`Cannot add option '${t.flags}'${this._name&&` to command '${this._name}'`} due to conflicting flag '${i}'
17
+ - already used by option '${s.flags}'`)}this.options.push(t)}_registerCommand(t){let s=n=>[n.name()].concat(n.aliases()),i=s(t).find(n=>this._findCommand(n));if(i){let n=s(this._findCommand(i)).join("|"),r=s(t).join("|");throw new Error(`cannot add command '${r}' as already have command '${n}'`)}this.commands.push(t)}addOption(t){this._registerOption(t);let s=t.name(),i=t.attributeName();if(t.negate){let r=t.long.replace(/^--no-/,"--");this._findOption(r)||this.setOptionValueWithSource(i,t.defaultValue===void 0?!0:t.defaultValue,"default")}else t.defaultValue!==void 0&&this.setOptionValueWithSource(i,t.defaultValue,"default");let n=(r,o,a)=>{r==null&&t.presetArg!==void 0&&(r=t.presetArg);let l=this.getOptionValue(i);r!==null&&t.parseArg?r=this._callParseArg(t,r,l,o):r!==null&&t.variadic&&(r=t._concatValue(r,l)),r==null&&(t.negate?r=!1:t.isBoolean()||t.optional?r=!0:r=""),this.setOptionValueWithSource(i,r,a)};return this.on("option:"+s,r=>{let o=`error: option '${t.flags}' argument '${r}' is invalid.`;n(r,o,"cli")}),t.envVar&&this.on("optionEnv:"+s,r=>{let o=`error: option '${t.flags}' value '${r}' from env '${t.envVar}' is invalid.`;n(r,o,"env")}),this}_optionEx(t,s,i,n,r){if(typeof s=="object"&&s instanceof mn)throw new Error("To add an Option object use addOption() instead of option() or requiredOption()");let o=this.createOption(s,i);if(o.makeOptionMandatory(!!t.mandatory),typeof n=="function")o.default(r).argParser(n);else if(n instanceof RegExp){let a=n;n=(l,d)=>{let u=a.exec(l);return u?u[0]:d},o.default(r).argParser(n)}else o.default(n);return this.addOption(o)}option(t,s,i,n){return this._optionEx({},t,s,i,n)}requiredOption(t,s,i,n){return this._optionEx({mandatory:!0},t,s,i,n)}combineFlagAndOptionalValue(t=!0){return this._combineFlagAndOptionalValue=!!t,this}allowUnknownOption(t=!0){return this._allowUnknownOption=!!t,this}allowExcessArguments(t=!0){return this._allowExcessArguments=!!t,this}enablePositionalOptions(t=!0){return this._enablePositionalOptions=!!t,this}passThroughOptions(t=!0){return this._passThroughOptions=!!t,this._checkForBrokenPassThrough(),this}_checkForBrokenPassThrough(){if(this.parent&&this._passThroughOptions&&!this.parent._enablePositionalOptions)throw new Error(`passThroughOptions cannot be used for '${this._name}' without turning on enablePositionalOptions for parent command(s)`)}storeOptionsAsProperties(t=!0){if(this.options.length)throw new Error("call .storeOptionsAsProperties() before adding options");if(Object.keys(this._optionValues).length)throw new Error("call .storeOptionsAsProperties() before setting option values");return this._storeOptionsAsProperties=!!t,this}getOptionValue(t){return this._storeOptionsAsProperties?this[t]:this._optionValues[t]}setOptionValue(t,s){return this.setOptionValueWithSource(t,s,void 0)}setOptionValueWithSource(t,s,i){return this._storeOptionsAsProperties?this[t]=s:this._optionValues[t]=s,this._optionValueSources[t]=i,this}getOptionValueSource(t){return this._optionValueSources[t]}getOptionValueSourceWithGlobals(t){let s;return this._getCommandAndAncestors().forEach(i=>{i.getOptionValueSource(t)!==void 0&&(s=i.getOptionValueSource(t))}),s}_prepareUserArgs(t,s){if(t!==void 0&&!Array.isArray(t))throw new Error("first parameter to parse must be array or undefined");if(s=s||{},t===void 0&&s.from===void 0){se.versions?.electron&&(s.from="electron");let n=se.execArgv??[];(n.includes("-e")||n.includes("--eval")||n.includes("-p")||n.includes("--print"))&&(s.from="eval")}t===void 0&&(t=se.argv),this.rawArgs=t.slice();let i;switch(s.from){case void 0:case"node":this._scriptPath=t[1],i=t.slice(2);break;case"electron":se.defaultApp?(this._scriptPath=t[1],i=t.slice(2)):i=t.slice(1);break;case"user":i=t.slice(0);break;case"eval":i=t.slice(1);break;default:throw new Error(`unexpected parse option { from: '${s.from}' }`)}return!this._name&&this._scriptPath&&this.nameFromFilename(this._scriptPath),this._name=this._name||"program",i}parse(t,s){this._prepareForParse();let i=this._prepareUserArgs(t,s);return this._parseCommand([],i),this}async parseAsync(t,s){this._prepareForParse();let i=this._prepareUserArgs(t,s);return await this._parseCommand([],i),this}_prepareForParse(){this._savedState===null?this.saveStateBeforeParse():this.restoreStateBeforeParse()}saveStateBeforeParse(){this._savedState={_name:this._name,_optionValues:{...this._optionValues},_optionValueSources:{...this._optionValueSources}}}restoreStateBeforeParse(){if(this._storeOptionsAsProperties)throw new Error(`Can not call parse again when storeOptionsAsProperties is true.
18
+ - either make a new Command for each call to parse, or stop storing options as properties`);this._name=this._savedState._name,this._scriptPath=null,this.rawArgs=[],this._optionValues={...this._savedState._optionValues},this._optionValueSources={...this._savedState._optionValueSources},this.args=[],this.processedArgs=[]}_checkForMissingExecutable(t,s,i){if(os.existsSync(t))return;let n=s?`searched for local subcommand relative to directory '${s}'`:"no directory for search for local subcommand, use .executableDir() to supply a custom directory",r=`'${t}' does not exist
19
+ - if '${i}' is not meant to be an executable command, remove description parameter from '.command()' and use '.description()' instead
20
20
  - if the default executable name is not suitable, use the executableFile option to supply a custom name or path
21
- - ${n}`;throw new Error(r)}_executeSubCommand(t,i){i=i.slice();let s=!1,n=[".js",".ts",".tsx",".mjs",".cjs"];function r(u,p){let g=nt.resolve(u,p);if(ri.existsSync(g))return g;if(n.includes(nt.extname(p)))return;let _=n.find(y=>ri.existsSync(`${g}${y}`));if(_)return`${g}${_}`}this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let o=t._executableFile||`${this._name}-${t._name}`,a=this._executableDir||"";if(this._scriptPath){let u;try{u=ri.realpathSync(this._scriptPath)}catch{u=this._scriptPath}a=nt.resolve(nt.dirname(u),a)}if(a){let u=r(a,o);if(!u&&!t._executableFile&&this._scriptPath){let p=nt.basename(this._scriptPath,nt.extname(this._scriptPath));p!==this._name&&(u=r(a,`${p}-${t._name}`))}o=u||o}s=n.includes(nt.extname(o));let l;ie.platform!=="win32"?s?(i.unshift(o),i=un(ie.execArgv).concat(i),l=es.spawn(ie.argv[0],i,{stdio:"inherit"})):l=es.spawn(o,i,{stdio:"inherit"}):(this._checkForMissingExecutable(o,a,t._name),i.unshift(o),i=un(ie.execArgv).concat(i),l=es.spawn(ie.execPath,i,{stdio:"inherit"})),l.killed||["SIGUSR1","SIGUSR2","SIGTERM","SIGINT","SIGHUP"].forEach(p=>{ie.on(p,()=>{l.killed===!1&&l.exitCode===null&&l.kill(p)})});let c=this._exitCallback;l.on("close",u=>{u=u??1,c?c(new ts(u,"commander.executeSubCommandAsync","(close)")):ie.exit(u)}),l.on("error",u=>{if(u.code==="ENOENT")this._checkForMissingExecutable(o,a,t._name);else if(u.code==="EACCES")throw new Error(`'${o}' not executable`);if(!c)ie.exit(1);else{let p=new ts(1,"commander.executeSubCommandAsync","(error)");p.nestedError=u,c(p)}}),this.runningCommand=l}_dispatchSubcommand(t,i,s){let n=this._findCommand(t);n||this.help({error:!0}),n._prepareForParse();let r;return r=this._chainOrCallSubCommandHook(r,n,"preSubcommand"),r=this._chainOrCall(r,()=>{if(n._executableHandler)this._executeSubCommand(n,i.concat(s));else return n._parseCommand(i,s)}),r}_dispatchHelpCommand(t){t||this.help();let i=this._findCommand(t);return i&&!i._executableHandler&&i.help(),this._dispatchSubcommand(t,[],[this._getHelpOption()?.long??this._getHelpOption()?.short??"--help"])}_checkNumberOfArguments(){this.registeredArguments.forEach((t,i)=>{t.required&&this.args[i]==null&&this.missingArgument(t.name())}),!(this.registeredArguments.length>0&&this.registeredArguments[this.registeredArguments.length-1].variadic)&&this.args.length>this.registeredArguments.length&&this._excessArguments(this.args)}_processArguments(){let t=(s,n,r)=>{let o=n;if(n!==null&&s.parseArg){let a=`error: command-argument value '${n}' is invalid for argument '${s.name()}'.`;o=this._callParseArg(s,n,r,a)}return o};this._checkNumberOfArguments();let i=[];this.registeredArguments.forEach((s,n)=>{let r=s.defaultValue;s.variadic?n<this.args.length?(r=this.args.slice(n),s.parseArg&&(r=r.reduce((o,a)=>t(s,a,o),s.defaultValue))):r===void 0&&(r=[]):n<this.args.length&&(r=this.args[n],s.parseArg&&(r=t(s,r,s.defaultValue))),i[n]=r}),this.processedArgs=i}_chainOrCall(t,i){return t&&t.then&&typeof t.then=="function"?t.then(()=>i()):i()}_chainOrCallHooks(t,i){let s=t,n=[];return this._getCommandAndAncestors().reverse().filter(r=>r._lifeCycleHooks[i]!==void 0).forEach(r=>{r._lifeCycleHooks[i].forEach(o=>{n.push({hookedCommand:r,callback:o})})}),i==="postAction"&&n.reverse(),n.forEach(r=>{s=this._chainOrCall(s,()=>r.callback(r.hookedCommand,this))}),s}_chainOrCallSubCommandHook(t,i,s){let n=t;return this._lifeCycleHooks[s]!==void 0&&this._lifeCycleHooks[s].forEach(r=>{n=this._chainOrCall(n,()=>r(this,i))}),n}_parseCommand(t,i){let s=this.parseOptions(i);if(this._parseOptionsEnv(),this._parseOptionsImplied(),t=t.concat(s.operands),i=s.unknown,this.args=t.concat(i),t&&this._findCommand(t[0]))return this._dispatchSubcommand(t[0],t.slice(1),i);if(this._getHelpCommand()&&t[0]===this._getHelpCommand().name())return this._dispatchHelpCommand(t[1]);if(this._defaultCommandName)return this._outputHelpIfRequested(i),this._dispatchSubcommand(this._defaultCommandName,t,i);this.commands.length&&this.args.length===0&&!this._actionHandler&&!this._defaultCommandName&&this.help({error:!0}),this._outputHelpIfRequested(s.unknown),this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let n=()=>{s.unknown.length>0&&this.unknownOption(s.unknown[0])},r=`command:${this.name()}`;if(this._actionHandler){n(),this._processArguments();let o;return o=this._chainOrCallHooks(o,"preAction"),o=this._chainOrCall(o,()=>this._actionHandler(this.processedArgs)),this.parent&&(o=this._chainOrCall(o,()=>{this.parent.emit(r,t,i)})),o=this._chainOrCallHooks(o,"postAction"),o}if(this.parent&&this.parent.listenerCount(r))n(),this._processArguments(),this.parent.emit(r,t,i);else if(t.length){if(this._findCommand("*"))return this._dispatchSubcommand("*",t,i);this.listenerCount("command:*")?this.emit("command:*",t,i):this.commands.length?this.unknownCommand():(n(),this._processArguments())}else this.commands.length?(n(),this.help({error:!0})):(n(),this._processArguments())}_findCommand(t){if(t)return this.commands.find(i=>i._name===t||i._aliases.includes(t))}_findOption(t){return this.options.find(i=>i.is(t))}_checkForMissingMandatoryOptions(){this._getCommandAndAncestors().forEach(t=>{t.options.forEach(i=>{i.mandatory&&t.getOptionValue(i.attributeName())===void 0&&t.missingMandatoryOptionValue(i)})})}_checkForConflictingLocalOptions(){let t=this.options.filter(s=>{let n=s.attributeName();return this.getOptionValue(n)===void 0?!1:this.getOptionValueSource(n)!=="default"});t.filter(s=>s.conflictsWith.length>0).forEach(s=>{let n=t.find(r=>s.conflictsWith.includes(r.attributeName()));n&&this._conflictingOption(s,n)})}_checkForConflictingOptions(){this._getCommandAndAncestors().forEach(t=>{t._checkForConflictingLocalOptions()})}parseOptions(t){let i=[],s=[],n=i,r=t.slice();function o(l){return l.length>1&&l[0]==="-"}let a=null;for(;r.length;){let l=r.shift();if(l==="--"){n===s&&n.push(l),n.push(...r);break}if(a&&!o(l)){this.emit(`option:${a.name()}`,l);continue}if(a=null,o(l)){let c=this._findOption(l);if(c){if(c.required){let u=r.shift();u===void 0&&this.optionMissingArgument(c),this.emit(`option:${c.name()}`,u)}else if(c.optional){let u=null;r.length>0&&!o(r[0])&&(u=r.shift()),this.emit(`option:${c.name()}`,u)}else this.emit(`option:${c.name()}`);a=c.variadic?c:null;continue}}if(l.length>2&&l[0]==="-"&&l[1]!=="-"){let c=this._findOption(`-${l[1]}`);if(c){c.required||c.optional&&this._combineFlagAndOptionalValue?this.emit(`option:${c.name()}`,l.slice(2)):(this.emit(`option:${c.name()}`),r.unshift(`-${l.slice(2)}`));continue}}if(/^--[^=]+=/.test(l)){let c=l.indexOf("="),u=this._findOption(l.slice(0,c));if(u&&(u.required||u.optional)){this.emit(`option:${u.name()}`,l.slice(c+1));continue}}if(o(l)&&(n=s),(this._enablePositionalOptions||this._passThroughOptions)&&i.length===0&&s.length===0){if(this._findCommand(l)){i.push(l),r.length>0&&s.push(...r);break}else if(this._getHelpCommand()&&l===this._getHelpCommand().name()){i.push(l),r.length>0&&i.push(...r);break}else if(this._defaultCommandName){s.push(l),r.length>0&&s.push(...r);break}}if(this._passThroughOptions){n.push(l),r.length>0&&n.push(...r);break}n.push(l)}return{operands:i,unknown:s}}opts(){if(this._storeOptionsAsProperties){let t={},i=this.options.length;for(let s=0;s<i;s++){let n=this.options[s].attributeName();t[n]=n===this._versionOptionName?this._version:this[n]}return t}return this._optionValues}optsWithGlobals(){return this._getCommandAndAncestors().reduce((t,i)=>Object.assign(t,i.opts()),{})}error(t,i){this._outputConfiguration.outputError(`${t}
21
+ - ${n}`;throw new Error(r)}_executeSubCommand(t,s){s=s.slice();let i=!1,n=[".js",".ts",".tsx",".mjs",".cjs"];function r(u,p){let g=nt.resolve(u,p);if(os.existsSync(g))return g;if(n.includes(nt.extname(p)))return;let x=n.find(y=>os.existsSync(`${g}${y}`));if(x)return`${g}${x}`}this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let o=t._executableFile||`${this._name}-${t._name}`,a=this._executableDir||"";if(this._scriptPath){let u;try{u=os.realpathSync(this._scriptPath)}catch{u=this._scriptPath}a=nt.resolve(nt.dirname(u),a)}if(a){let u=r(a,o);if(!u&&!t._executableFile&&this._scriptPath){let p=nt.basename(this._scriptPath,nt.extname(this._scriptPath));p!==this._name&&(u=r(a,`${p}-${t._name}`))}o=u||o}i=n.includes(nt.extname(o));let l;se.platform!=="win32"?i?(s.unshift(o),s=pn(se.execArgv).concat(s),l=ei.spawn(se.argv[0],s,{stdio:"inherit"})):l=ei.spawn(o,s,{stdio:"inherit"}):(this._checkForMissingExecutable(o,a,t._name),s.unshift(o),s=pn(se.execArgv).concat(s),l=ei.spawn(se.execPath,s,{stdio:"inherit"})),l.killed||["SIGUSR1","SIGUSR2","SIGTERM","SIGINT","SIGHUP"].forEach(p=>{se.on(p,()=>{l.killed===!1&&l.exitCode===null&&l.kill(p)})});let d=this._exitCallback;l.on("close",u=>{u=u??1,d?d(new ti(u,"commander.executeSubCommandAsync","(close)")):se.exit(u)}),l.on("error",u=>{if(u.code==="ENOENT")this._checkForMissingExecutable(o,a,t._name);else if(u.code==="EACCES")throw new Error(`'${o}' not executable`);if(!d)se.exit(1);else{let p=new ti(1,"commander.executeSubCommandAsync","(error)");p.nestedError=u,d(p)}}),this.runningCommand=l}_dispatchSubcommand(t,s,i){let n=this._findCommand(t);n||this.help({error:!0}),n._prepareForParse();let r;return r=this._chainOrCallSubCommandHook(r,n,"preSubcommand"),r=this._chainOrCall(r,()=>{if(n._executableHandler)this._executeSubCommand(n,s.concat(i));else return n._parseCommand(s,i)}),r}_dispatchHelpCommand(t){t||this.help();let s=this._findCommand(t);return s&&!s._executableHandler&&s.help(),this._dispatchSubcommand(t,[],[this._getHelpOption()?.long??this._getHelpOption()?.short??"--help"])}_checkNumberOfArguments(){this.registeredArguments.forEach((t,s)=>{t.required&&this.args[s]==null&&this.missingArgument(t.name())}),!(this.registeredArguments.length>0&&this.registeredArguments[this.registeredArguments.length-1].variadic)&&this.args.length>this.registeredArguments.length&&this._excessArguments(this.args)}_processArguments(){let t=(i,n,r)=>{let o=n;if(n!==null&&i.parseArg){let a=`error: command-argument value '${n}' is invalid for argument '${i.name()}'.`;o=this._callParseArg(i,n,r,a)}return o};this._checkNumberOfArguments();let s=[];this.registeredArguments.forEach((i,n)=>{let r=i.defaultValue;i.variadic?n<this.args.length?(r=this.args.slice(n),i.parseArg&&(r=r.reduce((o,a)=>t(i,a,o),i.defaultValue))):r===void 0&&(r=[]):n<this.args.length&&(r=this.args[n],i.parseArg&&(r=t(i,r,i.defaultValue))),s[n]=r}),this.processedArgs=s}_chainOrCall(t,s){return t&&t.then&&typeof t.then=="function"?t.then(()=>s()):s()}_chainOrCallHooks(t,s){let i=t,n=[];return this._getCommandAndAncestors().reverse().filter(r=>r._lifeCycleHooks[s]!==void 0).forEach(r=>{r._lifeCycleHooks[s].forEach(o=>{n.push({hookedCommand:r,callback:o})})}),s==="postAction"&&n.reverse(),n.forEach(r=>{i=this._chainOrCall(i,()=>r.callback(r.hookedCommand,this))}),i}_chainOrCallSubCommandHook(t,s,i){let n=t;return this._lifeCycleHooks[i]!==void 0&&this._lifeCycleHooks[i].forEach(r=>{n=this._chainOrCall(n,()=>r(this,s))}),n}_parseCommand(t,s){let i=this.parseOptions(s);if(this._parseOptionsEnv(),this._parseOptionsImplied(),t=t.concat(i.operands),s=i.unknown,this.args=t.concat(s),t&&this._findCommand(t[0]))return this._dispatchSubcommand(t[0],t.slice(1),s);if(this._getHelpCommand()&&t[0]===this._getHelpCommand().name())return this._dispatchHelpCommand(t[1]);if(this._defaultCommandName)return this._outputHelpIfRequested(s),this._dispatchSubcommand(this._defaultCommandName,t,s);this.commands.length&&this.args.length===0&&!this._actionHandler&&!this._defaultCommandName&&this.help({error:!0}),this._outputHelpIfRequested(i.unknown),this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let n=()=>{i.unknown.length>0&&this.unknownOption(i.unknown[0])},r=`command:${this.name()}`;if(this._actionHandler){n(),this._processArguments();let o;return o=this._chainOrCallHooks(o,"preAction"),o=this._chainOrCall(o,()=>this._actionHandler(this.processedArgs)),this.parent&&(o=this._chainOrCall(o,()=>{this.parent.emit(r,t,s)})),o=this._chainOrCallHooks(o,"postAction"),o}if(this.parent&&this.parent.listenerCount(r))n(),this._processArguments(),this.parent.emit(r,t,s);else if(t.length){if(this._findCommand("*"))return this._dispatchSubcommand("*",t,s);this.listenerCount("command:*")?this.emit("command:*",t,s):this.commands.length?this.unknownCommand():(n(),this._processArguments())}else this.commands.length?(n(),this.help({error:!0})):(n(),this._processArguments())}_findCommand(t){if(t)return this.commands.find(s=>s._name===t||s._aliases.includes(t))}_findOption(t){return this.options.find(s=>s.is(t))}_checkForMissingMandatoryOptions(){this._getCommandAndAncestors().forEach(t=>{t.options.forEach(s=>{s.mandatory&&t.getOptionValue(s.attributeName())===void 0&&t.missingMandatoryOptionValue(s)})})}_checkForConflictingLocalOptions(){let t=this.options.filter(i=>{let n=i.attributeName();return this.getOptionValue(n)===void 0?!1:this.getOptionValueSource(n)!=="default"});t.filter(i=>i.conflictsWith.length>0).forEach(i=>{let n=t.find(r=>i.conflictsWith.includes(r.attributeName()));n&&this._conflictingOption(i,n)})}_checkForConflictingOptions(){this._getCommandAndAncestors().forEach(t=>{t._checkForConflictingLocalOptions()})}parseOptions(t){let s=[],i=[],n=s,r=t.slice();function o(l){return l.length>1&&l[0]==="-"}let a=null;for(;r.length;){let l=r.shift();if(l==="--"){n===i&&n.push(l),n.push(...r);break}if(a&&!o(l)){this.emit(`option:${a.name()}`,l);continue}if(a=null,o(l)){let d=this._findOption(l);if(d){if(d.required){let u=r.shift();u===void 0&&this.optionMissingArgument(d),this.emit(`option:${d.name()}`,u)}else if(d.optional){let u=null;r.length>0&&!o(r[0])&&(u=r.shift()),this.emit(`option:${d.name()}`,u)}else this.emit(`option:${d.name()}`);a=d.variadic?d:null;continue}}if(l.length>2&&l[0]==="-"&&l[1]!=="-"){let d=this._findOption(`-${l[1]}`);if(d){d.required||d.optional&&this._combineFlagAndOptionalValue?this.emit(`option:${d.name()}`,l.slice(2)):(this.emit(`option:${d.name()}`),r.unshift(`-${l.slice(2)}`));continue}}if(/^--[^=]+=/.test(l)){let d=l.indexOf("="),u=this._findOption(l.slice(0,d));if(u&&(u.required||u.optional)){this.emit(`option:${u.name()}`,l.slice(d+1));continue}}if(o(l)&&(n=i),(this._enablePositionalOptions||this._passThroughOptions)&&s.length===0&&i.length===0){if(this._findCommand(l)){s.push(l),r.length>0&&i.push(...r);break}else if(this._getHelpCommand()&&l===this._getHelpCommand().name()){s.push(l),r.length>0&&s.push(...r);break}else if(this._defaultCommandName){i.push(l),r.length>0&&i.push(...r);break}}if(this._passThroughOptions){n.push(l),r.length>0&&n.push(...r);break}n.push(l)}return{operands:s,unknown:i}}opts(){if(this._storeOptionsAsProperties){let t={},s=this.options.length;for(let i=0;i<s;i++){let n=this.options[i].attributeName();t[n]=n===this._versionOptionName?this._version:this[n]}return t}return this._optionValues}optsWithGlobals(){return this._getCommandAndAncestors().reduce((t,s)=>Object.assign(t,s.opts()),{})}error(t,s){this._outputConfiguration.outputError(`${t}
22
22
  `,this._outputConfiguration.writeErr),typeof this._showHelpAfterError=="string"?this._outputConfiguration.writeErr(`${this._showHelpAfterError}
23
23
  `):this._showHelpAfterError&&(this._outputConfiguration.writeErr(`
24
- `),this.outputHelp({error:!0}));let s=i||{},n=s.exitCode||1,r=s.code||"commander.error";this._exit(n,r,t)}_parseOptionsEnv(){this.options.forEach(t=>{if(t.envVar&&t.envVar in ie.env){let i=t.attributeName();(this.getOptionValue(i)===void 0||["default","config","env"].includes(this.getOptionValueSource(i)))&&(t.required||t.optional?this.emit(`optionEnv:${t.name()}`,ie.env[t.envVar]):this.emit(`optionEnv:${t.name()}`))}})}_parseOptionsImplied(){let t=new Do(this.options),i=s=>this.getOptionValue(s)!==void 0&&!["default","implied"].includes(this.getOptionValueSource(s));this.options.filter(s=>s.implied!==void 0&&i(s.attributeName())&&t.valueFromOption(this.getOptionValue(s.attributeName()),s)).forEach(s=>{Object.keys(s.implied).filter(n=>!i(n)).forEach(n=>{this.setOptionValueWithSource(n,s.implied[n],"implied")})})}missingArgument(t){let i=`error: missing required argument '${t}'`;this.error(i,{code:"commander.missingArgument"})}optionMissingArgument(t){let i=`error: option '${t.flags}' argument missing`;this.error(i,{code:"commander.optionMissingArgument"})}missingMandatoryOptionValue(t){let i=`error: required option '${t.flags}' not specified`;this.error(i,{code:"commander.missingMandatoryOptionValue"})}_conflictingOption(t,i){let s=o=>{let a=o.attributeName(),l=this.getOptionValue(a),c=this.options.find(p=>p.negate&&a===p.attributeName()),u=this.options.find(p=>!p.negate&&a===p.attributeName());return c&&(c.presetArg===void 0&&l===!1||c.presetArg!==void 0&&l===c.presetArg)?c:u||o},n=o=>{let a=s(o),l=a.attributeName();return this.getOptionValueSource(l)==="env"?`environment variable '${a.envVar}'`:`option '${a.flags}'`},r=`error: ${n(t)} cannot be used with ${n(i)}`;this.error(r,{code:"commander.conflictingOption"})}unknownOption(t){if(this._allowUnknownOption)return;let i="";if(t.startsWith("--")&&this._showSuggestionAfterError){let n=[],r=this;do{let o=r.createHelp().visibleOptions(r).filter(a=>a.long).map(a=>a.long);n=n.concat(o),r=r.parent}while(r&&!r._enablePositionalOptions);i=dn(t,n)}let s=`error: unknown option '${t}'${i}`;this.error(s,{code:"commander.unknownOption"})}_excessArguments(t){if(this._allowExcessArguments)return;let i=this.registeredArguments.length,s=i===1?"":"s",r=`error: too many arguments${this.parent?` for '${this.name()}'`:""}. Expected ${i} argument${s} but got ${t.length}.`;this.error(r,{code:"commander.excessArguments"})}unknownCommand(){let t=this.args[0],i="";if(this._showSuggestionAfterError){let n=[];this.createHelp().visibleCommands(this).forEach(r=>{n.push(r.name()),r.alias()&&n.push(r.alias())}),i=dn(t,n)}let s=`error: unknown command '${t}'${i}`;this.error(s,{code:"commander.unknownCommand"})}version(t,i,s){if(t===void 0)return this._version;this._version=t,i=i||"-V, --version",s=s||"output the version number";let n=this.createOption(i,s);return this._versionOptionName=n.attributeName(),this._registerOption(n),this.on("option:"+n.name(),()=>{this._outputConfiguration.writeOut(`${t}
25
- `),this._exit(0,"commander.version",t)}),this}description(t,i){return t===void 0&&i===void 0?this._description:(this._description=t,i&&(this._argsDescription=i),this)}summary(t){return t===void 0?this._summary:(this._summary=t,this)}alias(t){if(t===void 0)return this._aliases[0];let i=this;if(this.commands.length!==0&&this.commands[this.commands.length-1]._executableHandler&&(i=this.commands[this.commands.length-1]),t===i._name)throw new Error("Command alias can't be the same as its name");let s=this.parent?._findCommand(t);if(s){let n=[s.name()].concat(s.aliases()).join("|");throw new Error(`cannot add alias '${t}' to command '${this.name()}' as already have command '${n}'`)}return i._aliases.push(t),this}aliases(t){return t===void 0?this._aliases:(t.forEach(i=>this.alias(i)),this)}usage(t){if(t===void 0){if(this._usage)return this._usage;let i=this.registeredArguments.map(s=>Io(s));return[].concat(this.options.length||this._helpOption!==null?"[options]":[],this.commands.length?"[command]":[],this.registeredArguments.length?i:[]).join(" ")}return this._usage=t,this}name(t){return t===void 0?this._name:(this._name=t,this)}nameFromFilename(t){return this._name=nt.basename(t,nt.extname(t)),this}executableDir(t){return t===void 0?this._executableDir:(this._executableDir=t,this)}helpInformation(t){let i=this.createHelp(),s=this._getOutputContext(t);i.prepareContext({error:s.error,helpWidth:s.helpWidth,outputHasColors:s.hasColors});let n=i.formatHelp(this,i);return s.hasColors?n:this._outputConfiguration.stripColor(n)}_getOutputContext(t){t=t||{};let i=!!t.error,s,n,r;return i?(s=a=>this._outputConfiguration.writeErr(a),n=this._outputConfiguration.getErrHasColors(),r=this._outputConfiguration.getErrHelpWidth()):(s=a=>this._outputConfiguration.writeOut(a),n=this._outputConfiguration.getOutHasColors(),r=this._outputConfiguration.getOutHelpWidth()),{error:i,write:a=>(n||(a=this._outputConfiguration.stripColor(a)),s(a)),hasColors:n,helpWidth:r}}outputHelp(t){let i;typeof t=="function"&&(i=t,t=void 0);let s=this._getOutputContext(t),n={error:s.error,write:s.write,command:this};this._getCommandAndAncestors().reverse().forEach(o=>o.emit("beforeAllHelp",n)),this.emit("beforeHelp",n);let r=this.helpInformation({error:s.error});if(i&&(r=i(r),typeof r!="string"&&!Buffer.isBuffer(r)))throw new Error("outputHelp callback must return a string or a Buffer");s.write(r),this._getHelpOption()?.long&&this.emit(this._getHelpOption().long),this.emit("afterHelp",n),this._getCommandAndAncestors().forEach(o=>o.emit("afterAllHelp",n))}helpOption(t,i){return typeof t=="boolean"?(t?this._helpOption=this._helpOption??void 0:this._helpOption=null,this):(t=t??"-h, --help",i=i??"display help for command",this._helpOption=this.createOption(t,i),this)}_getHelpOption(){return this._helpOption===void 0&&this.helpOption(void 0,void 0),this._helpOption}addHelpOption(t){return this._helpOption=t,this}help(t){this.outputHelp(t);let i=Number(ie.exitCode??0);i===0&&t&&typeof t!="function"&&t.error&&(i=1),this._exit(i,"commander.help","(outputHelp)")}addHelpText(t,i){let s=["beforeAll","before","after","afterAll"];if(!s.includes(t))throw new Error(`Unexpected value for position to addHelpText.
26
- Expecting one of '${s.join("', '")}'`);let n=`${t}Help`;return this.on(n,r=>{let o;typeof i=="function"?o=i({error:r.error,command:r.command}):o=i,o&&r.write(`${o}
27
- `)}),this}_outputHelpIfRequested(t){let i=this._getHelpOption();i&&t.find(n=>i.is(n))&&(this.outputHelp(),this._exit(0,"commander.helpDisplayed","(outputHelp)"))}};function un(e){return e.map(t=>{if(!t.startsWith("--inspect"))return t;let i,s="127.0.0.1",n="9229",r;return(r=t.match(/^(--inspect(-brk)?)$/))!==null?i=r[1]:(r=t.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))!==null?(i=r[1],/^\d+$/.test(r[3])?n=r[3]:s=r[3]):(r=t.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null&&(i=r[1],s=r[3],n=r[4]),i&&n!=="0"?`${i}=${s}:${parseInt(n)+1}`:t})}function ss(){if(ie.env.NO_COLOR||ie.env.FORCE_COLOR==="0"||ie.env.FORCE_COLOR==="false")return!1;if(ie.env.FORCE_COLOR||ie.env.CLICOLOR_FORCE!==void 0)return!0}ns.Command=is;ns.useColor=ss});var gn=st(qe=>{var{Argument:fn}=ni(),{Command:rs}=mn(),{CommanderError:No,InvalidArgumentError:pn}=Wt(),{Help:Fo}=Ki(),{Option:hn}=Qi();qe.program=new rs;qe.createCommand=e=>new rs(e);qe.createOption=(e,t)=>new hn(e,t);qe.createArgument=(e,t)=>new fn(e,t);qe.Command=rs;qe.Option=hn;qe.Argument=fn;qe.Help=Fo;qe.CommanderError=No;qe.InvalidArgumentError=pn;qe.InvalidOptionArgumentError=pn});var H=st((Sc,os)=>{var ai=process||{},bn=ai.argv||[],oi=ai.env||{},Lo=!(oi.NO_COLOR||bn.includes("--no-color"))&&(!!oi.FORCE_COLOR||bn.includes("--color")||ai.platform==="win32"||(ai.stdout||{}).isTTY&&oi.TERM!=="dumb"||!!oi.CI),Vo=(e,t,i=e)=>s=>{let n=""+s,r=n.indexOf(t,e.length);return~r?e+Uo(n,t,i,r)+t:e+n+t},Uo=(e,t,i,s)=>{let n="",r=0;do n+=e.substring(r,s)+i,r=s+t.length,s=e.indexOf(t,r);while(~s);return n+e.substring(r)},vn=(e=Lo)=>{let t=e?Vo:()=>String;return{isColorSupported:e,reset:t("\x1B[0m","\x1B[0m"),bold:t("\x1B[1m","\x1B[22m","\x1B[22m\x1B[1m"),dim:t("\x1B[2m","\x1B[22m","\x1B[22m\x1B[2m"),italic:t("\x1B[3m","\x1B[23m"),underline:t("\x1B[4m","\x1B[24m"),inverse:t("\x1B[7m","\x1B[27m"),hidden:t("\x1B[8m","\x1B[28m"),strikethrough:t("\x1B[9m","\x1B[29m"),black:t("\x1B[30m","\x1B[39m"),red:t("\x1B[31m","\x1B[39m"),green:t("\x1B[32m","\x1B[39m"),yellow:t("\x1B[33m","\x1B[39m"),blue:t("\x1B[34m","\x1B[39m"),magenta:t("\x1B[35m","\x1B[39m"),cyan:t("\x1B[36m","\x1B[39m"),white:t("\x1B[37m","\x1B[39m"),gray:t("\x1B[90m","\x1B[39m"),bgBlack:t("\x1B[40m","\x1B[49m"),bgRed:t("\x1B[41m","\x1B[49m"),bgGreen:t("\x1B[42m","\x1B[49m"),bgYellow:t("\x1B[43m","\x1B[49m"),bgBlue:t("\x1B[44m","\x1B[49m"),bgMagenta:t("\x1B[45m","\x1B[49m"),bgCyan:t("\x1B[46m","\x1B[49m"),bgWhite:t("\x1B[47m","\x1B[49m"),blackBright:t("\x1B[90m","\x1B[39m"),redBright:t("\x1B[91m","\x1B[39m"),greenBright:t("\x1B[92m","\x1B[39m"),yellowBright:t("\x1B[93m","\x1B[39m"),blueBright:t("\x1B[94m","\x1B[39m"),magentaBright:t("\x1B[95m","\x1B[39m"),cyanBright:t("\x1B[96m","\x1B[39m"),whiteBright:t("\x1B[97m","\x1B[39m"),bgBlackBright:t("\x1B[100m","\x1B[49m"),bgRedBright:t("\x1B[101m","\x1B[49m"),bgGreenBright:t("\x1B[102m","\x1B[49m"),bgYellowBright:t("\x1B[103m","\x1B[49m"),bgBlueBright:t("\x1B[104m","\x1B[49m"),bgMagentaBright:t("\x1B[105m","\x1B[49m"),bgCyanBright:t("\x1B[106m","\x1B[49m"),bgWhiteBright:t("\x1B[107m","\x1B[49m")}};os.exports=vn();os.exports.createColors=vn});var Et,li,Ht=Pe(()=>{"use strict";Et="domani.run",li=`https://${Et}`});function xn(e){_n=e}function rt(){try{let e=ft.default.readFileSync(as,"utf-8");return JSON.parse(e)}catch{return{}}}function It(e){ft.default.mkdirSync(ui,{recursive:!0,mode:448}),ft.default.writeFileSync(as,JSON.stringify(e,null,2),{mode:384})}function jn(){try{ft.default.unlinkSync(as)}catch{}}function ze(){return _n||rt().api_url||li}function bt(){return process.env.DOMANI_API_KEY||rt().token}function qo(){try{let e=ft.default.readFileSync(kn,"utf-8");return JSON.parse(e)}catch{return null}}function Wo(e){try{ft.default.mkdirSync(ui,{recursive:!0,mode:448}),ft.default.writeFileSync(kn,JSON.stringify(e),{mode:384})}catch{}}function ci(e,t){let i=e.split(".").map(Number),s=t.split(".").map(Number);for(let n=0;n<3;n++){if((i[n]||0)>(s[n]||0))return 1;if((i[n]||0)<(s[n]||0))return-1}return 0}async function Cn(){let e=qo();if(e&&Date.now()-e.checkedAt<Mo)return ci(e.version,_e)>0?{update:e.version,forced:ci(_e,e.min)<0}:null;try{let t=ze(),i=await fetch(`${t}/api/cli/version`,{signal:AbortSignal.timeout(3e3)});if(!i.ok)return null;let s=await i.json();if(Wo({version:s.version,min:s.min,checkedAt:Date.now()}),ci(s.version,_e)>0)return{update:s.version,forced:ci(_e,s.min)<0}}catch{}return null}var ft,di,wn,ui,as,_n,kn,Mo,Sn,_e,pt=Pe(()=>{"use strict";ft=F(require("fs"),1),di=F(require("path"),1),wn=F(require("os"),1);Ht();ui=process.env.DOMANI_CONFIG_DIR||di.default.join(wn.default.homedir(),".domani"),as=di.default.join(ui,"config.json");kn=di.default.join(ui,"version-check.json"),Mo=1440*60*1e3;Sn=process.stdout.isTTY??!1,_e="0.3.12"});var cs=st((Rc,On)=>{"use strict";var ls={to(e,t){return t?`\x1B[${t+1};${e+1}H`:`\x1B[${e+1}G`},move(e,t){let i="";return e<0?i+=`\x1B[${-e}D`:e>0&&(i+=`\x1B[${e}C`),t<0?i+=`\x1B[${-t}A`:t>0&&(i+=`\x1B[${t}B`),i},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"},Ho={up:(e=1)=>"\x1B[S".repeat(e),down:(e=1)=>"\x1B[T".repeat(e)},Jo={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 i=0;i<e;i++)t+=this.line+(i<e-1?ls.up():"");return e&&(t+=ls.left),t}};On.exports={cursor:ls,scroll:Ho,erase:Jo,beep:"\x07"}});function ot(e,t,i){if(!i.some(o=>!o.disabled))return e;let s=e+t,n=Math.max(i.length-1,0),r=s<0?n:s>n?0:s;return i[r].disabled?ot(r,t<0?-1:1,i):r}function ps(e,t,i){return String(e).normalize().replaceAll(`\r
24
+ `),this.outputHelp({error:!0}));let i=s||{},n=i.exitCode||1,r=i.code||"commander.error";this._exit(n,r,t)}_parseOptionsEnv(){this.options.forEach(t=>{if(t.envVar&&t.envVar in se.env){let s=t.attributeName();(this.getOptionValue(s)===void 0||["default","config","env"].includes(this.getOptionValueSource(s)))&&(t.required||t.optional?this.emit(`optionEnv:${t.name()}`,se.env[t.envVar]):this.emit(`optionEnv:${t.name()}`))}})}_parseOptionsImplied(){let t=new Fo(this.options),s=i=>this.getOptionValue(i)!==void 0&&!["default","implied"].includes(this.getOptionValueSource(i));this.options.filter(i=>i.implied!==void 0&&s(i.attributeName())&&t.valueFromOption(this.getOptionValue(i.attributeName()),i)).forEach(i=>{Object.keys(i.implied).filter(n=>!s(n)).forEach(n=>{this.setOptionValueWithSource(n,i.implied[n],"implied")})})}missingArgument(t){let s=`error: missing required argument '${t}'`;this.error(s,{code:"commander.missingArgument"})}optionMissingArgument(t){let s=`error: option '${t.flags}' argument missing`;this.error(s,{code:"commander.optionMissingArgument"})}missingMandatoryOptionValue(t){let s=`error: required option '${t.flags}' not specified`;this.error(s,{code:"commander.missingMandatoryOptionValue"})}_conflictingOption(t,s){let i=o=>{let a=o.attributeName(),l=this.getOptionValue(a),d=this.options.find(p=>p.negate&&a===p.attributeName()),u=this.options.find(p=>!p.negate&&a===p.attributeName());return d&&(d.presetArg===void 0&&l===!1||d.presetArg!==void 0&&l===d.presetArg)?d:u||o},n=o=>{let a=i(o),l=a.attributeName();return this.getOptionValueSource(l)==="env"?`environment variable '${a.envVar}'`:`option '${a.flags}'`},r=`error: ${n(t)} cannot be used with ${n(s)}`;this.error(r,{code:"commander.conflictingOption"})}unknownOption(t){if(this._allowUnknownOption)return;let s="";if(t.startsWith("--")&&this._showSuggestionAfterError){let n=[],r=this;do{let o=r.createHelp().visibleOptions(r).filter(a=>a.long).map(a=>a.long);n=n.concat(o),r=r.parent}while(r&&!r._enablePositionalOptions);s=fn(t,n)}let i=`error: unknown option '${t}'${s}`;this.error(i,{code:"commander.unknownOption"})}_excessArguments(t){if(this._allowExcessArguments)return;let s=this.registeredArguments.length,i=s===1?"":"s",r=`error: too many arguments${this.parent?` for '${this.name()}'`:""}. Expected ${s} argument${i} but got ${t.length}.`;this.error(r,{code:"commander.excessArguments"})}unknownCommand(){let t=this.args[0],s="";if(this._showSuggestionAfterError){let n=[];this.createHelp().visibleCommands(this).forEach(r=>{n.push(r.name()),r.alias()&&n.push(r.alias())}),s=fn(t,n)}let i=`error: unknown command '${t}'${s}`;this.error(i,{code:"commander.unknownCommand"})}version(t,s,i){if(t===void 0)return this._version;this._version=t,s=s||"-V, --version",i=i||"output the version number";let n=this.createOption(s,i);return this._versionOptionName=n.attributeName(),this._registerOption(n),this.on("option:"+n.name(),()=>{this._outputConfiguration.writeOut(`${t}
25
+ `),this._exit(0,"commander.version",t)}),this}description(t,s){return t===void 0&&s===void 0?this._description:(this._description=t,s&&(this._argsDescription=s),this)}summary(t){return t===void 0?this._summary:(this._summary=t,this)}alias(t){if(t===void 0)return this._aliases[0];let s=this;if(this.commands.length!==0&&this.commands[this.commands.length-1]._executableHandler&&(s=this.commands[this.commands.length-1]),t===s._name)throw new Error("Command alias can't be the same as its name");let i=this.parent?._findCommand(t);if(i){let n=[i.name()].concat(i.aliases()).join("|");throw new Error(`cannot add alias '${t}' to command '${this.name()}' as already have command '${n}'`)}return s._aliases.push(t),this}aliases(t){return t===void 0?this._aliases:(t.forEach(s=>this.alias(s)),this)}usage(t){if(t===void 0){if(this._usage)return this._usage;let s=this.registeredArguments.map(i=>Po(i));return[].concat(this.options.length||this._helpOption!==null?"[options]":[],this.commands.length?"[command]":[],this.registeredArguments.length?s:[]).join(" ")}return this._usage=t,this}name(t){return t===void 0?this._name:(this._name=t,this)}nameFromFilename(t){return this._name=nt.basename(t,nt.extname(t)),this}executableDir(t){return t===void 0?this._executableDir:(this._executableDir=t,this)}helpInformation(t){let s=this.createHelp(),i=this._getOutputContext(t);s.prepareContext({error:i.error,helpWidth:i.helpWidth,outputHasColors:i.hasColors});let n=s.formatHelp(this,s);return i.hasColors?n:this._outputConfiguration.stripColor(n)}_getOutputContext(t){t=t||{};let s=!!t.error,i,n,r;return s?(i=a=>this._outputConfiguration.writeErr(a),n=this._outputConfiguration.getErrHasColors(),r=this._outputConfiguration.getErrHelpWidth()):(i=a=>this._outputConfiguration.writeOut(a),n=this._outputConfiguration.getOutHasColors(),r=this._outputConfiguration.getOutHelpWidth()),{error:s,write:a=>(n||(a=this._outputConfiguration.stripColor(a)),i(a)),hasColors:n,helpWidth:r}}outputHelp(t){let s;typeof t=="function"&&(s=t,t=void 0);let i=this._getOutputContext(t),n={error:i.error,write:i.write,command:this};this._getCommandAndAncestors().reverse().forEach(o=>o.emit("beforeAllHelp",n)),this.emit("beforeHelp",n);let r=this.helpInformation({error:i.error});if(s&&(r=s(r),typeof r!="string"&&!Buffer.isBuffer(r)))throw new Error("outputHelp callback must return a string or a Buffer");i.write(r),this._getHelpOption()?.long&&this.emit(this._getHelpOption().long),this.emit("afterHelp",n),this._getCommandAndAncestors().forEach(o=>o.emit("afterAllHelp",n))}helpOption(t,s){return typeof t=="boolean"?(t?this._helpOption=this._helpOption??void 0:this._helpOption=null,this):(t=t??"-h, --help",s=s??"display help for command",this._helpOption=this.createOption(t,s),this)}_getHelpOption(){return this._helpOption===void 0&&this.helpOption(void 0,void 0),this._helpOption}addHelpOption(t){return this._helpOption=t,this}help(t){this.outputHelp(t);let s=Number(se.exitCode??0);s===0&&t&&typeof t!="function"&&t.error&&(s=1),this._exit(s,"commander.help","(outputHelp)")}addHelpText(t,s){let i=["beforeAll","before","after","afterAll"];if(!i.includes(t))throw new Error(`Unexpected value for position to addHelpText.
26
+ Expecting one of '${i.join("', '")}'`);let n=`${t}Help`;return this.on(n,r=>{let o;typeof s=="function"?o=s({error:r.error,command:r.command}):o=s,o&&r.write(`${o}
27
+ `)}),this}_outputHelpIfRequested(t){let s=this._getHelpOption();s&&t.find(n=>s.is(n))&&(this.outputHelp(),this._exit(0,"commander.helpDisplayed","(outputHelp)"))}};function pn(e){return e.map(t=>{if(!t.startsWith("--inspect"))return t;let s,i="127.0.0.1",n="9229",r;return(r=t.match(/^(--inspect(-brk)?)$/))!==null?s=r[1]:(r=t.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))!==null?(s=r[1],/^\d+$/.test(r[3])?n=r[3]:i=r[3]):(r=t.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null&&(s=r[1],i=r[3],n=r[4]),s&&n!=="0"?`${s}=${i}:${parseInt(n)+1}`:t})}function ii(){if(se.env.NO_COLOR||se.env.FORCE_COLOR==="0"||se.env.FORCE_COLOR==="false")return!1;if(se.env.FORCE_COLOR||se.env.CLICOLOR_FORCE!==void 0)return!0}ni.Command=si;ni.useColor=ii});var bn=it(We=>{var{Argument:gn}=rs(),{Command:ri}=hn(),{CommanderError:Lo,InvalidArgumentError:$n}=Wt(),{Help:Uo}=Ks(),{Option:yn}=Qs();We.program=new ri;We.createCommand=e=>new ri(e);We.createOption=(e,t)=>new yn(e,t);We.createArgument=(e,t)=>new gn(e,t);We.Command=ri;We.Option=yn;We.Argument=gn;We.Help=Uo;We.CommanderError=Lo;We.InvalidArgumentError=$n;We.InvalidOptionArgumentError=$n});var J=it((Oc,oi)=>{var ls=process||{},_n=ls.argv||[],as=ls.env||{},Vo=!(as.NO_COLOR||_n.includes("--no-color"))&&(!!as.FORCE_COLOR||_n.includes("--color")||ls.platform==="win32"||(ls.stdout||{}).isTTY&&as.TERM!=="dumb"||!!as.CI),Mo=(e,t,s=e)=>i=>{let n=""+i,r=n.indexOf(t,e.length);return~r?e+qo(n,t,s,r)+t:e+n+t},qo=(e,t,s,i)=>{let n="",r=0;do n+=e.substring(r,i)+s,r=i+t.length,i=e.indexOf(t,r);while(~i);return n+e.substring(r)},xn=(e=Vo)=>{let t=e?Mo:()=>String;return{isColorSupported:e,reset:t("\x1B[0m","\x1B[0m"),bold:t("\x1B[1m","\x1B[22m","\x1B[22m\x1B[1m"),dim:t("\x1B[2m","\x1B[22m","\x1B[22m\x1B[2m"),italic:t("\x1B[3m","\x1B[23m"),underline:t("\x1B[4m","\x1B[24m"),inverse:t("\x1B[7m","\x1B[27m"),hidden:t("\x1B[8m","\x1B[28m"),strikethrough:t("\x1B[9m","\x1B[29m"),black:t("\x1B[30m","\x1B[39m"),red:t("\x1B[31m","\x1B[39m"),green:t("\x1B[32m","\x1B[39m"),yellow:t("\x1B[33m","\x1B[39m"),blue:t("\x1B[34m","\x1B[39m"),magenta:t("\x1B[35m","\x1B[39m"),cyan:t("\x1B[36m","\x1B[39m"),white:t("\x1B[37m","\x1B[39m"),gray:t("\x1B[90m","\x1B[39m"),bgBlack:t("\x1B[40m","\x1B[49m"),bgRed:t("\x1B[41m","\x1B[49m"),bgGreen:t("\x1B[42m","\x1B[49m"),bgYellow:t("\x1B[43m","\x1B[49m"),bgBlue:t("\x1B[44m","\x1B[49m"),bgMagenta:t("\x1B[45m","\x1B[49m"),bgCyan:t("\x1B[46m","\x1B[49m"),bgWhite:t("\x1B[47m","\x1B[49m"),blackBright:t("\x1B[90m","\x1B[39m"),redBright:t("\x1B[91m","\x1B[39m"),greenBright:t("\x1B[92m","\x1B[39m"),yellowBright:t("\x1B[93m","\x1B[39m"),blueBright:t("\x1B[94m","\x1B[39m"),magentaBright:t("\x1B[95m","\x1B[39m"),cyanBright:t("\x1B[96m","\x1B[39m"),whiteBright:t("\x1B[97m","\x1B[39m"),bgBlackBright:t("\x1B[100m","\x1B[49m"),bgRedBright:t("\x1B[101m","\x1B[49m"),bgGreenBright:t("\x1B[102m","\x1B[49m"),bgYellowBright:t("\x1B[103m","\x1B[49m"),bgBlueBright:t("\x1B[104m","\x1B[49m"),bgMagentaBright:t("\x1B[105m","\x1B[49m"),bgCyanBright:t("\x1B[106m","\x1B[49m"),bgWhiteBright:t("\x1B[107m","\x1B[49m")}};oi.exports=xn();oi.exports.createColors=xn});var Tt,Ht,Jt=De(()=>{"use strict";Tt="domani.run",Ht=`https://${Tt}`});function Sn(e){jn=e}function rt(){try{let e=ft.default.readFileSync(ai,"utf-8");return JSON.parse(e)}catch{return{}}}function Pt(e){ft.default.mkdirSync(us,{recursive:!0,mode:448}),ft.default.writeFileSync(ai,JSON.stringify(e,null,2),{mode:384})}function On(){try{ft.default.unlinkSync(ai)}catch{}}function Ge(){return jn||rt().api_url||Ht}function pt(){return process.env.DOMANI_API_KEY||rt().token}function Ho(){try{let e=ft.default.readFileSync(Cn,"utf-8");return JSON.parse(e)}catch{return null}}function Jo(e){try{ft.default.mkdirSync(us,{recursive:!0,mode:448}),ft.default.writeFileSync(Cn,JSON.stringify(e),{mode:384})}catch{}}function cs(e,t){let s=e.split(".").map(Number),i=t.split(".").map(Number);for(let n=0;n<3;n++){if((s[n]||0)>(i[n]||0))return 1;if((s[n]||0)<(i[n]||0))return-1}return 0}async function Rn(){let e=Ho();if(e&&Date.now()-e.checkedAt<Wo)return cs(e.version,xe)>0?{update:e.version,forced:cs(xe,e.min)<0}:null;try{let t=Ge(),s=await fetch(`${t}/api/cli/version`,{signal:AbortSignal.timeout(3e3)});if(!s.ok)return null;let i=await s.json();if(Jo({version:i.version,min:i.min,checkedAt:Date.now()}),cs(i.version,xe)>0)return{update:i.version,forced:cs(xe,i.min)<0}}catch{}return null}var ft,ds,kn,us,ai,jn,Cn,Wo,li,xe,ht=De(()=>{"use strict";ft=U(require("fs"),1),ds=U(require("path"),1),kn=U(require("os"),1);Jt();us=process.env.DOMANI_CONFIG_DIR||ds.default.join(kn.default.homedir(),".domani"),ai=ds.default.join(us,"config.json");Cn=ds.default.join(us,"version-check.json"),Wo=1440*60*1e3;li=process.stdout.isTTY??!1,xe="0.3.12"});var di=it((Ic,An)=>{"use strict";var ci={to(e,t){return t?`\x1B[${t+1};${e+1}H`:`\x1B[${e+1}G`},move(e,t){let s="";return e<0?s+=`\x1B[${-e}D`:e>0&&(s+=`\x1B[${e}C`),t<0?s+=`\x1B[${-t}A`:t>0&&(s+=`\x1B[${t}B`),s},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"},Bo={up:(e=1)=>"\x1B[S".repeat(e),down:(e=1)=>"\x1B[T".repeat(e)},Go={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 s=0;s<e;s++)t+=this.line+(s<e-1?ci.up():"");return e&&(t+=ci.left),t}};An.exports={cursor:ci,scroll:Bo,erase:Go,beep:"\x07"}});function ot(e,t,s){if(!s.some(o=>!o.disabled))return e;let i=e+t,n=Math.max(s.length-1,0),r=i<0?n:i>n?0:i;return s[r].disabled?ot(r,t<0?-1:1,s):r}function hi(e,t,s){return String(e).normalize().replaceAll(`\r
28
28
  `,`
29
29
  `).split(`
30
- `).map(s=>sa(s,t,i)).join(`
31
- `)}function Fn(e){if(e.aliases!==void 0){let t=e.aliases;for(let i in t){if(!Object.hasOwn(t,i))continue;let s=t[i];re.actions.has(s)&&(re.aliases.has(i)||re.aliases.set(i,s))}}if(e.messages!==void 0){let t=e.messages;t.cancel!==void 0&&(re.messages.cancel=t.cancel),t.error!==void 0&&(re.messages.error=t.error)}e.withGuide!==void 0&&(re.withGuide=e.withGuide!==!1)}function ys(e,t){if(typeof e=="string")return re.aliases.get(e)===t;for(let i of e)if(i!==void 0&&ys(i,t))return!0;return!1}function ra(e,t){if(e===t)return;let i=e.split(`
32
- `),s=t.split(`
33
- `),n=Math.max(i.length,s.length),r=[];for(let o=0;o<n;o++)i[o]!==s[o]&&r.push(o);return{lines:r,numLinesBefore:i.length,numLinesAfter:s.length,numLines:n}}function oe(e){return e===hs}function hi(e,t){let i=e;i.isTTY&&i.setRawMode(t)}function Ln({input:e=vt.stdin,output:t=vt.stdout,overwrite:i=!0,hideCursor:s=!0}={}){let n=ht.createInterface({input:e,output:t,prompt:"",tabSize:1});ht.emitKeypressEvents(e,n),e instanceof fs.ReadStream&&e.isTTY&&e.setRawMode(!0);let r=(o,{name:a,sequence:l})=>{let c=String(o);if(ys([c,a,l],"cancel")){s&&t.write(Oe.cursor.show),process.exit(0);return}if(!i)return;ht.moveCursor(t,a==="return"?0:-1,a==="return"?-1:0,()=>{ht.clearLine(t,1,()=>{e.once("keypress",r)})})};return s&&t.write(Oe.cursor.hide),e.once("keypress",r),()=>{e.off("keypress",r),s&&t.write(Oe.cursor.show),e instanceof fs.ReadStream&&e.isTTY&&!oa&&e.setRawMode(!1),n.terminal=!1,n.close()}}function Ze(e,t,i,s=i){let n=wt(e??vt.stdout);return ps(t,n-i.length,{hard:!0,trim:!1}).split(`
34
- `).map((r,o)=>`${o===0?s:i}${r}`).join(`
35
- `)}function aa(e,t){if(e===void 0||t.length===0)return 0;let i=t.findIndex(s=>s.value===e);return i!==-1?i:0}function la(e,t){return(t.label??String(t.value)).toLowerCase().includes(e.toLowerCase())}function ca(e,t){if(t)return e?t:t[0]}var Tt,vt,ht,In,Oe,fs,Bo,Go,Yo,ds,mi,fi,us,pi,Ko,zo,Tn,Xo,Jt,_i,Pn,Zo,gs,Dn,Qo,Nn,$s,An,ea,Rn,En,ta,ms,ia,sa,na,re,oa,hs,wt,bs,Xe,Bt,gi,$i,Vn,yi,bi,vi,wi,vs=Pe(()=>{Tt=require("node:util"),vt=require("node:process"),ht=F(require("node:readline"),1),In=F(require("node:readline"),1),Oe=F(cs(),1),fs=require("node:tty");Bo=e=>e===161||e===164||e===167||e===168||e===170||e===173||e===174||e>=176&&e<=180||e>=182&&e<=186||e>=188&&e<=191||e===198||e===208||e===215||e===216||e>=222&&e<=225||e===230||e>=232&&e<=234||e===236||e===237||e===240||e===242||e===243||e>=247&&e<=250||e===252||e===254||e===257||e===273||e===275||e===283||e===294||e===295||e===299||e>=305&&e<=307||e===312||e>=319&&e<=322||e===324||e>=328&&e<=331||e===333||e===338||e===339||e===358||e===359||e===363||e===462||e===464||e===466||e===468||e===470||e===472||e===474||e===476||e===593||e===609||e===708||e===711||e>=713&&e<=715||e===717||e===720||e>=728&&e<=731||e===733||e===735||e>=768&&e<=879||e>=913&&e<=929||e>=931&&e<=937||e>=945&&e<=961||e>=963&&e<=969||e===1025||e>=1040&&e<=1103||e===1105||e===8208||e>=8211&&e<=8214||e===8216||e===8217||e===8220||e===8221||e>=8224&&e<=8226||e>=8228&&e<=8231||e===8240||e===8242||e===8243||e===8245||e===8251||e===8254||e===8308||e===8319||e>=8321&&e<=8324||e===8364||e===8451||e===8453||e===8457||e===8467||e===8470||e===8481||e===8482||e===8486||e===8491||e===8531||e===8532||e>=8539&&e<=8542||e>=8544&&e<=8555||e>=8560&&e<=8569||e===8585||e>=8592&&e<=8601||e===8632||e===8633||e===8658||e===8660||e===8679||e===8704||e===8706||e===8707||e===8711||e===8712||e===8715||e===8719||e===8721||e===8725||e===8730||e>=8733&&e<=8736||e===8739||e===8741||e>=8743&&e<=8748||e===8750||e>=8756&&e<=8759||e===8764||e===8765||e===8776||e===8780||e===8786||e===8800||e===8801||e>=8804&&e<=8807||e===8810||e===8811||e===8814||e===8815||e===8834||e===8835||e===8838||e===8839||e===8853||e===8857||e===8869||e===8895||e===8978||e>=9312&&e<=9449||e>=9451&&e<=9547||e>=9552&&e<=9587||e>=9600&&e<=9615||e>=9618&&e<=9621||e===9632||e===9633||e>=9635&&e<=9641||e===9650||e===9651||e===9654||e===9655||e===9660||e===9661||e===9664||e===9665||e>=9670&&e<=9672||e===9675||e>=9678&&e<=9681||e>=9698&&e<=9701||e===9711||e===9733||e===9734||e===9737||e===9742||e===9743||e===9756||e===9758||e===9792||e===9794||e===9824||e===9825||e>=9827&&e<=9829||e>=9831&&e<=9834||e===9836||e===9837||e===9839||e===9886||e===9887||e===9919||e>=9926&&e<=9933||e>=9935&&e<=9939||e>=9941&&e<=9953||e===9955||e===9960||e===9961||e>=9963&&e<=9969||e===9972||e>=9974&&e<=9977||e===9979||e===9980||e===9982||e===9983||e===10045||e>=10102&&e<=10111||e>=11094&&e<=11097||e>=12872&&e<=12879||e>=57344&&e<=63743||e>=65024&&e<=65039||e===65533||e>=127232&&e<=127242||e>=127248&&e<=127277||e>=127280&&e<=127337||e>=127344&&e<=127373||e===127375||e===127376||e>=127387&&e<=127404||e>=917760&&e<=917999||e>=983040&&e<=1048573||e>=1048576&&e<=1114109,Go=e=>e===12288||e>=65281&&e<=65376||e>=65504&&e<=65510,Yo=e=>e>=4352&&e<=4447||e===8986||e===8987||e===9001||e===9002||e>=9193&&e<=9196||e===9200||e===9203||e===9725||e===9726||e===9748||e===9749||e>=9800&&e<=9811||e===9855||e===9875||e===9889||e===9898||e===9899||e===9917||e===9918||e===9924||e===9925||e===9934||e===9940||e===9962||e===9970||e===9971||e===9973||e===9978||e===9981||e===9989||e===9994||e===9995||e===10024||e===10060||e===10062||e>=10067&&e<=10069||e===10071||e>=10133&&e<=10135||e===10160||e===10175||e===11035||e===11036||e===11088||e===11093||e>=11904&&e<=11929||e>=11931&&e<=12019||e>=12032&&e<=12245||e>=12272&&e<=12287||e>=12289&&e<=12350||e>=12353&&e<=12438||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>=19968&&e<=42124||e>=42128&&e<=42182||e>=43360&&e<=43388||e>=44032&&e<=55203||e>=63744&&e<=64255||e>=65040&&e<=65049||e>=65072&&e<=65106||e>=65108&&e<=65126||e>=65128&&e<=65131||e>=94176&&e<=94180||e===94192||e===94193||e>=94208&&e<=100343||e>=100352&&e<=101589||e>=101632&&e<=101640||e>=110576&&e<=110579||e>=110581&&e<=110587||e===110589||e===110590||e>=110592&&e<=110882||e===110898||e>=110928&&e<=110930||e===110933||e>=110948&&e<=110951||e>=110960&&e<=111355||e===126980||e===127183||e===127374||e>=127377&&e<=127386||e>=127488&&e<=127490||e>=127504&&e<=127547||e>=127552&&e<=127560||e===127568||e===127569||e>=127584&&e<=127589||e>=127744&&e<=127776||e>=127789&&e<=127797||e>=127799&&e<=127868||e>=127870&&e<=127891||e>=127904&&e<=127946||e>=127951&&e<=127955||e>=127968&&e<=127984||e===127988||e>=127992&&e<=128062||e===128064||e>=128066&&e<=128252||e>=128255&&e<=128317||e>=128331&&e<=128334||e>=128336&&e<=128359||e===128378||e===128405||e===128406||e===128420||e>=128507&&e<=128591||e>=128640&&e<=128709||e===128716||e>=128720&&e<=128722||e>=128725&&e<=128727||e>=128732&&e<=128735||e===128747||e===128748||e>=128756&&e<=128764||e>=128992&&e<=129003||e===129008||e>=129292&&e<=129338||e>=129340&&e<=129349||e>=129351&&e<=129535||e>=129648&&e<=129660||e>=129664&&e<=129672||e>=129680&&e<=129725||e>=129727&&e<=129733||e>=129742&&e<=129755||e>=129760&&e<=129768||e>=129776&&e<=129784||e>=131072&&e<=196605||e>=196608&&e<=262141,ds=/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/y,mi=/[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y,fi=/\t{1,1000}/y,us=new RegExp("[\\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"),pi=/(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y,Ko=new RegExp("\\p{M}+","gu"),zo={limit:1/0,ellipsis:""},Tn=(e,t={},i={})=>{let s=t.limit??1/0,n=t.ellipsis??"",r=t?.ellipsisWidth??(n?Tn(n,zo,i).width:0),o=i.ansiWidth??0,a=i.controlWidth??0,l=i.tabWidth??8,c=i.ambiguousWidth??1,u=i.emojiWidth??2,p=i.fullWidthWidth??2,g=i.regularWidth??1,_=i.wideWidth??2,y=0,m=0,v=e.length,x=0,C=!1,E=v,V=Math.max(0,s-r),L=0,G=0,I=0,D=0;e:for(;;){if(G>L||m>=v&&m>y){let N=e.slice(L,G)||e.slice(y,m);x=0;for(let Y of N.replaceAll(Ko,"")){let Z=Y.codePointAt(0)||0;if(Go(Z)?D=p:Yo(Z)?D=_:c!==g&&Bo(Z)?D=c:D=g,I+D>V&&(E=Math.min(E,Math.max(L,y)+x)),I+D>s){C=!0;break e}x+=Y.length,I+=D}L=G=0}if(m>=v)break;if(pi.lastIndex=m,pi.test(e)){if(x=pi.lastIndex-m,D=x*g,I+D>V&&(E=Math.min(E,m+Math.floor((V-I)/g))),I+D>s){C=!0;break}I+=D,L=y,G=m,m=y=pi.lastIndex;continue}if(ds.lastIndex=m,ds.test(e)){if(I+o>V&&(E=Math.min(E,m)),I+o>s){C=!0;break}I+=o,L=y,G=m,m=y=ds.lastIndex;continue}if(mi.lastIndex=m,mi.test(e)){if(x=mi.lastIndex-m,D=x*a,I+D>V&&(E=Math.min(E,m+Math.floor((V-I)/a))),I+D>s){C=!0;break}I+=D,L=y,G=m,m=y=mi.lastIndex;continue}if(fi.lastIndex=m,fi.test(e)){if(x=fi.lastIndex-m,D=x*l,I+D>V&&(E=Math.min(E,m+Math.floor((V-I)/l))),I+D>s){C=!0;break}I+=D,L=y,G=m,m=y=fi.lastIndex;continue}if(us.lastIndex=m,us.test(e)){if(I+u>V&&(E=Math.min(E,m)),I+u>s){C=!0;break}I+=u,L=y,G=m,m=y=us.lastIndex;continue}m+=1}return{width:C?V:I,index:C?E:v,truncated:C,ellipsed:C&&s>=r}},Xo={limit:1/0,ellipsis:"",ellipsisWidth:0},Jt=(e,t={})=>Tn(e,Xo,t).width,_i="\x1B",Pn="\x9B",Zo=39,gs="\x07",Dn="[",Qo="]",Nn="m",$s=`${Qo}8;;`,An=new RegExp(`(?:\\${Dn}(?<code>\\d+)m|\\${$s}(?<uri>.*)${gs})`,"y"),ea=e=>{if(e>=30&&e<=37||e>=90&&e<=97)return 39;if(e>=40&&e<=47||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},Rn=e=>`${_i}${Dn}${e}${Nn}`,En=e=>`${_i}${$s}${e}${gs}`,ta=e=>e.map(t=>Jt(t)),ms=(e,t,i)=>{let s=t[Symbol.iterator](),n=!1,r=!1,o=e.at(-1),a=o===void 0?0:Jt(o),l=s.next(),c=s.next(),u=0;for(;!l.done;){let p=l.value,g=Jt(p);a+g<=i?e[e.length-1]+=p:(e.push(p),a=0),(p===_i||p===Pn)&&(n=!0,r=t.startsWith($s,u+1)),n?r?p===gs&&(n=!1,r=!1):p===Nn&&(n=!1):(a+=g,a===i&&!c.done&&(e.push(""),a=0)),l=c,c=s.next(),u+=p.length}o=e.at(-1),!a&&o!==void 0&&o.length>0&&e.length>1&&(e[e.length-2]+=e.pop())},ia=e=>{let t=e.split(" "),i=t.length;for(;i>0&&!(Jt(t[i-1])>0);)i--;return i===t.length?e:t.slice(0,i).join(" ")+t.slice(i).join("")},sa=(e,t,i={})=>{if(i.trim!==!1&&e.trim()==="")return"";let s="",n,r,o=e.split(" "),a=ta(o),l=[""];for(let[y,m]of o.entries()){i.trim!==!1&&(l[l.length-1]=(l.at(-1)??"").trimStart());let v=Jt(l.at(-1)??"");if(y!==0&&(v>=t&&(i.wordWrap===!1||i.trim===!1)&&(l.push(""),v=0),(v>0||i.trim===!1)&&(l[l.length-1]+=" ",v++)),i.hard&&a[y]>t){let x=t-v,C=1+Math.floor((a[y]-x-1)/t);Math.floor((a[y]-1)/t)<C&&l.push(""),ms(l,m,t);continue}if(v+a[y]>t&&v>0&&a[y]>0){if(i.wordWrap===!1&&v<t){ms(l,m,t);continue}l.push("")}if(v+a[y]>t&&i.wordWrap===!1){ms(l,m,t);continue}l[l.length-1]+=m}i.trim!==!1&&(l=l.map(y=>ia(y)));let c=l.join(`
36
- `),u=c[Symbol.iterator](),p=u.next(),g=u.next(),_=0;for(;!p.done;){let y=p.value,m=g.value;if(s+=y,y===_i||y===Pn){An.lastIndex=_+1;let x=An.exec(c)?.groups;if(x?.code!==void 0){let C=Number.parseFloat(x.code);n=C===Zo?void 0:C}else x?.uri!==void 0&&(r=x.uri.length===0?void 0:x.uri)}let v=n?ea(n):void 0;m===`
37
- `?(r&&(s+=En("")),n&&v&&(s+=Rn(v))):y===`
38
- `&&(n&&v&&(s+=Rn(n)),r&&(s+=En(r))),_+=y.length,p=g,g=u.next()}return s};na=["up","down","left","right","space","enter","cancel"],re={actions:new Set(na),aliases:new Map([["k","up"],["j","down"],["h","left"],["l","right"],["","cancel"],["escape","cancel"]]),messages:{cancel:"Canceled",error:"Something went wrong"},withGuide:!0};oa=globalThis.process.platform.startsWith("win"),hs=Symbol("clack:cancel");wt=e=>"columns"in e&&typeof e.columns=="number"?e.columns:80,bs=e=>"rows"in e&&typeof e.rows=="number"?e.rows:20;Xe=class{input;output;_abortSignal;rl;opts;_render;_track=!1;_prevFrame="";_subscribers=new Map;_cursor=0;state="initial";error="";value;userInput="";constructor(t,i=!0){let{input:s=vt.stdin,output:n=vt.stdout,render:r,signal:o,...a}=t;this.opts=a,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=i,this._abortSignal=o,this.input=s,this.output=n}unsubscribe(){this._subscribers.clear()}setSubscriber(t,i){let s=this._subscribers.get(t)??[];s.push(i),this._subscribers.set(t,s)}on(t,i){this.setSubscriber(t,{cb:i})}once(t,i){this.setSubscriber(t,{cb:i,once:!0})}emit(t,...i){let s=this._subscribers.get(t)??[],n=[];for(let r of s)r.cb(...i),r.once&&n.push(()=>s.splice(s.indexOf(r),1));for(let r of n)r()}prompt(){return new Promise(t=>{if(this._abortSignal){if(this._abortSignal.aborted)return this.state="cancel",this.close(),t(hs);this._abortSignal.addEventListener("abort",()=>{this.state="cancel",this.close()},{once:!0})}this.rl=In.default.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),hi(this.input,!0),this.output.on("resize",this.render),this.render(),this.once("submit",()=>{this.output.write(Oe.cursor.show),this.output.off("resize",this.render),hi(this.input,!1),t(this.value)}),this.once("cancel",()=>{this.output.write(Oe.cursor.show),this.output.off("resize",this.render),hi(this.input,!1),t(hs)})})}_isActionKey(t,i){return t===" "}_setValue(t){this.value=t,this.emit("value",this.value)}_setUserInput(t,i){this.userInput=t??"",this.emit("userInput",this.userInput),i&&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(t,i){if(this._track&&i.name!=="return"&&(i.name&&this._isActionKey(t,i)&&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"),i?.name&&(!this._track&&re.aliases.has(i.name)&&this.emit("cursor",re.aliases.get(i.name)),re.actions.has(i.name)&&this.emit("cursor",i.name)),t&&(t.toLowerCase()==="y"||t.toLowerCase()==="n")&&this.emit("confirm",t.toLowerCase()==="y"),this.emit("key",t?.toLowerCase(),i),i?.name==="return"){if(this.opts.validate){let s=this.opts.validate(this.value);s&&(this.error=s instanceof Error?s.message:s,this.state="error",this.rl?.write(this.userInput))}this.state!=="error"&&(this.state="submit")}ys([t,i?.name,i?.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(`
39
- `),hi(this.input,!1),this.rl?.close(),this.rl=void 0,this.emit(`${this.state}`,this.value),this.unsubscribe()}restoreCursor(){let t=ps(this._prevFrame,process.stdout.columns,{hard:!0,trim:!1}).split(`
40
- `).length-1;this.output.write(Oe.cursor.move(-999,t*-1))}render(){let t=ps(this._render(this)??"",process.stdout.columns,{hard:!0,trim:!1});if(t!==this._prevFrame){if(this.state==="initial")this.output.write(Oe.cursor.hide);else{let i=ra(this._prevFrame,t),s=bs(this.output);if(this.restoreCursor(),i){let n=Math.max(0,i.numLinesAfter-s),r=Math.max(0,i.numLinesBefore-s),o=i.lines.find(a=>a>=n);if(o===void 0){this._prevFrame=t;return}if(i.lines.length===1){this.output.write(Oe.cursor.move(0,o-r)),this.output.write(Oe.erase.lines(1));let a=t.split(`
41
- `);this.output.write(a[o]),this._prevFrame=t,this.output.write(Oe.cursor.move(0,a.length-o-1));return}else if(i.lines.length>1){if(n<r)o=n;else{let l=o-r;l>0&&this.output.write(Oe.cursor.move(0,l))}this.output.write(Oe.erase.down());let a=t.split(`
30
+ `).map(i=>ra(i,t,s)).join(`
31
+ `)}function Un(e){if(e.aliases!==void 0){let t=e.aliases;for(let s in t){if(!Object.hasOwn(t,s))continue;let i=t[s];re.actions.has(i)&&(re.aliases.has(s)||re.aliases.set(s,i))}}if(e.messages!==void 0){let t=e.messages;t.cancel!==void 0&&(re.messages.cancel=t.cancel),t.error!==void 0&&(re.messages.error=t.error)}e.withGuide!==void 0&&(re.withGuide=e.withGuide!==!1)}function bi(e,t){if(typeof e=="string")return re.aliases.get(e)===t;for(let s of e)if(s!==void 0&&bi(s,t))return!0;return!1}function aa(e,t){if(e===t)return;let s=e.split(`
32
+ `),i=t.split(`
33
+ `),n=Math.max(s.length,i.length),r=[];for(let o=0;o<n;o++)s[o]!==i[o]&&r.push(o);return{lines:r,numLinesBefore:s.length,numLinesAfter:i.length,numLines:n}}function oe(e){return e===gi}function hs(e,t){let s=e;s.isTTY&&s.setRawMode(t)}function Vn({input:e=vt.stdin,output:t=vt.stdout,overwrite:s=!0,hideCursor:i=!0}={}){let n=gt.createInterface({input:e,output:t,prompt:"",tabSize:1});gt.emitKeypressEvents(e,n),e instanceof pi.ReadStream&&e.isTTY&&e.setRawMode(!0);let r=(o,{name:a,sequence:l})=>{let d=String(o);if(bi([d,a,l],"cancel")){i&&t.write(Re.cursor.show),process.exit(0);return}if(!s)return;gt.moveCursor(t,a==="return"?0:-1,a==="return"?-1:0,()=>{gt.clearLine(t,1,()=>{e.once("keypress",r)})})};return i&&t.write(Re.cursor.hide),e.once("keypress",r),()=>{e.off("keypress",r),i&&t.write(Re.cursor.show),e instanceof pi.ReadStream&&e.isTTY&&!la&&e.setRawMode(!1),n.terminal=!1,n.close()}}function et(e,t,s,i=s){let n=wt(e??vt.stdout);return hi(t,n-s.length,{hard:!0,trim:!1}).split(`
34
+ `).map((r,o)=>`${o===0?i:s}${r}`).join(`
35
+ `)}function ca(e,t){if(e===void 0||t.length===0)return 0;let s=t.findIndex(i=>i.value===e);return s!==-1?s:0}function da(e,t){return(t.label??String(t.value)).toLowerCase().includes(e.toLowerCase())}function ua(e,t){if(t)return e?t:t[0]}var Dt,vt,gt,Pn,Re,pi,Yo,Ko,zo,ui,ms,fs,mi,ps,Xo,Zo,Dn,Qo,Bt,_s,Nn,ea,$i,Fn,ta,Ln,yi,En,sa,In,Tn,ia,fi,na,ra,oa,re,la,gi,wt,vi,Qe,Gt,gs,$s,Mn,ys,bs,vs,ws,wi=De(()=>{Dt=require("node:util"),vt=require("node:process"),gt=U(require("node:readline"),1),Pn=U(require("node:readline"),1),Re=U(di(),1),pi=require("node:tty");Yo=e=>e===161||e===164||e===167||e===168||e===170||e===173||e===174||e>=176&&e<=180||e>=182&&e<=186||e>=188&&e<=191||e===198||e===208||e===215||e===216||e>=222&&e<=225||e===230||e>=232&&e<=234||e===236||e===237||e===240||e===242||e===243||e>=247&&e<=250||e===252||e===254||e===257||e===273||e===275||e===283||e===294||e===295||e===299||e>=305&&e<=307||e===312||e>=319&&e<=322||e===324||e>=328&&e<=331||e===333||e===338||e===339||e===358||e===359||e===363||e===462||e===464||e===466||e===468||e===470||e===472||e===474||e===476||e===593||e===609||e===708||e===711||e>=713&&e<=715||e===717||e===720||e>=728&&e<=731||e===733||e===735||e>=768&&e<=879||e>=913&&e<=929||e>=931&&e<=937||e>=945&&e<=961||e>=963&&e<=969||e===1025||e>=1040&&e<=1103||e===1105||e===8208||e>=8211&&e<=8214||e===8216||e===8217||e===8220||e===8221||e>=8224&&e<=8226||e>=8228&&e<=8231||e===8240||e===8242||e===8243||e===8245||e===8251||e===8254||e===8308||e===8319||e>=8321&&e<=8324||e===8364||e===8451||e===8453||e===8457||e===8467||e===8470||e===8481||e===8482||e===8486||e===8491||e===8531||e===8532||e>=8539&&e<=8542||e>=8544&&e<=8555||e>=8560&&e<=8569||e===8585||e>=8592&&e<=8601||e===8632||e===8633||e===8658||e===8660||e===8679||e===8704||e===8706||e===8707||e===8711||e===8712||e===8715||e===8719||e===8721||e===8725||e===8730||e>=8733&&e<=8736||e===8739||e===8741||e>=8743&&e<=8748||e===8750||e>=8756&&e<=8759||e===8764||e===8765||e===8776||e===8780||e===8786||e===8800||e===8801||e>=8804&&e<=8807||e===8810||e===8811||e===8814||e===8815||e===8834||e===8835||e===8838||e===8839||e===8853||e===8857||e===8869||e===8895||e===8978||e>=9312&&e<=9449||e>=9451&&e<=9547||e>=9552&&e<=9587||e>=9600&&e<=9615||e>=9618&&e<=9621||e===9632||e===9633||e>=9635&&e<=9641||e===9650||e===9651||e===9654||e===9655||e===9660||e===9661||e===9664||e===9665||e>=9670&&e<=9672||e===9675||e>=9678&&e<=9681||e>=9698&&e<=9701||e===9711||e===9733||e===9734||e===9737||e===9742||e===9743||e===9756||e===9758||e===9792||e===9794||e===9824||e===9825||e>=9827&&e<=9829||e>=9831&&e<=9834||e===9836||e===9837||e===9839||e===9886||e===9887||e===9919||e>=9926&&e<=9933||e>=9935&&e<=9939||e>=9941&&e<=9953||e===9955||e===9960||e===9961||e>=9963&&e<=9969||e===9972||e>=9974&&e<=9977||e===9979||e===9980||e===9982||e===9983||e===10045||e>=10102&&e<=10111||e>=11094&&e<=11097||e>=12872&&e<=12879||e>=57344&&e<=63743||e>=65024&&e<=65039||e===65533||e>=127232&&e<=127242||e>=127248&&e<=127277||e>=127280&&e<=127337||e>=127344&&e<=127373||e===127375||e===127376||e>=127387&&e<=127404||e>=917760&&e<=917999||e>=983040&&e<=1048573||e>=1048576&&e<=1114109,Ko=e=>e===12288||e>=65281&&e<=65376||e>=65504&&e<=65510,zo=e=>e>=4352&&e<=4447||e===8986||e===8987||e===9001||e===9002||e>=9193&&e<=9196||e===9200||e===9203||e===9725||e===9726||e===9748||e===9749||e>=9800&&e<=9811||e===9855||e===9875||e===9889||e===9898||e===9899||e===9917||e===9918||e===9924||e===9925||e===9934||e===9940||e===9962||e===9970||e===9971||e===9973||e===9978||e===9981||e===9989||e===9994||e===9995||e===10024||e===10060||e===10062||e>=10067&&e<=10069||e===10071||e>=10133&&e<=10135||e===10160||e===10175||e===11035||e===11036||e===11088||e===11093||e>=11904&&e<=11929||e>=11931&&e<=12019||e>=12032&&e<=12245||e>=12272&&e<=12287||e>=12289&&e<=12350||e>=12353&&e<=12438||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>=19968&&e<=42124||e>=42128&&e<=42182||e>=43360&&e<=43388||e>=44032&&e<=55203||e>=63744&&e<=64255||e>=65040&&e<=65049||e>=65072&&e<=65106||e>=65108&&e<=65126||e>=65128&&e<=65131||e>=94176&&e<=94180||e===94192||e===94193||e>=94208&&e<=100343||e>=100352&&e<=101589||e>=101632&&e<=101640||e>=110576&&e<=110579||e>=110581&&e<=110587||e===110589||e===110590||e>=110592&&e<=110882||e===110898||e>=110928&&e<=110930||e===110933||e>=110948&&e<=110951||e>=110960&&e<=111355||e===126980||e===127183||e===127374||e>=127377&&e<=127386||e>=127488&&e<=127490||e>=127504&&e<=127547||e>=127552&&e<=127560||e===127568||e===127569||e>=127584&&e<=127589||e>=127744&&e<=127776||e>=127789&&e<=127797||e>=127799&&e<=127868||e>=127870&&e<=127891||e>=127904&&e<=127946||e>=127951&&e<=127955||e>=127968&&e<=127984||e===127988||e>=127992&&e<=128062||e===128064||e>=128066&&e<=128252||e>=128255&&e<=128317||e>=128331&&e<=128334||e>=128336&&e<=128359||e===128378||e===128405||e===128406||e===128420||e>=128507&&e<=128591||e>=128640&&e<=128709||e===128716||e>=128720&&e<=128722||e>=128725&&e<=128727||e>=128732&&e<=128735||e===128747||e===128748||e>=128756&&e<=128764||e>=128992&&e<=129003||e===129008||e>=129292&&e<=129338||e>=129340&&e<=129349||e>=129351&&e<=129535||e>=129648&&e<=129660||e>=129664&&e<=129672||e>=129680&&e<=129725||e>=129727&&e<=129733||e>=129742&&e<=129755||e>=129760&&e<=129768||e>=129776&&e<=129784||e>=131072&&e<=196605||e>=196608&&e<=262141,ui=/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/y,ms=/[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y,fs=/\t{1,1000}/y,mi=new RegExp("[\\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"),ps=/(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y,Xo=new RegExp("\\p{M}+","gu"),Zo={limit:1/0,ellipsis:""},Dn=(e,t={},s={})=>{let i=t.limit??1/0,n=t.ellipsis??"",r=t?.ellipsisWidth??(n?Dn(n,Zo,s).width:0),o=s.ansiWidth??0,a=s.controlWidth??0,l=s.tabWidth??8,d=s.ambiguousWidth??1,u=s.emojiWidth??2,p=s.fullWidthWidth??2,g=s.regularWidth??1,x=s.wideWidth??2,y=0,f=0,v=e.length,_=0,C=!1,A=v,F=Math.max(0,i-r),L=0,G=0,I=0,P=0;e:for(;;){if(G>L||f>=v&&f>y){let D=e.slice(L,G)||e.slice(y,f);_=0;for(let Y of D.replaceAll(Xo,"")){let Z=Y.codePointAt(0)||0;if(Ko(Z)?P=p:zo(Z)?P=x:d!==g&&Yo(Z)?P=d:P=g,I+P>F&&(A=Math.min(A,Math.max(L,y)+_)),I+P>i){C=!0;break e}_+=Y.length,I+=P}L=G=0}if(f>=v)break;if(ps.lastIndex=f,ps.test(e)){if(_=ps.lastIndex-f,P=_*g,I+P>F&&(A=Math.min(A,f+Math.floor((F-I)/g))),I+P>i){C=!0;break}I+=P,L=y,G=f,f=y=ps.lastIndex;continue}if(ui.lastIndex=f,ui.test(e)){if(I+o>F&&(A=Math.min(A,f)),I+o>i){C=!0;break}I+=o,L=y,G=f,f=y=ui.lastIndex;continue}if(ms.lastIndex=f,ms.test(e)){if(_=ms.lastIndex-f,P=_*a,I+P>F&&(A=Math.min(A,f+Math.floor((F-I)/a))),I+P>i){C=!0;break}I+=P,L=y,G=f,f=y=ms.lastIndex;continue}if(fs.lastIndex=f,fs.test(e)){if(_=fs.lastIndex-f,P=_*l,I+P>F&&(A=Math.min(A,f+Math.floor((F-I)/l))),I+P>i){C=!0;break}I+=P,L=y,G=f,f=y=fs.lastIndex;continue}if(mi.lastIndex=f,mi.test(e)){if(I+u>F&&(A=Math.min(A,f)),I+u>i){C=!0;break}I+=u,L=y,G=f,f=y=mi.lastIndex;continue}f+=1}return{width:C?F:I,index:C?A:v,truncated:C,ellipsed:C&&i>=r}},Qo={limit:1/0,ellipsis:"",ellipsisWidth:0},Bt=(e,t={})=>Dn(e,Qo,t).width,_s="\x1B",Nn="\x9B",ea=39,$i="\x07",Fn="[",ta="]",Ln="m",yi=`${ta}8;;`,En=new RegExp(`(?:\\${Fn}(?<code>\\d+)m|\\${yi}(?<uri>.*)${$i})`,"y"),sa=e=>{if(e>=30&&e<=37||e>=90&&e<=97)return 39;if(e>=40&&e<=47||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},In=e=>`${_s}${Fn}${e}${Ln}`,Tn=e=>`${_s}${yi}${e}${$i}`,ia=e=>e.map(t=>Bt(t)),fi=(e,t,s)=>{let i=t[Symbol.iterator](),n=!1,r=!1,o=e.at(-1),a=o===void 0?0:Bt(o),l=i.next(),d=i.next(),u=0;for(;!l.done;){let p=l.value,g=Bt(p);a+g<=s?e[e.length-1]+=p:(e.push(p),a=0),(p===_s||p===Nn)&&(n=!0,r=t.startsWith(yi,u+1)),n?r?p===$i&&(n=!1,r=!1):p===Ln&&(n=!1):(a+=g,a===s&&!d.done&&(e.push(""),a=0)),l=d,d=i.next(),u+=p.length}o=e.at(-1),!a&&o!==void 0&&o.length>0&&e.length>1&&(e[e.length-2]+=e.pop())},na=e=>{let t=e.split(" "),s=t.length;for(;s>0&&!(Bt(t[s-1])>0);)s--;return s===t.length?e:t.slice(0,s).join(" ")+t.slice(s).join("")},ra=(e,t,s={})=>{if(s.trim!==!1&&e.trim()==="")return"";let i="",n,r,o=e.split(" "),a=ia(o),l=[""];for(let[y,f]of o.entries()){s.trim!==!1&&(l[l.length-1]=(l.at(-1)??"").trimStart());let v=Bt(l.at(-1)??"");if(y!==0&&(v>=t&&(s.wordWrap===!1||s.trim===!1)&&(l.push(""),v=0),(v>0||s.trim===!1)&&(l[l.length-1]+=" ",v++)),s.hard&&a[y]>t){let _=t-v,C=1+Math.floor((a[y]-_-1)/t);Math.floor((a[y]-1)/t)<C&&l.push(""),fi(l,f,t);continue}if(v+a[y]>t&&v>0&&a[y]>0){if(s.wordWrap===!1&&v<t){fi(l,f,t);continue}l.push("")}if(v+a[y]>t&&s.wordWrap===!1){fi(l,f,t);continue}l[l.length-1]+=f}s.trim!==!1&&(l=l.map(y=>na(y)));let d=l.join(`
36
+ `),u=d[Symbol.iterator](),p=u.next(),g=u.next(),x=0;for(;!p.done;){let y=p.value,f=g.value;if(i+=y,y===_s||y===Nn){En.lastIndex=x+1;let _=En.exec(d)?.groups;if(_?.code!==void 0){let C=Number.parseFloat(_.code);n=C===ea?void 0:C}else _?.uri!==void 0&&(r=_.uri.length===0?void 0:_.uri)}let v=n?sa(n):void 0;f===`
37
+ `?(r&&(i+=Tn("")),n&&v&&(i+=In(v))):y===`
38
+ `&&(n&&v&&(i+=In(n)),r&&(i+=Tn(r))),x+=y.length,p=g,g=u.next()}return i};oa=["up","down","left","right","space","enter","cancel"],re={actions:new Set(oa),aliases:new Map([["k","up"],["j","down"],["h","left"],["l","right"],["","cancel"],["escape","cancel"]]),messages:{cancel:"Canceled",error:"Something went wrong"},withGuide:!0};la=globalThis.process.platform.startsWith("win"),gi=Symbol("clack:cancel");wt=e=>"columns"in e&&typeof e.columns=="number"?e.columns:80,vi=e=>"rows"in e&&typeof e.rows=="number"?e.rows:20;Qe=class{input;output;_abortSignal;rl;opts;_render;_track=!1;_prevFrame="";_subscribers=new Map;_cursor=0;state="initial";error="";value;userInput="";constructor(t,s=!0){let{input:i=vt.stdin,output:n=vt.stdout,render:r,signal:o,...a}=t;this.opts=a,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=s,this._abortSignal=o,this.input=i,this.output=n}unsubscribe(){this._subscribers.clear()}setSubscriber(t,s){let i=this._subscribers.get(t)??[];i.push(s),this._subscribers.set(t,i)}on(t,s){this.setSubscriber(t,{cb:s})}once(t,s){this.setSubscriber(t,{cb:s,once:!0})}emit(t,...s){let i=this._subscribers.get(t)??[],n=[];for(let r of i)r.cb(...s),r.once&&n.push(()=>i.splice(i.indexOf(r),1));for(let r of n)r()}prompt(){return new Promise(t=>{if(this._abortSignal){if(this._abortSignal.aborted)return this.state="cancel",this.close(),t(gi);this._abortSignal.addEventListener("abort",()=>{this.state="cancel",this.close()},{once:!0})}this.rl=Pn.default.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),hs(this.input,!0),this.output.on("resize",this.render),this.render(),this.once("submit",()=>{this.output.write(Re.cursor.show),this.output.off("resize",this.render),hs(this.input,!1),t(this.value)}),this.once("cancel",()=>{this.output.write(Re.cursor.show),this.output.off("resize",this.render),hs(this.input,!1),t(gi)})})}_isActionKey(t,s){return t===" "}_setValue(t){this.value=t,this.emit("value",this.value)}_setUserInput(t,s){this.userInput=t??"",this.emit("userInput",this.userInput),s&&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(t,s){if(this._track&&s.name!=="return"&&(s.name&&this._isActionKey(t,s)&&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"),s?.name&&(!this._track&&re.aliases.has(s.name)&&this.emit("cursor",re.aliases.get(s.name)),re.actions.has(s.name)&&this.emit("cursor",s.name)),t&&(t.toLowerCase()==="y"||t.toLowerCase()==="n")&&this.emit("confirm",t.toLowerCase()==="y"),this.emit("key",t?.toLowerCase(),s),s?.name==="return"){if(this.opts.validate){let i=this.opts.validate(this.value);i&&(this.error=i instanceof Error?i.message:i,this.state="error",this.rl?.write(this.userInput))}this.state!=="error"&&(this.state="submit")}bi([t,s?.name,s?.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(`
39
+ `),hs(this.input,!1),this.rl?.close(),this.rl=void 0,this.emit(`${this.state}`,this.value),this.unsubscribe()}restoreCursor(){let t=hi(this._prevFrame,process.stdout.columns,{hard:!0,trim:!1}).split(`
40
+ `).length-1;this.output.write(Re.cursor.move(-999,t*-1))}render(){let t=hi(this._render(this)??"",process.stdout.columns,{hard:!0,trim:!1});if(t!==this._prevFrame){if(this.state==="initial")this.output.write(Re.cursor.hide);else{let s=aa(this._prevFrame,t),i=vi(this.output);if(this.restoreCursor(),s){let n=Math.max(0,s.numLinesAfter-i),r=Math.max(0,s.numLinesBefore-i),o=s.lines.find(a=>a>=n);if(o===void 0){this._prevFrame=t;return}if(s.lines.length===1){this.output.write(Re.cursor.move(0,o-r)),this.output.write(Re.erase.lines(1));let a=t.split(`
41
+ `);this.output.write(a[o]),this._prevFrame=t,this.output.write(Re.cursor.move(0,a.length-o-1));return}else if(s.lines.length>1){if(n<r)o=n;else{let l=o-r;l>0&&this.output.write(Re.cursor.move(0,l))}this.output.write(Re.erase.down());let a=t.split(`
42
42
  `).slice(o);this.output.write(a.join(`
43
- `)),this._prevFrame=t;return}}this.output.write(Oe.erase.down())}this.output.write(t),this.state==="initial"&&(this.state="active"),this._prevFrame=t}}};Bt=class extends Xe{filteredOptions;multiple;isNavigating=!1;selectedValues=[];focusedValue;#e=0;#i="";#s;#t;get cursor(){return this.#e}get userInputWithCursor(){if(!this.userInput)return(0,Tt.styleText)(["inverse","hidden"],"_");if(this._cursor>=this.userInput.length)return`${this.userInput}\u2588`;let t=this.userInput.slice(0,this._cursor),[i,...s]=this.userInput.slice(this._cursor);return`${t}${(0,Tt.styleText)("inverse",i)}${s.join("")}`}get options(){return typeof this.#t=="function"?this.#t():this.#t}constructor(t){super(t),this.#t=t.options;let i=this.options;this.filteredOptions=[...i],this.multiple=t.multiple===!0,this.#s=t.filter??la;let s;if(t.initialValue&&Array.isArray(t.initialValue)?this.multiple?s=t.initialValue:s=t.initialValue.slice(0,1):!this.multiple&&this.options.length>0&&(s=[this.options[0].value]),s)for(let n of s){let r=i.findIndex(o=>o.value===n);r!==-1&&(this.toggleSelected(n),this.#e=r)}this.focusedValue=this.options[this.#e]?.value,this.on("key",(n,r)=>this.#n(n,r)),this.on("userInput",n=>this.#r(n))}_isActionKey(t,i){return t===" "||this.multiple&&this.isNavigating&&i.name==="space"&&t!==void 0&&t!==""}#n(t,i){let s=i.name==="up",n=i.name==="down",r=i.name==="return";s||n?(this.#e=ot(this.#e,s?-1:1,this.filteredOptions),this.focusedValue=this.filteredOptions[this.#e]?.value,this.multiple||(this.selectedValues=[this.focusedValue]),this.isNavigating=!0):r?this.value=ca(this.multiple,this.selectedValues):this.multiple?this.focusedValue!==void 0&&(i.name==="tab"||this.isNavigating&&i.name==="space")?this.toggleSelected(this.focusedValue):this.isNavigating=!1:(this.focusedValue&&(this.selectedValues=[this.focusedValue]),this.isNavigating=!1)}deselectAll(){this.selectedValues=[]}toggleSelected(t){this.filteredOptions.length!==0&&(this.multiple?this.selectedValues.includes(t)?this.selectedValues=this.selectedValues.filter(i=>i!==t):this.selectedValues=[...this.selectedValues,t]:this.selectedValues=[t])}#r(t){if(t!==this.#i){this.#i=t;let i=this.options;t?this.filteredOptions=i.filter(r=>this.#s(t,r)):this.filteredOptions=[...i];let s=aa(this.focusedValue,this.filteredOptions);this.#e=ot(s,0,this.filteredOptions);let n=this.filteredOptions[this.#e];n&&!n.disabled?this.focusedValue=n.value:this.focusedValue=void 0,this.multiple||(this.focusedValue!==void 0?this.toggleSelected(this.focusedValue):this.deselectAll())}}},gi=class extends Xe{get cursor(){return this.value?0:1}get _value(){return this.cursor===0}constructor(t){super(t,!1),this.value=!!t.initialValue,this.on("userInput",()=>{this.value=this._value}),this.on("confirm",i=>{this.output.write(Oe.cursor.move(0,-1)),this.value=i,this.state="submit",this.close()}),this.on("cursor",()=>{this.value=!this.value})}},$i=class extends Xe{options;cursor=0;#e;getGroupItems(t){return this.options.filter(i=>i.group===t)}isGroupSelected(t){let i=this.getGroupItems(t),s=this.value;return s===void 0?!1:i.every(n=>s.includes(n.value))}toggleValue(){let t=this.options[this.cursor];if(this.value===void 0&&(this.value=[]),t.group===!0){let i=t.value,s=this.getGroupItems(i);this.isGroupSelected(i)?this.value=this.value.filter(n=>s.findIndex(r=>r.value===n)===-1):this.value=[...this.value,...s.map(n=>n.value)],this.value=Array.from(new Set(this.value))}else{let i=this.value.includes(t.value);this.value=i?this.value.filter(s=>s!==t.value):[...this.value,t.value]}}constructor(t){super(t,!1);let{options:i}=t;this.#e=t.selectableGroups!==!1,this.options=Object.entries(i).flatMap(([s,n])=>[{value:s,group:!0,label:s},...n.map(r=>({...r,group:s}))]),this.value=[...t.initialValues??[]],this.cursor=Math.max(this.options.findIndex(({value:s})=>s===t.cursorAt),this.#e?0:1),this.on("cursor",s=>{switch(s){case"left":case"up":{this.cursor=this.cursor===0?this.options.length-1:this.cursor-1;let n=this.options[this.cursor]?.group===!0;!this.#e&&n&&(this.cursor=this.cursor===0?this.options.length-1:this.cursor-1);break}case"down":case"right":{this.cursor=this.cursor===this.options.length-1?0:this.cursor+1;let n=this.options[this.cursor]?.group===!0;!this.#e&&n&&(this.cursor=this.cursor===this.options.length-1?0:this.cursor+1);break}case"space":this.toggleValue();break}})}},Vn=class extends Xe{options;cursor=0;get _value(){return this.options[this.cursor].value}get _enabledOptions(){return this.options.filter(e=>e.disabled!==!0)}toggleAll(){let e=this._enabledOptions,t=this.value!==void 0&&this.value.length===e.length;this.value=t?[]:e.map(i=>i.value)}toggleInvert(){let e=this.value;if(!e)return;let t=this._enabledOptions.filter(i=>!e.includes(i.value));this.value=t.map(i=>i.value)}toggleValue(){this.value===void 0&&(this.value=[]);let e=this.value.includes(this._value);this.value=e?this.value.filter(t=>t!==this._value):[...this.value,this._value]}constructor(e){super(e,!1),this.options=e.options,this.value=[...e.initialValues??[]];let t=Math.max(this.options.findIndex(({value:i})=>i===e.cursorAt),0);this.cursor=this.options[t].disabled?ot(t,1,this.options):t,this.on("key",i=>{i==="a"&&this.toggleAll(),i==="i"&&this.toggleInvert()}),this.on("cursor",i=>{switch(i){case"left":case"up":this.cursor=ot(this.cursor,-1,this.options);break;case"down":case"right":this.cursor=ot(this.cursor,1,this.options);break;case"space":this.toggleValue();break}})}},yi=class extends Xe{_mask="\u2022";get cursor(){return this._cursor}get masked(){return this.userInput.replaceAll(/./g,this._mask)}get userInputWithCursor(){if(this.state==="submit"||this.state==="cancel")return this.masked;let t=this.userInput;if(this.cursor>=t.length)return`${this.masked}${(0,Tt.styleText)(["inverse","hidden"],"_")}`;let i=this.masked,s=i.slice(0,this.cursor),n=i.slice(this.cursor);return`${s}${(0,Tt.styleText)("inverse",n[0])}${n.slice(1)}`}clear(){this._clearUserInput()}constructor({mask:t,...i}){super(i),this._mask=t??"\u2022",this.on("userInput",s=>{this._setValue(s)})}},bi=class extends Xe{options;cursor=0;get _selectedValue(){return this.options[this.cursor]}changeValue(){this.value=this._selectedValue.value}constructor(t){super(t,!1),this.options=t.options;let i=this.options.findIndex(({value:n})=>n===t.initialValue),s=i===-1?0:i;this.cursor=this.options[s].disabled?ot(s,1,this.options):s,this.changeValue(),this.on("cursor",n=>{switch(n){case"left":case"up":this.cursor=ot(this.cursor,-1,this.options);break;case"down":case"right":this.cursor=ot(this.cursor,1,this.options);break}this.changeValue()})}},vi=class extends Xe{options;cursor=0;constructor(t){super(t,!1),this.options=t.options;let i=t.caseSensitive===!0,s=this.options.map(({value:[n]})=>i?n:n?.toLowerCase());this.cursor=Math.max(s.indexOf(t.initialValue),0),this.on("key",(n,r)=>{if(!n)return;let o=i&&r.shift?n.toUpperCase():n;if(!s.includes(o))return;let a=this.options.find(({value:[l]})=>i?l===o:l?.toLowerCase()===n);a&&(this.value=a.value,this.state="submit",this.emit("submit"))})}},wi=class extends Xe{get userInputWithCursor(){if(this.state==="submit")return this.userInput;let t=this.userInput;if(this.cursor>=t.length)return`${this.userInput}\u2588`;let i=t.slice(0,this.cursor),[s,...n]=t.slice(this.cursor);return`${i}${(0,Tt.styleText)("inverse",s)}${n.join("")}`}get cursor(){return this._cursor}constructor(t){super({...t,initialUserInput:t.initialUserInput??t.initialValue}),this.on("userInput",i=>{this._setValue(i)}),this.on("finalize",()=>{this.value||(this.value=t.defaultValue),this.value===void 0&&(this.value="")})}}});var Ls={};Rt(Ls,{S_BAR:()=>R,S_BAR_END:()=>we,S_BAR_END_RIGHT:()=>zn,S_BAR_H:()=>Ai,S_BAR_START:()=>Cs,S_BAR_START_RIGHT:()=>Kn,S_CHECKBOX_ACTIVE:()=>Oi,S_CHECKBOX_INACTIVE:()=>Dt,S_CHECKBOX_SELECTED:()=>xt,S_CONNECT_LEFT:()=>Zn,S_CORNER_BOTTOM_LEFT:()=>Rs,S_CORNER_BOTTOM_RIGHT:()=>As,S_CORNER_TOP_LEFT:()=>Qn,S_CORNER_TOP_RIGHT:()=>Os,S_ERROR:()=>Ps,S_INFO:()=>Es,S_PASSWORD_MASK:()=>Xn,S_RADIO_ACTIVE:()=>Kt,S_RADIO_INACTIVE:()=>jt,S_STEP_ACTIVE:()=>Yn,S_STEP_CANCEL:()=>js,S_STEP_ERROR:()=>Ss,S_STEP_SUBMIT:()=>St,S_SUCCESS:()=>Is,S_WARN:()=>Ts,autocomplete:()=>rr,autocompleteMultiselect:()=>ja,box:()=>Aa,cancel:()=>Ia,confirm:()=>We,group:()=>Ra,groupMultiselect:()=>Ea,intro:()=>Ta,isCI:()=>ks,isCancel:()=>oe,isTTY:()=>Gn,limitOptions:()=>Ft,log:()=>Fe,multiselect:()=>Da,note:()=>La,outro:()=>Pa,password:()=>Va,path:()=>Ua,progress:()=>qa,select:()=>Ge,selectKey:()=>Wa,settings:()=>re,spinner:()=>zt,stream:()=>_t,symbol:()=>Be,symbolBar:()=>Ds,taskLog:()=>Ba,tasks:()=>Ha,text:()=>Ae,unicode:()=>Ci,unicodeOr:()=>ne,updateSettings:()=>Fn});function da(){return Ne.default.platform!=="win32"?Ne.default.env.TERM!=="linux":!!Ne.default.env.CI||!!Ne.default.env.WT_SESSION||!!Ne.default.env.TERMINUS_SUBLIME||Ne.default.env.ConEmuTask==="{cmd::Cmder}"||Ne.default.env.TERM_PROGRAM==="Terminus-Sublime"||Ne.default.env.TERM_PROGRAM==="vscode"||Ne.default.env.TERM==="xterm-256color"||Ne.default.env.TERM==="alacritty"||Ne.default.env.TERMINAL_EMULATOR==="JetBrains-JediTerm"}function Nt(e,t,i){return String(e).normalize().replaceAll(`\r
43
+ `)),this._prevFrame=t;return}}this.output.write(Re.erase.down())}this.output.write(t),this.state==="initial"&&(this.state="active"),this._prevFrame=t}}};Gt=class extends Qe{filteredOptions;multiple;isNavigating=!1;selectedValues=[];focusedValue;#e=0;#s="";#i;#t;get cursor(){return this.#e}get userInputWithCursor(){if(!this.userInput)return(0,Dt.styleText)(["inverse","hidden"],"_");if(this._cursor>=this.userInput.length)return`${this.userInput}\u2588`;let t=this.userInput.slice(0,this._cursor),[s,...i]=this.userInput.slice(this._cursor);return`${t}${(0,Dt.styleText)("inverse",s)}${i.join("")}`}get options(){return typeof this.#t=="function"?this.#t():this.#t}constructor(t){super(t),this.#t=t.options;let s=this.options;this.filteredOptions=[...s],this.multiple=t.multiple===!0,this.#i=t.filter??da;let i;if(t.initialValue&&Array.isArray(t.initialValue)?this.multiple?i=t.initialValue:i=t.initialValue.slice(0,1):!this.multiple&&this.options.length>0&&(i=[this.options[0].value]),i)for(let n of i){let r=s.findIndex(o=>o.value===n);r!==-1&&(this.toggleSelected(n),this.#e=r)}this.focusedValue=this.options[this.#e]?.value,this.on("key",(n,r)=>this.#n(n,r)),this.on("userInput",n=>this.#r(n))}_isActionKey(t,s){return t===" "||this.multiple&&this.isNavigating&&s.name==="space"&&t!==void 0&&t!==""}#n(t,s){let i=s.name==="up",n=s.name==="down",r=s.name==="return";i||n?(this.#e=ot(this.#e,i?-1:1,this.filteredOptions),this.focusedValue=this.filteredOptions[this.#e]?.value,this.multiple||(this.selectedValues=[this.focusedValue]),this.isNavigating=!0):r?this.value=ua(this.multiple,this.selectedValues):this.multiple?this.focusedValue!==void 0&&(s.name==="tab"||this.isNavigating&&s.name==="space")?this.toggleSelected(this.focusedValue):this.isNavigating=!1:(this.focusedValue&&(this.selectedValues=[this.focusedValue]),this.isNavigating=!1)}deselectAll(){this.selectedValues=[]}toggleSelected(t){this.filteredOptions.length!==0&&(this.multiple?this.selectedValues.includes(t)?this.selectedValues=this.selectedValues.filter(s=>s!==t):this.selectedValues=[...this.selectedValues,t]:this.selectedValues=[t])}#r(t){if(t!==this.#s){this.#s=t;let s=this.options;t?this.filteredOptions=s.filter(r=>this.#i(t,r)):this.filteredOptions=[...s];let i=ca(this.focusedValue,this.filteredOptions);this.#e=ot(i,0,this.filteredOptions);let n=this.filteredOptions[this.#e];n&&!n.disabled?this.focusedValue=n.value:this.focusedValue=void 0,this.multiple||(this.focusedValue!==void 0?this.toggleSelected(this.focusedValue):this.deselectAll())}}},gs=class extends Qe{get cursor(){return this.value?0:1}get _value(){return this.cursor===0}constructor(t){super(t,!1),this.value=!!t.initialValue,this.on("userInput",()=>{this.value=this._value}),this.on("confirm",s=>{this.output.write(Re.cursor.move(0,-1)),this.value=s,this.state="submit",this.close()}),this.on("cursor",()=>{this.value=!this.value})}},$s=class extends Qe{options;cursor=0;#e;getGroupItems(t){return this.options.filter(s=>s.group===t)}isGroupSelected(t){let s=this.getGroupItems(t),i=this.value;return i===void 0?!1:s.every(n=>i.includes(n.value))}toggleValue(){let t=this.options[this.cursor];if(this.value===void 0&&(this.value=[]),t.group===!0){let s=t.value,i=this.getGroupItems(s);this.isGroupSelected(s)?this.value=this.value.filter(n=>i.findIndex(r=>r.value===n)===-1):this.value=[...this.value,...i.map(n=>n.value)],this.value=Array.from(new Set(this.value))}else{let s=this.value.includes(t.value);this.value=s?this.value.filter(i=>i!==t.value):[...this.value,t.value]}}constructor(t){super(t,!1);let{options:s}=t;this.#e=t.selectableGroups!==!1,this.options=Object.entries(s).flatMap(([i,n])=>[{value:i,group:!0,label:i},...n.map(r=>({...r,group:i}))]),this.value=[...t.initialValues??[]],this.cursor=Math.max(this.options.findIndex(({value:i})=>i===t.cursorAt),this.#e?0:1),this.on("cursor",i=>{switch(i){case"left":case"up":{this.cursor=this.cursor===0?this.options.length-1:this.cursor-1;let n=this.options[this.cursor]?.group===!0;!this.#e&&n&&(this.cursor=this.cursor===0?this.options.length-1:this.cursor-1);break}case"down":case"right":{this.cursor=this.cursor===this.options.length-1?0:this.cursor+1;let n=this.options[this.cursor]?.group===!0;!this.#e&&n&&(this.cursor=this.cursor===this.options.length-1?0:this.cursor+1);break}case"space":this.toggleValue();break}})}},Mn=class extends Qe{options;cursor=0;get _value(){return this.options[this.cursor].value}get _enabledOptions(){return this.options.filter(e=>e.disabled!==!0)}toggleAll(){let e=this._enabledOptions,t=this.value!==void 0&&this.value.length===e.length;this.value=t?[]:e.map(s=>s.value)}toggleInvert(){let e=this.value;if(!e)return;let t=this._enabledOptions.filter(s=>!e.includes(s.value));this.value=t.map(s=>s.value)}toggleValue(){this.value===void 0&&(this.value=[]);let e=this.value.includes(this._value);this.value=e?this.value.filter(t=>t!==this._value):[...this.value,this._value]}constructor(e){super(e,!1),this.options=e.options,this.value=[...e.initialValues??[]];let t=Math.max(this.options.findIndex(({value:s})=>s===e.cursorAt),0);this.cursor=this.options[t].disabled?ot(t,1,this.options):t,this.on("key",s=>{s==="a"&&this.toggleAll(),s==="i"&&this.toggleInvert()}),this.on("cursor",s=>{switch(s){case"left":case"up":this.cursor=ot(this.cursor,-1,this.options);break;case"down":case"right":this.cursor=ot(this.cursor,1,this.options);break;case"space":this.toggleValue();break}})}},ys=class extends Qe{_mask="\u2022";get cursor(){return this._cursor}get masked(){return this.userInput.replaceAll(/./g,this._mask)}get userInputWithCursor(){if(this.state==="submit"||this.state==="cancel")return this.masked;let t=this.userInput;if(this.cursor>=t.length)return`${this.masked}${(0,Dt.styleText)(["inverse","hidden"],"_")}`;let s=this.masked,i=s.slice(0,this.cursor),n=s.slice(this.cursor);return`${i}${(0,Dt.styleText)("inverse",n[0])}${n.slice(1)}`}clear(){this._clearUserInput()}constructor({mask:t,...s}){super(s),this._mask=t??"\u2022",this.on("userInput",i=>{this._setValue(i)})}},bs=class extends Qe{options;cursor=0;get _selectedValue(){return this.options[this.cursor]}changeValue(){this.value=this._selectedValue.value}constructor(t){super(t,!1),this.options=t.options;let s=this.options.findIndex(({value:n})=>n===t.initialValue),i=s===-1?0:s;this.cursor=this.options[i].disabled?ot(i,1,this.options):i,this.changeValue(),this.on("cursor",n=>{switch(n){case"left":case"up":this.cursor=ot(this.cursor,-1,this.options);break;case"down":case"right":this.cursor=ot(this.cursor,1,this.options);break}this.changeValue()})}},vs=class extends Qe{options;cursor=0;constructor(t){super(t,!1),this.options=t.options;let s=t.caseSensitive===!0,i=this.options.map(({value:[n]})=>s?n:n?.toLowerCase());this.cursor=Math.max(i.indexOf(t.initialValue),0),this.on("key",(n,r)=>{if(!n)return;let o=s&&r.shift?n.toUpperCase():n;if(!i.includes(o))return;let a=this.options.find(({value:[l]})=>s?l===o:l?.toLowerCase()===n);a&&(this.value=a.value,this.state="submit",this.emit("submit"))})}},ws=class extends Qe{get userInputWithCursor(){if(this.state==="submit")return this.userInput;let t=this.userInput;if(this.cursor>=t.length)return`${this.userInput}\u2588`;let s=t.slice(0,this.cursor),[i,...n]=t.slice(this.cursor);return`${s}${(0,Dt.styleText)("inverse",i)}${n.join("")}`}get cursor(){return this._cursor}constructor(t){super({...t,initialUserInput:t.initialUserInput??t.initialValue}),this.on("userInput",s=>{this._setValue(s)}),this.on("finalize",()=>{this.value||(this.value=t.defaultValue),this.value===void 0&&(this.value="")})}}});var Ui={};It(Ui,{S_BAR:()=>E,S_BAR_END:()=>_e,S_BAR_END_RIGHT:()=>Zn,S_BAR_H:()=>Rs,S_BAR_START:()=>Oi,S_BAR_START_RIGHT:()=>Xn,S_CHECKBOX_ACTIVE:()=>Os,S_CHECKBOX_INACTIVE:()=>Ft,S_CHECKBOX_SELECTED:()=>xt,S_CONNECT_LEFT:()=>er,S_CORNER_BOTTOM_LEFT:()=>Ei,S_CORNER_BOTTOM_RIGHT:()=>Ai,S_CORNER_TOP_LEFT:()=>tr,S_CORNER_TOP_RIGHT:()=>Ri,S_ERROR:()=>Di,S_INFO:()=>Ii,S_PASSWORD_MASK:()=>Qn,S_RADIO_ACTIVE:()=>zt,S_RADIO_INACTIVE:()=>jt,S_STEP_ACTIVE:()=>zn,S_STEP_CANCEL:()=>Si,S_STEP_ERROR:()=>Ci,S_STEP_SUBMIT:()=>St,S_SUCCESS:()=>Ti,S_WARN:()=>Pi,autocomplete:()=>ar,autocompleteMultiselect:()=>Ca,box:()=>Ea,cancel:()=>Pa,confirm:()=>He,group:()=>Ia,groupMultiselect:()=>Ta,intro:()=>Da,isCI:()=>ji,isCancel:()=>oe,isTTY:()=>Kn,limitOptions:()=>Ut,log:()=>Le,multiselect:()=>Fa,note:()=>Va,outro:()=>Na,password:()=>Ma,path:()=>qa,progress:()=>Ha,select:()=>Ke,selectKey:()=>Ja,settings:()=>re,spinner:()=>Xt,stream:()=>_t,symbol:()=>Ye,symbolBar:()=>Ni,taskLog:()=>Ya,tasks:()=>Ba,text:()=>Ae,unicode:()=>Cs,unicodeOr:()=>ne,updateSettings:()=>Un});function ma(){return Fe.default.platform!=="win32"?Fe.default.env.TERM!=="linux":!!Fe.default.env.CI||!!Fe.default.env.WT_SESSION||!!Fe.default.env.TERMINUS_SUBLIME||Fe.default.env.ConEmuTask==="{cmd::Cmder}"||Fe.default.env.TERM_PROGRAM==="Terminus-Sublime"||Fe.default.env.TERM_PROGRAM==="vscode"||Fe.default.env.TERM==="xterm-256color"||Fe.default.env.TERM==="alacritty"||Fe.default.env.TERMINAL_EMULATOR==="JetBrains-JediTerm"}function Lt(e,t,s){return String(e).normalize().replaceAll(`\r
44
44
  `,`
45
45
  `).split(`
46
- `).map(s=>_a(s,t,i)).join(`
47
- `)}function Wn(e){return e.label??String(e.value??"")}function nr(e,t){if(!e)return!0;let i=(t.label??String(t.value??"")).toLowerCase(),s=(t.hint??"").toLowerCase(),n=String(t.value).toLowerCase(),r=e.toLowerCase();return i.includes(r)||s.includes(r)||n.includes(r)}function ka(e,t){let i=[];for(let s of t)e.includes(s.value)&&i.push(s);return i}function Hn(e,t,i,s){let n=i,r=i;return s==="center"?n=Math.floor((t-e)/2):s==="right"&&(n=t-e-i),r=t-n-e,[n,r]}function qa({style:e="heavy",max:t=100,size:i=40,...s}={}){let n=zt(s),r=0,o="",a=Math.max(1,t),l=Math.max(1,i),c=_=>{switch(_){case"initial":case"active":return y=>(0,f.styleText)("magenta",y);case"error":case"cancel":return y=>(0,f.styleText)("red",y);case"submit":return y=>(0,f.styleText)("green",y);default:return y=>(0,f.styleText)("magenta",y)}},u=(_,y)=>{let m=Math.floor(r/a*l);return`${c(_)(Jn[e].repeat(m))}${(0,f.styleText)("dim",Jn[e].repeat(l-m))} ${y}`},p=(_="")=>{o=_,n.start(u("initial",_))},g=(_=1,y)=>{r=Math.min(a,_+r),n.message(u("active",y??o)),o=y??o};return{start:p,stop:n.stop,cancel:n.cancel,error:n.error,clear:n.clear,advance:g,isCancelled:n.isCancelled,message:_=>g(0,_)}}var f,Ne,kt,Yt,Pt,Ci,ks,Gn,ne,Yn,js,Ss,St,Cs,R,we,Kn,zn,Kt,jt,Oi,xt,Dt,Xn,Ai,Os,Zn,As,Rs,Qn,Es,Is,Ts,Ps,Be,Ds,ua,ma,fa,ws,xi,ki,_s,ji,pa,ha,er,ga,Ee,Ri,tr,$a,Ns,ir,ya,sr,Fs,Un,ba,Mn,qn,va,xs,wa,_a,xa,Ft,rr,ja,Sa,Ca,Oa,Aa,We,Ra,Ea,Fe,Ia,Ta,Pa,Gt,Da,Na,Fa,La,Va,Ua,Ma,zt,Jn,Si,Ge,Wa,Bn,_t,Ha,Ja,Ba,Ae,Ie=Pe(()=>{vs();vs();f=require("node:util"),Ne=F(require("node:process"),1),kt=require("node:fs"),Yt=require("node:path"),Pt=F(cs(),1);Ci=da(),ks=()=>process.env.CI==="true",Gn=e=>e.isTTY===!0,ne=(e,t)=>Ci?e:t,Yn=ne("\u25C6","*"),js=ne("\u25A0","x"),Ss=ne("\u25B2","x"),St=ne("\u25C7","o"),Cs=ne("\u250C","T"),R=ne("\u2502","|"),we=ne("\u2514","\u2014"),Kn=ne("\u2510","T"),zn=ne("\u2518","\u2014"),Kt=ne("\u25CF",">"),jt=ne("\u25CB"," "),Oi=ne("\u25FB","[\u2022]"),xt=ne("\u25FC","[+]"),Dt=ne("\u25FB","[ ]"),Xn=ne("\u25AA","\u2022"),Ai=ne("\u2500","-"),Os=ne("\u256E","+"),Zn=ne("\u251C","+"),As=ne("\u256F","+"),Rs=ne("\u2570","+"),Qn=ne("\u256D","+"),Es=ne("\u25CF","\u2022"),Is=ne("\u25C6","*"),Ts=ne("\u25B2","!"),Ps=ne("\u25A0","x"),Be=e=>{switch(e){case"initial":case"active":return(0,f.styleText)("cyan",Yn);case"cancel":return(0,f.styleText)("red",js);case"error":return(0,f.styleText)("yellow",Ss);case"submit":return(0,f.styleText)("green",St)}},Ds=e=>{switch(e){case"initial":case"active":return(0,f.styleText)("cyan",R);case"cancel":return(0,f.styleText)("red",R);case"error":return(0,f.styleText)("yellow",R);case"submit":return(0,f.styleText)("green",R)}},ua=e=>e===161||e===164||e===167||e===168||e===170||e===173||e===174||e>=176&&e<=180||e>=182&&e<=186||e>=188&&e<=191||e===198||e===208||e===215||e===216||e>=222&&e<=225||e===230||e>=232&&e<=234||e===236||e===237||e===240||e===242||e===243||e>=247&&e<=250||e===252||e===254||e===257||e===273||e===275||e===283||e===294||e===295||e===299||e>=305&&e<=307||e===312||e>=319&&e<=322||e===324||e>=328&&e<=331||e===333||e===338||e===339||e===358||e===359||e===363||e===462||e===464||e===466||e===468||e===470||e===472||e===474||e===476||e===593||e===609||e===708||e===711||e>=713&&e<=715||e===717||e===720||e>=728&&e<=731||e===733||e===735||e>=768&&e<=879||e>=913&&e<=929||e>=931&&e<=937||e>=945&&e<=961||e>=963&&e<=969||e===1025||e>=1040&&e<=1103||e===1105||e===8208||e>=8211&&e<=8214||e===8216||e===8217||e===8220||e===8221||e>=8224&&e<=8226||e>=8228&&e<=8231||e===8240||e===8242||e===8243||e===8245||e===8251||e===8254||e===8308||e===8319||e>=8321&&e<=8324||e===8364||e===8451||e===8453||e===8457||e===8467||e===8470||e===8481||e===8482||e===8486||e===8491||e===8531||e===8532||e>=8539&&e<=8542||e>=8544&&e<=8555||e>=8560&&e<=8569||e===8585||e>=8592&&e<=8601||e===8632||e===8633||e===8658||e===8660||e===8679||e===8704||e===8706||e===8707||e===8711||e===8712||e===8715||e===8719||e===8721||e===8725||e===8730||e>=8733&&e<=8736||e===8739||e===8741||e>=8743&&e<=8748||e===8750||e>=8756&&e<=8759||e===8764||e===8765||e===8776||e===8780||e===8786||e===8800||e===8801||e>=8804&&e<=8807||e===8810||e===8811||e===8814||e===8815||e===8834||e===8835||e===8838||e===8839||e===8853||e===8857||e===8869||e===8895||e===8978||e>=9312&&e<=9449||e>=9451&&e<=9547||e>=9552&&e<=9587||e>=9600&&e<=9615||e>=9618&&e<=9621||e===9632||e===9633||e>=9635&&e<=9641||e===9650||e===9651||e===9654||e===9655||e===9660||e===9661||e===9664||e===9665||e>=9670&&e<=9672||e===9675||e>=9678&&e<=9681||e>=9698&&e<=9701||e===9711||e===9733||e===9734||e===9737||e===9742||e===9743||e===9756||e===9758||e===9792||e===9794||e===9824||e===9825||e>=9827&&e<=9829||e>=9831&&e<=9834||e===9836||e===9837||e===9839||e===9886||e===9887||e===9919||e>=9926&&e<=9933||e>=9935&&e<=9939||e>=9941&&e<=9953||e===9955||e===9960||e===9961||e>=9963&&e<=9969||e===9972||e>=9974&&e<=9977||e===9979||e===9980||e===9982||e===9983||e===10045||e>=10102&&e<=10111||e>=11094&&e<=11097||e>=12872&&e<=12879||e>=57344&&e<=63743||e>=65024&&e<=65039||e===65533||e>=127232&&e<=127242||e>=127248&&e<=127277||e>=127280&&e<=127337||e>=127344&&e<=127373||e===127375||e===127376||e>=127387&&e<=127404||e>=917760&&e<=917999||e>=983040&&e<=1048573||e>=1048576&&e<=1114109,ma=e=>e===12288||e>=65281&&e<=65376||e>=65504&&e<=65510,fa=e=>e>=4352&&e<=4447||e===8986||e===8987||e===9001||e===9002||e>=9193&&e<=9196||e===9200||e===9203||e===9725||e===9726||e===9748||e===9749||e>=9800&&e<=9811||e===9855||e===9875||e===9889||e===9898||e===9899||e===9917||e===9918||e===9924||e===9925||e===9934||e===9940||e===9962||e===9970||e===9971||e===9973||e===9978||e===9981||e===9989||e===9994||e===9995||e===10024||e===10060||e===10062||e>=10067&&e<=10069||e===10071||e>=10133&&e<=10135||e===10160||e===10175||e===11035||e===11036||e===11088||e===11093||e>=11904&&e<=11929||e>=11931&&e<=12019||e>=12032&&e<=12245||e>=12272&&e<=12287||e>=12289&&e<=12350||e>=12353&&e<=12438||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>=19968&&e<=42124||e>=42128&&e<=42182||e>=43360&&e<=43388||e>=44032&&e<=55203||e>=63744&&e<=64255||e>=65040&&e<=65049||e>=65072&&e<=65106||e>=65108&&e<=65126||e>=65128&&e<=65131||e>=94176&&e<=94180||e===94192||e===94193||e>=94208&&e<=100343||e>=100352&&e<=101589||e>=101632&&e<=101640||e>=110576&&e<=110579||e>=110581&&e<=110587||e===110589||e===110590||e>=110592&&e<=110882||e===110898||e>=110928&&e<=110930||e===110933||e>=110948&&e<=110951||e>=110960&&e<=111355||e===126980||e===127183||e===127374||e>=127377&&e<=127386||e>=127488&&e<=127490||e>=127504&&e<=127547||e>=127552&&e<=127560||e===127568||e===127569||e>=127584&&e<=127589||e>=127744&&e<=127776||e>=127789&&e<=127797||e>=127799&&e<=127868||e>=127870&&e<=127891||e>=127904&&e<=127946||e>=127951&&e<=127955||e>=127968&&e<=127984||e===127988||e>=127992&&e<=128062||e===128064||e>=128066&&e<=128252||e>=128255&&e<=128317||e>=128331&&e<=128334||e>=128336&&e<=128359||e===128378||e===128405||e===128406||e===128420||e>=128507&&e<=128591||e>=128640&&e<=128709||e===128716||e>=128720&&e<=128722||e>=128725&&e<=128727||e>=128732&&e<=128735||e===128747||e===128748||e>=128756&&e<=128764||e>=128992&&e<=129003||e===129008||e>=129292&&e<=129338||e>=129340&&e<=129349||e>=129351&&e<=129535||e>=129648&&e<=129660||e>=129664&&e<=129672||e>=129680&&e<=129725||e>=129727&&e<=129733||e>=129742&&e<=129755||e>=129760&&e<=129768||e>=129776&&e<=129784||e>=131072&&e<=196605||e>=196608&&e<=262141,ws=/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/y,xi=/[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y,ki=/\t{1,1000}/y,_s=new RegExp("[\\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"),ji=/(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y,pa=new RegExp("\\p{M}+","gu"),ha={limit:1/0,ellipsis:""},er=(e,t={},i={})=>{let s=t.limit??1/0,n=t.ellipsis??"",r=t?.ellipsisWidth??(n?er(n,ha,i).width:0),o=i.ansiWidth??0,a=i.controlWidth??0,l=i.tabWidth??8,c=i.ambiguousWidth??1,u=i.emojiWidth??2,p=i.fullWidthWidth??2,g=i.regularWidth??1,_=i.wideWidth??2,y=0,m=0,v=e.length,x=0,C=!1,E=v,V=Math.max(0,s-r),L=0,G=0,I=0,D=0;e:for(;;){if(G>L||m>=v&&m>y){let N=e.slice(L,G)||e.slice(y,m);x=0;for(let Y of N.replaceAll(pa,"")){let Z=Y.codePointAt(0)||0;if(ma(Z)?D=p:fa(Z)?D=_:c!==g&&ua(Z)?D=c:D=g,I+D>V&&(E=Math.min(E,Math.max(L,y)+x)),I+D>s){C=!0;break e}x+=Y.length,I+=D}L=G=0}if(m>=v)break;if(ji.lastIndex=m,ji.test(e)){if(x=ji.lastIndex-m,D=x*g,I+D>V&&(E=Math.min(E,m+Math.floor((V-I)/g))),I+D>s){C=!0;break}I+=D,L=y,G=m,m=y=ji.lastIndex;continue}if(ws.lastIndex=m,ws.test(e)){if(I+o>V&&(E=Math.min(E,m)),I+o>s){C=!0;break}I+=o,L=y,G=m,m=y=ws.lastIndex;continue}if(xi.lastIndex=m,xi.test(e)){if(x=xi.lastIndex-m,D=x*a,I+D>V&&(E=Math.min(E,m+Math.floor((V-I)/a))),I+D>s){C=!0;break}I+=D,L=y,G=m,m=y=xi.lastIndex;continue}if(ki.lastIndex=m,ki.test(e)){if(x=ki.lastIndex-m,D=x*l,I+D>V&&(E=Math.min(E,m+Math.floor((V-I)/l))),I+D>s){C=!0;break}I+=D,L=y,G=m,m=y=ki.lastIndex;continue}if(_s.lastIndex=m,_s.test(e)){if(I+u>V&&(E=Math.min(E,m)),I+u>s){C=!0;break}I+=u,L=y,G=m,m=y=_s.lastIndex;continue}m+=1}return{width:C?V:I,index:C?E:v,truncated:C,ellipsed:C&&s>=r}},ga={limit:1/0,ellipsis:"",ellipsisWidth:0},Ee=(e,t={})=>er(e,ga,t).width,Ri="\x1B",tr="\x9B",$a=39,Ns="\x07",ir="[",ya="]",sr="m",Fs=`${ya}8;;`,Un=new RegExp(`(?:\\${ir}(?<code>\\d+)m|\\${Fs}(?<uri>.*)${Ns})`,"y"),ba=e=>{if(e>=30&&e<=37||e>=90&&e<=97)return 39;if(e>=40&&e<=47||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},Mn=e=>`${Ri}${ir}${e}${sr}`,qn=e=>`${Ri}${Fs}${e}${Ns}`,va=e=>e.map(t=>Ee(t)),xs=(e,t,i)=>{let s=t[Symbol.iterator](),n=!1,r=!1,o=e.at(-1),a=o===void 0?0:Ee(o),l=s.next(),c=s.next(),u=0;for(;!l.done;){let p=l.value,g=Ee(p);a+g<=i?e[e.length-1]+=p:(e.push(p),a=0),(p===Ri||p===tr)&&(n=!0,r=t.startsWith(Fs,u+1)),n?r?p===Ns&&(n=!1,r=!1):p===sr&&(n=!1):(a+=g,a===i&&!c.done&&(e.push(""),a=0)),l=c,c=s.next(),u+=p.length}o=e.at(-1),!a&&o!==void 0&&o.length>0&&e.length>1&&(e[e.length-2]+=e.pop())},wa=e=>{let t=e.split(" "),i=t.length;for(;i>0&&!(Ee(t[i-1])>0);)i--;return i===t.length?e:t.slice(0,i).join(" ")+t.slice(i).join("")},_a=(e,t,i={})=>{if(i.trim!==!1&&e.trim()==="")return"";let s="",n,r,o=e.split(" "),a=va(o),l=[""];for(let[y,m]of o.entries()){i.trim!==!1&&(l[l.length-1]=(l.at(-1)??"").trimStart());let v=Ee(l.at(-1)??"");if(y!==0&&(v>=t&&(i.wordWrap===!1||i.trim===!1)&&(l.push(""),v=0),(v>0||i.trim===!1)&&(l[l.length-1]+=" ",v++)),i.hard&&a[y]>t){let x=t-v,C=1+Math.floor((a[y]-x-1)/t);Math.floor((a[y]-1)/t)<C&&l.push(""),xs(l,m,t);continue}if(v+a[y]>t&&v>0&&a[y]>0){if(i.wordWrap===!1&&v<t){xs(l,m,t);continue}l.push("")}if(v+a[y]>t&&i.wordWrap===!1){xs(l,m,t);continue}l[l.length-1]+=m}i.trim!==!1&&(l=l.map(y=>wa(y)));let c=l.join(`
48
- `),u=c[Symbol.iterator](),p=u.next(),g=u.next(),_=0;for(;!p.done;){let y=p.value,m=g.value;if(s+=y,y===Ri||y===tr){Un.lastIndex=_+1;let x=Un.exec(c)?.groups;if(x?.code!==void 0){let C=Number.parseFloat(x.code);n=C===$a?void 0:C}else x?.uri!==void 0&&(r=x.uri.length===0?void 0:x.uri)}let v=n?ba(n):void 0;m===`
49
- `?(r&&(s+=qn("")),n&&v&&(s+=Mn(v))):y===`
50
- `&&(n&&v&&(s+=Mn(n)),r&&(s+=qn(r))),_+=y.length,p=g,g=u.next()}return s};xa=(e,t,i,s,n)=>{let r=t,o=0;for(let a=i;a<s;a++){let l=e[a];if(r=r-l.length,o++,r<=n)break}return{lineCount:r,removals:o}},Ft=({cursor:e,options:t,style:i,output:s=process.stdout,maxItems:n=Number.POSITIVE_INFINITY,columnPadding:r=0,rowPadding:o=4})=>{let a=wt(s)-r,l=bs(s),c=(0,f.styleText)("dim","..."),u=Math.max(l-o,0),p=Math.max(Math.min(n,u),5),g=0;e>=p-3&&(g=Math.max(Math.min(e-p+3,t.length-p),0));let _=p<t.length&&g>0,y=p<t.length&&g+p<t.length,m=Math.min(g+p,t.length),v=[],x=0;_&&x++,y&&x++;let C=g+(_?1:0),E=m-(y?1:0);for(let L=C;L<E;L++){let G=Nt(i(t[L],L===e),a,{hard:!0,trim:!1}).split(`
51
- `);v.push(G),x+=G.length}if(x>u){let L=0,G=0,I=x,D=e-C,N=(Y,Z)=>xa(v,I,Y,Z,u);_?({lineCount:I,removals:L}=N(0,D),I>u&&({lineCount:I,removals:G}=N(D+1,v.length))):({lineCount:I,removals:G}=N(D+1,v.length),I>u&&({lineCount:I,removals:L}=N(0,D))),L>0&&(_=!0,v.splice(0,L)),G>0&&(y=!0,v.splice(v.length-G,G))}let V=[];_&&V.push(c);for(let L of v)for(let G of L)V.push(G);return y&&V.push(c),V};rr=e=>new Bt({options:e.options,initialValue:e.initialValue?[e.initialValue]:void 0,initialUserInput:e.initialUserInput,filter:e.filter??((t,i)=>nr(t,i)),signal:e.signal,input:e.input,output:e.output,validate:e.validate,render(){let t=e.withGuide??re.withGuide,i=t?[`${(0,f.styleText)("gray",R)}`,`${Be(this.state)} ${e.message}`]:[`${Be(this.state)} ${e.message}`],s=this.userInput,n=this.options,r=e.placeholder,o=s===""&&r!==void 0,a=(l,c)=>{let u=Wn(l),p=l.hint&&l.value===this.focusedValue?(0,f.styleText)("dim",` (${l.hint})`):"";switch(c){case"active":return`${(0,f.styleText)("green",Kt)} ${u}${p}`;case"inactive":return`${(0,f.styleText)("dim",jt)} ${(0,f.styleText)("dim",u)}`;case"disabled":return`${(0,f.styleText)("gray",jt)} ${(0,f.styleText)(["strikethrough","gray"],u)}`}};switch(this.state){case"submit":{let l=ka(this.selectedValues,n),c=l.length>0?` ${(0,f.styleText)("dim",l.map(Wn).join(", "))}`:"",u=t?(0,f.styleText)("gray",R):"";return`${i.join(`
46
+ `).map(i=>ka(i,t,s)).join(`
47
+ `)}function Jn(e){return e.label??String(e.value??"")}function or(e,t){if(!e)return!0;let s=(t.label??String(t.value??"")).toLowerCase(),i=(t.hint??"").toLowerCase(),n=String(t.value).toLowerCase(),r=e.toLowerCase();return s.includes(r)||i.includes(r)||n.includes(r)}function Sa(e,t){let s=[];for(let i of t)e.includes(i.value)&&s.push(i);return s}function Bn(e,t,s,i){let n=s,r=s;return i==="center"?n=Math.floor((t-e)/2):i==="right"&&(n=t-e-s),r=t-n-e,[n,r]}function Ha({style:e="heavy",max:t=100,size:s=40,...i}={}){let n=Xt(i),r=0,o="",a=Math.max(1,t),l=Math.max(1,s),d=x=>{switch(x){case"initial":case"active":return y=>(0,m.styleText)("magenta",y);case"error":case"cancel":return y=>(0,m.styleText)("red",y);case"submit":return y=>(0,m.styleText)("green",y);default:return y=>(0,m.styleText)("magenta",y)}},u=(x,y)=>{let f=Math.floor(r/a*l);return`${d(x)(Gn[e].repeat(f))}${(0,m.styleText)("dim",Gn[e].repeat(l-f))} ${y}`},p=(x="")=>{o=x,n.start(u("initial",x))},g=(x=1,y)=>{r=Math.min(a,x+r),n.message(u("active",y??o)),o=y??o};return{start:p,stop:n.stop,cancel:n.cancel,error:n.error,clear:n.clear,advance:g,isCancelled:n.isCancelled,message:x=>g(0,x)}}var m,Fe,kt,Kt,Nt,Cs,ji,Kn,ne,zn,Si,Ci,St,Oi,E,_e,Xn,Zn,zt,jt,Os,xt,Ft,Qn,Rs,Ri,er,Ai,Ei,tr,Ii,Ti,Pi,Di,Ye,Ni,fa,pa,ha,_i,xs,ks,xi,js,ga,$a,sr,ya,Ie,As,ir,ba,Fi,nr,va,rr,Li,qn,wa,Wn,Hn,_a,ki,xa,ka,ja,Ut,ar,Ca,Oa,Ra,Aa,Ea,He,Ia,Ta,Le,Pa,Da,Na,Yt,Fa,La,Ua,Va,Ma,qa,Wa,Xt,Gn,Ss,Ke,Ja,Yn,_t,Ba,Ga,Ya,Ae,Te=De(()=>{wi();wi();m=require("node:util"),Fe=U(require("node:process"),1),kt=require("node:fs"),Kt=require("node:path"),Nt=U(di(),1);Cs=ma(),ji=()=>process.env.CI==="true",Kn=e=>e.isTTY===!0,ne=(e,t)=>Cs?e:t,zn=ne("\u25C6","*"),Si=ne("\u25A0","x"),Ci=ne("\u25B2","x"),St=ne("\u25C7","o"),Oi=ne("\u250C","T"),E=ne("\u2502","|"),_e=ne("\u2514","\u2014"),Xn=ne("\u2510","T"),Zn=ne("\u2518","\u2014"),zt=ne("\u25CF",">"),jt=ne("\u25CB"," "),Os=ne("\u25FB","[\u2022]"),xt=ne("\u25FC","[+]"),Ft=ne("\u25FB","[ ]"),Qn=ne("\u25AA","\u2022"),Rs=ne("\u2500","-"),Ri=ne("\u256E","+"),er=ne("\u251C","+"),Ai=ne("\u256F","+"),Ei=ne("\u2570","+"),tr=ne("\u256D","+"),Ii=ne("\u25CF","\u2022"),Ti=ne("\u25C6","*"),Pi=ne("\u25B2","!"),Di=ne("\u25A0","x"),Ye=e=>{switch(e){case"initial":case"active":return(0,m.styleText)("cyan",zn);case"cancel":return(0,m.styleText)("red",Si);case"error":return(0,m.styleText)("yellow",Ci);case"submit":return(0,m.styleText)("green",St)}},Ni=e=>{switch(e){case"initial":case"active":return(0,m.styleText)("cyan",E);case"cancel":return(0,m.styleText)("red",E);case"error":return(0,m.styleText)("yellow",E);case"submit":return(0,m.styleText)("green",E)}},fa=e=>e===161||e===164||e===167||e===168||e===170||e===173||e===174||e>=176&&e<=180||e>=182&&e<=186||e>=188&&e<=191||e===198||e===208||e===215||e===216||e>=222&&e<=225||e===230||e>=232&&e<=234||e===236||e===237||e===240||e===242||e===243||e>=247&&e<=250||e===252||e===254||e===257||e===273||e===275||e===283||e===294||e===295||e===299||e>=305&&e<=307||e===312||e>=319&&e<=322||e===324||e>=328&&e<=331||e===333||e===338||e===339||e===358||e===359||e===363||e===462||e===464||e===466||e===468||e===470||e===472||e===474||e===476||e===593||e===609||e===708||e===711||e>=713&&e<=715||e===717||e===720||e>=728&&e<=731||e===733||e===735||e>=768&&e<=879||e>=913&&e<=929||e>=931&&e<=937||e>=945&&e<=961||e>=963&&e<=969||e===1025||e>=1040&&e<=1103||e===1105||e===8208||e>=8211&&e<=8214||e===8216||e===8217||e===8220||e===8221||e>=8224&&e<=8226||e>=8228&&e<=8231||e===8240||e===8242||e===8243||e===8245||e===8251||e===8254||e===8308||e===8319||e>=8321&&e<=8324||e===8364||e===8451||e===8453||e===8457||e===8467||e===8470||e===8481||e===8482||e===8486||e===8491||e===8531||e===8532||e>=8539&&e<=8542||e>=8544&&e<=8555||e>=8560&&e<=8569||e===8585||e>=8592&&e<=8601||e===8632||e===8633||e===8658||e===8660||e===8679||e===8704||e===8706||e===8707||e===8711||e===8712||e===8715||e===8719||e===8721||e===8725||e===8730||e>=8733&&e<=8736||e===8739||e===8741||e>=8743&&e<=8748||e===8750||e>=8756&&e<=8759||e===8764||e===8765||e===8776||e===8780||e===8786||e===8800||e===8801||e>=8804&&e<=8807||e===8810||e===8811||e===8814||e===8815||e===8834||e===8835||e===8838||e===8839||e===8853||e===8857||e===8869||e===8895||e===8978||e>=9312&&e<=9449||e>=9451&&e<=9547||e>=9552&&e<=9587||e>=9600&&e<=9615||e>=9618&&e<=9621||e===9632||e===9633||e>=9635&&e<=9641||e===9650||e===9651||e===9654||e===9655||e===9660||e===9661||e===9664||e===9665||e>=9670&&e<=9672||e===9675||e>=9678&&e<=9681||e>=9698&&e<=9701||e===9711||e===9733||e===9734||e===9737||e===9742||e===9743||e===9756||e===9758||e===9792||e===9794||e===9824||e===9825||e>=9827&&e<=9829||e>=9831&&e<=9834||e===9836||e===9837||e===9839||e===9886||e===9887||e===9919||e>=9926&&e<=9933||e>=9935&&e<=9939||e>=9941&&e<=9953||e===9955||e===9960||e===9961||e>=9963&&e<=9969||e===9972||e>=9974&&e<=9977||e===9979||e===9980||e===9982||e===9983||e===10045||e>=10102&&e<=10111||e>=11094&&e<=11097||e>=12872&&e<=12879||e>=57344&&e<=63743||e>=65024&&e<=65039||e===65533||e>=127232&&e<=127242||e>=127248&&e<=127277||e>=127280&&e<=127337||e>=127344&&e<=127373||e===127375||e===127376||e>=127387&&e<=127404||e>=917760&&e<=917999||e>=983040&&e<=1048573||e>=1048576&&e<=1114109,pa=e=>e===12288||e>=65281&&e<=65376||e>=65504&&e<=65510,ha=e=>e>=4352&&e<=4447||e===8986||e===8987||e===9001||e===9002||e>=9193&&e<=9196||e===9200||e===9203||e===9725||e===9726||e===9748||e===9749||e>=9800&&e<=9811||e===9855||e===9875||e===9889||e===9898||e===9899||e===9917||e===9918||e===9924||e===9925||e===9934||e===9940||e===9962||e===9970||e===9971||e===9973||e===9978||e===9981||e===9989||e===9994||e===9995||e===10024||e===10060||e===10062||e>=10067&&e<=10069||e===10071||e>=10133&&e<=10135||e===10160||e===10175||e===11035||e===11036||e===11088||e===11093||e>=11904&&e<=11929||e>=11931&&e<=12019||e>=12032&&e<=12245||e>=12272&&e<=12287||e>=12289&&e<=12350||e>=12353&&e<=12438||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>=19968&&e<=42124||e>=42128&&e<=42182||e>=43360&&e<=43388||e>=44032&&e<=55203||e>=63744&&e<=64255||e>=65040&&e<=65049||e>=65072&&e<=65106||e>=65108&&e<=65126||e>=65128&&e<=65131||e>=94176&&e<=94180||e===94192||e===94193||e>=94208&&e<=100343||e>=100352&&e<=101589||e>=101632&&e<=101640||e>=110576&&e<=110579||e>=110581&&e<=110587||e===110589||e===110590||e>=110592&&e<=110882||e===110898||e>=110928&&e<=110930||e===110933||e>=110948&&e<=110951||e>=110960&&e<=111355||e===126980||e===127183||e===127374||e>=127377&&e<=127386||e>=127488&&e<=127490||e>=127504&&e<=127547||e>=127552&&e<=127560||e===127568||e===127569||e>=127584&&e<=127589||e>=127744&&e<=127776||e>=127789&&e<=127797||e>=127799&&e<=127868||e>=127870&&e<=127891||e>=127904&&e<=127946||e>=127951&&e<=127955||e>=127968&&e<=127984||e===127988||e>=127992&&e<=128062||e===128064||e>=128066&&e<=128252||e>=128255&&e<=128317||e>=128331&&e<=128334||e>=128336&&e<=128359||e===128378||e===128405||e===128406||e===128420||e>=128507&&e<=128591||e>=128640&&e<=128709||e===128716||e>=128720&&e<=128722||e>=128725&&e<=128727||e>=128732&&e<=128735||e===128747||e===128748||e>=128756&&e<=128764||e>=128992&&e<=129003||e===129008||e>=129292&&e<=129338||e>=129340&&e<=129349||e>=129351&&e<=129535||e>=129648&&e<=129660||e>=129664&&e<=129672||e>=129680&&e<=129725||e>=129727&&e<=129733||e>=129742&&e<=129755||e>=129760&&e<=129768||e>=129776&&e<=129784||e>=131072&&e<=196605||e>=196608&&e<=262141,_i=/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/y,xs=/[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y,ks=/\t{1,1000}/y,xi=new RegExp("[\\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"),js=/(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y,ga=new RegExp("\\p{M}+","gu"),$a={limit:1/0,ellipsis:""},sr=(e,t={},s={})=>{let i=t.limit??1/0,n=t.ellipsis??"",r=t?.ellipsisWidth??(n?sr(n,$a,s).width:0),o=s.ansiWidth??0,a=s.controlWidth??0,l=s.tabWidth??8,d=s.ambiguousWidth??1,u=s.emojiWidth??2,p=s.fullWidthWidth??2,g=s.regularWidth??1,x=s.wideWidth??2,y=0,f=0,v=e.length,_=0,C=!1,A=v,F=Math.max(0,i-r),L=0,G=0,I=0,P=0;e:for(;;){if(G>L||f>=v&&f>y){let D=e.slice(L,G)||e.slice(y,f);_=0;for(let Y of D.replaceAll(ga,"")){let Z=Y.codePointAt(0)||0;if(pa(Z)?P=p:ha(Z)?P=x:d!==g&&fa(Z)?P=d:P=g,I+P>F&&(A=Math.min(A,Math.max(L,y)+_)),I+P>i){C=!0;break e}_+=Y.length,I+=P}L=G=0}if(f>=v)break;if(js.lastIndex=f,js.test(e)){if(_=js.lastIndex-f,P=_*g,I+P>F&&(A=Math.min(A,f+Math.floor((F-I)/g))),I+P>i){C=!0;break}I+=P,L=y,G=f,f=y=js.lastIndex;continue}if(_i.lastIndex=f,_i.test(e)){if(I+o>F&&(A=Math.min(A,f)),I+o>i){C=!0;break}I+=o,L=y,G=f,f=y=_i.lastIndex;continue}if(xs.lastIndex=f,xs.test(e)){if(_=xs.lastIndex-f,P=_*a,I+P>F&&(A=Math.min(A,f+Math.floor((F-I)/a))),I+P>i){C=!0;break}I+=P,L=y,G=f,f=y=xs.lastIndex;continue}if(ks.lastIndex=f,ks.test(e)){if(_=ks.lastIndex-f,P=_*l,I+P>F&&(A=Math.min(A,f+Math.floor((F-I)/l))),I+P>i){C=!0;break}I+=P,L=y,G=f,f=y=ks.lastIndex;continue}if(xi.lastIndex=f,xi.test(e)){if(I+u>F&&(A=Math.min(A,f)),I+u>i){C=!0;break}I+=u,L=y,G=f,f=y=xi.lastIndex;continue}f+=1}return{width:C?F:I,index:C?A:v,truncated:C,ellipsed:C&&i>=r}},ya={limit:1/0,ellipsis:"",ellipsisWidth:0},Ie=(e,t={})=>sr(e,ya,t).width,As="\x1B",ir="\x9B",ba=39,Fi="\x07",nr="[",va="]",rr="m",Li=`${va}8;;`,qn=new RegExp(`(?:\\${nr}(?<code>\\d+)m|\\${Li}(?<uri>.*)${Fi})`,"y"),wa=e=>{if(e>=30&&e<=37||e>=90&&e<=97)return 39;if(e>=40&&e<=47||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},Wn=e=>`${As}${nr}${e}${rr}`,Hn=e=>`${As}${Li}${e}${Fi}`,_a=e=>e.map(t=>Ie(t)),ki=(e,t,s)=>{let i=t[Symbol.iterator](),n=!1,r=!1,o=e.at(-1),a=o===void 0?0:Ie(o),l=i.next(),d=i.next(),u=0;for(;!l.done;){let p=l.value,g=Ie(p);a+g<=s?e[e.length-1]+=p:(e.push(p),a=0),(p===As||p===ir)&&(n=!0,r=t.startsWith(Li,u+1)),n?r?p===Fi&&(n=!1,r=!1):p===rr&&(n=!1):(a+=g,a===s&&!d.done&&(e.push(""),a=0)),l=d,d=i.next(),u+=p.length}o=e.at(-1),!a&&o!==void 0&&o.length>0&&e.length>1&&(e[e.length-2]+=e.pop())},xa=e=>{let t=e.split(" "),s=t.length;for(;s>0&&!(Ie(t[s-1])>0);)s--;return s===t.length?e:t.slice(0,s).join(" ")+t.slice(s).join("")},ka=(e,t,s={})=>{if(s.trim!==!1&&e.trim()==="")return"";let i="",n,r,o=e.split(" "),a=_a(o),l=[""];for(let[y,f]of o.entries()){s.trim!==!1&&(l[l.length-1]=(l.at(-1)??"").trimStart());let v=Ie(l.at(-1)??"");if(y!==0&&(v>=t&&(s.wordWrap===!1||s.trim===!1)&&(l.push(""),v=0),(v>0||s.trim===!1)&&(l[l.length-1]+=" ",v++)),s.hard&&a[y]>t){let _=t-v,C=1+Math.floor((a[y]-_-1)/t);Math.floor((a[y]-1)/t)<C&&l.push(""),ki(l,f,t);continue}if(v+a[y]>t&&v>0&&a[y]>0){if(s.wordWrap===!1&&v<t){ki(l,f,t);continue}l.push("")}if(v+a[y]>t&&s.wordWrap===!1){ki(l,f,t);continue}l[l.length-1]+=f}s.trim!==!1&&(l=l.map(y=>xa(y)));let d=l.join(`
48
+ `),u=d[Symbol.iterator](),p=u.next(),g=u.next(),x=0;for(;!p.done;){let y=p.value,f=g.value;if(i+=y,y===As||y===ir){qn.lastIndex=x+1;let _=qn.exec(d)?.groups;if(_?.code!==void 0){let C=Number.parseFloat(_.code);n=C===ba?void 0:C}else _?.uri!==void 0&&(r=_.uri.length===0?void 0:_.uri)}let v=n?wa(n):void 0;f===`
49
+ `?(r&&(i+=Hn("")),n&&v&&(i+=Wn(v))):y===`
50
+ `&&(n&&v&&(i+=Wn(n)),r&&(i+=Hn(r))),x+=y.length,p=g,g=u.next()}return i};ja=(e,t,s,i,n)=>{let r=t,o=0;for(let a=s;a<i;a++){let l=e[a];if(r=r-l.length,o++,r<=n)break}return{lineCount:r,removals:o}},Ut=({cursor:e,options:t,style:s,output:i=process.stdout,maxItems:n=Number.POSITIVE_INFINITY,columnPadding:r=0,rowPadding:o=4})=>{let a=wt(i)-r,l=vi(i),d=(0,m.styleText)("dim","..."),u=Math.max(l-o,0),p=Math.max(Math.min(n,u),5),g=0;e>=p-3&&(g=Math.max(Math.min(e-p+3,t.length-p),0));let x=p<t.length&&g>0,y=p<t.length&&g+p<t.length,f=Math.min(g+p,t.length),v=[],_=0;x&&_++,y&&_++;let C=g+(x?1:0),A=f-(y?1:0);for(let L=C;L<A;L++){let G=Lt(s(t[L],L===e),a,{hard:!0,trim:!1}).split(`
51
+ `);v.push(G),_+=G.length}if(_>u){let L=0,G=0,I=_,P=e-C,D=(Y,Z)=>ja(v,I,Y,Z,u);x?({lineCount:I,removals:L}=D(0,P),I>u&&({lineCount:I,removals:G}=D(P+1,v.length))):({lineCount:I,removals:G}=D(P+1,v.length),I>u&&({lineCount:I,removals:L}=D(0,P))),L>0&&(x=!0,v.splice(0,L)),G>0&&(y=!0,v.splice(v.length-G,G))}let F=[];x&&F.push(d);for(let L of v)for(let G of L)F.push(G);return y&&F.push(d),F};ar=e=>new Gt({options:e.options,initialValue:e.initialValue?[e.initialValue]:void 0,initialUserInput:e.initialUserInput,filter:e.filter??((t,s)=>or(t,s)),signal:e.signal,input:e.input,output:e.output,validate:e.validate,render(){let t=e.withGuide??re.withGuide,s=t?[`${(0,m.styleText)("gray",E)}`,`${Ye(this.state)} ${e.message}`]:[`${Ye(this.state)} ${e.message}`],i=this.userInput,n=this.options,r=e.placeholder,o=i===""&&r!==void 0,a=(l,d)=>{let u=Jn(l),p=l.hint&&l.value===this.focusedValue?(0,m.styleText)("dim",` (${l.hint})`):"";switch(d){case"active":return`${(0,m.styleText)("green",zt)} ${u}${p}`;case"inactive":return`${(0,m.styleText)("dim",jt)} ${(0,m.styleText)("dim",u)}`;case"disabled":return`${(0,m.styleText)("gray",jt)} ${(0,m.styleText)(["strikethrough","gray"],u)}`}};switch(this.state){case"submit":{let l=Sa(this.selectedValues,n),d=l.length>0?` ${(0,m.styleText)("dim",l.map(Jn).join(", "))}`:"",u=t?(0,m.styleText)("gray",E):"";return`${s.join(`
52
52
  `)}
53
- ${u}${c}`}case"cancel":{let l=s?` ${(0,f.styleText)(["strikethrough","dim"],s)}`:"",c=t?(0,f.styleText)("gray",R):"";return`${i.join(`
53
+ ${u}${d}`}case"cancel":{let l=i?` ${(0,m.styleText)(["strikethrough","dim"],i)}`:"",d=t?(0,m.styleText)("gray",E):"";return`${s.join(`
54
54
  `)}
55
- ${c}${l}`}default:{let l=this.state==="error"?"yellow":"cyan",c=t?`${(0,f.styleText)(l,R)} `:"",u=t?(0,f.styleText)(l,we):"",p="";if(this.isNavigating||o){let C=o?r:s;p=C!==""?` ${(0,f.styleText)("dim",C)}`:""}else p=` ${this.userInputWithCursor}`;let g=this.filteredOptions.length!==n.length?(0,f.styleText)("dim",` (${this.filteredOptions.length} match${this.filteredOptions.length===1?"":"es"})`):"",_=this.filteredOptions.length===0&&s?[`${c}${(0,f.styleText)("yellow","No matches found")}`]:[],y=this.state==="error"?[`${c}${(0,f.styleText)("yellow",this.error)}`]:[];t&&i.push(`${c.trimEnd()}`),i.push(`${c}${(0,f.styleText)("dim","Search:")}${p}${g}`,..._,...y);let m=[`${(0,f.styleText)("dim","\u2191/\u2193")} to select`,`${(0,f.styleText)("dim","Enter:")} confirm`,`${(0,f.styleText)("dim","Type:")} to search`],v=[`${c}${m.join(" \u2022 ")}`,u],x=this.filteredOptions.length===0?[]:Ft({cursor:this.cursor,options:this.filteredOptions,columnPadding:t?3:0,rowPadding:i.length+v.length,style:(C,E)=>a(C,C.disabled?"disabled":E?"active":"inactive"),maxItems:e.maxItems,output:e.output});return[...i,...x.map(C=>`${c}${C}`),...v].join(`
56
- `)}}}}).prompt(),ja=e=>{let t=(s,n,r,o)=>{let a=r.includes(s.value),l=s.label??String(s.value??""),c=s.hint&&o!==void 0&&s.value===o?(0,f.styleText)("dim",` (${s.hint})`):"",u=a?(0,f.styleText)("green",xt):(0,f.styleText)("dim",Dt);return s.disabled?`${(0,f.styleText)("gray",Dt)} ${(0,f.styleText)(["strikethrough","gray"],l)}`:n?`${u} ${l}${c}`:`${u} ${(0,f.styleText)("dim",l)}`},i=new Bt({options:e.options,multiple:!0,filter:e.filter??((s,n)=>nr(s,n)),validate:()=>{if(e.required&&i.selectedValues.length===0)return"Please select at least one item"},initialValue:e.initialValues,signal:e.signal,input:e.input,output:e.output,render(){let s=`${(0,f.styleText)("gray",R)}
57
- ${Be(this.state)} ${e.message}
58
- `,n=this.userInput,r=e.placeholder,o=n===""&&r!==void 0,a=this.isNavigating||o?(0,f.styleText)("dim",o?r:n):this.userInputWithCursor,l=this.options,c=this.filteredOptions.length!==l.length?(0,f.styleText)("dim",` (${this.filteredOptions.length} match${this.filteredOptions.length===1?"":"es"})`):"";switch(this.state){case"submit":return`${s}${(0,f.styleText)("gray",R)} ${(0,f.styleText)("dim",`${this.selectedValues.length} items selected`)}`;case"cancel":return`${s}${(0,f.styleText)("gray",R)} ${(0,f.styleText)(["strikethrough","dim"],n)}`;default:{let u=this.state==="error"?"yellow":"cyan",p=[`${(0,f.styleText)("dim","\u2191/\u2193")} to navigate`,`${(0,f.styleText)("dim",this.isNavigating?"Space/Tab:":"Tab:")} select`,`${(0,f.styleText)("dim","Enter:")} confirm`,`${(0,f.styleText)("dim","Type:")} to search`],g=this.filteredOptions.length===0&&n?[`${(0,f.styleText)(u,R)} ${(0,f.styleText)("yellow","No matches found")}`]:[],_=this.state==="error"?[`${(0,f.styleText)(u,R)} ${(0,f.styleText)("yellow",this.error)}`]:[],y=[...`${s}${(0,f.styleText)(u,R)}`.split(`
59
- `),`${(0,f.styleText)(u,R)} ${(0,f.styleText)("dim","Search:")} ${a}${c}`,...g,..._],m=[`${(0,f.styleText)(u,R)} ${p.join(" \u2022 ")}`,(0,f.styleText)(u,we)],v=Ft({cursor:this.cursor,options:this.filteredOptions,style:(x,C)=>t(x,C,this.selectedValues,this.focusedValue),maxItems:e.maxItems,output:e.output,rowPadding:y.length+m.length});return[...y,...v.map(x=>`${(0,f.styleText)(u,R)} ${x}`),...m].join(`
60
- `)}}}});return i.prompt()},Sa=[Qn,Os,Rs,As],Ca=[Cs,Kn,we,zn];Oa=e=>e,Aa=(e="",t="",i)=>{let s=i?.output??process.stdout,n=wt(s),r=2,o=i?.titlePadding??1,a=i?.contentPadding??2,l=i?.width===void 0||i.width==="auto"?1:Math.min(1,i.width),c=i?.withGuide??re.withGuide?`${R} `:"",u=i?.formatBorder??Oa,p=(i?.rounded?Sa:Ca).map(u),g=u(Ai),_=u(R),y=Ee(c),m=Ee(t),v=n-y,x=Math.floor(n*l)-y;if(i?.width==="auto"){let N=e.split(`
61
- `),Y=m+o*2;for(let U of N){let te=Ee(U)+a*2;te>Y&&(Y=te)}let Z=Y+r;Z<x&&(x=Z)}x%2!==0&&(x<v?x++:x--);let C=x-r,E=C-o*2,V=m>E?`${t.slice(0,E-3)}...`:t,[L,G]=Hn(Ee(V),C,o,i?.titleAlign),I=Nt(e,C-a*2,{hard:!0,trim:!1});s.write(`${c}${p[0]}${g.repeat(L)}${V}${g.repeat(G)}${p[1]}
62
- `);let D=I.split(`
63
- `);for(let N of D){let[Y,Z]=Hn(Ee(N),C,a,i?.contentAlign);s.write(`${c}${_}${" ".repeat(Y)}${N}${" ".repeat(Z)}${_}
64
- `)}s.write(`${c}${p[2]}${g.repeat(C)}${p[3]}
65
- `)},We=e=>{let t=e.active??"Yes",i=e.inactive??"No";return new gi({active:t,inactive:i,signal:e.signal,input:e.input,output:e.output,initialValue:e.initialValue??!0,render(){let s=e.withGuide??re.withGuide,n=`${s?`${(0,f.styleText)("gray",R)}
66
- `:""}${Be(this.state)} ${e.message}
67
- `,r=this.value?t:i;switch(this.state){case"submit":{let o=s?`${(0,f.styleText)("gray",R)} `:"";return`${n}${o}${(0,f.styleText)("dim",r)}`}case"cancel":{let o=s?`${(0,f.styleText)("gray",R)} `:"";return`${n}${o}${(0,f.styleText)(["strikethrough","dim"],r)}${s?`
68
- ${(0,f.styleText)("gray",R)}`:""}`}default:{let o=s?`${(0,f.styleText)("cyan",R)} `:"",a=s?(0,f.styleText)("cyan",we):"";return`${n}${o}${this.value?`${(0,f.styleText)("green",Kt)} ${t}`:`${(0,f.styleText)("dim",jt)} ${(0,f.styleText)("dim",t)}`}${e.vertical?s?`
69
- ${(0,f.styleText)("cyan",R)} `:`
70
- `:` ${(0,f.styleText)("dim","/")} `}${this.value?`${(0,f.styleText)("dim",jt)} ${(0,f.styleText)("dim",i)}`:`${(0,f.styleText)("green",Kt)} ${i}`}
55
+ ${d}${l}`}default:{let l=this.state==="error"?"yellow":"cyan",d=t?`${(0,m.styleText)(l,E)} `:"",u=t?(0,m.styleText)(l,_e):"",p="";if(this.isNavigating||o){let C=o?r:i;p=C!==""?` ${(0,m.styleText)("dim",C)}`:""}else p=` ${this.userInputWithCursor}`;let g=this.filteredOptions.length!==n.length?(0,m.styleText)("dim",` (${this.filteredOptions.length} match${this.filteredOptions.length===1?"":"es"})`):"",x=this.filteredOptions.length===0&&i?[`${d}${(0,m.styleText)("yellow","No matches found")}`]:[],y=this.state==="error"?[`${d}${(0,m.styleText)("yellow",this.error)}`]:[];t&&s.push(`${d.trimEnd()}`),s.push(`${d}${(0,m.styleText)("dim","Search:")}${p}${g}`,...x,...y);let f=[`${(0,m.styleText)("dim","\u2191/\u2193")} to select`,`${(0,m.styleText)("dim","Enter:")} confirm`,`${(0,m.styleText)("dim","Type:")} to search`],v=[`${d}${f.join(" \u2022 ")}`,u],_=this.filteredOptions.length===0?[]:Ut({cursor:this.cursor,options:this.filteredOptions,columnPadding:t?3:0,rowPadding:s.length+v.length,style:(C,A)=>a(C,C.disabled?"disabled":A?"active":"inactive"),maxItems:e.maxItems,output:e.output});return[...s,..._.map(C=>`${d}${C}`),...v].join(`
56
+ `)}}}}).prompt(),Ca=e=>{let t=(i,n,r,o)=>{let a=r.includes(i.value),l=i.label??String(i.value??""),d=i.hint&&o!==void 0&&i.value===o?(0,m.styleText)("dim",` (${i.hint})`):"",u=a?(0,m.styleText)("green",xt):(0,m.styleText)("dim",Ft);return i.disabled?`${(0,m.styleText)("gray",Ft)} ${(0,m.styleText)(["strikethrough","gray"],l)}`:n?`${u} ${l}${d}`:`${u} ${(0,m.styleText)("dim",l)}`},s=new Gt({options:e.options,multiple:!0,filter:e.filter??((i,n)=>or(i,n)),validate:()=>{if(e.required&&s.selectedValues.length===0)return"Please select at least one item"},initialValue:e.initialValues,signal:e.signal,input:e.input,output:e.output,render(){let i=`${(0,m.styleText)("gray",E)}
57
+ ${Ye(this.state)} ${e.message}
58
+ `,n=this.userInput,r=e.placeholder,o=n===""&&r!==void 0,a=this.isNavigating||o?(0,m.styleText)("dim",o?r:n):this.userInputWithCursor,l=this.options,d=this.filteredOptions.length!==l.length?(0,m.styleText)("dim",` (${this.filteredOptions.length} match${this.filteredOptions.length===1?"":"es"})`):"";switch(this.state){case"submit":return`${i}${(0,m.styleText)("gray",E)} ${(0,m.styleText)("dim",`${this.selectedValues.length} items selected`)}`;case"cancel":return`${i}${(0,m.styleText)("gray",E)} ${(0,m.styleText)(["strikethrough","dim"],n)}`;default:{let u=this.state==="error"?"yellow":"cyan",p=[`${(0,m.styleText)("dim","\u2191/\u2193")} to navigate`,`${(0,m.styleText)("dim",this.isNavigating?"Space/Tab:":"Tab:")} select`,`${(0,m.styleText)("dim","Enter:")} confirm`,`${(0,m.styleText)("dim","Type:")} to search`],g=this.filteredOptions.length===0&&n?[`${(0,m.styleText)(u,E)} ${(0,m.styleText)("yellow","No matches found")}`]:[],x=this.state==="error"?[`${(0,m.styleText)(u,E)} ${(0,m.styleText)("yellow",this.error)}`]:[],y=[...`${i}${(0,m.styleText)(u,E)}`.split(`
59
+ `),`${(0,m.styleText)(u,E)} ${(0,m.styleText)("dim","Search:")} ${a}${d}`,...g,...x],f=[`${(0,m.styleText)(u,E)} ${p.join(" \u2022 ")}`,(0,m.styleText)(u,_e)],v=Ut({cursor:this.cursor,options:this.filteredOptions,style:(_,C)=>t(_,C,this.selectedValues,this.focusedValue),maxItems:e.maxItems,output:e.output,rowPadding:y.length+f.length});return[...y,...v.map(_=>`${(0,m.styleText)(u,E)} ${_}`),...f].join(`
60
+ `)}}}});return s.prompt()},Oa=[tr,Ri,Ei,Ai],Ra=[Oi,Xn,_e,Zn];Aa=e=>e,Ea=(e="",t="",s)=>{let i=s?.output??process.stdout,n=wt(i),r=2,o=s?.titlePadding??1,a=s?.contentPadding??2,l=s?.width===void 0||s.width==="auto"?1:Math.min(1,s.width),d=s?.withGuide??re.withGuide?`${E} `:"",u=s?.formatBorder??Aa,p=(s?.rounded?Oa:Ra).map(u),g=u(Rs),x=u(E),y=Ie(d),f=Ie(t),v=n-y,_=Math.floor(n*l)-y;if(s?.width==="auto"){let D=e.split(`
61
+ `),Y=f+o*2;for(let V of D){let te=Ie(V)+a*2;te>Y&&(Y=te)}let Z=Y+r;Z<_&&(_=Z)}_%2!==0&&(_<v?_++:_--);let C=_-r,A=C-o*2,F=f>A?`${t.slice(0,A-3)}...`:t,[L,G]=Bn(Ie(F),C,o,s?.titleAlign),I=Lt(e,C-a*2,{hard:!0,trim:!1});i.write(`${d}${p[0]}${g.repeat(L)}${F}${g.repeat(G)}${p[1]}
62
+ `);let P=I.split(`
63
+ `);for(let D of P){let[Y,Z]=Bn(Ie(D),C,a,s?.contentAlign);i.write(`${d}${x}${" ".repeat(Y)}${D}${" ".repeat(Z)}${x}
64
+ `)}i.write(`${d}${p[2]}${g.repeat(C)}${p[3]}
65
+ `)},He=e=>{let t=e.active??"Yes",s=e.inactive??"No";return new gs({active:t,inactive:s,signal:e.signal,input:e.input,output:e.output,initialValue:e.initialValue??!0,render(){let i=e.withGuide??re.withGuide,n=`${i?`${(0,m.styleText)("gray",E)}
66
+ `:""}${Ye(this.state)} ${e.message}
67
+ `,r=this.value?t:s;switch(this.state){case"submit":{let o=i?`${(0,m.styleText)("gray",E)} `:"";return`${n}${o}${(0,m.styleText)("dim",r)}`}case"cancel":{let o=i?`${(0,m.styleText)("gray",E)} `:"";return`${n}${o}${(0,m.styleText)(["strikethrough","dim"],r)}${i?`
68
+ ${(0,m.styleText)("gray",E)}`:""}`}default:{let o=i?`${(0,m.styleText)("cyan",E)} `:"",a=i?(0,m.styleText)("cyan",_e):"";return`${n}${o}${this.value?`${(0,m.styleText)("green",zt)} ${t}`:`${(0,m.styleText)("dim",jt)} ${(0,m.styleText)("dim",t)}`}${e.vertical?i?`
69
+ ${(0,m.styleText)("cyan",E)} `:`
70
+ `:` ${(0,m.styleText)("dim","/")} `}${this.value?`${(0,m.styleText)("dim",jt)} ${(0,m.styleText)("dim",s)}`:`${(0,m.styleText)("green",zt)} ${s}`}
71
71
  ${a}
72
- `}}}}).prompt()},Ra=async(e,t)=>{let i={},s=Object.keys(e);for(let n of s){let r=e[n],o=await r({results:i})?.catch(a=>{throw a});if(typeof t?.onCancel=="function"&&oe(o)){i[n]="canceled",t.onCancel({results:i});continue}i[n]=o}return i},Ea=e=>{let{selectableGroups:t=!0,groupSpacing:i=0}=e,s=(r,o,a=[])=>{let l=r.label??String(r.value),c=typeof r.group=="string",u=c&&(a[a.indexOf(r)+1]??{group:!0}),p=c&&u&&u.group===!0,g=c?t?`${p?we:R} `:" ":"",_="";if(i>0&&!c){let m=`
73
- ${(0,f.styleText)("cyan",R)}`;_=`${m.repeat(i-1)}${m} `}if(o==="active")return`${_}${(0,f.styleText)("dim",g)}${(0,f.styleText)("cyan",Oi)} ${l}${r.hint?` ${(0,f.styleText)("dim",`(${r.hint})`)}`:""}`;if(o==="group-active")return`${_}${g}${(0,f.styleText)("cyan",Oi)} ${(0,f.styleText)("dim",l)}`;if(o==="group-active-selected")return`${_}${g}${(0,f.styleText)("green",xt)} ${(0,f.styleText)("dim",l)}`;if(o==="selected"){let m=c||t?(0,f.styleText)("green",xt):"";return`${_}${(0,f.styleText)("dim",g)}${m} ${(0,f.styleText)("dim",l)}${r.hint?` ${(0,f.styleText)("dim",`(${r.hint})`)}`:""}`}if(o==="cancelled")return`${(0,f.styleText)(["strikethrough","dim"],l)}`;if(o==="active-selected")return`${_}${(0,f.styleText)("dim",g)}${(0,f.styleText)("green",xt)} ${l}${r.hint?` ${(0,f.styleText)("dim",`(${r.hint})`)}`:""}`;if(o==="submitted")return`${(0,f.styleText)("dim",l)}`;let y=c||t?(0,f.styleText)("dim",Dt):"";return`${_}${(0,f.styleText)("dim",g)}${y} ${(0,f.styleText)("dim",l)}`},n=e.required??!0;return new $i({options:e.options,signal:e.signal,input:e.input,output:e.output,initialValues:e.initialValues,required:n,cursorAt:e.cursorAt,selectableGroups:t,validate(r){if(n&&(r===void 0||r.length===0))return`Please select at least one option.
74
- ${(0,f.styleText)("reset",(0,f.styleText)("dim",`Press ${(0,f.styleText)(["gray","bgWhite","inverse"]," space ")} to select, ${(0,f.styleText)("gray",(0,f.styleText)(["bgWhite","inverse"]," enter "))} to submit`))}`},render(){let r=`${(0,f.styleText)("gray",R)}
75
- ${Be(this.state)} ${e.message}
76
- `,o=this.value??[];switch(this.state){case"submit":{let a=this.options.filter(({value:c})=>o.includes(c)).map(c=>s(c,"submitted")),l=a.length===0?"":` ${a.join((0,f.styleText)("dim",", "))}`;return`${r}${(0,f.styleText)("gray",R)}${l}`}case"cancel":{let a=this.options.filter(({value:l})=>o.includes(l)).map(l=>s(l,"cancelled")).join((0,f.styleText)("dim",", "));return`${r}${(0,f.styleText)("gray",R)} ${a.trim()?`${a}
77
- ${(0,f.styleText)("gray",R)}`:""}`}case"error":{let a=this.error.split(`
78
- `).map((l,c)=>c===0?`${(0,f.styleText)("yellow",we)} ${(0,f.styleText)("yellow",l)}`:` ${l}`).join(`
79
- `);return`${r}${(0,f.styleText)("yellow",R)} ${this.options.map((l,c,u)=>{let p=o.includes(l.value)||l.group===!0&&this.isGroupSelected(`${l.value}`),g=c===this.cursor;return!g&&typeof l.group=="string"&&this.options[this.cursor].value===l.group?s(l,p?"group-active-selected":"group-active",u):g&&p?s(l,"active-selected",u):p?s(l,"selected",u):s(l,g?"active":"inactive",u)}).join(`
80
- ${(0,f.styleText)("yellow",R)} `)}
72
+ `}}}}).prompt()},Ia=async(e,t)=>{let s={},i=Object.keys(e);for(let n of i){let r=e[n],o=await r({results:s})?.catch(a=>{throw a});if(typeof t?.onCancel=="function"&&oe(o)){s[n]="canceled",t.onCancel({results:s});continue}s[n]=o}return s},Ta=e=>{let{selectableGroups:t=!0,groupSpacing:s=0}=e,i=(r,o,a=[])=>{let l=r.label??String(r.value),d=typeof r.group=="string",u=d&&(a[a.indexOf(r)+1]??{group:!0}),p=d&&u&&u.group===!0,g=d?t?`${p?_e:E} `:" ":"",x="";if(s>0&&!d){let f=`
73
+ ${(0,m.styleText)("cyan",E)}`;x=`${f.repeat(s-1)}${f} `}if(o==="active")return`${x}${(0,m.styleText)("dim",g)}${(0,m.styleText)("cyan",Os)} ${l}${r.hint?` ${(0,m.styleText)("dim",`(${r.hint})`)}`:""}`;if(o==="group-active")return`${x}${g}${(0,m.styleText)("cyan",Os)} ${(0,m.styleText)("dim",l)}`;if(o==="group-active-selected")return`${x}${g}${(0,m.styleText)("green",xt)} ${(0,m.styleText)("dim",l)}`;if(o==="selected"){let f=d||t?(0,m.styleText)("green",xt):"";return`${x}${(0,m.styleText)("dim",g)}${f} ${(0,m.styleText)("dim",l)}${r.hint?` ${(0,m.styleText)("dim",`(${r.hint})`)}`:""}`}if(o==="cancelled")return`${(0,m.styleText)(["strikethrough","dim"],l)}`;if(o==="active-selected")return`${x}${(0,m.styleText)("dim",g)}${(0,m.styleText)("green",xt)} ${l}${r.hint?` ${(0,m.styleText)("dim",`(${r.hint})`)}`:""}`;if(o==="submitted")return`${(0,m.styleText)("dim",l)}`;let y=d||t?(0,m.styleText)("dim",Ft):"";return`${x}${(0,m.styleText)("dim",g)}${y} ${(0,m.styleText)("dim",l)}`},n=e.required??!0;return new $s({options:e.options,signal:e.signal,input:e.input,output:e.output,initialValues:e.initialValues,required:n,cursorAt:e.cursorAt,selectableGroups:t,validate(r){if(n&&(r===void 0||r.length===0))return`Please select at least one option.
74
+ ${(0,m.styleText)("reset",(0,m.styleText)("dim",`Press ${(0,m.styleText)(["gray","bgWhite","inverse"]," space ")} to select, ${(0,m.styleText)("gray",(0,m.styleText)(["bgWhite","inverse"]," enter "))} to submit`))}`},render(){let r=`${(0,m.styleText)("gray",E)}
75
+ ${Ye(this.state)} ${e.message}
76
+ `,o=this.value??[];switch(this.state){case"submit":{let a=this.options.filter(({value:d})=>o.includes(d)).map(d=>i(d,"submitted")),l=a.length===0?"":` ${a.join((0,m.styleText)("dim",", "))}`;return`${r}${(0,m.styleText)("gray",E)}${l}`}case"cancel":{let a=this.options.filter(({value:l})=>o.includes(l)).map(l=>i(l,"cancelled")).join((0,m.styleText)("dim",", "));return`${r}${(0,m.styleText)("gray",E)} ${a.trim()?`${a}
77
+ ${(0,m.styleText)("gray",E)}`:""}`}case"error":{let a=this.error.split(`
78
+ `).map((l,d)=>d===0?`${(0,m.styleText)("yellow",_e)} ${(0,m.styleText)("yellow",l)}`:` ${l}`).join(`
79
+ `);return`${r}${(0,m.styleText)("yellow",E)} ${this.options.map((l,d,u)=>{let p=o.includes(l.value)||l.group===!0&&this.isGroupSelected(`${l.value}`),g=d===this.cursor;return!g&&typeof l.group=="string"&&this.options[this.cursor].value===l.group?i(l,p?"group-active-selected":"group-active",u):g&&p?i(l,"active-selected",u):p?i(l,"selected",u):i(l,g?"active":"inactive",u)}).join(`
80
+ ${(0,m.styleText)("yellow",E)} `)}
81
81
  ${a}
82
- `}default:{let a=this.options.map((c,u,p)=>{let g=o.includes(c.value)||c.group===!0&&this.isGroupSelected(`${c.value}`),_=u===this.cursor,y=!_&&typeof c.group=="string"&&this.options[this.cursor].value===c.group,m="";return y?m=s(c,g?"group-active-selected":"group-active",p):_&&g?m=s(c,"active-selected",p):g?m=s(c,"selected",p):m=s(c,_?"active":"inactive",p),`${u!==0&&!m.startsWith(`
83
- `)?" ":""}${m}`}).join(`
84
- ${(0,f.styleText)("cyan",R)}`),l=a.startsWith(`
85
- `)?"":" ";return`${r}${(0,f.styleText)("cyan",R)}${l}${a}
86
- ${(0,f.styleText)("cyan",we)}
87
- `}}}}).prompt()},Fe={message:(e=[],{symbol:t=(0,f.styleText)("gray",R),secondarySymbol:i=(0,f.styleText)("gray",R),output:s=process.stdout,spacing:n=1,withGuide:r}={})=>{let o=[],a=r??re.withGuide,l=a?i:"",c=a?`${t} `:"",u=a?`${i} `:"";for(let g=0;g<n;g++)o.push(l);let p=Array.isArray(e)?e:e.split(`
88
- `);if(p.length>0){let[g,..._]=p;g.length>0?o.push(`${c}${g}`):o.push(a?t:"");for(let y of _)y.length>0?o.push(`${u}${y}`):o.push(a?i:"")}s.write(`${o.join(`
82
+ `}default:{let a=this.options.map((d,u,p)=>{let g=o.includes(d.value)||d.group===!0&&this.isGroupSelected(`${d.value}`),x=u===this.cursor,y=!x&&typeof d.group=="string"&&this.options[this.cursor].value===d.group,f="";return y?f=i(d,g?"group-active-selected":"group-active",p):x&&g?f=i(d,"active-selected",p):g?f=i(d,"selected",p):f=i(d,x?"active":"inactive",p),`${u!==0&&!f.startsWith(`
83
+ `)?" ":""}${f}`}).join(`
84
+ ${(0,m.styleText)("cyan",E)}`),l=a.startsWith(`
85
+ `)?"":" ";return`${r}${(0,m.styleText)("cyan",E)}${l}${a}
86
+ ${(0,m.styleText)("cyan",_e)}
87
+ `}}}}).prompt()},Le={message:(e=[],{symbol:t=(0,m.styleText)("gray",E),secondarySymbol:s=(0,m.styleText)("gray",E),output:i=process.stdout,spacing:n=1,withGuide:r}={})=>{let o=[],a=r??re.withGuide,l=a?s:"",d=a?`${t} `:"",u=a?`${s} `:"";for(let g=0;g<n;g++)o.push(l);let p=Array.isArray(e)?e:e.split(`
88
+ `);if(p.length>0){let[g,...x]=p;g.length>0?o.push(`${d}${g}`):o.push(a?t:"");for(let y of x)y.length>0?o.push(`${u}${y}`):o.push(a?s:"")}i.write(`${o.join(`
89
89
  `)}
90
- `)},info:(e,t)=>{Fe.message(e,{...t,symbol:(0,f.styleText)("blue",Es)})},success:(e,t)=>{Fe.message(e,{...t,symbol:(0,f.styleText)("green",Is)})},step:(e,t)=>{Fe.message(e,{...t,symbol:(0,f.styleText)("green",St)})},warn:(e,t)=>{Fe.message(e,{...t,symbol:(0,f.styleText)("yellow",Ts)})},warning:(e,t)=>{Fe.warn(e,t)},error:(e,t)=>{Fe.message(e,{...t,symbol:(0,f.styleText)("red",Ps)})}},Ia=(e="",t)=>{let i=t?.output??process.stdout,s=t?.withGuide??re.withGuide?`${(0,f.styleText)("gray",we)} `:"";i.write(`${s}${(0,f.styleText)("red",e)}
90
+ `)},info:(e,t)=>{Le.message(e,{...t,symbol:(0,m.styleText)("blue",Ii)})},success:(e,t)=>{Le.message(e,{...t,symbol:(0,m.styleText)("green",Ti)})},step:(e,t)=>{Le.message(e,{...t,symbol:(0,m.styleText)("green",St)})},warn:(e,t)=>{Le.message(e,{...t,symbol:(0,m.styleText)("yellow",Pi)})},warning:(e,t)=>{Le.warn(e,t)},error:(e,t)=>{Le.message(e,{...t,symbol:(0,m.styleText)("red",Di)})}},Pa=(e="",t)=>{let s=t?.output??process.stdout,i=t?.withGuide??re.withGuide?`${(0,m.styleText)("gray",_e)} `:"";s.write(`${i}${(0,m.styleText)("red",e)}
91
91
 
92
- `)},Ta=(e="",t)=>{let i=t?.output??process.stdout,s=t?.withGuide??re.withGuide?`${(0,f.styleText)("gray",Cs)} `:"";i.write(`${s}${e}
93
- `)},Pa=(e="",t)=>{let i=t?.output??process.stdout,s=t?.withGuide??re.withGuide?`${(0,f.styleText)("gray",R)}
94
- ${(0,f.styleText)("gray",we)} `:"";i.write(`${s}${e}
92
+ `)},Da=(e="",t)=>{let s=t?.output??process.stdout,i=t?.withGuide??re.withGuide?`${(0,m.styleText)("gray",Oi)} `:"";s.write(`${i}${e}
93
+ `)},Na=(e="",t)=>{let s=t?.output??process.stdout,i=t?.withGuide??re.withGuide?`${(0,m.styleText)("gray",E)}
94
+ ${(0,m.styleText)("gray",_e)} `:"";s.write(`${i}${e}
95
95
 
96
- `)},Gt=(e,t)=>e.split(`
97
- `).map(i=>t(i)).join(`
98
- `),Da=e=>{let t=(s,n)=>{let r=s.label??String(s.value);return n==="disabled"?`${(0,f.styleText)("gray",Dt)} ${Gt(r,o=>(0,f.styleText)(["strikethrough","gray"],o))}${s.hint?` ${(0,f.styleText)("dim",`(${s.hint??"disabled"})`)}`:""}`:n==="active"?`${(0,f.styleText)("cyan",Oi)} ${r}${s.hint?` ${(0,f.styleText)("dim",`(${s.hint})`)}`:""}`:n==="selected"?`${(0,f.styleText)("green",xt)} ${Gt(r,o=>(0,f.styleText)("dim",o))}${s.hint?` ${(0,f.styleText)("dim",`(${s.hint})`)}`:""}`:n==="cancelled"?`${Gt(r,o=>(0,f.styleText)(["strikethrough","dim"],o))}`:n==="active-selected"?`${(0,f.styleText)("green",xt)} ${r}${s.hint?` ${(0,f.styleText)("dim",`(${s.hint})`)}`:""}`:n==="submitted"?`${Gt(r,o=>(0,f.styleText)("dim",o))}`:`${(0,f.styleText)("dim",Dt)} ${Gt(r,o=>(0,f.styleText)("dim",o))}`},i=e.required??!0;return new Vn({options:e.options,signal:e.signal,input:e.input,output:e.output,initialValues:e.initialValues,required:i,cursorAt:e.cursorAt,validate(s){if(i&&(s===void 0||s.length===0))return`Please select at least one option.
99
- ${(0,f.styleText)("reset",(0,f.styleText)("dim",`Press ${(0,f.styleText)(["gray","bgWhite","inverse"]," space ")} to select, ${(0,f.styleText)("gray",(0,f.styleText)("bgWhite",(0,f.styleText)("inverse"," enter ")))} to submit`))}`},render(){let s=Ze(e.output,e.message,`${Ds(this.state)} `,`${Be(this.state)} `),n=`${(0,f.styleText)("gray",R)}
100
- ${s}
101
- `,r=this.value??[],o=(a,l)=>{if(a.disabled)return t(a,"disabled");let c=r.includes(a.value);return l&&c?t(a,"active-selected"):c?t(a,"selected"):t(a,l?"active":"inactive")};switch(this.state){case"submit":{let a=this.options.filter(({value:c})=>r.includes(c)).map(c=>t(c,"submitted")).join((0,f.styleText)("dim",", "))||(0,f.styleText)("dim","none"),l=Ze(e.output,a,`${(0,f.styleText)("gray",R)} `);return`${n}${l}`}case"cancel":{let a=this.options.filter(({value:c})=>r.includes(c)).map(c=>t(c,"cancelled")).join((0,f.styleText)("dim",", "));if(a.trim()==="")return`${n}${(0,f.styleText)("gray",R)}`;let l=Ze(e.output,a,`${(0,f.styleText)("gray",R)} `);return`${n}${l}
102
- ${(0,f.styleText)("gray",R)}`}case"error":{let a=`${(0,f.styleText)("yellow",R)} `,l=this.error.split(`
103
- `).map((p,g)=>g===0?`${(0,f.styleText)("yellow",we)} ${(0,f.styleText)("yellow",p)}`:` ${p}`).join(`
104
- `),c=n.split(`
96
+ `)},Yt=(e,t)=>e.split(`
97
+ `).map(s=>t(s)).join(`
98
+ `),Fa=e=>{let t=(i,n)=>{let r=i.label??String(i.value);return n==="disabled"?`${(0,m.styleText)("gray",Ft)} ${Yt(r,o=>(0,m.styleText)(["strikethrough","gray"],o))}${i.hint?` ${(0,m.styleText)("dim",`(${i.hint??"disabled"})`)}`:""}`:n==="active"?`${(0,m.styleText)("cyan",Os)} ${r}${i.hint?` ${(0,m.styleText)("dim",`(${i.hint})`)}`:""}`:n==="selected"?`${(0,m.styleText)("green",xt)} ${Yt(r,o=>(0,m.styleText)("dim",o))}${i.hint?` ${(0,m.styleText)("dim",`(${i.hint})`)}`:""}`:n==="cancelled"?`${Yt(r,o=>(0,m.styleText)(["strikethrough","dim"],o))}`:n==="active-selected"?`${(0,m.styleText)("green",xt)} ${r}${i.hint?` ${(0,m.styleText)("dim",`(${i.hint})`)}`:""}`:n==="submitted"?`${Yt(r,o=>(0,m.styleText)("dim",o))}`:`${(0,m.styleText)("dim",Ft)} ${Yt(r,o=>(0,m.styleText)("dim",o))}`},s=e.required??!0;return new Mn({options:e.options,signal:e.signal,input:e.input,output:e.output,initialValues:e.initialValues,required:s,cursorAt:e.cursorAt,validate(i){if(s&&(i===void 0||i.length===0))return`Please select at least one option.
99
+ ${(0,m.styleText)("reset",(0,m.styleText)("dim",`Press ${(0,m.styleText)(["gray","bgWhite","inverse"]," space ")} to select, ${(0,m.styleText)("gray",(0,m.styleText)("bgWhite",(0,m.styleText)("inverse"," enter ")))} to submit`))}`},render(){let i=et(e.output,e.message,`${Ni(this.state)} `,`${Ye(this.state)} `),n=`${(0,m.styleText)("gray",E)}
100
+ ${i}
101
+ `,r=this.value??[],o=(a,l)=>{if(a.disabled)return t(a,"disabled");let d=r.includes(a.value);return l&&d?t(a,"active-selected"):d?t(a,"selected"):t(a,l?"active":"inactive")};switch(this.state){case"submit":{let a=this.options.filter(({value:d})=>r.includes(d)).map(d=>t(d,"submitted")).join((0,m.styleText)("dim",", "))||(0,m.styleText)("dim","none"),l=et(e.output,a,`${(0,m.styleText)("gray",E)} `);return`${n}${l}`}case"cancel":{let a=this.options.filter(({value:d})=>r.includes(d)).map(d=>t(d,"cancelled")).join((0,m.styleText)("dim",", "));if(a.trim()==="")return`${n}${(0,m.styleText)("gray",E)}`;let l=et(e.output,a,`${(0,m.styleText)("gray",E)} `);return`${n}${l}
102
+ ${(0,m.styleText)("gray",E)}`}case"error":{let a=`${(0,m.styleText)("yellow",E)} `,l=this.error.split(`
103
+ `).map((p,g)=>g===0?`${(0,m.styleText)("yellow",_e)} ${(0,m.styleText)("yellow",p)}`:` ${p}`).join(`
104
+ `),d=n.split(`
105
105
  `).length,u=l.split(`
106
- `).length+1;return`${n}${a}${Ft({output:e.output,options:this.options,cursor:this.cursor,maxItems:e.maxItems,columnPadding:a.length,rowPadding:c+u,style:o}).join(`
106
+ `).length+1;return`${n}${a}${Ut({output:e.output,options:this.options,cursor:this.cursor,maxItems:e.maxItems,columnPadding:a.length,rowPadding:d+u,style:o}).join(`
107
107
  ${a}`)}
108
108
  ${l}
109
- `}default:{let a=`${(0,f.styleText)("cyan",R)} `,l=n.split(`
110
- `).length;return`${n}${a}${Ft({output:e.output,options:this.options,cursor:this.cursor,maxItems:e.maxItems,columnPadding:a.length,rowPadding:l+2,style:o}).join(`
109
+ `}default:{let a=`${(0,m.styleText)("cyan",E)} `,l=n.split(`
110
+ `).length;return`${n}${a}${Ut({output:e.output,options:this.options,cursor:this.cursor,maxItems:e.maxItems,columnPadding:a.length,rowPadding:l+2,style:o}).join(`
111
111
  ${a}`)}
112
- ${(0,f.styleText)("cyan",we)}
113
- `}}}}).prompt()},Na=e=>(0,f.styleText)("dim",e),Fa=(e,t,i)=>{let s={hard:!0,trim:!1},n=Nt(e,t,s).split(`
114
- `),r=n.reduce((l,c)=>Math.max(Ee(c),l),0),o=n.map(i).reduce((l,c)=>Math.max(Ee(c),l),0),a=t-(o-r);return Nt(e,a,s)},La=(e="",t="",i)=>{let s=i?.output??Ne.default.stdout,n=i?.withGuide??re.withGuide,r=i?.format??Na,o=["",...Fa(e,wt(s)-6,r).split(`
115
- `).map(r),""],a=Ee(t),l=Math.max(o.reduce((g,_)=>{let y=Ee(_);return y>g?y:g},0),a)+2,c=o.map(g=>`${(0,f.styleText)("gray",R)} ${g}${" ".repeat(l-Ee(g))}${(0,f.styleText)("gray",R)}`).join(`
116
- `),u=n?`${(0,f.styleText)("gray",R)}
117
- `:"",p=n?Zn:Rs;s.write(`${u}${(0,f.styleText)("green",St)} ${(0,f.styleText)("reset",t)} ${(0,f.styleText)("gray",Ai.repeat(Math.max(l-a-1,1))+Os)}
118
- ${c}
119
- ${(0,f.styleText)("gray",p+Ai.repeat(l+2)+As)}
120
- `)},Va=e=>new yi({validate:e.validate,mask:e.mask??Xn,signal:e.signal,input:e.input,output:e.output,render(){let t=e.withGuide??re.withGuide,i=`${t?`${(0,f.styleText)("gray",R)}
121
- `:""}${Be(this.state)} ${e.message}
122
- `,s=this.userInputWithCursor,n=this.masked;switch(this.state){case"error":{let r=t?`${(0,f.styleText)("yellow",R)} `:"",o=t?`${(0,f.styleText)("yellow",we)} `:"",a=n??"";return e.clearOnError&&this.clear(),`${i.trim()}
112
+ ${(0,m.styleText)("cyan",_e)}
113
+ `}}}}).prompt()},La=e=>(0,m.styleText)("dim",e),Ua=(e,t,s)=>{let i={hard:!0,trim:!1},n=Lt(e,t,i).split(`
114
+ `),r=n.reduce((l,d)=>Math.max(Ie(d),l),0),o=n.map(s).reduce((l,d)=>Math.max(Ie(d),l),0),a=t-(o-r);return Lt(e,a,i)},Va=(e="",t="",s)=>{let i=s?.output??Fe.default.stdout,n=s?.withGuide??re.withGuide,r=s?.format??La,o=["",...Ua(e,wt(i)-6,r).split(`
115
+ `).map(r),""],a=Ie(t),l=Math.max(o.reduce((g,x)=>{let y=Ie(x);return y>g?y:g},0),a)+2,d=o.map(g=>`${(0,m.styleText)("gray",E)} ${g}${" ".repeat(l-Ie(g))}${(0,m.styleText)("gray",E)}`).join(`
116
+ `),u=n?`${(0,m.styleText)("gray",E)}
117
+ `:"",p=n?er:Ei;i.write(`${u}${(0,m.styleText)("green",St)} ${(0,m.styleText)("reset",t)} ${(0,m.styleText)("gray",Rs.repeat(Math.max(l-a-1,1))+Ri)}
118
+ ${d}
119
+ ${(0,m.styleText)("gray",p+Rs.repeat(l+2)+Ai)}
120
+ `)},Ma=e=>new ys({validate:e.validate,mask:e.mask??Qn,signal:e.signal,input:e.input,output:e.output,render(){let t=e.withGuide??re.withGuide,s=`${t?`${(0,m.styleText)("gray",E)}
121
+ `:""}${Ye(this.state)} ${e.message}
122
+ `,i=this.userInputWithCursor,n=this.masked;switch(this.state){case"error":{let r=t?`${(0,m.styleText)("yellow",E)} `:"",o=t?`${(0,m.styleText)("yellow",_e)} `:"",a=n??"";return e.clearOnError&&this.clear(),`${s.trim()}
123
123
  ${r}${a}
124
- ${o}${(0,f.styleText)("yellow",this.error)}
125
- `}case"submit":{let r=t?`${(0,f.styleText)("gray",R)} `:"",o=n?(0,f.styleText)("dim",n):"";return`${i}${r}${o}`}case"cancel":{let r=t?`${(0,f.styleText)("gray",R)} `:"",o=n?(0,f.styleText)(["strikethrough","dim"],n):"";return`${i}${r}${o}${n&&t?`
126
- ${(0,f.styleText)("gray",R)}`:""}`}default:{let r=t?`${(0,f.styleText)("cyan",R)} `:"",o=t?(0,f.styleText)("cyan",we):"";return`${i}${r}${s}
124
+ ${o}${(0,m.styleText)("yellow",this.error)}
125
+ `}case"submit":{let r=t?`${(0,m.styleText)("gray",E)} `:"",o=n?(0,m.styleText)("dim",n):"";return`${s}${r}${o}`}case"cancel":{let r=t?`${(0,m.styleText)("gray",E)} `:"",o=n?(0,m.styleText)(["strikethrough","dim"],n):"";return`${s}${r}${o}${n&&t?`
126
+ ${(0,m.styleText)("gray",E)}`:""}`}default:{let r=t?`${(0,m.styleText)("cyan",E)} `:"",o=t?(0,m.styleText)("cyan",_e):"";return`${s}${r}${i}
127
127
  ${o}
128
- `}}}}).prompt(),Ua=e=>{let t=e.validate;return rr({...e,initialUserInput:e.initialValue??e.root??process.cwd(),maxItems:5,validate(i){if(!Array.isArray(i)){if(!i)return"Please select a path";if(t)return t(i)}},options(){let i=this.userInput;if(i==="")return[];try{let s;return(0,kt.existsSync)(i)?(0,kt.lstatSync)(i).isDirectory()?s=i:s=(0,Yt.dirname)(i):s=(0,Yt.dirname)(i),(0,kt.readdirSync)(s).map(n=>{let r=(0,Yt.join)(s,n),o=(0,kt.lstatSync)(r);return{name:n,path:r,isDirectory:o.isDirectory()}}).filter(({path:n,isDirectory:r})=>n.startsWith(i)&&(e.directory||!r)).map(n=>({value:n.path}))}catch{return[]}}})},Ma=e=>(0,f.styleText)("magenta",e),zt=({indicator:e="dots",onCancel:t,output:i=process.stdout,cancelMessage:s,errorMessage:n,frames:r=Ci?["\u25D2","\u25D0","\u25D3","\u25D1"]:["\u2022","o","O","0"],delay:o=Ci?80:120,signal:a,...l}={})=>{let c=ks(),u,p,g=!1,_=!1,y="",m,v=performance.now(),x=wt(i),C=l?.styleFrame??Ma,E=X=>{let le=X>1?n??re.messages.error:s??re.messages.cancel;_=X===1,g&&(te(le,X),_&&typeof t=="function"&&t())},V=()=>E(2),L=()=>E(1),G=()=>{process.on("uncaughtExceptionMonitor",V),process.on("unhandledRejection",V),process.on("SIGINT",L),process.on("SIGTERM",L),process.on("exit",E),a&&a.addEventListener("abort",L)},I=()=>{process.removeListener("uncaughtExceptionMonitor",V),process.removeListener("unhandledRejection",V),process.removeListener("SIGINT",L),process.removeListener("SIGTERM",L),process.removeListener("exit",E),a&&a.removeEventListener("abort",L)},D=()=>{if(m===void 0)return;c&&i.write(`
129
- `);let X=Nt(m,x,{hard:!0,trim:!1}).split(`
130
- `);X.length>1&&i.write(Pt.cursor.up(X.length-1)),i.write(Pt.cursor.to(0)),i.write(Pt.erase.down())},N=X=>X.replace(/\.+$/,""),Y=X=>{let le=(performance.now()-X)/1e3,q=Math.floor(le/60),K=Math.floor(le%60);return q>0?`[${q}m ${K}s]`:`[${K}s]`},Z=l.withGuide??re.withGuide,U=(X="")=>{g=!0,u=Ln({output:i}),y=N(X),v=performance.now(),Z&&i.write(`${(0,f.styleText)("gray",R)}
131
- `);let le=0,q=0;G(),p=setInterval(()=>{if(c&&y===m)return;D(),m=y;let K=C(r[le]),de;if(c)de=`${K} ${y}...`;else if(e==="timer")de=`${K} ${y} ${Y(v)}`;else{let Ce=".".repeat(Math.floor(q)).slice(0,3);de=`${K} ${y}${Ce}`}let fe=Nt(de,x,{hard:!0,trim:!1});i.write(fe),le=le+1<r.length?le+1:0,q=q<4?q+.125:0},o)},te=(X="",le=0,q=!1)=>{if(!g)return;g=!1,clearInterval(p),D();let K=le===0?(0,f.styleText)("green",St):le===1?(0,f.styleText)("red",js):(0,f.styleText)("red",Ss);y=X??y,q||(e==="timer"?i.write(`${K} ${y} ${Y(v)}
132
- `):i.write(`${K} ${y}
133
- `)),I(),u()};return{start:U,stop:(X="")=>te(X,0),message:(X="")=>{y=N(X??y)},cancel:(X="")=>te(X,1),error:(X="")=>te(X,2),clear:()=>te("",0,!0),get isCancelled(){return _}}},Jn={light:ne("\u2500","-"),heavy:ne("\u2501","="),block:ne("\u2588","#")};Si=(e,t)=>e.includes(`
128
+ `}}}}).prompt(),qa=e=>{let t=e.validate;return ar({...e,initialUserInput:e.initialValue??e.root??process.cwd(),maxItems:5,validate(s){if(!Array.isArray(s)){if(!s)return"Please select a path";if(t)return t(s)}},options(){let s=this.userInput;if(s==="")return[];try{let i;return(0,kt.existsSync)(s)?(0,kt.lstatSync)(s).isDirectory()?i=s:i=(0,Kt.dirname)(s):i=(0,Kt.dirname)(s),(0,kt.readdirSync)(i).map(n=>{let r=(0,Kt.join)(i,n),o=(0,kt.lstatSync)(r);return{name:n,path:r,isDirectory:o.isDirectory()}}).filter(({path:n,isDirectory:r})=>n.startsWith(s)&&(e.directory||!r)).map(n=>({value:n.path}))}catch{return[]}}})},Wa=e=>(0,m.styleText)("magenta",e),Xt=({indicator:e="dots",onCancel:t,output:s=process.stdout,cancelMessage:i,errorMessage:n,frames:r=Cs?["\u25D2","\u25D0","\u25D3","\u25D1"]:["\u2022","o","O","0"],delay:o=Cs?80:120,signal:a,...l}={})=>{let d=ji(),u,p,g=!1,x=!1,y="",f,v=performance.now(),_=wt(s),C=l?.styleFrame??Wa,A=X=>{let le=X>1?n??re.messages.error:i??re.messages.cancel;x=X===1,g&&(te(le,X),x&&typeof t=="function"&&t())},F=()=>A(2),L=()=>A(1),G=()=>{process.on("uncaughtExceptionMonitor",F),process.on("unhandledRejection",F),process.on("SIGINT",L),process.on("SIGTERM",L),process.on("exit",A),a&&a.addEventListener("abort",L)},I=()=>{process.removeListener("uncaughtExceptionMonitor",F),process.removeListener("unhandledRejection",F),process.removeListener("SIGINT",L),process.removeListener("SIGTERM",L),process.removeListener("exit",A),a&&a.removeEventListener("abort",L)},P=()=>{if(f===void 0)return;d&&s.write(`
129
+ `);let X=Lt(f,_,{hard:!0,trim:!1}).split(`
130
+ `);X.length>1&&s.write(Nt.cursor.up(X.length-1)),s.write(Nt.cursor.to(0)),s.write(Nt.erase.down())},D=X=>X.replace(/\.+$/,""),Y=X=>{let le=(performance.now()-X)/1e3,q=Math.floor(le/60),K=Math.floor(le%60);return q>0?`[${q}m ${K}s]`:`[${K}s]`},Z=l.withGuide??re.withGuide,V=(X="")=>{g=!0,u=Vn({output:s}),y=D(X),v=performance.now(),Z&&s.write(`${(0,m.styleText)("gray",E)}
131
+ `);let le=0,q=0;G(),p=setInterval(()=>{if(d&&y===f)return;P(),f=y;let K=C(r[le]),de;if(d)de=`${K} ${y}...`;else if(e==="timer")de=`${K} ${y} ${Y(v)}`;else{let Oe=".".repeat(Math.floor(q)).slice(0,3);de=`${K} ${y}${Oe}`}let fe=Lt(de,_,{hard:!0,trim:!1});s.write(fe),le=le+1<r.length?le+1:0,q=q<4?q+.125:0},o)},te=(X="",le=0,q=!1)=>{if(!g)return;g=!1,clearInterval(p),P();let K=le===0?(0,m.styleText)("green",St):le===1?(0,m.styleText)("red",Si):(0,m.styleText)("red",Ci);y=X??y,q||(e==="timer"?s.write(`${K} ${y} ${Y(v)}
132
+ `):s.write(`${K} ${y}
133
+ `)),I(),u()};return{start:V,stop:(X="")=>te(X,0),message:(X="")=>{y=D(X??y)},cancel:(X="")=>te(X,1),error:(X="")=>te(X,2),clear:()=>te("",0,!0),get isCancelled(){return x}}},Gn={light:ne("\u2500","-"),heavy:ne("\u2501","="),block:ne("\u2588","#")};Ss=(e,t)=>e.includes(`
134
134
  `)?e.split(`
135
- `).map(i=>t(i)).join(`
136
- `):t(e),Ge=e=>{let t=(i,s)=>{let n=i.label??String(i.value);switch(s){case"disabled":return`${(0,f.styleText)("gray",jt)} ${Si(n,r=>(0,f.styleText)("gray",r))}${i.hint?` ${(0,f.styleText)("dim",`(${i.hint??"disabled"})`)}`:""}`;case"selected":return`${Si(n,r=>(0,f.styleText)("dim",r))}`;case"active":return`${(0,f.styleText)("green",Kt)} ${n}${i.hint?` ${(0,f.styleText)("dim",`(${i.hint})`)}`:""}`;case"cancelled":return`${Si(n,r=>(0,f.styleText)(["strikethrough","dim"],r))}`;default:return`${(0,f.styleText)("dim",jt)} ${Si(n,r=>(0,f.styleText)("dim",r))}`}};return new bi({options:e.options,signal:e.signal,input:e.input,output:e.output,initialValue:e.initialValue,render(){let i=e.withGuide??re.withGuide,s=`${Be(this.state)} `,n=`${Ds(this.state)} `,r=Ze(e.output,e.message,n,s),o=`${i?`${(0,f.styleText)("gray",R)}
135
+ `).map(s=>t(s)).join(`
136
+ `):t(e),Ke=e=>{let t=(s,i)=>{let n=s.label??String(s.value);switch(i){case"disabled":return`${(0,m.styleText)("gray",jt)} ${Ss(n,r=>(0,m.styleText)("gray",r))}${s.hint?` ${(0,m.styleText)("dim",`(${s.hint??"disabled"})`)}`:""}`;case"selected":return`${Ss(n,r=>(0,m.styleText)("dim",r))}`;case"active":return`${(0,m.styleText)("green",zt)} ${n}${s.hint?` ${(0,m.styleText)("dim",`(${s.hint})`)}`:""}`;case"cancelled":return`${Ss(n,r=>(0,m.styleText)(["strikethrough","dim"],r))}`;default:return`${(0,m.styleText)("dim",jt)} ${Ss(n,r=>(0,m.styleText)("dim",r))}`}};return new bs({options:e.options,signal:e.signal,input:e.input,output:e.output,initialValue:e.initialValue,render(){let s=e.withGuide??re.withGuide,i=`${Ye(this.state)} `,n=`${Ni(this.state)} `,r=et(e.output,e.message,n,i),o=`${s?`${(0,m.styleText)("gray",E)}
137
137
  `:""}${r}
138
- `;switch(this.state){case"submit":{let a=i?`${(0,f.styleText)("gray",R)} `:"",l=Ze(e.output,t(this.options[this.cursor],"selected"),a);return`${o}${l}`}case"cancel":{let a=i?`${(0,f.styleText)("gray",R)} `:"",l=Ze(e.output,t(this.options[this.cursor],"cancelled"),a);return`${o}${l}${i?`
139
- ${(0,f.styleText)("gray",R)}`:""}`}default:{let a=i?`${(0,f.styleText)("cyan",R)} `:"",l=i?(0,f.styleText)("cyan",we):"",c=o.split(`
140
- `).length,u=i?2:1;return`${o}${a}${Ft({output:e.output,cursor:this.cursor,options:this.options,maxItems:e.maxItems,columnPadding:a.length,rowPadding:c+u,style:(p,g)=>t(p,p.disabled?"disabled":g?"active":"inactive")}).join(`
138
+ `;switch(this.state){case"submit":{let a=s?`${(0,m.styleText)("gray",E)} `:"",l=et(e.output,t(this.options[this.cursor],"selected"),a);return`${o}${l}`}case"cancel":{let a=s?`${(0,m.styleText)("gray",E)} `:"",l=et(e.output,t(this.options[this.cursor],"cancelled"),a);return`${o}${l}${s?`
139
+ ${(0,m.styleText)("gray",E)}`:""}`}default:{let a=s?`${(0,m.styleText)("cyan",E)} `:"",l=s?(0,m.styleText)("cyan",_e):"",d=o.split(`
140
+ `).length,u=s?2:1;return`${o}${a}${Ut({output:e.output,cursor:this.cursor,options:this.options,maxItems:e.maxItems,columnPadding:a.length,rowPadding:d+u,style:(p,g)=>t(p,p.disabled?"disabled":g?"active":"inactive")}).join(`
141
141
  ${a}`)}
142
142
  ${l}
143
- `}}}}).prompt()},Wa=e=>{let t=(i,s="inactive")=>{let n=i.label??String(i.value);return s==="selected"?`${(0,f.styleText)("dim",n)}`:s==="cancelled"?`${(0,f.styleText)(["strikethrough","dim"],n)}`:s==="active"?`${(0,f.styleText)(["bgCyan","gray"],` ${i.value} `)} ${n}${i.hint?` ${(0,f.styleText)("dim",`(${i.hint})`)}`:""}`:`${(0,f.styleText)(["gray","bgWhite","inverse"],` ${i.value} `)} ${n}${i.hint?` ${(0,f.styleText)("dim",`(${i.hint})`)}`:""}`};return new vi({options:e.options,signal:e.signal,input:e.input,output:e.output,initialValue:e.initialValue,caseSensitive:e.caseSensitive,render(){let i=e.withGuide??re.withGuide,s=`${i?`${(0,f.styleText)("gray",R)}
144
- `:""}${Be(this.state)} ${e.message}
145
- `;switch(this.state){case"submit":{let n=i?`${(0,f.styleText)("gray",R)} `:"",r=this.options.find(a=>a.value===this.value)??e.options[0],o=Ze(e.output,t(r,"selected"),n);return`${s}${o}`}case"cancel":{let n=i?`${(0,f.styleText)("gray",R)} `:"",r=Ze(e.output,t(this.options[0],"cancelled"),n);return`${s}${r}${i?`
146
- ${(0,f.styleText)("gray",R)}`:""}`}default:{let n=i?`${(0,f.styleText)("cyan",R)} `:"",r=i?(0,f.styleText)("cyan",we):"",o=this.options.map((a,l)=>Ze(e.output,t(a,l===this.cursor?"active":"inactive"),n)).join(`
147
- `);return`${s}${o}
143
+ `}}}}).prompt()},Ja=e=>{let t=(s,i="inactive")=>{let n=s.label??String(s.value);return i==="selected"?`${(0,m.styleText)("dim",n)}`:i==="cancelled"?`${(0,m.styleText)(["strikethrough","dim"],n)}`:i==="active"?`${(0,m.styleText)(["bgCyan","gray"],` ${s.value} `)} ${n}${s.hint?` ${(0,m.styleText)("dim",`(${s.hint})`)}`:""}`:`${(0,m.styleText)(["gray","bgWhite","inverse"],` ${s.value} `)} ${n}${s.hint?` ${(0,m.styleText)("dim",`(${s.hint})`)}`:""}`};return new vs({options:e.options,signal:e.signal,input:e.input,output:e.output,initialValue:e.initialValue,caseSensitive:e.caseSensitive,render(){let s=e.withGuide??re.withGuide,i=`${s?`${(0,m.styleText)("gray",E)}
144
+ `:""}${Ye(this.state)} ${e.message}
145
+ `;switch(this.state){case"submit":{let n=s?`${(0,m.styleText)("gray",E)} `:"",r=this.options.find(a=>a.value===this.value)??e.options[0],o=et(e.output,t(r,"selected"),n);return`${i}${o}`}case"cancel":{let n=s?`${(0,m.styleText)("gray",E)} `:"",r=et(e.output,t(this.options[0],"cancelled"),n);return`${i}${r}${s?`
146
+ ${(0,m.styleText)("gray",E)}`:""}`}default:{let n=s?`${(0,m.styleText)("cyan",E)} `:"",r=s?(0,m.styleText)("cyan",_e):"",o=this.options.map((a,l)=>et(e.output,t(a,l===this.cursor?"active":"inactive"),n)).join(`
147
+ `);return`${i}${o}
148
148
  ${r}
149
- `}}}}).prompt()},Bn=`${(0,f.styleText)("gray",R)} `,_t={message:async(e,{symbol:t=(0,f.styleText)("gray",R)}={})=>{process.stdout.write(`${(0,f.styleText)("gray",R)}
150
- ${t} `);let i=3;for await(let s of e){s=s.replace(/\n/g,`
151
- ${Bn}`),s.includes(`
152
- `)&&(i=3+(0,f.stripVTControlCharacters)(s.slice(s.lastIndexOf(`
153
- `))).length);let n=(0,f.stripVTControlCharacters)(s).length;i+n<process.stdout.columns?(i+=n,process.stdout.write(s)):(process.stdout.write(`
154
- ${Bn}${s.trimStart()}`),i=3+(0,f.stripVTControlCharacters)(s.trimStart()).length)}process.stdout.write(`
155
- `)},info:e=>_t.message(e,{symbol:(0,f.styleText)("blue",Es)}),success:e=>_t.message(e,{symbol:(0,f.styleText)("green",Is)}),step:e=>_t.message(e,{symbol:(0,f.styleText)("green",St)}),warn:e=>_t.message(e,{symbol:(0,f.styleText)("yellow",Ts)}),warning:e=>_t.warn(e),error:e=>_t.message(e,{symbol:(0,f.styleText)("red",Ps)})},Ha=async(e,t)=>{for(let i of e){if(i.enabled===!1)continue;let s=zt(t);s.start(i.title);let n=await i.task(s.message);s.stop(n||i.title)}},Ja=e=>e.replace(/\x1b\[(?:\d+;)*\d*[ABCDEFGHfJKSTsu]|\x1b\[(s|u)/g,""),Ba=e=>{let t=e.output??process.stdout,i=wt(t),s=(0,f.styleText)("gray",R),n=e.spacing??1,r=3,o=e.retainLog===!0,a=!ks()&&Gn(t);t.write(`${s}
156
- `),t.write(`${(0,f.styleText)("green",St)} ${e.title}
157
- `);for(let v=0;v<n;v++)t.write(`${s}
158
- `);let l=[{value:"",full:""}],c=!1,u=v=>{if(l.length===0)return;let x=0;v&&(x+=n+2);for(let C of l){let{value:E,result:V}=C,L=V?.message??E;if(L.length===0)continue;V===void 0&&C.header!==void 0&&C.header!==""&&(L+=`
149
+ `}}}}).prompt()},Yn=`${(0,m.styleText)("gray",E)} `,_t={message:async(e,{symbol:t=(0,m.styleText)("gray",E)}={})=>{process.stdout.write(`${(0,m.styleText)("gray",E)}
150
+ ${t} `);let s=3;for await(let i of e){i=i.replace(/\n/g,`
151
+ ${Yn}`),i.includes(`
152
+ `)&&(s=3+(0,m.stripVTControlCharacters)(i.slice(i.lastIndexOf(`
153
+ `))).length);let n=(0,m.stripVTControlCharacters)(i).length;s+n<process.stdout.columns?(s+=n,process.stdout.write(i)):(process.stdout.write(`
154
+ ${Yn}${i.trimStart()}`),s=3+(0,m.stripVTControlCharacters)(i.trimStart()).length)}process.stdout.write(`
155
+ `)},info:e=>_t.message(e,{symbol:(0,m.styleText)("blue",Ii)}),success:e=>_t.message(e,{symbol:(0,m.styleText)("green",Ti)}),step:e=>_t.message(e,{symbol:(0,m.styleText)("green",St)}),warn:e=>_t.message(e,{symbol:(0,m.styleText)("yellow",Pi)}),warning:e=>_t.warn(e),error:e=>_t.message(e,{symbol:(0,m.styleText)("red",Di)})},Ba=async(e,t)=>{for(let s of e){if(s.enabled===!1)continue;let i=Xt(t);i.start(s.title);let n=await s.task(i.message);i.stop(n||s.title)}},Ga=e=>e.replace(/\x1b\[(?:\d+;)*\d*[ABCDEFGHfJKSTsu]|\x1b\[(s|u)/g,""),Ya=e=>{let t=e.output??process.stdout,s=wt(t),i=(0,m.styleText)("gray",E),n=e.spacing??1,r=3,o=e.retainLog===!0,a=!ji()&&Kn(t);t.write(`${i}
156
+ `),t.write(`${(0,m.styleText)("green",St)} ${e.title}
157
+ `);for(let v=0;v<n;v++)t.write(`${i}
158
+ `);let l=[{value:"",full:""}],d=!1,u=v=>{if(l.length===0)return;let _=0;v&&(_+=n+2);for(let C of l){let{value:A,result:F}=C,L=F?.message??A;if(L.length===0)continue;F===void 0&&C.header!==void 0&&C.header!==""&&(L+=`
159
159
  ${C.header}`);let G=L.split(`
160
- `).reduce((I,D)=>D===""?I+1:I+Math.ceil((D.length+r)/i),0);x+=G}x>0&&(x+=1,t.write(Pt.erase.lines(x)))},p=(v,x,C)=>{let E=C?`${v.full}
161
- ${v.value}`:v.value;v.header!==void 0&&v.header!==""&&Fe.message(v.header.split(`
162
- `).map(V=>(0,f.styleText)("bold",V)),{output:t,secondarySymbol:s,symbol:s,spacing:0}),Fe.message(E.split(`
163
- `).map(V=>(0,f.styleText)("dim",V)),{output:t,secondarySymbol:s,symbol:s,spacing:x??n})},g=()=>{for(let v of l){let{header:x,value:C,full:E}=v;(x===void 0||x.length===0)&&C.length===0||p(v,void 0,o===!0&&E.length>0)}},_=(v,x,C)=>{if(u(!1),(C?.raw!==!0||!c)&&v.value!==""&&(v.value+=`
164
- `),v.value+=Ja(x),c=C?.raw===!0,e.limit!==void 0){let E=v.value.split(`
165
- `),V=E.length-e.limit;if(V>0){let L=E.splice(0,V);o&&(v.full+=(v.full===""?"":`
160
+ `).reduce((I,P)=>P===""?I+1:I+Math.ceil((P.length+r)/s),0);_+=G}_>0&&(_+=1,t.write(Nt.erase.lines(_)))},p=(v,_,C)=>{let A=C?`${v.full}
161
+ ${v.value}`:v.value;v.header!==void 0&&v.header!==""&&Le.message(v.header.split(`
162
+ `).map(F=>(0,m.styleText)("bold",F)),{output:t,secondarySymbol:i,symbol:i,spacing:0}),Le.message(A.split(`
163
+ `).map(F=>(0,m.styleText)("dim",F)),{output:t,secondarySymbol:i,symbol:i,spacing:_??n})},g=()=>{for(let v of l){let{header:_,value:C,full:A}=v;(_===void 0||_.length===0)&&C.length===0||p(v,void 0,o===!0&&A.length>0)}},x=(v,_,C)=>{if(u(!1),(C?.raw!==!0||!d)&&v.value!==""&&(v.value+=`
164
+ `),v.value+=Ga(_),d=C?.raw===!0,e.limit!==void 0){let A=v.value.split(`
165
+ `),F=A.length-e.limit;if(F>0){let L=A.splice(0,F);o&&(v.full+=(v.full===""?"":`
166
166
  `)+L.join(`
167
- `))}v.value=E.join(`
168
- `)}a&&y()},y=()=>{for(let v of l)v.result?v.result.status==="error"?Fe.error(v.result.message,{output:t,secondarySymbol:s,spacing:0}):Fe.success(v.result.message,{output:t,secondarySymbol:s,spacing:0}):v.value!==""&&p(v,0)},m=(v,x)=>{u(!1),v.result=x,a&&y()};return{message(v,x){_(l[0],v,x)},group(v){let x={header:v,value:"",full:""};return l.push(x),{message(C,E){_(x,C,E)},error(C){m(x,{status:"error",message:C})},success(C){m(x,{status:"success",message:C})}}},error(v,x){u(!0),Fe.error(v,{output:t,secondarySymbol:s,spacing:1}),x?.showLog!==!1&&g(),l.splice(1,l.length-1),l[0].value="",l[0].full=""},success(v,x){u(!0),Fe.success(v,{output:t,secondarySymbol:s,spacing:1}),x?.showLog===!0&&g(),l.splice(1,l.length-1),l[0].value="",l[0].full=""}}},Ae=e=>new wi({validate:e.validate,placeholder:e.placeholder,defaultValue:e.defaultValue,initialValue:e.initialValue,output:e.output,signal:e.signal,input:e.input,render(){let t=e?.withGuide??re.withGuide,i=`${`${t?`${(0,f.styleText)("gray",R)}
169
- `:""}${Be(this.state)} `}${e.message}
170
- `,s=e.placeholder?(0,f.styleText)("inverse",e.placeholder[0])+(0,f.styleText)("dim",e.placeholder.slice(1)):(0,f.styleText)(["inverse","hidden"],"_"),n=this.userInput?this.userInputWithCursor:s,r=this.value??"";switch(this.state){case"error":{let o=this.error?` ${(0,f.styleText)("yellow",this.error)}`:"",a=t?`${(0,f.styleText)("yellow",R)} `:"",l=t?(0,f.styleText)("yellow",we):"";return`${i.trim()}
167
+ `))}v.value=A.join(`
168
+ `)}a&&y()},y=()=>{for(let v of l)v.result?v.result.status==="error"?Le.error(v.result.message,{output:t,secondarySymbol:i,spacing:0}):Le.success(v.result.message,{output:t,secondarySymbol:i,spacing:0}):v.value!==""&&p(v,0)},f=(v,_)=>{u(!1),v.result=_,a&&y()};return{message(v,_){x(l[0],v,_)},group(v){let _={header:v,value:"",full:""};return l.push(_),{message(C,A){x(_,C,A)},error(C){f(_,{status:"error",message:C})},success(C){f(_,{status:"success",message:C})}}},error(v,_){u(!0),Le.error(v,{output:t,secondarySymbol:i,spacing:1}),_?.showLog!==!1&&g(),l.splice(1,l.length-1),l[0].value="",l[0].full=""},success(v,_){u(!0),Le.success(v,{output:t,secondarySymbol:i,spacing:1}),_?.showLog===!0&&g(),l.splice(1,l.length-1),l[0].value="",l[0].full=""}}},Ae=e=>new ws({validate:e.validate,placeholder:e.placeholder,defaultValue:e.defaultValue,initialValue:e.initialValue,output:e.output,signal:e.signal,input:e.input,render(){let t=e?.withGuide??re.withGuide,s=`${`${t?`${(0,m.styleText)("gray",E)}
169
+ `:""}${Ye(this.state)} `}${e.message}
170
+ `,i=e.placeholder?(0,m.styleText)("inverse",e.placeholder[0])+(0,m.styleText)("dim",e.placeholder.slice(1)):(0,m.styleText)(["inverse","hidden"],"_"),n=this.userInput?this.userInputWithCursor:i,r=this.value??"";switch(this.state){case"error":{let o=this.error?` ${(0,m.styleText)("yellow",this.error)}`:"",a=t?`${(0,m.styleText)("yellow",E)} `:"",l=t?(0,m.styleText)("yellow",_e):"";return`${s.trim()}
171
171
  ${a}${n}
172
172
  ${l}${o}
173
- `}case"submit":{let o=r?` ${(0,f.styleText)("dim",r)}`:"",a=t?(0,f.styleText)("gray",R):"";return`${i}${a}${o}`}case"cancel":{let o=r?` ${(0,f.styleText)(["strikethrough","dim"],r)}`:"",a=t?(0,f.styleText)("gray",R):"";return`${i}${a}${o}${r.trim()?`
174
- ${a}`:""}`}default:{let o=t?`${(0,f.styleText)("cyan",R)} `:"",a=t?(0,f.styleText)("cyan",we):"";return`${i}${o}${n}
173
+ `}case"submit":{let o=r?` ${(0,m.styleText)("dim",r)}`:"",a=t?(0,m.styleText)("gray",E):"";return`${s}${a}${o}`}case"cancel":{let o=r?` ${(0,m.styleText)(["strikethrough","dim"],r)}`:"",a=t?(0,m.styleText)("gray",E):"";return`${s}${a}${o}${r.trim()?`
174
+ ${a}`:""}`}default:{let o=t?`${(0,m.styleText)("cyan",E)} `:"",a=t?(0,m.styleText)("cyan",_e):"";return`${s}${o}${n}
175
175
  ${a}
176
- `}}}}).prompt()});function Ga(e){return!!(e.json||!xe)}function O(e,t=50){console.log(),console.log(` ${M.default.bold(e)}`),console.log(` ${M.default.dim("\u2500".repeat(t))}`)}function $(e,t,i=2){let s=" ".repeat(i);console.log(`${s}${M.default.dim(e.padEnd(16))} ${t}`)}function d(){console.log()}function Lt(e){console.log(` ${M.default.dim(e)}`)}function A(e,t){console.log(` ${M.default.dim(e)} ${M.default.cyan(t)}`)}function cr(e){return e.split(/(https?:\/\/[^\s]+)/g).map(i=>/^https?:\/\//.test(i)?`\x1B]8;;${i}\x1B\\${M.default.underline(M.default.cyan(i))}\x1B]8;;\x1B\\`:M.default.dim(i)).join("")}function Us(e,t){console.error(` ${b.error} ${M.default.red(e)}`),t&&console.error(` ${cr(t)}`)}function j(e=!0){return e?zt():Ya}function dr(e){return e.replace(Ka,"")}function Ei(e,t){let i=dr(e).length,s=Math.max(0,t-i);return e+" ".repeat(s)}function ue(e,t,i){let s=i||e.map((o,a)=>{let l=t.reduce((c,u)=>Math.max(c,dr(u[a]||"").length),0);return Math.max(o.length,l)+2}),n=e.map((o,a)=>M.default.dim(o.padEnd(s[a]))).join(" "),r=s.map(o=>M.default.dim("\u2500".repeat(o))).join(" ");console.log(` ${n}`),console.log(` ${r}`);for(let o of t){let a=o.map((l,c)=>Ei(l,s[c])).join(" ");console.log(` ${a}`)}}function za(e){return e.replace(/[A-Z]/g,t=>`_${t.toLowerCase()}`)}function Vs(e){if(Array.isArray(e))return e.map(Vs);if(e&&typeof e=="object"&&!(e instanceof Date)){let t={};for(let[i,s]of Object.entries(e))t[za(i)]=Vs(s);return t}return e}function k(e,t){let i=Vs(e);if(!t){console.log(JSON.stringify(i,null,2));return}let s=t.split(",").map(n=>n.trim()).filter(Boolean);if(Array.isArray(i)){let n=i.map(r=>or(r,s));console.log(JSON.stringify(n,null,2))}else console.log(JSON.stringify(i&&typeof i=="object"?or(i,s):i,null,2))}function or(e,t){let i={};for(let s of t)s in e&&(i[s]=e[s]);if(Object.keys(i).length===0){for(let[s,n]of Object.entries(e))if(Array.isArray(n)&&n.length>0&&typeof n[0]=="object"){let r=n.map(o=>{let a={};for(let l of t)l in o&&(a[l]=o[l]);return a});Object.keys(r[0]).length>0&&(i[s]=r)}}return i}function Ct(e){return!!(e.yes||Ga(e))}function z(e,t,i,s){if(i){k({dry_run:!0,action:e,...t},s);return}console.log(),console.log(` ${M.default.yellow("\u25B8 DRY RUN")} ${M.default.dim("- no changes made")}`),console.log(` ${M.default.dim("Action:")} ${M.default.bold(e)}`);for(let[n,r]of Object.entries(t))r!=null&&(Array.isArray(r)?console.log(` ${M.default.dim(n+":")} ${r.map(String).join(", ")}`):console.log(typeof r=="object"?` ${M.default.dim(n+":")} ${JSON.stringify(r)}`:` ${M.default.dim(n+":")} ${String(r)}`));console.log()}function Za(e,t,i){return t===401||t===403?"auth_required":t===402||i?"payment_required":t===404?"not_found":t===409?"conflict":t===422?"validation_error":t===429?"rate_limited":/contact/i.test(e)?"contact_required":"error"}function h(e,t){let i=e||`Request failed${t?.status?` (${t.status})`:""}`,s=t?.code||Za(i,t?.status,t?.fixUrl),n=t?.fixCommand||Xa[s];if(t?.json){let r={error:i,code:s};t.hint&&(r.hint=t.hint),n&&(r.fix_command=n),t.fixUrl&&(r.fix_url=t.fixUrl),k(r,t.fields)}else Us(i,t?.hint),n?console.error(` ${M.default.dim("Or run:")} ${M.default.cyan(n)}`):t?.fixUrl&&console.error(` ${cr(`Add a payment method at ${t.fixUrl}`)}`);process.exit(1)}function Qe(e){let t=process.platform==="darwin"?"open":process.platform==="win32"?"start":"xdg-open";(0,lr.execFile)(t,[e])}function Vt(e){return new Promise(t=>setTimeout(t,e))}function Ut(e,t,i,s=!0){let n=process.stdout.isTTY??!1;if(!s)return{start(){},markDone(){},stop(){}};let r=0,o=null,a=2+t.length;function l(){let g=" "+e.map((m,v)=>M.default.dim(m.padEnd(i[v]))).join(" "),_=" "+i.map(m=>M.default.dim("\u2500".repeat(m))).join(" "),y=[g,_];for(let m of t){let v=m.status==="done"?m.icon??b.success:M.default.cyan(ar[r%ar.length]),x=m.cells.map((C,E)=>Ei(C,i[E])).join(" ");y.push(` ${v} ${x}`)}return y}let c=!1,u=()=>process.stdout.write("\x1B[?25h");function p(){let g=l();if(c&&n){process.stdout.write(`\x1B[${a}A`);for(let _ of g)process.stdout.write(`\x1B[2K${_}
177
- `)}else{for(let _ of g)console.log(_);c=!0}}return{start(){n&&(process.stdout.write("\x1B[?25l"),process.on("exit",u)),p(),n&&(o=setInterval(()=>{r++,p()},80))},markDone(g,_){t[g].status="done",_!==void 0&&(t[g].icon=_),n&&p()},stop(){o&&clearInterval(o);for(let g of t)g.status="done";p(),n&&(process.stdout.write("\x1B[?25h"),process.removeListener("exit",u))}}}var M,lr,xe,b,w,Ya,Ka,Xa,ar,J=Pe(()=>{"use strict";M=F(H(),1),lr=require("child_process");Ie();xe=process.stdout.isTTY??!1;b={success:M.default.green("\u2713"),error:M.default.red("\u2717"),warning:M.default.yellow("!"),info:M.default.cyan("\u25CF"),arrow:M.default.dim("\u2192"),dot:M.default.dim("\xB7"),dash:M.default.dim("\u2500")},w={domain:e=>M.default.bold(M.default.white(e)),price:e=>M.default.green(`$${e}`),label:e=>M.default.dim(e),value:e=>M.default.white(e),dim:e=>M.default.dim(e),bold:e=>M.default.bold(e),success:e=>M.default.green(e),error:e=>M.default.red(e),warn:e=>M.default.yellow(e),cyan:e=>M.default.cyan(e),url:e=>`\x1B]8;;${e}\x1B\\${M.default.underline(M.default.cyan(e))}\x1B]8;;\x1B\\`};Ya={start:()=>{},stop:()=>{},message:()=>{}};Ka=/\x1b\]8;;[^\x1b]*\x1b\\|\x1b\[[0-9;]*m/g;Xa={auth_required:"domani login",payment_required:"domani card add",contact_required:"domani contact set"};ar=["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"]});async function fr(){if(qs||bt()){qs=!0;return}(process.argv.includes("--json")||!Sn)&&(console.log(JSON.stringify({error:"Not logged in",code:"auth_required",hint:"Run 'domani login' or set DOMANI_API_KEY environment variable",fix_command:"domani login"},null,2)),process.exit(1)),d(),console.log(` ${et.default.dim("You're not logged in.")} Starting authentication...`),d();let t=ze(),i=j(!0);i.start("Requesting auth code");let s=await fetch(`${t}/api/auth/cli`,{method:"POST",headers:{"Content-Type":"application/json"}});if(!s.ok){i.stop("Failed");let o=`Could not reach ${t}`;try{let a=await s.json();o=a.error||a.message||o}catch{}console.error(` ${et.default.red("\u2717")} ${o}`),process.exit(1)}let{code:n,auth_url:r}=await s.json();i.stop(`${b.success} Auth code ready`),d(),console.log(` ${et.default.dim("Verification code:")} ${et.default.bold(et.default.cyan(n))}`),console.log(` ${et.default.dim("Opening browser")} ${b.arrow} ${w.url(r)}`),Qe(r),d(),i.start("Waiting for browser approval");for(let o=0;o<120;o++){await new Promise(c=>setTimeout(c,5e3));let a=await fetch(`${t}/api/auth/cli/poll?code=${n}`).catch(()=>null);if(!a||!a.ok&&a.status!==202)continue;let l=await a.json().catch(()=>({}));if(l.status==="complete"){It({...rt(),token:l.token,email:l.email,api_url:t}),qs=!0,i.stop(`${b.success} Logged in as ${et.default.bold(l.email)}`),d();return}}i.stop("Timed out"),console.error(` ${et.default.red("\u2717")} No approval received. Run ${et.default.cyan("domani login")} to try again.`),process.exit(1)}var et,qs,pr=Pe(()=>{"use strict";et=F(H(),1);pt();J();qs=!1});function hr(e){return e.json=async()=>{let t=await e.clone().text();try{return JSON.parse(t)}catch{return{error:`Server error (${e.status})`,hint:"The server returned an unexpected response. Try again later."}}},e}async function S(e,t={}){await fr();let i=bt(),s=`${ze()}${e}`,n=await fetch(s,{...t,headers:{Authorization:`Bearer ${i}`,"Content-Type":"application/json","User-Agent":`domani-cli/${_e}`,...t.headers}});return hr(n)}async function $e(e,t={}){let i=`${ze()}${e}`,s=bt(),n=await fetch(i,{...t,headers:{"Content-Type":"application/json","User-Agent":`domani-cli/${_e}`,...s?{Authorization:`Bearer ${s}`}:{},...t.headers}});return hr(n)}var Q=Pe(()=>{"use strict";pt();pr()});function $t(){return{ok:!0}}function at(e,t,i){return{ok:!1,error:{message:e,code:t,hint:i}}}function yr(e){return Qa.test(e)?at("Input contains control characters","invalid_input","Remove non-printable characters from the input"):$t()}function rl(e){return el.test(e)?at("Input contains path traversal","invalid_input","Domain names cannot contain '../' or '..\\'"):$t()}function ol(e){return tl.test(e)?at("Input contains query string or fragment","invalid_input","Remove '?' or '#' from the domain name"):$t()}function al(e){return il.test(e)?at("Input contains percent-encoded characters","invalid_input","Use plain text, not URL-encoded values (e.g. 'example.com' not 'example%2Ecom')"):$t()}function br(e){if(!e)return at("Domain name is required","validation_error");if(e.length>$r)return at(`Domain name too long (${e.length} chars, max ${$r})`,"validation_error");for(let t of[yr,rl,ol,al]){let i=t(e);if(!i.ok)return i}return sl.test(e)?$t():at(`Invalid domain name: ${e}`,"validation_error","Domain names can only contain letters, digits, hyphens, and dots")}function ll(e){if(!e)return at("TLD is required","validation_error");let t=yr(e);return t.ok?nl.test(e)?$t():at(`Invalid TLD: ${e}`,"validation_error","TLDs contain only letters (e.g. 'com', '.dev', 'ai')"):t}function cl(e){for(let t of e){let i=br(t);if(!i.ok)return i}return $t()}function dl(e){for(let t of e){let i=ll(t);if(!i.ok)return i}return $t()}function ee(e,t){let i=br(e);i.ok||h(i.error.message,{code:i.error.code,hint:i.error.hint,json:t?.json,fields:t?.fields})}function vr(e,t){let i=cl(e);i.ok||h(i.error.message,{code:i.error.code,hint:i.error.hint,json:t?.json,fields:t?.fields})}function Ii(e,t){let i=dl(e);i.ok||h(i.error.message,{code:i.error.code,hint:i.error.hint,json:t?.json,fields:t?.fields})}var Qa,el,tl,il,sl,nl,$r,ye=Pe(()=>{"use strict";J();Qa=/[\x00-\x08\x0b\x0c\x0e-\x1f]/,el=/\.\.[/\\]/,tl=/[?#]/,il=/%[0-9a-fA-F]{2}/,sl=/^[a-zA-Z0-9]([a-zA-Z0-9-]*[a-zA-Z0-9])?(\.[a-zA-Z0-9]([a-zA-Z0-9-]*[a-zA-Z0-9])?)*\.?$/,nl=/^\.?[a-zA-Z]{2,63}$/,$r=253});async function me(){xe||h("Missing required argument: domain",{hint:"Pass the domain as an argument, e.g. 'domani settings example.com'",code:"missing_argument",json:!0});let e=j(!0);e.start("Loading your domains");let t=await S("/api/domains"),i=await t.json();t.ok||(e.stop("Failed"),Us(i.error,i.hint),process.exit(1));let s=i.domains||[];s.length===0&&(e.stop("No domains"),d(),console.log(` ${Ws.default.dim("No domains yet.")} Use: ${Ws.default.cyan("domani buy <domain>")}`),d(),process.exit(0)),e.stop(`${s.length} domain(s)`);let n=await Ge({message:"Which domain?",options:s.map(r=>({value:r.domain,label:r.domain,hint:r.status!=="active"?r.status:void 0}))});return oe(n)&&process.exit(0),n}var Ws,He=Pe(()=>{"use strict";Q();Ie();Ws=F(H(),1);J()});var _r={};Rt(_r,{connect:()=>Hs});async function Hs(e,t,i){e||(e=await me()),ee(e,i);let s;if(t&&!i.provider?t.includes(".")?s=t:i.provider=t:s=t,!s&&!i.provider&&!i.list&&i.dryRun)return z("connect",{domain:e,note:"No provider specified. Pass --provider <name> to connect."},i.json,i.fields);if(!s&&!i.provider&&!i.list){let n=j(!i.json);n.start(`Loading providers for ${w.domain(e)}`);let r=await S(`/api/domains/${encodeURIComponent(e)}/connect`),o=await r.json();if(r.ok||(n.stop("Failed"),h(o.error||o.message,{hint:o.hint,status:r.status,json:i.json,fields:i.fields})),n.stop("Providers loaded"),i.json){k(o,i.fields);return}let a=[];for(let m of["hosting","email"]){let v=o.providers?.[m]||[];for(let x of v)a.push({value:`${m}:${x.name}`,label:x.name,hint:m})}a.length===0&&h("No providers available",{code:"not_found",json:i.json,fields:i.fields});let l=await Ge({message:"Choose a provider",options:a});oe(l)&&process.exit(0);let[c,u]=l.split(":"),g=(o.providers?.[c]||[]).find(m=>m.name===u),_;if(g&&g.methods.length>1){let m=await Ge({message:"Choose a method",options:g.methods.map(v=>({value:v.name,label:v.name,hint:v.default?"default":void 0}))});oe(m)&&process.exit(0),_=m}let y;if(c==="hosting"&&g?.requires_target){g.notes?.setup&&Lt(g.notes.setup);let m=await Ae({message:"Target hostname or IP"});oe(m)&&process.exit(0),y=m.trim()}return wr(e,{target:y,provider:u,method:_,dryRun:i.dryRun,json:!1})}if(i.list){let n=j(!i.json);n.start(`Loading providers for ${w.domain(e)}`);let r=await S(`/api/domains/${encodeURIComponent(e)}/connect`),o=await r.json();if(r.ok||(n.stop("Failed"),h(o.error||o.message,{hint:o.hint,status:r.status,json:i.json,fields:i.fields})),n.stop("Providers loaded"),i.json){k(o,i.fields);return}O(`Providers for ${w.domain(o.domain)}`);for(let a of["hosting","email"]){let l=o.providers?.[a];if(l?.length){d(),console.log(` ${ce.default.bold(a.toUpperCase())}`);for(let c of l){let u=c.methods.map(p=>p.default?ce.default.green(`${p.name} (default)`):ce.default.dim(p.name)).join(ce.default.dim(", "));console.log(` ${ce.default.cyan(c.name.padEnd(20))} ${u}`)}}}d();return}return wr(e,i)}async function wr(e,t){let i={};if(t.target&&(i.target=t.target),t.provider&&(i.provider=t.provider),t.method&&(i.method=t.method),t.dryRun)return z("connect",{domain:e,...i},t.json,t.fields);let s=j(!t.json);s.start(`Connecting ${w.domain(e)}`);let n=await S(`/api/domains/${encodeURIComponent(e)}/connect`,{method:"POST",body:JSON.stringify(i)}),r=await n.json();n.ok||(s.stop("Connection failed"),h(r.error||r.message,{hint:r.hint,status:n.status,json:t.json,fields:t.fields}));let o=r.status==="manual_setup_required";if(s.stop(o?`${b.success} DNS instructions for ${ce.default.cyan(r.provider)}`:`${b.success} Connected to ${ce.default.cyan(r.provider)}`),t.json){k(r,t.fields);return}if(O(o?`Add these records at your registrar for ${w.domain(r.domain)}`:`Connected ${w.domain(r.domain)}`),$("Provider",ce.default.cyan(r.provider)),$("Method",r.method),r.records?.length){let a=[8,22,40];d(),console.log(` ${ce.default.bold("DNS Records")}`);let l=["Type","Name","Value"].map((u,p)=>ce.default.dim(u.padEnd(a[p]))).join(" "),c=a.map(u=>ce.default.dim("\u2500".repeat(u))).join(" ");console.log(` ${l}`),console.log(` ${c}`);for(let u of r.records){let p=u.record,g=u.status!=="already_set";process.stdout.isTTY&&g&&await Vt(50);let y=[ce.default.yellow(p.type),p.name,ce.default.cyan(p.value)+(p.priority?ce.default.dim(` pri=${p.priority}`):"")].map((x,C)=>Ei(x,a[C])).join(" "),m=u.status==="already_set"?ce.default.dim("\u2713"):u.status==="updated"?ce.default.yellow("\u21BA"):u.status==="pending"?ce.default.yellow("\u2192"):b.success,v=u.status==="already_set"?ce.default.dim(" already set"):u.status==="updated"?ce.default.dim(" updated"):u.status==="pending"?ce.default.dim(" add this"):"";console.log(` ${m} ${y}${v}`)}}d(),r.next_steps?.length?(console.log(` ${ce.default.bold("Next steps")}`),r.next_steps.forEach((a,l)=>{console.log(` ${ce.default.dim(`${l+1}.`)} ${a}`)})):r.hint&&console.log(` ${ce.default.dim(r.hint)}`),r.docs&&console.log(` ${ce.default.dim("Docs:")} ${w.url(r.docs)}`),d()}var ce,Js=Pe(()=>{"use strict";Q();ce=F(H(),1);Ie();J();ye();He()});var Or={};Rt(Or,{email:()=>Zt});function fl(e){return[P.default.yellow(e.type),e.name,P.default.cyan(e.value)+(e.priority?P.default.dim(` pri=${e.priority}`):"")]}function Bs(e){return ml[e]||e}function pl(e,t){if(e&&e.includes("@")){let[i,s]=e.split("@",2);!t.slug&&i&&(t.slug=i),!t.domain&&s&&(t.domain=s)}}async function lt(e){return e.domain?(ee(e.domain,e),e.domain):me()}async function Zt(e,t,i){if(e&&e.includes(".")&&!ul.includes(e))return i.check?kr(e,!!i.json,i.fields):t?jr(e,t,!!i.json,i.fields):Sr(e,!!i.json,i.fields);if(pl(t,i),i.body&&!i.text&&(i.text=i.body),i.title&&!i.subject&&(i.subject=i.title),i.from&&i.from.includes("@")){let[s,n]=i.from.split("@",2);!i.slug&&s&&(i.slug=s),!i.domain&&n&&(i.domain=n)}switch(e){case void 0:return xr(i);case"list":return xr(i);case"inbox":return wl(i);case"setup":return hl(i);case"status":return gl(i);case"remove":return $l(i);case"create":return yl(i);case"delete":return bl(i);case"send":return vl(i);case"webhook":return _l(i);case"forward":return xl(i);case"check":return kr(i.domain||await me(),!!i.json,i.fields);case"connect":return jr(i.domain||await me(),t||void 0,!!i.json,i.fields);default:h(`Unknown action: ${e}`,{hint:"Actions: list, inbox, create, delete, send, forward, webhook, setup, status, check, connect",code:"validation_error",json:i.json,fields:i.fields})}}async function hl(e){let t=await lt(e);if(e.dryRun)return z("email_setup",{domain:t},e.json,e.fields);let i=j(!e.json);i.start(`Setting up email on ${w.domain(t)}`);let s=await S(`/api/domains/${encodeURIComponent(t)}/email/setup`,{method:"POST"}),n=await s.json();if(s.ok||(i.stop("Failed"),h(n.error||n.message,{hint:n.hint,status:s.status,json:e.json,fields:e.fields})),i.stop(`${b.success} Email ${n.status==="already_configured"?"already configured":"configured"}`),e.json){k(n,e.fields);return}if(n.records?.length){d(),O(`Email DNS Records ${w.domain(t)}`);let r=n.records.map(o=>[P.default.yellow(o.type),o.name,o.value.length>40?o.value.slice(0,40)+"...":o.value,o.status==="verified"||o.status==="created"?P.default.green(o.status):P.default.yellow(o.status)]);ue(["Type","Name","Value","Status"],r,[8,28,44,12])}d(),n.hint&&Lt(n.hint),A("Check status:",`domani email status --domain ${t}`),d()}async function gl(e){let t=await lt(e),i=j(!e.json);i.start(`Checking email status for ${w.domain(t)}`);let s=await S(`/api/domains/${encodeURIComponent(t)}/email/status`),n=await s.json();if(s.ok||(i.stop("Failed"),h(n.error||n.message,{hint:n.hint,status:s.status,json:e.json,fields:e.fields})),i.stop(`${b.success} Status loaded`),e.json){k(n,e.fields);return}if(O(`Email ${w.domain(t)}`),$("Enabled",n.enabled?P.default.green("yes"):P.default.dim("no")),n.enabled&&($("Verified",n.verified?P.default.green("yes"):P.default.yellow("pending")),$("Mailboxes",String(n.mailbox_count))),d(),!n.enabled)A("Set up email:",`domani email setup --domain ${t}`),d();else if(!n.verified&&n.records?.length){console.log(` ${P.default.yellow("!")} Add these DNS records to verify:`);for(let r of n.records)console.log(` ${P.default.yellow(r.type)} ${r.name} ${P.default.dim("\u2192")} ${r.value.length>50?r.value.slice(0,50)+"...":r.value}`);d()}}async function $l(e){let t=await lt(e);if(e.dryRun)return z("email_remove",{domain:t},e.json,e.fields);let i=j(!e.json);i.start(`Removing email from ${w.domain(t)}`);let s=await S(`/api/domains/${encodeURIComponent(t)}/email/setup`,{method:"DELETE"}),n=await s.json();if(s.ok||(i.stop("Failed"),h(n.error||n.message,{hint:n.hint,status:s.status,json:e.json,fields:e.fields})),i.stop(`${b.success} Email disabled`),e.json){k(n,e.fields);return}n.mailboxes_deleted>0&&console.log(` ${P.default.dim(`${n.mailboxes_deleted} mailbox(es) deleted.`)}`),d()}async function xr(e){let t=j(!e.json);t.start("Loading mailboxes");let i=e.domain?`?domain=${encodeURIComponent(e.domain)}`:"",s=await S(`/api/emails${i}`),n=await s.json();s.ok||(t.stop("Failed"),h(n.error||n.message,{hint:n.hint,status:s.status,json:e.json,fields:e.fields}));let r=n.mailboxes||[];if(t.stop(`${b.success} ${r.length} mailbox(es)`),e.json){k(n,e.fields);return}if(r.length===0){d(),console.log(` ${P.default.dim("No mailboxes.")}`),d(),A("Create one:","domani email create hello@example.com"),d();return}d(),O("Mailboxes");let o=r.map(a=>[P.default.cyan(a.address),String(a.message_count),a.webhook_url?w.url(a.webhook_url):P.default.dim("-"),P.default.dim(new Date(a.created_at).toLocaleDateString())]);ue(["Address","Messages","Webhook","Created"],o,[32,10,36,14]),d()}async function yl(e){let t=await lt(e);if(e.dryRun)return z("email_create_mailbox",{domain:t,slug:e.slug},e.json,e.fields);let i=e.slug;if(!i&&!e.json){let c=await Ae({message:`Email handle for @${t}:`,placeholder:"hello"});oe(c)&&process.exit(0),i=c}i||h("Slug required",{hint:`Usage: domani email create hello@${t}`,code:"validation_error",json:e.json,fields:e.fields});let s=`${i}@${t}`,n=j(!e.json);n.start("Creating mailbox");let r=await S("/api/emails",{method:"POST",body:JSON.stringify({address:s})}),o=await r.json();if(r.status===202&&!e.json){n.stop("");let c=o.txt_record,u=o.email_records||[],p=[{type:"TXT",name:c?.name||"@",value:c?.value||"",note:"ownership proof"},...u.map(m=>({...m,note:""}))];d(),console.log(" Add these records at your DNS provider:"),d();let g=[6,20,52,16];console.log(` ${P.default.dim("Type".padEnd(g[0]))} ${P.default.dim("Name".padEnd(g[1]))} ${P.default.dim("Value".padEnd(g[2]))} ${P.default.dim("Note")}`);for(let m of p){let v=m.value.length>g[2]?m.value.slice(0,g[2]-3)+"...":m.value,x="priority"in m&&m.priority!==void 0?P.default.dim(` pri=${m.priority}`):"";console.log(` ${P.default.yellow(m.type.padEnd(g[0]))} ${m.name.padEnd(g[1])} ${P.default.cyan(v)}${x} ${m.note?P.default.dim(m.note):""}`)}d(),Lt("DNS propagation typically takes 5\u201330 minutes. Checking automatically..."),d();let _=j(!0);_.start("Waiting for DNS propagation");let y=0;for(;r.status===202&&y<60;)await Vt(15e3),y++,r=await S("/api/emails",{method:"POST",body:JSON.stringify({address:s})}),o=await r.json(),r.status!==202&&!r.ok&&(_.stop("Failed"),h(o.error||o.message,{hint:o.hint,status:r.status,json:e.json,fields:e.fields})),_.start(`Waiting for DNS... (${Math.round(y*15/60)}m)`);r.status===202&&(_.stop(""),h("DNS records not detected after 15 minutes.",{hint:`Check records are set correctly, then retry: domani email create ${s}`,code:"timeout",json:e.json,fields:e.fields})),_.stop(`${b.success} DNS verified`),d()}if(r.ok||(n.stop("Failed"),h(o.error||o.message,{hint:o.hint,status:r.status,json:e.json,fields:e.fields})),n.stop(`${b.success} ${P.default.cyan(o.address)} created`),e.json){k(o,e.fields);return}let a=await S(`/api/domains/${encodeURIComponent(t)}/email/status`),l=await a.json();if(a.ok&&!l.verified&&l.records?.length){d(),console.log(` ${P.default.bold("Add these DNS records at your registrar to activate email:")}`),d();let c=l.records.map(u=>[P.default.yellow(u.type),u.name,u.value.length>50?u.value.slice(0,50)+"...":u.value,...u.priority!==void 0?[P.default.dim(`pri=${u.priority}`)]:[""]]);ue(["Type","Name","Value",""],c,[8,20,54,10]),d(),A("Check propagation:",`domani email status --domain ${t}`)}else d(),A("Read inbox:",`domani email inbox ${o.address}`),A("Web inbox:",`${li}/inbox?address=${encodeURIComponent(o.address)}`);d()}async function bl(e){let t=await lt(e);if(e.slug||h("Slug required",{hint:"Usage: domani email delete hello@example.com",code:"validation_error",json:e.json,fields:e.fields}),e.dryRun)return z("email_delete_mailbox",{domain:t,address:`${e.slug}@${t}`},e.json,e.fields);let i=j(!e.json);i.start(`Deleting ${e.slug}@${t}`);let s=encodeURIComponent(`${e.slug}@${t}`),n=await S(`/api/emails/${s}`,{method:"DELETE",body:JSON.stringify({confirm:!0})}),r=await n.json();if(n.ok||(i.stop("Failed"),h(r.error||r.message,{hint:r.hint,status:n.status,json:e.json,fields:e.fields})),i.stop(`${b.success} Mailbox deleted`),e.json){k(r,e.fields);return}console.log(` ${P.default.dim(`${r.address} and all messages deleted.`)}`),d()}async function vl(e){let t=await lt(e);if(e.slug||h("Slug required",{hint:'Usage: domani email send hello@example.com --to user@test.com --subject "Hi" --body "Hello"',code:"validation_error",json:e.json,fields:e.fields}),e.to||h("Recipient required",{hint:"Usage: domani email send hello@example.com --to user@test.com",code:"validation_error",json:e.json,fields:e.fields}),e.dryRun)return z("email_send",{from:`${e.slug}@${t}`,to:e.to,subject:e.subject},e.json,e.fields);let i=j(!e.json);i.start(`Sending from ${e.slug}@${t}`);let s={to:e.to};e.cc&&(s.cc=e.cc),e.bcc&&(s.bcc=e.bcc),e.subject&&(s.subject=e.subject),e.text&&(s.text=e.text),e.inReplyTo&&(s.in_reply_to=e.inReplyTo),e.references&&(s.references=e.references);let n=encodeURIComponent(`${e.slug}@${t}`),r=await S(`/api/emails/${n}/send`,{method:"POST",body:JSON.stringify(s)}),o=await r.json();if(!r.ok){i.stop("Failed");let l=o.code==="MONTHLY_LIMIT_EXCEEDED"?`Run ${P.default.cyan("domani upgrade")} to switch to Pro (10,000 emails/month).`:o.hint;h(o.error||o.message,{hint:l,status:r.status,json:e.json,fields:e.fields})}let a=Array.isArray(o.to)?o.to.join(", "):o.to;if(i.stop(`${b.success} Sent to ${P.default.cyan(a)}`),e.json){k(o,e.fields);return}}async function wl(e){let t=await lt(e);e.slug||h("Slug required",{hint:"Usage: domani email inbox hello@example.com [--direction in|out] [--limit 20]",code:"validation_error",json:e.json,fields:e.fields});let i=new URLSearchParams;e.direction&&i.set("direction",e.direction),e.limit&&i.set("limit",e.limit);let s=i.toString()?`?${i}`:"",n=j(!e.json);n.start(`Loading messages for ${e.slug}@${t}`);let r=encodeURIComponent(`${e.slug}@${t}`),o=await S(`/api/emails/${r}/messages${s}`),a=await o.json();o.ok||(n.stop("Failed"),h(a.error||a.message,{hint:a.hint,status:o.status,json:e.json,fields:e.fields}));let l=a.messages||[];if(e.json){n.stop(`${b.success} ${l.length} message(s)`),k(a,e.fields);return}if(l.length===0){n.stop(`${P.default.dim("No messages")}`);return}let c=l.length>1?"s":"";n.stop(`${b.success} ${P.default.cyan(`${e.slug}@${t}`)} ${P.default.dim("\xB7 "+l.length+" message"+c)}`);for(let u of l){let p=u.direction==="in"?P.default.green("in "):P.default.dim("out"),g=u.direction==="in"?u.from:u.to,_=u.subject||"(no subject)",y=P.default.dim(new Date(u.created_at).toLocaleString()),m=_;if(u.text){let v=u.text.replace(/\s+/g," ").trim(),x=v.length>60?v.slice(0,60)+"\u2026":v;m=`${_} ${P.default.dim("- "+x)}`}console.log(` ${p} ${g.padEnd(30)} ${m} ${y}`)}a.next_cursor&&console.log(` ${P.default.dim("\u2026 more available, use --limit to paginate")}`)}async function _l(e){let t=await lt(e);e.slug||h("Slug required",{hint:"Usage: domani email webhook hello@example.com --url https://...",code:"validation_error",json:e.json,fields:e.fields});let i=`${e.slug}@${t}`,s=encodeURIComponent(i);if(e.dryRun)return z("email_webhook",{address:i,webhook_url:e.url||null},e.json,e.fields);let n=j(!e.json);if(e.url){n.start(`Setting webhook for ${i}`);let r=await S(`/api/emails/${s}/webhook`,{method:"PUT",body:JSON.stringify({url:e.url})}),o=await r.json();if(r.ok||(n.stop("Failed"),h(o.error||o.message,{hint:o.hint,status:r.status,json:e.json,fields:e.fields})),n.stop(`${b.success} Webhook set`),e.json){k(o,e.fields);return}O(`Mailbox ${o.address}`),$("Webhook",w.url(o.webhook_url)),$("Signing secret",P.default.dim(o.signing_secret)),d()}else{n.start(`Removing webhook for ${i}`);let r=await S(`/api/emails/${s}/webhook`,{method:"DELETE"}),o=await r.json();if(r.ok||(n.stop("Failed"),h(o.error||o.message,{hint:o.hint,status:r.status,json:e.json,fields:e.fields})),n.stop(`${b.success} Webhook removed`),e.json){k(o,e.fields);return}O(`Mailbox ${o.address}`),$("Webhook",P.default.dim("none")),d()}}async function xl(e){let t=await lt(e);if(e.slug||h("Slug required",{hint:"Usage: domani email forward hello@example.com --forward-to me@gmail.com",code:"validation_error",json:e.json,fields:e.fields}),e.dryRun)return z("email_forward",{address:`${e.slug}@${t}`,forward_to:e.forwardTo||null},e.json,e.fields);let i=j(!e.json),s=e.forwardTo||null;i.start(`Updating forward for ${e.slug}@${t}`);let n=encodeURIComponent(`${e.slug}@${t}`),r=await S(`/api/emails/${n}`,{method:"PATCH",body:JSON.stringify({forward_to:s})}),o=await r.json();if(r.ok||(i.stop("Failed"),h(o.error||o.message,{hint:o.hint,status:r.status,json:e.json,fields:e.fields})),i.stop(`${b.success} Forward ${s?"set":"removed"}`),e.json){k(o,e.fields);return}O(`Mailbox ${o.address}`),$("Forward to",o.forward_to?P.default.cyan(o.forward_to):P.default.dim("none")),d()}async function kr(e,t,i){let s=j(!t);s.start(`Checking email health for ${w.domain(e)}`);let n=await S(`/api/domains/${encodeURIComponent(e)}/email/check`),r=await n.json();if(n.ok||(s.stop("Failed"),h(r.error||r.message,{hint:r.hint,status:n.status,json:t,fields:i})),s.stop("Email health checked"),t){k(r,i);return}if(O(`Email Health ${w.domain(r.domain)}`),r.provider?$("Provider",P.default.cyan(Bs(r.provider))):$("Provider",P.default.dim("unknown")),r.mx.configured?$("MX",`${b.success} ${P.default.green("propagated")} ${P.default.dim(`(${r.mx.records.length} record${r.mx.records.length!==1?"s":""})`)}`):$("MX",`${b.error} ${P.default.red("not configured")}`),r.spf.configured?$("SPF",`${b.success} ${P.default.green(r.spf.value)}`):$("SPF",`${b.error} ${P.default.red("missing")}`),r.dmarc.configured){let o=r.dmarc.value.length>50?r.dmarc.value.slice(0,50)+"...":r.dmarc.value;$("DMARC",`${b.success} ${P.default.green(o)}`)}else $("DMARC",`${b.error} ${P.default.red("missing")}`);r.dkim.configured?$("DKIM",`${b.success} ${P.default.green("found")} ${P.default.dim(`(${r.dkim.selectors.join(", ")})`)}`):$("DKIM",`${b.warning} ${P.default.yellow("not found")}`),d(),r.mx.configured?(!r.spf.configured||!r.dmarc.configured)&&(Lt("SPF and DMARC protect against email spoofing. Re-run email setup to add them."),d()):(A("Set up email:",`domani email ${e} google`),d())}async function jr(e,t,i,s){return t?Cr(e,t,i,s):Sr(e,i,s)}async function Sr(e,t,i){let s=j(!t);s.start("Loading email providers");let n=await S(`/api/domains/${encodeURIComponent(e)}/connect`),r=await n.json();n.ok||(s.stop("Failed"),h(r.error||r.message,{hint:r.hint,status:n.status,json:t,fields:i})),s.stop("Providers loaded");let o=r.providers?.email||[];o.length===0&&h("No email providers available",{code:"not_found",json:t,fields:i});let a=await Ge({message:"Choose an email provider",options:o.map(l=>({value:l.name,label:Bs(l.name)}))});return oe(a)&&process.exit(0),Cr(e,a,t,i)}async function Cr(e,t,i,s){if(i){let c=await S(`/api/domains/${encodeURIComponent(e)}/connect`,{method:"POST",body:JSON.stringify({target:t})}),u=await c.json();c.ok||h(u.error||u.message,{hint:u.hint,status:c.status,json:i,fields:s}),k(u,s);return}let n=await S(`/api/domains/${encodeURIComponent(e)}/connect?provider=${encodeURIComponent(t)}`);if(!n.ok){let c=await n.json();h(c.error||c.message,{hint:c.hint,status:n.status,json:i,fields:s})}let r=await n.json(),o=r.preview?.records??[],a=r.preview?.provider??t,l=Bs(a);if(O(`Email ${w.domain(e)}`),$("Provider",P.default.cyan(l)),o.length){d(),console.log(` ${P.default.bold("DNS Records")}`);let c=[8,24,40],u=Ut(["Type","Name","Value"],o.map(x=>({cells:fl(x),status:"pending"})),c);u.start();let p=await S(`/api/domains/${encodeURIComponent(e)}/connect`,{method:"POST",body:JSON.stringify({target:t})}),g=await p.json();p.ok||(u.stop(),d(),h(g.error||g.message,{hint:g.hint,status:p.status,json:i,fields:s}));let _=g.records||[];for(let x=0;x<o.length;x++)_.find(E=>E.record.type===o[x].type&&E.record.name===o[x].name&&E.record.value===o[x].value)?.status==="already_set"||await Vt(60),u.markDone(x);await Vt(80),u.stop();let y=_.filter(x=>x.status==="created"||x.status==="updated").length,m=_.filter(x=>x.status==="already_set").length,v;m===_.length?v=`All ${m} records already set`:m>0?v=`${y} created, ${m} already set`:v=`${y} DNS records set`,d(),console.log(` ${b.success} ${P.default.green(`Email configured - ${v}`)}`)}else{let c=j(!0);c.start("Setting DNS records");let u=await S(`/api/domains/${encodeURIComponent(e)}/connect`,{method:"POST",body:JSON.stringify({target:t})}),p=await u.json();u.ok||(c.stop("Failed"),h(p.error||p.message,{hint:p.hint,status:u.status,json:i,fields:s})),c.stop(`${b.success} Email configured via ${P.default.cyan(l)}`)}d(),A("Verify propagation:",`domani email ${e} --check`),d()}var P,ul,ml,Gs=Pe(()=>{"use strict";Q();Ht();P=F(H(),1);Ie();J();ye();He();ul=["setup","status","remove","list","create","delete","send","inbox","webhook","forward","check","connect"],ml={"google-workspace":"Google Workspace",fastmail:"Fastmail",proton:"Proton Mail"}});var Ar={};Rt(Ar,{dns:()=>Ks});async function Ks(e,t,i,s,n,r){e||(e=await me()),ee(e,r);let o=r?.json??!1,a=r?.type||i,l=r?.name||s,c=r?.value||n;if(!t||t==="get"){let u=j(!o);u.start(`Loading DNS for ${w.domain(e)}`);let p=await S(`/api/domains/${encodeURIComponent(e)}/dns`),g=await p.json();if(p.ok||(u.stop("Failed"),h(g.error||g.message,{hint:g.hint,status:p.status,json:o,fields:r?.fields})),u.stop(`${g.records.length} record(s)`),o){k(g,r?.fields);return}if(g.records.length===0){d(),console.log(` ${ke.default.dim(`No DNS records for ${e}`)}`),d(),A("Auto-configure DNS:",`domani connect ${e}`),d();return}let _=[8,24,40,8];O(`DNS ${w.domain(e)}`,_.reduce((m,v)=>m+v,0)+_.length-1);let y=g.records.map(m=>{let v=m.priority?ke.default.dim(` pri=${m.priority}`):"";return[ke.default.yellow(m.type),m.name,ke.default.cyan(m.value)+v,ke.default.dim(String(m.ttl))]});ue(["Type","Name","Value","TTL"],y,_),d();return}if(t==="set"){if((!a||!l||!c)&&h("Missing arguments for dns set",{hint:"Usage: domani dns <domain> set --type A --name www --value 1.2.3.4",code:"validation_error",json:o,fields:r?.fields}),r?.dryRun)return z("dns_set",{domain:e,record:{type:a.toUpperCase(),name:l,value:c,ttl:3600}},o,r?.fields);let u=j(!o);u.start(`Setting ${ke.default.yellow(a.toUpperCase())} record`);let p=await S(`/api/domains/${encodeURIComponent(e)}/dns`),g=await p.json(),y=(p.ok?g.records:[]).filter(x=>!(x.type===a.toUpperCase()&&x.name===l));y.push({type:a.toUpperCase(),name:l,value:c,ttl:3600});let m=await S(`/api/domains/${encodeURIComponent(e)}/dns`,{method:"PUT",body:JSON.stringify({records:y})}),v=await m.json();m.ok||(u.stop("Failed"),h(v.error||v.message,{hint:v.hint,status:m.status,json:o,fields:r?.fields})),u.stop(`${b.success} ${ke.default.yellow(a.toUpperCase())} ${l} ${b.arrow} ${ke.default.cyan(c)}`),o?k(v,r?.fields):(d(),A("Check propagation:",`domani status ${e}`),d());return}if(t==="delete"){if((!a||!l)&&h("Missing arguments for dns delete",{hint:"Usage: domani dns <domain> delete --type A --name www",code:"validation_error",json:o,fields:r?.fields}),r?.dryRun)return z("dns_delete",{domain:e,record:{type:a.toUpperCase(),name:l}},o,r?.fields);let u=j(!o);u.start(`Deleting ${ke.default.yellow(a.toUpperCase())} ${l}`);let p=await S(`/api/domains/${encodeURIComponent(e)}/dns?type=${encodeURIComponent(a.toUpperCase())}&name=${encodeURIComponent(l)}`,{method:"DELETE"}),g=await p.json();p.ok||(u.stop("Failed"),h(g.error||g.message,{hint:g.hint,status:p.status,json:o,fields:r?.fields})),u.stop(`${b.success} Deleted ${ke.default.yellow(a.toUpperCase())} ${l}`),o?k(g,r?.fields):(d(),A("Check propagation:",`domani status ${e}`),d());return}if(t==="snapshot"){if(r?.dryRun)return z("dns_snapshot",{domain:e},o,r?.fields);let u=j(!o);u.start(`Capturing DNS snapshot for ${w.domain(e)}`);let p=await S(`/api/domains/${encodeURIComponent(e)}/dns/snapshot`,{method:"POST"}),g=await p.json();p.ok||(u.stop("Failed"),h(g.error||g.message,{hint:g.hint,status:p.status,json:o,fields:r?.fields}));let _=g.records?.length??0;if(u.stop(`${b.success} Captured ${_} record(s)`),o){k(g,r?.fields);return}let y=`${e}.dns.json`,m=(0,Ys.resolve)(process.cwd(),y);(0,Ti.writeFileSync)(m,JSON.stringify(g,null,2)+`
178
- `),O("DNS Snapshot"),$("Domain",w.domain(g.domain)),$("Records",String(_)),$("Subdomains",String(g.subdomains?.length??0)),$("Sources",(g.sources||[]).join(", ")||"none"),$("Captured",g.capturedAt||g.captured_at||"now"),$("Saved to",ke.default.cyan(y)),d(),A("Restore from this snapshot:",`domani dns ${e} restore --file ${y}`),d();return}if(t==="restore"){if(r?.dryRun)return z("dns_restore",{domain:e,source:r?.file||"server_backup"},o,r?.fields);let u=j(!o),p;if(r?.file){let y=(0,Ys.resolve)(process.cwd(),r.file);y.startsWith(process.cwd())||h("File path must be within the current directory",{hint:`Got: ${r.file}`,code:"validation_error",json:o,fields:r?.fields});try{let m=(0,Ti.readFileSync)(y,"utf-8"),v=JSON.parse(m);p=JSON.stringify({snapshot:v}),u.start(`Restoring DNS for ${w.domain(e)} from ${ke.default.cyan(r.file)}`)}catch(m){h(`Failed to read snapshot file: ${m instanceof Error?m.message:"unknown"}`,{hint:`Make sure ${r.file} exists and contains valid JSON.`,code:"validation_error",json:o,fields:r?.fields})}}else u.start(`Restoring DNS for ${w.domain(e)} from server backup`);let g=await S(`/api/domains/${encodeURIComponent(e)}/dns/restore`,{method:"POST",...p?{body:p}:{}}),_=await g.json();if(g.ok||(u.stop("Failed"),h(_.error||_.message,{hint:_.hint,status:g.status,json:o,fields:r?.fields})),u.stop(`${b.success} Restored DNS`),o){k(_,r?.fields);return}if(O("DNS Restored"),$("Domain",w.domain(_.domain)),$("Applied",ke.default.green(String(_.applied??0))),$("Skipped",ke.default.dim(String(_.skipped??0))),_.errors?.length>0){$("Errors",ke.default.red(String(_.errors.length)));for(let y of _.errors)console.log(` ${ke.default.red("\u2022")} ${y}`)}d(),A("Verify DNS records:",`domani dns ${e}`),d();return}h(`Unknown action: ${t}`,{hint:"Use 'get', 'set', 'delete', 'snapshot', or 'restore'.",code:"validation_error",json:o,fields:r?.fields})}var ke,Ti,Ys,zs=Pe(()=>{"use strict";Q();ke=F(H(),1);J();ye();He();Ti=require("node:fs"),Ys=require("node:path")});var Rr={};Rt(Rr,{status:()=>Xs});function kl(e){return[Ye.default.yellow(e.type),e.name,Ye.default.cyan(e.value)+(e.priority?Ye.default.dim(` pri=${e.priority}`):"")]}function jl(e){if(O(`Status ${w.domain(e.domain)}`),e.expires){let t=new Date(e.expires).toLocaleDateString(),i=e.days_until_expiry,s=i!=null&&i<30?Ye.default.red:i!=null&&i<90?Ye.default.yellow:Ye.default.green;$("Expires",`${t} ${Ye.default.dim("(")}${s(`${i} days`)}${Ye.default.dim(")")}`)}}async function Xs(e,t){if(e||(e=await me()),ee(e,t),t.json){let p=await S(`/api/domains/${encodeURIComponent(e)}/status`),g=await p.json();p.ok||h(g.error||g.message,{hint:g.hint,status:p.status,json:t.json,fields:t.fields}),k(g,t.fields);return}let i=j(!0);i.start(`Checking ${w.domain(e)}`);let s;try{s=await S(`/api/domains/${encodeURIComponent(e)}/status`,{headers:{Accept:"text/event-stream"},signal:AbortSignal.timeout(t.timeout?parseInt(t.timeout,10)*1e3:3e4)})}catch{i.stop("Failed"),h("Request timed out",{hint:"The status check took too long. Try again.",code:"timeout",json:t.json,fields:t.fields})}if(!s.ok){i.stop("Failed");try{let p=await s.json();h(p.error||p.message,{hint:p.hint,status:s.status,json:t.json,fields:t.fields})}catch{h(`Server error (${s.status})`,{status:s.status,json:t.json,fields:t.fields})}}let n=s.body;n||(i.stop("Failed"),h("Empty response"));let r=new TextDecoder,o="",a=null,l=[],c=!1,u="";try{for await(let p of n){o+=r.decode(p,{stream:!0});let g=o.split(`
179
- `);o=g.pop()??"";for(let _ of g)if(_.startsWith("event: "))u=_.slice(7);else if(_.startsWith("data: ")){let y=JSON.parse(_.slice(6));if(u==="info"&&(i.stop("Status retrieved"),c=!0,jl(y)),u==="records")if(l=y,l.length>0){d(),console.log(` ${Ye.default.bold("DNS Records")}`);let m=[8,10,34];a=Ut(["Type","Name","Value"],l.map(v=>({cells:kl(v),status:"pending"})),m),a.start()}else d(),$("DNS",Ye.default.dim("no records")),A("Auto-configure DNS:",`domani connect ${e}`);if(u==="propagation"&&a){let{index:m,propagated:v}=y,x=v?b.success:`${b.warning}`;a.markDone(m,x)}u==="done"&&a&&a.stop(),u==="error"&&(c||i.stop("Failed"),a&&a.stop(),h(y.message||"Status check failed"))}}}catch{c||i.stop("Failed"),a&&a.stop(),h("Connection lost",{hint:"The status check was interrupted. Try again.",code:"connection_lost",json:t.json,fields:t.fields})}c||i.stop("Done"),d()}var Ye,Zs=Pe(()=>{"use strict";Q();Ye=F(H(),1);J();ye();He()});var Qt={};Rt(Qt,{buy:()=>en});async function Qs(e){let t=await Ge({message:`What's next for ${Te.default.cyan(e)}?`,options:[{value:"connect",label:"Connect to a service",hint:"domani connect"},{value:"email",label:"Set up email",hint:"domani email setup"},{value:"dns",label:"Configure DNS",hint:"domani dns"},{value:"status",label:"Check status & DNS propagation",hint:"domani status"},{value:"done",label:"Done"}]});if(oe(t)||t==="done"){d();return}if(d(),t==="connect"){let{connect:i}=await Promise.resolve().then(()=>(Js(),_r));await i(e,void 0,{})}else if(t==="email"){let i=await Ae({message:`Mailbox name for ${Te.default.cyan(e)}`,placeholder:"e.g. hey, hello, contact"});if(oe(i)||!i){d();return}d();let{email:s}=await Promise.resolve().then(()=>(Gs(),Or));await s("create",void 0,{domain:e,slug:i})}else if(t==="dns"){let{dns:i}=await Promise.resolve().then(()=>(zs(),Ar));await i(e)}else if(t==="status"){let{status:i}=await Promise.resolve().then(()=>(Zs(),Rr));await i(e,{})}}async function Sl(e,t){ee(e,t);let i;if(t.preChecked)i={available:!0,...t.preChecked};else{let u=j(!t.json);u.start(`Checking ${w.domain(e)}`);let p=await S(`/api/domains/search?q=${encodeURIComponent(e)}`);i=await p.json(),p.ok||(u.stop("Search failed"),h(i.error,{hint:i.hint,status:p.status,json:t.json,fields:t.fields})),i.available||(u.stop(`${b.error} ${w.domain(e)} is not available`),h(`${e} is not available`,{code:"not_available",json:t.json,fields:t.fields})),u.stop(`${b.success} ${w.domain(e)} ${b.dot} available ${b.dot} ${w.price(i.price)}/yr`)}if(t.dryRun)return z("buy",{domain:e,available:!0,price:i.price,currency:i.currency||"USD"},t.json,t.fields);if(!Ct(t)){let u=await We({message:`Purchase ${Te.default.bold(e)} for ${w.price(i.price)}/yr?`});if(!u||typeof u=="symbol"){console.log(` ${Te.default.dim("Cancelled.")}`);return}}let s=j(!t.json);s.start("Purchasing");let n=await S("/api/domains/buy",{method:"POST",headers:{Accept:"text/event-stream"},body:JSON.stringify({domain:e})});if(!n.ok||!n.body){s.stop("Purchase failed");let u=await n.json().catch(()=>({}));h(u.error||u.message,{hint:u.hint,fixUrl:u.setup_url||u.payment_options?.card?.setup_url,status:n.status,json:t.json,fields:t.fields})}let r={},o=new TextDecoder,a="",l="";for await(let u of n.body){a+=o.decode(u,{stream:!0});let p=a.split(`
180
- `);a=p.pop()??"";for(let g of p)if(g.startsWith("event: "))l=g.slice(7).trim();else if(g.startsWith("data: ")){let _=JSON.parse(g.slice(6));l==="checking"?s.message(`Checking ${w.domain(_.domain)}`):l==="payment"?s.message(`Charging ${w.price(_.total)}`):l==="registering"?s.message(`Registering ${w.domain(_.domain)}`):l==="registered"?r=_:l==="error"&&(s.stop("Purchase failed"),h(_.error,{hint:_.hint,fixUrl:_.setup_url,status:n.status,json:t.json,fields:t.fields}))}}let c=r.expires?Te.default.dim(` \xB7 expires ${new Date(r.expires).toLocaleDateString()}`):"";if(s.stop(`${b.success} ${w.domain(r.domain)} is yours!${c}`),t.json){k(r,t.fields);return}xe?await Qs(r.domain):(A("Connect to a service:",`domani connect ${r.domain}`),A("Set up email:",`domani email setup ${r.domain}`),A("Configure DNS:",`domani dns ${r.domain}`),d())}async function Cl(e,t){vr(e,t);let i=!!t.json,s=j(!i);s.start(`Checking ${e.length} domains`);let n=await Promise.all(e.map(async m=>{try{let v=await S(`/api/domains/search?q=${encodeURIComponent(m)}`),x=await v.json();return{domain:m,available:v.ok&&x.available,price:x.price}}catch{return{domain:m,available:!1,price:void 0}}})),r=n.filter(m=>m.available),o=n.filter(m=>!m.available);r.length===0&&(s.stop(`${b.error} None of the ${e.length} domains are available`),process.exit(1));let a=r.reduce((m,v)=>m+(v.price||0),0);if(s.stop(`${b.success} ${r.length}/${e.length} available ${b.dot} ${w.price(a.toFixed(2))} total`),o.length>0)for(let m of o)console.log(` ${b.error} ${w.domain(m.domain)} ${Te.default.dim("not available")}`);if(t.dryRun)return z("buy_bulk",{domains:r.map(m=>({domain:m.domain,price:m.price})),unavailable:o.map(m=>m.domain),total_price:parseFloat(a.toFixed(2))},t.json,t.fields);if(!Ct(t)){let m=await We({message:`Purchase ${Te.default.bold(String(r.length))} domain${r.length>1?"s":""} for ${w.price(a.toFixed(2))}?`});if(!m||typeof m=="symbol"){console.log(` ${Te.default.dim("Cancelled.")}`);return}}d();let l=r.map(m=>({cells:[w.domain(m.domain),m.price?`${w.price(m.price.toFixed(2))}/yr`:""],status:"pending"})),c=Ut(["Domain","Price"],l,[30,12],!i);c.start();let p=await(await S("/api/domains/buy",{method:"POST",body:JSON.stringify({domains:r.map(m=>m.domain)})})).json(),g=new Set((p.results||[]).map(m=>m.domain));for(let m=0;m<r.length;m++){let v=r[m].domain.toLowerCase().trim();g.has(v)?c.markDone(m,b.success):c.markDone(m,b.error)}if(c.stop(),i){k(p,t.fields);return}d();let _=p.summary?.succeeded??0,y=p.summary?.failed??0;if(_>0&&console.log(` ${b.success} ${Te.default.green(`${_} domain${_>1?"s":""} registered`)}`),y>0){console.log(` ${b.error} ${Te.default.red(`${y} failed`)}`);for(let m of p.errors||[])console.log(` ${Te.default.dim("\u2500")} ${w.domain(m.domain)}: ${Te.default.dim(m.error)}${m.hint?` ${Te.default.dim(`(${m.hint})`)}`:""}`)}if(d(),_>0&&xe){let m=(p.results||[]).filter(v=>v.success).map(v=>v.domain);if(m.length===1)await Qs(m[0]);else{let v=await Ge({message:"Set up one of your new domains?",options:[...m.map(x=>({value:x,label:Te.default.cyan(x)})),{value:"done",label:"Done"}]});!oe(v)&&v!=="done"?(d(),await Qs(v)):d()}}else _>0&&(A("Connect to a service:","domani connect <domain>"),A("Set up email:","domani email setup <domain>"),d())}async function en(e,t){let i=e.filter(Boolean);if(i.length===0){xe||h("Missing required argument: domain(s)",{hint:"Usage: domani buy <domain> [domain2 ...]",code:"missing_argument",json:t.json});let s=await Ae({message:"Domain to purchase",placeholder:"e.g. myapp.dev (space-separated for multiple)"});(oe(s)||!s)&&process.exit(0),i=s.split(/\s+/).filter(Boolean)}return i.length===1?Sl(i[0],t):Cl(i,t)}var Te,Mt=Pe(()=>{"use strict";Q();Ie();Te=F(H(),1);J();ye()});var $n=F(gn(),1),{program:hc,createCommand:gc,createArgument:$c,createOption:yc,CommanderError:bc,InvalidArgumentError:vc,InvalidOptionArgumentError:wc,Command:yn,Argument:_c,Option:xc,Help:kc}=$n.default;var it=F(H(),1);pt();Ht();pt();var gt=F(H(),1);J();async function ur(e){let t=ze(),i=j(!e.json),s=rt();if(s.token){i.start("Checking session");try{let c=await fetch(`${t}/api/me`,{headers:{Authorization:`Bearer ${s.token}`}});if(c.ok){let u=await c.json();i.stop(`Already logged in as ${gt.default.bold(u.email)}`),e.json&&k({status:"already_logged_in",email:u.email});return}}catch{}i.stop("Session expired, re-authenticating"),d()}i.start("Requesting auth code");let n=await fetch(`${t}/api/auth/cli`,{method:"POST",headers:{"Content-Type":"application/json"}});if(!n.ok){i.stop("Failed to initiate login");try{let c=await n.json();h(c.error||c.message||`Server error (${n.status})`,{hint:c.hint,code:"login_failed",json:e.json})}catch{h(`Could not reach ${t}. Check your connection and try again.`,{code:"network_error",json:e.json})}}let{code:r,auth_url:o,expires_in:a}=await n.json();if(i.stop("Auth code received"),e.json){k({status:"awaiting_approval",code:r,auth_url:o,expires_in:a});return}d(),console.log(` ${gt.default.dim("Verification code:")} ${gt.default.bold(gt.default.cyan(r))}`),e.open!==!1?(console.log(` ${gt.default.dim("Opening browser")} ${b.arrow} ${w.url(o)}`),Qe(o)):console.log(` ${gt.default.dim("Open this URL to approve:")} ${w.url(o)}`),d(),i.start("Waiting for approval");let l=120;for(let c=0;c<l;c++){await new Promise(g=>setTimeout(g,5e3));let u=await fetch(`${t}/api/auth/cli/poll?code=${r}`);!u.ok&&u.status!==202&&(i.stop("Login failed"),h(`Server error (${u.status})`,{code:"login_failed"}));let p=await u.json();if(p.status==="complete"){It({...rt(),token:p.token,email:p.email,api_url:t}),i.stop(`Logged in as ${gt.default.bold(p.email)}`),d(),A("Get started:","domani search"),d();return}p.error&&(i.stop("Login failed"),h(p.error||p.message,{hint:p.hint,code:"login_failed"}))}i.stop("Login timed out"),h("No approval received within 10 minutes",{hint:"Run 'domani login' to try again",code:"timeout"})}pt();var Ms=F(H(),1);J();async function mr(e){let t=rt();if(!t.token){e.json?k({status:"not_logged_in"}):console.log(` ${Ms.default.dim("Not logged in.")}`);return}let{api_url:i}=t;jn(),i&&It({api_url:i}),e.json?k({status:"logged_out",email:t.email||null}):console.log(` ${b.success} Logged out${t.email?` ${Ms.default.dim(`(${t.email})`)}`:""}`)}Q();var Xt=F(H(),1);J();async function gr(e){let t=await S("/api/me"),i=await t.json();if(t.ok||h(i.error||i.message,{hint:i.hint,status:t.status,json:e.json,fields:e.fields}),e.json){k(i,e.fields);return}O("Account"),$("Email",Xt.default.bold(i.email)),$("Payment",i.has_payment_method?`${b.success} ${Xt.default.green("active")}`:`${b.error} ${Xt.default.dim("none")}`),$("Domains",String(i.domain_count)),$("API tokens",String(i.token_count)),$("Referral code",i.referral_code||Xt.default.dim("-")),$("Created",new Date(i.created_at).toLocaleDateString()),d()}Q();Ie();var T=F(H(),1);J();ye();var Le=10,Pi=["com","io","ai","dev","app","co","net","org","xyz","sh","me","cc","tech","run","cloud","so","gg","fm","tv","pro","one","inc","ltd","llc","biz","group","global","ventures","capital","fund","agency","store","shop","market","sale","deals","auction","trade","studio","design","art","space","style","fashion","luxury","brand","media","digital","site","online","live","show","world","zone","land","place","city","town","blog","news","social","chat","link","page","fun","lol","meme","wtf","tools","build","works","work","team","solutions","services","systems","network","software","music","video","photo","photos","game","games","club","stream","film","movie","pizza","coffee","beer","bar","pub","restaurant","cafe","kitchen","food","wine","health","care","clinic","dental","fitness","yoga","bio","life","lifestyle","finance","money","legal","law","cash","academy","university","education","training","courses","science","wiki","guide","us","uk","eu","ca","au","de","fr","it","es","nl","jp","sg","nz","mx","house","homes","realty","estate","garden","nyc","london","berlin","paris","guru","ninja","rocks","fail","party","vip","gold","black","pink","red","events","travel","sport","jobs","careers","consulting","energy","eco","green","support","help","info","new","now","today","day"],Di=null;async function Er(){if(Di)return Di;try{let e=await $e("/api/tlds?sort=price&order=asc&limit=1000");if(e.ok){let i=(await e.json()).tlds.map(s=>s.tld);if(i.length>0){let s=new Set(Pi),n=new Set(i),r=[...Pi.filter(o=>n.has(o)),...i.filter(o=>!s.has(o))];return Di=r,r}}}catch{}return Di=Pi,Pi}async function Ol(e,t,i,s,n){let r=[],o=[],a=Le,l=0,c=!0,u=0,p=0,g=0,_=0,y=!1,m=!1,v=null,x="",C=["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"],E=0,V=setInterval(()=>{m||!c||(E=(E+1)%C.length,Y())},80);function L(){u>0&&(process.stdout.write(`\x1B[${u}A\x1B[0J`),u=0)}function G(){if(c)return[];let q=Le+_*Le;return r.length>a||s&&q<n.length?["more","new","skip"]:["new","skip"]}function I(){return r.slice(0,a)}function D(){let q=G();return Math.max(0,I().length+q.length-1)}let N=6;function Y(){L();let q=[],K=I(),de=!c&&K.length===0&&o.length>0,fe=de?o.slice(0,N):K,Ce=fe.reduce((ge,ae)=>Math.max(ge,ae.domain.length),0),Me=G();for(let ge=0;ge<fe.length;ge++){let ae=fe[ge];if(de)q.push(`${T.default.dim("\u2502")} ${T.default.dim("\u2715")} ${T.default.dim(ae.domain.padEnd(Ce))} ${T.default.dim("taken")}`);else{let W=ge===l,Je=W?T.default.green("\u25CF"):T.default.dim("\u25CB"),mt=ae.domain.padEnd(Ce),Ui=W?T.default.bold(T.default.cyan(mt)):mt,Mi=ae.for_sale?T.default.cyan(`$${ae.for_sale.price} (for sale)`):T.default.dim(`$${ae.price}/yr`);q.push(`${T.default.dim("\u2502")} ${Je} ${Ui} ${Mi}`)}}if(de&&o.length>N&&q.push(`${T.default.dim("\u2502")} ${T.default.dim(`\u2026 and ${o.length-N} more taken`)}`),c){let ge=x?T.default.dim(`checking ${x}\u2026`):T.default.dim("searching\u2026");q.push(`${T.default.dim("\u2502")} ${T.default.cyan(C[E])} ${ge}`)}else{let ge=Le+_*Le;s&&ge>=n.length&&q.push(`${T.default.dim("\u2502")} ${T.default.dim(`All ${Math.min(ge,n.length)} TLDs searched`)}`);for(let W=0;W<Me.length;W++){let Ui=I().length+W===l?T.default.green("\u25CF"):T.default.dim("\u25CB"),Mi=Me[W]==="more"?T.default.dim("More \u2192"):Me[W]==="new"?T.default.dim("New search \u2192"):T.default.dim("Skip");q.push(`${T.default.dim("\u2502")} ${Ui} ${Mi}`)}q.push(T.default.dim("\u2514"))}process.stdout.write(q.join(`
176
+ `}}}}).prompt()});function Ka(e){return!!(e.json||!ke)}function R(e,t=50){console.log(),console.log(` ${M.default.bold(e)}`),console.log(` ${M.default.dim("\u2500".repeat(t))}`)}function $(e,t,s=2){let i=" ".repeat(s);console.log(`${i}${M.default.dim(e.padEnd(16))} ${t}`)}function c(){console.log()}function Vt(e){console.log(` ${M.default.dim(e)}`)}function O(e,t){console.log(` ${M.default.dim(e)} ${M.default.cyan(t)}`)}function ur(e){return e.split(/(https?:\/\/[^\s]+)/g).map(s=>/^https?:\/\//.test(s)?`\x1B]8;;${s}\x1B\\${M.default.underline(M.default.cyan(s))}\x1B]8;;\x1B\\`:M.default.dim(s)).join("")}function Mi(e,t){console.error(` ${b.error} ${M.default.red(e)}`),t&&console.error(` ${ur(t)}`)}function j(e=!0){return e?Xt():za}function mr(e){return e.replace(Xa,"")}function Es(e,t){let s=mr(e).length,i=Math.max(0,t-s);return e+" ".repeat(i)}function me(e,t,s){let i=s||e.map((o,a)=>{let l=t.reduce((d,u)=>Math.max(d,mr(u[a]||"").length),0);return Math.max(o.length,l)+2}),n=e.map((o,a)=>M.default.dim(o.padEnd(i[a]))).join(" "),r=i.map(o=>M.default.dim("\u2500".repeat(o))).join(" ");console.log(` ${n}`),console.log(` ${r}`);for(let o of t){let a=o.map((l,d)=>Es(l,i[d])).join(" ");console.log(` ${a}`)}}function Za(e){return e.replace(/[A-Z]/g,t=>`_${t.toLowerCase()}`)}function Vi(e){if(Array.isArray(e))return e.map(Vi);if(e&&typeof e=="object"&&!(e instanceof Date)){let t={};for(let[s,i]of Object.entries(e))t[Za(s)]=Vi(i);return t}return e}function k(e,t){let s=Vi(e);if(!t){console.log(JSON.stringify(s,null,2));return}let i=t.split(",").map(n=>n.trim()).filter(Boolean);if(Array.isArray(s)){let n=s.map(r=>lr(r,i));console.log(JSON.stringify(n,null,2))}else console.log(JSON.stringify(s&&typeof s=="object"?lr(s,i):s,null,2))}function lr(e,t){let s={};for(let i of t)i in e&&(s[i]=e[i]);if(Object.keys(s).length===0){for(let[i,n]of Object.entries(e))if(Array.isArray(n)&&n.length>0&&typeof n[0]=="object"){let r=n.map(o=>{let a={};for(let l of t)l in o&&(a[l]=o[l]);return a});Object.keys(r[0]).length>0&&(s[i]=r)}}return s}function Ct(e){return!!(e.yes||Ka(e))}function z(e,t,s,i){if(s){k({dry_run:!0,action:e,...t},i);return}console.log(),console.log(` ${M.default.yellow("\u25B8 DRY RUN")} ${M.default.dim("- no changes made")}`),console.log(` ${M.default.dim("Action:")} ${M.default.bold(e)}`);for(let[n,r]of Object.entries(t))r!=null&&(Array.isArray(r)?console.log(` ${M.default.dim(n+":")} ${r.map(String).join(", ")}`):console.log(typeof r=="object"?` ${M.default.dim(n+":")} ${JSON.stringify(r)}`:` ${M.default.dim(n+":")} ${String(r)}`));console.log()}function el(e,t,s){return t===401||t===403?"auth_required":t===402||s?"payment_required":t===404?"not_found":t===409?"conflict":t===422?"validation_error":t===429?"rate_limited":/contact/i.test(e)?"contact_required":"error"}function h(e,t){let s=e||`Request failed${t?.status?` (${t.status})`:""}`,i=t?.code||el(s,t?.status,t?.fixUrl),n=t?.fixCommand||Qa[i];if(t?.json){let r={error:s,code:i};t.hint&&(r.hint=t.hint),n&&(r.fix_command=n),t.fixUrl&&(r.fix_url=t.fixUrl),k(r,t.fields)}else Mi(s,t?.hint),n?console.error(` ${M.default.dim("Or run:")} ${M.default.cyan(n)}`):t?.fixUrl&&console.error(` ${ur(`Add a payment method at ${t.fixUrl}`)}`);process.exit(1)}function ze(e){let t=process.platform==="darwin"?"open":process.platform==="win32"?"start":"xdg-open";(0,dr.execFile)(t,[e])}function Ot(e){return new Promise(t=>setTimeout(t,e))}function Rt(e,t,s,i=!0){let n=process.stdout.isTTY??!1;if(!i)return{start(){},markDone(){},stop(){}};let r=0,o=null,a=2+t.length;function l(){let g=" "+e.map((f,v)=>M.default.dim(f.padEnd(s[v]))).join(" "),x=" "+s.map(f=>M.default.dim("\u2500".repeat(f))).join(" "),y=[g,x];for(let f of t){let v=f.status==="done"?f.icon??b.success:M.default.cyan(cr[r%cr.length]),_=f.cells.map((C,A)=>Es(C,s[A])).join(" ");y.push(` ${v} ${_}`)}return y}let d=!1,u=()=>process.stdout.write("\x1B[?25h");function p(){let g=l();if(d&&n){process.stdout.write(`\x1B[${a}A`);for(let x of g)process.stdout.write(`\x1B[2K${x}
177
+ `)}else{for(let x of g)console.log(x);d=!0}}return{start(){n&&(process.stdout.write("\x1B[?25l"),process.on("exit",u)),p(),n&&(o=setInterval(()=>{r++,p()},80))},markDone(g,x){t[g].status="done",x!==void 0&&(t[g].icon=x),n&&p()},stop(){o&&clearInterval(o);for(let g of t)g.status="done";p(),n&&(process.stdout.write("\x1B[?25h"),process.removeListener("exit",u))}}}var M,dr,ke,b,w,za,Xa,Qa,cr,H=De(()=>{"use strict";M=U(J(),1),dr=require("child_process");Te();ke=process.stdout.isTTY??!1;b={success:M.default.green("\u2713"),error:M.default.red("\u2717"),warning:M.default.yellow("!"),info:M.default.cyan("\u25CF"),arrow:M.default.dim("\u2192"),dot:M.default.dim("\xB7"),dash:M.default.dim("\u2500")},w={domain:e=>M.default.bold(M.default.white(e)),price:e=>M.default.green(`$${e}`),label:e=>M.default.dim(e),value:e=>M.default.white(e),dim:e=>M.default.dim(e),bold:e=>M.default.bold(e),success:e=>M.default.green(e),error:e=>M.default.red(e),warn:e=>M.default.yellow(e),cyan:e=>M.default.cyan(e),url:e=>`\x1B]8;;${e}\x1B\\${M.default.underline(M.default.cyan(e))}\x1B]8;;\x1B\\`};za={start:()=>{},stop:()=>{},message:()=>{}};Xa=/\x1b\]8;;[^\x1b]*\x1b\\|\x1b\[[0-9;]*m/g;Qa={auth_required:"domani login",payment_required:"domani card add",contact_required:"domani contact set"};cr=["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"]});async function fr(){if(Wi)return;let e=process.argv.includes("--json")||!li,t=Ge(),s=pt();try{if((await(await fetch(`${t}/api/me`,{headers:{Authorization:`Bearer ${s}`}})).json()).plan==="pro"){Wi=!0;return}}catch{}e&&(console.log(JSON.stringify({error:"Pro plan required",code:"upgrade_required",hint:"Upgrade at https://domani.run/settings",fix_command:"domani upgrade"},null,2)),process.exit(1)),c(),console.log(` ${ye.default.dim("This feature requires")} ${ye.default.bold("Pro")} ${ye.default.dim("($9/month).")}`),console.log(` ${ye.default.dim("Opening billing page")} ${b.arrow} ${ye.default.cyan("domani.run/settings")}`),ze(`${t.replace("http://localhost:3000","https://domani.run")}/settings`),c();let i=j(!0);i.start("Waiting for upgrade...");for(let n=0;n<120;n++){await new Promise(r=>setTimeout(r,5e3));try{if((await(await fetch(`${t}/api/me`,{headers:{Authorization:`Bearer ${s}`}})).json()).plan==="pro"){Wi=!0,i.stop(`${b.success} Upgraded to Pro! Continuing...`),c();return}}catch{}}i.stop("Timed out"),console.error(` ${ye.default.red("\u2717")} No upgrade detected. Visit ${ye.default.cyan("domani.run/settings")} to upgrade.`),process.exit(1)}async function pr(){if(qi||pt()){qi=!0;return}(process.argv.includes("--json")||!li)&&(console.log(JSON.stringify({error:"Not logged in",code:"auth_required",hint:"Run 'domani login' or set DOMANI_API_KEY environment variable",fix_command:"domani login"},null,2)),process.exit(1)),c(),console.log(` ${ye.default.dim("You're not logged in.")} Starting authentication...`),c();let t=Ge(),s=j(!0);s.start("Requesting auth code");let i;try{i=await fetch(`${t}/api/auth/cli`,{method:"POST",headers:{"Content-Type":"application/json"}})}catch{s.stop("Failed"),console.error(` ${ye.default.red("\u2717")} Could not reach ${t}. Check your connection.`),process.exit(1)}if(!i.ok){s.stop("Failed");let o=`Server error (${i.status})`;try{let a=await i.json();o=a.error||a.message||o}catch{}console.error(` ${ye.default.red("\u2717")} ${o}`),process.exit(1)}let n,r;try{({code:n,auth_url:r}=await i.json())}catch{s.stop("Failed"),console.error(` ${ye.default.red("\u2717")} Invalid response from server.`),process.exit(1)}s.stop(`${b.success} Auth code ready`),c(),console.log(` ${ye.default.dim("Verification code:")} ${ye.default.bold(ye.default.cyan(n))}`),console.log(` ${ye.default.dim("Opening browser")} ${b.arrow} ${w.url(r)}`),ze(r),c(),s.start("Waiting for browser approval");for(let o=0;o<120;o++){await new Promise(d=>setTimeout(d,5e3));let a=await fetch(`${t}/api/auth/cli/poll?code=${n}`).catch(()=>null);if(!a||!a.ok&&a.status!==202)continue;let l=await a.json().catch(()=>({}));if(l.status==="complete"){Pt({...rt(),token:l.token,email:l.email,api_url:t}),qi=!0,s.stop(`${b.success} Logged in as ${ye.default.bold(l.email)}`),c();return}}s.stop("Timed out"),console.error(` ${ye.default.red("\u2717")} No approval received. Run ${ye.default.cyan("domani login")} to try again.`),process.exit(1)}var ye,qi,Wi,Hi=De(()=>{"use strict";ye=U(J(),1);ht();H();qi=!1,Wi=!1});function $r(e){return e.json=async()=>{let t=await e.clone().text();try{return JSON.parse(t)}catch{return{error:`Server error (${e.status})`,hint:"The server returned an unexpected response. Try again later."}}},e}async function S(e,t={},s=!1){let i=pt(),n=`${Ge()}${e}`,r=await fetch(n,{...t,headers:{Authorization:`Bearer ${i}`,"Content-Type":"application/json","User-Agent":`domani-cli/${xe}`,...t.headers}});if(!s){let o=await r.clone().text();try{if(JSON.parse(o).code==="UPGRADE_REQUIRED")return await fr(),S(e,t,!0)}catch{}}return $r(r)}async function $e(e,t={}){let s=`${Ge()}${e}`,i=pt(),n=await fetch(s,{...t,headers:{"Content-Type":"application/json","User-Agent":`domani-cli/${xe}`,...i?{Authorization:`Bearer ${i}`}:{},...t.headers}});return $r(n)}var Q=De(()=>{"use strict";ht();Hi()});function yt(){return{ok:!0}}function at(e,t,s){return{ok:!1,error:{message:e,code:t,hint:s}}}function vr(e){return tl.test(e)?at("Input contains control characters","invalid_input","Remove non-printable characters from the input"):yt()}function al(e){return sl.test(e)?at("Input contains path traversal","invalid_input","Domain names cannot contain '../' or '..\\'"):yt()}function ll(e){return il.test(e)?at("Input contains query string or fragment","invalid_input","Remove '?' or '#' from the domain name"):yt()}function cl(e){return nl.test(e)?at("Input contains percent-encoded characters","invalid_input","Use plain text, not URL-encoded values (e.g. 'example.com' not 'example%2Ecom')"):yt()}function wr(e){if(!e)return at("Domain name is required","validation_error");if(e.length>br)return at(`Domain name too long (${e.length} chars, max ${br})`,"validation_error");for(let t of[vr,al,ll,cl]){let s=t(e);if(!s.ok)return s}return rl.test(e)?yt():at(`Invalid domain name: ${e}`,"validation_error","Domain names can only contain letters, digits, hyphens, and dots")}function dl(e){if(!e)return at("TLD is required","validation_error");let t=vr(e);return t.ok?ol.test(e)?yt():at(`Invalid TLD: ${e}`,"validation_error","TLDs contain only letters (e.g. 'com', '.dev', 'ai')"):t}function ul(e){for(let t of e){let s=wr(t);if(!s.ok)return s}return yt()}function ml(e){for(let t of e){let s=dl(t);if(!s.ok)return s}return yt()}function ee(e,t){let s=wr(e);s.ok||h(s.error.message,{code:s.error.code,hint:s.error.hint,json:t?.json,fields:t?.fields})}function _r(e,t){let s=ul(e);s.ok||h(s.error.message,{code:s.error.code,hint:s.error.hint,json:t?.json,fields:t?.fields})}function Is(e,t){let s=ml(e);s.ok||h(s.error.message,{code:s.error.code,hint:s.error.hint,json:t?.json,fields:t?.fields})}var tl,sl,il,nl,rl,ol,br,be=De(()=>{"use strict";H();tl=/[\x00-\x08\x0b\x0c\x0e-\x1f]/,sl=/\.\.[/\\]/,il=/[?#]/,nl=/%[0-9a-fA-F]{2}/,rl=/^[a-zA-Z0-9]([a-zA-Z0-9-]*[a-zA-Z0-9])?(\.[a-zA-Z0-9]([a-zA-Z0-9-]*[a-zA-Z0-9])?)*\.?$/,ol=/^\.?[a-zA-Z]{2,63}$/,br=253});async function ue(){ke||h("Missing required argument: domain",{hint:"Pass the domain as an argument, e.g. 'domani settings example.com'",code:"missing_argument",json:!0});let e=j(!0);e.start("Loading your domains");let t=await S("/api/domains"),s=await t.json();t.ok||(e.stop("Failed"),Mi(s.error,s.hint),process.exit(1));let i=s.domains||[];i.length===0&&(e.stop("No domains"),c(),console.log(` ${Bi.default.dim("No domains yet.")} Use: ${Bi.default.cyan("domani buy <domain>")}`),c(),process.exit(0)),e.stop(`${i.length} domain(s)`);let n=await Ke({message:"Which domain?",options:i.map(r=>({value:r.domain,label:r.domain,hint:r.status!=="active"?r.status:void 0}))});return oe(n)&&process.exit(0),n}var Bi,Je=De(()=>{"use strict";Q();Te();Bi=U(J(),1);H()});var kr={};It(kr,{connect:()=>Gi});async function Gi(e,t,s){e||(e=await ue()),ee(e,s);let i;if(t&&!s.provider?t.includes(".")?i=t:s.provider=t:i=t,!i&&!s.provider&&!s.list&&s.dryRun)return z("connect",{domain:e,note:"No provider specified. Pass --provider <name> to connect."},s.json,s.fields);if(!i&&!s.provider&&!s.list){let n=j(!s.json);n.start(`Loading providers for ${w.domain(e)}`);let r=await S(`/api/domains/${encodeURIComponent(e)}/connect`),o=await r.json();if(r.ok||(n.stop("Failed"),h(o.error||o.message,{hint:o.hint,status:r.status,json:s.json,fields:s.fields})),n.stop("Providers loaded"),s.json){k(o,s.fields);return}let a=[];for(let f of["hosting","email"]){let v=o.providers?.[f]||[];for(let _ of v)a.push({value:`${f}:${_.name}`,label:_.name,hint:f})}a.length===0&&h("No providers available",{code:"not_found",json:s.json,fields:s.fields});let l=await Ke({message:"Choose a provider",options:a});oe(l)&&process.exit(0);let[d,u]=l.split(":"),g=(o.providers?.[d]||[]).find(f=>f.name===u),x;if(g&&g.methods.length>1){let f=await Ke({message:"Choose a method",options:g.methods.map(v=>({value:v.name,label:v.name,hint:v.default?"default":void 0}))});oe(f)&&process.exit(0),x=f}let y;if(d==="hosting"&&g?.requires_target){g.notes?.setup&&Vt(g.notes.setup);let f=await Ae({message:"Target hostname or IP"});oe(f)&&process.exit(0),y=f.trim()}return xr(e,{target:y,provider:u,method:x,dryRun:s.dryRun,json:!1})}if(s.list){let n=j(!s.json);n.start(`Loading providers for ${w.domain(e)}`);let r=await S(`/api/domains/${encodeURIComponent(e)}/connect`),o=await r.json();if(r.ok||(n.stop("Failed"),h(o.error||o.message,{hint:o.hint,status:r.status,json:s.json,fields:s.fields})),n.stop("Providers loaded"),s.json){k(o,s.fields);return}R(`Providers for ${w.domain(o.domain)}`);for(let a of["hosting","email"]){let l=o.providers?.[a];if(l?.length){c(),console.log(` ${ce.default.bold(a.toUpperCase())}`);for(let d of l){let u=d.methods.map(p=>p.default?ce.default.green(`${p.name} (default)`):ce.default.dim(p.name)).join(ce.default.dim(", "));console.log(` ${ce.default.cyan(d.name.padEnd(20))} ${u}`)}}}c();return}return xr(e,s)}async function xr(e,t){let s={};if(t.target&&(s.target=t.target),t.provider&&(s.provider=t.provider),t.method&&(s.method=t.method),t.dryRun)return z("connect",{domain:e,...s},t.json,t.fields);let i=j(!t.json);i.start(`Connecting ${w.domain(e)}`);let n=await S(`/api/domains/${encodeURIComponent(e)}/connect`,{method:"POST",body:JSON.stringify(s)}),r=await n.json();n.ok||(i.stop("Connection failed"),h(r.error||r.message,{hint:r.hint,status:n.status,json:t.json,fields:t.fields}));let o=r.status==="manual_setup_required";if(i.stop(o?`${b.success} DNS instructions for ${ce.default.cyan(r.provider)}`:`${b.success} Connected to ${ce.default.cyan(r.provider)}`),t.json){k(r,t.fields);return}if(R(o?`Add these records at your registrar for ${w.domain(r.domain)}`:`Connected ${w.domain(r.domain)}`),$("Provider",ce.default.cyan(r.provider)),$("Method",r.method),r.records?.length){let a=[8,22,40];c(),console.log(` ${ce.default.bold("DNS Records")}`);let l=["Type","Name","Value"].map((u,p)=>ce.default.dim(u.padEnd(a[p]))).join(" "),d=a.map(u=>ce.default.dim("\u2500".repeat(u))).join(" ");console.log(` ${l}`),console.log(` ${d}`);for(let u of r.records){let p=u.record,g=u.status!=="already_set";process.stdout.isTTY&&g&&await Ot(50);let y=[ce.default.yellow(p.type),p.name,ce.default.cyan(p.value)+(p.priority?ce.default.dim(` pri=${p.priority}`):"")].map((_,C)=>Es(_,a[C])).join(" "),f=u.status==="already_set"?ce.default.dim("\u2713"):u.status==="updated"?ce.default.yellow("\u21BA"):u.status==="pending"?ce.default.yellow("\u2192"):b.success,v=u.status==="already_set"?ce.default.dim(" already set"):u.status==="updated"?ce.default.dim(" updated"):u.status==="pending"?ce.default.dim(" add this"):"";console.log(` ${f} ${y}${v}`)}}c(),r.next_steps?.length?(console.log(` ${ce.default.bold("Next steps")}`),r.next_steps.forEach((a,l)=>{console.log(` ${ce.default.dim(`${l+1}.`)} ${a}`)})):r.hint&&console.log(` ${ce.default.dim(r.hint)}`),r.docs&&console.log(` ${ce.default.dim("Docs:")} ${w.url(r.docs)}`),c()}var ce,Yi=De(()=>{"use strict";Q();ce=U(J(),1);Te();H();be();Je()});var Ar={};It(Ar,{email:()=>Qt});function hl(e){return[N.default.yellow(e.type),e.name,N.default.cyan(e.value)+(e.priority?N.default.dim(` pri=${e.priority}`):"")]}function Ki(e){return pl[e]||e}function gl(e,t){if(e&&e.includes("@")){let[s,i]=e.split("@",2);!t.slug&&s&&(t.slug=s),!t.domain&&i&&(t.domain=i)}}async function lt(e){return e.domain?(ee(e.domain,e),e.domain):ue()}async function Qt(e,t,s){if(e&&e.includes(".")&&!fl.includes(e))return s.check?Sr(e,!!s.json,s.fields):t?Cr(e,t,!!s.json,s.fields):Or(e,!!s.json,s.fields);if(gl(t,s),s.body&&!s.text&&(s.text=s.body),s.title&&!s.subject&&(s.subject=s.title),s.from&&s.from.includes("@")){let[i,n]=s.from.split("@",2);!s.slug&&i&&(s.slug=i),!s.domain&&n&&(s.domain=n)}switch(e){case void 0:return jr(s);case"list":return jr(s);case"inbox":return xl(s);case"setup":return $l(s);case"status":return yl(s);case"remove":return bl(s);case"create":return vl(s);case"delete":return wl(s);case"send":return _l(s);case"webhook":return kl(s);case"forward":return jl(s);case"check":return Sr(s.domain||await ue(),!!s.json,s.fields);case"connect":return Cr(s.domain||await ue(),t||void 0,!!s.json,s.fields);default:h(`Unknown action: ${e}`,{hint:"Actions: list, inbox, create, delete, send, forward, webhook, setup, status, check, connect",code:"validation_error",json:s.json,fields:s.fields})}}async function $l(e){let t=await lt(e);if(e.dryRun)return z("email_setup",{domain:t},e.json,e.fields);let s=j(!e.json);s.start(`Setting up email on ${w.domain(t)}`);let i=await S(`/api/domains/${encodeURIComponent(t)}/email/setup`,{method:"POST"}),n=await i.json();if(i.ok||(s.stop("Failed"),h(n.error||n.message,{hint:n.hint,status:i.status,json:e.json,fields:e.fields})),s.stop(`${b.success} Email ${n.status==="already_configured"?"already configured":"configured"}`),e.json){k(n,e.fields);return}if(n.records?.length){c(),R(`Email DNS Records ${w.domain(t)}`);let r=n.records.map(o=>[N.default.yellow(o.type),o.name,o.value.length>40?o.value.slice(0,40)+"...":o.value,o.status==="verified"||o.status==="created"?N.default.green(o.status):N.default.yellow(o.status)]);me(["Type","Name","Value","Status"],r,[8,28,44,12])}c(),n.hint&&Vt(n.hint),O("Check status:",`domani email status --domain ${t}`),c()}async function yl(e){let t=await lt(e),s=j(!e.json);s.start(`Checking email status for ${w.domain(t)}`);let i=await S(`/api/domains/${encodeURIComponent(t)}/email/status`),n=await i.json();if(i.ok||(s.stop("Failed"),h(n.error||n.message,{hint:n.hint,status:i.status,json:e.json,fields:e.fields})),s.stop(`${b.success} Status loaded`),e.json){k(n,e.fields);return}if(R(`Email ${w.domain(t)}`),$("Enabled",n.enabled?N.default.green("yes"):N.default.dim("no")),n.enabled&&($("Verified",n.verified?N.default.green("yes"):N.default.yellow("pending")),$("Mailboxes",String(n.mailbox_count))),c(),!n.enabled)O("Set up email:",`domani email setup --domain ${t}`),c();else if(!n.verified&&n.records?.length){console.log(` ${N.default.yellow("!")} Add these DNS records to verify:`);for(let r of n.records)console.log(` ${N.default.yellow(r.type)} ${r.name} ${N.default.dim("\u2192")} ${r.value.length>50?r.value.slice(0,50)+"...":r.value}`);c()}}async function bl(e){let t=await lt(e);if(e.dryRun)return z("email_remove",{domain:t},e.json,e.fields);let s=j(!e.json);s.start(`Removing email from ${w.domain(t)}`);let i=await S(`/api/domains/${encodeURIComponent(t)}/email/setup`,{method:"DELETE"}),n=await i.json();if(i.ok||(s.stop("Failed"),h(n.error||n.message,{hint:n.hint,status:i.status,json:e.json,fields:e.fields})),s.stop(`${b.success} Email disabled`),e.json){k(n,e.fields);return}n.mailboxes_deleted>0&&console.log(` ${N.default.dim(`${n.mailboxes_deleted} mailbox(es) deleted.`)}`),c()}async function jr(e){let t=j(!e.json);t.start("Loading mailboxes");let s=e.domain?`?domain=${encodeURIComponent(e.domain)}`:"",i=await S(`/api/emails${s}`),n=await i.json();i.ok||(t.stop("Failed"),h(n.error||n.message,{hint:n.hint,status:i.status,json:e.json,fields:e.fields}));let r=n.mailboxes||[];if(t.stop(`${b.success} ${r.length} mailbox(es)`),e.json){k(n,e.fields);return}if(r.length===0){c(),console.log(` ${N.default.dim("No mailboxes.")}`),c(),O("Create one:","domani email create hello@example.com"),c();return}c(),R("Mailboxes");let o=r.map(a=>[N.default.cyan(a.address),String(a.message_count),a.webhook_url?w.url(a.webhook_url):N.default.dim("-"),N.default.dim(new Date(a.created_at).toLocaleDateString())]);me(["Address","Messages","Webhook","Created"],o,[32,10,36,14]),c()}async function vl(e){let t=await lt(e);if(e.dryRun)return z("email_create_mailbox",{domain:t,slug:e.slug},e.json,e.fields);let s=e.slug;if(!s&&!e.json){let d=await Ae({message:`Email handle for @${t}:`,placeholder:"hello"});oe(d)&&process.exit(0),s=d}s||h("Slug required",{hint:`Usage: domani email create hello@${t}`,code:"validation_error",json:e.json,fields:e.fields});let i=`${s}@${t}`,n=j(!e.json);n.start("Creating mailbox");let r=await S("/api/emails",{method:"POST",body:JSON.stringify({address:i})}),o=await r.json();if(r.status===202&&!e.json){n.stop("");let d=o.txt_record,u=o.email_records||[],p=[{type:"TXT",name:d?.name||"@",value:d?.value||"",note:"ownership proof"},...u];c(),console.log(" Add these records at your DNS provider:"),c();for(let _ of p){let C=_.priority!==void 0?` ${N.default.dim(`priority: ${_.priority}`)}`:"",A=_.note?` ${N.default.dim(`(${_.note})`)}`:"";console.log(` ${N.default.yellow(_.type)} ${N.default.bold(_.name)}${C}${A}`),console.log(` ${N.default.dim("\u2192")} ${N.default.cyan(_.value)}`),c()}Vt("DNS propagation typically takes 5\u201330 minutes. Checking automatically..."),c();let g=p.map(_=>({cells:[N.default.yellow(_.type),_.name,_.note?N.default.dim(`(${_.note})`):""],status:"pending"})),x=Rt(["Type","Name",""],g,[6,24,16]);x.start();let y=0;for(;r.status===202&&y<60;)await Ot(15e3),y++,r=await S("/api/emails",{method:"POST",body:JSON.stringify({address:i})}),o=await r.json(),r.status!==202&&!r.ok&&(x.stop(),h(o.error||o.message,{hint:o.hint,status:r.status,json:e.json,fields:e.fields}));r.status===202&&(x.stop(),h("TXT record not detected after 15 minutes.",{hint:`Check the record is set, then retry: domani email create ${i}`,code:"timeout",json:e.json,fields:e.fields})),x.markDone(0);let f=_=>`${_.type}:${_.name}`,v=new Map;p.slice(1).forEach((_,C)=>v.set(f(_),C+1));for(let _=0;_<60;_++){await Ot(15e3);let C=await S(`/api/domains/${encodeURIComponent(t)}/email/status`),A=await C.json();if(C.ok&&A.records){for(let F of A.records)if(F.status==="verified"||F.status==="created"){let L=v.get(f(F));L!==void 0&&x.markDone(L)}}if(C.ok&&A.verified)break}x.stop(),c()}if(r.ok||(n.stop("Failed"),h(o.error||o.message,{hint:o.hint,status:r.status,json:e.json,fields:e.fields})),n.stop(`${b.success} ${N.default.cyan(o.address)} created`),e.json){k(o,e.fields);return}let a=await S(`/api/domains/${encodeURIComponent(t)}/email/status`),l=await a.json();c(),a.ok&&l.verified?(O("Read inbox:",`domani email inbox ${o.address}`),O("Web inbox:",`${Ht}/inbox?address=${encodeURIComponent(o.address)}`)):(O("Check propagation:",`domani email status --domain ${t}`),O("Web inbox:",`${Ht}/inbox?address=${encodeURIComponent(o.address)}`)),c()}async function wl(e){let t=await lt(e);if(e.slug||h("Slug required",{hint:"Usage: domani email delete hello@example.com",code:"validation_error",json:e.json,fields:e.fields}),e.dryRun)return z("email_delete_mailbox",{domain:t,address:`${e.slug}@${t}`},e.json,e.fields);let s=j(!e.json);s.start(`Deleting ${e.slug}@${t}`);let i=encodeURIComponent(`${e.slug}@${t}`),n=await S(`/api/emails/${i}`,{method:"DELETE",body:JSON.stringify({confirm:!0})}),r=await n.json();if(n.ok||(s.stop("Failed"),h(r.error||r.message,{hint:r.hint,status:n.status,json:e.json,fields:e.fields})),s.stop(`${b.success} Mailbox deleted`),e.json){k(r,e.fields);return}console.log(` ${N.default.dim(`${r.address} and all messages deleted.`)}`),c()}async function _l(e){let t=await lt(e);if(e.slug||h("Slug required",{hint:'Usage: domani email send hello@example.com --to user@test.com --subject "Hi" --body "Hello"',code:"validation_error",json:e.json,fields:e.fields}),e.to||h("Recipient required",{hint:"Usage: domani email send hello@example.com --to user@test.com",code:"validation_error",json:e.json,fields:e.fields}),e.dryRun)return z("email_send",{from:`${e.slug}@${t}`,to:e.to,subject:e.subject},e.json,e.fields);let s=j(!e.json);s.start(`Sending from ${e.slug}@${t}`);let i={to:e.to};e.cc&&(i.cc=e.cc),e.bcc&&(i.bcc=e.bcc),e.subject&&(i.subject=e.subject),e.text&&(i.text=e.text),e.inReplyTo&&(i.in_reply_to=e.inReplyTo),e.references&&(i.references=e.references);let n=encodeURIComponent(`${e.slug}@${t}`),r=await S(`/api/emails/${n}/send`,{method:"POST",body:JSON.stringify(i)}),o=await r.json();if(!r.ok){s.stop("Failed");let l=o.code==="MONTHLY_LIMIT_EXCEEDED"?`Run ${N.default.cyan("domani upgrade")} to switch to Pro (10,000 emails/month).`:o.hint;h(o.error||o.message,{hint:l,status:r.status,json:e.json,fields:e.fields})}let a=Array.isArray(o.to)?o.to.join(", "):o.to;if(s.stop(`${b.success} Sent to ${N.default.cyan(a)}`),e.json){k(o,e.fields);return}}async function xl(e){let t=await lt(e);e.slug||h("Slug required",{hint:"Usage: domani email inbox hello@example.com [--direction in|out] [--limit 20]",code:"validation_error",json:e.json,fields:e.fields});let s=new URLSearchParams;e.direction&&s.set("direction",e.direction),e.limit&&s.set("limit",e.limit);let i=s.toString()?`?${s}`:"",n=j(!e.json);n.start(`Loading messages for ${e.slug}@${t}`);let r=encodeURIComponent(`${e.slug}@${t}`),o=await S(`/api/emails/${r}/messages${i}`),a=await o.json();o.ok||(n.stop("Failed"),h(a.error||a.message,{hint:a.hint,status:o.status,json:e.json,fields:e.fields}));let l=a.messages||[];if(e.json){n.stop(`${b.success} ${l.length} message(s)`),k(a,e.fields);return}if(l.length===0){n.stop(`${N.default.dim("No messages")}`);return}let d=l.length>1?"s":"";n.stop(`${b.success} ${N.default.cyan(`${e.slug}@${t}`)} ${N.default.dim("\xB7 "+l.length+" message"+d)}`);for(let u of l){let p=u.direction==="in"?N.default.green("in "):N.default.dim("out"),g=u.direction==="in"?u.from:u.to,x=u.subject||"(no subject)",y=N.default.dim(new Date(u.created_at).toLocaleString()),f=x;if(u.text){let v=u.text.replace(/\s+/g," ").trim(),_=v.length>60?v.slice(0,60)+"\u2026":v;f=`${x} ${N.default.dim("- "+_)}`}console.log(` ${p} ${g.padEnd(30)} ${f} ${y}`)}a.next_cursor&&console.log(` ${N.default.dim("\u2026 more available, use --limit to paginate")}`)}async function kl(e){let t=await lt(e);e.slug||h("Slug required",{hint:"Usage: domani email webhook hello@example.com --url https://...",code:"validation_error",json:e.json,fields:e.fields});let s=`${e.slug}@${t}`,i=encodeURIComponent(s);if(e.dryRun)return z("email_webhook",{address:s,webhook_url:e.url||null},e.json,e.fields);let n=j(!e.json);if(e.url){n.start(`Setting webhook for ${s}`);let r=await S(`/api/emails/${i}/webhook`,{method:"PUT",body:JSON.stringify({url:e.url})}),o=await r.json();if(r.ok||(n.stop("Failed"),h(o.error||o.message,{hint:o.hint,status:r.status,json:e.json,fields:e.fields})),n.stop(`${b.success} Webhook set`),e.json){k(o,e.fields);return}R(`Mailbox ${o.address}`),$("Webhook",w.url(o.webhook_url)),$("Signing secret",N.default.dim(o.signing_secret)),c()}else{n.start(`Removing webhook for ${s}`);let r=await S(`/api/emails/${i}/webhook`,{method:"DELETE"}),o=await r.json();if(r.ok||(n.stop("Failed"),h(o.error||o.message,{hint:o.hint,status:r.status,json:e.json,fields:e.fields})),n.stop(`${b.success} Webhook removed`),e.json){k(o,e.fields);return}R(`Mailbox ${o.address}`),$("Webhook",N.default.dim("none")),c()}}async function jl(e){let t=await lt(e);if(e.slug||h("Slug required",{hint:"Usage: domani email forward hello@example.com --forward-to me@gmail.com",code:"validation_error",json:e.json,fields:e.fields}),e.dryRun)return z("email_forward",{address:`${e.slug}@${t}`,forward_to:e.forwardTo||null},e.json,e.fields);let s=j(!e.json),i=e.forwardTo||null;s.start(`Updating forward for ${e.slug}@${t}`);let n=encodeURIComponent(`${e.slug}@${t}`),r=await S(`/api/emails/${n}`,{method:"PATCH",body:JSON.stringify({forward_to:i})}),o=await r.json();if(r.ok||(s.stop("Failed"),h(o.error||o.message,{hint:o.hint,status:r.status,json:e.json,fields:e.fields})),s.stop(`${b.success} Forward ${i?"set":"removed"}`),e.json){k(o,e.fields);return}R(`Mailbox ${o.address}`),$("Forward to",o.forward_to?N.default.cyan(o.forward_to):N.default.dim("none")),c()}async function Sr(e,t,s){let i=j(!t);i.start(`Checking email health for ${w.domain(e)}`);let n=await S(`/api/domains/${encodeURIComponent(e)}/email/check`),r=await n.json();if(n.ok||(i.stop("Failed"),h(r.error||r.message,{hint:r.hint,status:n.status,json:t,fields:s})),i.stop("Email health checked"),t){k(r,s);return}if(R(`Email Health ${w.domain(r.domain)}`),r.provider?$("Provider",N.default.cyan(Ki(r.provider))):$("Provider",N.default.dim("unknown")),r.mx.configured?$("MX",`${b.success} ${N.default.green("propagated")} ${N.default.dim(`(${r.mx.records.length} record${r.mx.records.length!==1?"s":""})`)}`):$("MX",`${b.error} ${N.default.red("not configured")}`),r.spf.configured?$("SPF",`${b.success} ${N.default.green(r.spf.value)}`):$("SPF",`${b.error} ${N.default.red("missing")}`),r.dmarc.configured){let o=r.dmarc.value.length>50?r.dmarc.value.slice(0,50)+"...":r.dmarc.value;$("DMARC",`${b.success} ${N.default.green(o)}`)}else $("DMARC",`${b.error} ${N.default.red("missing")}`);r.dkim.configured?$("DKIM",`${b.success} ${N.default.green("found")} ${N.default.dim(`(${r.dkim.selectors.join(", ")})`)}`):$("DKIM",`${b.warning} ${N.default.yellow("not found")}`),c(),r.mx.configured?(!r.spf.configured||!r.dmarc.configured)&&(Vt("SPF and DMARC protect against email spoofing. Re-run email setup to add them."),c()):(O("Set up email:",`domani email ${e} google`),c())}async function Cr(e,t,s,i){return t?Rr(e,t,s,i):Or(e,s,i)}async function Or(e,t,s){let i=j(!t);i.start("Loading email providers");let n=await S(`/api/domains/${encodeURIComponent(e)}/connect`),r=await n.json();n.ok||(i.stop("Failed"),h(r.error||r.message,{hint:r.hint,status:n.status,json:t,fields:s})),i.stop("Providers loaded");let o=r.providers?.email||[];o.length===0&&h("No email providers available",{code:"not_found",json:t,fields:s});let a=await Ke({message:"Choose an email provider",options:o.map(l=>({value:l.name,label:Ki(l.name)}))});return oe(a)&&process.exit(0),Rr(e,a,t,s)}async function Rr(e,t,s,i){if(s){let d=await S(`/api/domains/${encodeURIComponent(e)}/connect`,{method:"POST",body:JSON.stringify({target:t})}),u=await d.json();d.ok||h(u.error||u.message,{hint:u.hint,status:d.status,json:s,fields:i}),k(u,i);return}let n=await S(`/api/domains/${encodeURIComponent(e)}/connect?provider=${encodeURIComponent(t)}`);if(!n.ok){let d=await n.json();h(d.error||d.message,{hint:d.hint,status:n.status,json:s,fields:i})}let r=await n.json(),o=r.preview?.records??[],a=r.preview?.provider??t,l=Ki(a);if(R(`Email ${w.domain(e)}`),$("Provider",N.default.cyan(l)),o.length){c(),console.log(` ${N.default.bold("DNS Records")}`);let d=[8,24,40],u=Rt(["Type","Name","Value"],o.map(_=>({cells:hl(_),status:"pending"})),d);u.start();let p=await S(`/api/domains/${encodeURIComponent(e)}/connect`,{method:"POST",body:JSON.stringify({target:t})}),g=await p.json();p.ok||(u.stop(),c(),h(g.error||g.message,{hint:g.hint,status:p.status,json:s,fields:i}));let x=g.records||[];for(let _=0;_<o.length;_++)x.find(A=>A.record.type===o[_].type&&A.record.name===o[_].name&&A.record.value===o[_].value)?.status==="already_set"||await Ot(60),u.markDone(_);await Ot(80),u.stop();let y=x.filter(_=>_.status==="created"||_.status==="updated").length,f=x.filter(_=>_.status==="already_set").length,v;f===x.length?v=`All ${f} records already set`:f>0?v=`${y} created, ${f} already set`:v=`${y} DNS records set`,c(),console.log(` ${b.success} ${N.default.green(`Email configured - ${v}`)}`)}else{let d=j(!0);d.start("Setting DNS records");let u=await S(`/api/domains/${encodeURIComponent(e)}/connect`,{method:"POST",body:JSON.stringify({target:t})}),p=await u.json();u.ok||(d.stop("Failed"),h(p.error||p.message,{hint:p.hint,status:u.status,json:s,fields:i})),d.stop(`${b.success} Email configured via ${N.default.cyan(l)}`)}c(),O("Verify propagation:",`domani email ${e} --check`),c()}var N,fl,pl,zi=De(()=>{"use strict";Q();Jt();N=U(J(),1);Te();H();be();Je();fl=["setup","status","remove","list","create","delete","send","inbox","webhook","forward","check","connect"],pl={"google-workspace":"Google Workspace",fastmail:"Fastmail",proton:"Proton Mail"}});var Er={};It(Er,{dns:()=>Zi});async function Zi(e,t,s,i,n,r){e||(e=await ue()),ee(e,r);let o=r?.json??!1,a=r?.type||s,l=r?.name||i,d=r?.value||n;if(!t||t==="get"){let u=j(!o);u.start(`Loading DNS for ${w.domain(e)}`);let p=await S(`/api/domains/${encodeURIComponent(e)}/dns`),g=await p.json();if(p.ok||(u.stop("Failed"),h(g.error||g.message,{hint:g.hint,status:p.status,json:o,fields:r?.fields})),u.stop(`${g.records.length} record(s)`),o){k(g,r?.fields);return}if(g.records.length===0){c(),console.log(` ${je.default.dim(`No DNS records for ${e}`)}`),c(),O("Auto-configure DNS:",`domani connect ${e}`),c();return}let x=[8,24,40,8];R(`DNS ${w.domain(e)}`,x.reduce((f,v)=>f+v,0)+x.length-1);let y=g.records.map(f=>{let v=f.priority?je.default.dim(` pri=${f.priority}`):"";return[je.default.yellow(f.type),f.name,je.default.cyan(f.value)+v,je.default.dim(String(f.ttl))]});me(["Type","Name","Value","TTL"],y,x),c();return}if(t==="set"){if((!a||!l||!d)&&h("Missing arguments for dns set",{hint:"Usage: domani dns <domain> set --type A --name www --value 1.2.3.4",code:"validation_error",json:o,fields:r?.fields}),r?.dryRun)return z("dns_set",{domain:e,record:{type:a.toUpperCase(),name:l,value:d,ttl:3600}},o,r?.fields);let u=j(!o);u.start(`Setting ${je.default.yellow(a.toUpperCase())} record`);let p=await S(`/api/domains/${encodeURIComponent(e)}/dns`),g=await p.json(),y=(p.ok?g.records:[]).filter(_=>!(_.type===a.toUpperCase()&&_.name===l));y.push({type:a.toUpperCase(),name:l,value:d,ttl:3600});let f=await S(`/api/domains/${encodeURIComponent(e)}/dns`,{method:"PUT",body:JSON.stringify({records:y})}),v=await f.json();f.ok||(u.stop("Failed"),h(v.error||v.message,{hint:v.hint,status:f.status,json:o,fields:r?.fields})),u.stop(`${b.success} ${je.default.yellow(a.toUpperCase())} ${l} ${b.arrow} ${je.default.cyan(d)}`),o?k(v,r?.fields):(c(),O("Check propagation:",`domani status ${e}`),c());return}if(t==="delete"){if((!a||!l)&&h("Missing arguments for dns delete",{hint:"Usage: domani dns <domain> delete --type A --name www",code:"validation_error",json:o,fields:r?.fields}),r?.dryRun)return z("dns_delete",{domain:e,record:{type:a.toUpperCase(),name:l}},o,r?.fields);let u=j(!o);u.start(`Deleting ${je.default.yellow(a.toUpperCase())} ${l}`);let p=await S(`/api/domains/${encodeURIComponent(e)}/dns?type=${encodeURIComponent(a.toUpperCase())}&name=${encodeURIComponent(l)}`,{method:"DELETE"}),g=await p.json();p.ok||(u.stop("Failed"),h(g.error||g.message,{hint:g.hint,status:p.status,json:o,fields:r?.fields})),u.stop(`${b.success} Deleted ${je.default.yellow(a.toUpperCase())} ${l}`),o?k(g,r?.fields):(c(),O("Check propagation:",`domani status ${e}`),c());return}if(t==="snapshot"){if(r?.dryRun)return z("dns_snapshot",{domain:e},o,r?.fields);let u=j(!o);u.start(`Capturing DNS snapshot for ${w.domain(e)}`);let p=await S(`/api/domains/${encodeURIComponent(e)}/dns/snapshot`,{method:"POST"}),g=await p.json();p.ok||(u.stop("Failed"),h(g.error||g.message,{hint:g.hint,status:p.status,json:o,fields:r?.fields}));let x=g.records?.length??0;if(u.stop(`${b.success} Captured ${x} record(s)`),o){k(g,r?.fields);return}let y=`${e}.dns.json`,f=(0,Xi.resolve)(process.cwd(),y);(0,Ts.writeFileSync)(f,JSON.stringify(g,null,2)+`
178
+ `),R("DNS Snapshot"),$("Domain",w.domain(g.domain)),$("Records",String(x)),$("Subdomains",String(g.subdomains?.length??0)),$("Sources",(g.sources||[]).join(", ")||"none"),$("Captured",g.capturedAt||g.captured_at||"now"),$("Saved to",je.default.cyan(y)),c(),O("Restore from this snapshot:",`domani dns ${e} restore --file ${y}`),c();return}if(t==="restore"){if(r?.dryRun)return z("dns_restore",{domain:e,source:r?.file||"server_backup"},o,r?.fields);let u=j(!o),p;if(r?.file){let y=(0,Xi.resolve)(process.cwd(),r.file);y.startsWith(process.cwd())||h("File path must be within the current directory",{hint:`Got: ${r.file}`,code:"validation_error",json:o,fields:r?.fields});try{let f=(0,Ts.readFileSync)(y,"utf-8"),v=JSON.parse(f);p=JSON.stringify({snapshot:v}),u.start(`Restoring DNS for ${w.domain(e)} from ${je.default.cyan(r.file)}`)}catch(f){h(`Failed to read snapshot file: ${f instanceof Error?f.message:"unknown"}`,{hint:`Make sure ${r.file} exists and contains valid JSON.`,code:"validation_error",json:o,fields:r?.fields})}}else u.start(`Restoring DNS for ${w.domain(e)} from server backup`);let g=await S(`/api/domains/${encodeURIComponent(e)}/dns/restore`,{method:"POST",...p?{body:p}:{}}),x=await g.json();if(g.ok||(u.stop("Failed"),h(x.error||x.message,{hint:x.hint,status:g.status,json:o,fields:r?.fields})),u.stop(`${b.success} Restored DNS`),o){k(x,r?.fields);return}if(R("DNS Restored"),$("Domain",w.domain(x.domain)),$("Applied",je.default.green(String(x.applied??0))),$("Skipped",je.default.dim(String(x.skipped??0))),x.errors?.length>0){$("Errors",je.default.red(String(x.errors.length)));for(let y of x.errors)console.log(` ${je.default.red("\u2022")} ${y}`)}c(),O("Verify DNS records:",`domani dns ${e}`),c();return}h(`Unknown action: ${t}`,{hint:"Use 'get', 'set', 'delete', 'snapshot', or 'restore'.",code:"validation_error",json:o,fields:r?.fields})}var je,Ts,Xi,Qi=De(()=>{"use strict";Q();je=U(J(),1);H();be();Je();Ts=require("node:fs"),Xi=require("node:path")});var Ir={};It(Ir,{status:()=>en});function Sl(e){return[Xe.default.yellow(e.type),e.name,Xe.default.cyan(e.value)+(e.priority?Xe.default.dim(` pri=${e.priority}`):"")]}function Cl(e){if(R(`Status ${w.domain(e.domain)}`),e.expires){let t=new Date(e.expires).toLocaleDateString(),s=e.days_until_expiry,i=s!=null&&s<30?Xe.default.red:s!=null&&s<90?Xe.default.yellow:Xe.default.green;$("Expires",`${t} ${Xe.default.dim("(")}${i(`${s} days`)}${Xe.default.dim(")")}`)}}async function en(e,t){if(e||(e=await ue()),ee(e,t),t.json){let p=await S(`/api/domains/${encodeURIComponent(e)}/status`),g=await p.json();p.ok||h(g.error||g.message,{hint:g.hint,status:p.status,json:t.json,fields:t.fields}),k(g,t.fields);return}let s=j(!0);s.start(`Checking ${w.domain(e)}`);let i;try{i=await S(`/api/domains/${encodeURIComponent(e)}/status`,{headers:{Accept:"text/event-stream"},signal:AbortSignal.timeout(t.timeout?parseInt(t.timeout,10)*1e3:3e4)})}catch{s.stop("Failed"),h("Request timed out",{hint:"The status check took too long. Try again.",code:"timeout",json:t.json,fields:t.fields})}if(!i.ok){s.stop("Failed");try{let p=await i.json();h(p.error||p.message,{hint:p.hint,status:i.status,json:t.json,fields:t.fields})}catch{h(`Server error (${i.status})`,{status:i.status,json:t.json,fields:t.fields})}}let n=i.body;n||(s.stop("Failed"),h("Empty response"));let r=new TextDecoder,o="",a=null,l=[],d=!1,u="";try{for await(let p of n){o+=r.decode(p,{stream:!0});let g=o.split(`
179
+ `);o=g.pop()??"";for(let x of g)if(x.startsWith("event: "))u=x.slice(7);else if(x.startsWith("data: ")){let y=JSON.parse(x.slice(6));if(u==="info"&&(s.stop("Status retrieved"),d=!0,Cl(y)),u==="records")if(l=y,l.length>0){c(),console.log(` ${Xe.default.bold("DNS Records")}`);let f=[8,10,34];a=Rt(["Type","Name","Value"],l.map(v=>({cells:Sl(v),status:"pending"})),f),a.start()}else c(),$("DNS",Xe.default.dim("no records")),O("Auto-configure DNS:",`domani connect ${e}`);if(u==="propagation"&&a){let{index:f,propagated:v}=y,_=v?b.success:`${b.warning}`;a.markDone(f,_)}u==="done"&&a&&a.stop(),u==="error"&&(d||s.stop("Failed"),a&&a.stop(),h(y.message||"Status check failed"))}}}catch{d||s.stop("Failed"),a&&a.stop(),h("Connection lost",{hint:"The status check was interrupted. Try again.",code:"connection_lost",json:t.json,fields:t.fields})}d||s.stop("Done"),c()}var Xe,tn=De(()=>{"use strict";Q();Xe=U(J(),1);H();be();Je()});var es={};It(es,{buy:()=>nn});async function sn(e){let t=await Ke({message:`What's next for ${Pe.default.cyan(e)}?`,options:[{value:"connect",label:"Connect to a service",hint:"domani connect"},{value:"email",label:"Set up email",hint:"domani email setup"},{value:"dns",label:"Configure DNS",hint:"domani dns"},{value:"status",label:"Check status & DNS propagation",hint:"domani status"},{value:"done",label:"Done"}]});if(oe(t)||t==="done"){c();return}if(c(),t==="connect"){let{connect:s}=await Promise.resolve().then(()=>(Yi(),kr));await s(e,void 0,{})}else if(t==="email"){let s=await Ae({message:`Mailbox name for ${Pe.default.cyan(e)}`,placeholder:"e.g. hey, hello, contact"});if(oe(s)||!s){c();return}c();let{email:i}=await Promise.resolve().then(()=>(zi(),Ar));await i("create",void 0,{domain:e,slug:s})}else if(t==="dns"){let{dns:s}=await Promise.resolve().then(()=>(Qi(),Er));await s(e)}else if(t==="status"){let{status:s}=await Promise.resolve().then(()=>(tn(),Ir));await s(e,{})}}async function Ol(e,t){ee(e,t);let s;if(t.preChecked)s={available:!0,...t.preChecked};else{let u=j(!t.json);u.start(`Checking ${w.domain(e)}`);let p=await S(`/api/domains/search?q=${encodeURIComponent(e)}`);s=await p.json(),p.ok||(u.stop("Search failed"),h(s.error,{hint:s.hint,status:p.status,json:t.json,fields:t.fields})),s.available||(u.stop(`${b.error} ${w.domain(e)} is not available`),h(`${e} is not available`,{code:"not_available",json:t.json,fields:t.fields})),u.stop(`${b.success} ${w.domain(e)} ${b.dot} available ${b.dot} ${w.price(s.price)}/yr`)}if(t.dryRun)return z("buy",{domain:e,available:!0,price:s.price,currency:s.currency||"USD"},t.json,t.fields);if(!Ct(t)){let u=await He({message:`Purchase ${Pe.default.bold(e)} for ${w.price(s.price)}/yr?`});if(!u||typeof u=="symbol"){console.log(` ${Pe.default.dim("Cancelled.")}`);return}}let i=j(!t.json);i.start("Purchasing");let n=await S("/api/domains/buy",{method:"POST",headers:{Accept:"text/event-stream"},body:JSON.stringify({domain:e})});if(!n.ok||!n.body){i.stop("Purchase failed");let u=await n.json().catch(()=>({}));h(u.error||u.message,{hint:u.hint,fixUrl:u.setup_url||u.payment_options?.card?.setup_url,status:n.status,json:t.json,fields:t.fields})}let r={},o=new TextDecoder,a="",l="";for await(let u of n.body){a+=o.decode(u,{stream:!0});let p=a.split(`
180
+ `);a=p.pop()??"";for(let g of p)if(g.startsWith("event: "))l=g.slice(7).trim();else if(g.startsWith("data: ")){let x=JSON.parse(g.slice(6));l==="checking"?i.message(`Checking ${w.domain(x.domain)}`):l==="payment"?i.message(`Charging ${w.price(x.total)}`):l==="registering"?i.message(`Registering ${w.domain(x.domain)}`):l==="registered"?r=x:l==="error"&&(i.stop("Purchase failed"),h(x.error,{hint:x.hint,fixUrl:x.setup_url,status:n.status,json:t.json,fields:t.fields}))}}let d=r.expires?Pe.default.dim(` \xB7 expires ${new Date(r.expires).toLocaleDateString()}`):"";if(i.stop(`${b.success} ${w.domain(r.domain)} is yours!${d}`),t.json){k(r,t.fields);return}ke?await sn(r.domain):(O("Connect to a service:",`domani connect ${r.domain}`),O("Set up email:",`domani email setup ${r.domain}`),O("Configure DNS:",`domani dns ${r.domain}`),c())}async function Rl(e,t){_r(e,t);let s=!!t.json,i=j(!s);i.start(`Checking ${e.length} domains`);let n=await Promise.all(e.map(async f=>{try{let v=await S(`/api/domains/search?q=${encodeURIComponent(f)}`),_=await v.json();return{domain:f,available:v.ok&&_.available,price:_.price}}catch{return{domain:f,available:!1,price:void 0}}})),r=n.filter(f=>f.available),o=n.filter(f=>!f.available);r.length===0&&(i.stop(`${b.error} None of the ${e.length} domains are available`),process.exit(1));let a=r.reduce((f,v)=>f+(v.price||0),0);if(i.stop(`${b.success} ${r.length}/${e.length} available ${b.dot} ${w.price(a.toFixed(2))} total`),o.length>0)for(let f of o)console.log(` ${b.error} ${w.domain(f.domain)} ${Pe.default.dim("not available")}`);if(t.dryRun)return z("buy_bulk",{domains:r.map(f=>({domain:f.domain,price:f.price})),unavailable:o.map(f=>f.domain),total_price:parseFloat(a.toFixed(2))},t.json,t.fields);if(!Ct(t)){let f=await He({message:`Purchase ${Pe.default.bold(String(r.length))} domain${r.length>1?"s":""} for ${w.price(a.toFixed(2))}?`});if(!f||typeof f=="symbol"){console.log(` ${Pe.default.dim("Cancelled.")}`);return}}c();let l=r.map(f=>({cells:[w.domain(f.domain),f.price?`${w.price(f.price.toFixed(2))}/yr`:""],status:"pending"})),d=Rt(["Domain","Price"],l,[30,12],!s);d.start();let p=await(await S("/api/domains/buy",{method:"POST",body:JSON.stringify({domains:r.map(f=>f.domain)})})).json(),g=new Set((p.results||[]).map(f=>f.domain));for(let f=0;f<r.length;f++){let v=r[f].domain.toLowerCase().trim();g.has(v)?d.markDone(f,b.success):d.markDone(f,b.error)}if(d.stop(),s){k(p,t.fields);return}c();let x=p.summary?.succeeded??0,y=p.summary?.failed??0;if(x>0&&console.log(` ${b.success} ${Pe.default.green(`${x} domain${x>1?"s":""} registered`)}`),y>0){console.log(` ${b.error} ${Pe.default.red(`${y} failed`)}`);for(let f of p.errors||[])console.log(` ${Pe.default.dim("\u2500")} ${w.domain(f.domain)}: ${Pe.default.dim(f.error)}${f.hint?` ${Pe.default.dim(`(${f.hint})`)}`:""}`)}if(c(),x>0&&ke){let f=(p.results||[]).filter(v=>v.success).map(v=>v.domain);if(f.length===1)await sn(f[0]);else{let v=await Ke({message:"Set up one of your new domains?",options:[...f.map(_=>({value:_,label:Pe.default.cyan(_)})),{value:"done",label:"Done"}]});!oe(v)&&v!=="done"?(c(),await sn(v)):c()}}else x>0&&(O("Connect to a service:","domani connect <domain>"),O("Set up email:","domani email setup <domain>"),c())}async function nn(e,t){let s=e.filter(Boolean);if(s.length===0){ke||h("Missing required argument: domain(s)",{hint:"Usage: domani buy <domain> [domain2 ...]",code:"missing_argument",json:t.json});let i=await Ae({message:"Domain to purchase",placeholder:"e.g. myapp.dev (space-separated for multiple)"});(oe(i)||!i)&&process.exit(0),s=i.split(/\s+/).filter(Boolean)}return s.length===1?Ol(s[0],t):Rl(s,t)}var Pe,Mt=De(()=>{"use strict";Q();Te();Pe=U(J(),1);H();be()});var vn=U(bn(),1),{program:$c,createCommand:yc,createArgument:bc,createOption:vc,CommanderError:wc,InvalidArgumentError:_c,InvalidOptionArgumentError:xc,Command:wn,Argument:kc,Option:jc,Help:Sc}=vn.default;var st=U(J(),1);ht();Hi();H();Jt();ht();var $t=U(J(),1);H();async function hr(e){let t=Ge(),s=j(!e.json),i=rt();if(i.token){s.start("Checking session");try{let d=await fetch(`${t}/api/me`,{headers:{Authorization:`Bearer ${i.token}`}});if(d.ok){let u=await d.json();s.stop(`Already logged in as ${$t.default.bold(u.email)}`),e.json&&k({status:"already_logged_in",email:u.email});return}}catch{}s.stop("Session expired, re-authenticating"),c()}s.start("Requesting auth code");let n=await fetch(`${t}/api/auth/cli`,{method:"POST",headers:{"Content-Type":"application/json"}});if(!n.ok){s.stop("Failed to initiate login");try{let d=await n.json();h(d.error||d.message||`Server error (${n.status})`,{hint:d.hint,code:"login_failed",json:e.json})}catch{h(`Could not reach ${t}. Check your connection and try again.`,{code:"network_error",json:e.json})}}let{code:r,auth_url:o,expires_in:a}=await n.json();if(s.stop("Auth code received"),e.json){k({status:"awaiting_approval",code:r,auth_url:o,expires_in:a});return}c(),console.log(` ${$t.default.dim("Verification code:")} ${$t.default.bold($t.default.cyan(r))}`),e.open!==!1?(console.log(` ${$t.default.dim("Opening browser")} ${b.arrow} ${w.url(o)}`),ze(o)):console.log(` ${$t.default.dim("Open this URL to approve:")} ${w.url(o)}`),c(),s.start("Waiting for approval");let l=120;for(let d=0;d<l;d++){await new Promise(g=>setTimeout(g,5e3));let u=await fetch(`${t}/api/auth/cli/poll?code=${r}`);!u.ok&&u.status!==202&&(s.stop("Login failed"),h(`Server error (${u.status})`,{code:"login_failed"}));let p=await u.json();if(p.status==="complete"){Pt({...rt(),token:p.token,email:p.email,api_url:t}),s.stop(`Logged in as ${$t.default.bold(p.email)}`),c(),O("Get started:","domani search"),c();return}p.error&&(s.stop("Login failed"),h(p.error||p.message,{hint:p.hint,code:"login_failed"}))}s.stop("Login timed out"),h("No approval received within 10 minutes",{hint:"Run 'domani login' to try again",code:"timeout"})}ht();var Ji=U(J(),1);H();async function gr(e){let t=rt();if(!t.token){e.json?k({status:"not_logged_in"}):console.log(` ${Ji.default.dim("Not logged in.")}`);return}let{api_url:s}=t;On(),s&&Pt({api_url:s}),e.json?k({status:"logged_out",email:t.email||null}):console.log(` ${b.success} Logged out${t.email?` ${Ji.default.dim(`(${t.email})`)}`:""}`)}Q();var Zt=U(J(),1);H();async function yr(e){let t=await S("/api/me"),s=await t.json();if(t.ok||h(s.error||s.message,{hint:s.hint,status:t.status,json:e.json,fields:e.fields}),e.json){k(s,e.fields);return}R("Account"),$("Email",Zt.default.bold(s.email)),$("Payment",s.has_payment_method?`${b.success} ${Zt.default.green("active")}`:`${b.error} ${Zt.default.dim("none")}`),$("Domains",String(s.domain_count)),$("API tokens",String(s.token_count)),$("Referral code",s.referral_code||Zt.default.dim("-")),$("Created",new Date(s.created_at).toLocaleDateString()),c()}Q();Te();var T=U(J(),1);H();be();var Ue=10,Ps=["com","io","ai","dev","app","co","net","org","xyz","sh","me","cc","tech","run","cloud","so","gg","fm","tv","pro","one","inc","ltd","llc","biz","group","global","ventures","capital","fund","agency","store","shop","market","sale","deals","auction","trade","studio","design","art","space","style","fashion","luxury","brand","media","digital","site","online","live","show","world","zone","land","place","city","town","blog","news","social","chat","link","page","fun","lol","meme","wtf","tools","build","works","work","team","solutions","services","systems","network","software","music","video","photo","photos","game","games","club","stream","film","movie","pizza","coffee","beer","bar","pub","restaurant","cafe","kitchen","food","wine","health","care","clinic","dental","fitness","yoga","bio","life","lifestyle","finance","money","legal","law","cash","academy","university","education","training","courses","science","wiki","guide","us","uk","eu","ca","au","de","fr","it","es","nl","jp","sg","nz","mx","house","homes","realty","estate","garden","nyc","london","berlin","paris","guru","ninja","rocks","fail","party","vip","gold","black","pink","red","events","travel","sport","jobs","careers","consulting","energy","eco","green","support","help","info","new","now","today","day"],Ds=null;async function Tr(){if(Ds)return Ds;try{let e=await $e("/api/tlds?sort=price&order=asc&limit=1000");if(e.ok){let s=(await e.json()).tlds.map(i=>i.tld);if(s.length>0){let i=new Set(Ps),n=new Set(s),r=[...Ps.filter(o=>n.has(o)),...s.filter(o=>!i.has(o))];return Ds=r,r}}}catch{}return Ds=Ps,Ps}async function Al(e,t,s,i,n){let r=[],o=[],a=Ue,l=0,d=!0,u=0,p=0,g=0,x=0,y=!1,f=!1,v=null,_="",C=["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"],A=0,F=setInterval(()=>{f||!d||(A=(A+1)%C.length,Y())},80);function L(){u>0&&(process.stdout.write(`\x1B[${u}A\x1B[0J`),u=0)}function G(){if(d)return[];let q=Ue+x*Ue;return r.length>a||i&&q<n.length?["more","new","skip"]:["new","skip"]}function I(){return r.slice(0,a)}function P(){let q=G();return Math.max(0,I().length+q.length-1)}let D=6;function Y(){L();let q=[],K=I(),de=!d&&K.length===0&&o.length>0,fe=de?o.slice(0,D):K,Oe=fe.reduce((ge,ae)=>Math.max(ge,ae.domain.length),0),qe=G();for(let ge=0;ge<fe.length;ge++){let ae=fe[ge];if(de)q.push(`${T.default.dim("\u2502")} ${T.default.dim("\u2715")} ${T.default.dim(ae.domain.padEnd(Oe))} ${T.default.dim("taken")}`);else{let W=ge===l,Be=W?T.default.green("\u25CF"):T.default.dim("\u25CB"),mt=ae.domain.padEnd(Oe),Vs=W?T.default.bold(T.default.cyan(mt)):mt,Ms=ae.for_sale?T.default.cyan(`$${ae.for_sale.price} (for sale)`):T.default.dim(`$${ae.price}/yr`);q.push(`${T.default.dim("\u2502")} ${Be} ${Vs} ${Ms}`)}}if(de&&o.length>D&&q.push(`${T.default.dim("\u2502")} ${T.default.dim(`\u2026 and ${o.length-D} more taken`)}`),d){let ge=_?T.default.dim(`checking ${_}\u2026`):T.default.dim("searching\u2026");q.push(`${T.default.dim("\u2502")} ${T.default.cyan(C[A])} ${ge}`)}else{let ge=Ue+x*Ue;i&&ge>=n.length&&q.push(`${T.default.dim("\u2502")} ${T.default.dim(`All ${Math.min(ge,n.length)} TLDs searched`)}`);for(let W=0;W<qe.length;W++){let Vs=I().length+W===l?T.default.green("\u25CF"):T.default.dim("\u25CB"),Ms=qe[W]==="more"?T.default.dim("More \u2192"):qe[W]==="new"?T.default.dim("New search \u2192"):T.default.dim("Skip");q.push(`${T.default.dim("\u2502")} ${Vs} ${Ms}`)}q.push(T.default.dim("\u2514"))}process.stdout.write(q.join(`
181
181
  `)+`
182
182
  `),u=q.length}process.stdout.write(`${T.default.cyan("\u25C6")} Register a domain?
183
- `),process.stdout.write("\x1B[?25l"),process.stdin.setRawMode(!0),process.stdin.resume();let Z=q=>{let K=q.toString();if(K==="\x1B[A")l=Math.max(0,l-1),Y();else if(K==="\x1B[B")l=Math.min(D(),l+1),Y();else if(K==="\r"){let de=I();if(c&&de.length===0)return;if(l<de.length)v=de[l]?.domain??null,m=!0;else{let Ce=G()[l-de.length];Ce==="more"?(a+=Le,r.length<a?y=!0:(l=Math.min(l,D()),Y())):(Ce==="new"&&(v="__new__"),m=!0)}}else(K===""||K==="\x1B")&&(m=!0)};process.stdin.on("data",Z),Y();async function U(q){let K=new TextDecoder,de="",fe="";for await(let Ce of q){if(m)break;de+=K.decode(Ce,{stream:!0});let Me=de.split(`
184
- `);de=Me.pop()??"";for(let ge of Me)if(ge.startsWith("event: "))fe=ge.slice(7);else if(ge.startsWith("data: ")){let ae=JSON.parse(ge.slice(6));if(fe==="result"&&(x=ae.domain),fe==="result"&&(ae.available||ae.for_sale||i)){if(_===0){let W=r.findIndex(Je=>Je.price>ae.price);W===-1?r.push(ae):(r.splice(W,0,ae),W<=l&&l++)}else r.push(ae);Y()}else if(fe==="result"&&!ae.available&&!ae.error)o.length<8&&o.push(ae);else if(fe==="done"){p+=ae.total,g+=ae.available,c=!1,l=Math.min(l,D());let W=Le+_*Le;r.length<a&&s&&W<n.length&&(y=!0),y||Y()}}}c=!1}for(await U(e);!m;)if(await new Promise(q=>{let K=setInterval(()=>{(m||y)&&(clearInterval(K),q())},16)}),y&&!m){y=!1;let q=Le+_*Le,K=n.slice(q,q+Le);_++,c=!0,l=Math.min(l,Math.max(0,r.length-1)),Y();let de=new URLSearchParams;de.set("domains",K.map(fe=>`${t}.${fe}`).join(","));try{let fe=await $e(`/api/domains/search?${de}`,{headers:{Accept:"text/event-stream"}});fe.ok&&fe.body?await U(fe.body):(c=!1,Y())}catch{c=!1,Y()}}clearInterval(V),process.stdin.removeListener("data",Z),process.stdin.isTTY&&process.stdin.setRawMode(!1),process.stdin.pause(),process.stdout.write("\x1B[?25h"),L();let te=v==="__new__",X=te?null:v,le=X?r.find(q=>q.domain===X)??null:null;return X?process.stdout.write(`${T.default.dim("\u25C7")} Register a domain?
183
+ `),process.stdout.write("\x1B[?25l"),process.stdin.setRawMode(!0),process.stdin.resume();let Z=q=>{let K=q.toString();if(K==="\x1B[A")l=Math.max(0,l-1),Y();else if(K==="\x1B[B")l=Math.min(P(),l+1),Y();else if(K==="\r"){let de=I();if(d&&de.length===0)return;if(l<de.length)v=de[l]?.domain??null,f=!0;else{let Oe=G()[l-de.length];Oe==="more"?(a+=Ue,r.length<a?y=!0:(l=Math.min(l,P()),Y())):(Oe==="new"&&(v="__new__"),f=!0)}}else(K===""||K==="\x1B")&&(f=!0)};process.stdin.on("data",Z),Y();async function V(q){let K=new TextDecoder,de="",fe="";for await(let Oe of q){if(f)break;de+=K.decode(Oe,{stream:!0});let qe=de.split(`
184
+ `);de=qe.pop()??"";for(let ge of qe)if(ge.startsWith("event: "))fe=ge.slice(7);else if(ge.startsWith("data: ")){let ae=JSON.parse(ge.slice(6));if(fe==="result"&&(_=ae.domain),fe==="result"&&(ae.available||ae.for_sale||s)){if(x===0){let W=r.findIndex(Be=>Be.price>ae.price);W===-1?r.push(ae):(r.splice(W,0,ae),W<=l&&l++)}else r.push(ae);Y()}else if(fe==="result"&&!ae.available&&!ae.error)o.length<8&&o.push(ae);else if(fe==="done"){p+=ae.total,g+=ae.available,d=!1,l=Math.min(l,P());let W=Ue+x*Ue;r.length<a&&i&&W<n.length&&(y=!0),y||Y()}}}d=!1}for(await V(e);!f;)if(await new Promise(q=>{let K=setInterval(()=>{(f||y)&&(clearInterval(K),q())},16)}),y&&!f){y=!1;let q=Ue+x*Ue,K=n.slice(q,q+Ue);x++,d=!0,l=Math.min(l,Math.max(0,r.length-1)),Y();let de=new URLSearchParams;de.set("domains",K.map(fe=>`${t}.${fe}`).join(","));try{let fe=await $e(`/api/domains/search?${de}`,{headers:{Accept:"text/event-stream"}});fe.ok&&fe.body?await V(fe.body):(d=!1,Y())}catch{d=!1,Y()}}clearInterval(F),process.stdin.removeListener("data",Z),process.stdin.isTTY&&process.stdin.setRawMode(!1),process.stdin.pause(),process.stdout.write("\x1B[?25h"),L();let te=v==="__new__",X=te?null:v,le=X?r.find(q=>q.domain===X)??null:null;return X?process.stdout.write(`${T.default.dim("\u25C7")} Register a domain?
185
185
  ${T.default.dim("\u2502")} ${T.default.bold(T.default.cyan(X))}
186
186
  ${T.default.dim("\u2514")}
187
187
  `):process.stdout.write(`${T.default.dim("\u2514")}
188
- `),{chosen:X,chosenResult:le,searchAgain:te,allTaken:r.length===0&&o.length>0,expanded:_>0}}async function Ir(e,t,i){if(!e){xe||h("Missing required argument: domain",{hint:"Usage: domani search <domain> [tlds...]",code:"missing_argument",json:i.json});let N=await Ae({message:"Search for a domain",placeholder:"e.g. myapp or myapp.dev"});(oe(N)||!N)&&process.exit(0),e=N}let s=t.map(N=>N.replace(/^\./,"")),n=i.tlds?.split(",").map(N=>N.trim())||[],r=[...new Set([...s,...n])];if(r.length>0&&Ii(r,i),ee(e,i),e.includes(".")&&r.length===0){let N=j(!i.json);N.start(`Checking ${w.domain(e)}`);let[Y,Z]=await Promise.all([$e(`/api/domains/search?q=${encodeURIComponent(e)}`),$e(`/api/domains/${encodeURIComponent(e)}/og`).catch(()=>null)]),U=await Y.json();if(Y.ok||(N.stop("Search failed"),h(U.error||U.message,{hint:U.hint,status:Y.status,json:i.json,fields:i.fields})),i.json){let te=U.domain.split(".")[0];k({name:te,results:[U],total:1,available:U.available?1:0},i.fields);return}if(U.available)if(N.stop(`${b.success} ${w.domain(U.domain)} ${b.dot} available ${b.dot} ${w.price(U.price)}/yr`),xe&&!i.json){let{buy:te}=await Promise.resolve().then(()=>(Mt(),Qt));await te([U.domain],{preChecked:{price:U.price,currency:U.currency}})}else d(),A("Register it:",`domani buy ${U.domain}`),d();else if(U.for_sale?.buyable)if(N.stop(`${b.info} ${w.domain(U.domain)} ${b.dot} ${T.default.cyan("for sale")} ${b.dot} ${w.price(U.for_sale.price)}`),xe&&!i.json){let{buy:te}=await Promise.resolve().then(()=>(Mt(),Qt));await te([U.domain],{preChecked:{price:U.for_sale.price,currency:U.for_sale.currency,marketplace:!0}})}else d(),A("Buy it:",`domani buy ${U.domain}`),d();else if(U.error)N.stop(`${T.default.dim("?")} ${w.domain(U.domain)} ${b.dot} ${T.default.dim("lookup failed")}`);else{let te;try{if(Z?.ok){let le=await Z.json();le?.title&&(te=le.title)}}catch{}let X=te?` ${b.dot} ${T.default.dim(`"${te}"`)}`:"";N.stop(`${b.error} ${w.domain(U.domain)} ${b.dot} ${T.default.red("taken")}${X}`)}return}let o=e.split(".")[0];if(xe&&!i.json&&r.length>0){let N=new URLSearchParams;N.set("domains",r.map(W=>`${o}.${W}`).join(",")),i.maxPrice&&N.set("max_price",i.maxPrice);let Y=await $e(`/api/domains/search?${N}`,{headers:{Accept:"text/event-stream"}});if(!Y.ok||!Y.body){h("Search failed",{json:i.json});return}let Z=[],U=new TextDecoder,te="",X="",le=j(!0);le.start(`Checking ${r.length} TLD${r.length>1?"s":""}`);for await(let W of Y.body){te+=U.decode(W,{stream:!0});let Je=te.split(`
189
- `);te=Je.pop()??"";for(let mt of Je)mt.startsWith("event: ")?X=mt.slice(7):mt.startsWith("data: ")&&X==="result"&&Z.push(JSON.parse(mt.slice(6)))}le.stop("");let q=Math.max(...r.map(W=>`${o}.${W}`.length))+2,K=Z.filter(W=>W.available),de=Z.filter(W=>!W.available&&!W.error),fe=Z.filter(W=>!W.available&&W.for_sale);for(let W of[...K,...fe,...de.filter(Je=>!Je.for_sale)])W.available?console.log(` ${T.default.green("\u2713")} ${T.default.bold(T.default.white(W.domain.padEnd(q)))} ${T.default.green(w.price(W.price)+"/yr")}`):W.for_sale?console.log(` ${T.default.cyan("$")} ${T.default.bold(T.default.white(W.domain.padEnd(q)))} ${T.default.cyan(w.price(W.for_sale.price))} ${T.default.dim("(for sale)")}`):console.log(` ${T.default.dim("\u2717")} ${T.default.dim(W.domain.padEnd(q))} ${T.default.dim("taken")}`);if(K.length===0){console.log(` ${T.default.dim("No domains available")}`),d();return}let{buy:Ce}=await Promise.resolve().then(()=>(Mt(),Qt));if(K.length===1){await Ce([K[0].domain],{preChecked:{price:K[0].price,currency:K[0].currency}});return}let{select:Me,isCancel:ge}=await Promise.resolve().then(()=>(Ie(),Ls)),ae=await Me({message:"Register one?",options:[...K.map(W=>({value:W.domain,label:w.domain(W.domain),hint:w.price(W.price)+"/yr"})),{value:"__skip__",label:"Skip"}]});if(!ge(ae)&&ae!=="__skip__"){d();let W=K.find(Je=>Je.domain===ae);await Ce([ae],{preChecked:W?{price:W.price,currency:W.currency}:void 0})}else d();return}if(xe&&!i.json){let N=await Er();for(;;){let Y=i.expand?N:N.slice(0,Le),Z=new URLSearchParams;Z.set("domains",Y.map(Me=>`${o}.${Me}`).join(",")),i.maxPrice&&Z.set("max_price",i.maxPrice);let U=j(!0);U.start(`Searching available domains for ${T.default.bold(o)}`);let te=await $e(`/api/domains/search?${Z}`,{headers:{Accept:"text/event-stream"}});if(!te.ok||!te.body){U.stop("Search failed");break}U.stop("");let X=!i.expand,{chosen:le,chosenResult:q,searchAgain:K}=await Ol(te.body,o,i.all??!1,X,N);if(le){d();let{buy:Me}=await Promise.resolve().then(()=>(Mt(),Qt)),ge=q?{price:q.price,currency:q.currency}:void 0;await Me([le],{preChecked:ge});return}if(!K)break;let{text:de,isCancel:fe}=await Promise.resolve().then(()=>(Ie(),Ls)),Ce=await de({message:"Search for a domain",placeholder:"e.g. myapp or myapp.dev"});if(fe(Ce)||!Ce)break;o=Ce.split(".")[0]}d();return}let a=o,l=await Er(),u=(r.length>0?r:i.expand?l:l.slice(0,Le)).map(N=>`${a}.${N}`),p=new URLSearchParams;p.set("domains",u.join(",")),i.maxPrice&&p.set("max_price",i.maxPrice);let g=j(!i.json);g.start(`Searching available domains for ${T.default.bold(a)}`);let _=await $e(`/api/domains/search?${p}`,{headers:{Accept:"text/event-stream"}});if(!_.ok){g.stop("Search failed");try{let N=await _.json();h(N.error||N.message||`Server error (${_.status})`,{hint:N.hint,status:_.status,json:i.json,fields:i.fields})}catch{h(`Server error (${_.status})`,{status:_.status,json:i.json,fields:i.fields})}}let y=_.body;y||(g.stop("Search failed"),h("Empty response",{code:"error",json:i.json,fields:i.fields}));let m=[],v=!1,x=0,C=i.all??!1;function E(){v||(v=!0,g.stop(`Checking TLDs for ${T.default.bold(a)}`),d())}function V(N){E(),N.available?console.log(` ${b.success} ${w.domain(N.domain).padEnd(37)} ${w.price(N.price)}${T.default.dim("/yr")}`):N.for_sale?console.log(` ${b.info} ${w.domain(N.domain).padEnd(37)} ${T.default.cyan(w.price(N.for_sale.price))} ${T.default.dim("(for sale)")}`):N.error||console.log(` ${b.error} ${T.default.dim(N.domain.padEnd(38))} ${T.default.red("taken")}`)}function L(){v||g.message(`Checking TLDs for ${T.default.bold(a)} ${T.default.dim(`(${x} checked)`)}`)}let G=new TextDecoder,I="",D="";for await(let N of y){I+=G.decode(N,{stream:!0});let Y=I.split(`
190
- `);I=Y.pop()??"";for(let Z of Y)if(Z.startsWith("event: "))D=Z.slice(7);else if(Z.startsWith("data: ")){let U=JSON.parse(Z.slice(6));if(D==="result")x++,U.available||U.for_sale||C?(i.json||V(U),m.push(U)):i.json||L();else if(D==="done"){if(i.json){m.sort((q,K)=>q.price-K.price),k({name:a,results:m,total:U.total,available:U.available},i.fields);return}v&&console.log(` ${T.default.dim("\u2500".repeat(50))}`);let te=U.total-U.available,X=U.total>=5&&te/U.total>=.5,le=`Checked ${U.total} TLDs \xB7 ${U.available} available${X?" \xB7 popular name":""}`;console.log(` ${T.default.dim(le)}`),U.available===0&&!i.expand&&r.length===0&&(d(),A("Try more TLDs:",`domani search ${a} --expand`))}}}d()}Mt();Q();var ct=F(H(),1);J();async function Tr(e){let t=j(!e.json);t.start("Loading domains");let i=await S("/api/domains"),s=await i.json();if(i.ok||(t.stop("Failed"),h(s.error||s.message,{hint:s.hint,status:i.status,json:e.json,fields:e.fields})),t.stop(`${s.domains.length} domain(s)`),e.json){k({...s,count:s.domains.length},e.fields);return}if(s.domains.length===0){d(),console.log(` ${ct.default.dim("No domains yet.")} Use: ${ct.default.cyan("domani buy <domain>")}`),d();return}let n=[30,12,12,14];O(`Your Domains (${s.domains.length})`,n.reduce((o,a)=>o+a,0)+n.length-1);let r=s.domains.map(o=>{let a=new Date(o.expiresAt).toLocaleDateString(),l=o.status==="active"?ct.default.green:o.status==="pending"?ct.default.yellow:ct.default.red,c=o.autoRenew?ct.default.green("on"):ct.default.dim("off");return[w.domain(o.domain),l(o.status),c,ct.default.dim(a)]});ue(["Domain","Status","Auto-renew","Expires"],r,n),d()}zs();Q();var Ot=F(H(),1);J();async function Pr(e){let t=new URLSearchParams;e.maxPrice&&t.set("max_price",e.maxPrice),e.minPrice&&t.set("min_price",e.minPrice),e.sort&&t.set("sort",e.sort),e.search&&t.set("search",e.search),e.limit&&t.set("limit",e.limit),t.set("order","asc");let i=j(!e.json);i.start("Loading TLDs");let s=await $e(`/api/tlds?${t}`),n=await s.json();if(s.ok||(i.stop("Failed"),h(n.error||n.message,{hint:n.hint,status:s.status,json:e.json,fields:e.fields})),i.stop(`${n.total} TLDs loaded`),e.json){k(n,e.fields);return}let r=n.tlds;if(r.length===0){d(),console.log(` ${Ot.default.dim("No TLDs match your filters.")}`),d();return}O("TLD Pricing");let o=r.map(a=>[Ot.default.bold(`.${a.tld}`),w.price(a.registration.toFixed(2))+Ot.default.dim("/yr"),Ot.default.dim("renew ")+w.price(a.renewal.toFixed(2))+Ot.default.dim("/yr")]);ue(["TLD","Register","Renewal"],o,[22,16,20]),d(),console.log(` ${Ot.default.dim(`${n.total} TLDs total`)}`),d()}Q();var je=F(H(),1);J();ye();async function Dr(e,t){ee(e,t);let i=j(!t.json);i.start(`Looking up ${w.domain(e)}`);let[s,n]=await Promise.all([$e(`/api/domains/whois?q=${encodeURIComponent(e)}`),$e(`/api/domains/${encodeURIComponent(e)}/og`).catch(()=>null)]),r=await s.json(),o=null;try{n?.ok&&(o=await n.json())}catch{}if(s.ok||(i.stop("Lookup failed"),h(r.error||r.message,{hint:r.hint,status:s.status,json:t.json,fields:t.fields})),i.stop("WHOIS data retrieved"),t.json){k({...r,...o?{og:o}:{}},t.fields);return}if(O(`WHOIS ${w.domain(r.domain)}`),!r.registered){$("Status",`${b.success} ${je.default.green("not registered")}`),d(),A("Register it:",`domani buy ${r.domain}`),d();return}if($("Status",`${b.error} ${je.default.red("registered")}`),(o?.title||o?.description)&&(d(),console.log(` ${je.default.bold("Website preview")}`),console.log(` ${je.default.dim("\u2500".repeat(50))}`),o.title&&$("Title",o.title),o.description&&$("Description",je.default.dim(o.description.length>80?o.description.slice(0,80)+"\u2026":o.description)),d()),r.registrar&&$("Registrar",r.registrar),r.created&&$("Created",r.created),r.expires&&$("Expires",r.expires),r.days_until_expiry!=null){let l=r.days_until_expiry,c=l<30?je.default.red:l<90?je.default.yellow:je.default.green;$("Days left",c(String(l)))}r.updated&&$("Updated",r.updated),$("DNSSEC",r.dnssec?je.default.green("yes"):je.default.dim("no")),r.nameservers?.length>0&&$("Nameservers",r.nameservers.map(l=>je.default.cyan(l)).join(je.default.dim(", "))),r.status?.length>0&&$("Status codes",je.default.dim(r.status.join(", ")));let a=r.contacts?.registrant;a&&!r.redacted?(d(),console.log(` ${je.default.bold("Registrant")}`),console.log(` ${je.default.dim("\u2500".repeat(50))}`),a.name&&$("Name",a.name),a.organization&&$("Organization",a.organization),a.email&&$("Email",w.url(a.email)),a.country&&$("Country",a.country)):r.redacted&&$("Contact",je.default.dim("redacted (WHOIS privacy)")),d()}Q();Ie();var dt=F(H(),1);J();ye();async function Nr(e,t){if(!e){xe||h("Missing required argument: prompt",{hint:'Usage: domani suggest "describe your project"',code:"missing_argument",json:t.json});let m=await Ae({message:"Describe your project or idea",placeholder:"e.g. AI coding assistant, pet food delivery..."});(oe(m)||!m)&&process.exit(0),e=m}let i=new URLSearchParams({prompt:e});if(t.count&&i.set("count",t.count),t.tlds&&i.set("tlds",t.tlds),t.tlds&&Ii(t.tlds.split(",").map(m=>m.trim()),t),t.style&&i.set("style",t.style),t.lang&&i.set("lang",t.lang),t.json){let m=j(!1);m.start("Finding available domains");let v=t.timeout?parseInt(t.timeout,10)*1e3:6e4,x;try{x=await $e(`/api/domains/suggest?${i}`,{signal:AbortSignal.timeout(v)})}catch{m.stop("Failed"),h("Request timed out",{hint:"Suggest took too long. Try --timeout <seconds> to increase.",code:"timeout",json:t.json,fields:t.fields})}let C=await x.json();x.ok||(m.stop("Failed"),h(C.error||C.message,{hint:C.hint,status:x.status,json:t.json,fields:t.fields})),k(C,t.fields);return}let s=j(!0);s.start("Finding available domains");let n=t.timeout?parseInt(t.timeout,10)*1e3:6e4,r;try{r=await $e(`/api/domains/suggest?${i}`,{headers:{Accept:"text/event-stream"},signal:AbortSignal.timeout(n)})}catch{s.stop("Failed"),h("Request timed out",{hint:"Suggest took too long. Try --timeout <seconds> to increase.",code:"timeout"})}if(!r.ok){s.stop("Failed");try{let m=await r.json();h(m.error||m.message||`Server error (${r.status})`,{hint:m.hint,status:r.status})}catch{h(`Server error (${r.status})`,{status:r.status})}}let o=r.body;o||(s.stop("Failed"),h("Empty response"));let a=[],l=[],c=!1,u=0;function p(){c||(c=!0,s.stop("Finding available domains"),d())}let g=new TextDecoder,_="",y="";for await(let m of o){_+=g.decode(m,{stream:!0});let v=_.split(`
191
- `);_=v.pop()??"";for(let x of v)if(x.startsWith("event: "))y=x.slice(7);else if(x.startsWith("data: "))try{let C=JSON.parse(x.slice(6));if(y==="result")u++,C.available?a.push(C):l.push(C),c||s.message(`Finding available domains ${dt.default.dim(`(${u} checked, ${a.length} available)`)}`);else if(y==="iteration")c||s.message(`Finding available domains ${dt.default.dim(`(round ${C.n})`)}`);else if(y==="done"){p();for(let E of a){let V=E.reason?` ${dt.default.dim(E.reason)}`:"";console.log(` ${b.success} ${w.domain(E.domain).padEnd(37)} ${w.price(E.price)}${dt.default.dim("/yr")}${V}`)}for(let E of l)console.log(` ${b.error} ${dt.default.dim(E.domain.padEnd(38))} ${dt.default.red("taken")}`);console.log(` ${dt.default.dim("\u2500".repeat(50))}`),console.log(` ${dt.default.dim(`Found ${C.total} available \xB7 checked ${C.checked} \xB7 ${C.iterations} round${C.iterations>1?"s":""}`)}`)}else y==="error"&&(c||s.stop("Failed"),h(C.message))}catch{}}a.length===0&&l.length===0&&(c||s.stop("No results"),h("Could not find available domains for this prompt.")),d(),a.length>0&&(A("Register one:",`domani buy ${a[0].domain}`),d())}Js();Zs();Q();Ie();var qt=F(H(),1);J();ye();Ht();async function Fr(e,t){if(ee(e,t),!t.authCode){(t.json||!process.stdout.isTTY)&&h("--auth-code is required",{hint:"Get the EPP/auth code from your current registrar.",code:"validation_error",json:t.json,fields:t.fields});let a=await Ae({message:"Enter the EPP/auth code from your current registrar:",validate:l=>!l||l.trim().length===0?"Auth code is required":void 0});oe(a)&&process.exit(0),t.authCode=a}let i=j(!t.json);i.start(`Checking transfer eligibility for ${w.domain(e)}`);let s=await S(`/api/domains/transfer-check?domain=${encodeURIComponent(e)}`),n=await s.json();if(s.ok||(i.stop("Check failed"),h(n.error,{hint:n.hint,status:s.status,json:t.json,fields:t.fields})),n.eligible||(i.stop(`${b.error} Not eligible`),h(n.reason||"Domain is not eligible for transfer.",{hint:n.hint,code:"not_eligible",json:t.json,fields:t.fields})),i.stop(`${b.success} Eligible for transfer`),t.dryRun)return z("transfer",{domain:e,eligible:!0,price:n.price,currency:n.currency||"USD",includes_renewal:!0},t.json,t.fields);if(!Ct(t)){let a=n.price!=null?` for ${w.price(n.price.toFixed(2))}`:"",l=await We({message:`Transfer ${qt.default.bold(e)} to ${Et}${a}? (includes 1 year renewal)`});if(!l||typeof l=="symbol"){console.log(` ${qt.default.dim("Cancelled.")}`);return}}i.start(`Initiating transfer for ${w.domain(e)}`);let r=await S("/api/domains/transfer",{method:"POST",body:JSON.stringify({domain:e,auth_code:t.authCode})}),o=await r.json();if(r.ok||(i.stop("Transfer failed"),h(o.error||o.message,{hint:o.hint,fixUrl:o.setup_url||o.payment_options?.card?.setup_url,status:r.status,json:t.json,fields:t.fields})),i.stop(`${b.success} Transfer initiated`),t.json){k(o,t.fields);return}O("Transfer Initiated"),$("Domain",w.domain(o.domain)),$("Status",qt.default.yellow(o.status||"pending")),o.price&&$("Price",w.price(o.price)+qt.default.dim(` ${o.currency||"USD"}`)),o.payment_method&&$("Payment",o.payment_method),o.expires&&$("Expires",new Date(o.expires).toLocaleDateString()),o.hint&&(d(),console.log(` ${qt.default.dim(o.hint)}`)),d(),A("Check transfer progress:",`domani status ${o.domain}`),d()}Q();Ie();var Ni=F(H(),1);J();ye();He();async function Lr(e,t){e||(e=await me()),ee(e,t);let i=t.years?parseInt(t.years,10):1;if((isNaN(i)||i<1||i>10)&&h("--years must be between 1 and 10",{code:"validation_error",json:t.json,fields:t.fields}),t.dryRun)return z("renew",{domain:e,years:i},t.json,t.fields);if(!Ct(t)){let o=await We({message:`Renew ${Ni.default.bold(e)} for ${i} year${i>1?"s":""}? You will be charged.`});if(!o||typeof o=="symbol"){console.log(` ${Ni.default.dim("Cancelled.")}`);return}}let s=j(!t.json);s.start(`Renewing ${w.domain(e)}`);let n=await S(`/api/domains/${encodeURIComponent(e)}/renew`,{method:"POST",body:JSON.stringify({years:i})}),r=await n.json();if(n.ok||(s.stop("Renewal failed"),h(r.error||r.message,{hint:r.hint,fixUrl:r.setup_url||r.payment_options?.card?.setup_url,status:n.status,json:t.json,fields:t.fields})),s.stop(`${b.success} Domain renewed`),t.json){k(r,t.fields);return}O("Renewal Complete"),$("Domain",w.domain(r.domain)),$("Years",String(r.renewed_years)),$("New expiry",new Date(r.new_expiry).toLocaleDateString()),r.price&&$("Price",w.price(r.price)+Ni.default.dim(` ${r.currency||"USD"}`)),r.payment_method&&$("Payment",r.payment_method),d(),A("Verify renewal:",`domani status ${r.domain}`),d()}Q();var tt=F(H(),1);J();ye();async function Vr(e,t){e||h("Domain is required",{hint:`Usage: domani import <domain>
192
- domani import <domain> --verify`,code:"validation_error",json:t.json,fields:t.fields}),ee(e,t);let i=t.verify?"/api/domains/import/verify":"/api/domains/import",s=j(!t.json);s.start(t.verify?`Verifying ownership of ${w.domain(e)}`:`Initiating import for ${w.domain(e)}`);let n=await S(i,{method:"POST",body:JSON.stringify({domain:e})}),r=await n.json();if(n.ok||(s.stop(t.verify?"Verification failed":"Import failed"),h(r.error||r.message,{hint:r.hint,status:n.status,json:t.json,fields:t.fields})),t.json){s.stop(""),k(r,t.fields);return}t.verify?(s.stop(`${b.success} ${w.domain(e)} imported!`),O("Domain Imported"),$("Domain",w.domain(r.domain)),$("Status",tt.default.green(r.status||"active")),r.expires_at&&$("Expires",new Date(r.expires_at).toLocaleDateString()),r.registrar&&$("Registrar",r.registrar),d(),A("Check domain health:",`domani status ${r.domain}`),d()):(s.stop(`${b.success} Verification record ready`),O("Import Domain"),$("Domain",w.domain(r.domain)),$("Status",tt.default.yellow("pending verification")),d(),console.log(" Add this TXT record at your DNS provider:"),d(),console.log(` ${tt.default.dim("Type:")} ${tt.default.bold("TXT")}`),console.log(` ${tt.default.dim("Name:")} ${tt.default.bold(r.txt_record?.name||"@")}`),console.log(` ${tt.default.dim("Value:")} ${tt.default.bold(r.txt_record?.value||`domani-verify=${r.token}`)}`),d(),console.log(` ${tt.default.dim("DNS propagation may take a few minutes to 48 hours.")}`),d(),A("Once the record is set, verify:",`domani import ${e} --verify`),d())}Gs();pt();J();function Ur(e){let t=bt();t||(d(),h("Not logged in",{hint:"Run 'domani login' first",code:"auth_required",json:e.json})),e.json?k({token:t}):console.log(t)}Q();var Ve=F(H(),1);J();async function Mr(e,t){switch(e){case void 0:case"list":return Al(t.json,t.fields);case"create":return Rl(t);case"revoke":return El(t);default:h(`Unknown action: ${e}`,{hint:"Actions: list, create, revoke",code:"validation_error",json:t.json,fields:t.fields})}}async function Al(e,t){let i=j(!e);i.start("Loading tokens");let s=await S("/api/tokens"),n=await s.json();if(s.ok||(i.stop("Failed"),h(n.error||n.message,{hint:n.hint,status:s.status,json:e,fields:t})),i.stop(`${b.success} ${n.tokens.length} token(s)`),e){k(n,t);return}if(n.tokens.length===0){d(),console.log(` ${Ve.default.dim("No tokens.")}`),d(),A("Create one:",'domani tokens create --name "My App"'),d();return}d(),O("API Tokens");let r=n.tokens.map(o=>{let a;o.expired?a=Ve.default.red("Expired"):o.expiresAt?a=Ve.default.dim(`Expires ${new Date(o.expiresAt).toLocaleDateString()}`):a=Ve.default.dim("No expiration");let l=o.scopes.includes("*")?Ve.default.dim("all"):Ve.default.dim(o.scopes.join(", "));return[Ve.default.dim(o.id),Ve.default.bold(o.name),l,a]});ue(["ID","Name","Scopes","Expiration"],r,[28,16,32,20]),d()}async function Rl(e){let t={};if(e.name&&(t.name=e.name),e.scopes&&(t.scopes=e.scopes.split(",").map(r=>r.trim())),e.expiresIn){let r=Number(e.expiresIn);(isNaN(r)||r<3600||r>31536e3)&&h("Invalid --expires-in value",{hint:"Must be between 3600 (1 hour) and 31536000 (1 year) seconds",code:"validation_error",json:e.json,fields:e.fields}),t.expires_in=r}let i=j(!e.json);i.start("Creating token");let s=await S("/api/tokens",{method:"POST",body:JSON.stringify(t)}),n=await s.json();if(s.ok||(i.stop("Failed"),h(n.error||n.message,{hint:n.hint,status:s.status,json:e.json,fields:e.fields})),i.stop(`${b.success} Token created`),e.json){k(n,e.fields);return}d(),O("Token Created"),$("ID",n.id),$("Name",n.name),$("Scopes",n.scopes?.includes("*")?"All (full access)":n.scopes?.join(", ")||"All"),$("Expires",n.expiresAt?new Date(n.expiresAt).toLocaleString():"Never"),d(),console.log(` ${Ve.default.yellow("!")} ${Ve.default.bold("Key:")} ${n.key}`),console.log(` ${Ve.default.dim("Save this key - it will not be shown again.")}`),d()}async function El(e){e.tokenId||h("Token ID required",{hint:`Usage: domani tokens revoke --token-id <id>
193
- Run 'domani tokens list' to see your tokens.`,code:"validation_error",json:e.json,fields:e.fields});let t=j(!e.json);t.start("Revoking token");let i=await S(`/api/tokens/${encodeURIComponent(e.tokenId)}`,{method:"DELETE"}),s=await i.json();if(i.ok||(t.stop("Failed"),h(s.error||s.message,{hint:s.hint,status:i.status,json:e.json,fields:e.fields})),t.stop(`${b.success} Token revoked`),e.json){k(s,e.fields);return}console.log(` ${Ve.default.dim("Any applications using this key will need a new one.")}`),d()}Q();var Se=F(H(),1);J();ye();He();async function qr(e,t){e||(e=await me()),ee(e,t);let i=t.autoRenew!==void 0,s=t.whoisPrivacy!==void 0,n=t.securityLock!==void 0;if(!i&&!s&&!n)return Il(e,t.json,t.fields);let r={};if(i){let c=tn(t.autoRenew);c===null&&h("--auto-renew must be on or off",{code:"validation_error",json:t.json,fields:t.fields}),r.auto_renew=c}if(s){let c=tn(t.whoisPrivacy);c===null&&h("--whois-privacy must be on or off",{code:"validation_error",json:t.json,fields:t.fields}),r.whois_privacy=c}if(n){let c=tn(t.securityLock);c===null&&h("--security-lock must be on or off",{code:"validation_error",json:t.json,fields:t.fields}),r.security_lock=c}if(t.dryRun)return z("settings_update",{domain:e,...r},t.json,t.fields);let o=j(!t.json);o.start(`Updating ${w.domain(e)}`);let a=await S(`/api/domains/${encodeURIComponent(e)}/settings`,{method:"PUT",body:JSON.stringify(r)}),l=await a.json();if(a.ok||(o.stop("Failed"),h(l.error||l.message,{hint:l.hint,status:a.status,json:t.json,fields:t.fields})),o.stop(`${b.success} Settings updated`),t.json){k(l,t.fields);return}O("Settings Updated"),$("Domain",w.domain(l.domain)),l.auto_renew!==void 0&&$("Auto-renew",l.auto_renew?Se.default.green("on"):Se.default.dim("off")),l.whois_privacy!==void 0&&$("WHOIS privacy",l.whois_privacy?Se.default.green("on"):Se.default.dim("off")),l.security_lock!==void 0&&$("Security lock",l.security_lock?Se.default.green("locked"):Se.default.dim("unlocked")),l.hint&&$("",Se.default.dim(l.hint)),d()}async function Il(e,t,i){let s=j(!t);s.start(`Loading ${w.domain(e)}`);let n=await S(`/api/domains/${encodeURIComponent(e)}`),r=await n.json();if(n.ok||(s.stop("Failed"),h(r.error||r.message,{hint:r.hint,status:n.status,json:t,fields:i})),s.stop(`${b.success} ${w.domain(e)}`),t){k(r,i);return}O("Domain Settings"),$("Domain",w.domain(r.domain)),$("Status",r.status==="active"?Se.default.green(r.status):Se.default.yellow(r.status)),$("Auto-renew",r.auto_renew?Se.default.green("on"):Se.default.dim("off")),r.registrar&&($("WHOIS privacy",r.registrar.whois_privacy?Se.default.green("on"):Se.default.dim("off")),$("Security lock",r.registrar.security_lock?Se.default.green("locked"):Se.default.dim("unlocked"))),$("Expires",new Date(r.expires_at).toLocaleDateString()+Se.default.dim(` (${r.days_until_expiry} days)`)),d(),A("Toggle auto-renew:",`domani settings ${e} --auto-renew off`),A("Toggle WHOIS privacy:",`domani settings ${e} --whois-privacy off`),A("Toggle security lock:",`domani settings ${e} --security-lock off`),A("Get transfer auth code:",`domani auth-code ${e}`),d()}function tn(e){let t=e.toLowerCase();return t==="on"||t==="true"||t==="1"||t==="enable"?!0:t==="off"||t==="false"||t==="0"||t==="disable"?!1:null}Q();var At=F(H(),1);J();ye();He();async function Wr(e,t){e||(e=await me()),ee(e,t);let i=j(!t.json);i.start(`Getting auth code for ${w.domain(e)}`);let s=await S(`/api/domains/${encodeURIComponent(e)}/auth-code`),n=await s.json();if(s.ok||(i.stop("Failed"),h(n.error||n.message,{hint:n.hint,status:s.status,json:t.json,fields:t.fields})),i.stop(`${b.success} Auth code retrieved`),t.json){k(n,t.fields);return}if(O("Auth Code"),$("Domain",w.domain(n.domain)),$("Auth code",At.default.bold(At.default.green(n.auth_code))),n.was_unlocked&&$("",At.default.yellow("Domain was automatically unlocked to allow transfer.")),n.hint&&(d(),console.log(` ${At.default.dim(n.hint)}`)),n.next_steps?.length){d();for(let r of n.next_steps)console.log(` ${At.default.dim("\u2192")} ${At.default.dim(r)}`)}d(),A("Check transfer status:",`domani transfer-away ${e}`),A("Re-lock domain:",`domani settings ${e} --security-lock on`),d()}Q();var ut=F(H(),1);J();ye();He();var Tl={none:ut.default.dim,pending:ut.default.yellow,approved:ut.default.yellow,completed:ut.default.green,rejected:ut.default.red,expired:ut.default.red};async function Hr(e,t){e||(e=await me()),ee(e,t);let i=j(!t.json);i.start(`Checking transfer status for ${w.domain(e)}`);let s=await S(`/api/domains/${encodeURIComponent(e)}/transfer-away`),n=await s.json();if(s.ok||(i.stop("Failed"),h(n.error||n.message,{hint:n.hint,status:s.status,json:t.json,fields:t.fields})),i.stop(`${b.success} ${w.domain(e)}`),t.json){k(n,t.fields);return}O("Transfer Away Status"),$("Domain",w.domain(n.domain));let r=Tl[n.status]||ut.default.dim;$("Status",r(n.status)),n.gaining_registrar&&$("New registrar",n.gaining_registrar),n.request_date&&$("Requested",new Date(n.request_date).toLocaleDateString()),n.hint&&(d(),console.log(` ${ut.default.dim(n.hint)}`)),d(),n.status==="none"?A("Get auth code to start:",`domani auth-code ${e}`):n.status==="pending"||n.status==="approved"?A("Check again later:",`domani transfer-away ${e}`):n.status==="completed"?A("Search for a new domain:","domani search <name>"):(n.status==="rejected"||n.status==="expired")&&A("Retry with a new auth code:",`domani auth-code ${e}`),d()}Q();Ie();var Fi=F(H(),1);J();async function Jr(e,t){return e==="set"?Dl(t):Pl(t)}async function Pl(e){let t=j(!e.json);t.start("Loading contact info");let i=await S("/api/me/contact"),s=await i.json();if(i.ok||(t.stop("Failed"),h(s.error||s.message,{hint:s.hint,status:i.status,json:e.json,fields:e.fields})),t.stop(`${b.success} Contact info`),e.json){k(s,e.fields);return}if(O("Contact Info"),!s.has_contact){console.log(` ${b.warning} ${Fi.default.yellow("No contact info set.")} Run ${Fi.default.bold("domani contact set")} to add.`),d(),console.log(` ${Fi.default.dim("Contact info is required before purchasing domains.")}`),d();return}let n=s.contact;$("Name",`${n.first_name} ${n.last_name}`),n.org_name&&$("Organization",n.org_name),$("Address",n.address1),n.address2&&$("",n.address2),$("",`${n.city}, ${n.state} ${n.postal_code}`),$("Country",n.country),$("Phone",n.phone),$("Email",n.email),d()}async function Dl(e){let t={},i=e.firstName||e.lastName||e.address1;if(!xe&&!i&&h("Missing required flags for contact set",{hint:"Usage: domani contact set --first-name John --last-name Doe --address1 '123 Main St' --city SF --state CA --postal-code 94105 --country US --phone +1.5551234567 --email john@example.com",code:"missing_argument",json:e.json}),i){let a=["firstName","lastName","address1","city","state","postalCode","country","phone","email"],l={firstName:"first_name",lastName:"last_name",orgName:"org_name",address1:"address1",address2:"address2",city:"city",state:"state",postalCode:"postal_code",country:"country",phone:"phone",email:"email"},c=a.filter(u=>!e[u]);c.length>0&&h(`Missing required flags: ${c.map(u=>`--${u.replace(/[A-Z]/g,p=>`-${p.toLowerCase()}`)}`).join(", ")}`,{code:"missing_argument",json:e.json});for(let[u,p]of Object.entries(l)){let g=e[u];g&&(t[p]=g)}}else{let a=await S("/api/me/contact"),c=(a.ok?await a.json():null)?.contact,u=[{key:"first_name",message:"First name",placeholder:"John",required:!0},{key:"last_name",message:"Last name",placeholder:"Doe",required:!0},{key:"org_name",message:"Organization (optional, press Enter to skip)",placeholder:"Acme Inc.",required:!1},{key:"address1",message:"Address line 1",placeholder:"123 Main St",required:!0},{key:"address2",message:"Address line 2 (optional)",placeholder:"Suite 100",required:!1},{key:"city",message:"City",placeholder:"San Francisco",required:!0},{key:"state",message:"State / Province",placeholder:"CA",required:!0},{key:"postal_code",message:"Postal / ZIP code",placeholder:"94105",required:!0},{key:"country",message:"Country code (ISO 3166-1 alpha-2)",placeholder:"US",required:!0},{key:"phone",message:"Phone (+CC.NUMBER)",placeholder:"+1.5551234567",required:!0},{key:"email",message:"Contact email",placeholder:"john@example.com",required:!0}];for(let p of u){let g=c?.[p.key]||"",_=await Ae({message:p.message,placeholder:p.placeholder,defaultValue:g,validate:p.required?m=>m?.trim()?void 0:`${p.message} is required`:void 0});oe(_)&&process.exit(0);let y=_.trim();y&&(t[p.key]=y)}}if(e.dryRun)return z("contact_set",t,e.json,e.fields);let s=j(!e.json);s.start("Saving contact info");let n=await S("/api/me/contact",{method:"PUT",body:JSON.stringify(t)}),r=await n.json();if(n.ok||(s.stop("Failed"),h(r.error||r.message,{hint:r.hint,status:n.status,json:e.json,fields:e.fields})),s.stop(`${b.success} Contact info saved`),e.json){k(r,e.fields);return}O("Contact Saved");let o=r.contact;$("Name",`${o.first_name} ${o.last_name}`),o.org_name&&$("Organization",o.org_name),$("Address",o.address1),o.address2&&$("",o.address2),$("",`${o.city}, ${o.state} ${o.postal_code}`),$("Country",o.country),$("Phone",o.phone),$("Email",o.email),d(),A("Search for a domain:","domani search <name>"),d()}Q();var Re=F(H(),1);J();ye();He();async function Yr(e,t,i,s){if(e||(e=await me()),ee(e,s),!t)return Nl(e,s.json,s.fields);switch(t){case"enable":case"on":return s.dryRun?z("parking_enable",{domain:e},s.json,s.fields):Br(e,!0,s.json,s.fields);case"disable":case"off":return s.dryRun?z("parking_disable",{domain:e},s.json,s.fields):Br(e,!1,s.json,s.fields);case"price":{i||h("Price required",{hint:"Usage: domani parking <domain> price <amount>",code:"validation_error",json:s.json,fields:s.fields});let n=parseFloat(i);return(isNaN(n)||n<=0)&&h("Price must be a positive number",{hint:`Got: "${i}"`,code:"validation_error",json:s.json,fields:s.fields}),s.dryRun?z("parking_price",{domain:e,price:n},s.json,s.fields):Gr(e,n,s.json,s.fields)}case"unprice":case"unlist":return s.dryRun?z("parking_unlist",{domain:e},s.json,s.fields):Gr(e,null,s.json,s.fields);default:h(`Unknown action: ${t}`,{hint:"Actions: enable, disable, price <amount>, unprice",code:"validation_error",json:s.json,fields:s.fields})}}async function Nl(e,t,i){let s=j(!t);s.start(`Loading ${w.domain(e)}`);let n=await S(`/api/domains/${encodeURIComponent(e)}`),r=await n.json();if(n.ok||(s.stop("Failed"),h(r.error||r.message,{hint:r.hint,status:n.status,json:t,fields:i})),s.stop(`${b.success} ${w.domain(e)}`),t){k({domain:r.domain,parking_enabled:r.parking_enabled,listing_price:r.listing_price},i);return}O("Parking"),$("Domain",w.domain(r.domain)),$("Parking",r.parking_enabled?Re.default.green("enabled"):Re.default.dim("disabled")),$("Listing",r.listing_price?`${w.price(r.listing_price)} ${Re.default.dim("(for sale)")}`:Re.default.dim("not listed")),d(),A("Enable parking:",`domani parking ${e} enable`),A("Set sale price:",`domani parking ${e} price 499`),A("View analytics:",`domani analytics ${e}`),d()}async function Br(e,t,i,s){let n=j(!i);n.start(`${t?"Enabling":"Disabling"} parking for ${w.domain(e)}`);let r=await S(`/api/domains/${encodeURIComponent(e)}/parking`,{method:"PUT",body:JSON.stringify({enabled:t})}),o=await r.json();if(r.status===409&&o.requires_confirmation){if(n.stop(`${b.warning} DNS records will be replaced`),i){k(o,s);return}console.log(`
194
- ${Re.default.yellow("Enabling parking will replace these DNS records:")}`);for(let a of o.existing_dns||[])console.log(` ${Re.default.dim(a.type)} ${a.name} ${Re.default.dim("\u2192")} ${a.value}`);console.log(`
195
- ${Re.default.dim("Run again with --confirm to proceed (not implemented yet).")}`),console.log(` ${Re.default.dim("Or use the dashboard to confirm.")}`),d();return}if(r.ok||(n.stop("Failed"),h(o.error||o.message,{hint:o.hint,status:r.status,json:i,fields:s})),n.stop(`${b.success} Parking ${t?"enabled":"disabled"}`),i){k(o,s);return}O("Parking Updated"),$("Domain",w.domain(o.domain)),$("Parking",o.parking_enabled?Re.default.green("enabled"):Re.default.dim("disabled")),o.hint&&$("",Re.default.dim(o.hint)),d()}async function Gr(e,t,i,s){let n=j(!i);n.start(t!==null?`Setting price for ${w.domain(e)} to ${w.price(t)}`:`Removing listing for ${w.domain(e)}`);let r=await S(`/api/domains/${encodeURIComponent(e)}/parking`,{method:"PUT",body:JSON.stringify({listing_price:t})}),o=await r.json();if(r.ok||(n.stop("Failed"),h(o.error||o.message,{hint:o.hint,status:r.status,json:i,fields:s})),n.stop(`${b.success} ${t!==null?"Price set":"Listing removed"}`),i){k(o,s);return}O("Listing Updated"),$("Domain",w.domain(o.domain)),$("Listing",o.listing_price?`${w.price(o.listing_price)} ${Re.default.dim("(for sale)")}`:Re.default.dim("not listed")),o.hint&&$("",Re.default.dim(o.hint)),d()}Q();var Ue=F(H(),1);J();ye();He();var Fl=" \u2581\u2582\u2583\u2584\u2585\u2586\u2587\u2588";function Ll(e){let t=Math.max(...e,1);return e.map(i=>Fl[Math.min(Math.round(i/t*8),8)]).join("")}async function Kr(e,t){e||(e=await me()),ee(e,t);let i=j(!t.json);i.start(`Loading analytics for ${w.domain(e)}`);let s=await S(`/api/domains/${encodeURIComponent(e)}/analytics`),n=await s.json();if(s.ok||(i.stop("Failed"),h(n.error||n.message,{hint:n.hint,status:s.status,json:t.json,fields:t.fields})),i.stop("Analytics loaded"),t.json){k(n,t.fields);return}if(d(),O(`Analytics: ${w.domain(e)}`),$("Views (7d)",Ue.default.cyan(n.views_7d.toLocaleString())),$("Views (30d)",Ue.default.cyan(n.views_30d.toLocaleString())),$("Inquiries",Ue.default.cyan(String(n.inquiries_30d))),$("Conversion",n.conversion_rate>0?Ue.default.green(`${n.conversion_rate}%`):Ue.default.dim("0%")),n.daily_views&&n.daily_views.length>0){let r=n.daily_views.map(c=>c.views),o=Ll(r),a=n.daily_views[0].date.slice(5),l=n.daily_views[n.daily_views.length-1].date.slice(5);d(),console.log(` ${Ue.default.dim(a)} ${Ue.default.cyan(o)} ${Ue.default.dim(l)}`)}if(n.recent_inquiries&&n.recent_inquiries.length>0){d(),console.log(` ${Ue.default.bold("Recent Inquiries")}`);let r=n.recent_inquiries.map(o=>[Ue.default.dim(o.email),o.offer?w.price(o.offer):Ue.default.dim("-"),Ue.default.dim(new Date(o.date).toLocaleDateString())]);ue(["Email","Offer","Date"],r,[30,12,14])}d(),A("Set a listing price:",`domani parking ${e} price <amount>`),A("Set up email:",`domani email setup ${e}`),A("Domain settings:",`domani settings ${e}`),d()}Q();var he=F(H(),1);J();async function zr(e,t){switch(e){case void 0:case"list":return Vl(t.json,t.fields);case"create":return Ul(t);case"update":return Ml(t);case"delete":return ql(t);case"deliveries":return Wl(t);case"events":return Hl(t.json,t.fields);default:h(`Unknown action: ${e}`,{hint:"Actions: list, create, update, delete, deliveries, events",code:"validation_error",json:t.json,fields:t.fields})}}async function Vl(e,t){let i=j(!e);i.start("Loading webhooks");let s=await S("/api/webhooks"),n=await s.json();if(s.ok||(i.stop("Failed"),h(n.error||n.message,{hint:n.hint,status:s.status,json:e,fields:t})),i.stop(`${b.success} ${n.webhooks.length} webhook(s)`),e){k(n,t);return}if(n.webhooks.length===0){d(),console.log(` ${he.default.dim("No webhooks configured.")}`),d(),A("Create one:","domani webhooks create --url https://... --events domain.purchased,dns.updated"),A("List events:","domani webhooks events"),d();return}d(),O("Webhooks");let r=n.webhooks.map(o=>[he.default.dim(o.id),w.url(o.url),o.events.length<=3?o.events.join(", "):`${o.events.length} events`,o.active?he.default.green("active"):he.default.dim("paused")]);ue(["ID","URL","Events","Status"],r,[28,40,24,10]),d()}async function Ul(e){e.url||h("URL required",{hint:"Usage: domani webhooks create --url https://example.com/hook --events domain.purchased,dns.updated",code:"validation_error",json:e.json,fields:e.fields}),e.events||h("Events required",{hint:`Usage: domani webhooks create --url https://... --events domain.purchased,dns.updated
196
- Run 'domani webhooks events' to see available event types.`,code:"validation_error",json:e.json,fields:e.fields});let t=e.events.split(",").map(r=>r.trim());if(e.dryRun)return z("webhook_create",{url:e.url,events:t},e.json,e.fields);let i=j(!e.json);i.start("Creating webhook");let s=await S("/api/webhooks",{method:"POST",body:JSON.stringify({url:e.url,events:t})}),n=await s.json();if(s.ok||(i.stop("Failed"),h(n.error||n.message,{hint:n.hint,status:s.status,json:e.json,fields:e.fields})),i.stop(`${b.success} Webhook created`),e.json){k(n,e.fields);return}d(),O("Webhook Created"),$("ID",n.id),$("URL",w.url(n.url)),$("Events",n.events.join(", ")),$("Status",he.default.green("active")),d(),console.log(` ${he.default.yellow("!")} ${he.default.bold("Secret:")} ${n.secret}`),console.log(` ${he.default.dim("Save this secret - it won't be shown again.")}`),console.log(` ${he.default.dim("Use it to verify payloads with HMAC-SHA256.")}`),d()}async function Ml(e){e.webhookId||h("Webhook ID required",{hint:"Usage: domani webhooks update --webhook-id <id> [--url ...] [--events ...] [--active on|off]",code:"validation_error",json:e.json,fields:e.fields});let t={};if(e.url&&(t.url=e.url),e.events&&(t.events=e.events.split(",").map(r=>r.trim())),e.active!==void 0&&(t.active=e.active==="on"||e.active==="true"),e.dryRun)return z("webhook_update",{webhook_id:e.webhookId,...t},e.json,e.fields);let i=j(!e.json);i.start("Updating webhook");let s=await S(`/api/webhooks/${encodeURIComponent(e.webhookId)}`,{method:"PATCH",body:JSON.stringify(t)}),n=await s.json();if(s.ok||(i.stop("Failed"),h(n.error||n.message,{hint:n.hint,status:s.status,json:e.json,fields:e.fields})),i.stop(`${b.success} Webhook updated`),e.json){k(n,e.fields);return}O("Webhook Updated"),$("ID",n.id),$("URL",w.url(n.url)),$("Events",n.events.join(", ")),$("Status",n.active?he.default.green("active"):he.default.dim("paused")),d()}async function ql(e){if(e.webhookId||h("Webhook ID required",{hint:"Usage: domani webhooks delete --webhook-id <id>",code:"validation_error",json:e.json,fields:e.fields}),e.dryRun)return z("webhook_delete",{webhook_id:e.webhookId},e.json,e.fields);let t=j(!e.json);t.start("Deleting webhook");let i=await S(`/api/webhooks/${encodeURIComponent(e.webhookId)}`,{method:"DELETE"}),s=await i.json();if(i.ok||(t.stop("Failed"),h(s.error||s.message,{hint:s.hint,status:i.status,json:e.json,fields:e.fields})),t.stop(`${b.success} Webhook deleted`),e.json){k(s,e.fields);return}console.log(` ${he.default.dim("Pending deliveries have been cancelled.")}`),d()}async function Wl(e){e.webhookId||h("Webhook ID required",{hint:"Usage: domani webhooks deliveries --webhook-id <id> [--limit 20]",code:"validation_error",json:e.json,fields:e.fields});let t=e.limit?`?limit=${e.limit}`:"",i=j(!e.json);i.start("Loading deliveries");let s=await S(`/api/webhooks/${encodeURIComponent(e.webhookId)}/deliveries${t}`),n=await s.json();if(s.ok||(i.stop("Failed"),h(n.error||n.message,{hint:n.hint,status:s.status,json:e.json,fields:e.fields})),i.stop(`${b.success} ${n.deliveries.length} delivery(ies)`),e.json){k(n,e.fields);return}if(n.deliveries.length===0){d(),console.log(` ${he.default.dim("No deliveries yet.")}`),d();return}d(),O("Deliveries");let r=n.deliveries.map(o=>{let a=o.status==="delivered"?he.default.green("delivered"):o.status==="failed"?he.default.red("failed"):he.default.yellow("pending");return[o.event_type,a,o.http_status?String(o.http_status):he.default.dim("-"),String(o.attempts),he.default.dim(new Date(o.created_at).toLocaleString())]});ue(["Event","Status","HTTP","Tries","Date"],r,[22,12,6,6,22]),d()}async function Hl(e,t){let i=j(!e);i.start("Loading event types");let s=await $e("/api/webhooks/events"),n=await s.json();if(s.ok||(i.stop("Failed"),h(n.error||n.message,{hint:n.hint,status:s.status,json:e,fields:t})),i.stop(`${b.success} ${n.events.length} event type(s)`),e){k(n,t);return}d(),O("Webhook Event Types");let r=n.events.map(o=>[he.default.cyan(o.type),he.default.dim(o.description)]);ue(["Event","Description"],r,[24,50]),d()}Q();var be=F(H(),1);J();ye();async function Xr(e,t){if(e||h("Domain is required",{hint:`Usage: domani sell <domain> --price <amount>
188
+ `),{chosen:X,chosenResult:le,searchAgain:te,allTaken:r.length===0&&o.length>0,expanded:x>0}}async function Pr(e,t,s){if(!e){ke||h("Missing required argument: domain",{hint:"Usage: domani search <domain> [tlds...]",code:"missing_argument",json:s.json});let D=await Ae({message:"Search for a domain",placeholder:"e.g. myapp or myapp.dev"});(oe(D)||!D)&&process.exit(0),e=D}let i=t.map(D=>D.replace(/^\./,"")),n=s.tlds?.split(",").map(D=>D.trim())||[],r=[...new Set([...i,...n])];if(r.length>0&&Is(r,s),ee(e,s),e.includes(".")&&r.length===0){let D=j(!s.json);D.start(`Checking ${w.domain(e)}`);let[Y,Z]=await Promise.all([$e(`/api/domains/search?q=${encodeURIComponent(e)}`),$e(`/api/domains/${encodeURIComponent(e)}/og`).catch(()=>null)]),V=await Y.json();if(Y.ok||(D.stop("Search failed"),h(V.error||V.message,{hint:V.hint,status:Y.status,json:s.json,fields:s.fields})),s.json){let te=V.domain.split(".")[0];k({name:te,results:[V],total:1,available:V.available?1:0},s.fields);return}if(V.available)if(D.stop(`${b.success} ${w.domain(V.domain)} ${b.dot} available ${b.dot} ${w.price(V.price)}/yr`),ke&&!s.json){let{buy:te}=await Promise.resolve().then(()=>(Mt(),es));await te([V.domain],{preChecked:{price:V.price,currency:V.currency}})}else c(),O("Register it:",`domani buy ${V.domain}`),c();else if(V.for_sale?.buyable)if(D.stop(`${b.info} ${w.domain(V.domain)} ${b.dot} ${T.default.cyan("for sale")} ${b.dot} ${w.price(V.for_sale.price)}`),ke&&!s.json){let{buy:te}=await Promise.resolve().then(()=>(Mt(),es));await te([V.domain],{preChecked:{price:V.for_sale.price,currency:V.for_sale.currency,marketplace:!0}})}else c(),O("Buy it:",`domani buy ${V.domain}`),c();else if(V.error)D.stop(`${T.default.dim("?")} ${w.domain(V.domain)} ${b.dot} ${T.default.dim("lookup failed")}`);else{let te;try{if(Z?.ok){let le=await Z.json();le?.title&&(te=le.title)}}catch{}let X=te?` ${b.dot} ${T.default.dim(`"${te}"`)}`:"";D.stop(`${b.error} ${w.domain(V.domain)} ${b.dot} ${T.default.red("taken")}${X}`)}return}let o=e.split(".")[0];if(ke&&!s.json&&r.length>0){let D=new URLSearchParams;D.set("domains",r.map(W=>`${o}.${W}`).join(",")),s.maxPrice&&D.set("max_price",s.maxPrice);let Y=await $e(`/api/domains/search?${D}`,{headers:{Accept:"text/event-stream"}});if(!Y.ok||!Y.body){h("Search failed",{json:s.json});return}let Z=[],V=new TextDecoder,te="",X="",le=j(!0);le.start(`Checking ${r.length} TLD${r.length>1?"s":""}`);for await(let W of Y.body){te+=V.decode(W,{stream:!0});let Be=te.split(`
189
+ `);te=Be.pop()??"";for(let mt of Be)mt.startsWith("event: ")?X=mt.slice(7):mt.startsWith("data: ")&&X==="result"&&Z.push(JSON.parse(mt.slice(6)))}le.stop("");let q=Math.max(...r.map(W=>`${o}.${W}`.length))+2,K=Z.filter(W=>W.available),de=Z.filter(W=>!W.available&&!W.error),fe=Z.filter(W=>!W.available&&W.for_sale);for(let W of[...K,...fe,...de.filter(Be=>!Be.for_sale)])W.available?console.log(` ${T.default.green("\u2713")} ${T.default.bold(T.default.white(W.domain.padEnd(q)))} ${T.default.green(w.price(W.price)+"/yr")}`):W.for_sale?console.log(` ${T.default.cyan("$")} ${T.default.bold(T.default.white(W.domain.padEnd(q)))} ${T.default.cyan(w.price(W.for_sale.price))} ${T.default.dim("(for sale)")}`):console.log(` ${T.default.dim("\u2717")} ${T.default.dim(W.domain.padEnd(q))} ${T.default.dim("taken")}`);if(K.length===0){console.log(` ${T.default.dim("No domains available")}`),c();return}let{buy:Oe}=await Promise.resolve().then(()=>(Mt(),es));if(K.length===1){await Oe([K[0].domain],{preChecked:{price:K[0].price,currency:K[0].currency}});return}let{select:qe,isCancel:ge}=await Promise.resolve().then(()=>(Te(),Ui)),ae=await qe({message:"Register one?",options:[...K.map(W=>({value:W.domain,label:w.domain(W.domain),hint:w.price(W.price)+"/yr"})),{value:"__skip__",label:"Skip"}]});if(!ge(ae)&&ae!=="__skip__"){c();let W=K.find(Be=>Be.domain===ae);await Oe([ae],{preChecked:W?{price:W.price,currency:W.currency}:void 0})}else c();return}if(ke&&!s.json){let D=await Tr();for(;;){let Y=s.expand?D:D.slice(0,Ue),Z=new URLSearchParams;Z.set("domains",Y.map(qe=>`${o}.${qe}`).join(",")),s.maxPrice&&Z.set("max_price",s.maxPrice);let V=j(!0);V.start(`Searching available domains for ${T.default.bold(o)}`);let te=await $e(`/api/domains/search?${Z}`,{headers:{Accept:"text/event-stream"}});if(!te.ok||!te.body){V.stop("Search failed");break}V.stop("");let X=!s.expand,{chosen:le,chosenResult:q,searchAgain:K}=await Al(te.body,o,s.all??!1,X,D);if(le){c();let{buy:qe}=await Promise.resolve().then(()=>(Mt(),es)),ge=q?{price:q.price,currency:q.currency}:void 0;await qe([le],{preChecked:ge});return}if(!K)break;let{text:de,isCancel:fe}=await Promise.resolve().then(()=>(Te(),Ui)),Oe=await de({message:"Search for a domain",placeholder:"e.g. myapp or myapp.dev"});if(fe(Oe)||!Oe)break;o=Oe.split(".")[0]}c();return}let a=o,l=await Tr(),u=(r.length>0?r:s.expand?l:l.slice(0,Ue)).map(D=>`${a}.${D}`),p=new URLSearchParams;p.set("domains",u.join(",")),s.maxPrice&&p.set("max_price",s.maxPrice);let g=j(!s.json);g.start(`Searching available domains for ${T.default.bold(a)}`);let x=await $e(`/api/domains/search?${p}`,{headers:{Accept:"text/event-stream"}});if(!x.ok){g.stop("Search failed");try{let D=await x.json();h(D.error||D.message||`Server error (${x.status})`,{hint:D.hint,status:x.status,json:s.json,fields:s.fields})}catch{h(`Server error (${x.status})`,{status:x.status,json:s.json,fields:s.fields})}}let y=x.body;y||(g.stop("Search failed"),h("Empty response",{code:"error",json:s.json,fields:s.fields}));let f=[],v=!1,_=0,C=s.all??!1;function A(){v||(v=!0,g.stop(`Checking TLDs for ${T.default.bold(a)}`),c())}function F(D){A(),D.available?console.log(` ${b.success} ${w.domain(D.domain).padEnd(37)} ${w.price(D.price)}${T.default.dim("/yr")}`):D.for_sale?console.log(` ${b.info} ${w.domain(D.domain).padEnd(37)} ${T.default.cyan(w.price(D.for_sale.price))} ${T.default.dim("(for sale)")}`):D.error||console.log(` ${b.error} ${T.default.dim(D.domain.padEnd(38))} ${T.default.red("taken")}`)}function L(){v||g.message(`Checking TLDs for ${T.default.bold(a)} ${T.default.dim(`(${_} checked)`)}`)}let G=new TextDecoder,I="",P="";for await(let D of y){I+=G.decode(D,{stream:!0});let Y=I.split(`
190
+ `);I=Y.pop()??"";for(let Z of Y)if(Z.startsWith("event: "))P=Z.slice(7);else if(Z.startsWith("data: ")){let V=JSON.parse(Z.slice(6));if(P==="result")_++,V.available||V.for_sale||C?(s.json||F(V),f.push(V)):s.json||L();else if(P==="done"){if(s.json){f.sort((q,K)=>q.price-K.price),k({name:a,results:f,total:V.total,available:V.available},s.fields);return}v&&console.log(` ${T.default.dim("\u2500".repeat(50))}`);let te=V.total-V.available,X=V.total>=5&&te/V.total>=.5,le=`Checked ${V.total} TLDs \xB7 ${V.available} available${X?" \xB7 popular name":""}`;console.log(` ${T.default.dim(le)}`),V.available===0&&!s.expand&&r.length===0&&(c(),O("Try more TLDs:",`domani search ${a} --expand`))}}}c()}Mt();Q();var ct=U(J(),1);H();async function Dr(e){let t=j(!e.json);t.start("Loading domains");let s=await S("/api/domains"),i=await s.json();if(s.ok||(t.stop("Failed"),h(i.error||i.message,{hint:i.hint,status:s.status,json:e.json,fields:e.fields})),t.stop(`${i.domains.length} domain(s)`),e.json){k({...i,count:i.domains.length},e.fields);return}if(i.domains.length===0){c(),console.log(` ${ct.default.dim("No domains yet.")} Use: ${ct.default.cyan("domani buy <domain>")}`),c();return}let n=[30,12,12,14];R(`Your Domains (${i.domains.length})`,n.reduce((o,a)=>o+a,0)+n.length-1);let r=i.domains.map(o=>{let a=new Date(o.expiresAt).toLocaleDateString(),l=o.status==="active"?ct.default.green:o.status==="pending"?ct.default.yellow:ct.default.red,d=o.autoRenew?ct.default.green("on"):ct.default.dim("off");return[w.domain(o.domain),l(o.status),d,ct.default.dim(a)]});me(["Domain","Status","Auto-renew","Expires"],r,n),c()}Qi();Q();var At=U(J(),1);H();async function Nr(e){let t=new URLSearchParams;e.maxPrice&&t.set("max_price",e.maxPrice),e.minPrice&&t.set("min_price",e.minPrice),e.sort&&t.set("sort",e.sort),e.search&&t.set("search",e.search),e.limit&&t.set("limit",e.limit),t.set("order","asc");let s=j(!e.json);s.start("Loading TLDs");let i=await $e(`/api/tlds?${t}`),n=await i.json();if(i.ok||(s.stop("Failed"),h(n.error||n.message,{hint:n.hint,status:i.status,json:e.json,fields:e.fields})),s.stop(`${n.total} TLDs loaded`),e.json){k(n,e.fields);return}let r=n.tlds;if(r.length===0){c(),console.log(` ${At.default.dim("No TLDs match your filters.")}`),c();return}R("TLD Pricing");let o=r.map(a=>[At.default.bold(`.${a.tld}`),w.price(a.registration.toFixed(2))+At.default.dim("/yr"),At.default.dim("renew ")+w.price(a.renewal.toFixed(2))+At.default.dim("/yr")]);me(["TLD","Register","Renewal"],o,[22,16,20]),c(),console.log(` ${At.default.dim(`${n.total} TLDs total`)}`),c()}Q();var Se=U(J(),1);H();be();async function Fr(e,t){ee(e,t);let s=j(!t.json);s.start(`Looking up ${w.domain(e)}`);let[i,n]=await Promise.all([$e(`/api/domains/whois?q=${encodeURIComponent(e)}`),$e(`/api/domains/${encodeURIComponent(e)}/og`).catch(()=>null)]),r=await i.json(),o=null;try{n?.ok&&(o=await n.json())}catch{}if(i.ok||(s.stop("Lookup failed"),h(r.error||r.message,{hint:r.hint,status:i.status,json:t.json,fields:t.fields})),s.stop("WHOIS data retrieved"),t.json){k({...r,...o?{og:o}:{}},t.fields);return}if(R(`WHOIS ${w.domain(r.domain)}`),!r.registered){$("Status",`${b.success} ${Se.default.green("not registered")}`),c(),O("Register it:",`domani buy ${r.domain}`),c();return}if($("Status",`${b.error} ${Se.default.red("registered")}`),(o?.title||o?.description)&&(c(),console.log(` ${Se.default.bold("Website preview")}`),console.log(` ${Se.default.dim("\u2500".repeat(50))}`),o.title&&$("Title",o.title),o.description&&$("Description",Se.default.dim(o.description.length>80?o.description.slice(0,80)+"\u2026":o.description)),c()),r.registrar&&$("Registrar",r.registrar),r.created&&$("Created",r.created),r.expires&&$("Expires",r.expires),r.days_until_expiry!=null){let l=r.days_until_expiry,d=l<30?Se.default.red:l<90?Se.default.yellow:Se.default.green;$("Days left",d(String(l)))}r.updated&&$("Updated",r.updated),$("DNSSEC",r.dnssec?Se.default.green("yes"):Se.default.dim("no")),r.nameservers?.length>0&&$("Nameservers",r.nameservers.map(l=>Se.default.cyan(l)).join(Se.default.dim(", "))),r.status?.length>0&&$("Status codes",Se.default.dim(r.status.join(", ")));let a=r.contacts?.registrant;a&&!r.redacted?(c(),console.log(` ${Se.default.bold("Registrant")}`),console.log(` ${Se.default.dim("\u2500".repeat(50))}`),a.name&&$("Name",a.name),a.organization&&$("Organization",a.organization),a.email&&$("Email",w.url(a.email)),a.country&&$("Country",a.country)):r.redacted&&$("Contact",Se.default.dim("redacted (WHOIS privacy)")),c()}Q();Te();var dt=U(J(),1);H();be();async function Lr(e,t){if(!e){ke||h("Missing required argument: prompt",{hint:'Usage: domani suggest "describe your project"',code:"missing_argument",json:t.json});let f=await Ae({message:"Describe your project or idea",placeholder:"e.g. AI coding assistant, pet food delivery..."});(oe(f)||!f)&&process.exit(0),e=f}let s=new URLSearchParams({prompt:e});if(t.count&&s.set("count",t.count),t.tlds&&s.set("tlds",t.tlds),t.tlds&&Is(t.tlds.split(",").map(f=>f.trim()),t),t.style&&s.set("style",t.style),t.lang&&s.set("lang",t.lang),t.json){let f=j(!1);f.start("Finding available domains");let v=t.timeout?parseInt(t.timeout,10)*1e3:6e4,_;try{_=await $e(`/api/domains/suggest?${s}`,{signal:AbortSignal.timeout(v)})}catch{f.stop("Failed"),h("Request timed out",{hint:"Suggest took too long. Try --timeout <seconds> to increase.",code:"timeout",json:t.json,fields:t.fields})}let C=await _.json();_.ok||(f.stop("Failed"),h(C.error||C.message,{hint:C.hint,status:_.status,json:t.json,fields:t.fields})),k(C,t.fields);return}let i=j(!0);i.start("Finding available domains");let n=t.timeout?parseInt(t.timeout,10)*1e3:6e4,r;try{r=await $e(`/api/domains/suggest?${s}`,{headers:{Accept:"text/event-stream"},signal:AbortSignal.timeout(n)})}catch{i.stop("Failed"),h("Request timed out",{hint:"Suggest took too long. Try --timeout <seconds> to increase.",code:"timeout"})}if(!r.ok){i.stop("Failed");try{let f=await r.json();h(f.error||f.message||`Server error (${r.status})`,{hint:f.hint,status:r.status})}catch{h(`Server error (${r.status})`,{status:r.status})}}let o=r.body;o||(i.stop("Failed"),h("Empty response"));let a=[],l=[],d=!1,u=0;function p(){d||(d=!0,i.stop("Finding available domains"),c())}let g=new TextDecoder,x="",y="";for await(let f of o){x+=g.decode(f,{stream:!0});let v=x.split(`
191
+ `);x=v.pop()??"";for(let _ of v)if(_.startsWith("event: "))y=_.slice(7);else if(_.startsWith("data: "))try{let C=JSON.parse(_.slice(6));if(y==="result")u++,C.available?a.push(C):l.push(C),d||i.message(`Finding available domains ${dt.default.dim(`(${u} checked, ${a.length} available)`)}`);else if(y==="iteration")d||i.message(`Finding available domains ${dt.default.dim(`(round ${C.n})`)}`);else if(y==="done"){p();for(let A of a){let F=A.reason?` ${dt.default.dim(A.reason)}`:"";console.log(` ${b.success} ${w.domain(A.domain).padEnd(37)} ${w.price(A.price)}${dt.default.dim("/yr")}${F}`)}for(let A of l)console.log(` ${b.error} ${dt.default.dim(A.domain.padEnd(38))} ${dt.default.red("taken")}`);console.log(` ${dt.default.dim("\u2500".repeat(50))}`),console.log(` ${dt.default.dim(`Found ${C.total} available \xB7 checked ${C.checked} \xB7 ${C.iterations} round${C.iterations>1?"s":""}`)}`)}else y==="error"&&(d||i.stop("Failed"),h(C.message))}catch{}}a.length===0&&l.length===0&&(d||i.stop("No results"),h("Could not find available domains for this prompt.")),c(),a.length>0&&(O("Register one:",`domani buy ${a[0].domain}`),c())}Yi();tn();Q();Te();var qt=U(J(),1);H();be();Jt();async function Ur(e,t){if(ee(e,t),!t.authCode){(t.json||!process.stdout.isTTY)&&h("--auth-code is required",{hint:"Get the EPP/auth code from your current registrar.",code:"validation_error",json:t.json,fields:t.fields});let a=await Ae({message:"Enter the EPP/auth code from your current registrar:",validate:l=>!l||l.trim().length===0?"Auth code is required":void 0});oe(a)&&process.exit(0),t.authCode=a}let s=j(!t.json);s.start(`Checking transfer eligibility for ${w.domain(e)}`);let i=await S(`/api/domains/transfer-check?domain=${encodeURIComponent(e)}`),n=await i.json();if(i.ok||(s.stop("Check failed"),h(n.error,{hint:n.hint,status:i.status,json:t.json,fields:t.fields})),n.eligible||(s.stop(`${b.error} Not eligible`),h(n.reason||"Domain is not eligible for transfer.",{hint:n.hint,code:"not_eligible",json:t.json,fields:t.fields})),s.stop(`${b.success} Eligible for transfer`),t.dryRun)return z("transfer",{domain:e,eligible:!0,price:n.price,currency:n.currency||"USD",includes_renewal:!0},t.json,t.fields);if(!Ct(t)){let a=n.price!=null?` for ${w.price(n.price.toFixed(2))}`:"",l=await He({message:`Transfer ${qt.default.bold(e)} to ${Tt}${a}? (includes 1 year renewal)`});if(!l||typeof l=="symbol"){console.log(` ${qt.default.dim("Cancelled.")}`);return}}s.start(`Initiating transfer for ${w.domain(e)}`);let r=await S("/api/domains/transfer",{method:"POST",body:JSON.stringify({domain:e,auth_code:t.authCode})}),o=await r.json();if(r.ok||(s.stop("Transfer failed"),h(o.error||o.message,{hint:o.hint,fixUrl:o.setup_url||o.payment_options?.card?.setup_url,status:r.status,json:t.json,fields:t.fields})),s.stop(`${b.success} Transfer initiated`),t.json){k(o,t.fields);return}R("Transfer Initiated"),$("Domain",w.domain(o.domain)),$("Status",qt.default.yellow(o.status||"pending")),o.price&&$("Price",w.price(o.price)+qt.default.dim(` ${o.currency||"USD"}`)),o.payment_method&&$("Payment",o.payment_method),o.expires&&$("Expires",new Date(o.expires).toLocaleDateString()),o.hint&&(c(),console.log(` ${qt.default.dim(o.hint)}`)),c(),O("Check transfer progress:",`domani status ${o.domain}`),c()}Q();Te();var Ns=U(J(),1);H();be();Je();async function Vr(e,t){e||(e=await ue()),ee(e,t);let s=t.years?parseInt(t.years,10):1;if((isNaN(s)||s<1||s>10)&&h("--years must be between 1 and 10",{code:"validation_error",json:t.json,fields:t.fields}),t.dryRun)return z("renew",{domain:e,years:s},t.json,t.fields);if(!Ct(t)){let o=await He({message:`Renew ${Ns.default.bold(e)} for ${s} year${s>1?"s":""}? You will be charged.`});if(!o||typeof o=="symbol"){console.log(` ${Ns.default.dim("Cancelled.")}`);return}}let i=j(!t.json);i.start(`Renewing ${w.domain(e)}`);let n=await S(`/api/domains/${encodeURIComponent(e)}/renew`,{method:"POST",body:JSON.stringify({years:s})}),r=await n.json();if(n.ok||(i.stop("Renewal failed"),h(r.error||r.message,{hint:r.hint,fixUrl:r.setup_url||r.payment_options?.card?.setup_url,status:n.status,json:t.json,fields:t.fields})),i.stop(`${b.success} Domain renewed`),t.json){k(r,t.fields);return}R("Renewal Complete"),$("Domain",w.domain(r.domain)),$("Years",String(r.renewed_years)),$("New expiry",new Date(r.new_expiry).toLocaleDateString()),r.price&&$("Price",w.price(r.price)+Ns.default.dim(` ${r.currency||"USD"}`)),r.payment_method&&$("Payment",r.payment_method),c(),O("Verify renewal:",`domani status ${r.domain}`),c()}Q();var tt=U(J(),1);H();be();async function Mr(e,t){e||h("Domain is required",{hint:`Usage: domani import <domain>
192
+ domani import <domain> --verify`,code:"validation_error",json:t.json,fields:t.fields}),ee(e,t);let s=t.verify?"/api/domains/import/verify":"/api/domains/import",i=j(!t.json);i.start(t.verify?`Verifying ownership of ${w.domain(e)}`:`Initiating import for ${w.domain(e)}`);let n=await S(s,{method:"POST",body:JSON.stringify({domain:e})}),r=await n.json();if(n.ok||(i.stop(t.verify?"Verification failed":"Import failed"),h(r.error||r.message,{hint:r.hint,status:n.status,json:t.json,fields:t.fields})),t.json){i.stop(""),k(r,t.fields);return}t.verify?(i.stop(`${b.success} ${w.domain(e)} imported!`),R("Domain Imported"),$("Domain",w.domain(r.domain)),$("Status",tt.default.green(r.status||"active")),r.expires_at&&$("Expires",new Date(r.expires_at).toLocaleDateString()),r.registrar&&$("Registrar",r.registrar),c(),O("Check domain health:",`domani status ${r.domain}`),c()):(i.stop(`${b.success} Verification record ready`),R("Import Domain"),$("Domain",w.domain(r.domain)),$("Status",tt.default.yellow("pending verification")),c(),console.log(" Add this TXT record at your DNS provider:"),c(),console.log(` ${tt.default.dim("Type:")} ${tt.default.bold("TXT")}`),console.log(` ${tt.default.dim("Name:")} ${tt.default.bold(r.txt_record?.name||"@")}`),console.log(` ${tt.default.dim("Value:")} ${tt.default.bold(r.txt_record?.value||`domani-verify=${r.token}`)}`),c(),console.log(` ${tt.default.dim("DNS propagation may take a few minutes to 48 hours.")}`),c(),O("Once the record is set, verify:",`domani import ${e} --verify`),c())}zi();ht();H();function qr(e){let t=pt();t||(c(),h("Not logged in",{hint:"Run 'domani login' first",code:"auth_required",json:e.json})),e.json?k({token:t}):console.log(t)}Q();var Ve=U(J(),1);H();async function Wr(e,t){switch(e){case void 0:case"list":return El(t.json,t.fields);case"create":return Il(t);case"revoke":return Tl(t);default:h(`Unknown action: ${e}`,{hint:"Actions: list, create, revoke",code:"validation_error",json:t.json,fields:t.fields})}}async function El(e,t){let s=j(!e);s.start("Loading tokens");let i=await S("/api/tokens"),n=await i.json();if(i.ok||(s.stop("Failed"),h(n.error||n.message,{hint:n.hint,status:i.status,json:e,fields:t})),s.stop(`${b.success} ${n.tokens.length} token(s)`),e){k(n,t);return}if(n.tokens.length===0){c(),console.log(` ${Ve.default.dim("No tokens.")}`),c(),O("Create one:",'domani tokens create --name "My App"'),c();return}c(),R("API Tokens");let r=n.tokens.map(o=>{let a;o.expired?a=Ve.default.red("Expired"):o.expiresAt?a=Ve.default.dim(`Expires ${new Date(o.expiresAt).toLocaleDateString()}`):a=Ve.default.dim("No expiration");let l=o.scopes.includes("*")?Ve.default.dim("all"):Ve.default.dim(o.scopes.join(", "));return[Ve.default.dim(o.id),Ve.default.bold(o.name),l,a]});me(["ID","Name","Scopes","Expiration"],r,[28,16,32,20]),c()}async function Il(e){let t={};if(e.name&&(t.name=e.name),e.scopes&&(t.scopes=e.scopes.split(",").map(r=>r.trim())),e.expiresIn){let r=Number(e.expiresIn);(isNaN(r)||r<3600||r>31536e3)&&h("Invalid --expires-in value",{hint:"Must be between 3600 (1 hour) and 31536000 (1 year) seconds",code:"validation_error",json:e.json,fields:e.fields}),t.expires_in=r}let s=j(!e.json);s.start("Creating token");let i=await S("/api/tokens",{method:"POST",body:JSON.stringify(t)}),n=await i.json();if(i.ok||(s.stop("Failed"),h(n.error||n.message,{hint:n.hint,status:i.status,json:e.json,fields:e.fields})),s.stop(`${b.success} Token created`),e.json){k(n,e.fields);return}c(),R("Token Created"),$("ID",n.id),$("Name",n.name),$("Scopes",n.scopes?.includes("*")?"All (full access)":n.scopes?.join(", ")||"All"),$("Expires",n.expiresAt?new Date(n.expiresAt).toLocaleString():"Never"),c(),console.log(` ${Ve.default.yellow("!")} ${Ve.default.bold("Key:")} ${n.key}`),console.log(` ${Ve.default.dim("Save this key - it will not be shown again.")}`),c()}async function Tl(e){e.tokenId||h("Token ID required",{hint:`Usage: domani tokens revoke --token-id <id>
193
+ Run 'domani tokens list' to see your tokens.`,code:"validation_error",json:e.json,fields:e.fields});let t=j(!e.json);t.start("Revoking token");let s=await S(`/api/tokens/${encodeURIComponent(e.tokenId)}`,{method:"DELETE"}),i=await s.json();if(s.ok||(t.stop("Failed"),h(i.error||i.message,{hint:i.hint,status:s.status,json:e.json,fields:e.fields})),t.stop(`${b.success} Token revoked`),e.json){k(i,e.fields);return}console.log(` ${Ve.default.dim("Any applications using this key will need a new one.")}`),c()}Q();var Ce=U(J(),1);H();be();Je();async function Hr(e,t){e||(e=await ue()),ee(e,t);let s=t.autoRenew!==void 0,i=t.whoisPrivacy!==void 0,n=t.securityLock!==void 0;if(!s&&!i&&!n)return Pl(e,t.json,t.fields);let r={};if(s){let d=rn(t.autoRenew);d===null&&h("--auto-renew must be on or off",{code:"validation_error",json:t.json,fields:t.fields}),r.auto_renew=d}if(i){let d=rn(t.whoisPrivacy);d===null&&h("--whois-privacy must be on or off",{code:"validation_error",json:t.json,fields:t.fields}),r.whois_privacy=d}if(n){let d=rn(t.securityLock);d===null&&h("--security-lock must be on or off",{code:"validation_error",json:t.json,fields:t.fields}),r.security_lock=d}if(t.dryRun)return z("settings_update",{domain:e,...r},t.json,t.fields);let o=j(!t.json);o.start(`Updating ${w.domain(e)}`);let a=await S(`/api/domains/${encodeURIComponent(e)}/settings`,{method:"PUT",body:JSON.stringify(r)}),l=await a.json();if(a.ok||(o.stop("Failed"),h(l.error||l.message,{hint:l.hint,status:a.status,json:t.json,fields:t.fields})),o.stop(`${b.success} Settings updated`),t.json){k(l,t.fields);return}R("Settings Updated"),$("Domain",w.domain(l.domain)),l.auto_renew!==void 0&&$("Auto-renew",l.auto_renew?Ce.default.green("on"):Ce.default.dim("off")),l.whois_privacy!==void 0&&$("WHOIS privacy",l.whois_privacy?Ce.default.green("on"):Ce.default.dim("off")),l.security_lock!==void 0&&$("Security lock",l.security_lock?Ce.default.green("locked"):Ce.default.dim("unlocked")),l.hint&&$("",Ce.default.dim(l.hint)),c()}async function Pl(e,t,s){let i=j(!t);i.start(`Loading ${w.domain(e)}`);let n=await S(`/api/domains/${encodeURIComponent(e)}`),r=await n.json();if(n.ok||(i.stop("Failed"),h(r.error||r.message,{hint:r.hint,status:n.status,json:t,fields:s})),i.stop(`${b.success} ${w.domain(e)}`),t){k(r,s);return}R("Domain Settings"),$("Domain",w.domain(r.domain)),$("Status",r.status==="active"?Ce.default.green(r.status):Ce.default.yellow(r.status)),$("Auto-renew",r.auto_renew?Ce.default.green("on"):Ce.default.dim("off")),r.registrar&&($("WHOIS privacy",r.registrar.whois_privacy?Ce.default.green("on"):Ce.default.dim("off")),$("Security lock",r.registrar.security_lock?Ce.default.green("locked"):Ce.default.dim("unlocked"))),$("Expires",new Date(r.expires_at).toLocaleDateString()+Ce.default.dim(` (${r.days_until_expiry} days)`)),c(),O("Toggle auto-renew:",`domani settings ${e} --auto-renew off`),O("Toggle WHOIS privacy:",`domani settings ${e} --whois-privacy off`),O("Toggle security lock:",`domani settings ${e} --security-lock off`),O("Get transfer auth code:",`domani auth-code ${e}`),c()}function rn(e){let t=e.toLowerCase();return t==="on"||t==="true"||t==="1"||t==="enable"?!0:t==="off"||t==="false"||t==="0"||t==="disable"?!1:null}Q();var Et=U(J(),1);H();be();Je();async function Jr(e,t){e||(e=await ue()),ee(e,t);let s=j(!t.json);s.start(`Getting auth code for ${w.domain(e)}`);let i=await S(`/api/domains/${encodeURIComponent(e)}/auth-code`),n=await i.json();if(i.ok||(s.stop("Failed"),h(n.error||n.message,{hint:n.hint,status:i.status,json:t.json,fields:t.fields})),s.stop(`${b.success} Auth code retrieved`),t.json){k(n,t.fields);return}if(R("Auth Code"),$("Domain",w.domain(n.domain)),$("Auth code",Et.default.bold(Et.default.green(n.auth_code))),n.was_unlocked&&$("",Et.default.yellow("Domain was automatically unlocked to allow transfer.")),n.hint&&(c(),console.log(` ${Et.default.dim(n.hint)}`)),n.next_steps?.length){c();for(let r of n.next_steps)console.log(` ${Et.default.dim("\u2192")} ${Et.default.dim(r)}`)}c(),O("Check transfer status:",`domani transfer-away ${e}`),O("Re-lock domain:",`domani settings ${e} --security-lock on`),c()}Q();var ut=U(J(),1);H();be();Je();var Dl={none:ut.default.dim,pending:ut.default.yellow,approved:ut.default.yellow,completed:ut.default.green,rejected:ut.default.red,expired:ut.default.red};async function Br(e,t){e||(e=await ue()),ee(e,t);let s=j(!t.json);s.start(`Checking transfer status for ${w.domain(e)}`);let i=await S(`/api/domains/${encodeURIComponent(e)}/transfer-away`),n=await i.json();if(i.ok||(s.stop("Failed"),h(n.error||n.message,{hint:n.hint,status:i.status,json:t.json,fields:t.fields})),s.stop(`${b.success} ${w.domain(e)}`),t.json){k(n,t.fields);return}R("Transfer Away Status"),$("Domain",w.domain(n.domain));let r=Dl[n.status]||ut.default.dim;$("Status",r(n.status)),n.gaining_registrar&&$("New registrar",n.gaining_registrar),n.request_date&&$("Requested",new Date(n.request_date).toLocaleDateString()),n.hint&&(c(),console.log(` ${ut.default.dim(n.hint)}`)),c(),n.status==="none"?O("Get auth code to start:",`domani auth-code ${e}`):n.status==="pending"||n.status==="approved"?O("Check again later:",`domani transfer-away ${e}`):n.status==="completed"?O("Search for a new domain:","domani search <name>"):(n.status==="rejected"||n.status==="expired")&&O("Retry with a new auth code:",`domani auth-code ${e}`),c()}Q();Te();var Fs=U(J(),1);H();async function Gr(e,t){return e==="set"?Fl(t):Nl(t)}async function Nl(e){let t=j(!e.json);t.start("Loading contact info");let s=await S("/api/me/contact"),i=await s.json();if(s.ok||(t.stop("Failed"),h(i.error||i.message,{hint:i.hint,status:s.status,json:e.json,fields:e.fields})),t.stop(`${b.success} Contact info`),e.json){k(i,e.fields);return}if(R("Contact Info"),!i.has_contact){console.log(` ${b.warning} ${Fs.default.yellow("No contact info set.")} Run ${Fs.default.bold("domani contact set")} to add.`),c(),console.log(` ${Fs.default.dim("Contact info is required before purchasing domains.")}`),c();return}let n=i.contact;$("Name",`${n.first_name} ${n.last_name}`),n.org_name&&$("Organization",n.org_name),$("Address",n.address1),n.address2&&$("",n.address2),$("",`${n.city}, ${n.state} ${n.postal_code}`),$("Country",n.country),$("Phone",n.phone),$("Email",n.email),c()}async function Fl(e){let t={},s=e.firstName||e.lastName||e.address1;if(!ke&&!s&&h("Missing required flags for contact set",{hint:"Usage: domani contact set --first-name John --last-name Doe --address1 '123 Main St' --city SF --state CA --postal-code 94105 --country US --phone +1.5551234567 --email john@example.com",code:"missing_argument",json:e.json}),s){let a=["firstName","lastName","address1","city","state","postalCode","country","phone","email"],l={firstName:"first_name",lastName:"last_name",orgName:"org_name",address1:"address1",address2:"address2",city:"city",state:"state",postalCode:"postal_code",country:"country",phone:"phone",email:"email"},d=a.filter(u=>!e[u]);d.length>0&&h(`Missing required flags: ${d.map(u=>`--${u.replace(/[A-Z]/g,p=>`-${p.toLowerCase()}`)}`).join(", ")}`,{code:"missing_argument",json:e.json});for(let[u,p]of Object.entries(l)){let g=e[u];g&&(t[p]=g)}}else{let a=await S("/api/me/contact"),d=(a.ok?await a.json():null)?.contact,u=[{key:"first_name",message:"First name",placeholder:"John",required:!0},{key:"last_name",message:"Last name",placeholder:"Doe",required:!0},{key:"org_name",message:"Organization (optional, press Enter to skip)",placeholder:"Acme Inc.",required:!1},{key:"address1",message:"Address line 1",placeholder:"123 Main St",required:!0},{key:"address2",message:"Address line 2 (optional)",placeholder:"Suite 100",required:!1},{key:"city",message:"City",placeholder:"San Francisco",required:!0},{key:"state",message:"State / Province",placeholder:"CA",required:!0},{key:"postal_code",message:"Postal / ZIP code",placeholder:"94105",required:!0},{key:"country",message:"Country code (ISO 3166-1 alpha-2)",placeholder:"US",required:!0},{key:"phone",message:"Phone (+CC.NUMBER)",placeholder:"+1.5551234567",required:!0},{key:"email",message:"Contact email",placeholder:"john@example.com",required:!0}];for(let p of u){let g=d?.[p.key]||"",x=await Ae({message:p.message,placeholder:p.placeholder,defaultValue:g,validate:p.required?f=>f?.trim()?void 0:`${p.message} is required`:void 0});oe(x)&&process.exit(0);let y=x.trim();y&&(t[p.key]=y)}}if(e.dryRun)return z("contact_set",t,e.json,e.fields);let i=j(!e.json);i.start("Saving contact info");let n=await S("/api/me/contact",{method:"PUT",body:JSON.stringify(t)}),r=await n.json();if(n.ok||(i.stop("Failed"),h(r.error||r.message,{hint:r.hint,status:n.status,json:e.json,fields:e.fields})),i.stop(`${b.success} Contact info saved`),e.json){k(r,e.fields);return}R("Contact Saved");let o=r.contact;$("Name",`${o.first_name} ${o.last_name}`),o.org_name&&$("Organization",o.org_name),$("Address",o.address1),o.address2&&$("",o.address2),$("",`${o.city}, ${o.state} ${o.postal_code}`),$("Country",o.country),$("Phone",o.phone),$("Email",o.email),c(),O("Search for a domain:","domani search <name>"),c()}Q();var Ee=U(J(),1);H();be();Je();async function zr(e,t,s,i){if(e||(e=await ue()),ee(e,i),!t)return Ll(e,i.json,i.fields);switch(t){case"enable":case"on":return i.dryRun?z("parking_enable",{domain:e},i.json,i.fields):Yr(e,!0,i.json,i.fields);case"disable":case"off":return i.dryRun?z("parking_disable",{domain:e},i.json,i.fields):Yr(e,!1,i.json,i.fields);case"price":{s||h("Price required",{hint:"Usage: domani parking <domain> price <amount>",code:"validation_error",json:i.json,fields:i.fields});let n=parseFloat(s);return(isNaN(n)||n<=0)&&h("Price must be a positive number",{hint:`Got: "${s}"`,code:"validation_error",json:i.json,fields:i.fields}),i.dryRun?z("parking_price",{domain:e,price:n},i.json,i.fields):Kr(e,n,i.json,i.fields)}case"unprice":case"unlist":return i.dryRun?z("parking_unlist",{domain:e},i.json,i.fields):Kr(e,null,i.json,i.fields);default:h(`Unknown action: ${t}`,{hint:"Actions: enable, disable, price <amount>, unprice",code:"validation_error",json:i.json,fields:i.fields})}}async function Ll(e,t,s){let i=j(!t);i.start(`Loading ${w.domain(e)}`);let n=await S(`/api/domains/${encodeURIComponent(e)}`),r=await n.json();if(n.ok||(i.stop("Failed"),h(r.error||r.message,{hint:r.hint,status:n.status,json:t,fields:s})),i.stop(`${b.success} ${w.domain(e)}`),t){k({domain:r.domain,parking_enabled:r.parking_enabled,listing_price:r.listing_price},s);return}R("Parking"),$("Domain",w.domain(r.domain)),$("Parking",r.parking_enabled?Ee.default.green("enabled"):Ee.default.dim("disabled")),$("Listing",r.listing_price?`${w.price(r.listing_price)} ${Ee.default.dim("(for sale)")}`:Ee.default.dim("not listed")),c(),O("Enable parking:",`domani parking ${e} enable`),O("Set sale price:",`domani parking ${e} price 499`),O("View analytics:",`domani analytics ${e}`),c()}async function Yr(e,t,s,i){let n=j(!s);n.start(`${t?"Enabling":"Disabling"} parking for ${w.domain(e)}`);let r=await S(`/api/domains/${encodeURIComponent(e)}/parking`,{method:"PUT",body:JSON.stringify({enabled:t})}),o=await r.json();if(r.status===409&&o.requires_confirmation){if(n.stop(`${b.warning} DNS records will be replaced`),s){k(o,i);return}console.log(`
194
+ ${Ee.default.yellow("Enabling parking will replace these DNS records:")}`);for(let a of o.existing_dns||[])console.log(` ${Ee.default.dim(a.type)} ${a.name} ${Ee.default.dim("\u2192")} ${a.value}`);console.log(`
195
+ ${Ee.default.dim("Run again with --confirm to proceed (not implemented yet).")}`),console.log(` ${Ee.default.dim("Or use the dashboard to confirm.")}`),c();return}if(r.ok||(n.stop("Failed"),h(o.error||o.message,{hint:o.hint,status:r.status,json:s,fields:i})),n.stop(`${b.success} Parking ${t?"enabled":"disabled"}`),s){k(o,i);return}R("Parking Updated"),$("Domain",w.domain(o.domain)),$("Parking",o.parking_enabled?Ee.default.green("enabled"):Ee.default.dim("disabled")),o.hint&&$("",Ee.default.dim(o.hint)),c()}async function Kr(e,t,s,i){let n=j(!s);n.start(t!==null?`Setting price for ${w.domain(e)} to ${w.price(t)}`:`Removing listing for ${w.domain(e)}`);let r=await S(`/api/domains/${encodeURIComponent(e)}/parking`,{method:"PUT",body:JSON.stringify({listing_price:t})}),o=await r.json();if(r.ok||(n.stop("Failed"),h(o.error||o.message,{hint:o.hint,status:r.status,json:s,fields:i})),n.stop(`${b.success} ${t!==null?"Price set":"Listing removed"}`),s){k(o,i);return}R("Listing Updated"),$("Domain",w.domain(o.domain)),$("Listing",o.listing_price?`${w.price(o.listing_price)} ${Ee.default.dim("(for sale)")}`:Ee.default.dim("not listed")),o.hint&&$("",Ee.default.dim(o.hint)),c()}Q();var Me=U(J(),1);H();be();Je();var Ul=" \u2581\u2582\u2583\u2584\u2585\u2586\u2587\u2588";function Vl(e){let t=Math.max(...e,1);return e.map(s=>Ul[Math.min(Math.round(s/t*8),8)]).join("")}async function Xr(e,t){e||(e=await ue()),ee(e,t);let s=j(!t.json);s.start(`Loading analytics for ${w.domain(e)}`);let i=await S(`/api/domains/${encodeURIComponent(e)}/analytics`),n=await i.json();if(i.ok||(s.stop("Failed"),h(n.error||n.message,{hint:n.hint,status:i.status,json:t.json,fields:t.fields})),s.stop("Analytics loaded"),t.json){k(n,t.fields);return}if(c(),R(`Analytics: ${w.domain(e)}`),$("Views (7d)",Me.default.cyan(n.views_7d.toLocaleString())),$("Views (30d)",Me.default.cyan(n.views_30d.toLocaleString())),$("Inquiries",Me.default.cyan(String(n.inquiries_30d))),$("Conversion",n.conversion_rate>0?Me.default.green(`${n.conversion_rate}%`):Me.default.dim("0%")),n.daily_views&&n.daily_views.length>0){let r=n.daily_views.map(d=>d.views),o=Vl(r),a=n.daily_views[0].date.slice(5),l=n.daily_views[n.daily_views.length-1].date.slice(5);c(),console.log(` ${Me.default.dim(a)} ${Me.default.cyan(o)} ${Me.default.dim(l)}`)}if(n.recent_inquiries&&n.recent_inquiries.length>0){c(),console.log(` ${Me.default.bold("Recent Inquiries")}`);let r=n.recent_inquiries.map(o=>[Me.default.dim(o.email),o.offer?w.price(o.offer):Me.default.dim("-"),Me.default.dim(new Date(o.date).toLocaleDateString())]);me(["Email","Offer","Date"],r,[30,12,14])}c(),O("Set a listing price:",`domani parking ${e} price <amount>`),O("Set up email:",`domani email setup ${e}`),O("Domain settings:",`domani settings ${e}`),c()}Q();var he=U(J(),1);H();async function Zr(e,t){switch(e){case void 0:case"list":return Ml(t.json,t.fields);case"create":return ql(t);case"update":return Wl(t);case"delete":return Hl(t);case"deliveries":return Jl(t);case"events":return Bl(t.json,t.fields);default:h(`Unknown action: ${e}`,{hint:"Actions: list, create, update, delete, deliveries, events",code:"validation_error",json:t.json,fields:t.fields})}}async function Ml(e,t){let s=j(!e);s.start("Loading webhooks");let i=await S("/api/webhooks"),n=await i.json();if(i.ok||(s.stop("Failed"),h(n.error||n.message,{hint:n.hint,status:i.status,json:e,fields:t})),s.stop(`${b.success} ${n.webhooks.length} webhook(s)`),e){k(n,t);return}if(n.webhooks.length===0){c(),console.log(` ${he.default.dim("No webhooks configured.")}`),c(),O("Create one:","domani webhooks create --url https://... --events domain.purchased,dns.updated"),O("List events:","domani webhooks events"),c();return}c(),R("Webhooks");let r=n.webhooks.map(o=>[he.default.dim(o.id),w.url(o.url),o.events.length<=3?o.events.join(", "):`${o.events.length} events`,o.active?he.default.green("active"):he.default.dim("paused")]);me(["ID","URL","Events","Status"],r,[28,40,24,10]),c()}async function ql(e){e.url||h("URL required",{hint:"Usage: domani webhooks create --url https://example.com/hook --events domain.purchased,dns.updated",code:"validation_error",json:e.json,fields:e.fields}),e.events||h("Events required",{hint:`Usage: domani webhooks create --url https://... --events domain.purchased,dns.updated
196
+ Run 'domani webhooks events' to see available event types.`,code:"validation_error",json:e.json,fields:e.fields});let t=e.events.split(",").map(r=>r.trim());if(e.dryRun)return z("webhook_create",{url:e.url,events:t},e.json,e.fields);let s=j(!e.json);s.start("Creating webhook");let i=await S("/api/webhooks",{method:"POST",body:JSON.stringify({url:e.url,events:t})}),n=await i.json();if(i.ok||(s.stop("Failed"),h(n.error||n.message,{hint:n.hint,status:i.status,json:e.json,fields:e.fields})),s.stop(`${b.success} Webhook created`),e.json){k(n,e.fields);return}c(),R("Webhook Created"),$("ID",n.id),$("URL",w.url(n.url)),$("Events",n.events.join(", ")),$("Status",he.default.green("active")),c(),console.log(` ${he.default.yellow("!")} ${he.default.bold("Secret:")} ${n.secret}`),console.log(` ${he.default.dim("Save this secret - it won't be shown again.")}`),console.log(` ${he.default.dim("Use it to verify payloads with HMAC-SHA256.")}`),c()}async function Wl(e){e.webhookId||h("Webhook ID required",{hint:"Usage: domani webhooks update --webhook-id <id> [--url ...] [--events ...] [--active on|off]",code:"validation_error",json:e.json,fields:e.fields});let t={};if(e.url&&(t.url=e.url),e.events&&(t.events=e.events.split(",").map(r=>r.trim())),e.active!==void 0&&(t.active=e.active==="on"||e.active==="true"),e.dryRun)return z("webhook_update",{webhook_id:e.webhookId,...t},e.json,e.fields);let s=j(!e.json);s.start("Updating webhook");let i=await S(`/api/webhooks/${encodeURIComponent(e.webhookId)}`,{method:"PATCH",body:JSON.stringify(t)}),n=await i.json();if(i.ok||(s.stop("Failed"),h(n.error||n.message,{hint:n.hint,status:i.status,json:e.json,fields:e.fields})),s.stop(`${b.success} Webhook updated`),e.json){k(n,e.fields);return}R("Webhook Updated"),$("ID",n.id),$("URL",w.url(n.url)),$("Events",n.events.join(", ")),$("Status",n.active?he.default.green("active"):he.default.dim("paused")),c()}async function Hl(e){if(e.webhookId||h("Webhook ID required",{hint:"Usage: domani webhooks delete --webhook-id <id>",code:"validation_error",json:e.json,fields:e.fields}),e.dryRun)return z("webhook_delete",{webhook_id:e.webhookId},e.json,e.fields);let t=j(!e.json);t.start("Deleting webhook");let s=await S(`/api/webhooks/${encodeURIComponent(e.webhookId)}`,{method:"DELETE"}),i=await s.json();if(s.ok||(t.stop("Failed"),h(i.error||i.message,{hint:i.hint,status:s.status,json:e.json,fields:e.fields})),t.stop(`${b.success} Webhook deleted`),e.json){k(i,e.fields);return}console.log(` ${he.default.dim("Pending deliveries have been cancelled.")}`),c()}async function Jl(e){e.webhookId||h("Webhook ID required",{hint:"Usage: domani webhooks deliveries --webhook-id <id> [--limit 20]",code:"validation_error",json:e.json,fields:e.fields});let t=e.limit?`?limit=${e.limit}`:"",s=j(!e.json);s.start("Loading deliveries");let i=await S(`/api/webhooks/${encodeURIComponent(e.webhookId)}/deliveries${t}`),n=await i.json();if(i.ok||(s.stop("Failed"),h(n.error||n.message,{hint:n.hint,status:i.status,json:e.json,fields:e.fields})),s.stop(`${b.success} ${n.deliveries.length} delivery(ies)`),e.json){k(n,e.fields);return}if(n.deliveries.length===0){c(),console.log(` ${he.default.dim("No deliveries yet.")}`),c();return}c(),R("Deliveries");let r=n.deliveries.map(o=>{let a=o.status==="delivered"?he.default.green("delivered"):o.status==="failed"?he.default.red("failed"):he.default.yellow("pending");return[o.event_type,a,o.http_status?String(o.http_status):he.default.dim("-"),String(o.attempts),he.default.dim(new Date(o.created_at).toLocaleString())]});me(["Event","Status","HTTP","Tries","Date"],r,[22,12,6,6,22]),c()}async function Bl(e,t){let s=j(!e);s.start("Loading event types");let i=await $e("/api/webhooks/events"),n=await i.json();if(i.ok||(s.stop("Failed"),h(n.error||n.message,{hint:n.hint,status:i.status,json:e,fields:t})),s.stop(`${b.success} ${n.events.length} event type(s)`),e){k(n,t);return}c(),R("Webhook Event Types");let r=n.events.map(o=>[he.default.cyan(o.type),he.default.dim(o.description)]);me(["Event","Description"],r,[24,50]),c()}Q();var ve=U(J(),1);H();be();async function Qr(e,t){if(e||h("Domain is required",{hint:`Usage: domani sell <domain> --price <amount>
197
197
  domani sell <domain> --verify
198
198
  domani sell <domain> --status
199
- domani sell <domain> --cancel`,code:"validation_error",json:t.json,fields:t.fields}),ee(e,t),t.status)return Gl(e,t);if(t.verify)return Bl(e,t);if(t.cancel)return Yl(e,t);if(t.transferCode)return Kl(e,t.transferCode,t);if(t.price)return Jl(e,t);h("No action specified",{hint:`Usage: domani sell <domain> --price <amount>
199
+ domani sell <domain> --cancel`,code:"validation_error",json:t.json,fields:t.fields}),ee(e,t),t.status)return Kl(e,t);if(t.verify)return Yl(e,t);if(t.cancel)return zl(e,t);if(t.transferCode)return Xl(e,t.transferCode,t);if(t.price)return Gl(e,t);h("No action specified",{hint:`Usage: domani sell <domain> --price <amount>
200
200
  domani sell <domain> --verify
201
201
  domani sell <domain> --status
202
202
  domani sell <domain> --cancel
203
- domani sell <domain> --transfer-code <code>`,code:"validation_error",json:t.json,fields:t.fields})}async function Jl(e,t){let i=parseFloat(t.price);(isNaN(i)||i<=0)&&h("Invalid price",{hint:"Price must be a positive number, e.g. --price 5000",code:"validation_error",json:t.json,fields:t.fields});let s=j(!t.json);s.start(`Listing ${w.domain(e)} for sale`);let n={domain:e,price:i};t.description&&(n.description=t.description);let r=await S("/api/domains/sell",{method:"POST",body:JSON.stringify(n)}),o=await r.json();if(r.ok||(s.stop("Listing failed"),h(o.error||o.message,{hint:o.hint,status:r.status,json:t.json,fields:t.fields})),t.json){s.stop(""),k(o,t.fields);return}(o.listing?.status??"pending_verification")==="active"?(s.stop(`${b.success} Listed for sale`),O("Sell Domain"),$("Domain",w.domain(o.listing?.domain||e)),$("Price",w.price(i)),$("Status",be.default.green("active")),d(),console.log(` ${be.default.dim("Your listing is live on the marketplace.")}`),d()):(s.stop(`${b.success} Verification record ready`),O("Sell Domain"),$("Domain",w.domain(o.listing?.domain||e)),$("Price",w.price(i)),$("Status",be.default.yellow("pending verification")),d(),console.log(" Add this TXT record at your DNS provider:"),d(),console.log(` ${be.default.dim("Type:")} ${be.default.bold("TXT")}`),console.log(` ${be.default.dim("Name:")} ${be.default.bold(o.txt_record?.name||"@")}`),console.log(` ${be.default.dim("Value:")} ${be.default.bold(o.txt_record?.value||`domani-verify=${o.token}`)}`),d(),console.log(` ${be.default.dim("DNS propagation may take a few minutes to 48 hours.")}`),d(),A("Once the record is set, verify:",`domani sell ${e} --verify`),d())}async function Bl(e,t){let i=j(!t.json);i.start(`Verifying ownership of ${w.domain(e)}`);let s=await S("/api/domains/sell/verify",{method:"POST",body:JSON.stringify({domain:e})}),n=await s.json();if(s.ok||(i.stop("Verification failed"),h(n.error||n.message,{hint:n.hint,status:s.status,json:t.json,fields:t.fields})),t.json){i.stop(""),k(n,t.fields);return}i.stop(`${b.success} ${w.domain(e)} is now listed for sale!`),O("Domain Listed"),$("Domain",w.domain(n.domain||e)),$("Status",be.default.green(n.status||"active")),n.price&&$("Price",w.price(n.price)),d(),A("Check listing status:",`domani sell ${e} --status`),A("View your deals:","domani deals"),d()}async function Gl(e,t){let i=j(!t.json);i.start(`Checking listing status for ${w.domain(e)}`);let s=await S(`/api/domains/sell/status?domain=${encodeURIComponent(e)}`),n=await s.json();if(s.ok||(i.stop("Failed"),h(n.error||n.message,{hint:n.hint,status:s.status,json:t.json,fields:t.fields})),i.stop(`${b.success} Listing status loaded`),t.json){k(n,t.fields);return}let r=n.listing;if(O("Listing Status"),$("Domain",w.domain(n.domain||e)),r){let o=r.status;$("Status",o==="active"?be.default.green(o):be.default.yellow(o||"unknown")),r.price&&$("Price",w.price(r.price)),r.description&&$("Description",r.description),r.created_at&&$("Listed",be.default.dim(new Date(r.created_at).toLocaleDateString()))}else $("Status",be.default.dim("No listing found"));n.deal&&$("Deal",`${n.deal.status} ($${n.deal.price})`),d()}async function Yl(e,t){let i=j(!t.json);i.start(`Removing ${w.domain(e)} from sale`);let s=await S(`/api/domains/sell?domain=${encodeURIComponent(e)}`,{method:"DELETE"}),n=await s.json();if(s.ok||(i.stop("Failed"),h(n.error||n.message,{hint:n.hint,status:s.status,json:t.json,fields:t.fields})),t.json){i.stop(""),k(n,t.fields);return}i.stop(`${b.success} ${w.domain(e)} removed from sale`),d()}async function Kl(e,t,i){let s=j(!i.json);s.start(`Looking up active deal for ${w.domain(e)}`);let n=await S(`/api/deals?role=seller&domain=${encodeURIComponent(e)}&status=active`),r=await n.json();n.ok||(s.stop("Failed"),h(r.error||r.message,{hint:r.hint,status:n.status,json:i.json,fields:i.fields}));let a=(r.deals||r.data||[]).filter(p=>p.domain.toLowerCase()===e.toLowerCase());a.length===0&&(s.stop("No active deal found"),h(`No active deal found for ${e}`,{hint:`Make sure you have an active sale for this domain.
204
- Run 'domani deals --role seller' to see your deals.`,code:"not_found",json:i.json,fields:i.fields}));let l=a[0].id;s.message(`Submitting transfer code for deal ${be.default.dim(l)}`);let c=await S(`/api/deals/${encodeURIComponent(l)}`,{method:"PATCH",body:JSON.stringify({auth_code:t})}),u=await c.json();if(c.ok||(s.stop("Failed"),h(u.error||u.message,{hint:u.hint,status:c.status,json:i.json,fields:i.fields})),i.json){s.stop(""),k(u,i.fields);return}s.stop(`${b.success} Transfer code submitted for ${w.domain(e)}`),O("Transfer Code Submitted"),$("Domain",w.domain(e)),$("Deal",be.default.dim(l)),$("Status",be.default.green(u.status||"code_submitted")),d(),A("Track the deal:",`domani deals ${l}`),d()}Q();var ve=F(H(),1);J();async function Zr(e,t){return e?Xl(e,t):zl(t)}async function zl(e){let t=j(!e.json);t.start("Loading deals");let i=new URLSearchParams;e.role&&i.set("role",e.role),e.status&&i.set("status",e.status);let s=i.toString()?`?${i.toString()}`:"",n=await S(`/api/deals${s}`),r=await n.json();n.ok||(t.stop("Failed"),h(r.error||r.message,{hint:r.hint,status:n.status,json:e.json,fields:e.fields}));let o=r.deals||r.data||[];if(t.stop(`${b.success} ${o.length} deal(s)`),e.json){k(r,e.fields);return}if(o.length===0){d(),console.log(` ${ve.default.dim("No deals found.")}`),d(),A("List a domain for sale:","domani sell <domain> --price <amount>"),d();return}d(),O("Deals");let a=o.map(l=>{let c=l.status==="completed"?ve.default.green:l.status==="active"?ve.default.cyan:l.status==="cancelled"?ve.default.red:ve.default.yellow;return[w.domain(l.domain),w.price(l.price),c(l.status),ve.default.dim(l.role||"-"),ve.default.dim(new Date(l.created_at).toLocaleDateString())]});ue(["Domain","Price","Status","Role","Created"],a,[28,12,14,10,14]),d()}async function Xl(e,t){let i=j(!t.json);i.start(`Loading deal ${ve.default.dim(e)}`);let s=await S(`/api/deals/${encodeURIComponent(e)}`),n=await s.json();if(s.ok||(i.stop("Failed"),h(n.error||n.message,{hint:n.hint,status:s.status,json:t.json,fields:t.fields})),i.stop(`${b.success} Deal loaded`),t.json){k(n,t.fields);return}let r=n.deal||n;O("Deal Details"),$("ID",ve.default.dim(r.id)),$("Domain",w.domain(r.domain)),$("Price",w.price(r.price));let o=r.status==="completed"?ve.default.green:r.status==="active"?ve.default.cyan:r.status==="cancelled"?ve.default.red:ve.default.yellow;$("Status",o(r.status)),r.role&&$("Your Role",r.role),r.buyer&&$("Buyer",ve.default.dim(r.buyer)),r.seller&&$("Seller",ve.default.dim(r.seller)),r.created_at&&$("Created",ve.default.dim(new Date(r.created_at).toLocaleDateString())),r.updated_at&&$("Updated",ve.default.dim(new Date(r.updated_at).toLocaleDateString())),d();let a=r.events||[];if(a.length>0){O("Timeline");for(let l of a){let c=ve.default.dim(new Date(l.created_at).toLocaleString()),u=l.status==="completed"?b.success:l.status==="expired"||l.status==="refunded"?b.error:b.info;console.log(` ${u} ${c} ${l.detail||l.status}`)}d()}(r.status==="escrow_held"||r.status==="epp_pending")&&r.role==="seller"&&(A("Submit transfer code:",`domani sell ${r.domain} --transfer-code <code>`),d())}Q();var pe=F(H(),1);J();async function eo(e){return e.read?Ql(e):Zl(e)}async function Zl(e){let t=j(!e.json);t.start("Loading notifications");let i=new URLSearchParams;e.unread&&i.set("unread","true"),e.limit&&i.set("limit",e.limit);let s=i.toString()?`?${i.toString()}`:"",n=await S(`/api/notifications${s}`),r=await n.json();n.ok||(t.stop("Failed"),h(r.error||r.message,{hint:r.hint,status:n.status,json:e.json,fields:e.fields}));let o=r.notifications||r.data||[],a=r.unread_count??o.filter(c=>!c.read).length;if(t.stop(`${b.success} ${o.length} notification(s)${a>0?` ${b.dot} ${pe.default.yellow(`${a} unread`)}`:""}`),e.json){k(r,e.fields);return}if(o.length===0){d(),console.log(` ${pe.default.dim("No notifications.")}`),d();return}d(),O("Notifications");let l=o.map(c=>{let u=c.read?pe.default.dim(b.dot):pe.default.cyan(b.info),p=ec(c.type),g=c.read?pe.default.dim(c.title):pe.default.white(c.title),_=c.body?c.read?pe.default.dim(Qr(c.body,40)):pe.default.dim(Qr(c.body,40)):pe.default.dim("-"),y=pe.default.dim(new Date(c.created_at).toLocaleDateString());return[u,p,g,_,y]});ue(["","Type","Title","Body","Date"],l,[3,16,28,42,14]),d(),a>0&&(console.log(` ${pe.default.dim("Mark all as read:")} ${pe.default.cyan("domani notifications --read")}`),d())}async function Ql(e){let t=j(!e.json);t.start("Marking all notifications as read");let i=await S("/api/notifications/read-all",{method:"POST"}),s=await i.json();if(i.ok||(t.stop("Failed"),h(s.error||s.message,{hint:s.hint,status:i.status,json:e.json,fields:e.fields})),e.json){t.stop(""),k(s,e.fields);return}let n=s.count??0;t.stop(`${b.success} ${n} notification(s) marked as read`),d()}function ec(e){let t={deal:pe.default.cyan,sale:pe.default.green,purchase:pe.default.green,transfer:pe.default.yellow,expiry:pe.default.red,security:pe.default.red,billing:pe.default.yellow,email:pe.default.blue},i=e.split(".")[0].split("_")[0];return(t[i]||pe.default.dim)(e)}function Qr(e,t){return e.length<=t?e:e.slice(0,t-1)+"\u2026"}Q();var yt=F(H(),1);J();async function to(e){let t=e.limit?Number(e.limit):20,i=await S(`/api/billing/invoices?limit=${t}`),s=await i.json();if(i.ok||h(s.error||s.message,{hint:s.hint,status:i.status,json:e.json,fields:e.fields}),e.json){k({...s,count:s.invoices.length},e.fields);return}if(s.invoices.length===0){console.log(` ${yt.default.dim("No invoices yet.")}`);return}O(`Invoices (${s.invoices.length})`),d();for(let n of s.invoices){let r=`$${(n.amount_paid/100).toFixed(2)}`,o=new Date(n.created).toLocaleDateString(),a=n.number||n.id;console.log(` ${b.success} ${yt.default.bold(a)} ${yt.default.green(r)} ${yt.default.dim(o)}`),n.description&&console.log(` ${yt.default.dim(n.description)}`),n.hosted_invoice_url&&console.log(` ${yt.default.dim(n.hosted_invoice_url)}`)}d(),s.has_more&&(console.log(` ${yt.default.dim(`Showing ${s.invoices.length} most recent. Use --limit to see more.`)}`),d())}Q();var ei=F(H(),1);J();async function io(e){let t=j(!e?.json);t.start("Setting up billing session");let i=await S("/api/billing/setup",{method:"POST",body:JSON.stringify({mode:"checkout"})}),s=await i.json();if(i.ok||(t.stop("Failed"),h(s.error||s.message,{hint:s.hint,status:i.status,json:e?.json})),s.url||(t.stop("Failed"),h("No checkout URL returned",{hint:"Try again or add a payment method at the dashboard.",json:e?.json})),t.stop("Checkout ready"),e?.json){k({url:s.url});return}d(),console.log(` ${ei.default.dim("Opening browser")} ${b.arrow} ${w.url(s.url)}`),d(),Qe(s.url),console.log(` ${b.info} ${ei.default.dim("Complete payment setup in your browser.")}`),console.log(` ${ei.default.dim(" After setup, you can purchase domains with")} ${ei.default.cyan("domani buy")}`),d()}Q();var sn=F(H(),1);J();async function so(e){let t=j(!e?.json);t.start("Creating upgrade session");let i=await S("/api/billing/subscribe",{method:"POST"}),s=await i.json();if(!i.ok){t.stop("Failed"),s.code==="ALREADY_PRO"?h("You're already on the Pro plan.",{json:e?.json}):h(s.error||s.message,{hint:s.hint,status:i.status,json:e?.json});return}if(t.stop("Ready"),e?.json){k({url:s.url},e?.fields);return}d(),console.log(` ${sn.default.dim("Opening browser")} ${b.arrow} ${w.url(s.url)}`),d(),Qe(s.url),console.log(` ${b.info} ${sn.default.dim("Complete your Pro upgrade in the browser.")}`),d()}Q();var nn=F(H(),1);J();async function no(e){let t=j(!e?.json);t.start("Cancelling subscription");let i=await S("/api/billing/cancel",{method:"POST"}),s=await i.json();if(!i.ok){t.stop("Failed"),s.code==="NOT_PRO"?h("You're not on the Pro plan.",{json:e?.json}):h(s.error||s.message,{hint:s.hint,status:i.status,json:e?.json});return}if(t.stop("Done"),e?.json){k(s,e?.fields);return}d();let n=s.cancel_at?new Date(s.cancel_at).toLocaleDateString():"end of billing period";console.log(` ${b.success} ${nn.default.dim("Subscription cancelled.")} Access continues until ${nn.default.cyan(n)}.`),d()}Q();var Ke=F(H(),1);J();ye();He();async function ro(e,t,i){e||(e=await me()),ee(e,i);let s=[];if(t?.length&&s.push(...t),i.set&&s.push(...i.set.split(",").map(n=>n.trim()).filter(Boolean)),s.length>0||i.reset){await ic(e,s,i);return}await tc(e,i)}async function tc(e,t){let i=j(!t.json);i.start(`Fetching nameservers for ${w.domain(e)}`);let s=await S(`/api/domains/${encodeURIComponent(e)}/nameservers`),n=await s.json();if(s.ok||(i.stop("Failed"),h(n.error||n.message,{hint:n.hint,status:s.status,json:t.json,fields:t.fields})),i.stop(`Nameservers for ${w.domain(e)}`),t.json){k(n,t.fields);return}if(d(),n.nameservers.length===0)console.log(` ${b.warning} ${Ke.default.yellow("No nameservers configured.")}`),console.log(` ${Ke.default.dim("DNS operations (parking, email, connect) will not work.")}`),d(),A("Set default nameservers:",`domani nameservers ${e} --reset`);else{O("Nameservers");for(let r of n.nameservers)console.log(` ${b.success} ${Ke.default.cyan(r)}`);n.default_nameservers&&n.nameservers.length===n.default_nameservers.length&&n.nameservers.every(o=>n.default_nameservers.includes(o))&&(d(),console.log(` ${Ke.default.dim("Using default nameservers.")}`))}n.default_nameservers?.length&&(d(),$("Defaults",n.default_nameservers.map(r=>Ke.default.dim(r)).join(Ke.default.dim(", ")))),d()}async function ic(e,t,i){let s=j(!i.json);if(i.reset){s.start(`Fetching default nameservers for ${w.domain(e)}`);let o=await S(`/api/domains/${encodeURIComponent(e)}/nameservers`),a=await o.json();o.ok||(s.stop("Failed"),h(a.error,{hint:a.hint,status:o.status,json:i.json,fields:i.fields})),a.default_nameservers?.length||(s.stop("No defaults"),h("No default nameservers available for this domain's registrar.",{code:"not_found",json:i.json,fields:i.fields})),t=a.default_nameservers,s.stop(`Using defaults: ${t.map(l=>Ke.default.cyan(l)).join(Ke.default.dim(", "))}`)}if(t.length<2&&h("At least 2 nameservers required.",{hint:"Example: domani nameservers example.com ns1.dns.com ns2.dns.com",code:"validation_error",json:i.json,fields:i.fields}),i.dryRun)return z("nameservers_set",{domain:e,nameservers:t},i.json,i.fields);s.start(`Setting nameservers for ${w.domain(e)}`);let n=await S(`/api/domains/${encodeURIComponent(e)}/nameservers`,{method:"PUT",body:JSON.stringify({nameservers:t})}),r=await n.json();if(n.ok||(s.stop("Failed"),h(r.error||r.message,{hint:r.hint,status:n.status,json:i.json,fields:i.fields})),s.stop(`${b.success} Nameservers updated`),i.json){k(r,i.fields);return}d();for(let o of r.nameservers)console.log(` ${b.success} ${Ke.default.cyan(o)}`);d(),console.log(` ${Ke.default.dim("Changes may take up to 48 hours to propagate.")}`),d(),A("Check propagation:",`domani status ${e}`),d()}var oo=require("crypto"),Li=F(require("fs"),1);pt();var ti=F(H(),1);J();function sc(e,t){let i=e.split(".").map(Number),s=t.split(".").map(Number);for(let n=0;n<3;n++){if((i[n]||0)>(s[n]||0))return 1;if((i[n]||0)<(s[n]||0))return-1}return 0}async function ao(e){let t=j(!e?.json);t.start("Checking for updates");let i=ze();try{let s=await fetch(`${i}/api/cli/version`);s.ok||(t.stop("Failed"),h("Could not check for updates"));let n=await s.json(),r=n.version,o=n.sha256;if(sc(r,_e)<=0){t.stop(`${b.success} Already up to date (v${_e})`),e?.json&&k({current:_e,latest:r,up_to_date:!0});return}if(e?.json){t.stop(""),k({current:_e,latest:r,up_to_date:!1,hint:"Run `domani update` to upgrade."});return}t.stop(`New version available: ${ti.default.cyan(_e)} ${b.arrow} ${ti.default.green(r)}`);let a=j();a.start("Downloading update");let l=`${i}/cli/domani.js`,c=await fetch(l);c.ok||(a.stop("Download failed"),h(`Failed to download from ${l}`));let u=await c.text();o&&(0,oo.createHash)("sha256").update(u).digest("hex")!==o&&(a.stop("Integrity check failed"),h("Downloaded file does not match expected hash - update aborted"));let p=process.argv[1];p||(a.stop("Failed"),h("Could not determine binary path"));let g=Li.default.realpathSync(p),_=g+".tmp";Li.default.writeFileSync(_,u,{mode:493}),Li.default.renameSync(_,g),a.stop(`${b.success} Updated to v${r}`),d(),console.log(` ${ti.default.dim("Restart your terminal or run")} domani --version ${ti.default.dim("to verify")}`),d()}catch(s){h(`Update failed: ${s instanceof Error?s.message:String(s)}`)}}var Vi=F(require("fs"),1),lo=F(require("path"),1),co=F(require("os"),1);Ie();var ii=F(H(),1);J();async function uo(){let e=process.argv[1],t=e?Vi.default.realpathSync(e):null,i=lo.default.join(co.default.homedir(),".domani");if(d(),console.log(` ${ii.default.bold("This will remove:")}`),t&&console.log(` ${b.dot} CLI binary: ${ii.default.dim(t)}`),console.log(` ${b.dot} Config dir: ${ii.default.dim(i)}`),d(),await We({message:"Uninstall domani?"})!==!0){console.log(` ${ii.default.dim("Cancelled.")}`);return}Vi.default.rmSync(i,{recursive:!0,force:!0}),t&&Vi.default.unlinkSync(t),d(),console.log(` ${b.success} domani uninstalled.`),d()}Q();var se=F(H(),1);J();async function fo(e,t){let i=t?.json,s=t?.fields,n=e?`/api/schema?command=${encodeURIComponent(e)}`:"/api/schema",r=j(!i);r.start("Loading schema");let o=await $e(n),a=await o.json();if(o.ok||(r.stop("Failed"),h(a.error||a.message,{hint:a.hint,status:o.status,json:i,fields:s})),r.stop("Schema loaded"),i){k(a,s);return}e?rc(e,a):nc(a.commands)}function nc(e){O("Commands");let t=Object.entries(e).map(([i,s])=>[se.default.bold(se.default.cyan(i)),s.description]);ue(["Command","Description"],t,[20,50]),d(),console.log(` ${se.default.dim("Run")} ${se.default.cyan("domani schema <command>")} ${se.default.dim("for full details")}`),d()}function rc(e,t){if(O(`domani ${e}`),console.log(` ${t.description}`),d(),console.log(` ${w.label("Usage:")} ${se.default.cyan(t.usage)}`),t.arguments&&Object.keys(t.arguments).length>0){d(),console.log(` ${se.default.bold("Arguments")}`);for(let[i,s]of Object.entries(t.arguments)){let n=s.required?se.default.red("*"):"",r=se.default.dim(`(${s.type}${s.variadic?", variadic":""})`);console.log(` ${se.default.cyan(i)}${n} ${r}`),s.description&&console.log(` ${se.default.dim(s.description)}`)}}if(t.options&&Object.keys(t.options).length>0){d(),console.log(` ${se.default.bold("Options")}`);for(let[i,s]of Object.entries(t.options)){let n=s.required?se.default.red("*"):"",r=se.default.dim(`(${s.type})`),o=s.choices?se.default.dim(` [${s.choices.join(", ")}]`):"";console.log(` ${se.default.cyan(`--${i}`)}${n} ${r}${o}`),console.log(` ${se.default.dim(s.description)}`)}}if(t.api)if(d(),console.log(` ${se.default.bold("API")}`),oc(t.api))mo(t.api);else for(let[i,s]of Object.entries(t.api))console.log(` ${se.default.bold(se.default.yellow(i))}`),mo(s,6);t.errors&&t.errors.length>0&&(d(),console.log(` ${se.default.bold("Errors")}`),console.log(` ${t.errors.map(i=>se.default.dim(i)).join(se.default.dim(", "))}`)),d()}function oc(e){return typeof e=="object"&&e!==null&&"method"in e&&"path"in e}function mo(e,t=4){let i=" ".repeat(t);if(console.log(`${i}${se.default.green(e.method)} ${se.default.white(e.path)}`),e.parameters&&Object.keys(e.parameters).length>0)for(let[s,n]of Object.entries(e.parameters)){let r=n.required?se.default.red("*"):"",o=[n.type];n.enum&&o.push(`enum: ${n.enum.join(", ")}`),n.minimum!==void 0&&o.push(`min: ${n.minimum}`),n.maximum!==void 0&&o.push(`max: ${n.maximum}`),n.maxItems!==void 0&&o.push(`maxItems: ${n.maxItems}`),n.items&&o.push(`items: ${n.items}`),n.in==="path"&&o.push("in: path");let a=se.default.dim(`(${o.join(", ")})`);console.log(`${i} ${se.default.cyan(s)}${r} ${a}`),n.description&&console.log(`${i} ${se.default.dim(n.description)}`)}}Q();var De=F(H(),1);Ie();J();async function po(e){let t=j(!e.json);t.start("Loading payment method");let i=await S("/api/me"),s=await i.json();if(i.ok||(t.stop("Failed"),h(s.error||s.message,{hint:s.hint,status:i.status,json:e.json,fields:e.fields})),e.json){t.stop(""),k(s.card?{has_payment_method:s.has_payment_method,card:s.card}:{has_payment_method:!1},e.fields);return}if(!s.has_payment_method||!s.card){t.stop("No payment method on file"),d(),console.log(` ${De.default.dim("Add a card with")} ${De.default.cyan("domani card add")}`),d();return}let{brand:n,last4:r,exp_month:o,exp_year:a}=s.card,l=`${String(o).padStart(2,"0")}/${a}`,c=n.charAt(0).toUpperCase()+n.slice(1);t.stop("Payment method loaded"),O("Payment method"),$("Card",`${De.default.bold(c)} \u2022\u2022\u2022\u2022 ${De.default.bold(r)}`),$("Expires",l),d(),console.log(` ${De.default.dim("Update with")} ${De.default.cyan("domani card add")}`),d()}async function ho(e){let t=j(!e?.json);t.start("Setting up payment session");let i=await S("/api/billing/setup",{method:"POST",body:JSON.stringify({mode:"checkout"})}),s=await i.json();if(i.ok||(t.stop("Failed"),h(s.error||s.message,{hint:s.hint,status:i.status,json:e?.json})),s.url||(t.stop("Failed"),h("No checkout URL returned",{json:e?.json})),t.stop("Checkout ready"),e?.json){k({url:s.url},e?.fields);return}d(),console.log(` ${De.default.dim("Opening browser")} ${b.arrow} ${w.url(s.url)}`),d(),Qe(s.url),console.log(` ${b.info} ${De.default.dim("Complete payment setup in your browser.")}`),console.log(` ${De.default.dim(" After setup, you can purchase domains with")} ${De.default.cyan("domani buy")}`),d()}async function go(e){if(!e?.yes&&!e?.json){let n=await We({message:"Remove your saved payment method?"});if(oe(n)||!n){console.log(` ${De.default.dim("Cancelled.")}`);return}}let t=j(!e?.json);t.start("Removing payment method");let i=await S("/api/billing/card",{method:"DELETE"}),s=await i.json();if(i.ok||(t.stop("Failed"),h(s.error||s.message,{hint:s.hint,status:i.status,json:e?.json})),t.stop(`${b.success} Payment method removed`),e?.json){k({removed:!0},e?.fields);return}d(),console.log(` ${De.default.dim("Add a new card with")} ${De.default.cyan("domani card add")}`),d()}var B=new yn;B.name("domani").description(`Domain names for developers and AI agents - ${Et}`).version(_e).option("--api-url <url>","Override API base URL").configureOutput({outputError:(e,t)=>{let i=e.replace(/^error:\s*/i,"").trimEnd();if(t(`${it.default.red("\u2717")} ${i}
205
- `),/unknown option|missing required|expected argument/i.test(i)){let s=process.argv[2],n=s&&!s.startsWith("-")?`domani ${s} --help`:"domani --help";t(`${it.default.dim(` Run \`${n}\` to see available options.`)}
206
- `)}}}).hook("preAction",(e,t)=>{let i=e.opts();i.apiUrl&&xn(i.apiUrl),process.stdout.isTTY||t.options.some(n=>n.long==="--json")&&t.setOptionValue("json",!0)});B.command("login").description(`Log in to ${Et} (opens browser)`).option("--json","Output as JSON (returns auth_url for non-interactive approval)").option("--no-open","Don't open browser (print URL instead)").addHelpText("after",`
203
+ domani sell <domain> --transfer-code <code>`,code:"validation_error",json:t.json,fields:t.fields})}async function Gl(e,t){let s=parseFloat(t.price);(isNaN(s)||s<=0)&&h("Invalid price",{hint:"Price must be a positive number, e.g. --price 5000",code:"validation_error",json:t.json,fields:t.fields});let i=j(!t.json);i.start(`Listing ${w.domain(e)} for sale`);let n={domain:e,price:s};t.description&&(n.description=t.description);let r=await S("/api/domains/sell",{method:"POST",body:JSON.stringify(n)}),o=await r.json();if(r.ok||(i.stop("Listing failed"),h(o.error||o.message,{hint:o.hint,status:r.status,json:t.json,fields:t.fields})),t.json){i.stop(""),k(o,t.fields);return}(o.listing?.status??"pending_verification")==="active"?(i.stop(`${b.success} Listed for sale`),R("Sell Domain"),$("Domain",w.domain(o.listing?.domain||e)),$("Price",w.price(s)),$("Status",ve.default.green("active")),c(),console.log(` ${ve.default.dim("Your listing is live on the marketplace.")}`),c()):(i.stop(`${b.success} Verification record ready`),R("Sell Domain"),$("Domain",w.domain(o.listing?.domain||e)),$("Price",w.price(s)),$("Status",ve.default.yellow("pending verification")),c(),console.log(" Add this TXT record at your DNS provider:"),c(),console.log(` ${ve.default.dim("Type:")} ${ve.default.bold("TXT")}`),console.log(` ${ve.default.dim("Name:")} ${ve.default.bold(o.txt_record?.name||"@")}`),console.log(` ${ve.default.dim("Value:")} ${ve.default.bold(o.txt_record?.value||`domani-verify=${o.token}`)}`),c(),console.log(` ${ve.default.dim("DNS propagation may take a few minutes to 48 hours.")}`),c(),O("Once the record is set, verify:",`domani sell ${e} --verify`),c())}async function Yl(e,t){let s=j(!t.json);s.start(`Verifying ownership of ${w.domain(e)}`);let i=await S("/api/domains/sell/verify",{method:"POST",body:JSON.stringify({domain:e})}),n=await i.json();if(i.ok||(s.stop("Verification failed"),h(n.error||n.message,{hint:n.hint,status:i.status,json:t.json,fields:t.fields})),t.json){s.stop(""),k(n,t.fields);return}s.stop(`${b.success} ${w.domain(e)} is now listed for sale!`),R("Domain Listed"),$("Domain",w.domain(n.domain||e)),$("Status",ve.default.green(n.status||"active")),n.price&&$("Price",w.price(n.price)),c(),O("Check listing status:",`domani sell ${e} --status`),O("View your deals:","domani deals"),c()}async function Kl(e,t){let s=j(!t.json);s.start(`Checking listing status for ${w.domain(e)}`);let i=await S(`/api/domains/sell/status?domain=${encodeURIComponent(e)}`),n=await i.json();if(i.ok||(s.stop("Failed"),h(n.error||n.message,{hint:n.hint,status:i.status,json:t.json,fields:t.fields})),s.stop(`${b.success} Listing status loaded`),t.json){k(n,t.fields);return}let r=n.listing;if(R("Listing Status"),$("Domain",w.domain(n.domain||e)),r){let o=r.status;$("Status",o==="active"?ve.default.green(o):ve.default.yellow(o||"unknown")),r.price&&$("Price",w.price(r.price)),r.description&&$("Description",r.description),r.created_at&&$("Listed",ve.default.dim(new Date(r.created_at).toLocaleDateString()))}else $("Status",ve.default.dim("No listing found"));n.deal&&$("Deal",`${n.deal.status} ($${n.deal.price})`),c()}async function zl(e,t){let s=j(!t.json);s.start(`Removing ${w.domain(e)} from sale`);let i=await S(`/api/domains/sell?domain=${encodeURIComponent(e)}`,{method:"DELETE"}),n=await i.json();if(i.ok||(s.stop("Failed"),h(n.error||n.message,{hint:n.hint,status:i.status,json:t.json,fields:t.fields})),t.json){s.stop(""),k(n,t.fields);return}s.stop(`${b.success} ${w.domain(e)} removed from sale`),c()}async function Xl(e,t,s){let i=j(!s.json);i.start(`Looking up active deal for ${w.domain(e)}`);let n=await S(`/api/deals?role=seller&domain=${encodeURIComponent(e)}&status=active`),r=await n.json();n.ok||(i.stop("Failed"),h(r.error||r.message,{hint:r.hint,status:n.status,json:s.json,fields:s.fields}));let a=(r.deals||r.data||[]).filter(p=>p.domain.toLowerCase()===e.toLowerCase());a.length===0&&(i.stop("No active deal found"),h(`No active deal found for ${e}`,{hint:`Make sure you have an active sale for this domain.
204
+ Run 'domani deals --role seller' to see your deals.`,code:"not_found",json:s.json,fields:s.fields}));let l=a[0].id;i.message(`Submitting transfer code for deal ${ve.default.dim(l)}`);let d=await S(`/api/deals/${encodeURIComponent(l)}`,{method:"PATCH",body:JSON.stringify({auth_code:t})}),u=await d.json();if(d.ok||(i.stop("Failed"),h(u.error||u.message,{hint:u.hint,status:d.status,json:s.json,fields:s.fields})),s.json){i.stop(""),k(u,s.fields);return}i.stop(`${b.success} Transfer code submitted for ${w.domain(e)}`),R("Transfer Code Submitted"),$("Domain",w.domain(e)),$("Deal",ve.default.dim(l)),$("Status",ve.default.green(u.status||"code_submitted")),c(),O("Track the deal:",`domani deals ${l}`),c()}Q();var we=U(J(),1);H();async function eo(e,t){return e?Ql(e,t):Zl(t)}async function Zl(e){let t=j(!e.json);t.start("Loading deals");let s=new URLSearchParams;e.role&&s.set("role",e.role),e.status&&s.set("status",e.status);let i=s.toString()?`?${s.toString()}`:"",n=await S(`/api/deals${i}`),r=await n.json();n.ok||(t.stop("Failed"),h(r.error||r.message,{hint:r.hint,status:n.status,json:e.json,fields:e.fields}));let o=r.deals||r.data||[];if(t.stop(`${b.success} ${o.length} deal(s)`),e.json){k(r,e.fields);return}if(o.length===0){c(),console.log(` ${we.default.dim("No deals found.")}`),c(),O("List a domain for sale:","domani sell <domain> --price <amount>"),c();return}c(),R("Deals");let a=o.map(l=>{let d=l.status==="completed"?we.default.green:l.status==="active"?we.default.cyan:l.status==="cancelled"?we.default.red:we.default.yellow;return[w.domain(l.domain),w.price(l.price),d(l.status),we.default.dim(l.role||"-"),we.default.dim(new Date(l.created_at).toLocaleDateString())]});me(["Domain","Price","Status","Role","Created"],a,[28,12,14,10,14]),c()}async function Ql(e,t){let s=j(!t.json);s.start(`Loading deal ${we.default.dim(e)}`);let i=await S(`/api/deals/${encodeURIComponent(e)}`),n=await i.json();if(i.ok||(s.stop("Failed"),h(n.error||n.message,{hint:n.hint,status:i.status,json:t.json,fields:t.fields})),s.stop(`${b.success} Deal loaded`),t.json){k(n,t.fields);return}let r=n.deal||n;R("Deal Details"),$("ID",we.default.dim(r.id)),$("Domain",w.domain(r.domain)),$("Price",w.price(r.price));let o=r.status==="completed"?we.default.green:r.status==="active"?we.default.cyan:r.status==="cancelled"?we.default.red:we.default.yellow;$("Status",o(r.status)),r.role&&$("Your Role",r.role),r.buyer&&$("Buyer",we.default.dim(r.buyer)),r.seller&&$("Seller",we.default.dim(r.seller)),r.created_at&&$("Created",we.default.dim(new Date(r.created_at).toLocaleDateString())),r.updated_at&&$("Updated",we.default.dim(new Date(r.updated_at).toLocaleDateString())),c();let a=r.events||[];if(a.length>0){R("Timeline");for(let l of a){let d=we.default.dim(new Date(l.created_at).toLocaleString()),u=l.status==="completed"?b.success:l.status==="expired"||l.status==="refunded"?b.error:b.info;console.log(` ${u} ${d} ${l.detail||l.status}`)}c()}(r.status==="escrow_held"||r.status==="epp_pending")&&r.role==="seller"&&(O("Submit transfer code:",`domani sell ${r.domain} --transfer-code <code>`),c())}Q();var pe=U(J(),1);H();async function so(e){return e.read?tc(e):ec(e)}async function ec(e){let t=j(!e.json);t.start("Loading notifications");let s=new URLSearchParams;e.unread&&s.set("unread","true"),e.limit&&s.set("limit",e.limit);let i=s.toString()?`?${s.toString()}`:"",n=await S(`/api/notifications${i}`),r=await n.json();n.ok||(t.stop("Failed"),h(r.error||r.message,{hint:r.hint,status:n.status,json:e.json,fields:e.fields}));let o=r.notifications||r.data||[],a=r.unread_count??o.filter(d=>!d.read).length;if(t.stop(`${b.success} ${o.length} notification(s)${a>0?` ${b.dot} ${pe.default.yellow(`${a} unread`)}`:""}`),e.json){k(r,e.fields);return}if(o.length===0){c(),console.log(` ${pe.default.dim("No notifications.")}`),c();return}c(),R("Notifications");let l=o.map(d=>{let u=d.read?pe.default.dim(b.dot):pe.default.cyan(b.info),p=sc(d.type),g=d.read?pe.default.dim(d.title):pe.default.white(d.title),x=d.body?d.read?pe.default.dim(to(d.body,40)):pe.default.dim(to(d.body,40)):pe.default.dim("-"),y=pe.default.dim(new Date(d.created_at).toLocaleDateString());return[u,p,g,x,y]});me(["","Type","Title","Body","Date"],l,[3,16,28,42,14]),c(),a>0&&(console.log(` ${pe.default.dim("Mark all as read:")} ${pe.default.cyan("domani notifications --read")}`),c())}async function tc(e){let t=j(!e.json);t.start("Marking all notifications as read");let s=await S("/api/notifications/read-all",{method:"POST"}),i=await s.json();if(s.ok||(t.stop("Failed"),h(i.error||i.message,{hint:i.hint,status:s.status,json:e.json,fields:e.fields})),e.json){t.stop(""),k(i,e.fields);return}let n=i.count??0;t.stop(`${b.success} ${n} notification(s) marked as read`),c()}function sc(e){let t={deal:pe.default.cyan,sale:pe.default.green,purchase:pe.default.green,transfer:pe.default.yellow,expiry:pe.default.red,security:pe.default.red,billing:pe.default.yellow,email:pe.default.blue},s=e.split(".")[0].split("_")[0];return(t[s]||pe.default.dim)(e)}function to(e,t){return e.length<=t?e:e.slice(0,t-1)+"\u2026"}Q();var bt=U(J(),1);H();async function io(e){let t=e.limit?Number(e.limit):20,s=await S(`/api/billing/invoices?limit=${t}`),i=await s.json();if(s.ok||h(i.error||i.message,{hint:i.hint,status:s.status,json:e.json,fields:e.fields}),e.json){k({...i,count:i.invoices.length},e.fields);return}if(i.invoices.length===0){console.log(` ${bt.default.dim("No invoices yet.")}`);return}R(`Invoices (${i.invoices.length})`),c();for(let n of i.invoices){let r=`$${(n.amount_paid/100).toFixed(2)}`,o=new Date(n.created).toLocaleDateString(),a=n.number||n.id;console.log(` ${b.success} ${bt.default.bold(a)} ${bt.default.green(r)} ${bt.default.dim(o)}`),n.description&&console.log(` ${bt.default.dim(n.description)}`),n.hosted_invoice_url&&console.log(` ${bt.default.dim(n.hosted_invoice_url)}`)}c(),i.has_more&&(console.log(` ${bt.default.dim(`Showing ${i.invoices.length} most recent. Use --limit to see more.`)}`),c())}Q();var ts=U(J(),1);H();async function no(e){let t=j(!e?.json);t.start("Setting up billing session");let s=await S("/api/billing/setup",{method:"POST",body:JSON.stringify({mode:"checkout"})}),i=await s.json();if(s.ok||(t.stop("Failed"),h(i.error||i.message,{hint:i.hint,status:s.status,json:e?.json})),i.url||(t.stop("Failed"),h("No checkout URL returned",{hint:"Try again or add a payment method at the dashboard.",json:e?.json})),t.stop("Checkout ready"),e?.json){k({url:i.url});return}c(),console.log(` ${ts.default.dim("Opening browser")} ${b.arrow} ${w.url(i.url)}`),c(),ze(i.url),console.log(` ${b.info} ${ts.default.dim("Complete payment setup in your browser.")}`),console.log(` ${ts.default.dim(" After setup, you can purchase domains with")} ${ts.default.cyan("domani buy")}`),c()}Q();var on=U(J(),1);H();async function ro(e){let t=j(!e?.json);t.start("Creating upgrade session");let s=await S("/api/billing/subscribe",{method:"POST"}),i=await s.json();if(!s.ok){t.stop("Failed"),i.code==="ALREADY_PRO"?h("You're already on the Pro plan.",{json:e?.json}):h(i.error||i.message,{hint:i.hint,status:s.status,json:e?.json});return}if(t.stop("Ready"),e?.json){k({url:i.url},e?.fields);return}c(),console.log(` ${on.default.dim("Opening browser")} ${b.arrow} ${w.url(i.url)}`),c(),ze(i.url),console.log(` ${b.info} ${on.default.dim("Complete your Pro upgrade in the browser.")}`),c()}Q();var an=U(J(),1);H();async function oo(e){let t=j(!e?.json);t.start("Cancelling subscription");let s=await S("/api/billing/cancel",{method:"POST"}),i=await s.json();if(!s.ok){t.stop("Failed"),i.code==="NOT_PRO"?h("You're not on the Pro plan.",{json:e?.json}):h(i.error||i.message,{hint:i.hint,status:s.status,json:e?.json});return}if(t.stop("Done"),e?.json){k(i,e?.fields);return}c();let n=i.cancel_at?new Date(i.cancel_at).toLocaleDateString():"end of billing period";console.log(` ${b.success} ${an.default.dim("Subscription cancelled.")} Access continues until ${an.default.cyan(n)}.`),c()}Q();var Ze=U(J(),1);H();be();Je();async function ao(e,t,s){e||(e=await ue()),ee(e,s);let i=[];if(t?.length&&i.push(...t),s.set&&i.push(...s.set.split(",").map(n=>n.trim()).filter(Boolean)),i.length>0||s.reset){await nc(e,i,s);return}await ic(e,s)}async function ic(e,t){let s=j(!t.json);s.start(`Fetching nameservers for ${w.domain(e)}`);let i=await S(`/api/domains/${encodeURIComponent(e)}/nameservers`),n=await i.json();if(i.ok||(s.stop("Failed"),h(n.error||n.message,{hint:n.hint,status:i.status,json:t.json,fields:t.fields})),s.stop(`Nameservers for ${w.domain(e)}`),t.json){k(n,t.fields);return}if(c(),n.nameservers.length===0)console.log(` ${b.warning} ${Ze.default.yellow("No nameservers configured.")}`),console.log(` ${Ze.default.dim("DNS operations (parking, email, connect) will not work.")}`),c(),O("Set default nameservers:",`domani nameservers ${e} --reset`);else{R("Nameservers");for(let r of n.nameservers)console.log(` ${b.success} ${Ze.default.cyan(r)}`);n.default_nameservers&&n.nameservers.length===n.default_nameservers.length&&n.nameservers.every(o=>n.default_nameservers.includes(o))&&(c(),console.log(` ${Ze.default.dim("Using default nameservers.")}`))}n.default_nameservers?.length&&(c(),$("Defaults",n.default_nameservers.map(r=>Ze.default.dim(r)).join(Ze.default.dim(", ")))),c()}async function nc(e,t,s){let i=j(!s.json);if(s.reset){i.start(`Fetching default nameservers for ${w.domain(e)}`);let o=await S(`/api/domains/${encodeURIComponent(e)}/nameservers`),a=await o.json();o.ok||(i.stop("Failed"),h(a.error,{hint:a.hint,status:o.status,json:s.json,fields:s.fields})),a.default_nameservers?.length||(i.stop("No defaults"),h("No default nameservers available for this domain's registrar.",{code:"not_found",json:s.json,fields:s.fields})),t=a.default_nameservers,i.stop(`Using defaults: ${t.map(l=>Ze.default.cyan(l)).join(Ze.default.dim(", "))}`)}if(t.length<2&&h("At least 2 nameservers required.",{hint:"Example: domani nameservers example.com ns1.dns.com ns2.dns.com",code:"validation_error",json:s.json,fields:s.fields}),s.dryRun)return z("nameservers_set",{domain:e,nameservers:t},s.json,s.fields);i.start(`Setting nameservers for ${w.domain(e)}`);let n=await S(`/api/domains/${encodeURIComponent(e)}/nameservers`,{method:"PUT",body:JSON.stringify({nameservers:t})}),r=await n.json();if(n.ok||(i.stop("Failed"),h(r.error||r.message,{hint:r.hint,status:n.status,json:s.json,fields:s.fields})),i.stop(`${b.success} Nameservers updated`),s.json){k(r,s.fields);return}c();for(let o of r.nameservers)console.log(` ${b.success} ${Ze.default.cyan(o)}`);c(),console.log(` ${Ze.default.dim("Changes may take up to 48 hours to propagate.")}`),c(),O("Check propagation:",`domani status ${e}`),c()}var lo=require("crypto"),Ls=U(require("fs"),1);ht();var ss=U(J(),1);H();function rc(e,t){let s=e.split(".").map(Number),i=t.split(".").map(Number);for(let n=0;n<3;n++){if((s[n]||0)>(i[n]||0))return 1;if((s[n]||0)<(i[n]||0))return-1}return 0}async function co(e){let t=j(!e?.json);t.start("Checking for updates");let s=Ge();try{let i=await fetch(`${s}/api/cli/version`);i.ok||(t.stop("Failed"),h("Could not check for updates"));let n=await i.json(),r=n.version,o=n.sha256;if(rc(r,xe)<=0){t.stop(`${b.success} Already up to date (v${xe})`),e?.json&&k({current:xe,latest:r,up_to_date:!0});return}if(e?.json){t.stop(""),k({current:xe,latest:r,up_to_date:!1,hint:"Run `domani update` to upgrade."});return}t.stop(`New version available: ${ss.default.cyan(xe)} ${b.arrow} ${ss.default.green(r)}`);let a=j();a.start("Downloading update");let l=`${s}/cli/domani.js`,d=await fetch(l);d.ok||(a.stop("Download failed"),h(`Failed to download from ${l}`));let u=await d.text();o&&(0,lo.createHash)("sha256").update(u).digest("hex")!==o&&(a.stop("Integrity check failed"),h("Downloaded file does not match expected hash - update aborted"));let p=process.argv[1];p||(a.stop("Failed"),h("Could not determine binary path"));let g=Ls.default.realpathSync(p),x=g+".tmp";Ls.default.writeFileSync(x,u,{mode:493}),Ls.default.renameSync(x,g),a.stop(`${b.success} Updated to v${r}`),c(),console.log(` ${ss.default.dim("Restart your terminal or run")} domani --version ${ss.default.dim("to verify")}`),c()}catch(i){h(`Update failed: ${i instanceof Error?i.message:String(i)}`)}}var Us=U(require("fs"),1),uo=U(require("path"),1),mo=U(require("os"),1);Te();var is=U(J(),1);H();async function fo(){let e=process.argv[1],t=e?Us.default.realpathSync(e):null,s=uo.default.join(mo.default.homedir(),".domani");if(c(),console.log(` ${is.default.bold("This will remove:")}`),t&&console.log(` ${b.dot} CLI binary: ${is.default.dim(t)}`),console.log(` ${b.dot} Config dir: ${is.default.dim(s)}`),c(),await He({message:"Uninstall domani?"})!==!0){console.log(` ${is.default.dim("Cancelled.")}`);return}Us.default.rmSync(s,{recursive:!0,force:!0}),t&&Us.default.unlinkSync(t),c(),console.log(` ${b.success} domani uninstalled.`),c()}Q();var ie=U(J(),1);H();async function ho(e,t){let s=t?.json,i=t?.fields,n=e?`/api/schema?command=${encodeURIComponent(e)}`:"/api/schema",r=j(!s);r.start("Loading schema");let o=await $e(n),a=await o.json();if(o.ok||(r.stop("Failed"),h(a.error||a.message,{hint:a.hint,status:o.status,json:s,fields:i})),r.stop("Schema loaded"),s){k(a,i);return}e?ac(e,a):oc(a.commands)}function oc(e){R("Commands");let t=Object.entries(e).map(([s,i])=>[ie.default.bold(ie.default.cyan(s)),i.description]);me(["Command","Description"],t,[20,50]),c(),console.log(` ${ie.default.dim("Run")} ${ie.default.cyan("domani schema <command>")} ${ie.default.dim("for full details")}`),c()}function ac(e,t){if(R(`domani ${e}`),console.log(` ${t.description}`),c(),console.log(` ${w.label("Usage:")} ${ie.default.cyan(t.usage)}`),t.arguments&&Object.keys(t.arguments).length>0){c(),console.log(` ${ie.default.bold("Arguments")}`);for(let[s,i]of Object.entries(t.arguments)){let n=i.required?ie.default.red("*"):"",r=ie.default.dim(`(${i.type}${i.variadic?", variadic":""})`);console.log(` ${ie.default.cyan(s)}${n} ${r}`),i.description&&console.log(` ${ie.default.dim(i.description)}`)}}if(t.options&&Object.keys(t.options).length>0){c(),console.log(` ${ie.default.bold("Options")}`);for(let[s,i]of Object.entries(t.options)){let n=i.required?ie.default.red("*"):"",r=ie.default.dim(`(${i.type})`),o=i.choices?ie.default.dim(` [${i.choices.join(", ")}]`):"";console.log(` ${ie.default.cyan(`--${s}`)}${n} ${r}${o}`),console.log(` ${ie.default.dim(i.description)}`)}}if(t.api)if(c(),console.log(` ${ie.default.bold("API")}`),lc(t.api))po(t.api);else for(let[s,i]of Object.entries(t.api))console.log(` ${ie.default.bold(ie.default.yellow(s))}`),po(i,6);t.errors&&t.errors.length>0&&(c(),console.log(` ${ie.default.bold("Errors")}`),console.log(` ${t.errors.map(s=>ie.default.dim(s)).join(ie.default.dim(", "))}`)),c()}function lc(e){return typeof e=="object"&&e!==null&&"method"in e&&"path"in e}function po(e,t=4){let s=" ".repeat(t);if(console.log(`${s}${ie.default.green(e.method)} ${ie.default.white(e.path)}`),e.parameters&&Object.keys(e.parameters).length>0)for(let[i,n]of Object.entries(e.parameters)){let r=n.required?ie.default.red("*"):"",o=[n.type];n.enum&&o.push(`enum: ${n.enum.join(", ")}`),n.minimum!==void 0&&o.push(`min: ${n.minimum}`),n.maximum!==void 0&&o.push(`max: ${n.maximum}`),n.maxItems!==void 0&&o.push(`maxItems: ${n.maxItems}`),n.items&&o.push(`items: ${n.items}`),n.in==="path"&&o.push("in: path");let a=ie.default.dim(`(${o.join(", ")})`);console.log(`${s} ${ie.default.cyan(i)}${r} ${a}`),n.description&&console.log(`${s} ${ie.default.dim(n.description)}`)}}Q();var Ne=U(J(),1);Te();H();async function go(e){let t=j(!e.json);t.start("Loading payment method");let s=await S("/api/me"),i=await s.json();if(s.ok||(t.stop("Failed"),h(i.error||i.message,{hint:i.hint,status:s.status,json:e.json,fields:e.fields})),e.json){t.stop(""),k(i.card?{has_payment_method:i.has_payment_method,card:i.card}:{has_payment_method:!1},e.fields);return}if(!i.has_payment_method||!i.card){t.stop("No payment method on file"),c(),console.log(` ${Ne.default.dim("Add a card with")} ${Ne.default.cyan("domani card add")}`),c();return}let{brand:n,last4:r,exp_month:o,exp_year:a}=i.card,l=`${String(o).padStart(2,"0")}/${a}`,d=n.charAt(0).toUpperCase()+n.slice(1);t.stop("Payment method loaded"),R("Payment method"),$("Card",`${Ne.default.bold(d)} \u2022\u2022\u2022\u2022 ${Ne.default.bold(r)}`),$("Expires",l),c(),console.log(` ${Ne.default.dim("Update with")} ${Ne.default.cyan("domani card add")}`),c()}async function $o(e){let t=j(!e?.json);t.start("Setting up payment session");let s=await S("/api/billing/setup",{method:"POST",body:JSON.stringify({mode:"checkout"})}),i=await s.json();if(s.ok||(t.stop("Failed"),h(i.error||i.message,{hint:i.hint,status:s.status,json:e?.json})),i.url||(t.stop("Failed"),h("No checkout URL returned",{json:e?.json})),t.stop("Checkout ready"),e?.json){k({url:i.url},e?.fields);return}c(),console.log(` ${Ne.default.dim("Opening browser")} ${b.arrow} ${w.url(i.url)}`),c(),ze(i.url),console.log(` ${b.info} ${Ne.default.dim("Complete payment setup in your browser.")}`),console.log(` ${Ne.default.dim(" After setup, you can purchase domains with")} ${Ne.default.cyan("domani buy")}`),c()}async function yo(e){if(!e?.yes&&!e?.json){let n=await He({message:"Remove your saved payment method?"});if(oe(n)||!n){console.log(` ${Ne.default.dim("Cancelled.")}`);return}}let t=j(!e?.json);t.start("Removing payment method");let s=await S("/api/billing/card",{method:"DELETE"}),i=await s.json();if(s.ok||(t.stop("Failed"),h(i.error||i.message,{hint:i.hint,status:s.status,json:e?.json})),t.stop(`${b.success} Payment method removed`),e?.json){k({removed:!0},e?.fields);return}c(),console.log(` ${Ne.default.dim("Add a new card with")} ${Ne.default.cyan("domani card add")}`),c()}process.stdin.setMaxListeners(50);var B=new wn;B.name("domani").description(`Domain names for developers and AI agents - ${Tt}`).version(xe).option("--api-url <url>","Override API base URL").configureOutput({outputError:(e,t)=>{let s=e.replace(/^error:\s*/i,"").trimEnd();if(t(`${st.default.red("\u2717")} ${s}
205
+ `),/unknown option|missing required|expected argument/i.test(s)){let i=process.argv[2],n=i&&!i.startsWith("-")?`domani ${i} --help`:"domani --help";t(`${st.default.dim(` Run \`${n}\` to see available options.`)}
206
+ `)}}}).hook("preAction",async(e,t)=>{let s=e.opts();s.apiUrl&&Sn(s.apiUrl),process.stdout.isTTY||t.options.some(r=>r.long==="--json")&&t.setOptionValue("json",!0),["login","logout","search","suggest","tlds","whois","schema","update","uninstall"].includes(t.name())||await pr()});B.command("login").description(`Log in to ${Tt} (opens browser)`).option("--json","Output as JSON (returns auth_url for non-interactive approval)").option("--no-open","Don't open browser (print URL instead)").addHelpText("after",`
207
207
  Examples:
208
208
  domani login # interactive login (opens browser)
209
209
  domani login --json # non-interactive (returns auth_url)
210
210
  domani login --no-open # print login URL without opening browser
211
- DOMANI_API_KEY=domani_sk_xxx domani list # skip login, use env var`).action(ur);B.command("logout").description("Clear saved credentials").option("--yes","Skip confirmation").option("--json","Output as JSON").action(mr);B.command("me").description("Show account info").option("--json","Output as JSON").option("--fields <fields>","Filter JSON output fields (comma-separated)").addHelpText("after",`
211
+ DOMANI_API_KEY=domani_sk_xxx domani list # skip login, use env var`).action(hr);B.command("logout").description("Clear saved credentials").option("--yes","Skip confirmation").option("--json","Output as JSON").action(gr);B.command("me").description("Show account info").option("--json","Output as JSON").option("--fields <fields>","Filter JSON output fields (comma-separated)").addHelpText("after",`
212
212
  Examples:
213
213
  domani me # show account overview
214
214
  domani me --json # machine-readable account info
215
- domani me --json --fields email,plan # just email and plan`).action(gr);B.command("invoices").description("List payment invoices").option("--json","Output as JSON").option("--fields <fields>","Filter JSON output fields (comma-separated)").option("--limit <n>","Max invoices to show (default 20)").action(to);B.command("card [action]").description("Manage payment methods (list, add, remove)").option("--json","Output as JSON").option("--fields <fields>","Filter JSON output fields (comma-separated)").option("--yes","Skip confirmation prompt (for remove)").action(async(e,t)=>{if(!e||e==="list")return po(t);if(e==="add")return ho(t);if(e==="remove")return go(t);fail(`Unknown action: ${e}`,{hint:"Use: domani card list, domani card add, or domani card remove"})});B.command("upgrade").description("Upgrade to Pro \u2014 10,000 emails/month, unlimited mailboxes, API/MCP/CLI access").option("--json","Output as JSON (returns checkout URL)").action(so);B.command("cancel").description("Cancel Pro subscription (access continues until end of billing period)").option("--json","Output as JSON").action(no);B.command("billing",{hidden:!0}).option("--json","Output as JSON (returns checkout URL)").action(io);B.command("token").description("Print your API key").option("--json","Output as JSON").action(Ur);B.command("tokens [action]").description("Manage API tokens (list/create/revoke)").option("--name <name>","Token name (for create)").option("--scopes <scopes>","Comma-separated permission scopes (for create)").option("--expires-in <seconds>","Token lifetime in seconds (for create, min 3600)").option("--token-id <id>","Token ID (for revoke)").option("--json","Output as JSON").option("--fields <fields>","Filter JSON output fields (comma-separated)").addHelpText("after",`
215
+ domani me --json --fields email,plan # just email and plan`).action(yr);B.command("invoices").description("List payment invoices").option("--json","Output as JSON").option("--fields <fields>","Filter JSON output fields (comma-separated)").option("--limit <n>","Max invoices to show (default 20)").action(io);B.command("card [action]").description("Manage payment methods (list, add, remove)").option("--json","Output as JSON").option("--fields <fields>","Filter JSON output fields (comma-separated)").option("--yes","Skip confirmation prompt (for remove)").action(async(e,t)=>{if(!e||e==="list")return go(t);if(e==="add")return $o(t);if(e==="remove")return yo(t);h(`Unknown action: ${e}`,{hint:"Use: domani card list, domani card add, or domani card remove"})});B.command("upgrade").description("Upgrade to Pro \u2014 10,000 emails/month, unlimited mailboxes, API/MCP/CLI access").option("--json","Output as JSON (returns checkout URL)").action(ro);B.command("cancel").description("Cancel Pro subscription (access continues until end of billing period)").option("--json","Output as JSON").action(oo);B.command("billing",{hidden:!0}).option("--json","Output as JSON (returns checkout URL)").action(no);B.command("token").description("Print your API key").option("--json","Output as JSON").action(qr);B.command("tokens [action]").description("Manage API tokens (list/create/revoke)").option("--name <name>","Token name (for create)").option("--scopes <scopes>","Comma-separated permission scopes (for create)").option("--expires-in <seconds>","Token lifetime in seconds (for create, min 3600)").option("--token-id <id>","Token ID (for revoke)").option("--json","Output as JSON").option("--fields <fields>","Filter JSON output fields (comma-separated)").addHelpText("after",`
216
216
  Examples:
217
217
  domani tokens list # list all tokens
218
218
  domani tokens create --name "CI" --scopes "domains:read,search"
219
- domani tokens revoke --token-id tok_abc123`).action(Mr);B.command("search [domain] [tlds...]").description("Check availability - domani search myapp .io .fm .xyz").option("--tlds <tlds>","Comma-separated TLDs (e.g. com,io,dev)").option("--max-price <price>","Maximum price filter").option("--all","Show taken domains too").option("--expand","Check 30+ TLDs including creative/exotic extensions").option("--json","Output as JSON").option("--fields <fields>","Filter JSON output fields (comma-separated)").addHelpText("after",`
219
+ domani tokens revoke --token-id tok_abc123`).action(Wr);B.command("search [domain] [tlds...]").description("Check availability - domani search myapp .io .fm .xyz").option("--tlds <tlds>","Comma-separated TLDs (e.g. com,io,dev)").option("--max-price <price>","Maximum price filter").option("--all","Show taken domains too").option("--expand","Check 30+ TLDs including creative/exotic extensions").option("--json","Output as JSON").option("--fields <fields>","Filter JSON output fields (comma-separated)").addHelpText("after",`
220
220
  Examples:
221
221
  domani search myapp # check popular TLDs
222
222
  domani search myapp .io .fm .xyz # specific TLDs
223
223
  domani search myapp --expand # check 30+ TLDs
224
224
  domani search myapp --max-price 20 # only affordable options
225
- domani search myapp --json # machine-readable output`).action(Ir);B.command("tlds").description("List all TLDs with pricing").option("--max-price <price>","Maximum registration price").option("--min-price <price>","Minimum registration price").option("--sort <field>","Sort by: price, tld, renewal (default: tld)").option("--search <term>","Filter TLDs by name").option("--limit <n>","Limit results").option("--json","Output as JSON").option("--fields <fields>","Filter JSON output fields (comma-separated)").action(Pr);B.command("whois <domain>").description("WHOIS/RDAP lookup for any domain").option("--json","Output as JSON").option("--fields <fields>","Filter JSON output fields (comma-separated)").action(Dr);B.command("suggest [prompt]").description("AI-powered domain name suggestions").option("--count <n>","Number of suggestions (1-20, default 10)").option("--tlds <tlds>","Preferred TLDs, comma-separated (e.g. com,dev,ai)").option("--style <style>","Name style: single, creative, short, brandable, keyword").option("--lang <lang>","Language inspiration: japanese, spanish, french, italian, latin, nordic, arabic, sanskrit").option("--timeout <seconds>","Request timeout in seconds (default: 60)").option("--json","Output as JSON").option("--fields <fields>","Filter JSON output fields (comma-separated)").addHelpText("after",`
225
+ domani search myapp --json # machine-readable output`).action(Pr);B.command("tlds").description("List all TLDs with pricing").option("--max-price <price>","Maximum registration price").option("--min-price <price>","Minimum registration price").option("--sort <field>","Sort by: price, tld, renewal (default: tld)").option("--search <term>","Filter TLDs by name").option("--limit <n>","Limit results").option("--json","Output as JSON").option("--fields <fields>","Filter JSON output fields (comma-separated)").action(Nr);B.command("whois <domain>").description("WHOIS/RDAP lookup for any domain").option("--json","Output as JSON").option("--fields <fields>","Filter JSON output fields (comma-separated)").action(Fr);B.command("suggest [prompt]").description("AI-powered domain name suggestions").option("--count <n>","Number of suggestions (1-20, default 10)").option("--tlds <tlds>","Preferred TLDs, comma-separated (e.g. com,dev,ai)").option("--style <style>","Name style: single, creative, short, brandable, keyword").option("--lang <lang>","Language inspiration: japanese, spanish, french, italian, latin, nordic, arabic, sanskrit").option("--timeout <seconds>","Request timeout in seconds (default: 60)").option("--json","Output as JSON").option("--fields <fields>","Filter JSON output fields (comma-separated)").addHelpText("after",`
226
226
  Examples:
227
227
  domani suggest "cat sitting marketplace"
228
228
  domani suggest "AI code editor" --style creative --tlds ai,dev
229
- domani suggest "meditation app" --lang japanese --count 5`).action(Nr);B.command("buy [domains...]").description("Purchase one or more domains").option("--yes","Skip confirmation prompt").option("--dry-run","Show what would happen without executing").option("--json","Output as JSON").option("--fields <fields>","Filter JSON output fields (comma-separated)").addHelpText("after",`
229
+ domani suggest "meditation app" --lang japanese --count 5`).action(Lr);B.command("buy [domains...]").description("Purchase one or more domains").option("--yes","Skip confirmation prompt").option("--dry-run","Show what would happen without executing").option("--json","Output as JSON").option("--fields <fields>","Filter JSON output fields (comma-separated)").addHelpText("after",`
230
230
  Examples:
231
231
  domani buy myapp.dev # buy one domain
232
232
  domani buy myapp.dev myapp.com myapp.ai # buy multiple
233
233
  domani buy myapp.dev --dry-run # preview without buying
234
234
  domani buy myapp.dev --yes # skip confirmation
235
- domani buy myapp.dev --json # machine-readable output`).action(en);B.command("transfer <domain>").description("Transfer a domain from another registrar").option("--auth-code <code>","EPP/auth code from current registrar").option("--yes","Skip confirmation prompt").option("--dry-run","Show what would happen without executing").option("--json","Output as JSON").option("--fields <fields>","Filter JSON output fields (comma-separated)").addHelpText("after",`
235
+ domani buy myapp.dev --json # machine-readable output`).action(nn);B.command("transfer <domain>").description("Transfer a domain from another registrar").option("--auth-code <code>","EPP/auth code from current registrar").option("--yes","Skip confirmation prompt").option("--dry-run","Show what would happen without executing").option("--json","Output as JSON").option("--fields <fields>","Filter JSON output fields (comma-separated)").addHelpText("after",`
236
236
  Examples:
237
237
  domani transfer myapp.com --auth-code ABC123XYZ
238
238
  domani transfer myapp.com --auth-code ABC123XYZ --dry-run
239
- domani transfer myapp.com --auth-code ABC123XYZ --yes`).action(Fr);B.command("renew [domain]").description("Renew a domain").option("--years <n>","Number of years (1-10, default: 1)").option("--yes","Skip confirmation prompt").option("--dry-run","Show what would happen without executing").option("--json","Output as JSON").option("--fields <fields>","Filter JSON output fields (comma-separated)").action(Lr);B.command("import <domain>").description("Import a domain you own at another registrar").option("--verify","Verify DNS ownership and complete import").option("--json","Output as JSON").option("--fields <fields>","Filter JSON output fields (comma-separated)").addHelpText("after",`
239
+ domani transfer myapp.com --auth-code ABC123XYZ --yes`).action(Ur);B.command("renew [domain]").description("Renew a domain").option("--years <n>","Number of years (1-10, default: 1)").option("--yes","Skip confirmation prompt").option("--dry-run","Show what would happen without executing").option("--json","Output as JSON").option("--fields <fields>","Filter JSON output fields (comma-separated)").action(Vr);B.command("import <domain>").description("Import a domain you own at another registrar").option("--verify","Verify DNS ownership and complete import").option("--json","Output as JSON").option("--fields <fields>","Filter JSON output fields (comma-separated)").addHelpText("after",`
240
240
  Examples:
241
241
  domani import myapp.com # start import (shows TXT record to add)
242
- domani import myapp.com --verify # verify TXT record and complete import`).action(Vr);B.command("sell <domain>").description("List a domain for sale (verify ownership via TXT record)").option("--price <amount>","Sale price in USD").option("--verify","Verify DNS ownership and activate listing").option("--transfer-code <code>","Submit transfer/auth code for an active deal").option("--cancel","Remove domain from sale").option("--status","Check listing status").option("--description <text>","Listing description").option("--yes","Skip confirmation").option("--json","Output as JSON").option("--fields <fields>","Filter JSON output fields (comma-separated)").addHelpText("after",`
242
+ domani import myapp.com --verify # verify TXT record and complete import`).action(Mr);B.command("sell <domain>").description("List a domain for sale (verify ownership via TXT record)").option("--price <amount>","Sale price in USD").option("--verify","Verify DNS ownership and activate listing").option("--transfer-code <code>","Submit transfer/auth code for an active deal").option("--cancel","Remove domain from sale").option("--status","Check listing status").option("--description <text>","Listing description").option("--yes","Skip confirmation").option("--json","Output as JSON").option("--fields <fields>","Filter JSON output fields (comma-separated)").addHelpText("after",`
243
243
  Examples:
244
244
  domani sell myapp.dev --price 5000 # list for $5,000
245
245
  domani sell myapp.dev --price 5000 --description "Great brand name"
@@ -247,16 +247,16 @@ Examples:
247
247
  domani sell external.com --verify # verify TXT record
248
248
  domani sell myapp.dev --status # check listing status
249
249
  domani sell myapp.dev --cancel # remove from sale
250
- domani sell myapp.dev --transfer-code ABC123 # provide EPP code for a deal`).action(Xr);B.command("list").alias("domains").description("List your domains").option("--json","Output as JSON").option("--fields <fields>","Filter JSON output fields (comma-separated)").addHelpText("after",`
250
+ domani sell myapp.dev --transfer-code ABC123 # provide EPP code for a deal`).action(Qr);B.command("list").alias("domains").description("List your domains").option("--json","Output as JSON").option("--fields <fields>","Filter JSON output fields (comma-separated)").addHelpText("after",`
251
251
  Examples:
252
252
  domani list # list all domains
253
253
  domani domains # alias for list
254
- domani list --json --fields domain,expires_at`).action(Tr);B.command("status [domain]").description("Check domain health (DNS, SSL, email, expiry)").option("--timeout <seconds>","Request timeout in seconds (default: 30)").option("--json","Output as JSON").option("--fields <fields>","Filter JSON output fields (comma-separated)").action(Xs);B.command("connect [domain] [target]").description("Connect domain to a hosting/email provider").option("--provider <name>","Provider name (e.g. vercel, google-workspace)").option("--method <name>","Connection method (e.g. cname-only)").option("--list","List available providers").option("--dry-run","Show what would happen without executing").option("--json","Output as JSON").option("--fields <fields>","Filter JSON output fields (comma-separated)").addHelpText("after",`
254
+ domani list --json --fields domain,expires_at`).action(Dr);B.command("status [domain]").description("Check domain health (DNS, SSL, email, expiry)").option("--timeout <seconds>","Request timeout in seconds (default: 30)").option("--json","Output as JSON").option("--fields <fields>","Filter JSON output fields (comma-separated)").action(en);B.command("connect [domain] [target]").description("Connect domain to a hosting/email provider").option("--provider <name>","Provider name (e.g. vercel, google-workspace)").option("--method <name>","Connection method (e.g. cname-only)").option("--list","List available providers").option("--dry-run","Show what would happen without executing").option("--json","Output as JSON").option("--fields <fields>","Filter JSON output fields (comma-separated)").addHelpText("after",`
255
255
  Examples:
256
256
  domani connect --list # list providers
257
257
  domani connect myapp.dev vercel # connect to Vercel
258
258
  domani connect myapp.dev --provider google-workspace # connect Google Workspace
259
- domani connect myapp.dev vercel --dry-run # preview DNS changes`).action(Hs);B.command("email [action] [arg2]").description("Manage email: list, inbox, create, delete, send, forward, webhook, setup, status, check, connect").addHelpText("after",`
259
+ domani connect myapp.dev vercel --dry-run # preview DNS changes`).action(Gi);B.command("email [action] [arg2]").description("Manage email: list, inbox, create, delete, send, forward, webhook, setup, status, check, connect").addHelpText("after",`
260
260
  Examples:
261
261
  domani email list # list all mailboxes
262
262
  domani email create --domain myapp.dev --slug hi # create hi@myapp.dev
@@ -264,41 +264,41 @@ Examples:
264
264
  domani email send --from hi@myapp.dev --to bob@x.com --subject "Hello" --text "Hi Bob"
265
265
  domani email setup myapp.dev # setup email for domain
266
266
  domani email status myapp.dev # check email DNS health
267
- domani email delete --domain myapp.dev --slug hi # delete mailbox`).option("--domain <domain>","Domain name").option("--slug <slug>","Mailbox slug (local part before @)").option("--from <email>","Sender address user@domain (alternative to --domain + --slug)").option("--to <email>","Recipient email address (for send)").option("--cc <emails>","CC recipients, comma-separated (for send)").option("--bcc <emails>","BCC recipients, comma-separated (for send)").option("--subject <s>","Email subject (for send)").option("--title <s>","Email subject (alias for --subject)").option("--text <t>","Email body text (for send)").option("--body <t>","Email body text (alias for --text)").option("--in-reply-to <message-id>","Message-ID of email being replied to (for threading)").option("--references <message-ids>","Space-separated Message-ID chain (for threading)").option("--url <url>","Webhook URL (for webhook)").option("--forward-to <email>","Email address to forward inbound emails to (for forward)").option("--direction <dir>","Filter messages: in or out").option("--limit <n>","Limit results").option("--check","Verify email DNS health (MX, SPF, DKIM, DMARC)").option("--dry-run","Show what would happen without executing").option("--json","Output as JSON").option("--fields <fields>","Filter JSON output fields (comma-separated)").action(Zt);B.command("dns [domain] [action] [type] [name] [value]").description("Manage DNS records (get/set/delete/snapshot/restore)").option("--type <type>","Record type: A, AAAA, CNAME, MX, TXT, NS, SRV").option("--name <name>","Record name (e.g. www, @, _dmarc)").option("--value <value>","Record value").option("--file <path>","Snapshot file path (for restore)").option("--dry-run","Show what would happen without executing").option("--json","Output as JSON").option("--fields <fields>","Filter JSON output fields (comma-separated)").addHelpText("after",`
267
+ domani email delete --domain myapp.dev --slug hi # delete mailbox`).option("--domain <domain>","Domain name").option("--slug <slug>","Mailbox slug (local part before @)").option("--from <email>","Sender address user@domain (alternative to --domain + --slug)").option("--to <email>","Recipient email address (for send)").option("--cc <emails>","CC recipients, comma-separated (for send)").option("--bcc <emails>","BCC recipients, comma-separated (for send)").option("--subject <s>","Email subject (for send)").option("--title <s>","Email subject (alias for --subject)").option("--text <t>","Email body text (for send)").option("--body <t>","Email body text (alias for --text)").option("--in-reply-to <message-id>","Message-ID of email being replied to (for threading)").option("--references <message-ids>","Space-separated Message-ID chain (for threading)").option("--url <url>","Webhook URL (for webhook)").option("--forward-to <email>","Email address to forward inbound emails to (for forward)").option("--direction <dir>","Filter messages: in or out").option("--limit <n>","Limit results").option("--check","Verify email DNS health (MX, SPF, DKIM, DMARC)").option("--dry-run","Show what would happen without executing").option("--json","Output as JSON").option("--fields <fields>","Filter JSON output fields (comma-separated)").action(Qt);B.command("dns [domain] [action] [type] [name] [value]").description("Manage DNS records (get/set/delete/snapshot/restore)").option("--type <type>","Record type: A, AAAA, CNAME, MX, TXT, NS, SRV").option("--name <name>","Record name (e.g. www, @, _dmarc)").option("--value <value>","Record value").option("--file <path>","Snapshot file path (for restore)").option("--dry-run","Show what would happen without executing").option("--json","Output as JSON").option("--fields <fields>","Filter JSON output fields (comma-separated)").addHelpText("after",`
268
268
  Examples:
269
269
  domani dns myapp.dev get # list all records
270
270
  domani dns myapp.dev set --type A --name @ --value 76.76.21.21 # add A record
271
271
  domani dns myapp.dev set --type CNAME --name www --value cname.vercel-dns.com
272
272
  domani dns myapp.dev delete --type A --name @
273
273
  domani dns myapp.dev snapshot # export DNS as JSON
274
- domani dns myapp.dev restore --file dns-backup.json # restore from snapshot`).action(Ks);B.command("nameservers [domain] [ns...]").alias("ns").description("Get or set nameservers (--reset for defaults)").option("--set <ns>","Comma-separated nameservers to set").option("--reset","Reset to registrar default nameservers").option("--dry-run","Show what would happen without executing").option("--json","Output as JSON").option("--fields <fields>","Filter JSON output fields (comma-separated)").action(ro);B.command("settings [domain]").description("View or update domain settings (auto-renew, WHOIS privacy, security lock)").option("--auto-renew <on|off>","Enable or disable auto-renew").option("--whois-privacy <on|off>","Enable or disable WHOIS privacy").option("--security-lock <on|off>","Lock or unlock domain transfers").option("--dry-run","Show what would happen without executing").option("--json","Output as JSON").option("--fields <fields>","Filter JSON output fields (comma-separated)").addHelpText("after",`
274
+ domani dns myapp.dev restore --file dns-backup.json # restore from snapshot`).action(Zi);B.command("nameservers [domain] [ns...]").alias("ns").description("Get or set nameservers (--reset for defaults)").option("--set <ns>","Comma-separated nameservers to set").option("--reset","Reset to registrar default nameservers").option("--dry-run","Show what would happen without executing").option("--json","Output as JSON").option("--fields <fields>","Filter JSON output fields (comma-separated)").action(ao);B.command("settings [domain]").description("View or update domain settings (auto-renew, WHOIS privacy, security lock)").option("--auto-renew <on|off>","Enable or disable auto-renew").option("--whois-privacy <on|off>","Enable or disable WHOIS privacy").option("--security-lock <on|off>","Lock or unlock domain transfers").option("--dry-run","Show what would happen without executing").option("--json","Output as JSON").option("--fields <fields>","Filter JSON output fields (comma-separated)").addHelpText("after",`
275
275
  Examples:
276
276
  domani settings myapp.dev # view current settings
277
277
  domani settings myapp.dev --auto-renew on # enable auto-renew
278
278
  domani settings myapp.dev --whois-privacy on # enable WHOIS privacy
279
- domani settings myapp.dev --security-lock off # unlock for transfer`).action(qr);B.command("auth-code [domain]").description("Get EPP auth code to transfer domain to another registrar").option("--json","Output as JSON").option("--fields <fields>","Filter JSON output fields (comma-separated)").action(Wr);B.command("transfer-away [domain]").description("Check status of an outbound domain transfer").option("--json","Output as JSON").option("--fields <fields>","Filter JSON output fields (comma-separated)").action(Hr);B.command("contact [action]").description("View or set WHOIS contact info (required for purchases)").addHelpText("after",`
279
+ domani settings myapp.dev --security-lock off # unlock for transfer`).action(Hr);B.command("auth-code [domain]").description("Get EPP auth code to transfer domain to another registrar").option("--json","Output as JSON").option("--fields <fields>","Filter JSON output fields (comma-separated)").action(Jr);B.command("transfer-away [domain]").description("Check status of an outbound domain transfer").option("--json","Output as JSON").option("--fields <fields>","Filter JSON output fields (comma-separated)").action(Br);B.command("contact [action]").description("View or set WHOIS contact info (required for purchases)").addHelpText("after",`
280
280
  Examples:
281
281
  domani contact # view current contact info
282
282
  domani contact set --first-name John --last-name Doe --address1 "123 Main St" \\
283
- --city "San Francisco" --state CA --postal-code 94102 --country US --phone +1.5551234567 --email john@example.com`).option("--first-name <name>","First name (for set)").option("--last-name <name>","Last name (for set)").option("--org-name <name>","Organization name (for set, optional)").option("--address1 <addr>","Address line 1 (for set)").option("--address2 <addr>","Address line 2 (for set, optional)").option("--city <city>","City (for set)").option("--state <state>","State/Province (for set)").option("--postal-code <code>","Postal/ZIP code (for set)").option("--country <code>","Country code ISO 3166-1 alpha-2 (for set)").option("--phone <phone>","Phone +CC.NUMBER (for set)").option("--email <email>","Contact email (for set)").option("--dry-run","Show what would happen without executing").option("--json","Output as JSON").option("--fields <fields>","Filter JSON output fields (comma-separated)").action(Jr);B.command("parking [domain] [action] [value]").description("Manage parking page (enable/disable/price)").option("--dry-run","Show what would happen without executing").option("--json","Output as JSON").option("--fields <fields>","Filter JSON output fields (comma-separated)").addHelpText("after",`
283
+ --city "San Francisco" --state CA --postal-code 94102 --country US --phone +1.5551234567 --email john@example.com`).option("--first-name <name>","First name (for set)").option("--last-name <name>","Last name (for set)").option("--org-name <name>","Organization name (for set, optional)").option("--address1 <addr>","Address line 1 (for set)").option("--address2 <addr>","Address line 2 (for set, optional)").option("--city <city>","City (for set)").option("--state <state>","State/Province (for set)").option("--postal-code <code>","Postal/ZIP code (for set)").option("--country <code>","Country code ISO 3166-1 alpha-2 (for set)").option("--phone <phone>","Phone +CC.NUMBER (for set)").option("--email <email>","Contact email (for set)").option("--dry-run","Show what would happen without executing").option("--json","Output as JSON").option("--fields <fields>","Filter JSON output fields (comma-separated)").action(Gr);B.command("parking [domain] [action] [value]").description("Manage parking page (enable/disable/price)").option("--dry-run","Show what would happen without executing").option("--json","Output as JSON").option("--fields <fields>","Filter JSON output fields (comma-separated)").addHelpText("after",`
284
284
  Examples:
285
285
  domani parking myapp.dev # view parking status
286
286
  domani parking myapp.dev enable # enable parking page
287
287
  domani parking myapp.dev disable # disable parking page
288
- domani parking myapp.dev price 500 # set for-sale price to $500`).action(Yr);B.command("analytics [domain]").alias("stats").description("View parking analytics (views, inquiries, conversion)").option("--json","Output as JSON").option("--fields <fields>","Filter JSON output fields (comma-separated)").action(Kr);B.command("webhooks [action]").alias("webhook").description("Manage webhook endpoints (list/create/update/delete/deliveries/events)").addHelpText("after",`
288
+ domani parking myapp.dev price 500 # set for-sale price to $500`).action(zr);B.command("analytics [domain]").alias("stats").description("View parking analytics (views, inquiries, conversion)").option("--json","Output as JSON").option("--fields <fields>","Filter JSON output fields (comma-separated)").action(Xr);B.command("webhooks [action]").alias("webhook").description("Manage webhook endpoints (list/create/update/delete/deliveries/events)").addHelpText("after",`
289
289
  Examples:
290
290
  domani webhooks list
291
291
  domani webhooks create --url https://example.com/hook --events domain.purchased,domain.expiring
292
292
  domani webhooks update --webhook-id wh_abc --active off
293
293
  domani webhooks delete --webhook-id wh_abc
294
294
  domani webhooks deliveries --webhook-id wh_abc
295
- domani webhooks events # list available event types`).option("--url <url>","Webhook HTTPS URL").option("--events <events>","Comma-separated event types").option("--webhook-id <id>","Webhook ID (for update/delete/deliveries)").option("--active <on|off>","Enable or disable webhook").option("--limit <n>","Limit deliveries returned").option("--dry-run","Show what would happen without executing").option("--json","Output as JSON").option("--fields <fields>","Filter JSON output fields (comma-separated)").action(zr);B.command("deals [id]").description("List marketplace deals or view deal details").option("--role <role>","Filter by role: buyer or seller").option("--status <status>","Filter by status: active, completed, or all").option("--json","Output as JSON").option("--fields <fields>","Filter JSON output fields (comma-separated)").addHelpText("after",`
295
+ domani webhooks events # list available event types`).option("--url <url>","Webhook HTTPS URL").option("--events <events>","Comma-separated event types").option("--webhook-id <id>","Webhook ID (for update/delete/deliveries)").option("--active <on|off>","Enable or disable webhook").option("--limit <n>","Limit deliveries returned").option("--dry-run","Show what would happen without executing").option("--json","Output as JSON").option("--fields <fields>","Filter JSON output fields (comma-separated)").action(Zr);B.command("deals [id]").description("List marketplace deals or view deal details").option("--role <role>","Filter by role: buyer or seller").option("--status <status>","Filter by status: active, completed, or all").option("--json","Output as JSON").option("--fields <fields>","Filter JSON output fields (comma-separated)").addHelpText("after",`
296
296
  Examples:
297
297
  domani deals # list all your deals
298
298
  domani deals --role seller --status active # your active sales
299
299
  domani deals deal_abc123 # view specific deal
300
- domani deals --json # machine-readable output`).action(Zr);B.command("notifications").alias("notifs").description("View notifications or mark all as read").option("--read","Mark all notifications as read").option("--unread","Show only unread notifications").option("--limit <n>","Limit results").option("--json","Output as JSON").option("--fields <fields>","Filter JSON output fields (comma-separated)").action(eo);B.command("send [arg2]").description("Send an email - shortcut for: domani email send").option("--from <email>","Sender address user@domain").option("--to <email>","Recipient email address").option("--cc <emails>","CC recipients, comma-separated").option("--bcc <emails>","BCC recipients, comma-separated").option("--subject <s>","Email subject").option("--title <s>","Email subject (alias for --subject)").option("--text <t>","Email body text").option("--body <t>","Email body text (alias for --text)").option("--in-reply-to <message-id>","Message-ID of email being replied to").option("--references <message-ids>","Space-separated Message-ID chain").option("--domain <domain>","Domain name").option("--slug <slug>","Mailbox slug").option("--json","Output as JSON").option("--fields <fields>","Filter JSON output fields (comma-separated)").action((e,t)=>Zt("send",e,t));B.command("inbox [arg2]").description("View email inbox - shortcut for: domani email inbox").option("--from <email>","Sender address user@domain").option("--domain <domain>","Domain name").option("--slug <slug>","Mailbox slug").option("--direction <dir>","Filter messages: in or out").option("--limit <n>","Limit results").option("--json","Output as JSON").option("--fields <fields>","Filter JSON output fields (comma-separated)").action((e,t)=>Zt("inbox",e,t));B.command("schema [command]").description("Show command schemas for AI agent integration").option("--json","Output as JSON").option("--fields <fields>","Filter JSON output fields (comma-separated)").action(fo);B.command("update").description("Update domani CLI to the latest version").option("--json","Output as JSON (check version without updating)").action(ao);B.command("uninstall").description("Remove domani CLI and config from this machine").action(uo);(async()=>{let e=Cn();await B.parseAsync();let t=await e;t?.forced?(console.error(`
301
- ${it.default.red("!")} CLI v${_e} is no longer supported. Run ${it.default.bold("domani update")} to upgrade to v${t.update}
300
+ domani deals --json # machine-readable output`).action(eo);B.command("notifications").alias("notifs").description("View notifications or mark all as read").option("--read","Mark all notifications as read").option("--unread","Show only unread notifications").option("--limit <n>","Limit results").option("--json","Output as JSON").option("--fields <fields>","Filter JSON output fields (comma-separated)").action(so);B.command("send [arg2]").description("Send an email - shortcut for: domani email send").option("--from <email>","Sender address user@domain").option("--to <email>","Recipient email address").option("--cc <emails>","CC recipients, comma-separated").option("--bcc <emails>","BCC recipients, comma-separated").option("--subject <s>","Email subject").option("--title <s>","Email subject (alias for --subject)").option("--text <t>","Email body text").option("--body <t>","Email body text (alias for --text)").option("--in-reply-to <message-id>","Message-ID of email being replied to").option("--references <message-ids>","Space-separated Message-ID chain").option("--domain <domain>","Domain name").option("--slug <slug>","Mailbox slug").option("--json","Output as JSON").option("--fields <fields>","Filter JSON output fields (comma-separated)").action((e,t)=>Qt("send",e,t));B.command("inbox [arg2]").description("View email inbox - shortcut for: domani email inbox").option("--from <email>","Sender address user@domain").option("--domain <domain>","Domain name").option("--slug <slug>","Mailbox slug").option("--direction <dir>","Filter messages: in or out").option("--limit <n>","Limit results").option("--json","Output as JSON").option("--fields <fields>","Filter JSON output fields (comma-separated)").action((e,t)=>Qt("inbox",e,t));B.command("schema [command]").description("Show command schemas for AI agent integration").option("--json","Output as JSON").option("--fields <fields>","Filter JSON output fields (comma-separated)").action(ho);B.command("update").description("Update domani CLI to the latest version").option("--json","Output as JSON (check version without updating)").action(co);B.command("uninstall").description("Remove domani CLI and config from this machine").action(fo);(async()=>{let e=Rn();await B.parseAsync();let t=await e;t?.forced?(console.error(`
301
+ ${st.default.red("!")} CLI v${xe} is no longer supported. Run ${st.default.bold("domani update")} to upgrade to v${t.update}
302
302
  `),process.exit(1)):t?.update&&console.error(`
303
- ${it.default.yellow("!")} Update available: ${it.default.dim(_e)} ${it.default.dim("\u2192")} ${it.default.green(t.update)} Run ${it.default.bold("domani update")}
303
+ ${st.default.yellow("!")} Update available: ${st.default.dim(xe)} ${st.default.dim("\u2192")} ${st.default.green(t.update)} Run ${st.default.bold("domani update")}
304
304
  `)})();