@aegis-engine/core 0.13.1 → 0.14.0
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/account.js +1 -1
- package/dist/aegis-core.js +26 -26
- package/dist/contract/generated/aegis-swap.d.ts +310 -5
- package/dist/contract/generated/market-data.d.ts +310 -5
- package/dist/engine/account/activitySchemas.d.ts +1 -0
- package/dist/engine/account/discoverySchemas.d.ts +101 -0
- package/dist/engine/account/portfolioSchemas.d.ts +2 -0
- package/dist/engine/account/transactionSchemas.d.ts +1 -0
- package/dist/engine/account/transport.d.ts +6 -0
- package/dist/engine/account/types.d.ts +1 -0
- package/dist/engine/dataSource.d.ts +4 -1
- package/dist/engine/sdkDeployment.d.ts +16 -0
- package/dist/engine/types.d.ts +4 -1
- package/dist/index.d.ts +2 -0
- package/dist/sdkRuntime-CvLRgf5w.js +1593 -0
- package/dist/transactionHistory-BGpe2c7k.js +149 -0
- package/package.json +2 -2
- package/dist/sdkRuntime-CMBWjHxv.js +0 -1593
- package/dist/transactionHistory-C8KRA_tE.js +0 -149
|
@@ -1,149 +0,0 @@
|
|
|
1
|
-
var hi=Object.defineProperty;var pi=(e,t,n)=>t in e?hi(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var ie=(e,t,n)=>pi(e,typeof t!="symbol"?t+"":t,n);import{zeroAddress as mi,WaitForTransactionReceiptTimeoutError as gi}from"viem";function bi(e,t){return`${e}:${t.toLowerCase()}`;}function Wr(e,t){return e.kind==="borrow_vault"?`engine-vault:${e.chainId}:${e.vaultRegistry.toLowerCase()}:${e.vaultId}`:`engine-lend:${e.chainId}:${e.engine.toLowerCase()}:${t.toLowerCase()}:${e.poolId.toLowerCase()}`;}const vi=/\{[^{}]+\}/g,wi=()=>{var e,t;return typeof process=="object"&&Number.parseInt((t=(e=process==null?void 0:process.versions)==null?void 0:e.node)==null?void 0:t.substring(0,2))>=18&&process.versions.undici;};function yi(){return Math.random().toString(36).slice(2,11);}function _i(e){let{baseUrl:t="",Request:n=globalThis.Request,fetch:r=globalThis.fetch,querySerializer:o,bodySerializer:i,pathSerializer:s,headers:a,requestInitExt:c=void 0,...l}={...e};c=wi()?c:void 0,t=Vn(t);const u=[];async function h(d,f){var Jn;const{baseUrl:m,fetch:v=r,Request:k=n,headers:_,params:y={},parseAs:x="json",querySerializer:A,bodySerializer:B=i??Ii,pathSerializer:C,body:P,middleware:R=[],...O}=f||{};let me=t;m&&(me=Vn(m)??t);let oe=typeof o=="function"?o:Hn(o);A&&(oe=typeof A=="function"?A:Hn({...(typeof o=="object"?o:{}),...A}));const Se=C||s||ki,J=P===void 0?void 0:B(P,// Note: we declare mergeHeaders() both here and below because it’s a bit of a chicken-or-egg situation:
|
|
2
|
-
// bodySerializer() needs all headers so we aren’t dropping ones set by the user, however,
|
|
3
|
-
// the result of this ALSO sets the lowest-priority content-type header. So we re-merge below,
|
|
4
|
-
// setting the content-type at the very beginning to be overwritten.
|
|
5
|
-
// Lastly, based on the way headers work, it’s not a simple “present-or-not” check becauase null intentionally un-sets headers.
|
|
6
|
-
Kn(a,_,y.header)),De=Kn(// with no body, we should not to set Content-Type
|
|
7
|
-
J===void 0||// if serialized body is FormData; browser will correctly set Content-Type & boundary expression
|
|
8
|
-
J instanceof FormData?{}:{"Content-Type":"application/json"},a,_,y.header),G=[...u,...R],Xe={redirect:"follow",...l,...O,body:J,headers:De};let yt,_t,ze=new k($i(d,{baseUrl:me,params:y,querySerializer:oe,pathSerializer:Se}),Xe),H;for(const X in O)X in ze||(ze[X]=O[X]);if(G.length){yt=yi(),_t=Object.freeze({baseUrl:me,fetch:v,parseAs:x,querySerializer:oe,bodySerializer:B,pathSerializer:Se});for(const X of G)if(X&&typeof X=="object"&&typeof X.onRequest=="function"){const K=await X.onRequest({request:ze,schemaPath:d,params:y,options:_t,id:yt});if(K)if(K instanceof k)ze=K;else if(K instanceof Response){H=K;break;}else throw new Error("onRequest: must return new Request() or Response() when modifying the request");}}if(!H){try{H=await v(ze,c);}catch(X){let K=X;if(G.length)for(let Ce=G.length-1;Ce>=0;Ce--){const kt=G[Ce];if(kt&&typeof kt=="object"&&typeof kt.onError=="function"){const Qe=await kt.onError({request:ze,error:K,schemaPath:d,params:y,options:_t,id:yt});if(Qe){if(Qe instanceof Response){K=void 0,H=Qe;break;}if(Qe instanceof Error){K=Qe;continue;}throw new Error("onError: must return new Response() or instance of Error");}}}if(K)throw K;}if(G.length)for(let X=G.length-1;X>=0;X--){const K=G[X];if(K&&typeof K=="object"&&typeof K.onResponse=="function"){const Ce=await K.onResponse({request:ze,response:H,schemaPath:d,params:y,options:_t,id:yt});if(Ce){if(!(Ce instanceof Response))throw new Error("onResponse: must return new Response() when modifying the response");H=Ce;}}}}const qn=H.headers.get("Content-Length");if(H.status===204||ze.method==="HEAD"||qn==="0"&&!((Jn=H.headers.get("Transfer-Encoding"))!=null&&Jn.includes("chunked")))return H.ok?{data:void 0,response:H}:{error:void 0,response:H};if(H.ok)return{data:await(async()=>{if(x==="stream")return H.body;if(x==="json"&&!qn){const K=await H.text();return K?JSON.parse(K):void 0;}return await H[x]();})(),response:H};let Xt=await H.text();try{Xt=JSON.parse(Xt);}catch{}return{error:Xt,response:H};}return{request(d,f,m){return h(f,{...m,method:d.toUpperCase()});},/** Call a GET endpoint */GET(d,f){return h(d,{...f,method:"GET"});},/** Call a PUT endpoint */PUT(d,f){return h(d,{...f,method:"PUT"});},/** Call a POST endpoint */POST(d,f){return h(d,{...f,method:"POST"});},/** Call a DELETE endpoint */DELETE(d,f){return h(d,{...f,method:"DELETE"});},/** Call a OPTIONS endpoint */OPTIONS(d,f){return h(d,{...f,method:"OPTIONS"});},/** Call a HEAD endpoint */HEAD(d,f){return h(d,{...f,method:"HEAD"});},/** Call a PATCH endpoint */PATCH(d,f){return h(d,{...f,method:"PATCH"});},/** Call a TRACE endpoint */TRACE(d,f){return h(d,{...f,method:"TRACE"});},/** Register middleware */use(...d){for(const f of d)if(f){if(typeof f!="object"||!("onRequest"in f||"onResponse"in f||"onError"in f))throw new Error("Middleware must be an object with one of `onRequest()`, `onResponse() or `onError()`");u.push(f);}},/** Unregister middleware */eject(...d){for(const f of d){const m=u.indexOf(f);m!==-1&&u.splice(m,1);}}};}function Bt(e,t,n){if(t==null)return"";if(typeof t=="object")throw new Error("Deeply-nested arrays/objects aren’t supported. Provide your own `querySerializer()` to handle these.");return`${e}=${(n==null?void 0:n.allowReserved)===!0?t:encodeURIComponent(t)}`;}function Gr(e,t,n){if(!t||typeof t!="object")return"";const r=[],o={simple:",",label:".",matrix:";"}[n.style]||"&";if(n.style!=="deepObject"&&n.explode===!1){for(const a in t)r.push(a,n.allowReserved===!0?t[a]:encodeURIComponent(t[a]));const s=r.join(",");switch(n.style){case"form":return`${e}=${s}`;case"label":return`.${s}`;case"matrix":return`;${e}=${s}`;default:return s;}}for(const s in t){const a=n.style==="deepObject"?`${e}[${s}]`:s;r.push(Bt(a,t[s],n));}const i=r.join(o);return n.style==="label"||n.style==="matrix"?`${o}${i}`:i;}function Xr(e,t,n){if(!Array.isArray(t))return"";if(n.explode===!1){const i={form:",",spaceDelimited:"%20",pipeDelimited:"|"}[n.style]||",",s=(n.allowReserved===!0?t:t.map(a=>encodeURIComponent(a))).join(i);switch(n.style){case"simple":return s;case"label":return`.${s}`;case"matrix":return`;${e}=${s}`;// case "spaceDelimited":
|
|
9
|
-
// case "pipeDelimited":
|
|
10
|
-
default:return`${e}=${s}`;}}const r={simple:",",label:".",matrix:";"}[n.style]||"&",o=[];for(const i of t)n.style==="simple"||n.style==="label"?o.push(n.allowReserved===!0?i:encodeURIComponent(i)):o.push(Bt(e,i,n));return n.style==="label"||n.style==="matrix"?`${r}${o.join(r)}`:o.join(r);}function Hn(e){return function(n){const r=[];if(n&&typeof n=="object")for(const o in n){const i=n[o];if(i!=null){if(Array.isArray(i)){if(i.length===0)continue;r.push(Xr(o,i,{style:"form",explode:!0,...(e==null?void 0:e.array),allowReserved:(e==null?void 0:e.allowReserved)||!1}));continue;}if(typeof i=="object"){r.push(Gr(o,i,{style:"deepObject",explode:!0,...(e==null?void 0:e.object),allowReserved:(e==null?void 0:e.allowReserved)||!1}));continue;}r.push(Bt(o,i,e));}}return r.join("&");};}function ki(e,t){let n=e;for(const r of e.match(vi)??[]){let o=r.substring(1,r.length-1),i=!1,s="simple";if(o.endsWith("*")&&(i=!0,o=o.substring(0,o.length-1)),o.startsWith(".")?(s="label",o=o.substring(1)):o.startsWith(";")&&(s="matrix",o=o.substring(1)),!t||t[o]===void 0||t[o]===null)continue;const a=t[o];if(Array.isArray(a)){n=n.replace(r,Xr(o,a,{style:s,explode:i}));continue;}if(typeof a=="object"){n=n.replace(r,Gr(o,a,{style:s,explode:i}));continue;}if(s==="matrix"){n=n.replace(r,`;${Bt(o,a)}`);continue;}n=n.replace(r,s==="label"?`.${encodeURIComponent(a)}`:encodeURIComponent(a));}return n;}function Ii(e,t){return e instanceof FormData?e:t&&(t.get instanceof Function?t.get("Content-Type")??t.get("content-type"):t["Content-Type"]??t["content-type"])==="application/x-www-form-urlencoded"?new URLSearchParams(e).toString():JSON.stringify(e);}function $i(e,t){var o;let n=`${t.baseUrl}${e}`;(o=t.params)!=null&&o.path&&(n=t.pathSerializer(n,t.params.path));let r=t.querySerializer(t.params.query??{});return r.startsWith("?")&&(r=r.substring(1)),r&&(n+=`?${r}`),n;}function Kn(...e){const t=new Headers();for(const n of e){if(!n||typeof n!="object")continue;const r=n instanceof Headers?n.entries():Object.entries(n);for(const[o,i]of r)if(i===null)t.delete(o);else if(Array.isArray(i))for(const s of i)t.append(o,s);else i!==void 0&&t.set(o,i);}return t;}function Vn(e){return e.endsWith("/")?e.substring(0,e.length-1):e;}function Qr(e){const t=e.signal,n=e.timeoutMs;if(n===void 0)return{signal:t,cleanup:()=>{}};const r=new AbortController(),o=setTimeout(()=>{r.abort(new DOMException(e.timeoutMessage,"TimeoutError"));},n);return{signal:t?AbortSignal.any([t,r.signal]):r.signal,cleanup:()=>clearTimeout(o)};}function ln(e){const t=Object.values(e).filter(r=>typeof r=="number");return Object.entries(e).filter(([r,o])=>t.indexOf(+r)===-1).map(([r,o])=>o);}function Wn(e,t="|"){return e.map(n=>ro(n)).join(t);}function dn(e,t){return typeof t=="bigint"?t.toString():t;}class Si{constructor(t){this._getter=t,this._value=void 0;}get value(){const t=this._getter;return t!==void 0&&(this._value=t(),this._getter=void 0),this._value;}}function qt(e){return new Si(e);}function zi(e){return e==null;}function An(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n);}function Ei(e,t){const n=e/t,r=Math.round(n),o=4*Number.EPSILON*Math.max(Math.abs(n),1);return Math.abs(n-r)<o?0:n-r;}function $e(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0});}function xn(e){const t=Object.getOwnPropertyDescriptor(e,"shape");return t!=null&&t.get?t.get.raw:t==null?void 0:t.value;}function ke(e){return xn(e._zod.def)??e._zod.def.shape;}function Yr(e,t,n){Object.defineProperty(e,t,{get(){const r=n();return $e(this,t,r),r;},enumerable:!0,configurable:!0});}function eo(e,t,n){t in e?$e(e,t,n):e[t]=n;}function je(e,t,n,r){const o=ke(t);for(const i of n){const s=Object.getOwnPropertyDescriptor(o,i);s.enumerable&&(s.get?Yr(e,i,()=>{const a=t._zod.def.shape[i];return r?r(a,i):a;}):eo(e,i,r?r(s.value,i):s.value));}}function Ai(e,t){for(const n of Reflect.ownKeys(t)){const r=Object.getOwnPropertyDescriptor(t,n);r.enumerable&&(r.get?Yr(e,n,()=>t[n]):eo(e,n,r.value));}}function ae(...e){const t={};for(const n of e){const r=Object.getOwnPropertyDescriptors(n);Object.assign(t,r);}return Object.defineProperties({},t);}function xi(e){return JSON.stringify(e);}function Ri(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"");}const to="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function ht(e){return typeof e=="object"&&e!==null&&!Array.isArray(e);}const Oi=/* @__PURE__ */qt(()=>{var e;if(le.jitless||typeof navigator<"u"&&(e=navigator==null?void 0:navigator.userAgent)!=null&&e.includes("Cloudflare"))return!1;try{const t=Function;return new t(""),!0;}catch{return!1;}});function Je(e){if(ht(e)===!1)return!1;const t=e.constructor;if(t===void 0||typeof t!="function")return!0;const n=t.prototype;return!(ht(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1);}function no(e){return Je(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e;}const Pi=/* @__PURE__ */new Set(["string","number","symbol"]);function He(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");}function Pe(e,t,n){const r=new e._zod.constr(t??e._zod.def);return(!t||n!=null&&n.parent)&&(r._zod.parent=e),r;}function I(e){const t=e;if(!t)return{};if(typeof t=="string")return{error:()=>t};if((t==null?void 0:t.message)!==void 0){if((t==null?void 0:t.error)!==void 0)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message;}return delete t.message,typeof t.error=="string"?{...t,error:()=>t.error}:t;}function ro(e){return typeof e=="bigint"?e.toString()+"n":typeof e=="string"?`"${e}"`:`${e}`;}function Ti(e){return Object.keys(e).filter(t=>e[t]._zod.optin!==void 0&&e[t]._zod.optout==="optional");}const oo={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},Ci={int64:[/* @__PURE__ */BigInt("-9223372036854775808"),/* @__PURE__ */BigInt("9223372036854775807")],uint64:[/* @__PURE__ */BigInt(0),/* @__PURE__ */BigInt("18446744073709551615")]};function Ni(e,t){const n=e._zod.def,r=n.checks;if(r&&r.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");const i={};return je(i,e,Jt(e,t)),Pe(e,ae(n,{shape:i,checks:[]}));}function Jt(e,t){var o;const n=ke(e),r=[];for(const i of Reflect.ownKeys(t)){if(!((o=Object.getOwnPropertyDescriptor(n,i))!=null&&o.enumerable))throw new Error(`Unrecognized key: "${String(i)}"`);t[i]&&r.push(i);}return r;}function Zi(e,t){const n=e._zod.def,r=n.checks;if(r&&r.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");const i=new Set(Jt(e,t)),s={};return je(s,e,Reflect.ownKeys(ke(e)).filter(a=>!i.has(a))),Pe(e,ae(n,{shape:s,checks:[]}));}function ji(e,t){if(!Je(t))throw new Error("Invalid input to extend: expected a plain object");const n=e._zod.def.checks;if(n&&n.length>0){const o=ke(e);for(const i of Reflect.ownKeys(t))if(Object.getOwnPropertyDescriptor(o,i)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.");}return Pe(e,ae(e._zod.def,{shape:io(e,t)}));}function io(e,t){const n={};return je(n,e,Reflect.ownKeys(ke(e))),Ai(n,t),n;}function Di(e,t){if(!Je(t))throw new Error("Invalid input to safeExtend: expected a plain object");return Pe(e,ae(e._zod.def,{shape:io(e,t)}));}function Li(e,t){var o,i;if(!((o=t==null?void 0:t._zod)!=null&&o.def))throw new Error("Invalid input to merge: expected an object schema. To merge a plain shape, use `.extend()`.");if((i=e._zod.def.checks)!=null&&i.length)throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");const n={};je(n,e,Reflect.ownKeys(ke(e))),je(n,t,Reflect.ownKeys(ke(t)));const r=ae(e._zod.def,{shape:n,get catchall(){return t._zod.def.catchall;},checks:t._zod.def.checks??[]});return Pe(e,r);}function Gn(e,t,n,r="partial"){const i=t._zod.def.checks;if(i&&i.length>0)throw new Error(`.${r}() cannot be used on object schemas containing refinements`);const a=n?new Set(Jt(t,n)):void 0,c={};return je(c,t,Reflect.ownKeys(ke(t)),e&&((l,u)=>a&&!a.has(u)?l:new e({type:"optional",innerType:l}))),Pe(t,ae(t._zod.def,{shape:c,checks:[]}));}function Ui(e,t,n){const r=n?new Set(Jt(t,n)):void 0,o={};return je(o,t,Reflect.ownKeys(ke(t)),(i,s)=>// overwrite with non-optional
|
|
11
|
-
r&&!r.has(s)?i:new e({type:"nonoptional",innerType:i})),Pe(t,ae(t._zod.def,{shape:o}));}function he(e,t=0){var n;if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(((n=e.issues[r])==null?void 0:n.continue)!==!0)return!0;return!1;}function Fi(e,t=0){var n;if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(((n=e.issues[r])==null?void 0:n.continue)===!1)return!0;return!1;}function Ae(e,t){return t.map(n=>{var r;return(r=n).path??(r.path=[]),n.path.unshift(e),n;});}function Ye(e){return typeof e=="string"?e:e==null?void 0:e.message;}function Xn(e){const t=[];for(const n of e??[]){const r=n._zod.def;if(!/_(length|size)$|_equals$/.test(r.check))break;const o=r.maximum??r.length??r.size;o>=0&&t.push([o,n]);}return t;}function fn(e,t,n){var r;for(let o=t;o<e.length;o++)(r=e[o]).schema??(r.schema=n);}function xe(e,t,n){var c,l,u,h,d,f,m,v,k,_;var r;const o=(l=(c=e.inst)==null?void 0:c._zod)==null?void 0:l.traits;o!=null&&o.has("$ZodType")&&(o.has("$ZodCheck")?(r=e).schema??(r.schema=e.inst):e.schema=e.inst);const i=e.schema!==e.inst?(h=(u=e.schema)==null?void 0:u._zod.def)==null?void 0:h.error:void 0,s=e.message?e.message:Ye((m=(f=(d=e.inst)==null?void 0:d._zod.def)==null?void 0:f.error)==null?void 0:m.call(f,e))??Ye(i==null?void 0:i(e))??Ye((v=t==null?void 0:t.error)==null?void 0:v.call(t,e))??Ye((k=n.customError)==null?void 0:k.call(n,e))??Ye((_=n.localeError)==null?void 0:_.call(n,e))??"Invalid input",a={};for(const y of Object.keys(e))y==="inst"||y==="schema"||y==="continue"||y==="input"||y==="__proto__"||(a[y]=e[y]);return a.path??(a.path=[]),a.message=s,t!=null&&t.reportInput&&(a.input=e.input),a;}const Mi=/[\uD800-\uDBFF]/;function Rn(e){const t=e.length;if(!Mi.test(e))return t;let n=t;for(let r=0;r<t-1;r++)(e.charCodeAt(r)&64512)===55296&&(e.charCodeAt(r+1)&64512)===56320&&(n--,r++);return n;}function On(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown";}function Bi(e){const 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";const n=e;if(n&&Object.getPrototypeOf(n)!==Object.prototype&&"constructor"in n&&n.constructor)return n.constructor.name;}}return t;}function pt(...e){const[t,n,r]=e;return typeof t=="string"?{message:t,code:"custom",input:n,inst:r}:{...t};}function qi(e,t){for(const n in t){const r=Object.getOwnPropertyDescriptor(t,n);r.get?Object.defineProperty(e,n,{...r,enumerable:!1}):Ji(e,n,r.value);}}function Re(e,t,n,r=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:r,value:n}),n;}function so(e,t,n){return Re(e,t,n,!1);}function ao(e,t){for(const n in e){const r=e[n];Object.defineProperty(t,n,{configurable:!0,enumerable:!0,get(){return Re(this,n,r(this));},set(o){Re(this,n,o);}});}return t;}function Ji(e,t,n){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?n:Re(this,t,n.bind(this));},set(r){Re(this,t,r);}});}function Hi(e,t){const n=Object.getPrototypeOf(e);return t in n?void 0:n;}let Qt,Ee=!1;const Ki={configurable:!0,get(){Ee=!0;}};function T(e,t,n){const r=Object.getPrototypeOf(e._zod);if(t in r&&Qt!==e._zod){Qt=void 0;return;}Qt=e._zod,Object.defineProperty(r,t,{configurable:!0,get(){Object.defineProperty(this,t,Ki);const o=Ee;Ee=!1;try{const i=n(this);return Ee?delete this[t]:Object.defineProperty(this,t,{configurable:!0,writable:!0,value:i}),Ee=Ee||o,i;}catch(i){throw delete this[t],Ee=Ee||o,i;}},set(o){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:o});}});}function Vi(e,t,n,r){const o=Hi(e,t);o&&Object.defineProperty(o,t,{configurable:!0,get(){const i={configurable:!0,writable:!0,enumerable:r,value:void 0};return Object.defineProperty(this,t,i),i.value=n(this),Object.defineProperty(this,t,i),i.value;},set(i){Object.defineProperty(this,t,{configurable:!0,writable:!0,enumerable:r,value:i});}});}const Wi="~constantCatch";function Gi(e){const t=()=>e;return t[Wi]=!0,t;}var Qn;const Yt={value:void 0,enumerable:!1};let Yn="captureStackTrace"in Error?Error:null;function Xi(e){const t=Yn;if(t){const n=t.stackTraceLimit;if(typeof n=="number"){try{t.stackTraceLimit=0;}catch{return Yn=null,new e();}try{return new e();}finally{t.stackTraceLimit=n;}}}return new e();}function g(e,t,n,r){const o={};function i(d){this.def=d,this.constr=h,this.traits=/* @__PURE__ */new Set();}i.prototype=o;const s=n,a=s&&/* @__PURE__ */new WeakSet();function c(d,f){if(d._zod){if(d._zod.traits.has(e))return;}else{Yt.value=new i(f);try{Object.defineProperty(d,"_zod",Yt);}finally{Yt.value=void 0;}}if(d._zod.traits.add(e),t(d,f),a){const v=Object.getPrototypeOf(d),k=d._zod.constr.prototype;let _=v;for(;_&&_!==k;)_=Object.getPrototypeOf(_);const y=_??v;a.has(y)||(a.add(y),qi(y,s));}const m=h.prototype;for(const v in m)Object.prototype.hasOwnProperty.call(m,v)&&(v in d||(d[v]=m[v].bind(d)));}const l=(r==null?void 0:r.Parent)??Object;class u extends l{}Object.defineProperty(u,"name",{value:e});function h(d){var k;const f=r!=null&&r.Parent?Xi(u):this;c(f,d);const m=f._zod.deferred;if(m){for(const _ of m)_();f._zod.deferred=void 0;}const v=(k=globalThis.__zod_globalConfig)==null?void 0:k.postProcessor;return v&&v(f),f;}return Object.defineProperty(h,"init",{value:c}),Object.defineProperty(h,Symbol.hasInstance,{value:d=>{var f,m;return r!=null&&r.Parent&&d instanceof r.Parent?!0:(m=(f=d==null?void 0:d._zod)==null?void 0:f.traits)==null?void 0:m.has(e);}}),Object.defineProperty(h,"name",{value:e}),h;}class Ze extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.");}}class co extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError";}}(Qn=globalThis).__zod_globalConfig??(Qn.__zod_globalConfig={});const le=globalThis.__zod_globalConfig;function ge(e){return e&&Object.assign(le,e),le;}function Qi(){const e=this._zod;return e.message??(e.message=JSON.stringify(e.def,dn,2)),e.message;}function Yi(e){this._zod.message=e;}const es={get:Qi,set:Yi,enumerable:!0,configurable:!0},en={value:void 0,enumerable:!1},er=/* @__PURE__ */new WeakSet([Object.prototype,Error.prototype]),ts=(e,t)=>{e.name="$ZodError",en.value=t,Object.defineProperty(e,"issues",en),en.value=void 0,Object.defineProperty(e,"message",es);const n=Object.getPrototypeOf(e);er.has(n)||(er.add(n),Object.defineProperty(n,"toString",{configurable:!0,enumerable:!1,get(){const r=()=>this.message;return Object.defineProperty(this,"toString",{value:r,configurable:!0,writable:!0}),r;},set(r){Object.defineProperty(this,"toString",{value:r,configurable:!0,writable:!0});}}));},ns=g("$ZodError",ts);function rs(e,t,n){return Object.prototype.hasOwnProperty.call(e,t)||(t==="__proto__"?Object.defineProperty(e,t,{value:n(),writable:!0,enumerable:!0,configurable:!0}):e[t]=n()),e[t];}function os(e,t=n=>n.message){const n={},r=[];for(const o of e.issues)o.path.length>0?rs(n,o.path[0],()=>[]).push(t(o)):r.push(t(o));return{formErrors:r,fieldErrors:n};}function is(e,t=n=>n.message){const n={_errors:[]},r=(o,i=[])=>{for(const s of o.issues)if(s.code==="invalid_union"&&s.errors.length)s.errors.map(a=>r({issues:a},[...i,...s.path]));else if(s.code==="invalid_key")r({issues:s.issues},[...i,...s.path]);else if(s.code==="invalid_element")r({issues:s.issues},[...i,...s.path]);else{const a=[...i,...s.path];if(a.length===0)n._errors.push(t(s));else{let c=n,l=0;for(;l<a.length;){const u=a[l],h=l===a.length-1;if(u==="_errors"){h&&c._errors.push(t(s)),l++;continue;}Object.prototype.hasOwnProperty.call(c,u)||Object.defineProperty(c,u,{value:{_errors:[]},enumerable:!0,writable:!0,configurable:!0});const d=c[u];h&&d._errors.push(t(s)),c=d,l++;}}}};return r(e),n;}function Ht(e,t){return{callee:(t==null?void 0:t.callee)??e,Err:t==null?void 0:t.Err};}const Pn=e=>{const t=(n,r,o,i)=>{const s=o?{...o,async:!1}:{async:!1},a=n._zod.run({value:r,issues:[]},s);if(a instanceof Promise)throw new Ze();if(a.issues.length){const c=new((i==null?void 0:i.Err)??e)(a.issues.map(l=>xe(l,s,ge())));throw to(c,(i==null?void 0:i.callee)??t),c;}return a.value;};return t;},Tn=e=>{const t=async(n,r,o,i)=>{const s=o?{...o,async:!0}:{async:!0};let a=n._zod.run({value:r,issues:[]},s);if(a instanceof Promise&&(a=await a),a.issues.length){const c=new((i==null?void 0:i.Err)??e)(a.issues.map(l=>xe(l,s,ge())));throw to(c,(i==null?void 0:i.callee)??t),c;}return a.value;};return t;},Cn=e=>(t,n,r)=>{const o=r?{...r,async:!1}:{async:!1},i=t._zod.run({value:n,issues:[]},o);if(i instanceof Promise)throw new Ze();return i.issues.length?uo(e,i.issues,o):{success:!0,data:i.value};};function uo(e,t,n){let r;return{success:!1,get error(){return r||(r=new e(t.map(o=>xe(o,n,ge()))),t=void 0,n=void 0),r;},set error(o){r=o,t=void 0,n=void 0;}};}const Nn=e=>async(t,n,r)=>{const o=r?{...r,async:!0}:{async:!0};let i=t._zod.run({value:n,issues:[]},o);return i instanceof Promise&&(i=await i),i.issues.length?uo(e,i.issues,o):{success:!0,data:i.value};},ss=/* @__PURE__ */Symbol.for("zod.compile.invalid"),as=/* @__PURE__ */Symbol.for("zod.compile.fallback"),cs=(e,t,n)=>{const r=e._zod.bag.validator;if(r!==void 0){if(r(t)!==ss)return!0;if(r.definite===!0&&n===void 0)return!1;}return us(e,t,n);};function us(e,t,n){const r=n?{...n,async:!1,abortEarly:!0}:{async:!1,abortEarly:!0},o=e._zod.bag.fallbackRun;let i;if(o?(r[as]=!0,i=o({value:t,issues:[]},r)):i=e._zod.run({value:t,issues:[]},r),i instanceof Promise)throw new Ze();return i.issues.length===0;}const ls=async(e,t,n)=>{const r=n?{...n,async:!0,abortEarly:!0}:{async:!0,abortEarly:!0};let o=e._zod.run({value:t,issues:[]},r);return o instanceof Promise&&(o=await o),o.issues.length===0;},ds=e=>{const t=Pn(e),n=(r,o,i,s)=>{const a=i?{...i,direction:"backward"}:{direction:"backward"};return t(r,o,a,Ht(n,s));};return n;},fs=e=>{const t=Pn(e),n=(r,o,i,s)=>t(r,o,i,Ht(n,s));return n;},hs=e=>{const t=Tn(e),n=async(r,o,i,s)=>{const a=i?{...i,direction:"backward"}:{direction:"backward"};return await t(r,o,a,Ht(n,s));};return n;},ps=e=>{const t=Tn(e),n=async(r,o,i,s)=>await t(r,o,i,Ht(n,s));return n;},ms=e=>(t,n,r)=>{const o=r?{...r,direction:"backward"}:{direction:"backward"};return Cn(e)(t,n,o);},gs=e=>(t,n,r)=>Cn(e)(t,n,r),bs=e=>async(t,n,r)=>{const o=r?{...r,direction:"backward"}:{direction:"backward"};return Nn(e)(t,n,o);},vs=e=>async(t,n,r)=>Nn(e)(t,n,r),ws=/^[cC][0-9a-z]{6,}$/,ys=/^[0-9a-z]+$/,_s=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,ks=/^[0-9a-vA-V]{20}$/,Is=/^[A-Za-z0-9]{27}$/,$s=/^[a-zA-Z0-9_-]{21}$/;function Ss(e){return new RegExp(`^[a-zA-Z0-9_-]{${e}}$`);}const zs=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Es=/^([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})$/,tr=e=>e?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})$`):/^([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)$/,As=/^(?:[A-Za-z0-9_'+\-]+\.)*[A-Za-z0-9_'+\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,xs="^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$";function Rs(){return new RegExp(xs,"u");}const Os=/^(?:(?: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])$/,Ps=/^(([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}|:))$/,Ts=/^((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])$/,Cs=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Ns=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Zs=/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/,js=/^https?$/,Ds=/^\+[1-9]\d{6,14}$/,lo="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))";function Ls(e){return new RegExp(`^${e}$`);}const Us=/* @__PURE__ */Ls(lo);function hn(e){const t="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof e.precision=="number"?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:e.seconds?`${t}:[0-5]\\d(?:\\.\\d+)?`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`;}function Fs(e){return new RegExp(`^${hn(e)}$`);}function Ms(e){const t=["Z"];e.offset&&t.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const n=`${hn({precision:e.precision,seconds:!0})}(?:${t.join("|")})`,r=e.local?`${n}|${hn({precision:e.precision})}`:n;return new RegExp(`^${lo}T(?:${r})$`);}const Bs=/^[\s\S]{0,}$/,qs=/^-?\d+$/,Zn=/^-?\d+(?:\.\d+)?$/,Js=/^(?:true|false)$/i,Hs=/^null$/i,Ks=/^[^A-Z]*$/,Vs=/^[^a-z]*$/,re=/* @__PURE__ */g("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[]);}),jn=e=>{const t=e.value;return!zi(t)&&t.length!==void 0;},Tt={number:"number",bigint:"bigint",object:"date"},fo=/* @__PURE__ */g("$ZodCheckLessThan",(e,t)=>{re.init(e,t);const n=Tt[typeof t.value];e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:Tt[typeof r.value]??n,code:"too_big",maximum:typeof t.value=="object"?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort});};}),ho=/* @__PURE__ */g("$ZodCheckGreaterThan",(e,t)=>{re.init(e,t);const n=Tt[typeof t.value];e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:Tt[typeof r.value]??n,code:"too_small",minimum:typeof t.value=="object"?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort});};}),Ws=/* @__PURE__ */g("$ZodCheckMultipleOf",(e,t)=>{re.init(e,t),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof n.value=="bigint"?// `value % 0n` throws, and nothing is a multiple of zero — the number branch already fails this way via NaN
|
|
12
|
-
t.value!==BigInt(0)&&n.value%t.value===BigInt(0):Ei(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:"not_multiple_of",divisor:t.value,input:n.value,inst:e,continue:!t.abort});};}),Gs=/* @__PURE__ */g("$ZodCheckNumberFormat",(e,t)=>{var s;re.init(e,t),t.format=t.format||"float64";const n=(s=t.format)==null?void 0:s.includes("int"),r=n?"int":"number",[o,i]=oo[t.format];e._zod.check=a=>{const c=a.value;if(n){if(!Number.isInteger(c)){a.issues.push({expected:r,format:t.format,code:"invalid_type",continue:!1,input:c,inst:e});return;}if(!Number.isSafeInteger(c)){c>0?a.issues.push({input:c,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,inclusive:!0,continue:!t.abort}):a.issues.push({input:c,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,inclusive:!0,continue:!t.abort});return;}}c<o&&a.issues.push({origin:"number",input:c,code:"too_small",minimum:o,inclusive:!0,inst:e,continue:!t.abort}),c>i&&a.issues.push({origin:"number",input:c,code:"too_big",maximum:i,inclusive:!0,inst:e,continue:!t.abort});};}),Xs=/* @__PURE__ */g("$ZodCheckMaxLength",(e,t)=>{var n;re.init(e,t),(n=e._zod.def).when??(n.when=jn),e._zod.check=r=>{const o=r.value,i=o.length;if((typeof o=="string"&&i>t.maximum?Rn(o):i)<=t.maximum)return;const a=On(o);r.issues.push({origin:a,code:"too_big",maximum:t.maximum,inclusive:!0,input:o,inst:e,continue:!t.abort});};}),Qs=/* @__PURE__ */g("$ZodCheckMinLength",(e,t)=>{var n;re.init(e,t),(n=e._zod.def).when??(n.when=jn),e._zod.check=r=>{const o=r.value,i=o.length;if((typeof o=="string"&&i>=t.minimum&&i<t.minimum*2?Rn(o):i)>=t.minimum)return;const a=On(o);r.issues.push({origin:a,code:"too_small",minimum:t.minimum,inclusive:!0,input:o,inst:e,continue:!t.abort});};}),Ys=/* @__PURE__ */g("$ZodCheckLengthEquals",(e,t)=>{var n;re.init(e,t),(n=e._zod.def).when??(n.when=jn),e._zod.check=r=>{const o=r.value,i=o.length,s=typeof o=="string"&&i>=t.length&&i<=t.length*2?Rn(o):i;if(s===t.length)return;const a=On(o),c=s>t.length;r.issues.push({origin:a,...(c?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length}),inclusive:!0,exact:!0,input:r.value,inst:e,continue:!t.abort});};}),Kt=/* @__PURE__ */g("$ZodCheckStringFormat",(e,t)=>{var n,r;re.init(e,t),t.pattern?(n=e._zod).check??(n.check=o=>{t.pattern.lastIndex=0,!t.pattern.test(o.value)&&o.issues.push({origin:"string",code:"invalid_format",format:t.format,input:o.value,...(t.pattern?{pattern:t.pattern.toString()}:{}),inst:e,continue:!t.abort});}):(r=e._zod).check??(r.check=()=>{});}),ea=/* @__PURE__ */g("$ZodCheckRegex",(e,t)=>{Kt.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:"string",code:"invalid_format",format:"regex",input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort});};}),ta=/* @__PURE__ */g("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=Ks),Kt.init(e,t);}),na=/* @__PURE__ */g("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=Vs),Kt.init(e,t);}),ra=/* @__PURE__ */g("$ZodCheckIncludes",(e,t)=>{re.init(e,t);const n=He(t.includes),r=new RegExp(typeof t.position=="number"?`^.{${t.position},}${n}`:n);t.pattern=r,e._zod.check=o=>{o.value.includes(t.includes,t.position)||o.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:o.value,inst:e,continue:!t.abort});};}),oa=/* @__PURE__ */g("$ZodCheckStartsWith",(e,t)=>{re.init(e,t);const n=new RegExp(`^${He(t.prefix)}.*`);t.pattern??(t.pattern=n),e._zod.check=r=>{r.value.startsWith(t.prefix)||r.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:r.value,inst:e,continue:!t.abort});};}),ia=/* @__PURE__ */g("$ZodCheckEndsWith",(e,t)=>{re.init(e,t);const n=new RegExp(`.*${He(t.suffix)}$`);t.pattern??(t.pattern=n),e._zod.check=r=>{r.value.endsWith(t.suffix)||r.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:r.value,inst:e,continue:!t.abort});};}),sa=/* @__PURE__ */g("$ZodCheckOverwrite",(e,t)=>{re.init(e,t),e._zod.check=n=>{n.value=t.tx(n.value);};});class aa{constructor(t=[],n={}){this.content=[],this.indent=0,this.args=t,this.closed=n;}// the compiler catches a child's throw and keeps writing into this doc, so the indent has to unwind with it
|
|
13
|
-
indented(t){this.indent+=1;try{t(this);}finally{this.indent-=1;}}write(t){if(typeof t=="function"){t(this,{execution:"sync"}),t(this,{execution:"async"});return;}const r=t.split(`
|
|
14
|
-
`).filter(s=>s),o=Math.min(...r.map(s=>s.length-s.trimStart().length)),i=r.map(s=>s.slice(o)).map(s=>" ".repeat(this.indent*2)+s);for(const s of i)this.content.push(s);}compile(){const t=Function,n=(this==null?void 0:this.content)??[""];return new t(...Object.keys(this.closed),`return function (${this.args.join(", ")}) {
|
|
15
|
-
${n.join(`
|
|
16
|
-
`)}
|
|
17
|
-
};`)(...Object.values(this.closed));}}const ca={major:4,minor:6,patch:7},Z=/* @__PURE__ */g("$ZodType",(e,t)=>{var i;var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=ca;const r=e._zod.def.checks,o=e._zod.traits.has("$ZodCheck")?[e,...(r??[])]:r!=null&&r.length?[...r]:[];for(const s of o)for(const a of s._zod.onattach)a(e);if(o.length===0)(n=e._zod).deferred??(n.deferred=[]),(i=e._zod.deferred)==null||i.push(()=>{e._zod.run=e._zod.parse;});else{const s=(c,l,u)=>{if(c.memo)return c;let h=he(c),d;for(const f of l){if(f._zod.def.when){if(Fi(c)||!f._zod.def.when(c))continue;}else if(h)continue;const m=c.issues.length,v=f._zod.check(c);if(v instanceof Promise&&(u==null?void 0:u.async)===!1)throw new Ze();if(d||v instanceof Promise)d=(d??Promise.resolve()).then(async()=>{await v,c.issues.length!==m&&(fn(c.issues,m,e),h||(h=he(c,m)));});else{if(c.issues.length===m)continue;fn(c.issues,m,e),h||(h=he(c,m));}}return d?d.then(()=>c):c;},a=(c,l,u)=>{if(he(c))return c.aborted=!0,c;const h=s(l,o,u);if(h instanceof Promise){if(u.async===!1)throw new Ze();return h.then(d=>e._zod.parse(d,u));}return e._zod.parse(h,u);};e._zod.run=(c,l)=>{if(l.skipChecks)return e._zod.parse(c,l);if(l.direction==="backward"){const h=e._zod.parse({value:c.value,issues:[]},{...l,skipChecks:!0});return h instanceof Promise?h.then(d=>a(d,c,l)):a(h,c,l);}const u=e._zod.parse(c,l);if(u instanceof Promise){if(l.async===!1)throw new Ze();return u.then(h=>s(h,o,l));}return s(u,o,l);};}},{// Wrappers extend this by installing a richer factory over it; reading it eagerly would defeat the laziness.
|
|
18
|
-
get"~standard"(){return so(this,"~standard",mo(this));},set"~standard"(e){Re(this,"~standard",e);}}),po=(e,t)=>e.issues.length?{issues:e.issues.map(n=>xe(n,t,ge()))}:{value:e.value};async function ua(e,t){const n={async:!0};return po(await e._zod.run({value:t,issues:[]},n),n);}function mo(e){return{validate:t=>{const n={async:!1};try{const r=e._zod.run({value:t,issues:[]},n);if(!(r instanceof Promise))return po(r,n);}catch{}return ua(e,t);},vendor:"zod",version:1};}const Dn=/* @__PURE__ */g("$ZodString",(e,t)=>{Z.init(e,t),e._zod.pattern=t.pattern??Bs,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=String(n.value);}catch{}return typeof n.value=="string"||n.issues.push({expected:"string",code:"invalid_type",input:n.value,inst:e}),n;};}),D=/* @__PURE__ */g("$ZodStringFormat",(e,t)=>{Kt.init(e,t),Dn.init(e,t);}),la=/* @__PURE__ */g("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=Es),D.init(e,t);}),da=/* @__PURE__ */g("$ZodUUID",(e,t)=>{if(t.version){const r={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(r===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=tr(r));}else t.pattern??(t.pattern=tr());D.init(e,t);}),fa=/* @__PURE__ */g("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=As),D.init(e,t);}),go=1,Ct=2;function bo(e){try{return typeof URL<"u"&&typeof URL.canParse=="function"?URL.canParse(e):(new URL(e),!0);}catch{return!1;}}function ha(e,t){return!("normalize"in t)&&!("hostname"in t)&&!("protocol"in t)?bo(e)||Ct:pa(e,t);}function pa(e,t){var n;if(!t.normalize&&((n=t.protocol)==null?void 0:n.source)===js.source&&!/^https?:\/\//i.test(e))return go;try{if(typeof URL<"u"){const r=URL;if(typeof r.parse=="function")return r.parse(e)??Ct;}return new URL(e);}catch{return Ct;}}const ma=/[\t\n\r]/g;function nr(e){return e.replace(ma,"");}function ga(e,t){return t.lastIndex=0,t.test(e.hostname);}function ba(e,t){return t.lastIndex=0,t.test(e.protocol.endsWith(":")?e.protocol.slice(0,-1):e.protocol);}const va=/* @__PURE__ */g("$ZodURL",(e,t)=>{D.init(e,t),e._zod.check=n=>{try{const r=n.value.trim(),o=ha(r,t);if(o===go){n.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:n.value,inst:e,continue:!t.abort});return;}if(o===Ct){n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort});return;}if(o===!0){n.value=nr(r);return;}t.hostname&&!ga(o,t.hostname)&&n.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort}),t.protocol&&!ba(o,t.protocol)&&n.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort}),n.value=t.normalize?o.href:nr(r);return;}catch{n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort});}};}),wa=/* @__PURE__ */g("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=Rs()),D.init(e,t);}),ya=/* @__PURE__ */g("$ZodNanoID",(e,t)=>{if(t.length!==void 0&&(!Number.isInteger(t.length)||t.length<1))throw new Error(`Invalid nanoid length: ${t.length}`);t.pattern??(t.pattern=t.length===void 0?$s:Ss(t.length)),D.init(e,t);}),_a=/* @__PURE__ */g("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=ws),D.init(e,t);}),ka=/* @__PURE__ */g("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=ys),D.init(e,t);}),Ia=/* @__PURE__ */g("$ZodULID",(e,t)=>{t.pattern??(t.pattern=_s),D.init(e,t);}),$a=/* @__PURE__ */g("$ZodXID",(e,t)=>{t.pattern??(t.pattern=ks),D.init(e,t);}),Sa=/* @__PURE__ */g("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=Is),D.init(e,t);}),za=/* @__PURE__ */g("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=Ms(t)),D.init(e,t);}),Ea=/* @__PURE__ */g("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=Us),D.init(e,t);}),Aa=/* @__PURE__ */g("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=Fs(t)),D.init(e,t);}),xa=/* @__PURE__ */g("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=zs),D.init(e,t);}),Ra=/* @__PURE__ */g("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=Os),D.init(e,t);}),Oa=/^[0-9a-fA-F:.]+$/;function vo(e){return Oa.test(e)?bo(`http://[${e}]`):!1;}const Pa=/* @__PURE__ */g("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=Ps),D.init(e,t),e._zod.check=n=>{vo(n.value)||n.issues.push({code:"invalid_format",format:"ipv6",input:n.value,inst:e,continue:!t.abort});};}),Ta=/* @__PURE__ */g("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=Ts),D.init(e,t);});function Ca(e){const t=e.split("/");if(t.length!==2)return!1;const[n,r]=t;if(!r)return!1;const o=Number(r);return`${o}`!==r||o<0||o>128?!1:vo(n);}const Na=/* @__PURE__ */g("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=Cs),D.init(e,t),e._zod.check=n=>{Ca(n.value)||n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:e,continue:!t.abort});};});function wo(e){if(e==="")return!0;if(/\s/.test(e)||e.length%4!==0)return!1;try{return atob(e),!0;}catch{return!1;}}const yo=/^[0-9a-zA-Z+/]*={0,2}$/,Za=/* @__PURE__ */g("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=yo),D.init(e,t),e._zod.check=n=>{wo(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort});};}),Ln=/^[A-Za-z0-9_-]*$/;function ja(e){if(!Ln.test(e))return!1;const t=e.replace(/[-_]/g,r=>r==="-"?"+":"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"=");return wo(n);}const Da=/* @__PURE__ */g("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=Ln),D.init(e,t),e._zod.check=n=>{ja(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort});};}),La=/* @__PURE__ */g("$ZodE164",(e,t)=>{t.pattern??(t.pattern=Ds),D.init(e,t);});function Ua(e,t=null){try{const n=e.split(".");if(n.length!==3)return!1;const[r]=n;if(!r)return!1;const o=JSON.parse(atob(r));return!("typ"in o&&(o==null?void 0:o.typ)!=="JWT"||!o.alg||t&&(!("alg"in o)||o.alg!==t));}catch{return!1;}}const Fa=/* @__PURE__ */g("$ZodJWT",(e,t)=>{D.init(e,t),e._zod.check=n=>{Ua(n.value,t.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort});};}),_o=/* @__PURE__ */g("$ZodNumber",(e,t)=>{Z.init(e,t),e._zod.pattern=Zn,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value);}catch{}const o=n.value;if(typeof o=="number"&&!Number.isNaN(o)&&Number.isFinite(o))return n;const i=typeof o=="number"?Number.isNaN(o)?"NaN":Number.isFinite(o)?void 0:String(o):void 0;return n.issues.push({expected:"number",code:"invalid_type",input:o,inst:e,...(i?{received:i}:{})}),n;};}),Ma=/* @__PURE__ */g("$ZodNumberFormat",(e,t)=>{Gs.init(e,t),_o.init(e,t);}),Ba=/* @__PURE__ */g("$ZodBoolean",(e,t)=>{Z.init(e,t),e._zod.pattern=Js,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=!!n.value;}catch{}const o=n.value;return typeof o=="boolean"||n.issues.push({expected:"boolean",code:"invalid_type",input:o,inst:e}),n;};}),qa=/* @__PURE__ */g("$ZodNull",(e,t)=>{Z.init(e,t),e._zod.pattern=Hs,e._zod.values=/* @__PURE__ */new Set([null]),e._zod.parse=(n,r)=>{const o=n.value;return o===null||n.issues.push({expected:"null",code:"invalid_type",input:o,inst:e}),n;};}),Ja=/* @__PURE__ */g("$ZodUnknown",(e,t)=>{Z.init(e,t),e._zod.parse=n=>n;}),Ha=/* @__PURE__ */g("$ZodNever",(e,t)=>{Z.init(e,t),e._zod.parse=(n,r)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:e}),n);});function Ka(e,t){const n=Xn(e._zod.def.checks);if(!n.length)return;const r=Math.min(...n.map(i=>i[0])),o=e._zod.parse;e._zod.parse=(i,s)=>{const a=t(i.value);if(a>r&&!(s!=null&&s.skipChecks)&&(s==null?void 0:s.direction)!=="backward"){for(const[c,l]of Xn(e._zod.def.checks))if(a>c&&l._zod.def.when(i)){const u=i.issues.length;return l._zod.check(i),i.issues[u].continue=!1,fn(i.issues,u,e),i;}}return o(i,s);};}const Va=e=>Array.isArray(e)?e.length:-1;function rr(e,t,n){e.issues.length&&t.issues.push(...Ae(n,e.issues)),t.value[n]=e.value;}const Wa=/* @__PURE__ */g("$ZodArray",(e,t)=>{Z.init(e,t);const n=le.memoizer;n==null||n.attach(e),e._zod.parse=(r,o)=>{const i=r.value;if(!Array.isArray(i))return r.issues.push({expected:"array",code:"invalid_type",input:i,inst:e}),r;r.value=n?n.alloc(e,r,Array(i.length),o):Array(i.length);const s=[],a=o==null?void 0:o.abortEarly;for(let c=0;c<i.length;c++){const l=i[c],u=t.element._zod.run({value:l,issues:[]},o);if(u instanceof Promise)s.push(u.then(h=>rr(h,r,c)));else if(rr(u,r,c),a&&u.issues.length!==0&&he(u))break;}return s.length?Promise.all(s).then(()=>r):r;},Ka(e,Va);});function Nt(e,t,n,r,o,i){const s=n in r,a=i==="optional";if(!(!s&&a&&o==="optional")){if(e.issues.length){if(o!==void 0&&a&&!s)return;t.issues.push(...Ae(n,e.issues));}if(!s&&o===void 0){e.issues.length||t.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[n]});return;}e.value===void 0?(s||o==="defaulted"&&!a)&&(t.value[n]=void 0):t.value[n]=e.value;}}const Ga=[];function ko(e){var s,a,c,l;const t=Object.keys(e.shape),n=Object.getOwnPropertySymbols(e.shape),r=n.length?n:Ga,o=r.length?[...t,...r]:t;for(const u of o)if(!((l=(c=(a=(s=e.shape)==null?void 0:s[u])==null?void 0:a._zod)==null?void 0:c.traits)!=null&&l.has("$ZodType")))throw new Error(`Invalid element at key "${String(u)}": expected a Zod schema`);const i=Ti(e.shape);return{...e,allKeys:o,symbolKeys:r,// string-only: handleCatchall matches it against `for...in`, which never yields a symbol
|
|
19
|
-
keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(i)};}function Io(e,t,n,r,o,i,s){const a=[],c=o.keySet,l=o.catchall._zod,u=l.def.type,h=l.optin,d=l.optout;let f=0;for(const m in t){if(s&&n.issues.length!==f){if(he(n,f))break;f=n.issues.length;}if(c.has(m))continue;if(m==="__proto__"){u==="never"&&a.push(m);continue;}if(u==="never"){a.push(m);continue;}const v=l.run({value:t[m],issues:[]},r);v instanceof Promise?e.push(v.then(k=>Nt(k,n,m,t,h,d))):Nt(v,n,m,t,h,d);}return a.length&&n.issues.push({code:"unrecognized_keys",keys:a,input:t,inst:i,// Describes the shape of the input, not the validity of the parsed value, so it never aborts. The parse still fails; the schema's own checks just get to run first, and an enclosing intersection can reconcile the key against a sibling operand.
|
|
20
|
-
continue:!0}),e.length?Promise.all(e).then(()=>n):n;}const Xa=/* @__PURE__ */g("$ZodObject",(e,t)=>{Z.init(e,t);const n=Object.getOwnPropertyDescriptor(t,"shape"),r=n!=null&&n.get?n.get.raw:t.shape??{};if(r){const l=()=>{const u={...r};return Object.defineProperty(t,"shape",{value:u}),l.raw=u,u;};l.raw=r,Object.defineProperty(t,"shape",{get:l});}const o=qt(()=>ko(t));T(e,"propValues",l=>{const u=l.def.shape,h={};for(const d in u){const f=u[d]._zod;if(f.values){Object.prototype.hasOwnProperty.call(h,d)||$e(h,d,/* @__PURE__ */new Set());for(const m of f.values)h[d].add(m);f.optin!==void 0&&h[d].add(void 0);}}return h;});const i=ht,s=t.catchall;let a;const c=le.memoizer;c==null||c.attach(e),e._zod.parse=(l,u)=>{a??(a=o.value);const h=l.value;if(!i(h))return l.issues.push({expected:"object",code:"invalid_type",input:h,inst:e}),l;l.value=c?c.alloc(e,l,{},u):{};const d=[],f=a.shape,m=u==null?void 0:u.abortEarly;let v=l.issues.length;for(const k of a.allKeys){if(m&&l.issues.length!==v){if(he(l,v))break;v=l.issues.length;}if(k==="__proto__")continue;const _=f[k],y=_._zod.optin,x=_._zod.optout,A=_._zod.run({value:h[k],issues:[]},u);A instanceof Promise?d.push(A.then(B=>Nt(B,l,k,h,y,x))):Nt(A,l,k,h,y,x);}return s?Io(d,h,l,u,o.value,e,m===!0):d.length?Promise.all(d).then(()=>l):l;};}),Qa=/* @__PURE__ */g("$ZodObjectJIT",(e,t)=>{Xa.init(e,t);const n=e._zod.parse,r=qt(()=>ko(t)),o=le.memoizer,i=f=>{var B,C;const m=r.value,v=m.symbolKeys,k=new aa(["payload","ctx"],{shape:f,inst:e,memo:o,syms:v}),_=P=>`shape[${P}]._zod.run({ value: input[${P}], issues: [] }, ctx)`,y=(P,R)=>`
|
|
21
|
-
let ${P}_ab = false;
|
|
22
|
-
for (let i = 0; i < ${P}.issues.length; i++) {
|
|
23
|
-
const iss = ${P}.issues[i];
|
|
24
|
-
iss.path = iss.path ? [${R}, ...iss.path] : [${R}];
|
|
25
|
-
payload.issues.push(iss);
|
|
26
|
-
if (iss.continue !== true) ${P}_ab = true;
|
|
27
|
-
}
|
|
28
|
-
if (${P}_ab && ctx && ctx.abortEarly) {
|
|
29
|
-
payload.value = newResult;
|
|
30
|
-
return payload;
|
|
31
|
-
}`;k.write("const input = payload.value;");const x=/* @__PURE__ */Object.create(null);let A=0;for(const P of m.allKeys)x[P]=`key_${A++}`;k.write(o?"const newResult = memo.alloc(inst, payload, {}, ctx);":"const newResult = {};");for(const P of m.allKeys){if(P==="__proto__")continue;const R=x[P],O=typeof P=="symbol"?`syms[${v.indexOf(P)}]`:xi(P),me=`${O} in input`,oe=f[P],Se=(B=oe==null?void 0:oe._zod)==null?void 0:B.optin,J=Se!==void 0,De=((C=oe==null?void 0:oe._zod)==null?void 0:C.optout)==="optional";if(k.write(`const ${R} = ${_(O)};`),J&&De){const G=Se==="optional"?`${R}_present`:`${R}.value !== undefined || ${R}_present`;k.write(`
|
|
32
|
-
const ${R}_present = ${me};
|
|
33
|
-
if (!${R}.issues.length || ${R}_present) {
|
|
34
|
-
if (${R}.issues.length) {${y(R,O)}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
if (${G}) {
|
|
38
|
-
newResult[${O}] = ${R}.value;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
`);}else J?(k.write(`
|
|
43
|
-
if (${R}.issues.length) {${y(R,O)}
|
|
44
|
-
}
|
|
45
|
-
`),Se==="defaulted"?k.write(`newResult[${O}] = ${R}.value;`):k.write(`
|
|
46
|
-
if (${R}.value !== undefined || ${me}) {
|
|
47
|
-
newResult[${O}] = ${R}.value;
|
|
48
|
-
}
|
|
49
|
-
`)):k.write(`
|
|
50
|
-
const ${R}_present = ${me};
|
|
51
|
-
if (${R}.issues.length) {${y(R,O)}
|
|
52
|
-
}
|
|
53
|
-
if (!${R}_present && !${R}.issues.length) {
|
|
54
|
-
payload.issues.push({
|
|
55
|
-
code: "invalid_type",
|
|
56
|
-
expected: "nonoptional",
|
|
57
|
-
input: undefined,
|
|
58
|
-
path: [${O}]
|
|
59
|
-
});
|
|
60
|
-
if (ctx && ctx.abortEarly) {
|
|
61
|
-
payload.value = newResult;
|
|
62
|
-
return payload;
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
if (${R}_present) {
|
|
67
|
-
newResult[${O}] = ${R}.value;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
`);}return k.write("payload.value = newResult;"),k.write("return payload;"),k.compile();};let s;const a=ht,c=!le.jitless,u=c&&Oi.value,h=t.catchall;let d;e._zod.parse=(f,m)=>{d??(d=r.value);const v=f.value;return a(v)?c&&u&&(m==null?void 0:m.async)===!1&&m.jitless!==!0?(s||(s=i(t.shape)),f=s(f,m),h?Io([],v,f,m,d,e,(m==null?void 0:m.abortEarly)===!0):f):n(f,m):(f.issues.push({expected:"object",code:"invalid_type",input:v,inst:e}),f);};});function or(e,t,n,r){for(const i of e)if(i.issues.length===0)return t.value=i.value,t;const o=e.filter(i=>!he(i));return o.length===1?(t.value=o[0].value,o[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map(i=>i.issues.map(s=>xe(s,r,ge())))}),t);}const $o=/* @__PURE__ */g("$ZodUnion",(e,t)=>{Z.init(e,t),T(e,"optin",r=>r.def.options.some(o=>o._zod.optin==="defaulted")?"defaulted":r.def.options.some(o=>o._zod.optin!==void 0)?"optional":void 0),T(e,"optout",r=>r.def.options.some(o=>o._zod.optout==="optional")?"optional":void 0),T(e,"values",r=>{if(r.def.options.every(o=>o._zod.values))return new Set(r.def.options.flatMap(o=>Array.from(o._zod.values)));}),T(e,"pattern",r=>{if(r.def.options.every(o=>o._zod.pattern)){const o=r.def.options.map(i=>i._zod.pattern);return new RegExp(`^(${o.map(i=>An(i.source)).join("|")})$`);}});const n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(r,o)=>{if(n)return n(r,o);let i=!1;const s=[];for(const a of t.options){const c=a._zod.run({value:r.value,issues:[]},o);if(c instanceof Promise)s.push(c),i=!0;else{if(c.issues.length===0)return c;s.push(c);}}return i?Promise.all(s).then(a=>or(a,r,e,o)):or(s,r,e,o);};});function Ya(e){var n;const t=/* @__PURE__ */new Map();for(const r of e.options){const o=(n=r._zod.propValues)==null?void 0:n[e.discriminator];if(!o||o.size===0)throw new Error(`Invalid discriminated union option at index "${e.options.indexOf(r)}"`);for(const i of o)if(t.has(i)){if(i!==void 0)throw new Error(`Duplicate discriminator value "${String(i)}"`);t.set(i,null);}else t.set(i,r);}return t;}const ec=/* @__PURE__ */g("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,$o.init(e,t);const n=e._zod.parse;T(e,"propValues",o=>{var a,c;const i={};let s=0;for(const l of o.def.options){const u=l._zod.propValues;if(!u||Object.keys(u).length===0)throw new Error(`Invalid discriminated union option at index "${o.def.options.indexOf(l)}"`);(a=u[o.def.discriminator])!=null&&a.has(void 0)&&s++;for(const[h,d]of Object.entries(u)){Object.prototype.hasOwnProperty.call(i,h)||$e(i,h,/* @__PURE__ */new Set());for(const f of d)i[h].add(f);}}return!o.def.unionFallback&&s>1&&((c=i[o.def.discriminator])==null||c.delete(void 0)),i;}),t.options.forEach((o,i)=>{const s=xn(o._zod.def);if(s&&!Object.prototype.hasOwnProperty.call(s,t.discriminator))throw new Error(`Invalid discriminated union option at index "${i}"`);});const r=qt(()=>Ya(t));e._zod.parse=(o,i)=>{const s=o.value;if(!ht(s))return o.issues.push({code:"invalid_type",expected:"object",input:s,inst:e}),o;const a=s==null?void 0:s[t.discriminator],c=r.value.get(a);return c&&(a!==void 0||i.direction!=="backward")?c._zod.run(o,i):t.unionFallback||i.direction==="backward"?n(o,i):(o.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,options:Array.from(r.value.keys()).filter(l=>r.value.get(l)!==null),input:s,path:[t.discriminator],inst:e}),o);};}),tc=/* @__PURE__ */g("$ZodIntersection",(e,t)=>{Z.init(e,t),e._zod.parse=(n,r)=>{const o=n.value,i=t.left._zod.run({value:o,issues:[]},r),s=t.right._zod.run({value:o,issues:[]},r);return i instanceof Promise||s instanceof Promise?Promise.all([i,s]).then(([c,l])=>ir(n,c,l)):ir(n,i,s);};});function pn(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)){const n=Object.keys(t),r=Object.keys(e).filter(i=>n.indexOf(i)!==-1),o={...e,...t};Object.prototype.hasOwnProperty.call(o,"__proto__")&&delete o.__proto__;for(const i of r){if(i==="__proto__")continue;const s=pn(e[i],t[i]);if(!s.valid)return{valid:!1,mergeErrorPath:[i,...s.mergeErrorPath]};o[i]=s.data;}return{valid:!0,data:o};}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};const n=[];for(let r=0;r<e.length;r++){const o=e[r],i=t[r],s=pn(o,i);if(!s.valid)return{valid:!1,mergeErrorPath:[r,...s.mergeErrorPath]};n.push(s.data);}return{valid:!0,data:n};}return{valid:!1,mergeErrorPath:[]};}function ir(e,t,n){const r=/* @__PURE__ */new Map();let o;const i=/* @__PURE__ */new Map(),s=(l,u)=>{var d,f;let h;if(l.code==="unrecognized_keys"&&!((d=l.path)!=null&&d.length))o??(o=l),h=l.keys;else if(l.code==="invalid_key"&&l.origin==="record"&&((f=l.path)==null?void 0:f.length)===1){const m=String(l.path[0]);i.has(m)||i.set(m,l),h=[m];}else return!1;for(const m of h)r.has(m)||r.set(m,{}),r.get(m)[u]=!0;return!0;};for(const l of t.issues)s(l,"l")||e.issues.push(l);for(const l of n.issues)s(l,"r")||e.issues.push(l);const a=[...r].filter(([,l])=>l.l&&l.r).map(([l])=>l);if(a.length){const l=o?a.filter(u=>o.keys.includes(u)):[];l.length&&e.issues.push({...o,keys:l});for(const u of a)!l.includes(u)&&i.has(u)&&e.issues.push(i.get(u));}const c=pn(t.value,n.value);if(!c.valid){if(he(e))return e;throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(c.mergeErrorPath)}`);}return e.value=c.data,e;}const nc=/* @__PURE__ */g("$ZodTuple",(e,t)=>{Z.init(e,t);const n=t.items,r=le.memoizer;r==null||r.attach(e),e._zod.parse=(o,i)=>{const s=o.value;if(!Array.isArray(s))return o.issues.push({input:s,inst:e,expected:"tuple",code:"invalid_type"}),o;o.value=r?r.alloc(e,o,[],i):[];const a=[],c=sr(n,"optin"),l=sr(n,"optout");if(!t.rest){if(s.length<c)return o.issues.push({code:"too_small",minimum:c,inclusive:!0,input:s,inst:e,origin:"array"}),o;s.length>n.length&&o.issues.push({code:"too_big",maximum:n.length,inclusive:!0,input:s,inst:e,origin:"array"});}const u=new Array(n.length),h=t.rest?i==null?void 0:i.abortEarly:void 0;let d=!1;for(let f=0;f<n.length;f++){const m=n[f]._zod.run({value:s[f],issues:[]},i);m instanceof Promise?a.push(m.then(v=>{u[f]=v;})):(u[f]=m,h&&!d&&m.issues.length&&(d=he(m)));}if(t.rest&&!d){let f=n.length-1;const m=s.slice(n.length);let v=o.issues.length;for(const k of m){if(h&&o.issues.length!==v){if(he(o,v))break;v=o.issues.length;}f++;const _=t.rest._zod.run({value:k,issues:[]},i);_ instanceof Promise?a.push(_.then(y=>ar(y,o,f))):ar(_,o,f);}}return a.length?Promise.all(a).then(()=>cr(u,o,n,s,l)):cr(u,o,n,s,l);};});function sr(e,t){for(let n=e.length-1;n>=0;n--)if(!(t==="optin"?e[n]._zod.optin!==void 0:e[n]._zod.optout==="optional"))return n+1;return 0;}function ar(e,t,n){e.issues.length&&t.issues.push(...Ae(n,e.issues)),t.value[n]=e.value;}function cr(e,t,n,r,o){for(let i=0;i<n.length;i++){const s=e[i],a=i<r.length;if(!a&&i>=o&&n[i]._zod.optin==="optional"){t.value.length=i;break;}if(s.issues.length){if(!a&&i>=o){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>=r.length&&n[i]._zod.optout==="optional"&&t.value[i]===void 0;i--)t.value.length=i;return t;}const rc=/* @__PURE__ */g("$ZodRecord",(e,t)=>{Z.init(e,t);const n=le.memoizer;n==null||n.attach(e),e._zod.parse=(r,o)=>{const i=r.value;if(!Je(i))return r.issues.push({expected:"record",code:"invalid_type",input:i,inst:e}),r;const s=[],a=t.keyType._zod.values;if(a&&!t.partial){r.value=n?n.alloc(e,r,{},o):{};const c=/* @__PURE__ */new Set();for(const u of a)if(typeof u=="string"||typeof u=="number"||typeof u=="symbol"){if(c.add(typeof u=="number"?u.toString():u),u==="__proto__")continue;const h=t.keyType._zod.run({value:u,issues:[]},o);if(h instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(h.issues.length){r.issues.push({code:"invalid_key",origin:"record",issues:h.issues.map(m=>xe(m,o,ge())),input:u,path:[u],inst:e});continue;}const d=h.value;if(d==="__proto__")continue;const f=t.valueType._zod.run({value:i[u],issues:[]},o);f instanceof Promise?s.push(f.then(m=>{m.issues.length&&r.issues.push(...Ae(u,m.issues)),r.value[d]=m.value;})):(f.issues.length&&r.issues.push(...Ae(u,f.issues)),r.value[d]=f.value);}let l;for(const u in i)if(!c.has(u))if(t.mode==="loose"){if(u==="__proto__")continue;r.value[u]=i[u];}else l=l??[],l.push(u);l&&l.length>0&&r.issues.push({code:"unrecognized_keys",input:i,inst:e,keys:l,continue:!0});}else{r.value=n?n.alloc(e,r,{},o):{};let c;for(const l of Reflect.ownKeys(i)){if(l==="__proto__"||!Object.prototype.propertyIsEnumerable.call(i,l))continue;let u=t.keyType._zod.run({value:l,issues:[]},o);if(u instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(typeof l=="string"&&Zn.test(l)&&u.issues.length){const m=t.keyType._zod.run({value:Number(l),issues:[]},o);if(m instanceof Promise)throw new Error("Async schemas not supported in object keys currently");m.issues.length===0&&(u=m);}if(u.issues.length){t.mode==="loose"?r.value[l]=i[l]:a?(c=c??[],c.push(l)):r.issues.push({code:"invalid_key",origin:"record",issues:u.issues.map(m=>xe(m,o,ge())),input:l,path:[l],inst:e});continue;}const d=u.value;if(d==="__proto__")continue;const f=t.valueType._zod.run({value:i[l],issues:[]},o);f instanceof Promise?s.push(f.then(m=>{m.issues.length&&r.issues.push(...Ae(l,m.issues)),r.value[d]=m.value;})):(f.issues.length&&r.issues.push(...Ae(l,f.issues)),r.value[d]=f.value);}c&&c.length>0&&r.issues.push({code:"unrecognized_keys",input:i,inst:e,keys:c,continue:!0});}return s.length?Promise.all(s).then(()=>r):r;};}),oc=/* @__PURE__ */g("$ZodEnum",(e,t)=>{Z.init(e,t);const n=ln(t.entries),r=new Set(n);e._zod.values=r,T(e,"pattern",o=>{const i=ln(o.def.entries).filter(s=>Pi.has(typeof s));return new RegExp(i.length?`^(${i.map(s=>He(s.toString())).join("|")})$`:"^[^\\s\\S]$");}),e._zod.parse=(o,i)=>{const s=o.value;return r.has(s)||o.issues.push({code:"invalid_value",values:n,input:s,inst:e}),o;};}),ic=/* @__PURE__ */g("$ZodLiteral",(e,t)=>{Z.init(e,t);const n=new Set(t.values);e._zod.values=n,T(e,"pattern",r=>{const o=r.def.values;return new RegExp(o.length?`^(${o.map(i=>typeof i=="string"?He(i):i?He(i.toString()):String(i)).join("|")})$`:"^[^\\s\\S]$");}),e._zod.parse=(r,o)=>{const i=r.value;return n.has(i)||r.issues.push({code:"invalid_value",values:t.values,input:i,inst:e}),r;};}),sc=/* @__PURE__ */g("$ZodTransform",(e,t)=>{var n;Z.init(e,t),e._zod.optin="optional",(n=le.memoizer)==null||n.guard(e),e._zod.parse=(r,o)=>{if(o.direction==="backward")throw new co(e.constructor.name);const i=t.transform(r.value,r);if(o.async)return(i instanceof Promise?i:Promise.resolve(i)).then(a=>(r.value=a,r));if(i instanceof Promise)throw new Ze();return r.value=i,r;};});function ur(e,t){return e.value=t.issues.length?void 0:t.value,e;}const So=/* @__PURE__ */g("$ZodOptional",(e,t)=>{Z.init(e,t),T(e,"optin",n=>n.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),e._zod.optout="optional",T(e,"values",n=>{const r=n.def.innerType._zod.values;return r?/* @__PURE__ */new Set([...r,void 0]):void 0;}),T(e,"pattern",n=>{const r=n.def.innerType._zod.pattern;return r?new RegExp(`^(${An(r.source)})?$`):void 0;}),e._zod.parse=(n,r)=>{if(n.value===void 0){if(t.innerType._zod.optin!=="defaulted")return n;const o=t.innerType._zod.run({value:n.value,issues:[]},r);return o instanceof Promise?o.then(i=>ur(n,i)):ur(n,o);}return t.innerType._zod.run(n,r);};}),ac=/* @__PURE__ */g("$ZodExactOptional",(e,t)=>{So.init(e,t),T(e,"values",n=>n.def.innerType._zod.values),T(e,"pattern",n=>n.def.innerType._zod.pattern),e._zod.parse=(n,r)=>t.innerType._zod.run(n,r);}),cc=/* @__PURE__ */g("$ZodNullable",(e,t)=>{Z.init(e,t),T(e,"optin",n=>n.def.innerType._zod.optin),T(e,"optout",n=>n.def.innerType._zod.optout),T(e,"pattern",n=>{const r=n.def.innerType._zod.pattern;return r?new RegExp(`^(${An(r.source)}|null)$`):void 0;}),T(e,"values",n=>n.def.innerType._zod.values?/* @__PURE__ */new Set([...n.def.innerType._zod.values,null]):void 0),e._zod.parse=(n,r)=>n.value===null?n:t.innerType._zod.run(n,r);}),uc=/* @__PURE__ */g("$ZodDefault",(e,t)=>{Z.init(e,t),e._zod.optin="defaulted",T(e,"values",n=>n.def.innerType._zod.values),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);if(n.value===void 0)return n.value=t.defaultValue,n;const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(i=>lr(i,t)):lr(o,t);};});function lr(e,t){return e.value===void 0&&(e.value=t.defaultValue),e;}const lc=/* @__PURE__ */g("$ZodPrefault",(e,t)=>{Z.init(e,t),e._zod.optin="defaulted",T(e,"values",n=>n.def.innerType._zod.values),e._zod.parse=(n,r)=>(r.direction==="backward"||n.value===void 0&&(n.value=t.defaultValue),t.innerType._zod.run(n,r));}),dc=/* @__PURE__ */g("$ZodNonOptional",(e,t)=>{Z.init(e,t),T(e,"values",n=>{const r=n.def.innerType._zod.values;return r?new Set([...r].filter(o=>o!==void 0)):void 0;}),e._zod.parse=(n,r)=>{const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(i=>dr(i,e)):dr(o,e);};});function dr(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e;}function fr(e,t,n,r){return t.issues.length?(e.value=n.catchValue({...t,value:e.value,error:{issues:t.issues.map(o=>xe(o,r,ge()))},input:e.value}),e):(e.value=t.value,t.memo&&(e.memo=!0),e);}const fc=/* @__PURE__ */g("$ZodCatch",(e,t)=>{Z.init(e,t),T(e,"optin",n=>n.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),T(e,"optout",n=>n.def.innerType._zod.optout),T(e,"values",n=>n.def.innerType._zod.values),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);const o=t.innerType._zod.run({value:n.value,issues:[]},r);return o instanceof Promise?o.then(i=>fr(n,i,t,r)):fr(n,o,t,r);};}),hc=/* @__PURE__ */g("$ZodPipe",(e,t)=>{Z.init(e,t),T(e,"values",n=>n.def.in._zod.values),T(e,"optin",n=>n.def.in._zod.optin),T(e,"optout",n=>n.def.out._zod.optout),T(e,"propValues",n=>n.def.in._zod.propValues),e._zod.parse=(n,r)=>{if(r.direction==="backward"){const i=t.out._zod.run(n,r);return i instanceof Promise?i.then(s=>It(s,t.in,r)):It(i,t.in,r);}const o=t.in._zod.run(n,r);return o instanceof Promise?o.then(i=>It(i,t.out,r)):It(o,t.out,r);};});function It(e,t,n){return e.issues.some(r=>r.code!=="unrecognized_keys")?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n);}const pc=/* @__PURE__ */g("$ZodReadonly",(e,t)=>{Z.init(e,t),T(e,"propValues",n=>n.def.innerType._zod.propValues),T(e,"values",n=>n.def.innerType._zod.values),T(e,"optin",n=>{var r,o;return(o=(r=n.def.innerType)==null?void 0:r._zod)==null?void 0:o.optin;}),T(e,"optout",n=>{var r,o;return(o=(r=n.def.innerType)==null?void 0:r._zod)==null?void 0:o.optout;}),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(hr):hr(o);};});function hr(e){return e.memo||(e.value=Object.freeze(e.value)),e;}const mc=/* @__PURE__ */g("$ZodCustom",(e,t)=>{re.init(e,t),Z.init(e,t),e._zod.parse=(n,r)=>n,e._zod.check=n=>{const r=n.value,o=t.fn(r);if(o instanceof Promise)return o.then(i=>pr(i,n,r,e));pr(o,n,r,e);};});function pr(e,t,n,r){if(!e){const o={code:"custom",input:n,inst:r,// incorporates params.error into issue reporting
|
|
71
|
-
path:[...(r._zod.def.path??[])],// incorporates params.error into issue reporting
|
|
72
|
-
continue:!r._zod.def.abort// params: inst._zod.def.params,
|
|
73
|
-
};r._zod.def.params&&(o.params=r._zod.def.params),t.issues.push(pt(o));}}class gc extends Error{constructor(){super("Cannot parse a reference cycle that closes through a transform"),this.name="ZodCyclicError";}}const mn="~memo",mr=[];function zo(e){return e!==null&&typeof e=="object";}function tn(e){return e.map(t=>t.path?{...t,path:t.path.slice()}:{...t});}const Eo=/* @__PURE__ */new WeakMap(),rt=0,Rt=1,ct=2;function Ot(e,t,n){const r=Eo.get(e);if(r!==void 0)return r?ct:rt;if(t.has(e))return ct;t.add(e);let o=rt;const i=u=>{if(o!==ct&&u!=null&&u._zod){const h=Ot(u,t);h>o&&(o=h);}},s=(u,h)=>{var f;let d=rt;for(const m of Reflect.ownKeys(u)){const v=Object.getOwnPropertyDescriptor(u,m);if(!v.enumerable)continue;const k=v.get?Rt:(f=v.value)!=null&&f._zod?Ot(v.value,t):rt;k>d&&(d=k);}return d;},a=u=>{u>o&&(o=u);},c=e._zod.def;switch(c.type){case"object":{const u=xn(c);a(u?s(u):Rt),i(c.catchall);break;}case"array":i(c.element);break;case"tuple":for(const u of c.items)i(u);i(c.rest);break;case"record":case"map":i(c.keyType),i(c.valueType);break;case"set":i(c.valueType);break;case"union":for(const u of c.options)i(u);break;case"intersection":i(c.left),i(c.right);break;case"optional":case"nullable":case"default":case"prefault":case"catch":case"readonly":case"nonoptional":case"promise":case"success":i(c.innerType);break;case"pipe":i(c.in),i(c.out);break;case"function":i(c.input),i(c.output);break;// `$ZodLazy` caches its inner on the def, so a resolved edge is followed exactly
|
|
74
|
-
case"lazy":{const u=c._cachedInner??void 0;a(u?Ot(u,t):Rt);break;}// a leaf by choice: `parts` are regex fragments, not data positions
|
|
75
|
-
case"template_literal":// leaves
|
|
76
|
-
case"string":case"number":case"int":case"boolean":case"bigint":case"symbol":case"undefined":case"null":case"void":case"never":case"any":case"unknown":case"date":case"nan":case"enum":case"literal":case"file":case"transform":case"custom":break;default:for(const u in c){const h=Object.getOwnPropertyDescriptor(c,u);if(!h||h.get)continue;const d=h.value;if(!(!d||typeof d!="object")){if(d._zod)i(d);else if(Array.isArray(d))for(const f of d)i(f);}}}return t.delete(e),bc(e,o);}function bc(e,t){return t!==Rt&&Eo.set(e,t===ct),t;}function vc(e,t){let n=e.buckets.get(t);return n||(n=/* @__PURE__ */new WeakMap(),e.buckets.set(t,n)),n;}let $t;const St=[],wc={alloc(e,t,n){const r=$t;if(!r)return n;$t=void 0;const o={value:n,issues:null};return r.set(t.value,o),St.push(o),n;},guard(e){var t;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{const n=e._zod.parse,r=(o,i)=>{if(i.direction!=="backward"&&_c(i,o.value))throw new gc();return n(o,i);};e._zod.parse=r,e._zod.run===n&&(e._zod.run=r);});},attach(e){var t;let n,r=!1,o,i;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{const s=e._zod.parse,a=(c,l)=>{if(n===void 0){const _=Ot(e,/* @__PURE__ */new Set());if(_===rt)return e._zod.parse=s,e._zod.run===a&&(e._zod.run=s),s(c,l);_===ct||r?n=!0:r=!0;}const u=c.value;if(!zo(u))return s(c,l);let h=l[mn];h||(h={buckets:/* @__PURE__ */new WeakMap(),backEdges:void 0},l[mn]=h);let d;o===l?d=i:(d=vc(h,e),o=l,i=d);const f=d.get(u);if(f)return c.value=f.value,f.issues?f.issues.length&&c.issues.push(...tn(f.issues)):(c.memo=!0,h.backEdges??(h.backEdges=/* @__PURE__ */new WeakSet()),h.backEdges.add(f.value)),c;$t=d;const m=St.length,v=s(c,l);$t=void 0;const k=St.length>m?St.pop():void 0;return v instanceof Promise?v.then(_=>(k&&(k.issues=_.issues.length?tn(_.issues):mr),_)):(k&&(k.issues=v.issues.length?tn(v.issues):mr),v);};e._zod.parse=a,e._zod.run===s&&(e._zod.run=a);});}};function yc(){return wc;}function _c(e,t){var r;const n=(r=e[mn])==null?void 0:r.backEdges;return n!==void 0&&zo(t)&&n.has(t);}const kc=()=>{const 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(i){return e[i]??null;}const n={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",mac:"MAC address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",currency_code:"currency code",credit_card:"credit card number",iban:"IBAN",jwt:"JWT",template_literal:"input"},r={// Compatibility: "nan" -> "NaN" for display
|
|
77
|
-
nan:"NaN"// All other type names omitted - they fall back to raw values via ?? operator
|
|
78
|
-
};function o(i,s){return i==="number"&&typeof s=="number"&&!Number.isFinite(s)?String(s):r[i]??i;}return i=>{switch(i.code){case"invalid_type":{const s=o(i.expected),a=Bi(i.input),c=o(a,i.input);return`Invalid input: expected ${s}, received ${c}`;}case"invalid_value":return i.values.length===1?`Invalid input: expected ${ro(i.values[0])}`:`Invalid option: expected one of ${Wn(i.values,"|")}`;case"too_big":{const s=i.exact?"exactly ":i.inclusive?"<=":"<",a=t(i.origin);return a?`Too big: expected ${i.origin??"value"} to have ${s}${i.maximum.toString()} ${a.unit??"elements"}`:`Too big: expected ${i.origin??"value"} to be ${s}${i.maximum.toString()}`;}case"too_small":{const s=i.exact?"exactly ":i.inclusive?">=":">",a=t(i.origin);return a?`Too small: expected ${i.origin} to have ${s}${i.minimum.toString()} ${a.unit}`:`Too small: expected ${i.origin} to be ${s}${i.minimum.toString()}`;}case"invalid_format":{const s=i;return s.format==="starts_with"?`Invalid string: must start with "${s.prefix}"`:s.format==="ends_with"?`Invalid string: must end with "${s.suffix}"`:s.format==="includes"?`Invalid string: must include "${s.includes}"`:s.format==="regex"?`Invalid string: must match pattern ${s.pattern}`:`Invalid ${n[s.format]??i.format}`;}case"not_multiple_of":return`Invalid number: must be a multiple of ${i.divisor}`;case"unrecognized_keys":return`Unrecognized key${i.keys.length>1?"s":""}: ${Wn(i.keys,", ")}`;case"invalid_key":return`Invalid key in ${i.origin}`;case"invalid_union":return i.options&&Array.isArray(i.options)&&i.options.length>0?`Invalid discriminator value. Expected ${i.options.map(a=>`'${a}'`).join(" | ")}`:i.inclusive===!1?"Invalid input: more than one option matched":"Invalid input";case"invalid_element":return`Invalid value in ${i.origin}`;default:return"Invalid input";}};};function Ic(){return{localeError:kc()};}var gr;class $c{constructor(){this._map=/* @__PURE__ */new WeakMap(),this._idmap=/* @__PURE__ */new Map();}add(t,...n){const r=n[0];return this._map.set(t,r),r&&typeof r=="object"&&"id"in r&&this._idmap.set(r.id,t),this;}clear(){return this._map=/* @__PURE__ */new WeakMap(),this._idmap=/* @__PURE__ */new Map(),this;}remove(t){const n=this._map.get(t);return n&&typeof n=="object"&&"id"in n&&this._idmap.delete(n.id),this._map.delete(t),this;}get(t){const n=t._zod.parent;if(n){const r={...(this.get(n)??{})};delete r.id;const o={...r,...this._map.get(t)};return Object.keys(o).length?o:void 0;}return this._map.get(t);}has(t){return this._map.has(t);}}function Sc(){return new $c();}(gr=globalThis).__zod_globalRegistry??(gr.__zod_globalRegistry=Sc());const ot=globalThis.__zod_globalRegistry;function Ao(e){return e.checks&&(e.checks=[...e.checks]),e;}// @__NO_SIDE_EFFECTS__
|
|
79
|
-
function zc(e,t){return new e(Ao({type:"string",...I(t)}));}// @__NO_SIDE_EFFECTS__
|
|
80
|
-
function Ec(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...I(t)});}// @__NO_SIDE_EFFECTS__
|
|
81
|
-
function Ac(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...I(t)});}// @__NO_SIDE_EFFECTS__
|
|
82
|
-
function xc(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...I(t)});}// @__NO_SIDE_EFFECTS__
|
|
83
|
-
function Rc(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...I(t)});}// @__NO_SIDE_EFFECTS__
|
|
84
|
-
function Oc(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...I(t)});}// @__NO_SIDE_EFFECTS__
|
|
85
|
-
function Pc(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...I(t)});}// @__NO_SIDE_EFFECTS__
|
|
86
|
-
function Tc(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...I(t)});}// @__NO_SIDE_EFFECTS__
|
|
87
|
-
function Cc(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...I(t)});}// @__NO_SIDE_EFFECTS__
|
|
88
|
-
function Nc(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...I(t)});}// @__NO_SIDE_EFFECTS__
|
|
89
|
-
function Zc(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...I(t)});}// @__NO_SIDE_EFFECTS__
|
|
90
|
-
function jc(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...I(t)});}// @__NO_SIDE_EFFECTS__
|
|
91
|
-
function Dc(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...I(t)});}// @__NO_SIDE_EFFECTS__
|
|
92
|
-
function Lc(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...I(t)});}// @__NO_SIDE_EFFECTS__
|
|
93
|
-
function Uc(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...I(t)});}// @__NO_SIDE_EFFECTS__
|
|
94
|
-
function Fc(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...I(t)});}// @__NO_SIDE_EFFECTS__
|
|
95
|
-
function Mc(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...I(t)});}// @__NO_SIDE_EFFECTS__
|
|
96
|
-
function Bc(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...I(t)});}// @__NO_SIDE_EFFECTS__
|
|
97
|
-
function qc(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...I(t)});}// @__NO_SIDE_EFFECTS__
|
|
98
|
-
function Jc(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...I(t)});}// @__NO_SIDE_EFFECTS__
|
|
99
|
-
function Hc(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...I(t)});}// @__NO_SIDE_EFFECTS__
|
|
100
|
-
function Kc(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...I(t)});}// @__NO_SIDE_EFFECTS__
|
|
101
|
-
function Vc(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...I(t)});}// @__NO_SIDE_EFFECTS__
|
|
102
|
-
function xo(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...I(t)});}// @__NO_SIDE_EFFECTS__
|
|
103
|
-
function Wc(e,t){return new e({type:"string",format:"date",check:"string_format",...I(t)});}// @__NO_SIDE_EFFECTS__
|
|
104
|
-
function Gc(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...I(t)});}// @__NO_SIDE_EFFECTS__
|
|
105
|
-
function Xc(e,t){return new e({type:"string",format:"duration",check:"string_format",...I(t)});}// @__NO_SIDE_EFFECTS__
|
|
106
|
-
function Qc(e,t){return new e(Ao({type:"number",checks:[],...I(t)}));}// @__NO_SIDE_EFFECTS__
|
|
107
|
-
function Yc(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...I(t)});}// @__NO_SIDE_EFFECTS__
|
|
108
|
-
function eu(e,t){return new e({type:"boolean",...I(t)});}// @__NO_SIDE_EFFECTS__
|
|
109
|
-
function tu(e,t){return new e({type:"null",...I(t)});}// @__NO_SIDE_EFFECTS__
|
|
110
|
-
function nu(e){return new e({type:"unknown"});}// @__NO_SIDE_EFFECTS__
|
|
111
|
-
function ru(e,t){return new e({type:"never",...I(t)});}// @__NO_SIDE_EFFECTS__
|
|
112
|
-
function br(e,t){return new fo({check:"less_than",...I(t),value:e,inclusive:!1});}// @__NO_SIDE_EFFECTS__
|
|
113
|
-
function nn(e,t){return new fo({check:"less_than",...I(t),value:e,inclusive:!0});}// @__NO_SIDE_EFFECTS__
|
|
114
|
-
function vr(e,t){return new ho({check:"greater_than",...I(t),value:e,inclusive:!1});}// @__NO_SIDE_EFFECTS__
|
|
115
|
-
function rn(e,t){return new ho({check:"greater_than",...I(t),value:e,inclusive:!0});}// @__NO_SIDE_EFFECTS__
|
|
116
|
-
function wr(e,t){return new Ws({check:"multiple_of",...I(t),value:e});}// @__NO_SIDE_EFFECTS__
|
|
117
|
-
function Ro(e,t){return new Xs({check:"max_length",...I(t),maximum:e});}// @__NO_SIDE_EFFECTS__
|
|
118
|
-
function Zt(e,t){return new Qs({check:"min_length",...I(t),minimum:e});}// @__NO_SIDE_EFFECTS__
|
|
119
|
-
function Oo(e,t){return new Ys({check:"length_equals",...I(t),length:e});}// @__NO_SIDE_EFFECTS__
|
|
120
|
-
function ou(e,t){return new ea({check:"string_format",format:"regex",...I(t),pattern:e});}// @__NO_SIDE_EFFECTS__
|
|
121
|
-
function iu(e){return new ta({check:"string_format",format:"lowercase",...I(e)});}// @__NO_SIDE_EFFECTS__
|
|
122
|
-
function su(e){return new na({check:"string_format",format:"uppercase",...I(e)});}// @__NO_SIDE_EFFECTS__
|
|
123
|
-
function au(e,t){return new ra({check:"string_format",format:"includes",...I(t),includes:e});}// @__NO_SIDE_EFFECTS__
|
|
124
|
-
function cu(e,t){return new oa({check:"string_format",format:"starts_with",...I(t),prefix:e});}// @__NO_SIDE_EFFECTS__
|
|
125
|
-
function uu(e,t){return new ia({check:"string_format",format:"ends_with",...I(t),suffix:e});}// @__NO_SIDE_EFFECTS__
|
|
126
|
-
function Ge(e){return new sa({check:"overwrite",tx:e});}// @__NO_SIDE_EFFECTS__
|
|
127
|
-
function lu(e){return/* @__PURE__ */Ge(t=>t.normalize(e));}// @__NO_SIDE_EFFECTS__
|
|
128
|
-
function du(){return/* @__PURE__ */Ge(e=>e.trim());}// @__NO_SIDE_EFFECTS__
|
|
129
|
-
function fu(){return/* @__PURE__ */Ge(e=>e.toLowerCase());}// @__NO_SIDE_EFFECTS__
|
|
130
|
-
function hu(){return/* @__PURE__ */Ge(e=>e.toUpperCase());}// @__NO_SIDE_EFFECTS__
|
|
131
|
-
function pu(){return/* @__PURE__ */Ge(e=>Ri(e));}// @__NO_SIDE_EFFECTS__
|
|
132
|
-
function mu(e,t,n){return new e({type:"array",element:t,// get element() {
|
|
133
|
-
// return element;
|
|
134
|
-
// },
|
|
135
|
-
...I(n)});}// @__NO_SIDE_EFFECTS__
|
|
136
|
-
function gu(e,t,n){return new e({type:"custom",check:"custom",fn:t,...I(n)});}// @__NO_SIDE_EFFECTS__
|
|
137
|
-
function bu(e,t){const n=/* @__PURE__ */vu(r=>(r.addIssue=o=>{if(typeof o=="string")r.issues.push(pt(o,r.value,n._zod.def));else{const i=o;i.fatal&&(i.continue=!1),i.code??(i.code="custom"),"input"in i||(i.input=r.value),i.inst??(i.inst=n),i.continue??(i.continue=!n._zod.def.abort),r.issues.push(pt(i));}},e(r.value,r)),t);return n;}// @__NO_SIDE_EFFECTS__
|
|
138
|
-
function vu(e,t){const n=new re({check:"custom",...I(t)});return n._zod.check=e,n;}function ut(e,...t){for(const n of t)for(const r of Reflect.ownKeys(n))Object.prototype.propertyIsEnumerable.call(n,r)&&$e(e,r,n[r]);return e;}function Po(e){let t=(e==null?void 0:e.target)??"draft-2020-12";return t==="draft-4"&&(t="draft-04"),t==="draft-7"&&(t="draft-07"),{processors:e.processors??{},metadataRegistry:(e==null?void 0:e.metadata)??ot,target:t,unrepresentable:(e==null?void 0:e.unrepresentable)??"throw",override:(e==null?void 0:e.override)??(()=>{}),io:(e==null?void 0:e.io)??"output",counter:0,seen:/* @__PURE__ */new Map(),sharedDefsExtractedFor:void 0,sharedEmitDoneFor:void 0,cycles:(e==null?void 0:e.cycles)??"ref",reused:(e==null?void 0:e.reused)??"inline",intersections:[],deferred:[],external:(e==null?void 0:e.external)??void 0};}function Oe(e,t,n,r,o){const i=typeof t.unrepresentable=="function"?t.unrepresentable({zodSchema:e,path:r.path,message:o}):t.unrepresentable;if(i==="any")return!1;if(i===void 0||i==="throw")throw new Error(o);return Object.assign(n,i),!0;}function M(e,t,n={path:[],schemaPath:[]}){var u,h;var r;const o=e._zod.def,i=t.seen.get(e);if(i)return i.count++,n.schemaPath.includes(e)&&(i.cycle=n.path),i.schema;const s={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,s),t.sharedDefsExtractedFor=void 0,t.sharedEmitDoneFor=void 0;const a=(h=(u=e._zod).toJSONSchema)==null?void 0:h.call(u);if(a)s.schema=a;else{const d={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,s.schema,d);else{const m=s.schema,v=t.processors[o.type];if(!v)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${o.type}`);v(e,t,m,d);}const f=e._zod.parent;f&&(s.ref||(s.ref=f),M(f,t,d),t.seen.get(f).isParent=!0);}const c=t.metadataRegistry.get(e);return c&&ut(s.schema,c),t.io==="input"&&Q(e)&&(delete s.schema.examples,delete s.schema.default),t.io==="input"&&"_prefault"in s.schema&&((r=s.schema).default??(r.default=s.schema._prefault)),delete s.schema._prefault,t.seen.get(e).schema;}function yr(e){return e.replace(/~/g,"~0").replace(/\//g,"~1");}function To(e,t){var s,a,c,l;const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");if(e.external&&e.sharedDefsExtractedFor===e.external)return;const r=/* @__PURE__ */new Map();for(const u of e.seen.entries()){const h=(s=e.metadataRegistry.get(u[0]))==null?void 0:s.id;if(h){const d=r.get(h);if(d&&d!==u[0])throw new Error(`Duplicate schema id "${h}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(h,u[0]);}}const o=u=>{var v;const h=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){const k=(v=e.external.registry.get(u[0]))==null?void 0:v.id,_=e.external.uri??(x=>x);if(k)return{ref:_(k)};const y=u[1].defId??u[1].schema.id??`schema${e.counter++}`;return u[1].defId=y,{defId:y,ref:`${_("__shared")}#/${h}/${yr(y)}`};}const d="#",f=`${d}/${h}/`;if(u[1]===n&&!u[1].schema.id)return{ref:d};const m=u[1].schema.id??`__schema${e.counter++}`;return{defId:m,ref:f+yr(m)};},i=u=>{if(u[1].schema.$ref)return;const h=u[1],{ref:d,defId:f}=o(u);h.def={...h.schema},f&&(h.defId=f);const m=h.schema;for(const v in m)delete m[v];m.$ref=d;};if(e.cycles==="throw")for(const u of e.seen.entries()){const h=u[1];if(h.cycle)throw new Error(`Cycle detected: #/${(a=h.cycle)==null?void 0:a.join("/")}/<root>
|
|
139
|
-
|
|
140
|
-
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`);}for(const u of e.seen.entries()){const h=u[1];if(t===u[0]){i(u);continue;}if(e.external){const f=(c=e.external.registry.get(u[0]))==null?void 0:c.id;if(t!==u[0]&&f){i(u);continue;}}if((l=e.metadataRegistry.get(u[0]))==null?void 0:l.id){i(u);continue;}if(h.cycle){i(u);continue;}h.count>1&&e.reused==="ref"&&i(u);}e.external&&(e.sharedDefsExtractedFor=e.external);}function Co(e){const t=e.anyOf;if(!Array.isArray(t)||t.length===0||e.type!==void 0)return;const n=[];for(const r of t){if(!r||typeof r!="object")return;Co(r);const o=Object.keys(r);if(o.length!==1||o[0]!=="type")return;const i=r.type;for(const s of Array.isArray(i)?i:[i]){if(typeof s!="string")return;n.includes(s)||n.push(s);}}delete e.anyOf,e.type=n.length===1?n[0]:n;}const No=/* @__PURE__ */new Set(["type","properties","required","additionalProperties"]),_r=["oneOf","anyOf"];function kr(e){const t=e.additionalProperties;return t===void 0||t===!1||typeof t!="object"||t===null?null:Object.keys(t).length?t:null;}function gn(e){var i;const t=[];for(const s of e){if(typeof s!="object"||s.type!=="object")return null;for(const a in s)if(!No.has(a))return null;t.push(s);}const n={},r=/* @__PURE__ */new Set();for(const s of t){for(const a in s.properties){if(Object.prototype.hasOwnProperty.call(n,a))continue;const c=[];for(const u of t){const h=((i=u.properties)==null?void 0:i[a])??kr(u);h!=null&&(c.some(d=>JSON.stringify(d)===JSON.stringify(h))||c.push(h));}const l=c.length===1?c[0]:gn(c)??{allOf:c};$e(n,a,l);}for(const a of s.required??[])r.add(a);}const o={type:"object",properties:n};if(r.size&&(o.required=[...r]),t.every(s=>s.additionalProperties===!1))o.additionalProperties=!1;else{const s=[];for(const a of t){const c=kr(a);c&&!s.some(l=>JSON.stringify(l)===JSON.stringify(c))&&s.push(c);}s.length===1?o.additionalProperties=s[0]:s.length>1&&(o.additionalProperties={allOf:s});}return o;}function wu(e){const t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(const o of No)if(o in e)return;const n=t.filter(o=>_r.some(i=>Array.isArray(o[i])));let r=null;if(!n.length)r=gn(t);else{const o=n[0],i=_r.find(c=>Array.isArray(o[c]));if(Object.keys(o).length!==1)return;const s=t.filter(c=>c!==o),a=o[i].map(c=>gn([...s,c]));if(a.some(c=>!c))return;r={[i]:a};}r&&(delete e.allOf,ut(e,r));}function Zo(e,t){var a,c,l,u;const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=h=>{const d=e.seen.get(h);if(d.ref===null)return;const f=d.def??d.schema,m={...f},v=d.ref;if(d.ref=null,v){r(v);const _=e.seen.get(v),y=_.schema;if(y.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(f.allOf=f.allOf??[],f.allOf.push(y)):ut(f,y),ut(f,m),h._zod.parent===v)for(const A in f)A==="$ref"||A==="allOf"||A in m||delete f[A];if(y.$ref&&_.def)for(const A in f)A==="$ref"||A==="allOf"||A in _.def&&JSON.stringify(f[A])===JSON.stringify(_.def[A])&&delete f[A];}const k=h._zod.parent;if(k&&k!==v){r(k);const _=e.seen.get(k);if(_!=null&&_.schema.$ref&&(f.$ref=_.schema.$ref,_.def))for(const y in f)y==="$ref"||y==="allOf"||y in _.def&&JSON.stringify(f[y])===JSON.stringify(_.def[y])&&delete f[y];}e.override({zodSchema:h,jsonSchema:f,path:d.path??[]});};if(!e.external||e.sharedEmitDoneFor!==e.external){for(const h of[...e.seen.entries()].reverse())r(h[0]);if(e.target!=="openapi-3.0")for(const h of e.seen.entries())Co(h[1].def??h[1].schema);for(const h of e.deferred)h();if(e.intersections.length){const h=/* @__PURE__ */new Map();for(const d of e.seen.values())for(const f of[d.schema,d.def]){const m=f==null?void 0:f.allOf;if(!Array.isArray(m))continue;const v=h.get(m);v?v.push(f):h.set(m,[f]);}for(const d of e.intersections)for(const f of h.get(d)??[])wu(f);}}const o={};if(e.target==="draft-2020-12"?o.$schema="https://json-schema.org/draft/2020-12/schema":e.target==="draft-07"?o.$schema="http://json-schema.org/draft-07/schema#":e.target==="draft-04"?o.$schema="http://json-schema.org/draft-04/schema#":e.target,(a=e.external)!=null&&a.uri){const h=(c=e.external.registry.get(t))==null?void 0:c.id;if(!h)throw new Error("Schema is missing an `id` property");o.$id=e.external.uri(h);}ut(o,n.defId?n.schema:n.def??n.schema);const i=(l=e.metadataRegistry.get(t))==null?void 0:l.id;i!==void 0&&o.id===i&&delete o.id;const s=((u=e.external)==null?void 0:u.defs)??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(const h of e.seen.entries()){const d=h[1];d.def&&d.defId&&(d.def.id===d.defId&&delete d.def.id,$e(s,d.defId,d.def));}e.external&&(e.sharedEmitDoneFor=e.external),e.external||Object.keys(s).length>0&&(e.target==="draft-2020-12"?o.$defs=s:o.definitions=s);try{const h=JSON.parse(JSON.stringify(o));return Object.defineProperty(h,"~standard",{value:{...t["~standard"],jsonSchema:{input:jt(t,"input",e.processors),output:jt(t,"output",e.processors)}},enumerable:!1,writable:!1}),h;}catch{throw new Error("Error converting schema to JSON.");}}function Q(e,t){const n=t??{seen:/* @__PURE__ */new Set()};if(n.seen.has(e))return!1;n.seen.add(e);const r=e._zod.def;if(r.type==="transform")return!0;if(r.type==="array")return Q(r.element,n);if(r.type==="set")return Q(r.valueType,n);if(r.type==="lazy")return Q(r.getter(),n);if(r.type==="promise"||r.type==="optional"||r.type==="nonoptional"||r.type==="nullable"||r.type==="readonly"||r.type==="default"||r.type==="prefault"||r.type==="catch")return Q(r.innerType,n);if(r.type==="intersection")return Q(r.left,n)||Q(r.right,n);if(r.type==="record"||r.type==="map")return Q(r.keyType,n)||Q(r.valueType,n);if(r.type==="pipe")return e._zod.traits.has("$ZodCodec")?!0:Q(r.in,n)||Q(r.out,n);if(r.type==="object"){for(const o in r.shape)if(Q(r.shape[o],n))return!0;return!1;}if(r.type==="union"){for(const o of r.options)if(Q(o,n))return!0;return!1;}if(r.type==="tuple"){for(const o of r.items)if(Q(o,n))return!0;return!!(r.rest&&Q(r.rest,n));}return!1;}const yu=(e,t={})=>n=>{const r=Po({...n,processors:t});return M(e,r),To(r,e),Zo(r,e);},jt=(e,t,n={})=>r=>{const{libraryOptions:o,target:i}=r??{},s=Po({...(o??{}),target:i,io:t,processors:n});return M(e,s),To(s,e),Zo(s,e);},Ke=(e,t,n)=>{(e[t]===void 0||n>e[t])&&(e[t]=n);},Ve=(e,t,n)=>{(e[t]===void 0||n<e[t])&&(e[t]=n);},Ir=(e,t)=>{Ke(e,"minimum",t),Ve(e,"maximum",t);},jo=(e,t)=>{e.multipleOf??(e.multipleOf=[]),e.multipleOf.includes(t)||e.multipleOf.push(t);},Do=(e,t)=>{e.patterns??(e.patterns=/* @__PURE__ */new Set()),e.patterns.add(t);},Lo=(e,t)=>{e.mime=e.mime?e.mime.filter(n=>t.includes(n)):[...t];},Uo=(e,t)=>{e.format=t,t.includes("int")&&(e.isInt=!0);},$r=(e,t)=>Ke(e,"minimum",t.minimum),Sr=(e,t)=>Ve(e,"maximum",t.maximum),zr=e=>(t,n)=>{Uo(t,n.format);const[r,o]=e[n.format];Ke(t,"minimum",r),Ve(t,"maximum",o);},on={greater_than:(e,t)=>Ke(e,t.inclusive?"minimum":"exclusiveMinimum",t.value),less_than:(e,t)=>Ve(e,t.inclusive?"maximum":"exclusiveMaximum",t.value),multiple_of:(e,t)=>jo(e,t.value),number_format:zr(oo),bigint_format:zr(Ci),min_length:$r,max_length:Sr,length_equals:(e,t)=>Ir(e,t.length),min_size:$r,max_size:Sr,size_equals:(e,t)=>Ir(e,t.size),string_format:(e,t)=>{Uo(e,t.format),t.pattern&&Do(e,t.pattern),(t.format==="base64"||t.format==="base64url")&&(e.contentEncoding=t.format),(t.local||t.precision===-1)&&(e.laxFormat=!0);},mime_type:(e,t)=>Lo(e,t.mime)};function ue(e){var i;const t={},n=e._zod.def,r=e._zod.traits.has("$ZodCheck")?[e,...(n.checks??[])]:n.checks??[];for(const s of r)(i=on[s._zod.def.check])==null||i.call(on,t,s._zod.def);const o=e._zod.bag;o.minimum!==void 0&&Ke(t,"minimum",o.minimum),o.exclusiveMinimum!==void 0&&Ke(t,"exclusiveMinimum",o.exclusiveMinimum),o.maximum!==void 0&&Ve(t,"maximum",o.maximum),o.exclusiveMaximum!==void 0&&Ve(t,"exclusiveMaximum",o.exclusiveMaximum),o.multipleOf!==void 0&&jo(t,o.multipleOf),o.format!==void 0&&(t.format??(t.format=o.format),o.format.includes("int")&&(t.isInt=!0)),o.mime&&Lo(t,o.mime);for(const s of o.patterns??[])Do(t,s);return t;}const _u={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""// do not set
|
|
141
|
-
},ku=/* @__PURE__ */new Map([[yo,Ns],[Ln,Zs]]),Fo=e=>ku.get(e)??e,Iu=(e,t,n,r)=>{const o=n;o.type="string";const{minimum:i,maximum:s,format:a,patterns:c,contentEncoding:l,laxFormat:u}=ue(e);if(typeof i=="number"&&(o.minLength=i),typeof s=="number"&&(o.maxLength=s),a&&(o.format=_u[a]??a,o.format===""&&delete o.format,(a==="time"||u)&&delete o.format),l&&(o.contentEncoding=l),c&&c.size>0){const h=[...c].map(Fo);h.length===1?o.pattern=h[0].source:h.length>1&&(o.allOf=[...h.map(d=>({...(t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{}),pattern:d.source}))]);}},$u=(e,t,n,r)=>{const o=n,{minimum:i,maximum:s,multipleOf:a,exclusiveMaximum:c,exclusiveMinimum:l,isInt:u}=ue(e);o.type=u?"integer":"number";const h=typeof l=="number"&&l>=(i??Number.NEGATIVE_INFINITY),d=typeof c=="number"&&c<=(s??Number.POSITIVE_INFINITY),f=t.target==="draft-04"||t.target==="openapi-3.0";if(h?f?(o.minimum=l,o.exclusiveMinimum=!0):o.exclusiveMinimum=l:typeof i=="number"&&(o.minimum=i),d?f?(o.maximum=c,o.exclusiveMaximum=!0):o.exclusiveMaximum=c:typeof s=="number"&&(o.maximum=s),a){const m=/* @__PURE__ */new Set();for(const _ of a)Number.isFinite(_)&&_!==0?m.add(Math.abs(_)):Oe(e,t,o,r,`A multipleOf divisor of ${_} cannot be represented in JSON Schema`);const[v,...k]=m;v!==void 0&&(o.multipleOf=v),k.length&&(o.allOf=[...(o.allOf??[]),...k.map(_=>({multipleOf:_}))]);}},Su=(e,t,n,r)=>{n.type="boolean";},zu=(e,t,n,r)=>{t.target==="openapi-3.0"?(n.type="string",n.nullable=!0,n.enum=[null]):n.type="null";},Eu=(e,t,n,r)=>{n.not={};},Au=(e,t,n,r)=>{},xu=(e,t,n,r)=>{const o=e._zod.def,i=ln(o.entries);if(i.length===0){n.not={};return;}i.every(s=>typeof s=="number")&&(n.type="number"),i.every(s=>typeof s=="string")&&(n.type="string"),n.enum=i;},Ru=(e,t,n,r)=>{const o=e._zod.def;if(o.values.length===0){n.not={};return;}const i=[];for(const s of o.values)if(s===void 0){if(Oe(e,t,n,r,"Literal `undefined` cannot be represented in JSON Schema"))return;}else if(typeof s=="bigint"){if(Oe(e,t,n,r,"BigInt literals cannot be represented in JSON Schema"))return;i.push(Number(s));}else i.push(s);if(i.length!==0)if(i.length===1){const s=i[0];n.type=s===null?"null":typeof s,t.target==="draft-04"||t.target==="openapi-3.0"?n.enum=[s]:n.const=s;}else i.every(s=>typeof s=="number")&&(n.type="number"),i.every(s=>typeof s=="string")&&(n.type="string"),i.every(s=>typeof s=="boolean")&&(n.type="boolean"),i.every(s=>s===null)&&(n.type="null"),n.enum=i;},Ou=(e,t,n,r)=>{Oe(e,t,n,r,"Custom types cannot be represented in JSON Schema");},Pu=(e,t,n,r)=>{Oe(e,t,n,r,"Transforms cannot be represented in JSON Schema");},Tu=(e,t,n,r)=>{const o=n,i=e._zod.def,{minimum:s,maximum:a}=ue(e);typeof s=="number"&&(o.minItems=s),typeof a=="number"&&(o.maxItems=a),o.type="array",o.items=M(i.element,t,{...r,path:[...r.path,"items"]});};function mt(e){const t=e._zod.def;return t.type==="pipe"&&t.in._zod.traits.has("$ZodTransform")?mt(t.out):t.type==="catch"?mt(t.innerType):e._zod.optin;}const Cu=(e,t,n,r)=>{var l;const o=n,i=e._zod.def,s=i.shape;if(Object.getOwnPropertySymbols(s).length&&Oe(e,t,o,r,"Symbol keys cannot be represented in JSON Schema"))return;o.type="object",o.properties={};for(const u in s)$e(o.properties,u,M(s[u],t,{...r,path:[...r.path,"properties",u]}));const c=[];for(const u of Object.keys(s)){const h=i.shape[u];(t.io==="input"?mt(h)===void 0:h._zod.optout===void 0)&&c.push(u);}c.length>0&&(o.required=c),((l=i.catchall)==null?void 0:l._zod.def.type)==="never"?o.additionalProperties=!1:i.catchall?i.catchall&&(o.additionalProperties=M(i.catchall,t,{...r,path:[...r.path,"additionalProperties"]})):t.io==="output"&&(o.additionalProperties=!1);},Nu=(e,t,n,r)=>{const o=e._zod.def,i=o.inclusive===!1,s=o.options.map((a,c)=>M(a,t,{...r,path:[...r.path,i?"oneOf":"anyOf",c]}));i?n.oneOf=s:n.anyOf=s;},Zu=(e,t,n,r)=>{const o=e._zod.def,i=M(o.left,t,{...r,path:[...r.path,"allOf",0]}),s=M(o.right,t,{...r,path:[...r.path,"allOf",1]}),a=l=>"allOf"in l&&Object.keys(l).length===1,c=[...(a(i)?i.allOf:[i]),...(a(s)?s.allOf:[s])];n.allOf=c,t.intersections.push(c);},ju=(e,t,n,r)=>{const o=n,i=e._zod.def;o.type="array";const s=t.target==="draft-2020-12"?"prefixItems":"items",a=t.target==="draft-2020-12"||t.target==="openapi-3.0"?"items":"additionalItems",c=i.items.map((v,k)=>M(v,t,{...r,path:[...r.path,s,k]})),l=i.rest?M(i.rest,t,{...r,path:[...r.path,a,...(t.target==="openapi-3.0"?[i.items.length]:[])]}):null;let u=i.items.length;for(;u>0;){const v=i.items[u-1];if(!(t.io==="input"?mt(v)!==void 0:v._zod.optout==="optional"))break;u--;}const h=i.items.length,d=!i.rest;t.target==="draft-2020-12"?(o.prefixItems=c,d?o.items=!1:l&&(o.items=l),u>0&&(o.minItems=u),d&&(o.maxItems=h)):t.target==="openapi-3.0"?(o.items={anyOf:c},l&&o.items.anyOf.push(l),u>0&&(o.minItems=u),d&&(o.maxItems=h)):(o.items=c,d?o.additionalItems=!1:l&&(o.additionalItems=l),u>0&&(o.minItems=u),d&&(o.maxItems=h));const{minimum:f,maximum:m}=ue(e);typeof f=="number"&&(o.minItems=f),typeof m=="number"&&(o.maxItems=m);};function bn(e,t,n){var m;if(t.$ref){if(n.has(t))return t;n.add(t);const v=(m=e.get(t))==null?void 0:m.def;if(!v)return t;const k=bn(e,v,n);return k===v?t:k;}for(const v of["anyOf","oneOf"]){const k=t[v];if(!Array.isArray(k))continue;const _=k.map(y=>bn(e,y,n));_.some((y,x)=>y!==k[x])&&(t={...t,[v]:_});}const r=Array.isArray(t.type)?t.type:[t.type],o=!r.includes("string")&&r.some(v=>v==="number"||v==="integer"),i=t.enum??(t.const!==void 0?[t.const]:void 0);if(!o&&!(i!=null&&i.some(v=>typeof v=="number")))return t;const{minimum:s,maximum:a,exclusiveMinimum:c,exclusiveMaximum:l,multipleOf:u,format:h,id:d,...f}=t;return f.enum?f.enum=f.enum.map(v=>typeof v=="number"?String(v):v):typeof f.const=="number"&&(f.const=String(f.const)),o&&(f.type="string",i||(f.pattern=(r.includes("number")?Zn:qs).source)),f;}const vn=/* @__PURE__ */new WeakMap();function Du(e){var r;const t=/* @__PURE__ */new Map();for(const o of e.seen.values())o.def&&!t.has(o.schema)&&t.set(o.schema,o);const n=/* @__PURE__ */new Map();for(const o of vn.get(e)??[]){const i=e.seen.get(o),s=(r=(i==null?void 0:i.def)??(i==null?void 0:i.schema))==null?void 0:r.propertyNames;if(!s||s===!0||n.has(s))continue;const a=bn(t,s,/* @__PURE__ */new Set());a!==s&&n.set(s,a);}if(n.size)for(const o of e.seen.values())for(const i of[o.schema,o.def]){const s=i&&n.get(i.propertyNames);s&&(i.propertyNames=s);}}const Lu=(e,t,n,r)=>{const o=n,i=e._zod.def;o.type="object";const s=i.keyType,a=ue(s).patterns;if(i.mode==="loose"&&a&&a.size>0){const u=M(i.valueType,t,{...r,path:[...r.path,"patternProperties","*"]});o.patternProperties={};for(const h of a)$e(o.patternProperties,Fo(h).source,u);}else{if(t.target==="draft-07"||t.target==="draft-2020-12"){o.propertyNames=M(i.keyType,t,{...r,path:[...r.path,"propertyNames"]});let u=vn.get(t);u||(u=[],vn.set(t,u),t.deferred.push(()=>Du(t))),u.push(e);}o.additionalProperties=M(i.valueType,t,{...r,path:[...r.path,"additionalProperties"]});}const c=s._zod.values,l=t.io==="input"&&mt(i.valueType)!==void 0;if(c&&!i.partial&&!l){const u=[...c].filter(h=>typeof h=="string"||typeof h=="number");u.length>0&&(o.required=u.map(String));}},Uu=(e,t,n,r)=>{const o=e._zod.def,i=M(o.innerType,t,r),s=t.seen.get(e);t.target==="openapi-3.0"?(s.ref=o.innerType,n.nullable=!0):n.anyOf=[i,{type:"null"}];},Fu=(e,t,n,r)=>{const o=e._zod.def;M(o.innerType,t,r);const i=t.seen.get(e);i.ref=o.innerType;},Un=Symbol();function Mo(e,t,n,r,o){let i=!1;const s=JSON.stringify(e,(a,c)=>typeof c!="bigint"?c:(i=!0,null));return i?(Oe(t,n,r,o,"BigInt defaults cannot be represented in JSON Schema"),Un):JSON.parse(s);}const Mu=(e,t,n,r)=>{const o=e._zod.def;M(o.innerType,t,r);const i=t.seen.get(e);i.ref=o.innerType;const s=Mo(o.defaultValue,e,t,n,r);s!==Un&&(n.default=s);},Bu=(e,t,n,r)=>{const o=e._zod.def;M(o.innerType,t,r);const i=t.seen.get(e);if(i.ref=o.innerType,t.io!=="input")return;const s=Mo(o.defaultValue,e,t,n,r);s!==Un&&(n._prefault=s);},qu=(e,t,n,r)=>{const o=e._zod.def;M(o.innerType,t,r);const i=t.seen.get(e);i.ref=o.innerType;let s;try{s=o.catchValue(void 0);}catch{Oe(e,t,n,r,"Dynamic catch values are not supported in JSON Schema");return;}n.default=s;},Ju=(e,t,n,r)=>{const o=e._zod.def,i=o.in._zod.traits.has("$ZodTransform"),s=t.io==="input"?i?o.out:o.in:o.out;M(s,t,r);const a=t.seen.get(e);a.ref=s;},Hu=(e,t,n,r)=>{const o=e._zod.def;M(o.innerType,t,r);const i=t.seen.get(e);i.ref=o.innerType,n.readOnly=!0;},Bo=(e,t,n,r)=>{const o=e._zod.def;M(o.innerType,t,r);const i=t.seen.get(e);i.ref=o.innerType;},Er=/* @__PURE__ */new WeakSet([Object.prototype,Error.prototype]);function zt(e,t,n){Object.defineProperty(e,t,{configurable:!0,enumerable:!1,get(){const r=n(this);return Object.defineProperty(this,t,{value:r,configurable:!0,writable:!0}),r;},set(r){Object.defineProperty(this,t,{value:r,configurable:!0,writable:!0});}});}const Ku=(e,t)=>{ns.init(e,t),e.name="ZodError";const n=Object.getPrototypeOf(e);Er.has(n)||(Er.add(n),zt(n,"format",r=>o=>is(r,o)),zt(n,"flatten",r=>o=>os(r,o)),zt(n,"addIssue",r=>o=>{r.issues.push(o),r.message=JSON.stringify(r.issues,dn,2);}),zt(n,"addIssues",r=>o=>{r.issues.push(...o),r.message=JSON.stringify(r.issues,dn,2);}),Object.defineProperty(n,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0;}}));},de=/* @__PURE__ */g("ZodError",Ku,void 0,{Parent:Error}),Vu=/* @__PURE__ */Pn(de),Wu=/* @__PURE__ */Tn(de),Gu=/* @__PURE__ */Cn(de),Xu=/* @__PURE__ */Nn(de),Qu=/* @__PURE__ */ds(de),Yu=/* @__PURE__ */fs(de),el=/* @__PURE__ */hs(de),tl=/* @__PURE__ */ps(de),nl=/* @__PURE__ */ms(de),rl=/* @__PURE__ */gs(de),ol=/* @__PURE__ */bs(de),il=/* @__PURE__ */vs(de);function sl(){le.localeError||ge(Ic());}function bt(){le.memoizer||ge({memoizer:yc()});}const j=/* @__PURE__ */g("ZodType",(e,t)=>(sl(),Z.init(e,t),e.def=t,e.type=t.type,e),{check(...e){const t=this.def;return this.clone(ae(t,{checks:[...(t.checks??[]),...e.map(n=>typeof n=="function"?{_zod:{check:n,def:{check:"custom"},onattach:[]}}:n)]}),{parent:!0});},with(...e){return this.check(...e);},clone(e,t){return Pe(this,e,t);},brand(){return this;},register(e,t){return e.add(this,t),this;},refine(e,t){return this.check(rd(e,t));},superRefine(e,t){return this.check(od(e,t));},overwrite(e){return this.check(/* @__PURE__ */Ge(e));},optional(){return Or(this);},exactOptional(){return ql(this);},nullable(){return Pr(this);},nullish(){return Or(Pr(this));},nonoptional(e){return Gl(this,e);},array(){return z(this);},or(e){return Wo([this,e]);},and(e){return Dl(this,e);},transform(e){return Tr(this,Bl(e));},default(e){return Kl(this,e);},prefault(e){return Wl(this,e);},catch(e){return Ql(this,e);},pipe(e){return Tr(this,e);},readonly(){return td(this);},describe(e){const t=this.clone();return ot.add(t,{description:e}),t;},meta(...e){if(e.length===0)return ot.get(this);const t=this.clone();return ot.add(t,e[0]),t;},isOptional(){return this.safeParse(void 0).success;},isNullable(){return this.safeParse(null).success;},apply(e,...t){return t.length===0?e(this):e(this,...t);},// Overrides core's `~standard` to add `jsonSchema`. Must stay a prototype entry: redefining it per instance demotes instances to dictionary mode.
|
|
142
|
-
get"~standard"(){return so(this,"~standard",{...mo(this),jsonSchema:{input:jt(this,"input"),output:jt(this,"output")}});},set"~standard"(e){Re(this,"~standard",e);},parse:function e(t,n){return Vu(this,t,n,{callee:e});},parseAsync:async function e(t,n){return await Wu(this,t,n,{callee:e});},safeParse(e,t){return Gu(this,e,t);},async safeParseAsync(e,t){return Xu(this,e,t);},// `spa` is an alias: same function object as `safeParseAsync`, as before.
|
|
143
|
-
get spa(){return this==null?void 0:this.safeParseAsync;},set spa(e){Re(this,"spa",e);},validate(e,t){return cs(this,e,t);},validateAsync(e,t){return ls(this,e,t);},encode:function e(t,n){return Qu(this,t,n,{callee:e});},decode:function e(t,n){return Yu(this,t,n,{callee:e});},encodeAsync:async function e(t,n){return await el(this,t,n,{callee:e});},decodeAsync:async function e(t,n){return await tl(this,t,n,{callee:e});},safeEncode(e,t){return nl(this,e,t);},safeDecode(e,t){return rl(this,e,t);},async safeEncodeAsync(e,t){return ol(this,e,t);},async safeDecodeAsync(e,t){return il(this,e,t);},toJSONSchema(e){return yu(this,{})(e);},// Reads through to the registry on every access, so it must not cache.
|
|
144
|
-
get description(){var e;return(e=ot.get(this))==null?void 0:e.description;},// No setter: `schema._def = x` throws, as it did when `_def` was a non-writable own property.
|
|
145
|
-
get _def(){return this._zod.def;}}),qo=/* @__PURE__ */g("_ZodString",(e,t)=>{Dn.init(e,t),j.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Iu(e,n,r);},/* @__PURE__ */ao({format:e=>ue(e).format??null,minLength:e=>ue(e).minimum??null,maxLength:e=>ue(e).maximum??null},{regex(...e){return this.check(/* @__PURE__ */ou(...e));},includes(...e){return this.check(/* @__PURE__ */au(...e));},startsWith(...e){return this.check(/* @__PURE__ */cu(...e));},endsWith(...e){return this.check(/* @__PURE__ */uu(...e));},min(...e){return this.check(/* @__PURE__ */Zt(...e));},max(...e){return this.check(/* @__PURE__ */Ro(...e));},length(...e){return this.check(/* @__PURE__ */Oo(...e));},nonempty(...e){return this.check(/* @__PURE__ */Zt(1,...e));},lowercase(e){return this.check(/* @__PURE__ */iu(e));},uppercase(e){return this.check(/* @__PURE__ */su(e));},trim(){return this.check(/* @__PURE__ */du());},normalize(...e){return this.check(/* @__PURE__ */lu(...e));},toLowerCase(){return this.check(/* @__PURE__ */fu());},toUpperCase(){return this.check(/* @__PURE__ */hu());},slugify(){return this.check(/* @__PURE__ */pu());}})),al=/* @__PURE__ */g("ZodString",(e,t)=>{Dn.init(e,t),qo.init(e,t);},{email(e){return this.check(/* @__PURE__ */Ec(dl,e));},url(e){return this.check(/* @__PURE__ */Tc(hl,e));},jwt(e){return this.check(/* @__PURE__ */Vc(Al,e));},emoji(e){return this.check(/* @__PURE__ */Cc(pl,e));},guid(e){return this.check(/* @__PURE__ */Ac(fl,e));},uuid(e){return this.check(/* @__PURE__ */xc(Et,e));},uuidv4(e){return this.check(/* @__PURE__ */Rc(Et,e));},uuidv6(e){return this.check(/* @__PURE__ */Oc(Et,e));},uuidv7(e){return this.check(/* @__PURE__ */Pc(Et,e));},nanoid(e){return this.check(/* @__PURE__ */Nc(ml,e));},cuid(e){return this.check(/* @__PURE__ */Zc(gl,e));},cuid2(e){return this.check(/* @__PURE__ */jc(bl,e));},ulid(e){return this.check(/* @__PURE__ */Dc(vl,e));},base64(e){return this.check(/* @__PURE__ */Jc(Sl,e));},base64url(e){return this.check(/* @__PURE__ */Hc(zl,e));},xid(e){return this.check(/* @__PURE__ */Lc(wl,e));},ksuid(e){return this.check(/* @__PURE__ */Uc(yl,e));},ipv4(e){return this.check(/* @__PURE__ */Fc(_l,e));},ipv6(e){return this.check(/* @__PURE__ */Mc(kl,e));},cidrv4(e){return this.check(/* @__PURE__ */Bc(Il,e));},cidrv6(e){return this.check(/* @__PURE__ */qc($l,e));},e164(e){return this.check(/* @__PURE__ */Kc(El,e));},datetime(e){return this.check(/* @__PURE__ */xo(Jo,e));},date(e){return this.check(/* @__PURE__ */Wc(cl,e));},time(e){return this.check(/* @__PURE__ */Gc(ul,e));},duration(e){return this.check(/* @__PURE__ */Xc(ll,e));}});function p(e){return/* @__PURE__ */zc(al,e);}const L=/* @__PURE__ */g("ZodStringFormat",(e,t)=>{D.init(e,t),qo.init(e,t);}),Jo=/* @__PURE__ */g("ZodISODateTime",(e,t)=>{za.init(e,t),L.init(e,t);}),cl=/* @__PURE__ */g("ZodISODate",(e,t)=>{Ea.init(e,t),L.init(e,t);}),ul=/* @__PURE__ */g("ZodISOTime",(e,t)=>{Aa.init(e,t),L.init(e,t);}),ll=/* @__PURE__ */g("ZodISODuration",(e,t)=>{xa.init(e,t),L.init(e,t);}),dl=/* @__PURE__ */g("ZodEmail",(e,t)=>{fa.init(e,t),L.init(e,t);}),fl=/* @__PURE__ */g("ZodGUID",(e,t)=>{la.init(e,t),L.init(e,t);}),Et=/* @__PURE__ */g("ZodUUID",(e,t)=>{da.init(e,t),L.init(e,t);}),hl=/* @__PURE__ */g("ZodURL",(e,t)=>{va.init(e,t),L.init(e,t);}),pl=/* @__PURE__ */g("ZodEmoji",(e,t)=>{wa.init(e,t),L.init(e,t);}),ml=/* @__PURE__ */g("ZodNanoID",(e,t)=>{ya.init(e,t),L.init(e,t);}),gl=/* @__PURE__ */g("ZodCUID",(e,t)=>{_a.init(e,t),L.init(e,t);}),bl=/* @__PURE__ */g("ZodCUID2",(e,t)=>{ka.init(e,t),L.init(e,t);}),vl=/* @__PURE__ */g("ZodULID",(e,t)=>{Ia.init(e,t),L.init(e,t);}),wl=/* @__PURE__ */g("ZodXID",(e,t)=>{$a.init(e,t),L.init(e,t);}),yl=/* @__PURE__ */g("ZodKSUID",(e,t)=>{Sa.init(e,t),L.init(e,t);}),_l=/* @__PURE__ */g("ZodIPv4",(e,t)=>{Ra.init(e,t),L.init(e,t);}),kl=/* @__PURE__ */g("ZodIPv6",(e,t)=>{Pa.init(e,t),L.init(e,t);}),Il=/* @__PURE__ */g("ZodCIDRv4",(e,t)=>{Ta.init(e,t),L.init(e,t);}),$l=/* @__PURE__ */g("ZodCIDRv6",(e,t)=>{Na.init(e,t),L.init(e,t);}),Sl=/* @__PURE__ */g("ZodBase64",(e,t)=>{Za.init(e,t),L.init(e,t);}),zl=/* @__PURE__ */g("ZodBase64URL",(e,t)=>{Da.init(e,t),L.init(e,t);}),El=/* @__PURE__ */g("ZodE164",(e,t)=>{La.init(e,t),L.init(e,t);}),Al=/* @__PURE__ */g("ZodJWT",(e,t)=>{Fa.init(e,t),L.init(e,t);}),Ho=/* @__PURE__ */g("ZodNumber",(e,t)=>{_o.init(e,t),j.init(e,t),e._zod.processJSONSchema=(n,r,o)=>$u(e,n,r,o),e.isFinite=!0;},/* @__PURE__ */ao({minValue:e=>{const{minimum:t,exclusiveMinimum:n}=ue(e);return Math.max(t??Number.NEGATIVE_INFINITY,n??Number.NEGATIVE_INFINITY);},maxValue:e=>{const{maximum:t,exclusiveMaximum:n}=ue(e);return Math.min(t??Number.POSITIVE_INFINITY,n??Number.POSITIVE_INFINITY);},isInt:e=>{const{isInt:t,multipleOf:n}=ue(e);return!!t||!!(n!=null&&n.some(Number.isSafeInteger));},format:e=>ue(e).format??null},{gt(e,t){return this.check(/* @__PURE__ */vr(e,t));},gte(e,t){return this.check(/* @__PURE__ */rn(e,t));},min(e,t){return this.check(/* @__PURE__ */rn(e,t));},lt(e,t){return this.check(/* @__PURE__ */br(e,t));},lte(e,t){return this.check(/* @__PURE__ */nn(e,t));},max(e,t){return this.check(/* @__PURE__ */nn(e,t));},int(e){return this.check(Ar(e));},safe(e){return this.check(Ar(e));},positive(e){return this.check(/* @__PURE__ */vr(0,e));},nonnegative(e){return this.check(/* @__PURE__ */rn(0,e));},negative(e){return this.check(/* @__PURE__ */br(0,e));},nonpositive(e){return this.check(/* @__PURE__ */nn(0,e));},multipleOf(e,t){return this.check(/* @__PURE__ */wr(e,t));},step(e,t){return this.check(/* @__PURE__ */wr(e,t));},finite(){return this;}}));function $(e){return/* @__PURE__ */Qc(Ho,e);}const xl=/* @__PURE__ */g("ZodNumberFormat",(e,t)=>{Ma.init(e,t),Ho.init(e,t);});function Ar(e){return/* @__PURE__ */Yc(xl,e);}const Rl=/* @__PURE__ */g("ZodBoolean",(e,t)=>{Ba.init(e,t),j.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Su(e,n,r);});function q(e){return/* @__PURE__ */eu(Rl,e);}const Ol=/* @__PURE__ */g("ZodNull",(e,t)=>{qa.init(e,t),j.init(e,t),e._zod.processJSONSchema=(n,r,o)=>zu(e,n,r);});function Vt(e){return/* @__PURE__ */tu(Ol,e);}const Pl=/* @__PURE__ */g("ZodUnknown",(e,t)=>{Ja.init(e,t),j.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Au();});function wn(){return/* @__PURE__ */nu(Pl);}const Tl=/* @__PURE__ */g("ZodNever",(e,t)=>{Ha.init(e,t),j.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Eu(e,n,r);});function Cl(e){return/* @__PURE__ */ru(Tl,e);}const Nl=/* @__PURE__ */g("ZodArray",(e,t)=>{bt(),Wa.init(e,t),j.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Tu(e,n,r,o),e.element=t.element;},{min(e,t){return this.check(/* @__PURE__ */Zt(e,t));},nonempty(e){return this.check(/* @__PURE__ */Zt(1,e));},max(e,t){return this.check(/* @__PURE__ */Ro(e,t));},length(e,t){return this.check(/* @__PURE__ */Oo(e,t));},unwrap(){return this.element;}});function z(e,t){return/* @__PURE__ */mu(Nl,e,t);}const Ko=/* @__PURE__ */g("ZodObject",(e,t)=>{bt(),Qa.init(e,t),j.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Cu(e,n,r,o),Vi(e,"shape",n=>n._zod.def.shape,!1);},{keyof(){return S(Object.keys(this._zod.def.shape));},catchall(e){return this.clone(ae(this._zod.def,{catchall:e}));},passthrough(){return this.clone(ae(this._zod.def,{catchall:wn()}));},loose(){return this.clone(ae(this._zod.def,{catchall:wn()}));},strict(){return this.clone(ae(this._zod.def,{catchall:Cl()}));},strip(){return this.clone(ae(this._zod.def,{catchall:void 0}));},extend(e){return ji(this,e);},safeExtend(e){return Di(this,e);},merge(e){return Li(this,e);},pick(e){return Ni(this,e);},omit(e){return Zi(this,e);},partial(...e){return Gn(Fn,this,e[0]);},exactPartial(...e){return Gn(Go,this,e[0],"exactPartial");},required(...e){return Ui(Xo,this,e[0]);}});function w(e,t){const n={type:"object",shape:e??{},...I(t)};return new Ko(n);}function xr(e,t){return new Ko({type:"object",shape:e,catchall:wn(),...I(t)});}const Vo=/* @__PURE__ */g("ZodUnion",(e,t)=>{$o.init(e,t),j.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Nu(e,n,r,o),e.options=t.options;});function Wo(e,t){return new Vo({type:"union",options:e,...I(t)});}const Zl=/* @__PURE__ */g("ZodDiscriminatedUnion",(e,t)=>{Vo.init(e,t),ec.init(e,t);});function Te(e,t,n){return new Zl({type:"union",options:t,discriminator:e,...I(n)});}const jl=/* @__PURE__ */g("ZodIntersection",(e,t)=>{tc.init(e,t),j.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Zu(e,n,r,o);});function Dl(e,t){return new jl({type:"intersection",left:e,right:t});}const Ll=/* @__PURE__ */g("ZodTuple",(e,t)=>{bt(),nc.init(e,t),j.init(e,t),e._zod.processJSONSchema=(n,r,o)=>ju(e,n,r,o);},{rest(e){return this.clone({...this._zod.def,rest:e});},partial(){var t;const e=this._zod.def;if((t=e.checks)!=null&&t.length)throw new Error(".partial() cannot be used on tuple schemas containing refinements");return this.clone({...e,items:e.items.map(n=>new Fn({type:"optional",innerType:n}))});}});function If(e,t,n){const r=t instanceof Z,o=r?n:t,i=r?t:null;return new Ll({type:"tuple",items:e,rest:i,...I(o)});}const Rr=/* @__PURE__ */g("ZodRecord",(e,t)=>{bt(),rc.init(e,t),j.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Lu(e,n,r,o),e.keyType=t.keyType,e.valueType=t.valueType;});function Ul(e,t,n){return!t||!t._zod?new Rr({type:"record",keyType:p(),valueType:e,...I(t)}):new Rr({type:"record",keyType:e,valueType:t,...I(n)});}const yn=/* @__PURE__ */g("ZodEnum",(e,t)=>{oc.init(e,t),j.init(e,t),e._zod.processJSONSchema=(r,o,i)=>xu(e,r,o),e.enum=t.entries,e.options=[...e._zod.values];const n=new Set(Object.keys(t.entries));e.extract=(r,o)=>{const i={};for(const s of r)if(n.has(s))i[s]=t.entries[s];else throw new Error(`Key ${s} not found in enum`);return new yn({...t,checks:[],...I(o),entries:i});},e.exclude=(r,o)=>{const i={...t.entries};for(const s of r)if(n.has(s))delete i[s];else throw new Error(`Key ${s} not found in enum`);return new yn({...t,checks:[],...I(o),entries:i});};});function S(e,t){const n=Array.isArray(e)?Object.fromEntries(e.map(r=>[r,r])):e;return new yn({type:"enum",entries:n,...I(t)});}const Fl=/* @__PURE__ */g("ZodLiteral",(e,t)=>{ic.init(e,t),j.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Ru(e,n,r,o),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0];}});});function b(e,t){return new Fl({type:"literal",values:Array.isArray(e)?e:[e],...I(t)});}const Ml=/* @__PURE__ */g("ZodTransform",(e,t)=>{bt(),sc.init(e,t),j.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Pu(e,n,r,o),e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new co(e.constructor.name);n.addIssue=i=>{if(typeof i=="string")n.issues.push(pt(i,n.value,t));else{const s=i;s.fatal&&(s.continue=!1),s.code??(s.code="custom"),"input"in s||(s.input=n.value),s.inst??(s.inst=e),n.issues.push(pt(s));}};const o=t.transform(n.value,n);return o instanceof Promise?o.then(i=>(n.value=i,n)):(n.value=o,n);};});function Bl(e){return new Ml({type:"transform",transform:e});}const Fn=/* @__PURE__ */g("ZodOptional",(e,t)=>{So.init(e,t),j.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Bo(e,n,r,o),e.unwrap=()=>e._zod.def.innerType;});function Or(e){return new Fn({type:"optional",innerType:e});}const Go=/* @__PURE__ */g("ZodExactOptional",(e,t)=>{ac.init(e,t),j.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Bo(e,n,r,o),e.unwrap=()=>e._zod.def.innerType;});function ql(e){return new Go({type:"optional",innerType:e});}const Jl=/* @__PURE__ */g("ZodNullable",(e,t)=>{cc.init(e,t),j.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Uu(e,n,r,o),e.unwrap=()=>e._zod.def.innerType;});function Pr(e){return new Jl({type:"nullable",innerType:e});}const Hl=/* @__PURE__ */g("ZodDefault",(e,t)=>{uc.init(e,t),j.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Mu(e,n,r,o),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap;});function Kl(e,t){return new Hl({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():no(t);}});}const Vl=/* @__PURE__ */g("ZodPrefault",(e,t)=>{lc.init(e,t),j.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Bu(e,n,r,o),e.unwrap=()=>e._zod.def.innerType;});function Wl(e,t){return new Vl({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():no(t);}});}const Xo=/* @__PURE__ */g("ZodNonOptional",(e,t)=>{dc.init(e,t),j.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Fu(e,n,r,o),e.unwrap=()=>e._zod.def.innerType;});function Gl(e,t){return new Xo({type:"nonoptional",innerType:e,...I(t)});}const Xl=/* @__PURE__ */g("ZodCatch",(e,t)=>{fc.init(e,t),j.init(e,t),e._zod.processJSONSchema=(n,r,o)=>qu(e,n,r,o),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap;});function Ql(e,t){return new Xl({type:"catch",innerType:e,catchValue:typeof t=="function"?t:Gi(t)});}const Yl=/* @__PURE__ */g("ZodPipe",(e,t)=>{hc.init(e,t),j.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Ju(e,n,r,o),e.in=t.in,e.out=t.out;});function Tr(e,t){return new Yl({type:"pipe",in:e,out:t// ...util.normalizeParams(params),
|
|
146
|
-
});}const ed=/* @__PURE__ */g("ZodReadonly",(e,t)=>{pc.init(e,t),j.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Hu(e,n,r,o),e.unwrap=()=>e._zod.def.innerType;});function td(e){return new ed({type:"readonly",innerType:e});}const nd=/* @__PURE__ */g("ZodCustom",(e,t)=>{mc.init(e,t),j.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Ou(e,n,r,o);});function rd(e,t={}){return/* @__PURE__ */gu(nd,e,t);}function od(e,t){return/* @__PURE__ */bu(e,t);}function id(e){return/* @__PURE__ */xo(Jo,e);}const sd="0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE";function $f(e){return Dt(e,mi)||Dt(e,sd);}function Sf(e){return(e==null?void 0:e.toLowerCase())??"";}function Dt(e,t){return e.toLowerCase()===t.toLowerCase();}function zf(e,t){return e===null||t===null?e===t:Dt(e,t);}function Ef(e,t){return e.toLowerCase()===t.toLowerCase();}const ad=/^0x[0-9a-fA-F]{40}$/,cd=/^0x[0-9a-fA-F]*$/,ud=/^\d+$/,ld=/^[1-9]\d*$/,ee=p().regex(ad,"Expected a 0x-prefixed 20-byte hex address").transform(e=>e),dd=p().regex(cd,"Expected 0x-prefixed hex data").transform(e=>e),sn=p().regex(ud,"Expected a base-10 unsigned integer string"),Cr=p().regex(ld,"Expected a positive base-10 integer string"),fd=id({offset:!0}),Qo=S(["aegis-direct-v4","kyber"]),Af=S(["exactIn","exactOut"]),hd=S(["enabled","disabled"]),pd=b([1,56,130,8453,57073]),Mn=$().int().positive(),md=w({chainId:Mn,slug:p(),name:p()}),gd=w({ttlSeconds:$().int().min(1).max(600),defaultSlippageBps:$().int().min(0).max(1e4),maxSlippageBps:$().int().min(0).max(1e4)}),et=Ul(p(),ee.optional()),tt=w({routers:z(ee),spenders:z(ee)}),bd=w({1:et,56:et,130:et,8453:et,// Older deployed APIs omit Ink; keep it optional while preserving the
|
|
147
|
-
// registry when a newer /v1/config response includes it.
|
|
148
|
-
57073:et.optional()}),vd=w({1:tt,56:tt,130:tt,8453:tt,57073:tt.optional()}),Nr="0x8ea2C7de60ef1Cd4dcE64ea2DDDe2f99F0127eFC",Yo=w({outputFeeBps:$().int().min(0).max(200),recipient:ee.refine(e=>Dt(e,Nr),`Fee recipient must be ${Nr}`)}),wd=w({schemaVersion:b("1"),chains:z(md).superRefine((e,t)=>{const n=/* @__PURE__ */new Set();e.forEach((r,o)=>{n.has(r.chainId)&&t.addIssue({code:"custom",path:[o,"chainId"],message:"Duplicate chain id."}),n.add(r.chainId);});}),providers:z(Qo),quote:gd,contracts:bd,allowlists:vd,fee:Yo}),yd=w({id:p(),chainId:Mn,address:ee,symbol:p(),displayName:p(),fullName:p(),decimals:$().int().min(0).max(255),priceUsd:$(),iconUrl:p(),stable:q()}),_d=w({tvlUsd:$(),volumeUsd7d:$(),feeApr7d:$()}),kd=w({currency0:ee,currency1:ee,fee:$().int(),tickSpacing:$().int(),hooks:ee}),Id=/^evm_(\d+)_(0x[0-9a-fA-F]{40})$/;function $d(e){const t=Id.exec(e);return t?`evm_${t[1]}_${t[2].toLowerCase()}`:e;}const Sd=w({id:p().transform($d),chainId:Mn,status:hd,kind:b("aegis-direct-v4"),label:p(),baseToken:ee,quoteToken:ee,poolId:dd,poolKey:kd,metrics:_d,warnings:z(S(["paused","surge-active","cap-event"]))}),Zr={chainId:pd,provider:Qo,marketId:p().optional(),tokenIn:ee,tokenOut:ee,slippageBps:$().int().min(0).max(2e3),account:ee.nullable().optional()},xf=Te("mode",[xr({...Zr,mode:b("exactIn"),amountIn:Cr}),xr({...Zr,mode:b("exactOut"),amountOut:Cr})]),zd=w({indicative:b(!0),executable:b(!1),provider:b("aegis-direct-v4"),marketId:p(),mode:b("exactIn"),tokenIn:ee,tokenOut:ee,amountIn:sn,amountOut:sn,minAmountOut:sn,price:$(),slippageBps:$(),fee:Yo,asOf:fd,warnings:z(p())}),Ed=w({ok:q()}),jr=z(yd),Ad=z(Sd);function Rf(e,t){e.pointCount!==e.points.length&&t.addIssue({code:"custom",path:["pointCount"],message:"pointCount must match points.length."});const n=e.points.length===0?"no_data":e.points.length===1?"warming_up":"ready";e.status!==n&&t.addIssue({code:"custom",path:["status"],message:`status must be ${n} for ${e.points.length} point(s).`});for(let r=1;r<e.points.length;r+=1)if(e.points[r].t<=e.points[r-1].t){t.addIssue({code:"custom",path:["points",r,"t"],message:"History timestamps must be strictly increasing."});break;}}class Dr extends Error{constructor(n,r){super(`${n} response exceeds the ${r}-byte safety limit.`);ie(this,"resource");ie(this,"maximumBytes");this.name="AegisResponseBodyTooLargeError",this.resource=n,this.maximumBytes=r;}}function xd(e){const t=e.headers.get("content-length");if(t===null)return null;const n=Number(t);return Number.isSafeInteger(n)&&n>=0?n:null;}async function ei(e,t,n){const r=xd(e);if(r!==null&&r>t)throw new Dr(n,t);if(!e.body)return new Uint8Array();const o=e.body.getReader(),i=[];let s=0;for(;;){const{done:l,value:u}=await o.read();if(l)break;if(s+=u.byteLength,s>t)throw await o.cancel().catch(()=>{}),new Dr(n,t);i.push(u);}const a=new Uint8Array(s);let c=0;for(const l of i)a.set(l,c),c+=l.byteLength;return a;}async function Rd(e,t,n){if(!(e instanceof Response))return e;const r=await ei(e,t,n);return new Response(e.body===null?null:r,{status:e.status,statusText:e.statusText,headers:e.headers});}async function Of(e,t,n){if(!(e instanceof Response))return e.json();const r=await ei(e,t,n),o=new TextDecoder().decode(r);return JSON.parse(o);}const Pf="https://nlkvpvkx9h.execute-api.us-east-1.amazonaws.com/prod";class ti extends Error{constructor({status:n,statusText:r,body:o,retryAfterSeconds:i=null}){const s=!o||typeof o!="object"?"":"message"in o?`: ${String(o.message)}`:"error"in o?`: ${String(o.error)}`:"";super(`Aegis backend API error ${n}${s||`: ${r||"Request failed"}`}`);ie(this,"status");ie(this,"statusText");ie(this,"body");ie(this,"retryAfterSeconds");this.name="AegisBackendApiError",this.status=n,this.statusText=r,this.body=o,this.retryAfterSeconds=i;}}class _n extends Error{constructor({endpoint:n,issues:r}){const o=r[0],i=o?`: ${o.path.length>0?o.path.join("."):"(root)"} ${o.message}`:"";super(`Aegis backend response violated the V1 contract at ${n}${i}`);ie(this,"endpoint");ie(this,"issues");this.name="AegisBackendContractError",this.endpoint=n,this.issues=r;}}function Tf(e){return e instanceof ti?e.status===429||e.status>=500:e instanceof _n?!1:e instanceof TypeError?!0:e instanceof Error&&(e.name==="AbortError"||e.name==="TimeoutError");}function ni(e){const t=e.trim().replace(/\/+$/,"");return t.endsWith("/v1")?t.slice(0,-3):t;}function an(e){return String(e);}function Le(e,t,n=!1){return{Accept:"application/json",...(n?{"Content-Type":"application/json"}:{}),...e,...(t==null?void 0:t.headers)};}function Od(e){return e.method!=="GET"&&e.method!=="HEAD"&&e.body!==null;}async function Pd(e){const t=await e.clone().text();return t.length>0?t:void 0;}function Td(e){const t=new URL(e).pathname;return t.endsWith("/v1/health")?16*1024:t.endsWith("/v1/config")?256*1024:t.includes("/v1/tokens")||t.endsWith("/v1/markets")?1024*1024:256*1024;}function Cd(e){return async t=>{const n=Od(t)?await Pd(t):void 0,r=await e(t.url,{body:n,cache:t.cache,credentials:t.credentials,headers:Object.fromEntries(t.headers.entries()),integrity:t.integrity,keepalive:t.keepalive,method:t.method,mode:t.mode,redirect:t.redirect,referrer:t.referrer,referrerPolicy:t.referrerPolicy,signal:t.signal});return Rd(r,Td(t.url),new URL(t.url).pathname);};}function Ue(e){return Qr({signal:e==null?void 0:e.signal,timeoutMs:e==null?void 0:e.timeoutMs,timeoutMessage:"Aegis backend request timed out."});}async function Fe(e,t,n,r,o){try{let i;try{i=await t;}catch(a){throw a instanceof SyntaxError?new _n({endpoint:e,issues:[{code:"custom",path:[],message:"Response body is not valid JSON",input:void 0}]}):a;}if(i.error!==void 0||!i.response.ok)throw new ti({status:i.response.status,statusText:i.response.statusText,body:i.error});if(!r)return i.data;const s=n.safeParse(i.data);if(!s.success)throw new _n({endpoint:e,issues:s.error.issues});return s.data;}finally{o();}}function Cf(e){if(!e.baseUrl.trim())throw new Error("Aegis backend baseUrl is required.");const t=ni(e.baseUrl),n=e.fetch??globalThis.fetch,r=e.validate??!0;if(typeof n!="function")throw new Error("Aegis backend API client requires a fetch implementation.");const o=_i({baseUrl:t,fetch:Cd(n)});return{health:i=>{const{signal:s,cleanup:a}=Ue(i);return Fe("/v1/health",o.GET("/v1/health",{headers:Le(e.headers,i),signal:s}),Ed,r,a);},config:i=>{const{signal:s,cleanup:a}=Ue(i);return Fe("/v1/config",o.GET("/v1/config",{headers:Le(e.headers,i),signal:s}),wd,r,a);},tokens:({chainId:i},s)=>{const{signal:a,cleanup:c}=Ue(s);return Fe("/v1/tokens",o.GET("/v1/tokens",{params:{query:{chainId:an(i)}},headers:Le(e.headers,s),signal:a}),jr,r,c);},tokensByAddress:({chainId:i,addresses:s},a)=>{const{signal:c,cleanup:l}=Ue(a);return Fe("/v1/tokens/by-address",o.GET("/v1/tokens/by-address",{params:{query:{chainId:an(i),addresses:s.join(",")}},headers:Le(e.headers,a),signal:c}),jr,r,l);},markets:({chainId:i},s)=>{const{signal:a,cleanup:c}=Ue(s);return Fe("/v1/markets",o.GET("/v1/markets",{params:{query:{chainId:an(i)}},headers:Le(e.headers,s),signal:a}),Ad,r,c);},quote:(i,s)=>{const{signal:a,cleanup:c}=Ue(s);return Fe("/v1/swap/quote",o.POST("/v1/swap/quote",{body:i,headers:Le(e.headers,s,!0),signal:a}),zd,r,c);}};}p().regex(/^0x[0-9a-f]{40}$/);const Nd=p().regex(/^0x[0-9a-f]{64}$/),te=p().max(78).regex(/^(0|[1-9][0-9]*)$/).refine(e=>e.length<=78&&/^(0|[1-9][0-9]*)$/.test(e)&&BigInt(e)<2n**256n,"Must fit uint256"),Ie=w({blockNumber:$().int().nonnegative().max(Number.MAX_SAFE_INTEGER),blockHash:Nd,blockTimestamp:$().int().nonnegative().max(253402300799),deployment:p().min(1).max(256)}).strict(),Zd="engine-portfolio-v1",be=[1,56,130,8453,4663,57073],lt=be.length*50,ye=p().regex(/^0x[0-9a-f]{40}$/),jd=p().regex(/^0x[0-9a-f]{64}$/),dt=p().max(230).regex(/^-?(0|[1-9][0-9]*)\.[0-9]{18}$/),vt=z(p().min(1).max(80)).max(32),Wt=w({account:p().regex(/^0x[0-9a-fA-F]{40}$/).transform(e=>e.toLowerCase()),chainIds:p().max(32).regex(new RegExp(`^[0-9]+(,[0-9]+){0,${be.length-1}}$`)).transform(e=>e.split(",").map(Number)).refine(e=>new Set(e).size===e.length&&e.every(t=>be.includes(t)),"chainIds must contain distinct supported Engine chains").transform(e=>e.sort((t,n)=>t-n))}),Nf=Wt.extend({snapshotId:p().uuid(),cursor:p().max(512).optional(),limit:p().regex(/^[1-9][0-9]?$/).transform(Number).refine(e=>e<=50).default(25)}),Dd=w({usd:dt.nullable(),knownUsd:dt,reasons:vt}).strict(),fe=Dd,ri=w({id:p().max(180),chainId:$().int(),address:ye,decimals:$().int().min(0).max(255).nullable(),symbol:p().max(64).nullable(),status:S(["observed","assumed","unavailable"]),priceUsd:p().max(280).regex(/^(0|[1-9][0-9]*)\.[0-9]{18,146}$/).nullable(),reasons:vt,source:S(["coingecko","configured_peg","pool","cross_chain","custom"]).nullable(),observedAt:p().datetime().nullable(),fetchedAt:p().datetime().nullable(),resolvedAt:p().datetime().nullable(),recordedAt:p().datetime().nullable(),effectiveObservedAt:p().datetime().nullable(),assumptions:z(p()).max(4),dependencies:z(w({tokenId:p(),effectiveObservedAt:p().datetime().nullable()}).strict()).max(1)}).strict(),At=w({amount0Raw:te,amount1Raw:te}).strict().nullable(),oi=w({id:p().max(256),kind:S(["borrow_vault","lend_shares"]),chainId:$().int(),engine:ye,vaultRegistry:ye,vaultId:te.nullable(),poolId:jd,token0:ye.nullable(),token1:ye.nullable(),status:S(["complete","partial","unavailable"]),reasons:vt,basis:S(["spot-token-amounts","interest-preview-estimate"]),amounts:w({idle:At,debt:At,attachedPrincipal:At,supply:At,debtLRaw:te.nullable(),shareBalanceRaw:te.nullable(),totalSharesRaw:te.nullable(),equityLWadRaw:te.nullable()}).strict(),metrics:w({idleUsd:fe,attachedPrincipalUsd:fe,attachedFeesUsd:fe,grossAssetsUsd:fe,debtUsd:fe,netEquityUsd:fe,supplyUsd:fe}).strict(),risk:w({ltvPips:te.nullable(),maxLtvPips:$().int(),hardLtvPips:$().int()}).strict().nullable()}).strict(),Ld=w({grossAssetsUsd:fe,debtUsd:fe,netEquityUsd:fe,supplyUsd:fe,knownPricedAssetsUsd:dt,knownDebtUsd:dt,knownNetSubtotalUsd:dt,positionCount:$().int().nonnegative(),completePositionCount:$().int().nonnegative()}).strict(),Ud=w({chainId:$().int(),version:p(),engine:ye,vaultRegistry:ye,status:S(["complete","partial","unavailable"]),discoveryComplete:q(),reasons:vt,discoveryCounts:w({evaluatedRowCount:$().int().nonnegative(),returnedPositionCount:$().int().nonnegative(),rejectedRows:w({borrowVaults:$().int().nonnegative(),lenderShares:$().int().nonnegative()}).strict()}).strict().nullable(),frame:Ie.nullable(),canonicality:S(["checked-at-read","unavailable"]),finality:b("indexed-head-not-finalized"),checkedAt:p().datetime().nullable()}).strict(),Fd=w({schemaVersion:b("1"),scope:b("aegis-engine"),valuationModel:b(Zd),snapshotId:p().uuid(),account:ye,chainIds:z($().int()).min(1).max(be.length),createdAt:p().datetime(),expiresAt:p().datetime(),status:S(["complete","partial"]),summary:Ld,chains:z(Ud).max(be.length),prices:z(ri).max(lt*2),positions:z(oi).max(lt)}).strict(),ii=w({snapshotId:p().uuid(),account:ye,chainIds:z($().int()),expiresAt:p().datetime(),positions:z(oi).max(50),nextCursor:p().nullable(),total:$().int().nonnegative()}).strict(),Md=Fd.omit({positions:!0}).extend({freshness:w({status:S(["fresh","stale"]),lastAttemptAt:p().datetime(),refreshOutcome:S(["refreshed","cached","pending","failed"]),reasons:vt}).strict(),page:ii}).strict();w({error:b("Engine portfolio unavailable"),code:p()}).strict();const Bd=4*1024*1024,qd=2*1024*1024;class ne extends Error{constructor(n,r=503,o=null){super(n==="snapshot-expired"?"The portfolio snapshot expired. Refresh to load a new snapshot.":"Engine account data is unavailable.");ie(this,"name","AegisEngineAccountReadError");this.code=n,this.status=r,this.retryAfterSeconds=o;}}function Jd(e,t=999){const n=e&&/^\d+$/.test(e)?Number(e):e&&/^[A-Za-z]{3}, /.test(e)?Math.max(0,Math.ceil((Date.parse(e)-Date.now())/1e3)):NaN;return Number.isFinite(n)?Math.min(n,t):null;}function N(){throw new ne("invalid-response");}function si(e,t){return e.length===t.length&&e.every((n,r)=>n===t[r]);}async function wt(e,t){const n=Wt.safeParse({account:e.account,chainIds:[...e.chainIds].sort((s,a)=>s-a).join(",")});if(!n.success)throw new ne("invalid-query",400);const r=e.source.timeoutMs??15e3;if(!Number.isFinite(r)||r<=0||r>12e4)throw new RangeError("Account request timeout must be between 1 and 120000 milliseconds.");const{signal:o,cleanup:i}=Qr({signal:e.signal,timeoutMs:r,timeoutMessage:"Engine account request timed out."});try{return o==null||o.throwIfAborted(),await t({input:e,query:n.data,baseUrl:ni(e.source.baseUrl),signal:o,remainingBytes:Bd});}finally{i();}}async function We(e,t,n,r,o={}){var f,m,v,k,_,y,x,A;const i=o.responseLimit??qd,s=new URLSearchParams({account:e.query.account,...(o.omitChainIds?{}:{chainIds:e.query.chainIds.join(",")}),...n});(f=e.signal)==null||f.throwIfAborted();const a=await fetch(`${e.baseUrl}/v1/engine/${t}?${s}`,{headers:e.input.source.headers,signal:e.signal,cache:"no-store"});if(!a.ok){(m=a.body)==null||m.cancel().catch(()=>{});const B=a.headers.get("retry-after"),C=Jd(B),P=a.status===410?"snapshot-expired":a.status===404?"service-unavailable":a.status===429?"rate-limited":"upstream-unavailable";throw new ne(P,a.status,C);}const c=Number(a.headers.get("content-length"));if(Number.isFinite(c)&&c>Math.min(i,e.remainingBytes))throw(v=a.body)==null||v.cancel().catch(()=>{}),new ne("response-limit-exceeded");const l=(k=a.body)==null?void 0:k.getReader();l||N();const u=[];let h=0;const d=()=>{l.cancel().catch(()=>{});};(_=e.signal)==null||_.addEventListener("abort",d,{once:!0});try{for(;;){(y=e.signal)==null||y.throwIfAborted();const O=await l.read();if((x=e.signal)==null||x.throwIfAborted(),O.done)break;if(h+=O.value.byteLength,e.remainingBytes-=O.value.byteLength,h>i||e.remainingBytes<0)throw new ne("response-limit-exceeded");u.push(O.value);}const B=new Uint8Array(h);let C=0;for(const O of u)B.set(O,C),C+=O.byteLength;let P;try{P=JSON.parse(new TextDecoder().decode(B));}catch{N();}const R=r.safeParse(P);return R.success||N(),R.data;}finally{(A=e.signal)==null||A.removeEventListener("abort",d),l.cancel().catch(()=>{}),l.releaseLock();}}function Lt(e,t){(t.account!==e.query.account||!si(t.chainIds,e.query.chainIds))&&N();}const pe=p().regex(/^0x[0-9a-f]{40}$/),Lr=p().regex(/^0x[0-9a-f]{64}$/),F=$().int().nonnegative().max(Number.MAX_SAFE_INTEGER),kn=te,V=p().max(79).regex(/^(0|-?[1-9][0-9]*)$/).refine(e=>e.length<=79&&/^(0|-?[1-9][0-9]*)$/.test(e)&&BigInt(e)>=-(2n**255n)&&BigInt(e)<2n**255n,"Must fit int256"),ai=S(["vaultCreatedActions","vaultBurnedActions","vaultLockedActions","debtModifiedActions","idleModifiedActions","vaultMicroLiquidatedActions","liquidityModifiedActions","marketShareTransfers"]),Hd=Te("kind",[w({kind:b("vault_created"),owner:pe}).strict(),w({kind:b("vault_burned"),caller:pe}).strict(),w({kind:b("vault_locked"),ltvPips:F}).strict(),w({kind:b("debt_modified"),principalDeltaRequestedRaw:V,principalDeltaActualRaw:V,borrowIndexWad:kn,deltaIdle0Raw:V,deltaIdle1Raw:V}).strict(),w({kind:b("idle_modified"),deltaAmount0Raw:V,deltaAmount1Raw:V}).strict(),w({kind:b("vault_micro_liquidated"),caller:pe,zeroForOne:q(),swapDelta0Raw:V,swapDelta1Raw:V,debtRepaidRlRaw:V,idleDelta0Raw:V,idleDelta1Raw:V,keeperFee0Raw:V,keeperFee1Raw:V,initialLtvPips:F}).strict(),w({kind:S(["deposit","withdraw"]),deltaSharesRaw:V,deltaAmount0Raw:V,deltaAmount1Raw:V}).strict(),w({kind:S(["transfer_in","transfer_out","transfer_self"]),sharesRaw:kn,counterparty:pe}).strict()]),Kd=w({id:p().max(256),chainId:F,engine:pe,sourceId:p().min(1).max(256),sourceCollection:ai,txHash:Lr,blockNumber:F,transactionIndex:F,logIndex:F,timestamp:F,positionId:p().max(256),vaultId:kn.nullable(),poolId:Lr,action:Hd}).strict();Wt.extend({limit:p().regex(/^[1-9][0-9]?$/).transform(Number).refine(e=>e<=50).default(25),cursor:p().min(1).max(8192).optional()});const ci=w({chainId:F,engine:pe,vaultRegistry:pe,version:p().max(16),frame:Ie.nullable(),beforeBlock:F,eventBlock:F.nullable(),beforeLog:F.nullable(),eventTimestamp:F.nullable(),done:q(),unavailable:q()}).strict();w({version:b(1),account:pe,chainIds:z(F).min(1).max(be.length),limit:F.min(1).max(50),expiresAt:p().datetime(),chains:z(ci).min(1).max(be.length),rejectedRows:F}).strict();const Ur=ci.pick({beforeBlock:!0,eventBlock:!0,beforeLog:!0,done:!0}),Vd=w({schemaVersion:b("2"),account:pe,chainIds:z(F),scope:b("currently-owned-vaults-and-account-lending"),ordering:b("chain-execution-order-merged-by-timestamp"),events:z(Kd).max(50),nextCursor:p().nullable(),expiresAt:p().datetime(),coverage:w({status:S(["complete","partial"]),categories:z(ai),returnedEvents:F,candidateRowsRead:F,evaluatedRows:F,rejectedRows:F,rejectedRowsSinceStart:F,exhausted:q(),reasons:z(p()).max(16)}).strict(),chains:z(w({chainId:F,engine:pe,vaultRegistry:pe,frame:Ie.nullable(),status:S(["available","unavailable"]),exhausted:q(),range:w({start:Ur,end:Ur}).strict().nullable(),canonicality:b("indexer-only-not-rpc-verified")}).strict()).max(be.length)}).strict();w({error:b("Engine activity unavailable"),code:p()}).strict();const Be=p().regex(/^0x[0-9a-fA-F]{40}$/).transform(e=>e.toLowerCase()),we=p().regex(/^0x[0-9a-fA-F]{64}$/).transform(e=>e.toLowerCase()),ve=$().int().nonnegative().max(Number.MAX_SAFE_INTEGER),nt=p().max(16).regex(/^0x(0|[1-9a-fA-F][0-9a-fA-F]*)$/).transform(e=>Number(BigInt(e))).pipe(ve);Wt.extend({chainId:p().regex(/^[1-9][0-9]{0,5}$/).transform(Number).refine(e=>be.includes(e)),txHash:we,observedBlockNumber:p().max(16).regex(/^(0|[1-9][0-9]*)$/).transform(Number).pipe(ve).optional(),observedBlockHash:we.optional()}).refine(e=>e.chainIds.includes(e.chainId),"The portfolio chain set must include the transaction chain").refine(e=>e.observedBlockNumber===void 0==(e.observedBlockHash===void 0),"Provide both observed block fields");w({transactionHash:we,from:Be,to:Be.nullable(),blockNumber:nt,blockHash:we,transactionIndex:nt,status:S(["0x0","0x1"]),logs:z(w({address:Be,topics:z(we).max(4),data:p().max(131074).regex(/^0x([0-9a-fA-F]{2})*$/),blockNumber:nt,blockHash:we,transactionHash:we,transactionIndex:nt,logIndex:nt,removed:b(!1)})).max(256)});const Wd=w({schemaVersion:b("1"),chainId:ve,txHash:we,account:Be,chainIds:z(ve).min(1).max(be.length),status:S(["unknown","confirmed","indexing","ready","reverted","reorged","unsupported"]),checkedAt:p().datetime(),retryAfterSeconds:b(5),reasons:z(p().max(80)).max(16),receipt:w({blockNumber:ve,blockHash:we,transactionIndex:ve,from:Be,to:Be.nullable(),succeeded:q(),canonicality:S(["checked-at-read","changed"])}).strict().nullable(),indexed:w({frame:Ie,expectedEvents:ve,acknowledgedEvents:ve}).strict().nullable(),portfolio:w({snapshotId:p().uuid(),createdAt:p().datetime(),expiresAt:p().datetime(),status:S(["complete","partial"]),chainIds:z(ve),frame:Ie,acknowledged:q()}).strict().nullable(),finality:b("checked-at-read-not-finalized")}).strict();w({error:b("Engine transaction status unavailable"),code:p(),status:S(["unavailable","rate_limited"])}).strict();const In=25;function Zf(e){return wt(e,async t=>{var d;const n=await We(t,"portfolio",{},Md);Lt(t,n);const r=f=>{if(Lt(t,f),(f.snapshotId!==n.snapshotId||f.expiresAt!==n.expiresAt||f.total!==n.summary.positionCount||f.total>lt)&&N(),Date.parse(f.expiresAt)<=Date.now())throw new ne("snapshot-expired",410);},o=new Map(n.chains.map(f=>[f.chainId,f]));(o.size!==t.query.chainIds.length||n.chains.length!==o.size||t.query.chainIds.some(f=>!o.has(f)))&&N(),n.summary.completePositionCount>n.summary.positionCount&&N(),r(n.page);const i=[...n.page.positions],s=/* @__PURE__ */new Set();let a=n.page.nextCursor;for(;a!==null;){(s.has(a)||s.size>=lt/In||i.length>=n.page.total)&&N(),s.add(a);const f=await We(t,"portfolio/positions",{snapshotId:n.snapshotId,limit:String(In),cursor:a},ii);r(f),f.positions.length||N(),i.push(...f.positions),i.length>lt&&N(),a=f.nextCursor;}(i.length!==n.page.total||new Set(i.map(f=>f.id)).size!==i.length)&&N();for(const f of i){const m=o.get(f.chainId);(!m||f.engine!==m.engine||f.vaultRegistry!==m.vaultRegistry||f.id!==Wr(f,t.query.account)||f.kind==="borrow_vault"!=(f.vaultId!==null))&&N();}const c=/* @__PURE__ */new Set(),l=/* @__PURE__ */new Set();for(const f of n.prices){const m=`${f.chainId}:${f.address}`;(!o.has(f.chainId)||c.has(f.id)||l.has(m))&&N(),c.add(f.id),l.add(m);}if((d=t.signal)==null||d.throwIfAborted(),Date.parse(n.expiresAt)<=Date.now())throw new ne("snapshot-expired",410);const{page:u,...h}=n;return{...h,positions:i,performance:{status:"unavailable",reason:"cashflow-cost-basis-unavailable"}};});}function jf(e){return wt(e,async t=>{const n=e.limit??In;if(!Number.isInteger(n)||n<1||n>50||e.cursor!==void 0&&(e.cursor.length<1||e.cursor.length>8192))throw new ne("invalid-query",400);const r=await We(t,"positions/activity/v2",{limit:String(n),...(e.cursor?{cursor:e.cursor}:{})},Vd);if(Lt(t,r),Date.parse(r.expiresAt)<=Date.now())throw new ne("snapshot-expired",410);const o=new Map(r.chains.map(i=>[i.chainId,i]));(o.size!==t.query.chainIds.length||r.chains.length!==o.size||t.query.chainIds.some(i=>!o.has(i))||r.events.length>n||r.coverage.returnedEvents!==r.events.length||new Set(r.events.map(i=>i.id)).size!==r.events.length)&&N();for(const i of r.events){["deposit","withdraw","transfer_in","transfer_out","transfer_self"].includes(i.action.kind)!==(i.vaultId===null)&&N();const a=o.get(i.chainId);(!a||i.engine!==a.engine||i.id!==`engine-event:${i.chainId}:${i.engine}:${i.txHash}:${i.logIndex}`)&&N();const c=Wr({kind:i.vaultId===null?"lend_shares":"borrow_vault",chainId:i.chainId,engine:i.engine,vaultRegistry:a.vaultRegistry,vaultId:i.vaultId,poolId:i.poolId},t.query.account);i.positionId!==c&&N();}return r;});}function Df(e){return wt(e,async t=>{var i,s;if(!t.query.chainIds.includes(e.chainId)||!/^0x[0-9a-fA-F]{64}$/.test(e.txHash))throw new ne("invalid-query",400);const n=e.observedReceipt;if(n&&(!Number.isSafeInteger(n.blockNumber)||n.blockNumber<0||!/^0x[0-9a-fA-F]{64}$/.test(n.blockHash)))throw new ne("invalid-query",400);const r=e.txHash.toLowerCase(),o=await We(t,`transactions/${e.chainId}/${r}/status`,n?{observedBlockNumber:String(n.blockNumber),observedBlockHash:n.blockHash.toLowerCase()}:{},Wd);return Lt(t,o),(o.chainId!==e.chainId||o.txHash!==r)&&N(),o.portfolio&&!si(o.portfolio.chainIds,t.query.chainIds)&&N(),o.status==="ready"&&(!((i=o.receipt)!=null&&i.succeeded)||o.receipt.canonicality!=="checked-at-read"||!o.indexed||o.indexed.expectedEvents===0||o.indexed.acknowledgedEvents!==o.indexed.expectedEvents||o.indexed.frame.blockNumber<o.receipt.blockNumber||!((s=o.portfolio)!=null&&s.acknowledged)||o.portfolio.frame.blockNumber<o.receipt.blockNumber||Date.parse(o.portfolio.expiresAt)<=Date.now())&&N(),o;});}const Gd=p().regex(/^0x[0-9a-fA-F]{40}$/).transform(e=>e.toLowerCase()),Xd=p().regex(/^0x[0-9a-fA-F]{64}$/).transform(e=>e.toLowerCase()),Me=Gd,$n=Xd,Qd=$().int().nonnegative().max(Number.MAX_SAFE_INTEGER),_e=te,it=p().max(180).regex(/^-?(0|[1-9][0-9]*)$/),Ne=w({value:it.nullable(),reasons:z(p().max(100))}),ft=p().max(400).regex(/^-?[0-9]+\.[0-9]+$/).nullable(),Yd=w({amount0Raw:_e,amount1Raw:_e}),Fr=w({priceUsd:ft,status:S(["observed","assumed","unavailable"]),source:p().nullable(),effectiveObservedAt:p().datetime().nullable(),reasons:z(p()),assumptions:z(p())}),ef=w({observedAt:p().datetime(),bucketStartedAt:p().datetime(),frame:w({blockNumber:_e,blockHash:$n,blockTimestamp:Qd}),shareBalanceRaw:_e.nullable(),principalRlRaw:_e.nullable(),idle:Yd.nullable(),nftCount:$().int().nonnegative().nullable(),supplyLWad:Ne,debtLWad:Ne,assetsQuoteToken1Raw:Ne,debtQuoteToken1Raw:Ne,equityQuoteToken1Raw:Ne,supplyUsd:ft,debtUsd:ft,equityUsd:ft,token0Price:Fr,token1Price:Fr,reasons:z(p())}),Sn=w({schemaVersion:b("1"),modelVersion:b("engine-position-history-v1"),position:w({id:p(),kind:S(["lend_shares","borrow_vault"]),chainId:$().int(),account:Me,engine:Me,poolId:$n,vaultId:_e.nullable(),scope:S(["account-lending","vault-lifetime"]),indexedOwner:Me.nullable(),createdOwner:Me.nullable(),burned:q().nullable()}),requested:w({window:S(["1d","7d","30d","since-open"]),from:p().datetime().nullable(),to:p().datetime()}),sampling:w({resolutionSeconds:Wo([b(3600),b(86400)]),semantics:b("first-observation-in-bucket"),interpolation:b("none"),canonicality:b("checked-by-writer-at-capture"),finality:b("not-a-finality-verdict")}),coverage:w({status:S(["complete","partial","unavailable"]),reasons:z(p()),from:p().datetime().nullable(),to:p().datetime().nullable(),pointCount:$().int().nonnegative(),gapCount:$().int().nonnegative(),ledgerComplete:q(),ledgerEventCount:$().int().nonnegative(),ledgerFrame:Ie.nullable(),anchorEvidence:S(["rpc-verified","indexed-terminal","unavailable"]),markersTruncated:q(),nextBefore:p().datetime().nullable()}),currency:w({token0:Me.nullable(),token1:Me.nullable(),decimals0:$().int().nullable(),decimals1:$().int().nullable()}),performance:w({basis:S(["native-net-supply-growth","native-borrow-index-accrual"]),from:p().datetime().nullable(),to:p().datetime().nullable(),netSupplyGrowthLWad:Ne,borrowInterestLWad:Ne,historicalUsdPnl:w({value:ft,reasons:z(p())}),includesGas:b(!1),includesExecutionFees:b(!1)}),points:z(ef).max(768),markers:z(w({id:p(),kind:p(),blockNumber:_e,transactionHash:$n,logIndex:$().int().nonnegative(),observedAt:p().datetime(),deltaIdle0Raw:it,deltaIdle1Raw:it,deltaPrincipalRlRaw:it,deltaSharesRaw:it,externalCapital:S(["known","internal","not-applicable","unsupported"]),referencePrice:w({basis:b("debt-action-token-ratio"),numeratorRaw:_e,denominatorRaw:_e}).nullable()})).max(200)}),Ut=p().regex(/^0x[0-9a-f]{40}$/),Mr=p().regex(/^0x[0-9a-f]{64}$/),st=$().int().nonnegative().max(Number.MAX_SAFE_INTEGER),tf=w({version:S(["v0.4.0","v1.0.2","v1.0.3"]),engine:Ut,vaultRegistry:Ut}).strict(),nf=Te("kind",[w({kind:b("lend_shares"),id:p().max(256),poolId:Mr,status:S(["open","closed"]),indexedBalanceRaw:te}).strict(),w({kind:b("borrow_vault"),id:p().max(256),poolId:Mr,vaultId:te,status:S(["open","closed"]),indexedOwner:Ut,createdAt:p().datetime(),burnedAt:p().datetime().nullable(),burnedAtBlockNumber:st.nullable()}).strict()]),rf=w({schemaVersion:b("1"),chainId:st.positive(),account:Ut,deployment:tf,scope:S(["account-lending-and-current-or-last-owned-vaults","account-lending-and-ever-owned-vaults"]),ownershipEpochs:b("unavailable"),ordering:b("vaults-then-lending-by-source-id"),positions:z(nf).max(50),pagination:w({limit:st.min(1).max(50),nextCursor:p().max(2048).nullable(),expiresAt:p().datetime()}).strict(),coverage:w({status:S(["complete","partial"]),exhausted:q(),evaluatedRowCount:st.max(52),returnedPositionCount:st.max(50),reasons:z(b("more-positions")).max(1)}).strict(),freshness:w({source:b("engine-subgraph"),frame:Ie,fetchedAt:p().datetime(),canonicality:b("indexer-only-not-rpc-verified")}).strict()}).strict();w({error:b("Engine history position catalog unavailable"),code:p().max(64)}).strict();function Lf(e){return wt({...e,chainIds:[e.chainId]},async t=>{var s,a;const n=e.window??"7d";if(!["1d","7d","30d","since-open"].includes(n)||!/^0x[0-9a-fA-F]{64}$/.test(e.poolId)||!["lend_shares","borrow_vault"].includes(e.kind)||(e.kind==="borrow_vault"?!/^(0|[1-9][0-9]{0,77})$/.test(e.vaultId)||BigInt(e.vaultId)>=2n**256n:e.vaultId!==void 0)||e.before!==void 0&&(!/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d{3})?Z$/.test(e.before)||!Number.isFinite(Date.parse(e.before))))throw new ne("invalid-query",400);const r=await We(t,"positions/history",{chainId:String(e.chainId),poolId:e.poolId.toLowerCase(),kind:e.kind,window:n,...(e.kind==="borrow_vault"?{vaultId:e.vaultId}:{}),...(e.before?{before:e.before}:{})},Sn,{omitChainIds:!0,responseLimit:4*1024*1024}),o=r.position;(o.account!==t.query.account||o.chainId!==e.chainId||o.poolId!==e.poolId.toLowerCase()||o.kind!==e.kind||o.vaultId!==(e.vaultId??null)||r.requested.window!==n||r.sampling.resolutionSeconds!==(n==="since-open"?86400:3600)||r.coverage.pointCount!==r.points.length||e.before&&Date.parse(r.requested.to)!==Math.floor(Date.parse(e.before)/1e3)*1e3)&&N(),(o.kind==="lend_shares"?o.id!==`engine-lend:${o.chainId}:${o.engine}:${o.account}:${o.poolId}`:!new RegExp(`^engine-vault:${o.chainId}:0x[0-9a-f]{40}:${o.vaultId}$`).test(o.id))&&N(),r.coverage.nextBefore&&(Date.parse(r.coverage.nextBefore)>=Date.parse(r.requested.to)||!r.points.length)&&N();const i=r.points;for(let c=0;c<i.length;c++){const l=i[c],u=Date.parse(l.observedAt);(u!==l.frame.blockTimestamp*1e3||u>=Date.parse(r.requested.to)||c>0&&(u<=Date.parse(i[c-1].observedAt)||BigInt(l.frame.blockNumber)<=BigInt(i[c-1].frame.blockNumber)))&&N();}return(r.coverage.from!==(((s=i[0])==null?void 0:s.observedAt)??null)||r.coverage.to!==(((a=i.at(-1))==null?void 0:a.observedAt)??null))&&N(),r;});}function Uf(e){return wt({...e,chainIds:[e.chainId]},async t=>{const n=e.limit??25,r=e.ownerScope??"current-or-last";if(!["current-or-last","ever-owned"].includes(r)||!Number.isInteger(n)||n<1||n>50||e.cursor!==void 0&&(!e.cursor.length||e.cursor.length>2048))throw new ne("invalid-query",400);const o=await We(t,"positions/history/catalog",{chainId:String(e.chainId),limit:String(n),...(e.ownerScope?{ownerScope:r}:{}),...(e.cursor?{cursor:e.cursor}:{})},rf,{omitChainIds:!0});if((o.scope!==(r==="ever-owned"?"account-lending-and-ever-owned-vaults":"account-lending-and-current-or-last-owned-vaults")||o.chainId!==e.chainId||o.account!==t.query.account||o.pagination.limit!==n||o.positions.length>n||new Set(o.positions.map(i=>i.id)).size!==o.positions.length||o.coverage.returnedPositionCount!==o.positions.length||o.coverage.exhausted!==(o.pagination.nextCursor===null)||o.coverage.status!==(o.coverage.exhausted?"complete":"partial"))&&N(),Date.parse(o.pagination.expiresAt)<=Date.now())throw new ne("snapshot-expired",410);for(const i of o.positions){const s=i.kind==="lend_shares"?`engine-lend:${e.chainId}:${o.deployment.engine}:${o.account}:${i.poolId}`:`engine-vault:${e.chainId}:${o.deployment.vaultRegistry}:${i.vaultId}`;(i.id!==s||(i.kind==="lend_shares"?i.status!==(i.indexedBalanceRaw==="0"?"closed":"open"):r==="current-or-last"&&i.indexedOwner!==o.account||i.status!==(i.burnedAt===null?"open":"closed")||i.burnedAt===null!=(i.burnedAtBlockNumber===null)))&&N();}return o;});}const of="engine-accounting-evidence-v1",Br=64,U=p().regex(/^0x[0-9a-f]{40}$/),Ft=p().regex(/^0x[0-9a-f]{64}$/),W=te,Y=p().max(79).regex(/^(0|-?[1-9][0-9]*)$/),ce=$().int().nonnegative().max(Number.MAX_SAFE_INTEGER),ui=ce.max(253402300799),qe=p().min(1).max(300),zn=z(p().min(1).max(120)).max(64),E=e=>w(e).strict(),se={id:qe,sourceId:qe,sourceCollection:p().max(80),blockNumber:ce,blockTimestamp:ui,transactionHash:Ft,transactionIndex:ce,logIndex:ce,deltaSharesRaw:Y,deltaLiquidityLRaw:Y,deltaPrincipalRlRaw:Y,deltaIdle0Raw:Y,deltaIdle1Raw:Y,deltaNftCount:$().int().min(-1).max(1),borrowIndexWadRaw:W.nullable(),externalCapital:E({status:S(["known","internal","not-applicable","unsupported"]),amount0Raw:Y.nullable(),amount1Raw:Y.nullable()})},sf=Te("kind",[E({...se,kind:b("liquidity_modified"),details:E({account:U,liquidityOrSharesDeltaRaw:Y,deltaAmount0Raw:Y,deltaAmount1Raw:Y})}),E({...se,kind:b("share_transfer"),details:E({from:U,to:U,amountRaw:W,selfTransfer:q()})}),E({...se,kind:b("protocol_fee_minted"),details:E({recipient:U,protocolFeeAmountLWadRaw:W})}),E({...se,kind:b("vault_created"),details:E({owner:U})}),E({...se,kind:b("vault_burned"),details:E({caller:U})}),E({...se,kind:b("vault_locked"),details:E({ltvPipsRaw:W})}),E({...se,kind:b("debt_modified"),details:E({principalDeltaRequestedRaw:Y,debtIdle0Raw:Y,debtIdle1Raw:Y,companionIdleEventIds:z(qe).max(Br),executionPrice:b("unavailable")})}),E({...se,kind:b("idle_modified"),details:E({companionDebtEventIds:z(qe).max(Br),flowAttribution:b("unproven")})}),E({...se,kind:b("idle_donated"),details:E({donor:b("unavailable")})}),E({...se,kind:b("vault_micro_liquidated"),details:E({caller:U,zeroForOne:q(),swapDelta0Raw:Y,swapDelta1Raw:Y,keeperFee0Raw:W,keeperFee1Raw:W,initialLtvPipsRaw:W,borrowIndexSourceEventId:qe.nullable()})}),E({...se,kind:b("nft_attached"),details:E({nftKind:$().int().min(0).max(1),tokenId:W,from:U,liquidityRaw:W})}),E({...se,kind:b("nft_detached"),details:E({nftKind:$().int().min(0).max(1),tokenId:W,to:U})}),E({...se,kind:b("nft_peeled"),details:E({nftKind:$().int().min(0).max(1),tokenId:W,caller:U,xRealizedRaw:W,yRealizedRaw:W,initialLtvPipsRaw:W})})]),af=E({id:qe,schemaVersion:b(1),registry:U,vaultId:W,from:U,to:U,isMint:q(),isBurn:q(),blockNumber:ce,blockHash:Ft,blockTimestamp:ui,transactionHash:Ft,transactionIndex:ce,logIndex:ce}),cf=Te("status",[E({status:b("known"),owner:U}),E({status:S(["unavailable","inactive","not-applicable"]),owner:Vt()})]),uf=Te("type",[E({type:b("engine"),event:sf,ownershipAtEvent:cf}),E({type:b("ownership"),event:af})]),li=E({currency0:U,currency1:U,fee:$().int().min(0).max(16777215),tickSpacing:$().int().min(1).max(32767),hooks:U}),lf=E({schemaVersion:b("1"),modelVersion:b(of),snapshotId:p().uuid(),createdAt:p().datetime(),expiresAt:p().datetime(),position:E({chainId:$().int().positive(),account:U,poolId:Ft,kind:S(["lend_shares","borrow_vault"]),vaultId:W.nullable(),engine:U,registry:U,version:S(["v0.4.0","v1.0.2","v1.0.3"]),key:li,scope:S(["account-lending","vault-lifetime"]),indexedOwner:U.nullable(),createdOwner:U.nullable()}),frame:Ie,anchorEvidence:S(["rpc-verified","indexed-terminal"]),canonicality:b("rpc-checked-at-capture"),finality:b("not-a-finality-verdict"),ledger:E({status:S(["complete","partial"]),exhausted:q(),evaluatedRows:ce,eventCount:ce.max(2e3),completeCategories:z(p()).max(20),requiredCategories:z(p()).max(20),reasons:zn}),ownership:E({status:S(["complete","partial","unavailable","not-applicable"]),transferCount:ce.max(1e3),accountEverOwned:q().nullable(),reasons:zn}),capabilities:E({walletSettlement:b("unavailable"),executionFills:b("unavailable"),historicalUsdPnl:b("unavailable"),historicalNftValues:S(["unavailable","not-applicable"]),transactionCosts:b("unavailable")}),nativePerformance:Sn.shape.performance.extend({historicalUsdPnl:Sn.shape.performance.shape.historicalUsdPnl.extend({value:Vt()})}),recordCount:ce.max(3e3),pageCount:ce.min(1).max(96)}),df=E({snapshotId:p().uuid(),page:ce.max(95),records:z(uf).max(50)}),Ff=lf.extend({freshness:E({status:S(["fresh","stale"]),outcome:S(["refreshed","cached","page","pending","failed"]),reasons:zn}),page:df,nextCursor:p().max(256).nullable()}).strict();E({error:b("Engine accounting unavailable"),code:p().max(120)});function Mf(e){const t=/* @__PURE__ */new Map();return{read(n,r,o){var c;const i=t.get(n);if(!o&&i&&(!i.settled||i.expiresAt>Date.now()))return i.promise;if(i&&t.delete(n),e.maxEntries!==void 0&&t.size>=e.maxEntries){const l=(c=[...t].find(([,u])=>u.settled))==null?void 0:c[0];if(l===void 0)return r();t.delete(l);}const s=r(),a={promise:s,settled:!1,expiresAt:0};return t.set(n,a),s.then(l=>{t.get(n)===a&&(a.settled=!0,a.value=l,a.expiresAt=Date.now()+e.ttlMs);},()=>{t.get(n)===a&&t.delete(n);}),s;},peek(n){const r=t.get(n);return r!=null&&r.settled&&r.expiresAt>Date.now()?r.value:void 0;},clear(){t.clear();}};}function Bf(e){return e?Object.keys(e).sort().map(t=>`${encodeURIComponent(t)}=${encodeURIComponent(e[t]??"")}`).join("&"):"";}function qf(e,t,n){if(!t)return e;const r=()=>t.reason??new DOMException(n,"AbortError");return t.aborted?Promise.reject(r()):new Promise((o,i)=>{const s=()=>i(r());t.addEventListener("abort",s,{once:!0}),e.then(o,i).finally(()=>t.removeEventListener("abort",s));});}const Pt=$().int().nonnegative().max(Number.MAX_SAFE_INTEGER),gt=te,qr=p().max(79).regex(/^(0|-?[1-9][0-9]*)$/).refine(e=>{if(!/^(0|-?[1-9][0-9]*)$/.test(e))return!1;const t=BigInt(e);return t>-(1n<<256n)&&t<1n<<256n;}),ff=p().regex(/^0x[0-9a-f]{40}$/),En=p().regex(/^0x[0-9a-f]{64}$/),Mt=w({amount0Raw:gt,amount1Raw:gt}).strict(),di=w({amount0Raw:qr,amount1Raw:qr}).strict(),Jr=w({phase:S(["open","close"]),transactionHash:En,block:w({number:Pt,hash:En,timestamp:Pt.max(253402300799),transactionIndex:Pt}).strict(),paid:Mt,received:Mt,net:di,executionGasFeeWei:gt}).strict(),Hr={schemaVersion:b("1"),modelVersion:b("closed-tap-token-pnl-v1"),snapshotId:p().uuid(),chainId:Pt,account:ff,poolId:En,vaultId:gt,capturedAt:p().datetime(),expiresAt:p().datetime(),canonicality:b("rpc-checked-at-capture"),finality:b("not-a-finality-verdict")},Jf=Te("status",[w({...Hr,status:b("unavailable"),reason:S(["incomplete-accounting","incomplete-ownership","position-not-closed","unsupported-lifecycle","settlement-unavailable","native-settlement-unavailable"])}).strict(),w({...Hr,status:b("token-pnl"),basis:b("closed-position-wallet-cashflows"),key:li,opening:Jr,closing:Jr,totals:w({paid:Mt,received:Mt,net:di,executionGasFeeWei:gt}).strict(),costs:w({tradingAndBorrowing:b("embedded-in-cashflows"),gasCoverage:b("opening-and-closing-execution-only"),totalTransactionCost:b("unavailable")}).strict(),historicalUsdPnl:Vt(),netEconomicPnl:b("unavailable")}).strict()]).superRefine((e,t)=>{if(t.issues.length)return;const n=()=>t.addIssue({code:"custom",message:"Inconsistent PnL evidence"});if(Date.parse(e.capturedAt)>=Date.parse(e.expiresAt)&&n(),e.status!=="token-pnl")return;const{opening:r,closing:o,totals:i}=e;(r.phase!=="open"||o.phase!=="close"||r.transactionHash===o.transactionHash||o.block.number<r.block.number||o.block.timestamp<r.block.timestamp||o.block.timestamp*1e3>Date.parse(e.capturedAt)+6e4||o.block.number===r.block.number&&(o.block.hash!==r.block.hash||o.block.timestamp!==r.block.timestamp||o.block.transactionIndex<=r.block.transactionIndex)||e.key.currency0>=e.key.currency1||e.key.currency0===`0x${"0".repeat(40)}`)&&n();for(const s of["amount0Raw","amount1Raw"]){for(const a of[r,o,i])BigInt(a.net[s])!==BigInt(a.received[s])-BigInt(a.paid[s])&&n();for(const a of["paid","received","net"])BigInt(i[a][s])!==BigInt(r[a][s])+BigInt(o[a][s])&&n();}BigInt(i.executionGasFeeWei)!==BigInt(r.executionGasFeeWei)+BigInt(o.executionGasFeeWei)&&n();});w({error:b("Engine PnL unavailable"),code:p().max(120)}).strict();const xt=p().max(230).regex(/^-?(0|[1-9][0-9]*)\.[0-9]{18}$/),Kr={schemaVersion:b("1"),modelVersion:b("position-usd-performance-v1"),snapshotId:p().uuid(),portfolioSnapshotId:p().uuid().nullable(),chainId:$().int().positive(),account:p().regex(/^0x[0-9a-f]{40}$/),poolId:p().regex(/^0x[0-9a-f]{64}$/),vaultId:p().regex(/^(0|[1-9][0-9]*)$/),capturedAt:p().datetime(),expiresAt:p().datetime(),canonicality:b("rpc-checked-at-capture"),finality:b("not-a-finality-verdict")},Hf=Te("status",[w({...Kr,status:b("unavailable"),reason:p().min(1).max(120)}).strict(),w({...Kr,status:b("estimated"),positionStatus:S(["open","closed"]),denomination:b("USD"),basis:b("equity-plus-withdrawals-minus-contributions"),roiBasis:b("initial-net-contribution"),asOf:p().datetime(),equityUsd:xt,contributionUsd:xt,withdrawalsUsd:xt,pnlUsd:xt,roiPercent:p().max(230).regex(/^-?(0|[1-9][0-9]*)\.[0-9]{2}$/),costs:w({tradingAndBorrowing:b("embedded-in-equity-and-cashflows"),gas:b("excluded")}).strict(),coverage:b("single-opening-no-intermediate-mutations"),equityFrame:Ie.nullable(),currentPrices:z(ri).max(2),historicalPrices:z(w({phase:S(["open","close"]),address:p().regex(/^0x[0-9a-f]{40}$/),decimals:$().int().min(0).max(255),priceUsd:p().max(280).regex(/^(0|[1-9][0-9]*)\.[0-9]{18,146}$/),transactionTimestamp:$().int().nonnegative(),bucketStart:$().int().nonnegative(),bucketSeconds:b(43200),source:b("historical-token-prices"),observationTime:Vt()}).strict()).max(4),assumptions:z(p()).max(12)}).strict()]).superRefine((e,t)=>{const n=()=>t.addIssue({code:"custom",message:"Inconsistent performance snapshot"});if(Date.parse(e.capturedAt)>=Date.parse(e.expiresAt)&&n(),e.status!=="estimated")return;const r=s=>BigInt(s.replace(".","")),o=r(e.contributionUsd),i=r(e.pnlUsd);if((o<=0n||i!==r(e.equityUsd)+r(e.withdrawalsUsd)-o)&&n(),Date.parse(e.asOf)>Date.parse(e.capturedAt)+6e4||o<=0n)n();else{const a=((i<0n?-i:i)*10000n+o/2n)/o,c=`${i<0n&&a!==0n?"-":""}${a/100n}.${String(a%100n).padStart(2,"0")}`;e.roiPercent!==c&&n();}e.positionStatus==="closed"&&(e.portfolioSnapshotId!==null||e.equityFrame!==null||r(e.equityUsd)!==0n||e.currentPrices.length)&&n(),e.positionStatus==="open"&&(e.portfolioSnapshotId===null||e.equityFrame===null||r(e.withdrawalsUsd)!==0n)&&n();for(const s of e.historicalPrices)(s.bucketStart%s.bucketSeconds!==0||s.transactionTimestamp<s.bucketStart||s.transactionTimestamp>=s.bucketStart+s.bucketSeconds)&&n();});function Kf(e){const t=/* @__PURE__ */new Map(),n=/* @__PURE__ */new Set();for(const r of e){if(n.has(r.id))continue;n.add(r.id);const o=bi(r.chainId,r.txHash);let i=t.get(o);i||(i={id:o,chainId:r.chainId,txHash:r.txHash,timestamp:r.timestamp,blockNumber:r.blockNumber,transactionIndex:r.transactionIndex,status:"indexed",kinds:[],events:[],movements:[],principalChanges:[]},t.set(o,i)),i.events.push(r),i.kinds.includes(r.action.kind)||i.kinds.push(r.action.kind);const s=r.action;let a=null,c="vault-idle";if(s.kind==="idle_modified")a=[s.deltaAmount0Raw,s.deltaAmount1Raw];else if(s.kind==="debt_modified"){a=[s.deltaIdle0Raw,s.deltaIdle1Raw];const l=i.principalChanges.find(u=>u.positionId===r.positionId);l?l.deltaRlRaw=String(BigInt(l.deltaRlRaw)+BigInt(s.principalDeltaActualRaw)):i.principalChanges.push({positionId:r.positionId,deltaRlRaw:s.principalDeltaActualRaw});}else s.kind==="deposit"||s.kind==="withdraw"?(a=[s.deltaAmount0Raw,s.deltaAmount1Raw],c="lending-settlement"):s.kind==="vault_micro_liquidated"&&(a=[s.idleDelta0Raw,s.idleDelta1Raw]);if(a){const l=i.movements.find(u=>u.positionId===r.positionId&&u.scope===c);l?(l.amount0Raw=String(BigInt(l.amount0Raw)+BigInt(a[0])),l.amount1Raw=String(BigInt(l.amount1Raw)+BigInt(a[1]))):i.movements.push({positionId:r.positionId,poolId:r.poolId,scope:c,amount0Raw:a[0],amount1Raw:a[1]});}}for(const r of t.values())r.events.sort((o,i)=>o.logIndex-i.logIndex);return[...t.values()].sort((r,o)=>o.timestamp-r.timestamp||o.chainId-r.chainId||o.blockNumber-r.blockNumber||o.transactionIndex-r.transactionIndex||r.id.localeCompare(o.id));}function Vf(e,t,n=6){if(t===null||!Number.isInteger(t)||t<0||t>255||!/^(0|-?[1-9][0-9]*)$/.test(e)||e.length>80)return{text:"Amount unavailable",exact:e,available:!1};const r=e.startsWith("-"),o=(r?e.slice(1):e).padStart(t+1,"0"),i=t?o.slice(0,-t):o,s=t?o.slice(-t).replace(/0+$/,""):"",a=`${r?"-":""}${i}${s?`.${s}`:""}`,c=Math.max(0,Math.min(18,Math.trunc(n))),l=s.slice(0,c).replace(/0+$/,""),u=BigInt(i).toLocaleString("en-US"),h=i==="0"&&!/[1-9]/.test(l)&&/[1-9]/.test(s),d=c>0?`0.${"0".repeat(c-1)}1`:"1";return{text:h?`${r?"−":""}<${d}`:`${r?"−":""}${u}${l?`.${l}`:""}`,exact:a,available:!0};}function Wf(e,t,n){return n===null?null:e.find(r=>r.chainId===t&&r.address.toLowerCase()===n.toLowerCase())??null;}function Gf(e){return{borrowing:e.filter(t=>t.kind==="borrow_vault"),lending:e.filter(t=>t.kind==="lend_shares")};}function Xf({position:e,account:t,chainId:n,markets:r,snapshot:o,hydration:i,now:s=Date.now()}){if(e.chainId!==n||!o||o.chainId!==n||o.account.toLowerCase()!==t.toLowerCase()||!(i!=null&&i.frame.blockHash)||!Number.isFinite(i.frame.observedAt)||s-i.frame.observedAt>6e4||i.frame.observedAt>s+5e3)return null;const a=r.find(u=>{var h,d;return u.chainId===n&&u.poolId.toLowerCase()===e.poolId&&((h=u.engine)==null?void 0:h.toLowerCase())===e.engine&&((d=u.vaultRegistry)==null?void 0:d.toLowerCase())===e.vaultRegistry;});if(!a)return null;if(e.kind==="borrow_vault"){const u=o.positions.find(d=>d.chainId===n&&d.account.toLowerCase()===t.toLowerCase()&&d.poolId.toLowerCase()===e.poolId&&d.vaultId===e.vaultId),h=u&&i.borrowPositions.find(d=>d.positionId===u.id&&String(d.vaultId)===e.vaultId);return!u||(h==null?void 0:h.status)!=="ok"||h.vault.owner.toLowerCase()!==t.toLowerCase()||h.vault.poolId.toLowerCase()!==e.poolId?null:{kind:"borrow_vault",positionId:u.id,chainId:n,marketId:a.id,poolId:a.poolId,vaultId:h.vaultId};}const c=o.lendPositions.find(u=>u.chainId===n&&u.account.toLowerCase()===t.toLowerCase()&&u.poolId.toLowerCase()===e.poolId),l=c&&i.lendPositions.find(u=>u.positionId===c.id&&u.account.toLowerCase()===t.toLowerCase()&&u.poolId.toLowerCase()===e.poolId);return!c||(l==null?void 0:l.status)!=="ok"||l.shareBalance<=0n?null:{kind:"lend_shares",positionId:c.id,chainId:n,marketId:a.id,poolId:a.poolId};}const hf=w({chainId:$().int().positive().max(Number.MAX_SAFE_INTEGER),account:p().regex(/^0x[0-9a-fA-F]{40}$/),hash:p().regex(/^0x[0-9a-fA-F]{64}$/),replacedHashes:z(p().regex(/^0x[0-9a-fA-F]{64}$/)).max(128).optional(),stage:S(["authorization","action"]).optional(),executionChanged:q().optional(),recoveryAcknowledgedAt:$().int().nonnegative().max(Number.MAX_SAFE_INTEGER).optional(),kind:S(["swap","lend","borrow","trade"]),status:S(["submitted","success","reverted","cancelled"]),title:p().max(160),detail:p().max(256),createdAt:$().int().nonnegative().max(Number.MAX_SAFE_INTEGER)}).strict();function pf(e){return`aegis-engine:transactions:v1:${e.chainId}:${e.account.toLowerCase()}`;}function at(e,t){if(e===null)return[];if(e.length>128*1024)throw new Error("Transaction history is too large.");const n=w({version:b(1),records:z(hf).max(128)}).strict().parse(JSON.parse(e)),r=/* @__PURE__ */new Set();return n.records.map(o=>{const i=o.hash.toLowerCase();if(o.chainId!==t.chainId||o.account.toLowerCase()!==t.account.toLowerCase()||r.has(i))throw new Error("Transaction history scope mismatch.");r.add(i);const{replacedHashes:s,...a}=o;return{...a,hash:i,...(s?{replacedHashes:s.map(c=>c.toLowerCase())}:{}),account:o.account.toLowerCase()};});}function fi(e,t){const n=d=>d.chainId===t.chainId&&d.account.toLowerCase()===t.account.toLowerCase(),r=d=>d.toLowerCase(),o=/* @__PURE__ */new Set([r(t.hash),...(t.replacedHashes??[]).map(r)]),i=[t];let s=!0;for(;s;){s=!1;for(const d of e){if(!n(d)||i.includes(d))continue;const f=[r(d.hash),...(d.replacedHashes??[]).map(r)];if(f.some(m=>o.has(m))){i.push(d);for(const m of f)o.add(m);s=!0;}}}const a=new Set(i.flatMap(d=>d.replacedHashes??[]).map(r)),c=[...new Set(i.map(d=>r(d.hash)))].filter(d=>!a.has(d)),l=c.length?c:[...new Set(i.map(d=>r(d.hash)))],h=[...l.map(d=>{const f=i.filter(y=>r(y.hash)===d),v=f.find(y=>y.status!=="submitted")??f[0],k=i.some(y=>y.executionChanged),_=[...o].filter(y=>y!==d&&!l.includes(y));return{...v,hash:d,// Acknowledgement belongs to this exact hash, never a replacement.
|
|
149
|
-
...(f.some(y=>y.recoveryAcknowledgedAt!==void 0)?{recoveryAcknowledgedAt:Math.max(...f.map(y=>y.recoveryAcknowledgedAt??0))}:{}),createdAt:Math.min(...i.map(y=>y.createdAt)),...(k?{executionChanged:!0}:{}),status:k&&v.status==="success"?"cancelled":v.status,...(_.length?{replacedHashes:_}:{})};}),...e.filter(d=>!i.includes(d))];return[...h.filter(d=>d.status==="submitted"),...h.filter(d=>d.status!=="submitted").slice(0,24)];}class Bn extends Error{constructor(n,r={}){super(n);ie(this,"kind");ie(this,"retryable");this.name="UserFacingError",this.kind=r.kind??"unknown",this.retryable=r.retryable??!0;}}class Gt extends Bn{constructor({hash:n,cause:r,message:o="Transaction status could not be confirmed. Check the explorer before retrying.",kind:i="rpc"}){super(o,{kind:i,retryable:!1});ie(this,"hash");this.name="SubmittedTransactionReceiptError",this.hash=n,Object.defineProperty(this,"cause",{value:r,configurable:!0});}}function mf(e){return e instanceof Gt;}class gf extends Gt{constructor({hash:t}){super({hash:t,message:"Transaction confirmation timed out. Check the explorer before retrying.",kind:"tx-timeout"}),this.name="TransactionReceiptTimeoutError";}}function bf(e){for(let n=e;n&&typeof n=="object";n=n.cause)if(n.code===4001)return!0;const t=e instanceof Error?e.message.toLowerCase():"";return t.includes("user rejected")||t.includes("user denied")||t.includes("rejected the request")||t.includes("request rejected");}const vf="Request rejected.";function wf(e,t){if(e instanceof Gt)return{message:e.message,kind:e.kind,retryable:e.retryable};if(bf(e))return{message:vf,kind:"wallet-rejected",retryable:!0};if(e instanceof Bn)return{message:e.message,kind:e.kind,retryable:e.retryable};if(e&&typeof e=="object"&&e.code==="CHAIN_MISMATCH")return{message:"Switch to the required network.",kind:"wrong-chain",retryable:!0};const n=e instanceof Error?e.message:"";if(!n)return{message:t,kind:"unknown",retryable:!0};const r=n.toLowerCase();return r.includes("wallet_switchethereumchain")||r.includes("wallet_addethereumchain")?{message:"Network switch failed.",kind:"wrong-chain",retryable:!0}:r.includes("insufficient funds")?{message:"Not enough funds for network fees.",kind:"validation",retryable:!1}:r.includes("execution reverted")||r.includes("swap reverted")?{message:"The swap failed. Try again.",kind:"tx-reverted",retryable:!0}:r.includes("token not found")?{message:"This token isn't supported.",kind:"validation",retryable:!1}:r.includes("kyberswap api error")?{message:"Couldn't price this swap. Try again.",kind:"quote",retryable:!0}:{message:t,kind:"unknown",retryable:!0};}function Qf(e,t){return wf(e,t).message;}const Yf=5*6e4,eh=10*6e4;async function th(e){let t=e.hash;try{return await e.publicClient.waitForTransactionReceipt({hash:e.hash,timeout:e.timeoutMs,onReplaced:n=>{var r;t=n.transaction.hash,(r=e.onReplaced)==null||r.call(e,n);}});}catch(n){throw n instanceof Bn&&(n.kind==="tx-reverted"||n.kind==="tx-cancelled")?n:n instanceof gi?new gf({hash:t}):mf(n)?n:new Gt({hash:t,cause:n});}}async function yf(e){let t=e.hash,n=!1;try{const r=await e.publicClient.waitForTransactionReceipt({hash:e.hash,timeout:e.timeoutMs,onReplaced:i=>{t=i.transaction.hash,n||(n=i.reason!=="repriced");}});t=r.transactionHash;const o={...(t===e.hash?{}:{replacesHash:e.hash}),...(n?{executionChanged:!0}:{})};return n?{status:"cancelled",hash:t,receipt:r,...o}:{status:r.status==="reverted"?"reverted":"confirmed",hash:t,receipt:r,...o};}catch{const r={...(t===e.hash?{}:{replacesHash:e.hash}),...(n?{executionChanged:!0}:{})};return{status:"unresolved",hash:t,...r};}}const cn=/* @__PURE__ */new Set();function un(e,t){const n=JSON.stringify({version:1,records:[...e].sort((r,o)=>r.hash.localeCompare(o.hash))});return at(n,t),n;}function Vr(...e){return e.flat().reduce(fi,[]);}function nh({scope:e,storage:t=null}){let n=t;const r={chainId:e.chainId,account:e.account.toLowerCase()};if(!Number.isSafeInteger(r.chainId)||r.chainId<=0||!/^0x[0-9a-f]{40}$/.test(r.account))throw new Error("Invalid transaction history scope.");const o=pf(r);let i={records:[],pending:[],blockingPending:[],acknowledgeable:[],restored:!1,error:!1,checking:!1};const s=/* @__PURE__ */new Set(),a=/* @__PURE__ */new Set();function c(_,y,x=i.checking){const A=_.map(C=>Object.freeze({...C,...(C.replacedHashes?{replacedHashes:[...C.replacedHashes]}:{})})).sort((C,P)=>P.createdAt-C.createdAt||C.hash.localeCompare(P.hash)),B=A.filter(C=>C.status==="submitted"&&C.recoveryAcknowledgedAt===void 0);i=Object.freeze({records:Object.freeze(A),pending:Object.freeze(A.filter(C=>C.status==="submitted")),blockingPending:Object.freeze(B),acknowledgeable:Object.freeze(B.filter(C=>s.has(C.hash))),restored:!0,error:y,checking:x});for(const C of a)C();}function l(){if(n)for(const _ of cn)_(n,o);}function u(_){try{const y=(n==null?void 0:n.getItem(o))??null,x=Vr(i.records,_===void 0?[]:at(_,r),at(y,r)),A=un(x,r),B=!!(n&&A!==y);B&&n.setItem(o,A),c(x,!1),B&&l();}catch{c(i.records,!0);}}function h(_){const[y]=at(un([_],r),r);let x=fi(i.records,y),A=!1;try{x=Vr(at((n==null?void 0:n.getItem(o))??null,r),x),n==null||n.setItem(o,un(x,r));}catch{A=!0;}c(x,A),A||l();}function d(_){const y=i.pending.find(x=>x.hash===_);return i.checking||!s.has(_)||!y?!1:(h({...y,recoveryAcknowledgedAt:Date.now()}),!0);}const f=(_,y)=>{_===n&&y===o&&u();};function m(_){return a.add(_),a.size===1&&cn.add(f),()=>{a.delete(_),a.size||cn.delete(f);};}async function v(_,{signal:y,timeoutMs:x=3e4}={}){var R;if(!Number.isFinite(x)||x<1||x>6e4)throw new RangeError("Recovery timeout must be between 1 and 60000 milliseconds.");if(i.checking||((R=_.chain)==null?void 0:R.id)!==r.chainId||y!=null&&y.aborted)return{checked:0,settled:0};i.restored||u();const A=[...i.pending],B=Date.now()+x;let C=0,P=0;c(i.records,i.error,!0);try{for(const O of A){if(y!=null&&y.aborted||Date.now()>=B)break;if(!i.pending.some(Xe=>Xe.hash===O.hash))continue;const me=Math.min(8e3,B-Date.now());let oe;const Se={status:"unresolved",hash:O.hash},J=await Promise.race([yf({publicClient:_,hash:O.hash,timeoutMs:me}),new Promise(Xe=>{oe=setTimeout(()=>Xe(Se),me);})]).finally(()=>clearTimeout(oe));C++,J.status==="unresolved"&&!(y!=null&&y.aborted)&&s.add(J.hash);const De=O.executionChanged||J.executionChanged,G=J.status==="unresolved"?"submitted":J.status==="confirmed"?De?"cancelled":"success":J.status;J.status==="unresolved"&&J.hash===O.hash&&!J.executionChanged||(h({...O,hash:J.hash,status:G,...(J.hash!==O.hash?{recoveryAcknowledgedAt:void 0}:{}),...(De?{executionChanged:!0}:{}),...(J.hash!==O.hash?{replacedHashes:[...(O.replacedHashes??[]),O.hash]}:{}),...(G==="submitted"?{}:{title:G==="success"?"Transaction confirmed":G==="reverted"?"Transaction reverted":"Transaction cancelled"})}),J.status!=="unresolved"&&P++);}return{checked:C,settled:P};}finally{c(i.records,i.error,!1);}}function k(_){_!==n&&(n=_,u());}return{key:o,getSnapshot:()=>i,subscribe:m,restore:u,setStorage:k,upsert:h,checkPendingTransactions:v,acknowledgeUnresolvedTransaction:d};}export{S as $,ne as A,Kf as B,Gf as C,fi as D,te as E,at as F,Xf as G,un as H,Ef as I,Dt as J,zf as K,Qr as L,xr as M,sd as N,ee as O,Jf as P,dd as Q,sn as R,z as S,th as T,Bn as U,Yf as V,Qf as W,$f as X,Sf as Y,Ul as Z,fd as _,Ff as a,Rf as a0,eh as a1,bf as a2,q as a3,wn as a4,Te as a5,Of as a6,ti as a7,Jd as a8,wf as a9,hd as aA,Ad as aB,gd as aC,Af as aD,Qo as aE,xf as aF,zd as aG,yd as aH,jr as aI,kd as aJ,Cf as aK,Tf as aL,mf as aM,If as aa,Wo as ab,yf as ac,Gd as ad,Xd as ae,Pf as af,_n as ag,be as ah,Nf as ai,ii as aj,Wt as ak,Md as al,Gt as am,gf as an,vf as ao,tt as ap,vd as aq,pd as ar,md as as,wd as at,et as au,bd as av,Yo as aw,Ed as ax,_d as ay,Sd as az,ni as b,Bf as c,qf as d,Mf as e,Hf as f,nh as g,Wr as h,N as i,bi as j,rf as k,b as l,Wf as m,$ as n,w as o,Sn as p,pf as q,We as r,p as s,jf as t,Zf as u,Uf as v,wt as w,Lf as x,Df as y,Vf as z};
|