nipa-cli 0.1.2 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/nipa.js +44 -44
- package/package.json +1 -1
package/dist/nipa.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{createRequire as qd}from"node:module";var Ud=Object.create;var{getPrototypeOf:Md,defineProperty:zn,getOwnPropertyNames:Bd}=Object;var Ns=Object.prototype.hasOwnProperty;function Vd(e){return this[e]}var Gd,Wd,nt=(e,t,r)=>{var n=e!=null&&typeof e==="object";if(n){var o=t?Gd??=new WeakMap:Wd??=new WeakMap,s=o.get(e);if(s)return s}r=e!=null?Ud(Md(e)):{};let i=t||!e||!e.__esModule||!Ns.call(e,"default")?zn(r,"default",{value:e,enumerable:!0}):r;if(e&&typeof e==="object"||typeof e==="function"){for(let a of Bd(e))if(!Ns.call(i,a))zn(i,a,{get:Vd.bind(e,a),enumerable:!0})}if(n)o.set(e,i);return i};var En=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var Kd=(e)=>e;function Jd(e,t){this[e]=Kd.bind(null,t)}var Hd=(e,t)=>{for(var r in t)zn(e,r,{get:t[r],enumerable:!0,configurable:!0,set:Jd.bind(t,r)})};var Fs=qd(import.meta.url);var Ft=En(function(ow,Eo){var Vr=process||{},nl=Vr.argv||[],Br=Vr.env||{},th=!(!!Br.NO_COLOR||nl.includes("--no-color"))&&(!!Br.FORCE_COLOR||nl.includes("--color")||Vr.platform==="win32"||(Vr.stdout||{}).isTTY&&Br.TERM!=="dumb"||!!Br.CI),rh=(e,t,r=e)=>(n)=>{let o=""+n,s=o.indexOf(t,e.length);return~s?e+nh(o,t,r,s)+t:e+o+t},nh=(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)},ol=(e=th)=>{let t=e?rh:()=>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")}};Eo.exports=ol();Eo.exports.createColors=ol});var hl=En(function(jw,ml){ml.exports=wh;function bh(e){let t={defaultWidth:0,output:process.stdout,tty:Fs("tty")};if(!e)return t;return Object.keys(t).forEach(function(r){if(!e[r])e[r]=t[r]}),e}function wh(e){let t=bh(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 Rl=En(function(qw,Al){var jh=Fs("stream");class Il extends jh{#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)}}Al.exports=Il});var Cn={name:"nipa-cli",version:"0.1.2",description:"Nipa Cloud from your terminal: log in with MFA once, then run openstack and terraform with the session.",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"},devDependencies:{"@inquirer/prompts":"^8.7.2","@types/bun":"^1.4.2",picocolors:"^1.1.1",typescript:"^6",zod:"^4.6.5"},engines:{node:">=22.13.0"}};function St(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 Tn(e,t="|"){return e.map((r)=>Rn(r)).join(t)}function kt(e,t){if(typeof t==="bigint")return t.toString();return t}class Us{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 Us(e)}function Ms(e){return e===null||e===void 0}function ir(e){let t=e.startsWith("^")?1:0,r=e.endsWith("$")?e.length-1:e.length;return e.slice(t,r)}function Bs(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 fe(e,t,r){Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0})}function ar(e){let t=Object.getOwnPropertyDescriptor(e,"shape");return t?.get?t.get.raw:t?.value}function Ee(e){return ar(e._zod.def)??e._zod.def.shape}function Vs(e,t,r){Object.defineProperty(e,t,{get(){let n=r();return fe(this,t,n),n},enumerable:!0,configurable:!0})}function Gs(e,t,r){if(t in e)fe(e,t,r);else e[t]=r}function Ve(e,t,r,n){let o=Ee(t);for(let s of r){let i=Object.getOwnPropertyDescriptor(o,s);if(!i.enumerable)continue;if(i.get)Vs(e,s,()=>{let a=t._zod.def.shape[s];return n?n(a,s):a});else Gs(e,s,n?n(i.value,s):i.value)}}function Xd(e,t){for(let r of Reflect.ownKeys(t)){let n=Object.getOwnPropertyDescriptor(t,r);if(!n.enumerable)continue;if(n.get)Vs(e,r,()=>t[r]);else Gs(e,r,n.value)}}function te(...e){let t={};for(let r of e){let n=Object.getOwnPropertyDescriptors(r);Object.assign(t,n)}return Object.defineProperties({},t)}function Ws(e){return JSON.stringify(e)}function Ks(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}var In="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function $t(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}var Js=sr(()=>{if(H.jitless)return!1;if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{return new Function(""),!0}catch(e){return!1}});function Ge(e){if($t(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($t(r)===!1)return!1;if(Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)return!1;return!0}function An(e){if(Ge(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 Hs=new Set(["string","number","symbol"]);function ot(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function me(e,t,r){let n=new e._zod.constr(t??e._zod.def);if(!t||r?.parent)n._zod.parent=e;return n}function w(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 Rn(e){if(typeof e==="bigint")return e.toString()+"n";if(typeof e==="string")return`"${e}"`;return`${e}`}function qs(e){return Object.keys(e).filter((t)=>e[t]._zod.optin!==void 0&&e[t]._zod.optout==="optional")}var cr=(()=>({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]}))(),Zn={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function Qd(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 Ve(s,e,ur(e,t)),me(e,te(r,{shape:s,checks:[]}))}function ur(e,t){let r=Ee(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 ef(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(ur(e,t)),i={};return Ve(i,e,Reflect.ownKeys(Ee(e)).filter((a)=>!s.has(a))),me(e,te(r,{shape:i,checks:[]}))}function tf(e,t){if(!Ge(t))throw Error("Invalid input to extend: expected a plain object");let r=e._zod.def.checks;if(r&&r.length>0){let o=Ee(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 me(e,te(e._zod.def,{shape:Ys(e,t)}))}function Ys(e,t){let r={};return Ve(r,e,Reflect.ownKeys(Ee(e))),Xd(r,t),r}function rf(e,t){if(!Ge(t))throw Error("Invalid input to safeExtend: expected a plain object");return me(e,te(e._zod.def,{shape:Ys(e,t)}))}function nf(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={};Ve(r,e,Reflect.ownKeys(Ee(e))),Ve(r,t,Reflect.ownKeys(Ee(t)));let n=te(e._zod.def,{shape:r,get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return me(e,n)}function Xs(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(ur(t,r)):void 0,c={};return Ve(c,t,Reflect.ownKeys(Ee(t)),e&&((u,l)=>a&&!a.has(l)?u:new e({type:"optional",innerType:u}))),me(t,te(t._zod.def,{shape:c,checks:[]}))}function of(e,t,r){let n=r?new Set(ur(t,r)):void 0,o={};return Ve(o,t,Reflect.ownKeys(Ee(t)),(s,i)=>n&&!n.has(i)?s:new e({type:"nonoptional",innerType:s})),me(t,te(t._zod.def,{shape:o}))}function we(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 Qs(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 De(e,t){return t.map((r)=>{var n;return(n=r).path??(n.path=[]),r.path.unshift(e),r})}function vt(e){return typeof e==="string"?e:e?.message}function jn(e,t,r){var n;for(let o=t;o<e.length;o++)(n=e[o]).schema??(n.schema=r)}function ve(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:vt(e.inst?._zod.def?.error?.(e))??vt(s?.(e))??vt(t?.error?.(e))??vt(r.customError?.(e))??vt(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 sf=/[\uD800-\uDBFF]/;function lr(e){let t=e.length;if(!sf.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 pr(e){if(Array.isArray(e))return"array";if(typeof e==="string")return"string";return"unknown"}function ei(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 We(...e){let[t,r,n]=e;if(typeof t==="string")return{message:t,code:"custom",input:r,inst:n};return{...t}}function ti(e,t){for(let r in t){let n=Object.getOwnPropertyDescriptor(t,r);if(n.get)Object.defineProperty(e,r,{...n,enumerable:!1});else af(e,r,n.value)}}function Ce(e,t,r,n=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:n,value:r}),r}function dr(e,t,r){return Ce(e,t,r,!1)}function ri(e,t){for(let r in e){let n=e[r];Object.defineProperty(t,r,{configurable:!0,enumerable:!0,get(){return Ce(this,r,n(this))},set(o){Ce(this,r,o)}})}return t}function af(e,t,r){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?r:Ce(this,t,r.bind(this))},set(n){Ce(this,t,n)}})}function cf(e,t){let r=Object.getPrototypeOf(e);return t in r?void 0:r}var On,Le=!1,uf={configurable:!0,get(){Le=!0;return}};function T(e,t,r){let n=Object.getPrototypeOf(e._zod);if(t in n&&On!==e._zod){On=void 0;return}On=e._zod,Object.defineProperty(n,t,{configurable:!0,get(){Object.defineProperty(this,t,uf);let o=Le;Le=!1;try{let s=r(this);if(Le)delete this[t];else Object.defineProperty(this,t,{configurable:!0,writable:!0,value:s});return Le=Le||o,s}catch(s){throw delete this[t],Le=Le||o,s}},set(o){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:o})}})}function lf(e,t,r,n){let o=cf(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 pf="~constantCatch";function ni(e){let t=()=>e;return t[pf]=!0,t}var oi;var Ln={value:void 0,enumerable:!1},si="captureStackTrace"in Error?Error:null;function df(e){let t=si;if(t){let r=t.stackTraceLimit;if(typeof r==="number"){try{t.stackTraceLimit=0}catch{return si=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){Ln.value=new s(f);try{Object.defineProperty(d,"_zod",Ln)}finally{Ln.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 b=_??g;if(!a.has(b))a.add(b),ti(b,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?df(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 $e extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class Pt extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`);this.name="ZodEncodeError"}}(oi=globalThis).__zod_globalConfig??(oi.__zod_globalConfig={});var H=globalThis.__zod_globalConfig;function q(e){if(e)Object.assign(H,e);return H}function ff(){let e=this._zod;return e.message??(e.message=JSON.stringify(e.def,kt,2)),e.message}function mf(e){this._zod.message=e}var hf={get:ff,set:mf,enumerable:!0,configurable:!0},Nn={value:void 0,enumerable:!1},ii=new WeakSet([Object.prototype,Error.prototype]),ai=(e,t)=>{e.name="$ZodError",Nn.value=t,Object.defineProperty(e,"issues",Nn),Nn.value=void 0,Object.defineProperty(e,"message",hf);let r=Object.getPrototypeOf(e);if(!ii.has(r))ii.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})}})},ci=h("$ZodError",ai),py=h("$ZodError",ai,void 0,{Parent:Error});function gf(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 Fn(e,t=(r)=>r.message){let r={},n=[];for(let o of e.issues)if(o.path.length>0)gf(r,o.path[0],()=>[]).push(t(o));else n.push(t(o));return{formErrors:n,fieldErrors:r}}function Un(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 xf(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 st(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 ${xf(n.path)}`);return t.join(`
|
|
3
|
-
`)}function fr(e,t){return{callee:t?.callee??e,Err:t?.Err}}var mr=(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 $e;if(a.issues.length){let c=new(s?.Err??e)(a.issues.map((u)=>ve(u,i,q())));throw In(c,s?.callee??t),c}return a.value};return t};var hr=(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)=>ve(u,i,q())));throw In(c,s?.callee??t),c}return a.value};return t};var gr=(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 $e;return s.issues.length?ui(e,s.issues,o):{success:!0,data:s.value}};function ui(e,t,r){let n;return{success:!1,get error(){if(!n)n=new e(t.map((o)=>ve(o,r,q()))),t=void 0,r=void 0;return n},set error(o){n=o,t=void 0,r=void 0}}}var xr=(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?ui(e,s.issues,o):{success:!0,data:s.value}};var yf=Symbol.for("zod.compile.invalid"),_f=Symbol.for("zod.compile.fallback"),Mn=(e,t,r)=>{let n=e._zod.bag.validator;if(n!==void 0){if(n(t)!==yf)return!0;if(n.definite===!0&&r===void 0)return!1}return bf(e,t,r)};function bf(e,t,r){let n=r?{...r,async:!1,abortEarly:!0}:{async:!1,abortEarly:!0},o=e._zod.bag.fallbackRun,s;if(o)n[_f]=!0,s=o({value:t,issues:[]},n);else s=e._zod.run({value:t,issues:[]},n);if(s instanceof Promise)throw new $e;return s.issues.length===0}var Bn=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},li=(e)=>{let t=mr(e),r=(n,o,s,i)=>{let a=s?{...s,direction:"backward"}:{direction:"backward"};return t(n,o,a,fr(r,i))};return r};var pi=(e)=>{let t=mr(e),r=(n,o,s,i)=>t(n,o,s,fr(r,i));return r};var di=(e)=>{let t=hr(e),r=async(n,o,s,i)=>{let a=s?{...s,direction:"backward"}:{direction:"backward"};return await t(n,o,a,fr(r,i))};return r};var fi=(e)=>{let t=hr(e),r=async(n,o,s,i)=>await t(n,o,s,fr(r,i));return r};var mi=(e)=>(t,r,n)=>{let o=n?{...n,direction:"backward"}:{direction:"backward"};return gr(e)(t,r,o)};var hi=(e)=>(t,r,n)=>gr(e)(t,r,n);var gi=(e)=>async(t,r,n)=>{let o=n?{...n,direction:"backward"}:{direction:"backward"};return xr(e)(t,r,o)};var xi=(e)=>async(t,r,n)=>xr(e)(t,r,n);var yi=/^[cC][0-9a-z]{6,}$/,_i=/^[0-9a-z]+$/,bi=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,wi=/^[0-9a-vA-V]{20}$/,vi=/^[A-Za-z0-9]{27}$/,$i=/^[a-zA-Z0-9_-]{21}$/;function Si(e){return new RegExp(`^[a-zA-Z0-9_-]{${e}}$`)}var ki=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;var Pi=/^([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})$/,Gn=(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 zi=/^(?:[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 wf="^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$";function Ei(){return new RegExp(wf,"u")}var Ci=/^(?:(?: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])$/,Oi=/^(([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 Ti=/^((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])$/,Ii=/^(([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])$/,Ai=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Ri=/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/;var Zi=/^https?$/,ji=/^\+[1-9]\d{6,14}$/;var Li="(?:(?:\\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 vf(e){return new RegExp(`^${e}$`)}var Di=vf(Li);function Vn(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 Ni(e){return new RegExp(`^${Vn(e)}$`)}function Fi(e){let t=["Z"];if(e.offset)t.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");let r=`${Vn({precision:e.precision,seconds:!0})}(?:${t.join("|")})`,n=e.local?`${r}|${Vn({precision:e.precision})}`:r;return new RegExp(`^${Li}T(?:${n})$`)}var Ui=/^[\s\S]{0,}$/;var Wn=/^-?\d+$/,zt=/^-?\d+(?:\.\d+)?$/,Mi=/^(?:true|false)$/i;var Bi=/^[^A-Z]*$/,Vi=/^[^a-z]*$/;var K=h("$ZodCheck",(e,t)=>{var r;e._zod??(e._zod={}),e._zod.def=t,(r=e._zod).onattach??(r.onattach=[])});var Kn=(e)=>{let t=e.value;return!Ms(t)&&t.length!==void 0},yr={number:"number",bigint:"bigint",object:"date"},Jn=h("$ZodCheckLessThan",(e,t)=>{K.init(e,t);let r=yr[typeof t.value];e._zod.check=(n)=>{if(t.inclusive?n.value<=t.value:n.value<t.value)return;n.issues.push({origin:yr[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})}}),Hn=h("$ZodCheckGreaterThan",(e,t)=>{K.init(e,t);let r=yr[typeof t.value];e._zod.check=(n)=>{if(t.inclusive?n.value>=t.value:n.value>t.value)return;n.issues.push({origin:yr[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})}}),Gi=h("$ZodCheckMultipleOf",(e,t)=>{K.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):Bs(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})}}),Wi=h("$ZodCheckNumberFormat",(e,t)=>{K.init(e,t),t.format=t.format||"float64";let r=t.format?.includes("int"),n=r?"int":"number",[o,s]=cr[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 Ki=h("$ZodCheckMaxLength",(e,t)=>{var r;K.init(e,t),(r=e._zod.def).when??(r.when=Kn),e._zod.check=(n)=>{let o=n.value,s=o.length;if((typeof o==="string"&&s>t.maximum?lr(o):s)<=t.maximum)return;let a=pr(o);n.issues.push({origin:a,code:"too_big",maximum:t.maximum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),Ji=h("$ZodCheckMinLength",(e,t)=>{var r;K.init(e,t),(r=e._zod.def).when??(r.when=Kn),e._zod.check=(n)=>{let o=n.value,s=o.length;if((typeof o==="string"&&s>=t.minimum&&s<t.minimum*2?lr(o):s)>=t.minimum)return;let a=pr(o);n.issues.push({origin:a,code:"too_small",minimum:t.minimum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),Hi=h("$ZodCheckLengthEquals",(e,t)=>{var r;K.init(e,t),(r=e._zod.def).when??(r.when=Kn),e._zod.check=(n)=>{let o=n.value,s=o.length,i=typeof o==="string"&&s>=t.length&&s<=t.length*2?lr(o):s;if(i===t.length)return;let a=pr(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})}}),Et=h("$ZodCheckStringFormat",(e,t)=>{var r,n;if(K.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=()=>{})}),qi=h("$ZodCheckRegex",(e,t)=>{Et.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})}}),Yi=h("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=Bi),Et.init(e,t)}),Xi=h("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=Vi),Et.init(e,t)}),Qi=h("$ZodCheckIncludes",(e,t)=>{K.init(e,t);let r=ot(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})}}),ea=h("$ZodCheckStartsWith",(e,t)=>{K.init(e,t);let r=new RegExp(`^${ot(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})}}),ta=h("$ZodCheckEndsWith",(e,t)=>{K.init(e,t);let r=new RegExp(`.*${ot(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 ra=h("$ZodCheckOverwrite",(e,t)=>{K.init(e,t),e._zod.check=(r)=>{r.value=t.tx(r.value)}});class qn{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(`
|
|
2
|
+
import{createRequire as Qd}from"node:module";var Vd=Object.create;var{getPrototypeOf:Gd,defineProperty:zn,getOwnPropertyNames:Wd}=Object;var Ds=Object.prototype.hasOwnProperty;function Kd(e){return this[e]}var Jd,Hd,nt=(e,t,r)=>{var n=e!=null&&typeof e==="object";if(n){var o=t?Jd??=new WeakMap:Hd??=new WeakMap,s=o.get(e);if(s)return s}r=e!=null?Vd(Gd(e)):{};let i=t||!e||!e.__esModule||!Ds.call(e,"default")?zn(r,"default",{value:e,enumerable:!0}):r;if(e&&typeof e==="object"||typeof e==="function"){for(let a of Wd(e))if(!Ds.call(i,a))zn(i,a,{get:Kd.bind(e,a),enumerable:!0})}if(n)o.set(e,i);return i};var En=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var qd=(e)=>e;function Yd(e,t){this[e]=qd.bind(null,t)}var Xd=(e,t)=>{for(var r in t)zn(e,r,{get:t[r],enumerable:!0,configurable:!0,set:Yd.bind(t,r)})};var Ns=Qd(import.meta.url);var Ft=En(function(iw,Eo){var Vr=process||{},rl=Vr.argv||[],Br=Vr.env||{},oh=!(!!Br.NO_COLOR||rl.includes("--no-color"))&&(!!Br.FORCE_COLOR||rl.includes("--color")||Vr.platform==="win32"||(Vr.stdout||{}).isTTY&&Br.TERM!=="dumb"||!!Br.CI),sh=(e,t,r=e)=>(n)=>{let o=""+n,s=o.indexOf(t,e.length);return~s?e+ih(o,t,r,s)+t:e+o+t},ih=(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)},nl=(e=oh)=>{let t=e?sh:()=>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")}};Eo.exports=nl();Eo.exports.createColors=nl});var ml=En(function(Dw,fl){fl.exports=Sh;function $h(e){let t={defaultWidth:0,output:process.stdout,tty:Ns("tty")};if(!e)return t;return Object.keys(t).forEach(function(r){if(!e[r])e[r]=t[r]}),e}function Sh(e){let t=$h(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 Al=En(function(Xw,Il){var Nh=Ns("stream");class Tl extends Nh{#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)}}Il.exports=Tl});var Cn={name:"nipa-cli",version:"0.1.3",description:"Nipa Cloud from your terminal: log in with MFA once, then run openstack and terraform with the session.",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"},devDependencies:{"@inquirer/prompts":"^8.7.2","@types/bun":"^1.4.2",picocolors:"^1.1.1",typescript:"^6",zod:"^4.6.5"},engines:{node:">=22.13.0"}};function St(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 Tn(e,t="|"){return e.map((r)=>Rn(r)).join(t)}function kt(e,t){if(typeof t==="bigint")return t.toString();return t}class Fs{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 Fs(e)}function Us(e){return e===null||e===void 0}function ir(e){let t=e.startsWith("^")?1:0,r=e.endsWith("$")?e.length-1:e.length;return e.slice(t,r)}function Ms(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 fe(e,t,r){Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0})}function ar(e){let t=Object.getOwnPropertyDescriptor(e,"shape");return t?.get?t.get.raw:t?.value}function Ee(e){return ar(e._zod.def)??e._zod.def.shape}function Bs(e,t,r){Object.defineProperty(e,t,{get(){let n=r();return fe(this,t,n),n},enumerable:!0,configurable:!0})}function Vs(e,t,r){if(t in e)fe(e,t,r);else e[t]=r}function Ve(e,t,r,n){let o=Ee(t);for(let s of r){let i=Object.getOwnPropertyDescriptor(o,s);if(!i.enumerable)continue;if(i.get)Bs(e,s,()=>{let a=t._zod.def.shape[s];return n?n(a,s):a});else Vs(e,s,n?n(i.value,s):i.value)}}function tf(e,t){for(let r of Reflect.ownKeys(t)){let n=Object.getOwnPropertyDescriptor(t,r);if(!n.enumerable)continue;if(n.get)Bs(e,r,()=>t[r]);else Vs(e,r,n.value)}}function re(...e){let t={};for(let r of e){let n=Object.getOwnPropertyDescriptors(r);Object.assign(t,n)}return Object.defineProperties({},t)}function Gs(e){return JSON.stringify(e)}function Ws(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}var In="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function $t(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}var Ks=sr(()=>{if(H.jitless)return!1;if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{return new Function(""),!0}catch(e){return!1}});function Ge(e){if($t(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($t(r)===!1)return!1;if(Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)return!1;return!0}function An(e){if(Ge(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 Js=new Set(["string","number","symbol"]);function ot(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function me(e,t,r){let n=new e._zod.constr(t??e._zod.def);if(!t||r?.parent)n._zod.parent=e;return n}function w(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 Rn(e){if(typeof e==="bigint")return e.toString()+"n";if(typeof e==="string")return`"${e}"`;return`${e}`}function Hs(e){return Object.keys(e).filter((t)=>e[t]._zod.optin!==void 0&&e[t]._zod.optout==="optional")}var cr=(()=>({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]}))(),Zn={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function rf(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 Ve(s,e,ur(e,t)),me(e,re(r,{shape:s,checks:[]}))}function ur(e,t){let r=Ee(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 nf(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(ur(e,t)),i={};return Ve(i,e,Reflect.ownKeys(Ee(e)).filter((a)=>!s.has(a))),me(e,re(r,{shape:i,checks:[]}))}function of(e,t){if(!Ge(t))throw Error("Invalid input to extend: expected a plain object");let r=e._zod.def.checks;if(r&&r.length>0){let o=Ee(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 me(e,re(e._zod.def,{shape:qs(e,t)}))}function qs(e,t){let r={};return Ve(r,e,Reflect.ownKeys(Ee(e))),tf(r,t),r}function sf(e,t){if(!Ge(t))throw Error("Invalid input to safeExtend: expected a plain object");return me(e,re(e._zod.def,{shape:qs(e,t)}))}function af(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={};Ve(r,e,Reflect.ownKeys(Ee(e))),Ve(r,t,Reflect.ownKeys(Ee(t)));let n=re(e._zod.def,{shape:r,get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return me(e,n)}function Ys(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(ur(t,r)):void 0,c={};return Ve(c,t,Reflect.ownKeys(Ee(t)),e&&((u,l)=>a&&!a.has(l)?u:new e({type:"optional",innerType:u}))),me(t,re(t._zod.def,{shape:c,checks:[]}))}function cf(e,t,r){let n=r?new Set(ur(t,r)):void 0,o={};return Ve(o,t,Reflect.ownKeys(Ee(t)),(s,i)=>n&&!n.has(i)?s:new e({type:"nonoptional",innerType:s})),me(t,re(t._zod.def,{shape:o}))}function we(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 Xs(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 De(e,t){return t.map((r)=>{var n;return(n=r).path??(n.path=[]),r.path.unshift(e),r})}function vt(e){return typeof e==="string"?e:e?.message}function jn(e,t,r){var n;for(let o=t;o<e.length;o++)(n=e[o]).schema??(n.schema=r)}function ve(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:vt(e.inst?._zod.def?.error?.(e))??vt(s?.(e))??vt(t?.error?.(e))??vt(r.customError?.(e))??vt(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 uf=/[\uD800-\uDBFF]/;function lr(e){let t=e.length;if(!uf.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 pr(e){if(Array.isArray(e))return"array";if(typeof e==="string")return"string";return"unknown"}function Qs(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 We(...e){let[t,r,n]=e;if(typeof t==="string")return{message:t,code:"custom",input:r,inst:n};return{...t}}function ei(e,t){for(let r in t){let n=Object.getOwnPropertyDescriptor(t,r);if(n.get)Object.defineProperty(e,r,{...n,enumerable:!1});else lf(e,r,n.value)}}function Ce(e,t,r,n=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:n,value:r}),r}function dr(e,t,r){return Ce(e,t,r,!1)}function ti(e,t){for(let r in e){let n=e[r];Object.defineProperty(t,r,{configurable:!0,enumerable:!0,get(){return Ce(this,r,n(this))},set(o){Ce(this,r,o)}})}return t}function lf(e,t,r){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?r:Ce(this,t,r.bind(this))},set(n){Ce(this,t,n)}})}function pf(e,t){let r=Object.getPrototypeOf(e);return t in r?void 0:r}var On,Le=!1,df={configurable:!0,get(){Le=!0;return}};function T(e,t,r){let n=Object.getPrototypeOf(e._zod);if(t in n&&On!==e._zod){On=void 0;return}On=e._zod,Object.defineProperty(n,t,{configurable:!0,get(){Object.defineProperty(this,t,df);let o=Le;Le=!1;try{let s=r(this);if(Le)delete this[t];else Object.defineProperty(this,t,{configurable:!0,writable:!0,value:s});return Le=Le||o,s}catch(s){throw delete this[t],Le=Le||o,s}},set(o){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:o})}})}function ff(e,t,r,n){let o=pf(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 mf="~constantCatch";function ri(e){let t=()=>e;return t[mf]=!0,t}var ni;var Ln={value:void 0,enumerable:!1},oi="captureStackTrace"in Error?Error:null;function hf(e){let t=oi;if(t){let r=t.stackTraceLimit;if(typeof r==="number"){try{t.stackTraceLimit=0}catch{return oi=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){Ln.value=new s(f);try{Object.defineProperty(d,"_zod",Ln)}finally{Ln.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 b=_??g;if(!a.has(b))a.add(b),ei(b,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?hf(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 $e extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class Pt extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`);this.name="ZodEncodeError"}}(ni=globalThis).__zod_globalConfig??(ni.__zod_globalConfig={});var H=globalThis.__zod_globalConfig;function q(e){if(e)Object.assign(H,e);return H}function gf(){let e=this._zod;return e.message??(e.message=JSON.stringify(e.def,kt,2)),e.message}function xf(e){this._zod.message=e}var yf={get:gf,set:xf,enumerable:!0,configurable:!0},Nn={value:void 0,enumerable:!1},si=new WeakSet([Object.prototype,Error.prototype]),ii=(e,t)=>{e.name="$ZodError",Nn.value=t,Object.defineProperty(e,"issues",Nn),Nn.value=void 0,Object.defineProperty(e,"message",yf);let r=Object.getPrototypeOf(e);if(!si.has(r))si.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})}})},ai=h("$ZodError",ii),fy=h("$ZodError",ii,void 0,{Parent:Error});function _f(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 Fn(e,t=(r)=>r.message){let r={},n=[];for(let o of e.issues)if(o.path.length>0)_f(r,o.path[0],()=>[]).push(t(o));else n.push(t(o));return{formErrors:n,fieldErrors:r}}function Un(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 bf(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 st(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 ${bf(n.path)}`);return t.join(`
|
|
3
|
+
`)}function fr(e,t){return{callee:t?.callee??e,Err:t?.Err}}var mr=(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 $e;if(a.issues.length){let c=new(s?.Err??e)(a.issues.map((u)=>ve(u,i,q())));throw In(c,s?.callee??t),c}return a.value};return t};var hr=(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)=>ve(u,i,q())));throw In(c,s?.callee??t),c}return a.value};return t};var gr=(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 $e;return s.issues.length?ci(e,s.issues,o):{success:!0,data:s.value}};function ci(e,t,r){let n;return{success:!1,get error(){if(!n)n=new e(t.map((o)=>ve(o,r,q()))),t=void 0,r=void 0;return n},set error(o){n=o,t=void 0,r=void 0}}}var xr=(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?ci(e,s.issues,o):{success:!0,data:s.value}};var wf=Symbol.for("zod.compile.invalid"),vf=Symbol.for("zod.compile.fallback"),Mn=(e,t,r)=>{let n=e._zod.bag.validator;if(n!==void 0){if(n(t)!==wf)return!0;if(n.definite===!0&&r===void 0)return!1}return $f(e,t,r)};function $f(e,t,r){let n=r?{...r,async:!1,abortEarly:!0}:{async:!1,abortEarly:!0},o=e._zod.bag.fallbackRun,s;if(o)n[vf]=!0,s=o({value:t,issues:[]},n);else s=e._zod.run({value:t,issues:[]},n);if(s instanceof Promise)throw new $e;return s.issues.length===0}var Bn=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},ui=(e)=>{let t=mr(e),r=(n,o,s,i)=>{let a=s?{...s,direction:"backward"}:{direction:"backward"};return t(n,o,a,fr(r,i))};return r};var li=(e)=>{let t=mr(e),r=(n,o,s,i)=>t(n,o,s,fr(r,i));return r};var pi=(e)=>{let t=hr(e),r=async(n,o,s,i)=>{let a=s?{...s,direction:"backward"}:{direction:"backward"};return await t(n,o,a,fr(r,i))};return r};var di=(e)=>{let t=hr(e),r=async(n,o,s,i)=>await t(n,o,s,fr(r,i));return r};var fi=(e)=>(t,r,n)=>{let o=n?{...n,direction:"backward"}:{direction:"backward"};return gr(e)(t,r,o)};var mi=(e)=>(t,r,n)=>gr(e)(t,r,n);var hi=(e)=>async(t,r,n)=>{let o=n?{...n,direction:"backward"}:{direction:"backward"};return xr(e)(t,r,o)};var gi=(e)=>async(t,r,n)=>xr(e)(t,r,n);var xi=/^[cC][0-9a-z]{6,}$/,yi=/^[0-9a-z]+$/,_i=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,bi=/^[0-9a-vA-V]{20}$/,wi=/^[A-Za-z0-9]{27}$/,vi=/^[a-zA-Z0-9_-]{21}$/;function $i(e){return new RegExp(`^[a-zA-Z0-9_-]{${e}}$`)}var Si=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;var ki=/^([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})$/,Gn=(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 Pi=/^(?:[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 Sf="^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$";function zi(){return new RegExp(Sf,"u")}var Ei=/^(?:(?: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])$/,Ci=/^(([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 Oi=/^((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])$/,Ti=/^(([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])$/,Ii=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Ai=/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/;var Ri=/^https?$/,Zi=/^\+[1-9]\d{6,14}$/;var ji="(?:(?:\\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 kf(e){return new RegExp(`^${e}$`)}var Li=kf(ji);function Vn(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 Di(e){return new RegExp(`^${Vn(e)}$`)}function Ni(e){let t=["Z"];if(e.offset)t.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");let r=`${Vn({precision:e.precision,seconds:!0})}(?:${t.join("|")})`,n=e.local?`${r}|${Vn({precision:e.precision})}`:r;return new RegExp(`^${ji}T(?:${n})$`)}var Fi=/^[\s\S]{0,}$/;var Wn=/^-?\d+$/,zt=/^-?\d+(?:\.\d+)?$/,Ui=/^(?:true|false)$/i;var Mi=/^[^A-Z]*$/,Bi=/^[^a-z]*$/;var K=h("$ZodCheck",(e,t)=>{var r;e._zod??(e._zod={}),e._zod.def=t,(r=e._zod).onattach??(r.onattach=[])});var Kn=(e)=>{let t=e.value;return!Us(t)&&t.length!==void 0},yr={number:"number",bigint:"bigint",object:"date"},Jn=h("$ZodCheckLessThan",(e,t)=>{K.init(e,t);let r=yr[typeof t.value];e._zod.check=(n)=>{if(t.inclusive?n.value<=t.value:n.value<t.value)return;n.issues.push({origin:yr[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})}}),Hn=h("$ZodCheckGreaterThan",(e,t)=>{K.init(e,t);let r=yr[typeof t.value];e._zod.check=(n)=>{if(t.inclusive?n.value>=t.value:n.value>t.value)return;n.issues.push({origin:yr[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})}}),Vi=h("$ZodCheckMultipleOf",(e,t)=>{K.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):Ms(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})}}),Gi=h("$ZodCheckNumberFormat",(e,t)=>{K.init(e,t),t.format=t.format||"float64";let r=t.format?.includes("int"),n=r?"int":"number",[o,s]=cr[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 Wi=h("$ZodCheckMaxLength",(e,t)=>{var r;K.init(e,t),(r=e._zod.def).when??(r.when=Kn),e._zod.check=(n)=>{let o=n.value,s=o.length;if((typeof o==="string"&&s>t.maximum?lr(o):s)<=t.maximum)return;let a=pr(o);n.issues.push({origin:a,code:"too_big",maximum:t.maximum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),Ki=h("$ZodCheckMinLength",(e,t)=>{var r;K.init(e,t),(r=e._zod.def).when??(r.when=Kn),e._zod.check=(n)=>{let o=n.value,s=o.length;if((typeof o==="string"&&s>=t.minimum&&s<t.minimum*2?lr(o):s)>=t.minimum)return;let a=pr(o);n.issues.push({origin:a,code:"too_small",minimum:t.minimum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),Ji=h("$ZodCheckLengthEquals",(e,t)=>{var r;K.init(e,t),(r=e._zod.def).when??(r.when=Kn),e._zod.check=(n)=>{let o=n.value,s=o.length,i=typeof o==="string"&&s>=t.length&&s<=t.length*2?lr(o):s;if(i===t.length)return;let a=pr(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})}}),Et=h("$ZodCheckStringFormat",(e,t)=>{var r,n;if(K.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=()=>{})}),Hi=h("$ZodCheckRegex",(e,t)=>{Et.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})}}),qi=h("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=Mi),Et.init(e,t)}),Yi=h("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=Bi),Et.init(e,t)}),Xi=h("$ZodCheckIncludes",(e,t)=>{K.init(e,t);let r=ot(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})}}),Qi=h("$ZodCheckStartsWith",(e,t)=>{K.init(e,t);let r=new RegExp(`^${ot(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})}}),ea=h("$ZodCheckEndsWith",(e,t)=>{K.init(e,t);let r=new RegExp(`.*${ot(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 ta=h("$ZodCheckOverwrite",(e,t)=>{K.init(e,t),e._zod.check=(r)=>{r.value=t.tx(r.value)}});class qn{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(`
|
|
4
4
|
`).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(", ")}) {
|
|
5
5
|
${t.join(`
|
|
6
6
|
`)}
|
|
7
|
-
};`)(...Object.values(this.closed))}}var oa={major:4,minor:6,patch:5};var j=h("$ZodType",(e,t)=>{var r;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=oa;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=we(a),p;for(let d of c){if(d._zod.def.when){if(Qs(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 $e;if(p||m instanceof Promise)p=(p??Promise.resolve()).then(async()=>{if(await m,a.issues.length===f)return;if(jn(a.issues,f,e),!l)l=we(a,f)});else{if(a.issues.length===f)continue;if(jn(a.issues,f,e),!l)l=we(a,f)}}if(p)return p.then(()=>a);return a},i=(a,c,u)=>{if(we(a))return a.aborted=!0,a;let l=s(c,o,u);if(l instanceof Promise){if(u.async===!1)throw new $e;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 $e;return u.then((l)=>s(l,o,c))}return s(u,o,c)}}},{get "~standard"(){return dr(this,"~standard",Xn(this))},set "~standard"(e){Ce(this,"~standard",e)}}),ha=(e,t)=>e.issues.length?{issues:e.issues.map((r)=>ve(r,t,q()))}:{value:e.value};async function $f(e,t){let r={async:!0};return ha(await e._zod.run({value:t,issues:[]},r),r)}function Xn(e){return{validate:(t)=>{let r={async:!1};try{let n=e._zod.run({value:t,issues:[]},r);if(!(n instanceof Promise))return ha(n,r)}catch(n){}return $f(e,t)},vendor:"zod",version:1}}var vr=h("$ZodString",(e,t)=>{j.init(e,t),e._zod.pattern=t.pattern??Ui,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}}),R=h("$ZodStringFormat",(e,t)=>{Et.init(e,t),vr.init(e,t)}),ga=h("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=Pi),R.init(e,t)}),xa=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=Gn(n))}else t.pattern??(t.pattern=Gn());R.init(e,t)}),ya=h("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=zi),R.init(e,t)}),_a=1,br=2;function ba(e){try{if(typeof URL<"u"&&typeof URL.canParse==="function")return URL.canParse(e);return new URL(e),!0}catch{return!1}}function Sf(e,t){if(!("normalize"in t)&&!("hostname"in t)&&!("protocol"in t))return ba(e)||br;return kf(e,t)}function kf(e,t){if(!t.normalize&&t.protocol?.source===Zi.source&&!/^https?:\/\//i.test(e))return _a;try{if(typeof URL<"u"){let r=URL;if(typeof r.parse==="function")return r.parse(e)??br}return new URL(e)}catch{return br}}var Pf=/[\t\n\r]/g;function sa(e){return e.replace(Pf,"")}function zf(e,t){return t.lastIndex=0,t.test(e.hostname)}function Ef(e,t){return t.lastIndex=0,t.test(e.protocol.endsWith(":")?e.protocol.slice(0,-1):e.protocol)}var wa=h("$ZodURL",(e,t)=>{R.init(e,t),e._zod.check=(r)=>{try{let n=r.value.trim(),o=Sf(n,t);if(o===_a){r.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:r.value,inst:e,continue:!t.abort});return}if(o===br){r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:e,continue:!t.abort});return}if(o===!0){r.value=sa(n);return}if(t.hostname&&!zf(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&&!Ef(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:sa(n);return}catch(n){r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:e,continue:!t.abort})}}}),va=h("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=Ei()),R.init(e,t)}),$a=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?$i:Si(t.length)),R.init(e,t)}),Sa=h("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=yi),R.init(e,t)}),ka=h("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=_i),R.init(e,t)}),Pa=h("$ZodULID",(e,t)=>{t.pattern??(t.pattern=bi),R.init(e,t)}),za=h("$ZodXID",(e,t)=>{t.pattern??(t.pattern=wi),R.init(e,t)}),Ea=h("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=vi),R.init(e,t)}),Ca=h("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=Fi(t)),R.init(e,t)}),Oa=h("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=Di),R.init(e,t)}),Ta=h("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=Ni(t)),R.init(e,t)}),Ia=h("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=ki),R.init(e,t)}),Aa=h("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=Ci),R.init(e,t)}),Cf=/^[0-9a-fA-F:.]+$/;function Ra(e){if(!Cf.test(e))return!1;return ba(`http://[${e}]`)}var Za=h("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=Oi),R.init(e,t),e._zod.check=(r)=>{if(!Ra(r.value))r.issues.push({code:"invalid_format",format:"ipv6",input:r.value,inst:e,continue:!t.abort})}});var ja=h("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=Ti),R.init(e,t)});function Of(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 Ra(r)}var La=h("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=Ii),R.init(e,t),e._zod.check=(r)=>{if(!Of(r.value))r.issues.push({code:"invalid_format",format:"cidrv6",input:r.value,inst:e,continue:!t.abort})}});function Da(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 Qn=/^[0-9a-zA-Z+/]*={0,2}$/,Na=h("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=Qn),R.init(e,t),e._zod.check=(r)=>{if(Da(r.value))return;r.issues.push({code:"invalid_format",format:"base64",input:r.value,inst:e,continue:!t.abort})}}),$r=/^[A-Za-z0-9_-]*$/;function Tf(e){if(!$r.test(e))return!1;let t=e.replace(/[-_]/g,(n)=>n==="-"?"+":"/"),r=t.padEnd(Math.ceil(t.length/4)*4,"=");return Da(r)}var Fa=h("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=$r),R.init(e,t),e._zod.check=(r)=>{if(Tf(r.value))return;r.issues.push({code:"invalid_format",format:"base64url",input:r.value,inst:e,continue:!t.abort})}}),Ua=h("$ZodE164",(e,t)=>{t.pattern??(t.pattern=ji),R.init(e,t)});function If(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 Ma=h("$ZodJWT",(e,t)=>{R.init(e,t),e._zod.check=(r)=>{if(If(r.value,t.alg))return;r.issues.push({code:"invalid_format",format:"jwt",input:r.value,inst:e,continue:!t.abort})}});var eo=h("$ZodNumber",(e,t)=>{j.init(e,t),e._zod.pattern=zt,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}}),Ba=h("$ZodNumberFormat",(e,t)=>{Wi.init(e,t),eo.init(e,t)}),Va=h("$ZodBoolean",(e,t)=>{j.init(e,t),e._zod.pattern=Mi,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 Ga=h("$ZodUnknown",(e,t)=>{j.init(e,t),e._zod.parse=(r)=>r}),Wa=h("$ZodNever",(e,t)=>{j.init(e,t),e._zod.parse=(r,n)=>(r.issues.push({expected:"never",code:"invalid_type",input:r.value,inst:e}),r)});function ia(e,t,r){if(e.issues.length)t.issues.push(...De(r,e.issues));t.value[r]=e.value}var Ka=h("$ZodArray",(e,t)=>{j.init(e,t);let r=H.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)=>ia(p,n,c)));else if(ia(l,n,c),a&&l.issues.length!==0&&we(l))break}if(i.length)return Promise.all(i).then(()=>n);return n}});function wr(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(...De(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 Af=[];function Ja(e){let t=Object.keys(e.shape),r=Object.getOwnPropertySymbols(e.shape),n=r.length?r:Af,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=qs(e.shape);return{...e,allKeys:o,symbolKeys:n,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(s)}}function Ha(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(we(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)=>wr(x,r,m,t,p,d)));else wr(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 Rf=h("$ZodObject",(e,t)=>{j.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(()=>Ja(t));T(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))fe(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=$t,i=t.catchall,a,c=H.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(we(u,g))break;g=u.issues.length}if(x==="__proto__")continue;let _=f[x],b=_._zod.optin,k=_._zod.optout,z=_._zod.run({value:p[x],issues:[]},l);if(z instanceof Promise)d.push(z.then((y)=>wr(y,u,x,p,b,k)));else wr(z,u,x,p,b,k)}if(!i)return d.length?Promise.all(d).then(()=>u):u;return Ha(d,p,u,l,o.value,e,m===!0)}}),qa=h("$ZodObjectJIT",(e,t)=>{Rf.init(e,t);let r=e._zod.parse,n=sr(()=>Ja(t)),o=H.memoizer,s=(f)=>{let m=n.value,g=m.symbolKeys,x=new qn(["payload","ctx"],{shape:f,inst:e,memo:o,syms:g}),_=(y)=>`shape[${y}]._zod.run({ value: input[${y}], issues: [] }, ctx)`,b=(y,S)=>`
|
|
7
|
+
};`)(...Object.values(this.closed))}}var na={major:4,minor:6,patch:5};var j=h("$ZodType",(e,t)=>{var r;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=na;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=we(a),p;for(let d of c){if(d._zod.def.when){if(Xs(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 $e;if(p||m instanceof Promise)p=(p??Promise.resolve()).then(async()=>{if(await m,a.issues.length===f)return;if(jn(a.issues,f,e),!l)l=we(a,f)});else{if(a.issues.length===f)continue;if(jn(a.issues,f,e),!l)l=we(a,f)}}if(p)return p.then(()=>a);return a},i=(a,c,u)=>{if(we(a))return a.aborted=!0,a;let l=s(c,o,u);if(l instanceof Promise){if(u.async===!1)throw new $e;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 $e;return u.then((l)=>s(l,o,c))}return s(u,o,c)}}},{get "~standard"(){return dr(this,"~standard",Xn(this))},set "~standard"(e){Ce(this,"~standard",e)}}),ma=(e,t)=>e.issues.length?{issues:e.issues.map((r)=>ve(r,t,q()))}:{value:e.value};async function Pf(e,t){let r={async:!0};return ma(await e._zod.run({value:t,issues:[]},r),r)}function Xn(e){return{validate:(t)=>{let r={async:!1};try{let n=e._zod.run({value:t,issues:[]},r);if(!(n instanceof Promise))return ma(n,r)}catch(n){}return Pf(e,t)},vendor:"zod",version:1}}var vr=h("$ZodString",(e,t)=>{j.init(e,t),e._zod.pattern=t.pattern??Fi,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}}),R=h("$ZodStringFormat",(e,t)=>{Et.init(e,t),vr.init(e,t)}),ha=h("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=ki),R.init(e,t)}),ga=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=Gn(n))}else t.pattern??(t.pattern=Gn());R.init(e,t)}),xa=h("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=Pi),R.init(e,t)}),ya=1,br=2;function _a(e){try{if(typeof URL<"u"&&typeof URL.canParse==="function")return URL.canParse(e);return new URL(e),!0}catch{return!1}}function zf(e,t){if(!("normalize"in t)&&!("hostname"in t)&&!("protocol"in t))return _a(e)||br;return Ef(e,t)}function Ef(e,t){if(!t.normalize&&t.protocol?.source===Ri.source&&!/^https?:\/\//i.test(e))return ya;try{if(typeof URL<"u"){let r=URL;if(typeof r.parse==="function")return r.parse(e)??br}return new URL(e)}catch{return br}}var Cf=/[\t\n\r]/g;function oa(e){return e.replace(Cf,"")}function Of(e,t){return t.lastIndex=0,t.test(e.hostname)}function Tf(e,t){return t.lastIndex=0,t.test(e.protocol.endsWith(":")?e.protocol.slice(0,-1):e.protocol)}var ba=h("$ZodURL",(e,t)=>{R.init(e,t),e._zod.check=(r)=>{try{let n=r.value.trim(),o=zf(n,t);if(o===ya){r.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:r.value,inst:e,continue:!t.abort});return}if(o===br){r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:e,continue:!t.abort});return}if(o===!0){r.value=oa(n);return}if(t.hostname&&!Of(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&&!Tf(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:oa(n);return}catch(n){r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:e,continue:!t.abort})}}}),wa=h("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=zi()),R.init(e,t)}),va=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?vi:$i(t.length)),R.init(e,t)}),$a=h("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=xi),R.init(e,t)}),Sa=h("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=yi),R.init(e,t)}),ka=h("$ZodULID",(e,t)=>{t.pattern??(t.pattern=_i),R.init(e,t)}),Pa=h("$ZodXID",(e,t)=>{t.pattern??(t.pattern=bi),R.init(e,t)}),za=h("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=wi),R.init(e,t)}),Ea=h("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=Ni(t)),R.init(e,t)}),Ca=h("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=Li),R.init(e,t)}),Oa=h("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=Di(t)),R.init(e,t)}),Ta=h("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=Si),R.init(e,t)}),Ia=h("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=Ei),R.init(e,t)}),If=/^[0-9a-fA-F:.]+$/;function Aa(e){if(!If.test(e))return!1;return _a(`http://[${e}]`)}var Ra=h("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=Ci),R.init(e,t),e._zod.check=(r)=>{if(!Aa(r.value))r.issues.push({code:"invalid_format",format:"ipv6",input:r.value,inst:e,continue:!t.abort})}});var Za=h("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=Oi),R.init(e,t)});function Af(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 Aa(r)}var ja=h("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=Ti),R.init(e,t),e._zod.check=(r)=>{if(!Af(r.value))r.issues.push({code:"invalid_format",format:"cidrv6",input:r.value,inst:e,continue:!t.abort})}});function La(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 Qn=/^[0-9a-zA-Z+/]*={0,2}$/,Da=h("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=Qn),R.init(e,t),e._zod.check=(r)=>{if(La(r.value))return;r.issues.push({code:"invalid_format",format:"base64",input:r.value,inst:e,continue:!t.abort})}}),$r=/^[A-Za-z0-9_-]*$/;function Rf(e){if(!$r.test(e))return!1;let t=e.replace(/[-_]/g,(n)=>n==="-"?"+":"/"),r=t.padEnd(Math.ceil(t.length/4)*4,"=");return La(r)}var Na=h("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=$r),R.init(e,t),e._zod.check=(r)=>{if(Rf(r.value))return;r.issues.push({code:"invalid_format",format:"base64url",input:r.value,inst:e,continue:!t.abort})}}),Fa=h("$ZodE164",(e,t)=>{t.pattern??(t.pattern=Zi),R.init(e,t)});function Zf(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 Ua=h("$ZodJWT",(e,t)=>{R.init(e,t),e._zod.check=(r)=>{if(Zf(r.value,t.alg))return;r.issues.push({code:"invalid_format",format:"jwt",input:r.value,inst:e,continue:!t.abort})}});var eo=h("$ZodNumber",(e,t)=>{j.init(e,t),e._zod.pattern=zt,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}}),Ma=h("$ZodNumberFormat",(e,t)=>{Gi.init(e,t),eo.init(e,t)}),Ba=h("$ZodBoolean",(e,t)=>{j.init(e,t),e._zod.pattern=Ui,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 Va=h("$ZodUnknown",(e,t)=>{j.init(e,t),e._zod.parse=(r)=>r}),Ga=h("$ZodNever",(e,t)=>{j.init(e,t),e._zod.parse=(r,n)=>(r.issues.push({expected:"never",code:"invalid_type",input:r.value,inst:e}),r)});function sa(e,t,r){if(e.issues.length)t.issues.push(...De(r,e.issues));t.value[r]=e.value}var Wa=h("$ZodArray",(e,t)=>{j.init(e,t);let r=H.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)=>sa(p,n,c)));else if(sa(l,n,c),a&&l.issues.length!==0&&we(l))break}if(i.length)return Promise.all(i).then(()=>n);return n}});function wr(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(...De(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 jf=[];function Ka(e){let t=Object.keys(e.shape),r=Object.getOwnPropertySymbols(e.shape),n=r.length?r:jf,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=Hs(e.shape);return{...e,allKeys:o,symbolKeys:n,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(s)}}function Ja(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(we(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)=>wr(x,r,m,t,p,d)));else wr(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 Lf=h("$ZodObject",(e,t)=>{j.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(()=>Ka(t));T(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))fe(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=$t,i=t.catchall,a,c=H.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(we(u,g))break;g=u.issues.length}if(x==="__proto__")continue;let _=f[x],b=_._zod.optin,k=_._zod.optout,z=_._zod.run({value:p[x],issues:[]},l);if(z instanceof Promise)d.push(z.then((y)=>wr(y,u,x,p,b,k)));else wr(z,u,x,p,b,k)}if(!i)return d.length?Promise.all(d).then(()=>u):u;return Ja(d,p,u,l,o.value,e,m===!0)}}),Ha=h("$ZodObjectJIT",(e,t)=>{Lf.init(e,t);let r=e._zod.parse,n=sr(()=>Ka(t)),o=H.memoizer,s=(f)=>{let m=n.value,g=m.symbolKeys,x=new qn(["payload","ctx"],{shape:f,inst:e,memo:o,syms:g}),_=(y)=>`shape[${y}]._zod.run({ value: input[${y}], issues: [] }, ctx)`,b=(y,S)=>`
|
|
8
8
|
let ${y}_ab = false;
|
|
9
9
|
for (let i = 0; i < ${y}.issues.length; i++) {
|
|
10
10
|
const iss = ${y}.issues[i];
|
|
@@ -15,7 +15,7 @@ ${t.join(`
|
|
|
15
15
|
if (${y}_ab && ctx && ctx.abortEarly) {
|
|
16
16
|
payload.value = newResult;
|
|
17
17
|
return payload;
|
|
18
|
-
}`;x.write("const input = payload.value;");let k=Object.create(null),z=0;for(let y of m.allKeys)k[y]=`key_${z++}`;x.write(o?"const newResult = memo.alloc(inst, payload, {}, ctx);":"const newResult = {};");for(let y of m.allKeys){if(y==="__proto__")continue;let S=k[y],E=typeof y==="symbol"?`syms[${g.indexOf(y)}]`:
|
|
18
|
+
}`;x.write("const input = payload.value;");let k=Object.create(null),z=0;for(let y of m.allKeys)k[y]=`key_${z++}`;x.write(o?"const newResult = memo.alloc(inst, payload, {}, ctx);":"const newResult = {};");for(let y of m.allKeys){if(y==="__proto__")continue;let S=k[y],E=typeof y==="symbol"?`syms[${g.indexOf(y)}]`:Gs(y),G=`${E} in input`,P=f[y],C=P?._zod?.optin,U=C!==void 0,W=P?._zod?.optout==="optional";if(x.write(`const ${S} = ${_(E)};`),U&&W){let de=C==="optional"?`${S}_present`:`${S}.value !== undefined || ${S}_present`;x.write(`
|
|
19
19
|
const ${S}_present = ${G};
|
|
20
20
|
if (!${S}.issues.length || ${S}_present) {
|
|
21
21
|
if (${S}.issues.length) {${b(S,E)}
|
|
@@ -54,46 +54,46 @@ ${t.join(`
|
|
|
54
54
|
if (${S}.value !== undefined || ${G}) {
|
|
55
55
|
newResult[${E}] = ${S}.value;
|
|
56
56
|
}
|
|
57
|
-
`)}return x.write("payload.value = newResult;"),x.write("return payload;"),x.compile()},i,a=$t,c=!H.jitless,l=c&&Js.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 Ha([],g,f,m,d,e,m?.abortEarly===!0)}return r(f,m)}});function aa(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)=>!we(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)=>ve(i,n,q())))}),t}var Ya=h("$ZodUnion",(e,t)=>{j.init(e,t),T(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),T(e,"optout",(n)=>n.def.options.some((o)=>o._zod.optout==="optional")?"optional":void 0),T(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}),T(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)=>ir(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 aa(i,n,e,o);return Promise.all(i).then((a)=>aa(a,n,e,o))}});var Xa=h("$ZodIntersection",(e,t)=>{j.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])=>ca(r,c,u));return ca(r,s,i)}});function Yn(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(Ge(e)&&Ge(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=Yn(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=Yn(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 ca(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=Yn(t.value,r.value);if(!c.valid){if(we(e))return e;throw Error(`Unmergable intersection. Error path: ${JSON.stringify(c.mergeErrorPath)}`)}return e.value=c.data,e}var Qa=h("$ZodRecord",(e,t)=>{j.init(e,t);let r=H.memoizer;r?.attach(e),e._zod.parse=(n,o)=>{let s=n.value;if(!Ge(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)=>ve(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(...De(l,m.issues));n.value[d]=m.value}));else{if(f.issues.length)n.issues.push(...De(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"&&zt.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)=>ve(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(...De(u,m.issues));n.value[d]=m.value}));else{if(f.issues.length)n.issues.push(...De(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 ec=h("$ZodEnum",(e,t)=>{j.init(e,t);let r=St(t.entries),n=new Set(r);e._zod.values=n,T(e,"pattern",(o)=>{let s=St(o.def.entries).filter((i)=>Hs.has(typeof i));return new RegExp(s.length?`^(${s.map((i)=>ot(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 tc=h("$ZodTransform",(e,t)=>{j.init(e,t),e._zod.optin="optional",H.memoizer?.guard(e),e._zod.parse=(r,n)=>{if(n.direction==="backward")throw new Pt(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 $e;return r.value=o,r}});function ua(e,t){return e.value=t.issues.length?void 0:t.value,e}var to=h("$ZodOptional",(e,t)=>{j.init(e,t),T(e,"optin",(r)=>r.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),e._zod.optout="optional",T(e,"values",(r)=>{let n=r.def.innerType._zod.values;return n?new Set([...n,void 0]):void 0}),T(e,"pattern",(r)=>{let n=r.def.innerType._zod.pattern;return n?new RegExp(`^(${ir(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)=>ua(r,s));return ua(r,o)}return t.innerType._zod.run(r,n)}}),rc=h("$ZodExactOptional",(e,t)=>{to.init(e,t),T(e,"values",(r)=>r.def.innerType._zod.values),T(e,"pattern",(r)=>r.def.innerType._zod.pattern),e._zod.parse=(r,n)=>t.innerType._zod.run(r,n)}),nc=h("$ZodNullable",(e,t)=>{j.init(e,t),T(e,"optin",(r)=>r.def.innerType._zod.optin),T(e,"optout",(r)=>r.def.innerType._zod.optout),T(e,"pattern",(r)=>{let n=r.def.innerType._zod.pattern;return n?new RegExp(`^(${ir(n.source)}|null)$`):void 0}),T(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)}}),oc=h("$ZodDefault",(e,t)=>{j.init(e,t),e._zod.optin="defaulted",T(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)=>la(s,t));return la(o,t)}});function la(e,t){if(e.value===void 0)e.value=t.defaultValue;return e}var sc=h("$ZodPrefault",(e,t)=>{j.init(e,t),e._zod.optin="defaulted",T(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)}}),ic=h("$ZodNonOptional",(e,t)=>{j.init(e,t),T(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)=>pa(s,e));return pa(o,e)}});function pa(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 da(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)=>ve(o,n,q()))},input:e.value}),e}var ac=h("$ZodCatch",(e,t)=>{j.init(e,t),T(e,"optin",(r)=>r.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),T(e,"optout",(r)=>r.def.innerType._zod.optout),T(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)=>da(r,s,t,n));return da(r,o,t,n)}});var cc=h("$ZodPipe",(e,t)=>{j.init(e,t),T(e,"values",(r)=>r.def.in._zod.values),T(e,"optin",(r)=>r.def.in._zod.optin),T(e,"optout",(r)=>r.def.out._zod.optout),T(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)=>_r(i,t.in,n));return _r(s,t.in,n)}let o=t.in._zod.run(r,n);if(o instanceof Promise)return o.then((s)=>_r(s,t.out,n));return _r(o,t.out,n)}});function _r(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 uc=h("$ZodReadonly",(e,t)=>{j.init(e,t),T(e,"propValues",(r)=>r.def.innerType._zod.propValues),T(e,"values",(r)=>r.def.innerType._zod.values),T(e,"optin",(r)=>r.def.innerType?._zod?.optin),T(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(fa);return fa(o)}});function fa(e){if(!e.memo)e.value=Object.freeze(e.value);return e}var lc=h("$ZodCustom",(e,t)=>{K.init(e,t),j.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)=>ma(s,r,n,e));ma(o,r,n,e);return}});function ma(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(We(o))}}class dc extends Error{constructor(){super("Cannot parse a reference cycle that closes through a transform");this.name="ZodCyclicError"}}var no="~memo",pc=[];function fc(e){return e!==null&&typeof e==="object"}function ro(e){return e.map((t)=>t.path?{...t,path:t.path.slice()}:{...t})}var mc=new WeakMap,Ct=0,Pr=1,Ot=2;function zr(e,t,r){let n=mc.get(e);if(n!==void 0)return n?Ot:Ct;if(t.has(e))return Ot;t.add(e);let o=Ct,s=(l)=>{if(o!==Ot&&l?._zod){let p=zr(l,t,r);if(p>o)o=p}},i=(l,p)=>{let d=Ct;for(let f of Reflect.ownKeys(l)){let m=Object.getOwnPropertyDescriptor(l,f);if(p&&!m.enumerable)continue;let g=m.get?Pr:m.value?._zod?zr(m.value,t,r):Ct;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=ar(c);a(l?i(l,!0):Pr),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?zr(l,t,!1):Pr);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),Zf(e,o)}function Zf(e,t){if(t!==Pr)mc.set(e,t===Ot);return t}function jf(e,t){let r=e.buckets.get(t);if(!r)r=new WeakMap,e.buckets.set(t,r);return r}var Sr,kr=[],Lf={alloc(e,t,r){let n=Sr;if(!n)return r;Sr=void 0;let o={value:r,issues:null};return n.set(t.value,o),kr.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"&&Df(s,o.value))throw new dc;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 _=zr(e,new Set,!1);if(_===Ct){if(e._zod.parse=i,e._zod.run===a)e._zod.run=i;return i(c,u)}if(_===Ot||n)r=!0;else n=!0}let l=c.value;if(!fc(l))return i(c,u);let p=u[no];if(!p)p={buckets:new WeakMap,backEdges:void 0},u[no]=p;let d;if(o===u)d=s;else d=jf(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}Sr=d;let m=kr.length,g=i(c,u);Sr=void 0;let x=kr.length>m?kr.pop():void 0;if(g instanceof Promise)return g.then((_)=>{if(x)x.issues=_.issues.length?ro(_.issues):pc;return _});if(x)x.issues=g.issues.length?ro(g.issues):pc;return g};if(e._zod.parse=a,e._zod.run===i)e._zod.run=a})}};function oo(){return Lf}function Df(e,t){let r=e[no]?.backEdges;return r!==void 0&&fc(t)&&r.has(t)}var Nf=()=>{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=ei(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 ${Rn(s.values[0])}`;return`Invalid option: expected one of ${Tn(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":""}: ${Tn(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 so(){return{localeError:Nf()}}var hc;class gc{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 xc(){return new gc}(hc=globalThis).__zod_globalRegistry??(hc.__zod_globalRegistry=xc());var Ne=globalThis.__zod_globalRegistry;function yc(e){if(e.checks)e.checks=[...e.checks];return e}function _c(e,t){return new e(yc({type:"string",...w(t)}))}function bc(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...w(t)})}function wc(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...w(t)})}function vc(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...w(t)})}function $c(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...w(t)})}function Sc(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...w(t)})}function kc(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...w(t)})}function io(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...w(t)})}function Pc(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...w(t)})}function zc(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...w(t)})}function Ec(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...w(t)})}function Cc(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...w(t)})}function Oc(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...w(t)})}function Tc(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...w(t)})}function Ic(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...w(t)})}function Ac(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...w(t)})}function Rc(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...w(t)})}function Zc(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...w(t)})}function jc(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...w(t)})}function Lc(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...w(t)})}function Dc(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...w(t)})}function Nc(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...w(t)})}function Fc(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...w(t)})}function Er(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...w(t)})}function Cr(e,t){return new e({type:"string",format:"date",check:"string_format",...w(t)})}function Or(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...w(t)})}function Tr(e,t){return new e({type:"string",format:"duration",check:"string_format",...w(t)})}function Uc(e,t){return new e(yc({type:"number",checks:[],...w(t)}))}function Mc(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...w(t)})}function Bc(e,t){return new e({type:"boolean",...w(t)})}function Vc(e){return new e({type:"unknown"})}function Gc(e,t){return new e({type:"never",...w(t)})}function Ir(e,t){return new Jn({check:"less_than",...w(t),value:e,inclusive:!1})}function Tt(e,t){return new Jn({check:"less_than",...w(t),value:e,inclusive:!0})}function Ar(e,t){return new Hn({check:"greater_than",...w(t),value:e,inclusive:!1})}function It(e,t){return new Hn({check:"greater_than",...w(t),value:e,inclusive:!0})}function Rr(e,t){return new Gi({check:"multiple_of",...w(t),value:e})}function Zr(e,t){return new Ki({check:"max_length",...w(t),maximum:e})}function at(e,t){return new Ji({check:"min_length",...w(t),minimum:e})}function jr(e,t){return new Hi({check:"length_equals",...w(t),length:e})}function ao(e,t){return new qi({check:"string_format",format:"regex",...w(t),pattern:e})}function co(e){return new Yi({check:"string_format",format:"lowercase",...w(e)})}function uo(e){return new Xi({check:"string_format",format:"uppercase",...w(e)})}function lo(e,t){return new Qi({check:"string_format",format:"includes",...w(t),includes:e})}function po(e,t){return new ea({check:"string_format",format:"starts_with",...w(t),prefix:e})}function fo(e,t){return new ta({check:"string_format",format:"ends_with",...w(t),suffix:e})}function Fe(e){return new ra({check:"overwrite",tx:e})}function mo(e){return Fe((t)=>t.normalize(e))}function ho(){return Fe((e)=>e.trim())}function go(){return Fe((e)=>e.toLowerCase())}function xo(){return Fe((e)=>e.toUpperCase())}function yo(){return Fe((e)=>Ks(e))}function Wc(e,t,r){return new e({type:"array",element:t,...w(r)})}function Kc(e,t,r){return new e({type:"custom",check:"custom",fn:t,...w(r)})}function Jc(e,t){let r=Ff((n)=>(n.addIssue=(o)=>{if(typeof o==="string")n.issues.push(We(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(We(s))}},e(n.value,n)),t);return r}function Ff(e,t){let r=new K({check:"custom",...w(t)});return r._zod.check=e,r}function At(e,...t){for(let r of t)for(let n of Reflect.ownKeys(r))if(Object.prototype.propertyIsEnumerable.call(r,n))fe(e,n,r[n]);return e}function bo(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??Ne,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 Ke(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 M(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;M(p,t,l),t.seen.get(p).isParent=!0}}let c=t.metadataRegistry.get(e);if(c)At(i.schema,c);if(t.io==="input"&&J(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 Hc(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function wo(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}/${Hc(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+Hc(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>
|
|
57
|
+
`)}return x.write("payload.value = newResult;"),x.write("return payload;"),x.compile()},i,a=$t,c=!H.jitless,l=c&&Ks.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 Ja([],g,f,m,d,e,m?.abortEarly===!0)}return r(f,m)}});function ia(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)=>!we(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)=>ve(i,n,q())))}),t}var qa=h("$ZodUnion",(e,t)=>{j.init(e,t),T(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),T(e,"optout",(n)=>n.def.options.some((o)=>o._zod.optout==="optional")?"optional":void 0),T(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}),T(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)=>ir(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 ia(i,n,e,o);return Promise.all(i).then((a)=>ia(a,n,e,o))}});var Ya=h("$ZodIntersection",(e,t)=>{j.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])=>aa(r,c,u));return aa(r,s,i)}});function Yn(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(Ge(e)&&Ge(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=Yn(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=Yn(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 aa(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=Yn(t.value,r.value);if(!c.valid){if(we(e))return e;throw Error(`Unmergable intersection. Error path: ${JSON.stringify(c.mergeErrorPath)}`)}return e.value=c.data,e}var Xa=h("$ZodRecord",(e,t)=>{j.init(e,t);let r=H.memoizer;r?.attach(e),e._zod.parse=(n,o)=>{let s=n.value;if(!Ge(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)=>ve(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(...De(l,m.issues));n.value[d]=m.value}));else{if(f.issues.length)n.issues.push(...De(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"&&zt.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)=>ve(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(...De(u,m.issues));n.value[d]=m.value}));else{if(f.issues.length)n.issues.push(...De(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 Qa=h("$ZodEnum",(e,t)=>{j.init(e,t);let r=St(t.entries),n=new Set(r);e._zod.values=n,T(e,"pattern",(o)=>{let s=St(o.def.entries).filter((i)=>Js.has(typeof i));return new RegExp(s.length?`^(${s.map((i)=>ot(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 ec=h("$ZodTransform",(e,t)=>{j.init(e,t),e._zod.optin="optional",H.memoizer?.guard(e),e._zod.parse=(r,n)=>{if(n.direction==="backward")throw new Pt(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 $e;return r.value=o,r}});function ca(e,t){return e.value=t.issues.length?void 0:t.value,e}var to=h("$ZodOptional",(e,t)=>{j.init(e,t),T(e,"optin",(r)=>r.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),e._zod.optout="optional",T(e,"values",(r)=>{let n=r.def.innerType._zod.values;return n?new Set([...n,void 0]):void 0}),T(e,"pattern",(r)=>{let n=r.def.innerType._zod.pattern;return n?new RegExp(`^(${ir(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)=>ca(r,s));return ca(r,o)}return t.innerType._zod.run(r,n)}}),tc=h("$ZodExactOptional",(e,t)=>{to.init(e,t),T(e,"values",(r)=>r.def.innerType._zod.values),T(e,"pattern",(r)=>r.def.innerType._zod.pattern),e._zod.parse=(r,n)=>t.innerType._zod.run(r,n)}),rc=h("$ZodNullable",(e,t)=>{j.init(e,t),T(e,"optin",(r)=>r.def.innerType._zod.optin),T(e,"optout",(r)=>r.def.innerType._zod.optout),T(e,"pattern",(r)=>{let n=r.def.innerType._zod.pattern;return n?new RegExp(`^(${ir(n.source)}|null)$`):void 0}),T(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)}}),nc=h("$ZodDefault",(e,t)=>{j.init(e,t),e._zod.optin="defaulted",T(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)=>ua(s,t));return ua(o,t)}});function ua(e,t){if(e.value===void 0)e.value=t.defaultValue;return e}var oc=h("$ZodPrefault",(e,t)=>{j.init(e,t),e._zod.optin="defaulted",T(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)}}),sc=h("$ZodNonOptional",(e,t)=>{j.init(e,t),T(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)=>la(s,e));return la(o,e)}});function la(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 pa(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)=>ve(o,n,q()))},input:e.value}),e}var ic=h("$ZodCatch",(e,t)=>{j.init(e,t),T(e,"optin",(r)=>r.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),T(e,"optout",(r)=>r.def.innerType._zod.optout),T(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)=>pa(r,s,t,n));return pa(r,o,t,n)}});var ac=h("$ZodPipe",(e,t)=>{j.init(e,t),T(e,"values",(r)=>r.def.in._zod.values),T(e,"optin",(r)=>r.def.in._zod.optin),T(e,"optout",(r)=>r.def.out._zod.optout),T(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)=>_r(i,t.in,n));return _r(s,t.in,n)}let o=t.in._zod.run(r,n);if(o instanceof Promise)return o.then((s)=>_r(s,t.out,n));return _r(o,t.out,n)}});function _r(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 cc=h("$ZodReadonly",(e,t)=>{j.init(e,t),T(e,"propValues",(r)=>r.def.innerType._zod.propValues),T(e,"values",(r)=>r.def.innerType._zod.values),T(e,"optin",(r)=>r.def.innerType?._zod?.optin),T(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(da);return da(o)}});function da(e){if(!e.memo)e.value=Object.freeze(e.value);return e}var uc=h("$ZodCustom",(e,t)=>{K.init(e,t),j.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)=>fa(s,r,n,e));fa(o,r,n,e);return}});function fa(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(We(o))}}class pc extends Error{constructor(){super("Cannot parse a reference cycle that closes through a transform");this.name="ZodCyclicError"}}var no="~memo",lc=[];function dc(e){return e!==null&&typeof e==="object"}function ro(e){return e.map((t)=>t.path?{...t,path:t.path.slice()}:{...t})}var fc=new WeakMap,Ct=0,Pr=1,Ot=2;function zr(e,t,r){let n=fc.get(e);if(n!==void 0)return n?Ot:Ct;if(t.has(e))return Ot;t.add(e);let o=Ct,s=(l)=>{if(o!==Ot&&l?._zod){let p=zr(l,t,r);if(p>o)o=p}},i=(l,p)=>{let d=Ct;for(let f of Reflect.ownKeys(l)){let m=Object.getOwnPropertyDescriptor(l,f);if(p&&!m.enumerable)continue;let g=m.get?Pr:m.value?._zod?zr(m.value,t,r):Ct;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=ar(c);a(l?i(l,!0):Pr),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?zr(l,t,!1):Pr);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),Df(e,o)}function Df(e,t){if(t!==Pr)fc.set(e,t===Ot);return t}function Nf(e,t){let r=e.buckets.get(t);if(!r)r=new WeakMap,e.buckets.set(t,r);return r}var Sr,kr=[],Ff={alloc(e,t,r){let n=Sr;if(!n)return r;Sr=void 0;let o={value:r,issues:null};return n.set(t.value,o),kr.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"&&Uf(s,o.value))throw new pc;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 _=zr(e,new Set,!1);if(_===Ct){if(e._zod.parse=i,e._zod.run===a)e._zod.run=i;return i(c,u)}if(_===Ot||n)r=!0;else n=!0}let l=c.value;if(!dc(l))return i(c,u);let p=u[no];if(!p)p={buckets:new WeakMap,backEdges:void 0},u[no]=p;let d;if(o===u)d=s;else d=Nf(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}Sr=d;let m=kr.length,g=i(c,u);Sr=void 0;let x=kr.length>m?kr.pop():void 0;if(g instanceof Promise)return g.then((_)=>{if(x)x.issues=_.issues.length?ro(_.issues):lc;return _});if(x)x.issues=g.issues.length?ro(g.issues):lc;return g};if(e._zod.parse=a,e._zod.run===i)e._zod.run=a})}};function oo(){return Ff}function Uf(e,t){let r=e[no]?.backEdges;return r!==void 0&&dc(t)&&r.has(t)}var Mf=()=>{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=Qs(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 ${Rn(s.values[0])}`;return`Invalid option: expected one of ${Tn(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":""}: ${Tn(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 so(){return{localeError:Mf()}}var mc;class hc{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 gc(){return new hc}(mc=globalThis).__zod_globalRegistry??(mc.__zod_globalRegistry=gc());var Ne=globalThis.__zod_globalRegistry;function xc(e){if(e.checks)e.checks=[...e.checks];return e}function yc(e,t){return new e(xc({type:"string",...w(t)}))}function _c(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...w(t)})}function bc(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...w(t)})}function wc(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...w(t)})}function vc(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...w(t)})}function $c(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...w(t)})}function Sc(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...w(t)})}function io(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...w(t)})}function kc(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...w(t)})}function Pc(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...w(t)})}function zc(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...w(t)})}function Ec(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...w(t)})}function Cc(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...w(t)})}function Oc(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...w(t)})}function Tc(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...w(t)})}function Ic(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...w(t)})}function Ac(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...w(t)})}function Rc(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...w(t)})}function Zc(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...w(t)})}function jc(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...w(t)})}function Lc(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...w(t)})}function Dc(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...w(t)})}function Nc(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...w(t)})}function Er(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...w(t)})}function Cr(e,t){return new e({type:"string",format:"date",check:"string_format",...w(t)})}function Or(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...w(t)})}function Tr(e,t){return new e({type:"string",format:"duration",check:"string_format",...w(t)})}function Fc(e,t){return new e(xc({type:"number",checks:[],...w(t)}))}function Uc(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...w(t)})}function Mc(e,t){return new e({type:"boolean",...w(t)})}function Bc(e){return new e({type:"unknown"})}function Vc(e,t){return new e({type:"never",...w(t)})}function Ir(e,t){return new Jn({check:"less_than",...w(t),value:e,inclusive:!1})}function Tt(e,t){return new Jn({check:"less_than",...w(t),value:e,inclusive:!0})}function Ar(e,t){return new Hn({check:"greater_than",...w(t),value:e,inclusive:!1})}function It(e,t){return new Hn({check:"greater_than",...w(t),value:e,inclusive:!0})}function Rr(e,t){return new Vi({check:"multiple_of",...w(t),value:e})}function Zr(e,t){return new Wi({check:"max_length",...w(t),maximum:e})}function at(e,t){return new Ki({check:"min_length",...w(t),minimum:e})}function jr(e,t){return new Ji({check:"length_equals",...w(t),length:e})}function ao(e,t){return new Hi({check:"string_format",format:"regex",...w(t),pattern:e})}function co(e){return new qi({check:"string_format",format:"lowercase",...w(e)})}function uo(e){return new Yi({check:"string_format",format:"uppercase",...w(e)})}function lo(e,t){return new Xi({check:"string_format",format:"includes",...w(t),includes:e})}function po(e,t){return new Qi({check:"string_format",format:"starts_with",...w(t),prefix:e})}function fo(e,t){return new ea({check:"string_format",format:"ends_with",...w(t),suffix:e})}function Fe(e){return new ta({check:"overwrite",tx:e})}function mo(e){return Fe((t)=>t.normalize(e))}function ho(){return Fe((e)=>e.trim())}function go(){return Fe((e)=>e.toLowerCase())}function xo(){return Fe((e)=>e.toUpperCase())}function yo(){return Fe((e)=>Ws(e))}function Gc(e,t,r){return new e({type:"array",element:t,...w(r)})}function Wc(e,t,r){return new e({type:"custom",check:"custom",fn:t,...w(r)})}function Kc(e,t){let r=Bf((n)=>(n.addIssue=(o)=>{if(typeof o==="string")n.issues.push(We(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(We(s))}},e(n.value,n)),t);return r}function Bf(e,t){let r=new K({check:"custom",...w(t)});return r._zod.check=e,r}function At(e,...t){for(let r of t)for(let n of Reflect.ownKeys(r))if(Object.prototype.propertyIsEnumerable.call(r,n))fe(e,n,r[n]);return e}function bo(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??Ne,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 Ke(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 M(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;M(p,t,l),t.seen.get(p).isParent=!0}}let c=t.metadataRegistry.get(e);if(c)At(i.schema,c);if(t.io==="input"&&J(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 Jc(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function wo(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}/${Jc(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+Jc(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>
|
|
58
58
|
|
|
59
|
-
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 Xc(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;Xc(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 Qc=new Set(["type","properties","required","additionalProperties"]),qc=["oneOf","anyOf"];function Yc(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 _o(e){let t=[];for(let s of e){if(typeof s!=="object"||s.type!=="object")return null;for(let i in s)if(!Qc.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]??Yc(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]:_o(a)??{allOf:a};fe(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=Yc(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 Uf(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let o of Qc)if(o in e)return;let r=t.filter((o)=>qc.some((s)=>Array.isArray(o[s]))),n=null;if(!r.length)n=_o(t);else{let o=r[0],s=qc.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)=>_o([...i,c]));if(a.some((c)=>!c))return;n={[s]:a}}if(!n)return;delete e.allOf,At(e,n)}function vo(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 At(u,m);if(At(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())Xc(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)??[])Uf(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)}At(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;fe(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:Rt(t,"input",e.processors),output:Rt(t,"output",e.processors)}},enumerable:!1,writable:!1}),a}catch(a){throw Error("Error converting schema to JSON.")}}function J(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 J(n.element,r);if(n.type==="set")return J(n.valueType,r);if(n.type==="lazy")return J(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 J(n.innerType,r);if(n.type==="intersection")return J(n.left,r)||J(n.right,r);if(n.type==="record"||n.type==="map")return J(n.keyType,r)||J(n.valueType,r);if(n.type==="pipe"){if(e._zod.traits.has("$ZodCodec"))return!0;return J(n.in,r)||J(n.out,r)}if(n.type==="object"){for(let o in n.shape)if(J(n.shape[o],r))return!0;return!1}if(n.type==="union"){for(let o of n.options)if(J(o,r))return!0;return!1}if(n.type==="tuple"){for(let o of n.items)if(J(o,r))return!0;if(n.rest&&J(n.rest,r))return!0;return!1}return!1}var eu=(e,t={})=>(r)=>{let n=bo({...r,processors:t});return M(e,n),wo(n,e),vo(n,e)},Rt=(e,t,r={})=>(n)=>{let{libraryOptions:o,target:s}=n??{},i=bo({...o??{},target:s,io:t,processors:r});return M(e,i),wo(i,e),vo(i,e)};var ct=(e,t,r)=>{if(e[t]===void 0||r>e[t])e[t]=r},ut=(e,t,r)=>{if(e[t]===void 0||r<e[t])e[t]=r},tu=(e,t)=>{ct(e,"minimum",t),ut(e,"maximum",t)},su=(e,t)=>{if(e.multipleOf??(e.multipleOf=[]),!e.multipleOf.includes(t))e.multipleOf.push(t)},iu=(e,t)=>{e.patterns??(e.patterns=new Set),e.patterns.add(t)},au=(e,t)=>{e.mime=e.mime?e.mime.filter((r)=>t.includes(r)):[...t]},cu=(e,t)=>{if(e.format=t,t.includes("int"))e.isInt=!0},ru=(e,t)=>ct(e,"minimum",t.minimum),nu=(e,t)=>ut(e,"maximum",t.maximum),ou=(e)=>(t,r)=>{cu(t,r.format);let[n,o]=e[r.format];ct(t,"minimum",n),ut(t,"maximum",o)},Mf={greater_than:(e,t)=>ct(e,t.inclusive?"minimum":"exclusiveMinimum",t.value),less_than:(e,t)=>ut(e,t.inclusive?"maximum":"exclusiveMaximum",t.value),multiple_of:(e,t)=>su(e,t.value),number_format:ou(cr),bigint_format:ou(Zn),min_length:ru,max_length:nu,length_equals:(e,t)=>tu(e,t.length),min_size:ru,max_size:nu,size_equals:(e,t)=>tu(e,t.size),string_format:(e,t)=>{if(cu(e,t.format),t.pattern)iu(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)=>au(e,t.mime)};function ce(e){let t={},r=e._zod.def,n=e._zod.traits.has("$ZodCheck")?[e,...r.checks??[]]:r.checks??[];for(let s of n)Mf[s._zod.def.check]?.(t,s._zod.def);let o=e._zod.bag;if(o.minimum!==void 0)ct(t,"minimum",o.minimum);if(o.exclusiveMinimum!==void 0)ct(t,"exclusiveMinimum",o.exclusiveMinimum);if(o.maximum!==void 0)ut(t,"maximum",o.maximum);if(o.exclusiveMaximum!==void 0)ut(t,"exclusiveMaximum",o.exclusiveMaximum);if(o.multipleOf!==void 0)su(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)au(t,o.mime);for(let s of o.patterns??[])iu(t,s);return t}var Bf={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},Vf=new Map([[Qn,Ai],[$r,Ri]]),uu=(e)=>Vf.get(e)??e,lu=(e,t,r,n)=>{let o=r;o.type="string";let{minimum:s,maximum:i,format:a,patterns:c,contentEncoding:u,laxFormat:l}=ce(e);if(typeof s==="number")o.minLength=s;if(typeof i==="number")o.maxLength=i;if(a){if(o.format=Bf[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(uu);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}))]}},pu=(e,t,r,n)=>{let o=r,{minimum:s,maximum:i,multipleOf:a,exclusiveMaximum:c,exclusiveMinimum:u,isInt:l}=ce(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 Ke(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:_}))]}},du=(e,t,r,n)=>{r.type="boolean"};var fu=(e,t,r,n)=>{r.not={}};var mu=(e,t,r,n)=>{};var hu=(e,t,r,n)=>{let o=e._zod.def,s=St(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 gu=(e,t,r,n)=>{Ke(e,t,r,n,"Custom types cannot be represented in JSON Schema")};var xu=(e,t,r,n)=>{Ke(e,t,r,n,"Transforms cannot be represented in JSON Schema")};var yu=(e,t,r,n)=>{let o=r,s=e._zod.def,{minimum:i,maximum:a}=ce(e);if(typeof i==="number")o.minItems=i;if(typeof a==="number")o.maxItems=a;o.type="array",o.items=M(s.element,t,{...n,path:[...n.path,"items"]})};function Lr(e){let t=e._zod.def;if(t.type==="pipe"&&t.in._zod.traits.has("$ZodTransform"))return Lr(t.out);if(t.type==="catch")return Lr(t.innerType);return e._zod.optin}var _u=(e,t,r,n)=>{let o=r,s=e._zod.def,i=s.shape;if(Object.getOwnPropertySymbols(i).length&&Ke(e,t,o,n,"Symbol keys cannot be represented in JSON Schema"))return;o.type="object",o.properties={};for(let u in i)fe(o.properties,u,M(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"?Lr(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=M(s.catchall,t,{...n,path:[...n.path,"additionalProperties"]})},bu=(e,t,r,n)=>{let o=e._zod.def,s=o.inclusive===!1,i=o.options.map((a,c)=>M(a,t,{...n,path:[...n.path,s?"oneOf":"anyOf",c]}));if(s)r.oneOf=i;else r.anyOf=i},wu=(e,t,r,n)=>{let o=e._zod.def,s=M(o.left,t,{...n,path:[...n.path,"allOf",0]}),i=M(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 $o(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=$o(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((_)=>$o(e,_,r));if(x.some((_,b)=>_!==g[b]))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")?zt:Wn).source;return f}var So=new WeakMap;function Gf(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 So.get(e)??[]){let o=e.seen.get(n),s=(o?.def??o?.schema)?.propertyNames;if(!s||s===!0||r.has(s))continue;let i=$o(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 vu=(e,t,r,n)=>{let o=r,s=e._zod.def;o.type="object";let i=s.keyType,a=ce(i).patterns;if(s.mode==="loose"&&a&&a.size>0){let l=M(s.valueType,t,{...n,path:[...n.path,"patternProperties","*"]});o.patternProperties={};for(let p of a)fe(o.patternProperties,uu(p).source,l)}else{if(t.target==="draft-07"||t.target==="draft-2020-12"){o.propertyNames=M(s.keyType,t,{...n,path:[...n.path,"propertyNames"]});let l=So.get(t);if(!l)l=[],So.set(t,l),t.deferred.push(()=>Gf(t));l.push(e)}o.additionalProperties=M(s.valueType,t,{...n,path:[...n.path,"additionalProperties"]})}let c=i._zod.values,u=t.io==="input"&&Lr(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)}},$u=(e,t,r,n)=>{let o=e._zod.def,s=M(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"}]},Su=(e,t,r,n)=>{let o=e._zod.def;M(o.innerType,t,n);let s=t.seen.get(e);s.ref=o.innerType},ko=Symbol();function ku(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 Ke(t,r,n,o,"BigInt defaults cannot be represented in JSON Schema"),ko}var Pu=(e,t,r,n)=>{let o=e._zod.def;M(o.innerType,t,n);let s=t.seen.get(e);s.ref=o.innerType;let i=ku(o.defaultValue,e,t,r,n);if(i!==ko)r.default=i},zu=(e,t,r,n)=>{let o=e._zod.def;M(o.innerType,t,n);let s=t.seen.get(e);if(s.ref=o.innerType,t.io!=="input")return;let i=ku(o.defaultValue,e,t,r,n);if(i!==ko)r._prefault=i},Eu=(e,t,r,n)=>{let o=e._zod.def;M(o.innerType,t,n);let s=t.seen.get(e);s.ref=o.innerType;let i;try{i=o.catchValue(void 0)}catch{Ke(e,t,r,n,"Dynamic catch values are not supported in JSON Schema");return}r.default=i},Cu=(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;M(i,t,n);let a=t.seen.get(e);a.ref=i},Ou=(e,t,r,n)=>{let o=e._zod.def;M(o.innerType,t,n);let s=t.seen.get(e);s.ref=o.innerType,r.readOnly=!0};var Po=(e,t,r,n)=>{let o=e._zod.def;M(o.innerType,t,n);let s=t.seen.get(e);s.ref=o.innerType};var Tu=new WeakSet([Object.prototype,Error.prototype]);function Dr(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 em=(e,t)=>{ci.init(e,t),e.name="ZodError";let r=Object.getPrototypeOf(e);if(Tu.has(r))return;Tu.add(r),Dr(r,"format",(n)=>(o)=>Un(n,o)),Dr(r,"flatten",(n)=>(o)=>Fn(n,o)),Dr(r,"addIssue",(n)=>(o)=>{n.issues.push(o),n.message=JSON.stringify(n.issues,kt,2)}),Dr(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 re=h("ZodError",em,void 0,{Parent:Error});var Iu=mr(re),Au=hr(re),Ru=gr(re),Zu=xr(re),ju=li(re),Lu=pi(re),Du=di(re),Nu=fi(re),Fu=mi(re),Uu=hi(re),Mu=gi(re),Bu=xi(re);function rm(){if(!H.localeError)q(so())}function Fr(){if(!H.memoizer)q({memoizer:oo()})}var N=h("ZodType",(e,t)=>(rm(),j.init(e,t),e.def=t,e.type=t.type,e),{check(...e){let t=this.def;return this.clone(te(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 me(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(Hm(e,t))},superRefine(e,t){return this.check(qm(e,t))},overwrite(e){return this.check(Fe(e))},optional(){return Ku(this)},exactOptional(){return jm(this)},nullable(){return Ju(this)},nullish(){return Ku(Ju(this))},nonoptional(e){return Mm(this,e)},array(){return Se(this)},or(e){return Ur([this,e])},and(e){return Im(this,e)},transform(e){return Hu(this,Zm(e))},default(e){return Nm(this,e)},prefault(e){return Um(this,e)},catch(e){return Vm(this,e)},pipe(e){return Hu(this,e)},readonly(){return Km(this)},describe(e){let t=this.clone();return Ne.add(t,{description:e}),t},meta(...e){if(e.length===0)return Ne.get(this);let t=this.clone();return Ne.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 dr(this,"~standard",{...Xn(this),jsonSchema:{input:Rt(this,"input"),output:Rt(this,"output")}})},set "~standard"(e){Ce(this,"~standard",e)},parse:function e(t,r){return Iu(this,t,r,{callee:e})},parseAsync:async function e(t,r){return await Au(this,t,r,{callee:e})},safeParse(e,t){return Ru(this,e,t)},async safeParseAsync(e,t){return Zu(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){Ce(this,"spa",e)},validate(e,t){return Mn(this,e,t)},validateAsync(e,t){return Bn(this,e,t)},encode:function e(t,r){return ju(this,t,r,{callee:e})},decode:function e(t,r){return Lu(this,t,r,{callee:e})},encodeAsync:async function e(t,r){return await Du(this,t,r,{callee:e})},decodeAsync:async function e(t,r){return await Nu(this,t,r,{callee:e})},safeEncode(e,t){return Fu(this,e,t)},safeDecode(e,t){return Uu(this,e,t)},async safeEncodeAsync(e,t){return Mu(this,e,t)},async safeDecodeAsync(e,t){return Bu(this,e,t)},toJSONSchema(e){return eu(this,{})(e)},get description(){return Ne.get(this)?.description},get _def(){return this._zod.def}}),qu=h("_ZodString",(e,t)=>{vr.init(e,t),N.init(e,t),e._zod.processJSONSchema=(r,n,o)=>lu(e,r,n,o)},ri({format:(e)=>ce(e).format??null,minLength:(e)=>ce(e).minimum??null,maxLength:(e)=>ce(e).maximum??null},{regex(...e){return this.check(ao(...e))},includes(...e){return this.check(lo(...e))},startsWith(...e){return this.check(po(...e))},endsWith(...e){return this.check(fo(...e))},min(...e){return this.check(at(...e))},max(...e){return this.check(Zr(...e))},length(...e){return this.check(jr(...e))},nonempty(...e){return this.check(at(1,...e))},lowercase(e){return this.check(co(e))},uppercase(e){return this.check(uo(e))},trim(){return this.check(ho())},normalize(...e){return this.check(mo(...e))},toLowerCase(){return this.check(go())},toUpperCase(){return this.check(xo())},slugify(){return this.check(yo())}})),nm=h("ZodString",(e,t)=>{vr.init(e,t),qu.init(e,t)},{email(e){return this.check(bc(om,e))},url(e){return this.check(io(Yu,e))},jwt(e){return this.check(Fc(wm,e))},emoji(e){return this.check(Pc(am,e))},guid(e){return this.check(wc(sm,e))},uuid(e){return this.check(vc(Nr,e))},uuidv4(e){return this.check($c(Nr,e))},uuidv6(e){return this.check(Sc(Nr,e))},uuidv7(e){return this.check(kc(Nr,e))},nanoid(e){return this.check(zc(cm,e))},cuid(e){return this.check(Ec(um,e))},cuid2(e){return this.check(Cc(lm,e))},ulid(e){return this.check(Oc(pm,e))},base64(e){return this.check(Lc(ym,e))},base64url(e){return this.check(Dc(_m,e))},xid(e){return this.check(Tc(dm,e))},ksuid(e){return this.check(Ic(fm,e))},ipv4(e){return this.check(Ac(mm,e))},ipv6(e){return this.check(Rc(hm,e))},cidrv4(e){return this.check(Zc(gm,e))},cidrv6(e){return this.check(jc(xm,e))},e164(e){return this.check(Nc(bm,e))},datetime(e){return this.check(Er(jt,e))},date(e){return this.check(Cr(Lt,e))},time(e){return this.check(Or(Dt,e))},duration(e){return this.check(Tr(Nt,e))}});function v(e){return _c(nm,e)}var L=h("ZodStringFormat",(e,t)=>{R.init(e,t),qu.init(e,t)}),jt=h("ZodISODateTime",(e,t)=>{Ca.init(e,t),L.init(e,t)}),Lt=h("ZodISODate",(e,t)=>{Oa.init(e,t),L.init(e,t)}),Dt=h("ZodISOTime",(e,t)=>{Ta.init(e,t),L.init(e,t)}),Nt=h("ZodISODuration",(e,t)=>{Ia.init(e,t),L.init(e,t)}),om=h("ZodEmail",(e,t)=>{ya.init(e,t),L.init(e,t)});var sm=h("ZodGUID",(e,t)=>{ga.init(e,t),L.init(e,t)});var Nr=h("ZodUUID",(e,t)=>{xa.init(e,t),L.init(e,t)});var Yu=h("ZodURL",(e,t)=>{wa.init(e,t),L.init(e,t)});function im(e){return io(Yu,e)}var am=h("ZodEmoji",(e,t)=>{va.init(e,t),L.init(e,t)});var cm=h("ZodNanoID",(e,t)=>{$a.init(e,t),L.init(e,t)});var um=h("ZodCUID",(e,t)=>{Sa.init(e,t),L.init(e,t)});var lm=h("ZodCUID2",(e,t)=>{ka.init(e,t),L.init(e,t)});var pm=h("ZodULID",(e,t)=>{Pa.init(e,t),L.init(e,t)});var dm=h("ZodXID",(e,t)=>{za.init(e,t),L.init(e,t)});var fm=h("ZodKSUID",(e,t)=>{Ea.init(e,t),L.init(e,t)});var mm=h("ZodIPv4",(e,t)=>{Aa.init(e,t),L.init(e,t)});var hm=h("ZodIPv6",(e,t)=>{Za.init(e,t),L.init(e,t)});var gm=h("ZodCIDRv4",(e,t)=>{ja.init(e,t),L.init(e,t)});var xm=h("ZodCIDRv6",(e,t)=>{La.init(e,t),L.init(e,t)});var ym=h("ZodBase64",(e,t)=>{Na.init(e,t),L.init(e,t)});var _m=h("ZodBase64URL",(e,t)=>{Fa.init(e,t),L.init(e,t)});var bm=h("ZodE164",(e,t)=>{Ua.init(e,t),L.init(e,t)});var wm=h("ZodJWT",(e,t)=>{Ma.init(e,t),L.init(e,t)});var Xu=h("ZodNumber",(e,t)=>{eo.init(e,t),N.init(e,t),e._zod.processJSONSchema=(r,n,o)=>pu(e,r,n,o),e.isFinite=!0},ri({minValue:(e)=>{let{minimum:t,exclusiveMinimum:r}=ce(e);return Math.max(t??Number.NEGATIVE_INFINITY,r??Number.NEGATIVE_INFINITY)},maxValue:(e)=>{let{maximum:t,exclusiveMaximum:r}=ce(e);return Math.min(t??Number.POSITIVE_INFINITY,r??Number.POSITIVE_INFINITY)},isInt:(e)=>{let{isInt:t,multipleOf:r}=ce(e);return!!t||!!r?.some(Number.isSafeInteger)},format:(e)=>ce(e).format??null},{gt(e,t){return this.check(Ar(e,t))},gte(e,t){return this.check(It(e,t))},min(e,t){return this.check(It(e,t))},lt(e,t){return this.check(Ir(e,t))},lte(e,t){return this.check(Tt(e,t))},max(e,t){return this.check(Tt(e,t))},int(e){return this.check(Vu(e))},safe(e){return this.check(Vu(e))},positive(e){return this.check(Ar(0,e))},nonnegative(e){return this.check(It(0,e))},negative(e){return this.check(Ir(0,e))},nonpositive(e){return this.check(Tt(0,e))},multipleOf(e,t){return this.check(Rr(e,t))},step(e,t){return this.check(Rr(e,t))},finite(){return this}}));function Qu(e){return Uc(Xu,e)}var vm=h("ZodNumberFormat",(e,t)=>{Ba.init(e,t),Xu.init(e,t)});function Vu(e){return Mc(vm,e)}var $m=h("ZodBoolean",(e,t)=>{Va.init(e,t),N.init(e,t),e._zod.processJSONSchema=(r,n,o)=>du(e,r,n,o)});function Sm(e){return Bc($m,e)}var km=h("ZodUnknown",(e,t)=>{Ga.init(e,t),N.init(e,t),e._zod.processJSONSchema=(r,n,o)=>mu(e,r,n,o)});function Gu(){return Vc(km)}var Pm=h("ZodNever",(e,t)=>{Wa.init(e,t),N.init(e,t),e._zod.processJSONSchema=(r,n,o)=>fu(e,r,n,o)});function zm(e){return Gc(Pm,e)}var Em=h("ZodArray",(e,t)=>{Fr(),Ka.init(e,t),N.init(e,t),e._zod.processJSONSchema=(r,n,o)=>yu(e,r,n,o),e.element=t.element},{min(e,t){return this.check(at(e,t))},nonempty(e){return this.check(at(1,e))},max(e,t){return this.check(Zr(e,t))},length(e,t){return this.check(jr(e,t))},unwrap(){return this.element}});function Se(e,t){return Wc(Em,e,t)}var Cm=h("ZodObject",(e,t)=>{Fr(),qa.init(e,t),N.init(e,t),e._zod.processJSONSchema=(r,n,o)=>_u(e,r,n,o),lf(e,"shape",(r)=>r._zod.def.shape,!1)},{keyof(){return Am(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(te(this._zod.def,{catchall:e}))},passthrough(){return this.clone(te(this._zod.def,{catchall:Gu()}))},loose(){return this.clone(te(this._zod.def,{catchall:Gu()}))},strict(){return this.clone(te(this._zod.def,{catchall:zm()}))},strip(){return this.clone(te(this._zod.def,{catchall:void 0}))},extend(e){return tf(this,e)},safeExtend(e){return rf(this,e)},merge(e){return nf(this,e)},pick(e){return Qd(this,e)},omit(e){return ef(this,e)},partial(...e){return Xs(el,this,e[0])},exactPartial(...e){return Xs(tl,this,e[0],"exactPartial")},required(...e){return of(rl,this,e[0])}});function I(e,t){let r={type:"object",shape:e??{},...w(t)};return new Cm(r)}var Om=h("ZodUnion",(e,t)=>{Ya.init(e,t),N.init(e,t),e._zod.processJSONSchema=(r,n,o)=>bu(e,r,n,o),e.options=t.options});function Ur(e,t){return new Om({type:"union",options:e,...w(t)})}var Tm=h("ZodIntersection",(e,t)=>{Xa.init(e,t),N.init(e,t),e._zod.processJSONSchema=(r,n,o)=>wu(e,r,n,o)});function Im(e,t){return new Tm({type:"intersection",left:e,right:t})}var Wu=h("ZodRecord",(e,t)=>{Fr(),Qa.init(e,t),N.init(e,t),e._zod.processJSONSchema=(r,n,o)=>vu(e,r,n,o),e.keyType=t.keyType,e.valueType=t.valueType});function lt(e,t,r){if(!t||!t._zod)return new Wu({type:"record",keyType:v(),valueType:e,...w(t)});return new Wu({type:"record",keyType:e,valueType:t,...w(r)})}var zo=h("ZodEnum",(e,t)=>{ec.init(e,t),N.init(e,t),e._zod.processJSONSchema=(n,o,s)=>hu(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 zo({...t,checks:[],...w(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 zo({...t,checks:[],...w(o),entries:s})}});function Am(e,t){let r=Array.isArray(e)?Object.fromEntries(e.map((n)=>[n,n])):e;return new zo({type:"enum",entries:r,...w(t)})}var Rm=h("ZodTransform",(e,t)=>{Fr(),tc.init(e,t),N.init(e,t),e._zod.processJSONSchema=(r,n,o)=>xu(e,r,n,o),e._zod.parse=(r,n)=>{if(n.direction==="backward")throw new Pt(e.constructor.name);r.addIssue=(s)=>{if(typeof s==="string")r.issues.push(We(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(We(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 Zm(e){return new Rm({type:"transform",transform:e})}var el=h("ZodOptional",(e,t)=>{to.init(e,t),N.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Po(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function Ku(e){return new el({type:"optional",innerType:e})}var tl=h("ZodExactOptional",(e,t)=>{rc.init(e,t),N.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Po(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function jm(e){return new tl({type:"optional",innerType:e})}var Lm=h("ZodNullable",(e,t)=>{nc.init(e,t),N.init(e,t),e._zod.processJSONSchema=(r,n,o)=>$u(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function Ju(e){return new Lm({type:"nullable",innerType:e})}var Dm=h("ZodDefault",(e,t)=>{oc.init(e,t),N.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Pu(e,r,n,o),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Nm(e,t){return new Dm({type:"default",innerType:e,get defaultValue(){return typeof t==="function"?t():An(t)}})}var Fm=h("ZodPrefault",(e,t)=>{sc.init(e,t),N.init(e,t),e._zod.processJSONSchema=(r,n,o)=>zu(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function Um(e,t){return new Fm({type:"prefault",innerType:e,get defaultValue(){return typeof t==="function"?t():An(t)}})}var rl=h("ZodNonOptional",(e,t)=>{ic.init(e,t),N.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Su(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function Mm(e,t){return new rl({type:"nonoptional",innerType:e,...w(t)})}var Bm=h("ZodCatch",(e,t)=>{ac.init(e,t),N.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Eu(e,r,n,o),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function Vm(e,t){return new Bm({type:"catch",innerType:e,catchValue:typeof t==="function"?t:ni(t)})}var Gm=h("ZodPipe",(e,t)=>{cc.init(e,t),N.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Cu(e,r,n,o),e.in=t.in,e.out=t.out});function Hu(e,t){return new Gm({type:"pipe",in:e,out:t})}var Wm=h("ZodReadonly",(e,t)=>{uc.init(e,t),N.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Ou(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function Km(e){return new Wm({type:"readonly",innerType:e})}var Jm=h("ZodCustom",(e,t)=>{lc.init(e,t),N.init(e,t),e._zod.processJSONSchema=(r,n,o)=>gu(e,r,n,o)});function Hm(e,t={}){return Kc(Jm,e,t)}function qm(e,t){return Jc(e,t)}var Mr={};Hd(Mr,{ZodISODate:()=>Lt,ZodISODateTime:()=>jt,ZodISODuration:()=>Nt,ZodISOTime:()=>Dt,date:()=>Xm,datetime:()=>Ym,duration:()=>eh,time:()=>Qm});function Ym(e){return Er(jt,e)}function Xm(e){return Cr(Lt,e)}function Qm(e){return Or(Dt,e)}function eh(e){return Tr(Nt,e)}var ql=nt(Ft(),1);var oh=["emacs","vim"],sh=new Set(oh);function ih(e){return sh.has(e)}function sl(){let e=process.env.INQUIRER_KEYBINDINGS;if(!e)return[];return Array.from(new Set(e.toLowerCase().split(/[\s,]+/).filter(ih)))}var Ut=(e,t=[])=>e.name==="up"||t.includes("vim")&&e.name==="k"||t.includes("emacs")&&e.ctrl&&e.name==="p",Gr=(e,t=[])=>e.name==="down"||t.includes("vim")&&e.name==="j"||t.includes("emacs")&&e.ctrl&&e.name==="n";var Mt=(e)=>e.name==="backspace",Bt=(e)=>e.name==="tab",Co=(e)=>"1234567890".includes(e.name),Oe=(e)=>e.name==="enter"||e.name==="return";class Oo extends Error{name="AbortPromptError";message="Prompt was aborted";constructor(e){super();this.cause=e?.cause}}class To extends Error{name="CancelPromptError";message="Prompt was canceled"}class Wr extends Error{name="ExitPromptError"}class Io extends Error{name="HookError"}class Vt extends Error{name="ValidationError"}import{AsyncResource as lh}from"node:async_hooks";import{AsyncLocalStorage as ah,AsyncResource as ch}from"node:async_hooks";var il=new ah;function uh(e){return{rl:e,hooks:[],hooksCleanup:[],hooksEffect:[],index:0,handleChange(){}}}function al(e,t){let r=uh(e);return il.run(r,()=>{function n(o){r.handleChange=()=>{r.index=0,o()},r.handleChange()}return t(n)})}function He(){let e=il.getStore();if(!e)throw new Io("[Inquirer] Hook functions can only be called from within a prompt");return e}function Ao(){return He().rl}function Ro(e){let t=(...r)=>{let n=He(),o=!1,s=n.handleChange;n.handleChange=()=>{o=!0};let i=e(...r);if(o)s();return n.handleChange=s,i};return ch.bind(t)}function pt(e){let t=He(),{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 cl(){He().handleChange()}var Gt={queue(e){let t=He(),{index:r}=t;t.hooksEffect.push(()=>{t.hooksCleanup[r]?.();let n=e(Ao());if(n!=null&&typeof n!=="function")throw new Vt("useEffect return value must be a cleanup function or nothing.");t.hooksCleanup[r]=n})},run(){let e=He();Ro(()=>{e.hooksEffect.forEach((t)=>{t()}),e.hooksEffect.length=0})()},clearAll(){let e=He();e.hooksCleanup.forEach((t)=>{t?.()}),e.hooksEffect.length=0,e.hooksCleanup.length=0}};function ph(e){return typeof e==="function"}function dh(e){return typeof e==="function"}function D(e){return pt((t)=>{let r=lh.bind(function(s){let i=t.get(),a=dh(s)?s(i):s;if(!Object.is(i,a))t.set(a),cl()});if(t.initialized)return[t.get(),r];let n=ph(e)?e():e;return t.set(n),[n,r]})}function Te(e,t){pt((r)=>{let n=r.get();if(!Array.isArray(n)||t.some((s,i)=>!Object.is(s,n[i])))Gt.queue(e);r.set(t)})}import{styleText as ge}from"node:util";import he from"node:process";function fh(){if(!he.platform.startsWith("win"))return he.env.TERM!=="linux";return Boolean(he.env.CI)||Boolean(he.env.WT_SESSION)||Boolean(he.env.TERMINUS_SUBLIME)||he.env.ConEmuTask==="{cmd::Cmder}"||he.env.TERM_PROGRAM==="Terminus-Sublime"||he.env.TERM_PROGRAM==="vscode"||he.env.TERM==="xterm-256color"||he.env.TERM==="alacritty"||he.env.TERMINAL_EMULATOR==="JetBrains-JediTerm"}var ul={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:"╱"},ll={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:"⅒"},mh={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"},hh={...ul,...ll},gh={...ul,...mh},xh=fh(),yh=xh?hh:gh,dt=yh,gw=Object.entries(ll);var _h={prefix:{idle:ge("blue","?"),done:ge("green",dt.tick)},spinner:{interval:80,frames:["⠋","⠙","⠹","⠸","⠼","⠴","⠦","⠧","⠇","⠏"].map((e)=>ge("yellow",e))},keybindings:[],style:{answer:(e)=>ge("cyan",e),message:(e)=>ge("bold",e),error:(e)=>ge("red",`> ${e}`),defaultAnswer:(e)=>ge("dim",`(${e})`),help:(e)=>ge("dim",e),highlight:(e)=>ge("cyan",e),key:(e)=>ge("cyan",ge("bold",`<${e}>`))}};function pl(){return{..._h,keybindings:sl()}}function dl(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 fl(...e){let t={};for(let r of e)for(let[n,o]of Object.entries(r)){let s=t[n];t[n]=dl(s)&&dl(o)?fl(s,o):o}return t}function xe(...e){let t=[pl(),...e.filter((r)=>r!=null)];return fl(...t)}function Ie({status:e="idle",theme:t}){let[r,n]=D(!1),[o,s]=D(0),{prefix:i,spinner:a}=xe(t);if(Te(()=>{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 Wt(e,t){return pt((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 qe(e){return D({current:e})[0]}function Ae(e){let t=qe(e);t.current=e,Te((r)=>{let n=!1,o=Ro((s,i)=>{if(n)return;t.current(i,r)});return r.input.on("keypress",o),()=>{n=!0,r.input.removeListener("keypress",o)}},[])}var Tl=nt(hl(),1);var gl=(()=>{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}})(),xl=(e)=>e===12288||e>=65281&&e<=65376||e>=65504&&e<=65510,yl=(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 vh=/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]|\u001b\]8;[^;]*;.*?(?:\u0007|\u001b\u005c)/y,$h=/[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y,_l=/(?:(?![\uFF61-\uFF9F\uFF00-\uFFEF])[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}\p{Script=Tangut}]){1,1000}/yu,Sh=/\t{1,1000}/y,bl=/[\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,kh=/(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y,Ph=/\p{M}+/gu,zh={limit:1/0,ellipsis:""},wl=(e,t={},r={})=>{let n=t.limit??1/0,o=t.ellipsis??"",s=t?.ellipsisWidth??(o?wl(o,zh,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=[[kh,p],[vh,0],[$h,a],[Sh,c],[bl,u],[_l,d]],m=0,g=0,x=e.length,_=0,b=!1,k=x,z=Math.max(0,n-s),y=0,S=0,E=0,G=0;e:while(!0){if(S>y||g>=x&&g>m){let P=e.slice(y,S)||e.slice(m,g);_=0;for(let C of P.replaceAll(Ph,"")){let U=C.codePointAt(0)||0;if(xl(U))G=2;else if(yl(U))G=d;else G=p;if(E+G>z)k=Math.min(k,Math.max(y,m)+_);if(E+G>n){b=!0;break e}_+=C.length,E+=G}y=S=0}if(g>=x)break e;for(let P=0,C=f.length;P<C;P++){let[U,W]=f[P];if(U.lastIndex=g,U.test(e)){if(_=U===_l?gl(e.slice(g,U.lastIndex)):U===bl?1:U.lastIndex-g,G=_*W,E+G>z)k=Math.min(k,g+Math.floor((z-E)/W));if(E+G>n){b=!0;break e}E+=G,y=m,S=g,g=m=U.lastIndex;continue e}}g+=1}return{width:b?z:E,index:b?k:x,truncated:b,ellipsed:b&&n>=s}},vl=wl;var Eh={limit:1/0,ellipsis:"",ellipsisWidth:0},Ch=(e,t={})=>vl(e,Eh,t).width,Re=Ch;var Kr="\x1B",zl="",Oh=39,jo="\x07",El="[",Th="]",Cl="m",Lo=`${Th}8;;`,$l=new RegExp(`(?:\\${El}(?<code>\\d+)m|\\${Lo}(?<uri>.*)${jo})`,"y"),Sl=(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},kl=(e)=>`${Kr}${El}${e}${Cl}`,Pl=(e)=>`${Kr}${Lo}${e}${jo}`,Zo=(e,t,r)=>{let n=t[Symbol.iterator](),o=!1,s=!1,i=e.at(-1),a=i===void 0?0:Re(i),c=n.next(),u=n.next(),l=0;while(!c.done){let p=c.value,d=Re(p);if(a+d<=r)e[e.length-1]+=p;else e.push(p),a=0;if(p===Kr||p===zl)o=!0,s=t.startsWith(Lo,l+1);if(o){if(s){if(p===jo)o=!1,s=!1}else if(p===Cl)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()},Ih=(e)=>{let t=e.split(" "),r=t.length;while(r){if(Re(t[r-1]))break;r--}if(r===t.length)return e;return t.slice(0,r).join(" ")+t.slice(r).join("")},Ah=(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=Re(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=Re(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("");Zo(a,d,t),c=Re(a.at(-1)??"");continue}if(c+f>t&&c&&f){if(r.wordWrap===!1&&c<t){Zo(a,d,t),c=Re(a.at(-1)??"");continue}a.push(""),c=0}if(c+f>t&&r.wordWrap===!1){Zo(a,d,t),c=Re(a.at(-1)??"");continue}a[a.length-1]+=d,c+=f}if(r.trim!==!1)a=a.map((p)=>Ih(p));let u=a.join(`
|
|
60
|
-
`),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===Kr||d===
|
|
61
|
-
`){if(s)n+=
|
|
62
|
-
`){if(o
|
|
59
|
+
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 Yc(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;Yc(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 Xc=new Set(["type","properties","required","additionalProperties"]),Hc=["oneOf","anyOf"];function qc(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 _o(e){let t=[];for(let s of e){if(typeof s!=="object"||s.type!=="object")return null;for(let i in s)if(!Xc.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]??qc(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]:_o(a)??{allOf:a};fe(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=qc(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 Vf(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let o of Xc)if(o in e)return;let r=t.filter((o)=>Hc.some((s)=>Array.isArray(o[s]))),n=null;if(!r.length)n=_o(t);else{let o=r[0],s=Hc.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)=>_o([...i,c]));if(a.some((c)=>!c))return;n={[s]:a}}if(!n)return;delete e.allOf,At(e,n)}function vo(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 At(u,m);if(At(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())Yc(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)??[])Vf(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)}At(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;fe(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:Rt(t,"input",e.processors),output:Rt(t,"output",e.processors)}},enumerable:!1,writable:!1}),a}catch(a){throw Error("Error converting schema to JSON.")}}function J(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 J(n.element,r);if(n.type==="set")return J(n.valueType,r);if(n.type==="lazy")return J(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 J(n.innerType,r);if(n.type==="intersection")return J(n.left,r)||J(n.right,r);if(n.type==="record"||n.type==="map")return J(n.keyType,r)||J(n.valueType,r);if(n.type==="pipe"){if(e._zod.traits.has("$ZodCodec"))return!0;return J(n.in,r)||J(n.out,r)}if(n.type==="object"){for(let o in n.shape)if(J(n.shape[o],r))return!0;return!1}if(n.type==="union"){for(let o of n.options)if(J(o,r))return!0;return!1}if(n.type==="tuple"){for(let o of n.items)if(J(o,r))return!0;if(n.rest&&J(n.rest,r))return!0;return!1}return!1}var Qc=(e,t={})=>(r)=>{let n=bo({...r,processors:t});return M(e,n),wo(n,e),vo(n,e)},Rt=(e,t,r={})=>(n)=>{let{libraryOptions:o,target:s}=n??{},i=bo({...o??{},target:s,io:t,processors:r});return M(e,i),wo(i,e),vo(i,e)};var ct=(e,t,r)=>{if(e[t]===void 0||r>e[t])e[t]=r},ut=(e,t,r)=>{if(e[t]===void 0||r<e[t])e[t]=r},eu=(e,t)=>{ct(e,"minimum",t),ut(e,"maximum",t)},ou=(e,t)=>{if(e.multipleOf??(e.multipleOf=[]),!e.multipleOf.includes(t))e.multipleOf.push(t)},su=(e,t)=>{e.patterns??(e.patterns=new Set),e.patterns.add(t)},iu=(e,t)=>{e.mime=e.mime?e.mime.filter((r)=>t.includes(r)):[...t]},au=(e,t)=>{if(e.format=t,t.includes("int"))e.isInt=!0},tu=(e,t)=>ct(e,"minimum",t.minimum),ru=(e,t)=>ut(e,"maximum",t.maximum),nu=(e)=>(t,r)=>{au(t,r.format);let[n,o]=e[r.format];ct(t,"minimum",n),ut(t,"maximum",o)},Gf={greater_than:(e,t)=>ct(e,t.inclusive?"minimum":"exclusiveMinimum",t.value),less_than:(e,t)=>ut(e,t.inclusive?"maximum":"exclusiveMaximum",t.value),multiple_of:(e,t)=>ou(e,t.value),number_format:nu(cr),bigint_format:nu(Zn),min_length:tu,max_length:ru,length_equals:(e,t)=>eu(e,t.length),min_size:tu,max_size:ru,size_equals:(e,t)=>eu(e,t.size),string_format:(e,t)=>{if(au(e,t.format),t.pattern)su(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)=>iu(e,t.mime)};function ce(e){let t={},r=e._zod.def,n=e._zod.traits.has("$ZodCheck")?[e,...r.checks??[]]:r.checks??[];for(let s of n)Gf[s._zod.def.check]?.(t,s._zod.def);let o=e._zod.bag;if(o.minimum!==void 0)ct(t,"minimum",o.minimum);if(o.exclusiveMinimum!==void 0)ct(t,"exclusiveMinimum",o.exclusiveMinimum);if(o.maximum!==void 0)ut(t,"maximum",o.maximum);if(o.exclusiveMaximum!==void 0)ut(t,"exclusiveMaximum",o.exclusiveMaximum);if(o.multipleOf!==void 0)ou(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)iu(t,o.mime);for(let s of o.patterns??[])su(t,s);return t}var Wf={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},Kf=new Map([[Qn,Ii],[$r,Ai]]),cu=(e)=>Kf.get(e)??e,uu=(e,t,r,n)=>{let o=r;o.type="string";let{minimum:s,maximum:i,format:a,patterns:c,contentEncoding:u,laxFormat:l}=ce(e);if(typeof s==="number")o.minLength=s;if(typeof i==="number")o.maxLength=i;if(a){if(o.format=Wf[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(cu);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}))]}},lu=(e,t,r,n)=>{let o=r,{minimum:s,maximum:i,multipleOf:a,exclusiveMaximum:c,exclusiveMinimum:u,isInt:l}=ce(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 Ke(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:_}))]}},pu=(e,t,r,n)=>{r.type="boolean"};var du=(e,t,r,n)=>{r.not={}};var fu=(e,t,r,n)=>{};var mu=(e,t,r,n)=>{let o=e._zod.def,s=St(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 hu=(e,t,r,n)=>{Ke(e,t,r,n,"Custom types cannot be represented in JSON Schema")};var gu=(e,t,r,n)=>{Ke(e,t,r,n,"Transforms cannot be represented in JSON Schema")};var xu=(e,t,r,n)=>{let o=r,s=e._zod.def,{minimum:i,maximum:a}=ce(e);if(typeof i==="number")o.minItems=i;if(typeof a==="number")o.maxItems=a;o.type="array",o.items=M(s.element,t,{...n,path:[...n.path,"items"]})};function Lr(e){let t=e._zod.def;if(t.type==="pipe"&&t.in._zod.traits.has("$ZodTransform"))return Lr(t.out);if(t.type==="catch")return Lr(t.innerType);return e._zod.optin}var yu=(e,t,r,n)=>{let o=r,s=e._zod.def,i=s.shape;if(Object.getOwnPropertySymbols(i).length&&Ke(e,t,o,n,"Symbol keys cannot be represented in JSON Schema"))return;o.type="object",o.properties={};for(let u in i)fe(o.properties,u,M(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"?Lr(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=M(s.catchall,t,{...n,path:[...n.path,"additionalProperties"]})},_u=(e,t,r,n)=>{let o=e._zod.def,s=o.inclusive===!1,i=o.options.map((a,c)=>M(a,t,{...n,path:[...n.path,s?"oneOf":"anyOf",c]}));if(s)r.oneOf=i;else r.anyOf=i},bu=(e,t,r,n)=>{let o=e._zod.def,s=M(o.left,t,{...n,path:[...n.path,"allOf",0]}),i=M(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 $o(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=$o(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((_)=>$o(e,_,r));if(x.some((_,b)=>_!==g[b]))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")?zt:Wn).source;return f}var So=new WeakMap;function Jf(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 So.get(e)??[]){let o=e.seen.get(n),s=(o?.def??o?.schema)?.propertyNames;if(!s||s===!0||r.has(s))continue;let i=$o(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 wu=(e,t,r,n)=>{let o=r,s=e._zod.def;o.type="object";let i=s.keyType,a=ce(i).patterns;if(s.mode==="loose"&&a&&a.size>0){let l=M(s.valueType,t,{...n,path:[...n.path,"patternProperties","*"]});o.patternProperties={};for(let p of a)fe(o.patternProperties,cu(p).source,l)}else{if(t.target==="draft-07"||t.target==="draft-2020-12"){o.propertyNames=M(s.keyType,t,{...n,path:[...n.path,"propertyNames"]});let l=So.get(t);if(!l)l=[],So.set(t,l),t.deferred.push(()=>Jf(t));l.push(e)}o.additionalProperties=M(s.valueType,t,{...n,path:[...n.path,"additionalProperties"]})}let c=i._zod.values,u=t.io==="input"&&Lr(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)}},vu=(e,t,r,n)=>{let o=e._zod.def,s=M(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"}]},$u=(e,t,r,n)=>{let o=e._zod.def;M(o.innerType,t,n);let s=t.seen.get(e);s.ref=o.innerType},ko=Symbol();function Su(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 Ke(t,r,n,o,"BigInt defaults cannot be represented in JSON Schema"),ko}var ku=(e,t,r,n)=>{let o=e._zod.def;M(o.innerType,t,n);let s=t.seen.get(e);s.ref=o.innerType;let i=Su(o.defaultValue,e,t,r,n);if(i!==ko)r.default=i},Pu=(e,t,r,n)=>{let o=e._zod.def;M(o.innerType,t,n);let s=t.seen.get(e);if(s.ref=o.innerType,t.io!=="input")return;let i=Su(o.defaultValue,e,t,r,n);if(i!==ko)r._prefault=i},zu=(e,t,r,n)=>{let o=e._zod.def;M(o.innerType,t,n);let s=t.seen.get(e);s.ref=o.innerType;let i;try{i=o.catchValue(void 0)}catch{Ke(e,t,r,n,"Dynamic catch values are not supported in JSON Schema");return}r.default=i},Eu=(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;M(i,t,n);let a=t.seen.get(e);a.ref=i},Cu=(e,t,r,n)=>{let o=e._zod.def;M(o.innerType,t,n);let s=t.seen.get(e);s.ref=o.innerType,r.readOnly=!0};var Po=(e,t,r,n)=>{let o=e._zod.def;M(o.innerType,t,n);let s=t.seen.get(e);s.ref=o.innerType};var Ou=new WeakSet([Object.prototype,Error.prototype]);function Dr(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 nm=(e,t)=>{ai.init(e,t),e.name="ZodError";let r=Object.getPrototypeOf(e);if(Ou.has(r))return;Ou.add(r),Dr(r,"format",(n)=>(o)=>Un(n,o)),Dr(r,"flatten",(n)=>(o)=>Fn(n,o)),Dr(r,"addIssue",(n)=>(o)=>{n.issues.push(o),n.message=JSON.stringify(n.issues,kt,2)}),Dr(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 ne=h("ZodError",nm,void 0,{Parent:Error});var Tu=mr(ne),Iu=hr(ne),Au=gr(ne),Ru=xr(ne),Zu=ui(ne),ju=li(ne),Lu=pi(ne),Du=di(ne),Nu=fi(ne),Fu=mi(ne),Uu=hi(ne),Mu=gi(ne);function sm(){if(!H.localeError)q(so())}function Fr(){if(!H.memoizer)q({memoizer:oo()})}var N=h("ZodType",(e,t)=>(sm(),j.init(e,t),e.def=t,e.type=t.type,e),{check(...e){let t=this.def;return this.clone(re(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 me(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(Xm(e,t))},superRefine(e,t){return this.check(Qm(e,t))},overwrite(e){return this.check(Fe(e))},optional(){return Wu(this)},exactOptional(){return Nm(this)},nullable(){return Ku(this)},nullish(){return Wu(Ku(this))},nonoptional(e){return Gm(this,e)},array(){return Se(this)},or(e){return Ur([this,e])},and(e){return Zm(this,e)},transform(e){return Ju(this,Dm(e))},default(e){return Mm(this,e)},prefault(e){return Vm(this,e)},catch(e){return Km(this,e)},pipe(e){return Ju(this,e)},readonly(){return qm(this)},describe(e){let t=this.clone();return Ne.add(t,{description:e}),t},meta(...e){if(e.length===0)return Ne.get(this);let t=this.clone();return Ne.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 dr(this,"~standard",{...Xn(this),jsonSchema:{input:Rt(this,"input"),output:Rt(this,"output")}})},set "~standard"(e){Ce(this,"~standard",e)},parse:function e(t,r){return Tu(this,t,r,{callee:e})},parseAsync:async function e(t,r){return await Iu(this,t,r,{callee:e})},safeParse(e,t){return Au(this,e,t)},async safeParseAsync(e,t){return Ru(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){Ce(this,"spa",e)},validate(e,t){return Mn(this,e,t)},validateAsync(e,t){return Bn(this,e,t)},encode:function e(t,r){return Zu(this,t,r,{callee:e})},decode:function e(t,r){return ju(this,t,r,{callee:e})},encodeAsync:async function e(t,r){return await Lu(this,t,r,{callee:e})},decodeAsync:async function e(t,r){return await Du(this,t,r,{callee:e})},safeEncode(e,t){return Nu(this,e,t)},safeDecode(e,t){return Fu(this,e,t)},async safeEncodeAsync(e,t){return Uu(this,e,t)},async safeDecodeAsync(e,t){return Mu(this,e,t)},toJSONSchema(e){return Qc(this,{})(e)},get description(){return Ne.get(this)?.description},get _def(){return this._zod.def}}),Hu=h("_ZodString",(e,t)=>{vr.init(e,t),N.init(e,t),e._zod.processJSONSchema=(r,n,o)=>uu(e,r,n,o)},ti({format:(e)=>ce(e).format??null,minLength:(e)=>ce(e).minimum??null,maxLength:(e)=>ce(e).maximum??null},{regex(...e){return this.check(ao(...e))},includes(...e){return this.check(lo(...e))},startsWith(...e){return this.check(po(...e))},endsWith(...e){return this.check(fo(...e))},min(...e){return this.check(at(...e))},max(...e){return this.check(Zr(...e))},length(...e){return this.check(jr(...e))},nonempty(...e){return this.check(at(1,...e))},lowercase(e){return this.check(co(e))},uppercase(e){return this.check(uo(e))},trim(){return this.check(ho())},normalize(...e){return this.check(mo(...e))},toLowerCase(){return this.check(go())},toUpperCase(){return this.check(xo())},slugify(){return this.check(yo())}})),im=h("ZodString",(e,t)=>{vr.init(e,t),Hu.init(e,t)},{email(e){return this.check(_c(am,e))},url(e){return this.check(io(qu,e))},jwt(e){return this.check(Nc(Sm,e))},emoji(e){return this.check(kc(lm,e))},guid(e){return this.check(bc(cm,e))},uuid(e){return this.check(wc(Nr,e))},uuidv4(e){return this.check(vc(Nr,e))},uuidv6(e){return this.check($c(Nr,e))},uuidv7(e){return this.check(Sc(Nr,e))},nanoid(e){return this.check(Pc(pm,e))},cuid(e){return this.check(zc(dm,e))},cuid2(e){return this.check(Ec(fm,e))},ulid(e){return this.check(Cc(mm,e))},base64(e){return this.check(jc(wm,e))},base64url(e){return this.check(Lc(vm,e))},xid(e){return this.check(Oc(hm,e))},ksuid(e){return this.check(Tc(gm,e))},ipv4(e){return this.check(Ic(xm,e))},ipv6(e){return this.check(Ac(ym,e))},cidrv4(e){return this.check(Rc(_m,e))},cidrv6(e){return this.check(Zc(bm,e))},e164(e){return this.check(Dc($m,e))},datetime(e){return this.check(Er(jt,e))},date(e){return this.check(Cr(Lt,e))},time(e){return this.check(Or(Dt,e))},duration(e){return this.check(Tr(Nt,e))}});function v(e){return yc(im,e)}var L=h("ZodStringFormat",(e,t)=>{R.init(e,t),Hu.init(e,t)}),jt=h("ZodISODateTime",(e,t)=>{Ea.init(e,t),L.init(e,t)}),Lt=h("ZodISODate",(e,t)=>{Ca.init(e,t),L.init(e,t)}),Dt=h("ZodISOTime",(e,t)=>{Oa.init(e,t),L.init(e,t)}),Nt=h("ZodISODuration",(e,t)=>{Ta.init(e,t),L.init(e,t)}),am=h("ZodEmail",(e,t)=>{xa.init(e,t),L.init(e,t)});var cm=h("ZodGUID",(e,t)=>{ha.init(e,t),L.init(e,t)});var Nr=h("ZodUUID",(e,t)=>{ga.init(e,t),L.init(e,t)});var qu=h("ZodURL",(e,t)=>{ba.init(e,t),L.init(e,t)});function um(e){return io(qu,e)}var lm=h("ZodEmoji",(e,t)=>{wa.init(e,t),L.init(e,t)});var pm=h("ZodNanoID",(e,t)=>{va.init(e,t),L.init(e,t)});var dm=h("ZodCUID",(e,t)=>{$a.init(e,t),L.init(e,t)});var fm=h("ZodCUID2",(e,t)=>{Sa.init(e,t),L.init(e,t)});var mm=h("ZodULID",(e,t)=>{ka.init(e,t),L.init(e,t)});var hm=h("ZodXID",(e,t)=>{Pa.init(e,t),L.init(e,t)});var gm=h("ZodKSUID",(e,t)=>{za.init(e,t),L.init(e,t)});var xm=h("ZodIPv4",(e,t)=>{Ia.init(e,t),L.init(e,t)});var ym=h("ZodIPv6",(e,t)=>{Ra.init(e,t),L.init(e,t)});var _m=h("ZodCIDRv4",(e,t)=>{Za.init(e,t),L.init(e,t)});var bm=h("ZodCIDRv6",(e,t)=>{ja.init(e,t),L.init(e,t)});var wm=h("ZodBase64",(e,t)=>{Da.init(e,t),L.init(e,t)});var vm=h("ZodBase64URL",(e,t)=>{Na.init(e,t),L.init(e,t)});var $m=h("ZodE164",(e,t)=>{Fa.init(e,t),L.init(e,t)});var Sm=h("ZodJWT",(e,t)=>{Ua.init(e,t),L.init(e,t)});var Yu=h("ZodNumber",(e,t)=>{eo.init(e,t),N.init(e,t),e._zod.processJSONSchema=(r,n,o)=>lu(e,r,n,o),e.isFinite=!0},ti({minValue:(e)=>{let{minimum:t,exclusiveMinimum:r}=ce(e);return Math.max(t??Number.NEGATIVE_INFINITY,r??Number.NEGATIVE_INFINITY)},maxValue:(e)=>{let{maximum:t,exclusiveMaximum:r}=ce(e);return Math.min(t??Number.POSITIVE_INFINITY,r??Number.POSITIVE_INFINITY)},isInt:(e)=>{let{isInt:t,multipleOf:r}=ce(e);return!!t||!!r?.some(Number.isSafeInteger)},format:(e)=>ce(e).format??null},{gt(e,t){return this.check(Ar(e,t))},gte(e,t){return this.check(It(e,t))},min(e,t){return this.check(It(e,t))},lt(e,t){return this.check(Ir(e,t))},lte(e,t){return this.check(Tt(e,t))},max(e,t){return this.check(Tt(e,t))},int(e){return this.check(Bu(e))},safe(e){return this.check(Bu(e))},positive(e){return this.check(Ar(0,e))},nonnegative(e){return this.check(It(0,e))},negative(e){return this.check(Ir(0,e))},nonpositive(e){return this.check(Tt(0,e))},multipleOf(e,t){return this.check(Rr(e,t))},step(e,t){return this.check(Rr(e,t))},finite(){return this}}));function Xu(e){return Fc(Yu,e)}var km=h("ZodNumberFormat",(e,t)=>{Ma.init(e,t),Yu.init(e,t)});function Bu(e){return Uc(km,e)}var Pm=h("ZodBoolean",(e,t)=>{Ba.init(e,t),N.init(e,t),e._zod.processJSONSchema=(r,n,o)=>pu(e,r,n,o)});function zm(e){return Mc(Pm,e)}var Em=h("ZodUnknown",(e,t)=>{Va.init(e,t),N.init(e,t),e._zod.processJSONSchema=(r,n,o)=>fu(e,r,n,o)});function Vu(){return Bc(Em)}var Cm=h("ZodNever",(e,t)=>{Ga.init(e,t),N.init(e,t),e._zod.processJSONSchema=(r,n,o)=>du(e,r,n,o)});function Om(e){return Vc(Cm,e)}var Tm=h("ZodArray",(e,t)=>{Fr(),Wa.init(e,t),N.init(e,t),e._zod.processJSONSchema=(r,n,o)=>xu(e,r,n,o),e.element=t.element},{min(e,t){return this.check(at(e,t))},nonempty(e){return this.check(at(1,e))},max(e,t){return this.check(Zr(e,t))},length(e,t){return this.check(jr(e,t))},unwrap(){return this.element}});function Se(e,t){return Gc(Tm,e,t)}var Im=h("ZodObject",(e,t)=>{Fr(),Ha.init(e,t),N.init(e,t),e._zod.processJSONSchema=(r,n,o)=>yu(e,r,n,o),ff(e,"shape",(r)=>r._zod.def.shape,!1)},{keyof(){return jm(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(re(this._zod.def,{catchall:e}))},passthrough(){return this.clone(re(this._zod.def,{catchall:Vu()}))},loose(){return this.clone(re(this._zod.def,{catchall:Vu()}))},strict(){return this.clone(re(this._zod.def,{catchall:Om()}))},strip(){return this.clone(re(this._zod.def,{catchall:void 0}))},extend(e){return of(this,e)},safeExtend(e){return sf(this,e)},merge(e){return af(this,e)},pick(e){return rf(this,e)},omit(e){return nf(this,e)},partial(...e){return Ys(Qu,this,e[0])},exactPartial(...e){return Ys(el,this,e[0],"exactPartial")},required(...e){return cf(tl,this,e[0])}});function I(e,t){let r={type:"object",shape:e??{},...w(t)};return new Im(r)}var Am=h("ZodUnion",(e,t)=>{qa.init(e,t),N.init(e,t),e._zod.processJSONSchema=(r,n,o)=>_u(e,r,n,o),e.options=t.options});function Ur(e,t){return new Am({type:"union",options:e,...w(t)})}var Rm=h("ZodIntersection",(e,t)=>{Ya.init(e,t),N.init(e,t),e._zod.processJSONSchema=(r,n,o)=>bu(e,r,n,o)});function Zm(e,t){return new Rm({type:"intersection",left:e,right:t})}var Gu=h("ZodRecord",(e,t)=>{Fr(),Xa.init(e,t),N.init(e,t),e._zod.processJSONSchema=(r,n,o)=>wu(e,r,n,o),e.keyType=t.keyType,e.valueType=t.valueType});function lt(e,t,r){if(!t||!t._zod)return new Gu({type:"record",keyType:v(),valueType:e,...w(t)});return new Gu({type:"record",keyType:e,valueType:t,...w(r)})}var zo=h("ZodEnum",(e,t)=>{Qa.init(e,t),N.init(e,t),e._zod.processJSONSchema=(n,o,s)=>mu(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 zo({...t,checks:[],...w(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 zo({...t,checks:[],...w(o),entries:s})}});function jm(e,t){let r=Array.isArray(e)?Object.fromEntries(e.map((n)=>[n,n])):e;return new zo({type:"enum",entries:r,...w(t)})}var Lm=h("ZodTransform",(e,t)=>{Fr(),ec.init(e,t),N.init(e,t),e._zod.processJSONSchema=(r,n,o)=>gu(e,r,n,o),e._zod.parse=(r,n)=>{if(n.direction==="backward")throw new Pt(e.constructor.name);r.addIssue=(s)=>{if(typeof s==="string")r.issues.push(We(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(We(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 Dm(e){return new Lm({type:"transform",transform:e})}var Qu=h("ZodOptional",(e,t)=>{to.init(e,t),N.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Po(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function Wu(e){return new Qu({type:"optional",innerType:e})}var el=h("ZodExactOptional",(e,t)=>{tc.init(e,t),N.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Po(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function Nm(e){return new el({type:"optional",innerType:e})}var Fm=h("ZodNullable",(e,t)=>{rc.init(e,t),N.init(e,t),e._zod.processJSONSchema=(r,n,o)=>vu(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function Ku(e){return new Fm({type:"nullable",innerType:e})}var Um=h("ZodDefault",(e,t)=>{nc.init(e,t),N.init(e,t),e._zod.processJSONSchema=(r,n,o)=>ku(e,r,n,o),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Mm(e,t){return new Um({type:"default",innerType:e,get defaultValue(){return typeof t==="function"?t():An(t)}})}var Bm=h("ZodPrefault",(e,t)=>{oc.init(e,t),N.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Pu(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function Vm(e,t){return new Bm({type:"prefault",innerType:e,get defaultValue(){return typeof t==="function"?t():An(t)}})}var tl=h("ZodNonOptional",(e,t)=>{sc.init(e,t),N.init(e,t),e._zod.processJSONSchema=(r,n,o)=>$u(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function Gm(e,t){return new tl({type:"nonoptional",innerType:e,...w(t)})}var Wm=h("ZodCatch",(e,t)=>{ic.init(e,t),N.init(e,t),e._zod.processJSONSchema=(r,n,o)=>zu(e,r,n,o),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function Km(e,t){return new Wm({type:"catch",innerType:e,catchValue:typeof t==="function"?t:ri(t)})}var Jm=h("ZodPipe",(e,t)=>{ac.init(e,t),N.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Eu(e,r,n,o),e.in=t.in,e.out=t.out});function Ju(e,t){return new Jm({type:"pipe",in:e,out:t})}var Hm=h("ZodReadonly",(e,t)=>{cc.init(e,t),N.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Cu(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function qm(e){return new Hm({type:"readonly",innerType:e})}var Ym=h("ZodCustom",(e,t)=>{uc.init(e,t),N.init(e,t),e._zod.processJSONSchema=(r,n,o)=>hu(e,r,n,o)});function Xm(e,t={}){return Wc(Ym,e,t)}function Qm(e,t){return Kc(e,t)}var Mr={};Xd(Mr,{ZodISODate:()=>Lt,ZodISODateTime:()=>jt,ZodISODuration:()=>Nt,ZodISOTime:()=>Dt,date:()=>th,datetime:()=>eh,duration:()=>nh,time:()=>rh});function eh(e){return Er(jt,e)}function th(e){return Cr(Lt,e)}function rh(e){return Or(Dt,e)}function nh(e){return Tr(Nt,e)}var Hl=nt(Ft(),1);var ah=["emacs","vim"],ch=new Set(ah);function uh(e){return ch.has(e)}function ol(){let e=process.env.INQUIRER_KEYBINDINGS;if(!e)return[];return Array.from(new Set(e.toLowerCase().split(/[\s,]+/).filter(uh)))}var Ut=(e,t=[])=>e.name==="up"||t.includes("vim")&&e.name==="k"||t.includes("emacs")&&e.ctrl&&e.name==="p",Gr=(e,t=[])=>e.name==="down"||t.includes("vim")&&e.name==="j"||t.includes("emacs")&&e.ctrl&&e.name==="n";var Mt=(e)=>e.name==="backspace",Bt=(e)=>e.name==="tab",Co=(e)=>"1234567890".includes(e.name),Oe=(e)=>e.name==="enter"||e.name==="return";class Oo extends Error{name="AbortPromptError";message="Prompt was aborted";constructor(e){super();this.cause=e?.cause}}class To extends Error{name="CancelPromptError";message="Prompt was canceled"}class Wr extends Error{name="ExitPromptError"}class Io extends Error{name="HookError"}class Vt extends Error{name="ValidationError"}import{AsyncResource as fh}from"node:async_hooks";import{AsyncLocalStorage as lh,AsyncResource as ph}from"node:async_hooks";var sl=new lh;function dh(e){return{rl:e,hooks:[],hooksCleanup:[],hooksEffect:[],index:0,handleChange(){}}}function il(e,t){let r=dh(e);return sl.run(r,()=>{function n(o){r.handleChange=()=>{r.index=0,o()},r.handleChange()}return t(n)})}function He(){let e=sl.getStore();if(!e)throw new Io("[Inquirer] Hook functions can only be called from within a prompt");return e}function Ao(){return He().rl}function Ro(e){let t=(...r)=>{let n=He(),o=!1,s=n.handleChange;n.handleChange=()=>{o=!0};let i=e(...r);if(o)s();return n.handleChange=s,i};return ph.bind(t)}function pt(e){let t=He(),{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 al(){He().handleChange()}var Gt={queue(e){let t=He(),{index:r}=t;t.hooksEffect.push(()=>{t.hooksCleanup[r]?.();let n=e(Ao());if(n!=null&&typeof n!=="function")throw new Vt("useEffect return value must be a cleanup function or nothing.");t.hooksCleanup[r]=n})},run(){let e=He();Ro(()=>{e.hooksEffect.forEach((t)=>{t()}),e.hooksEffect.length=0})()},clearAll(){let e=He();e.hooksCleanup.forEach((t)=>{t?.()}),e.hooksEffect.length=0,e.hooksCleanup.length=0}};function mh(e){return typeof e==="function"}function hh(e){return typeof e==="function"}function D(e){return pt((t)=>{let r=fh.bind(function(s){let i=t.get(),a=hh(s)?s(i):s;if(!Object.is(i,a))t.set(a),al()});if(t.initialized)return[t.get(),r];let n=mh(e)?e():e;return t.set(n),[n,r]})}function Te(e,t){pt((r)=>{let n=r.get();if(!Array.isArray(n)||t.some((s,i)=>!Object.is(s,n[i])))Gt.queue(e);r.set(t)})}import{styleText as ge}from"node:util";import he from"node:process";function gh(){if(!he.platform.startsWith("win"))return he.env.TERM!=="linux";return Boolean(he.env.CI)||Boolean(he.env.WT_SESSION)||Boolean(he.env.TERMINUS_SUBLIME)||he.env.ConEmuTask==="{cmd::Cmder}"||he.env.TERM_PROGRAM==="Terminus-Sublime"||he.env.TERM_PROGRAM==="vscode"||he.env.TERM==="xterm-256color"||he.env.TERM==="alacritty"||he.env.TERMINAL_EMULATOR==="JetBrains-JediTerm"}var cl={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:"╱"},ul={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:"⅒"},xh={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"},yh={...cl,...ul},_h={...cl,...xh},bh=gh(),wh=bh?yh:_h,dt=wh,yw=Object.entries(ul);var vh={prefix:{idle:ge("blue","?"),done:ge("green",dt.tick)},spinner:{interval:80,frames:["⠋","⠙","⠹","⠸","⠼","⠴","⠦","⠧","⠇","⠏"].map((e)=>ge("yellow",e))},keybindings:[],style:{answer:(e)=>ge("cyan",e),message:(e)=>ge("bold",e),error:(e)=>ge("red",`> ${e}`),defaultAnswer:(e)=>ge("dim",`(${e})`),help:(e)=>ge("dim",e),highlight:(e)=>ge("cyan",e),key:(e)=>ge("cyan",ge("bold",`<${e}>`))}};function ll(){return{...vh,keybindings:ol()}}function pl(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 dl(...e){let t={};for(let r of e)for(let[n,o]of Object.entries(r)){let s=t[n];t[n]=pl(s)&&pl(o)?dl(s,o):o}return t}function xe(...e){let t=[ll(),...e.filter((r)=>r!=null)];return dl(...t)}function Ie({status:e="idle",theme:t}){let[r,n]=D(!1),[o,s]=D(0),{prefix:i,spinner:a}=xe(t);if(Te(()=>{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 Wt(e,t){return pt((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 qe(e){return D({current:e})[0]}function Ae(e){let t=qe(e);t.current=e,Te((r)=>{let n=!1,o=Ro((s,i)=>{if(n)return;t.current(i,r)});return r.input.on("keypress",o),()=>{n=!0,r.input.removeListener("keypress",o)}},[])}var Ol=nt(ml(),1);var hl=(()=>{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}})(),gl=(e)=>e===12288||e>=65281&&e<=65376||e>=65504&&e<=65510,xl=(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 kh=/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]|\u001b\]8;[^;]*;.*?(?:\u0007|\u001b\u005c)/y,Ph=/[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y,yl=/(?:(?![\uFF61-\uFF9F\uFF00-\uFFEF])[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}\p{Script=Tangut}]){1,1000}/yu,zh=/\t{1,1000}/y,_l=/[\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,Eh=/(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y,Ch=/\p{M}+/gu,Oh={limit:1/0,ellipsis:""},bl=(e,t={},r={})=>{let n=t.limit??1/0,o=t.ellipsis??"",s=t?.ellipsisWidth??(o?bl(o,Oh,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=[[Eh,p],[kh,0],[Ph,a],[zh,c],[_l,u],[yl,d]],m=0,g=0,x=e.length,_=0,b=!1,k=x,z=Math.max(0,n-s),y=0,S=0,E=0,G=0;e:while(!0){if(S>y||g>=x&&g>m){let P=e.slice(y,S)||e.slice(m,g);_=0;for(let C of P.replaceAll(Ch,"")){let U=C.codePointAt(0)||0;if(gl(U))G=2;else if(xl(U))G=d;else G=p;if(E+G>z)k=Math.min(k,Math.max(y,m)+_);if(E+G>n){b=!0;break e}_+=C.length,E+=G}y=S=0}if(g>=x)break e;for(let P=0,C=f.length;P<C;P++){let[U,W]=f[P];if(U.lastIndex=g,U.test(e)){if(_=U===yl?hl(e.slice(g,U.lastIndex)):U===_l?1:U.lastIndex-g,G=_*W,E+G>z)k=Math.min(k,g+Math.floor((z-E)/W));if(E+G>n){b=!0;break e}E+=G,y=m,S=g,g=m=U.lastIndex;continue e}}g+=1}return{width:b?z:E,index:b?k:x,truncated:b,ellipsed:b&&n>=s}},wl=bl;var Th={limit:1/0,ellipsis:"",ellipsisWidth:0},Ih=(e,t={})=>wl(e,Th,t).width,Re=Ih;var Kr="\x1B",Pl="",Ah=39,jo="\x07",zl="[",Rh="]",El="m",Lo=`${Rh}8;;`,vl=new RegExp(`(?:\\${zl}(?<code>\\d+)m|\\${Lo}(?<uri>.*)${jo})`,"y"),$l=(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},Sl=(e)=>`${Kr}${zl}${e}${El}`,kl=(e)=>`${Kr}${Lo}${e}${jo}`,Zo=(e,t,r)=>{let n=t[Symbol.iterator](),o=!1,s=!1,i=e.at(-1),a=i===void 0?0:Re(i),c=n.next(),u=n.next(),l=0;while(!c.done){let p=c.value,d=Re(p);if(a+d<=r)e[e.length-1]+=p;else e.push(p),a=0;if(p===Kr||p===Pl)o=!0,s=t.startsWith(Lo,l+1);if(o){if(s){if(p===jo)o=!1,s=!1}else if(p===El)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()},Zh=(e)=>{let t=e.split(" "),r=t.length;while(r){if(Re(t[r-1]))break;r--}if(r===t.length)return e;return t.slice(0,r).join(" ")+t.slice(r).join("")},jh=(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=Re(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=Re(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("");Zo(a,d,t),c=Re(a.at(-1)??"");continue}if(c+f>t&&c&&f){if(r.wordWrap===!1&&c<t){Zo(a,d,t),c=Re(a.at(-1)??"");continue}a.push(""),c=0}if(c+f>t&&r.wordWrap===!1){Zo(a,d,t),c=Re(a.at(-1)??"");continue}a[a.length-1]+=d,c+=f}if(r.trim!==!1)a=a.map((p)=>Zh(p));let u=a.join(`
|
|
60
|
+
`),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===Kr||d===Pl){vl.lastIndex=p+1;let m=vl.exec(u)?.groups;if(m?.code!==void 0){let g=Number.parseFloat(m.code);o=g===Ah?void 0:g}else if(m?.uri!==void 0)s=m.uri.length===0?void 0:m.uri}if(u[p+1]===`
|
|
61
|
+
`){if(s)n+=kl("");let f=o?$l(o):void 0;if(o&&f)n+=Sl(f)}else if(d===`
|
|
62
|
+
`){if(o&&$l(o))n+=Sl(o);if(s)n+=kl(s)}}return n},Lh=/\r?\n/;function Cl(e,t,r){return String(e).normalize().split(Lh).map((n)=>jh(n,t,r)).join(`
|
|
63
63
|
`)}function Kt(e,t){return e.split(`
|
|
64
|
-
`).flatMap((r)=>
|
|
64
|
+
`).flatMap((r)=>Cl(r,t,{trim:!1,wordWrap:!1}).split(`
|
|
65
65
|
`).map((n)=>n.trimEnd())).join(`
|
|
66
|
-
`)}function Jr(){return
|
|
67
|
-
`)}),c=a.reduce((_,b)=>_+b.length,0),u=(_)=>a[_]??[],l=
|
|
68
|
-
`)}var
|
|
69
|
-
`).length,
|
|
70
|
-
`).pop()??"";class Yr{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=
|
|
66
|
+
`)}function Jr(){return Ol.default({defaultWidth:80,output:Ao().output})}function Dh({active:e,renderedItems:t,pageSize:r,loop:n}){let o=qe({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 Do({items:e,active:t,renderItem:r,pageSize:n,loop:o=!0}){let s=Jr(),i=(_)=>(_%e.length+e.length)%e.length,a=e.map((_,b)=>{if(_==null)return[];return Kt(r({item:_,index:b,isActive:b===t}),s).split(`
|
|
67
|
+
`)}),c=a.reduce((_,b)=>_+b.length,0),u=(_)=>a[_]??[],l=Dh({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 b=u(x).slice(0,n-g);f.splice(g,b.length,...b),m.add(x),g+=b.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),b=_.slice(Math.max(0,_.length-g-1));f.splice(g-b.length+1,b.length,...b),m.add(x),g-=b.length,x=i(x-1)}return f.filter((_)=>typeof _==="string").join(`
|
|
68
|
+
`)}var Ml=nt(Al(),1);import*as Ul from"node:readline";import{AsyncResource as Vh}from"node:async_hooks";var Ye=[];Ye.push("SIGHUP","SIGINT","SIGTERM");if(process.platform!=="win32")Ye.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");if(process.platform==="linux")Ye.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var Hr=(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",No=Symbol.for("signal-exit emitter"),Fo=globalThis,Fh=Object.defineProperty.bind(Object);class Rl{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(Fo[No])return Fo[No];Fh(Fo,No,{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 Mo{}var Uh=(e)=>({onExit(t,r){return e.onExit(t,r)},load(){return e.load()},unload(){return e.unload()}});class Zl extends Mo{onExit(){return()=>{}}load(){}unload(){}}class jl extends Mo{#r=Uo.platform==="win32"?"SIGINT":"SIGHUP";#t=new Rl;#e;#s;#i;#o={};#n=!1;constructor(e){super();this.#e=e,this.#o={};for(let t of Ye)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(!Hr(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 Ye)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,Ye.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(!Hr(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"&&Hr(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 Uo=globalThis.process,{onExit:Ll,load:tv,unload:rv}=Uh(Hr(Uo)?new jl(Uo):new Zl);import{stripVTControlCharacters as Mh}from"node:util";var Bo="\x1B[G",qr="\x1B[?25l",Nl="\x1B[?25h",Vo=(e=1)=>e>0?`\x1B[${e}A`:"",Go=(e=1)=>e>0?`\x1B[${e}B`:"",Wo=(e,t)=>{if(typeof t==="number"&&!Number.isNaN(t))return`\x1B[${t+1};${e+1}H`;return`\x1B[${e+1}G`},Dl="\x1B[2K",Ko=(e)=>e>0?(Dl+Vo(1)).repeat(e-1)+Dl+Bo:"";var Fl=(e)=>e.split(`
|
|
69
|
+
`).length,Bh=(e)=>e.split(`
|
|
70
|
+
`).pop()??"";class Yr{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=Bh(e),n=Mh(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=Jr();if(e=Kt(e,s),t=Kt(t,s),n.length%s===0)e+=`
|
|
71
71
|
`;let i=e+(t?`
|
|
72
|
-
`+t:""),c=Math.floor(n.length/s)-this.cursorPos.rows+(t?
|
|
73
|
-
`,t+=Bo,t+=
|
|
74
|
-
at ${C}`)}let[G,P]=typeof E==="string"?[E]:E;l.render(G,P),Gt.run()}catch(E){b(E)}if(S=!0,y!==null){let{value:E}=y;y=null,_(E)}})};if("readableFlowing"in s)
|
|
75
|
-
`);return[_,b]});import{styleText as Jt}from"node:util";var
|
|
76
|
-
`).trimEnd()}${qr}`});var ye=nt(Ft(),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 F=(e,t)=>new O(e,{exitCode:2,hint:t}),Ht=(e)=>e<1000?`${Math.round(e)}ms`:`${Math.round(e/1000)}s`,
|
|
77
|
-
`)},V=(e)=>{
|
|
72
|
+
`+t:""),c=Math.floor(n.length/s)-this.cursorPos.rows+(t?Fl(t):0);if(c>0)i+=Vo(c);i+=Wo(this.cursorPos.cols),this.write(Go(this.extraLinesUnderPrompt)+Ko(this.height)+i),this.extraLinesUnderPrompt=c,this.height=Fl(i)}checkCursorPos(){let e=this.rl.getCursorPos();if(e.cols!==this.cursorPos.cols)this.write(Wo(e.cols)),this.cursorPos=e}done({clearContent:e}){this.rl.setPrompt("");let t=Go(this.extraLinesUnderPrompt);t+=e?Ko(this.height):`
|
|
73
|
+
`,t+=Bo,t+=Nl,this.write(t),this.rl.close()}}class Jo extends Promise{static withResolver(){let e,t;return{promise:new Promise((n,o)=>{e=n,t=o}),resolve:e,reject:t}}}import Gh from"node:path";var Wh=globalThis.setImmediate;function Xr(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 Kh(){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 Ze(e){let t=Kh();return(n,o={})=>{let{input:s=process.stdin,signal:i}=o,a=new Set,c=new Ml.default;c.pipe(o.output??process.stdout);let u=Ul.createInterface({terminal:!0,input:s,output:c});c.mute();let l=new Yr(u),{promise:p,resolve:d,reject:f}=Jo.withResolver();return il(u,(m)=>{let g=Vh.bind(()=>Gt.clearAll()),x=(y)=>{try{g(),y()}catch(S){f(S)}},_=(y)=>x(()=>d(y)),b=(y)=>x(()=>f(y)),k=Object.assign(p.finally(()=>{a.forEach((y)=>y()),l.done({clearContent:Boolean(o.clearPromptOnDone)}),c.end()}).then(()=>p),{cancel:()=>b(new To)});if(i){let y=()=>b(new Oo({cause:i.reason}));if(i.aborted)return y(),k;a.add(Xr(i,"abort",y))}a.add(Ll((y,S)=>{b(new Wr(`User force closed the prompt with ${y} ${S}`))})),a.add(Xr(u,"SIGINT",()=>b(new Wr("User force closed the prompt with SIGINT")))),a.add(Xr(u,"close",g));let z=()=>{a.add(Xr(u.input,"keypress",()=>l.checkCursorPos()));let y=null;m(()=>{let S=!1;try{let E=e(n,(C)=>{if(S)_(C);else y={value:C}});if(E===void 0){let C=t[1]?.getFileName();if(C&&!C.startsWith("file://"))C=Gh.resolve(C);throw Error(`Prompt functions must return a string.
|
|
74
|
+
at ${C}`)}let[G,P]=typeof E==="string"?[E]:E;l.render(G,P),Gt.run()}catch(E){b(E)}if(S=!0,y!==null){let{value:E}=y;y=null,_(E)}})};if("readableFlowing"in s)Wh(z);else z();return k})}}import{styleText as Jh}from"node:util";class ke{separator=Jh("dim",Array.from({length:15}).join(dt.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 Hh}from"node:util";var qh={keywords:{yes:"Yes",no:"No"},style:{confirmDefault:(e)=>{let t=e[0]??"";if(t.toLowerCase()===t.toUpperCase())return Hh("cyan",e);return t.toUpperCase()+e.slice(1)}}},Ho=Ze((e,t)=>{let[r,n]=D("idle"),[o,s]=D(""),i=xe(qh,e.theme),a=Ie({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(k){return k?c:u}let{transformer:m=f}=e;function g(k,z){let y=k.trim().toLowerCase();if(y==="")return z!==!1;if(c.toLowerCase().startsWith(y))return!0;if(u.toLowerCase().startsWith(y))return!1;return z!==!1}Ae((k,z)=>{if(r!=="idle")return;if(Oe(k)){let y=g(o,e.default);s(m(y)),n("done"),t(y)}else if(Bt(k)){let y=f(!g(o,e.default));z.clearLine(0),z.write(y),s(y)}else s(z.line)});let x=o,_="";if(r==="done")x=i.style.answer(o);else _=` ${i.style.defaultAnswer(d)}`;let b=i.style.message(e.message,r);return`${a} ${b}${_} ${x}`});var Yh={validationFailureMode:"keep"},qo=Ze((e,t)=>{let{prefill:r="tab"}=e,n=xe(Yh,e.theme),[o,s]=D("idle"),[i,a]=D(String(e.default??"")),[c,u]=D(),[l,p]=D(""),d=Ie({status:o,theme:n});async function f(b){let{required:k,pattern:z,patternError:y="Invalid input"}=e;if(k&&!b)return"You must provide a value";if(z&&!z.test(b))return y;if(typeof e.validate==="function")return await e.validate(b)||"You must provide a valid value";return!0}Ae(async(b,k)=>{if(o!=="idle")return;if(Oe(b)){let z=l||i;s("loading");let y=await f(z);if(y===!0)p(z),s("done"),t(z);else{if(n.validationFailureMode==="clear")p("");else k.write(l);u(y),s("idle")}}else if(Mt(b)&&!l)a("");else if(Bt(b)&&!l)a(""),k.clearLine(0),k.write(i),p(i);else p(k.line),u(void 0)}),Te((b)=>{if(r==="editable"&&i)b.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((b)=>b!==void 0).join(" "),_]});import{styleText as Yo}from"node:util";var Xh={style:{maskedText:"[input is masked]",keysHelpTip:(e)=>e.map(([t,r])=>`${Yo("bold",t)} ${Yo("dim",r)}`).join(Yo("dim"," • "))}},Xo=Ze((e,t)=>{let{toggleMask:r=!0,validate:n=()=>!0}=e,o=xe(Xh,e.theme),[s,i]=D("idle"),[a,c]=D(),[u,l]=D(""),[p,d]=D(!1),f=Ie({status:s,theme:o});Ae(async(k,z)=>{if(s!=="idle")return;if(Oe(k)){let y=u;i("loading");let S=await n(y);if(S===!0)l(y),i("done"),t(y);else z.write(u),c(S||"You must provide a valid value"),i("idle")}else if(r&&k.ctrl&&k.name==="t")d((y)=>!y);else l(z.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+=qr;let _=[f,m,x].filter(Boolean).join(" "),b=[a?o.style.error(a):"",r&&s==="idle"?o.style.keysHelpTip([["ctrl+t","toggle visibility"]]):""].filter(Boolean).join(`
|
|
75
|
+
`);return[_,b]});import{styleText as Jt}from"node:util";var Qh={icon:{cursor:dt.pointer},style:{disabled:(e)=>Jt("dim",e),description:(e)=>Jt("cyan",e),keysHelpTip:(e)=>e.map(([t,r])=>`${Jt("bold",t)} ${Jt("dim",r)}`).join(Jt("dim"," • "))},i18n:{disabledError:"This option is disabled and cannot be selected."},indexMode:"hidden"};function Qo(e){return!ke.isSeparator(e)&&!e.disabled}function es(e){return!ke.isSeparator(e)}function eg(e){return e.map((t)=>{if(ke.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 ts=Ze((e,t)=>{let{loop:r=!0,pageSize:n=7}=e,o=xe(Qh,e.theme),{keybindings:s}=o,[i,a]=D("idle"),c=Ie({status:i,theme:o}),u=qe(),l=!s.includes("vim"),p=Wt(()=>eg(e.choices),[e.choices]),d=Wt(()=>{let P=p.findIndex(es),C=p.findLastIndex(es);if(P===-1)throw new Vt("[select prompt] No selectable choices. All choices are disabled.");return{first:P,last:C}},[p]),f=Wt(()=>{if(!("default"in e))return-1;return p.findIndex((P)=>Qo(P)&&P.value===e.default)},[e.default,p]),[m,g]=D(f===-1?d.first:f),x=p[m];if(x==null||ke.isSeparator(x))throw Error("Active index does not point to a choice");let[_,b]=D();Ae((P,C)=>{if(clearTimeout(u.current),_)b(void 0);if(Oe(P))if(x.disabled)b(o.i18n.disabledError);else a("done"),t(x.value);else if(Ut(P,s)||Gr(P,s)){if(C.clearLine(0),r||Ut(P,s)&&m!==d.first||Gr(P,s)&&m!==d.last){let U=Ut(P,s)?-1:1,W=m;do W=(W+U+p.length)%p.length;while(!es(p[W]));g(W)}}else if(Co(P)&&!Number.isNaN(Number(C.line))){let U=Number(C.line)-1,W=-1,de=p.findIndex((wt)=>{if(ke.isSeparator(wt))return!1;return W++,W===U}),Pn=p[de];if(Pn!=null&&Qo(Pn))g(de);u.current=setTimeout(()=>{C.clearLine(0)},700)}else if(Mt(P))C.clearLine(0);else if(l){let U=C.line.toLowerCase(),W=p.findIndex((de)=>{if(ke.isSeparator(de)||!Qo(de))return!1;return de.name.toLowerCase().startsWith(U)});if(W!==-1)g(W);u.current=setTimeout(()=>{C.clearLine(0)},700)}}),Te(()=>()=>{clearTimeout(u.current)},[]);let k=o.style.message(e.message,i),z=o.style.keysHelpTip([["↑↓","navigate"],["⏎","select"]]),y=0,S=Do({items:p,active:m,renderItem({item:P,isActive:C,index:U}){if(ke.isSeparator(P))return y++,` ${P.separator}`;let W=C?o.icon.cursor:" ",de=o.indexMode==="number"?`${U+1-y}. `:"";if(P.disabled){let wt=typeof P.disabled==="string"?P.disabled:"(disabled)",Bd=C?o.icon.cursor:"-";return o.style.disabled(`${Bd} ${de}${P.name} ${wt}`)}return(C?o.style.highlight:(wt)=>wt)(`${W} ${de}${P.name}`)},pageSize:n,loop:r});if(i==="done")return[c,k,o.style.answer(x.short)].filter(Boolean).join(" ");let{description:E}=x;return`${[[c,k].filter(Boolean).join(" "),S," ",E?o.style.description(E):"",_?o.style.error(_):"",z].filter(Boolean).join(`
|
|
76
|
+
`).trimEnd()}${qr}`});var ye=nt(Ft(),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 F=(e,t)=>new O(e,{exitCode:2,hint:t}),Ht=(e)=>e<1000?`${Math.round(e)}ms`:`${Math.round(e/1000)}s`,tg=[["d",86400000],["h",3600000],["m",60000],["s",1000]],Vl=(e)=>{let t=Math.max(0,e);for(let[r,n]of tg)if(t>=n)return`${Math.round(t/n)}${r}`;return`${Math.round(t)}ms`},Gl=(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}
|
|
77
|
+
`)},V=(e)=>{oe(`${ye.default.dim(">")} ${e}`)},ue=(e,t)=>{let r=t===void 0?"":`[${Ht(t)}]`,n=r?` ${ye.default.dim(r)}`:"";oe(`${ye.default.cyan("> Success!")} ${e}${n}`)},ft=(e)=>{oe(`${ye.default.bold(ye.default.yellow("> NOTE:"))} ${e}`)},Wl=(e)=>{if(oe(`${ye.default.bold(ye.default.red("Error:"))} ${e.message}`),e.hint)oe(`${ye.default.dim(">")} ${e.hint}`)},Bl=["⠋","⠙","⠹","⠸","⠼","⠴","⠦","⠧","⠇","⠏"],rg=300,ng="\r\x1B[2K",Y=async(e,t)=>{if(!process.stderr.isTTY)return t();let r=0,n=!1,o,s=()=>{n=!0;let a=Bl[r%Bl.length]??"";r+=1,process.stderr.write(`\r${ye.default.dim(a)} ${e}`)},i=setTimeout(()=>{s(),o=setInterval(s,80)},rg);try{return await t()}finally{if(clearTimeout(i),clearInterval(o),n)process.stderr.write(ng)}},Qr=async(e)=>{try{return await e()}catch(t){if(t instanceof Error&&t.name==="ExitPromptError")throw new O("Canceled",{exitCode:130});throw t}},Kl=(e)=>{let t={output:e.stderr};return{choice:(r)=>Qr(()=>ts(r,t)),confirm:(r)=>Qr(()=>Ho(r,t)),interactive:e.stdin.isTTY===!0&&e.stderr.isTTY===!0,secret:(r)=>Qr(()=>Xo({mask:"*",message:r},t)),text:(r)=>Qr(()=>qo({...r,required:!0},t))}},Jl=(e)=>({isTTY:e.isTTY===!0,json:(t)=>{e.write(`${JSON.stringify(t,null,2)}
|
|
78
78
|
`)},line:(t)=>{e.write(`${t}
|
|
79
|
-
`)},write:(t)=>{e.write(t)}}),{bold:A,cyan:
|
|
80
|
-
`),pp=(e)=>{let t=e?.split("/").at(-1)??"";return
|
|
81
|
-
`)},
|
|
82
|
-
`,{mode:384}),await
|
|
83
|
-
`).flatMap((t)=>{let r=
|
|
84
|
-
`),vp=(e)=>Math.max(0,...e.map(([t])=>t.length)),$p=(e,t)=>{let r=[],n="";for(let o of e.split(" "))if(n&&t.length+n.length+1+o.length>
|
|
85
|
-
`)},
|
|
79
|
+
`)},write:(t)=>{e.write(t)}}),{bold:A,cyan:og,dim:Ue,gray:en,green:tn,red:rs,yellow:_e}=ye.default,sg=" ".repeat(5),ig=(e)=>A(og(e)),rn=(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(sg);oe(""),oe(` ${s(t.map((i)=>({paint:ig,text:i})))}`);for(let[i,a]of n.entries())oe(`${r?.[i]??" "} ${s(a)}`);oe("")};var ns=()=>process.env.NIPA_DEBUG==="1",nn=(e)=>{if(ns())oe(Hl.default.dim(`> [debug] [${new Date().toISOString()}] ${e}`))};class on extends Error{url;constructor(e,t){super(`can't reach ${new URL(e).host}: ${t}`);this.name="NetworkError",this.url=e}}var ql=(e)=>e.cause instanceof Error?`${e.message} (${ql(e.cause)})`:e.message,Pe=async(e,t={})=>{let r=t.method??"GET",n=performance.now();nn(`${r} ${e}`);let o;try{o=await fetch(e,t)}catch(s){throw new on(e,s instanceof Error?ql(s):String(s))}return nn(`${o.status} ${r} ${e} [${Ht(performance.now()-n)}]`),o};var os=I({domainId:v().optional(),id:v(),name:v()});class X extends Error{status;constructor(e,t){super(e);this.name="KeystoneError",this.status=t}}var qt=(e)=>{let t=e;while(t.endsWith("/"))t=t.slice(0,-1);if(t.endsWith("/v3"))t=t.slice(0,-3);return`${t}/v3`},ss=(e,t)=>t?{auth:{identity:e,scope:{project:{id:t}}}}:{auth:{identity:e}},Xl=(e)=>({domain:{name:e.userDomain},name:e.username}),ag=(e,t)=>ss({methods:["password"],password:{user:{...Xl(e),password:t}}},e.projectId),cg=(e,t)=>ss({methods:["totp"],totp:{user:{...Xl(e),passcode:t}}},e.projectId),ug=(e,t)=>ss({methods:["token"],token:{id:e}},t),lg=I({error:I({message:v().optional()}).optional(),receipt:I({}).loose().optional(),required_auth_methods:Se(Se(v())).optional()}),Ql=async(e)=>{try{let t=lg.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",pg=(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}`},mt=async(e,t)=>{let r=await Ql(e);throw new X(pg({body:r,status:e.status,unauthorized:t}),e.status)},dg=I({token:I({expires_at:v(),project:I({domain:I({id:v()}).optional(),id:v(),name:v()}).optional(),user:I({id:v(),name:v()})})}),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}},tp="Openstack-Auth-Receipt",is=(e,t,r)=>{let n=new Headers({"Content-Type":"application/json"});if(r!==void 0)n.set(tp,r);return Pe(`${qt(e)}/auth/tokens`,{body:JSON.stringify(t),headers:n,method:"POST"})},as=async(e)=>{let t=e.headers.get("X-Subject-Token");if(!t)throw new X("Keystone didn't return a token",e.status);let r=dg.safeParse(await e.json());if(!r.success)throw new X(`unexpected token response: ${st(r.error)}`,e.status);return fg(t,r.data)},rp=async(e,t)=>{let r=await is(e.authUrl,ag(e,t));if(r.ok)return{kind:"token",token:await as(r)};let n=r.headers.get(tp);if(r.status===401&&n){let s=(await Ql(r)).required_auth_methods;if(!s||s.some((i)=>i.includes("totp")))return{kind:"mfa",receipt:n};throw new X(ep(s),r.status)}return mt(r,"wrong email or password")},np=async(e)=>{let{account:t,passcode:r,receipt:n}=e,o=await is(t.authUrl,cg(t,r),n);return o.ok?as(o):mt(o,"wrong OTP code")},sn="the session expired or was revoked",an=async(e)=>{let t=await is(e.authUrl,ug(e.token,e.projectId));return t.ok?as(t):mt(t,sn)},mg=I({projects:Se(I({domain_id:v().optional(),enabled:zm().optional(),id:v(),name:v()}))}),hg=(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)),ht=async({authUrl:e,token:t})=>{let r=await Pe(`${qt(e)}/auth/projects`,{headers:{"X-Auth-Token":t}});if(!r.ok)return mt(r,sn);let n=mg.safeParse(await r.json());if(!n.success)throw new X(`unexpected project list: ${st(n.error)}`,r.status);return hg(n.data)},op=lt(v(),v()),gg=I({catalog:Se(I({endpoints:Se(I({interface:v(),region:v().nullish(),region_id:v().nullish(),url:v()})),type:v()}))}),xg=(e,t)=>Object.fromEntries(e.catalog.flatMap((r)=>{let n=r.endpoints.find((o)=>o.interface==="public"&&(o.region_id??o.region)===t);return n?[[r.type,n.url]]:[]})),sp=async(e)=>{let t=await Pe(`${qt(e.authUrl)}/auth/catalog`,{headers:{"X-Auth-Token":e.token}});if(!t.ok)return mt(t,sn);let r=gg.safeParse(await t.json());if(!r.success)throw new X(`unexpected catalog: ${st(r.error)}`,t.status);return xg(r.data,e.region)},cn=async({authUrl:e,token:t})=>{let r=await Pe(`${qt(e)}/auth/tokens`,{headers:{"X-Auth-Token":t,"X-Subject-Token":t},method:"DELETE"});if(!(r.ok||r.status===401||r.status===404))await mt(r,sn)},Yl=I({version:I({id:v(),status:v()})}),ip=async(e)=>{let t=qt(e),r=await Pe(t,{signal:AbortSignal.timeout(1e4)}),n;try{n=Yl.safeParse(await r.json())}catch{n=Yl.safeParse(null)}if(!(r.ok&&n.success))throw new X(`${t} doesn't answer like Keystone v3 (HTTP ${r.status})`,r.status);return n.data.version.id};import{spawn as Ag}from"node:child_process";import{once as Rg}from"node:events";import{stat as Zg}from"node:fs/promises";import{text as jg}from"node:stream/consumers";import{accessSync as yg,constants as _g}from"node:fs";import{homedir as bg}from"node:os";import Yt from"node:path";var ap=(e)=>{try{return yg(e,_g.X_OK),!0}catch{return!1}},wg=(e)=>process.platform==="win32"?[...(process.env.PATHEXT??".EXE;.CMD;.BAT").split(";").map((t)=>`${e}${t}`),e]:[e],un=(e)=>{if(e.includes("/")||e.includes(Yt.sep)){let r=Yt.resolve(e);return ap(r)?r:void 0}return[...(process.env.PATH??"").split(Yt.delimiter).filter(Boolean),Yt.join(bg(),".local","bin")].flatMap((r)=>wg(Yt.join(r,e))).find(ap)},ln=(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}),up=(e,t)=>({...Object.fromEntries(Object.entries(e).filter(([r])=>!r.startsWith("OS_"))),...t}),cs=["bash","zsh","fish"],vg=(e)=>cs.some((t)=>t===e),cp=(e,t)=>`'${t==="fish"?e.replaceAll("\\","\\\\").replaceAll("'","\\'"):e.replaceAll("'","'\\''")}'`,lp=(e,t)=>Object.entries(e).map(([r,n])=>t==="fish"?`set -gx ${r} ${cp(n,t)}`:`export ${r}=${cp(n,t)}`).join(`
|
|
80
|
+
`),pp=(e)=>{let t=e?.split("/").at(-1)??"";return vg(t)?t:"bash"};import{chmod as $g,mkdir as dp,readFile as fp,rm as Sg,writeFile as mp}from"node:fs/promises";import{homedir as hp}from"node:os";import Qe from"node:path";var Q="prod",be={authUrl:"https://identity-api.nipa.cloud/v3",region:"NCP-TH",userDomain:"nipacloud"},Xe=I({authUrl:um({protocol:/^https?$/u}),project:os.optional(),region:v().min(1),userDomain:v().min(1),username:v().optional()}),ls=/^[a-z][\da-z-]{0,31}$/u,kg=lt(v().regex(ls),Xe),ps=(e)=>({[Q]:be,...e}),Pg=I({currentProfile:v().default(Q),profiles:kg.default({})}).strict().transform((e)=>({...e,profiles:ps(e.profiles)})),zg=Xe.extend({authUrl:Xe.shape.authUrl.default(be.authUrl),region:Xe.shape.region.default(be.region),userDomain:Xe.shape.userDomain.default(be.userDomain)}).transform((e)=>({currentProfile:Q,profiles:ps({[Q]:e})})),Eg=Ur([Pg,zg]),gp=I({endpoints:op.optional(),expiresAt:Mr.datetime({offset:!0}),project:os,token:v().min(1),user:I({id:v(),name:v()})}),Cg=lt(v(),gp),Og=Ur([I({sessions:Cg}).strict().transform((e)=>e.sessions),gp.transform((e)=>({[Q]:e}))]);class Xt extends Error{constructor(e){super(e);this.name="StoreError"}}var Tg=60000,ds=(e=process.env)=>e.NIPA_CONFIG_DIR??Qe.join(e.XDG_CONFIG_HOME??Qe.join(hp(),".config"),"nipa"),xp=()=>Qe.join(ds(),"config.json"),pn=()=>Qe.join(ds(),"auth.json"),us=(e,t=process.env)=>Qe.join(t.XDG_CACHE_HOME??Qe.join(hp(),".cache"),"nipa",e),dn=async(e,t)=>{try{let r=await fp(us(e),"utf-8"),n=t.safeParse(JSON.parse(r));return n.success?n.data:void 0}catch{return}},fn=async(e,t)=>{await dp(Qe.dirname(us(e)),{recursive:!0}),await mp(us(e),`${JSON.stringify(t)}
|
|
81
|
+
`)},Ig=async(e)=>{try{return await fp(e,"utf-8")}catch(t){if(t instanceof Error&&"code"in t&&t.code==="ENOENT")return;throw t}},yp=async(e,t)=>{let r=await Ig(e);if(r===void 0)return;let n;try{n=JSON.parse(r)}catch{throw new Xt(`${e} isn't valid JSON`)}let o=t.safeParse(n);if(!o.success)throw new Xt(`${e}: ${st(o.error)}`);return o.data},fs=async(e,t)=>{await dp(ds(),{mode:448,recursive:!0}),await mp(e,`${JSON.stringify(t,null,2)}
|
|
82
|
+
`,{mode:384}),await $g(e,384)},le=async()=>await yp(xp(),Eg)??{currentProfile:Q,profiles:ps({})},Me=(e)=>fs(xp(),e),ms=async()=>await yp(pn(),Og)??{},pe=async(e)=>(await ms())[e],hs=async(e)=>{let t=await ms();await fs(pn(),{sessions:{...t,[e.profile]:e.session}})},mn=async(e)=>{let t=await ms(),r=Object.fromEntries(Object.entries(t).filter(([n])=>n!==e));if(Object.keys(r).length===0){await Sg(pn(),{force:!0});return}await fs(pn(),{sessions:r})},gs=(e,t=Date.now())=>Date.parse(e.expiresAt)-t,ee=(e,t=Date.now())=>e!==void 0&&gs(e,t)>Tg;var _p="openstack.json",Lg=20000,Dg=lt(v(),Se(v())),Ng=I({bin:v(),mtimeMs:Xu(),table:Dg}),Fg=/^\s*cmds(?:_(?<key>\S+))?='(?<words>[^']*)'$/u,Ug=(e)=>Object.fromEntries(e.split(`
|
|
83
|
+
`).flatMap((t)=>{let r=Fg.exec(t)?.groups;if(!r)return[];let n=r.words?.split(" ").filter(Boolean)??[];return[[r.key??"",n]]})),Mg=(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("_"))},Bg=async(e)=>{let{mtimeMs:t}=await Zg(e),r=await dn(_p,Ng);if(r?.bin===e&&r.mtimeMs===t)return r.table;let n=Ag(e,["complete","--shell","none"],{stdio:["ignore","pipe","ignore"],timeout:Lg}),[o]=await Promise.all([jg(n.stdout),Rg(n,"close")]);if(n.exitCode!==0)return;let s=Ug(o);return await fn(_p,{bin:e,mtimeMs:t,table:s}),s},bp=async(e)=>{let t=un("openstack");if(!t)return[];let r=await Bg(t);return r?Mg(r,e):[]};var je=nt(Ft(),1);var gt={description:"Print JSON",long:"json",value:{kind:"none"}},wp={description:"Don't ask for confirmation",long:"yes",short:"y",value:{kind:"none"}},xs={description:"Use this profile (or set NIPA_PROFILE)",long:"profile",short:"P",value:{kind:"profile"}},ys={description:"Show help",long:"help",short:"h",value:{kind:"none"}},se=[xs,{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"}},ys,{description:"Show the version",long:"version",short:"v",value:{kind:"none"}}];var te=(e)=>[e.name,...e.aliases??[]],ie=(e)=>e.short?[`--${e.long}`,`-${e.short}`]:[`--${e.long}`],Qt=(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}},_s=(e)=>e.length===1?e[0]:e[1],er=(e)=>e.sections.flatMap((t)=>t.commands);var bs=" ",Vg=80,tr=(e,t)=>e.map(([r,n])=>`${bs}${r.padEnd(t)} ${n}`).join(`
|
|
84
|
+
`),vp=(e)=>Math.max(0,...e.map(([t])=>t.length)),$p=(e,t)=>{let r=[],n="";for(let o of e.split(" "))if(n&&t.length+n.length+1+o.length>Vg)r.push(n),n=o;else n=n?`${n} ${o}`:o;return r.push(n),r.map((o)=>`${t}${o}`).join(`
|
|
85
|
+
`)},Gg=(e)=>{switch(e.arity){case"one":return`<${e.name}>`;case"optional":return`[${e.name}]`;case"rest":return`[${e.name}...]`;default:return e.arity}},Wg=(e)=>{let[t,...r]=e;if(!t)return[];if(r.length===0&&t.value.kind==="none")return[`[--${t.long}]`];return["[options]"]},Kg=(e)=>{switch(e.kind){case"program":case"openstack":return"<args...>";case"command":return"<command> [args...]";default:return e}},Sp=(e)=>{switch(e.kind){case"leaf":return[...e.args.map(Gg),...Wg(e.flags)].join(" ");case"group":return`[${e.subcommands.map((t)=>t.name).join("|")}]`;case"passthrough":return Kg(e.target);default:return e}},hn=(e)=>`nipa ${e.map((t)=>t.name).join(" ")}`,rr=(e)=>{let t=Sp(_s(e));return t?`${hn(e)} ${t}`:hn(e)},Jg=(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}},kp=(e)=>[`${e.short?`-${e.short}, `:" "}--${e.long}${Qt(e.value)}`,e.description],ws=(e)=>{let t=Sp(e);return[t?`${e.name} ${t}`:e.name,e.summary]},et=(e,t)=>` ${je.default.dim(`${e}:`)}
|
|
86
86
|
|
|
87
87
|
${t}
|
|
88
88
|
`,Pp=(e)=>e.map((t)=>`${bs}${je.default.dim(t.description)}
|
|
89
89
|
${bs}${je.default.cyan("$")} ${t.command}`).join(`
|
|
90
90
|
|
|
91
91
|
`),gn=se.map(kp),vs=(e)=>{let{program:t}=e,r=t.sections.flatMap((i)=>i.commands.map(ws)),n=vp([...r,...gn]),o=t.sections.map((i)=>et(i.title,tr(i.commands.map(ws),n))),s=je.default.dim(`v${e.version}`);return["",` ${je.default.bold("nipa")} ${s}`,"",$p(t.summary," "),"",` ${je.default.dim("Usage:")} nipa [options] <command>`,"",...o,et("Global options",tr(gn,n)),et("Examples",Pp(t.examples)),` Run ${je.default.bold("nipa <command> --help")} for a command's options.`,""].join(`
|
|
92
|
-
`)},xn=(e)=>{let t=_s(e),r=t.kind==="group"?t.subcommands.map(ws):[],n=
|
|
93
|
-
`)};var Cp=(e)=>new Map(e.flatMap((t)=>ie(t).map((r)=>[r,t]))),ks=(e)=>`Use one of: ${e.join(", ")}.`,Op=(e,t)=>{if(e.value.kind==="choice"&&!e.value.choices.includes(t))throw F(`unknown ${e.long} "${t}"`,ks(e.value.choices));return t},zp=(e)=>{let{flag:t,hints:r,name:n,next:o}=e;if(o===void 0||o.startsWith("-"))throw F(`${n} needs${Qt(t.value)}`,`Usage: ${r.usage}`);return Op(t,o)},Tp=(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 F(`${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:Op(d,o.slice(l+1))}],used:1};return{options:[{flag:d,value:zp({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:zp({flag:p,hints:t,name:`-${s[l]}`,next:n})}),u=2;else throw F(`-${s[l]} needs${Qt(p.value)}`,`Usage: ${t.usage}`);return{options:c,used:u}},Ss=(e,t)=>{let r=e.flatMap((n)=>{let o=t.get(n.long);return o===void 0?[]:[[n.long,o]]});return Object.fromEntries(r)},
|
|
94
|
-
`);return`${r}${
|
|
92
|
+
`)},xn=(e)=>{let t=_s(e),r=t.kind==="group"?t.subcommands.map(ws):[],n=Jg(t).map(kp),o=vp([...r,...n,...gn]),s=["",` ${je.default.dim("Usage:")} ${rr(e)}`,"",$p(t.description??t.summary," "),""];if(r.length>0)s.push(et("Subcommands",tr(r,o)));if(n.length>0)s.push(et("Options",tr(n,o)));if(s.push(et("Global options",tr(gn,o))),t.examples?.length)s.push(et("Examples",Pp(t.examples)));return s.join(`
|
|
93
|
+
`)};var Cp=(e)=>new Map(e.flatMap((t)=>ie(t).map((r)=>[r,t]))),ks=(e)=>`Use one of: ${e.join(", ")}.`,Op=(e,t)=>{if(e.value.kind==="choice"&&!e.value.choices.includes(t))throw F(`unknown ${e.long} "${t}"`,ks(e.value.choices));return t},zp=(e)=>{let{flag:t,hints:r,name:n,next:o}=e;if(o===void 0||o.startsWith("-"))throw F(`${n} needs${Qt(t.value)}`,`Usage: ${r.usage}`);return Op(t,o)},Tp=(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 F(`${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:Op(d,o.slice(l+1))}],used:1};return{options:[{flag:d,value:zp({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:zp({flag:p,hints:t,name:`-${s[l]}`,next:n})}),u=2;else throw F(`-${s[l]} needs${Qt(p.value)}`,`Usage: ${t.usage}`);return{options:c,used:u}},Ss=(e,t)=>{let r=e.flatMap((n)=>{let o=t.get(n.long);return o===void 0?[]:[[n.long,o]]});return Object.fromEntries(r)},Hg={command:"nipa",usage:"nipa [options] <command>"},qg=Cp(se),Ep=(e)=>{let{at:t,words:r}=e,n=r[t];if(n===void 0||n==="--"||n==="-"||!n.startsWith("-"))return;let o=Tp({hints:Hg,index:qg,next:r[t+1],word:n});if(!o&&e.unknown==="reject")throw F(`unknown option "${n}"`,"Run `nipa --help` to see the options.");return o},Ps=(e)=>{let{unknown:t,words:r}=e,n=new Map,o=0;for(let s=Ep({at:o,unknown:t,words:r});s!==void 0;s=Ep({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:Ss(se,n),rest:r.slice(o)}},Ip=(e)=>{let t=e.indexOf("--"),r=t===-1?e:e.slice(0,t),n=new Set(ie(ys));return r.some((o)=>n.has(o))},Yg=(e)=>{let{flags:t,hints:r,words:n}=e,o=Cp([...t,...se]),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=Tp({hints:r,index:o,next:n[u+1],word:l});if(!p)throw F(`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}},$s=(e,t)=>{if(e.value.kind==="choice"&&!e.value.choices.includes(t))throw F(`unknown ${e.name} "${t}"`,ks(e.value.choices));return t},Xg=(e)=>{let t=[...e.positionals],r=e.args.map((o)=>{switch(o.arity){case"one":{let s=t.shift();if(s===void 0)throw F(`missing <${o.name}>`,o.value.kind==="choice"?ks(o.value.choices):`Usage: ${e.hints.usage}`);return[o.name,$s(o,s)]}case"optional":{let s=t.shift();return[o.name,s===void 0?void 0:$s(o,s)]}case"rest":return[o.name,t.splice(0).map((s)=>$s(o,s))];default:return o.arity}}),[n]=t;if(n!==void 0)throw F(`unexpected argument "${n}"`,`Usage: ${e.hints.usage}`);return Object.fromEntries(r)},Ap=(e)=>{let{path:t,spec:r,words:n}=e,o={command:hn(t),usage:rr(t)},s=Yg({flags:r.flags,hints:o,words:n});return{globals:Ss(se,s.globals),input:{args:Xg({args:r.args,hints:o,positionals:s.positionals}),flags:Ss(r.flags,s.own)}}};var B=(e)=>({...e,kind:"leaf"}),yn=(e)=>({...e,kind:"group"}),xt=(e)=>({...e,kind:"passthrough"}),Z=(e,t)=>({kind:"leaf",prepare:({path:r,words:n})=>{let o=Ap({path:r,spec:e,words:n});return{globals:o.globals,run:(s)=>t({...o.input,client:s})}},spec:e}),_n=(e,t)=>{let r=Object.values(t),n=new Map(r.flatMap((o)=>te(o.spec).map((s)=>[s,o])));return{fallback:t[e.default],kind:"group",spec:e,subcommands:n}},Qg=(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 F("missing <command>",`Usage: ${rr([e])}`);return{args:o,command:n}}default:return r}},yt=(e,t)=>({kind:"passthrough",run:({client:r,words:n})=>t({...Qg(e,n),client:r}),spec:e}),Rp=(e)=>e.spec,Zp=(e)=>({examples:e.examples,hidden:e.hidden.map(Rp),sections:e.sections.map((t)=>({commands:t.commands.map(Rp),title:t.title})),summary:e.summary});var jp=["bash","zsh","fish","pwsh"],Lp=["projects","profiles","openstack"],_t=(e)=>`nipa __complete ${e}`,tt=ie(xs),ex=(e)=>e.filter((t)=>t.kind==="passthrough").flatMap((t)=>te(t)),zs=(e)=>[...e.flags,...se],vn=(e)=>{let t=e.args.findIndex((n)=>n.value.kind!=="text"),r=e.args[t];return r?{arg:r,position:t+1}:void 0},tx=(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}},rx=(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}},nx=(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}},Dp=(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)=>Dp(i,t+1)),"esac")}else if(e.kind==="passthrough")n.push(nx(e.target));else{let s=zs(e),i=s.flatMap((l)=>{let p=tx(l.value);return p===void 0?[]:[` ${ie(l).join("|")}) ${p} ;;`]});if(i.length>0)n.push('case "$prev" in',...i,"esac");let a=s.flatMap(ie).join(" ");n.push(`if [[ $cur == -* ]]; then _nipa_reply ${a}; return; fi`);let c=vn(e),u=c&&rx(c.arg.value);if(u)n.push(u)}let o=n.map((s)=>`${r} ${s}`).join(`
|
|
94
|
+
`);return`${r}${te(e).join("|")})
|
|
95
95
|
${o}
|
|
96
|
-
${r} ;;`},
|
|
96
|
+
${r} ;;`},ox=(e)=>{let t=er(e),r=t.map((o)=>o.name).join(" "),n=se.flatMap(ie).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.
|
|
@@ -135,13 +135,13 @@ ${t.map((o)=>Dp(o,0)).join(`
|
|
|
135
135
|
esac
|
|
136
136
|
}
|
|
137
137
|
complete -o default -F _nipa nipa
|
|
138
|
-
`},bn=(e)=>e.replaceAll("'","'\\''").replaceAll(":","\\:"),
|
|
138
|
+
`},bn=(e)=>e.replaceAll("'","'\\''").replaceAll(":","\\:"),sx=(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}},ix=(e)=>{let t=ie(e),r=t.length>1?`(${t.join(" ")})`:"",n=t.length>1?`{${t.join(",")}}`:t[0];return`'${r}'${n}'[${bn(e.description)}]${sx(e)}'`},ax=({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}},cx=(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}},Np=(e,t)=>{if(e.kind==="group"){let o=e.subcommands,s=o.map((a)=>`'${a.name}:${bn(a.summary)}'`).join(" "),i=o.map((a)=>{let c=Np(a,`${t} `);return`${t} ${te(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
|
|
142
|
+
`)}if(e.kind==="passthrough")return cx(e.target,t);let r=vn(e),n=[...zs(e).map(ix),r?ax(r):""];return`${t} _arguments -s ${n.filter(Boolean).join(" ")}`},ux=(e)=>{let t=er(e),r=t.map((s)=>` '${s.name}:${bn(s.summary)}'`).join(`
|
|
143
143
|
`),n=se.flatMap((s)=>ie(s).map((i)=>` '${i}:${bn(s.description)}'`)).join(`
|
|
144
|
-
`),o=t.map((s)=>` ${
|
|
144
|
+
`),o=t.map((s)=>` ${te(s).join("|")})
|
|
145
145
|
${Np(s," ")}
|
|
146
146
|
;;`).join(`
|
|
147
147
|
`);return`#compdef nipa
|
|
@@ -198,7 +198,7 @@ if [[ $zsh_eval_context[-1] == loadautofunc ]]; then
|
|
|
198
198
|
else
|
|
199
199
|
compdef _nipa nipa
|
|
200
200
|
fi
|
|
201
|
-
`},Be=(e)=>`'${e.replaceAll("\\","\\\\").replaceAll("'","\\'")}'`,wn=(e)=>`'(${_t(e)} 2>/dev/null)'`,
|
|
201
|
+
`},Be=(e)=>`'${e.replaceAll("\\","\\\\").replaceAll("'","\\'")}'`,wn=(e)=>`'(${_t(e)} 2>/dev/null)'`,lx=(e)=>{switch(e.kind){case"none":return"";case"text":return" --exclusive";case"choice":return` --exclusive -a ${Be(e.choices.join(" "))}`;case"project":return` --exclusive -a ${wn("projects")}`;case"profile":return` --exclusive -a ${wn("profiles")}`;default:return e}},px=(e)=>{switch(e.kind){case"text":return;case"project":return wn("projects");case"profile":return wn("profiles");case"choice":return Be(e.choices.join(" "));default:return e}},dx=(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}},fx=(e)=>{if(e.kind==="passthrough")return dx(e.target);let t=vn(e);return t&&px(t.arg.value)},Fp=(e,t)=>{let r=e.short?` -s ${e.short}`:"";return`complete -c nipa -n ${Be(t)}${r} -l ${e.long}${lx(e.value)} -d ${Be(e.description)}`},Up=(e,t)=>{let r=`__nipa_using ${te(t??e).join(" ")}`,n=t?`${r}; and __fish_seen_subcommand_from ${te(e).join(" ")}`:r;if(e.kind==="group"){let c=e.subcommands,u=`${n}; and not __fish_seen_subcommand_from ${c.flatMap((l)=>te(l)).join(" ")}`;return[...c.map((l)=>`complete -c nipa -n ${Be(u)} -a ${l.name} -d ${Be(l.summary)}`),...c.flatMap((l)=>Up(l,e))]}let s=(e.kind==="leaf"?e.flags:[]).map((c)=>Fp(c,n)),i=fx(e),a=i?[`complete -c nipa -n ${Be(n)} -a ${i}`]:[];return[...s,...a]},mx=(e)=>{let t=er(e),r=[...t,...e.hidden],n=`not __nipa_using ${ex(r).join(" ")}`,o=t.map((s)=>`complete -c nipa -n __nipa_needs_command -a ${s.name} -d ${Be(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
|
|
@@ -253,14 +253,14 @@ ${o.join(`
|
|
|
253
253
|
`)}
|
|
254
254
|
${t.flatMap((s)=>Up(s)).join(`
|
|
255
255
|
`)}
|
|
256
|
-
`},nr=(e)=>`'${e.replaceAll("'","''")}'`,ze=(e)=>`@(${e.map(nr).join(", ")})`,
|
|
256
|
+
`},nr=(e)=>`'${e.replaceAll("'","''")}'`,ze=(e)=>`@(${e.map(nr).join(", ")})`,hx=(e)=>{switch(e.kind){case"none":case"text":return;case"choice":return ze(e.choices);case"project":return"(Dynamic projects)";case"profile":return"(Dynamic profiles)";default:return e}},gx=(e)=>{switch(e.kind){case"text":return;case"project":return"(Dynamic projects)";case"profile":return"(Dynamic profiles)";case"choice":return ze(e.choices);default:return e}},xx=(e)=>{switch(e.kind){case"openstack":return"(Openstack ($c + 1))";case"program":case"command":return;default:return e}},Mp=(e,t)=>{if(e.kind==="group"){let i=e.subcommands,a=i.map((u)=>`${nr(u.name)} = ${nr(u.summary)}`).join("; "),c=i.map((u)=>{let l=Mp(u,`${t} `);return`${t} { $_ -in ${ze(te(u))} } {
|
|
257
257
|
${t} $c += 1
|
|
258
258
|
${l}
|
|
259
259
|
${t} }`}).join(`
|
|
260
260
|
`);return[`${t} if ($index -eq $c + 1) { return Complete ${ze(i.map((u)=>u.name))} @{ ${a} } }`,`${t} switch ($words[$c + 1]) {`,c,`${t} }`].join(`
|
|
261
|
-
`)}if(e.kind==="passthrough"){let i=
|
|
262
|
-
`)},
|
|
263
|
-
`),n=t.map((o)=>` { $_ -in ${ze(
|
|
261
|
+
`)}if(e.kind==="passthrough"){let i=xx(e.target);return i?`${t} return Complete ${i}`:`${t} return`}let r=zs(e),n=r.flatMap((i)=>{let a=hx(i.value);return a===void 0?[]:[`if ($prev -in ${ze(ie(i))}) { return Complete ${a} }`]});n.push(`if ($wordToComplete -like '-*') { return Complete ${ze(r.flatMap(ie))} }`);let o=vn(e),s=o&&gx(o.arg.value);if(s)n.push(`Complete ${s}`);return n.map((i)=>`${t} ${i}`).join(`
|
|
262
|
+
`)},yx=(e)=>{let t=er(e),r=t.map((o)=>` ${nr(o.name)} = ${nr(o.summary)}`).join(`
|
|
263
|
+
`),n=t.map((o)=>` { $_ -in ${ze(te(o))} } {
|
|
264
264
|
${Mp(o," ")}
|
|
265
265
|
}`).join(`
|
|
266
266
|
`);return`# nipa completion for PowerShell
|
|
@@ -301,7 +301,7 @@ ${r}
|
|
|
301
301
|
${n}
|
|
302
302
|
}
|
|
303
303
|
}
|
|
304
|
-
`},Bp=(e)=>{let{program:t,shell:r}=e;switch(r){case"bash":return
|
|
305
|
-
`).join("")),0});var Wp=B({args:[{arity:"one",name:"shell",value:{choices:jp,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 Kp=Z(Wp,({args:e,client:t})=>(t.stdout.write(Bp({program:t.program,shell:e.shell})),Promise.resolve(0)));var Jp=B({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:cs,kind:"choice"}}],name:"env",summary:"Print the OS_* variables for your shell"});var Hp=Z(Jp,async({client:e,flags:t})=>{let r=t.shell??pp(process.env.SHELL),{active:n,session:o}=await e.session();return e.stdout.line(lp(ln({profile:n.profile,session:o}),r)),0});import{spawn as yx}from"node:child_process";import{once as _x}from"node:events";import{constants as qp}from"node:os";var bx=new Map([["openstack","Install it with `pipx install python-openstackclient`."],["terraform","Install it with `brew install hashicorp/tap/terraform`."]]),bt=async({args:e,command:t,signIn:r})=>{let n=un(t);if(!n)throw new O(`command not found: ${t}`,{exitCode:127,hint:bx.get(t)});let{active:o,session:s}=await r(),i=yx(n,e,{env:up(process.env,ln({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 _x(i,"exit"),process.off("SIGINT",c),process.off("SIGTERM",u);let{exitCode:l,signalCode:p}=i;if(p)return 128+qp.signals[p];return a&&l===0?128+qp.signals.SIGINT:l??1};var Yp=xt({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 Xp=yt(Yp,({args:e,client:t,command:r})=>bt({args:e,command:r,signIn:t.cloud}));class rt extends Error{status;constructor(e,t){super(e);this.name="ApiError",this.status=t}}var Qp=I({message:v()}),wx=Ur([Qp.transform((e)=>e.message),lt(v(),Qp).transform((e)=>Object.values(e)[0]?.message)]),vx=async(e)=>{try{let t=wx.safeParse(JSON.parse(await e.text()));return t.success?t.data:void 0}catch{return}},$x=async(e,t)=>{try{return t.safeParse(await e.json())}catch{return t.safeParse(null)}},ed=(e)=>{let t=e.url;while(t.endsWith("/"))t=t.slice(0,-1);return{get:async(r,n,o={})=>{let s=await Pe(`${t}${r}`,{headers:{Accept:"application/json",...o,"X-Auth-Token":e.token}});if(!s.ok){let a=await vx(s)??`${e.type} returned HTTP ${s.status}`;throw new rt(a,s.status)}let i=await $x(s,n);if(!i.success)throw new rt(`unexpected ${e.type} response: ${st(i.error)}`,s.status);return i.data}}};var td=async(e)=>{let t=await le(),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}},Sn=(e)=>e===X?"nipa login":`nipa login -P ${e}`,rd=(e)=>{if(e.name!==X){let t=Ue(`(${new URL(e.profile.authUrl).host})`);V(`Using profile ${A(e.name)} ${t}`)}},Sx=/^\d{6}$/u,kx=/^[\da-f]{32}$/u,Px=3,zx=(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)=>Sx.test(r)||"Enter the 6-digit code from your authenticator app"}),password:()=>e.secret("Password"),project:(t)=>e.choice({choices:t.map((r)=>({description:r.id,name:r.name,value:r})),message:"Which project?"})}),Es=(e)=>{let{projects:t,wanted:r}=e;if(r){let s=t.find((i)=>i.id===r||i.name===r);if(!s)throw new O(`no project named or with ID "${r}"`,{hint:`Your projects: ${t.map((i)=>i.name).join(", ")}`});return Promise.resolve(s)}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)},$n=(e,t)=>({expiresAt:e.expiresAt,project:e.project??t,token:e.value,user:e.user}),nd=async(e)=>{let t=await e.ask(e.attempt);try{return await Y("Checking the code…",()=>np({account:e.account,passcode:t,receipt:e.receipt}))}catch(r){if(!(r instanceof oe&&r.status===401)||e.attempt===Px)throw r;return V("That code didn't work. Each code works once, so wait for the next one."),nd({...e,attempt:e.attempt+1})}},Ex=async(e)=>{let{profile:t,prompts:r,wantedProject:n}=e,o=e.username??await r.email(t.username),s=await r.password(),i=n??t.project?.id,a={authUrl:t.authUrl,projectId:i&&kx.test(i)?i:void 0,userDomain:t.userDomain,username:o},c=await Y("Checking your password…",()=>rp(a,s)),u=c.kind==="token"?c.token:await nd({account:a,ask:r.otp,attempt:1,receipt:c.receipt});if(u.project)return $n(u,u.project);let l=await Y("Loading your projects…",()=>ht({authUrl:t.authUrl,token:u.value})),p=await Es({ask:r.project,projects:l,wanted:i}),d=await Y(`Switching to ${p.name}…`,()=>an({authUrl:t.authUrl,projectId:p.id,token:u.value}));return $n(d,p)},Cs=async(e)=>{let{active:t,session:r}=e,n={...t.profile,project:r.project,username:r.user.name};await Me({...t.config,profiles:{...t.config.profiles,[t.name]:n}}),await hs({profile:t.name,session:r})},Os=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=Ue(`(${new URL(t.profile.authUrl).host})`);V(`Logging in to ${A(t.name)} ${n}`);let o=await Ex({profile:t.profile,prompts:zx(r),username:e.username,wantedProject:e.wantedProject});await Cs({active:t,session:o});let s=A(o.user.name);return ue(`Logged in as ${s}, project ${A(o.project.name)}`),o},od=async(e)=>{let{active:t,prompts:r}=e,n=await pe(t.name);if(Q(n))return{active:t,session:n};let o=`Run \`${Sn(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 V(n?"Your session expired.":"You aren't logged in yet."),{active:t,session:await Os({active:t,prompts:r})}},Cx=(e)=>async(t)=>{try{return await t()}catch(r){if((r instanceof rt||r instanceof oe?r.status:void 0)===401)throw new O(`your ${e} session expired or was revoked`,{hint:`Run \`${Sn(e)}\`.`});throw r}},sd=(e)=>{let{active:t,session:r}=e,{authUrl:n,region:o}=t.profile,s=Cx(t.name),{endpoints:i}=r,a=async()=>{if(!i)i=await s(()=>sp({authUrl:n,region:o,token:r.token})),await hs({profile:t.name,session:{...r,endpoints:i}});return i};return{active:t,service:async(c)=>{let l=(await a())[c];if(!l)throw new O(`there's no ${c} endpoint in ${o}`,{hint:"Check the profile's region with `nipa profile ls`."});let p=ed({token:r.token,type:c,url:l});return{get:(d,f,m)=>s(()=>p.get(d,f,m))}},session:r}};var id=B({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 ad=Z(id,async({client:e,flags:t})=>(await Os({active:await e.profile(),prompts:e.prompts,username:t.username,wantedProject:t.project}),0));var cd=B({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 ud=Z(cd,async({client:e})=>{let t=await e.profile(),r=await pe(t.name);if(!r)return ft(`Not logged in to ${t.name}, so \`nipa logout\` did nothing`),0;if(Q(r))try{await Y("Logging out…",()=>cn({authUrl:t.profile.authUrl,token:r.token}))}catch{}return await mn(t.name),ue(`Logged out of ${A(t.name)}`),0});var ld=xt({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 pd=yt(ld,({args:e,client:t,command:r})=>bt({args:e,command:r,signIn:t.cloud}));var Ts=B({args:[],flags:[gt],name:"ls",summary:"List your profiles and who is logged in to each"}),Is=B({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:"Make it the current profile",long:"use",value:{kind:"none"}}],name:"add",summary:"Add a profile, asking for missing values"}),As=B({args:[{arity:"optional",name:"name",value:{kind:"profile"}}],flags:[],name:"use",summary:"Make a profile the current one"}),Rs=B({args:[{arity:"one",name:"name",value:{kind:"profile"}}],flags:[{...wp,description:"Remove it without asking"}],name:"rm",summary:"Remove a profile and log out of it"}),dd=yn({default:"ls",description:"A profile is a Keystone URL, user domain and region 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:[Ts,Is,As,Rs],summary:"Manage Keystone profiles, such as staging"});var Ox=(e)=>(t)=>{if(!ls.test(t))return"Use lowercase letters, digits and hyphens, starting with a letter";return e.profiles[t]?`A profile named ${t} already exists`:!0},fd=(e)=>Xe.shape.authUrl.safeParse(e).success||"Enter an http or https URL, such as https://keystone.example.com/v3",md=(e)=>{if(e.value!==void 0)return Promise.resolve(e.value);if(!e.prompts.interactive)throw F(`missing ${e.flag}`,"Pass every value as a flag when there is no terminal.");return e.ask()},hd=Z(Is,async({args:e,client:t,flags:r})=>{let{prompts:n}=t,o=await le(),s=Ox(o),i=await md({ask:()=>n.text({message:"Profile name",validate:s}),flag:"<name>",prompts:n,value:e.name}),a=s(i);if(a!==!0)throw F(`can't add profile "${i}"`,a);let c=await md({ask:()=>n.text({message:"Keystone URL",validate:fd}),flag:"--auth-url",prompts:n,value:r["auth-url"]}),u=fd(c);if(u!==!0)throw F(`invalid --auth-url "${c}"`,u);let l=r["user-domain"]??(n.interactive?await n.text({default:be.userDomain,message:"User domain"}):be.userDomain),p=r.region??(n.interactive?await n.text({default:be.region,message:"Region"}):be.region),d=performance.now(),f=await Y(`Checking ${c}…`,()=>ip(c)),m={authUrl:c,region:p,userDomain:l},g=r.use??(n.interactive&&await n.confirm({default:!0,message:`Use ${i} now?`}));return await Me({currentProfile:g?i:o.currentProfile,profiles:{...o.profiles,[i]:m}}),ue(`Added profile ${A(i)} (Keystone ${f})`,performance.now()-d),V(g?`Now using ${A(i)}. Run \`nipa login\` to log in to it.`:`Run \`nipa login -P ${i}\` to log in to it.`),0});var gd=Z(Ts,async({client:e,flags:t})=>{let r=await le(),n=Object.keys(r.profiles).toSorted(),o=await Promise.all(n.map((i)=>pe(i)));if(t.json)return e.stdout.json(n.map((i,a)=>{let c=o[a];return{current:i===r.currentProfile,loggedIn:Q(c),name:i,...r.profiles[i],user:Q(c)?c.user.name:void 0}})),0;let s=n.map((i,a)=>{let c=r.profiles[i]??be,u=o[a],l=Q(u)?`${u.user.name} (${u.project.name})`:"-";return[i,new URL(c.authUrl).host,c.region,l].map((p)=>({text:p}))});return V(`${n.length} ${n.length===1?"profile":"profiles"}`),rn({headings:["Name","Keystone","Region","Logged in as"],marks:n.map((i)=>i===r.currentProfile?tn("✔"):" "),rows:s}),0});var xd=Z(Rs,async({args:e,client:t,flags:r})=>{let{name:n}=e,o=await le(),s=o.profiles[n];if(!s)throw new O(`no profile named "${n}"`);if(n===X)throw new O(`can't remove ${X}`,{hint:"nipa always has the Nipa Cloud production profile."});if(!r.yes){if(!t.prompts.interactive)throw F(`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 pe(n);if(Q(i))try{await cn({authUrl:s.authUrl,token:i.token})}catch{}await mn(n);let a=Object.fromEntries(Object.entries(o.profiles).filter(([u])=>u!==n)),c=o.currentProfile===n;if(await Me({currentProfile:c?X:o.currentProfile,profiles:a}),ue(`Removed profile ${A(n)}`),c)V(`Now using ${A(X)}`);return 0});var yd=Z(As,async({args:e,client:t})=>{let r=await le(),n=Object.keys(r.profiles).toSorted(),{name:o}=e;if(o===void 0){if(!t.prompts.interactive)throw F("missing <name>",`Your profiles: ${n.join(", ")}`);o=await t.prompts.choice({choices:n.map((s)=>({name:s===r.currentProfile?`${s} ${A("(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 ${A(o)}`),0;return await Me({...r,currentProfile:o}),ue(`Now using profile ${A(o)}`),0});var _d=_n(dd,{add:hd,ls:gd,rm:xd,use:yd});var Zs="List the servers in your project",js=B({aliases:["list"],args:[],flags:[gt],name:"ls",summary:Zs}),bd=yn({aliases:["servers"],default:"ls",description:"Lists the servers in your project with their status, address, flavor and age. nipa calls the compute API itself, 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:[js],summary:Zs});var Tx={"OpenStack-API-Version":"compute 2.47"},Ix=I({"OS-EXT-IPS:type":v().optional(),addr:v(),version:Qu()}),Ax=I({addresses:lt(v(),Se(Ix)),created:v(),flavor:I({original_name:v()}),id:v(),name:v(),status:v()}),Rx=I({href:v(),rel:v()}),Zx=I({servers:Se(Ax),servers_links:Se(Rx).optional()}),jx=(e)=>({addresses:Object.entries(e.addresses).flatMap(([t,r])=>r.map((n)=>({address:n.addr,network:t,type:n["OS-EXT-IPS:type"]??"fixed",version:n.version}))),createdAt:e.created,flavor:e.flavor.original_name,id:e.id,name:e.name,status:e.status}),Lx=(e=[])=>{let t=e.find((n)=>n.rel==="next");if(!t)return;return URL.parse(t.href,"http://localhost")?.searchParams.get("marker")??void 0},wd=async(e)=>{let{compute:t,marker:r}=e,n=r===void 0?"":`?marker=${encodeURIComponent(r)}`,o=await t.get(`/servers/detail${n}`,Zx,Tx),s=o.servers.map(jx),i=Lx(o.servers_links);if(i===void 0||i===r||s.length===0)return s;return[...s,...await wd({compute:t,marker:i})]},vd=(e)=>wd({compute:e});var Dx=new Map([["ACTIVE",tn],["BUILD",_e],["ERROR",rs],["HARD_REBOOT",_e],["MIGRATING",_e],["PASSWORD",_e],["REBOOT",_e],["REBUILD",_e],["RESCUE",_e],["RESIZE",_e],["REVERT_RESIZE",_e],["UNKNOWN",rs],["VERIFY_RESIZE",_e]]),Nx=(e)=>{let t=e.toLowerCase().replaceAll("_"," ");return`${t.charAt(0).toUpperCase()}${t.slice(1)}`},$d=(e)=>{let t=e.addresses.filter((n)=>n.version===4);return(t.find((n)=>n.type==="floating")??t[0]??e.addresses[0])?.address},Sd=(e)=>{let t=Dx.get(e)??en;return{paint:(r)=>`${t("●")}${r.slice(1)}`,text:`● ${Nx(e)}`}};var Fx=(e,t)=>{rn({headings:["Name","Status","Address","Flavor","Age"],rows:e.map((r)=>[{text:r.name},Sd(r.status),{text:$d(r)??"-"},{text:r.flavor},{paint:en,text:Gl(t-Date.parse(r.createdAt))}])})},kd=Z(js,async({client:e,flags:t})=>{let{active:r,service:n,session:o}=await e.cloud(),{project:s}=o,i=performance.now(),a=await Y(`Loading the servers in ${s.name}…`,async()=>vd(await n("compute")));if(t.json)return e.stdout.json({profile:r.name,project:s,servers:a}),0;let c=Ue(`[${Ht(performance.now()-i)}]`);if(a.length===0)return V(`No servers in ${A(s.name)} ${c}`),0;if(V(`Servers in ${A(s.name)} ${c}`),Fx(a,Date.now()),!e.stdout.isTTY)e.stdout.line(a.map((u)=>u.id).join(`
|
|
306
|
-
`));return 0});var
|
|
307
|
-
`)},
|
|
304
|
+
`},Bp=(e)=>{let{program:t,shell:r}=e;switch(r){case"bash":return ox(t);case"zsh":return ux(t);case"fish":return mx(t);case"pwsh":return yx(t);default:return r}};var Vp=B({args:[{arity:"one",name:"kind",value:{choices:Lp,kind:"choice"}},{arity:"rest",name:"words",value:{kind:"text"}}],flags:[],name:"__complete",summary:"Print values for the completion scripts",updateNotice:!1});var _x=async(e)=>{let t=await e.profile(),r=await pe(t.name);if(!ee(r))return[];return(await ht({authUrl:t.profile.authUrl,token:r.token})).map((o)=>o.name)},bx=async(e)=>{let{client:t,kind:r,words:n}=e;switch(r){case"projects":return await _x(t);case"profiles":{let o=await le();return Object.keys(o.profiles).toSorted()}case"openstack":return await bp(n);default:return r}},Gp=Z(Vp,async({args:e,client:t})=>{let r=await bx({client:t,kind:e.kind,words:e.words});return t.stdout.write(r.map((n)=>`${n}
|
|
305
|
+
`).join("")),0});var Wp=B({args:[{arity:"one",name:"shell",value:{choices:jp,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 Kp=Z(Wp,({args:e,client:t})=>(t.stdout.write(Bp({program:t.program,shell:e.shell})),Promise.resolve(0)));var Jp=B({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:cs,kind:"choice"}}],name:"env",summary:"Print the OS_* variables for your shell"});var Hp=Z(Jp,async({client:e,flags:t})=>{let r=t.shell??pp(process.env.SHELL),{active:n,session:o}=await e.session();return e.stdout.line(lp(ln({profile:n.profile,session:o}),r)),0});import{spawn as wx}from"node:child_process";import{once as vx}from"node:events";import{constants as qp}from"node:os";var $x=new Map([["openstack","Install it with `pipx install python-openstackclient`."],["terraform","Install it with `brew install hashicorp/tap/terraform`."]]),bt=async({args:e,command:t,signIn:r})=>{let n=un(t);if(!n)throw new O(`command not found: ${t}`,{exitCode:127,hint:$x.get(t)});let{active:o,session:s}=await r(),i=wx(n,e,{env:up(process.env,ln({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 vx(i,"exit"),process.off("SIGINT",c),process.off("SIGTERM",u);let{exitCode:l,signalCode:p}=i;if(p)return 128+qp.signals[p];return a&&l===0?128+qp.signals.SIGINT:l??1};var Yp=xt({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 Xp=yt(Yp,({args:e,client:t,command:r})=>bt({args:e,command:r,signIn:t.cloud}));class rt extends Error{status;constructor(e,t){super(e);this.name="ApiError",this.status=t}}var Qp=I({message:v()}),Sx=Ur([Qp.transform((e)=>e.message),lt(v(),Qp).transform((e)=>Object.values(e)[0]?.message)]),kx=async(e)=>{try{let t=Sx.safeParse(JSON.parse(await e.text()));return t.success?t.data:void 0}catch{return}},Px=async(e,t)=>{try{return t.safeParse(await e.json())}catch{return t.safeParse(null)}},ed=(e)=>{let t=e.url;while(t.endsWith("/"))t=t.slice(0,-1);return{get:async(r,n,o={})=>{let s=await Pe(`${t}${r}`,{headers:{Accept:"application/json",...o,"X-Auth-Token":e.token}});if(!s.ok){let a=await kx(s)??`${e.type} returned HTTP ${s.status}`;throw new rt(a,s.status)}let i=await Px(s,n);if(!i.success)throw new rt(`unexpected ${e.type} response: ${st(i.error)}`,s.status);return i.data}}};var td=async(e)=>{let t=await le(),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}},Sn=(e)=>e===Q?"nipa login":`nipa login -P ${e}`,rd=(e)=>{if(e.name!==Q){let t=Ue(`(${new URL(e.profile.authUrl).host})`);V(`Using profile ${A(e.name)} ${t}`)}},zx=/^\d{6}$/u,nd=/^[\da-f]{32}$/u,Ex=3,Cx=(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)=>zx.test(r)||"Enter the 6-digit code from your authenticator app"}),password:()=>e.secret("Password"),projectId:()=>e.text({message:"Project ID",validate:(t)=>nd.test(t)||"Enter the 32-character ID, as in OS_PROJECT_ID in your openrc file"})}),od=(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},sd=(e)=>{let{projects:t,wanted:r}=e;if(r)return Promise.resolve(od({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)},$n=(e,t)=>({expiresAt:e.expiresAt,project:e.project??t,token:e.value,user:e.user}),id=async(e)=>{let t=await e.ask(e.attempt);try{return await Y("Checking the code…",()=>np({account:e.account,passcode:t,receipt:e.receipt}))}catch(r){if(!(r instanceof X&&r.status===401)||e.attempt===Ex)throw r;return V("That code didn't work. Each code works once, so wait for the next one."),id({...e,attempt:e.attempt+1})}},Ox=async(e)=>{let{profile:t,prompts:r,wantedProject:n}=e,o=e.username??await r.email(t.username),s=n!==void 0&&nd.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 Y("Checking your password…",()=>rp(c,a)),l=u.kind==="token"?u.token:await id({account:c,ask:r.otp,attempt:1,receipt:u.receipt});if(!l.project)throw new X(`Keystone returned a token without project ${i}`,0);let p=s?void 0:n;if(p===void 0||l.project.name===p)return $n(l,l.project);let d=await Y("Loading your projects…",()=>ht({authUrl:t.authUrl,token:l.value})),f=od({projects:d,wanted:p}),m=await Y(`Switching to ${f.name}…`,()=>an({authUrl:t.authUrl,projectId:f.id,token:l.value}));return $n(m,f)},Es=async(e)=>{let{active:t,session:r}=e,n={...t.profile,project:r.project,username:r.user.name};await Me({...t.config,profiles:{...t.config.profiles,[t.name]:n}}),await hs({profile:t.name,session:r})},Cs=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=Ue(`(${new URL(t.profile.authUrl).host})`);V(`Logging in to ${A(t.name)} ${n}`);let o=await Ox({profile:t.profile,prompts:Cx(r),username:e.username,wantedProject:e.wantedProject});await Es({active:t,session:o});let s=A(o.user.name);return ue(`Logged in as ${s}, project ${A(o.project.name)}`),o},ad=async(e)=>{let{active:t,prompts:r}=e,n=await pe(t.name);if(ee(n))return{active:t,session:n};let o=`Run \`${Sn(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 V(n?"Your session expired.":"You aren't logged in yet."),{active:t,session:await Cs({active:t,prompts:r})}},Tx=(e)=>async(t)=>{try{return await t()}catch(r){if((r instanceof rt||r instanceof X?r.status:void 0)===401)throw new O(`your ${e} session expired or was revoked`,{hint:`Run \`${Sn(e)}\`.`});throw r}},cd=(e)=>{let{active:t,session:r}=e,{authUrl:n,region:o}=t.profile,s=Tx(t.name),{endpoints:i}=r,a=async()=>{if(!i)i=await s(()=>sp({authUrl:n,region:o,token:r.token})),await hs({profile:t.name,session:{...r,endpoints:i}});return i};return{active:t,service:async(c)=>{let l=(await a())[c];if(!l)throw new O(`there's no ${c} endpoint in ${o}`,{hint:"Check the profile's region with `nipa profile ls`."});let p=ed({token:r.token,type:c,url:l});return{get:(d,f,m)=>s(()=>p.get(d,f,m))}},session:r}};var ud=B({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 ld=Z(ud,async({client:e,flags:t})=>(await Cs({active:await e.profile(),prompts:e.prompts,username:t.username,wantedProject:t.project}),0));var pd=B({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 dd=Z(pd,async({client:e})=>{let t=await e.profile(),r=await pe(t.name);if(!r)return ft(`Not logged in to ${t.name}, so \`nipa logout\` did nothing`),0;if(ee(r))try{await Y("Logging out…",()=>cn({authUrl:t.profile.authUrl,token:r.token}))}catch{}return await mn(t.name),ue(`Logged out of ${A(t.name)}`),0});var fd=xt({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 md=yt(fd,({args:e,client:t,command:r})=>bt({args:e,command:r,signIn:t.cloud}));var Os=B({args:[],flags:[gt],name:"ls",summary:"List your profiles and who is logged in to each"}),Ts=B({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:"Make it the current profile",long:"use",value:{kind:"none"}}],name:"add",summary:"Add a profile, asking for missing values"}),Is=B({args:[{arity:"optional",name:"name",value:{kind:"profile"}}],flags:[],name:"use",summary:"Make a profile the current one"}),As=B({args:[{arity:"one",name:"name",value:{kind:"profile"}}],flags:[{...wp,description:"Remove it without asking"}],name:"rm",summary:"Remove a profile and log out of it"}),hd=yn({default:"ls",description:"A profile is a Keystone URL, user domain and region 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,Ts,Is,As],summary:"Manage Keystone profiles, such as staging"});var Ix=(e)=>(t)=>{if(!ls.test(t))return"Use lowercase letters, digits and hyphens, starting with a letter";return e.profiles[t]?`A profile named ${t} already exists`:!0},gd=(e)=>Xe.shape.authUrl.safeParse(e).success||"Enter an http or https URL, such as https://keystone.example.com/v3",xd=(e)=>{if(e.value!==void 0)return Promise.resolve(e.value);if(!e.prompts.interactive)throw F(`missing ${e.flag}`,"Pass every value as a flag when there is no terminal.");return e.ask()},yd=Z(Ts,async({args:e,client:t,flags:r})=>{let{prompts:n}=t,o=await le(),s=Ix(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 F(`can't add profile "${i}"`,a);let c=await xd({ask:()=>n.text({message:"Keystone URL",validate:gd}),flag:"--auth-url",prompts:n,value:r["auth-url"]}),u=gd(c);if(u!==!0)throw F(`invalid --auth-url "${c}"`,u);let l=r["user-domain"]??(n.interactive?await n.text({default:be.userDomain,message:"User domain"}):be.userDomain),p=r.region??(n.interactive?await n.text({default:be.region,message:"Region"}):be.region),d=performance.now(),f=await Y(`Checking ${c}…`,()=>ip(c)),m={authUrl:c,region:p,userDomain:l},g=r.use??(n.interactive&&await n.confirm({default:!0,message:`Use ${i} now?`}));return await Me({currentProfile:g?i:o.currentProfile,profiles:{...o.profiles,[i]:m}}),ue(`Added profile ${A(i)} (Keystone ${f})`,performance.now()-d),V(g?`Now using ${A(i)}. Run \`nipa login\` to log in to it.`:`Run \`nipa login -P ${i}\` to log in to it.`),0});var _d=Z(Os,async({client:e,flags:t})=>{let r=await le(),n=Object.keys(r.profiles).toSorted(),o=await Promise.all(n.map((i)=>pe(i)));if(t.json)return e.stdout.json(n.map((i,a)=>{let c=o[a];return{current:i===r.currentProfile,loggedIn:ee(c),name:i,...r.profiles[i],user:ee(c)?c.user.name:void 0}})),0;let s=n.map((i,a)=>{let c=r.profiles[i]??be,u=o[a],l=ee(u)?`${u.user.name} (${u.project.name})`:"-";return[i,new URL(c.authUrl).host,c.region,l].map((p)=>({text:p}))});return V(`${n.length} ${n.length===1?"profile":"profiles"}`),rn({headings:["Name","Keystone","Region","Logged in as"],marks:n.map((i)=>i===r.currentProfile?tn("✔"):" "),rows:s}),0});var bd=Z(As,async({args:e,client:t,flags:r})=>{let{name:n}=e,o=await le(),s=o.profiles[n];if(!s)throw new O(`no profile named "${n}"`);if(n===Q)throw new O(`can't remove ${Q}`,{hint:"nipa always has the Nipa Cloud production profile."});if(!r.yes){if(!t.prompts.interactive)throw F(`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 pe(n);if(ee(i))try{await cn({authUrl:s.authUrl,token:i.token})}catch{}await mn(n);let a=Object.fromEntries(Object.entries(o.profiles).filter(([u])=>u!==n)),c=o.currentProfile===n;if(await Me({currentProfile:c?Q:o.currentProfile,profiles:a}),ue(`Removed profile ${A(n)}`),c)V(`Now using ${A(Q)}`);return 0});var wd=Z(Is,async({args:e,client:t})=>{let r=await le(),n=Object.keys(r.profiles).toSorted(),{name:o}=e;if(o===void 0){if(!t.prompts.interactive)throw F("missing <name>",`Your profiles: ${n.join(", ")}`);o=await t.prompts.choice({choices:n.map((s)=>({name:s===r.currentProfile?`${s} ${A("(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 ${A(o)}`),0;return await Me({...r,currentProfile:o}),ue(`Now using profile ${A(o)}`),0});var vd=_n(hd,{add:yd,ls:_d,rm:bd,use:wd});var Rs="List the servers in your project",Zs=B({aliases:["list"],args:[],flags:[gt],name:"ls",summary:Rs}),$d=yn({aliases:["servers"],default:"ls",description:"Lists the servers in your project with their status, address, flavor and age. nipa calls the compute API itself, so you don't need the OpenStack client.",examples:[{command:"nipa server ls",description:Rs},{command:"nipa server ls --json | jq -r '.servers[].name'",description:"Print each server's name"}],name:"server",subcommands:[Zs],summary:Rs});var Ax={"OpenStack-API-Version":"compute 2.47"},Rx=I({"OS-EXT-IPS:type":v().optional(),addr:v(),version:Xu()}),Zx=I({addresses:lt(v(),Se(Rx)),created:v(),flavor:I({original_name:v()}),id:v(),name:v(),status:v()}),jx=I({href:v(),rel:v()}),Lx=I({servers:Se(Zx),servers_links:Se(jx).optional()}),Dx=(e)=>({addresses:Object.entries(e.addresses).flatMap(([t,r])=>r.map((n)=>({address:n.addr,network:t,type:n["OS-EXT-IPS:type"]??"fixed",version:n.version}))),createdAt:e.created,flavor:e.flavor.original_name,id:e.id,name:e.name,status:e.status}),Nx=(e=[])=>{let t=e.find((n)=>n.rel==="next");if(!t)return;return URL.parse(t.href,"http://localhost")?.searchParams.get("marker")??void 0},Sd=async(e)=>{let{compute:t,marker:r}=e,n=r===void 0?"":`?marker=${encodeURIComponent(r)}`,o=await t.get(`/servers/detail${n}`,Lx,Ax),s=o.servers.map(Dx),i=Nx(o.servers_links);if(i===void 0||i===r||s.length===0)return s;return[...s,...await Sd({compute:t,marker:i})]},kd=(e)=>Sd({compute:e});var Fx=new Map([["ACTIVE",tn],["BUILD",_e],["ERROR",rs],["HARD_REBOOT",_e],["MIGRATING",_e],["PASSWORD",_e],["REBOOT",_e],["REBUILD",_e],["RESCUE",_e],["RESIZE",_e],["REVERT_RESIZE",_e],["UNKNOWN",rs],["VERIFY_RESIZE",_e]]),Ux=(e)=>{let t=e.toLowerCase().replaceAll("_"," ");return`${t.charAt(0).toUpperCase()}${t.slice(1)}`},Pd=(e)=>{let t=e.addresses.filter((n)=>n.version===4);return(t.find((n)=>n.type==="floating")??t[0]??e.addresses[0])?.address},zd=(e)=>{let t=Fx.get(e)??en;return{paint:(r)=>`${t("●")}${r.slice(1)}`,text:`● ${Ux(e)}`}};var Mx=(e,t)=>{rn({headings:["Name","Status","Address","Flavor","Age"],rows:e.map((r)=>[{text:r.name},zd(r.status),{text:Pd(r)??"-"},{text:r.flavor},{paint:en,text:Vl(t-Date.parse(r.createdAt))}])})},Ed=Z(Zs,async({client:e,flags:t})=>{let{active:r,service:n,session:o}=await e.cloud(),{project:s}=o,i=performance.now(),a=await Y(`Loading the servers in ${s.name}…`,async()=>kd(await n("compute")));if(t.json)return e.stdout.json({profile:r.name,project:s,servers:a}),0;let c=Ue(`[${Ht(performance.now()-i)}]`);if(a.length===0)return V(`No servers in ${A(s.name)} ${c}`),0;if(V(`Servers in ${A(s.name)} ${c}`),Mx(a,Date.now()),!e.stdout.isTTY)e.stdout.line(a.map((u)=>u.id).join(`
|
|
306
|
+
`));return 0});var js=_n($d,{ls:Ed});var Cd=B({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 Bx=(e,t)=>(r)=>e.choice({choices:r.map((n)=>({description:n.id,name:n.id===t.id?`${n.name} ${A("(current)")}`:n.name,value:n})),default:r.find((n)=>n.id===t.id),message:"Switch to:"}),Od=Z(Cd,async({args:e,client:t})=>{let{project:r}=e,{active:n,session:o}=await t.session(),{authUrl:s}=n.profile,i=await Y("Loading your projects…",()=>ht({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 sd({ask:Bx(t.prompts,o.project),projects:i,wanted:r});if(a.id===o.project.id)return ft(`You're already using ${A(a.name)}`),0;let c=performance.now(),u=await Y(`Switching to ${a.name}…`,()=>an({authUrl:s,projectId:a.id,token:o.token}));return await Es({active:n,session:$n(u,a)}),ue(`Switched to ${A(a.name)}`,performance.now()-c),0});var Td=xt({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 Id=yt(Td,({args:e,client:t,command:r})=>bt({args:e,command:r,signIn:t.cloud}));var Ad=B({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:[gt],name:"whoami",summary:"Show who you're logged in as"});var Rd=Z(Ad,async({client:e,flags:t})=>{let r=await e.profile(),n=await pe(r.name);if(!ee(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 \`${Sn(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=Gl(gs(n));V(`Logged in as ${A(n.user.name)}`);let i=Ue(`(${o}, ${r.profile.region})`),a=Ue(`(${n.project.id})`);return V(`Profile: ${A(r.name)} ${i}`),V(`Project: ${A(n.project.name)} ${a}`),V(`The session expires in ${s}`),0});var Zd={examples:[{command:"nipa login",description:"Log in and pick a project"},{command:"nipa server ls",description:js.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:[Gp],sections:[{commands:[ld,dd,Rd,Od],title:"Session"},{commands:[js],title:"Resources"},{commands:[md,Id,Xp,Hp],title:"Run tools"},{commands:[vd,Kp],title:"Setup"}],summary:"Log in to Nipa Cloud once, then list your servers, or run openstack and terraform with the session."};var kn=nt(Ft(),1);var jd="https://github.com/PunGrumpy/nipa/releases",Vx="https://api.github.com/repos/PunGrumpy/nipa/releases/latest",Gx=86400000,Wx=I({checkedAt:Mr.datetime(),latest:v()}),Ld="update.json",Kx=I({tag_name:v()}),Dd=(e)=>e.replace(/^v/u,"").split("-")[0]?.split(".").map(Number)??[],Jx=(e,t)=>{let r=Dd(e),n=Dd(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},Hx=(e)=>e.isTTY&&e.version!=="0.0.0"&&!e.env.CI&&!e.env.NIPA_NO_UPDATE_CHECK,qx=async()=>{try{let e=await Pe(Vx,{signal:AbortSignal.timeout(1500)}),t=Kx.safeParse(await e.json());return t.success?t.data.tag_name.replace(/^v/u,""):void 0}catch(e){nn(`update check failed: ${e instanceof Error?e.message:String(e)}`);return}},Yx=(e,t)=>{let r=`${jd}/tag/v${e}`,n=kn.default.dim(`v${t}`),o=kn.default.green(`v${e}`),s=[`Update available! ${n} ≫ ${o}`,`Release notes: ${kn.default.cyan(r)}`],i=[`Update available! v${t} ≫ v${e}`,`Release notes: ${jd}/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(`
|
|
307
|
+
`)},Nd=async(e)=>{if(!Hx({env:process.env,isTTY:process.stderr.isTTY===!0,version:e}))return;let t=await dn(Ld,Wx);if(t&&Jx(t.latest,e))oe(Yx(t.latest,e));if(t&&Date.now()-Date.parse(t.checkedAt)<Gx)return;let r=await qx();if(r){let n={checkedAt:new Date().toISOString(),latest:r};await fn(Ld,n)}};var Ls=(e)=>{let t;return()=>(t??=e(),t)},Fd=(e)=>{let{globals:t,program:r}=e;if(t.debug)process.env.NIPA_DEBUG="1";let n=Kl({stderr:process.stderr,stdin:process.stdin}),o=Ls(()=>td({override:t.profile})),s=Ls(async()=>ad({active:await o(),prompts:n}));return{cloud:Ls(async()=>{let a=await s();return rd(a.active),cd(a)}),profile:o,program:r,prompts:n,session:s,stdout:Jl(process.stdout)}};var or=(e)=>({kind:"print",text:e}),Ud=(e,t)=>({exitCode:e,kind:"ran",updateNotice:t.every((r)=>r.updateNotice!==!1)}),Xx=(e)=>new Map([...e.sections.flatMap((t)=>t.commands),...e.hidden].flatMap((t)=>te(t.spec).map((r)=>[r,t]))),Qx=(e)=>{let t=e.at(-1)??"",r=e.slice(0,-1);return r.length===0?t:`${r.join(", ")} or ${t}`},ey=(e,t)=>F(`unknown subcommand "${e.spec.name} ${t}"`,`Use ${Qx(e.spec.subcommands.map((r)=>r.name))}.`),ty=(e,t)=>{let{rest:r}=Ps({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)}},ry=(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]},ny=(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},oy=(e)=>{let[t]=e.program.sections.flatMap((n)=>n.commands).map((n)=>({name:n.name,score:ny(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})},Md=async(e)=>{let t=Zp(e.program),r=Xx(e.program),n=Ps({unknown:"reject",words:e.argv});if(n.globals.version)return or(e.version);let[o,...s]=n.rest;if(o===void 0)return or(vs({program:t,version:e.version}));if(o==="help"){let p=ry(r,s);return or(p?xn(p):vs({program:t,version:e.version}))}let i=r.get(o);if(!i)throw oy({program:t,word:o});if(i.kind==="passthrough"){if(n.globals.help)return or(xn([i.spec]));let p=e.createClient({globals:n.globals,program:t});return Ud(await i.run({client:p,words:s}),[i.spec])}let a=i.kind==="group"?ty(i,s):{kind:"leaf",leaf:i,path:[i.spec],words:s};if(n.globals.help||Ip(s))return or(xn(a.kind==="leaf"?a.path:[i.spec]));if(a.kind==="unknown")throw ey(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 Ud(await c.run(l),a.path)};var sy="Run it again with --debug to see each request.",iy=(e)=>{if(e instanceof O)return e;if(e instanceof X||e instanceof rt){let t=e.status===0||e.status>=500;return new O(e.message,{hint:t&&!ns()?sy:void 0})}if(e instanceof on)return new O(e.message,{hint:"Check the Keystone URL with `nipa profile ls`, or your network connection."});if(e instanceof Xt)return new O(e.message,{hint:"Fix the file, or delete it and run `nipa login` again."});return};try{let e=await Md({argv:process.argv.slice(2),createClient:Fd,program:Zd,version:Cn.version});switch(e.kind){case"print":{console.log(e.text),process.exitCode=0;break}case"ran":{if(process.exitCode=e.exitCode,e.updateNotice)await Nd(Cn.version);break}default:throw Error(`unknown outcome ${String(e)}`)}}catch(e){let t=e instanceof Error?iy(e):void 0;if(!t)throw e;Wl(t),process.exitCode=t.exitCode}
|