nipa-cli 0.1.4 → 0.1.5

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/nipa.js +79 -79
  2. package/package.json +1 -1
package/dist/nipa.js CHANGED
@@ -1,71 +1,71 @@
1
1
  #!/usr/bin/env node
2
- import{createRequire as xf}from"node:module";var cf=Object.create;var{getPrototypeOf:uf,defineProperty:kn,getOwnPropertyNames:lf}=Object;var Fs=Object.prototype.hasOwnProperty;function pf(e){return this[e]}var df,ff,ut=(e,t,r)=>{var n=e!=null&&typeof e==="object";if(n){var o=t?df??=new WeakMap:ff??=new WeakMap,s=o.get(e);if(s)return s}r=e!=null?cf(uf(e)):{};let i=t||!e||!e.__esModule||!Fs.call(e,"default")?kn(r,"default",{value:e,enumerable:!0}):r;if(e&&typeof e==="object"||typeof e==="function"){for(let a of lf(e))if(!Fs.call(i,a))kn(i,a,{get:pf.bind(e,a),enumerable:!0})}if(n)o.set(e,i);return i};var Pn=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var mf=(e)=>e;function hf(e,t){this[e]=mf.bind(null,t)}var gf=(e,t)=>{for(var r in t)kn(e,r,{get:t[r],enumerable:!0,configurable:!0,set:hf.bind(t,r)})};var Us=xf(import.meta.url);var Pt=Pn(function(Dy,En){var lr=process||{},Ms=lr.argv||[],ur=lr.env||{},_f=!(!!ur.NO_COLOR||Ms.includes("--no-color"))&&(!!ur.FORCE_COLOR||Ms.includes("--color")||lr.platform==="win32"||(lr.stdout||{}).isTTY&&ur.TERM!=="dumb"||!!ur.CI),bf=(e,t,r=e)=>(n)=>{let o=""+n,s=o.indexOf(t,e.length);return~s?e+wf(o,t,r,s)+t:e+o+t},wf=(e,t,r,n)=>{let o="",s=0;do o+=e.substring(s,n)+r,s=n+t.length,n=e.indexOf(t,s);while(~n);return o+e.substring(s)},Bs=(e=_f)=>{let t=e?bf:()=>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")}};En.exports=Bs();En.exports.createColors=Bs});var ii=Pn(function(w_,si){si.exports=Gf;function Bf(e){let t={defaultWidth:0,output:process.stdout,tty:Us("tty")};if(!e)return t;return Object.keys(t).forEach(function(r){if(!e[r])e[r]=t[r]}),e}function Gf(e){let t=Bf(e);if(t.output.getWindowSize)return t.output.getWindowSize()[0]||t.defaultWidth;if(t.tty.getWindowSize)return t.tty.getWindowSize()[1]||t.defaultWidth;if(t.output.columns)return t.output.columns;if(process.env.CLI_WIDTH){let r=parseInt(process.env.CLI_WIDTH,10);if(!isNaN(r)&&r!==0)return r}return t.defaultWidth}});var ki=Pn(function(R_,Si){var sm=Us("stream");class $i extends sm{#r=null;constructor(e={}){super(e);this.writable=this.readable=!0,this.muted=!1,this.on("pipe",this._onpipe),this.replace=e.replace,this._prompt=e.prompt||null,this._hadControl=!1}#t(e,t){if(this._dest)return this._dest[e];if(this._src)return this._src[e];return t}#e(e,...t){if(typeof this._dest?.[e]==="function")this._dest[e](...t);if(typeof this._src?.[e]==="function")this._src[e](...t)}get isTTY(){if(this.#r!==null)return this.#r;return this.#t("isTTY",!1)}set isTTY(e){this.#r=e}get rows(){return this.#t("rows")}get columns(){return this.#t("columns")}mute(){this.muted=!0}unmute(){this.muted=!1}_onpipe(e){this._src=e}pipe(e,t){return this._dest=e,super.pipe(e,t)}pause(){if(this._src)return this._src.pause()}resume(){if(this._src)return this._src.resume()}write(e){if(this.muted){if(!this.replace)return!0;if(e.match(/^\u001b/)){if(e.indexOf(this._prompt)===0)e=e.slice(this._prompt.length),e=e.replace(/./g,this.replace),e=this._prompt+e;return this._hadControl=!0,this.emit("data",e)}else{if(this._prompt&&this._hadControl&&e.indexOf(this._prompt)===0)this._hadControl=!1,this.emit("data",this._prompt),e=e.slice(this._prompt.length);e=e.toString().replace(/./g,this.replace)}}this.emit("data",e)}end(e){if(this.muted)if(e&&this.replace)e=e.toString().replace(/./g,this.replace);else e=null;if(e)this.emit("data",e);this.emit("end")}destroy(...e){return this.#e("destroy",...e)}destroySoon(...e){return this.#e("destroySoon",...e)}close(...e){return this.#e("close",...e)}}Si.exports=$i});var zn={name:"nipa-cli",version:"0.1.4",description:"The command-line interface for Nipa Cloud",keywords:["cli","keystone","mfa","nipa-cloud","openstack","terraform","totp"],homepage:"https://github.com/PunGrumpy/nipa#readme",bugs:{url:"https://github.com/PunGrumpy/nipa/issues"},license:"MIT",author:{name:"Noppakorn Kaewsalabnil",url:"https://www.pungrumpy.com"},repository:{type:"git",url:"git+https://github.com/PunGrumpy/nipa.git",directory:"packages/cli"},bin:{nipa:"dist/nipa.js"},files:["dist/nipa.js","README.md","LICENSE"],type:"module",publishConfig:{access:"public"},scripts:{dev:"bun src/index.ts",build:"bun build src/index.ts --compile --minify --outfile dist/nipa","build:npm":"bun build src/index.ts --target=node --minify --outfile dist/nipa.js","build:release":"bun scripts/build-release.ts",test:"bun test",typecheck:"tsc --noEmit","check:package":"bun run build:npm && publint",prepack:"bun run build:npm"},devDependencies:{"@inquirer/confirm":"6.3.2","@inquirer/input":"5.1.6","@inquirer/password":"5.2.2","@inquirer/select":"5.2.5","@types/bun":"1.4.2",picocolors:"1.1.1",typescript:"6.0.3",zod:"4.6.5"},preferGlobal:!0,engines:{node:">=22.13.0"}};var Ae=ut(Pt(),1);var ue={description:"Print JSON",long:"json",value:{kind:"none"}},Gs={description:"Don't ask for confirmation",long:"yes",short:"y",value:{kind:"none"}},Cn={description:"Use this profile (or set NIPA_PROFILE)",long:"profile",short:"P",value:{kind:"profile"}},In={description:"Show help",long:"help",short:"h",value:{kind:"none"}},re=[Cn,{description:"Log each HTTP request (or set NIPA_DEBUG=1)",long:"debug",short:"d",value:{kind:"none"}},{description:"Turn off colors (or set NO_COLOR=1)",long:"no-color",value:{kind:"none"}},In,{description:"Show the version",long:"version",short:"v",value:{kind:"none"}}];var q=(e)=>[e.name,...e.aliases??[]],ne=(e)=>e.short?[`--${e.long}`,`-${e.short}`]:[`--${e.long}`],zt=(e)=>{switch(e.kind){case"none":return"";case"text":return` <${e.name}>`;case"choice":return` <${e.choices.join("|")}>`;case"project":return" <project>";case"profile":return" <name>";default:return e}},Tn=(e)=>e.length===1?e[0]:e[1],Et=(e)=>e.sections.flatMap((t)=>t.commands);var On=" ",vf=80,Ct=(e,t)=>e.map(([r,n])=>`${On}${r.padEnd(t)} ${n}`).join(`
3
- `),Vs=(e)=>Math.max(0,...e.map(([t])=>t.length)),Ws=(e,t)=>{let r=[],n="";for(let o of e.split(" "))if(n&&t.length+n.length+1+o.length>vf)r.push(n),n=o;else n=n?`${n} ${o}`:o;return r.push(n),r.map((o)=>`${t}${o}`).join(`
4
- `)},$f=(e)=>{switch(e.arity){case"one":return`<${e.name}>`;case"optional":return`[${e.name}]`;case"rest":return`[${e.name}...]`;default:return e.arity}},Sf=(e)=>{let[t,...r]=e;if(!t)return[];if(r.length===0&&t.value.kind==="none")return[`[--${t.long}]`];return["[options]"]},kf=(e)=>{switch(e.kind){case"program":case"openstack":return"<args...>";case"command":return"<command> [args...]";default:return e}},Ks=(e)=>{switch(e.kind){case"leaf":return[...e.args.map($f),...Sf(e.flags)].join(" ");case"group":return`[${e.subcommands.map((t)=>t.name).join("|")}]`;case"passthrough":return kf(e.target);default:return e}},pr=(e)=>`nipa ${e.map((t)=>t.name).join(" ")}`,It=(e)=>{let t=Ks(Tn(e));return t?`${pr(e)} ${t}`:pr(e)},Pf=(e)=>{switch(e.kind){case"leaf":return e.flags;case"group":{let t=e.subcommands.flatMap((r)=>r.flags);return t.filter((r,n)=>t.findIndex((o)=>o.long===r.long)===n)}case"passthrough":return[];default:return e}},Js=(e)=>[`${e.short?`-${e.short}, `:" "}--${e.long}${zt(e.value)}`,e.description],An=(e)=>{let t=Ks(e);return[t?`${e.name} ${t}`:e.name,e.summary]},Xe=(e,t)=>` ${Ae.default.dim(`${e}:`)}
2
+ import{createRequire as Rm}from"node:module";var km=Object.create;var{getPrototypeOf:zm,defineProperty:On,getOwnPropertyNames:Em}=Object;var Js=Object.prototype.hasOwnProperty;function Cm(e){return this[e]}var Im,Tm,mt=(e,t,r)=>{var n=e!=null&&typeof e==="object";if(n){var o=t?Im??=new WeakMap:Tm??=new WeakMap,s=o.get(e);if(s)return s}r=e!=null?km(zm(e)):{};let i=t||!e||!e.__esModule||!Js.call(e,"default")?On(r,"default",{value:e,enumerable:!0}):r;if(e&&typeof e==="object"||typeof e==="function"){for(let a of Em(e))if(!Js.call(i,a))On(i,a,{get:Cm.bind(e,a),enumerable:!0})}if(n)o.set(e,i);return i};var An=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var Om=(e)=>e;function Am(e,t){this[e]=Om.bind(null,t)}var jm=(e,t)=>{for(var r in t)On(e,r,{get:t[r],enumerable:!0,configurable:!0,set:Am.bind(t,r)})};var Hs=Rm(import.meta.url);var Tt=An(function(m_,jn){var xr=process||{},qs=xr.argv||[],gr=xr.env||{},Zm=!(!!gr.NO_COLOR||qs.includes("--no-color"))&&(!!gr.FORCE_COLOR||qs.includes("--color")||xr.platform==="win32"||(xr.stdout||{}).isTTY&&gr.TERM!=="dumb"||!!gr.CI),Dm=(e,t,r=e)=>(n)=>{let o=""+n,s=o.indexOf(t,e.length);return~s?e+Nm(o,t,r,s)+t:e+o+t},Nm=(e,t,r,n)=>{let o="",s=0;do o+=e.substring(s,n)+r,s=n+t.length,n=e.indexOf(t,s);while(~n);return o+e.substring(s)},Ys=(e=Zm)=>{let t=e?Dm:()=>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")}};jn.exports=Ys();jn.exports.createColors=Ys});var fi=An(function(q_,mi){mi.exports=uf;function cf(e){let t={defaultWidth:0,output:process.stdout,tty:Hs("tty")};if(!e)return t;return Object.keys(t).forEach(function(r){if(!e[r])e[r]=t[r]}),e}function uf(e){let t=cf(e);if(t.output.getWindowSize)return t.output.getWindowSize()[0]||t.defaultWidth;if(t.tty.getWindowSize)return t.tty.getWindowSize()[1]||t.defaultWidth;if(t.output.columns)return t.output.columns;if(process.env.CLI_WIDTH){let r=parseInt(process.env.CLI_WIDTH,10);if(!isNaN(r)&&r!==0)return r}return t.defaultWidth}});var Ai=An(function(lb,Oi){var Sf=Hs("stream");class Ti extends Sf{#r=null;constructor(e={}){super(e);this.writable=this.readable=!0,this.muted=!1,this.on("pipe",this._onpipe),this.replace=e.replace,this._prompt=e.prompt||null,this._hadControl=!1}#t(e,t){if(this._dest)return this._dest[e];if(this._src)return this._src[e];return t}#e(e,...t){if(typeof this._dest?.[e]==="function")this._dest[e](...t);if(typeof this._src?.[e]==="function")this._src[e](...t)}get isTTY(){if(this.#r!==null)return this.#r;return this.#t("isTTY",!1)}set isTTY(e){this.#r=e}get rows(){return this.#t("rows")}get columns(){return this.#t("columns")}mute(){this.muted=!0}unmute(){this.muted=!1}_onpipe(e){this._src=e}pipe(e,t){return this._dest=e,super.pipe(e,t)}pause(){if(this._src)return this._src.pause()}resume(){if(this._src)return this._src.resume()}write(e){if(this.muted){if(!this.replace)return!0;if(e.match(/^\u001b/)){if(e.indexOf(this._prompt)===0)e=e.slice(this._prompt.length),e=e.replace(/./g,this.replace),e=this._prompt+e;return this._hadControl=!0,this.emit("data",e)}else{if(this._prompt&&this._hadControl&&e.indexOf(this._prompt)===0)this._hadControl=!1,this.emit("data",this._prompt),e=e.slice(this._prompt.length);e=e.toString().replace(/./g,this.replace)}}this.emit("data",e)}end(e){if(this.muted)if(e&&this.replace)e=e.toString().replace(/./g,this.replace);else e=null;if(e)this.emit("data",e);this.emit("end")}destroy(...e){return this.#e("destroy",...e)}destroySoon(...e){return this.#e("destroySoon",...e)}close(...e){return this.#e("close",...e)}}Oi.exports=Ti});var ft={name:"nipa-cli",version:"0.1.5",description:"The command-line interface for Nipa Cloud",keywords:["cli","keystone","mfa","nipa-cloud","openstack","terraform","totp"],homepage:"https://github.com/PunGrumpy/nipa#readme",bugs:{url:"https://github.com/PunGrumpy/nipa/issues"},license:"MIT",author:{name:"Noppakorn Kaewsalabnil",url:"https://www.pungrumpy.com"},repository:{type:"git",url:"git+https://github.com/PunGrumpy/nipa.git",directory:"packages/cli"},bin:{nipa:"dist/nipa.js"},files:["dist/nipa.js","README.md","LICENSE"],type:"module",publishConfig:{access:"public"},scripts:{dev:"bun src/index.ts",build:"bun build src/index.ts --compile --minify --outfile dist/nipa","build:npm":"bun build src/index.ts --target=node --minify --outfile dist/nipa.js","build:release":"bun scripts/build-release.ts",test:"bun test",typecheck:"tsc --noEmit","check:package":"bun run build:npm && publint",prepack:"bun run build:npm"},devDependencies:{"@inquirer/confirm":"6.3.2","@inquirer/input":"5.1.6","@inquirer/password":"5.2.2","@inquirer/select":"5.2.5","@types/bun":"1.4.2",picocolors:"1.1.1",typescript:"6.0.3",zod:"4.6.5"},preferGlobal:!0,engines:{node:">=22.13.0"}};var je=mt(Tt(),1);var le={description:"Print JSON",long:"json",value:{kind:"none"}},Xs={description:"Don't ask for confirmation",long:"yes",short:"y",value:{kind:"none"}},Rn={description:"Use this profile (or set NIPA_PROFILE)",long:"profile",short:"P",value:{kind:"profile"}},Ln={description:"Show help",long:"help",short:"h",value:{kind:"none"}},oe=[Rn,{description:"Log each HTTP request (or set NIPA_DEBUG=1)",long:"debug",short:"d",value:{kind:"none"}},{description:"Turn off colors (or set NO_COLOR=1)",long:"no-color",value:{kind:"none"}},Ln,{description:"Show the version",long:"version",short:"v",value:{kind:"none"}}];var X=(e)=>[e.name,...e.aliases??[]],se=(e)=>e.short?[`--${e.long}`,`-${e.short}`]:[`--${e.long}`],Ot=(e)=>{switch(e.kind){case"none":return"";case"text":return` <${e.name}>`;case"choice":return` <${e.choices.join("|")}>`;case"project":return" <project>";case"profile":return" <name>";default:return e}},Zn=(e)=>e.length===1?e[0]:e[1],At=(e)=>e.sections.flatMap((t)=>t.commands);var Dn=" ",Um=80,jt=(e,t)=>e.map(([r,n])=>`${Dn}${r.padEnd(t)} ${n}`).join(`
3
+ `),Qs=(e)=>Math.max(0,...e.map(([t])=>t.length)),ei=(e,t)=>{let r=[],n="";for(let o of e.split(" "))if(n&&t.length+n.length+1+o.length>Um)r.push(n),n=o;else n=n?`${n} ${o}`:o;return r.push(n),r.map((o)=>`${t}${o}`).join(`
4
+ `)},Fm=(e)=>{switch(e.arity){case"one":return`<${e.name}>`;case"optional":return`[${e.name}]`;case"rest":return`[${e.name}...]`;default:return e.arity}},Mm=(e)=>{let[t,...r]=e;if(!t)return[];if(r.length===0&&t.value.kind==="none")return[`[--${t.long}]`];return["[options]"]},Bm=(e)=>{switch(e.kind){case"program":case"openstack":return"<args...>";case"command":return"<command> [args...]";default:return e}},ti=(e)=>{switch(e.kind){case"leaf":return[...e.args.map(Fm),...Mm(e.flags)].join(" ");case"group":return`[${e.subcommands.map((t)=>t.name).join("|")}]`;case"passthrough":return Bm(e.target);default:return e}},yr=(e)=>`nipa ${e.map((t)=>t.name).join(" ")}`,Rt=(e)=>{let t=ti(Zn(e));return t?`${yr(e)} ${t}`:yr(e)},Gm=(e)=>{switch(e.kind){case"leaf":return e.flags;case"group":{let t=e.subcommands.flatMap((r)=>r.flags);return t.filter((r,n)=>t.findIndex((o)=>o.long===r.long)===n)}case"passthrough":return[];default:return e}},ri=(e)=>[`${e.short?`-${e.short}, `:" "}--${e.long}${Ot(e.value)}`,e.description],Nn=(e)=>{let t=ti(e);return[t?`${e.name} ${t}`:e.name,e.summary]},tt=(e,t)=>` ${je.default.dim(`${e}:`)}
5
5
 
6
6
  ${t}
7
- `,Hs=(e)=>e.map((t)=>`${On}${Ae.default.dim(t.description)}
8
- ${On}${Ae.default.cyan("$")} ${t.command}`).join(`
7
+ `,ni=(e)=>e.map((t)=>`${Dn}${je.default.dim(t.description)}
8
+ ${Dn}${je.default.cyan("$")} ${t.command}`).join(`
9
9
 
10
- `),dr=re.map(Js),jn=(e)=>{let{program:t}=e,r=t.sections.flatMap((i)=>i.commands.map(An)),n=Vs([...r,...dr]),o=t.sections.map((i)=>Xe(i.title,Ct(i.commands.map(An),n))),s=Ae.default.dim(`v${e.version}`);return["",` ${Ae.default.bold("nipa")} ${s}`,"",Ws(t.summary," "),"",` ${Ae.default.dim("Usage:")} nipa [options] <command>`,"",...o,Xe("Global options",Ct(dr,n)),Xe("Examples",Hs(t.examples)),` Run ${Ae.default.bold("nipa <command> --help")} for a command's options.`,""].join(`
11
- `)},fr=(e)=>{let t=Tn(e),r=t.kind==="group"?t.subcommands.map(An):[],n=Pf(t).map(Js),o=Vs([...r,...n,...dr]),s=["",` ${Ae.default.dim("Usage:")} ${It(e)}`,"",Ws(t.description??t.summary," "),""];if(r.length>0)s.push(Xe("Subcommands",Ct(r,o)));if(n.length>0)s.push(Xe("Options",Ct(n,o)));if(s.push(Xe("Global options",Ct(dr,o))),t.examples?.length)s.push(Xe("Examples",Hs(t.examples)));return s.join(`
12
- `)};var zf=["emacs","vim"],Ef=new Set(zf);function Cf(e){return Ef.has(e)}function qs(){let e=process.env.INQUIRER_KEYBINDINGS;if(!e)return[];return Array.from(new Set(e.toLowerCase().split(/[\s,]+/).filter(Cf)))}var Tt=(e,t=[])=>e.name==="up"||t.includes("vim")&&e.name==="k"||t.includes("emacs")&&e.ctrl&&e.name==="p",mr=(e,t=[])=>e.name==="down"||t.includes("vim")&&e.name==="j"||t.includes("emacs")&&e.ctrl&&e.name==="n";var Ot=(e)=>e.name==="backspace",At=(e)=>e.name==="tab",Rn=(e)=>"1234567890".includes(e.name),je=(e)=>e.name==="enter"||e.name==="return";class Zn extends Error{name="AbortPromptError";message="Prompt was aborted";constructor(e){super();this.cause=e?.cause}}class Ln extends Error{name="CancelPromptError";message="Prompt was canceled"}class hr extends Error{name="ExitPromptError"}class Dn extends Error{name="HookError"}class jt extends Error{name="ValidationError"}import{AsyncResource as Af}from"node:async_hooks";import{AsyncLocalStorage as If,AsyncResource as Tf}from"node:async_hooks";var Ys=new If;function Of(e){return{rl:e,hooks:[],hooksCleanup:[],hooksEffect:[],index:0,handleChange(){}}}function Xs(e,t){let r=Of(e);return Ys.run(r,()=>{function n(o){r.handleChange=()=>{r.index=0,o()},r.handleChange()}return t(n)})}function Qe(){let e=Ys.getStore();if(!e)throw new Dn("[Inquirer] Hook functions can only be called from within a prompt");return e}function Nn(){return Qe().rl}function Fn(e){let t=(...r)=>{let n=Qe(),o=!1,s=n.handleChange;n.handleChange=()=>{o=!0};let i=e(...r);if(o)s();return n.handleChange=s,i};return Tf.bind(t)}function lt(e){let t=Qe(),{index:r}=t,n={get(){return t.hooks[r]},set(s){t.hooks[r]=s},initialized:r in t.hooks},o=e(n);return t.index++,o}function Qs(){Qe().handleChange()}var Rt={queue(e){let t=Qe(),{index:r}=t;t.hooksEffect.push(()=>{t.hooksCleanup[r]?.();let n=e(Nn());if(n!=null&&typeof n!=="function")throw new jt("useEffect return value must be a cleanup function or nothing.");t.hooksCleanup[r]=n})},run(){let e=Qe();Fn(()=>{e.hooksEffect.forEach((t)=>{t()}),e.hooksEffect.length=0})()},clearAll(){let e=Qe();e.hooksCleanup.forEach((t)=>{t?.()}),e.hooksEffect.length=0,e.hooksCleanup.length=0}};function jf(e){return typeof e==="function"}function Rf(e){return typeof e==="function"}function D(e){return lt((t)=>{let r=Af.bind(function(s){let i=t.get(),a=Rf(s)?s(i):s;if(!Object.is(i,a))t.set(a),Qs()});if(t.initialized)return[t.get(),r];let n=jf(e)?e():e;return t.set(n),[n,r]})}function Re(e,t){lt((r)=>{let n=r.get();if(!Array.isArray(n)||t.some((s,i)=>!Object.is(s,n[i])))Rt.queue(e);r.set(t)})}import{styleText as ye}from"node:util";import xe from"node:process";function Zf(){if(!xe.platform.startsWith("win"))return xe.env.TERM!=="linux";return Boolean(xe.env.CI)||Boolean(xe.env.WT_SESSION)||Boolean(xe.env.TERMINUS_SUBLIME)||xe.env.ConEmuTask==="{cmd::Cmder}"||xe.env.TERM_PROGRAM==="Terminus-Sublime"||xe.env.TERM_PROGRAM==="vscode"||xe.env.TERM==="xterm-256color"||xe.env.TERM==="alacritty"||xe.env.TERMINAL_EMULATOR==="JetBrains-JediTerm"}var ei={circleQuestionMark:"(?)",questionMarkPrefix:"(?)",square:"█",squareDarkShade:"▓",squareMediumShade:"▒",squareLightShade:"░",squareTop:"▀",squareBottom:"▄",squareLeft:"▌",squareRight:"▐",squareCenter:"■",bullet:"●",dot:"․",ellipsis:"…",pointerSmall:"›",triangleUp:"▲",triangleUpSmall:"▴",triangleDown:"▼",triangleDownSmall:"▾",triangleLeftSmall:"◂",triangleRightSmall:"▸",home:"⌂",heart:"♥",musicNote:"♪",musicNoteBeamed:"♫",arrowUp:"↑",arrowDown:"↓",arrowLeft:"←",arrowRight:"→",arrowLeftRight:"↔",arrowUpDown:"↕",almostEqual:"≈",notEqual:"≠",lessOrEqual:"≤",greaterOrEqual:"≥",identical:"≡",infinity:"∞",subscriptZero:"₀",subscriptOne:"₁",subscriptTwo:"₂",subscriptThree:"₃",subscriptFour:"₄",subscriptFive:"₅",subscriptSix:"₆",subscriptSeven:"₇",subscriptEight:"₈",subscriptNine:"₉",oneHalf:"½",oneThird:"⅓",oneQuarter:"¼",oneFifth:"⅕",oneSixth:"⅙",oneEighth:"⅛",twoThirds:"⅔",twoFifths:"⅖",threeQuarters:"¾",threeFifths:"⅗",threeEighths:"⅜",fourFifths:"⅘",fiveSixths:"⅚",fiveEighths:"⅝",sevenEighths:"⅞",line:"─",lineBold:"━",lineDouble:"═",lineDashed0:"┄",lineDashed1:"┅",lineDashed2:"┈",lineDashed3:"┉",lineDashed4:"╌",lineDashed5:"╍",lineDashed6:"╴",lineDashed7:"╶",lineDashed8:"╸",lineDashed9:"╺",lineDashed10:"╼",lineDashed11:"╾",lineDashed12:"−",lineDashed13:"–",lineDashed14:"‐",lineDashed15:"⁃",lineVertical:"│",lineVerticalBold:"┃",lineVerticalDouble:"║",lineVerticalDashed0:"┆",lineVerticalDashed1:"┇",lineVerticalDashed2:"┊",lineVerticalDashed3:"┋",lineVerticalDashed4:"╎",lineVerticalDashed5:"╏",lineVerticalDashed6:"╵",lineVerticalDashed7:"╷",lineVerticalDashed8:"╹",lineVerticalDashed9:"╻",lineVerticalDashed10:"╽",lineVerticalDashed11:"╿",lineDownLeft:"┐",lineDownLeftArc:"╮",lineDownBoldLeftBold:"┓",lineDownBoldLeft:"┒",lineDownLeftBold:"┑",lineDownDoubleLeftDouble:"╗",lineDownDoubleLeft:"╖",lineDownLeftDouble:"╕",lineDownRight:"┌",lineDownRightArc:"╭",lineDownBoldRightBold:"┏",lineDownBoldRight:"┎",lineDownRightBold:"┍",lineDownDoubleRightDouble:"╔",lineDownDoubleRight:"╓",lineDownRightDouble:"╒",lineUpLeft:"┘",lineUpLeftArc:"╯",lineUpBoldLeftBold:"┛",lineUpBoldLeft:"┚",lineUpLeftBold:"┙",lineUpDoubleLeftDouble:"╝",lineUpDoubleLeft:"╜",lineUpLeftDouble:"╛",lineUpRight:"└",lineUpRightArc:"╰",lineUpBoldRightBold:"┗",lineUpBoldRight:"┖",lineUpRightBold:"┕",lineUpDoubleRightDouble:"╚",lineUpDoubleRight:"╙",lineUpRightDouble:"╘",lineUpDownLeft:"┤",lineUpBoldDownBoldLeftBold:"┫",lineUpBoldDownBoldLeft:"┨",lineUpDownLeftBold:"┥",lineUpBoldDownLeftBold:"┩",lineUpDownBoldLeftBold:"┪",lineUpDownBoldLeft:"┧",lineUpBoldDownLeft:"┦",lineUpDoubleDownDoubleLeftDouble:"╣",lineUpDoubleDownDoubleLeft:"╢",lineUpDownLeftDouble:"╡",lineUpDownRight:"├",lineUpBoldDownBoldRightBold:"┣",lineUpBoldDownBoldRight:"┠",lineUpDownRightBold:"┝",lineUpBoldDownRightBold:"┡",lineUpDownBoldRightBold:"┢",lineUpDownBoldRight:"┟",lineUpBoldDownRight:"┞",lineUpDoubleDownDoubleRightDouble:"╠",lineUpDoubleDownDoubleRight:"╟",lineUpDownRightDouble:"╞",lineDownLeftRight:"┬",lineDownBoldLeftBoldRightBold:"┳",lineDownLeftBoldRightBold:"┯",lineDownBoldLeftRight:"┰",lineDownBoldLeftBoldRight:"┱",lineDownBoldLeftRightBold:"┲",lineDownLeftRightBold:"┮",lineDownLeftBoldRight:"┭",lineDownDoubleLeftDoubleRightDouble:"╦",lineDownDoubleLeftRight:"╥",lineDownLeftDoubleRightDouble:"╤",lineUpLeftRight:"┴",lineUpBoldLeftBoldRightBold:"┻",lineUpLeftBoldRightBold:"┷",lineUpBoldLeftRight:"┸",lineUpBoldLeftBoldRight:"┹",lineUpBoldLeftRightBold:"┺",lineUpLeftRightBold:"┶",lineUpLeftBoldRight:"┵",lineUpDoubleLeftDoubleRightDouble:"╩",lineUpDoubleLeftRight:"╨",lineUpLeftDoubleRightDouble:"╧",lineUpDownLeftRight:"┼",lineUpBoldDownBoldLeftBoldRightBold:"╋",lineUpDownBoldLeftBoldRightBold:"╈",lineUpBoldDownLeftBoldRightBold:"╇",lineUpBoldDownBoldLeftRightBold:"╊",lineUpBoldDownBoldLeftBoldRight:"╉",lineUpBoldDownLeftRight:"╀",lineUpDownBoldLeftRight:"╁",lineUpDownLeftBoldRight:"┽",lineUpDownLeftRightBold:"┾",lineUpBoldDownBoldLeftRight:"╂",lineUpDownLeftBoldRightBold:"┿",lineUpBoldDownLeftBoldRight:"╃",lineUpBoldDownLeftRightBold:"╄",lineUpDownBoldLeftBoldRight:"╅",lineUpDownBoldLeftRightBold:"╆",lineUpDoubleDownDoubleLeftDoubleRightDouble:"╬",lineUpDoubleDownDoubleLeftRight:"╫",lineUpDownLeftDoubleRightDouble:"╪",lineCross:"╳",lineBackslash:"╲",lineSlash:"╱"},ti={tick:"✔",info:"ℹ",warning:"⚠",cross:"✘",squareSmall:"◻",squareSmallFilled:"◼",circle:"◯",circleFilled:"◉",circleDotted:"◌",circleDouble:"◎",circleCircle:"ⓞ",circleCross:"ⓧ",circlePipe:"Ⓘ",radioOn:"◉",radioOff:"◯",checkboxOn:"☒",checkboxOff:"☐",checkboxCircleOn:"ⓧ",checkboxCircleOff:"Ⓘ",pointer:"❯",triangleUpOutline:"△",triangleLeft:"◀",triangleRight:"▶",lozenge:"◆",lozengeOutline:"◇",hamburger:"☰",smiley:"㋡",mustache:"෴",star:"★",play:"▶",nodejs:"⬢",oneSeventh:"⅐",oneNinth:"⅑",oneTenth:"⅒"},Lf={tick:"√",info:"i",warning:"‼",cross:"×",squareSmall:"□",squareSmallFilled:"■",circle:"( )",circleFilled:"(*)",circleDotted:"( )",circleDouble:"( )",circleCircle:"(○)",circleCross:"(×)",circlePipe:"(│)",radioOn:"(*)",radioOff:"( )",checkboxOn:"[×]",checkboxOff:"[ ]",checkboxCircleOn:"(×)",checkboxCircleOff:"( )",pointer:">",triangleUpOutline:"∆",triangleLeft:"◄",triangleRight:"►",lozenge:"♦",lozengeOutline:"◊",hamburger:"≡",smiley:"☺",mustache:"┌─┐",star:"✶",play:"►",nodejs:"♦",oneSeventh:"1/7",oneNinth:"1/9",oneTenth:"1/10"},Df={...ei,...ti},Nf={...ei,...Lf},Ff=Zf(),Uf=Ff?Df:Nf,pt=Uf,t_=Object.entries(ti);var Mf={prefix:{idle:ye("blue","?"),done:ye("green",pt.tick)},spinner:{interval:80,frames:["⠋","⠙","⠹","⠸","⠼","⠴","⠦","⠧","⠇","⠏"].map((e)=>ye("yellow",e))},keybindings:[],style:{answer:(e)=>ye("cyan",e),message:(e)=>ye("bold",e),error:(e)=>ye("red",`> ${e}`),defaultAnswer:(e)=>ye("dim",`(${e})`),help:(e)=>ye("dim",e),highlight:(e)=>ye("cyan",e),key:(e)=>ye("cyan",ye("bold",`<${e}>`))}};function ri(){return{...Mf,keybindings:qs()}}function ni(e){if(typeof e!=="object"||e===null)return!1;let t=e;while(Object.getPrototypeOf(t)!==null)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t}function oi(...e){let t={};for(let r of e)for(let[n,o]of Object.entries(r)){let s=t[n];t[n]=ni(s)&&ni(o)?oi(s,o):o}return t}function _e(...e){let t=[ri(),...e.filter((r)=>r!=null)];return oi(...t)}function Ze({status:e="idle",theme:t}){let[r,n]=D(!1),[o,s]=D(0),{prefix:i,spinner:a}=_e(t);if(Re(()=>{if(e==="loading"){let u,l=-1,p=setTimeout(()=>{n(!0),u=setInterval(()=>{l=l+1,s(l%a.frames.length)},a.interval)},300);return()=>{clearTimeout(p),clearInterval(u)}}else n(!1)},[e]),r)return a.frames[o];return typeof i==="string"?i:i[e==="loading"?"idle":e]??i.idle}function Zt(e,t){return lt((r)=>{let n=r.get();if(!r.initialized||n.dependencies.length!==t.length||n.dependencies.some((o,s)=>o!==t[s])){let o=e();return r.set({value:o,dependencies:t}),o}return n.value})}function et(e){return D({current:e})[0]}function Le(e){let t=et(e);t.current=e,Re((r)=>{let n=!1,o=Fn((s,i)=>{if(n)return;t.current(i,r)});return r.input.on("keypress",o),()=>{n=!0,r.input.removeListener("keypress",o)}},[])}var vi=ut(ii(),1);var ai=(()=>{let e=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g;return(t)=>{let r=0;e.lastIndex=0;while(e.test(t))r+=1;return t.length-r}})(),ci=(e)=>e===12288||e>=65281&&e<=65376||e>=65504&&e<=65510,ui=(e)=>e===8987||e===9001||e>=12272&&e<=12287||e>=12289&&e<=12350||e>=12441&&e<=12543||e>=12549&&e<=12591||e>=12593&&e<=12686||e>=12688&&e<=12771||e>=12783&&e<=12830||e>=12832&&e<=12871||e>=12880&&e<=19903||e>=65040&&e<=65049||e>=65072&&e<=65106||e>=65108&&e<=65126||e>=65128&&e<=65131||e>=127488&&e<=127490||e>=127504&&e<=127547||e>=127552&&e<=127560||e>=131072&&e<=196605||e>=196608&&e<=262141;var Vf=/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]|\u001b\]8;[^;]*;.*?(?:\u0007|\u001b\u005c)/y,Wf=/[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y,li=/(?:(?![\uFF61-\uFF9F\uFF00-\uFFEF])[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}\p{Script=Tangut}]){1,1000}/yu,Kf=/\t{1,1000}/y,pi=/[\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,Jf=/(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y,Hf=/\p{M}+/gu,qf={limit:1/0,ellipsis:""},di=(e,t={},r={})=>{let n=t.limit??1/0,o=t.ellipsis??"",s=t?.ellipsisWidth??(o?di(o,qf,r).width:0),i=0,a=r.controlWidth??0,c=r.tabWidth??8,u=r.emojiWidth??2,l=2,p=r.regularWidth??1,d=r.wideWidth??2,f=[[Jf,p],[Vf,0],[Wf,a],[Kf,c],[pi,u],[li,d]],m=0,g=0,x=e.length,_=0,w=!1,P=x,C=Math.max(0,n-s),y=0,S=0,I=0,W=0;e:while(!0){if(S>y||g>=x&&g>m){let E=e.slice(y,S)||e.slice(m,g);_=0;for(let T of E.replaceAll(Hf,"")){let B=T.codePointAt(0)||0;if(ci(B))W=2;else if(ui(B))W=d;else W=p;if(I+W>C)P=Math.min(P,Math.max(y,m)+_);if(I+W>n){w=!0;break e}_+=T.length,I+=W}y=S=0}if(g>=x)break e;for(let E=0,T=f.length;E<T;E++){let[B,K]=f[E];if(B.lastIndex=g,B.test(e)){if(_=B===li?ai(e.slice(g,B.lastIndex)):B===pi?1:B.lastIndex-g,W=_*K,I+W>C)P=Math.min(P,g+Math.floor((C-I)/K));if(I+W>n){w=!0;break e}I+=W,y=m,S=g,g=m=B.lastIndex;continue e}}g+=1}return{width:w?C:I,index:w?P:x,truncated:w,ellipsed:w&&n>=s}},fi=di;var Yf={limit:1/0,ellipsis:"",ellipsisWidth:0},Xf=(e,t={})=>fi(e,Yf,t).width,De=Xf;var gr="\x1B",yi="›",Qf=39,Mn="\x07",_i="[",em="]",bi="m",Bn=`${em}8;;`,mi=new RegExp(`(?:\\${_i}(?<code>\\d+)m|\\${Bn}(?<uri>.*)${Mn})`,"y"),hi=(e)=>{if(e>=30&&e<=37)return 39;if(e>=90&&e<=97)return 39;if(e>=40&&e<=47)return 49;if(e>=100&&e<=107)return 49;if(e===1||e===2)return 22;if(e===3)return 23;if(e===4)return 24;if(e===7)return 27;if(e===8)return 28;if(e===9)return 29;if(e===0)return 0;return},gi=(e)=>`${gr}${_i}${e}${bi}`,xi=(e)=>`${gr}${Bn}${e}${Mn}`,Un=(e,t,r)=>{let n=t[Symbol.iterator](),o=!1,s=!1,i=e.at(-1),a=i===void 0?0:De(i),c=n.next(),u=n.next(),l=0;while(!c.done){let p=c.value,d=De(p);if(a+d<=r)e[e.length-1]+=p;else e.push(p),a=0;if(p===gr||p===yi)o=!0,s=t.startsWith(Bn,l+1);if(o){if(s){if(p===Mn)o=!1,s=!1}else if(p===bi)o=!1}else if(a+=d,a===r&&!u.done)e.push(""),a=0;c=u,u=n.next(),l+=p.length}if(i=e.at(-1),!a&&i!==void 0&&i.length&&e.length>1)e[e.length-2]+=e.pop()},tm=(e)=>{let t=e.split(" "),r=t.length;while(r){if(De(t[r-1]))break;r--}if(r===t.length)return e;return t.slice(0,r).join(" ")+t.slice(r).join("")},rm=(e,t,r={})=>{if(r.trim!==!1&&e.trim()==="")return"";let n="",o,s,i=e.split(" "),a=[""],c=0;for(let p=0;p<i.length;p++){let d=i[p];if(r.trim!==!1){let m=a.at(-1)??"",g=m.trimStart();if(m.length!==g.length)a[a.length-1]=g,c=De(g)}if(p!==0){if(c>=t&&(r.wordWrap===!1||r.trim===!1))a.push(""),c=0;if(c||r.trim===!1)a[a.length-1]+=" ",c++}let f=De(d);if(r.hard&&f>t){let m=t-c,g=1+Math.floor((f-m-1)/t);if(Math.floor((f-1)/t)<g)a.push("");Un(a,d,t),c=De(a.at(-1)??"");continue}if(c+f>t&&c&&f){if(r.wordWrap===!1&&c<t){Un(a,d,t),c=De(a.at(-1)??"");continue}a.push(""),c=0}if(c+f>t&&r.wordWrap===!1){Un(a,d,t),c=De(a.at(-1)??"");continue}a[a.length-1]+=d,c+=f}if(r.trim!==!1)a=a.map((p)=>tm(p));let u=a.join(`
13
- `),l=!1;for(let p=0;p<u.length;p++){let d=u[p];if(n+=d,!l){if(l=d>="\uD800"&&d<="\uDBFF",l)continue}else l=!1;if(d===gr||d===yi){mi.lastIndex=p+1;let m=mi.exec(u)?.groups;if(m?.code!==void 0){let g=Number.parseFloat(m.code);o=g===Qf?void 0:g}else if(m?.uri!==void 0)s=m.uri.length===0?void 0:m.uri}if(u[p+1]===`
14
- `){if(s)n+=xi("");let f=o?hi(o):void 0;if(o&&f)n+=gi(f)}else if(d===`
15
- `){if(o&&hi(o))n+=gi(o);if(s)n+=xi(s)}}return n},nm=/\r?\n/;function wi(e,t,r){return String(e).normalize().split(nm).map((n)=>rm(n,t,r)).join(`
16
- `)}function Lt(e,t){return e.split(`
17
- `).flatMap((r)=>wi(r,t,{trim:!1,wordWrap:!1}).split(`
10
+ `),_r=oe.map(ri),Un=(e)=>{let{program:t}=e,r=t.sections.flatMap((i)=>i.commands.map(Nn)),n=Qs([...r,..._r]),o=t.sections.map((i)=>tt(i.title,jt(i.commands.map(Nn),n))),s=je.default.dim(`v${e.version}`);return["",` ${je.default.bold("nipa")} ${s}`,"",ei(t.summary," "),"",` ${je.default.dim("Usage:")} nipa [options] <command>`,"",...o,tt("Global options",jt(_r,n)),tt("Examples",ni(t.examples)),` Run ${je.default.bold("nipa <command> --help")} for a command's options.`,""].join(`
11
+ `)},br=(e)=>{let t=Zn(e),r=t.kind==="group"?t.subcommands.map(Nn):[],n=Gm(t).map(ri),o=Qs([...r,...n,..._r]),s=["",` ${je.default.dim("Usage:")} ${Rt(e)}`,"",ei(t.description??t.summary," "),""];if(r.length>0)s.push(tt("Subcommands",jt(r,o)));if(n.length>0)s.push(tt("Options",jt(n,o)));if(s.push(tt("Global options",jt(_r,o))),t.examples?.length)s.push(tt("Examples",ni(t.examples)));return s.join(`
12
+ `)};var Vm=["emacs","vim"],Wm=new Set(Vm);function Km(e){return Wm.has(e)}function oi(){let e=process.env.INQUIRER_KEYBINDINGS;if(!e)return[];return Array.from(new Set(e.toLowerCase().split(/[\s,]+/).filter(Km)))}var Lt=(e,t=[])=>e.name==="up"||t.includes("vim")&&e.name==="k"||t.includes("emacs")&&e.ctrl&&e.name==="p",wr=(e,t=[])=>e.name==="down"||t.includes("vim")&&e.name==="j"||t.includes("emacs")&&e.ctrl&&e.name==="n";var Zt=(e)=>e.name==="backspace",Dt=(e)=>e.name==="tab",Fn=(e)=>"1234567890".includes(e.name),Re=(e)=>e.name==="enter"||e.name==="return";class Mn extends Error{name="AbortPromptError";message="Prompt was aborted";constructor(e){super();this.cause=e?.cause}}class Bn extends Error{name="CancelPromptError";message="Prompt was canceled"}class vr extends Error{name="ExitPromptError"}class Gn extends Error{name="HookError"}class Nt extends Error{name="ValidationError"}import{AsyncResource as Ym}from"node:async_hooks";import{AsyncLocalStorage as Jm,AsyncResource as Hm}from"node:async_hooks";var si=new Jm;function qm(e){return{rl:e,hooks:[],hooksCleanup:[],hooksEffect:[],index:0,handleChange(){}}}function ii(e,t){let r=qm(e);return si.run(r,()=>{function n(o){r.handleChange=()=>{r.index=0,o()},r.handleChange()}return t(n)})}function rt(){let e=si.getStore();if(!e)throw new Gn("[Inquirer] Hook functions can only be called from within a prompt");return e}function Vn(){return rt().rl}function Wn(e){let t=(...r)=>{let n=rt(),o=!1,s=n.handleChange;n.handleChange=()=>{o=!0};let i=e(...r);if(o)s();return n.handleChange=s,i};return Hm.bind(t)}function ht(e){let t=rt(),{index:r}=t,n={get(){return t.hooks[r]},set(s){t.hooks[r]=s},initialized:r in t.hooks},o=e(n);return t.index++,o}function ai(){rt().handleChange()}var Ut={queue(e){let t=rt(),{index:r}=t;t.hooksEffect.push(()=>{t.hooksCleanup[r]?.();let n=e(Vn());if(n!=null&&typeof n!=="function")throw new Nt("useEffect return value must be a cleanup function or nothing.");t.hooksCleanup[r]=n})},run(){let e=rt();Wn(()=>{e.hooksEffect.forEach((t)=>{t()}),e.hooksEffect.length=0})()},clearAll(){let e=rt();e.hooksCleanup.forEach((t)=>{t?.()}),e.hooksEffect.length=0,e.hooksCleanup.length=0}};function Xm(e){return typeof e==="function"}function Qm(e){return typeof e==="function"}function N(e){return ht((t)=>{let r=Ym.bind(function(s){let i=t.get(),a=Qm(s)?s(i):s;if(!Object.is(i,a))t.set(a),ai()});if(t.initialized)return[t.get(),r];let n=Xm(e)?e():e;return t.set(n),[n,r]})}function Le(e,t){ht((r)=>{let n=r.get();if(!Array.isArray(n)||t.some((s,i)=>!Object.is(s,n[i])))Ut.queue(e);r.set(t)})}import{styleText as ye}from"node:util";import xe from"node:process";function ef(){if(!xe.platform.startsWith("win"))return xe.env.TERM!=="linux";return Boolean(xe.env.CI)||Boolean(xe.env.WT_SESSION)||Boolean(xe.env.TERMINUS_SUBLIME)||xe.env.ConEmuTask==="{cmd::Cmder}"||xe.env.TERM_PROGRAM==="Terminus-Sublime"||xe.env.TERM_PROGRAM==="vscode"||xe.env.TERM==="xterm-256color"||xe.env.TERM==="alacritty"||xe.env.TERMINAL_EMULATOR==="JetBrains-JediTerm"}var ci={circleQuestionMark:"(?)",questionMarkPrefix:"(?)",square:"█",squareDarkShade:"▓",squareMediumShade:"▒",squareLightShade:"░",squareTop:"▀",squareBottom:"▄",squareLeft:"▌",squareRight:"▐",squareCenter:"■",bullet:"●",dot:"․",ellipsis:"…",pointerSmall:"›",triangleUp:"▲",triangleUpSmall:"▴",triangleDown:"▼",triangleDownSmall:"▾",triangleLeftSmall:"◂",triangleRightSmall:"▸",home:"⌂",heart:"♥",musicNote:"♪",musicNoteBeamed:"♫",arrowUp:"↑",arrowDown:"↓",arrowLeft:"←",arrowRight:"→",arrowLeftRight:"↔",arrowUpDown:"↕",almostEqual:"≈",notEqual:"≠",lessOrEqual:"≤",greaterOrEqual:"≥",identical:"≡",infinity:"∞",subscriptZero:"₀",subscriptOne:"₁",subscriptTwo:"₂",subscriptThree:"₃",subscriptFour:"₄",subscriptFive:"₅",subscriptSix:"₆",subscriptSeven:"₇",subscriptEight:"₈",subscriptNine:"₉",oneHalf:"½",oneThird:"⅓",oneQuarter:"¼",oneFifth:"⅕",oneSixth:"⅙",oneEighth:"⅛",twoThirds:"⅔",twoFifths:"⅖",threeQuarters:"¾",threeFifths:"⅗",threeEighths:"⅜",fourFifths:"⅘",fiveSixths:"⅚",fiveEighths:"⅝",sevenEighths:"⅞",line:"─",lineBold:"━",lineDouble:"═",lineDashed0:"┄",lineDashed1:"┅",lineDashed2:"┈",lineDashed3:"┉",lineDashed4:"╌",lineDashed5:"╍",lineDashed6:"╴",lineDashed7:"╶",lineDashed8:"╸",lineDashed9:"╺",lineDashed10:"╼",lineDashed11:"╾",lineDashed12:"−",lineDashed13:"–",lineDashed14:"‐",lineDashed15:"⁃",lineVertical:"│",lineVerticalBold:"┃",lineVerticalDouble:"║",lineVerticalDashed0:"┆",lineVerticalDashed1:"┇",lineVerticalDashed2:"┊",lineVerticalDashed3:"┋",lineVerticalDashed4:"╎",lineVerticalDashed5:"╏",lineVerticalDashed6:"╵",lineVerticalDashed7:"╷",lineVerticalDashed8:"╹",lineVerticalDashed9:"╻",lineVerticalDashed10:"╽",lineVerticalDashed11:"╿",lineDownLeft:"┐",lineDownLeftArc:"╮",lineDownBoldLeftBold:"┓",lineDownBoldLeft:"┒",lineDownLeftBold:"┑",lineDownDoubleLeftDouble:"╗",lineDownDoubleLeft:"╖",lineDownLeftDouble:"╕",lineDownRight:"┌",lineDownRightArc:"╭",lineDownBoldRightBold:"┏",lineDownBoldRight:"┎",lineDownRightBold:"┍",lineDownDoubleRightDouble:"╔",lineDownDoubleRight:"╓",lineDownRightDouble:"╒",lineUpLeft:"┘",lineUpLeftArc:"╯",lineUpBoldLeftBold:"┛",lineUpBoldLeft:"┚",lineUpLeftBold:"┙",lineUpDoubleLeftDouble:"╝",lineUpDoubleLeft:"╜",lineUpLeftDouble:"╛",lineUpRight:"└",lineUpRightArc:"╰",lineUpBoldRightBold:"┗",lineUpBoldRight:"┖",lineUpRightBold:"┕",lineUpDoubleRightDouble:"╚",lineUpDoubleRight:"╙",lineUpRightDouble:"╘",lineUpDownLeft:"┤",lineUpBoldDownBoldLeftBold:"┫",lineUpBoldDownBoldLeft:"┨",lineUpDownLeftBold:"┥",lineUpBoldDownLeftBold:"┩",lineUpDownBoldLeftBold:"┪",lineUpDownBoldLeft:"┧",lineUpBoldDownLeft:"┦",lineUpDoubleDownDoubleLeftDouble:"╣",lineUpDoubleDownDoubleLeft:"╢",lineUpDownLeftDouble:"╡",lineUpDownRight:"├",lineUpBoldDownBoldRightBold:"┣",lineUpBoldDownBoldRight:"┠",lineUpDownRightBold:"┝",lineUpBoldDownRightBold:"┡",lineUpDownBoldRightBold:"┢",lineUpDownBoldRight:"┟",lineUpBoldDownRight:"┞",lineUpDoubleDownDoubleRightDouble:"╠",lineUpDoubleDownDoubleRight:"╟",lineUpDownRightDouble:"╞",lineDownLeftRight:"┬",lineDownBoldLeftBoldRightBold:"┳",lineDownLeftBoldRightBold:"┯",lineDownBoldLeftRight:"┰",lineDownBoldLeftBoldRight:"┱",lineDownBoldLeftRightBold:"┲",lineDownLeftRightBold:"┮",lineDownLeftBoldRight:"┭",lineDownDoubleLeftDoubleRightDouble:"╦",lineDownDoubleLeftRight:"╥",lineDownLeftDoubleRightDouble:"╤",lineUpLeftRight:"┴",lineUpBoldLeftBoldRightBold:"┻",lineUpLeftBoldRightBold:"┷",lineUpBoldLeftRight:"┸",lineUpBoldLeftBoldRight:"┹",lineUpBoldLeftRightBold:"┺",lineUpLeftRightBold:"┶",lineUpLeftBoldRight:"┵",lineUpDoubleLeftDoubleRightDouble:"╩",lineUpDoubleLeftRight:"╨",lineUpLeftDoubleRightDouble:"╧",lineUpDownLeftRight:"┼",lineUpBoldDownBoldLeftBoldRightBold:"╋",lineUpDownBoldLeftBoldRightBold:"╈",lineUpBoldDownLeftBoldRightBold:"╇",lineUpBoldDownBoldLeftRightBold:"╊",lineUpBoldDownBoldLeftBoldRight:"╉",lineUpBoldDownLeftRight:"╀",lineUpDownBoldLeftRight:"╁",lineUpDownLeftBoldRight:"┽",lineUpDownLeftRightBold:"┾",lineUpBoldDownBoldLeftRight:"╂",lineUpDownLeftBoldRightBold:"┿",lineUpBoldDownLeftBoldRight:"╃",lineUpBoldDownLeftRightBold:"╄",lineUpDownBoldLeftBoldRight:"╅",lineUpDownBoldLeftRightBold:"╆",lineUpDoubleDownDoubleLeftDoubleRightDouble:"╬",lineUpDoubleDownDoubleLeftRight:"╫",lineUpDownLeftDoubleRightDouble:"╪",lineCross:"╳",lineBackslash:"╲",lineSlash:"╱"},ui={tick:"✔",info:"ℹ",warning:"⚠",cross:"✘",squareSmall:"◻",squareSmallFilled:"◼",circle:"◯",circleFilled:"◉",circleDotted:"◌",circleDouble:"◎",circleCircle:"ⓞ",circleCross:"ⓧ",circlePipe:"Ⓘ",radioOn:"◉",radioOff:"◯",checkboxOn:"☒",checkboxOff:"☐",checkboxCircleOn:"ⓧ",checkboxCircleOff:"Ⓘ",pointer:"❯",triangleUpOutline:"△",triangleLeft:"◀",triangleRight:"▶",lozenge:"◆",lozengeOutline:"◇",hamburger:"☰",smiley:"㋡",mustache:"෴",star:"★",play:"▶",nodejs:"⬢",oneSeventh:"⅐",oneNinth:"⅑",oneTenth:"⅒"},tf={tick:"√",info:"i",warning:"‼",cross:"×",squareSmall:"□",squareSmallFilled:"■",circle:"( )",circleFilled:"(*)",circleDotted:"( )",circleDouble:"( )",circleCircle:"(○)",circleCross:"(×)",circlePipe:"(│)",radioOn:"(*)",radioOff:"( )",checkboxOn:"[×]",checkboxOff:"[ ]",checkboxCircleOn:"(×)",checkboxCircleOff:"( )",pointer:">",triangleUpOutline:"∆",triangleLeft:"◄",triangleRight:"►",lozenge:"♦",lozengeOutline:"◊",hamburger:"≡",smiley:"☺",mustache:"┌─┐",star:"✶",play:"►",nodejs:"♦",oneSeventh:"1/7",oneNinth:"1/9",oneTenth:"1/10"},rf={...ci,...ui},nf={...ci,...tf},of=ef(),sf=of?rf:nf,gt=sf,I_=Object.entries(ui);var af={prefix:{idle:ye("blue","?"),done:ye("green",gt.tick)},spinner:{interval:80,frames:["⠋","⠙","⠹","⠸","⠼","⠴","⠦","⠧","⠇","⠏"].map((e)=>ye("yellow",e))},keybindings:[],style:{answer:(e)=>ye("cyan",e),message:(e)=>ye("bold",e),error:(e)=>ye("red",`> ${e}`),defaultAnswer:(e)=>ye("dim",`(${e})`),help:(e)=>ye("dim",e),highlight:(e)=>ye("cyan",e),key:(e)=>ye("cyan",ye("bold",`<${e}>`))}};function li(){return{...af,keybindings:oi()}}function pi(e){if(typeof e!=="object"||e===null)return!1;let t=e;while(Object.getPrototypeOf(t)!==null)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t}function di(...e){let t={};for(let r of e)for(let[n,o]of Object.entries(r)){let s=t[n];t[n]=pi(s)&&pi(o)?di(s,o):o}return t}function _e(...e){let t=[li(),...e.filter((r)=>r!=null)];return di(...t)}function Ze({status:e="idle",theme:t}){let[r,n]=N(!1),[o,s]=N(0),{prefix:i,spinner:a}=_e(t);if(Le(()=>{if(e==="loading"){let u,l=-1,p=setTimeout(()=>{n(!0),u=setInterval(()=>{l=l+1,s(l%a.frames.length)},a.interval)},300);return()=>{clearTimeout(p),clearInterval(u)}}else n(!1)},[e]),r)return a.frames[o];return typeof i==="string"?i:i[e==="loading"?"idle":e]??i.idle}function Ft(e,t){return ht((r)=>{let n=r.get();if(!r.initialized||n.dependencies.length!==t.length||n.dependencies.some((o,s)=>o!==t[s])){let o=e();return r.set({value:o,dependencies:t}),o}return n.value})}function nt(e){return N({current:e})[0]}function De(e){let t=nt(e);t.current=e,Le((r)=>{let n=!1,o=Wn((s,i)=>{if(n)return;t.current(i,r)});return r.input.on("keypress",o),()=>{n=!0,r.input.removeListener("keypress",o)}},[])}var Ii=mt(fi(),1);var hi=(()=>{let e=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g;return(t)=>{let r=0;e.lastIndex=0;while(e.test(t))r+=1;return t.length-r}})(),gi=(e)=>e===12288||e>=65281&&e<=65376||e>=65504&&e<=65510,xi=(e)=>e===8987||e===9001||e>=12272&&e<=12287||e>=12289&&e<=12350||e>=12441&&e<=12543||e>=12549&&e<=12591||e>=12593&&e<=12686||e>=12688&&e<=12771||e>=12783&&e<=12830||e>=12832&&e<=12871||e>=12880&&e<=19903||e>=65040&&e<=65049||e>=65072&&e<=65106||e>=65108&&e<=65126||e>=65128&&e<=65131||e>=127488&&e<=127490||e>=127504&&e<=127547||e>=127552&&e<=127560||e>=131072&&e<=196605||e>=196608&&e<=262141;var lf=/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]|\u001b\]8;[^;]*;.*?(?:\u0007|\u001b\u005c)/y,pf=/[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y,yi=/(?:(?![\uFF61-\uFF9F\uFF00-\uFFEF])[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}\p{Script=Tangut}]){1,1000}/yu,df=/\t{1,1000}/y,_i=/[\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,mf=/(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y,ff=/\p{M}+/gu,hf={limit:1/0,ellipsis:""},bi=(e,t={},r={})=>{let n=t.limit??1/0,o=t.ellipsis??"",s=t?.ellipsisWidth??(o?bi(o,hf,r).width:0),i=0,a=r.controlWidth??0,c=r.tabWidth??8,u=r.emojiWidth??2,l=2,p=r.regularWidth??1,d=r.wideWidth??2,m=[[mf,p],[lf,0],[pf,a],[df,c],[_i,u],[yi,d]],f=0,g=0,x=e.length,y=0,w=!1,k=x,I=Math.max(0,n-s),_=0,S=0,O=0,W=0;e:while(!0){if(S>_||g>=x&&g>f){let C=e.slice(_,S)||e.slice(f,g);y=0;for(let A of C.replaceAll(ff,"")){let B=A.codePointAt(0)||0;if(gi(B))W=2;else if(xi(B))W=d;else W=p;if(O+W>I)k=Math.min(k,Math.max(_,f)+y);if(O+W>n){w=!0;break e}y+=A.length,O+=W}_=S=0}if(g>=x)break e;for(let C=0,A=m.length;C<A;C++){let[B,K]=m[C];if(B.lastIndex=g,B.test(e)){if(y=B===yi?hi(e.slice(g,B.lastIndex)):B===_i?1:B.lastIndex-g,W=y*K,O+W>I)k=Math.min(k,g+Math.floor((I-O)/K));if(O+W>n){w=!0;break e}O+=W,_=f,S=g,g=f=B.lastIndex;continue e}}g+=1}return{width:w?I:O,index:w?k:x,truncated:w,ellipsed:w&&n>=s}},wi=bi;var gf={limit:1/0,ellipsis:"",ellipsisWidth:0},xf=(e,t={})=>wi(e,gf,t).width,Ne=xf;var $r="\x1B",ki="›",yf=39,Jn="\x07",zi="[",_f="]",Ei="m",Hn=`${_f}8;;`,vi=new RegExp(`(?:\\${zi}(?<code>\\d+)m|\\${Hn}(?<uri>.*)${Jn})`,"y"),$i=(e)=>{if(e>=30&&e<=37)return 39;if(e>=90&&e<=97)return 39;if(e>=40&&e<=47)return 49;if(e>=100&&e<=107)return 49;if(e===1||e===2)return 22;if(e===3)return 23;if(e===4)return 24;if(e===7)return 27;if(e===8)return 28;if(e===9)return 29;if(e===0)return 0;return},Si=(e)=>`${$r}${zi}${e}${Ei}`,Pi=(e)=>`${$r}${Hn}${e}${Jn}`,Kn=(e,t,r)=>{let n=t[Symbol.iterator](),o=!1,s=!1,i=e.at(-1),a=i===void 0?0:Ne(i),c=n.next(),u=n.next(),l=0;while(!c.done){let p=c.value,d=Ne(p);if(a+d<=r)e[e.length-1]+=p;else e.push(p),a=0;if(p===$r||p===ki)o=!0,s=t.startsWith(Hn,l+1);if(o){if(s){if(p===Jn)o=!1,s=!1}else if(p===Ei)o=!1}else if(a+=d,a===r&&!u.done)e.push(""),a=0;c=u,u=n.next(),l+=p.length}if(i=e.at(-1),!a&&i!==void 0&&i.length&&e.length>1)e[e.length-2]+=e.pop()},bf=(e)=>{let t=e.split(" "),r=t.length;while(r){if(Ne(t[r-1]))break;r--}if(r===t.length)return e;return t.slice(0,r).join(" ")+t.slice(r).join("")},wf=(e,t,r={})=>{if(r.trim!==!1&&e.trim()==="")return"";let n="",o,s,i=e.split(" "),a=[""],c=0;for(let p=0;p<i.length;p++){let d=i[p];if(r.trim!==!1){let f=a.at(-1)??"",g=f.trimStart();if(f.length!==g.length)a[a.length-1]=g,c=Ne(g)}if(p!==0){if(c>=t&&(r.wordWrap===!1||r.trim===!1))a.push(""),c=0;if(c||r.trim===!1)a[a.length-1]+=" ",c++}let m=Ne(d);if(r.hard&&m>t){let f=t-c,g=1+Math.floor((m-f-1)/t);if(Math.floor((m-1)/t)<g)a.push("");Kn(a,d,t),c=Ne(a.at(-1)??"");continue}if(c+m>t&&c&&m){if(r.wordWrap===!1&&c<t){Kn(a,d,t),c=Ne(a.at(-1)??"");continue}a.push(""),c=0}if(c+m>t&&r.wordWrap===!1){Kn(a,d,t),c=Ne(a.at(-1)??"");continue}a[a.length-1]+=d,c+=m}if(r.trim!==!1)a=a.map((p)=>bf(p));let u=a.join(`
13
+ `),l=!1;for(let p=0;p<u.length;p++){let d=u[p];if(n+=d,!l){if(l=d>="\uD800"&&d<="\uDBFF",l)continue}else l=!1;if(d===$r||d===ki){vi.lastIndex=p+1;let f=vi.exec(u)?.groups;if(f?.code!==void 0){let g=Number.parseFloat(f.code);o=g===yf?void 0:g}else if(f?.uri!==void 0)s=f.uri.length===0?void 0:f.uri}if(u[p+1]===`
14
+ `){if(s)n+=Pi("");let m=o?$i(o):void 0;if(o&&m)n+=Si(m)}else if(d===`
15
+ `){if(o&&$i(o))n+=Si(o);if(s)n+=Pi(s)}}return n},vf=/\r?\n/;function Ci(e,t,r){return String(e).normalize().split(vf).map((n)=>wf(n,t,r)).join(`
16
+ `)}function Mt(e,t){return e.split(`
17
+ `).flatMap((r)=>Ci(r,t,{trim:!1,wordWrap:!1}).split(`
18
18
  `).map((n)=>n.trimEnd())).join(`
19
- `)}function xr(){return vi.default({defaultWidth:80,output:Nn().output})}function om({active:e,renderedItems:t,pageSize:r,loop:n}){let o=et({lastPointer:e,lastActive:void 0}),{lastPointer:s,lastActive:i}=o.current,a=Math.floor(r/2),c=t.reduce((p,d)=>p+d.length,0),u=t.slice(0,e).reduce((p,d)=>p+d.length,0),l=u;if(c>r)if(n){if(l=s,i!=null&&i<e&&e-i<r)l=Math.min(a,Math.abs(e-i)===1?Math.min(s+(t[i]?.length??0),Math.max(u,s)):s+e-i)}else{let p=t.slice(e).reduce((d,f)=>d+f.length,0);l=p<r-a?r-p:Math.min(u,a)}return o.current.lastPointer=l,o.current.lastActive=e,l}function Gn({items:e,active:t,renderItem:r,pageSize:n,loop:o=!0}){let s=xr(),i=(_)=>(_%e.length+e.length)%e.length,a=e.map((_,w)=>{if(_==null)return[];return Lt(r({item:_,index:w,isActive:w===t}),s).split(`
20
- `)}),c=a.reduce((_,w)=>_+w.length,0),u=(_)=>a[_]??[],l=om({active:t,renderedItems:a,pageSize:n,loop:o}),p=u(t).slice(0,n),d=l+p.length<=n?l:n-p.length,f=Array.from({length:n});f.splice(d,p.length,...p);let m=new Set([t]),g=d+p.length,x=i(t+1);while(g<n&&!m.has(x)&&(o&&c>n?x!==t:x>t)){let w=u(x).slice(0,n-g);f.splice(g,w.length,...w),m.add(x),g+=w.length,x=i(x+1)}g=d-1,x=i(t-1);while(g>=0&&!m.has(x)&&(o&&c>n?x!==t:x<t)){let _=u(x),w=_.slice(Math.max(0,_.length-g-1));f.splice(g-w.length+1,w.length,...w),m.add(x),g-=w.length,x=i(x-1)}return f.filter((_)=>typeof _==="string").join(`
21
- `)}var ji=ut(ki(),1);import*as Ai from"node:readline";import{AsyncResource as lm}from"node:async_hooks";var tt=[];tt.push("SIGHUP","SIGINT","SIGTERM");if(process.platform!=="win32")tt.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");if(process.platform==="linux")tt.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var yr=(e)=>!!e&&typeof e==="object"&&typeof e.removeListener==="function"&&typeof e.emit==="function"&&typeof e.reallyExit==="function"&&typeof e.listeners==="function"&&typeof e.kill==="function"&&typeof e.pid==="number"&&typeof e.on==="function",Vn=Symbol.for("signal-exit emitter"),Wn=globalThis,im=Object.defineProperty.bind(Object);class Pi{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(Wn[Vn])return Wn[Vn];im(Wn,Vn,{value:this,writable:!1,enumerable:!1,configurable:!1})}on(e,t){this.listeners[e].push(t)}removeListener(e,t){let r=this.listeners[e],n=r.indexOf(t);if(n===-1)return;if(n===0&&r.length===1)r.length=0;else r.splice(n,1)}emit(e,t,r){if(this.emitted[e])return!1;this.emitted[e]=!0;let n=!1;for(let o of this.listeners[e])n=o(t,r)===!0||n;if(e==="exit")n=this.emit("afterExit",t,r)||n;return n}}class Jn{}var am=(e)=>({onExit(t,r){return e.onExit(t,r)},load(){return e.load()},unload(){return e.unload()}});class zi extends Jn{onExit(){return()=>{}}load(){}unload(){}}class Ei extends Jn{#r=Kn.platform==="win32"?"SIGINT":"SIGHUP";#t=new Pi;#e;#s;#i;#o={};#n=!1;constructor(e){super();this.#e=e,this.#o={};for(let t of tt)this.#o[t]=()=>{let r=this.#e.listeners(t),{count:n}=this.#t,o=e;if(typeof o.__signal_exit_emitter__==="object"&&typeof o.__signal_exit_emitter__.count==="number")n+=o.__signal_exit_emitter__.count;if(r.length===n){this.unload();let s=this.#t.emit("exit",null,t),i=t==="SIGHUP"?this.#r:t;if(!s)e.kill(e.pid,i)}};this.#i=e.reallyExit,this.#s=e.emit}onExit(e,t){if(!yr(this.#e))return()=>{};if(this.#n===!1)this.load();let r=t?.alwaysLast?"afterExit":"exit";return this.#t.on(r,e),()=>{if(this.#t.removeListener(r,e),this.#t.listeners.exit.length===0&&this.#t.listeners.afterExit.length===0)this.unload()}}load(){if(this.#n)return;this.#n=!0,this.#t.count+=1;for(let e of tt)try{let t=this.#o[e];if(t)this.#e.on(e,t)}catch(t){}this.#e.emit=(e,...t)=>this.#c(e,...t),this.#e.reallyExit=(e)=>this.#a(e)}unload(){if(!this.#n)return;this.#n=!1,tt.forEach((e)=>{let t=this.#o[e];if(!t)throw Error("Listener not defined for signal: "+e);try{this.#e.removeListener(e,t)}catch(r){}}),this.#e.emit=this.#s,this.#e.reallyExit=this.#i,this.#t.count-=1}#a(e){if(!yr(this.#e))return 0;return this.#e.exitCode=e||0,this.#t.emit("exit",this.#e.exitCode,null),this.#i.call(this.#e,this.#e.exitCode)}#c(e,...t){let r=this.#s;if(e==="exit"&&yr(this.#e)){if(typeof t[0]==="number")this.#e.exitCode=t[0];let n=r.call(this.#e,e,...t);return this.#t.emit("exit",this.#e.exitCode,null),n}else return r.call(this.#e,e,...t)}}var Kn=globalThis.process,{onExit:Ci,load:D_,unload:N_}=am(yr(Kn)?new Ei(Kn):new zi);import{stripVTControlCharacters as cm}from"node:util";var Hn="\x1B[G",_r="\x1B[?25l",Ti="\x1B[?25h",qn=(e=1)=>e>0?`\x1B[${e}A`:"",Yn=(e=1)=>e>0?`\x1B[${e}B`:"",Xn=(e,t)=>{if(typeof t==="number"&&!Number.isNaN(t))return`\x1B[${t+1};${e+1}H`;return`\x1B[${e+1}G`},Ii="\x1B[2K",Qn=(e)=>e>0?(Ii+qn(1)).repeat(e-1)+Ii+Hn:"";var Oi=(e)=>e.split(`
22
- `).length,um=(e)=>e.split(`
23
- `).pop()??"";class br{height=0;extraLinesUnderPrompt=0;cursorPos;rl;constructor(e){this.rl=e,this.cursorPos=e.getCursorPos()}write(e){this.rl.output.unmute(),this.rl.output.write(e),this.rl.output.mute()}render(e,t=""){let r=um(e),n=cm(r),o=n;if(this.rl.line.length>0)o=o.slice(0,-this.rl.line.length);this.rl.setPrompt(o),this.cursorPos=this.rl.getCursorPos();let s=xr();if(e=Lt(e,s),t=Lt(t,s),n.length%s===0)e+=`
19
+ `)}function Sr(){return Ii.default({defaultWidth:80,output:Vn().output})}function $f({active:e,renderedItems:t,pageSize:r,loop:n}){let o=nt({lastPointer:e,lastActive:void 0}),{lastPointer:s,lastActive:i}=o.current,a=Math.floor(r/2),c=t.reduce((p,d)=>p+d.length,0),u=t.slice(0,e).reduce((p,d)=>p+d.length,0),l=u;if(c>r)if(n){if(l=s,i!=null&&i<e&&e-i<r)l=Math.min(a,Math.abs(e-i)===1?Math.min(s+(t[i]?.length??0),Math.max(u,s)):s+e-i)}else{let p=t.slice(e).reduce((d,m)=>d+m.length,0);l=p<r-a?r-p:Math.min(u,a)}return o.current.lastPointer=l,o.current.lastActive=e,l}function qn({items:e,active:t,renderItem:r,pageSize:n,loop:o=!0}){let s=Sr(),i=(y)=>(y%e.length+e.length)%e.length,a=e.map((y,w)=>{if(y==null)return[];return Mt(r({item:y,index:w,isActive:w===t}),s).split(`
20
+ `)}),c=a.reduce((y,w)=>y+w.length,0),u=(y)=>a[y]??[],l=$f({active:t,renderedItems:a,pageSize:n,loop:o}),p=u(t).slice(0,n),d=l+p.length<=n?l:n-p.length,m=Array.from({length:n});m.splice(d,p.length,...p);let f=new Set([t]),g=d+p.length,x=i(t+1);while(g<n&&!f.has(x)&&(o&&c>n?x!==t:x>t)){let w=u(x).slice(0,n-g);m.splice(g,w.length,...w),f.add(x),g+=w.length,x=i(x+1)}g=d-1,x=i(t-1);while(g>=0&&!f.has(x)&&(o&&c>n?x!==t:x<t)){let y=u(x),w=y.slice(Math.max(0,y.length-g-1));m.splice(g-w.length+1,w.length,...w),f.add(x),g-=w.length,x=i(x-1)}return m.filter((y)=>typeof y==="string").join(`
21
+ `)}var Mi=mt(Ai(),1);import*as Fi from"node:readline";import{AsyncResource as Cf}from"node:async_hooks";var ot=[];ot.push("SIGHUP","SIGINT","SIGTERM");if(process.platform!=="win32")ot.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");if(process.platform==="linux")ot.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var Pr=(e)=>!!e&&typeof e==="object"&&typeof e.removeListener==="function"&&typeof e.emit==="function"&&typeof e.reallyExit==="function"&&typeof e.listeners==="function"&&typeof e.kill==="function"&&typeof e.pid==="number"&&typeof e.on==="function",Yn=Symbol.for("signal-exit emitter"),Xn=globalThis,Pf=Object.defineProperty.bind(Object);class ji{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(Xn[Yn])return Xn[Yn];Pf(Xn,Yn,{value:this,writable:!1,enumerable:!1,configurable:!1})}on(e,t){this.listeners[e].push(t)}removeListener(e,t){let r=this.listeners[e],n=r.indexOf(t);if(n===-1)return;if(n===0&&r.length===1)r.length=0;else r.splice(n,1)}emit(e,t,r){if(this.emitted[e])return!1;this.emitted[e]=!0;let n=!1;for(let o of this.listeners[e])n=o(t,r)===!0||n;if(e==="exit")n=this.emit("afterExit",t,r)||n;return n}}class eo{}var kf=(e)=>({onExit(t,r){return e.onExit(t,r)},load(){return e.load()},unload(){return e.unload()}});class Ri extends eo{onExit(){return()=>{}}load(){}unload(){}}class Li extends eo{#r=Qn.platform==="win32"?"SIGINT":"SIGHUP";#t=new ji;#e;#s;#i;#o={};#n=!1;constructor(e){super();this.#e=e,this.#o={};for(let t of ot)this.#o[t]=()=>{let r=this.#e.listeners(t),{count:n}=this.#t,o=e;if(typeof o.__signal_exit_emitter__==="object"&&typeof o.__signal_exit_emitter__.count==="number")n+=o.__signal_exit_emitter__.count;if(r.length===n){this.unload();let s=this.#t.emit("exit",null,t),i=t==="SIGHUP"?this.#r:t;if(!s)e.kill(e.pid,i)}};this.#i=e.reallyExit,this.#s=e.emit}onExit(e,t){if(!Pr(this.#e))return()=>{};if(this.#n===!1)this.load();let r=t?.alwaysLast?"afterExit":"exit";return this.#t.on(r,e),()=>{if(this.#t.removeListener(r,e),this.#t.listeners.exit.length===0&&this.#t.listeners.afterExit.length===0)this.unload()}}load(){if(this.#n)return;this.#n=!0,this.#t.count+=1;for(let e of ot)try{let t=this.#o[e];if(t)this.#e.on(e,t)}catch(t){}this.#e.emit=(e,...t)=>this.#c(e,...t),this.#e.reallyExit=(e)=>this.#a(e)}unload(){if(!this.#n)return;this.#n=!1,ot.forEach((e)=>{let t=this.#o[e];if(!t)throw Error("Listener not defined for signal: "+e);try{this.#e.removeListener(e,t)}catch(r){}}),this.#e.emit=this.#s,this.#e.reallyExit=this.#i,this.#t.count-=1}#a(e){if(!Pr(this.#e))return 0;return this.#e.exitCode=e||0,this.#t.emit("exit",this.#e.exitCode,null),this.#i.call(this.#e,this.#e.exitCode)}#c(e,...t){let r=this.#s;if(e==="exit"&&Pr(this.#e)){if(typeof t[0]==="number")this.#e.exitCode=t[0];let n=r.call(this.#e,e,...t);return this.#t.emit("exit",this.#e.exitCode,null),n}else return r.call(this.#e,e,...t)}}var Qn=globalThis.process,{onExit:Zi,load:mb,unload:fb}=kf(Pr(Qn)?new Li(Qn):new Ri);import{stripVTControlCharacters as zf}from"node:util";var to="\x1B[G",kr="\x1B[?25l",Ni="\x1B[?25h",ro=(e=1)=>e>0?`\x1B[${e}A`:"",no=(e=1)=>e>0?`\x1B[${e}B`:"",oo=(e,t)=>{if(typeof t==="number"&&!Number.isNaN(t))return`\x1B[${t+1};${e+1}H`;return`\x1B[${e+1}G`},Di="\x1B[2K",so=(e)=>e>0?(Di+ro(1)).repeat(e-1)+Di+to:"";var Ui=(e)=>e.split(`
22
+ `).length,Ef=(e)=>e.split(`
23
+ `).pop()??"";class zr{height=0;extraLinesUnderPrompt=0;cursorPos;rl;constructor(e){this.rl=e,this.cursorPos=e.getCursorPos()}write(e){this.rl.output.unmute(),this.rl.output.write(e),this.rl.output.mute()}render(e,t=""){let r=Ef(e),n=zf(r),o=n;if(this.rl.line.length>0)o=o.slice(0,-this.rl.line.length);this.rl.setPrompt(o),this.cursorPos=this.rl.getCursorPos();let s=Sr();if(e=Mt(e,s),t=Mt(t,s),n.length%s===0)e+=`
24
24
  `;let i=e+(t?`
25
- `+t:""),c=Math.floor(n.length/s)-this.cursorPos.rows+(t?Oi(t):0);if(c>0)i+=qn(c);i+=Xn(this.cursorPos.cols),this.write(Yn(this.extraLinesUnderPrompt)+Qn(this.height)+i),this.extraLinesUnderPrompt=c,this.height=Oi(i)}checkCursorPos(){let e=this.rl.getCursorPos();if(e.cols!==this.cursorPos.cols)this.write(Xn(e.cols)),this.cursorPos=e}done({clearContent:e}){this.rl.setPrompt("");let t=Yn(this.extraLinesUnderPrompt);t+=e?Qn(this.height):`
26
- `,t+=Hn,t+=Ti,this.write(t),this.rl.close()}}class eo extends Promise{static withResolver(){let e,t;return{promise:new Promise((n,o)=>{e=n,t=o}),resolve:e,reject:t}}}import pm from"node:path";var dm=globalThis.setImmediate;function wr(e,t,r){if("on"in e)return e.on(t,r),()=>e.removeListener(t,r);return e.addEventListener(t,r),()=>e.removeEventListener(t,r)}function fm(){let e=Error.prepareStackTrace,t=[];try{Error.prepareStackTrace=(r,n)=>{let o=n.slice(1);return t=o,o},Error().stack}catch{return t}return Error.prepareStackTrace=e,t}function Ne(e){let t=fm();return(n,o={})=>{let{input:s=process.stdin,signal:i}=o,a=new Set,c=new ji.default;c.pipe(o.output??process.stdout);let u=Ai.createInterface({terminal:!0,input:s,output:c});c.mute();let l=new br(u),{promise:p,resolve:d,reject:f}=eo.withResolver();return Xs(u,(m)=>{let g=lm.bind(()=>Rt.clearAll()),x=(y)=>{try{g(),y()}catch(S){f(S)}},_=(y)=>x(()=>d(y)),w=(y)=>x(()=>f(y)),P=Object.assign(p.finally(()=>{a.forEach((y)=>y()),l.done({clearContent:Boolean(o.clearPromptOnDone)}),c.end()}).then(()=>p),{cancel:()=>w(new Ln)});if(i){let y=()=>w(new Zn({cause:i.reason}));if(i.aborted)return y(),P;a.add(wr(i,"abort",y))}a.add(Ci((y,S)=>{w(new hr(`User force closed the prompt with ${y} ${S}`))})),a.add(wr(u,"SIGINT",()=>w(new hr("User force closed the prompt with SIGINT")))),a.add(wr(u,"close",g));let C=()=>{a.add(wr(u.input,"keypress",()=>l.checkCursorPos()));let y=null;m(()=>{let S=!1;try{let I=e(n,(T)=>{if(S)_(T);else y={value:T}});if(I===void 0){let T=t[1]?.getFileName();if(T&&!T.startsWith("file://"))T=pm.resolve(T);throw Error(`Prompt functions must return a string.
27
- at ${T}`)}let[W,E]=typeof I==="string"?[I]:I;l.render(W,E),Rt.run()}catch(I){w(I)}if(S=!0,y!==null){let{value:I}=y;y=null,_(I)}})};if("readableFlowing"in s)dm(C);else C();return P})}}import{styleText as mm}from"node:util";class Se{separator=mm("dim",Array.from({length:15}).join(pt.line));type="separator";constructor(e){if(e)this.separator=e}static isSeparator(e){return Boolean(e&&typeof e==="object"&&"type"in e&&e.type==="separator")}}import{styleText as hm}from"node:util";var gm={keywords:{yes:"Yes",no:"No"},style:{confirmDefault:(e)=>{let t=e[0]??"";if(t.toLowerCase()===t.toUpperCase())return hm("cyan",e);return t.toUpperCase()+e.slice(1)}}},Ri=Ne((e,t)=>{let[r,n]=D("idle"),[o,s]=D(""),i=_e(gm,e.theme),a=Ze({status:r,theme:i}),{yes:c,no:u}=i.keywords,l=(c[0]??"").toLowerCase(),p=(u[0]??"").toLowerCase(),d=e.default===!1?`${l}/${i.style.confirmDefault(p)}`:`${i.style.confirmDefault(l)}/${p}`;function f(P){return P?c:u}let{transformer:m=f}=e;function g(P,C){let y=P.trim().toLowerCase();if(y==="")return C!==!1;if(c.toLowerCase().startsWith(y))return!0;if(u.toLowerCase().startsWith(y))return!1;return C!==!1}Le((P,C)=>{if(r!=="idle")return;if(je(P)){let y=g(o,e.default);s(m(y)),n("done"),t(y)}else if(At(P)){let y=f(!g(o,e.default));C.clearLine(0),C.write(y),s(y)}else s(C.line)});let x=o,_="";if(r==="done")x=i.style.answer(o);else _=` ${i.style.defaultAnswer(d)}`;let w=i.style.message(e.message,r);return`${a} ${w}${_} ${x}`});var xm={validationFailureMode:"keep"},Zi=Ne((e,t)=>{let{prefill:r="tab"}=e,n=_e(xm,e.theme),[o,s]=D("idle"),[i,a]=D(String(e.default??"")),[c,u]=D(),[l,p]=D(""),d=Ze({status:o,theme:n});async function f(w){let{required:P,pattern:C,patternError:y="Invalid input"}=e;if(P&&!w)return"You must provide a value";if(C&&!C.test(w))return y;if(typeof e.validate==="function")return await e.validate(w)||"You must provide a valid value";return!0}Le(async(w,P)=>{if(o!=="idle")return;if(je(w)){let C=l||i;s("loading");let y=await f(C);if(y===!0)p(C),s("done"),t(C);else{if(n.validationFailureMode==="clear")p("");else P.write(l);u(y),s("idle")}}else if(Ot(w)&&!l)a("");else if(At(w)&&!l)a(""),P.clearLine(0),P.write(i),p(i);else p(P.line),u(void 0)}),Re((w)=>{if(r==="editable"&&i)w.write(i),p(i)},[]);let m=n.style.message(e.message,o),g=l;if(typeof e.transformer==="function")g=e.transformer(l,{isFinal:o==="done"});else if(o==="done")g=n.style.answer(l);let x;if(i&&o!=="done"&&!l)x=n.style.defaultAnswer(i);let _="";if(c)_=n.style.error(c);return[[d,m,x,g].filter((w)=>w!==void 0).join(" "),_]});import{styleText as to}from"node:util";var ym={style:{maskedText:"[input is masked]",keysHelpTip:(e)=>e.map(([t,r])=>`${to("bold",t)} ${to("dim",r)}`).join(to("dim"," • "))}},Li=Ne((e,t)=>{let{toggleMask:r=!0,validate:n=()=>!0}=e,o=_e(ym,e.theme),[s,i]=D("idle"),[a,c]=D(),[u,l]=D(""),[p,d]=D(!1),f=Ze({status:s,theme:o});Le(async(P,C)=>{if(s!=="idle")return;if(je(P)){let y=u;i("loading");let S=await n(y);if(S===!0)l(y),i("done"),t(y);else C.write(u),c(S||"You must provide a valid value"),i("idle")}else if(r&&P.ctrl&&P.name==="t")d((y)=>!y);else l(C.line),c(void 0)});let m=o.style.message(e.message,s),g=r&&p&&s==="idle",x="";if(g)x=u;else if(e.mask)x=(typeof e.mask==="string"?e.mask:"*").repeat(u.length);else if(s!=="done")x=o.style.help(o.style.maskedText);if(s==="done")x=o.style.answer(x);else if(!e.mask)x+=_r;let _=[f,m,x].filter(Boolean).join(" "),w=[a?o.style.error(a):"",r&&s==="idle"?o.style.keysHelpTip([["ctrl+t","toggle visibility"]]):""].filter(Boolean).join(`
28
- `);return[_,w]});import{styleText as Dt}from"node:util";var _m={icon:{cursor:pt.pointer},style:{disabled:(e)=>Dt("dim",e),description:(e)=>Dt("cyan",e),keysHelpTip:(e)=>e.map(([t,r])=>`${Dt("bold",t)} ${Dt("dim",r)}`).join(Dt("dim"," • "))},i18n:{disabledError:"This option is disabled and cannot be selected."},indexMode:"hidden"};function ro(e){return!Se.isSeparator(e)&&!e.disabled}function no(e){return!Se.isSeparator(e)}function bm(e){return e.map((t)=>{if(Se.isSeparator(t))return t;if(typeof t!=="object"||t===null||!("value"in t)){let o=String(t);return{value:t,name:o,short:o,disabled:!1}}let r=t.name??String(t.value),n={value:t.value,name:r,short:t.short??r,disabled:t.disabled??!1};if(t.description)n.description=t.description;return n})}var Di=Ne((e,t)=>{let{loop:r=!0,pageSize:n=7}=e,o=_e(_m,e.theme),{keybindings:s}=o,[i,a]=D("idle"),c=Ze({status:i,theme:o}),u=et(),l=!s.includes("vim"),p=Zt(()=>bm(e.choices),[e.choices]),d=Zt(()=>{let E=p.findIndex(no),T=p.findLastIndex(no);if(E===-1)throw new jt("[select prompt] No selectable choices. All choices are disabled.");return{first:E,last:T}},[p]),f=Zt(()=>{if(!("default"in e))return-1;return p.findIndex((E)=>ro(E)&&E.value===e.default)},[e.default,p]),[m,g]=D(f===-1?d.first:f),x=p[m];if(x==null||Se.isSeparator(x))throw Error("Active index does not point to a choice");let[_,w]=D();Le((E,T)=>{if(clearTimeout(u.current),_)w(void 0);if(je(E))if(x.disabled)w(o.i18n.disabledError);else a("done"),t(x.value);else if(Tt(E,s)||mr(E,s)){if(T.clearLine(0),r||Tt(E,s)&&m!==d.first||mr(E,s)&&m!==d.last){let B=Tt(E,s)?-1:1,K=m;do K=(K+B+p.length)%p.length;while(!no(p[K]));g(K)}}else if(Rn(E)&&!Number.isNaN(Number(T.line))){let B=Number(T.line)-1,K=-1,ge=p.findIndex((kt)=>{if(Se.isSeparator(kt))return!1;return K++,K===B}),Sn=p[ge];if(Sn!=null&&ro(Sn))g(ge);u.current=setTimeout(()=>{T.clearLine(0)},700)}else if(Ot(E))T.clearLine(0);else if(l){let B=T.line.toLowerCase(),K=p.findIndex((ge)=>{if(Se.isSeparator(ge)||!ro(ge))return!1;return ge.name.toLowerCase().startsWith(B)});if(K!==-1)g(K);u.current=setTimeout(()=>{T.clearLine(0)},700)}}),Re(()=>()=>{clearTimeout(u.current)},[]);let P=o.style.message(e.message,i),C=o.style.keysHelpTip([["↑↓","navigate"],["⏎","select"]]),y=0,S=Gn({items:p,active:m,renderItem({item:E,isActive:T,index:B}){if(Se.isSeparator(E))return y++,` ${E.separator}`;let K=T?o.icon.cursor:" ",ge=o.indexMode==="number"?`${B+1-y}. `:"";if(E.disabled){let kt=typeof E.disabled==="string"?E.disabled:"(disabled)",af=T?o.icon.cursor:"-";return o.style.disabled(`${af} ${ge}${E.name} ${kt}`)}return(T?o.style.highlight:(kt)=>kt)(`${K} ${ge}${E.name}`)},pageSize:n,loop:r});if(i==="done")return[c,P,o.style.answer(x.short)].filter(Boolean).join(" ");let{description:I}=x;return`${[[c,P].filter(Boolean).join(" "),S," ",I?o.style.description(I):"",_?o.style.error(_):"",C].filter(Boolean).join(`
29
- `).trimEnd()}${_r}`});var be=ut(Pt(),1);class O extends Error{hint;exitCode;constructor(e,t={}){super(e);this.name="CliError",this.hint=t.hint,this.exitCode=t.exitCode??1}}var N=(e,t)=>new O(e,{exitCode:2,hint:t}),we=(e)=>e<1000?`${Math.round(e)}ms`:`${Math.round(e/1000)}s`,wm=[["d",86400000],["h",3600000],["m",60000],["s",1000]],dt=(e)=>{let t=Math.max(0,e);for(let[r,n]of wm)if(t>=n)return`${Math.round(t/n)}${r}`;return`${Math.round(t)}ms`},Fi=(e)=>{let t=Math.max(0,Math.floor(e/60000)),r=Math.floor(t/60);return r>0?`${r}h ${t%60}m`:`${t}m`},oe=(e)=>{process.stderr.write(`${e}
30
- `)},R=(e)=>{oe(`${be.default.dim(">")} ${e}`)},le=(e,t)=>{let r=t===void 0?"":`[${we(t)}]`,n=r?` ${be.default.dim(r)}`:"";oe(`${be.default.cyan("> Success!")} ${e}${n}`)},ft=(e)=>{oe(`${be.default.bold(be.default.yellow("> NOTE:"))} ${e}`)},Ui=(e)=>{if(oe(`${be.default.bold(be.default.red("Error:"))} ${e.message}`),e.hint)oe(`${be.default.dim(">")} ${e.hint}`)},Ni=["⠋","⠙","⠹","⠸","⠼","⠴","⠦","⠧","⠇","⠏"],vm=300,$m="\r\x1B[2K",V=async(e,t)=>{if(!process.stderr.isTTY)return t();let r=0,n=!1,o,s=()=>{n=!0;let a=Ni[r%Ni.length]??"";r+=1,process.stderr.write(`\r${be.default.dim(a)} ${e}`)},i=setTimeout(()=>{s(),o=setInterval(s,80)},vm);try{return await t()}finally{if(clearTimeout(i),clearInterval(o),n)process.stderr.write($m)}},vr=async(e)=>{try{return await e()}catch(t){if(t instanceof Error&&t.name==="ExitPromptError")throw new O("Canceled",{exitCode:130});throw t}},Mi=(e)=>{let t={output:e.stderr};return{choice:(r)=>vr(()=>Di(r,t)),confirm:(r)=>vr(()=>Ri(r,t)),interactive:e.stdin.isTTY===!0&&e.stderr.isTTY===!0,secret:(r)=>vr(()=>Li({mask:"*",message:r},t)),text:(r)=>vr(()=>Zi({...r,required:!0},t))}},Bi=(e)=>({isTTY:e.isTTY===!0,json:(t)=>{e.write(`${JSON.stringify(t,null,2)}
25
+ `+t:""),c=Math.floor(n.length/s)-this.cursorPos.rows+(t?Ui(t):0);if(c>0)i+=ro(c);i+=oo(this.cursorPos.cols),this.write(no(this.extraLinesUnderPrompt)+so(this.height)+i),this.extraLinesUnderPrompt=c,this.height=Ui(i)}checkCursorPos(){let e=this.rl.getCursorPos();if(e.cols!==this.cursorPos.cols)this.write(oo(e.cols)),this.cursorPos=e}done({clearContent:e}){this.rl.setPrompt("");let t=no(this.extraLinesUnderPrompt);t+=e?so(this.height):`
26
+ `,t+=to,t+=Ni,this.write(t),this.rl.close()}}class io extends Promise{static withResolver(){let e,t;return{promise:new Promise((n,o)=>{e=n,t=o}),resolve:e,reject:t}}}import If from"node:path";var Tf=globalThis.setImmediate;function Er(e,t,r){if("on"in e)return e.on(t,r),()=>e.removeListener(t,r);return e.addEventListener(t,r),()=>e.removeEventListener(t,r)}function Of(){let e=Error.prepareStackTrace,t=[];try{Error.prepareStackTrace=(r,n)=>{let o=n.slice(1);return t=o,o},Error().stack}catch{return t}return Error.prepareStackTrace=e,t}function Ue(e){let t=Of();return(n,o={})=>{let{input:s=process.stdin,signal:i}=o,a=new Set,c=new Mi.default;c.pipe(o.output??process.stdout);let u=Fi.createInterface({terminal:!0,input:s,output:c});c.mute();let l=new zr(u),{promise:p,resolve:d,reject:m}=io.withResolver();return ii(u,(f)=>{let g=Cf.bind(()=>Ut.clearAll()),x=(_)=>{try{g(),_()}catch(S){m(S)}},y=(_)=>x(()=>d(_)),w=(_)=>x(()=>m(_)),k=Object.assign(p.finally(()=>{a.forEach((_)=>_()),l.done({clearContent:Boolean(o.clearPromptOnDone)}),c.end()}).then(()=>p),{cancel:()=>w(new Bn)});if(i){let _=()=>w(new Mn({cause:i.reason}));if(i.aborted)return _(),k;a.add(Er(i,"abort",_))}a.add(Zi((_,S)=>{w(new vr(`User force closed the prompt with ${_} ${S}`))})),a.add(Er(u,"SIGINT",()=>w(new vr("User force closed the prompt with SIGINT")))),a.add(Er(u,"close",g));let I=()=>{a.add(Er(u.input,"keypress",()=>l.checkCursorPos()));let _=null;f(()=>{let S=!1;try{let O=e(n,(A)=>{if(S)y(A);else _={value:A}});if(O===void 0){let A=t[1]?.getFileName();if(A&&!A.startsWith("file://"))A=If.resolve(A);throw Error(`Prompt functions must return a string.
27
+ at ${A}`)}let[W,C]=typeof O==="string"?[O]:O;l.render(W,C),Ut.run()}catch(O){w(O)}if(S=!0,_!==null){let{value:O}=_;_=null,y(O)}})};if("readableFlowing"in s)Tf(I);else I();return k})}}import{styleText as Af}from"node:util";class Pe{separator=Af("dim",Array.from({length:15}).join(gt.line));type="separator";constructor(e){if(e)this.separator=e}static isSeparator(e){return Boolean(e&&typeof e==="object"&&"type"in e&&e.type==="separator")}}import{styleText as jf}from"node:util";var Rf={keywords:{yes:"Yes",no:"No"},style:{confirmDefault:(e)=>{let t=e[0]??"";if(t.toLowerCase()===t.toUpperCase())return jf("cyan",e);return t.toUpperCase()+e.slice(1)}}},Bi=Ue((e,t)=>{let[r,n]=N("idle"),[o,s]=N(""),i=_e(Rf,e.theme),a=Ze({status:r,theme:i}),{yes:c,no:u}=i.keywords,l=(c[0]??"").toLowerCase(),p=(u[0]??"").toLowerCase(),d=e.default===!1?`${l}/${i.style.confirmDefault(p)}`:`${i.style.confirmDefault(l)}/${p}`;function m(k){return k?c:u}let{transformer:f=m}=e;function g(k,I){let _=k.trim().toLowerCase();if(_==="")return I!==!1;if(c.toLowerCase().startsWith(_))return!0;if(u.toLowerCase().startsWith(_))return!1;return I!==!1}De((k,I)=>{if(r!=="idle")return;if(Re(k)){let _=g(o,e.default);s(f(_)),n("done"),t(_)}else if(Dt(k)){let _=m(!g(o,e.default));I.clearLine(0),I.write(_),s(_)}else s(I.line)});let x=o,y="";if(r==="done")x=i.style.answer(o);else y=` ${i.style.defaultAnswer(d)}`;let w=i.style.message(e.message,r);return`${a} ${w}${y} ${x}`});var Lf={validationFailureMode:"keep"},Gi=Ue((e,t)=>{let{prefill:r="tab"}=e,n=_e(Lf,e.theme),[o,s]=N("idle"),[i,a]=N(String(e.default??"")),[c,u]=N(),[l,p]=N(""),d=Ze({status:o,theme:n});async function m(w){let{required:k,pattern:I,patternError:_="Invalid input"}=e;if(k&&!w)return"You must provide a value";if(I&&!I.test(w))return _;if(typeof e.validate==="function")return await e.validate(w)||"You must provide a valid value";return!0}De(async(w,k)=>{if(o!=="idle")return;if(Re(w)){let I=l||i;s("loading");let _=await m(I);if(_===!0)p(I),s("done"),t(I);else{if(n.validationFailureMode==="clear")p("");else k.write(l);u(_),s("idle")}}else if(Zt(w)&&!l)a("");else if(Dt(w)&&!l)a(""),k.clearLine(0),k.write(i),p(i);else p(k.line),u(void 0)}),Le((w)=>{if(r==="editable"&&i)w.write(i),p(i)},[]);let f=n.style.message(e.message,o),g=l;if(typeof e.transformer==="function")g=e.transformer(l,{isFinal:o==="done"});else if(o==="done")g=n.style.answer(l);let x;if(i&&o!=="done"&&!l)x=n.style.defaultAnswer(i);let y="";if(c)y=n.style.error(c);return[[d,f,x,g].filter((w)=>w!==void 0).join(" "),y]});import{styleText as ao}from"node:util";var Zf={style:{maskedText:"[input is masked]",keysHelpTip:(e)=>e.map(([t,r])=>`${ao("bold",t)} ${ao("dim",r)}`).join(ao("dim"," • "))}},Vi=Ue((e,t)=>{let{toggleMask:r=!0,validate:n=()=>!0}=e,o=_e(Zf,e.theme),[s,i]=N("idle"),[a,c]=N(),[u,l]=N(""),[p,d]=N(!1),m=Ze({status:s,theme:o});De(async(k,I)=>{if(s!=="idle")return;if(Re(k)){let _=u;i("loading");let S=await n(_);if(S===!0)l(_),i("done"),t(_);else I.write(u),c(S||"You must provide a valid value"),i("idle")}else if(r&&k.ctrl&&k.name==="t")d((_)=>!_);else l(I.line),c(void 0)});let f=o.style.message(e.message,s),g=r&&p&&s==="idle",x="";if(g)x=u;else if(e.mask)x=(typeof e.mask==="string"?e.mask:"*").repeat(u.length);else if(s!=="done")x=o.style.help(o.style.maskedText);if(s==="done")x=o.style.answer(x);else if(!e.mask)x+=kr;let y=[m,f,x].filter(Boolean).join(" "),w=[a?o.style.error(a):"",r&&s==="idle"?o.style.keysHelpTip([["ctrl+t","toggle visibility"]]):""].filter(Boolean).join(`
28
+ `);return[y,w]});import{styleText as Bt}from"node:util";var Df={icon:{cursor:gt.pointer},style:{disabled:(e)=>Bt("dim",e),description:(e)=>Bt("cyan",e),keysHelpTip:(e)=>e.map(([t,r])=>`${Bt("bold",t)} ${Bt("dim",r)}`).join(Bt("dim"," • "))},i18n:{disabledError:"This option is disabled and cannot be selected."},indexMode:"hidden"};function co(e){return!Pe.isSeparator(e)&&!e.disabled}function uo(e){return!Pe.isSeparator(e)}function Nf(e){return e.map((t)=>{if(Pe.isSeparator(t))return t;if(typeof t!=="object"||t===null||!("value"in t)){let o=String(t);return{value:t,name:o,short:o,disabled:!1}}let r=t.name??String(t.value),n={value:t.value,name:r,short:t.short??r,disabled:t.disabled??!1};if(t.description)n.description=t.description;return n})}var Wi=Ue((e,t)=>{let{loop:r=!0,pageSize:n=7}=e,o=_e(Df,e.theme),{keybindings:s}=o,[i,a]=N("idle"),c=Ze({status:i,theme:o}),u=nt(),l=!s.includes("vim"),p=Ft(()=>Nf(e.choices),[e.choices]),d=Ft(()=>{let C=p.findIndex(uo),A=p.findLastIndex(uo);if(C===-1)throw new Nt("[select prompt] No selectable choices. All choices are disabled.");return{first:C,last:A}},[p]),m=Ft(()=>{if(!("default"in e))return-1;return p.findIndex((C)=>co(C)&&C.value===e.default)},[e.default,p]),[f,g]=N(m===-1?d.first:m),x=p[f];if(x==null||Pe.isSeparator(x))throw Error("Active index does not point to a choice");let[y,w]=N();De((C,A)=>{if(clearTimeout(u.current),y)w(void 0);if(Re(C))if(x.disabled)w(o.i18n.disabledError);else a("done"),t(x.value);else if(Lt(C,s)||wr(C,s)){if(A.clearLine(0),r||Lt(C,s)&&f!==d.first||wr(C,s)&&f!==d.last){let B=Lt(C,s)?-1:1,K=f;do K=(K+B+p.length)%p.length;while(!uo(p[K]));g(K)}}else if(Fn(C)&&!Number.isNaN(Number(A.line))){let B=Number(A.line)-1,K=-1,ge=p.findIndex((It)=>{if(Pe.isSeparator(It))return!1;return K++,K===B}),Tn=p[ge];if(Tn!=null&&co(Tn))g(ge);u.current=setTimeout(()=>{A.clearLine(0)},700)}else if(Zt(C))A.clearLine(0);else if(l){let B=A.line.toLowerCase(),K=p.findIndex((ge)=>{if(Pe.isSeparator(ge)||!co(ge))return!1;return ge.name.toLowerCase().startsWith(B)});if(K!==-1)g(K);u.current=setTimeout(()=>{A.clearLine(0)},700)}}),Le(()=>()=>{clearTimeout(u.current)},[]);let k=o.style.message(e.message,i),I=o.style.keysHelpTip([["↑↓","navigate"],["⏎","select"]]),_=0,S=qn({items:p,active:f,renderItem({item:C,isActive:A,index:B}){if(Pe.isSeparator(C))return _++,` ${C.separator}`;let K=A?o.icon.cursor:" ",ge=o.indexMode==="number"?`${B+1-_}. `:"";if(C.disabled){let It=typeof C.disabled==="string"?C.disabled:"(disabled)",Pm=A?o.icon.cursor:"-";return o.style.disabled(`${Pm} ${ge}${C.name} ${It}`)}return(A?o.style.highlight:(It)=>It)(`${K} ${ge}${C.name}`)},pageSize:n,loop:r});if(i==="done")return[c,k,o.style.answer(x.short)].filter(Boolean).join(" ");let{description:O}=x;return`${[[c,k].filter(Boolean).join(" "),S," ",O?o.style.description(O):"",y?o.style.error(y):"",I].filter(Boolean).join(`
29
+ `).trimEnd()}${kr}`});var be=mt(Tt(),1);class E extends Error{hint;exitCode;constructor(e,t={}){super(e);this.name="CliError",this.hint=t.hint,this.exitCode=t.exitCode??1}}var Z=(e,t)=>new E(e,{exitCode:2,hint:t}),we=(e)=>e<1000?`${Math.round(e)}ms`:`${Math.round(e/1000)}s`,Uf=[["d",86400000],["h",3600000],["m",60000],["s",1000]],xt=(e)=>{let t=Math.max(0,e);for(let[r,n]of Uf)if(t>=n)return`${Math.round(t/n)}${r}`;return`${Math.round(t)}ms`},Ji=(e)=>{let t=Math.max(0,Math.floor(e/60000)),r=Math.floor(t/60);return r>0?`${r}h ${t%60}m`:`${t}m`},ie=(e)=>{process.stderr.write(`${e}
30
+ `)},T=(e)=>{ie(`${be.default.dim(">")} ${e}`)},Q=(e,t)=>{let r=t===void 0?"":`[${we(t)}]`,n=r?` ${be.default.dim(r)}`:"";ie(`${be.default.cyan("> Success!")} ${e}${n}`)},Ve=(e)=>{ie(`${be.default.bold(be.default.yellow("> NOTE:"))} ${e}`)},Hi=(e)=>{if(ie(`${be.default.bold(be.default.red("Error:"))} ${e.message}`),e.hint)ie(`${be.default.dim(">")} ${e.hint}`)},Ki=["⠋","⠙","⠹","⠸","⠼","⠴","⠦","⠧","⠇","⠏"],Ff=300,Mf="\r\x1B[2K",G=async(e,t)=>{if(!process.stderr.isTTY)return t();let r=0,n=!1,o,s=()=>{n=!0;let a=Ki[r%Ki.length]??"";r+=1,process.stderr.write(`\r${be.default.dim(a)} ${e}`)},i=setTimeout(()=>{s(),o=setInterval(s,80)},Ff);try{return await t()}finally{if(clearTimeout(i),clearInterval(o),n)process.stderr.write(Mf)}},Cr=async(e)=>{try{return await e()}catch(t){if(t instanceof Error&&t.name==="ExitPromptError")throw new E("Canceled",{exitCode:130});throw t}},qi=(e)=>{let t={output:e.stderr};return{choice:(r)=>Cr(()=>Wi(r,t)),confirm:(r)=>Cr(()=>Bi(r,t)),interactive:e.stdin.isTTY===!0&&e.stderr.isTTY===!0,secret:(r)=>Cr(()=>Vi({mask:"*",message:r},t)),text:(r)=>Cr(()=>Gi({...r,required:r.required??!0},t))}},Yi=(e)=>({isTTY:e.isTTY===!0,json:(t)=>{e.write(`${JSON.stringify(t,null,2)}
31
31
  `)},line:(t)=>{e.write(`${t}
32
- `)},write:(t)=>{e.write(t)}}),{bold:k,cyan:Sm,dim:Y,gray:Ge,green:$r,red:Gi,yellow:Vi}=be.default,km=" ".repeat(5),Pm=(e)=>k(Sm(e)),ke=(e)=>{let{headings:t,marks:r,rows:n}=e,o=t.map((i,a)=>Math.max(i.length,...n.map((c)=>c[a]?.text.length??0))),s=(i)=>i.map((a,c)=>{let l=c===i.length-1?a.text:a.text.padEnd(o[c]??0);return a.paint?a.paint(l):l}).join(km);oe(""),oe(` ${s(t.map((i)=>({paint:Pm,text:i})))}`);for(let[i,a]of n.entries())oe(`${r?.[i]??" "} ${s(a)}`);oe("")};var Ji=(e)=>new Map(e.flatMap((t)=>ne(t).map((r)=>[r,t]))),io=(e)=>`Use one of: ${e.join(", ")}.`,Hi=(e,t)=>{if(e.value.kind==="choice"&&!e.value.choices.includes(t))throw N(`unknown ${e.long} "${t}"`,io(e.value.choices));return t},Wi=(e)=>{let{flag:t,hints:r,name:n,next:o}=e;if(o===void 0||o.startsWith("-"))throw N(`${n} needs${zt(t.value)}`,`Usage: ${r.usage}`);return Hi(t,o)},qi=(e)=>{let{hints:t,index:r,next:n,word:o}=e;if(o.startsWith("--")){let l=o.indexOf("="),p=l===-1?o:o.slice(0,l),d=r.get(p);if(!d)return;if(d.value.kind==="none"){if(l!==-1)throw N(`${p} doesn't take a value`,`Usage: ${t.usage}`);return{options:[{flag:d,value:!0}],used:1}}if(l!==-1)return{options:[{flag:d,value:Hi(d,o.slice(l+1))}],used:1};return{options:[{flag:d,value:Wi({flag:d,hints:t,name:p,next:n})}],used:2}}let s=[...o].slice(1),a=s.map((l)=>r.get(`-${l}`)).filter((l)=>l!==void 0);if(a.length!==s.length)return;let c=[],u=1;for(let[l,p]of a.entries())if(p.value.kind==="none")c.push({flag:p,value:!0});else if(l===a.length-1)c.push({flag:p,value:Wi({flag:p,hints:t,name:`-${s[l]}`,next:n})}),u=2;else throw N(`-${s[l]} needs${zt(p.value)}`,`Usage: ${t.usage}`);return{options:c,used:u}},so=(e,t)=>{let r=e.flatMap((n)=>{let o=t.get(n.long);return o===void 0?[]:[[n.long,o]]});return Object.fromEntries(r)},zm={command:"nipa",usage:"nipa [options] <command>"},Em=Ji(re),Ki=(e)=>{let{at:t,words:r}=e,n=r[t];if(n===void 0||n==="--"||n==="-"||!n.startsWith("-"))return;let o=qi({hints:zm,index:Em,next:r[t+1],word:n});if(!o&&e.unknown==="reject")throw N(`unknown option "${n}"`,"Run `nipa --help` to see the options.");return o},ao=(e)=>{let{unknown:t,words:r}=e,n=new Map,o=0;for(let s=Ki({at:o,unknown:t,words:r});s!==void 0;s=Ki({at:o,unknown:t,words:r})){for(let{flag:i,value:a}of s.options)n.set(i.long,a);o+=s.used}return{globals:so(re,n),rest:r.slice(o)}},Yi=(e)=>{let t=e.indexOf("--"),r=t===-1?e:e.slice(0,t),n=new Set(ne(In));return r.some((o)=>n.has(o))},Cm=(e)=>{let{flags:t,hints:r,words:n}=e,o=Ji([...t,...re]),s=new Set(t.map((l)=>l.long)),i=new Map,a=new Map,c=[],u=0;while(u<n.length){let l=n[u]??"";if(l==="--"){c.push(...n.slice(u+1));break}if(l.startsWith("-")&&l!=="-"){let p=qi({hints:r,index:o,next:n[u+1],word:l});if(!p)throw N(`unknown option "${l}"`,`Run \`${r.command} --help\` to see the options.`);for(let{flag:d,value:f}of p.options)(s.has(d.long)?i:a).set(d.long,f);u+=p.used}else c.push(l),u+=1}return{globals:a,own:i,positionals:c}},oo=(e,t)=>{if(e.value.kind==="choice"&&!e.value.choices.includes(t))throw N(`unknown ${e.name} "${t}"`,io(e.value.choices));return t},Im=(e)=>{let t=[...e.positionals],r=e.args.map((o)=>{switch(o.arity){case"one":{let s=t.shift();if(s===void 0)throw N(`missing <${o.name}>`,o.value.kind==="choice"?io(o.value.choices):`Usage: ${e.hints.usage}`);return[o.name,oo(o,s)]}case"optional":{let s=t.shift();return[o.name,s===void 0?void 0:oo(o,s)]}case"rest":return[o.name,t.splice(0).map((s)=>oo(o,s))];default:return o.arity}}),[n]=t;if(n!==void 0)throw N(`unexpected argument "${n}"`,`Usage: ${e.hints.usage}`);return Object.fromEntries(r)},Xi=(e)=>{let{path:t,spec:r,words:n}=e,o={command:pr(t),usage:It(t)},s=Cm({flags:r.flags,hints:o,words:n});return{globals:so(re,s.globals),input:{args:Im({args:r.args,hints:o,positionals:s.positionals}),flags:so(r.flags,s.own)}}};var Z=(e)=>({...e,kind:"leaf"}),Pe=(e)=>({...e,kind:"group"}),mt=(e)=>({...e,kind:"passthrough"}),A=(e,t)=>({kind:"leaf",prepare:({path:r,words:n})=>{let o=Xi({path:r,spec:e,words:n});return{globals:o.globals,run:(s)=>t({...o.input,client:s})}},spec:e}),ze=(e,t)=>{let r=Object.values(t),n=new Map(r.flatMap((o)=>q(o.spec).map((s)=>[s,o])));return{fallback:t[e.default],kind:"group",spec:e,subcommands:n}},Tm=(e,t)=>{let{target:r}=e;switch(r.kind){case"program":return{args:t,command:r.program};case"openstack":return{args:t,command:"openstack"};case"command":{let[n,...o]=t;if(n===void 0)throw N("missing <command>",`Usage: ${It([e])}`);return{args:o,command:n}}default:return r}},ht=(e,t)=>({kind:"passthrough",run:({client:r,words:n})=>t({...Tm(e,n),client:r}),spec:e}),Qi=(e)=>e.spec,ea=(e)=>({examples:e.examples,hidden:e.hidden.map(Qi),sections:e.sections.map((t)=>({commands:t.commands.map(Qi),title:t.title})),summary:e.summary});function Ut(e){let t=Object.values(e).filter((n)=>typeof n==="number");return Object.entries(e).filter(([n,o])=>t.indexOf(+n)===-1).map(([n,o])=>o)}function uo(e,t="|"){return e.map((r)=>fo(r)).join(t)}function Mt(e,t){if(typeof t==="bigint")return t.toString();return t}class ta{constructor(e){this._getter=e,this._value=void 0}get value(){let e=this._getter;if(e!==void 0)this._value=e(),this._getter=void 0;return this._value}}function Sr(e){return new ta(e)}function ra(e){return e===null||e===void 0}function kr(e){let t=e.startsWith("^")?1:0,r=e.endsWith("$")?e.length-1:e.length;return e.slice(t,r)}function na(e,t){let r=e/t,n=Math.round(r),o=4*Number.EPSILON*Math.max(Math.abs(r),1);if(Math.abs(r-n)<o)return 0;return r-n}function ve(e,t,r){Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0})}function Pr(e){let t=Object.getOwnPropertyDescriptor(e,"shape");return t?.get?t.get.raw:t?.value}function Fe(e){return Pr(e._zod.def)??e._zod.def.shape}function oa(e,t,r){Object.defineProperty(e,t,{get(){let n=r();return ve(this,t,n),n},enumerable:!0,configurable:!0})}function sa(e,t,r){if(t in e)ve(e,t,r);else e[t]=r}function rt(e,t,r,n){let o=Fe(t);for(let s of r){let i=Object.getOwnPropertyDescriptor(o,s);if(!i.enumerable)continue;if(i.get)oa(e,s,()=>{let a=t._zod.def.shape[s];return n?n(a,s):a});else sa(e,s,n?n(i.value,s):i.value)}}function Om(e,t){for(let r of Reflect.ownKeys(t)){let n=Object.getOwnPropertyDescriptor(t,r);if(!n.enumerable)continue;if(n.get)oa(e,r,()=>t[r]);else sa(e,r,n.value)}}function se(...e){let t={};for(let r of e){let n=Object.getOwnPropertyDescriptors(r);Object.assign(t,n)}return Object.defineProperties({},t)}function ia(e){return JSON.stringify(e)}function aa(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}var lo="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function Ft(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}var ca=Sr(()=>{if(X.jitless)return!1;if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{return new Function(""),!0}catch(e){return!1}});function nt(e){if(Ft(e)===!1)return!1;let t=e.constructor;if(t===void 0)return!0;if(typeof t!=="function")return!0;let r=t.prototype;if(Ft(r)===!1)return!1;if(Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)return!1;return!0}function po(e){if(nt(e))return{...e};if(Array.isArray(e))return[...e];if(e instanceof Map)return new Map(e);if(e instanceof Set)return new Set(e);return e}var ua=new Set(["string","number","symbol"]);function gt(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function $e(e,t,r){let n=new e._zod.constr(t??e._zod.def);if(!t||r?.parent)n._zod.parent=e;return n}function v(e){let t=e;if(!t)return{};if(typeof t==="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");t.error=t.message}if(delete t.message,typeof t.error==="string")return{...t,error:()=>t.error};return t}function fo(e){if(typeof e==="bigint")return e.toString()+"n";if(typeof e==="string")return`"${e}"`;return`${e}`}function la(e){return Object.keys(e).filter((t)=>e[t]._zod.optin!==void 0&&e[t]._zod.optout==="optional")}var zr=(()=>({safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-340282346638528860000000000000000000000,340282346638528860000000000000000000000],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]}))(),mo={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function Am(e,t){let r=e._zod.def,n=r.checks;if(n&&n.length>0)throw Error(".pick() cannot be used on object schemas containing refinements");let s={};return rt(s,e,Er(e,t)),$e(e,se(r,{shape:s,checks:[]}))}function Er(e,t){let r=Fe(e),n=[];for(let o of Reflect.ownKeys(t)){if(!Object.getOwnPropertyDescriptor(r,o)?.enumerable)throw Error(`Unrecognized key: "${String(o)}"`);if(t[o])n.push(o)}return n}function jm(e,t){let r=e._zod.def,n=r.checks;if(n&&n.length>0)throw Error(".omit() cannot be used on object schemas containing refinements");let s=new Set(Er(e,t)),i={};return rt(i,e,Reflect.ownKeys(Fe(e)).filter((a)=>!s.has(a))),$e(e,se(r,{shape:i,checks:[]}))}function Rm(e,t){if(!nt(t))throw Error("Invalid input to extend: expected a plain object");let r=e._zod.def.checks;if(r&&r.length>0){let o=Fe(e);for(let s of Reflect.ownKeys(t))if(Object.getOwnPropertyDescriptor(o,s)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return $e(e,se(e._zod.def,{shape:pa(e,t)}))}function pa(e,t){let r={};return rt(r,e,Reflect.ownKeys(Fe(e))),Om(r,t),r}function Zm(e,t){if(!nt(t))throw Error("Invalid input to safeExtend: expected a plain object");return $e(e,se(e._zod.def,{shape:pa(e,t)}))}function Lm(e,t){if(!t?._zod?.def)throw Error("Invalid input to merge: expected an object schema. To merge a plain shape, use `.extend()`.");if(e._zod.def.checks?.length)throw Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");let r={};rt(r,e,Reflect.ownKeys(Fe(e))),rt(r,t,Reflect.ownKeys(Fe(t)));let n=se(e._zod.def,{shape:r,get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return $e(e,n)}function da(e,t,r,n="partial"){let s=t._zod.def.checks;if(s&&s.length>0)throw Error(`.${n}() cannot be used on object schemas containing refinements`);let a=r?new Set(Er(t,r)):void 0,c={};return rt(c,t,Reflect.ownKeys(Fe(t)),e&&((u,l)=>a&&!a.has(l)?u:new e({type:"optional",innerType:u}))),$e(t,se(t._zod.def,{shape:c,checks:[]}))}function Dm(e,t,r){let n=r?new Set(Er(t,r)):void 0,o={};return rt(o,t,Reflect.ownKeys(Fe(t)),(s,i)=>n&&!n.has(i)?s:new e({type:"nonoptional",innerType:s})),$e(t,se(t._zod.def,{shape:o}))}function Ee(e,t=0){if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(e.issues[r]?.continue!==!0)return!0;return!1}function fa(e,t=0){if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(e.issues[r]?.continue===!1)return!0;return!1}function We(e,t){return t.map((r)=>{var n;return(n=r).path??(n.path=[]),r.path.unshift(e),r})}function Nt(e){return typeof e==="string"?e:e?.message}function ho(e,t,r){var n;for(let o=t;o<e.length;o++)(n=e[o]).schema??(n.schema=r)}function Ce(e,t,r){var n;let o=e.inst?._zod?.traits;if(o?.has("$ZodType"))if(o.has("$ZodCheck"))(n=e).schema??(n.schema=e.inst);else e.schema=e.inst;let s=e.schema!==e.inst?e.schema?._zod.def?.error:void 0,i=e.message?e.message:Nt(e.inst?._zod.def?.error?.(e))??Nt(s?.(e))??Nt(t?.error?.(e))??Nt(r.customError?.(e))??Nt(r.localeError?.(e))??"Invalid input",a={};for(let c of Object.keys(e)){if(c==="inst"||c==="schema"||c==="continue"||c==="input"||c==="__proto__")continue;a[c]=e[c]}if(a.path??(a.path=[]),a.message=i,t?.reportInput)a.input=e.input;return a}var Nm=/[\uD800-\uDBFF]/;function Cr(e){let t=e.length;if(!Nm.test(e))return t;let r=t;for(let n=0;n<t-1;n++)if((e.charCodeAt(n)&64512)===55296&&(e.charCodeAt(n+1)&64512)===56320)r--,n++;return r}function Ir(e){if(Array.isArray(e))return"array";if(typeof e==="string")return"string";return"unknown"}function ma(e){let t=typeof e;switch(t){case"number":return Number.isNaN(e)?"nan":"number";case"object":{if(e===null)return"null";if(Array.isArray(e))return"array";let r=e;if(r&&Object.getPrototypeOf(r)!==Object.prototype&&"constructor"in r&&r.constructor)return r.constructor.name}}return t}function ot(...e){let[t,r,n]=e;if(typeof t==="string")return{message:t,code:"custom",input:r,inst:n};return{...t}}function ha(e,t){for(let r in t){let n=Object.getOwnPropertyDescriptor(t,r);if(n.get)Object.defineProperty(e,r,{...n,enumerable:!1});else Fm(e,r,n.value)}}function Ue(e,t,r,n=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:n,value:r}),r}function Tr(e,t,r){return Ue(e,t,r,!1)}function ga(e,t){for(let r in e){let n=e[r];Object.defineProperty(t,r,{configurable:!0,enumerable:!0,get(){return Ue(this,r,n(this))},set(o){Ue(this,r,o)}})}return t}function Fm(e,t,r){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?r:Ue(this,t,r.bind(this))},set(n){Ue(this,t,n)}})}function Um(e,t){let r=Object.getPrototypeOf(e);return t in r?void 0:r}var co,Ve=!1,Mm={configurable:!0,get(){Ve=!0;return}};function j(e,t,r){let n=Object.getPrototypeOf(e._zod);if(t in n&&co!==e._zod){co=void 0;return}co=e._zod,Object.defineProperty(n,t,{configurable:!0,get(){Object.defineProperty(this,t,Mm);let o=Ve;Ve=!1;try{let s=r(this);if(Ve)delete this[t];else Object.defineProperty(this,t,{configurable:!0,writable:!0,value:s});return Ve=Ve||o,s}catch(s){throw delete this[t],Ve=Ve||o,s}},set(o){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:o})}})}function Bm(e,t,r,n){let o=Um(e,t);if(!o)return;Object.defineProperty(o,t,{configurable:!0,get(){let s={configurable:!0,writable:!0,enumerable:n,value:void 0};return Object.defineProperty(this,t,s),s.value=r(this),Object.defineProperty(this,t,s),s.value},set(s){Object.defineProperty(this,t,{configurable:!0,writable:!0,enumerable:n,value:s})}})}var Gm="~constantCatch";function xa(e){let t=()=>e;return t[Gm]=!0,t}var ya;var go={value:void 0,enumerable:!1},_a="captureStackTrace"in Error?Error:null;function Vm(e){let t=_a;if(t){let r=t.stackTraceLimit;if(typeof r==="number"){try{t.stackTraceLimit=0}catch{return _a=null,new e}try{return new e}finally{t.stackTraceLimit=r}}}return new e}function h(e,t,r,n){let o={};function s(d){this.def=d,this.constr=p,this.traits=new Set}s.prototype=o;let i=r,a=i&&new WeakSet;function c(d,f){if(!d._zod){go.value=new s(f);try{Object.defineProperty(d,"_zod",go)}finally{go.value=void 0}}else if(d._zod.traits.has(e))return;if(d._zod.traits.add(e),t(d,f),a){let g=Object.getPrototypeOf(d),x=d._zod.constr.prototype,_=g;while(_&&_!==x)_=Object.getPrototypeOf(_);let w=_??g;if(!a.has(w))a.add(w),ha(w,i)}let m=p.prototype;for(let g in m){if(!Object.prototype.hasOwnProperty.call(m,g))continue;if(!(g in d))d[g]=m[g].bind(d)}}let u=n?.Parent??Object;class l extends u{}Object.defineProperty(l,"name",{value:e});function p(d){let f=n?.Parent?Vm(l):this;c(f,d);let m=f._zod.deferred;if(m){for(let x of m)x();f._zod.deferred=void 0}let g=globalThis.__zod_globalConfig?.postProcessor;if(g)g(f);return f}return Object.defineProperty(p,"init",{value:c}),Object.defineProperty(p,Symbol.hasInstance,{value:(d)=>{if(n?.Parent&&d instanceof n.Parent)return!0;return d?._zod?.traits?.has(e)}}),Object.defineProperty(p,"name",{value:e}),p}class Ie extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class Bt extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`);this.name="ZodEncodeError"}}(ya=globalThis).__zod_globalConfig??(ya.__zod_globalConfig={});var X=globalThis.__zod_globalConfig;function Q(e){if(e)Object.assign(X,e);return X}function Wm(){let e=this._zod;return e.message??(e.message=JSON.stringify(e.def,Mt,2)),e.message}function Km(e){this._zod.message=e}var Jm={get:Wm,set:Km,enumerable:!0,configurable:!0},yo={value:void 0,enumerable:!1},ba=new WeakSet([Object.prototype,Error.prototype]),wa=(e,t)=>{e.name="$ZodError",yo.value=t,Object.defineProperty(e,"issues",yo),yo.value=void 0,Object.defineProperty(e,"message",Jm);let r=Object.getPrototypeOf(e);if(!ba.has(r))ba.add(r),Object.defineProperty(r,"toString",{configurable:!0,enumerable:!1,get(){let n=()=>this.message;return Object.defineProperty(this,"toString",{value:n,configurable:!0,writable:!0}),n},set(n){Object.defineProperty(this,"toString",{value:n,configurable:!0,writable:!0})}})},va=h("$ZodError",wa),Yb=h("$ZodError",wa,void 0,{Parent:Error});function Hm(e,t,r){if(!Object.prototype.hasOwnProperty.call(e,t))if(t==="__proto__")Object.defineProperty(e,t,{value:r(),writable:!0,enumerable:!0,configurable:!0});else e[t]=r();return e[t]}function _o(e,t=(r)=>r.message){let r={},n=[];for(let o of e.issues)if(o.path.length>0)Hm(r,o.path[0],()=>[]).push(t(o));else n.push(t(o));return{formErrors:n,fieldErrors:r}}function bo(e,t=(r)=>r.message){let r={_errors:[]},n=(o,s=[])=>{for(let i of o.issues)if(i.code==="invalid_union"&&i.errors.length)i.errors.map((a)=>n({issues:a},[...s,...i.path]));else if(i.code==="invalid_key")n({issues:i.issues},[...s,...i.path]);else if(i.code==="invalid_element")n({issues:i.issues},[...s,...i.path]);else{let a=[...s,...i.path];if(a.length===0)r._errors.push(t(i));else{let c=r,u=0;while(u<a.length){let l=a[u],p=u===a.length-1;if(l==="_errors"){if(p)c._errors.push(t(i));u++;continue}if(!Object.prototype.hasOwnProperty.call(c,l))Object.defineProperty(c,l,{value:{_errors:[]},enumerable:!0,writable:!0,configurable:!0});let d=c[l];if(p)d._errors.push(t(i));c=d,u++}}}};return n(e),r}function qm(e){let t=[],r=e.map((n)=>typeof n==="object"?n.key:n);for(let n of r)if(typeof n==="number")t.push(`[${n}]`);else if(typeof n==="symbol")t.push(`[${JSON.stringify(String(n))}]`);else if(/[^\w$]/.test(n))t.push(`[${JSON.stringify(n)}]`);else{if(t.length)t.push(".");t.push(n)}return t.join("")}function Gt(e){let t=[],r=[...e.issues].sort((n,o)=>(n.path??[]).length-(o.path??[]).length);for(let n of r)if(t.push(`✖ ${n.message}`),n.path?.length)t.push(` → at ${qm(n.path)}`);return t.join(`
33
- `)}function Or(e,t){return{callee:t?.callee??e,Err:t?.Err}}var Ar=(e)=>{let t=(r,n,o,s)=>{let i=o?{...o,async:!1}:{async:!1},a=r._zod.run({value:n,issues:[]},i);if(a instanceof Promise)throw new Ie;if(a.issues.length){let c=new(s?.Err??e)(a.issues.map((u)=>Ce(u,i,Q())));throw lo(c,s?.callee??t),c}return a.value};return t};var jr=(e)=>{let t=async(r,n,o,s)=>{let i=o?{...o,async:!0}:{async:!0},a=r._zod.run({value:n,issues:[]},i);if(a instanceof Promise)a=await a;if(a.issues.length){let c=new(s?.Err??e)(a.issues.map((u)=>Ce(u,i,Q())));throw lo(c,s?.callee??t),c}return a.value};return t};var Rr=(e)=>(t,r,n)=>{let o=n?{...n,async:!1}:{async:!1},s=t._zod.run({value:r,issues:[]},o);if(s instanceof Promise)throw new Ie;return s.issues.length?$a(e,s.issues,o):{success:!0,data:s.value}};function $a(e,t,r){let n;return{success:!1,get error(){if(!n)n=new e(t.map((o)=>Ce(o,r,Q()))),t=void 0,r=void 0;return n},set error(o){n=o,t=void 0,r=void 0}}}var Zr=(e)=>async(t,r,n)=>{let o=n?{...n,async:!0}:{async:!0},s=t._zod.run({value:r,issues:[]},o);if(s instanceof Promise)s=await s;return s.issues.length?$a(e,s.issues,o):{success:!0,data:s.value}};var Ym=Symbol.for("zod.compile.invalid"),Xm=Symbol.for("zod.compile.fallback"),wo=(e,t,r)=>{let n=e._zod.bag.validator;if(n!==void 0){if(n(t)!==Ym)return!0;if(n.definite===!0&&r===void 0)return!1}return Qm(e,t,r)};function Qm(e,t,r){let n=r?{...r,async:!1,abortEarly:!0}:{async:!1,abortEarly:!0},o=e._zod.bag.fallbackRun,s;if(o)n[Xm]=!0,s=o({value:t,issues:[]},n);else s=e._zod.run({value:t,issues:[]},n);if(s instanceof Promise)throw new Ie;return s.issues.length===0}var vo=async(e,t,r)=>{let n=r?{...r,async:!0,abortEarly:!0}:{async:!0,abortEarly:!0},o=e._zod.run({value:t,issues:[]},n);if(o instanceof Promise)o=await o;return o.issues.length===0},Sa=(e)=>{let t=Ar(e),r=(n,o,s,i)=>{let a=s?{...s,direction:"backward"}:{direction:"backward"};return t(n,o,a,Or(r,i))};return r};var ka=(e)=>{let t=Ar(e),r=(n,o,s,i)=>t(n,o,s,Or(r,i));return r};var Pa=(e)=>{let t=jr(e),r=async(n,o,s,i)=>{let a=s?{...s,direction:"backward"}:{direction:"backward"};return await t(n,o,a,Or(r,i))};return r};var za=(e)=>{let t=jr(e),r=async(n,o,s,i)=>await t(n,o,s,Or(r,i));return r};var Ea=(e)=>(t,r,n)=>{let o=n?{...n,direction:"backward"}:{direction:"backward"};return Rr(e)(t,r,o)};var Ca=(e)=>(t,r,n)=>Rr(e)(t,r,n);var Ia=(e)=>async(t,r,n)=>{let o=n?{...n,direction:"backward"}:{direction:"backward"};return Zr(e)(t,r,o)};var Ta=(e)=>async(t,r,n)=>Zr(e)(t,r,n);var Oa=/^[cC][0-9a-z]{6,}$/,Aa=/^[0-9a-z]+$/,ja=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,Ra=/^[0-9a-vA-V]{20}$/,Za=/^[A-Za-z0-9]{27}$/,La=/^[a-zA-Z0-9_-]{21}$/;function Da(e){return new RegExp(`^[a-zA-Z0-9_-]{${e}}$`)}var Na=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;var Fa=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,So=(e)=>{if(!e)return/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/;return new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`)};var Ua=/^(?:[A-Za-z0-9_'+\-]+\.)*[A-Za-z0-9_'+\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;var eh="^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$";function Ma(){return new RegExp(eh,"u")}var Ba=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,Ga=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/;var Va=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,Wa=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Ka=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Ja=/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/;var Ha=/^https?$/,qa=/^\+[1-9]\d{6,14}$/;var Ya="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))";function th(e){return new RegExp(`^${e}$`)}var Xa=th(Ya);function $o(e){return typeof e.precision==="number"?e.precision===-1?"(?:[01]\\d|2[0-3]):[0-5]\\d":e.precision===0?"(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d":`(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d\\.\\d{${e.precision}}`:e.seconds?"(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?":"(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?"}function Qa(e){return new RegExp(`^${$o(e)}$`)}function ec(e){let t=["Z"];if(e.offset)t.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");let r=`${$o({precision:e.precision,seconds:!0})}(?:${t.join("|")})`,n=e.local?`${r}|${$o({precision:e.precision})}`:r;return new RegExp(`^${Ya}T(?:${n})$`)}var tc=/^[\s\S]{0,}$/;var ko=/^-?\d+$/,Vt=/^-?\d+(?:\.\d+)?$/,rc=/^(?:true|false)$/i;var nc=/^[^A-Z]*$/,oc=/^[^a-z]*$/;var J=h("$ZodCheck",(e,t)=>{var r;e._zod??(e._zod={}),e._zod.def=t,(r=e._zod).onattach??(r.onattach=[])});var Po=(e)=>{let t=e.value;return!ra(t)&&t.length!==void 0},Lr={number:"number",bigint:"bigint",object:"date"},zo=h("$ZodCheckLessThan",(e,t)=>{J.init(e,t);let r=Lr[typeof t.value];e._zod.check=(n)=>{if(t.inclusive?n.value<=t.value:n.value<t.value)return;n.issues.push({origin:Lr[typeof n.value]??r,code:"too_big",maximum:typeof t.value==="object"?t.value.getTime():t.value,input:n.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Eo=h("$ZodCheckGreaterThan",(e,t)=>{J.init(e,t);let r=Lr[typeof t.value];e._zod.check=(n)=>{if(t.inclusive?n.value>=t.value:n.value>t.value)return;n.issues.push({origin:Lr[typeof n.value]??r,code:"too_small",minimum:typeof t.value==="object"?t.value.getTime():t.value,input:n.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),sc=h("$ZodCheckMultipleOf",(e,t)=>{J.init(e,t),e._zod.check=(r)=>{if(typeof r.value!==typeof t.value)throw Error("Cannot mix number and bigint in multiple_of check.");if(typeof r.value==="bigint"?t.value!==BigInt(0)&&r.value%t.value===BigInt(0):na(r.value,t.value)===0)return;r.issues.push({origin:typeof r.value,code:"not_multiple_of",divisor:t.value,input:r.value,inst:e,continue:!t.abort})}}),ic=h("$ZodCheckNumberFormat",(e,t)=>{J.init(e,t),t.format=t.format||"float64";let r=t.format?.includes("int"),n=r?"int":"number",[o,s]=zr[t.format];e._zod.check=(i)=>{let a=i.value;if(r){if(!Number.isInteger(a)){i.issues.push({expected:n,format:t.format,code:"invalid_type",continue:!1,input:a,inst:e});return}if(!Number.isSafeInteger(a)){if(a>0)i.issues.push({input:a,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:n,inclusive:!0,continue:!t.abort});else i.issues.push({input:a,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:n,inclusive:!0,continue:!t.abort});return}}if(a<o)i.issues.push({origin:"number",input:a,code:"too_small",minimum:o,inclusive:!0,inst:e,continue:!t.abort});if(a>s)i.issues.push({origin:"number",input:a,code:"too_big",maximum:s,inclusive:!0,inst:e,continue:!t.abort})}});var ac=h("$ZodCheckMaxLength",(e,t)=>{var r;J.init(e,t),(r=e._zod.def).when??(r.when=Po),e._zod.check=(n)=>{let o=n.value,s=o.length;if((typeof o==="string"&&s>t.maximum?Cr(o):s)<=t.maximum)return;let a=Ir(o);n.issues.push({origin:a,code:"too_big",maximum:t.maximum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),cc=h("$ZodCheckMinLength",(e,t)=>{var r;J.init(e,t),(r=e._zod.def).when??(r.when=Po),e._zod.check=(n)=>{let o=n.value,s=o.length;if((typeof o==="string"&&s>=t.minimum&&s<t.minimum*2?Cr(o):s)>=t.minimum)return;let a=Ir(o);n.issues.push({origin:a,code:"too_small",minimum:t.minimum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),uc=h("$ZodCheckLengthEquals",(e,t)=>{var r;J.init(e,t),(r=e._zod.def).when??(r.when=Po),e._zod.check=(n)=>{let o=n.value,s=o.length,i=typeof o==="string"&&s>=t.length&&s<=t.length*2?Cr(o):s;if(i===t.length)return;let a=Ir(o),c=i>t.length;n.issues.push({origin:a,...c?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),Wt=h("$ZodCheckStringFormat",(e,t)=>{var r,n;if(J.init(e,t),t.pattern)(r=e._zod).check??(r.check=(o)=>{if(t.pattern.lastIndex=0,t.pattern.test(o.value))return;o.issues.push({origin:"string",code:"invalid_format",format:t.format,input:o.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})});else(n=e._zod).check??(n.check=()=>{})}),lc=h("$ZodCheckRegex",(e,t)=>{Wt.init(e,t),e._zod.check=(r)=>{if(t.pattern.lastIndex=0,t.pattern.test(r.value))return;r.issues.push({origin:"string",code:"invalid_format",format:"regex",input:r.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),pc=h("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=nc),Wt.init(e,t)}),dc=h("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=oc),Wt.init(e,t)}),fc=h("$ZodCheckIncludes",(e,t)=>{J.init(e,t);let r=gt(t.includes),n=new RegExp(typeof t.position==="number"?`^.{${t.position},}${r}`:r);t.pattern=n,e._zod.check=(o)=>{if(o.value.includes(t.includes,t.position))return;o.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:o.value,inst:e,continue:!t.abort})}}),mc=h("$ZodCheckStartsWith",(e,t)=>{J.init(e,t);let r=new RegExp(`^${gt(t.prefix)}.*`);t.pattern??(t.pattern=r),e._zod.check=(n)=>{if(n.value.startsWith(t.prefix))return;n.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),hc=h("$ZodCheckEndsWith",(e,t)=>{J.init(e,t);let r=new RegExp(`.*${gt(t.suffix)}$`);t.pattern??(t.pattern=r),e._zod.check=(n)=>{if(n.value.endsWith(t.suffix))return;n.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}});var gc=h("$ZodCheckOverwrite",(e,t)=>{J.init(e,t),e._zod.check=(r)=>{r.value=t.tx(r.value)}});class Co{constructor(e=[],t={}){this.content=[],this.indent=0,this.args=e,this.closed=t}indented(e){this.indent+=1;try{e(this)}finally{this.indent-=1}}write(e){if(typeof e==="function"){e(this,{execution:"sync"}),e(this,{execution:"async"});return}let r=e.split(`
32
+ `)},write:(t)=>{e.write(t)}}),{bold:P,cyan:Bf,dim:H,gray:We,green:Ir,red:Xi,yellow:Qi}=be.default,Gf=" ".repeat(5),Vf=(e)=>P(Bf(e)),ke=(e)=>{let{headings:t,marks:r,rows:n}=e,o=t.map((i,a)=>Math.max(i.length,...n.map((c)=>c[a]?.text.length??0))),s=(i)=>i.map((a,c)=>{let l=c===i.length-1?a.text:a.text.padEnd(o[c]??0);return a.paint?a.paint(l):l}).join(Gf);ie(""),ie(` ${s(t.map((i)=>({paint:Vf,text:i})))}`);for(let[i,a]of n.entries())ie(`${r?.[i]??" "} ${s(a)}`);ie("")};var ra=(e)=>new Map(e.flatMap((t)=>se(t).map((r)=>[r,t]))),mo=(e)=>`Use one of: ${e.join(", ")}.`,na=(e,t)=>{if(e.value.kind==="choice"&&!e.value.choices.includes(t))throw Z(`unknown ${e.long} "${t}"`,mo(e.value.choices));return t},ea=(e)=>{let{flag:t,hints:r,name:n,next:o}=e;if(o===void 0||o.startsWith("-"))throw Z(`${n} needs${Ot(t.value)}`,`Usage: ${r.usage}`);return na(t,o)},oa=(e)=>{let{hints:t,index:r,next:n,word:o}=e;if(o.startsWith("--")){let l=o.indexOf("="),p=l===-1?o:o.slice(0,l),d=r.get(p);if(!d)return;if(d.value.kind==="none"){if(l!==-1)throw Z(`${p} doesn't take a value`,`Usage: ${t.usage}`);return{options:[{flag:d,value:!0}],used:1}}if(l!==-1)return{options:[{flag:d,value:na(d,o.slice(l+1))}],used:1};return{options:[{flag:d,value:ea({flag:d,hints:t,name:p,next:n})}],used:2}}let s=[...o].slice(1),a=s.map((l)=>r.get(`-${l}`)).filter((l)=>l!==void 0);if(a.length!==s.length)return;let c=[],u=1;for(let[l,p]of a.entries())if(p.value.kind==="none")c.push({flag:p,value:!0});else if(l===a.length-1)c.push({flag:p,value:ea({flag:p,hints:t,name:`-${s[l]}`,next:n})}),u=2;else throw Z(`-${s[l]} needs${Ot(p.value)}`,`Usage: ${t.usage}`);return{options:c,used:u}},po=(e,t)=>{let r=e.flatMap((n)=>{let o=t.get(n.long);return o===void 0?[]:[[n.long,o]]});return Object.fromEntries(r)},Wf={command:"nipa",usage:"nipa [options] <command>"},Kf=ra(oe),ta=(e)=>{let{at:t,words:r}=e,n=r[t];if(n===void 0||n==="--"||n==="-"||!n.startsWith("-"))return;let o=oa({hints:Wf,index:Kf,next:r[t+1],word:n});if(!o&&e.unknown==="reject")throw Z(`unknown option "${n}"`,"Run `nipa --help` to see the options.");return o},fo=(e)=>{let{unknown:t,words:r}=e,n=new Map,o=0;for(let s=ta({at:o,unknown:t,words:r});s!==void 0;s=ta({at:o,unknown:t,words:r})){for(let{flag:i,value:a}of s.options)n.set(i.long,a);o+=s.used}return{globals:po(oe,n),rest:r.slice(o)}},sa=(e)=>{let t=e.indexOf("--"),r=t===-1?e:e.slice(0,t),n=new Set(se(Ln));return r.some((o)=>n.has(o))},Jf=(e)=>{let{flags:t,hints:r,words:n}=e,o=ra([...t,...oe]),s=new Set(t.map((l)=>l.long)),i=new Map,a=new Map,c=[],u=0;while(u<n.length){let l=n[u]??"";if(l==="--"){c.push(...n.slice(u+1));break}if(l.startsWith("-")&&l!=="-"){let p=oa({hints:r,index:o,next:n[u+1],word:l});if(!p)throw Z(`unknown option "${l}"`,`Run \`${r.command} --help\` to see the options.`);for(let{flag:d,value:m}of p.options)(s.has(d.long)?i:a).set(d.long,m);u+=p.used}else c.push(l),u+=1}return{globals:a,own:i,positionals:c}},lo=(e,t)=>{if(e.value.kind==="choice"&&!e.value.choices.includes(t))throw Z(`unknown ${e.name} "${t}"`,mo(e.value.choices));return t},Hf=(e)=>{let t=[...e.positionals],r=e.args.map((o)=>{switch(o.arity){case"one":{let s=t.shift();if(s===void 0)throw Z(`missing <${o.name}>`,o.value.kind==="choice"?mo(o.value.choices):`Usage: ${e.hints.usage}`);return[o.name,lo(o,s)]}case"optional":{let s=t.shift();return[o.name,s===void 0?void 0:lo(o,s)]}case"rest":return[o.name,t.splice(0).map((s)=>lo(o,s))];default:return o.arity}}),[n]=t;if(n!==void 0)throw Z(`unexpected argument "${n}"`,`Usage: ${e.hints.usage}`);return Object.fromEntries(r)},ia=(e)=>{let{path:t,spec:r,words:n}=e,o={command:yr(t),usage:Rt(t)},s=Jf({flags:r.flags,hints:o,words:n});return{globals:po(oe,s.globals),input:{args:Hf({args:r.args,hints:o,positionals:s.positionals}),flags:po(r.flags,s.own)}}};var L=(e)=>({...e,kind:"leaf"}),ze=(e)=>({...e,kind:"group"}),yt=(e)=>({...e,kind:"passthrough"}),j=(e,t)=>({kind:"leaf",prepare:({path:r,words:n})=>{let o=ia({path:r,spec:e,words:n});return{globals:o.globals,run:(s)=>t({...o.input,client:s})}},spec:e}),Ee=(e,t)=>{let r=Object.values(t),n=new Map(r.flatMap((o)=>X(o.spec).map((s)=>[s,o])));return{fallback:t[e.default],kind:"group",spec:e,subcommands:n}},qf=(e,t)=>{let{target:r}=e;switch(r.kind){case"program":return{args:t,command:r.program};case"openstack":return{args:t,command:"openstack"};case"command":{let[n,...o]=t;if(n===void 0)throw Z("missing <command>",`Usage: ${Rt([e])}`);return{args:o,command:n}}default:return r}},_t=(e,t)=>({kind:"passthrough",run:({client:r,words:n})=>t({...qf(e,n),client:r}),spec:e}),aa=(e)=>e.spec,Tr=(e)=>({examples:e.examples,hidden:e.hidden.map(aa),sections:e.sections.map((t)=>({commands:t.commands.map(aa),title:t.title})),summary:e.summary});function Wt(e){let t=Object.values(e).filter((n)=>typeof n==="number");return Object.entries(e).filter(([n,o])=>t.indexOf(+n)===-1).map(([n,o])=>o)}function go(e,t="|"){return e.map((r)=>_o(r)).join(t)}function Kt(e,t){if(typeof t==="bigint")return t.toString();return t}class ca{constructor(e){this._getter=e,this._value=void 0}get value(){let e=this._getter;if(e!==void 0)this._value=e(),this._getter=void 0;return this._value}}function Or(e){return new ca(e)}function ua(e){return e===null||e===void 0}function Ar(e){let t=e.startsWith("^")?1:0,r=e.endsWith("$")?e.length-1:e.length;return e.slice(t,r)}function la(e,t){let r=e/t,n=Math.round(r),o=4*Number.EPSILON*Math.max(Math.abs(r),1);if(Math.abs(r-n)<o)return 0;return r-n}function ve(e,t,r){Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0})}function jr(e){let t=Object.getOwnPropertyDescriptor(e,"shape");return t?.get?t.get.raw:t?.value}function Fe(e){return jr(e._zod.def)??e._zod.def.shape}function pa(e,t,r){Object.defineProperty(e,t,{get(){let n=r();return ve(this,t,n),n},enumerable:!0,configurable:!0})}function da(e,t,r){if(t in e)ve(e,t,r);else e[t]=r}function st(e,t,r,n){let o=Fe(t);for(let s of r){let i=Object.getOwnPropertyDescriptor(o,s);if(!i.enumerable)continue;if(i.get)pa(e,s,()=>{let a=t._zod.def.shape[s];return n?n(a,s):a});else da(e,s,n?n(i.value,s):i.value)}}function Yf(e,t){for(let r of Reflect.ownKeys(t)){let n=Object.getOwnPropertyDescriptor(t,r);if(!n.enumerable)continue;if(n.get)pa(e,r,()=>t[r]);else da(e,r,n.value)}}function ae(...e){let t={};for(let r of e){let n=Object.getOwnPropertyDescriptors(r);Object.assign(t,n)}return Object.defineProperties({},t)}function ma(e){return JSON.stringify(e)}function fa(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}var xo="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function Vt(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}var ha=Or(()=>{if(ee.jitless)return!1;if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{return new Function(""),!0}catch(e){return!1}});function it(e){if(Vt(e)===!1)return!1;let t=e.constructor;if(t===void 0)return!0;if(typeof t!=="function")return!0;let r=t.prototype;if(Vt(r)===!1)return!1;if(Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)return!1;return!0}function yo(e){if(it(e))return{...e};if(Array.isArray(e))return[...e];if(e instanceof Map)return new Map(e);if(e instanceof Set)return new Set(e);return e}var ga=new Set(["string","number","symbol"]);function bt(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function $e(e,t,r){let n=new e._zod.constr(t??e._zod.def);if(!t||r?.parent)n._zod.parent=e;return n}function v(e){let t=e;if(!t)return{};if(typeof t==="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");t.error=t.message}if(delete t.message,typeof t.error==="string")return{...t,error:()=>t.error};return t}function _o(e){if(typeof e==="bigint")return e.toString()+"n";if(typeof e==="string")return`"${e}"`;return`${e}`}function xa(e){return Object.keys(e).filter((t)=>e[t]._zod.optin!==void 0&&e[t]._zod.optout==="optional")}var Rr=(()=>({safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-340282346638528860000000000000000000000,340282346638528860000000000000000000000],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]}))(),bo={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function Xf(e,t){let r=e._zod.def,n=r.checks;if(n&&n.length>0)throw Error(".pick() cannot be used on object schemas containing refinements");let s={};return st(s,e,Lr(e,t)),$e(e,ae(r,{shape:s,checks:[]}))}function Lr(e,t){let r=Fe(e),n=[];for(let o of Reflect.ownKeys(t)){if(!Object.getOwnPropertyDescriptor(r,o)?.enumerable)throw Error(`Unrecognized key: "${String(o)}"`);if(t[o])n.push(o)}return n}function Qf(e,t){let r=e._zod.def,n=r.checks;if(n&&n.length>0)throw Error(".omit() cannot be used on object schemas containing refinements");let s=new Set(Lr(e,t)),i={};return st(i,e,Reflect.ownKeys(Fe(e)).filter((a)=>!s.has(a))),$e(e,ae(r,{shape:i,checks:[]}))}function eh(e,t){if(!it(t))throw Error("Invalid input to extend: expected a plain object");let r=e._zod.def.checks;if(r&&r.length>0){let o=Fe(e);for(let s of Reflect.ownKeys(t))if(Object.getOwnPropertyDescriptor(o,s)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return $e(e,ae(e._zod.def,{shape:ya(e,t)}))}function ya(e,t){let r={};return st(r,e,Reflect.ownKeys(Fe(e))),Yf(r,t),r}function th(e,t){if(!it(t))throw Error("Invalid input to safeExtend: expected a plain object");return $e(e,ae(e._zod.def,{shape:ya(e,t)}))}function rh(e,t){if(!t?._zod?.def)throw Error("Invalid input to merge: expected an object schema. To merge a plain shape, use `.extend()`.");if(e._zod.def.checks?.length)throw Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");let r={};st(r,e,Reflect.ownKeys(Fe(e))),st(r,t,Reflect.ownKeys(Fe(t)));let n=ae(e._zod.def,{shape:r,get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return $e(e,n)}function _a(e,t,r,n="partial"){let s=t._zod.def.checks;if(s&&s.length>0)throw Error(`.${n}() cannot be used on object schemas containing refinements`);let a=r?new Set(Lr(t,r)):void 0,c={};return st(c,t,Reflect.ownKeys(Fe(t)),e&&((u,l)=>a&&!a.has(l)?u:new e({type:"optional",innerType:u}))),$e(t,ae(t._zod.def,{shape:c,checks:[]}))}function nh(e,t,r){let n=r?new Set(Lr(t,r)):void 0,o={};return st(o,t,Reflect.ownKeys(Fe(t)),(s,i)=>n&&!n.has(i)?s:new e({type:"nonoptional",innerType:s})),$e(t,ae(t._zod.def,{shape:o}))}function Ce(e,t=0){if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(e.issues[r]?.continue!==!0)return!0;return!1}function ba(e,t=0){if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(e.issues[r]?.continue===!1)return!0;return!1}function Je(e,t){return t.map((r)=>{var n;return(n=r).path??(n.path=[]),r.path.unshift(e),r})}function Gt(e){return typeof e==="string"?e:e?.message}function wo(e,t,r){var n;for(let o=t;o<e.length;o++)(n=e[o]).schema??(n.schema=r)}function Ie(e,t,r){var n;let o=e.inst?._zod?.traits;if(o?.has("$ZodType"))if(o.has("$ZodCheck"))(n=e).schema??(n.schema=e.inst);else e.schema=e.inst;let s=e.schema!==e.inst?e.schema?._zod.def?.error:void 0,i=e.message?e.message:Gt(e.inst?._zod.def?.error?.(e))??Gt(s?.(e))??Gt(t?.error?.(e))??Gt(r.customError?.(e))??Gt(r.localeError?.(e))??"Invalid input",a={};for(let c of Object.keys(e)){if(c==="inst"||c==="schema"||c==="continue"||c==="input"||c==="__proto__")continue;a[c]=e[c]}if(a.path??(a.path=[]),a.message=i,t?.reportInput)a.input=e.input;return a}var oh=/[\uD800-\uDBFF]/;function Zr(e){let t=e.length;if(!oh.test(e))return t;let r=t;for(let n=0;n<t-1;n++)if((e.charCodeAt(n)&64512)===55296&&(e.charCodeAt(n+1)&64512)===56320)r--,n++;return r}function Dr(e){if(Array.isArray(e))return"array";if(typeof e==="string")return"string";return"unknown"}function wa(e){let t=typeof e;switch(t){case"number":return Number.isNaN(e)?"nan":"number";case"object":{if(e===null)return"null";if(Array.isArray(e))return"array";let r=e;if(r&&Object.getPrototypeOf(r)!==Object.prototype&&"constructor"in r&&r.constructor)return r.constructor.name}}return t}function at(...e){let[t,r,n]=e;if(typeof t==="string")return{message:t,code:"custom",input:r,inst:n};return{...t}}function va(e,t){for(let r in t){let n=Object.getOwnPropertyDescriptor(t,r);if(n.get)Object.defineProperty(e,r,{...n,enumerable:!1});else sh(e,r,n.value)}}function Me(e,t,r,n=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:n,value:r}),r}function Nr(e,t,r){return Me(e,t,r,!1)}function $a(e,t){for(let r in e){let n=e[r];Object.defineProperty(t,r,{configurable:!0,enumerable:!0,get(){return Me(this,r,n(this))},set(o){Me(this,r,o)}})}return t}function sh(e,t,r){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?r:Me(this,t,r.bind(this))},set(n){Me(this,t,n)}})}function ih(e,t){let r=Object.getPrototypeOf(e);return t in r?void 0:r}var ho,Ke=!1,ah={configurable:!0,get(){Ke=!0;return}};function R(e,t,r){let n=Object.getPrototypeOf(e._zod);if(t in n&&ho!==e._zod){ho=void 0;return}ho=e._zod,Object.defineProperty(n,t,{configurable:!0,get(){Object.defineProperty(this,t,ah);let o=Ke;Ke=!1;try{let s=r(this);if(Ke)delete this[t];else Object.defineProperty(this,t,{configurable:!0,writable:!0,value:s});return Ke=Ke||o,s}catch(s){throw delete this[t],Ke=Ke||o,s}},set(o){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:o})}})}function ch(e,t,r,n){let o=ih(e,t);if(!o)return;Object.defineProperty(o,t,{configurable:!0,get(){let s={configurable:!0,writable:!0,enumerable:n,value:void 0};return Object.defineProperty(this,t,s),s.value=r(this),Object.defineProperty(this,t,s),s.value},set(s){Object.defineProperty(this,t,{configurable:!0,writable:!0,enumerable:n,value:s})}})}var uh="~constantCatch";function Sa(e){let t=()=>e;return t[uh]=!0,t}var Pa;var vo={value:void 0,enumerable:!1},ka="captureStackTrace"in Error?Error:null;function lh(e){let t=ka;if(t){let r=t.stackTraceLimit;if(typeof r==="number"){try{t.stackTraceLimit=0}catch{return ka=null,new e}try{return new e}finally{t.stackTraceLimit=r}}}return new e}function h(e,t,r,n){let o={};function s(d){this.def=d,this.constr=p,this.traits=new Set}s.prototype=o;let i=r,a=i&&new WeakSet;function c(d,m){if(!d._zod){vo.value=new s(m);try{Object.defineProperty(d,"_zod",vo)}finally{vo.value=void 0}}else if(d._zod.traits.has(e))return;if(d._zod.traits.add(e),t(d,m),a){let g=Object.getPrototypeOf(d),x=d._zod.constr.prototype,y=g;while(y&&y!==x)y=Object.getPrototypeOf(y);let w=y??g;if(!a.has(w))a.add(w),va(w,i)}let f=p.prototype;for(let g in f){if(!Object.prototype.hasOwnProperty.call(f,g))continue;if(!(g in d))d[g]=f[g].bind(d)}}let u=n?.Parent??Object;class l extends u{}Object.defineProperty(l,"name",{value:e});function p(d){let m=n?.Parent?lh(l):this;c(m,d);let f=m._zod.deferred;if(f){for(let x of f)x();m._zod.deferred=void 0}let g=globalThis.__zod_globalConfig?.postProcessor;if(g)g(m);return m}return Object.defineProperty(p,"init",{value:c}),Object.defineProperty(p,Symbol.hasInstance,{value:(d)=>{if(n?.Parent&&d instanceof n.Parent)return!0;return d?._zod?.traits?.has(e)}}),Object.defineProperty(p,"name",{value:e}),p}class Te extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class Jt extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`);this.name="ZodEncodeError"}}(Pa=globalThis).__zod_globalConfig??(Pa.__zod_globalConfig={});var ee=globalThis.__zod_globalConfig;function te(e){if(e)Object.assign(ee,e);return ee}function ph(){let e=this._zod;return e.message??(e.message=JSON.stringify(e.def,Kt,2)),e.message}function dh(e){this._zod.message=e}var mh={get:ph,set:dh,enumerable:!0,configurable:!0},So={value:void 0,enumerable:!1},za=new WeakSet([Object.prototype,Error.prototype]),Ea=(e,t)=>{e.name="$ZodError",So.value=t,Object.defineProperty(e,"issues",So),So.value=void 0,Object.defineProperty(e,"message",mh);let r=Object.getPrototypeOf(e);if(!za.has(r))za.add(r),Object.defineProperty(r,"toString",{configurable:!0,enumerable:!1,get(){let n=()=>this.message;return Object.defineProperty(this,"toString",{value:n,configurable:!0,writable:!0}),n},set(n){Object.defineProperty(this,"toString",{value:n,configurable:!0,writable:!0})}})},Ca=h("$ZodError",Ea),kw=h("$ZodError",Ea,void 0,{Parent:Error});function fh(e,t,r){if(!Object.prototype.hasOwnProperty.call(e,t))if(t==="__proto__")Object.defineProperty(e,t,{value:r(),writable:!0,enumerable:!0,configurable:!0});else e[t]=r();return e[t]}function Po(e,t=(r)=>r.message){let r={},n=[];for(let o of e.issues)if(o.path.length>0)fh(r,o.path[0],()=>[]).push(t(o));else n.push(t(o));return{formErrors:n,fieldErrors:r}}function ko(e,t=(r)=>r.message){let r={_errors:[]},n=(o,s=[])=>{for(let i of o.issues)if(i.code==="invalid_union"&&i.errors.length)i.errors.map((a)=>n({issues:a},[...s,...i.path]));else if(i.code==="invalid_key")n({issues:i.issues},[...s,...i.path]);else if(i.code==="invalid_element")n({issues:i.issues},[...s,...i.path]);else{let a=[...s,...i.path];if(a.length===0)r._errors.push(t(i));else{let c=r,u=0;while(u<a.length){let l=a[u],p=u===a.length-1;if(l==="_errors"){if(p)c._errors.push(t(i));u++;continue}if(!Object.prototype.hasOwnProperty.call(c,l))Object.defineProperty(c,l,{value:{_errors:[]},enumerable:!0,writable:!0,configurable:!0});let d=c[l];if(p)d._errors.push(t(i));c=d,u++}}}};return n(e),r}function hh(e){let t=[],r=e.map((n)=>typeof n==="object"?n.key:n);for(let n of r)if(typeof n==="number")t.push(`[${n}]`);else if(typeof n==="symbol")t.push(`[${JSON.stringify(String(n))}]`);else if(/[^\w$]/.test(n))t.push(`[${JSON.stringify(n)}]`);else{if(t.length)t.push(".");t.push(n)}return t.join("")}function Ht(e){let t=[],r=[...e.issues].sort((n,o)=>(n.path??[]).length-(o.path??[]).length);for(let n of r)if(t.push(`✖ ${n.message}`),n.path?.length)t.push(` → at ${hh(n.path)}`);return t.join(`
33
+ `)}function Ur(e,t){return{callee:t?.callee??e,Err:t?.Err}}var Fr=(e)=>{let t=(r,n,o,s)=>{let i=o?{...o,async:!1}:{async:!1},a=r._zod.run({value:n,issues:[]},i);if(a instanceof Promise)throw new Te;if(a.issues.length){let c=new(s?.Err??e)(a.issues.map((u)=>Ie(u,i,te())));throw xo(c,s?.callee??t),c}return a.value};return t};var Mr=(e)=>{let t=async(r,n,o,s)=>{let i=o?{...o,async:!0}:{async:!0},a=r._zod.run({value:n,issues:[]},i);if(a instanceof Promise)a=await a;if(a.issues.length){let c=new(s?.Err??e)(a.issues.map((u)=>Ie(u,i,te())));throw xo(c,s?.callee??t),c}return a.value};return t};var Br=(e)=>(t,r,n)=>{let o=n?{...n,async:!1}:{async:!1},s=t._zod.run({value:r,issues:[]},o);if(s instanceof Promise)throw new Te;return s.issues.length?Ia(e,s.issues,o):{success:!0,data:s.value}};function Ia(e,t,r){let n;return{success:!1,get error(){if(!n)n=new e(t.map((o)=>Ie(o,r,te()))),t=void 0,r=void 0;return n},set error(o){n=o,t=void 0,r=void 0}}}var Gr=(e)=>async(t,r,n)=>{let o=n?{...n,async:!0}:{async:!0},s=t._zod.run({value:r,issues:[]},o);if(s instanceof Promise)s=await s;return s.issues.length?Ia(e,s.issues,o):{success:!0,data:s.value}};var gh=Symbol.for("zod.compile.invalid"),xh=Symbol.for("zod.compile.fallback"),zo=(e,t,r)=>{let n=e._zod.bag.validator;if(n!==void 0){if(n(t)!==gh)return!0;if(n.definite===!0&&r===void 0)return!1}return yh(e,t,r)};function yh(e,t,r){let n=r?{...r,async:!1,abortEarly:!0}:{async:!1,abortEarly:!0},o=e._zod.bag.fallbackRun,s;if(o)n[xh]=!0,s=o({value:t,issues:[]},n);else s=e._zod.run({value:t,issues:[]},n);if(s instanceof Promise)throw new Te;return s.issues.length===0}var Eo=async(e,t,r)=>{let n=r?{...r,async:!0,abortEarly:!0}:{async:!0,abortEarly:!0},o=e._zod.run({value:t,issues:[]},n);if(o instanceof Promise)o=await o;return o.issues.length===0},Ta=(e)=>{let t=Fr(e),r=(n,o,s,i)=>{let a=s?{...s,direction:"backward"}:{direction:"backward"};return t(n,o,a,Ur(r,i))};return r};var Oa=(e)=>{let t=Fr(e),r=(n,o,s,i)=>t(n,o,s,Ur(r,i));return r};var Aa=(e)=>{let t=Mr(e),r=async(n,o,s,i)=>{let a=s?{...s,direction:"backward"}:{direction:"backward"};return await t(n,o,a,Ur(r,i))};return r};var ja=(e)=>{let t=Mr(e),r=async(n,o,s,i)=>await t(n,o,s,Ur(r,i));return r};var Ra=(e)=>(t,r,n)=>{let o=n?{...n,direction:"backward"}:{direction:"backward"};return Br(e)(t,r,o)};var La=(e)=>(t,r,n)=>Br(e)(t,r,n);var Za=(e)=>async(t,r,n)=>{let o=n?{...n,direction:"backward"}:{direction:"backward"};return Gr(e)(t,r,o)};var Da=(e)=>async(t,r,n)=>Gr(e)(t,r,n);var Na=/^[cC][0-9a-z]{6,}$/,Ua=/^[0-9a-z]+$/,Fa=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,Ma=/^[0-9a-vA-V]{20}$/,Ba=/^[A-Za-z0-9]{27}$/,Ga=/^[a-zA-Z0-9_-]{21}$/;function Va(e){return new RegExp(`^[a-zA-Z0-9_-]{${e}}$`)}var Wa=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;var Ka=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,Io=(e)=>{if(!e)return/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/;return new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`)};var Ja=/^(?:[A-Za-z0-9_'+\-]+\.)*[A-Za-z0-9_'+\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;var _h="^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$";function Ha(){return new RegExp(_h,"u")}var qa=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,Ya=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/;var Xa=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,Qa=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,ec=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,tc=/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/;var rc=/^https?$/,nc=/^\+[1-9]\d{6,14}$/;var oc="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))";function bh(e){return new RegExp(`^${e}$`)}var sc=bh(oc);function Co(e){return typeof e.precision==="number"?e.precision===-1?"(?:[01]\\d|2[0-3]):[0-5]\\d":e.precision===0?"(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d":`(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d\\.\\d{${e.precision}}`:e.seconds?"(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?":"(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?"}function ic(e){return new RegExp(`^${Co(e)}$`)}function ac(e){let t=["Z"];if(e.offset)t.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");let r=`${Co({precision:e.precision,seconds:!0})}(?:${t.join("|")})`,n=e.local?`${r}|${Co({precision:e.precision})}`:r;return new RegExp(`^${oc}T(?:${n})$`)}var cc=/^[\s\S]{0,}$/;var To=/^-?\d+$/,qt=/^-?\d+(?:\.\d+)?$/,uc=/^(?:true|false)$/i;var lc=/^[^A-Z]*$/,pc=/^[^a-z]*$/;var J=h("$ZodCheck",(e,t)=>{var r;e._zod??(e._zod={}),e._zod.def=t,(r=e._zod).onattach??(r.onattach=[])});var Oo=(e)=>{let t=e.value;return!ua(t)&&t.length!==void 0},Vr={number:"number",bigint:"bigint",object:"date"},Ao=h("$ZodCheckLessThan",(e,t)=>{J.init(e,t);let r=Vr[typeof t.value];e._zod.check=(n)=>{if(t.inclusive?n.value<=t.value:n.value<t.value)return;n.issues.push({origin:Vr[typeof n.value]??r,code:"too_big",maximum:typeof t.value==="object"?t.value.getTime():t.value,input:n.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),jo=h("$ZodCheckGreaterThan",(e,t)=>{J.init(e,t);let r=Vr[typeof t.value];e._zod.check=(n)=>{if(t.inclusive?n.value>=t.value:n.value>t.value)return;n.issues.push({origin:Vr[typeof n.value]??r,code:"too_small",minimum:typeof t.value==="object"?t.value.getTime():t.value,input:n.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),dc=h("$ZodCheckMultipleOf",(e,t)=>{J.init(e,t),e._zod.check=(r)=>{if(typeof r.value!==typeof t.value)throw Error("Cannot mix number and bigint in multiple_of check.");if(typeof r.value==="bigint"?t.value!==BigInt(0)&&r.value%t.value===BigInt(0):la(r.value,t.value)===0)return;r.issues.push({origin:typeof r.value,code:"not_multiple_of",divisor:t.value,input:r.value,inst:e,continue:!t.abort})}}),mc=h("$ZodCheckNumberFormat",(e,t)=>{J.init(e,t),t.format=t.format||"float64";let r=t.format?.includes("int"),n=r?"int":"number",[o,s]=Rr[t.format];e._zod.check=(i)=>{let a=i.value;if(r){if(!Number.isInteger(a)){i.issues.push({expected:n,format:t.format,code:"invalid_type",continue:!1,input:a,inst:e});return}if(!Number.isSafeInteger(a)){if(a>0)i.issues.push({input:a,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:n,inclusive:!0,continue:!t.abort});else i.issues.push({input:a,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:n,inclusive:!0,continue:!t.abort});return}}if(a<o)i.issues.push({origin:"number",input:a,code:"too_small",minimum:o,inclusive:!0,inst:e,continue:!t.abort});if(a>s)i.issues.push({origin:"number",input:a,code:"too_big",maximum:s,inclusive:!0,inst:e,continue:!t.abort})}});var fc=h("$ZodCheckMaxLength",(e,t)=>{var r;J.init(e,t),(r=e._zod.def).when??(r.when=Oo),e._zod.check=(n)=>{let o=n.value,s=o.length;if((typeof o==="string"&&s>t.maximum?Zr(o):s)<=t.maximum)return;let a=Dr(o);n.issues.push({origin:a,code:"too_big",maximum:t.maximum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),hc=h("$ZodCheckMinLength",(e,t)=>{var r;J.init(e,t),(r=e._zod.def).when??(r.when=Oo),e._zod.check=(n)=>{let o=n.value,s=o.length;if((typeof o==="string"&&s>=t.minimum&&s<t.minimum*2?Zr(o):s)>=t.minimum)return;let a=Dr(o);n.issues.push({origin:a,code:"too_small",minimum:t.minimum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),gc=h("$ZodCheckLengthEquals",(e,t)=>{var r;J.init(e,t),(r=e._zod.def).when??(r.when=Oo),e._zod.check=(n)=>{let o=n.value,s=o.length,i=typeof o==="string"&&s>=t.length&&s<=t.length*2?Zr(o):s;if(i===t.length)return;let a=Dr(o),c=i>t.length;n.issues.push({origin:a,...c?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),Yt=h("$ZodCheckStringFormat",(e,t)=>{var r,n;if(J.init(e,t),t.pattern)(r=e._zod).check??(r.check=(o)=>{if(t.pattern.lastIndex=0,t.pattern.test(o.value))return;o.issues.push({origin:"string",code:"invalid_format",format:t.format,input:o.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})});else(n=e._zod).check??(n.check=()=>{})}),xc=h("$ZodCheckRegex",(e,t)=>{Yt.init(e,t),e._zod.check=(r)=>{if(t.pattern.lastIndex=0,t.pattern.test(r.value))return;r.issues.push({origin:"string",code:"invalid_format",format:"regex",input:r.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),yc=h("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=lc),Yt.init(e,t)}),_c=h("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=pc),Yt.init(e,t)}),bc=h("$ZodCheckIncludes",(e,t)=>{J.init(e,t);let r=bt(t.includes),n=new RegExp(typeof t.position==="number"?`^.{${t.position},}${r}`:r);t.pattern=n,e._zod.check=(o)=>{if(o.value.includes(t.includes,t.position))return;o.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:o.value,inst:e,continue:!t.abort})}}),wc=h("$ZodCheckStartsWith",(e,t)=>{J.init(e,t);let r=new RegExp(`^${bt(t.prefix)}.*`);t.pattern??(t.pattern=r),e._zod.check=(n)=>{if(n.value.startsWith(t.prefix))return;n.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),vc=h("$ZodCheckEndsWith",(e,t)=>{J.init(e,t);let r=new RegExp(`.*${bt(t.suffix)}$`);t.pattern??(t.pattern=r),e._zod.check=(n)=>{if(n.value.endsWith(t.suffix))return;n.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}});var $c=h("$ZodCheckOverwrite",(e,t)=>{J.init(e,t),e._zod.check=(r)=>{r.value=t.tx(r.value)}});class Ro{constructor(e=[],t={}){this.content=[],this.indent=0,this.args=e,this.closed=t}indented(e){this.indent+=1;try{e(this)}finally{this.indent-=1}}write(e){if(typeof e==="function"){e(this,{execution:"sync"}),e(this,{execution:"async"});return}let r=e.split(`
34
34
  `).filter((s)=>s),n=Math.min(...r.map((s)=>s.length-s.trimStart().length)),o=r.map((s)=>s.slice(n)).map((s)=>" ".repeat(this.indent*2)+s);for(let s of o)this.content.push(s)}compile(){let e=Function,t=this?.content??[""];return new e(...Object.keys(this.closed),`return function (${this.args.join(", ")}) {
35
35
  ${t.join(`
36
36
  `)}
37
- };`)(...Object.values(this.closed))}}var yc={major:4,minor:6,patch:5};var F=h("$ZodType",(e,t)=>{var r;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=yc;let n=e._zod.def.checks,o=e._zod.traits.has("$ZodCheck")?[e,...n??[]]:n?.length?[...n]:[];for(let s of o)for(let i of s._zod.onattach)i(e);if(o.length===0)(r=e._zod).deferred??(r.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let s=(a,c,u)=>{if(a.memo)return a;let l=Ee(a),p;for(let d of c){if(d._zod.def.when){if(fa(a))continue;if(!d._zod.def.when(a))continue}else if(l)continue;let f=a.issues.length,m=d._zod.check(a);if(m instanceof Promise&&u?.async===!1)throw new Ie;if(p||m instanceof Promise)p=(p??Promise.resolve()).then(async()=>{if(await m,a.issues.length===f)return;if(ho(a.issues,f,e),!l)l=Ee(a,f)});else{if(a.issues.length===f)continue;if(ho(a.issues,f,e),!l)l=Ee(a,f)}}if(p)return p.then(()=>a);return a},i=(a,c,u)=>{if(Ee(a))return a.aborted=!0,a;let l=s(c,o,u);if(l instanceof Promise){if(u.async===!1)throw new Ie;return l.then((p)=>e._zod.parse(p,u))}return e._zod.parse(l,u)};e._zod.run=(a,c)=>{if(c.skipChecks)return e._zod.parse(a,c);if(c.direction==="backward"){let l=e._zod.parse({value:a.value,issues:[]},{...c,skipChecks:!0});if(l instanceof Promise)return l.then((p)=>i(p,a,c));return i(l,a,c)}let u=e._zod.parse(a,c);if(u instanceof Promise){if(c.async===!1)throw new Ie;return u.then((l)=>s(l,o,c))}return s(u,o,c)}}},{get "~standard"(){return Tr(this,"~standard",To(this))},set "~standard"(e){Ue(this,"~standard",e)}}),Cc=(e,t)=>e.issues.length?{issues:e.issues.map((r)=>Ce(r,t,Q()))}:{value:e.value};async function rh(e,t){let r={async:!0};return Cc(await e._zod.run({value:t,issues:[]},r),r)}function To(e){return{validate:(t)=>{let r={async:!1};try{let n=e._zod.run({value:t,issues:[]},r);if(!(n instanceof Promise))return Cc(n,r)}catch(n){}return rh(e,t)},vendor:"zod",version:1}}var Ur=h("$ZodString",(e,t)=>{F.init(e,t),e._zod.pattern=t.pattern??tc,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=String(r.value)}catch(o){}if(typeof r.value==="string")return r;return r.issues.push({expected:"string",code:"invalid_type",input:r.value,inst:e}),r}}),L=h("$ZodStringFormat",(e,t)=>{Wt.init(e,t),Ur.init(e,t)}),Ic=h("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=Fa),L.init(e,t)}),Tc=h("$ZodUUID",(e,t)=>{if(t.version){let n={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(n===void 0)throw Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=So(n))}else t.pattern??(t.pattern=So());L.init(e,t)}),Oc=h("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=Ua),L.init(e,t)}),Ac=1,Nr=2;function jc(e){try{if(typeof URL<"u"&&typeof URL.canParse==="function")return URL.canParse(e);return new URL(e),!0}catch{return!1}}function nh(e,t){if(!("normalize"in t)&&!("hostname"in t)&&!("protocol"in t))return jc(e)||Nr;return oh(e,t)}function oh(e,t){if(!t.normalize&&t.protocol?.source===Ha.source&&!/^https?:\/\//i.test(e))return Ac;try{if(typeof URL<"u"){let r=URL;if(typeof r.parse==="function")return r.parse(e)??Nr}return new URL(e)}catch{return Nr}}var sh=/[\t\n\r]/g;function _c(e){return e.replace(sh,"")}function ih(e,t){return t.lastIndex=0,t.test(e.hostname)}function ah(e,t){return t.lastIndex=0,t.test(e.protocol.endsWith(":")?e.protocol.slice(0,-1):e.protocol)}var Rc=h("$ZodURL",(e,t)=>{L.init(e,t),e._zod.check=(r)=>{try{let n=r.value.trim(),o=nh(n,t);if(o===Ac){r.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:r.value,inst:e,continue:!t.abort});return}if(o===Nr){r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:e,continue:!t.abort});return}if(o===!0){r.value=_c(n);return}if(t.hostname&&!ih(o,t.hostname))r.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:r.value,inst:e,continue:!t.abort});if(t.protocol&&!ah(o,t.protocol))r.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:r.value,inst:e,continue:!t.abort});r.value=t.normalize?o.href:_c(n);return}catch(n){r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:e,continue:!t.abort})}}}),Zc=h("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=Ma()),L.init(e,t)}),Lc=h("$ZodNanoID",(e,t)=>{if(t.length!==void 0&&(!Number.isInteger(t.length)||t.length<1))throw Error(`Invalid nanoid length: ${t.length}`);t.pattern??(t.pattern=t.length===void 0?La:Da(t.length)),L.init(e,t)}),Dc=h("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=Oa),L.init(e,t)}),Nc=h("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=Aa),L.init(e,t)}),Fc=h("$ZodULID",(e,t)=>{t.pattern??(t.pattern=ja),L.init(e,t)}),Uc=h("$ZodXID",(e,t)=>{t.pattern??(t.pattern=Ra),L.init(e,t)}),Mc=h("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=Za),L.init(e,t)}),Bc=h("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=ec(t)),L.init(e,t)}),Gc=h("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=Xa),L.init(e,t)}),Vc=h("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=Qa(t)),L.init(e,t)}),Wc=h("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=Na),L.init(e,t)}),Kc=h("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=Ba),L.init(e,t)}),ch=/^[0-9a-fA-F:.]+$/;function Jc(e){if(!ch.test(e))return!1;return jc(`http://[${e}]`)}var Hc=h("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=Ga),L.init(e,t),e._zod.check=(r)=>{if(!Jc(r.value))r.issues.push({code:"invalid_format",format:"ipv6",input:r.value,inst:e,continue:!t.abort})}});var qc=h("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=Va),L.init(e,t)});function uh(e){let t=e.split("/");if(t.length!==2)return!1;let[r,n]=t;if(!n)return!1;let o=Number(n);if(`${o}`!==n)return!1;if(o<0||o>128)return!1;return Jc(r)}var Yc=h("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=Wa),L.init(e,t),e._zod.check=(r)=>{if(!uh(r.value))r.issues.push({code:"invalid_format",format:"cidrv6",input:r.value,inst:e,continue:!t.abort})}});function Xc(e){if(e==="")return!0;if(/\s/.test(e))return!1;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}var Oo=/^[0-9a-zA-Z+/]*={0,2}$/,Qc=h("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=Oo),L.init(e,t),e._zod.check=(r)=>{if(Xc(r.value))return;r.issues.push({code:"invalid_format",format:"base64",input:r.value,inst:e,continue:!t.abort})}}),Mr=/^[A-Za-z0-9_-]*$/;function lh(e){if(!Mr.test(e))return!1;let t=e.replace(/[-_]/g,(n)=>n==="-"?"+":"/"),r=t.padEnd(Math.ceil(t.length/4)*4,"=");return Xc(r)}var eu=h("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=Mr),L.init(e,t),e._zod.check=(r)=>{if(lh(r.value))return;r.issues.push({code:"invalid_format",format:"base64url",input:r.value,inst:e,continue:!t.abort})}}),tu=h("$ZodE164",(e,t)=>{t.pattern??(t.pattern=qa),L.init(e,t)});function ph(e,t=null){try{let r=e.split(".");if(r.length!==3)return!1;let[n]=r;if(!n)return!1;let o=JSON.parse(atob(n));if("typ"in o&&o?.typ!=="JWT")return!1;if(!o.alg)return!1;if(t&&(!("alg"in o)||o.alg!==t))return!1;return!0}catch{return!1}}var ru=h("$ZodJWT",(e,t)=>{L.init(e,t),e._zod.check=(r)=>{if(ph(r.value,t.alg))return;r.issues.push({code:"invalid_format",format:"jwt",input:r.value,inst:e,continue:!t.abort})}});var Ao=h("$ZodNumber",(e,t)=>{F.init(e,t),e._zod.pattern=Vt,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=Number(r.value)}catch(i){}let o=r.value;if(typeof o==="number"&&!Number.isNaN(o)&&Number.isFinite(o))return r;let s=typeof o==="number"?Number.isNaN(o)?"NaN":!Number.isFinite(o)?String(o):void 0:void 0;return r.issues.push({expected:"number",code:"invalid_type",input:o,inst:e,...s?{received:s}:{}}),r}}),nu=h("$ZodNumberFormat",(e,t)=>{ic.init(e,t),Ao.init(e,t)}),ou=h("$ZodBoolean",(e,t)=>{F.init(e,t),e._zod.pattern=rc,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=Boolean(r.value)}catch(s){}let o=r.value;if(typeof o==="boolean")return r;return r.issues.push({expected:"boolean",code:"invalid_type",input:o,inst:e}),r}});var su=h("$ZodUnknown",(e,t)=>{F.init(e,t),e._zod.parse=(r)=>r}),iu=h("$ZodNever",(e,t)=>{F.init(e,t),e._zod.parse=(r,n)=>(r.issues.push({expected:"never",code:"invalid_type",input:r.value,inst:e}),r)});function bc(e,t,r){if(e.issues.length)t.issues.push(...We(r,e.issues));t.value[r]=e.value}var au=h("$ZodArray",(e,t)=>{F.init(e,t);let r=X.memoizer;r?.attach(e),e._zod.parse=(n,o)=>{let s=n.value;if(!Array.isArray(s))return n.issues.push({expected:"array",code:"invalid_type",input:s,inst:e}),n;n.value=r?r.alloc(e,n,Array(s.length),o):Array(s.length);let i=[],a=o?.abortEarly;for(let c=0;c<s.length;c++){let u=s[c],l=t.element._zod.run({value:u,issues:[]},o);if(l instanceof Promise)i.push(l.then((p)=>bc(p,n,c)));else if(bc(l,n,c),a&&l.issues.length!==0&&Ee(l))break}if(i.length)return Promise.all(i).then(()=>n);return n}});function Fr(e,t,r,n,o,s){let i=r in n,a=s==="optional";if(!i&&a&&o==="optional")return;if(e.issues.length){if(o!==void 0&&a&&!i)return;t.issues.push(...We(r,e.issues))}if(!i&&o===void 0){if(!e.issues.length)t.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[r]});return}if(e.value===void 0){if(i||o==="defaulted"&&!a)t.value[r]=void 0}else t.value[r]=e.value}var dh=[];function cu(e){let t=Object.keys(e.shape),r=Object.getOwnPropertySymbols(e.shape),n=r.length?r:dh,o=n.length?[...t,...n]:t;for(let i of o)if(!e.shape?.[i]?._zod?.traits?.has("$ZodType"))throw Error(`Invalid element at key "${String(i)}": expected a Zod schema`);let s=la(e.shape);return{...e,allKeys:o,symbolKeys:n,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(s)}}function uu(e,t,r,n,o,s,i){let a=[],c=o.keySet,u=o.catchall._zod,l=u.def.type,{optin:p,optout:d}=u,f=0;for(let m in t){if(i&&r.issues.length!==f){if(Ee(r,f))break;f=r.issues.length}if(c.has(m))continue;if(m==="__proto__"){if(l==="never")a.push(m);continue}if(l==="never"){a.push(m);continue}let g=u.run({value:t[m],issues:[]},n);if(g instanceof Promise)e.push(g.then((x)=>Fr(x,r,m,t,p,d)));else Fr(g,r,m,t,p,d)}if(a.length)r.issues.push({code:"unrecognized_keys",keys:a,input:t,inst:s,continue:!0});if(!e.length)return r;return Promise.all(e).then(()=>r)}var fh=h("$ZodObject",(e,t)=>{F.init(e,t);let r=Object.getOwnPropertyDescriptor(t,"shape"),n=r?.get?r.get.raw:t.shape??{};if(n){let u=()=>{let l={...n};return Object.defineProperty(t,"shape",{value:l}),u.raw=l,l};u.raw=n,Object.defineProperty(t,"shape",{get:u})}let o=Sr(()=>cu(t));j(e,"propValues",(u)=>{let l=u.def.shape,p={};for(let d in l){let f=l[d]._zod;if(f.values){if(!Object.prototype.hasOwnProperty.call(p,d))ve(p,d,new Set);for(let m of f.values)p[d].add(m);if(f.optin!==void 0)p[d].add(void 0)}}return p});let s=Ft,i=t.catchall,a,c=X.memoizer;c?.attach(e),e._zod.parse=(u,l)=>{a??(a=o.value);let p=u.value;if(!s(p))return u.issues.push({expected:"object",code:"invalid_type",input:p,inst:e}),u;u.value=c?c.alloc(e,u,{},l):{};let d=[],f=a.shape,m=l?.abortEarly,g=u.issues.length;for(let x of a.allKeys){if(m&&u.issues.length!==g){if(Ee(u,g))break;g=u.issues.length}if(x==="__proto__")continue;let _=f[x],w=_._zod.optin,P=_._zod.optout,C=_._zod.run({value:p[x],issues:[]},l);if(C instanceof Promise)d.push(C.then((y)=>Fr(y,u,x,p,w,P)));else Fr(C,u,x,p,w,P)}if(!i)return d.length?Promise.all(d).then(()=>u):u;return uu(d,p,u,l,o.value,e,m===!0)}}),lu=h("$ZodObjectJIT",(e,t)=>{fh.init(e,t);let r=e._zod.parse,n=Sr(()=>cu(t)),o=X.memoizer,s=(f)=>{let m=n.value,g=m.symbolKeys,x=new Co(["payload","ctx"],{shape:f,inst:e,memo:o,syms:g}),_=(y)=>`shape[${y}]._zod.run({ value: input[${y}], issues: [] }, ctx)`,w=(y,S)=>`
38
- let ${y}_ab = false;
39
- for (let i = 0; i < ${y}.issues.length; i++) {
40
- const iss = ${y}.issues[i];
37
+ };`)(...Object.values(this.closed))}}var Pc={major:4,minor:6,patch:5};var U=h("$ZodType",(e,t)=>{var r;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Pc;let n=e._zod.def.checks,o=e._zod.traits.has("$ZodCheck")?[e,...n??[]]:n?.length?[...n]:[];for(let s of o)for(let i of s._zod.onattach)i(e);if(o.length===0)(r=e._zod).deferred??(r.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let s=(a,c,u)=>{if(a.memo)return a;let l=Ce(a),p;for(let d of c){if(d._zod.def.when){if(ba(a))continue;if(!d._zod.def.when(a))continue}else if(l)continue;let m=a.issues.length,f=d._zod.check(a);if(f instanceof Promise&&u?.async===!1)throw new Te;if(p||f instanceof Promise)p=(p??Promise.resolve()).then(async()=>{if(await f,a.issues.length===m)return;if(wo(a.issues,m,e),!l)l=Ce(a,m)});else{if(a.issues.length===m)continue;if(wo(a.issues,m,e),!l)l=Ce(a,m)}}if(p)return p.then(()=>a);return a},i=(a,c,u)=>{if(Ce(a))return a.aborted=!0,a;let l=s(c,o,u);if(l instanceof Promise){if(u.async===!1)throw new Te;return l.then((p)=>e._zod.parse(p,u))}return e._zod.parse(l,u)};e._zod.run=(a,c)=>{if(c.skipChecks)return e._zod.parse(a,c);if(c.direction==="backward"){let l=e._zod.parse({value:a.value,issues:[]},{...c,skipChecks:!0});if(l instanceof Promise)return l.then((p)=>i(p,a,c));return i(l,a,c)}let u=e._zod.parse(a,c);if(u instanceof Promise){if(c.async===!1)throw new Te;return u.then((l)=>s(l,o,c))}return s(u,o,c)}}},{get "~standard"(){return Nr(this,"~standard",Zo(this))},set "~standard"(e){Me(this,"~standard",e)}}),Lc=(e,t)=>e.issues.length?{issues:e.issues.map((r)=>Ie(r,t,te()))}:{value:e.value};async function wh(e,t){let r={async:!0};return Lc(await e._zod.run({value:t,issues:[]},r),r)}function Zo(e){return{validate:(t)=>{let r={async:!1};try{let n=e._zod.run({value:t,issues:[]},r);if(!(n instanceof Promise))return Lc(n,r)}catch(n){}return wh(e,t)},vendor:"zod",version:1}}var Hr=h("$ZodString",(e,t)=>{U.init(e,t),e._zod.pattern=t.pattern??cc,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=String(r.value)}catch(o){}if(typeof r.value==="string")return r;return r.issues.push({expected:"string",code:"invalid_type",input:r.value,inst:e}),r}}),D=h("$ZodStringFormat",(e,t)=>{Yt.init(e,t),Hr.init(e,t)}),Zc=h("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=Ka),D.init(e,t)}),Dc=h("$ZodUUID",(e,t)=>{if(t.version){let n={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(n===void 0)throw Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=Io(n))}else t.pattern??(t.pattern=Io());D.init(e,t)}),Nc=h("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=Ja),D.init(e,t)}),Uc=1,Kr=2;function Fc(e){try{if(typeof URL<"u"&&typeof URL.canParse==="function")return URL.canParse(e);return new URL(e),!0}catch{return!1}}function vh(e,t){if(!("normalize"in t)&&!("hostname"in t)&&!("protocol"in t))return Fc(e)||Kr;return $h(e,t)}function $h(e,t){if(!t.normalize&&t.protocol?.source===rc.source&&!/^https?:\/\//i.test(e))return Uc;try{if(typeof URL<"u"){let r=URL;if(typeof r.parse==="function")return r.parse(e)??Kr}return new URL(e)}catch{return Kr}}var Sh=/[\t\n\r]/g;function kc(e){return e.replace(Sh,"")}function Ph(e,t){return t.lastIndex=0,t.test(e.hostname)}function kh(e,t){return t.lastIndex=0,t.test(e.protocol.endsWith(":")?e.protocol.slice(0,-1):e.protocol)}var Mc=h("$ZodURL",(e,t)=>{D.init(e,t),e._zod.check=(r)=>{try{let n=r.value.trim(),o=vh(n,t);if(o===Uc){r.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:r.value,inst:e,continue:!t.abort});return}if(o===Kr){r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:e,continue:!t.abort});return}if(o===!0){r.value=kc(n);return}if(t.hostname&&!Ph(o,t.hostname))r.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:r.value,inst:e,continue:!t.abort});if(t.protocol&&!kh(o,t.protocol))r.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:r.value,inst:e,continue:!t.abort});r.value=t.normalize?o.href:kc(n);return}catch(n){r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:e,continue:!t.abort})}}}),Bc=h("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=Ha()),D.init(e,t)}),Gc=h("$ZodNanoID",(e,t)=>{if(t.length!==void 0&&(!Number.isInteger(t.length)||t.length<1))throw Error(`Invalid nanoid length: ${t.length}`);t.pattern??(t.pattern=t.length===void 0?Ga:Va(t.length)),D.init(e,t)}),Vc=h("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=Na),D.init(e,t)}),Wc=h("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=Ua),D.init(e,t)}),Kc=h("$ZodULID",(e,t)=>{t.pattern??(t.pattern=Fa),D.init(e,t)}),Jc=h("$ZodXID",(e,t)=>{t.pattern??(t.pattern=Ma),D.init(e,t)}),Hc=h("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=Ba),D.init(e,t)}),qc=h("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=ac(t)),D.init(e,t)}),Yc=h("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=sc),D.init(e,t)}),Xc=h("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=ic(t)),D.init(e,t)}),Qc=h("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=Wa),D.init(e,t)}),eu=h("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=qa),D.init(e,t)}),zh=/^[0-9a-fA-F:.]+$/;function tu(e){if(!zh.test(e))return!1;return Fc(`http://[${e}]`)}var ru=h("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=Ya),D.init(e,t),e._zod.check=(r)=>{if(!tu(r.value))r.issues.push({code:"invalid_format",format:"ipv6",input:r.value,inst:e,continue:!t.abort})}});var nu=h("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=Xa),D.init(e,t)});function Eh(e){let t=e.split("/");if(t.length!==2)return!1;let[r,n]=t;if(!n)return!1;let o=Number(n);if(`${o}`!==n)return!1;if(o<0||o>128)return!1;return tu(r)}var ou=h("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=Qa),D.init(e,t),e._zod.check=(r)=>{if(!Eh(r.value))r.issues.push({code:"invalid_format",format:"cidrv6",input:r.value,inst:e,continue:!t.abort})}});function su(e){if(e==="")return!0;if(/\s/.test(e))return!1;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}var Do=/^[0-9a-zA-Z+/]*={0,2}$/,iu=h("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=Do),D.init(e,t),e._zod.check=(r)=>{if(su(r.value))return;r.issues.push({code:"invalid_format",format:"base64",input:r.value,inst:e,continue:!t.abort})}}),qr=/^[A-Za-z0-9_-]*$/;function Ch(e){if(!qr.test(e))return!1;let t=e.replace(/[-_]/g,(n)=>n==="-"?"+":"/"),r=t.padEnd(Math.ceil(t.length/4)*4,"=");return su(r)}var au=h("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=qr),D.init(e,t),e._zod.check=(r)=>{if(Ch(r.value))return;r.issues.push({code:"invalid_format",format:"base64url",input:r.value,inst:e,continue:!t.abort})}}),cu=h("$ZodE164",(e,t)=>{t.pattern??(t.pattern=nc),D.init(e,t)});function Ih(e,t=null){try{let r=e.split(".");if(r.length!==3)return!1;let[n]=r;if(!n)return!1;let o=JSON.parse(atob(n));if("typ"in o&&o?.typ!=="JWT")return!1;if(!o.alg)return!1;if(t&&(!("alg"in o)||o.alg!==t))return!1;return!0}catch{return!1}}var uu=h("$ZodJWT",(e,t)=>{D.init(e,t),e._zod.check=(r)=>{if(Ih(r.value,t.alg))return;r.issues.push({code:"invalid_format",format:"jwt",input:r.value,inst:e,continue:!t.abort})}});var No=h("$ZodNumber",(e,t)=>{U.init(e,t),e._zod.pattern=qt,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=Number(r.value)}catch(i){}let o=r.value;if(typeof o==="number"&&!Number.isNaN(o)&&Number.isFinite(o))return r;let s=typeof o==="number"?Number.isNaN(o)?"NaN":!Number.isFinite(o)?String(o):void 0:void 0;return r.issues.push({expected:"number",code:"invalid_type",input:o,inst:e,...s?{received:s}:{}}),r}}),lu=h("$ZodNumberFormat",(e,t)=>{mc.init(e,t),No.init(e,t)}),pu=h("$ZodBoolean",(e,t)=>{U.init(e,t),e._zod.pattern=uc,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=Boolean(r.value)}catch(s){}let o=r.value;if(typeof o==="boolean")return r;return r.issues.push({expected:"boolean",code:"invalid_type",input:o,inst:e}),r}});var du=h("$ZodUnknown",(e,t)=>{U.init(e,t),e._zod.parse=(r)=>r}),mu=h("$ZodNever",(e,t)=>{U.init(e,t),e._zod.parse=(r,n)=>(r.issues.push({expected:"never",code:"invalid_type",input:r.value,inst:e}),r)});function zc(e,t,r){if(e.issues.length)t.issues.push(...Je(r,e.issues));t.value[r]=e.value}var fu=h("$ZodArray",(e,t)=>{U.init(e,t);let r=ee.memoizer;r?.attach(e),e._zod.parse=(n,o)=>{let s=n.value;if(!Array.isArray(s))return n.issues.push({expected:"array",code:"invalid_type",input:s,inst:e}),n;n.value=r?r.alloc(e,n,Array(s.length),o):Array(s.length);let i=[],a=o?.abortEarly;for(let c=0;c<s.length;c++){let u=s[c],l=t.element._zod.run({value:u,issues:[]},o);if(l instanceof Promise)i.push(l.then((p)=>zc(p,n,c)));else if(zc(l,n,c),a&&l.issues.length!==0&&Ce(l))break}if(i.length)return Promise.all(i).then(()=>n);return n}});function Jr(e,t,r,n,o,s){let i=r in n,a=s==="optional";if(!i&&a&&o==="optional")return;if(e.issues.length){if(o!==void 0&&a&&!i)return;t.issues.push(...Je(r,e.issues))}if(!i&&o===void 0){if(!e.issues.length)t.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[r]});return}if(e.value===void 0){if(i||o==="defaulted"&&!a)t.value[r]=void 0}else t.value[r]=e.value}var Th=[];function hu(e){let t=Object.keys(e.shape),r=Object.getOwnPropertySymbols(e.shape),n=r.length?r:Th,o=n.length?[...t,...n]:t;for(let i of o)if(!e.shape?.[i]?._zod?.traits?.has("$ZodType"))throw Error(`Invalid element at key "${String(i)}": expected a Zod schema`);let s=xa(e.shape);return{...e,allKeys:o,symbolKeys:n,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(s)}}function gu(e,t,r,n,o,s,i){let a=[],c=o.keySet,u=o.catchall._zod,l=u.def.type,{optin:p,optout:d}=u,m=0;for(let f in t){if(i&&r.issues.length!==m){if(Ce(r,m))break;m=r.issues.length}if(c.has(f))continue;if(f==="__proto__"){if(l==="never")a.push(f);continue}if(l==="never"){a.push(f);continue}let g=u.run({value:t[f],issues:[]},n);if(g instanceof Promise)e.push(g.then((x)=>Jr(x,r,f,t,p,d)));else Jr(g,r,f,t,p,d)}if(a.length)r.issues.push({code:"unrecognized_keys",keys:a,input:t,inst:s,continue:!0});if(!e.length)return r;return Promise.all(e).then(()=>r)}var Oh=h("$ZodObject",(e,t)=>{U.init(e,t);let r=Object.getOwnPropertyDescriptor(t,"shape"),n=r?.get?r.get.raw:t.shape??{};if(n){let u=()=>{let l={...n};return Object.defineProperty(t,"shape",{value:l}),u.raw=l,l};u.raw=n,Object.defineProperty(t,"shape",{get:u})}let o=Or(()=>hu(t));R(e,"propValues",(u)=>{let l=u.def.shape,p={};for(let d in l){let m=l[d]._zod;if(m.values){if(!Object.prototype.hasOwnProperty.call(p,d))ve(p,d,new Set);for(let f of m.values)p[d].add(f);if(m.optin!==void 0)p[d].add(void 0)}}return p});let s=Vt,i=t.catchall,a,c=ee.memoizer;c?.attach(e),e._zod.parse=(u,l)=>{a??(a=o.value);let p=u.value;if(!s(p))return u.issues.push({expected:"object",code:"invalid_type",input:p,inst:e}),u;u.value=c?c.alloc(e,u,{},l):{};let d=[],m=a.shape,f=l?.abortEarly,g=u.issues.length;for(let x of a.allKeys){if(f&&u.issues.length!==g){if(Ce(u,g))break;g=u.issues.length}if(x==="__proto__")continue;let y=m[x],w=y._zod.optin,k=y._zod.optout,I=y._zod.run({value:p[x],issues:[]},l);if(I instanceof Promise)d.push(I.then((_)=>Jr(_,u,x,p,w,k)));else Jr(I,u,x,p,w,k)}if(!i)return d.length?Promise.all(d).then(()=>u):u;return gu(d,p,u,l,o.value,e,f===!0)}}),xu=h("$ZodObjectJIT",(e,t)=>{Oh.init(e,t);let r=e._zod.parse,n=Or(()=>hu(t)),o=ee.memoizer,s=(m)=>{let f=n.value,g=f.symbolKeys,x=new Ro(["payload","ctx"],{shape:m,inst:e,memo:o,syms:g}),y=(_)=>`shape[${_}]._zod.run({ value: input[${_}], issues: [] }, ctx)`,w=(_,S)=>`
38
+ let ${_}_ab = false;
39
+ for (let i = 0; i < ${_}.issues.length; i++) {
40
+ const iss = ${_}.issues[i];
41
41
  iss.path = iss.path ? [${S}, ...iss.path] : [${S}];
42
42
  payload.issues.push(iss);
43
- if (iss.continue !== true) ${y}_ab = true;
43
+ if (iss.continue !== true) ${_}_ab = true;
44
44
  }
45
- if (${y}_ab && ctx && ctx.abortEarly) {
45
+ if (${_}_ab && ctx && ctx.abortEarly) {
46
46
  payload.value = newResult;
47
47
  return payload;
48
- }`;x.write("const input = payload.value;");let P=Object.create(null),C=0;for(let y of m.allKeys)P[y]=`key_${C++}`;x.write(o?"const newResult = memo.alloc(inst, payload, {}, ctx);":"const newResult = {};");for(let y of m.allKeys){if(y==="__proto__")continue;let S=P[y],I=typeof y==="symbol"?`syms[${g.indexOf(y)}]`:ia(y),W=`${I} in input`,E=f[y],T=E?._zod?.optin,B=T!==void 0,K=E?._zod?.optout==="optional";if(x.write(`const ${S} = ${_(I)};`),B&&K){let ge=T==="optional"?`${S}_present`:`${S}.value !== undefined || ${S}_present`;x.write(`
48
+ }`;x.write("const input = payload.value;");let k=Object.create(null),I=0;for(let _ of f.allKeys)k[_]=`key_${I++}`;x.write(o?"const newResult = memo.alloc(inst, payload, {}, ctx);":"const newResult = {};");for(let _ of f.allKeys){if(_==="__proto__")continue;let S=k[_],O=typeof _==="symbol"?`syms[${g.indexOf(_)}]`:ma(_),W=`${O} in input`,C=m[_],A=C?._zod?.optin,B=A!==void 0,K=C?._zod?.optout==="optional";if(x.write(`const ${S} = ${y(O)};`),B&&K){let ge=A==="optional"?`${S}_present`:`${S}.value !== undefined || ${S}_present`;x.write(`
49
49
  const ${S}_present = ${W};
50
50
  if (!${S}.issues.length || ${S}_present) {
51
- if (${S}.issues.length) {${w(S,I)}
51
+ if (${S}.issues.length) {${w(S,O)}
52
52
  }
53
53
 
54
54
  if (${ge}) {
55
- newResult[${I}] = ${S}.value;
55
+ newResult[${O}] = ${S}.value;
56
56
  }
57
57
  }
58
58
 
59
59
  `)}else if(!B)x.write(`
60
60
  const ${S}_present = ${W};
61
- if (${S}.issues.length) {${w(S,I)}
61
+ if (${S}.issues.length) {${w(S,O)}
62
62
  }
63
63
  if (!${S}_present && !${S}.issues.length) {
64
64
  payload.issues.push({
65
65
  code: "invalid_type",
66
66
  expected: "nonoptional",
67
67
  input: undefined,
68
- path: [${I}]
68
+ path: [${O}]
69
69
  });
70
70
  if (ctx && ctx.abortEarly) {
71
71
  payload.value = newResult;
@@ -74,26 +74,26 @@ ${t.join(`
74
74
  }
75
75
 
76
76
  if (${S}_present) {
77
- newResult[${I}] = ${S}.value;
77
+ newResult[${O}] = ${S}.value;
78
78
  }
79
79
 
80
80
  `);else if(x.write(`
81
- if (${S}.issues.length) {${w(S,I)}
81
+ if (${S}.issues.length) {${w(S,O)}
82
82
  }
83
- `),T==="defaulted")x.write(`newResult[${I}] = ${S}.value;`);else x.write(`
83
+ `),A==="defaulted")x.write(`newResult[${O}] = ${S}.value;`);else x.write(`
84
84
  if (${S}.value !== undefined || ${W}) {
85
- newResult[${I}] = ${S}.value;
85
+ newResult[${O}] = ${S}.value;
86
86
  }
87
- `)}return x.write("payload.value = newResult;"),x.write("return payload;"),x.compile()},i,a=Ft,c=!X.jitless,l=c&&ca.value,p=t.catchall,d;e._zod.parse=(f,m)=>{d??(d=n.value);let g=f.value;if(!a(g))return f.issues.push({expected:"object",code:"invalid_type",input:g,inst:e}),f;if(c&&l&&m?.async===!1&&m.jitless!==!0){if(!i)i=s(t.shape);if(f=i(f,m),!p)return f;return uu([],g,f,m,d,e,m?.abortEarly===!0)}return r(f,m)}});function wc(e,t,r,n){for(let s of e)if(s.issues.length===0)return t.value=s.value,t;let o=e.filter((s)=>!Ee(s));if(o.length===1)return t.value=o[0].value,o[0];return t.issues.push({code:"invalid_union",input:t.value,inst:r,errors:e.map((s)=>s.issues.map((i)=>Ce(i,n,Q())))}),t}var pu=h("$ZodUnion",(e,t)=>{F.init(e,t),j(e,"optin",(n)=>n.def.options.some((o)=>o._zod.optin==="defaulted")?"defaulted":n.def.options.some((o)=>o._zod.optin!==void 0)?"optional":void 0),j(e,"optout",(n)=>n.def.options.some((o)=>o._zod.optout==="optional")?"optional":void 0),j(e,"values",(n)=>{if(n.def.options.every((o)=>o._zod.values))return new Set(n.def.options.flatMap((o)=>Array.from(o._zod.values)));return}),j(e,"pattern",(n)=>{if(n.def.options.every((o)=>o._zod.pattern)){let o=n.def.options.map((s)=>s._zod.pattern);return new RegExp(`^(${o.map((s)=>kr(s.source)).join("|")})$`)}return});let r=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(n,o)=>{if(r)return r(n,o);let s=!1,i=[];for(let a of t.options){let c=a._zod.run({value:n.value,issues:[]},o);if(c instanceof Promise)i.push(c),s=!0;else{if(c.issues.length===0)return c;i.push(c)}}if(!s)return wc(i,n,e,o);return Promise.all(i).then((a)=>wc(a,n,e,o))}});var du=h("$ZodIntersection",(e,t)=>{F.init(e,t),e._zod.parse=(r,n)=>{let o=r.value,s=t.left._zod.run({value:o,issues:[]},n),i=t.right._zod.run({value:o,issues:[]},n);if(s instanceof Promise||i instanceof Promise)return Promise.all([s,i]).then(([c,u])=>vc(r,c,u));return vc(r,s,i)}});function Io(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e===+t)return{valid:!0,data:e};if(nt(e)&&nt(t)){let r=Object.keys(t),n=Object.keys(e).filter((s)=>r.indexOf(s)!==-1),o={...e,...t};if(Object.prototype.hasOwnProperty.call(o,"__proto__"))delete o.__proto__;for(let s of n){if(s==="__proto__")continue;let i=Io(e[s],t[s]);if(!i.valid)return{valid:!1,mergeErrorPath:[s,...i.mergeErrorPath]};o[s]=i.data}return{valid:!0,data:o}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let r=[];for(let n=0;n<e.length;n++){let o=e[n],s=t[n],i=Io(o,s);if(!i.valid)return{valid:!1,mergeErrorPath:[n,...i.mergeErrorPath]};r.push(i.data)}return{valid:!0,data:r}}return{valid:!1,mergeErrorPath:[]}}function vc(e,t,r){let n=new Map,o,s=new Map,i=(u,l)=>{let p;if(u.code==="unrecognized_keys"&&!u.path?.length)o??(o=u),p=u.keys;else if(u.code==="invalid_key"&&u.origin==="record"&&u.path?.length===1){let d=String(u.path[0]);if(!s.has(d))s.set(d,u);p=[d]}else return!1;for(let d of p){if(!n.has(d))n.set(d,{});n.get(d)[l]=!0}return!0};for(let u of t.issues)if(!i(u,"l"))e.issues.push(u);for(let u of r.issues)if(!i(u,"r"))e.issues.push(u);let a=[...n].filter(([,u])=>u.l&&u.r).map(([u])=>u);if(a.length){let u=o?a.filter((l)=>o.keys.includes(l)):[];if(u.length)e.issues.push({...o,keys:u});for(let l of a)if(!u.includes(l)&&s.has(l))e.issues.push(s.get(l))}let c=Io(t.value,r.value);if(!c.valid){if(Ee(e))return e;throw Error(`Unmergable intersection. Error path: ${JSON.stringify(c.mergeErrorPath)}`)}return e.value=c.data,e}var fu=h("$ZodRecord",(e,t)=>{F.init(e,t);let r=X.memoizer;r?.attach(e),e._zod.parse=(n,o)=>{let s=n.value;if(!nt(s))return n.issues.push({expected:"record",code:"invalid_type",input:s,inst:e}),n;let i=[],a=t.keyType._zod.values;if(a&&!t.partial){n.value=r?r.alloc(e,n,{},o):{};let c=new Set;for(let l of a)if(typeof l==="string"||typeof l==="number"||typeof l==="symbol"){if(c.add(typeof l==="number"?l.toString():l),l==="__proto__")continue;let p=t.keyType._zod.run({value:l,issues:[]},o);if(p instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(p.issues.length){n.issues.push({code:"invalid_key",origin:"record",issues:p.issues.map((m)=>Ce(m,o,Q())),input:l,path:[l],inst:e});continue}let d=p.value;if(d==="__proto__")continue;let f=t.valueType._zod.run({value:s[l],issues:[]},o);if(f instanceof Promise)i.push(f.then((m)=>{if(m.issues.length)n.issues.push(...We(l,m.issues));n.value[d]=m.value}));else{if(f.issues.length)n.issues.push(...We(l,f.issues));n.value[d]=f.value}}let u;for(let l in s)if(!c.has(l))if(t.mode==="loose"){if(l==="__proto__")continue;n.value[l]=s[l]}else u=u??[],u.push(l);if(u&&u.length>0)n.issues.push({code:"unrecognized_keys",input:s,inst:e,keys:u,continue:!0})}else{n.value=r?r.alloc(e,n,{},o):{};let c;for(let u of Reflect.ownKeys(s)){if(u==="__proto__")continue;if(!Object.prototype.propertyIsEnumerable.call(s,u))continue;let l=t.keyType._zod.run({value:u,issues:[]},o);if(l instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(typeof u==="string"&&Vt.test(u)&&l.issues.length){let m=t.keyType._zod.run({value:Number(u),issues:[]},o);if(m instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(m.issues.length===0)l=m}if(l.issues.length){if(t.mode==="loose")n.value[u]=s[u];else if(a)c=c??[],c.push(u);else n.issues.push({code:"invalid_key",origin:"record",issues:l.issues.map((m)=>Ce(m,o,Q())),input:u,path:[u],inst:e});continue}let d=l.value;if(d==="__proto__")continue;let f=t.valueType._zod.run({value:s[u],issues:[]},o);if(f instanceof Promise)i.push(f.then((m)=>{if(m.issues.length)n.issues.push(...We(u,m.issues));n.value[d]=m.value}));else{if(f.issues.length)n.issues.push(...We(u,f.issues));n.value[d]=f.value}}if(c&&c.length>0)n.issues.push({code:"unrecognized_keys",input:s,inst:e,keys:c,continue:!0})}if(i.length)return Promise.all(i).then(()=>n);return n}});var mu=h("$ZodEnum",(e,t)=>{F.init(e,t);let r=Ut(t.entries),n=new Set(r);e._zod.values=n,j(e,"pattern",(o)=>{let s=Ut(o.def.entries).filter((i)=>ua.has(typeof i));return new RegExp(s.length?`^(${s.map((i)=>gt(i.toString())).join("|")})$`:"^[^\\s\\S]$")}),e._zod.parse=(o,s)=>{let i=o.value;if(n.has(i))return o;return o.issues.push({code:"invalid_value",values:r,input:i,inst:e}),o}});var hu=h("$ZodTransform",(e,t)=>{F.init(e,t),e._zod.optin="optional",X.memoizer?.guard(e),e._zod.parse=(r,n)=>{if(n.direction==="backward")throw new Bt(e.constructor.name);let o=t.transform(r.value,r);if(n.async)return(o instanceof Promise?o:Promise.resolve(o)).then((i)=>(r.value=i,r));if(o instanceof Promise)throw new Ie;return r.value=o,r}});function $c(e,t){return e.value=t.issues.length?void 0:t.value,e}var jo=h("$ZodOptional",(e,t)=>{F.init(e,t),j(e,"optin",(r)=>r.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),e._zod.optout="optional",j(e,"values",(r)=>{let n=r.def.innerType._zod.values;return n?new Set([...n,void 0]):void 0}),j(e,"pattern",(r)=>{let n=r.def.innerType._zod.pattern;return n?new RegExp(`^(${kr(n.source)})?$`):void 0}),e._zod.parse=(r,n)=>{if(r.value===void 0){if(t.innerType._zod.optin!=="defaulted")return r;let o=t.innerType._zod.run({value:r.value,issues:[]},n);if(o instanceof Promise)return o.then((s)=>$c(r,s));return $c(r,o)}return t.innerType._zod.run(r,n)}}),gu=h("$ZodExactOptional",(e,t)=>{jo.init(e,t),j(e,"values",(r)=>r.def.innerType._zod.values),j(e,"pattern",(r)=>r.def.innerType._zod.pattern),e._zod.parse=(r,n)=>t.innerType._zod.run(r,n)}),xu=h("$ZodNullable",(e,t)=>{F.init(e,t),j(e,"optin",(r)=>r.def.innerType._zod.optin),j(e,"optout",(r)=>r.def.innerType._zod.optout),j(e,"pattern",(r)=>{let n=r.def.innerType._zod.pattern;return n?new RegExp(`^(${kr(n.source)}|null)$`):void 0}),j(e,"values",(r)=>r.def.innerType._zod.values?new Set([...r.def.innerType._zod.values,null]):void 0),e._zod.parse=(r,n)=>{if(r.value===null)return r;return t.innerType._zod.run(r,n)}}),yu=h("$ZodDefault",(e,t)=>{F.init(e,t),e._zod.optin="defaulted",j(e,"values",(r)=>r.def.innerType._zod.values),e._zod.parse=(r,n)=>{if(n.direction==="backward")return t.innerType._zod.run(r,n);if(r.value===void 0)return r.value=t.defaultValue,r;let o=t.innerType._zod.run(r,n);if(o instanceof Promise)return o.then((s)=>Sc(s,t));return Sc(o,t)}});function Sc(e,t){if(e.value===void 0)e.value=t.defaultValue;return e}var _u=h("$ZodPrefault",(e,t)=>{F.init(e,t),e._zod.optin="defaulted",j(e,"values",(r)=>r.def.innerType._zod.values),e._zod.parse=(r,n)=>{if(n.direction==="backward")return t.innerType._zod.run(r,n);if(r.value===void 0)r.value=t.defaultValue;return t.innerType._zod.run(r,n)}}),bu=h("$ZodNonOptional",(e,t)=>{F.init(e,t),j(e,"values",(r)=>{let n=r.def.innerType._zod.values;return n?new Set([...n].filter((o)=>o!==void 0)):void 0}),e._zod.parse=(r,n)=>{let o=t.innerType._zod.run(r,n);if(o instanceof Promise)return o.then((s)=>kc(s,e));return kc(o,e)}});function kc(e,t){if(!e.issues.length&&e.value===void 0)e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t});return e}function Pc(e,t,r,n){if(!t.issues.length){if(e.value=t.value,t.memo)e.memo=!0;return e}return e.value=r.catchValue({...t,value:e.value,error:{issues:t.issues.map((o)=>Ce(o,n,Q()))},input:e.value}),e}var wu=h("$ZodCatch",(e,t)=>{F.init(e,t),j(e,"optin",(r)=>r.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),j(e,"optout",(r)=>r.def.innerType._zod.optout),j(e,"values",(r)=>r.def.innerType._zod.values),e._zod.parse=(r,n)=>{if(n.direction==="backward")return t.innerType._zod.run(r,n);let o=t.innerType._zod.run({value:r.value,issues:[]},n);if(o instanceof Promise)return o.then((s)=>Pc(r,s,t,n));return Pc(r,o,t,n)}});var vu=h("$ZodPipe",(e,t)=>{F.init(e,t),j(e,"values",(r)=>r.def.in._zod.values),j(e,"optin",(r)=>r.def.in._zod.optin),j(e,"optout",(r)=>r.def.out._zod.optout),j(e,"propValues",(r)=>r.def.in._zod.propValues),e._zod.parse=(r,n)=>{if(n.direction==="backward"){let s=t.out._zod.run(r,n);if(s instanceof Promise)return s.then((i)=>Dr(i,t.in,n));return Dr(s,t.in,n)}let o=t.in._zod.run(r,n);if(o instanceof Promise)return o.then((s)=>Dr(s,t.out,n));return Dr(o,t.out,n)}});function Dr(e,t,r){if(e.issues.some((n)=>n.code!=="unrecognized_keys"))return e.aborted=!0,e;return t._zod.run({value:e.value,issues:e.issues},r)}var $u=h("$ZodReadonly",(e,t)=>{F.init(e,t),j(e,"propValues",(r)=>r.def.innerType._zod.propValues),j(e,"values",(r)=>r.def.innerType._zod.values),j(e,"optin",(r)=>r.def.innerType?._zod?.optin),j(e,"optout",(r)=>r.def.innerType?._zod?.optout),e._zod.parse=(r,n)=>{if(n.direction==="backward")return t.innerType._zod.run(r,n);let o=t.innerType._zod.run(r,n);if(o instanceof Promise)return o.then(zc);return zc(o)}});function zc(e){if(!e.memo)e.value=Object.freeze(e.value);return e}var Su=h("$ZodCustom",(e,t)=>{J.init(e,t),F.init(e,t),e._zod.parse=(r,n)=>r,e._zod.check=(r)=>{let n=r.value,o=t.fn(n);if(o instanceof Promise)return o.then((s)=>Ec(s,r,n,e));Ec(o,r,n,e);return}});function Ec(e,t,r,n){if(!e){let o={code:"custom",input:r,inst:n,path:[...n._zod.def.path??[]],continue:!n._zod.def.abort};if(n._zod.def.params)o.params=n._zod.def.params;t.issues.push(ot(o))}}class Pu extends Error{constructor(){super("Cannot parse a reference cycle that closes through a transform");this.name="ZodCyclicError"}}var Zo="~memo",ku=[];function zu(e){return e!==null&&typeof e==="object"}function Ro(e){return e.map((t)=>t.path?{...t,path:t.path.slice()}:{...t})}var Eu=new WeakMap,Kt=0,Vr=1,Jt=2;function Wr(e,t,r){let n=Eu.get(e);if(n!==void 0)return n?Jt:Kt;if(t.has(e))return Jt;t.add(e);let o=Kt,s=(l)=>{if(o!==Jt&&l?._zod){let p=Wr(l,t,r);if(p>o)o=p}},i=(l,p)=>{let d=Kt;for(let f of Reflect.ownKeys(l)){let m=Object.getOwnPropertyDescriptor(l,f);if(p&&!m.enumerable)continue;let g=m.get?Vr:m.value?._zod?Wr(m.value,t,r):Kt;if(g>d)d=g}return d},a=(l)=>{if(l>o)o=l},c=e._zod.def,u=c.type;switch(u){case"object":{let l=Pr(c);a(l?i(l,!0):Vr),s(c.catchall);break}case"array":s(c.element);break;case"tuple":for(let l of c.items)s(l);s(c.rest);break;case"record":case"map":s(c.keyType),s(c.valueType);break;case"set":s(c.valueType);break;case"union":for(let l of c.options)s(l);break;case"intersection":s(c.left),s(c.right);break;case"optional":case"nullable":case"default":case"prefault":case"catch":case"readonly":case"nonoptional":case"promise":case"success":s(c.innerType);break;case"pipe":s(c.in),s(c.out);break;case"function":s(c.input),s(c.output);break;case"lazy":{let l=c._cachedInner??(r?e._zod.innerType:void 0);a(l?Wr(l,t,!1):Vr);break}case"template_literal":case"string":case"number":case"int":case"boolean":case"bigint":case"symbol":case"undefined":case"null":case"void":case"never":case"any":case"unknown":case"date":case"nan":case"enum":case"literal":case"file":case"transform":case"custom":break;default:for(let l in c){let p=Object.getOwnPropertyDescriptor(c,l);if(!p||p.get)continue;let d=p.value;if(!d||typeof d!=="object")continue;if(d._zod)s(d);else if(Array.isArray(d))for(let f of d)s(f)}}return t.delete(e),mh(e,o)}function mh(e,t){if(t!==Vr)Eu.set(e,t===Jt);return t}function hh(e,t){let r=e.buckets.get(t);if(!r)r=new WeakMap,e.buckets.set(t,r);return r}var Br,Gr=[],gh={alloc(e,t,r){let n=Br;if(!n)return r;Br=void 0;let o={value:r,issues:null};return n.set(t.value,o),Gr.push(o),r},guard(e){var t;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let r=e._zod.parse,n=(o,s)=>{if(s.direction!=="backward"&&xh(s,o.value))throw new Pu;return r(o,s)};if(e._zod.parse=n,e._zod.run===r)e._zod.run=n})},attach(e){var t;let r,n=!1,o,s;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let i=e._zod.parse,a=(c,u)=>{if(r===void 0){let _=Wr(e,new Set,!1);if(_===Kt){if(e._zod.parse=i,e._zod.run===a)e._zod.run=i;return i(c,u)}if(_===Jt||n)r=!0;else n=!0}let l=c.value;if(!zu(l))return i(c,u);let p=u[Zo];if(!p)p={buckets:new WeakMap,backEdges:void 0},u[Zo]=p;let d;if(o===u)d=s;else d=hh(p,e),o=u,s=d;let f=d.get(l);if(f){if(c.value=f.value,f.issues){if(f.issues.length)c.issues.push(...Ro(f.issues))}else c.memo=!0,p.backEdges??(p.backEdges=new WeakSet),p.backEdges.add(f.value);return c}Br=d;let m=Gr.length,g=i(c,u);Br=void 0;let x=Gr.length>m?Gr.pop():void 0;if(g instanceof Promise)return g.then((_)=>{if(x)x.issues=_.issues.length?Ro(_.issues):ku;return _});if(x)x.issues=g.issues.length?Ro(g.issues):ku;return g};if(e._zod.parse=a,e._zod.run===i)e._zod.run=a})}};function Lo(){return gh}function xh(e,t){let r=e[Zo]?.backEdges;return r!==void 0&&zu(t)&&r.has(t)}var yh=()=>{let e={string:{unit:"characters",verb:"to have"},file:{unit:"bytes",verb:"to have"},array:{unit:"items",verb:"to have"},set:{unit:"items",verb:"to have"},map:{unit:"entries",verb:"to have"}};function t(s){return e[s]??null}let r={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",mac:"MAC address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",currency_code:"currency code",credit_card:"credit card number",iban:"IBAN",jwt:"JWT",template_literal:"input"},n={nan:"NaN"};function o(s,i){if(s==="number"&&typeof i==="number"&&!Number.isFinite(i))return String(i);return n[s]??s}return(s)=>{switch(s.code){case"invalid_type":{let i=o(s.expected),a=ma(s.input),c=o(a,s.input);return`Invalid input: expected ${i}, received ${c}`}case"invalid_value":if(s.values.length===1)return`Invalid input: expected ${fo(s.values[0])}`;return`Invalid option: expected one of ${uo(s.values,"|")}`;case"too_big":{let i=s.exact?"exactly ":s.inclusive?"<=":"<",a=t(s.origin);if(a)return`Too big: expected ${s.origin??"value"} to have ${i}${s.maximum.toString()} ${a.unit??"elements"}`;return`Too big: expected ${s.origin??"value"} to be ${i}${s.maximum.toString()}`}case"too_small":{let i=s.exact?"exactly ":s.inclusive?">=":">",a=t(s.origin);if(a)return`Too small: expected ${s.origin} to have ${i}${s.minimum.toString()} ${a.unit}`;return`Too small: expected ${s.origin} to be ${i}${s.minimum.toString()}`}case"invalid_format":{let i=s;if(i.format==="starts_with")return`Invalid string: must start with "${i.prefix}"`;if(i.format==="ends_with")return`Invalid string: must end with "${i.suffix}"`;if(i.format==="includes")return`Invalid string: must include "${i.includes}"`;if(i.format==="regex")return`Invalid string: must match pattern ${i.pattern}`;return`Invalid ${r[i.format]??s.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${s.divisor}`;case"unrecognized_keys":return`Unrecognized key${s.keys.length>1?"s":""}: ${uo(s.keys,", ")}`;case"invalid_key":return`Invalid key in ${s.origin}`;case"invalid_union":if(s.options&&Array.isArray(s.options)&&s.options.length>0)return`Invalid discriminator value. Expected ${s.options.map((a)=>`'${a}'`).join(" | ")}`;if(s.inclusive===!1)return"Invalid input: more than one option matched";return"Invalid input";case"invalid_element":return`Invalid value in ${s.origin}`;default:return"Invalid input"}}};function Do(){return{localeError:yh()}}var Cu;class Iu{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){let r=t[0];if(this._map.set(e,r),r&&typeof r==="object"&&"id"in r)this._idmap.set(r.id,e);return this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let t=this._map.get(e);if(t&&typeof t==="object"&&"id"in t)this._idmap.delete(t.id);return this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let r={...this.get(t)??{}};delete r.id;let n={...r,...this._map.get(e)};return Object.keys(n).length?n:void 0}return this._map.get(e)}has(e){return this._map.has(e)}}function Tu(){return new Iu}(Cu=globalThis).__zod_globalRegistry??(Cu.__zod_globalRegistry=Tu());var Ke=globalThis.__zod_globalRegistry;function Ou(e){if(e.checks)e.checks=[...e.checks];return e}function Au(e,t){return new e(Ou({type:"string",...v(t)}))}function ju(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...v(t)})}function Ru(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...v(t)})}function Zu(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...v(t)})}function Lu(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...v(t)})}function Du(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...v(t)})}function Nu(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...v(t)})}function No(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...v(t)})}function Fu(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...v(t)})}function Uu(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...v(t)})}function Mu(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...v(t)})}function Bu(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...v(t)})}function Gu(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...v(t)})}function Vu(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...v(t)})}function Wu(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...v(t)})}function Ku(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...v(t)})}function Ju(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...v(t)})}function Hu(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...v(t)})}function qu(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...v(t)})}function Yu(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...v(t)})}function Xu(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...v(t)})}function Qu(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...v(t)})}function el(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...v(t)})}function Kr(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...v(t)})}function Jr(e,t){return new e({type:"string",format:"date",check:"string_format",...v(t)})}function Hr(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...v(t)})}function qr(e,t){return new e({type:"string",format:"duration",check:"string_format",...v(t)})}function tl(e,t){return new e(Ou({type:"number",checks:[],...v(t)}))}function rl(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...v(t)})}function nl(e,t){return new e({type:"boolean",...v(t)})}function ol(e){return new e({type:"unknown"})}function sl(e,t){return new e({type:"never",...v(t)})}function Yr(e,t){return new zo({check:"less_than",...v(t),value:e,inclusive:!1})}function Ht(e,t){return new zo({check:"less_than",...v(t),value:e,inclusive:!0})}function Xr(e,t){return new Eo({check:"greater_than",...v(t),value:e,inclusive:!1})}function qt(e,t){return new Eo({check:"greater_than",...v(t),value:e,inclusive:!0})}function Qr(e,t){return new sc({check:"multiple_of",...v(t),value:e})}function en(e,t){return new ac({check:"max_length",...v(t),maximum:e})}function yt(e,t){return new cc({check:"min_length",...v(t),minimum:e})}function tn(e,t){return new uc({check:"length_equals",...v(t),length:e})}function Fo(e,t){return new lc({check:"string_format",format:"regex",...v(t),pattern:e})}function Uo(e){return new pc({check:"string_format",format:"lowercase",...v(e)})}function Mo(e){return new dc({check:"string_format",format:"uppercase",...v(e)})}function Bo(e,t){return new fc({check:"string_format",format:"includes",...v(t),includes:e})}function Go(e,t){return new mc({check:"string_format",format:"starts_with",...v(t),prefix:e})}function Vo(e,t){return new hc({check:"string_format",format:"ends_with",...v(t),suffix:e})}function Je(e){return new gc({check:"overwrite",tx:e})}function Wo(e){return Je((t)=>t.normalize(e))}function Ko(){return Je((e)=>e.trim())}function Jo(){return Je((e)=>e.toLowerCase())}function Ho(){return Je((e)=>e.toUpperCase())}function qo(){return Je((e)=>aa(e))}function il(e,t,r){return new e({type:"array",element:t,...v(r)})}function al(e,t,r){return new e({type:"custom",check:"custom",fn:t,...v(r)})}function cl(e,t){let r=_h((n)=>(n.addIssue=(o)=>{if(typeof o==="string")n.issues.push(ot(o,n.value,r._zod.def));else{let s=o;if(s.fatal)s.continue=!1;if(s.code??(s.code="custom"),!("input"in s))s.input=n.value;s.inst??(s.inst=r),s.continue??(s.continue=!r._zod.def.abort),n.issues.push(ot(s))}},e(n.value,n)),t);return r}function _h(e,t){let r=new J({check:"custom",...v(t)});return r._zod.check=e,r}function Yt(e,...t){for(let r of t)for(let n of Reflect.ownKeys(r))if(Object.prototype.propertyIsEnumerable.call(r,n))ve(e,n,r[n]);return e}function Xo(e){let t=e?.target??"draft-2020-12";if(t==="draft-4")t="draft-04";if(t==="draft-7")t="draft-07";return{processors:e.processors??{},metadataRegistry:e?.metadata??Ke,target:t,unrepresentable:e?.unrepresentable??"throw",override:e?.override??(()=>{}),io:e?.io??"output",counter:0,seen:new Map,sharedDefsExtractedFor:void 0,sharedEmitDoneFor:void 0,cycles:e?.cycles??"ref",reused:e?.reused??"inline",intersections:[],deferred:[],external:e?.external??void 0}}function st(e,t,r,n,o){let s=typeof t.unrepresentable==="function"?t.unrepresentable({zodSchema:e,path:n.path,message:o}):t.unrepresentable;if(s==="any")return!1;if(s===void 0||s==="throw")throw Error(o);return Object.assign(r,s),!0}function G(e,t,r={path:[],schemaPath:[]}){var n;let o=e._zod.def,s=t.seen.get(e);if(s){if(s.count++,r.schemaPath.includes(e))s.cycle=r.path;return s.schema}let i={schema:{},count:1,cycle:void 0,path:r.path};t.seen.set(e,i),t.sharedDefsExtractedFor=void 0,t.sharedEmitDoneFor=void 0;let a=e._zod.toJSONSchema?.();if(a)i.schema=a;else{let l={...r,schemaPath:[...r.schemaPath,e],path:r.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,i.schema,l);else{let d=i.schema,f=t.processors[o.type];if(!f)throw Error(`[toJSONSchema]: Non-representable type encountered: ${o.type}`);f(e,t,d,l)}let p=e._zod.parent;if(p){if(!i.ref)i.ref=p;G(p,t,l),t.seen.get(p).isParent=!0}}let c=t.metadataRegistry.get(e);if(c)Yt(i.schema,c);if(t.io==="input"&&H(e))delete i.schema.examples,delete i.schema.default;if(t.io==="input"&&"_prefault"in i.schema)(n=i.schema).default??(n.default=i.schema._prefault);return delete i.schema._prefault,t.seen.get(e).schema}function ul(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function Qo(e,t){let r=e.seen.get(t);if(!r)throw Error("Unprocessed schema. This is a bug in Zod.");if(e.external&&e.sharedDefsExtractedFor===e.external)return;let n=new Map;for(let i of e.seen.entries()){let a=e.metadataRegistry.get(i[0])?.id;if(a){let c=n.get(a);if(c&&c!==i[0])throw Error(`Duplicate schema id "${a}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);n.set(a,i[0])}}let o=(i)=>{let a=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){let p=e.external.registry.get(i[0])?.id,d=e.external.uri??((m)=>m);if(p)return{ref:d(p)};let f=i[1].defId??i[1].schema.id??`schema${e.counter++}`;return i[1].defId=f,{defId:f,ref:`${d("__shared")}#/${a}/${ul(f)}`}}let c="#",u=`${c}/${a}/`;if(i[1]===r&&!i[1].schema.id)return{ref:c};let l=i[1].schema.id??`__schema${e.counter++}`;return{defId:l,ref:u+ul(l)}},s=(i)=>{if(i[1].schema.$ref)return;let a=i[1],{ref:c,defId:u}=o(i);if(a.def={...a.schema},u)a.defId=u;let l=a.schema;for(let p in l)delete l[p];l.$ref=c};if(e.cycles==="throw")for(let i of e.seen.entries()){let a=i[1];if(a.cycle)throw Error(`Cycle detected: #/${a.cycle?.join("/")}/<root>
87
+ `)}return x.write("payload.value = newResult;"),x.write("return payload;"),x.compile()},i,a=Vt,c=!ee.jitless,l=c&&ha.value,p=t.catchall,d;e._zod.parse=(m,f)=>{d??(d=n.value);let g=m.value;if(!a(g))return m.issues.push({expected:"object",code:"invalid_type",input:g,inst:e}),m;if(c&&l&&f?.async===!1&&f.jitless!==!0){if(!i)i=s(t.shape);if(m=i(m,f),!p)return m;return gu([],g,m,f,d,e,f?.abortEarly===!0)}return r(m,f)}});function Ec(e,t,r,n){for(let s of e)if(s.issues.length===0)return t.value=s.value,t;let o=e.filter((s)=>!Ce(s));if(o.length===1)return t.value=o[0].value,o[0];return t.issues.push({code:"invalid_union",input:t.value,inst:r,errors:e.map((s)=>s.issues.map((i)=>Ie(i,n,te())))}),t}var yu=h("$ZodUnion",(e,t)=>{U.init(e,t),R(e,"optin",(n)=>n.def.options.some((o)=>o._zod.optin==="defaulted")?"defaulted":n.def.options.some((o)=>o._zod.optin!==void 0)?"optional":void 0),R(e,"optout",(n)=>n.def.options.some((o)=>o._zod.optout==="optional")?"optional":void 0),R(e,"values",(n)=>{if(n.def.options.every((o)=>o._zod.values))return new Set(n.def.options.flatMap((o)=>Array.from(o._zod.values)));return}),R(e,"pattern",(n)=>{if(n.def.options.every((o)=>o._zod.pattern)){let o=n.def.options.map((s)=>s._zod.pattern);return new RegExp(`^(${o.map((s)=>Ar(s.source)).join("|")})$`)}return});let r=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(n,o)=>{if(r)return r(n,o);let s=!1,i=[];for(let a of t.options){let c=a._zod.run({value:n.value,issues:[]},o);if(c instanceof Promise)i.push(c),s=!0;else{if(c.issues.length===0)return c;i.push(c)}}if(!s)return Ec(i,n,e,o);return Promise.all(i).then((a)=>Ec(a,n,e,o))}});var _u=h("$ZodIntersection",(e,t)=>{U.init(e,t),e._zod.parse=(r,n)=>{let o=r.value,s=t.left._zod.run({value:o,issues:[]},n),i=t.right._zod.run({value:o,issues:[]},n);if(s instanceof Promise||i instanceof Promise)return Promise.all([s,i]).then(([c,u])=>Cc(r,c,u));return Cc(r,s,i)}});function Lo(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e===+t)return{valid:!0,data:e};if(it(e)&&it(t)){let r=Object.keys(t),n=Object.keys(e).filter((s)=>r.indexOf(s)!==-1),o={...e,...t};if(Object.prototype.hasOwnProperty.call(o,"__proto__"))delete o.__proto__;for(let s of n){if(s==="__proto__")continue;let i=Lo(e[s],t[s]);if(!i.valid)return{valid:!1,mergeErrorPath:[s,...i.mergeErrorPath]};o[s]=i.data}return{valid:!0,data:o}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let r=[];for(let n=0;n<e.length;n++){let o=e[n],s=t[n],i=Lo(o,s);if(!i.valid)return{valid:!1,mergeErrorPath:[n,...i.mergeErrorPath]};r.push(i.data)}return{valid:!0,data:r}}return{valid:!1,mergeErrorPath:[]}}function Cc(e,t,r){let n=new Map,o,s=new Map,i=(u,l)=>{let p;if(u.code==="unrecognized_keys"&&!u.path?.length)o??(o=u),p=u.keys;else if(u.code==="invalid_key"&&u.origin==="record"&&u.path?.length===1){let d=String(u.path[0]);if(!s.has(d))s.set(d,u);p=[d]}else return!1;for(let d of p){if(!n.has(d))n.set(d,{});n.get(d)[l]=!0}return!0};for(let u of t.issues)if(!i(u,"l"))e.issues.push(u);for(let u of r.issues)if(!i(u,"r"))e.issues.push(u);let a=[...n].filter(([,u])=>u.l&&u.r).map(([u])=>u);if(a.length){let u=o?a.filter((l)=>o.keys.includes(l)):[];if(u.length)e.issues.push({...o,keys:u});for(let l of a)if(!u.includes(l)&&s.has(l))e.issues.push(s.get(l))}let c=Lo(t.value,r.value);if(!c.valid){if(Ce(e))return e;throw Error(`Unmergable intersection. Error path: ${JSON.stringify(c.mergeErrorPath)}`)}return e.value=c.data,e}var bu=h("$ZodRecord",(e,t)=>{U.init(e,t);let r=ee.memoizer;r?.attach(e),e._zod.parse=(n,o)=>{let s=n.value;if(!it(s))return n.issues.push({expected:"record",code:"invalid_type",input:s,inst:e}),n;let i=[],a=t.keyType._zod.values;if(a&&!t.partial){n.value=r?r.alloc(e,n,{},o):{};let c=new Set;for(let l of a)if(typeof l==="string"||typeof l==="number"||typeof l==="symbol"){if(c.add(typeof l==="number"?l.toString():l),l==="__proto__")continue;let p=t.keyType._zod.run({value:l,issues:[]},o);if(p instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(p.issues.length){n.issues.push({code:"invalid_key",origin:"record",issues:p.issues.map((f)=>Ie(f,o,te())),input:l,path:[l],inst:e});continue}let d=p.value;if(d==="__proto__")continue;let m=t.valueType._zod.run({value:s[l],issues:[]},o);if(m instanceof Promise)i.push(m.then((f)=>{if(f.issues.length)n.issues.push(...Je(l,f.issues));n.value[d]=f.value}));else{if(m.issues.length)n.issues.push(...Je(l,m.issues));n.value[d]=m.value}}let u;for(let l in s)if(!c.has(l))if(t.mode==="loose"){if(l==="__proto__")continue;n.value[l]=s[l]}else u=u??[],u.push(l);if(u&&u.length>0)n.issues.push({code:"unrecognized_keys",input:s,inst:e,keys:u,continue:!0})}else{n.value=r?r.alloc(e,n,{},o):{};let c;for(let u of Reflect.ownKeys(s)){if(u==="__proto__")continue;if(!Object.prototype.propertyIsEnumerable.call(s,u))continue;let l=t.keyType._zod.run({value:u,issues:[]},o);if(l instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(typeof u==="string"&&qt.test(u)&&l.issues.length){let f=t.keyType._zod.run({value:Number(u),issues:[]},o);if(f instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(f.issues.length===0)l=f}if(l.issues.length){if(t.mode==="loose")n.value[u]=s[u];else if(a)c=c??[],c.push(u);else n.issues.push({code:"invalid_key",origin:"record",issues:l.issues.map((f)=>Ie(f,o,te())),input:u,path:[u],inst:e});continue}let d=l.value;if(d==="__proto__")continue;let m=t.valueType._zod.run({value:s[u],issues:[]},o);if(m instanceof Promise)i.push(m.then((f)=>{if(f.issues.length)n.issues.push(...Je(u,f.issues));n.value[d]=f.value}));else{if(m.issues.length)n.issues.push(...Je(u,m.issues));n.value[d]=m.value}}if(c&&c.length>0)n.issues.push({code:"unrecognized_keys",input:s,inst:e,keys:c,continue:!0})}if(i.length)return Promise.all(i).then(()=>n);return n}});var wu=h("$ZodEnum",(e,t)=>{U.init(e,t);let r=Wt(t.entries),n=new Set(r);e._zod.values=n,R(e,"pattern",(o)=>{let s=Wt(o.def.entries).filter((i)=>ga.has(typeof i));return new RegExp(s.length?`^(${s.map((i)=>bt(i.toString())).join("|")})$`:"^[^\\s\\S]$")}),e._zod.parse=(o,s)=>{let i=o.value;if(n.has(i))return o;return o.issues.push({code:"invalid_value",values:r,input:i,inst:e}),o}});var vu=h("$ZodTransform",(e,t)=>{U.init(e,t),e._zod.optin="optional",ee.memoizer?.guard(e),e._zod.parse=(r,n)=>{if(n.direction==="backward")throw new Jt(e.constructor.name);let o=t.transform(r.value,r);if(n.async)return(o instanceof Promise?o:Promise.resolve(o)).then((i)=>(r.value=i,r));if(o instanceof Promise)throw new Te;return r.value=o,r}});function Ic(e,t){return e.value=t.issues.length?void 0:t.value,e}var Uo=h("$ZodOptional",(e,t)=>{U.init(e,t),R(e,"optin",(r)=>r.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),e._zod.optout="optional",R(e,"values",(r)=>{let n=r.def.innerType._zod.values;return n?new Set([...n,void 0]):void 0}),R(e,"pattern",(r)=>{let n=r.def.innerType._zod.pattern;return n?new RegExp(`^(${Ar(n.source)})?$`):void 0}),e._zod.parse=(r,n)=>{if(r.value===void 0){if(t.innerType._zod.optin!=="defaulted")return r;let o=t.innerType._zod.run({value:r.value,issues:[]},n);if(o instanceof Promise)return o.then((s)=>Ic(r,s));return Ic(r,o)}return t.innerType._zod.run(r,n)}}),$u=h("$ZodExactOptional",(e,t)=>{Uo.init(e,t),R(e,"values",(r)=>r.def.innerType._zod.values),R(e,"pattern",(r)=>r.def.innerType._zod.pattern),e._zod.parse=(r,n)=>t.innerType._zod.run(r,n)}),Su=h("$ZodNullable",(e,t)=>{U.init(e,t),R(e,"optin",(r)=>r.def.innerType._zod.optin),R(e,"optout",(r)=>r.def.innerType._zod.optout),R(e,"pattern",(r)=>{let n=r.def.innerType._zod.pattern;return n?new RegExp(`^(${Ar(n.source)}|null)$`):void 0}),R(e,"values",(r)=>r.def.innerType._zod.values?new Set([...r.def.innerType._zod.values,null]):void 0),e._zod.parse=(r,n)=>{if(r.value===null)return r;return t.innerType._zod.run(r,n)}}),Pu=h("$ZodDefault",(e,t)=>{U.init(e,t),e._zod.optin="defaulted",R(e,"values",(r)=>r.def.innerType._zod.values),e._zod.parse=(r,n)=>{if(n.direction==="backward")return t.innerType._zod.run(r,n);if(r.value===void 0)return r.value=t.defaultValue,r;let o=t.innerType._zod.run(r,n);if(o instanceof Promise)return o.then((s)=>Tc(s,t));return Tc(o,t)}});function Tc(e,t){if(e.value===void 0)e.value=t.defaultValue;return e}var ku=h("$ZodPrefault",(e,t)=>{U.init(e,t),e._zod.optin="defaulted",R(e,"values",(r)=>r.def.innerType._zod.values),e._zod.parse=(r,n)=>{if(n.direction==="backward")return t.innerType._zod.run(r,n);if(r.value===void 0)r.value=t.defaultValue;return t.innerType._zod.run(r,n)}}),zu=h("$ZodNonOptional",(e,t)=>{U.init(e,t),R(e,"values",(r)=>{let n=r.def.innerType._zod.values;return n?new Set([...n].filter((o)=>o!==void 0)):void 0}),e._zod.parse=(r,n)=>{let o=t.innerType._zod.run(r,n);if(o instanceof Promise)return o.then((s)=>Oc(s,e));return Oc(o,e)}});function Oc(e,t){if(!e.issues.length&&e.value===void 0)e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t});return e}function Ac(e,t,r,n){if(!t.issues.length){if(e.value=t.value,t.memo)e.memo=!0;return e}return e.value=r.catchValue({...t,value:e.value,error:{issues:t.issues.map((o)=>Ie(o,n,te()))},input:e.value}),e}var Eu=h("$ZodCatch",(e,t)=>{U.init(e,t),R(e,"optin",(r)=>r.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),R(e,"optout",(r)=>r.def.innerType._zod.optout),R(e,"values",(r)=>r.def.innerType._zod.values),e._zod.parse=(r,n)=>{if(n.direction==="backward")return t.innerType._zod.run(r,n);let o=t.innerType._zod.run({value:r.value,issues:[]},n);if(o instanceof Promise)return o.then((s)=>Ac(r,s,t,n));return Ac(r,o,t,n)}});var Cu=h("$ZodPipe",(e,t)=>{U.init(e,t),R(e,"values",(r)=>r.def.in._zod.values),R(e,"optin",(r)=>r.def.in._zod.optin),R(e,"optout",(r)=>r.def.out._zod.optout),R(e,"propValues",(r)=>r.def.in._zod.propValues),e._zod.parse=(r,n)=>{if(n.direction==="backward"){let s=t.out._zod.run(r,n);if(s instanceof Promise)return s.then((i)=>Wr(i,t.in,n));return Wr(s,t.in,n)}let o=t.in._zod.run(r,n);if(o instanceof Promise)return o.then((s)=>Wr(s,t.out,n));return Wr(o,t.out,n)}});function Wr(e,t,r){if(e.issues.some((n)=>n.code!=="unrecognized_keys"))return e.aborted=!0,e;return t._zod.run({value:e.value,issues:e.issues},r)}var Iu=h("$ZodReadonly",(e,t)=>{U.init(e,t),R(e,"propValues",(r)=>r.def.innerType._zod.propValues),R(e,"values",(r)=>r.def.innerType._zod.values),R(e,"optin",(r)=>r.def.innerType?._zod?.optin),R(e,"optout",(r)=>r.def.innerType?._zod?.optout),e._zod.parse=(r,n)=>{if(n.direction==="backward")return t.innerType._zod.run(r,n);let o=t.innerType._zod.run(r,n);if(o instanceof Promise)return o.then(jc);return jc(o)}});function jc(e){if(!e.memo)e.value=Object.freeze(e.value);return e}var Tu=h("$ZodCustom",(e,t)=>{J.init(e,t),U.init(e,t),e._zod.parse=(r,n)=>r,e._zod.check=(r)=>{let n=r.value,o=t.fn(n);if(o instanceof Promise)return o.then((s)=>Rc(s,r,n,e));Rc(o,r,n,e);return}});function Rc(e,t,r,n){if(!e){let o={code:"custom",input:r,inst:n,path:[...n._zod.def.path??[]],continue:!n._zod.def.abort};if(n._zod.def.params)o.params=n._zod.def.params;t.issues.push(at(o))}}class Au extends Error{constructor(){super("Cannot parse a reference cycle that closes through a transform");this.name="ZodCyclicError"}}var Mo="~memo",Ou=[];function ju(e){return e!==null&&typeof e==="object"}function Fo(e){return e.map((t)=>t.path?{...t,path:t.path.slice()}:{...t})}var Ru=new WeakMap,Xt=0,Qr=1,Qt=2;function en(e,t,r){let n=Ru.get(e);if(n!==void 0)return n?Qt:Xt;if(t.has(e))return Qt;t.add(e);let o=Xt,s=(l)=>{if(o!==Qt&&l?._zod){let p=en(l,t,r);if(p>o)o=p}},i=(l,p)=>{let d=Xt;for(let m of Reflect.ownKeys(l)){let f=Object.getOwnPropertyDescriptor(l,m);if(p&&!f.enumerable)continue;let g=f.get?Qr:f.value?._zod?en(f.value,t,r):Xt;if(g>d)d=g}return d},a=(l)=>{if(l>o)o=l},c=e._zod.def,u=c.type;switch(u){case"object":{let l=jr(c);a(l?i(l,!0):Qr),s(c.catchall);break}case"array":s(c.element);break;case"tuple":for(let l of c.items)s(l);s(c.rest);break;case"record":case"map":s(c.keyType),s(c.valueType);break;case"set":s(c.valueType);break;case"union":for(let l of c.options)s(l);break;case"intersection":s(c.left),s(c.right);break;case"optional":case"nullable":case"default":case"prefault":case"catch":case"readonly":case"nonoptional":case"promise":case"success":s(c.innerType);break;case"pipe":s(c.in),s(c.out);break;case"function":s(c.input),s(c.output);break;case"lazy":{let l=c._cachedInner??(r?e._zod.innerType:void 0);a(l?en(l,t,!1):Qr);break}case"template_literal":case"string":case"number":case"int":case"boolean":case"bigint":case"symbol":case"undefined":case"null":case"void":case"never":case"any":case"unknown":case"date":case"nan":case"enum":case"literal":case"file":case"transform":case"custom":break;default:for(let l in c){let p=Object.getOwnPropertyDescriptor(c,l);if(!p||p.get)continue;let d=p.value;if(!d||typeof d!=="object")continue;if(d._zod)s(d);else if(Array.isArray(d))for(let m of d)s(m)}}return t.delete(e),Ah(e,o)}function Ah(e,t){if(t!==Qr)Ru.set(e,t===Qt);return t}function jh(e,t){let r=e.buckets.get(t);if(!r)r=new WeakMap,e.buckets.set(t,r);return r}var Yr,Xr=[],Rh={alloc(e,t,r){let n=Yr;if(!n)return r;Yr=void 0;let o={value:r,issues:null};return n.set(t.value,o),Xr.push(o),r},guard(e){var t;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let r=e._zod.parse,n=(o,s)=>{if(s.direction!=="backward"&&Lh(s,o.value))throw new Au;return r(o,s)};if(e._zod.parse=n,e._zod.run===r)e._zod.run=n})},attach(e){var t;let r,n=!1,o,s;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let i=e._zod.parse,a=(c,u)=>{if(r===void 0){let y=en(e,new Set,!1);if(y===Xt){if(e._zod.parse=i,e._zod.run===a)e._zod.run=i;return i(c,u)}if(y===Qt||n)r=!0;else n=!0}let l=c.value;if(!ju(l))return i(c,u);let p=u[Mo];if(!p)p={buckets:new WeakMap,backEdges:void 0},u[Mo]=p;let d;if(o===u)d=s;else d=jh(p,e),o=u,s=d;let m=d.get(l);if(m){if(c.value=m.value,m.issues){if(m.issues.length)c.issues.push(...Fo(m.issues))}else c.memo=!0,p.backEdges??(p.backEdges=new WeakSet),p.backEdges.add(m.value);return c}Yr=d;let f=Xr.length,g=i(c,u);Yr=void 0;let x=Xr.length>f?Xr.pop():void 0;if(g instanceof Promise)return g.then((y)=>{if(x)x.issues=y.issues.length?Fo(y.issues):Ou;return y});if(x)x.issues=g.issues.length?Fo(g.issues):Ou;return g};if(e._zod.parse=a,e._zod.run===i)e._zod.run=a})}};function Bo(){return Rh}function Lh(e,t){let r=e[Mo]?.backEdges;return r!==void 0&&ju(t)&&r.has(t)}var Zh=()=>{let e={string:{unit:"characters",verb:"to have"},file:{unit:"bytes",verb:"to have"},array:{unit:"items",verb:"to have"},set:{unit:"items",verb:"to have"},map:{unit:"entries",verb:"to have"}};function t(s){return e[s]??null}let r={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",mac:"MAC address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",currency_code:"currency code",credit_card:"credit card number",iban:"IBAN",jwt:"JWT",template_literal:"input"},n={nan:"NaN"};function o(s,i){if(s==="number"&&typeof i==="number"&&!Number.isFinite(i))return String(i);return n[s]??s}return(s)=>{switch(s.code){case"invalid_type":{let i=o(s.expected),a=wa(s.input),c=o(a,s.input);return`Invalid input: expected ${i}, received ${c}`}case"invalid_value":if(s.values.length===1)return`Invalid input: expected ${_o(s.values[0])}`;return`Invalid option: expected one of ${go(s.values,"|")}`;case"too_big":{let i=s.exact?"exactly ":s.inclusive?"<=":"<",a=t(s.origin);if(a)return`Too big: expected ${s.origin??"value"} to have ${i}${s.maximum.toString()} ${a.unit??"elements"}`;return`Too big: expected ${s.origin??"value"} to be ${i}${s.maximum.toString()}`}case"too_small":{let i=s.exact?"exactly ":s.inclusive?">=":">",a=t(s.origin);if(a)return`Too small: expected ${s.origin} to have ${i}${s.minimum.toString()} ${a.unit}`;return`Too small: expected ${s.origin} to be ${i}${s.minimum.toString()}`}case"invalid_format":{let i=s;if(i.format==="starts_with")return`Invalid string: must start with "${i.prefix}"`;if(i.format==="ends_with")return`Invalid string: must end with "${i.suffix}"`;if(i.format==="includes")return`Invalid string: must include "${i.includes}"`;if(i.format==="regex")return`Invalid string: must match pattern ${i.pattern}`;return`Invalid ${r[i.format]??s.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${s.divisor}`;case"unrecognized_keys":return`Unrecognized key${s.keys.length>1?"s":""}: ${go(s.keys,", ")}`;case"invalid_key":return`Invalid key in ${s.origin}`;case"invalid_union":if(s.options&&Array.isArray(s.options)&&s.options.length>0)return`Invalid discriminator value. Expected ${s.options.map((a)=>`'${a}'`).join(" | ")}`;if(s.inclusive===!1)return"Invalid input: more than one option matched";return"Invalid input";case"invalid_element":return`Invalid value in ${s.origin}`;default:return"Invalid input"}}};function Go(){return{localeError:Zh()}}var Lu;class Zu{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){let r=t[0];if(this._map.set(e,r),r&&typeof r==="object"&&"id"in r)this._idmap.set(r.id,e);return this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let t=this._map.get(e);if(t&&typeof t==="object"&&"id"in t)this._idmap.delete(t.id);return this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let r={...this.get(t)??{}};delete r.id;let n={...r,...this._map.get(e)};return Object.keys(n).length?n:void 0}return this._map.get(e)}has(e){return this._map.has(e)}}function Du(){return new Zu}(Lu=globalThis).__zod_globalRegistry??(Lu.__zod_globalRegistry=Du());var He=globalThis.__zod_globalRegistry;function Nu(e){if(e.checks)e.checks=[...e.checks];return e}function Uu(e,t){return new e(Nu({type:"string",...v(t)}))}function Fu(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...v(t)})}function Mu(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...v(t)})}function Bu(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...v(t)})}function Gu(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...v(t)})}function Vu(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...v(t)})}function Wu(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...v(t)})}function Vo(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...v(t)})}function Ku(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...v(t)})}function Ju(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...v(t)})}function Hu(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...v(t)})}function qu(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...v(t)})}function Yu(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...v(t)})}function Xu(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...v(t)})}function Qu(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...v(t)})}function el(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...v(t)})}function tl(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...v(t)})}function rl(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...v(t)})}function nl(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...v(t)})}function ol(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...v(t)})}function sl(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...v(t)})}function il(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...v(t)})}function al(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...v(t)})}function tn(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...v(t)})}function rn(e,t){return new e({type:"string",format:"date",check:"string_format",...v(t)})}function nn(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...v(t)})}function on(e,t){return new e({type:"string",format:"duration",check:"string_format",...v(t)})}function cl(e,t){return new e(Nu({type:"number",checks:[],...v(t)}))}function ul(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...v(t)})}function ll(e,t){return new e({type:"boolean",...v(t)})}function pl(e){return new e({type:"unknown"})}function dl(e,t){return new e({type:"never",...v(t)})}function sn(e,t){return new Ao({check:"less_than",...v(t),value:e,inclusive:!1})}function er(e,t){return new Ao({check:"less_than",...v(t),value:e,inclusive:!0})}function an(e,t){return new jo({check:"greater_than",...v(t),value:e,inclusive:!1})}function tr(e,t){return new jo({check:"greater_than",...v(t),value:e,inclusive:!0})}function cn(e,t){return new dc({check:"multiple_of",...v(t),value:e})}function un(e,t){return new fc({check:"max_length",...v(t),maximum:e})}function vt(e,t){return new hc({check:"min_length",...v(t),minimum:e})}function ln(e,t){return new gc({check:"length_equals",...v(t),length:e})}function Wo(e,t){return new xc({check:"string_format",format:"regex",...v(t),pattern:e})}function Ko(e){return new yc({check:"string_format",format:"lowercase",...v(e)})}function Jo(e){return new _c({check:"string_format",format:"uppercase",...v(e)})}function Ho(e,t){return new bc({check:"string_format",format:"includes",...v(t),includes:e})}function qo(e,t){return new wc({check:"string_format",format:"starts_with",...v(t),prefix:e})}function Yo(e,t){return new vc({check:"string_format",format:"ends_with",...v(t),suffix:e})}function qe(e){return new $c({check:"overwrite",tx:e})}function Xo(e){return qe((t)=>t.normalize(e))}function Qo(){return qe((e)=>e.trim())}function es(){return qe((e)=>e.toLowerCase())}function ts(){return qe((e)=>e.toUpperCase())}function rs(){return qe((e)=>fa(e))}function ml(e,t,r){return new e({type:"array",element:t,...v(r)})}function fl(e,t,r){return new e({type:"custom",check:"custom",fn:t,...v(r)})}function hl(e,t){let r=Dh((n)=>(n.addIssue=(o)=>{if(typeof o==="string")n.issues.push(at(o,n.value,r._zod.def));else{let s=o;if(s.fatal)s.continue=!1;if(s.code??(s.code="custom"),!("input"in s))s.input=n.value;s.inst??(s.inst=r),s.continue??(s.continue=!r._zod.def.abort),n.issues.push(at(s))}},e(n.value,n)),t);return r}function Dh(e,t){let r=new J({check:"custom",...v(t)});return r._zod.check=e,r}function rr(e,...t){for(let r of t)for(let n of Reflect.ownKeys(r))if(Object.prototype.propertyIsEnumerable.call(r,n))ve(e,n,r[n]);return e}function os(e){let t=e?.target??"draft-2020-12";if(t==="draft-4")t="draft-04";if(t==="draft-7")t="draft-07";return{processors:e.processors??{},metadataRegistry:e?.metadata??He,target:t,unrepresentable:e?.unrepresentable??"throw",override:e?.override??(()=>{}),io:e?.io??"output",counter:0,seen:new Map,sharedDefsExtractedFor:void 0,sharedEmitDoneFor:void 0,cycles:e?.cycles??"ref",reused:e?.reused??"inline",intersections:[],deferred:[],external:e?.external??void 0}}function ct(e,t,r,n,o){let s=typeof t.unrepresentable==="function"?t.unrepresentable({zodSchema:e,path:n.path,message:o}):t.unrepresentable;if(s==="any")return!1;if(s===void 0||s==="throw")throw Error(o);return Object.assign(r,s),!0}function V(e,t,r={path:[],schemaPath:[]}){var n;let o=e._zod.def,s=t.seen.get(e);if(s){if(s.count++,r.schemaPath.includes(e))s.cycle=r.path;return s.schema}let i={schema:{},count:1,cycle:void 0,path:r.path};t.seen.set(e,i),t.sharedDefsExtractedFor=void 0,t.sharedEmitDoneFor=void 0;let a=e._zod.toJSONSchema?.();if(a)i.schema=a;else{let l={...r,schemaPath:[...r.schemaPath,e],path:r.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,i.schema,l);else{let d=i.schema,m=t.processors[o.type];if(!m)throw Error(`[toJSONSchema]: Non-representable type encountered: ${o.type}`);m(e,t,d,l)}let p=e._zod.parent;if(p){if(!i.ref)i.ref=p;V(p,t,l),t.seen.get(p).isParent=!0}}let c=t.metadataRegistry.get(e);if(c)rr(i.schema,c);if(t.io==="input"&&Y(e))delete i.schema.examples,delete i.schema.default;if(t.io==="input"&&"_prefault"in i.schema)(n=i.schema).default??(n.default=i.schema._prefault);return delete i.schema._prefault,t.seen.get(e).schema}function gl(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function ss(e,t){let r=e.seen.get(t);if(!r)throw Error("Unprocessed schema. This is a bug in Zod.");if(e.external&&e.sharedDefsExtractedFor===e.external)return;let n=new Map;for(let i of e.seen.entries()){let a=e.metadataRegistry.get(i[0])?.id;if(a){let c=n.get(a);if(c&&c!==i[0])throw Error(`Duplicate schema id "${a}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);n.set(a,i[0])}}let o=(i)=>{let a=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){let p=e.external.registry.get(i[0])?.id,d=e.external.uri??((f)=>f);if(p)return{ref:d(p)};let m=i[1].defId??i[1].schema.id??`schema${e.counter++}`;return i[1].defId=m,{defId:m,ref:`${d("__shared")}#/${a}/${gl(m)}`}}let c="#",u=`${c}/${a}/`;if(i[1]===r&&!i[1].schema.id)return{ref:c};let l=i[1].schema.id??`__schema${e.counter++}`;return{defId:l,ref:u+gl(l)}},s=(i)=>{if(i[1].schema.$ref)return;let a=i[1],{ref:c,defId:u}=o(i);if(a.def={...a.schema},u)a.defId=u;let l=a.schema;for(let p in l)delete l[p];l.$ref=c};if(e.cycles==="throw")for(let i of e.seen.entries()){let a=i[1];if(a.cycle)throw Error(`Cycle detected: #/${a.cycle?.join("/")}/<root>
88
88
 
89
- Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let i of e.seen.entries()){let a=i[1];if(t===i[0]){s(i);continue}if(e.external){let u=e.external.registry.get(i[0])?.id;if(t!==i[0]&&u){s(i);continue}}if(e.metadataRegistry.get(i[0])?.id){s(i);continue}if(a.cycle){s(i);continue}if(a.count>1){if(e.reused==="ref")s(i)}}if(e.external)e.sharedDefsExtractedFor=e.external}function dl(e){let t=e.anyOf;if(!Array.isArray(t)||t.length===0||e.type!==void 0)return;let r=[];for(let n of t){if(!n||typeof n!=="object")return;dl(n);let o=Object.keys(n);if(o.length!==1||o[0]!=="type")return;let s=n.type;for(let i of Array.isArray(s)?s:[s]){if(typeof i!=="string")return;if(!r.includes(i))r.push(i)}}delete e.anyOf,e.type=r.length===1?r[0]:r}var fl=new Set(["type","properties","required","additionalProperties"]),ll=["oneOf","anyOf"];function pl(e){let t=e.additionalProperties;if(t===void 0||t===!1||typeof t!=="object"||t===null)return null;return Object.keys(t).length?t:null}function Yo(e){let t=[];for(let s of e){if(typeof s!=="object"||s.type!=="object")return null;for(let i in s)if(!fl.has(i))return null;t.push(s)}let r={},n=new Set;for(let s of t){for(let i in s.properties){if(Object.prototype.hasOwnProperty.call(r,i))continue;let a=[];for(let u of t){let l=u.properties?.[i]??pl(u);if(l===null||l===void 0)continue;if(!a.some((p)=>JSON.stringify(p)===JSON.stringify(l)))a.push(l)}let c=a.length===1?a[0]:Yo(a)??{allOf:a};ve(r,i,c)}for(let i of s.required??[])n.add(i)}let o={type:"object",properties:r};if(n.size)o.required=[...n];if(t.every((s)=>s.additionalProperties===!1))o.additionalProperties=!1;else{let s=[];for(let i of t){let a=pl(i);if(a&&!s.some((c)=>JSON.stringify(c)===JSON.stringify(a)))s.push(a)}if(s.length===1)o.additionalProperties=s[0];else if(s.length>1)o.additionalProperties={allOf:s}}return o}function bh(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let o of fl)if(o in e)return;let r=t.filter((o)=>ll.some((s)=>Array.isArray(o[s]))),n=null;if(!r.length)n=Yo(t);else{let o=r[0],s=ll.find((c)=>Array.isArray(o[c]));if(Object.keys(o).length!==1)return;let i=t.filter((c)=>c!==o),a=o[s].map((c)=>Yo([...i,c]));if(a.some((c)=>!c))return;n={[s]:a}}if(!n)return;delete e.allOf,Yt(e,n)}function es(e,t){let r=e.seen.get(t);if(!r)throw Error("Unprocessed schema. This is a bug in Zod.");let n=(a)=>{let c=e.seen.get(a);if(c.ref===null)return;let u=c.def??c.schema,l={...u},p=c.ref;if(c.ref=null,p){n(p);let f=e.seen.get(p),m=f.schema;if(m.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0"))u.allOf=u.allOf??[],u.allOf.push(m);else Yt(u,m);if(Yt(u,l),a._zod.parent===p)for(let x in u){if(x==="$ref"||x==="allOf")continue;if(!(x in l))delete u[x]}if(m.$ref&&f.def)for(let x in u){if(x==="$ref"||x==="allOf")continue;if(x in f.def&&JSON.stringify(u[x])===JSON.stringify(f.def[x]))delete u[x]}}let d=a._zod.parent;if(d&&d!==p){n(d);let f=e.seen.get(d);if(f?.schema.$ref){if(u.$ref=f.schema.$ref,f.def)for(let m in u){if(m==="$ref"||m==="allOf")continue;if(m in f.def&&JSON.stringify(u[m])===JSON.stringify(f.def[m]))delete u[m]}}}e.override({zodSchema:a,jsonSchema:u,path:c.path??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(let a of[...e.seen.entries()].reverse())n(a[0]);if(e.target!=="openapi-3.0")for(let a of e.seen.entries())dl(a[1].def??a[1].schema);for(let a of e.deferred)a();if(e.intersections.length){let a=new Map;for(let c of e.seen.values())for(let u of[c.schema,c.def]){let l=u?.allOf;if(!Array.isArray(l))continue;let p=a.get(l);if(p)p.push(u);else a.set(l,[u])}for(let c of e.intersections)for(let u of a.get(c)??[])bh(u)}}let o={};if(e.target==="draft-2020-12")o.$schema="https://json-schema.org/draft/2020-12/schema";else if(e.target==="draft-07")o.$schema="http://json-schema.org/draft-07/schema#";else if(e.target==="draft-04")o.$schema="http://json-schema.org/draft-04/schema#";else if(e.target==="openapi-3.0");if(e.external?.uri){let a=e.external.registry.get(t)?.id;if(!a)throw Error("Schema is missing an `id` property");o.$id=e.external.uri(a)}Yt(o,r.defId?r.schema:r.def??r.schema);let s=e.metadataRegistry.get(t)?.id;if(s!==void 0&&o.id===s)delete o.id;let i=e.external?.defs??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(let a of e.seen.entries()){let c=a[1];if(c.def&&c.defId){if(c.def.id===c.defId)delete c.def.id;ve(i,c.defId,c.def)}}if(e.external)e.sharedEmitDoneFor=e.external;if(e.external);else if(Object.keys(i).length>0)if(e.target==="draft-2020-12")o.$defs=i;else o.definitions=i;try{let a=JSON.parse(JSON.stringify(o));return Object.defineProperty(a,"~standard",{value:{...t["~standard"],jsonSchema:{input:Xt(t,"input",e.processors),output:Xt(t,"output",e.processors)}},enumerable:!1,writable:!1}),a}catch(a){throw Error("Error converting schema to JSON.")}}function H(e,t){let r=t??{seen:new Set};if(r.seen.has(e))return!1;r.seen.add(e);let n=e._zod.def;if(n.type==="transform")return!0;if(n.type==="array")return H(n.element,r);if(n.type==="set")return H(n.valueType,r);if(n.type==="lazy")return H(n.getter(),r);if(n.type==="promise"||n.type==="optional"||n.type==="nonoptional"||n.type==="nullable"||n.type==="readonly"||n.type==="default"||n.type==="prefault"||n.type==="catch")return H(n.innerType,r);if(n.type==="intersection")return H(n.left,r)||H(n.right,r);if(n.type==="record"||n.type==="map")return H(n.keyType,r)||H(n.valueType,r);if(n.type==="pipe"){if(e._zod.traits.has("$ZodCodec"))return!0;return H(n.in,r)||H(n.out,r)}if(n.type==="object"){for(let o in n.shape)if(H(n.shape[o],r))return!0;return!1}if(n.type==="union"){for(let o of n.options)if(H(o,r))return!0;return!1}if(n.type==="tuple"){for(let o of n.items)if(H(o,r))return!0;if(n.rest&&H(n.rest,r))return!0;return!1}return!1}var ml=(e,t={})=>(r)=>{let n=Xo({...r,processors:t});return G(e,n),Qo(n,e),es(n,e)},Xt=(e,t,r={})=>(n)=>{let{libraryOptions:o,target:s}=n??{},i=Xo({...o??{},target:s,io:t,processors:r});return G(e,i),Qo(i,e),es(i,e)};var _t=(e,t,r)=>{if(e[t]===void 0||r>e[t])e[t]=r},bt=(e,t,r)=>{if(e[t]===void 0||r<e[t])e[t]=r},hl=(e,t)=>{_t(e,"minimum",t),bt(e,"maximum",t)},_l=(e,t)=>{if(e.multipleOf??(e.multipleOf=[]),!e.multipleOf.includes(t))e.multipleOf.push(t)},bl=(e,t)=>{e.patterns??(e.patterns=new Set),e.patterns.add(t)},wl=(e,t)=>{e.mime=e.mime?e.mime.filter((r)=>t.includes(r)):[...t]},vl=(e,t)=>{if(e.format=t,t.includes("int"))e.isInt=!0},gl=(e,t)=>_t(e,"minimum",t.minimum),xl=(e,t)=>bt(e,"maximum",t.maximum),yl=(e)=>(t,r)=>{vl(t,r.format);let[n,o]=e[r.format];_t(t,"minimum",n),bt(t,"maximum",o)},wh={greater_than:(e,t)=>_t(e,t.inclusive?"minimum":"exclusiveMinimum",t.value),less_than:(e,t)=>bt(e,t.inclusive?"maximum":"exclusiveMaximum",t.value),multiple_of:(e,t)=>_l(e,t.value),number_format:yl(zr),bigint_format:yl(mo),min_length:gl,max_length:xl,length_equals:(e,t)=>hl(e,t.length),min_size:gl,max_size:xl,size_equals:(e,t)=>hl(e,t.size),string_format:(e,t)=>{if(vl(e,t.format),t.pattern)bl(e,t.pattern);if(t.format==="base64"||t.format==="base64url")e.contentEncoding=t.format;if(t.local||t.precision===-1)e.laxFormat=!0},mime_type:(e,t)=>wl(e,t.mime)};function de(e){let t={},r=e._zod.def,n=e._zod.traits.has("$ZodCheck")?[e,...r.checks??[]]:r.checks??[];for(let s of n)wh[s._zod.def.check]?.(t,s._zod.def);let o=e._zod.bag;if(o.minimum!==void 0)_t(t,"minimum",o.minimum);if(o.exclusiveMinimum!==void 0)_t(t,"exclusiveMinimum",o.exclusiveMinimum);if(o.maximum!==void 0)bt(t,"maximum",o.maximum);if(o.exclusiveMaximum!==void 0)bt(t,"exclusiveMaximum",o.exclusiveMaximum);if(o.multipleOf!==void 0)_l(t,o.multipleOf);if(o.format!==void 0){if(t.format??(t.format=o.format),o.format.includes("int"))t.isInt=!0}if(o.mime)wl(t,o.mime);for(let s of o.patterns??[])bl(t,s);return t}var vh={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},$h=new Map([[Oo,Ka],[Mr,Ja]]),$l=(e)=>$h.get(e)??e,Sl=(e,t,r,n)=>{let o=r;o.type="string";let{minimum:s,maximum:i,format:a,patterns:c,contentEncoding:u,laxFormat:l}=de(e);if(typeof s==="number")o.minLength=s;if(typeof i==="number")o.maxLength=i;if(a){if(o.format=vh[a]??a,o.format==="")delete o.format;if(a==="time"||l)delete o.format}if(u)o.contentEncoding=u;if(c&&c.size>0){let p=[...c].map($l);if(p.length===1)o.pattern=p[0].source;else if(p.length>1)o.allOf=[...p.map((d)=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:d.source}))]}},kl=(e,t,r,n)=>{let o=r,{minimum:s,maximum:i,multipleOf:a,exclusiveMaximum:c,exclusiveMinimum:u,isInt:l}=de(e);o.type=l?"integer":"number";let p=typeof u==="number"&&u>=(s??Number.NEGATIVE_INFINITY),d=typeof c==="number"&&c<=(i??Number.POSITIVE_INFINITY),f=t.target==="draft-04"||t.target==="openapi-3.0";if(p)if(f)o.minimum=u,o.exclusiveMinimum=!0;else o.exclusiveMinimum=u;else if(typeof s==="number")o.minimum=s;if(d)if(f)o.maximum=c,o.exclusiveMaximum=!0;else o.exclusiveMaximum=c;else if(typeof i==="number")o.maximum=i;if(a){let m=new Set;for(let _ of a)if(Number.isFinite(_)&&_!==0)m.add(Math.abs(_));else st(e,t,o,n,`A multipleOf divisor of ${_} cannot be represented in JSON Schema`);let[g,...x]=m;if(g!==void 0)o.multipleOf=g;if(x.length)o.allOf=[...o.allOf??[],...x.map((_)=>({multipleOf:_}))]}},Pl=(e,t,r,n)=>{r.type="boolean"};var zl=(e,t,r,n)=>{r.not={}};var El=(e,t,r,n)=>{};var Cl=(e,t,r,n)=>{let o=e._zod.def,s=Ut(o.entries);if(s.length===0){r.not={};return}if(s.every((i)=>typeof i==="number"))r.type="number";if(s.every((i)=>typeof i==="string"))r.type="string";r.enum=s};var Il=(e,t,r,n)=>{st(e,t,r,n,"Custom types cannot be represented in JSON Schema")};var Tl=(e,t,r,n)=>{st(e,t,r,n,"Transforms cannot be represented in JSON Schema")};var Ol=(e,t,r,n)=>{let o=r,s=e._zod.def,{minimum:i,maximum:a}=de(e);if(typeof i==="number")o.minItems=i;if(typeof a==="number")o.maxItems=a;o.type="array",o.items=G(s.element,t,{...n,path:[...n.path,"items"]})};function rn(e){let t=e._zod.def;if(t.type==="pipe"&&t.in._zod.traits.has("$ZodTransform"))return rn(t.out);if(t.type==="catch")return rn(t.innerType);return e._zod.optin}var Al=(e,t,r,n)=>{let o=r,s=e._zod.def,i=s.shape;if(Object.getOwnPropertySymbols(i).length&&st(e,t,o,n,"Symbol keys cannot be represented in JSON Schema"))return;o.type="object",o.properties={};for(let u in i)ve(o.properties,u,G(i[u],t,{...n,path:[...n.path,"properties",u]}));let c=[];for(let u of Object.keys(i)){let l=s.shape[u];if(t.io==="input"?rn(l)===void 0:l._zod.optout===void 0)c.push(u)}if(c.length>0)o.required=c;if(s.catchall?._zod.def.type==="never")o.additionalProperties=!1;else if(!s.catchall){if(t.io==="output")o.additionalProperties=!1}else if(s.catchall)o.additionalProperties=G(s.catchall,t,{...n,path:[...n.path,"additionalProperties"]})},jl=(e,t,r,n)=>{let o=e._zod.def,s=o.inclusive===!1,i=o.options.map((a,c)=>G(a,t,{...n,path:[...n.path,s?"oneOf":"anyOf",c]}));if(s)r.oneOf=i;else r.anyOf=i},Rl=(e,t,r,n)=>{let o=e._zod.def,s=G(o.left,t,{...n,path:[...n.path,"allOf",0]}),i=G(o.right,t,{...n,path:[...n.path,"allOf",1]}),a=(u)=>("allOf"in u)&&Object.keys(u).length===1,c=[...a(s)?s.allOf:[s],...a(i)?i.allOf:[i]];r.allOf=c,t.intersections.push(c)};function ts(e,t,r){if(t.$ref){if(r.has(t))return t;r.add(t);let m=e.get(t)?.def;if(!m)return t;let g=ts(e,m,r);return g===m?t:g}for(let m of["anyOf","oneOf"]){let g=t[m];if(!Array.isArray(g))continue;let x=g.map((_)=>ts(e,_,r));if(x.some((_,w)=>_!==g[w]))t={...t,[m]:x}}let n=Array.isArray(t.type)?t.type:[t.type],o=!n.includes("string")&&n.some((m)=>m==="number"||m==="integer"),s=t.enum??(t.const!==void 0?[t.const]:void 0);if(!o&&!s?.some((m)=>typeof m==="number"))return t;let{minimum:i,maximum:a,exclusiveMinimum:c,exclusiveMaximum:u,multipleOf:l,format:p,id:d,...f}=t;if(f.enum)f.enum=f.enum.map((m)=>typeof m==="number"?String(m):m);else if(typeof f.const==="number")f.const=String(f.const);if(!o)return f;if(f.type="string",!s)f.pattern=(n.includes("number")?Vt:ko).source;return f}var rs=new WeakMap;function Sh(e){let t=new Map;for(let n of e.seen.values())if(n.def&&!t.has(n.schema))t.set(n.schema,n);let r=new Map;for(let n of rs.get(e)??[]){let o=e.seen.get(n),s=(o?.def??o?.schema)?.propertyNames;if(!s||s===!0||r.has(s))continue;let i=ts(t,s,new Set);if(i!==s)r.set(s,i)}if(!r.size)return;for(let n of e.seen.values())for(let o of[n.schema,n.def]){let s=o&&r.get(o.propertyNames);if(s)o.propertyNames=s}}var Zl=(e,t,r,n)=>{let o=r,s=e._zod.def;o.type="object";let i=s.keyType,a=de(i).patterns;if(s.mode==="loose"&&a&&a.size>0){let l=G(s.valueType,t,{...n,path:[...n.path,"patternProperties","*"]});o.patternProperties={};for(let p of a)ve(o.patternProperties,$l(p).source,l)}else{if(t.target==="draft-07"||t.target==="draft-2020-12"){o.propertyNames=G(s.keyType,t,{...n,path:[...n.path,"propertyNames"]});let l=rs.get(t);if(!l)l=[],rs.set(t,l),t.deferred.push(()=>Sh(t));l.push(e)}o.additionalProperties=G(s.valueType,t,{...n,path:[...n.path,"additionalProperties"]})}let c=i._zod.values,u=t.io==="input"&&rn(s.valueType)!==void 0;if(c&&!s.partial&&!u){let l=[...c].filter((p)=>typeof p==="string"||typeof p==="number");if(l.length>0)o.required=l.map(String)}},Ll=(e,t,r,n)=>{let o=e._zod.def,s=G(o.innerType,t,n),i=t.seen.get(e);if(t.target==="openapi-3.0")i.ref=o.innerType,r.nullable=!0;else r.anyOf=[s,{type:"null"}]},Dl=(e,t,r,n)=>{let o=e._zod.def;G(o.innerType,t,n);let s=t.seen.get(e);s.ref=o.innerType},ns=Symbol();function Nl(e,t,r,n,o){let s=!1,i=JSON.stringify(e,(a,c)=>{if(typeof c!=="bigint")return c;return s=!0,null});if(!s)return JSON.parse(i);return st(t,r,n,o,"BigInt defaults cannot be represented in JSON Schema"),ns}var Fl=(e,t,r,n)=>{let o=e._zod.def;G(o.innerType,t,n);let s=t.seen.get(e);s.ref=o.innerType;let i=Nl(o.defaultValue,e,t,r,n);if(i!==ns)r.default=i},Ul=(e,t,r,n)=>{let o=e._zod.def;G(o.innerType,t,n);let s=t.seen.get(e);if(s.ref=o.innerType,t.io!=="input")return;let i=Nl(o.defaultValue,e,t,r,n);if(i!==ns)r._prefault=i},Ml=(e,t,r,n)=>{let o=e._zod.def;G(o.innerType,t,n);let s=t.seen.get(e);s.ref=o.innerType;let i;try{i=o.catchValue(void 0)}catch{st(e,t,r,n,"Dynamic catch values are not supported in JSON Schema");return}r.default=i},Bl=(e,t,r,n)=>{let o=e._zod.def,s=o.in._zod.traits.has("$ZodTransform"),i=t.io==="input"?s?o.out:o.in:o.out;G(i,t,n);let a=t.seen.get(e);a.ref=i},Gl=(e,t,r,n)=>{let o=e._zod.def;G(o.innerType,t,n);let s=t.seen.get(e);s.ref=o.innerType,r.readOnly=!0};var os=(e,t,r,n)=>{let o=e._zod.def;G(o.innerType,t,n);let s=t.seen.get(e);s.ref=o.innerType};var Vl=new WeakSet([Object.prototype,Error.prototype]);function nn(e,t,r){Object.defineProperty(e,t,{configurable:!0,enumerable:!1,get(){let n=r(this);return Object.defineProperty(this,t,{value:n,configurable:!0,writable:!0}),n},set(n){Object.defineProperty(this,t,{value:n,configurable:!0,writable:!0})}})}var Ah=(e,t)=>{va.init(e,t),e.name="ZodError";let r=Object.getPrototypeOf(e);if(Vl.has(r))return;Vl.add(r),nn(r,"format",(n)=>(o)=>bo(n,o)),nn(r,"flatten",(n)=>(o)=>_o(n,o)),nn(r,"addIssue",(n)=>(o)=>{n.issues.push(o),n.message=JSON.stringify(n.issues,Mt,2)}),nn(r,"addIssues",(n)=>(o)=>{n.issues.push(...o),n.message=JSON.stringify(n.issues,Mt,2)}),Object.defineProperty(r,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}})};var ie=h("ZodError",Ah,void 0,{Parent:Error});var Wl=Ar(ie),Kl=jr(ie),Jl=Rr(ie),Hl=Zr(ie),ql=Sa(ie),Yl=ka(ie),Xl=Pa(ie),Ql=za(ie),ep=Ea(ie),tp=Ca(ie),rp=Ia(ie),np=Ta(ie);function Rh(){if(!X.localeError)Q(Do())}function sn(){if(!X.memoizer)Q({memoizer:Lo()})}var M=h("ZodType",(e,t)=>(Rh(),F.init(e,t),e.def=t,e.type=t.type,e),{check(...e){let t=this.def;return this.clone(se(t,{checks:[...t.checks??[],...e.map((r)=>typeof r==="function"?{_zod:{check:r,def:{check:"custom"},onattach:[]}}:r)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return $e(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(Eg(e,t))},superRefine(e,t){return this.check(Cg(e,t))},overwrite(e){return this.check(Je(e))},optional(){return ip(this)},exactOptional(){return hg(this)},nullable(){return ap(this)},nullish(){return ip(ap(this))},nonoptional(e){return wg(this,e)},array(){return fe(this)},or(e){return as([this,e])},and(e){return pg(this,e)},transform(e){return cp(this,mg(e))},default(e){return yg(this,e)},prefault(e){return bg(this,e)},catch(e){return $g(this,e)},pipe(e){return cp(this,e)},readonly(){return Pg(this)},describe(e){let t=this.clone();return Ke.add(t,{description:e}),t},meta(...e){if(e.length===0)return Ke.get(this);let t=this.clone();return Ke.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e,...t){return t.length===0?e(this):e(this,...t)},get "~standard"(){return Tr(this,"~standard",{...To(this),jsonSchema:{input:Xt(this,"input"),output:Xt(this,"output")}})},set "~standard"(e){Ue(this,"~standard",e)},parse:function e(t,r){return Wl(this,t,r,{callee:e})},parseAsync:async function e(t,r){return await Kl(this,t,r,{callee:e})},safeParse(e,t){return Jl(this,e,t)},async safeParseAsync(e,t){return Hl(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){Ue(this,"spa",e)},validate(e,t){return wo(this,e,t)},validateAsync(e,t){return vo(this,e,t)},encode:function e(t,r){return ql(this,t,r,{callee:e})},decode:function e(t,r){return Yl(this,t,r,{callee:e})},encodeAsync:async function e(t,r){return await Xl(this,t,r,{callee:e})},decodeAsync:async function e(t,r){return await Ql(this,t,r,{callee:e})},safeEncode(e,t){return ep(this,e,t)},safeDecode(e,t){return tp(this,e,t)},async safeEncodeAsync(e,t){return rp(this,e,t)},async safeDecodeAsync(e,t){return np(this,e,t)},toJSONSchema(e){return ml(this,{})(e)},get description(){return Ke.get(this)?.description},get _def(){return this._zod.def}}),up=h("_ZodString",(e,t)=>{Ur.init(e,t),M.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Sl(e,r,n,o)},ga({format:(e)=>de(e).format??null,minLength:(e)=>de(e).minimum??null,maxLength:(e)=>de(e).maximum??null},{regex(...e){return this.check(Fo(...e))},includes(...e){return this.check(Bo(...e))},startsWith(...e){return this.check(Go(...e))},endsWith(...e){return this.check(Vo(...e))},min(...e){return this.check(yt(...e))},max(...e){return this.check(en(...e))},length(...e){return this.check(tn(...e))},nonempty(...e){return this.check(yt(1,...e))},lowercase(e){return this.check(Uo(e))},uppercase(e){return this.check(Mo(e))},trim(){return this.check(Ko())},normalize(...e){return this.check(Wo(...e))},toLowerCase(){return this.check(Jo())},toUpperCase(){return this.check(Ho())},slugify(){return this.check(qo())}})),Zh=h("ZodString",(e,t)=>{Ur.init(e,t),up.init(e,t)},{email(e){return this.check(ju(Lh,e))},url(e){return this.check(No(lp,e))},jwt(e){return this.check(el(eg,e))},emoji(e){return this.check(Fu(Fh,e))},guid(e){return this.check(Ru(Dh,e))},uuid(e){return this.check(Zu(on,e))},uuidv4(e){return this.check(Lu(on,e))},uuidv6(e){return this.check(Du(on,e))},uuidv7(e){return this.check(Nu(on,e))},nanoid(e){return this.check(Uu(Uh,e))},cuid(e){return this.check(Mu(Mh,e))},cuid2(e){return this.check(Bu(Bh,e))},ulid(e){return this.check(Gu(Gh,e))},base64(e){return this.check(Yu(Yh,e))},base64url(e){return this.check(Xu(Xh,e))},xid(e){return this.check(Vu(Vh,e))},ksuid(e){return this.check(Wu(Wh,e))},ipv4(e){return this.check(Ku(Kh,e))},ipv6(e){return this.check(Ju(Jh,e))},cidrv4(e){return this.check(Hu(Hh,e))},cidrv6(e){return this.check(qu(qh,e))},e164(e){return this.check(Qu(Qh,e))},datetime(e){return this.check(Kr(er,e))},date(e){return this.check(Jr(tr,e))},time(e){return this.check(Hr(rr,e))},duration(e){return this.check(qr(nr,e))}});function b(e){return Au(Zh,e)}var U=h("ZodStringFormat",(e,t)=>{L.init(e,t),up.init(e,t)}),er=h("ZodISODateTime",(e,t)=>{Bc.init(e,t),U.init(e,t)}),tr=h("ZodISODate",(e,t)=>{Gc.init(e,t),U.init(e,t)}),rr=h("ZodISOTime",(e,t)=>{Vc.init(e,t),U.init(e,t)}),nr=h("ZodISODuration",(e,t)=>{Wc.init(e,t),U.init(e,t)}),Lh=h("ZodEmail",(e,t)=>{Oc.init(e,t),U.init(e,t)});var Dh=h("ZodGUID",(e,t)=>{Ic.init(e,t),U.init(e,t)});var on=h("ZodUUID",(e,t)=>{Tc.init(e,t),U.init(e,t)});var lp=h("ZodURL",(e,t)=>{Rc.init(e,t),U.init(e,t)});function Nh(e){return No(lp,e)}var Fh=h("ZodEmoji",(e,t)=>{Zc.init(e,t),U.init(e,t)});var Uh=h("ZodNanoID",(e,t)=>{Lc.init(e,t),U.init(e,t)});var Mh=h("ZodCUID",(e,t)=>{Dc.init(e,t),U.init(e,t)});var Bh=h("ZodCUID2",(e,t)=>{Nc.init(e,t),U.init(e,t)});var Gh=h("ZodULID",(e,t)=>{Fc.init(e,t),U.init(e,t)});var Vh=h("ZodXID",(e,t)=>{Uc.init(e,t),U.init(e,t)});var Wh=h("ZodKSUID",(e,t)=>{Mc.init(e,t),U.init(e,t)});var Kh=h("ZodIPv4",(e,t)=>{Kc.init(e,t),U.init(e,t)});var Jh=h("ZodIPv6",(e,t)=>{Hc.init(e,t),U.init(e,t)});var Hh=h("ZodCIDRv4",(e,t)=>{qc.init(e,t),U.init(e,t)});var qh=h("ZodCIDRv6",(e,t)=>{Yc.init(e,t),U.init(e,t)});var Yh=h("ZodBase64",(e,t)=>{Qc.init(e,t),U.init(e,t)});var Xh=h("ZodBase64URL",(e,t)=>{eu.init(e,t),U.init(e,t)});var Qh=h("ZodE164",(e,t)=>{tu.init(e,t),U.init(e,t)});var eg=h("ZodJWT",(e,t)=>{ru.init(e,t),U.init(e,t)});var pp=h("ZodNumber",(e,t)=>{Ao.init(e,t),M.init(e,t),e._zod.processJSONSchema=(r,n,o)=>kl(e,r,n,o),e.isFinite=!0},ga({minValue:(e)=>{let{minimum:t,exclusiveMinimum:r}=de(e);return Math.max(t??Number.NEGATIVE_INFINITY,r??Number.NEGATIVE_INFINITY)},maxValue:(e)=>{let{maximum:t,exclusiveMaximum:r}=de(e);return Math.min(t??Number.POSITIVE_INFINITY,r??Number.POSITIVE_INFINITY)},isInt:(e)=>{let{isInt:t,multipleOf:r}=de(e);return!!t||!!r?.some(Number.isSafeInteger)},format:(e)=>de(e).format??null},{gt(e,t){return this.check(Xr(e,t))},gte(e,t){return this.check(qt(e,t))},min(e,t){return this.check(qt(e,t))},lt(e,t){return this.check(Yr(e,t))},lte(e,t){return this.check(Ht(e,t))},max(e,t){return this.check(Ht(e,t))},int(e){return this.check(op(e))},safe(e){return this.check(op(e))},positive(e){return this.check(Xr(0,e))},nonnegative(e){return this.check(qt(0,e))},negative(e){return this.check(Yr(0,e))},nonpositive(e){return this.check(Ht(0,e))},multipleOf(e,t){return this.check(Qr(e,t))},step(e,t){return this.check(Qr(e,t))},finite(){return this}}));function dp(e){return tl(pp,e)}var tg=h("ZodNumberFormat",(e,t)=>{nu.init(e,t),pp.init(e,t)});function op(e){return rl(tg,e)}var rg=h("ZodBoolean",(e,t)=>{ou.init(e,t),M.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Pl(e,r,n,o)});function ng(e){return nl(rg,e)}var og=h("ZodUnknown",(e,t)=>{su.init(e,t),M.init(e,t),e._zod.processJSONSchema=(r,n,o)=>El(e,r,n,o)});function ss(){return ol(og)}var sg=h("ZodNever",(e,t)=>{iu.init(e,t),M.init(e,t),e._zod.processJSONSchema=(r,n,o)=>zl(e,r,n,o)});function ig(e){return sl(sg,e)}var ag=h("ZodArray",(e,t)=>{sn(),au.init(e,t),M.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Ol(e,r,n,o),e.element=t.element},{min(e,t){return this.check(yt(e,t))},nonempty(e){return this.check(yt(1,e))},max(e,t){return this.check(en(e,t))},length(e,t){return this.check(tn(e,t))},unwrap(){return this.element}});function fe(e,t){return il(ag,e,t)}var cg=h("ZodObject",(e,t)=>{sn(),lu.init(e,t),M.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Al(e,r,n,o),Bm(e,"shape",(r)=>r._zod.def.shape,!1)},{keyof(){return dg(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(se(this._zod.def,{catchall:e}))},passthrough(){return this.clone(se(this._zod.def,{catchall:ss()}))},loose(){return this.clone(se(this._zod.def,{catchall:ss()}))},strict(){return this.clone(se(this._zod.def,{catchall:ig()}))},strip(){return this.clone(se(this._zod.def,{catchall:void 0}))},extend(e){return Rm(this,e)},safeExtend(e){return Zm(this,e)},merge(e){return Lm(this,e)},pick(e){return Am(this,e)},omit(e){return jm(this,e)},partial(...e){return da(fp,this,e[0])},exactPartial(...e){return da(mp,this,e[0],"exactPartial")},required(...e){return Dm(hp,this,e[0])}});function z(e,t){let r={type:"object",shape:e??{},...v(t)};return new cg(r)}var ug=h("ZodUnion",(e,t)=>{pu.init(e,t),M.init(e,t),e._zod.processJSONSchema=(r,n,o)=>jl(e,r,n,o),e.options=t.options});function as(e,t){return new ug({type:"union",options:e,...v(t)})}var lg=h("ZodIntersection",(e,t)=>{du.init(e,t),M.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Rl(e,r,n,o)});function pg(e,t){return new lg({type:"intersection",left:e,right:t})}var sp=h("ZodRecord",(e,t)=>{sn(),fu.init(e,t),M.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Zl(e,r,n,o),e.keyType=t.keyType,e.valueType=t.valueType});function cs(e,t,r){if(!t||!t._zod)return new sp({type:"record",keyType:b(),valueType:e,...v(t)});return new sp({type:"record",keyType:e,valueType:t,...v(r)})}var is=h("ZodEnum",(e,t)=>{mu.init(e,t),M.init(e,t),e._zod.processJSONSchema=(n,o,s)=>Cl(e,n,o,s),e.enum=t.entries,e.options=[...e._zod.values];let r=new Set(Object.keys(t.entries));e.extract=(n,o)=>{let s={};for(let i of n)if(r.has(i))s[i]=t.entries[i];else throw Error(`Key ${i} not found in enum`);return new is({...t,checks:[],...v(o),entries:s})},e.exclude=(n,o)=>{let s={...t.entries};for(let i of n)if(r.has(i))delete s[i];else throw Error(`Key ${i} not found in enum`);return new is({...t,checks:[],...v(o),entries:s})}});function dg(e,t){let r=Array.isArray(e)?Object.fromEntries(e.map((n)=>[n,n])):e;return new is({type:"enum",entries:r,...v(t)})}var fg=h("ZodTransform",(e,t)=>{sn(),hu.init(e,t),M.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Tl(e,r,n,o),e._zod.parse=(r,n)=>{if(n.direction==="backward")throw new Bt(e.constructor.name);r.addIssue=(s)=>{if(typeof s==="string")r.issues.push(ot(s,r.value,t));else{let i=s;if(i.fatal)i.continue=!1;if(i.code??(i.code="custom"),!("input"in i))i.input=r.value;i.inst??(i.inst=e),r.issues.push(ot(i))}};let o=t.transform(r.value,r);if(o instanceof Promise)return o.then((s)=>(r.value=s,r));return r.value=o,r}});function mg(e){return new fg({type:"transform",transform:e})}var fp=h("ZodOptional",(e,t)=>{jo.init(e,t),M.init(e,t),e._zod.processJSONSchema=(r,n,o)=>os(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function ip(e){return new fp({type:"optional",innerType:e})}var mp=h("ZodExactOptional",(e,t)=>{gu.init(e,t),M.init(e,t),e._zod.processJSONSchema=(r,n,o)=>os(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function hg(e){return new mp({type:"optional",innerType:e})}var gg=h("ZodNullable",(e,t)=>{xu.init(e,t),M.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Ll(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function ap(e){return new gg({type:"nullable",innerType:e})}var xg=h("ZodDefault",(e,t)=>{yu.init(e,t),M.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Fl(e,r,n,o),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function yg(e,t){return new xg({type:"default",innerType:e,get defaultValue(){return typeof t==="function"?t():po(t)}})}var _g=h("ZodPrefault",(e,t)=>{_u.init(e,t),M.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Ul(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function bg(e,t){return new _g({type:"prefault",innerType:e,get defaultValue(){return typeof t==="function"?t():po(t)}})}var hp=h("ZodNonOptional",(e,t)=>{bu.init(e,t),M.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Dl(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function wg(e,t){return new hp({type:"nonoptional",innerType:e,...v(t)})}var vg=h("ZodCatch",(e,t)=>{wu.init(e,t),M.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Ml(e,r,n,o),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function $g(e,t){return new vg({type:"catch",innerType:e,catchValue:typeof t==="function"?t:xa(t)})}var Sg=h("ZodPipe",(e,t)=>{vu.init(e,t),M.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Bl(e,r,n,o),e.in=t.in,e.out=t.out});function cp(e,t){return new Sg({type:"pipe",in:e,out:t})}var kg=h("ZodReadonly",(e,t)=>{$u.init(e,t),M.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Gl(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function Pg(e){return new kg({type:"readonly",innerType:e})}var zg=h("ZodCustom",(e,t)=>{Su.init(e,t),M.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Il(e,r,n,o)});function Eg(e,t={}){return al(zg,e,t)}function Cg(e,t){return cl(e,t)}var an={};gf(an,{ZodISODate:()=>tr,ZodISODateTime:()=>er,ZodISODuration:()=>nr,ZodISOTime:()=>rr,date:()=>Tg,datetime:()=>Ig,duration:()=>Ag,time:()=>Og});function Ig(e){return Kr(er,e)}function Tg(e){return Jr(tr,e)}function Og(e){return Hr(rr,e)}function Ag(e){return qr(nr,e)}var gp=ut(Pt(),1);var us=()=>process.env.NIPA_DEBUG==="1",cn=(e)=>{if(us())oe(gp.default.dim(`> [debug] [${new Date().toISOString()}] ${e}`))};class wt extends Error{url;constructor(e,t){super(`can't reach ${new URL(e).host}: ${t}`);this.name="NetworkError",this.url=e}}var xp=(e)=>e.cause instanceof Error?`${e.message} (${xp(e.cause)})`:e.message,Me=async(e,t={})=>{let r=t.method??"GET",n=performance.now();cn(`${r} ${e}`);let o;try{o=await fetch(e,t)}catch(s){throw new wt(e,s instanceof Error?xp(s):String(s))}return cn(`${o.status} ${r} ${e} [${we(performance.now()-n)}]`),o};var ls=z({domainId:b().optional(),id:b(),name:b()});class ae extends Error{status;constructor(e,t){super(e);this.name="KeystoneError",this.status=t}}var un=(e)=>{let t=e;while(t.endsWith("/"))t=t.slice(0,-1);if(t.endsWith("/v3"))t=t.slice(0,-3);return`${t}/v3`},ps=(e,t)=>t?{auth:{identity:e,scope:{project:{id:t}}}}:{auth:{identity:e}},_p=(e)=>({domain:{name:e.userDomain},name:e.username}),jg=(e,t)=>ps({methods:["password"],password:{user:{..._p(e),password:t}}},e.projectId),Rg=(e,t)=>ps({methods:["totp"],totp:{user:{..._p(e),passcode:t}}},e.projectId),Zg=(e,t)=>ps({methods:["token"],token:{id:e}},t),Lg=z({error:z({message:b().optional()}).optional(),receipt:z({}).loose().optional(),required_auth_methods:fe(fe(b())).optional()}),bp=async(e)=>{try{let t=Lg.safeParse(JSON.parse(await e.text()));return t.success?t.data:{}}catch{return{}}},wp=(e)=>e.length>0?`this account needs ${e.map((t)=>t.join(" + ")).join(" or ")} to log in`:"this account's MFA rules don't allow this login method",Dg=(e)=>{let{body:t,status:r}=e;if(t.receipt)return wp(t.required_auth_methods??[]);if(r===401)return e.unauthorized;return t.error?.message??`Keystone returned HTTP ${r}`},or=async(e,t)=>{let r=await bp(e);throw new ae(Dg({body:r,status:e.status,unauthorized:t}),e.status)},Ng=z({token:z({expires_at:b(),project:z({domain:z({id:b()}).optional(),id:b(),name:b()}).optional(),user:z({id:b(),name:b()})})}),Fg=(e,t)=>{let{expires_at:r,project:n,user:o}=t.token;return{expiresAt:r,project:n&&{domainId:n.domain?.id,id:n.id,name:n.name},user:o,value:e}},vp="Openstack-Auth-Receipt",ds=(e,t,r)=>{let n=new Headers({"Content-Type":"application/json"});if(r!==void 0)n.set(vp,r);return Me(`${un(e)}/auth/tokens`,{body:JSON.stringify(t),headers:n,method:"POST"})},fs=async(e)=>{let t=e.headers.get("X-Subject-Token");if(!t)throw new ae("Keystone didn't return a token",e.status);let r=Ng.safeParse(await e.json());if(!r.success)throw new ae(`unexpected token response: ${Gt(r.error)}`,e.status);return Fg(t,r.data)},$p=async(e,t)=>{let r=await ds(e.authUrl,jg(e,t));if(r.ok)return{kind:"token",token:await fs(r)};let n=r.headers.get(vp);if(r.status===401&&n){let s=(await bp(r)).required_auth_methods;if(!s||s.some((i)=>i.includes("totp")))return{kind:"mfa",receipt:n};throw new ae(wp(s),r.status)}return or(r,"wrong email or password")},Sp=async(e)=>{let{account:t,passcode:r,receipt:n}=e,o=await ds(t.authUrl,Rg(t,r),n);return o.ok?fs(o):or(o,"wrong OTP code")},ms="the session expired or was revoked",ln=async(e)=>{let t=await ds(e.authUrl,Zg(e.token,e.projectId));return t.ok?fs(t):or(t,ms)},Ug=z({projects:fe(z({domain_id:b().optional(),enabled:ng().optional(),id:b(),name:b()}))}),Mg=(e)=>e.projects.filter((t)=>t.enabled!==!1).map((t)=>({domainId:t.domain_id,id:t.id,name:t.name})).toSorted((t,r)=>t.name.localeCompare(r.name)),vt=async({authUrl:e,token:t})=>{let r=await Me(`${un(e)}/auth/projects`,{headers:{"X-Auth-Token":t}});if(!r.ok)return or(r,ms);let n=Ug.safeParse(await r.json());if(!n.success)throw new ae(`unexpected project list: ${Gt(n.error)}`,r.status);return Mg(n.data)},pn=async({authUrl:e,token:t})=>{let r=await Me(`${un(e)}/auth/tokens`,{headers:{"X-Auth-Token":t,"X-Subject-Token":t},method:"DELETE"});if(!(r.ok||r.status===401||r.status===404))await or(r,ms)},yp=z({version:z({id:b(),status:b()})}),kp=async(e)=>{let t=un(e),r=await Me(t,{signal:AbortSignal.timeout(1e4)}),n;try{n=yp.safeParse(await r.json())}catch{n=yp.safeParse(null)}if(!(r.ok&&n.success))throw new ae(`${t} doesn't answer like Keystone v3 (HTTP ${r.status})`,r.status);return n.data.version.id};import{spawn as ox}from"node:child_process";import{once as sx}from"node:events";import{stat as ix}from"node:fs/promises";import{text as ax}from"node:stream/consumers";import{accessSync as Bg,constants as Gg}from"node:fs";import{homedir as Vg}from"node:os";import sr from"node:path";var Pp=(e)=>{try{return Bg(e,Gg.X_OK),!0}catch{return!1}},Wg=(e)=>process.platform==="win32"?[...(process.env.PATHEXT??".EXE;.CMD;.BAT").split(";").map((t)=>`${e}${t}`),e]:[e],dn=(e)=>{if(e.includes("/")||e.includes(sr.sep)){let r=sr.resolve(e);return Pp(r)?r:void 0}return[...(process.env.PATH??"").split(sr.delimiter).filter(Boolean),sr.join(Vg(),".local","bin")].flatMap((r)=>Wg(sr.join(r,e))).find(Pp)},fn=(e)=>({OS_AUTH_TYPE:"v3token",OS_AUTH_URL:e.profile.authUrl,OS_IDENTITY_API_VERSION:"3",OS_INTERFACE:"public",OS_PROJECT_DOMAIN_ID:e.session.project.domainId??"",OS_PROJECT_ID:e.session.project.id,OS_PROJECT_NAME:e.session.project.name,OS_REGION_NAME:e.profile.region,OS_TOKEN:e.session.token}),Ep=(e,t)=>({...Object.fromEntries(Object.entries(e).filter(([r])=>!r.startsWith("OS_"))),...t}),hs=["bash","zsh","fish"],Kg=(e)=>hs.some((t)=>t===e),zp=(e,t)=>`'${t==="fish"?e.replaceAll("\\","\\\\").replaceAll("'","\\'"):e.replaceAll("'","'\\''")}'`,Cp=(e,t)=>Object.entries(e).map(([r,n])=>t==="fish"?`set -gx ${r} ${zp(n,t)}`:`export ${r}=${zp(n,t)}`).join(`
90
- `),Ip=(e)=>{let t=e?.split("/").at(-1)??"";return Kg(t)?t:"bash"};import{chmod as Jg,mkdir as Op,readFile as Ap,rm as Hg,writeFile as jp}from"node:fs/promises";import{homedir as Rp}from"node:os";import it from"node:path";var ee="prod",ce={authUrl:"https://identity-api.nipa.cloud/v3",region:"NCP-TH",spaceUrl:"https://space.nipa.cloud/api",userDomain:"nipacloud"},Tp=Nh({protocol:/^https?$/u}),He=z({authUrl:Tp,project:ls.optional(),region:b().min(1),spaceUrl:Tp.default(ce.spaceUrl),userDomain:b().min(1),username:b().optional()}),xs=/^[a-z][\da-z-]{0,31}$/u,qg=cs(b().regex(xs),He),ys=(e)=>({[ee]:ce,...e}),Yg=z({currentProfile:b().default(ee),profiles:qg.default({})}).strict().transform((e)=>({...e,profiles:ys(e.profiles)})),Xg=He.extend({authUrl:He.shape.authUrl.default(ce.authUrl),region:He.shape.region.default(ce.region),userDomain:He.shape.userDomain.default(ce.userDomain)}).transform((e)=>({currentProfile:ee,profiles:ys({[ee]:e})})),Qg=as([Yg,Xg]),Zp=z({expiresAt:an.datetime({offset:!0}),project:ls,token:b().min(1),user:z({id:b(),name:b()})}),ex=cs(b(),Zp),tx=as([z({sessions:ex}).strict().transform((e)=>e.sessions),Zp.transform((e)=>({[ee]:e}))]);class ir extends Error{constructor(e){super(e);this.name="StoreError"}}var rx=60000,_s=(e=process.env)=>e.NIPA_CONFIG_DIR??it.join(e.XDG_CONFIG_HOME??it.join(Rp(),".config"),"nipa"),Lp=()=>it.join(_s(),"config.json"),mn=()=>it.join(_s(),"auth.json"),gs=(e,t=process.env)=>it.join(t.XDG_CACHE_HOME??it.join(Rp(),".cache"),"nipa",e),hn=async(e,t)=>{try{let r=await Ap(gs(e),"utf-8"),n=t.safeParse(JSON.parse(r));return n.success?n.data:void 0}catch{return}},gn=async(e,t)=>{await Op(it.dirname(gs(e)),{recursive:!0}),await jp(gs(e),`${JSON.stringify(t)}
91
- `)},nx=async(e)=>{try{return await Ap(e,"utf-8")}catch(t){if(t instanceof Error&&"code"in t&&t.code==="ENOENT")return;throw t}},Dp=async(e,t)=>{let r=await nx(e);if(r===void 0)return;let n;try{n=JSON.parse(r)}catch{throw new ir(`${e} isn't valid JSON`)}let o=t.safeParse(n);if(!o.success)throw new ir(`${e}: ${Gt(o.error)}`);return o.data},bs=async(e,t)=>{await Op(_s(),{mode:448,recursive:!0}),await jp(e,`${JSON.stringify(t,null,2)}
92
- `,{mode:384}),await Jg(e,384)},me=async()=>await Dp(Lp(),Qg)??{currentProfile:ee,profiles:ys({})},qe=(e)=>bs(Lp(),e),ws=async()=>await Dp(mn(),tx)??{},he=async(e)=>(await ws())[e],Np=async(e)=>{let t=await ws();await bs(mn(),{sessions:{...t,[e.profile]:e.session}})},xn=async(e)=>{let t=await ws(),r=Object.fromEntries(Object.entries(t).filter(([n])=>n!==e));if(Object.keys(r).length===0){await Hg(mn(),{force:!0});return}await bs(mn(),{sessions:r})},vs=(e,t=Date.now())=>Date.parse(e.expiresAt)-t,te=(e,t=Date.now())=>e!==void 0&&vs(e,t)>rx;var Fp="openstack.json",cx=20000,ux=cs(b(),fe(b())),lx=z({bin:b(),mtimeMs:dp(),table:ux}),px=/^\s*cmds(?:_(?<key>\S+))?='(?<words>[^']*)'$/u,dx=(e)=>Object.fromEntries(e.split(`
93
- `).flatMap((t)=>{let r=px.exec(t)?.groups;if(!r)return[];let n=r.words?.split(" ").filter(Boolean)??[];return[[r.key??"",n]]})),fx=(e,t)=>{let r=t.at(-1)??"",n="";for(let s of t.slice(0,-1)){let i=(n?`${n}_${s}`:s).replaceAll("-","_");if(s.startsWith("-")||!Object.hasOwn(e,i))break;n=i}let o=e[n]??[];if(r.startsWith("-"))return o.filter((s)=>s.startsWith(r));return o.filter((s)=>s.startsWith(r)&&!s.startsWith("-")&&!s.includes("_"))},mx=async(e)=>{let{mtimeMs:t}=await ix(e),r=await hn(Fp,lx);if(r?.bin===e&&r.mtimeMs===t)return r.table;let n=ox(e,["complete","--shell","none"],{stdio:["ignore","pipe","ignore"],timeout:cx}),[o]=await Promise.all([ax(n.stdout),sx(n,"close")]);if(n.exitCode!==0)return;let s=dx(o);return await gn(Fp,{bin:e,mtimeMs:t,table:s}),s},Up=async(e)=>{let t=dn("openstack");if(!t)return[];let r=await mx(t);return r?fx(r,e):[]};var Mp=["bash","zsh","fish","pwsh"],Bp=["projects","profiles","openstack"],$t=(e)=>`nipa __complete ${e}`,at=ne(Cn),hx=(e)=>e.filter((t)=>t.kind==="passthrough").flatMap((t)=>q(t)),$s=(e)=>[...e.flags,...re],bn=(e)=>{let t=e.args.findIndex((n)=>n.value.kind!=="text"),r=e.args[t];return r?{arg:r,position:t+1}:void 0},gx=(e)=>{switch(e.kind){case"none":return;case"text":return"return";case"choice":return`_nipa_reply ${e.choices.join(" ")}; return`;case"project":return`_nipa_reply "$(${$t("projects")} 2>/dev/null)"; return`;case"profile":return`_nipa_reply "$(${$t("profiles")} 2>/dev/null)"; return`;default:return e}},xx=(e)=>{switch(e.kind){case"text":return;case"project":return`_nipa_reply "$(${$t("projects")} 2>/dev/null)"`;case"profile":return`_nipa_reply "$(${$t("profiles")} 2>/dev/null)"`;case"choice":return`_nipa_reply ${e.choices.join(" ")}`;default:return e}},yx=(e)=>{switch(e.kind){case"program":return`COMP_WORDS[i]=${e.program}; _nipa_offset "$i"`;case"command":return'_nipa_offset "$((i + 1))"';case"openstack":return'_nipa_reply "$(nipa __complete openstack -- "${COMP_WORDS[@]:i+1:COMP_CWORD-i}" 2>/dev/null)"';default:return e}},Gp=(e,t)=>{let r=" ".repeat(t*2+2),n=[];if(e.kind==="group"){let s=e.subcommands;n.push(`if [[ $COMP_CWORD -eq $((i + 1)) ]]; then _nipa_reply ${s.map((i)=>i.name).join(" ")}; return; fi`,"case ${COMP_WORDS[i + 1]} in",...s.map((i)=>Gp(i,t+1)),"esac")}else if(e.kind==="passthrough")n.push(yx(e.target));else{let s=$s(e),i=s.flatMap((l)=>{let p=gx(l.value);return p===void 0?[]:[` ${ne(l).join("|")}) ${p} ;;`]});if(i.length>0)n.push('case "$prev" in',...i,"esac");let a=s.flatMap(ne).join(" ");n.push(`if [[ $cur == -* ]]; then _nipa_reply ${a}; return; fi`);let c=bn(e),u=c&&xx(c.arg.value);if(u)n.push(u)}let o=n.map((s)=>`${r} ${s}`).join(`
94
- `);return`${r}${q(e).join("|")})
89
+ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let i of e.seen.entries()){let a=i[1];if(t===i[0]){s(i);continue}if(e.external){let u=e.external.registry.get(i[0])?.id;if(t!==i[0]&&u){s(i);continue}}if(e.metadataRegistry.get(i[0])?.id){s(i);continue}if(a.cycle){s(i);continue}if(a.count>1){if(e.reused==="ref")s(i)}}if(e.external)e.sharedDefsExtractedFor=e.external}function _l(e){let t=e.anyOf;if(!Array.isArray(t)||t.length===0||e.type!==void 0)return;let r=[];for(let n of t){if(!n||typeof n!=="object")return;_l(n);let o=Object.keys(n);if(o.length!==1||o[0]!=="type")return;let s=n.type;for(let i of Array.isArray(s)?s:[s]){if(typeof i!=="string")return;if(!r.includes(i))r.push(i)}}delete e.anyOf,e.type=r.length===1?r[0]:r}var bl=new Set(["type","properties","required","additionalProperties"]),xl=["oneOf","anyOf"];function yl(e){let t=e.additionalProperties;if(t===void 0||t===!1||typeof t!=="object"||t===null)return null;return Object.keys(t).length?t:null}function ns(e){let t=[];for(let s of e){if(typeof s!=="object"||s.type!=="object")return null;for(let i in s)if(!bl.has(i))return null;t.push(s)}let r={},n=new Set;for(let s of t){for(let i in s.properties){if(Object.prototype.hasOwnProperty.call(r,i))continue;let a=[];for(let u of t){let l=u.properties?.[i]??yl(u);if(l===null||l===void 0)continue;if(!a.some((p)=>JSON.stringify(p)===JSON.stringify(l)))a.push(l)}let c=a.length===1?a[0]:ns(a)??{allOf:a};ve(r,i,c)}for(let i of s.required??[])n.add(i)}let o={type:"object",properties:r};if(n.size)o.required=[...n];if(t.every((s)=>s.additionalProperties===!1))o.additionalProperties=!1;else{let s=[];for(let i of t){let a=yl(i);if(a&&!s.some((c)=>JSON.stringify(c)===JSON.stringify(a)))s.push(a)}if(s.length===1)o.additionalProperties=s[0];else if(s.length>1)o.additionalProperties={allOf:s}}return o}function Nh(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let o of bl)if(o in e)return;let r=t.filter((o)=>xl.some((s)=>Array.isArray(o[s]))),n=null;if(!r.length)n=ns(t);else{let o=r[0],s=xl.find((c)=>Array.isArray(o[c]));if(Object.keys(o).length!==1)return;let i=t.filter((c)=>c!==o),a=o[s].map((c)=>ns([...i,c]));if(a.some((c)=>!c))return;n={[s]:a}}if(!n)return;delete e.allOf,rr(e,n)}function is(e,t){let r=e.seen.get(t);if(!r)throw Error("Unprocessed schema. This is a bug in Zod.");let n=(a)=>{let c=e.seen.get(a);if(c.ref===null)return;let u=c.def??c.schema,l={...u},p=c.ref;if(c.ref=null,p){n(p);let m=e.seen.get(p),f=m.schema;if(f.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0"))u.allOf=u.allOf??[],u.allOf.push(f);else rr(u,f);if(rr(u,l),a._zod.parent===p)for(let x in u){if(x==="$ref"||x==="allOf")continue;if(!(x in l))delete u[x]}if(f.$ref&&m.def)for(let x in u){if(x==="$ref"||x==="allOf")continue;if(x in m.def&&JSON.stringify(u[x])===JSON.stringify(m.def[x]))delete u[x]}}let d=a._zod.parent;if(d&&d!==p){n(d);let m=e.seen.get(d);if(m?.schema.$ref){if(u.$ref=m.schema.$ref,m.def)for(let f in u){if(f==="$ref"||f==="allOf")continue;if(f in m.def&&JSON.stringify(u[f])===JSON.stringify(m.def[f]))delete u[f]}}}e.override({zodSchema:a,jsonSchema:u,path:c.path??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(let a of[...e.seen.entries()].reverse())n(a[0]);if(e.target!=="openapi-3.0")for(let a of e.seen.entries())_l(a[1].def??a[1].schema);for(let a of e.deferred)a();if(e.intersections.length){let a=new Map;for(let c of e.seen.values())for(let u of[c.schema,c.def]){let l=u?.allOf;if(!Array.isArray(l))continue;let p=a.get(l);if(p)p.push(u);else a.set(l,[u])}for(let c of e.intersections)for(let u of a.get(c)??[])Nh(u)}}let o={};if(e.target==="draft-2020-12")o.$schema="https://json-schema.org/draft/2020-12/schema";else if(e.target==="draft-07")o.$schema="http://json-schema.org/draft-07/schema#";else if(e.target==="draft-04")o.$schema="http://json-schema.org/draft-04/schema#";else if(e.target==="openapi-3.0");if(e.external?.uri){let a=e.external.registry.get(t)?.id;if(!a)throw Error("Schema is missing an `id` property");o.$id=e.external.uri(a)}rr(o,r.defId?r.schema:r.def??r.schema);let s=e.metadataRegistry.get(t)?.id;if(s!==void 0&&o.id===s)delete o.id;let i=e.external?.defs??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(let a of e.seen.entries()){let c=a[1];if(c.def&&c.defId){if(c.def.id===c.defId)delete c.def.id;ve(i,c.defId,c.def)}}if(e.external)e.sharedEmitDoneFor=e.external;if(e.external);else if(Object.keys(i).length>0)if(e.target==="draft-2020-12")o.$defs=i;else o.definitions=i;try{let a=JSON.parse(JSON.stringify(o));return Object.defineProperty(a,"~standard",{value:{...t["~standard"],jsonSchema:{input:nr(t,"input",e.processors),output:nr(t,"output",e.processors)}},enumerable:!1,writable:!1}),a}catch(a){throw Error("Error converting schema to JSON.")}}function Y(e,t){let r=t??{seen:new Set};if(r.seen.has(e))return!1;r.seen.add(e);let n=e._zod.def;if(n.type==="transform")return!0;if(n.type==="array")return Y(n.element,r);if(n.type==="set")return Y(n.valueType,r);if(n.type==="lazy")return Y(n.getter(),r);if(n.type==="promise"||n.type==="optional"||n.type==="nonoptional"||n.type==="nullable"||n.type==="readonly"||n.type==="default"||n.type==="prefault"||n.type==="catch")return Y(n.innerType,r);if(n.type==="intersection")return Y(n.left,r)||Y(n.right,r);if(n.type==="record"||n.type==="map")return Y(n.keyType,r)||Y(n.valueType,r);if(n.type==="pipe"){if(e._zod.traits.has("$ZodCodec"))return!0;return Y(n.in,r)||Y(n.out,r)}if(n.type==="object"){for(let o in n.shape)if(Y(n.shape[o],r))return!0;return!1}if(n.type==="union"){for(let o of n.options)if(Y(o,r))return!0;return!1}if(n.type==="tuple"){for(let o of n.items)if(Y(o,r))return!0;if(n.rest&&Y(n.rest,r))return!0;return!1}return!1}var wl=(e,t={})=>(r)=>{let n=os({...r,processors:t});return V(e,n),ss(n,e),is(n,e)},nr=(e,t,r={})=>(n)=>{let{libraryOptions:o,target:s}=n??{},i=os({...o??{},target:s,io:t,processors:r});return V(e,i),ss(i,e),is(i,e)};var $t=(e,t,r)=>{if(e[t]===void 0||r>e[t])e[t]=r},St=(e,t,r)=>{if(e[t]===void 0||r<e[t])e[t]=r},vl=(e,t)=>{$t(e,"minimum",t),St(e,"maximum",t)},kl=(e,t)=>{if(e.multipleOf??(e.multipleOf=[]),!e.multipleOf.includes(t))e.multipleOf.push(t)},zl=(e,t)=>{e.patterns??(e.patterns=new Set),e.patterns.add(t)},El=(e,t)=>{e.mime=e.mime?e.mime.filter((r)=>t.includes(r)):[...t]},Cl=(e,t)=>{if(e.format=t,t.includes("int"))e.isInt=!0},$l=(e,t)=>$t(e,"minimum",t.minimum),Sl=(e,t)=>St(e,"maximum",t.maximum),Pl=(e)=>(t,r)=>{Cl(t,r.format);let[n,o]=e[r.format];$t(t,"minimum",n),St(t,"maximum",o)},Uh={greater_than:(e,t)=>$t(e,t.inclusive?"minimum":"exclusiveMinimum",t.value),less_than:(e,t)=>St(e,t.inclusive?"maximum":"exclusiveMaximum",t.value),multiple_of:(e,t)=>kl(e,t.value),number_format:Pl(Rr),bigint_format:Pl(bo),min_length:$l,max_length:Sl,length_equals:(e,t)=>vl(e,t.length),min_size:$l,max_size:Sl,size_equals:(e,t)=>vl(e,t.size),string_format:(e,t)=>{if(Cl(e,t.format),t.pattern)zl(e,t.pattern);if(t.format==="base64"||t.format==="base64url")e.contentEncoding=t.format;if(t.local||t.precision===-1)e.laxFormat=!0},mime_type:(e,t)=>El(e,t.mime)};function de(e){let t={},r=e._zod.def,n=e._zod.traits.has("$ZodCheck")?[e,...r.checks??[]]:r.checks??[];for(let s of n)Uh[s._zod.def.check]?.(t,s._zod.def);let o=e._zod.bag;if(o.minimum!==void 0)$t(t,"minimum",o.minimum);if(o.exclusiveMinimum!==void 0)$t(t,"exclusiveMinimum",o.exclusiveMinimum);if(o.maximum!==void 0)St(t,"maximum",o.maximum);if(o.exclusiveMaximum!==void 0)St(t,"exclusiveMaximum",o.exclusiveMaximum);if(o.multipleOf!==void 0)kl(t,o.multipleOf);if(o.format!==void 0){if(t.format??(t.format=o.format),o.format.includes("int"))t.isInt=!0}if(o.mime)El(t,o.mime);for(let s of o.patterns??[])zl(t,s);return t}var Fh={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},Mh=new Map([[Do,ec],[qr,tc]]),Il=(e)=>Mh.get(e)??e,Tl=(e,t,r,n)=>{let o=r;o.type="string";let{minimum:s,maximum:i,format:a,patterns:c,contentEncoding:u,laxFormat:l}=de(e);if(typeof s==="number")o.minLength=s;if(typeof i==="number")o.maxLength=i;if(a){if(o.format=Fh[a]??a,o.format==="")delete o.format;if(a==="time"||l)delete o.format}if(u)o.contentEncoding=u;if(c&&c.size>0){let p=[...c].map(Il);if(p.length===1)o.pattern=p[0].source;else if(p.length>1)o.allOf=[...p.map((d)=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:d.source}))]}},Ol=(e,t,r,n)=>{let o=r,{minimum:s,maximum:i,multipleOf:a,exclusiveMaximum:c,exclusiveMinimum:u,isInt:l}=de(e);o.type=l?"integer":"number";let p=typeof u==="number"&&u>=(s??Number.NEGATIVE_INFINITY),d=typeof c==="number"&&c<=(i??Number.POSITIVE_INFINITY),m=t.target==="draft-04"||t.target==="openapi-3.0";if(p)if(m)o.minimum=u,o.exclusiveMinimum=!0;else o.exclusiveMinimum=u;else if(typeof s==="number")o.minimum=s;if(d)if(m)o.maximum=c,o.exclusiveMaximum=!0;else o.exclusiveMaximum=c;else if(typeof i==="number")o.maximum=i;if(a){let f=new Set;for(let y of a)if(Number.isFinite(y)&&y!==0)f.add(Math.abs(y));else ct(e,t,o,n,`A multipleOf divisor of ${y} cannot be represented in JSON Schema`);let[g,...x]=f;if(g!==void 0)o.multipleOf=g;if(x.length)o.allOf=[...o.allOf??[],...x.map((y)=>({multipleOf:y}))]}},Al=(e,t,r,n)=>{r.type="boolean"};var jl=(e,t,r,n)=>{r.not={}};var Rl=(e,t,r,n)=>{};var Ll=(e,t,r,n)=>{let o=e._zod.def,s=Wt(o.entries);if(s.length===0){r.not={};return}if(s.every((i)=>typeof i==="number"))r.type="number";if(s.every((i)=>typeof i==="string"))r.type="string";r.enum=s};var Zl=(e,t,r,n)=>{ct(e,t,r,n,"Custom types cannot be represented in JSON Schema")};var Dl=(e,t,r,n)=>{ct(e,t,r,n,"Transforms cannot be represented in JSON Schema")};var Nl=(e,t,r,n)=>{let o=r,s=e._zod.def,{minimum:i,maximum:a}=de(e);if(typeof i==="number")o.minItems=i;if(typeof a==="number")o.maxItems=a;o.type="array",o.items=V(s.element,t,{...n,path:[...n.path,"items"]})};function pn(e){let t=e._zod.def;if(t.type==="pipe"&&t.in._zod.traits.has("$ZodTransform"))return pn(t.out);if(t.type==="catch")return pn(t.innerType);return e._zod.optin}var Ul=(e,t,r,n)=>{let o=r,s=e._zod.def,i=s.shape;if(Object.getOwnPropertySymbols(i).length&&ct(e,t,o,n,"Symbol keys cannot be represented in JSON Schema"))return;o.type="object",o.properties={};for(let u in i)ve(o.properties,u,V(i[u],t,{...n,path:[...n.path,"properties",u]}));let c=[];for(let u of Object.keys(i)){let l=s.shape[u];if(t.io==="input"?pn(l)===void 0:l._zod.optout===void 0)c.push(u)}if(c.length>0)o.required=c;if(s.catchall?._zod.def.type==="never")o.additionalProperties=!1;else if(!s.catchall){if(t.io==="output")o.additionalProperties=!1}else if(s.catchall)o.additionalProperties=V(s.catchall,t,{...n,path:[...n.path,"additionalProperties"]})},Fl=(e,t,r,n)=>{let o=e._zod.def,s=o.inclusive===!1,i=o.options.map((a,c)=>V(a,t,{...n,path:[...n.path,s?"oneOf":"anyOf",c]}));if(s)r.oneOf=i;else r.anyOf=i},Ml=(e,t,r,n)=>{let o=e._zod.def,s=V(o.left,t,{...n,path:[...n.path,"allOf",0]}),i=V(o.right,t,{...n,path:[...n.path,"allOf",1]}),a=(u)=>("allOf"in u)&&Object.keys(u).length===1,c=[...a(s)?s.allOf:[s],...a(i)?i.allOf:[i]];r.allOf=c,t.intersections.push(c)};function as(e,t,r){if(t.$ref){if(r.has(t))return t;r.add(t);let f=e.get(t)?.def;if(!f)return t;let g=as(e,f,r);return g===f?t:g}for(let f of["anyOf","oneOf"]){let g=t[f];if(!Array.isArray(g))continue;let x=g.map((y)=>as(e,y,r));if(x.some((y,w)=>y!==g[w]))t={...t,[f]:x}}let n=Array.isArray(t.type)?t.type:[t.type],o=!n.includes("string")&&n.some((f)=>f==="number"||f==="integer"),s=t.enum??(t.const!==void 0?[t.const]:void 0);if(!o&&!s?.some((f)=>typeof f==="number"))return t;let{minimum:i,maximum:a,exclusiveMinimum:c,exclusiveMaximum:u,multipleOf:l,format:p,id:d,...m}=t;if(m.enum)m.enum=m.enum.map((f)=>typeof f==="number"?String(f):f);else if(typeof m.const==="number")m.const=String(m.const);if(!o)return m;if(m.type="string",!s)m.pattern=(n.includes("number")?qt:To).source;return m}var cs=new WeakMap;function Bh(e){let t=new Map;for(let n of e.seen.values())if(n.def&&!t.has(n.schema))t.set(n.schema,n);let r=new Map;for(let n of cs.get(e)??[]){let o=e.seen.get(n),s=(o?.def??o?.schema)?.propertyNames;if(!s||s===!0||r.has(s))continue;let i=as(t,s,new Set);if(i!==s)r.set(s,i)}if(!r.size)return;for(let n of e.seen.values())for(let o of[n.schema,n.def]){let s=o&&r.get(o.propertyNames);if(s)o.propertyNames=s}}var Bl=(e,t,r,n)=>{let o=r,s=e._zod.def;o.type="object";let i=s.keyType,a=de(i).patterns;if(s.mode==="loose"&&a&&a.size>0){let l=V(s.valueType,t,{...n,path:[...n.path,"patternProperties","*"]});o.patternProperties={};for(let p of a)ve(o.patternProperties,Il(p).source,l)}else{if(t.target==="draft-07"||t.target==="draft-2020-12"){o.propertyNames=V(s.keyType,t,{...n,path:[...n.path,"propertyNames"]});let l=cs.get(t);if(!l)l=[],cs.set(t,l),t.deferred.push(()=>Bh(t));l.push(e)}o.additionalProperties=V(s.valueType,t,{...n,path:[...n.path,"additionalProperties"]})}let c=i._zod.values,u=t.io==="input"&&pn(s.valueType)!==void 0;if(c&&!s.partial&&!u){let l=[...c].filter((p)=>typeof p==="string"||typeof p==="number");if(l.length>0)o.required=l.map(String)}},Gl=(e,t,r,n)=>{let o=e._zod.def,s=V(o.innerType,t,n),i=t.seen.get(e);if(t.target==="openapi-3.0")i.ref=o.innerType,r.nullable=!0;else r.anyOf=[s,{type:"null"}]},Vl=(e,t,r,n)=>{let o=e._zod.def;V(o.innerType,t,n);let s=t.seen.get(e);s.ref=o.innerType},us=Symbol();function Wl(e,t,r,n,o){let s=!1,i=JSON.stringify(e,(a,c)=>{if(typeof c!=="bigint")return c;return s=!0,null});if(!s)return JSON.parse(i);return ct(t,r,n,o,"BigInt defaults cannot be represented in JSON Schema"),us}var Kl=(e,t,r,n)=>{let o=e._zod.def;V(o.innerType,t,n);let s=t.seen.get(e);s.ref=o.innerType;let i=Wl(o.defaultValue,e,t,r,n);if(i!==us)r.default=i},Jl=(e,t,r,n)=>{let o=e._zod.def;V(o.innerType,t,n);let s=t.seen.get(e);if(s.ref=o.innerType,t.io!=="input")return;let i=Wl(o.defaultValue,e,t,r,n);if(i!==us)r._prefault=i},Hl=(e,t,r,n)=>{let o=e._zod.def;V(o.innerType,t,n);let s=t.seen.get(e);s.ref=o.innerType;let i;try{i=o.catchValue(void 0)}catch{ct(e,t,r,n,"Dynamic catch values are not supported in JSON Schema");return}r.default=i},ql=(e,t,r,n)=>{let o=e._zod.def,s=o.in._zod.traits.has("$ZodTransform"),i=t.io==="input"?s?o.out:o.in:o.out;V(i,t,n);let a=t.seen.get(e);a.ref=i},Yl=(e,t,r,n)=>{let o=e._zod.def;V(o.innerType,t,n);let s=t.seen.get(e);s.ref=o.innerType,r.readOnly=!0};var ls=(e,t,r,n)=>{let o=e._zod.def;V(o.innerType,t,n);let s=t.seen.get(e);s.ref=o.innerType};var Xl=new WeakSet([Object.prototype,Error.prototype]);function dn(e,t,r){Object.defineProperty(e,t,{configurable:!0,enumerable:!1,get(){let n=r(this);return Object.defineProperty(this,t,{value:n,configurable:!0,writable:!0}),n},set(n){Object.defineProperty(this,t,{value:n,configurable:!0,writable:!0})}})}var Xh=(e,t)=>{Ca.init(e,t),e.name="ZodError";let r=Object.getPrototypeOf(e);if(Xl.has(r))return;Xl.add(r),dn(r,"format",(n)=>(o)=>ko(n,o)),dn(r,"flatten",(n)=>(o)=>Po(n,o)),dn(r,"addIssue",(n)=>(o)=>{n.issues.push(o),n.message=JSON.stringify(n.issues,Kt,2)}),dn(r,"addIssues",(n)=>(o)=>{n.issues.push(...o),n.message=JSON.stringify(n.issues,Kt,2)}),Object.defineProperty(r,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}})};var ce=h("ZodError",Xh,void 0,{Parent:Error});var Ql=Fr(ce),ep=Mr(ce),tp=Br(ce),rp=Gr(ce),np=Ta(ce),op=Oa(ce),sp=Aa(ce),ip=ja(ce),ap=Ra(ce),cp=La(ce),up=Za(ce),lp=Da(ce);function eg(){if(!ee.localeError)te(Go())}function fn(){if(!ee.memoizer)te({memoizer:Bo()})}var M=h("ZodType",(e,t)=>(eg(),U.init(e,t),e.def=t,e.type=t.type,e),{check(...e){let t=this.def;return this.clone(ae(t,{checks:[...t.checks??[],...e.map((r)=>typeof r==="function"?{_zod:{check:r,def:{check:"custom"},onattach:[]}}:r)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return $e(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(Kg(e,t))},superRefine(e,t){return this.check(Jg(e,t))},overwrite(e){return this.check(qe(e))},optional(){return dp(this)},exactOptional(){return jg(this)},nullable(){return mp(this)},nullish(){return dp(mp(this))},nonoptional(e){return Ug(this,e)},array(){return me(this)},or(e){return fs([this,e])},and(e){return Ig(this,e)},transform(e){return fp(this,Ag(e))},default(e){return Zg(this,e)},prefault(e){return Ng(this,e)},catch(e){return Mg(this,e)},pipe(e){return fp(this,e)},readonly(){return Vg(this)},describe(e){let t=this.clone();return He.add(t,{description:e}),t},meta(...e){if(e.length===0)return He.get(this);let t=this.clone();return He.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e,...t){return t.length===0?e(this):e(this,...t)},get "~standard"(){return Nr(this,"~standard",{...Zo(this),jsonSchema:{input:nr(this,"input"),output:nr(this,"output")}})},set "~standard"(e){Me(this,"~standard",e)},parse:function e(t,r){return Ql(this,t,r,{callee:e})},parseAsync:async function e(t,r){return await ep(this,t,r,{callee:e})},safeParse(e,t){return tp(this,e,t)},async safeParseAsync(e,t){return rp(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){Me(this,"spa",e)},validate(e,t){return zo(this,e,t)},validateAsync(e,t){return Eo(this,e,t)},encode:function e(t,r){return np(this,t,r,{callee:e})},decode:function e(t,r){return op(this,t,r,{callee:e})},encodeAsync:async function e(t,r){return await sp(this,t,r,{callee:e})},decodeAsync:async function e(t,r){return await ip(this,t,r,{callee:e})},safeEncode(e,t){return ap(this,e,t)},safeDecode(e,t){return cp(this,e,t)},async safeEncodeAsync(e,t){return up(this,e,t)},async safeDecodeAsync(e,t){return lp(this,e,t)},toJSONSchema(e){return wl(this,{})(e)},get description(){return He.get(this)?.description},get _def(){return this._zod.def}}),hp=h("_ZodString",(e,t)=>{Hr.init(e,t),M.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Tl(e,r,n,o)},$a({format:(e)=>de(e).format??null,minLength:(e)=>de(e).minimum??null,maxLength:(e)=>de(e).maximum??null},{regex(...e){return this.check(Wo(...e))},includes(...e){return this.check(Ho(...e))},startsWith(...e){return this.check(qo(...e))},endsWith(...e){return this.check(Yo(...e))},min(...e){return this.check(vt(...e))},max(...e){return this.check(un(...e))},length(...e){return this.check(ln(...e))},nonempty(...e){return this.check(vt(1,...e))},lowercase(e){return this.check(Ko(e))},uppercase(e){return this.check(Jo(e))},trim(){return this.check(Qo())},normalize(...e){return this.check(Xo(...e))},toLowerCase(){return this.check(es())},toUpperCase(){return this.check(ts())},slugify(){return this.check(rs())}})),tg=h("ZodString",(e,t)=>{Hr.init(e,t),hp.init(e,t)},{email(e){return this.check(Fu(rg,e))},url(e){return this.check(Vo(gp,e))},jwt(e){return this.check(al(_g,e))},emoji(e){return this.check(Ku(sg,e))},guid(e){return this.check(Mu(ng,e))},uuid(e){return this.check(Bu(mn,e))},uuidv4(e){return this.check(Gu(mn,e))},uuidv6(e){return this.check(Vu(mn,e))},uuidv7(e){return this.check(Wu(mn,e))},nanoid(e){return this.check(Ju(ig,e))},cuid(e){return this.check(Hu(ag,e))},cuid2(e){return this.check(qu(cg,e))},ulid(e){return this.check(Yu(ug,e))},base64(e){return this.check(ol(gg,e))},base64url(e){return this.check(sl(xg,e))},xid(e){return this.check(Xu(lg,e))},ksuid(e){return this.check(Qu(pg,e))},ipv4(e){return this.check(el(dg,e))},ipv6(e){return this.check(tl(mg,e))},cidrv4(e){return this.check(rl(fg,e))},cidrv6(e){return this.check(nl(hg,e))},e164(e){return this.check(il(yg,e))},datetime(e){return this.check(tn(sr,e))},date(e){return this.check(rn(ir,e))},time(e){return this.check(nn(ar,e))},duration(e){return this.check(on(cr,e))}});function b(e){return Uu(tg,e)}var F=h("ZodStringFormat",(e,t)=>{D.init(e,t),hp.init(e,t)}),sr=h("ZodISODateTime",(e,t)=>{qc.init(e,t),F.init(e,t)}),ir=h("ZodISODate",(e,t)=>{Yc.init(e,t),F.init(e,t)}),ar=h("ZodISOTime",(e,t)=>{Xc.init(e,t),F.init(e,t)}),cr=h("ZodISODuration",(e,t)=>{Qc.init(e,t),F.init(e,t)}),rg=h("ZodEmail",(e,t)=>{Nc.init(e,t),F.init(e,t)});var ng=h("ZodGUID",(e,t)=>{Zc.init(e,t),F.init(e,t)});var mn=h("ZodUUID",(e,t)=>{Dc.init(e,t),F.init(e,t)});var gp=h("ZodURL",(e,t)=>{Mc.init(e,t),F.init(e,t)});function og(e){return Vo(gp,e)}var sg=h("ZodEmoji",(e,t)=>{Bc.init(e,t),F.init(e,t)});var ig=h("ZodNanoID",(e,t)=>{Gc.init(e,t),F.init(e,t)});var ag=h("ZodCUID",(e,t)=>{Vc.init(e,t),F.init(e,t)});var cg=h("ZodCUID2",(e,t)=>{Wc.init(e,t),F.init(e,t)});var ug=h("ZodULID",(e,t)=>{Kc.init(e,t),F.init(e,t)});var lg=h("ZodXID",(e,t)=>{Jc.init(e,t),F.init(e,t)});var pg=h("ZodKSUID",(e,t)=>{Hc.init(e,t),F.init(e,t)});var dg=h("ZodIPv4",(e,t)=>{eu.init(e,t),F.init(e,t)});var mg=h("ZodIPv6",(e,t)=>{ru.init(e,t),F.init(e,t)});var fg=h("ZodCIDRv4",(e,t)=>{nu.init(e,t),F.init(e,t)});var hg=h("ZodCIDRv6",(e,t)=>{ou.init(e,t),F.init(e,t)});var gg=h("ZodBase64",(e,t)=>{iu.init(e,t),F.init(e,t)});var xg=h("ZodBase64URL",(e,t)=>{au.init(e,t),F.init(e,t)});var yg=h("ZodE164",(e,t)=>{cu.init(e,t),F.init(e,t)});var _g=h("ZodJWT",(e,t)=>{uu.init(e,t),F.init(e,t)});var xp=h("ZodNumber",(e,t)=>{No.init(e,t),M.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Ol(e,r,n,o),e.isFinite=!0},$a({minValue:(e)=>{let{minimum:t,exclusiveMinimum:r}=de(e);return Math.max(t??Number.NEGATIVE_INFINITY,r??Number.NEGATIVE_INFINITY)},maxValue:(e)=>{let{maximum:t,exclusiveMaximum:r}=de(e);return Math.min(t??Number.POSITIVE_INFINITY,r??Number.POSITIVE_INFINITY)},isInt:(e)=>{let{isInt:t,multipleOf:r}=de(e);return!!t||!!r?.some(Number.isSafeInteger)},format:(e)=>de(e).format??null},{gt(e,t){return this.check(an(e,t))},gte(e,t){return this.check(tr(e,t))},min(e,t){return this.check(tr(e,t))},lt(e,t){return this.check(sn(e,t))},lte(e,t){return this.check(er(e,t))},max(e,t){return this.check(er(e,t))},int(e){return this.check(pp(e))},safe(e){return this.check(pp(e))},positive(e){return this.check(an(0,e))},nonnegative(e){return this.check(tr(0,e))},negative(e){return this.check(sn(0,e))},nonpositive(e){return this.check(er(0,e))},multipleOf(e,t){return this.check(cn(e,t))},step(e,t){return this.check(cn(e,t))},finite(){return this}}));function yp(e){return cl(xp,e)}var bg=h("ZodNumberFormat",(e,t)=>{lu.init(e,t),xp.init(e,t)});function pp(e){return ul(bg,e)}var wg=h("ZodBoolean",(e,t)=>{pu.init(e,t),M.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Al(e,r,n,o)});function vg(e){return ll(wg,e)}var $g=h("ZodUnknown",(e,t)=>{du.init(e,t),M.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Rl(e,r,n,o)});function ps(){return pl($g)}var Sg=h("ZodNever",(e,t)=>{mu.init(e,t),M.init(e,t),e._zod.processJSONSchema=(r,n,o)=>jl(e,r,n,o)});function Pg(e){return dl(Sg,e)}var kg=h("ZodArray",(e,t)=>{fn(),fu.init(e,t),M.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Nl(e,r,n,o),e.element=t.element},{min(e,t){return this.check(vt(e,t))},nonempty(e){return this.check(vt(1,e))},max(e,t){return this.check(un(e,t))},length(e,t){return this.check(ln(e,t))},unwrap(){return this.element}});function me(e,t){return ml(kg,e,t)}var zg=h("ZodObject",(e,t)=>{fn(),xu.init(e,t),M.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Ul(e,r,n,o),ch(e,"shape",(r)=>r._zod.def.shape,!1)},{keyof(){return _p(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(ae(this._zod.def,{catchall:e}))},passthrough(){return this.clone(ae(this._zod.def,{catchall:ps()}))},loose(){return this.clone(ae(this._zod.def,{catchall:ps()}))},strict(){return this.clone(ae(this._zod.def,{catchall:Pg()}))},strip(){return this.clone(ae(this._zod.def,{catchall:void 0}))},extend(e){return eh(this,e)},safeExtend(e){return th(this,e)},merge(e){return rh(this,e)},pick(e){return Xf(this,e)},omit(e){return Qf(this,e)},partial(...e){return _a(bp,this,e[0])},exactPartial(...e){return _a(wp,this,e[0],"exactPartial")},required(...e){return nh(vp,this,e[0])}});function z(e,t){let r={type:"object",shape:e??{},...v(t)};return new zg(r)}var Eg=h("ZodUnion",(e,t)=>{yu.init(e,t),M.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Fl(e,r,n,o),e.options=t.options});function fs(e,t){return new Eg({type:"union",options:e,...v(t)})}var Cg=h("ZodIntersection",(e,t)=>{_u.init(e,t),M.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Ml(e,r,n,o)});function Ig(e,t){return new Cg({type:"intersection",left:e,right:t})}var ds=h("ZodRecord",(e,t)=>{fn(),bu.init(e,t),M.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Bl(e,r,n,o),e.keyType=t.keyType,e.valueType=t.valueType});function hs(e,t,r){if(!t||!t._zod)return new ds({type:"record",keyType:b(),valueType:e,...v(t)});return new ds({type:"record",keyType:e,valueType:t,...v(r)})}function Tg(e,t,r){return new ds({type:"record",keyType:e,valueType:t,...v(r),partial:!0})}var ms=h("ZodEnum",(e,t)=>{wu.init(e,t),M.init(e,t),e._zod.processJSONSchema=(n,o,s)=>Ll(e,n,o,s),e.enum=t.entries,e.options=[...e._zod.values];let r=new Set(Object.keys(t.entries));e.extract=(n,o)=>{let s={};for(let i of n)if(r.has(i))s[i]=t.entries[i];else throw Error(`Key ${i} not found in enum`);return new ms({...t,checks:[],...v(o),entries:s})},e.exclude=(n,o)=>{let s={...t.entries};for(let i of n)if(r.has(i))delete s[i];else throw Error(`Key ${i} not found in enum`);return new ms({...t,checks:[],...v(o),entries:s})}});function _p(e,t){let r=Array.isArray(e)?Object.fromEntries(e.map((n)=>[n,n])):e;return new ms({type:"enum",entries:r,...v(t)})}var Og=h("ZodTransform",(e,t)=>{fn(),vu.init(e,t),M.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Dl(e,r,n,o),e._zod.parse=(r,n)=>{if(n.direction==="backward")throw new Jt(e.constructor.name);r.addIssue=(s)=>{if(typeof s==="string")r.issues.push(at(s,r.value,t));else{let i=s;if(i.fatal)i.continue=!1;if(i.code??(i.code="custom"),!("input"in i))i.input=r.value;i.inst??(i.inst=e),r.issues.push(at(i))}};let o=t.transform(r.value,r);if(o instanceof Promise)return o.then((s)=>(r.value=s,r));return r.value=o,r}});function Ag(e){return new Og({type:"transform",transform:e})}var bp=h("ZodOptional",(e,t)=>{Uo.init(e,t),M.init(e,t),e._zod.processJSONSchema=(r,n,o)=>ls(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function dp(e){return new bp({type:"optional",innerType:e})}var wp=h("ZodExactOptional",(e,t)=>{$u.init(e,t),M.init(e,t),e._zod.processJSONSchema=(r,n,o)=>ls(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function jg(e){return new wp({type:"optional",innerType:e})}var Rg=h("ZodNullable",(e,t)=>{Su.init(e,t),M.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Gl(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function mp(e){return new Rg({type:"nullable",innerType:e})}var Lg=h("ZodDefault",(e,t)=>{Pu.init(e,t),M.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Kl(e,r,n,o),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Zg(e,t){return new Lg({type:"default",innerType:e,get defaultValue(){return typeof t==="function"?t():yo(t)}})}var Dg=h("ZodPrefault",(e,t)=>{ku.init(e,t),M.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Jl(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function Ng(e,t){return new Dg({type:"prefault",innerType:e,get defaultValue(){return typeof t==="function"?t():yo(t)}})}var vp=h("ZodNonOptional",(e,t)=>{zu.init(e,t),M.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Vl(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function Ug(e,t){return new vp({type:"nonoptional",innerType:e,...v(t)})}var Fg=h("ZodCatch",(e,t)=>{Eu.init(e,t),M.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Hl(e,r,n,o),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function Mg(e,t){return new Fg({type:"catch",innerType:e,catchValue:typeof t==="function"?t:Sa(t)})}var Bg=h("ZodPipe",(e,t)=>{Cu.init(e,t),M.init(e,t),e._zod.processJSONSchema=(r,n,o)=>ql(e,r,n,o),e.in=t.in,e.out=t.out});function fp(e,t){return new Bg({type:"pipe",in:e,out:t})}var Gg=h("ZodReadonly",(e,t)=>{Iu.init(e,t),M.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Yl(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function Vg(e){return new Gg({type:"readonly",innerType:e})}var Wg=h("ZodCustom",(e,t)=>{Tu.init(e,t),M.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Zl(e,r,n,o)});function Kg(e,t={}){return fl(Wg,e,t)}function Jg(e,t){return hl(e,t)}var hn={};jm(hn,{ZodISODate:()=>ir,ZodISODateTime:()=>sr,ZodISODuration:()=>cr,ZodISOTime:()=>ar,date:()=>qg,datetime:()=>Hg,duration:()=>Xg,time:()=>Yg});function Hg(e){return tn(sr,e)}function qg(e){return rn(ir,e)}function Yg(e){return nn(ar,e)}function Xg(e){return on(cr,e)}var $p=mt(Tt(),1);var gs=()=>process.env.NIPA_DEBUG==="1",Pt=(e)=>{if(gs())ie($p.default.dim(`> [debug] [${new Date().toISOString()}] ${e}`))};class kt extends Error{url;constructor(e,t){super(`can't reach ${new URL(e).host}: ${t}`);this.name="NetworkError",this.url=e}}var Sp=(e)=>e.cause instanceof Error?`${e.message} (${Sp(e.cause)})`:e.message,Oe=async(e,t={})=>{let r=t.method??"GET",n=performance.now();Pt(`${r} ${e}`);let o;try{o=await fetch(e,t)}catch(s){throw new kt(e,s instanceof Error?Sp(s):String(s))}return Pt(`${o.status} ${r} ${e} [${we(performance.now()-n)}]`),o};var xs=z({domainId:b().optional(),id:b(),name:b()});class ue extends Error{status;constructor(e,t){super(e);this.name="KeystoneError",this.status=t}}var gn=(e)=>{let t=e;while(t.endsWith("/"))t=t.slice(0,-1);if(t.endsWith("/v3"))t=t.slice(0,-3);return`${t}/v3`},ys=(e,t)=>t?{auth:{identity:e,scope:{project:{id:t}}}}:{auth:{identity:e}},kp=(e)=>({domain:{name:e.userDomain},name:e.username}),Qg=(e,t)=>ys({methods:["password"],password:{user:{...kp(e),password:t}}},e.projectId),ex=(e,t)=>ys({methods:["totp"],totp:{user:{...kp(e),passcode:t}}},e.projectId),tx=(e,t)=>ys({methods:["token"],token:{id:e}},t),rx=z({error:z({message:b().optional()}).optional(),receipt:z({}).loose().optional(),required_auth_methods:me(me(b())).optional()}),zp=async(e)=>{try{let t=rx.safeParse(JSON.parse(await e.text()));return t.success?t.data:{}}catch{return{}}},Ep=(e)=>e.length>0?`this account needs ${e.map((t)=>t.join(" + ")).join(" or ")} to log in`:"this account's MFA rules don't allow this login method",nx=(e)=>{let{body:t,status:r}=e;if(t.receipt)return Ep(t.required_auth_methods??[]);if(r===401)return e.unauthorized;return t.error?.message??`Keystone returned HTTP ${r}`},ur=async(e,t)=>{let r=await zp(e);throw new ue(nx({body:r,status:e.status,unauthorized:t}),e.status)},ox=z({token:z({expires_at:b(),project:z({domain:z({id:b()}).optional(),id:b(),name:b()}).optional(),user:z({id:b(),name:b()})})}),sx=(e,t)=>{let{expires_at:r,project:n,user:o}=t.token;return{expiresAt:r,project:n&&{domainId:n.domain?.id,id:n.id,name:n.name},user:o,value:e}},Cp="Openstack-Auth-Receipt",_s=(e,t,r)=>{let n=new Headers({"Content-Type":"application/json"});if(r!==void 0)n.set(Cp,r);return Oe(`${gn(e)}/auth/tokens`,{body:JSON.stringify(t),headers:n,method:"POST"})},bs=async(e)=>{let t=e.headers.get("X-Subject-Token");if(!t)throw new ue("Keystone didn't return a token",e.status);let r=ox.safeParse(await e.json());if(!r.success)throw new ue(`unexpected token response: ${Ht(r.error)}`,e.status);return sx(t,r.data)},Ip=async(e,t)=>{let r=await _s(e.authUrl,Qg(e,t));if(r.ok)return{kind:"token",token:await bs(r)};let n=r.headers.get(Cp);if(r.status===401&&n){let s=(await zp(r)).required_auth_methods;if(!s||s.some((i)=>i.includes("totp")))return{kind:"mfa",receipt:n};throw new ue(Ep(s),r.status)}return ur(r,"wrong email or password")},Tp=async(e)=>{let{account:t,passcode:r,receipt:n}=e,o=await _s(t.authUrl,ex(t,r),n);return o.ok?bs(o):ur(o,"wrong OTP code")},ws="the session expired or was revoked",xn=async(e)=>{let t=await _s(e.authUrl,tx(e.token,e.projectId));return t.ok?bs(t):ur(t,ws)},ix=z({projects:me(z({domain_id:b().optional(),enabled:vg().optional(),id:b(),name:b()}))}),ax=(e)=>e.projects.filter((t)=>t.enabled!==!1).map((t)=>({domainId:t.domain_id,id:t.id,name:t.name})).toSorted((t,r)=>t.name.localeCompare(r.name)),zt=async({authUrl:e,token:t})=>{let r=await Oe(`${gn(e)}/auth/projects`,{headers:{"X-Auth-Token":t}});if(!r.ok)return ur(r,ws);let n=ix.safeParse(await r.json());if(!n.success)throw new ue(`unexpected project list: ${Ht(n.error)}`,r.status);return ax(n.data)},yn=async({authUrl:e,token:t})=>{let r=await Oe(`${gn(e)}/auth/tokens`,{headers:{"X-Auth-Token":t,"X-Subject-Token":t},method:"DELETE"});if(!(r.ok||r.status===401||r.status===404))await ur(r,ws)},Pp=z({version:z({id:b(),status:b()})}),Op=async(e)=>{let t=gn(e),r=await Oe(t,{signal:AbortSignal.timeout(1e4)}),n;try{n=Pp.safeParse(await r.json())}catch{n=Pp.safeParse(null)}if(!(r.ok&&n.success))throw new ue(`${t} doesn't answer like Keystone v3 (HTTP ${r.status})`,r.status);return n.data.version.id};import{spawn as kx}from"node:child_process";import{once as zx}from"node:events";import{stat as Ex}from"node:fs/promises";import{text as Cx}from"node:stream/consumers";import{accessSync as cx,constants as ux}from"node:fs";import{homedir as lx}from"node:os";import lr from"node:path";var Ap=(e)=>{try{return cx(e,ux.X_OK),!0}catch{return!1}},px=(e)=>process.platform==="win32"?[...(process.env.PATHEXT??".EXE;.CMD;.BAT").split(";").map((t)=>`${e}${t}`),e]:[e],_n=(e)=>{if(e.includes("/")||e.includes(lr.sep)){let r=lr.resolve(e);return Ap(r)?r:void 0}return[...(process.env.PATH??"").split(lr.delimiter).filter(Boolean),lr.join(lx(),".local","bin")].flatMap((r)=>px(lr.join(r,e))).find(Ap)},bn=(e)=>({OS_AUTH_TYPE:"v3token",OS_AUTH_URL:e.profile.authUrl,OS_IDENTITY_API_VERSION:"3",OS_INTERFACE:"public",OS_PROJECT_DOMAIN_ID:e.session.project.domainId??"",OS_PROJECT_ID:e.session.project.id,OS_PROJECT_NAME:e.session.project.name,OS_REGION_NAME:e.profile.region,OS_TOKEN:e.session.token}),Rp=(e,t)=>({...Object.fromEntries(Object.entries(e).filter(([r])=>!r.startsWith("OS_"))),...t}),vs=["bash","zsh","fish"],dx=(e)=>vs.some((t)=>t===e),jp=(e,t)=>`'${t==="fish"?e.replaceAll("\\","\\\\").replaceAll("'","\\'"):e.replaceAll("'","'\\''")}'`,Lp=(e,t)=>Object.entries(e).map(([r,n])=>t==="fish"?`set -gx ${r} ${jp(n,t)}`:`export ${r}=${jp(n,t)}`).join(`
90
+ `),Zp=(e)=>{let t=e?.split("/").at(-1)??"";return dx(t)?t:"bash"};import{chmod as hx,mkdir as Bp,readFile as Gp,rm as gx,writeFile as Vp}from"node:fs/promises";import{homedir as Wp}from"node:os";import ut from"node:path";class Ye extends Error{status;constructor(e,t){super(e);this.name="ApiError",this.status=t}}var mx=z({message:b()}),Dp=async(e)=>{try{let t=mx.safeParse(JSON.parse(await e.text()));return t.success?t.data.message:void 0}catch{return}},fx=async(e,t)=>{try{return t.safeParse(await e.json())}catch{return t.safeParse(null)}},Np=(e)=>{let t=e;while(t.endsWith("/"))t=t.slice(0,-1);return t},pr=(e)=>{let{origin:t,pathname:r}=new URL(e),n=Np(r);return n===""?`${t}/api`:`${t}${n}`},Up=async(e)=>{let t=await Oe(`${e}/v3/instances`,{headers:{Accept:"application/json"},signal:AbortSignal.timeout(1e4)}),r=await Dp(t);if(t.status!==401||r===void 0)throw new Ye(`${e} doesn't answer like the Space API (HTTP ${t.status})`,t.status)},Fp=(e)=>{let t=Np(e.url);return{get:async(r,n)=>{let o=await Oe(`${t}${r}`,{headers:{Accept:"application/json","Project-Id":e.projectId,Region:e.region,"X-Auth-Token":e.token}});if(!o.ok){let i=await Dp(o)??`the Space API returned HTTP ${o.status}`;throw new Ye(i,o.status)}if(!o.headers.get("Content-Type")?.includes("json"))throw new E(`${t} doesn't answer like the Space API`,{hint:"Check the profile's `spaceUrl` with `nipa profile ls --json`. It's the portal URL with /api, such as https://space.nipa.cloud/api."});let s=await fx(o,n);if(!s.success)throw new Ye(`unexpected Space API response: ${Ht(s.error)}`,o.status);return s.data}}};var re="prod",q={authUrl:"https://identity-api.nipa.cloud/v3",region:"NCP-TH",spaceUrl:"https://space.nipa.cloud/api",userDomain:"nipacloud"},Mp=og({protocol:/^https?$/u}),Be=z({authUrl:Mp,project:xs.optional(),region:b().min(1),spaceUrl:Mp.optional(),userDomain:b().min(1),username:b().optional()}),Ss=/^[a-z][\da-z-]{0,31}$/u,xx=hs(b().regex(Ss),Be),yx=(e)=>{let{spaceUrl:t,...r}=e;if(e.authUrl===q.authUrl)return{...r,spaceUrl:pr(t??q.spaceUrl)};if(t===void 0||t===q.spaceUrl)return r;return{...r,spaceUrl:pr(t)}},Ps=(e)=>({[re]:q,...Object.fromEntries(Object.entries(e).map(([t,r])=>[t,yx(r)]))}),_x=z({currentProfile:b().default(re),profiles:xx.default({})}).strict().transform((e)=>({...e,profiles:Ps(e.profiles)})),bx=Be.extend({authUrl:Be.shape.authUrl.default(q.authUrl),region:Be.shape.region.default(q.region),userDomain:Be.shape.userDomain.default(q.userDomain)}).transform((e)=>({currentProfile:re,profiles:Ps({[re]:e})})),wx=fs([_x,bx]),Kp=z({expiresAt:hn.datetime({offset:!0}),project:xs,token:b().min(1),user:z({id:b(),name:b()})}),vx=hs(b(),Kp),$x=fs([z({sessions:vx}).strict().transform((e)=>e.sessions),Kp.transform((e)=>({[re]:e}))]);class dr extends Error{constructor(e){super(e);this.name="StoreError"}}var Sx=60000,ks=(e=process.env)=>e.NIPA_CONFIG_DIR??ut.join(e.XDG_CONFIG_HOME??ut.join(Wp(),".config"),"nipa"),Jp=()=>ut.join(ks(),"config.json"),wn=()=>ut.join(ks(),"auth.json"),$s=(e,t=process.env)=>ut.join(t.XDG_CACHE_HOME??ut.join(Wp(),".cache"),"nipa",e),lt=async(e,t)=>{try{let r=await Gp($s(e),"utf-8"),n=t.safeParse(JSON.parse(r));return n.success?n.data:void 0}catch{return}},pt=async(e,t)=>{await Bp(ut.dirname($s(e)),{recursive:!0}),await Vp($s(e),`${JSON.stringify(t)}
91
+ `)},Px=async(e)=>{try{return await Gp(e,"utf-8")}catch(t){if(t instanceof Error&&"code"in t&&t.code==="ENOENT")return;throw t}},Hp=async(e,t)=>{let r=await Px(e);if(r===void 0)return;let n;try{n=JSON.parse(r)}catch{throw new dr(`${e} isn't valid JSON`)}let o=t.safeParse(n);if(!o.success)throw new dr(`${e}: ${Ht(o.error)}`);return o.data},zs=async(e,t)=>{await Bp(ks(),{mode:448,recursive:!0}),await Vp(e,`${JSON.stringify(t,null,2)}
92
+ `,{mode:384}),await hx(e,384)},fe=async()=>await Hp(Jp(),wx)??{currentProfile:re,profiles:Ps({})},Xe=(e)=>zs(Jp(),e),Es=async()=>await Hp(wn(),$x)??{},he=async(e)=>(await Es())[e],qp=async(e)=>{let t=await Es();await zs(wn(),{sessions:{...t,[e.profile]:e.session}})},vn=async(e)=>{let t=await Es(),r=Object.fromEntries(Object.entries(t).filter(([n])=>n!==e));if(Object.keys(r).length===0){await gx(wn(),{force:!0});return}await zs(wn(),{sessions:r})},Cs=(e,t=Date.now())=>Date.parse(e.expiresAt)-t,ne=(e,t=Date.now())=>e!==void 0&&Cs(e,t)>Sx;var Yp="openstack.json",Ix=20000,Tx=hs(b(),me(b())),Ox=z({bin:b(),mtimeMs:yp(),table:Tx}),Ax=/^\s*cmds(?:_(?<key>\S+))?='(?<words>[^']*)'$/u,jx=(e)=>Object.fromEntries(e.split(`
93
+ `).flatMap((t)=>{let r=Ax.exec(t)?.groups;if(!r)return[];let n=r.words?.split(" ").filter(Boolean)??[];return[[r.key??"",n]]})),Rx=(e,t)=>{let r=t.at(-1)??"",n="";for(let s of t.slice(0,-1)){let i=(n?`${n}_${s}`:s).replaceAll("-","_");if(s.startsWith("-")||!Object.hasOwn(e,i))break;n=i}let o=e[n]??[];if(r.startsWith("-"))return o.filter((s)=>s.startsWith(r));return o.filter((s)=>s.startsWith(r)&&!s.startsWith("-")&&!s.includes("_"))},Lx=async(e)=>{let{mtimeMs:t}=await Ex(e),r=await lt(Yp,Ox);if(r?.bin===e&&r.mtimeMs===t)return r.table;let n=kx(e,["complete","--shell","none"],{stdio:["ignore","pipe","ignore"],timeout:Ix}),[o]=await Promise.all([Cx(n.stdout),zx(n,"close")]);if(n.exitCode!==0)return;let s=jx(o);return await pt(Yp,{bin:e,mtimeMs:t,table:s}),s},Xp=async(e)=>{let t=_n("openstack");if(!t)return[];let r=await Lx(t);return r?Rx(r,e):[]};var Qp=["bash","zsh","fish","pwsh"],ed=["projects","profiles","openstack"],Et=(e)=>`nipa __complete ${e}`,dt=se(Rn),Zx=(e)=>e.filter((t)=>t.kind==="passthrough").flatMap((t)=>X(t)),Is=(e)=>[...e.flags,...oe],Pn=(e)=>{let t=e.args.findIndex((n)=>n.value.kind!=="text"),r=e.args[t];return r?{arg:r,position:t+1}:void 0},Dx=(e)=>{switch(e.kind){case"none":return;case"text":return"return";case"choice":return`_nipa_reply ${e.choices.join(" ")}; return`;case"project":return`_nipa_reply "$(${Et("projects")} 2>/dev/null)"; return`;case"profile":return`_nipa_reply "$(${Et("profiles")} 2>/dev/null)"; return`;default:return e}},Nx=(e)=>{switch(e.kind){case"text":return;case"project":return`_nipa_reply "$(${Et("projects")} 2>/dev/null)"`;case"profile":return`_nipa_reply "$(${Et("profiles")} 2>/dev/null)"`;case"choice":return`_nipa_reply ${e.choices.join(" ")}`;default:return e}},Ux=(e)=>{switch(e.kind){case"program":return`COMP_WORDS[i]=${e.program}; _nipa_offset "$i"`;case"command":return'_nipa_offset "$((i + 1))"';case"openstack":return'_nipa_reply "$(nipa __complete openstack -- "${COMP_WORDS[@]:i+1:COMP_CWORD-i}" 2>/dev/null)"';default:return e}},td=(e,t)=>{let r=" ".repeat(t*2+2),n=[];if(e.kind==="group"){let s=e.subcommands;n.push(`if [[ $COMP_CWORD -eq $((i + 1)) ]]; then _nipa_reply ${s.map((i)=>i.name).join(" ")}; return; fi`,"case ${COMP_WORDS[i + 1]} in",...s.map((i)=>td(i,t+1)),"esac")}else if(e.kind==="passthrough")n.push(Ux(e.target));else{let s=Is(e),i=s.flatMap((l)=>{let p=Dx(l.value);return p===void 0?[]:[` ${se(l).join("|")}) ${p} ;;`]});if(i.length>0)n.push('case "$prev" in',...i,"esac");let a=s.flatMap(se).join(" ");n.push(`if [[ $cur == -* ]]; then _nipa_reply ${a}; return; fi`);let c=Pn(e),u=c&&Nx(c.arg.value);if(u)n.push(u)}let o=n.map((s)=>`${r} ${s}`).join(`
94
+ `);return`${r}${X(e).join("|")})
95
95
  ${o}
96
- ${r} ;;`},_x=(e)=>{let t=Et(e),r=t.map((o)=>o.name).join(" "),n=re.flatMap(ne).join(" ");return`# nipa completion for bash
96
+ ${r} ;;`},Fx=(e)=>{let t=At(e),r=t.map((o)=>o.name).join(" "),n=oe.flatMap(se).join(" ");return`# nipa completion for bash
97
97
  # Load it from ~/.bashrc: eval "$(nipa completion bash)"
98
98
 
99
99
  # One word per line, so project names with spaces stay whole.
@@ -117,32 +117,32 @@ _nipa() {
117
117
  local i=1 command=""
118
118
  while [[ $i -lt $COMP_CWORD ]]; do
119
119
  case \${COMP_WORDS[i]} in
120
- ${at.join("|")}) ((i += 2)) ;;
120
+ ${dt.join("|")}) ((i += 2)) ;;
121
121
  -*) ((i += 1)) ;;
122
122
  *) command=\${COMP_WORDS[i]}; break ;;
123
123
  esac
124
124
  done
125
125
  if [[ -z $command ]]; then
126
126
  case $prev in
127
- ${at.join("|")}) _nipa_reply "$(${$t("profiles")} 2>/dev/null)"; return ;;
127
+ ${dt.join("|")}) _nipa_reply "$(${Et("profiles")} 2>/dev/null)"; return ;;
128
128
  esac
129
129
  if [[ $cur == -* ]]; then _nipa_reply ${n}; else _nipa_reply ${r}; fi
130
130
  return
131
131
  fi
132
132
  case $command in
133
- ${t.map((o)=>Gp(o,0)).join(`
133
+ ${t.map((o)=>td(o,0)).join(`
134
134
  `)}
135
135
  esac
136
136
  }
137
137
  complete -o default -F _nipa nipa
138
- `},yn=(e)=>e.replaceAll("'","'\\''").replaceAll(":","\\:"),bx=(e)=>{let{value:t}=e;switch(t.kind){case"none":return"";case"text":return`:${t.name}: `;case"choice":return`:${e.long}:(${t.choices.join(" ")})`;case"project":return":project:{_nipa_dynamic projects project}";case"profile":return":profile:{_nipa_dynamic profiles profile}";default:return t}},wx=(e)=>{let t=ne(e),r=t.length>1?`(${t.join(" ")})`:"",n=t.length>1?`{${t.join(",")}}`:t[0];return`'${r}'${n}'[${yn(e.description)}]${bx(e)}'`},vx=({arg:e,position:t})=>{let{value:r}=e;switch(r.kind){case"project":return`'${t}:project:{_nipa_dynamic projects project}'`;case"profile":return`'${t}:profile:{_nipa_dynamic profiles profile}'`;case"choice":return`'${t}:${e.name}:(${r.choices.join(" ")})'`;case"text":return"";default:return r}},$x=(e,t)=>{switch(e.kind){case"program":return`${t} words[1]=${e.program}; _normal`;case"command":return`${t} shift words; (( CURRENT-- )); _normal`;case"openstack":return`${t} _nipa_openstack`;default:return e}},Vp=(e,t)=>{if(e.kind==="group"){let o=e.subcommands,s=o.map((a)=>`'${a.name}:${yn(a.summary)}'`).join(" "),i=o.map((a)=>{let c=Vp(a,`${t} `);return`${t} ${q(a).join("|")})
138
+ `},$n=(e)=>e.replaceAll("'","'\\''").replaceAll(":","\\:"),Mx=(e)=>{let{value:t}=e;switch(t.kind){case"none":return"";case"text":return`:${t.name}: `;case"choice":return`:${e.long}:(${t.choices.join(" ")})`;case"project":return":project:{_nipa_dynamic projects project}";case"profile":return":profile:{_nipa_dynamic profiles profile}";default:return t}},Bx=(e)=>{let t=se(e),r=t.length>1?`(${t.join(" ")})`:"",n=t.length>1?`{${t.join(",")}}`:t[0];return`'${r}'${n}'[${$n(e.description)}]${Mx(e)}'`},Gx=({arg:e,position:t})=>{let{value:r}=e;switch(r.kind){case"project":return`'${t}:project:{_nipa_dynamic projects project}'`;case"profile":return`'${t}:profile:{_nipa_dynamic profiles profile}'`;case"choice":return`'${t}:${e.name}:(${r.choices.join(" ")})'`;case"text":return"";default:return r}},Vx=(e,t)=>{switch(e.kind){case"program":return`${t} words[1]=${e.program}; _normal`;case"command":return`${t} shift words; (( CURRENT-- )); _normal`;case"openstack":return`${t} _nipa_openstack`;default:return e}},rd=(e,t)=>{if(e.kind==="group"){let o=e.subcommands,s=o.map((a)=>`'${a.name}:${$n(a.summary)}'`).join(" "),i=o.map((a)=>{let c=rd(a,`${t} `);return`${t} ${X(a).join("|")})
139
139
  ${c}
140
140
  ${t} ;;`}).join(`
141
141
  `);return[`${t} if (( CURRENT == 2 )); then`,`${t} local -a subcommands; subcommands=(${s})`,`${t} _describe -t subcommands '${e.name} subcommand' subcommands; return`,`${t} fi`,`${t} shift words; (( CURRENT-- ))`,`${t} case $words[1] in`,i,`${t} esac`].join(`
142
- `)}if(e.kind==="passthrough")return $x(e.target,t);let r=bn(e),n=[...$s(e).map(wx),r?vx(r):""];return`${t} _arguments -s ${n.filter(Boolean).join(" ")}`},Sx=(e)=>{let t=Et(e),r=t.map((s)=>` '${s.name}:${yn(s.summary)}'`).join(`
143
- `),n=re.flatMap((s)=>ne(s).map((i)=>` '${i}:${yn(s.description)}'`)).join(`
144
- `),o=t.map((s)=>` ${q(s).join("|")})
145
- ${Vp(s," ")}
142
+ `)}if(e.kind==="passthrough")return Vx(e.target,t);let r=Pn(e),n=[...Is(e).map(Bx),r?Gx(r):""];return`${t} _arguments -s ${n.filter(Boolean).join(" ")}`},Wx=(e)=>{let t=At(e),r=t.map((s)=>` '${s.name}:${$n(s.summary)}'`).join(`
143
+ `),n=oe.flatMap((s)=>se(s).map((i)=>` '${i}:${$n(s.description)}'`)).join(`
144
+ `),o=t.map((s)=>` ${X(s).join("|")})
145
+ ${rd(s," ")}
146
146
  ;;`).join(`
147
147
  `);return`#compdef nipa
148
148
  # nipa completion for zsh
@@ -165,13 +165,13 @@ _nipa() {
165
165
  local i=2 command=""
166
166
  while (( i < CURRENT )); do
167
167
  case $words[i] in
168
- ${at.join("|")}) (( i += 2 )) ;;
168
+ ${dt.join("|")}) (( i += 2 )) ;;
169
169
  -*) (( i += 1 )) ;;
170
170
  *) command=$words[i]; break ;;
171
171
  esac
172
172
  done
173
173
  if [[ -z $command ]]; then
174
- if [[ $words[CURRENT-1] == (${at.join("|")}) ]]; then
174
+ if [[ $words[CURRENT-1] == (${dt.join("|")}) ]]; then
175
175
  _nipa_dynamic profiles profile
176
176
  elif [[ $PREFIX == -* ]]; then
177
177
  local -a globals; globals=(
@@ -198,7 +198,7 @@ if [[ $zsh_eval_context[-1] == loadautofunc ]]; then
198
198
  else
199
199
  compdef _nipa nipa
200
200
  fi
201
- `},Ye=(e)=>`'${e.replaceAll("\\","\\\\").replaceAll("'","\\'")}'`,_n=(e)=>`'(${$t(e)} 2>/dev/null)'`,kx=(e)=>{switch(e.kind){case"none":return"";case"text":return" --exclusive";case"choice":return` --exclusive -a ${Ye(e.choices.join(" "))}`;case"project":return` --exclusive -a ${_n("projects")}`;case"profile":return` --exclusive -a ${_n("profiles")}`;default:return e}},Px=(e)=>{switch(e.kind){case"text":return;case"project":return _n("projects");case"profile":return _n("profiles");case"choice":return Ye(e.choices.join(" "));default:return e}},zx=(e)=>{switch(e.kind){case"program":return`'(__nipa_complete_as ${e.program})'`;case"command":return"'(__nipa_complete_as)'";case"openstack":return"'(__nipa_openstack)'";default:return e}},Ex=(e)=>{if(e.kind==="passthrough")return zx(e.target);let t=bn(e);return t&&Px(t.arg.value)},Wp=(e,t)=>{let r=e.short?` -s ${e.short}`:"";return`complete -c nipa -n ${Ye(t)}${r} -l ${e.long}${kx(e.value)} -d ${Ye(e.description)}`},Kp=(e,t)=>{let r=`__nipa_using ${q(t??e).join(" ")}`,n=t?`${r}; and __fish_seen_subcommand_from ${q(e).join(" ")}`:r;if(e.kind==="group"){let c=e.subcommands,u=`${n}; and not __fish_seen_subcommand_from ${c.flatMap((l)=>q(l)).join(" ")}`;return[...c.map((l)=>`complete -c nipa -n ${Ye(u)} -a ${l.name} -d ${Ye(l.summary)}`),...c.flatMap((l)=>Kp(l,e))]}let s=(e.kind==="leaf"?e.flags:[]).map((c)=>Wp(c,n)),i=Ex(e),a=i?[`complete -c nipa -n ${Ye(n)} -a ${i}`]:[];return[...s,...a]},Cx=(e)=>{let t=Et(e),r=[...t,...e.hidden],n=`not __nipa_using ${hx(r).join(" ")}`,o=t.map((s)=>`complete -c nipa -n __nipa_needs_command -a ${s.name} -d ${Ye(s.summary)}`);return`# nipa completion for fish
201
+ `},Qe=(e)=>`'${e.replaceAll("\\","\\\\").replaceAll("'","\\'")}'`,Sn=(e)=>`'(${Et(e)} 2>/dev/null)'`,Kx=(e)=>{switch(e.kind){case"none":return"";case"text":return" --exclusive";case"choice":return` --exclusive -a ${Qe(e.choices.join(" "))}`;case"project":return` --exclusive -a ${Sn("projects")}`;case"profile":return` --exclusive -a ${Sn("profiles")}`;default:return e}},Jx=(e)=>{switch(e.kind){case"text":return;case"project":return Sn("projects");case"profile":return Sn("profiles");case"choice":return Qe(e.choices.join(" "));default:return e}},Hx=(e)=>{switch(e.kind){case"program":return`'(__nipa_complete_as ${e.program})'`;case"command":return"'(__nipa_complete_as)'";case"openstack":return"'(__nipa_openstack)'";default:return e}},qx=(e)=>{if(e.kind==="passthrough")return Hx(e.target);let t=Pn(e);return t&&Jx(t.arg.value)},nd=(e,t)=>{let r=e.short?` -s ${e.short}`:"";return`complete -c nipa -n ${Qe(t)}${r} -l ${e.long}${Kx(e.value)} -d ${Qe(e.description)}`},od=(e,t)=>{let r=`__nipa_using ${X(t??e).join(" ")}`,n=t?`${r}; and __fish_seen_subcommand_from ${X(e).join(" ")}`:r;if(e.kind==="group"){let c=e.subcommands,u=`${n}; and not __fish_seen_subcommand_from ${c.flatMap((l)=>X(l)).join(" ")}`;return[...c.map((l)=>`complete -c nipa -n ${Qe(u)} -a ${l.name} -d ${Qe(l.summary)}`),...c.flatMap((l)=>od(l,e))]}let s=(e.kind==="leaf"?e.flags:[]).map((c)=>nd(c,n)),i=qx(e),a=i?[`complete -c nipa -n ${Qe(n)} -a ${i}`]:[];return[...s,...a]},Yx=(e)=>{let t=At(e),r=[...t,...e.hidden],n=`not __nipa_using ${Zx(r).join(" ")}`,o=t.map((s)=>`complete -c nipa -n __nipa_needs_command -a ${s.name} -d ${Qe(s.summary)}`);return`# nipa completion for fish
202
202
  # Save it: nipa completion fish > ~/.config/fish/completions/nipa.fish
203
203
 
204
204
  function __nipa_command_index
@@ -206,7 +206,7 @@ function __nipa_command_index
206
206
  set -l i 2
207
207
  while test $i -le (count $tokens)
208
208
  switch $tokens[$i]
209
- case ${at.join(" ")}
209
+ case ${dt.join(" ")}
210
210
  set i (math $i + 2)
211
211
  case '-*'
212
212
  set i (math $i + 1)
@@ -247,21 +247,21 @@ function __nipa_openstack
247
247
  end
248
248
 
249
249
  complete -c nipa -f
250
- ${re.map((s)=>Wp(s,n)).join(`
250
+ ${oe.map((s)=>nd(s,n)).join(`
251
251
  `)}
252
252
  ${o.join(`
253
253
  `)}
254
- ${t.flatMap((s)=>Kp(s)).join(`
254
+ ${t.flatMap((s)=>od(s)).join(`
255
255
  `)}
256
- `},ar=(e)=>`'${e.replaceAll("'","''")}'`,Oe=(e)=>`@(${e.map(ar).join(", ")})`,Ix=(e)=>{switch(e.kind){case"none":case"text":return;case"choice":return Oe(e.choices);case"project":return"(Dynamic projects)";case"profile":return"(Dynamic profiles)";default:return e}},Tx=(e)=>{switch(e.kind){case"text":return;case"project":return"(Dynamic projects)";case"profile":return"(Dynamic profiles)";case"choice":return Oe(e.choices);default:return e}},Ox=(e)=>{switch(e.kind){case"openstack":return"(Openstack ($c + 1))";case"program":case"command":return;default:return e}},Jp=(e,t)=>{if(e.kind==="group"){let i=e.subcommands,a=i.map((u)=>`${ar(u.name)} = ${ar(u.summary)}`).join("; "),c=i.map((u)=>{let l=Jp(u,`${t} `);return`${t} { $_ -in ${Oe(q(u))} } {
256
+ `},mr=(e)=>`'${e.replaceAll("'","''")}'`,Ae=(e)=>`@(${e.map(mr).join(", ")})`,Xx=(e)=>{switch(e.kind){case"none":case"text":return;case"choice":return Ae(e.choices);case"project":return"(Dynamic projects)";case"profile":return"(Dynamic profiles)";default:return e}},Qx=(e)=>{switch(e.kind){case"text":return;case"project":return"(Dynamic projects)";case"profile":return"(Dynamic profiles)";case"choice":return Ae(e.choices);default:return e}},ey=(e)=>{switch(e.kind){case"openstack":return"(Openstack ($c + 1))";case"program":case"command":return;default:return e}},sd=(e,t)=>{if(e.kind==="group"){let i=e.subcommands,a=i.map((u)=>`${mr(u.name)} = ${mr(u.summary)}`).join("; "),c=i.map((u)=>{let l=sd(u,`${t} `);return`${t} { $_ -in ${Ae(X(u))} } {
257
257
  ${t} $c += 1
258
258
  ${l}
259
259
  ${t} }`}).join(`
260
- `);return[`${t} if ($index -eq $c + 1) { return Complete ${Oe(i.map((u)=>u.name))} @{ ${a} } }`,`${t} switch ($words[$c + 1]) {`,c,`${t} }`].join(`
261
- `)}if(e.kind==="passthrough"){let i=Ox(e.target);return i?`${t} return Complete ${i}`:`${t} return`}let r=$s(e),n=r.flatMap((i)=>{let a=Ix(i.value);return a===void 0?[]:[`if ($prev -in ${Oe(ne(i))}) { return Complete ${a} }`]});n.push(`if ($wordToComplete -like '-*') { return Complete ${Oe(r.flatMap(ne))} }`);let o=bn(e),s=o&&Tx(o.arg.value);if(s)n.push(`Complete ${s}`);return n.map((i)=>`${t} ${i}`).join(`
262
- `)},Ax=(e)=>{let t=Et(e),r=t.map((o)=>` ${ar(o.name)} = ${ar(o.summary)}`).join(`
263
- `),n=t.map((o)=>` { $_ -in ${Oe(q(o))} } {
264
- ${Jp(o," ")}
260
+ `);return[`${t} if ($index -eq $c + 1) { return Complete ${Ae(i.map((u)=>u.name))} @{ ${a} } }`,`${t} switch ($words[$c + 1]) {`,c,`${t} }`].join(`
261
+ `)}if(e.kind==="passthrough"){let i=ey(e.target);return i?`${t} return Complete ${i}`:`${t} return`}let r=Is(e),n=r.flatMap((i)=>{let a=Xx(i.value);return a===void 0?[]:[`if ($prev -in ${Ae(se(i))}) { return Complete ${a} }`]});n.push(`if ($wordToComplete -like '-*') { return Complete ${Ae(r.flatMap(se))} }`);let o=Pn(e),s=o&&Qx(o.arg.value);if(s)n.push(`Complete ${s}`);return n.map((i)=>`${t} ${i}`).join(`
262
+ `)},ty=(e)=>{let t=At(e),r=t.map((o)=>` ${mr(o.name)} = ${mr(o.summary)}`).join(`
263
+ `),n=t.map((o)=>` { $_ -in ${Ae(X(o))} } {
264
+ ${sd(o," ")}
265
265
  }`).join(`
266
266
  `);return`# nipa completion for PowerShell
267
267
  # Load it from your $PROFILE: nipa completion pwsh | Out-String | Invoke-Expression
@@ -288,23 +288,23 @@ ${r}
288
288
  $c = 1
289
289
  $command = $null
290
290
  while ($c -lt $index) {
291
- if ($words[$c] -in ${Oe(at)}) { $c += 2 }
291
+ if ($words[$c] -in ${Ae(dt)}) { $c += 2 }
292
292
  elseif ($words[$c] -like '-*') { $c += 1 }
293
293
  else { $command = $words[$c]; break }
294
294
  }
295
295
  if (-not $command) {
296
- if ($prev -in ${Oe(at)}) { return Complete (Dynamic profiles) }
297
- if ($wordToComplete -like '-*') { return Complete ${Oe(re.flatMap(ne))} }
296
+ if ($prev -in ${Ae(dt)}) { return Complete (Dynamic profiles) }
297
+ if ($wordToComplete -like '-*') { return Complete ${Ae(oe.flatMap(se))} }
298
298
  return Complete ([string[]]$commands.Keys) $commands
299
299
  }
300
300
  switch ($command) {
301
301
  ${n}
302
302
  }
303
303
  }
304
- `},Hp=(e)=>{let{program:t,shell:r}=e;switch(r){case"bash":return _x(t);case"zsh":return Sx(t);case"fish":return Cx(t);case"pwsh":return Ax(t);default:return r}};var qp=Z({args:[{arity:"one",name:"kind",value:{choices:Bp,kind:"choice"}},{arity:"rest",name:"words",value:{kind:"text"}}],flags:[],name:"__complete",summary:"Print values for the completion scripts",updateNotice:!1});var jx=async(e)=>{let t=await e.profile(),r=await he(t.name);if(!te(r))return[];return(await vt({authUrl:t.profile.authUrl,token:r.token})).map((o)=>o.name)},Rx=async(e)=>{let{client:t,kind:r,words:n}=e;switch(r){case"projects":return await jx(t);case"profiles":{let o=await me();return Object.keys(o.profiles).toSorted()}case"openstack":return await Up(n);default:return r}},Yp=A(qp,async({args:e,client:t})=>{let r=await Rx({client:t,kind:e.kind,words:e.words});return t.stdout.write(r.map((n)=>`${n}
305
- `).join("")),0});var Xp=Z({args:[{arity:"one",name:"shell",value:{choices:Mp,kind:"choice"}}],description:"Prints the tab completion script for bash, zsh, fish or PowerShell. Load it from your shell's startup file.",examples:[{command:`echo 'eval "$(nipa completion zsh)"' >> ~/.zshrc`,description:"zsh"},{command:"nipa completion fish > ~/.config/fish/completions/nipa.fish",description:"fish"}],flags:[],name:"completion",summary:"Print the tab completion script for your shell",updateNotice:!1});var Qp=A(Xp,({args:e,client:t})=>(t.stdout.write(Hp({program:t.program,shell:e.shell})),Promise.resolve(0)));var Ss="List the databases in your project",ks=Z({aliases:["list"],args:[],flags:[ue],name:"ls",summary:Ss}),ed=Pe({aliases:["database","databases"],default:"ls",description:"Lists the database clusters in your project with their engine, status, address, flavor and age. These are Nipa Cloud's managed databases, which `nipa server ls` doesn't show.",examples:[{command:"nipa db ls",description:Ss},{command:"nipa db ls --json | jq -r '.databases[].name'",description:"Print each database's name"}],name:"db",subcommands:[ks],summary:Ss});var Zx=z({datastore_type:b(),datastore_version:b(),external_ip_address:b().nullish(),instance_status:b(),ip_address:b(),machine_type:z({name:b()}),operating_status:b(),volume_size:dp()}),Lx=z({created_at:b(),id:b(),name:b(),primary:Zx.nullish()}),Dx=z({database_clusters:fe(Lx)}),Nx=(e)=>({address:e.ip_address,engine:e.datastore_type,externalAddress:e.external_ip_address??null,flavor:e.machine_type.name,health:e.operating_status,status:e.instance_status,storageGb:e.volume_size,version:e.datastore_version}),Fx=(e)=>({createdAt:e.created_at,id:e.id,name:e.name,primary:e.primary?Nx(e.primary):null}),td=async(e)=>(await e.get("/v4/database/clusters?include_primary=true&include_machine_type=true",Dx)).database_clusters.map(Fx).toSorted((r,n)=>Date.parse(n.createdAt)-Date.parse(r.createdAt));var Ux=new Set(["ACTIVE","HEALTHY","ONLINE"]),Mx=new Set(["DEGRADED","ERROR","OFFLINE","UNKNOWN"]),Bx=new Set(["BUILD","HARD_REBOOT","MIGRATING","PASSWORD","REBOOT","REBUILD","RESCUE","RESIZE","REVERT_RESIZE","VERIFY_RESIZE"]),Gx=(e)=>{if(Ux.has(e))return $r;if(Mx.has(e))return Gi;if(Bx.has(e)||e.startsWith("PENDING_"))return Vi;return Ge},Vx=(e)=>{let t=e.toLowerCase().replaceAll("_"," ");return`${t.charAt(0).toUpperCase()}${t.slice(1)}`},Be=(e)=>{let t=Gx(e);return{paint:(r)=>`${t("●")}${r.slice(1)}`,text:`● ${Vx(e)}`}};var Wx=(e,t)=>{ke({headings:["Name","Engine","Status","Address","Flavor","Age"],rows:e.map(({createdAt:r,name:n,primary:o})=>[{text:n},{text:o?`${o.engine} ${o.version}`:"-"},o?Be(o.status):{text:"-"},{text:o?o.externalAddress??o.address:"-"},{text:o?.flavor??"-"},{paint:Ge,text:dt(t-Date.parse(r))}])})},rd=A(ks,async({client:e,flags:t})=>{let{active:r,session:n,space:o}=await e.cloud(),{project:s}=n,i=performance.now(),a=await V(`Loading the databases in ${s.name}…`,()=>td(o));if(t.json)return e.stdout.json({databases:a,profile:r.name,project:s}),0;let c=Y(`[${we(performance.now()-i)}]`);if(a.length===0)return R(`No databases in ${k(s.name)} ${c}`),0;if(R(`Databases in ${k(s.name)} ${c}`),Wx(a,Date.now()),!e.stdout.isTTY)e.stdout.line(a.map((u)=>u.id).join(`
306
- `));return 0});var nd=ze(ed,{ls:rd});var od=Z({args:[],description:'Prints the session\'s OS_* variables as shell commands. Load them with `eval "$(nipa env)"` in bash or zsh, or with `nipa env | source` in fish.',flags:[{description:"Shell syntax to print (default: from $SHELL)",long:"shell",value:{choices:hs,kind:"choice"}}],name:"env",summary:"Print the OS_* variables for your shell"});var sd=A(od,async({client:e,flags:t})=>{let r=t.shell??Ip(process.env.SHELL),{active:n,session:o}=await e.session();return e.stdout.line(Cp(fn({profile:n.profile,session:o}),r)),0});import{spawn as Kx}from"node:child_process";import{once as Jx}from"node:events";import{constants as id}from"node:os";var Hx=new Map([["openstack","Install it with `pipx install python-openstackclient`."],["terraform","Install it with `brew install hashicorp/tap/terraform`."]]),St=async({args:e,command:t,signIn:r})=>{let n=dn(t);if(!n)throw new O(`command not found: ${t}`,{exitCode:127,hint:Hx.get(t)});let{active:o,session:s}=await r(),i=Kx(n,e,{env:Ep(process.env,fn({profile:o.profile,session:s})),stdio:"inherit"}),a=!1,c=()=>{a=!0},u=()=>i.kill("SIGTERM");process.on("SIGINT",c),process.on("SIGTERM",u),await Jx(i,"exit"),process.off("SIGINT",c),process.off("SIGTERM",u);let{exitCode:l,signalCode:p}=i;if(p)return 128+id.signals[p];return a&&l===0?128+id.signals.SIGINT:l??1};var ad=mt({description:"Runs a command with the session's OS_* variables. nipa removes any OS_* variable already in your shell first, so a stale OS_PASSWORD from an old openrc can't override the token. nipa exits with the command's exit code.",examples:[{command:"nipa exec ansible-playbook site.yml",description:"Run an Ansible playbook"}],name:"exec",summary:"Run any command with the session",target:{kind:"command"}});var cd=ht(ad,({args:e,client:t,command:r})=>St({args:e,command:r,signIn:t.cloud}));var Ps="List the external IPs in your project",zs=Z({aliases:["list"],args:[],flags:[ue],name:"ls",summary:Ps}),ud=Pe({aliases:["ips"],default:"ls",description:"Lists the external IPs in your project with their status, the internal IP each one forwards to, zone and name. An IP without an internal IP isn't attached to anything.",examples:[{command:"nipa ip ls",description:Ps},{command:"nipa ip ls --json | jq -r '.ips[] | select(.internalAddress == null) | .address'",description:"Print the IPs that aren't attached"}],name:"ip",subcommands:[zs],summary:Ps});var qx=z({availability_zone:b(),external_ip_address:b(),id:b(),internal_ip_address:b().nullable(),name:b(),status:b()}),Yx=z({external_ips:fe(qx)}),Xx=(e)=>({address:e.external_ip_address,id:e.id,internalAddress:e.internal_ip_address,name:e.name,status:e.status,zone:e.availability_zone}),ld=async(e)=>(await e.get("/v4/external_ips",Yx)).external_ips.map(Xx);var Qx=(e)=>{ke({headings:["Address","Status","Internal IP","Zone","Name"],rows:e.map((t)=>[{text:t.address},Be(t.status),{text:t.internalAddress??"-"},{text:t.zone},{text:t.name}])})},pd=A(zs,async({client:e,flags:t})=>{let{active:r,session:n,space:o}=await e.cloud(),{project:s}=n,i=performance.now(),a=await V(`Loading the external IPs in ${s.name}…`,()=>ld(o));if(t.json)return e.stdout.json({ips:a,profile:r.name,project:s}),0;let c=Y(`[${we(performance.now()-i)}]`);if(a.length===0)return R(`No external IPs in ${k(s.name)} ${c}`),0;if(R(`External IPs in ${k(s.name)} ${c}`),Qx(a),!e.stdout.isTTY)e.stdout.line(a.map((u)=>u.address).join(`
307
- `));return 0});var dd=ze(ud,{ls:pd});var Es="List the load balancers in your project",Cs=Z({aliases:["list"],args:[],flags:[ue],name:"ls",summary:Es}),fd=Pe({aliases:["loadbalancer","loadbalancers"],default:"ls",description:"Lists the load balancers in your project with their status, health, virtual IP, listener count and age.",examples:[{command:"nipa lb ls",description:Es},{command:"nipa lb ls --json | jq -r '.loadBalancers[].address'",description:"Print each load balancer's virtual IP"}],name:"lb",subcommands:[Cs],summary:Es});var ey=z({created_at:b(),id:b(),listeners:fe(ss()),name:b(),operating_status:b(),provisioning_status:b(),vip_address:b()}),ty=z({loadbalancers:fe(ey)}),ry=(e)=>({address:e.vip_address,createdAt:e.created_at,health:e.operating_status,id:e.id,listeners:e.listeners.length,name:e.name,status:e.provisioning_status}),md=async(e)=>(await e.get("/v4/loadbalancers",ty)).loadbalancers.map(ry).toSorted((r,n)=>Date.parse(n.createdAt)-Date.parse(r.createdAt));var ny=(e,t)=>{ke({headings:["Name","Status","Health","Address","Listeners","Age"],rows:e.map((r)=>[{text:r.name},Be(r.status),Be(r.health),{text:r.address},{text:String(r.listeners)},{paint:Ge,text:dt(t-Date.parse(r.createdAt))}])})},hd=A(Cs,async({client:e,flags:t})=>{let{active:r,session:n,space:o}=await e.cloud(),{project:s}=n,i=performance.now(),a=await V(`Loading the load balancers in ${s.name}…`,()=>md(o));if(t.json)return e.stdout.json({loadBalancers:a,profile:r.name,project:s}),0;let c=Y(`[${we(performance.now()-i)}]`);if(a.length===0)return R(`No load balancers in ${k(s.name)} ${c}`),0;if(R(`Load balancers in ${k(s.name)} ${c}`),ny(a,Date.now()),!e.stdout.isTTY)e.stdout.line(a.map((u)=>u.id).join(`
308
- `));return 0});var gd=ze(fd,{ls:hd});class ct extends Error{status;constructor(e,t){super(e);this.name="ApiError",this.status=t}}var oy=z({message:b()}),sy=async(e)=>{try{let t=oy.safeParse(JSON.parse(await e.text()));return t.success?t.data.message:void 0}catch{return}},iy=async(e,t)=>{try{return t.safeParse(await e.json())}catch{return t.safeParse(null)}},xd=(e)=>{let t=e.url;while(t.endsWith("/"))t=t.slice(0,-1);return{get:async(r,n)=>{let o=await Me(`${t}${r}`,{headers:{Accept:"application/json","Project-Id":e.projectId,Region:e.region,"X-Auth-Token":e.token}});if(!o.ok){let i=await sy(o)??`the Space API returned HTTP ${o.status}`;throw new ct(i,o.status)}let s=await iy(o,n);if(!s.success)throw new ct(`unexpected Space API response: ${Gt(s.error)}`,o.status);return s.data}}};var yd=async(e)=>{let t=await me(),r=e.override??process.env.NIPA_PROFILE??t.currentProfile,n=t.profiles[r];if(!n){let o=Object.keys(t.profiles).join(", ");throw new O(`no profile named "${r}"`,{hint:`Your profiles: ${o}. Add one with \`nipa profile add ${r}\`.`})}return{config:t,name:r,profile:n}},vn=(e)=>e===ee?"nipa login":`nipa login -P ${e}`,_d=(e)=>{if(e.name!==ee){let t=Y(`(${new URL(e.profile.authUrl).host})`);R(`Using profile ${k(e.name)} ${t}`)}},ay=/^\d{6}$/u,bd=/^[\da-f]{32}$/u,cy=3,uy=(e)=>({email:(t)=>e.text({default:t,message:"Email",validate:(r)=>r.includes("@")||"Enter the email you log in to the portal with"}),otp:(t)=>e.text({message:t===1?"OTP code":"Next OTP code",validate:(r)=>ay.test(r)||"Enter the 6-digit code from your authenticator app"}),password:()=>e.secret("Password"),projectId:()=>e.text({message:"Project ID",validate:(t)=>bd.test(t)||"Enter the 32-character ID, as in OS_PROJECT_ID in your openrc file"})}),wd=(e)=>{let{projects:t,wanted:r}=e,n=t.find((o)=>o.id===r||o.name===r);if(!n)throw new O(`no project named or with ID "${r}"`,{hint:`Your projects: ${t.map((o)=>o.name).join(", ")}`});return n},vd=(e)=>{let{projects:t,wanted:r}=e;if(r)return Promise.resolve(wd({projects:t,wanted:r}));let[n,...o]=t;if(!n)throw new O("your account has no projects you can use");return o.length===0?Promise.resolve(n):e.ask(t)},wn=(e,t)=>({expiresAt:e.expiresAt,project:e.project??t,token:e.value,user:e.user}),$d=async(e)=>{let t=await e.ask(e.attempt);try{return await V("Checking the code…",()=>Sp({account:e.account,passcode:t,receipt:e.receipt}))}catch(r){if(!(r instanceof ae&&r.status===401)||e.attempt===cy)throw r;return R("That code didn't work. Each code works once, so wait for the next one."),$d({...e,attempt:e.attempt+1})}},ly=async(e)=>{let{profile:t,prompts:r,wantedProject:n}=e,o=e.username??await r.email(t.username),s=n!==void 0&&bd.test(n)?n:void 0,i=s??t.project?.id??await r.projectId(),a=await r.password(),c={authUrl:t.authUrl,projectId:i,userDomain:t.userDomain,username:o},u=await V("Checking your password…",()=>$p(c,a)),l=u.kind==="token"?u.token:await $d({account:c,ask:r.otp,attempt:1,receipt:u.receipt});if(!l.project)throw new ae(`Keystone returned a token without project ${i}`,0);let p=s?void 0:n;if(p===void 0||l.project.name===p)return wn(l,l.project);let d=await V("Loading your projects…",()=>vt({authUrl:t.authUrl,token:l.value})),f=wd({projects:d,wanted:p}),m=await V(`Switching to ${f.name}…`,()=>ln({authUrl:t.authUrl,projectId:f.id,token:l.value}));return wn(m,f)},Is=async(e)=>{let{active:t,session:r}=e,n={...t.profile,project:r.project,username:r.user.name};await qe({...t.config,profiles:{...t.config.profiles,[t.name]:n}}),await Np({profile:t.name,session:r})},Ts=async(e)=>{let{active:t,prompts:r}=e;if(!r.interactive)throw new O("`nipa login` needs a terminal to ask for your password",{hint:"Run it in a terminal, then run this command again."});let n=Y(`(${new URL(t.profile.authUrl).host})`);R(`Logging in to ${k(t.name)} ${n}`);let o=await ly({profile:t.profile,prompts:uy(r),username:e.username,wantedProject:e.wantedProject});await Is({active:t,session:o});let s=k(o.user.name);return le(`Logged in as ${s}, project ${k(o.project.name)}`),o},Sd=async(e)=>{let{active:t,prompts:r}=e,n=await he(t.name);if(te(n))return{active:t,session:n};let o=`Run \`${vn(t.name)}\`.`;if(!r.interactive)throw n?new O(`your ${t.name} session expired`,{hint:o}):new O(`you aren't logged in to ${t.name}`,{hint:o});return R(n?"Your session expired.":"You aren't logged in yet."),{active:t,session:await Ts({active:t,prompts:r})}},py=(e)=>async(t)=>{try{return await t()}catch(r){if((r instanceof ct||r instanceof ae?r.status:void 0)===401)throw new O(`your ${e} session expired or was revoked`,{hint:`Run \`${vn(e)}\`.`});throw r}},kd=(e)=>{let{active:t,session:r}=e,n=py(t.name),o=xd({projectId:r.project.id,region:t.profile.region,token:r.token,url:t.profile.spaceUrl});return{active:t,session:r,space:{get:(s,i)=>n(async()=>{try{return await o.get(s,i)}catch(a){if(a instanceof wt)throw new O(a.message,{hint:"Check your network connection, or the profile's Space API URL."});throw a}})}}};var Pd=Z({args:[],description:"Asks for your email and password, then for an OTP code when your account uses MFA. nipa saves a token for the current profile, scoped to a project, and reuses it until it expires.",examples:[{command:"nipa login",description:"Log in to the current profile"},{command:"nipa -P staging login",description:"Log in to the staging profile"}],flags:[{description:"Log in as this user instead of the last one",long:"username",short:"u",value:{kind:"text",name:"email"}},{description:"Use this project instead of the last one",long:"project",short:"p",value:{kind:"project"}}],name:"login",summary:"Log in with your password and an OTP code"});var zd=A(Pd,async({client:e,flags:t})=>(await Ts({active:await e.profile(),prompts:e.prompts,username:t.username,wantedProject:t.project}),0));var Ed=Z({args:[],description:"Revokes the current profile's token and deletes its session. nipa keeps your email and last project for the next login.",flags:[],name:"logout",summary:"Revoke the token and forget the session"});var Cd=A(Ed,async({client:e})=>{let t=await e.profile(),r=await he(t.name);if(!r)return ft(`Not logged in to ${t.name}, so \`nipa logout\` did nothing`),0;if(te(r))try{await V("Logging out…",()=>pn({authUrl:t.profile.authUrl,token:r.token}))}catch{}return await xn(t.name),le(`Logged out of ${k(t.name)}`),0});var Id=mt({aliases:["openstack"],description:"Runs `openstack <args...>` with the session. It's the same as `nipa exec openstack <args...>`.",examples:[{command:"nipa os volume list",description:"List the volumes in your project"}],name:"os",summary:"Run openstack with the session",target:{kind:"openstack"}});var Td=ht(Id,({args:e,client:t,command:r})=>St({args:e,command:r,signIn:t.cloud}));var Os=Z({args:[],flags:[ue],name:"ls",summary:"List your profiles and who is logged in to each"}),As=Z({args:[{arity:"optional",name:"name",value:{kind:"text"}}],flags:[{description:"Keystone URL, ending in /v3",long:"auth-url",value:{kind:"text",name:"url"}},{description:"User domain (default: nipacloud)",long:"user-domain",value:{kind:"text",name:"domain"}},{description:"Region (default: NCP-TH)",long:"region",value:{kind:"text",name:"region"}},{description:"Space API URL (default: https://space.nipa.cloud/api)",long:"space-url",value:{kind:"text",name:"url"}},{description:"Make it the current profile",long:"use",value:{kind:"none"}}],name:"add",summary:"Add a profile, asking for missing values"}),js=Z({args:[{arity:"optional",name:"name",value:{kind:"profile"}}],flags:[],name:"use",summary:"Make a profile the current one"}),Rs=Z({args:[{arity:"one",name:"name",value:{kind:"profile"}}],flags:[{...Gs,description:"Remove it without asking"}],name:"rm",summary:"Remove a profile and log out of it"}),Od=Pe({default:"ls",description:"A profile is a Keystone URL, user domain, region and Space API URL with its own session. nipa starts with prod, which is Nipa Cloud production. Add a profile for staging or any other Keystone, then use it with `nipa profile use <name>` or `-P <name>`.",examples:[{command:"nipa profile add staging --auth-url https://keystone.example.com/v3",description:"Add a staging profile"},{command:"nipa profile use staging",description:"Make staging the current profile"}],name:"profile",subcommands:[Os,As,js,Rs],summary:"Manage Keystone profiles, such as staging"});var dy=(e)=>(t)=>{if(!xs.test(t))return"Use lowercase letters, digits and hyphens, starting with a letter";return e.profiles[t]?`A profile named ${t} already exists`:!0},Ad=(e)=>He.shape.authUrl.safeParse(e).success||"Enter an http or https URL, such as https://keystone.example.com/v3",jd=(e)=>{if(e.value!==void 0)return Promise.resolve(e.value);if(!e.prompts.interactive)throw N(`missing ${e.flag}`,"Pass every value as a flag when there is no terminal.");return e.ask()},Rd=A(As,async({args:e,client:t,flags:r})=>{let{prompts:n}=t,o=await me(),s=dy(o),i=await jd({ask:()=>n.text({message:"Profile name",validate:s}),flag:"<name>",prompts:n,value:e.name}),a=s(i);if(a!==!0)throw N(`can't add profile "${i}"`,a);let c=await jd({ask:()=>n.text({message:"Keystone URL",validate:Ad}),flag:"--auth-url",prompts:n,value:r["auth-url"]}),u=Ad(c);if(u!==!0)throw N(`invalid --auth-url "${c}"`,u);let l=r["user-domain"]??(n.interactive?await n.text({default:ce.userDomain,message:"User domain"}):ce.userDomain),p=r.region??(n.interactive?await n.text({default:ce.region,message:"Region"}):ce.region),d=r["space-url"]??ce.spaceUrl;if(!He.shape.spaceUrl.safeParse(d).success)throw N(`invalid --space-url "${d}"`,"Enter an http or https URL, such as https://space.example.com/api");let f=performance.now(),m=await V(`Checking ${c}…`,()=>kp(c)),g={authUrl:c,region:p,spaceUrl:d,userDomain:l},x=r.use??(n.interactive&&await n.confirm({default:!0,message:`Use ${i} now?`}));return await qe({currentProfile:x?i:o.currentProfile,profiles:{...o.profiles,[i]:g}}),le(`Added profile ${k(i)} (Keystone ${m})`,performance.now()-f),R(x?`Now using ${k(i)}. Run \`nipa login\` to log in to it.`:`Run \`nipa login -P ${i}\` to log in to it.`),0});var Zd=A(Os,async({client:e,flags:t})=>{let r=await me(),n=Object.keys(r.profiles).toSorted(),o=await Promise.all(n.map((i)=>he(i)));if(t.json)return e.stdout.json(n.map((i,a)=>{let c=o[a];return{current:i===r.currentProfile,loggedIn:te(c),name:i,...r.profiles[i],user:te(c)?c.user.name:void 0}})),0;let s=n.map((i,a)=>{let c=r.profiles[i]??ce,u=o[a],l=te(u)?`${u.user.name} (${u.project.name})`:"-";return[i,new URL(c.authUrl).host,c.region,l].map((p)=>({text:p}))});return R(`${n.length} ${n.length===1?"profile":"profiles"}`),ke({headings:["Name","Keystone","Region","Logged in as"],marks:n.map((i)=>i===r.currentProfile?$r("✔"):" "),rows:s}),0});var Ld=A(Rs,async({args:e,client:t,flags:r})=>{let{name:n}=e,o=await me(),s=o.profiles[n];if(!s)throw new O(`no profile named "${n}"`);if(n===ee)throw new O(`can't remove ${ee}`,{hint:"nipa always has the Nipa Cloud production profile."});if(!r.yes){if(!t.prompts.interactive)throw N(`removing ${n} needs confirmation`,"Add --yes to remove it without asking.");if(!await t.prompts.confirm({default:!1,message:`Remove profile ${n} and log out of it?`}))throw new O("Canceled",{exitCode:130})}let i=await he(n);if(te(i))try{await pn({authUrl:s.authUrl,token:i.token})}catch{}await xn(n);let a=Object.fromEntries(Object.entries(o.profiles).filter(([u])=>u!==n)),c=o.currentProfile===n;if(await qe({currentProfile:c?ee:o.currentProfile,profiles:a}),le(`Removed profile ${k(n)}`),c)R(`Now using ${k(ee)}`);return 0});var Dd=A(js,async({args:e,client:t})=>{let r=await me(),n=Object.keys(r.profiles).toSorted(),{name:o}=e;if(o===void 0){if(!t.prompts.interactive)throw N("missing <name>",`Your profiles: ${n.join(", ")}`);o=await t.prompts.choice({choices:n.map((s)=>({name:s===r.currentProfile?`${s} ${k("(current)")}`:s,value:s})),default:r.currentProfile,message:"Use profile:"})}if(!r.profiles[o])throw new O(`no profile named "${o}"`,{hint:`Your profiles: ${n.join(", ")}`});if(o===r.currentProfile)return ft(`You're already using ${k(o)}`),0;return await qe({...r,currentProfile:o}),le(`Now using profile ${k(o)}`),0});var Nd=ze(Od,{add:Rd,ls:Zd,rm:Ld,use:Dd});var Zs="List the servers in your project",Ls=Z({aliases:["list"],args:[],flags:[ue],name:"ls",summary:Zs}),Fd=Pe({aliases:["servers"],default:"ls",description:"Lists the servers in your project with their status, address, flavor and age. nipa calls the Space API, the one the Nipa Cloud Space portal uses, so you don't need the OpenStack client.",examples:[{command:"nipa server ls",description:Zs},{command:"nipa server ls --json | jq -r '.servers[].name'",description:"Print each server's name"}],name:"server",subcommands:[Ls],summary:Zs});var Ud=z({address:b()}),fy=z({created:b(),external_ips:fe(Ud),flavor:z({name:b()}),id:b(),internal_ips:fe(Ud),name:b(),status:b()}),my=z({instances:fe(fy)}),Md=(e,t)=>({address:e.address,type:t,version:e.address.includes(":")?6:4}),hy=(e)=>({addresses:[...e.internal_ips.map((t)=>Md(t,"fixed")),...e.external_ips.map((t)=>Md(t,"floating"))],createdAt:e.created,flavor:e.flavor.name,id:e.id,name:e.name,status:e.status}),Bd=async(e)=>(await e.get("/v3/instances",my)).instances.map(hy);var Gd=(e)=>{let t=e.addresses.filter((n)=>n.version===4);return(t.find((n)=>n.type==="floating")??t[0]??e.addresses[0])?.address};var gy=(e,t)=>{ke({headings:["Name","Status","Address","Flavor","Age"],rows:e.map((r)=>[{text:r.name},Be(r.status),{text:Gd(r)??"-"},{text:r.flavor},{paint:Ge,text:dt(t-Date.parse(r.createdAt))}])})},Vd=A(Ls,async({client:e,flags:t})=>{let{active:r,session:n,space:o}=await e.cloud(),{project:s}=n,i=performance.now(),a=await V(`Loading the servers in ${s.name}…`,()=>Bd(o));if(t.json)return e.stdout.json({profile:r.name,project:s,servers:a}),0;let c=Y(`[${we(performance.now()-i)}]`);if(a.length===0)return R(`No servers in ${k(s.name)} ${c}`),0;if(R(`Servers in ${k(s.name)} ${c}`),gy(a,Date.now()),!e.stdout.isTTY)e.stdout.line(a.map((u)=>u.id).join(`
309
- `));return 0});var Ds=ze(Fd,{ls:Vd});var Wd=Z({args:[{arity:"optional",name:"project",value:{kind:"project"}}],description:"Scopes the session to another project, by name or ID, without a password or OTP code. Without a project, nipa lists your projects to pick from.",flags:[],name:"switch",summary:"Use another project"});var xy=(e,t)=>(r)=>e.choice({choices:r.map((n)=>({description:n.id,name:n.id===t.id?`${n.name} ${k("(current)")}`:n.name,value:n})),default:r.find((n)=>n.id===t.id),message:"Switch to:"}),Kd=A(Wd,async({args:e,client:t})=>{let{project:r}=e,{active:n,session:o}=await t.session(),{authUrl:s}=n.profile,i=await V("Loading your projects…",()=>vt({authUrl:s,token:o.token}));if(r===void 0&&!t.prompts.interactive)throw new O("tell nipa which project to use",{exitCode:2,hint:`Run \`nipa switch <project>\`. Your projects: ${i.map((l)=>l.name).join(", ")}`});let a=await vd({ask:xy(t.prompts,o.project),projects:i,wanted:r});if(a.id===o.project.id)return ft(`You're already using ${k(a.name)}`),0;let c=performance.now(),u=await V(`Switching to ${a.name}…`,()=>ln({authUrl:s,projectId:a.id,token:o.token}));return await Is({active:n,session:wn(u,a)}),le(`Switched to ${k(a.name)}`,performance.now()-c),0});var Jd=mt({aliases:["terraform"],description:"Runs `terraform <args...>` with the session. It's the same as `nipa exec terraform <args...>`.",examples:[{command:"nipa -P staging tf plan",description:"Plan against the staging profile"}],name:"tf",summary:"Run terraform with the session",target:{kind:"program",program:"terraform"}});var Hd=ht(Jd,({args:e,client:t,command:r})=>St({args:e,command:r,signIn:t.cloud}));var qd=Z({args:[],description:"Prints your user, profile, project and when the session expires. When the output goes to a pipe, nipa prints only your user name.",flags:[ue],name:"whoami",summary:"Show who you're logged in as"});var Yd=A(qd,async({client:e,flags:t})=>{let r=await e.profile(),n=await he(r.name);if(!te(n)){if(t.json)e.stdout.line(JSON.stringify({loggedIn:!1,profile:r.name}));throw new O(`you aren't logged in to ${r.name}`,{hint:`Run \`${vn(r.name)}\`.`})}if(t.json)return e.stdout.json({authUrl:r.profile.authUrl,expiresAt:n.expiresAt,loggedIn:!0,profile:r.name,project:n.project,region:r.profile.region,user:n.user}),0;if(!e.stdout.isTTY)return e.stdout.line(n.user.name),0;let{host:o}=new URL(r.profile.authUrl),s=Fi(vs(n));R(`Logged in as ${k(n.user.name)}`);let i=Y(`(${o}, ${r.profile.region})`),a=Y(`(${n.project.id})`);return R(`Profile: ${k(r.name)} ${i}`),R(`Project: ${k(n.project.name)} ${a}`),R(`The session expires in ${s}`),0});var Xd={examples:[{command:"nipa login",description:"Log in and pick a project"},{command:"nipa server ls",description:Ds.spec.summary},{command:"nipa os volume list",description:"Run any openstack command with the session"},{command:"nipa -P staging tf plan",description:"Run terraform against the staging profile"}],hidden:[Yp],sections:[{commands:[zd,Cd,Yd,Kd],title:"Session"},{commands:[Ds,nd,gd,dd],title:"Resources"},{commands:[Td,Hd,cd,sd],title:"Run tools"},{commands:[Nd,Qp],title:"Setup"}],summary:"Log in to Nipa Cloud once, then list your servers, databases, load balancers and external IPs, or run openstack and terraform with the session."};var Ns=(e)=>{let t;return()=>(t??=e(),t)},Qd=(e)=>{let{globals:t,program:r}=e;if(t.debug)process.env.NIPA_DEBUG="1";let n=Mi({stderr:process.stderr,stdin:process.stdin}),o=Ns(()=>yd({override:t.profile})),s=Ns(async()=>Sd({active:await o(),prompts:n}));return{cloud:Ns(async()=>{let a=await s();return _d(a.active),kd(a)}),profile:o,program:r,prompts:n,session:s,stdout:Bi(process.stdout)}};var cr=(e)=>({kind:"print",text:e}),ef=(e,t)=>({exitCode:e,kind:"ran",updateNotice:t.every((r)=>r.updateNotice!==!1)}),yy=(e)=>new Map([...e.sections.flatMap((t)=>t.commands),...e.hidden].flatMap((t)=>q(t.spec).map((r)=>[r,t]))),_y=(e)=>{let t=e.at(-1)??"",r=e.slice(0,-1);return r.length===0?t:`${r.join(", ")} or ${t}`},by=(e,t)=>N(`unknown subcommand "${e.spec.name} ${t}"`,`Use ${_y(e.spec.subcommands.map((r)=>r.name))}.`),wy=(e,t)=>{let{rest:r}=ao({unknown:"stop",words:t}),[n]=r;if(n===void 0||n.startsWith("-"))return{kind:"leaf",leaf:e.fallback,path:[e.spec],words:t};let o=e.subcommands.get(n);if(!o)return{group:e,kind:"unknown",word:n};return{kind:"leaf",leaf:o,path:[e.spec,o.spec],words:t.toSpliced(t.length-r.length,1)}},vy=(e,t)=>{let[r,n]=t,o=r===void 0?void 0:e.get(r);if(!o)return;let s=o.kind==="group"&&n!==void 0?o.subcommands.get(n):void 0;return o.kind==="group"&&s?[o.spec,s.spec]:[o.spec]},$y=(e,t)=>{let r=Array.from({length:t.length+1},(n,o)=>o);for(let n=1;n<=e.length;n+=1){let o=[n];for(let s=1;s<=t.length;s+=1){let i=e[n-1]===t[s-1]?0:1;o[s]=Math.min((r[s]??0)+1,(o[s-1]??0)+1,(r[s-1]??0)+i)}r=o}return r[t.length]??0},Sy=(e)=>{let[t]=e.program.sections.flatMap((n)=>n.commands).map((n)=>({name:n.name,score:$y(e.word,n.name)})).toSorted((n,o)=>n.score-o.score),r=t&&t.score<=2?`Did you mean \`nipa ${t.name}\`?`:"Run `nipa --help` to see the commands.";return new O(`unknown command "${e.word}"`,{exitCode:2,hint:r})},tf=async(e)=>{let t=ea(e.program),r=yy(e.program),n=ao({unknown:"reject",words:e.argv});if(n.globals.version)return cr(e.version);let[o,...s]=n.rest;if(o===void 0)return cr(jn({program:t,version:e.version}));if(o==="help"){let p=vy(r,s);return cr(p?fr(p):jn({program:t,version:e.version}))}let i=r.get(o);if(!i)throw Sy({program:t,word:o});if(i.kind==="passthrough"){if(n.globals.help)return cr(fr([i.spec]));let p=e.createClient({globals:n.globals,program:t});return ef(await i.run({client:p,words:s}),[i.spec])}let a=i.kind==="group"?wy(i,s):{kind:"leaf",leaf:i,path:[i.spec],words:s};if(n.globals.help||Yi(s))return cr(fr(a.kind==="leaf"?a.path:[i.spec]));if(a.kind==="unknown")throw by(a.group,a.word);let c=a.leaf.prepare({path:a.path,words:a.words}),u={...n.globals,...c.globals},l=e.createClient({globals:u,program:t});return ef(await c.run(l),a.path)};var $n=ut(Pt(),1);var rf="https://github.com/PunGrumpy/nipa/releases",ky="https://api.github.com/repos/PunGrumpy/nipa/releases/latest",Py=86400000,zy=z({checkedAt:an.datetime(),latest:b()}),nf="update.json",Ey=z({tag_name:b()}),of=(e)=>e.replace(/^v/u,"").split("-")[0]?.split(".").map(Number)??[],Cy=(e,t)=>{let r=of(e),n=of(t);for(let o=0;o<Math.max(r.length,n.length);o+=1){let s=(r[o]??0)-(n[o]??0);if(s!==0)return s>0}return!1},Iy=(e)=>e.isTTY&&e.version!=="0.0.0"&&!e.env.CI&&!e.env.NIPA_NO_UPDATE_CHECK,Ty=async()=>{try{let e=await Me(ky,{signal:AbortSignal.timeout(1500)}),t=Ey.safeParse(await e.json());return t.success?t.data.tag_name.replace(/^v/u,""):void 0}catch(e){cn(`update check failed: ${e instanceof Error?e.message:String(e)}`);return}},Oy=(e,t)=>{let r=`${rf}/tag/v${e}`,n=$n.default.dim(`v${t}`),o=$n.default.green(`v${e}`),s=[`Update available! ${n} ≫ ${o}`,`Release notes: ${$n.default.cyan(r)}`],i=[`Update available! v${t} ≫ v${e}`,`Release notes: ${rf}/tag/v${e}`],a=Math.max(...i.map((u)=>u.length)),c=(u,l)=>` │ ${u}${" ".repeat(a-l.length)} │`;return["",` ╭${"─".repeat(a+4)}╮`,...s.map((u,l)=>c(u,i[l]??u)),` ╰${"─".repeat(a+4)}╯`,""].join(`
310
- `)},sf=async(e)=>{if(!Iy({env:process.env,isTTY:process.stderr.isTTY===!0,version:e}))return;let t=await hn(nf,zy);if(t&&Cy(t.latest,e))oe(Oy(t.latest,e));if(t&&Date.now()-Date.parse(t.checkedAt)<Py)return;let r=await Ty();if(r){let n={checkedAt:new Date().toISOString(),latest:r};await gn(nf,n)}};var Ay="Run it again with --debug to see each request.",jy=(e)=>{if(e instanceof O)return e;if(e instanceof ae||e instanceof ct){let t=e.status===0||e.status>=500;return new O(e.message,{hint:t&&!us()?Ay:void 0})}if(e instanceof wt)return new O(e.message,{hint:"Check the Keystone URL with `nipa profile ls`, or your network connection."});if(e instanceof ir)return new O(e.message,{hint:"Fix the file, or delete it and run `nipa login` again."});return};try{let e=await tf({argv:process.argv.slice(2),createClient:Qd,program:Xd,version:zn.version});switch(e.kind){case"print":{console.log(e.text),process.exitCode=0;break}case"ran":{if(process.exitCode=e.exitCode,e.updateNotice)await sf(zn.version);break}default:throw Error(`unknown outcome ${String(e)}`)}}catch(e){let t=e instanceof Error?jy(e):void 0;if(!t)throw e;Ui(t),process.exitCode=t.exitCode}
304
+ `},kn=(e)=>{let{program:t,shell:r}=e;switch(r){case"bash":return Fx(t);case"zsh":return Wx(t);case"fish":return Yx(t);case"pwsh":return ty(t);default:return r}};var id=L({args:[{arity:"one",name:"kind",value:{choices:ed,kind:"choice"}},{arity:"rest",name:"words",value:{kind:"text"}}],flags:[],name:"__complete",summary:"Print values for the completion scripts",updateNotice:!1});var ry=async(e)=>{let t=await e.profile(),r=await he(t.name);if(!ne(r))return[];return(await zt({authUrl:t.profile.authUrl,token:r.token})).map((o)=>o.name)},ny=async(e)=>{let{client:t,kind:r,words:n}=e;switch(r){case"projects":return await ry(t);case"profiles":{let o=await fe();return Object.keys(o.profiles).toSorted()}case"openstack":return await Xp(n);default:return r}},ad=j(id,async({args:e,client:t})=>{let r=await ny({client:t,kind:e.kind,words:e.words});return t.stdout.write(r.map((n)=>`${n}
305
+ `).join("")),0});import{mkdir as oy,readFile as sy,writeFile as iy}from"node:fs/promises";import{homedir as ay}from"node:os";import et from"node:path";var cd=_p(["bash","zsh","fish"]),zn="completion.json",cy=z({path:b(),version:b()}),ud=Tg(cd,cy),ld=(e=process.env)=>{let t=et.basename(e.SHELL??"");switch(t){case"bash":case"zsh":case"fish":case"pwsh":return t;default:return}},fr=(e)=>e.HOME??ay(),uy=(e,t=process.env)=>{switch(e){case"zsh":return et.join(t.ZDOTDIR??fr(t),".zfunc","_nipa");case"bash":{let r=t.XDG_DATA_HOME??et.join(fr(t),".local","share");return et.join(r,"bash-completion","completions","nipa")}case"fish":{let r=t.XDG_CONFIG_HOME??et.join(fr(t),".config");return et.join(r,"fish","completions","nipa.fish")}default:return e}},pd=(e,t=process.env)=>{let r=fr(t);return e.startsWith(`${r}/`)?`~${e.slice(r.length)}`:e},dd=async(e=process.env)=>{let t=et.join(e.ZDOTDIR??fr(e),".zshrc");try{return(await sy(t,"utf-8")).includes(".zfunc")}catch{return!1}},md=async(e)=>{await oy(et.dirname(e.file),{recursive:!0}),await iy(e.file,kn({program:e.program,shell:e.shell}))},fd=async(e)=>{let t=uy(e.shell);await md({file:t,program:e.program,shell:e.shell});let r=await lt(zn,ud)??{};return await pt(zn,{...r,[e.shell]:{path:t,version:e.version}}),t},ly=async(e)=>{let t=await lt(zn,ud);if(!t)return;let r=cd.options.flatMap((o)=>{let s=t[o];return s&&s.version!==e.version?[{file:s.path,shell:o}]:[]});if(r.length===0)return;await Promise.all(r.map(({file:o,shell:s})=>md({file:o,program:e.program,shell:s})));let n=r.map(({file:o,shell:s})=>[s,{path:o,version:e.version}]);await pt(zn,{...t,...Object.fromEntries(n)})},hd=async(e)=>{try{await ly(e)}catch(t){Pt(`can't refresh the completion scripts: ${t instanceof Error?t.message:String(t)}`)}};var gd=L({args:[{arity:"optional",name:"shell",value:{choices:Qp,kind:"choice"}}],description:"Prints the tab completion script for bash, zsh, fish or PowerShell. Without a shell, nipa uses the one in $SHELL. Load the script from your shell's startup file, or save it with --install where the shell loads it, and nipa rewrites it when nipa updates.",examples:[{command:`echo 'eval "$(nipa completion zsh)"' >> ~/.zshrc`,description:"Load it each time zsh starts"},{command:"nipa completion --install",description:"Save it for the shell in $SHELL"}],flags:[{description:"Save it where the shell loads it, instead of printing it",long:"install",value:{kind:"none"}}],name:"completion",summary:"Print or install the tab completion script for your shell",updateNotice:!1});var xd=j(gd,async({args:e,client:t,flags:r})=>{let n=e.shell??ld();if(!n)throw Z("missing <shell>","Pass bash, zsh, fish or pwsh, such as `nipa completion zsh`.");if(!r.install)return t.stdout.write(kn({program:t.program,shell:n})),0;if(n==="pwsh")throw Z("can't install the completion for pwsh","PowerShell has no completion folder. Add `nipa completion pwsh | Out-String | Invoke-Expression` to your $PROFILE.");let o=await fd({program:t.program,shell:n,version:ft.version});if(Q(`Installed the ${n} completion in ${pd(o)}`),n==="zsh"&&!await dd())T("Add `fpath=(~/.zfunc $fpath)` to ~/.zshrc before `compinit`, then open a new terminal.");else if(n==="bash")T("Open a new terminal to use it. It needs the bash-completion package.");else T("Open a new terminal to use it.");return 0});var Ts="List the databases in your project",Os=L({aliases:["list"],args:[],flags:[le],name:"ls",summary:Ts}),yd=ze({aliases:["database","databases"],default:"ls",description:"Lists the database clusters in your project with their engine, status, address, flavor and age. These are Nipa Cloud's managed databases, which `nipa server ls` doesn't show.",examples:[{command:"nipa db ls",description:Ts},{command:"nipa db ls --json | jq -r '.databases[].name'",description:"Print each database's name"}],name:"db",subcommands:[Os],summary:Ts});var py=z({datastore_type:b(),datastore_version:b(),external_ip_address:b().nullish(),instance_status:b(),ip_address:b(),machine_type:z({name:b()}),operating_status:b(),volume_size:yp()}),dy=z({created_at:b(),id:b(),name:b(),primary:py.nullish()}),my=z({database_clusters:me(dy)}),fy=(e)=>({address:e.ip_address,engine:e.datastore_type,externalAddress:e.external_ip_address??null,flavor:e.machine_type.name,health:e.operating_status,status:e.instance_status,storageGb:e.volume_size,version:e.datastore_version}),hy=(e)=>({createdAt:e.created_at,id:e.id,name:e.name,primary:e.primary?fy(e.primary):null}),_d=async(e)=>(await e.get("/v4/database/clusters?include_primary=true&include_machine_type=true",my)).database_clusters.map(hy).toSorted((r,n)=>Date.parse(n.createdAt)-Date.parse(r.createdAt));var gy=new Set(["ACTIVE","HEALTHY","ONLINE"]),xy=new Set(["DEGRADED","ERROR","OFFLINE","UNKNOWN"]),yy=new Set(["BUILD","HARD_REBOOT","MIGRATING","PASSWORD","REBOOT","REBUILD","RESCUE","RESIZE","REVERT_RESIZE","VERIFY_RESIZE"]),_y=(e)=>{if(gy.has(e))return Ir;if(xy.has(e))return Xi;if(yy.has(e)||e.startsWith("PENDING_"))return Qi;return We},by=(e)=>{let t=e.toLowerCase().replaceAll("_"," ");return`${t.charAt(0).toUpperCase()}${t.slice(1)}`},Ge=(e)=>{let t=_y(e);return{paint:(r)=>`${t("●")}${r.slice(1)}`,text:`● ${by(e)}`}};var wy=(e,t)=>{ke({headings:["Name","Engine","Status","Address","Flavor","Age"],rows:e.map(({createdAt:r,name:n,primary:o})=>[{text:n},{text:o?`${o.engine} ${o.version}`:"-"},o?Ge(o.status):{text:"-"},{text:o?o.externalAddress??o.address:"-"},{text:o?.flavor??"-"},{paint:We,text:xt(t-Date.parse(r))}])})},bd=j(Os,async({client:e,flags:t})=>{let{active:r,session:n,space:o}=await e.cloud(),{project:s}=n,i=performance.now(),a=await G(`Loading the databases in ${s.name}…`,()=>_d(o));if(t.json)return e.stdout.json({databases:a,profile:r.name,project:s}),0;let c=H(`[${we(performance.now()-i)}]`);if(a.length===0)return T(`No databases in ${P(s.name)} ${c}`),0;if(T(`Databases in ${P(s.name)} ${c}`),wy(a,Date.now()),!e.stdout.isTTY)e.stdout.line(a.map((u)=>u.id).join(`
306
+ `));return 0});var wd=Ee(yd,{ls:bd});var vd=L({args:[],description:'Prints the session\'s OS_* variables as shell commands. Load them with `eval "$(nipa env)"` in bash or zsh, or with `nipa env | source` in fish.',flags:[{description:"Shell syntax to print (default: from $SHELL)",long:"shell",value:{choices:vs,kind:"choice"}}],name:"env",summary:"Print the OS_* variables for your shell"});var $d=j(vd,async({client:e,flags:t})=>{let r=t.shell??Zp(process.env.SHELL),{active:n,session:o}=await e.session();return e.stdout.line(Lp(bn({profile:n.profile,session:o}),r)),0});import{spawn as vy}from"node:child_process";import{once as $y}from"node:events";import{constants as Sd}from"node:os";var Sy=new Map([["openstack","Install it with `pipx install python-openstackclient`."],["terraform","Install it with `brew install hashicorp/tap/terraform`."]]),Ct=async({args:e,command:t,signIn:r})=>{let n=_n(t);if(!n)throw new E(`command not found: ${t}`,{exitCode:127,hint:Sy.get(t)});let{active:o,session:s}=await r(),i=vy(n,e,{env:Rp(process.env,bn({profile:o.profile,session:s})),stdio:"inherit"}),a=!1,c=()=>{a=!0},u=()=>i.kill("SIGTERM");process.on("SIGINT",c),process.on("SIGTERM",u),await $y(i,"exit"),process.off("SIGINT",c),process.off("SIGTERM",u);let{exitCode:l,signalCode:p}=i;if(p)return 128+Sd.signals[p];return a&&l===0?128+Sd.signals.SIGINT:l??1};var Pd=yt({description:"Runs a command with the session's OS_* variables. nipa removes any OS_* variable already in your shell first, so a stale OS_PASSWORD from an old openrc can't override the token. nipa exits with the command's exit code.",examples:[{command:"nipa exec ansible-playbook site.yml",description:"Run an Ansible playbook"}],name:"exec",summary:"Run any command with the session",target:{kind:"command"}});var kd=_t(Pd,({args:e,client:t,command:r})=>Ct({args:e,command:r,signIn:t.cloud}));var As="List the external IPs in your project",js=L({aliases:["list"],args:[],flags:[le],name:"ls",summary:As}),zd=ze({aliases:["ips"],default:"ls",description:"Lists the external IPs in your project with their status, the internal IP each one forwards to, zone and name. An IP without an internal IP isn't attached to anything.",examples:[{command:"nipa ip ls",description:As},{command:"nipa ip ls --json | jq -r '.ips[] | select(.internalAddress == null) | .address'",description:"Print the IPs that aren't attached"}],name:"ip",subcommands:[js],summary:As});var Py=z({availability_zone:b(),external_ip_address:b(),id:b(),internal_ip_address:b().nullable(),name:b(),status:b()}),ky=z({external_ips:me(Py)}),zy=(e)=>({address:e.external_ip_address,id:e.id,internalAddress:e.internal_ip_address,name:e.name,status:e.status,zone:e.availability_zone}),Ed=async(e)=>(await e.get("/v4/external_ips",ky)).external_ips.map(zy);var Ey=(e)=>{ke({headings:["Address","Status","Internal IP","Zone","Name"],rows:e.map((t)=>[{text:t.address},Ge(t.status),{text:t.internalAddress??"-"},{text:t.zone},{text:t.name}])})},Cd=j(js,async({client:e,flags:t})=>{let{active:r,session:n,space:o}=await e.cloud(),{project:s}=n,i=performance.now(),a=await G(`Loading the external IPs in ${s.name}…`,()=>Ed(o));if(t.json)return e.stdout.json({ips:a,profile:r.name,project:s}),0;let c=H(`[${we(performance.now()-i)}]`);if(a.length===0)return T(`No external IPs in ${P(s.name)} ${c}`),0;if(T(`External IPs in ${P(s.name)} ${c}`),Ey(a),!e.stdout.isTTY)e.stdout.line(a.map((u)=>u.address).join(`
307
+ `));return 0});var Id=Ee(zd,{ls:Cd});var Rs="List the load balancers in your project",Ls=L({aliases:["list"],args:[],flags:[le],name:"ls",summary:Rs}),Td=ze({aliases:["loadbalancer","loadbalancers"],default:"ls",description:"Lists the load balancers in your project with their status, health, virtual IP, listener count and age.",examples:[{command:"nipa lb ls",description:Rs},{command:"nipa lb ls --json | jq -r '.loadBalancers[].address'",description:"Print each load balancer's virtual IP"}],name:"lb",subcommands:[Ls],summary:Rs});var Cy=z({created_at:b(),id:b(),listeners:me(ps()),name:b(),operating_status:b(),provisioning_status:b(),vip_address:b()}),Iy=z({loadbalancers:me(Cy)}),Ty=(e)=>({address:e.vip_address,createdAt:e.created_at,health:e.operating_status,id:e.id,listeners:e.listeners.length,name:e.name,status:e.provisioning_status}),Od=async(e)=>(await e.get("/v4/loadbalancers",Iy)).loadbalancers.map(Ty).toSorted((r,n)=>Date.parse(n.createdAt)-Date.parse(r.createdAt));var Oy=(e,t)=>{ke({headings:["Name","Status","Health","Address","Listeners","Age"],rows:e.map((r)=>[{text:r.name},Ge(r.status),Ge(r.health),{text:r.address},{text:String(r.listeners)},{paint:We,text:xt(t-Date.parse(r.createdAt))}])})},Ad=j(Ls,async({client:e,flags:t})=>{let{active:r,session:n,space:o}=await e.cloud(),{project:s}=n,i=performance.now(),a=await G(`Loading the load balancers in ${s.name}…`,()=>Od(o));if(t.json)return e.stdout.json({loadBalancers:a,profile:r.name,project:s}),0;let c=H(`[${we(performance.now()-i)}]`);if(a.length===0)return T(`No load balancers in ${P(s.name)} ${c}`),0;if(T(`Load balancers in ${P(s.name)} ${c}`),Oy(a,Date.now()),!e.stdout.isTTY)e.stdout.line(a.map((u)=>u.id).join(`
308
+ `));return 0});var jd=Ee(Td,{ls:Ad});var Rd=async(e)=>{let t=await fe(),r=e.override??process.env.NIPA_PROFILE??t.currentProfile,n=t.profiles[r];if(!n){let o=Object.keys(t.profiles).join(", ");throw new E(`no profile named "${r}"`,{hint:`Your profiles: ${o}. Add one with \`nipa profile add ${r}\`.`})}return{config:t,name:r,profile:n}},Cn=(e)=>e===re?"nipa login":`nipa login -P ${e}`,Ld=(e)=>{if(e.name!==re){let t=H(`(${new URL(e.profile.authUrl).host})`);T(`Using profile ${P(e.name)} ${t}`)}},Ay=/^\d{6}$/u,Zd=/^[\da-f]{32}$/u,jy=3,Ry=(e)=>({email:(t)=>e.text({default:t,message:"Email",validate:(r)=>r.includes("@")||"Enter the email you log in to the portal with"}),otp:(t)=>e.text({message:t===1?"OTP code":"Next OTP code",validate:(r)=>Ay.test(r)||"Enter the 6-digit code from your authenticator app"}),password:()=>e.secret("Password"),projectId:()=>e.text({message:"Project ID",validate:(t)=>Zd.test(t)||"Enter the 32-character ID, as in OS_PROJECT_ID in your openrc file"})}),Dd=(e)=>{let{projects:t,wanted:r}=e,n=t.find((o)=>o.id===r||o.name===r);if(!n)throw new E(`no project named or with ID "${r}"`,{hint:`Your projects: ${t.map((o)=>o.name).join(", ")}`});return n},Nd=(e)=>{let{projects:t,wanted:r}=e;if(r)return Promise.resolve(Dd({projects:t,wanted:r}));let[n,...o]=t;if(!n)throw new E("your account has no projects you can use");return o.length===0?Promise.resolve(n):e.ask(t)},En=(e,t)=>({expiresAt:e.expiresAt,project:e.project??t,token:e.value,user:e.user}),Ud=async(e)=>{let t=await e.ask(e.attempt);try{return await G("Checking the code…",()=>Tp({account:e.account,passcode:t,receipt:e.receipt}))}catch(r){if(!(r instanceof ue&&r.status===401)||e.attempt===jy)throw r;return T("That code didn't work. Each code works once, so wait for the next one."),Ud({...e,attempt:e.attempt+1})}},Ly=async(e)=>{let{profile:t,prompts:r,wantedProject:n}=e,o=e.username??await r.email(t.username),s=n!==void 0&&Zd.test(n)?n:void 0,i=s??t.project?.id??await r.projectId(),a=await r.password(),c={authUrl:t.authUrl,projectId:i,userDomain:t.userDomain,username:o},u=await G("Checking your password…",()=>Ip(c,a)),l=u.kind==="token"?u.token:await Ud({account:c,ask:r.otp,attempt:1,receipt:u.receipt});if(!l.project)throw new ue(`Keystone returned a token without project ${i}`,0);let p=s?void 0:n;if(p===void 0||l.project.name===p)return En(l,l.project);let d=await G("Loading your projects…",()=>zt({authUrl:t.authUrl,token:l.value})),m=Dd({projects:d,wanted:p}),f=await G(`Switching to ${m.name}…`,()=>xn({authUrl:t.authUrl,projectId:m.id,token:l.value}));return En(f,m)},Zs=async(e)=>{let{active:t,session:r}=e,n={...t.profile,project:r.project,username:r.user.name};await Xe({...t.config,profiles:{...t.config.profiles,[t.name]:n}}),await qp({profile:t.name,session:r})},Ds=async(e)=>{let{active:t,prompts:r}=e;if(!r.interactive)throw new E("`nipa login` needs a terminal to ask for your password",{hint:"Run it in a terminal, then run this command again."});let n=H(`(${new URL(t.profile.authUrl).host})`);T(`Logging in to ${P(t.name)} ${n}`);let o=await Ly({profile:t.profile,prompts:Ry(r),username:e.username,wantedProject:e.wantedProject});await Zs({active:t,session:o});let s=P(o.user.name);return Q(`Logged in as ${s}, project ${P(o.project.name)}`),o},Fd=async(e)=>{let{active:t,prompts:r}=e,n=await he(t.name);if(ne(n))return{active:t,session:n};let o=`Run \`${Cn(t.name)}\`.`;if(!r.interactive)throw n?new E(`your ${t.name} session expired`,{hint:o}):new E(`you aren't logged in to ${t.name}`,{hint:o});return T(n?"Your session expired.":"You aren't logged in yet."),{active:t,session:await Ds({active:t,prompts:r})}},Zy=(e)=>async(t)=>{try{return await t()}catch(r){if((r instanceof Ye||r instanceof ue?r.status:void 0)===401)throw new E(`your ${e} session expired or was revoked`,{hint:`Run \`${Cn(e)}\`.`});throw r}},Md=(e)=>{let{spaceUrl:t}=e.profile;if(!t)throw new E(`the ${e.name} profile has no Space API URL`,{hint:`Remove it with \`nipa profile rm ${e.name}\`, then add it again with \`--space-url\` and its Space portal URL. \`nipa -P ${e.name} os server list\` works without one.`});return t},Bd=(e)=>{let{active:t,session:r}=e.signedIn,n=Zy(t.name),o=Fp({projectId:r.project.id,region:t.profile.region,token:r.token,url:e.spaceUrl});return{active:t,session:r,space:{get:(s,i)=>n(async()=>{try{return await o.get(s,i)}catch(a){if(a instanceof kt)throw new E(a.message,{hint:"Check your network connection, or the profile's Space API URL."});throw a}})}}};var Gd=L({args:[],description:"Asks for your email and password, then for an OTP code when your account uses MFA. nipa saves a token for the current profile, scoped to a project, and reuses it until it expires.",examples:[{command:"nipa login",description:"Log in to the current profile"},{command:"nipa -P staging login",description:"Log in to the staging profile"}],flags:[{description:"Log in as this user instead of the last one",long:"username",short:"u",value:{kind:"text",name:"email"}},{description:"Use this project instead of the last one",long:"project",short:"p",value:{kind:"project"}}],name:"login",summary:"Log in with your password and an OTP code"});var Vd=j(Gd,async({client:e,flags:t})=>(await Ds({active:await e.profile(),prompts:e.prompts,username:t.username,wantedProject:t.project}),0));var Wd=L({args:[],description:"Revokes the current profile's token and deletes its session. nipa keeps your email and last project for the next login.",flags:[],name:"logout",summary:"Revoke the token and forget the session"});var Kd=j(Wd,async({client:e})=>{let t=await e.profile(),r=await he(t.name);if(!r)return Ve(`Not logged in to ${t.name}, so \`nipa logout\` did nothing`),0;if(ne(r))try{await G("Logging out…",()=>yn({authUrl:t.profile.authUrl,token:r.token}))}catch{}return await vn(t.name),Q(`Logged out of ${P(t.name)}`),0});var Jd=yt({aliases:["openstack"],description:"Runs `openstack <args...>` with the session. It's the same as `nipa exec openstack <args...>`.",examples:[{command:"nipa os volume list",description:"List the volumes in your project"}],name:"os",summary:"Run openstack with the session",target:{kind:"openstack"}});var Hd=_t(Jd,({args:e,client:t,command:r})=>Ct({args:e,command:r,signIn:t.cloud}));var Ns=L({args:[],flags:[le],name:"ls",summary:"List your profiles and who is logged in to each"}),Us=L({args:[{arity:"optional",name:"name",value:{kind:"text"}}],flags:[{description:"Keystone URL, ending in /v3",long:"auth-url",value:{kind:"text",name:"url"}},{description:"User domain (default: nipacloud)",long:"user-domain",value:{kind:"text",name:"domain"}},{description:"Region (default: NCP-TH)",long:"region",value:{kind:"text",name:"region"}},{description:"Space portal URL, such as https://space.nipa.cloud (default: production's for production's Keystone)",long:"space-url",value:{kind:"text",name:"url"}},{description:"Make it the current profile",long:"use",value:{kind:"none"}}],name:"add",summary:"Add a profile, asking for missing values"}),Fs=L({args:[{arity:"optional",name:"name",value:{kind:"profile"}}],flags:[],name:"use",summary:"Make a profile the current one"}),Ms=L({args:[{arity:"one",name:"name",value:{kind:"profile"}}],flags:[{...Xs,description:"Remove it without asking"}],name:"rm",summary:"Remove a profile and log out of it"}),qd=ze({default:"ls",description:"A profile is a Keystone URL, user domain, region and Space API URL with its own session. nipa starts with prod, which is Nipa Cloud production. Add a profile for staging or any other Keystone, then use it with `nipa profile use <name>` or `-P <name>`.",examples:[{command:"nipa profile add staging --auth-url https://keystone.example.com/v3",description:"Add a staging profile"},{command:"nipa profile use staging",description:"Make staging the current profile"}],name:"profile",subcommands:[Ns,Us,Fs,Ms],summary:"Manage Keystone profiles, such as staging"});var Dy=(e)=>(t)=>{if(!Ss.test(t))return"Use lowercase letters, digits and hyphens, starting with a letter";return e.profiles[t]?`A profile named ${t} already exists`:!0},Yd=(e)=>Be.shape.authUrl.safeParse(e).success||"Enter an http or https URL, such as https://keystone.example.com/v3",Qd="Enter the http or https URL of the Space portal, such as https://space.nipa.cloud",Ny=async(e)=>{if(e.flag!==void 0)return e.flag;if(e.authUrl===q.authUrl)return q.spaceUrl;if(!e.prompts.interactive)return;let t=await e.prompts.text({message:"Space portal URL (Enter to skip)",required:!1,validate:(r)=>r===""||Be.shape.authUrl.safeParse(r).success||Qd});return t===""?void 0:t},Xd=(e)=>{if(e.value!==void 0)return Promise.resolve(e.value);if(!e.prompts.interactive)throw Z(`missing ${e.flag}`,"Pass every value as a flag when there is no terminal.");return e.ask()},em=j(Us,async({args:e,client:t,flags:r})=>{let{prompts:n}=t,o=await fe(),s=Dy(o),i=await Xd({ask:()=>n.text({message:"Profile name",validate:s}),flag:"<name>",prompts:n,value:e.name}),a=s(i);if(a!==!0)throw Z(`can't add profile "${i}"`,a);let c=await Xd({ask:()=>n.text({message:"Keystone URL",validate:Yd}),flag:"--auth-url",prompts:n,value:r["auth-url"]}),u=Yd(c);if(u!==!0)throw Z(`invalid --auth-url "${c}"`,u);let l=r["user-domain"]??(n.interactive?await n.text({default:q.userDomain,message:"User domain"}):q.userDomain),p=r.region??(n.interactive?await n.text({default:q.region,message:"Region"}):q.region),d=await Ny({authUrl:c,flag:r["space-url"],prompts:n});if(d!==void 0&&!Be.shape.authUrl.safeParse(d).success)throw Z(`invalid --space-url "${d}"`,Qd);let m=d===void 0?void 0:pr(d),f=performance.now(),g=await G(`Checking ${c}…`,()=>Op(c));if(m!==void 0)await G(`Checking ${m}…`,()=>Up(m));let x={authUrl:c,region:p,spaceUrl:m,userDomain:l},y=r.use??(n.interactive&&await n.confirm({default:!0,message:`Use ${i} now?`}));await Xe({currentProfile:y?i:o.currentProfile,profiles:{...o.profiles,[i]:x}});let w=m===void 0?"":`, Space API ${new URL(m).host}`;if(Q(`Added profile ${P(i)} (Keystone ${g}${w})`,performance.now()-f),m===void 0)Ve(`${i} has no Space API URL, so \`nipa server ls\` and the other resource commands don't work with it. Pass \`--space-url\` with its Space portal URL when you add it.`);return T(y?`Now using ${P(i)}. Run \`nipa login\` to log in to it.`:`Run \`nipa login -P ${i}\` to log in to it.`),0});var tm=j(Ns,async({client:e,flags:t})=>{let r=await fe(),n=Object.keys(r.profiles).toSorted(),o=await Promise.all(n.map((i)=>he(i)));if(t.json)return e.stdout.json(n.map((i,a)=>{let c=o[a];return{current:i===r.currentProfile,loggedIn:ne(c),name:i,...r.profiles[i],user:ne(c)?c.user.name:void 0}})),0;let s=n.map((i,a)=>{let c=r.profiles[i]??q,u=o[a],l=ne(u)?`${u.user.name} (${u.project.name})`:"-";return[i,new URL(c.authUrl).host,c.region,l].map((p)=>({text:p}))});return T(`${n.length} ${n.length===1?"profile":"profiles"}`),ke({headings:["Name","Keystone","Region","Logged in as"],marks:n.map((i)=>i===r.currentProfile?Ir("✔"):" "),rows:s}),0});var rm=j(Ms,async({args:e,client:t,flags:r})=>{let{name:n}=e,o=await fe(),s=o.profiles[n];if(!s)throw new E(`no profile named "${n}"`);if(n===re)throw new E(`can't remove ${re}`,{hint:"nipa always has the Nipa Cloud production profile."});if(!r.yes){if(!t.prompts.interactive)throw Z(`removing ${n} needs confirmation`,"Add --yes to remove it without asking.");if(!await t.prompts.confirm({default:!1,message:`Remove profile ${n} and log out of it?`}))throw new E("Canceled",{exitCode:130})}let i=await he(n);if(ne(i))try{await yn({authUrl:s.authUrl,token:i.token})}catch{}await vn(n);let a=Object.fromEntries(Object.entries(o.profiles).filter(([u])=>u!==n)),c=o.currentProfile===n;if(await Xe({currentProfile:c?re:o.currentProfile,profiles:a}),Q(`Removed profile ${P(n)}`),c)T(`Now using ${P(re)}`);return 0});var nm=j(Fs,async({args:e,client:t})=>{let r=await fe(),n=Object.keys(r.profiles).toSorted(),{name:o}=e;if(o===void 0){if(!t.prompts.interactive)throw Z("missing <name>",`Your profiles: ${n.join(", ")}`);o=await t.prompts.choice({choices:n.map((s)=>({name:s===r.currentProfile?`${s} ${P("(current)")}`:s,value:s})),default:r.currentProfile,message:"Use profile:"})}if(!r.profiles[o])throw new E(`no profile named "${o}"`,{hint:`Your profiles: ${n.join(", ")}`});if(o===r.currentProfile)return Ve(`You're already using ${P(o)}`),0;return await Xe({...r,currentProfile:o}),Q(`Now using profile ${P(o)}`),0});var om=Ee(qd,{add:em,ls:tm,rm,use:nm});var Bs="List the servers in your project",Gs=L({aliases:["list"],args:[],flags:[le],name:"ls",summary:Bs}),sm=ze({aliases:["servers"],default:"ls",description:"Lists the servers in your project with their status, address, flavor and age. nipa calls the Space API, the one the Nipa Cloud Space portal uses, so you don't need the OpenStack client.",examples:[{command:"nipa server ls",description:Bs},{command:"nipa server ls --json | jq -r '.servers[].name'",description:"Print each server's name"}],name:"server",subcommands:[Gs],summary:Bs});var im=z({address:b()}),Uy=z({magnum_cluster_id:b().optional(),magnum_role:b().optional()}),Fy=z({created:b(),external_ips:me(im),flavor:z({name:b()}),id:b(),internal_ips:me(im),metadata:Uy.optional(),name:b(),status:b()}),My=z({instances:me(Fy)}),am=(e,t)=>({address:e.address,type:t,version:e.address.includes(":")?6:4}),By=(e={})=>e.magnum_cluster_id===void 0?null:{clusterId:e.magnum_cluster_id,role:e.magnum_role??null},Gy=(e)=>({addresses:[...e.internal_ips.map((t)=>am(t,"fixed")),...e.external_ips.map((t)=>am(t,"floating"))],createdAt:e.created,flavor:e.flavor.name,id:e.id,kubernetes:By(e.metadata),name:e.name,status:e.status}),cm=async(e)=>(await e.get("/v3/instances",My)).instances.map(Gy);var um=(e)=>{let t=e.addresses.filter((n)=>n.version===4);return(t.find((n)=>n.type==="floating")??t[0]??e.addresses[0])?.address},lm=(e)=>{if(!e.kubernetes)return{text:e.name};let t=e.kubernetes.role??"node";return{paint:(r)=>`${e.name}${H(r.slice(e.name.length))}`,text:`${e.name} (Kubernetes ${t})`}};var Vy=(e,t)=>{ke({headings:["Name","Status","Address","Flavor","Age"],rows:e.map((r)=>[lm(r),Ge(r.status),{text:um(r)??"-"},{text:r.flavor},{paint:We,text:xt(t-Date.parse(r.createdAt))}])})},pm=j(Gs,async({client:e,flags:t})=>{let{active:r,session:n,space:o}=await e.cloud(),{project:s}=n,i=performance.now(),a=await G(`Loading the servers in ${s.name}…`,()=>cm(o));if(t.json)return e.stdout.json({profile:r.name,project:s,servers:a}),0;let c=H(`[${we(performance.now()-i)}]`);if(a.length===0)return T(`No servers in ${P(s.name)} ${c}`),0;if(T(`Servers in ${P(s.name)} ${c}`),Vy(a,Date.now()),!e.stdout.isTTY)e.stdout.line(a.map((u)=>u.id).join(`
309
+ `));return 0});var Vs=Ee(sm,{ls:pm});var dm=L({args:[{arity:"optional",name:"project",value:{kind:"project"}}],description:"Scopes the session to another project, by name or ID, without a password or OTP code. Without a project, nipa lists your projects to pick from.",flags:[],name:"switch",summary:"Use another project"});var Wy=(e,t)=>(r)=>e.choice({choices:r.map((n)=>({description:n.id,name:n.id===t.id?`${n.name} ${P("(current)")}`:n.name,value:n})),default:r.find((n)=>n.id===t.id),message:"Switch to:"}),mm=j(dm,async({args:e,client:t})=>{let{project:r}=e,{active:n,session:o}=await t.session(),{authUrl:s}=n.profile,i=await G("Loading your projects…",()=>zt({authUrl:s,token:o.token}));if(r===void 0&&!t.prompts.interactive)throw new E("tell nipa which project to use",{exitCode:2,hint:`Run \`nipa switch <project>\`. Your projects: ${i.map((l)=>l.name).join(", ")}`});let a=await Nd({ask:Wy(t.prompts,o.project),projects:i,wanted:r});if(a.id===o.project.id)return Ve(`You're already using ${P(a.name)}`),0;let c=performance.now(),u=await G(`Switching to ${a.name}…`,()=>xn({authUrl:s,projectId:a.id,token:o.token}));return await Zs({active:n,session:En(u,a)}),Q(`Switched to ${P(a.name)}`,performance.now()-c),0});var fm=yt({aliases:["terraform"],description:"Runs `terraform <args...>` with the session. It's the same as `nipa exec terraform <args...>`.",examples:[{command:"nipa -P staging tf plan",description:"Plan against the staging profile"}],name:"tf",summary:"Run terraform with the session",target:{kind:"program",program:"terraform"}});var hm=_t(fm,({args:e,client:t,command:r})=>Ct({args:e,command:r,signIn:t.cloud}));var gm=L({args:[],description:"Prints your user, profile, project and when the session expires. When the output goes to a pipe, nipa prints only your user name.",flags:[le],name:"whoami",summary:"Show who you're logged in as"});var xm=j(gm,async({client:e,flags:t})=>{let r=await e.profile(),n=await he(r.name);if(!ne(n)){if(t.json)e.stdout.line(JSON.stringify({loggedIn:!1,profile:r.name}));throw new E(`you aren't logged in to ${r.name}`,{hint:`Run \`${Cn(r.name)}\`.`})}if(t.json)return e.stdout.json({authUrl:r.profile.authUrl,expiresAt:n.expiresAt,loggedIn:!0,profile:r.name,project:n.project,region:r.profile.region,user:n.user}),0;if(!e.stdout.isTTY)return e.stdout.line(n.user.name),0;let{host:o}=new URL(r.profile.authUrl),s=Ji(Cs(n));T(`Logged in as ${P(n.user.name)}`);let i=H(`(${o}, ${r.profile.region})`),a=H(`(${n.project.id})`);return T(`Profile: ${P(r.name)} ${i}`),T(`Project: ${P(n.project.name)} ${a}`),T(`The session expires in ${s}`),0});var Ws={examples:[{command:"nipa login",description:"Log in and pick a project"},{command:"nipa server ls",description:Vs.spec.summary},{command:"nipa os volume list",description:"Run any openstack command with the session"},{command:"nipa -P staging tf plan",description:"Run terraform against the staging profile"}],hidden:[ad],sections:[{commands:[Vd,Kd,xm,mm],title:"Session"},{commands:[Vs,wd,jd,Id],title:"Resources"},{commands:[Hd,hm,kd,$d],title:"Run tools"},{commands:[om,xd],title:"Setup"}],summary:"Log in to Nipa Cloud once, then list your servers, databases, load balancers and external IPs, or run openstack and terraform with the session."};var Ks=(e)=>{let t;return()=>(t??=e(),t)},ym=(e)=>{let{globals:t,program:r}=e;if(t.debug)process.env.NIPA_DEBUG="1";let n=qi({stderr:process.stderr,stdin:process.stdin}),o=Ks(()=>Rd({override:t.profile})),s=Ks(async()=>Fd({active:await o(),prompts:n}));return{cloud:Ks(async()=>{let a=Md(await o()),c=await s();return Ld(c.active),Bd({signedIn:c,spaceUrl:a})}),profile:o,program:r,prompts:n,session:s,stdout:Yi(process.stdout)}};var hr=(e)=>({kind:"print",text:e}),_m=(e,t)=>({exitCode:e,kind:"ran",updateNotice:t.every((r)=>r.updateNotice!==!1)}),Ky=(e)=>new Map([...e.sections.flatMap((t)=>t.commands),...e.hidden].flatMap((t)=>X(t.spec).map((r)=>[r,t]))),Jy=(e)=>{let t=e.at(-1)??"",r=e.slice(0,-1);return r.length===0?t:`${r.join(", ")} or ${t}`},Hy=(e,t)=>Z(`unknown subcommand "${e.spec.name} ${t}"`,`Use ${Jy(e.spec.subcommands.map((r)=>r.name))}.`),qy=(e,t)=>{let{rest:r}=fo({unknown:"stop",words:t}),[n]=r;if(n===void 0||n.startsWith("-"))return{kind:"leaf",leaf:e.fallback,path:[e.spec],words:t};let o=e.subcommands.get(n);if(!o)return{group:e,kind:"unknown",word:n};return{kind:"leaf",leaf:o,path:[e.spec,o.spec],words:t.toSpliced(t.length-r.length,1)}},Yy=(e,t)=>{let[r,n]=t,o=r===void 0?void 0:e.get(r);if(!o)return;let s=o.kind==="group"&&n!==void 0?o.subcommands.get(n):void 0;return o.kind==="group"&&s?[o.spec,s.spec]:[o.spec]},Xy=(e,t)=>{let r=Array.from({length:t.length+1},(n,o)=>o);for(let n=1;n<=e.length;n+=1){let o=[n];for(let s=1;s<=t.length;s+=1){let i=e[n-1]===t[s-1]?0:1;o[s]=Math.min((r[s]??0)+1,(o[s-1]??0)+1,(r[s-1]??0)+i)}r=o}return r[t.length]??0},Qy=(e)=>{let[t]=e.program.sections.flatMap((n)=>n.commands).map((n)=>({name:n.name,score:Xy(e.word,n.name)})).toSorted((n,o)=>n.score-o.score),r=t&&t.score<=2?`Did you mean \`nipa ${t.name}\`?`:"Run `nipa --help` to see the commands.";return new E(`unknown command "${e.word}"`,{exitCode:2,hint:r})},bm=async(e)=>{let t=Tr(e.program),r=Ky(e.program),n=fo({unknown:"reject",words:e.argv});if(n.globals.version)return hr(e.version);let[o,...s]=n.rest;if(o===void 0)return hr(Un({program:t,version:e.version}));if(o==="help"){let p=Yy(r,s);return hr(p?br(p):Un({program:t,version:e.version}))}let i=r.get(o);if(!i)throw Qy({program:t,word:o});if(i.kind==="passthrough"){if(n.globals.help)return hr(br([i.spec]));let p=e.createClient({globals:n.globals,program:t});return _m(await i.run({client:p,words:s}),[i.spec])}let a=i.kind==="group"?qy(i,s):{kind:"leaf",leaf:i,path:[i.spec],words:s};if(n.globals.help||sa(s))return hr(br(a.kind==="leaf"?a.path:[i.spec]));if(a.kind==="unknown")throw Hy(a.group,a.word);let c=a.leaf.prepare({path:a.path,words:a.words}),u={...n.globals,...c.globals},l=e.createClient({globals:u,program:t});return _m(await c.run(l),a.path)};var In=mt(Tt(),1);var wm="https://github.com/PunGrumpy/nipa/releases",e_="https://api.github.com/repos/PunGrumpy/nipa/releases/latest",t_=86400000,r_=z({checkedAt:hn.datetime(),latest:b()}),vm="update.json",n_=z({tag_name:b()}),$m=(e)=>e.replace(/^v/u,"").split("-")[0]?.split(".").map(Number)??[],o_=(e,t)=>{let r=$m(e),n=$m(t);for(let o=0;o<Math.max(r.length,n.length);o+=1){let s=(r[o]??0)-(n[o]??0);if(s!==0)return s>0}return!1},s_=(e)=>e.isTTY&&e.version!=="0.0.0"&&!e.env.CI&&!e.env.NIPA_NO_UPDATE_CHECK,i_=async()=>{try{let e=await Oe(e_,{signal:AbortSignal.timeout(1500)}),t=n_.safeParse(await e.json());return t.success?t.data.tag_name.replace(/^v/u,""):void 0}catch(e){Pt(`update check failed: ${e instanceof Error?e.message:String(e)}`);return}},a_=(e,t)=>{let r=`${wm}/tag/v${e}`,n=In.default.dim(`v${t}`),o=In.default.green(`v${e}`),s=[`Update available! ${n} ≫ ${o}`,`Release notes: ${In.default.cyan(r)}`],i=[`Update available! v${t} ≫ v${e}`,`Release notes: ${wm}/tag/v${e}`],a=Math.max(...i.map((u)=>u.length)),c=(u,l)=>` │ ${u}${" ".repeat(a-l.length)} │`;return["",` ╭${"─".repeat(a+4)}╮`,...s.map((u,l)=>c(u,i[l]??u)),` ╰${"─".repeat(a+4)}╯`,""].join(`
310
+ `)},Sm=async(e)=>{if(!s_({env:process.env,isTTY:process.stderr.isTTY===!0,version:e}))return;let t=await lt(vm,r_);if(t&&o_(t.latest,e))ie(a_(t.latest,e));if(t&&Date.now()-Date.parse(t.checkedAt)<t_)return;let r=await i_();if(r){let n={checkedAt:new Date().toISOString(),latest:r};await pt(vm,n)}};var c_="Run it again with --debug to see each request.",u_=(e)=>{if(e instanceof E)return e;if(e instanceof ue||e instanceof Ye){let t=e.status===0||e.status>=500;return new E(e.message,{hint:t&&!gs()?c_:void 0})}if(e instanceof kt)return new E(e.message,{hint:"Check the Keystone URL with `nipa profile ls`, or your network connection."});if(e instanceof dr)return new E(e.message,{hint:"Fix the file, or delete it and run `nipa login` again."});return};try{let e=await bm({argv:process.argv.slice(2),createClient:ym,program:Ws,version:ft.version});switch(e.kind){case"print":{console.log(e.text),process.exitCode=0;break}case"ran":{if(process.exitCode=e.exitCode,e.updateNotice)await hd({program:Tr(Ws),version:ft.version}),await Sm(ft.version);break}default:throw Error(`unknown outcome ${String(e)}`)}}catch(e){let t=e instanceof Error?u_(e):void 0;if(!t)throw e;Hi(t),process.exitCode=t.exitCode}