@dmgnr/kuber 2.6.0 → 2.6.1-rc2
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/index.js +24 -24
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -7,33 +7,33 @@ var ab=Object.defineProperty;var cb=(e)=>e;function ub(e,t){this[e]=cb.bind(null
|
|
|
7
7
|
`);process.exit(1)}}function xc(e){return(t={})=>$b(e,t)}async function Ab(e){let t=await J(e.args||{}),r=new Set,o=new Set;for(let[n,i]of Object.entries(t)){r.add(n);for(let s of Ot(i.alias))o.add(s)}return{help:_c("help","h",r,o),version:_c("version","v",r,o)}}function _c(e,t,r,o){if(r.has(e)||o.has(e))return[];if(r.has(t)||o.has(t))return[`--${e}`];return[`--${e}`,`-${t}`]}var Oe,bb,Pr=(e,t=39)=>(r)=>bb?r:`\x1B[${e}m${r}\x1B[${t}m`,$r,ge,kr,Ar,Eb;var q=_(()=>{yc();Oe=class extends Error{code;constructor(e,t){super(e);this.name="CLIError",this.code=t}};bb=(()=>{let e=globalThis.process?.env??{};return e.NO_COLOR==="1"||e.TERM==="dumb"||e.TEST||e.CI})(),$r=Pr(1,22),ge=Pr(36),kr=Pr(90),Ar=Pr(4,24);Eb=/^no[-A-Z]/});function g(e,t,r){function o(a,c){if(!a._zod)Object.defineProperty(a,"_zod",{value:{def:c,constr:s,traits:new Set},enumerable:!1});if(a._zod.traits.has(e))return;a._zod.traits.add(e),t(a,c);let u=s.prototype,l=Object.keys(u);for(let f=0;f<l.length;f++){let d=l[f];if(!(d in a))a[d]=u[d].bind(a)}}let n=r?.Parent??Object;class i extends n{}Object.defineProperty(i,"name",{value:e});function s(a){var c;let u=r?.Parent?new i:this;o(u,a),(c=u._zod).deferred??(c.deferred=[]);for(let l of u._zod.deferred)l();return u}return Object.defineProperty(s,"init",{value:o}),Object.defineProperty(s,Symbol.hasInstance,{value:(a)=>{if(r?.Parent&&a instanceof r.Parent)return!0;return a?._zod?.traits?.has(e)}}),Object.defineProperty(s,"name",{value:e}),s}function H(e){if(e)Object.assign(ut,e);return ut}var Ec,kb,Ie,lt,ut;var Ge=_(()=>{kb=Symbol("zod_brand");Ie=class Ie extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}};lt=class lt extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`);this.name="ZodEncodeError"}};(Ec=globalThis).__zod_globalConfig??(Ec.__zod_globalConfig={});ut=globalThis.__zod_globalConfig});function Rr(e){let t=Object.values(e).filter((o)=>typeof o==="number");return Object.entries(e).filter(([o,n])=>t.indexOf(+o)===-1).map(([o,n])=>n)}function Bn(e,t="|"){return e.map((r)=>Ln(r)).join(t)}function It(e,t){if(typeof t==="bigint")return t.toString();return t}function Bt(e){return{get value(){{let r=e();return Object.defineProperty(this,"value",{value:r}),r}throw Error("cached value already set")}}}function Ke(e){return e===null||e===void 0}function Tr(e){let t=e.startsWith("^")?1:0,r=e.endsWith("$")?e.length-1:e.length;return e.slice(t,r)}function $c(e,t){let r=e/t,o=Math.round(r),n=Number.EPSILON*Math.max(Math.abs(r),1);if(Math.abs(r-o)<n)return 0;return r-o}function I(e,t,r){let o=void 0;Object.defineProperty(e,t,{get(){if(o===Sc)return;if(o===void 0)o=Sc,o=r();return o},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function He(e,t,r){Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0})}function Le(...e){let t={};for(let r of e){let o=Object.getOwnPropertyDescriptors(r);Object.assign(t,o)}return Object.defineProperties({},t)}function zn(e){return JSON.stringify(e)}function Ac(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}function pt(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}function Je(e){if(pt(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(pt(r)===!1)return!1;if(Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)return!1;return!0}function Nn(e){if(Je(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}function ye(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function pe(e,t,r){let o=new e._zod.constr(t??e._zod.def);if(!t||r?.parent)o._zod.parent=e;return o}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 Ln(e){if(typeof e==="bigint")return e.toString()+"n";if(typeof e==="string")return`"${e}"`;return`${e}`}function Cc(e){return Object.keys(e).filter((t)=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}function Pb(e,t){let r=e._zod.def,o=r.checks;if(o&&o.length>0)throw Error(".pick() cannot be used on object schemas containing refinements");let i=Le(e._zod.def,{get shape(){let s={};for(let a in t){if(!(a in r.shape))throw Error(`Unrecognized key: "${a}"`);if(!t[a])continue;s[a]=r.shape[a]}return He(this,"shape",s),s},checks:[]});return pe(e,i)}function Cb(e,t){let r=e._zod.def,o=r.checks;if(o&&o.length>0)throw Error(".omit() cannot be used on object schemas containing refinements");let i=Le(e._zod.def,{get shape(){let s={...e._zod.def.shape};for(let a in t){if(!(a in r.shape))throw Error(`Unrecognized key: "${a}"`);if(!t[a])continue;delete s[a]}return He(this,"shape",s),s},checks:[]});return pe(e,i)}function Rb(e,t){if(!Je(t))throw Error("Invalid input to extend: expected a plain object");let r=e._zod.def.checks;if(r&&r.length>0){let i=e._zod.def.shape;for(let s in t)if(Object.getOwnPropertyDescriptor(i,s)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}let n=Le(e._zod.def,{get shape(){let i={...e._zod.def.shape,...t};return He(this,"shape",i),i}});return pe(e,n)}function Tb(e,t){if(!Je(t))throw Error("Invalid input to safeExtend: expected a plain object");let r=Le(e._zod.def,{get shape(){let o={...e._zod.def.shape,...t};return He(this,"shape",o),o}});return pe(e,r)}function Ob(e,t){if(e._zod.def.checks?.length)throw Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");let r=Le(e._zod.def,{get shape(){let o={...e._zod.def.shape,...t._zod.def.shape};return He(this,"shape",o),o},get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return pe(e,r)}function Ib(e,t,r){let n=t._zod.def.checks;if(n&&n.length>0)throw Error(".partial() cannot be used on object schemas containing refinements");let s=Le(t._zod.def,{get shape(){let a=t._zod.def.shape,c={...a};if(r)for(let u in r){if(!(u in a))throw Error(`Unrecognized key: "${u}"`);if(!r[u])continue;c[u]=e?new e({type:"optional",innerType:a[u]}):a[u]}else for(let u in a)c[u]=e?new e({type:"optional",innerType:a[u]}):a[u];return He(this,"shape",c),c},checks:[]});return pe(t,s)}function Bb(e,t,r){let o=Le(t._zod.def,{get shape(){let n=t._zod.def.shape,i={...n};if(r)for(let s in r){if(!(s in i))throw Error(`Unrecognized key: "${s}"`);if(!r[s])continue;i[s]=new e({type:"nonoptional",innerType:n[s]})}else for(let s in n)i[s]=new e({type:"nonoptional",innerType:n[s]});return He(this,"shape",i),i}});return pe(t,o)}function Ye(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 Oc(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 ae(e,t){return t.map((r)=>{var o;return(o=r).path??(o.path=[]),r.path.unshift(e),r})}function Cr(e){return typeof e==="string"?e:e?.message}function ne(e,t,r){let o=e.message?e.message:Cr(e.inst?._zod.def?.error?.(e))??Cr(t?.error?.(e))??Cr(r.customError?.(e))??Cr(r.localeError?.(e))??"Invalid input",{inst:n,continue:i,input:s,...a}=e;if(a.path??(a.path=[]),a.message=o,t?.reportInput)a.input=s;return a}function Ir(e){if(e instanceof Set)return"set";if(e instanceof Map)return"map";if(e instanceof File)return"file";return"unknown"}function Br(e){if(Array.isArray(e))return"array";if(typeof e==="string")return"string";return"unknown"}function Ic(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 Xe(...e){let[t,r,o]=e;if(typeof t==="string")return{message:t,code:"custom",input:r,inst:o};return{...t}}var Sc,Dn,kc,Or,Pc,Rc,Tc;var de=_(()=>{Ge();Sc=Symbol("evaluating");Dn="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};kc=Bt(()=>{if(ut.jitless)return!1;if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{return new Function(""),!0}catch(e){return!1}});Or=new Set(["string","number","symbol"]),Pc=new Set(["string","number","bigint","boolean","symbol","undefined"]);Rc={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]},Tc={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]}});function Vn(e,t=(r)=>r.message){let r={},o=[];for(let n of e.issues)if(n.path.length>0)r[n.path[0]]=r[n.path[0]]||[],r[n.path[0]].push(t(n));else o.push(t(n));return{formErrors:o,fieldErrors:r}}function Un(e,t=(r)=>r.message){let r={_errors:[]},o=(n,i=[])=>{for(let s of n.issues)if(s.code==="invalid_union"&&s.errors.length)s.errors.map((a)=>o({issues:a},[...i,...s.path]));else if(s.code==="invalid_key")o({issues:s.issues},[...i,...s.path]);else if(s.code==="invalid_element")o({issues:s.issues},[...i,...s.path]);else{let a=[...i,...s.path];if(a.length===0)r._errors.push(t(s));else{let c=r,u=0;while(u<a.length){let l=a[u];if(u!==a.length-1)c[l]=c[l]||{_errors:[]};else c[l]=c[l]||{_errors:[]},c[l]._errors.push(t(s));c=c[l],u++}}}};return o(e),r}function zb(e){let t=[],r=e.map((o)=>typeof o==="object"?o.key:o);for(let o of r)if(typeof o==="number")t.push(`[${o}]`);else if(typeof o==="symbol")t.push(`[${JSON.stringify(String(o))}]`);else if(/[^\w$]/.test(o))t.push(`[${JSON.stringify(o)}]`);else{if(t.length)t.push(".");t.push(o)}return t.join("")}function zc(e){let t=[],r=[...e.issues].sort((o,n)=>(o.path??[]).length-(n.path??[]).length);for(let o of r)if(t.push(`\u2716 ${o.message}`),o.path?.length)t.push(` \u2192 at ${zb(o.path)}`);return t.join(`
|
|
8
8
|
`)}var Bc=(e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,It,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},zr,zt;var Mn=_(()=>{Ge();de();zr=g("$ZodError",Bc),zt=g("$ZodError",Bc,{Parent:Error})});var Dt=(e)=>(t,r,o,n)=>{let i=o?{...o,async:!1}:{async:!1},s=t._zod.run({value:r,issues:[]},i);if(s instanceof Promise)throw new Ie;if(s.issues.length){let a=new(n?.Err??e)(s.issues.map((c)=>ne(c,i,H())));throw Dn(a,n?.callee),a}return s.value},Fn,Nt=(e)=>async(t,r,o,n)=>{let i=o?{...o,async:!0}:{async:!0},s=t._zod.run({value:r,issues:[]},i);if(s instanceof Promise)s=await s;if(s.issues.length){let a=new(n?.Err??e)(s.issues.map((c)=>ne(c,i,H())));throw Dn(a,n?.callee),a}return s.value},jn,Lt=(e)=>(t,r,o)=>{let n=o?{...o,async:!1}:{async:!1},i=t._zod.run({value:r,issues:[]},n);if(i instanceof Promise)throw new Ie;return i.issues.length?{success:!1,error:new(e??zr)(i.issues.map((s)=>ne(s,n,H())))}:{success:!0,data:i.value}},Dc,Vt=(e)=>async(t,r,o)=>{let n=o?{...o,async:!0}:{async:!0},i=t._zod.run({value:r,issues:[]},n);if(i instanceof Promise)i=await i;return i.issues.length?{success:!1,error:new e(i.issues.map((s)=>ne(s,n,H())))}:{success:!0,data:i.value}},Nc,Lc=(e)=>(t,r,o)=>{let n=o?{...o,direction:"backward"}:{direction:"backward"};return Dt(e)(t,r,n)},Vc=(e)=>(t,r,o)=>Dt(e)(t,r,o),Uc=(e)=>async(t,r,o)=>{let n=o?{...o,direction:"backward"}:{direction:"backward"};return Nt(e)(t,r,n)},Mc=(e)=>async(t,r,o)=>Nt(e)(t,r,o),Fc=(e)=>(t,r,o)=>{let n=o?{...o,direction:"backward"}:{direction:"backward"};return Lt(e)(t,r,n)},jc=(e)=>(t,r,o)=>Lt(e)(t,r,o),Zc=(e)=>async(t,r,o)=>{let n=o?{...o,direction:"backward"}:{direction:"backward"};return Vt(e)(t,r,n)},qc=(e)=>async(t,r,o)=>Vt(e)(t,r,o);var Zn=_(()=>{Ge();Mn();de();Fn=Dt(zt),jn=Nt(zt),Dc=Lt(zt),Nc=Vt(zt)});var tt={};Er(tt,{base64:()=>si,base64url:()=>Dr,bigint:()=>di,boolean:()=>mi,browserEmail:()=>Zb,cidrv4:()=>ni,cidrv6:()=>ii,cuid:()=>qn,cuid2:()=>Qn,date:()=>ci,datetime:()=>li,domain:()=>Gc,duration:()=>Jn,e164:()=>ai,email:()=>Xn,emoji:()=>ei,extendedDuration:()=>Nb,guid:()=>Yn,hex:()=>Jc,hostname:()=>Wc,html5Email:()=>Mb,httpProtocol:()=>Nr,idnEmail:()=>jb,integer:()=>fi,ipv4:()=>ti,ipv6:()=>ri,ksuid:()=>Kn,lowercase:()=>yi,mac:()=>oi,md5_base64:()=>Wb,md5_base64url:()=>Gb,md5_hex:()=>Qb,nanoid:()=>Hn,null:()=>hi,number:()=>Lr,rfc5322Email:()=>Fb,sha1_base64:()=>Hb,sha1_base64url:()=>Jb,sha1_hex:()=>Kb,sha256_base64:()=>Xb,sha256_base64url:()=>e_,sha256_hex:()=>Yb,sha384_base64:()=>r_,sha384_base64url:()=>o_,sha384_hex:()=>t_,sha512_base64:()=>i_,sha512_base64url:()=>s_,sha512_hex:()=>n_,string:()=>pi,time:()=>ui,ulid:()=>Wn,undefined:()=>gi,unicodeEmail:()=>Qc,uppercase:()=>bi,uuid:()=>et,uuid4:()=>Lb,uuid6:()=>Vb,uuid7:()=>Ub,xid:()=>Gn});function ei(){return new RegExp(qb,"u")}function Hc(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}}`:"(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?"}function ui(e){return new RegExp(`^${Hc(e)}$`)}function li(e){let t=Hc({precision:e.precision}),r=["Z"];if(e.local)r.push("");if(e.offset)r.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");let o=`${t}(?:${r.join("|")})`;return new RegExp(`^${Kc}T(?:${o})$`)}function Ut(e,t){return new RegExp(`^[A-Za-z0-9+/]{${e}}${t}$`)}function Mt(e){return new RegExp(`^[A-Za-z0-9_-]{${e}}$`)}var qn,Qn,Wn,Gn,Kn,Hn,Jn,Nb,Yn,et=(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})$`)},Lb,Vb,Ub,Xn,Mb,Fb,Qc,jb,Zb,qb="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",ti,ri,oi=(e)=>{let t=ye(e??":");return new RegExp(`^(?:[0-9A-F]{2}${t}){5}[0-9A-F]{2}$|^(?:[0-9a-f]{2}${t}){5}[0-9a-f]{2}$`)},ni,ii,si,Dr,Wc,Gc,Nr,ai,Kc="(?:(?:\\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])))",ci,pi=(e)=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},di,fi,Lr,mi,hi,gi,yi,bi,Jc,Qb,Wb,Gb,Kb,Hb,Jb,Yb,Xb,e_,t_,r_,o_,n_,i_,s_;var Vr=_(()=>{de();qn=/^[cC][0-9a-z]{6,}$/,Qn=/^[0-9a-z]+$/,Wn=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,Gn=/^[0-9a-vA-V]{20}$/,Kn=/^[A-Za-z0-9]{27}$/,Hn=/^[a-zA-Z0-9_-]{21}$/,Jn=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Nb=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,Yn=/^([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})$/,Lb=et(4),Vb=et(6),Ub=et(7),Xn=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,Mb=/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/,Fb=/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/,Qc=/^[^\s@"]{1,64}@[^\s@]{1,255}$/u,jb=Qc,Zb=/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/;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])$/,ri=/^(([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}|:))$/,ni=/^((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})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,si=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Dr=/^[A-Za-z0-9_-]*$/,Wc=/^(?=.{1,253}\.?$)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[-0-9a-zA-Z]{0,61}[0-9a-zA-Z])?)*\.?$/,Gc=/^([a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$/,Nr=/^https?$/,ai=/^\+[1-9]\d{6,14}$/,ci=new RegExp(`^${Kc}$`);di=/^-?\d+n?$/,fi=/^-?\d+$/,Lr=/^-?\d+(?:\.\d+)?$/,mi=/^(?:true|false)$/i,hi=/^null$/i,gi=/^undefined$/i,yi=/^[^A-Z]*$/,bi=/^[^a-z]*$/,Jc=/^[0-9a-fA-F]*$/;Qb=/^[0-9a-fA-F]{32}$/,Wb=Ut(22,"=="),Gb=Mt(22),Kb=/^[0-9a-fA-F]{40}$/,Hb=Ut(27,"="),Jb=Mt(27),Yb=/^[0-9a-fA-F]{64}$/,Xb=Ut(43,"="),e_=Mt(43),t_=/^[0-9a-fA-F]{96}$/,r_=Ut(64,""),o_=Mt(64),n_=/^[0-9a-fA-F]{128}$/,i_=Ut(86,"=="),s_=Mt(86)});function Yc(e,t,r){if(e.issues.length)t.issues.push(...ae(r,e.issues))}var U,Xc,_i,wi,eu,tu,ru,ou,nu,iu,su,au,cu,Ft,uu,lu,pu,du,fu,mu,hu,gu,yu;var Ur=_(()=>{Ge();Vr();de();U=g("$ZodCheck",(e,t)=>{var r;e._zod??(e._zod={}),e._zod.def=t,(r=e._zod).onattach??(r.onattach=[])}),Xc={number:"number",bigint:"bigint",object:"date"},_i=g("$ZodCheckLessThan",(e,t)=>{U.init(e,t);let r=Xc[typeof t.value];e._zod.onattach.push((o)=>{let n=o._zod.bag,i=(t.inclusive?n.maximum:n.exclusiveMaximum)??Number.POSITIVE_INFINITY;if(t.value<i)if(t.inclusive)n.maximum=t.value;else n.exclusiveMaximum=t.value}),e._zod.check=(o)=>{if(t.inclusive?o.value<=t.value:o.value<t.value)return;o.issues.push({origin:r,code:"too_big",maximum:typeof t.value==="object"?t.value.getTime():t.value,input:o.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),wi=g("$ZodCheckGreaterThan",(e,t)=>{U.init(e,t);let r=Xc[typeof t.value];e._zod.onattach.push((o)=>{let n=o._zod.bag,i=(t.inclusive?n.minimum:n.exclusiveMinimum)??Number.NEGATIVE_INFINITY;if(t.value>i)if(t.inclusive)n.minimum=t.value;else n.exclusiveMinimum=t.value}),e._zod.check=(o)=>{if(t.inclusive?o.value>=t.value:o.value>t.value)return;o.issues.push({origin:r,code:"too_small",minimum:typeof t.value==="object"?t.value.getTime():t.value,input:o.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),eu=g("$ZodCheckMultipleOf",(e,t)=>{U.init(e,t),e._zod.onattach.push((r)=>{var o;(o=r._zod.bag).multipleOf??(o.multipleOf=t.value)}),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"?r.value%t.value===BigInt(0):$c(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})}}),tu=g("$ZodCheckNumberFormat",(e,t)=>{U.init(e,t),t.format=t.format||"float64";let r=t.format?.includes("int"),o=r?"int":"number",[n,i]=Rc[t.format];e._zod.onattach.push((s)=>{let a=s._zod.bag;if(a.format=t.format,a.minimum=n,a.maximum=i,r)a.pattern=fi}),e._zod.check=(s)=>{let a=s.value;if(r){if(!Number.isInteger(a)){s.issues.push({expected:o,format:t.format,code:"invalid_type",continue:!1,input:a,inst:e});return}if(!Number.isSafeInteger(a)){if(a>0)s.issues.push({input:a,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:o,inclusive:!0,continue:!t.abort});else s.issues.push({input:a,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:o,inclusive:!0,continue:!t.abort});return}}if(a<n)s.issues.push({origin:"number",input:a,code:"too_small",minimum:n,inclusive:!0,inst:e,continue:!t.abort});if(a>i)s.issues.push({origin:"number",input:a,code:"too_big",maximum:i,inclusive:!0,inst:e,continue:!t.abort})}}),ru=g("$ZodCheckBigIntFormat",(e,t)=>{U.init(e,t);let[r,o]=Tc[t.format];e._zod.onattach.push((n)=>{let i=n._zod.bag;i.format=t.format,i.minimum=r,i.maximum=o}),e._zod.check=(n)=>{let i=n.value;if(i<r)n.issues.push({origin:"bigint",input:i,code:"too_small",minimum:r,inclusive:!0,inst:e,continue:!t.abort});if(i>o)n.issues.push({origin:"bigint",input:i,code:"too_big",maximum:o,inclusive:!0,inst:e,continue:!t.abort})}}),ou=g("$ZodCheckMaxSize",(e,t)=>{var r;U.init(e,t),(r=e._zod.def).when??(r.when=(o)=>{let n=o.value;return!Ke(n)&&n.size!==void 0}),e._zod.onattach.push((o)=>{let n=o._zod.bag.maximum??Number.POSITIVE_INFINITY;if(t.maximum<n)o._zod.bag.maximum=t.maximum}),e._zod.check=(o)=>{let n=o.value;if(n.size<=t.maximum)return;o.issues.push({origin:Ir(n),code:"too_big",maximum:t.maximum,inclusive:!0,input:n,inst:e,continue:!t.abort})}}),nu=g("$ZodCheckMinSize",(e,t)=>{var r;U.init(e,t),(r=e._zod.def).when??(r.when=(o)=>{let n=o.value;return!Ke(n)&&n.size!==void 0}),e._zod.onattach.push((o)=>{let n=o._zod.bag.minimum??Number.NEGATIVE_INFINITY;if(t.minimum>n)o._zod.bag.minimum=t.minimum}),e._zod.check=(o)=>{let n=o.value;if(n.size>=t.minimum)return;o.issues.push({origin:Ir(n),code:"too_small",minimum:t.minimum,inclusive:!0,input:n,inst:e,continue:!t.abort})}}),iu=g("$ZodCheckSizeEquals",(e,t)=>{var r;U.init(e,t),(r=e._zod.def).when??(r.when=(o)=>{let n=o.value;return!Ke(n)&&n.size!==void 0}),e._zod.onattach.push((o)=>{let n=o._zod.bag;n.minimum=t.size,n.maximum=t.size,n.size=t.size}),e._zod.check=(o)=>{let n=o.value,i=n.size;if(i===t.size)return;let s=i>t.size;o.issues.push({origin:Ir(n),...s?{code:"too_big",maximum:t.size}:{code:"too_small",minimum:t.size},inclusive:!0,exact:!0,input:o.value,inst:e,continue:!t.abort})}}),su=g("$ZodCheckMaxLength",(e,t)=>{var r;U.init(e,t),(r=e._zod.def).when??(r.when=(o)=>{let n=o.value;return!Ke(n)&&n.length!==void 0}),e._zod.onattach.push((o)=>{let n=o._zod.bag.maximum??Number.POSITIVE_INFINITY;if(t.maximum<n)o._zod.bag.maximum=t.maximum}),e._zod.check=(o)=>{let n=o.value;if(n.length<=t.maximum)return;let s=Br(n);o.issues.push({origin:s,code:"too_big",maximum:t.maximum,inclusive:!0,input:n,inst:e,continue:!t.abort})}}),au=g("$ZodCheckMinLength",(e,t)=>{var r;U.init(e,t),(r=e._zod.def).when??(r.when=(o)=>{let n=o.value;return!Ke(n)&&n.length!==void 0}),e._zod.onattach.push((o)=>{let n=o._zod.bag.minimum??Number.NEGATIVE_INFINITY;if(t.minimum>n)o._zod.bag.minimum=t.minimum}),e._zod.check=(o)=>{let n=o.value;if(n.length>=t.minimum)return;let s=Br(n);o.issues.push({origin:s,code:"too_small",minimum:t.minimum,inclusive:!0,input:n,inst:e,continue:!t.abort})}}),cu=g("$ZodCheckLengthEquals",(e,t)=>{var r;U.init(e,t),(r=e._zod.def).when??(r.when=(o)=>{let n=o.value;return!Ke(n)&&n.length!==void 0}),e._zod.onattach.push((o)=>{let n=o._zod.bag;n.minimum=t.length,n.maximum=t.length,n.length=t.length}),e._zod.check=(o)=>{let n=o.value,i=n.length;if(i===t.length)return;let s=Br(n),a=i>t.length;o.issues.push({origin:s,...a?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:o.value,inst:e,continue:!t.abort})}}),Ft=g("$ZodCheckStringFormat",(e,t)=>{var r,o;if(U.init(e,t),e._zod.onattach.push((n)=>{let i=n._zod.bag;if(i.format=t.format,t.pattern)i.patterns??(i.patterns=new Set),i.patterns.add(t.pattern)}),t.pattern)(r=e._zod).check??(r.check=(n)=>{if(t.pattern.lastIndex=0,t.pattern.test(n.value))return;n.issues.push({origin:"string",code:"invalid_format",format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})});else(o=e._zod).check??(o.check=()=>{})}),uu=g("$ZodCheckRegex",(e,t)=>{Ft.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})}}),lu=g("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=yi),Ft.init(e,t)}),pu=g("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=bi),Ft.init(e,t)}),du=g("$ZodCheckIncludes",(e,t)=>{U.init(e,t);let r=ye(t.includes),o=new RegExp(typeof t.position==="number"?`^.{${t.position}}${r}`:r);t.pattern=o,e._zod.onattach.push((n)=>{let i=n._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(o)}),e._zod.check=(n)=>{if(n.value.includes(t.includes,t.position))return;n.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:n.value,inst:e,continue:!t.abort})}}),fu=g("$ZodCheckStartsWith",(e,t)=>{U.init(e,t);let r=new RegExp(`^${ye(t.prefix)}.*`);t.pattern??(t.pattern=r),e._zod.onattach.push((o)=>{let n=o._zod.bag;n.patterns??(n.patterns=new Set),n.patterns.add(r)}),e._zod.check=(o)=>{if(o.value.startsWith(t.prefix))return;o.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:o.value,inst:e,continue:!t.abort})}}),mu=g("$ZodCheckEndsWith",(e,t)=>{U.init(e,t);let r=new RegExp(`.*${ye(t.suffix)}$`);t.pattern??(t.pattern=r),e._zod.onattach.push((o)=>{let n=o._zod.bag;n.patterns??(n.patterns=new Set),n.patterns.add(r)}),e._zod.check=(o)=>{if(o.value.endsWith(t.suffix))return;o.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:o.value,inst:e,continue:!t.abort})}});hu=g("$ZodCheckProperty",(e,t)=>{U.init(e,t),e._zod.check=(r)=>{let o=t.schema._zod.run({value:r.value[t.property],issues:[]},{});if(o instanceof Promise)return o.then((n)=>Yc(n,r,t.property));Yc(o,r,t.property);return}}),gu=g("$ZodCheckMimeType",(e,t)=>{U.init(e,t);let r=new Set(t.mime);e._zod.onattach.push((o)=>{o._zod.bag.mime=t.mime}),e._zod.check=(o)=>{if(r.has(o.value.type))return;o.issues.push({code:"invalid_value",values:t.mime,input:o.value.type,inst:e,continue:!t.abort})}}),yu=g("$ZodCheckOverwrite",(e,t)=>{U.init(e,t),e._zod.check=(r)=>{r.value=t.tx(r.value)}})});class vi{constructor(e=[]){if(this.content=[],this.indent=0,this)this.args=e}indented(e){this.indent+=1,e(this),this.indent-=1}write(e){if(typeof e==="function"){e(this,{execution:"sync"}),e(this,{execution:"async"});return}let r=e.split(`
|
|
9
9
|
`).filter((i)=>i),o=Math.min(...r.map((i)=>i.length-i.trimStart().length)),n=r.map((i)=>i.slice(o)).map((i)=>" ".repeat(this.indent*2)+i);for(let i of n)this.content.push(i)}compile(){let e=Function,t=this?.args,o=[...(this?.content??[""]).map((n)=>` ${n}`)];return new e(...t,o.join(`
|
|
10
|
-
`))}}var _u;var xi=_(()=>{_u={major:4,minor:4,patch:3}});function el(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}}function a_(e){if(!Dr.test(e))return!1;let t=e.replace(/[-_]/g,(o)=>o==="-"?"+":"/"),r=t.padEnd(Math.ceil(t.length/4)*4,"=");return el(r)}function c_(e,t=null){try{let r=e.split(".");if(r.length!==3)return!1;let[o]=r;if(!o)return!1;let n=JSON.parse(atob(o));if("typ"in n&&n?.typ!=="JWT")return!1;if(!n.alg)return!1;if(t&&(!("alg"in n)||n.alg!==t))return!1;return!0}catch{return!1}}function wu(e,t,r){if(e.issues.length)t.issues.push(...ae(r,e.issues));t.value[r]=e.value}function Zr(e,t,r,o,n,i){let s=r in o;if(e.issues.length){if(n&&i&&!s)return;t.issues.push(...ae(r,e.issues))}if(!s&&!n){if(!e.issues.length)t.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[r]});return}if(e.value===void 0){if(s)t.value[r]=void 0}else t.value[r]=e.value}function yl(e){let t=Object.keys(e.shape);for(let o of t)if(!e.shape?.[o]?._zod?.traits?.has("$ZodType"))throw Error(`Invalid element at key "${o}": expected a Zod schema`);let r=Cc(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(r)}}function bl(e,t,r,o,n,i){let s=[],a=n.keySet,c=n.catchall._zod,u=c.def.type,l=c.optin==="optional",f=c.optout==="optional";for(let d in t){if(d==="__proto__")continue;if(a.has(d))continue;if(u==="never"){s.push(d);continue}let p=c.run({value:t[d],issues:[]},o);if(p instanceof Promise)e.push(p.then((m)=>Zr(m,r,d,t,l,f)));else Zr(p,r,d,t,l,f)}if(s.length)r.issues.push({code:"unrecognized_keys",keys:s,input:t,inst:i});if(!e.length)return r;return Promise.all(e).then(()=>r)}function vu(e,t,r,o){for(let i of e)if(i.issues.length===0)return t.value=i.value,t;let n=e.filter((i)=>!Ye(i));if(n.length===1)return t.value=n[0].value,n[0];return t.issues.push({code:"invalid_union",input:t.value,inst:r,errors:e.map((i)=>i.issues.map((s)=>ne(s,o,H())))}),t}function xu(e,t,r,o){let n=e.filter((i)=>i.issues.length===0);if(n.length===1)return t.value=n[0].value,t;if(n.length===0)t.issues.push({code:"invalid_union",input:t.value,inst:r,errors:e.map((i)=>i.issues.map((s)=>ne(s,o,H())))});else t.issues.push({code:"invalid_union",input:t.value,inst:r,errors:[],inclusive:!1});return t}function Ei(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(Je(e)&&Je(t)){let r=Object.keys(t),o=Object.keys(e).filter((i)=>r.indexOf(i)!==-1),n={...e,...t};for(let i of o){let s=Ei(e[i],t[i]);if(!s.valid)return{valid:!1,mergeErrorPath:[i,...s.mergeErrorPath]};n[i]=s.data}return{valid:!0,data:n}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let r=[];for(let o=0;o<e.length;o++){let n=e[o],i=t[o],s=Ei(n,i);if(!s.valid)return{valid:!1,mergeErrorPath:[o,...s.mergeErrorPath]};r.push(s.data)}return{valid:!0,data:r}}return{valid:!1,mergeErrorPath:[]}}function Eu(e,t,r){let o=new Map,n;for(let a of t.issues)if(a.code==="unrecognized_keys"){n??(n=a);for(let c of a.keys){if(!o.has(c))o.set(c,{});o.get(c).l=!0}}else e.issues.push(a);for(let a of r.issues)if(a.code==="unrecognized_keys")for(let c of a.keys){if(!o.has(c))o.set(c,{});o.get(c).r=!0}else e.issues.push(a);let i=[...o].filter(([,a])=>a.l&&a.r).map(([a])=>a);if(i.length&&n)e.issues.push({...n,keys:i});if(Ye(e))return e;let s=Ei(t.value,r.value);if(!s.valid)throw Error(`Unmergable intersection. Error path: ${JSON.stringify(s.mergeErrorPath)}`);return e.value=s.data,e}function Su(e,t){for(let r=e.length-1;r>=0;r--)if(e[r]._zod[t]!=="optional")return r+1;return 0}function $u(e,t,r){if(e.issues.length)t.issues.push(...ae(r,e.issues));t.value[r]=e.value}function Au(e,t,r,o,n){for(let i=0;i<r.length;i++){let s=e[i],a=i<o.length;if(s.issues.length){if(!a&&i>=n){t.value.length=i;break}t.issues.push(...ae(i,s.issues))}t.value[i]=s.value}for(let i=t.value.length-1;i>=o.length;i--)if(r[i]._zod.optout==="optional"&&t.value[i]===void 0)t.value.length=i;else break;return t}function ku(e,t,r,o,n,i,s){if(e.issues.length)if(Or.has(typeof o))r.issues.push(...ae(o,e.issues));else r.issues.push({code:"invalid_key",origin:"map",input:n,inst:i,issues:e.issues.map((a)=>ne(a,s,H()))});if(t.issues.length)if(Or.has(typeof o))r.issues.push(...ae(o,t.issues));else r.issues.push({origin:"map",code:"invalid_element",input:n,inst:i,key:o,issues:t.issues.map((a)=>ne(a,s,H()))});r.value.set(e.value,t.value)}function Pu(e,t){if(e.issues.length)t.issues.push(...e.issues);t.value.add(e.value)}function Cu(e,t){if(t===void 0&&(e.issues.length||e.fallback))return{issues:[],value:void 0};return e}function Ru(e,t){if(e.value===void 0)e.value=t.defaultValue;return e}function Tu(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 Mr(e,t,r){if(e.issues.length)return e.aborted=!0,e;return t._zod.run({value:e.value,issues:e.issues,fallback:e.fallback},r)}function Fr(e,t,r){if(e.issues.length)return e.aborted=!0,e;if((r.direction||"forward")==="forward"){let n=t.transform(e.value,e);if(n instanceof Promise)return n.then((i)=>jr(e,i,t.out,r));return jr(e,n,t.out,r)}else{let n=t.reverseTransform(e.value,e);if(n instanceof Promise)return n.then((i)=>jr(e,i,t.in,r));return jr(e,n,t.in,r)}}function jr(e,t,r,o){if(e.issues.length)return e.aborted=!0,e;return r._zod.run({value:t,issues:e.issues},o)}function Ou(e){return e.value=Object.freeze(e.value),e}function Iu(e,t,r,o){if(!e){let n={code:"custom",input:r,inst:o,path:[...o._zod.def.path??[]],continue:!o._zod.def.abort};if(o._zod.def.params)n.params=o._zod.def.params;t.issues.push(Xe(n))}}var R,dt,N,Bu,zu,Du,Nu,Lu,Vu,Uu,Mu,Fu,ju,Zu,qu,Qu,Wu,Gu,Ku,Hu,Ju,Yu,Xu,tl,rl,ol,nl,il,Si,sl,qr,$i,al,cl,ul,ll,pl,dl,fl,ml,hl,gl,u_,_l,Qr,wl,vl,xl,Ai,El,Sl,$l,Al,kl,Pl,Cl,ki,Rl,Tl,Ol,Il,Bl,zl,Dl,Nl,Pi,Wr,Ll,Vl,Ul,Ml,Fl,jl,Zl;var Ci=_(()=>{Ur();Ge();Zn();Vr();de();xi();de();R=g("$ZodType",(e,t)=>{var r;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=_u;let o=[...e._zod.def.checks??[]];if(e._zod.traits.has("$ZodCheck"))o.unshift(e);for(let n of o)for(let i of n._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 n=(s,a,c)=>{let u=Ye(s),l;for(let f of a){if(f._zod.def.when){if(Oc(s))continue;if(!f._zod.def.when(s))continue}else if(u)continue;let d=s.issues.length,p=f._zod.check(s);if(p instanceof Promise&&c?.async===!1)throw new Ie;if(l||p instanceof Promise)l=(l??Promise.resolve()).then(async()=>{if(await p,s.issues.length===d)return;if(!u)u=Ye(s,d)});else{if(s.issues.length===d)continue;if(!u)u=Ye(s,d)}}if(l)return l.then(()=>s);return s},i=(s,a,c)=>{if(Ye(s))return s.aborted=!0,s;let u=n(a,o,c);if(u instanceof Promise){if(c.async===!1)throw new Ie;return u.then((l)=>e._zod.parse(l,c))}return e._zod.parse(u,c)};e._zod.run=(s,a)=>{if(a.skipChecks)return e._zod.parse(s,a);if(a.direction==="backward"){let u=e._zod.parse({value:s.value,issues:[]},{...a,skipChecks:!0});if(u instanceof Promise)return u.then((l)=>i(l,s,a));return i(u,s,a)}let c=e._zod.parse(s,a);if(c instanceof Promise){if(a.async===!1)throw new Ie;return c.then((u)=>n(u,o,a))}return n(c,o,a)}}I(e,"~standard",()=>({validate:(n)=>{try{let i=Dc(e,n);return i.success?{value:i.data}:{issues:i.error?.issues}}catch(i){return Nc(e,n).then((s)=>s.success?{value:s.data}:{issues:s.error?.issues})}},vendor:"zod",version:1}))}),dt=g("$ZodString",(e,t)=>{R.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??pi(e._zod.bag),e._zod.parse=(r,o)=>{if(t.coerce)try{r.value=String(r.value)}catch(n){}if(typeof r.value==="string")return r;return r.issues.push({expected:"string",code:"invalid_type",input:r.value,inst:e}),r}}),N=g("$ZodStringFormat",(e,t)=>{Ft.init(e,t),dt.init(e,t)}),Bu=g("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=Yn),N.init(e,t)}),zu=g("$ZodUUID",(e,t)=>{if(t.version){let o={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(o===void 0)throw Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=et(o))}else t.pattern??(t.pattern=et());N.init(e,t)}),Du=g("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=Xn),N.init(e,t)}),Nu=g("$ZodURL",(e,t)=>{N.init(e,t),e._zod.check=(r)=>{try{let o=r.value.trim();if(!t.normalize&&t.protocol?.source===Nr.source){if(!/^https?:\/\//i.test(o)){r.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:r.value,inst:e,continue:!t.abort});return}}let n=new URL(o);if(t.hostname){if(t.hostname.lastIndex=0,!t.hostname.test(n.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){if(t.protocol.lastIndex=0,!t.protocol.test(n.protocol.endsWith(":")?n.protocol.slice(0,-1):n.protocol))r.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:r.value,inst:e,continue:!t.abort})}if(t.normalize)r.value=n.href;else r.value=o;return}catch(o){r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:e,continue:!t.abort})}}}),Lu=g("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=ei()),N.init(e,t)}),Vu=g("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=Hn),N.init(e,t)}),Uu=g("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=qn),N.init(e,t)}),Mu=g("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=Qn),N.init(e,t)}),Fu=g("$ZodULID",(e,t)=>{t.pattern??(t.pattern=Wn),N.init(e,t)}),ju=g("$ZodXID",(e,t)=>{t.pattern??(t.pattern=Gn),N.init(e,t)}),Zu=g("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=Kn),N.init(e,t)}),qu=g("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=li(t)),N.init(e,t)}),Qu=g("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=ci),N.init(e,t)}),Wu=g("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=ui(t)),N.init(e,t)}),Gu=g("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=Jn),N.init(e,t)}),Ku=g("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=ti),N.init(e,t),e._zod.bag.format="ipv4"}),Hu=g("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=ri),N.init(e,t),e._zod.bag.format="ipv6",e._zod.check=(r)=>{try{new URL(`http://[${r.value}]`)}catch{r.issues.push({code:"invalid_format",format:"ipv6",input:r.value,inst:e,continue:!t.abort})}}}),Ju=g("$ZodMAC",(e,t)=>{t.pattern??(t.pattern=oi(t.delimiter)),N.init(e,t),e._zod.bag.format="mac"}),Yu=g("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=ni),N.init(e,t)}),Xu=g("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=ii),N.init(e,t),e._zod.check=(r)=>{let o=r.value.split("/");try{if(o.length!==2)throw Error();let[n,i]=o;if(!i)throw Error();let s=Number(i);if(`${s}`!==i)throw Error();if(s<0||s>128)throw Error();new URL(`http://[${n}]`)}catch{r.issues.push({code:"invalid_format",format:"cidrv6",input:r.value,inst:e,continue:!t.abort})}}});tl=g("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=si),N.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=(r)=>{if(el(r.value))return;r.issues.push({code:"invalid_format",format:"base64",input:r.value,inst:e,continue:!t.abort})}});rl=g("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=Dr),N.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=(r)=>{if(a_(r.value))return;r.issues.push({code:"invalid_format",format:"base64url",input:r.value,inst:e,continue:!t.abort})}}),ol=g("$ZodE164",(e,t)=>{t.pattern??(t.pattern=ai),N.init(e,t)});nl=g("$ZodJWT",(e,t)=>{N.init(e,t),e._zod.check=(r)=>{if(c_(r.value,t.alg))return;r.issues.push({code:"invalid_format",format:"jwt",input:r.value,inst:e,continue:!t.abort})}}),il=g("$ZodCustomStringFormat",(e,t)=>{N.init(e,t),e._zod.check=(r)=>{if(t.fn(r.value))return;r.issues.push({code:"invalid_format",format:t.format,input:r.value,inst:e,continue:!t.abort})}}),Si=g("$ZodNumber",(e,t)=>{R.init(e,t),e._zod.pattern=e._zod.bag.pattern??Lr,e._zod.parse=(r,o)=>{if(t.coerce)try{r.value=Number(r.value)}catch(s){}let n=r.value;if(typeof n==="number"&&!Number.isNaN(n)&&Number.isFinite(n))return r;let i=typeof n==="number"?Number.isNaN(n)?"NaN":!Number.isFinite(n)?"Infinity":void 0:void 0;return r.issues.push({expected:"number",code:"invalid_type",input:n,inst:e,...i?{received:i}:{}}),r}}),sl=g("$ZodNumberFormat",(e,t)=>{tu.init(e,t),Si.init(e,t)}),qr=g("$ZodBoolean",(e,t)=>{R.init(e,t),e._zod.pattern=mi,e._zod.parse=(r,o)=>{if(t.coerce)try{r.value=Boolean(r.value)}catch(i){}let n=r.value;if(typeof n==="boolean")return r;return r.issues.push({expected:"boolean",code:"invalid_type",input:n,inst:e}),r}}),$i=g("$ZodBigInt",(e,t)=>{R.init(e,t),e._zod.pattern=di,e._zod.parse=(r,o)=>{if(t.coerce)try{r.value=BigInt(r.value)}catch(n){}if(typeof r.value==="bigint")return r;return r.issues.push({expected:"bigint",code:"invalid_type",input:r.value,inst:e}),r}}),al=g("$ZodBigIntFormat",(e,t)=>{ru.init(e,t),$i.init(e,t)}),cl=g("$ZodSymbol",(e,t)=>{R.init(e,t),e._zod.parse=(r,o)=>{let n=r.value;if(typeof n==="symbol")return r;return r.issues.push({expected:"symbol",code:"invalid_type",input:n,inst:e}),r}}),ul=g("$ZodUndefined",(e,t)=>{R.init(e,t),e._zod.pattern=gi,e._zod.values=new Set([void 0]),e._zod.parse=(r,o)=>{let n=r.value;if(typeof n>"u")return r;return r.issues.push({expected:"undefined",code:"invalid_type",input:n,inst:e}),r}}),ll=g("$ZodNull",(e,t)=>{R.init(e,t),e._zod.pattern=hi,e._zod.values=new Set([null]),e._zod.parse=(r,o)=>{let n=r.value;if(n===null)return r;return r.issues.push({expected:"null",code:"invalid_type",input:n,inst:e}),r}}),pl=g("$ZodAny",(e,t)=>{R.init(e,t),e._zod.parse=(r)=>r}),dl=g("$ZodUnknown",(e,t)=>{R.init(e,t),e._zod.parse=(r)=>r}),fl=g("$ZodNever",(e,t)=>{R.init(e,t),e._zod.parse=(r,o)=>(r.issues.push({expected:"never",code:"invalid_type",input:r.value,inst:e}),r)}),ml=g("$ZodVoid",(e,t)=>{R.init(e,t),e._zod.parse=(r,o)=>{let n=r.value;if(typeof n>"u")return r;return r.issues.push({expected:"void",code:"invalid_type",input:n,inst:e}),r}}),hl=g("$ZodDate",(e,t)=>{R.init(e,t),e._zod.parse=(r,o)=>{if(t.coerce)try{r.value=new Date(r.value)}catch(a){}let n=r.value,i=n instanceof Date;if(i&&!Number.isNaN(n.getTime()))return r;return r.issues.push({expected:"date",code:"invalid_type",input:n,...i?{received:"Invalid Date"}:{},inst:e}),r}});gl=g("$ZodArray",(e,t)=>{R.init(e,t),e._zod.parse=(r,o)=>{let n=r.value;if(!Array.isArray(n))return r.issues.push({expected:"array",code:"invalid_type",input:n,inst:e}),r;r.value=Array(n.length);let i=[];for(let s=0;s<n.length;s++){let a=n[s],c=t.element._zod.run({value:a,issues:[]},o);if(c instanceof Promise)i.push(c.then((u)=>wu(u,r,s)));else wu(c,r,s)}if(i.length)return Promise.all(i).then(()=>r);return r}});u_=g("$ZodObject",(e,t)=>{if(R.init(e,t),!Object.getOwnPropertyDescriptor(t,"shape")?.get){let a=t.shape;Object.defineProperty(t,"shape",{get:()=>{let c={...a};return Object.defineProperty(t,"shape",{value:c}),c}})}let o=Bt(()=>yl(t));I(e._zod,"propValues",()=>{let a=t.shape,c={};for(let u in a){let l=a[u]._zod;if(l.values){c[u]??(c[u]=new Set);for(let f of l.values)c[u].add(f)}}return c});let n=pt,i=t.catchall,s;e._zod.parse=(a,c)=>{s??(s=o.value);let u=a.value;if(!n(u))return a.issues.push({expected:"object",code:"invalid_type",input:u,inst:e}),a;a.value={};let l=[],f=s.shape;for(let d of s.keys){let p=f[d],m=p._zod.optin==="optional",h=p._zod.optout==="optional",y=p._zod.run({value:u[d],issues:[]},c);if(y instanceof Promise)l.push(y.then((b)=>Zr(b,a,d,u,m,h)));else Zr(y,a,d,u,m,h)}if(!i)return l.length?Promise.all(l).then(()=>a):a;return bl(l,u,a,c,o.value,e)}}),_l=g("$ZodObjectJIT",(e,t)=>{u_.init(e,t);let r=e._zod.parse,o=Bt(()=>yl(t)),n=(d)=>{let p=new vi(["shape","payload","ctx"]),m=o.value,h=(E)=>{let A=zn(E);return`shape[${A}]._zod.run({ value: input[${A}], issues: [] }, ctx)`};p.write("const input = payload.value;");let y=Object.create(null),b=0;for(let E of m.keys)y[E]=`key_${b++}`;p.write("const newResult = {};");for(let E of m.keys){let A=y[E],x=zn(E),k=d[E],T=k?._zod?.optin==="optional",B=k?._zod?.optout==="optional";if(p.write(`const ${A} = ${h(E)};`),T&&B)p.write(`
|
|
11
|
-
if (${
|
|
10
|
+
`))}}var _u;var xi=_(()=>{_u={major:4,minor:4,patch:3}});function el(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}}function a_(e){if(!Dr.test(e))return!1;let t=e.replace(/[-_]/g,(o)=>o==="-"?"+":"/"),r=t.padEnd(Math.ceil(t.length/4)*4,"=");return el(r)}function c_(e,t=null){try{let r=e.split(".");if(r.length!==3)return!1;let[o]=r;if(!o)return!1;let n=JSON.parse(atob(o));if("typ"in n&&n?.typ!=="JWT")return!1;if(!n.alg)return!1;if(t&&(!("alg"in n)||n.alg!==t))return!1;return!0}catch{return!1}}function wu(e,t,r){if(e.issues.length)t.issues.push(...ae(r,e.issues));t.value[r]=e.value}function Zr(e,t,r,o,n,i){let s=r in o;if(e.issues.length){if(n&&i&&!s)return;t.issues.push(...ae(r,e.issues))}if(!s&&!n){if(!e.issues.length)t.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[r]});return}if(e.value===void 0){if(s)t.value[r]=void 0}else t.value[r]=e.value}function yl(e){let t=Object.keys(e.shape);for(let o of t)if(!e.shape?.[o]?._zod?.traits?.has("$ZodType"))throw Error(`Invalid element at key "${o}": expected a Zod schema`);let r=Cc(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(r)}}function bl(e,t,r,o,n,i){let s=[],a=n.keySet,c=n.catchall._zod,u=c.def.type,l=c.optin==="optional",f=c.optout==="optional";for(let d in t){if(d==="__proto__")continue;if(a.has(d))continue;if(u==="never"){s.push(d);continue}let p=c.run({value:t[d],issues:[]},o);if(p instanceof Promise)e.push(p.then((m)=>Zr(m,r,d,t,l,f)));else Zr(p,r,d,t,l,f)}if(s.length)r.issues.push({code:"unrecognized_keys",keys:s,input:t,inst:i});if(!e.length)return r;return Promise.all(e).then(()=>r)}function vu(e,t,r,o){for(let i of e)if(i.issues.length===0)return t.value=i.value,t;let n=e.filter((i)=>!Ye(i));if(n.length===1)return t.value=n[0].value,n[0];return t.issues.push({code:"invalid_union",input:t.value,inst:r,errors:e.map((i)=>i.issues.map((s)=>ne(s,o,H())))}),t}function xu(e,t,r,o){let n=e.filter((i)=>i.issues.length===0);if(n.length===1)return t.value=n[0].value,t;if(n.length===0)t.issues.push({code:"invalid_union",input:t.value,inst:r,errors:e.map((i)=>i.issues.map((s)=>ne(s,o,H())))});else t.issues.push({code:"invalid_union",input:t.value,inst:r,errors:[],inclusive:!1});return t}function Ei(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(Je(e)&&Je(t)){let r=Object.keys(t),o=Object.keys(e).filter((i)=>r.indexOf(i)!==-1),n={...e,...t};for(let i of o){let s=Ei(e[i],t[i]);if(!s.valid)return{valid:!1,mergeErrorPath:[i,...s.mergeErrorPath]};n[i]=s.data}return{valid:!0,data:n}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let r=[];for(let o=0;o<e.length;o++){let n=e[o],i=t[o],s=Ei(n,i);if(!s.valid)return{valid:!1,mergeErrorPath:[o,...s.mergeErrorPath]};r.push(s.data)}return{valid:!0,data:r}}return{valid:!1,mergeErrorPath:[]}}function Eu(e,t,r){let o=new Map,n;for(let a of t.issues)if(a.code==="unrecognized_keys"){n??(n=a);for(let c of a.keys){if(!o.has(c))o.set(c,{});o.get(c).l=!0}}else e.issues.push(a);for(let a of r.issues)if(a.code==="unrecognized_keys")for(let c of a.keys){if(!o.has(c))o.set(c,{});o.get(c).r=!0}else e.issues.push(a);let i=[...o].filter(([,a])=>a.l&&a.r).map(([a])=>a);if(i.length&&n)e.issues.push({...n,keys:i});if(Ye(e))return e;let s=Ei(t.value,r.value);if(!s.valid)throw Error(`Unmergable intersection. Error path: ${JSON.stringify(s.mergeErrorPath)}`);return e.value=s.data,e}function Su(e,t){for(let r=e.length-1;r>=0;r--)if(e[r]._zod[t]!=="optional")return r+1;return 0}function $u(e,t,r){if(e.issues.length)t.issues.push(...ae(r,e.issues));t.value[r]=e.value}function Au(e,t,r,o,n){for(let i=0;i<r.length;i++){let s=e[i],a=i<o.length;if(s.issues.length){if(!a&&i>=n){t.value.length=i;break}t.issues.push(...ae(i,s.issues))}t.value[i]=s.value}for(let i=t.value.length-1;i>=o.length;i--)if(r[i]._zod.optout==="optional"&&t.value[i]===void 0)t.value.length=i;else break;return t}function ku(e,t,r,o,n,i,s){if(e.issues.length)if(Or.has(typeof o))r.issues.push(...ae(o,e.issues));else r.issues.push({code:"invalid_key",origin:"map",input:n,inst:i,issues:e.issues.map((a)=>ne(a,s,H()))});if(t.issues.length)if(Or.has(typeof o))r.issues.push(...ae(o,t.issues));else r.issues.push({origin:"map",code:"invalid_element",input:n,inst:i,key:o,issues:t.issues.map((a)=>ne(a,s,H()))});r.value.set(e.value,t.value)}function Pu(e,t){if(e.issues.length)t.issues.push(...e.issues);t.value.add(e.value)}function Cu(e,t){if(t===void 0&&(e.issues.length||e.fallback))return{issues:[],value:void 0};return e}function Ru(e,t){if(e.value===void 0)e.value=t.defaultValue;return e}function Tu(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 Mr(e,t,r){if(e.issues.length)return e.aborted=!0,e;return t._zod.run({value:e.value,issues:e.issues,fallback:e.fallback},r)}function Fr(e,t,r){if(e.issues.length)return e.aborted=!0,e;if((r.direction||"forward")==="forward"){let n=t.transform(e.value,e);if(n instanceof Promise)return n.then((i)=>jr(e,i,t.out,r));return jr(e,n,t.out,r)}else{let n=t.reverseTransform(e.value,e);if(n instanceof Promise)return n.then((i)=>jr(e,i,t.in,r));return jr(e,n,t.in,r)}}function jr(e,t,r,o){if(e.issues.length)return e.aborted=!0,e;return r._zod.run({value:t,issues:e.issues},o)}function Ou(e){return e.value=Object.freeze(e.value),e}function Iu(e,t,r,o){if(!e){let n={code:"custom",input:r,inst:o,path:[...o._zod.def.path??[]],continue:!o._zod.def.abort};if(o._zod.def.params)n.params=o._zod.def.params;t.issues.push(Xe(n))}}var R,dt,N,Bu,zu,Du,Nu,Lu,Vu,Uu,Mu,Fu,ju,Zu,qu,Qu,Wu,Gu,Ku,Hu,Ju,Yu,Xu,tl,rl,ol,nl,il,Si,sl,qr,$i,al,cl,ul,ll,pl,dl,fl,ml,hl,gl,u_,_l,Qr,wl,vl,xl,Ai,El,Sl,$l,Al,kl,Pl,Cl,ki,Rl,Tl,Ol,Il,Bl,zl,Dl,Nl,Pi,Wr,Ll,Vl,Ul,Ml,Fl,jl,Zl;var Ci=_(()=>{Ur();Ge();Zn();Vr();de();xi();de();R=g("$ZodType",(e,t)=>{var r;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=_u;let o=[...e._zod.def.checks??[]];if(e._zod.traits.has("$ZodCheck"))o.unshift(e);for(let n of o)for(let i of n._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 n=(s,a,c)=>{let u=Ye(s),l;for(let f of a){if(f._zod.def.when){if(Oc(s))continue;if(!f._zod.def.when(s))continue}else if(u)continue;let d=s.issues.length,p=f._zod.check(s);if(p instanceof Promise&&c?.async===!1)throw new Ie;if(l||p instanceof Promise)l=(l??Promise.resolve()).then(async()=>{if(await p,s.issues.length===d)return;if(!u)u=Ye(s,d)});else{if(s.issues.length===d)continue;if(!u)u=Ye(s,d)}}if(l)return l.then(()=>s);return s},i=(s,a,c)=>{if(Ye(s))return s.aborted=!0,s;let u=n(a,o,c);if(u instanceof Promise){if(c.async===!1)throw new Ie;return u.then((l)=>e._zod.parse(l,c))}return e._zod.parse(u,c)};e._zod.run=(s,a)=>{if(a.skipChecks)return e._zod.parse(s,a);if(a.direction==="backward"){let u=e._zod.parse({value:s.value,issues:[]},{...a,skipChecks:!0});if(u instanceof Promise)return u.then((l)=>i(l,s,a));return i(u,s,a)}let c=e._zod.parse(s,a);if(c instanceof Promise){if(a.async===!1)throw new Ie;return c.then((u)=>n(u,o,a))}return n(c,o,a)}}I(e,"~standard",()=>({validate:(n)=>{try{let i=Dc(e,n);return i.success?{value:i.data}:{issues:i.error?.issues}}catch(i){return Nc(e,n).then((s)=>s.success?{value:s.data}:{issues:s.error?.issues})}},vendor:"zod",version:1}))}),dt=g("$ZodString",(e,t)=>{R.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??pi(e._zod.bag),e._zod.parse=(r,o)=>{if(t.coerce)try{r.value=String(r.value)}catch(n){}if(typeof r.value==="string")return r;return r.issues.push({expected:"string",code:"invalid_type",input:r.value,inst:e}),r}}),N=g("$ZodStringFormat",(e,t)=>{Ft.init(e,t),dt.init(e,t)}),Bu=g("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=Yn),N.init(e,t)}),zu=g("$ZodUUID",(e,t)=>{if(t.version){let o={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(o===void 0)throw Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=et(o))}else t.pattern??(t.pattern=et());N.init(e,t)}),Du=g("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=Xn),N.init(e,t)}),Nu=g("$ZodURL",(e,t)=>{N.init(e,t),e._zod.check=(r)=>{try{let o=r.value.trim();if(!t.normalize&&t.protocol?.source===Nr.source){if(!/^https?:\/\//i.test(o)){r.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:r.value,inst:e,continue:!t.abort});return}}let n=new URL(o);if(t.hostname){if(t.hostname.lastIndex=0,!t.hostname.test(n.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){if(t.protocol.lastIndex=0,!t.protocol.test(n.protocol.endsWith(":")?n.protocol.slice(0,-1):n.protocol))r.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:r.value,inst:e,continue:!t.abort})}if(t.normalize)r.value=n.href;else r.value=o;return}catch(o){r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:e,continue:!t.abort})}}}),Lu=g("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=ei()),N.init(e,t)}),Vu=g("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=Hn),N.init(e,t)}),Uu=g("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=qn),N.init(e,t)}),Mu=g("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=Qn),N.init(e,t)}),Fu=g("$ZodULID",(e,t)=>{t.pattern??(t.pattern=Wn),N.init(e,t)}),ju=g("$ZodXID",(e,t)=>{t.pattern??(t.pattern=Gn),N.init(e,t)}),Zu=g("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=Kn),N.init(e,t)}),qu=g("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=li(t)),N.init(e,t)}),Qu=g("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=ci),N.init(e,t)}),Wu=g("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=ui(t)),N.init(e,t)}),Gu=g("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=Jn),N.init(e,t)}),Ku=g("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=ti),N.init(e,t),e._zod.bag.format="ipv4"}),Hu=g("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=ri),N.init(e,t),e._zod.bag.format="ipv6",e._zod.check=(r)=>{try{new URL(`http://[${r.value}]`)}catch{r.issues.push({code:"invalid_format",format:"ipv6",input:r.value,inst:e,continue:!t.abort})}}}),Ju=g("$ZodMAC",(e,t)=>{t.pattern??(t.pattern=oi(t.delimiter)),N.init(e,t),e._zod.bag.format="mac"}),Yu=g("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=ni),N.init(e,t)}),Xu=g("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=ii),N.init(e,t),e._zod.check=(r)=>{let o=r.value.split("/");try{if(o.length!==2)throw Error();let[n,i]=o;if(!i)throw Error();let s=Number(i);if(`${s}`!==i)throw Error();if(s<0||s>128)throw Error();new URL(`http://[${n}]`)}catch{r.issues.push({code:"invalid_format",format:"cidrv6",input:r.value,inst:e,continue:!t.abort})}}});tl=g("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=si),N.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=(r)=>{if(el(r.value))return;r.issues.push({code:"invalid_format",format:"base64",input:r.value,inst:e,continue:!t.abort})}});rl=g("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=Dr),N.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=(r)=>{if(a_(r.value))return;r.issues.push({code:"invalid_format",format:"base64url",input:r.value,inst:e,continue:!t.abort})}}),ol=g("$ZodE164",(e,t)=>{t.pattern??(t.pattern=ai),N.init(e,t)});nl=g("$ZodJWT",(e,t)=>{N.init(e,t),e._zod.check=(r)=>{if(c_(r.value,t.alg))return;r.issues.push({code:"invalid_format",format:"jwt",input:r.value,inst:e,continue:!t.abort})}}),il=g("$ZodCustomStringFormat",(e,t)=>{N.init(e,t),e._zod.check=(r)=>{if(t.fn(r.value))return;r.issues.push({code:"invalid_format",format:t.format,input:r.value,inst:e,continue:!t.abort})}}),Si=g("$ZodNumber",(e,t)=>{R.init(e,t),e._zod.pattern=e._zod.bag.pattern??Lr,e._zod.parse=(r,o)=>{if(t.coerce)try{r.value=Number(r.value)}catch(s){}let n=r.value;if(typeof n==="number"&&!Number.isNaN(n)&&Number.isFinite(n))return r;let i=typeof n==="number"?Number.isNaN(n)?"NaN":!Number.isFinite(n)?"Infinity":void 0:void 0;return r.issues.push({expected:"number",code:"invalid_type",input:n,inst:e,...i?{received:i}:{}}),r}}),sl=g("$ZodNumberFormat",(e,t)=>{tu.init(e,t),Si.init(e,t)}),qr=g("$ZodBoolean",(e,t)=>{R.init(e,t),e._zod.pattern=mi,e._zod.parse=(r,o)=>{if(t.coerce)try{r.value=Boolean(r.value)}catch(i){}let n=r.value;if(typeof n==="boolean")return r;return r.issues.push({expected:"boolean",code:"invalid_type",input:n,inst:e}),r}}),$i=g("$ZodBigInt",(e,t)=>{R.init(e,t),e._zod.pattern=di,e._zod.parse=(r,o)=>{if(t.coerce)try{r.value=BigInt(r.value)}catch(n){}if(typeof r.value==="bigint")return r;return r.issues.push({expected:"bigint",code:"invalid_type",input:r.value,inst:e}),r}}),al=g("$ZodBigIntFormat",(e,t)=>{ru.init(e,t),$i.init(e,t)}),cl=g("$ZodSymbol",(e,t)=>{R.init(e,t),e._zod.parse=(r,o)=>{let n=r.value;if(typeof n==="symbol")return r;return r.issues.push({expected:"symbol",code:"invalid_type",input:n,inst:e}),r}}),ul=g("$ZodUndefined",(e,t)=>{R.init(e,t),e._zod.pattern=gi,e._zod.values=new Set([void 0]),e._zod.parse=(r,o)=>{let n=r.value;if(typeof n>"u")return r;return r.issues.push({expected:"undefined",code:"invalid_type",input:n,inst:e}),r}}),ll=g("$ZodNull",(e,t)=>{R.init(e,t),e._zod.pattern=hi,e._zod.values=new Set([null]),e._zod.parse=(r,o)=>{let n=r.value;if(n===null)return r;return r.issues.push({expected:"null",code:"invalid_type",input:n,inst:e}),r}}),pl=g("$ZodAny",(e,t)=>{R.init(e,t),e._zod.parse=(r)=>r}),dl=g("$ZodUnknown",(e,t)=>{R.init(e,t),e._zod.parse=(r)=>r}),fl=g("$ZodNever",(e,t)=>{R.init(e,t),e._zod.parse=(r,o)=>(r.issues.push({expected:"never",code:"invalid_type",input:r.value,inst:e}),r)}),ml=g("$ZodVoid",(e,t)=>{R.init(e,t),e._zod.parse=(r,o)=>{let n=r.value;if(typeof n>"u")return r;return r.issues.push({expected:"void",code:"invalid_type",input:n,inst:e}),r}}),hl=g("$ZodDate",(e,t)=>{R.init(e,t),e._zod.parse=(r,o)=>{if(t.coerce)try{r.value=new Date(r.value)}catch(a){}let n=r.value,i=n instanceof Date;if(i&&!Number.isNaN(n.getTime()))return r;return r.issues.push({expected:"date",code:"invalid_type",input:n,...i?{received:"Invalid Date"}:{},inst:e}),r}});gl=g("$ZodArray",(e,t)=>{R.init(e,t),e._zod.parse=(r,o)=>{let n=r.value;if(!Array.isArray(n))return r.issues.push({expected:"array",code:"invalid_type",input:n,inst:e}),r;r.value=Array(n.length);let i=[];for(let s=0;s<n.length;s++){let a=n[s],c=t.element._zod.run({value:a,issues:[]},o);if(c instanceof Promise)i.push(c.then((u)=>wu(u,r,s)));else wu(c,r,s)}if(i.length)return Promise.all(i).then(()=>r);return r}});u_=g("$ZodObject",(e,t)=>{if(R.init(e,t),!Object.getOwnPropertyDescriptor(t,"shape")?.get){let a=t.shape;Object.defineProperty(t,"shape",{get:()=>{let c={...a};return Object.defineProperty(t,"shape",{value:c}),c}})}let o=Bt(()=>yl(t));I(e._zod,"propValues",()=>{let a=t.shape,c={};for(let u in a){let l=a[u]._zod;if(l.values){c[u]??(c[u]=new Set);for(let f of l.values)c[u].add(f)}}return c});let n=pt,i=t.catchall,s;e._zod.parse=(a,c)=>{s??(s=o.value);let u=a.value;if(!n(u))return a.issues.push({expected:"object",code:"invalid_type",input:u,inst:e}),a;a.value={};let l=[],f=s.shape;for(let d of s.keys){let p=f[d],m=p._zod.optin==="optional",h=p._zod.optout==="optional",y=p._zod.run({value:u[d],issues:[]},c);if(y instanceof Promise)l.push(y.then((b)=>Zr(b,a,d,u,m,h)));else Zr(y,a,d,u,m,h)}if(!i)return l.length?Promise.all(l).then(()=>a):a;return bl(l,u,a,c,o.value,e)}}),_l=g("$ZodObjectJIT",(e,t)=>{u_.init(e,t);let r=e._zod.parse,o=Bt(()=>yl(t)),n=(d)=>{let p=new vi(["shape","payload","ctx"]),m=o.value,h=(E)=>{let k=zn(E);return`shape[${k}]._zod.run({ value: input[${k}], issues: [] }, ctx)`};p.write("const input = payload.value;");let y=Object.create(null),b=0;for(let E of m.keys)y[E]=`key_${b++}`;p.write("const newResult = {};");for(let E of m.keys){let k=y[E],x=zn(E),A=d[E],T=A?._zod?.optin==="optional",B=A?._zod?.optout==="optional";if(p.write(`const ${k} = ${h(E)};`),T&&B)p.write(`
|
|
11
|
+
if (${k}.issues.length) {
|
|
12
12
|
if (${x} in input) {
|
|
13
|
-
payload.issues = payload.issues.concat(${
|
|
13
|
+
payload.issues = payload.issues.concat(${k}.issues.map(iss => ({
|
|
14
14
|
...iss,
|
|
15
15
|
path: iss.path ? [${x}, ...iss.path] : [${x}]
|
|
16
16
|
})));
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
if (${
|
|
20
|
+
if (${k}.value === undefined) {
|
|
21
21
|
if (${x} in input) {
|
|
22
22
|
newResult[${x}] = undefined;
|
|
23
23
|
}
|
|
24
24
|
} else {
|
|
25
|
-
newResult[${x}] = ${
|
|
25
|
+
newResult[${x}] = ${k}.value;
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
`);else if(!T)p.write(`
|
|
29
|
-
const ${
|
|
30
|
-
if (${
|
|
31
|
-
payload.issues = payload.issues.concat(${
|
|
29
|
+
const ${k}_present = ${x} in input;
|
|
30
|
+
if (${k}.issues.length) {
|
|
31
|
+
payload.issues = payload.issues.concat(${k}.issues.map(iss => ({
|
|
32
32
|
...iss,
|
|
33
33
|
path: iss.path ? [${x}, ...iss.path] : [${x}]
|
|
34
34
|
})));
|
|
35
35
|
}
|
|
36
|
-
if (!${
|
|
36
|
+
if (!${k}_present && !${k}.issues.length) {
|
|
37
37
|
payload.issues.push({
|
|
38
38
|
code: "invalid_type",
|
|
39
39
|
expected: "nonoptional",
|
|
@@ -42,31 +42,31 @@ var ab=Object.defineProperty;var cb=(e)=>e;function ub(e,t){this[e]=cb.bind(null
|
|
|
42
42
|
});
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
if (${
|
|
46
|
-
if (${
|
|
45
|
+
if (${k}_present) {
|
|
46
|
+
if (${k}.value === undefined) {
|
|
47
47
|
newResult[${x}] = undefined;
|
|
48
48
|
} else {
|
|
49
|
-
newResult[${x}] = ${
|
|
49
|
+
newResult[${x}] = ${k}.value;
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
`);else p.write(`
|
|
54
|
-
if (${
|
|
55
|
-
payload.issues = payload.issues.concat(${
|
|
54
|
+
if (${k}.issues.length) {
|
|
55
|
+
payload.issues = payload.issues.concat(${k}.issues.map(iss => ({
|
|
56
56
|
...iss,
|
|
57
57
|
path: iss.path ? [${x}, ...iss.path] : [${x}]
|
|
58
58
|
})));
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
-
if (${
|
|
61
|
+
if (${k}.value === undefined) {
|
|
62
62
|
if (${x} in input) {
|
|
63
63
|
newResult[${x}] = undefined;
|
|
64
64
|
}
|
|
65
65
|
} else {
|
|
66
|
-
newResult[${x}] = ${
|
|
66
|
+
newResult[${x}] = ${k}.value;
|
|
67
67
|
}
|
|
68
68
|
|
|
69
|
-
`)}p.write("payload.value = newResult;"),p.write("return payload;");let P=p.compile();return(E,A)=>P(d,E,A)},i,s=pt,a=!ut.jitless,u=a&&kc.value,l=t.catchall,f;e._zod.parse=(d,p)=>{f??(f=o.value);let m=d.value;if(!s(m))return d.issues.push({expected:"object",code:"invalid_type",input:m,inst:e}),d;if(a&&u&&p?.async===!1&&p.jitless!==!0){if(!i)i=n(t.shape);if(d=i(d,p),!l)return d;return bl([],m,d,p,f,e)}return r(d,p)}});Qr=g("$ZodUnion",(e,t)=>{R.init(e,t),I(e._zod,"optin",()=>t.options.some((o)=>o._zod.optin==="optional")?"optional":void 0),I(e._zod,"optout",()=>t.options.some((o)=>o._zod.optout==="optional")?"optional":void 0),I(e._zod,"values",()=>{if(t.options.every((o)=>o._zod.values))return new Set(t.options.flatMap((o)=>Array.from(o._zod.values)));return}),I(e._zod,"pattern",()=>{if(t.options.every((o)=>o._zod.pattern)){let o=t.options.map((n)=>n._zod.pattern);return new RegExp(`^(${o.map((n)=>Tr(n.source)).join("|")})$`)}return});let r=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(o,n)=>{if(r)return r(o,n);let i=!1,s=[];for(let a of t.options){let c=a._zod.run({value:o.value,issues:[]},n);if(c instanceof Promise)s.push(c),i=!0;else{if(c.issues.length===0)return c;s.push(c)}}if(!i)return vu(s,o,e,n);return Promise.all(s).then((a)=>vu(a,o,e,n))}});wl=g("$ZodXor",(e,t)=>{Qr.init(e,t),t.inclusive=!1;let r=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(o,n)=>{if(r)return r(o,n);let i=!1,s=[];for(let a of t.options){let c=a._zod.run({value:o.value,issues:[]},n);if(c instanceof Promise)s.push(c),i=!0;else s.push(c)}if(!i)return xu(s,o,e,n);return Promise.all(s).then((a)=>xu(a,o,e,n))}}),vl=g("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,Qr.init(e,t);let r=e._zod.parse;I(e._zod,"propValues",()=>{let n={};for(let i of t.options){let s=i._zod.propValues;if(!s||Object.keys(s).length===0)throw Error(`Invalid discriminated union option at index "${t.options.indexOf(i)}"`);for(let[a,c]of Object.entries(s)){if(!n[a])n[a]=new Set;for(let u of c)n[a].add(u)}}return n});let o=Bt(()=>{let n=t.options,i=new Map;for(let s of n){let a=s._zod.propValues?.[t.discriminator];if(!a||a.size===0)throw Error(`Invalid discriminated union option at index "${t.options.indexOf(s)}"`);for(let c of a){if(i.has(c))throw Error(`Duplicate discriminator value "${String(c)}"`);i.set(c,s)}}return i});e._zod.parse=(n,i)=>{let s=n.value;if(!pt(s))return n.issues.push({code:"invalid_type",expected:"object",input:s,inst:e}),n;let a=o.value.get(s?.[t.discriminator]);if(a)return a._zod.run(n,i);if(t.unionFallback||i.direction==="backward")return r(n,i);return n.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,options:Array.from(o.value.keys()),input:s,path:[t.discriminator],inst:e}),n}}),xl=g("$ZodIntersection",(e,t)=>{R.init(e,t),e._zod.parse=(r,o)=>{let n=r.value,i=t.left._zod.run({value:n,issues:[]},o),s=t.right._zod.run({value:n,issues:[]},o);if(i instanceof Promise||s instanceof Promise)return Promise.all([i,s]).then(([c,u])=>Eu(r,c,u));return Eu(r,i,s)}});Ai=g("$ZodTuple",(e,t)=>{R.init(e,t);let r=t.items;e._zod.parse=(o,n)=>{let i=o.value;if(!Array.isArray(i))return o.issues.push({input:i,inst:e,expected:"tuple",code:"invalid_type"}),o;o.value=[];let s=[],a=Su(r,"optin"),c=Su(r,"optout");if(!t.rest){if(i.length<a)return o.issues.push({code:"too_small",minimum:a,inclusive:!0,input:i,inst:e,origin:"array"}),o;if(i.length>r.length)o.issues.push({code:"too_big",maximum:r.length,inclusive:!0,input:i,inst:e,origin:"array"})}let u=Array(r.length);for(let l=0;l<r.length;l++){let f=r[l]._zod.run({value:i[l],issues:[]},n);if(f instanceof Promise)s.push(f.then((d)=>{u[l]=d}));else u[l]=f}if(t.rest){let l=r.length-1,f=i.slice(r.length);for(let d of f){l++;let p=t.rest._zod.run({value:d,issues:[]},n);if(p instanceof Promise)s.push(p.then((m)=>$u(m,o,l)));else $u(p,o,l)}}if(s.length)return Promise.all(s).then(()=>Au(u,o,r,i,c));return Au(u,o,r,i,c)}});El=g("$ZodRecord",(e,t)=>{R.init(e,t),e._zod.parse=(r,o)=>{let n=r.value;if(!Je(n))return r.issues.push({expected:"record",code:"invalid_type",input:n,inst:e}),r;let i=[],s=t.keyType._zod.values;if(s){r.value={};let a=new Set;for(let u of s)if(typeof u==="string"||typeof u==="number"||typeof u==="symbol"){a.add(typeof u==="number"?u.toString():u);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(l.issues.length){r.issues.push({code:"invalid_key",origin:"record",issues:l.issues.map((p)=>ne(p,o,H())),input:u,path:[u],inst:e});continue}let f=l.value,d=t.valueType._zod.run({value:n[u],issues:[]},o);if(d instanceof Promise)i.push(d.then((p)=>{if(p.issues.length)r.issues.push(...ae(u,p.issues));r.value[f]=p.value}));else{if(d.issues.length)r.issues.push(...ae(u,d.issues));r.value[f]=d.value}}let c;for(let u in n)if(!a.has(u))c=c??[],c.push(u);if(c&&c.length>0)r.issues.push({code:"unrecognized_keys",input:n,inst:e,keys:c})}else{r.value={};for(let a of Reflect.ownKeys(n)){if(a==="__proto__")continue;if(!Object.prototype.propertyIsEnumerable.call(n,a))continue;let c=t.keyType._zod.run({value:a,issues:[]},o);if(c instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(typeof a==="string"&&Lr.test(a)&&c.issues.length){let f=t.keyType._zod.run({value:Number(a),issues:[]},o);if(f instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(f.issues.length===0)c=f}if(c.issues.length){if(t.mode==="loose")r.value[a]=n[a];else r.issues.push({code:"invalid_key",origin:"record",issues:c.issues.map((f)=>ne(f,o,H())),input:a,path:[a],inst:e});continue}let l=t.valueType._zod.run({value:n[a],issues:[]},o);if(l instanceof Promise)i.push(l.then((f)=>{if(f.issues.length)r.issues.push(...ae(a,f.issues));r.value[c.value]=f.value}));else{if(l.issues.length)r.issues.push(...ae(a,l.issues));r.value[c.value]=l.value}}}if(i.length)return Promise.all(i).then(()=>r);return r}}),Sl=g("$ZodMap",(e,t)=>{R.init(e,t),e._zod.parse=(r,o)=>{let n=r.value;if(!(n instanceof Map))return r.issues.push({expected:"map",code:"invalid_type",input:n,inst:e}),r;let i=[];r.value=new Map;for(let[s,a]of n){let c=t.keyType._zod.run({value:s,issues:[]},o),u=t.valueType._zod.run({value:a,issues:[]},o);if(c instanceof Promise||u instanceof Promise)i.push(Promise.all([c,u]).then(([l,f])=>{ku(l,f,r,s,n,e,o)}));else ku(c,u,r,s,n,e,o)}if(i.length)return Promise.all(i).then(()=>r);return r}});$l=g("$ZodSet",(e,t)=>{R.init(e,t),e._zod.parse=(r,o)=>{let n=r.value;if(!(n instanceof Set))return r.issues.push({input:n,inst:e,expected:"set",code:"invalid_type"}),r;let i=[];r.value=new Set;for(let s of n){let a=t.valueType._zod.run({value:s,issues:[]},o);if(a instanceof Promise)i.push(a.then((c)=>Pu(c,r)));else Pu(a,r)}if(i.length)return Promise.all(i).then(()=>r);return r}});Al=g("$ZodEnum",(e,t)=>{R.init(e,t);let r=Rr(t.entries),o=new Set(r);e._zod.values=o,e._zod.pattern=new RegExp(`^(${r.filter((n)=>Or.has(typeof n)).map((n)=>typeof n==="string"?ye(n):n.toString()).join("|")})$`),e._zod.parse=(n,i)=>{let s=n.value;if(o.has(s))return n;return n.issues.push({code:"invalid_value",values:r,input:s,inst:e}),n}}),kl=g("$ZodLiteral",(e,t)=>{if(R.init(e,t),t.values.length===0)throw Error("Cannot create literal schema with no valid values");let r=new Set(t.values);e._zod.values=r,e._zod.pattern=new RegExp(`^(${t.values.map((o)=>typeof o==="string"?ye(o):o?ye(o.toString()):String(o)).join("|")})$`),e._zod.parse=(o,n)=>{let i=o.value;if(r.has(i))return o;return o.issues.push({code:"invalid_value",values:t.values,input:i,inst:e}),o}}),Pl=g("$ZodFile",(e,t)=>{R.init(e,t),e._zod.parse=(r,o)=>{let n=r.value;if(n instanceof File)return r;return r.issues.push({expected:"file",code:"invalid_type",input:n,inst:e}),r}}),Cl=g("$ZodTransform",(e,t)=>{R.init(e,t),e._zod.optin="optional",e._zod.parse=(r,o)=>{if(o.direction==="backward")throw new lt(e.constructor.name);let n=t.transform(r.value,r);if(o.async)return(n instanceof Promise?n:Promise.resolve(n)).then((s)=>(r.value=s,r.fallback=!0,r));if(n instanceof Promise)throw new Ie;return r.value=n,r.fallback=!0,r}});ki=g("$ZodOptional",(e,t)=>{R.init(e,t),e._zod.optin="optional",e._zod.optout="optional",I(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),I(e._zod,"pattern",()=>{let r=t.innerType._zod.pattern;return r?new RegExp(`^(${Tr(r.source)})?$`):void 0}),e._zod.parse=(r,o)=>{if(t.innerType._zod.optin==="optional"){let n=r.value,i=t.innerType._zod.run(r,o);if(i instanceof Promise)return i.then((s)=>Cu(s,n));return Cu(i,n)}if(r.value===void 0)return r;return t.innerType._zod.run(r,o)}}),Rl=g("$ZodExactOptional",(e,t)=>{ki.init(e,t),I(e._zod,"values",()=>t.innerType._zod.values),I(e._zod,"pattern",()=>t.innerType._zod.pattern),e._zod.parse=(r,o)=>t.innerType._zod.run(r,o)}),Tl=g("$ZodNullable",(e,t)=>{R.init(e,t),I(e._zod,"optin",()=>t.innerType._zod.optin),I(e._zod,"optout",()=>t.innerType._zod.optout),I(e._zod,"pattern",()=>{let r=t.innerType._zod.pattern;return r?new RegExp(`^(${Tr(r.source)}|null)$`):void 0}),I(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(r,o)=>{if(r.value===null)return r;return t.innerType._zod.run(r,o)}}),Ol=g("$ZodDefault",(e,t)=>{R.init(e,t),e._zod.optin="optional",I(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,o)=>{if(o.direction==="backward")return t.innerType._zod.run(r,o);if(r.value===void 0)return r.value=t.defaultValue,r;let n=t.innerType._zod.run(r,o);if(n instanceof Promise)return n.then((i)=>Ru(i,t));return Ru(n,t)}});Il=g("$ZodPrefault",(e,t)=>{R.init(e,t),e._zod.optin="optional",I(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,o)=>{if(o.direction==="backward")return t.innerType._zod.run(r,o);if(r.value===void 0)r.value=t.defaultValue;return t.innerType._zod.run(r,o)}}),Bl=g("$ZodNonOptional",(e,t)=>{R.init(e,t),I(e._zod,"values",()=>{let r=t.innerType._zod.values;return r?new Set([...r].filter((o)=>o!==void 0)):void 0}),e._zod.parse=(r,o)=>{let n=t.innerType._zod.run(r,o);if(n instanceof Promise)return n.then((i)=>Tu(i,e));return Tu(n,e)}});zl=g("$ZodSuccess",(e,t)=>{R.init(e,t),e._zod.parse=(r,o)=>{if(o.direction==="backward")throw new lt("ZodSuccess");let n=t.innerType._zod.run(r,o);if(n instanceof Promise)return n.then((i)=>(r.value=i.issues.length===0,r));return r.value=n.issues.length===0,r}}),Dl=g("$ZodCatch",(e,t)=>{R.init(e,t),e._zod.optin="optional",I(e._zod,"optout",()=>t.innerType._zod.optout),I(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,o)=>{if(o.direction==="backward")return t.innerType._zod.run(r,o);let n=t.innerType._zod.run(r,o);if(n instanceof Promise)return n.then((i)=>{if(r.value=i.value,i.issues.length)r.value=t.catchValue({...r,error:{issues:i.issues.map((s)=>ne(s,o,H()))},input:r.value}),r.issues=[],r.fallback=!0;return r});if(r.value=n.value,n.issues.length)r.value=t.catchValue({...r,error:{issues:n.issues.map((i)=>ne(i,o,H()))},input:r.value}),r.issues=[],r.fallback=!0;return r}}),Nl=g("$ZodNaN",(e,t)=>{R.init(e,t),e._zod.parse=(r,o)=>{if(typeof r.value!=="number"||!Number.isNaN(r.value))return r.issues.push({input:r.value,inst:e,expected:"nan",code:"invalid_type"}),r;return r}}),Pi=g("$ZodPipe",(e,t)=>{R.init(e,t),I(e._zod,"values",()=>t.in._zod.values),I(e._zod,"optin",()=>t.in._zod.optin),I(e._zod,"optout",()=>t.out._zod.optout),I(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(r,o)=>{if(o.direction==="backward"){let i=t.out._zod.run(r,o);if(i instanceof Promise)return i.then((s)=>Mr(s,t.in,o));return Mr(i,t.in,o)}let n=t.in._zod.run(r,o);if(n instanceof Promise)return n.then((i)=>Mr(i,t.out,o));return Mr(n,t.out,o)}});Wr=g("$ZodCodec",(e,t)=>{R.init(e,t),I(e._zod,"values",()=>t.in._zod.values),I(e._zod,"optin",()=>t.in._zod.optin),I(e._zod,"optout",()=>t.out._zod.optout),I(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(r,o)=>{if((o.direction||"forward")==="forward"){let i=t.in._zod.run(r,o);if(i instanceof Promise)return i.then((s)=>Fr(s,t,o));return Fr(i,t,o)}else{let i=t.out._zod.run(r,o);if(i instanceof Promise)return i.then((s)=>Fr(s,t,o));return Fr(i,t,o)}}});Ll=g("$ZodPreprocess",(e,t)=>{Pi.init(e,t)}),Vl=g("$ZodReadonly",(e,t)=>{R.init(e,t),I(e._zod,"propValues",()=>t.innerType._zod.propValues),I(e._zod,"values",()=>t.innerType._zod.values),I(e._zod,"optin",()=>t.innerType?._zod?.optin),I(e._zod,"optout",()=>t.innerType?._zod?.optout),e._zod.parse=(r,o)=>{if(o.direction==="backward")return t.innerType._zod.run(r,o);let n=t.innerType._zod.run(r,o);if(n instanceof Promise)return n.then(Ou);return Ou(n)}});Ul=g("$ZodTemplateLiteral",(e,t)=>{R.init(e,t);let r=[];for(let o of t.parts)if(typeof o==="object"&&o!==null){if(!o._zod.pattern)throw Error(`Invalid template literal part, no pattern found: ${[...o._zod.traits].shift()}`);let n=o._zod.pattern instanceof RegExp?o._zod.pattern.source:o._zod.pattern;if(!n)throw Error(`Invalid template literal part: ${o._zod.traits}`);let i=n.startsWith("^")?1:0,s=n.endsWith("$")?n.length-1:n.length;r.push(n.slice(i,s))}else if(o===null||Pc.has(typeof o))r.push(ye(`${o}`));else throw Error(`Invalid template literal part: ${o}`);e._zod.pattern=new RegExp(`^${r.join("")}$`),e._zod.parse=(o,n)=>{if(typeof o.value!=="string")return o.issues.push({input:o.value,inst:e,expected:"string",code:"invalid_type"}),o;if(e._zod.pattern.lastIndex=0,!e._zod.pattern.test(o.value))return o.issues.push({input:o.value,inst:e,code:"invalid_format",format:t.format??"template_literal",pattern:e._zod.pattern.source}),o;return o}}),Ml=g("$ZodFunction",(e,t)=>(R.init(e,t),e._def=t,e._zod.def=t,e.implement=(r)=>{if(typeof r!=="function")throw Error("implement() must be called with a function");return function(...o){let n=e._def.input?Fn(e._def.input,o):o,i=Reflect.apply(r,this,n);if(e._def.output)return Fn(e._def.output,i);return i}},e.implementAsync=(r)=>{if(typeof r!=="function")throw Error("implementAsync() must be called with a function");return async function(...o){let n=e._def.input?await jn(e._def.input,o):o,i=await Reflect.apply(r,this,n);if(e._def.output)return await jn(e._def.output,i);return i}},e._zod.parse=(r,o)=>{if(typeof r.value!=="function")return r.issues.push({code:"invalid_type",expected:"function",input:r.value,inst:e}),r;if(e._def.output&&e._def.output._zod.def.type==="promise")r.value=e.implementAsync(r.value);else r.value=e.implement(r.value);return r},e.input=(...r)=>{let o=e.constructor;if(Array.isArray(r[0]))return new o({type:"function",input:new Ai({type:"tuple",items:r[0],rest:r[1]}),output:e._def.output});return new o({type:"function",input:r[0],output:e._def.output})},e.output=(r)=>new e.constructor({type:"function",input:e._def.input,output:r}),e)),Fl=g("$ZodPromise",(e,t)=>{R.init(e,t),e._zod.parse=(r,o)=>Promise.resolve(r.value).then((n)=>t.innerType._zod.run({value:n,issues:[]},o))}),jl=g("$ZodLazy",(e,t)=>{R.init(e,t),I(e._zod,"innerType",()=>{let r=t;if(!r._cachedInner)r._cachedInner=t.getter();return r._cachedInner}),I(e._zod,"pattern",()=>e._zod.innerType?._zod?.pattern),I(e._zod,"propValues",()=>e._zod.innerType?._zod?.propValues),I(e._zod,"optin",()=>e._zod.innerType?._zod?.optin??void 0),I(e._zod,"optout",()=>e._zod.innerType?._zod?.optout??void 0),e._zod.parse=(r,o)=>e._zod.innerType._zod.run(r,o)}),Zl=g("$ZodCustom",(e,t)=>{U.init(e,t),R.init(e,t),e._zod.parse=(r,o)=>r,e._zod.check=(r)=>{let o=r.value,n=t.fn(o);if(n instanceof Promise)return n.then((i)=>Iu(i,r,o,e));Iu(n,r,o,e);return}})});function Ri(){return{localeError:p_()}}var p_=()=>{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(n){return e[n]??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",jwt:"JWT",template_literal:"input"},o={nan:"NaN"};return(n)=>{switch(n.code){case"invalid_type":{let i=o[n.expected]??n.expected,s=Ic(n.input),a=o[s]??s;return`Invalid input: expected ${i}, received ${a}`}case"invalid_value":if(n.values.length===1)return`Invalid input: expected ${Ln(n.values[0])}`;return`Invalid option: expected one of ${Bn(n.values,"|")}`;case"too_big":{let i=n.inclusive?"<=":"<",s=t(n.origin);if(s)return`Too big: expected ${n.origin??"value"} to have ${i}${n.maximum.toString()} ${s.unit??"elements"}`;return`Too big: expected ${n.origin??"value"} to be ${i}${n.maximum.toString()}`}case"too_small":{let i=n.inclusive?">=":">",s=t(n.origin);if(s)return`Too small: expected ${n.origin} to have ${i}${n.minimum.toString()} ${s.unit}`;return`Too small: expected ${n.origin} to be ${i}${n.minimum.toString()}`}case"invalid_format":{let i=n;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]??n.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${n.divisor}`;case"unrecognized_keys":return`Unrecognized key${n.keys.length>1?"s":""}: ${Bn(n.keys,", ")}`;case"invalid_key":return`Invalid key in ${n.origin}`;case"invalid_union":if(n.options&&Array.isArray(n.options)&&n.options.length>0)return`Invalid discriminator value. Expected ${n.options.map((s)=>`'${s}'`).join(" | ")}`;return"Invalid input";case"invalid_element":return`Invalid value in ${n.origin}`;default:return"Invalid input"}}};var ql=_(()=>{de()});var Ti=()=>{};class Gl{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 o={...r,...this._map.get(e)};return Object.keys(o).length?o:void 0}return this._map.get(e)}has(e){return this._map.has(e)}}function Kl(){return new Gl}var Wl,d_,f_,te;var jt=_(()=>{d_=Symbol("ZodOutput"),f_=Symbol("ZodInput");(Wl=globalThis).__zod_globalRegistry??(Wl.__zod_globalRegistry=Kl());te=globalThis.__zod_globalRegistry});function Hl(e,t){return new e({type:"string",...w(t)})}function Oi(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...w(t)})}function Gr(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...w(t)})}function Ii(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...w(t)})}function Bi(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...w(t)})}function zi(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...w(t)})}function Di(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...w(t)})}function Kr(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...w(t)})}function Ni(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...w(t)})}function Li(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...w(t)})}function Vi(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...w(t)})}function Ui(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...w(t)})}function Mi(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...w(t)})}function Fi(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...w(t)})}function ji(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...w(t)})}function Zi(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...w(t)})}function qi(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...w(t)})}function Jl(e,t){return new e({type:"string",format:"mac",check:"string_format",abort:!1,...w(t)})}function Qi(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...w(t)})}function Wi(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...w(t)})}function Gi(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...w(t)})}function Ki(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...w(t)})}function Hi(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...w(t)})}function Ji(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...w(t)})}function Yl(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...w(t)})}function Xl(e,t){return new e({type:"string",format:"date",check:"string_format",...w(t)})}function ep(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...w(t)})}function tp(e,t){return new e({type:"string",format:"duration",check:"string_format",...w(t)})}function rp(e,t){return new e({type:"number",checks:[],...w(t)})}function op(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...w(t)})}function np(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"float32",...w(t)})}function ip(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"float64",...w(t)})}function sp(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"int32",...w(t)})}function ap(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"uint32",...w(t)})}function cp(e,t){return new e({type:"boolean",...w(t)})}function up(e,t){return new e({type:"bigint",...w(t)})}function lp(e,t){return new e({type:"bigint",check:"bigint_format",abort:!1,format:"int64",...w(t)})}function pp(e,t){return new e({type:"bigint",check:"bigint_format",abort:!1,format:"uint64",...w(t)})}function dp(e,t){return new e({type:"symbol",...w(t)})}function fp(e,t){return new e({type:"undefined",...w(t)})}function mp(e,t){return new e({type:"null",...w(t)})}function hp(e){return new e({type:"any"})}function gp(e){return new e({type:"unknown"})}function yp(e,t){return new e({type:"never",...w(t)})}function bp(e,t){return new e({type:"void",...w(t)})}function _p(e,t){return new e({type:"date",...w(t)})}function wp(e,t){return new e({type:"nan",...w(t)})}function Ve(e,t){return new _i({check:"less_than",...w(t),value:e,inclusive:!1})}function _e(e,t){return new _i({check:"less_than",...w(t),value:e,inclusive:!0})}function Ue(e,t){return new wi({check:"greater_than",...w(t),value:e,inclusive:!1})}function ce(e,t){return new wi({check:"greater_than",...w(t),value:e,inclusive:!0})}function vp(e){return Ue(0,e)}function xp(e){return Ve(0,e)}function Ep(e){return _e(0,e)}function Sp(e){return ce(0,e)}function ft(e,t){return new eu({check:"multiple_of",...w(t),value:e})}function mt(e,t){return new ou({check:"max_size",...w(t),maximum:e})}function Me(e,t){return new nu({check:"min_size",...w(t),minimum:e})}function Zt(e,t){return new iu({check:"size_equals",...w(t),size:e})}function qt(e,t){return new su({check:"max_length",...w(t),maximum:e})}function rt(e,t){return new au({check:"min_length",...w(t),minimum:e})}function Qt(e,t){return new cu({check:"length_equals",...w(t),length:e})}function Hr(e,t){return new uu({check:"string_format",format:"regex",...w(t),pattern:e})}function Jr(e){return new lu({check:"string_format",format:"lowercase",...w(e)})}function Yr(e){return new pu({check:"string_format",format:"uppercase",...w(e)})}function Xr(e,t){return new du({check:"string_format",format:"includes",...w(t),includes:e})}function eo(e,t){return new fu({check:"string_format",format:"starts_with",...w(t),prefix:e})}function to(e,t){return new mu({check:"string_format",format:"ends_with",...w(t),suffix:e})}function $p(e,t,r){return new hu({check:"property",property:e,schema:t,...w(r)})}function ro(e,t){return new gu({check:"mime_type",mime:e,...w(t)})}function Be(e){return new yu({check:"overwrite",tx:e})}function oo(e){return Be((t)=>t.normalize(e))}function no(){return Be((e)=>e.trim())}function io(){return Be((e)=>e.toLowerCase())}function so(){return Be((e)=>e.toUpperCase())}function ao(){return Be((e)=>Ac(e))}function Ap(e,t,r){return new e({type:"array",element:t,...w(r)})}function kp(e,t){return new e({type:"file",...w(t)})}function Pp(e,t,r){let o=w(r);return o.abort??(o.abort=!0),new e({type:"custom",check:"custom",fn:t,...o})}function Cp(e,t,r){return new e({type:"custom",check:"custom",fn:t,...w(r)})}function Rp(e,t){let r=h_((o)=>(o.addIssue=(n)=>{if(typeof n==="string")o.issues.push(Xe(n,o.value,r._zod.def));else{let i=n;if(i.fatal)i.continue=!1;i.code??(i.code="custom"),i.input??(i.input=o.value),i.inst??(i.inst=r),i.continue??(i.continue=!r._zod.def.abort),o.issues.push(Xe(i))}},e(o.value,o)),t);return r}function h_(e,t){let r=new U({check:"custom",...w(t)});return r._zod.check=e,r}function Tp(e){let t=new U({check:"describe"});return t._zod.onattach=[(r)=>{let o=te.get(r)??{};te.add(r,{...o,description:e})}],t._zod.check=()=>{},t}function Op(e){let t=new U({check:"meta"});return t._zod.onattach=[(r)=>{let o=te.get(r)??{};te.add(r,{...o,...e})}],t._zod.check=()=>{},t}function Ip(e,t){let r=w(t),o=r.truthy??["true","1","yes","on","y","enabled"],n=r.falsy??["false","0","no","off","n","disabled"];if(r.case!=="sensitive")o=o.map((p)=>typeof p==="string"?p.toLowerCase():p),n=n.map((p)=>typeof p==="string"?p.toLowerCase():p);let i=new Set(o),s=new Set(n),a=e.Codec??Wr,c=e.Boolean??qr,l=new(e.String??dt)({type:"string",error:r.error}),f=new c({type:"boolean",error:r.error}),d=new a({type:"pipe",in:l,out:f,transform:(p,m)=>{let h=p;if(r.case!=="sensitive")h=h.toLowerCase();if(i.has(h))return!0;else if(s.has(h))return!1;else return m.issues.push({code:"invalid_value",expected:"stringbool",values:[...i,...s],input:m.value,inst:d,continue:!1}),{}},reverseTransform:(p,m)=>{if(p===!0)return o[0]||"true";else return n[0]||"false"},error:r.error});return d}function Wt(e,t,r,o={}){let n=w(o),i={...w(o),check:"string_format",type:"string",format:t,fn:typeof r==="function"?r:(a)=>r.test(a),...n};if(r instanceof RegExp)i.pattern=r;return new e(i)}var Bp=_(()=>{Ur();jt();Ci();de()});function Yi(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??te,target:t,unrepresentable:e?.unrepresentable??"throw",override:e?.override??(()=>{}),io:e?.io??"output",counter:0,seen:new Map,cycles:e?.cycles??"ref",reused:e?.reused??"inline",external:e?.external??void 0}}function j(e,t,r={path:[],schemaPath:[]}){var o;let n=e._zod.def,i=t.seen.get(e);if(i){if(i.count++,r.schemaPath.includes(e))i.cycle=r.path;return i.schema}let s={schema:{},count:1,cycle:void 0,path:r.path};t.seen.set(e,s);let a=e._zod.toJSONSchema?.();if(a)s.schema=a;else{let l={...r,schemaPath:[...r.schemaPath,e],path:r.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,s.schema,l);else{let d=s.schema,p=t.processors[n.type];if(!p)throw Error(`[toJSONSchema]: Non-representable type encountered: ${n.type}`);p(e,t,d,l)}let f=e._zod.parent;if(f){if(!s.ref)s.ref=f;j(f,t,l),t.seen.get(f).isParent=!0}}let c=t.metadataRegistry.get(e);if(c)Object.assign(s.schema,c);if(t.io==="input"&&re(e))delete s.schema.examples,delete s.schema.default;if(t.io==="input"&&"_prefault"in s.schema)(o=s.schema).default??(o.default=s.schema._prefault);return delete s.schema._prefault,t.seen.get(e).schema}function Xi(e,t){let r=e.seen.get(t);if(!r)throw Error("Unprocessed schema. This is a bug in Zod.");let o=new Map;for(let s of e.seen.entries()){let a=e.metadataRegistry.get(s[0])?.id;if(a){let c=o.get(a);if(c&&c!==s[0])throw Error(`Duplicate schema id "${a}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);o.set(a,s[0])}}let n=(s)=>{let a=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){let f=e.external.registry.get(s[0])?.id,d=e.external.uri??((m)=>m);if(f)return{ref:d(f)};let p=s[1].defId??s[1].schema.id??`schema${e.counter++}`;return s[1].defId=p,{defId:p,ref:`${d("__shared")}#/${a}/${p}`}}if(s[1]===r)return{ref:"#"};let u=`${"#"}/${a}/`,l=s[1].schema.id??`__schema${e.counter++}`;return{defId:l,ref:u+l}},i=(s)=>{if(s[1].schema.$ref)return;let a=s[1],{ref:c,defId:u}=n(s);if(a.def={...a.schema},u)a.defId=u;let l=a.schema;for(let f in l)delete l[f];l.$ref=c};if(e.cycles==="throw")for(let s of e.seen.entries()){let a=s[1];if(a.cycle)throw Error(`Cycle detected: #/${a.cycle?.join("/")}/<root>
|
|
69
|
+
`)}p.write("payload.value = newResult;"),p.write("return payload;");let P=p.compile();return(E,k)=>P(d,E,k)},i,s=pt,a=!ut.jitless,u=a&&kc.value,l=t.catchall,f;e._zod.parse=(d,p)=>{f??(f=o.value);let m=d.value;if(!s(m))return d.issues.push({expected:"object",code:"invalid_type",input:m,inst:e}),d;if(a&&u&&p?.async===!1&&p.jitless!==!0){if(!i)i=n(t.shape);if(d=i(d,p),!l)return d;return bl([],m,d,p,f,e)}return r(d,p)}});Qr=g("$ZodUnion",(e,t)=>{R.init(e,t),I(e._zod,"optin",()=>t.options.some((o)=>o._zod.optin==="optional")?"optional":void 0),I(e._zod,"optout",()=>t.options.some((o)=>o._zod.optout==="optional")?"optional":void 0),I(e._zod,"values",()=>{if(t.options.every((o)=>o._zod.values))return new Set(t.options.flatMap((o)=>Array.from(o._zod.values)));return}),I(e._zod,"pattern",()=>{if(t.options.every((o)=>o._zod.pattern)){let o=t.options.map((n)=>n._zod.pattern);return new RegExp(`^(${o.map((n)=>Tr(n.source)).join("|")})$`)}return});let r=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(o,n)=>{if(r)return r(o,n);let i=!1,s=[];for(let a of t.options){let c=a._zod.run({value:o.value,issues:[]},n);if(c instanceof Promise)s.push(c),i=!0;else{if(c.issues.length===0)return c;s.push(c)}}if(!i)return vu(s,o,e,n);return Promise.all(s).then((a)=>vu(a,o,e,n))}});wl=g("$ZodXor",(e,t)=>{Qr.init(e,t),t.inclusive=!1;let r=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(o,n)=>{if(r)return r(o,n);let i=!1,s=[];for(let a of t.options){let c=a._zod.run({value:o.value,issues:[]},n);if(c instanceof Promise)s.push(c),i=!0;else s.push(c)}if(!i)return xu(s,o,e,n);return Promise.all(s).then((a)=>xu(a,o,e,n))}}),vl=g("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,Qr.init(e,t);let r=e._zod.parse;I(e._zod,"propValues",()=>{let n={};for(let i of t.options){let s=i._zod.propValues;if(!s||Object.keys(s).length===0)throw Error(`Invalid discriminated union option at index "${t.options.indexOf(i)}"`);for(let[a,c]of Object.entries(s)){if(!n[a])n[a]=new Set;for(let u of c)n[a].add(u)}}return n});let o=Bt(()=>{let n=t.options,i=new Map;for(let s of n){let a=s._zod.propValues?.[t.discriminator];if(!a||a.size===0)throw Error(`Invalid discriminated union option at index "${t.options.indexOf(s)}"`);for(let c of a){if(i.has(c))throw Error(`Duplicate discriminator value "${String(c)}"`);i.set(c,s)}}return i});e._zod.parse=(n,i)=>{let s=n.value;if(!pt(s))return n.issues.push({code:"invalid_type",expected:"object",input:s,inst:e}),n;let a=o.value.get(s?.[t.discriminator]);if(a)return a._zod.run(n,i);if(t.unionFallback||i.direction==="backward")return r(n,i);return n.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,options:Array.from(o.value.keys()),input:s,path:[t.discriminator],inst:e}),n}}),xl=g("$ZodIntersection",(e,t)=>{R.init(e,t),e._zod.parse=(r,o)=>{let n=r.value,i=t.left._zod.run({value:n,issues:[]},o),s=t.right._zod.run({value:n,issues:[]},o);if(i instanceof Promise||s instanceof Promise)return Promise.all([i,s]).then(([c,u])=>Eu(r,c,u));return Eu(r,i,s)}});Ai=g("$ZodTuple",(e,t)=>{R.init(e,t);let r=t.items;e._zod.parse=(o,n)=>{let i=o.value;if(!Array.isArray(i))return o.issues.push({input:i,inst:e,expected:"tuple",code:"invalid_type"}),o;o.value=[];let s=[],a=Su(r,"optin"),c=Su(r,"optout");if(!t.rest){if(i.length<a)return o.issues.push({code:"too_small",minimum:a,inclusive:!0,input:i,inst:e,origin:"array"}),o;if(i.length>r.length)o.issues.push({code:"too_big",maximum:r.length,inclusive:!0,input:i,inst:e,origin:"array"})}let u=Array(r.length);for(let l=0;l<r.length;l++){let f=r[l]._zod.run({value:i[l],issues:[]},n);if(f instanceof Promise)s.push(f.then((d)=>{u[l]=d}));else u[l]=f}if(t.rest){let l=r.length-1,f=i.slice(r.length);for(let d of f){l++;let p=t.rest._zod.run({value:d,issues:[]},n);if(p instanceof Promise)s.push(p.then((m)=>$u(m,o,l)));else $u(p,o,l)}}if(s.length)return Promise.all(s).then(()=>Au(u,o,r,i,c));return Au(u,o,r,i,c)}});El=g("$ZodRecord",(e,t)=>{R.init(e,t),e._zod.parse=(r,o)=>{let n=r.value;if(!Je(n))return r.issues.push({expected:"record",code:"invalid_type",input:n,inst:e}),r;let i=[],s=t.keyType._zod.values;if(s){r.value={};let a=new Set;for(let u of s)if(typeof u==="string"||typeof u==="number"||typeof u==="symbol"){a.add(typeof u==="number"?u.toString():u);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(l.issues.length){r.issues.push({code:"invalid_key",origin:"record",issues:l.issues.map((p)=>ne(p,o,H())),input:u,path:[u],inst:e});continue}let f=l.value,d=t.valueType._zod.run({value:n[u],issues:[]},o);if(d instanceof Promise)i.push(d.then((p)=>{if(p.issues.length)r.issues.push(...ae(u,p.issues));r.value[f]=p.value}));else{if(d.issues.length)r.issues.push(...ae(u,d.issues));r.value[f]=d.value}}let c;for(let u in n)if(!a.has(u))c=c??[],c.push(u);if(c&&c.length>0)r.issues.push({code:"unrecognized_keys",input:n,inst:e,keys:c})}else{r.value={};for(let a of Reflect.ownKeys(n)){if(a==="__proto__")continue;if(!Object.prototype.propertyIsEnumerable.call(n,a))continue;let c=t.keyType._zod.run({value:a,issues:[]},o);if(c instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(typeof a==="string"&&Lr.test(a)&&c.issues.length){let f=t.keyType._zod.run({value:Number(a),issues:[]},o);if(f instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(f.issues.length===0)c=f}if(c.issues.length){if(t.mode==="loose")r.value[a]=n[a];else r.issues.push({code:"invalid_key",origin:"record",issues:c.issues.map((f)=>ne(f,o,H())),input:a,path:[a],inst:e});continue}let l=t.valueType._zod.run({value:n[a],issues:[]},o);if(l instanceof Promise)i.push(l.then((f)=>{if(f.issues.length)r.issues.push(...ae(a,f.issues));r.value[c.value]=f.value}));else{if(l.issues.length)r.issues.push(...ae(a,l.issues));r.value[c.value]=l.value}}}if(i.length)return Promise.all(i).then(()=>r);return r}}),Sl=g("$ZodMap",(e,t)=>{R.init(e,t),e._zod.parse=(r,o)=>{let n=r.value;if(!(n instanceof Map))return r.issues.push({expected:"map",code:"invalid_type",input:n,inst:e}),r;let i=[];r.value=new Map;for(let[s,a]of n){let c=t.keyType._zod.run({value:s,issues:[]},o),u=t.valueType._zod.run({value:a,issues:[]},o);if(c instanceof Promise||u instanceof Promise)i.push(Promise.all([c,u]).then(([l,f])=>{ku(l,f,r,s,n,e,o)}));else ku(c,u,r,s,n,e,o)}if(i.length)return Promise.all(i).then(()=>r);return r}});$l=g("$ZodSet",(e,t)=>{R.init(e,t),e._zod.parse=(r,o)=>{let n=r.value;if(!(n instanceof Set))return r.issues.push({input:n,inst:e,expected:"set",code:"invalid_type"}),r;let i=[];r.value=new Set;for(let s of n){let a=t.valueType._zod.run({value:s,issues:[]},o);if(a instanceof Promise)i.push(a.then((c)=>Pu(c,r)));else Pu(a,r)}if(i.length)return Promise.all(i).then(()=>r);return r}});Al=g("$ZodEnum",(e,t)=>{R.init(e,t);let r=Rr(t.entries),o=new Set(r);e._zod.values=o,e._zod.pattern=new RegExp(`^(${r.filter((n)=>Or.has(typeof n)).map((n)=>typeof n==="string"?ye(n):n.toString()).join("|")})$`),e._zod.parse=(n,i)=>{let s=n.value;if(o.has(s))return n;return n.issues.push({code:"invalid_value",values:r,input:s,inst:e}),n}}),kl=g("$ZodLiteral",(e,t)=>{if(R.init(e,t),t.values.length===0)throw Error("Cannot create literal schema with no valid values");let r=new Set(t.values);e._zod.values=r,e._zod.pattern=new RegExp(`^(${t.values.map((o)=>typeof o==="string"?ye(o):o?ye(o.toString()):String(o)).join("|")})$`),e._zod.parse=(o,n)=>{let i=o.value;if(r.has(i))return o;return o.issues.push({code:"invalid_value",values:t.values,input:i,inst:e}),o}}),Pl=g("$ZodFile",(e,t)=>{R.init(e,t),e._zod.parse=(r,o)=>{let n=r.value;if(n instanceof File)return r;return r.issues.push({expected:"file",code:"invalid_type",input:n,inst:e}),r}}),Cl=g("$ZodTransform",(e,t)=>{R.init(e,t),e._zod.optin="optional",e._zod.parse=(r,o)=>{if(o.direction==="backward")throw new lt(e.constructor.name);let n=t.transform(r.value,r);if(o.async)return(n instanceof Promise?n:Promise.resolve(n)).then((s)=>(r.value=s,r.fallback=!0,r));if(n instanceof Promise)throw new Ie;return r.value=n,r.fallback=!0,r}});ki=g("$ZodOptional",(e,t)=>{R.init(e,t),e._zod.optin="optional",e._zod.optout="optional",I(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),I(e._zod,"pattern",()=>{let r=t.innerType._zod.pattern;return r?new RegExp(`^(${Tr(r.source)})?$`):void 0}),e._zod.parse=(r,o)=>{if(t.innerType._zod.optin==="optional"){let n=r.value,i=t.innerType._zod.run(r,o);if(i instanceof Promise)return i.then((s)=>Cu(s,n));return Cu(i,n)}if(r.value===void 0)return r;return t.innerType._zod.run(r,o)}}),Rl=g("$ZodExactOptional",(e,t)=>{ki.init(e,t),I(e._zod,"values",()=>t.innerType._zod.values),I(e._zod,"pattern",()=>t.innerType._zod.pattern),e._zod.parse=(r,o)=>t.innerType._zod.run(r,o)}),Tl=g("$ZodNullable",(e,t)=>{R.init(e,t),I(e._zod,"optin",()=>t.innerType._zod.optin),I(e._zod,"optout",()=>t.innerType._zod.optout),I(e._zod,"pattern",()=>{let r=t.innerType._zod.pattern;return r?new RegExp(`^(${Tr(r.source)}|null)$`):void 0}),I(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(r,o)=>{if(r.value===null)return r;return t.innerType._zod.run(r,o)}}),Ol=g("$ZodDefault",(e,t)=>{R.init(e,t),e._zod.optin="optional",I(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,o)=>{if(o.direction==="backward")return t.innerType._zod.run(r,o);if(r.value===void 0)return r.value=t.defaultValue,r;let n=t.innerType._zod.run(r,o);if(n instanceof Promise)return n.then((i)=>Ru(i,t));return Ru(n,t)}});Il=g("$ZodPrefault",(e,t)=>{R.init(e,t),e._zod.optin="optional",I(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,o)=>{if(o.direction==="backward")return t.innerType._zod.run(r,o);if(r.value===void 0)r.value=t.defaultValue;return t.innerType._zod.run(r,o)}}),Bl=g("$ZodNonOptional",(e,t)=>{R.init(e,t),I(e._zod,"values",()=>{let r=t.innerType._zod.values;return r?new Set([...r].filter((o)=>o!==void 0)):void 0}),e._zod.parse=(r,o)=>{let n=t.innerType._zod.run(r,o);if(n instanceof Promise)return n.then((i)=>Tu(i,e));return Tu(n,e)}});zl=g("$ZodSuccess",(e,t)=>{R.init(e,t),e._zod.parse=(r,o)=>{if(o.direction==="backward")throw new lt("ZodSuccess");let n=t.innerType._zod.run(r,o);if(n instanceof Promise)return n.then((i)=>(r.value=i.issues.length===0,r));return r.value=n.issues.length===0,r}}),Dl=g("$ZodCatch",(e,t)=>{R.init(e,t),e._zod.optin="optional",I(e._zod,"optout",()=>t.innerType._zod.optout),I(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,o)=>{if(o.direction==="backward")return t.innerType._zod.run(r,o);let n=t.innerType._zod.run(r,o);if(n instanceof Promise)return n.then((i)=>{if(r.value=i.value,i.issues.length)r.value=t.catchValue({...r,error:{issues:i.issues.map((s)=>ne(s,o,H()))},input:r.value}),r.issues=[],r.fallback=!0;return r});if(r.value=n.value,n.issues.length)r.value=t.catchValue({...r,error:{issues:n.issues.map((i)=>ne(i,o,H()))},input:r.value}),r.issues=[],r.fallback=!0;return r}}),Nl=g("$ZodNaN",(e,t)=>{R.init(e,t),e._zod.parse=(r,o)=>{if(typeof r.value!=="number"||!Number.isNaN(r.value))return r.issues.push({input:r.value,inst:e,expected:"nan",code:"invalid_type"}),r;return r}}),Pi=g("$ZodPipe",(e,t)=>{R.init(e,t),I(e._zod,"values",()=>t.in._zod.values),I(e._zod,"optin",()=>t.in._zod.optin),I(e._zod,"optout",()=>t.out._zod.optout),I(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(r,o)=>{if(o.direction==="backward"){let i=t.out._zod.run(r,o);if(i instanceof Promise)return i.then((s)=>Mr(s,t.in,o));return Mr(i,t.in,o)}let n=t.in._zod.run(r,o);if(n instanceof Promise)return n.then((i)=>Mr(i,t.out,o));return Mr(n,t.out,o)}});Wr=g("$ZodCodec",(e,t)=>{R.init(e,t),I(e._zod,"values",()=>t.in._zod.values),I(e._zod,"optin",()=>t.in._zod.optin),I(e._zod,"optout",()=>t.out._zod.optout),I(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(r,o)=>{if((o.direction||"forward")==="forward"){let i=t.in._zod.run(r,o);if(i instanceof Promise)return i.then((s)=>Fr(s,t,o));return Fr(i,t,o)}else{let i=t.out._zod.run(r,o);if(i instanceof Promise)return i.then((s)=>Fr(s,t,o));return Fr(i,t,o)}}});Ll=g("$ZodPreprocess",(e,t)=>{Pi.init(e,t)}),Vl=g("$ZodReadonly",(e,t)=>{R.init(e,t),I(e._zod,"propValues",()=>t.innerType._zod.propValues),I(e._zod,"values",()=>t.innerType._zod.values),I(e._zod,"optin",()=>t.innerType?._zod?.optin),I(e._zod,"optout",()=>t.innerType?._zod?.optout),e._zod.parse=(r,o)=>{if(o.direction==="backward")return t.innerType._zod.run(r,o);let n=t.innerType._zod.run(r,o);if(n instanceof Promise)return n.then(Ou);return Ou(n)}});Ul=g("$ZodTemplateLiteral",(e,t)=>{R.init(e,t);let r=[];for(let o of t.parts)if(typeof o==="object"&&o!==null){if(!o._zod.pattern)throw Error(`Invalid template literal part, no pattern found: ${[...o._zod.traits].shift()}`);let n=o._zod.pattern instanceof RegExp?o._zod.pattern.source:o._zod.pattern;if(!n)throw Error(`Invalid template literal part: ${o._zod.traits}`);let i=n.startsWith("^")?1:0,s=n.endsWith("$")?n.length-1:n.length;r.push(n.slice(i,s))}else if(o===null||Pc.has(typeof o))r.push(ye(`${o}`));else throw Error(`Invalid template literal part: ${o}`);e._zod.pattern=new RegExp(`^${r.join("")}$`),e._zod.parse=(o,n)=>{if(typeof o.value!=="string")return o.issues.push({input:o.value,inst:e,expected:"string",code:"invalid_type"}),o;if(e._zod.pattern.lastIndex=0,!e._zod.pattern.test(o.value))return o.issues.push({input:o.value,inst:e,code:"invalid_format",format:t.format??"template_literal",pattern:e._zod.pattern.source}),o;return o}}),Ml=g("$ZodFunction",(e,t)=>(R.init(e,t),e._def=t,e._zod.def=t,e.implement=(r)=>{if(typeof r!=="function")throw Error("implement() must be called with a function");return function(...o){let n=e._def.input?Fn(e._def.input,o):o,i=Reflect.apply(r,this,n);if(e._def.output)return Fn(e._def.output,i);return i}},e.implementAsync=(r)=>{if(typeof r!=="function")throw Error("implementAsync() must be called with a function");return async function(...o){let n=e._def.input?await jn(e._def.input,o):o,i=await Reflect.apply(r,this,n);if(e._def.output)return await jn(e._def.output,i);return i}},e._zod.parse=(r,o)=>{if(typeof r.value!=="function")return r.issues.push({code:"invalid_type",expected:"function",input:r.value,inst:e}),r;if(e._def.output&&e._def.output._zod.def.type==="promise")r.value=e.implementAsync(r.value);else r.value=e.implement(r.value);return r},e.input=(...r)=>{let o=e.constructor;if(Array.isArray(r[0]))return new o({type:"function",input:new Ai({type:"tuple",items:r[0],rest:r[1]}),output:e._def.output});return new o({type:"function",input:r[0],output:e._def.output})},e.output=(r)=>new e.constructor({type:"function",input:e._def.input,output:r}),e)),Fl=g("$ZodPromise",(e,t)=>{R.init(e,t),e._zod.parse=(r,o)=>Promise.resolve(r.value).then((n)=>t.innerType._zod.run({value:n,issues:[]},o))}),jl=g("$ZodLazy",(e,t)=>{R.init(e,t),I(e._zod,"innerType",()=>{let r=t;if(!r._cachedInner)r._cachedInner=t.getter();return r._cachedInner}),I(e._zod,"pattern",()=>e._zod.innerType?._zod?.pattern),I(e._zod,"propValues",()=>e._zod.innerType?._zod?.propValues),I(e._zod,"optin",()=>e._zod.innerType?._zod?.optin??void 0),I(e._zod,"optout",()=>e._zod.innerType?._zod?.optout??void 0),e._zod.parse=(r,o)=>e._zod.innerType._zod.run(r,o)}),Zl=g("$ZodCustom",(e,t)=>{U.init(e,t),R.init(e,t),e._zod.parse=(r,o)=>r,e._zod.check=(r)=>{let o=r.value,n=t.fn(o);if(n instanceof Promise)return n.then((i)=>Iu(i,r,o,e));Iu(n,r,o,e);return}})});function Ri(){return{localeError:p_()}}var p_=()=>{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(n){return e[n]??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",jwt:"JWT",template_literal:"input"},o={nan:"NaN"};return(n)=>{switch(n.code){case"invalid_type":{let i=o[n.expected]??n.expected,s=Ic(n.input),a=o[s]??s;return`Invalid input: expected ${i}, received ${a}`}case"invalid_value":if(n.values.length===1)return`Invalid input: expected ${Ln(n.values[0])}`;return`Invalid option: expected one of ${Bn(n.values,"|")}`;case"too_big":{let i=n.inclusive?"<=":"<",s=t(n.origin);if(s)return`Too big: expected ${n.origin??"value"} to have ${i}${n.maximum.toString()} ${s.unit??"elements"}`;return`Too big: expected ${n.origin??"value"} to be ${i}${n.maximum.toString()}`}case"too_small":{let i=n.inclusive?">=":">",s=t(n.origin);if(s)return`Too small: expected ${n.origin} to have ${i}${n.minimum.toString()} ${s.unit}`;return`Too small: expected ${n.origin} to be ${i}${n.minimum.toString()}`}case"invalid_format":{let i=n;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]??n.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${n.divisor}`;case"unrecognized_keys":return`Unrecognized key${n.keys.length>1?"s":""}: ${Bn(n.keys,", ")}`;case"invalid_key":return`Invalid key in ${n.origin}`;case"invalid_union":if(n.options&&Array.isArray(n.options)&&n.options.length>0)return`Invalid discriminator value. Expected ${n.options.map((s)=>`'${s}'`).join(" | ")}`;return"Invalid input";case"invalid_element":return`Invalid value in ${n.origin}`;default:return"Invalid input"}}};var ql=_(()=>{de()});var Ti=()=>{};class Gl{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 o={...r,...this._map.get(e)};return Object.keys(o).length?o:void 0}return this._map.get(e)}has(e){return this._map.has(e)}}function Kl(){return new Gl}var Wl,d_,f_,te;var jt=_(()=>{d_=Symbol("ZodOutput"),f_=Symbol("ZodInput");(Wl=globalThis).__zod_globalRegistry??(Wl.__zod_globalRegistry=Kl());te=globalThis.__zod_globalRegistry});function Hl(e,t){return new e({type:"string",...w(t)})}function Oi(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...w(t)})}function Gr(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...w(t)})}function Ii(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...w(t)})}function Bi(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...w(t)})}function zi(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...w(t)})}function Di(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...w(t)})}function Kr(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...w(t)})}function Ni(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...w(t)})}function Li(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...w(t)})}function Vi(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...w(t)})}function Ui(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...w(t)})}function Mi(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...w(t)})}function Fi(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...w(t)})}function ji(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...w(t)})}function Zi(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...w(t)})}function qi(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...w(t)})}function Jl(e,t){return new e({type:"string",format:"mac",check:"string_format",abort:!1,...w(t)})}function Qi(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...w(t)})}function Wi(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...w(t)})}function Gi(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...w(t)})}function Ki(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...w(t)})}function Hi(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...w(t)})}function Ji(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...w(t)})}function Yl(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...w(t)})}function Xl(e,t){return new e({type:"string",format:"date",check:"string_format",...w(t)})}function ep(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...w(t)})}function tp(e,t){return new e({type:"string",format:"duration",check:"string_format",...w(t)})}function rp(e,t){return new e({type:"number",checks:[],...w(t)})}function op(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...w(t)})}function np(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"float32",...w(t)})}function ip(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"float64",...w(t)})}function sp(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"int32",...w(t)})}function ap(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"uint32",...w(t)})}function cp(e,t){return new e({type:"boolean",...w(t)})}function up(e,t){return new e({type:"bigint",...w(t)})}function lp(e,t){return new e({type:"bigint",check:"bigint_format",abort:!1,format:"int64",...w(t)})}function pp(e,t){return new e({type:"bigint",check:"bigint_format",abort:!1,format:"uint64",...w(t)})}function dp(e,t){return new e({type:"symbol",...w(t)})}function fp(e,t){return new e({type:"undefined",...w(t)})}function mp(e,t){return new e({type:"null",...w(t)})}function hp(e){return new e({type:"any"})}function gp(e){return new e({type:"unknown"})}function yp(e,t){return new e({type:"never",...w(t)})}function bp(e,t){return new e({type:"void",...w(t)})}function _p(e,t){return new e({type:"date",...w(t)})}function wp(e,t){return new e({type:"nan",...w(t)})}function Ve(e,t){return new _i({check:"less_than",...w(t),value:e,inclusive:!1})}function _e(e,t){return new _i({check:"less_than",...w(t),value:e,inclusive:!0})}function Ue(e,t){return new wi({check:"greater_than",...w(t),value:e,inclusive:!1})}function ce(e,t){return new wi({check:"greater_than",...w(t),value:e,inclusive:!0})}function vp(e){return Ue(0,e)}function xp(e){return Ve(0,e)}function Ep(e){return _e(0,e)}function Sp(e){return ce(0,e)}function ft(e,t){return new eu({check:"multiple_of",...w(t),value:e})}function mt(e,t){return new ou({check:"max_size",...w(t),maximum:e})}function Me(e,t){return new nu({check:"min_size",...w(t),minimum:e})}function Zt(e,t){return new iu({check:"size_equals",...w(t),size:e})}function qt(e,t){return new su({check:"max_length",...w(t),maximum:e})}function rt(e,t){return new au({check:"min_length",...w(t),minimum:e})}function Qt(e,t){return new cu({check:"length_equals",...w(t),length:e})}function Hr(e,t){return new uu({check:"string_format",format:"regex",...w(t),pattern:e})}function Jr(e){return new lu({check:"string_format",format:"lowercase",...w(e)})}function Yr(e){return new pu({check:"string_format",format:"uppercase",...w(e)})}function Xr(e,t){return new du({check:"string_format",format:"includes",...w(t),includes:e})}function eo(e,t){return new fu({check:"string_format",format:"starts_with",...w(t),prefix:e})}function to(e,t){return new mu({check:"string_format",format:"ends_with",...w(t),suffix:e})}function $p(e,t,r){return new hu({check:"property",property:e,schema:t,...w(r)})}function ro(e,t){return new gu({check:"mime_type",mime:e,...w(t)})}function Be(e){return new yu({check:"overwrite",tx:e})}function oo(e){return Be((t)=>t.normalize(e))}function no(){return Be((e)=>e.trim())}function io(){return Be((e)=>e.toLowerCase())}function so(){return Be((e)=>e.toUpperCase())}function ao(){return Be((e)=>Ac(e))}function Ap(e,t,r){return new e({type:"array",element:t,...w(r)})}function kp(e,t){return new e({type:"file",...w(t)})}function Pp(e,t,r){let o=w(r);return o.abort??(o.abort=!0),new e({type:"custom",check:"custom",fn:t,...o})}function Cp(e,t,r){return new e({type:"custom",check:"custom",fn:t,...w(r)})}function Rp(e,t){let r=h_((o)=>(o.addIssue=(n)=>{if(typeof n==="string")o.issues.push(Xe(n,o.value,r._zod.def));else{let i=n;if(i.fatal)i.continue=!1;i.code??(i.code="custom"),i.input??(i.input=o.value),i.inst??(i.inst=r),i.continue??(i.continue=!r._zod.def.abort),o.issues.push(Xe(i))}},e(o.value,o)),t);return r}function h_(e,t){let r=new U({check:"custom",...w(t)});return r._zod.check=e,r}function Tp(e){let t=new U({check:"describe"});return t._zod.onattach=[(r)=>{let o=te.get(r)??{};te.add(r,{...o,description:e})}],t._zod.check=()=>{},t}function Op(e){let t=new U({check:"meta"});return t._zod.onattach=[(r)=>{let o=te.get(r)??{};te.add(r,{...o,...e})}],t._zod.check=()=>{},t}function Ip(e,t){let r=w(t),o=r.truthy??["true","1","yes","on","y","enabled"],n=r.falsy??["false","0","no","off","n","disabled"];if(r.case!=="sensitive")o=o.map((p)=>typeof p==="string"?p.toLowerCase():p),n=n.map((p)=>typeof p==="string"?p.toLowerCase():p);let i=new Set(o),s=new Set(n),a=e.Codec??Wr,c=e.Boolean??qr,l=new(e.String??dt)({type:"string",error:r.error}),f=new c({type:"boolean",error:r.error}),d=new a({type:"pipe",in:l,out:f,transform:(p,m)=>{let h=p;if(r.case!=="sensitive")h=h.toLowerCase();if(i.has(h))return!0;else if(s.has(h))return!1;else return m.issues.push({code:"invalid_value",expected:"stringbool",values:[...i,...s],input:m.value,inst:d,continue:!1}),{}},reverseTransform:(p,m)=>{if(p===!0)return o[0]||"true";else return n[0]||"false"},error:r.error});return d}function Wt(e,t,r,o={}){let n=w(o),i={...w(o),check:"string_format",type:"string",format:t,fn:typeof r==="function"?r:(a)=>r.test(a),...n};if(r instanceof RegExp)i.pattern=r;return new e(i)}var Bp=_(()=>{Ur();jt();Ci();de()});function Yi(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??te,target:t,unrepresentable:e?.unrepresentable??"throw",override:e?.override??(()=>{}),io:e?.io??"output",counter:0,seen:new Map,cycles:e?.cycles??"ref",reused:e?.reused??"inline",external:e?.external??void 0}}function j(e,t,r={path:[],schemaPath:[]}){var o;let n=e._zod.def,i=t.seen.get(e);if(i){if(i.count++,r.schemaPath.includes(e))i.cycle=r.path;return i.schema}let s={schema:{},count:1,cycle:void 0,path:r.path};t.seen.set(e,s);let a=e._zod.toJSONSchema?.();if(a)s.schema=a;else{let l={...r,schemaPath:[...r.schemaPath,e],path:r.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,s.schema,l);else{let d=s.schema,p=t.processors[n.type];if(!p)throw Error(`[toJSONSchema]: Non-representable type encountered: ${n.type}`);p(e,t,d,l)}let f=e._zod.parent;if(f){if(!s.ref)s.ref=f;j(f,t,l),t.seen.get(f).isParent=!0}}let c=t.metadataRegistry.get(e);if(c)Object.assign(s.schema,c);if(t.io==="input"&&re(e))delete s.schema.examples,delete s.schema.default;if(t.io==="input"&&"_prefault"in s.schema)(o=s.schema).default??(o.default=s.schema._prefault);return delete s.schema._prefault,t.seen.get(e).schema}function Xi(e,t){let r=e.seen.get(t);if(!r)throw Error("Unprocessed schema. This is a bug in Zod.");let o=new Map;for(let s of e.seen.entries()){let a=e.metadataRegistry.get(s[0])?.id;if(a){let c=o.get(a);if(c&&c!==s[0])throw Error(`Duplicate schema id "${a}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);o.set(a,s[0])}}let n=(s)=>{let a=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){let f=e.external.registry.get(s[0])?.id,d=e.external.uri??((m)=>m);if(f)return{ref:d(f)};let p=s[1].defId??s[1].schema.id??`schema${e.counter++}`;return s[1].defId=p,{defId:p,ref:`${d("__shared")}#/${a}/${p}`}}if(s[1]===r)return{ref:"#"};let u=`${"#"}/${a}/`,l=s[1].schema.id??`__schema${e.counter++}`;return{defId:l,ref:u+l}},i=(s)=>{if(s[1].schema.$ref)return;let a=s[1],{ref:c,defId:u}=n(s);if(a.def={...a.schema},u)a.defId=u;let l=a.schema;for(let f in l)delete l[f];l.$ref=c};if(e.cycles==="throw")for(let s of e.seen.entries()){let a=s[1];if(a.cycle)throw Error(`Cycle detected: #/${a.cycle?.join("/")}/<root>
|
|
70
70
|
|
|
71
71
|
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let s of e.seen.entries()){let a=s[1];if(t===s[0]){i(s);continue}if(e.external){let u=e.external.registry.get(s[0])?.id;if(t!==s[0]&&u){i(s);continue}}if(e.metadataRegistry.get(s[0])?.id){i(s);continue}if(a.cycle){i(s);continue}if(a.count>1){if(e.reused==="ref"){i(s);continue}}}}function es(e,t){let r=e.seen.get(t);if(!r)throw Error("Unprocessed schema. This is a bug in Zod.");let o=(a)=>{let c=e.seen.get(a);if(c.ref===null)return;let u=c.def??c.schema,l={...u},f=c.ref;if(c.ref=null,f){o(f);let p=e.seen.get(f),m=p.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 Object.assign(u,m);if(Object.assign(u,l),a._zod.parent===f)for(let y in u){if(y==="$ref"||y==="allOf")continue;if(!(y in l))delete u[y]}if(m.$ref&&p.def)for(let y in u){if(y==="$ref"||y==="allOf")continue;if(y in p.def&&JSON.stringify(u[y])===JSON.stringify(p.def[y]))delete u[y]}}let d=a._zod.parent;if(d&&d!==f){o(d);let p=e.seen.get(d);if(p?.schema.$ref){if(u.$ref=p.schema.$ref,p.def)for(let m in u){if(m==="$ref"||m==="allOf")continue;if(m in p.def&&JSON.stringify(u[m])===JSON.stringify(p.def[m]))delete u[m]}}}e.override({zodSchema:a,jsonSchema:u,path:c.path??[]})};for(let a of[...e.seen.entries()].reverse())o(a[0]);let n={};if(e.target==="draft-2020-12")n.$schema="https://json-schema.org/draft/2020-12/schema";else if(e.target==="draft-07")n.$schema="http://json-schema.org/draft-07/schema#";else if(e.target==="draft-04")n.$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");n.$id=e.external.uri(a)}Object.assign(n,r.def??r.schema);let i=e.metadataRegistry.get(t)?.id;if(i!==void 0&&n.id===i)delete n.id;let s=e.external?.defs??{};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;s[c.defId]=c.def}}if(e.external);else if(Object.keys(s).length>0)if(e.target==="draft-2020-12")n.$defs=s;else n.definitions=s;try{let a=JSON.parse(JSON.stringify(n));return Object.defineProperty(a,"~standard",{value:{...t["~standard"],jsonSchema:{input:Gt(t,"input",e.processors),output:Gt(t,"output",e.processors)}},enumerable:!1,writable:!1}),a}catch(a){throw Error("Error converting schema to JSON.")}}function re(e,t){let r=t??{seen:new Set};if(r.seen.has(e))return!1;r.seen.add(e);let o=e._zod.def;if(o.type==="transform")return!0;if(o.type==="array")return re(o.element,r);if(o.type==="set")return re(o.valueType,r);if(o.type==="lazy")return re(o.getter(),r);if(o.type==="promise"||o.type==="optional"||o.type==="nonoptional"||o.type==="nullable"||o.type==="readonly"||o.type==="default"||o.type==="prefault")return re(o.innerType,r);if(o.type==="intersection")return re(o.left,r)||re(o.right,r);if(o.type==="record"||o.type==="map")return re(o.keyType,r)||re(o.valueType,r);if(o.type==="pipe"){if(e._zod.traits.has("$ZodCodec"))return!0;return re(o.in,r)||re(o.out,r)}if(o.type==="object"){for(let n in o.shape)if(re(o.shape[n],r))return!0;return!1}if(o.type==="union"){for(let n of o.options)if(re(n,r))return!0;return!1}if(o.type==="tuple"){for(let n of o.items)if(re(n,r))return!0;if(o.rest&&re(o.rest,r))return!0;return!1}return!1}var zp=(e,t={})=>(r)=>{let o=Yi({...r,processors:t});return j(e,o),Xi(o,e),es(o,e)},Gt=(e,t,r={})=>(o)=>{let{libraryOptions:n,target:i}=o??{},s=Yi({...n??{},target:i,io:t,processors:r});return j(e,s),Xi(s,e),es(s,e)};var co=_(()=>{jt()});var g_,Dp=(e,t,r,o)=>{let n=r;n.type="string";let{minimum:i,maximum:s,format:a,patterns:c,contentEncoding:u}=e._zod.bag;if(typeof i==="number")n.minLength=i;if(typeof s==="number")n.maxLength=s;if(a){if(n.format=g_[a]??a,n.format==="")delete n.format;if(a==="time")delete n.format}if(u)n.contentEncoding=u;if(c&&c.size>0){let l=[...c];if(l.length===1)n.pattern=l[0].source;else if(l.length>1)n.allOf=[...l.map((f)=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:f.source}))]}},Np=(e,t,r,o)=>{let n=r,{minimum:i,maximum:s,format:a,multipleOf:c,exclusiveMaximum:u,exclusiveMinimum:l}=e._zod.bag;if(typeof a==="string"&&a.includes("int"))n.type="integer";else n.type="number";let f=typeof l==="number"&&l>=(i??Number.NEGATIVE_INFINITY),d=typeof u==="number"&&u<=(s??Number.POSITIVE_INFINITY),p=t.target==="draft-04"||t.target==="openapi-3.0";if(f)if(p)n.minimum=l,n.exclusiveMinimum=!0;else n.exclusiveMinimum=l;else if(typeof i==="number")n.minimum=i;if(d)if(p)n.maximum=u,n.exclusiveMaximum=!0;else n.exclusiveMaximum=u;else if(typeof s==="number")n.maximum=s;if(typeof c==="number")n.multipleOf=c},Lp=(e,t,r,o)=>{r.type="boolean"},Vp=(e,t,r,o)=>{if(t.unrepresentable==="throw")throw Error("BigInt cannot be represented in JSON Schema")},Up=(e,t,r,o)=>{if(t.unrepresentable==="throw")throw Error("Symbols cannot be represented in JSON Schema")},Mp=(e,t,r,o)=>{if(t.target==="openapi-3.0")r.type="string",r.nullable=!0,r.enum=[null];else r.type="null"},Fp=(e,t,r,o)=>{if(t.unrepresentable==="throw")throw Error("Undefined cannot be represented in JSON Schema")},jp=(e,t,r,o)=>{if(t.unrepresentable==="throw")throw Error("Void cannot be represented in JSON Schema")},Zp=(e,t,r,o)=>{r.not={}},qp=(e,t,r,o)=>{},Qp=(e,t,r,o)=>{},Wp=(e,t,r,o)=>{if(t.unrepresentable==="throw")throw Error("Date cannot be represented in JSON Schema")},Gp=(e,t,r,o)=>{let n=e._zod.def,i=Rr(n.entries);if(i.every((s)=>typeof s==="number"))r.type="number";if(i.every((s)=>typeof s==="string"))r.type="string";r.enum=i},Kp=(e,t,r,o)=>{let n=e._zod.def,i=[];for(let s of n.values)if(s===void 0){if(t.unrepresentable==="throw")throw Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof s==="bigint")if(t.unrepresentable==="throw")throw Error("BigInt literals cannot be represented in JSON Schema");else i.push(Number(s));else i.push(s);if(i.length===0);else if(i.length===1){let s=i[0];if(r.type=s===null?"null":typeof s,t.target==="draft-04"||t.target==="openapi-3.0")r.enum=[s];else r.const=s}else{if(i.every((s)=>typeof s==="number"))r.type="number";if(i.every((s)=>typeof s==="string"))r.type="string";if(i.every((s)=>typeof s==="boolean"))r.type="boolean";if(i.every((s)=>s===null))r.type="null";r.enum=i}},Hp=(e,t,r,o)=>{if(t.unrepresentable==="throw")throw Error("NaN cannot be represented in JSON Schema")},Jp=(e,t,r,o)=>{let n=r,i=e._zod.pattern;if(!i)throw Error("Pattern not found in template literal");n.type="string",n.pattern=i.source},Yp=(e,t,r,o)=>{let n=r,i={type:"string",format:"binary",contentEncoding:"binary"},{minimum:s,maximum:a,mime:c}=e._zod.bag;if(s!==void 0)i.minLength=s;if(a!==void 0)i.maxLength=a;if(c)if(c.length===1)i.contentMediaType=c[0],Object.assign(n,i);else Object.assign(n,i),n.anyOf=c.map((u)=>({contentMediaType:u}));else Object.assign(n,i)},Xp=(e,t,r,o)=>{r.type="boolean"},ed=(e,t,r,o)=>{if(t.unrepresentable==="throw")throw Error("Custom types cannot be represented in JSON Schema")},td=(e,t,r,o)=>{if(t.unrepresentable==="throw")throw Error("Function types cannot be represented in JSON Schema")},rd=(e,t,r,o)=>{if(t.unrepresentable==="throw")throw Error("Transforms cannot be represented in JSON Schema")},od=(e,t,r,o)=>{if(t.unrepresentable==="throw")throw Error("Map cannot be represented in JSON Schema")},nd=(e,t,r,o)=>{if(t.unrepresentable==="throw")throw Error("Set cannot be represented in JSON Schema")},id=(e,t,r,o)=>{let n=r,i=e._zod.def,{minimum:s,maximum:a}=e._zod.bag;if(typeof s==="number")n.minItems=s;if(typeof a==="number")n.maxItems=a;n.type="array",n.items=j(i.element,t,{...o,path:[...o.path,"items"]})},sd=(e,t,r,o)=>{let n=r,i=e._zod.def;n.type="object",n.properties={};let s=i.shape;for(let u in s)n.properties[u]=j(s[u],t,{...o,path:[...o.path,"properties",u]});let a=new Set(Object.keys(s)),c=new Set([...a].filter((u)=>{let l=i.shape[u]._zod;if(t.io==="input")return l.optin===void 0;else return l.optout===void 0}));if(c.size>0)n.required=Array.from(c);if(i.catchall?._zod.def.type==="never")n.additionalProperties=!1;else if(!i.catchall){if(t.io==="output")n.additionalProperties=!1}else if(i.catchall)n.additionalProperties=j(i.catchall,t,{...o,path:[...o.path,"additionalProperties"]})},ts=(e,t,r,o)=>{let n=e._zod.def,i=n.inclusive===!1,s=n.options.map((a,c)=>j(a,t,{...o,path:[...o.path,i?"oneOf":"anyOf",c]}));if(i)r.oneOf=s;else r.anyOf=s},ad=(e,t,r,o)=>{let n=e._zod.def,i=j(n.left,t,{...o,path:[...o.path,"allOf",0]}),s=j(n.right,t,{...o,path:[...o.path,"allOf",1]}),a=(u)=>("allOf"in u)&&Object.keys(u).length===1,c=[...a(i)?i.allOf:[i],...a(s)?s.allOf:[s]];r.allOf=c},cd=(e,t,r,o)=>{let n=r,i=e._zod.def;n.type="array";let s=t.target==="draft-2020-12"?"prefixItems":"items",a=t.target==="draft-2020-12"?"items":t.target==="openapi-3.0"?"items":"additionalItems",c=i.items.map((d,p)=>j(d,t,{...o,path:[...o.path,s,p]})),u=i.rest?j(i.rest,t,{...o,path:[...o.path,a,...t.target==="openapi-3.0"?[i.items.length]:[]]}):null;if(t.target==="draft-2020-12"){if(n.prefixItems=c,u)n.items=u}else if(t.target==="openapi-3.0"){if(n.items={anyOf:c},u)n.items.anyOf.push(u);if(n.minItems=c.length,!u)n.maxItems=c.length}else if(n.items=c,u)n.additionalItems=u;let{minimum:l,maximum:f}=e._zod.bag;if(typeof l==="number")n.minItems=l;if(typeof f==="number")n.maxItems=f},ud=(e,t,r,o)=>{let n=r,i=e._zod.def;n.type="object";let s=i.keyType,c=s._zod.bag?.patterns;if(i.mode==="loose"&&c&&c.size>0){let l=j(i.valueType,t,{...o,path:[...o.path,"patternProperties","*"]});n.patternProperties={};for(let f of c)n.patternProperties[f.source]=l}else{if(t.target==="draft-07"||t.target==="draft-2020-12")n.propertyNames=j(i.keyType,t,{...o,path:[...o.path,"propertyNames"]});n.additionalProperties=j(i.valueType,t,{...o,path:[...o.path,"additionalProperties"]})}let u=s._zod.values;if(u){let l=[...u].filter((f)=>typeof f==="string"||typeof f==="number");if(l.length>0)n.required=l}},ld=(e,t,r,o)=>{let n=e._zod.def,i=j(n.innerType,t,o),s=t.seen.get(e);if(t.target==="openapi-3.0")s.ref=n.innerType,r.nullable=!0;else r.anyOf=[i,{type:"null"}]},pd=(e,t,r,o)=>{let n=e._zod.def;j(n.innerType,t,o);let i=t.seen.get(e);i.ref=n.innerType},dd=(e,t,r,o)=>{let n=e._zod.def;j(n.innerType,t,o);let i=t.seen.get(e);i.ref=n.innerType,r.default=JSON.parse(JSON.stringify(n.defaultValue))},fd=(e,t,r,o)=>{let n=e._zod.def;j(n.innerType,t,o);let i=t.seen.get(e);if(i.ref=n.innerType,t.io==="input")r._prefault=JSON.parse(JSON.stringify(n.defaultValue))},md=(e,t,r,o)=>{let n=e._zod.def;j(n.innerType,t,o);let i=t.seen.get(e);i.ref=n.innerType;let s;try{s=n.catchValue(void 0)}catch{throw Error("Dynamic catch values are not supported in JSON Schema")}r.default=s},hd=(e,t,r,o)=>{let n=e._zod.def,i=n.in._zod.traits.has("$ZodTransform"),s=t.io==="input"?i?n.out:n.in:n.out;j(s,t,o);let a=t.seen.get(e);a.ref=s},gd=(e,t,r,o)=>{let n=e._zod.def;j(n.innerType,t,o);let i=t.seen.get(e);i.ref=n.innerType,r.readOnly=!0},yd=(e,t,r,o)=>{let n=e._zod.def;j(n.innerType,t,o);let i=t.seen.get(e);i.ref=n.innerType},rs=(e,t,r,o)=>{let n=e._zod.def;j(n.innerType,t,o);let i=t.seen.get(e);i.ref=n.innerType},bd=(e,t,r,o)=>{let n=e._zod.innerType;j(n,t,o);let i=t.seen.get(e);i.ref=n};var _d=_(()=>{co();de();g_={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""}});var wd=()=>{};var we=_(()=>{de();Vr();Ti();wd();Ge();Zn();Mn();Ci();Ur();xi();jt();Bp();co()});var uo={};Er(uo,{endsWith:()=>to,gt:()=>Ue,gte:()=>ce,includes:()=>Xr,length:()=>Qt,lowercase:()=>Jr,lt:()=>Ve,lte:()=>_e,maxLength:()=>qt,maxSize:()=>mt,mime:()=>ro,minLength:()=>rt,minSize:()=>Me,multipleOf:()=>ft,negative:()=>xp,nonnegative:()=>Sp,nonpositive:()=>Ep,normalize:()=>oo,overwrite:()=>Be,positive:()=>vp,property:()=>$p,regex:()=>Hr,size:()=>Zt,slugify:()=>ao,startsWith:()=>eo,toLowerCase:()=>io,toUpperCase:()=>so,trim:()=>no,uppercase:()=>Yr});var lo=_(()=>{we()});var Ht={};Er(Ht,{ZodISODate:()=>xd,ZodISODateTime:()=>vd,ZodISODuration:()=>Sd,ZodISOTime:()=>Ed,date:()=>ns,datetime:()=>os,duration:()=>ss,time:()=>is});function os(e){return Yl(vd,e)}function ns(e){return Xl(xd,e)}function is(e){return ep(Ed,e)}function ss(e){return tp(Sd,e)}var vd,xd,Ed,Sd;var po=_(()=>{we();mo();vd=g("ZodISODateTime",(e,t)=>{qu.init(e,t),L.init(e,t)});xd=g("ZodISODate",(e,t)=>{Qu.init(e,t),L.init(e,t)});Ed=g("ZodISOTime",(e,t)=>{Wu.init(e,t),L.init(e,t)});Sd=g("ZodISODuration",(e,t)=>{Gu.init(e,t),L.init(e,t)})});var $d=(e,t)=>{zr.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:(r)=>Un(e,r)},flatten:{value:(r)=>Vn(e,r)},addIssue:{value:(r)=>{e.issues.push(r),e.message=JSON.stringify(e.issues,It,2)}},addIssues:{value:(r)=>{e.issues.push(...r),e.message=JSON.stringify(e.issues,It,2)}},isEmpty:{get(){return e.issues.length===0}}})},Ad,ue;var as=_(()=>{we();we();de();Ad=g("ZodError",$d),ue=g("ZodError",$d,{Parent:Error})});var kd,Pd,Cd,Rd,Td,Od,Id,Bd,zd,Dd,Nd,Ld;var cs=_(()=>{we();as();kd=Dt(ue),Pd=Nt(ue),Cd=Lt(ue),Rd=Vt(ue),Td=Lc(ue),Od=Vc(ue),Id=Uc(ue),Bd=Mc(ue),zd=Fc(ue),Dd=jc(ue),Nd=Zc(ue),Ld=qc(ue)});var fo={};Er(fo,{ZodAny:()=>Wd,ZodArray:()=>Yd,ZodBase64:()=>$s,ZodBase64URL:()=>As,ZodBigInt:()=>Ts,ZodBigIntFormat:()=>Os,ZodBoolean:()=>Rs,ZodCIDRv4:()=>Es,ZodCIDRv6:()=>Ss,ZodCUID:()=>gs,ZodCUID2:()=>ys,ZodCatch:()=>vf,ZodCodec:()=>So,ZodCustom:()=>$o,ZodCustomStringFormat:()=>er,ZodDate:()=>Jd,ZodDefault:()=>hf,ZodDiscriminatedUnion:()=>ef,ZodE164:()=>ks,ZodEmail:()=>fs,ZodEmoji:()=>ms,ZodEnum:()=>Yt,ZodExactOptional:()=>df,ZodFile:()=>lf,ZodFunction:()=>Tf,ZodGUID:()=>go,ZodIPv4:()=>vs,ZodIPv6:()=>xs,ZodIntersection:()=>tf,ZodJWT:()=>Ps,ZodKSUID:()=>ws,ZodLazy:()=>Pf,ZodLiteral:()=>uf,ZodMAC:()=>Ud,ZodMap:()=>af,ZodNaN:()=>Ef,ZodNanoID:()=>hs,ZodNever:()=>Kd,ZodNonOptional:()=>Ls,ZodNull:()=>qd,ZodNullable:()=>mf,ZodNumber:()=>Cs,ZodNumberFormat:()=>gt,ZodObject:()=>vo,ZodOptional:()=>Ns,ZodPipe:()=>Eo,ZodPrefault:()=>yf,ZodPreprocess:()=>Sf,ZodPromise:()=>Rf,ZodReadonly:()=>$f,ZodRecord:()=>Jt,ZodSet:()=>cf,ZodString:()=>ds,ZodStringFormat:()=>L,ZodSuccess:()=>wf,ZodSymbol:()=>jd,ZodTemplateLiteral:()=>kf,ZodTransform:()=>pf,ZodTuple:()=>of,ZodType:()=>O,ZodULID:()=>bs,ZodURL:()=>_o,ZodUUID:()=>ze,ZodUndefined:()=>Zd,ZodUnion:()=>xo,ZodUnknown:()=>Gd,ZodVoid:()=>Hd,ZodXID:()=>_s,ZodXor:()=>Xd,_ZodString:()=>ps,_default:()=>gf,_function:()=>$w,any:()=>rw,array:()=>wo,base64:()=>V_,base64url:()=>U_,bigint:()=>J_,boolean:()=>Fd,catch:()=>xf,check:()=>Aw,cidrv4:()=>N_,cidrv6:()=>L_,codec:()=>vw,cuid:()=>C_,cuid2:()=>R_,custom:()=>kw,date:()=>nw,describe:()=>Pw,discriminatedUnion:()=>lw,e164:()=>M_,email:()=>__,emoji:()=>k_,enum:()=>zs,exactOptional:()=>ff,file:()=>yw,float32:()=>W_,float64:()=>G_,function:()=>$w,guid:()=>w_,hash:()=>Q_,hex:()=>q_,hostname:()=>Z_,httpUrl:()=>A_,instanceof:()=>Rw,int:()=>us,int32:()=>K_,int64:()=>Y_,intersection:()=>rf,invertCodec:()=>xw,ipv4:()=>B_,ipv6:()=>D_,json:()=>Ow,jwt:()=>F_,keyof:()=>iw,ksuid:()=>I_,lazy:()=>Cf,literal:()=>gw,looseObject:()=>cw,looseRecord:()=>dw,mac:()=>z_,map:()=>fw,meta:()=>Cw,nan:()=>ww,nanoid:()=>P_,nativeEnum:()=>hw,never:()=>Is,nonoptional:()=>_f,null:()=>Qd,nullable:()=>bo,nullish:()=>bw,number:()=>Md,object:()=>sw,optional:()=>yo,partialRecord:()=>pw,pipe:()=>ls,prefault:()=>bf,preprocess:()=>Iw,promise:()=>Sw,readonly:()=>Af,record:()=>sf,refine:()=>Of,set:()=>mw,strictObject:()=>aw,string:()=>ho,stringFormat:()=>j_,stringbool:()=>Tw,success:()=>_w,superRefine:()=>If,symbol:()=>ew,templateLiteral:()=>Ew,transform:()=>Ds,tuple:()=>nf,uint32:()=>H_,uint64:()=>X_,ulid:()=>T_,undefined:()=>tw,union:()=>Bs,unknown:()=>ht,url:()=>$_,uuid:()=>v_,uuidv4:()=>x_,uuidv6:()=>E_,uuidv7:()=>S_,void:()=>ow,xid:()=>O_,xor:()=>uw});function Xt(e,t,r){let o=Object.getPrototypeOf(e),n=Vd.get(o);if(!n)n=new Set,Vd.set(o,n);if(n.has(t))return;n.add(t);for(let i in r){let s=r[i];Object.defineProperty(o,i,{configurable:!0,enumerable:!1,get(){let a=s.bind(this);return Object.defineProperty(this,i,{configurable:!0,writable:!0,enumerable:!0,value:a}),a},set(a){Object.defineProperty(this,i,{configurable:!0,writable:!0,enumerable:!0,value:a})}})}}function ho(e){return Hl(ds,e)}function __(e){return Oi(fs,e)}function w_(e){return Gr(go,e)}function v_(e){return Ii(ze,e)}function x_(e){return Bi(ze,e)}function E_(e){return zi(ze,e)}function S_(e){return Di(ze,e)}function $_(e){return Kr(_o,e)}function A_(e){return Kr(_o,{protocol:Nr,hostname:Gc,...w(e)})}function k_(e){return Ni(ms,e)}function P_(e){return Li(hs,e)}function C_(e){return Vi(gs,e)}function R_(e){return Ui(ys,e)}function T_(e){return Mi(bs,e)}function O_(e){return Fi(_s,e)}function I_(e){return ji(ws,e)}function B_(e){return Zi(vs,e)}function z_(e){return Jl(Ud,e)}function D_(e){return qi(xs,e)}function N_(e){return Qi(Es,e)}function L_(e){return Wi(Ss,e)}function V_(e){return Gi($s,e)}function U_(e){return Ki(As,e)}function M_(e){return Hi(ks,e)}function F_(e){return Ji(Ps,e)}function j_(e,t,r={}){return Wt(er,e,t,r)}function Z_(e){return Wt(er,"hostname",Wc,e)}function q_(e){return Wt(er,"hex",Jc,e)}function Q_(e,t){let r=t?.enc??"hex",o=`${e}_${r}`,n=tt[o];if(!n)throw Error(`Unrecognized hash format: ${o}`);return Wt(er,o,n,t)}function Md(e){return rp(Cs,e)}function us(e){return op(gt,e)}function W_(e){return np(gt,e)}function G_(e){return ip(gt,e)}function K_(e){return sp(gt,e)}function H_(e){return ap(gt,e)}function Fd(e){return cp(Rs,e)}function J_(e){return up(Ts,e)}function Y_(e){return lp(Os,e)}function X_(e){return pp(Os,e)}function ew(e){return dp(jd,e)}function tw(e){return fp(Zd,e)}function Qd(e){return mp(qd,e)}function rw(){return hp(Wd)}function ht(){return gp(Gd)}function Is(e){return yp(Kd,e)}function ow(e){return bp(Hd,e)}function nw(e){return _p(Jd,e)}function wo(e,t){return Ap(Yd,e,t)}function iw(e){let t=e._zod.def.shape;return zs(Object.keys(t))}function sw(e,t){let r={type:"object",shape:e??{},...w(t)};return new vo(r)}function aw(e,t){return new vo({type:"object",shape:e,catchall:Is(),...w(t)})}function cw(e,t){return new vo({type:"object",shape:e,catchall:ht(),...w(t)})}function Bs(e,t){return new xo({type:"union",options:e,...w(t)})}function uw(e,t){return new Xd({type:"union",options:e,inclusive:!1,...w(t)})}function lw(e,t,r){return new ef({type:"union",options:t,discriminator:e,...w(r)})}function rf(e,t){return new tf({type:"intersection",left:e,right:t})}function nf(e,t,r){let o=t instanceof R,n=o?r:t;return new of({type:"tuple",items:e,rest:o?t:null,...w(n)})}function sf(e,t,r){if(!t||!t._zod)return new Jt({type:"record",keyType:ho(),valueType:e,...w(t)});return new Jt({type:"record",keyType:e,valueType:t,...w(r)})}function pw(e,t,r){let o=pe(e);return o._zod.values=void 0,new Jt({type:"record",keyType:o,valueType:t,...w(r)})}function dw(e,t,r){return new Jt({type:"record",keyType:e,valueType:t,mode:"loose",...w(r)})}function fw(e,t,r){return new af({type:"map",keyType:e,valueType:t,...w(r)})}function mw(e,t){return new cf({type:"set",valueType:e,...w(t)})}function zs(e,t){let r=Array.isArray(e)?Object.fromEntries(e.map((o)=>[o,o])):e;return new Yt({type:"enum",entries:r,...w(t)})}function hw(e,t){return new Yt({type:"enum",entries:e,...w(t)})}function gw(e,t){return new uf({type:"literal",values:Array.isArray(e)?e:[e],...w(t)})}function yw(e){return kp(lf,e)}function Ds(e){return new pf({type:"transform",transform:e})}function yo(e){return new Ns({type:"optional",innerType:e})}function ff(e){return new df({type:"optional",innerType:e})}function bo(e){return new mf({type:"nullable",innerType:e})}function bw(e){return yo(bo(e))}function gf(e,t){return new hf({type:"default",innerType:e,get defaultValue(){return typeof t==="function"?t():Nn(t)}})}function bf(e,t){return new yf({type:"prefault",innerType:e,get defaultValue(){return typeof t==="function"?t():Nn(t)}})}function _f(e,t){return new Ls({type:"nonoptional",innerType:e,...w(t)})}function _w(e){return new wf({type:"success",innerType:e})}function xf(e,t){return new vf({type:"catch",innerType:e,catchValue:typeof t==="function"?t:()=>t})}function ww(e){return wp(Ef,e)}function ls(e,t){return new Eo({type:"pipe",in:e,out:t})}function vw(e,t,r){return new So({type:"pipe",in:e,out:t,transform:r.decode,reverseTransform:r.encode})}function xw(e){let t=e._zod.def;return new So({type:"pipe",in:t.out,out:t.in,transform:t.reverseTransform,reverseTransform:t.transform})}function Af(e){return new $f({type:"readonly",innerType:e})}function Ew(e,t){return new kf({type:"template_literal",parts:e,...w(t)})}function Cf(e){return new Pf({type:"lazy",getter:e})}function Sw(e){return new Rf({type:"promise",innerType:e})}function $w(e){return new Tf({type:"function",input:Array.isArray(e?.input)?nf(e?.input):e?.input??wo(ht()),output:e?.output??ht()})}function Aw(e){let t=new U({check:"custom"});return t._zod.check=e,t}function kw(e,t){return Pp($o,e??(()=>!0),t)}function Of(e,t={}){return Cp($o,e,t)}function If(e,t){return Rp(e,t)}function Rw(e,t={}){let r=new $o({type:"custom",check:"custom",fn:(o)=>o instanceof e,abort:!0,...w(t)});return r._zod.bag.Class=e,r._zod.check=(o)=>{if(!(o.value instanceof e))o.issues.push({code:"invalid_type",expected:e.name,input:o.value,inst:r,path:[...r._zod.def.path??[]]})},r}function Ow(e){let t=Cf(()=>Bs([ho(e),Md(),Fd(),Qd(),wo(t),sf(ho(),t)]));return t}function Iw(e,t){return new Sf({type:"pipe",in:Ds(e),out:t})}var Vd,O,ps,ds,L,fs,go,ze,_o,ms,hs,gs,ys,bs,_s,ws,vs,Ud,xs,Es,Ss,$s,As,ks,Ps,er,Cs,gt,Rs,Ts,Os,jd,Zd,qd,Wd,Gd,Kd,Hd,Jd,Yd,vo,xo,Xd,ef,tf,of,Jt,af,cf,Yt,uf,lf,pf,Ns,df,mf,hf,yf,Ls,wf,vf,Ef,Eo,So,Sf,$f,kf,Pf,Rf,Tf,$o,Pw,Cw,Tw=(...e)=>Ip({Codec:So,Boolean:Rs,String:ds},...e);var mo=_(()=>{we();we();_d();co();lo();po();cs();Vd=new WeakMap;O=g("ZodType",(e,t)=>(R.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:Gt(e,"input"),output:Gt(e,"output")}}),e.toJSONSchema=zp(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.parse=(r,o)=>kd(e,r,o,{callee:e.parse}),e.safeParse=(r,o)=>Cd(e,r,o),e.parseAsync=async(r,o)=>Pd(e,r,o,{callee:e.parseAsync}),e.safeParseAsync=async(r,o)=>Rd(e,r,o),e.spa=e.safeParseAsync,e.encode=(r,o)=>Td(e,r,o),e.decode=(r,o)=>Od(e,r,o),e.encodeAsync=async(r,o)=>Id(e,r,o),e.decodeAsync=async(r,o)=>Bd(e,r,o),e.safeEncode=(r,o)=>zd(e,r,o),e.safeDecode=(r,o)=>Dd(e,r,o),e.safeEncodeAsync=async(r,o)=>Nd(e,r,o),e.safeDecodeAsync=async(r,o)=>Ld(e,r,o),Xt(e,"ZodType",{check(...r){let o=this.def;return this.clone(Le(o,{checks:[...o.checks??[],...r.map((n)=>typeof n==="function"?{_zod:{check:n,def:{check:"custom"},onattach:[]}}:n)]}),{parent:!0})},with(...r){return this.check(...r)},clone(r,o){return pe(this,r,o)},brand(){return this},register(r,o){return r.add(this,o),this},refine(r,o){return this.check(Of(r,o))},superRefine(r,o){return this.check(If(r,o))},overwrite(r){return this.check(Be(r))},optional(){return yo(this)},exactOptional(){return ff(this)},nullable(){return bo(this)},nullish(){return yo(bo(this))},nonoptional(r){return _f(this,r)},array(){return wo(this)},or(r){return Bs([this,r])},and(r){return rf(this,r)},transform(r){return ls(this,Ds(r))},default(r){return gf(this,r)},prefault(r){return bf(this,r)},catch(r){return xf(this,r)},pipe(r){return ls(this,r)},readonly(){return Af(this)},describe(r){let o=this.clone();return te.add(o,{description:r}),o},meta(...r){if(r.length===0)return te.get(this);let o=this.clone();return te.add(o,r[0]),o},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(r){return r(this)}}),Object.defineProperty(e,"description",{get(){return te.get(e)?.description},configurable:!0}),e)),ps=g("_ZodString",(e,t)=>{dt.init(e,t),O.init(e,t),e._zod.processJSONSchema=(o,n,i)=>Dp(e,o,n,i);let r=e._zod.bag;e.format=r.format??null,e.minLength=r.minimum??null,e.maxLength=r.maximum??null,Xt(e,"_ZodString",{regex(...o){return this.check(Hr(...o))},includes(...o){return this.check(Xr(...o))},startsWith(...o){return this.check(eo(...o))},endsWith(...o){return this.check(to(...o))},min(...o){return this.check(rt(...o))},max(...o){return this.check(qt(...o))},length(...o){return this.check(Qt(...o))},nonempty(...o){return this.check(rt(1,...o))},lowercase(o){return this.check(Jr(o))},uppercase(o){return this.check(Yr(o))},trim(){return this.check(no())},normalize(...o){return this.check(oo(...o))},toLowerCase(){return this.check(io())},toUpperCase(){return this.check(so())},slugify(){return this.check(ao())}})}),ds=g("ZodString",(e,t)=>{dt.init(e,t),ps.init(e,t),e.email=(r)=>e.check(Oi(fs,r)),e.url=(r)=>e.check(Kr(_o,r)),e.jwt=(r)=>e.check(Ji(Ps,r)),e.emoji=(r)=>e.check(Ni(ms,r)),e.guid=(r)=>e.check(Gr(go,r)),e.uuid=(r)=>e.check(Ii(ze,r)),e.uuidv4=(r)=>e.check(Bi(ze,r)),e.uuidv6=(r)=>e.check(zi(ze,r)),e.uuidv7=(r)=>e.check(Di(ze,r)),e.nanoid=(r)=>e.check(Li(hs,r)),e.guid=(r)=>e.check(Gr(go,r)),e.cuid=(r)=>e.check(Vi(gs,r)),e.cuid2=(r)=>e.check(Ui(ys,r)),e.ulid=(r)=>e.check(Mi(bs,r)),e.base64=(r)=>e.check(Gi($s,r)),e.base64url=(r)=>e.check(Ki(As,r)),e.xid=(r)=>e.check(Fi(_s,r)),e.ksuid=(r)=>e.check(ji(ws,r)),e.ipv4=(r)=>e.check(Zi(vs,r)),e.ipv6=(r)=>e.check(qi(xs,r)),e.cidrv4=(r)=>e.check(Qi(Es,r)),e.cidrv6=(r)=>e.check(Wi(Ss,r)),e.e164=(r)=>e.check(Hi(ks,r)),e.datetime=(r)=>e.check(os(r)),e.date=(r)=>e.check(ns(r)),e.time=(r)=>e.check(is(r)),e.duration=(r)=>e.check(ss(r))});L=g("ZodStringFormat",(e,t)=>{N.init(e,t),ps.init(e,t)}),fs=g("ZodEmail",(e,t)=>{Du.init(e,t),L.init(e,t)});go=g("ZodGUID",(e,t)=>{Bu.init(e,t),L.init(e,t)});ze=g("ZodUUID",(e,t)=>{zu.init(e,t),L.init(e,t)});_o=g("ZodURL",(e,t)=>{Nu.init(e,t),L.init(e,t)});ms=g("ZodEmoji",(e,t)=>{Lu.init(e,t),L.init(e,t)});hs=g("ZodNanoID",(e,t)=>{Vu.init(e,t),L.init(e,t)});gs=g("ZodCUID",(e,t)=>{Uu.init(e,t),L.init(e,t)});ys=g("ZodCUID2",(e,t)=>{Mu.init(e,t),L.init(e,t)});bs=g("ZodULID",(e,t)=>{Fu.init(e,t),L.init(e,t)});_s=g("ZodXID",(e,t)=>{ju.init(e,t),L.init(e,t)});ws=g("ZodKSUID",(e,t)=>{Zu.init(e,t),L.init(e,t)});vs=g("ZodIPv4",(e,t)=>{Ku.init(e,t),L.init(e,t)});Ud=g("ZodMAC",(e,t)=>{Ju.init(e,t),L.init(e,t)});xs=g("ZodIPv6",(e,t)=>{Hu.init(e,t),L.init(e,t)});Es=g("ZodCIDRv4",(e,t)=>{Yu.init(e,t),L.init(e,t)});Ss=g("ZodCIDRv6",(e,t)=>{Xu.init(e,t),L.init(e,t)});$s=g("ZodBase64",(e,t)=>{tl.init(e,t),L.init(e,t)});As=g("ZodBase64URL",(e,t)=>{rl.init(e,t),L.init(e,t)});ks=g("ZodE164",(e,t)=>{ol.init(e,t),L.init(e,t)});Ps=g("ZodJWT",(e,t)=>{nl.init(e,t),L.init(e,t)});er=g("ZodCustomStringFormat",(e,t)=>{il.init(e,t),L.init(e,t)});Cs=g("ZodNumber",(e,t)=>{Si.init(e,t),O.init(e,t),e._zod.processJSONSchema=(o,n,i)=>Np(e,o,n,i),Xt(e,"ZodNumber",{gt(o,n){return this.check(Ue(o,n))},gte(o,n){return this.check(ce(o,n))},min(o,n){return this.check(ce(o,n))},lt(o,n){return this.check(Ve(o,n))},lte(o,n){return this.check(_e(o,n))},max(o,n){return this.check(_e(o,n))},int(o){return this.check(us(o))},safe(o){return this.check(us(o))},positive(o){return this.check(Ue(0,o))},nonnegative(o){return this.check(ce(0,o))},negative(o){return this.check(Ve(0,o))},nonpositive(o){return this.check(_e(0,o))},multipleOf(o,n){return this.check(ft(o,n))},step(o,n){return this.check(ft(o,n))},finite(){return this}});let r=e._zod.bag;e.minValue=Math.max(r.minimum??Number.NEGATIVE_INFINITY,r.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(r.maximum??Number.POSITIVE_INFINITY,r.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(r.format??"").includes("int")||Number.isSafeInteger(r.multipleOf??0.5),e.isFinite=!0,e.format=r.format??null});gt=g("ZodNumberFormat",(e,t)=>{sl.init(e,t),Cs.init(e,t)});Rs=g("ZodBoolean",(e,t)=>{qr.init(e,t),O.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Lp(e,r,o,n)});Ts=g("ZodBigInt",(e,t)=>{$i.init(e,t),O.init(e,t),e._zod.processJSONSchema=(o,n,i)=>Vp(e,o,n,i),e.gte=(o,n)=>e.check(ce(o,n)),e.min=(o,n)=>e.check(ce(o,n)),e.gt=(o,n)=>e.check(Ue(o,n)),e.gte=(o,n)=>e.check(ce(o,n)),e.min=(o,n)=>e.check(ce(o,n)),e.lt=(o,n)=>e.check(Ve(o,n)),e.lte=(o,n)=>e.check(_e(o,n)),e.max=(o,n)=>e.check(_e(o,n)),e.positive=(o)=>e.check(Ue(BigInt(0),o)),e.negative=(o)=>e.check(Ve(BigInt(0),o)),e.nonpositive=(o)=>e.check(_e(BigInt(0),o)),e.nonnegative=(o)=>e.check(ce(BigInt(0),o)),e.multipleOf=(o,n)=>e.check(ft(o,n));let r=e._zod.bag;e.minValue=r.minimum??null,e.maxValue=r.maximum??null,e.format=r.format??null});Os=g("ZodBigIntFormat",(e,t)=>{al.init(e,t),Ts.init(e,t)});jd=g("ZodSymbol",(e,t)=>{cl.init(e,t),O.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Up(e,r,o,n)});Zd=g("ZodUndefined",(e,t)=>{ul.init(e,t),O.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Fp(e,r,o,n)});qd=g("ZodNull",(e,t)=>{ll.init(e,t),O.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Mp(e,r,o,n)});Wd=g("ZodAny",(e,t)=>{pl.init(e,t),O.init(e,t),e._zod.processJSONSchema=(r,o,n)=>qp(e,r,o,n)});Gd=g("ZodUnknown",(e,t)=>{dl.init(e,t),O.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Qp(e,r,o,n)});Kd=g("ZodNever",(e,t)=>{fl.init(e,t),O.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Zp(e,r,o,n)});Hd=g("ZodVoid",(e,t)=>{ml.init(e,t),O.init(e,t),e._zod.processJSONSchema=(r,o,n)=>jp(e,r,o,n)});Jd=g("ZodDate",(e,t)=>{hl.init(e,t),O.init(e,t),e._zod.processJSONSchema=(o,n,i)=>Wp(e,o,n,i),e.min=(o,n)=>e.check(ce(o,n)),e.max=(o,n)=>e.check(_e(o,n));let r=e._zod.bag;e.minDate=r.minimum?new Date(r.minimum):null,e.maxDate=r.maximum?new Date(r.maximum):null});Yd=g("ZodArray",(e,t)=>{gl.init(e,t),O.init(e,t),e._zod.processJSONSchema=(r,o,n)=>id(e,r,o,n),e.element=t.element,Xt(e,"ZodArray",{min(r,o){return this.check(rt(r,o))},nonempty(r){return this.check(rt(1,r))},max(r,o){return this.check(qt(r,o))},length(r,o){return this.check(Qt(r,o))},unwrap(){return this.element}})});vo=g("ZodObject",(e,t)=>{_l.init(e,t),O.init(e,t),e._zod.processJSONSchema=(r,o,n)=>sd(e,r,o,n),I(e,"shape",()=>t.shape),Xt(e,"ZodObject",{keyof(){return zs(Object.keys(this._zod.def.shape))},catchall(r){return this.clone({...this._zod.def,catchall:r})},passthrough(){return this.clone({...this._zod.def,catchall:ht()})},loose(){return this.clone({...this._zod.def,catchall:ht()})},strict(){return this.clone({...this._zod.def,catchall:Is()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(r){return Rb(this,r)},safeExtend(r){return Tb(this,r)},merge(r){return Ob(this,r)},pick(r){return Pb(this,r)},omit(r){return Cb(this,r)},partial(...r){return Ib(Ns,this,r[0])},required(...r){return Bb(Ls,this,r[0])}})});xo=g("ZodUnion",(e,t)=>{Qr.init(e,t),O.init(e,t),e._zod.processJSONSchema=(r,o,n)=>ts(e,r,o,n),e.options=t.options});Xd=g("ZodXor",(e,t)=>{xo.init(e,t),wl.init(e,t),e._zod.processJSONSchema=(r,o,n)=>ts(e,r,o,n),e.options=t.options});ef=g("ZodDiscriminatedUnion",(e,t)=>{xo.init(e,t),vl.init(e,t)});tf=g("ZodIntersection",(e,t)=>{xl.init(e,t),O.init(e,t),e._zod.processJSONSchema=(r,o,n)=>ad(e,r,o,n)});of=g("ZodTuple",(e,t)=>{Ai.init(e,t),O.init(e,t),e._zod.processJSONSchema=(r,o,n)=>cd(e,r,o,n),e.rest=(r)=>e.clone({...e._zod.def,rest:r})});Jt=g("ZodRecord",(e,t)=>{El.init(e,t),O.init(e,t),e._zod.processJSONSchema=(r,o,n)=>ud(e,r,o,n),e.keyType=t.keyType,e.valueType=t.valueType});af=g("ZodMap",(e,t)=>{Sl.init(e,t),O.init(e,t),e._zod.processJSONSchema=(r,o,n)=>od(e,r,o,n),e.keyType=t.keyType,e.valueType=t.valueType,e.min=(...r)=>e.check(Me(...r)),e.nonempty=(r)=>e.check(Me(1,r)),e.max=(...r)=>e.check(mt(...r)),e.size=(...r)=>e.check(Zt(...r))});cf=g("ZodSet",(e,t)=>{$l.init(e,t),O.init(e,t),e._zod.processJSONSchema=(r,o,n)=>nd(e,r,o,n),e.min=(...r)=>e.check(Me(...r)),e.nonempty=(r)=>e.check(Me(1,r)),e.max=(...r)=>e.check(mt(...r)),e.size=(...r)=>e.check(Zt(...r))});Yt=g("ZodEnum",(e,t)=>{Al.init(e,t),O.init(e,t),e._zod.processJSONSchema=(o,n,i)=>Gp(e,o,n,i),e.enum=t.entries,e.options=Object.values(t.entries);let r=new Set(Object.keys(t.entries));e.extract=(o,n)=>{let i={};for(let s of o)if(r.has(s))i[s]=t.entries[s];else throw Error(`Key ${s} not found in enum`);return new Yt({...t,checks:[],...w(n),entries:i})},e.exclude=(o,n)=>{let i={...t.entries};for(let s of o)if(r.has(s))delete i[s];else throw Error(`Key ${s} not found in enum`);return new Yt({...t,checks:[],...w(n),entries:i})}});uf=g("ZodLiteral",(e,t)=>{kl.init(e,t),O.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Kp(e,r,o,n),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});lf=g("ZodFile",(e,t)=>{Pl.init(e,t),O.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Yp(e,r,o,n),e.min=(r,o)=>e.check(Me(r,o)),e.max=(r,o)=>e.check(mt(r,o)),e.mime=(r,o)=>e.check(ro(Array.isArray(r)?r:[r],o))});pf=g("ZodTransform",(e,t)=>{Cl.init(e,t),O.init(e,t),e._zod.processJSONSchema=(r,o,n)=>rd(e,r,o,n),e._zod.parse=(r,o)=>{if(o.direction==="backward")throw new lt(e.constructor.name);r.addIssue=(i)=>{if(typeof i==="string")r.issues.push(Xe(i,r.value,t));else{let s=i;if(s.fatal)s.continue=!1;s.code??(s.code="custom"),s.input??(s.input=r.value),s.inst??(s.inst=e),r.issues.push(Xe(s))}};let n=t.transform(r.value,r);if(n instanceof Promise)return n.then((i)=>(r.value=i,r.fallback=!0,r));return r.value=n,r.fallback=!0,r}});Ns=g("ZodOptional",(e,t)=>{ki.init(e,t),O.init(e,t),e._zod.processJSONSchema=(r,o,n)=>rs(e,r,o,n),e.unwrap=()=>e._zod.def.innerType});df=g("ZodExactOptional",(e,t)=>{Rl.init(e,t),O.init(e,t),e._zod.processJSONSchema=(r,o,n)=>rs(e,r,o,n),e.unwrap=()=>e._zod.def.innerType});mf=g("ZodNullable",(e,t)=>{Tl.init(e,t),O.init(e,t),e._zod.processJSONSchema=(r,o,n)=>ld(e,r,o,n),e.unwrap=()=>e._zod.def.innerType});hf=g("ZodDefault",(e,t)=>{Ol.init(e,t),O.init(e,t),e._zod.processJSONSchema=(r,o,n)=>dd(e,r,o,n),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});yf=g("ZodPrefault",(e,t)=>{Il.init(e,t),O.init(e,t),e._zod.processJSONSchema=(r,o,n)=>fd(e,r,o,n),e.unwrap=()=>e._zod.def.innerType});Ls=g("ZodNonOptional",(e,t)=>{Bl.init(e,t),O.init(e,t),e._zod.processJSONSchema=(r,o,n)=>pd(e,r,o,n),e.unwrap=()=>e._zod.def.innerType});wf=g("ZodSuccess",(e,t)=>{zl.init(e,t),O.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Xp(e,r,o,n),e.unwrap=()=>e._zod.def.innerType});vf=g("ZodCatch",(e,t)=>{Dl.init(e,t),O.init(e,t),e._zod.processJSONSchema=(r,o,n)=>md(e,r,o,n),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});Ef=g("ZodNaN",(e,t)=>{Nl.init(e,t),O.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Hp(e,r,o,n)});Eo=g("ZodPipe",(e,t)=>{Pi.init(e,t),O.init(e,t),e._zod.processJSONSchema=(r,o,n)=>hd(e,r,o,n),e.in=t.in,e.out=t.out});So=g("ZodCodec",(e,t)=>{Eo.init(e,t),Wr.init(e,t)});Sf=g("ZodPreprocess",(e,t)=>{Eo.init(e,t),Ll.init(e,t)}),$f=g("ZodReadonly",(e,t)=>{Vl.init(e,t),O.init(e,t),e._zod.processJSONSchema=(r,o,n)=>gd(e,r,o,n),e.unwrap=()=>e._zod.def.innerType});kf=g("ZodTemplateLiteral",(e,t)=>{Ul.init(e,t),O.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Jp(e,r,o,n)});Pf=g("ZodLazy",(e,t)=>{jl.init(e,t),O.init(e,t),e._zod.processJSONSchema=(r,o,n)=>bd(e,r,o,n),e.unwrap=()=>e._zod.def.getter()});Rf=g("ZodPromise",(e,t)=>{Fl.init(e,t),O.init(e,t),e._zod.processJSONSchema=(r,o,n)=>yd(e,r,o,n),e.unwrap=()=>e._zod.def.innerType});Tf=g("ZodFunction",(e,t)=>{Ml.init(e,t),O.init(e,t),e._zod.processJSONSchema=(r,o,n)=>td(e,r,o,n)});$o=g("ZodCustom",(e,t)=>{Zl.init(e,t),O.init(e,t),e._zod.processJSONSchema=(r,o,n)=>ed(e,r,o,n)});Pw=Tp,Cw=Op});var Bf;var zf=_(()=>{(function(e){})(Bf||(Bf={}))});function zw(e,t){let r=e.$schema;if(r==="https://json-schema.org/draft/2020-12/schema")return"draft-2020-12";if(r==="http://json-schema.org/draft-07/schema#")return"draft-7";if(r==="http://json-schema.org/draft-04/schema#")return"draft-4";return t??"draft-2020-12"}function Dw(e,t){if(!e.startsWith("#"))throw Error("External $ref is not supported, only local refs (#/...) are allowed");let r=e.slice(1).split("/").filter(Boolean);if(r.length===0)return t.rootSchema;let o=t.version==="draft-2020-12"?"$defs":"definitions";if(r[0]===o){let n=r[1];if(!n||!t.defs[n])throw Error(`Reference not found: ${e}`);return t.defs[n]}throw Error(`Reference not found: ${e}`)}function Df(e,t){if(e.not!==void 0){if(typeof e.not==="object"&&Object.keys(e.not).length===0)return v.never();throw Error("not is not supported in Zod (except { not: {} } for never)")}if(e.unevaluatedItems!==void 0)throw Error("unevaluatedItems is not supported");if(e.unevaluatedProperties!==void 0)throw Error("unevaluatedProperties is not supported");if(e.if!==void 0||e.then!==void 0||e.else!==void 0)throw Error("Conditional schemas (if/then/else) are not supported");if(e.dependentSchemas!==void 0||e.dependentRequired!==void 0)throw Error("dependentSchemas and dependentRequired are not supported");if(e.$ref){let n=e.$ref;if(t.refs.has(n))return t.refs.get(n);if(t.processing.has(n))return v.lazy(()=>{if(!t.refs.has(n))throw Error(`Circular reference not resolved: ${n}`);return t.refs.get(n)});t.processing.add(n);let i=Dw(n,t),s=Y(i,t);return t.refs.set(n,s),t.processing.delete(n),s}if(e.enum!==void 0){let n=e.enum;if(t.version==="openapi-3.0"&&e.nullable===!0&&n.length===1&&n[0]===null)return v.null();if(n.length===0)return v.never();if(n.length===1)return v.literal(n[0]);if(n.every((s)=>typeof s==="string"))return v.enum(n);let i=n.map((s)=>v.literal(s));if(i.length<2)return i[0];return v.union([i[0],i[1],...i.slice(2)])}if(e.const!==void 0)return v.literal(e.const);let r=e.type;if(Array.isArray(r)){let n=r.map((i)=>{let s={...e,type:i};return Df(s,t)});if(n.length===0)return v.never();if(n.length===1)return n[0];return v.union(n)}if(!r)return v.any();let o;switch(r){case"string":{let n=v.string();if(e.format){let i=e.format;if(i==="email")n=n.check(v.email());else if(i==="uri"||i==="uri-reference")n=n.check(v.url());else if(i==="uuid"||i==="guid")n=n.check(v.uuid());else if(i==="date-time")n=n.check(v.iso.datetime());else if(i==="date")n=n.check(v.iso.date());else if(i==="time")n=n.check(v.iso.time());else if(i==="duration")n=n.check(v.iso.duration());else if(i==="ipv4")n=n.check(v.ipv4());else if(i==="ipv6")n=n.check(v.ipv6());else if(i==="mac")n=n.check(v.mac());else if(i==="cidr")n=n.check(v.cidrv4());else if(i==="cidr-v6")n=n.check(v.cidrv6());else if(i==="base64")n=n.check(v.base64());else if(i==="base64url")n=n.check(v.base64url());else if(i==="e164")n=n.check(v.e164());else if(i==="jwt")n=n.check(v.jwt());else if(i==="emoji")n=n.check(v.emoji());else if(i==="nanoid")n=n.check(v.nanoid());else if(i==="cuid")n=n.check(v.cuid());else if(i==="cuid2")n=n.check(v.cuid2());else if(i==="ulid")n=n.check(v.ulid());else if(i==="xid")n=n.check(v.xid());else if(i==="ksuid")n=n.check(v.ksuid())}if(typeof e.minLength==="number")n=n.min(e.minLength);if(typeof e.maxLength==="number")n=n.max(e.maxLength);if(e.pattern)n=n.regex(new RegExp(e.pattern));o=n;break}case"number":case"integer":{let n=r==="integer"?v.number().int():v.number();if(typeof e.minimum==="number")n=n.min(e.minimum);if(typeof e.maximum==="number")n=n.max(e.maximum);if(typeof e.exclusiveMinimum==="number")n=n.gt(e.exclusiveMinimum);else if(e.exclusiveMinimum===!0&&typeof e.minimum==="number")n=n.gt(e.minimum);if(typeof e.exclusiveMaximum==="number")n=n.lt(e.exclusiveMaximum);else if(e.exclusiveMaximum===!0&&typeof e.maximum==="number")n=n.lt(e.maximum);if(typeof e.multipleOf==="number")n=n.multipleOf(e.multipleOf);o=n;break}case"boolean":{o=v.boolean();break}case"null":{o=v.null();break}case"object":{let n={},i=e.properties||{},s=new Set(e.required||[]);for(let[c,u]of Object.entries(i)){let l=Y(u,t);n[c]=s.has(c)?l:l.optional()}if(e.propertyNames){let c=Y(e.propertyNames,t),u=e.additionalProperties&&typeof e.additionalProperties==="object"?Y(e.additionalProperties,t):v.any();if(Object.keys(n).length===0){o=v.record(c,u);break}let l=v.object(n).passthrough(),f=v.looseRecord(c,u);o=v.intersection(l,f);break}if(e.patternProperties){let c=e.patternProperties,u=Object.keys(c),l=[];for(let d of u){let p=Y(c[d],t),m=v.string().regex(new RegExp(d));l.push(v.looseRecord(m,p))}let f=[];if(Object.keys(n).length>0)f.push(v.object(n).passthrough());if(f.push(...l),f.length===0)o=v.object({}).passthrough();else if(f.length===1)o=f[0];else{let d=v.intersection(f[0],f[1]);for(let p=2;p<f.length;p++)d=v.intersection(d,f[p]);o=d}break}let a=v.object(n);if(e.additionalProperties===!1)o=a.strict();else if(typeof e.additionalProperties==="object")o=a.catchall(Y(e.additionalProperties,t));else o=a.passthrough();break}case"array":{let{prefixItems:n,items:i}=e;if(n&&Array.isArray(n)){let s=n.map((c)=>Y(c,t)),a=i&&typeof i==="object"&&!Array.isArray(i)?Y(i,t):void 0;if(a)o=v.tuple(s).rest(a);else o=v.tuple(s);if(typeof e.minItems==="number")o=o.check(v.minLength(e.minItems));if(typeof e.maxItems==="number")o=o.check(v.maxLength(e.maxItems))}else if(Array.isArray(i)){let s=i.map((c)=>Y(c,t)),a=e.additionalItems&&typeof e.additionalItems==="object"?Y(e.additionalItems,t):void 0;if(a)o=v.tuple(s).rest(a);else o=v.tuple(s);if(typeof e.minItems==="number")o=o.check(v.minLength(e.minItems));if(typeof e.maxItems==="number")o=o.check(v.maxLength(e.maxItems))}else if(i!==void 0){let s=Y(i,t),a=v.array(s);if(typeof e.minItems==="number")a=a.min(e.minItems);if(typeof e.maxItems==="number")a=a.max(e.maxItems);o=a}else o=v.array(v.any());break}default:throw Error(`Unsupported type: ${r}`)}return o}function Y(e,t){if(typeof e==="boolean")return e?v.any():v.never();let r=Df(e,t),o=e.type||e.enum!==void 0||e.const!==void 0;if(e.anyOf&&Array.isArray(e.anyOf)){let a=e.anyOf.map((u)=>Y(u,t)),c=v.union(a);r=o?v.intersection(r,c):c}if(e.oneOf&&Array.isArray(e.oneOf)){let a=e.oneOf.map((u)=>Y(u,t)),c=v.xor(a);r=o?v.intersection(r,c):c}if(e.allOf&&Array.isArray(e.allOf))if(e.allOf.length===0)r=o?r:v.any();else{let a=o?r:Y(e.allOf[0],t),c=o?0:1;for(let u=c;u<e.allOf.length;u++)a=v.intersection(a,Y(e.allOf[u],t));r=a}if(e.nullable===!0&&t.version==="openapi-3.0")r=v.nullable(r);if(e.readOnly===!0)r=v.readonly(r);if(e.default!==void 0)r=r.default(e.default);let n={},i=["$id","id","$comment","$anchor","$vocabulary","$dynamicRef","$dynamicAnchor"];for(let a of i)if(a in e)n[a]=e[a];let s=["contentEncoding","contentMediaType","contentSchema"];for(let a of s)if(a in e)n[a]=e[a];for(let a of Object.keys(e))if(!Bw.has(a))n[a]=e[a];if(Object.keys(n).length>0)t.registry.add(r,n);if(e.description)r=r.describe(e.description);return r}function Nf(e,t){if(typeof e==="boolean")return e?v.any():v.never();let r;try{r=JSON.parse(JSON.stringify(e))}catch{throw Error("fromJSONSchema input is not valid JSON (possibly cyclic); use $defs/$ref for recursive schemas")}let o=zw(r,t?.defaultTarget),n=r.$defs||r.definitions||{},i={version:o,defs:n,refs:new Map,processing:new Set,rootSchema:r,registry:t?.registry??te};return Y(r,i)}var v,Bw;var Lf=_(()=>{jt();lo();po();mo();v={...fo,...uo,iso:Ht},Bw=new Set(["$schema","$ref","$defs","definitions","$id","id","$comment","$anchor","$vocabulary","$dynamicRef","$dynamicAnchor","type","enum","const","anyOf","oneOf","allOf","not","properties","required","additionalProperties","patternProperties","propertyNames","minProperties","maxProperties","items","prefixItems","additionalItems","minItems","maxItems","uniqueItems","contains","minContains","maxContains","minLength","maxLength","pattern","format","minimum","maximum","exclusiveMinimum","exclusiveMaximum","multipleOf","description","default","contentEncoding","contentMediaType","contentSchema","unevaluatedItems","unevaluatedProperties","if","then","else","dependentSchemas","dependentRequired","nullable","readOnly"])});var Vf=()=>{};var Us=_(()=>{we();we();ql();we();Lf();Ti();po();Vf();mo();lo();as();cs();zf();H(Ri())});var Ms=_(()=>{Us();Us()});var Mf="registry.neko-piranha.ts.net",Ao="https://kuber.astrxl.dev/api/v2",X;var Fe=_(()=>{X={"app.kubernetes.io/managed-by":"kuber"}});import{chmod as Ff,mkdir as Vw,readFile as Uw,rename as Mw,rm as js,writeFile as Fw}from"fs/promises";import{randomUUID as jw}from"crypto";import{tmpdir as Qf}from"os";import{dirname as jf,join as ko}from"path";function Zs(){let e=process.env.XDG_RUNTIME_DIR??ko(Qf(),`kuber-${process.getuid?.()??"user"}`);return ko(e,"kuber","session.json")}function qs(){let e=process.env.XDG_CONFIG_HOME??ko(process.env.HOME??Qf(),".config");return ko(e,"kuber","session.json")}function Zf(e){return e?qs():Zs()}function Zw(e){if(!e||typeof e!=="object")return!1;let t=e;return typeof t.token==="string"&&typeof t.expiresAt==="string"&&Boolean(t.user)&&typeof t.user?.username==="string"&&Array.isArray(t.user.roles)&&t.user.roles.every((r)=>typeof r==="string")}async function qf(e){try{let t=JSON.parse(await Uw(e,"utf8"));if(!Zw(t))return;if(Date.parse(t.expiresAt)<=Date.now()){await js(e,{force:!0});return}return t}catch(t){if(t&&typeof t==="object"&&"code"in t&&t.code==="ENOENT")return;if(t instanceof SyntaxError)return;throw t}}async function yt(){let e=Zs(),t=qs();if(je?.runtimePath===e&&je.persistentPath===t&&(je.expiresAt===0||je.expiresAt>Date.now()))return je.value;let r=await qf(e)??await qf(t);return je={runtimePath:e,persistentPath:t,value:r,expiresAt:r?Date.parse(r.expiresAt):0},r}async function Wf(e,t){let r=Zf(t);await Vw(jf(r),{recursive:!0,mode:448}),await Ff(jf(r),448);let o=`${r}.${jw()}.tmp`;return await Fw(o,`${JSON.stringify(e,null,2)}
|
|
72
72
|
`,{flag:"wx",mode:384}),await Mw(o,r),await Ff(r,384),await js(Zf(!t),{force:!0}),je=void 0,r}async function Qs(){await Promise.all([Zs(),qs()].map((e)=>js(e,{force:!0}))),je=void 0}var je;var Po=()=>{};function Gf(e,t=qw){if(!Number.isFinite(t)||t<0)throw RangeError("timeoutMs must be a finite non-negative number");let r=new AbortController,o=()=>r.abort(e?.reason);if(e?.aborted)o();else e?.addEventListener("abort",o,{once:!0});let n=t===0?void 0:setTimeout(()=>{r.abort(new DOMException(`API request timed out after ${t}ms`,"TimeoutError"))},t);return{signal:r.signal,clear:()=>{if(n!==void 0)clearTimeout(n);e?.removeEventListener("abort",o)}}}function Qw(e){return e instanceof ArrayBuffer||ArrayBuffer.isView(e)||typeof Blob<"u"&&e instanceof Blob||typeof ReadableStream<"u"&&e instanceof ReadableStream}async function Ww(e,t){let r=new Headers(e.headers);if(!r.has("accept"))r.set("accept","application/json");if(Object.hasOwn(e,"json"))r.set("content-type","application/json");else if(e.body!==void 0&&e.body!==null&&!r.has("content-type")&&!Qw(e.body))r.set("content-type","application/json");if(t.uploadOffset!==void 0){if(!Number.isSafeInteger(t.uploadOffset)||t.uploadOffset<0)throw RangeError("uploadOffset must be a non-negative safe integer");r.set("upload-offset",String(t.uploadOffset))}if(t.authenticated!==!1){let o=t.session??await yt();if(!o)throw Error("Not logged in. Run kuber login first.");r.set("authorization",`Bearer ${o.token}`)}return r}async function Gw(e){let t;try{let r=JSON.parse(await e.text());if(r&&typeof r==="object")t=r}catch{}return{...t,status:e.status,title:t?.title||e.statusText||`HTTP ${e.status}`,code:t?.code||`HTTP_${e.status}`,requestId:t?.requestId??e.headers.get("x-request-id")??void 0,operationId:t?.operationId??e.headers.get("x-operation-id")??void 0}}async function Kf(e){if(e.ok)return;let t=await Gw(e);throw new xe(t.detail||t.message||t.title,e.status,t)}async function Hf(e,t,r,o){let n=await Ww(t,r),{json:i,...s}=t,a=Object.hasOwn(t,"json")?JSON.stringify(i):t.body;return fetch(`${r.baseUrl??Ao}${e}`,{...s,body:a,headers:n,signal:o})}async function C(e,t={},r={}){let o=Gf(t.signal,r.timeoutMs);try{let n=await Hf(e,t,r,o.signal);if(await Kf(n),t.method?.toUpperCase()==="HEAD"||n.status===204||n.status===205||n.body===null)return;let i=await n.text();if(!i.trim())return;return JSON.parse(i)}finally{o.clear()}}async function*Ws(e,t={},r={}){let o=Gf(t.signal,r.timeoutMs);try{let n=new Headers(t.headers);n.set("accept","application/x-ndjson");let i=await Hf(e,{...t,headers:n},r,o.signal);if(await Kf(i),!i.body)return;let s=i.body.getReader();try{let a=new TextDecoder,c="";for(;;){let{done:l,value:f}=await s.read();c+=a.decode(f,{stream:!l});let d=0,p=c.indexOf(`
|
|
@@ -76,7 +76,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
76
76
|
`)[0]?.split(/ /g);for(let n=0;n<o.length;n++){let i=o[n];if(r){let s=Se(i);if(Se(r)+s>=e)break}r+=(n>0?" ":"")+i}return r}function im(e,t){let r="",o=[...t.split(`
|
|
77
77
|
`)[0].matchAll(new RegExp(`(?:${Hs})+|.`,"gu"))].map(([n])=>n);for(let n of o){if(r){let i=Se(n);if(Se(r)+i>e)break}r+=n}return r}var Co=_(()=>{Js()});var le;var Ro=_(()=>{le=class le extends Array{options={};static from(e){let t=new this(...e);if(e instanceof le)t.options={...e.options};return t}clone(){let e=new le(...this.map((t)=>t instanceof ie?t.clone():t));return e.options={...this.options},e}border(e=!0,t=!0){if(t||typeof this.options.border>"u")this.options.border=e;return this}align(e,t=!0){if(t||typeof this.options.align>"u")this.options.align=e;return this}getBorder(){return this.options.border===!0}hasBorder(){return this.getBorder()||this.some((e)=>e instanceof ie&&e.getBorder())}getAlign(){return this.options.align??"left"}}});class Ys{table;options;constructor(e,t){this.table=e,this.options=t}toString(){let e=this.createLayout();return e.rows.length?this.renderRows(e):""}createLayout(){Object.keys(this.options.chars).forEach((u)=>{if(typeof this.options.chars[u]!=="string")this.options.chars[u]=""});let e=this.table.getBorder()||this.table.hasBodyBorder(),t=this.table.hasHeaderBorder(),r=t||e,o=this.#t(),n=Math.max(...o.map((u)=>u.length));for(let u=0;u<o.length;u++){let l=o[u],f=l.length;if(f<n){let d=n-f;for(let p=0;p<d;p++)l.push(this.createCell(null,l,u,f+p))}}let{padding:i,width:s,minColWidth:a,maxColWidth:c}=this.computeColumnDimensions(n,o);if(isFinite(this.options.maxWidth)){let u=r?$e(i)*2+(n+1):$e(i.slice(0,-1)),l=this.options.maxWidth-u;if($e(s)>l)this.applyFlexShrink(s,a,l);if($e(s)<l)this.applyFlexGrow(s,c,l)}return{padding:i,width:s,rows:o,columns:n,hasBorder:r,hasBodyBorder:e,hasHeaderBorder:t}}computeColumnDimensions(e,t){let r=[],o=[],n=[],i=[];for(let s=0;s<e;s++){let a=this.options.columns.at(s);n[s]=a?.getMinWidth()??(Array.isArray(this.options.minColWidth)?this.options.minColWidth[s]:this.options.minColWidth)??0,i[s]=a?.getMaxWidth()??(Array.isArray(this.options.maxColWidth)?this.options.maxColWidth[s]:this.options.maxColWidth)??1/0;let c=om(s,t,i[s]);o[s]=Math.min(i[s],Math.max(n[s],c)),r[s]=a?.getPadding()??(Array.isArray(this.options.padding)?this.options.padding[s]:this.options.padding)??0}return{padding:r,width:o,minColWidth:n,maxColWidth:i}}applyFlexShrink(e,t,r){let o=e.map((i,s)=>this.resolveColumnWeight("flexShrink",s)),n=!0;while(n){if(n=!1,$e(e)<=r)break;let i=$e(e)-r,s=$e(e.map((a,c)=>o[c]>0&&a>t[c]?o[c]*a:0));if(s===0)break;for(let a=0;a<e.length;a++)if(o[a]>0&&e[a]>t[a]){let c=Math.max(Math.max(1,t[a]),Math.floor(e[a]*(1-i*o[a]/s)));if(c!==e[a])e[a]=c,n=!0}}}applyFlexGrow(e,t,r){let o=e.map((i,s)=>this.resolveColumnWeight("flexGrow",s)),n=!0;while(n){if(n=!1,$e(e)>=r)break;let i=r-$e(e),s=$e(o.map((a,c)=>e[c]<t[c]?a:0));if(s===0)break;for(let a=0;a<e.length;a++)if(o[a]>0&&e[a]<t[a]){let c=Math.floor(i*o[a]/s),u=Math.min(t[a],e[a]+c);if(u!==e[a])e[a]=u,n=!0}}}resolveColumnWeight(e,t){let r=e==="flexShrink"?"getFlexShrink":"getFlexGrow",o=this.options.columns.at(t)?.[r]()??(Array.isArray(this.options[e])?this.options[e][t]:this.options[e]);return Number.isFinite(o)&&o>0?o:0}#t(){let e=this.table.getHeader(),t=e?[e,...this.table]:this.table.slice();if(t.some((o)=>o.some((n)=>n instanceof ie&&(n.getColSpan()>1||n.getRowSpan()>1))))return this.spanRows(t);return t.map((o,n)=>{let i=this.createRow(o);for(let s=0;s<o.length;s++)i[s]=this.createCell(o[s],i,n,s);return i})}spanRows(e){let t=[],r=1,o=-1;while(!0){if(o++,o===e.length&&t.every((s)=>s===1))break;let n=e[o]=this.createRow(e[o]||[]),i=-1;while(!0){if(i++,i===n.length&&i===t.length&&r===1)break;if(r>1){r--,t[i]=t[i-1],n.splice(i,this.getDeleteCount(e,o,i),n[i-1]);continue}if(t[i]>1){t[i]--,e[o].splice(i,this.getDeleteCount(e,o,i),e[o-1][i]);continue}let s=n[i]=this.createCell(n[i]||null,n,o,i);r=s.getColSpan(),t[i]=s.getRowSpan()}}return e}getDeleteCount(e,t,r){return r<=e[t].length-1&&typeof e[t][r]>"u"?1:0}createRow(e){return le.from(e).border(this.table.getBorder(),!1).align(this.table.getAlign(),!1)}createCell(e,t,r,o){let n=this.options.columns.at(o),i=this.isHeaderRow(r);return ie.from(e??"").border((i?null:n?.getBorder())??t.getBorder(),!1).align((i?null:n?.getAlign())??t.getAlign(),!1)}isHeaderRow(e){return e===0&&this.table.getHeader()!==void 0}renderRows(e){let t="",r=Array(e.columns).fill(1);for(let o=0;o<e.rows.length;o++)t+=this.renderRow(r,o,e);return t.slice(0,-1)}renderRow(e,t,r,o){let n=r.rows[t],i=r.rows[t-1],s=r.rows[t+1],a="",c=1;if(!o&&t===0&&n.hasBorder())a+=this.renderBorderRow(void 0,n,e,r);let u=!1;a+=" ".repeat(this.options.indent||0);for(let l=0;l<r.columns;l++){if(c>1){c--,e[l]=e[l-1];continue}if(a+=this.renderCell(l,n,r),e[l]>1){if(!o)e[l]--}else if(!i||i[l]!==n[l])e[l]=n[l].getRowSpan();if(c=n[l].getColSpan(),e[l]===1&&n[l].length)u=!0}if(r.columns>0){if(n[r.columns-1].getBorder())a+=this.options.chars.right;else if(r.hasBorder)a+=" "}if(a+=`
|
|
78
78
|
`,u)return a+this.renderRow(e,t,r,u);if(r.rows.length>1&&(t===0&&r.hasHeaderBorder||t<r.rows.length-1&&r.hasBodyBorder))a+=this.renderBorderRow(n,s,e,r);if(t===r.rows.length-1&&n.hasBorder())a+=this.renderBorderRow(n,void 0,e,r);return a}renderCell(e,t,r,o){let n="",i=t[e-1],s=t[e];if(!o){if(e===0){if(s.getBorder())n+=this.options.chars.left;else if(r.hasBorder)n+=" "}else if(s.getBorder()||i?.getBorder())n+=this.options.chars.middle;else if(r.hasBorder)n+=" "}let a=r.width[e],c=s.getColSpan();if(c>1){for(let f=1;f<c;f++)if(a+=r.width[e+f]+r.padding[e+f],r.hasBorder)a+=r.padding[e+f]+1}let{current:u,next:l}=this.renderCellValue(s,a);if(t[e].setValue(l),r.hasBorder)n+=" ".repeat(r.padding[e]);if(n+=u,r.hasBorder||e<r.columns-1)n+=" ".repeat(r.padding[e]);return n}renderCellValue(e,t){if(t<=0)return{current:"",next:""};let r=Math.min(t,Se(e.toString())),o=or(r,e.toString()),n=Se(o)>r;if(n)o=im(r,o);let i=e.toString().slice(o.length+(n?0:1));o=e.unclosedAnsiRuns+o;let{currentSuffix:s,nextPrefix:a}=nm(o);o+=s,e.unclosedAnsiRuns=a;let c=t-Se(o),u=e.getAlign(),l;if(c===0)l=o;else if(u==="left")l=o+" ".repeat(c);else if(u==="center")l=" ".repeat(Math.floor(c/2))+o+" ".repeat(Math.ceil(c/2));else if(u==="right")l=" ".repeat(c)+o;else throw Error("Unknown direction: "+u);return{current:l,next:i}}renderBorderRow(e,t,r,o){let n="",i=1;for(let s=0;s<o.columns;s++){if(r[s]>1){if(!t)throw Error("invalid layout");if(i>1){i--;continue}}n+=this.renderBorderCell(s,e,t,r,o),i=t?.[s].getColSpan()??1}return n.length?" ".repeat(this.options.indent)+n+`
|
|
79
|
-
`:""}renderBorderCell(e,t,r,o,n){let i=t?.[e-1],s=r?.[e-1],a=t?.[e],c=r?.[e],u=!!i?.getBorder(),l=!!s?.getBorder(),f=!!a?.getBorder(),d=!!c?.getBorder(),p=(b)=>(b?.getColSpan()??1)>1,m=(b)=>(b?.getRowSpan()??1)>1,h="";if(e===0)if(o[e]>1)if(f)h+=this.options.chars.left;else h+=" ";else if(f&&d)h+=this.options.chars.leftMid;else if(f)h+=this.options.chars.bottomLeft;else if(d)h+=this.options.chars.topLeft;else h+=" ";else if(e<n.columns)if(u&&d||f&&l){let b=p(i),P=p(s),E=p(a),A=p(c),x=m(i),k=m(s),T=m(a),B=m(c),W=u&&d&&f&&l,Te=x&&T&&k&&B,Ne=b&&E&&P&&A;if(Te&&W)h+=this.options.chars.middle;else if(Ne&&W&&i===a&&s===c)h+=this.options.chars.mid;else if(b&&E&&i===a)h+=this.options.chars.topMid;else if(P&&A&&s===c)h+=this.options.chars.bottomMid;else if(x&&k&&i===s)h+=this.options.chars.leftMid;else if(T&&B&&a===c)h+=this.options.chars.rightMid;else h+=this.options.chars.midMid}else if(u&&f)if(p(i)&&p(a)&&i===a)h+=this.options.chars.bottom;else h+=this.options.chars.bottomMid;else if(f&&d)if(o[e]>1)h+=this.options.chars.left;else h+=this.options.chars.leftMid;else if(d&&l)if(p(s)&&p(c)&&s===c)h+=this.options.chars.top;else h+=this.options.chars.topMid;else if(u&&l)if(m(i)&&i===s)h+=this.options.chars.right;else h+=this.options.chars.rightMid;else if(u)h+=this.options.chars.bottomRight;else if(f)h+=this.options.chars.bottomLeft;else if(l)h+=this.options.chars.topRight;else if(d)h+=this.options.chars.topLeft;else h+=" ";let y=n.padding[e]+n.width[e]+n.padding[e];if(o[e]>1&&r){if(h+=this.renderCell(e,r,n,!0),r[e]===r[r.length-1]){if(f)h+=this.options.chars.right;else h+=" ";return h}}else if(f&&d)h+=this.options.chars.mid.repeat(y);else if(f)h+=this.options.chars.bottom.repeat(y);else if(d)h+=this.options.chars.top.repeat(y);else h+=" ".repeat(y);if(e===n.columns-1)if(f&&d)h+=this.options.chars.rightMid;else if(f)h+=this.options.chars.bottomRight;else if(d)h+=this.options.chars.topRight;else h+=" ";return h}}var $e=(e)=>e.reduce((t,r)=>t+r,0);var sm=_(()=>{Co();Ro();Js()});var Ze;var am=_(()=>{Ks();sm();Ro();Ze=class Ze extends Array{static _chars={...Gs};options={indent:0,border:!1,maxColWidth:1/0,minColWidth:0,padding:1,maxWidth:1/0,flexShrink:0,flexGrow:0,chars:{...Ze._chars},columns:[]};headerRow;static from(e){let t=new this(...e);if(e instanceof Ze)t.options={...e.options},t.headerRow=e.headerRow?le.from(e.headerRow):void 0;return t}static fromJson(e){return new this().fromJson(e)}static chars(e){return Object.assign(this._chars,e),this}static render(e){Ze.from(e).render()}fromJson(e){return this.header(Object.keys(e[0])),this.body(e.map((t)=>Object.values(t))),this}columns(e){return this.options.columns=e.map((t)=>t instanceof Ee?t:Ee.from(t)),this}column(e,t){if(t instanceof Ee)this.options.columns[e]=t;else if(this.options.columns[e])this.options.columns[e].options(t);else this.options.columns[e]=Ee.from(t);return this}header(e){return this.headerRow=e instanceof le?e:le.from(e),this}body(e){return this.length=0,this.push(...e),this}clone(){let e=new Ze(...this.map((t)=>t instanceof le?t.clone():le.from(t).clone()));return e.options={...this.options},e.headerRow=this.headerRow?.clone(),e}toString(){return new Ys(this,this.options).toString()}render(){return console.log(this.toString()),this}maxColWidth(e,t=!0){if(t||typeof this.options.maxColWidth>"u")this.options.maxColWidth=e;return this}minColWidth(e,t=!0){if(t||typeof this.options.minColWidth>"u")this.options.minColWidth=e;return this}maxWidth(e,t=!0){if(t||typeof this.options.maxWidth>"u")this.options.maxWidth=e;return this}flexShrink(e=1,t=!0){if(t||typeof this.options.flexShrink>"u")this.options.flexShrink=e;return this}flexGrow(e=1,t=!0){if(t||typeof this.options.flexGrow>"u")this.options.flexGrow=e;return this}flex(e=1,t=!0){return this.flexGrow(e,t).flexShrink(e,t)}indent(e,t=!0){if(t||typeof this.options.indent>"u")this.options.indent=e;return this}padding(e,t=!0){if(t||typeof this.options.padding>"u")this.options.padding=e;return this}border(e=!0,t=!0){if(t||typeof this.options.border>"u")this.options.border=e;return this}align(e,t=!0){if(t||typeof this.options.align>"u")this.options.align=e;return this}chars(e){return Object.assign(this.options.chars,e),this}getHeader(){return this.headerRow}getBody(){return[...this]}getMaxColWidth(){return this.options.maxColWidth}getMinColWidth(){return this.options.minColWidth}getIndent(){return this.options.indent}getPadding(){return this.options.padding}getBorder(){return this.options.border===!0}hasHeaderBorder(){let e=this.headerRow?.hasBorder();return e===!0||this.getBorder()&&e!==!1}hasBodyBorder(){return this.getBorder()||this.options.columns.some((e)=>e.getBorder())||this.some((e)=>e instanceof le?e.hasBorder():e.some((t)=>t instanceof ie?t.getBorder():!1))}hasBorder(){return this.hasHeaderBorder()||this.hasBodyBorder()}getAlign(){return this.options.align??"left"}getColumns(){return this.options.columns}getColumn(e){return this.options.columns[e]??=new Ee}}});var cm=_(()=>{Ks();Co();Ro();am()});function fe(e){return new Ze(Object.keys(e[0]??{}).map((t)=>t.toUpperCase()),...e.map((t)=>Object.values(t))).toString()}function um(e){if(!e)return;if(Array.isArray(e))return e.map((t)=>{let r=t.indexOf("=");return{name:r===-1?t:t.slice(0,r),value:r===-1?void 0:t.slice(r+1)}});return Object.entries(e).map(([t,r])=>({name:t,value:r===null?void 0:String(r)}))}var ot=_(()=>{cm()});async function ev(e,t=C){let r=e?`/audit?${new URLSearchParams({workspaceId:e})}`:"/audit",o=await t(r);if(o.items.length===0)return"No audit events";return fe(o.items.map((n)=>({timestamp:n.metadata.creationTimestamp,actor:n.spec.actor.username,action:n.spec.action,workspace:n.spec.workspaceId,outcome:n.spec.outcome,operation:n.spec.operationId})))}var tv,rv;var lm=_(()=>{q();G();ot();tv=S({meta:{name:"ls",description:"List audit events"},args:{workspace:{type:"string",alias:"w",description:"Filter by workspace"}},async run({args:e}){console.log(await ev(e.workspace??e._[0]))}}),rv=S({meta:{name:"audit",description:"Inspect the audit log"},subCommands:{ls:tv}})});import{basename as ov,isAbsolute as nv,resolve as pm}from"path";import{pathToFileURL as iv}from"url";function Xs(e,t){if(typeof e!=="string"||e.trim().length===0)throw Error(`${t} must be a non-empty string`);return e.trim()}function cv(e,t){if(!e||typeof e!=="object"||Array.isArray(e))throw Error(`${t} must default export a configuration object`);let r=e;for(let o of["compose","preBuild","postBuild","postRender","postApply"])if(r[o]!==void 0&&typeof r[o]!=="function")throw Error(`${o} in ${t} must be a function`);if(r.project!==void 0)Xs(r.project,"project");if(r.composeFile!==void 0)Xs(r.composeFile,"composeFile");if(r.registry!==void 0)Xs(r.registry,"registry");if(r.rolloutTimeoutMs!==void 0&&(typeof r.rolloutTimeoutMs!=="number"||!Number.isFinite(r.rolloutTimeoutMs)||r.rolloutTimeoutMs<=0))throw Error(`rolloutTimeoutMs in ${t} must be a positive number`);return e}function dm(e){let t,r=[];for(let o=0;o<e.length;o+=1){let n=e[o];if(n==="--"){r.push(...e.slice(o));break}if(n.startsWith("--config=")){let i=n.slice(9);if(!i)throw Error("--config requires a path");if(t)throw Error("--config may only be specified once");t=i;continue}if(n==="--config"){let i=e[o+1];if(!i||i.startsWith("-"))throw Error(`${n} requires a path`);if(t)throw Error("--config may only be specified once");t=i,o+=1;continue}r.push(n)}return{configPath:t,rawArgs:r}}async function fm(e,t){let r=pm(e,t??sv),o=await Bun.file(r).exists();if(!o&&t)throw Error(`Config file cannot be found: ${r}`);let n=o?cv((await import(iv(r).href)).default,r):{},i=n.composeFile?.trim(),s=(n.registry?.trim()??To).replace(/\/+$/,"");if(!s)throw Error(`registry in ${r} cannot be empty`);return{project:n.project?.trim()??ov(e),projectConfigured:n.project!==void 0,composeFile:i?nv(i)?i:pm(e,i):void 0,registry:s,rolloutTimeoutMs:n.rolloutTimeoutMs??av,configFile:o?r:void 0,compose:n.compose,preBuild:n.preBuild,postBuild:n.postBuild,postRender:n.postRender,postApply:n.postApply}}function mm(e,t,r){return{cwd:t,project:e.project,composeFile:r,configFile:e.configFile}}var sv=".kuberrc.ts",To,av=300000;var Oo=_(()=>{Fe();To=Mf});var hm;var gm=_(()=>{hm={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"compose_spec.json",type:"object",title:"Compose Specification",description:"The Compose file is a YAML file defining a multi-containers based application.",properties:{version:{type:"string",deprecated:!0,description:"declared for backward compatibility, ignored. Please remove it."},name:{type:"string",description:"define the Compose project name, until user defines one explicitly."},include:{type:"array",items:{$ref:"#/$defs/include"},description:"compose sub-projects to be included."},services:{type:"object",patternProperties:{"^[a-zA-Z0-9._-]+$":{$ref:"#/$defs/service"}},additionalProperties:!1,description:"The services that will be used by your application."},models:{type:"object",patternProperties:{"^[a-zA-Z0-9._-]+$":{$ref:"#/$defs/model"}},description:"Language models that will be used by your application."},networks:{type:"object",patternProperties:{"^[a-zA-Z0-9._-]+$":{$ref:"#/$defs/network"}},description:"Networks that are shared among multiple services."},volumes:{type:"object",patternProperties:{"^[a-zA-Z0-9._-]+$":{$ref:"#/$defs/volume"}},additionalProperties:!1,description:"Named volumes that are shared among multiple services."},secrets:{type:"object",patternProperties:{"^[a-zA-Z0-9._-]+$":{$ref:"#/$defs/secret"}},additionalProperties:!1,description:"Secrets that are shared among multiple services."},configs:{type:"object",patternProperties:{"^[a-zA-Z0-9._-]+$":{$ref:"#/$defs/config"}},additionalProperties:!1,description:"Configurations that are shared among multiple services."}},patternProperties:{"^x-":{}},additionalProperties:!1,$defs:{service:{type:"object",description:"Configuration for a service.",properties:{develop:{$ref:"#/$defs/development"},deploy:{$ref:"#/$defs/deployment"},annotations:{$ref:"#/$defs/list_or_dict"},attach:{type:["boolean","string"]},build:{description:"Configuration options for building the service's image.",oneOf:[{type:"string",description:"Path to the build context. Can be a relative path or a URL."},{type:"object",properties:{context:{type:"string",description:"Path to the build context. Can be a relative path or a URL."},dockerfile:{type:"string",description:"Name of the Dockerfile to use for building the image."},dockerfile_inline:{type:"string",description:"Inline Dockerfile content to use instead of a Dockerfile from the build context."},entitlements:{type:"array",items:{type:"string"},description:"List of extra privileged entitlements to grant to the build process."},args:{$ref:"#/$defs/list_or_dict",description:"Build-time variables, specified as a map or a list of KEY=VAL pairs."},ssh:{$ref:"#/$defs/list_or_dict",description:"SSH agent socket or keys to expose to the build. Format is either a string or a list of 'default|<id>[=<socket>|<key>[,<key>]]'."},labels:{$ref:"#/$defs/list_or_dict",description:"Labels to apply to the built image."},cache_from:{type:"array",items:{type:"string"},description:"List of sources the image builder should use for cache resolution"},cache_to:{type:"array",items:{type:"string"},description:"Cache destinations for the build cache."},no_cache:{type:["boolean","string"],description:"Do not use cache when building the image."},no_cache_filter:{$ref:"#/$defs/string_or_list",description:"Do not use build cache for the specified stages."},additional_contexts:{$ref:"#/$defs/list_or_dict",description:"Additional build contexts to use, specified as a map of name to context path or URL."},network:{type:"string",description:"Network mode to use for the build. Options include 'default', 'none', 'host', or a network name."},provenance:{type:["string","boolean"],description:"Add a provenance attestation"},sbom:{type:["string","boolean"],description:"Add a SBOM attestation"},pull:{type:["boolean","string"],description:"Always attempt to pull a newer version of the image."},target:{type:"string",description:"Build stage to target in a multi-stage Dockerfile."},shm_size:{type:["integer","string"],description:"Size of /dev/shm for the build container. A string value can use suffix like '2g' for 2 gigabytes."},extra_hosts:{$ref:"#/$defs/extra_hosts",description:"Add hostname mappings for the build container."},isolation:{type:"string",description:"Container isolation technology to use for the build process."},privileged:{type:["boolean","string"],description:"Give extended privileges to the build container."},secrets:{$ref:"#/$defs/service_config_or_secret",description:"Secrets to expose to the build. These are accessible at build-time."},tags:{type:"array",items:{type:"string"},description:"Additional tags to apply to the built image."},ulimits:{$ref:"#/$defs/ulimits",description:"Override the default ulimits for the build container."},platforms:{type:"array",items:{type:"string"},description:"Platforms to build for, e.g., 'linux/amd64', 'linux/arm64', or 'windows/amd64'."}},additionalProperties:!1,patternProperties:{"^x-":{}}}]},blkio_config:{type:"object",description:"Block IO configuration for the service.",properties:{device_read_bps:{type:"array",description:"Limit read rate (bytes per second) from a device.",items:{$ref:"#/$defs/blkio_limit"}},device_read_iops:{type:"array",description:"Limit read rate (IO per second) from a device.",items:{$ref:"#/$defs/blkio_limit"}},device_write_bps:{type:"array",description:"Limit write rate (bytes per second) to a device.",items:{$ref:"#/$defs/blkio_limit"}},device_write_iops:{type:"array",description:"Limit write rate (IO per second) to a device.",items:{$ref:"#/$defs/blkio_limit"}},weight:{type:["integer","string"],description:"Block IO weight (relative weight) for the service, between 10 and 1000."},weight_device:{type:"array",description:"Block IO weight (relative weight) for specific devices.",items:{$ref:"#/$defs/blkio_weight"}}},additionalProperties:!1},cap_add:{type:"array",items:{type:"string"},uniqueItems:!0,description:"Add Linux capabilities. For example, 'CAP_SYS_ADMIN', 'SYS_ADMIN', or 'NET_ADMIN'."},cap_drop:{type:"array",items:{type:"string"},uniqueItems:!0,description:"Drop Linux capabilities. For example, 'CAP_SYS_ADMIN', 'SYS_ADMIN', or 'NET_ADMIN'."},cgroup:{type:"string",enum:["host","private"],description:"Specify the cgroup namespace to join. Use 'host' to use the host's cgroup namespace, or 'private' to use a private cgroup namespace."},cgroup_parent:{type:"string",description:"Specify an optional parent cgroup for the container."},command:{$ref:"#/$defs/command",description:"Override the default command declared by the container image, for example 'CMD' in Dockerfile."},configs:{$ref:"#/$defs/service_config_or_secret",description:"Grant access to Configs on a per-service basis."},container_name:{type:"string",description:"Specify a custom container name, rather than a generated default name.",pattern:"[a-zA-Z0-9][a-zA-Z0-9_.-]+"},cpu_count:{oneOf:[{type:"string"},{type:"integer",minimum:0}],description:"Number of usable CPUs."},cpu_percent:{oneOf:[{type:"string"},{type:"integer",minimum:0,maximum:100}],description:"Percentage of CPU resources to use."},cpu_shares:{type:["number","string"],description:"CPU shares (relative weight) for the container."},cpu_quota:{type:["number","string"],description:"Limit the CPU CFS (Completely Fair Scheduler) quota."},cpu_period:{type:["number","string"],description:"Limit the CPU CFS (Completely Fair Scheduler) period."},cpu_rt_period:{type:["number","string"],description:"Limit the CPU real-time period in microseconds or a duration."},cpu_rt_runtime:{type:["number","string"],description:"Limit the CPU real-time runtime in microseconds or a duration."},cpus:{type:["number","string"],description:"Number of CPUs to use. A floating-point value is supported to request partial CPUs."},cpuset:{type:"string",description:"CPUs in which to allow execution (0-3, 0,1)."},credential_spec:{type:"object",description:"Configure the credential spec for managed service account.",properties:{config:{type:"string",description:"The name of the credential spec Config to use."},file:{type:"string",description:"Path to a credential spec file."},registry:{type:"string",description:"Path to a credential spec in the Windows registry."}},additionalProperties:!1,patternProperties:{"^x-":{}}},depends_on:{oneOf:[{$ref:"#/$defs/list_of_strings"},{type:"object",additionalProperties:!1,patternProperties:{"^[a-zA-Z0-9._-]+$":{type:"object",additionalProperties:!1,patternProperties:{"^x-":{}},properties:{restart:{type:["boolean","string"],description:"Whether to restart dependent services when this service is restarted."},required:{type:"boolean",default:!0,description:"Whether the dependency is required for the dependent service to start."},condition:{type:"string",enum:["service_started","service_healthy","service_completed_successfully"],description:"Condition to wait for. 'service_started' waits until the service has started, 'service_healthy' waits until the service is healthy (as defined by its healthcheck), 'service_completed_successfully' waits until the service has completed successfully."}},required:["condition"]}}}],description:"Express dependency between services. Service dependencies cause services to be started in dependency order. The dependent service will wait for the dependency to be ready before starting."},device_cgroup_rules:{$ref:"#/$defs/list_of_strings",description:"Add rules to the cgroup allowed devices list."},devices:{type:"array",description:"List of device mappings for the container.",items:{oneOf:[{type:"string"},{type:"object",required:["source"],properties:{source:{type:"string",description:"Path on the host to the device."},target:{type:"string",description:"Path in the container where the device will be mapped."},permissions:{type:"string",description:"Cgroup permissions for the device (rwm)."}},additionalProperties:!1,patternProperties:{"^x-":{}}}]}},dns:{$ref:"#/$defs/string_or_list",description:"Custom DNS servers to set for the service container."},dns_opt:{type:"array",items:{type:"string"},uniqueItems:!0,description:"Custom DNS options to be passed to the container's DNS resolver."},dns_search:{$ref:"#/$defs/string_or_list",description:"Custom DNS search domains to set on the service container."},domainname:{type:"string",description:"Custom domain name to use for the service container."},entrypoint:{$ref:"#/$defs/command",description:"Override the default entrypoint declared by the container image, for example 'ENTRYPOINT' in Dockerfile."},env_file:{$ref:"#/$defs/env_file",description:"Add environment variables from a file or multiple files. Can be a single file path or a list of file paths."},label_file:{$ref:"#/$defs/label_file",description:"Add metadata to containers using files containing Docker labels."},environment:{$ref:"#/$defs/list_or_dict",description:"Add environment variables. You can use either an array or a list of KEY=VAL pairs."},expose:{type:"array",items:{type:["string","number"]},uniqueItems:!0,description:"Expose ports without publishing them to the host machine - they'll only be accessible to linked services."},extends:{oneOf:[{type:"string"},{type:"object",properties:{service:{type:"string",description:"The name of the service to extend."},file:{type:"string",description:"The file path where the service to extend is defined."}},required:["service"],additionalProperties:!1}],description:"Extend another service, in the current file or another file."},provider:{type:"object",description:"Specify a service which will not be manage by Compose directly, and delegate its management to an external provider.",required:["type"],properties:{type:{type:"string",description:"External component used by Compose to manage setup and teardown lifecycle of the service."},options:{type:"object",description:"Provider-specific options.",patternProperties:{"^.+$":{oneOf:[{type:["string","number","boolean"]},{type:"array",items:{type:["string","number","boolean"]}}]}}}},additionalProperties:!1,patternProperties:{"^x-":{}}},external_links:{type:"array",items:{type:"string"},uniqueItems:!0,description:"Link to services started outside this Compose application. Specify services as <service_name>:<alias>."},extra_hosts:{$ref:"#/$defs/extra_hosts",description:"Add hostname mappings to the container network interface configuration."},gpus:{$ref:"#/$defs/gpus",description:"Define GPU devices to use. Can be set to 'all' to use all GPUs, or a list of specific GPU devices."},group_add:{type:"array",items:{type:["string","number"]},uniqueItems:!0,description:"Add additional groups which user inside the container should be member of."},healthcheck:{$ref:"#/$defs/healthcheck",description:"Configure a health check for the container to monitor its health status."},hostname:{type:"string",description:"Define a custom hostname for the service container."},image:{type:"string",description:"Specify the image to start the container from. Can be a repository/tag, a digest, or a local image ID."},init:{type:["boolean","string"],description:"Run as an init process inside the container that forwards signals and reaps processes."},ipc:{type:"string",description:"IPC sharing mode for the service container. Use 'host' to share the host's IPC namespace, 'service:[service_name]' to share with another service, or 'shareable' to allow other services to share this service's IPC namespace."},isolation:{type:"string",description:"Container isolation technology to use. Supported values are platform-specific."},labels:{$ref:"#/$defs/list_or_dict",description:"Add metadata to containers using Docker labels. You can use either an array or a list."},links:{type:"array",items:{type:"string"},uniqueItems:!0,description:"Link to containers in another service. Either specify both the service name and a link alias (SERVICE:ALIAS), or just the service name."},logging:{type:"object",description:"Logging configuration for the service.",properties:{driver:{type:"string",description:"Logging driver to use, such as 'json-file', 'syslog', 'journald', etc."},options:{type:"object",description:"Options for the logging driver.",patternProperties:{"^.+$":{type:["string","number","null"]}}}},additionalProperties:!1,patternProperties:{"^x-":{}}},mac_address:{type:"string",description:"Container MAC address to set."},mem_limit:{type:["number","string"],description:"Memory limit for the container. A string value can use suffix like '2g' for 2 gigabytes."},mem_reservation:{type:["string","integer"],description:"Memory reservation for the container."},mem_swappiness:{type:["integer","string"],description:"Container memory swappiness as percentage (0 to 100)."},memswap_limit:{type:["number","string"],description:"Amount of memory the container is allowed to swap to disk. Set to -1 to enable unlimited swap."},network_mode:{type:"string",description:"Network mode. Values can be 'bridge', 'host', 'none', 'service:[service name]', or 'container:[container name]'."},models:{oneOf:[{$ref:"#/$defs/list_of_strings"},{type:"object",patternProperties:{"^[a-zA-Z0-9._-]+$":{oneOf:[{type:"object",properties:{endpoint_var:{type:"string",description:"Environment variable set to AI model endpoint."},model_var:{type:"string",description:"Environment variable set to AI model name."}},additionalProperties:!1,patternProperties:{"^x-":{}}},{type:"null"}]}}}],description:"AI Models to use, referencing entries under the top-level models key."},networks:{oneOf:[{$ref:"#/$defs/list_of_strings"},{type:"object",patternProperties:{"^[a-zA-Z0-9._-]+$":{oneOf:[{type:"object",properties:{aliases:{$ref:"#/$defs/list_of_strings",description:"Alternative hostnames for this service on the network."},interface_name:{type:"string",description:"Interface network name used to connect to network"},ipv4_address:{type:"string",description:"Specify a static IPv4 address for this service on this network."},ipv6_address:{type:"string",description:"Specify a static IPv6 address for this service on this network."},link_local_ips:{$ref:"#/$defs/list_of_strings",description:"List of link-local IPs."},mac_address:{type:"string",description:"Specify a MAC address for this service on this network."},driver_opts:{type:"object",description:"Driver options for this network.",patternProperties:{"^.+$":{type:["string","number"]}}},priority:{type:"number",description:"Specify the priority for the network connection."},gw_priority:{type:"number",description:"Specify the gateway priority for the network connection."}},additionalProperties:!1,patternProperties:{"^x-":{}}},{type:"null"}]}},additionalProperties:!1}],description:"Networks to join, referencing entries under the top-level networks key. Can be a list of network names or a mapping of network name to network configuration."},oom_kill_disable:{type:["boolean","string"],description:"Disable OOM Killer for the container."},oom_score_adj:{oneOf:[{type:"string"},{type:"integer",minimum:-1000,maximum:1000}],description:"Tune host's OOM preferences for the container (accepts -1000 to 1000)."},pid:{type:["string","null"],description:"PID mode for container."},pids_limit:{type:["number","string"],description:"Tune a container's PIDs limit. Set to -1 for unlimited PIDs."},platform:{type:"string",description:"Target platform to run on, e.g., 'linux/amd64', 'linux/arm64', or 'windows/amd64'."},ports:{type:"array",description:"Expose container ports. Short format ([HOST:]CONTAINER[/PROTOCOL]).",items:{oneOf:[{type:"number"},{type:"string"},{type:"object",properties:{name:{type:"string",description:"A human-readable name for this port mapping."},mode:{type:"string",description:"The port binding mode, either 'host' for publishing a host port or 'ingress' for load balancing."},host_ip:{type:"string",description:"The host IP to bind to."},target:{type:["integer","string"],description:"The port inside the container."},published:{type:["string","integer"],description:"The publicly exposed port."},protocol:{type:"string",description:"The port protocol (tcp or udp)."},app_protocol:{type:"string",description:"Application protocol to use with the port (e.g., http, https, mysql)."}},additionalProperties:!1,patternProperties:{"^x-":{}}}]},uniqueItems:!0},pre_start:{type:"array",items:{$ref:"#/$defs/pre_start_hook"},description:"Init containers to run to completion before the service container is started. Each step runs in its own ephemeral container, in declared order; a non-zero exit fails the bring-up of the service and its dependents."},post_start:{type:"array",items:{$ref:"#/$defs/service_hook"},description:"Commands to run after the container starts. If any command fails, the container stops."},pre_stop:{type:"array",items:{$ref:"#/$defs/service_hook"},description:"Commands to run before the container stops. If any command fails, the container stop is aborted."},privileged:{type:["boolean","string"],description:"Give extended privileges to the service container."},profiles:{$ref:"#/$defs/list_of_strings",description:"List of profiles for this service. When profiles are specified, services are only started when the profile is activated."},pull_policy:{type:"string",pattern:"always|never|build|if_not_present|missing|refresh|daily|weekly|every_([0-9]+[wdhms])+",description:"Policy for pulling images. Options include: 'always', 'never', 'if_not_present', 'missing', 'build', or time-based refresh policies."},pull_refresh_after:{type:"string",description:"Time after which to refresh the image. Used with pull_policy=refresh."},read_only:{type:["boolean","string"],description:"Mount the container's filesystem as read only."},restart:{type:"string",description:"Restart policy for the service container. Options include: 'no', 'always', 'on-failure', and 'unless-stopped'."},runtime:{type:"string",description:"Runtime to use for this container, e.g., 'runc'."},scale:{type:["integer","string"],description:"Number of containers to deploy for this service."},security_opt:{type:"array",items:{type:"string"},uniqueItems:!0,description:"Override the default labeling scheme for each container."},shm_size:{type:["number","string"],description:"Size of /dev/shm. A string value can use suffix like '2g' for 2 gigabytes."},secrets:{$ref:"#/$defs/service_config_or_secret",description:"Grant access to Secrets on a per-service basis."},sysctls:{$ref:"#/$defs/list_or_dict",description:"Kernel parameters to set in the container. You can use either an array or a list."},stdin_open:{type:["boolean","string"],description:"Keep STDIN open even if not attached."},stop_grace_period:{type:"string",description:"Time to wait for the container to stop gracefully before sending SIGKILL (e.g., '1s', '1m30s')."},stop_signal:{type:"string",description:"Signal to stop the container (e.g., 'SIGTERM', 'SIGINT')."},storage_opt:{type:"object",description:"Storage driver options for the container."},tmpfs:{$ref:"#/$defs/string_or_list",description:"Mount a temporary filesystem (tmpfs) into the container. Can be a single value or a list."},tty:{type:["boolean","string"],description:"Allocate a pseudo-TTY to service container."},ulimits:{$ref:"#/$defs/ulimits",description:"Override the default ulimits for a container."},use_api_socket:{type:"boolean",description:"Bind mount Docker API socket and required auth."},user:{type:"string",description:"Username or UID to run the container process as."},uts:{type:"string",description:"UTS namespace to use. 'host' shares the host's UTS namespace."},userns_mode:{type:"string",description:"User namespace to use. 'host' shares the host's user namespace."},volumes:{type:"array",description:"Mount host paths or named volumes accessible to the container. Short syntax (VOLUME:CONTAINER_PATH[:MODE])",items:{oneOf:[{type:"string"},{type:"object",required:["type"],properties:{type:{type:"string",enum:["bind","volume","tmpfs","cluster","npipe","image"],description:"The mount type: bind for mounting host directories, volume for named volumes, tmpfs for temporary filesystems, cluster for cluster volumes, npipe for named pipes, or image for mounting from an image."},source:{type:"string",description:"The source of the mount, a path on the host for a bind mount, a docker image reference for an image mount, or the name of a volume defined in the top-level volumes key. Not applicable for a tmpfs mount."},target:{type:"string",description:"The path in the container where the volume is mounted."},read_only:{type:["boolean","string"],description:"Flag to set the volume as read-only."},consistency:{type:"string",description:"The consistency requirements for the mount. Available values are platform specific."},bind:{type:"object",description:"Configuration specific to bind mounts.",properties:{propagation:{type:"string",description:"The propagation mode for the bind mount: 'shared', 'slave', 'private', 'rshared', 'rslave', or 'rprivate'."},create_host_path:{type:["boolean","string"],description:"Create the host path if it doesn't exist."},recursive:{type:"string",enum:["enabled","disabled","writable","readonly"],description:"Recursively mount the source directory."},selinux:{type:"string",enum:["z","Z"],description:"SELinux relabeling options: 'z' for shared content, 'Z' for private unshared content."}},additionalProperties:!1,patternProperties:{"^x-":{}}},volume:{type:"object",description:"Configuration specific to volume mounts.",properties:{labels:{$ref:"#/$defs/list_or_dict",description:"Labels to apply to the volume."},nocopy:{type:["boolean","string"],description:"Flag to disable copying of data from a container when a volume is created."},subpath:{type:"string",description:"Path within the volume to mount instead of the volume root."}},additionalProperties:!1,patternProperties:{"^x-":{}}},tmpfs:{type:"object",description:"Configuration specific to tmpfs mounts.",properties:{size:{oneOf:[{type:"integer",minimum:0},{type:"string"}],description:"Size of the tmpfs mount in bytes."},mode:{type:["number","string"],description:"File mode of the tmpfs in octal."}},additionalProperties:!1,patternProperties:{"^x-":{}}},image:{type:"object",description:"Configuration specific to image mounts.",properties:{subpath:{type:"string",description:"Path within the image to mount instead of the image root."}},additionalProperties:!1,patternProperties:{"^x-":{}}}},additionalProperties:!1,patternProperties:{"^x-":{}}}]},uniqueItems:!0},volumes_from:{type:"array",items:{type:"string"},uniqueItems:!0,description:"Mount volumes from another service or container. Optionally specify read-only access (ro) or read-write (rw)."},working_dir:{type:"string",description:"The working directory in which the entrypoint or command will be run"}},patternProperties:{"^x-":{}},additionalProperties:!1},healthcheck:{type:"object",description:"Configuration options to determine whether the container is healthy.",properties:{disable:{type:["boolean","string"],description:"Disable any container-specified healthcheck. Set to true to disable."},interval:{type:"string",description:"Time between running the check (e.g., '1s', '1m30s'). Default: 30s."},retries:{type:["number","string"],description:"Number of consecutive failures needed to consider the container as unhealthy. Default: 3."},test:{oneOf:[{type:"string"},{type:"array",items:{type:"string"}}],description:"The test to perform to check container health. Can be a string or a list. The first item is either NONE, CMD, or CMD-SHELL. If it's CMD, the rest of the command is exec'd. If it's CMD-SHELL, the rest is run in the shell."},timeout:{type:"string",description:"Maximum time to allow one check to run (e.g., '1s', '1m30s'). Default: 30s."},start_period:{type:"string",description:"Start period for the container to initialize before starting health-retries countdown (e.g., '1s', '1m30s'). Default: 0s."},start_interval:{type:"string",description:"Time between running the check during the start period (e.g., '1s', '1m30s'). Default: interval value."}},additionalProperties:!1,patternProperties:{"^x-":{}}},development:{type:["object","null"],description:"Development configuration for the service, used for development workflows.",properties:{watch:{type:"array",description:"Configure watch mode for the service, which monitors file changes and performs actions in response.",items:{type:"object",required:["path","action"],properties:{ignore:{$ref:"#/$defs/string_or_list",description:"Patterns to exclude from watching."},include:{$ref:"#/$defs/string_or_list",description:"Patterns to include in watching."},path:{type:"string",description:"Path to watch for changes."},action:{type:"string",enum:["rebuild","sync","restart","sync+restart","sync+exec"],description:"Action to take when a change is detected: rebuild the container, sync files, restart the container, sync and restart, or sync and execute a command."},target:{type:"string",description:"Target path in the container for sync operations."},exec:{$ref:"#/$defs/service_hook",description:"Command to execute when a change is detected and action is sync+exec."},initial_sync:{type:"boolean",description:"Ensure that an initial synchronization is done before starting watch mode for sync+x triggers"}},additionalProperties:!1,patternProperties:{"^x-":{}}}}},additionalProperties:!1,patternProperties:{"^x-":{}}},deployment:{type:["object","null"],description:"Deployment configuration for the service.",properties:{mode:{type:"string",description:"Deployment mode for the service: 'replicated' (default) or 'global'."},endpoint_mode:{type:"string",description:"Endpoint mode for the service: 'vip' (default) or 'dnsrr'."},replicas:{type:["integer","string"],description:"Number of replicas of the service container to run."},labels:{$ref:"#/$defs/list_or_dict",description:"Labels to apply to the service."},rollback_config:{type:"object",description:"Configuration for rolling back a service update.",properties:{parallelism:{type:["integer","string"],description:"The number of containers to rollback at a time. If set to 0, all containers rollback simultaneously."},delay:{type:"string",description:"The time to wait between each container group's rollback (e.g., '1s', '1m30s')."},failure_action:{type:"string",description:"Action to take if a rollback fails: 'continue', 'pause'."},monitor:{type:"string",description:"Duration to monitor each task for failures after it is created (e.g., '1s', '1m30s')."},max_failure_ratio:{type:["number","string"],description:"Failure rate to tolerate during a rollback."},order:{type:"string",enum:["start-first","stop-first"],description:"Order of operations during rollbacks: 'stop-first' (default) or 'start-first'."}},additionalProperties:!1,patternProperties:{"^x-":{}}},update_config:{type:"object",description:"Configuration for updating a service.",properties:{parallelism:{type:["integer","string"],description:"The number of containers to update at a time."},delay:{type:"string",description:"The time to wait between updating a group of containers (e.g., '1s', '1m30s')."},failure_action:{type:"string",description:"Action to take if an update fails: 'continue', 'pause', 'rollback'."},monitor:{type:"string",description:"Duration to monitor each updated task for failures after it is created (e.g., '1s', '1m30s')."},max_failure_ratio:{type:["number","string"],description:"Failure rate to tolerate during an update (0 to 1)."},order:{type:"string",enum:["start-first","stop-first"],description:"Order of operations during updates: 'stop-first' (default) or 'start-first'."}},additionalProperties:!1,patternProperties:{"^x-":{}}},resources:{type:"object",description:"Resource constraints and reservations for the service.",properties:{limits:{type:"object",description:"Resource limits for the service containers.",properties:{cpus:{type:["number","string"],description:"Limit for how much of the available CPU resources, as number of cores, a container can use."},memory:{type:"string",description:"Limit on the amount of memory a container can allocate (e.g., '1g', '1024m')."},pids:{type:["integer","string"],description:"Maximum number of PIDs available to the container."}},additionalProperties:!1,patternProperties:{"^x-":{}}},reservations:{type:"object",description:"Resource reservations for the service containers.",properties:{cpus:{type:["number","string"],description:"Reservation for how much of the available CPU resources, as number of cores, a container can use."},memory:{type:"string",description:"Reservation on the amount of memory a container can allocate (e.g., '1g', '1024m')."},generic_resources:{$ref:"#/$defs/generic_resources",description:"User-defined resources to reserve."},devices:{$ref:"#/$defs/devices",description:"Device reservations for the container."}},additionalProperties:!1,patternProperties:{"^x-":{}}}},additionalProperties:!1,patternProperties:{"^x-":{}}},restart_policy:{type:"object",description:"Restart policy for the service containers.",properties:{condition:{type:"string",description:"Condition for restarting the container: 'none', 'on-failure', 'any'."},delay:{type:"string",description:"Delay between restart attempts (e.g., '1s', '1m30s')."},max_attempts:{type:["integer","string"],description:"Maximum number of restart attempts before giving up."},window:{type:"string",description:"Time window used to evaluate the restart policy (e.g., '1s', '1m30s')."}},additionalProperties:!1,patternProperties:{"^x-":{}}},placement:{type:"object",description:"Constraints and preferences for the platform to select a physical node to run service containers",properties:{constraints:{type:"array",items:{type:"string"},description:"Placement constraints for the service (e.g., 'node.role==manager')."},preferences:{type:"array",description:"Placement preferences for the service.",items:{type:"object",properties:{spread:{type:"string",description:"Spread tasks evenly across values of the specified node label."}},additionalProperties:!1,patternProperties:{"^x-":{}}}},max_replicas_per_node:{type:["integer","string"],description:"Maximum number of replicas of the service."}},additionalProperties:!1,patternProperties:{"^x-":{}}}},additionalProperties:!1,patternProperties:{"^x-":{}}},generic_resources:{type:"array",description:"User-defined resources for services, allowing services to reserve specialized hardware resources.",items:{type:"object",properties:{discrete_resource_spec:{type:"object",description:"Specification for discrete (countable) resources.",properties:{kind:{type:"string",description:"Type of resource (e.g., 'GPU', 'FPGA', 'SSD')."},value:{type:["number","string"],description:"Number of resources of this kind to reserve."}},additionalProperties:!1,patternProperties:{"^x-":{}}}},additionalProperties:!1,patternProperties:{"^x-":{}}}},devices:{type:"array",description:"Device reservations for containers, allowing services to access specific hardware devices.",items:{type:"object",properties:{capabilities:{$ref:"#/$defs/list_of_strings",description:"List of capabilities the device needs to have (e.g., 'gpu', 'compute', 'utility')."},count:{type:["string","integer"],description:"Number of devices of this type to reserve."},device_ids:{$ref:"#/$defs/list_of_strings",description:"List of specific device IDs to reserve."},driver:{type:"string",description:"Device driver to use (e.g., 'nvidia')."},options:{$ref:"#/$defs/list_or_dict",description:"Driver-specific options for the device."}},additionalProperties:!1,patternProperties:{"^x-":{}},required:["capabilities"]}},gpus:{oneOf:[{type:"string",enum:["all"],description:"Use all available GPUs."},{type:"array",description:"List of specific GPU devices to use.",items:{type:"object",properties:{capabilities:{$ref:"#/$defs/list_of_strings",description:"List of capabilities the GPU needs to have (e.g., 'compute', 'utility')."},count:{type:["string","integer"],description:"Number of GPUs to use."},device_ids:{$ref:"#/$defs/list_of_strings",description:"List of specific GPU device IDs to use."},driver:{type:"string",description:"GPU driver to use (e.g., 'nvidia')."},options:{$ref:"#/$defs/list_or_dict",description:"Driver-specific options for the GPU."}}},additionalProperties:!1,patternProperties:{"^x-":{}}}]},include:{description:"Compose application or sub-projects to be included.",oneOf:[{type:"string"},{type:"object",properties:{path:{$ref:"#/$defs/string_or_list",description:"Path to the Compose application or sub-project files to include."},env_file:{$ref:"#/$defs/string_or_list",description:"Path to the environment files to use to define default values when interpolating variables in the Compose files being parsed."},project_directory:{type:"string",description:"Path to resolve relative paths set in the Compose file"}},additionalProperties:!1}]},network:{type:["object","null"],description:"Network configuration for the Compose application.",properties:{name:{type:"string",description:"Custom name for this network."},driver:{type:"string",description:"Specify which driver should be used for this network. Default is 'bridge'."},driver_opts:{type:"object",description:"Specify driver-specific options defined as key/value pairs.",patternProperties:{"^.+$":{type:["string","number"]}}},ipam:{type:"object",description:"Custom IP Address Management configuration for this network.",properties:{driver:{type:"string",description:"Custom IPAM driver, instead of the default."},config:{type:"array",description:"List of IPAM configuration blocks.",items:{type:"object",properties:{subnet:{type:"string",description:"Subnet in CIDR format that represents a network segment."},ip_range:{type:"string",description:"Range of IPs from which to allocate container IPs."},gateway:{type:"string",description:"IPv4 or IPv6 gateway for the subnet."},aux_addresses:{type:"object",description:"Auxiliary IPv4 or IPv6 addresses used by Network driver.",additionalProperties:!1,patternProperties:{"^.+$":{type:"string"}}}},additionalProperties:!1,patternProperties:{"^x-":{}}}},options:{type:"object",description:"Driver-specific options for the IPAM driver.",additionalProperties:!1,patternProperties:{"^.+$":{type:"string"}}}},additionalProperties:!1,patternProperties:{"^x-":{}}},external:{type:["boolean","string","object"],description:"Specifies that this network already exists and was created outside of Compose.",properties:{name:{deprecated:!0,type:"string",description:"Specifies the name of the external network. Deprecated: use the 'name' property instead."}},additionalProperties:!1,patternProperties:{"^x-":{}}},internal:{type:["boolean","string"],description:"Create an externally isolated network."},enable_ipv4:{type:["boolean","string"],description:"Enable IPv4 networking."},enable_ipv6:{type:["boolean","string"],description:"Enable IPv6 networking."},attachable:{type:["boolean","string"],description:"If true, standalone containers can attach to this network."},labels:{$ref:"#/$defs/list_or_dict",description:"Add metadata to the network using labels."}},additionalProperties:!1,patternProperties:{"^x-":{}}},volume:{type:["object","null"],description:"Volume configuration for the Compose application.",properties:{name:{type:"string",description:"Custom name for this volume."},driver:{type:"string",description:"Specify which volume driver should be used for this volume."},driver_opts:{type:"object",description:"Specify driver-specific options.",patternProperties:{"^.+$":{type:["string","number"]}}},external:{type:["boolean","string","object"],description:"Specifies that this volume already exists and was created outside of Compose.",properties:{name:{deprecated:!0,type:"string",description:"Specifies the name of the external volume. Deprecated: use the 'name' property instead."}},additionalProperties:!1,patternProperties:{"^x-":{}}},labels:{$ref:"#/$defs/list_or_dict",description:"Add metadata to the volume using labels."}},additionalProperties:!1,patternProperties:{"^x-":{}}},secret:{type:"object",description:"Secret configuration for the Compose application.",properties:{name:{type:"string",description:"Custom name for this secret."},environment:{type:"string",description:"Name of an environment variable from which to get the secret value."},file:{type:"string",description:"Path to a file containing the secret value."},external:{type:["boolean","string","object"],description:"Specifies that this secret already exists and was created outside of Compose.",properties:{name:{type:"string",description:"Specifies the name of the external secret."}}},labels:{$ref:"#/$defs/list_or_dict",description:"Add metadata to the secret using labels."},driver:{type:"string",description:"Specify which secret driver should be used for this secret."},driver_opts:{type:"object",description:"Specify driver-specific options.",patternProperties:{"^.+$":{type:["string","number"]}}},template_driver:{type:"string",description:"Driver to use for templating the secret's value."}},additionalProperties:!1,patternProperties:{"^x-":{}}},config:{type:"object",description:"Config configuration for the Compose application.",properties:{name:{type:"string",description:"Custom name for this config."},content:{type:"string",description:"Inline content of the config."},environment:{type:"string",description:"Name of an environment variable from which to get the config value."},file:{type:"string",description:"Path to a file containing the config value."},external:{type:["boolean","string","object"],description:"Specifies that this config already exists and was created outside of Compose.",properties:{name:{deprecated:!0,type:"string",description:"Specifies the name of the external config. Deprecated: use the 'name' property instead."}}},labels:{$ref:"#/$defs/list_or_dict",description:"Add metadata to the config using labels."},template_driver:{type:"string",description:"Driver to use for templating the config's value."}},additionalProperties:!1,patternProperties:{"^x-":{}}},model:{type:"object",description:"Language Model for the Compose application.",properties:{name:{type:"string",description:"Custom name for this model."},model:{type:"string",description:"Language Model to run."},context_size:{type:"integer"},runtime_flags:{type:"array",items:{type:"string"},description:"Raw runtime flags to pass to the inference engine."}},required:["model"],additionalProperties:!1,patternProperties:{"^x-":{}}},command:{oneOf:[{type:"null",description:"No command specified, use the container's default command."},{type:"string",description:"Command as a string, which will be executed in a shell (e.g., '/bin/sh -c')."},{type:"array",description:"Command as an array of strings, which will be executed directly without a shell.",items:{type:"string",description:"Part of the command (executable or argument)."}}],description:"Command to run in the container, which can be specified as a string (shell form) or array (exec form)."},service_hook:{type:"object",description:"Configuration for service lifecycle hooks, which are commands executed at specific points in a container's lifecycle.",properties:{command:{$ref:"#/$defs/command",description:"Command to execute as part of the hook."},user:{type:"string",description:"User to run the command as."},privileged:{type:["boolean","string"],description:"Whether to run the command with extended privileges."},working_dir:{type:"string",description:"Working directory for the command."},environment:{$ref:"#/$defs/list_or_dict",description:"Environment variables for the command."}},additionalProperties:!1,patternProperties:{"^x-":{}},required:["command"]},pre_start_hook:{type:"object",description:"Configuration for a pre_start init container, run to completion before the service container starts.",properties:{command:{$ref:"#/$defs/command",description:"Command to execute. Optional when the chosen image's entrypoint already runs the intended command."},image:{type:"string",description:"Image used for the ephemeral container. If omitted, the parent service's image is used."},user:{type:"string",description:"User to run the command as. Defaults to the user declared in image (or to the service's user when image is omitted)."},privileged:{type:["boolean","string"],description:"Whether to run the command with extended privileges."},working_dir:{type:"string",description:"Working directory for the command. Defaults to the service's working directory."},environment:{$ref:"#/$defs/list_or_dict",description:"Environment variables for the command. Appended to or overriding the service environment."},per_replica:{type:["boolean","string"],description:"Whether the hook runs once per service replica (true), or once for the service as a whole before any replica starts (false, the default)."}},additionalProperties:!1,patternProperties:{"^x-":{}}},env_file:{oneOf:[{type:"string",description:"Path to a file containing environment variables."},{type:"array",description:"List of paths to files containing environment variables.",items:{oneOf:[{type:"string",description:"Path to a file containing environment variables."},{type:"object",description:"Detailed configuration for an environment file.",additionalProperties:!1,properties:{path:{type:"string",description:"Path to the environment file."},format:{type:"string",description:"Format attribute lets you to use an alternative file formats for env_file. When not set, env_file is parsed according to Compose rules."},required:{type:["boolean","string"],default:!0,description:"Whether the file is required. If true and the file doesn't exist, an error will be raised."}},required:["path"]}]}}]},label_file:{oneOf:[{type:"string",description:"Path to a file containing Docker labels."},{type:"array",description:"List of paths to files containing Docker labels.",items:{type:"string",description:"Path to a file containing Docker labels."}}]},string_or_list:{oneOf:[{type:"string",description:"A single string value."},{$ref:"#/$defs/list_of_strings",description:"A list of string values."}],description:"Either a single string or a list of strings."},list_of_strings:{type:"array",description:"A list of unique string values.",items:{type:"string",description:"A string value in the list."},uniqueItems:!0},list_or_dict:{oneOf:[{type:"object",description:"A dictionary mapping keys to values.",patternProperties:{".+":{type:["string","number","boolean","null"],description:"Value for the key, which can be a string, number, boolean, or null."}},additionalProperties:!1},{type:"array",description:"A list of unique string values.",items:{type:"string",description:"A string value in the list."},uniqueItems:!0}],description:"Either a dictionary mapping keys to values, or a list of strings."},extra_hosts:{oneOf:[{type:"object",description:"list mapping hostnames to IP addresses.",patternProperties:{".+":{oneOf:[{type:"string",description:"IP address for the hostname."},{type:"array",description:"List of IP addresses for the hostname.",items:{type:"string",description:"IP address for the hostname."},uniqueItems:!1}]}},additionalProperties:!1},{type:"array",description:"List of host:IP mappings in the format 'hostname:IP'.",items:{type:"string",description:"Host:IP mapping in the format 'hostname:IP'."},uniqueItems:!0}],description:"Additional hostnames to be defined in the container's /etc/hosts file."},blkio_limit:{type:"object",description:"Block IO limit for a specific device.",properties:{path:{type:"string",description:"Path to the device (e.g., '/dev/sda')."},rate:{type:["integer","string"],description:"Rate limit in bytes per second or IO operations per second."}},additionalProperties:!1},blkio_weight:{type:"object",description:"Block IO weight for a specific device.",properties:{path:{type:"string",description:"Path to the device (e.g., '/dev/sda')."},weight:{type:["integer","string"],description:"Relative weight for the device, between 10 and 1000."}},additionalProperties:!1},service_config_or_secret:{type:"array",description:"Configuration for service configs or secrets, defining how they are mounted in the container.",items:{oneOf:[{type:"string",description:"Name of the config or secret to grant access to."},{type:"object",description:"Detailed configuration for a config or secret.",properties:{source:{type:"string",description:"Name of the config or secret as defined in the top-level configs or secrets section."},target:{type:"string",description:"Path in the container where the config or secret will be mounted. Defaults to /<source> for configs and /run/secrets/<source> for secrets."},uid:{type:"string",description:"UID of the file in the container. Default is 0 (root)."},gid:{type:"string",description:"GID of the file in the container. Default is 0 (root)."},mode:{type:["number","string"],description:"File permission mode inside the container, in octal. Default is 0444 for configs and 0400 for secrets."}},additionalProperties:!1,patternProperties:{"^x-":{}}}]}},ulimits:{type:"object",description:"Container ulimit options, controlling resource limits for processes inside the container.",patternProperties:{"^[a-z]+$":{oneOf:[{type:["integer","string"],description:"Single value for both soft and hard limits."},{type:"object",description:"Separate soft and hard limits.",properties:{hard:{type:["integer","string"],description:"Hard limit for the ulimit type. This is the maximum allowed value."},soft:{type:["integer","string"],description:"Soft limit for the ulimit type. This is the value that's actually enforced."}},required:["soft","hard"],additionalProperties:!1,patternProperties:{"^x-":{}}}]}}}}}});import{readdir as uv}from"fs/promises";import{join as lv}from"path";var{file:pv,YAML:dv}=globalThis.Bun;function mv(){if(!Io)Io=Promise.resolve().then(() => (gm(),{})).then(({})=>Nf(hm)).catch((e)=>{throw Io=void 0,e});return Io}function ym(e){return pv(e).text().then(dv.parse).then(async(t)=>(await mv()).parse(t))}async function bm(e){return(await uv(e,{withFileTypes:!0})).filter((r)=>r.isFile()&&fv.has(r.name)).map((r)=>lv(e,r.name)).sort()[0]}var fv,Io;var _m=_(()=>{Ms();fv=new Set(["compose.yml","compose.yaml","docker-compose.yml","docker-compose.yaml"])});import{AsyncLocalStorage as hv}from"async_hooks";function gv(e,t){if(e.projectConfigured)return e.project;return t.name?.trim()||e.project}async function vm(e,t){let r=process.cwd(),o=await fm(r,t),n=Bo("composeFile",()=>o.composeFile?Promise.resolve(o.composeFile):bm(r)),i=Bo("parsedCompose",async()=>{let c=await n();if(!c)throw Error("Compose file cannot be found");return ym(c)});if(!o.projectConfigured){if(await n())o.project=gv(o,await i())}let s=Bo("hookContext",async()=>{let c=await n();if(!c)throw Error("Compose file cannot be found");return mm(o,r,c)}),a=Bo("compose",async()=>{let c=await s(),u=await i();return await o.compose?.(u,c),u});return await wm.run({project:o.project,cwd:r,config:o,path:n,hookContext:s,compose:a},e)}function D(){let e=wm.getStore();if(!e)throw Error("Not in context!");return e}function Bo(e,t){let r;return()=>(r??=t().catch((o)=>{throw r=void 0,o}),r)}var wm;var oe=_(()=>{Oo();_m();wm=new hv});import{createHash as yv,randomUUID as bv}from"crypto";import{chmod as xm,mkdir as _v,readFile as wv,realpath as vv,rename as xv,writeFile as Ev}from"fs/promises";import{join as Em}from"path";function $m(){return Em(process.env.XDG_CONFIG_HOME??Em(process.env.HOME??"/tmp",".config"),"kuber","trust.json")}async function bt(e,t=process.cwd()){let r=await vv(t);return{project:e,fingerprint:yv("sha256").update(r).digest("hex")}}function Sv(e){return!!e&&typeof e==="object"&&typeof e.project==="string"&&typeof e.fingerprint==="string"&&/^[a-f0-9]{64}$/.test(e.fingerprint)}async function zo(){try{let e=JSON.parse(await wv($m(),"utf8"));if(!e||typeof e!=="object"||e.version!==Sm||!Array.isArray(e.records))return[];return e.records.filter(Sv)}catch{return[]}}async function $v(e){let t=$m(),r=t.slice(0,t.lastIndexOf("/"));await _v(r,{recursive:!0,mode:448}),await xm(r,448);let o=`${t}.${bv()}.tmp`;await Ev(o,JSON.stringify({version:Sm,records:e},null,2)+`
|
|
79
|
+
`:""}renderBorderCell(e,t,r,o,n){let i=t?.[e-1],s=r?.[e-1],a=t?.[e],c=r?.[e],u=!!i?.getBorder(),l=!!s?.getBorder(),f=!!a?.getBorder(),d=!!c?.getBorder(),p=(b)=>(b?.getColSpan()??1)>1,m=(b)=>(b?.getRowSpan()??1)>1,h="";if(e===0)if(o[e]>1)if(f)h+=this.options.chars.left;else h+=" ";else if(f&&d)h+=this.options.chars.leftMid;else if(f)h+=this.options.chars.bottomLeft;else if(d)h+=this.options.chars.topLeft;else h+=" ";else if(e<n.columns)if(u&&d||f&&l){let b=p(i),P=p(s),E=p(a),k=p(c),x=m(i),A=m(s),T=m(a),B=m(c),W=u&&d&&f&&l,Te=x&&T&&A&&B,Ne=b&&E&&P&&k;if(Te&&W)h+=this.options.chars.middle;else if(Ne&&W&&i===a&&s===c)h+=this.options.chars.mid;else if(b&&E&&i===a)h+=this.options.chars.topMid;else if(P&&k&&s===c)h+=this.options.chars.bottomMid;else if(x&&A&&i===s)h+=this.options.chars.leftMid;else if(T&&B&&a===c)h+=this.options.chars.rightMid;else h+=this.options.chars.midMid}else if(u&&f)if(p(i)&&p(a)&&i===a)h+=this.options.chars.bottom;else h+=this.options.chars.bottomMid;else if(f&&d)if(o[e]>1)h+=this.options.chars.left;else h+=this.options.chars.leftMid;else if(d&&l)if(p(s)&&p(c)&&s===c)h+=this.options.chars.top;else h+=this.options.chars.topMid;else if(u&&l)if(m(i)&&i===s)h+=this.options.chars.right;else h+=this.options.chars.rightMid;else if(u)h+=this.options.chars.bottomRight;else if(f)h+=this.options.chars.bottomLeft;else if(l)h+=this.options.chars.topRight;else if(d)h+=this.options.chars.topLeft;else h+=" ";let y=n.padding[e]+n.width[e]+n.padding[e];if(o[e]>1&&r){if(h+=this.renderCell(e,r,n,!0),r[e]===r[r.length-1]){if(f)h+=this.options.chars.right;else h+=" ";return h}}else if(f&&d)h+=this.options.chars.mid.repeat(y);else if(f)h+=this.options.chars.bottom.repeat(y);else if(d)h+=this.options.chars.top.repeat(y);else h+=" ".repeat(y);if(e===n.columns-1)if(f&&d)h+=this.options.chars.rightMid;else if(f)h+=this.options.chars.bottomRight;else if(d)h+=this.options.chars.topRight;else h+=" ";return h}}var $e=(e)=>e.reduce((t,r)=>t+r,0);var sm=_(()=>{Co();Ro();Js()});var Ze;var am=_(()=>{Ks();sm();Ro();Ze=class Ze extends Array{static _chars={...Gs};options={indent:0,border:!1,maxColWidth:1/0,minColWidth:0,padding:1,maxWidth:1/0,flexShrink:0,flexGrow:0,chars:{...Ze._chars},columns:[]};headerRow;static from(e){let t=new this(...e);if(e instanceof Ze)t.options={...e.options},t.headerRow=e.headerRow?le.from(e.headerRow):void 0;return t}static fromJson(e){return new this().fromJson(e)}static chars(e){return Object.assign(this._chars,e),this}static render(e){Ze.from(e).render()}fromJson(e){return this.header(Object.keys(e[0])),this.body(e.map((t)=>Object.values(t))),this}columns(e){return this.options.columns=e.map((t)=>t instanceof Ee?t:Ee.from(t)),this}column(e,t){if(t instanceof Ee)this.options.columns[e]=t;else if(this.options.columns[e])this.options.columns[e].options(t);else this.options.columns[e]=Ee.from(t);return this}header(e){return this.headerRow=e instanceof le?e:le.from(e),this}body(e){return this.length=0,this.push(...e),this}clone(){let e=new Ze(...this.map((t)=>t instanceof le?t.clone():le.from(t).clone()));return e.options={...this.options},e.headerRow=this.headerRow?.clone(),e}toString(){return new Ys(this,this.options).toString()}render(){return console.log(this.toString()),this}maxColWidth(e,t=!0){if(t||typeof this.options.maxColWidth>"u")this.options.maxColWidth=e;return this}minColWidth(e,t=!0){if(t||typeof this.options.minColWidth>"u")this.options.minColWidth=e;return this}maxWidth(e,t=!0){if(t||typeof this.options.maxWidth>"u")this.options.maxWidth=e;return this}flexShrink(e=1,t=!0){if(t||typeof this.options.flexShrink>"u")this.options.flexShrink=e;return this}flexGrow(e=1,t=!0){if(t||typeof this.options.flexGrow>"u")this.options.flexGrow=e;return this}flex(e=1,t=!0){return this.flexGrow(e,t).flexShrink(e,t)}indent(e,t=!0){if(t||typeof this.options.indent>"u")this.options.indent=e;return this}padding(e,t=!0){if(t||typeof this.options.padding>"u")this.options.padding=e;return this}border(e=!0,t=!0){if(t||typeof this.options.border>"u")this.options.border=e;return this}align(e,t=!0){if(t||typeof this.options.align>"u")this.options.align=e;return this}chars(e){return Object.assign(this.options.chars,e),this}getHeader(){return this.headerRow}getBody(){return[...this]}getMaxColWidth(){return this.options.maxColWidth}getMinColWidth(){return this.options.minColWidth}getIndent(){return this.options.indent}getPadding(){return this.options.padding}getBorder(){return this.options.border===!0}hasHeaderBorder(){let e=this.headerRow?.hasBorder();return e===!0||this.getBorder()&&e!==!1}hasBodyBorder(){return this.getBorder()||this.options.columns.some((e)=>e.getBorder())||this.some((e)=>e instanceof le?e.hasBorder():e.some((t)=>t instanceof ie?t.getBorder():!1))}hasBorder(){return this.hasHeaderBorder()||this.hasBodyBorder()}getAlign(){return this.options.align??"left"}getColumns(){return this.options.columns}getColumn(e){return this.options.columns[e]??=new Ee}}});var cm=_(()=>{Ks();Co();Ro();am()});function fe(e){return new Ze(Object.keys(e[0]??{}).map((t)=>t.toUpperCase()),...e.map((t)=>Object.values(t))).toString()}function um(e){if(!e)return;if(Array.isArray(e))return e.map((t)=>{let r=t.indexOf("=");return{name:r===-1?t:t.slice(0,r),value:r===-1?void 0:t.slice(r+1)}});return Object.entries(e).map(([t,r])=>({name:t,value:r===null?void 0:String(r)}))}var ot=_(()=>{cm()});async function ev(e,t=C){let r=e?`/audit?${new URLSearchParams({workspaceId:e})}`:"/audit",o=await t(r);if(o.items.length===0)return"No audit events";return fe(o.items.map((n)=>({timestamp:n.metadata.creationTimestamp,actor:n.spec.actor.username,action:n.spec.action,workspace:n.spec.workspaceId,outcome:n.spec.outcome,operation:n.spec.operationId})))}var tv,rv;var lm=_(()=>{q();G();ot();tv=S({meta:{name:"ls",description:"List audit events"},args:{workspace:{type:"string",alias:"w",description:"Filter by workspace"}},async run({args:e}){console.log(await ev(e.workspace??e._[0]))}}),rv=S({meta:{name:"audit",description:"Inspect the audit log"},subCommands:{ls:tv}})});import{basename as ov,isAbsolute as nv,resolve as pm}from"path";import{pathToFileURL as iv}from"url";function Xs(e,t){if(typeof e!=="string"||e.trim().length===0)throw Error(`${t} must be a non-empty string`);return e.trim()}function cv(e,t){if(!e||typeof e!=="object"||Array.isArray(e))throw Error(`${t} must default export a configuration object`);let r=e;for(let o of["compose","preBuild","postBuild","postRender","postApply"])if(r[o]!==void 0&&typeof r[o]!=="function")throw Error(`${o} in ${t} must be a function`);if(r.project!==void 0)Xs(r.project,"project");if(r.composeFile!==void 0)Xs(r.composeFile,"composeFile");if(r.registry!==void 0)Xs(r.registry,"registry");if(r.rolloutTimeoutMs!==void 0&&(typeof r.rolloutTimeoutMs!=="number"||!Number.isFinite(r.rolloutTimeoutMs)||r.rolloutTimeoutMs<=0))throw Error(`rolloutTimeoutMs in ${t} must be a positive number`);return e}function dm(e){let t,r=[];for(let o=0;o<e.length;o+=1){let n=e[o];if(n==="--"){r.push(...e.slice(o));break}if(n.startsWith("--config=")){let i=n.slice(9);if(!i)throw Error("--config requires a path");if(t)throw Error("--config may only be specified once");t=i;continue}if(n==="--config"){let i=e[o+1];if(!i||i.startsWith("-"))throw Error(`${n} requires a path`);if(t)throw Error("--config may only be specified once");t=i,o+=1;continue}r.push(n)}return{configPath:t,rawArgs:r}}async function fm(e,t){let r=pm(e,t??sv),o=await Bun.file(r).exists();if(!o&&t)throw Error(`Config file cannot be found: ${r}`);let n=o?cv((await import(iv(r).href)).default,r):{},i=n.composeFile?.trim(),s=(n.registry?.trim()??To).replace(/\/+$/,"");if(!s)throw Error(`registry in ${r} cannot be empty`);return{project:n.project?.trim()??ov(e),projectConfigured:n.project!==void 0,composeFile:i?nv(i)?i:pm(e,i):void 0,registry:s,rolloutTimeoutMs:n.rolloutTimeoutMs??av,configFile:o?r:void 0,compose:n.compose,preBuild:n.preBuild,postBuild:n.postBuild,postRender:n.postRender,postApply:n.postApply}}function mm(e,t,r){return{cwd:t,project:e.project,composeFile:r,configFile:e.configFile}}var sv=".kuberrc.ts",To,av=300000;var Oo=_(()=>{Fe();To=Mf});var hm;var gm=_(()=>{hm={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"compose_spec.json",type:"object",title:"Compose Specification",description:"The Compose file is a YAML file defining a multi-containers based application.",properties:{version:{type:"string",deprecated:!0,description:"declared for backward compatibility, ignored. Please remove it."},name:{type:"string",description:"define the Compose project name, until user defines one explicitly."},include:{type:"array",items:{$ref:"#/$defs/include"},description:"compose sub-projects to be included."},services:{type:"object",patternProperties:{"^[a-zA-Z0-9._-]+$":{$ref:"#/$defs/service"}},additionalProperties:!1,description:"The services that will be used by your application."},models:{type:"object",patternProperties:{"^[a-zA-Z0-9._-]+$":{$ref:"#/$defs/model"}},description:"Language models that will be used by your application."},networks:{type:"object",patternProperties:{"^[a-zA-Z0-9._-]+$":{$ref:"#/$defs/network"}},description:"Networks that are shared among multiple services."},volumes:{type:"object",patternProperties:{"^[a-zA-Z0-9._-]+$":{$ref:"#/$defs/volume"}},additionalProperties:!1,description:"Named volumes that are shared among multiple services."},secrets:{type:"object",patternProperties:{"^[a-zA-Z0-9._-]+$":{$ref:"#/$defs/secret"}},additionalProperties:!1,description:"Secrets that are shared among multiple services."},configs:{type:"object",patternProperties:{"^[a-zA-Z0-9._-]+$":{$ref:"#/$defs/config"}},additionalProperties:!1,description:"Configurations that are shared among multiple services."}},patternProperties:{"^x-":{}},additionalProperties:!1,$defs:{service:{type:"object",description:"Configuration for a service.",properties:{develop:{$ref:"#/$defs/development"},deploy:{$ref:"#/$defs/deployment"},annotations:{$ref:"#/$defs/list_or_dict"},attach:{type:["boolean","string"]},build:{description:"Configuration options for building the service's image.",oneOf:[{type:"string",description:"Path to the build context. Can be a relative path or a URL."},{type:"object",properties:{context:{type:"string",description:"Path to the build context. Can be a relative path or a URL."},dockerfile:{type:"string",description:"Name of the Dockerfile to use for building the image."},dockerfile_inline:{type:"string",description:"Inline Dockerfile content to use instead of a Dockerfile from the build context."},entitlements:{type:"array",items:{type:"string"},description:"List of extra privileged entitlements to grant to the build process."},args:{$ref:"#/$defs/list_or_dict",description:"Build-time variables, specified as a map or a list of KEY=VAL pairs."},ssh:{$ref:"#/$defs/list_or_dict",description:"SSH agent socket or keys to expose to the build. Format is either a string or a list of 'default|<id>[=<socket>|<key>[,<key>]]'."},labels:{$ref:"#/$defs/list_or_dict",description:"Labels to apply to the built image."},cache_from:{type:"array",items:{type:"string"},description:"List of sources the image builder should use for cache resolution"},cache_to:{type:"array",items:{type:"string"},description:"Cache destinations for the build cache."},no_cache:{type:["boolean","string"],description:"Do not use cache when building the image."},no_cache_filter:{$ref:"#/$defs/string_or_list",description:"Do not use build cache for the specified stages."},additional_contexts:{$ref:"#/$defs/list_or_dict",description:"Additional build contexts to use, specified as a map of name to context path or URL."},network:{type:"string",description:"Network mode to use for the build. Options include 'default', 'none', 'host', or a network name."},provenance:{type:["string","boolean"],description:"Add a provenance attestation"},sbom:{type:["string","boolean"],description:"Add a SBOM attestation"},pull:{type:["boolean","string"],description:"Always attempt to pull a newer version of the image."},target:{type:"string",description:"Build stage to target in a multi-stage Dockerfile."},shm_size:{type:["integer","string"],description:"Size of /dev/shm for the build container. A string value can use suffix like '2g' for 2 gigabytes."},extra_hosts:{$ref:"#/$defs/extra_hosts",description:"Add hostname mappings for the build container."},isolation:{type:"string",description:"Container isolation technology to use for the build process."},privileged:{type:["boolean","string"],description:"Give extended privileges to the build container."},secrets:{$ref:"#/$defs/service_config_or_secret",description:"Secrets to expose to the build. These are accessible at build-time."},tags:{type:"array",items:{type:"string"},description:"Additional tags to apply to the built image."},ulimits:{$ref:"#/$defs/ulimits",description:"Override the default ulimits for the build container."},platforms:{type:"array",items:{type:"string"},description:"Platforms to build for, e.g., 'linux/amd64', 'linux/arm64', or 'windows/amd64'."}},additionalProperties:!1,patternProperties:{"^x-":{}}}]},blkio_config:{type:"object",description:"Block IO configuration for the service.",properties:{device_read_bps:{type:"array",description:"Limit read rate (bytes per second) from a device.",items:{$ref:"#/$defs/blkio_limit"}},device_read_iops:{type:"array",description:"Limit read rate (IO per second) from a device.",items:{$ref:"#/$defs/blkio_limit"}},device_write_bps:{type:"array",description:"Limit write rate (bytes per second) to a device.",items:{$ref:"#/$defs/blkio_limit"}},device_write_iops:{type:"array",description:"Limit write rate (IO per second) to a device.",items:{$ref:"#/$defs/blkio_limit"}},weight:{type:["integer","string"],description:"Block IO weight (relative weight) for the service, between 10 and 1000."},weight_device:{type:"array",description:"Block IO weight (relative weight) for specific devices.",items:{$ref:"#/$defs/blkio_weight"}}},additionalProperties:!1},cap_add:{type:"array",items:{type:"string"},uniqueItems:!0,description:"Add Linux capabilities. For example, 'CAP_SYS_ADMIN', 'SYS_ADMIN', or 'NET_ADMIN'."},cap_drop:{type:"array",items:{type:"string"},uniqueItems:!0,description:"Drop Linux capabilities. For example, 'CAP_SYS_ADMIN', 'SYS_ADMIN', or 'NET_ADMIN'."},cgroup:{type:"string",enum:["host","private"],description:"Specify the cgroup namespace to join. Use 'host' to use the host's cgroup namespace, or 'private' to use a private cgroup namespace."},cgroup_parent:{type:"string",description:"Specify an optional parent cgroup for the container."},command:{$ref:"#/$defs/command",description:"Override the default command declared by the container image, for example 'CMD' in Dockerfile."},configs:{$ref:"#/$defs/service_config_or_secret",description:"Grant access to Configs on a per-service basis."},container_name:{type:"string",description:"Specify a custom container name, rather than a generated default name.",pattern:"[a-zA-Z0-9][a-zA-Z0-9_.-]+"},cpu_count:{oneOf:[{type:"string"},{type:"integer",minimum:0}],description:"Number of usable CPUs."},cpu_percent:{oneOf:[{type:"string"},{type:"integer",minimum:0,maximum:100}],description:"Percentage of CPU resources to use."},cpu_shares:{type:["number","string"],description:"CPU shares (relative weight) for the container."},cpu_quota:{type:["number","string"],description:"Limit the CPU CFS (Completely Fair Scheduler) quota."},cpu_period:{type:["number","string"],description:"Limit the CPU CFS (Completely Fair Scheduler) period."},cpu_rt_period:{type:["number","string"],description:"Limit the CPU real-time period in microseconds or a duration."},cpu_rt_runtime:{type:["number","string"],description:"Limit the CPU real-time runtime in microseconds or a duration."},cpus:{type:["number","string"],description:"Number of CPUs to use. A floating-point value is supported to request partial CPUs."},cpuset:{type:"string",description:"CPUs in which to allow execution (0-3, 0,1)."},credential_spec:{type:"object",description:"Configure the credential spec for managed service account.",properties:{config:{type:"string",description:"The name of the credential spec Config to use."},file:{type:"string",description:"Path to a credential spec file."},registry:{type:"string",description:"Path to a credential spec in the Windows registry."}},additionalProperties:!1,patternProperties:{"^x-":{}}},depends_on:{oneOf:[{$ref:"#/$defs/list_of_strings"},{type:"object",additionalProperties:!1,patternProperties:{"^[a-zA-Z0-9._-]+$":{type:"object",additionalProperties:!1,patternProperties:{"^x-":{}},properties:{restart:{type:["boolean","string"],description:"Whether to restart dependent services when this service is restarted."},required:{type:"boolean",default:!0,description:"Whether the dependency is required for the dependent service to start."},condition:{type:"string",enum:["service_started","service_healthy","service_completed_successfully"],description:"Condition to wait for. 'service_started' waits until the service has started, 'service_healthy' waits until the service is healthy (as defined by its healthcheck), 'service_completed_successfully' waits until the service has completed successfully."}},required:["condition"]}}}],description:"Express dependency between services. Service dependencies cause services to be started in dependency order. The dependent service will wait for the dependency to be ready before starting."},device_cgroup_rules:{$ref:"#/$defs/list_of_strings",description:"Add rules to the cgroup allowed devices list."},devices:{type:"array",description:"List of device mappings for the container.",items:{oneOf:[{type:"string"},{type:"object",required:["source"],properties:{source:{type:"string",description:"Path on the host to the device."},target:{type:"string",description:"Path in the container where the device will be mapped."},permissions:{type:"string",description:"Cgroup permissions for the device (rwm)."}},additionalProperties:!1,patternProperties:{"^x-":{}}}]}},dns:{$ref:"#/$defs/string_or_list",description:"Custom DNS servers to set for the service container."},dns_opt:{type:"array",items:{type:"string"},uniqueItems:!0,description:"Custom DNS options to be passed to the container's DNS resolver."},dns_search:{$ref:"#/$defs/string_or_list",description:"Custom DNS search domains to set on the service container."},domainname:{type:"string",description:"Custom domain name to use for the service container."},entrypoint:{$ref:"#/$defs/command",description:"Override the default entrypoint declared by the container image, for example 'ENTRYPOINT' in Dockerfile."},env_file:{$ref:"#/$defs/env_file",description:"Add environment variables from a file or multiple files. Can be a single file path or a list of file paths."},label_file:{$ref:"#/$defs/label_file",description:"Add metadata to containers using files containing Docker labels."},environment:{$ref:"#/$defs/list_or_dict",description:"Add environment variables. You can use either an array or a list of KEY=VAL pairs."},expose:{type:"array",items:{type:["string","number"]},uniqueItems:!0,description:"Expose ports without publishing them to the host machine - they'll only be accessible to linked services."},extends:{oneOf:[{type:"string"},{type:"object",properties:{service:{type:"string",description:"The name of the service to extend."},file:{type:"string",description:"The file path where the service to extend is defined."}},required:["service"],additionalProperties:!1}],description:"Extend another service, in the current file or another file."},provider:{type:"object",description:"Specify a service which will not be manage by Compose directly, and delegate its management to an external provider.",required:["type"],properties:{type:{type:"string",description:"External component used by Compose to manage setup and teardown lifecycle of the service."},options:{type:"object",description:"Provider-specific options.",patternProperties:{"^.+$":{oneOf:[{type:["string","number","boolean"]},{type:"array",items:{type:["string","number","boolean"]}}]}}}},additionalProperties:!1,patternProperties:{"^x-":{}}},external_links:{type:"array",items:{type:"string"},uniqueItems:!0,description:"Link to services started outside this Compose application. Specify services as <service_name>:<alias>."},extra_hosts:{$ref:"#/$defs/extra_hosts",description:"Add hostname mappings to the container network interface configuration."},gpus:{$ref:"#/$defs/gpus",description:"Define GPU devices to use. Can be set to 'all' to use all GPUs, or a list of specific GPU devices."},group_add:{type:"array",items:{type:["string","number"]},uniqueItems:!0,description:"Add additional groups which user inside the container should be member of."},healthcheck:{$ref:"#/$defs/healthcheck",description:"Configure a health check for the container to monitor its health status."},hostname:{type:"string",description:"Define a custom hostname for the service container."},image:{type:"string",description:"Specify the image to start the container from. Can be a repository/tag, a digest, or a local image ID."},init:{type:["boolean","string"],description:"Run as an init process inside the container that forwards signals and reaps processes."},ipc:{type:"string",description:"IPC sharing mode for the service container. Use 'host' to share the host's IPC namespace, 'service:[service_name]' to share with another service, or 'shareable' to allow other services to share this service's IPC namespace."},isolation:{type:"string",description:"Container isolation technology to use. Supported values are platform-specific."},labels:{$ref:"#/$defs/list_or_dict",description:"Add metadata to containers using Docker labels. You can use either an array or a list."},links:{type:"array",items:{type:"string"},uniqueItems:!0,description:"Link to containers in another service. Either specify both the service name and a link alias (SERVICE:ALIAS), or just the service name."},logging:{type:"object",description:"Logging configuration for the service.",properties:{driver:{type:"string",description:"Logging driver to use, such as 'json-file', 'syslog', 'journald', etc."},options:{type:"object",description:"Options for the logging driver.",patternProperties:{"^.+$":{type:["string","number","null"]}}}},additionalProperties:!1,patternProperties:{"^x-":{}}},mac_address:{type:"string",description:"Container MAC address to set."},mem_limit:{type:["number","string"],description:"Memory limit for the container. A string value can use suffix like '2g' for 2 gigabytes."},mem_reservation:{type:["string","integer"],description:"Memory reservation for the container."},mem_swappiness:{type:["integer","string"],description:"Container memory swappiness as percentage (0 to 100)."},memswap_limit:{type:["number","string"],description:"Amount of memory the container is allowed to swap to disk. Set to -1 to enable unlimited swap."},network_mode:{type:"string",description:"Network mode. Values can be 'bridge', 'host', 'none', 'service:[service name]', or 'container:[container name]'."},models:{oneOf:[{$ref:"#/$defs/list_of_strings"},{type:"object",patternProperties:{"^[a-zA-Z0-9._-]+$":{oneOf:[{type:"object",properties:{endpoint_var:{type:"string",description:"Environment variable set to AI model endpoint."},model_var:{type:"string",description:"Environment variable set to AI model name."}},additionalProperties:!1,patternProperties:{"^x-":{}}},{type:"null"}]}}}],description:"AI Models to use, referencing entries under the top-level models key."},networks:{oneOf:[{$ref:"#/$defs/list_of_strings"},{type:"object",patternProperties:{"^[a-zA-Z0-9._-]+$":{oneOf:[{type:"object",properties:{aliases:{$ref:"#/$defs/list_of_strings",description:"Alternative hostnames for this service on the network."},interface_name:{type:"string",description:"Interface network name used to connect to network"},ipv4_address:{type:"string",description:"Specify a static IPv4 address for this service on this network."},ipv6_address:{type:"string",description:"Specify a static IPv6 address for this service on this network."},link_local_ips:{$ref:"#/$defs/list_of_strings",description:"List of link-local IPs."},mac_address:{type:"string",description:"Specify a MAC address for this service on this network."},driver_opts:{type:"object",description:"Driver options for this network.",patternProperties:{"^.+$":{type:["string","number"]}}},priority:{type:"number",description:"Specify the priority for the network connection."},gw_priority:{type:"number",description:"Specify the gateway priority for the network connection."}},additionalProperties:!1,patternProperties:{"^x-":{}}},{type:"null"}]}},additionalProperties:!1}],description:"Networks to join, referencing entries under the top-level networks key. Can be a list of network names or a mapping of network name to network configuration."},oom_kill_disable:{type:["boolean","string"],description:"Disable OOM Killer for the container."},oom_score_adj:{oneOf:[{type:"string"},{type:"integer",minimum:-1000,maximum:1000}],description:"Tune host's OOM preferences for the container (accepts -1000 to 1000)."},pid:{type:["string","null"],description:"PID mode for container."},pids_limit:{type:["number","string"],description:"Tune a container's PIDs limit. Set to -1 for unlimited PIDs."},platform:{type:"string",description:"Target platform to run on, e.g., 'linux/amd64', 'linux/arm64', or 'windows/amd64'."},ports:{type:"array",description:"Expose container ports. Short format ([HOST:]CONTAINER[/PROTOCOL]).",items:{oneOf:[{type:"number"},{type:"string"},{type:"object",properties:{name:{type:"string",description:"A human-readable name for this port mapping."},mode:{type:"string",description:"The port binding mode, either 'host' for publishing a host port or 'ingress' for load balancing."},host_ip:{type:"string",description:"The host IP to bind to."},target:{type:["integer","string"],description:"The port inside the container."},published:{type:["string","integer"],description:"The publicly exposed port."},protocol:{type:"string",description:"The port protocol (tcp or udp)."},app_protocol:{type:"string",description:"Application protocol to use with the port (e.g., http, https, mysql)."}},additionalProperties:!1,patternProperties:{"^x-":{}}}]},uniqueItems:!0},pre_start:{type:"array",items:{$ref:"#/$defs/pre_start_hook"},description:"Init containers to run to completion before the service container is started. Each step runs in its own ephemeral container, in declared order; a non-zero exit fails the bring-up of the service and its dependents."},post_start:{type:"array",items:{$ref:"#/$defs/service_hook"},description:"Commands to run after the container starts. If any command fails, the container stops."},pre_stop:{type:"array",items:{$ref:"#/$defs/service_hook"},description:"Commands to run before the container stops. If any command fails, the container stop is aborted."},privileged:{type:["boolean","string"],description:"Give extended privileges to the service container."},profiles:{$ref:"#/$defs/list_of_strings",description:"List of profiles for this service. When profiles are specified, services are only started when the profile is activated."},pull_policy:{type:"string",pattern:"always|never|build|if_not_present|missing|refresh|daily|weekly|every_([0-9]+[wdhms])+",description:"Policy for pulling images. Options include: 'always', 'never', 'if_not_present', 'missing', 'build', or time-based refresh policies."},pull_refresh_after:{type:"string",description:"Time after which to refresh the image. Used with pull_policy=refresh."},read_only:{type:["boolean","string"],description:"Mount the container's filesystem as read only."},restart:{type:"string",description:"Restart policy for the service container. Options include: 'no', 'always', 'on-failure', and 'unless-stopped'."},runtime:{type:"string",description:"Runtime to use for this container, e.g., 'runc'."},scale:{type:["integer","string"],description:"Number of containers to deploy for this service."},security_opt:{type:"array",items:{type:"string"},uniqueItems:!0,description:"Override the default labeling scheme for each container."},shm_size:{type:["number","string"],description:"Size of /dev/shm. A string value can use suffix like '2g' for 2 gigabytes."},secrets:{$ref:"#/$defs/service_config_or_secret",description:"Grant access to Secrets on a per-service basis."},sysctls:{$ref:"#/$defs/list_or_dict",description:"Kernel parameters to set in the container. You can use either an array or a list."},stdin_open:{type:["boolean","string"],description:"Keep STDIN open even if not attached."},stop_grace_period:{type:"string",description:"Time to wait for the container to stop gracefully before sending SIGKILL (e.g., '1s', '1m30s')."},stop_signal:{type:"string",description:"Signal to stop the container (e.g., 'SIGTERM', 'SIGINT')."},storage_opt:{type:"object",description:"Storage driver options for the container."},tmpfs:{$ref:"#/$defs/string_or_list",description:"Mount a temporary filesystem (tmpfs) into the container. Can be a single value or a list."},tty:{type:["boolean","string"],description:"Allocate a pseudo-TTY to service container."},ulimits:{$ref:"#/$defs/ulimits",description:"Override the default ulimits for a container."},use_api_socket:{type:"boolean",description:"Bind mount Docker API socket and required auth."},user:{type:"string",description:"Username or UID to run the container process as."},uts:{type:"string",description:"UTS namespace to use. 'host' shares the host's UTS namespace."},userns_mode:{type:"string",description:"User namespace to use. 'host' shares the host's user namespace."},volumes:{type:"array",description:"Mount host paths or named volumes accessible to the container. Short syntax (VOLUME:CONTAINER_PATH[:MODE])",items:{oneOf:[{type:"string"},{type:"object",required:["type"],properties:{type:{type:"string",enum:["bind","volume","tmpfs","cluster","npipe","image"],description:"The mount type: bind for mounting host directories, volume for named volumes, tmpfs for temporary filesystems, cluster for cluster volumes, npipe for named pipes, or image for mounting from an image."},source:{type:"string",description:"The source of the mount, a path on the host for a bind mount, a docker image reference for an image mount, or the name of a volume defined in the top-level volumes key. Not applicable for a tmpfs mount."},target:{type:"string",description:"The path in the container where the volume is mounted."},read_only:{type:["boolean","string"],description:"Flag to set the volume as read-only."},consistency:{type:"string",description:"The consistency requirements for the mount. Available values are platform specific."},bind:{type:"object",description:"Configuration specific to bind mounts.",properties:{propagation:{type:"string",description:"The propagation mode for the bind mount: 'shared', 'slave', 'private', 'rshared', 'rslave', or 'rprivate'."},create_host_path:{type:["boolean","string"],description:"Create the host path if it doesn't exist."},recursive:{type:"string",enum:["enabled","disabled","writable","readonly"],description:"Recursively mount the source directory."},selinux:{type:"string",enum:["z","Z"],description:"SELinux relabeling options: 'z' for shared content, 'Z' for private unshared content."}},additionalProperties:!1,patternProperties:{"^x-":{}}},volume:{type:"object",description:"Configuration specific to volume mounts.",properties:{labels:{$ref:"#/$defs/list_or_dict",description:"Labels to apply to the volume."},nocopy:{type:["boolean","string"],description:"Flag to disable copying of data from a container when a volume is created."},subpath:{type:"string",description:"Path within the volume to mount instead of the volume root."}},additionalProperties:!1,patternProperties:{"^x-":{}}},tmpfs:{type:"object",description:"Configuration specific to tmpfs mounts.",properties:{size:{oneOf:[{type:"integer",minimum:0},{type:"string"}],description:"Size of the tmpfs mount in bytes."},mode:{type:["number","string"],description:"File mode of the tmpfs in octal."}},additionalProperties:!1,patternProperties:{"^x-":{}}},image:{type:"object",description:"Configuration specific to image mounts.",properties:{subpath:{type:"string",description:"Path within the image to mount instead of the image root."}},additionalProperties:!1,patternProperties:{"^x-":{}}}},additionalProperties:!1,patternProperties:{"^x-":{}}}]},uniqueItems:!0},volumes_from:{type:"array",items:{type:"string"},uniqueItems:!0,description:"Mount volumes from another service or container. Optionally specify read-only access (ro) or read-write (rw)."},working_dir:{type:"string",description:"The working directory in which the entrypoint or command will be run"}},patternProperties:{"^x-":{}},additionalProperties:!1},healthcheck:{type:"object",description:"Configuration options to determine whether the container is healthy.",properties:{disable:{type:["boolean","string"],description:"Disable any container-specified healthcheck. Set to true to disable."},interval:{type:"string",description:"Time between running the check (e.g., '1s', '1m30s'). Default: 30s."},retries:{type:["number","string"],description:"Number of consecutive failures needed to consider the container as unhealthy. Default: 3."},test:{oneOf:[{type:"string"},{type:"array",items:{type:"string"}}],description:"The test to perform to check container health. Can be a string or a list. The first item is either NONE, CMD, or CMD-SHELL. If it's CMD, the rest of the command is exec'd. If it's CMD-SHELL, the rest is run in the shell."},timeout:{type:"string",description:"Maximum time to allow one check to run (e.g., '1s', '1m30s'). Default: 30s."},start_period:{type:"string",description:"Start period for the container to initialize before starting health-retries countdown (e.g., '1s', '1m30s'). Default: 0s."},start_interval:{type:"string",description:"Time between running the check during the start period (e.g., '1s', '1m30s'). Default: interval value."}},additionalProperties:!1,patternProperties:{"^x-":{}}},development:{type:["object","null"],description:"Development configuration for the service, used for development workflows.",properties:{watch:{type:"array",description:"Configure watch mode for the service, which monitors file changes and performs actions in response.",items:{type:"object",required:["path","action"],properties:{ignore:{$ref:"#/$defs/string_or_list",description:"Patterns to exclude from watching."},include:{$ref:"#/$defs/string_or_list",description:"Patterns to include in watching."},path:{type:"string",description:"Path to watch for changes."},action:{type:"string",enum:["rebuild","sync","restart","sync+restart","sync+exec"],description:"Action to take when a change is detected: rebuild the container, sync files, restart the container, sync and restart, or sync and execute a command."},target:{type:"string",description:"Target path in the container for sync operations."},exec:{$ref:"#/$defs/service_hook",description:"Command to execute when a change is detected and action is sync+exec."},initial_sync:{type:"boolean",description:"Ensure that an initial synchronization is done before starting watch mode for sync+x triggers"}},additionalProperties:!1,patternProperties:{"^x-":{}}}}},additionalProperties:!1,patternProperties:{"^x-":{}}},deployment:{type:["object","null"],description:"Deployment configuration for the service.",properties:{mode:{type:"string",description:"Deployment mode for the service: 'replicated' (default) or 'global'."},endpoint_mode:{type:"string",description:"Endpoint mode for the service: 'vip' (default) or 'dnsrr'."},replicas:{type:["integer","string"],description:"Number of replicas of the service container to run."},labels:{$ref:"#/$defs/list_or_dict",description:"Labels to apply to the service."},rollback_config:{type:"object",description:"Configuration for rolling back a service update.",properties:{parallelism:{type:["integer","string"],description:"The number of containers to rollback at a time. If set to 0, all containers rollback simultaneously."},delay:{type:"string",description:"The time to wait between each container group's rollback (e.g., '1s', '1m30s')."},failure_action:{type:"string",description:"Action to take if a rollback fails: 'continue', 'pause'."},monitor:{type:"string",description:"Duration to monitor each task for failures after it is created (e.g., '1s', '1m30s')."},max_failure_ratio:{type:["number","string"],description:"Failure rate to tolerate during a rollback."},order:{type:"string",enum:["start-first","stop-first"],description:"Order of operations during rollbacks: 'stop-first' (default) or 'start-first'."}},additionalProperties:!1,patternProperties:{"^x-":{}}},update_config:{type:"object",description:"Configuration for updating a service.",properties:{parallelism:{type:["integer","string"],description:"The number of containers to update at a time."},delay:{type:"string",description:"The time to wait between updating a group of containers (e.g., '1s', '1m30s')."},failure_action:{type:"string",description:"Action to take if an update fails: 'continue', 'pause', 'rollback'."},monitor:{type:"string",description:"Duration to monitor each updated task for failures after it is created (e.g., '1s', '1m30s')."},max_failure_ratio:{type:["number","string"],description:"Failure rate to tolerate during an update (0 to 1)."},order:{type:"string",enum:["start-first","stop-first"],description:"Order of operations during updates: 'stop-first' (default) or 'start-first'."}},additionalProperties:!1,patternProperties:{"^x-":{}}},resources:{type:"object",description:"Resource constraints and reservations for the service.",properties:{limits:{type:"object",description:"Resource limits for the service containers.",properties:{cpus:{type:["number","string"],description:"Limit for how much of the available CPU resources, as number of cores, a container can use."},memory:{type:"string",description:"Limit on the amount of memory a container can allocate (e.g., '1g', '1024m')."},pids:{type:["integer","string"],description:"Maximum number of PIDs available to the container."}},additionalProperties:!1,patternProperties:{"^x-":{}}},reservations:{type:"object",description:"Resource reservations for the service containers.",properties:{cpus:{type:["number","string"],description:"Reservation for how much of the available CPU resources, as number of cores, a container can use."},memory:{type:"string",description:"Reservation on the amount of memory a container can allocate (e.g., '1g', '1024m')."},generic_resources:{$ref:"#/$defs/generic_resources",description:"User-defined resources to reserve."},devices:{$ref:"#/$defs/devices",description:"Device reservations for the container."}},additionalProperties:!1,patternProperties:{"^x-":{}}}},additionalProperties:!1,patternProperties:{"^x-":{}}},restart_policy:{type:"object",description:"Restart policy for the service containers.",properties:{condition:{type:"string",description:"Condition for restarting the container: 'none', 'on-failure', 'any'."},delay:{type:"string",description:"Delay between restart attempts (e.g., '1s', '1m30s')."},max_attempts:{type:["integer","string"],description:"Maximum number of restart attempts before giving up."},window:{type:"string",description:"Time window used to evaluate the restart policy (e.g., '1s', '1m30s')."}},additionalProperties:!1,patternProperties:{"^x-":{}}},placement:{type:"object",description:"Constraints and preferences for the platform to select a physical node to run service containers",properties:{constraints:{type:"array",items:{type:"string"},description:"Placement constraints for the service (e.g., 'node.role==manager')."},preferences:{type:"array",description:"Placement preferences for the service.",items:{type:"object",properties:{spread:{type:"string",description:"Spread tasks evenly across values of the specified node label."}},additionalProperties:!1,patternProperties:{"^x-":{}}}},max_replicas_per_node:{type:["integer","string"],description:"Maximum number of replicas of the service."}},additionalProperties:!1,patternProperties:{"^x-":{}}}},additionalProperties:!1,patternProperties:{"^x-":{}}},generic_resources:{type:"array",description:"User-defined resources for services, allowing services to reserve specialized hardware resources.",items:{type:"object",properties:{discrete_resource_spec:{type:"object",description:"Specification for discrete (countable) resources.",properties:{kind:{type:"string",description:"Type of resource (e.g., 'GPU', 'FPGA', 'SSD')."},value:{type:["number","string"],description:"Number of resources of this kind to reserve."}},additionalProperties:!1,patternProperties:{"^x-":{}}}},additionalProperties:!1,patternProperties:{"^x-":{}}}},devices:{type:"array",description:"Device reservations for containers, allowing services to access specific hardware devices.",items:{type:"object",properties:{capabilities:{$ref:"#/$defs/list_of_strings",description:"List of capabilities the device needs to have (e.g., 'gpu', 'compute', 'utility')."},count:{type:["string","integer"],description:"Number of devices of this type to reserve."},device_ids:{$ref:"#/$defs/list_of_strings",description:"List of specific device IDs to reserve."},driver:{type:"string",description:"Device driver to use (e.g., 'nvidia')."},options:{$ref:"#/$defs/list_or_dict",description:"Driver-specific options for the device."}},additionalProperties:!1,patternProperties:{"^x-":{}},required:["capabilities"]}},gpus:{oneOf:[{type:"string",enum:["all"],description:"Use all available GPUs."},{type:"array",description:"List of specific GPU devices to use.",items:{type:"object",properties:{capabilities:{$ref:"#/$defs/list_of_strings",description:"List of capabilities the GPU needs to have (e.g., 'compute', 'utility')."},count:{type:["string","integer"],description:"Number of GPUs to use."},device_ids:{$ref:"#/$defs/list_of_strings",description:"List of specific GPU device IDs to use."},driver:{type:"string",description:"GPU driver to use (e.g., 'nvidia')."},options:{$ref:"#/$defs/list_or_dict",description:"Driver-specific options for the GPU."}}},additionalProperties:!1,patternProperties:{"^x-":{}}}]},include:{description:"Compose application or sub-projects to be included.",oneOf:[{type:"string"},{type:"object",properties:{path:{$ref:"#/$defs/string_or_list",description:"Path to the Compose application or sub-project files to include."},env_file:{$ref:"#/$defs/string_or_list",description:"Path to the environment files to use to define default values when interpolating variables in the Compose files being parsed."},project_directory:{type:"string",description:"Path to resolve relative paths set in the Compose file"}},additionalProperties:!1}]},network:{type:["object","null"],description:"Network configuration for the Compose application.",properties:{name:{type:"string",description:"Custom name for this network."},driver:{type:"string",description:"Specify which driver should be used for this network. Default is 'bridge'."},driver_opts:{type:"object",description:"Specify driver-specific options defined as key/value pairs.",patternProperties:{"^.+$":{type:["string","number"]}}},ipam:{type:"object",description:"Custom IP Address Management configuration for this network.",properties:{driver:{type:"string",description:"Custom IPAM driver, instead of the default."},config:{type:"array",description:"List of IPAM configuration blocks.",items:{type:"object",properties:{subnet:{type:"string",description:"Subnet in CIDR format that represents a network segment."},ip_range:{type:"string",description:"Range of IPs from which to allocate container IPs."},gateway:{type:"string",description:"IPv4 or IPv6 gateway for the subnet."},aux_addresses:{type:"object",description:"Auxiliary IPv4 or IPv6 addresses used by Network driver.",additionalProperties:!1,patternProperties:{"^.+$":{type:"string"}}}},additionalProperties:!1,patternProperties:{"^x-":{}}}},options:{type:"object",description:"Driver-specific options for the IPAM driver.",additionalProperties:!1,patternProperties:{"^.+$":{type:"string"}}}},additionalProperties:!1,patternProperties:{"^x-":{}}},external:{type:["boolean","string","object"],description:"Specifies that this network already exists and was created outside of Compose.",properties:{name:{deprecated:!0,type:"string",description:"Specifies the name of the external network. Deprecated: use the 'name' property instead."}},additionalProperties:!1,patternProperties:{"^x-":{}}},internal:{type:["boolean","string"],description:"Create an externally isolated network."},enable_ipv4:{type:["boolean","string"],description:"Enable IPv4 networking."},enable_ipv6:{type:["boolean","string"],description:"Enable IPv6 networking."},attachable:{type:["boolean","string"],description:"If true, standalone containers can attach to this network."},labels:{$ref:"#/$defs/list_or_dict",description:"Add metadata to the network using labels."}},additionalProperties:!1,patternProperties:{"^x-":{}}},volume:{type:["object","null"],description:"Volume configuration for the Compose application.",properties:{name:{type:"string",description:"Custom name for this volume."},driver:{type:"string",description:"Specify which volume driver should be used for this volume."},driver_opts:{type:"object",description:"Specify driver-specific options.",patternProperties:{"^.+$":{type:["string","number"]}}},external:{type:["boolean","string","object"],description:"Specifies that this volume already exists and was created outside of Compose.",properties:{name:{deprecated:!0,type:"string",description:"Specifies the name of the external volume. Deprecated: use the 'name' property instead."}},additionalProperties:!1,patternProperties:{"^x-":{}}},labels:{$ref:"#/$defs/list_or_dict",description:"Add metadata to the volume using labels."}},additionalProperties:!1,patternProperties:{"^x-":{}}},secret:{type:"object",description:"Secret configuration for the Compose application.",properties:{name:{type:"string",description:"Custom name for this secret."},environment:{type:"string",description:"Name of an environment variable from which to get the secret value."},file:{type:"string",description:"Path to a file containing the secret value."},external:{type:["boolean","string","object"],description:"Specifies that this secret already exists and was created outside of Compose.",properties:{name:{type:"string",description:"Specifies the name of the external secret."}}},labels:{$ref:"#/$defs/list_or_dict",description:"Add metadata to the secret using labels."},driver:{type:"string",description:"Specify which secret driver should be used for this secret."},driver_opts:{type:"object",description:"Specify driver-specific options.",patternProperties:{"^.+$":{type:["string","number"]}}},template_driver:{type:"string",description:"Driver to use for templating the secret's value."}},additionalProperties:!1,patternProperties:{"^x-":{}}},config:{type:"object",description:"Config configuration for the Compose application.",properties:{name:{type:"string",description:"Custom name for this config."},content:{type:"string",description:"Inline content of the config."},environment:{type:"string",description:"Name of an environment variable from which to get the config value."},file:{type:"string",description:"Path to a file containing the config value."},external:{type:["boolean","string","object"],description:"Specifies that this config already exists and was created outside of Compose.",properties:{name:{deprecated:!0,type:"string",description:"Specifies the name of the external config. Deprecated: use the 'name' property instead."}}},labels:{$ref:"#/$defs/list_or_dict",description:"Add metadata to the config using labels."},template_driver:{type:"string",description:"Driver to use for templating the config's value."}},additionalProperties:!1,patternProperties:{"^x-":{}}},model:{type:"object",description:"Language Model for the Compose application.",properties:{name:{type:"string",description:"Custom name for this model."},model:{type:"string",description:"Language Model to run."},context_size:{type:"integer"},runtime_flags:{type:"array",items:{type:"string"},description:"Raw runtime flags to pass to the inference engine."}},required:["model"],additionalProperties:!1,patternProperties:{"^x-":{}}},command:{oneOf:[{type:"null",description:"No command specified, use the container's default command."},{type:"string",description:"Command as a string, which will be executed in a shell (e.g., '/bin/sh -c')."},{type:"array",description:"Command as an array of strings, which will be executed directly without a shell.",items:{type:"string",description:"Part of the command (executable or argument)."}}],description:"Command to run in the container, which can be specified as a string (shell form) or array (exec form)."},service_hook:{type:"object",description:"Configuration for service lifecycle hooks, which are commands executed at specific points in a container's lifecycle.",properties:{command:{$ref:"#/$defs/command",description:"Command to execute as part of the hook."},user:{type:"string",description:"User to run the command as."},privileged:{type:["boolean","string"],description:"Whether to run the command with extended privileges."},working_dir:{type:"string",description:"Working directory for the command."},environment:{$ref:"#/$defs/list_or_dict",description:"Environment variables for the command."}},additionalProperties:!1,patternProperties:{"^x-":{}},required:["command"]},pre_start_hook:{type:"object",description:"Configuration for a pre_start init container, run to completion before the service container starts.",properties:{command:{$ref:"#/$defs/command",description:"Command to execute. Optional when the chosen image's entrypoint already runs the intended command."},image:{type:"string",description:"Image used for the ephemeral container. If omitted, the parent service's image is used."},user:{type:"string",description:"User to run the command as. Defaults to the user declared in image (or to the service's user when image is omitted)."},privileged:{type:["boolean","string"],description:"Whether to run the command with extended privileges."},working_dir:{type:"string",description:"Working directory for the command. Defaults to the service's working directory."},environment:{$ref:"#/$defs/list_or_dict",description:"Environment variables for the command. Appended to or overriding the service environment."},per_replica:{type:["boolean","string"],description:"Whether the hook runs once per service replica (true), or once for the service as a whole before any replica starts (false, the default)."}},additionalProperties:!1,patternProperties:{"^x-":{}}},env_file:{oneOf:[{type:"string",description:"Path to a file containing environment variables."},{type:"array",description:"List of paths to files containing environment variables.",items:{oneOf:[{type:"string",description:"Path to a file containing environment variables."},{type:"object",description:"Detailed configuration for an environment file.",additionalProperties:!1,properties:{path:{type:"string",description:"Path to the environment file."},format:{type:"string",description:"Format attribute lets you to use an alternative file formats for env_file. When not set, env_file is parsed according to Compose rules."},required:{type:["boolean","string"],default:!0,description:"Whether the file is required. If true and the file doesn't exist, an error will be raised."}},required:["path"]}]}}]},label_file:{oneOf:[{type:"string",description:"Path to a file containing Docker labels."},{type:"array",description:"List of paths to files containing Docker labels.",items:{type:"string",description:"Path to a file containing Docker labels."}}]},string_or_list:{oneOf:[{type:"string",description:"A single string value."},{$ref:"#/$defs/list_of_strings",description:"A list of string values."}],description:"Either a single string or a list of strings."},list_of_strings:{type:"array",description:"A list of unique string values.",items:{type:"string",description:"A string value in the list."},uniqueItems:!0},list_or_dict:{oneOf:[{type:"object",description:"A dictionary mapping keys to values.",patternProperties:{".+":{type:["string","number","boolean","null"],description:"Value for the key, which can be a string, number, boolean, or null."}},additionalProperties:!1},{type:"array",description:"A list of unique string values.",items:{type:"string",description:"A string value in the list."},uniqueItems:!0}],description:"Either a dictionary mapping keys to values, or a list of strings."},extra_hosts:{oneOf:[{type:"object",description:"list mapping hostnames to IP addresses.",patternProperties:{".+":{oneOf:[{type:"string",description:"IP address for the hostname."},{type:"array",description:"List of IP addresses for the hostname.",items:{type:"string",description:"IP address for the hostname."},uniqueItems:!1}]}},additionalProperties:!1},{type:"array",description:"List of host:IP mappings in the format 'hostname:IP'.",items:{type:"string",description:"Host:IP mapping in the format 'hostname:IP'."},uniqueItems:!0}],description:"Additional hostnames to be defined in the container's /etc/hosts file."},blkio_limit:{type:"object",description:"Block IO limit for a specific device.",properties:{path:{type:"string",description:"Path to the device (e.g., '/dev/sda')."},rate:{type:["integer","string"],description:"Rate limit in bytes per second or IO operations per second."}},additionalProperties:!1},blkio_weight:{type:"object",description:"Block IO weight for a specific device.",properties:{path:{type:"string",description:"Path to the device (e.g., '/dev/sda')."},weight:{type:["integer","string"],description:"Relative weight for the device, between 10 and 1000."}},additionalProperties:!1},service_config_or_secret:{type:"array",description:"Configuration for service configs or secrets, defining how they are mounted in the container.",items:{oneOf:[{type:"string",description:"Name of the config or secret to grant access to."},{type:"object",description:"Detailed configuration for a config or secret.",properties:{source:{type:"string",description:"Name of the config or secret as defined in the top-level configs or secrets section."},target:{type:"string",description:"Path in the container where the config or secret will be mounted. Defaults to /<source> for configs and /run/secrets/<source> for secrets."},uid:{type:"string",description:"UID of the file in the container. Default is 0 (root)."},gid:{type:"string",description:"GID of the file in the container. Default is 0 (root)."},mode:{type:["number","string"],description:"File permission mode inside the container, in octal. Default is 0444 for configs and 0400 for secrets."}},additionalProperties:!1,patternProperties:{"^x-":{}}}]}},ulimits:{type:"object",description:"Container ulimit options, controlling resource limits for processes inside the container.",patternProperties:{"^[a-z]+$":{oneOf:[{type:["integer","string"],description:"Single value for both soft and hard limits."},{type:"object",description:"Separate soft and hard limits.",properties:{hard:{type:["integer","string"],description:"Hard limit for the ulimit type. This is the maximum allowed value."},soft:{type:["integer","string"],description:"Soft limit for the ulimit type. This is the value that's actually enforced."}},required:["soft","hard"],additionalProperties:!1,patternProperties:{"^x-":{}}}]}}}}}});import{readdir as uv}from"fs/promises";import{join as lv}from"path";var{file:pv,YAML:dv}=globalThis.Bun;function mv(){if(!Io)Io=Promise.resolve().then(() => (gm(),{})).then(({})=>Nf(hm)).catch((e)=>{throw Io=void 0,e});return Io}function ym(e){return pv(e).text().then(dv.parse).then(async(t)=>(await mv()).parse(t))}async function bm(e){return(await uv(e,{withFileTypes:!0})).filter((r)=>r.isFile()&&fv.has(r.name)).map((r)=>lv(e,r.name)).sort()[0]}var fv,Io;var _m=_(()=>{Ms();fv=new Set(["compose.yml","compose.yaml","docker-compose.yml","docker-compose.yaml"])});import{AsyncLocalStorage as hv}from"async_hooks";function gv(e,t){if(e.projectConfigured)return e.project;return t.name?.trim()||e.project}async function vm(e,t){let r=process.cwd(),o=await fm(r,t),n=Bo("composeFile",()=>o.composeFile?Promise.resolve(o.composeFile):bm(r)),i=Bo("parsedCompose",async()=>{let c=await n();if(!c)throw Error("Compose file cannot be found");return ym(c)});if(!o.projectConfigured){if(await n())o.project=gv(o,await i())}let s=Bo("hookContext",async()=>{let c=await n();if(!c)throw Error("Compose file cannot be found");return mm(o,r,c)}),a=Bo("compose",async()=>{let c=await s(),u=await i();return await o.compose?.(u,c),u});return await wm.run({project:o.project,cwd:r,config:o,path:n,hookContext:s,compose:a},e)}function D(){let e=wm.getStore();if(!e)throw Error("Not in context!");return e}function Bo(e,t){let r;return()=>(r??=t().catch((o)=>{throw r=void 0,o}),r)}var wm;var oe=_(()=>{Oo();_m();wm=new hv});import{createHash as yv,randomUUID as bv}from"crypto";import{chmod as xm,mkdir as _v,readFile as wv,realpath as vv,rename as xv,writeFile as Ev}from"fs/promises";import{join as Em}from"path";function $m(){return Em(process.env.XDG_CONFIG_HOME??Em(process.env.HOME??"/tmp",".config"),"kuber","trust.json")}async function bt(e,t=process.cwd()){let r=await vv(t);return{project:e,fingerprint:yv("sha256").update(r).digest("hex")}}function Sv(e){return!!e&&typeof e==="object"&&typeof e.project==="string"&&typeof e.fingerprint==="string"&&/^[a-f0-9]{64}$/.test(e.fingerprint)}async function zo(){try{let e=JSON.parse(await wv($m(),"utf8"));if(!e||typeof e!=="object"||e.version!==Sm||!Array.isArray(e.records))return[];return e.records.filter(Sv)}catch{return[]}}async function $v(e){let t=$m(),r=t.slice(0,t.lastIndexOf("/"));await _v(r,{recursive:!0,mode:448}),await xm(r,448);let o=`${t}.${bv()}.tmp`;await Ev(o,JSON.stringify({version:Sm,records:e},null,2)+`
|
|
80
80
|
`,{flag:"wx",mode:384}),await xv(o,t),await xm(t,384)}async function ea(e){await $v(e(await zo()))}function Am(e){return{"x-kuber-trust-project":e.project,"x-kuber-trust-fingerprint":e.fingerprint}}async function km(e){let t=(await zo()).find((r)=>r.project===e.project&&r.fingerprint===e.fingerprint);if(t)return t;throw Error("TRUST_REQUIRED: this directory is not trusted for this namespace. Run kuber trust before kuber up.")}var Sm=1;var Do=()=>{};var _t,a0,c0,u0,l0,p0,d0,f0,m0,h0,nr,g0,y0,b0,_0,w0;var Pm=_(()=>{_t=globalThis.window?.document!==void 0,a0=globalThis.process?.versions?.node!==void 0,c0=globalThis.process?.versions?.bun!==void 0,u0=globalThis.Deno?.version?.deno!==void 0,l0=globalThis.process?.versions?.electron!==void 0,p0=globalThis.navigator?.userAgent?.includes("jsdom")===!0,d0=typeof WorkerGlobalScope<"u"&&globalThis instanceof WorkerGlobalScope,f0=typeof DedicatedWorkerGlobalScope<"u"&&globalThis instanceof DedicatedWorkerGlobalScope,m0=typeof SharedWorkerGlobalScope<"u"&&globalThis instanceof SharedWorkerGlobalScope,h0=typeof ServiceWorkerGlobalScope<"u"&&globalThis instanceof ServiceWorkerGlobalScope,nr=globalThis.navigator?.userAgentData?.platform,g0=nr==="macOS"||globalThis.navigator?.platform==="MacIntel"||globalThis.navigator?.userAgent?.includes(" Mac ")===!0||globalThis.process?.platform==="darwin",y0=nr==="Windows"||globalThis.navigator?.platform==="Win32"||globalThis.process?.platform==="win32",b0=nr==="Linux"||globalThis.navigator?.platform?.startsWith("Linux")===!0||globalThis.navigator?.userAgent?.includes(" Linux ")===!0||globalThis.process?.platform==="linux",_0=nr==="iOS"||globalThis.navigator?.platform==="MacIntel"&&globalThis.navigator?.maxTouchPoints>1||/iPad|iPhone|iPod/.test(globalThis.navigator?.platform),w0=nr==="Android"||globalThis.navigator?.platform==="Android"||globalThis.navigator?.userAgent?.includes(" Android ")===!0||globalThis.process?.platform==="android"});import wt from"process";import Av from"os";var M="\x1B[",Cm,kv,$0,A0,No=(e=1)=>M+e+"A",ra=(e=1)=>M+e+"B",oa,k0,P0,C0,R0,T0,O0,I0,ir=(e)=>{let t="";for(let r=0;r<e;r++)t+=Rm+(r<e-1?No():"");if(e)t+=oa;return t},Pv,B0,Rm,z0,D0,ta,N0,L0,V0,Cv=()=>{if(_t||!kv)return!1;let e=Av.release().split("."),t=Number(e[0]),r=Number(e[2]??0);if(t<10)return!0;if(t===10&&r<10586)return!0;return!1},U0,M0,F0,j0,Z0;var na=_(()=>{Pm();Cm=!_t&&wt.env.TERM_PROGRAM==="Apple_Terminal",kv=!_t&&wt.platform==="win32",$0=!_t&&(wt.env.TERM?.startsWith("screen")||wt.env.TERM?.startsWith("tmux")||wt.env.TMUX!==void 0),A0=_t?()=>{throw Error("`process.cwd()` only works in Node.js, not the browser.")}:wt.cwd,oa=M+"G",k0=Cm?"\x1B7":M+"s",P0=Cm?"\x1B8":M+"u",C0=M+"6n",R0=M+"E",T0=M+"F",O0=M+"?25l",I0=M+"?25h",Pv=M+"K",B0=M+"1K",Rm=M+"2K",z0=M+"J",D0=M+"1J",ta=M+"2J",N0=M+"S",L0=M+"T",V0=`${ta}${M}H`,U0=Cv()?`${ta}${M}0f`:`${ta}${M}3J${M}H`,M0=M+"?1049h",F0=M+"?1049l",j0=M+"?2026h",Z0=M+"?2026l"});var Om=_(()=>{na();na()});function ia(e,t,{ignoreNonConfigurable:r=!1}={}){let{name:o}=e;for(let n of Reflect.ownKeys(t))Rv(e,t,n,r);return Ov(e,t),Dv(e,t,o),e}var Rv=(e,t,r,o)=>{if(r==="length"||r==="prototype")return;if(r==="arguments"||r==="caller")return;let n=Object.getOwnPropertyDescriptor(e,r),i=Object.getOwnPropertyDescriptor(t,r);if(!Tv(n,i)&&o)return;Object.defineProperty(e,r,i)},Tv=function(e,t){return e===void 0||e.configurable||e.writable===t.writable&&e.enumerable===t.enumerable&&e.configurable===t.configurable&&(e.writable||e.value===t.value)},Ov=(e,t)=>{let r=Object.getPrototypeOf(t);if(r===Object.getPrototypeOf(e))return;Object.setPrototypeOf(e,r)},Iv=(e,t)=>`/* Wrapped ${e}*/
|
|
81
81
|
${t}`,Bv,zv,Dv=(e,t,r)=>{let o=r===""?"":`with ${r.trim()}() `,n=Iv.bind(null,o,t.toString());Object.defineProperty(n,"name",zv);let{writable:i,enumerable:s,configurable:a}=Bv;Object.defineProperty(e,"toString",{value:n,writable:i,enumerable:s,configurable:a})};var Im=_(()=>{Bv=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),zv=Object.getOwnPropertyDescriptor(Function.prototype.toString,"name")});var Lo,Bm=(e,t={})=>{if(typeof e!=="function")throw TypeError("Expected a function");let r,o=0,n=e.displayName||e.name||"<anonymous>",i=function(...s){if(Lo.set(i,++o),o===1)r=e.apply(this,s),e=void 0;else if(t.throw===!0)throw Error(`Function \`${n}\` can only be called once`);return r};return ia(i,e),Lo.set(i,o),i},zm;var Dm=_(()=>{Im();Lo=new WeakMap;Bm.callCount=(e)=>{if(!Lo.has(e))throw Error(`The given function \`${e.name}\` is not wrapped by the \`onetime\` package`);return Lo.get(e)};zm=Bm});var nt;var Nm=_(()=>{nt=[];nt.push("SIGHUP","SIGINT","SIGTERM");if(process.platform!=="win32")nt.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");if(process.platform==="linux")nt.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT")});class Lm{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(aa[sa])return aa[sa];Nv(aa,sa,{value:this,writable:!1,enumerable:!1,configurable:!1})}on(e,t){this.listeners[e].push(t)}removeListener(e,t){let r=this.listeners[e],o=r.indexOf(t);if(o===-1)return;if(o===0&&r.length===1)r.length=0;else r.splice(o,1)}emit(e,t,r){if(this.emitted[e])return!1;this.emitted[e]=!0;let o=!1;for(let n of this.listeners[e])o=n(t,r)===!0||o;if(e==="exit")o=this.emit("afterExit",t,r)||o;return o}}class ua{}var Vo=(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",sa,aa,Nv,Lv=(e)=>({onExit(t,r){return e.onExit(t,r)},load(){return e.load()},unload(){return e.unload()}}),Vm,Um,ca,Mm,Y0,X0;var Fm=_(()=>{Nm();sa=Symbol.for("signal-exit emitter"),aa=globalThis,Nv=Object.defineProperty.bind(Object);Vm=class Vm extends ua{onExit(){return()=>{}}load(){}unload(){}};Um=class Um extends ua{#t=ca.platform==="win32"?"SIGINT":"SIGHUP";#r=new Lm;#e;#o;#s;#i={};#n=!1;constructor(e){super();this.#e=e,this.#i={};for(let t of nt)this.#i[t]=()=>{let r=this.#e.listeners(t),{count:o}=this.#r,n=e;if(typeof n.__signal_exit_emitter__==="object"&&typeof n.__signal_exit_emitter__.count==="number")o+=n.__signal_exit_emitter__.count;if(r.length===o){this.unload();let i=this.#r.emit("exit",null,t),s=t==="SIGHUP"?this.#t:t;if(!i)e.kill(e.pid,s)}};this.#s=e.reallyExit,this.#o=e.emit}onExit(e,t){if(!Vo(this.#e))return()=>{};if(this.#n===!1)this.load();let r=t?.alwaysLast?"afterExit":"exit";return this.#r.on(r,e),()=>{if(this.#r.removeListener(r,e),this.#r.listeners.exit.length===0&&this.#r.listeners.afterExit.length===0)this.unload()}}load(){if(this.#n)return;this.#n=!0,this.#r.count+=1;for(let e of nt)try{let t=this.#i[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,nt.forEach((e)=>{let t=this.#i[e];if(!t)throw Error("Listener not defined for signal: "+e);try{this.#e.removeListener(e,t)}catch(r){}}),this.#e.emit=this.#o,this.#e.reallyExit=this.#s,this.#r.count-=1}#a(e){if(!Vo(this.#e))return 0;return this.#e.exitCode=e||0,this.#r.emit("exit",this.#e.exitCode,null),this.#s.call(this.#e,this.#e.exitCode)}#c(e,...t){let r=this.#o;if(e==="exit"&&Vo(this.#e)){if(typeof t[0]==="number")this.#e.exitCode=t[0];let o=r.call(this.#e,e,...t);return this.#r.emit("exit",this.#e.exitCode,null),o}else return r.call(this.#e,e,...t)}};ca=globalThis.process,{onExit:Mm,load:Y0,unload:X0}=Lv(Vo(ca)?new Um(ca):new Vm)});import Uo from"process";var jm,Vv,Zm;var qm=_(()=>{Dm();Fm();jm=Uo.stderr.isTTY?Uo.stderr:Uo.stdout.isTTY?Uo.stdout:void 0,Vv=jm?zm(()=>{Mm(()=>{jm.write("\x1B[?25h")},{alwaysLast:!0})}):()=>{},Zm=Vv});import Qm from"process";var Mo=!1,vt,la;var Wm=_(()=>{qm();vt={};vt.show=(e=Qm.stderr)=>{if(!e.isTTY)return;Mo=!1,e.write("\x1B[?25h")};vt.hide=(e=Qm.stderr)=>{if(!e.isTTY)return;Zm(),Mo=!0,e.write("\x1B[?25l")};vt.toggle=(e,t)=>{if(e!==void 0)Mo=e;if(Mo)vt.show(t);else vt.hide(t)};la=vt});function pa({onlyFirst:e=!1}={}){return new RegExp("(?:\\u001B\\][\\s\\S]*?(?:\\u0007|\\u001B\\u005C|\\u009C))|[\\u001B\\u009B][[\\]()#;?]*(?:\\d{1,4}(?:[;:]\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]",e?void 0:"g")}function qe(e){if(typeof e!=="string")throw TypeError(`Expected a \`string\`, got \`${typeof e}\``);if(!e.includes("\x1B")&&!e.includes("\x9B"))return e;return e.replace(Uv,"")}var Uv;var Fo=_(()=>{Uv=pa()});var Gm=161,Km=1114109,Hm,Jm=12288,Ym=65510,Xm,eh=4352,th=262141,da;var rh=_(()=>{Hm=[161,161,164,164,167,168,170,170,173,174,176,180,182,186,188,191,198,198,208,208,215,216,222,225,230,230,232,234,236,237,240,240,242,243,247,250,252,252,254,254,257,257,273,273,275,275,283,283,294,295,299,299,305,307,312,312,319,322,324,324,328,331,333,333,338,339,358,359,363,363,462,462,464,464,466,466,468,468,470,470,472,472,474,474,476,476,593,593,609,609,708,708,711,711,713,715,717,717,720,720,728,731,733,733,735,735,768,879,913,929,931,937,945,961,963,969,1025,1025,1040,1103,1105,1105,8208,8208,8211,8214,8216,8217,8220,8221,8224,8226,8228,8231,8240,8240,8242,8243,8245,8245,8251,8251,8254,8254,8308,8308,8319,8319,8321,8324,8364,8364,8451,8451,8453,8453,8457,8457,8467,8467,8470,8470,8481,8482,8486,8486,8491,8491,8531,8532,8539,8542,8544,8555,8560,8569,8585,8585,8592,8601,8632,8633,8658,8658,8660,8660,8679,8679,8704,8704,8706,8707,8711,8712,8715,8715,8719,8719,8721,8721,8725,8725,8730,8730,8733,8736,8739,8739,8741,8741,8743,8748,8750,8750,8756,8759,8764,8765,8776,8776,8780,8780,8786,8786,8800,8801,8804,8807,8810,8811,8814,8815,8834,8835,8838,8839,8853,8853,8857,8857,8869,8869,8895,8895,8978,8978,9312,9449,9451,9547,9552,9587,9600,9615,9618,9621,9632,9633,9635,9641,9650,9651,9654,9655,9660,9661,9664,9665,9670,9672,9675,9675,9678,9681,9698,9701,9711,9711,9733,9734,9737,9737,9742,9743,9756,9756,9758,9758,9792,9792,9794,9794,9824,9825,9827,9829,9831,9834,9836,9837,9839,9839,9886,9887,9919,9919,9926,9933,9935,9939,9941,9953,9955,9955,9960,9961,9963,9969,9972,9972,9974,9977,9979,9980,9982,9983,10045,10045,10102,10111,11094,11097,12872,12879,57344,63743,65024,65039,65533,65533,127232,127242,127248,127277,127280,127337,127344,127373,127375,127376,127387,127404,917760,917999,983040,1048573,1048576,1114109],Xm=[12288,12288,65281,65376,65504,65510],da=[4352,4447,8986,8987,9001,9002,9193,9196,9200,9200,9203,9203,9725,9726,9748,9749,9776,9783,9800,9811,9855,9855,9866,9871,9875,9875,9889,9889,9898,9899,9917,9918,9924,9925,9934,9934,9940,9940,9962,9962,9970,9971,9973,9973,9978,9978,9981,9981,9989,9989,9994,9995,10024,10024,10060,10060,10062,10062,10067,10069,10071,10071,10133,10135,10160,10160,10175,10175,11035,11036,11088,11088,11093,11093,11904,11929,11931,12019,12032,12245,12272,12287,12289,12350,12353,12438,12441,12543,12549,12591,12593,12686,12688,12773,12783,12830,12832,12871,12880,42124,42128,42182,43360,43388,44032,55203,63744,64255,65040,65049,65072,65106,65108,65126,65128,65131,94176,94180,94192,94198,94208,101589,101631,101662,101760,101874,110576,110579,110581,110587,110589,110590,110592,110882,110898,110898,110928,110930,110933,110933,110948,110951,110960,111355,119552,119638,119648,119670,126980,126980,127183,127183,127374,127374,127377,127386,127488,127490,127504,127547,127552,127560,127568,127569,127584,127589,127744,127776,127789,127797,127799,127868,127870,127891,127904,127946,127951,127955,127968,127984,127988,127988,127992,128062,128064,128064,128066,128252,128255,128317,128331,128334,128336,128359,128378,128378,128405,128406,128420,128420,128507,128591,128640,128709,128716,128716,128720,128722,128725,128728,128732,128735,128747,128748,128756,128764,128992,129003,129008,129008,129292,129338,129340,129349,129351,129535,129648,129660,129664,129674,129678,129734,129736,129736,129741,129756,129759,129770,129775,129784,131072,196605,196608,262141]});var jo=(e,t)=>{let r=0,o=Math.floor(e.length/2)-1;while(r<=o){let n=Math.floor((r+o)/2),i=n*2;if(t<e[i])o=n-1;else if(t>e[i+1])r=n+1;else return!0}return!1};function jv(e){let t=e[0],r=e[1];for(let o=0;o<e.length;o+=2){let n=e[o],i=e[o+1];if(oh>=n&&oh<=i)return[n,i];if(i-n>r-t)t=n,r=i}return[t,r]}var oh=19968,Mv,Fv,nh=(e)=>{if(e<Gm||e>Km)return!1;return jo(Hm,e)},sr=(e)=>{if(e<Jm||e>Ym)return!1;return jo(Xm,e)},ar=(e)=>{if(e>=Mv&&e<=Fv)return!0;if(e<eh||e>th)return!1;return jo(da,e)};var fa=_(()=>{rh();[Mv,Fv]=jv(da)});function Zv(e){if(!Number.isSafeInteger(e))throw TypeError(`Expected a code point, got \`${typeof e}\`.`)}function cr(e,{ambiguousAsWide:t=!1}={}){if(Zv(e),sr(e)||ar(e)||t&&nh(e))return 2;return 1}var ma=_(()=>{fa();fa()});function Jv(e){if(e.length>50)return!1;if(Kv.test(e))return!0;if(e.includes("\u200D")){let t=e.match(Hv);return t!==null&&t.length>=2}return!1}function Yv(e){return e.replace(Qv,"")}function Xv(e){return ih.test(e)}function sh(e){return e>=4352&&e<=4447||e>=43360&&e<=43388}function ah(e){return e>=4448&&e<=4519||e>=55216&&e<=55238}function ch(e){return e>=4520&&e<=4607||e>=55243&&e<=55291}function ex(e){return sh(e)||ah(e)||ch(e)}function tx(e,t){let r=[];for(let n of e){if(ih.test(n))continue;r.push(n.codePointAt(0))}if(r.length===0)return;let o=0;for(let n=0;n<r.length;n++){let i=r[n];if(!ex(i)){if(o===0)return;for(let s=n;s<r.length;s++)o+=cr(r[s],t);return o}if(sh(i)&&ah(r[n+1])){o+=2,n+=ch(r[n+2])?2:1;continue}o+=cr(i,t)}return o}function rx(e,t){let r=0,o=!0;for(let n of e){if(o){o=!1;continue}if(Wv.test(n)||n>="\uFF00"&&n<="\uFFEF")r+=cr(n.codePointAt(0),t)}return r}function K(e,t={}){if(typeof e!=="string"||e.length===0)return 0;let{ambiguousIsNarrow:r=!0,countAnsiEscapeCodes:o=!1}=t,n=e;if(!o&&(n.includes("\x1B")||n.includes("\x9B")))n=qe(n);if(n.length===0)return 0;if(/^[\u0020-\u007E]*$/.test(n))return n.length;let i=0,s={ambiguousAsWide:!r};for(let{segment:a}of qv.segment(n)){if(Xv(a))continue;if(Gv.test(a)||Jv(a)){i+=2;continue}let c=Yv(a),u=tx(c,s);if(u!==void 0){i+=u;continue}let l=c.codePointAt(0);i+=cr(l,s),i+=rx(c,s)}return i}var qv,ih,Qv,Wv,Gv,Kv,Hv;var Zo=_(()=>{Fo();ma();qv=new Intl.Segmenter,ih=/^(?:\p{Default_Ignorable_Code_Point}|\p{Control}|\p{Format}|\p{Nonspacing_Mark}|\p{Enclosing_Mark}|\p{Surrogate})+$/v,Qv=/^[\p{Default_Ignorable_Code_Point}\p{Control}\p{Format}\p{Nonspacing_Mark}\p{Enclosing_Mark}\p{Surrogate}]+/v,Wv=/\p{Spacing_Mark}/v,Gv=/^\p{RGI_Emoji}$/v,Kv=/^[\d#*]\u20E3$/,Hv=/\p{Extended_Pictographic}/gu});function ix(){let e=new Map;for(let[t,r]of Object.entries(Z)){for(let[o,n]of Object.entries(r))Z[o]={open:`\x1B[${n[0]}m`,close:`\x1B[${n[1]}m`},r[o]=Z[o],e.set(n[0],n[1]);Object.defineProperty(Z,t,{value:r,enumerable:!1})}return Object.defineProperty(Z,"codes",{value:e,enumerable:!1}),Z.color.close="\x1B[39m",Z.bgColor.close="\x1B[49m",Z.color.ansi=uh(),Z.color.ansi256=lh(),Z.color.ansi16m=ph(),Z.bgColor.ansi=uh(10),Z.bgColor.ansi256=lh(10),Z.bgColor.ansi16m=ph(10),Object.defineProperties(Z,{rgbToAnsi256:{value(t,r,o){if(t===r&&r===o){if(t<8)return 16;if(t>248)return 231;return Math.round((t-8)/247*24)+232}return 16+36*Math.round(t/255*5)+6*Math.round(r/255*5)+Math.round(o/255*5)},enumerable:!1},hexToRgb:{value(t){let r=/[a-f\d]{6}|[a-f\d]{3}/i.exec(t.toString(16));if(!r)return[0,0,0];let[o]=r;if(o.length===3)o=[...o].map((i)=>i+i).join("");let n=Number.parseInt(o,16);return[n>>16&255,n>>8&255,n&255]},enumerable:!1},hexToAnsi256:{value:(t)=>Z.rgbToAnsi256(...Z.hexToRgb(t)),enumerable:!1},ansi256ToAnsi:{value(t){if(t<8)return 30+t;if(t<16)return 90+(t-8);let r,o,n;if(t>=232)r=((t-232)*10+8)/255,o=r,n=r;else{t-=16;let a=t%36;r=Math.floor(t/36)/5,o=Math.floor(a/6)/5,n=a%6/5}let i=Math.max(r,o,n)*2;if(i===0)return 30;let s=30+(Math.round(n)<<2|Math.round(o)<<1|Math.round(r));if(i===2)s+=60;return s},enumerable:!1},rgbToAnsi:{value:(t,r,o)=>Z.ansi256ToAnsi(Z.rgbToAnsi256(t,r,o)),enumerable:!1},hexToAnsi:{value:(t)=>Z.ansi256ToAnsi(Z.hexToAnsi256(t)),enumerable:!1}}),Z}var uh=(e=0)=>(t)=>`\x1B[${t+e}m`,lh=(e=0)=>(t)=>`\x1B[${38+e};5;${t}m`,ph=(e=0)=>(t,r,o)=>`\x1B[${38+e};2;${t};${r};${o}m`,Z,CR,ox,nx,RR,sx,me;var ha=_(()=>{Z={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],gray:[90,39],grey:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgGray:[100,49],bgGrey:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}},CR=Object.keys(Z.modifier),ox=Object.keys(Z.color),nx=Object.keys(Z.bgColor),RR=[...ox,...nx];sx=ix(),me=sx});function ur(e,t,r){return String(e).normalize().replaceAll(`\r
|
|
82
82
|
`,`
|
|
@@ -87,9 +87,9 @@ ${t}`,Bv,zv,Dv=(e,t,r)=>{let o=r===""?"":`with ${r.trim()}() `,n=Iv.bind(null,o,
|
|
|
87
87
|
`){if(n)o+=fh("");o+=gx(i)}else if(d===`
|
|
88
88
|
`){let p=[...i];if(hx(c.slice(l+1),p),o+=yx(p),n)o+=fh(n)}l+=d.length}return o};var ba=_(()=>{Zo();Fo();ha();ax=new Set([it,ya]),Qo=`${cx}8;;`,$h=new RegExp(`^\\u001B(?:\\${bh}(?<sgr>[0-9;]*)${Wo}|${Qo}(?<uri>[^\\u0007\\u001B]*)(?:\\u0007|\\u001B\\\\))`),Ah=new RegExp(`^\\u009B(?<sgr>[0-9;]*)${Wo}`),kh=new Set(me.codes.values());kh.delete(Go);px=new Intl.Segmenter});function Ko(e){if(!Number.isInteger(e))return!1;return sr(e)||ar(e)}var Oh=_(()=>{ma()});function Kx(e){return e>=Cx&&e<=Rx||e===Tx||e===Ox}function Hx(e){return e>=Ix&&e<=Bx}function Jx(e){return e>=zx&&e<=Dx}function Yx(e){return e>=Nx&&e<=Lx}function Xx(e){return e>=Vx&&e<=Ux}function ve(e,t){return{token:{type:"control",code:e},endIndex:t}}function eE(e){if(Gx.test(e))return!0;for(let t of e){let r=t.codePointAt(0);if(r===Qx||r===Wx)return!0}return!1}function Qh(e){let t=0;for(let r of e){let o=r.codePointAt(0);if(Ko(o))return 2;if(Xx(o))t++}if(t>=1)return 2;if(eE(e))return 2;return 1}function tE(e){if(e.startsWith("\x9B"))return"\x9B";return`${xt}${$a}`}function lr(e,t){return`${e}${t.join(";")}${jh}`}function rE(e){let t=[],r=tE(e),o;if(e.startsWith(`${xt}${$a}`))o=e.slice(2,-1);else if(e.startsWith("\x9B"))o=e.slice(1,-1);else return t;let n=o.length===0?[String(Ih)]:o.split(";"),i=0;while(i<n.length){let s=Number.parseInt(n[i],10);if(Number.isNaN(s)){i++;continue}if(s===Ih){t.push({type:"reset"}),i++;continue}if(s===Ho||s===Mx){let u=Number.parseInt(n[i+1],10);if(u===Fx&&i+Zx<n.length){let f=lr(r,n.slice(i,i+Bh));t.push({type:"start",code:f,endCode:me.color.ansi(s===Ho?_a:wa)}),i+=Bh;continue}if(u===jx&&i+qx<n.length){let f=lr(r,n.slice(i,i+zh));t.push({type:"start",code:f,endCode:me.color.ansi(s===Ho?_a:wa)}),i+=zh;continue}let l=lr(r,[n[i]]);t.push({type:"start",code:l,endCode:me.color.ansi(s===Ho?_a:wa)}),i++;continue}if(qh.has(s)){t.push({type:"end",endCode:me.color.ansi(s)}),i++;continue}let a=me.codes.get(s);if(a!==void 0){let u=lr(r,[n[i]]);t.push({type:"start",code:u,endCode:me.color.ansi(a)}),i++;continue}let c=lr(r,[n[i]]);t.push({type:"start",code:c,endCode:me.reset.open}),i++}if(t.length===0)t.push({type:"reset"});return t}function oE(e,t){let r=e.codePointAt(t),o;if(r===pr){if(e[t+1]!==$a)return;o=t+2}else if(r===Lh)o=t+1;else return;let n=!0;for(let i=o;i<e.length;i++){let s=e.codePointAt(i);if(Yx(s)){let c=e.slice(t,i+1);if(e[i]!==jh||!n)return ve(c,i+1);return{token:{type:"sgr",code:c,fragments:rE(c)},endIndex:i+1}}if(Hx(s)){if(!Kx(s))n=!1;continue}if(Jx(s)){n=!1;continue}let a=i;return ve(e.slice(t,a),a)}return ve(e.slice(t),e.length)}function nE(e,t){let r,o,n=e.codePointAt(t);if(n===pr&&e.startsWith(Ea,t))r=Ea,o=kx;else if(n===Xo&&e.startsWith(Sa,t))r=Sa,o=Px;else return;let i=e.indexOf(";",t+r.length);if(i===-1)return ve(e.slice(t),e.length);for(let s=i+1;s<e.length;s++){let a=e[s];if(a===xa){let c=e.slice(t,s+1),u=s===i+1?"close":"open";return{token:{type:"hyperlink",code:c,action:u,closePrefix:o,terminator:xa},endIndex:s+1}}if(a===xt&&e[s+1]===Jo){let c=e.slice(t,s+2),u=s===i+1?"close":"open";return{token:{type:"hyperlink",code:c,action:u,closePrefix:o,terminator:Zh},endIndex:s+2}}if(a===Yo){let c=e.slice(t,s+1),u=s===i+1?"close":"open";return{token:{type:"hyperlink",code:c,action:u,closePrefix:o,terminator:Yo},endIndex:s+1}}}return ve(e.slice(t),e.length)}function iE(e,t){let r=e.codePointAt(t),o,n=!1;switch(r){case pr:{switch(e[t+1]){case Fh:{o=t+2,n=!0;break}case xx:case Ex:case Sx:case $x:{o=t+2;break}case Jo:return ve(Zh,t+2);default:return}break}case Xo:{o=t+1,n=!0;break}case Dh:case Nh:case Uh:case Mh:{o=t+1;break}case Vh:return ve(Yo,t+1);default:return}for(let i=o;i<e.length;i++){if(n&&e[i]===xa)return ve(e.slice(t,i+1),i+1);if(e[i]===xt&&e[i+1]===Jo)return ve(e.slice(t,i+2),i+2);if(e[i]===Yo)return ve(e.slice(t,i+1),i+1)}return ve(e.slice(t),e.length)}function fr(e,t){let r=e.codePointAt(t);if(r===pr||r===Xo){let n=nE(e,t);if(n)return n}let o=iE(e,t);if(o)return o;return oE(e,t)}function Wh(e,t,r){while(t<e.length){let o=e.codePointAt(t);if(!dr.has(o))break;let n=fr(e,t);if(!n)break;r.push(n.token),t=n.endIndex}return t}function Gh(e,t,r){let o=r.containing(t);if(!o||o.index!==t)return;return{token:{type:"character",value:o.segment,visibleWidth:Qh(o.segment),isGraphemeContinuation:!1},endIndex:t+o.segment.length}}function sE(e){let t=[],r=0;while(r<e.length){let o=e.codePointAt(r);if(dr.has(o)){let i=fr(e,r);if(i){r=i.endIndex;continue}}let n=String.fromCodePoint(o);t.push({value:n,visibleWidth:1,isGraphemeContinuation:!1}),r+=n.length}return t}function aE(e){if(e.length===0)return;let t=e.map(({value:i})=>i).join(""),r=[],o=0;for(let i of e)r.push(o),o+=i.value.length;let n=0;for(let i of Aa.segment(t)){while(n<e.length&&r[n]<i.index)n++;let s=n,a=!0;while(s<e.length&&r[s]<i.index+i.segment.length)e[s].visibleWidth=a?Qh(i.segment):0,e[s].isGraphemeContinuation=!a,a=!1,s++;n=s}}function va(e,{endCharacter:t=Number.POSITIVE_INFINITY}={}){let r=[],o=sE(e);aE(o);let n=0,i=0,s=0;while(n<e.length){let a=e.codePointAt(n);if(dr.has(a)){let d=fr(e,n);if(d){r.push(d.token),n=d.endIndex;continue}}let c=String.fromCodePoint(a),u=o[i],l=Ko(a)?2:c.length;if(u)l=u.visibleWidth;let f={type:"character",value:c,visibleWidth:l,isGraphemeContinuation:u?u.isGraphemeContinuation:!1};if(r.push(f),n+=c.length,i++,s+=f.visibleWidth,s>=t){let d=o[i];if(!d||!d.isGraphemeContinuation){n=Wh(e,n,r);break}}}return r}function Kh(e,t){let r=`${e}${t}`,o=e.length;for(let n of Aa.segment(r)){if(n.index===o)return!1;if(n.index>o)return!0}return!0}function cE(e,t,r,o){if(!r)return!1;let n=t,i=!1;while(n<e.length){let s=e.codePointAt(n);if(dr.has(s)){let c=fr(e,n);if(c){i=!0,n=c.endIndex;continue}}if(!i)return!1;let a=Gh(e,n,o);if(!a)return!0;return Kh(r,a.token.value)}return!1}function ka(e,{endCharacter:t=Number.POSITIVE_INFINITY}={}){let r=[],o=Aa.segment(e),n=0,i=0,s,a=!1;while(n<e.length){let c=e.codePointAt(n);if(dr.has(c)){let l=fr(e,n);if(l){r.push(l.token),n=l.endIndex,a=!0;continue}}let u=Gh(e,n,o);if(!u)return va(e,{endCharacter:t});if(a&&s&&Kh(s,u.token.value))return va(e,{endCharacter:t});if(r.push(u.token),n=u.endIndex,i+=u.token.visibleWidth,a=!1,s=u.token.value,i>=t){if(cE(e,n,s,o))return va(e,{endCharacter:t});n=Wh(e,n,r);break}}return r}var pr=27,Dh=144,Nh=152,Lh=155,Vh=156,Xo=157,Uh=158,Mh=159,dr,xt="\x1B",xa="\x07",$a="[",Fh="]",xx="P",Ex="X",Sx="^",$x="_",jh="m",Jo="\\",Zh,Ax="\x9D",Yo="\x9C",Ea,Sa,kx,Px,Cx,Rx,Tx,Ox,Ix,Bx,zx,Dx,Nx,Lx,Vx=127462,Ux=127487,Ih=0,Ho=38,_a=39,Mx=48,wa=49,Fx=5,jx=2,Bh=3,zh=5,Zx=2,qx=4,Qx=65039,Wx=8419,Gx,Aa,qh;var Hh=_(()=>{ha();Oh();dr=new Set([pr,Dh,Nh,Lh,Vh,Xo,Uh,Mh]),Zh=`${xt}${Jo}`,Ea=`${xt}${Fh}8;`,Sa=`${Ax}8;`,kx=`${Ea};`,Px=`${Sa};`,Cx="0".codePointAt(0),Rx="9".codePointAt(0),Tx=";".codePointAt(0),Ox=":".codePointAt(0),Ix="0".codePointAt(0),Bx="?".codePointAt(0),zx=" ".codePointAt(0),Dx="/".codePointAt(0),Nx="@".codePointAt(0),Lx="~".codePointAt(0),Gx=/\p{Emoji_Presentation}/v,Aa=new Intl.Segmenter(void 0,{granularity:"grapheme"}),qh=new Set;for(let[,e]of me.codes)qh.add(e)});function uE(e,t){for(let r of t)switch(r.type){case"reset":{e.clear();break}case"end":{e.delete(r.endCode);break}case"start":{e.delete(r.endCode),e.set(r.endCode,r.code);break}default:break}return e}function lE(e){return[...e.keys()].toReversed().join("")}function pE(e){return`${e.closePrefix}${e.terminator}`}function dE(e,t){let r=!1,o=!1;for(let n of e.fragments){if(n.type==="start"){r=!0;continue}if(n.type==="reset"&&t.size>0){o=!0;continue}if(n.type==="end"&&t.has(n.endCode))o=!0}return o&&!r}function fE(e){return e.fragments.some((t)=>t.type==="start")}function Jh(e){if(e.activeHyperlink&&!e.activeHyperlinkHasVisibleText&&e.activeHyperlinkOutputIndex!==void 0){let t=e.activeHyperlink.code.length;if(e.returnValue=e.returnValue.slice(0,e.activeHyperlinkOutputIndex)+e.returnValue.slice(e.activeHyperlinkOutputIndex+t),e.pendingSgrOutputIndex!==void 0&&e.pendingSgrOutputIndex>e.activeHyperlinkOutputIndex)e.pendingSgrOutputIndex-=t}e.activeHyperlink=void 0,e.activeHyperlinkHasVisibleText=!1,e.activeHyperlinkOutputIndex=void 0}function mE(e){if(e.isPastEnd&&!dE(e.token,e.activeStyles))return e;if(e.include&&fE(e.token)&&e.pendingSgrOutputIndex===void 0)e.pendingSgrOutputIndex=e.returnValue.length,e.pendingSgrActiveStyles=new Map(e.activeStyles);if(e.activeStyles=uE(e.activeStyles,e.token.fragments),e.include)e.returnValue+=e.token.code;return e}function hE(e){if(e.isPastEnd&&(e.token.action!=="close"||!e.activeHyperlink))return e;if(e.token.action==="open"){if(e.activeHyperlink=e.token,e.activeHyperlinkHasVisibleText=!1,e.activeHyperlinkOutputIndex=void 0,e.include)e.activeHyperlinkOutputIndex=e.returnValue.length}else if(e.token.action==="close"){if(e.include&&e.activeHyperlink&&!e.activeHyperlinkHasVisibleText)return Jh(e),e;e.activeHyperlink=void 0,e.activeHyperlinkHasVisibleText=!1,e.activeHyperlinkOutputIndex=void 0}if(e.include)e.returnValue+=e.token.code;return e}function gE(e){if(!e.isPastEnd&&e.include)e.returnValue+=e.token.code;return e}function yE(e){if(!e.include&&e.position>=e.start&&!e.token.isGraphemeContinuation){if(e.include=!0,e.returnValue=[...e.activeStyles.values()].join(""),e.activeHyperlink)e.activeHyperlinkOutputIndex=e.returnValue.length,e.returnValue+=e.activeHyperlink.code}if(e.include){if(e.returnValue+=e.token.value,e.pendingSgrOutputIndex=void 0,e.pendingSgrActiveStyles=void 0,e.activeHyperlink)e.activeHyperlinkHasVisibleText=!0}return e.position+=e.token.visibleWidth,e}function _E(e){let t=bE[e.token.type];if(!t)return e;return t(e)}function wE(e){let t=Array.from({length:e.length},()=>!1),r=!1;for(let o=e.length-1;o>=0;o--){let n=e[o];if(t[o]=r,n.type==="character")r=Boolean(n.isGraphemeContinuation)}return t}function vE(e,t,r){if(r===void 0)return!1;if(t>=r)return!0;return e.type==="character"&&!e.isGraphemeContinuation&&t+e.visibleWidth>r}function se(e,t,r){let o=ka(e,{endCharacter:r}),n=wE(o),i=new Map,s,a=!1,c,u,l,f=0,d="",p=!1;for(let[m,h]of o.entries()){let y=vE(h,f,r);if(y&&h.type!=="character"&&n[m])y=!1;if(y&&h.type==="character"&&!h.isGraphemeContinuation){if(s&&!a){let b={activeHyperlink:s,activeHyperlinkHasVisibleText:a,activeHyperlinkOutputIndex:c,pendingSgrOutputIndex:u,returnValue:d};Jh(b),{activeHyperlink:s,activeHyperlinkHasVisibleText:a,activeHyperlinkOutputIndex:c,pendingSgrOutputIndex:u,returnValue:d}=b}if(u!==void 0)d=d.slice(0,u),i=l,u=void 0,l=void 0;break}({activeStyles:i,activeHyperlink:s,activeHyperlinkHasVisibleText:a,activeHyperlinkOutputIndex:c,pendingSgrOutputIndex:u,pendingSgrActiveStyles:l,position:f,returnValue:d,include:p}=_E({token:h,isPastEnd:y,start:t,activeStyles:i,activeHyperlink:s,activeHyperlinkHasVisibleText:a,activeHyperlinkOutputIndex:c,pendingSgrOutputIndex:u,pendingSgrActiveStyles:l,position:f,returnValue:d,include:p}))}if(!p)return"";if(s)d+=pE(s);return d+=lE(i),d}var bE;var Pa=_(()=>{Hh();bE={sgr:mE,hyperlink:hE,control:gE,character:yE}});import Yh from"process";function tn(e,{showCursor:t=!1,defaultWidth:r,defaultHeight:o}={}){let n=0,i=en(e,r),s="",a=e.isTTY===!0,c=(d)=>{if(d==="")return;if(a){e.write(xE+d+EE);return}e.write(d)},u=(d,p,m=!0)=>{let h=String(d),y=h.endsWith(`
|
|
89
89
|
`)?h:`${h}
|
|
90
|
-
`,b=ur(y,p,{trim:!1,hard:!0,wordWrap:!1}),{text:P,wasClipped:E}=m?$E(e,b,o):{text:b,wasClipped:!1},
|
|
91
|
-
`);return{wrapped:P,lines:
|
|
92
|
-
`),{start:P,endPrevious:E,endNext:
|
|
90
|
+
`,b=ur(y,p,{trim:!1,hard:!0,wordWrap:!1}),{text:P,wasClipped:E}=m?$E(e,b,o):{text:b,wasClipped:!1},k=P===""?[]:P.split(`
|
|
91
|
+
`);return{wrapped:P,lines:k,wasClipped:E}},l=()=>{s="",i=en(e,r),n=0},f=(...d)=>{if(!t)la.hide();let p=en(e,r),{wrapped:m,lines:h,wasClipped:y}=u(d.join(" "),p);if(h.length===0){if(n>0)c(ir(n));s=m,i=p,n=0;return}if(m===s&&i===p)return;if(n===0){c(m),s=m,i=p,n=h.length;return}if(i!==p||y){c(ir(n)+m),s=m,i=p,n=h.length;return}let b=s===""?[]:s.split(`
|
|
92
|
+
`),{start:P,endPrevious:E,endNext:k}=AE(b,h);if(b.length!==h.length)E=b.length-1,k=h.length-1;if(P===h.length&&n===h.length)return;if(P===0){c(ir(n)+m),s=m,i=p,n=h.length;return}let x=kE({prevCount:n,start:P,endPrevious:E,endNext:k,nextLines:h,nextWrappedEndsWithNewline:m.endsWith(`
|
|
93
93
|
`)});c(x),s=m,i=p,n=h.length};return f.clear=()=>{c(ir(n)),l()},f.done=()=>{if(l(),!t)la.show()},f.persist=(...d)=>{let p=n>0?ir(n):"",m=en(e,r),{wrapped:h}=u(d.join(" "),m,!1);c(p+h),l()},f}var en=(e,t)=>e.columns??t??80,xE="\x1B[?2026h",EE="\x1B[?2026l",SE=(e)=>e.split(`
|
|
94
94
|
`).length,Ca=(e)=>{let t=qe(e);return t===""?0:t.split(`
|
|
95
95
|
`).length},$E=(e,t,r)=>{let o=e.rows??r??24;if(o===0)return{text:"",wasClipped:t!==""};let i=qe(t).split(`
|
|
@@ -97,10 +97,10 @@ ${t}`,Bv,zv,Dv=(e,t,r)=>{let o=r===""?"":`with ${r.trim()}() `,n=Iv.bind(null,o,
|
|
|
97
97
|
`),y=i&&o<n.length-1&&!h.endsWith(`
|
|
98
98
|
`);if(s+=h,f=SE(h)-1,s+=Pv,y)s+=`
|
|
99
99
|
`,f++}let d=t+f,m=n.length-1-d;if(m>0)s+=ra(m);if(m<0)s+=No(-m);return s},HR,JR;var Xh=_(()=>{Om();Wm();ba();Pa();Fo();Zo();HR=tn(Yh.stdout),JR=tn(Yh.stderr)});function rn(e,t,r){if(e.charAt(t)===" ")return t;let o=r?1:-1;for(let n=0;n<=3;n++){let i=t+n*o;if(e.charAt(i)===" ")return i}return t}function CE(e,t,r,o){if(typeof e!=="string")throw TypeError(`Expected \`input\` to be a string, got ${typeof e}`);if(typeof t!=="number")throw TypeError(`Expected \`columns\` to be a number, got ${typeof t}`);if(!Number.isFinite(t))throw TypeError(`Expected \`columns\` to be a finite number, got ${t}`);if(!PE.has(r))throw TypeError(`Expected \`options.position\` to be either \`start\`, \`middle\` or \`end\`, got ${r}`);if(typeof o!=="string")throw TypeError(`Expected \`options.truncationCharacter\` to be a string, got ${typeof o}`)}function Ra(e,t,r={}){let{position:o="end",space:n=!1,preferTruncationOnSpace:i=!1}=r,{truncationCharacter:s="\u2026"}=r;if(CE(e,t,o,s),t<1)return"";let a=K(e);if(a<=t)return e;if(t===1)return s;let c={ESC:27,LEFT_BRACKET:91,LETTER_M:109},u=(m)=>m>=48&&m<=57||m===59;function l(m){let h=0;while(h+2<m.length&&m.codePointAt(h)===c.ESC&&m.codePointAt(h+1)===c.LEFT_BRACKET){let y=h+2;while(y<m.length&&u(m.codePointAt(y)))y++;if(y<m.length&&m.codePointAt(y)===c.LETTER_M){h=y+1;continue}break}return h}function f(m){let h=m.length;while(h>1&&m.codePointAt(h-1)===c.LETTER_M){let y=h-2;while(y>=0&&u(m.codePointAt(y)))y--;if(y>=1&&m.codePointAt(y-1)===c.ESC&&m.codePointAt(y)===c.LEFT_BRACKET){h=y-1;continue}break}return h}function d(m,h){let y=f(m);if(y===m.length)return m+h;return m.slice(0,y)+h+m.slice(y)}function p(m,h){let y=l(h);if(y===0)return m+h;return h.slice(0,y)+m+h.slice(y)}if(o==="start"){if(i){let h=rn(e,a-t+K(s),!0),y=se(e,h,a).trim();return p(s,y)}if(n)s+=" ";let m=se(e,a-t+K(s),a);return p(s,m)}if(o==="middle"){if(n){if(s=` ${s} `,K(s)>=t)s=s.trim()}let m=K(s),h=Math.min(Math.floor(t/2),Math.max(0,t-m));if(i){let y=rn(e,h),b=rn(e,a-(t-h)+m,!0);return se(e,0,y)+s+se(e,b,a).trim()}return se(e,0,h)+s+se(e,a-(t-h)+m,a)}if(o==="end"){if(i){let h=rn(e,t-K(s)),y=se(e,0,h);return d(y,s)}if(n)s=` ${s}`;let m=se(e,0,t-K(s));return d(m,s)}}var PE;var eg=_(()=>{Pa();Zo();PE=new Set(["start","middle","end"])});import RE,{setMaxListeners as TE}from"events";import{inspect as OE,styleText as IE}from"util";import{format as BE}from"util";import{EOL as Ae}from"os";import{StringDecoder as zE}from"string_decoder";import{Writable as DE}from"stream";import{randomUUID as NE}from"crypto";function ME(e){return!!e&&typeof e==="object"&&typeof e.subscribe==="function"}function FE(e){return!!e&&typeof e==="object"&&e.readable===!0&&typeof e.read==="function"&&typeof e.on==="function"}function ug(){return!!process.env.LISTR_FORCE_UNICODE||process.platform!=="win32"||!!process.env.CI||!!process.env.WT_SESSION||process.env.TERM_PROGRAM==="vscode"||process.env.TERM==="xterm-256color"||process.env.TERM==="alacritty"}function hr(e){return String(e).replace(new RegExp(jE,"gmi"),"").trim()}function og(e,t){return e.replace(/^(?!\s*$)/gm," ".repeat(t))}function mr(e,...t){return BE(String(e),...t)}function QE(e){let t=new DE;return t.rows=1/0,t.columns=1/0,t.write=(r)=>(e(r.toString()),!0),t}function GE(e){let t=Math.floor(e/1000),r=Math.floor(t/60),o;if(t===0&&r===0)o=`0.${Math.floor(e/100)}s`;if(t>0)o=`${t%60}s`;if(r>0)o=`${r}m${o}`;return o}function tS(e){return process.stdout.isTTY===!0||e.nonTTY===!0}function on(e){if(typeof e==="string")return Ta[e]??Ta.default;return typeof e==="function"?e:Ta.default}function rS(e){if(Et(e?.silentRendererCondition))return{renderer:on("silent"),selection:"SILENT"};let t={renderer:on(e.renderer),options:e.rendererOptions,selection:"PRIMARY"};if(!tS(t.renderer)||Et(e?.fallbackRendererCondition))return{renderer:on(e.fallbackRenderer),options:e.fallbackRendererOptions,selection:"SECONDARY"};return t}function Et(e,...t){if(typeof e==="function")return e(...t);else return e}function nS(e){return new Promise((t)=>{setTimeout(t,e)})}var tg,ag,LE,cg=class{emitter=new RE;constructor(){this.emitter.setMaxListeners(0)}emit(e,t){this.emitter.emit(e,t)}on(e,t){if(!t)return;this.emitter.addListener(e,t)}once(e,t){if(!t)return;this.emitter.once(e,t)}off(e,t){if(t)this.emitter.off(e,t);else this.emitter.removeAllListeners(e)}complete(){this.emitter.removeAllListeners()}},VE,rg,UE,jE="(?:\\u001b|\\u009b)\\[[\\=><~/#&.:=?%@~_-]*[0-9]*[\\a-ln-tqyz=><~/#&.:=?%@~_-]+",z,lg,ZE,F,nn,pg,sn=class{options;process;constructor(e){this.options=e,this.options={useIcons:!0,toStderr:[],...e??{}},this.options.fields??={},this.options.fields.prefix??=[],this.options.fields.suffix??=[],this.process=this.options.processOutput??new qE}log(e,t,r){let o=this.format(e,t,r);if(this.options.toStderr.includes(e)){this.process.toStderr(o);return}this.process.toStdout(o)}toStdout(e,t,r=!0){this.process.toStdout(this.format(null,e,t),r)}toStderr(e,t,r=!0){this.process.toStderr(this.format(null,e,t),r)}wrap(e,t){if(!e)return e;return this.applyFormat(`[${e}]`,t)}splat(...e){let t=e.shift()??"";return e.length===0?t:mr(t,e)}suffix(e,...t){return t.filter(Boolean).forEach((r)=>{if(e+=this.spacing(e),typeof r==="string")e+=this.wrap(r);else if(typeof r==="object"){if(r.args??=[],typeof r.condition==="function"?!r.condition(...r.args):!(r.condition??!0))return e;e+=this.wrap(typeof r.field==="function"?r.field(...r.args):r.field,{format:r?.format(...r.args)})}}),e}prefix(e,...t){return t.filter(Boolean).forEach((r)=>{if(e=this.spacing(e)+e,typeof r==="string")e=this.wrap(r)+e;else if(typeof r==="object"){if(r.args??=[],typeof r.condition==="function"?!r.condition(...r.args):!(r.condition??!0))return e;e=this.wrap(typeof r.field==="function"?r.field(...r.args):r.field,{format:r?.format()})+e}}),e}fields(e,t){if(this.options?.fields?.prefix)e=this.prefix(e,...this.options.fields.prefix);if(t?.prefix)e=this.prefix(e,...t.prefix);if(t?.suffix)e=this.suffix(e,...t.suffix);if(this.options?.fields?.suffix)e=this.suffix(e,...this.options.fields.suffix);return e}icon(e,t){if(!e)return null;if(!t){let o=this.options.icon?.[e];t=typeof o==="function"?o():o}let r=this.options.color?.[e];if(t&&r)t=r(t);return t}format(e,t,r){if(!Array.isArray(t))t=[t];return t=this.splat(t.shift(),...t).toString().split(Ae).filter((o)=>!o||o.trim()!=="").map((o)=>this.style(e,this.fields(o,{prefix:Array.isArray(r?.prefix)?r.prefix:[r?.prefix],suffix:Array.isArray(r?.suffix)?r.suffix:[r?.suffix]}))).join(Ae),t}style(e,t){if(!e||!t)return t;let r=this.icon(e,!this.options.useIcons&&this.wrap(e));if(r)t=r+" "+t;return t}applyFormat(e,t){if(t?.format)return t.format(e);return e}spacing(e){return typeof e>"u"||e.trim()===""?"":" "}},Oa=class{options;buffer=[];decoder=new zE;constructor(e){this.options=e}get all(){return this.buffer}get last(){return this.buffer.at(-1)}get length(){return this.buffer.length}write(e,...t){let r=t[t.length-1];if(this.buffer.push({time:Date.now(),stream:this.options?.stream,entry:this.decoder.write(typeof e==="string"?Buffer.from(e,typeof t[0]==="string"?t[0]:void 0):Buffer.from(e))}),this.options?.limit)this.buffer=this.buffer.slice(-this.options.limit);if(typeof r==="function")r();return!0}reset(){this.buffer=[]}},ng=class{stream;method;buffer;constructor(e){this.stream=e,this.method=e.write,this.buffer=new Oa({stream:e})}get out(){let e=this;return new Proxy(this.stream,{get(t,r,o){if(r==="write")return e.write.bind(e);return Reflect.get(t,r,o)}})}hijack(){this.stream.write=this.buffer.write.bind(this.buffer)}release(){this.stream.write=this.method;let e=[...this.buffer.all];return this.buffer.reset(),e}write(...e){return this.method.apply(this.stream,e)}},qE=class{options;stream;active;constructor(e,t,r){this.options=r,this.stream={stdout:new ng(e??process.stdout),stderr:new ng(t??process.stderr)},this.options={dump:["stdout","stderr"],leaveEmptyLine:!0,...r}}get stdout(){return this.stream.stdout.out}get stderr(){return this.stream.stderr.out}hijack(){if(this.active)throw Error("ProcessOutput has been already hijacked!");this.stream.stdout.write(tg.CURSOR_HIDE),Object.values(this.stream).forEach((e)=>e.hijack()),this.active=!0}release(){let e=Object.entries(this.stream).map(([t,r])=>({name:t,buffer:r.release()})).filter((t)=>this.options.dump.includes(t.name)).flatMap((t)=>t.buffer).sort((t,r)=>t.time-r.time).map((t)=>({...t,entry:hr(t.entry)})).filter((t)=>t.entry);if(e.length>0){if(this.options.leaveEmptyLine)this.stdout.write(Ae);e.forEach((t)=>{(t.stream??this.stdout).write(t.entry+Ae)})}this.stream.stdout.write(tg.CURSOR_SHOW),this.active=!1}toStdout(e,t=!0){if(t)e=e+Ae;return this.stream.stdout.write(e)}toStderr(e,t=!0){if(t)e=e+Ae;return this.stream.stderr.write(e)}},WE=class{spinner=!ug()?["-","\\","|","/"]:["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"];id;spinnerPosition=0;spin(){this.spinnerPosition=++this.spinnerPosition%this.spinner.length}fetch(){return this.spinner[this.spinnerPosition]}isRunning(){return!!this.id}start(e,t=100){this.id=setInterval(()=>{if(this.spin(),e)e()},t)}stop(){clearInterval(this.id),this.id=void 0}},ig,Ia,KE,HE=class{tasks;options;static nonTTY=!0;static rendererOptions;static rendererTaskOptions;constructor(e,t){this.tasks=e,this.options=t}render(){}end(){}},JE,YE=class{options;constructor(e){this.options=e}serialize(e,t,r){return JSON.stringify(this.generate(e,t,r))}generate(e,t,r){let o={event:e,data:t};if(typeof this.options?.task!=="boolean"){let n=Object.fromEntries(this.options.task.map((i)=>{let s=r[i];if(typeof s==="function")return[i,s.call(r)];return[i,s]}));if(Object.keys(r).length>0)o.task=n}return o}},XE,eS,Ta,oS=class{concurrency;count;queue;constructor(e){this.concurrency=e.concurrency,this.count=0,this.queue=new Set}add(e){if(this.count<this.concurrency)return this.run(e);return new Promise((t)=>{let r=()=>t(this.run(e));this.queue.add(r)})}flush(){for(let e of this.queue){if(this.count>=this.concurrency)break;this.queue.delete(e),e()}}run(e){this.count++;let t=e(),r=()=>{this.count--,this.flush()};return t.then(r,()=>{this.queue.clear()}),t}},iS=class{task;constructor(e){this.task=e}get title(){return this.task.title}set title(e){e=Array.isArray(e)?e:[e],this.task.title$=mr(e.shift(),...e)}get output(){return this.task.output}set output(e){if(e===null){this.task.outputReset$=null;return}e=Array.isArray(e)?e:[e],this.task.output$=mr(e.shift(),...e)}set promptOutput(e){this.task.promptOutput$=e}get signal(){return this.task.listr.signal}cancel(){this.task.listr.cancel()}newListr(e,t){let r;if(typeof e==="function")r=e(this);else r=e;return new he(r,t,this.task)}report(e,t){if(this.task.options.collectErrors)this.task.listr.errors?.push(new VE(e,t,this.task));this.task.message$={error:e.message??this.task?.title}}skip(e,...t){if(this.task.state$="SKIPPED",e)this.task.message$={skip:e?mr(e,...t):this.task?.title}}isRetrying(){return this.task.isRetrying()?this.task.retry:{count:0}}prompt(e){if(this.task.prompt)return this.task.prompt;return new e(this.task,this)}stdout(e){return QE((t)=>{switch(e){case"PROMPT":this.promptOutput=t;break;default:this.output=t}})}run(e){return this.task.run(e,this)}},sS,aS,sg,he=class{task;options;parentTask;tasks=[];errors;ctx;events;path=[];rendererClass;rendererClassOptions;rendererSelection;boundSignalHandler;signal;concurrency;renderer;abortController;startedTasks=[];constructor(e,t,r){if(this.task=e,this.options=t,this.parentTask=r,this.options={concurrent:!1,renderer:"default",fallbackRenderer:"simple",exitOnError:!0,exitAfterRollback:!0,collectErrors:!1,registerSignalListeners:!0,...this.parentTask?.options??{},...t},this.options.concurrent===!0)this.options.concurrent=1/0;else if(typeof this.options.concurrent!=="number")this.options.concurrent=1;if(this.concurrency=new oS({concurrency:this.options.concurrent}),r)this.path=[...r.listr.path,r.title],this.errors=r.listr.errors;else this.errors=this.options.collectErrors?[]:null;if(this.parentTask?.listr.events instanceof sg)this.events=this.parentTask.listr.events;else this.events=new sg;if(this.parentTask?.listr.abortController instanceof AbortController)this.abortController=this.parentTask.listr.abortController;else this.abortController=new AbortController,TE(0,this.abortController.signal);if(this.signal=this.abortController.signal,this.options?.forceTTY||process.env.LISTR_FORCE_TTY)process.stdout.isTTY=!0,process.stderr.isTTY=!0;if(this.options?.forceUnicode)process.env.LISTR_FORCE_UNICODE="1";let o=rS({renderer:this.options.renderer,rendererOptions:this.options.rendererOptions,fallbackRenderer:this.options.fallbackRenderer,fallbackRendererOptions:this.options.fallbackRendererOptions,fallbackRendererCondition:this.options?.fallbackRendererCondition,silentRendererCondition:this.options?.silentRendererCondition});if(this.rendererClass=o.renderer,this.rendererClassOptions=o.options,this.rendererSelection=o.selection,this.add(e??[]),this.options.registerSignalListeners&&this.isRoot())this.boundSignalHandler=this.signalHandler.bind(this),process.on("SIGINT",this.boundSignalHandler).setMaxListeners(0)}isRoot(){return!this.parentTask}isSubtask(){return!!this.parentTask}add(e){this.tasks.push(...this.generate(e))}async run(e){if(!this.renderer)this.renderer=new this.rendererClass(this.tasks,this.rendererClassOptions,this.events);await this.renderer.render(),this.ctx=this.options?.ctx??e??{};let t,r=!1;try{await Promise.all(this.tasks.map((o)=>o.check(this.ctx))),await Promise.all(this.tasks.map((o)=>this.concurrency.add(()=>this.runTask(o))))}catch(o){r=!0,t=o}if(this.signal.aborted){if(await Promise.allSettled(this.startedTasks),this.isRoot())return this.cancelUnfinishedTasks(),this.renderer.end(),this.removeSignalHandler(),process.exit(127),this.ctx;throw t??Error("Interrupted.")}if(r&&this.options.exitOnError!==!1)throw this.renderer.end(t),this.removeSignalHandler(),t;if(!r)this.renderer.end(),this.removeSignalHandler();return this.ctx}cancel(){this.abortController.abort()}generate(e){return e=Array.isArray(e)?e:[e],e.map((t)=>{let r;if(this.rendererSelection==="PRIMARY")r=t.rendererOptions;else if(this.rendererSelection==="SECONDARY")r=t.fallbackRendererOptions;return new aS(this,t,this.options,this.rendererClassOptions,r)})}async runTask(e){if(!await e.check(this.ctx))return;let t=new iS(e).run(this.ctx);return this.startedTasks.push(t),t}signalHandler(){this.abortController.abort()}removeSignalHandler(){if(this.boundSignalHandler)process.removeListener("SIGINT",this.boundSignalHandler)}cancelUnfinishedTasks(e=this.tasks){for(let t of e){if(t.hasSubtasks())this.cancelUnfinishedTasks(t.subtasks);if(t.isEnabled()!==!1&&!t.hasFinalized())t.state$="CANCELLED"}}};var St=_(()=>{tg={CURSOR_HIDE:"\x1B[?25l",CURSOR_SHOW:"\x1B[?25h"},ag=function(e){return e.WILL_RETRY="WILL_RETRY",e.WILL_ROLLBACK="WILL_ROLLBACK",e.HAS_FAILED_TO_ROLLBACK="HAS_FAILED_TO_ROLLBACK",e.HAS_FAILED="HAS_FAILED",e.HAS_FAILED_WITHOUT_ERROR="HAS_FAILED_WITHOUT_ERROR",e}({}),LE=function(e){return e.WAITING="WAITING",e.STARTED="STARTED",e.COMPLETED="COMPLETED",e.FAILED="FAILED",e.SKIPPED="SKIPPED",e.ROLLING_BACK="ROLLING_BACK",e.ROLLED_BACK="ROLLED_BACK",e.RETRY="RETRY",e.PAUSED="PAUSED",e.PROMPT="PROMPT",e.PROMPT_COMPLETED="PROMPT_COMPLETED",e.PROMPT_FAILED="PROMPT_FAILED",e.CANCELLED="CANCELLED",e}({}),VE=class extends Error{error;type;task;path;constructor(e,t,r){super(e.message);this.error=e,this.type=t,this.task=r,this.name="ListrError",this.path=r.path,this.stack=e?.stack}},rg=class extends Error{},UE=class extends Error{};z=Object.fromEntries(Object.keys(OE.colors).map((e)=>[e,(t)=>IE(e,String(t))]));lg={warning:"\u26A0",cross:"\u2716",arrowDown:"\u2193",tick:"\u2714",arrowRight:"\u2192",pointer:"\u276F",checkboxOn:"\u2612",arrowLeft:"\u2190",squareSmallFilled:"\u25FC",pointerSmall:"\u203A",circleSlash:"\u2298"},ZE={...lg,warning:"\u203C",cross:"\xD7",tick:"\u221A",pointer:">",checkboxOn:"[\xD7]",squareSmallFilled:"\u25A0",circleSlash:"\xF8"},F=ug()?lg:ZE;nn={icon:{["STARTED"]:F.pointer,["FAILED"]:F.cross,["SKIPPED"]:F.arrowDown,["COMPLETED"]:F.tick,["OUTPUT"]:F.pointerSmall,["TITLE"]:F.arrowRight,["RETRY"]:F.warning,["ROLLBACK"]:F.arrowLeft,["PAUSED"]:F.squareSmallFilled,["CANCELLED"]:F.circleSlash},color:{["STARTED"]:z.yellow,["FAILED"]:z.red,["SKIPPED"]:z.yellow,["COMPLETED"]:z.green,["RETRY"]:z.yellowBright,["ROLLBACK"]:z.redBright,["PAUSED"]:z.yellowBright,["CANCELLED"]:z.red}},pg=["RETRY","ROLLBACK","FAILED"];ig={icon:{["SKIPPED_WITH_COLLAPSE"]:F.arrowDown,["SKIPPED_WITHOUT_COLLAPSE"]:F.warning,["OUTPUT"]:F.pointerSmall,["OUTPUT_WITH_BOTTOMBAR"]:F.pointerSmall,["PENDING"]:F.pointer,["COMPLETED"]:F.tick,["COMPLETED_WITH_FAILED_SUBTASKS"]:F.warning,["COMPLETED_WITH_SISTER_TASKS_FAILED"]:F.squareSmallFilled,["RETRY"]:F.warning,["ROLLING_BACK"]:F.warning,["ROLLED_BACK"]:F.arrowLeft,["FAILED"]:F.cross,["FAILED_WITH_SUBTASKS"]:F.pointer,["WAITING"]:F.squareSmallFilled,["PAUSED"]:F.squareSmallFilled,["CANCELLED"]:F.circleSlash},color:{["SKIPPED_WITH_COLLAPSE"]:z.yellow,["SKIPPED_WITHOUT_COLLAPSE"]:z.yellow,["PENDING"]:z.yellow,["COMPLETED"]:z.green,["COMPLETED_WITH_FAILED_SUBTASKS"]:z.yellow,["COMPLETED_WITH_SISTER_TASKS_FAILED"]:z.red,["RETRY"]:z.yellowBright,["ROLLING_BACK"]:z.redBright,["ROLLED_BACK"]:z.redBright,["FAILED"]:z.red,["FAILED_WITH_SUBTASKS"]:z.red,["WAITING"]:z.dim,["PAUSED"]:z.yellowBright,["CANCELLED"]:z.red}};Ia={condition:!0,field:GE,format:()=>z.dim},KE=class e{tasks;options;events;static nonTTY=!1;static rendererOptions={indentation:2,clearOutput:!1,showSubtasks:!0,collapseSubtasks:!0,collapseSkips:!0,showSkipMessage:!0,suffixSkips:!1,collapseErrors:!0,showErrorMessage:!0,suffixRetries:!0,lazy:!1,removeEmptyLines:!0,formatOutput:"wrap",pausedTimer:{...Ia,format:()=>z.yellowBright}};static rendererTaskOptions={outputBar:!0};prompt;activePrompt;spinner;logger;updater;truncate;wrap;buffer={output:new Map,bottom:new Map};cache={render:new Map,rendererOptions:new Map,rendererTaskOptions:new Map};constructor(t,r,o){this.tasks=t,this.options=r,this.events=o,this.options={...e.rendererOptions,...this.options,icon:{...ig.icon,...r?.icon??{}},color:{...ig.color,...r?.color??{}}},this.spinner=this.options.spinner??new WE,this.logger=this.options.logger??new sn({useIcons:!0,toStderr:[]}),this.logger.options.icon=this.options.icon,this.logger.options.color=this.options.color}async render(){await Promise.resolve().then(() => Xh());await Promise.resolve().then(() => eg());await Promise.resolve().then(() => ba());if(this.updater=tn(this.logger.process.stdout),this.truncate=Ra,this.wrap=ur,this.logger.process.hijack(),!this.options?.lazy)this.spinner.start(()=>{this.update()});this.events.on("SHOUD_REFRESH_RENDER",this.refresh)}update(){this.updater(this.create())}end(){if(this.spinner.stop(),this.events.off("SHOUD_REFRESH_RENDER",this.refresh),this.updater.clear(),this.updater.done(),!this.options.clearOutput)this.logger.process.toStdout(this.create({prompt:!1}));this.logger.process.release()}create(t){t={tasks:!0,bottomBar:!0,prompt:!0,...t};let r=[],o=this.renderer(this.tasks),n=this.renderBottomBar(),i=this.renderPrompt();if(t.tasks&&o.length>0)r.push(...o);if(t.bottomBar&&n.length>0){if(r.length>0)r.push("");r.push(...n)}if(t.prompt&&i.length>0){if(r.length>0)r.push("");r.push(...i)}return r.join(Ae)}style(t,r=!1){let o=this.cache.rendererOptions.get(t.id);if(t.isSkipped()){if(r||o.collapseSkips)return this.logger.icon("SKIPPED_WITH_COLLAPSE");else if(o.collapseSkips===!1)return this.logger.icon("SKIPPED_WITHOUT_COLLAPSE")}if(r){if(this.shouldOutputToBottomBar(t))return this.logger.icon("OUTPUT_WITH_BOTTOMBAR");return this.logger.icon("OUTPUT")}if(t.hasSubtasks()){if(t.isStarted()||t.isPrompt()&&o.showSubtasks!==!1&&!t.subtasks.every((n)=>!n.hasTitle()))return this.logger.icon("PENDING");else if(t.isCompleted()&&t.subtasks.some((n)=>n.hasFailed()))return this.logger.icon("COMPLETED_WITH_FAILED_SUBTASKS");else if(t.hasFailed())return this.logger.icon("FAILED_WITH_SUBTASKS")}if(t.isStarted()||t.isPrompt())return this.logger.icon("PENDING",!this.options?.lazy&&this.spinner.fetch());else if(t.isCompleted())return this.logger.icon("COMPLETED");else if(t.isRetrying())return this.logger.icon("RETRY",!this.options?.lazy&&this.spinner.fetch());else if(t.isRollingBack())return this.logger.icon("ROLLING_BACK",!this.options?.lazy&&this.spinner.fetch());else if(t.hasRolledBack())return this.logger.icon("ROLLED_BACK");else if(t.hasFailed())return this.logger.icon("FAILED");else if(t.isCancelled())return this.logger.icon("CANCELLED");else if(t.isPaused())return this.logger.icon("PAUSED");return this.logger.icon("WAITING")}format(t,r,o){if(t.trim()==="")return[];if(r)t=r+" "+t;let n,i=(this.logger.process.stdout.columns??80)-o*this.options.indentation-2;switch(this.options.formatOutput){case"truncate":n=t.split(Ae).map((s,a)=>this.truncate(this.indent(s,a),i));break;case"wrap":n=this.wrap(t,i,{hard:!0,trim:!1}).split(Ae).map((s,a)=>this.indent(s,a));break;default:throw new rg("Format option for the renderer is wrong.")}if(this.options.removeEmptyLines)n=n.filter(Boolean);return n.map((s)=>og(s,o*this.options.indentation))}shouldOutputToOutputBar(t){let r=this.cache.rendererTaskOptions.get(t.id).outputBar;return typeof r==="number"&&r!==0||typeof r==="boolean"&&r!==!1}shouldOutputToBottomBar(t){let r=this.cache.rendererTaskOptions.get(t.id).bottomBar;return typeof r==="number"&&r!==0||typeof r==="boolean"&&r!==!1||!t.hasTitle()}refresh=()=>{this.update()};renderer(t,r=0){return t.flatMap((o)=>{if(!o.isEnabled())return[];if(this.cache.render.has(o.id))return this.cache.render.get(o.id);this.calculate(o),this.setupBuffer(o);let n=this.cache.rendererOptions.get(o.id),i=this.cache.rendererTaskOptions.get(o.id),s=[];if(o.isPrompt()){if(this.activePrompt&&this.activePrompt!==o.id)throw new rg("Only one prompt can be active at the given time, please re-evaluate your task design.");else if(!this.activePrompt)o.on("PROMPT",(a)=>{let c=hr(a);if(c)this.prompt=c}),o.on("STATE",(a)=>{if(a==="PROMPT_COMPLETED"||o.hasFinalized()||o.hasReset())this.prompt=null,this.activePrompt=null,o.off("PROMPT")}),this.activePrompt=o.id}if(o.hasTitle())if(!(t.some((a)=>a.hasFailed())&&!o.hasFailed()&&o.options.exitOnError!==!1&&!(o.isCompleted()||o.isSkipped()||o.isCancelled())))if(o.hasFailed()&&n.collapseErrors)s.push(...this.format(!o.hasSubtasks()&&o.message.error&&n.showErrorMessage?o.message.error:o.title,this.style(o),r));else if(o.isSkipped()&&n.collapseSkips)s.push(...this.format(this.logger.suffix(o.message.skip&&n.showSkipMessage?o.message.skip:o.title,{field:"SKIPPED",condition:n.suffixSkips,format:()=>z.dim}),this.style(o),r));else if(o.isRetrying())s.push(...this.format(this.logger.suffix(o.title,{field:`RETRY:${o.message.retry.count}`,format:()=>z.yellow,condition:n.suffixRetries}),this.style(o),r));else if(o.isCompleted()&&o.hasTitle()&&Et(i.timer?.condition,o.message.duration))s.push(...this.format(this.logger.suffix(o?.title,{...i.timer,args:[o.message.duration]}),this.style(o),r));else if(o.isPaused())s.push(...this.format(this.logger.suffix(o.title,{...n.pausedTimer,args:[o.message.paused-Date.now()]}),this.style(o),r));else s.push(...this.format(o.title,this.style(o),r));else s.push(...this.format(o.title,this.logger.icon("COMPLETED_WITH_SISTER_TASKS_FAILED"),r));if(!o.hasSubtasks()||!n.showSubtasks){if(o.hasFailed()&&n.collapseErrors===!1&&(n.showErrorMessage||!n.showSubtasks))s.push(...this.dump(o,r,"FAILED"));else if(o.isSkipped()&&n.collapseSkips===!1&&(n.showSkipMessage||!n.showSubtasks))s.push(...this.dump(o,r,"SKIPPED"))}if(o.isPending()||i.persistentOutput)s.push(...this.renderOutputBar(o,r));if(n.showSubtasks!==!1&&o.hasSubtasks()&&(o.isPending()||o.hasFinalized()&&!o.hasTitle()||o.isCompleted()&&n.collapseSubtasks===!1&&!o.subtasks.some((a)=>this.cache.rendererOptions.get(a.id)?.collapseSubtasks===!0)||o.subtasks.some((a)=>this.cache.rendererOptions.get(a.id)?.collapseSubtasks===!1)||o.subtasks.some((a)=>a.hasFailed())||o.subtasks.some((a)=>a.hasRolledBack())||o.subtasks.some((a)=>a.isCancelled()))){let a=!o.hasTitle()?r:r+1,c=this.renderer(o.subtasks,a);s.push(...c)}if(o.hasFinalized()){if(!i.persistentOutput)this.buffer.bottom.delete(o.id),this.buffer.output.delete(o.id)}if(o.isClosed())this.cache.render.set(o.id,s),this.reset(o);return s})}renderOutputBar(t,r){let o=this.buffer.output.get(t.id);if(!o)return[];return o.all.flatMap((n)=>this.dump(t,r,"OUTPUT",n.entry))}renderBottomBar(){if(this.buffer.bottom.size===0)return[];return Array.from(this.buffer.bottom.values()).flatMap((t)=>t.all).sort((t,r)=>t.time-r.time).map((t)=>t.entry)}renderPrompt(){if(!this.prompt)return[];return[this.prompt]}calculate(t){if(this.cache.rendererOptions.has(t.id)&&this.cache.rendererTaskOptions.has(t.id))return;let r={...this.options,...t.rendererOptions};this.cache.rendererOptions.set(t.id,r),this.cache.rendererTaskOptions.set(t.id,{...e.rendererTaskOptions,timer:r.timer,...t.rendererTaskOptions})}setupBuffer(t){if(this.buffer.bottom.has(t.id)||this.buffer.output.has(t.id))return;if(t.hasFinalized())return;let r=this.cache.rendererTaskOptions.get(t.id);if(this.shouldOutputToBottomBar(t)&&!this.buffer.bottom.has(t.id))this.buffer.bottom.set(t.id,new Oa({limit:typeof r.bottomBar==="number"?r.bottomBar:1})),t.on("OUTPUT",(o)=>{let n=this.dump(t,-1,"OUTPUT",o);this.buffer.bottom.get(t.id).write(n.join(Ae))}),t.on("OUTPUT_RESET",()=>{this.buffer.bottom.get(t.id)?.reset()}),t.on("STATE",(o)=>{if(o==="RETRY"||o==="ROLLING_BACK")this.buffer.bottom.delete(t.id)});else if(this.shouldOutputToOutputBar(t)&&!this.buffer.output.has(t.id))this.buffer.output.set(t.id,new Oa({limit:typeof r.outputBar==="number"?r.outputBar:1})),t.on("OUTPUT",(o)=>{this.buffer.output.get(t.id).write(o)}),t.on("OUTPUT_RESET",()=>{this.buffer.output.get(t.id)?.reset()}),t.on("STATE",(o)=>{if(o==="RETRY"||o==="ROLLING_BACK")this.buffer.output.delete(t.id)})}reset(t){this.cache.rendererOptions.delete(t.id),this.cache.rendererTaskOptions.delete(t.id),this.buffer.output.delete(t.id)}dump(t,r,o="OUTPUT",n){if(!n)switch(o){case"OUTPUT":n=t.output;break;case"SKIPPED":n=t.message.skip;break;case"FAILED":n=t.message.error;break}if(t.hasTitle()&&o==="FAILED"&&n===t.title||typeof n!=="string")return[];if(o==="OUTPUT")n=hr(n);return this.format(n,this.style(t,!0),r+1)}indent(t,r){return r>0?og(t.trimEnd(),this.options.indentation):t.trimEnd()}},JE=class e{tasks;options;static nonTTY=!0;static rendererOptions={pausedTimer:{...Ia,field:(t)=>`PAUSED:${t}`,format:()=>z.yellowBright}};static rendererTaskOptions={};logger;cache={rendererOptions:new Map,rendererTaskOptions:new Map};constructor(t,r){if(this.tasks=t,this.options=r,this.options={...e.rendererOptions,...r,icon:{...nn.icon,...r?.icon??{}},color:{...nn.color,...r?.color??{}}},this.logger=this.options.logger??new sn({useIcons:!0,toStderr:pg}),this.logger.options.icon=this.options.icon,this.logger.options.color=this.options.color,this.options.timestamp)this.logger.options.fields.prefix.unshift(this.options.timestamp)}end(){}render(){this.renderer(this.tasks)}renderer(t){t.forEach((r)=>{this.calculate(r),r.once("CLOSED",()=>{this.reset(r)});let o=this.cache.rendererOptions.get(r.id),n=this.cache.rendererTaskOptions.get(r.id);r.on("SUBTASK",(i)=>{this.renderer(i)}),r.on("STATE",(i)=>{if(!r.hasTitle())return;if(i==="STARTED")this.logger.log("STARTED",r.title);else if(i==="COMPLETED"){let s=n?.timer;this.logger.log("COMPLETED",r.title,s&&{suffix:{...s,condition:!!r.message?.duration&&s.condition,args:[r.message.duration]}})}else if(i==="PROMPT")this.logger.process.hijack(),r.on("PROMPT",(s)=>{this.logger.process.toStderr(s,!1)});else if(i==="PROMPT_COMPLETED")r.off("PROMPT"),this.logger.process.release();else if(i==="CANCELLED")this.logger.log("CANCELLED",r.title)}),r.on("OUTPUT",(i)=>{this.logger.log("OUTPUT",i)}),r.on("MESSAGE",(i)=>{if(i.error)this.logger.log("FAILED",r.title,{suffix:{field:`FAILED: ${i.error}`,format:()=>z.red}});else if(i.skip)this.logger.log("SKIPPED",r.title,{suffix:{field:`SKIPPED: ${i.skip}`,format:()=>z.yellow}});else if(i.rollback)this.logger.log("ROLLBACK",r.title,{suffix:{field:`ROLLBACK: ${i.rollback}`,format:()=>z.red}});else if(i.retry)this.logger.log("RETRY",r.title,{suffix:{field:`RETRY:${i.retry.count}`,format:()=>z.red}});else if(i.paused){let s=o?.pausedTimer;this.logger.log("PAUSED",r.title,s&&{suffix:{...s,condition:!!i?.paused&&s.condition,args:[i.paused-Date.now()]}})}})})}calculate(t){if(this.cache.rendererOptions.has(t.id)&&this.cache.rendererTaskOptions.has(t.id))return;let r={...this.options,...t.rendererOptions};this.cache.rendererOptions.set(t.id,r),this.cache.rendererTaskOptions.set(t.id,{...e.rendererTaskOptions,timer:r.timer,...t.rendererTaskOptions})}reset(t){this.cache.rendererOptions.delete(t.id),this.cache.rendererTaskOptions.delete(t.id)}},XE=class e{tasks;options;static nonTTY=!0;static rendererOptions={subtasks:!0,state:Object.values(LE),output:!0,prompt:!0,title:!0,messages:["skip","error","retry","rollback","paused"],messagesToStderr:["error","rollback","retry"],task:["hasRolledBack","isRollingBack","isCompleted","isSkipped","hasFinalized","hasSubtasks","title","hasReset","hasTitle","isPrompt","isPaused","isPending","isCancelled","isStarted","hasFailed","isEnabled","isRetrying","path"]};static rendererTaskOptions;logger;serializer;constructor(t,r){this.tasks=t,this.options=r,this.options={...e.rendererOptions,...this.options},this.logger=this.options.logger??new sn({useIcons:!1}),this.serializer=new YE(this.options)}render(){this.renderer(this.tasks)}end(){}renderer(t){t.forEach((r)=>{if(this.options.subtasks)r.on("SUBTASK",(o)=>{this.renderer(o)});if(this.options.state)r.on("STATE",(o)=>{this.logger.toStdout(this.serializer.serialize("STATE",o,r))});if(this.options.output)r.on("OUTPUT",(o)=>{this.logger.toStdout(this.serializer.serialize("OUTPUT",o,r))});if(this.options.prompt)r.on("PROMPT",(o)=>{this.logger.toStdout(this.serializer.serialize("PROMPT",o,r))});if(this.options.title)r.on("TITLE",(o)=>{this.logger.toStdout(this.serializer.serialize("TITLE",o,r))});r.on("MESSAGE",(o)=>{let n=Object.fromEntries(Object.entries(o).map(([i,s])=>{if(this.options.messages.includes(i))return[i,s]}).filter(Boolean));if(Object.keys(n).length>0){let i=this.serializer.serialize("MESSAGE",n,r);if(this.options.messagesToStderr.some((s)=>Object.keys(n).includes(s)))this.logger.toStderr(i);else this.logger.toStdout(i)}})})}},eS=class e{tasks;options;static nonTTY=!0;static rendererOptions={logTitleChange:!1,pausedTimer:{...Ia,format:()=>z.yellowBright}};static rendererTaskOptions;logger;cache={rendererOptions:new Map,rendererTaskOptions:new Map};constructor(t,r){if(this.tasks=t,this.options=r,this.options={...e.rendererOptions,...this.options,icon:{...nn.icon,...r?.icon??{}},color:{...nn.color,...r?.color??{}}},this.logger=this.options.logger??new sn({useIcons:!1,toStderr:pg}),this.logger.options.icon=this.options.icon,this.logger.options.color=this.options.color,this.options.timestamp)this.logger.options.fields.prefix.unshift(this.options.timestamp)}render(){this.renderer(this.tasks)}end(){}renderer(t){t.forEach((r)=>{this.calculate(r),r.once("CLOSED",()=>{this.reset(r)});let o=this.cache.rendererOptions.get(r.id),n=this.cache.rendererTaskOptions.get(r.id);if(r.on("SUBTASK",(i)=>{this.renderer(i)}),r.on("STATE",(i)=>{if(!r.hasTitle())return;if(i==="STARTED")this.logger.log("STARTED",r.title);else if(i==="COMPLETED"){let s=n.timer;this.logger.log("COMPLETED",r.title,s&&{suffix:{...s,condition:!!r.message?.duration&&s.condition,args:[r.message.duration]}})}else if(i==="CANCELLED")this.logger.log("CANCELLED",r.title)}),r.on("OUTPUT",(i)=>{this.logger.log("OUTPUT",i)}),r.on("PROMPT",(i)=>{let s=hr(i);if(s)this.logger.log("PROMPT",s)}),this.options?.logTitleChange!==!1)r.on("TITLE",(i)=>{this.logger.log("TITLE",i)});r.on("MESSAGE",(i)=>{if(i?.error)this.logger.log("FAILED",i.error);else if(i?.skip)this.logger.log("SKIPPED",i.skip);else if(i?.rollback)this.logger.log("ROLLBACK",i.rollback);else if(i?.retry)this.logger.log("RETRY",r.title,{suffix:i.retry.count.toString()});else if(i?.paused){let s=o?.pausedTimer;this.logger.log("PAUSED",r.title,s&&{suffix:{...s,condition:!!i?.paused&&s.condition,args:[i.paused-Date.now()]}})}})})}calculate(t){if(this.cache.rendererOptions.has(t.id)&&this.cache.rendererTaskOptions.has(t.id))return;let r={...this.options,...t.rendererOptions};this.cache.rendererOptions.set(t.id,r),this.cache.rendererTaskOptions.set(t.id,{...e.rendererTaskOptions,timer:r.timer,...t.rendererTaskOptions})}reset(t){this.cache.rendererOptions.delete(t.id),this.cache.rendererTaskOptions.delete(t.id)}},Ta={default:KE,simple:JE,verbose:eS,test:XE,silent:HE};sS=class extends cg{},aS=class extends sS{listr;task;options;rendererOptions;rendererTaskOptions;id=NE();state="WAITING";subtasks;title;initialTitle;output;retry;message={};prompt;parent;enabled;taskFn;closed;constructor(e,t,r,o,n){super();if(this.listr=e,this.task=t,this.options=r,this.rendererOptions=o,this.rendererTaskOptions=n,t.title){let i=Array.isArray(t?.title)?t.title:[t.title];this.title=mr(i.shift(),...i),this.initialTitle=this.title}this.taskFn=t.task,this.parent=e.parentTask}set state$(e){if(this.state=e,this.emit("STATE",e),this.hasSubtasks()&&this.hasFailed()){for(let t of this.subtasks)if(t.state==="STARTED")t.state$="FAILED"}this.listr.events.emit("SHOUD_REFRESH_RENDER")}set output$(e){this.output=e,this.emit("OUTPUT",e),this.listr.events.emit("SHOUD_REFRESH_RENDER")}set outputReset$(e){this.output=e,this.emit("OUTPUT_RESET"),this.listr.events.emit("SHOUD_REFRESH_RENDER")}set promptOutput$(e){if(this.emit("PROMPT",e),hr(e))this.listr.events.emit("SHOUD_REFRESH_RENDER")}set message$(e){this.message={...this.message,...e},this.emit("MESSAGE",e),this.listr.events.emit("SHOUD_REFRESH_RENDER")}set title$(e){this.title=e,this.emit("TITLE",e),this.listr.events.emit("SHOUD_REFRESH_RENDER")}get path(){return[...this.listr.path,this.initialTitle]}async check(e){if(this.state==="WAITING")this.enabled=await Et(this.task?.enabled??!0,e),this.emit("ENABLED",this.enabled),this.listr.events.emit("SHOUD_REFRESH_RENDER");return this.enabled}hasSubtasks(){return this.subtasks?.length>0}hasFinalized(){return this.isCompleted()||this.hasFailed()||this.isSkipped()||this.hasRolledBack()||this.isCancelled()}isPending(){return this.isStarted()||this.isPrompt()||this.hasReset()}isStarted(){return this.state==="STARTED"}isSkipped(){return this.state==="SKIPPED"}isCompleted(){return this.state==="COMPLETED"}hasFailed(){return this.state==="FAILED"}isCancelled(){return this.state==="CANCELLED"}isRollingBack(){return this.state==="ROLLING_BACK"}hasRolledBack(){return this.state==="ROLLED_BACK"}isRetrying(){return this.state==="RETRY"}hasReset(){return this.state==="RETRY"||this.state==="ROLLING_BACK"}isEnabled(){return this.enabled}hasTitle(){return typeof this?.title==="string"}isPrompt(){return this.state==="PROMPT"}isPaused(){return this.state==="PAUSED"}isClosed(){return this.closed}async pause(e){let t=this.state;this.state$="PAUSED",this.message$={paused:Date.now()+e},await nS(e),this.state$=t,this.message$={paused:null}}async run(e,t){let r=(i)=>{if(i instanceof he)i.options={...this.options,...i.options},i.rendererClass=on("silent"),this.subtasks=i.tasks,i.errors=this.listr.errors,this.emit("SUBTASK",this.subtasks),i=i.run(e);else if(i instanceof Promise)i=i.then(r);else if(FE(i))i=new Promise((s,a)=>{i.on("data",(c)=>{this.output$=c.toString()}),i.on("error",(c)=>a(c)),i.on("end",()=>s(null))});else if(ME(i))i=new Promise((s,a)=>{i.subscribe({next:(c)=>{this.output$=c},error:a,complete:s})});return i},o=Date.now();this.state$="STARTED";let n=await Et(this.task?.skip??!1,e);if(n){if(typeof n==="string")this.message$={skip:n};else if(this.hasTitle())this.message$={skip:this.title};else this.message$={skip:"Skipped task without a title."};this.state$="SKIPPED";return}try{let i=typeof this.task?.retry==="number"&&this.task.retry>0?this.task.retry+1:typeof this.task?.retry==="object"&&this.task.retry.tries>0?this.task.retry.tries+1:1,s=typeof this.task.retry==="object"&&this.task.retry.delay;for(let a=1;a<=i;a++)try{await Promise.race([r(this.taskFn(e,t)),this.whenInterrupted()]);break}catch(c){if(this.listr.signal.aborted)throw c;if(a!==i){if(this.retry={count:a,error:c},this.message$={retry:this.retry},this.title$=this.initialTitle,this.output=void 0,t.report(c,"WILL_RETRY"),this.state$="RETRY",s)await this.pause(s)}else throw c}if(this.isStarted()||this.isRetrying())this.message$={duration:Date.now()-o},this.state$="COMPLETED"}catch(i){if(this.prompt instanceof UE)i=this.prompt;if(this.task?.rollback){t.report(i,"WILL_ROLLBACK");try{this.state$="ROLLING_BACK",await this.task.rollback(e,t),this.message$={rollback:this.title},this.state$="ROLLED_BACK"}catch(s){throw this.state$="FAILED",t.report(s,"HAS_FAILED_TO_ROLLBACK"),this.close(),s}if(this.listr.options?.exitAfterRollback!==!1)throw this.close(),i}else{if(this.listr.signal.aborted)throw this.state$="CANCELLED",i;if(this.state$="FAILED",this.listr.options.exitOnError!==!1&&await Et(this.task?.exitOnError,e)!==!1)throw t.report(i,"HAS_FAILED"),this.close(),i;else if(!this.hasSubtasks())t.report(i,"HAS_FAILED_WITHOUT_ERROR")}}finally{this.close()}}close(){this.emit("CLOSED"),this.listr.events.emit("SHOUD_REFRESH_RENDER"),this.complete()}whenInterrupted(){return new Promise((e,t)=>{let r=()=>{if(!this.hasSubtasks())t(Error("Interrupted."))};if(this.listr.signal.aborted){r();return}this.listr.signal.addEventListener("abort",r,{once:!0})})}},sg=class extends cg{}});function cS(e){return typeof e==="string"&&/^sha256:[a-f0-9]{64}$/.test(e)}function dg(e){if(!cS(e))throw Error(`Invalid SHA-256 digest: ${e}`)}var gr=1;import{AsyncLocalStorage as uS}from"async_hooks";function Ba(e){return e["x-arch"]==="amd64"?"amd64":"arm64"}function fg(e){if(Ba(e)!=="amd64")return{};return{nodeSelector:{"kubernetes.io/arch":"amd64"},tolerations:[{key:"arch",operator:"Equal",value:"amd64",effect:"NoExecute"}]}}var CT;var za=_(()=>{CT=new uS});import{execFile as lS,spawn as pS}from"child_process";import{createHash as dS}from"crypto";import{constants as Da}from"fs";import{access as fS}from"fs/promises";import{chmod as DT,lstat as mS,mkdir as NT,open as hS,readdir as gg,readlink as gS,realpath as yS,symlink as LT,readFile as bS}from"fs/promises";import{delimiter as _S,dirname as wS,isAbsolute as La,relative as yr,resolve as $t,sep as br}from"path";import{promisify as vS}from"util";async function Ua(){for(let e of(process.env.PATH??"").split(_S)){if(!e)continue;try{return await fS($t(e,process.platform==="win32"?"git.exe":"git"),Da.X_OK),!0}catch{}}return!1}function Na(e){return`sha256:${dS("sha256").update(e).digest("hex")}`}function yg(e){if(!e||e.includes("\x00")||e.includes("\\")||La(e)||e.split("/").some((t)=>!t||t==="."||t===".."))throw Error(`Unsafe workspace path: ${JSON.stringify(e)}`)}function mg(e,t){let r=yr(e,t);return r===""||!r.startsWith(`..${br}`)&&r!==".."&&!La(r)}async function hg(e,t){let{stdout:r}=await Va("git",["-C",e,"ls-files","-z",...t],{encoding:"buffer",maxBuffer:67108864}),o=new TextDecoder("utf-8",{fatal:!0}),n=[],i=0;for(let s=r.indexOf(0);s!==-1;s=r.indexOf(0,i)){if(s>i)n.push(o.decode(r.subarray(i,s)));i=s+1}return n}async function xS(e){let[t,r]=await Promise.all([hg(e,["--cached","--others","--exclude-standard"]),hg(e,["--others","--ignored","--exclude-standard","--",".env*","**/.env*"])]);return[...new Set([...t,...r])].sort((o,n)=>Buffer.from(o).compare(Buffer.from(n)))}async function ES(e){let t=[],r=new Set([".git",".hg",".svn","node_modules","vendor","bower_components",".venv","venv","__pycache__",".tox",".mypy_cache",".pytest_cache",".next",".nuxt",".svelte-kit",".cache",".turbo","dist","build","coverage","target","out","tmp","temp"]),o=/(?:^|[-_.])(?:secrets?|credentials?|configs?)(?:$|[-_.])/i,n=[],i=async(c)=>{try{let u=await bS($t(c,".gitignore"),"utf8");for(let l of u.split(/\r?\n/)){let f=l.trim();if(!f||f.startsWith("#"))continue;if(f.startsWith("!"))continue;let d=f.replace(/^\//,"");if(d)n.push({base:yr(e,c).split(br).join("/"),pattern:d.replace(/\/$/,""),directory:f.endsWith("/")})}}catch(u){if(u.code!=="ENOENT")throw u}},s=(c,u)=>{let l=!1;for(let f of n){let d=f.base?`${f.base}/`:"";if(f.base&&c!==f.base&&!c.startsWith(d))continue;let p=f.base&&c.startsWith(d)?c.slice(d.length):c,m=f.pattern.replace(/[.+^${}()|[\]\\]/g,"\\$&").replace(/\*\*/g,"__DOUBLESTAR__").replace(/\*/g,"[^/]*").replace(/\?/g,"[^/]").replace(/__DOUBLESTAR__/g,".*"),h=new RegExp(`^(?:${m})(?:/.*)?$`),y=new RegExp(`^(?:${m})$`);if((h.test(p)||p.split("/").some((b)=>y.test(b)))&&(!f.directory||u||p.includes("/")))l=!0}return l},a=async(c)=>{await i(c);for(let u of await gg(c,{withFileTypes:!0})){let l=$t(c,u.name),f=yr(e,l).split(br).join("/");if(u.isDirectory()){if(r.has(u.name)||o.test(u.name)||s(f,!0))continue;await a(l)}else if(u.isFile()||u.isSymbolicLink()){if(s(f,!1))continue;if(/^\.env/i.test(u.name)||/(?:secret|credential|password|token|private[-_.]?key)/i.test(u.name)||/^(?:id_rsa|id_ed25519|known_hosts|config\.json|\.npmrc|\.pypirc|\.netrc)$/i.test(u.name))continue;t.push(f)}else throw Error(`Special files are not allowed in workspaces: ${yr(e,l).split(br).join("/")}`)}};return await a(e),t.sort((c,u)=>Buffer.from(c).compare(Buffer.from(u)))}async function SS(e){if(!await Ua())return!1;try{return await Va("git",["-C",e,"rev-parse","--show-toplevel"]),!0}catch(t){let{code:r,exitCode:o}=t,n=t instanceof Error?t.message:String(t);if(r==="ENOENT")return!1;if(o===128||r===128||/not a git repository/i.test(n))return!1;throw t}}async function $S(e){let t=await Va("git",["-C",e,"ls-files","--others","--ignored","--exclude-standard","--directory","-z"],{encoding:"buffer",maxBuffer:67108864}),r=new TextDecoder("utf-8",{fatal:!0}),o=new Set,n=0;for(let m=t.stdout.indexOf(0);m!==-1;m=t.stdout.indexOf(0,n)){if(m>n){let h=r.decode(t.stdout.subarray(n,m));if(h.endsWith("/"))o.add(h.slice(0,-1))}n=m+1}let i=[],s=async(m)=>{for(let h of await gg(m,{withFileTypes:!0})){if(m===e&&h.name===".git")continue;let y=$t(m,h.name),b=yr(e,y).split(br).join("/");if(h.isDirectory()){if(!o.has(b))await s(y)}else if(!h.isFile()&&!h.isSymbolicLink())i.push(b)}};if(await s(e),i.length===0)return;let a=Buffer.from(`${i.join("\x00")}\x00`),c=pS("git",["-C",e,"check-ignore","--stdin","-z"]),u=[],l=[];c.stdout.on("data",(m)=>u.push(m)),c.stderr.on("data",(m)=>l.push(m));let f=new Promise((m,h)=>{c.once("error",h),c.once("close",(y)=>{if(y===0||y===1)m();else h(Error(Buffer.concat(l).toString("utf8")||`git check-ignore exited with ${y}`))})});c.stdin.end(a),await f;let d=Buffer.concat(u),p=new Set;n=0;for(let m=d.indexOf(0);m!==-1;m=d.indexOf(0,n)){if(m>n)p.add(r.decode(d.subarray(n,m)));n=m+1}for(let m of i){let h=m.slice(m.lastIndexOf("/")+1);if(!p.has(m)||h.startsWith(".env"))throw Error(`Special files are not allowed in workspaces: ${m}`)}}function AS(e){return JSON.stringify({version:e.version,files:e.files.map((t)=>({path:t.path,type:t.type,digest:t.digest,size:t.size,mode:t.mode}))})}function Ma(e){return PS(e),Buffer.from(AS(e))}function kS(e){return Na(Ma(e))}function PS(e){if(e.version!==gr||!Array.isArray(e.files))throw Error("Unsupported workspace manifest");let t="",r=new Set;for(let o of e.files){if(yg(o.path),dg(o.digest),!Number.isSafeInteger(o.size)||o.size<0)throw Error(`Invalid size for ${o.path}`);if(o.type==="file"&&o.mode!==420&&o.mode!==493||o.type==="symlink"&&o.mode!==511)throw Error(`Invalid mode for ${o.path}`);if(o.type!=="file"&&o.type!=="symlink")throw Error(`Invalid entry type for ${o.path}`);if(r.has(o.path))throw Error(`Duplicate workspace path: ${o.path}`);for(let n of o.path.split("/").slice(0,-1).map((i,s,a)=>a.slice(0,s+1).join("/")))if(r.has(n))throw Error(`Workspace entry is used as a directory: ${n}`);if(t&&Buffer.from(t).compare(Buffer.from(o.path))>=0)throw Error("Workspace files must be bytewise sorted");r.add(o.path),t=o.path}}async function an(e){let t=await yS(e),o=await SS(t)?await(async()=>(await $S(t),xS(t)))():await ES(t),n=[],i=new Map;for(let a of o){yg(a);let c=$t(t,a);if(!mg(t,c))throw Error(`Workspace path escapes root: ${a}`);let u;try{u=await mS(c)}catch(d){if(d.code==="ENOENT")continue;throw d}let l,f;if(u.isSymbolicLink()){let d=await gS(c);if(La(d)||!mg(t,$t(wS(c),d)))throw Error(`Symlink escapes workspace: ${a} -> ${d}`);l=Buffer.from(d),f={path:a,type:"symlink",digest:Na(l),size:l.byteLength,mode:511}}else if(u.isFile()){let d,p=await hS(c,Da.O_RDONLY|Da.O_NOFOLLOW);try{let m=await p.stat();if(!m.isFile())throw Error(`Not a regular file: ${a}`);d=m.mode&73?493:420,l=await p.readFile()}finally{await p.close()}f={path:a,type:"file",digest:Na(l),size:l.byteLength,mode:d}}else throw Error(`Special files are not allowed in workspaces: ${a}`);n.push(f),i.set(f.digest,l)}let s={version:gr,files:n};return{manifest:s,digest:kS(s),blobs:[...i].map(([a,c])=>({digest:a,data:c}))}}var Va;var Fa=_(()=>{Va=vS(lS)});import{randomUUID as CS}from"crypto";import{execFile as RS}from"child_process";import{isAbsolute as TS,relative as xg,resolve as bg,sep as Eg}from"path";import{promisify as OS}from"util";class $g{inflight=0;maxInflight;maxPerSecond;requestStarts=[];waiting=[];rateGate=Promise.resolve();clock;sleep;constructor(e){if(this.maxInflight=e?.maxInflight??NS,this.maxPerSecond=e?.maxPerSecond??LS,!Number.isSafeInteger(this.maxInflight)||this.maxInflight<1)throw RangeError("maxInflight must be a positive integer");if(!Number.isSafeInteger(this.maxPerSecond)||this.maxPerSecond<1)throw RangeError("maxPerSecond must be a positive integer");this.clock=e?.clock??{now:()=>Date.now()},this.sleep=e?.sleep??((t)=>Bun.sleep(t))}get currentInflight(){return this.inflight}get maxConcurrent(){return this.maxInflight}get currentRequestStarts(){return this.pruneOldStarts(),this.requestStarts.length}pruneOldStarts(){let e=this.clock.now()-1000;while(this.requestStarts.length>0&&this.requestStarts[0]<=e)this.requestStarts.shift()}async acquire(){if(this.inflight<this.maxInflight){this.inflight++;return}await new Promise((e)=>{this.waiting.push(e)})}release(){if(this.waiting.length>0)this.waiting.shift()();else this.inflight--}waitForRateLimit(){let e=this.rateGate.then(async()=>{for(;;){if(this.pruneOldStarts(),this.requestStarts.length<this.maxPerSecond){this.requestStarts.push(this.clock.now());return}let t=this.requestStarts[0];await this.sleep(Math.max(1,t+1000-this.clock.now()))}});return this.rateGate=e.catch(()=>{}),e}async run(e){await this.acquire();try{return await this.waitForRateLimit(),await e()}finally{this.release()}}}async function VS(e,t,r){let o=0,n=async()=>{for(;;){let i=o++;if(i>=e.length)return;await r(e[i])}};await Promise.all(Array.from({length:Math.min(t,e.length)},n))}function US(e,t){return xg(e,t).split(Eg).join("/")||"."}function wg(e,t,r,o){let n=xg(e,t);if(n.startsWith(`..${Eg}`)||n===".."||TS(n))throw Error(`${r} must stay inside the git repo for service ${o}`);return US(e,t)}function MS(e){if(!e.build||typeof e.build==="string"||!e.build.args)return[];if(Array.isArray(e.build.args))return[...e.build.args];return Object.entries(e.build.args).filter(([,t])=>t!==null).map(([t,r])=>`${t}=${String(r)}`)}function FS(e,t,r,o,n,i){if(!r.build)return;let s=r.build,a=typeof s==="string"?s:s.context??".";if(a.includes("://"))throw Error(`Remote build context is not supported for service ${t}`);if(typeof s!=="string"&&s.dockerfile_inline)throw Error(`dockerfile_inline is not supported for service ${t}`);let c=bg(o,a),u=wg(n,c,"Build context",t),l=typeof s==="string"||!s.dockerfile?void 0:bg(c,s.dockerfile);return{name:t,image:jS(e,t,i),context:u,dockerfile:l?wg(n,l,"Dockerfile",t):void 0,target:typeof s==="string"?void 0:s.target,buildArgs:MS(r)}}function jS(e,t,r=To){return`${r.replace(/\/+$/,"")}/kuber/${e}-${t}:latest`}async function ja(e){if(!await Ua())return e;try{let{stdout:t}=await IS("git",["-C",e,"rev-parse","--show-toplevel"]);return t.trim()}catch(t){if(t.code==="ENOENT")return e;throw t}}async function ZS(e,t,r,o,n){let i=`/blobs/${encodeURIComponent(e)}/uploads`,s=n?`?project=${encodeURIComponent(n)}`:"",a=`${i}${s}`,c=await o.run(()=>r(a,{method:"POST",json:{size:t.byteLength}})),u=c.offset;while(!c.complete&&u<t.byteLength){let l=t.subarray(u,u+BS),f=await o.run(()=>r(a,{method:"PATCH",headers:{"content-type":"application/octet-stream","upload-offset":String(u)},body:l}));if(f.offset<=u)throw Error(`Blob upload for ${e} made no progress`);u=f.offset}if(!c.complete)await o.run(()=>r(`${i}/complete${s}`,{method:"POST",json:{}}))}async function qS(e,t=C,r,o,n){let i=new Map(e.blobs.map((a)=>[a.digest,a.data]));i.set(e.digest,Ma(e.manifest));let s=o??new $g;for(;;){let a=await s.run(()=>t("/snapshots/negotiate",{method:"POST",json:{workspace:e.digest,...n&&{project:n}}}));if(a.ready)return;if(a.missing.length===0)throw Error("Snapshot negotiation is incomplete but reported no missing blobs");await VS(a.missing,s.maxConcurrent,async(c)=>{let u=i.get(c);if(!u)throw Error(`Server requested unknown workspace blob ${c}`);await r?.progress?.(`Uploading ${c}`),await ZS(c,u,t,s,n)})}}async function QS(e,t,r,o){if(e.type==="status"){let n=e.status.phase??(e.status.state==="succeeded"||e.status.state==="failed"?"done":e.status.state);if(!r?.has(n))r?.add(n),await t?.progress?.(`${o?`${o}: `:""}Build ${n}${e.status.state==="failed"?`: ${e.status.error??"unknown error"}`:""}`);return}if(t?.stream)t.stream.write(o?`[${o}] ${e.message}`:e.message);else await t?.progress?.(`${o?`${o}: `:""}${e.message.trimEnd()}`)}function WS(e){if(!(e instanceof Error)||e.name==="AbortError")return!1;if(e.name==="TimeoutError"||e instanceof TypeError)return!0;let t="code"in e&&typeof e.code==="string"?e.code:e.cause&&typeof e.cause==="object"&&("code"in e.cause)&&typeof e.cause.code==="string"?e.cause.code:void 0;return t==="ECONNABORTED"||t==="ECONNRESET"||t==="ECONNREFUSED"||t==="EAI_AGAIN"||t==="ETIMEDOUT"}async function vg(e,t,r,o,n,i){for(let s=1;s<=_g;s++)try{return i?.throwIfAborted(),await e(t,{...r,signal:i},{timeoutMs:DS})}catch(a){if(!WS(a)||s===_g)throw a;i?.throwIfAborted(),await n(o)}throw Error("Build poll retries exhausted")}async function GS(e,t,r,o,n,i,s,a=!1){let c=i,u=0,l="",f=new Map;for(let{name:d,reporter:p}of r)if(!f.has(p))f.set(p,{name:d,reporter:p,states:new Set});for(;;){let d=await vg(t,`/builds/${encodeURIComponent(e)}/events?after=${u}`,void 0,o,n,s);for(let p of d){if(p.type==="log"&&p.sequence<=u)continue;if(p.type==="log")l=(l+p.message).slice(-8192);for(let{name:m,reporter:h,states:y}of f.values())await QS(p,h,y,a?m:void 0);if(p.type==="log")u=p.sequence}if(c.state==="succeeded"||c.state==="failed"){let p=l.trim();if(c.state==="failed"&&p&&!c.error?.includes(p))return{...c,error:`${c.error??"BuildKit Job failed"}
|
|
100
|
-
${p}`};return c}if(c=await vg(t,`/builds/${encodeURIComponent(e)}/reconcile`,{method:"POST",json:{}},o,n,s),c.state!=="succeeded"&&c.state!=="failed")s?.throwIfAborted(),await n(o)}}async function cn(e,t,r={}){let o=r.request??C,n=Object.entries(t.services??{}).filter(([,a])=>a.build).map(([a])=>a),i=Array(n.length),s=0;return await Promise.all(Array.from({length:Math.min(Sg,n.length)},async()=>{for(;;){let a=s++;if(a>=n.length)return;let c=n[a];r.signal?.throwIfAborted();try{i[a]=(await o("/images/resolve",{method:"POST",json:{project:e,service:c},signal:r.signal})).reference}catch(u){throw Error(`Cannot resolve a published image for service ${c}. Run kuber up to build it.`,{cause:u})}}})),Object.fromEntries(n.map((a,c)=>[a,i[c]]))}async function Ag(e,t,r=process.cwd(),o,n={}){if(!Object.values(t.services??{}).some((x)=>x.build))return{built:[],changed:[],images:{}};let i=n.buildConcurrency??Sg;if(!Number.isSafeInteger(i)||i<1)throw RangeError("buildConcurrency must be a positive integer");let s=n.request??C,a=n.workspaceRoot;if(!a&&!n.snapshot)try{a=await ja(r)}catch(x){a=r}a??=r;let c=n.snapshot??await an(a),u=Object.entries(t.services??{}).flatMap(([x,k])=>{let T=FS(e,x,k,r,a,n.registry??To);return T?[T]:[]});await qS(c,s,o,n.scheduler,e);let l=Array(u.length),f=new Map(u.map((x)=>[x.name,o?.service?.(x.name)??o])),d=Ba(t),p=new Map;u.forEach((x,k)=>{let T=JSON.stringify({workspace:c.digest,architecture:d,context:x.context,dockerfile:x.dockerfile,target:x.target,buildArgs:x.buildArgs}),B=p.get(T)??[];B.push(k),p.set(T,B)});let m=[...p.values()],h=0,y,b=!1,P=async()=>{while(!b&&h<m.length){let x=m[h++],k=x.map((T)=>u[T]);try{n.signal?.throwIfAborted();for(let B of k)await f.get(B.name)?.progress?.(`${o?.service?"":`${B.name}: `}Build queued`);let T=await E(k);x.forEach((B)=>{let W=u[B],Te=B===x[0]?T.reference:T.references?.[W.name];if(!Te)throw Error(`Build result missing image for service ${W.name}`);l[B]=Te});for(let B of k)o?.settled?.(B.name)}catch(T){if(!b)y=T;b=!0;for(let B of k)o?.settled?.(B.name,T)}}},E=async(x)=>{let k=x[0],T=CS(),B={version:gr,id:T,project:e,service:k.name,...x.length>1&&{destinations:x.slice(1).map(({name:Ne,image:sb})=>({service:Ne,image:sb}))},spec:{architecture:d,image:k.image,context:k.context,dockerfile:k.dockerfile,target:k.target,buildArgs:k.buildArgs,workspace:c.digest}},W=await s("/builds",{method:"POST",json:B,signal:n.signal},{timeoutMs:300000}),Te=await GS(T,s,x.map(({name:Ne})=>({name:Ne,reporter:f.get(Ne)})),n.pollIntervalMs??zS,n.sleep??((Ne)=>Bun.sleep(Ne)),W,n.signal,!o?.service);if(Te.state!=="succeeded")throw Error(`Build failed for service ${k.name}: ${Te.error??"unknown error"}`);return await s(`/builds/${encodeURIComponent(T)}/result`,{signal:n.signal})};if(await Promise.all(Array.from({length:Math.min(i,m.length)},P)),b)throw y;let A=Object.fromEntries(u.map((x,k)=>[x.name,l[k]]));return{built:u.map((x)=>x.name),changed:u.map((x)=>x.name),images:A}}var IS,BS=8388608,zS=1000,DS=300000,_g=3,Sg=3,NS=20,LS=40;var Za=_(()=>{za();G();Oo();Fa();IS=OS(RS)});function kg(e){return KS[e.kind]??999}function Pg(e){return[...e].sort((t,r)=>kg(t)-kg(r))}var KS,oO,nO;var un=_(()=>{Fe();KS={Namespace:0,GarageBucket:1,GarageKey:2,ServiceAccount:3,ClusterRole:4,Role:5,ClusterRoleBinding:6,RoleBinding:7,StorageClass:8,PersistentVolumeClaim:9,Secret:10,ConfigMap:11,Service:12,Deployment:13,HorizontalPodAutoscaler:14,Ingress:15,IngressRoute:16},oO=`app.kubernetes.io/managed-by=${X["app.kubernetes.io/managed-by"]}`,nO=X["app.kubernetes.io/managed-by"]});function XS(e){return`${YS}-${e}`}function qa(e){return encodeURIComponent(e)}function Cg(e,t){return`postgresql://${qa(t.username)}:${qa(t.password)}@${Qa}:${Wa}/${qa(e.database)}`}function Rg(e){if(!e.startsWith("postgresql:"))return;let t=e.split(":");if(t.length!==2)throw Error(`Invalid postgres volume ${e}. Use postgresql:<name> or postgresql:<user>/<database>.`);let r=t[1]?.trim();if(!r)throw Error(`Invalid postgres volume ${e}. Use postgresql:<name> or postgresql:<user>/<database>.`);let o=r.split("/");if(o.length>2||o.some((s)=>s.trim()===""))throw Error(`Invalid postgres volume ${e}. Use postgresql:<name> or postgresql:<user>/<database>.`);let n=o[0],i=o[1]??n;return{username:n,database:i}}function Tg(e){return typeof e==="string"&&Rg(e)!==void 0}function e$(e,t){let r=t.volumes?.flatMap((o)=>{if(typeof o!=="string")return[];let n=Rg(o);return n?[{...n,service:e,secretName:XS(n.username)}]:[]})??[];if(r.length>1)throw Error(`Service ${e} declares multiple postgres volumes. Only zero or one postgresql:<...> entry is allowed per service.`);return r[0]}function st(e){let t=Object.entries(e.services??{}).flatMap(([o,n])=>{let i=e$(o,n);return i?[i]:[]}),r=new Map;for(let o of t){let n=r.get(o.database);if(n&&n!==o.username)throw Error(`Database ${o.database} is claimed by both ${n} and ${o.username}. A database can only have one owner.`);r.set(o.database,o.username)}return t}var JS="database",YS="postgres",Qa,Wa=5432;var _r=_(()=>{Fe();un();Qa=`c.${JS}.svc.cluster.local`});function ln(e,t){if(typeof e!=="object"||e===null||typeof t!=="object"||t===null)return t;let r=Array.isArray(e)?[...e]:{...e};for(let o of Object.keys(t)){let n=r[o],i=t[o];if(Array.isArray(n)&&Array.isArray(i))r[o]=[...n,...i];else if(n&&typeof n==="object"&&i&&typeof i==="object")r[o]=ln(n,i);else r[o]=i}return r}function Og(e){if(!e.startsWith("s3:"))return;let t=e.split(":");if(t.length!==2)throw Error(`Invalid S3 volume ${e}. Use s3:<name> or s3:<key>/<bucket>.`);let r=t[1]?.trim();if(!r)throw Error(`Invalid S3 volume ${e}. Use s3:<name> or s3:<key>/<bucket>.`);let o=r.split("/");if(o.length>2||o.some((s)=>s.trim()===""))throw Error(`Invalid S3 volume ${e}. Use s3:<name> or s3:<key>/<bucket>.`);let n=o[0],i=o[1]??n;return{key:n,bucket:i}}function Ig(e){return typeof e==="string"&&Og(e)!==void 0}function t$(e,t){let r=t.volumes?.flatMap((o)=>{if(typeof o!=="string")return[];let n=Og(o);return n?[{...n,service:e}]:[]})??[];if(r.length>1)throw Error(`Service ${e} declares multiple S3 volumes. Only zero or one s3:<...> entry is allowed per service.`);return r[0]}function at(e){let t=Object.entries(e.services??{}).flatMap(([o,n])=>{let i=t$(o,n);return i?[i]:[]}),r=new Map;for(let o of t){let n=r.get(o.key);if(n&&n!==o.bucket)throw Error(`S3 key ${o.key} is claimed for both ${n} and ${o.bucket}. A managed key can only target one bucket.`);r.set(o.key,o.bucket)}return t}var wr=_(()=>{Fe();un()});import{existsSync as Bg,readFileSync as r$,realpathSync as Ka,statSync as o$}from"fs";import{dirname as n$,isAbsolute as zg,normalize as i$,relative as s$,resolve as pn,sep as Dg}from"path";function At(e,t){return Object.assign(Error(e),t?{code:t}:{})}function a$(e){if(!e||e.includes("\x00")||e.includes("\\")||e.startsWith("~")||zg(e))throw At(`Artifact path must be workspace-relative: ${e}`);let t=i$(e);if(t===".."||t.startsWith(`..${Dg}`))throw At(`Artifact path escapes the workspace: ${e}`);return t.replace(/^\.\//,"")}function Ha(e,t){let r=s$(e,t);if(r===".."||r.startsWith(`..${Dg}`)||zg(r))throw At(`Artifact path escapes the workspace: ${t}`)}function c$(e,t){let r=t;while(!Bg(r)){let o=n$(r);if(o===r)break;r=o}Ha(e,Ka(r))}function Ga(e,t){if(t!==void 0&&(!Number.isSafeInteger(t)||t<0))throw Error(`${e} must be a non-negative safe integer`)}class Ng{#t;#r=0;#e=0;constructor(e){Ga("maxArtifactCount",e.maxArtifactCount),Ga("maxArtifactBytes",e.maxArtifactBytes),Ga("maxTotalBytes",e.maxTotalBytes),this.#t=e}add(e,t){let r=Buffer.byteLength(t);if(this.#t.maxArtifactBytes!==void 0&&r>this.#t.maxArtifactBytes)throw At(`Artifact ${e} exceeds the ${this.#t.maxArtifactBytes} byte limit`);if(this.#t.maxArtifactCount!==void 0&&this.#r+1>this.#t.maxArtifactCount)throw At(`Artifact count exceeds the ${this.#t.maxArtifactCount} limit`);if(this.#t.maxTotalBytes!==void 0&&this.#e+r>this.#t.maxTotalBytes)throw At(`Artifact bytes exceed the ${this.#t.maxTotalBytes} byte limit`);this.#r+=1,this.#e+=r}}class Qe{#t;#r;#e;constructor(e){this.#t=e.strict?Ka(e.workspace):pn(e.workspace),this.#r=e.strict??!1,this.#e=new Ng(e)}#o(e,t){if(!this.#r)return t.expandHome&&e.startsWith("~")?pn(process.env.HOME??"",e.slice(1)):pn(this.#t,e);let r=pn(this.#t,a$(e));return Ha(this.#t,r),c$(this.#t,r),r}isFile(e,t={}){let r=this.#o(e,t);return Bg(r)&&o$(r).isFile()}readText(e,t={}){let r=this.#o(e,t);if(this.#r)Ha(this.#t,Ka(r));let o=r$(r,"utf8");return this.#e.add(e,o),o}}var Lg=()=>{};import{createHash as Zg}from"crypto";import{basename as qg}from"path";function Qg(e){if(!e.diskTag&&e.replicaCount===void 0&&!e.dataLocality)return;return{diskTag:e.diskTag?[...e.diskTag].sort():void 0,replicaCount:e.replicaCount,dataLocality:e.dataLocality}}function Wg(e){return`kuber-longhorn-${Zg("sha256").update(JSON.stringify(e)).digest("hex").slice(0,12)}`}function ct(e){if(typeof e==="number")return e;if(!e||e.includes("-"))return;let t=Number(e);return Number.isInteger(t)?t:void 0}function Vg(e){if(typeof e!=="string"&&typeof e!=="number")return;let t=String(e).trim(),r=u$.exec(t);if(!r)return;let o=Number(r[1]),n=Number(r[2]);if(!Number.isInteger(o)||!Number.isInteger(n))return;if(o<1||n<1)throw Error(`Invalid replica range ${t}. Range bounds must be positive integers.`);if(o>n)throw Error(`Invalid replica range ${t}. Minimum (${o}) cannot exceed maximum (${n}).`);return{kind:"range",min:o,max:n}}function fn(e,t){if(t===void 0||t.trim()==="")return;let r=Number(t);if(!Number.isInteger(r)||r<0)throw Error(`Invalid ${e} value ${JSON.stringify(t)}. Expected a non-negative integer (zero allowed for a fixed replica count), a numeric string, or a "min-max" range.`)}function Ug(e){if(e.scale!==void 0){let t=ct(e.scale);if(t!==void 0)return fn("scale",String(e.scale)),t;fn("scale",String(e.scale))}if(e.deploy?.replicas!==void 0){let t=ct(e.deploy.replicas);if(t!==void 0)return fn("deploy.replicas",String(e.deploy.replicas)),t;fn("deploy.replicas",String(e.deploy.replicas))}return 1}function Gg(e){let t=Vg(e.scale);if(t)return Mg(t);if(e.scale!==void 0)return{kind:"fixed",value:Ug(e)};let r=Vg(e.deploy?.replicas);if(r)return Mg(r);return{kind:"fixed",value:Ug(e)}}function Mg(e){if(e.min===e.max)return{kind:"fixed",value:e.min};return e}function l$(e){if(e.kind==="range")return e.max>1;return e.value>1}function p$(e,t,r){if(t.build){let o=r[e];if(!o)throw Error(`Missing resolved build image for service ${e}`);return o}return t.image}function Ja(e){return e?.toUpperCase()==="UDP"?"UDP":"TCP"}function mn(e){if(!e)return;return/[a-z]/i.test(e)?e:void 0}function hn(e){return typeof e==="string"?JSON.stringify(e):String(e)}function Fg(e,t){let r=String(e).trim(),o=d$.exec(r);if(!o)throw Error(`Invalid ${t} value ${hn(e)}. Expected a non-negative finite decimal number of CPU cores.`);let n=BigInt(o[1]??"0"),i=o[2]??"",s=n*1000n+(i?BigInt(i.padEnd(3,"0").slice(0,3)):0n);if(i.slice(3).replaceAll("0","")!=="")throw Error(`Invalid ${t} value ${hn(e)}. CPU cores must be representable in whole millicores.`);return s%1000n===0n?String(s/1000n):`${s}m`}function jg(e,t){let r=e.trim(),o=f$.exec(r);if(!o)throw Error(`Invalid ${t} value ${hn(e)}. Expected a non-negative memory quantity.`);let n=o[1]??"",i=(()=>{switch(n.toLowerCase()){case"b":return"";case"k":case"kb":return"k";case"m":case"mb":return"M";case"g":case"gb":return"G";case"t":case"tb":return"T";case"p":case"pb":return"P";case"e":case"eb":return"E";default:return n}})();if(!["","n","u","m","k","M","G","T","P","E","Ki","Mi","Gi","Ti","Pi","Ei"].includes(i))throw Error(`Invalid ${t} value ${hn(e)}. Expected a valid Kubernetes or Compose memory quantity.`);return`${r.slice(0,r.length-n.length)}${i}`}function m$(e){let t=e.deploy?.resources;if(!t)return;let r={...t.limits?.cpus!==void 0?{cpu:Fg(t.limits.cpus,"deploy.resources.limits.cpus")}:{},...t.limits?.memory!==void 0?{memory:jg(t.limits.memory,"deploy.resources.limits.memory")}:{}},o={...t.reservations?.cpus!==void 0?{cpu:Fg(t.reservations.cpus,"deploy.resources.reservations.cpus")}:{},...t.reservations?.memory!==void 0?{memory:jg(t.reservations.memory,"deploy.resources.reservations.memory")}:{}};if(Object.keys(r).length===0&&Object.keys(o).length===0)return;return{...Object.keys(r).length>0?{limits:r}:{},...Object.keys(o).length>0?{requests:o}:{}}}function h$(e){if(typeof e==="boolean")return e;if(!e)return;switch(e.toLowerCase()){case"1":case"true":case"yes":case"on":case"ro":return!0;case"0":case"false":case"no":case"off":case"rw":return!1}}function gn(e){return e.toLowerCase().replace(/[^a-z0-9-]+/g,"-").replace(/^-+|-+$/g,"").slice(0,63)}function Ya(e){if(e===void 0||e===null)return;let t=String(e).trim();if(!t)return;return t}function Kg(e){if(e===void 0||e===null)return;let t=(Array.isArray(e)?e:[e]).flatMap((r)=>String(r).split(",")).map((r)=>r.trim()).filter(Boolean);return t.length>0?[...new Set(t)]:void 0}function Hg(e){if(e===void 0||e===null||e==="")return;let t=Number(e);return Number.isInteger(t)&&t>=1&&t<=20?t:void 0}function g$(e){let[t,r]=e.split(/\s+on\s+/i,2).map((n)=>n?.trim());if(!r)return{requestedStorage:Ya(t)};let o=/^(?:(?<replicas>\d+)\s+)?(?<tags>.+)$/.exec(r);return{requestedStorage:Ya(t),diskTag:Kg(o?.groups?.tags),replicaCount:Hg(o?.groups?.replicas),dataLocality:"none"}}function y$(e){let t=/^(?<name>[^()]+)\((?<size>[^()]+)\)$/.exec(e.trim());if(!t?.groups)return;let r=t.groups.name?.trim(),{requestedStorage:o,diskTag:n,replicaCount:i,dataLocality:s}=g$(t.groups.size??"");if(!r)return;return{source:r,requestedStorage:o,diskTag:n,replicaCount:i,dataLocality:s}}function Jg(e){if(!e||Xa(e))return{source:e};let t=y$(e);if(!t)return{source:e};if(!t.source)throw Error(`Invalid volume source ${e}. Expected name(size).`);return t}function Yg(e){return Ya(e?.["x-size"])}function Xg(e){return Kg(e?.["x-diskTag"])}function ey(e){return Hg(e?.["x-replicaCount"])}function ty(e){return e?.["x-dataLocality"]==="none"?"none":void 0}function ry(e){return gn(`bind-${Bun.hash(e).toString(36)}`)}function Xa(e){return e.startsWith(".")||e.startsWith("/")||e.startsWith("~")||e.includes("/")}function oy(e,t){return t.isFile(e,{expandHome:!0})}function b$(e,t,r){if(Tg(e)||Ig(e))return;let o=e.split(":");if(o.length===1)return{name:`volume-${t}`,kind:"volume",target:e};let n=o.at(-1),i=n==="ro"||n==="rw",s=o.at(i?-2:-1),a=o.slice(0,i?-2:-1).join(":");if(!s)return;let{source:c,requestedStorage:u,diskTag:l,replicaCount:f,dataLocality:d}=Jg(a||void 0);return{name:c&&Xa(c)?ry(c):`volume-${t}`,kind:c&&Xa(c)?oy(c,r)?"config-file":"bind":"volume",source:c||void 0,target:s,configKey:c?qg(c):void 0,readOnly:i?n==="ro":void 0,requestedStorage:u,diskTag:l,replicaCount:f,dataLocality:d}}function _$(e,t,r){if(typeof e==="string")return b$(e,t,r);if(!e.target)return;if(e.type!=="bind"&&e.type!=="volume"&&e.type!=="tmpfs")return;let{source:o,requestedStorage:n,diskTag:i,replicaCount:s,dataLocality:a}=Jg(e.source);return{name:o?e.type==="bind"?ry(o):`${e.type}-${gn(o)||t}`:`${e.type}-${t}`,kind:e.type==="bind"&&o&&oy(o,r)?"config-file":e.type,source:o,target:e.target,readOnly:h$(e.read_only),configKey:o?qg(o):void 0,subPath:e.volume?.subpath,sizeLimit:e.type==="tmpfs"&&e.tmpfs?.size!==void 0?String(e.tmpfs.size):void 0,requestedStorage:n??Yg(e.volume),diskTag:i??Xg(e.volume),replicaCount:s??ey(e.volume),dataLocality:a??ty(e.volume)}}function w$(e,t){if(!t||!e)return;let r=e[t];return Yg(r)}function v$(e,t){if(!t||!e)return;let r=e[t];return Xg(r)}function x$(e,t){if(!t||!e)return;let r=e[t];return ey(r)}function E$(e,t){if(!t||!e)return;let r=e[t];return ty(r)}function yn(e,t,r={}){let o=e.volumes?.flatMap((i,s)=>{let a=_$(i,s,t);if(!a)return[];return[{...a,requestedStorage:a.requestedStorage??w$(r,a.source)??(a.kind==="volume"&&a.source?dn.requestedStorage:void 0),diskTag:a.diskTag??v$(r,a.source)??(a.kind==="volume"&&a.source?dn.diskTag:void 0),replicaCount:a.replicaCount??x$(r,a.source)??(a.kind==="volume"&&a.source?dn.replicaCount:void 0),dataLocality:a.dataLocality??E$(r,a.source)??(a.kind==="volume"&&a.source?dn.dataLocality:void 0)}]})??[],n=(Array.isArray(e.tmpfs)?e.tmpfs:[e.tmpfs]).filter((i)=>Boolean(i)).map((i,s)=>({name:`tmpfs-${o.length+s}`,kind:"tmpfs",target:i}));return[...o,...n]}function S$(e){if(e.length===0)return;return e.map((t)=>({name:t.name,mountPath:t.target,readOnly:t.readOnly,subPath:t.kind==="config-file"?t.configKey:t.subPath}))}function $$(e,t){if(t.length===0)return;return t.map((r)=>{if(r.kind==="config-file")return{name:r.name,configMap:{name:r.name}};if(r.kind==="bind"){if(!r.source)return{name:r.name,emptyDir:{}};return{name:r.name,persistentVolumeClaim:{claimName:r.name}}}if(r.kind==="tmpfs")return{name:r.name,emptyDir:{medium:"Memory",sizeLimit:r.sizeLimit}};if(!r.source)return{name:r.name,emptyDir:{}};return{name:r.name,persistentVolumeClaim:{claimName:gn(`${e}-${r.source}`)}}})}function A$(e){return[...new Set(e.split(",").map((t)=>t.trim()).filter(Boolean).map((t)=>t.startsWith("/")?t:`/${t}`))]}function k$(e){let t=/^(?<portSpec>.+):protected(?:\((?<paths>[^)]*)\))?$/.exec(e);if(!t?.groups)return{portSpec:e};let r=t.groups.portSpec?.trim();if(!r)throw Error(`Invalid protected port syntax ${e}.`);let o=t.groups.paths?.trim();if(o===void 0)return{portSpec:r,routingKind:"ingressroute"};let n=A$(o);if(n.length===0)throw Error(`Invalid protected port syntax ${e}. Expected one or more paths.`);return{portSpec:r,routingKind:"ingressroute",paths:n}}function bn(e){let t=e.ports?.flatMap((o,n)=>{if(typeof o==="number")return[{name:`port-${n}`,containerPort:o,servicePort:o,protocol:"TCP"}];if(typeof o==="string"){let a=/\/(tcp|udp)$/i.exec(o),c=a?o.slice(0,-a[0].length):o,u=a?.[1];if(!c)return[];let{portSpec:l,routingKind:f,paths:d}=k$(c),p=l.split(":"),m=ct(p.at(-1));if(!m)return[];let h=ct(p.at(-2)),y=h!==void 0?mn(p.at(-3)):mn(p.at(-2));return[{name:`port-${n}`,containerPort:m,servicePort:h??m,hostPort:h,host:y,protocol:Ja(u),routingKind:y?f??"ingress":void 0,paths:d}]}let i=ct(o.target);if(!i)return[];let s=ct(o.published);return[{name:o.name??`port-${n}`,containerPort:i,servicePort:s??i,hostPort:s,host:mn(o.host_ip),protocol:Ja(o.protocol),routingKind:mn(o.host_ip)?"ingress":void 0}]})??[],r=e.expose?.flatMap((o,n)=>{let[i,s]=String(o).split("/"),a=ct(i);if(!a)return[];return[{name:`expose-${n}`,containerPort:a,servicePort:a,protocol:Ja(s)}]})??[];return[...t,...r]}function P$(e){if(e.length===0)return;let t=new Map;for(let r of e)t.set(`${r.containerPort}:${r.protocol}`,{name:r.name,containerPort:r.containerPort,hostPort:r.hostPort,protocol:r.protocol});return[...t.values()]}function C$(e){if(e.length===0)return;let t=new Map;for(let r of e)t.set(`${r.servicePort}:${r.protocol}`,{name:r.name,port:r.servicePort,targetPort:r.containerPort,protocol:r.protocol});return[...t.values()]}function R$(e,t){let r=new Set;return t.flatMap((o)=>{if(!o.host||o.routingKind==="ingressroute"||r.has(o.host))return[];return r.add(o.host),[{host:o.host,http:{paths:[{path:"/",pathType:"Prefix",backend:{service:{name:e,port:{number:o.servicePort}}}}]}}]})}function T$(e,t,r){let o=r.flatMap((n)=>{if(!n.host||n.routingKind!=="ingressroute")return[];return(n.paths&&n.paths.length>0?n.paths.map((s)=>`Host(\`${n.host}\`) && PathPrefix(\`${s}\`)`):[`Host(\`${n.host}\`)`]).map((s)=>({kind:"Rule",match:s,middlewares:[{name:"cf-auth",namespace:"routing"}],services:[{name:t,port:n.servicePort}]}))});if(o.length===0)return;return{apiVersion:"traefik.io/v1alpha1",kind:"IngressRoute",metadata:{name:t,namespace:e,labels:X},spec:{routes:o}}}function O$(e){if(!e)return[];return(Array.isArray(e)?e:[e]).map((r)=>typeof r==="string"?{path:r,required:!0}:{path:r.path,required:r.required!==!1&&r.required!=="false"})}function I$(e){let t={};for(let r of e.split(/\r?\n/)){let o=r.trim();if(!o||o.startsWith("#"))continue;let n=o.indexOf("=");if(n===-1)continue;let i=o.slice(0,n).trim(),s=o.slice(n+1);if(!i)continue;t[i]=s}return t}async function B$(e,t){let r={};for(let o of O$(e))try{let n=t.readText(o.path);Object.assign(r,I$(n))}catch(n){if(!o.required&&n&&typeof n==="object"&&"code"in n&&n.code==="ENOENT")continue;throw n}return r}function z$(e,t,r,o,n=process.cwd(),i={},s={},a={},c=new Qe({workspace:n}),u={}){let l=yn(o,c,s),f=bn(o),d=Boolean(o.env_file)||Object.keys(i).length>0,p=u.replicaSpec??Gg(o),m=p.kind==="range"?p.min:p.value,h=[ln({name:t,imagePullPolicy:"Always",env:um(o.environment),image:p$(t,o,a),command:o.command instanceof Array?o.command:o.command?o.command.split(" "):void 0,envFrom:d?[{secretRef:{name:`${t}-env`}}]:void 0,ports:P$(f),resources:m$(o),volumeMounts:S$(l)},o["x-container"]??{})],y={restartPolicy:"Always",...fg(r),volumes:$$(e,l),containers:h};if(l$(p))y.topologySpreadConstraints=[{maxSkew:1,topologyKey:"kubernetes.io/hostname",whenUnsatisfiable:"ScheduleAnyway",labelSelector:{matchLabels:{app:t}}}];return ln({apiVersion:"apps/v1",kind:"Deployment",metadata:{name:t,namespace:e,labels:X},spec:{replicas:m,strategy:{rollingUpdate:{maxSurge:"25%",maxUnavailable:"25%"}},selector:{matchLabels:{app:t}},template:{metadata:{labels:{app:t}},spec:y}}},o["x-deployment"]??{})}function D$(e,t,r){let o=C$(bn(r));if(!o)return;return{apiVersion:"v1",kind:"Service",metadata:{name:t,namespace:e,labels:X},spec:{type:"ClusterIP",selector:{app:t},ports:o}}}function N$(e,t,r){let o=R$(t,bn(r));if(o.length===0)return;return{apiVersion:"networking.k8s.io/v1",kind:"Ingress",metadata:{name:t,namespace:e,labels:X},spec:{rules:o}}}function L$(e,t,r=process.cwd(),o={},n=new Qe({workspace:r})){let i=new Map;for(let s of yn(t,n,o)){let a=s.kind==="bind"?s.source?s.name:void 0:s.kind==="volume"&&s.source?gn(`${e}-${s.source}`):void 0;if(!a||i.has(a))continue;let c=Qg(s);i.set(a,{apiVersion:"v1",kind:"PersistentVolumeClaim",metadata:{name:a,namespace:e,labels:X},spec:{accessModes:[c?.replicaCount===1?"ReadWriteOnce":"ReadWriteMany"],storageClassName:c?Wg(c):void 0,resources:{requests:{storage:s.requestedStorage??"1Gi"}}}})}return[...i.values()]}function V$(e,t=process.cwd(),r={},o=new Qe({workspace:t})){let n=new Map;for(let i of yn(e,o,r)){let s=Qg(i);if(!s)continue;let a=Wg(s);n.set(a,{apiVersion:"storage.k8s.io/v1",kind:"StorageClass",metadata:{name:a,labels:X},provisioner:"driver.longhorn.io",allowVolumeExpansion:!0,reclaimPolicy:"Delete",volumeBindingMode:"Immediate",parameters:{...s.diskTag?{diskSelector:s.diskTag.join(",")}:{},...s.replicaCount!==void 0?{numberOfReplicas:String(s.replicaCount)}:{},...s.dataLocality?{dataLocality:"disabled"}:{}}})}return[...n.values()]}function U$(e,t,r=process.cwd(),o={},n=new Qe({workspace:r})){let i=new Map;for(let s of yn(t,n,o)){if(s.kind!=="config-file"||!s.source||!s.configKey)continue;i.set(s.name,{apiVersion:"v1",kind:"ConfigMap",metadata:{name:s.name,namespace:e,labels:X},data:{[s.configKey]:n.readText(s.source,{expandHome:!0})}})}return[...i.values()]}async function M$(e,t,r,o=process.cwd(),n={},i=new Qe({workspace:o})){let s={...await B$(r.env_file,i),...n};if(Object.keys(s).length===0)return[];return[{apiVersion:"v1",kind:"Secret",metadata:{name:`${t}-env`,namespace:e,labels:X},type:"Opaque",stringData:s}]}function F$(e){let t=Object.entries(e.stringData??{}).sort(([r],[o])=>r.localeCompare(o));return Zg("sha256").update(JSON.stringify(t)).digest("hex")}function j$(e){return{apiVersion:"v1",kind:"Namespace",metadata:{name:e,labels:X}}}function Z$(e,t){let r=e.spec?.template.spec?.containers[0];if(!r)return;if(t["x-container"]?.resources?.requests?.cpu!==void 0)return;if(r.resources??={},r.resources.requests??={},r.resources.requests.cpu===void 0)r.resources.requests.cpu="100m"}function q$(e,t,r){return{apiVersion:"autoscaling/v2",kind:"HorizontalPodAutoscaler",metadata:{name:t,namespace:e,labels:X},spec:{scaleTargetRef:{apiVersion:"apps/v1",kind:"Deployment",name:t},minReplicas:r.min,maxReplicas:r.max,metrics:[{type:"Resource",resource:{name:"cpu",target:{type:"Utilization",averageUtilization:80}}}]}}}function ke(e){return`${e.kind}:${e.metadata?.namespace??""}:${e.metadata?.name??""}`}async function _n(e,t,r=process.cwd(),o={},n={},i=new Qe({workspace:r})){let s=new Map,a=j$(e);s.set(ke(a),a);for(let[c,u]of Object.entries(t.services??{})){for(let b of V$(u,r,t.volumes,i))s.set(ke(b),b);for(let b of L$(e,u,r,t.volumes,i))s.set(ke(b),b);for(let b of U$(e,u,r,t.volumes,i))s.set(ke(b),b);let l=await M$(e,c,u,r,o[c]??{},i);for(let b of l)s.set(ke(b),b);let f=D$(e,c,u);if(f)s.set(ke(f),f);let d=Gg(u),p=z$(e,c,t,u,r,o[c]??{},t.volumes,n,i,{replicaSpec:d}),m=l[0];if(m)p.spec.template.metadata.annotations={...p.spec?.template.metadata?.annotations,"kuber.astrxl.dev/env-checksum":F$(m)};if(s.set(ke(p),p),d.kind==="range"){Z$(p,u);let b=q$(e,c,d);s.set(ke(b),b)}let h=N$(e,c,u);if(h)s.set(ke(h),h);let y=T$(e,c,bn(u));if(y)s.set(ke(y),y)}return[...s.values()]}var dn,u$,d$,f$;var ec=_(()=>{Fe();za();_r();ot();wr();Lg();dn={requestedStorage:"1Gi",diskTag:["fast"],replicaCount:2,dataLocality:"none"};u$=/^\s*(\d+)\s*-\s*(\d+)\s*$/;d$=/^(\d+)(?:\.(\d+))?$/,f$=/^(?:\d+(?:\.\d+)?|\.\d+)([a-zA-Z]*)$/});import{randomUUID as tc}from"crypto";import{isDeepStrictEqual as ny}from"util";function py(e){return`/workspaces/${encodeURIComponent(e)}/adopt`}function iy(e,t){let r={...e};for(let[o,n]of Object.entries(t))r[o]={...r[o],...n};return r}function H$(e){let{resource:t,phase:r,state:o}=e.data;return`${r==="apply"?"Applied":r==="wait"?"Waited for":"Deleted"} ${t.kind}/${t.name}: ${o}`}function J$(e){if(!e||typeof e!=="object")return!1;let{sequence:t,data:r}=e;if(!Number.isSafeInteger(t)||!r||typeof r!=="object")return!1;let{resource:o,phase:n,state:i}=r;if(!o||typeof o!=="object")return!1;let s=o;return typeof s.apiVersion==="string"&&typeof s.kind==="string"&&typeof s.name==="string"&&(s.namespace===void 0||typeof s.namespace==="string")&&(n==="apply"||n==="wait"||n==="delete")&&(i==="started"||i==="succeeded"||i==="failed"||i==="aborted")}function Y$(e,t){return{source:{uri:`cas://${t.digest}`,digest:t.digest},config:{compose:e}}}function X$(e,t){return ny(e.spec?.source,t.source)&&ny(e.spec?.config,t.config)}function sy(e){if(e instanceof xe)return e.status===409;if(e instanceof DOMException&&e.name==="AbortError")return!1;if(e instanceof Error&&e.name==="AbortError")return!1;return e instanceof TypeError||e instanceof Error&&e.name==="TimeoutError"}async function eA(e,t,r,o=C){let n=`/workspaces/${encodeURIComponent(e)}`,i=Y$(t,r),s=(u)=>o(n,{method:"PUT",headers:{"if-match":`"${u.metadata.resourceVersion}"`},json:i}),a=async(u)=>{try{let l=await o(n);if(X$(l,i))return l;return await s(l)}catch{throw u}},c;try{c=await o(n)}catch(u){if(!(u instanceof xe)||u.status!==404)throw u;try{return await o("/workspaces",{method:"POST",json:{id:e,...i}})}catch(l){if(!sy(l))throw l;return a(l)}}try{return await s(c)}catch(u){if(!sy(u))throw u;return a(u)}}function ay(e){return Object.fromEntries(Object.entries(e).filter(([t,r])=>t!=="operation"&&t!=="operationId"&&r!==null&&typeof r==="object"&&!Array.isArray(r)))}function wn(e,t){let r=t instanceof Error?t.message:String(t);if(!/namespace .* (?:external|different-workspace)/i.test(r))return t instanceof Error?t:Error(r);return Error(`${r}. Safe adoption requires ${ly} ${py(e)} with namespace UID and ownership preconditions.`,{cause:t})}async function Pt(e,t,r,o){try{return await t(r,o)}catch(n){throw wn(e,n)}}function tA(e){if(!e||typeof e!=="object")return;let t=e.operationId;return typeof t==="string"&&t?t:void 0}function rA(e){if(!e||typeof e!=="object")return;let t=e.operation?.status;return t&&typeof t==="object"?t:void 0}function cy(e,t){let r=t.error,o=t.state==="cancelled",n=typeof r?.message==="string"?r.message:o?"The operation was cancelled":"The operation failed",i=typeof r?.code==="string"?r.code:o?"OPERATION_CANCELLED":"OPERATION_FAILED";return new xe(n,o?409:500,{title:o?"Operation cancelled":"Operation failed",status:o?409:500,code:i,operationId:e})}function oA(e){if(e instanceof xe)return K$.has(e.code);if(e instanceof DOMException&&e.name==="AbortError")return!1;if(e instanceof Error&&e.name==="AbortError")return!1;return e instanceof TypeError||e instanceof Error&&e.name==="TimeoutError"}function nA(e){return e.state==="failed"&&e.error?.code==="OPERATION_INTERRUPTED"}function iA(e,t){return e.cursorGap===!0||Number.isSafeInteger(e.retainedFirstSequence)&&e.retainedFirstSequence>t+1}function sA(e,t){return t+Math.max(e,0)+G$}function dy(e){return e.reason??new DOMException("The operation was aborted","AbortError")}function kt(e){if(e?.aborted)throw dy(e)}function aA(e,t){return kt(t),new Promise((r,o)=>{let n,i=()=>{if(n!==void 0)clearTimeout(n);t?.removeEventListener("abort",a)},s=()=>{i(),r()},a=()=>{i(),o(dy(t))};if(n=setTimeout(s,e),t?.addEventListener("abort",a,{once:!0}),t?.aborted)a()})}async function rc(e,t,r,o,n,i){let s=i.now??Date.now,a=sA(n,s()),c=new Headers(o.headers);c.set("idempotency-key",tc()),c.set("prefer","respond-async");let u={...o,headers:c,signal:i.signal??o.signal},l,f=Q$,d=!1,p=0;for(;;){if(kt(i.signal),d&&s()>=a)throw Error("Timed out while reconnecting to resume the operation");try{let y;if(l)y=(await Pt(e,t,`/operations/${encodeURIComponent(l)}`,{signal:i.signal})).status;else{d=!1;let b=await Pt(e,t,r,u);l=tA(b),y=rA(b)}if(l)try{let b=await Pt(e,t,`/operations/${encodeURIComponent(l)}/events?after=${p}`,{signal:i.signal});if(iA(b,p))throw new ic;for(let P of b.items??[]){if(!Number.isSafeInteger(P.sequence)||P.sequence<=p)continue;if(p=P.sequence,!J$(P))continue;i.onEvent?.(P)}}catch(b){if(b instanceof ic)throw b;kt(i.signal)}if(!l||!y||y.state==="succeeded")return;if(nA(y)){if(s()>=a)throw cy(l,y);l=void 0,p=0,d=!0,c.set("idempotency-key",tc()),u={...o,headers:c,signal:i.signal??o.signal}}else if(y.state==="failed"||y.state==="cancelled")throw cy(l,y)}catch(y){if(kt(i.signal),y instanceof xe&&y.code==="OPERATION_INTERRUPTED"){if(s()>=a)throw wn(e,y);l=void 0,p=0,d=!0,c.set("idempotency-key",tc()),u={...o,headers:c,signal:i.signal??o.signal}}else{if(!oA(y))throw wn(e,y);if(s()>=a)throw wn(e,y)}}let m=a-s();if(m<=0)throw Error("Timed out while reconnecting to resume the operation");let h=Math.min(f,m);if(i.sleep)kt(i.signal),await i.sleep(h),kt(i.signal);else await aA(h,i.signal);f=Math.min(f*2,W$)}}async function cA(e,t,r=C){let o=`/workspaces/${encodeURIComponent(e)}`;return Pt(e,r,`${o}/resources/plan`,{method:"POST",json:{resources:t}})}function oc(e){let t=e.name??e.metadata?.name;if(!e.apiVersion||!e.kind||!t)return;return{apiVersion:e.apiVersion,kind:e.kind,name:t,namespace:e.namespace??e.metadata?.namespace}}function uy(e){return`${e.apiVersion}\x00${e.kind}\x00${e.namespace??""}\x00${e.name}`}function uA(e,t){return`${e==="apply"?"Apply":e==="wait"?"Wait for":"Delete"} ${t.kind}/${t.name}`}function nc(e,t,r,o,n={}){if(r.length===0)return o(()=>{},e.signal);let i=new Map,s=new Set,a=0;return e.newListr(r.map((c)=>({title:uA(t,c),task:async(u,l)=>{if(i.set(uy(c),l),n.onTaskStarted?.(c,l),a+=1,a!==r.length)return new Promise((f)=>{let d=()=>{e.signal.removeEventListener("abort",d),s.delete(d),f()};if(s.add(d),e.signal.aborted)d();else e.signal.addEventListener("abort",d,{once:!0})});try{await o((f)=>{let d=f.data.resource,p=i.get(uy(d));if(!p)return;p.output=f.data.state,e.output=H$(f)},e.signal)}finally{for(let f of[...s])f()}}})),{concurrent:!0})}async function vr(e,t=C,r={}){let{project:o,compose:n,cwd:i,config:s,hookContext:a}=D(),c=r.trust??await km(await bt(o,i)),u=t;t=async(d,p={},m)=>{let h=new Headers(p.headers);for(let[y,b]of Object.entries(Am(c)))h.set(y,b);return u(d,{...p,headers:h},m)};let l=`/workspaces/${encodeURIComponent(o)}`;return await new he([{title:"Read compose",task:async(d,p)=>{if(d.compose=await n(),e)await s.preBuild?.(d.compose,await a());p.output=`${Object.keys(d.compose.services??{}).length} services`}},{title:"Snapshot workspace",task:async(d,p)=>{let m;try{m=await ja(i)}catch(h){m=i}d.workspaceRoot=m,d.snapshot=await an(m),p.output=`${d.snapshot.manifest.files.length} files`}},{title:"Build images",rendererOptions:{bottomBar:1/0,persistentOutput:!0},enabled:async()=>e&&Object.values((await n()).services??{}).some((d)=>d.build),task:async(d,p)=>{let m=Object.entries(d.compose.services??{}).filter(([,k])=>k.build).map(([k])=>k),h=new Map,y=new Map,b=new Map(m.map((k)=>[k,new Promise((T)=>y.set(k,T))])),P,E,A,x=()=>(A??=Ag(o,d.compose,i,{progress:(k)=>{p.output=k},service:(k)=>{let T;return{progress:(B)=>{let W=h.get(k);if(W&&W.output!==B)W.output=B},get stream(){let B=h.get(k);if(B)T??=B.stdout();return T}}},settled:(k,T)=>{y.get(k)?.(T),y.delete(k)}},{...s,request:t,snapshot:d.snapshot,workspaceRoot:d.workspaceRoot,signal:p.signal}).then((k)=>{P=k},(k)=>{let T=k instanceof Error?k:Error(String(k));E=T,p.output=T.stack??T.message,p.report(T,ag.HAS_FAILED);for(let B of y.values())B(T);y.clear()}),A);if(await p.newListr(m.map((k)=>({title:`Build ${k}`,rendererOptions:{outputBar:10,persistentOutput:!0},task:async(T,B)=>{if(h.set(k,B),B.output="Build queued",h.size===m.length)x();let W=await b.get(k);if(W)throw W;B.output="done"}})),{concurrent:!0,exitOnError:!1}).run(),await A,!P)throw E??Error("Build images failed");d.buildImages=P.images,await s.postBuild?.(P,await a()),p.title=`Built ${P.built.length} image${P.built.length===1?"":"s"}`}},{title:"Resolve images",enabled:async()=>!e&&Object.values((await n()).services??{}).some((d)=>d.build),task:async(d,p)=>{d.buildImages=await cn(o,d.compose,{...s,request:t}),p.output=`${Object.keys(d.buildImages).length} images`}},{title:"Update workspace",task:async(d,p)=>{let m=await eA(o,d.compose,d.snapshot,t),h=await t(py(o),{method:ly,json:{workspaceUid:m.metadata.uid}});p.output=h.resourcesAdopted?`Adopted ${h.resourcesAdopted} existing resources`:"Workspace ready"}},{title:"Reconcile backing services",task:async(d,p)=>{let m={},h={};await p.newListr([{title:"Reconcile databases",enabled:()=>st(d.compose).length>0,task:async(y,b)=>{let P=await Pt(o,t,`${l}/databases`,{method:"POST",json:{compose:d.compose}});m=ay(P),b.output=`${Object.keys(m).length} services`}},{title:"Reconcile S3 storage",enabled:()=>at(d.compose).length>0,task:async(y,b)=>{let P=await Pt(o,t,`${l}/storage`,{method:"POST",json:{compose:d.compose}});h=ay(P),b.output=`${Object.keys(h).length} services`}}],{concurrent:!0}).run(),d.serviceEnv=iy(iy(d.serviceEnv,m),h)}},{title:"Render manifests",task:async(d,p)=>{d.resources=await _n(o,d.compose,i,d.serviceEnv,d.buildImages),await s.postRender?.(d.resources,await a()),p.output=`${d.resources.length} resources`}},{title:"Reconcile resources",task:async(d,p)=>{d.plan=await cA(o,d.resources,t);let m=d.plan,h=m.desired.map(oc).filter((E)=>Boolean(E)),y=m.desired.filter((E)=>E.kind==="Deployment").map(oc).filter((E)=>Boolean(E)),b=m.stale.map(oc).filter((E)=>Boolean(E)),P=`${l}/resources`;return p.newListr([{title:"Apply resources",task:async(E,A)=>nc(A,"apply",h,(x,k)=>rc(o,t,`${P}/apply`,{method:"POST",json:{resources:m.desired}},s.rolloutTimeoutMs,{onEvent:x,signal:k}))},{title:"Run post-apply hook",skip:!s.postApply,task:async()=>s.postApply?.(m.desired,await a())},{title:"Wait for deployments",skip:y.length===0,task:async(E,A)=>nc(A,"wait",y,(x,k)=>rc(o,t,`${P}/wait`,{method:"POST",json:{deployments:y.map((T)=>T.name),timeoutMs:s.rolloutTimeoutMs}},s.rolloutTimeoutMs,{onEvent:x,signal:k}))},{title:"Delete stale resources",skip:b.length===0,task:async(E,A)=>nc(A,"delete",b,(x,k)=>rc(o,t,`${P}/delete`,{method:"POST",json:{resources:m.stale}},s.rolloutTimeoutMs,{onEvent:x,signal:k}))}])}}],{rendererOptions:{collapseErrors:!1}}).run()}var ly="POST",Q$=250,W$=5000,G$=60000,K$,ic,lA;var vn=_(()=>{q();St();G();Za();ec();oe();_r();wr();Fa();Do();K$=new Set(["HTTP_502","HTTP_503","HTTP_504"]);ic=class ic extends Error{constructor(){super("Operation progress history was truncated; refusing to report an incomplete resource stream")}};lA=S({meta:{name:"up",description:"Create and start deployments"},args:{build:{type:"boolean",default:!0,alias:"b",description:"Build images before starting deployments",negativeDescription:"Don't build an image, even if it's policy"}},async run({args:e}){await vr(e.build)}})});function pA(e){let t=e?.trim();if(!t)throw Error("KUBER_API_KEY or --api-key is required for kuber ci");return t}function dA(e){return(t,r={},o={})=>{let n=new Headers(r.headers);return n.set("authorization",`Bearer ${e}`),C(t,{...r,headers:n},{...o,authenticated:!1})}}async function fA(e,t,r,o=dA(r)){let{project:n,cwd:i}=D(),s=await bt(n,i);if(t)await o(`/workspaces/${encodeURIComponent(n)}/trust`,{method:"POST",json:{fingerprint:s.fingerprint}});await vr(e,o,{trust:t?s:void 0})}var mA;var fy=_(()=>{q();G();oe();Do();vn();mA=S({meta:{name:"ci",description:"Deploy using an API key without a session"},args:{apiKey:{type:"string",description:"API key (defaults to KUBER_API_KEY)"},trust:{type:"boolean",description:"Grant current directory trust before deploying"},build:{type:"boolean",default:!0,negativeDescription:"Resolve existing images without building"}},async run({args:e}){await fA(e.build,Boolean(e.trust),pA(e.apiKey??process.env.KUBER_API_KEY))}})});function hA(e,t,r=C){return r(`/workspaces/${encodeURIComponent(e)}/databases/credentials`,{method:"POST",json:{claim:t}})}var gA,yA,bA;var my=_(()=>{q();G();oe();_r();ot();gA=S({meta:{name:"ls",description:"List managed postgres claims"},async run(){let e=st(await D().compose());if(e.length===0){console.log("No managed postgres volumes declared");return}console.log(fe(e.map((t)=>({service:t.service,username:t.username,database:t.database,secret:t.secretName}))))}}),yA=S({meta:{name:"creds",description:"Print postgres credentials for a service"},async run({args:e}){let t=e._[0];if(!t)throw Error("Service name is required");let r=D(),o=st(await r.compose()).find((s)=>s.service===t);if(!o)throw Error(`Service ${t} does not declare a managed postgres volume.`);let n=await hA(r.project,o),i=Cg(o,n);console.log(fe([{service:o.service,username:n.username,database:o.database,host:Qa,port:Wa,secret:o.secretName}])),console.log(`DATABASE_URL=${i}`)}}),bA=S({meta:{name:"db",description:"Inspect managed postgres databases"},subCommands:{creds:yA,ls:gA}})});function _A(e,t=!1,r=C){return r(`/workspaces/${encodeURIComponent(e)}/down`,{method:"POST",json:{full:t}})}var wA;var hy=_(()=>{q();St();G();oe();wA=S({meta:{name:"down",description:"Delete managed resources except ingress and PVCs"},args:{full:{type:"boolean",alias:"f",description:"Also delete ingress, PVCs, and the namespace"}},async run({args:e}){let{project:t}=D();await new he([{title:"Delete resources",task:async(r,o)=>{let n=await _A(t,e.full);o.output=`${n.delete.length} resources queued`}}]).run()}})});async function gy(e,t,r=process.cwd(),o={}){let n=[...st(t).length?["Postgres"]:[],...at(t).length?["S3"]:[]];if(n.length>0)throw Error(`Cannot export without generated ${n.join(" and ")} credentials. Export is side-effect-free; run kuber up or remove managed provider claims.`);let i=await cn(e,t,o);return _n(e,t,r,{},i)}var yy=_(()=>{ec();_r();wr();Za()});import{resolve as vA}from"path";var{YAML:xA}=globalThis.Bun;function EA(e){return`${Pg(e).map((t)=>xA.stringify(t,null,2).trimEnd()).join(`
|
|
100
|
+
${p}`};return c}if(c=await vg(t,`/builds/${encodeURIComponent(e)}/reconcile`,{method:"POST",json:{}},o,n,s),c.state!=="succeeded"&&c.state!=="failed")s?.throwIfAborted(),await n(o)}}async function cn(e,t,r={}){let o=r.request??C,n=Object.entries(t.services??{}).filter(([,a])=>a.build).map(([a])=>a),i=Array(n.length),s=0;return await Promise.all(Array.from({length:Math.min(Sg,n.length)},async()=>{for(;;){let a=s++;if(a>=n.length)return;let c=n[a];r.signal?.throwIfAborted();try{i[a]=(await o("/images/resolve",{method:"POST",json:{project:e,service:c},signal:r.signal})).reference}catch(u){throw Error(`Cannot resolve a published image for service ${c}. Run kuber up to build it.`,{cause:u})}}})),Object.fromEntries(n.map((a,c)=>[a,i[c]]))}async function Ag(e,t,r=process.cwd(),o,n={}){if(!Object.values(t.services??{}).some((x)=>x.build))return{built:[],changed:[],images:{}};let i=n.buildConcurrency??Sg;if(!Number.isSafeInteger(i)||i<1)throw RangeError("buildConcurrency must be a positive integer");let s=n.request??C,a=n.workspaceRoot;if(!a&&!n.snapshot)try{a=await ja(r)}catch(x){a=r}a??=r;let c=n.snapshot??await an(a),u=Object.entries(t.services??{}).flatMap(([x,A])=>{let T=FS(e,x,A,r,a,n.registry??To);return T?[T]:[]});await qS(c,s,o,n.scheduler,e);let l=Array(u.length),f=new Map(u.map((x)=>[x.name,o?.service?.(x.name)??o])),d=Ba(t),p=new Map;u.forEach((x,A)=>{let T=JSON.stringify({workspace:c.digest,architecture:d,context:x.context,dockerfile:x.dockerfile,target:x.target,buildArgs:x.buildArgs}),B=p.get(T)??[];B.push(A),p.set(T,B)});let m=[...p.values()],h=0,y,b=!1,P=async()=>{while(!b&&h<m.length){let x=m[h++],A=x.map((T)=>u[T]);try{n.signal?.throwIfAborted();for(let B of A)await f.get(B.name)?.progress?.(`${o?.service?"":`${B.name}: `}Build queued`);let T=await E(A);x.forEach((B)=>{let W=u[B],Te=B===x[0]?T.reference:T.references?.[W.name];if(!Te)throw Error(`Build result missing image for service ${W.name}`);l[B]=Te});for(let B of A)o?.settled?.(B.name)}catch(T){if(!b)y=T;b=!0;for(let B of A)o?.settled?.(B.name,T)}}},E=async(x)=>{let A=x[0],T=CS(),B={version:gr,id:T,project:e,service:A.name,...x.length>1&&{destinations:x.slice(1).map(({name:Ne,image:sb})=>({service:Ne,image:sb}))},spec:{architecture:d,image:A.image,context:A.context,dockerfile:A.dockerfile,target:A.target,buildArgs:A.buildArgs,workspace:c.digest}},W=await s("/builds",{method:"POST",json:B,signal:n.signal},{timeoutMs:300000}),Te=await GS(T,s,x.map(({name:Ne})=>({name:Ne,reporter:f.get(Ne)})),n.pollIntervalMs??zS,n.sleep??((Ne)=>Bun.sleep(Ne)),W,n.signal,!o?.service);if(Te.state!=="succeeded")throw Error(`Build failed for service ${A.name}: ${Te.error??"unknown error"}`);return await s(`/builds/${encodeURIComponent(T)}/result`,{signal:n.signal})};if(await Promise.all(Array.from({length:Math.min(i,m.length)},P)),b)throw y;let k=Object.fromEntries(u.map((x,A)=>[x.name,l[A]]));return{built:u.map((x)=>x.name),changed:u.map((x)=>x.name),images:k}}var IS,BS=8388608,zS=1000,DS=300000,_g=3,Sg=3,NS=20,LS=40;var Za=_(()=>{za();G();Oo();Fa();IS=OS(RS)});function kg(e){return KS[e.kind]??999}function Pg(e){return[...e].sort((t,r)=>kg(t)-kg(r))}var KS,oO,nO;var un=_(()=>{Fe();KS={Namespace:0,GarageBucket:1,GarageKey:2,ServiceAccount:3,ClusterRole:4,Role:5,ClusterRoleBinding:6,RoleBinding:7,StorageClass:8,PersistentVolumeClaim:9,Secret:10,ConfigMap:11,Service:12,Deployment:13,HorizontalPodAutoscaler:14,Ingress:15,IngressRoute:16},oO=`app.kubernetes.io/managed-by=${X["app.kubernetes.io/managed-by"]}`,nO=X["app.kubernetes.io/managed-by"]});function XS(e){return`${YS}-${e}`}function qa(e){return encodeURIComponent(e)}function Cg(e,t){return`postgresql://${qa(t.username)}:${qa(t.password)}@${Qa}:${Wa}/${qa(e.database)}`}function Rg(e){if(!e.startsWith("postgresql:"))return;let t=e.split(":");if(t.length!==2)throw Error(`Invalid postgres volume ${e}. Use postgresql:<name> or postgresql:<user>/<database>.`);let r=t[1]?.trim();if(!r)throw Error(`Invalid postgres volume ${e}. Use postgresql:<name> or postgresql:<user>/<database>.`);let o=r.split("/");if(o.length>2||o.some((s)=>s.trim()===""))throw Error(`Invalid postgres volume ${e}. Use postgresql:<name> or postgresql:<user>/<database>.`);let n=o[0],i=o[1]??n;return{username:n,database:i}}function Tg(e){return typeof e==="string"&&Rg(e)!==void 0}function e$(e,t){let r=t.volumes?.flatMap((o)=>{if(typeof o!=="string")return[];let n=Rg(o);return n?[{...n,service:e,secretName:XS(n.username)}]:[]})??[];if(r.length>1)throw Error(`Service ${e} declares multiple postgres volumes. Only zero or one postgresql:<...> entry is allowed per service.`);return r[0]}function st(e){let t=Object.entries(e.services??{}).flatMap(([o,n])=>{let i=e$(o,n);return i?[i]:[]}),r=new Map;for(let o of t){let n=r.get(o.database);if(n&&n!==o.username)throw Error(`Database ${o.database} is claimed by both ${n} and ${o.username}. A database can only have one owner.`);r.set(o.database,o.username)}return t}var JS="database",YS="postgres",Qa,Wa=5432;var _r=_(()=>{Fe();un();Qa=`c.${JS}.svc.cluster.local`});function ln(e,t){if(typeof e!=="object"||e===null||typeof t!=="object"||t===null)return t;let r=Array.isArray(e)?[...e]:{...e};for(let o of Object.keys(t)){let n=r[o],i=t[o];if(Array.isArray(n)&&Array.isArray(i))r[o]=[...n,...i];else if(n&&typeof n==="object"&&i&&typeof i==="object")r[o]=ln(n,i);else r[o]=i}return r}function Og(e){if(!e.startsWith("s3:"))return;let t=e.split(":");if(t.length!==2)throw Error(`Invalid S3 volume ${e}. Use s3:<name> or s3:<key>/<bucket>.`);let r=t[1]?.trim();if(!r)throw Error(`Invalid S3 volume ${e}. Use s3:<name> or s3:<key>/<bucket>.`);let o=r.split("/");if(o.length>2||o.some((s)=>s.trim()===""))throw Error(`Invalid S3 volume ${e}. Use s3:<name> or s3:<key>/<bucket>.`);let n=o[0],i=o[1]??n;return{key:n,bucket:i}}function Ig(e){return typeof e==="string"&&Og(e)!==void 0}function t$(e,t){let r=t.volumes?.flatMap((o)=>{if(typeof o!=="string")return[];let n=Og(o);return n?[{...n,service:e}]:[]})??[];if(r.length>1)throw Error(`Service ${e} declares multiple S3 volumes. Only zero or one s3:<...> entry is allowed per service.`);return r[0]}function at(e){let t=Object.entries(e.services??{}).flatMap(([o,n])=>{let i=t$(o,n);return i?[i]:[]}),r=new Map;for(let o of t){let n=r.get(o.key);if(n&&n!==o.bucket)throw Error(`S3 key ${o.key} is claimed for both ${n} and ${o.bucket}. A managed key can only target one bucket.`);r.set(o.key,o.bucket)}return t}var wr=_(()=>{Fe();un()});import{existsSync as Bg,readFileSync as r$,realpathSync as Ka,statSync as o$}from"fs";import{dirname as n$,isAbsolute as zg,normalize as i$,relative as s$,resolve as pn,sep as Dg}from"path";function At(e,t){return Object.assign(Error(e),t?{code:t}:{})}function a$(e){if(!e||e.includes("\x00")||e.includes("\\")||e.startsWith("~")||zg(e))throw At(`Artifact path must be workspace-relative: ${e}`);let t=i$(e);if(t===".."||t.startsWith(`..${Dg}`))throw At(`Artifact path escapes the workspace: ${e}`);return t.replace(/^\.\//,"")}function Ha(e,t){let r=s$(e,t);if(r===".."||r.startsWith(`..${Dg}`)||zg(r))throw At(`Artifact path escapes the workspace: ${t}`)}function c$(e,t){let r=t;while(!Bg(r)){let o=n$(r);if(o===r)break;r=o}Ha(e,Ka(r))}function Ga(e,t){if(t!==void 0&&(!Number.isSafeInteger(t)||t<0))throw Error(`${e} must be a non-negative safe integer`)}class Ng{#t;#r=0;#e=0;constructor(e){Ga("maxArtifactCount",e.maxArtifactCount),Ga("maxArtifactBytes",e.maxArtifactBytes),Ga("maxTotalBytes",e.maxTotalBytes),this.#t=e}add(e,t){let r=Buffer.byteLength(t);if(this.#t.maxArtifactBytes!==void 0&&r>this.#t.maxArtifactBytes)throw At(`Artifact ${e} exceeds the ${this.#t.maxArtifactBytes} byte limit`);if(this.#t.maxArtifactCount!==void 0&&this.#r+1>this.#t.maxArtifactCount)throw At(`Artifact count exceeds the ${this.#t.maxArtifactCount} limit`);if(this.#t.maxTotalBytes!==void 0&&this.#e+r>this.#t.maxTotalBytes)throw At(`Artifact bytes exceed the ${this.#t.maxTotalBytes} byte limit`);this.#r+=1,this.#e+=r}}class Qe{#t;#r;#e;constructor(e){this.#t=e.strict?Ka(e.workspace):pn(e.workspace),this.#r=e.strict??!1,this.#e=new Ng(e)}#o(e,t){if(!this.#r)return t.expandHome&&e.startsWith("~")?pn(process.env.HOME??"",e.slice(1)):pn(this.#t,e);let r=pn(this.#t,a$(e));return Ha(this.#t,r),c$(this.#t,r),r}isFile(e,t={}){let r=this.#o(e,t);return Bg(r)&&o$(r).isFile()}readText(e,t={}){let r=this.#o(e,t);if(this.#r)Ha(this.#t,Ka(r));let o=r$(r,"utf8");return this.#e.add(e,o),o}}var Lg=()=>{};import{createHash as Zg}from"crypto";import{basename as qg}from"path";function Qg(e){if(!e.diskTag&&e.replicaCount===void 0&&!e.dataLocality)return;return{diskTag:e.diskTag?[...e.diskTag].sort():void 0,replicaCount:e.replicaCount,dataLocality:e.dataLocality}}function Wg(e){return`kuber-longhorn-${Zg("sha256").update(JSON.stringify(e)).digest("hex").slice(0,12)}`}function ct(e){if(typeof e==="number")return e;if(!e||e.includes("-"))return;let t=Number(e);return Number.isInteger(t)?t:void 0}function Vg(e){if(typeof e!=="string"&&typeof e!=="number")return;let t=String(e).trim(),r=u$.exec(t);if(!r)return;let o=Number(r[1]),n=Number(r[2]);if(!Number.isInteger(o)||!Number.isInteger(n))return;if(o<1||n<1)throw Error(`Invalid replica range ${t}. Range bounds must be positive integers.`);if(o>n)throw Error(`Invalid replica range ${t}. Minimum (${o}) cannot exceed maximum (${n}).`);return{kind:"range",min:o,max:n}}function fn(e,t){if(t===void 0||t.trim()==="")return;let r=Number(t);if(!Number.isInteger(r)||r<0)throw Error(`Invalid ${e} value ${JSON.stringify(t)}. Expected a non-negative integer (zero allowed for a fixed replica count), a numeric string, or a "min-max" range.`)}function Ug(e){if(e.scale!==void 0){let t=ct(e.scale);if(t!==void 0)return fn("scale",String(e.scale)),t;fn("scale",String(e.scale))}if(e.deploy?.replicas!==void 0){let t=ct(e.deploy.replicas);if(t!==void 0)return fn("deploy.replicas",String(e.deploy.replicas)),t;fn("deploy.replicas",String(e.deploy.replicas))}return 1}function Gg(e){let t=Vg(e.scale);if(t)return Mg(t);if(e.scale!==void 0)return{kind:"fixed",value:Ug(e)};let r=Vg(e.deploy?.replicas);if(r)return Mg(r);return{kind:"fixed",value:Ug(e)}}function Mg(e){if(e.min===e.max)return{kind:"fixed",value:e.min};return e}function l$(e){if(e.kind==="range")return e.max>1;return e.value>1}function p$(e,t,r){if(t.build){let o=r[e];if(!o)throw Error(`Missing resolved build image for service ${e}`);return o}return t.image}function Ja(e){return e?.toUpperCase()==="UDP"?"UDP":"TCP"}function mn(e){if(!e)return;return/[a-z]/i.test(e)?e:void 0}function hn(e){return typeof e==="string"?JSON.stringify(e):String(e)}function Fg(e,t){let r=String(e).trim(),o=d$.exec(r);if(!o)throw Error(`Invalid ${t} value ${hn(e)}. Expected a non-negative finite decimal number of CPU cores.`);let n=BigInt(o[1]??"0"),i=o[2]??"",s=n*1000n+(i?BigInt(i.padEnd(3,"0").slice(0,3)):0n);if(i.slice(3).replaceAll("0","")!=="")throw Error(`Invalid ${t} value ${hn(e)}. CPU cores must be representable in whole millicores.`);return s%1000n===0n?String(s/1000n):`${s}m`}function jg(e,t){let r=e.trim(),o=f$.exec(r);if(!o)throw Error(`Invalid ${t} value ${hn(e)}. Expected a non-negative memory quantity.`);let n=o[1]??"",i=(()=>{switch(n.toLowerCase()){case"b":return"";case"k":case"kb":return"k";case"m":case"mb":return"M";case"g":case"gb":return"G";case"t":case"tb":return"T";case"p":case"pb":return"P";case"e":case"eb":return"E";default:return n}})();if(!["","n","u","m","k","M","G","T","P","E","Ki","Mi","Gi","Ti","Pi","Ei"].includes(i))throw Error(`Invalid ${t} value ${hn(e)}. Expected a valid Kubernetes or Compose memory quantity.`);return`${r.slice(0,r.length-n.length)}${i}`}function m$(e){let t=e.deploy?.resources;if(!t)return;let r={...t.limits?.cpus!==void 0?{cpu:Fg(t.limits.cpus,"deploy.resources.limits.cpus")}:{},...t.limits?.memory!==void 0?{memory:jg(t.limits.memory,"deploy.resources.limits.memory")}:{}},o={...t.reservations?.cpus!==void 0?{cpu:Fg(t.reservations.cpus,"deploy.resources.reservations.cpus")}:{},...t.reservations?.memory!==void 0?{memory:jg(t.reservations.memory,"deploy.resources.reservations.memory")}:{}};if(Object.keys(r).length===0&&Object.keys(o).length===0)return;return{...Object.keys(r).length>0?{limits:r}:{},...Object.keys(o).length>0?{requests:o}:{}}}function h$(e){if(typeof e==="boolean")return e;if(!e)return;switch(e.toLowerCase()){case"1":case"true":case"yes":case"on":case"ro":return!0;case"0":case"false":case"no":case"off":case"rw":return!1}}function gn(e){return e.toLowerCase().replace(/[^a-z0-9-]+/g,"-").replace(/^-+|-+$/g,"").slice(0,63)}function Ya(e){if(e===void 0||e===null)return;let t=String(e).trim();if(!t)return;return t}function Kg(e){if(e===void 0||e===null)return;let t=(Array.isArray(e)?e:[e]).flatMap((r)=>String(r).split(",")).map((r)=>r.trim()).filter(Boolean);return t.length>0?[...new Set(t)]:void 0}function Hg(e){if(e===void 0||e===null||e==="")return;let t=Number(e);return Number.isInteger(t)&&t>=1&&t<=20?t:void 0}function g$(e){let[t,r]=e.split(/\s+on\s+/i,2).map((n)=>n?.trim());if(!r)return{requestedStorage:Ya(t)};let o=/^(?:(?<replicas>\d+)\s+)?(?<tags>.+)$/.exec(r);return{requestedStorage:Ya(t),diskTag:Kg(o?.groups?.tags),replicaCount:Hg(o?.groups?.replicas),dataLocality:"none"}}function y$(e){let t=/^(?<name>[^()]+)\((?<size>[^()]+)\)$/.exec(e.trim());if(!t?.groups)return;let r=t.groups.name?.trim(),{requestedStorage:o,diskTag:n,replicaCount:i,dataLocality:s}=g$(t.groups.size??"");if(!r)return;return{source:r,requestedStorage:o,diskTag:n,replicaCount:i,dataLocality:s}}function Jg(e){if(!e||Xa(e))return{source:e};let t=y$(e);if(!t)return{source:e};if(!t.source)throw Error(`Invalid volume source ${e}. Expected name(size).`);return t}function Yg(e){return Ya(e?.["x-size"])}function Xg(e){return Kg(e?.["x-diskTag"])}function ey(e){return Hg(e?.["x-replicaCount"])}function ty(e){return e?.["x-dataLocality"]==="none"?"none":void 0}function ry(e){return gn(`bind-${Bun.hash(e).toString(36)}`)}function Xa(e){return e.startsWith(".")||e.startsWith("/")||e.startsWith("~")||e.includes("/")}function oy(e,t){return t.isFile(e,{expandHome:!0})}function b$(e,t,r){if(Tg(e)||Ig(e))return;let o=e.split(":");if(o.length===1)return{name:`volume-${t}`,kind:"volume",target:e};let n=o.at(-1),i=n==="ro"||n==="rw",s=o.at(i?-2:-1),a=o.slice(0,i?-2:-1).join(":");if(!s)return;let{source:c,requestedStorage:u,diskTag:l,replicaCount:f,dataLocality:d}=Jg(a||void 0);return{name:c&&Xa(c)?ry(c):`volume-${t}`,kind:c&&Xa(c)?oy(c,r)?"config-file":"bind":"volume",source:c||void 0,target:s,configKey:c?qg(c):void 0,readOnly:i?n==="ro":void 0,requestedStorage:u,diskTag:l,replicaCount:f,dataLocality:d}}function _$(e,t,r){if(typeof e==="string")return b$(e,t,r);if(!e.target)return;if(e.type!=="bind"&&e.type!=="volume"&&e.type!=="tmpfs")return;let{source:o,requestedStorage:n,diskTag:i,replicaCount:s,dataLocality:a}=Jg(e.source);return{name:o?e.type==="bind"?ry(o):`${e.type}-${gn(o)||t}`:`${e.type}-${t}`,kind:e.type==="bind"&&o&&oy(o,r)?"config-file":e.type,source:o,target:e.target,readOnly:h$(e.read_only),configKey:o?qg(o):void 0,subPath:e.volume?.subpath,sizeLimit:e.type==="tmpfs"&&e.tmpfs?.size!==void 0?String(e.tmpfs.size):void 0,requestedStorage:n??Yg(e.volume),diskTag:i??Xg(e.volume),replicaCount:s??ey(e.volume),dataLocality:a??ty(e.volume)}}function w$(e,t){if(!t||!e)return;let r=e[t];return Yg(r)}function v$(e,t){if(!t||!e)return;let r=e[t];return Xg(r)}function x$(e,t){if(!t||!e)return;let r=e[t];return ey(r)}function E$(e,t){if(!t||!e)return;let r=e[t];return ty(r)}function yn(e,t,r={}){let o=e.volumes?.flatMap((i,s)=>{let a=_$(i,s,t);if(!a)return[];return[{...a,requestedStorage:a.requestedStorage??w$(r,a.source)??(a.kind==="volume"&&a.source?dn.requestedStorage:void 0),diskTag:a.diskTag??v$(r,a.source)??(a.kind==="volume"&&a.source?dn.diskTag:void 0),replicaCount:a.replicaCount??x$(r,a.source)??(a.kind==="volume"&&a.source?dn.replicaCount:void 0),dataLocality:a.dataLocality??E$(r,a.source)??(a.kind==="volume"&&a.source?dn.dataLocality:void 0)}]})??[],n=(Array.isArray(e.tmpfs)?e.tmpfs:[e.tmpfs]).filter((i)=>Boolean(i)).map((i,s)=>({name:`tmpfs-${o.length+s}`,kind:"tmpfs",target:i}));return[...o,...n]}function S$(e){if(e.length===0)return;return e.map((t)=>({name:t.name,mountPath:t.target,readOnly:t.readOnly,subPath:t.kind==="config-file"?t.configKey:t.subPath}))}function $$(e,t){if(t.length===0)return;return t.map((r)=>{if(r.kind==="config-file")return{name:r.name,configMap:{name:r.name}};if(r.kind==="bind"){if(!r.source)return{name:r.name,emptyDir:{}};return{name:r.name,persistentVolumeClaim:{claimName:r.name}}}if(r.kind==="tmpfs")return{name:r.name,emptyDir:{medium:"Memory",sizeLimit:r.sizeLimit}};if(!r.source)return{name:r.name,emptyDir:{}};return{name:r.name,persistentVolumeClaim:{claimName:gn(`${e}-${r.source}`)}}})}function A$(e){return[...new Set(e.split(",").map((t)=>t.trim()).filter(Boolean).map((t)=>t.startsWith("/")?t:`/${t}`))]}function k$(e){let t=/^(?<portSpec>.+):protected(?:\((?<paths>[^)]*)\))?$/.exec(e);if(!t?.groups)return{portSpec:e};let r=t.groups.portSpec?.trim();if(!r)throw Error(`Invalid protected port syntax ${e}.`);let o=t.groups.paths?.trim();if(o===void 0)return{portSpec:r,routingKind:"ingressroute"};let n=A$(o);if(n.length===0)throw Error(`Invalid protected port syntax ${e}. Expected one or more paths.`);return{portSpec:r,routingKind:"ingressroute",paths:n}}function bn(e){let t=e.ports?.flatMap((o,n)=>{if(typeof o==="number")return[{name:`port-${n}`,containerPort:o,servicePort:o,protocol:"TCP"}];if(typeof o==="string"){let a=/\/(tcp|udp)$/i.exec(o),c=a?o.slice(0,-a[0].length):o,u=a?.[1];if(!c)return[];let{portSpec:l,routingKind:f,paths:d}=k$(c),p=l.split(":"),m=ct(p.at(-1));if(!m)return[];let h=ct(p.at(-2)),y=h!==void 0?mn(p.at(-3)):mn(p.at(-2));return[{name:`port-${n}`,containerPort:m,servicePort:h??m,hostPort:h,host:y,protocol:Ja(u),routingKind:y?f??"ingress":void 0,paths:d}]}let i=ct(o.target);if(!i)return[];let s=ct(o.published);return[{name:o.name??`port-${n}`,containerPort:i,servicePort:s??i,hostPort:s,host:mn(o.host_ip),protocol:Ja(o.protocol),routingKind:mn(o.host_ip)?"ingress":void 0}]})??[],r=e.expose?.flatMap((o,n)=>{let[i,s]=String(o).split("/"),a=ct(i);if(!a)return[];return[{name:`expose-${n}`,containerPort:a,servicePort:a,protocol:Ja(s)}]})??[];return[...t,...r]}function P$(e){if(e.length===0)return;let t=new Map;for(let r of e)t.set(`${r.containerPort}:${r.protocol}`,{name:r.name,containerPort:r.containerPort,hostPort:r.hostPort,protocol:r.protocol});return[...t.values()]}function C$(e){if(e.length===0)return;let t=new Map;for(let r of e)t.set(`${r.servicePort}:${r.protocol}`,{name:r.name,port:r.servicePort,targetPort:r.containerPort,protocol:r.protocol});return[...t.values()]}function R$(e,t){let r=new Set;return t.flatMap((o)=>{if(!o.host||o.routingKind==="ingressroute"||r.has(o.host))return[];return r.add(o.host),[{host:o.host,http:{paths:[{path:"/",pathType:"Prefix",backend:{service:{name:e,port:{number:o.servicePort}}}}]}}]})}function T$(e,t,r){let o=r.flatMap((n)=>{if(!n.host||n.routingKind!=="ingressroute")return[];return(n.paths&&n.paths.length>0?n.paths.map((s)=>`Host(\`${n.host}\`) && PathPrefix(\`${s}\`)`):[`Host(\`${n.host}\`)`]).map((s)=>({kind:"Rule",match:s,middlewares:[{name:"cf-auth",namespace:"routing"}],services:[{name:t,port:n.servicePort}]}))});if(o.length===0)return;return{apiVersion:"traefik.io/v1alpha1",kind:"IngressRoute",metadata:{name:t,namespace:e,labels:X},spec:{routes:o}}}function O$(e){if(!e)return[];return(Array.isArray(e)?e:[e]).map((r)=>typeof r==="string"?{path:r,required:!0}:{path:r.path,required:r.required!==!1&&r.required!=="false"})}function I$(e){let t={};for(let r of e.split(/\r?\n/)){let o=r.trim();if(!o||o.startsWith("#"))continue;let n=o.indexOf("=");if(n===-1)continue;let i=o.slice(0,n).trim(),s=o.slice(n+1);if(!i)continue;t[i]=s}return t}async function B$(e,t){let r={};for(let o of O$(e))try{let n=t.readText(o.path);Object.assign(r,I$(n))}catch(n){if(!o.required&&n&&typeof n==="object"&&"code"in n&&n.code==="ENOENT")continue;throw n}return r}function z$(e,t,r,o,n=process.cwd(),i={},s={},a={},c=new Qe({workspace:n}),u={}){let l=yn(o,c,s),f=bn(o),d=Boolean(o.env_file)||Object.keys(i).length>0,p=u.replicaSpec??Gg(o),m=p.kind==="range"?p.min:p.value,h=[ln({name:t,imagePullPolicy:"Always",env:um(o.environment),image:p$(t,o,a),command:o.command instanceof Array?o.command:o.command?o.command.split(" "):void 0,envFrom:d?[{secretRef:{name:`${t}-env`}}]:void 0,ports:P$(f),resources:m$(o),volumeMounts:S$(l)},o["x-container"]??{})],y={restartPolicy:"Always",...fg(r),volumes:$$(e,l),containers:h};if(l$(p))y.topologySpreadConstraints=[{maxSkew:1,topologyKey:"kubernetes.io/hostname",whenUnsatisfiable:"ScheduleAnyway",labelSelector:{matchLabels:{app:t}}}];return ln({apiVersion:"apps/v1",kind:"Deployment",metadata:{name:t,namespace:e,labels:X},spec:{replicas:m,strategy:{rollingUpdate:{maxSurge:"25%",maxUnavailable:"25%"}},selector:{matchLabels:{app:t}},template:{metadata:{labels:{app:t}},spec:y}}},o["x-deployment"]??{})}function D$(e,t,r){let o=C$(bn(r));if(!o)return;return{apiVersion:"v1",kind:"Service",metadata:{name:t,namespace:e,labels:X},spec:{type:"ClusterIP",selector:{app:t},ports:o}}}function N$(e,t,r){let o=R$(t,bn(r));if(o.length===0)return;return{apiVersion:"networking.k8s.io/v1",kind:"Ingress",metadata:{name:t,namespace:e,labels:X},spec:{rules:o}}}function L$(e,t,r=process.cwd(),o={},n=new Qe({workspace:r})){let i=new Map;for(let s of yn(t,n,o)){let a=s.kind==="bind"?s.source?s.name:void 0:s.kind==="volume"&&s.source?gn(`${e}-${s.source}`):void 0;if(!a||i.has(a))continue;let c=Qg(s);i.set(a,{apiVersion:"v1",kind:"PersistentVolumeClaim",metadata:{name:a,namespace:e,labels:X},spec:{accessModes:[c?.replicaCount===1?"ReadWriteOnce":"ReadWriteMany"],storageClassName:c?Wg(c):void 0,resources:{requests:{storage:s.requestedStorage??"1Gi"}}}})}return[...i.values()]}function V$(e,t=process.cwd(),r={},o=new Qe({workspace:t})){let n=new Map;for(let i of yn(e,o,r)){let s=Qg(i);if(!s)continue;let a=Wg(s);n.set(a,{apiVersion:"storage.k8s.io/v1",kind:"StorageClass",metadata:{name:a,labels:X},provisioner:"driver.longhorn.io",allowVolumeExpansion:!0,reclaimPolicy:"Delete",volumeBindingMode:"Immediate",parameters:{...s.diskTag?{diskSelector:s.diskTag.join(",")}:{},...s.replicaCount!==void 0?{numberOfReplicas:String(s.replicaCount)}:{},...s.dataLocality?{dataLocality:"disabled"}:{}}})}return[...n.values()]}function U$(e,t,r=process.cwd(),o={},n=new Qe({workspace:r})){let i=new Map;for(let s of yn(t,n,o)){if(s.kind!=="config-file"||!s.source||!s.configKey)continue;i.set(s.name,{apiVersion:"v1",kind:"ConfigMap",metadata:{name:s.name,namespace:e,labels:X},data:{[s.configKey]:n.readText(s.source,{expandHome:!0})}})}return[...i.values()]}async function M$(e,t,r,o=process.cwd(),n={},i=new Qe({workspace:o})){let s={...await B$(r.env_file,i),...n};if(Object.keys(s).length===0)return[];return[{apiVersion:"v1",kind:"Secret",metadata:{name:`${t}-env`,namespace:e,labels:X},type:"Opaque",stringData:s}]}function F$(e){let t=Object.entries(e.stringData??{}).sort(([r],[o])=>r.localeCompare(o));return Zg("sha256").update(JSON.stringify(t)).digest("hex")}function j$(e){return{apiVersion:"v1",kind:"Namespace",metadata:{name:e,labels:X}}}function Z$(e,t){let r=e.spec?.template.spec?.containers[0];if(!r)return;if(t["x-container"]?.resources?.requests?.cpu!==void 0)return;if(r.resources??={},r.resources.requests??={},r.resources.requests.cpu===void 0)r.resources.requests.cpu="100m"}function q$(e,t,r){return{apiVersion:"autoscaling/v2",kind:"HorizontalPodAutoscaler",metadata:{name:t,namespace:e,labels:X},spec:{scaleTargetRef:{apiVersion:"apps/v1",kind:"Deployment",name:t},minReplicas:r.min,maxReplicas:r.max,metrics:[{type:"Resource",resource:{name:"cpu",target:{type:"Utilization",averageUtilization:80}}}]}}}function ke(e){return`${e.kind}:${e.metadata?.namespace??""}:${e.metadata?.name??""}`}async function _n(e,t,r=process.cwd(),o={},n={},i=new Qe({workspace:r})){let s=new Map,a=j$(e);s.set(ke(a),a);for(let[c,u]of Object.entries(t.services??{})){for(let b of V$(u,r,t.volumes,i))s.set(ke(b),b);for(let b of L$(e,u,r,t.volumes,i))s.set(ke(b),b);for(let b of U$(e,u,r,t.volumes,i))s.set(ke(b),b);let l=await M$(e,c,u,r,o[c]??{},i);for(let b of l)s.set(ke(b),b);let f=D$(e,c,u);if(f)s.set(ke(f),f);let d=Gg(u),p=z$(e,c,t,u,r,o[c]??{},t.volumes,n,i,{replicaSpec:d}),m=l[0];if(m)p.spec.template.metadata.annotations={...p.spec?.template.metadata?.annotations,"kuber.astrxl.dev/env-checksum":F$(m)};if(s.set(ke(p),p),d.kind==="range"){Z$(p,u);let b=q$(e,c,d);s.set(ke(b),b)}let h=N$(e,c,u);if(h)s.set(ke(h),h);let y=T$(e,c,bn(u));if(y)s.set(ke(y),y)}return[...s.values()]}var dn,u$,d$,f$;var ec=_(()=>{Fe();za();_r();ot();wr();Lg();dn={requestedStorage:"1Gi",diskTag:["fast"],replicaCount:2,dataLocality:"none"};u$=/^\s*(\d+)\s*-\s*(\d+)\s*$/;d$=/^(\d+)(?:\.(\d+))?$/,f$=/^(?:\d+(?:\.\d+)?|\.\d+)([a-zA-Z]*)$/});import{randomUUID as tc}from"crypto";import{isDeepStrictEqual as ny}from"util";function py(e){return`/workspaces/${encodeURIComponent(e)}/adopt`}function iy(e,t){let r={...e};for(let[o,n]of Object.entries(t))r[o]={...r[o],...n};return r}function H$(e){let{resource:t,phase:r,state:o}=e.data;return`${r==="apply"?"Applied":r==="wait"?"Waited for":"Deleted"} ${t.kind}/${t.name}: ${o}`}function J$(e){if(!e||typeof e!=="object")return!1;let{sequence:t,data:r}=e;if(!Number.isSafeInteger(t)||!r||typeof r!=="object")return!1;let{resource:o,phase:n,state:i}=r;if(!o||typeof o!=="object")return!1;let s=o;return typeof s.apiVersion==="string"&&typeof s.kind==="string"&&typeof s.name==="string"&&(s.namespace===void 0||typeof s.namespace==="string")&&(n==="apply"||n==="wait"||n==="delete")&&(i==="started"||i==="succeeded"||i==="failed"||i==="aborted")}function Y$(e,t){return{source:{uri:`cas://${t.digest}`,digest:t.digest},config:{compose:e}}}function X$(e,t){return ny(e.spec?.source,t.source)&&ny(e.spec?.config,t.config)}function sy(e){if(e instanceof xe)return e.status===409;if(e instanceof DOMException&&e.name==="AbortError")return!1;if(e instanceof Error&&e.name==="AbortError")return!1;return e instanceof TypeError||e instanceof Error&&e.name==="TimeoutError"}async function eA(e,t,r,o=C){let n=`/workspaces/${encodeURIComponent(e)}`,i=Y$(t,r),s=(u)=>o(n,{method:"PUT",headers:{"if-match":`"${u.metadata.resourceVersion}"`},json:i}),a=async(u)=>{try{let l=await o(n);if(X$(l,i))return l;return await s(l)}catch{throw u}},c;try{c=await o(n)}catch(u){if(!(u instanceof xe)||u.status!==404)throw u;try{return await o("/workspaces",{method:"POST",json:{id:e,...i}})}catch(l){if(!sy(l))throw l;return a(l)}}try{return await s(c)}catch(u){if(!sy(u))throw u;return a(u)}}function ay(e){return Object.fromEntries(Object.entries(e).filter(([t,r])=>t!=="operation"&&t!=="operationId"&&r!==null&&typeof r==="object"&&!Array.isArray(r)))}function wn(e,t){let r=t instanceof Error?t.message:String(t);if(!/namespace .* (?:external|different-workspace)/i.test(r))return t instanceof Error?t:Error(r);return Error(`${r}. Safe adoption requires ${ly} ${py(e)} with namespace UID and ownership preconditions.`,{cause:t})}async function Pt(e,t,r,o){try{return await t(r,o)}catch(n){throw wn(e,n)}}function tA(e){if(!e||typeof e!=="object")return;let t=e.operationId;return typeof t==="string"&&t?t:void 0}function rA(e){if(!e||typeof e!=="object")return;let t=e.operation?.status;return t&&typeof t==="object"?t:void 0}function cy(e,t){let r=t.error,o=t.state==="cancelled",n=typeof r?.message==="string"?r.message:o?"The operation was cancelled":"The operation failed",i=typeof r?.code==="string"?r.code:o?"OPERATION_CANCELLED":"OPERATION_FAILED";return new xe(n,o?409:500,{title:o?"Operation cancelled":"Operation failed",status:o?409:500,code:i,operationId:e})}function oA(e){if(e instanceof xe)return K$.has(e.code);if(e instanceof DOMException&&e.name==="AbortError")return!1;if(e instanceof Error&&e.name==="AbortError")return!1;return e instanceof TypeError||e instanceof Error&&e.name==="TimeoutError"}function nA(e){return e.state==="failed"&&e.error?.code==="OPERATION_INTERRUPTED"}function iA(e,t){return e.cursorGap===!0||Number.isSafeInteger(e.retainedFirstSequence)&&e.retainedFirstSequence>t+1}function sA(e,t){return t+Math.max(e,0)+G$}function dy(e){return e.reason??new DOMException("The operation was aborted","AbortError")}function kt(e){if(e?.aborted)throw dy(e)}function aA(e,t){return kt(t),new Promise((r,o)=>{let n,i=()=>{if(n!==void 0)clearTimeout(n);t?.removeEventListener("abort",a)},s=()=>{i(),r()},a=()=>{i(),o(dy(t))};if(n=setTimeout(s,e),t?.addEventListener("abort",a,{once:!0}),t?.aborted)a()})}async function rc(e,t,r,o,n,i){let s=i.now??Date.now,a=sA(n,s()),c=new Headers(o.headers);c.set("idempotency-key",tc()),c.set("prefer","respond-async");let u={...o,headers:c,signal:i.signal??o.signal},l,f=Q$,d=!1,p=0;for(;;){if(kt(i.signal),d&&s()>=a)throw Error("Timed out while reconnecting to resume the operation");try{let y;if(l)y=(await Pt(e,t,`/operations/${encodeURIComponent(l)}`,{signal:i.signal})).status;else{d=!1;let b=await Pt(e,t,r,u);l=tA(b),y=rA(b)}if(l)try{let b=await Pt(e,t,`/operations/${encodeURIComponent(l)}/events?after=${p}`,{signal:i.signal});if(iA(b,p))throw new ic;for(let P of b.items??[]){if(!Number.isSafeInteger(P.sequence)||P.sequence<=p)continue;if(p=P.sequence,!J$(P))continue;i.onEvent?.(P)}}catch(b){if(b instanceof ic)throw b;kt(i.signal)}if(!l||!y||y.state==="succeeded")return;if(nA(y)){if(s()>=a)throw cy(l,y);l=void 0,p=0,d=!0,c.set("idempotency-key",tc()),u={...o,headers:c,signal:i.signal??o.signal}}else if(y.state==="failed"||y.state==="cancelled")throw cy(l,y)}catch(y){if(kt(i.signal),y instanceof xe&&y.code==="OPERATION_INTERRUPTED"){if(s()>=a)throw wn(e,y);l=void 0,p=0,d=!0,c.set("idempotency-key",tc()),u={...o,headers:c,signal:i.signal??o.signal}}else{if(!oA(y))throw wn(e,y);if(s()>=a)throw wn(e,y)}}let m=a-s();if(m<=0)throw Error("Timed out while reconnecting to resume the operation");let h=Math.min(f,m);if(i.sleep)kt(i.signal),await i.sleep(h),kt(i.signal);else await aA(h,i.signal);f=Math.min(f*2,W$)}}async function cA(e,t,r=C){let o=`/workspaces/${encodeURIComponent(e)}`;return Pt(e,r,`${o}/resources/plan`,{method:"POST",json:{resources:t}})}function oc(e){let t=e.name??e.metadata?.name;if(!e.apiVersion||!e.kind||!t)return;return{apiVersion:e.apiVersion,kind:e.kind,name:t,namespace:e.namespace??e.metadata?.namespace}}function uy(e){return`${e.apiVersion}\x00${e.kind}\x00${e.namespace??""}\x00${e.name}`}function uA(e,t){return`${e==="apply"?"Apply":e==="wait"?"Wait for":"Delete"} ${t.kind}/${t.name}`}function nc(e,t,r,o,n={}){if(r.length===0)return o(()=>{},e.signal);let i=new Map,s=new Set,a=0;return e.newListr(r.map((c)=>({title:uA(t,c),task:async(u,l)=>{if(i.set(uy(c),l),n.onTaskStarted?.(c,l),a+=1,a!==r.length)return new Promise((f)=>{let d=()=>{e.signal.removeEventListener("abort",d),s.delete(d),f()};if(s.add(d),e.signal.aborted)d();else e.signal.addEventListener("abort",d,{once:!0})});try{await o((f)=>{let d=f.data.resource,p=i.get(uy(d));if(!p)return;p.output=f.data.state,e.output=H$(f)},e.signal)}finally{for(let f of[...s])f()}}})),{concurrent:!0})}async function vr(e,t=C,r={}){let{project:o,compose:n,cwd:i,config:s,hookContext:a}=D(),c=r.trust??await km(await bt(o,i)),u=t;t=async(d,p={},m)=>{let h=new Headers(p.headers);for(let[y,b]of Object.entries(Am(c)))h.set(y,b);return u(d,{...p,headers:h},m)};let l=`/workspaces/${encodeURIComponent(o)}`;return await new he([{title:"Read compose",task:async(d,p)=>{if(d.compose=await n(),e)await s.preBuild?.(d.compose,await a());p.output=`${Object.keys(d.compose.services??{}).length} services`}},{title:"Snapshot workspace",task:async(d,p)=>{let m;try{m=await ja(i)}catch(h){m=i}d.workspaceRoot=m,d.snapshot=await an(m),p.output=`${d.snapshot.manifest.files.length} files`}},{title:"Build images",rendererOptions:{bottomBar:1/0,persistentOutput:!0},enabled:async()=>e&&Object.values((await n()).services??{}).some((d)=>d.build),task:async(d,p)=>{let m=Object.entries(d.compose.services??{}).filter(([,A])=>A.build).map(([A])=>A),h=new Map,y=new Map,b=new Map(m.map((A)=>[A,new Promise((T)=>y.set(A,T))])),P,E,k,x=()=>(k??=Ag(o,d.compose,i,{progress:(A)=>{if(p.output!==A)p.output=A},service:(A)=>{let T;return{progress:(B)=>{let W=h.get(A);if(W&&W.output!==B)W.output=B},get stream(){let B=h.get(A);if(B)T??=B.stdout();return T}}},settled:(A,T)=>{y.get(A)?.(T),y.delete(A)}},{...s,request:t,snapshot:d.snapshot,workspaceRoot:d.workspaceRoot,signal:p.signal}).then((A)=>{P=A},(A)=>{let T=A instanceof Error?A:Error(String(A));E=T,p.output=T.stack??T.message,p.report(T,ag.HAS_FAILED);for(let B of y.values())B(T);y.clear()}),k);return p.newListr([...m.map((A)=>({title:`Build ${A}`,rendererOptions:{outputBar:10,persistentOutput:!0},exitOnError:!1,task:async(T,B)=>{if(h.set(A,B),B.output="Build queued",h.size===m.length)x();let W=await b.get(A);if(W)throw W;B.output="done"}})),{task:async()=>{if(await Promise.all(b.values()),await k,!P)throw E??Error("Build images failed");d.buildImages=P.images,await s.postBuild?.(P,await a()),p.title=`Built ${P.built.length} image${P.built.length===1?"":"s"}`}}],{concurrent:!0})}},{title:"Resolve images",enabled:async()=>!e&&Object.values((await n()).services??{}).some((d)=>d.build),task:async(d,p)=>{d.buildImages=await cn(o,d.compose,{...s,request:t}),p.output=`${Object.keys(d.buildImages).length} images`}},{title:"Update workspace",task:async(d,p)=>{let m=await eA(o,d.compose,d.snapshot,t),h=await t(py(o),{method:ly,json:{workspaceUid:m.metadata.uid}});p.output=h.resourcesAdopted?`Adopted ${h.resourcesAdopted} existing resources`:"Workspace ready"}},{title:"Reconcile backing services",task:async(d,p)=>{let m={},h={};await p.newListr([{title:"Reconcile databases",enabled:()=>st(d.compose).length>0,task:async(y,b)=>{let P=await Pt(o,t,`${l}/databases`,{method:"POST",json:{compose:d.compose}});m=ay(P),b.output=`${Object.keys(m).length} services`}},{title:"Reconcile S3 storage",enabled:()=>at(d.compose).length>0,task:async(y,b)=>{let P=await Pt(o,t,`${l}/storage`,{method:"POST",json:{compose:d.compose}});h=ay(P),b.output=`${Object.keys(h).length} services`}}],{concurrent:!0}).run(),d.serviceEnv=iy(iy(d.serviceEnv,m),h)}},{title:"Render manifests",task:async(d,p)=>{d.resources=await _n(o,d.compose,i,d.serviceEnv,d.buildImages),await s.postRender?.(d.resources,await a()),p.output=`${d.resources.length} resources`}},{title:"Reconcile resources",task:async(d,p)=>{d.plan=await cA(o,d.resources,t);let m=d.plan,h=m.desired.map(oc).filter((E)=>Boolean(E)),y=m.desired.filter((E)=>E.kind==="Deployment").map(oc).filter((E)=>Boolean(E)),b=m.stale.map(oc).filter((E)=>Boolean(E)),P=`${l}/resources`;return p.newListr([{title:"Apply resources",task:async(E,k)=>nc(k,"apply",h,(x,A)=>rc(o,t,`${P}/apply`,{method:"POST",json:{resources:m.desired}},s.rolloutTimeoutMs,{onEvent:x,signal:A}))},{title:"Run post-apply hook",skip:!s.postApply,task:async()=>s.postApply?.(m.desired,await a())},{title:"Wait for deployments",skip:y.length===0,task:async(E,k)=>nc(k,"wait",y,(x,A)=>rc(o,t,`${P}/wait`,{method:"POST",json:{deployments:y.map((T)=>T.name),timeoutMs:s.rolloutTimeoutMs}},s.rolloutTimeoutMs,{onEvent:x,signal:A}))},{title:"Delete stale resources",skip:b.length===0,task:async(E,k)=>nc(k,"delete",b,(x,A)=>rc(o,t,`${P}/delete`,{method:"POST",json:{resources:m.stale}},s.rolloutTimeoutMs,{onEvent:x,signal:A}))}])}}],{renderer:"default",rendererOptions:{collapseErrors:!1,collapseSubtasks:!1,lazy:!0}}).run()}var ly="POST",Q$=250,W$=5000,G$=60000,K$,ic,lA;var vn=_(()=>{q();St();G();Za();ec();oe();_r();wr();Fa();Do();K$=new Set(["HTTP_502","HTTP_503","HTTP_504"]);ic=class ic extends Error{constructor(){super("Operation progress history was truncated; refusing to report an incomplete resource stream")}};lA=S({meta:{name:"up",description:"Create and start deployments"},args:{build:{type:"boolean",default:!0,alias:"b",description:"Build images before starting deployments",negativeDescription:"Don't build an image, even if it's policy"}},async run({args:e}){await vr(e.build)}})});function pA(e){let t=e?.trim();if(!t)throw Error("KUBER_API_KEY or --api-key is required for kuber ci");return t}function dA(e){return(t,r={},o={})=>{let n=new Headers(r.headers);return n.set("authorization",`Bearer ${e}`),C(t,{...r,headers:n},{...o,authenticated:!1})}}async function fA(e,t,r,o=dA(r)){let{project:n,cwd:i}=D(),s=await bt(n,i);if(t)await o(`/workspaces/${encodeURIComponent(n)}/trust`,{method:"POST",json:{fingerprint:s.fingerprint}});await vr(e,o,{trust:t?s:void 0})}var mA;var fy=_(()=>{q();G();oe();Do();vn();mA=S({meta:{name:"ci",description:"Deploy using an API key without a session"},args:{apiKey:{type:"string",description:"API key (defaults to KUBER_API_KEY)"},trust:{type:"boolean",description:"Grant current directory trust before deploying"},build:{type:"boolean",default:!0,negativeDescription:"Resolve existing images without building"}},async run({args:e}){await fA(e.build,Boolean(e.trust),pA(e.apiKey??process.env.KUBER_API_KEY))}})});function hA(e,t,r=C){return r(`/workspaces/${encodeURIComponent(e)}/databases/credentials`,{method:"POST",json:{claim:t}})}var gA,yA,bA;var my=_(()=>{q();G();oe();_r();ot();gA=S({meta:{name:"ls",description:"List managed postgres claims"},async run(){let e=st(await D().compose());if(e.length===0){console.log("No managed postgres volumes declared");return}console.log(fe(e.map((t)=>({service:t.service,username:t.username,database:t.database,secret:t.secretName}))))}}),yA=S({meta:{name:"creds",description:"Print postgres credentials for a service"},async run({args:e}){let t=e._[0];if(!t)throw Error("Service name is required");let r=D(),o=st(await r.compose()).find((s)=>s.service===t);if(!o)throw Error(`Service ${t} does not declare a managed postgres volume.`);let n=await hA(r.project,o),i=Cg(o,n);console.log(fe([{service:o.service,username:n.username,database:o.database,host:Qa,port:Wa,secret:o.secretName}])),console.log(`DATABASE_URL=${i}`)}}),bA=S({meta:{name:"db",description:"Inspect managed postgres databases"},subCommands:{creds:yA,ls:gA}})});function _A(e,t=!1,r=C){return r(`/workspaces/${encodeURIComponent(e)}/down`,{method:"POST",json:{full:t}})}var wA;var hy=_(()=>{q();St();G();oe();wA=S({meta:{name:"down",description:"Delete managed resources except ingress and PVCs"},args:{full:{type:"boolean",alias:"f",description:"Also delete ingress, PVCs, and the namespace"}},async run({args:e}){let{project:t}=D();await new he([{title:"Delete resources",task:async(r,o)=>{let n=await _A(t,e.full);o.output=`${n.delete.length} resources queued`}}]).run()}})});async function gy(e,t,r=process.cwd(),o={}){let n=[...st(t).length?["Postgres"]:[],...at(t).length?["S3"]:[]];if(n.length>0)throw Error(`Cannot export without generated ${n.join(" and ")} credentials. Export is side-effect-free; run kuber up or remove managed provider claims.`);let i=await cn(e,t,o);return _n(e,t,r,{},i)}var yy=_(()=>{ec();_r();wr();Za()});import{resolve as vA}from"path";var{YAML:xA}=globalThis.Bun;function EA(e){return`${Pg(e).map((t)=>xA.stringify(t,null,2).trimEnd()).join(`
|
|
101
101
|
---
|
|
102
102
|
`)}
|
|
103
|
-
`}var SA;var by=_(()=>{q();un();oe();yy();SA=S({meta:{name:"export",description:"Write rendered manifests to a YAML file"},args:{output:{type:"string",alias:"o",description:"Output YAML file path"}},async run({args:e}){let{project:t,compose:r,cwd:o,config:n,hookContext:i}=D(),s=await gy(t,await r(),o,n);await n.postRender?.(s,await i());let a=vA(o,e.output||`${t}.yaml`);await Bun.write(a,EA(s)),console.log(a)}})});function $A(e,t){let r=new URL(`${e}${t}`);return r.protocol=r.protocol==="https:"?"wss:":"ws:",r.toString()}function kA(e){if(typeof e!=="string")throw Error("Exec frame must be JSON text");let t=JSON.parse(e);if(!t||typeof t!=="object"||!("type"in t))throw Error("Invalid exec frame");let r=t;if(r.type==="stdout"||r.type==="stderr"){if(r.encoding!=="base64"||typeof r.data!=="string")throw Error("Invalid exec output frame");return{type:r.type,data:Uint8Array.from(Buffer.from(r.data,"base64"))}}if(r.type==="exit"&&Number.isSafeInteger(r.exitCode))return r;if(r.type==="error"&&typeof r.message==="string")return r;throw Error("Invalid exec frame")}async function _y(e,t,r,o={}){if(r.aborted)throw r.reason??new DOMException("Aborted","AbortError");let n=o.session??await yt();if(!n)throw Error("Not logged in. Run kuber login first.");let i=`/workspaces/${encodeURIComponent(e)}/exec`,s=(o.socketFactory??AA)($A(o.baseUrl??Ao,i),{authorization:`Bearer ${n.token}`});s.binaryType="arraybuffer",await new Promise((E,
|
|
103
|
+
`}var SA;var by=_(()=>{q();un();oe();yy();SA=S({meta:{name:"export",description:"Write rendered manifests to a YAML file"},args:{output:{type:"string",alias:"o",description:"Output YAML file path"}},async run({args:e}){let{project:t,compose:r,cwd:o,config:n,hookContext:i}=D(),s=await gy(t,await r(),o,n);await n.postRender?.(s,await i());let a=vA(o,e.output||`${t}.yaml`);await Bun.write(a,EA(s)),console.log(a)}})});function $A(e,t){let r=new URL(`${e}${t}`);return r.protocol=r.protocol==="https:"?"wss:":"ws:",r.toString()}function kA(e){if(typeof e!=="string")throw Error("Exec frame must be JSON text");let t=JSON.parse(e);if(!t||typeof t!=="object"||!("type"in t))throw Error("Invalid exec frame");let r=t;if(r.type==="stdout"||r.type==="stderr"){if(r.encoding!=="base64"||typeof r.data!=="string")throw Error("Invalid exec output frame");return{type:r.type,data:Uint8Array.from(Buffer.from(r.data,"base64"))}}if(r.type==="exit"&&Number.isSafeInteger(r.exitCode))return r;if(r.type==="error"&&typeof r.message==="string")return r;throw Error("Invalid exec frame")}async function _y(e,t,r,o={}){if(r.aborted)throw r.reason??new DOMException("Aborted","AbortError");let n=o.session??await yt();if(!n)throw Error("Not logged in. Run kuber login first.");let i=`/workspaces/${encodeURIComponent(e)}/exec`,s=(o.socketFactory??AA)($A(o.baseUrl??Ao,i),{authorization:`Bearer ${n.token}`});s.binaryType="arraybuffer",await new Promise((E,k)=>{let x=()=>{W(),s.send(JSON.stringify({type:"start",version:1,...t})),E()},A=(Te)=>{W(),k(Te.error??Error("Exec WebSocket connection failed"))},T=()=>{W(),k(Error("Exec WebSocket closed before opening"))},B=()=>{W(),s.close(1000,"aborted"),k(r.reason??new DOMException("Aborted","AbortError"))},W=()=>{s.removeEventListener("open",x),s.removeEventListener("error",A),s.removeEventListener("close",T),r.removeEventListener("abort",B)};s.addEventListener("open",x),s.addEventListener("error",A),s.addEventListener("close",T),r.addEventListener("abort",B,{once:!0})});let a=[],c=[],u=!1,l,f=!1,d=[],p=(E)=>{if(u)return;u=!0,l=E,s.removeEventListener("message",m),s.removeEventListener("error",h),s.removeEventListener("close",y),r.removeEventListener("abort",b);for(let k of c.splice(0))if(E)k.reject(E);else k.resolve({done:!0,value:void 0})},m=(E)=>{try{if(!f){f=!0;for(let A of d.splice(0))s.send(JSON.stringify(A))}let k=kA(E.data),x=c.shift();if(x)x.resolve({done:!1,value:k});else a.push(k)}catch(k){s.close(1002,"invalid frame"),p(k)}},h=(E)=>p(E.error??Error("Exec WebSocket failed")),y=()=>p(),b=()=>{s.close(1000,"aborted"),p()};s.addEventListener("message",m),s.addEventListener("error",h),s.addEventListener("close",y),r.addEventListener("abort",b,{once:!0});let P=(E)=>{if(u)throw l??Error("Exec session is closed");if(!f){d.push(E);return}s.send(JSON.stringify(E))};return{sendStdin(E,k){P({type:"stdin",data:Buffer.from(E).toString("base64"),encoding:"base64",...k?{eof:!0}:{}})},resize(E,k){P({type:"resize",columns:E,rows:k})},close(){if(!u&&s.readyState===1)P({type:"close"});s.close(1000,"client closed"),p()},[Symbol.asyncIterator](){return{next(){let E=a.shift();if(E)return Promise.resolve({done:!1,value:E});if(l)return Promise.reject(l);if(u)return Promise.resolve({done:!0,value:void 0});return new Promise((k,x)=>c.push({resolve:k,reject:x}))}}}}}var AA=(e,t)=>new WebSocket(e,{headers:t});var wy=_(()=>{Fe();Po()});function vy(){return{columns:process.stdout.columns,rows:process.stdout.rows}}async function PA(e,t,r,o,n=_y,i){if(!t)throw Error("Deployment name is required");if(r.length===0)throw Error("Command is required");let s=Boolean(process.stdin.isTTY&&process.stdout.isTTY&&process.stdin.isRaw),a=await n(e,{deployment:t,command:r,tty:s,...s?vy():{}},o,i),c=(f)=>a.sendStdin(typeof f==="string"?new TextEncoder().encode(f):f),u=()=>a.sendStdin(new Uint8Array,!0),l=()=>{let{columns:f,rows:d}=vy();if(f&&d)a.resize(f,d)};if(process.stdin.on("data",c),process.stdin.once("end",u),s)process.stdout.on("resize",l);try{for await(let f of a)if(f.type==="stdout")process.stdout.write(f.data);else if(f.type==="stderr")process.stderr.write(f.data);else if(f.type==="error")throw Error(f.message);else return f.exitCode;if(o.aborted)return 0;throw Error("Exec connection closed without an exit status")}finally{process.stdin.off("data",c),process.stdin.off("end",u),process.stdout.off("resize",l),a.close()}}var CA;var xy=_(()=>{q();oe();wy();CA=S({meta:{name:"exec",description:"Execute a command inside a deployment pod"},async run({args:e}){let[t,...r]=e._;if(!t)throw Error("Deployment name is required");if(r.length===0)throw Error("Command is required");let o=new AbortController,n=()=>o.abort();process.on("SIGINT",n),process.on("SIGTERM",n);let i=Boolean(process.stdin.isTTY);if(i)process.stdin.setRawMode?.(!0),process.stdin.resume();try{let s=await PA(D().project,t,r,o.signal);if(s!==0)process.exitCode=s}catch(s){if(!o.signal.aborted)throw s}finally{if(process.off("SIGINT",n),process.off("SIGTERM",n),i)process.stdin.setRawMode?.(!1),process.stdin.pause()}}})});import{styleText as Ct}from"util";var{inspect:Ey}=globalThis.Bun;function ac(e){let t=Date.now(),r=Sy[sc];sc=(sc+1)%Sy.length;function o(i,s){return(a,...c)=>{if(!(i===console?process.stdout.isTTY:process.stderr.isTTY)){let f=`${(e??`${Date.now()-t}ms`).padStart(7)} \u258C${s?"\u258C":" "}`,d=a.reduce((p,m,h)=>p+m+(typeof c[h]==="string"?c[h]:typeof c[h]<"u"?Ey(c[h],{colors:!1}):""),"");d=d.split(`
|
|
104
104
|
`).join(`
|
|
105
105
|
${" ".repeat(7)} \u258C${s?"\u258C":" "}`),i.write(`${f}${d}
|
|
106
106
|
`);return}let l=Ct(r,`${(s?Ct:(f,d)=>d)("bold",(e??`${Date.now()-t}ms`).padStart(7))} \u258C${s?Ct(s,"\u258C"):" "}${a.reduce((f,d,p)=>f+Ct(r,d)+(typeof c[p]==="string"?c[p]:typeof c[p]<"u"?Ey(c[p],{colors:!0}):""),"").split(`
|
|
@@ -916,4 +916,4 @@ Register-ArgumentCompleter -CommandName '${e}' -ScriptBlock $__${r}CompleterBloc
|
|
|
916
916
|
`}var mc=_(()=>{fc()});function Hy(e="cli"){if(process.argv.indexOf("--")===-1){let t=`Error: You need to use -- to separate completion arguments.
|
|
917
917
|
Example: ${e} complete -- <args>`;console.error(t),process.exit(1)}}var Jy=()=>{};async function jk(e){let t=[],r=[];for(let[o,n]of Object.entries(e))if(n.type==="positional"){let i=n;r.push({name:o,description:i.description,isOptional:!i.required,isVariadic:o.startsWith("[...")||o.startsWith("<...")})}else{let i={name:`--${o}`,description:n.description||"",isRequired:n.required};"alias"in n&&n.alias&&(Array.isArray(n.alias)?n.alias:[n.alias]).forEach((s)=>{t.push({...i,name:`-${s}`})}),t.push(i)}return{options:t,args:r}}async function Yy(e,t=""){let r=await Promise.resolve(e.meta),o=await Promise.resolve(e.subCommands);if(!r||!r.name)throw Error("Command meta or name is missing");let n={name:t?`${t} ${r.name}`:r.name,description:r.description||""};if(e.args){let{options:i,args:s}=await jk(await Promise.resolve(e.args));i.length>0&&(n.options=i),s.length>0&&(n.args=s)}return o&&(n.subcommands=await Promise.all(Object.entries(o).map(async([i,s])=>Yy(await Promise.resolve(s),n.name)))),n}async function Zk(e){let t=await Yy(e);return JSON.stringify(t,null,2)}function Xy(e){return e.args&&Object.values(e.args).some((t)=>t.type==="positional")}async function eb(e,t,r){for(let[o,n]of Object.entries(e)){let i=await xr(n),s=await xr(i.meta),a=await xr(i.subCommands),c=r?.[o];if(!s||typeof s?.description!="string")throw Error("Invalid meta or missing description.");let u=Xy(i),l=t?`${t} ${o}`:o,f=Re.command(l,s.description);if(u&&i.args)for(let[d,p]of Object.entries(i.args)){let m=p;if(m.type==="positional"){let h=m.required===!1,y=c?.args?.[d];y?f.argument(d,y,h):f.argument(d,void 0,h)}}if(a&&await eb(a,l,c?.subCommands),i.args)for(let[d,p]of Object.entries(i.args)){let m=p,h=typeof m=="object"&&"alias"in m?Array.isArray(m.alias)?m.alias[0]:m.alias:void 0,y=c?.options?.[d];y?h?f.option(d,m.description??"",y,h):f.option(d,m.description??"",y):h?f.option(d,m.description??"",h):f.option(d,m.description??"")}}}async function tb(e,t){let r=await xr(e.meta);if(!r)throw Error("Invalid meta.");let o=r.name;if(!o)throw Error("Invalid meta or missing name.");let n=await xr(e.subCommands);if(Xy(e)&&e.args)for(let[s,a]of Object.entries(e.args)){let c=a;if(c.type==="positional"){let u=c.required===!1,l=t?.args?.[s];l?Re.argument(s,l,u):Re.argument(s,void 0,u)}}if(n&&await eb(n,void 0,t?.subCommands),e.args)for(let[s,a]of Object.entries(e.args)){let c=a,u=typeof c=="object"&&"alias"in c?Array.isArray(c.alias)?c.alias[0]:c.alias:void 0,l=t?.options?.[s];l?u?Re.option(s,c.description??"",l,u):Re.option(s,c.description??"",l):u?Re.option(s,c.description??"",u):Re.option(s,c.description??"")}let i=S({meta:{name:"complete",description:"Generate shell completion scripts"},args:{shell:{type:"positional",description:"Shell type (zsh, bash, fish, powershell, fig)",required:!1}},async run(s){let a=s.rawArgs[0];a==="--"&&(a=void 0);let c=o;switch(a){case"zsh":{let u=Sn(o,c);console.log(u);break}case"bash":{let u=$n(o,c);console.log(u);break}case"fish":{let u=An(o,c);console.log(u);break}case"powershell":{let u=kn(o,c);console.log(u);break}case"fig":{let u=await Zk(e);console.log(u);break}default:{Hy(o);let u=s.rawArgs.slice(s.rawArgs.indexOf("--")+1);return Re.parse(u)}}}});return n?n.complete=i:e.subCommands={complete:i},Re}async function xr(e){return e instanceof Function?await e():await e}var rb=_(()=>{mc();fc();Jy();q()});q();q();Ms();var Uf=Symbol("wrappedCommand");function Fs(e){if(e instanceof Ad)return zc(e);if(e instanceof Error){let t=e.stack?.split(`
|
|
918
918
|
`).slice(0,3).join(`
|
|
919
|
-
`);return t&&t.trim().length>0?t:e.message}try{return JSON.stringify(e,null,2)}catch{return String(e)}}function Lw(e){console.error(Fs(e)),process.exitCode=1}function tr(e,t=Lw){let r=e;if(r[Uf])return;if(r[Uf]=!0,e.run){let o=e.run;e.run=async(...n)=>{try{return await o(...n)}catch(i){t(i)}}}if(!e.subCommands||typeof e.subCommands!=="object")return;for(let o of Object.values(e.subCommands))if(o&&typeof o==="object")tr(o,t)}function Q(e){let t;return()=>t??=e().then((r)=>{let o=nb(r);return tr(o),o}).catch((r)=>{throw t=void 0,r})}function nb(e){let t={...e},r=t.subCommands;if(r&&typeof r==="object")t.subCommands=Object.fromEntries(Object.entries(r).map(([o,n])=>[o,n&&typeof n==="object"?nb(n):n]));return t}var Rt=S({meta:{name:"kuber",version:"2.6.
|
|
919
|
+
`);return t&&t.trim().length>0?t:e.message}try{return JSON.stringify(e,null,2)}catch{return String(e)}}function Lw(e){console.error(Fs(e)),process.exitCode=1}function tr(e,t=Lw){let r=e;if(r[Uf])return;if(r[Uf]=!0,e.run){let o=e.run;e.run=async(...n)=>{try{return await o(...n)}catch(i){t(i)}}}if(!e.subCommands||typeof e.subCommands!=="object")return;for(let o of Object.values(e.subCommands))if(o&&typeof o==="object")tr(o,t)}function Q(e){let t;return()=>t??=e().then((r)=>{let o=nb(r);return tr(o),o}).catch((r)=>{throw t=void 0,r})}function nb(e){let t={...e},r=t.subCommands;if(r&&typeof r==="object")t.subCommands=Object.fromEntries(Object.entries(r).map(([o,n])=>[o,n&&typeof n==="object"?nb(n):n]));return t}var Rt=S({meta:{name:"kuber",version:"2.6.1-rc2",description:"Docker Compose -> K8s translation layer"},args:{config:{type:"string",description:"Path to a kuber configuration file"}},subCommands:{audit:Q(()=>Promise.resolve().then(() => (lm(),{})).then((e)=>rv)),ci:Q(()=>Promise.resolve().then(() => (fy(),{})).then((e)=>mA)),db:Q(()=>Promise.resolve().then(() => (my(),{})).then((e)=>bA)),down:Q(()=>Promise.resolve().then(() => (hy(),{})).then((e)=>wA)),export:Q(()=>Promise.resolve().then(() => (by(),{})).then((e)=>SA)),exec:Q(()=>Promise.resolve().then(() => (xy(),{})).then((e)=>CA)),logs:Q(()=>Promise.resolve().then(() => (ky(),{})).then((e)=>OA)),maintenance:Q(()=>Promise.resolve().then(() => (Cy(),{})).then((e)=>UA)),login:Q(()=>Promise.resolve().then(() => (En(),{})).then((e)=>qA)),logout:Q(()=>Promise.resolve().then(() => (En(),{})).then((e)=>QA)),operations:Q(()=>Promise.resolve().then(() => (Ty(),{})).then((e)=>XA)),ps:Q(()=>Promise.resolve().then(() => (By(),{})).then((e)=>ok)),restart:Q(()=>Promise.resolve().then(() => (zy(),{})).then((e)=>ik)),rollback:Q(()=>Promise.resolve().then(() => (Dy(),{})).then((e)=>ak)),s3:Q(()=>Promise.resolve().then(() => (Ly(),{})).then((e)=>mk)),start:Q(()=>Promise.resolve().then(() => (Vy(),{})).then((e)=>hk)),stop:Q(()=>Promise.resolve().then(() => (Uy(),{})).then((e)=>yk)),up:Q(()=>Promise.resolve().then(() => (vn(),{})).then((e)=>lA)),users:Q(()=>Promise.resolve().then(() => (Wy(),{})).then((e)=>Bk)),trust:Q(()=>Promise.resolve().then(() => (Gy(),{})).then((e)=>Lk)),whoami:Q(()=>Promise.resolve().then(() => (En(),{})).then((e)=>WA))}}),ob;function ib(){return ob??=(async()=>{let e=Rt.subCommands;if(e&&typeof e!=="function")Rt.subCommands=Object.fromEntries(await Promise.all(Object.entries(e).map(async([r,o])=>[r,typeof o==="function"?await o():await o])));await Promise.resolve().then(() => rb());return tb(Rt)})(),ob}oe();Oo();async function qk(){let{configPath:e,rawArgs:t}=dm(process.argv.slice(2));if(t[0]==="fuck")t[0]="rollback";if(t.length===0||t[0]==="complete"||t[0]==="--help"||t[0]==="-h")await ib();tr(Rt);let r=xc(Rt),o=new Set(["login","logout","whoami","maintenance"]);if(t[0]&&o.has(t[0])){await r({rawArgs:t});return}await vm(()=>r({rawArgs:t}),e)}qk().catch((e)=>{console.error(Fs(e)),process.exitCode=1});
|