@mcpcloud/runtime 0.14.0 → 0.15.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.
@@ -1,4 +1,4 @@
1
- /*! @mcpcloud/runtime v0.14.0 — (c) MCPCloud.sh. All rights reserved. SEE LICENSE: https://www.npmjs.com/package/@mcpcloud/runtime */
1
+ /*! @mcpcloud/runtime v0.15.0 — (c) MCPCloud.sh. All rights reserved. SEE LICENSE: https://www.npmjs.com/package/@mcpcloud/runtime */
2
2
  var Yh=Object.defineProperty;var Xh=(e)=>e;function Qh(e,t){this[e]=Xh.bind(null,t)}var ei=(e,t)=>{for(var r in t)Yh(e,r,{get:t[r],enumerable:!0,configurable:!0,set:Qh.bind(t,r)})};var{create:ef,defineProperty:In,getOwnPropertyDescriptor:tf,getOwnPropertyNames:rf,getPrototypeOf:of}=Object,nf=Object.prototype.hasOwnProperty,D=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Cu=(e,t)=>{let r={};for(var o in e)In(r,o,{get:e[o],enumerable:!0});if(t)In(r,Symbol.toStringTag,{value:"Module"});return r},sf=(e,t,r,o)=>{if(t&&typeof t==="object"||typeof t==="function"){for(var n=rf(t),s=0,a=n.length,i;s<a;s++)if(i=n[s],!nf.call(e,i)&&i!==r)In(e,i,{get:((c)=>t[c]).bind(null,i),enumerable:!(o=tf(t,i))||o.enumerable})}return e},On=(e,t,r)=>(r=e!=null?ef(of(e)):{},sf(t||!e||!e.__esModule?In(r,"default",{value:e,enumerable:!0}):r,e));var af=new Set(["https://json-schema.org/draft/2020-12/schema","http://json-schema.org/draft/2020-12/schema"]),Iu=new Set(["https://json-schema.org/draft/2019-09/schema","http://json-schema.org/draft/2019-09/schema"]),cf=new Set(["https://json-schema.org/draft-07/schema","http://json-schema.org/draft-07/schema"]),uf=new Set(["https://json-schema.org/draft-06/schema","http://json-schema.org/draft-06/schema"]);function Ou(e){return typeof e==="string"&&Iu.has(e.replace(/#$/,""))}function Nu(e,t){if(!("$schema"in e)||typeof e.$schema!=="string")return"2020-12";let r=e.$schema.replace(/#$/,"");if(af.has(r))return"2020-12";if(Iu.has(r))return"2019-09";if(cf.has(r)||uf.has(r))return"draft-7";throw Error(`JSON Schema declares an unsupported dialect ("$schema": "${e.$schema.slice(0,200)}"). The default validator supports JSON Schema 2020-12, 2019-09, draft-07, and draft-06; ${t}`)}var ju,ti=Object.freeze({status:"aborted"});function M(e,t,r){function o(i,c){if(!i._zod)Object.defineProperty(i,"_zod",{value:{def:c,constr:a,traits:new Set},enumerable:!1});if(i._zod.traits.has(e))return;i._zod.traits.add(e),t(i,c);let l=a.prototype,m=Object.keys(l);for(let g=0;g<m.length;g++){let z=m[g];if(!(z in i))i[z]=l[z].bind(i)}}let n=r?.Parent??Object;class s extends n{}Object.defineProperty(s,"name",{value:e});function a(i){var c;let l=r?.Parent?new s:this;o(l,i),(c=l._zod).deferred??(c.deferred=[]);for(let m of l._zod.deferred)m();return l}return Object.defineProperty(a,"init",{value:o}),Object.defineProperty(a,Symbol.hasInstance,{value:(i)=>{if(r?.Parent&&i instanceof r.Parent)return!0;return i?._zod?.traits?.has(e)}}),Object.defineProperty(a,"name",{value:e}),a}var lf=Symbol("zod_brand");class dt extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class go extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`);this.name="ZodEncodeError"}}(ju=globalThis).__zod_globalConfig??(ju.__zod_globalConfig={});var pr=globalThis.__zod_globalConfig;function Ge(e){if(e)Object.assign(pr,e);return pr}var Se={};ei(Se,{BIGINT_FORMAT_RANGES:()=>Mu,Class:()=>Uu,NUMBER_FORMAT_RANGES:()=>ci,aborted:()=>Pt,allowsEval:()=>si,assert:()=>ff,assertEqual:()=>df,assertIs:()=>pf,assertNever:()=>hf,assertNotEqual:()=>mf,assignProp:()=>Rt,base64ToUint8Array:()=>Zu,base64urlToUint8Array:()=>Of,cached:()=>fr,captureStackTrace:()=>qn,cleanEnum:()=>If,cleanRegex:()=>vo,clone:()=>tt,cloneDef:()=>_f,createTransparentProxy:()=>$f,defineLazy:()=>_e,esc:()=>jn,escapeRegex:()=>pt,explicitlyAborted:()=>ui,extend:()=>Pf,finalizeIssue:()=>rt,floatSafeRemainder:()=>oi,getElementAtPath:()=>Sf,getEnumValues:()=>So,getLengthableOrigin:()=>bo,getParsedType:()=>zf,getSizableOrigin:()=>Lu,hexToUint8Array:()=>jf,isObject:()=>Gt,isPlainObject:()=>wt,issue:()=>gr,joinValues:()=>Nn,jsonStringifyReplacer:()=>hr,merge:()=>Tf,mergeDefs:()=>mt,normalizeParams:()=>re,nullish:()=>yo,numKeys:()=>bf,objectClone:()=>gf,omit:()=>wf,optionalKeys:()=>ii,parsedType:()=>li,partial:()=>kf,pick:()=>Rf,prefixIssues:()=>ht,primitiveTypes:()=>Au,promiseAllObject:()=>yf,propertyKeyTypes:()=>ai,randomString:()=>vf,required:()=>Cf,safeExtend:()=>Ef,shallowClone:()=>xu,slugify:()=>ni,stringifyPrimitive:()=>xn,uint8ArrayToBase64:()=>Du,uint8ArrayToBase64url:()=>Nf,uint8ArrayToHex:()=>qf,unwrapMessage:()=>_o});function df(e){return e}function mf(e){return e}function pf(e){}function hf(e){throw Error("Unexpected value in exhaustive check")}function ff(e){}function So(e){let t=Object.values(e).filter((o)=>typeof o==="number");return Object.entries(e).filter(([o,n])=>t.indexOf(+o)===-1).map(([o,n])=>n)}function Nn(e,t="|"){return e.map((r)=>xn(r)).join(t)}function hr(e,t){if(typeof t==="bigint")return t.toString();return t}function fr(e){return{get value(){{let r=e();return Object.defineProperty(this,"value",{value:r}),r}throw Error("cached value already set")}}}function yo(e){return e===null||e===void 0}function vo(e){let t=e.startsWith("^")?1:0,r=e.endsWith("$")?e.length-1:e.length;return e.slice(t,r)}function oi(e,t){let r=e/t,o=Math.round(r),n=Number.EPSILON*Math.max(Math.abs(r),1);if(Math.abs(r-o)<n)return 0;return r-o}var qu=Symbol("evaluating");function _e(e,t,r){let o=void 0;Object.defineProperty(e,t,{get(){if(o===qu)return;if(o===void 0)o=qu,o=r();return o},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function gf(e){return Object.create(Object.getPrototypeOf(e),Object.getOwnPropertyDescriptors(e))}function Rt(e,t,r){Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0})}function mt(...e){let t={};for(let r of e){let o=Object.getOwnPropertyDescriptors(r);Object.assign(t,o)}return Object.defineProperties({},t)}function _f(e){return mt(e._zod.def)}function Sf(e,t){if(!t)return e;return t.reduce((r,o)=>r?.[o],e)}function yf(e){let t=Object.keys(e),r=t.map((o)=>e[o]);return Promise.all(r).then((o)=>{let n={};for(let s=0;s<t.length;s++)n[t[s]]=o[s];return n})}function vf(e=10){let r="";for(let o=0;o<e;o++)r+="abcdefghijklmnopqrstuvwxyz"[Math.floor(Math.random()*26)];return r}function jn(e){return JSON.stringify(e)}function ni(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}var qn="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function Gt(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}var si=fr(()=>{if(pr.jitless)return!1;if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{return new Function(""),!0}catch(e){return!1}});function wt(e){if(Gt(e)===!1)return!1;let t=e.constructor;if(t===void 0)return!0;if(typeof t!=="function")return!0;let r=t.prototype;if(Gt(r)===!1)return!1;if(Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)return!1;return!0}function xu(e){if(wt(e))return{...e};if(Array.isArray(e))return[...e];if(e instanceof Map)return new Map(e);if(e instanceof Set)return new Set(e);return e}function bf(e){let t=0;for(let r in e)if(Object.prototype.hasOwnProperty.call(e,r))t++;return t}var zf=(e)=>{let t=typeof e;switch(t){case"undefined":return"undefined";case"string":return"string";case"number":return Number.isNaN(e)?"nan":"number";case"boolean":return"boolean";case"function":return"function";case"bigint":return"bigint";case"symbol":return"symbol";case"object":if(Array.isArray(e))return"array";if(e===null)return"null";if(e.then&&typeof e.then==="function"&&e.catch&&typeof e.catch==="function")return"promise";if(typeof Map<"u"&&e instanceof Map)return"map";if(typeof Set<"u"&&e instanceof Set)return"set";if(typeof Date<"u"&&e instanceof Date)return"date";if(typeof File<"u"&&e instanceof File)return"file";return"object";default:throw Error(`Unknown data type: ${t}`)}},ai=new Set(["string","number","symbol"]),Au=new Set(["string","number","bigint","boolean","symbol","undefined"]);function pt(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function tt(e,t,r){let o=new e._zod.constr(t??e._zod.def);if(!t||r?.parent)o._zod.parent=e;return o}function re(e){let t=e;if(!t)return{};if(typeof t==="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");t.error=t.message}if(delete t.message,typeof t.error==="string")return{...t,error:()=>t.error};return t}function $f(e){let t;return new Proxy({},{get(r,o,n){return t??(t=e()),Reflect.get(t,o,n)},set(r,o,n,s){return t??(t=e()),Reflect.set(t,o,n,s)},has(r,o){return t??(t=e()),Reflect.has(t,o)},deleteProperty(r,o){return t??(t=e()),Reflect.deleteProperty(t,o)},ownKeys(r){return t??(t=e()),Reflect.ownKeys(t)},getOwnPropertyDescriptor(r,o){return t??(t=e()),Reflect.getOwnPropertyDescriptor(t,o)},defineProperty(r,o,n){return t??(t=e()),Reflect.defineProperty(t,o,n)}})}function xn(e){if(typeof e==="bigint")return e.toString()+"n";if(typeof e==="string")return`"${e}"`;return`${e}`}function ii(e){return Object.keys(e).filter((t)=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}var ci={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-340282346638528860000000000000000000000,340282346638528860000000000000000000000],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},Mu={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function Rf(e,t){let r=e._zod.def,o=r.checks;if(o&&o.length>0)throw Error(".pick() cannot be used on object schemas containing refinements");let s=mt(e._zod.def,{get shape(){let a={};for(let i in t){if(!(i in r.shape))throw Error(`Unrecognized key: "${i}"`);if(!t[i])continue;a[i]=r.shape[i]}return Rt(this,"shape",a),a},checks:[]});return tt(e,s)}function wf(e,t){let r=e._zod.def,o=r.checks;if(o&&o.length>0)throw Error(".omit() cannot be used on object schemas containing refinements");let s=mt(e._zod.def,{get shape(){let a={...e._zod.def.shape};for(let i in t){if(!(i in r.shape))throw Error(`Unrecognized key: "${i}"`);if(!t[i])continue;delete a[i]}return Rt(this,"shape",a),a},checks:[]});return tt(e,s)}function Pf(e,t){if(!wt(t))throw Error("Invalid input to extend: expected a plain object");let r=e._zod.def.checks;if(r&&r.length>0){let s=e._zod.def.shape;for(let a in t)if(Object.getOwnPropertyDescriptor(s,a)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}let n=mt(e._zod.def,{get shape(){let s={...e._zod.def.shape,...t};return Rt(this,"shape",s),s}});return tt(e,n)}function Ef(e,t){if(!wt(t))throw Error("Invalid input to safeExtend: expected a plain object");let r=mt(e._zod.def,{get shape(){let o={...e._zod.def.shape,...t};return Rt(this,"shape",o),o}});return tt(e,r)}function Tf(e,t){if(e._zod.def.checks?.length)throw Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");let r=mt(e._zod.def,{get shape(){let o={...e._zod.def.shape,...t._zod.def.shape};return Rt(this,"shape",o),o},get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return tt(e,r)}function kf(e,t,r){let n=t._zod.def.checks;if(n&&n.length>0)throw Error(".partial() cannot be used on object schemas containing refinements");let a=mt(t._zod.def,{get shape(){let i=t._zod.def.shape,c={...i};if(r)for(let l in r){if(!(l in i))throw Error(`Unrecognized key: "${l}"`);if(!r[l])continue;c[l]=e?new e({type:"optional",innerType:i[l]}):i[l]}else for(let l in i)c[l]=e?new e({type:"optional",innerType:i[l]}):i[l];return Rt(this,"shape",c),c},checks:[]});return tt(t,a)}function Cf(e,t,r){let o=mt(t._zod.def,{get shape(){let n=t._zod.def.shape,s={...n};if(r)for(let a in r){if(!(a in s))throw Error(`Unrecognized key: "${a}"`);if(!r[a])continue;s[a]=new e({type:"nonoptional",innerType:n[a]})}else for(let a in n)s[a]=new e({type:"nonoptional",innerType:n[a]});return Rt(this,"shape",s),s}});return tt(t,o)}function Pt(e,t=0){if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(e.issues[r]?.continue!==!0)return!0;return!1}function ui(e,t=0){if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(e.issues[r]?.continue===!1)return!0;return!1}function ht(e,t){return t.map((r)=>{var o;return(o=r).path??(o.path=[]),r.path.unshift(e),r})}function _o(e){return typeof e==="string"?e:e?.message}function rt(e,t,r){let o=e.message?e.message:_o(e.inst?._zod.def?.error?.(e))??_o(t?.error?.(e))??_o(r.customError?.(e))??_o(r.localeError?.(e))??"Invalid input",{inst:n,continue:s,input:a,...i}=e;if(i.path??(i.path=[]),i.message=o,t?.reportInput)i.input=a;return i}function Lu(e){if(e instanceof Set)return"set";if(e instanceof Map)return"map";if(e instanceof File)return"file";return"unknown"}function bo(e){if(Array.isArray(e))return"array";if(typeof e==="string")return"string";return"unknown"}function li(e){let t=typeof e;switch(t){case"number":return Number.isNaN(e)?"nan":"number";case"object":{if(e===null)return"null";if(Array.isArray(e))return"array";let r=e;if(r&&Object.getPrototypeOf(r)!==Object.prototype&&"constructor"in r&&r.constructor)return r.constructor.name}}return t}function gr(...e){let[t,r,o]=e;if(typeof t==="string")return{message:t,code:"custom",input:r,inst:o};return{...t}}function If(e){return Object.entries(e).filter(([t,r])=>Number.isNaN(Number.parseInt(t,10))).map((t)=>t[1])}function Zu(e){let t=atob(e),r=new Uint8Array(t.length);for(let o=0;o<t.length;o++)r[o]=t.charCodeAt(o);return r}function Du(e){let t="";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return btoa(t)}function Of(e){let t=e.replace(/-/g,"+").replace(/_/g,"/"),r="=".repeat((4-t.length%4)%4);return Zu(t+r)}function Nf(e){return Du(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function jf(e){let t=e.replace(/^0x/,"");if(t.length%2!==0)throw Error("Invalid hex string length");let r=new Uint8Array(t.length/2);for(let o=0;o<t.length;o+=2)r[o/2]=Number.parseInt(t.slice(o,o+2),16);return r}function qf(e){return Array.from(e).map((t)=>t.toString(16).padStart(2,"0")).join("")}class Uu{constructor(...e){}}var Vu=(e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,hr,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},An=M("$ZodError",Vu),di=M("$ZodError",Vu,{Parent:Error});function mi(e,t=(r)=>r.message){let r={},o=[];for(let n of e.issues)if(n.path.length>0)r[n.path[0]]=r[n.path[0]]||[],r[n.path[0]].push(t(n));else o.push(t(n));return{formErrors:o,fieldErrors:r}}function pi(e,t=(r)=>r.message){let r={_errors:[]},o=(n,s=[])=>{for(let a of n.issues)if(a.code==="invalid_union"&&a.errors.length)a.errors.map((i)=>o({issues:i},[...s,...a.path]));else if(a.code==="invalid_key")o({issues:a.issues},[...s,...a.path]);else if(a.code==="invalid_element")o({issues:a.issues},[...s,...a.path]);else{let i=[...s,...a.path];if(i.length===0)r._errors.push(t(a));else{let c=r,l=0;while(l<i.length){let m=i[l];if(l!==i.length-1)c[m]=c[m]||{_errors:[]};else c[m]=c[m]||{_errors:[]},c[m]._errors.push(t(a));c=c[m],l++}}}};return o(e),r}var Mn=(e)=>(t,r,o,n)=>{let s=o?{...o,async:!1}:{async:!1},a=t._zod.run({value:r,issues:[]},s);if(a instanceof Promise)throw new dt;if(a.issues.length){let i=new(n?.Err??e)(a.issues.map((c)=>rt(c,s,Ge())));throw qn(i,n?.callee),i}return a.value};var Ln=(e)=>async(t,r,o,n)=>{let s=o?{...o,async:!0}:{async:!0},a=t._zod.run({value:r,issues:[]},s);if(a instanceof Promise)a=await a;if(a.issues.length){let i=new(n?.Err??e)(a.issues.map((c)=>rt(c,s,Ge())));throw qn(i,n?.callee),i}return a.value};var zo=(e)=>(t,r,o)=>{let n=o?{...o,async:!1}:{async:!1},s=t._zod.run({value:r,issues:[]},n);if(s instanceof Promise)throw new dt;return s.issues.length?{success:!1,error:new(e??An)(s.issues.map((a)=>rt(a,n,Ge())))}:{success:!0,data:s.value}},Fu=zo(di),$o=(e)=>async(t,r,o)=>{let n=o?{...o,async:!0}:{async:!0},s=t._zod.run({value:r,issues:[]},n);if(s instanceof Promise)s=await s;return s.issues.length?{success:!1,error:new e(s.issues.map((a)=>rt(a,n,Ge())))}:{success:!0,data:s.value}},Hu=$o(di),Ju=(e)=>(t,r,o)=>{let n=o?{...o,direction:"backward"}:{direction:"backward"};return Mn(e)(t,r,n)};var Bu=(e)=>(t,r,o)=>Mn(e)(t,r,o);var Ku=(e)=>async(t,r,o)=>{let n=o?{...o,direction:"backward"}:{direction:"backward"};return Ln(e)(t,r,n)};var Gu=(e)=>async(t,r,o)=>Ln(e)(t,r,o);var Wu=(e)=>(t,r,o)=>{let n=o?{...o,direction:"backward"}:{direction:"backward"};return zo(e)(t,r,n)};var Yu=(e)=>(t,r,o)=>zo(e)(t,r,o);var Xu=(e)=>async(t,r,o)=>{let n=o?{...o,direction:"backward"}:{direction:"backward"};return $o(e)(t,r,n)};var Qu=(e)=>async(t,r,o)=>$o(e)(t,r,o);var el=/^[cC][0-9a-z]{6,}$/,tl=/^[0-9a-z]+$/,rl=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,ol=/^[0-9a-vA-V]{20}$/,nl=/^[A-Za-z0-9]{27}$/,sl=/^[a-zA-Z0-9_-]{21}$/,al=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;var il=/^([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})$/,hi=(e)=>{if(!e)return/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/;return new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`)};var cl=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;var Af="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function ul(){return new RegExp(Af,"u")}var ll=/^(?:(?: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])$/,dl=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/;var ml=/^((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])$/,pl=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,hl=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,fi=/^[A-Za-z0-9_-]*$/;var fl=/^https?$/,gl=/^\+[1-9]\d{6,14}$/,_l="(?:(?:\\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])))",Sl=new RegExp(`^${_l}$`);function yl(e){return typeof e.precision==="number"?e.precision===-1?"(?:[01]\\d|2[0-3]):[0-5]\\d":e.precision===0?"(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d":`(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d\\.\\d{${e.precision}}`:"(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?"}function vl(e){return new RegExp(`^${yl(e)}$`)}function bl(e){let t=yl({precision:e.precision}),r=["Z"];if(e.local)r.push("");if(e.offset)r.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");let o=`${t}(?:${r.join("|")})`;return new RegExp(`^${_l}T(?:${o})$`)}var zl=(e)=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},$l=/^-?\d+n?$/,Rl=/^-?\d+$/,Zn=/^-?\d+(?:\.\d+)?$/,wl=/^(?:true|false)$/i,Pl=/^null$/i;var El=/^[^A-Z]*$/,Tl=/^[^a-z]*$/;var Le=M("$ZodCheck",(e,t)=>{var r;e._zod??(e._zod={}),e._zod.def=t,(r=e._zod).onattach??(r.onattach=[])}),kl={number:"number",bigint:"bigint",object:"date"},gi=M("$ZodCheckLessThan",(e,t)=>{Le.init(e,t);let r=kl[typeof t.value];e._zod.onattach.push((o)=>{let n=o._zod.bag,s=(t.inclusive?n.maximum:n.exclusiveMaximum)??Number.POSITIVE_INFINITY;if(t.value<s)if(t.inclusive)n.maximum=t.value;else n.exclusiveMaximum=t.value}),e._zod.check=(o)=>{if(t.inclusive?o.value<=t.value:o.value<t.value)return;o.issues.push({origin:r,code:"too_big",maximum:typeof t.value==="object"?t.value.getTime():t.value,input:o.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),_i=M("$ZodCheckGreaterThan",(e,t)=>{Le.init(e,t);let r=kl[typeof t.value];e._zod.onattach.push((o)=>{let n=o._zod.bag,s=(t.inclusive?n.minimum:n.exclusiveMinimum)??Number.NEGATIVE_INFINITY;if(t.value>s)if(t.inclusive)n.minimum=t.value;else n.exclusiveMinimum=t.value}),e._zod.check=(o)=>{if(t.inclusive?o.value>=t.value:o.value>t.value)return;o.issues.push({origin:r,code:"too_small",minimum:typeof t.value==="object"?t.value.getTime():t.value,input:o.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Cl=M("$ZodCheckMultipleOf",(e,t)=>{Le.init(e,t),e._zod.onattach.push((r)=>{var o;(o=r._zod.bag).multipleOf??(o.multipleOf=t.value)}),e._zod.check=(r)=>{if(typeof r.value!==typeof t.value)throw Error("Cannot mix number and bigint in multiple_of check.");if(typeof r.value==="bigint"?r.value%t.value===BigInt(0):oi(r.value,t.value)===0)return;r.issues.push({origin:typeof r.value,code:"not_multiple_of",divisor:t.value,input:r.value,inst:e,continue:!t.abort})}}),Il=M("$ZodCheckNumberFormat",(e,t)=>{Le.init(e,t),t.format=t.format||"float64";let r=t.format?.includes("int"),o=r?"int":"number",[n,s]=ci[t.format];e._zod.onattach.push((a)=>{let i=a._zod.bag;if(i.format=t.format,i.minimum=n,i.maximum=s,r)i.pattern=Rl}),e._zod.check=(a)=>{let i=a.value;if(r){if(!Number.isInteger(i)){a.issues.push({expected:o,format:t.format,code:"invalid_type",continue:!1,input:i,inst:e});return}if(!Number.isSafeInteger(i)){if(i>0)a.issues.push({input:i,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:o,inclusive:!0,continue:!t.abort});else a.issues.push({input:i,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:o,inclusive:!0,continue:!t.abort});return}}if(i<n)a.issues.push({origin:"number",input:i,code:"too_small",minimum:n,inclusive:!0,inst:e,continue:!t.abort});if(i>s)a.issues.push({origin:"number",input:i,code:"too_big",maximum:s,inclusive:!0,inst:e,continue:!t.abort})}});var Ol=M("$ZodCheckMaxLength",(e,t)=>{var r;Le.init(e,t),(r=e._zod.def).when??(r.when=(o)=>{let n=o.value;return!yo(n)&&n.length!==void 0}),e._zod.onattach.push((o)=>{let n=o._zod.bag.maximum??Number.POSITIVE_INFINITY;if(t.maximum<n)o._zod.bag.maximum=t.maximum}),e._zod.check=(o)=>{let n=o.value;if(n.length<=t.maximum)return;let a=bo(n);o.issues.push({origin:a,code:"too_big",maximum:t.maximum,inclusive:!0,input:n,inst:e,continue:!t.abort})}}),Nl=M("$ZodCheckMinLength",(e,t)=>{var r;Le.init(e,t),(r=e._zod.def).when??(r.when=(o)=>{let n=o.value;return!yo(n)&&n.length!==void 0}),e._zod.onattach.push((o)=>{let n=o._zod.bag.minimum??Number.NEGATIVE_INFINITY;if(t.minimum>n)o._zod.bag.minimum=t.minimum}),e._zod.check=(o)=>{let n=o.value;if(n.length>=t.minimum)return;let a=bo(n);o.issues.push({origin:a,code:"too_small",minimum:t.minimum,inclusive:!0,input:n,inst:e,continue:!t.abort})}}),jl=M("$ZodCheckLengthEquals",(e,t)=>{var r;Le.init(e,t),(r=e._zod.def).when??(r.when=(o)=>{let n=o.value;return!yo(n)&&n.length!==void 0}),e._zod.onattach.push((o)=>{let n=o._zod.bag;n.minimum=t.length,n.maximum=t.length,n.length=t.length}),e._zod.check=(o)=>{let n=o.value,s=n.length;if(s===t.length)return;let a=bo(n),i=s>t.length;o.issues.push({origin:a,...i?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:o.value,inst:e,continue:!t.abort})}}),wo=M("$ZodCheckStringFormat",(e,t)=>{var r,o;if(Le.init(e,t),e._zod.onattach.push((n)=>{let s=n._zod.bag;if(s.format=t.format,t.pattern)s.patterns??(s.patterns=new Set),s.patterns.add(t.pattern)}),t.pattern)(r=e._zod).check??(r.check=(n)=>{if(t.pattern.lastIndex=0,t.pattern.test(n.value))return;n.issues.push({origin:"string",code:"invalid_format",format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})});else(o=e._zod).check??(o.check=()=>{})}),ql=M("$ZodCheckRegex",(e,t)=>{wo.init(e,t),e._zod.check=(r)=>{if(t.pattern.lastIndex=0,t.pattern.test(r.value))return;r.issues.push({origin:"string",code:"invalid_format",format:"regex",input:r.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),xl=M("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=El),wo.init(e,t)}),Al=M("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=Tl),wo.init(e,t)}),Ml=M("$ZodCheckIncludes",(e,t)=>{Le.init(e,t);let r=pt(t.includes),o=new RegExp(typeof t.position==="number"?`^.{${t.position}}${r}`:r);t.pattern=o,e._zod.onattach.push((n)=>{let s=n._zod.bag;s.patterns??(s.patterns=new Set),s.patterns.add(o)}),e._zod.check=(n)=>{if(n.value.includes(t.includes,t.position))return;n.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:n.value,inst:e,continue:!t.abort})}}),Ll=M("$ZodCheckStartsWith",(e,t)=>{Le.init(e,t);let r=new RegExp(`^${pt(t.prefix)}.*`);t.pattern??(t.pattern=r),e._zod.onattach.push((o)=>{let n=o._zod.bag;n.patterns??(n.patterns=new Set),n.patterns.add(r)}),e._zod.check=(o)=>{if(o.value.startsWith(t.prefix))return;o.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:o.value,inst:e,continue:!t.abort})}}),Zl=M("$ZodCheckEndsWith",(e,t)=>{Le.init(e,t);let r=new RegExp(`.*${pt(t.suffix)}$`);t.pattern??(t.pattern=r),e._zod.onattach.push((o)=>{let n=o._zod.bag;n.patterns??(n.patterns=new Set),n.patterns.add(r)}),e._zod.check=(o)=>{if(o.value.endsWith(t.suffix))return;o.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:o.value,inst:e,continue:!t.abort})}});var Dl=M("$ZodCheckOverwrite",(e,t)=>{Le.init(e,t),e._zod.check=(r)=>{r.value=t.tx(r.value)}});class Si{constructor(e=[]){if(this.content=[],this.indent=0,this)this.args=e}indented(e){this.indent+=1,e(this),this.indent-=1}write(e){if(typeof e==="function"){e(this,{execution:"sync"}),e(this,{execution:"async"});return}let r=e.split(`
3
3
  `).filter((s)=>s),o=Math.min(...r.map((s)=>s.length-s.trimStart().length)),n=r.map((s)=>s.slice(o)).map((s)=>" ".repeat(this.indent*2)+s);for(let s of n)this.content.push(s)}compile(){let e=Function,t=this?.args,o=[...(this?.content??[""]).map((n)=>` ${n}`)];return new e(...t,o.join(`
4
4
  `))}}var Vl={major:4,minor:4,patch:3};var ye=M("$ZodType",(e,t)=>{var r;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Vl;let o=[...e._zod.def.checks??[]];if(e._zod.traits.has("$ZodCheck"))o.unshift(e);for(let n of o)for(let s of n._zod.onattach)s(e);if(o.length===0)(r=e._zod).deferred??(r.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let n=(a,i,c)=>{let l=Pt(a),m;for(let g of i){if(g._zod.def.when){if(ui(a))continue;if(!g._zod.def.when(a))continue}else if(l)continue;let z=a.issues.length,w=g._zod.check(a);if(w instanceof Promise&&c?.async===!1)throw new dt;if(m||w instanceof Promise)m=(m??Promise.resolve()).then(async()=>{if(await w,a.issues.length===z)return;if(!l)l=Pt(a,z)});else{if(a.issues.length===z)continue;if(!l)l=Pt(a,z)}}if(m)return m.then(()=>a);return a},s=(a,i,c)=>{if(Pt(a))return a.aborted=!0,a;let l=n(i,o,c);if(l instanceof Promise){if(c.async===!1)throw new dt;return l.then((m)=>e._zod.parse(m,c))}return e._zod.parse(l,c)};e._zod.run=(a,i)=>{if(i.skipChecks)return e._zod.parse(a,i);if(i.direction==="backward"){let l=e._zod.parse({value:a.value,issues:[]},{...i,skipChecks:!0});if(l instanceof Promise)return l.then((m)=>s(m,a,i));return s(l,a,i)}let c=e._zod.parse(a,i);if(c instanceof Promise){if(i.async===!1)throw new dt;return c.then((l)=>n(l,o,i))}return n(c,o,i)}}_e(e,"~standard",()=>({validate:(n)=>{try{let s=Fu(e,n);return s.success?{value:s.data}:{issues:s.error?.issues}}catch(s){return Hu(e,n).then((a)=>a.success?{value:a.data}:{issues:a.error?.issues})}},vendor:"zod",version:1}))}),Vn=M("$ZodString",(e,t)=>{ye.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??zl(e._zod.bag),e._zod.parse=(r,o)=>{if(t.coerce)try{r.value=String(r.value)}catch(n){}if(typeof r.value==="string")return r;return r.issues.push({expected:"string",code:"invalid_type",input:r.value,inst:e}),r}}),Re=M("$ZodStringFormat",(e,t)=>{wo.init(e,t),Vn.init(e,t)}),Xl=M("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=il),Re.init(e,t)}),Ql=M("$ZodUUID",(e,t)=>{if(t.version){let o={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(o===void 0)throw Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=hi(o))}else t.pattern??(t.pattern=hi());Re.init(e,t)}),ed=M("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=cl),Re.init(e,t)}),td=M("$ZodURL",(e,t)=>{Re.init(e,t),e._zod.check=(r)=>{try{let o=r.value.trim();if(!t.normalize&&t.protocol?.source===fl.source){if(!/^https?:\/\//i.test(o)){r.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:r.value,inst:e,continue:!t.abort});return}}let n=new URL(o);if(t.hostname){if(t.hostname.lastIndex=0,!t.hostname.test(n.hostname))r.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:r.value,inst:e,continue:!t.abort})}if(t.protocol){if(t.protocol.lastIndex=0,!t.protocol.test(n.protocol.endsWith(":")?n.protocol.slice(0,-1):n.protocol))r.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:r.value,inst:e,continue:!t.abort})}if(t.normalize)r.value=n.href;else r.value=o;return}catch(o){r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:e,continue:!t.abort})}}}),rd=M("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=ul()),Re.init(e,t)}),od=M("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=sl),Re.init(e,t)}),nd=M("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=el),Re.init(e,t)}),sd=M("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=tl),Re.init(e,t)}),ad=M("$ZodULID",(e,t)=>{t.pattern??(t.pattern=rl),Re.init(e,t)}),id=M("$ZodXID",(e,t)=>{t.pattern??(t.pattern=ol),Re.init(e,t)}),cd=M("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=nl),Re.init(e,t)}),ud=M("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=bl(t)),Re.init(e,t)}),ld=M("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=Sl),Re.init(e,t)}),dd=M("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=vl(t)),Re.init(e,t)}),md=M("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=al),Re.init(e,t)}),pd=M("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=ll),Re.init(e,t),e._zod.bag.format="ipv4"}),hd=M("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=dl),Re.init(e,t),e._zod.bag.format="ipv6",e._zod.check=(r)=>{try{new URL(`http://[${r.value}]`)}catch{r.issues.push({code:"invalid_format",format:"ipv6",input:r.value,inst:e,continue:!t.abort})}}});var fd=M("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=ml),Re.init(e,t)}),gd=M("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=pl),Re.init(e,t),e._zod.check=(r)=>{let o=r.value.split("/");try{if(o.length!==2)throw Error();let[n,s]=o;if(!s)throw Error();let a=Number(s);if(`${a}`!==s)throw Error();if(a<0||a>128)throw Error();new URL(`http://[${n}]`)}catch{r.issues.push({code:"invalid_format",format:"cidrv6",input:r.value,inst:e,continue:!t.abort})}}});function _d(e){if(e==="")return!0;if(/\s/.test(e))return!1;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}var Sd=M("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=hl),Re.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=(r)=>{if(_d(r.value))return;r.issues.push({code:"invalid_format",format:"base64",input:r.value,inst:e,continue:!t.abort})}});function Mf(e){if(!fi.test(e))return!1;let t=e.replace(/[-_]/g,(o)=>o==="-"?"+":"/"),r=t.padEnd(Math.ceil(t.length/4)*4,"=");return _d(r)}var yd=M("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=fi),Re.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=(r)=>{if(Mf(r.value))return;r.issues.push({code:"invalid_format",format:"base64url",input:r.value,inst:e,continue:!t.abort})}}),vd=M("$ZodE164",(e,t)=>{t.pattern??(t.pattern=gl),Re.init(e,t)});function Lf(e,t=null){try{let r=e.split(".");if(r.length!==3)return!1;let[o]=r;if(!o)return!1;let n=JSON.parse(atob(o));if("typ"in n&&n?.typ!=="JWT")return!1;if(!n.alg)return!1;if(t&&(!("alg"in n)||n.alg!==t))return!1;return!0}catch{return!1}}var bd=M("$ZodJWT",(e,t)=>{Re.init(e,t),e._zod.check=(r)=>{if(Lf(r.value,t.alg))return;r.issues.push({code:"invalid_format",format:"jwt",input:r.value,inst:e,continue:!t.abort})}});var vi=M("$ZodNumber",(e,t)=>{ye.init(e,t),e._zod.pattern=e._zod.bag.pattern??Zn,e._zod.parse=(r,o)=>{if(t.coerce)try{r.value=Number(r.value)}catch(a){}let n=r.value;if(typeof n==="number"&&!Number.isNaN(n)&&Number.isFinite(n))return r;let s=typeof n==="number"?Number.isNaN(n)?"NaN":!Number.isFinite(n)?"Infinity":void 0:void 0;return r.issues.push({expected:"number",code:"invalid_type",input:n,inst:e,...s?{received:s}:{}}),r}}),zd=M("$ZodNumberFormat",(e,t)=>{Il.init(e,t),vi.init(e,t)}),$d=M("$ZodBoolean",(e,t)=>{ye.init(e,t),e._zod.pattern=wl,e._zod.parse=(r,o)=>{if(t.coerce)try{r.value=Boolean(r.value)}catch(s){}let n=r.value;if(typeof n==="boolean")return r;return r.issues.push({expected:"boolean",code:"invalid_type",input:n,inst:e}),r}}),Rd=M("$ZodBigInt",(e,t)=>{ye.init(e,t),e._zod.pattern=$l,e._zod.parse=(r,o)=>{if(t.coerce)try{r.value=BigInt(r.value)}catch(n){}if(typeof r.value==="bigint")return r;return r.issues.push({expected:"bigint",code:"invalid_type",input:r.value,inst:e}),r}});var wd=M("$ZodNull",(e,t)=>{ye.init(e,t),e._zod.pattern=Pl,e._zod.values=new Set([null]),e._zod.parse=(r,o)=>{let n=r.value;if(n===null)return r;return r.issues.push({expected:"null",code:"invalid_type",input:n,inst:e}),r}}),Pd=M("$ZodAny",(e,t)=>{ye.init(e,t),e._zod.parse=(r)=>r}),Ed=M("$ZodUnknown",(e,t)=>{ye.init(e,t),e._zod.parse=(r)=>r}),Td=M("$ZodNever",(e,t)=>{ye.init(e,t),e._zod.parse=(r,o)=>(r.issues.push({expected:"never",code:"invalid_type",input:r.value,inst:e}),r)});var kd=M("$ZodDate",(e,t)=>{ye.init(e,t),e._zod.parse=(r,o)=>{if(t.coerce)try{r.value=new Date(r.value)}catch(i){}let n=r.value,s=n instanceof Date;if(s&&!Number.isNaN(n.getTime()))return r;return r.issues.push({expected:"date",code:"invalid_type",input:n,...s?{received:"Invalid Date"}:{},inst:e}),r}});function Fl(e,t,r){if(e.issues.length)t.issues.push(...ht(r,e.issues));t.value[r]=e.value}var Cd=M("$ZodArray",(e,t)=>{ye.init(e,t),e._zod.parse=(r,o)=>{let n=r.value;if(!Array.isArray(n))return r.issues.push({expected:"array",code:"invalid_type",input:n,inst:e}),r;r.value=Array(n.length);let s=[];for(let a=0;a<n.length;a++){let i=n[a],c=t.element._zod.run({value:i,issues:[]},o);if(c instanceof Promise)s.push(c.then((l)=>Fl(l,r,a)));else Fl(c,r,a)}if(s.length)return Promise.all(s).then(()=>r);return r}});function Un(e,t,r,o,n,s){let a=r in o;if(e.issues.length){if(n&&s&&!a)return;t.issues.push(...ht(r,e.issues))}if(!a&&!n){if(!e.issues.length)t.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[r]});return}if(e.value===void 0){if(a)t.value[r]=void 0}else t.value[r]=e.value}function Id(e){let t=Object.keys(e.shape);for(let o of t)if(!e.shape?.[o]?._zod?.traits?.has("$ZodType"))throw Error(`Invalid element at key "${o}": expected a Zod schema`);let r=ii(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(r)}}function Od(e,t,r,o,n,s){let a=[],i=n.keySet,c=n.catchall._zod,l=c.def.type,m=c.optin==="optional",g=c.optout==="optional";for(let z in t){if(z==="__proto__")continue;if(i.has(z))continue;if(l==="never"){a.push(z);continue}let w=c.run({value:t[z],issues:[]},o);if(w instanceof Promise)e.push(w.then((_)=>Un(_,r,z,t,m,g)));else Un(w,r,z,t,m,g)}if(a.length)r.issues.push({code:"unrecognized_keys",keys:a,input:t,inst:s});if(!e.length)return r;return Promise.all(e).then(()=>r)}var Zf=M("$ZodObject",(e,t)=>{if(ye.init(e,t),!Object.getOwnPropertyDescriptor(t,"shape")?.get){let i=t.shape;Object.defineProperty(t,"shape",{get:()=>{let c={...i};return Object.defineProperty(t,"shape",{value:c}),c}})}let o=fr(()=>Id(t));_e(e._zod,"propValues",()=>{let i=t.shape,c={};for(let l in i){let m=i[l]._zod;if(m.values){c[l]??(c[l]=new Set);for(let g of m.values)c[l].add(g)}}return c});let n=Gt,s=t.catchall,a;e._zod.parse=(i,c)=>{a??(a=o.value);let l=i.value;if(!n(l))return i.issues.push({expected:"object",code:"invalid_type",input:l,inst:e}),i;i.value={};let m=[],g=a.shape;for(let z of a.keys){let w=g[z],_=w._zod.optin==="optional",b=w._zod.optout==="optional",f=w._zod.run({value:l[z],issues:[]},c);if(f instanceof Promise)m.push(f.then((d)=>Un(d,i,z,l,_,b)));else Un(f,i,z,l,_,b)}if(!s)return m.length?Promise.all(m).then(()=>i):i;return Od(m,l,i,c,o.value,e)}}),Nd=M("$ZodObjectJIT",(e,t)=>{Zf.init(e,t);let r=e._zod.parse,o=fr(()=>Id(t)),n=(z)=>{let w=new Si(["shape","payload","ctx"]),_=o.value,b=(p)=>{let S=jn(p);return`shape[${S}]._zod.run({ value: input[${S}], issues: [] }, ctx)`};w.write("const input = payload.value;");let f=Object.create(null),d=0;for(let p of _.keys)f[p]=`key_${d++}`;w.write("const newResult = {};");for(let p of _.keys){let S=f[p],P=jn(p),y=z[p],h=y?._zod?.optin==="optional",E=y?._zod?.optout==="optional";if(w.write(`const ${S} = ${b(p)};`),h&&E)w.write(`
@@ -1,4 +1,4 @@
1
- /*! @mcpcloud/runtime v0.14.0 — (c) MCPCloud.sh. All rights reserved. SEE LICENSE: https://www.npmjs.com/package/@mcpcloud/runtime */
1
+ /*! @mcpcloud/runtime v0.15.0 — (c) MCPCloud.sh. All rights reserved. SEE LICENSE: https://www.npmjs.com/package/@mcpcloud/runtime */
2
2
  var mk=Object.create;var{getPrototypeOf:pk,defineProperty:Zd,getOwnPropertyNames:fk}=Object;var hk=Object.prototype.hasOwnProperty;function gk(e){return this[e]}var vk,_k,Sk=(e,t,n)=>{var o=e!=null&&typeof e==="object";if(o){var r=t?vk??=new WeakMap:_k??=new WeakMap,i=r.get(e);if(i)return i}n=e!=null?mk(pk(e)):{};let a=t||!e||!e.__esModule?Zd(n,"default",{value:e,enumerable:!0}):n;if(e&&typeof e==="object"||typeof e==="function"){for(let s of fk(e))if(!hk.call(a,s))Zd(a,s,{get:gk.bind(e,s),enumerable:!0})}if(o)r.set(e,a);return a};var D=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var yk=(e)=>e;function bk(e,t){this[e]=yk.bind(null,t)}var rr=(e,t)=>{for(var n in t)Zd(e,n,{get:t[n],enumerable:!0,configurable:!0,set:bk.bind(t,n)})};var Va=D(function(X$){Object.defineProperty(X$,"__esModule",{value:!0});X$.regexpCode=X$.getEsmExportName=X$.getProperty=X$.safeStringify=X$.stringify=X$.strConcat=X$.addCodeArg=X$.str=X$._=X$.nil=X$._Code=X$.Name=X$.IDENTIFIER=X$._CodeOrName=void 0;class id{}X$._CodeOrName=id;X$.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;class Mo extends id{constructor(e){super();if(!X$.IDENTIFIER.test(e))throw Error("CodeGen: name must be a valid identifier");this.str=e}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}}X$.Name=Mo;class jt extends id{constructor(e){super();this._items=typeof e==="string"?[e]:e}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;let e=this._items[0];return e===""||e==='""'}get str(){var e;return(e=this._str)!==null&&e!==void 0?e:this._str=this._items.reduce((t,n)=>`${t}${n}`,"")}get names(){var e;return(e=this._names)!==null&&e!==void 0?e:this._names=this._items.reduce((t,n)=>{if(n instanceof Mo)t[n.str]=(t[n.str]||0)+1;return t},{})}}X$._Code=jt;X$.nil=new jt("");function W$(e,...t){let n=[e[0]],o=0;while(o<t.length)Z_(n,t[o]),n.push(e[++o]);return new jt(n)}X$._=W$;var L_=new jt("+");function Y$(e,...t){let n=[Za(e[0])],o=0;while(o<t.length)n.push(L_),Z_(n,t[o]),n.push(L_,Za(e[++o]));return UT(n),new jt(n)}X$.str=Y$;function Z_(e,t){if(t instanceof jt)e.push(...t._items);else if(t instanceof Mo)e.push(t);else e.push(ZT(t))}X$.addCodeArg=Z_;function UT(e){let t=1;while(t<e.length-1){if(e[t]===L_){let n=DT(e[t-1],e[t+1]);if(n!==void 0){e.splice(t-1,3,n);continue}e[t++]="+"}t++}}function DT(e,t){if(t==='""')return e;if(e==='""')return t;if(typeof e=="string"){if(t instanceof Mo||e[e.length-1]!=='"')return;if(typeof t!="string")return`${e.slice(0,-1)}${t}"`;if(t[0]==='"')return e.slice(0,-1)+t.slice(1);return}if(typeof t=="string"&&t[0]==='"'&&!(e instanceof Mo))return`"${e}${t.slice(1)}`;return}function LT(e,t){return t.emptyStr()?e:e.emptyStr()?t:Y$`${e}${t}`}X$.strConcat=LT;function ZT(e){return typeof e=="number"||typeof e=="boolean"||e===null?e:Za(Array.isArray(e)?e.join(","):e)}function VT(e){return new jt(Za(e))}X$.stringify=VT;function Za(e){return JSON.stringify(e).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}X$.safeStringify=Za;function FT(e){return typeof e=="string"&&X$.IDENTIFIER.test(e)?new jt(`.${e}`):W$`[${e}]`}X$.getProperty=FT;function JT(e){if(typeof e=="string"&&X$.IDENTIFIER.test(e))return new jt(`${e}`);throw Error(`CodeGen: invalid export name: ${e}, use explicit $id name mapping`)}X$.getEsmExportName=JT;function HT(e){return new jt(e.toString())}X$.regexpCode=HT});var H_=D(function(rz){Object.defineProperty(rz,"__esModule",{value:!0});rz.ValueScope=rz.ValueScopeName=rz.Scope=rz.varKinds=rz.UsedValueState=void 0;var ot=Va();class ez extends Error{constructor(e){super(`CodeGen: "code" for ${e} not defined`);this.value=e.value}}var sd;(function(e){e[e.Started=0]="Started",e[e.Completed=1]="Completed"})(sd||(rz.UsedValueState=sd={}));rz.varKinds={const:new ot.Name("const"),let:new ot.Name("let"),var:new ot.Name("var")};class F_{constructor({prefixes:e,parent:t}={}){this._names={},this._prefixes=e,this._parent=t}toName(e){return e instanceof ot.Name?e:this.name(e)}name(e){return new ot.Name(this._newName(e))}_newName(e){let t=this._names[e]||this._nameGroup(e);return`${e}${t.index++}`}_nameGroup(e){var t,n;if(((n=(t=this._parent)===null||t===void 0?void 0:t._prefixes)===null||n===void 0?void 0:n.has(e))||this._prefixes&&!this._prefixes.has(e))throw Error(`CodeGen: prefix "${e}" is not allowed in this scope`);return this._names[e]={prefix:e,index:0}}}rz.Scope=F_;class J_ extends ot.Name{constructor(e,t){super(t);this.prefix=e}setValue(e,{property:t,itemIndex:n}){this.value=e,this.scopePath=ot._`.${new ot.Name(t)}[${n}]`}}rz.ValueScopeName=J_;var ij=ot._`\n`;class tz extends F_{constructor(e){super(e);this._values={},this._scope=e.scope,this.opts={...e,_n:e.lines?ij:ot.nil}}get(){return this._scope}name(e){return new J_(e,this._newName(e))}value(e,t){var n;if(t.ref===void 0)throw Error("CodeGen: ref must be passed in value");let o=this.toName(e),{prefix:r}=o,i=(n=t.key)!==null&&n!==void 0?n:t.ref,a=this._values[r];if(a){let l=a.get(i);if(l)return l}else a=this._values[r]=new Map;a.set(i,o);let s=this._scope[r]||(this._scope[r]=[]),c=s.length;return s[c]=t.ref,o.setValue(t,{property:r,itemIndex:c}),o}getValue(e,t){let n=this._values[e];if(!n)return;return n.get(t)}scopeRefs(e,t=this._values){return this._reduceValues(t,(n)=>{if(n.scopePath===void 0)throw Error(`CodeGen: name "${n}" has no value`);return ot._`${e}${n.scopePath}`})}scopeCode(e=this._values,t,n){return this._reduceValues(e,(o)=>{if(o.value===void 0)throw Error(`CodeGen: name "${o}" has no value`);return o.value.code},t,n)}_reduceValues(e,t,n={},o){let r=ot.nil;for(let i in e){let a=e[i];if(!a)continue;let s=n[i]=n[i]||new Map;a.forEach((c)=>{if(s.has(c))return;s.set(c,sd.Started);let l=t(c);if(l){let d=this.opts.es5?rz.varKinds.var:rz.varKinds.const;r=ot._`${r}${d} ${c} = ${l};${this.opts._n}`}else if(l=o===null||o===void 0?void 0:o(c))r=ot._`${r}${l}${this.opts._n}`;else throw new ez(c);s.set(c,sd.Completed)})}return r}}rz.ValueScope=tz});var ce=D(function(it){Object.defineProperty(it,"__esModule",{value:!0});it.or=it.and=it.not=it.CodeGen=it.operators=it.varKinds=it.ValueScopeName=it.ValueScope=it.Scope=it.Name=it.regexpCode=it.stringify=it.getProperty=it.nil=it.strConcat=it.str=it._=void 0;var le=Va(),Ot=H_(),Zr=Va();Object.defineProperty(it,"_",{enumerable:!0,get:function(){return Zr._}});Object.defineProperty(it,"str",{enumerable:!0,get:function(){return Zr.str}});Object.defineProperty(it,"strConcat",{enumerable:!0,get:function(){return Zr.strConcat}});Object.defineProperty(it,"nil",{enumerable:!0,get:function(){return Zr.nil}});Object.defineProperty(it,"getProperty",{enumerable:!0,get:function(){return Zr.getProperty}});Object.defineProperty(it,"stringify",{enumerable:!0,get:function(){return Zr.stringify}});Object.defineProperty(it,"regexpCode",{enumerable:!0,get:function(){return Zr.regexpCode}});Object.defineProperty(it,"Name",{enumerable:!0,get:function(){return Zr.Name}});var pd=H_();Object.defineProperty(it,"Scope",{enumerable:!0,get:function(){return pd.Scope}});Object.defineProperty(it,"ValueScope",{enumerable:!0,get:function(){return pd.ValueScope}});Object.defineProperty(it,"ValueScopeName",{enumerable:!0,get:function(){return pd.ValueScopeName}});Object.defineProperty(it,"varKinds",{enumerable:!0,get:function(){return pd.varKinds}});it.operators={GT:new le._Code(">"),GTE:new le._Code(">="),LT:new le._Code("<"),LTE:new le._Code("<="),EQ:new le._Code("==="),NEQ:new le._Code("!=="),NOT:new le._Code("!"),OR:new le._Code("||"),AND:new le._Code("&&"),ADD:new le._Code("+")};class Vr{optimizeNodes(){return this}optimizeNames(e,t){return this}}class oz extends Vr{constructor(e,t,n){super();this.varKind=e,this.name=t,this.rhs=n}render({es5:e,_n:t}){let n=e?Ot.varKinds.var:this.varKind,o=this.rhs===void 0?"":` = ${this.rhs}`;return`${n} ${this.name}${o};`+t}optimizeNames(e,t){if(!e[this.name.str])return;if(this.rhs)this.rhs=Do(this.rhs,e,t);return this}get names(){return this.rhs instanceof le._CodeOrName?this.rhs.names:{}}}class B_ extends Vr{constructor(e,t,n){super();this.lhs=e,this.rhs=t,this.sideEffects=n}render({_n:e}){return`${this.lhs} = ${this.rhs};`+e}optimizeNames(e,t){if(this.lhs instanceof le.Name&&!e[this.lhs.str]&&!this.sideEffects)return;return this.rhs=Do(this.rhs,e,t),this}get names(){let e=this.lhs instanceof le.Name?{}:{...this.lhs.names};return md(e,this.rhs)}}class iz extends B_{constructor(e,t,n,o){super(e,n,o);this.op=t}render({_n:e}){return`${this.lhs} ${this.op}= ${this.rhs};`+e}}class az extends Vr{constructor(e){super();this.label=e,this.names={}}render({_n:e}){return`${this.label}:`+e}}class sz extends Vr{constructor(e){super();this.label=e,this.names={}}render({_n:e}){return`break${this.label?` ${this.label}`:""};`+e}}class cz extends Vr{constructor(e){super();this.error=e}render({_n:e}){return`throw ${this.error};`+e}get names(){return this.error.names}}class lz extends Vr{constructor(e){super();this.code=e}render({_n:e}){return`${this.code};`+e}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames(e,t){return this.code=Do(this.code,e,t),this}get names(){return this.code instanceof le._CodeOrName?this.code.names:{}}}class fd extends Vr{constructor(e=[]){super();this.nodes=e}render(e){return this.nodes.reduce((t,n)=>t+n.render(e),"")}optimizeNodes(){let{nodes:e}=this,t=e.length;while(t--){let n=e[t].optimizeNodes();if(Array.isArray(n))e.splice(t,1,...n);else if(n)e[t]=n;else e.splice(t,1)}return e.length>0?this:void 0}optimizeNames(e,t){let{nodes:n}=this,o=n.length;while(o--){let r=n[o];if(r.optimizeNames(e,t))continue;lj(e,r.names),n.splice(o,1)}return n.length>0?this:void 0}get names(){return this.nodes.reduce((e,t)=>wn(e,t.names),{})}}class Fr extends fd{render(e){return"{"+e._n+super.render(e)+"}"+e._n}}class uz extends fd{}class Fa extends Fr{}Fa.kind="else";class mr extends Fr{constructor(e,t){super(t);this.condition=e}render(e){let t=`if(${this.condition})`+super.render(e);if(this.else)t+="else "+this.else.render(e);return t}optimizeNodes(){super.optimizeNodes();let e=this.condition;if(e===!0)return this.nodes;let t=this.else;if(t){let n=t.optimizeNodes();t=this.else=Array.isArray(n)?new Fa(n):n}if(t){if(e===!1)return t instanceof mr?t:t.nodes;if(this.nodes.length)return this;return new mr(hz(e),t instanceof mr?[t]:t.nodes)}if(e===!1||!this.nodes.length)return;return this}optimizeNames(e,t){var n;if(this.else=(n=this.else)===null||n===void 0?void 0:n.optimizeNames(e,t),!(super.optimizeNames(e,t)||this.else))return;return this.condition=Do(this.condition,e,t),this}get names(){let e=super.names;if(md(e,this.condition),this.else)wn(e,this.else.names);return e}}mr.kind="if";class Uo extends Fr{}Uo.kind="for";class dz extends Uo{constructor(e){super();this.iteration=e}render(e){return`for(${this.iteration})`+super.render(e)}optimizeNames(e,t){if(!super.optimizeNames(e,t))return;return this.iteration=Do(this.iteration,e,t),this}get names(){return wn(super.names,this.iteration.names)}}class mz extends Uo{constructor(e,t,n,o){super();this.varKind=e,this.name=t,this.from=n,this.to=o}render(e){let t=e.es5?Ot.varKinds.var:this.varKind,{name:n,from:o,to:r}=this;return`for(${t} ${n}=${o}; ${n}<${r}; ${n}++)`+super.render(e)}get names(){let e=md(super.names,this.from);return md(e,this.to)}}class K_ extends Uo{constructor(e,t,n,o){super();this.loop=e,this.varKind=t,this.name=n,this.iterable=o}render(e){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(e)}optimizeNames(e,t){if(!super.optimizeNames(e,t))return;return this.iterable=Do(this.iterable,e,t),this}get names(){return wn(super.names,this.iterable.names)}}class cd extends Fr{constructor(e,t,n){super();this.name=e,this.args=t,this.async=n}render(e){return`${this.async?"async ":""}function ${this.name}(${this.args})`+super.render(e)}}cd.kind="func";class ld extends fd{render(e){return"return "+super.render(e)}}ld.kind="return";class pz extends Fr{render(e){let t="try"+super.render(e);if(this.catch)t+=this.catch.render(e);if(this.finally)t+=this.finally.render(e);return t}optimizeNodes(){var e,t;return super.optimizeNodes(),(e=this.catch)===null||e===void 0||e.optimizeNodes(),(t=this.finally)===null||t===void 0||t.optimizeNodes(),this}optimizeNames(e,t){var n,o;return super.optimizeNames(e,t),(n=this.catch)===null||n===void 0||n.optimizeNames(e,t),(o=this.finally)===null||o===void 0||o.optimizeNames(e,t),this}get names(){let e=super.names;if(this.catch)wn(e,this.catch.names);if(this.finally)wn(e,this.finally.names);return e}}class ud extends Fr{constructor(e){super();this.error=e}render(e){return`catch(${this.error})`+super.render(e)}}ud.kind="catch";class dd extends Fr{render(e){return"finally"+super.render(e)}}dd.kind="finally";class fz{constructor(e,t={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...t,_n:t.lines?`
3
3
  `:""},this._extScope=e,this._scope=new Ot.Scope({parent:e}),this._nodes=[new uz]}toString(){return this._root.render(this.opts)}name(e){return this._scope.name(e)}scopeName(e){return this._extScope.name(e)}scopeValue(e,t){let n=this._extScope.value(e,t);return(this._values[n.prefix]||(this._values[n.prefix]=new Set)).add(n),n}getScopeValue(e,t){return this._extScope.getValue(e,t)}scopeRefs(e){return this._extScope.scopeRefs(e,this._values)}scopeCode(){return this._extScope.scopeCode(this._values)}_def(e,t,n,o){let r=this._scope.toName(t);if(n!==void 0&&o)this._constants[r.str]=n;return this._leafNode(new oz(e,r,n)),r}const(e,t,n){return this._def(Ot.varKinds.const,e,t,n)}let(e,t,n){return this._def(Ot.varKinds.let,e,t,n)}var(e,t,n){return this._def(Ot.varKinds.var,e,t,n)}assign(e,t,n){return this._leafNode(new B_(e,t,n))}add(e,t){return this._leafNode(new iz(e,it.operators.ADD,t))}code(e){if(typeof e=="function")e();else if(e!==le.nil)this._leafNode(new lz(e));return this}object(...e){let t=["{"];for(let[n,o]of e){if(t.length>1)t.push(",");if(t.push(n),n!==o||this.opts.es5)t.push(":"),(0,le.addCodeArg)(t,o)}return t.push("}"),new le._Code(t)}if(e,t,n){if(this._blockNode(new mr(e)),t&&n)this.code(t).else().code(n).endIf();else if(t)this.code(t).endIf();else if(n)throw Error('CodeGen: "else" body without "then" body');return this}elseIf(e){return this._elseNode(new mr(e))}else(){return this._elseNode(new Fa)}endIf(){return this._endBlockNode(mr,Fa)}_for(e,t){if(this._blockNode(e),t)this.code(t).endFor();return this}for(e,t){return this._for(new dz(e),t)}forRange(e,t,n,o,r=this.opts.es5?Ot.varKinds.var:Ot.varKinds.let){let i=this._scope.toName(e);return this._for(new mz(r,i,t,n),()=>o(i))}forOf(e,t,n,o=Ot.varKinds.const){let r=this._scope.toName(e);if(this.opts.es5){let i=t instanceof le.Name?t:this.var("_arr",t);return this.forRange("_i",0,le._`${i}.length`,(a)=>{this.var(r,le._`${i}[${a}]`),n(r)})}return this._for(new K_("of",o,r,t),()=>n(r))}forIn(e,t,n,o=this.opts.es5?Ot.varKinds.var:Ot.varKinds.const){if(this.opts.ownProperties)return this.forOf(e,le._`Object.keys(${t})`,n);let r=this._scope.toName(e);return this._for(new K_("in",o,r,t),()=>n(r))}endFor(){return this._endBlockNode(Uo)}label(e){return this._leafNode(new az(e))}break(e){return this._leafNode(new sz(e))}return(e){let t=new ld;if(this._blockNode(t),this.code(e),t.nodes.length!==1)throw Error('CodeGen: "return" should have one node');return this._endBlockNode(ld)}try(e,t,n){if(!t&&!n)throw Error('CodeGen: "try" without "catch" and "finally"');let o=new pz;if(this._blockNode(o),this.code(e),t){let r=this.name("e");this._currNode=o.catch=new ud(r),t(r)}if(n)this._currNode=o.finally=new dd,this.code(n);return this._endBlockNode(ud,dd)}throw(e){return this._leafNode(new cz(e))}block(e,t){if(this._blockStarts.push(this._nodes.length),e)this.code(e).endBlock(t);return this}endBlock(e){let t=this._blockStarts.pop();if(t===void 0)throw Error("CodeGen: not in self-balancing block");let n=this._nodes.length-t;if(n<0||e!==void 0&&n!==e)throw Error(`CodeGen: wrong number of nodes: ${n} vs ${e} expected`);return this._nodes.length=t,this}func(e,t=le.nil,n,o){if(this._blockNode(new cd(e,t,n)),o)this.code(o).endFunc();return this}endFunc(){return this._endBlockNode(cd)}optimize(e=1){while(e-- >0)this._root.optimizeNodes(),this._root.optimizeNames(this._root.names,this._constants)}_leafNode(e){return this._currNode.nodes.push(e),this}_blockNode(e){this._currNode.nodes.push(e),this._nodes.push(e)}_endBlockNode(e,t){let n=this._currNode;if(n instanceof e||t&&n instanceof t)return this._nodes.pop(),this;throw Error(`CodeGen: not in block "${t?`${e.kind}/${t.kind}`:e.kind}"`)}_elseNode(e){let t=this._currNode;if(!(t instanceof mr))throw Error('CodeGen: "else" without "if"');return this._currNode=t.else=e,this}get _root(){return this._nodes[0]}get _currNode(){let e=this._nodes;return e[e.length-1]}set _currNode(e){let t=this._nodes;t[t.length-1]=e}}it.CodeGen=fz;function wn(e,t){for(let n in t)e[n]=(e[n]||0)+(t[n]||0);return e}function md(e,t){return t instanceof le._CodeOrName?wn(e,t.names):e}function Do(e,t,n){if(e instanceof le.Name)return o(e);if(!r(e))return e;return new le._Code(e._items.reduce((i,a)=>{if(a instanceof le.Name)a=o(a);if(a instanceof le._Code)i.push(...a._items);else i.push(a);return i},[]));function o(i){let a=n[i.str];if(a===void 0||t[i.str]!==1)return i;return delete t[i.str],a}function r(i){return i instanceof le._Code&&i._items.some((a)=>a instanceof le.Name&&t[a.str]===1&&n[a.str]!==void 0)}}function lj(e,t){for(let n in t)e[n]=(e[n]||0)-(t[n]||0)}function hz(e){return typeof e=="boolean"||typeof e=="number"||e===null?!e:le._`!${G_(e)}`}it.not=hz;var uj=gz(it.operators.AND);function dj(...e){return e.reduce(uj)}it.and=dj;var mj=gz(it.operators.OR);function pj(...e){return e.reduce(mj)}it.or=pj;function gz(e){return(t,n)=>t===le.nil?n:n===le.nil?t:le._`${G_(t)} ${e} ${G_(n)}`}function G_(e){return e instanceof le.Name?e:le._`(${e})`}});var de=D(function(Rz){Object.defineProperty(Rz,"__esModule",{value:!0});Rz.checkStrictMode=Rz.getErrorPath=Rz.Type=Rz.useFunc=Rz.setEvaluated=Rz.evaluatedPropsToName=Rz.mergeEvaluated=Rz.eachItem=Rz.unescapeJsonPointer=Rz.escapeJsonPointer=Rz.escapeFragment=Rz.unescapeFragment=Rz.schemaRefOrVal=Rz.schemaHasRulesButRef=Rz.schemaHasRules=Rz.checkUnknownRules=Rz.alwaysValidSchema=Rz.toHash=void 0;var ve=ce(),vj=Va();function _j(e){let t={};for(let n of e)t[n]=!0;return t}Rz.toHash=_j;function Sj(e,t){if(typeof t=="boolean")return t;if(Object.keys(t).length===0)return!0;return yz(e,t),!bz(t,e.self.RULES.all)}Rz.alwaysValidSchema=Sj;function yz(e,t=e.schema){let{opts:n,self:o}=e;if(!n.strictSchema)return;if(typeof t==="boolean")return;let r=o.RULES.keywords;for(let i in t)if(!r[i])wz(e,`unknown keyword: "${i}"`)}Rz.checkUnknownRules=yz;function bz(e,t){if(typeof e=="boolean")return!e;for(let n in e)if(t[n])return!0;return!1}Rz.schemaHasRules=bz;function yj(e,t){if(typeof e=="boolean")return!e;for(let n in e)if(n!=="$ref"&&t.all[n])return!0;return!1}Rz.schemaHasRulesButRef=yj;function bj({topSchemaRef:e,schemaPath:t},n,o,r){if(!r){if(typeof n=="number"||typeof n=="boolean")return n;if(typeof n=="string")return ve._`${n}`}return ve._`${e}${t}${(0,ve.getProperty)(o)}`}Rz.schemaRefOrVal=bj;function $j(e){return $z(decodeURIComponent(e))}Rz.unescapeFragment=$j;function zj(e){return encodeURIComponent(Y_(e))}Rz.escapeFragment=zj;function Y_(e){if(typeof e=="number")return`${e}`;return e.replace(/~/g,"~0").replace(/\//g,"~1")}Rz.escapeJsonPointer=Y_;function $z(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}Rz.unescapeJsonPointer=$z;function wj(e,t){if(Array.isArray(e))for(let n of e)t(n);else t(e)}Rz.eachItem=wj;function _z({mergeNames:e,mergeToName:t,mergeValues:n,resultToName:o}){return(r,i,a,s)=>{let c=a===void 0?i:a instanceof ve.Name?(i instanceof ve.Name?e(r,i,a):t(r,i,a),a):i instanceof ve.Name?(t(r,a,i),i):n(i,a);return s===ve.Name&&!(c instanceof ve.Name)?o(r,c):c}}Rz.mergeEvaluated={props:_z({mergeNames:(e,t,n)=>e.if(ve._`${n} !== true && ${t} !== undefined`,()=>{e.if(ve._`${t} === true`,()=>e.assign(n,!0),()=>e.assign(n,ve._`${n} || {}`).code(ve._`Object.assign(${n}, ${t})`))}),mergeToName:(e,t,n)=>e.if(ve._`${n} !== true`,()=>{if(t===!0)e.assign(n,!0);else e.assign(n,ve._`${n} || {}`),X_(e,n,t)}),mergeValues:(e,t)=>e===!0?!0:{...e,...t},resultToName:zz}),items:_z({mergeNames:(e,t,n)=>e.if(ve._`${n} !== true && ${t} !== undefined`,()=>e.assign(n,ve._`${t} === true ? true : ${n} > ${t} ? ${n} : ${t}`)),mergeToName:(e,t,n)=>e.if(ve._`${n} !== true`,()=>e.assign(n,t===!0?!0:ve._`${n} > ${t} ? ${n} : ${t}`)),mergeValues:(e,t)=>e===!0?!0:Math.max(e,t),resultToName:(e,t)=>e.var("items",t)})};function zz(e,t){if(t===!0)return e.var("props",!0);let n=e.var("props",ve._`{}`);if(t!==void 0)X_(e,n,t);return n}Rz.evaluatedPropsToName=zz;function X_(e,t,n){Object.keys(n).forEach((o)=>e.assign(ve._`${t}${(0,ve.getProperty)(o)}`,!0))}Rz.setEvaluated=X_;var Sz={};function Rj(e,t){return e.scopeValue("func",{ref:t,code:Sz[t.code]||(Sz[t.code]=new vj._Code(t.code))})}Rz.useFunc=Rj;var W_;(function(e){e[e.Num=0]="Num",e[e.Str=1]="Str"})(W_||(Rz.Type=W_={}));function xj(e,t,n){if(e instanceof ve.Name){let o=t===W_.Num;return n?o?ve._`"[" + ${e} + "]"`:ve._`"['" + ${e} + "']"`:o?ve._`"/" + ${e}`:ve._`"/" + ${e}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return n?(0,ve.getProperty)(e).toString():"/"+Y_(e)}Rz.getErrorPath=xj;function wz(e,t,n=e.opts.strictSchema){if(!n)return;if(t=`strict mode: ${t}`,n===!0)throw Error(t);e.self.logger.warn(t)}Rz.checkStrictMode=wz});var pr=D(function(kz){Object.defineProperty(kz,"__esModule",{value:!0});var De=ce(),Fj={data:new De.Name("data"),valCxt:new De.Name("valCxt"),instancePath:new De.Name("instancePath"),parentData:new De.Name("parentData"),parentDataProperty:new De.Name("parentDataProperty"),rootData:new De.Name("rootData"),dynamicAnchors:new De.Name("dynamicAnchors"),vErrors:new De.Name("vErrors"),errors:new De.Name("errors"),this:new De.Name("this"),self:new De.Name("self"),scope:new De.Name("scope"),json:new De.Name("json"),jsonPos:new De.Name("jsonPos"),jsonLen:new De.Name("jsonLen"),jsonPart:new De.Name("jsonPart")};kz.default=Fj});var Ja=D(function(Tz){Object.defineProperty(Tz,"__esModule",{value:!0});Tz.extendErrors=Tz.resetErrorsCount=Tz.reportExtraError=Tz.reportError=Tz.keyword$DataError=Tz.keywordError=void 0;var me=ce(),gd=de(),Be=pr();Tz.keywordError={message:({keyword:e})=>me.str`must pass "${e}" keyword validation`};Tz.keyword$DataError={message:({keyword:e,schemaType:t})=>t?me.str`"${e}" keyword must be ${t} ($data)`:me.str`"${e}" keyword is invalid ($data)`};function Hj(e,t=Tz.keywordError,n,o){let{it:r}=e,{gen:i,compositeRule:a,allErrors:s}=r,c=Ez(e,t,n);if(o!==null&&o!==void 0?o:a||s)Iz(i,c);else Pz(r,me._`[${c}]`)}Tz.reportError=Hj;function Kj(e,t=Tz.keywordError,n){let{it:o}=e,{gen:r,compositeRule:i,allErrors:a}=o,s=Ez(e,t,n);if(Iz(r,s),!(i||a))Pz(o,Be.default.vErrors)}Tz.reportExtraError=Kj;function Gj(e,t){e.assign(Be.default.errors,t),e.if(me._`${Be.default.vErrors} !== null`,()=>e.if(t,()=>e.assign(me._`${Be.default.vErrors}.length`,t),()=>e.assign(Be.default.vErrors,null)))}Tz.resetErrorsCount=Gj;function Bj({gen:e,keyword:t,schemaValue:n,data:o,errsCount:r,it:i}){if(r===void 0)throw Error("ajv implementation error");let a=e.name("err");e.forRange("i",r,Be.default.errors,(s)=>{if(e.const(a,me._`${Be.default.vErrors}[${s}]`),e.if(me._`${a}.instancePath === undefined`,()=>e.assign(me._`${a}.instancePath`,(0,me.strConcat)(Be.default.instancePath,i.errorPath))),e.assign(me._`${a}.schemaPath`,me.str`${i.errSchemaPath}/${t}`),i.opts.verbose)e.assign(me._`${a}.schema`,n),e.assign(me._`${a}.data`,o)})}Tz.extendErrors=Bj;function Iz(e,t){let n=e.const("err",t);e.if(me._`${Be.default.vErrors} === null`,()=>e.assign(Be.default.vErrors,me._`[${n}]`),me._`${Be.default.vErrors}.push(${n})`),e.code(me._`${Be.default.errors}++`)}function Pz(e,t){let{gen:n,validateName:o,schemaEnv:r}=e;if(r.$async)n.throw(me._`new ${e.ValidationError}(${t})`);else n.assign(me._`${o}.errors`,t),n.return(!1)}var Rn={keyword:new me.Name("keyword"),schemaPath:new me.Name("schemaPath"),params:new me.Name("params"),propertyName:new me.Name("propertyName"),message:new me.Name("message"),schema:new me.Name("schema"),parentSchema:new me.Name("parentSchema")};function Ez(e,t,n){let{createErrors:o}=e.it;if(o===!1)return me._`{}`;return Wj(e,t,n)}function Wj(e,t,n={}){let{gen:o,it:r}=e,i=[Yj(r,n),Xj(e,n)];return Qj(e,t,i),o.object(...i)}function Yj({errorPath:e},{instancePath:t}){let n=t?me.str`${e}${(0,gd.getErrorPath)(t,gd.Type.Str)}`:e;return[Be.default.instancePath,(0,me.strConcat)(Be.default.instancePath,n)]}function Xj({keyword:e,it:{errSchemaPath:t}},{schemaPath:n,parentSchema:o}){let r=o?t:me.str`${t}/${e}`;if(n)r=me.str`${r}${(0,gd.getErrorPath)(n,gd.Type.Str)}`;return[Rn.schemaPath,r]}function Qj(e,{params:t,message:n},o){let{keyword:r,data:i,schemaValue:a,it:s}=e,{opts:c,propertyName:l,topSchemaRef:d,schemaPath:m}=s;if(o.push([Rn.keyword,r],[Rn.params,typeof t=="function"?t(e):t||me._`{}`]),c.messages)o.push([Rn.message,typeof n=="function"?n(e):n]);if(c.verbose)o.push([Rn.schema,a],[Rn.parentSchema,me._`${d}${m}`],[Be.default.data,i]);if(l)o.push([Rn.propertyName,l])}});var qz=D(function(Nz){Object.defineProperty(Nz,"__esModule",{value:!0});Nz.boolOrEmptySchema=Nz.topBoolOrEmptySchema=void 0;var oO=Ja(),iO=ce(),aO=pr(),sO={message:"boolean schema is false"};function cO(e){let{gen:t,schema:n,validateName:o}=e;if(n===!1)Oz(e,!1);else if(typeof n=="object"&&n.$async===!0)t.return(aO.default.data);else t.assign(iO._`${o}.errors`,null),t.return(!0)}Nz.topBoolOrEmptySchema=cO;function lO(e,t){let{gen:n,schema:o}=e;if(o===!1)n.var(t,!1),Oz(e);else n.var(t,!0)}Nz.boolOrEmptySchema=lO;function Oz(e,t){let{gen:n,data:o}=e,r={gen:n,keyword:"false schema",data:o,schema:!1,schemaCode:!1,schemaValue:!1,params:{},it:e};(0,oO.reportError)(r,sO,void 0,t)}});var eS=D(function(Az){Object.defineProperty(Az,"__esModule",{value:!0});Az.getRules=Az.isJSONType=void 0;var dO=["string","number","integer","boolean","null","object","array"],mO=new Set(dO);function pO(e){return typeof e=="string"&&mO.has(e)}Az.isJSONType=pO;function fO(){let e={number:{type:"number",rules:[]},string:{type:"string",rules:[]},array:{type:"array",rules:[]},object:{type:"object",rules:[]}};return{types:{...e,integer:!0,boolean:!0,null:!0},rules:[{rules:[]},e.number,e.string,e.array,e.object],post:{rules:[]},all:{},keywords:{}}}Az.getRules=fO});var tS=D(function(Lz){Object.defineProperty(Lz,"__esModule",{value:!0});Lz.shouldUseRule=Lz.shouldUseGroup=Lz.schemaHasRulesForType=void 0;function gO({schema:e,self:t},n){let o=t.RULES.types[n];return o&&o!==!0&&Uz(e,o)}Lz.schemaHasRulesForType=gO;function Uz(e,t){return t.rules.some((n)=>Dz(e,n))}Lz.shouldUseGroup=Uz;function Dz(e,t){var n;return e[t.keyword]!==void 0||((n=t.definition.implements)===null||n===void 0?void 0:n.some((o)=>e[o]!==void 0))}Lz.shouldUseRule=Dz});var Ha=D(function(Hz){Object.defineProperty(Hz,"__esModule",{value:!0});Hz.reportTypeError=Hz.checkDataTypes=Hz.checkDataType=Hz.coerceAndCheckDataType=Hz.getJSONTypes=Hz.getSchemaTypes=Hz.DataType=void 0;var SO=eS(),yO=tS(),bO=Ja(),ie=ce(),Vz=de(),Lo;(function(e){e[e.Correct=0]="Correct",e[e.Wrong=1]="Wrong"})(Lo||(Hz.DataType=Lo={}));function $O(e){let t=Fz(e.type);if(t.includes("null")){if(e.nullable===!1)throw Error("type: null contradicts nullable: false")}else{if(!t.length&&e.nullable!==void 0)throw Error('"nullable" cannot be used without "type"');if(e.nullable===!0)t.push("null")}return t}Hz.getSchemaTypes=$O;function Fz(e){let t=Array.isArray(e)?e:e?[e]:[];if(t.every(SO.isJSONType))return t;throw Error("type must be JSONType or JSONType[]: "+t.join(","))}Hz.getJSONTypes=Fz;function zO(e,t){let{gen:n,data:o,opts:r}=e,i=wO(t,r.coerceTypes),a=t.length>0&&!(i.length===0&&t.length===1&&(0,yO.schemaHasRulesForType)(e,t[0]));if(a){let s=nS(t,o,r.strictNumbers,Lo.Wrong);n.if(s,()=>{if(i.length)RO(e,t,i);else oS(e)})}return a}Hz.coerceAndCheckDataType=zO;var Jz=new Set(["string","number","integer","boolean","null"]);function wO(e,t){return t?e.filter((n)=>Jz.has(n)||t==="array"&&n==="array"):[]}function RO(e,t,n){let{gen:o,data:r,opts:i}=e,a=o.let("dataType",ie._`typeof ${r}`),s=o.let("coerced",ie._`undefined`);if(i.coerceTypes==="array")o.if(ie._`${a} == 'object' && Array.isArray(${r}) && ${r}.length == 1`,()=>o.assign(r,ie._`${r}[0]`).assign(a,ie._`typeof ${r}`).if(nS(t,r,i.strictNumbers),()=>o.assign(s,r)));o.if(ie._`${s} !== undefined`);for(let l of n)if(Jz.has(l)||l==="array"&&i.coerceTypes==="array")c(l);o.else(),oS(e),o.endIf(),o.if(ie._`${s} !== undefined`,()=>{o.assign(r,s),xO(e,s)});function c(l){switch(l){case"string":o.elseIf(ie._`${a} == "number" || ${a} == "boolean"`).assign(s,ie._`"" + ${r}`).elseIf(ie._`${r} === null`).assign(s,ie._`""`);return;case"number":o.elseIf(ie._`${a} == "boolean" || ${r} === null
4
4
  || (${a} == "string" && ${r} && ${r} == +${r})`).assign(s,ie._`+${r}`);return;case"integer":o.elseIf(ie._`${a} === "boolean" || ${r} === null
@@ -1,4 +1,4 @@
1
- /*! @mcpcloud/runtime v0.14.0 — (c) MCPCloud.sh. All rights reserved. SEE LICENSE: https://www.npmjs.com/package/@mcpcloud/runtime */
1
+ /*! @mcpcloud/runtime v0.15.0 — (c) MCPCloud.sh. All rights reserved. SEE LICENSE: https://www.npmjs.com/package/@mcpcloud/runtime */
2
2
  var At=Object.create;var{getPrototypeOf:bt,defineProperty:re,getOwnPropertyNames:Pt}=Object;var Ot=Object.prototype.hasOwnProperty;function vt(e){return this[e]}var Mt,xt,Nt=(e,t,r)=>{var o=e!=null&&typeof e==="object";if(o){var l=t?Mt??=new WeakMap:xt??=new WeakMap,d=l.get(e);if(d)return d}r=e!=null?At(bt(e)):{};let f=t||!e||!e.__esModule?re(r,"default",{value:e,enumerable:!0}):r;if(e&&typeof e==="object"||typeof e==="function"){for(let s of Pt(e))if(!Ot.call(f,s))re(f,s,{get:vt.bind(e,s),enumerable:!0})}if(o)l.set(e,f);return f};var kt=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var Ct=(e)=>e;function It(e,t){this[e]=Ct.bind(null,t)}var Lt=(e,t)=>{for(var r in t)re(e,r,{get:t[r],enumerable:!0,configurable:!0,set:It.bind(t,r)})};var ne=(e,t)=>()=>(e&&(t=e(e=0)),t);var U,ie,j,K,H;var V=ne(()=>{U={JS_EVAL_TYPE_GLOBAL:0,JS_EVAL_TYPE_MODULE:1,JS_EVAL_TYPE_DIRECT:2,JS_EVAL_TYPE_INDIRECT:3,JS_EVAL_TYPE_MASK:3,JS_EVAL_FLAG_STRICT:8,JS_EVAL_FLAG_STRIP:16,JS_EVAL_FLAG_COMPILE_ONLY:32,JS_EVAL_FLAG_BACKTRACE_BARRIER:64},ie={BaseObjects:1,Date:2,Eval:4,StringNormalize:8,RegExp:16,RegExpCompiler:32,JSON:64,Proxy:128,MapSet:256,TypedArrays:512,Promise:1024,BigInt:2048,BigFloat:4096,BigDecimal:8192,OperatorOverloading:16384,BignumExt:32768},j={Pending:0,Fulfilled:1,Rejected:2},K={JS_GPN_STRING_MASK:1,JS_GPN_SYMBOL_MASK:2,JS_GPN_PRIVATE_MASK:4,JS_GPN_ENUM_ONLY:16,JS_GPN_SET_ENUM:32,QTS_GPN_NUMBER_MASK:64,QTS_STANDARD_COMPLIANT_NUMBER:128},H={IsStrictlyEqual:0,IsSameValue:1,IsSameValueZero:2}});function J(...e){ce&&console.log("quickjs-emscripten:",...e)}function*st(e){return yield e}function Ft(e){return st(de(e))}function je(e,t){return(...r)=>{let o=t.call(e,he,...r);return de(o)}}function Dt(e,t){let r=t.call(e,he);return de(r)}function de(e){function t(r){return r.done?r.value:r.value instanceof Promise?r.value.then((o)=>t(e.next(o)),(o)=>t(e.throw(o))):t(e.next(r.value))}return t(e.next())}function se(e,t){let r;try{e.dispose()}catch(o){r=o}if(t&&r)throw Object.assign(t,{message:`${t.message}
3
3
  Then, failed to dispose scope: ${r.message}`,disposeError:r}),t;if(t||r)throw t||r}function Qt(e){let t=e?Array.from(e):[];function r(){return t.forEach((l)=>l.alive?l.dispose():void 0)}function o(){return t.some((l)=>l.alive)}return Object.defineProperty(t,le,{configurable:!0,enumerable:!1,value:r}),Object.defineProperty(t,"dispose",{configurable:!0,enumerable:!1,value:r}),Object.defineProperty(t,"alive",{configurable:!0,enumerable:!1,get:o}),t}function W(e){return!!(e&&(typeof e=="object"||typeof e=="function")&&("alive"in e)&&typeof e.alive=="boolean"&&("dispose"in e)&&typeof e.dispose=="function")}function Gt(e){if(!e)return 0;let t=0;for(let[r,o]of Object.entries(e)){if(!(r in ie))throw new tt(r);o&&(t|=ie[r])}return t}function Wt(e){if(typeof e=="number")return e;if(e===void 0)return 0;let{type:t,strict:r,strip:o,compileOnly:l,backtraceBarrier:d}=e,f=0;return t==="global"&&(f|=U.JS_EVAL_TYPE_GLOBAL),t==="module"&&(f|=U.JS_EVAL_TYPE_MODULE),r&&(f|=U.JS_EVAL_FLAG_STRICT),o&&(f|=U.JS_EVAL_FLAG_STRIP),l&&(f|=U.JS_EVAL_FLAG_COMPILE_ONLY),d&&(f|=U.JS_EVAL_FLAG_BACKTRACE_BARRIER),f}function qt(e){if(typeof e=="number")return e;if(e===void 0)return 0;let{strings:t,symbols:r,quickjsPrivate:o,onlyEnumerable:l,numbers:d,numbersAsStrings:f}=e,s=0;return t&&(s|=K.JS_GPN_STRING_MASK),r&&(s|=K.JS_GPN_SYMBOL_MASK),o&&(s|=K.JS_GPN_PRIVATE_MASK),l&&(s|=K.JS_GPN_ENUM_ONLY),d&&(s|=K.QTS_GPN_NUMBER_MASK),f&&(s|=K.QTS_STANDARD_COMPLIANT_NUMBER),s}function zt(...e){let t=[];for(let r of e)r!==void 0&&(t=t.concat(r));return t}function oe(e){return e>>8}function pe(e,t){t.interruptHandler&&e.setInterruptHandler(t.interruptHandler),t.maxStackSizeBytes!==void 0&&e.setMaxStackSize(t.maxStackSizeBytes),t.memoryLimitBytes!==void 0&&e.setMemoryLimit(t.memoryLimitBytes)}function _e(e,t){t.moduleLoader&&e.setModuleLoader(t.moduleLoader),t.shouldInterrupt&&e.setInterruptHandler(t.shouldInterrupt),t.memoryLimitBytes!==void 0&&e.setMemoryLimit(t.memoryLimitBytes),t.maxStackSizeBytes!==void 0&&e.setMaxStackSize(t.maxStackSizeBytes)}var Kt,Bt=(e,t)=>{for(var r in t)Kt(e,r,{get:t[r],enumerable:!0})},ce=!1,Yt,ae,ze,ue,Xe,Ze,et,Ht,Jt,tt,rt,nt,it,I,he,N,le,$e,A,B,Ve,M,fe,jt,$t,Y,Vt,ot=class{constructor(e){this.module=e}toPointerArray(e){let t=new Int32Array(e.map((l)=>l.value)),r=t.length*t.BYTES_PER_ELEMENT,o=this.module._malloc(r);return new Uint8Array(this.module.HEAPU8.buffer,o,r).set(new Uint8Array(t.buffer)),new A(o,void 0,(l)=>this.module._free(l))}newTypedArray(e,t){let r=new e(Array(t).fill(0)),o=r.length*r.BYTES_PER_ELEMENT,l=this.module._malloc(o),d=new e(this.module.HEAPU8.buffer,l,t);return d.set(r),new A({typedArray:d,ptr:l},void 0,(f)=>this.module._free(f.ptr))}newMutablePointerArray(e){return this.newTypedArray(Int32Array,e)}newHeapCharPointer(e){let t=this.module.lengthBytesUTF8(e),r=t+1,o=this.module._malloc(r);return this.module.stringToUTF8(e,o,r),new A({ptr:o,strlen:t},void 0,(l)=>this.module._free(l.ptr))}newHeapBufferPointer(e){let t=e.byteLength,r=this.module._malloc(t);return this.module.HEAPU8.set(e,r),new A({pointer:r,numBytes:t},void 0,(o)=>this.module._free(o.pointer))}consumeHeapCharPointer(e){let t=this.module.UTF8ToString(e);return this.module._free(e),t}},Lr,Ur,Xt,Ge=-2147483648,We=2147483647,G=0,Zt=class{constructor(){this.nextId=Ge,this.freelist=[],this.groups=new Map}put(e){let t=this.allocateId(),r=oe(t),o=this.groups.get(r);return o||(o=new Map,this.groups.set(r,o)),o.set(t,e),t}get(e){if(e===G)throw new I("no host reference id defined");let t=oe(e),r=this.groups.get(t);if(!r)throw new I(`host reference id ${e} is not defined`);let o=r.get(e);if(!o)throw new I(`host reference id ${e} is not defined`);return o}delete(e){if(e===G)throw new I("no host reference id defined");let t=oe(e),r=this.groups.get(t);if(!r)throw new I(`host reference id ${e} is not defined`);r.delete(e),r.size===0&&this.groups.delete(t),this.freelist.push(e)}allocateId(){if(this.freelist.length>0)return this.freelist.shift();if(this.nextId===G&&this.nextId++,this.nextId>We)throw new it(`HostRefMap: too many host refs created without disposing. Max simultaneous host refs: ${We-Ge}`);return this.nextId++}},qe,er,tr,rr,nr=class{constructor(e){this.freeHostRef=e.freeHostRef,this.callFunction=e.callFunction,this.shouldInterrupt=e.shouldInterrupt,this.loadModuleSource=e.loadModuleSource,this.normalizeModule=e.normalizeModule}},me=class{constructor(e){this.contextCallbacks=new Map,this.runtimeCallbacks=new Map,this.suspendedCount=0,this.cToHostCallbacks=new nr({freeHostRef:(t,r,o)=>{let l=this.runtimeCallbacks.get(r);if(!l)throw Error(`QuickJSRuntime(rt = ${r}) not found when trying to free HostRef(id = ${o})`);l.freeHostRef(r,o)},callFunction:(t,r,o,l,d,f)=>this.handleAsyncify(t,()=>{try{let s=this.contextCallbacks.get(r);if(!s)throw Error(`QuickJSContext(ctx = ${r}) not found for C function call "${f}"`);return s.callFunction(r,o,l,d,f)}catch(s){return console.error("[C to host error: returning null]",s),0}}),shouldInterrupt:(t,r)=>this.handleAsyncify(t,()=>{try{let o=this.runtimeCallbacks.get(r);if(!o)throw Error(`QuickJSRuntime(rt = ${r}) not found for C interrupt`);return o.shouldInterrupt(r)}catch(o){return console.error("[C to host interrupt: returning error]",o),1}}),loadModuleSource:(t,r,o,l)=>this.handleAsyncify(t,()=>{try{let d=this.runtimeCallbacks.get(r);if(!d)throw Error(`QuickJSRuntime(rt = ${r}) not found for C module loader`);let f=d.loadModuleSource;if(!f)throw Error(`QuickJSRuntime(rt = ${r}) does not support module loading`);return f(r,o,l)}catch(d){return console.error("[C to host module loader error: returning null]",d),0}}),normalizeModule:(t,r,o,l,d)=>this.handleAsyncify(t,()=>{try{let f=this.runtimeCallbacks.get(r);if(!f)throw Error(`QuickJSRuntime(rt = ${r}) not found for C module loader`);let s=f.normalizeModule;if(!s)throw Error(`QuickJSRuntime(rt = ${r}) does not support module loading`);return s(r,o,l,d)}catch(f){return console.error("[C to host module loader error: returning null]",f),0}})}),this.module=e,this.module.callbacks=this.cToHostCallbacks}setRuntimeCallbacks(e,t){this.runtimeCallbacks.set(e,t)}deleteRuntime(e){this.runtimeCallbacks.delete(e)}setContextCallbacks(e,t){this.contextCallbacks.set(e,t)}deleteContext(e){this.contextCallbacks.delete(e)}handleAsyncify(e,t){if(e)return e.handleSleep((o)=>{try{let l=t();if(!(l instanceof Promise)){J("asyncify.handleSleep: not suspending:",l),o(l);return}if(this.suspended)throw new Ze(`Already suspended at: ${this.suspended.stack}
4
4
  Attempted to suspend at:`);this.suspended=new et(`(${this.suspendedCount++})`),J("asyncify.handleSleep: suspending:",this.suspended),l.then((d)=>{this.suspended=void 0,J("asyncify.handleSleep: resolved:",d),o(d)},(d)=>{J("asyncify.handleSleep: rejected:",d),console.error("QuickJS: cannot handle error in suspended function",d),this.suspended=void 0})}catch(l){throw J("asyncify.handleSleep: error:",l),this.suspended=void 0,l}});let r=t();if(r instanceof Promise)throw Error("Promise return value not supported in non-asyncify context.");return r}},at=class{constructor(e,t){this.module=e,this.ffi=t,this.callbacks=new me(e)}newRuntime(e={}){let t=new A(this.ffi.QTS_NewRuntime(),void 0,(o)=>{this.ffi.QTS_FreeRuntime(o),this.callbacks.deleteRuntime(o)}),r=new rr({module:this.module,callbacks:this.callbacks,ffi:this.ffi,rt:t});return pe(r,e),e.moduleLoader&&r.setModuleLoader(e.moduleLoader),r}newContext(e={}){let t=this.newRuntime(),r=t.newContext({...e,ownedLifetimes:zt(t,e.ownedLifetimes)});return t.context=r,r}evalCode(e,t={}){return M.withScope((r)=>{let o=r.manage(this.newContext());_e(o.runtime,t);let l=o.evalCode(e,"eval.js");if(t.memoryLimitBytes!==void 0&&o.runtime.setMemoryLimit(-1),l.error)throw o.dump(r.manage(l.error));return o.dump(r.manage(l.value))})}getWasmMemory(){let e=this.module.quickjsEmscriptenInit?.(()=>{})?.getWasmMemory?.();if(!e)throw Error("Variant does not support getting WebAssembly.Memory");return e}getFFI(){return this.ffi}};var ut=ne(()=>{V();V();Kt=Object.defineProperty;Yt={};Bt(Yt,{QuickJSAsyncifyError:()=>Ze,QuickJSAsyncifySuspended:()=>et,QuickJSEmptyGetOwnPropertyNames:()=>nt,QuickJSEmscriptenModuleError:()=>Jt,QuickJSHostRefInvalid:()=>I,QuickJSHostRefRangeExceeded:()=>it,QuickJSMemoryLeakDetected:()=>Ht,QuickJSNotImplemented:()=>Xe,QuickJSPromisePending:()=>rt,QuickJSUnknownIntrinsic:()=>tt,QuickJSUnwrapError:()=>ae,QuickJSUseAfterFree:()=>ue,QuickJSWrongOwner:()=>ze});ae=class extends Error{constructor(e,t){let r=typeof e=="object"&&e&&"message"in e?String(e.message):String(e);super(r);this.cause=e,this.context=t,this.name="QuickJSUnwrapError"}},ze=class extends Error{constructor(){super(...arguments);this.name="QuickJSWrongOwner"}},ue=class extends Error{constructor(){super(...arguments);this.name="QuickJSUseAfterFree"}},Xe=class extends Error{constructor(){super(...arguments);this.name="QuickJSNotImplemented"}},Ze=class extends Error{constructor(){super(...arguments);this.name="QuickJSAsyncifyError"}},et=class extends Error{constructor(){super(...arguments);this.name="QuickJSAsyncifySuspended"}},Ht=class extends Error{constructor(){super(...arguments);this.name="QuickJSMemoryLeakDetected"}},Jt=class extends Error{constructor(){super(...arguments);this.name="QuickJSEmscriptenModuleError"}},tt=class extends TypeError{constructor(){super(...arguments);this.name="QuickJSUnknownIntrinsic"}},rt=class extends Error{constructor(){super(...arguments);this.name="QuickJSPromisePending"}},nt=class extends Error{constructor(){super(...arguments);this.name="QuickJSEmptyGetOwnPropertyNames"}},it=class extends Error{constructor(){super(...arguments);this.name="QuickJSHostRefRangeExceeded"}},I=class extends Error{constructor(){super(...arguments);this.name="QuickJSHostRefInvalid"}};he=st;he.of=Ft;N=class{[Symbol.dispose](){return this.dispose()}},le=Symbol.dispose??Symbol.for("Symbol.dispose"),$e=N.prototype;$e[le]||($e[le]=function(){return this.dispose()});A=class e extends N{constructor(t,r,o,l){super();this._value=t,this.copier=r,this.disposer=o,this._owner=l,this._alive=!0,this._constructorStack=ce?Error("Lifetime constructed").stack:void 0}get alive(){return this._alive}get value(){return this.assertAlive(),this._value}get owner(){return this._owner}get dupable(){return!!this.copier}dup(){if(this.assertAlive(),!this.copier)throw Error("Non-dupable lifetime");return new e(this.copier(this._value),this.copier,this.disposer,this._owner)}consume(t){this.assertAlive();let r=t(this);return this.dispose(),r}map(t){return this.assertAlive(),t(this)}tap(t){return t(this),this}dispose(){this.assertAlive(),this.disposer&&this.disposer(this._value),this._alive=!1}assertAlive(){if(!this.alive)throw this._constructorStack?new ue(`Lifetime not alive