xmcp 1.10.0 → 1.10.2
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/cli.js +1 -1
- package/dist/client.js +42 -44
- package/dist/cloudflare.js +1 -3
- package/dist/config.js +1 -1
- package/dist/host-bridge.js +1 -1
- package/dist/index.js +55 -52
- package/dist/node.js +1 -1
- package/dist/runtime/adapter-express.js +74 -74
- package/dist/runtime/adapter-fastify.js +74 -74
- package/dist/runtime/adapter-fetch-cloudflare.js +69 -69
- package/dist/runtime/adapter-fetch.js +74 -74
- package/dist/runtime/adapter-nestjs.js +70 -70
- package/dist/runtime/adapter-nextjs.js +72 -72
- package/dist/runtime/cloudflare-worker.js +219 -219
- package/dist/runtime/headers.js +1 -1
- package/dist/runtime/http.js +95 -90
- package/dist/runtime/stdio.js +70 -60
- package/dist/runtime/vercel.js +95 -90
- package/package.json +28 -26
|
@@ -1,44 +1,44 @@
|
|
|
1
|
-
let t,r,i,n,a,o,s,l,c,u,d,p,m,h,f,g,y,v,_,b,S,w,R,k;import{AsyncLocalStorage as x}from"async_hooks";var $,T,C,E,P,O,I,q,j,A,z,N,M,L,Z={},U={};function F(t){var r=U[t];if(void 0!==r)return r.exports;var i=U[t]={exports:{}};return Z[t](i,i.exports,F),i.exports}F.d=(t,r)=>{for(var i in r)F.o(r,i)&&!F.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:r[i]})},F.g=(()=>{if("object"==typeof globalThis)return globalThis;try{return this||Function("return this")()}catch(t){if("object"==typeof window)return window}})(),F.o=(t,r)=>Object.prototype.hasOwnProperty.call(t,r);var D={};F.d(D,{r:()=>hO});var H=Object.create,J=Object.defineProperty,V=Object.getOwnPropertyDescriptor,B=Object.getOwnPropertyNames,W=Object.getPrototypeOf,G=Object.prototype.hasOwnProperty;let K=new Set(["https://json-schema.org/draft/2020-12/schema","http://json-schema.org/draft/2020-12/schema"]),Y=new Set(["https://json-schema.org/draft/2019-09/schema","http://json-schema.org/draft/2019-09/schema"]),X=new Set(["https://json-schema.org/draft-07/schema","http://json-schema.org/draft-07/schema"]),Q=new Set(["https://json-schema.org/draft-06/schema","http://json-schema.org/draft-06/schema"]);function ee(t){let r=Object.values(t).filter(t=>"number"==typeof t);return Object.entries(t).filter(([t,i])=>-1===r.indexOf(+t)).map(([t,r])=>r)}function et(t,r="|"){return t.map(t=>eR(t)).join(r)}function er(t,r){return"bigint"==typeof r?r.toString():r}class ei{constructor(t){this._getter=t,this._value=void 0}get value(){let t=this._getter;return void 0!==t&&(this._value=t(),this._getter=void 0),this._value}}function en(t){return new ei(t)}function ea(t){let r=+!!t.startsWith("^"),i=t.endsWith("$")?t.length-1:t.length;return t.slice(r,i)}let eo=Symbol("evaluating");function es(t,r,i){Object.defineProperty(t,r,{value:i,writable:!0,enumerable:!0,configurable:!0})}function el(t){let r=Object.getOwnPropertyDescriptor(t,"shape");return r?.get?r.get.raw:r?.value}function ec(t){return el(t._zod.def)??t._zod.def.shape}function eu(t,r,i){Object.defineProperty(t,r,{get(){let t=i();return es(this,r,t),t},enumerable:!0,configurable:!0})}function ed(t,r,i){r in t?es(t,r,i):t[r]=i}function ep(t,r,i,n){let a=ec(r);for(let o of i){let i=Object.getOwnPropertyDescriptor(a,o);i.enumerable&&(i.get?eu(t,o,()=>{let t=r._zod.def.shape[o];return n?n(t,o):t}):ed(t,o,n?n(i.value,o):i.value))}}function em(...t){let r={};for(let i of t)Object.assign(r,Object.getOwnPropertyDescriptors(i));return Object.defineProperties({},r)}let eh="captureStackTrace"in Error?Error.captureStackTrace:(...t)=>{};function ef(t){return"object"==typeof t&&null!==t&&!Array.isArray(t)}let eg=en(()=>{if(eG.jitless||"undefined"!=typeof navigator&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{return Function(""),!0}catch(t){return!1}});function ey(t){if(!1===ef(t))return!1;let r=t.constructor;if(void 0===r||"function"!=typeof r)return!0;let i=r.prototype;return!1!==ef(i)&&!1!==Object.prototype.hasOwnProperty.call(i,"isPrototypeOf")}function ev(t){return ey(t)?{...t}:Array.isArray(t)?[...t]:t instanceof Map?new Map(t):t instanceof Set?new Set(t):t}let e_=new Set(["string","number","symbol"]);function eb(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function eS(t,r,i){let n=new t._zod.constr(r??t._zod.def);return(!r||i?.parent)&&(n._zod.parent=t),n}function ew(t){if(!t)return{};if("string"==typeof t)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}return(delete t.message,"string"==typeof t.error)?{...t,error:()=>t.error}:t}function eR(t){return"bigint"==typeof t?t.toString()+"n":"string"==typeof t?`"${t}"`:`${t}`}let ek={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-0x80000000,0x7fffffff],uint32:[0,0xffffffff],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},ex={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function e$(t,r){let i=ec(t),n=[];for(let t of Reflect.ownKeys(r)){if(!Object.getOwnPropertyDescriptor(i,t)?.enumerable)throw Error(`Unrecognized key: "${String(t)}"`);r[t]&&n.push(t)}return n}function eT(t,r){let i={};ep(i,t,Reflect.ownKeys(ec(t)));for(let t of Reflect.ownKeys(r)){let n=Object.getOwnPropertyDescriptor(r,t);n.enumerable&&(n.get?eu(i,t,()=>r[t]):ed(i,t,n.value))}return i}function eC(t,r,i,n="partial"){let a=r._zod.def.checks;if(a&&a.length>0)throw Error(`.${n}() cannot be used on object schemas containing refinements`);let o=i?new Set(e$(r,i)):void 0,s={};return ep(s,r,Reflect.ownKeys(ec(r)),t&&((r,i)=>o&&!o.has(i)?r:new t({type:"optional",innerType:r}))),eS(r,em(r._zod.def,{shape:s,checks:[]}))}function eE(t,r=0){if(!0===t.aborted)return!0;for(let i=r;i<t.issues.length;i++)if(t.issues[i]?.continue!==!0)return!0;return!1}function eP(t,r){return r.map(r=>(r.path??(r.path=[]),r.path.unshift(t),r))}function eO(t){return"string"==typeof t?t:t?.message}function eI(t,r,i){var n;for(let a=r;a<t.length;a++)(n=t[a]).schema??(n.schema=i)}function eq(t,r,i){let n=t.inst?._zod?.traits;n?.has("$ZodType")&&(n.has("$ZodCheck")?t.schema??(t.schema=t.inst):t.schema=t.inst);let a=t.schema!==t.inst?t.schema?._zod.def?.error:void 0,o=t.message?t.message:eO(t.inst?._zod.def?.error?.(t))??eO(a?.(t))??eO(r?.error?.(t))??eO(i.customError?.(t))??eO(i.localeError?.(t))??"Invalid input",s={};for(let r of Object.keys(t))"inst"!==r&&"schema"!==r&&"continue"!==r&&"input"!==r&&"__proto__"!==r&&(s[r]=t[r]);return s.path??(s.path=[]),s.message=o,r?.reportInput&&(s.input=t.input),s}let ej=/[\uD800-\uDBFF]/;function eA(t){let r=t.length;if(!ej.test(t))return r;let i=r;for(let n=0;n<r-1;n++)(64512&t.charCodeAt(n))==55296&&(64512&t.charCodeAt(n+1))==56320&&(i--,n++);return i}function ez(t){return Array.isArray(t)?"array":"string"==typeof t?"string":"unknown"}function eN(...t){let[r,i,n]=t;return"string"==typeof r?{message:r,code:"custom",input:i,inst:n}:{...r}}function eM(t,r,i,n=!0){return Object.defineProperty(t,r,{configurable:!0,writable:!0,enumerable:n,value:i}),i}function eL(t,r){for(let i in t){let n=t[i];Object.defineProperty(r,i,{configurable:!0,enumerable:!0,get(){return eM(this,i,n(this))},set(t){eM(this,i,t)}})}return r}let eZ=!1,eU={configurable:!0,get(){eZ=!0}};function eF(r,i,n){let a=Object.getPrototypeOf(r._zod);if(i in a&&t!==r._zod){t=void 0;return}t=r._zod,Object.defineProperty(a,i,{configurable:!0,get(){Object.defineProperty(this,i,eU);let t=eZ;eZ=!1;try{let r=n(this);return eZ?delete this[i]:Object.defineProperty(this,i,{configurable:!0,writable:!0,value:r}),eZ=eZ||t,r}catch(r){throw delete this[i],eZ=eZ||t,r}},set(t){Object.defineProperty(this,i,{configurable:!0,writable:!0,value:t})}})}let eD=Object.freeze({status:"aborted"}),eH={value:void 0,enumerable:!1},eJ="captureStackTrace"in Error?Error:null;function eV(t,r,i,n){function a(t){this.def=t,this.constr=u,this.traits=new Set}a.prototype={};let o=i&&new WeakSet;function s(n,s){if(n._zod){if(n._zod.traits.has(t))return}else{eH.value=new a(s);try{Object.defineProperty(n,"_zod",eH)}finally{eH.value=void 0}}if(n._zod.traits.add(t),r(n,s),o){let t=Object.getPrototypeOf(n),r=n._zod.constr.prototype,a=t;for(;a&&a!==r;)a=Object.getPrototypeOf(a);let s=a??t;if(!o.has(s)){o.add(s);for(let t in i){let r=Object.getOwnPropertyDescriptor(i,t);r.get?Object.defineProperty(s,t,{...r,enumerable:!1}):function(t,r,i){Object.defineProperty(t,r,{configurable:!0,get(){return this==null?i:eM(this,r,i.bind(this))},set(t){eM(this,r,t)}})}(s,t,r.value)}}}let l=u.prototype;for(let t in l)Object.prototype.hasOwnProperty.call(l,t)&&(t in n||(n[t]=l[t].bind(n)))}let l=n?.Parent??Object;class c extends l{}function u(t){let r=n?.Parent?function(t){let r=eJ;if(r){let i=r.stackTraceLimit;if("number"==typeof i){try{r.stackTraceLimit=0}catch{return eJ=null,new t}try{return new t}finally{r.stackTraceLimit=i}}}return new t}(c):this;s(r,t);let i=r._zod.deferred;if(i){for(let t of i)t();r._zod.deferred=void 0}let a=globalThis.__zod_globalConfig?.postProcessor;return a&&a(r),r}return Object.defineProperty(c,"name",{value:t}),Object.defineProperty(u,"init",{value:s}),Object.defineProperty(u,Symbol.hasInstance,{value:r=>!!n?.Parent&&r instanceof n.Parent||r?._zod?.traits?.has(t)}),Object.defineProperty(u,"name",{value:t}),u}class eB extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class eW extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}}(q=globalThis).__zod_globalConfig??(q.__zod_globalConfig={});let eG=globalThis.__zod_globalConfig;function eK(t){return t&&Object.assign(eG,t),eG}class eY extends Error{constructor(){super("Cannot parse a reference cycle that closes through a transform"),this.name="ZodCyclicError"}}let eX="~memo",eQ=[];function e0(t){return null!==t&&"object"==typeof t}function e1(t){return t.map(t=>t.path?{...t,path:t.path.slice()}:{...t})}let e2=new WeakMap,e9=[],e4={alloc(t,i,n){let a=r;if(!a)return n;r=void 0;let o={value:n,issues:null};return a.set(i.value,o),e9.push(o),n},guard(t){var r;(r=t._zod).deferred??(r.deferred=[]),t._zod.deferred.push(()=>{let r=t._zod.parse,i=(t,i)=>{var n,a;let o;if("backward"!==i.direction&&(n=i,a=t.value,void 0!==(o=n[eX]?.backEdges)&&e0(a)&&o.has(a)))throw new eY;return r(t,i)};t._zod.parse=i,t._zod.run===r&&(t._zod.run=i)})},attach(t){var i;let n,a,o,s=!1;(i=t._zod).deferred??(i.deferred=[]),t._zod.deferred.push(()=>{let i=t._zod.parse,l=(c,u)=>{let d;if(void 0===n){let r=function t(r,i,n){var a,o;let s=e2.get(r);if(void 0!==s)return 2*!!s;if(i.has(r))return 2;i.add(r);let l=0,c=r=>{if(2!==l&&r?._zod){let a=t(r,i,n);a>l&&(l=a)}},u=t=>{t>l&&(l=t)},d=r._zod.def;switch(d.type){case"object":{let r=el(d);u(r?((r,a)=>{let o=0;for(let s of Reflect.ownKeys(r)){let l=Object.getOwnPropertyDescriptor(r,s);if(a&&!l.enumerable)continue;let c=l.get?1:l.value?._zod?t(l.value,i,n):0;c>o&&(o=c)}return o})(r,!0):1),c(d.catchall);break}case"array":c(d.element);break;case"tuple":for(let t of d.items)c(t);c(d.rest);break;case"record":case"map":c(d.keyType),c(d.valueType);break;case"set":c(d.valueType);break;case"union":for(let t of d.options)c(t);break;case"intersection":c(d.left),c(d.right);break;case"optional":case"nullable":case"default":case"prefault":case"catch":case"readonly":case"nonoptional":case"promise":case"success":c(d.innerType);break;case"pipe":c(d.in),c(d.out);break;case"function":c(d.input),c(d.output);break;case"lazy":{let a=d._cachedInner??(n?r._zod.innerType:void 0);u(a?t(a,i,!1):1);break}case"template_literal":case"string":case"number":case"int":case"boolean":case"bigint":case"symbol":case"undefined":case"null":case"void":case"never":case"any":case"unknown":case"date":case"nan":case"enum":case"literal":case"file":case"transform":case"custom":break;default:for(let t in d){let r=Object.getOwnPropertyDescriptor(d,t);if(!r||r.get)continue;let i=r.value;if(i&&"object"==typeof i){if(i._zod)c(i);else if(Array.isArray(i))for(let t of i)c(t)}}}return i.delete(r),a=r,1!==(o=l)&&e2.set(a,2===o),o}(t,new Set,!1);if(0===r)return t._zod.parse=i,t._zod.run===l&&(t._zod.run=i),i(c,u);2===r||s?n=!0:s=!0}let p=c.value;if(!e0(p))return i(c,u);let m=u[eX];if(m||(m={buckets:new WeakMap,backEdges:void 0},u[eX]=m),a===u)d=o;else{var h;let r;(r=(h=m).buckets.get(t))||(r=new WeakMap,h.buckets.set(t,r)),d=r,a=u,o=d}let f=d.get(p);if(f)return c.value=f.value,f.issues?f.issues.length&&c.issues.push(...e1(f.issues)):(c.memo=!0,m.backEdges??(m.backEdges=new WeakSet),m.backEdges.add(f.value)),c;r=d;let g=e9.length,y=i(c,u);r=void 0;let v=e9.length>g?e9.pop():void 0;return y instanceof Promise?y.then(t=>(v&&(v.issues=t.issues.length?e1(t.issues):eQ),t)):(v&&(v.issues=y.issues.length?e1(y.issues):eQ),y)};t._zod.parse=l,t._zod.run===i&&(t._zod.run=l)})}},e3=/^[cC][0-9a-z]{6,}$/,e6=/^[0-9a-z]+$/,e5=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,e7=/^[0-9a-vA-V]{20}$/,e8=/^[A-Za-z0-9]{27}$/,te=/^[a-zA-Z0-9_-]{21}$/,tt=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,tr=/^([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})$/,ti=t=>t?RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${t}[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)$/,tn=/^(?:[A-Za-z0-9_'+\-]+\.)*[A-Za-z0-9_'+\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,ta=`^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$`,to=/^(?:(?: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])$/,ts=/^(([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}|:))$/,tl=/^((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])$/,tc=/^(([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])$/,tu=/^https?$/,td=/^\+[1-9]\d{6,14}$/,tp="(?:(?:\\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])))",tm=RegExp(`^${tp}$`);function th(t){let r="(?:[01]\\d|2[0-3]):[0-5]\\d";return"number"==typeof t.precision?-1===t.precision?`${r}`:0===t.precision?`${r}:[0-5]\\d`:`${r}:[0-5]\\d\\.\\d{${t.precision}}`:t.seconds?`${r}:[0-5]\\d(?:\\.\\d+)?`:`${r}(?::[0-5]\\d(?:\\.\\d+)?)?`}let tf=/^[\s\S]{0,}$/,tg=/^-?\d+$/,ty=/^-?\d+(?:\.\d+)?$/,tv=/^(?:true|false)$/i,t_=/^null$/i,tb=/^[^A-Z]*$/,tS=/^[^a-z]*$/,tw=eV("$ZodCheck",(t,r)=>{var i;t._zod??(t._zod={}),t._zod.def=r,(i=t._zod).onattach??(i.onattach=[])}),tR=t=>{let r=t.value;return null!=r&&void 0!==r.length},tk={number:"number",bigint:"bigint",object:"date"},tx=eV("$ZodCheckLessThan",(t,r)=>{tw.init(t,r);let i=tk[typeof r.value];t._zod.check=n=>{(r.inclusive?n.value<=r.value:n.value<r.value)||n.issues.push({origin:tk[typeof n.value]??i,code:"too_big",maximum:"object"==typeof r.value?r.value.getTime():r.value,input:n.value,inclusive:r.inclusive,inst:t,continue:!r.abort})}}),t$=eV("$ZodCheckGreaterThan",(t,r)=>{tw.init(t,r);let i=tk[typeof r.value];t._zod.check=n=>{(r.inclusive?n.value>=r.value:n.value>r.value)||n.issues.push({origin:tk[typeof n.value]??i,code:"too_small",minimum:"object"==typeof r.value?r.value.getTime():r.value,input:n.value,inclusive:r.inclusive,inst:t,continue:!r.abort})}}),tT=eV("$ZodCheckMultipleOf",(t,r)=>{tw.init(t,r),t._zod.check=i=>{let n,a,o;if(typeof i.value!=typeof r.value)throw Error("Cannot mix number and bigint in multiple_of check.");("bigint"==typeof i.value?r.value!==BigInt(0)&&i.value%r.value===BigInt(0):0==(a=Math.round(n=i.value/r.value),o=4*Number.EPSILON*Math.max(Math.abs(n),1),Math.abs(n-a)<o?0:n-a))||i.issues.push({origin:typeof i.value,code:"not_multiple_of",divisor:r.value,input:i.value,inst:t,continue:!r.abort})}}),tC=eV("$ZodCheckNumberFormat",(t,r)=>{tw.init(t,r),r.format=r.format||"float64";let i=r.format?.includes("int"),n=i?"int":"number",[a,o]=ek[r.format];t._zod.check=s=>{let l=s.value;if(i){if(!Number.isInteger(l))return void s.issues.push({expected:n,format:r.format,code:"invalid_type",continue:!1,input:l,inst:t});if(!Number.isSafeInteger(l))return void(l>0?s.issues.push({input:l,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:t,origin:n,inclusive:!0,continue:!r.abort}):s.issues.push({input:l,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:t,origin:n,inclusive:!0,continue:!r.abort}))}l<a&&s.issues.push({origin:"number",input:l,code:"too_small",minimum:a,inclusive:!0,inst:t,continue:!r.abort}),l>o&&s.issues.push({origin:"number",input:l,code:"too_big",maximum:o,inclusive:!0,inst:t,continue:!r.abort})}}),tE=eV("$ZodCheckMaxLength",(t,r)=>{var i;tw.init(t,r),(i=t._zod.def).when??(i.when=tR),t._zod.check=i=>{let n=i.value,a=n.length;if(("string"==typeof n&&a>r.maximum?eA(n):a)<=r.maximum)return;let o=ez(n);i.issues.push({origin:o,code:"too_big",maximum:r.maximum,inclusive:!0,input:n,inst:t,continue:!r.abort})}}),tP=eV("$ZodCheckMinLength",(t,r)=>{var i;tw.init(t,r),(i=t._zod.def).when??(i.when=tR),t._zod.check=i=>{let n=i.value,a=n.length;if(("string"==typeof n&&a>=r.minimum&&a<2*r.minimum?eA(n):a)>=r.minimum)return;let o=ez(n);i.issues.push({origin:o,code:"too_small",minimum:r.minimum,inclusive:!0,input:n,inst:t,continue:!r.abort})}}),tO=eV("$ZodCheckLengthEquals",(t,r)=>{var i;tw.init(t,r),(i=t._zod.def).when??(i.when=tR),t._zod.check=i=>{let n=i.value,a=n.length,o="string"==typeof n&&a>=r.length&&a<=2*r.length?eA(n):a;if(o===r.length)return;let s=ez(n),l=o>r.length;i.issues.push({origin:s,...l?{code:"too_big",maximum:r.length}:{code:"too_small",minimum:r.length},inclusive:!0,exact:!0,input:i.value,inst:t,continue:!r.abort})}}),tI=eV("$ZodCheckStringFormat",(t,r)=>{var i,n;tw.init(t,r),r.pattern?(i=t._zod).check??(i.check=i=>{r.pattern.lastIndex=0,r.pattern.test(i.value)||i.issues.push({origin:"string",code:"invalid_format",format:r.format,input:i.value,...r.pattern?{pattern:r.pattern.toString()}:{},inst:t,continue:!r.abort})}):(n=t._zod).check??(n.check=()=>{})}),tq=eV("$ZodCheckRegex",(t,r)=>{tI.init(t,r),t._zod.check=i=>{r.pattern.lastIndex=0,r.pattern.test(i.value)||i.issues.push({origin:"string",code:"invalid_format",format:"regex",input:i.value,pattern:r.pattern.toString(),inst:t,continue:!r.abort})}}),tj=eV("$ZodCheckLowerCase",(t,r)=>{r.pattern??(r.pattern=tb),tI.init(t,r)}),tA=eV("$ZodCheckUpperCase",(t,r)=>{r.pattern??(r.pattern=tS),tI.init(t,r)}),tz=eV("$ZodCheckIncludes",(t,r)=>{tw.init(t,r);let i=eb(r.includes),n=new RegExp("number"==typeof r.position?`^.{${r.position},}${i}`:i);r.pattern=n,t._zod.check=i=>{i.value.includes(r.includes,r.position)||i.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:r.includes,input:i.value,inst:t,continue:!r.abort})}}),tN=eV("$ZodCheckStartsWith",(t,r)=>{tw.init(t,r);let i=RegExp(`^${eb(r.prefix)}.*`);r.pattern??(r.pattern=i),t._zod.check=i=>{i.value.startsWith(r.prefix)||i.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:r.prefix,input:i.value,inst:t,continue:!r.abort})}}),tM=eV("$ZodCheckEndsWith",(t,r)=>{tw.init(t,r);let i=RegExp(`.*${eb(r.suffix)}$`);r.pattern??(r.pattern=i),t._zod.check=i=>{i.value.endsWith(r.suffix)||i.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:r.suffix,input:i.value,inst:t,continue:!r.abort})}}),tL=eV("$ZodCheckOverwrite",(t,r)=>{tw.init(t,r),t._zod.check=t=>{t.value=r.tx(t.value)}});class tZ{constructor(t=[],r={}){this.content=[],this.indent=0,this.args=t,this.closed=r}indented(t){this.indent+=1;try{t(this)}finally{this.indent-=1}}write(t){if("function"==typeof t){t(this,{execution:"sync"}),t(this,{execution:"async"});return}let r=t.split("\n").filter(t=>t),i=Math.min(...r.map(t=>t.length-t.trimStart().length));for(let t of r.map(t=>t.slice(i)).map(t=>" ".repeat(2*this.indent)+t))this.content.push(t)}compile(){let t=Function,r=this?.content??[""];return new t(...Object.keys(this.closed),`return function (${this.args.join(", ")}) {
|
|
2
|
-
${
|
|
3
|
-
};`)(...Object.values(this.closed))}}let tU={major:4,minor:6,patch:5},tF=eV("$ZodType",(t,r)=>{var i;t??(t={}),t._zod.def=r,t._zod.bag=t._zod.bag||{},t._zod.version=tU;let n=t._zod.def.checks,a=t._zod.traits.has("$ZodCheck")?[t,...n??[]]:n?.length?[...n]:[];for(let r of a)for(let i of r._zod.onattach)i(t);if(0===a.length)(i=t._zod).deferred??(i.deferred=[]),t._zod.deferred?.push(()=>{t._zod.run=t._zod.parse});else{let r=(r,i,n)=>{let a;if(r.memo)return r;let o=eE(r);for(let s of i){if(s._zod.def.when){if(function(t,r=0){if(!0===t.aborted)return!0;for(let i=r;i<t.issues.length;i++)if(t.issues[i]?.continue===!1)return!0;return!1}(r)||!s._zod.def.when(r))continue}else if(o)continue;let i=r.issues.length,l=s._zod.check(r);if(l instanceof Promise&&n?.async===!1)throw new eB;if(a||l instanceof Promise)a=(a??Promise.resolve()).then(async()=>{await l,r.issues.length!==i&&(eI(r.issues,i,t),o||(o=eE(r,i)))});else{if(r.issues.length===i)continue;eI(r.issues,i,t),o||(o=eE(r,i))}}return a?a.then(()=>r):r},i=(i,n,o)=>{if(eE(i))return i.aborted=!0,i;let s=r(n,a,o);if(s instanceof Promise){if(!1===o.async)throw new eB;return s.then(r=>t._zod.parse(r,o))}return t._zod.parse(s,o)};t._zod.run=(n,o)=>{if(o.skipChecks)return t._zod.parse(n,o);if("backward"===o.direction){let r=t._zod.parse({value:n.value,issues:[]},{...o,skipChecks:!0});return r instanceof Promise?r.then(t=>i(t,n,o)):i(r,n,o)}let s=t._zod.parse(n,o);if(s instanceof Promise){if(!1===o.async)throw new eB;return s.then(t=>r(t,a,o))}return r(s,a,o)}}},{get"~standard"(){return eM(this,"~standard",tJ(this),!1)},set"~standard"(value){eM(this,"~standard",value)}}),tD=(t,r)=>t.issues.length?{issues:t.issues.map(t=>eq(t,r,eK()))}:{value:t.value};async function tH(t,r){let i={async:!0};return tD(await t._zod.run({value:r,issues:[]},i),i)}function tJ(t){return{validate:r=>{let i={async:!1};try{let n=t._zod.run({value:r,issues:[]},i);if(!(n instanceof Promise))return tD(n,i)}catch(t){}return tH(t,r)},vendor:"zod",version:1}}let tV=eV("$ZodString",(t,r)=>{tF.init(t,r),t._zod.pattern=r.pattern??tf,t._zod.parse=(i,n)=>{if(r.coerce)try{i.value=String(i.value)}catch(t){}return"string"==typeof i.value||i.issues.push({expected:"string",code:"invalid_type",input:i.value,inst:t}),i}}),tB=eV("$ZodStringFormat",(t,r)=>{tI.init(t,r),tV.init(t,r)}),tW=eV("$ZodGUID",(t,r)=>{r.pattern??(r.pattern=tr),tB.init(t,r)}),tG=eV("$ZodUUID",(t,r)=>{if(r.version){let t={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[r.version];if(void 0===t)throw Error(`Invalid UUID version: "${r.version}"`);r.pattern??(r.pattern=ti(t))}else r.pattern??(r.pattern=ti());tB.init(t,r)}),tK=eV("$ZodEmail",(t,r)=>{r.pattern??(r.pattern=tn),tB.init(t,r)});function tY(t){try{if("undefined"!=typeof URL&&"function"==typeof URL.canParse)return URL.canParse(t);return new URL(t),!0}catch{return!1}}let tX=/[\t\n\r]/g;function tQ(t){return t.replace(tX,"")}let t0=eV("$ZodURL",(t,r)=>{tB.init(t,r),t._zod.check=i=>{try{var n,a;let o=i.value.trim(),s="normalize"in r||"hostname"in r||"protocol"in r?function(t,r){if(!r.normalize&&r.protocol?.source===tu.source&&!/^https?:\/\//i.test(t))return 1;try{if("undefined"!=typeof URL){let r=URL;if("function"==typeof r.parse)return r.parse(t)??2}return new URL(t)}catch{return 2}}(o,r):tY(o)||2;if(1===s)return void i.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:i.value,inst:t,continue:!r.abort});if(2===s)return void i.issues.push({code:"invalid_format",format:"url",input:i.value,inst:t,continue:!r.abort});if(!0===s){i.value=tQ(o);return}r.hostname&&((n=r.hostname).lastIndex=0,!n.test(s.hostname))&&i.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:r.hostname.source,input:i.value,inst:t,continue:!r.abort}),r.protocol&&((a=r.protocol).lastIndex=0,!a.test(s.protocol.endsWith(":")?s.protocol.slice(0,-1):s.protocol))&&i.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:r.protocol.source,input:i.value,inst:t,continue:!r.abort}),i.value=r.normalize?s.href:tQ(o);return}catch(n){i.issues.push({code:"invalid_format",format:"url",input:i.value,inst:t,continue:!r.abort})}}}),t1=eV("$ZodEmoji",(t,r)=>{r.pattern??(r.pattern=RegExp(ta,"u")),tB.init(t,r)}),t2=eV("$ZodNanoID",(t,r)=>{var i;if(void 0!==r.length&&(!Number.isInteger(r.length)||r.length<1))throw Error(`Invalid nanoid length: ${r.length}`);r.pattern??(r.pattern=void 0===r.length?te:(i=r.length,RegExp(`^[a-zA-Z0-9_-]{${i}}$`))),tB.init(t,r)}),t9=eV("$ZodCUID",(t,r)=>{r.pattern??(r.pattern=e3),tB.init(t,r)}),t4=eV("$ZodCUID2",(t,r)=>{r.pattern??(r.pattern=e6),tB.init(t,r)}),t3=eV("$ZodULID",(t,r)=>{r.pattern??(r.pattern=e5),tB.init(t,r)}),t6=eV("$ZodXID",(t,r)=>{r.pattern??(r.pattern=e7),tB.init(t,r)}),t5=eV("$ZodKSUID",(t,r)=>{r.pattern??(r.pattern=e8),tB.init(t,r)}),t7=eV("$ZodISODateTime",(t,r)=>{let i,n,a;r.pattern??(i=["Z"],r.offset&&i.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)"),n=`${th({precision:r.precision,seconds:!0})}(?:${i.join("|")})`,a=r.local?`${n}|${th({precision:r.precision})}`:n,r.pattern=RegExp(`^${tp}T(?:${a})$`)),tB.init(t,r)}),t8=eV("$ZodISODate",(t,r)=>{r.pattern??(r.pattern=tm),tB.init(t,r)}),re=eV("$ZodISOTime",(t,r)=>{r.pattern??(r.pattern=RegExp(`^${th(r)}$`)),tB.init(t,r)}),rt=eV("$ZodISODuration",(t,r)=>{r.pattern??(r.pattern=tt),tB.init(t,r)}),rr=eV("$ZodIPv4",(t,r)=>{r.pattern??(r.pattern=to),tB.init(t,r)}),ri=/^[0-9a-fA-F:.]+$/;function rn(t){return!!ri.test(t)&&tY(`http://[${t}]`)}let ra=eV("$ZodIPv6",(t,r)=>{r.pattern??(r.pattern=ts),tB.init(t,r),t._zod.check=i=>{rn(i.value)||i.issues.push({code:"invalid_format",format:"ipv6",input:i.value,inst:t,continue:!r.abort})}}),ro=eV("$ZodCIDRv4",(t,r)=>{r.pattern??(r.pattern=tl),tB.init(t,r)}),rs=eV("$ZodCIDRv6",(t,r)=>{r.pattern??(r.pattern=tc),tB.init(t,r),t._zod.check=i=>{!function(t){let r=t.split("/");if(2!==r.length)return!1;let[i,n]=r;if(!n)return!1;let a=Number(n);return`${a}`===n&&!(a<0)&&!(a>128)&&rn(i)}(i.value)&&i.issues.push({code:"invalid_format",format:"cidrv6",input:i.value,inst:t,continue:!r.abort})}});function rl(t){if(""===t)return!0;if(/\s/.test(t)||t.length%4!=0)return!1;try{return atob(t),!0}catch{return!1}}let rc=/^[0-9a-zA-Z+/]*={0,2}$/,ru=eV("$ZodBase64",(t,r)=>{r.pattern??(r.pattern=rc),tB.init(t,r),t._zod.check=i=>{rl(i.value)||i.issues.push({code:"invalid_format",format:"base64",input:i.value,inst:t,continue:!r.abort})}}),rd=/^[A-Za-z0-9_-]*$/,rp=eV("$ZodBase64URL",(t,r)=>{r.pattern??(r.pattern=rd),tB.init(t,r),t._zod.check=i=>{!function(t){if(!rd.test(t))return!1;let r=t.replace(/[-_]/g,t=>"-"===t?"+":"/");return rl(r.padEnd(4*Math.ceil(r.length/4),"="))}(i.value)&&i.issues.push({code:"invalid_format",format:"base64url",input:i.value,inst:t,continue:!r.abort})}}),rm=eV("$ZodE164",(t,r)=>{r.pattern??(r.pattern=td),tB.init(t,r)}),rh=eV("$ZodJWT",(t,r)=>{tB.init(t,r),t._zod.check=i=>{!function(t,r=null){try{let i=t.split(".");if(3!==i.length)return!1;let[n]=i;if(!n)return!1;let a=JSON.parse(atob(n));if("typ"in a&&a?.typ!=="JWT"||!a.alg||r&&(!("alg"in a)||a.alg!==r))return!1;return!0}catch{return!1}}(i.value,r.alg)&&i.issues.push({code:"invalid_format",format:"jwt",input:i.value,inst:t,continue:!r.abort})}}),rf=eV("$ZodNumber",(t,r)=>{tF.init(t,r),t._zod.pattern=ty,t._zod.parse=(i,n)=>{if(r.coerce)try{i.value=Number(i.value)}catch(t){}let a=i.value;if("number"==typeof a&&!Number.isNaN(a)&&Number.isFinite(a))return i;let o="number"==typeof a?Number.isNaN(a)?"NaN":Number.isFinite(a)?void 0:String(a):void 0;return i.issues.push({expected:"number",code:"invalid_type",input:a,inst:t,...o?{received:o}:{}}),i}}),rg=eV("$ZodNumberFormat",(t,r)=>{tC.init(t,r),rf.init(t,r)}),ry=eV("$ZodBoolean",(t,r)=>{tF.init(t,r),t._zod.pattern=tv,t._zod.parse=(i,n)=>{if(r.coerce)try{i.value=!!i.value}catch(t){}let a=i.value;return"boolean"==typeof a||i.issues.push({expected:"boolean",code:"invalid_type",input:a,inst:t}),i}}),rv=eV("$ZodNull",(t,r)=>{tF.init(t,r),t._zod.pattern=t_,t._zod.values=new Set([null]),t._zod.parse=(r,i)=>{let n=r.value;return null===n||r.issues.push({expected:"null",code:"invalid_type",input:n,inst:t}),r}}),r_=eV("$ZodAny",(t,r)=>{tF.init(t,r),t._zod.parse=t=>t}),rb=eV("$ZodUnknown",(t,r)=>{tF.init(t,r),t._zod.parse=t=>t}),rS=eV("$ZodNever",(t,r)=>{tF.init(t,r),t._zod.parse=(r,i)=>(r.issues.push({expected:"never",code:"invalid_type",input:r.value,inst:t}),r)});function rw(t,r,i){t.issues.length&&r.issues.push(...eP(i,t.issues)),r.value[i]=t.value}let rR=eV("$ZodArray",(t,r)=>{tF.init(t,r);let i=eG.memoizer;i?.attach(t),t._zod.parse=(n,a)=>{let o=n.value;if(!Array.isArray(o))return n.issues.push({expected:"array",code:"invalid_type",input:o,inst:t}),n;n.value=i?i.alloc(t,n,Array(o.length),a):Array(o.length);let s=[],l=a?.abortEarly;for(let t=0;t<o.length;t++){let i=o[t],c=r.element._zod.run({value:i,issues:[]},a);if(c instanceof Promise)s.push(c.then(r=>rw(r,n,t)));else if(rw(c,n,t),l&&0!==c.issues.length&&eE(c))break}return s.length?Promise.all(s).then(()=>n):n}});function rk(t,r,i,n,a,o){let s=i in n,l="optional"===o;if(s||!l||"optional"!==a){if(t.issues.length){if(void 0!==a&&l&&!s)return;r.issues.push(...eP(i,t.issues))}if(!s&&void 0===a){t.issues.length||r.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[i]});return}void 0===t.value?(s||"defaulted"===a&&!l)&&(r.value[i]=void 0):r.value[i]=t.value}}let rx=[];function r$(t){var r;let i=Object.keys(t.shape),n=Object.getOwnPropertySymbols(t.shape),a=n.length?n:rx,o=a.length?[...i,...a]:i;for(let r of o)if(!t.shape?.[r]?._zod?.traits?.has("$ZodType"))throw Error(`Invalid element at key "${String(r)}": expected a Zod schema`);let s=Object.keys(r=t.shape).filter(t=>void 0!==r[t]._zod.optin&&"optional"===r[t]._zod.optout);return{...t,allKeys:o,symbolKeys:a,keySet:new Set(i),numKeys:i.length,optionalKeys:new Set(s)}}function rT(t,r,i,n,a,o,s){let l=[],c=a.keySet,u=a.catchall._zod,d=u.def.type,p=u.optin,m=u.optout,h=0;for(let a in r){if(s&&i.issues.length!==h){if(eE(i,h))break;h=i.issues.length}if(c.has(a))continue;if("__proto__"===a){"never"===d&&l.push(a);continue}if("never"===d){l.push(a);continue}let o=u.run({value:r[a],issues:[]},n);o instanceof Promise?t.push(o.then(t=>rk(t,i,a,r,p,m))):rk(o,i,a,r,p,m)}return(l.length&&i.issues.push({code:"unrecognized_keys",keys:l,input:r,inst:o,continue:!0}),t.length)?Promise.all(t).then(()=>i):i}let rC=eV("$ZodObject",(t,r)=>{let i;tF.init(t,r);let n=Object.getOwnPropertyDescriptor(r,"shape"),a=n?.get?n.get.raw:r.shape??{};if(a){let t=()=>{let i={...a};return Object.defineProperty(r,"shape",{value:i}),t.raw=i,i};t.raw=a,Object.defineProperty(r,"shape",{get:t})}let o=en(()=>r$(r));eF(t,"propValues",t=>{let r=t.def.shape,i={};for(let t in r){let n=r[t]._zod;if(n.values){for(let r of(Object.prototype.hasOwnProperty.call(i,t)||es(i,t,new Set),n.values))i[t].add(r);void 0!==n.optin&&i[t].add(void 0)}}return i});let s=r.catchall,l=eG.memoizer;l?.attach(t),t._zod.parse=(r,n)=>{i??(i=o.value);let a=r.value;if(!ef(a))return r.issues.push({expected:"object",code:"invalid_type",input:a,inst:t}),r;r.value=l?l.alloc(t,r,{},n):{};let c=[],u=i.shape,d=n?.abortEarly,p=r.issues.length;for(let t of i.allKeys){if(d&&r.issues.length!==p){if(eE(r,p))break;p=r.issues.length}if("__proto__"===t)continue;let i=u[t],o=i._zod.optin,s=i._zod.optout,l=i._zod.run({value:a[t],issues:[]},n);l instanceof Promise?c.push(l.then(i=>rk(i,r,t,a,o,s))):rk(l,r,t,a,o,s)}return s?rT(c,a,r,n,o.value,t,!0===d):c.length?Promise.all(c).then(()=>r):r}}),rE=eV("$ZodObjectJIT",(t,r)=>{let i,n;rC.init(t,r);let a=t._zod.parse,o=en(()=>r$(r)),s=eG.memoizer,l=!eG.jitless,c=l&&eg.value,u=r.catchall;t._zod.parse=(d,p)=>{n??(n=o.value);let m=d.value;return ef(m)?l&&c&&p?.async===!1&&!0!==p.jitless?(i||(i=(r=>{let i=o.value,n=i.symbolKeys,a=new tZ(["payload","ctx"],{shape:r,inst:t,memo:s,syms:n}),l=t=>`shape[${t}]._zod.run({ value: input[${t}], issues: [] }, ctx)`,c=(t,r)=>`
|
|
4
|
-
let ${
|
|
5
|
-
for (let i = 0; i < ${
|
|
6
|
-
const iss = ${
|
|
7
|
-
iss.path = iss.path ? [${
|
|
1
|
+
let e,t,r,i,n,a,o,s,l,c,u,d,p,m,h,f,g,y,v,_,b,S,w,R,k;import{AsyncLocalStorage as x}from"async_hooks";var $,T,C,P,O,E,I,q,j,z,A,N,M,L,Z={},U={};function F(e){var t=U[e];if(void 0!==t)return t.exports;var r=U[e]={exports:{}};return Z[e](r,r.exports,F),r.exports}F.d=(e,t,r)=>{var i=(t,r)=>{for(var i in t)F.o(t,i)&&!F.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,[r]:t[i]})};i(t,"get"),i(r,"value")},F.g=(()=>{if("object"==typeof globalThis)return globalThis;try{return this||Function("return this")()}catch(e){if("object"==typeof window)return window}})(),F.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var D={};F.d(D,{r:()=>hh});var H=Object.create,J=Object.defineProperty,V=Object.getOwnPropertyDescriptor,B=Object.getOwnPropertyNames,W=Object.getPrototypeOf,G=Object.prototype.hasOwnProperty;let K=new Set(["https://json-schema.org/draft/2020-12/schema","http://json-schema.org/draft/2020-12/schema"]),Y=new Set(["https://json-schema.org/draft/2019-09/schema","http://json-schema.org/draft/2019-09/schema"]),X=new Set(["https://json-schema.org/draft-07/schema","http://json-schema.org/draft-07/schema"]),Q=new Set(["https://json-schema.org/draft-06/schema","http://json-schema.org/draft-06/schema"]);function ee(e){let t=Object.values(e).filter(e=>"number"==typeof e);return Object.entries(e).filter(([e,r])=>-1===t.indexOf(+e)).map(([e,t])=>t)}function et(e,t="|"){return e.map(e=>eR(e)).join(t)}function er(e,t){return"bigint"==typeof t?t.toString():t}class ei{constructor(e){this._getter=e,this._value=void 0}get value(){let e=this._getter;return void 0!==e&&(this._value=e(),this._getter=void 0),this._value}}function en(e){return new ei(e)}function ea(e){let t=+!!e.startsWith("^"),r=e.endsWith("$")?e.length-1:e.length;return e.slice(t,r)}let eo=Symbol("evaluating");function es(e,t,r){Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0})}function el(e){let t=Object.getOwnPropertyDescriptor(e,"shape");return t?.get?t.get.raw:t?.value}function ec(e){return el(e._zod.def)??e._zod.def.shape}function eu(e,t,r){Object.defineProperty(e,t,{get(){let e=r();return es(this,t,e),e},enumerable:!0,configurable:!0})}function ed(e,t,r){t in e?es(e,t,r):e[t]=r}function ep(e,t,r,i){let n=ec(t);for(let a of r){let r=Object.getOwnPropertyDescriptor(n,a);r.enumerable&&(r.get?eu(e,a,()=>{let e=t._zod.def.shape[a];return i?i(e,a):e}):ed(e,a,i?i(r.value,a):r.value))}}function em(...e){let t={};for(let r of e)Object.assign(t,Object.getOwnPropertyDescriptors(r));return Object.defineProperties({},t)}let eh="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function ef(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}let eg=en(()=>{if(eK.jitless||"u">typeof navigator&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{return Function(""),!0}catch(e){return!1}});function ey(e){if(!1===ef(e))return!1;let t=e.constructor;if(void 0===t||"function"!=typeof t)return!0;let r=t.prototype;return!1!==ef(r)&&!1!==Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")}function ev(e){return ey(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}let e_=new Set(["string","number","symbol"]);function eb(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function eS(e,t,r){let i=new e._zod.constr(t??e._zod.def);return(!t||r?.parent)&&(i._zod.parent=e),i}function ew(e){if(!e)return{};if("string"==typeof e)return{error:()=>e};if(e?.message!==void 0){if(e?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");e.error=e.message}return(delete e.message,"string"==typeof e.error)?{...e,error:()=>e.error}:e}function eR(e){return"bigint"==typeof e?e.toString()+"n":"string"==typeof e?`"${e}"`:`${e}`}let ek={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-0x80000000,0x7fffffff],uint32:[0,0xffffffff],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},ex={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function e$(e,t){let r=ec(e),i=[];for(let e of Reflect.ownKeys(t)){if(!Object.getOwnPropertyDescriptor(r,e)?.enumerable)throw Error(`Unrecognized key: "${String(e)}"`);t[e]&&i.push(e)}return i}function eT(e,t){let r={};ep(r,e,Reflect.ownKeys(ec(e)));for(let e of Reflect.ownKeys(t)){let i=Object.getOwnPropertyDescriptor(t,e);i.enumerable&&(i.get?eu(r,e,()=>t[e]):ed(r,e,i.value))}return r}function eC(e,t,r,i="partial"){let n=t._zod.def.checks;if(n&&n.length>0)throw Error(`.${i}() cannot be used on object schemas containing refinements`);let a=r?new Set(e$(t,r)):void 0,o={};return ep(o,t,Reflect.ownKeys(ec(t)),e&&((t,r)=>a&&!a.has(r)?t:new e({type:"optional",innerType:t}))),eS(t,em(t._zod.def,{shape:o,checks:[]}))}function eP(e,t=0){if(!0===e.aborted)return!0;for(let r=t;r<e.issues.length;r++)if(e.issues[r]?.continue!==!0)return!0;return!1}function eO(e,t){return t.map(t=>(t.path??(t.path=[]),t.path.unshift(e),t))}function eE(e){return"string"==typeof e?e:e?.message}function eI(e){let t=[];for(let r of e??[]){let e=r._zod.def;if(!/_(length|size)$|_equals$/.test(e.check))break;let i=e.maximum??e.length??e.size;i>=0&&t.push([i,r])}return t}function eq(e,t,r){var i;for(let n=t;n<e.length;n++)(i=e[n]).schema??(i.schema=r)}function ej(e,t,r){let i=e.inst?._zod?.traits;i?.has("$ZodType")&&(i.has("$ZodCheck")?e.schema??(e.schema=e.inst):e.schema=e.inst);let n=e.schema!==e.inst?e.schema?._zod.def?.error:void 0,a=e.message?e.message:eE(e.inst?._zod.def?.error?.(e))??eE(n?.(e))??eE(t?.error?.(e))??eE(r.customError?.(e))??eE(r.localeError?.(e))??"Invalid input",o={};for(let t of Object.keys(e))"inst"!==t&&"schema"!==t&&"continue"!==t&&"input"!==t&&"__proto__"!==t&&(o[t]=e[t]);return o.path??(o.path=[]),o.message=a,t?.reportInput&&(o.input=e.input),o}let ez=/[\uD800-\uDBFF]/;function eA(e){let t=e.length;if(!ez.test(e))return t;let r=t;for(let i=0;i<t-1;i++)(64512&e.charCodeAt(i))==55296&&(64512&e.charCodeAt(i+1))==56320&&(r--,i++);return r}function eN(e){return Array.isArray(e)?"array":"string"==typeof e?"string":"unknown"}function eM(...e){let[t,r,i]=e;return"string"==typeof t?{message:t,code:"custom",input:r,inst:i}:{...t}}function eL(e,t,r,i=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:i,value:r}),r}function eZ(e,t){for(let r in e){let i=e[r];Object.defineProperty(t,r,{configurable:!0,enumerable:!0,get(){return eL(this,r,i(this))},set(e){eL(this,r,e)}})}return t}let eU=!1,eF={configurable:!0,get(){eU=!0}};function eD(t,r,i){let n=Object.getPrototypeOf(t._zod);if(r in n&&e!==t._zod){e=void 0;return}e=t._zod,Object.defineProperty(n,r,{configurable:!0,get(){Object.defineProperty(this,r,eF);let e=eU;eU=!1;try{let t=i(this);return eU?delete this[r]:Object.defineProperty(this,r,{configurable:!0,writable:!0,value:t}),eU=eU||e,t}catch(t){throw delete this[r],eU=eU||e,t}},set(e){Object.defineProperty(this,r,{configurable:!0,writable:!0,value:e})}})}let eH=Object.freeze({status:"aborted"}),eJ={value:void 0,enumerable:!1},eV="captureStackTrace"in Error?Error:null;function eB(e,t,r,i){function n(e){this.def=e,this.constr=c,this.traits=new Set}n.prototype={};let a=r&&new WeakSet;function o(i,o){if(i._zod){if(i._zod.traits.has(e))return}else{eJ.value=new n(o);try{Object.defineProperty(i,"_zod",eJ)}finally{eJ.value=void 0}}if(i._zod.traits.add(e),t(i,o),a){let e=Object.getPrototypeOf(i),t=i._zod.constr.prototype,n=e;for(;n&&n!==t;)n=Object.getPrototypeOf(n);let o=n??e;if(!a.has(o)){a.add(o);for(let e in r){let t=Object.getOwnPropertyDescriptor(r,e);t.get?Object.defineProperty(o,e,{...t,enumerable:!1}):function(e,t,r){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?r:eL(this,t,r.bind(this))},set(e){eL(this,t,e)}})}(o,e,t.value)}}}let s=c.prototype;for(let e in s)Object.prototype.hasOwnProperty.call(s,e)&&(e in i||(i[e]=s[e].bind(i)))}let s=i?.Parent??Object;class l extends s{}function c(e){let t=i?.Parent?function(e){let t=eV;if(t){let r=t.stackTraceLimit;if("number"==typeof r){try{t.stackTraceLimit=0}catch{return eV=null,new e}try{return new e}finally{t.stackTraceLimit=r}}}return new e}(l):this;o(t,e);let r=t._zod.deferred;if(r){for(let e of r)e();t._zod.deferred=void 0}let n=globalThis.__zod_globalConfig?.postProcessor;return n&&n(t),t}return Object.defineProperty(l,"name",{value:e}),Object.defineProperty(c,"init",{value:o}),Object.defineProperty(c,Symbol.hasInstance,{value:t=>!!i?.Parent&&t instanceof i.Parent||t?._zod?.traits?.has(e)}),Object.defineProperty(c,"name",{value:e}),c}class eW extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class eG extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name="ZodEncodeError"}}(q=globalThis).__zod_globalConfig??(q.__zod_globalConfig={});let eK=globalThis.__zod_globalConfig;function eY(e){return e&&Object.assign(eK,e),eK}class eX extends Error{constructor(){super("Cannot parse a reference cycle that closes through a transform"),this.name="ZodCyclicError"}}let eQ="~memo",e0=[];function e1(e){return null!==e&&"object"==typeof e}function e2(e){return e.map(e=>e.path?{...e,path:e.path.slice()}:{...e})}let e9=new WeakMap,e4=[],e3={alloc(e,r,i){let n=t;if(!n)return i;t=void 0;let a={value:i,issues:null};return n.set(r.value,a),e4.push(a),i},guard(e){var t;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let t=e._zod.parse,r=(e,r)=>{var i,n;let a;if("backward"!==r.direction&&(i=r,n=e.value,void 0!==(a=i[eQ]?.backEdges)&&e1(n)&&a.has(n)))throw new eX;return t(e,r)};e._zod.parse=r,e._zod.run===t&&(e._zod.run=r)})},attach(e){var r;let i,n,a,o=!1;(r=e._zod).deferred??(r.deferred=[]),e._zod.deferred.push(()=>{let r=e._zod.parse,s=(l,c)=>{let u;if(void 0===i){let t=function e(t,r,i){var n,a;let o=e9.get(t);if(void 0!==o)return 2*!!o;if(r.has(t))return 2;r.add(t);let s=0,l=t=>{if(2!==s&&t?._zod){let n=e(t,r,i);n>s&&(s=n)}},c=e=>{e>s&&(s=e)},u=t._zod.def;switch(u.type){case"object":{let t=el(u);c(t?((t,n)=>{let a=0;for(let o of Reflect.ownKeys(t)){let s=Object.getOwnPropertyDescriptor(t,o);if(n&&!s.enumerable)continue;let l=s.get?1:s.value?._zod?e(s.value,r,i):0;l>a&&(a=l)}return a})(t,!0):1),l(u.catchall);break}case"array":l(u.element);break;case"tuple":for(let e of u.items)l(e);l(u.rest);break;case"record":case"map":l(u.keyType),l(u.valueType);break;case"set":l(u.valueType);break;case"union":for(let e of u.options)l(e);break;case"intersection":l(u.left),l(u.right);break;case"optional":case"nullable":case"default":case"prefault":case"catch":case"readonly":case"nonoptional":case"promise":case"success":l(u.innerType);break;case"pipe":l(u.in),l(u.out);break;case"function":l(u.input),l(u.output);break;case"lazy":{let n=u._cachedInner??(i?t._zod.innerType:void 0);c(n?e(n,r,!1):1);break}case"template_literal":case"string":case"number":case"int":case"boolean":case"bigint":case"symbol":case"undefined":case"null":case"void":case"never":case"any":case"unknown":case"date":case"nan":case"enum":case"literal":case"file":case"transform":case"custom":break;default:for(let e in u){let t=Object.getOwnPropertyDescriptor(u,e);if(!t||t.get)continue;let r=t.value;if(r&&"object"==typeof r){if(r._zod)l(r);else if(Array.isArray(r))for(let e of r)l(e)}}}return r.delete(t),n=t,1!==(a=s)&&e9.set(n,2===a),a}(e,new Set,!1);if(0===t)return e._zod.parse=r,e._zod.run===s&&(e._zod.run=r),r(l,c);2===t||o?i=!0:o=!0}let d=l.value;if(!e1(d))return r(l,c);let p=c[eQ];if(p||(p={buckets:new WeakMap,backEdges:void 0},c[eQ]=p),n===c)u=a;else{var m;let t;(t=(m=p).buckets.get(e))||(t=new WeakMap,m.buckets.set(e,t)),u=t,n=c,a=u}let h=u.get(d);if(h)return l.value=h.value,h.issues?h.issues.length&&l.issues.push(...e2(h.issues)):(l.memo=!0,p.backEdges??(p.backEdges=new WeakSet),p.backEdges.add(h.value)),l;t=u;let f=e4.length,g=r(l,c);t=void 0;let y=e4.length>f?e4.pop():void 0;return g instanceof Promise?g.then(e=>(y&&(y.issues=e.issues.length?e2(e.issues):e0),e)):(y&&(y.issues=g.issues.length?e2(g.issues):e0),g)};e._zod.parse=s,e._zod.run===r&&(e._zod.run=s)})}},e6=/^[cC][0-9a-z]{6,}$/,e5=/^[0-9a-z]+$/,e7=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,e8=/^[0-9a-vA-V]{20}$/,te=/^[A-Za-z0-9]{27}$/,tt=/^[a-zA-Z0-9_-]{21}$/,tr=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,ti=/^([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})$/,tn=e=>e?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)$/,ta=/^(?:[A-Za-z0-9_'+\-]+\.)*[A-Za-z0-9_'+\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,to=/^(?:(?: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])$/,ts=/^(([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}|:))$/,tl=/^((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])$/,tc=/^(([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])$/,tu=/^https?$/,td=/^\+[1-9]\d{6,14}$/,tp="(?:(?:\\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])))",tm=RegExp(`^${tp}$`);function th(e){let t="(?:[01]\\d|2[0-3]):[0-5]\\d";return"number"==typeof e.precision?-1===e.precision?`${t}`:0===e.precision?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:e.seconds?`${t}:[0-5]\\d(?:\\.\\d+)?`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}let tf=/^[\s\S]{0,}$/,tg=/^-?\d+$/,ty=/^-?\d+(?:\.\d+)?$/,tv=/^(?:true|false)$/i,t_=/^null$/i,tb=/^[^A-Z]*$/,tS=/^[^a-z]*$/,tw=eB("$ZodCheck",(e,t)=>{var r;e._zod??(e._zod={}),e._zod.def=t,(r=e._zod).onattach??(r.onattach=[])}),tR=e=>{let t=e.value;return null!=t&&void 0!==t.length},tk={number:"number",bigint:"bigint",object:"date"},tx=eB("$ZodCheckLessThan",(e,t)=>{tw.init(e,t);let r=tk[typeof t.value];e._zod.check=i=>{(t.inclusive?i.value<=t.value:i.value<t.value)||i.issues.push({origin:tk[typeof i.value]??r,code:"too_big",maximum:"object"==typeof t.value?t.value.getTime():t.value,input:i.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),t$=eB("$ZodCheckGreaterThan",(e,t)=>{tw.init(e,t);let r=tk[typeof t.value];e._zod.check=i=>{(t.inclusive?i.value>=t.value:i.value>t.value)||i.issues.push({origin:tk[typeof i.value]??r,code:"too_small",minimum:"object"==typeof t.value?t.value.getTime():t.value,input:i.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),tT=eB("$ZodCheckMultipleOf",(e,t)=>{tw.init(e,t),e._zod.check=r=>{let i,n,a;if(typeof r.value!=typeof t.value)throw Error("Cannot mix number and bigint in multiple_of check.");("bigint"==typeof r.value?t.value!==BigInt(0)&&r.value%t.value===BigInt(0):0==(n=Math.round(i=r.value/t.value),a=4*Number.EPSILON*Math.max(Math.abs(i),1),Math.abs(i-n)<a?0:i-n))||r.issues.push({origin:typeof r.value,code:"not_multiple_of",divisor:t.value,input:r.value,inst:e,continue:!t.abort})}}),tC=eB("$ZodCheckNumberFormat",(e,t)=>{tw.init(e,t),t.format=t.format||"float64";let r=t.format?.includes("int"),i=r?"int":"number",[n,a]=ek[t.format];e._zod.check=o=>{let s=o.value;if(r){if(!Number.isInteger(s))return void o.issues.push({expected:i,format:t.format,code:"invalid_type",continue:!1,input:s,inst:e});if(!Number.isSafeInteger(s))return void(s>0?o.issues.push({input:s,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:i,inclusive:!0,continue:!t.abort}):o.issues.push({input:s,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:i,inclusive:!0,continue:!t.abort}))}s<n&&o.issues.push({origin:"number",input:s,code:"too_small",minimum:n,inclusive:!0,inst:e,continue:!t.abort}),s>a&&o.issues.push({origin:"number",input:s,code:"too_big",maximum:a,inclusive:!0,inst:e,continue:!t.abort})}}),tP=eB("$ZodCheckMaxLength",(e,t)=>{var r;tw.init(e,t),(r=e._zod.def).when??(r.when=tR),e._zod.check=r=>{let i=r.value,n=i.length;if(("string"==typeof i&&n>t.maximum?eA(i):n)<=t.maximum)return;let a=eN(i);r.issues.push({origin:a,code:"too_big",maximum:t.maximum,inclusive:!0,input:i,inst:e,continue:!t.abort})}}),tO=eB("$ZodCheckMinLength",(e,t)=>{var r;tw.init(e,t),(r=e._zod.def).when??(r.when=tR),e._zod.check=r=>{let i=r.value,n=i.length;if(("string"==typeof i&&n>=t.minimum&&n<2*t.minimum?eA(i):n)>=t.minimum)return;let a=eN(i);r.issues.push({origin:a,code:"too_small",minimum:t.minimum,inclusive:!0,input:i,inst:e,continue:!t.abort})}}),tE=eB("$ZodCheckLengthEquals",(e,t)=>{var r;tw.init(e,t),(r=e._zod.def).when??(r.when=tR),e._zod.check=r=>{let i=r.value,n=i.length,a="string"==typeof i&&n>=t.length&&n<=2*t.length?eA(i):n;if(a===t.length)return;let o=eN(i),s=a>t.length;r.issues.push({origin:o,...s?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:r.value,inst:e,continue:!t.abort})}}),tI=eB("$ZodCheckStringFormat",(e,t)=>{var r,i;tw.init(e,t),t.pattern?(r=e._zod).check??(r.check=r=>{t.pattern.lastIndex=0,t.pattern.test(r.value)||r.issues.push({origin:"string",code:"invalid_format",format:t.format,input:r.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(i=e._zod).check??(i.check=()=>{})}),tq=eB("$ZodCheckRegex",(e,t)=>{tI.init(e,t),e._zod.check=r=>{t.pattern.lastIndex=0,t.pattern.test(r.value)||r.issues.push({origin:"string",code:"invalid_format",format:"regex",input:r.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),tj=eB("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=tb),tI.init(e,t)}),tz=eB("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=tS),tI.init(e,t)}),tA=eB("$ZodCheckIncludes",(e,t)=>{tw.init(e,t);let r=eb(t.includes),i=new RegExp("number"==typeof t.position?`^.{${t.position},}${r}`:r);t.pattern=i,e._zod.check=r=>{r.value.includes(t.includes,t.position)||r.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:r.value,inst:e,continue:!t.abort})}}),tN=eB("$ZodCheckStartsWith",(e,t)=>{tw.init(e,t);let r=RegExp(`^${eb(t.prefix)}.*`);t.pattern??(t.pattern=r),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})}}),tM=eB("$ZodCheckEndsWith",(e,t)=>{tw.init(e,t);let r=RegExp(`.*${eb(t.suffix)}$`);t.pattern??(t.pattern=r),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})}}),tL=eB("$ZodCheckOverwrite",(e,t)=>{tw.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}});class tZ{constructor(e=[],t={}){this.content=[],this.indent=0,this.args=e,this.closed=t}indented(e){this.indent+=1;try{e(this)}finally{this.indent-=1}}write(e){if("function"==typeof e){e(this,{execution:"sync"}),e(this,{execution:"async"});return}let t=e.split("\n").filter(e=>e),r=Math.min(...t.map(e=>e.length-e.trimStart().length));for(let e of t.map(e=>e.slice(r)).map(e=>" ".repeat(2*this.indent)+e))this.content.push(e)}compile(){let e=Function,t=this?.content??[""];return new e(...Object.keys(this.closed),`return function (${this.args.join(", ")}) {
|
|
2
|
+
${t.join("\n")}
|
|
3
|
+
};`)(...Object.values(this.closed))}}let tU={major:4,minor:6,patch:7},tF=eB("$ZodType",(e,t)=>{var r;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=tU;let i=e._zod.def.checks,n=e._zod.traits.has("$ZodCheck")?[e,...i??[]]:i?.length?[...i]:[];for(let t of n)for(let r of t._zod.onattach)r(e);if(0===n.length)(r=e._zod).deferred??(r.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let t=(t,r,i)=>{let n;if(t.memo)return t;let a=eP(t);for(let o of r){if(o._zod.def.when){if(function(e,t=0){if(!0===e.aborted)return!0;for(let r=t;r<e.issues.length;r++)if(e.issues[r]?.continue===!1)return!0;return!1}(t)||!o._zod.def.when(t))continue}else if(a)continue;let r=t.issues.length,s=o._zod.check(t);if(s instanceof Promise&&i?.async===!1)throw new eW;if(n||s instanceof Promise)n=(n??Promise.resolve()).then(async()=>{await s,t.issues.length!==r&&(eq(t.issues,r,e),a||(a=eP(t,r)))});else{if(t.issues.length===r)continue;eq(t.issues,r,e),a||(a=eP(t,r))}}return n?n.then(()=>t):t},r=(r,i,a)=>{if(eP(r))return r.aborted=!0,r;let o=t(i,n,a);if(o instanceof Promise){if(!1===a.async)throw new eW;return o.then(t=>e._zod.parse(t,a))}return e._zod.parse(o,a)};e._zod.run=(i,a)=>{if(a.skipChecks)return e._zod.parse(i,a);if("backward"===a.direction){let t=e._zod.parse({value:i.value,issues:[]},{...a,skipChecks:!0});return t instanceof Promise?t.then(e=>r(e,i,a)):r(t,i,a)}let o=e._zod.parse(i,a);if(o instanceof Promise){if(!1===a.async)throw new eW;return o.then(e=>t(e,n,a))}return t(o,n,a)}}},{get"~standard"(){return eL(this,"~standard",tH(this),!1)},set"~standard"(e){eL(this,"~standard",e)}}),tD=(e,t)=>e.issues.length?{issues:e.issues.map(e=>ej(e,t,eY()))}:{value:e.value};function tH(e){return{validate:t=>{let r={async:!1};try{let i=e._zod.run({value:t,issues:[]},r);if(!(i instanceof Promise))return tD(i,r)}catch(e){}return async function(e,t){let r={async:!0};return tD(await e._zod.run({value:t,issues:[]},r),r)}(e,t)},vendor:"zod",version:1}}let tJ=eB("$ZodString",(e,t)=>{tF.init(e,t),e._zod.pattern=t.pattern??tf,e._zod.parse=(r,i)=>{if(t.coerce)try{r.value=String(r.value)}catch(e){}return"string"==typeof r.value||r.issues.push({expected:"string",code:"invalid_type",input:r.value,inst:e}),r}}),tV=eB("$ZodStringFormat",(e,t)=>{tI.init(e,t),tJ.init(e,t)}),tB=eB("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=ti),tV.init(e,t)}),tW=eB("$ZodUUID",(e,t)=>{if(t.version){let e={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(void 0===e)throw Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=tn(e))}else t.pattern??(t.pattern=tn());tV.init(e,t)}),tG=eB("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=ta),tV.init(e,t)});function tK(e){try{if("u">typeof URL&&"function"==typeof URL.canParse)return URL.canParse(e);return new URL(e),!0}catch{return!1}}let tY=/[\t\n\r]/g;function tX(e){return e.replace(tY,"")}let tQ=eB("$ZodURL",(e,t)=>{tV.init(e,t),e._zod.check=r=>{try{var i,n;let a=r.value.trim(),o="normalize"in t||"hostname"in t||"protocol"in t?function(e,t){if(!t.normalize&&t.protocol?.source===tu.source&&!/^https?:\/\//i.test(e))return 1;try{if("u">typeof URL){let t=URL;if("function"==typeof t.parse)return t.parse(e)??2}return new URL(e)}catch{return 2}}(a,t):tK(a)||2;if(1===o)return void r.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:r.value,inst:e,continue:!t.abort});if(2===o)return void r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:e,continue:!t.abort});if(!0===o){r.value=tX(a);return}t.hostname&&((i=t.hostname).lastIndex=0,!i.test(o.hostname))&&r.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:r.value,inst:e,continue:!t.abort}),t.protocol&&((n=t.protocol).lastIndex=0,!n.test(o.protocol.endsWith(":")?o.protocol.slice(0,-1):o.protocol))&&r.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:r.value,inst:e,continue:!t.abort}),r.value=t.normalize?o.href:tX(a);return}catch(i){r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:e,continue:!t.abort})}}}),t0=eB("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=RegExp("^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$","u")),tV.init(e,t)}),t1=eB("$ZodNanoID",(e,t)=>{var r;if(void 0!==t.length&&(!Number.isInteger(t.length)||t.length<1))throw Error(`Invalid nanoid length: ${t.length}`);t.pattern??(t.pattern=void 0===t.length?tt:(r=t.length,RegExp(`^[a-zA-Z0-9_-]{${r}}$`))),tV.init(e,t)}),t2=eB("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=e6),tV.init(e,t)}),t9=eB("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=e5),tV.init(e,t)}),t4=eB("$ZodULID",(e,t)=>{t.pattern??(t.pattern=e7),tV.init(e,t)}),t3=eB("$ZodXID",(e,t)=>{t.pattern??(t.pattern=e8),tV.init(e,t)}),t6=eB("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=te),tV.init(e,t)}),t5=eB("$ZodISODateTime",(e,t)=>{let r,i,n;t.pattern??(r=["Z"],t.offset&&r.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)"),i=`${th({precision:t.precision,seconds:!0})}(?:${r.join("|")})`,n=t.local?`${i}|${th({precision:t.precision})}`:i,t.pattern=RegExp(`^${tp}T(?:${n})$`)),tV.init(e,t)}),t7=eB("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=tm),tV.init(e,t)}),t8=eB("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=RegExp(`^${th(t)}$`)),tV.init(e,t)}),re=eB("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=tr),tV.init(e,t)}),rt=eB("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=to),tV.init(e,t)}),rr=/^[0-9a-fA-F:.]+$/;function ri(e){return!!rr.test(e)&&tK(`http://[${e}]`)}let rn=eB("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=ts),tV.init(e,t),e._zod.check=r=>{ri(r.value)||r.issues.push({code:"invalid_format",format:"ipv6",input:r.value,inst:e,continue:!t.abort})}}),ra=eB("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=tl),tV.init(e,t)}),ro=eB("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=tc),tV.init(e,t),e._zod.check=r=>{!function(e){let t=e.split("/");if(2!==t.length)return!1;let[r,i]=t;if(!i)return!1;let n=Number(i);return`${n}`===i&&!(n<0)&&!(n>128)&&ri(r)}(r.value)&&r.issues.push({code:"invalid_format",format:"cidrv6",input:r.value,inst:e,continue:!t.abort})}});function rs(e){if(""===e)return!0;if(/\s/.test(e)||e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}let rl=/^[0-9a-zA-Z+/]*={0,2}$/,rc=eB("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=rl),tV.init(e,t),e._zod.check=r=>{rs(r.value)||r.issues.push({code:"invalid_format",format:"base64",input:r.value,inst:e,continue:!t.abort})}}),ru=/^[A-Za-z0-9_-]*$/,rd=eB("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=ru),tV.init(e,t),e._zod.check=r=>{!function(e){if(!ru.test(e))return!1;let t=e.replace(/[-_]/g,e=>"-"===e?"+":"/");return rs(t.padEnd(4*Math.ceil(t.length/4),"="))}(r.value)&&r.issues.push({code:"invalid_format",format:"base64url",input:r.value,inst:e,continue:!t.abort})}}),rp=eB("$ZodE164",(e,t)=>{t.pattern??(t.pattern=td),tV.init(e,t)}),rm=eB("$ZodJWT",(e,t)=>{tV.init(e,t),e._zod.check=r=>{!function(e,t=null){try{let r=e.split(".");if(3!==r.length)return!1;let[i]=r;if(!i)return!1;let n=JSON.parse(atob(i));if("typ"in n&&n?.typ!=="JWT"||!n.alg||t&&(!("alg"in n)||n.alg!==t))return!1;return!0}catch{return!1}}(r.value,t.alg)&&r.issues.push({code:"invalid_format",format:"jwt",input:r.value,inst:e,continue:!t.abort})}}),rh=eB("$ZodNumber",(e,t)=>{tF.init(e,t),e._zod.pattern=ty,e._zod.parse=(r,i)=>{if(t.coerce)try{r.value=Number(r.value)}catch(e){}let n=r.value;if("number"==typeof n&&!Number.isNaN(n)&&Number.isFinite(n))return r;let a="number"==typeof n?Number.isNaN(n)?"NaN":Number.isFinite(n)?void 0:String(n):void 0;return r.issues.push({expected:"number",code:"invalid_type",input:n,inst:e,...a?{received:a}:{}}),r}}),rf=eB("$ZodNumberFormat",(e,t)=>{tC.init(e,t),rh.init(e,t)}),rg=eB("$ZodBoolean",(e,t)=>{tF.init(e,t),e._zod.pattern=tv,e._zod.parse=(r,i)=>{if(t.coerce)try{r.value=!!r.value}catch(e){}let n=r.value;return"boolean"==typeof n||r.issues.push({expected:"boolean",code:"invalid_type",input:n,inst:e}),r}}),ry=eB("$ZodNull",(e,t)=>{tF.init(e,t),e._zod.pattern=t_,e._zod.values=new Set([null]),e._zod.parse=(t,r)=>{let i=t.value;return null===i||t.issues.push({expected:"null",code:"invalid_type",input:i,inst:e}),t}}),rv=eB("$ZodAny",(e,t)=>{tF.init(e,t),e._zod.parse=e=>e}),r_=eB("$ZodUnknown",(e,t)=>{tF.init(e,t),e._zod.parse=e=>e}),rb=eB("$ZodNever",(e,t)=>{tF.init(e,t),e._zod.parse=(t,r)=>(t.issues.push({expected:"never",code:"invalid_type",input:t.value,inst:e}),t)}),rS=e=>Array.isArray(e)?e.length:-1;function rw(e,t,r){e.issues.length&&t.issues.push(...eO(r,e.issues)),t.value[r]=e.value}let rR=eB("$ZodArray",(e,t)=>{tF.init(e,t);let r=eK.memoizer;r?.attach(e),e._zod.parse=(i,n)=>{let a=i.value;if(!Array.isArray(a))return i.issues.push({expected:"array",code:"invalid_type",input:a,inst:e}),i;i.value=r?r.alloc(e,i,Array(a.length),n):Array(a.length);let o=[],s=n?.abortEarly;for(let e=0;e<a.length;e++){let r=a[e],l=t.element._zod.run({value:r,issues:[]},n);if(l instanceof Promise)o.push(l.then(t=>rw(t,i,e)));else if(rw(l,i,e),s&&0!==l.issues.length&&eP(l))break}return o.length?Promise.all(o).then(()=>i):i},function(e,t){let r=eI(e._zod.def.checks);if(!r.length)return;let i=Math.min(...r.map(e=>e[0])),n=e._zod.parse;e._zod.parse=(r,a)=>{let o=t(r.value);if(o>i&&!a?.skipChecks&&a?.direction!=="backward"){for(let[t,i]of eI(e._zod.def.checks))if(o>t&&i._zod.def.when(r)){let t=r.issues.length;return i._zod.check(r),r.issues[t].continue=!1,eq(r.issues,t,e),r}}return n(r,a)}}(e,rS)});function rk(e,t,r,i,n,a){let o=r in i,s="optional"===a;if(o||!s||"optional"!==n){if(e.issues.length){if(void 0!==n&&s&&!o)return;t.issues.push(...eO(r,e.issues))}if(!o&&void 0===n){e.issues.length||t.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[r]});return}void 0===e.value?(o||"defaulted"===n&&!s)&&(t.value[r]=void 0):t.value[r]=e.value}}let rx=[];function r$(e){var t;let r=Object.keys(e.shape),i=Object.getOwnPropertySymbols(e.shape),n=i.length?i:rx,a=n.length?[...r,...n]:r;for(let t of a)if(!e.shape?.[t]?._zod?.traits?.has("$ZodType"))throw Error(`Invalid element at key "${String(t)}": expected a Zod schema`);let o=Object.keys(t=e.shape).filter(e=>void 0!==t[e]._zod.optin&&"optional"===t[e]._zod.optout);return{...e,allKeys:a,symbolKeys:n,keySet:new Set(r),numKeys:r.length,optionalKeys:new Set(o)}}function rT(e,t,r,i,n,a,o){let s=[],l=n.keySet,c=n.catchall._zod,u=c.def.type,d=c.optin,p=c.optout,m=0;for(let n in t){if(o&&r.issues.length!==m){if(eP(r,m))break;m=r.issues.length}if(l.has(n))continue;if("__proto__"===n){"never"===u&&s.push(n);continue}if("never"===u){s.push(n);continue}let a=c.run({value:t[n],issues:[]},i);a instanceof Promise?e.push(a.then(e=>rk(e,r,n,t,d,p))):rk(a,r,n,t,d,p)}return(s.length&&r.issues.push({code:"unrecognized_keys",keys:s,input:t,inst:a,continue:!0}),e.length)?Promise.all(e).then(()=>r):r}let rC=eB("$ZodObject",(e,t)=>{let r;tF.init(e,t);let i=Object.getOwnPropertyDescriptor(t,"shape"),n=i?.get?i.get.raw:t.shape??{};if(n){let e=()=>{let r={...n};return Object.defineProperty(t,"shape",{value:r}),e.raw=r,r};e.raw=n,Object.defineProperty(t,"shape",{get:e})}let a=en(()=>r$(t));eD(e,"propValues",e=>{let t=e.def.shape,r={};for(let e in t){let i=t[e]._zod;if(i.values){for(let t of(Object.prototype.hasOwnProperty.call(r,e)||es(r,e,new Set),i.values))r[e].add(t);void 0!==i.optin&&r[e].add(void 0)}}return r});let o=t.catchall,s=eK.memoizer;s?.attach(e),e._zod.parse=(t,i)=>{r??(r=a.value);let n=t.value;if(!ef(n))return t.issues.push({expected:"object",code:"invalid_type",input:n,inst:e}),t;t.value=s?s.alloc(e,t,{},i):{};let l=[],c=r.shape,u=i?.abortEarly,d=t.issues.length;for(let e of r.allKeys){if(u&&t.issues.length!==d){if(eP(t,d))break;d=t.issues.length}if("__proto__"===e)continue;let r=c[e],a=r._zod.optin,o=r._zod.optout,s=r._zod.run({value:n[e],issues:[]},i);s instanceof Promise?l.push(s.then(r=>rk(r,t,e,n,a,o))):rk(s,t,e,n,a,o)}return o?rT(l,n,t,i,a.value,e,!0===u):l.length?Promise.all(l).then(()=>t):t}}),rP=eB("$ZodObjectJIT",(e,t)=>{let r,i;rC.init(e,t);let n=e._zod.parse,a=en(()=>r$(t)),o=eK.memoizer,s=!eK.jitless,l=s&&eg.value,c=t.catchall;e._zod.parse=(u,d)=>{i??(i=a.value);let p=u.value;return ef(p)?s&&l&&d?.async===!1&&!0!==d.jitless?(r||(r=(t=>{let r=a.value,i=r.symbolKeys,n=new tZ(["payload","ctx"],{shape:t,inst:e,memo:o,syms:i}),s=e=>`shape[${e}]._zod.run({ value: input[${e}], issues: [] }, ctx)`,l=(e,t)=>`
|
|
4
|
+
let ${e}_ab = false;
|
|
5
|
+
for (let i = 0; i < ${e}.issues.length; i++) {
|
|
6
|
+
const iss = ${e}.issues[i];
|
|
7
|
+
iss.path = iss.path ? [${t}, ...iss.path] : [${t}];
|
|
8
8
|
payload.issues.push(iss);
|
|
9
|
-
if (iss.continue !== true) ${
|
|
9
|
+
if (iss.continue !== true) ${e}_ab = true;
|
|
10
10
|
}
|
|
11
|
-
if (${
|
|
11
|
+
if (${e}_ab && ctx && ctx.abortEarly) {
|
|
12
12
|
payload.value = newResult;
|
|
13
13
|
return payload;
|
|
14
|
-
}`;
|
|
15
|
-
const ${
|
|
16
|
-
if (!${
|
|
17
|
-
if (${
|
|
14
|
+
}`;n.write("const input = payload.value;");let c=Object.create(null),u=0;for(let e of r.allKeys)c[e]=`key_${u++}`;for(let e of(n.write(o?"const newResult = memo.alloc(inst, payload, {}, ctx);":"const newResult = {};"),r.allKeys)){if("__proto__"===e)continue;let r=c[e],a="symbol"==typeof e?`syms[${i.indexOf(e)}]`:JSON.stringify(e),o=`${a} in input`,u=t[e],d=u?._zod?.optin,p=void 0!==d,m=u?._zod?.optout==="optional";if(n.write(`const ${r} = ${s(a)};`),p&&m){let e="optional"===d?`${r}_present`:`${r}.value !== undefined || ${r}_present`;n.write(`
|
|
15
|
+
const ${r}_present = ${o};
|
|
16
|
+
if (!${r}.issues.length || ${r}_present) {
|
|
17
|
+
if (${r}.issues.length) {${l(r,a)}
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
if (${
|
|
21
|
-
newResult[${
|
|
20
|
+
if (${e}) {
|
|
21
|
+
newResult[${a}] = ${r}.value;
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
`)}else
|
|
26
|
-
if (${
|
|
25
|
+
`)}else p?(n.write(`
|
|
26
|
+
if (${r}.issues.length) {${l(r,a)}
|
|
27
27
|
}
|
|
28
|
-
`),"defaulted"===
|
|
29
|
-
if (${
|
|
30
|
-
newResult[${
|
|
28
|
+
`),"defaulted"===d?n.write(`newResult[${a}] = ${r}.value;`):n.write(`
|
|
29
|
+
if (${r}.value !== undefined || ${o}) {
|
|
30
|
+
newResult[${a}] = ${r}.value;
|
|
31
31
|
}
|
|
32
|
-
`)):
|
|
33
|
-
const ${
|
|
34
|
-
if (${
|
|
32
|
+
`)):n.write(`
|
|
33
|
+
const ${r}_present = ${o};
|
|
34
|
+
if (${r}.issues.length) {${l(r,a)}
|
|
35
35
|
}
|
|
36
|
-
if (!${
|
|
36
|
+
if (!${r}_present && !${r}.issues.length) {
|
|
37
37
|
payload.issues.push({
|
|
38
38
|
code: "invalid_type",
|
|
39
39
|
expected: "nonoptional",
|
|
40
40
|
input: undefined,
|
|
41
|
-
path: [${
|
|
41
|
+
path: [${a}]
|
|
42
42
|
});
|
|
43
43
|
if (ctx && ctx.abortEarly) {
|
|
44
44
|
payload.value = newResult;
|
|
@@ -46,41 +46,47 @@ ${r.join("\n")}
|
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
if (${
|
|
50
|
-
newResult[${
|
|
49
|
+
if (${r}_present) {
|
|
50
|
+
newResult[${a}] = ${r}.value;
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
-
`)}return a.write("payload.value = newResult;"),a.write("return payload;"),a.compile()})(r.shape)),d=i(d,p),u)?rT([],m,d,p,n,t,p?.abortEarly===!0):d:a(d,p):(d.issues.push({expected:"object",code:"invalid_type",input:m,inst:t}),d)}});function rP(t,r,i,n){for(let i of t)if(0===i.issues.length)return r.value=i.value,r;let a=t.filter(t=>!eE(t));return 1===a.length?(r.value=a[0].value,a[0]):(r.issues.push({code:"invalid_union",input:r.value,inst:i,errors:t.map(t=>t.issues.map(t=>eq(t,n,eK())))}),r)}let rO=eV("$ZodUnion",(t,r)=>{tF.init(t,r),eF(t,"optin",t=>t.def.options.some(t=>"defaulted"===t._zod.optin)?"defaulted":t.def.options.some(t=>void 0!==t._zod.optin)?"optional":void 0),eF(t,"optout",t=>t.def.options.some(t=>"optional"===t._zod.optout)?"optional":void 0),eF(t,"values",t=>{if(t.def.options.every(t=>t._zod.values))return new Set(t.def.options.flatMap(t=>Array.from(t._zod.values)))}),eF(t,"pattern",t=>{if(t.def.options.every(t=>t._zod.pattern)){let r=t.def.options.map(t=>t._zod.pattern);return RegExp(`^(${r.map(t=>ea(t.source)).join("|")})$`)}});let i=1===r.options.length?r.options[0]._zod.run:null;t._zod.parse=(n,a)=>{if(i)return i(n,a);let o=!1,s=[];for(let t of r.options){let r=t._zod.run({value:n.value,issues:[]},a);if(r instanceof Promise)s.push(r),o=!0;else{if(0===r.issues.length)return r;s.push(r)}}return o?Promise.all(s).then(r=>rP(r,n,t,a)):rP(s,n,t,a)}}),rI=eV("$ZodDiscriminatedUnion",(t,r)=>{r.inclusive=!1,rO.init(t,r);let i=t._zod.parse;eF(t,"propValues",t=>{let r={},i=0;for(let n of t.def.options){let a=n._zod.propValues;if(!a||0===Object.keys(a).length)throw Error(`Invalid discriminated union option at index "${t.def.options.indexOf(n)}"`);for(let[n,o]of(a[t.def.discriminator]?.has(void 0)&&i++,Object.entries(a)))for(let t of(Object.prototype.hasOwnProperty.call(r,n)||es(r,n,new Set),o))r[n].add(t)}return!t.def.unionFallback&&i>1&&r[t.def.discriminator]?.delete(void 0),r}),r.options.forEach((t,i)=>{let n=el(t._zod.def);if(n&&!Object.prototype.hasOwnProperty.call(n,r.discriminator))throw Error(`Invalid discriminated union option at index "${i}"`)});let n=en(()=>(function(t){let r=new Map;for(let i of t.options){let n=i._zod.propValues?.[t.discriminator];if(!n||0===n.size)throw Error(`Invalid discriminated union option at index "${t.options.indexOf(i)}"`);for(let t of n)if(r.has(t)){if(void 0!==t)throw Error(`Duplicate discriminator value "${String(t)}"`);r.set(t,null)}else r.set(t,i)}return r})(r));t._zod.parse=(a,o)=>{let s=a.value;if(!ef(s))return a.issues.push({code:"invalid_type",expected:"object",input:s,inst:t}),a;let l=s?.[r.discriminator],c=n.value.get(l);return c&&(void 0!==l||"backward"!==o.direction)?c._zod.run(a,o):r.unionFallback||"backward"===o.direction?i(a,o):(a.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:r.discriminator,options:Array.from(n.value.keys()).filter(t=>null!==n.value.get(t)),input:s,path:[r.discriminator],inst:t}),a)}}),rq=eV("$ZodIntersection",(t,r)=>{tF.init(t,r),t._zod.parse=(t,i)=>{let n=t.value,a=r.left._zod.run({value:n,issues:[]},i),o=r.right._zod.run({value:n,issues:[]},i);return a instanceof Promise||o instanceof Promise?Promise.all([a,o]).then(([r,i])=>rj(t,r,i)):rj(t,a,o)}});function rj(t,r,i){let n,a=new Map,o=new Map,s=(t,r)=>{let i;if("unrecognized_keys"!==t.code||t.path?.length)if("invalid_key"!==t.code||"record"!==t.origin||t.path?.length!==1)return!1;else{let r=String(t.path[0]);o.has(r)||o.set(r,t),i=[r]}else n??(n=t),i=t.keys;for(let t of i)a.has(t)||a.set(t,{}),a.get(t)[r]=!0;return!0};for(let i of r.issues)s(i,"l")||t.issues.push(i);for(let r of i.issues)s(r,"r")||t.issues.push(r);let l=[...a].filter(([,t])=>t.l&&t.r).map(([t])=>t);if(l.length){let r=n?l.filter(t=>n.keys.includes(t)):[];for(let i of(r.length&&t.issues.push({...n,keys:r}),l))!r.includes(i)&&o.has(i)&&t.issues.push(o.get(i))}let c=function t(r,i){if(r===i||r instanceof Date&&i instanceof Date&&+r==+i)return{valid:!0,data:r};if(ey(r)&&ey(i)){let n=Object.keys(i),a=Object.keys(r).filter(t=>-1!==n.indexOf(t)),o={...r,...i};for(let n of(Object.prototype.hasOwnProperty.call(o,"__proto__")&&delete o.__proto__,a)){if("__proto__"===n)continue;let a=t(r[n],i[n]);if(!a.valid)return{valid:!1,mergeErrorPath:[n,...a.mergeErrorPath]};o[n]=a.data}return{valid:!0,data:o}}if(Array.isArray(r)&&Array.isArray(i)){if(r.length!==i.length)return{valid:!1,mergeErrorPath:[]};let n=[];for(let a=0;a<r.length;a++){let o=t(r[a],i[a]);if(!o.valid)return{valid:!1,mergeErrorPath:[a,...o.mergeErrorPath]};n.push(o.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}(r.value,i.value);if(!c.valid){if(eE(t))return t;throw Error(`Unmergable intersection. Error path: ${JSON.stringify(c.mergeErrorPath)}`)}return t.value=c.data,t}let rA=eV("$ZodRecord",(t,r)=>{tF.init(t,r);let i=eG.memoizer;i?.attach(t),t._zod.parse=(n,a)=>{let o=n.value;if(!ey(o))return n.issues.push({expected:"record",code:"invalid_type",input:o,inst:t}),n;let s=[],l=r.keyType._zod.values;if(l&&!r.partial){let c;n.value=i?i.alloc(t,n,{},a):{};let u=new Set;for(let i of l)if("string"==typeof i||"number"==typeof i||"symbol"==typeof i){if(u.add("number"==typeof i?i.toString():i),"__proto__"===i)continue;let l=r.keyType._zod.run({value:i,issues:[]},a);if(l instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(l.issues.length){n.issues.push({code:"invalid_key",origin:"record",issues:l.issues.map(t=>eq(t,a,eK())),input:i,path:[i],inst:t});continue}let c=l.value;if("__proto__"===c)continue;let d=r.valueType._zod.run({value:o[i],issues:[]},a);d instanceof Promise?s.push(d.then(t=>{t.issues.length&&n.issues.push(...eP(i,t.issues)),n.value[c]=t.value})):(d.issues.length&&n.issues.push(...eP(i,d.issues)),n.value[c]=d.value)}for(let t in o)if(!u.has(t))if("loose"===r.mode){if("__proto__"===t)continue;n.value[t]=o[t]}else(c=c??[]).push(t);c&&c.length>0&&n.issues.push({code:"unrecognized_keys",input:o,inst:t,keys:c,continue:!0})}else{let c;for(let u of(n.value=i?i.alloc(t,n,{},a):{},Reflect.ownKeys(o))){if("__proto__"===u||!Object.prototype.propertyIsEnumerable.call(o,u))continue;let i=r.keyType._zod.run({value:u,issues:[]},a);if(i instanceof Promise)throw Error("Async schemas not supported in object keys currently");if("string"==typeof u&&ty.test(u)&&i.issues.length){let t=r.keyType._zod.run({value:Number(u),issues:[]},a);if(t instanceof Promise)throw Error("Async schemas not supported in object keys currently");0===t.issues.length&&(i=t)}if(i.issues.length){"loose"===r.mode?n.value[u]=o[u]:l?(c=c??[]).push(u):n.issues.push({code:"invalid_key",origin:"record",issues:i.issues.map(t=>eq(t,a,eK())),input:u,path:[u],inst:t});continue}let d=i.value;if("__proto__"===d)continue;let p=r.valueType._zod.run({value:o[u],issues:[]},a);p instanceof Promise?s.push(p.then(t=>{t.issues.length&&n.issues.push(...eP(u,t.issues)),n.value[d]=t.value})):(p.issues.length&&n.issues.push(...eP(u,p.issues)),n.value[d]=p.value)}c&&c.length>0&&n.issues.push({code:"unrecognized_keys",input:o,inst:t,keys:c,continue:!0})}return s.length?Promise.all(s).then(()=>n):n}}),rz=eV("$ZodEnum",(t,r)=>{tF.init(t,r);let i=ee(r.entries),n=new Set(i);t._zod.values=n,eF(t,"pattern",t=>{let r=ee(t.def.entries).filter(t=>e_.has(typeof t));return new RegExp(r.length?`^(${r.map(t=>eb(t.toString())).join("|")})$`:"^[^\\s\\S]$")}),t._zod.parse=(r,a)=>{let o=r.value;return n.has(o)||r.issues.push({code:"invalid_value",values:i,input:o,inst:t}),r}}),rN=eV("$ZodLiteral",(t,r)=>{tF.init(t,r);let i=new Set(r.values);t._zod.values=i,eF(t,"pattern",t=>{let r=t.def.values;return new RegExp(r.length?`^(${r.map(t=>"string"==typeof t?eb(t):t?eb(t.toString()):String(t)).join("|")})$`:"^[^\\s\\S]$")}),t._zod.parse=(n,a)=>{let o=n.value;return i.has(o)||n.issues.push({code:"invalid_value",values:r.values,input:o,inst:t}),n}}),rM=eV("$ZodTransform",(t,r)=>{tF.init(t,r),t._zod.optin="optional",eG.memoizer?.guard(t),t._zod.parse=(i,n)=>{if("backward"===n.direction)throw new eW(t.constructor.name);let a=r.transform(i.value,i);if(n.async)return(a instanceof Promise?a:Promise.resolve(a)).then(t=>(i.value=t,i));if(a instanceof Promise)throw new eB;return i.value=a,i}});function rL(t,r){return t.value=r.issues.length?void 0:r.value,t}let rZ=eV("$ZodOptional",(t,r)=>{tF.init(t,r),eF(t,"optin",t=>"defaulted"===t.def.innerType._zod.optin?"defaulted":"optional"),t._zod.optout="optional",eF(t,"values",t=>{let r=t.def.innerType._zod.values;return r?new Set([...r,void 0]):void 0}),eF(t,"pattern",t=>{let r=t.def.innerType._zod.pattern;return r?RegExp(`^(${ea(r.source)})?$`):void 0}),t._zod.parse=(t,i)=>{if(void 0===t.value){if("defaulted"!==r.innerType._zod.optin)return t;let n=r.innerType._zod.run({value:t.value,issues:[]},i);return n instanceof Promise?n.then(r=>rL(t,r)):rL(t,n)}return r.innerType._zod.run(t,i)}}),rU=eV("$ZodExactOptional",(t,r)=>{rZ.init(t,r),eF(t,"values",t=>t.def.innerType._zod.values),eF(t,"pattern",t=>t.def.innerType._zod.pattern),t._zod.parse=(t,i)=>r.innerType._zod.run(t,i)}),rF=eV("$ZodNullable",(t,r)=>{tF.init(t,r),eF(t,"optin",t=>t.def.innerType._zod.optin),eF(t,"optout",t=>t.def.innerType._zod.optout),eF(t,"pattern",t=>{let r=t.def.innerType._zod.pattern;return r?RegExp(`^(${ea(r.source)}|null)$`):void 0}),eF(t,"values",t=>t.def.innerType._zod.values?new Set([...t.def.innerType._zod.values,null]):void 0),t._zod.parse=(t,i)=>null===t.value?t:r.innerType._zod.run(t,i)}),rD=eV("$ZodDefault",(t,r)=>{tF.init(t,r),t._zod.optin="defaulted",eF(t,"values",t=>t.def.innerType._zod.values),t._zod.parse=(t,i)=>{if("backward"===i.direction)return r.innerType._zod.run(t,i);if(void 0===t.value)return t.value=r.defaultValue,t;let n=r.innerType._zod.run(t,i);return n instanceof Promise?n.then(t=>rH(t,r)):rH(n,r)}});function rH(t,r){return void 0===t.value&&(t.value=r.defaultValue),t}let rJ=eV("$ZodPrefault",(t,r)=>{tF.init(t,r),t._zod.optin="defaulted",eF(t,"values",t=>t.def.innerType._zod.values),t._zod.parse=(t,i)=>("backward"===i.direction||void 0===t.value&&(t.value=r.defaultValue),r.innerType._zod.run(t,i))}),rV=eV("$ZodNonOptional",(t,r)=>{tF.init(t,r),eF(t,"values",t=>{let r=t.def.innerType._zod.values;return r?new Set([...r].filter(t=>void 0!==t)):void 0}),t._zod.parse=(i,n)=>{let a=r.innerType._zod.run(i,n);return a instanceof Promise?a.then(r=>rB(r,t)):rB(a,t)}});function rB(t,r){return t.issues.length||void 0!==t.value||t.issues.push({code:"invalid_type",expected:"nonoptional",input:t.value,inst:r}),t}function rW(t,r,i,n){return r.issues.length?t.value=i.catchValue({...r,value:t.value,error:{issues:r.issues.map(t=>eq(t,n,eK()))},input:t.value}):(t.value=r.value,r.memo&&(t.memo=!0)),t}let rG=eV("$ZodCatch",(t,r)=>{tF.init(t,r),eF(t,"optin",t=>"defaulted"===t.def.innerType._zod.optin?"defaulted":"optional"),eF(t,"optout",t=>t.def.innerType._zod.optout),eF(t,"values",t=>t.def.innerType._zod.values),t._zod.parse=(t,i)=>{if("backward"===i.direction)return r.innerType._zod.run(t,i);let n=r.innerType._zod.run({value:t.value,issues:[]},i);return n instanceof Promise?n.then(n=>rW(t,n,r,i)):rW(t,n,r,i)}}),rK=eV("$ZodPipe",(t,r)=>{tF.init(t,r),eF(t,"values",t=>t.def.in._zod.values),eF(t,"optin",t=>t.def.in._zod.optin),eF(t,"optout",t=>t.def.out._zod.optout),eF(t,"propValues",t=>t.def.in._zod.propValues),t._zod.parse=(t,i)=>{if("backward"===i.direction){let n=r.out._zod.run(t,i);return n instanceof Promise?n.then(t=>rY(t,r.in,i)):rY(n,r.in,i)}let n=r.in._zod.run(t,i);return n instanceof Promise?n.then(t=>rY(t,r.out,i)):rY(n,r.out,i)}});function rY(t,r,i){return t.issues.some(t=>"unrecognized_keys"!==t.code)?(t.aborted=!0,t):r._zod.run({value:t.value,issues:t.issues},i)}let rX=eV("$ZodPreprocess",(t,r)=>{rK.init(t,r)}),rQ=eV("$ZodReadonly",(t,r)=>{tF.init(t,r),eF(t,"propValues",t=>t.def.innerType._zod.propValues),eF(t,"values",t=>t.def.innerType._zod.values),eF(t,"optin",t=>t.def.innerType?._zod?.optin),eF(t,"optout",t=>t.def.innerType?._zod?.optout),t._zod.parse=(t,i)=>{if("backward"===i.direction)return r.innerType._zod.run(t,i);let n=r.innerType._zod.run(t,i);return n instanceof Promise?n.then(r0):r0(n)}});function r0(t){return t.memo||(t.value=Object.freeze(t.value)),t}let r1=eV("$ZodLazy",(t,r)=>{var i;let n;tF.init(t,r),i=t._zod,Object.defineProperty(i,"innerType",{get(){if(n!==eo)return void 0===n&&(n=eo,n=(()=>(r._cachedInner||(r._cachedInner=r.getter()),r._cachedInner))()),n},set(t){Object.defineProperty(i,"innerType",{value:t})},configurable:!0}),eF(t,"pattern",t=>t.innerType?._zod?.pattern),eF(t,"propValues",t=>t.innerType?._zod?.propValues),eF(t,"optin",t=>t.innerType?._zod?.optin??void 0),eF(t,"optout",t=>t.innerType?._zod?.optout??void 0),t._zod.parse=(r,i)=>t._zod.innerType._zod.run(r,i)}),r2=eV("$ZodCustom",(t,r)=>{tw.init(t,r),tF.init(t,r),t._zod.parse=(t,r)=>t,t._zod.check=i=>{let n=i.value,a=r.fn(n);if(a instanceof Promise)return a.then(r=>r9(r,i,n,t));r9(a,i,n,t)}});function r9(t,r,i,n){if(!t){let t={code:"custom",input:i,inst:n,path:[...n._zod.def.path??[]],continue:!n._zod.def.abort};n._zod.def.params&&(t.params=n._zod.def.params),r.issues.push(eN(t))}}(j=globalThis).__zod_globalRegistry??(j.__zod_globalRegistry=new class t{constructor(){this._map=new WeakMap,this._idmap=new Map}add(t,...r){let i=r[0];return this._map.set(t,i),i&&"object"==typeof i&&"id"in i&&this._idmap.set(i.id,t),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(t){let r=this._map.get(t);return r&&"object"==typeof r&&"id"in r&&this._idmap.delete(r.id),this._map.delete(t),this}get(t){let r=t._zod.parent;if(r){let i={...this.get(r)??{}};delete i.id;let n={...i,...this._map.get(t)};return Object.keys(n).length?n:void 0}return this._map.get(t)}has(t){return this._map.has(t)}});let r4=globalThis.__zod_globalRegistry;function r3(t){return t.checks&&(t.checks=[...t.checks]),t}function r6(t,r){return new t({type:"string",format:"email",check:"string_format",abort:!1,...ew(r)})}function r5(t,r){return new t({type:"string",format:"url",check:"string_format",abort:!1,...ew(r)})}function r7(t,r){return new t({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...ew(r)})}function r8(t,r){return new t({type:"string",format:"date",check:"string_format",...ew(r)})}function ie(t,r){return new tx({check:"less_than",...ew(r),value:t,inclusive:!1})}function it(t,r){return new tx({check:"less_than",...ew(r),value:t,inclusive:!0})}function ir(t,r){return new t$({check:"greater_than",...ew(r),value:t,inclusive:!1})}function ii(t,r){return new t$({check:"greater_than",...ew(r),value:t,inclusive:!0})}function ia(t,r){return new tT({check:"multiple_of",...ew(r),value:t})}function io(t,r){return new tE({check:"max_length",...ew(r),maximum:t})}function is(t,r){return new tP({check:"min_length",...ew(r),minimum:t})}function il(t,r){return new tO({check:"length_equals",...ew(r),length:t})}function ic(t){return new tL({check:"overwrite",tx:t})}function iu(t,...r){for(let i of r)for(let r of Reflect.ownKeys(i))Object.prototype.propertyIsEnumerable.call(i,r)&&es(t,r,i[r]);return t}function id(t){let r=t?.target??"draft-2020-12";return"draft-4"===r&&(r="draft-04"),"draft-7"===r&&(r="draft-07"),{processors:t.processors??{},metadataRegistry:t?.metadata??r4,target:r,unrepresentable:t?.unrepresentable??"throw",override:t?.override??(()=>{}),io:t?.io??"output",counter:0,seen:new Map,sharedDefsExtractedFor:void 0,sharedEmitDoneFor:void 0,cycles:t?.cycles??"ref",reused:t?.reused??"inline",intersections:[],deferred:[],external:t?.external??void 0}}function ip(t,r,i,n,a){let o="function"==typeof r.unrepresentable?r.unrepresentable({zodSchema:t,path:n.path,message:a}):r.unrepresentable;if("any"===o)return!1;if(void 0===o||"throw"===o)throw Error(a);return Object.assign(i,o),!0}function im(t,r,i={path:[],schemaPath:[]}){var n;let a=t._zod.def,o=r.seen.get(t);if(o)return o.count++,i.schemaPath.includes(t)&&(o.cycle=i.path),o.schema;let s={schema:{},count:1,cycle:void 0,path:i.path};r.seen.set(t,s),r.sharedDefsExtractedFor=void 0,r.sharedEmitDoneFor=void 0;let l=t._zod.toJSONSchema?.();if(l)s.schema=l;else{let n={...i,schemaPath:[...i.schemaPath,t],path:i.path};if(t._zod.processJSONSchema)t._zod.processJSONSchema(r,s.schema,n);else{let i=s.schema,o=r.processors[a.type];if(!o)throw Error(`[toJSONSchema]: Non-representable type encountered: ${a.type}`);o(t,r,i,n)}let o=t._zod.parent;o&&(s.ref||(s.ref=o),im(o,r,n),r.seen.get(o).isParent=!0)}let c=r.metadataRegistry.get(t);return c&&iu(s.schema,c),"input"===r.io&&function t(r,i){let n=i??{seen:new Set};if(n.seen.has(r))return!1;n.seen.add(r);let a=r._zod.def;if("transform"===a.type)return!0;if("array"===a.type)return t(a.element,n);if("set"===a.type)return t(a.valueType,n);if("lazy"===a.type)return t(a.getter(),n);if("promise"===a.type||"optional"===a.type||"nonoptional"===a.type||"nullable"===a.type||"readonly"===a.type||"default"===a.type||"prefault"===a.type||"catch"===a.type)return t(a.innerType,n);if("intersection"===a.type)return t(a.left,n)||t(a.right,n);if("record"===a.type||"map"===a.type)return t(a.keyType,n)||t(a.valueType,n);if("pipe"===a.type)return!!r._zod.traits.has("$ZodCodec")||t(a.in,n)||t(a.out,n);if("object"===a.type){for(let r in a.shape)if(t(a.shape[r],n))return!0;return!1}if("union"===a.type){for(let r of a.options)if(t(r,n))return!0;return!1}if("tuple"===a.type){for(let r of a.items)if(t(r,n))return!0;if(a.rest&&t(a.rest,n))return!0}return!1}(t)&&(delete s.schema.examples,delete s.schema.default),"input"===r.io&&"_prefault"in s.schema&&((n=s.schema).default??(n.default=s.schema._prefault)),delete s.schema._prefault,r.seen.get(t).schema}function ih(t){return t.replace(/~/g,"~0").replace(/\//g,"~1")}function ig(t,r){let i=t.seen.get(r);if(!i)throw Error("Unprocessed schema. This is a bug in Zod.");if(t.external&&t.sharedDefsExtractedFor===t.external)return;let n=new Map;for(let r of t.seen.entries()){let i=t.metadataRegistry.get(r[0])?.id;if(i){let t=n.get(i);if(t&&t!==r[0])throw Error(`Duplicate schema id "${i}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);n.set(i,r[0])}}let a=r=>{if(r[1].schema.$ref)return;let n=r[1],{ref:a,defId:o}=(r=>{let n="draft-2020-12"===t.target?"$defs":"definitions";if(t.external){let i=t.external.registry.get(r[0])?.id,a=t.external.uri??(t=>t);if(i)return{ref:a(i)};let o=r[1].defId??r[1].schema.id??`schema${t.counter++}`;return r[1].defId=o,{defId:o,ref:`${a("__shared")}#/${n}/${ih(o)}`}}let a=`#/${n}/`;if(r[1]===i&&!r[1].schema.id)return{ref:"#"};let o=r[1].schema.id??`__schema${t.counter++}`;return{defId:o,ref:a+ih(o)}})(r);n.def={...n.schema},o&&(n.defId=o);let s=n.schema;for(let t in s)delete s[t];s.$ref=a};if("throw"===t.cycles)for(let r of t.seen.entries()){let t=r[1];if(t.cycle)throw Error(`Cycle detected: #/${t.cycle?.join("/")}/<root>
|
|
53
|
+
`)}return n.write("payload.value = newResult;"),n.write("return payload;"),n.compile()})(t.shape)),u=r(u,d),c)?rT([],p,u,d,i,e,d?.abortEarly===!0):u:n(u,d):(u.issues.push({expected:"object",code:"invalid_type",input:p,inst:e}),u)}});function rO(e,t,r,i){for(let r of e)if(0===r.issues.length)return t.value=r.value,t;let n=e.filter(e=>!eP(e));return 1===n.length?(t.value=n[0].value,n[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:r,errors:e.map(e=>e.issues.map(e=>ej(e,i,eY())))}),t)}let rE=eB("$ZodUnion",(e,t)=>{tF.init(e,t),eD(e,"optin",e=>e.def.options.some(e=>"defaulted"===e._zod.optin)?"defaulted":e.def.options.some(e=>void 0!==e._zod.optin)?"optional":void 0),eD(e,"optout",e=>e.def.options.some(e=>"optional"===e._zod.optout)?"optional":void 0),eD(e,"values",e=>{if(e.def.options.every(e=>e._zod.values))return new Set(e.def.options.flatMap(e=>Array.from(e._zod.values)))}),eD(e,"pattern",e=>{if(e.def.options.every(e=>e._zod.pattern)){let t=e.def.options.map(e=>e._zod.pattern);return RegExp(`^(${t.map(e=>ea(e.source)).join("|")})$`)}});let r=1===t.options.length?t.options[0]._zod.run:null;e._zod.parse=(i,n)=>{if(r)return r(i,n);let a=!1,o=[];for(let e of t.options){let t=e._zod.run({value:i.value,issues:[]},n);if(t instanceof Promise)o.push(t),a=!0;else{if(0===t.issues.length)return t;o.push(t)}}return a?Promise.all(o).then(t=>rO(t,i,e,n)):rO(o,i,e,n)}}),rI=eB("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,rE.init(e,t);let r=e._zod.parse;eD(e,"propValues",e=>{let t={},r=0;for(let i of e.def.options){let n=i._zod.propValues;if(!n||0===Object.keys(n).length)throw Error(`Invalid discriminated union option at index "${e.def.options.indexOf(i)}"`);for(let[i,a]of(n[e.def.discriminator]?.has(void 0)&&r++,Object.entries(n)))for(let e of(Object.prototype.hasOwnProperty.call(t,i)||es(t,i,new Set),a))t[i].add(e)}return!e.def.unionFallback&&r>1&&t[e.def.discriminator]?.delete(void 0),t}),t.options.forEach((e,r)=>{let i=el(e._zod.def);if(i&&!Object.prototype.hasOwnProperty.call(i,t.discriminator))throw Error(`Invalid discriminated union option at index "${r}"`)});let i=en(()=>(function(e){let t=new Map;for(let r of e.options){let i=r._zod.propValues?.[e.discriminator];if(!i||0===i.size)throw Error(`Invalid discriminated union option at index "${e.options.indexOf(r)}"`);for(let e of i)if(t.has(e)){if(void 0!==e)throw Error(`Duplicate discriminator value "${String(e)}"`);t.set(e,null)}else t.set(e,r)}return t})(t));e._zod.parse=(n,a)=>{let o=n.value;if(!ef(o))return n.issues.push({code:"invalid_type",expected:"object",input:o,inst:e}),n;let s=o?.[t.discriminator],l=i.value.get(s);return l&&(void 0!==s||"backward"!==a.direction)?l._zod.run(n,a):t.unionFallback||"backward"===a.direction?r(n,a):(n.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,options:Array.from(i.value.keys()).filter(e=>null!==i.value.get(e)),input:o,path:[t.discriminator],inst:e}),n)}}),rq=eB("$ZodIntersection",(e,t)=>{tF.init(e,t),e._zod.parse=(e,r)=>{let i=e.value,n=t.left._zod.run({value:i,issues:[]},r),a=t.right._zod.run({value:i,issues:[]},r);return n instanceof Promise||a instanceof Promise?Promise.all([n,a]).then(([t,r])=>rj(e,t,r)):rj(e,n,a)}});function rj(e,t,r){let i,n=new Map,a=new Map,o=(e,t)=>{let r;if("unrecognized_keys"!==e.code||e.path?.length)if("invalid_key"!==e.code||"record"!==e.origin||e.path?.length!==1)return!1;else{let t=String(e.path[0]);a.has(t)||a.set(t,e),r=[t]}else i??(i=e),r=e.keys;for(let e of r)n.has(e)||n.set(e,{}),n.get(e)[t]=!0;return!0};for(let r of t.issues)o(r,"l")||e.issues.push(r);for(let t of r.issues)o(t,"r")||e.issues.push(t);let s=[...n].filter(([,e])=>e.l&&e.r).map(([e])=>e);if(s.length){let t=i?s.filter(e=>i.keys.includes(e)):[];for(let r of(t.length&&e.issues.push({...i,keys:t}),s))!t.includes(r)&&a.has(r)&&e.issues.push(a.get(r))}let l=function e(t,r){if(t===r||t instanceof Date&&r instanceof Date&&+t==+r)return{valid:!0,data:t};if(ey(t)&&ey(r)){let i=Object.keys(r),n=Object.keys(t).filter(e=>-1!==i.indexOf(e)),a={...t,...r};for(let i of(Object.prototype.hasOwnProperty.call(a,"__proto__")&&delete a.__proto__,n)){if("__proto__"===i)continue;let n=e(t[i],r[i]);if(!n.valid)return{valid:!1,mergeErrorPath:[i,...n.mergeErrorPath]};a[i]=n.data}return{valid:!0,data:a}}if(Array.isArray(t)&&Array.isArray(r)){if(t.length!==r.length)return{valid:!1,mergeErrorPath:[]};let i=[];for(let n=0;n<t.length;n++){let a=e(t[n],r[n]);if(!a.valid)return{valid:!1,mergeErrorPath:[n,...a.mergeErrorPath]};i.push(a.data)}return{valid:!0,data:i}}return{valid:!1,mergeErrorPath:[]}}(t.value,r.value);if(!l.valid){if(eP(e))return e;throw Error(`Unmergable intersection. Error path: ${JSON.stringify(l.mergeErrorPath)}`)}return e.value=l.data,e}let rz=eB("$ZodRecord",(e,t)=>{tF.init(e,t);let r=eK.memoizer;r?.attach(e),e._zod.parse=(i,n)=>{let a=i.value;if(!ey(a))return i.issues.push({expected:"record",code:"invalid_type",input:a,inst:e}),i;let o=[],s=t.keyType._zod.values;if(s&&!t.partial){let l;i.value=r?r.alloc(e,i,{},n):{};let c=new Set;for(let r of s)if("string"==typeof r||"number"==typeof r||"symbol"==typeof r){if(c.add("number"==typeof r?r.toString():r),"__proto__"===r)continue;let s=t.keyType._zod.run({value:r,issues:[]},n);if(s instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(s.issues.length){i.issues.push({code:"invalid_key",origin:"record",issues:s.issues.map(e=>ej(e,n,eY())),input:r,path:[r],inst:e});continue}let l=s.value;if("__proto__"===l)continue;let u=t.valueType._zod.run({value:a[r],issues:[]},n);u instanceof Promise?o.push(u.then(e=>{e.issues.length&&i.issues.push(...eO(r,e.issues)),i.value[l]=e.value})):(u.issues.length&&i.issues.push(...eO(r,u.issues)),i.value[l]=u.value)}for(let e in a)if(!c.has(e))if("loose"===t.mode){if("__proto__"===e)continue;i.value[e]=a[e]}else(l=l??[]).push(e);l&&l.length>0&&i.issues.push({code:"unrecognized_keys",input:a,inst:e,keys:l,continue:!0})}else{let l;for(let c of(i.value=r?r.alloc(e,i,{},n):{},Reflect.ownKeys(a))){if("__proto__"===c||!Object.prototype.propertyIsEnumerable.call(a,c))continue;let r=t.keyType._zod.run({value:c,issues:[]},n);if(r instanceof Promise)throw Error("Async schemas not supported in object keys currently");if("string"==typeof c&&ty.test(c)&&r.issues.length){let e=t.keyType._zod.run({value:Number(c),issues:[]},n);if(e instanceof Promise)throw Error("Async schemas not supported in object keys currently");0===e.issues.length&&(r=e)}if(r.issues.length){"loose"===t.mode?i.value[c]=a[c]:s?(l=l??[]).push(c):i.issues.push({code:"invalid_key",origin:"record",issues:r.issues.map(e=>ej(e,n,eY())),input:c,path:[c],inst:e});continue}let u=r.value;if("__proto__"===u)continue;let d=t.valueType._zod.run({value:a[c],issues:[]},n);d instanceof Promise?o.push(d.then(e=>{e.issues.length&&i.issues.push(...eO(c,e.issues)),i.value[u]=e.value})):(d.issues.length&&i.issues.push(...eO(c,d.issues)),i.value[u]=d.value)}l&&l.length>0&&i.issues.push({code:"unrecognized_keys",input:a,inst:e,keys:l,continue:!0})}return o.length?Promise.all(o).then(()=>i):i}}),rA=eB("$ZodEnum",(e,t)=>{tF.init(e,t);let r=ee(t.entries),i=new Set(r);e._zod.values=i,eD(e,"pattern",e=>{let t=ee(e.def.entries).filter(e=>e_.has(typeof e));return new RegExp(t.length?`^(${t.map(e=>eb(e.toString())).join("|")})$`:"^[^\\s\\S]$")}),e._zod.parse=(t,n)=>{let a=t.value;return i.has(a)||t.issues.push({code:"invalid_value",values:r,input:a,inst:e}),t}}),rN=eB("$ZodLiteral",(e,t)=>{tF.init(e,t);let r=new Set(t.values);e._zod.values=r,eD(e,"pattern",e=>{let t=e.def.values;return new RegExp(t.length?`^(${t.map(e=>"string"==typeof e?eb(e):e?eb(e.toString()):String(e)).join("|")})$`:"^[^\\s\\S]$")}),e._zod.parse=(i,n)=>{let a=i.value;return r.has(a)||i.issues.push({code:"invalid_value",values:t.values,input:a,inst:e}),i}}),rM=eB("$ZodTransform",(e,t)=>{tF.init(e,t),e._zod.optin="optional",eK.memoizer?.guard(e),e._zod.parse=(r,i)=>{if("backward"===i.direction)throw new eG(e.constructor.name);let n=t.transform(r.value,r);if(i.async)return(n instanceof Promise?n:Promise.resolve(n)).then(e=>(r.value=e,r));if(n instanceof Promise)throw new eW;return r.value=n,r}});function rL(e,t){return e.value=t.issues.length?void 0:t.value,e}let rZ=eB("$ZodOptional",(e,t)=>{tF.init(e,t),eD(e,"optin",e=>"defaulted"===e.def.innerType._zod.optin?"defaulted":"optional"),e._zod.optout="optional",eD(e,"values",e=>{let t=e.def.innerType._zod.values;return t?new Set([...t,void 0]):void 0}),eD(e,"pattern",e=>{let t=e.def.innerType._zod.pattern;return t?RegExp(`^(${ea(t.source)})?$`):void 0}),e._zod.parse=(e,r)=>{if(void 0===e.value){if("defaulted"!==t.innerType._zod.optin)return e;let i=t.innerType._zod.run({value:e.value,issues:[]},r);return i instanceof Promise?i.then(t=>rL(e,t)):rL(e,i)}return t.innerType._zod.run(e,r)}}),rU=eB("$ZodExactOptional",(e,t)=>{rZ.init(e,t),eD(e,"values",e=>e.def.innerType._zod.values),eD(e,"pattern",e=>e.def.innerType._zod.pattern),e._zod.parse=(e,r)=>t.innerType._zod.run(e,r)}),rF=eB("$ZodNullable",(e,t)=>{tF.init(e,t),eD(e,"optin",e=>e.def.innerType._zod.optin),eD(e,"optout",e=>e.def.innerType._zod.optout),eD(e,"pattern",e=>{let t=e.def.innerType._zod.pattern;return t?RegExp(`^(${ea(t.source)}|null)$`):void 0}),eD(e,"values",e=>e.def.innerType._zod.values?new Set([...e.def.innerType._zod.values,null]):void 0),e._zod.parse=(e,r)=>null===e.value?e:t.innerType._zod.run(e,r)}),rD=eB("$ZodDefault",(e,t)=>{tF.init(e,t),e._zod.optin="defaulted",eD(e,"values",e=>e.def.innerType._zod.values),e._zod.parse=(e,r)=>{if("backward"===r.direction)return t.innerType._zod.run(e,r);if(void 0===e.value)return e.value=t.defaultValue,e;let i=t.innerType._zod.run(e,r);return i instanceof Promise?i.then(e=>rH(e,t)):rH(i,t)}});function rH(e,t){return void 0===e.value&&(e.value=t.defaultValue),e}let rJ=eB("$ZodPrefault",(e,t)=>{tF.init(e,t),e._zod.optin="defaulted",eD(e,"values",e=>e.def.innerType._zod.values),e._zod.parse=(e,r)=>("backward"===r.direction||void 0===e.value&&(e.value=t.defaultValue),t.innerType._zod.run(e,r))}),rV=eB("$ZodNonOptional",(e,t)=>{tF.init(e,t),eD(e,"values",e=>{let t=e.def.innerType._zod.values;return t?new Set([...t].filter(e=>void 0!==e)):void 0}),e._zod.parse=(r,i)=>{let n=t.innerType._zod.run(r,i);return n instanceof Promise?n.then(t=>rB(t,e)):rB(n,e)}});function rB(e,t){return e.issues.length||void 0!==e.value||e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}function rW(e,t,r,i){return t.issues.length?e.value=r.catchValue({...t,value:e.value,error:{issues:t.issues.map(e=>ej(e,i,eY()))},input:e.value}):(e.value=t.value,t.memo&&(e.memo=!0)),e}let rG=eB("$ZodCatch",(e,t)=>{tF.init(e,t),eD(e,"optin",e=>"defaulted"===e.def.innerType._zod.optin?"defaulted":"optional"),eD(e,"optout",e=>e.def.innerType._zod.optout),eD(e,"values",e=>e.def.innerType._zod.values),e._zod.parse=(e,r)=>{if("backward"===r.direction)return t.innerType._zod.run(e,r);let i=t.innerType._zod.run({value:e.value,issues:[]},r);return i instanceof Promise?i.then(i=>rW(e,i,t,r)):rW(e,i,t,r)}}),rK=eB("$ZodPipe",(e,t)=>{tF.init(e,t),eD(e,"values",e=>e.def.in._zod.values),eD(e,"optin",e=>e.def.in._zod.optin),eD(e,"optout",e=>e.def.out._zod.optout),eD(e,"propValues",e=>e.def.in._zod.propValues),e._zod.parse=(e,r)=>{if("backward"===r.direction){let i=t.out._zod.run(e,r);return i instanceof Promise?i.then(e=>rY(e,t.in,r)):rY(i,t.in,r)}let i=t.in._zod.run(e,r);return i instanceof Promise?i.then(e=>rY(e,t.out,r)):rY(i,t.out,r)}});function rY(e,t,r){return e.issues.some(e=>"unrecognized_keys"!==e.code)?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},r)}let rX=eB("$ZodPreprocess",(e,t)=>{rK.init(e,t)}),rQ=eB("$ZodReadonly",(e,t)=>{tF.init(e,t),eD(e,"propValues",e=>e.def.innerType._zod.propValues),eD(e,"values",e=>e.def.innerType._zod.values),eD(e,"optin",e=>e.def.innerType?._zod?.optin),eD(e,"optout",e=>e.def.innerType?._zod?.optout),e._zod.parse=(e,r)=>{if("backward"===r.direction)return t.innerType._zod.run(e,r);let i=t.innerType._zod.run(e,r);return i instanceof Promise?i.then(r0):r0(i)}});function r0(e){return e.memo||(e.value=Object.freeze(e.value)),e}let r1=eB("$ZodLazy",(e,t)=>{var r;let i;tF.init(e,t),r=e._zod,Object.defineProperty(r,"innerType",{get(){if(i!==eo)return void 0===i&&(i=eo,i=(()=>(t._cachedInner||(t._cachedInner=t.getter()),t._cachedInner))()),i},set(e){Object.defineProperty(r,"innerType",{value:e})},configurable:!0}),eD(e,"pattern",e=>e.innerType?._zod?.pattern),eD(e,"propValues",e=>e.innerType?._zod?.propValues),eD(e,"optin",e=>e.innerType?._zod?.optin??void 0),eD(e,"optout",e=>e.innerType?._zod?.optout??void 0),e._zod.parse=(t,r)=>e._zod.innerType._zod.run(t,r)}),r2=eB("$ZodCustom",(e,t)=>{tw.init(e,t),tF.init(e,t),e._zod.parse=(e,t)=>e,e._zod.check=r=>{let i=r.value,n=t.fn(i);if(n instanceof Promise)return n.then(t=>r9(t,r,i,e));r9(n,r,i,e)}});function r9(e,t,r,i){if(!e){let e={code:"custom",input:r,inst:i,path:[...i._zod.def.path??[]],continue:!i._zod.def.abort};i._zod.def.params&&(e.params=i._zod.def.params),t.issues.push(eM(e))}}(j=globalThis).__zod_globalRegistry??(j.__zod_globalRegistry=new class e{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){let r=t[0];return this._map.set(e,r),r&&"object"==typeof r&&"id"in r&&this._idmap.set(r.id,e),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let t=this._map.get(e);return t&&"object"==typeof t&&"id"in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let r={...this.get(t)??{}};delete r.id;let i={...r,...this._map.get(e)};return Object.keys(i).length?i:void 0}return this._map.get(e)}has(e){return this._map.has(e)}});let r4=globalThis.__zod_globalRegistry;function r3(e){return e.checks&&(e.checks=[...e.checks]),e}function r6(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...ew(t)})}function r5(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...ew(t)})}function r7(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...ew(t)})}function r8(e,t){return new e({type:"string",format:"date",check:"string_format",...ew(t)})}function ie(e,t){return new tx({check:"less_than",...ew(t),value:e,inclusive:!1})}function it(e,t){return new tx({check:"less_than",...ew(t),value:e,inclusive:!0})}function ir(e,t){return new t$({check:"greater_than",...ew(t),value:e,inclusive:!1})}function ii(e,t){return new t$({check:"greater_than",...ew(t),value:e,inclusive:!0})}function ia(e,t){return new tT({check:"multiple_of",...ew(t),value:e})}function io(e,t){return new tP({check:"max_length",...ew(t),maximum:e})}function is(e,t){return new tO({check:"min_length",...ew(t),minimum:e})}function il(e,t){return new tE({check:"length_equals",...ew(t),length:e})}function ic(e){return new tL({check:"overwrite",tx:e})}function iu(e,...t){for(let r of t)for(let t of Reflect.ownKeys(r))Object.prototype.propertyIsEnumerable.call(r,t)&&es(e,t,r[t]);return e}function id(e){let t=e?.target??"draft-2020-12";return"draft-4"===t&&(t="draft-04"),"draft-7"===t&&(t="draft-07"),{processors:e.processors??{},metadataRegistry:e?.metadata??r4,target:t,unrepresentable:e?.unrepresentable??"throw",override:e?.override??(()=>{}),io:e?.io??"output",counter:0,seen:new Map,sharedDefsExtractedFor:void 0,sharedEmitDoneFor:void 0,cycles:e?.cycles??"ref",reused:e?.reused??"inline",intersections:[],deferred:[],external:e?.external??void 0}}function ip(e,t,r,i,n){let a="function"==typeof t.unrepresentable?t.unrepresentable({zodSchema:e,path:i.path,message:n}):t.unrepresentable;if("any"===a)return!1;if(void 0===a||"throw"===a)throw Error(n);return Object.assign(r,a),!0}function im(e,t,r={path:[],schemaPath:[]}){var i;let n=e._zod.def,a=t.seen.get(e);if(a)return a.count++,r.schemaPath.includes(e)&&(a.cycle=r.path),a.schema;let o={schema:{},count:1,cycle:void 0,path:r.path};t.seen.set(e,o),t.sharedDefsExtractedFor=void 0,t.sharedEmitDoneFor=void 0;let s=e._zod.toJSONSchema?.();if(s)o.schema=s;else{let i={...r,schemaPath:[...r.schemaPath,e],path:r.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,o.schema,i);else{let r=o.schema,a=t.processors[n.type];if(!a)throw Error(`[toJSONSchema]: Non-representable type encountered: ${n.type}`);a(e,t,r,i)}let a=e._zod.parent;a&&(o.ref||(o.ref=a),im(a,t,i),t.seen.get(a).isParent=!0)}let l=t.metadataRegistry.get(e);return l&&iu(o.schema,l),"input"===t.io&&function e(t,r){let i=r??{seen:new Set};if(i.seen.has(t))return!1;i.seen.add(t);let n=t._zod.def;if("transform"===n.type)return!0;if("array"===n.type)return e(n.element,i);if("set"===n.type)return e(n.valueType,i);if("lazy"===n.type)return e(n.getter(),i);if("promise"===n.type||"optional"===n.type||"nonoptional"===n.type||"nullable"===n.type||"readonly"===n.type||"default"===n.type||"prefault"===n.type||"catch"===n.type)return e(n.innerType,i);if("intersection"===n.type)return e(n.left,i)||e(n.right,i);if("record"===n.type||"map"===n.type)return e(n.keyType,i)||e(n.valueType,i);if("pipe"===n.type)return!!t._zod.traits.has("$ZodCodec")||e(n.in,i)||e(n.out,i);if("object"===n.type){for(let t in n.shape)if(e(n.shape[t],i))return!0;return!1}if("union"===n.type){for(let t of n.options)if(e(t,i))return!0;return!1}if("tuple"===n.type){for(let t of n.items)if(e(t,i))return!0;if(n.rest&&e(n.rest,i))return!0}return!1}(e)&&(delete o.schema.examples,delete o.schema.default),"input"===t.io&&"_prefault"in o.schema&&((i=o.schema).default??(i.default=o.schema._prefault)),delete o.schema._prefault,t.seen.get(e).schema}function ih(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function ig(e,t){let r=e.seen.get(t);if(!r)throw Error("Unprocessed schema. This is a bug in Zod.");if(e.external&&e.sharedDefsExtractedFor===e.external)return;let i=new Map;for(let t of e.seen.entries()){let r=e.metadataRegistry.get(t[0])?.id;if(r){let e=i.get(r);if(e&&e!==t[0])throw Error(`Duplicate schema id "${r}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);i.set(r,t[0])}}let n=t=>{if(t[1].schema.$ref)return;let i=t[1],{ref:n,defId:a}=(t=>{let i="draft-2020-12"===e.target?"$defs":"definitions";if(e.external){let r=e.external.registry.get(t[0])?.id,n=e.external.uri??(e=>e);if(r)return{ref:n(r)};let a=t[1].defId??t[1].schema.id??`schema${e.counter++}`;return t[1].defId=a,{defId:a,ref:`${n("__shared")}#/${i}/${ih(a)}`}}let n=`#/${i}/`;if(t[1]===r&&!t[1].schema.id)return{ref:"#"};let a=t[1].schema.id??`__schema${e.counter++}`;return{defId:a,ref:n+ih(a)}})(t);i.def={...i.schema},a&&(i.defId=a);let o=i.schema;for(let e in o)delete o[e];o.$ref=n};if("throw"===e.cycles)for(let t of e.seen.entries()){let e=t[1];if(e.cycle)throw Error(`Cycle detected: #/${e.cycle?.join("/")}/<root>
|
|
54
54
|
|
|
55
|
-
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let i of t.seen.entries()){let n=i[1];if(r===i[0]){a(i);continue}if(t.external){let n=t.external.registry.get(i[0])?.id;if(r!==i[0]&&n){a(i);continue}}if(t.metadataRegistry.get(i[0])?.id||n.cycle){a(i);continue}n.count>1&&"ref"===t.reused&&a(i)}t.external&&(t.sharedDefsExtractedFor=t.external)}let iy=new Set(["type","properties","required","additionalProperties"]),iv=["oneOf","anyOf"];function i_(t){let r=t.additionalProperties;return void 0===r||!1===r||"object"!=typeof r||null===r?null:Object.keys(r).length?r:null}function ib(t){let r=[];for(let i of t){if("object"!=typeof i||"object"!==i.type)return null;for(let t in i)if(!iy.has(t))return null;r.push(i)}let i={},n=new Set;for(let t of r){for(let n in t.properties){if(Object.prototype.hasOwnProperty.call(i,n))continue;let t=[];for(let i of r){let r=i.properties?.[n]??i_(i);null!=r&&(t.some(t=>JSON.stringify(t)===JSON.stringify(r))||t.push(r))}es(i,n,1===t.length?t[0]:ib(t)??{allOf:t})}for(let r of t.required??[])n.add(r)}let a={type:"object",properties:i};if(n.size&&(a.required=[...n]),r.every(t=>!1===t.additionalProperties))a.additionalProperties=!1;else{let t=[];for(let i of r){let r=i_(i);r&&!t.some(t=>JSON.stringify(t)===JSON.stringify(r))&&t.push(r)}1===t.length?a.additionalProperties=t[0]:t.length>1&&(a.additionalProperties={allOf:t})}return a}function iS(t,r){let i=t.seen.get(r);if(!i)throw Error("Unprocessed schema. This is a bug in Zod.");let n=r=>{let i=t.seen.get(r);if(null===i.ref)return;let a=i.def??i.schema,o={...a},s=i.ref;if(i.ref=null,s){n(s);let i=t.seen.get(s),l=i.schema;if(l.$ref&&("draft-07"===t.target||"draft-04"===t.target||"openapi-3.0"===t.target)?(a.allOf=a.allOf??[],a.allOf.push(l)):iu(a,l),iu(a,o),r._zod.parent===s)for(let t in a)"$ref"!==t&&"allOf"!==t&&(t in o||delete a[t]);if(l.$ref&&i.def)for(let t in a)"$ref"!==t&&"allOf"!==t&&t in i.def&&JSON.stringify(a[t])===JSON.stringify(i.def[t])&&delete a[t]}let l=r._zod.parent;if(l&&l!==s){n(l);let r=t.seen.get(l);if(r?.schema.$ref&&(a.$ref=r.schema.$ref,r.def))for(let t in a)"$ref"!==t&&"allOf"!==t&&t in r.def&&JSON.stringify(a[t])===JSON.stringify(r.def[t])&&delete a[t]}t.override({zodSchema:r,jsonSchema:a,path:i.path??[]})};if(!t.external||t.sharedEmitDoneFor!==t.external){for(let r of[...t.seen.entries()].reverse())n(r[0]);if("openapi-3.0"!==t.target)for(let r of t.seen.entries())!function t(r){let i=r.anyOf;if(!Array.isArray(i)||0===i.length||void 0!==r.type)return;let n=[];for(let r of i){if(!r||"object"!=typeof r)return;t(r);let i=Object.keys(r);if(1!==i.length||"type"!==i[0])return;let a=r.type;for(let t of Array.isArray(a)?a:[a]){if("string"!=typeof t)return;n.includes(t)||n.push(t)}}delete r.anyOf,r.type=1===n.length?n[0]:n}(r[1].def??r[1].schema);for(let r of t.deferred)r();if(t.intersections.length){let r=new Map;for(let i of t.seen.values())for(let t of[i.schema,i.def]){let i=t?.allOf;if(!Array.isArray(i))continue;let n=r.get(i);n?n.push(t):r.set(i,[t])}for(let i of t.intersections)for(let t of r.get(i)??[])!function(t){let r=t.allOf;if(!Array.isArray(r)||r.length<2)return;for(let r of iy)if(r in t)return;let i=r.filter(t=>iv.some(r=>Array.isArray(t[r]))),n=null;if(i.length){let t=i[0],a=iv.find(r=>Array.isArray(t[r]));if(1!==Object.keys(t).length)return;let o=r.filter(r=>r!==t),s=t[a].map(t=>ib([...o,t]));if(s.some(t=>!t))return;n={[a]:s}}else n=ib(r);n&&(delete t.allOf,iu(t,n))}(t)}}let a={};if("draft-2020-12"===t.target?a.$schema="https://json-schema.org/draft/2020-12/schema":"draft-07"===t.target?a.$schema="http://json-schema.org/draft-07/schema#":"draft-04"===t.target?a.$schema="http://json-schema.org/draft-04/schema#":t.target,t.external?.uri){let i=t.external.registry.get(r)?.id;if(!i)throw Error("Schema is missing an `id` property");a.$id=t.external.uri(i)}iu(a,i.defId?i.schema:i.def??i.schema);let o=t.metadataRegistry.get(r)?.id;void 0!==o&&a.id===o&&delete a.id;let s=t.external?.defs??{};if(!t.external||t.sharedEmitDoneFor!==t.external)for(let r of t.seen.entries()){let t=r[1];t.def&&t.defId&&(t.def.id===t.defId&&delete t.def.id,es(s,t.defId,t.def))}t.external&&(t.sharedEmitDoneFor=t.external),t.external||Object.keys(s).length>0&&("draft-2020-12"===t.target?a.$defs=s:a.definitions=s);try{let i=JSON.parse(JSON.stringify(a));return Object.defineProperty(i,"~standard",{value:{...r["~standard"],jsonSchema:{input:iw(r,"input",t.processors),output:iw(r,"output",t.processors)}},enumerable:!1,writable:!1}),i}catch(t){throw Error("Error converting schema to JSON.")}}let iw=(t,r,i={})=>n=>{let{libraryOptions:a,target:o}=n??{},s=id({...a??{},target:o,io:r,processors:i});return im(t,s),ig(s,t),iS(s,t)},iR=(t,r,i)=>{(void 0===t[r]||i>t[r])&&(t[r]=i)},ik=(t,r,i)=>{(void 0===t[r]||i<t[r])&&(t[r]=i)},ix=(t,r)=>{iR(t,"minimum",r),ik(t,"maximum",r)},i$=(t,r)=>{t.multipleOf??(t.multipleOf=[]),t.multipleOf.includes(r)||t.multipleOf.push(r)},iT=(t,r)=>{t.patterns??(t.patterns=new Set),t.patterns.add(r)},iC=(t,r)=>{t.mime=t.mime?t.mime.filter(t=>r.includes(t)):[...r]},iE=(t,r)=>{t.format=r,r.includes("int")&&(t.isInt=!0)},iP=(t,r)=>iR(t,"minimum",r.minimum),iO=(t,r)=>ik(t,"maximum",r.maximum),iI=t=>(r,i)=>{iE(r,i.format);let[n,a]=t[i.format];iR(r,"minimum",n),ik(r,"maximum",a)},iq={greater_than:(t,r)=>iR(t,r.inclusive?"minimum":"exclusiveMinimum",r.value),less_than:(t,r)=>ik(t,r.inclusive?"maximum":"exclusiveMaximum",r.value),multiple_of:(t,r)=>i$(t,r.value),number_format:iI(ek),bigint_format:iI(ex),min_length:iP,max_length:iO,length_equals:(t,r)=>ix(t,r.length),min_size:iP,max_size:iO,size_equals:(t,r)=>ix(t,r.size),string_format:(t,r)=>{iE(t,r.format),r.pattern&&iT(t,r.pattern),("base64"===r.format||"base64url"===r.format)&&(t.contentEncoding=r.format),(r.local||-1===r.precision)&&(t.laxFormat=!0)},mime_type:(t,r)=>iC(t,r.mime)};function ij(t){let r={},i=t._zod.def;for(let n of t._zod.traits.has("$ZodCheck")?[t,...i.checks??[]]:i.checks??[])iq[n._zod.def.check]?.(r,n._zod.def);let n=t._zod.bag;for(let t of(void 0!==n.minimum&&iR(r,"minimum",n.minimum),void 0!==n.exclusiveMinimum&&iR(r,"exclusiveMinimum",n.exclusiveMinimum),void 0!==n.maximum&&ik(r,"maximum",n.maximum),void 0!==n.exclusiveMaximum&&ik(r,"exclusiveMaximum",n.exclusiveMaximum),void 0!==n.multipleOf&&i$(r,n.multipleOf),void 0!==n.format&&(r.format??(r.format=n.format),n.format.includes("int")&&(r.isInt=!0)),n.mime&&iC(r,n.mime),n.patterns??[]))iT(r,t);return r}let iA={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},iz=new Map([[rc,/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/],[rd,/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/]]),iN=t=>iz.get(t)??t,iM=(t,r,i,n)=>{i.type="string";let{minimum:a,maximum:o,format:s,patterns:l,contentEncoding:c,laxFormat:u}=ij(t);if("number"==typeof a&&(i.minLength=a),"number"==typeof o&&(i.maxLength=o),s&&(i.format=iA[s]??s,""===i.format&&delete i.format,("time"===s||u)&&delete i.format),c&&(i.contentEncoding=c),l&&l.size>0){let t=[...l].map(iN);1===t.length?i.pattern=t[0].source:t.length>1&&(i.allOf=[...t.map(t=>({..."draft-07"===r.target||"draft-04"===r.target||"openapi-3.0"===r.target?{type:"string"}:{},pattern:t.source}))])}},iL=(t,r,i,n)=>{let{minimum:a,maximum:o,multipleOf:s,exclusiveMaximum:l,exclusiveMinimum:c,isInt:u}=ij(t);i.type=u?"integer":"number";let d="number"==typeof c&&c>=(a??-1/0),p="number"==typeof l&&l<=(o??1/0),m="draft-04"===r.target||"openapi-3.0"===r.target;if(d?m?(i.minimum=c,i.exclusiveMinimum=!0):i.exclusiveMinimum=c:"number"==typeof a&&(i.minimum=a),p?m?(i.maximum=l,i.exclusiveMaximum=!0):i.exclusiveMaximum=l:"number"==typeof o&&(i.maximum=o),s){let a=new Set;for(let o of s)Number.isFinite(o)&&0!==o?a.add(Math.abs(o)):ip(t,r,i,n,`A multipleOf divisor of ${o} cannot be represented in JSON Schema`);let[o,...l]=a;void 0!==o&&(i.multipleOf=o),l.length&&(i.allOf=[...i.allOf??[],...l.map(t=>({multipleOf:t}))])}},iZ=(t,r,i,n)=>{i.type="boolean"},iU=(t,r,i,n)=>{"openapi-3.0"===r.target?(i.type="string",i.nullable=!0,i.enum=[null]):i.type="null"},iF=(t,r,i,n)=>{i.not={}},iD=(t,r,i,n)=>{},iH=(t,r,i,n)=>{},iJ=(t,r,i,n)=>{let a=ee(t._zod.def.entries);if(0===a.length){i.not={};return}a.every(t=>"number"==typeof t)&&(i.type="number"),a.every(t=>"string"==typeof t)&&(i.type="string"),i.enum=a},iV=(t,r,i,n)=>{let a=t._zod.def;if(0===a.values.length){i.not={};return}let o=[];for(let s of a.values)if(void 0===s){if(ip(t,r,i,n,"Literal `undefined` cannot be represented in JSON Schema"))return}else if("bigint"==typeof s){if(ip(t,r,i,n,"BigInt literals cannot be represented in JSON Schema"))return;o.push(Number(s))}else o.push(s);if(0===o.length);else if(1===o.length){let t=o[0];i.type=null===t?"null":typeof t,"draft-04"===r.target||"openapi-3.0"===r.target?i.enum=[t]:i.const=t}else o.every(t=>"number"==typeof t)&&(i.type="number"),o.every(t=>"string"==typeof t)&&(i.type="string"),o.every(t=>"boolean"==typeof t)&&(i.type="boolean"),o.every(t=>null===t)&&(i.type="null"),i.enum=o},iB=(t,r,i,n)=>{ip(t,r,i,n,"Custom types cannot be represented in JSON Schema")},iW=(t,r,i,n)=>{ip(t,r,i,n,"Transforms cannot be represented in JSON Schema")},iG=(t,r,i,n)=>{let a=t._zod.def,{minimum:o,maximum:s}=ij(t);"number"==typeof o&&(i.minItems=o),"number"==typeof s&&(i.maxItems=s),i.type="array",i.items=im(a.element,r,{...n,path:[...n.path,"items"]})};function iK(t){let r=t._zod.def;return"pipe"===r.type&&r.in._zod.traits.has("$ZodTransform")?iK(r.out):"catch"===r.type?iK(r.innerType):t._zod.optin}let iY=(t,r,i,n)=>{let a=t._zod.def,o=a.shape;if(Object.getOwnPropertySymbols(o).length&&ip(t,r,i,n,"Symbol keys cannot be represented in JSON Schema"))return;for(let t in i.type="object",i.properties={},o)es(i.properties,t,im(o[t],r,{...n,path:[...n.path,"properties",t]}));let s=[];for(let t of Object.keys(o)){let i=a.shape[t];("input"===r.io?void 0===iK(i):void 0===i._zod.optout)&&s.push(t)}s.length>0&&(i.required=s),a.catchall?._zod.def.type==="never"?i.additionalProperties=!1:a.catchall?a.catchall&&(i.additionalProperties=im(a.catchall,r,{...n,path:[...n.path,"additionalProperties"]})):"output"===r.io&&(i.additionalProperties=!1)},iX=(t,r,i,n)=>{let a=t._zod.def,o=!1===a.inclusive,s=a.options.map((t,i)=>im(t,r,{...n,path:[...n.path,o?"oneOf":"anyOf",i]}));o?i.oneOf=s:i.anyOf=s},iQ=(t,r,i,n)=>{let a=t._zod.def,o=im(a.left,r,{...n,path:[...n.path,"allOf",0]}),s=im(a.right,r,{...n,path:[...n.path,"allOf",1]}),l=t=>"allOf"in t&&1===Object.keys(t).length,c=[...l(o)?o.allOf:[o],...l(s)?s.allOf:[s]];i.allOf=c,r.intersections.push(c)},i0=new WeakMap,i1=(t,r,i,n)=>{let a=t._zod.def;i.type="object";let o=a.keyType,s=ij(o).patterns;if("loose"===a.mode&&s&&s.size>0){let t=im(a.valueType,r,{...n,path:[...n.path,"patternProperties","*"]});for(let r of(i.patternProperties={},s))es(i.patternProperties,iN(r).source,t)}else{if("draft-07"===r.target||"draft-2020-12"===r.target){i.propertyNames=im(a.keyType,r,{...n,path:[...n.path,"propertyNames"]});let o=i0.get(r);o||(o=[],i0.set(r,o),r.deferred.push(()=>(function(t){let r=new Map;for(let i of t.seen.values())i.def&&!r.has(i.schema)&&r.set(i.schema,i);let i=new Map;for(let n of i0.get(t)??[]){let a=t.seen.get(n),o=(a?.def??a?.schema)?.propertyNames;if(!o||!0===o||i.has(o))continue;let s=function t(r,i,n){if(i.$ref){if(n.has(i))return i;n.add(i);let a=r.get(i)?.def;if(!a)return i;let o=t(r,a,n);return o===a?i:o}for(let a of["anyOf","oneOf"]){let o=i[a];if(!Array.isArray(o))continue;let s=o.map(i=>t(r,i,n));s.some((t,r)=>t!==o[r])&&(i={...i,[a]:s})}let a=Array.isArray(i.type)?i.type:[i.type],o=!a.includes("string")&&a.some(t=>"number"===t||"integer"===t),s=i.enum??(void 0!==i.const?[i.const]:void 0);if(!o&&!s?.some(t=>"number"==typeof t))return i;let{minimum:l,maximum:c,exclusiveMinimum:u,exclusiveMaximum:d,multipleOf:p,format:m,id:h,...f}=i;return f.enum?f.enum=f.enum.map(t=>"number"==typeof t?String(t):t):"number"==typeof f.const&&(f.const=String(f.const)),o&&(f.type="string",s||(f.pattern=(a.includes("number")?ty:tg).source)),f}(r,o,new Set);s!==o&&i.set(o,s)}if(i.size)for(let r of t.seen.values())for(let t of[r.schema,r.def]){let r=t&&i.get(t.propertyNames);r&&(t.propertyNames=r)}})(r))),o.push(t)}i.additionalProperties=im(a.valueType,r,{...n,path:[...n.path,"additionalProperties"]})}let l=o._zod.values,c="input"===r.io&&void 0!==iK(a.valueType);if(l&&!a.partial&&!c){let t=[...l].filter(t=>"string"==typeof t||"number"==typeof t);t.length>0&&(i.required=t.map(String))}},i2=(t,r,i,n)=>{let a=t._zod.def,o=im(a.innerType,r,n),s=r.seen.get(t);"openapi-3.0"===r.target?(s.ref=a.innerType,i.nullable=!0):i.anyOf=[o,{type:"null"}]},i9=(t,r,i,n)=>{let a=t._zod.def;im(a.innerType,r,n),r.seen.get(t).ref=a.innerType},i4=Symbol();function i3(t,r,i,n,a){let o=!1,s=JSON.stringify(t,(t,r)=>"bigint"!=typeof r?r:(o=!0,null));return o?(ip(r,i,n,a,"BigInt defaults cannot be represented in JSON Schema"),i4):JSON.parse(s)}let i6=(t,r,i,n)=>{let a=t._zod.def;im(a.innerType,r,n),r.seen.get(t).ref=a.innerType;let o=i3(a.defaultValue,t,r,i,n);o!==i4&&(i.default=o)},i5=(t,r,i,n)=>{let a=t._zod.def;if(im(a.innerType,r,n),r.seen.get(t).ref=a.innerType,"input"!==r.io)return;let o=i3(a.defaultValue,t,r,i,n);o!==i4&&(i._prefault=o)},i7=(t,r,i,n)=>{let a,o=t._zod.def;im(o.innerType,r,n),r.seen.get(t).ref=o.innerType;try{a=o.catchValue(void 0)}catch{ip(t,r,i,n,"Dynamic catch values are not supported in JSON Schema");return}i.default=a},i8=(t,r,i,n)=>{let a=t._zod.def,o=a.in._zod.traits.has("$ZodTransform"),s="input"===r.io?o?a.out:a.in:a.out;im(s,r,n),r.seen.get(t).ref=s},ne=(t,r,i,n)=>{let a=t._zod.def;im(a.innerType,r,n),r.seen.get(t).ref=a.innerType,i.readOnly=!0},nt=(t,r,i,n)=>{let a=t._zod.def;im(a.innerType,r,n),r.seen.get(t).ref=a.innerType},nr=(t,r,i,n)=>{let a=t._zod.innerType;im(a,r,n),r.seen.get(t).ref=a},ni={string:iM,number:iL,boolean:iZ,bigint:(t,r,i,n)=>{ip(t,r,i,n,"BigInt cannot be represented in JSON Schema")},symbol:(t,r,i,n)=>{ip(t,r,i,n,"Symbols cannot be represented in JSON Schema")},null:iU,undefined:(t,r,i,n)=>{ip(t,r,i,n,"Undefined cannot be represented in JSON Schema")},void:(t,r,i,n)=>{ip(t,r,i,n,"Void cannot be represented in JSON Schema")},never:iF,any:iD,unknown:iH,date:(t,r,i,n)=>{ip(t,r,i,n,"Date cannot be represented in JSON Schema")},enum:iJ,literal:iV,nan:(t,r,i,n)=>{ip(t,r,i,n,"NaN cannot be represented in JSON Schema")},template_literal:(t,r,i,n)=>{let a=t._zod.pattern;if(!a)throw Error("Pattern not found in template literal");i.type="string",i.pattern=a.source},file:(t,r,i,n)=>{i.type="string",i.format="binary",i.contentEncoding="binary";let{minimum:a,maximum:o,mime:s}=ij(t);void 0!==a&&(i.minLength=a),void 0!==o&&(i.maxLength=o),s&&(0===s.length?i.not={}:1===s.length?i.contentMediaType=s[0]:i.anyOf=s.map(t=>({contentMediaType:t})))},success:(t,r,i,n)=>{i.type="boolean"},custom:iB,function:(t,r,i,n)=>{ip(t,r,i,n,"Function types cannot be represented in JSON Schema")},transform:iW,map:(t,r,i,n)=>{ip(t,r,i,n,"Map cannot be represented in JSON Schema")},set:(t,r,i,n)=>{ip(t,r,i,n,"Set cannot be represented in JSON Schema")},array:iG,object:iY,union:iX,intersection:iQ,tuple:(t,r,i,n)=>{let a=t._zod.def;i.type="array";let o="draft-2020-12"===r.target?"prefixItems":"items",s="draft-2020-12"===r.target||"openapi-3.0"===r.target?"items":"additionalItems",l=a.items.map((t,i)=>im(t,r,{...n,path:[...n.path,o,i]})),c=a.rest?im(a.rest,r,{...n,path:[...n.path,s,..."openapi-3.0"===r.target?[a.items.length]:[]]}):null,u=a.items.length;for(;u>0;){let t=a.items[u-1];if(!("input"===r.io?void 0!==iK(t):"optional"===t._zod.optout))break;u--}let d=a.items.length,p=!a.rest;"draft-2020-12"===r.target?(i.prefixItems=l,p?i.items=!1:c&&(i.items=c)):"openapi-3.0"===r.target?(i.items={anyOf:l},c&&i.items.anyOf.push(c)):(i.items=l,p?i.additionalItems=!1:c&&(i.additionalItems=c)),u>0&&(i.minItems=u),p&&(i.maxItems=d);let{minimum:m,maximum:h}=ij(t);"number"==typeof m&&(i.minItems=m),"number"==typeof h&&(i.maxItems=h)},record:i1,nullable:i2,nonoptional:i9,default:i6,prefault:i5,catch:i7,pipe:i8,readonly:ne,promise:(t,r,i,n)=>{let a=t._zod.def;im(a.innerType,r,n),r.seen.get(t).ref=a.innerType},optional:nt,lazy:nr};function nn(t,r){if("_idmap"in t){let i=id({...r,processors:ni}),n={};for(let r of t._idmap.entries()){let[t,n]=r;im(n,i)}let a={};for(let o of(i.external={registry:t,uri:r?.uri,defs:n},t._idmap.entries())){let[t,r]=o;ig(i,r),es(a,t,iS(i,r))}return Object.keys(n).length>0&&(a.__shared={["draft-2020-12"===i.target?"$defs":"definitions"]:n}),{schemas:a}}let i=id({...r,processors:ni});return im(t,i),ig(i,t),iS(i,t)}let na={get:function(){let t=this._zod;return t.message??(t.message=JSON.stringify(t.def,er,2)),t.message},set:function(t){this._zod.message=t},enumerable:!0,configurable:!0},no={value:void 0,enumerable:!1},ns=new WeakSet([Object.prototype,Error.prototype]),nl=(t,r)=>{t.name="$ZodError",no.value=r,Object.defineProperty(t,"issues",no),no.value=void 0,Object.defineProperty(t,"message",na);let i=Object.getPrototypeOf(t);ns.has(i)||(ns.add(i),Object.defineProperty(i,"toString",{configurable:!0,enumerable:!1,get(){let t=()=>this.message;return Object.defineProperty(this,"toString",{value:t,configurable:!0,writable:!0}),t},set(t){Object.defineProperty(this,"toString",{value:t,configurable:!0,writable:!0})}}))},nc=eV("$ZodError",nl);function nu(t,r){return{callee:r?.callee??t,Err:r?.Err}}eV("$ZodError",nl,void 0,{Parent:Error});let nd=t=>{let r=(i,n,a,o)=>{let s=a?{...a,async:!1}:{async:!1},l=i._zod.run({value:n,issues:[]},s);if(l instanceof Promise)throw new eB;if(l.issues.length){let i=new(o?.Err??t)(l.issues.map(t=>eq(t,s,eK())));throw eh(i,o?.callee??r),i}return l.value};return r},np=t=>{let r=async(i,n,a,o)=>{let s=a?{...a,async:!0}:{async:!0},l=i._zod.run({value:n,issues:[]},s);if(l instanceof Promise&&(l=await l),l.issues.length){let i=new(o?.Err??t)(l.issues.map(t=>eq(t,s,eK())));throw eh(i,o?.callee??r),i}return l.value};return r},nm=t=>(r,i,n)=>{let a=n?{...n,async:!1}:{async:!1},o=r._zod.run({value:i,issues:[]},a);if(o instanceof Promise)throw new eB;return o.issues.length?nh(t,o.issues,a):{success:!0,data:o.value}};function nh(t,r,i){let n;return{success:!1,get error(){return n||(n=new t(r.map(t=>eq(t,i,eK()))),r=void 0,i=void 0),n},set error(e){n=e,r=void 0,i=void 0}}}let nf=t=>async(r,i,n)=>{let a=n?{...n,async:!0}:{async:!0},o=r._zod.run({value:i,issues:[]},a);return o instanceof Promise&&(o=await o),o.issues.length?nh(t,o.issues,a):{success:!0,data:o.value}},ng=Symbol.for("zod.compile.invalid"),ny=Symbol.for("zod.compile.fallback"),nv=async(t,r,i)=>{let n=i?{...i,async:!0,abortEarly:!0}:{async:!0,abortEarly:!0},a=t._zod.run({value:r,issues:[]},n);return a instanceof Promise&&(a=await a),0===a.issues.length},n_=new WeakSet([Object.prototype,Error.prototype]);function nb(t,r,i){Object.defineProperty(t,r,{configurable:!0,enumerable:!1,get(){let t=i(this);return Object.defineProperty(this,r,{value:t,configurable:!0,writable:!0}),t},set(t){Object.defineProperty(this,r,{value:t,configurable:!0,writable:!0})}})}let nS=eV("ZodError",(t,r)=>{nc.init(t,r),t.name="ZodError";let i=Object.getPrototypeOf(t);n_.has(i)||(n_.add(i),nb(i,"format",t=>r=>(function(t,r=t=>t.message){let i={_errors:[]},n=(t,a=[])=>{for(let o of t.issues)if("invalid_union"===o.code&&o.errors.length)o.errors.map(t=>n({issues:t},[...a,...o.path]));else if("invalid_key"===o.code)n({issues:o.issues},[...a,...o.path]);else if("invalid_element"===o.code)n({issues:o.issues},[...a,...o.path]);else{let t=[...a,...o.path];if(0===t.length)i._errors.push(r(o));else{let n=i,a=0;for(;a<t.length;){let i=t[a],s=a===t.length-1;if("_errors"===i){s&&n._errors.push(r(o)),a++;continue}Object.prototype.hasOwnProperty.call(n,i)||Object.defineProperty(n,i,{value:{_errors:[]},enumerable:!0,writable:!0,configurable:!0});let l=n[i];s&&l._errors.push(r(o)),n=l,a++}}}};return n(t),i})(t,r)),nb(i,"flatten",t=>r=>(function(t,r=t=>t.message){let i={},n=[];for(let s of t.issues)if(s.path.length>0){var a,o;(a=s.path[0],o=()=>[],!Object.prototype.hasOwnProperty.call(i,a)&&("__proto__"===a?Object.defineProperty(i,a,{value:o(),writable:!0,enumerable:!0,configurable:!0}):i[a]=o()),i[a]).push(r(s))}else n.push(r(s));return{formErrors:n,fieldErrors:i}})(t,r)),nb(i,"addIssue",t=>r=>{t.issues.push(r),t.message=JSON.stringify(t.issues,er,2)}),nb(i,"addIssues",t=>r=>{t.issues.push(...r),t.message=JSON.stringify(t.issues,er,2)}),Object.defineProperty(i,"isEmpty",{configurable:!0,enumerable:!1,get(){return 0===this.issues.length}}))},void 0,{Parent:Error}),nw=nd(nS),nR=np(nS),nk=nm(nS),nx=nf(nS),n$=(m=nd(nS),h=(t,r,i,n)=>m(t,r,i?{...i,direction:"backward"}:{direction:"backward"},nu(h,n))),nT=(f=nd(nS),g=(t,r,i,n)=>f(t,r,i,nu(g,n))),nC=(y=np(nS),v=async(t,r,i,n)=>{let a=i?{...i,direction:"backward"}:{direction:"backward"};return await y(t,r,a,nu(v,n))}),nE=(_=np(nS),b=async(t,r,i,n)=>await _(t,r,i,nu(b,n))),nP=(t,r,i)=>{let n=i?{...i,direction:"backward"}:{direction:"backward"};return nm(nS)(t,r,n)},nO=(t,r,i)=>nm(nS)(t,r,i),nI=async(t,r,i)=>{let n=i?{...i,direction:"backward"}:{direction:"backward"};return nf(nS)(t,r,n)},nq=async(t,r,i)=>nf(nS)(t,r,i);function nj(){eG.memoizer||eK({memoizer:e4})}let nA=eV("ZodType",(t,r)=>(eG.localeError||eK({localeError:(()=>{let t={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"}},r={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",mac:"MAC address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",currency_code:"currency code",credit_card:"credit card number",iban:"IBAN",jwt:"JWT",template_literal:"input"},i={nan:"NaN"};function n(t,r){return"number"!==t||"number"!=typeof r||Number.isFinite(r)?i[t]??t:String(r)}return i=>{switch(i.code){case"invalid_type":{let t=n(i.expected),r=n(function(t){let r=typeof t;switch(r){case"number":return Number.isNaN(t)?"nan":"number";case"object":if(null===t)return"null";if(Array.isArray(t))return"array";if(t&&Object.getPrototypeOf(t)!==Object.prototype&&"constructor"in t&&t.constructor)return t.constructor.name}return r}(i.input),i.input);return`Invalid input: expected ${t}, received ${r}`}case"invalid_value":if(1===i.values.length)return`Invalid input: expected ${eR(i.values[0])}`;return`Invalid option: expected one of ${et(i.values,"|")}`;case"too_big":{let r=i.exact?"exactly ":i.inclusive?"<=":"<",n=t[i.origin]??null;if(n)return`Too big: expected ${i.origin??"value"} to have ${r}${i.maximum.toString()} ${n.unit??"elements"}`;return`Too big: expected ${i.origin??"value"} to be ${r}${i.maximum.toString()}`}case"too_small":{let r=i.exact?"exactly ":i.inclusive?">=":">",n=t[i.origin]??null;if(n)return`Too small: expected ${i.origin} to have ${r}${i.minimum.toString()} ${n.unit}`;return`Too small: expected ${i.origin} to be ${r}${i.minimum.toString()}`}case"invalid_format":if("starts_with"===i.format)return`Invalid string: must start with "${i.prefix}"`;if("ends_with"===i.format)return`Invalid string: must end with "${i.suffix}"`;if("includes"===i.format)return`Invalid string: must include "${i.includes}"`;if("regex"===i.format)return`Invalid string: must match pattern ${i.pattern}`;return`Invalid ${r[i.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":""}: ${et(i.keys,", ")}`;case"invalid_key":return`Invalid key in ${i.origin}`;case"invalid_union":if(i.options&&Array.isArray(i.options)&&i.options.length>0){let t=i.options.map(t=>`'${t}'`).join(" | ");return`Invalid discriminator value. Expected ${t}`}if(!1===i.inclusive)return"Invalid input: more than one option matched";return"Invalid input";case"invalid_element":return`Invalid value in ${i.origin}`;default:return"Invalid input"}}})()}),tF.init(t,r),t.def=r,t.type=r.type,t),{check(...t){let r=this.def;return this.clone(em(r,{checks:[...r.checks??[],...t.map(t=>"function"==typeof t?{_zod:{check:t,def:{check:"custom"},onattach:[]}}:t)]}),{parent:!0})},with(...t){return this.check(...t)},clone(t,r){return eS(this,t,r)},brand(){return this},register(t,r){return t.add(this,r),this},refine(t,r){return this.check(function(t,r={}){return new aJ({type:"custom",check:"custom",fn:t,...ew(r)})}(t,r))},superRefine(t,r){return this.check(function(t,r){var i;let n,a;return i=r=>(r.addIssue=t=>{"string"==typeof t?r.issues.push(eN(t,r.value,n._zod.def)):(t.fatal&&(t.continue=!1),t.code??(t.code="custom"),"input"in t||(t.input=r.value),t.inst??(t.inst=n),t.continue??(t.continue=!n._zod.def.abort),r.issues.push(eN(t)))},t(r.value,r)),(a=new tw({check:"custom",...ew(r)}))._zod.check=i,n=a}(t,r))},overwrite(t){return this.check(ic(t))},optional(){return aO(this)},exactOptional(){var t;return t=this,new aI({type:"optional",innerType:t})},nullable(){return aj(this)},nullish(){return aO(aj(this))},nonoptional(t){var r;return r=this,new aN({type:"nonoptional",innerType:r,...ew(t)})},array(){return ap(this)},or(t){return ay([this,t])},and(t){return aS(this,t)},transform(t){return aZ(this,aE(t))},default(t){var r,i;return r=this,i=t,new aA({type:"default",innerType:r,get defaultValue(){return"function"==typeof i?i():ev(i)}})},prefault(t){var r,i;return r=this,i=t,new az({type:"prefault",innerType:r,get defaultValue(){return"function"==typeof i?i():ev(i)}})},catch(t){return function(t,r){let i;return new aM({type:"catch",innerType:t,catchValue:"function"==typeof r?r:((i=()=>r)["~constantCatch"]=!0,i)})}(this,t)},pipe(t){return aZ(this,t)},readonly(){var t;return t=this,new aF({type:"readonly",innerType:t})},describe(t){let r=this.clone();return r4.add(r,{description:t}),r},meta(...t){if(0===t.length)return r4.get(this);let r=this.clone();return r4.add(r,t[0]),r},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(t,...r){return 0===r.length?t(this):t(this,...r)},get"~standard"(){return eM(this,"~standard",{...tJ(this),jsonSchema:{input:iw(this,"input"),output:iw(this,"output")}},!1)},set"~standard"(value){eM(this,"~standard",value)},parse:function t(r,i){return nw(this,r,i,{callee:t})},parseAsync:async function t(r,i){return await nR(this,r,i,{callee:t})},safeParse(t,r){return nk(this,t,r)},async safeParseAsync(t,r){return nx(this,t,r)},get spa(){return this?.safeParseAsync},set spa(value){eM(this,"spa",value)},validate(t,r){let i=this._zod.bag.validator;if(void 0!==i){if(i(t)!==ng)return!0;if(!0===i.definite&&void 0===r)return!1}return function(t,r,i){let n,a=i?{...i,async:!1,abortEarly:!0}:{async:!1,abortEarly:!0},o=t._zod.bag.fallbackRun;if(o?(a[ny]=!0,n=o({value:r,issues:[]},a)):n=t._zod.run({value:r,issues:[]},a),n instanceof Promise)throw new eB;return 0===n.issues.length}(this,t,r)},validateAsync(t,r){return nv(this,t,r)},encode:function t(r,i){return n$(this,r,i,{callee:t})},decode:function t(r,i){return nT(this,r,i,{callee:t})},encodeAsync:async function t(r,i){return await nC(this,r,i,{callee:t})},decodeAsync:async function t(r,i){return await nE(this,r,i,{callee:t})},safeEncode(t,r){return nP(this,t,r)},safeDecode(t,r){return nO(this,t,r)},async safeEncodeAsync(t,r){return nI(this,t,r)},async safeDecodeAsync(t,r){return nq(this,t,r)},toJSONSchema(t){return((t,r={})=>i=>{let n=id({...i,processors:r});return im(t,n),ig(n,t),iS(n,t)})(this,{})(t)},get description(){return r4.get(this)?.description},get _def(){return this._zod.def}}),nz=eV("_ZodString",(t,r)=>{tV.init(t,r),nA.init(t,r),t._zod.processJSONSchema=(r,i,n)=>iM(t,r,i,n)},eL({format:t=>ij(t).format??null,minLength:t=>ij(t).minimum??null,maxLength:t=>ij(t).maximum??null},{regex(...t){return this.check(function(t,r){return new tq({check:"string_format",format:"regex",...ew(r),pattern:t})}(...t))},includes(...t){return this.check(function(t,r){return new tz({check:"string_format",format:"includes",...ew(r),includes:t})}(...t))},startsWith(...t){return this.check(function(t,r){return new tN({check:"string_format",format:"starts_with",...ew(r),prefix:t})}(...t))},endsWith(...t){return this.check(function(t,r){return new tM({check:"string_format",format:"ends_with",...ew(r),suffix:t})}(...t))},min(...t){return this.check(is(...t))},max(...t){return this.check(io(...t))},length(...t){return this.check(il(...t))},nonempty(...t){return this.check(is(1,...t))},lowercase(t){return this.check(new tj({check:"string_format",format:"lowercase",...ew(t)}))},uppercase(t){return this.check(new tA({check:"string_format",format:"uppercase",...ew(t)}))},trim(){return this.check(ic(t=>t.trim()))},normalize(...t){return this.check(function(t){return ic(r=>r.normalize(t))}(...t))},toLowerCase(){return this.check(ic(t=>t.toLowerCase()))},toUpperCase(){return this.check(ic(t=>t.toUpperCase()))},slugify(){return this.check(ic(t=>t.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")))}})),nN=eV("ZodString",(t,r)=>{tV.init(t,r),nz.init(t,r)},{email(t){return this.check(r6(nH,t))},url(t){return this.check(r5(nB,t))},jwt(t){return this.check(new n7({type:"string",format:"jwt",check:"string_format",abort:!1,...ew(t)}))},emoji(t){return this.check(new nW({type:"string",format:"emoji",check:"string_format",abort:!1,...ew(t)}))},guid(t){return this.check(new nJ({type:"string",format:"guid",check:"string_format",abort:!1,...ew(t)}))},uuid(t){return this.check(new nV({type:"string",format:"uuid",check:"string_format",abort:!1,...ew(t)}))},uuidv4(t){return this.check(new nV({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...ew(t)}))},uuidv6(t){return this.check(new nV({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...ew(t)}))},uuidv7(t){return this.check(new nV({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...ew(t)}))},nanoid(t){return this.check(new nG({type:"string",format:"nanoid",check:"string_format",abort:!1,...ew(t)}))},cuid(t){return this.check(new nK({type:"string",format:"cuid",check:"string_format",abort:!1,...ew(t)}))},cuid2(t){return this.check(new nY({type:"string",format:"cuid2",check:"string_format",abort:!1,...ew(t)}))},ulid(t){return this.check(new nX({type:"string",format:"ulid",check:"string_format",abort:!1,...ew(t)}))},base64(t){return this.check(new n3({type:"string",format:"base64",check:"string_format",abort:!1,...ew(t)}))},base64url(t){return this.check(new n6({type:"string",format:"base64url",check:"string_format",abort:!1,...ew(t)}))},xid(t){return this.check(new nQ({type:"string",format:"xid",check:"string_format",abort:!1,...ew(t)}))},ksuid(t){return this.check(new n0({type:"string",format:"ksuid",check:"string_format",abort:!1,...ew(t)}))},ipv4(t){return this.check(new n1({type:"string",format:"ipv4",check:"string_format",abort:!1,...ew(t)}))},ipv6(t){return this.check(new n2({type:"string",format:"ipv6",check:"string_format",abort:!1,...ew(t)}))},cidrv4(t){return this.check(new n9({type:"string",format:"cidrv4",check:"string_format",abort:!1,...ew(t)}))},cidrv6(t){return this.check(new n4({type:"string",format:"cidrv6",check:"string_format",abort:!1,...ew(t)}))},e164(t){return this.check(new n5({type:"string",format:"e164",check:"string_format",abort:!1,...ew(t)}))},datetime(t){return this.check(r7(nZ,t))},date(t){return this.check(r8(nU,t))},time(t){return this.check(new nF({type:"string",format:"time",check:"string_format",precision:null,...ew(t)}))},duration(t){return this.check(new nD({type:"string",format:"duration",check:"string_format",...ew(t)}))}});function nM(t){return new nN(r3({type:"string",...ew(t)}))}let nL=eV("ZodStringFormat",(t,r)=>{tB.init(t,r),nz.init(t,r)}),nZ=eV("ZodISODateTime",(t,r)=>{t7.init(t,r),nL.init(t,r)}),nU=eV("ZodISODate",(t,r)=>{t8.init(t,r),nL.init(t,r)}),nF=eV("ZodISOTime",(t,r)=>{re.init(t,r),nL.init(t,r)}),nD=eV("ZodISODuration",(t,r)=>{rt.init(t,r),nL.init(t,r)}),nH=eV("ZodEmail",(t,r)=>{tK.init(t,r),nL.init(t,r)}),nJ=eV("ZodGUID",(t,r)=>{tW.init(t,r),nL.init(t,r)}),nV=eV("ZodUUID",(t,r)=>{tG.init(t,r),nL.init(t,r)}),nB=eV("ZodURL",(t,r)=>{t0.init(t,r),nL.init(t,r)}),nW=eV("ZodEmoji",(t,r)=>{t1.init(t,r),nL.init(t,r)}),nG=eV("ZodNanoID",(t,r)=>{t2.init(t,r),nL.init(t,r)}),nK=eV("ZodCUID",(t,r)=>{t9.init(t,r),nL.init(t,r)}),nY=eV("ZodCUID2",(t,r)=>{t4.init(t,r),nL.init(t,r)}),nX=eV("ZodULID",(t,r)=>{t3.init(t,r),nL.init(t,r)}),nQ=eV("ZodXID",(t,r)=>{t6.init(t,r),nL.init(t,r)}),n0=eV("ZodKSUID",(t,r)=>{t5.init(t,r),nL.init(t,r)}),n1=eV("ZodIPv4",(t,r)=>{rr.init(t,r),nL.init(t,r)}),n2=eV("ZodIPv6",(t,r)=>{ra.init(t,r),nL.init(t,r)}),n9=eV("ZodCIDRv4",(t,r)=>{ro.init(t,r),nL.init(t,r)}),n4=eV("ZodCIDRv6",(t,r)=>{rs.init(t,r),nL.init(t,r)}),n3=eV("ZodBase64",(t,r)=>{ru.init(t,r),nL.init(t,r)}),n6=eV("ZodBase64URL",(t,r)=>{rp.init(t,r),nL.init(t,r)}),n5=eV("ZodE164",(t,r)=>{rm.init(t,r),nL.init(t,r)}),n7=eV("ZodJWT",(t,r)=>{rh.init(t,r),nL.init(t,r)}),n8=eV("ZodNumber",(t,r)=>{rf.init(t,r),nA.init(t,r),t._zod.processJSONSchema=(r,i,n)=>iL(t,r,i,n),t.isFinite=!0},eL({minValue:t=>{let{minimum:r,exclusiveMinimum:i}=ij(t);return Math.max(r??-1/0,i??-1/0)},maxValue:t=>{let{maximum:r,exclusiveMaximum:i}=ij(t);return Math.min(r??1/0,i??1/0)},isInt:t=>{let{isInt:r,multipleOf:i}=ij(t);return!!r||!!i?.some(Number.isSafeInteger)},format:t=>ij(t).format??null},{gt(t,r){return this.check(ir(t,r))},gte(t,r){return this.check(ii(t,r))},min(t,r){return this.check(ii(t,r))},lt(t,r){return this.check(ie(t,r))},lte(t,r){return this.check(it(t,r))},max(t,r){return this.check(it(t,r))},int(t){return this.check(ar(t))},safe(t){return this.check(ar(t))},positive(t){return this.check(ir(0,t))},nonnegative(t){return this.check(ii(0,t))},negative(t){return this.check(ie(0,t))},nonpositive(t){return this.check(it(0,t))},multipleOf(t,r){return this.check(ia(t,r))},step(t,r){return this.check(ia(t,r))},finite(){return this}}));function ae(t){return new n8(r3({type:"number",checks:[],...ew(t)}))}let at=eV("ZodNumberFormat",(t,r)=>{rg.init(t,r),n8.init(t,r)});function ar(t){return new at({type:"number",check:"number_format",abort:!1,format:"safeint",...ew(t)})}let ai=eV("ZodBoolean",(t,r)=>{ry.init(t,r),nA.init(t,r),t._zod.processJSONSchema=(r,i,n)=>iZ(t,r,i,n)});function an(t){return new ai({type:"boolean",...ew(t)})}let aa=eV("ZodNull",(t,r)=>{rv.init(t,r),nA.init(t,r),t._zod.processJSONSchema=(r,i,n)=>iU(t,r,i,n)});function ao(t){return new aa({type:"null",...ew(t)})}let as=eV("ZodAny",(t,r)=>{r_.init(t,r),nA.init(t,r),t._zod.processJSONSchema=(r,i,n)=>iD(t,r,i,n)}),al=eV("ZodUnknown",(t,r)=>{rb.init(t,r),nA.init(t,r),t._zod.processJSONSchema=(r,i,n)=>iH(t,r,i,n)});function ac(){return new al({type:"unknown"})}let au=eV("ZodNever",(t,r)=>{rS.init(t,r),nA.init(t,r),t._zod.processJSONSchema=(r,i,n)=>iF(t,r,i,n)}),ad=eV("ZodArray",(t,r)=>{nj(),rR.init(t,r),nA.init(t,r),t._zod.processJSONSchema=(r,i,n)=>iG(t,r,i,n),t.element=r.element},{min(t,r){return this.check(is(t,r))},nonempty(t){return this.check(is(1,t))},max(t,r){return this.check(io(t,r))},length(t,r){return this.check(il(t,r))},unwrap(){return this.element}});function ap(t,r){return new ad({type:"array",element:t,...ew(r)})}let am=eV("ZodObject",(t,r)=>{var i;let n,a;nj(),rE.init(t,r),nA.init(t,r),t._zod.processJSONSchema=(r,i,n)=>iY(t,r,i,n),i="shape",(a=i in(n=Object.getPrototypeOf(t))?void 0:n)&&Object.defineProperty(a,i,{configurable:!0,get(){let t={configurable:!0,writable:!0,enumerable:!1,value:void 0};return Object.defineProperty(this,i,t),t.value=(t=>t._zod.def.shape)(this),Object.defineProperty(this,i,t),t.value},set(t){Object.defineProperty(this,i,{configurable:!0,writable:!0,enumerable:!1,value:t})}})},{keyof(){return ax(Object.keys(this._zod.def.shape))},catchall(t){return this.clone(em(this._zod.def,{catchall:t}))},passthrough(){return this.clone(em(this._zod.def,{catchall:ac()}))},loose(){return this.clone(em(this._zod.def,{catchall:ac()}))},strict(){return this.clone(em(this._zod.def,{catchall:new au({type:"never",...ew(void 0)})}))},strip(){return this.clone(em(this._zod.def,{catchall:void 0}))},extend(t){if(!ey(t))throw Error("Invalid input to extend: expected a plain object");let r=this._zod.def.checks;if(r&&r.length>0){let r=ec(this);for(let i of Reflect.ownKeys(t))if(void 0!==Object.getOwnPropertyDescriptor(r,i))throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return eS(this,em(this._zod.def,{shape:eT(this,t)}))},safeExtend(t){if(!ey(t))throw Error("Invalid input to safeExtend: expected a plain object");return eS(this,em(this._zod.def,{shape:eT(this,t)}))},merge(t){if(!t?._zod?.def)throw Error("Invalid input to merge: expected an object schema. To merge a plain shape, use `.extend()`.");if(this._zod.def.checks?.length)throw Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");let r={};return ep(r,this,Reflect.ownKeys(ec(this))),ep(r,t,Reflect.ownKeys(ec(t))),eS(this,em(this._zod.def,{shape:r,get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]}))},pick(t){return function(t,r){let i=t._zod.def,n=i.checks;if(n&&n.length>0)throw Error(".pick() cannot be used on object schemas containing refinements");let a={};return ep(a,t,e$(t,r)),eS(t,em(i,{shape:a,checks:[]}))}(this,t)},omit(t){return function(t,r){let i=t._zod.def,n=i.checks;if(n&&n.length>0)throw Error(".omit() cannot be used on object schemas containing refinements");let a=new Set(e$(t,r)),o={};return ep(o,t,Reflect.ownKeys(ec(t)).filter(t=>!a.has(t))),eS(t,em(i,{shape:o,checks:[]}))}(this,t)},partial(...t){return eC(aP,this,t[0])},exactPartial(...t){return eC(aI,this,t[0],"exactPartial")},required(...t){var r;let i,n;return i=(r=t[0])?new Set(e$(this,r)):void 0,ep(n={},this,Reflect.ownKeys(ec(this)),(t,r)=>i&&!i.has(r)?t:new aN({type:"nonoptional",innerType:t})),eS(this,em(this._zod.def,{shape:n}))}});function ah(t,r){return new am({type:"object",shape:t??{},...ew(r)})}function af(t,r){return new am({type:"object",shape:t,catchall:ac(),...ew(r)})}let ag=eV("ZodUnion",(t,r)=>{rO.init(t,r),nA.init(t,r),t._zod.processJSONSchema=(r,i,n)=>iX(t,r,i,n),t.options=r.options});function ay(t,r){return new ag({type:"union",options:t,...ew(r)})}let av=eV("ZodDiscriminatedUnion",(t,r)=>{ag.init(t,r),rI.init(t,r)});function a_(t,r,i){return new av({type:"union",options:r,discriminator:t,...ew(i)})}let ab=eV("ZodIntersection",(t,r)=>{rq.init(t,r),nA.init(t,r),t._zod.processJSONSchema=(r,i,n)=>iQ(t,r,i,n)});function aS(t,r){return new ab({type:"intersection",left:t,right:r})}let aw=eV("ZodRecord",(t,r)=>{nj(),rA.init(t,r),nA.init(t,r),t._zod.processJSONSchema=(r,i,n)=>i1(t,r,i,n),t.keyType=r.keyType,t.valueType=r.valueType});function aR(t,r,i){return new aw(r&&r._zod?{type:"record",keyType:t,valueType:r,...ew(i)}:{type:"record",keyType:nM(),valueType:t,...ew(r)})}let ak=eV("ZodEnum",(t,r)=>{rz.init(t,r),nA.init(t,r),t._zod.processJSONSchema=(r,i,n)=>iJ(t,r,i,n),t.enum=r.entries,t.options=[...t._zod.values];let i=new Set(Object.keys(r.entries));t.extract=(t,n)=>{let a={};for(let n of t)if(i.has(n))a[n]=r.entries[n];else throw Error(`Key ${n} not found in enum`);return new ak({...r,checks:[],...ew(n),entries:a})},t.exclude=(t,n)=>{let a={...r.entries};for(let r of t)if(i.has(r))delete a[r];else throw Error(`Key ${r} not found in enum`);return new ak({...r,checks:[],...ew(n),entries:a})}});function ax(t,r){return new ak({type:"enum",entries:Array.isArray(t)?Object.fromEntries(t.map(t=>[t,t])):t,...ew(r)})}let a$=eV("ZodLiteral",(t,r)=>{rN.init(t,r),nA.init(t,r),t._zod.processJSONSchema=(r,i,n)=>iV(t,r,i,n),t.values=new Set(r.values),Object.defineProperty(t,"value",{get(){if(r.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return r.values[0]}})});function aT(t,r){return new a$({type:"literal",values:Array.isArray(t)?t:[t],...ew(r)})}let aC=eV("ZodTransform",(t,r)=>{nj(),rM.init(t,r),nA.init(t,r),t._zod.processJSONSchema=(r,i,n)=>iW(t,r,i,n),t._zod.parse=(i,n)=>{if("backward"===n.direction)throw new eW(t.constructor.name);i.addIssue=n=>{"string"==typeof n?i.issues.push(eN(n,i.value,r)):(n.fatal&&(n.continue=!1),n.code??(n.code="custom"),"input"in n||(n.input=i.value),n.inst??(n.inst=t),i.issues.push(eN(n)))};let a=r.transform(i.value,i);return a instanceof Promise?a.then(t=>(i.value=t,i)):(i.value=a,i)}});function aE(t){return new aC({type:"transform",transform:t})}let aP=eV("ZodOptional",(t,r)=>{rZ.init(t,r),nA.init(t,r),t._zod.processJSONSchema=(r,i,n)=>nt(t,r,i,n),t.unwrap=()=>t._zod.def.innerType});function aO(t){return new aP({type:"optional",innerType:t})}let aI=eV("ZodExactOptional",(t,r)=>{rU.init(t,r),nA.init(t,r),t._zod.processJSONSchema=(r,i,n)=>nt(t,r,i,n),t.unwrap=()=>t._zod.def.innerType}),aq=eV("ZodNullable",(t,r)=>{rF.init(t,r),nA.init(t,r),t._zod.processJSONSchema=(r,i,n)=>i2(t,r,i,n),t.unwrap=()=>t._zod.def.innerType});function aj(t){return new aq({type:"nullable",innerType:t})}let aA=eV("ZodDefault",(t,r)=>{rD.init(t,r),nA.init(t,r),t._zod.processJSONSchema=(r,i,n)=>i6(t,r,i,n),t.unwrap=()=>t._zod.def.innerType,t.removeDefault=t.unwrap}),az=eV("ZodPrefault",(t,r)=>{rJ.init(t,r),nA.init(t,r),t._zod.processJSONSchema=(r,i,n)=>i5(t,r,i,n),t.unwrap=()=>t._zod.def.innerType}),aN=eV("ZodNonOptional",(t,r)=>{rV.init(t,r),nA.init(t,r),t._zod.processJSONSchema=(r,i,n)=>i9(t,r,i,n),t.unwrap=()=>t._zod.def.innerType}),aM=eV("ZodCatch",(t,r)=>{rG.init(t,r),nA.init(t,r),t._zod.processJSONSchema=(r,i,n)=>i7(t,r,i,n),t.unwrap=()=>t._zod.def.innerType,t.removeCatch=t.unwrap}),aL=eV("ZodPipe",(t,r)=>{rK.init(t,r),nA.init(t,r),t._zod.processJSONSchema=(r,i,n)=>i8(t,r,i,n),t.in=r.in,t.out=r.out});function aZ(t,r){return new aL({type:"pipe",in:t,out:r})}let aU=eV("ZodPreprocess",(t,r)=>{aL.init(t,r),rX.init(t,r)}),aF=eV("ZodReadonly",(t,r)=>{rQ.init(t,r),nA.init(t,r),t._zod.processJSONSchema=(r,i,n)=>ne(t,r,i,n),t.unwrap=()=>t._zod.def.innerType}),aD=eV("ZodLazy",(t,r)=>{r1.init(t,r),nA.init(t,r),t._zod.processJSONSchema=(r,i,n)=>nr(t,r,i,n),t.unwrap=()=>t._zod.def.getter()});function aH(t){return new aD({type:"lazy",getter:t})}let aJ=eV("ZodCustom",(t,r)=>{r2.init(t,r),nA.init(t,r),t._zod.processJSONSchema=(r,i,n)=>iB(t,r,i,n)});function aV(t,r){return new aU({type:"pipe",in:aE(t),out:r})}A||(A={});let aB="2025-11-25",aW=[aB,"2025-06-18","2025-03-26","2024-11-05","2024-10-07"],aG="io.modelcontextprotocol/protocolVersion",aK="io.modelcontextprotocol/clientInfo",aY="io.modelcontextprotocol/serverInfo",aX="io.modelcontextprotocol/clientCapabilities",aQ="io.modelcontextprotocol/subscriptionId",a0="io.modelcontextprotocol/logLevel",a1=aH(()=>ay([nM(),ae(),an(),ao(),aR(nM(),a1),ap(a1)])),a2=aR(nM(),a1),a9=ap(a1),a4=ay([nM(),ae().int()]),a3=nM(),a6=ah({ttl:ae().optional()}),a5=ah({taskId:nM()}),a7=af({progressToken:a4.optional(),"io.modelcontextprotocol/related-task":a5.optional()}),a8=ah({_meta:a7.optional()}),oe=a8.extend({task:a6.optional()}),ot=ah({method:nM(),params:a8.loose().optional()}),or=ah({_meta:a7.optional()}),oi=ah({method:nM(),params:or.loose().optional()}),on=af({get[aY](){return o_.optional().catch(void 0)}}),oa=af({_meta:on.optional()}),oo=ay([nM(),ae().int()]),os=ah({jsonrpc:aT("2.0"),id:oo,...ot.shape}).strict(),ol=ah({jsonrpc:aT("2.0"),...oi.shape}).strict(),oc=ah({jsonrpc:aT("2.0"),id:oo,result:oa}).strict(),ou=ah({jsonrpc:aT("2.0"),id:oo.optional(),error:ah({code:ae().int(),message:nM(),data:ac().optional()})}).strict(),od=ay([os,ol,oc,ou]),op=ay([oc,ou]),om=oa.strict(),oh=or.extend({requestId:oo.optional(),reason:nM().optional()}),of=oi.extend({method:aT("notifications/cancelled"),params:oh}),og=ah({src:nM(),mimeType:nM().optional(),sizes:ap(nM()).optional(),theme:ax(["light","dark"]).optional()}),oy=ah({icons:ap(og).optional()}),ov=ah({name:nM(),title:nM().optional()}),o_=ov.extend({...ov.shape,...oy.shape,version:nM(),websiteUrl:nM().optional(),description:nM().optional()}),ob=aS(ah({applyDefaults:an().optional()}),a2),oS=aV(t=>t&&"object"==typeof t&&!Array.isArray(t)&&0===Object.keys(t).length?{form:{}}:t,aS(ah({form:ob.optional(),url:a2.optional()}),a2.optional())),ow=af({list:a2.optional(),cancel:a2.optional(),requests:af({sampling:af({createMessage:a2.optional()}).optional(),elicitation:af({create:a2.optional()}).optional()}).optional()}),oR=af({list:a2.optional(),cancel:a2.optional(),requests:af({tools:af({call:a2.optional()}).optional()}).optional()}),ok=ah({experimental:aR(nM(),a2).optional(),sampling:ah({context:a2.optional(),tools:a2.optional()}).optional(),elicitation:oS.optional(),roots:ah({listChanged:an().optional()}).optional(),tasks:ow.optional(),extensions:aR(nM(),a2).optional()}),ox=a8.extend({protocolVersion:nM(),capabilities:ok,clientInfo:o_}),o$=ot.extend({method:aT("initialize"),params:ox}),oT=ah({experimental:aR(nM(),a2).optional(),logging:a2.optional(),completions:a2.optional(),prompts:ah({listChanged:an().optional()}).optional(),resources:ah({subscribe:an().optional(),listChanged:an().optional()}).optional(),tools:ah({listChanged:an().optional()}).optional(),tasks:oR.optional(),extensions:aR(nM(),a2).optional()}),oC=oa.extend({protocolVersion:nM(),capabilities:oT,serverInfo:o_,instructions:nM().optional()}),oE=oi.extend({method:aT("notifications/initialized"),params:or.optional()}),oP=ot.extend({method:aT("server/discover"),params:a8.optional()}),oO=oa.extend({supportedVersions:ap(nM()),capabilities:oT,instructions:nM().optional()}),oI=ot.extend({method:aT("ping"),params:a8.optional()}),oq=ah({progress:ae(),total:aO(ae()),message:aO(nM())}),oj=ah({...or.shape,...oq.shape,progressToken:a4}),oA=oi.extend({method:aT("notifications/progress"),params:oj}),oz=a8.extend({cursor:a3.optional()}),oN=ot.extend({params:oz.optional()}),oM=oa.extend({nextCursor:a3.optional()}),oL=ah({uri:nM(),mimeType:aO(nM()),_meta:aR(nM(),ac()).optional()}),oZ=oL.extend({text:nM()}),oU=nM().refine(t=>{try{return atob(t),!0}catch{return!1}},{message:"Invalid Base64 string"}),oF=oL.extend({blob:oU}),oD=ax(["user","assistant"]),oH=ah({audience:ap(oD).optional(),priority:ae().min(0).max(1).optional(),lastModified:r7(nZ,{offset:!0}).optional()}),oJ=ah({...ov.shape,...oy.shape,uri:nM(),description:aO(nM()),mimeType:aO(nM()),size:aO(ae()),annotations:oH.optional(),_meta:aO(af({}))}),oV=ah({...ov.shape,...oy.shape,uriTemplate:nM(),description:aO(nM()),mimeType:aO(nM()),annotations:oH.optional(),_meta:aO(af({}))}),oB=oN.extend({method:aT("resources/list")}),oW=oM.extend({resources:ap(oJ)}),oG=oN.extend({method:aT("resources/templates/list")}),oK=oM.extend({resourceTemplates:ap(oV)}),oY=a8.extend({uri:nM()}),oX=ot.extend({method:aT("resources/read"),params:oY}),oQ=oa.extend({contents:ap(ay([oZ,oF]))}),o0=oi.extend({method:aT("notifications/resources/list_changed"),params:or.optional()}),o1=ot.extend({method:aT("resources/subscribe"),params:oY}),o2=ot.extend({method:aT("resources/unsubscribe"),params:oY}),o9=ah({toolsListChanged:an().optional(),promptsListChanged:an().optional(),resourcesListChanged:an().optional(),resourceSubscriptions:ap(nM()).optional()}),o4=a8.extend({notifications:o9}),o3=ot.extend({method:aT("subscriptions/listen"),params:o4}),o6=or.extend({notifications:o9}),o5=oi.extend({method:aT("notifications/subscriptions/acknowledged"),params:o6}),o7=on.extend({[aQ]:oo}),o8=oa.extend({_meta:o7}),se=or.extend({uri:nM()}),st=oi.extend({method:aT("notifications/resources/updated"),params:se}),sr=ah({name:nM(),description:aO(nM()),required:aO(an())}),si=ah({...ov.shape,...oy.shape,description:aO(nM()),arguments:aO(ap(sr)),_meta:aO(af({}))}),sn=oN.extend({method:aT("prompts/list")}),sa=oM.extend({prompts:ap(si)}),so=a8.extend({name:nM(),arguments:aR(nM(),nM()).optional()}),ss=ot.extend({method:aT("prompts/get"),params:so}),sl=ah({type:aT("text"),text:nM(),annotations:oH.optional(),_meta:aR(nM(),ac()).optional()}),sc=ah({type:aT("image"),data:oU,mimeType:nM(),annotations:oH.optional(),_meta:aR(nM(),ac()).optional()}),su=ah({type:aT("audio"),data:oU,mimeType:nM(),annotations:oH.optional(),_meta:aR(nM(),ac()).optional()}),sd=ah({type:aT("tool_use"),name:nM(),id:nM(),input:aR(nM(),ac()),_meta:aR(nM(),ac()).optional()}),sp=ah({type:aT("resource"),resource:ay([oZ,oF]),annotations:oH.optional(),_meta:aR(nM(),ac()).optional()}),sm=oJ.extend({type:aT("resource_link")}),sh=ay([sl,sc,su,sm,sp]),sf=ah({role:oD,content:sh}),sg=oa.extend({description:nM().optional(),messages:ap(sf)}),sy=oi.extend({method:aT("notifications/prompts/list_changed"),params:or.optional()}),sv=ah({title:nM().optional(),readOnlyHint:an().optional(),destructiveHint:an().optional(),idempotentHint:an().optional(),openWorldHint:an().optional()}),s_=ah({taskSupport:ax(["required","optional","forbidden"]).optional()}),sb=ah({...ov.shape,...oy.shape,description:nM().optional(),inputSchema:ah({type:aT("object"),properties:aR(nM(),a1).optional(),required:ap(nM()).optional()}).catchall(ac()),outputSchema:af({$schema:nM().optional()}).optional(),annotations:sv.optional(),execution:s_.optional(),_meta:aR(nM(),ac()).optional()}),sS=oN.extend({method:aT("tools/list")}),sw=oM.extend({tools:ap(sb)}),sR=oa.extend({content:ap(sh).default([]),structuredContent:ac().optional(),isError:an().optional()}),sk=sR.or(oa.extend({toolResult:ac()})),sx=oe.extend({name:nM(),arguments:aR(nM(),ac()).optional()}),s$=ot.extend({method:aT("tools/call"),params:sx}),sT=oi.extend({method:aT("notifications/tools/list_changed"),params:or.optional()}),sC=ah({autoRefresh:an().default(!0),debounceMs:ae().int().nonnegative().default(300)}),sE=ax(["debug","info","notice","warning","error","critical","alert","emergency"]),sP=a8.extend({level:sE}),sO=ot.extend({method:aT("logging/setLevel"),params:sP}),sI=or.extend({level:sE,logger:nM().optional(),data:ac()}),sq=oi.extend({method:aT("notifications/message"),params:sI}),sj=ah({name:nM().optional()}),sA=ah({hints:ap(sj).optional(),costPriority:ae().min(0).max(1).optional(),speedPriority:ae().min(0).max(1).optional(),intelligencePriority:ae().min(0).max(1).optional()}),sz=ah({mode:ax(["auto","required","none"]).optional()}),sN=ah({type:aT("tool_result"),toolUseId:nM().describe("The unique identifier for the corresponding tool call."),content:ap(sh),structuredContent:ac().optional(),isError:an().optional(),_meta:aR(nM(),ac()).optional()}),sM=a_("type",[sl,sc,su]),sL=a_("type",[sl,sc,su,sd,sN]),sZ=ah({role:oD,content:ay([sL,ap(sL)]),_meta:aR(nM(),ac()).optional()}),sU=oe.extend({messages:ap(sZ),modelPreferences:sA.optional(),systemPrompt:nM().optional(),includeContext:ax(["none","thisServer","allServers"]).optional(),temperature:ae().optional(),maxTokens:ae().int(),stopSequences:ap(nM()).optional(),metadata:a2.optional(),tools:ap(sb).optional(),toolChoice:sz.optional()}),sF=ot.extend({method:aT("sampling/createMessage"),params:sU}),sD=oa.extend({model:nM(),stopReason:aO(ax(["endTurn","stopSequence","maxTokens"]).or(nM())),role:oD,content:sM}),sH=oa.extend({model:nM(),stopReason:aO(ax(["endTurn","stopSequence","maxTokens","toolUse"]).or(nM())),role:oD,content:ay([sL,ap(sL)])}),sJ=ah({type:aT("boolean"),title:nM().optional(),description:nM().optional(),default:an().optional()}),sV=ah({type:aT("string"),title:nM().optional(),description:nM().optional(),minLength:ae().optional(),maxLength:ae().optional(),format:ax(["email","uri","date","date-time"]).optional(),default:nM().optional()}),sB=ah({type:ax(["number","integer"]),title:nM().optional(),description:nM().optional(),minimum:ae().optional(),maximum:ae().optional(),default:ae().optional()}),sW=ah({type:aT("string"),title:nM().optional(),description:nM().optional(),enum:ap(nM()),default:nM().optional()}),sG=ah({type:aT("string"),title:nM().optional(),description:nM().optional(),oneOf:ap(ah({const:nM(),title:nM()})),default:nM().optional()}),sK=ah({type:aT("string"),title:nM().optional(),description:nM().optional(),enum:ap(nM()),enumNames:ap(nM()).optional(),default:nM().optional()}),sY=ay([sW,sG]),sX=ah({type:aT("array"),title:nM().optional(),description:nM().optional(),minItems:ae().optional(),maxItems:ae().optional(),items:ah({type:aT("string"),enum:ap(nM())}),default:ap(nM()).optional()}),sQ=ah({type:aT("array"),title:nM().optional(),description:nM().optional(),minItems:ae().optional(),maxItems:ae().optional(),items:ah({anyOf:ap(ah({const:nM(),title:nM()}))}),default:ap(nM()).optional()}),s0=ay([sX,sQ]),s1=ay([sK,sY,s0]),s2=ay([s1,sJ,sV,sB]),s9=oe.extend({mode:aT("form").optional(),message:nM(),requestedSchema:ah({type:aT("object"),properties:aR(nM(),s2),required:ap(nM()).optional()}).catchall(ac())}),s4=oe.extend({mode:aT("url"),message:nM(),elicitationId:nM(),url:nM().url()}),s3=ay([s9,s4]),s6=ot.extend({method:aT("elicitation/create"),params:s3}),s5=or.extend({elicitationId:nM()}),s7=oi.extend({method:aT("notifications/elicitation/complete"),params:s5}),s8=oa.extend({action:ax(["accept","decline","cancel"]),content:aV(t=>null===t?void 0:t,aR(nM(),ay([nM(),ae(),an(),ap(nM())])).optional())}),le=ah({type:aT("ref/resource"),uri:nM()}),lt=ah({type:aT("ref/prompt"),name:nM()}),lr=a8.extend({ref:ay([lt,le]),argument:ah({name:nM(),value:nM()}),context:ah({arguments:aR(nM(),nM()).optional()}).optional()}),li=ot.extend({method:aT("completion/complete"),params:lr}),ln=oa.extend({completion:af({values:ap(nM()).max(100),total:aO(ae().int()),hasMore:aO(an())})}),la=ah({uri:nM().startsWith("file://"),name:nM().optional(),_meta:aR(nM(),ac()).optional()}),lo=ot.extend({method:aT("roots/list"),params:a8.optional()}),ls=oa.extend({roots:ap(la)}),ll=oi.extend({method:aT("notifications/roots/list_changed"),params:or.optional()}),lc=af({ttl:ae().optional(),pollInterval:ae().optional()}),lu=ax(["working","input_required","completed","failed","cancelled"]),ld=ah({taskId:nM(),status:lu,ttl:ay([ae(),ao()]),createdAt:nM(),lastUpdatedAt:nM(),pollInterval:aO(ae()),statusMessage:aO(nM())}),lp=oa.extend({task:ld}),lm=or.merge(ld),lh=oi.extend({method:aT("notifications/tasks/status"),params:lm}),lf=ot.extend({method:aT("tasks/get"),params:a8.extend({taskId:nM()})}),lg=oa.merge(ld),ly=ot.extend({method:aT("tasks/result"),params:a8.extend({taskId:nM()})}),lv=oa.loose(),l_=oN.extend({method:aT("tasks/list")}),lb=oM.extend({tasks:ap(ld)}),lS=ot.extend({method:aT("tasks/cancel"),params:a8.extend({taskId:nM()})}),lw=oa.merge(ld),lR=ay([oI,o$,oP,li,sO,ss,sn,oB,oG,oX,o1,o2,o3,s$,sS]),lk=ay([of,oA,oE,ll]),lx=ay([om,sD,sH,s8,ls]),l$=ay([oI,sF,s6,lo]),lT=ay([of,oA,sq,st,o0,sT,sy,o5,s7]),lC=ay([om,oC,oO,ln,sg,sa,oW,oK,oQ,sR,sw,o8]),lE=r5(nB,void 0).superRefine((t,r)=>{if(!URL.canParse(t))return r.addIssue({code:"custom",message:"URL must be parseable",fatal:!0}),eD}).refine(t=>{let r=new URL(t);return"javascript:"!==r.protocol&&"data:"!==r.protocol&&"vbscript:"!==r.protocol},{message:"URL cannot use javascript:, data:, or vbscript: scheme"}),lP=af({resource:nM().url(),authorization_servers:ap(lE).optional(),jwks_uri:nM().url().optional(),scopes_supported:ap(nM()).optional(),bearer_methods_supported:ap(nM()).optional(),resource_signing_alg_values_supported:ap(nM()).optional(),resource_name:nM().optional(),resource_documentation:nM().optional(),resource_policy_uri:nM().url().optional(),resource_tos_uri:nM().url().optional(),tls_client_certificate_bound_access_tokens:an().optional(),authorization_details_types_supported:ap(nM()).optional(),dpop_signing_alg_values_supported:ap(nM()).optional(),dpop_bound_access_tokens_required:an().optional()}),lO=af({issuer:nM(),authorization_endpoint:lE,token_endpoint:lE,registration_endpoint:lE.optional(),scopes_supported:ap(nM()).optional(),response_types_supported:ap(nM()),response_modes_supported:ap(nM()).optional(),grant_types_supported:ap(nM()).optional(),token_endpoint_auth_methods_supported:ap(nM()).optional(),token_endpoint_auth_signing_alg_values_supported:ap(nM()).optional(),service_documentation:lE.optional(),revocation_endpoint:lE.optional(),revocation_endpoint_auth_methods_supported:ap(nM()).optional(),revocation_endpoint_auth_signing_alg_values_supported:ap(nM()).optional(),introspection_endpoint:nM().optional(),introspection_endpoint_auth_methods_supported:ap(nM()).optional(),introspection_endpoint_auth_signing_alg_values_supported:ap(nM()).optional(),code_challenge_methods_supported:ap(nM()).optional(),client_id_metadata_document_supported:an().optional(),authorization_response_iss_parameter_supported:an().optional().catch(void 0),dpop_signing_alg_values_supported:ap(nM()).optional()}),lI=af({issuer:nM(),authorization_endpoint:lE,token_endpoint:lE,userinfo_endpoint:lE.optional(),jwks_uri:lE,registration_endpoint:lE.optional(),scopes_supported:ap(nM()).optional(),response_types_supported:ap(nM()),response_modes_supported:ap(nM()).optional(),grant_types_supported:ap(nM()).optional(),acr_values_supported:ap(nM()).optional(),subject_types_supported:ap(nM()),id_token_signing_alg_values_supported:ap(nM()),id_token_encryption_alg_values_supported:ap(nM()).optional(),id_token_encryption_enc_values_supported:ap(nM()).optional(),userinfo_signing_alg_values_supported:ap(nM()).optional(),userinfo_encryption_alg_values_supported:ap(nM()).optional(),userinfo_encryption_enc_values_supported:ap(nM()).optional(),request_object_signing_alg_values_supported:ap(nM()).optional(),request_object_encryption_alg_values_supported:ap(nM()).optional(),request_object_encryption_enc_values_supported:ap(nM()).optional(),token_endpoint_auth_methods_supported:ap(nM()).optional(),token_endpoint_auth_signing_alg_values_supported:ap(nM()).optional(),display_values_supported:ap(nM()).optional(),claim_types_supported:ap(nM()).optional(),claims_supported:ap(nM()).optional(),service_documentation:nM().optional(),claims_locales_supported:ap(nM()).optional(),ui_locales_supported:ap(nM()).optional(),claims_parameter_supported:an().optional(),request_parameter_supported:an().optional(),request_uri_parameter_supported:an().optional(),require_request_uri_registration:an().optional(),op_policy_uri:lE.optional(),op_tos_uri:lE.optional(),client_id_metadata_document_supported:an().optional(),authorization_response_iss_parameter_supported:an().optional().catch(void 0)}),lq=ah({...lI.shape,...lO.pick({code_challenge_methods_supported:!0}).shape}),lj=ah({access_token:nM(),id_token:nM().optional(),token_type:nM(),expires_in:new n8(r3({type:"number",coerce:!0,checks:[],...ew(void 0)})).optional(),scope:nM().optional(),refresh_token:nM().optional(),issuer:nM().optional().catch(void 0)}).strip(),lA=ah({issued_token_type:aT("urn:ietf:params:oauth:token-type:id-jag"),access_token:nM(),token_type:nM().optional(),expires_in:ae().optional(),scope:nM().optional()}).strip(),lz=ah({error:nM(),error_description:nM().optional(),error_uri:nM().optional()}),lN=lE.optional().or(aT("").transform(()=>void 0)),lM=ah({redirect_uris:ap(lE),token_endpoint_auth_method:nM().optional(),grant_types:ap(nM()).optional(),response_types:ap(nM()).optional(),application_type:nM().optional(),client_name:nM().optional(),client_uri:lE.optional(),logo_uri:lN,scope:nM().optional(),contacts:ap(nM()).optional(),tos_uri:lN,policy_uri:nM().optional(),jwks_uri:lE.optional(),jwks:new as({type:"any"}).optional(),software_id:nM().optional(),software_version:nM().optional(),software_statement:nM().optional()}).strip(),lL=ah({client_id:nM(),client_secret:nM().optional(),client_id_issued_at:ae().optional(),client_secret_expires_at:ae().optional(),issuer:nM().optional().catch(void 0)}).strip(),lZ=lM.merge(lL),lU=ah({error:nM(),error_description:nM().optional()}).strip(),lF=ah({token:nM(),token_type_hint:nM().optional()}).strip(),lD=Symbol.for("mcp.sdk.errorBrands");function lH(t,r){let i=new Set,n=r;for(;"function"==typeof n;){let t=n.mcpBrand;Object.prototype.hasOwnProperty.call(n,"mcpBrand")&&"string"==typeof t&&i.add(t),n=Object.getPrototypeOf(n)}0!==i.size&&Object.defineProperty(t,lD,{value:i,enumerable:!1,configurable:!0})}function lJ(t,r){try{if("object"==typeof r&&null!==r&&Object.prototype.hasOwnProperty.call(t,"mcpBrand")&&"string"==typeof t.mcpBrand&&Object.prototype.hasOwnProperty.call(r,lD)){let i=r[lD];if(i&&"function"==typeof i.has&&i.has(t.mcpBrand))return!0}}catch{}return Function.prototype[Symbol.hasInstance].call(t,r)}let lV=(($={}).InvalidRequest="invalid_request",$.InvalidClient="invalid_client",$.InvalidGrant="invalid_grant",$.UnauthorizedClient="unauthorized_client",$.UnsupportedGrantType="unsupported_grant_type",$.InvalidScope="invalid_scope",$.AccessDenied="access_denied",$.ServerError="server_error",$.TemporarilyUnavailable="temporarily_unavailable",$.UnsupportedResponseType="unsupported_response_type",$.UnsupportedTokenType="unsupported_token_type",$.InvalidToken="invalid_token",$.MethodNotAllowed="method_not_allowed",$.TooManyRequests="too_many_requests",$.InvalidClientMetadata="invalid_client_metadata",$.InvalidRedirectUri="invalid_redirect_uri",$.InsufficientScope="insufficient_scope",$.InvalidTarget="invalid_target",$.InvalidDpopProof="invalid_dpop_proof",$.UseDpopNonce="use_dpop_nonce",$);var lB=class t extends Error{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.OAuthError"})}static[Symbol.hasInstance](t){return lJ(this,t)}static isInstance(t){if("function"!=typeof this)throw TypeError("isInstance must be called on the class (e.g. `SdkError.isInstance(value)`); for callbacks use `v => SdkError.isInstance(v)`");return lJ(this,t)}constructor(t,r,i){super(r),this.code=t,this.errorUri=i,this.name="OAuthError",lH(this,new.target)}toResponseObject(){let t={error:this.code,error_description:this.message};return this.errorUri&&(t.error_uri=this.errorUri),t}static fromResponse(r){return new t(r.error,r.error_description??r.error,r.error_uri)}};let lW=((T={}).NotConnected="NOT_CONNECTED",T.AlreadyConnected="ALREADY_CONNECTED",T.NotInitialized="NOT_INITIALIZED",T.CapabilityNotSupported="CAPABILITY_NOT_SUPPORTED",T.RequestTimeout="REQUEST_TIMEOUT",T.ConnectionClosed="CONNECTION_CLOSED",T.SendFailed="SEND_FAILED",T.InvalidResult="INVALID_RESULT",T.UnsupportedResultType="UNSUPPORTED_RESULT_TYPE",T.InputRequiredRoundsExceeded="INPUT_REQUIRED_ROUNDS_EXCEEDED",T.ListPaginationExceeded="LIST_PAGINATION_EXCEEDED",T.MethodNotSupportedByProtocolVersion="METHOD_NOT_SUPPORTED_BY_PROTOCOL_VERSION",T.EraNegotiationFailed="ERA_NEGOTIATION_FAILED",T.ClientHttpNotImplemented="CLIENT_HTTP_NOT_IMPLEMENTED",T.ClientHttpAuthentication="CLIENT_HTTP_AUTHENTICATION",T.ClientHttpForbidden="CLIENT_HTTP_FORBIDDEN",T.ClientHttpUnexpectedContent="CLIENT_HTTP_UNEXPECTED_CONTENT",T.ClientHttpFailedToOpenStream="CLIENT_HTTP_FAILED_TO_OPEN_STREAM",T.ClientHttpFailedToTerminateSession="CLIENT_HTTP_FAILED_TO_TERMINATE_SESSION",T);var lG=class extends Error{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.SdkError"})}static[Symbol.hasInstance](t){return lJ(this,t)}static isInstance(t){if("function"!=typeof this)throw TypeError("isInstance must be called on the class (e.g. `SdkError.isInstance(value)`); for callbacks use `v => SdkError.isInstance(v)`");return lJ(this,t)}constructor(t,r,i,n){super(r,n),this.code=t,this.data=i,this.name="SdkError",lH(this,new.target)}};(class extends lG{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.SdkHttpError"})}constructor(t,r,i,n){super(t,r,i,n),this.name="SdkHttpError"}get status(){return this.data.status}get statusText(){return this.data.statusText}});let lK={};function lY(t){return null!==t&&"object"==typeof t&&!Array.isArray(t)}function lX(t,r){let i={};for(let[n,a]of Object.entries(t)){if(void 0===a)continue;let t=void 0===r?void 0:r[n];if(void 0===t){i[n]=a;continue}if(lY(a)&&lY(t)){let r={};for(let[i,o]of Object.entries(a))void 0!==o&&void 0===t[i]&&("elicitation"!==n||"form"!==i||void 0!==t.form||void 0!==t.url)&&(r[i]=o);Object.keys(r).length>0&&(i[n]=r)}}return Object.keys(i).length>0?i:void 0}let lQ="2026-07-28",l0=[lQ];function l1(t){return t.filter(t=>t>=lQ)}function l2(t){let r=t.structuredContent;return void 0===r||!("object"!=typeof r||null===r||Array.isArray(r))||t.content?.some(t=>"text"===t.type)?t:{...t,content:[...t.content??[],{type:"text",text:JSON.stringify(r)}]}}let l9=["task","inputRequests","requestState"];function l4(t){return null===t||"object"!=typeof t||Array.isArray(t)||void 0!==t.content||l9.some(r=>r in t)?t:{...t,content:[]}}function l3(){let t,r,n,a,o,s,l,c,u,d,p,m,h,f,g,y,v,_,b,S,w,R,k,x,$,T,C,E,P,O,I,q,j,A,z,N,M,L,Z,U,F,D,H,J,V,B,W,G,K,Y,X,Q,ee,et,er,ei,en,ea,eo,es,el,ec,eu,ed,ep,em,eh,ef,eg,ey,ev,e_,eb,eS,ew,eR,ek,ex,e$,eT,eC,eE,eP,eO,eI,eq,ej,eA,ez,eN,eM,eL,eZ,eU,eF,eD,eH,eJ,eV,eB,eW,eG,eK,eY,eX,eQ,e0,e1,e2,e9,e4,e3,e6,e5,e7,e8,te,tt,tr,ti,tn,ta,to,ts,tl,tc,tu,td,tp,tm,th,tf,tg,ty,tv,t_,tb,tS,tw,tR;return i??=(t=aH(()=>ay([nM(),ae(),an(),ao(),aR(nM(),t),ap(t)])),r=aR(nM(),t),n=ay([nM(),ae().int()]),a=nM(),o=ah({ttl:ae().optional()}),s=ah({taskId:nM()}),u=(c=ah({_meta:(l=af({progressToken:n.optional(),"io.modelcontextprotocol/related-task":s.optional()})).optional()})).extend({task:o.optional()}),d=ah({method:nM(),params:c.loose().optional()}),p=ah({_meta:l.optional()}),m=ah({method:nM(),params:p.loose().optional()}),h=af({_meta:l.optional()}),f=ay([nM(),ae().int()]),g=h.strict(),y=p.extend({requestId:f.optional(),reason:nM().optional()}),v=m.extend({method:aT("notifications/cancelled"),params:y}),_=ah({src:nM(),mimeType:nM().optional(),sizes:ap(nM()).optional(),theme:ax(["light","dark"]).optional()}),b=ah({icons:ap(_).optional()}),w=(S=ah({name:nM(),title:nM().optional()})).extend({...S.shape,...b.shape,version:nM(),websiteUrl:nM().optional(),description:nM().optional()}),R=aS(ah({applyDefaults:an().optional()}),r),k=aV(t=>t&&"object"==typeof t&&!Array.isArray(t)&&0===Object.keys(t).length?{form:{}}:t,aS(ah({form:R.optional(),url:r.optional()}),r.optional())),x=af({list:r.optional(),cancel:r.optional(),requests:af({sampling:af({createMessage:r.optional()}).optional(),elicitation:af({create:r.optional()}).optional()}).optional()}),$=af({list:r.optional(),cancel:r.optional(),requests:af({tools:af({call:r.optional()}).optional()}).optional()}),T=ah({experimental:aR(nM(),r).optional(),sampling:ah({context:r.optional(),tools:r.optional()}).optional(),elicitation:k.optional(),roots:ah({listChanged:an().optional()}).optional(),tasks:x.optional(),extensions:aR(nM(),r).optional()}),C=c.extend({protocolVersion:nM(),capabilities:T,clientInfo:w}),E=d.extend({method:aT("initialize"),params:C}),P=ah({experimental:aR(nM(),r).optional(),logging:r.optional(),completions:r.optional(),prompts:ah({listChanged:an().optional()}).optional(),resources:ah({subscribe:an().optional(),listChanged:an().optional()}).optional(),tools:ah({listChanged:an().optional()}).optional(),tasks:$.optional(),extensions:aR(nM(),r).optional()}),O=h.extend({protocolVersion:nM(),capabilities:P,serverInfo:w,instructions:nM().optional()}),I=m.extend({method:aT("notifications/initialized"),params:p.optional()}),q=d.extend({method:aT("ping"),params:c.optional()}),j=ah({progress:ae(),total:aO(ae()),message:aO(nM())}),A=ah({...p.shape,...j.shape,progressToken:n}),z=m.extend({method:aT("notifications/progress"),params:A}),N=c.extend({cursor:a.optional()}),M=d.extend({params:N.optional()}),L=h.extend({nextCursor:a.optional()}),U=(Z=ah({uri:nM(),mimeType:aO(nM()),_meta:aR(nM(),ac()).optional()})).extend({text:nM()}),F=nM().refine(t=>{try{return atob(t),!0}catch{return!1}},{message:"Invalid Base64 string"}),D=Z.extend({blob:F}),J=ah({audience:ap(H=ax(["user","assistant"])).optional(),priority:ae().min(0).max(1).optional(),lastModified:r7(nZ,{offset:!0}).optional()}),V=ah({...S.shape,...b.shape,uri:nM(),description:aO(nM()),mimeType:aO(nM()),size:aO(ae()),annotations:J.optional(),_meta:aO(af({}))}),B=ah({...S.shape,...b.shape,uriTemplate:nM(),description:aO(nM()),mimeType:aO(nM()),annotations:J.optional(),_meta:aO(af({}))}),W=M.extend({method:aT("resources/list")}),G=L.extend({resources:ap(V)}),K=M.extend({method:aT("resources/templates/list")}),Y=L.extend({resourceTemplates:ap(B)}),X=c.extend({uri:nM()}),Q=d.extend({method:aT("resources/read"),params:X}),ee=h.extend({contents:ap(ay([U,D]))}),et=m.extend({method:aT("notifications/resources/list_changed"),params:p.optional()}),er=d.extend({method:aT("resources/subscribe"),params:X}),ei=d.extend({method:aT("resources/unsubscribe"),params:X}),en=p.extend({uri:nM()}),ea=m.extend({method:aT("notifications/resources/updated"),params:en}),eo=ah({name:nM(),description:aO(nM()),required:aO(an())}),es=ah({...S.shape,...b.shape,description:aO(nM()),arguments:aO(ap(eo)),_meta:aO(af({}))}),el=M.extend({method:aT("prompts/list")}),ec=L.extend({prompts:ap(es)}),eu=c.extend({name:nM(),arguments:aR(nM(),nM()).optional()}),ed=d.extend({method:aT("prompts/get"),params:eu}),ep=ah({type:aT("text"),text:nM(),annotations:J.optional(),_meta:aR(nM(),ac()).optional()}),em=ah({type:aT("image"),data:F,mimeType:nM(),annotations:J.optional(),_meta:aR(nM(),ac()).optional()}),eh=ah({type:aT("audio"),data:F,mimeType:nM(),annotations:J.optional(),_meta:aR(nM(),ac()).optional()}),ef=ah({type:aT("tool_use"),name:nM(),id:nM(),input:aR(nM(),ac()),_meta:aR(nM(),ac()).optional()}),eg=ah({type:aT("resource"),resource:ay([U,D]),annotations:J.optional(),_meta:aR(nM(),ac()).optional()}),e_=ah({role:H,content:ev=ay([ep,em,eh,ey=V.extend({type:aT("resource_link")}),eg])}),eb=h.extend({description:nM().optional(),messages:ap(e_)}),eS=m.extend({method:aT("notifications/prompts/list_changed"),params:p.optional()}),ew=ah({title:nM().optional(),readOnlyHint:an().optional(),destructiveHint:an().optional(),idempotentHint:an().optional(),openWorldHint:an().optional()}),eR=ah({taskSupport:ax(["required","optional","forbidden"]).optional()}),ek=ah({...S.shape,...b.shape,description:nM().optional(),inputSchema:ah({type:aT("object"),properties:aR(nM(),t).optional(),required:ap(nM()).optional()}).catchall(ac()),outputSchema:ah({type:aT("object"),properties:aR(nM(),t).optional(),required:ap(nM()).optional()}).catchall(ac()).optional(),annotations:ew.optional(),execution:eR.optional(),_meta:aR(nM(),ac()).optional()}),ex=M.extend({method:aT("tools/list")}),e$=L.extend({tools:ap(ek)}),eT=h.extend({content:ap(ev),structuredContent:aR(nM(),ac()).optional(),isError:an().optional()}),eC=u.extend({name:nM(),arguments:aR(nM(),ac()).optional()}),eE=d.extend({method:aT("tools/call"),params:eC}),eP=m.extend({method:aT("notifications/tools/list_changed"),params:p.optional()}),eO=ax(["debug","info","notice","warning","error","critical","alert","emergency"]),eI=c.extend({level:eO}),eq=d.extend({method:aT("logging/setLevel"),params:eI}),ej=p.extend({level:eO,logger:nM().optional(),data:ac()}),eA=m.extend({method:aT("notifications/message"),params:ej}),ez=ah({name:nM().optional()}),eN=ah({hints:ap(ez).optional(),costPriority:ae().min(0).max(1).optional(),speedPriority:ae().min(0).max(1).optional(),intelligencePriority:ae().min(0).max(1).optional()}),eM=ah({mode:ax(["auto","required","none"]).optional()}),eL=ah({type:aT("tool_result"),toolUseId:nM().describe("The unique identifier for the corresponding tool call."),content:ap(ev),structuredContent:ah({}).loose().optional(),isError:an().optional(),_meta:aR(nM(),ac()).optional()}),eZ=a_("type",[ep,em,eh]),eF=ah({role:H,content:ay([eU=a_("type",[ep,em,eh,ef,eL]),ap(eU)]),_meta:aR(nM(),ac()).optional()}),eD=u.extend({messages:ap(eF),modelPreferences:eN.optional(),systemPrompt:nM().optional(),includeContext:ax(["none","thisServer","allServers"]).optional(),temperature:ae().optional(),maxTokens:ae().int(),stopSequences:ap(nM()).optional(),metadata:r.optional(),tools:ap(ek).optional(),toolChoice:eM.optional()}),eH=d.extend({method:aT("sampling/createMessage"),params:eD}),eJ=h.extend({model:nM(),stopReason:aO(ax(["endTurn","stopSequence","maxTokens"]).or(nM())),role:H,content:eZ}),eV=h.extend({model:nM(),stopReason:aO(ax(["endTurn","stopSequence","maxTokens","toolUse"]).or(nM())),role:H,content:ay([eU,ap(eU)])}),eB=ah({type:aT("boolean"),title:nM().optional(),description:nM().optional(),default:an().optional()}),eW=ah({type:aT("string"),title:nM().optional(),description:nM().optional(),minLength:ae().optional(),maxLength:ae().optional(),format:ax(["email","uri","date","date-time"]).optional(),default:nM().optional()}),eG=ah({type:ax(["number","integer"]),title:nM().optional(),description:nM().optional(),minimum:ae().optional(),maximum:ae().optional(),default:ae().optional()}),eK=ah({type:aT("string"),title:nM().optional(),description:nM().optional(),enum:ap(nM()),default:nM().optional()}),eY=ah({type:aT("string"),title:nM().optional(),description:nM().optional(),oneOf:ap(ah({const:nM(),title:nM()})),default:nM().optional()}),eX=ah({type:aT("string"),title:nM().optional(),description:nM().optional(),enum:ap(nM()),enumNames:ap(nM()).optional(),default:nM().optional()}),eQ=ay([eK,eY]),e0=ah({type:aT("array"),title:nM().optional(),description:nM().optional(),minItems:ae().optional(),maxItems:ae().optional(),items:ah({type:aT("string"),enum:ap(nM())}),default:ap(nM()).optional()}),e2=ay([e0,e1=ah({type:aT("array"),title:nM().optional(),description:nM().optional(),minItems:ae().optional(),maxItems:ae().optional(),items:ah({anyOf:ap(ah({const:nM(),title:nM()}))}),default:ap(nM()).optional()})]),e9=ay([eX,eQ,e2]),e4=ay([e9,eB,eW,eG]),e3=u.extend({mode:aT("form").optional(),message:nM(),requestedSchema:ah({type:aT("object"),properties:aR(nM(),e4),required:ap(nM()).optional()}).catchall(ac())}),e5=ay([e3,e6=u.extend({mode:aT("url"),message:nM(),elicitationId:nM(),url:nM().url()})]),e7=d.extend({method:aT("elicitation/create"),params:e5}),e8=p.extend({elicitationId:nM()}),te=m.extend({method:aT("notifications/elicitation/complete"),params:e8}),tt=h.extend({action:ax(["accept","decline","cancel"]),content:aV(t=>null===t?void 0:t,aR(nM(),ay([nM(),ae(),an(),ap(nM())])).optional())}),tr=ah({type:aT("ref/resource"),uri:nM()}),ti=ah({type:aT("ref/prompt"),name:nM()}),tn=c.extend({ref:ay([ti,tr]),argument:ah({name:nM(),value:nM()}),context:ah({arguments:aR(nM(),nM()).optional()}).optional()}),ta=d.extend({method:aT("completion/complete"),params:tn}),to=h.extend({completion:af({values:ap(nM()).max(100),total:aO(ae().int()),hasMore:aO(an())})}),ts=ah({uri:nM().startsWith("file://"),name:nM().optional(),_meta:aR(nM(),ac()).optional()}),tl=d.extend({method:aT("roots/list"),params:c.optional()}),tc=h.extend({roots:ap(ts)}),tu=m.extend({method:aT("notifications/roots/list_changed"),params:p.optional()}),td=af({ttl:ae().optional(),pollInterval:ae().optional()}),tp=ax(["working","input_required","completed","failed","cancelled"]),tm=ah({taskId:nM(),status:tp,ttl:ay([ae(),ao()]),createdAt:nM(),lastUpdatedAt:nM(),pollInterval:aO(ae()),statusMessage:aO(nM())}),th=h.extend({task:tm}),tf=p.merge(tm),tg=m.extend({method:aT("notifications/tasks/status"),params:tf}),ty=d.extend({method:aT("tasks/get"),params:c.extend({taskId:nM()})}),tv=h.merge(tm),t_=d.extend({method:aT("tasks/result"),params:c.extend({taskId:nM()})}),tb=h.loose(),tS=M.extend({method:aT("tasks/list")}),tw=L.extend({tasks:ap(tm)}),tR=d.extend({method:aT("tasks/cancel"),params:c.extend({taskId:nM()})}),{JSONValueSchema:t,JSONObjectSchema:r,ProgressTokenSchema:n,CursorSchema:a,TaskMetadataSchema:o,RelatedTaskMetadataSchema:s,RequestMetaSchema:l,BaseRequestParamsSchema:c,TaskAugmentedRequestParamsSchema:u,RequestSchema:d,NotificationsParamsSchema:p,NotificationSchema:m,ResultSchema:h,RequestIdSchema:f,EmptyResultSchema:g,CancelledNotificationParamsSchema:y,CancelledNotificationSchema:v,IconSchema:_,IconsSchema:b,BaseMetadataSchema:S,ImplementationSchema:w,ClientTasksCapabilitySchema:x,ServerTasksCapabilitySchema:$,ClientCapabilitiesSchema:T,InitializeRequestParamsSchema:C,InitializeRequestSchema:E,ServerCapabilitiesSchema:P,InitializeResultSchema:O,InitializedNotificationSchema:I,PingRequestSchema:q,ProgressSchema:j,ProgressNotificationParamsSchema:A,ProgressNotificationSchema:z,PaginatedRequestParamsSchema:N,PaginatedRequestSchema:M,PaginatedResultSchema:L,ResourceContentsSchema:Z,TextResourceContentsSchema:U,BlobResourceContentsSchema:D,RoleSchema:H,AnnotationsSchema:J,ResourceSchema:V,ResourceTemplateSchema:B,ListResourcesRequestSchema:W,ListResourcesResultSchema:G,ListResourceTemplatesRequestSchema:K,ListResourceTemplatesResultSchema:Y,ResourceRequestParamsSchema:X,ReadResourceRequestParamsSchema:X,ReadResourceRequestSchema:Q,ReadResourceResultSchema:ee,ResourceListChangedNotificationSchema:et,SubscribeRequestParamsSchema:X,SubscribeRequestSchema:er,UnsubscribeRequestParamsSchema:X,UnsubscribeRequestSchema:ei,ResourceUpdatedNotificationParamsSchema:en,ResourceUpdatedNotificationSchema:ea,PromptArgumentSchema:eo,PromptSchema:es,ListPromptsRequestSchema:el,ListPromptsResultSchema:ec,GetPromptRequestParamsSchema:eu,GetPromptRequestSchema:ed,TextContentSchema:ep,ImageContentSchema:em,AudioContentSchema:eh,ToolUseContentSchema:ef,EmbeddedResourceSchema:eg,ResourceLinkSchema:ey,ContentBlockSchema:ev,PromptMessageSchema:e_,GetPromptResultSchema:eb,PromptListChangedNotificationSchema:eS,ToolAnnotationsSchema:ew,ToolExecutionSchema:eR,ToolSchema:ek,ListToolsRequestSchema:ex,ListToolsResultSchema:e$,CallToolResultSchema:eT,CallToolRequestParamsSchema:eC,CallToolRequestSchema:eE,ToolListChangedNotificationSchema:eP,LoggingLevelSchema:eO,SetLevelRequestParamsSchema:eI,SetLevelRequestSchema:eq,LoggingMessageNotificationParamsSchema:ej,LoggingMessageNotificationSchema:eA,ModelHintSchema:ez,ModelPreferencesSchema:eN,ToolChoiceSchema:eM,ToolResultContentSchema:eL,SamplingContentSchema:eZ,SamplingMessageContentBlockSchema:eU,SamplingMessageSchema:eF,CreateMessageRequestParamsSchema:eD,CreateMessageRequestSchema:eH,CreateMessageResultSchema:eJ,CreateMessageResultWithToolsSchema:eV,BooleanSchemaSchema:eB,StringSchemaSchema:eW,NumberSchemaSchema:eG,UntitledSingleSelectEnumSchemaSchema:eK,TitledSingleSelectEnumSchemaSchema:eY,LegacyTitledEnumSchemaSchema:eX,SingleSelectEnumSchemaSchema:eQ,UntitledMultiSelectEnumSchemaSchema:e0,TitledMultiSelectEnumSchemaSchema:e1,MultiSelectEnumSchemaSchema:e2,EnumSchemaSchema:e9,PrimitiveSchemaDefinitionSchema:e4,ElicitRequestFormParamsSchema:e3,ElicitRequestURLParamsSchema:e6,ElicitRequestParamsSchema:e5,ElicitRequestSchema:e7,ElicitationCompleteNotificationParamsSchema:e8,ElicitationCompleteNotificationSchema:te,ElicitResultSchema:tt,ResourceTemplateReferenceSchema:tr,PromptReferenceSchema:ti,CompleteRequestParamsSchema:tn,CompleteRequestSchema:ta,CompleteResultSchema:to,RootSchema:ts,ListRootsRequestSchema:tl,ListRootsResultSchema:tc,RootsListChangedNotificationSchema:tu,TaskCreationParamsSchema:td,TaskStatusSchema:tp,TaskSchema:tm,CreateTaskResultSchema:th,TaskStatusNotificationParamsSchema:tf,TaskStatusNotificationSchema:tg,GetTaskRequestSchema:ty,GetTaskResultSchema:tv,GetTaskPayloadRequestSchema:t_,GetTaskPayloadResultSchema:tb,ListTasksRequestSchema:tS,ListTasksResultSchema:tw,CancelTaskRequestSchema:tR,CancelTaskResultSchema:h.merge(tm),ClientRequestSchema:ay([q,E,ta,eq,ed,el,W,K,Q,er,ei,eE,ex,ty,t_,tS,tR]),ClientNotificationSchema:ay([v,z,I,tu,tg]),ClientResultSchema:ay([g,eJ,eV,tt,tc,tv,tw,th]),ServerRequestSchema:ay([q,eH,e7,tl,ty,t_,tS,tR]),ServerNotificationSchema:ay([v,z,eA,ea,et,eP,eS,tg,te]),ServerResultSchema:ay([g,O,to,eb,ec,G,Y,ee,eT,e$,tv,tw,th]),CallToolResultWireSchema:ac().superRefine((t,r)=>{if(!("object"!=typeof t||null===t||Array.isArray(t))&&void 0===t.content){for(let i of l9)if(i in t)return void r.addIssue({code:"custom",message:`content is required when the body carries '${i}' — another result family cannot default into an empty tools/call success`})}}).transform(l4).pipe(eT)})}function l6(t){return"object"!==t.type}let l5=new Set(["const","enum","default","examples"]),l7=new Set(["properties","patternProperties","$defs","definitions","dependentSchemas","dependencies"]);function l8(t){return void 0!==t&&!("string"==typeof t&&t.startsWith("#"))}let ce={ping:null,initialize:null,"completion/complete":null,"logging/setLevel":null,"prompts/get":null,"prompts/list":null,"resources/list":null,"resources/templates/list":null,"resources/read":null,"resources/subscribe":null,"resources/unsubscribe":null,"tools/call":null,"tools/list":null,"tasks/get":null,"tasks/result":null,"tasks/list":null,"tasks/cancel":null,"sampling/createMessage":null,"elicitation/create":null,"roots/list":null},ct={"notifications/cancelled":null,"notifications/progress":null,"notifications/initialized":null,"notifications/roots/list_changed":null,"notifications/tasks/status":null,"notifications/message":null,"notifications/resources/updated":null,"notifications/resources/list_changed":null,"notifications/tools/list_changed":null,"notifications/prompts/list_changed":null,"notifications/elicitation/complete":null},cr={ping:null,initialize:null,"completion/complete":null,"logging/setLevel":null,"prompts/get":null,"prompts/list":null,"resources/list":null,"resources/templates/list":null,"resources/read":null,"resources/subscribe":null,"resources/unsubscribe":null,"tools/call":null,"tools/list":null,"sampling/createMessage":null,"elicitation/create":null,"roots/list":null};function ci(){if(n)return n;let t=l3();return n={requestSchemas:{ping:t.PingRequestSchema,initialize:t.InitializeRequestSchema,"completion/complete":t.CompleteRequestSchema,"logging/setLevel":t.SetLevelRequestSchema,"prompts/get":t.GetPromptRequestSchema,"prompts/list":t.ListPromptsRequestSchema,"resources/list":t.ListResourcesRequestSchema,"resources/templates/list":t.ListResourceTemplatesRequestSchema,"resources/read":t.ReadResourceRequestSchema,"resources/subscribe":t.SubscribeRequestSchema,"resources/unsubscribe":t.UnsubscribeRequestSchema,"tools/call":t.CallToolRequestSchema,"tools/list":t.ListToolsRequestSchema,"tasks/get":t.GetTaskRequestSchema,"tasks/result":t.GetTaskPayloadRequestSchema,"tasks/list":t.ListTasksRequestSchema,"tasks/cancel":t.CancelTaskRequestSchema,"sampling/createMessage":t.CreateMessageRequestSchema,"elicitation/create":t.ElicitRequestSchema,"roots/list":t.ListRootsRequestSchema},notificationSchemas:{"notifications/cancelled":t.CancelledNotificationSchema,"notifications/progress":t.ProgressNotificationSchema,"notifications/initialized":t.InitializedNotificationSchema,"notifications/roots/list_changed":t.RootsListChangedNotificationSchema,"notifications/tasks/status":t.TaskStatusNotificationSchema,"notifications/message":t.LoggingMessageNotificationSchema,"notifications/resources/updated":t.ResourceUpdatedNotificationSchema,"notifications/resources/list_changed":t.ResourceListChangedNotificationSchema,"notifications/tools/list_changed":t.ToolListChangedNotificationSchema,"notifications/prompts/list_changed":t.PromptListChangedNotificationSchema,"notifications/elicitation/complete":t.ElicitationCompleteNotificationSchema},resultSchemas:{ping:t.EmptyResultSchema,initialize:t.InitializeResultSchema,"completion/complete":t.CompleteResultSchema,"logging/setLevel":t.EmptyResultSchema,"prompts/get":t.GetPromptResultSchema,"prompts/list":t.ListPromptsResultSchema,"resources/list":t.ListResourcesResultSchema,"resources/templates/list":t.ListResourceTemplatesResultSchema,"resources/read":t.ReadResourceResultSchema,"resources/subscribe":t.EmptyResultSchema,"resources/unsubscribe":t.EmptyResultSchema,"tools/call":t.CallToolResultWireSchema,"tools/list":t.ListToolsResultSchema,"sampling/createMessage":t.CreateMessageResultWithToolsSchema,"elicitation/create":t.ElicitResultSchema,"roots/list":t.ListRootsResultSchema}}}function cn(t){return Object.prototype.hasOwnProperty.call(ce,t)}function ca(t){return Object.prototype.hasOwnProperty.call(ct,t)}function co(t){return null!==t&&"object"==typeof t&&!Array.isArray(t)}function cs(t,r){if(void 0===t)return{ok:!1,reason:"not-in-era"};let i=t.safeParse(r);return i.success?{ok:!0,value:i.data}:{ok:!1,reason:"invalid",message:String(i.error)}}Object.keys(ce),Object.keys(ct);let cl={ok:!1,reason:"not-in-era"};function cc(t){return co(t)&&co(t.outputSchema)&&l6(t.outputSchema)}let cu={era:"2025-11-25",hasRequestMethod:cn,hasNotificationMethod:ca,validateRequest:(t,r)=>cs(cn(t)?ci().requestSchemas[t]:void 0,r),validateResult:(t,r)=>cs(Object.prototype.hasOwnProperty.call(cr,t)?ci().resultSchemas[t]:void 0,r),validateNotification:(t,r)=>cs(ca(t)?ci().notificationSchemas[t]:void 0,r),hasInputRequestMethod:()=>!1,validateInputRequest:()=>cl,validateInputResponse:()=>cl,samplingResultVariant:(t,r)=>{let i=l3();return cs(t?i.CreateMessageResultWithToolsSchema:i.CreateMessageResultSchema,r)},outboundEnvelope:t=>void 0,validateEnvelopeMeta:t=>[],projectCallToolResult(t,r){let i=l2(t),n=i.structuredContent;if(void 0===n)return i;let a="object"!=typeof n||null===n||Array.isArray(n),o=void 0!==r&&l6(r);return a||o?{...i,structuredContent:{result:n}}:i},decodeResult(t,r){if(co(r)&&"resultType"in r){let t={...r};return delete t.resultType,{kind:"complete",result:t}}return{kind:"complete",result:r}},encodeResult(t,r){if("tools/list"!==t)return r;let i=r.tools;return Array.isArray(i)&&i.some(t=>cc(t))?{...r,tools:i.map(t=>cc(t)?{...t,outputSchema:function(t){var r;let i="string"==typeof t.$schema?t.$schema:void 0;if(l8(t.$id))return{...void 0!==i&&{$schema:i},type:"object",properties:{result:t},required:["result"]};let n="string"==typeof(r=t.$schema)&&Y.has(r.replace(/#$/,""))&&!0!==t.$recursiveAnchor,a=(t,r)=>{if(Array.isArray(t))return t.map(t=>a(t,!1));if(null===t||"object"!=typeof t||!r&&l8(t.$id))return t;let i={},o=!1;for(let[s,l]of Object.entries(t))r?i[s]=a(l,!1):("$ref"===s||"$dynamicRef"===s)&&"string"==typeof l?i[s]="#"===l?"#/properties/result":l.startsWith("#/")?`#/properties/result${l.slice(1)}`:l:"$recursiveRef"===s&&"#"===l&&n?o=!0:l5.has(s)?i[s]=l:l7.has(s)?i[s]=a(l,!0):i[s]=a(l,!1);return o&&("$ref"in i?i.allOf=[...Array.isArray(i.allOf)?i.allOf:[],{$ref:"#/properties/result"}]:i.$ref="#/properties/result"),i};return{...void 0!==i&&{$schema:i},type:"object",properties:{result:a(t,!1)},required:["result"]}}(t.outputSchema)}:t)}:r},encodeErrorCode:t=>-32002===t?-32602:t,checkInboundEnvelope:t=>void 0};function cd(){return a??=function(){let t=aH(()=>ay([nM(),ae(),an(),ao(),aR(nM(),t),ap(t)])),r=aR(nM(),t),i=ay([nM(),ae().int()]),n=nM(),a=ay([nM(),ae().int()]),o=ax(["user","assistant"]),s=ax(["debug","info","notice","warning","error","critical","alert","emergency"]),l=nM().refine(t=>{try{return atob(t),!0}catch{return!1}},{message:"Invalid Base64 string"}),c=ah({ttl:ae().optional()}),u=ah({taskId:nM()}),d=af({progressToken:i.optional(),"io.modelcontextprotocol/related-task":u.optional()}),p=ah({_meta:d.optional()}),m=p.extend({task:c.optional()}),h=ah({_meta:d.optional()}),f=ah({method:nM(),params:h.loose().optional()}),g=ah({src:nM(),mimeType:nM().optional(),sizes:ap(nM()).optional(),theme:ax(["light","dark"]).optional()}),y=ah({icons:ap(g).optional()}),v=ah({name:nM(),title:nM().optional()}),_=v.extend({...v.shape,...y.shape,version:nM(),websiteUrl:nM().optional(),description:nM().optional()}),b=aS(ah({applyDefaults:an().optional()}),r),S=aV(t=>t&&"object"==typeof t&&!Array.isArray(t)&&0===Object.keys(t).length?{form:{}}:t,aS(ah({form:b.optional(),url:r.optional()}),r.optional())),w=af({list:r.optional(),cancel:r.optional(),requests:af({sampling:af({createMessage:r.optional()}).optional(),elicitation:af({create:r.optional()}).optional()}).optional()}),R=af({list:r.optional(),cancel:r.optional(),requests:af({tools:af({call:r.optional()}).optional()}).optional()}),k=ah({experimental:aR(nM(),r).optional(),sampling:ah({context:r.optional(),tools:r.optional()}).optional(),elicitation:S.optional(),roots:ah({listChanged:an().optional()}).optional(),tasks:w.optional(),extensions:aR(nM(),r).optional()}),x=ah({experimental:aR(nM(),r).optional(),logging:r.optional(),completions:r.optional(),prompts:ah({listChanged:an().optional()}).optional(),resources:ah({subscribe:an().optional(),listChanged:an().optional()}).optional(),tools:ah({listChanged:an().optional()}).optional(),tasks:R.optional(),extensions:aR(nM(),r).optional()}),$=ah({progress:ae(),total:aO(ae()),message:aO(nM())}),T=ah({...h.shape,...$.shape,progressToken:i}),C=f.extend({method:aT("notifications/progress"),params:T}),E=h.extend({level:s,logger:nM().optional(),data:ac()}),P=f.extend({method:aT("notifications/message"),params:E}),O=ah({uri:nM(),mimeType:aO(nM()),_meta:aR(nM(),ac()).optional()}),I=O.extend({text:nM()}),q=O.extend({blob:l}),j=ah({audience:ap(o).optional(),priority:ae().min(0).max(1).optional(),lastModified:r7(nZ,{offset:!0}).optional()}),A=ah({...v.shape,...y.shape,uri:nM(),description:aO(nM()),mimeType:aO(nM()),size:aO(ae()),annotations:j.optional(),_meta:aO(af({}))}),z=ah({...v.shape,...y.shape,uriTemplate:nM(),description:aO(nM()),mimeType:aO(nM()),annotations:j.optional(),_meta:aO(af({}))}),N=f.extend({method:aT("notifications/resources/list_changed"),params:h.optional()}),M=h.extend({uri:nM()}),L=f.extend({method:aT("notifications/resources/updated"),params:M}),Z=ah({name:nM(),description:aO(nM()),required:aO(an())}),U=ah({...v.shape,...y.shape,description:aO(nM()),arguments:aO(ap(Z)),_meta:aO(af({}))}),F=f.extend({method:aT("notifications/prompts/list_changed"),params:h.optional()}),D=ah({type:aT("text"),text:nM(),annotations:j.optional(),_meta:aR(nM(),ac()).optional()}),H=ah({type:aT("image"),data:l,mimeType:nM(),annotations:j.optional(),_meta:aR(nM(),ac()).optional()}),J=ah({type:aT("audio"),data:l,mimeType:nM(),annotations:j.optional(),_meta:aR(nM(),ac()).optional()}),V=ah({type:aT("tool_use"),name:nM(),id:nM(),input:aR(nM(),ac()),_meta:aR(nM(),ac()).optional()}),B=ah({type:aT("resource"),resource:ay([I,q]),annotations:j.optional(),_meta:aR(nM(),ac()).optional()}),W=A.extend({type:aT("resource_link")}),G=ay([D,H,J,W,B]),K=ah({role:o,content:G}),Y=ah({title:nM().optional(),readOnlyHint:an().optional(),destructiveHint:an().optional(),idempotentHint:an().optional(),openWorldHint:an().optional()}),X=f.extend({method:aT("notifications/tools/list_changed"),params:h.optional()}),Q=ah({name:nM().optional()}),ee=ah({hints:ap(Q).optional(),costPriority:ae().min(0).max(1).optional(),speedPriority:ae().min(0).max(1).optional(),intelligencePriority:ae().min(0).max(1).optional()}),et=ah({mode:ax(["auto","required","none"]).optional()}),er=ah({type:aT("boolean"),title:nM().optional(),description:nM().optional(),default:an().optional()}),ei=ah({type:aT("string"),title:nM().optional(),description:nM().optional(),minLength:ae().optional(),maxLength:ae().optional(),format:ax(["email","uri","date","date-time"]).optional(),default:nM().optional()}),en=ah({type:ax(["number","integer"]),title:nM().optional(),description:nM().optional(),minimum:ae().optional(),maximum:ae().optional(),default:ae().optional()}),ea=ah({type:aT("string"),title:nM().optional(),description:nM().optional(),enum:ap(nM()),default:nM().optional()}),eo=ah({type:aT("string"),title:nM().optional(),description:nM().optional(),oneOf:ap(ah({const:nM(),title:nM()})),default:nM().optional()}),es=ah({type:aT("string"),title:nM().optional(),description:nM().optional(),enum:ap(nM()),enumNames:ap(nM()).optional(),default:nM().optional()}),el=ay([ea,eo]),ec=ah({type:aT("array"),title:nM().optional(),description:nM().optional(),minItems:ae().optional(),maxItems:ae().optional(),items:ah({type:aT("string"),enum:ap(nM())}),default:ap(nM()).optional()}),eu=ah({type:aT("array"),title:nM().optional(),description:nM().optional(),minItems:ae().optional(),maxItems:ae().optional(),items:ah({anyOf:ap(ah({const:nM(),title:nM()}))}),default:ap(nM()).optional()}),ed=ay([ec,eu]),ep=ay([es,el,ed]),em=ay([ep,er,ei,en]),eh=m.extend({mode:aT("form").optional(),message:nM(),requestedSchema:ah({type:aT("object"),properties:aR(nM(),em),required:ap(nM()).optional()}).catchall(ac())}),ef=ah({type:aT("ref/resource"),uri:nM()}),eg=ah({type:aT("ref/prompt"),name:nM()}),ey=ah({uri:nM().startsWith("file://"),name:nM().optional(),_meta:aR(nM(),ac()).optional()}),ev=k.shape,e_=ah({experimental:ev.experimental,sampling:ev.sampling,elicitation:ev.elicitation,roots:ev.roots,extensions:ev.extensions}),eb=x.shape,eS=ah({experimental:eb.experimental,logging:eb.logging,completions:eb.completions,prompts:eb.prompts,resources:eb.resources,tools:eb.tools,extensions:eb.extensions}),ew=af({progressToken:i.optional(),[aG]:nM(),[aK]:_.optional(),[aX]:e_,[a0]:s.optional()}),eR=ah({...v.shape,...y.shape,description:nM().optional(),inputSchema:af({$schema:nM().optional(),type:aT("object")}),outputSchema:af({$schema:nM().optional()}).optional(),annotations:Y.optional(),_meta:aR(nM(),ac()).optional()}),ek=ah({type:aT("tool_result"),toolUseId:nM(),content:ap(G),structuredContent:ac().optional(),isError:an().optional(),_meta:aR(nM(),ac()).optional()}),ex=ay([D,H,J,V,ek]),e$=ah({role:o,content:ay([ex,ap(ex)]),_meta:aR(nM(),ac()).optional()}),eT=nM(),eC=af({[aY]:_.optional().catch(void 0)}),eE=eC.optional();function eP(t){return af({_meta:eE,resultType:eT.default("complete"),...t})}let eO=eP({}),eI=eP({nextCursor:n.optional()}),eq=eP({content:ap(G),structuredContent:ac().optional(),isError:an().optional()}),ej=eP({ttlMs:ae().int().min(0),cacheScope:ax(["public","private"]),tools:ap(eR),nextCursor:n.optional()}),eA=eP({ttlMs:ae().int().min(0),cacheScope:ax(["public","private"]),prompts:ap(U),nextCursor:n.optional()}),ez=eP({description:nM().optional(),messages:ap(K)}),eN=eP({ttlMs:ae().int().min(0),cacheScope:ax(["public","private"]),resources:ap(A),nextCursor:n.optional()}),eM=eP({ttlMs:ae().int().min(0),cacheScope:ax(["public","private"]),resourceTemplates:ap(z),nextCursor:n.optional()}),eL=eP({ttlMs:ae().int().min(0),cacheScope:ax(["public","private"]),contents:ap(ay([I,q]))}),eZ=eP({completion:ah({values:ap(nM()).max(100),total:ae().int().optional(),hasMore:an().optional()}).loose()}),eU=eP({ttlMs:ae().int().min(0),cacheScope:ax(["public","private"])}),eF=eP({ttlMs:ae().int().min(0).catch(0),cacheScope:ax(["public","private"]).catch("private"),supportedVersions:ap(nM()),capabilities:eS,instructions:nM().optional()}),eD=ah({messages:ap(e$),modelPreferences:ee.optional(),systemPrompt:nM().optional(),includeContext:ax(["none","thisServer","allServers"]).optional(),temperature:ae().optional(),maxTokens:ae().int(),stopSequences:ap(nM()).optional(),metadata:r.optional(),tools:ap(eR).optional(),toolChoice:et.optional()}),eH=ah({method:aT("sampling/createMessage"),params:eD}),eJ=ah({method:aT("roots/list"),params:ah({_meta:aR(nM(),ac()).optional()}).optional()}),eV=ah({...e$.shape,model:nM(),stopReason:nM().optional()}),eB=ah({roots:ap(ey)}),eW=ah({action:ax(["accept","decline","cancel"]),content:aR(nM(),ay([nM(),ae(),an(),ap(nM())])).optional()}),eG=ah({mode:aT("url"),message:nM(),url:nM().url()}),eK=ay([eh,eG]),eY=ah({method:aT("elicitation/create"),params:eK}),eX=ay([eH,eJ,eY]),eQ=ay([eV,eB,eW]),e0=aR(nM(),eX),e1=aR(nM(),eQ),e2=eP({inputRequests:e0.optional(),requestState:nM().optional()}),e9={inputResponses:e1.optional(),requestState:nM().optional()},e4=ah({_meta:ew,...e9}),e3=af({progressToken:i.optional()});function e6(t,r){return ah({method:aT(t),params:ah({_meta:ew,...r})})}function e5(t,r){return ah({method:aT(t),params:ah({_meta:e3.optional(),...r}).optional()})}let e7={name:nM(),arguments:aR(nM(),ac()).optional(),...e9},e8={cursor:n.optional()},te=e6("tools/call",e7),tt=e6("tools/list",e8),tr=e6("prompts/list",e8),ti=e6("prompts/get",{name:nM(),arguments:aR(nM(),nM()).optional(),...e9}),tn=e6("resources/list",e8),ta=e6("resources/templates/list",e8),to=e6("resources/read",{uri:nM(),...e9}),ts={ref:ay([eg,ef]),argument:ah({name:nM(),value:nM()}),context:ah({arguments:aR(nM(),nM()).optional()}).optional()},tl=e6("completion/complete",ts),tc=e6("server/discover",{}),tu=ah({toolsListChanged:an().optional(),promptsListChanged:an().optional(),resourcesListChanged:an().optional(),resourceSubscriptions:ap(nM()).optional()}),td={notifications:tu},tp=e6("subscriptions/listen",td),tm=eC.extend({"io.modelcontextprotocol/subscriptionId":a}),th=af({_meta:tm,resultType:eT.default("complete")}),tf={"tools/call":e5("tools/call",e7),"tools/list":e5("tools/list",e8),"prompts/get":e5("prompts/get",{name:nM(),arguments:aR(nM(),nM()).optional()}),"prompts/list":e5("prompts/list",e8),"resources/list":e5("resources/list",e8),"resources/templates/list":e5("resources/templates/list",e8),"resources/read":e5("resources/read",{uri:nM()}),"completion/complete":e5("completion/complete",ts),"server/discover":e5("server/discover",{}),"subscriptions/listen":e5("subscriptions/listen",td)};function tg(t){return af({_meta:eE,...t})}let ty={"tools/call":tg({content:ap(G),structuredContent:ac().optional(),isError:an().optional()}),"tools/list":tg({ttlMs:ae().int().min(0),cacheScope:ax(["public","private"]),tools:ap(eR),nextCursor:n.optional()}),"prompts/get":tg({description:nM().optional(),messages:ap(K)}),"prompts/list":tg({ttlMs:ae().int().min(0),cacheScope:ax(["public","private"]),prompts:ap(U),nextCursor:n.optional()}),"resources/list":tg({ttlMs:ae().int().min(0),cacheScope:ax(["public","private"]),resources:ap(A),nextCursor:n.optional()}),"resources/templates/list":tg({ttlMs:ae().int().min(0),cacheScope:ax(["public","private"]),resourceTemplates:ap(z),nextCursor:n.optional()}),"resources/read":tg({ttlMs:ae().int().min(0),cacheScope:ax(["public","private"]),contents:ap(ay([I,q]))}),"completion/complete":tg({completion:ah({values:ap(nM()).max(100),total:ae().int().optional(),hasMore:an().optional()}).loose()}),"server/discover":tg({ttlMs:ae().int().min(0).catch(0),cacheScope:ax(["public","private"]).catch("private"),supportedVersions:ap(nM()),capabilities:eS,instructions:nM().optional()}),"subscriptions/listen":tg({})},tv=af({"io.modelcontextprotocol/subscriptionId":a.optional()}),t_=ah({method:aT("notifications/subscriptions/acknowledged"),params:ah({_meta:tv.optional(),notifications:tu})}),tb=ah({_meta:tv.optional(),requestId:a,reason:nM().optional()}),tS=ah({method:aT("notifications/cancelled"),params:tb}),tw=t=>ah({jsonrpc:aT("2.0"),id:ay([nM(),ae().int()]),result:t}).strict();return{JSONValueSchema:t,JSONObjectSchema:r,ProgressTokenSchema:i,CursorSchema:n,RequestIdSchema:a,RoleSchema:o,LoggingLevelSchema:s,TaskMetadataSchema:c,RelatedTaskMetadataSchema:u,RequestMetaSchema:d,BaseRequestParamsSchema:p,TaskAugmentedRequestParamsSchema:m,NotificationsParamsSchema:h,NotificationSchema:f,IconSchema:g,IconsSchema:y,BaseMetadataSchema:v,ImplementationSchema:_,ClientTasksCapabilitySchema:w,ServerTasksCapabilitySchema:R,ClientCapabilitiesSchema:k,ServerCapabilitiesSchema:x,ProgressSchema:$,ProgressNotificationParamsSchema:T,ProgressNotificationSchema:C,LoggingMessageNotificationParamsSchema:E,LoggingMessageNotificationSchema:P,ResourceContentsSchema:O,TextResourceContentsSchema:I,BlobResourceContentsSchema:q,AnnotationsSchema:j,ResourceSchema:A,ResourceTemplateSchema:z,ResourceListChangedNotificationSchema:N,ResourceUpdatedNotificationParamsSchema:M,ResourceUpdatedNotificationSchema:L,PromptArgumentSchema:Z,PromptSchema:U,PromptListChangedNotificationSchema:F,TextContentSchema:D,ImageContentSchema:H,AudioContentSchema:J,ToolUseContentSchema:V,EmbeddedResourceSchema:B,ResourceLinkSchema:W,ContentBlockSchema:G,PromptMessageSchema:K,ToolAnnotationsSchema:Y,ToolListChangedNotificationSchema:X,ModelHintSchema:Q,ModelPreferencesSchema:ee,ToolChoiceSchema:et,BooleanSchemaSchema:er,StringSchemaSchema:ei,NumberSchemaSchema:en,UntitledSingleSelectEnumSchemaSchema:ea,TitledSingleSelectEnumSchemaSchema:eo,LegacyTitledEnumSchemaSchema:es,SingleSelectEnumSchemaSchema:el,UntitledMultiSelectEnumSchemaSchema:ec,TitledMultiSelectEnumSchemaSchema:eu,MultiSelectEnumSchemaSchema:ed,EnumSchemaSchema:ep,PrimitiveSchemaDefinitionSchema:em,ElicitRequestFormParamsSchema:eh,ResourceTemplateReferenceSchema:ef,PromptReferenceSchema:eg,RootSchema:ey,ClientCapabilities2026Schema:e_,ServerCapabilities2026Schema:eS,RequestMetaEnvelopeSchema:ew,ToolSchema:eR,ToolResultContentSchema:ek,SamplingMessageContentBlockSchema:ex,SamplingMessageSchema:e$,ResultTypeSchema:eT,ResultMetaSchema:eC,ResultSchema:eO,PaginatedResultSchema:eI,CallToolResultSchema:eq,ListToolsResultSchema:ej,ListPromptsResultSchema:eA,GetPromptResultSchema:ez,ListResourcesResultSchema:eN,ListResourceTemplatesResultSchema:eM,ReadResourceResultSchema:eL,CompleteResultSchema:eZ,CacheableResultSchema:eU,DiscoverResultSchema:eF,CreateMessageRequestParamsSchema:eD,CreateMessageRequestSchema:eH,ListRootsRequestSchema:eJ,CreateMessageResultSchema:eV,ListRootsResultSchema:eB,ElicitResultSchema:eW,ElicitRequestURLParamsSchema:eG,ElicitRequestParamsSchema:eK,ElicitRequestSchema:eY,InputRequestSchema:eX,InputResponseSchema:eQ,InputRequestsSchema:e0,InputResponsesSchema:e1,InputRequiredResultSchema:e2,InputResponseRequestParamsSchema:e4,CallToolRequestSchema:te,ListToolsRequestSchema:tt,ListPromptsRequestSchema:tr,GetPromptRequestSchema:ti,ListResourcesRequestSchema:tn,ListResourceTemplatesRequestSchema:ta,ReadResourceRequestSchema:to,CompleteRequestSchema:tl,DiscoverRequestSchema:tc,SubscriptionFilterSchema:tu,SubscriptionsListenRequestSchema:tp,SubscriptionsListenResultMetaSchema:tm,SubscriptionsListenResultSchema:th,dispatchRequestSchemas:tf,dispatchResultSchemas:ty,NotificationMetaSchema:tv,SubscriptionsAcknowledgedNotificationSchema:t_,CancelledNotificationParamsSchema:tb,CancelledNotificationSchema:tS,notificationSchemas2026:{"notifications/cancelled":tS,"notifications/progress":C,"notifications/message":P,"notifications/resources/updated":L,"notifications/resources/list_changed":N,"notifications/tools/list_changed":X,"notifications/prompts/list_changed":F,"notifications/subscriptions/acknowledged":t_},JSONRPCResultResponseSchema:tw(eO),CallToolResultResponseSchema:tw(ay([eq,e2])),ListToolsResultResponseSchema:tw(ej),ListPromptsResultResponseSchema:tw(eA),GetPromptResultResponseSchema:tw(ay([ez,e2])),ListResourcesResultResponseSchema:tw(eN),ListResourceTemplatesResultResponseSchema:tw(eM),ReadResourceResultResponseSchema:tw(ay([eL,e2])),CompleteResultResponseSchema:tw(eZ),DiscoverResultResponseSchema:tw(eF),SubscriptionsListenResultResponseSchema:tw(th)}}()}let cp=["tools/list","prompts/list","resources/list","resources/templates/list","resources/read","server/discover"],cm=Symbol("modelcontextprotocol.resultCacheHintFallback");function ch(t,r){if(void 0===r)return t;let i=t[cm];if(void 0===i)return{...t,[cm]:r};let n={},a=i.ttlMs??r.ttlMs;void 0!==a&&(n.ttlMs=a);let o=i.cacheScope??r.cacheScope;return void 0!==o&&(n.cacheScope=o),{...t,[cm]:n}}function cf(t){return"number"==typeof t&&Number.isSafeInteger(t)&&t>=0}function cg(t){return"public"===t||"private"===t}function cy(t,r){if(void 0!==t.ttlMs&&!cf(t.ttlMs))throw RangeError(`Invalid cache hint for ${r}: ttlMs must be a non-negative safe integer (got ${String(t.ttlMs)})`);if(void 0!==t.cacheScope&&!cg(t.cacheScope))throw RangeError(`Invalid cache hint for ${r}: cacheScope must be 'public' or 'private' (got ${String(t.cacheScope)})`)}let cv=((C={})[C.ParseError=-32700]="ParseError",C[C.InvalidRequest=-32600]="InvalidRequest",C[C.MethodNotFound=-32601]="MethodNotFound",C[C.InvalidParams=-32602]="InvalidParams",C[C.InternalError=-32603]="InternalError",C[C.ResourceNotFound=-32002]="ResourceNotFound",C[C.MissingRequiredClientCapability=-32021]="MissingRequiredClientCapability",C[C.UnsupportedProtocolVersion=-32022]="UnsupportedProtocolVersion",C[C.UrlElicitationRequired=-32042]="UrlElicitationRequired",C);var c_=class t extends Error{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.ProtocolError"})}static[Symbol.hasInstance](t){return lJ(this,t)}static isInstance(t){if("function"!=typeof this)throw TypeError("isInstance must be called on the class (e.g. `SdkError.isInstance(value)`); for callbacks use `v => SdkError.isInstance(v)`");return lJ(this,t)}constructor(t,r,i){super(r),this.code=t,this.data=i,this.name="ProtocolError",lH(this,new.target)}static fromError(r,i,n){return r===cv.UrlElicitationRequired&&n&&n.elicitations?new cS(n.elicitations,i):r===cv.UnsupportedProtocolVersion&&n&&Array.isArray(n.supported)&&"string"==typeof n.requested?new cw({supported:n.supported,requested:n.requested},i):(r===cv.InvalidParams||r===cv.ResourceNotFound)&&"string"==typeof n?.uri&&(r===cv.ResourceNotFound||1===Object.keys(n).length)?new cb(n.uri,i):r===cv.MissingRequiredClientCapability&&n&&null!==n.requiredCapabilities&&"object"==typeof n.requiredCapabilities&&!Array.isArray(n.requiredCapabilities)?new cR({requiredCapabilities:n.requiredCapabilities},i):new t(r,i,n)}},cb=class extends c_{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.ResourceNotFoundError"})}constructor(t,r=`Resource not found: ${t}`){super(cv.InvalidParams,r,{uri:t})}get uri(){return this.data.uri}},cS=class extends c_{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.UrlElicitationRequiredError"})}constructor(t,r=`URL elicitation${t.length>1?"s":""} required`){super(cv.UrlElicitationRequired,r,{elicitations:t})}get elicitations(){return this.data?.elicitations??[]}},cw=class extends c_{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.UnsupportedProtocolVersionError"})}constructor(t,r=`Unsupported protocol version: ${t.requested}`){super(cv.UnsupportedProtocolVersion,r,t)}get supported(){return this.data.supported}get requested(){return this.data.requested}},cR=class extends c_{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.MissingRequiredClientCapabilityError"})}constructor(t,r=`Missing required client capabilities: ${Object.keys(t.requiredCapabilities).join(", ")}`){super(cv.MissingRequiredClientCapability,r,t)}get requiredCapabilities(){return this.data.requiredCapabilities}};let ck=["tools/call","prompts/get","resources/read"],cx=["elicitation/create","sampling/createMessage","roots/list"];function c$(){if(o)return o;let t=cd();return o={request:{"elicitation/create":ah({method:aT("elicitation/create"),params:t.ElicitRequestParamsSchema}),"sampling/createMessage":ah({method:aT("sampling/createMessage"),params:t.CreateMessageRequestParamsSchema}),"roots/list":ah({method:aT("roots/list"),params:af({}).optional()})},response:{"elicitation/create":t.ElicitResultSchema,"sampling/createMessage":t.CreateMessageResultSchema,"roots/list":t.ListRootsResultSchema}}}function cT(t){return cx.includes(t)}function cC(t){return cT(t)?c$().request[t]:void 0}let cE={"tools/call":null,"tools/list":null,"prompts/get":null,"prompts/list":null,"resources/list":null,"resources/templates/list":null,"resources/read":null,"completion/complete":null,"server/discover":null,"subscriptions/listen":null},cP={"notifications/cancelled":null,"notifications/progress":null,"notifications/message":null,"notifications/resources/updated":null,"notifications/resources/list_changed":null,"notifications/tools/list_changed":null,"notifications/prompts/list_changed":null,"notifications/subscriptions/acknowledged":null};function cO(t){return Object.prototype.hasOwnProperty.call(cE,t)}function cI(t){return Object.prototype.hasOwnProperty.call(cP,t)}function cq(t){return null!==t&&"object"==typeof t&&!Array.isArray(t)}function cj(t,r){if(void 0===t)return{ok:!1,reason:"not-in-era"};let i=t.safeParse(r);return i.success?{ok:!0,value:i.data}:{ok:!1,reason:"invalid",message:String(i.error)}}Object.keys(cE),Object.keys(cP);let cA={ok:!1,reason:"not-in-era"},cz=[aG,aX],cN={era:"2026-07-28",hasRequestMethod:cO,hasNotificationMethod:cI,hasInputRequestMethod:t=>void 0!==cC(t),validateRequest:(t,r)=>cj(cO(t)?cd().dispatchRequestSchemas[t]:void 0,r),validateResult:(t,r)=>cj(Object.prototype.hasOwnProperty.call(cE,t)?cd().dispatchResultSchemas[t]:void 0,r),validateNotification:(t,r)=>cj(cI(t)?cd().notificationSchemas2026[t]:void 0,r),validateInputRequest:(t,r)=>cj(cC(t),r),validateInputResponse:(t,r)=>cj(cT(t)?c$().response[t]:void 0,r),samplingResultVariant:()=>cA,outboundEnvelope:t=>({[aG]:t.protocolVersion,[aK]:t.clientInfo,[aX]:t.clientCapabilities,...void 0!==t.logLevel&&{[a0]:t.logLevel}}),validateEnvelopeMeta(t){let r=[];for(let i of cz)i in t||r.push({key:i,problem:"missing"});let i=cd().RequestMetaEnvelopeSchema.safeParse(t);if(!i.success)for(let t of i.error.issues){let i=t.path.map(String),n=i.length>0?i.join("."):"_meta";1===i.length&&r.some(t=>t.key===n&&"missing"===t.problem)||r.push({key:n,problem:t.message})}return r},projectCallToolResult:t=>l2(t),inputRequestSchema:cC,decodeResult(t,r){if(!cq(r))return{kind:"invalid",error:new lG(lW.InvalidResult,`Invalid result for ${t}: not an object`,{method:t})};let i=r.resultType;if(void 0===i)return{kind:"invalid",error:new lG(lW.InvalidResult,`Invalid result for ${t}: missing required resultType — servers implementing protocol revision 2026-07-28 MUST include it (the absent-means-complete bridge applies only to earlier-revision servers)`,{method:t,violation:"missing-resultType"})};if("string"!=typeof i)return{kind:"invalid",error:new lG(lW.InvalidResult,`Invalid result for ${t}: non-string resultType`,{method:t,resultType:i})};if("input_required"===i){let i=r.inputRequests,n=cq(i)?i:{},a=r.requestState,o=void 0===r._meta?void 0:cd().ResultMetaSchema.safeParse(r._meta),s=o?.success?o.data:void 0;return 0===Object.keys(n).length&&"string"!=typeof a?{kind:"invalid",error:new lG(lW.InvalidResult,`Invalid result for ${t}: input_required carries neither inputRequests nor requestState (every input_required result must include at least one of the two)`,{method:t,violation:"input-required-missing-both"})}:{kind:"input_required",inputRequests:n,..."string"==typeof a&&{requestState:a},...void 0!==s&&{_meta:s}}}if("complete"!==i)return{kind:"invalid",error:new lG(lW.UnsupportedResultType,`Unsupported result type '${i}' for ${t}`,{resultType:i,method:t})};let n=cM(),a=Object.hasOwn(n,t)?n[t]:void 0;if(void 0!==a){let i=a.safeParse(r);if(!i.success)return{kind:"invalid",error:new lG(lW.InvalidResult,`Invalid result for ${t}: ${i.error}`,{method:t})}}let o={...r};return delete o.resultType,{kind:"complete",result:o}},encodeResult:(t,r,i)=>(function(t,r){if(void 0===r)return t;let i=t._meta;return void 0===i?{...t,_meta:{[aY]:r}}:null===i||"object"!=typeof i||Array.isArray(i)||void 0!==i[aY]?t:{...t,_meta:{...i,[aY]:r}}})(function(t,r){var i,n;let a=r[cm];if("complete"!==r.resultType||!cp.includes(t)){let t;return void 0===a?r:(t={...r},delete t[cm],t)}let o=cf(r.ttlMs)?r.ttlMs:void 0!==(i=a)&&cf(i.ttlMs)?i.ttlMs:0,s=cg(r.cacheScope)?r.cacheScope:void 0!==(n=a)&&cg(n.cacheScope)?n.cacheScope:"private",l={...r,ttlMs:o,cacheScope:s};return delete l[cm],l}(t,function(t,r){let i=r.resultType;if(void 0===i)return{...r,resultType:"complete"};if("complete"===i||ck.includes(t))return r;throw new c_(cv.InternalError,`Handler for ${t} returned resultType '${String(i)}', but results of ${t} only support 'complete' on protocol revision 2026-07-28`)}(t,function(t,r){let i=r,n=!1,a=()=>(n||(i={...i},n=!0),i),o=r.tools;"tools/list"===t&&Array.isArray(o)&&o.some(t=>cq(t)&&"execution"in t)&&(a().tools=o.map(t=>{if(!cq(t)||!("execution"in t))return t;let r={...t};return delete r.execution,r}));let s=r.capabilities;if(cq(s)&&"tasks"in s){let t={...s};delete t.tasks,a().capabilities=t}return i}(t,r))),i),encodeErrorCode:t=>-32002===t?-32602:t,checkInboundEnvelope(t){if(void 0===t.envelope)return"Request is missing the required _meta envelope for protocol revision 2026-07-28 (io.modelcontextprotocol/protocolVersion, io.modelcontextprotocol/clientCapabilities)";let r=cd().RequestMetaEnvelopeSchema.safeParse(t.envelope);if(!r.success)return`Invalid _meta envelope for protocol revision 2026-07-28: ${r.error.issues.map(t=>t.message).join("; ")}`}};function cM(){if(s)return s;let t=cd();return s={"tools/call":t.CallToolResultSchema,"tools/list":t.ListToolsResultSchema,"prompts/get":t.GetPromptResultSchema,"prompts/list":t.ListPromptsResultSchema,"resources/list":t.ListResourcesResultSchema,"resources/templates/list":t.ListResourceTemplatesResultSchema,"resources/read":t.ReadResourceResultSchema,"completion/complete":t.CompleteResultSchema,"server/discover":t.DiscoverResultSchema}}let cL="2026-07-28";function cZ(t){return void 0!==t&&t>=lQ?cN:cu}function cU(t){return void 0!==t.revision?cZ(t.revision).era:"modern"===t.era?cN.era:cu.era}function cF(t){return cJ.some(r=>r.hasRequestMethod(t))}function cD(t){return cJ.some(r=>r.hasNotificationMethod(t))}function cH(t){return"tasks/get"===t||"tasks/cancel"===t}let cJ=[cu,cN];function cV(t){return null!==t&&"object"==typeof t&&!Array.isArray(t)}function cB(t){if(!cV(t))return;let r=t._meta;return cV(r)?r:void 0}function cW(t){let r=cB(t);return void 0!==r&&aG in r}function cG(t){let r=cB(t)?.[aG];return"string"==typeof r?r:void 0}function cK(t){return cZ(cL).validateEnvelopeMeta(t)}var cY=((t,r)=>{let i={};for(var n in t)J(i,n,{get:t[n],enumerable:!0});return r&&J(i,Symbol.toStringTag,{value:"Module"}),i})({AnnotationsSchema:()=>oH,AudioContentSchema:()=>su,BaseMetadataSchema:()=>ov,BaseRequestParamsSchema:()=>a8,BlobResourceContentsSchema:()=>oF,BooleanSchemaSchema:()=>sJ,CallToolRequestParamsSchema:()=>sx,CallToolRequestSchema:()=>s$,CallToolResultSchema:()=>sR,CancelTaskRequestSchema:()=>lS,CancelTaskResultSchema:()=>lw,CancelledNotificationParamsSchema:()=>oh,CancelledNotificationSchema:()=>of,ClientCapabilitiesSchema:()=>ok,ClientNotificationSchema:()=>lk,ClientRequestSchema:()=>lR,ClientResultSchema:()=>lx,ClientTasksCapabilitySchema:()=>ow,CompatibilityCallToolResultSchema:()=>sk,CompleteRequestParamsSchema:()=>lr,CompleteRequestSchema:()=>li,CompleteResultSchema:()=>ln,ContentBlockSchema:()=>sh,CreateMessageRequestParamsSchema:()=>sU,CreateMessageRequestSchema:()=>sF,CreateMessageResultSchema:()=>sD,CreateMessageResultWithToolsSchema:()=>sH,CreateTaskResultSchema:()=>lp,CursorSchema:()=>a3,DiscoverRequestSchema:()=>oP,DiscoverResultSchema:()=>oO,ElicitRequestFormParamsSchema:()=>s9,ElicitRequestParamsSchema:()=>s3,ElicitRequestSchema:()=>s6,ElicitRequestURLParamsSchema:()=>s4,ElicitResultSchema:()=>s8,ElicitationCompleteNotificationParamsSchema:()=>s5,ElicitationCompleteNotificationSchema:()=>s7,EmbeddedResourceSchema:()=>sp,EmptyResultSchema:()=>om,EnumSchemaSchema:()=>s1,GetPromptRequestParamsSchema:()=>so,GetPromptRequestSchema:()=>ss,GetPromptResultSchema:()=>sg,GetTaskPayloadRequestSchema:()=>ly,GetTaskPayloadResultSchema:()=>lv,GetTaskRequestSchema:()=>lf,GetTaskResultSchema:()=>lg,IconSchema:()=>og,IconsSchema:()=>oy,ImageContentSchema:()=>sc,ImplementationSchema:()=>o_,InitializeRequestParamsSchema:()=>ox,InitializeRequestSchema:()=>o$,InitializeResultSchema:()=>oC,InitializedNotificationSchema:()=>oE,JSONArraySchema:()=>a9,JSONObjectSchema:()=>a2,JSONRPCErrorResponseSchema:()=>ou,JSONRPCMessageSchema:()=>od,JSONRPCNotificationSchema:()=>ol,JSONRPCRequestSchema:()=>os,JSONRPCResponseSchema:()=>op,JSONRPCResultResponseSchema:()=>oc,JSONValueSchema:()=>a1,LegacyTitledEnumSchemaSchema:()=>sK,ListChangedOptionsBaseSchema:()=>sC,ListPromptsRequestSchema:()=>sn,ListPromptsResultSchema:()=>sa,ListResourceTemplatesRequestSchema:()=>oG,ListResourceTemplatesResultSchema:()=>oK,ListResourcesRequestSchema:()=>oB,ListResourcesResultSchema:()=>oW,ListRootsRequestSchema:()=>lo,ListRootsResultSchema:()=>ls,ListTasksRequestSchema:()=>l_,ListTasksResultSchema:()=>lb,ListToolsRequestSchema:()=>sS,ListToolsResultSchema:()=>sw,LoggingLevelSchema:()=>sE,LoggingMessageNotificationParamsSchema:()=>sI,LoggingMessageNotificationSchema:()=>sq,ModelHintSchema:()=>sj,ModelPreferencesSchema:()=>sA,MultiSelectEnumSchemaSchema:()=>s0,NotificationSchema:()=>oi,NotificationsParamsSchema:()=>or,NumberSchemaSchema:()=>sB,PaginatedRequestParamsSchema:()=>oz,PaginatedRequestSchema:()=>oN,PaginatedResultSchema:()=>oM,PingRequestSchema:()=>oI,PrimitiveSchemaDefinitionSchema:()=>s2,ProgressNotificationParamsSchema:()=>oj,ProgressNotificationSchema:()=>oA,ProgressSchema:()=>oq,ProgressTokenSchema:()=>a4,PromptArgumentSchema:()=>sr,PromptListChangedNotificationSchema:()=>sy,PromptMessageSchema:()=>sf,PromptReferenceSchema:()=>lt,PromptSchema:()=>si,ReadResourceRequestParamsSchema:()=>oY,ReadResourceRequestSchema:()=>oX,ReadResourceResultSchema:()=>oQ,RelatedTaskMetadataSchema:()=>a5,RequestIdSchema:()=>oo,RequestMetaSchema:()=>a7,RequestSchema:()=>ot,ResourceContentsSchema:()=>oL,ResourceLinkSchema:()=>sm,ResourceListChangedNotificationSchema:()=>o0,ResourceRequestParamsSchema:()=>oY,ResourceSchema:()=>oJ,ResourceTemplateReferenceSchema:()=>le,ResourceTemplateSchema:()=>oV,ResourceUpdatedNotificationParamsSchema:()=>se,ResourceUpdatedNotificationSchema:()=>st,ResultMetaObjectSchema:()=>on,ResultSchema:()=>oa,RoleSchema:()=>oD,RootSchema:()=>la,RootsListChangedNotificationSchema:()=>ll,SamplingContentSchema:()=>sM,SamplingMessageContentBlockSchema:()=>sL,SamplingMessageSchema:()=>sZ,ServerCapabilitiesSchema:()=>oT,ServerNotificationSchema:()=>lT,ServerRequestSchema:()=>l$,ServerResultSchema:()=>lC,ServerTasksCapabilitySchema:()=>oR,SetLevelRequestParamsSchema:()=>sP,SetLevelRequestSchema:()=>sO,SingleSelectEnumSchemaSchema:()=>sY,StringSchemaSchema:()=>sV,SubscribeRequestParamsSchema:()=>oY,SubscribeRequestSchema:()=>o1,SubscriptionFilterSchema:()=>o9,SubscriptionsAcknowledgedNotificationParamsSchema:()=>o6,SubscriptionsAcknowledgedNotificationSchema:()=>o5,SubscriptionsListenRequestParamsSchema:()=>o4,SubscriptionsListenRequestSchema:()=>o3,SubscriptionsListenResultMetaSchema:()=>o7,SubscriptionsListenResultSchema:()=>o8,TaskAugmentedRequestParamsSchema:()=>oe,TaskCreationParamsSchema:()=>lc,TaskMetadataSchema:()=>a6,TaskSchema:()=>ld,TaskStatusNotificationParamsSchema:()=>lm,TaskStatusNotificationSchema:()=>lh,TaskStatusSchema:()=>lu,TextContentSchema:()=>sl,TextResourceContentsSchema:()=>oZ,TitledMultiSelectEnumSchemaSchema:()=>sQ,TitledSingleSelectEnumSchemaSchema:()=>sG,ToolAnnotationsSchema:()=>sv,ToolChoiceSchema:()=>sz,ToolExecutionSchema:()=>s_,ToolListChangedNotificationSchema:()=>sT,ToolResultContentSchema:()=>sN,ToolSchema:()=>sb,ToolUseContentSchema:()=>sd,UnsubscribeRequestParamsSchema:()=>oY,UnsubscribeRequestSchema:()=>o2,UntitledMultiSelectEnumSchemaSchema:()=>sX,UntitledSingleSelectEnumSchemaSchema:()=>sW});let cX=t=>os.safeParse(t).success,cQ=t=>ol.safeParse(t).success,c0=t=>oc.safeParse(t).success,c1=t=>ou.safeParse(t).success,c2=t=>"object"==typeof t&&null!==t&&!Array.isArray(t)&&"input_required"===t.resultType,c9="x-mcp-header",c4=/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/,c3=new Set(["string","integer","boolean","number"]);function c6(t){let r=[],i=new Map,n=(t,a,o)=>{if(null===t||"object"!=typeof t)return;if(c9 in t){if(!o||0===a.length)return`${c8(a)}: x-mcp-header is only permitted on properties statically reachable via a chain of 'properties' keys (not under items, additionalProperties, oneOf/anyOf/allOf/not, if/then/else, or $ref)`;let n=t[c9];if("string"!=typeof n||0===n.length)return`${c8(a)}: x-mcp-header MUST be a non-empty string`;if(!c4.test(n))return`${c8(a)}: x-mcp-header '${n}' is not a valid RFC 9110 token (no spaces, control characters or HTTP delimiters)`;let s="string"==typeof t.type?t.type:void 0;if(void 0===s||!c3.has(s))return`${c8(a)}: x-mcp-header is only permitted on primitive-typed properties (string, integer, boolean); got ${s??"<none>"}`;let l=n.toLowerCase(),c=i.get(l);if(void 0!==c)return`x-mcp-header '${n}' is not case-insensitively unique (also declared as '${c}')`;i.set(l,n),r.push({path:a,headerName:n,type:s})}let s=t.properties;if(null!==s&&"object"==typeof s)for(let[t,r]of Object.entries(s)){let i=n(r,[...a,t],o);if(void 0!==i)return i}for(let r of c5){let i=t[r];if(void 0!==i)for(let t of Array.isArray(i)?i:null!==i&&"object"==typeof i&&c7.has(r)?Object.values(i):[i]){let i=n(t,[...a,`<${r}>`],!1);if(void 0!==i)return i}}},a=n(t,[],!0);return void 0===a?{valid:!0,declarations:r}:{valid:!1,reason:a}}let c5=["items","prefixItems","contains","additionalProperties","unevaluatedProperties","unevaluatedItems","propertyNames","patternProperties","dependentSchemas","oneOf","anyOf","allOf","not","if","then","else","$defs","definitions"],c7=new Set(["patternProperties","dependentSchemas","$defs","definitions"]);function c8(t){return 0===t.length?"<root>":t.join(".")}let ue=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/,ut=/^-?\d+(\.\d+)?$/;function ur(t){if(!(t.startsWith("=?base64?")&&t.endsWith("?=")))return t;let r=t.slice(9,t.length-2);if(ue.test(r))try{let t=atob(r),i=new Uint8Array(t.length);for(let r=0;r<t.length;r++)i[r]=t.codePointAt(r);return new TextDecoder("utf-8",{fatal:!0}).decode(i)}catch{return}}function ui(t,r,i){return{kind:"reject",rung:"param-header-validation",cell:t,httpStatus:400,code:un,message:`Bad Request: the request headers and body disagree: ${i}`,data:{mismatch:{header:r,body:i}},settled:!0}}let un=-32020;cv.InvalidRequest,cv.UnsupportedProtocolVersion,cv.InvalidParams,cv.MethodNotFound,cv.InvalidParams,cv.MissingRequiredClientCapability;let ua={[cv.ParseError]:400,[cv.InvalidRequest]:400,[cv.MethodNotFound]:404,[cv.UnsupportedProtocolVersion]:400,[cv.MissingRequiredClientCapability]:400,[un]:400};function uo(t,r,i,n,a){return{kind:"reject",rung:t,cell:r,httpStatus:i,code:n.code,message:n.message,...void 0!==n.data&&{data:n.data},settled:a}}function us(t,r,i,n="era-classification"){return uo(n,t,400,new c_(un,`Bad Request: the request headers and body disagree: ${i}`,{mismatch:{header:r,body:i}}),!0)}let ul={"tools/call":"name","prompts/get":"name","resources/read":"uri","tasks/get":"taskId","tasks/update":"taskId","tasks/cancel":"taskId"};function uc(t){let r=0;for(;r<t.length;){let i=t.codePointAt(r);if(9!==i&&32!==i)break;r+=1}let i=t.length;for(;i>r;){let r=t.codePointAt(i-1);if(9!==r&&32!==r)break;i-=1}return 0===r&&i===t.length?t:t.slice(r,i)}function uu(t){return null!==t&&"object"==typeof t&&!Array.isArray(t)}function ud(t){return void 0===t?{era:"modern"}:{era:t>=lQ?"modern":"legacy",revision:t}}function up(t){return new Set(t.flatMap(t=>Object.keys(t.shape)))}function um(t){if(null==t)return!1;let r=typeof t;return("object"===r||"function"===r)&&"~standard"in t&&"function"==typeof t["~standard"]?.validate}let uh=!1,uf="draft-2020-12";function ug(t,r="input"){let i,n=t["~standard"];if(n.jsonSchema)i=n.jsonSchema[r]({target:uf});else if("zod"===n.vendor){if(!("_zod"in t))throw Error("Schema appears to be from zod 3, which the SDK cannot convert to JSON Schema. Upgrade to zod >=4.2.0, or wrap your JSON Schema with fromJsonSchema().");uh||(uh=!0,console.warn("[mcp-sdk] Your zod version does not implement `~standard.jsonSchema` (added in zod 4.2.0). Falling back to z.toJSONSchema(). Upgrade to zod >=4.2.0 to silence this warning.")),i=nn(t,{target:uf,io:r})}else throw Error(`Schema library "${n.vendor}" does not implement StandardJSONSchemaV1 (\`~standard.jsonSchema\`). Upgrade to a version that does, or wrap your JSON Schema with fromJsonSchema().`);if("output"===r)return void 0!==i.type||!function t(r){if("properties"in r||"patternProperties"in r||"additionalProperties"in r||"required"in r)return!0;for(let i of["oneOf","anyOf","allOf"]){let n=r[i];if(Array.isArray(n)&&n.length>0)return n.every(r=>null!==r&&"object"==typeof r&&("object"===r.type||t(r)))}return!1}(i)?i:{type:"object",...i};if(void 0!==i.type&&"object"!==i.type)throw Error(`MCP tool and prompt schemas must describe objects (got type: ${JSON.stringify(i.type)}). Wrap your schema in z.object({...}) or equivalent.`);return{type:"object",...i}}async function uy(t,r){let i=await t["~standard"].validate(r);return i.issues&&i.issues.length>0?{success:!1,error:i.issues.map(t=>t.path?.length?`${t.path.map(t=>String("object"==typeof t?t.key:t)).join(".")}: ${t.message}`:t.message).join(", ")}:{success:!0,data:i.value}}let uv=/\\\.\\d\{(\d+)\}/;function u_(t){return"object"==typeof t&&null!==t&&!Array.isArray(t)}let ub=new Set(["$comment","deprecated","description","examples","readOnly","title","writeOnly"]);function uS(t){return ub.has(t)||t.startsWith("x-")}let uw=new Set(["$schema",...Object.keys(s9.shape.requestedSchema.shape)]),uR={string:up([sV,sW,sG,sK]),number:up([sB]),integer:up([sB]),boolean:up([sJ]),array:up([sX,sQ])},uk=new Set(sV.shape.format.unwrap().options);Object.assign(function(t){let r=void 0!==t.inputRequests&&Object.keys(t.inputRequests).length>0,i="string"==typeof t.requestState;if(!r&&!i)throw TypeError("inputRequired() requires at least one of inputRequests (with at least one entry) or requestState (spec: every InputRequiredResult MUST include at least one of the two)");return{resultType:"input_required",...void 0!==t.inputRequests&&{inputRequests:t.inputRequests},...void 0!==t.requestState&&{requestState:t.requestState}}},{elicit(t){try{return{method:"elicitation/create",params:function(t){var r;if(!um(t.requestedSchema))return{...t,mode:"form",requestedSchema:t.requestedSchema};let i=t.requestedSchema["~standard"].vendor,n=function(t,r){let i={},n=[];for(let[a,o]of Object.entries(t))"properties"===a&&u_(o)?i[a]=Object.fromEntries(Object.entries(o).map(([t,i])=>[t,function(t,r,i,n){if(!u_(t))return t;let a="string"==typeof t.type&&Object.hasOwn(uR,t.type)?uR[t.type]:void 0;if(void 0===a)return t;let o={};for(let[l,c]of Object.entries(t))if(a.has(l)||uS(l))o[l]=c;else if("pattern"===l&&"string"===t.type&&"string"==typeof t.format)if(uk.has(t.format)){var s;"string"==typeof c&&(s=t.format,"zod"!==i||(function(t,r){let i;switch(t){case"email":i=[r6(nH,void 0)];break;case"uri":i=[r5(nB,void 0)];break;case"date":i=[r8(nU,void 0)];break;case"date-time":let n,a;n=uv.exec(r),a=[void 0,-1,0],n&&a.push(Number(n[1])),i=[!1,!0].flatMap(t=>[!1,!0].flatMap(r=>a.map(i=>r7(nZ,{local:t,offset:r,precision:i}))))}return new Set(i.map(t=>{let r;return r=nn(t,{target:uf,io:"input"}),"string"==typeof r.pattern?r.pattern:void 0}).filter(t=>void 0!==t))})(s,c).has(c))||n.push(`${r}.${l}`)}else o[l]=c;else n.push(`${r}.${l}`);return o}(i,`properties.${t}`,r,n)])):uw.has(a)?i[a]=o:uS(a)||n.push(a);if(n.length>0)throw new c_(cv.InvalidParams,`Elicitation requestedSchema contains unsupported JSON Schema constraint(s) after Standard Schema conversion: ${n.join(", ")}`);return i}(function(t){try{return ug(t,"input")}catch(r){let t=r instanceof Error?r.message:String(r);throw new c_(cv.InvalidParams,`Elicitation requestedSchema must describe an object with flat primitive properties: ${t}`)}}(t.requestedSchema),i),a=(r=s9.shape.requestedSchema,nk(r,n));if(!a.success)throw new c_(cv.InvalidParams,`Elicitation requestedSchema only supports flat primitive properties (string, number, integer, boolean, and string enums): ${function(t,r){if(!u_(t.properties))return r;let i=Object.entries(t.properties).filter(([,t])=>!nk(s2,t).success).map(([t])=>`properties.${t}`);return i.length>0?i.join(", "):r}(n,a.error.message)}`);let o=function t(r,i,n=""){return Array.isArray(r)&&Array.isArray(i)?r.flatMap((r,a)=>t(r,i[a],`${n}[${a}]`)):u_(r)&&u_(i)?Object.entries(r).flatMap(([r,a])=>{let o=n?`${n}.${r}`:r;return Object.prototype.hasOwnProperty.call(i,r)?t(a,i[r],o):uS(r)?[]:[o]}):[]}(n,a.data);if(o.length>0)throw new c_(cv.InvalidParams,`Elicitation requestedSchema contains unsupported JSON Schema constraint(s) after Standard Schema conversion: ${o.join(", ")}`);let s=(a.data.required??[]).filter(t=>!Object.prototype.hasOwnProperty.call(a.data.properties,t));if(s.length>0)throw new c_(cv.InvalidParams,`Elicitation requestedSchema lists required properties that are not defined in properties: ${s.join(", ")}`);return{...t,mode:"form",requestedSchema:a.data}}(t)}}catch(t){throw t instanceof c_?TypeError(t.message,{cause:t}):t}},elicitUrl:t=>({method:"elicitation/create",params:{...t,mode:"url"}}),createMessage:t=>({method:"sampling/createMessage",params:t}),listRoots:()=>({method:"roots/list"})});let ux={},u$={};function uT(t,r){let i=t.slice(0,-6);ux[i]=r,u$[i]=t=>r.safeParse(t).success}for(let t of["AnnotationsSchema","AudioContentSchema","BaseMetadataSchema","BlobResourceContentsSchema","BooleanSchemaSchema","CallToolRequestSchema","CallToolRequestParamsSchema","CallToolResultSchema","CancelledNotificationSchema","CancelledNotificationParamsSchema","CancelTaskRequestSchema","CancelTaskResultSchema","ClientCapabilitiesSchema","ClientNotificationSchema","ClientRequestSchema","ClientResultSchema","CompatibilityCallToolResultSchema","CompleteRequestSchema","CompleteRequestParamsSchema","CompleteResultSchema","ContentBlockSchema","CreateMessageRequestSchema","CreateMessageRequestParamsSchema","CreateMessageResultSchema","CreateMessageResultWithToolsSchema","CreateTaskResultSchema","CursorSchema","DiscoverRequestSchema","DiscoverResultSchema","ElicitationCompleteNotificationSchema","ElicitationCompleteNotificationParamsSchema","ElicitRequestSchema","ElicitRequestFormParamsSchema","ElicitRequestParamsSchema","ElicitRequestURLParamsSchema","ElicitResultSchema","EmbeddedResourceSchema","EmptyResultSchema","EnumSchemaSchema","GetPromptRequestSchema","GetPromptRequestParamsSchema","GetPromptResultSchema","GetTaskPayloadRequestSchema","GetTaskPayloadResultSchema","GetTaskRequestSchema","GetTaskResultSchema","IconSchema","IconsSchema","ImageContentSchema","ImplementationSchema","InitializedNotificationSchema","InitializeRequestSchema","InitializeRequestParamsSchema","InitializeResultSchema","JSONArraySchema","JSONObjectSchema","JSONRPCErrorResponseSchema","JSONRPCMessageSchema","JSONRPCNotificationSchema","JSONRPCRequestSchema","JSONRPCResponseSchema","JSONRPCResultResponseSchema","JSONValueSchema","LegacyTitledEnumSchemaSchema","ListPromptsRequestSchema","ListPromptsResultSchema","ListResourcesRequestSchema","ListResourcesResultSchema","ListResourceTemplatesRequestSchema","ListResourceTemplatesResultSchema","ListRootsRequestSchema","ListRootsResultSchema","ListTasksRequestSchema","ListTasksResultSchema","ListToolsRequestSchema","ListToolsResultSchema","LoggingLevelSchema","LoggingMessageNotificationSchema","LoggingMessageNotificationParamsSchema","ModelHintSchema","ModelPreferencesSchema","MultiSelectEnumSchemaSchema","NotificationSchema","NumberSchemaSchema","PaginatedRequestSchema","PaginatedRequestParamsSchema","PaginatedResultSchema","PingRequestSchema","PrimitiveSchemaDefinitionSchema","ProgressSchema","ProgressNotificationSchema","ProgressNotificationParamsSchema","ProgressTokenSchema","PromptSchema","PromptArgumentSchema","PromptListChangedNotificationSchema","PromptMessageSchema","PromptReferenceSchema","ReadResourceRequestSchema","ReadResourceRequestParamsSchema","ReadResourceResultSchema","RelatedTaskMetadataSchema","RequestSchema","RequestIdSchema","RequestMetaSchema","ResourceSchema","ResourceContentsSchema","ResourceLinkSchema","ResourceListChangedNotificationSchema","ResourceRequestParamsSchema","ResourceTemplateSchema","ResourceTemplateReferenceSchema","ResourceUpdatedNotificationSchema","ResourceUpdatedNotificationParamsSchema","ResultMetaObjectSchema","ResultSchema","RoleSchema","RootSchema","RootsListChangedNotificationSchema","SamplingContentSchema","SamplingMessageSchema","SamplingMessageContentBlockSchema","ServerCapabilitiesSchema","ServerNotificationSchema","ServerRequestSchema","ServerResultSchema","SetLevelRequestSchema","SetLevelRequestParamsSchema","SingleSelectEnumSchemaSchema","StringSchemaSchema","SubscribeRequestSchema","SubscribeRequestParamsSchema","SubscriptionFilterSchema","SubscriptionsAcknowledgedNotificationSchema","SubscriptionsAcknowledgedNotificationParamsSchema","SubscriptionsListenRequestSchema","SubscriptionsListenRequestParamsSchema","SubscriptionsListenResultSchema","SubscriptionsListenResultMetaSchema","TaskAugmentedRequestParamsSchema","TaskCreationParamsSchema","TaskMetadataSchema","TaskSchema","TaskStatusSchema","TaskStatusNotificationSchema","TaskStatusNotificationParamsSchema","TextContentSchema","TextResourceContentsSchema","TitledMultiSelectEnumSchemaSchema","TitledSingleSelectEnumSchemaSchema","ToolSchema","ToolAnnotationsSchema","ToolChoiceSchema","ToolExecutionSchema","ToolListChangedNotificationSchema","ToolResultContentSchema","ToolUseContentSchema","UnsubscribeRequestSchema","UnsubscribeRequestParamsSchema","UntitledMultiSelectEnumSchemaSchema","UntitledSingleSelectEnumSchemaSchema"])uT(t,cY[t]);for(let[t,r]of Object.entries({IdJagTokenExchangeResponseSchema:lA,OAuthClientInformationFullSchema:lZ,OAuthClientInformationSchema:lL,OAuthClientMetadataSchema:lM,OAuthClientRegistrationErrorSchema:lU,OAuthErrorResponseSchema:lz,OAuthMetadataSchema:lO,OAuthProtectedResourceMetadataSchema:lP,OAuthTokenRevocationRequestSchema:lF,OAuthTokensSchema:lj,OpenIdProviderDiscoveryMetadataSchema:lq,OpenIdProviderMetadataSchema:lI}))uT(t,r);let uC=Object.freeze(ux);Object.freeze(u$);let uE=[aG,aK,aX,a0],uP=["inputResponses","requestState"];function uO(t,r){let i=t.params;if(!uz(i))return{message:t,lifted:{}};let n=i._meta,a=uz(n)?uE.filter(t=>t in n):[],o="request"===r?uP.filter(t=>t in i):[];if(0===a.length&&0===o.length)return{message:t,lifted:{}};let s={},l={...i};if(a.length>0&&uz(n)){let t={},r={...n};for(let i of a)t[i]=n[i],delete r[i];s.envelope=t,Object.keys(r).length>0?l._meta=r:delete l._meta}for(let t of o)"inputResponses"===t&&(s.inputResponses=l[t]),"requestState"===t&&(s.requestState=l[t]),delete l[t];return{message:{...t,params:l},lifted:s}}function uI(t,r){let i=t.validateResult(r,void 0);if(i.ok||"not-in-era"!==i.reason)return{"~standard":{version:1,vendor:"mcp-wire-codec",validate(i){let n=t.validateResult(r,i);return n.ok?{value:n.value}:{issues:[{message:"invalid"===n.reason?n.message:`not-in-era: ${r}`}]}}}}}let uq=(E=void 0,()=>E);function uj(t,r){return{...t,mcpReq:{...t.mcpReq,requestState:()=>r}}}var uA=class{_transport;_requestMessageId=0;_requestHandlers=new Map;_customSchemaRequestMethods=new Set;_requestHandlerAbortControllers=new Map;_notificationHandlers=new Map;_responseHandlers=new Map;_progressHandlers=new Map;_timeoutInfo=new Map;_pendingDebouncedNotifications=new Set;_negotiatedProtocolVersion;static{l=(t,r)=>{t._negotiatedProtocolVersion=r}}_supportedProtocolVersions;onclose;onerror;fallbackRequestHandler;fallbackNotificationHandler;constructor(t){this._options=t,this._supportedProtocolVersions=t?.supportedProtocolVersions??aW,this.setNotificationHandler("notifications/cancelled",t=>{this._oncancel(t)}),this.setNotificationHandler("notifications/progress",t=>{this._onprogress(t)}),this.setRequestHandler("ping",t=>({}))}_shouldDropInbound(t){}_outboundMetaEnvelope(){}_envelopeOutbound(t){let r=this._outboundMetaEnvelope();if(void 0===r)return t;let i=t.params??{};return{...t,params:{...i,_meta:{...r,...i._meta}}}}_resolveNonCompleteResult(t,r){return Promise.reject(new lG(lW.UnsupportedResultType,`Unsupported result type '${t.kind}' for ${r.request.method}`,{resultType:t.kind,method:r.request.method}))}_getRequestHandler(t){return this._requestHandlers.get(t)}async _oncancel(t){void 0!==t.params.requestId&&this._requestHandlerAbortControllers.get(t.params.requestId)?.abort(t.params.reason)}_setupTimeout(t,r,i,n,a=!1){this._timeoutInfo.set(t,{timeoutId:setTimeout(n,r),startTime:Date.now(),timeout:r,maxTotalTimeout:i,resetTimeoutOnProgress:a,onTimeout:n})}_resetTimeout(t){let r=this._timeoutInfo.get(t);if(!r)return!1;let i=Date.now()-r.startTime;if(r.maxTotalTimeout&&i>=r.maxTotalTimeout)throw this._timeoutInfo.delete(t),new lG(lW.RequestTimeout,"Maximum total timeout exceeded",{maxTotalTimeout:r.maxTotalTimeout,totalElapsed:i});return clearTimeout(r.timeoutId),r.timeoutId=setTimeout(r.onTimeout,r.timeout),!0}_cleanupTimeout(t){let r=this._timeoutInfo.get(t);r&&(clearTimeout(r.timeoutId),this._timeoutInfo.delete(t))}async connect(t){this._transport=t;let r=this.transport?.onclose;this._transport.onclose=()=>{try{r?.()}finally{this._onclose()}};let i=this.transport?.onerror;this._transport.onerror=t=>{i?.(t),this._onerror(t)};let n=this._transport?.onmessage;this._transport.onmessage=(t,r)=>{n?.(t,r),c0(t)||c1(t)?this._onresponse(t):cX(t)?this._onrequest(t,r):cQ(t)?this._onnotification(t,r):this._onerror(Error(`Unknown message type: ${JSON.stringify(t)}`))},t.setSupportedProtocolVersions?.(this._supportedProtocolVersions),await this._transport.start()}_onclose(){let t=this._responseHandlers;for(let t of(this._responseHandlers=new Map,this._progressHandlers.clear(),this._pendingDebouncedNotifications.clear(),this._timeoutInfo.values()))clearTimeout(t.timeoutId);this._timeoutInfo.clear();let r=this._requestHandlerAbortControllers;this._requestHandlerAbortControllers=new Map;let i=new lG(lW.ConnectionClosed,"Connection closed");this._transport=void 0;try{this.onclose?.()}finally{for(let r of t.values())r(i);for(let t of r.values())t.abort(i)}}_onerror(t){this.onerror?.(t)}_onnotification(t,r){let{message:i}=uO(t,"notification"),n=this._negotiatedWireCodec();if(r?.classification===void 0&&"drop"===this._shouldDropInbound(t))return;if(r?.classification!==void 0){let t=cU(r.classification);if(t!==n.era)return void this._onerror(Error(`Era mismatch on inbound notification '${i.method}': classified as ${t} but this instance serves ${n.era}`))}if(cD(i.method)&&!n.hasNotificationMethod(i.method))return;let a=this._notificationHandlers.get(i.method),o=this.fallbackNotificationHandler;(void 0!==a||void 0!==o)&&Promise.resolve().then(()=>void 0===a?o(i):a(i,n)).catch(t=>this._onerror(Error(`Uncaught error in notification handler: ${t}`)))}_onrequest(t,r){var i;let{message:n,lifted:a}=uO(t,"request"),o=this._negotiatedWireCodec();if(r?.classification===void 0&&"drop"===this._shouldDropInbound(t))return void this._onerror(Error(`Dropped inbound request '${t.method}': not servable on this connection's protocol era`));let s=this._transport,l=(t,r,i)=>{let a={jsonrpc:"2.0",id:n.id,error:{code:t,message:r,...void 0!==i&&{data:i}}};s?.send(a).catch(t=>this._onerror(Error(`Failed to send an error response: ${t}`)))};if(r?.classification!==void 0){let t=cU(r.classification);if(t!==o.era){this._onerror(Error(`Era mismatch on inbound request '${n.method}': classified as ${t} but this instance serves ${o.era}`));let i=r.classification.revision??t;l(cv.UnsupportedProtocolVersion,`Unsupported protocol version: ${i}`,{supported:this._supportedProtocolVersions,requested:i});return}}if(cF(n.method)&&!o.hasRequestMethod(n.method)&&!(cH(n.method)&&this._customSchemaRequestMethods.has(n.method)))return void l(cv.MethodNotFound,"Method not found");let c=this._requestHandlers.get(n.method)??this.fallbackRequestHandler;if(void 0===c)return void l(cv.MethodNotFound,"Method not found");let u=o.checkInboundEnvelope(a);if(void 0!==u)return void l(cv.InvalidParams,u);let d=(t,r)=>this._notificationViaCodec(this._resolveOutboundCodec(t.method),t,{...r,relatedRequestId:n.id}),p=(t,r,i)=>this._requestWithSchemaViaCodec(this._resolveOutboundCodec(t.method),t,r,{...i,relatedRequestId:n.id}),m=new AbortController;this._requestHandlerAbortControllers.set(n.id,m);let h=void 0===a.inputResponses?void 0:function(t){let r={},i=[];if(!uN(t))return{accepted:r,droppedKeys:i};for(let[n,a]of Object.entries(t)){if(!uN(a)||"method"in a||"result"in a){i.push(n);continue}r[n]=a}return{accepted:r,droppedKeys:i}}(a.inputResponses),f={sessionId:s?.sessionId,mcpReq:{id:n.id,method:n.method,_meta:n.params?._meta,...void 0!==a.envelope&&{envelope:a.envelope},...void 0!==h&&{inputResponses:h.accepted},...void 0!==h&&h.droppedKeys.length>0&&{droppedInputResponseKeys:h.droppedKeys},requestState:void 0===a.requestState?uq:(i=a.requestState,()=>i),signal:m.signal,send:(t,r,i)=>{let n=this._resolveOutboundCodec(t.method);if(this._assertOutboundRequestInEra(n,t.method),um(r))return p(t,r,i);let a=uI(n,t.method);if(void 0===a)throw TypeError(`'${t.method}' is not a spec method; pass a result schema as the second argument to ctx.mcpReq.send().`);return p(t,a,r)},notify:d},http:r?.authInfo?{authInfo:r.authInfo}:void 0},g=this.buildContext(f,r);Promise.resolve().then(()=>c(n,g)).then(async t=>{let r;if(m.signal.aborted)return;try{r=o.encodeResult(n.method,t,this._outboundServerInfo())}catch(t){this._onerror(Error(`Failed to encode result for ${n.method}: ${t}`)),l(cv.InternalError,"Internal error");return}let i={result:r,jsonrpc:"2.0",id:n.id};await s?.send(i)},async t=>{if(m.signal.aborted)return;let r=Number.isSafeInteger(t.code)?t.code:cv.InternalError,i={jsonrpc:"2.0",id:n.id,error:{code:o.encodeErrorCode(r),message:t.message??"Internal error",...void 0!==t.data&&{data:t.data}}};await s?.send(i)}).catch(t=>this._onerror(Error(`Failed to send response: ${t}`))).finally(()=>{this._requestHandlerAbortControllers.get(n.id)===m&&this._requestHandlerAbortControllers.delete(n.id)})}_onprogress(t){let{progressToken:r,...i}=t.params,n=Number(r),a=this._progressHandlers.get(n);if(!a)return void this._onerror(Error(`Received a progress notification for an unknown token: ${JSON.stringify(t)}`));let o=this._responseHandlers.get(n),s=this._timeoutInfo.get(n);if(s&&o&&s.resetTimeoutOnProgress)try{this._resetTimeout(n)}catch(t){this._responseHandlers.delete(n),this._progressHandlers.delete(n),this._cleanupTimeout(n),o(t);return}a(i)}_onresponse(t){let r=Number(t.id),i=this._responseHandlers.get(r);void 0===i?this._onerror(Error(`Received a response for an unknown message ID: ${JSON.stringify(t)}`)):(this._responseHandlers.delete(r),this._cleanupTimeout(r),this._progressHandlers.delete(r),i(c0(t)?t:c_.fromError(t.error.code,t.error.message,t.error.data)))}get transport(){return this._transport}async close(){await this._transport?.close()}request(t,r,i){let n=this._resolveOutboundCodec(t.method);if(um(r))return cH(t.method)||this._assertOutboundRequestInEra(n,t.method),this._requestWithSchemaViaCodec(n,t,r,i);this._assertOutboundRequestInEra(n,t.method);let a=uI(n,t.method);if(void 0===a)throw TypeError(`'${t.method}' is not a spec method; pass a result schema as the second argument to request().`);return this._requestWithSchemaViaCodec(n,t,a,r)}_negotiatedWireCodec(){return cZ(this._negotiatedProtocolVersion)}_wireCodec(){return this._negotiatedWireCodec()}_resolveOutboundCodec(t){if(void 0===this._negotiatedProtocolVersion){let r=function(t){switch(t){case"initialize":case"notifications/initialized":return cZ(void 0);case"server/discover":return cZ(cL);default:return}}(t);if(r)return r}return this._negotiatedWireCodec()}_assertOutboundRequestInEra(t,r){if(cF(r)&&!t.hasRequestMethod(r))throw new lG(lW.MethodNotSupportedByProtocolVersion,`Method '${r}' is not supported by the negotiated protocol version (wire era ${t.era})`,{method:r,era:t.era})}_requestWithSchema(t,r,i){let n=this._resolveOutboundCodec(t.method);return this._assertOutboundRequestInEra(n,t.method),this._requestWithSchemaViaCodec(n,t,r,i)}_requestWithSchemaViaCodec(t,r,i,n){let a,o,{relatedRequestId:s,resumptionToken:l,onresumptiontoken:c,headers:u}=n??{},d=Date.now();return new Promise((p,m)=>{let h=t=>{m(t)};if(!this._transport)return void h(Error("Not connected"));if(this._options?.enforceStrictCapabilities===!0)try{this.assertCapabilityForMethod(r.method)}catch(t){h(t);return}if(n?.signal?.aborted){let t=n.signal.reason;throw t instanceof lG?t:new lG(lW.RequestTimeout,String(t))}let f=t.era===cL&&!0===this._transport.hasPerRequestStream?new AbortController:void 0,g=this._requestMessageId++;o=g;let y={...r,jsonrpc:"2.0",id:g};n?.onprogress&&(this._progressHandlers.set(g,n.onprogress),y.params={...r.params,_meta:{...r.params?._meta,progressToken:g}});let v=this._envelopeOutbound(y),_=!1,b=t=>{_||(this._progressHandlers.delete(g),void 0===f?"initialize"!==r.method&&this._transport?.send(this._envelopeOutbound({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:g,reason:String(t)}}),{relatedRequestId:s,resumptionToken:l,onresumptiontoken:c}).catch(t=>this._onerror(Error(`Failed to send cancellation: ${t}`))):f.abort(),m(t instanceof lG?t:new lG(lW.RequestTimeout,String(t))))};this._responseHandlers.set(g,a=>{let o;if(!n?.signal?.aborted){if(_=!0,a instanceof Error)return m(a);try{o=t.decodeResult(r.method,a.result)}catch(t){return m(t instanceof Error?t:Error(String(t)))}if("invalid"===o.kind)return m(o.error);if("input_required"===o.kind){var s;return n?.allowInputRequired===!0?p({resultType:"input_required",inputRequests:(s=o).inputRequests,...void 0!==s.requestState&&{requestState:s.requestState},...void 0!==s._meta&&{_meta:s._meta}}):p(this._resolveNonCompleteResult(o,{codec:t,request:r,resultSchema:i,options:n,flowStartedAt:d,retry:(n,a)=>this._requestWithSchemaViaCodec(t,void 0===n?{method:r.method}:{method:r.method,params:n},i,a)}))}uy(i,o.result).then(t=>{t.success?p(t.data):m(new lG(lW.InvalidResult,`Invalid result for ${r.method}: ${t.error}`))},m)}}),a=()=>b(n?.signal?.reason),n?.signal?.addEventListener("abort",a,{once:!0});let S=n?.timeout??6e4;this._setupTimeout(g,S,n?.maxTotalTimeout,()=>b(new lG(lW.RequestTimeout,"Request timed out",{timeout:S})),n?.resetTimeoutOnProgress??!1),this._transport.send(v,{relatedRequestId:s,resumptionToken:l,onresumptiontoken:c,headers:u,requestSignal:f?.signal}).catch(t=>{this._progressHandlers.delete(g),m(t)})}).finally(()=>{a&&n?.signal?.removeEventListener("abort",a),void 0!==o&&(this._responseHandlers.delete(o),this._cleanupTimeout(o))})}async notification(t,r){return await this._notificationViaCodec(this._resolveOutboundCodec(t.method),t,r)}async _notificationViaCodec(t,r,i){if(!this._transport)throw new lG(lW.NotConnected,"Not connected");if(cD(r.method)&&!t.hasNotificationMethod(r.method))throw new lG(lW.MethodNotSupportedByProtocolVersion,`Notification '${r.method}' is not supported by the negotiated protocol version (wire era ${t.era})`,{method:r.method,era:t.era});this.assertNotificationCapability(r.method);let n=this._envelopeOutbound({jsonrpc:"2.0",...r});if((this._options?.debouncedNotificationMethods??[]).includes(r.method)&&!r.params&&i?.relatedRequestId===void 0){if(this._pendingDebouncedNotifications.has(r.method))return;this._pendingDebouncedNotifications.add(r.method),Promise.resolve().then(()=>{this._pendingDebouncedNotifications.delete(r.method),this._transport&&this._transport?.send(n,i).catch(t=>this._onerror(t))});return}await this._transport.send(n,i)}setRequestHandler(t,r,i){let n;if(this.assertRequestHandlerCapability(t),"function"==typeof r){if(!cF(t))throw TypeError(`'${t}' is not a spec request method; pass schemas as the second argument to setRequestHandler().`);n=(i,n)=>{let a=this._negotiatedWireCodec(),o=a.validateRequest(t,i);if(o.ok||"not-in-era"!==o.reason||(o=a.validateInputRequest(t,i)),!o.ok){if("not-in-era"===o.reason)throw new c_(cv.InternalError,`No wire schema for ${t} in the resolved era`);throw Error(o.message)}return Promise.resolve(r(o.value,n))}}else if(i)n=async(n,a)=>{let o=await uy(r.params,{...n.params});if(!o.success)throw new c_(cv.InvalidParams,`Invalid params for ${t}: ${o.error}`);return i(o.data,a)};else throw TypeError("setRequestHandler: handler is required");"function"==typeof r?this._customSchemaRequestMethods.delete(t):this._customSchemaRequestMethods.add(t),this._requestHandlers.set(t,this._wrapHandler(t,n))}_wrapHandler(t,r){return r}_outboundServerInfo(){}removeRequestHandler(t){this._requestHandlers.delete(t),this._customSchemaRequestMethods.delete(t)}assertCanSetRequestHandler(t){if(this._requestHandlers.has(t))throw Error(`A request handler for ${t} already exists, which would be overridden`)}setNotificationHandler(t,r,i){if("function"==typeof r){if(!cD(t))throw TypeError(`'${t}' is not a spec notification method; pass schemas as the second argument to setNotificationHandler().`);this._notificationHandlers.set(t,(i,n)=>{let a=n.validateNotification(t,i);if(!a.ok){if("not-in-era"===a.reason)throw new c_(cv.InternalError,`No wire schema for ${t} in the resolved era`);throw Error(a.message)}return Promise.resolve(r(a.value))});return}if(!i)throw TypeError("setNotificationHandler: handler is required");this._notificationHandlers.set(t,async n=>{let a=await uy(r.params,{...n.params});if(!a.success)throw new c_(cv.InvalidParams,`Invalid params for notification ${t}: ${a.error}`);await i(a.data,n)})}removeNotificationHandler(t){this._notificationHandlers.delete(t)}};function uz(t){return null!==t&&"object"==typeof t&&!Array.isArray(t)}function uN(t){return"object"==typeof t&&null!==t&&!Array.isArray(t)}var uM=((t,r,i,n)=>{if(r&&"object"==typeof r||"function"==typeof r)for(var a,o=B(r),s=0,l=o.length;s<l;s++)a=o[s],G.call(t,a)||a===i||J(t,a,{get:(t=>r[t]).bind(null,a),enumerable:!(n=V(r,a))||n.enumerable});return t})(J(null!=(R=(S=t=>{var r=/; *([!#$%&'*+.^_`|~0-9A-Za-z-]+) *= *("(?:[\u000b\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\u000b\u0020-\u00ff])*"|[!#$%&'*+.^_`|~0-9A-Za-z-]+) */g,i=/\\([\u000b\u0020-\u00ff])/g,n=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/;function a(t){this.parameters=Object.create(null),this.type=t}t.parse=function(t){if(!t)throw TypeError("argument string is required");var o,s,l,c="object"==typeof t?function(t){var r;if("function"==typeof t.getHeader?r=t.getHeader("content-type"):"object"==typeof t.headers&&(r=t.headers&&t.headers["content-type"]),"string"!=typeof r)throw TypeError("content-type header is missing from object");return r}(t):t;if("string"!=typeof c)throw TypeError("argument string is required to be a string");var u=c.indexOf(";"),d=-1!==u?c.slice(0,u).trim():c.trim();if(!n.test(d))throw TypeError("invalid media type");var p=new a(d.toLowerCase());if(-1!==u){for(r.lastIndex=u;s=r.exec(c);){if(s.index!==u)throw TypeError("invalid parameter format");u+=s[0].length,o=s[1].toLowerCase(),34===(l=s[2]).charCodeAt(0)&&-1!==(l=l.slice(1,-1)).indexOf("\\")&&(l=l.replace(i,"$1")),p.parameters[o]=l}if(u!==c.length)throw TypeError("invalid parameter format")}return p}},()=>(w||S((w={exports:{}}).exports,w),w.exports))())?H(W(R)):{},"default",{value:R,enumerable:!0}),R);function uL(t){if(t)try{return uM.parse(t).type}catch{let r=(t.split(";",1)[0]??"").trim().toLowerCase();if(""===r||t.slice(r.length).includes(","))return;return r}}function uZ(t){return"application/json"===t||"application/json"===uL(t)}let uU=/^[A-Za-z0-9._-]{1,128}$/;function uF(t){let r=function(t){let r=[];if(0===t.length)return{isValid:!1,warnings:["Tool name cannot be empty"]};if(t.length>128)return{isValid:!1,warnings:[`Tool name exceeds maximum length of 128 characters (current: ${t.length})`]};if(t.includes(" ")&&r.push("Tool name contains spaces, which may cause parsing issues"),t.includes(",")&&r.push("Tool name contains commas, which may cause parsing issues"),(t.startsWith("-")||t.endsWith("-"))&&r.push("Tool name starts or ends with a dash, which may cause parsing issues in some contexts"),(t.startsWith(".")||t.endsWith("."))&&r.push("Tool name starts or ends with a dot, which may cause parsing issues in some contexts"),!uU.test(t)){let i=[...t].filter(t=>!/[A-Za-z0-9._-]/.test(t)).filter((t,r,i)=>i.indexOf(t)===r);return r.push(`Tool name contains invalid characters: ${i.map(t=>`"${t}"`).join(", ")}`,"Allowed characters are: A-Z, a-z, 0-9, underscore (_), dash (-), and dot (.)"),{isValid:!1,warnings:r}}return{isValid:!0,warnings:r}}(t);var i=r.warnings;if(i.length>0){for(let r of(console.warn(`Tool name validation warning for "${t}":`),i))console.warn(` - ${r}`);console.warn("Tool registration will proceed, but this may cause compatibility issues."),console.warn("Consider updating the tool name to conform to the MCP tool naming standard."),console.warn("See SEP: Specify Format for Tool Names (https://github.com/modelcontextprotocol/modelcontextprotocol/issues/986) for more details.")}return r.isValid}var uD=class t{static isTemplate(t){return/\{[^}\s]+\}/.test(t)}static validateLength(t,r,i){if(t.length>r)throw Error(`${i} exceeds maximum length of ${r} characters (got ${t.length})`)}template;parts;get variableNames(){return this.parts.flatMap(t=>"string"==typeof t?[]:t.names)}constructor(r){t.validateLength(r,1e6,"Template"),this.template=r,this.parts=this.parse(r)}toString(){return this.template}parse(r){let i=[],n="",a=0,o=0;for(;a<r.length;)if("{"===r[a]){n&&(i.push(n),n="");let s=r.indexOf("}",a);if(-1===s)throw Error("Unclosed template expression");if(++o>1e4)throw Error("Template contains too many expressions (max 10000)");let l=r.slice(a+1,s),c=this.getOperator(l),u=l.includes("*"),d=this.getNames(l),p=d[0];for(let r of d)t.validateLength(r,1e6,"Variable name");i.push({name:p,operator:c,names:d,exploded:u}),a=s+1}else n+=r[a],a++;return n&&i.push(n),i}getOperator(t){return["+","#",".","/","?","&"].find(r=>t.startsWith(r))||""}getNames(t){let r=this.getOperator(t);return t.slice(r.length).split(",").map(t=>t.replace("*","").trim()).filter(t=>t.length>0)}encodeValue(r,i){return(t.validateLength(r,1e6,"Variable value"),"+"===i||"#"===i)?encodeURI(r):encodeURIComponent(r)}expandPart(t,r){if("?"===t.operator||"&"===t.operator){let i=t.names.map(i=>{let n=r[i];return void 0===n?"":`${i}=${Array.isArray(n)?n.map(r=>this.encodeValue(r,t.operator)).join(","):this.encodeValue(n.toString(),t.operator)}`}).filter(t=>t.length>0);return 0===i.length?"":("?"===t.operator?"?":"&")+i.join("&")}if(t.names.length>1){let i=t.names.map(t=>r[t]).filter(t=>void 0!==t);return 0===i.length?"":i.map(t=>Array.isArray(t)?t[0]:t).join(",")}let i=r[t.name];if(void 0===i)return"";let n=(Array.isArray(i)?i:[i]).map(r=>this.encodeValue(r,t.operator));switch(t.operator){case"":case"+":default:return n.join(",");case"#":return"#"+n.join(",");case".":return"."+n.join(".");case"/":return"/"+n.join("/")}}expand(t){let r="",i=!1;for(let n of this.parts){if("string"==typeof n){r+=n;continue}let a=this.expandPart(n,t);a&&(r+=("?"===n.operator||"&"===n.operator)&&i?a.replace("?","&"):a,("?"===n.operator||"&"===n.operator)&&(i=!0))}return r}escapeRegExp(t){return t.replaceAll(/[.*+?^${}()|[\]\\]/g,String.raw`\$&`)}partToRegExp(r){let i,n=[];for(let i of r.names)t.validateLength(i,1e6,"Variable name");if("?"===r.operator||"&"===r.operator){for(let t=0;t<r.names.length;t++){let i=r.names[t],a=0===t?"\\"+r.operator:"&";n.push({pattern:a+this.escapeRegExp(i)+"=([^&]+)",name:i})}return n}let a=r.name;switch(r.operator){case"":i=r.exploded?"([^/,]+(?:,[^/,]+)*)":"([^/,]+)";break;case"+":case"#":i="(.+)";break;case".":i=String.raw`\.([^/,]+)`;break;case"/":i="/"+(r.exploded?"([^/,]+(?:,[^/,]+)*)":"([^/,]+)");break;default:i="([^/]+)"}return n.push({pattern:i,name:a}),n}match(r){t.validateLength(r,1e6,"URI");let i="^",n=[];for(let t of this.parts)if("string"==typeof t)i+=this.escapeRegExp(t);else for(let{pattern:r,name:a}of this.partToRegExp(t))i+=r,n.push({name:a,exploded:t.exploded});i+="$",t.validateLength(i,1e6,"Generated regex pattern");let a=new RegExp(i),o=r.match(a);if(!o)return null;let s={};for(let[t,r]of n.entries()){let{name:i,exploded:n}=r,a=o[t+1];s[i.replace("*","")]=n&&a.includes(",")?a.split(","):a}return s}};function uH(t){if(void 0!==t){if(function(t){if("object"!=typeof t||null===t||um(t))return!1;let r=Object.getPrototypeOf(t);return(r===Object.prototype||null===r)&&Object.values(t).every(t=>"object"==typeof t&&null!==t&&"_zod"in t)}(t))return ah(t);if("object"==typeof t&&null!==t&&!um(t)&&Object.values(t).some(t=>"object"==typeof t&&null!==t&&!("_zod"in t)&&"_def"in t&&"string"==typeof t._def?.typeName))throw TypeError("Raw-shape inputSchema/outputSchema/argsSchema fields must be Zod v4 schemas. Got a Zod v3 field schema. Import from `zod/v4` (or upgrade your zod import), or wrap with `z.object({...})` yourself.");if(!um(t))throw TypeError("inputSchema/outputSchema/argsSchema must be a Standard Schema (e.g. z.object({...})) or a raw Zod shape ({ field: z.string() }).");return t}}function uJ(t,r){let i=typeof t;if(i!==typeof r)return!1;if(Array.isArray(t)){if(!Array.isArray(r))return!1;let i=t.length;if(i!==r.length)return!1;for(let n=0;n<i;n++)if(!uJ(t[n],r[n]))return!1;return!0}if("object"===i){if(!t||!r)return t===r;let i=Object.keys(t),n=Object.keys(r);if(i.length!==n.length)return!1;for(let n of i)if(!uJ(t[n],r[n]))return!1;return!0}return t===r}function uV(t){return encodeURI(t.replace(/~/g,"~0").replace(/\//g,"~1"))}let uB={prefixItems:!0,items:!0,allOf:!0,anyOf:!0,oneOf:!0},uW={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependentSchemas:!0},uG={id:!0,$id:!0,$ref:!0,$schema:!0,$anchor:!0,$vocabulary:!0,$comment:!0,default:!0,enum:!0,const:!0,required:!0,type:!0,maximum:!0,minimum:!0,exclusiveMaximum:!0,exclusiveMinimum:!0,multipleOf:!0,maxLength:!0,minLength:!0,pattern:!0,format:!0,maxItems:!0,minItems:!0,uniqueItems:!0,maxProperties:!0,minProperties:!0},uK="undefined"!=typeof self&&self.location&&"null"!==self.location.origin?new URL(self.location.origin+self.location.pathname+location.search):new URL("https://github.com/cfworker");function uY(t,r=Object.create(null),i=uK,n=""){if(t&&"object"==typeof t&&!Array.isArray(t)){let a=t.$id||t.id;if(a){let o=new URL(a,i.href);o.hash.length>1?r[o.href]=t:(o.hash="",""===n?i=o:uY(t,r,i))}}else if(!0!==t&&!1!==t)return r;let a=i.href+(n?"#"+n:"");if(void 0!==r[a])throw Error(`Duplicate schema URI "${a}".`);if(r[a]=t,!0===t||!1===t)return r;if(void 0===t.__absolute_uri__&&Object.defineProperty(t,"__absolute_uri__",{enumerable:!1,value:a}),t.$ref&&void 0===t.__absolute_ref__){let r=new URL(t.$ref,i.href);r.hash=r.hash,Object.defineProperty(t,"__absolute_ref__",{enumerable:!1,value:r.href})}if(t.$recursiveRef&&void 0===t.__absolute_recursive_ref__){let r=new URL(t.$recursiveRef,i.href);r.hash=r.hash,Object.defineProperty(t,"__absolute_recursive_ref__",{enumerable:!1,value:r.href})}for(let a in t.$anchor&&(r[new URL("#"+t.$anchor,i.href).href]=t),t){if(uG[a])continue;let o=`${n}/${uV(a)}`,s=t[a];if(Array.isArray(s)){if(uB[a]){let t=s.length;for(let n=0;n<t;n++)uY(s[n],r,i,`${o}/${n}`)}}else if(uW[a])for(let t in s)uY(s[t],r,i,`${o}/${uV(t)}`);else uY(s,r,i,o)}return r}let uX=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,uQ=[0,31,28,31,30,31,30,31,31,30,31,30,31],u0=/^(\d\d):(\d\d):(\d\d)(\.\d+)?(z|[+-]\d\d(?::?\d\d)?)?$/i;function u1(t){return t.test.bind(t)}let u2={date:u9,time:u4.bind(void 0,!1),"date-time":function(t){let r=t.split(u3);return 2==r.length&&u9(r[0])&&u4(!0,r[1])},duration:t=>t.length>1&&t.length<80&&(/^P\d+([.,]\d+)?W$/.test(t)||/^P[\dYMDTHS]*(\d[.,]\d+)?[YMDHS]$/.test(t)&&/^P([.,\d]+Y)?([.,\d]+M)?([.,\d]+D)?(T([.,\d]+H)?([.,\d]+M)?([.,\d]+S)?)?$/.test(t)),uri:function(t){return u6.test(t)&&u5.test(t)},"uri-reference":u1(/^(?:[a-z][a-z0-9+\-.]*:)?(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'"()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?(?:\?(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i),"uri-template":u1(/^(?:(?:[^\x00-\x20"'<>%\\^`{|}]|%[0-9a-f]{2})|\{[+#./;?&=,!@|]?(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?(?:,(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?)*\})*$/i),url:u1(/^(?:(?:https?|ftp):\/\/)(?:\S+(?::\S*)?@)?(?:(?!10(?:\.\d{1,3}){3})(?!127(?:\.\d{1,3}){3})(?!169\.254(?:\.\d{1,3}){2})(?!192\.168(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\u{00a1}-\u{ffff}0-9]+-?)*[a-z\u{00a1}-\u{ffff}0-9]+)(?:\.(?:[a-z\u{00a1}-\u{ffff}0-9]+-?)*[a-z\u{00a1}-\u{ffff}0-9]+)*(?:\.(?:[a-z\u{00a1}-\u{ffff}]{2,})))(?::\d{2,5})?(?:\/[^\s]*)?$/iu),email:t=>{if('"'===t[0])return!1;let[r,i,...n]=t.split("@");return!(!r||!i||0!==n.length||r.length>64||i.length>253||"."===r[0]||r.endsWith(".")||r.includes(".."))&&!!/^[a-z0-9.-]+$/i.test(i)&&!!/^[a-z0-9.!#$%&'*+/=?^_`{|}~-]+$/i.test(r)&&i.split(".").every(t=>/^[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?$/i.test(t))},hostname:u1(/^(?=.{1,253}\.?$)[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[-0-9a-z]{0,61}[0-9a-z])?)*\.?$/i),ipv4:u1(/^(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)$/),ipv6:u1(/^((([0-9a-f]{1,4}:){7}([0-9a-f]{1,4}|:))|(([0-9a-f]{1,4}:){6}(:[0-9a-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){5}(((:[0-9a-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){4}(((:[0-9a-f]{1,4}){1,3})|((:[0-9a-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){3}(((:[0-9a-f]{1,4}){1,4})|((:[0-9a-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){2}(((:[0-9a-f]{1,4}){1,5})|((:[0-9a-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){1}(((:[0-9a-f]{1,4}){1,6})|((:[0-9a-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9a-f]{1,4}){1,7})|((:[0-9a-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))$/i),regex:function(t){if(u7.test(t))return!1;try{return RegExp(t,"u"),!0}catch(t){return!1}},uuid:u1(/^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i),"json-pointer":u1(/^(?:\/(?:[^~/]|~0|~1)*)*$/),"json-pointer-uri-fragment":u1(/^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i),"relative-json-pointer":u1(/^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/)};function u9(t){var r;let i=t.match(uX);if(!i)return!1;let n=+i[1],a=+i[2],o=+i[3];return a>=1&&a<=12&&o>=1&&o<=(2==a&&(r=n)%4==0&&(r%100!=0||r%400==0)?29:uQ[a])}function u4(t,r){let i=r.match(u0);if(!i)return!1;let n=+i[1],a=+i[2],o=+i[3],s=!!i[5];return(n<=23&&a<=59&&o<=59||23==n&&59==a&&60==o)&&(!t||s)}let u3=/t|\s/i,u6=/\/|:/,u5=/^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)(?:\?(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i,u7=/[^\\]\\Z/;var u8=class{schema;draft;shortCircuit;lookup;constructor(t,r="2019-09",i=!0){this.schema=t,this.draft=r,this.shortCircuit=i,this.lookup=uY(t)}validate(t){return function t(r,i,n="2019-09",a=uY(i),o=!0,s=null,l="#",c="#",u=Object.create(null)){let d;if(!0===i)return{valid:!0,errors:[]};if(!1===i)return{valid:!1,errors:[{instanceLocation:l,keyword:"false",keywordLocation:l,error:"False boolean schema."}]};let p=typeof r;switch(p){case"boolean":case"number":case"string":d=p;break;case"object":d=null===r?"null":Array.isArray(r)?"array":"object";break;default:throw Error(`Instances of "${p}" type are not supported.`)}let{$ref:m,$recursiveRef:h,$recursiveAnchor:f,type:g,const:y,enum:v,required:_,not:b,anyOf:S,allOf:w,oneOf:R,if:k,then:x,else:$,format:T,properties:C,patternProperties:E,additionalProperties:P,unevaluatedProperties:O,minProperties:I,maxProperties:q,propertyNames:j,dependentRequired:A,dependentSchemas:z,dependencies:N,prefixItems:M,items:L,additionalItems:Z,unevaluatedItems:U,contains:F,minContains:D,maxContains:H,minItems:J,maxItems:V,uniqueItems:B,minimum:W,maximum:G,exclusiveMinimum:K,exclusiveMaximum:Y,multipleOf:X,minLength:Q,maxLength:ee,pattern:et,__absolute_ref__:er,__absolute_recursive_ref__:ei}=i,en=[];if(!0===f&&null===s&&(s=i),"#"===h){let d=null===s?a[ei]:s,p=`${c}/$recursiveRef`,m=t(r,null===s?i:s,n,a,o,d,l,p,u);m.valid||en.push({instanceLocation:l,keyword:"$recursiveRef",keywordLocation:p,error:"A subschema had errors."},...m.errors)}if(void 0!==m){let i=a[er||m];if(void 0===i){let t=`Unresolved $ref "${m}".`;throw er&&er!==m&&(t+=` Absolute URI "${er}".`),Error(t+=`
|
|
55
|
+
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let r of e.seen.entries()){let i=r[1];if(t===r[0]){n(r);continue}if(e.external){let i=e.external.registry.get(r[0])?.id;if(t!==r[0]&&i){n(r);continue}}if(e.metadataRegistry.get(r[0])?.id||i.cycle){n(r);continue}i.count>1&&"ref"===e.reused&&n(r)}e.external&&(e.sharedDefsExtractedFor=e.external)}let iy=new Set(["type","properties","required","additionalProperties"]),iv=["oneOf","anyOf"];function i_(e){let t=e.additionalProperties;return void 0===t||!1===t||"object"!=typeof t||null===t?null:Object.keys(t).length?t:null}function ib(e){let t=[];for(let r of e){if("object"!=typeof r||"object"!==r.type)return null;for(let e in r)if(!iy.has(e))return null;t.push(r)}let r={},i=new Set;for(let e of t){for(let i in e.properties){if(Object.prototype.hasOwnProperty.call(r,i))continue;let e=[];for(let r of t){let t=r.properties?.[i]??i_(r);null!=t&&(e.some(e=>JSON.stringify(e)===JSON.stringify(t))||e.push(t))}es(r,i,1===e.length?e[0]:ib(e)??{allOf:e})}for(let t of e.required??[])i.add(t)}let n={type:"object",properties:r};if(i.size&&(n.required=[...i]),t.every(e=>!1===e.additionalProperties))n.additionalProperties=!1;else{let e=[];for(let r of t){let t=i_(r);t&&!e.some(e=>JSON.stringify(e)===JSON.stringify(t))&&e.push(t)}1===e.length?n.additionalProperties=e[0]:e.length>1&&(n.additionalProperties={allOf:e})}return n}function iS(e,t){let r=e.seen.get(t);if(!r)throw Error("Unprocessed schema. This is a bug in Zod.");let i=t=>{let r=e.seen.get(t);if(null===r.ref)return;let n=r.def??r.schema,a={...n},o=r.ref;if(r.ref=null,o){i(o);let r=e.seen.get(o),s=r.schema;if(s.$ref&&("draft-07"===e.target||"draft-04"===e.target||"openapi-3.0"===e.target)?(n.allOf=n.allOf??[],n.allOf.push(s)):iu(n,s),iu(n,a),t._zod.parent===o)for(let e in n)"$ref"!==e&&"allOf"!==e&&(e in a||delete n[e]);if(s.$ref&&r.def)for(let e in n)"$ref"!==e&&"allOf"!==e&&e in r.def&&JSON.stringify(n[e])===JSON.stringify(r.def[e])&&delete n[e]}let s=t._zod.parent;if(s&&s!==o){i(s);let t=e.seen.get(s);if(t?.schema.$ref&&(n.$ref=t.schema.$ref,t.def))for(let e in n)"$ref"!==e&&"allOf"!==e&&e in t.def&&JSON.stringify(n[e])===JSON.stringify(t.def[e])&&delete n[e]}e.override({zodSchema:t,jsonSchema:n,path:r.path??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(let t of[...e.seen.entries()].reverse())i(t[0]);if("openapi-3.0"!==e.target)for(let t of e.seen.entries())!function e(t){let r=t.anyOf;if(!Array.isArray(r)||0===r.length||void 0!==t.type)return;let i=[];for(let t of r){if(!t||"object"!=typeof t)return;e(t);let r=Object.keys(t);if(1!==r.length||"type"!==r[0])return;let n=t.type;for(let e of Array.isArray(n)?n:[n]){if("string"!=typeof e)return;i.includes(e)||i.push(e)}}delete t.anyOf,t.type=1===i.length?i[0]:i}(t[1].def??t[1].schema);for(let t of e.deferred)t();if(e.intersections.length){let t=new Map;for(let r of e.seen.values())for(let e of[r.schema,r.def]){let r=e?.allOf;if(!Array.isArray(r))continue;let i=t.get(r);i?i.push(e):t.set(r,[e])}for(let r of e.intersections)for(let e of t.get(r)??[])!function(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let t of iy)if(t in e)return;let r=t.filter(e=>iv.some(t=>Array.isArray(e[t]))),i=null;if(r.length){let e=r[0],n=iv.find(t=>Array.isArray(e[t]));if(1!==Object.keys(e).length)return;let a=t.filter(t=>t!==e),o=e[n].map(e=>ib([...a,e]));if(o.some(e=>!e))return;i={[n]:o}}else i=ib(t);i&&(delete e.allOf,iu(e,i))}(e)}}let n={};if("draft-2020-12"===e.target?n.$schema="https://json-schema.org/draft/2020-12/schema":"draft-07"===e.target?n.$schema="http://json-schema.org/draft-07/schema#":"draft-04"===e.target?n.$schema="http://json-schema.org/draft-04/schema#":e.target,e.external?.uri){let r=e.external.registry.get(t)?.id;if(!r)throw Error("Schema is missing an `id` property");n.$id=e.external.uri(r)}iu(n,r.defId?r.schema:r.def??r.schema);let a=e.metadataRegistry.get(t)?.id;void 0!==a&&n.id===a&&delete n.id;let o=e.external?.defs??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(let t of e.seen.entries()){let e=t[1];e.def&&e.defId&&(e.def.id===e.defId&&delete e.def.id,es(o,e.defId,e.def))}e.external&&(e.sharedEmitDoneFor=e.external),e.external||Object.keys(o).length>0&&("draft-2020-12"===e.target?n.$defs=o:n.definitions=o);try{let r=JSON.parse(JSON.stringify(n));return Object.defineProperty(r,"~standard",{value:{...t["~standard"],jsonSchema:{input:iw(t,"input",e.processors),output:iw(t,"output",e.processors)}},enumerable:!1,writable:!1}),r}catch(e){throw Error("Error converting schema to JSON.")}}let iw=(e,t,r={})=>i=>{let{libraryOptions:n,target:a}=i??{},o=id({...n??{},target:a,io:t,processors:r});return im(e,o),ig(o,e),iS(o,e)},iR=(e,t,r)=>{(void 0===e[t]||r>e[t])&&(e[t]=r)},ik=(e,t,r)=>{(void 0===e[t]||r<e[t])&&(e[t]=r)},ix=(e,t)=>{iR(e,"minimum",t),ik(e,"maximum",t)},i$=(e,t)=>{e.multipleOf??(e.multipleOf=[]),e.multipleOf.includes(t)||e.multipleOf.push(t)},iT=(e,t)=>{e.patterns??(e.patterns=new Set),e.patterns.add(t)},iC=(e,t)=>{e.mime=e.mime?e.mime.filter(e=>t.includes(e)):[...t]},iP=(e,t)=>{e.format=t,t.includes("int")&&(e.isInt=!0)},iO=(e,t)=>iR(e,"minimum",t.minimum),iE=(e,t)=>ik(e,"maximum",t.maximum),iI=e=>(t,r)=>{iP(t,r.format);let[i,n]=e[r.format];iR(t,"minimum",i),ik(t,"maximum",n)},iq={greater_than:(e,t)=>iR(e,t.inclusive?"minimum":"exclusiveMinimum",t.value),less_than:(e,t)=>ik(e,t.inclusive?"maximum":"exclusiveMaximum",t.value),multiple_of:(e,t)=>i$(e,t.value),number_format:iI(ek),bigint_format:iI(ex),min_length:iO,max_length:iE,length_equals:(e,t)=>ix(e,t.length),min_size:iO,max_size:iE,size_equals:(e,t)=>ix(e,t.size),string_format:(e,t)=>{iP(e,t.format),t.pattern&&iT(e,t.pattern),("base64"===t.format||"base64url"===t.format)&&(e.contentEncoding=t.format),(t.local||-1===t.precision)&&(e.laxFormat=!0)},mime_type:(e,t)=>iC(e,t.mime)};function ij(e){let t={},r=e._zod.def;for(let i of e._zod.traits.has("$ZodCheck")?[e,...r.checks??[]]:r.checks??[])iq[i._zod.def.check]?.(t,i._zod.def);let i=e._zod.bag;for(let e of(void 0!==i.minimum&&iR(t,"minimum",i.minimum),void 0!==i.exclusiveMinimum&&iR(t,"exclusiveMinimum",i.exclusiveMinimum),void 0!==i.maximum&&ik(t,"maximum",i.maximum),void 0!==i.exclusiveMaximum&&ik(t,"exclusiveMaximum",i.exclusiveMaximum),void 0!==i.multipleOf&&i$(t,i.multipleOf),void 0!==i.format&&(t.format??(t.format=i.format),i.format.includes("int")&&(t.isInt=!0)),i.mime&&iC(t,i.mime),i.patterns??[]))iT(t,e);return t}let iz={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},iA=new Map([[rl,/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/],[ru,/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/]]),iN=e=>iA.get(e)??e,iM=(e,t,r,i)=>{r.type="string";let{minimum:n,maximum:a,format:o,patterns:s,contentEncoding:l,laxFormat:c}=ij(e);if("number"==typeof n&&(r.minLength=n),"number"==typeof a&&(r.maxLength=a),o&&(r.format=iz[o]??o,""===r.format&&delete r.format,("time"===o||c)&&delete r.format),l&&(r.contentEncoding=l),s&&s.size>0){let e=[...s].map(iN);1===e.length?r.pattern=e[0].source:e.length>1&&(r.allOf=[...e.map(e=>({..."draft-07"===t.target||"draft-04"===t.target||"openapi-3.0"===t.target?{type:"string"}:{},pattern:e.source}))])}},iL=(e,t,r,i)=>{let{minimum:n,maximum:a,multipleOf:o,exclusiveMaximum:s,exclusiveMinimum:l,isInt:c}=ij(e);r.type=c?"integer":"number";let u="number"==typeof l&&l>=(n??-1/0),d="number"==typeof s&&s<=(a??1/0),p="draft-04"===t.target||"openapi-3.0"===t.target;if(u?p?(r.minimum=l,r.exclusiveMinimum=!0):r.exclusiveMinimum=l:"number"==typeof n&&(r.minimum=n),d?p?(r.maximum=s,r.exclusiveMaximum=!0):r.exclusiveMaximum=s:"number"==typeof a&&(r.maximum=a),o){let n=new Set;for(let a of o)Number.isFinite(a)&&0!==a?n.add(Math.abs(a)):ip(e,t,r,i,`A multipleOf divisor of ${a} cannot be represented in JSON Schema`);let[a,...s]=n;void 0!==a&&(r.multipleOf=a),s.length&&(r.allOf=[...r.allOf??[],...s.map(e=>({multipleOf:e}))])}},iZ=(e,t,r,i)=>{r.type="boolean"},iU=(e,t,r,i)=>{"openapi-3.0"===t.target?(r.type="string",r.nullable=!0,r.enum=[null]):r.type="null"},iF=(e,t,r,i)=>{r.not={}},iD=(e,t,r,i)=>{},iH=(e,t,r,i)=>{},iJ=(e,t,r,i)=>{let n=ee(e._zod.def.entries);if(0===n.length){r.not={};return}n.every(e=>"number"==typeof e)&&(r.type="number"),n.every(e=>"string"==typeof e)&&(r.type="string"),r.enum=n},iV=(e,t,r,i)=>{let n=e._zod.def;if(0===n.values.length){r.not={};return}let a=[];for(let o of n.values)if(void 0===o){if(ip(e,t,r,i,"Literal `undefined` cannot be represented in JSON Schema"))return}else if("bigint"==typeof o){if(ip(e,t,r,i,"BigInt literals cannot be represented in JSON Schema"))return;a.push(Number(o))}else a.push(o);if(0===a.length);else if(1===a.length){let e=a[0];r.type=null===e?"null":typeof e,"draft-04"===t.target||"openapi-3.0"===t.target?r.enum=[e]:r.const=e}else a.every(e=>"number"==typeof e)&&(r.type="number"),a.every(e=>"string"==typeof e)&&(r.type="string"),a.every(e=>"boolean"==typeof e)&&(r.type="boolean"),a.every(e=>null===e)&&(r.type="null"),r.enum=a},iB=(e,t,r,i)=>{ip(e,t,r,i,"Custom types cannot be represented in JSON Schema")},iW=(e,t,r,i)=>{ip(e,t,r,i,"Transforms cannot be represented in JSON Schema")},iG=(e,t,r,i)=>{let n=e._zod.def,{minimum:a,maximum:o}=ij(e);"number"==typeof a&&(r.minItems=a),"number"==typeof o&&(r.maxItems=o),r.type="array",r.items=im(n.element,t,{...i,path:[...i.path,"items"]})};function iK(e){let t=e._zod.def;return"pipe"===t.type&&t.in._zod.traits.has("$ZodTransform")?iK(t.out):"catch"===t.type?iK(t.innerType):e._zod.optin}let iY=(e,t,r,i)=>{let n=e._zod.def,a=n.shape;if(Object.getOwnPropertySymbols(a).length&&ip(e,t,r,i,"Symbol keys cannot be represented in JSON Schema"))return;for(let e in r.type="object",r.properties={},a)es(r.properties,e,im(a[e],t,{...i,path:[...i.path,"properties",e]}));let o=[];for(let e of Object.keys(a)){let r=n.shape[e];("input"===t.io?void 0===iK(r):void 0===r._zod.optout)&&o.push(e)}o.length>0&&(r.required=o),n.catchall?._zod.def.type==="never"?r.additionalProperties=!1:n.catchall?n.catchall&&(r.additionalProperties=im(n.catchall,t,{...i,path:[...i.path,"additionalProperties"]})):"output"===t.io&&(r.additionalProperties=!1)},iX=(e,t,r,i)=>{let n=e._zod.def,a=!1===n.inclusive,o=n.options.map((e,r)=>im(e,t,{...i,path:[...i.path,a?"oneOf":"anyOf",r]}));a?r.oneOf=o:r.anyOf=o},iQ=(e,t,r,i)=>{let n=e._zod.def,a=im(n.left,t,{...i,path:[...i.path,"allOf",0]}),o=im(n.right,t,{...i,path:[...i.path,"allOf",1]}),s=e=>"allOf"in e&&1===Object.keys(e).length,l=[...s(a)?a.allOf:[a],...s(o)?o.allOf:[o]];r.allOf=l,t.intersections.push(l)},i0=new WeakMap,i1=(e,t,r,i)=>{let n=e._zod.def;r.type="object";let a=n.keyType,o=ij(a).patterns;if("loose"===n.mode&&o&&o.size>0){let e=im(n.valueType,t,{...i,path:[...i.path,"patternProperties","*"]});for(let t of(r.patternProperties={},o))es(r.patternProperties,iN(t).source,e)}else{if("draft-07"===t.target||"draft-2020-12"===t.target){r.propertyNames=im(n.keyType,t,{...i,path:[...i.path,"propertyNames"]});let a=i0.get(t);a||(a=[],i0.set(t,a),t.deferred.push(()=>(function(e){let t=new Map;for(let r of e.seen.values())r.def&&!t.has(r.schema)&&t.set(r.schema,r);let r=new Map;for(let i of i0.get(e)??[]){let n=e.seen.get(i),a=(n?.def??n?.schema)?.propertyNames;if(!a||!0===a||r.has(a))continue;let o=function e(t,r,i){if(r.$ref){if(i.has(r))return r;i.add(r);let n=t.get(r)?.def;if(!n)return r;let a=e(t,n,i);return a===n?r:a}for(let n of["anyOf","oneOf"]){let a=r[n];if(!Array.isArray(a))continue;let o=a.map(r=>e(t,r,i));o.some((e,t)=>e!==a[t])&&(r={...r,[n]:o})}let n=Array.isArray(r.type)?r.type:[r.type],a=!n.includes("string")&&n.some(e=>"number"===e||"integer"===e),o=r.enum??(void 0!==r.const?[r.const]:void 0);if(!a&&!o?.some(e=>"number"==typeof e))return r;let{minimum:s,maximum:l,exclusiveMinimum:c,exclusiveMaximum:u,multipleOf:d,format:p,id:m,...h}=r;return h.enum?h.enum=h.enum.map(e=>"number"==typeof e?String(e):e):"number"==typeof h.const&&(h.const=String(h.const)),a&&(h.type="string",o||(h.pattern=(n.includes("number")?ty:tg).source)),h}(t,a,new Set);o!==a&&r.set(a,o)}if(r.size)for(let t of e.seen.values())for(let e of[t.schema,t.def]){let t=e&&r.get(e.propertyNames);t&&(e.propertyNames=t)}})(t))),a.push(e)}r.additionalProperties=im(n.valueType,t,{...i,path:[...i.path,"additionalProperties"]})}let s=a._zod.values,l="input"===t.io&&void 0!==iK(n.valueType);if(s&&!n.partial&&!l){let e=[...s].filter(e=>"string"==typeof e||"number"==typeof e);e.length>0&&(r.required=e.map(String))}},i2=(e,t,r,i)=>{let n=e._zod.def,a=im(n.innerType,t,i),o=t.seen.get(e);"openapi-3.0"===t.target?(o.ref=n.innerType,r.nullable=!0):r.anyOf=[a,{type:"null"}]},i9=(e,t,r,i)=>{let n=e._zod.def;im(n.innerType,t,i),t.seen.get(e).ref=n.innerType},i4=Symbol();function i3(e,t,r,i,n){let a=!1,o=JSON.stringify(e,(e,t)=>"bigint"!=typeof t?t:(a=!0,null));return a?(ip(t,r,i,n,"BigInt defaults cannot be represented in JSON Schema"),i4):JSON.parse(o)}let i6=(e,t,r,i)=>{let n=e._zod.def;im(n.innerType,t,i),t.seen.get(e).ref=n.innerType;let a=i3(n.defaultValue,e,t,r,i);a!==i4&&(r.default=a)},i5=(e,t,r,i)=>{let n=e._zod.def;if(im(n.innerType,t,i),t.seen.get(e).ref=n.innerType,"input"!==t.io)return;let a=i3(n.defaultValue,e,t,r,i);a!==i4&&(r._prefault=a)},i7=(e,t,r,i)=>{let n,a=e._zod.def;im(a.innerType,t,i),t.seen.get(e).ref=a.innerType;try{n=a.catchValue(void 0)}catch{ip(e,t,r,i,"Dynamic catch values are not supported in JSON Schema");return}r.default=n},i8=(e,t,r,i)=>{let n=e._zod.def,a=n.in._zod.traits.has("$ZodTransform"),o="input"===t.io?a?n.out:n.in:n.out;im(o,t,i),t.seen.get(e).ref=o},ne=(e,t,r,i)=>{let n=e._zod.def;im(n.innerType,t,i),t.seen.get(e).ref=n.innerType,r.readOnly=!0},nt=(e,t,r,i)=>{let n=e._zod.def;im(n.innerType,t,i),t.seen.get(e).ref=n.innerType},nr=(e,t,r,i)=>{let n=e._zod.innerType;im(n,t,i),t.seen.get(e).ref=n},ni={string:iM,number:iL,boolean:iZ,bigint:(e,t,r,i)=>{ip(e,t,r,i,"BigInt cannot be represented in JSON Schema")},symbol:(e,t,r,i)=>{ip(e,t,r,i,"Symbols cannot be represented in JSON Schema")},null:iU,undefined:(e,t,r,i)=>{ip(e,t,r,i,"Undefined cannot be represented in JSON Schema")},void:(e,t,r,i)=>{ip(e,t,r,i,"Void cannot be represented in JSON Schema")},never:iF,any:iD,unknown:iH,date:(e,t,r,i)=>{ip(e,t,r,i,"Date cannot be represented in JSON Schema")},enum:iJ,literal:iV,nan:(e,t,r,i)=>{ip(e,t,r,i,"NaN cannot be represented in JSON Schema")},template_literal:(e,t,r,i)=>{let n=e._zod.pattern;if(!n)throw Error("Pattern not found in template literal");r.type="string",r.pattern=n.source},file:(e,t,r,i)=>{r.type="string",r.format="binary",r.contentEncoding="binary";let{minimum:n,maximum:a,mime:o}=ij(e);void 0!==n&&(r.minLength=n),void 0!==a&&(r.maxLength=a),o&&(0===o.length?r.not={}:1===o.length?r.contentMediaType=o[0]:r.anyOf=o.map(e=>({contentMediaType:e})))},success:(e,t,r,i)=>{r.type="boolean"},custom:iB,function:(e,t,r,i)=>{ip(e,t,r,i,"Function types cannot be represented in JSON Schema")},transform:iW,map:(e,t,r,i)=>{ip(e,t,r,i,"Map cannot be represented in JSON Schema")},set:(e,t,r,i)=>{ip(e,t,r,i,"Set cannot be represented in JSON Schema")},array:iG,object:iY,union:iX,intersection:iQ,tuple:(e,t,r,i)=>{let n=e._zod.def;r.type="array";let a="draft-2020-12"===t.target?"prefixItems":"items",o="draft-2020-12"===t.target||"openapi-3.0"===t.target?"items":"additionalItems",s=n.items.map((e,r)=>im(e,t,{...i,path:[...i.path,a,r]})),l=n.rest?im(n.rest,t,{...i,path:[...i.path,o,..."openapi-3.0"===t.target?[n.items.length]:[]]}):null,c=n.items.length;for(;c>0;){let e=n.items[c-1];if(!("input"===t.io?void 0!==iK(e):"optional"===e._zod.optout))break;c--}let u=n.items.length,d=!n.rest;"draft-2020-12"===t.target?(r.prefixItems=s,d?r.items=!1:l&&(r.items=l)):"openapi-3.0"===t.target?(r.items={anyOf:s},l&&r.items.anyOf.push(l)):(r.items=s,d?r.additionalItems=!1:l&&(r.additionalItems=l)),c>0&&(r.minItems=c),d&&(r.maxItems=u);let{minimum:p,maximum:m}=ij(e);"number"==typeof p&&(r.minItems=p),"number"==typeof m&&(r.maxItems=m)},record:i1,nullable:i2,nonoptional:i9,default:i6,prefault:i5,catch:i7,pipe:i8,readonly:ne,promise:(e,t,r,i)=>{let n=e._zod.def;im(n.innerType,t,i),t.seen.get(e).ref=n.innerType},optional:nt,lazy:nr};function nn(e,t){if("_idmap"in e){let r=id({...t,processors:ni}),i={};for(let t of e._idmap.entries()){let[e,i]=t;im(i,r)}let n={};for(let a of(r.external={registry:e,uri:t?.uri,defs:i},e._idmap.entries())){let[e,t]=a;ig(r,t),es(n,e,iS(r,t))}return Object.keys(i).length>0&&(n.__shared={["draft-2020-12"===r.target?"$defs":"definitions"]:i}),{schemas:n}}let r=id({...t,processors:ni});return im(e,r),ig(r,e),iS(r,e)}let na={get:function(){let e=this._zod;return e.message??(e.message=JSON.stringify(e.def,er,2)),e.message},set:function(e){this._zod.message=e},enumerable:!0,configurable:!0},no={value:void 0,enumerable:!1},ns=new WeakSet([Object.prototype,Error.prototype]),nl=(e,t)=>{e.name="$ZodError",no.value=t,Object.defineProperty(e,"issues",no),no.value=void 0,Object.defineProperty(e,"message",na);let r=Object.getPrototypeOf(e);ns.has(r)||(ns.add(r),Object.defineProperty(r,"toString",{configurable:!0,enumerable:!1,get(){let e=()=>this.message;return Object.defineProperty(this,"toString",{value:e,configurable:!0,writable:!0}),e},set(e){Object.defineProperty(this,"toString",{value:e,configurable:!0,writable:!0})}}))},nc=eB("$ZodError",nl);function nu(e,t){return{callee:t?.callee??e,Err:t?.Err}}eB("$ZodError",nl,void 0,{Parent:Error});let nd=e=>{let t=(r,i,n,a)=>{let o=n?{...n,async:!1}:{async:!1},s=r._zod.run({value:i,issues:[]},o);if(s instanceof Promise)throw new eW;if(s.issues.length){let r=new(a?.Err??e)(s.issues.map(e=>ej(e,o,eY())));throw eh(r,a?.callee??t),r}return s.value};return t},np=e=>{let t=async(r,i,n,a)=>{let o=n?{...n,async:!0}:{async:!0},s=r._zod.run({value:i,issues:[]},o);if(s instanceof Promise&&(s=await s),s.issues.length){let r=new(a?.Err??e)(s.issues.map(e=>ej(e,o,eY())));throw eh(r,a?.callee??t),r}return s.value};return t},nm=e=>(t,r,i)=>{let n=i?{...i,async:!1}:{async:!1},a=t._zod.run({value:r,issues:[]},n);if(a instanceof Promise)throw new eW;return a.issues.length?nh(e,a.issues,n):{success:!0,data:a.value}};function nh(e,t,r){let i;return{success:!1,get error(){return i||(i=new e(t.map(e=>ej(e,r,eY()))),t=void 0,r=void 0),i},set error(e){i=e,t=void 0,r=void 0}}}let nf=e=>async(t,r,i)=>{let n=i?{...i,async:!0}:{async:!0},a=t._zod.run({value:r,issues:[]},n);return a instanceof Promise&&(a=await a),a.issues.length?nh(e,a.issues,n):{success:!0,data:a.value}},ng=Symbol.for("zod.compile.invalid"),ny=Symbol.for("zod.compile.fallback"),nv=new WeakSet([Object.prototype,Error.prototype]);function n_(e,t,r){Object.defineProperty(e,t,{configurable:!0,enumerable:!1,get(){let e=r(this);return Object.defineProperty(this,t,{value:e,configurable:!0,writable:!0}),e},set(e){Object.defineProperty(this,t,{value:e,configurable:!0,writable:!0})}})}let nb=eB("ZodError",(e,t)=>{nc.init(e,t),e.name="ZodError";let r=Object.getPrototypeOf(e);nv.has(r)||(nv.add(r),n_(r,"format",e=>t=>(function(e,t=e=>e.message){let r={_errors:[]},i=(e,n=[])=>{for(let a of e.issues)if("invalid_union"===a.code&&a.errors.length)a.errors.map(e=>i({issues:e},[...n,...a.path]));else if("invalid_key"===a.code)i({issues:a.issues},[...n,...a.path]);else if("invalid_element"===a.code)i({issues:a.issues},[...n,...a.path]);else{let e=[...n,...a.path];if(0===e.length)r._errors.push(t(a));else{let i=r,n=0;for(;n<e.length;){let r=e[n],o=n===e.length-1;if("_errors"===r){o&&i._errors.push(t(a)),n++;continue}Object.prototype.hasOwnProperty.call(i,r)||Object.defineProperty(i,r,{value:{_errors:[]},enumerable:!0,writable:!0,configurable:!0});let s=i[r];o&&s._errors.push(t(a)),i=s,n++}}}};return i(e),r})(e,t)),n_(r,"flatten",e=>t=>(function(e,t=e=>e.message){let r={},i=[];for(let o of e.issues)if(o.path.length>0){var n,a;(n=o.path[0],a=()=>[],!Object.prototype.hasOwnProperty.call(r,n)&&("__proto__"===n?Object.defineProperty(r,n,{value:a(),writable:!0,enumerable:!0,configurable:!0}):r[n]=a()),r[n]).push(t(o))}else i.push(t(o));return{formErrors:i,fieldErrors:r}})(e,t)),n_(r,"addIssue",e=>t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,er,2)}),n_(r,"addIssues",e=>t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,er,2)}),Object.defineProperty(r,"isEmpty",{configurable:!0,enumerable:!1,get(){return 0===this.issues.length}}))},void 0,{Parent:Error}),nS=nd(nb),nw=np(nb),nR=nm(nb),nk=nf(nb),nx=(m=nd(nb),h=(e,t,r,i)=>m(e,t,r?{...r,direction:"backward"}:{direction:"backward"},nu(h,i))),n$=(f=nd(nb),g=(e,t,r,i)=>f(e,t,r,nu(g,i))),nT=(y=np(nb),v=async(e,t,r,i)=>{let n=r?{...r,direction:"backward"}:{direction:"backward"};return await y(e,t,n,nu(v,i))}),nC=(_=np(nb),b=async(e,t,r,i)=>await _(e,t,r,nu(b,i))),nP=(e,t,r)=>{let i=r?{...r,direction:"backward"}:{direction:"backward"};return nm(nb)(e,t,i)},nO=(e,t,r)=>nm(nb)(e,t,r),nE=async(e,t,r)=>{let i=r?{...r,direction:"backward"}:{direction:"backward"};return nf(nb)(e,t,i)},nI=async(e,t,r)=>nf(nb)(e,t,r);function nq(){eK.memoizer||eY({memoizer:e3})}let nj=eB("ZodType",(e,t)=>(eK.localeError||eY({localeError:(()=>{let e={string:{unit:"characters",verb:"to have"},file:{unit:"bytes",verb:"to have"},array:{unit:"items",verb:"to have"},set:{unit:"items",verb:"to have"},map:{unit:"entries",verb:"to have"}},t={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={nan:"NaN"};function i(e,t){return"number"!==e||"number"!=typeof t||Number.isFinite(t)?r[e]??e:String(t)}return r=>{switch(r.code){case"invalid_type":{let e=i(r.expected),t=i(function(e){let t=typeof e;switch(t){case"number":return Number.isNaN(e)?"nan":"number";case"object":if(null===e)return"null";if(Array.isArray(e))return"array";if(e&&Object.getPrototypeOf(e)!==Object.prototype&&"constructor"in e&&e.constructor)return e.constructor.name}return t}(r.input),r.input);return`Invalid input: expected ${e}, received ${t}`}case"invalid_value":if(1===r.values.length)return`Invalid input: expected ${eR(r.values[0])}`;return`Invalid option: expected one of ${et(r.values,"|")}`;case"too_big":{let t=r.exact?"exactly ":r.inclusive?"<=":"<",i=e[r.origin]??null;if(i)return`Too big: expected ${r.origin??"value"} to have ${t}${r.maximum.toString()} ${i.unit??"elements"}`;return`Too big: expected ${r.origin??"value"} to be ${t}${r.maximum.toString()}`}case"too_small":{let t=r.exact?"exactly ":r.inclusive?">=":">",i=e[r.origin]??null;if(i)return`Too small: expected ${r.origin} to have ${t}${r.minimum.toString()} ${i.unit}`;return`Too small: expected ${r.origin} to be ${t}${r.minimum.toString()}`}case"invalid_format":if("starts_with"===r.format)return`Invalid string: must start with "${r.prefix}"`;if("ends_with"===r.format)return`Invalid string: must end with "${r.suffix}"`;if("includes"===r.format)return`Invalid string: must include "${r.includes}"`;if("regex"===r.format)return`Invalid string: must match pattern ${r.pattern}`;return`Invalid ${t[r.format]??r.format}`;case"not_multiple_of":return`Invalid number: must be a multiple of ${r.divisor}`;case"unrecognized_keys":return`Unrecognized key${r.keys.length>1?"s":""}: ${et(r.keys,", ")}`;case"invalid_key":return`Invalid key in ${r.origin}`;case"invalid_union":if(r.options&&Array.isArray(r.options)&&r.options.length>0){let e=r.options.map(e=>`'${e}'`).join(" | ");return`Invalid discriminator value. Expected ${e}`}if(!1===r.inclusive)return"Invalid input: more than one option matched";return"Invalid input";case"invalid_element":return`Invalid value in ${r.origin}`;default:return"Invalid input"}}})()}),tF.init(e,t),e.def=t,e.type=t.type,e),{check(...e){let t=this.def;return this.clone(em(t,{checks:[...t.checks??[],...e.map(e=>"function"==typeof e?{_zod:{check:e,def:{check:"custom"},onattach:[]}}:e)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return eS(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(function(e,t={}){return new aH({type:"custom",check:"custom",fn:e,...ew(t)})}(e,t))},superRefine(e,t){return this.check(function(e,t){var r;let i,n;return r=t=>(t.addIssue=e=>{"string"==typeof e?t.issues.push(eM(e,t.value,i._zod.def)):(e.fatal&&(e.continue=!1),e.code??(e.code="custom"),"input"in e||(e.input=t.value),e.inst??(e.inst=i),e.continue??(e.continue=!i._zod.def.abort),t.issues.push(eM(e)))},e(t.value,t)),(n=new tw({check:"custom",...ew(t)}))._zod.check=r,i=n}(e,t))},overwrite(e){return this.check(ic(e))},optional(){return aO(this)},exactOptional(){var e;return e=this,new aE({type:"optional",innerType:e})},nullable(){return aq(this)},nullish(){return aO(aq(this))},nonoptional(e){var t;return t=this,new aA({type:"nonoptional",innerType:t,...ew(e)})},array(){return ad(this)},or(e){return ag([this,e])},and(e){return ab(this,e)},transform(e){return aL(this,aC(e))},default(e){var t,r;return t=this,r=e,new aj({type:"default",innerType:t,get defaultValue(){return"function"==typeof r?r():ev(r)}})},prefault(e){var t,r;return t=this,r=e,new az({type:"prefault",innerType:t,get defaultValue(){return"function"==typeof r?r():ev(r)}})},catch(e){return function(e,t){let r;return new aN({type:"catch",innerType:e,catchValue:"function"==typeof t?t:((r=()=>t)["~constantCatch"]=!0,r)})}(this,e)},pipe(e){return aL(this,e)},readonly(){var e;return e=this,new aU({type:"readonly",innerType:e})},describe(e){let t=this.clone();return r4.add(t,{description:e}),t},meta(...e){if(0===e.length)return r4.get(this);let t=this.clone();return r4.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e,...t){return 0===t.length?e(this):e(this,...t)},get"~standard"(){return eL(this,"~standard",{...tH(this),jsonSchema:{input:iw(this,"input"),output:iw(this,"output")}},!1)},set"~standard"(e){eL(this,"~standard",e)},parse:function e(t,r){return nS(this,t,r,{callee:e})},parseAsync:async function e(t,r){return await nw(this,t,r,{callee:e})},safeParse(e,t){return nR(this,e,t)},async safeParseAsync(e,t){return nk(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){eL(this,"spa",e)},validate(e,t){let r=this._zod.bag.validator;if(void 0!==r){if(r(e)!==ng)return!0;if(!0===r.definite&&void 0===t)return!1}return function(e,t,r){let i,n=r?{...r,async:!1,abortEarly:!0}:{async:!1,abortEarly:!0},a=e._zod.bag.fallbackRun;if(a?(n[ny]=!0,i=a({value:t,issues:[]},n)):i=e._zod.run({value:t,issues:[]},n),i instanceof Promise)throw new eW;return 0===i.issues.length}(this,e,t)},validateAsync(e,t){return(async(e,t,r)=>{let i=r?{...r,async:!0,abortEarly:!0}:{async:!0,abortEarly:!0},n=e._zod.run({value:t,issues:[]},i);return n instanceof Promise&&(n=await n),0===n.issues.length})(this,e,t)},encode:function e(t,r){return nx(this,t,r,{callee:e})},decode:function e(t,r){return n$(this,t,r,{callee:e})},encodeAsync:async function e(t,r){return await nT(this,t,r,{callee:e})},decodeAsync:async function e(t,r){return await nC(this,t,r,{callee:e})},safeEncode(e,t){return nP(this,e,t)},safeDecode(e,t){return nO(this,e,t)},async safeEncodeAsync(e,t){return nE(this,e,t)},async safeDecodeAsync(e,t){return nI(this,e,t)},toJSONSchema(e){return((e,t={})=>r=>{let i=id({...r,processors:t});return im(e,i),ig(i,e),iS(i,e)})(this,{})(e)},get description(){return r4.get(this)?.description},get _def(){return this._zod.def}}),nz=eB("_ZodString",(e,t)=>{tJ.init(e,t),nj.init(e,t),e._zod.processJSONSchema=(t,r,i)=>iM(e,t,r,i)},eZ({format:e=>ij(e).format??null,minLength:e=>ij(e).minimum??null,maxLength:e=>ij(e).maximum??null},{regex(...e){return this.check(function(e,t){return new tq({check:"string_format",format:"regex",...ew(t),pattern:e})}(...e))},includes(...e){return this.check(function(e,t){return new tA({check:"string_format",format:"includes",...ew(t),includes:e})}(...e))},startsWith(...e){return this.check(function(e,t){return new tN({check:"string_format",format:"starts_with",...ew(t),prefix:e})}(...e))},endsWith(...e){return this.check(function(e,t){return new tM({check:"string_format",format:"ends_with",...ew(t),suffix:e})}(...e))},min(...e){return this.check(is(...e))},max(...e){return this.check(io(...e))},length(...e){return this.check(il(...e))},nonempty(...e){return this.check(is(1,...e))},lowercase(e){return this.check(new tj({check:"string_format",format:"lowercase",...ew(e)}))},uppercase(e){return this.check(new tz({check:"string_format",format:"uppercase",...ew(e)}))},trim(){return this.check(ic(e=>e.trim()))},normalize(...e){return this.check(function(e){return ic(t=>t.normalize(e))}(...e))},toLowerCase(){return this.check(ic(e=>e.toLowerCase()))},toUpperCase(){return this.check(ic(e=>e.toUpperCase()))},slugify(){return this.check(ic(e=>e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")))}})),nA=eB("ZodString",(e,t)=>{tJ.init(e,t),nz.init(e,t)},{email(e){return this.check(r6(nD,e))},url(e){return this.check(r5(nV,e))},jwt(e){return this.check(new n5({type:"string",format:"jwt",check:"string_format",abort:!1,...ew(e)}))},emoji(e){return this.check(new nB({type:"string",format:"emoji",check:"string_format",abort:!1,...ew(e)}))},guid(e){return this.check(new nH({type:"string",format:"guid",check:"string_format",abort:!1,...ew(e)}))},uuid(e){return this.check(new nJ({type:"string",format:"uuid",check:"string_format",abort:!1,...ew(e)}))},uuidv4(e){return this.check(new nJ({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...ew(e)}))},uuidv6(e){return this.check(new nJ({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...ew(e)}))},uuidv7(e){return this.check(new nJ({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...ew(e)}))},nanoid(e){return this.check(new nW({type:"string",format:"nanoid",check:"string_format",abort:!1,...ew(e)}))},cuid(e){return this.check(new nG({type:"string",format:"cuid",check:"string_format",abort:!1,...ew(e)}))},cuid2(e){return this.check(new nK({type:"string",format:"cuid2",check:"string_format",abort:!1,...ew(e)}))},ulid(e){return this.check(new nY({type:"string",format:"ulid",check:"string_format",abort:!1,...ew(e)}))},base64(e){return this.check(new n4({type:"string",format:"base64",check:"string_format",abort:!1,...ew(e)}))},base64url(e){return this.check(new n3({type:"string",format:"base64url",check:"string_format",abort:!1,...ew(e)}))},xid(e){return this.check(new nX({type:"string",format:"xid",check:"string_format",abort:!1,...ew(e)}))},ksuid(e){return this.check(new nQ({type:"string",format:"ksuid",check:"string_format",abort:!1,...ew(e)}))},ipv4(e){return this.check(new n0({type:"string",format:"ipv4",check:"string_format",abort:!1,...ew(e)}))},ipv6(e){return this.check(new n1({type:"string",format:"ipv6",check:"string_format",abort:!1,...ew(e)}))},cidrv4(e){return this.check(new n2({type:"string",format:"cidrv4",check:"string_format",abort:!1,...ew(e)}))},cidrv6(e){return this.check(new n9({type:"string",format:"cidrv6",check:"string_format",abort:!1,...ew(e)}))},e164(e){return this.check(new n6({type:"string",format:"e164",check:"string_format",abort:!1,...ew(e)}))},datetime(e){return this.check(r7(nL,e))},date(e){return this.check(r8(nZ,e))},time(e){return this.check(new nU({type:"string",format:"time",check:"string_format",precision:null,...ew(e)}))},duration(e){return this.check(new nF({type:"string",format:"duration",check:"string_format",...ew(e)}))}});function nN(e){return new nA(r3({type:"string",...ew(e)}))}let nM=eB("ZodStringFormat",(e,t)=>{tV.init(e,t),nz.init(e,t)}),nL=eB("ZodISODateTime",(e,t)=>{t5.init(e,t),nM.init(e,t)}),nZ=eB("ZodISODate",(e,t)=>{t7.init(e,t),nM.init(e,t)}),nU=eB("ZodISOTime",(e,t)=>{t8.init(e,t),nM.init(e,t)}),nF=eB("ZodISODuration",(e,t)=>{re.init(e,t),nM.init(e,t)}),nD=eB("ZodEmail",(e,t)=>{tG.init(e,t),nM.init(e,t)}),nH=eB("ZodGUID",(e,t)=>{tB.init(e,t),nM.init(e,t)}),nJ=eB("ZodUUID",(e,t)=>{tW.init(e,t),nM.init(e,t)}),nV=eB("ZodURL",(e,t)=>{tQ.init(e,t),nM.init(e,t)}),nB=eB("ZodEmoji",(e,t)=>{t0.init(e,t),nM.init(e,t)}),nW=eB("ZodNanoID",(e,t)=>{t1.init(e,t),nM.init(e,t)}),nG=eB("ZodCUID",(e,t)=>{t2.init(e,t),nM.init(e,t)}),nK=eB("ZodCUID2",(e,t)=>{t9.init(e,t),nM.init(e,t)}),nY=eB("ZodULID",(e,t)=>{t4.init(e,t),nM.init(e,t)}),nX=eB("ZodXID",(e,t)=>{t3.init(e,t),nM.init(e,t)}),nQ=eB("ZodKSUID",(e,t)=>{t6.init(e,t),nM.init(e,t)}),n0=eB("ZodIPv4",(e,t)=>{rt.init(e,t),nM.init(e,t)}),n1=eB("ZodIPv6",(e,t)=>{rn.init(e,t),nM.init(e,t)}),n2=eB("ZodCIDRv4",(e,t)=>{ra.init(e,t),nM.init(e,t)}),n9=eB("ZodCIDRv6",(e,t)=>{ro.init(e,t),nM.init(e,t)}),n4=eB("ZodBase64",(e,t)=>{rc.init(e,t),nM.init(e,t)}),n3=eB("ZodBase64URL",(e,t)=>{rd.init(e,t),nM.init(e,t)}),n6=eB("ZodE164",(e,t)=>{rp.init(e,t),nM.init(e,t)}),n5=eB("ZodJWT",(e,t)=>{rm.init(e,t),nM.init(e,t)}),n7=eB("ZodNumber",(e,t)=>{rh.init(e,t),nj.init(e,t),e._zod.processJSONSchema=(t,r,i)=>iL(e,t,r,i),e.isFinite=!0},eZ({minValue:e=>{let{minimum:t,exclusiveMinimum:r}=ij(e);return Math.max(t??-1/0,r??-1/0)},maxValue:e=>{let{maximum:t,exclusiveMaximum:r}=ij(e);return Math.min(t??1/0,r??1/0)},isInt:e=>{let{isInt:t,multipleOf:r}=ij(e);return!!t||!!r?.some(Number.isSafeInteger)},format:e=>ij(e).format??null},{gt(e,t){return this.check(ir(e,t))},gte(e,t){return this.check(ii(e,t))},min(e,t){return this.check(ii(e,t))},lt(e,t){return this.check(ie(e,t))},lte(e,t){return this.check(it(e,t))},max(e,t){return this.check(it(e,t))},int(e){return this.check(at(e))},safe(e){return this.check(at(e))},positive(e){return this.check(ir(0,e))},nonnegative(e){return this.check(ii(0,e))},negative(e){return this.check(ie(0,e))},nonpositive(e){return this.check(it(0,e))},multipleOf(e,t){return this.check(ia(e,t))},step(e,t){return this.check(ia(e,t))},finite(){return this}}));function n8(e){return new n7(r3({type:"number",checks:[],...ew(e)}))}let ae=eB("ZodNumberFormat",(e,t)=>{rf.init(e,t),n7.init(e,t)});function at(e){return new ae({type:"number",check:"number_format",abort:!1,format:"safeint",...ew(e)})}let ar=eB("ZodBoolean",(e,t)=>{rg.init(e,t),nj.init(e,t),e._zod.processJSONSchema=(t,r,i)=>iZ(e,t,r,i)});function ai(e){return new ar({type:"boolean",...ew(e)})}let an=eB("ZodNull",(e,t)=>{ry.init(e,t),nj.init(e,t),e._zod.processJSONSchema=(t,r,i)=>iU(e,t,r,i)});function aa(e){return new an({type:"null",...ew(e)})}let ao=eB("ZodAny",(e,t)=>{rv.init(e,t),nj.init(e,t),e._zod.processJSONSchema=(t,r,i)=>iD(e,t,r,i)}),as=eB("ZodUnknown",(e,t)=>{r_.init(e,t),nj.init(e,t),e._zod.processJSONSchema=(t,r,i)=>iH(e,t,r,i)});function al(){return new as({type:"unknown"})}let ac=eB("ZodNever",(e,t)=>{rb.init(e,t),nj.init(e,t),e._zod.processJSONSchema=(t,r,i)=>iF(e,t,r,i)}),au=eB("ZodArray",(e,t)=>{nq(),rR.init(e,t),nj.init(e,t),e._zod.processJSONSchema=(t,r,i)=>iG(e,t,r,i),e.element=t.element},{min(e,t){return this.check(is(e,t))},nonempty(e){return this.check(is(1,e))},max(e,t){return this.check(io(e,t))},length(e,t){return this.check(il(e,t))},unwrap(){return this.element}});function ad(e,t){return new au({type:"array",element:e,...ew(t)})}let ap=eB("ZodObject",(e,t)=>{var r;let i,n;nq(),rP.init(e,t),nj.init(e,t),e._zod.processJSONSchema=(t,r,i)=>iY(e,t,r,i),r="shape",(n=r in(i=Object.getPrototypeOf(e))?void 0:i)&&Object.defineProperty(n,r,{configurable:!0,get(){let e={configurable:!0,writable:!0,enumerable:!1,value:void 0};return Object.defineProperty(this,r,e),e.value=(e=>e._zod.def.shape)(this),Object.defineProperty(this,r,e),e.value},set(e){Object.defineProperty(this,r,{configurable:!0,writable:!0,enumerable:!1,value:e})}})},{keyof(){return ak(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(em(this._zod.def,{catchall:e}))},passthrough(){return this.clone(em(this._zod.def,{catchall:al()}))},loose(){return this.clone(em(this._zod.def,{catchall:al()}))},strict(){return this.clone(em(this._zod.def,{catchall:new ac({type:"never",...ew(void 0)})}))},strip(){return this.clone(em(this._zod.def,{catchall:void 0}))},extend(e){if(!ey(e))throw Error("Invalid input to extend: expected a plain object");let t=this._zod.def.checks;if(t&&t.length>0){let t=ec(this);for(let r of Reflect.ownKeys(e))if(void 0!==Object.getOwnPropertyDescriptor(t,r))throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return eS(this,em(this._zod.def,{shape:eT(this,e)}))},safeExtend(e){if(!ey(e))throw Error("Invalid input to safeExtend: expected a plain object");return eS(this,em(this._zod.def,{shape:eT(this,e)}))},merge(e){if(!e?._zod?.def)throw Error("Invalid input to merge: expected an object schema. To merge a plain shape, use `.extend()`.");if(this._zod.def.checks?.length)throw Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");let t={};return ep(t,this,Reflect.ownKeys(ec(this))),ep(t,e,Reflect.ownKeys(ec(e))),eS(this,em(this._zod.def,{shape:t,get catchall(){return e._zod.def.catchall},checks:e._zod.def.checks??[]}))},pick(e){return function(e,t){let r=e._zod.def,i=r.checks;if(i&&i.length>0)throw Error(".pick() cannot be used on object schemas containing refinements");let n={};return ep(n,e,e$(e,t)),eS(e,em(r,{shape:n,checks:[]}))}(this,e)},omit(e){return function(e,t){let r=e._zod.def,i=r.checks;if(i&&i.length>0)throw Error(".omit() cannot be used on object schemas containing refinements");let n=new Set(e$(e,t)),a={};return ep(a,e,Reflect.ownKeys(ec(e)).filter(e=>!n.has(e))),eS(e,em(r,{shape:a,checks:[]}))}(this,e)},partial(...e){return eC(aP,this,e[0])},exactPartial(...e){return eC(aE,this,e[0],"exactPartial")},required(...e){var t;let r,i;return r=(t=e[0])?new Set(e$(this,t)):void 0,ep(i={},this,Reflect.ownKeys(ec(this)),(e,t)=>r&&!r.has(t)?e:new aA({type:"nonoptional",innerType:e})),eS(this,em(this._zod.def,{shape:i}))}});function am(e,t){return new ap({type:"object",shape:e??{},...ew(t)})}function ah(e,t){return new ap({type:"object",shape:e,catchall:al(),...ew(t)})}let af=eB("ZodUnion",(e,t)=>{rE.init(e,t),nj.init(e,t),e._zod.processJSONSchema=(t,r,i)=>iX(e,t,r,i),e.options=t.options});function ag(e,t){return new af({type:"union",options:e,...ew(t)})}let ay=eB("ZodDiscriminatedUnion",(e,t)=>{af.init(e,t),rI.init(e,t)});function av(e,t,r){return new ay({type:"union",options:t,discriminator:e,...ew(r)})}let a_=eB("ZodIntersection",(e,t)=>{rq.init(e,t),nj.init(e,t),e._zod.processJSONSchema=(t,r,i)=>iQ(e,t,r,i)});function ab(e,t){return new a_({type:"intersection",left:e,right:t})}let aS=eB("ZodRecord",(e,t)=>{nq(),rz.init(e,t),nj.init(e,t),e._zod.processJSONSchema=(t,r,i)=>i1(e,t,r,i),e.keyType=t.keyType,e.valueType=t.valueType});function aw(e,t,r){return new aS(t&&t._zod?{type:"record",keyType:e,valueType:t,...ew(r)}:{type:"record",keyType:nN(),valueType:e,...ew(t)})}let aR=eB("ZodEnum",(e,t)=>{rA.init(e,t),nj.init(e,t),e._zod.processJSONSchema=(t,r,i)=>iJ(e,t,r,i),e.enum=t.entries,e.options=[...e._zod.values];let r=new Set(Object.keys(t.entries));e.extract=(e,i)=>{let n={};for(let i of e)if(r.has(i))n[i]=t.entries[i];else throw Error(`Key ${i} not found in enum`);return new aR({...t,checks:[],...ew(i),entries:n})},e.exclude=(e,i)=>{let n={...t.entries};for(let t of e)if(r.has(t))delete n[t];else throw Error(`Key ${t} not found in enum`);return new aR({...t,checks:[],...ew(i),entries:n})}});function ak(e,t){return new aR({type:"enum",entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...ew(t)})}let ax=eB("ZodLiteral",(e,t)=>{rN.init(e,t),nj.init(e,t),e._zod.processJSONSchema=(t,r,i)=>iV(e,t,r,i),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function a$(e,t){return new ax({type:"literal",values:Array.isArray(e)?e:[e],...ew(t)})}let aT=eB("ZodTransform",(e,t)=>{nq(),rM.init(e,t),nj.init(e,t),e._zod.processJSONSchema=(t,r,i)=>iW(e,t,r,i),e._zod.parse=(r,i)=>{if("backward"===i.direction)throw new eG(e.constructor.name);r.addIssue=i=>{"string"==typeof i?r.issues.push(eM(i,r.value,t)):(i.fatal&&(i.continue=!1),i.code??(i.code="custom"),"input"in i||(i.input=r.value),i.inst??(i.inst=e),r.issues.push(eM(i)))};let n=t.transform(r.value,r);return n instanceof Promise?n.then(e=>(r.value=e,r)):(r.value=n,r)}});function aC(e){return new aT({type:"transform",transform:e})}let aP=eB("ZodOptional",(e,t)=>{rZ.init(e,t),nj.init(e,t),e._zod.processJSONSchema=(t,r,i)=>nt(e,t,r,i),e.unwrap=()=>e._zod.def.innerType});function aO(e){return new aP({type:"optional",innerType:e})}let aE=eB("ZodExactOptional",(e,t)=>{rU.init(e,t),nj.init(e,t),e._zod.processJSONSchema=(t,r,i)=>nt(e,t,r,i),e.unwrap=()=>e._zod.def.innerType}),aI=eB("ZodNullable",(e,t)=>{rF.init(e,t),nj.init(e,t),e._zod.processJSONSchema=(t,r,i)=>i2(e,t,r,i),e.unwrap=()=>e._zod.def.innerType});function aq(e){return new aI({type:"nullable",innerType:e})}let aj=eB("ZodDefault",(e,t)=>{rD.init(e,t),nj.init(e,t),e._zod.processJSONSchema=(t,r,i)=>i6(e,t,r,i),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap}),az=eB("ZodPrefault",(e,t)=>{rJ.init(e,t),nj.init(e,t),e._zod.processJSONSchema=(t,r,i)=>i5(e,t,r,i),e.unwrap=()=>e._zod.def.innerType}),aA=eB("ZodNonOptional",(e,t)=>{rV.init(e,t),nj.init(e,t),e._zod.processJSONSchema=(t,r,i)=>i9(e,t,r,i),e.unwrap=()=>e._zod.def.innerType}),aN=eB("ZodCatch",(e,t)=>{rG.init(e,t),nj.init(e,t),e._zod.processJSONSchema=(t,r,i)=>i7(e,t,r,i),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap}),aM=eB("ZodPipe",(e,t)=>{rK.init(e,t),nj.init(e,t),e._zod.processJSONSchema=(t,r,i)=>i8(e,t,r,i),e.in=t.in,e.out=t.out});function aL(e,t){return new aM({type:"pipe",in:e,out:t})}let aZ=eB("ZodPreprocess",(e,t)=>{aM.init(e,t),rX.init(e,t)}),aU=eB("ZodReadonly",(e,t)=>{rQ.init(e,t),nj.init(e,t),e._zod.processJSONSchema=(t,r,i)=>ne(e,t,r,i),e.unwrap=()=>e._zod.def.innerType}),aF=eB("ZodLazy",(e,t)=>{r1.init(e,t),nj.init(e,t),e._zod.processJSONSchema=(t,r,i)=>nr(e,t,r,i),e.unwrap=()=>e._zod.def.getter()});function aD(e){return new aF({type:"lazy",getter:e})}let aH=eB("ZodCustom",(e,t)=>{r2.init(e,t),nj.init(e,t),e._zod.processJSONSchema=(t,r,i)=>iB(e,t,r,i)});function aJ(e,t){return new aZ({type:"pipe",in:aC(e),out:t})}let aV="2025-11-25",aB=[aV,"2025-06-18","2025-03-26","2024-11-05","2024-10-07"],aW="io.modelcontextprotocol/protocolVersion",aG="io.modelcontextprotocol/clientInfo",aK="io.modelcontextprotocol/serverInfo",aY="io.modelcontextprotocol/clientCapabilities",aX="io.modelcontextprotocol/subscriptionId",aQ="io.modelcontextprotocol/logLevel",a0=aD(()=>ag([nN(),n8(),ai(),aa(),aw(nN(),a0),ad(a0)])),a1=aw(nN(),a0),a2=ad(a0),a9=ag([nN(),n8().int()]),a4=nN(),a3=am({ttl:n8().optional()}),a6=am({taskId:nN()}),a5=ah({progressToken:a9.optional(),"io.modelcontextprotocol/related-task":a6.optional()}),a7=am({_meta:a5.optional()}),a8=a7.extend({task:a3.optional()}),oe=am({method:nN(),params:a7.loose().optional()}),ot=am({_meta:a5.optional()}),or=am({method:nN(),params:ot.loose().optional()}),oi=ah({get[aK](){return ov.optional().catch(void 0)}}),on=ah({_meta:oi.optional()}),oa=ag([nN(),n8().int()]),oo=am({jsonrpc:a$("2.0"),id:oa,...oe.shape}).strict(),os=am({jsonrpc:a$("2.0"),...or.shape}).strict(),ol=am({jsonrpc:a$("2.0"),id:oa,result:on}).strict(),oc=am({jsonrpc:a$("2.0"),id:oa.optional(),error:am({code:n8().int(),message:nN(),data:al().optional()})}).strict(),ou=ag([oo,os,ol,oc]),od=ag([ol,oc]),op=on.strict(),om=ot.extend({requestId:oa.optional(),reason:nN().optional()}),oh=or.extend({method:a$("notifications/cancelled"),params:om}),of=am({src:nN(),mimeType:nN().optional(),sizes:ad(nN()).optional(),theme:ak(["light","dark"]).optional()}),og=am({icons:ad(of).optional()}),oy=am({name:nN(),title:nN().optional()}),ov=oy.extend({...oy.shape,...og.shape,version:nN(),websiteUrl:nN().optional(),description:nN().optional()}),o_=ab(am({applyDefaults:ai().optional()}),a1),ob=aJ(e=>e&&"object"==typeof e&&!Array.isArray(e)&&0===Object.keys(e).length?{form:{}}:e,ab(am({form:o_.optional(),url:a1.optional()}),a1.optional())),oS=ah({list:a1.optional(),cancel:a1.optional(),requests:ah({sampling:ah({createMessage:a1.optional()}).optional(),elicitation:ah({create:a1.optional()}).optional()}).optional()}),ow=ah({list:a1.optional(),cancel:a1.optional(),requests:ah({tools:ah({call:a1.optional()}).optional()}).optional()}),oR=am({experimental:aw(nN(),a1).optional(),sampling:am({context:a1.optional(),tools:a1.optional()}).optional(),elicitation:ob.optional(),roots:am({listChanged:ai().optional()}).optional(),tasks:oS.optional(),extensions:aw(nN(),a1).optional()}),ok=a7.extend({protocolVersion:nN(),capabilities:oR,clientInfo:ov}),ox=oe.extend({method:a$("initialize"),params:ok}),o$=am({experimental:aw(nN(),a1).optional(),logging:a1.optional(),completions:a1.optional(),prompts:am({listChanged:ai().optional()}).optional(),resources:am({subscribe:ai().optional(),listChanged:ai().optional()}).optional(),tools:am({listChanged:ai().optional()}).optional(),tasks:ow.optional(),extensions:aw(nN(),a1).optional()}),oT=on.extend({protocolVersion:nN(),capabilities:o$,serverInfo:ov,instructions:nN().optional()}),oC=or.extend({method:a$("notifications/initialized"),params:ot.optional()}),oP=oe.extend({method:a$("server/discover"),params:a7.optional()}),oO=on.extend({supportedVersions:ad(nN()),capabilities:o$,instructions:nN().optional()}),oE=oe.extend({method:a$("ping"),params:a7.optional()}),oI=am({progress:n8(),total:aO(n8()),message:aO(nN())}),oq=am({...ot.shape,...oI.shape,progressToken:a9}),oj=or.extend({method:a$("notifications/progress"),params:oq}),oz=a7.extend({cursor:a4.optional()}),oA=oe.extend({params:oz.optional()}),oN=on.extend({nextCursor:a4.optional()}),oM=am({uri:nN(),mimeType:aO(nN()),_meta:aw(nN(),al()).optional()}),oL=oM.extend({text:nN()}),oZ=nN().refine(e=>{try{return atob(e),!0}catch{return!1}},{message:"Invalid Base64 string"}),oU=oM.extend({blob:oZ}),oF=ak(["user","assistant"]),oD=am({audience:ad(oF).optional(),priority:n8().min(0).max(1).optional(),lastModified:r7(nL,{offset:!0}).optional()}),oH=am({...oy.shape,...og.shape,uri:nN(),description:aO(nN()),mimeType:aO(nN()),size:aO(n8()),annotations:oD.optional(),_meta:aO(ah({}))}),oJ=am({...oy.shape,...og.shape,uriTemplate:nN(),description:aO(nN()),mimeType:aO(nN()),annotations:oD.optional(),_meta:aO(ah({}))}),oV=oA.extend({method:a$("resources/list")}),oB=oN.extend({resources:ad(oH)}),oW=oA.extend({method:a$("resources/templates/list")}),oG=oN.extend({resourceTemplates:ad(oJ)}),oK=a7.extend({uri:nN()}),oY=oe.extend({method:a$("resources/read"),params:oK}),oX=on.extend({contents:ad(ag([oL,oU]))}),oQ=or.extend({method:a$("notifications/resources/list_changed"),params:ot.optional()}),o0=oe.extend({method:a$("resources/subscribe"),params:oK}),o1=oe.extend({method:a$("resources/unsubscribe"),params:oK}),o2=am({toolsListChanged:ai().optional(),promptsListChanged:ai().optional(),resourcesListChanged:ai().optional(),resourceSubscriptions:ad(nN()).optional()}),o9=a7.extend({notifications:o2}),o4=oe.extend({method:a$("subscriptions/listen"),params:o9}),o3=ot.extend({notifications:o2}),o6=or.extend({method:a$("notifications/subscriptions/acknowledged"),params:o3}),o5=oi.extend({[aX]:oa}),o7=on.extend({_meta:o5}),o8=ot.extend({uri:nN()}),se=or.extend({method:a$("notifications/resources/updated"),params:o8}),st=am({name:nN(),description:aO(nN()),required:aO(ai())}),sr=am({...oy.shape,...og.shape,description:aO(nN()),arguments:aO(ad(st)),_meta:aO(ah({}))}),si=oA.extend({method:a$("prompts/list")}),sn=oN.extend({prompts:ad(sr)}),sa=a7.extend({name:nN(),arguments:aw(nN(),nN()).optional()}),so=oe.extend({method:a$("prompts/get"),params:sa}),ss=am({type:a$("text"),text:nN(),annotations:oD.optional(),_meta:aw(nN(),al()).optional()}),sl=am({type:a$("image"),data:oZ,mimeType:nN(),annotations:oD.optional(),_meta:aw(nN(),al()).optional()}),sc=am({type:a$("audio"),data:oZ,mimeType:nN(),annotations:oD.optional(),_meta:aw(nN(),al()).optional()}),su=am({type:a$("tool_use"),name:nN(),id:nN(),input:aw(nN(),al()),_meta:aw(nN(),al()).optional()}),sd=am({type:a$("resource"),resource:ag([oL,oU]),annotations:oD.optional(),_meta:aw(nN(),al()).optional()}),sp=oH.extend({type:a$("resource_link")}),sm=ag([ss,sl,sc,sp,sd]),sh=am({role:oF,content:sm}),sf=on.extend({description:nN().optional(),messages:ad(sh)}),sg=or.extend({method:a$("notifications/prompts/list_changed"),params:ot.optional()}),sy=am({title:nN().optional(),readOnlyHint:ai().optional(),destructiveHint:ai().optional(),idempotentHint:ai().optional(),openWorldHint:ai().optional()}),sv=am({taskSupport:ak(["required","optional","forbidden"]).optional()}),s_=am({...oy.shape,...og.shape,description:nN().optional(),inputSchema:am({type:a$("object"),properties:aw(nN(),a0).optional(),required:ad(nN()).optional()}).catchall(al()),outputSchema:ah({$schema:nN().optional()}).optional(),annotations:sy.optional(),execution:sv.optional(),_meta:aw(nN(),al()).optional()}),sb=oA.extend({method:a$("tools/list")}),sS=oN.extend({tools:ad(s_)}),sw=on.extend({content:ad(sm).default([]),structuredContent:al().optional(),isError:ai().optional()}),sR=sw.or(on.extend({toolResult:al()})),sk=a8.extend({name:nN(),arguments:aw(nN(),al()).optional()}),sx=oe.extend({method:a$("tools/call"),params:sk}),s$=or.extend({method:a$("notifications/tools/list_changed"),params:ot.optional()}),sT=am({autoRefresh:ai().default(!0),debounceMs:n8().int().nonnegative().default(300)}),sC=ak(["debug","info","notice","warning","error","critical","alert","emergency"]),sP=a7.extend({level:sC}),sO=oe.extend({method:a$("logging/setLevel"),params:sP}),sE=ot.extend({level:sC,logger:nN().optional(),data:al()}),sI=or.extend({method:a$("notifications/message"),params:sE}),sq=am({name:nN().optional()}),sj=am({hints:ad(sq).optional(),costPriority:n8().min(0).max(1).optional(),speedPriority:n8().min(0).max(1).optional(),intelligencePriority:n8().min(0).max(1).optional()}),sz=am({mode:ak(["auto","required","none"]).optional()}),sA=am({type:a$("tool_result"),toolUseId:nN().describe("The unique identifier for the corresponding tool call."),content:ad(sm),structuredContent:al().optional(),isError:ai().optional(),_meta:aw(nN(),al()).optional()}),sN=av("type",[ss,sl,sc]),sM=av("type",[ss,sl,sc,su,sA]),sL=am({role:oF,content:ag([sM,ad(sM)]),_meta:aw(nN(),al()).optional()}),sZ=a8.extend({messages:ad(sL),modelPreferences:sj.optional(),systemPrompt:nN().optional(),includeContext:ak(["none","thisServer","allServers"]).optional(),temperature:n8().optional(),maxTokens:n8().int(),stopSequences:ad(nN()).optional(),metadata:a1.optional(),tools:ad(s_).optional(),toolChoice:sz.optional()}),sU=oe.extend({method:a$("sampling/createMessage"),params:sZ}),sF=on.extend({model:nN(),stopReason:aO(ak(["endTurn","stopSequence","maxTokens"]).or(nN())),role:oF,content:sN}),sD=on.extend({model:nN(),stopReason:aO(ak(["endTurn","stopSequence","maxTokens","toolUse"]).or(nN())),role:oF,content:ag([sM,ad(sM)])}),sH=am({type:a$("boolean"),title:nN().optional(),description:nN().optional(),default:ai().optional()}),sJ=am({type:a$("string"),title:nN().optional(),description:nN().optional(),minLength:n8().optional(),maxLength:n8().optional(),format:ak(["email","uri","date","date-time"]).optional(),default:nN().optional()}),sV=am({type:ak(["number","integer"]),title:nN().optional(),description:nN().optional(),minimum:n8().optional(),maximum:n8().optional(),default:n8().optional()}),sB=am({type:a$("string"),title:nN().optional(),description:nN().optional(),enum:ad(nN()),default:nN().optional()}),sW=am({type:a$("string"),title:nN().optional(),description:nN().optional(),oneOf:ad(am({const:nN(),title:nN()})),default:nN().optional()}),sG=am({type:a$("string"),title:nN().optional(),description:nN().optional(),enum:ad(nN()),enumNames:ad(nN()).optional(),default:nN().optional()}),sK=ag([sB,sW]),sY=am({type:a$("array"),title:nN().optional(),description:nN().optional(),minItems:n8().optional(),maxItems:n8().optional(),items:am({type:a$("string"),enum:ad(nN())}),default:ad(nN()).optional()}),sX=am({type:a$("array"),title:nN().optional(),description:nN().optional(),minItems:n8().optional(),maxItems:n8().optional(),items:am({anyOf:ad(am({const:nN(),title:nN()}))}),default:ad(nN()).optional()}),sQ=ag([sY,sX]),s0=ag([sG,sK,sQ]),s1=ag([s0,sH,sJ,sV]),s2=a8.extend({mode:a$("form").optional(),message:nN(),requestedSchema:am({type:a$("object"),properties:aw(nN(),s1),required:ad(nN()).optional()}).catchall(al())}),s9=a8.extend({mode:a$("url"),message:nN(),elicitationId:nN(),url:nN().url()}),s4=ag([s2,s9]),s3=oe.extend({method:a$("elicitation/create"),params:s4}),s6=ot.extend({elicitationId:nN()}),s5=or.extend({method:a$("notifications/elicitation/complete"),params:s6}),s7=on.extend({action:ak(["accept","decline","cancel"]),content:aJ(e=>null===e?void 0:e,aw(nN(),ag([nN(),n8(),ai(),ad(nN())])).optional())}),s8=am({type:a$("ref/resource"),uri:nN()}),le=am({type:a$("ref/prompt"),name:nN()}),lt=a7.extend({ref:ag([le,s8]),argument:am({name:nN(),value:nN()}),context:am({arguments:aw(nN(),nN()).optional()}).optional()}),lr=oe.extend({method:a$("completion/complete"),params:lt}),li=on.extend({completion:ah({values:ad(nN()).max(100),total:aO(n8().int()),hasMore:aO(ai())})}),ln=am({uri:nN().startsWith("file://"),name:nN().optional(),_meta:aw(nN(),al()).optional()}),la=oe.extend({method:a$("roots/list"),params:a7.optional()}),lo=on.extend({roots:ad(ln)}),ls=or.extend({method:a$("notifications/roots/list_changed"),params:ot.optional()}),ll=ah({ttl:n8().optional(),pollInterval:n8().optional()}),lc=ak(["working","input_required","completed","failed","cancelled"]),lu=am({taskId:nN(),status:lc,ttl:ag([n8(),aa()]),createdAt:nN(),lastUpdatedAt:nN(),pollInterval:aO(n8()),statusMessage:aO(nN())}),ld=on.extend({task:lu}),lp=ot.merge(lu),lm=or.extend({method:a$("notifications/tasks/status"),params:lp}),lh=oe.extend({method:a$("tasks/get"),params:a7.extend({taskId:nN()})}),lf=on.merge(lu),lg=oe.extend({method:a$("tasks/result"),params:a7.extend({taskId:nN()})}),ly=on.loose(),lv=oA.extend({method:a$("tasks/list")}),l_=oN.extend({tasks:ad(lu)}),lb=oe.extend({method:a$("tasks/cancel"),params:a7.extend({taskId:nN()})}),lS=on.merge(lu),lw=ag([oE,ox,oP,lr,sO,so,si,oV,oW,oY,o0,o1,o4,sx,sb]),lR=ag([oh,oj,oC,ls]),lk=ag([op,sF,sD,s7,lo]),lx=ag([oE,sU,s3,la]),l$=ag([oh,oj,sI,se,oQ,s$,sg,o6,s5]),lT=ag([op,oT,oO,li,sf,sn,oB,oG,oX,sw,sS,o7]);z||(z={});let lC=r5(nV,void 0).superRefine((e,t)=>{if(!URL.canParse(e))return t.addIssue({code:"custom",message:"URL must be parseable",fatal:!0}),eH}).refine(e=>{let t=new URL(e);return"javascript:"!==t.protocol&&"data:"!==t.protocol&&"vbscript:"!==t.protocol},{message:"URL cannot use javascript:, data:, or vbscript: scheme"}),lP=ah({resource:nN().url(),authorization_servers:ad(lC).optional(),jwks_uri:nN().url().optional(),scopes_supported:ad(nN()).optional(),bearer_methods_supported:ad(nN()).optional(),resource_signing_alg_values_supported:ad(nN()).optional(),resource_name:nN().optional(),resource_documentation:nN().optional(),resource_policy_uri:nN().url().optional(),resource_tos_uri:nN().url().optional(),tls_client_certificate_bound_access_tokens:ai().optional(),authorization_details_types_supported:ad(nN()).optional(),dpop_signing_alg_values_supported:ad(nN()).optional(),dpop_bound_access_tokens_required:ai().optional()}),lO=ah({issuer:nN(),authorization_endpoint:lC,token_endpoint:lC,registration_endpoint:lC.optional(),scopes_supported:ad(nN()).optional(),response_types_supported:ad(nN()),response_modes_supported:ad(nN()).optional(),grant_types_supported:ad(nN()).optional(),token_endpoint_auth_methods_supported:ad(nN()).optional(),token_endpoint_auth_signing_alg_values_supported:ad(nN()).optional(),service_documentation:lC.optional(),revocation_endpoint:lC.optional(),revocation_endpoint_auth_methods_supported:ad(nN()).optional(),revocation_endpoint_auth_signing_alg_values_supported:ad(nN()).optional(),introspection_endpoint:nN().optional(),introspection_endpoint_auth_methods_supported:ad(nN()).optional(),introspection_endpoint_auth_signing_alg_values_supported:ad(nN()).optional(),code_challenge_methods_supported:ad(nN()).optional(),client_id_metadata_document_supported:ai().optional(),authorization_response_iss_parameter_supported:ai().optional().catch(void 0),dpop_signing_alg_values_supported:ad(nN()).optional()}),lE=ah({issuer:nN(),authorization_endpoint:lC,token_endpoint:lC,userinfo_endpoint:lC.optional(),jwks_uri:lC,registration_endpoint:lC.optional(),scopes_supported:ad(nN()).optional(),response_types_supported:ad(nN()),response_modes_supported:ad(nN()).optional(),grant_types_supported:ad(nN()).optional(),acr_values_supported:ad(nN()).optional(),subject_types_supported:ad(nN()),id_token_signing_alg_values_supported:ad(nN()),id_token_encryption_alg_values_supported:ad(nN()).optional(),id_token_encryption_enc_values_supported:ad(nN()).optional(),userinfo_signing_alg_values_supported:ad(nN()).optional(),userinfo_encryption_alg_values_supported:ad(nN()).optional(),userinfo_encryption_enc_values_supported:ad(nN()).optional(),request_object_signing_alg_values_supported:ad(nN()).optional(),request_object_encryption_alg_values_supported:ad(nN()).optional(),request_object_encryption_enc_values_supported:ad(nN()).optional(),token_endpoint_auth_methods_supported:ad(nN()).optional(),token_endpoint_auth_signing_alg_values_supported:ad(nN()).optional(),display_values_supported:ad(nN()).optional(),claim_types_supported:ad(nN()).optional(),claims_supported:ad(nN()).optional(),service_documentation:nN().optional(),claims_locales_supported:ad(nN()).optional(),ui_locales_supported:ad(nN()).optional(),claims_parameter_supported:ai().optional(),request_parameter_supported:ai().optional(),request_uri_parameter_supported:ai().optional(),require_request_uri_registration:ai().optional(),op_policy_uri:lC.optional(),op_tos_uri:lC.optional(),client_id_metadata_document_supported:ai().optional(),authorization_response_iss_parameter_supported:ai().optional().catch(void 0)}),lI=am({...lE.shape,...lO.pick({code_challenge_methods_supported:!0}).shape}),lq=am({access_token:nN(),id_token:nN().optional(),token_type:nN(),expires_in:new n7(r3({type:"number",coerce:!0,checks:[],...ew(void 0)})).optional(),scope:nN().optional(),refresh_token:nN().optional(),issuer:nN().optional().catch(void 0)}).strip(),lj=am({issued_token_type:a$("urn:ietf:params:oauth:token-type:id-jag"),access_token:nN(),token_type:nN().optional(),expires_in:n8().optional(),scope:nN().optional()}).strip(),lz=am({error:nN(),error_description:nN().optional(),error_uri:nN().optional()}),lA=lC.optional().or(a$("").transform(()=>void 0)),lN=am({redirect_uris:ad(lC),token_endpoint_auth_method:nN().optional(),grant_types:ad(nN()).optional(),response_types:ad(nN()).optional(),application_type:nN().optional(),client_name:nN().optional(),client_uri:lC.optional(),logo_uri:lA,scope:nN().optional(),contacts:ad(nN()).optional(),tos_uri:lA,policy_uri:nN().optional(),jwks_uri:lC.optional(),jwks:new ao({type:"any"}).optional(),software_id:nN().optional(),software_version:nN().optional(),software_statement:nN().optional()}).strip(),lM=am({client_id:nN(),client_secret:nN().optional(),client_id_issued_at:n8().optional(),client_secret_expires_at:n8().optional(),issuer:nN().optional().catch(void 0)}).strip(),lL=lN.merge(lM),lZ=am({error:nN(),error_description:nN().optional()}).strip(),lU=am({token:nN(),token_type_hint:nN().optional()}).strip(),lF=Symbol.for("mcp.sdk.errorBrands");function lD(e,t){let r=new Set,i=t;for(;"function"==typeof i;){let e=i.mcpBrand;Object.prototype.hasOwnProperty.call(i,"mcpBrand")&&"string"==typeof e&&r.add(e),i=Object.getPrototypeOf(i)}0!==r.size&&Object.defineProperty(e,lF,{value:r,enumerable:!1,configurable:!0})}function lH(e,t){try{if("object"==typeof t&&null!==t&&Object.prototype.hasOwnProperty.call(e,"mcpBrand")&&"string"==typeof e.mcpBrand&&Object.prototype.hasOwnProperty.call(t,lF)){let r=t[lF];if(r&&"function"==typeof r.has&&r.has(e.mcpBrand))return!0}}catch{}return Function.prototype[Symbol.hasInstance].call(e,t)}let lJ=(($={}).InvalidRequest="invalid_request",$.InvalidClient="invalid_client",$.InvalidGrant="invalid_grant",$.UnauthorizedClient="unauthorized_client",$.UnsupportedGrantType="unsupported_grant_type",$.InvalidScope="invalid_scope",$.AccessDenied="access_denied",$.ServerError="server_error",$.TemporarilyUnavailable="temporarily_unavailable",$.UnsupportedResponseType="unsupported_response_type",$.UnsupportedTokenType="unsupported_token_type",$.InvalidToken="invalid_token",$.MethodNotAllowed="method_not_allowed",$.TooManyRequests="too_many_requests",$.InvalidClientMetadata="invalid_client_metadata",$.InvalidRedirectUri="invalid_redirect_uri",$.InsufficientScope="insufficient_scope",$.InvalidTarget="invalid_target",$.InvalidDpopProof="invalid_dpop_proof",$.UseDpopNonce="use_dpop_nonce",$);var lV=class e extends Error{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.OAuthError"})}static[Symbol.hasInstance](e){return lH(this,e)}static isInstance(e){if("function"!=typeof this)throw TypeError("isInstance must be called on the class (e.g. `SdkError.isInstance(value)`); for callbacks use `v => SdkError.isInstance(v)`");return lH(this,e)}constructor(e,t,r){super(t),this.code=e,this.errorUri=r,this.name="OAuthError",lD(this,new.target)}toResponseObject(){let e={error:this.code,error_description:this.message};return this.errorUri&&(e.error_uri=this.errorUri),e}static fromResponse(t){return new e(t.error,t.error_description??t.error,t.error_uri)}};let lB=((T={}).NotConnected="NOT_CONNECTED",T.AlreadyConnected="ALREADY_CONNECTED",T.NotInitialized="NOT_INITIALIZED",T.CapabilityNotSupported="CAPABILITY_NOT_SUPPORTED",T.RequestTimeout="REQUEST_TIMEOUT",T.ConnectionClosed="CONNECTION_CLOSED",T.SendFailed="SEND_FAILED",T.InvalidResult="INVALID_RESULT",T.UnsupportedResultType="UNSUPPORTED_RESULT_TYPE",T.InputRequiredRoundsExceeded="INPUT_REQUIRED_ROUNDS_EXCEEDED",T.ListPaginationExceeded="LIST_PAGINATION_EXCEEDED",T.MethodNotSupportedByProtocolVersion="METHOD_NOT_SUPPORTED_BY_PROTOCOL_VERSION",T.EraNegotiationFailed="ERA_NEGOTIATION_FAILED",T.ClientHttpNotImplemented="CLIENT_HTTP_NOT_IMPLEMENTED",T.ClientHttpAuthentication="CLIENT_HTTP_AUTHENTICATION",T.ClientHttpForbidden="CLIENT_HTTP_FORBIDDEN",T.ClientHttpUnexpectedContent="CLIENT_HTTP_UNEXPECTED_CONTENT",T.ClientHttpFailedToOpenStream="CLIENT_HTTP_FAILED_TO_OPEN_STREAM",T.ClientHttpFailedToTerminateSession="CLIENT_HTTP_FAILED_TO_TERMINATE_SESSION",T);var lW=class extends Error{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.SdkError"})}static[Symbol.hasInstance](e){return lH(this,e)}static isInstance(e){if("function"!=typeof this)throw TypeError("isInstance must be called on the class (e.g. `SdkError.isInstance(value)`); for callbacks use `v => SdkError.isInstance(v)`");return lH(this,e)}constructor(e,t,r,i){super(t,i),this.code=e,this.data=r,this.name="SdkError",lD(this,new.target)}};(class extends lW{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.SdkHttpError"})}constructor(e,t,r,i){super(e,t,r,i),this.name="SdkHttpError"}get status(){return this.data.status}get statusText(){return this.data.statusText}});let lG={};function lK(e){return null!==e&&"object"==typeof e&&!Array.isArray(e)}function lY(e,t){let r={};for(let[i,n]of Object.entries(e)){if(void 0===n)continue;let e=void 0===t?void 0:t[i];if(void 0===e){r[i]=n;continue}if(lK(n)&&lK(e)){let t={};for(let[r,a]of Object.entries(n))void 0!==a&&void 0===e[r]&&("elicitation"!==i||"form"!==r||void 0!==e.form||void 0!==e.url)&&(t[r]=a);Object.keys(t).length>0&&(r[i]=t)}}return Object.keys(r).length>0?r:void 0}let lX="2026-07-28",lQ=[lX];function l0(e){return e.filter(e=>e>=lX)}function l1(e){let t=e.structuredContent;return void 0===t||!("object"!=typeof t||null===t||Array.isArray(t))||e.content?.some(e=>"text"===e.type)?e:{...e,content:[...e.content??[],{type:"text",text:JSON.stringify(t)}]}}let l2=["task","inputRequests","requestState"];function l9(e){return null===e||"object"!=typeof e||Array.isArray(e)||void 0!==e.content||l2.some(t=>t in e)?e:{...e,content:[]}}function l4(){let e,t,i,n,a,o,s,l,c,u,d,p,m,h,f,g,y,v,_,b,S,w,R,k,x,$,T,C,P,O,E,I,q,j,z,A,N,M,L,Z,U,F,D,H,J,V,B,W,G,K,Y,X,Q,ee,et,er,ei,en,ea,eo,es,el,ec,eu,ed,ep,em,eh,ef,eg,ey,ev,e_,eb,eS,ew,eR,ek,ex,e$,eT,eC,eP,eO,eE,eI,eq,ej,ez,eA,eN,eM,eL,eZ,eU,eF,eD,eH,eJ,eV,eB,eW,eG,eK,eY,eX,eQ,e0,e1,e2,e9,e4,e3,e6,e5,e7,e8,te,tt,tr,ti,tn,ta,to,ts,tl,tc,tu,td,tp,tm,th,tf,tg,ty,tv,t_,tb,tS,tw;return r??=(e=aD(()=>ag([nN(),n8(),ai(),aa(),aw(nN(),e),ad(e)])),t=aw(nN(),e),i=ag([nN(),n8().int()]),n=nN(),a=am({ttl:n8().optional()}),o=am({taskId:nN()}),c=(l=am({_meta:(s=ah({progressToken:i.optional(),"io.modelcontextprotocol/related-task":o.optional()})).optional()})).extend({task:a.optional()}),u=am({method:nN(),params:l.loose().optional()}),d=am({_meta:s.optional()}),p=am({method:nN(),params:d.loose().optional()}),m=ah({_meta:s.optional()}),h=ag([nN(),n8().int()]),f=m.strict(),g=d.extend({requestId:h.optional(),reason:nN().optional()}),y=p.extend({method:a$("notifications/cancelled"),params:g}),v=am({src:nN(),mimeType:nN().optional(),sizes:ad(nN()).optional(),theme:ak(["light","dark"]).optional()}),_=am({icons:ad(v).optional()}),S=(b=am({name:nN(),title:nN().optional()})).extend({...b.shape,..._.shape,version:nN(),websiteUrl:nN().optional(),description:nN().optional()}),w=ab(am({applyDefaults:ai().optional()}),t),R=aJ(e=>e&&"object"==typeof e&&!Array.isArray(e)&&0===Object.keys(e).length?{form:{}}:e,ab(am({form:w.optional(),url:t.optional()}),t.optional())),k=ah({list:t.optional(),cancel:t.optional(),requests:ah({sampling:ah({createMessage:t.optional()}).optional(),elicitation:ah({create:t.optional()}).optional()}).optional()}),x=ah({list:t.optional(),cancel:t.optional(),requests:ah({tools:ah({call:t.optional()}).optional()}).optional()}),$=am({experimental:aw(nN(),t).optional(),sampling:am({context:t.optional(),tools:t.optional()}).optional(),elicitation:R.optional(),roots:am({listChanged:ai().optional()}).optional(),tasks:k.optional(),extensions:aw(nN(),t).optional()}),T=l.extend({protocolVersion:nN(),capabilities:$,clientInfo:S}),C=u.extend({method:a$("initialize"),params:T}),P=am({experimental:aw(nN(),t).optional(),logging:t.optional(),completions:t.optional(),prompts:am({listChanged:ai().optional()}).optional(),resources:am({subscribe:ai().optional(),listChanged:ai().optional()}).optional(),tools:am({listChanged:ai().optional()}).optional(),tasks:x.optional(),extensions:aw(nN(),t).optional()}),O=m.extend({protocolVersion:nN(),capabilities:P,serverInfo:S,instructions:nN().optional()}),E=p.extend({method:a$("notifications/initialized"),params:d.optional()}),I=u.extend({method:a$("ping"),params:l.optional()}),q=am({progress:n8(),total:aO(n8()),message:aO(nN())}),j=am({...d.shape,...q.shape,progressToken:i}),z=p.extend({method:a$("notifications/progress"),params:j}),A=l.extend({cursor:n.optional()}),N=u.extend({params:A.optional()}),M=m.extend({nextCursor:n.optional()}),Z=(L=am({uri:nN(),mimeType:aO(nN()),_meta:aw(nN(),al()).optional()})).extend({text:nN()}),U=nN().refine(e=>{try{return atob(e),!0}catch{return!1}},{message:"Invalid Base64 string"}),F=L.extend({blob:U}),H=am({audience:ad(D=ak(["user","assistant"])).optional(),priority:n8().min(0).max(1).optional(),lastModified:r7(nL,{offset:!0}).optional()}),J=am({...b.shape,..._.shape,uri:nN(),description:aO(nN()),mimeType:aO(nN()),size:aO(n8()),annotations:H.optional(),_meta:aO(ah({}))}),V=am({...b.shape,..._.shape,uriTemplate:nN(),description:aO(nN()),mimeType:aO(nN()),annotations:H.optional(),_meta:aO(ah({}))}),B=N.extend({method:a$("resources/list")}),W=M.extend({resources:ad(J)}),G=N.extend({method:a$("resources/templates/list")}),K=M.extend({resourceTemplates:ad(V)}),Y=l.extend({uri:nN()}),X=u.extend({method:a$("resources/read"),params:Y}),Q=m.extend({contents:ad(ag([Z,F]))}),ee=p.extend({method:a$("notifications/resources/list_changed"),params:d.optional()}),et=u.extend({method:a$("resources/subscribe"),params:Y}),er=u.extend({method:a$("resources/unsubscribe"),params:Y}),ei=d.extend({uri:nN()}),en=p.extend({method:a$("notifications/resources/updated"),params:ei}),ea=am({name:nN(),description:aO(nN()),required:aO(ai())}),eo=am({...b.shape,..._.shape,description:aO(nN()),arguments:aO(ad(ea)),_meta:aO(ah({}))}),es=N.extend({method:a$("prompts/list")}),el=M.extend({prompts:ad(eo)}),ec=l.extend({name:nN(),arguments:aw(nN(),nN()).optional()}),eu=u.extend({method:a$("prompts/get"),params:ec}),ed=am({type:a$("text"),text:nN(),annotations:H.optional(),_meta:aw(nN(),al()).optional()}),ep=am({type:a$("image"),data:U,mimeType:nN(),annotations:H.optional(),_meta:aw(nN(),al()).optional()}),em=am({type:a$("audio"),data:U,mimeType:nN(),annotations:H.optional(),_meta:aw(nN(),al()).optional()}),eh=am({type:a$("tool_use"),name:nN(),id:nN(),input:aw(nN(),al()),_meta:aw(nN(),al()).optional()}),ef=am({type:a$("resource"),resource:ag([Z,F]),annotations:H.optional(),_meta:aw(nN(),al()).optional()}),ev=am({role:D,content:ey=ag([ed,ep,em,eg=J.extend({type:a$("resource_link")}),ef])}),e_=m.extend({description:nN().optional(),messages:ad(ev)}),eb=p.extend({method:a$("notifications/prompts/list_changed"),params:d.optional()}),eS=am({title:nN().optional(),readOnlyHint:ai().optional(),destructiveHint:ai().optional(),idempotentHint:ai().optional(),openWorldHint:ai().optional()}),ew=am({taskSupport:ak(["required","optional","forbidden"]).optional()}),eR=am({...b.shape,..._.shape,description:nN().optional(),inputSchema:am({type:a$("object"),properties:aw(nN(),e).optional(),required:ad(nN()).optional()}).catchall(al()),outputSchema:am({type:a$("object"),properties:aw(nN(),e).optional(),required:ad(nN()).optional()}).catchall(al()).optional(),annotations:eS.optional(),execution:ew.optional(),_meta:aw(nN(),al()).optional()}),ek=N.extend({method:a$("tools/list")}),ex=M.extend({tools:ad(eR)}),e$=m.extend({content:ad(ey),structuredContent:aw(nN(),al()).optional(),isError:ai().optional()}),eT=c.extend({name:nN(),arguments:aw(nN(),al()).optional()}),eC=u.extend({method:a$("tools/call"),params:eT}),eP=p.extend({method:a$("notifications/tools/list_changed"),params:d.optional()}),eO=ak(["debug","info","notice","warning","error","critical","alert","emergency"]),eE=l.extend({level:eO}),eI=u.extend({method:a$("logging/setLevel"),params:eE}),eq=d.extend({level:eO,logger:nN().optional(),data:al()}),ej=p.extend({method:a$("notifications/message"),params:eq}),ez=am({name:nN().optional()}),eA=am({hints:ad(ez).optional(),costPriority:n8().min(0).max(1).optional(),speedPriority:n8().min(0).max(1).optional(),intelligencePriority:n8().min(0).max(1).optional()}),eN=am({mode:ak(["auto","required","none"]).optional()}),eM=am({type:a$("tool_result"),toolUseId:nN().describe("The unique identifier for the corresponding tool call."),content:ad(ey),structuredContent:am({}).loose().optional(),isError:ai().optional(),_meta:aw(nN(),al()).optional()}),eL=av("type",[ed,ep,em]),eU=am({role:D,content:ag([eZ=av("type",[ed,ep,em,eh,eM]),ad(eZ)]),_meta:aw(nN(),al()).optional()}),eF=c.extend({messages:ad(eU),modelPreferences:eA.optional(),systemPrompt:nN().optional(),includeContext:ak(["none","thisServer","allServers"]).optional(),temperature:n8().optional(),maxTokens:n8().int(),stopSequences:ad(nN()).optional(),metadata:t.optional(),tools:ad(eR).optional(),toolChoice:eN.optional()}),eD=u.extend({method:a$("sampling/createMessage"),params:eF}),eH=m.extend({model:nN(),stopReason:aO(ak(["endTurn","stopSequence","maxTokens"]).or(nN())),role:D,content:eL}),eJ=m.extend({model:nN(),stopReason:aO(ak(["endTurn","stopSequence","maxTokens","toolUse"]).or(nN())),role:D,content:ag([eZ,ad(eZ)])}),eV=am({type:a$("boolean"),title:nN().optional(),description:nN().optional(),default:ai().optional()}),eB=am({type:a$("string"),title:nN().optional(),description:nN().optional(),minLength:n8().optional(),maxLength:n8().optional(),format:ak(["email","uri","date","date-time"]).optional(),default:nN().optional()}),eW=am({type:ak(["number","integer"]),title:nN().optional(),description:nN().optional(),minimum:n8().optional(),maximum:n8().optional(),default:n8().optional()}),eG=am({type:a$("string"),title:nN().optional(),description:nN().optional(),enum:ad(nN()),default:nN().optional()}),eK=am({type:a$("string"),title:nN().optional(),description:nN().optional(),oneOf:ad(am({const:nN(),title:nN()})),default:nN().optional()}),eY=am({type:a$("string"),title:nN().optional(),description:nN().optional(),enum:ad(nN()),enumNames:ad(nN()).optional(),default:nN().optional()}),eX=ag([eG,eK]),eQ=am({type:a$("array"),title:nN().optional(),description:nN().optional(),minItems:n8().optional(),maxItems:n8().optional(),items:am({type:a$("string"),enum:ad(nN())}),default:ad(nN()).optional()}),e1=ag([eQ,e0=am({type:a$("array"),title:nN().optional(),description:nN().optional(),minItems:n8().optional(),maxItems:n8().optional(),items:am({anyOf:ad(am({const:nN(),title:nN()}))}),default:ad(nN()).optional()})]),e2=ag([eY,eX,e1]),e9=ag([e2,eV,eB,eW]),e4=c.extend({mode:a$("form").optional(),message:nN(),requestedSchema:am({type:a$("object"),properties:aw(nN(),e9),required:ad(nN()).optional()}).catchall(al())}),e6=ag([e4,e3=c.extend({mode:a$("url"),message:nN(),elicitationId:nN(),url:nN().url()})]),e5=u.extend({method:a$("elicitation/create"),params:e6}),e7=d.extend({elicitationId:nN()}),e8=p.extend({method:a$("notifications/elicitation/complete"),params:e7}),te=m.extend({action:ak(["accept","decline","cancel"]),content:aJ(e=>null===e?void 0:e,aw(nN(),ag([nN(),n8(),ai(),ad(nN())])).optional())}),tt=am({type:a$("ref/resource"),uri:nN()}),tr=am({type:a$("ref/prompt"),name:nN()}),ti=l.extend({ref:ag([tr,tt]),argument:am({name:nN(),value:nN()}),context:am({arguments:aw(nN(),nN()).optional()}).optional()}),tn=u.extend({method:a$("completion/complete"),params:ti}),ta=m.extend({completion:ah({values:ad(nN()).max(100),total:aO(n8().int()),hasMore:aO(ai())})}),to=am({uri:nN().startsWith("file://"),name:nN().optional(),_meta:aw(nN(),al()).optional()}),ts=u.extend({method:a$("roots/list"),params:l.optional()}),tl=m.extend({roots:ad(to)}),tc=p.extend({method:a$("notifications/roots/list_changed"),params:d.optional()}),tu=ah({ttl:n8().optional(),pollInterval:n8().optional()}),td=ak(["working","input_required","completed","failed","cancelled"]),tp=am({taskId:nN(),status:td,ttl:ag([n8(),aa()]),createdAt:nN(),lastUpdatedAt:nN(),pollInterval:aO(n8()),statusMessage:aO(nN())}),tm=m.extend({task:tp}),th=d.merge(tp),tf=p.extend({method:a$("notifications/tasks/status"),params:th}),tg=u.extend({method:a$("tasks/get"),params:l.extend({taskId:nN()})}),ty=m.merge(tp),tv=u.extend({method:a$("tasks/result"),params:l.extend({taskId:nN()})}),t_=m.loose(),tb=N.extend({method:a$("tasks/list")}),tS=M.extend({tasks:ad(tp)}),tw=u.extend({method:a$("tasks/cancel"),params:l.extend({taskId:nN()})}),{JSONValueSchema:e,JSONObjectSchema:t,ProgressTokenSchema:i,CursorSchema:n,TaskMetadataSchema:a,RelatedTaskMetadataSchema:o,RequestMetaSchema:s,BaseRequestParamsSchema:l,TaskAugmentedRequestParamsSchema:c,RequestSchema:u,NotificationsParamsSchema:d,NotificationSchema:p,ResultSchema:m,RequestIdSchema:h,EmptyResultSchema:f,CancelledNotificationParamsSchema:g,CancelledNotificationSchema:y,IconSchema:v,IconsSchema:_,BaseMetadataSchema:b,ImplementationSchema:S,ClientTasksCapabilitySchema:k,ServerTasksCapabilitySchema:x,ClientCapabilitiesSchema:$,InitializeRequestParamsSchema:T,InitializeRequestSchema:C,ServerCapabilitiesSchema:P,InitializeResultSchema:O,InitializedNotificationSchema:E,PingRequestSchema:I,ProgressSchema:q,ProgressNotificationParamsSchema:j,ProgressNotificationSchema:z,PaginatedRequestParamsSchema:A,PaginatedRequestSchema:N,PaginatedResultSchema:M,ResourceContentsSchema:L,TextResourceContentsSchema:Z,BlobResourceContentsSchema:F,RoleSchema:D,AnnotationsSchema:H,ResourceSchema:J,ResourceTemplateSchema:V,ListResourcesRequestSchema:B,ListResourcesResultSchema:W,ListResourceTemplatesRequestSchema:G,ListResourceTemplatesResultSchema:K,ResourceRequestParamsSchema:Y,ReadResourceRequestParamsSchema:Y,ReadResourceRequestSchema:X,ReadResourceResultSchema:Q,ResourceListChangedNotificationSchema:ee,SubscribeRequestParamsSchema:Y,SubscribeRequestSchema:et,UnsubscribeRequestParamsSchema:Y,UnsubscribeRequestSchema:er,ResourceUpdatedNotificationParamsSchema:ei,ResourceUpdatedNotificationSchema:en,PromptArgumentSchema:ea,PromptSchema:eo,ListPromptsRequestSchema:es,ListPromptsResultSchema:el,GetPromptRequestParamsSchema:ec,GetPromptRequestSchema:eu,TextContentSchema:ed,ImageContentSchema:ep,AudioContentSchema:em,ToolUseContentSchema:eh,EmbeddedResourceSchema:ef,ResourceLinkSchema:eg,ContentBlockSchema:ey,PromptMessageSchema:ev,GetPromptResultSchema:e_,PromptListChangedNotificationSchema:eb,ToolAnnotationsSchema:eS,ToolExecutionSchema:ew,ToolSchema:eR,ListToolsRequestSchema:ek,ListToolsResultSchema:ex,CallToolResultSchema:e$,CallToolRequestParamsSchema:eT,CallToolRequestSchema:eC,ToolListChangedNotificationSchema:eP,LoggingLevelSchema:eO,SetLevelRequestParamsSchema:eE,SetLevelRequestSchema:eI,LoggingMessageNotificationParamsSchema:eq,LoggingMessageNotificationSchema:ej,ModelHintSchema:ez,ModelPreferencesSchema:eA,ToolChoiceSchema:eN,ToolResultContentSchema:eM,SamplingContentSchema:eL,SamplingMessageContentBlockSchema:eZ,SamplingMessageSchema:eU,CreateMessageRequestParamsSchema:eF,CreateMessageRequestSchema:eD,CreateMessageResultSchema:eH,CreateMessageResultWithToolsSchema:eJ,BooleanSchemaSchema:eV,StringSchemaSchema:eB,NumberSchemaSchema:eW,UntitledSingleSelectEnumSchemaSchema:eG,TitledSingleSelectEnumSchemaSchema:eK,LegacyTitledEnumSchemaSchema:eY,SingleSelectEnumSchemaSchema:eX,UntitledMultiSelectEnumSchemaSchema:eQ,TitledMultiSelectEnumSchemaSchema:e0,MultiSelectEnumSchemaSchema:e1,EnumSchemaSchema:e2,PrimitiveSchemaDefinitionSchema:e9,ElicitRequestFormParamsSchema:e4,ElicitRequestURLParamsSchema:e3,ElicitRequestParamsSchema:e6,ElicitRequestSchema:e5,ElicitationCompleteNotificationParamsSchema:e7,ElicitationCompleteNotificationSchema:e8,ElicitResultSchema:te,ResourceTemplateReferenceSchema:tt,PromptReferenceSchema:tr,CompleteRequestParamsSchema:ti,CompleteRequestSchema:tn,CompleteResultSchema:ta,RootSchema:to,ListRootsRequestSchema:ts,ListRootsResultSchema:tl,RootsListChangedNotificationSchema:tc,TaskCreationParamsSchema:tu,TaskStatusSchema:td,TaskSchema:tp,CreateTaskResultSchema:tm,TaskStatusNotificationParamsSchema:th,TaskStatusNotificationSchema:tf,GetTaskRequestSchema:tg,GetTaskResultSchema:ty,GetTaskPayloadRequestSchema:tv,GetTaskPayloadResultSchema:t_,ListTasksRequestSchema:tb,ListTasksResultSchema:tS,CancelTaskRequestSchema:tw,CancelTaskResultSchema:m.merge(tp),ClientRequestSchema:ag([I,C,tn,eI,eu,es,B,G,X,et,er,eC,ek,tg,tv,tb,tw]),ClientNotificationSchema:ag([y,z,E,tc,tf]),ClientResultSchema:ag([f,eH,eJ,te,tl,ty,tS,tm]),ServerRequestSchema:ag([I,eD,e5,ts,tg,tv,tb,tw]),ServerNotificationSchema:ag([y,z,ej,en,ee,eP,eb,tf,e8]),ServerResultSchema:ag([f,O,ta,e_,el,W,K,Q,e$,ex,ty,tS,tm]),CallToolResultWireSchema:al().superRefine((e,t)=>{if(!("object"!=typeof e||null===e||Array.isArray(e))&&void 0===e.content){for(let r of l2)if(r in e)return void t.addIssue({code:"custom",message:`content is required when the body carries '${r}' — another result family cannot default into an empty tools/call success`})}}).transform(l9).pipe(e$)})}function l3(e){return"object"!==e.type}let l6=new Set(["const","enum","default","examples"]),l5=new Set(["properties","patternProperties","$defs","definitions","dependentSchemas","dependencies"]);function l7(e){return void 0!==e&&!("string"==typeof e&&e.startsWith("#"))}let l8={ping:null,initialize:null,"completion/complete":null,"logging/setLevel":null,"prompts/get":null,"prompts/list":null,"resources/list":null,"resources/templates/list":null,"resources/read":null,"resources/subscribe":null,"resources/unsubscribe":null,"tools/call":null,"tools/list":null,"tasks/get":null,"tasks/result":null,"tasks/list":null,"tasks/cancel":null,"sampling/createMessage":null,"elicitation/create":null,"roots/list":null},ce={"notifications/cancelled":null,"notifications/progress":null,"notifications/initialized":null,"notifications/roots/list_changed":null,"notifications/tasks/status":null,"notifications/message":null,"notifications/resources/updated":null,"notifications/resources/list_changed":null,"notifications/tools/list_changed":null,"notifications/prompts/list_changed":null,"notifications/elicitation/complete":null},ct={ping:null,initialize:null,"completion/complete":null,"logging/setLevel":null,"prompts/get":null,"prompts/list":null,"resources/list":null,"resources/templates/list":null,"resources/read":null,"resources/subscribe":null,"resources/unsubscribe":null,"tools/call":null,"tools/list":null,"sampling/createMessage":null,"elicitation/create":null,"roots/list":null};function cr(){if(i)return i;let e=l4();return i={requestSchemas:{ping:e.PingRequestSchema,initialize:e.InitializeRequestSchema,"completion/complete":e.CompleteRequestSchema,"logging/setLevel":e.SetLevelRequestSchema,"prompts/get":e.GetPromptRequestSchema,"prompts/list":e.ListPromptsRequestSchema,"resources/list":e.ListResourcesRequestSchema,"resources/templates/list":e.ListResourceTemplatesRequestSchema,"resources/read":e.ReadResourceRequestSchema,"resources/subscribe":e.SubscribeRequestSchema,"resources/unsubscribe":e.UnsubscribeRequestSchema,"tools/call":e.CallToolRequestSchema,"tools/list":e.ListToolsRequestSchema,"tasks/get":e.GetTaskRequestSchema,"tasks/result":e.GetTaskPayloadRequestSchema,"tasks/list":e.ListTasksRequestSchema,"tasks/cancel":e.CancelTaskRequestSchema,"sampling/createMessage":e.CreateMessageRequestSchema,"elicitation/create":e.ElicitRequestSchema,"roots/list":e.ListRootsRequestSchema},notificationSchemas:{"notifications/cancelled":e.CancelledNotificationSchema,"notifications/progress":e.ProgressNotificationSchema,"notifications/initialized":e.InitializedNotificationSchema,"notifications/roots/list_changed":e.RootsListChangedNotificationSchema,"notifications/tasks/status":e.TaskStatusNotificationSchema,"notifications/message":e.LoggingMessageNotificationSchema,"notifications/resources/updated":e.ResourceUpdatedNotificationSchema,"notifications/resources/list_changed":e.ResourceListChangedNotificationSchema,"notifications/tools/list_changed":e.ToolListChangedNotificationSchema,"notifications/prompts/list_changed":e.PromptListChangedNotificationSchema,"notifications/elicitation/complete":e.ElicitationCompleteNotificationSchema},resultSchemas:{ping:e.EmptyResultSchema,initialize:e.InitializeResultSchema,"completion/complete":e.CompleteResultSchema,"logging/setLevel":e.EmptyResultSchema,"prompts/get":e.GetPromptResultSchema,"prompts/list":e.ListPromptsResultSchema,"resources/list":e.ListResourcesResultSchema,"resources/templates/list":e.ListResourceTemplatesResultSchema,"resources/read":e.ReadResourceResultSchema,"resources/subscribe":e.EmptyResultSchema,"resources/unsubscribe":e.EmptyResultSchema,"tools/call":e.CallToolResultWireSchema,"tools/list":e.ListToolsResultSchema,"sampling/createMessage":e.CreateMessageResultWithToolsSchema,"elicitation/create":e.ElicitResultSchema,"roots/list":e.ListRootsResultSchema}}}function ci(e){return Object.prototype.hasOwnProperty.call(l8,e)}function cn(e){return Object.prototype.hasOwnProperty.call(ce,e)}function ca(e){return null!==e&&"object"==typeof e&&!Array.isArray(e)}function co(e,t){if(void 0===e)return{ok:!1,reason:"not-in-era"};let r=e.safeParse(t);return r.success?{ok:!0,value:r.data}:{ok:!1,reason:"invalid",message:String(r.error)}}Object.keys(l8),Object.keys(ce);let cs={ok:!1,reason:"not-in-era"};function cl(e){return ca(e)&&ca(e.outputSchema)&&l3(e.outputSchema)}let cc={era:"2025-11-25",hasRequestMethod:ci,hasNotificationMethod:cn,validateRequest:(e,t)=>co(ci(e)?cr().requestSchemas[e]:void 0,t),validateResult:(e,t)=>co(Object.prototype.hasOwnProperty.call(ct,e)?cr().resultSchemas[e]:void 0,t),validateNotification:(e,t)=>co(cn(e)?cr().notificationSchemas[e]:void 0,t),hasInputRequestMethod:()=>!1,validateInputRequest:()=>cs,validateInputResponse:()=>cs,samplingResultVariant:(e,t)=>{let r=l4();return co(e?r.CreateMessageResultWithToolsSchema:r.CreateMessageResultSchema,t)},outboundEnvelope:e=>void 0,validateEnvelopeMeta:e=>[],projectCallToolResult(e,t){let r=l1(e),i=r.structuredContent;if(void 0===i)return r;let n="object"!=typeof i||null===i||Array.isArray(i),a=void 0!==t&&l3(t);return n||a?{...r,structuredContent:{result:i}}:r},decodeResult(e,t){if(ca(t)&&"resultType"in t){let e={...t};return delete e.resultType,{kind:"complete",result:e}}return{kind:"complete",result:t}},encodeResult(e,t){if("tools/list"!==e)return t;let r=t.tools;return Array.isArray(r)&&r.some(e=>cl(e))?{...t,tools:r.map(e=>cl(e)?{...e,outputSchema:function(e){var t;let r="string"==typeof e.$schema?e.$schema:void 0;if(l7(e.$id))return{...void 0!==r&&{$schema:r},type:"object",properties:{result:e},required:["result"]};let i="string"==typeof(t=e.$schema)&&Y.has(t.replace(/#$/,""))&&!0!==e.$recursiveAnchor,n=(e,t)=>{if(Array.isArray(e))return e.map(e=>n(e,!1));if(null===e||"object"!=typeof e||!t&&l7(e.$id))return e;let r={},a=!1;for(let[o,s]of Object.entries(e))t?r[o]=n(s,!1):("$ref"===o||"$dynamicRef"===o)&&"string"==typeof s?r[o]="#"===s?"#/properties/result":s.startsWith("#/")?`#/properties/result${s.slice(1)}`:s:"$recursiveRef"===o&&"#"===s&&i?a=!0:l6.has(o)?r[o]=s:l5.has(o)?r[o]=n(s,!0):r[o]=n(s,!1);return a&&("$ref"in r?r.allOf=[...Array.isArray(r.allOf)?r.allOf:[],{$ref:"#/properties/result"}]:r.$ref="#/properties/result"),r};return{...void 0!==r&&{$schema:r},type:"object",properties:{result:n(e,!1)},required:["result"]}}(e.outputSchema)}:e)}:t},encodeErrorCode:e=>-32002===e?-32602:e,checkInboundEnvelope:e=>void 0};function cu(){return n??=function(){let e=aD(()=>ag([nN(),n8(),ai(),aa(),aw(nN(),e),ad(e)])),t=aw(nN(),e),r=ag([nN(),n8().int()]),i=nN(),n=ag([nN(),n8().int()]),a=ak(["user","assistant"]),o=ak(["debug","info","notice","warning","error","critical","alert","emergency"]),s=nN().refine(e=>{try{return atob(e),!0}catch{return!1}},{message:"Invalid Base64 string"}),l=am({ttl:n8().optional()}),c=am({taskId:nN()}),u=ah({progressToken:r.optional(),"io.modelcontextprotocol/related-task":c.optional()}),d=am({_meta:u.optional()}),p=d.extend({task:l.optional()}),m=am({_meta:u.optional()}),h=am({method:nN(),params:m.loose().optional()}),f=am({src:nN(),mimeType:nN().optional(),sizes:ad(nN()).optional(),theme:ak(["light","dark"]).optional()}),g=am({icons:ad(f).optional()}),y=am({name:nN(),title:nN().optional()}),v=y.extend({...y.shape,...g.shape,version:nN(),websiteUrl:nN().optional(),description:nN().optional()}),_=ab(am({applyDefaults:ai().optional()}),t),b=aJ(e=>e&&"object"==typeof e&&!Array.isArray(e)&&0===Object.keys(e).length?{form:{}}:e,ab(am({form:_.optional(),url:t.optional()}),t.optional())),S=ah({list:t.optional(),cancel:t.optional(),requests:ah({sampling:ah({createMessage:t.optional()}).optional(),elicitation:ah({create:t.optional()}).optional()}).optional()}),w=ah({list:t.optional(),cancel:t.optional(),requests:ah({tools:ah({call:t.optional()}).optional()}).optional()}),R=am({experimental:aw(nN(),t).optional(),sampling:am({context:t.optional(),tools:t.optional()}).optional(),elicitation:b.optional(),roots:am({listChanged:ai().optional()}).optional(),tasks:S.optional(),extensions:aw(nN(),t).optional()}),k=am({experimental:aw(nN(),t).optional(),logging:t.optional(),completions:t.optional(),prompts:am({listChanged:ai().optional()}).optional(),resources:am({subscribe:ai().optional(),listChanged:ai().optional()}).optional(),tools:am({listChanged:ai().optional()}).optional(),tasks:w.optional(),extensions:aw(nN(),t).optional()}),x=am({progress:n8(),total:aO(n8()),message:aO(nN())}),$=am({...m.shape,...x.shape,progressToken:r}),T=h.extend({method:a$("notifications/progress"),params:$}),C=m.extend({level:o,logger:nN().optional(),data:al()}),P=h.extend({method:a$("notifications/message"),params:C}),O=am({uri:nN(),mimeType:aO(nN()),_meta:aw(nN(),al()).optional()}),E=O.extend({text:nN()}),I=O.extend({blob:s}),q=am({audience:ad(a).optional(),priority:n8().min(0).max(1).optional(),lastModified:r7(nL,{offset:!0}).optional()}),j=am({...y.shape,...g.shape,uri:nN(),description:aO(nN()),mimeType:aO(nN()),size:aO(n8()),annotations:q.optional(),_meta:aO(ah({}))}),z=am({...y.shape,...g.shape,uriTemplate:nN(),description:aO(nN()),mimeType:aO(nN()),annotations:q.optional(),_meta:aO(ah({}))}),A=h.extend({method:a$("notifications/resources/list_changed"),params:m.optional()}),N=m.extend({uri:nN()}),M=h.extend({method:a$("notifications/resources/updated"),params:N}),L=am({name:nN(),description:aO(nN()),required:aO(ai())}),Z=am({...y.shape,...g.shape,description:aO(nN()),arguments:aO(ad(L)),_meta:aO(ah({}))}),U=h.extend({method:a$("notifications/prompts/list_changed"),params:m.optional()}),F=am({type:a$("text"),text:nN(),annotations:q.optional(),_meta:aw(nN(),al()).optional()}),D=am({type:a$("image"),data:s,mimeType:nN(),annotations:q.optional(),_meta:aw(nN(),al()).optional()}),H=am({type:a$("audio"),data:s,mimeType:nN(),annotations:q.optional(),_meta:aw(nN(),al()).optional()}),J=am({type:a$("tool_use"),name:nN(),id:nN(),input:aw(nN(),al()),_meta:aw(nN(),al()).optional()}),V=am({type:a$("resource"),resource:ag([E,I]),annotations:q.optional(),_meta:aw(nN(),al()).optional()}),B=j.extend({type:a$("resource_link")}),W=ag([F,D,H,B,V]),G=am({role:a,content:W}),K=am({title:nN().optional(),readOnlyHint:ai().optional(),destructiveHint:ai().optional(),idempotentHint:ai().optional(),openWorldHint:ai().optional()}),Y=h.extend({method:a$("notifications/tools/list_changed"),params:m.optional()}),X=am({name:nN().optional()}),Q=am({hints:ad(X).optional(),costPriority:n8().min(0).max(1).optional(),speedPriority:n8().min(0).max(1).optional(),intelligencePriority:n8().min(0).max(1).optional()}),ee=am({mode:ak(["auto","required","none"]).optional()}),et=am({type:a$("boolean"),title:nN().optional(),description:nN().optional(),default:ai().optional()}),er=am({type:a$("string"),title:nN().optional(),description:nN().optional(),minLength:n8().optional(),maxLength:n8().optional(),format:ak(["email","uri","date","date-time"]).optional(),default:nN().optional()}),ei=am({type:ak(["number","integer"]),title:nN().optional(),description:nN().optional(),minimum:n8().optional(),maximum:n8().optional(),default:n8().optional()}),en=am({type:a$("string"),title:nN().optional(),description:nN().optional(),enum:ad(nN()),default:nN().optional()}),ea=am({type:a$("string"),title:nN().optional(),description:nN().optional(),oneOf:ad(am({const:nN(),title:nN()})),default:nN().optional()}),eo=am({type:a$("string"),title:nN().optional(),description:nN().optional(),enum:ad(nN()),enumNames:ad(nN()).optional(),default:nN().optional()}),es=ag([en,ea]),el=am({type:a$("array"),title:nN().optional(),description:nN().optional(),minItems:n8().optional(),maxItems:n8().optional(),items:am({type:a$("string"),enum:ad(nN())}),default:ad(nN()).optional()}),ec=am({type:a$("array"),title:nN().optional(),description:nN().optional(),minItems:n8().optional(),maxItems:n8().optional(),items:am({anyOf:ad(am({const:nN(),title:nN()}))}),default:ad(nN()).optional()}),eu=ag([el,ec]),ed=ag([eo,es,eu]),ep=ag([ed,et,er,ei]),em=p.extend({mode:a$("form").optional(),message:nN(),requestedSchema:am({type:a$("object"),properties:aw(nN(),ep),required:ad(nN()).optional()}).catchall(al())}),eh=am({type:a$("ref/resource"),uri:nN()}),ef=am({type:a$("ref/prompt"),name:nN()}),eg=am({uri:nN().startsWith("file://"),name:nN().optional(),_meta:aw(nN(),al()).optional()}),ey=R.shape,ev=am({experimental:ey.experimental,sampling:ey.sampling,elicitation:ey.elicitation,roots:ey.roots,extensions:ey.extensions}),e_=k.shape,eb=am({experimental:e_.experimental,logging:e_.logging,completions:e_.completions,prompts:e_.prompts,resources:e_.resources,tools:e_.tools,extensions:e_.extensions}),eS=ah({progressToken:r.optional(),[aW]:nN(),[aG]:v.optional(),[aY]:ev,[aQ]:o.optional()}),ew=am({...y.shape,...g.shape,description:nN().optional(),inputSchema:ah({$schema:nN().optional(),type:a$("object")}),outputSchema:ah({$schema:nN().optional()}).optional(),annotations:K.optional(),_meta:aw(nN(),al()).optional()}),eR=am({type:a$("tool_result"),toolUseId:nN(),content:ad(W),structuredContent:al().optional(),isError:ai().optional(),_meta:aw(nN(),al()).optional()}),ek=ag([F,D,H,J,eR]),ex=am({role:a,content:ag([ek,ad(ek)]),_meta:aw(nN(),al()).optional()}),e$=nN(),eT=ah({[aK]:v.optional().catch(void 0)}),eC=eT.optional();function eP(e){return ah({_meta:eC,resultType:e$.default("complete"),...e})}let eO=eP({}),eE=eP({nextCursor:i.optional()}),eI=eP({content:ad(W),structuredContent:al().optional(),isError:ai().optional()}),eq=eP({ttlMs:n8().int().min(0),cacheScope:ak(["public","private"]),tools:ad(ew),nextCursor:i.optional()}),ej=eP({ttlMs:n8().int().min(0),cacheScope:ak(["public","private"]),prompts:ad(Z),nextCursor:i.optional()}),ez=eP({description:nN().optional(),messages:ad(G)}),eA=eP({ttlMs:n8().int().min(0),cacheScope:ak(["public","private"]),resources:ad(j),nextCursor:i.optional()}),eN=eP({ttlMs:n8().int().min(0),cacheScope:ak(["public","private"]),resourceTemplates:ad(z),nextCursor:i.optional()}),eM=eP({ttlMs:n8().int().min(0),cacheScope:ak(["public","private"]),contents:ad(ag([E,I]))}),eL=eP({completion:am({values:ad(nN()).max(100),total:n8().int().optional(),hasMore:ai().optional()}).loose()}),eZ=eP({ttlMs:n8().int().min(0),cacheScope:ak(["public","private"])}),eU=eP({ttlMs:n8().int().min(0).catch(0),cacheScope:ak(["public","private"]).catch("private"),supportedVersions:ad(nN()),capabilities:eb,instructions:nN().optional()}),eF=am({messages:ad(ex),modelPreferences:Q.optional(),systemPrompt:nN().optional(),includeContext:ak(["none","thisServer","allServers"]).optional(),temperature:n8().optional(),maxTokens:n8().int(),stopSequences:ad(nN()).optional(),metadata:t.optional(),tools:ad(ew).optional(),toolChoice:ee.optional()}),eD=am({method:a$("sampling/createMessage"),params:eF}),eH=am({method:a$("roots/list"),params:am({_meta:aw(nN(),al()).optional()}).optional()}),eJ=am({...ex.shape,model:nN(),stopReason:nN().optional()}),eV=am({roots:ad(eg)}),eB=am({action:ak(["accept","decline","cancel"]),content:aw(nN(),ag([nN(),n8(),ai(),ad(nN())])).optional()}),eW=am({mode:a$("url"),message:nN(),url:nN().url()}),eG=ag([em,eW]),eK=am({method:a$("elicitation/create"),params:eG}),eY=ag([eD,eH,eK]),eX=ag([eJ,eV,eB]),eQ=aw(nN(),eY),e0=aw(nN(),eX),e1=eP({inputRequests:eQ.optional(),requestState:nN().optional()}),e2={inputResponses:e0.optional(),requestState:nN().optional()},e9=am({_meta:eS,...e2}),e4=ah({progressToken:r.optional()});function e3(e,t){return am({method:a$(e),params:am({_meta:eS,...t})})}function e6(e,t){return am({method:a$(e),params:am({_meta:e4.optional(),...t}).optional()})}let e5={name:nN(),arguments:aw(nN(),al()).optional(),...e2},e7={cursor:i.optional()},e8=e3("tools/call",e5),te=e3("tools/list",e7),tt=e3("prompts/list",e7),tr=e3("prompts/get",{name:nN(),arguments:aw(nN(),nN()).optional(),...e2}),ti=e3("resources/list",e7),tn=e3("resources/templates/list",e7),ta=e3("resources/read",{uri:nN(),...e2}),to={ref:ag([ef,eh]),argument:am({name:nN(),value:nN()}),context:am({arguments:aw(nN(),nN()).optional()}).optional()},ts=e3("completion/complete",to),tl=e3("server/discover",{}),tc=am({toolsListChanged:ai().optional(),promptsListChanged:ai().optional(),resourcesListChanged:ai().optional(),resourceSubscriptions:ad(nN()).optional()}),tu={notifications:tc},td=e3("subscriptions/listen",tu),tp=eT.extend({"io.modelcontextprotocol/subscriptionId":n}),tm=ah({_meta:tp,resultType:e$.default("complete")}),th={"tools/call":e6("tools/call",e5),"tools/list":e6("tools/list",e7),"prompts/get":e6("prompts/get",{name:nN(),arguments:aw(nN(),nN()).optional()}),"prompts/list":e6("prompts/list",e7),"resources/list":e6("resources/list",e7),"resources/templates/list":e6("resources/templates/list",e7),"resources/read":e6("resources/read",{uri:nN()}),"completion/complete":e6("completion/complete",to),"server/discover":e6("server/discover",{}),"subscriptions/listen":e6("subscriptions/listen",tu)};function tf(e){return ah({_meta:eC,...e})}let tg={"tools/call":tf({content:ad(W),structuredContent:al().optional(),isError:ai().optional()}),"tools/list":tf({ttlMs:n8().int().min(0),cacheScope:ak(["public","private"]),tools:ad(ew),nextCursor:i.optional()}),"prompts/get":tf({description:nN().optional(),messages:ad(G)}),"prompts/list":tf({ttlMs:n8().int().min(0),cacheScope:ak(["public","private"]),prompts:ad(Z),nextCursor:i.optional()}),"resources/list":tf({ttlMs:n8().int().min(0),cacheScope:ak(["public","private"]),resources:ad(j),nextCursor:i.optional()}),"resources/templates/list":tf({ttlMs:n8().int().min(0),cacheScope:ak(["public","private"]),resourceTemplates:ad(z),nextCursor:i.optional()}),"resources/read":tf({ttlMs:n8().int().min(0),cacheScope:ak(["public","private"]),contents:ad(ag([E,I]))}),"completion/complete":tf({completion:am({values:ad(nN()).max(100),total:n8().int().optional(),hasMore:ai().optional()}).loose()}),"server/discover":tf({ttlMs:n8().int().min(0).catch(0),cacheScope:ak(["public","private"]).catch("private"),supportedVersions:ad(nN()),capabilities:eb,instructions:nN().optional()}),"subscriptions/listen":tf({})},ty=ah({"io.modelcontextprotocol/subscriptionId":n.optional()}),tv=am({method:a$("notifications/subscriptions/acknowledged"),params:am({_meta:ty.optional(),notifications:tc})}),t_=am({_meta:ty.optional(),requestId:n,reason:nN().optional()}),tb=am({method:a$("notifications/cancelled"),params:t_}),tS=e=>am({jsonrpc:a$("2.0"),id:ag([nN(),n8().int()]),result:e}).strict();return{JSONValueSchema:e,JSONObjectSchema:t,ProgressTokenSchema:r,CursorSchema:i,RequestIdSchema:n,RoleSchema:a,LoggingLevelSchema:o,TaskMetadataSchema:l,RelatedTaskMetadataSchema:c,RequestMetaSchema:u,BaseRequestParamsSchema:d,TaskAugmentedRequestParamsSchema:p,NotificationsParamsSchema:m,NotificationSchema:h,IconSchema:f,IconsSchema:g,BaseMetadataSchema:y,ImplementationSchema:v,ClientTasksCapabilitySchema:S,ServerTasksCapabilitySchema:w,ClientCapabilitiesSchema:R,ServerCapabilitiesSchema:k,ProgressSchema:x,ProgressNotificationParamsSchema:$,ProgressNotificationSchema:T,LoggingMessageNotificationParamsSchema:C,LoggingMessageNotificationSchema:P,ResourceContentsSchema:O,TextResourceContentsSchema:E,BlobResourceContentsSchema:I,AnnotationsSchema:q,ResourceSchema:j,ResourceTemplateSchema:z,ResourceListChangedNotificationSchema:A,ResourceUpdatedNotificationParamsSchema:N,ResourceUpdatedNotificationSchema:M,PromptArgumentSchema:L,PromptSchema:Z,PromptListChangedNotificationSchema:U,TextContentSchema:F,ImageContentSchema:D,AudioContentSchema:H,ToolUseContentSchema:J,EmbeddedResourceSchema:V,ResourceLinkSchema:B,ContentBlockSchema:W,PromptMessageSchema:G,ToolAnnotationsSchema:K,ToolListChangedNotificationSchema:Y,ModelHintSchema:X,ModelPreferencesSchema:Q,ToolChoiceSchema:ee,BooleanSchemaSchema:et,StringSchemaSchema:er,NumberSchemaSchema:ei,UntitledSingleSelectEnumSchemaSchema:en,TitledSingleSelectEnumSchemaSchema:ea,LegacyTitledEnumSchemaSchema:eo,SingleSelectEnumSchemaSchema:es,UntitledMultiSelectEnumSchemaSchema:el,TitledMultiSelectEnumSchemaSchema:ec,MultiSelectEnumSchemaSchema:eu,EnumSchemaSchema:ed,PrimitiveSchemaDefinitionSchema:ep,ElicitRequestFormParamsSchema:em,ResourceTemplateReferenceSchema:eh,PromptReferenceSchema:ef,RootSchema:eg,ClientCapabilities2026Schema:ev,ServerCapabilities2026Schema:eb,RequestMetaEnvelopeSchema:eS,ToolSchema:ew,ToolResultContentSchema:eR,SamplingMessageContentBlockSchema:ek,SamplingMessageSchema:ex,ResultTypeSchema:e$,ResultMetaSchema:eT,ResultSchema:eO,PaginatedResultSchema:eE,CallToolResultSchema:eI,ListToolsResultSchema:eq,ListPromptsResultSchema:ej,GetPromptResultSchema:ez,ListResourcesResultSchema:eA,ListResourceTemplatesResultSchema:eN,ReadResourceResultSchema:eM,CompleteResultSchema:eL,CacheableResultSchema:eZ,DiscoverResultSchema:eU,CreateMessageRequestParamsSchema:eF,CreateMessageRequestSchema:eD,ListRootsRequestSchema:eH,CreateMessageResultSchema:eJ,ListRootsResultSchema:eV,ElicitResultSchema:eB,ElicitRequestURLParamsSchema:eW,ElicitRequestParamsSchema:eG,ElicitRequestSchema:eK,InputRequestSchema:eY,InputResponseSchema:eX,InputRequestsSchema:eQ,InputResponsesSchema:e0,InputRequiredResultSchema:e1,InputResponseRequestParamsSchema:e9,CallToolRequestSchema:e8,ListToolsRequestSchema:te,ListPromptsRequestSchema:tt,GetPromptRequestSchema:tr,ListResourcesRequestSchema:ti,ListResourceTemplatesRequestSchema:tn,ReadResourceRequestSchema:ta,CompleteRequestSchema:ts,DiscoverRequestSchema:tl,SubscriptionFilterSchema:tc,SubscriptionsListenRequestSchema:td,SubscriptionsListenResultMetaSchema:tp,SubscriptionsListenResultSchema:tm,dispatchRequestSchemas:th,dispatchResultSchemas:tg,NotificationMetaSchema:ty,SubscriptionsAcknowledgedNotificationSchema:tv,CancelledNotificationParamsSchema:t_,CancelledNotificationSchema:tb,notificationSchemas2026:{"notifications/cancelled":tb,"notifications/progress":T,"notifications/message":P,"notifications/resources/updated":M,"notifications/resources/list_changed":A,"notifications/tools/list_changed":Y,"notifications/prompts/list_changed":U,"notifications/subscriptions/acknowledged":tv},JSONRPCResultResponseSchema:tS(eO),CallToolResultResponseSchema:tS(ag([eI,e1])),ListToolsResultResponseSchema:tS(eq),ListPromptsResultResponseSchema:tS(ej),GetPromptResultResponseSchema:tS(ag([ez,e1])),ListResourcesResultResponseSchema:tS(eA),ListResourceTemplatesResultResponseSchema:tS(eN),ReadResourceResultResponseSchema:tS(ag([eM,e1])),CompleteResultResponseSchema:tS(eL),DiscoverResultResponseSchema:tS(eU),SubscriptionsListenResultResponseSchema:tS(tm)}}()}let cd=["tools/list","prompts/list","resources/list","resources/templates/list","resources/read","server/discover"],cp=Symbol("modelcontextprotocol.resultCacheHintFallback");function cm(e,t){if(void 0===t)return e;let r=e[cp];if(void 0===r)return{...e,[cp]:t};let i={},n=r.ttlMs??t.ttlMs;void 0!==n&&(i.ttlMs=n);let a=r.cacheScope??t.cacheScope;return void 0!==a&&(i.cacheScope=a),{...e,[cp]:i}}function ch(e){return"number"==typeof e&&Number.isSafeInteger(e)&&e>=0}function cf(e){return"public"===e||"private"===e}function cg(e,t){if(void 0!==e.ttlMs&&!ch(e.ttlMs))throw RangeError(`Invalid cache hint for ${t}: ttlMs must be a non-negative safe integer (got ${String(e.ttlMs)})`);if(void 0!==e.cacheScope&&!cf(e.cacheScope))throw RangeError(`Invalid cache hint for ${t}: cacheScope must be 'public' or 'private' (got ${String(e.cacheScope)})`)}let cy=((C={})[C.ParseError=-32700]="ParseError",C[C.InvalidRequest=-32600]="InvalidRequest",C[C.MethodNotFound=-32601]="MethodNotFound",C[C.InvalidParams=-32602]="InvalidParams",C[C.InternalError=-32603]="InternalError",C[C.ResourceNotFound=-32002]="ResourceNotFound",C[C.MissingRequiredClientCapability=-32021]="MissingRequiredClientCapability",C[C.UnsupportedProtocolVersion=-32022]="UnsupportedProtocolVersion",C[C.UrlElicitationRequired=-32042]="UrlElicitationRequired",C);var cv=class e extends Error{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.ProtocolError"})}static[Symbol.hasInstance](e){return lH(this,e)}static isInstance(e){if("function"!=typeof this)throw TypeError("isInstance must be called on the class (e.g. `SdkError.isInstance(value)`); for callbacks use `v => SdkError.isInstance(v)`");return lH(this,e)}constructor(e,t,r){super(t),this.code=e,this.data=r,this.name="ProtocolError",lD(this,new.target)}static fromError(t,r,i){return t===cy.UrlElicitationRequired&&i&&i.elicitations?new cb(i.elicitations,r):t===cy.UnsupportedProtocolVersion&&i&&Array.isArray(i.supported)&&"string"==typeof i.requested?new cS({supported:i.supported,requested:i.requested},r):(t===cy.InvalidParams||t===cy.ResourceNotFound)&&"string"==typeof i?.uri&&(t===cy.ResourceNotFound||1===Object.keys(i).length)?new c_(i.uri,r):t===cy.MissingRequiredClientCapability&&i&&null!==i.requiredCapabilities&&"object"==typeof i.requiredCapabilities&&!Array.isArray(i.requiredCapabilities)?new cw({requiredCapabilities:i.requiredCapabilities},r):new e(t,r,i)}},c_=class extends cv{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.ResourceNotFoundError"})}constructor(e,t=`Resource not found: ${e}`){super(cy.InvalidParams,t,{uri:e})}get uri(){return this.data.uri}},cb=class extends cv{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.UrlElicitationRequiredError"})}constructor(e,t=`URL elicitation${e.length>1?"s":""} required`){super(cy.UrlElicitationRequired,t,{elicitations:e})}get elicitations(){return this.data?.elicitations??[]}},cS=class extends cv{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.UnsupportedProtocolVersionError"})}constructor(e,t=`Unsupported protocol version: ${e.requested}`){super(cy.UnsupportedProtocolVersion,t,e)}get supported(){return this.data.supported}get requested(){return this.data.requested}},cw=class extends cv{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.MissingRequiredClientCapabilityError"})}constructor(e,t=`Missing required client capabilities: ${Object.keys(e.requiredCapabilities).join(", ")}`){super(cy.MissingRequiredClientCapability,t,e)}get requiredCapabilities(){return this.data.requiredCapabilities}};let cR=["tools/call","prompts/get","resources/read"],ck=["elicitation/create","sampling/createMessage","roots/list"];function cx(){if(a)return a;let e=cu();return a={request:{"elicitation/create":am({method:a$("elicitation/create"),params:e.ElicitRequestParamsSchema}),"sampling/createMessage":am({method:a$("sampling/createMessage"),params:e.CreateMessageRequestParamsSchema}),"roots/list":am({method:a$("roots/list"),params:ah({}).optional()})},response:{"elicitation/create":e.ElicitResultSchema,"sampling/createMessage":e.CreateMessageResultSchema,"roots/list":e.ListRootsResultSchema}}}function c$(e){return ck.includes(e)}function cT(e){return c$(e)?cx().request[e]:void 0}let cC={"tools/call":null,"tools/list":null,"prompts/get":null,"prompts/list":null,"resources/list":null,"resources/templates/list":null,"resources/read":null,"completion/complete":null,"server/discover":null,"subscriptions/listen":null},cP={"notifications/cancelled":null,"notifications/progress":null,"notifications/message":null,"notifications/resources/updated":null,"notifications/resources/list_changed":null,"notifications/tools/list_changed":null,"notifications/prompts/list_changed":null,"notifications/subscriptions/acknowledged":null};function cO(e){return Object.prototype.hasOwnProperty.call(cC,e)}function cE(e){return Object.prototype.hasOwnProperty.call(cP,e)}function cI(e){return null!==e&&"object"==typeof e&&!Array.isArray(e)}function cq(e,t){if(void 0===e)return{ok:!1,reason:"not-in-era"};let r=e.safeParse(t);return r.success?{ok:!0,value:r.data}:{ok:!1,reason:"invalid",message:String(r.error)}}Object.keys(cC),Object.keys(cP);let cj={ok:!1,reason:"not-in-era"},cz=[aW,aY],cA={era:"2026-07-28",hasRequestMethod:cO,hasNotificationMethod:cE,hasInputRequestMethod:e=>void 0!==cT(e),validateRequest:(e,t)=>cq(cO(e)?cu().dispatchRequestSchemas[e]:void 0,t),validateResult:(e,t)=>cq(Object.prototype.hasOwnProperty.call(cC,e)?cu().dispatchResultSchemas[e]:void 0,t),validateNotification:(e,t)=>cq(cE(e)?cu().notificationSchemas2026[e]:void 0,t),validateInputRequest:(e,t)=>cq(cT(e),t),validateInputResponse:(e,t)=>cq(c$(e)?cx().response[e]:void 0,t),samplingResultVariant:()=>cj,outboundEnvelope:e=>({[aW]:e.protocolVersion,[aG]:e.clientInfo,[aY]:e.clientCapabilities,...void 0!==e.logLevel&&{[aQ]:e.logLevel}}),validateEnvelopeMeta(e){let t=[];for(let r of cz)r in e||t.push({key:r,problem:"missing"});let r=cu().RequestMetaEnvelopeSchema.safeParse(e);if(!r.success)for(let e of r.error.issues){let r=e.path.map(String),i=r.length>0?r.join("."):"_meta";1===r.length&&t.some(e=>e.key===i&&"missing"===e.problem)||t.push({key:i,problem:e.message})}return t},projectCallToolResult:e=>l1(e),inputRequestSchema:cT,decodeResult(e,t){if(!cI(t))return{kind:"invalid",error:new lW(lB.InvalidResult,`Invalid result for ${e}: not an object`,{method:e})};let r=t.resultType;if(void 0===r)return{kind:"invalid",error:new lW(lB.InvalidResult,`Invalid result for ${e}: missing required resultType — servers implementing protocol revision 2026-07-28 MUST include it (the absent-means-complete bridge applies only to earlier-revision servers)`,{method:e,violation:"missing-resultType"})};if("string"!=typeof r)return{kind:"invalid",error:new lW(lB.InvalidResult,`Invalid result for ${e}: non-string resultType`,{method:e,resultType:r})};if("input_required"===r){let r=t.inputRequests,i=cI(r)?r:{},n=t.requestState,a=void 0===t._meta?void 0:cu().ResultMetaSchema.safeParse(t._meta),o=a?.success?a.data:void 0;return 0===Object.keys(i).length&&"string"!=typeof n?{kind:"invalid",error:new lW(lB.InvalidResult,`Invalid result for ${e}: input_required carries neither inputRequests nor requestState (every input_required result must include at least one of the two)`,{method:e,violation:"input-required-missing-both"})}:{kind:"input_required",inputRequests:i,..."string"==typeof n&&{requestState:n},...void 0!==o&&{_meta:o}}}if("complete"!==r)return{kind:"invalid",error:new lW(lB.UnsupportedResultType,`Unsupported result type '${r}' for ${e}`,{resultType:r,method:e})};let i=cN(),n=Object.hasOwn(i,e)?i[e]:void 0;if(void 0!==n){let r=n.safeParse(t);if(!r.success)return{kind:"invalid",error:new lW(lB.InvalidResult,`Invalid result for ${e}: ${r.error}`,{method:e})}}let a={...t};return delete a.resultType,{kind:"complete",result:a}},encodeResult:(e,t,r)=>(function(e,t){if(void 0===t)return e;let r=e._meta;return void 0===r?{...e,_meta:{[aK]:t}}:null===r||"object"!=typeof r||Array.isArray(r)||void 0!==r[aK]?e:{...e,_meta:{...r,[aK]:t}}})(function(e,t){var r,i;let n=t[cp];if("complete"!==t.resultType||!cd.includes(e)){let e;return void 0===n?t:(e={...t},delete e[cp],e)}let a=ch(t.ttlMs)?t.ttlMs:void 0!==(r=n)&&ch(r.ttlMs)?r.ttlMs:0,o=cf(t.cacheScope)?t.cacheScope:void 0!==(i=n)&&cf(i.cacheScope)?i.cacheScope:"private",s={...t,ttlMs:a,cacheScope:o};return delete s[cp],s}(e,function(e,t){let r=t.resultType;if(void 0===r)return{...t,resultType:"complete"};if("complete"===r||cR.includes(e))return t;throw new cv(cy.InternalError,`Handler for ${e} returned resultType '${String(r)}', but results of ${e} only support 'complete' on protocol revision 2026-07-28`)}(e,function(e,t){let r=t,i=!1,n=()=>(i||(r={...r},i=!0),r),a=t.tools;"tools/list"===e&&Array.isArray(a)&&a.some(e=>cI(e)&&"execution"in e)&&(n().tools=a.map(e=>{if(!cI(e)||!("execution"in e))return e;let t={...e};return delete t.execution,t}));let o=t.capabilities;if(cI(o)&&"tasks"in o){let e={...o};delete e.tasks,n().capabilities=e}return r}(e,t))),r),encodeErrorCode:e=>-32002===e?-32602:e,checkInboundEnvelope(e){if(void 0===e.envelope)return"Request is missing the required _meta envelope for protocol revision 2026-07-28 (io.modelcontextprotocol/protocolVersion, io.modelcontextprotocol/clientCapabilities)";let t=cu().RequestMetaEnvelopeSchema.safeParse(e.envelope);if(!t.success)return`Invalid _meta envelope for protocol revision 2026-07-28: ${t.error.issues.map(e=>e.message).join("; ")}`}};function cN(){if(o)return o;let e=cu();return o={"tools/call":e.CallToolResultSchema,"tools/list":e.ListToolsResultSchema,"prompts/get":e.GetPromptResultSchema,"prompts/list":e.ListPromptsResultSchema,"resources/list":e.ListResourcesResultSchema,"resources/templates/list":e.ListResourceTemplatesResultSchema,"resources/read":e.ReadResourceResultSchema,"completion/complete":e.CompleteResultSchema,"server/discover":e.DiscoverResultSchema}}let cM="2026-07-28";function cL(e){return void 0!==e&&e>=lX?cA:cc}function cZ(e){return void 0!==e.revision?cL(e.revision).era:"modern"===e.era?cA.era:cc.era}function cU(e){return cH.some(t=>t.hasRequestMethod(e))}function cF(e){return cH.some(t=>t.hasNotificationMethod(e))}function cD(e){return"tasks/get"===e||"tasks/cancel"===e}let cH=[cc,cA];function cJ(e){return null!==e&&"object"==typeof e&&!Array.isArray(e)}function cV(e){if(!cJ(e))return;let t=e._meta;return cJ(t)?t:void 0}function cB(e){let t=cV(e);return void 0!==t&&aW in t}function cW(e){let t=cV(e)?.[aW];return"string"==typeof t?t:void 0}function cG(e){return cL(cM).validateEnvelopeMeta(e)}var cK=(e=>{let t={};for(var r in e)J(t,r,{get:e[r],enumerable:!0});return t})({AnnotationsSchema:()=>oD,AudioContentSchema:()=>sc,BaseMetadataSchema:()=>oy,BaseRequestParamsSchema:()=>a7,BlobResourceContentsSchema:()=>oU,BooleanSchemaSchema:()=>sH,CallToolRequestParamsSchema:()=>sk,CallToolRequestSchema:()=>sx,CallToolResultSchema:()=>sw,CancelTaskRequestSchema:()=>lb,CancelTaskResultSchema:()=>lS,CancelledNotificationParamsSchema:()=>om,CancelledNotificationSchema:()=>oh,ClientCapabilitiesSchema:()=>oR,ClientNotificationSchema:()=>lR,ClientRequestSchema:()=>lw,ClientResultSchema:()=>lk,ClientTasksCapabilitySchema:()=>oS,CompatibilityCallToolResultSchema:()=>sR,CompleteRequestParamsSchema:()=>lt,CompleteRequestSchema:()=>lr,CompleteResultSchema:()=>li,ContentBlockSchema:()=>sm,CreateMessageRequestParamsSchema:()=>sZ,CreateMessageRequestSchema:()=>sU,CreateMessageResultSchema:()=>sF,CreateMessageResultWithToolsSchema:()=>sD,CreateTaskResultSchema:()=>ld,CursorSchema:()=>a4,DiscoverRequestSchema:()=>oP,DiscoverResultSchema:()=>oO,ElicitRequestFormParamsSchema:()=>s2,ElicitRequestParamsSchema:()=>s4,ElicitRequestSchema:()=>s3,ElicitRequestURLParamsSchema:()=>s9,ElicitResultSchema:()=>s7,ElicitationCompleteNotificationParamsSchema:()=>s6,ElicitationCompleteNotificationSchema:()=>s5,EmbeddedResourceSchema:()=>sd,EmptyResultSchema:()=>op,EnumSchemaSchema:()=>s0,GetPromptRequestParamsSchema:()=>sa,GetPromptRequestSchema:()=>so,GetPromptResultSchema:()=>sf,GetTaskPayloadRequestSchema:()=>lg,GetTaskPayloadResultSchema:()=>ly,GetTaskRequestSchema:()=>lh,GetTaskResultSchema:()=>lf,IconSchema:()=>of,IconsSchema:()=>og,ImageContentSchema:()=>sl,ImplementationSchema:()=>ov,InitializeRequestParamsSchema:()=>ok,InitializeRequestSchema:()=>ox,InitializeResultSchema:()=>oT,InitializedNotificationSchema:()=>oC,JSONArraySchema:()=>a2,JSONObjectSchema:()=>a1,JSONRPCErrorResponseSchema:()=>oc,JSONRPCMessageSchema:()=>ou,JSONRPCNotificationSchema:()=>os,JSONRPCRequestSchema:()=>oo,JSONRPCResponseSchema:()=>od,JSONRPCResultResponseSchema:()=>ol,JSONValueSchema:()=>a0,LegacyTitledEnumSchemaSchema:()=>sG,ListChangedOptionsBaseSchema:()=>sT,ListPromptsRequestSchema:()=>si,ListPromptsResultSchema:()=>sn,ListResourceTemplatesRequestSchema:()=>oW,ListResourceTemplatesResultSchema:()=>oG,ListResourcesRequestSchema:()=>oV,ListResourcesResultSchema:()=>oB,ListRootsRequestSchema:()=>la,ListRootsResultSchema:()=>lo,ListTasksRequestSchema:()=>lv,ListTasksResultSchema:()=>l_,ListToolsRequestSchema:()=>sb,ListToolsResultSchema:()=>sS,LoggingLevelSchema:()=>sC,LoggingMessageNotificationParamsSchema:()=>sE,LoggingMessageNotificationSchema:()=>sI,ModelHintSchema:()=>sq,ModelPreferencesSchema:()=>sj,MultiSelectEnumSchemaSchema:()=>sQ,NotificationSchema:()=>or,NotificationsParamsSchema:()=>ot,NumberSchemaSchema:()=>sV,PaginatedRequestParamsSchema:()=>oz,PaginatedRequestSchema:()=>oA,PaginatedResultSchema:()=>oN,PingRequestSchema:()=>oE,PrimitiveSchemaDefinitionSchema:()=>s1,ProgressNotificationParamsSchema:()=>oq,ProgressNotificationSchema:()=>oj,ProgressSchema:()=>oI,ProgressTokenSchema:()=>a9,PromptArgumentSchema:()=>st,PromptListChangedNotificationSchema:()=>sg,PromptMessageSchema:()=>sh,PromptReferenceSchema:()=>le,PromptSchema:()=>sr,ReadResourceRequestParamsSchema:()=>oK,ReadResourceRequestSchema:()=>oY,ReadResourceResultSchema:()=>oX,RelatedTaskMetadataSchema:()=>a6,RequestIdSchema:()=>oa,RequestMetaSchema:()=>a5,RequestSchema:()=>oe,ResourceContentsSchema:()=>oM,ResourceLinkSchema:()=>sp,ResourceListChangedNotificationSchema:()=>oQ,ResourceRequestParamsSchema:()=>oK,ResourceSchema:()=>oH,ResourceTemplateReferenceSchema:()=>s8,ResourceTemplateSchema:()=>oJ,ResourceUpdatedNotificationParamsSchema:()=>o8,ResourceUpdatedNotificationSchema:()=>se,ResultMetaObjectSchema:()=>oi,ResultSchema:()=>on,RoleSchema:()=>oF,RootSchema:()=>ln,RootsListChangedNotificationSchema:()=>ls,SamplingContentSchema:()=>sN,SamplingMessageContentBlockSchema:()=>sM,SamplingMessageSchema:()=>sL,ServerCapabilitiesSchema:()=>o$,ServerNotificationSchema:()=>l$,ServerRequestSchema:()=>lx,ServerResultSchema:()=>lT,ServerTasksCapabilitySchema:()=>ow,SetLevelRequestParamsSchema:()=>sP,SetLevelRequestSchema:()=>sO,SingleSelectEnumSchemaSchema:()=>sK,StringSchemaSchema:()=>sJ,SubscribeRequestParamsSchema:()=>oK,SubscribeRequestSchema:()=>o0,SubscriptionFilterSchema:()=>o2,SubscriptionsAcknowledgedNotificationParamsSchema:()=>o3,SubscriptionsAcknowledgedNotificationSchema:()=>o6,SubscriptionsListenRequestParamsSchema:()=>o9,SubscriptionsListenRequestSchema:()=>o4,SubscriptionsListenResultMetaSchema:()=>o5,SubscriptionsListenResultSchema:()=>o7,TaskAugmentedRequestParamsSchema:()=>a8,TaskCreationParamsSchema:()=>ll,TaskMetadataSchema:()=>a3,TaskSchema:()=>lu,TaskStatusNotificationParamsSchema:()=>lp,TaskStatusNotificationSchema:()=>lm,TaskStatusSchema:()=>lc,TextContentSchema:()=>ss,TextResourceContentsSchema:()=>oL,TitledMultiSelectEnumSchemaSchema:()=>sX,TitledSingleSelectEnumSchemaSchema:()=>sW,ToolAnnotationsSchema:()=>sy,ToolChoiceSchema:()=>sz,ToolExecutionSchema:()=>sv,ToolListChangedNotificationSchema:()=>s$,ToolResultContentSchema:()=>sA,ToolSchema:()=>s_,ToolUseContentSchema:()=>su,UnsubscribeRequestParamsSchema:()=>oK,UnsubscribeRequestSchema:()=>o1,UntitledMultiSelectEnumSchemaSchema:()=>sY,UntitledSingleSelectEnumSchemaSchema:()=>sB});let cY=e=>oo.safeParse(e).success,cX=e=>os.safeParse(e).success,cQ=e=>ol.safeParse(e).success,c0=e=>oc.safeParse(e).success,c1=e=>"object"==typeof e&&null!==e&&!Array.isArray(e)&&"input_required"===e.resultType,c2="x-mcp-header",c9=/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/,c4=new Set(["string","integer","boolean"]);function c3(e){let t,r=[],i=new Map,n=(e,a,o)=>{if(null===e||"object"!=typeof e)return;if(c2 in e){if(!o||0===a.length)return`${c7(a)}: x-mcp-header is only permitted on properties statically reachable via a chain of 'properties' keys (not under items, additionalProperties, oneOf/anyOf/allOf/not, if/then/else, or $ref)`;let n=e[c2];if("string"!=typeof n||0===n.length)return`${c7(a)}: x-mcp-header MUST be a non-empty string`;if(!c9.test(n))return`${c7(a)}: x-mcp-header '${n}' is not a valid RFC 9110 token (no spaces, control characters or HTTP delimiters)`;let s="string"==typeof e.type?e.type:void 0;if(void 0===s||!c4.has(s)){let e=`${c7(a)}: x-mcp-header is only permitted on primitive-typed properties (string, integer, boolean); got ${s??"<none>"}`;if("number"!==s)return e;t??=e}let l=n.toLowerCase(),c=i.get(l);if(void 0!==c)return`x-mcp-header '${n}' is not case-insensitively unique (also declared as '${c}')`;i.set(l,n),r.push({path:a,headerName:n,type:s})}let s=e.properties;if(null!==s&&"object"==typeof s)for(let[e,t]of Object.entries(s)){let r=n(t,[...a,e],o);if(void 0!==r)return r}for(let t of c6){let r=e[t];if(void 0!==r)for(let e of Array.isArray(r)?r:null!==r&&"object"==typeof r&&c5.has(t)?Object.values(r):[r]){let r=n(e,[...a,`<${t}>`],!1);if(void 0!==r)return r}}},a=n(e,[],!0);return void 0!==a?{valid:!1,reason:t??a}:void 0===t?{valid:!0,declarations:r}:{valid:!1,reason:t,declarations:r}}let c6=["items","prefixItems","contains","additionalProperties","unevaluatedProperties","unevaluatedItems","propertyNames","patternProperties","dependentSchemas","oneOf","anyOf","allOf","not","if","then","else","$defs","definitions"],c5=new Set(["patternProperties","dependentSchemas","$defs","definitions"]);function c7(e){return 0===e.length?"<root>":e.join(".")}let c8=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/,ue=/^-?\d+(\.\d+)?$/;function ut(e){if(!(e.startsWith("=?base64?")&&e.endsWith("?=")))return e;let t=e.slice(9,e.length-2);if(c8.test(t))try{let e=atob(t),r=new Uint8Array(e.length);for(let t=0;t<e.length;t++)r[t]=e.codePointAt(t);return new TextDecoder("utf-8",{fatal:!0}).decode(r)}catch{return}}function ur(e,t,r){return{kind:"reject",rung:"param-header-validation",cell:e,httpStatus:400,code:ui,message:`Bad Request: the request headers and body disagree: ${r}`,data:{mismatch:{header:t,body:r}},settled:!0}}let ui=-32020;cy.InvalidRequest,cy.UnsupportedProtocolVersion,cy.InvalidParams,cy.MethodNotFound,cy.InvalidParams,cy.MissingRequiredClientCapability;let un={[cy.ParseError]:400,[cy.InvalidRequest]:400,[cy.MethodNotFound]:404,[cy.UnsupportedProtocolVersion]:400,[cy.MissingRequiredClientCapability]:400,[ui]:400};function ua(e,t,r,i,n){return{kind:"reject",rung:e,cell:t,httpStatus:r,code:i.code,message:i.message,...void 0!==i.data&&{data:i.data},settled:n}}function uo(e,t,r,i="era-classification"){return ua(i,e,400,new cv(ui,`Bad Request: the request headers and body disagree: ${r}`,{mismatch:{header:t,body:r}}),!0)}let us={"tools/call":"name","prompts/get":"name","resources/read":"uri","tasks/get":"taskId","tasks/update":"taskId","tasks/cancel":"taskId"};function ul(e){let t=0;for(;t<e.length;){let r=e.codePointAt(t);if(9!==r&&32!==r)break;t+=1}let r=e.length;for(;r>t;){let t=e.codePointAt(r-1);if(9!==t&&32!==t)break;r-=1}return 0===t&&r===e.length?e:e.slice(t,r)}function uc(e){return null!==e&&"object"==typeof e&&!Array.isArray(e)}function uu(e){return void 0===e?{era:"modern"}:{era:e>=lX?"modern":"legacy",revision:e}}function ud(e){return new Set(e.flatMap(e=>Object.keys(e.shape)))}function up(e){if(null==e)return!1;let t=typeof e;return("object"===t||"function"===t)&&"~standard"in e&&"function"==typeof e["~standard"]?.validate}let um=!1,uh="draft-2020-12";function uf(e,t="input"){let r,i=e["~standard"];if(i.jsonSchema)r=i.jsonSchema[t]({target:uh});else if("zod"===i.vendor){if(!("_zod"in e))throw Error("Schema appears to be from zod 3, which the SDK cannot convert to JSON Schema. Upgrade to zod >=4.2.0, or wrap your JSON Schema with fromJsonSchema().");um||(um=!0,console.warn("[mcp-sdk] Your zod version does not implement `~standard.jsonSchema` (added in zod 4.2.0). Falling back to z.toJSONSchema(). Upgrade to zod >=4.2.0 to silence this warning.")),r=nn(e,{target:uh,io:t})}else throw Error(`Schema library "${i.vendor}" does not implement StandardJSONSchemaV1 (\`~standard.jsonSchema\`). Upgrade to a version that does, or wrap your JSON Schema with fromJsonSchema().`);if("output"===t)return void 0!==r.type||!function e(t,r=t){if("properties"in t||"patternProperties"in t||"additionalProperties"in t||"required"in t)return!0;let i="string"==typeof t.$ref&&ug.exec(t.$ref);if(i&&r[i[1]]?.[i[2]]?.type==="object")return!0;for(let i of["oneOf","anyOf","allOf"]){let n=t[i];if(Array.isArray(n)&&n.length>0)return n.every(t=>null!==t&&"object"==typeof t&&("object"===t.type||e(t,"$id"in t?{}:r)))}return!1}(r)?r:{type:"object",...r};if(void 0!==r.type&&"object"!==r.type)throw Error(`MCP tool and prompt schemas must describe objects (got type: ${JSON.stringify(r.type)}). Wrap your schema in z.object({...}) or equivalent.`);return{type:"object",...r}}let ug=/^#\/(\$defs|definitions)\/([^/~%]+)$/;async function uy(e,t){let r=await e["~standard"].validate(t);return r.issues&&r.issues.length>0?{success:!1,error:r.issues.map(e=>e.path?.length?`${e.path.map(e=>String("object"==typeof e?e.key:e)).join(".")}: ${e.message}`:e.message).join(", ")}:{success:!0,data:r.value}}let uv=/\\\.\\d\{(\d+)\}/;function u_(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}let ub=new Set(["$comment","deprecated","description","examples","readOnly","title","writeOnly"]);function uS(e){return ub.has(e)||e.startsWith("x-")}let uw=new Set(["$schema",...Object.keys(s2.shape.requestedSchema.shape)]),uR={string:ud([sJ,sB,sW,sG]),number:ud([sV]),integer:ud([sV]),boolean:ud([sH]),array:ud([sY,sX])},uk=new Set(sJ.shape.format.unwrap().options);Object.assign(function(e){let t=void 0!==e.inputRequests&&Object.keys(e.inputRequests).length>0,r="string"==typeof e.requestState;if(!t&&!r)throw TypeError("inputRequired() requires at least one of inputRequests (with at least one entry) or requestState (spec: every InputRequiredResult MUST include at least one of the two)");return{resultType:"input_required",...void 0!==e.inputRequests&&{inputRequests:e.inputRequests},...void 0!==e.requestState&&{requestState:e.requestState}}},{elicit(e){try{return{method:"elicitation/create",params:function(e){var t;if(!up(e.requestedSchema))return{...e,mode:"form",requestedSchema:e.requestedSchema};let r=e.requestedSchema["~standard"].vendor,i=function(e,t){let r={},i=[];for(let[n,a]of Object.entries(e))"properties"===n&&u_(a)?r[n]=Object.fromEntries(Object.entries(a).map(([e,r])=>[e,function(e,t,r,i){if(!u_(e))return e;let n="string"==typeof e.type&&Object.hasOwn(uR,e.type)?uR[e.type]:void 0;if(void 0===n)return e;let a={};for(let[s,l]of Object.entries(e))if(n.has(s)||uS(s))a[s]=l;else if("pattern"===s&&"string"===e.type&&"string"==typeof e.format)if(uk.has(e.format)){var o;"string"==typeof l&&(o=e.format,"zod"!==r||(function(e,t){let r;switch(e){case"email":r=[r6(nD,void 0)];break;case"uri":r=[r5(nV,void 0)];break;case"date":r=[r8(nZ,void 0)];break;case"date-time":let i,n;i=uv.exec(t),n=[void 0,-1,0],i&&n.push(Number(i[1])),r=[!1,!0].flatMap(e=>[!1,!0].flatMap(t=>n.map(r=>r7(nL,{local:e,offset:t,precision:r}))))}return new Set(r.map(e=>{let t;return t=nn(e,{target:uh,io:"input"}),"string"==typeof t.pattern?t.pattern:void 0}).filter(e=>void 0!==e))})(o,l).has(l))||i.push(`${t}.${s}`)}else a[s]=l;else i.push(`${t}.${s}`);return a}(r,`properties.${e}`,t,i)])):uw.has(n)?r[n]=a:uS(n)||i.push(n);if(i.length>0)throw new cv(cy.InvalidParams,`Elicitation requestedSchema contains unsupported JSON Schema constraint(s) after Standard Schema conversion: ${i.join(", ")}`);return r}(function(e){try{return uf(e,"input")}catch(t){let e=t instanceof Error?t.message:String(t);throw new cv(cy.InvalidParams,`Elicitation requestedSchema must describe an object with flat primitive properties: ${e}`)}}(e.requestedSchema),r),n=(t=s2.shape.requestedSchema,nR(t,i));if(!n.success)throw new cv(cy.InvalidParams,`Elicitation requestedSchema only supports flat primitive properties (string, number, integer, boolean, and string enums): ${function(e,t){if(!u_(e.properties))return t;let r=Object.entries(e.properties).filter(([,e])=>!nR(s1,e).success).map(([e])=>`properties.${e}`);return r.length>0?r.join(", "):t}(i,n.error.message)}`);let a=function e(t,r,i=""){return Array.isArray(t)&&Array.isArray(r)?t.flatMap((t,n)=>e(t,r[n],`${i}[${n}]`)):u_(t)&&u_(r)?Object.entries(t).flatMap(([t,n])=>{let a=i?`${i}.${t}`:t;return Object.prototype.hasOwnProperty.call(r,t)?e(n,r[t],a):uS(t)?[]:[a]}):[]}(i,n.data);if(a.length>0)throw new cv(cy.InvalidParams,`Elicitation requestedSchema contains unsupported JSON Schema constraint(s) after Standard Schema conversion: ${a.join(", ")}`);let o=(n.data.required??[]).filter(e=>!Object.prototype.hasOwnProperty.call(n.data.properties,e));if(o.length>0)throw new cv(cy.InvalidParams,`Elicitation requestedSchema lists required properties that are not defined in properties: ${o.join(", ")}`);return{...e,mode:"form",requestedSchema:n.data}}(e)}}catch(e){throw e instanceof cv?TypeError(e.message,{cause:e}):e}},elicitUrl:e=>({method:"elicitation/create",params:{...e,mode:"url"}}),createMessage:e=>({method:"sampling/createMessage",params:e}),listRoots:()=>({method:"roots/list"})});let ux={},u$={};function uT(e,t){let r=e.slice(0,-6);ux[r]=t,u$[r]=e=>t.safeParse(e).success}for(let e of["AnnotationsSchema","AudioContentSchema","BaseMetadataSchema","BlobResourceContentsSchema","BooleanSchemaSchema","CallToolRequestSchema","CallToolRequestParamsSchema","CallToolResultSchema","CancelledNotificationSchema","CancelledNotificationParamsSchema","CancelTaskRequestSchema","CancelTaskResultSchema","ClientCapabilitiesSchema","ClientNotificationSchema","ClientRequestSchema","ClientResultSchema","CompatibilityCallToolResultSchema","CompleteRequestSchema","CompleteRequestParamsSchema","CompleteResultSchema","ContentBlockSchema","CreateMessageRequestSchema","CreateMessageRequestParamsSchema","CreateMessageResultSchema","CreateMessageResultWithToolsSchema","CreateTaskResultSchema","CursorSchema","DiscoverRequestSchema","DiscoverResultSchema","ElicitationCompleteNotificationSchema","ElicitationCompleteNotificationParamsSchema","ElicitRequestSchema","ElicitRequestFormParamsSchema","ElicitRequestParamsSchema","ElicitRequestURLParamsSchema","ElicitResultSchema","EmbeddedResourceSchema","EmptyResultSchema","EnumSchemaSchema","GetPromptRequestSchema","GetPromptRequestParamsSchema","GetPromptResultSchema","GetTaskPayloadRequestSchema","GetTaskPayloadResultSchema","GetTaskRequestSchema","GetTaskResultSchema","IconSchema","IconsSchema","ImageContentSchema","ImplementationSchema","InitializedNotificationSchema","InitializeRequestSchema","InitializeRequestParamsSchema","InitializeResultSchema","JSONArraySchema","JSONObjectSchema","JSONRPCErrorResponseSchema","JSONRPCMessageSchema","JSONRPCNotificationSchema","JSONRPCRequestSchema","JSONRPCResponseSchema","JSONRPCResultResponseSchema","JSONValueSchema","LegacyTitledEnumSchemaSchema","ListPromptsRequestSchema","ListPromptsResultSchema","ListResourcesRequestSchema","ListResourcesResultSchema","ListResourceTemplatesRequestSchema","ListResourceTemplatesResultSchema","ListRootsRequestSchema","ListRootsResultSchema","ListTasksRequestSchema","ListTasksResultSchema","ListToolsRequestSchema","ListToolsResultSchema","LoggingLevelSchema","LoggingMessageNotificationSchema","LoggingMessageNotificationParamsSchema","ModelHintSchema","ModelPreferencesSchema","MultiSelectEnumSchemaSchema","NotificationSchema","NumberSchemaSchema","PaginatedRequestSchema","PaginatedRequestParamsSchema","PaginatedResultSchema","PingRequestSchema","PrimitiveSchemaDefinitionSchema","ProgressSchema","ProgressNotificationSchema","ProgressNotificationParamsSchema","ProgressTokenSchema","PromptSchema","PromptArgumentSchema","PromptListChangedNotificationSchema","PromptMessageSchema","PromptReferenceSchema","ReadResourceRequestSchema","ReadResourceRequestParamsSchema","ReadResourceResultSchema","RelatedTaskMetadataSchema","RequestSchema","RequestIdSchema","RequestMetaSchema","ResourceSchema","ResourceContentsSchema","ResourceLinkSchema","ResourceListChangedNotificationSchema","ResourceRequestParamsSchema","ResourceTemplateSchema","ResourceTemplateReferenceSchema","ResourceUpdatedNotificationSchema","ResourceUpdatedNotificationParamsSchema","ResultMetaObjectSchema","ResultSchema","RoleSchema","RootSchema","RootsListChangedNotificationSchema","SamplingContentSchema","SamplingMessageSchema","SamplingMessageContentBlockSchema","ServerCapabilitiesSchema","ServerNotificationSchema","ServerRequestSchema","ServerResultSchema","SetLevelRequestSchema","SetLevelRequestParamsSchema","SingleSelectEnumSchemaSchema","StringSchemaSchema","SubscribeRequestSchema","SubscribeRequestParamsSchema","SubscriptionFilterSchema","SubscriptionsAcknowledgedNotificationSchema","SubscriptionsAcknowledgedNotificationParamsSchema","SubscriptionsListenRequestSchema","SubscriptionsListenRequestParamsSchema","SubscriptionsListenResultSchema","SubscriptionsListenResultMetaSchema","TaskAugmentedRequestParamsSchema","TaskCreationParamsSchema","TaskMetadataSchema","TaskSchema","TaskStatusSchema","TaskStatusNotificationSchema","TaskStatusNotificationParamsSchema","TextContentSchema","TextResourceContentsSchema","TitledMultiSelectEnumSchemaSchema","TitledSingleSelectEnumSchemaSchema","ToolSchema","ToolAnnotationsSchema","ToolChoiceSchema","ToolExecutionSchema","ToolListChangedNotificationSchema","ToolResultContentSchema","ToolUseContentSchema","UnsubscribeRequestSchema","UnsubscribeRequestParamsSchema","UntitledMultiSelectEnumSchemaSchema","UntitledSingleSelectEnumSchemaSchema"])uT(e,cK[e]);for(let[e,t]of Object.entries({IdJagTokenExchangeResponseSchema:lj,OAuthClientInformationFullSchema:lL,OAuthClientInformationSchema:lM,OAuthClientMetadataSchema:lN,OAuthClientRegistrationErrorSchema:lZ,OAuthErrorResponseSchema:lz,OAuthMetadataSchema:lO,OAuthProtectedResourceMetadataSchema:lP,OAuthTokenRevocationRequestSchema:lU,OAuthTokensSchema:lq,OpenIdProviderDiscoveryMetadataSchema:lI,OpenIdProviderMetadataSchema:lE}))uT(e,t);let uC=Object.freeze(ux);Object.freeze(u$);let uP=[aW,aG,aY,aQ],uO=["inputResponses","requestState"];function uE(e,t){let r=e.params;if(!uA(r))return{message:e,lifted:{}};let i=r._meta,n=uA(i)?uP.filter(e=>e in i):[],a="request"===t?uO.filter(e=>e in r):[];if(0===n.length&&0===a.length)return{message:e,lifted:{}};let o={},s={...r};if(n.length>0&&uA(i)){let e={},t={...i};for(let r of n)e[r]=i[r],delete t[r];o.envelope=e,Object.keys(t).length>0?s._meta=t:delete s._meta}for(let e of a)"inputResponses"===e&&(o.inputResponses=s[e]),"requestState"===e&&(o.requestState=s[e]),delete s[e];return{message:{...e,params:s},lifted:o}}function uI(e,t){let r=e.validateResult(t,void 0);if(r.ok||"not-in-era"!==r.reason)return{"~standard":{version:1,vendor:"mcp-wire-codec",validate(r){let i=e.validateResult(t,r);return i.ok?{value:i.value}:{issues:[{message:"invalid"===i.reason?i.message:`not-in-era: ${t}`}]}}}}}let uq=(P=void 0,()=>P);function uj(e,t){return{...e,mcpReq:{...e.mcpReq,requestState:()=>t}}}var uz=class{_transport;_requestMessageId=0;_requestHandlers=new Map;_customSchemaRequestMethods=new Set;_requestHandlerAbortControllers=new Map;_notificationHandlers=new Map;_responseHandlers=new Map;_progressHandlers=new Map;_timeoutInfo=new Map;_pendingDebouncedNotifications=new Set;_negotiatedProtocolVersion;static{s=(e,t)=>{e._negotiatedProtocolVersion=t}}_supportedProtocolVersions;onclose;onerror;fallbackRequestHandler;fallbackNotificationHandler;constructor(e){this._options=e,this._supportedProtocolVersions=e?.supportedProtocolVersions??aB,this.setNotificationHandler("notifications/cancelled",e=>{this._oncancel(e)}),this.setNotificationHandler("notifications/progress",e=>{this._onprogress(e)}),this.setRequestHandler("ping",e=>({}))}_shouldDropInbound(e){}_outboundMetaEnvelope(){}_envelopeOutbound(e){let t=this._outboundMetaEnvelope();if(void 0===t)return e;let r=e.params??{};return{...e,params:{...r,_meta:{...t,...r._meta}}}}_resolveNonCompleteResult(e,t){return Promise.reject(new lW(lB.UnsupportedResultType,`Unsupported result type '${e.kind}' for ${t.request.method}`,{resultType:e.kind,method:t.request.method}))}_getRequestHandler(e){return this._requestHandlers.get(e)}async _oncancel(e){void 0!==e.params.requestId&&this._requestHandlerAbortControllers.get(e.params.requestId)?.abort(e.params.reason)}_setupTimeout(e,t,r,i,n=!1){this._timeoutInfo.set(e,{timeoutId:setTimeout(i,t),startTime:Date.now(),timeout:t,maxTotalTimeout:r,resetTimeoutOnProgress:n,onTimeout:i})}_resetTimeout(e){let t=this._timeoutInfo.get(e);if(!t)return!1;let r=Date.now()-t.startTime;if(t.maxTotalTimeout&&r>=t.maxTotalTimeout)throw this._timeoutInfo.delete(e),new lW(lB.RequestTimeout,"Maximum total timeout exceeded",{maxTotalTimeout:t.maxTotalTimeout,totalElapsed:r});return clearTimeout(t.timeoutId),t.timeoutId=setTimeout(t.onTimeout,t.timeout),!0}_cleanupTimeout(e){let t=this._timeoutInfo.get(e);t&&(clearTimeout(t.timeoutId),this._timeoutInfo.delete(e))}async connect(e){this._transport=e;let t=this.transport?.onclose;this._transport.onclose=()=>{try{t?.()}finally{this._onclose()}};let r=this.transport?.onerror;this._transport.onerror=e=>{r?.(e),this._onerror(e)};let i=this._transport?.onmessage;this._transport.onmessage=(e,t)=>{i?.(e,t),cQ(e)||c0(e)?this._onresponse(e):cY(e)?this._onrequest(e,t):cX(e)?this._onnotification(e,t):this._onerror(Error(`Unknown message type: ${JSON.stringify(e)}`))},e.setSupportedProtocolVersions?.(this._supportedProtocolVersions),await this._transport.start()}_onclose(){let e=this._responseHandlers;for(let e of(this._responseHandlers=new Map,this._progressHandlers.clear(),this._pendingDebouncedNotifications.clear(),this._timeoutInfo.values()))clearTimeout(e.timeoutId);this._timeoutInfo.clear();let t=this._requestHandlerAbortControllers;this._requestHandlerAbortControllers=new Map;let r=new lW(lB.ConnectionClosed,"Connection closed");this._transport=void 0;try{this.onclose?.()}finally{for(let t of e.values())t(r);for(let e of t.values())e.abort(r)}}_onerror(e){this.onerror?.(e)}_onnotification(e,t){let{message:r}=uE(e,"notification"),i=this._negotiatedWireCodec();if(t?.classification===void 0&&"drop"===this._shouldDropInbound(e))return;if(t?.classification!==void 0){let e=cZ(t.classification);if(e!==i.era)return void this._onerror(Error(`Era mismatch on inbound notification '${r.method}': classified as ${e} but this instance serves ${i.era}`))}if(cF(r.method)&&!i.hasNotificationMethod(r.method))return;let n=this._notificationHandlers.get(r.method),a=this.fallbackNotificationHandler;(void 0!==n||void 0!==a)&&Promise.resolve().then(()=>void 0===n?a(r):n(r,i)).catch(e=>this._onerror(Error(`Uncaught error in notification handler: ${e}`)))}_onrequest(e,t){var r;let{message:i,lifted:n}=uE(e,"request"),a=this._negotiatedWireCodec();if(t?.classification===void 0&&"drop"===this._shouldDropInbound(e))return void this._onerror(Error(`Dropped inbound request '${e.method}': not servable on this connection's protocol era`));let o=this._transport,s=(e,t,r)=>{let n={jsonrpc:"2.0",id:i.id,error:{code:e,message:t,...void 0!==r&&{data:r}}};o?.send(n).catch(e=>this._onerror(Error(`Failed to send an error response: ${e}`)))};if(t?.classification!==void 0){let e=cZ(t.classification);if(e!==a.era){this._onerror(Error(`Era mismatch on inbound request '${i.method}': classified as ${e} but this instance serves ${a.era}`));let r=t.classification.revision??e;s(cy.UnsupportedProtocolVersion,`Unsupported protocol version: ${r}`,{supported:this._supportedProtocolVersions,requested:r});return}}if(cU(i.method)&&!a.hasRequestMethod(i.method)&&!(cD(i.method)&&this._customSchemaRequestMethods.has(i.method)))return void s(cy.MethodNotFound,"Method not found");let l=this._requestHandlers.get(i.method)??this.fallbackRequestHandler;if(void 0===l)return void s(cy.MethodNotFound,"Method not found");let c=a.checkInboundEnvelope(n);if(void 0!==c)return void s(cy.InvalidParams,c);let u=(e,t)=>this._notificationViaCodec(this._resolveOutboundCodec(e.method),e,{...t,relatedRequestId:i.id}),d=(e,t,r)=>this._requestWithSchemaViaCodec(this._resolveOutboundCodec(e.method),e,t,{...r,relatedRequestId:i.id}),p=new AbortController;this._requestHandlerAbortControllers.set(i.id,p);let m=void 0===n.inputResponses?void 0:function(e){let t={},r=[];if(!uN(e))return{accepted:t,droppedKeys:r};for(let[i,n]of Object.entries(e)){if(!uN(n)||"method"in n||"result"in n){r.push(i);continue}t[i]=n}return{accepted:t,droppedKeys:r}}(n.inputResponses),h={sessionId:o?.sessionId,mcpReq:{id:i.id,method:i.method,_meta:i.params?._meta,...void 0!==n.envelope&&{envelope:n.envelope},...void 0!==m&&{inputResponses:m.accepted},...void 0!==m&&m.droppedKeys.length>0&&{droppedInputResponseKeys:m.droppedKeys},requestState:void 0===n.requestState?uq:(r=n.requestState,()=>r),signal:p.signal,send:(e,t,r)=>{let i=this._resolveOutboundCodec(e.method);if(this._assertOutboundRequestInEra(i,e.method),up(t))return d(e,t,r);let n=uI(i,e.method);if(void 0===n)throw TypeError(`'${e.method}' is not a spec method; pass a result schema as the second argument to ctx.mcpReq.send().`);return d(e,n,t)},notify:u},http:t?.authInfo?{authInfo:t.authInfo}:void 0},f=this.buildContext(h,t);Promise.resolve().then(()=>l(i,f)).then(async e=>{let t;if(p.signal.aborted)return;try{t=a.encodeResult(i.method,e,this._outboundServerInfo())}catch(e){this._onerror(Error(`Failed to encode result for ${i.method}: ${e}`)),s(cy.InternalError,"Internal error");return}let r={result:t,jsonrpc:"2.0",id:i.id};await o?.send(r)},async e=>{if(p.signal.aborted)return;let t=Number.isSafeInteger(e.code)?e.code:cy.InternalError,r={jsonrpc:"2.0",id:i.id,error:{code:a.encodeErrorCode(t),message:e.message??"Internal error",...void 0!==e.data&&{data:e.data}}};await o?.send(r)}).catch(e=>this._onerror(Error(`Failed to send response: ${e}`))).finally(()=>{this._requestHandlerAbortControllers.get(i.id)===p&&this._requestHandlerAbortControllers.delete(i.id)})}_onprogress(e){let{progressToken:t,...r}=e.params,i=Number(t),n=this._progressHandlers.get(i);if(!n)return void this._onerror(Error(`Received a progress notification for an unknown token: ${JSON.stringify(e)}`));let a=this._responseHandlers.get(i),o=this._timeoutInfo.get(i);if(o&&a&&o.resetTimeoutOnProgress)try{this._resetTimeout(i)}catch(e){this._responseHandlers.delete(i),this._progressHandlers.delete(i),this._cleanupTimeout(i),a(e);return}n(r)}_onresponse(e){let t=Number(e.id),r=this._responseHandlers.get(t);void 0===r?this._onerror(Error(`Received a response for an unknown message ID: ${JSON.stringify(e)}`)):(this._responseHandlers.delete(t),this._cleanupTimeout(t),this._progressHandlers.delete(t),r(cQ(e)?e:cv.fromError(e.error.code,e.error.message,e.error.data)))}get transport(){return this._transport}async close(){await this._transport?.close()}request(e,t,r){let i=this._resolveOutboundCodec(e.method);if(up(t))return cD(e.method)||this._assertOutboundRequestInEra(i,e.method),this._requestWithSchemaViaCodec(i,e,t,r);this._assertOutboundRequestInEra(i,e.method);let n=uI(i,e.method);if(void 0===n)throw TypeError(`'${e.method}' is not a spec method; pass a result schema as the second argument to request().`);return this._requestWithSchemaViaCodec(i,e,n,t)}_negotiatedWireCodec(){return cL(this._negotiatedProtocolVersion)}_wireCodec(){return this._negotiatedWireCodec()}_resolveOutboundCodec(e){if(void 0===this._negotiatedProtocolVersion){let t=function(e){switch(e){case"initialize":case"notifications/initialized":return cL(void 0);case"server/discover":return cL(cM);default:return}}(e);if(t)return t}return this._negotiatedWireCodec()}_assertOutboundRequestInEra(e,t){if(cU(t)&&!e.hasRequestMethod(t))throw new lW(lB.MethodNotSupportedByProtocolVersion,`Method '${t}' is not supported by the negotiated protocol version (wire era ${e.era})`,{method:t,era:e.era})}_requestWithSchema(e,t,r){let i=this._resolveOutboundCodec(e.method);return this._assertOutboundRequestInEra(i,e.method),this._requestWithSchemaViaCodec(i,e,t,r)}_requestWithSchemaViaCodec(e,t,r,i){let n,a,{relatedRequestId:o,resumptionToken:s,onresumptiontoken:l,headers:c}=i??{},u=Date.now();return new Promise((d,p)=>{let m=e=>{p(e)};if(!this._transport)return void m(Error("Not connected"));if(this._options?.enforceStrictCapabilities===!0)try{this.assertCapabilityForMethod(t.method)}catch(e){m(e);return}if(i?.signal?.aborted){let e=i.signal.reason;throw e instanceof lW?e:new lW(lB.RequestTimeout,String(e))}let h=e.era===cM&&!0===this._transport.hasPerRequestStream?new AbortController:void 0,f=this._requestMessageId++;a=f;let g={...t,jsonrpc:"2.0",id:f};i?.onprogress&&(this._progressHandlers.set(f,i.onprogress),g.params={...t.params,_meta:{...t.params?._meta,progressToken:f}});let y=this._envelopeOutbound(g),v=!1,_=e=>{v||(this._progressHandlers.delete(f),void 0===h?"initialize"!==t.method&&this._transport?.send(this._envelopeOutbound({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:f,reason:String(e)}}),{relatedRequestId:o,resumptionToken:s,onresumptiontoken:l}).catch(e=>this._onerror(Error(`Failed to send cancellation: ${e}`))):h.abort(),p(e instanceof lW?e:new lW(lB.RequestTimeout,String(e))))};this._responseHandlers.set(f,n=>{let a;if(!i?.signal?.aborted){if(v=!0,n instanceof Error)return p(n);try{a=e.decodeResult(t.method,n.result)}catch(e){return p(e instanceof Error?e:Error(String(e)))}if("invalid"===a.kind)return p(a.error);if("input_required"===a.kind){var o;return i?.allowInputRequired===!0?d({resultType:"input_required",inputRequests:(o=a).inputRequests,...void 0!==o.requestState&&{requestState:o.requestState},...void 0!==o._meta&&{_meta:o._meta}}):d(this._resolveNonCompleteResult(a,{codec:e,request:t,resultSchema:r,options:i,flowStartedAt:u,retry:(i,n)=>this._requestWithSchemaViaCodec(e,void 0===i?{method:t.method}:{method:t.method,params:i},r,n)}))}uy(r,a.result).then(e=>{e.success?d(e.data):p(new lW(lB.InvalidResult,`Invalid result for ${t.method}: ${e.error}`))},p)}}),n=()=>_(i?.signal?.reason),i?.signal?.addEventListener("abort",n,{once:!0});let b=i?.timeout??6e4;this._setupTimeout(f,b,i?.maxTotalTimeout,()=>_(new lW(lB.RequestTimeout,"Request timed out",{timeout:b})),i?.resetTimeoutOnProgress??!1),this._transport.send(y,{relatedRequestId:o,resumptionToken:s,onresumptiontoken:l,headers:c,requestSignal:h?.signal}).catch(e=>{this._progressHandlers.delete(f),p(e)})}).finally(()=>{n&&i?.signal?.removeEventListener("abort",n),void 0!==a&&(this._responseHandlers.delete(a),this._cleanupTimeout(a))})}async notification(e,t){return await this._notificationViaCodec(this._resolveOutboundCodec(e.method),e,t)}async _notificationViaCodec(e,t,r){if(!this._transport)throw new lW(lB.NotConnected,"Not connected");if(cF(t.method)&&!e.hasNotificationMethod(t.method))throw new lW(lB.MethodNotSupportedByProtocolVersion,`Notification '${t.method}' is not supported by the negotiated protocol version (wire era ${e.era})`,{method:t.method,era:e.era});this.assertNotificationCapability(t.method);let i=this._envelopeOutbound({jsonrpc:"2.0",...t});if((this._options?.debouncedNotificationMethods??[]).includes(t.method)&&!t.params&&r?.relatedRequestId===void 0){if(this._pendingDebouncedNotifications.has(t.method))return;this._pendingDebouncedNotifications.add(t.method),Promise.resolve().then(()=>{this._pendingDebouncedNotifications.delete(t.method),this._transport&&this._transport?.send(i,r).catch(e=>this._onerror(e))});return}await this._transport.send(i,r)}setRequestHandler(e,t,r){let i;if(this.assertRequestHandlerCapability(e),"function"==typeof t){if(!cU(e))throw TypeError(`'${e}' is not a spec request method; pass schemas as the second argument to setRequestHandler().`);i=(r,i)=>{let n=this._negotiatedWireCodec(),a=n.validateRequest(e,r);if(a.ok||"not-in-era"!==a.reason||(a=n.validateInputRequest(e,r)),!a.ok){if("not-in-era"===a.reason)throw new cv(cy.InternalError,`No wire schema for ${e} in the resolved era`);throw Error(a.message)}return Promise.resolve(t(a.value,i))}}else if(r)i=async(i,n)=>{let a=await uy(t.params,{...i.params});if(!a.success)throw new cv(cy.InvalidParams,`Invalid params for ${e}: ${a.error}`);return r(a.data,n)};else throw TypeError("setRequestHandler: handler is required");"function"==typeof t?this._customSchemaRequestMethods.delete(e):this._customSchemaRequestMethods.add(e),this._requestHandlers.set(e,this._wrapHandler(e,i))}_wrapHandler(e,t){return t}_outboundServerInfo(){}removeRequestHandler(e){this._requestHandlers.delete(e),this._customSchemaRequestMethods.delete(e)}assertCanSetRequestHandler(e){if(this._requestHandlers.has(e))throw Error(`A request handler for ${e} already exists, which would be overridden`)}setNotificationHandler(e,t,r){if("function"==typeof t){if(!cF(e))throw TypeError(`'${e}' is not a spec notification method; pass schemas as the second argument to setNotificationHandler().`);this._notificationHandlers.set(e,(r,i)=>{let n=i.validateNotification(e,r);if(!n.ok){if("not-in-era"===n.reason)throw new cv(cy.InternalError,`No wire schema for ${e} in the resolved era`);throw Error(n.message)}return Promise.resolve(t(n.value))});return}if(!r)throw TypeError("setNotificationHandler: handler is required");this._notificationHandlers.set(e,async i=>{let n=await uy(t.params,{...i.params});if(!n.success)throw new cv(cy.InvalidParams,`Invalid params for notification ${e}: ${n.error}`);await r(n.data,i)})}removeNotificationHandler(e){this._notificationHandlers.delete(e)}};function uA(e){return null!==e&&"object"==typeof e&&!Array.isArray(e)}function uN(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}var uM=((e,t,r)=>{if(t&&"object"==typeof t||"function"==typeof t)for(var i,n=B(t),a=0,o=n.length;a<o;a++)i=n[a],G.call(e,i)||void 0===i||J(e,i,{get:(e=>t[e]).bind(null,i),enumerable:!(r=V(t,i))||r.enumerable});return e})(J(null!=(R=(S=e=>{var t=/; *([!#$%&'*+.^_`|~0-9A-Za-z-]+) *= *("(?:[\u000b\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\u000b\u0020-\u00ff])*"|[!#$%&'*+.^_`|~0-9A-Za-z-]+) */g,r=/\\([\u000b\u0020-\u00ff])/g,i=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/;function n(e){this.parameters=Object.create(null),this.type=e}e.parse=function(e){if(!e)throw TypeError("argument string is required");var a,o,s,l="object"==typeof e?function(e){var t;if("function"==typeof e.getHeader?t=e.getHeader("content-type"):"object"==typeof e.headers&&(t=e.headers&&e.headers["content-type"]),"string"!=typeof t)throw TypeError("content-type header is missing from object");return t}(e):e;if("string"!=typeof l)throw TypeError("argument string is required to be a string");var c=l.indexOf(";"),u=-1!==c?l.slice(0,c).trim():l.trim();if(!i.test(u))throw TypeError("invalid media type");var d=new n(u.toLowerCase());if(-1!==c){for(t.lastIndex=c;o=t.exec(l);){if(o.index!==c)throw TypeError("invalid parameter format");c+=o[0].length,a=o[1].toLowerCase(),34===(s=o[2]).charCodeAt(0)&&-1!==(s=s.slice(1,-1)).indexOf("\\")&&(s=s.replace(r,"$1")),d.parameters[a]=s}if(c!==l.length)throw TypeError("invalid parameter format")}return d}},()=>(w||S((w={exports:{}}).exports),w.exports))())?H(W(R)):{},"default",{value:R,enumerable:!0}),R);function uL(e){if(e)try{return uM.parse(e).type}catch{let t=(e.split(";",1)[0]??"").trim().toLowerCase();if(""===t||e.slice(t.length).includes(","))return;return t}}function uZ(e){return"application/json"===e||"application/json"===uL(e)}let uU=/^[A-Za-z0-9._-]{1,128}$/;function uF(e){let t=function(e){let t=[];if(0===e.length)return{isValid:!1,warnings:["Tool name cannot be empty"]};if(e.length>128)return{isValid:!1,warnings:[`Tool name exceeds maximum length of 128 characters (current: ${e.length})`]};if(e.includes(" ")&&t.push("Tool name contains spaces, which may cause parsing issues"),e.includes(",")&&t.push("Tool name contains commas, which may cause parsing issues"),(e.startsWith("-")||e.endsWith("-"))&&t.push("Tool name starts or ends with a dash, which may cause parsing issues in some contexts"),(e.startsWith(".")||e.endsWith("."))&&t.push("Tool name starts or ends with a dot, which may cause parsing issues in some contexts"),!uU.test(e)){let r=[...e].filter(e=>!/[A-Za-z0-9._-]/.test(e)).filter((e,t,r)=>r.indexOf(e)===t);return t.push(`Tool name contains invalid characters: ${r.map(e=>`"${e}"`).join(", ")}`,"Allowed characters are: A-Z, a-z, 0-9, underscore (_), dash (-), and dot (.)"),{isValid:!1,warnings:t}}return{isValid:!0,warnings:t}}(e);var r=t.warnings;if(r.length>0){for(let t of(console.warn(`Tool name validation warning for "${e}":`),r))console.warn(` - ${t}`);console.warn("Tool registration will proceed, but this may cause compatibility issues."),console.warn("Consider updating the tool name to conform to the MCP tool naming standard."),console.warn("See SEP: Specify Format for Tool Names (https://github.com/modelcontextprotocol/modelcontextprotocol/issues/986) for more details.")}return t.isValid}var uD=class e{static isTemplate(e){return/\{[^}\s]+\}/.test(e)}static validateLength(e,t,r){if(e.length>t)throw Error(`${r} exceeds maximum length of ${t} characters (got ${e.length})`)}template;parts;get variableNames(){return this.parts.flatMap(e=>"string"==typeof e?[]:e.names)}constructor(t){e.validateLength(t,1e6,"Template"),this.template=t,this.parts=this.parse(t)}toString(){return this.template}parse(t){let r=[],i="",n=0,a=0;for(;n<t.length;)if("{"===t[n]){i&&(r.push(i),i="");let o=t.indexOf("}",n);if(-1===o)throw Error("Unclosed template expression");if(++a>1e4)throw Error("Template contains too many expressions (max 10000)");let s=t.slice(n+1,o),l=this.getOperator(s),c=s.includes("*"),u=this.getNames(s),d=u[0];for(let t of u)e.validateLength(t,1e6,"Variable name");r.push({name:d,operator:l,names:u,exploded:c}),n=o+1}else i+=t[n],n++;return i&&r.push(i),r}getOperator(e){return["+","#",".","/","?","&"].find(t=>e.startsWith(t))||""}getNames(e){let t=this.getOperator(e);return e.slice(t.length).split(",").map(e=>e.replace("*","").trim()).filter(e=>e.length>0)}encodeValue(t,r){return(e.validateLength(t,1e6,"Variable value"),"+"===r||"#"===r)?encodeURI(t):encodeURIComponent(t)}expandPart(e,t){if("?"===e.operator||"&"===e.operator){let r=e.names.map(r=>{let i=t[r];return void 0===i?"":`${r}=${Array.isArray(i)?i.map(t=>this.encodeValue(t,e.operator)).join(","):this.encodeValue(i.toString(),e.operator)}`}).filter(e=>e.length>0);return 0===r.length?"":("?"===e.operator?"?":"&")+r.join("&")}if(e.names.length>1){let r=e.names.map(e=>t[e]).filter(e=>void 0!==e);return 0===r.length?"":r.map(e=>Array.isArray(e)?e[0]:e).join(",")}let r=t[e.name];if(void 0===r)return"";let i=(Array.isArray(r)?r:[r]).map(t=>this.encodeValue(t,e.operator));switch(e.operator){case"":case"+":default:return i.join(",");case"#":return"#"+i.join(",");case".":return"."+i.join(".");case"/":return"/"+i.join("/")}}expand(e){let t="",r=!1;for(let i of this.parts){if("string"==typeof i){t+=i;continue}let n=this.expandPart(i,e);n&&(t+=("?"===i.operator||"&"===i.operator)&&r?n.replace("?","&"):n,("?"===i.operator||"&"===i.operator)&&(r=!0))}return t}escapeRegExp(e){return e.replaceAll(/[.*+?^${}()|[\]\\]/g,String.raw`\$&`)}partToRegExp(t){let r,i=[];for(let r of t.names)e.validateLength(r,1e6,"Variable name");if("?"===t.operator||"&"===t.operator){for(let e=0;e<t.names.length;e++){let r=t.names[e],n=0===e?"\\"+t.operator:"&";i.push({pattern:n+this.escapeRegExp(r)+"=([^&]+)",name:r})}return i}let n=t.name;switch(t.operator){case"":r=t.exploded?"([^/,]+(?:,[^/,]+)*)":"([^/,]+)";break;case"+":case"#":r="(.+)";break;case".":r=String.raw`\.([^/,]+)`;break;case"/":r="/"+(t.exploded?"([^/,]+(?:,[^/,]+)*)":"([^/,]+)");break;default:r="([^/]+)"}return i.push({pattern:r,name:n}),i}match(t){e.validateLength(t,1e6,"URI");let r="^",i=[];for(let e of this.parts)if("string"==typeof e)r+=this.escapeRegExp(e);else for(let{pattern:t,name:n}of this.partToRegExp(e))r+=t,i.push({name:n,exploded:e.exploded});r+="$",e.validateLength(r,1e6,"Generated regex pattern");let n=new RegExp(r),a=t.match(n);if(!a)return null;let o={};for(let[e,t]of i.entries()){let{name:r,exploded:i}=t,n=a[e+1];o[r.replace("*","")]=i&&n.includes(",")?n.split(","):n}return o}};function uH(e){if(void 0!==e){if(function(e){if("object"!=typeof e||null===e||up(e))return!1;let t=Object.getPrototypeOf(e);return(t===Object.prototype||null===t)&&Object.values(e).every(e=>"object"==typeof e&&null!==e&&"_zod"in e)}(e))return am(e);if("object"==typeof e&&null!==e&&!up(e)&&Object.values(e).some(e=>"object"==typeof e&&null!==e&&!("_zod"in e)&&"_def"in e&&"string"==typeof e._def?.typeName))throw TypeError("Raw-shape inputSchema/outputSchema/argsSchema fields must be Zod v4 schemas. Got a Zod v3 field schema. Import from `zod/v4` (or upgrade your zod import), or wrap with `z.object({...})` yourself.");if(!up(e))throw TypeError("inputSchema/outputSchema/argsSchema must be a Standard Schema (e.g. z.object({...})) or a raw Zod shape ({ field: z.string() }).");return e}}function uJ(e,t){let r=typeof e;if(r!==typeof t)return!1;if(Array.isArray(e)){if(!Array.isArray(t))return!1;let r=e.length;if(r!==t.length)return!1;for(let i=0;i<r;i++)if(!uJ(e[i],t[i]))return!1;return!0}if("object"===r){if(!e||!t)return e===t;let r=Object.keys(e),i=Object.keys(t);if(r.length!==i.length)return!1;for(let i of r)if(!uJ(e[i],t[i]))return!1;return!0}return e===t}function uV(e){return encodeURI(e.replace(/~/g,"~0").replace(/\//g,"~1"))}let uB={prefixItems:!0,items:!0,allOf:!0,anyOf:!0,oneOf:!0},uW={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependentSchemas:!0},uG={id:!0,$id:!0,$ref:!0,$schema:!0,$anchor:!0,$vocabulary:!0,$comment:!0,default:!0,enum:!0,const:!0,required:!0,type:!0,maximum:!0,minimum:!0,exclusiveMaximum:!0,exclusiveMinimum:!0,multipleOf:!0,maxLength:!0,minLength:!0,pattern:!0,format:!0,maxItems:!0,minItems:!0,uniqueItems:!0,maxProperties:!0,minProperties:!0},uK="u">typeof self&&self.location&&"null"!==self.location.origin?new URL(self.location.origin+self.location.pathname+location.search):new URL("https://github.com/cfworker");function uY(e,t=Object.create(null),r=uK,i=""){if(e&&"object"==typeof e&&!Array.isArray(e)){let n=e.$id||e.id;if(n){let a=new URL(n,r.href);a.hash.length>1?t[a.href]=e:(a.hash="",""===i?r=a:uY(e,t,r))}}else if(!0!==e&&!1!==e)return t;let n=r.href+(i?"#"+i:"");if(void 0!==t[n])throw Error(`Duplicate schema URI "${n}".`);if(t[n]=e,!0===e||!1===e)return t;if(void 0===e.__absolute_uri__&&Object.defineProperty(e,"__absolute_uri__",{enumerable:!1,value:n}),e.$ref&&void 0===e.__absolute_ref__){let t=new URL(e.$ref,r.href);t.hash=t.hash,Object.defineProperty(e,"__absolute_ref__",{enumerable:!1,value:t.href})}if(e.$recursiveRef&&void 0===e.__absolute_recursive_ref__){let t=new URL(e.$recursiveRef,r.href);t.hash=t.hash,Object.defineProperty(e,"__absolute_recursive_ref__",{enumerable:!1,value:t.href})}for(let n in e.$anchor&&(t[new URL("#"+e.$anchor,r.href).href]=e),e){if(uG[n])continue;let a=`${i}/${uV(n)}`,o=e[n];if(Array.isArray(o)){if(uB[n]){let e=o.length;for(let i=0;i<e;i++)uY(o[i],t,r,`${a}/${i}`)}}else if(uW[n])for(let e in o)uY(o[e],t,r,`${a}/${uV(e)}`);else uY(o,t,r,a)}return t}let uX=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,uQ=[0,31,28,31,30,31,30,31,31,30,31,30,31],u0=/^(\d\d):(\d\d):(\d\d)(\.\d+)?(z|[+-]\d\d(?::?\d\d)?)?$/i;function u1(e){return e.test.bind(e)}let u2={date:u9,time:u4.bind(void 0,!1),"date-time":function(e){let t=e.split(u3);return 2==t.length&&u9(t[0])&&u4(!0,t[1])},duration:e=>e.length>1&&e.length<80&&(/^P\d+([.,]\d+)?W$/.test(e)||/^P[\dYMDTHS]*(\d[.,]\d+)?[YMDHS]$/.test(e)&&/^P([.,\d]+Y)?([.,\d]+M)?([.,\d]+D)?(T([.,\d]+H)?([.,\d]+M)?([.,\d]+S)?)?$/.test(e)),uri:function(e){return u6.test(e)&&u5.test(e)},"uri-reference":u1(/^(?:[a-z][a-z0-9+\-.]*:)?(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'"()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?(?:\?(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i),"uri-template":u1(/^(?:(?:[^\x00-\x20"'<>%\\^`{|}]|%[0-9a-f]{2})|\{[+#./;?&=,!@|]?(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?(?:,(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?)*\})*$/i),url:u1(/^(?:(?:https?|ftp):\/\/)(?:\S+(?::\S*)?@)?(?:(?!10(?:\.\d{1,3}){3})(?!127(?:\.\d{1,3}){3})(?!169\.254(?:\.\d{1,3}){2})(?!192\.168(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\u{00a1}-\u{ffff}0-9]+-?)*[a-z\u{00a1}-\u{ffff}0-9]+)(?:\.(?:[a-z\u{00a1}-\u{ffff}0-9]+-?)*[a-z\u{00a1}-\u{ffff}0-9]+)*(?:\.(?:[a-z\u{00a1}-\u{ffff}]{2,})))(?::\d{2,5})?(?:\/[^\s]*)?$/iu),email:e=>{if('"'===e[0])return!1;let[t,r,...i]=e.split("@");return!(!t||!r||0!==i.length||t.length>64||r.length>253||"."===t[0]||t.endsWith(".")||t.includes(".."))&&!!/^[a-z0-9.-]+$/i.test(r)&&!!/^[a-z0-9.!#$%&'*+/=?^_`{|}~-]+$/i.test(t)&&r.split(".").every(e=>/^[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?$/i.test(e))},hostname:u1(/^(?=.{1,253}\.?$)[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[-0-9a-z]{0,61}[0-9a-z])?)*\.?$/i),ipv4:u1(/^(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)$/),ipv6:u1(/^((([0-9a-f]{1,4}:){7}([0-9a-f]{1,4}|:))|(([0-9a-f]{1,4}:){6}(:[0-9a-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){5}(((:[0-9a-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){4}(((:[0-9a-f]{1,4}){1,3})|((:[0-9a-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){3}(((:[0-9a-f]{1,4}){1,4})|((:[0-9a-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){2}(((:[0-9a-f]{1,4}){1,5})|((:[0-9a-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){1}(((:[0-9a-f]{1,4}){1,6})|((:[0-9a-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9a-f]{1,4}){1,7})|((:[0-9a-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))$/i),regex:function(e){if(u7.test(e))return!1;try{return RegExp(e,"u"),!0}catch(e){return!1}},uuid:u1(/^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i),"json-pointer":u1(/^(?:\/(?:[^~/]|~0|~1)*)*$/),"json-pointer-uri-fragment":u1(/^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i),"relative-json-pointer":u1(/^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/)};function u9(e){var t;let r=e.match(uX);if(!r)return!1;let i=+r[1],n=+r[2],a=+r[3];return n>=1&&n<=12&&a>=1&&a<=(2==n&&(t=i)%4==0&&(t%100!=0||t%400==0)?29:uQ[n])}function u4(e,t){let r=t.match(u0);if(!r)return!1;let i=+r[1],n=+r[2],a=+r[3],o=!!r[5];return(i<=23&&n<=59&&a<=59||23==i&&59==n&&60==a)&&(!e||o)}let u3=/t|\s/i,u6=/\/|:/,u5=/^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)(?:\?(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i,u7=/[^\\]\\Z/;var u8=class{schema;draft;shortCircuit;lookup;constructor(e,t="2019-09",r=!0){this.schema=e,this.draft=t,this.shortCircuit=r,this.lookup=uY(e)}validate(e){return function e(t,r,i="2019-09",n=uY(r),a=!0,o=null,s="#",l="#",c=Object.create(null)){let u;if(!0===r)return{valid:!0,errors:[]};if(!1===r)return{valid:!1,errors:[{instanceLocation:s,keyword:"false",keywordLocation:s,error:"False boolean schema."}]};let d=typeof t;switch(d){case"boolean":case"number":case"string":u=d;break;case"object":u=null===t?"null":Array.isArray(t)?"array":"object";break;default:throw Error(`Instances of "${d}" type are not supported.`)}let{$ref:p,$recursiveRef:m,$recursiveAnchor:h,type:f,const:g,enum:y,required:v,not:_,anyOf:b,allOf:S,oneOf:w,if:R,then:k,else:x,format:$,properties:T,patternProperties:C,additionalProperties:P,unevaluatedProperties:O,minProperties:E,maxProperties:I,propertyNames:q,dependentRequired:j,dependentSchemas:z,dependencies:A,prefixItems:N,items:M,additionalItems:L,unevaluatedItems:Z,contains:U,minContains:F,maxContains:D,minItems:H,maxItems:J,uniqueItems:V,minimum:B,maximum:W,exclusiveMinimum:G,exclusiveMaximum:K,multipleOf:Y,minLength:X,maxLength:Q,pattern:ee,__absolute_ref__:et,__absolute_recursive_ref__:er}=r,ei=[];if(!0===h&&null===o&&(o=r),"#"===m){let u=null===o?n[er]:o,d=`${l}/$recursiveRef`,p=e(t,null===o?r:o,i,n,a,u,s,d,c);p.valid||ei.push({instanceLocation:s,keyword:"$recursiveRef",keywordLocation:d,error:"A subschema had errors."},...p.errors)}if(void 0!==p){let r=n[et||p];if(void 0===r){let e=`Unresolved $ref "${p}".`;throw et&&et!==p&&(e+=` Absolute URI "${et}".`),Error(e+=`
|
|
56
56
|
Known schemas:
|
|
57
|
-
- ${Object.keys(a).join("\n- ")}`)}let d=`${c}/$ref`,p=t(r,i,n,a,o,s,l,d,u);if(p.valid||en.push({instanceLocation:l,keyword:"$ref",keywordLocation:d,error:"A subschema had errors."},...p.errors),"4"===n||"7"===n)return{valid:0===en.length,errors:en}}if(Array.isArray(g)){let t=g.length,i=!1;for(let n=0;n<t;n++)if(d===g[n]||"integer"===g[n]&&"number"===d&&r%1==0&&r==r){i=!0;break}i||en.push({instanceLocation:l,keyword:"type",keywordLocation:`${c}/type`,error:`Instance type "${d}" is invalid. Expected "${g.join('", "')}".`})}else"integer"===g?("number"!==d||r%1||r!=r)&&en.push({instanceLocation:l,keyword:"type",keywordLocation:`${c}/type`,error:`Instance type "${d}" is invalid. Expected "${g}".`}):void 0!==g&&d!==g&&en.push({instanceLocation:l,keyword:"type",keywordLocation:`${c}/type`,error:`Instance type "${d}" is invalid. Expected "${g}".`});if(void 0!==y&&("object"===d||"array"===d?uJ(r,y)||en.push({instanceLocation:l,keyword:"const",keywordLocation:`${c}/const`,error:`Instance does not match ${JSON.stringify(y)}.`}):r!==y&&en.push({instanceLocation:l,keyword:"const",keywordLocation:`${c}/const`,error:`Instance does not match ${JSON.stringify(y)}.`})),void 0!==v&&("object"===d||"array"===d?v.some(t=>uJ(r,t))||en.push({instanceLocation:l,keyword:"enum",keywordLocation:`${c}/enum`,error:`Instance does not match any of ${JSON.stringify(v)}.`}):v.some(t=>r===t)||en.push({instanceLocation:l,keyword:"enum",keywordLocation:`${c}/enum`,error:`Instance does not match any of ${JSON.stringify(v)}.`})),void 0!==b){let i=`${c}/not`;t(r,b,n,a,o,s,l,i).valid&&en.push({instanceLocation:l,keyword:"not",keywordLocation:i,error:'Instance matched "not" schema.'})}let ea=[];if(void 0!==S){let i=`${c}/anyOf`,d=en.length,p=!1;for(let c=0;c<S.length;c++){let d=S[c],m=Object.create(u),h=t(r,d,n,a,o,!0===f?s:null,l,`${i}/${c}`,m);en.push(...h.errors),p=p||h.valid,h.valid&&ea.push(m)}p?en.length=d:en.splice(d,0,{instanceLocation:l,keyword:"anyOf",keywordLocation:i,error:"Instance does not match any subschemas."})}if(void 0!==w){let i=`${c}/allOf`,d=en.length,p=!0;for(let c=0;c<w.length;c++){let d=w[c],m=Object.create(u),h=t(r,d,n,a,o,!0===f?s:null,l,`${i}/${c}`,m);en.push(...h.errors),p=p&&h.valid,h.valid&&ea.push(m)}p?en.length=d:en.splice(d,0,{instanceLocation:l,keyword:"allOf",keywordLocation:i,error:"Instance does not match every subschema."})}if(void 0!==R){let i=`${c}/oneOf`,d=en.length,p=R.filter((c,d)=>{let p=Object.create(u),m=t(r,c,n,a,o,!0===f?s:null,l,`${i}/${d}`,p);return en.push(...m.errors),m.valid&&ea.push(p),m.valid}).length;1===p?en.length=d:en.splice(d,0,{instanceLocation:l,keyword:"oneOf",keywordLocation:i,error:`Instance does not match exactly one subschema (${p} matches).`})}if(("object"===d||"array"===d)&&Object.assign(u,...ea),void 0!==k){let i=`${c}/if`;if(t(r,k,n,a,o,s,l,i,u).valid){if(void 0!==x){let d=t(r,x,n,a,o,s,l,`${c}/then`,u);d.valid||en.push({instanceLocation:l,keyword:"if",keywordLocation:i,error:'Instance does not match "then" schema.'},...d.errors)}}else if(void 0!==$){let d=t(r,$,n,a,o,s,l,`${c}/else`,u);d.valid||en.push({instanceLocation:l,keyword:"if",keywordLocation:i,error:'Instance does not match "else" schema.'},...d.errors)}}if("object"===d){if(void 0!==_)for(let t of _)t in r||en.push({instanceLocation:l,keyword:"required",keywordLocation:`${c}/required`,error:`Instance does not have required property "${t}".`});let i=Object.keys(r);if(void 0!==I&&i.length<I&&en.push({instanceLocation:l,keyword:"minProperties",keywordLocation:`${c}/minProperties`,error:`Instance does not have at least ${I} properties.`}),void 0!==q&&i.length>q&&en.push({instanceLocation:l,keyword:"maxProperties",keywordLocation:`${c}/maxProperties`,error:`Instance does not have at least ${q} properties.`}),void 0!==j){let i=`${c}/propertyNames`;for(let c in r){let r=`${l}/${uV(c)}`,u=t(c,j,n,a,o,s,r,i);u.valid||en.push({instanceLocation:l,keyword:"propertyNames",keywordLocation:i,error:`Property name "${c}" does not match schema.`},...u.errors)}}if(void 0!==A){let t=`${c}/dependantRequired`;for(let i in A)if(i in r)for(let n of A[i])n in r||en.push({instanceLocation:l,keyword:"dependentRequired",keywordLocation:t,error:`Instance has "${i}" but does not have "${n}".`})}if(void 0!==z)for(let i in z){let d=`${c}/dependentSchemas`;if(i in r){let c=t(r,z[i],n,a,o,s,l,`${d}/${uV(i)}`,u);c.valid||en.push({instanceLocation:l,keyword:"dependentSchemas",keywordLocation:d,error:`Instance has "${i}" but does not match dependant schema.`},...c.errors)}}if(void 0!==N){let i=`${c}/dependencies`;for(let c in N)if(c in r){let u=N[c];if(Array.isArray(u))for(let t of u)t in r||en.push({instanceLocation:l,keyword:"dependencies",keywordLocation:i,error:`Instance has "${c}" but does not have "${t}".`});else{let d=t(r,u,n,a,o,s,l,`${i}/${uV(c)}`);d.valid||en.push({instanceLocation:l,keyword:"dependencies",keywordLocation:i,error:`Instance has "${c}" but does not match dependant schema.`},...d.errors)}}}let d=Object.create(null),p=!1;if(void 0!==C){let i=`${c}/properties`;for(let c in C){if(!(c in r))continue;let m=`${l}/${uV(c)}`,h=t(r[c],C[c],n,a,o,s,m,`${i}/${uV(c)}`);if(h.valid)u[c]=d[c]=!0;else if(p=o,en.push({instanceLocation:l,keyword:"properties",keywordLocation:i,error:`Property "${c}" does not match schema.`},...h.errors),p)break}}if(!p&&void 0!==E){let i=`${c}/patternProperties`;for(let c in E){let m=RegExp(c,"u"),h=E[c];for(let f in r){if(!m.test(f))continue;let g=`${l}/${uV(f)}`,y=t(r[f],h,n,a,o,s,g,`${i}/${uV(c)}`);y.valid?u[f]=d[f]=!0:(p=o,en.push({instanceLocation:l,keyword:"patternProperties",keywordLocation:i,error:`Property "${f}" matches pattern "${c}" but does not match associated schema.`},...y.errors))}}}if(p||void 0===P){if(!p&&void 0!==O){let i=`${c}/unevaluatedProperties`;for(let c in r)if(!u[c]){let d=`${l}/${uV(c)}`,p=t(r[c],O,n,a,o,s,d,i);p.valid?u[c]=!0:en.push({instanceLocation:l,keyword:"unevaluatedProperties",keywordLocation:i,error:`Property "${c}" does not match unevaluated properties schema.`},...p.errors)}}}else{let i=`${c}/additionalProperties`;for(let c in r){if(d[c])continue;let m=`${l}/${uV(c)}`,h=t(r[c],P,n,a,o,s,m,i);h.valid?u[c]=!0:(p=o,en.push({instanceLocation:l,keyword:"additionalProperties",keywordLocation:i,error:`Property "${c}" does not match additional properties schema.`},...h.errors))}}}else if("array"===d){void 0!==V&&r.length>V&&en.push({instanceLocation:l,keyword:"maxItems",keywordLocation:`${c}/maxItems`,error:`Array has too many items (${r.length} > ${V}).`}),void 0!==J&&r.length<J&&en.push({instanceLocation:l,keyword:"minItems",keywordLocation:`${c}/minItems`,error:`Array has too few items (${r.length} < ${J}).`});let i=r.length,d=0,p=!1;if(void 0!==M){let m=`${c}/prefixItems`,h=Math.min(M.length,i);for(;d<h;d++){let i=t(r[d],M[d],n,a,o,s,`${l}/${d}`,`${m}/${d}`);if(u[d]=!0,!i.valid&&(p=o,en.push({instanceLocation:l,keyword:"prefixItems",keywordLocation:m,error:"Items did not match schema."},...i.errors),p))break}}if(void 0!==L){let m=`${c}/items`;if(Array.isArray(L)){let c=Math.min(L.length,i);for(;d<c;d++){let i=t(r[d],L[d],n,a,o,s,`${l}/${d}`,`${m}/${d}`);if(u[d]=!0,!i.valid&&(p=o,en.push({instanceLocation:l,keyword:"items",keywordLocation:m,error:"Items did not match schema."},...i.errors),p))break}}else for(;d<i;d++){let i=t(r[d],L,n,a,o,s,`${l}/${d}`,m);if(u[d]=!0,!i.valid&&(p=o,en.push({instanceLocation:l,keyword:"items",keywordLocation:m,error:"Items did not match schema."},...i.errors),p))break}if(!p&&void 0!==Z){let m=`${c}/additionalItems`;for(;d<i;d++){let i=t(r[d],Z,n,a,o,s,`${l}/${d}`,m);u[d]=!0,i.valid||(p=o,en.push({instanceLocation:l,keyword:"additionalItems",keywordLocation:m,error:"Items did not match additional items schema."},...i.errors))}}}if(void 0!==F)if(0===i&&void 0===D)en.push({instanceLocation:l,keyword:"contains",keywordLocation:`${c}/contains`,error:"Array is empty. It must contain at least one item matching the schema."});else if(void 0!==D&&i<D)en.push({instanceLocation:l,keyword:"minContains",keywordLocation:`${c}/minContains`,error:`Array has less items (${i}) than minContains (${D}).`});else{let d=`${c}/contains`,p=en.length,m=0;for(let c=0;c<i;c++){let i=t(r[c],F,n,a,o,s,`${l}/${c}`,d);i.valid?(u[c]=!0,m++):en.push(...i.errors)}m>=(D||0)&&(en.length=p),void 0===D&&void 0===H&&0===m?en.splice(p,0,{instanceLocation:l,keyword:"contains",keywordLocation:d,error:"Array does not contain item matching schema."}):void 0!==D&&m<D?en.push({instanceLocation:l,keyword:"minContains",keywordLocation:`${c}/minContains`,error:`Array must contain at least ${D} items matching schema. Only ${m} items were found.`}):void 0!==H&&m>H&&en.push({instanceLocation:l,keyword:"maxContains",keywordLocation:`${c}/maxContains`,error:`Array may contain at most ${H} items matching schema. ${m} items were found.`})}if(!p&&void 0!==U){let p=`${c}/unevaluatedItems`;for(;d<i;d++){if(u[d])continue;let i=t(r[d],U,n,a,o,s,`${l}/${d}`,p);u[d]=!0,i.valid||en.push({instanceLocation:l,keyword:"unevaluatedItems",keywordLocation:p,error:"Items did not match unevaluated items schema."},...i.errors)}}if(B)for(let t=0;t<i;t++){let n=r[t],a="object"==typeof n&&null!==n;for(let o=0;o<i;o++){if(t===o)continue;let i=r[o];(n===i||a&&"object"==typeof i&&null!==i&&uJ(n,i))&&(en.push({instanceLocation:l,keyword:"uniqueItems",keywordLocation:`${c}/uniqueItems`,error:`Duplicate items at indexes ${t} and ${o}.`}),t=Number.MAX_SAFE_INTEGER,o=Number.MAX_SAFE_INTEGER)}}}else if("number"===d){if("4"===n?(void 0!==W&&(!0===K&&r<=W||r<W)&&en.push({instanceLocation:l,keyword:"minimum",keywordLocation:`${c}/minimum`,error:`${r} is less than ${K?"or equal to ":""} ${W}.`}),void 0!==G&&(!0===Y&&r>=G||r>G)&&en.push({instanceLocation:l,keyword:"maximum",keywordLocation:`${c}/maximum`,error:`${r} is greater than ${Y?"or equal to ":""} ${G}.`})):(void 0!==W&&r<W&&en.push({instanceLocation:l,keyword:"minimum",keywordLocation:`${c}/minimum`,error:`${r} is less than ${W}.`}),void 0!==G&&r>G&&en.push({instanceLocation:l,keyword:"maximum",keywordLocation:`${c}/maximum`,error:`${r} is greater than ${G}.`}),void 0!==K&&r<=K&&en.push({instanceLocation:l,keyword:"exclusiveMinimum",keywordLocation:`${c}/exclusiveMinimum`,error:`${r} is less than ${K}.`}),void 0!==Y&&r>=Y&&en.push({instanceLocation:l,keyword:"exclusiveMaximum",keywordLocation:`${c}/exclusiveMaximum`,error:`${r} is greater than or equal to ${Y}.`})),void 0!==X){let t=r%X;Math.abs(0-t)>=11920929e-14&&Math.abs(X-t)>=11920929e-14&&en.push({instanceLocation:l,keyword:"multipleOf",keywordLocation:`${c}/multipleOf`,error:`${r} is not a multiple of ${X}.`})}}else if("string"===d){let t=void 0===Q&&void 0===ee?0:function(t){let r,i=0,n=t.length,a=0;for(;a<n;)i++,(r=t.charCodeAt(a++))>=55296&&r<=56319&&a<n&&(64512&(r=t.charCodeAt(a)))==56320&&a++;return i}(r);void 0!==Q&&t<Q&&en.push({instanceLocation:l,keyword:"minLength",keywordLocation:`${c}/minLength`,error:`String is too short (${t} < ${Q}).`}),void 0!==ee&&t>ee&&en.push({instanceLocation:l,keyword:"maxLength",keywordLocation:`${c}/maxLength`,error:`String is too long (${t} > ${ee}).`}),void 0===et||RegExp(et,"u").test(r)||en.push({instanceLocation:l,keyword:"pattern",keywordLocation:`${c}/pattern`,error:"String does not match pattern."}),void 0!==T&&u2[T]&&!u2[T](r)&&en.push({instanceLocation:l,keyword:"format",keywordLocation:`${c}/format`,error:`String does not match format "${T}".`})}return{valid:0===en.length,errors:en}}(t,this.schema,this.draft,this.lookup,this.shortCircuit)}addSchema(t,r){r&&(t={...t,$id:r}),uY(t,this.lookup)}},de=class{shortcircuit;draft;constructor(t){this.shortcircuit=t?.shortcircuit??!0,this.draft=t?.draft}_draftFor(t){let r=function(t,r){if(!("$schema"in t)||"string"!=typeof t.$schema)return"2020-12";let i=t.$schema.replace(/#$/,"");if(K.has(i))return"2020-12";if(Y.has(i))return"2019-09";if(X.has(i)||Q.has(i))return"draft-7";throw Error(`JSON Schema declares an unsupported dialect ("$schema": "${t.$schema.slice(0,200)}"). The default validator supports JSON Schema 2020-12, 2019-09, draft-07, and draft-06; ${r}`)}(t,"pass an explicit { draft } to CfWorkerJsonSchemaValidator to validate other dialects.");return"draft-7"===r?"7":r}getValidator(t){let r=new u8(t,this.draft??this._draftFor(t),this.shortcircuit);return t=>{let i=r.validate(t);return i.valid?{valid:!0,data:t,errorMessage:void 0}:{valid:!1,data:void 0,errorMessage:i.errors.map(t=>`${t.instanceLocation}: ${t.error}`).join("; ")}}}};l3(),cd(),ci(),c$(),cM();let dt=Symbol.for("mcp.completable");function dr(t){return!!t&&"object"==typeof t&&dt in t}let di=0x80000000-1;function dn(t,r){if(!Number.isFinite(t)||t<1)return;let i=setInterval(r,Math.min(t,di));return i.unref?.(),i}var da=class{_listeners=new Set;constructor(t){this.onerror=t}publish(t){for(let r of this._listeners)try{r(t)}catch(t){this.onerror?.(t instanceof Error?t:Error(String(t)))}}subscribe(t){this._listeners.add(t);let r=!0;return()=>{r&&(r=!1,this._listeners.delete(t))}}get listenerCount(){return this._listeners.size}};function ds(t,r,i){return Response.json({jsonrpc:"2.0",error:{code:r,message:i},id:t},{status:200})}function dl(t,r){return{method:t.method,params:{...t.params,_meta:{...t.params?._meta,[aQ]:r}}}}function dc(t){return t.replaceAll(/[\\"]/g,String.raw`\$&`).replaceAll(/[^\u0020-\u007E]/g," ")}function du(t,r,i,n){let a=`Bearer error="${dc(t)}", error_description="${dc(r)}"`;return i.length>0&&(a+=`, scope="${dc(i.join(" "))}"`),n&&(a+=`, resource_metadata="${dc(n)}"`),a}async function dd(t,r,i){for(let a of t){let t=await i({request:a,...void 0!==r&&{authInfo:r}});if(void 0!==t){if(null===t||"object"!=typeof t||!Array.isArray(t.scopes)||0===t.scopes.length)throw TypeError("scope challenge must contain at least one scope");for(let[r,i]of t.scopes.entries()){var n=`scope challenge scopes[${r}]`;if("string"!=typeof i||!/^[\u0021\u0023-\u005B\u005D-\u007E]+$/.test(i))throw TypeError(`${n} must satisfy the OAuth scope-token grammar`)}if(void 0!==t.errorDescription&&"string"!=typeof t.errorDescription)throw TypeError("scope challenge errorDescription must be a string");if(void 0!==t.errorDescription&&!/^[\u0020-\u0021\u0023-\u005B\u005D-\u007E]+$/.test(t.errorDescription))throw TypeError("scope challenge errorDescription must satisfy the RFC 6750 error-description grammar");return t}}}function dp(t){if(t?.resourceMetadataUrl!==void 0)return t.resourceMetadataUrl;if(t?.resource?.protocol==="https:"||t?.resource?.protocol==="http:"){var r,i;let n,a;return n=new URL(r=t.resource),a=(i=r.pathname).length>1&&i.endsWith("/")?i.slice(0,-1):i,n.pathname=`/.well-known/oauth-protected-resource${"/"===a?"":a}`,n.hash="",n.href}}function dm(t,r){return function(t,r){let{requiredScopes:i=[],resourceMetadataUrl:n}=r??{};if(!(t instanceof lB)){let t=new lB(lV.ServerError,"Internal Server Error");return Response.json(t.toResponseObject(),{status:500})}switch(t.code){case lV.InvalidToken:{let r=du(t.code,t.message,i,n);return Response.json(t.toResponseObject(),{status:401,headers:{"WWW-Authenticate":r}})}case lV.InsufficientScope:{let r=du(t.code,t.message,i,n);return Response.json(t.toResponseObject(),{status:403,headers:{"WWW-Authenticate":r}})}case lV.ServerError:return Response.json(t.toResponseObject(),{status:500});default:return Response.json(t.toResponseObject(),{status:400})}}(new lB(lV.InsufficientScope,t.errorDescription??"Insufficient scope"),{requiredScopes:[...t.scopes],resourceMetadataUrl:r})}function dh(t,r,i){if(null===i||"object"!=typeof i||"string"!=typeof i.method)throw new c_(cv.InternalError,`Handler for ${t} returned an invalid input request '${r}': each inputRequests entry must be an embedded elicitation/create, sampling/createMessage, or roots/list request`);let n=function(t){switch(t.method){case"elicitation/create":if(t.params?.mode==="url")return{elicitation:{url:{}}};return{elicitation:{form:{}}};case"sampling/createMessage":{let r=t.params;if(void 0!==r&&(void 0!==r.tools||void 0!==r.toolChoice))return{sampling:{tools:{}}};return{sampling:{}}}case"roots/list":return{roots:{}};default:return}}(i);if(void 0===n)throw new c_(cv.InternalError,`Handler for ${t} returned an input request '${r}' of kind '${i.method}', which is not an embedded request the 2026-07-28 revision defines`);return{embedded:i,required:n}}function df(t,r){if("tools/call"===t)return{content:[{type:"text",text:r}],isError:!0};throw new c_(cv.InternalError,r)}var dg=class{constructor(t){this._host=t}async fulfill(t,r,i,n,a){let{maxRounds:o,roundTimeoutMs:s}=this._host,l=n.mcpReq.signal,c=a,u=0;for(;;){let a;if((u+=1)>o)return df(t,`Multi-round-trip request '${t}' still required input after ${o} rounds (inputRequired.maxRounds)`);let d=c.inputRequests,p=null!=d&&Object.keys(d).length>0,m="string"==typeof c.requestState?c.requestState:void 0;if(!p&&void 0===m)throw new c_(cv.InternalError,`Handler for ${t} returned an input-required result with neither inputRequests nor requestState (every InputRequiredResult must include at least one of the two)`);if(p){let r=this._host.resolvedClientCapabilities(n),i=[];for(let[n,a]of Object.entries(d)){let{embedded:o,required:s}=dh(t,n,a);if("roots/list"!==o.method&&void 0===o.params)throw new c_(cv.InternalError,`Handler for ${t} returned an input request '${n}' of kind '${o.method}' without params`);if(void 0!==lX(s,r))return df(t,`Cannot request input '${n}' (${o.method}): the client on this 2025-era connection did not declare the required capability${void 0===r?" (no client capabilities are available on this connection — per-request legacy serving cannot receive server-to-client requests)":""}`);i.push([n,o])}let o=function(t){let r=new AbortController,i=()=>r.abort(t?.reason);return t?.addEventListener("abort",i,{once:!0}),t?.aborted&&r.abort(t.reason),{signal:r.signal,abort:t=>r.abort(t),dispose:()=>t?.removeEventListener("abort",i)}}(l);try{let t={relatedRequestId:n.mcpReq.id,timeout:s,resetTimeoutOnProgress:!0,onprogress:()=>{},signal:o.signal},r=await Promise.all(i.map(async([r,i])=>{try{return[r,await this._dispatchLeg(i,t)]}catch(t){throw o.abort(t),t}}));a=Object.fromEntries(r)}catch(r){if(l.aborted)throw r;return df(t,`Fulfilling input required by '${t}' failed: ${r instanceof Error?r.message:String(r)}`)}finally{o.dispose()}}else await function(t,r){return new Promise((t,i)=>{if(r?.aborted)return void i(r.reason instanceof lG?r.reason:new lG(lW.RequestTimeout,String(r.reason)));let n=setTimeout(()=>{r?.removeEventListener("abort",a),t()},250),a=()=>{clearTimeout(n),i(r?.reason instanceof lG?r.reason:new lG(lW.RequestTimeout,String(r?.reason)))};r?.addEventListener("abort",a,{once:!0})})}(0,l);let h={...n,mcpReq:{...n.mcpReq,inputResponses:a,droppedInputResponseKeys:void 0,requestState:function(t){return()=>t}(m)}};if(void 0!==m){let r=await this._host.verifyRequestState(m,h,t);void 0!==r&&(h=uj(h,r))}let f=await r(i,h);if(!c2(f))return f;c=f}}async _dispatchLeg(t,r){switch(t.method){case"elicitation/create":{let i=t.params;return"url"===i.mode&&void 0===i.elicitationId&&(i={...i,elicitationId:function(){let t=globalThis.crypto;if(t?.randomUUID!==void 0)return t.randomUUID();let r=new Uint8Array(16);t.getRandomValues(r),r[6]=15&r[6]|64,r[8]=63&r[8]|128;let i=[...r].map(t=>t.toString(16).padStart(2,"0")).join("");return`${i.slice(0,8)}-${i.slice(8,12)}-${i.slice(12,16)}-${i.slice(16,20)}-${i.slice(20)}`}()}),await this._host.sendElicitation(i,r)}case"sampling/createMessage":return await this._host.sendSampling(t.params,r);case"roots/list":return await this._host.listRoots(t.params,r)}}};let dy=new Set(["tools/call","prompts/get","resources/read"]);var dv=class extends uA{_clientCapabilities;_clientVersion;static{c=(t,r)=>{void 0!==r.clientCapabilities&&(t._clientCapabilities=r.clientCapabilities),void 0!==r.clientInfo&&(t._clientVersion=r.clientInfo)},u=(t,r)=>{let i=r.filter(r=>!t._supportedProtocolVersions.includes(r));i.length>0&&(t._supportedProtocolVersions=[...t._supportedProtocolVersions,...i]),t.setRequestHandler("server/discover",()=>t._ondiscover())},d=t=>t._serverInfo}_capabilities;_instructions;_jsonSchemaValidator;_cacheHints;_requestStateVerify;_inputRequiredServing;_legacyShim;_legacyInputRequiredShim(){return this._legacyShim??=new dg({maxRounds:this._inputRequiredServing.maxRounds,roundTimeoutMs:this._inputRequiredServing.roundTimeoutMs,resolvedClientCapabilities:t=>this._inputRequestCapabilityView(t),verifyRequestState:(t,r,i)=>this._verifyRequestState(t,r,i),sendElicitation:(t,r)=>this._sendElicitationLeg(t,r,{validateAcceptedContent:!1}),sendSampling:(t,r)=>this.createMessage(t,r),listRoots:(t,r)=>this.listRoots(t,r)})}oninitialized;constructor(t,r){if(super(r),this._serverInfo=t,this._capabilities=r?.capabilities?{...r.capabilities}:{},this._instructions=r?.instructions,this._jsonSchemaValidator=r?.jsonSchemaValidator??new de,this._requestStateVerify=r?.requestState?.verify,this._inputRequiredServing=function(t){if(t?.maxRounds!==void 0&&(!Number.isInteger(t.maxRounds)||t.maxRounds<1))throw RangeError(`inputRequired.maxRounds must be a positive integer (got ${t.maxRounds})`);if(t?.roundTimeoutMs!==void 0&&(!Number.isFinite(t.roundTimeoutMs)||t.roundTimeoutMs<=0))throw RangeError(`inputRequired.roundTimeoutMs must be a positive number (got ${t.roundTimeoutMs})`);return{maxRounds:t?.maxRounds??8,roundTimeoutMs:t?.roundTimeoutMs??6e5,legacyShim:t?.legacyShim??!0}}(r?.inputRequired),r?.cacheHints!==void 0){for(let[t,i]of Object.entries(r.cacheHints))void 0!==i&&cy(i,`cacheHints['${t}']`);this._cacheHints=r.cacheHints}this.setRequestHandler("initialize",t=>this._oninitialize(t)),this.setNotificationHandler("notifications/initialized",()=>this.oninitialized?.()),l1(this._supportedProtocolVersions).length>0&&this.setRequestHandler("server/discover",()=>this._ondiscover()),this._capabilities.logging&&this._registerLoggingHandler()}async connect(t){if(void 0!==this.transport)throw new lG(lW.AlreadyConnected,"Use a separate Server instance per connection: this instance is already connected to a transport. To connect it to a new transport, call close() first.");await super.connect(t)}_registerLoggingHandler(){this.setRequestHandler("logging/setLevel",async(t,r)=>{let i=r.sessionId||r.http?.req?.headers.get("mcp-session-id")||void 0,{level:n}=t.params,a=nk(sE,n);return a.success&&this._loggingLevels.set(i,a.data),{}})}buildContext(t,r){let i=t.http||r?.request||r?.closeSSEStream||r?.closeStandaloneSSEStream;return{...t,mcpReq:{...t.mcpReq,log:(r,i,n)=>{let a;if(!this._capabilities.logging)return Promise.resolve();if(this._servedModernEra()){if(void 0===(a=t.mcpReq.envelope?.[a0]))return Promise.resolve()}else a=this._loggingLevels.get(t.sessionId)??this._loggingLevels.get(void 0);return void 0!==a&&this.LOG_LEVEL_SEVERITY.get(r)<this.LOG_LEVEL_SEVERITY.get(a)?Promise.resolve():t.mcpReq.notify({method:"notifications/message",params:{level:r,data:i,logger:n}})},elicitInput:(t,r)=>this.elicitInput(t,r),requestSampling:(t,r)=>this.createMessage(t,r)},http:i?{...t.http,req:r?.request,closeSSE:r?.closeSSEStream,closeStandaloneSSE:r?.closeStandaloneSSEStream}:void 0}}_loggingLevels=new Map;LOG_LEVEL_SEVERITY=new Map(sE.options.map((t,r)=>[t,r]));isMessageIgnored=(t,r)=>{let i=this._loggingLevels.get(r);return!!i&&this.LOG_LEVEL_SEVERITY.get(t)<this.LOG_LEVEL_SEVERITY.get(i)};registerCapabilities(t){if(this.transport)throw new lG(lW.AlreadyConnected,"Cannot register capabilities after connecting to transport");let r=!!this._capabilities.logging;this._capabilities=function(t,r){let i={...t};for(let t in r){let n=r[t];if(void 0===n)continue;let a=i[t];i[t]=uz(a)&&uz(n)?{...a,...n}:n}return i}(this._capabilities,t),!r&&this._capabilities.logging&&this._registerLoggingHandler()}_wrapHandler(t,r){if("tools/call"!==t){let i=this._cacheHints?.[t],n=dy.has(t);return void 0!==i||n?async(a,o)=>{let s=n?await this._invokeInputRequiredCapableHandler(t,r,a,o):await r(a,o);if(c2(s)){if(!n)throw new c_(cv.InternalError,`Handler for ${t} returned an input-required result, but only tools/call, prompts/get and resources/read support input_required (protocol revision 2026-07-28)`);return s}return void 0===i?s:ch(s,i)}:async(i,n)=>{let a=await r(i,n);if(c2(a))throw new c_(cv.InternalError,`Handler for ${t} returned an input-required result, but only tools/call, prompts/get and resources/read support input_required (protocol revision 2026-07-28)`);return a}}return async(t,i)=>{let n=cZ(this._negotiatedProtocolVersion),a=n.validateRequest("tools/call",t);if(!a.ok)throw new c_("not-in-era"===a.reason?cv.InternalError:cv.InvalidParams,"not-in-era"===a.reason?"No wire schema for tools/call in the resolved era":`Invalid tools/call request: ${a.message}`);let o=await this._invokeInputRequiredCapableHandler("tools/call",r,t,i);if(c2(o))return o;let s=l4(o),l=n.validateResult("tools/call",s);if(!l.ok)throw new c_("not-in-era"===l.reason?cv.InternalError:cv.InvalidParams,"not-in-era"===l.reason?"No wire schema for tools/call in the resolved era":`Invalid tools/call result: ${l.message}`);return l.value}}_servedModernEra(){return void 0!==this._negotiatedProtocolVersion&&this._negotiatedProtocolVersion>=lQ}async _invokeInputRequiredCapableHandler(t,r,i,n){let a,o=this._servedModernEra(),s=n.mcpReq.requestState();if(void 0!==s&&"string"!=typeof s)throw new c_(cv.InvalidParams,"Invalid or expired requestState",{reason:"invalid_request_state"});let l=n;if("string"==typeof s){let r=await this._verifyRequestState(s,n,t);void 0!==r&&(l=uj(n,r))}try{a=await r(i,l)}catch(t){if(t instanceof c_&&t.code===cv.UrlElicitationRequired){if(!o)throw t;throw new c_(cv.InternalError,`URL elicitation cannot be signalled by throwing UrlElicitationRequiredError on protocol revision ${this._negotiatedProtocolVersion}: return inputRequired({ inputRequests: { …: inputRequired.elicitUrl(...) } }) from the handler instead. The urlElicitationRequired error (-32042) of earlier revisions is not available on this revision.`)}throw t}if(!c2(a))return a;if(!o){if(!this._inputRequiredServing.legacyShim)throw new c_(cv.InternalError,`Handler for ${t} returned an input-required result, but this request is served on protocol revision ${this._negotiatedProtocolVersion??aB}, which has no input_required vocabulary`);return await this._legacyInputRequiredShim().fulfill(t,r,i,l,a)}let c=a.inputRequests,u=null!=c&&Object.keys(c).length>0,d="string"==typeof a.requestState;if(!u&&!d)throw new c_(cv.InternalError,`Handler for ${t} returned an input-required result with neither inputRequests nor requestState (every InputRequiredResult must include at least one of the two)`);if(u){let r=this._inputRequestCapabilityView(n);for(let[i,n]of Object.entries(c)){let{embedded:a,required:o}=dh(t,i,n),s=lX(o,r);if(void 0!==s)throw new cR({requiredCapabilities:s},`Cannot request input '${i}' (${a.method}): the request's client capabilities do not declare the required capability`)}}return a}async _verifyRequestState(t,r,i){if(void 0!==this._requestStateVerify)try{return await this._requestStateVerify(t,r)}catch(t){throw this.onerror?.(Error(`requestState verification rejected ${i}: ${t instanceof Error?t.message:String(t)}`)),new c_(cv.InvalidParams,"Invalid or expired requestState",{reason:"invalid_request_state"})}}_inputRequestCapabilityView(t){return this._servedModernEra()?t.mcpReq.envelope?.[aX]:this._clientCapabilities}_assertPushApiInServedEra(t){if(this._servedModernEra())throw new lG(lW.MethodNotSupportedByProtocolVersion,`Server-to-client requests are not available on protocol revision ${this._negotiatedProtocolVersion}: '${t}' cannot be sent while serving a request on that revision. Return inputRequired({ ... }) from the handler instead — the client fulfils the embedded requests and retries the original request (multi round-trip requests).`,{method:t,era:"2026-07-28"})}assertCapabilityForMethod(t){switch(t){case"sampling/createMessage":if(!this._clientCapabilities?.sampling)throw new lG(lW.CapabilityNotSupported,`Client does not support sampling (required for ${t})`);break;case"elicitation/create":if(!this._clientCapabilities?.elicitation)throw new lG(lW.CapabilityNotSupported,`Client does not support elicitation (required for ${t})`);break;case"roots/list":if(!this._clientCapabilities?.roots)throw new lG(lW.CapabilityNotSupported,`Client does not support listing roots (required for ${t})`)}}assertNotificationCapability(t){switch(t){case"notifications/message":if(!this._capabilities.logging)throw new lG(lW.CapabilityNotSupported,`Server does not support logging (required for ${t})`);break;case"notifications/resources/updated":case"notifications/resources/list_changed":if(!this._capabilities.resources)throw new lG(lW.CapabilityNotSupported,`Server does not support notifying about resources (required for ${t})`);break;case"notifications/tools/list_changed":if(!this._capabilities.tools)throw new lG(lW.CapabilityNotSupported,`Server does not support notifying of tool list changes (required for ${t})`);break;case"notifications/prompts/list_changed":if(!this._capabilities.prompts)throw new lG(lW.CapabilityNotSupported,`Server does not support notifying of prompt list changes (required for ${t})`);break;case"notifications/elicitation/complete":if(!this._clientCapabilities?.elicitation?.url)throw new lG(lW.CapabilityNotSupported,`Client does not support URL elicitation (required for ${t})`)}}assertRequestHandlerCapability(t){switch(t){case"completion/complete":if(!this._capabilities.completions)throw new lG(lW.CapabilityNotSupported,`Server does not support completions (required for ${t})`);break;case"logging/setLevel":if(!this._capabilities.logging)throw new lG(lW.CapabilityNotSupported,`Server does not support logging (required for ${t})`);break;case"prompts/get":case"prompts/list":if(!this._capabilities.prompts)throw new lG(lW.CapabilityNotSupported,`Server does not support prompts (required for ${t})`);break;case"resources/list":case"resources/templates/list":case"resources/read":if(!this._capabilities.resources)throw new lG(lW.CapabilityNotSupported,`Server does not support resources (required for ${t})`);break;case"tools/call":case"tools/list":if(!this._capabilities.tools)throw new lG(lW.CapabilityNotSupported,`Server does not support tools (required for ${t})`)}}async _oninitialize(t){let r=t.params.protocolVersion;this._clientCapabilities=t.params.capabilities,this._clientVersion=t.params.clientInfo;let i=this._supportedProtocolVersions.filter(t=>!(t>=lQ)),n=i.includes(r)?r:i[0]??aB;return this._negotiatedProtocolVersion=n,this.transport?.setProtocolVersion?.(n),{protocolVersion:n,capabilities:this.getCapabilities(),serverInfo:this._serverInfo,...this._instructions&&{instructions:this._instructions}}}_ondiscover(){return{supportedVersions:l1(this._supportedProtocolVersions),capabilities:{...this.getCapabilities()},...this._instructions&&{instructions:this._instructions}}}_outboundServerInfo(){return this._serverInfo}getClientCapabilities(){return this._clientCapabilities}getClientVersion(){return this._clientVersion}getNegotiatedProtocolVersion(){return this._negotiatedProtocolVersion}projectCallToolResult(t,r){return this._wireCodec().projectCallToolResult(t,r)}getCapabilities(){return this._capabilities}async ping(){return this._assertPushApiInServedEra("ping"),this.request({method:"ping"})}async createMessage(t,r){if(this._assertPushApiInServedEra("sampling/createMessage"),(t.tools||t.toolChoice)&&!this._clientCapabilities?.sampling?.tools)throw new lG(lW.CapabilityNotSupported,"Client does not support sampling tools capability.");if(t.messages.length>0){let r=t.messages.at(-1),i=Array.isArray(r.content)?r.content:[r.content],n=i.some(t=>"tool_result"===t.type),a=t.messages.length>1?t.messages.at(-2):void 0,o=a?Array.isArray(a.content)?a.content:[a.content]:[],s=o.some(t=>"tool_use"===t.type);if(n){if(i.some(t=>"tool_result"!==t.type))throw new c_(cv.InvalidParams,"The last message must contain only tool_result content if any is present");if(!s)throw new c_(cv.InvalidParams,"tool_result blocks are not matching any tool_use from the previous message")}if(s){let t=new Set(o.filter(t=>"tool_use"===t.type).map(t=>t.id)),r=new Set(i.filter(t=>"tool_result"===t.type).map(t=>t.toolUseId));if(t.size!==r.size||![...t].every(t=>r.has(t)))throw new c_(cv.InvalidParams,"ids of tool_result blocks and tool_use blocks from previous message do not match")}}let i=!!(t.tools||t.toolChoice),n=await this.request({method:"sampling/createMessage",params:t},r),a=this._wireCodec().samplingResultVariant(i,n);if(!a.ok)throw new lG(lW.InvalidResult,`Invalid sampling/createMessage result: ${"invalid"===a.reason?a.message:a.reason}`);return a.value}async elicitInput(t,r){switch(this._assertPushApiInServedEra("elicitation/create"),t.mode??"form"){case"url":if(!this._clientCapabilities?.elicitation?.url)throw new lG(lW.CapabilityNotSupported,"Client does not support url elicitation.");break;case"form":if(!this._clientCapabilities?.elicitation?.form)throw new lG(lW.CapabilityNotSupported,"Client does not support form elicitation.")}return this._sendElicitationLeg(t,r)}async _sendElicitationLeg(t,r,i){let n=t.mode??"form",a=i?.validateAcceptedContent??!0;switch(n){case"url":return this.request({method:"elicitation/create",params:t},r);case"form":{let i="form"===t.mode?t:{...t,mode:"form"},n=await this.request({method:"elicitation/create",params:i},r);if(a&&"accept"===n.action&&n.content&&i.requestedSchema)try{let t=this._jsonSchemaValidator.getValidator(i.requestedSchema)(n.content);if(!t.valid)throw new c_(cv.InvalidParams,`Elicitation response content does not match requested schema: ${t.errorMessage}`)}catch(t){if(t instanceof c_)throw t;throw new c_(cv.InternalError,`Error validating elicitation response: ${t instanceof Error?t.message:String(t)}`)}return n}}}createElicitationCompletionNotifier(t,r){if(!this._clientCapabilities?.elicitation?.url)throw new lG(lW.CapabilityNotSupported,"Client does not support URL elicitation (required for notifications/elicitation/complete)");return()=>this.notification({method:"notifications/elicitation/complete",params:{elicitationId:t}},r)}async listRoots(t,r){return this._assertPushApiInServedEra("roots/list"),this.request({method:"roots/list",params:t},r)}async sendLoggingMessage(t,r){if(this._capabilities.logging&&!this.isMessageIgnored(t.level,r))return this.notification({method:"notifications/message",params:t})}async sendResourceUpdated(t){return this.notification({method:"notifications/resources/updated",params:t})}async sendResourceListChanged(){return this.notification({method:"notifications/resources/list_changed"})}async sendToolListChanged(){return this.notification({method:"notifications/tools/list_changed"})}async sendPromptListChanged(){return this.notification({method:"notifications/prompts/list_changed"})}},d_=class{server;_maxToolInputElements;_registeredResources={};_registeredResourceTemplates={};_registeredTools={};_registeredPrompts={};_toolInputSchemaJson={};toolInputSchemaJson(t){let r=this._registeredTools[t];if(void 0!==r&&r.enabled){if(Object.hasOwn(this._toolInputSchemaJson,t))return this._toolInputSchemaJson[t];if(void 0===r.inputSchema)return dw;try{let i=ug(r.inputSchema,"input");return this._toolInputSchemaJson[t]=i,i}catch{return}}}constructor(t,r){this.server=new dv(t,r),this._maxToolInputElements=function(t){if(void 0!==t&&t!==1/0){if("number"!=typeof t||Number.isNaN(t)||t<1)throw RangeError(`maxToolInputElements must be a number of at least 1, or Infinity, got ${String(t)}`);return t}}(r?.maxToolInputElements),r?.capabilities?.tools&&this.setToolRequestHandlers(),r?.capabilities?.resources&&this.setResourceRequestHandlers(),r?.capabilities?.prompts&&this.setPromptRequestHandlers()}async connect(t){return"object"==typeof t&&null!==t&&"setScopeChallengeResolver"in t&&"function"==typeof t.setScopeChallengeResolver&&t.setScopeChallengeResolver(t=>this.resolveScopeChallenge(t)),await this.server.connect(t)}async close(){await this.server.close()}resolveScopeChallenge=t=>{switch(t.request.method){case"tools/call":{let r=t.request.params?.name;if("string"!=typeof r)return;let i=this._registeredTools[r];if(void 0===i||!i.enabled)return;return i.scopeChallenge?.(t)}case"resources/read":{let r,i=t.request.params?.uri;if("string"!=typeof i)return;try{r=new URL(i)}catch{return}let n=this._registeredResources[r.toString()];if(void 0!==n)return n.enabled?n.scopeChallenge?.(t):void 0;for(let i of Object.values(this._registeredResourceTemplates))if(i.resourceTemplate.uriTemplate.match(r.toString()))return i.enabled?i.scopeChallenge?.(t):void 0;return}case"prompts/get":{let r=t.request.params?.name;if("string"!=typeof r)return;let i=this._registeredPrompts[r];if(void 0===i||!i.enabled)return;return i.scopeChallenge?.(t)}default:return}};_toolHandlersInitialized=!1;setToolRequestHandlers(){this._toolHandlersInitialized||(this.server.assertCanSetRequestHandler("tools/list"),this.server.assertCanSetRequestHandler("tools/call"),this.server.registerCapabilities({tools:{listChanged:this.server.getCapabilities().tools?.listChanged??!0}}),this.server.setRequestHandler("tools/list",()=>({tools:Object.entries(this._registeredTools).filter(([,t])=>t.enabled).map(([t,r])=>{var i;let n,a,o={name:t,title:r.title,description:r.description,inputSchema:r.inputSchema?(i=t,(a=c6(n=ug(r.inputSchema,"input"))).valid||console.warn(`[mcp-sdk] tool '${i}' carries an invalid x-mcp-header declaration and will be excluded by conforming Streamable HTTP clients: ${a.reason}`),n):dw,annotations:r.annotations,icons:r.icons,execution:r.execution,_meta:r._meta};return r.outputSchema&&(o.outputSchema=ug(r.outputSchema,"output")),o})})),this.server.setRequestHandler("tools/call",async(t,r)=>{let i=this._registeredTools[t.params.name];if(!i)throw new c_(cv.InvalidParams,`Tool ${t.params.name} not found`);if(!i.enabled)throw new c_(cv.InvalidParams,`Tool ${t.params.name} disabled`);try{let n=await this.validateToolInput(i,t.params.arguments,t.params.name),a=await this.executeToolHandler(i,n,r);if(await this.validateToolOutput(i,a,t.params.name),c2(a))return a;return this.server.projectCallToolResult(a,i.outputSchemaJson)}catch(t){if(t instanceof c_&&t.code===cv.UrlElicitationRequired)throw t;return this.createToolError(t instanceof Error?t.message:String(t))}}),this._toolHandlersInitialized=!0)}createToolError(t){return{content:[{type:"text",text:t}],isError:!0}}async validateToolInput(t,r,i){if(void 0!==this._maxToolInputElements&&function(t,r){let i=0,n=[t];for(;n.length>0;){let t=n.pop();if(null!==t&&"object"==typeof t)if(Array.isArray(t))for(let a of t){if(++i>r)return i;null!==a&&"object"==typeof a&&n.push(a)}else for(let a in t){if(!Object.prototype.hasOwnProperty.call(t,a))continue;if(++i>r)return i;let o=t[a];null!==o&&"object"==typeof o&&n.push(o)}}return i}(r,this._maxToolInputElements)>this._maxToolInputElements)throw new c_(cv.InvalidParams,`Invalid arguments for tool ${i}: arguments contain more than the maximum of ${this._maxToolInputElements} elements`);if(!t.inputSchema)return;let n=await uy(t.inputSchema,r??{});if(!n.success)throw new c_(cv.InvalidParams,`Input validation error: Invalid arguments for tool ${i}: ${n.error}`);return n.data}async validateToolOutput(t,r,i){if(!t.outputSchema||c2(r)||r.isError)return;if(void 0===r.structuredContent)throw new c_(cv.InvalidParams,`Output validation error: Tool ${i} has an output schema but no structured content was provided`);let n=await uy(t.outputSchema,r.structuredContent);if(!n.success)throw new c_(cv.InvalidParams,`Output validation error: Invalid structured content for tool ${i}: ${n.error}`)}async executeToolHandler(t,r,i){return t.executor(r,i)}_completionHandlerInitialized=!1;setCompletionRequestHandler(){this._completionHandlerInitialized||(this.server.assertCanSetRequestHandler("completion/complete"),this.server.registerCapabilities({completions:{}}),this.server.setRequestHandler("completion/complete",async t=>{switch(t.params.ref.type){case"ref/prompt":if("ref/prompt"!==t.params.ref.type)throw TypeError(`Expected CompleteRequestPrompt, but got ${t.params.ref.type}`);return this.handlePromptCompletion(t,t.params.ref);case"ref/resource":if("ref/resource"!==t.params.ref.type)throw TypeError(`Expected CompleteRequestResourceTemplate, but got ${t.params.ref.type}`);return this.handleResourceCompletion(t,t.params.ref);default:throw new c_(cv.InvalidParams,`Invalid completion reference: ${t.params.ref}`)}}),this._completionHandlerInitialized=!0)}async handlePromptCompletion(t,r){let i=this._registeredPrompts[r.name];if(!i)throw new c_(cv.InvalidParams,`Prompt ${r.name} not found`);if(!i.enabled)throw new c_(cv.InvalidParams,`Prompt ${r.name} disabled`);if(!i.argsSchema)return d$;let n=dC(dT(i.argsSchema)?.[t.params.argument.name]);if(!dr(n))return d$;let a=n[dt]?.complete;return a?dx(await a(t.params.argument.value,t.params.context)):d$}async handleResourceCompletion(t,r){let i=Object.values(this._registeredResourceTemplates).find(t=>t.resourceTemplate.uriTemplate.toString()===r.uri);if(!i){if(this._registeredResources[r.uri])return d$;throw new c_(cv.InvalidParams,`Resource template ${t.params.ref.uri} not found`)}let n=i.resourceTemplate.completeCallback(t.params.argument.name);return n?dx(await n(t.params.argument.value,t.params.context)):d$}_resourceHandlersInitialized=!1;setResourceRequestHandlers(){this._resourceHandlersInitialized||(this.server.assertCanSetRequestHandler("resources/list"),this.server.assertCanSetRequestHandler("resources/templates/list"),this.server.assertCanSetRequestHandler("resources/read"),this.server.registerCapabilities({resources:{listChanged:this.server.getCapabilities().resources?.listChanged??!0}}),this.server.setRequestHandler("resources/list",async(t,r)=>{let i=Object.entries(this._registeredResources).filter(([t,r])=>r.enabled).map(([t,r])=>({uri:t,name:r.name,...r.metadata})),n=[];for(let t of Object.values(this._registeredResourceTemplates))if(t.resourceTemplate.listCallback)for(let i of(await t.resourceTemplate.listCallback(r)).resources)n.push({...t.metadata,...i});return{resources:[...i,...n]}}),this.server.setRequestHandler("resources/templates/list",async()=>({resourceTemplates:Object.entries(this._registeredResourceTemplates).map(([t,r])=>({name:t,uriTemplate:r.resourceTemplate.uriTemplate.toString(),...r.metadata}))})),this.server.setRequestHandler("resources/read",async(t,r)=>{let i;try{i=new URL(t.params.uri)}catch{throw new c_(cv.InvalidParams,`Resource URI ${t.params.uri} is invalid`,{uri:t.params.uri,reason:"invalid_uri"})}let n=this._registeredResources[i.toString()];if(n){if(!n.enabled)throw new c_(cv.InvalidParams,`Resource ${i} disabled`);return ch(await n.readCallback(i,r),n.cacheHint)}for(let t of Object.values(this._registeredResourceTemplates)){let n=t.resourceTemplate.uriTemplate.match(i.toString());if(n){if(!t.enabled)throw new c_(cv.InvalidParams,`Resource template ${t.resourceTemplate.uriTemplate} disabled`);return ch(await t.readCallback(i,n,r),t.cacheHint)}}throw new cb(t.params.uri)}),this._resourceHandlersInitialized=!0)}_promptHandlersInitialized=!1;setPromptRequestHandlers(){this._promptHandlersInitialized||(this.server.assertCanSetRequestHandler("prompts/list"),this.server.assertCanSetRequestHandler("prompts/get"),this.server.registerCapabilities({prompts:{listChanged:this.server.getCapabilities().prompts?.listChanged??!0}}),this.server.setRequestHandler("prompts/list",()=>({prompts:Object.entries(this._registeredPrompts).filter(([,t])=>t.enabled).map(([t,r])=>{let i,n,a;return{name:t,title:r.title,description:r.description,arguments:r.argsSchema?(n=(i=ug(r.argsSchema,"input")).properties||{},a=i.required||[],Object.entries(n).map(([t,r])=>({name:t,description:r?.description,required:a.includes(t)}))):void 0,icons:r.icons,_meta:r._meta}})})),this.server.setRequestHandler("prompts/get",async(t,r)=>{let i=this._registeredPrompts[t.params.name];if(!i)throw new c_(cv.InvalidParams,`Prompt ${t.params.name} not found`);if(!i.enabled)throw new c_(cv.InvalidParams,`Prompt ${t.params.name} disabled`);return i.handler(t.params.arguments,r)}),this._promptHandlersInitialized=!0)}registerResource(t,r,i,n){let{cacheHint:a,scopeChallenge:o,...s}=i;if(void 0!==a&&cy(a,`resource ${t}`),"string"==typeof r){if(this._registeredResources[r])throw Error(`Resource ${r} is already registered`);let l=this._createRegisteredResource(t,i.title,r,s,o,n);return void 0!==a&&(l.cacheHint=a),this.setResourceRequestHandlers(),this.sendResourceListChanged(),l}{if(this._registeredResourceTemplates[t])throw Error(`Resource template ${t} is already registered`);let l=this._createRegisteredResourceTemplate(t,i.title,r,s,o,n);return void 0!==a&&(l.cacheHint=a),this.setResourceRequestHandlers(),this.sendResourceListChanged(),l}}_createRegisteredResource(t,r,i,n,a,o){let s={name:t,title:r,metadata:n,readCallback:o,scopeChallenge:a,enabled:!0,disable:()=>s.update({enabled:!1}),enable:()=>s.update({enabled:!0}),remove:()=>s.update({uri:null}),update:t=>{void 0!==t.uri&&t.uri!==i&&(delete this._registeredResources[i],t.uri&&(this._registeredResources[t.uri]=s)),void 0!==t.name&&(s.name=t.name),void 0!==t.title&&(s.title=t.title),void 0!==t.metadata&&(s.metadata=t.metadata),void 0!==t.callback&&(s.readCallback=t.callback),void 0!==t.scopeChallenge&&(s.scopeChallenge=null===t.scopeChallenge?void 0:t.scopeChallenge),void 0!==t.enabled&&(s.enabled=t.enabled),this.sendResourceListChanged()}};return this._registeredResources[i]=s,s}_createRegisteredResourceTemplate(t,r,i,n,a,o){let s={resourceTemplate:i,title:r,metadata:n,readCallback:o,scopeChallenge:a,enabled:!0,disable:()=>s.update({enabled:!1}),enable:()=>s.update({enabled:!0}),remove:()=>s.update({name:null}),update:r=>{void 0!==r.name&&r.name!==t&&(delete this._registeredResourceTemplates[t],r.name&&(this._registeredResourceTemplates[r.name]=s)),void 0!==r.title&&(s.title=r.title),void 0!==r.template&&(s.resourceTemplate=r.template),void 0!==r.metadata&&(s.metadata=r.metadata),void 0!==r.callback&&(s.readCallback=r.callback),void 0!==r.scopeChallenge&&(s.scopeChallenge=null===r.scopeChallenge?void 0:r.scopeChallenge),void 0!==r.enabled&&(s.enabled=r.enabled),this.sendResourceListChanged()}};this._registeredResourceTemplates[t]=s;let l=i.uriTemplate.variableNames;return Array.isArray(l)&&l.some(t=>!!i.completeCallback(t))&&this.setCompletionRequestHandler(),s}_createRegisteredPrompt(t,r,i,n,a,o,s,l){let c=n,u=a,d={title:r,description:i,argsSchema:n,icons:o,scopeChallenge:s,_meta:l,handler:dk(t,n,a),enabled:!0,disable:()=>d.update({enabled:!1}),enable:()=>d.update({enabled:!0}),remove:()=>d.update({name:null}),update:r=>{void 0!==r.name&&r.name!==t&&(delete this._registeredPrompts[t],r.name&&(this._registeredPrompts[r.name]=d)),void 0!==r.title&&(d.title=r.title),void 0!==r.description&&(d.description=r.description),void 0!==r.icons&&(d.icons=r.icons),void 0!==r.scopeChallenge&&(d.scopeChallenge=null===r.scopeChallenge?void 0:r.scopeChallenge),void 0!==r._meta&&(d._meta=r._meta);let i=!1;void 0!==r.argsSchema&&(d.argsSchema=r.argsSchema,c=r.argsSchema,i=!0),void 0!==r.callback&&(u=r.callback,i=!0),i&&(d.handler=dk(t,c,u)),void 0!==r.enabled&&(d.enabled=r.enabled),this.sendPromptListChanged()}};if(this._registeredPrompts[t]=d,n){let t=dT(n);t&&Object.values(t).some(t=>dr(dC(t)))&&this.setCompletionRequestHandler()}return d}_createRegisteredTool(t,r,i,n,a,o,s,l,c,u,d){let p;uF(t);let m=d,h={title:r,description:i,inputSchema:n,outputSchema:a,get outputSchemaJson(){return p??=dR(h.outputSchema)},set outputSchemaJson(value){p=value},annotations:o,icons:s,execution:l,scopeChallenge:c,_meta:u,handler:d,executor:dS(n,d),enabled:!0,disable:()=>h.update({enabled:!1}),enable:()=>h.update({enabled:!0}),remove:()=>h.update({name:null}),update:r=>{void 0!==r.name&&r.name!==t&&("string"==typeof r.name&&uF(r.name),delete this._registeredTools[t],delete this._toolInputSchemaJson[t],r.name&&(delete this._toolInputSchemaJson[r.name],this._registeredTools[r.name]=h,t=r.name)),void 0!==r.title&&(h.title=r.title),void 0!==r.description&&(h.description=r.description);let i=!1;void 0!==r.paramsSchema&&(h.inputSchema=r.paramsSchema,delete this._toolInputSchemaJson[t],i=!0),void 0!==r.callback&&(h.handler=r.callback,m=r.callback,i=!0),i&&(h.executor=dS(h.inputSchema,m)),void 0!==r.outputSchema&&(h.outputSchema=r.outputSchema,h.outputSchemaJson=dR(r.outputSchema)),void 0!==r.annotations&&(h.annotations=r.annotations),void 0!==r.icons&&(h.icons=r.icons),void 0!==r.scopeChallenge&&(h.scopeChallenge=null===r.scopeChallenge?void 0:r.scopeChallenge),void 0!==r._meta&&(h._meta=r._meta),void 0!==r.enabled&&(h.enabled=r.enabled),this.sendToolListChanged()}};return this._registeredTools[t]=h,this.setToolRequestHandlers(),this.sendToolListChanged(),h}registerTool(t,r,i){if(this._registeredTools[t])throw Error(`Tool ${t} is already registered`);let{title:n,description:a,inputSchema:o,outputSchema:s,annotations:l,icons:c,scopeChallenge:u,_meta:d}=r;return this._createRegisteredTool(t,n,a,uH(o),uH(s),l,c,void 0,u,d,i)}registerPrompt(t,r,i){if(this._registeredPrompts[t])throw Error(`Prompt ${t} is already registered`);let{title:n,description:a,argsSchema:o,icons:s,scopeChallenge:l,_meta:c}=r,u=this._createRegisteredPrompt(t,n,a,uH(o),i,s,l,c);return this.setPromptRequestHandlers(),this.sendPromptListChanged(),u}isConnected(){return void 0!==this.server.transport}async sendLoggingMessage(t,r){return this.server.sendLoggingMessage(t,r)}sendResourceListChanged(){this.isConnected()&&this.server.sendResourceListChanged()}sendToolListChanged(){this.isConnected()&&this.server.sendToolListChanged()}sendPromptListChanged(){this.isConnected()&&this.server.sendPromptListChanged()}},db=class{_uriTemplate;constructor(t,r){this._callbacks=r,this._uriTemplate="string"==typeof t?new uD(t):t}get uriTemplate(){return this._uriTemplate}get listCallback(){return this._callbacks.list}completeCallback(t){return this._callbacks.complete?.[t]}};function dS(t,r){return t?async(t,i)=>r(t,i):async(t,i)=>r(i)}let dw={type:"object",properties:{}};function dR(t){if(void 0!==t)try{return ug(t,"output")}catch{return}}function dk(t,r,i){return r?async(n,a)=>{let o=await uy(r,n??{});if(!o.success)throw new c_(cv.InvalidParams,`Invalid arguments for prompt ${t}: ${o.error}`);return i(o.data,a)}:async(t,r)=>i(r)}function dx(t){return{completion:{values:t.map(String).slice(0,100),total:t.length,hasMore:t.length>100}}}let d$={completion:{values:[],hasMore:!1}};function dT(t){if(t.shape&&"object"==typeof t.shape)return t.shape}function dC(t){return t?.type!=="optional"?t:t.def?.innerType??t}var dE=class{onclose;onerror;onmessage;_classification;_responseMode;_started=!1;_used=!1;_closed=!1;_terminalDelivered=!1;_dispatchWindowOpen=!1;_requestId;_deferredResponse;_sse;_abortCleanup;_keepAliveMs;constructor(t){this._classification=t.classification,this._responseMode=t.responseMode??"auto",this._keepAliveMs=t.keepAliveMs??15e3}async start(){if(this._started)throw Error("PerRequestHTTPServerTransport is already started");this._started=!0}async handleMessage(t,r){if(this._used)throw Error("PerRequestHTTPServerTransport serves exactly one exchange; construct a new transport per request");if(!this._started||void 0===this.onmessage)throw Error("PerRequestHTTPServerTransport is not connected: connect a server to this transport before handling a message");if(this._closed)throw Error("PerRequestHTTPServerTransport is closed");this._used=!0;let i=r?.request?.signal;if(i?.aborted)throw await this.close(),new lG(lW.ConnectionClosed,"The request was aborted before it could be handled");let n={classification:this._classification,...r?.request!==void 0&&{request:r.request},...r?.authInfo!==void 0&&{authInfo:r.authInfo}};if(cX(t)){let r,a;this._requestId=t.id;let o=new Promise((t,i)=>{r=t,a=i});if(this._deferredResponse={promise:o,resolve:r,reject:a,settled:!1},void 0!==i){let t=()=>void this.close();i.addEventListener("abort",t,{once:!0}),this._abortCleanup=()=>i.removeEventListener("abort",t)}this._dispatchWindowOpen=!0;try{this.onmessage(t,n)}finally{this._dispatchWindowOpen=!1}return"sse"!==this._responseMode||this._closed||this._deferredResponse.settled||this.upgradeToSse(),o}return this.onmessage(t,n),new Response(null,{status:202})}async send(t,r){if(this._closed)return;let i=c0(t)||c1(t),n=i?t.id:r?.relatedRequestId;if(void 0===this._requestId||void 0===n||n!==this._requestId){i&&this.onerror?.(Error(`Received a response for an unknown request id: ${String(t.id)}`));return}if(i){if(this._terminalDelivered)return;this._terminalDelivered=!0;let r=c1(t)?t.error.code:void 0,i=void 0!==r&&(this._dispatchWindowOpen||r===cv.MissingRequiredClientCapability)?ua[r]:void 0;if(void 0!==i&&void 0===this._sse){this.settleResponse(Response.json(t,{status:i,headers:{"Content-Type":"application/json"}})),queueMicrotask(()=>void this.close());return}if(void 0!==this._sse||"sse"===this._responseMode){void 0===this._sse&&this.upgradeToSse(),this.writeMessageFrame(t),this.finalizeStream();return}this.settleResponse(Response.json(t,{status:200,headers:{"Content-Type":"application/json"}})),queueMicrotask(()=>void this.close());return}"json"!==this._responseMode&&(void 0===this._sse&&this.upgradeToSse(),this.writeMessageFrame(t))}writeCommentFrame(t){if(this._closed||void 0===this._sse||this._sse.closed)return;let r=t.split("\n").map(t=>`: ${t}`).join("\n");this.writeFrame(`${r}
|
|
57
|
+
- ${Object.keys(n).join("\n- ")}`)}let u=`${l}/$ref`,d=e(t,r,i,n,a,o,s,u,c);if(d.valid||ei.push({instanceLocation:s,keyword:"$ref",keywordLocation:u,error:"A subschema had errors."},...d.errors),"4"===i||"7"===i)return{valid:0===ei.length,errors:ei}}if(Array.isArray(f)){let e=f.length,r=!1;for(let i=0;i<e;i++)if(u===f[i]||"integer"===f[i]&&"number"===u&&t%1==0&&t==t){r=!0;break}r||ei.push({instanceLocation:s,keyword:"type",keywordLocation:`${l}/type`,error:`Instance type "${u}" is invalid. Expected "${f.join('", "')}".`})}else"integer"===f?("number"!==u||t%1||t!=t)&&ei.push({instanceLocation:s,keyword:"type",keywordLocation:`${l}/type`,error:`Instance type "${u}" is invalid. Expected "${f}".`}):void 0!==f&&u!==f&&ei.push({instanceLocation:s,keyword:"type",keywordLocation:`${l}/type`,error:`Instance type "${u}" is invalid. Expected "${f}".`});if(void 0!==g&&("object"===u||"array"===u?uJ(t,g)||ei.push({instanceLocation:s,keyword:"const",keywordLocation:`${l}/const`,error:`Instance does not match ${JSON.stringify(g)}.`}):t!==g&&ei.push({instanceLocation:s,keyword:"const",keywordLocation:`${l}/const`,error:`Instance does not match ${JSON.stringify(g)}.`})),void 0!==y&&("object"===u||"array"===u?y.some(e=>uJ(t,e))||ei.push({instanceLocation:s,keyword:"enum",keywordLocation:`${l}/enum`,error:`Instance does not match any of ${JSON.stringify(y)}.`}):y.some(e=>t===e)||ei.push({instanceLocation:s,keyword:"enum",keywordLocation:`${l}/enum`,error:`Instance does not match any of ${JSON.stringify(y)}.`})),void 0!==_){let r=`${l}/not`;e(t,_,i,n,a,o,s,r).valid&&ei.push({instanceLocation:s,keyword:"not",keywordLocation:r,error:'Instance matched "not" schema.'})}let en=[];if(void 0!==b){let r=`${l}/anyOf`,u=ei.length,d=!1;for(let l=0;l<b.length;l++){let u=b[l],p=Object.create(c),m=e(t,u,i,n,a,!0===h?o:null,s,`${r}/${l}`,p);ei.push(...m.errors),d=d||m.valid,m.valid&&en.push(p)}d?ei.length=u:ei.splice(u,0,{instanceLocation:s,keyword:"anyOf",keywordLocation:r,error:"Instance does not match any subschemas."})}if(void 0!==S){let r=`${l}/allOf`,u=ei.length,d=!0;for(let l=0;l<S.length;l++){let u=S[l],p=Object.create(c),m=e(t,u,i,n,a,!0===h?o:null,s,`${r}/${l}`,p);ei.push(...m.errors),d=d&&m.valid,m.valid&&en.push(p)}d?ei.length=u:ei.splice(u,0,{instanceLocation:s,keyword:"allOf",keywordLocation:r,error:"Instance does not match every subschema."})}if(void 0!==w){let r=`${l}/oneOf`,u=ei.length,d=w.filter((l,u)=>{let d=Object.create(c),p=e(t,l,i,n,a,!0===h?o:null,s,`${r}/${u}`,d);return ei.push(...p.errors),p.valid&&en.push(d),p.valid}).length;1===d?ei.length=u:ei.splice(u,0,{instanceLocation:s,keyword:"oneOf",keywordLocation:r,error:`Instance does not match exactly one subschema (${d} matches).`})}if(("object"===u||"array"===u)&&Object.assign(c,...en),void 0!==R){let r=`${l}/if`;if(e(t,R,i,n,a,o,s,r,c).valid){if(void 0!==k){let u=e(t,k,i,n,a,o,s,`${l}/then`,c);u.valid||ei.push({instanceLocation:s,keyword:"if",keywordLocation:r,error:'Instance does not match "then" schema.'},...u.errors)}}else if(void 0!==x){let u=e(t,x,i,n,a,o,s,`${l}/else`,c);u.valid||ei.push({instanceLocation:s,keyword:"if",keywordLocation:r,error:'Instance does not match "else" schema.'},...u.errors)}}if("object"===u){if(void 0!==v)for(let e of v)e in t||ei.push({instanceLocation:s,keyword:"required",keywordLocation:`${l}/required`,error:`Instance does not have required property "${e}".`});let r=Object.keys(t);if(void 0!==E&&r.length<E&&ei.push({instanceLocation:s,keyword:"minProperties",keywordLocation:`${l}/minProperties`,error:`Instance does not have at least ${E} properties.`}),void 0!==I&&r.length>I&&ei.push({instanceLocation:s,keyword:"maxProperties",keywordLocation:`${l}/maxProperties`,error:`Instance does not have at least ${I} properties.`}),void 0!==q){let r=`${l}/propertyNames`;for(let l in t){let t=`${s}/${uV(l)}`,c=e(l,q,i,n,a,o,t,r);c.valid||ei.push({instanceLocation:s,keyword:"propertyNames",keywordLocation:r,error:`Property name "${l}" does not match schema.`},...c.errors)}}if(void 0!==j){let e=`${l}/dependantRequired`;for(let r in j)if(r in t)for(let i of j[r])i in t||ei.push({instanceLocation:s,keyword:"dependentRequired",keywordLocation:e,error:`Instance has "${r}" but does not have "${i}".`})}if(void 0!==z)for(let r in z){let u=`${l}/dependentSchemas`;if(r in t){let l=e(t,z[r],i,n,a,o,s,`${u}/${uV(r)}`,c);l.valid||ei.push({instanceLocation:s,keyword:"dependentSchemas",keywordLocation:u,error:`Instance has "${r}" but does not match dependant schema.`},...l.errors)}}if(void 0!==A){let r=`${l}/dependencies`;for(let l in A)if(l in t){let c=A[l];if(Array.isArray(c))for(let e of c)e in t||ei.push({instanceLocation:s,keyword:"dependencies",keywordLocation:r,error:`Instance has "${l}" but does not have "${e}".`});else{let u=e(t,c,i,n,a,o,s,`${r}/${uV(l)}`);u.valid||ei.push({instanceLocation:s,keyword:"dependencies",keywordLocation:r,error:`Instance has "${l}" but does not match dependant schema.`},...u.errors)}}}let u=Object.create(null),d=!1;if(void 0!==T){let r=`${l}/properties`;for(let l in T){if(!(l in t))continue;let p=`${s}/${uV(l)}`,m=e(t[l],T[l],i,n,a,o,p,`${r}/${uV(l)}`);if(m.valid)c[l]=u[l]=!0;else if(d=a,ei.push({instanceLocation:s,keyword:"properties",keywordLocation:r,error:`Property "${l}" does not match schema.`},...m.errors),d)break}}if(!d&&void 0!==C){let r=`${l}/patternProperties`;for(let l in C){let p=RegExp(l,"u"),m=C[l];for(let h in t){if(!p.test(h))continue;let f=`${s}/${uV(h)}`,g=e(t[h],m,i,n,a,o,f,`${r}/${uV(l)}`);g.valid?c[h]=u[h]=!0:(d=a,ei.push({instanceLocation:s,keyword:"patternProperties",keywordLocation:r,error:`Property "${h}" matches pattern "${l}" but does not match associated schema.`},...g.errors))}}}if(d||void 0===P){if(!d&&void 0!==O){let r=`${l}/unevaluatedProperties`;for(let l in t)if(!c[l]){let u=`${s}/${uV(l)}`,d=e(t[l],O,i,n,a,o,u,r);d.valid?c[l]=!0:ei.push({instanceLocation:s,keyword:"unevaluatedProperties",keywordLocation:r,error:`Property "${l}" does not match unevaluated properties schema.`},...d.errors)}}}else{let r=`${l}/additionalProperties`;for(let l in t){if(u[l])continue;let p=`${s}/${uV(l)}`,m=e(t[l],P,i,n,a,o,p,r);m.valid?c[l]=!0:(d=a,ei.push({instanceLocation:s,keyword:"additionalProperties",keywordLocation:r,error:`Property "${l}" does not match additional properties schema.`},...m.errors))}}}else if("array"===u){void 0!==J&&t.length>J&&ei.push({instanceLocation:s,keyword:"maxItems",keywordLocation:`${l}/maxItems`,error:`Array has too many items (${t.length} > ${J}).`}),void 0!==H&&t.length<H&&ei.push({instanceLocation:s,keyword:"minItems",keywordLocation:`${l}/minItems`,error:`Array has too few items (${t.length} < ${H}).`});let r=t.length,u=0,d=!1;if(void 0!==N){let p=`${l}/prefixItems`,m=Math.min(N.length,r);for(;u<m;u++){let r=e(t[u],N[u],i,n,a,o,`${s}/${u}`,`${p}/${u}`);if(c[u]=!0,!r.valid&&(d=a,ei.push({instanceLocation:s,keyword:"prefixItems",keywordLocation:p,error:"Items did not match schema."},...r.errors),d))break}}if(void 0!==M){let p=`${l}/items`;if(Array.isArray(M)){let l=Math.min(M.length,r);for(;u<l;u++){let r=e(t[u],M[u],i,n,a,o,`${s}/${u}`,`${p}/${u}`);if(c[u]=!0,!r.valid&&(d=a,ei.push({instanceLocation:s,keyword:"items",keywordLocation:p,error:"Items did not match schema."},...r.errors),d))break}}else for(;u<r;u++){let r=e(t[u],M,i,n,a,o,`${s}/${u}`,p);if(c[u]=!0,!r.valid&&(d=a,ei.push({instanceLocation:s,keyword:"items",keywordLocation:p,error:"Items did not match schema."},...r.errors),d))break}if(!d&&void 0!==L){let p=`${l}/additionalItems`;for(;u<r;u++){let r=e(t[u],L,i,n,a,o,`${s}/${u}`,p);c[u]=!0,r.valid||(d=a,ei.push({instanceLocation:s,keyword:"additionalItems",keywordLocation:p,error:"Items did not match additional items schema."},...r.errors))}}}if(void 0!==U)if(0===r&&void 0===F)ei.push({instanceLocation:s,keyword:"contains",keywordLocation:`${l}/contains`,error:"Array is empty. It must contain at least one item matching the schema."});else if(void 0!==F&&r<F)ei.push({instanceLocation:s,keyword:"minContains",keywordLocation:`${l}/minContains`,error:`Array has less items (${r}) than minContains (${F}).`});else{let u=`${l}/contains`,d=ei.length,p=0;for(let l=0;l<r;l++){let r=e(t[l],U,i,n,a,o,`${s}/${l}`,u);r.valid?(c[l]=!0,p++):ei.push(...r.errors)}p>=(F||0)&&(ei.length=d),void 0===F&&void 0===D&&0===p?ei.splice(d,0,{instanceLocation:s,keyword:"contains",keywordLocation:u,error:"Array does not contain item matching schema."}):void 0!==F&&p<F?ei.push({instanceLocation:s,keyword:"minContains",keywordLocation:`${l}/minContains`,error:`Array must contain at least ${F} items matching schema. Only ${p} items were found.`}):void 0!==D&&p>D&&ei.push({instanceLocation:s,keyword:"maxContains",keywordLocation:`${l}/maxContains`,error:`Array may contain at most ${D} items matching schema. ${p} items were found.`})}if(!d&&void 0!==Z){let d=`${l}/unevaluatedItems`;for(;u<r;u++){if(c[u])continue;let r=e(t[u],Z,i,n,a,o,`${s}/${u}`,d);c[u]=!0,r.valid||ei.push({instanceLocation:s,keyword:"unevaluatedItems",keywordLocation:d,error:"Items did not match unevaluated items schema."},...r.errors)}}if(V)for(let e=0;e<r;e++){let i=t[e],n="object"==typeof i&&null!==i;for(let a=0;a<r;a++){if(e===a)continue;let r=t[a];(i===r||n&&"object"==typeof r&&null!==r&&uJ(i,r))&&(ei.push({instanceLocation:s,keyword:"uniqueItems",keywordLocation:`${l}/uniqueItems`,error:`Duplicate items at indexes ${e} and ${a}.`}),e=Number.MAX_SAFE_INTEGER,a=Number.MAX_SAFE_INTEGER)}}}else if("number"===u){if("4"===i?(void 0!==B&&(!0===G&&t<=B||t<B)&&ei.push({instanceLocation:s,keyword:"minimum",keywordLocation:`${l}/minimum`,error:`${t} is less than ${G?"or equal to ":""} ${B}.`}),void 0!==W&&(!0===K&&t>=W||t>W)&&ei.push({instanceLocation:s,keyword:"maximum",keywordLocation:`${l}/maximum`,error:`${t} is greater than ${K?"or equal to ":""} ${W}.`})):(void 0!==B&&t<B&&ei.push({instanceLocation:s,keyword:"minimum",keywordLocation:`${l}/minimum`,error:`${t} is less than ${B}.`}),void 0!==W&&t>W&&ei.push({instanceLocation:s,keyword:"maximum",keywordLocation:`${l}/maximum`,error:`${t} is greater than ${W}.`}),void 0!==G&&t<=G&&ei.push({instanceLocation:s,keyword:"exclusiveMinimum",keywordLocation:`${l}/exclusiveMinimum`,error:`${t} is less than ${G}.`}),void 0!==K&&t>=K&&ei.push({instanceLocation:s,keyword:"exclusiveMaximum",keywordLocation:`${l}/exclusiveMaximum`,error:`${t} is greater than or equal to ${K}.`})),void 0!==Y){let e=t%Y;Math.abs(0-e)>=11920929e-14&&Math.abs(Y-e)>=11920929e-14&&ei.push({instanceLocation:s,keyword:"multipleOf",keywordLocation:`${l}/multipleOf`,error:`${t} is not a multiple of ${Y}.`})}}else if("string"===u){let e=void 0===X&&void 0===Q?0:function(e){let t,r=0,i=e.length,n=0;for(;n<i;)r++,(t=e.charCodeAt(n++))>=55296&&t<=56319&&n<i&&(64512&(t=e.charCodeAt(n)))==56320&&n++;return r}(t);void 0!==X&&e<X&&ei.push({instanceLocation:s,keyword:"minLength",keywordLocation:`${l}/minLength`,error:`String is too short (${e} < ${X}).`}),void 0!==Q&&e>Q&&ei.push({instanceLocation:s,keyword:"maxLength",keywordLocation:`${l}/maxLength`,error:`String is too long (${e} > ${Q}).`}),void 0===ee||RegExp(ee,"u").test(t)||ei.push({instanceLocation:s,keyword:"pattern",keywordLocation:`${l}/pattern`,error:"String does not match pattern."}),void 0!==$&&u2[$]&&!u2[$](t)&&ei.push({instanceLocation:s,keyword:"format",keywordLocation:`${l}/format`,error:`String does not match format "${$}".`})}return{valid:0===ei.length,errors:ei}}(e,this.schema,this.draft,this.lookup,this.shortCircuit)}addSchema(e,t){t&&(e={...e,$id:t}),uY(e,this.lookup)}},de=class{shortcircuit;draft;constructor(e){this.shortcircuit=e?.shortcircuit??!0,this.draft=e?.draft}_draftFor(e){let t=function(e,t){if(!("$schema"in e)||"string"!=typeof e.$schema)return"2020-12";let r=e.$schema.replace(/#$/,"");if(K.has(r))return"2020-12";if(Y.has(r))return"2019-09";if(X.has(r)||Q.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}`)}(e,"pass an explicit { draft } to CfWorkerJsonSchemaValidator to validate other dialects.");return"draft-7"===t?"7":t}getValidator(e){let t=new u8(e,this.draft??this._draftFor(e),this.shortcircuit);return e=>{let r=t.validate(e);return r.valid?{valid:!0,data:e,errorMessage:void 0}:{valid:!1,data:void 0,errorMessage:r.errors.map(e=>`${e.instanceLocation}: ${e.error}`).join("; ")}}}};l4(),cu(),cr(),cx(),cN();let dt=Symbol.for("mcp.completable");function dr(e){return!!e&&"object"==typeof e&&dt in e}function di(e,t){if(!Number.isFinite(e)||e<1)return;let r=setInterval(t,Math.min(e,0x7fffffff));return r.unref?.(),r}var dn=class{static{l=e=>e._classification}onclose;onerror;onmessage;_classification;_responseMode;_started=!1;_used=!1;_closed=!1;_terminalDelivered=!1;_dispatchWindowOpen=!1;_requestId;_deferredResponse;_sse;_abortCleanup;_keepAliveMs;constructor(e){this._classification=e.classification,this._responseMode=e.responseMode??"auto",this._keepAliveMs=e.keepAliveMs??15e3}async start(){if(this._started)throw Error("PerRequestHTTPServerTransport is already started");this._started=!0}async handleMessage(e,t){if(this._used)throw Error("PerRequestHTTPServerTransport serves exactly one exchange; construct a new transport per request");if(!this._started||void 0===this.onmessage)throw Error("PerRequestHTTPServerTransport is not connected: connect a server to this transport before handling a message");if(this._closed)throw Error("PerRequestHTTPServerTransport is closed");this._used=!0;let r=t?.request?.signal;if(r?.aborted)throw await this.close(),new lW(lB.ConnectionClosed,"The request was aborted before it could be handled");let i={classification:this._classification,...t?.request!==void 0&&{request:t.request},...t?.authInfo!==void 0&&{authInfo:t.authInfo}};if(cY(e)){let t,n;this._requestId=e.id;let a=new Promise((e,r)=>{t=e,n=r});if(this._deferredResponse={promise:a,resolve:t,reject:n,settled:!1},void 0!==r){let e=()=>void this.close();r.addEventListener("abort",e,{once:!0}),this._abortCleanup=()=>r.removeEventListener("abort",e)}this._dispatchWindowOpen=!0;try{this.onmessage(e,i)}finally{this._dispatchWindowOpen=!1}return"sse"!==this._responseMode||this._closed||this._deferredResponse.settled||this.upgradeToSse(),a}return this.onmessage(e,i),new Response(null,{status:202})}async send(e,t){if(this._closed)return;let r=cQ(e)||c0(e),i=r?e.id:t?.relatedRequestId;if(void 0===this._requestId||void 0===i||i!==this._requestId){r&&this.onerror?.(Error(`Received a response for an unknown request id: ${String(e.id)}`));return}if(r){if(this._terminalDelivered)return;this._terminalDelivered=!0;let t=c0(e)?e.error.code:void 0,r=void 0!==t&&(this._dispatchWindowOpen||t===cy.MissingRequiredClientCapability)?un[t]:void 0;if(void 0!==r&&void 0===this._sse){this.settleResponse(Response.json(e,{status:r,headers:{"Content-Type":"application/json"}})),queueMicrotask(()=>void this.close());return}if(void 0!==this._sse||"sse"===this._responseMode){void 0===this._sse&&this.upgradeToSse(),this.writeMessageFrame(e),this.finalizeStream();return}this.settleResponse(Response.json(e,{status:200,headers:{"Content-Type":"application/json"}})),queueMicrotask(()=>void this.close());return}"json"!==this._responseMode&&(void 0===this._sse&&this.upgradeToSse(),this.writeMessageFrame(e))}writeCommentFrame(e){if(this._closed||void 0===this._sse||this._sse.closed)return;let t=e.split("\n").map(e=>`: ${e}`).join("\n");this.writeFrame(`${t}
|
|
58
58
|
|
|
59
|
-
`)}async close(){if(!this._closed){if(this._closed=!0,this._abortCleanup?.(),this._abortCleanup=void 0,this._sse?.keepAliveTimer!==void 0&&clearInterval(this._sse.keepAliveTimer),void 0!==this._sse&&!this._sse.closed){this._sse.closed=!0;try{this._sse.controller.close()}catch{}}void 0===this._deferredResponse||this._deferredResponse.settled||(this._deferredResponse.settled=!0,this._deferredResponse.reject(new
|
|
60
|
-
data: ${JSON.stringify(
|
|
59
|
+
`)}async close(){if(!this._closed){if(this._closed=!0,this._abortCleanup?.(),this._abortCleanup=void 0,this._sse?.keepAliveTimer!==void 0&&clearInterval(this._sse.keepAliveTimer),void 0!==this._sse&&!this._sse.closed){this._sse.closed=!0;try{this._sse.controller.close()}catch{}}void 0===this._deferredResponse||this._deferredResponse.settled||(this._deferredResponse.settled=!0,this._deferredResponse.reject(new lW(lB.ConnectionClosed,"Connection closed before a response was produced"))),this.onclose?.()}}settleResponse(e){void 0===this._deferredResponse||this._deferredResponse.settled||(this._deferredResponse.settled=!0,this._deferredResponse.resolve(e))}upgradeToSse(){let e,t=new ReadableStream({start:t=>{e=t},cancel:()=>{this.close()}});this._sse={controller:e,encoder:new TextEncoder,closed:!1},this._sse.keepAliveTimer=di(this._keepAliveMs,()=>this.writeCommentFrame("keepalive")),this.settleResponse(new Response(t,{status:200,headers:{"Content-Type":"text/event-stream","Cache-Control":"no-cache, no-transform",Connection:"keep-alive","X-Accel-Buffering":"no"}}))}finalizeStream(){if(this._sse?.keepAliveTimer!==void 0&&clearInterval(this._sse.keepAliveTimer),void 0!==this._sse&&!this._sse.closed){this._sse.closed=!0;try{this._sse.controller.close()}catch{}}queueMicrotask(()=>void this.close())}writeMessageFrame(e){this.writeFrame(`event: message
|
|
60
|
+
data: ${JSON.stringify(e)}
|
|
61
61
|
|
|
62
|
-
`)}writeFrame(t){if(void 0!==this._sse&&!this._sse.closed)try{this._sse.controller.enqueue(this._sse.encoder.encode(t))}catch(t){this.onerror?.(Error(`Failed to write to the response stream: ${t}`))}}};async function dP(t,r,i){let n=new dE({classification:i.classification,...void 0!==i.responseMode&&{responseMode:i.responseMode},...void 0!==i.keepAliveMs&&{keepAliveMs:i.keepAliveMs}});return await t.connect(n),n.handleMessage(r,{...void 0!==i.request&&{request:i.request},...void 0!==i.authInfo&&{authInfo:i.authInfo}})}function dO(t){return`Payload Too Large: Request body must not exceed ${t} bytes`}function dI(t){if(void 0===t)return 4194304;if("number"!=typeof t||!Number.isFinite(t)||t<=0)throw RangeError(`maxRequestBodySize must be a positive number of bytes, got ${String(t)}`);return t}async function dq(t,r=4194304){if(Number(t.headers.get("content-length"))>r)return{tooLarge:!0};if(null===t.body)return{tooLarge:!1,text:""};let i=t.body.getReader(),n=new TextDecoder,a=0,o="";try{for(;;){let{done:t,value:s}=await i.read();if(t)break;if((a+=s.byteLength)>r)return{tooLarge:!0};o+=n.decode(s,{stream:!0})}}finally{i.releaseLock()}return{tooLarge:!1,text:o+n.decode()}}var dj=class{sessionIdGenerator;_started=!1;_hasHandledRequest=!1;_closed=!1;_streamMapping=new Map;_requestToStreamMapping=new Map;_requestResponseMap=new Map;_initialized=!1;_enableJsonResponse=!1;_standaloneSseStreamId="_GET_stream";_eventStore;_onsessioninitialized;_onsessionclosed;_allowedHosts;_allowedOrigins;_enableDnsRebindingProtection;_retryInterval;_supportedProtocolVersions;_keepAliveMs;_maxRequestBodySize;_scopeChallengeResolver;sessionId;onclose;onerror;onmessage;constructor(t={}){this.sessionIdGenerator=t.sessionIdGenerator,this._enableJsonResponse=t.enableJsonResponse??!1,this._eventStore=t.eventStore,this._onsessioninitialized=t.onsessioninitialized,this._onsessionclosed=t.onsessionclosed,this._allowedHosts=t.allowedHosts,this._allowedOrigins=t.allowedOrigins,this._enableDnsRebindingProtection=t.enableDnsRebindingProtection??!1,this._retryInterval=t.retryInterval,this._supportedProtocolVersions=t.supportedProtocolVersions??aW,this._keepAliveMs=t.keepAliveMs??15e3,this._maxRequestBodySize=dI(t.maxRequestBodySize)}startKeepAlive(t,r){if(this._closed)return;let i=dn(this._keepAliveMs,()=>{try{t.enqueue(r.encode(": keepalive\n\n"))}catch{void 0!==i&&clearInterval(i)}});return i}setScopeChallengeResolver(t){this._scopeChallengeResolver=t}async start(){if(this._started)throw Error("Transport already started");this._started=!0}setSupportedProtocolVersions(t){this._supportedProtocolVersions=t}createJsonErrorResponse(t,r,i,n){let a={code:r,message:i};return n?.data!==void 0&&(a.data=n.data),Response.json({jsonrpc:"2.0",error:a,id:null},{status:t,headers:{"Content-Type":"application/json",...n?.headers}})}async _checkScopeChallenge(t,r){if(!this._scopeChallengeResolver)return;let i=await dd(t.filter(t=>cX(t)),r,this._scopeChallengeResolver);return void 0===i?void 0:dm(i,dp(r))}validateRequestHeaders(t){if(this._enableDnsRebindingProtection){if(this._allowedHosts&&this._allowedHosts.length>0){let r=t.headers.get("host");if(!r||!this._allowedHosts.includes(r)){let t=`Invalid Host header: ${r}`;return this.onerror?.(Error(t)),this.createJsonErrorResponse(403,-32e3,t)}}if(this._allowedOrigins&&this._allowedOrigins.length>0){let r=t.headers.get("origin");if(r&&!this._allowedOrigins.includes(r)){let t=`Invalid Origin header: ${r}`;return this.onerror?.(Error(t)),this.createJsonErrorResponse(403,-32e3,t)}}}}async handleRequest(t,r){if(this._closed)return this.createJsonErrorResponse(404,-32001,"Session not found");if(!this.sessionIdGenerator&&this._hasHandledRequest)throw Error("Stateless transport cannot be reused across requests. Create a new transport per request.");this._hasHandledRequest=!0;let i=this.validateRequestHeaders(t);if(i)return i;switch(t.method){case"POST":return this.handlePostRequest(t,r);case"GET":return this.handleGetRequest(t);case"DELETE":return this.handleDeleteRequest(t);default:return this.handleUnsupportedRequest()}}supportsEmptySSEData(t){return this._supportedProtocolVersions.includes(t)&&t>="2025-11-25"}async writePrimingEvent(t,r,i,n){if(!this._eventStore||!this.supportsEmptySSEData(n))return;let a=await this._eventStore.storeEvent(i,{}),o=`id: ${a}
|
|
62
|
+
`)}writeFrame(e){if(void 0!==this._sse&&!this._sse.closed)try{this._sse.controller.enqueue(this._sse.encoder.encode(e))}catch(e){this.onerror?.(Error(`Failed to write to the response stream: ${e}`))}}};function da(e){return e.replaceAll(/[\\"]/g,String.raw`\$&`).replaceAll(/[^\u0020-\u007E]/g," ")}function ds(e,t,r,i){let n=`Bearer error="${da(e)}", error_description="${da(t)}"`;return r.length>0&&(n+=`, scope="${da(r.join(" "))}"`),i&&(n+=`, resource_metadata="${da(i)}"`),n}async function dl(e,t,r){for(let n of e){let e=await r({request:n,...void 0!==t&&{authInfo:t}});if(void 0!==e){if(null===e||"object"!=typeof e||!Array.isArray(e.scopes)||0===e.scopes.length)throw TypeError("scope challenge must contain at least one scope");for(let[t,r]of e.scopes.entries()){var i=`scope challenge scopes[${t}]`;if("string"!=typeof r||!/^[\u0021\u0023-\u005B\u005D-\u007E]+$/.test(r))throw TypeError(`${i} must satisfy the OAuth scope-token grammar`)}if(void 0!==e.errorDescription&&"string"!=typeof e.errorDescription)throw TypeError("scope challenge errorDescription must be a string");if(void 0!==e.errorDescription&&!/^[\u0020-\u0021\u0023-\u005B\u005D-\u007E]+$/.test(e.errorDescription))throw TypeError("scope challenge errorDescription must satisfy the RFC 6750 error-description grammar");return e}}}function dc(e){if(e?.resourceMetadataUrl!==void 0)return e.resourceMetadataUrl;if(e?.resource?.protocol==="https:"||e?.resource?.protocol==="http:"){var t,r;let i,n;return i=new URL(t=e.resource),n=(r=t.pathname).length>1&&r.endsWith("/")?r.slice(0,-1):r,i.pathname=`/.well-known/oauth-protected-resource${"/"===n?"":n}`,i.hash="",i.href}}function du(e,t){return function(e,t){let{requiredScopes:r=[],resourceMetadataUrl:i}=t??{};if(!(e instanceof lV)){let e=new lV(lJ.ServerError,"Internal Server Error");return Response.json(e.toResponseObject(),{status:500})}switch(e.code){case lJ.InvalidToken:{let t=ds(e.code,e.message,r,i);return Response.json(e.toResponseObject(),{status:401,headers:{"WWW-Authenticate":t}})}case lJ.InsufficientScope:{let t=ds(e.code,e.message,r,i);return Response.json(e.toResponseObject(),{status:403,headers:{"WWW-Authenticate":t}})}case lJ.ServerError:return Response.json(e.toResponseObject(),{status:500});default:return Response.json(e.toResponseObject(),{status:400})}}(new lV(lJ.InsufficientScope,e.errorDescription??"Insufficient scope"),{requiredScopes:[...e.scopes],resourceMetadataUrl:t})}function dd(e,t,r){if(null===r||"object"!=typeof r||"string"!=typeof r.method)throw new cv(cy.InternalError,`Handler for ${e} returned an invalid input request '${t}': each inputRequests entry must be an embedded elicitation/create, sampling/createMessage, or roots/list request`);let i=function(e){switch(e.method){case"elicitation/create":if(e.params?.mode==="url")return{elicitation:{url:{}}};return{elicitation:{form:{}}};case"sampling/createMessage":{let t=e.params;if(void 0!==t&&(void 0!==t.tools||void 0!==t.toolChoice))return{sampling:{tools:{}}};return{sampling:{}}}case"roots/list":return{roots:{}};default:return}}(r);if(void 0===i)throw new cv(cy.InternalError,`Handler for ${e} returned an input request '${t}' of kind '${r.method}', which is not an embedded request the 2026-07-28 revision defines`);return{embedded:r,required:i}}function dp(e,t){if("tools/call"===e)return{content:[{type:"text",text:t}],isError:!0};throw new cv(cy.InternalError,t)}var dm=class{constructor(e){this._host=e}async fulfill(e,t,r,i,n){let{maxRounds:a,roundTimeoutMs:o}=this._host,s=i.mcpReq.signal,l=n,c=0;for(;;){let n;if((c+=1)>a)return dp(e,`Multi-round-trip request '${e}' still required input after ${a} rounds (inputRequired.maxRounds)`);let u=l.inputRequests,d=null!=u&&Object.keys(u).length>0,p="string"==typeof l.requestState?l.requestState:void 0;if(!d&&void 0===p)throw new cv(cy.InternalError,`Handler for ${e} returned an input-required result with neither inputRequests nor requestState (every InputRequiredResult must include at least one of the two)`);if(d){let t=this._host.resolvedClientCapabilities(i),r=[];for(let[i,n]of Object.entries(u)){let{embedded:a,required:o}=dd(e,i,n);if("roots/list"!==a.method&&void 0===a.params)throw new cv(cy.InternalError,`Handler for ${e} returned an input request '${i}' of kind '${a.method}' without params`);if(void 0!==lY(o,t))return dp(e,`Cannot request input '${i}' (${a.method}): the client on this 2025-era connection did not declare the required capability${void 0===t?" (no client capabilities are available on this connection — per-request legacy serving cannot receive server-to-client requests)":""}`);r.push([i,a])}let a=function(e){let t=new AbortController,r=()=>t.abort(e?.reason);return e?.addEventListener("abort",r,{once:!0}),e?.aborted&&t.abort(e.reason),{signal:t.signal,abort:e=>t.abort(e),dispose:()=>e?.removeEventListener("abort",r)}}(s);try{let e={relatedRequestId:i.mcpReq.id,timeout:o,resetTimeoutOnProgress:!0,onprogress:()=>{},signal:a.signal},t=await Promise.all(r.map(async([t,r])=>{try{return[t,await this._dispatchLeg(r,e)]}catch(e){throw a.abort(e),e}}));n=Object.fromEntries(t)}catch(t){if(s.aborted)throw t;return dp(e,`Fulfilling input required by '${e}' failed: ${t instanceof Error?t.message:String(t)}`)}finally{a.dispose()}}else await function(e){return new Promise((t,r)=>{if(e?.aborted)return void r(e.reason instanceof lW?e.reason:new lW(lB.RequestTimeout,String(e.reason)));let i=setTimeout(()=>{e?.removeEventListener("abort",n),t()},250),n=()=>{clearTimeout(i),r(e?.reason instanceof lW?e.reason:new lW(lB.RequestTimeout,String(e?.reason)))};e?.addEventListener("abort",n,{once:!0})})}(s);let m={...i,mcpReq:{...i.mcpReq,inputResponses:n,droppedInputResponseKeys:void 0,requestState:function(e){return()=>e}(p)}};if(void 0!==p){let t=await this._host.verifyRequestState(p,m,e);void 0!==t&&(m=uj(m,t))}let h=await t(r,m);if(!c1(h))return h;l=h}}async _dispatchLeg(e,t){switch(e.method){case"elicitation/create":{let r=e.params;return"url"===r.mode&&void 0===r.elicitationId&&(r={...r,elicitationId:function(){let e=globalThis.crypto;if(e?.randomUUID!==void 0)return e.randomUUID();let t=new Uint8Array(16);e.getRandomValues(t),t[6]=15&t[6]|64,t[8]=63&t[8]|128;let r=[...t].map(e=>e.toString(16).padStart(2,"0")).join("");return`${r.slice(0,8)}-${r.slice(8,12)}-${r.slice(12,16)}-${r.slice(16,20)}-${r.slice(20)}`}()}),await this._host.sendElicitation(r,t)}case"sampling/createMessage":return await this._host.sendSampling(e.params,t);case"roots/list":return await this._host.listRoots(e.params,t)}}};let dh=new Set(["tools/call","prompts/get","resources/read"]);var df=class extends uz{_clientCapabilities;_clientVersion;static{c=(e,t)=>{void 0!==t.clientCapabilities&&(e._clientCapabilities=t.clientCapabilities),void 0!==t.clientInfo&&(e._clientVersion=t.clientInfo)},u=(e,t)=>{let r=t.filter(t=>!e._supportedProtocolVersions.includes(t));r.length>0&&(e._supportedProtocolVersions=[...e._supportedProtocolVersions,...r]),e.setRequestHandler("server/discover",()=>e._ondiscover())},d=e=>e._serverInfo}_capabilities;_instructions;_jsonSchemaValidator;_cacheHints;_requestStateVerify;_inputRequiredServing;_legacyShim;_boundFromTransport=!1;_legacyInputRequiredShim(){return this._legacyShim??=new dm({maxRounds:this._inputRequiredServing.maxRounds,roundTimeoutMs:this._inputRequiredServing.roundTimeoutMs,resolvedClientCapabilities:e=>this._inputRequestCapabilityView(e),verifyRequestState:(e,t,r)=>this._verifyRequestState(e,t,r),sendElicitation:(e,t)=>this._sendElicitationLeg(e,t,{validateAcceptedContent:!1}),sendSampling:(e,t)=>this.createMessage(e,t),listRoots:(e,t)=>this.listRoots(e,t)})}oninitialized;constructor(e,t){if(super(t),this._serverInfo=e,this._capabilities=t?.capabilities?{...t.capabilities}:{},this._instructions=t?.instructions,this._jsonSchemaValidator=t?.jsonSchemaValidator??new de,this._requestStateVerify=t?.requestState?.verify,this._inputRequiredServing=function(e){if(e?.maxRounds!==void 0&&(!Number.isInteger(e.maxRounds)||e.maxRounds<1))throw RangeError(`inputRequired.maxRounds must be a positive integer (got ${e.maxRounds})`);if(e?.roundTimeoutMs!==void 0&&(!Number.isFinite(e.roundTimeoutMs)||e.roundTimeoutMs<=0))throw RangeError(`inputRequired.roundTimeoutMs must be a positive number (got ${e.roundTimeoutMs})`);return{maxRounds:e?.maxRounds??8,roundTimeoutMs:e?.roundTimeoutMs??6e5,legacyShim:e?.legacyShim??!0}}(t?.inputRequired),t?.cacheHints!==void 0){for(let[e,r]of Object.entries(t.cacheHints))void 0!==r&&cg(r,`cacheHints['${e}']`);this._cacheHints=t.cacheHints}this.setRequestHandler("initialize",e=>this._oninitialize(e)),this.setNotificationHandler("notifications/initialized",()=>this.oninitialized?.()),l0(this._supportedProtocolVersions).length>0&&this.setRequestHandler("server/discover",()=>this._ondiscover()),this._capabilities.logging&&this._registerLoggingHandler()}async connect(e){if(void 0!==this.transport)throw new lW(lB.AlreadyConnected,"Use a separate Server instance per connection: this instance is already connected to a transport. To connect it to a new transport, call close() first.");this._boundFromTransport&&(this._boundFromTransport=!1,this._negotiatedProtocolVersion=void 0);let t=(e instanceof dn?l(e):void 0)?.revision;void 0!==t&&!this._servedModernEra()&&lQ.includes(t)&&l0(this._supportedProtocolVersions).includes(t)&&(this._negotiatedProtocolVersion=t,this._boundFromTransport=!0),await super.connect(e)}_registerLoggingHandler(){this.setRequestHandler("logging/setLevel",async(e,t)=>{let r=t.sessionId||t.http?.req?.headers.get("mcp-session-id")||void 0,{level:i}=e.params,n=nR(sC,i);return n.success&&this._loggingLevels.set(r,n.data),{}})}buildContext(e,t){let r=e.http||t?.request||t?.closeSSEStream||t?.closeStandaloneSSEStream;return{...e,mcpReq:{...e.mcpReq,log:(t,r,i)=>{let n;if(!this._capabilities.logging)return Promise.resolve();if(this._servedModernEra()){if(void 0===(n=e.mcpReq.envelope?.[aQ]))return Promise.resolve()}else n=this._loggingLevels.get(e.sessionId)??this._loggingLevels.get(void 0);return void 0!==n&&this.LOG_LEVEL_SEVERITY.get(t)<this.LOG_LEVEL_SEVERITY.get(n)?Promise.resolve():e.mcpReq.notify({method:"notifications/message",params:{level:t,data:r,logger:i}})},elicitInput:(e,t)=>this.elicitInput(e,t),requestSampling:(e,t)=>this.createMessage(e,t)},http:r?{...e.http,req:t?.request,closeSSE:t?.closeSSEStream,closeStandaloneSSE:t?.closeStandaloneSSEStream}:void 0}}_loggingLevels=new Map;LOG_LEVEL_SEVERITY=new Map(sC.options.map((e,t)=>[e,t]));isMessageIgnored=(e,t)=>{let r=this._loggingLevels.get(t);return!!r&&this.LOG_LEVEL_SEVERITY.get(e)<this.LOG_LEVEL_SEVERITY.get(r)};registerCapabilities(e){if(this.transport)throw new lW(lB.AlreadyConnected,"Cannot register capabilities after connecting to transport");let t=!!this._capabilities.logging;this._capabilities=function(e,t){let r={...e};for(let e in t){let i=t[e];if(void 0===i)continue;let n=r[e];r[e]=uA(n)&&uA(i)?{...n,...i}:i}return r}(this._capabilities,e),!t&&this._capabilities.logging&&this._registerLoggingHandler()}_wrapHandler(e,t){if("tools/call"!==e){let r=this._cacheHints?.[e],i=dh.has(e);return void 0!==r||i?async(n,a)=>{let o=i?await this._invokeInputRequiredCapableHandler(e,t,n,a):await t(n,a);if(c1(o)){if(!i)throw new cv(cy.InternalError,`Handler for ${e} returned an input-required result, but only tools/call, prompts/get and resources/read support input_required (protocol revision 2026-07-28)`);return o}return void 0===r?o:cm(o,r)}:async(r,i)=>{let n=await t(r,i);if(c1(n))throw new cv(cy.InternalError,`Handler for ${e} returned an input-required result, but only tools/call, prompts/get and resources/read support input_required (protocol revision 2026-07-28)`);return n}}return async(e,r)=>{let i=cL(this._negotiatedProtocolVersion),n=i.validateRequest("tools/call",e);if(!n.ok)throw new cv("not-in-era"===n.reason?cy.InternalError:cy.InvalidParams,"not-in-era"===n.reason?"No wire schema for tools/call in the resolved era":`Invalid tools/call request: ${n.message}`);let a=await this._invokeInputRequiredCapableHandler("tools/call",t,e,r);if(c1(a))return a;let o=l9(a),s=i.validateResult("tools/call",o);if(!s.ok)throw new cv("not-in-era"===s.reason?cy.InternalError:cy.InvalidParams,"not-in-era"===s.reason?"No wire schema for tools/call in the resolved era":`Invalid tools/call result: ${s.message}`);return s.value}}_servedModernEra(){return void 0!==this._negotiatedProtocolVersion&&this._negotiatedProtocolVersion>=lX}async _invokeInputRequiredCapableHandler(e,t,r,i){let n,a=this._servedModernEra(),o=i.mcpReq.requestState();if(void 0!==o&&"string"!=typeof o)throw new cv(cy.InvalidParams,"Invalid or expired requestState",{reason:"invalid_request_state"});let s=i;if("string"==typeof o){let t=await this._verifyRequestState(o,i,e);void 0!==t&&(s=uj(i,t))}try{n=await t(r,s)}catch(e){if(e instanceof cv&&e.code===cy.UrlElicitationRequired){if(!a)throw e;throw new cv(cy.InternalError,`URL elicitation cannot be signalled by throwing UrlElicitationRequiredError on protocol revision ${this._negotiatedProtocolVersion}: return inputRequired({ inputRequests: { …: inputRequired.elicitUrl(...) } }) from the handler instead. The urlElicitationRequired error (-32042) of earlier revisions is not available on this revision.`)}throw e}if(!c1(n))return n;if(!a){if(!this._inputRequiredServing.legacyShim)throw new cv(cy.InternalError,`Handler for ${e} returned an input-required result, but this request is served on protocol revision ${this._negotiatedProtocolVersion??aV}, which has no input_required vocabulary`);return await this._legacyInputRequiredShim().fulfill(e,t,r,s,n)}let l=n.inputRequests,c=null!=l&&Object.keys(l).length>0,u="string"==typeof n.requestState;if(!c&&!u)throw new cv(cy.InternalError,`Handler for ${e} returned an input-required result with neither inputRequests nor requestState (every InputRequiredResult must include at least one of the two)`);if(c){let t=this._inputRequestCapabilityView(i);for(let[r,i]of Object.entries(l)){let{embedded:n,required:a}=dd(e,r,i),o=lY(a,t);if(void 0!==o)throw new cw({requiredCapabilities:o},`Cannot request input '${r}' (${n.method}): the request's client capabilities do not declare the required capability`)}}return n}async _verifyRequestState(e,t,r){if(void 0!==this._requestStateVerify)try{return await this._requestStateVerify(e,t)}catch(e){throw this.onerror?.(Error(`requestState verification rejected ${r}: ${e instanceof Error?e.message:String(e)}`)),new cv(cy.InvalidParams,"Invalid or expired requestState",{reason:"invalid_request_state"})}}_inputRequestCapabilityView(e){return this._servedModernEra()?e.mcpReq.envelope?.[aY]:this._clientCapabilities}_assertPushApiInServedEra(e){if(this._servedModernEra())throw new lW(lB.MethodNotSupportedByProtocolVersion,`Server-to-client requests are not available on protocol revision ${this._negotiatedProtocolVersion}: '${e}' cannot be sent while serving a request on that revision. Return inputRequired({ ... }) from the handler instead — the client fulfils the embedded requests and retries the original request (multi round-trip requests).`,{method:e,era:"2026-07-28"})}assertCapabilityForMethod(e){switch(e){case"sampling/createMessage":if(!this._clientCapabilities?.sampling)throw new lW(lB.CapabilityNotSupported,`Client does not support sampling (required for ${e})`);break;case"elicitation/create":if(!this._clientCapabilities?.elicitation)throw new lW(lB.CapabilityNotSupported,`Client does not support elicitation (required for ${e})`);break;case"roots/list":if(!this._clientCapabilities?.roots)throw new lW(lB.CapabilityNotSupported,`Client does not support listing roots (required for ${e})`)}}assertNotificationCapability(e){switch(e){case"notifications/message":if(!this._capabilities.logging)throw new lW(lB.CapabilityNotSupported,`Server does not support logging (required for ${e})`);break;case"notifications/resources/updated":case"notifications/resources/list_changed":if(!this._capabilities.resources)throw new lW(lB.CapabilityNotSupported,`Server does not support notifying about resources (required for ${e})`);break;case"notifications/tools/list_changed":if(!this._capabilities.tools)throw new lW(lB.CapabilityNotSupported,`Server does not support notifying of tool list changes (required for ${e})`);break;case"notifications/prompts/list_changed":if(!this._capabilities.prompts)throw new lW(lB.CapabilityNotSupported,`Server does not support notifying of prompt list changes (required for ${e})`);break;case"notifications/elicitation/complete":if(!this._clientCapabilities?.elicitation?.url)throw new lW(lB.CapabilityNotSupported,`Client does not support URL elicitation (required for ${e})`)}}assertRequestHandlerCapability(e){switch(e){case"completion/complete":if(!this._capabilities.completions)throw new lW(lB.CapabilityNotSupported,`Server does not support completions (required for ${e})`);break;case"logging/setLevel":if(!this._capabilities.logging)throw new lW(lB.CapabilityNotSupported,`Server does not support logging (required for ${e})`);break;case"prompts/get":case"prompts/list":if(!this._capabilities.prompts)throw new lW(lB.CapabilityNotSupported,`Server does not support prompts (required for ${e})`);break;case"resources/list":case"resources/templates/list":case"resources/read":if(!this._capabilities.resources)throw new lW(lB.CapabilityNotSupported,`Server does not support resources (required for ${e})`);break;case"tools/call":case"tools/list":if(!this._capabilities.tools)throw new lW(lB.CapabilityNotSupported,`Server does not support tools (required for ${e})`)}}async _oninitialize(e){let t=e.params.protocolVersion;this._clientCapabilities=e.params.capabilities,this._clientVersion=e.params.clientInfo;let r=this._supportedProtocolVersions.filter(e=>!(e>=lX)),i=r.includes(t)?t:r[0]??aV;return this._negotiatedProtocolVersion=i,this.transport?.setProtocolVersion?.(i),{protocolVersion:i,capabilities:this.getCapabilities(),serverInfo:this._serverInfo,...this._instructions&&{instructions:this._instructions}}}_ondiscover(){return{supportedVersions:l0(this._supportedProtocolVersions),capabilities:{...this.getCapabilities()},...this._instructions&&{instructions:this._instructions}}}_outboundServerInfo(){return this._serverInfo}getClientCapabilities(){return this._clientCapabilities}getClientVersion(){return this._clientVersion}getNegotiatedProtocolVersion(){return this._negotiatedProtocolVersion}projectCallToolResult(e,t){return this._wireCodec().projectCallToolResult(e,t)}getCapabilities(){return this._capabilities}async ping(){return this._assertPushApiInServedEra("ping"),this.request({method:"ping"})}async createMessage(e,t){if(this._assertPushApiInServedEra("sampling/createMessage"),(e.tools||e.toolChoice)&&!this._clientCapabilities?.sampling?.tools)throw new lW(lB.CapabilityNotSupported,"Client does not support sampling tools capability.");if(e.messages.length>0){let t=e.messages.at(-1),r=Array.isArray(t.content)?t.content:[t.content],i=r.some(e=>"tool_result"===e.type),n=e.messages.length>1?e.messages.at(-2):void 0,a=n?Array.isArray(n.content)?n.content:[n.content]:[],o=a.some(e=>"tool_use"===e.type);if(i){if(r.some(e=>"tool_result"!==e.type))throw new cv(cy.InvalidParams,"The last message must contain only tool_result content if any is present");if(!o)throw new cv(cy.InvalidParams,"tool_result blocks are not matching any tool_use from the previous message")}if(o){let e=new Set(a.filter(e=>"tool_use"===e.type).map(e=>e.id)),t=new Set(r.filter(e=>"tool_result"===e.type).map(e=>e.toolUseId));if(e.size!==t.size||![...e].every(e=>t.has(e)))throw new cv(cy.InvalidParams,"ids of tool_result blocks and tool_use blocks from previous message do not match")}}let r=!!(e.tools||e.toolChoice),i=await this.request({method:"sampling/createMessage",params:e},t),n=this._wireCodec().samplingResultVariant(r,i);if(!n.ok)throw new lW(lB.InvalidResult,`Invalid sampling/createMessage result: ${"invalid"===n.reason?n.message:n.reason}`);return n.value}async elicitInput(e,t){switch(this._assertPushApiInServedEra("elicitation/create"),e.mode??"form"){case"url":if(!this._clientCapabilities?.elicitation?.url)throw new lW(lB.CapabilityNotSupported,"Client does not support url elicitation.");break;case"form":if(!this._clientCapabilities?.elicitation?.form)throw new lW(lB.CapabilityNotSupported,"Client does not support form elicitation.")}return this._sendElicitationLeg(e,t)}async _sendElicitationLeg(e,t,r){let i=e.mode??"form",n=r?.validateAcceptedContent??!0;switch(i){case"url":return this.request({method:"elicitation/create",params:e},t);case"form":{let r="form"===e.mode?e:{...e,mode:"form"},i=await this.request({method:"elicitation/create",params:r},t);if(n&&"accept"===i.action&&i.content&&r.requestedSchema)try{let e=this._jsonSchemaValidator.getValidator(r.requestedSchema)(i.content);if(!e.valid)throw new cv(cy.InvalidParams,`Elicitation response content does not match requested schema: ${e.errorMessage}`)}catch(e){if(e instanceof cv)throw e;throw new cv(cy.InternalError,`Error validating elicitation response: ${e instanceof Error?e.message:String(e)}`)}return i}}}createElicitationCompletionNotifier(e,t){if(!this._clientCapabilities?.elicitation?.url)throw new lW(lB.CapabilityNotSupported,"Client does not support URL elicitation (required for notifications/elicitation/complete)");return()=>this.notification({method:"notifications/elicitation/complete",params:{elicitationId:e}},t)}async listRoots(e,t){return this._assertPushApiInServedEra("roots/list"),this.request({method:"roots/list",params:e},t)}async sendLoggingMessage(e,t){if(this._capabilities.logging&&!this.isMessageIgnored(e.level,t))return this.notification({method:"notifications/message",params:e})}async sendResourceUpdated(e){return this.notification({method:"notifications/resources/updated",params:e})}async sendResourceListChanged(){return this.notification({method:"notifications/resources/list_changed"})}async sendToolListChanged(){return this.notification({method:"notifications/tools/list_changed"})}async sendPromptListChanged(){return this.notification({method:"notifications/prompts/list_changed"})}},dg=class{server;_maxToolInputElements;_registeredResources={};_registeredResourceTemplates={};_registeredTools={};_registeredPrompts={};_toolInputSchemaJson={};toolInputSchemaJson(e){let t=this._registeredTools[e];if(void 0!==t&&t.enabled){if(Object.hasOwn(this._toolInputSchemaJson,e))return this._toolInputSchemaJson[e];if(void 0===t.inputSchema)return d_;try{let r=uf(t.inputSchema,"input");return this._toolInputSchemaJson[e]=r,r}catch{return}}}constructor(e,t){this.server=new df(e,t),this._maxToolInputElements=function(e){if(void 0!==e&&1/0!==e){if("number"!=typeof e||Number.isNaN(e)||e<1)throw RangeError(`maxToolInputElements must be a number of at least 1, or Infinity, got ${String(e)}`);return e}}(t?.maxToolInputElements),t?.capabilities?.tools&&this.setToolRequestHandlers(),t?.capabilities?.resources&&this.setResourceRequestHandlers(),t?.capabilities?.prompts&&this.setPromptRequestHandlers()}async connect(e){return"object"==typeof e&&null!==e&&"setScopeChallengeResolver"in e&&"function"==typeof e.setScopeChallengeResolver&&e.setScopeChallengeResolver(e=>this.resolveScopeChallenge(e)),await this.server.connect(e)}async close(){await this.server.close()}resolveScopeChallenge=e=>{switch(e.request.method){case"tools/call":{let t=e.request.params?.name;if("string"!=typeof t)return;let r=this._registeredTools[t];if(void 0===r||!r.enabled)return;return r.scopeChallenge?.(e)}case"resources/read":{let t,r=e.request.params?.uri;if("string"!=typeof r)return;try{t=new URL(r)}catch{return}let i=this._registeredResources[t.toString()];if(void 0!==i)return i.enabled?i.scopeChallenge?.(e):void 0;for(let r of Object.values(this._registeredResourceTemplates))if(r.resourceTemplate.uriTemplate.match(t.toString()))return r.enabled?r.scopeChallenge?.(e):void 0;return}case"prompts/get":{let t=e.request.params?.name;if("string"!=typeof t)return;let r=this._registeredPrompts[t];if(void 0===r||!r.enabled)return;return r.scopeChallenge?.(e)}default:return}};_toolHandlersInitialized=!1;setToolRequestHandlers(){this._toolHandlersInitialized||(this.server.assertCanSetRequestHandler("tools/list"),this.server.assertCanSetRequestHandler("tools/call"),this.server.registerCapabilities({tools:{listChanged:this.server.getCapabilities().tools?.listChanged??!0}}),this.server.setRequestHandler("tools/list",()=>({tools:Object.entries(this._registeredTools).filter(([,e])=>e.enabled).map(([e,t])=>{var r;let i,n,a={name:e,title:t.title,description:t.description,inputSchema:t.inputSchema?(r=e,(n=c3(i=uf(t.inputSchema,"input"))).valid||console.warn(`[mcp-sdk] tool '${r}' carries an invalid x-mcp-header declaration and will be excluded by conforming Streamable HTTP clients: ${n.reason}`),i):d_,annotations:t.annotations,icons:t.icons,execution:t.execution,_meta:t._meta};return t.outputSchema&&(a.outputSchema=uf(t.outputSchema,"output")),a})})),this.server.setRequestHandler("tools/call",async(e,t)=>{let r=this._registeredTools[e.params.name];if(!r)throw new cv(cy.InvalidParams,`Tool ${e.params.name} not found`);if(!r.enabled)throw new cv(cy.InvalidParams,`Tool ${e.params.name} disabled`);try{let i=await this.validateToolInput(r,e.params.arguments,e.params.name),n=await this.executeToolHandler(r,i,t);if(await this.validateToolOutput(r,n,e.params.name),c1(n))return n;return this.server.projectCallToolResult(n,r.outputSchemaJson)}catch(e){if(e instanceof cv&&e.code===cy.UrlElicitationRequired)throw e;return this.createToolError(e instanceof Error?e.message:String(e))}}),this._toolHandlersInitialized=!0)}createToolError(e){return{content:[{type:"text",text:e}],isError:!0}}async validateToolInput(e,t,r){if(void 0!==this._maxToolInputElements&&function(e,t){let r=0,i=[e];for(;i.length>0;){let e=i.pop();if(null!==e&&"object"==typeof e)if(Array.isArray(e))for(let n of e){if(++r>t)return r;null!==n&&"object"==typeof n&&i.push(n)}else for(let n in e){if(!Object.prototype.hasOwnProperty.call(e,n))continue;if(++r>t)return r;let a=e[n];null!==a&&"object"==typeof a&&i.push(a)}}return r}(t,this._maxToolInputElements)>this._maxToolInputElements)throw new cv(cy.InvalidParams,`Invalid arguments for tool ${r}: arguments contain more than the maximum of ${this._maxToolInputElements} elements`);if(!e.inputSchema)return;let i=await uy(e.inputSchema,t??{});if(!i.success)throw new cv(cy.InvalidParams,`Input validation error: Invalid arguments for tool ${r}: ${i.error}`);return i.data}async validateToolOutput(e,t,r){if(!e.outputSchema||c1(t)||t.isError)return;if(void 0===t.structuredContent)throw new cv(cy.InvalidParams,`Output validation error: Tool ${r} has an output schema but no structured content was provided`);let i=await uy(e.outputSchema,t.structuredContent);if(!i.success)throw new cv(cy.InvalidParams,`Output validation error: Invalid structured content for tool ${r}: ${i.error}`)}async executeToolHandler(e,t,r){return e.executor(t,r)}_completionHandlerInitialized=!1;setCompletionRequestHandler(){this._completionHandlerInitialized||(this.server.assertCanSetRequestHandler("completion/complete"),this.server.registerCapabilities({completions:{}}),this.server.setRequestHandler("completion/complete",async e=>{switch(e.params.ref.type){case"ref/prompt":if("ref/prompt"!==e.params.ref.type)throw TypeError(`Expected CompleteRequestPrompt, but got ${e.params.ref.type}`);return this.handlePromptCompletion(e,e.params.ref);case"ref/resource":if("ref/resource"!==e.params.ref.type)throw TypeError(`Expected CompleteRequestResourceTemplate, but got ${e.params.ref.type}`);return this.handleResourceCompletion(e,e.params.ref);default:throw new cv(cy.InvalidParams,`Invalid completion reference: ${e.params.ref}`)}}),this._completionHandlerInitialized=!0)}async handlePromptCompletion(e,t){let r=this._registeredPrompts[t.name];if(!r)throw new cv(cy.InvalidParams,`Prompt ${t.name} not found`);if(!r.enabled)throw new cv(cy.InvalidParams,`Prompt ${t.name} disabled`);if(!r.argsSchema)return dR;let i=dx(dk(r.argsSchema)?.[e.params.argument.name]);if(!dr(i))return dR;let n=i[dt]?.complete;return n?dw(await n(e.params.argument.value,e.params.context)):dR}async handleResourceCompletion(e,t){let r=Object.values(this._registeredResourceTemplates).find(e=>e.resourceTemplate.uriTemplate.toString()===t.uri);if(!r){if(this._registeredResources[t.uri])return dR;throw new cv(cy.InvalidParams,`Resource template ${e.params.ref.uri} not found`)}let i=r.resourceTemplate.completeCallback(e.params.argument.name);return i?dw(await i(e.params.argument.value,e.params.context)):dR}_resourceHandlersInitialized=!1;setResourceRequestHandlers(){this._resourceHandlersInitialized||(this.server.assertCanSetRequestHandler("resources/list"),this.server.assertCanSetRequestHandler("resources/templates/list"),this.server.assertCanSetRequestHandler("resources/read"),this.server.registerCapabilities({resources:{listChanged:this.server.getCapabilities().resources?.listChanged??!0}}),this.server.setRequestHandler("resources/list",async(e,t)=>{let r=Object.entries(this._registeredResources).filter(([e,t])=>t.enabled).map(([e,t])=>({uri:e,name:t.name,...t.metadata})),i=[];for(let e of Object.values(this._registeredResourceTemplates))if(e.resourceTemplate.listCallback)for(let r of(await e.resourceTemplate.listCallback(t)).resources)i.push({...e.metadata,...r});return{resources:[...r,...i]}}),this.server.setRequestHandler("resources/templates/list",async()=>({resourceTemplates:Object.entries(this._registeredResourceTemplates).map(([e,t])=>({name:e,uriTemplate:t.resourceTemplate.uriTemplate.toString(),...t.metadata}))})),this.server.setRequestHandler("resources/read",async(e,t)=>{let r;try{r=new URL(e.params.uri)}catch{throw new cv(cy.InvalidParams,`Resource URI ${e.params.uri} is invalid`,{uri:e.params.uri,reason:"invalid_uri"})}let i=this._registeredResources[r.toString()];if(i){if(!i.enabled)throw new cv(cy.InvalidParams,`Resource ${r} disabled`);return cm(await i.readCallback(r,t),i.cacheHint)}for(let e of Object.values(this._registeredResourceTemplates)){let i=e.resourceTemplate.uriTemplate.match(r.toString());if(i){if(!e.enabled)throw new cv(cy.InvalidParams,`Resource template ${e.resourceTemplate.uriTemplate} disabled`);return cm(await e.readCallback(r,i,t),e.cacheHint)}}throw new c_(e.params.uri)}),this._resourceHandlersInitialized=!0)}_promptHandlersInitialized=!1;setPromptRequestHandlers(){this._promptHandlersInitialized||(this.server.assertCanSetRequestHandler("prompts/list"),this.server.assertCanSetRequestHandler("prompts/get"),this.server.registerCapabilities({prompts:{listChanged:this.server.getCapabilities().prompts?.listChanged??!0}}),this.server.setRequestHandler("prompts/list",()=>({prompts:Object.entries(this._registeredPrompts).filter(([,e])=>e.enabled).map(([e,t])=>{let r,i,n;return{name:e,title:t.title,description:t.description,arguments:t.argsSchema?(i=(r=uf(t.argsSchema,"input")).properties||{},n=r.required||[],Object.entries(i).map(([e,t])=>({name:e,description:t?.description,required:n.includes(e)}))):void 0,icons:t.icons,_meta:t._meta}})})),this.server.setRequestHandler("prompts/get",async(e,t)=>{let r=this._registeredPrompts[e.params.name];if(!r)throw new cv(cy.InvalidParams,`Prompt ${e.params.name} not found`);if(!r.enabled)throw new cv(cy.InvalidParams,`Prompt ${e.params.name} disabled`);return r.handler(e.params.arguments,t)}),this._promptHandlersInitialized=!0)}registerResource(e,t,r,i){let{cacheHint:n,scopeChallenge:a,...o}=r;if(void 0!==n&&cg(n,`resource ${e}`),"string"==typeof t){if(this._registeredResources[t])throw Error(`Resource ${t} is already registered`);let s=this._createRegisteredResource(e,r.title,t,o,a,i);return void 0!==n&&(s.cacheHint=n),this.setResourceRequestHandlers(),this.sendResourceListChanged(),s}{if(this._registeredResourceTemplates[e])throw Error(`Resource template ${e} is already registered`);let s=this._createRegisteredResourceTemplate(e,r.title,t,o,a,i);return void 0!==n&&(s.cacheHint=n),this.setResourceRequestHandlers(),this.sendResourceListChanged(),s}}_createRegisteredResource(e,t,r,i,n,a){let o={name:e,title:t,metadata:i,readCallback:a,scopeChallenge:n,enabled:!0,disable:()=>o.update({enabled:!1}),enable:()=>o.update({enabled:!0}),remove:()=>o.update({uri:null}),update:e=>{void 0!==e.uri&&e.uri!==r&&(delete this._registeredResources[r],e.uri&&(this._registeredResources[e.uri]=o)),void 0!==e.name&&(o.name=e.name),void 0!==e.metadata&&(o.metadata=e.metadata),void 0!==e.title&&(o.title=e.title,o.metadata={...o.metadata,title:e.title}),void 0!==e.callback&&(o.readCallback=e.callback),void 0!==e.scopeChallenge&&(o.scopeChallenge=null===e.scopeChallenge?void 0:e.scopeChallenge),void 0!==e.enabled&&(o.enabled=e.enabled),this.sendResourceListChanged()}};return this._registeredResources[r]=o,o}_createRegisteredResourceTemplate(e,t,r,i,n,a){let o={resourceTemplate:r,title:t,metadata:i,readCallback:a,scopeChallenge:n,enabled:!0,disable:()=>o.update({enabled:!1}),enable:()=>o.update({enabled:!0}),remove:()=>o.update({name:null}),update:t=>{void 0!==t.name&&t.name!==e&&(delete this._registeredResourceTemplates[e],t.name&&(this._registeredResourceTemplates[t.name]=o)),void 0!==t.template&&(o.resourceTemplate=t.template),void 0!==t.metadata&&(o.metadata=t.metadata),void 0!==t.title&&(o.title=t.title,o.metadata={...o.metadata,title:t.title}),void 0!==t.callback&&(o.readCallback=t.callback),void 0!==t.scopeChallenge&&(o.scopeChallenge=null===t.scopeChallenge?void 0:t.scopeChallenge),void 0!==t.enabled&&(o.enabled=t.enabled),this.sendResourceListChanged()}};this._registeredResourceTemplates[e]=o;let s=r.uriTemplate.variableNames;return Array.isArray(s)&&s.some(e=>!!r.completeCallback(e))&&this.setCompletionRequestHandler(),o}_createRegisteredPrompt(e,t,r,i,n,a,o,s){let l=i,c=n,u={title:t,description:r,argsSchema:i,icons:a,scopeChallenge:o,_meta:s,handler:dS(e,i,n),enabled:!0,disable:()=>u.update({enabled:!1}),enable:()=>u.update({enabled:!0}),remove:()=>u.update({name:null}),update:t=>{void 0!==t.name&&t.name!==e&&(delete this._registeredPrompts[e],t.name&&(this._registeredPrompts[t.name]=u)),void 0!==t.title&&(u.title=t.title),void 0!==t.description&&(u.description=t.description),void 0!==t.icons&&(u.icons=t.icons),void 0!==t.scopeChallenge&&(u.scopeChallenge=null===t.scopeChallenge?void 0:t.scopeChallenge),void 0!==t._meta&&(u._meta=t._meta);let r=!1;void 0!==t.argsSchema&&(u.argsSchema=t.argsSchema,l=t.argsSchema,r=!0),void 0!==t.callback&&(c=t.callback,r=!0),r&&(u.handler=dS(e,l,c)),void 0!==t.enabled&&(u.enabled=t.enabled),this.sendPromptListChanged()}};if(this._registeredPrompts[e]=u,i){let e=dk(i);e&&Object.values(e).some(e=>dr(dx(e)))&&this.setCompletionRequestHandler()}return u}_createRegisteredTool(e,t,r,i,n,a,o,s,l,c,u){let d;uF(e);let p=u,m={title:t,description:r,inputSchema:i,outputSchema:n,get outputSchemaJson(){return d??=db(m.outputSchema)},set outputSchemaJson(e){d=e},annotations:a,icons:o,execution:s,scopeChallenge:l,_meta:c,handler:u,executor:dv(i,u),enabled:!0,disable:()=>m.update({enabled:!1}),enable:()=>m.update({enabled:!0}),remove:()=>m.update({name:null}),update:t=>{void 0!==t.name&&t.name!==e&&("string"==typeof t.name&&uF(t.name),delete this._registeredTools[e],delete this._toolInputSchemaJson[e],t.name&&(delete this._toolInputSchemaJson[t.name],this._registeredTools[t.name]=m,e=t.name)),void 0!==t.title&&(m.title=t.title),void 0!==t.description&&(m.description=t.description);let r=!1;void 0!==t.paramsSchema&&(m.inputSchema=t.paramsSchema,delete this._toolInputSchemaJson[e],r=!0),void 0!==t.callback&&(m.handler=t.callback,p=t.callback,r=!0),r&&(m.executor=dv(m.inputSchema,p)),void 0!==t.outputSchema&&(m.outputSchema=t.outputSchema,m.outputSchemaJson=db(t.outputSchema)),void 0!==t.annotations&&(m.annotations=t.annotations),void 0!==t.icons&&(m.icons=t.icons),void 0!==t.scopeChallenge&&(m.scopeChallenge=null===t.scopeChallenge?void 0:t.scopeChallenge),void 0!==t._meta&&(m._meta=t._meta),void 0!==t.enabled&&(m.enabled=t.enabled),this.sendToolListChanged()}};return this._registeredTools[e]=m,this.setToolRequestHandlers(),this.sendToolListChanged(),m}registerTool(e,t,r){if(this._registeredTools[e])throw Error(`Tool ${e} is already registered`);let{title:i,description:n,inputSchema:a,outputSchema:o,annotations:s,icons:l,scopeChallenge:c,_meta:u}=t;return this._createRegisteredTool(e,i,n,uH(a),uH(o),s,l,void 0,c,u,r)}registerPrompt(e,t,r){if(this._registeredPrompts[e])throw Error(`Prompt ${e} is already registered`);let{title:i,description:n,argsSchema:a,icons:o,scopeChallenge:s,_meta:l}=t,c=this._createRegisteredPrompt(e,i,n,uH(a),r,o,s,l);return this.setPromptRequestHandlers(),this.sendPromptListChanged(),c}isConnected(){return void 0!==this.server.transport}async sendLoggingMessage(e,t){return this.server.sendLoggingMessage(e,t)}sendResourceListChanged(){this.isConnected()&&this.server.sendResourceListChanged()}sendToolListChanged(){this.isConnected()&&this.server.sendToolListChanged()}sendPromptListChanged(){this.isConnected()&&this.server.sendPromptListChanged()}},dy=class{_uriTemplate;constructor(e,t){this._callbacks=t,this._uriTemplate="string"==typeof e?new uD(e):e}get uriTemplate(){return this._uriTemplate}get listCallback(){return this._callbacks.list}completeCallback(e){return this._callbacks.complete?.[e]}};function dv(e,t){return e?async(e,r)=>t(e,r):async(e,r)=>t(r)}let d_={type:"object",properties:{}};function db(e){if(void 0!==e)try{return uf(e,"output")}catch{return}}function dS(e,t,r){return t?async(i,n)=>{let a=await uy(t,i??{});if(!a.success)throw new cv(cy.InvalidParams,`Invalid arguments for prompt ${e}: ${a.error}`);return r(a.data,n)}:async(e,t)=>r(t)}function dw(e){return{completion:{values:e.map(String).slice(0,100),total:e.length,hasMore:e.length>100}}}let dR={completion:{values:[],hasMore:!1}};function dk(e){if(e.shape&&"object"==typeof e.shape)return e.shape}function dx(e){return e?.type!=="optional"?e:e.def?.innerType??e}var d$=class{_listeners=new Set;constructor(e){this.onerror=e}publish(e){for(let t of this._listeners)try{t(e)}catch(e){this.onerror?.(e instanceof Error?e:Error(String(e)))}}subscribe(e){this._listeners.add(e);let t=!0;return()=>{t&&(t=!1,this._listeners.delete(e))}}get listenerCount(){return this._listeners.size}};function dT(e,t,r){return Response.json({jsonrpc:"2.0",error:{code:t,message:r},id:e},{status:200})}function dC(e,t){return{method:e.method,params:{...e.params,_meta:{...e.params?._meta,[aX]:t}}}}function dP(e){return`Payload Too Large: Request body must not exceed ${e} bytes`}function dO(e){if(void 0===e)return 4194304;if("number"!=typeof e||!Number.isFinite(e)||e<=0)throw RangeError(`maxRequestBodySize must be a positive number of bytes, got ${String(e)}`);return e}async function dE(e,t=4194304){if(Number(e.headers.get("content-length"))>t)return{tooLarge:!0};if(null===e.body)return{tooLarge:!1,text:""};let r=e.body.getReader(),i=new TextDecoder,n=0,a="";try{for(;;){let{done:e,value:o}=await r.read();if(e)break;if((n+=o.byteLength)>t)return{tooLarge:!0};a+=i.decode(o,{stream:!0})}}finally{r.releaseLock()}return{tooLarge:!1,text:a+i.decode()}}var dI=class{sessionIdGenerator;_started=!1;_hasHandledRequest=!1;_closed=!1;_streamMapping=new Map;_requestToStreamMapping=new Map;_requestResponseMap=new Map;_initialized=!1;_enableJsonResponse=!1;_standaloneSseStreamId="_GET_stream";_eventStore;_onsessioninitialized;_onsessionclosed;_allowedHosts;_allowedOrigins;_enableDnsRebindingProtection;_retryInterval;_supportedProtocolVersions;_keepAliveMs;_maxRequestBodySize;_scopeChallengeResolver;sessionId;onclose;onerror;onmessage;constructor(e={}){this.sessionIdGenerator=e.sessionIdGenerator,this._enableJsonResponse=e.enableJsonResponse??!1,this._eventStore=e.eventStore,this._onsessioninitialized=e.onsessioninitialized,this._onsessionclosed=e.onsessionclosed,this._allowedHosts=e.allowedHosts,this._allowedOrigins=e.allowedOrigins,this._enableDnsRebindingProtection=e.enableDnsRebindingProtection??!1,this._retryInterval=e.retryInterval,this._supportedProtocolVersions=e.supportedProtocolVersions??aB,this._keepAliveMs=e.keepAliveMs??15e3,this._maxRequestBodySize=dO(e.maxRequestBodySize)}startKeepAlive(e,t){if(this._closed)return;let r=di(this._keepAliveMs,()=>{try{e.enqueue(t.encode(": keepalive\n\n"))}catch{void 0!==r&&clearInterval(r)}});return r}setScopeChallengeResolver(e){this._scopeChallengeResolver=e}async start(){if(this._started)throw Error("Transport already started");this._started=!0}setSupportedProtocolVersions(e){this._supportedProtocolVersions=e}createJsonErrorResponse(e,t,r,i){let n={code:t,message:r};return i?.data!==void 0&&(n.data=i.data),Response.json({jsonrpc:"2.0",error:n,id:null},{status:e,headers:{"Content-Type":"application/json",...i?.headers}})}async _checkScopeChallenge(e,t){if(!this._scopeChallengeResolver)return;let r=await dl(e.filter(e=>cY(e)),t,this._scopeChallengeResolver);return void 0===r?void 0:du(r,dc(t))}validateRequestHeaders(e){if(this._enableDnsRebindingProtection){if(this._allowedHosts&&this._allowedHosts.length>0){let t=e.headers.get("host");if(!t||!this._allowedHosts.includes(t)){let e=`Invalid Host header: ${t}`;return this.onerror?.(Error(e)),this.createJsonErrorResponse(403,-32e3,e)}}if(this._allowedOrigins&&this._allowedOrigins.length>0){let t=e.headers.get("origin");if(t&&!this._allowedOrigins.includes(t)){let e=`Invalid Origin header: ${t}`;return this.onerror?.(Error(e)),this.createJsonErrorResponse(403,-32e3,e)}}}}async handleRequest(e,t){if(this._closed)return this.createJsonErrorResponse(404,-32001,"Session not found");if(!this.sessionIdGenerator&&this._hasHandledRequest)throw Error("Stateless transport cannot be reused across requests. Create a new transport per request.");this._hasHandledRequest=!0;let r=this.validateRequestHeaders(e);if(r)return r;switch(e.method){case"POST":return this.handlePostRequest(e,t);case"GET":return this.handleGetRequest(e);case"DELETE":return this.handleDeleteRequest(e);default:return this.handleUnsupportedRequest()}}supportsEmptySSEData(e){return this._supportedProtocolVersions.includes(e)&&e>="2025-11-25"}async writePrimingEvent(e,t,r,i){if(!this._eventStore||!this.supportsEmptySSEData(i))return;let n=await this._eventStore.storeEvent(r,{}),a=`id: ${n}
|
|
63
63
|
data:
|
|
64
64
|
|
|
65
|
-
`;void 0!==this._retryInterval&&(
|
|
65
|
+
`;void 0!==this._retryInterval&&(a=`id: ${n}
|
|
66
66
|
retry: ${this._retryInterval}
|
|
67
67
|
data:
|
|
68
68
|
|
|
69
|
-
`),
|
|
70
|
-
`;return
|
|
71
|
-
`),
|
|
72
|
-
|
|
73
|
-
`,t.enqueue(r.encode(a)),!0}catch(t){return this.onerror?.(t),!1}}handleUnsupportedRequest(){return this.onerror?.(Error("Method not allowed.")),Response.json({jsonrpc:"2.0",error:{code:-32e3,message:"Method not allowed."},id:null},{status:405,headers:{Allow:"GET, POST, DELETE","Content-Type":"application/json"}})}async handlePostRequest(t,r){try{let i,n,a,o,s,l=t.headers.get("accept");if(!l?.includes("application/json")||!l.includes("text/event-stream"))return this.onerror?.(Error("Not Acceptable: Client must accept both application/json and text/event-stream")),this.createJsonErrorResponse(406,-32e3,"Not Acceptable: Client must accept both application/json and text/event-stream");if(!uZ(t.headers.get("content-type")))return this.onerror?.(Error("Unsupported Media Type: Content-Type must be application/json")),this.createJsonErrorResponse(415,-32e3,"Unsupported Media Type: Content-Type must be application/json");if(r?.parsedBody===void 0)try{let r=await dq(t,this._maxRequestBodySize);if(r.tooLarge){let t=dO(this._maxRequestBodySize);return this.onerror?.(Error(t)),this.createJsonErrorResponse(413,-32e3,t)}i=JSON.parse(r.text)}catch(t){return this.onerror?.(t),this.createJsonErrorResponse(400,-32700,"Parse error: Invalid JSON")}else i=r.parsedBody;if(Array.isArray(i)&&i.length>100)return this.onerror?.(Error("Invalid Request: Batch must not exceed 100 messages")),this.createJsonErrorResponse(400,-32600,"Invalid Request: Batch must not exceed 100 messages");try{n=Array.isArray(i)?i.map(t=>od.parse(t)):[od.parse(i)]}catch(t){return this.onerror?.(t),this.createJsonErrorResponse(400,-32700,"Parse error: Invalid JSON-RPC message")}if(this._closed)return this.createJsonErrorResponse(404,-32001,"Session not found");let c=n.some(t=>o$.safeParse(t).success);if(c){if(this._initialized&&void 0!==this.sessionId)return this.onerror?.(Error("Invalid Request: Server already initialized")),this.createJsonErrorResponse(400,-32600,"Invalid Request: Server already initialized");if(n.length>1)return this.onerror?.(Error("Invalid Request: Only one initialization request is allowed")),this.createJsonErrorResponse(400,-32600,"Invalid Request: Only one initialization request is allowed");this.sessionId=this.sessionIdGenerator?.(),this._initialized=!0,this.sessionId&&this._onsessioninitialized&&await Promise.resolve(this._onsessioninitialized(this.sessionId))}if(!c){let r=this.validateSession(t);if(r)return r;let i=this.validateProtocolVersion(t);if(i)return i}if(this._closed)return this.createJsonErrorResponse(404,-32001,"Session not found");try{a=await this._checkScopeChallenge(n,r?.authInfo)}catch(t){return this.onerror?.(t),this.createJsonErrorResponse(500,-32603,"Internal server error")}if(a)return a;if(!n.some(t=>cX(t))){for(let i of n)this.onmessage?.(i,{authInfo:r?.authInfo,request:t});return new Response(null,{status:202})}let u=crypto.randomUUID(),d=n.find(t=>o$.safeParse(t).success),p=d?d.params.protocolVersion:t.headers.get("mcp-protocol-version")??"2025-03-26";if(this._enableJsonResponse)return new Promise(i=>{for(let t of(this._streamMapping.set(u,{resolveJson:i,cleanup:()=>{this._streamMapping.delete(u)}}),n))cX(t)&&this._requestToStreamMapping.set(t.id,u);for(let i of n)this.onmessage?.(i,{authInfo:r?.authInfo,request:t})});let m=new TextEncoder,h=new ReadableStream({start:t=>{o=t},cancel:()=>{void 0!==s&&clearInterval(s),this._streamMapping.get(u)?.controller===o&&this._streamMapping.delete(u)}}),f={"Content-Type":"text/event-stream","Cache-Control":"no-cache, no-transform",Connection:"keep-alive","X-Accel-Buffering":"no"};for(let t of(void 0!==this.sessionId&&(f["mcp-session-id"]=this.sessionId),n))cX(t)&&(this._streamMapping.set(u,{controller:o,encoder:m,cleanup:()=>{void 0!==s&&clearInterval(s),this._streamMapping.delete(u);try{o.close()}catch{}}}),this._requestToStreamMapping.set(t.id,u));for(let i of(await this.writePrimingEvent(o,m,u,p),n)){let n,a;cX(i)&&this._eventStore&&this.supportsEmptySSEData(p)&&(n=()=>{this.closeSSEStream(i.id)},a=()=>{this.closeStandaloneSSEStream()}),this.onmessage?.(i,{authInfo:r?.authInfo,request:t,closeSSEStream:n,closeStandaloneSSEStream:a})}return this._streamMapping.get(u)?.controller===o&&(s=this.startKeepAlive(o,m)),new Response(h,{status:200,headers:f})}catch(t){return this.onerror?.(t),this.createJsonErrorResponse(400,-32700,"Parse error",{data:String(t)})}}async handleDeleteRequest(t){let r=this.validateSession(t);if(r)return r;let i=this.validateProtocolVersion(t);if(i)return i;try{return await Promise.resolve(this._onsessionclosed?.(this.sessionId)),new Response(null,{status:200})}finally{await this.close()}}validateSession(t){if(void 0===this.sessionIdGenerator)return;if(!this._initialized)return this.onerror?.(Error("Bad Request: Server not initialized")),this.createJsonErrorResponse(400,-32e3,"Bad Request: Server not initialized");let r=t.headers.get("mcp-session-id");return r?r!==this.sessionId?(this.onerror?.(Error("Session not found")),this.createJsonErrorResponse(404,-32001,"Session not found")):void 0:(this.onerror?.(Error("Bad Request: Mcp-Session-Id header is required")),this.createJsonErrorResponse(400,-32e3,"Bad Request: Mcp-Session-Id header is required"))}validateProtocolVersion(t){let r=t.headers.get("mcp-protocol-version");if(null!==r&&!this._supportedProtocolVersions.includes(r)){let t=`Bad Request: Unsupported protocol version: ${r} (supported versions: ${this._supportedProtocolVersions.join(", ")})`;return this.onerror?.(Error(t)),this.createJsonErrorResponse(400,-32e3,t)}}async close(){if(!this._closed){for(let{cleanup:t}of(this._closed=!0,this._streamMapping.values()))t();this._streamMapping.clear(),this._requestResponseMap.clear(),this.onclose?.()}}closeSSEStream(t){let r=this._requestToStreamMapping.get(t);if(!r)return;let i=this._streamMapping.get(r);i&&i.cleanup()}closeStandaloneSSEStream(){let t=this._streamMapping.get(this._standaloneSseStreamId);t&&t.cleanup()}async send(t,r){let i=r?.relatedRequestId;if((c0(t)||c1(t))&&(i=t.id),void 0===i){let r;if(c0(t)||c1(t))throw Error("Cannot send a response on a standalone SSE stream unless resuming a previous client request");this._eventStore&&(r=await this._eventStore.storeEvent(this._standaloneSseStreamId,t));let i=this._streamMapping.get(this._standaloneSseStreamId);if(void 0===i)return;i.controller&&i.encoder&&(void 0===r||!i.replayedEventIds?.has(r))&&this.writeSSEEvent(i.controller,i.encoder,t,r);return}let n=this._requestToStreamMapping.get(i);if(!n)throw Error(`No connection established for request ID: ${String(i)}`);let a=this._streamMapping.get(n);if(!this._enableJsonResponse){let r;this._eventStore&&(r=await this._eventStore.storeEvent(n,t),a=this._streamMapping.get(n)),a?.controller&&a?.encoder&&(void 0===r||!a.replayedEventIds?.has(r))&&this.writeSSEEvent(a.controller,a.encoder,t,r)}if(c0(t)||c1(t)){this._requestResponseMap.set(i,t);let r=[...this._requestToStreamMapping.entries()].filter(([t,r])=>r===n).map(([t])=>t);if(r.every(t=>this._requestResponseMap.has(t))){if(!a){if(this._enableJsonResponse)throw Error(`No connection established for request ID: ${String(i)}`);if(!this._eventStore){for(let t of(this.onerror?.(Error(`Response for request ID ${String(i)} is undeliverable: per-request stream is disconnected and no eventStore is configured`)),r))this._requestResponseMap.delete(t),this._requestToStreamMapping.delete(t);return}for(let t of r)this._requestResponseMap.delete(t),this._requestToStreamMapping.delete(t);return}if(this._enableJsonResponse&&a.resolveJson){let t={"Content-Type":"application/json"};void 0!==this.sessionId&&(t["mcp-session-id"]=this.sessionId);let i=r.map(t=>this._requestResponseMap.get(t));1===i.length?a.resolveJson(Response.json(i[0],{status:200,headers:t})):a.resolveJson(Response.json(i,{status:200,headers:t})),a.cleanup()}else a.cleanup();for(let t of r)this._requestResponseMap.delete(t),this._requestToStreamMapping.delete(t)}}}};function dA(t){if(null===t||"object"!=typeof t||Array.isArray(t))return null;let{method:r,id:i}=t;return"string"!=typeof r?null:"string"==typeof i||"number"==typeof i?i:null}function dz(t,r,i,n,a=null){return Response.json({jsonrpc:"2.0",error:{code:r,message:i,...void 0!==n&&{data:n}},id:a},{status:t})}function dN(t,r=null){return dz(t.httpStatus,t.code,t.message,t.data,r)}function dM(t){return t instanceof Error?t:Error(String(t))}function dL(t=null){return dz(500,-32603,"Internal server error",void 0,t)}function dZ(t){if(void 0!==t.transport)throw Error("The factory returned an instance that is still serving another request. Return a new instance for each request.")}function dU(t){return{protocolVersionHeader:t.headers.get("mcp-protocol-version")??void 0,mcpMethodHeader:t.headers.get("mcp-method")??void 0,mcpNameHeader:t.headers.get("mcp-name")??void 0}}async function dF(t,r,i=!0,n=4194304){let a,o=t.method.toUpperCase(),s=r,l=t,c=!1;if("POST"===o){if(void 0===s){let r;i&&(l=t.clone());try{let i=await dq(t,n);if(i.tooLarge)return{step:"body-too-large"};r=i.text}catch{return{step:"unreadable-body"}}try{a=0===r.length?void 0:JSON.parse(r)}catch{c=!0}c||void 0===a||(s=a)}else a=s;if(c||void 0===a)return{step:"no-json-body",forwardRequest:l}}return{step:"classified",outcome:function(t){if("POST"!==(t={...t,...void 0!==t.protocolVersionHeader&&{protocolVersionHeader:uc(t.protocolVersionHeader)},...void 0!==t.mcpMethodHeader&&{mcpMethodHeader:uc(t.mcpMethodHeader)},...void 0!==t.mcpNameHeader&&{mcpNameHeader:uc(t.mcpNameHeader)}}).httpMethod.toUpperCase())return{kind:"legacy",reason:"http-method"};let r=t.body;if(Array.isArray(r)){if(0===r.length)return uo("jsonrpc-shape","empty-batch",400,new c_(cv.InvalidRequest,"Bad Request: empty JSON-RPC batch"),!0);for(let t of r){if(cW(uu(t)?t.params:void 0))return uo("jsonrpc-shape","batch-with-modern-element",400,new c_(cv.InvalidRequest,"Bad Request: JSON-RPC batches may not contain requests for protocol revision 2026-07-28 or later"),!0);if(!(cX(t)||cQ(t)||c0(t)||c1(t)))return uo("jsonrpc-shape","batch-with-invalid-element",400,new c_(cv.InvalidRequest,"Bad Request: JSON-RPC batch contains an invalid message"),!0)}return{kind:"legacy",reason:"batch"}}return c0(r)||c1(r)?{kind:"legacy",reason:"response"}:uu(r)&&cX(r)?function(t,r){let i=r.params,n=r.method,a=t.protocolVersionHeader,o=void 0!==a&&a>=lQ;if("initialize"===n&&!function(t){if(!cW(t))return!1;let r=cG(t);if(void 0===r||!(r>=lQ))return!1;let i=cB(t);return void 0!==i&&0===cK(i).length}(i)){if(o)return us("initialize-with-modern-header",a,"an initialize request (legacy handshake) was sent with a modern MCP-Protocol-Version header");let t=uu(i)&&"string"==typeof i.protocolVersion?i.protocolVersion:void 0;return{kind:"legacy",reason:"initialize",...void 0!==t&&{requestedVersion:t}}}if(cW(i)){let o=cB(i),s=(void 0===o?[]:cK(o))[0];if(void 0!==s)return uo("envelope","envelope-invalid",400,new c_(cv.InvalidParams,`Invalid _meta envelope for protocol revision 2026-07-28: ${s.key}: ${s.problem}`,{envelope:s}),!0);let l=cG(i);return void 0!==a&&void 0!==l&&a!==l?us("header-body-version-mismatch",a,`the body envelope names protocol version ${l} but the MCP-Protocol-Version header names ${a}`):void 0!==t.mcpMethodHeader&&t.mcpMethodHeader!==n?us("method-header-mismatch",t.mcpMethodHeader,`the body names method ${n} but the Mcp-Method header names ${t.mcpMethodHeader}`):{kind:"modern",messageKind:"request",message:r,classification:ud(l)}}if(o){let t=cB(i),r=cK(t??{}).filter(t=>"missing"===t.problem).map(t=>t.key),n=void 0===t?["_meta"]:r.length>0?r:[aG];return uo("envelope","modern-header-without-claim",400,new c_(cv.InvalidParams,`Invalid params: the MCP-Protocol-Version header names protocol revision ${a}, but the request is missing the required per-request envelope key(s): ${n.join(", ")}`,{envelope:{missing:n}}),!0)}return{kind:"legacy",reason:"no-claim",...void 0!==a&&{requestedVersion:a}}}(t,r):uu(r)&&cQ(r)?function(t,r){let i=r.params,n=r.method,a=t.protocolVersionHeader,o=void 0!==a&&a>=lQ;if(cW(i)){let o=cG(i);if(void 0===o){let t=cB(i),r=(void 0===t?[]:cK(t)).find(t=>t.key===aG)??{key:aG,problem:"expected a protocol version string"};return uo("envelope","notification-envelope-invalid",400,new c_(cv.InvalidParams,`Invalid _meta envelope for protocol revision 2026-07-28: ${r.key}: ${r.problem}`,{envelope:r}),!0)}if(void 0!==a&&a!==o)return us("notification-header-body-version-mismatch",a,`the notification envelope names protocol version ${o} but the MCP-Protocol-Version header names ${a}`);let s=ud(o);return"modern"===s.era&&void 0!==t.mcpMethodHeader&&t.mcpMethodHeader!==n?us("notification-method-header-mismatch",t.mcpMethodHeader,`the notification body names method ${n} but the Mcp-Method header names ${t.mcpMethodHeader}`):{kind:"modern",messageKind:"notification",message:r,classification:s}}return o?void 0!==t.mcpMethodHeader&&t.mcpMethodHeader!==n?us("notification-method-header-mismatch",t.mcpMethodHeader,`the notification body names method ${n} but the Mcp-Method header names ${t.mcpMethodHeader}`):{kind:"modern",messageKind:"notification",message:r,classification:{era:"modern",revision:a}}:{kind:"legacy",reason:"notification",...void 0!==a&&{requestedVersion:a}}}(t,r):uo("jsonrpc-shape","invalid-json-rpc-body",400,new c_(cv.InvalidRequest,"Bad Request: the request body is not a valid JSON-RPC message"),!0)}({httpMethod:o,...dU(t),...void 0!==a&&{body:a}}),body:a,parsedBody:s,forwardRequest:l}}let dD=(t,r)=>{globalThis[t]=r},dH=t=>globalThis[t];function dJ({name:t,fallback:r=!0}){let i=Symbol.for(`xmcp-context-${t}`),n=Symbol.for(`xmcp-context-${t}-fallback-store`);if(dH(i))return dH(i);let a=new x,o=globalThis[n]??{current:null};dD(n,o);let s={provider:(t,i)=>(r&&(o.current=t),a.run(t,i)),getContext:()=>{let i=a.getStore();if(i)return i;if(r&&o.current)return o.current;throw Error(`getContext() can only be used within the ${t} context.`)},setContext:i=>{let n=a.getStore()??(r?o.current:null);if(!n)throw Error(`setContext() can only be used within the ${t} context.`);Object.assign(n,i)}};return dD(i,s),s}let dV=dJ({name:"http-request-context"});dV.setContext;let dB=dV.getContext,dW=dV.provider,dG=t=>"object"==typeof t&&null!==t&&!Array.isArray(t),dK=t=>{if(!dG(t)||"string"!=typeof t.name||"string"!=typeof t.version)return;let r={name:t.name,version:t.version};return"string"==typeof t.title&&(r.title=t.title),"string"==typeof t.websiteUrl&&(r.websiteUrl=t.websiteUrl),"string"==typeof t.description&&(r.description=t.description),r},dY=t=>{if(t&&"initialize"===t.method&&dG(t.params))return dK(t.params.clientInfo)},dX=(t,r)=>{let i=r.toLowerCase();for(let[r,n]of Object.entries(t)){if(r.toLowerCase()!==i)continue;let t=Array.isArray(n)?n[0]:n;if("string"!=typeof t)break;let a=t.trim();return a.length>0?a:void 0}};function dQ(t){let{tags:r,enabled:i,...n}=t;return{...n,_meta:void 0===r?n._meta:{...n._meta,"xmcp/tags":r}}}let d0=new class{add(t,r){this.resources.set(t,r)}getAll(){return this.resources}clear(){this.resources.clear()}has(t){return this.resources.has(t)}constructor(){var t,r;t="resources",r=new Map,t in this?Object.defineProperty(this,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):this[t]=r}},d1=dJ({name:"request-context",fallback:!1}),d2=dJ({name:"client-info-context"});d2.setContext;let d9=d2.getContext;d2.provider;let d4=new Set(["message","mode","requestedSchema"]),d3=new Set(["elicitationId","message","mode","url"]),d6=new Set(["properties","required","type"]),d5=new Set(["default","description","format","maxLength","minLength","title","type"]),d7=new Set(["default","description","enum","enumNames","title","type"]),d8=new Set(["default","description","title","type"]),pe=new Set(["default","description","maximum","minimum","title","type"]),pt=new Set(["date","date-time","email","uri"]);async function pr(t,r,i){let n=function(t){let r=t.mode??"form";if("url"===r)return function(t){let r;pn(t,"Elicitation request must be a plain object."),pi(t,d3,"URL elicitation"),pa(t.message,"URL elicitation requires a string message."),po(t.elicitationId,"URL elicitation requires a non-empty elicitationId."),po(t.url,"URL elicitation requires a non-empty URL.");try{r=new URL(t.url)}catch{throw Error("URL elicitation requires a valid http or https URL.")}if("http:"!==r.protocol&&"https:"!==r.protocol)throw Error("URL elicitation requires a valid http or https URL.")}(t),t;if("form"!==r)throw Error(`Unsupported elicitation mode "${String(t.mode)}". Expected "form" or "url".`);return function(t){pn(t,"Elicitation request must be a plain object."),pi(t,d4,"Form elicitation"),pa(t.message,"Form elicitation requires a string message.");let r=t.requestedSchema;if(pn(r,"Form elicitation requires a flat object schema."),pi(r,d6,"Form elicitation schema"),"object"!==r.type)throw Error('Form elicitation schema must use type "object".');for(let[t,i]of(pn(r.properties,"Form elicitation schema requires a properties object."),Object.entries(r.properties)))!function(t,r){if(pn(r,`Form elicitation field "${t}" must be a plain object.`),ps(r.title,`Form elicitation field "${t}" title must be a string.`),ps(r.description,`Form elicitation field "${t}" description must be a string.`),"string"===r.type&&"enum"in r){var i,n;if(pi(r,d7,`Form elicitation field "${t}"`),pc(r.enum,`Form elicitation field "${t}" enum values must be strings.`),i=r.enumNames,n=`Form elicitation field "${t}" enumNames must be strings.`,void 0!==i&&pc(i,n),void 0!==r.enumNames&&r.enumNames.length!==r.enum.length)throw Error(`Form elicitation field "${t}" enumNames length must match enum length.`);if(ps(r.default,`Form elicitation field "${t}" default must be a string.`),void 0!==r.default&&!r.enum.includes(r.default))throw Error(`Form elicitation field "${t}" default must be one of its enum values.`);return}if("string"===r.type&&!("enum"in r)){pi(r,d5,`Form elicitation field "${t}"`),pl(r.minLength,`Form elicitation field "${t}" minLength must be a number.`),pl(r.maxLength,`Form elicitation field "${t}" maxLength must be a number.`),ps(r.default,`Form elicitation field "${t}" default must be a string.`);let i=r.format;if(ps(i,`Form elicitation field "${t}" format must be a string.`),void 0!==i&&!pt.has(i))throw Error(`Form elicitation field "${t}" format must be one of: ${Array.from(pt).join(", ")}.`);return}if("boolean"===r.type){if(pi(r,d8,`Form elicitation field "${t}"`),void 0!==r.default&&"boolean"!=typeof r.default)throw Error(`Form elicitation field "${t}" default must be a boolean.`);return}if("number"===r.type||"integer"===r.type){pi(r,pe,`Form elicitation field "${t}"`),pl(r.minimum,`Form elicitation field "${t}" minimum must be a number.`),pl(r.maximum,`Form elicitation field "${t}" maximum must be a number.`),pl(r.default,`Form elicitation field "${t}" default must be a number.`);return}throw Error(`Form elicitation field "${t}" uses unsupported type "${String(r.type)}". Supported types are string, boolean, number, integer, and string enums.`)}(t,i);if(void 0!==r.required){if(!Array.isArray(r.required)||r.required.some(t=>"string"!=typeof t))throw Error("Form elicitation schema required fields must be a string array.");for(let t of r.required)if(!(t in r.properties))throw Error(`Form elicitation schema required field "${t}" is not defined in properties.`)}}(t),{...t,mode:"form"}}(r);try{let r=await t.mcpReq.elicitInput(n,i);return{...r,content:r.content??void 0}}catch(t){if(t instanceof lG&&t.code===lW.MethodNotSupportedByProtocolVersion)throw Error("extra.elicit() is not available on protocol revision 2026-07-28: server-initiated elicitation was replaced by multi round-trip requests. Return inputRequired({ ... }) from the tool handler instead (re-exported from xmcp); the client fulfils the embedded requests and retries the tool call.");throw t}}function pi(t,r,i){let n=Object.keys(t).filter(t=>!r.has(t));if(0!==n.length)throw Error(`${i} includes unsupported key(s): ${n.join(", ")}.`)}function pn(t,r){if("object"!=typeof t||null===t||Array.isArray(t))throw Error(r)}function pa(t,r){if("string"!=typeof t)throw Error(r)}function po(t,r){if("string"!=typeof t||0===t.trim().length)throw Error(r)}function ps(t,r){if(void 0!==t&&"string"!=typeof t)throw Error(r)}function pl(t,r){if(void 0!==t&&"number"!=typeof t)throw Error(r)}function pc(t,r){if(!Array.isArray(t)||t.some(t=>"string"!=typeof t))throw Error(r)}let pu=new Set(["_meta","includeContext","maxTokens","messages","metadata","modelPreferences","stopSequences","systemPrompt","temperature"]),pd=new Set(["task","toolChoice","tools"]),pp=new Set(["text","image","audio"]);async function pm(t,r,i){let n=function(t){ph(t,"Sampling request must be a plain object.");let r=Object.keys(t),i=r.filter(t=>pd.has(t));if(i.length>0)throw Error(`Sampling request key(s) not supported by xmcp yet: ${i.join(", ")}.`);let n=r.filter(t=>!pu.has(t));if(n.length>0)throw Error(`Sampling request includes unsupported key(s): ${n.join(", ")}.`);if(!Array.isArray(t.messages)||0===t.messages.length)throw Error("Sampling requires at least one message.");for(let[r,i]of t.messages.entries())!function(t,r){if(ph(r,`Sampling message at index ${t} must be a plain object.`),"user"!==r.role&&"assistant"!==r.role)throw Error(`Sampling message at index ${t} requires role "user" or "assistant".`);let i=r.content;ph(i,`Sampling message at index ${t} requires a content object.`);let n=i.type;if("string"!=typeof n||!pp.has(n))throw Error(`Sampling message at index ${t} uses unsupported content type "${String(n)}". Supported types are text, image, and audio.`);if("text"===n&&"string"!=typeof i.text)throw Error(`Sampling message at index ${t} requires string text content.`);if(("image"===n||"audio"===n)&&("string"!=typeof i.data||"string"!=typeof i.mimeType))throw Error(`Sampling message at index ${t} requires base64 data and a mimeType.`)}(r,i);if("number"!=typeof t.maxTokens)throw Error("Sampling requires a numeric maxTokens.");return t}(r);try{return await t.mcpReq.requestSampling(n,i)}catch(t){if(t instanceof lG&&t.code===lW.MethodNotSupportedByProtocolVersion)throw Error("extra.sample() is not available on protocol revision 2026-07-28: server-initiated sampling was replaced by multi round-trip requests. Return inputRequired({ ... }) with inputRequired.createMessage(...) from the tool handler instead (re-exported from xmcp); the client fulfils the embedded requests and retries the tool call.");throw t}}function ph(t,r){if("object"!=typeof t||null===t||Array.isArray(t))throw Error(r)}let pf={text:t=>"string"!=typeof t.text?{valid:!1,error:'Text content must have a "text" property of type string'}:{valid:!0},image:t=>"string"!=typeof t.data?{valid:!1,error:'Image content must have a "data" property of type string (base64-encoded image)'}:"string"!=typeof t.mimeType?{valid:!1,error:'Image content must have a "mimeType" property of type string'}:{valid:!0},audio:t=>"string"!=typeof t.data?{valid:!1,error:'Audio content must have a "data" property of type string (base64-encoded audio)'}:"string"!=typeof t.mimeType?{valid:!1,error:'Audio content must have a "mimeType" property of type string'}:{valid:!0},resource_link:t=>"string"!=typeof t.name?{valid:!1,error:'Resource link content must have a "name" property of type string'}:"string"!=typeof t.uri?{valid:!1,error:'Resource link content must have a "uri" property of type string'}:void 0!==t.title&&"string"!=typeof t.title?{valid:!1,error:'Resource link "title" property must be a string if provided'}:void 0!==t.description&&"string"!=typeof t.description?{valid:!1,error:'Resource link "description" property must be a string if provided'}:void 0!==t.mimeType&&"string"!=typeof t.mimeType?{valid:!1,error:'Resource link "mimeType" property must be a string if provided'}:{valid:!0}};function pg(t){if(!t||"object"!=typeof t)return{valid:!1,error:"Content must be an object"};if("string"!=typeof t.type)return{valid:!1,error:'Content must have a "type" property of type string'};if(void 0!==t._meta&&(null===t._meta||"object"!=typeof t._meta))return{valid:!1,error:'Content "_meta" property must be an object if provided'};let r=pf[t.type];return r?r(t):{valid:!0}}function py(t,r,i,n){if(null===t||"object"!=typeof t||Array.isArray(t))throw Error(`Tool "${i}" ${n}: expected a plain object.`);let a=new Set(Object.keys(r)),o=Object.keys(t).filter(t=>!a.has(t));if(o.length>0)throw Error(`Tool "${i}" ${n}: unrecognized key(s): ${o.join(", ")}`);for(let[a,o]of Object.entries(r))try{o.parse(t[a])}catch(t){throw Error(`Tool "${i}" ${n}: ${t?.message??`invalid field "${a}"`}`)}}function pv(t){return!!(t&&"object"==typeof t&&Object.keys(t).some(t=>t.startsWith("ui/")))}function p_(t){let r=t.mcpReq.envelope,i=dK(r?.[aK]);if(!i)try{let t,r=dB();i=r.clientInfo??(t=r.headers,dK({name:dX(t,"x-mcp-client-name"),version:dX(t,"x-mcp-client-version"),title:dX(t,"x-mcp-client-title"),websiteUrl:dX(t,"x-mcp-client-website-url"),description:dX(t,"x-mcp-client-description")}))}catch{}if(!i)try{i=d9().clientInfo}catch{}return i}function pb(t){let r=[...t];return(t,i,n)=>(function(t,r,i){let n,a=new Map;if(t.http){let t=dB(),r=Object.fromEntries(Object.entries(t.headers).map(([t,r])=>[t,Array.isArray(r)?Object.freeze([...r]):r]));n=Object.freeze({id:t.id,headers:Object.freeze(r)})}return d1.provider(Object.freeze({clientInfo:r?Object.freeze({...r}):void 0,http:n,authInfo:t.http?.authInfo,signal:t.mcpReq.signal,set(t,r){a.set(t,r)},get:t=>a.get(t),async progress(r,i){let n=t.mcpReq._meta?.progressToken;void 0!==n&&await t.mcpReq.notify({method:"notifications/progress",params:{progressToken:n,progress:r,...void 0===i?{}:{total:i}}})},log:(r,i)=>t.mcpReq.log(r,i)}),i)})(i,p_(i),async()=>{if(0===r.length)return n();let i=Object.freeze({...function(){try{return d1.getContext()}catch{throw Error("getRequestContext() can only be used while handling an MCP request.")}}(),...t,params:Object.freeze({...t.params})}),a=-1,o=async t=>{if(t<=a)throw Error("MCP middleware next() can only be called once");a=t;let s=r[t];return s?s(i,()=>o(t+1)):n()};return o(0)})}let pS=new Set(["tools/list","prompts/get","prompts/list","resources/read","resources/list","resources/templates/list","completion/complete"]);function pw(t){return t.endsWith(".tsx")}let pR=Symbol("Let zodToJsonSchema decide on which parser to use"),pk={name:void 0,$refStrategy:"root",basePath:["#"],effectStrategy:"input",pipeStrategy:"all",dateStrategy:"format:date-time",mapStrategy:"entries",removeAdditionalStrategy:"passthrough",allowedAdditionalProperties:!0,rejectedAdditionalProperties:!1,definitionPath:"definitions",target:"jsonSchema7",strictUnions:!1,definitions:{},errorMessages:!1,markdownDescription:!1,patternStrategy:"escape",applyRegexFlags:!1,emailStrategy:"format:email",base64Strategy:"contentEncoding:base64",nameStrategy:"ref",openAiAnyTypeName:"OpenAiAnyType"};(P=z||(z={})).assertEqual=t=>{},P.assertIs=function(t){},P.assertNever=function(t){throw Error()},P.arrayToEnum=t=>{let r={};for(let i of t)r[i]=i;return r},P.getValidEnumValues=t=>{let r=P.objectKeys(t).filter(r=>"number"!=typeof t[t[r]]),i={};for(let n of r)i[n]=t[n];return P.objectValues(i)},P.objectValues=t=>P.objectKeys(t).map(function(r){return t[r]}),P.objectKeys="function"==typeof Object.keys?t=>Object.keys(t):t=>{let r=[];for(let i in t)Object.prototype.hasOwnProperty.call(t,i)&&r.push(i);return r},P.find=(t,r)=>{for(let i of t)if(r(i))return i},P.isInteger="function"==typeof Number.isInteger?t=>Number.isInteger(t):t=>"number"==typeof t&&Number.isFinite(t)&&Math.floor(t)===t,P.joinValues=function(t,r=" | "){return t.map(t=>"string"==typeof t?`'${t}'`:t).join(r)},P.jsonStringifyReplacer=(t,r)=>"bigint"==typeof r?r.toString():r,(N||(N={})).mergeShapes=(t,r)=>({...t,...r});let px=z.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),p$=t=>{switch(typeof t){case"undefined":return px.undefined;case"string":return px.string;case"number":return Number.isNaN(t)?px.nan:px.number;case"boolean":return px.boolean;case"function":return px.function;case"bigint":return px.bigint;case"symbol":return px.symbol;case"object":if(Array.isArray(t))return px.array;if(null===t)return px.null;if(t.then&&"function"==typeof t.then&&t.catch&&"function"==typeof t.catch)return px.promise;if("undefined"!=typeof Map&&t instanceof Map)return px.map;if("undefined"!=typeof Set&&t instanceof Set)return px.set;if("undefined"!=typeof Date&&t instanceof Date)return px.date;return px.object;default:return px.unknown}},pT=z.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]);class pC extends Error{get errors(){return this.issues}constructor(t){super(),this.issues=[],this.addIssue=t=>{this.issues=[...this.issues,t]},this.addIssues=(t=[])=>{this.issues=[...this.issues,...t]};let r=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,r):this.__proto__=r,this.name="ZodError",this.issues=t}format(t){let r=t||function(t){return t.message},i={_errors:[]},n=t=>{for(let a of t.issues)if("invalid_union"===a.code)a.unionErrors.map(n);else if("invalid_return_type"===a.code)n(a.returnTypeError);else if("invalid_arguments"===a.code)n(a.argumentsError);else if(0===a.path.length)i._errors.push(r(a));else{let t=i,n=0;for(;n<a.path.length;){let i=a.path[n],o=n===a.path.length-1;if("_errors"===i){o&&t._errors.push(r(a)),n++;continue}Object.prototype.hasOwnProperty.call(t,i)||("__proto__"===i?Object.defineProperty(t,i,{value:{_errors:[]},writable:!0,enumerable:!0,configurable:!0}):t[i]={_errors:[]}),t=t[i],o&&t._errors.push(r(a)),n++}}};return n(this),i}static assert(t){if(!(t instanceof pC))throw Error(`Not a ZodError: ${t}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,z.jsonStringifyReplacer,2)}get isEmpty(){return 0===this.issues.length}flatten(t=t=>t.message){let r=Object.create(null),i=[];for(let n of this.issues)if(n.path.length>0){let i=n.path[0];r[i]=r[i]||[],r[i].push(t(n))}else i.push(t(n));return{formErrors:i,fieldErrors:r}}get formErrors(){return this.flatten()}}pC.create=t=>new pC(t);let pE=(t,r)=>{let i;switch(t.code){case pT.invalid_type:i=t.received===px.undefined?"Required":`Expected ${t.expected}, received ${t.received}`;break;case pT.invalid_literal:i=`Invalid literal value, expected ${JSON.stringify(t.expected,z.jsonStringifyReplacer)}`;break;case pT.unrecognized_keys:i=`Unrecognized key(s) in object: ${z.joinValues(t.keys,", ")}`;break;case pT.invalid_union:i="Invalid input";break;case pT.invalid_union_discriminator:i=`Invalid discriminator value. Expected ${z.joinValues(t.options)}`;break;case pT.invalid_enum_value:i=`Invalid enum value. Expected ${z.joinValues(t.options)}, received '${t.received}'`;break;case pT.invalid_arguments:i="Invalid function arguments";break;case pT.invalid_return_type:i="Invalid function return type";break;case pT.invalid_date:i="Invalid date";break;case pT.invalid_string:"object"==typeof t.validation?"includes"in t.validation?(i=`Invalid input: must include "${t.validation.includes}"`,"number"==typeof t.validation.position&&(i=`${i} at one or more positions greater than or equal to ${t.validation.position}`)):"startsWith"in t.validation?i=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?i=`Invalid input: must end with "${t.validation.endsWith}"`:z.assertNever(t.validation):i="regex"!==t.validation?`Invalid ${t.validation}`:"Invalid";break;case pT.too_small:i="array"===t.type?`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:"string"===t.type?`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:"number"===t.type||"bigint"===t.type?`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:"date"===t.type?`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(t.minimum))}`:"Invalid input";break;case pT.too_big:i="array"===t.type?`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:"string"===t.type?`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:"number"===t.type?`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:"bigint"===t.type?`BigInt must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:"date"===t.type?`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(t.maximum))}`:"Invalid input";break;case pT.custom:i="Invalid input";break;case pT.invalid_intersection_types:i="Intersection results could not be merged";break;case pT.not_multiple_of:i=`Number must be a multiple of ${t.multipleOf}`;break;case pT.not_finite:i="Number must be finite";break;default:i=r.defaultError,z.assertNever(t)}return{message:i}};(O=M||(M={})).errToObj=t=>"string"==typeof t?{message:t}:t||{},O.toString=t=>"string"==typeof t?t:t?.message;let pP=t=>{let{data:r,path:i,errorMaps:n,issueData:a}=t,o=[...i,...a.path||[]],s={...a,path:o};if(void 0!==a.message)return{...a,path:o,message:a.message};let l="";for(let t of n.filter(t=>!!t).slice().reverse())l=t(s,{data:r,defaultError:l}).message;return{...a,path:o,message:l}};function pO(t,r){let i=pP({issueData:r,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,pE,void 0].filter(t=>!!t)});t.common.issues.push(i)}class pI{constructor(){this.value="valid"}dirty(){"valid"===this.value&&(this.value="dirty")}abort(){"aborted"!==this.value&&(this.value="aborted")}static mergeArray(t,r){let i=[];for(let n of r){if("aborted"===n.status)return pq;"dirty"===n.status&&t.dirty(),i.push(n.value)}return{status:t.value,value:i}}static async mergeObjectAsync(t,r){let i=[];for(let t of r){let r=await t.key,n=await t.value;i.push({key:r,value:n})}return pI.mergeObjectSync(t,i)}static mergeObjectSync(t,r){let i={};for(let n of r){let{key:r,value:a}=n;if("aborted"===r.status||"aborted"===a.status)return pq;"dirty"===r.status&&t.dirty(),"dirty"===a.status&&t.dirty(),"__proto__"!==r.value&&(void 0!==a.value||n.alwaysSet)&&(i[r.value]=a.value)}return{status:t.value,value:i}}}let pq=Object.freeze({status:"aborted"}),pj=t=>({status:"dirty",value:t}),pA=t=>({status:"valid",value:t}),pz=t=>"undefined"!=typeof Promise&&t instanceof Promise;class pN{constructor(t,r,i,n){this._cachedPath=[],this.parent=t,this.data=r,this._path=i,this._key=n}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}let pM=(t,r)=>{if("valid"===r.status)return{success:!0,data:r.value};if(!t.common.issues.length)throw Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let r=new pC(t.common.issues);return this._error=r,this._error}}};function pL(t){if(!t)return{};let{errorMap:r,invalid_type_error:i,required_error:n,description:a}=t;if(r&&(i||n))throw Error('Can\'t use "invalid_type_error" or "required_error" in conjunction with custom error map.');return r?{errorMap:r,description:a}:{errorMap:(r,a)=>{let{message:o}=t;return"invalid_enum_value"===r.code?{message:o??a.defaultError}:void 0===a.data?{message:o??n??a.defaultError}:"invalid_type"!==r.code?{message:a.defaultError}:{message:o??i??a.defaultError}},description:a}}class pZ{get description(){return this._def.description}_getType(t){return p$(t.data)}_getOrReturnCtx(t,r){return r||{common:t.parent.common,data:t.data,parsedType:p$(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}_processInputParams(t){return{status:new pI,ctx:{common:t.parent.common,data:t.data,parsedType:p$(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}}_parseSync(t){let r=this._parse(t);if(pz(r))throw Error("Synchronous parse encountered promise.");return r}_parseAsync(t){return Promise.resolve(this._parse(t))}parse(t,r){let i=this.safeParse(t,r);if(i.success)return i.data;throw i.error}safeParse(t,r){let i={common:{issues:[],async:r?.async??!1,contextualErrorMap:r?.errorMap},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:p$(t)},n=this._parseSync({data:t,path:i.path,parent:i});return pM(i,n)}"~validate"(t){let r={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:p$(t)};if(!this["~standard"].async)try{let i=this._parseSync({data:t,path:[],parent:r});return"valid"===i.status?{value:i.value}:{issues:r.common.issues}}catch(t){t?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),r.common={issues:[],async:!0}}return this._parseAsync({data:t,path:[],parent:r}).then(t=>"valid"===t.status?{value:t.value}:{issues:r.common.issues})}async parseAsync(t,r){let i=await this.safeParseAsync(t,r);if(i.success)return i.data;throw i.error}async safeParseAsync(t,r){let i={common:{issues:[],contextualErrorMap:r?.errorMap,async:!0},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:p$(t)},n=this._parse({data:t,path:i.path,parent:i});return pM(i,await (pz(n)?n:Promise.resolve(n)))}refine(t,r){return this._refinement((i,n)=>{let a=t(i),o=()=>n.addIssue({code:pT.custom,..."string"==typeof r||void 0===r?{message:r}:"function"==typeof r?r(i):r});return"undefined"!=typeof Promise&&a instanceof Promise?a.then(t=>!!t||(o(),!1)):!!a||(o(),!1)})}refinement(t,r){return this._refinement((i,n)=>!!t(i)||(n.addIssue("function"==typeof r?r(i,n):r),!1))}_refinement(t){return new mR({schema:this,typeName:L.ZodEffects,effect:{type:"refinement",refinement:t}})}superRefine(t){return this._refinement(t)}constructor(t){this.spa=this.safeParseAsync,this._def=t,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:t=>this["~validate"](t)}}optional(){return mk.create(this,this._def)}nullable(){return mx.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return mo.create(this)}promise(){return mw.create(this,this._def)}or(t){return ml.create([this,t],this._def)}and(t){return md.create(this,t,this._def)}transform(t){return new mR({...pL(this._def),schema:this,typeName:L.ZodEffects,effect:{type:"transform",transform:t}})}default(t){return new m$({...pL(this._def),innerType:this,defaultValue:"function"==typeof t?t:()=>t,typeName:L.ZodDefault})}brand(){return new mE({typeName:L.ZodBranded,type:this,...pL(this._def)})}catch(t){return new mT({...pL(this._def),innerType:this,catchValue:"function"==typeof t?t:()=>t,typeName:L.ZodCatch})}describe(t){return new this.constructor({...this._def,description:t})}pipe(t){return mP.create(this,t)}readonly(){return mO.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}let pU=/^c[^\s-]{8,}$/i,pF=/^[0-9a-z]+$/,pD=/^[0-9A-HJKMNP-TV-Z]{26}$/i,pH=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,pJ=/^[a-z0-9_-]{21}$/i,pV=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,pB=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,pW=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,pG=/^(?:(?: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])$/,pK=/^(?:(?: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])\/(3[0-2]|[12]?[0-9])$/,pY=/^(([0-9a-fA-F]{1,4}:){7,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}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,pX=/^(([0-9a-fA-F]{1,4}:){7,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}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,pQ=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,p0=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,p1="((\\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])))",p2=RegExp(`^${p1}$`);function p9(t){let r="[0-5]\\d";t.precision?r=`${r}\\.\\d{${t.precision}}`:null==t.precision&&(r=`${r}(\\.\\d+)?`);let i=t.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${r})${i}`}class p4 extends pZ{_parse(t){var r,i,n,a;let o;if(this._def.coerce&&(t.data=String(t.data)),this._getType(t)!==px.string){let r=this._getOrReturnCtx(t);return pO(r,{code:pT.invalid_type,expected:px.string,received:r.parsedType}),pq}let s=new pI;for(let l of this._def.checks)if("min"===l.kind)t.data.length<l.value&&(pO(o=this._getOrReturnCtx(t,o),{code:pT.too_small,minimum:l.value,type:"string",inclusive:!0,exact:!1,message:l.message}),s.dirty());else if("max"===l.kind)t.data.length>l.value&&(pO(o=this._getOrReturnCtx(t,o),{code:pT.too_big,maximum:l.value,type:"string",inclusive:!0,exact:!1,message:l.message}),s.dirty());else if("length"===l.kind){let r=t.data.length>l.value,i=t.data.length<l.value;(r||i)&&(o=this._getOrReturnCtx(t,o),r?pO(o,{code:pT.too_big,maximum:l.value,type:"string",inclusive:!0,exact:!0,message:l.message}):i&&pO(o,{code:pT.too_small,minimum:l.value,type:"string",inclusive:!0,exact:!0,message:l.message}),s.dirty())}else if("email"===l.kind)pW.test(t.data)||(pO(o=this._getOrReturnCtx(t,o),{validation:"email",code:pT.invalid_string,message:l.message}),s.dirty());else if("emoji"===l.kind)p||(p=RegExp("^[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$","u")),p.test(t.data)||(pO(o=this._getOrReturnCtx(t,o),{validation:"emoji",code:pT.invalid_string,message:l.message}),s.dirty());else if("uuid"===l.kind)pH.test(t.data)||(pO(o=this._getOrReturnCtx(t,o),{validation:"uuid",code:pT.invalid_string,message:l.message}),s.dirty());else if("nanoid"===l.kind)pJ.test(t.data)||(pO(o=this._getOrReturnCtx(t,o),{validation:"nanoid",code:pT.invalid_string,message:l.message}),s.dirty());else if("cuid"===l.kind)pU.test(t.data)||(pO(o=this._getOrReturnCtx(t,o),{validation:"cuid",code:pT.invalid_string,message:l.message}),s.dirty());else if("cuid2"===l.kind)pF.test(t.data)||(pO(o=this._getOrReturnCtx(t,o),{validation:"cuid2",code:pT.invalid_string,message:l.message}),s.dirty());else if("ulid"===l.kind)pD.test(t.data)||(pO(o=this._getOrReturnCtx(t,o),{validation:"ulid",code:pT.invalid_string,message:l.message}),s.dirty());else if("url"===l.kind)try{new URL(t.data)}catch{pO(o=this._getOrReturnCtx(t,o),{validation:"url",code:pT.invalid_string,message:l.message}),s.dirty()}else"regex"===l.kind?(l.regex.lastIndex=0,l.regex.test(t.data)||(pO(o=this._getOrReturnCtx(t,o),{validation:"regex",code:pT.invalid_string,message:l.message}),s.dirty())):"trim"===l.kind?t.data=t.data.trim():"includes"===l.kind?t.data.includes(l.value,l.position)||(pO(o=this._getOrReturnCtx(t,o),{code:pT.invalid_string,validation:{includes:l.value,position:l.position},message:l.message}),s.dirty()):"toLowerCase"===l.kind?t.data=t.data.toLowerCase():"toUpperCase"===l.kind?t.data=t.data.toUpperCase():"startsWith"===l.kind?t.data.startsWith(l.value)||(pO(o=this._getOrReturnCtx(t,o),{code:pT.invalid_string,validation:{startsWith:l.value},message:l.message}),s.dirty()):"endsWith"===l.kind?t.data.endsWith(l.value)||(pO(o=this._getOrReturnCtx(t,o),{code:pT.invalid_string,validation:{endsWith:l.value},message:l.message}),s.dirty()):"datetime"===l.kind?(function(t){let r=`${p1}T${p9(t)}`,i=[];return i.push(t.local?"Z?":"Z"),t.offset&&i.push("([+-]\\d{2}:?\\d{2})"),r=`${r}(${i.join("|")})`,RegExp(`^${r}$`)})(l).test(t.data)||(pO(o=this._getOrReturnCtx(t,o),{code:pT.invalid_string,validation:"datetime",message:l.message}),s.dirty()):"date"===l.kind?p2.test(t.data)||(pO(o=this._getOrReturnCtx(t,o),{code:pT.invalid_string,validation:"date",message:l.message}),s.dirty()):"time"===l.kind?RegExp(`^${p9(l)}$`).test(t.data)||(pO(o=this._getOrReturnCtx(t,o),{code:pT.invalid_string,validation:"time",message:l.message}),s.dirty()):"duration"===l.kind?pB.test(t.data)||(pO(o=this._getOrReturnCtx(t,o),{validation:"duration",code:pT.invalid_string,message:l.message}),s.dirty()):"ip"===l.kind?(r=t.data,!(("v4"===(i=l.version)||!i)&&pG.test(r)||("v6"===i||!i)&&pY.test(r))&&1&&(pO(o=this._getOrReturnCtx(t,o),{validation:"ip",code:pT.invalid_string,message:l.message}),s.dirty())):"jwt"===l.kind?!function(t,r){if(!pV.test(t))return!1;try{let[i]=t.split(".");if(!i)return!1;let n=i.replace(/-/g,"+").replace(/_/g,"/").padEnd(i.length+(4-i.length%4)%4,"="),a=JSON.parse(atob(n));if("object"!=typeof a||null===a||"typ"in a&&a?.typ!=="JWT"||!a.alg||r&&a.alg!==r)return!1;return!0}catch{return!1}}(t.data,l.alg)&&(pO(o=this._getOrReturnCtx(t,o),{validation:"jwt",code:pT.invalid_string,message:l.message}),s.dirty()):"cidr"===l.kind?(n=t.data,!(("v4"===(a=l.version)||!a)&&pK.test(n)||("v6"===a||!a)&&pX.test(n))&&1&&(pO(o=this._getOrReturnCtx(t,o),{validation:"cidr",code:pT.invalid_string,message:l.message}),s.dirty())):"base64"===l.kind?pQ.test(t.data)||(pO(o=this._getOrReturnCtx(t,o),{validation:"base64",code:pT.invalid_string,message:l.message}),s.dirty()):"base64url"===l.kind?p0.test(t.data)||(pO(o=this._getOrReturnCtx(t,o),{validation:"base64url",code:pT.invalid_string,message:l.message}),s.dirty()):z.assertNever(l);return{status:s.value,value:t.data}}_regex(t,r,i){return this.refinement(r=>t.test(r),{validation:r,code:pT.invalid_string,...M.errToObj(i)})}_addCheck(t){return new p4({...this._def,checks:[...this._def.checks,t]})}email(t){return this._addCheck({kind:"email",...M.errToObj(t)})}url(t){return this._addCheck({kind:"url",...M.errToObj(t)})}emoji(t){return this._addCheck({kind:"emoji",...M.errToObj(t)})}uuid(t){return this._addCheck({kind:"uuid",...M.errToObj(t)})}nanoid(t){return this._addCheck({kind:"nanoid",...M.errToObj(t)})}cuid(t){return this._addCheck({kind:"cuid",...M.errToObj(t)})}cuid2(t){return this._addCheck({kind:"cuid2",...M.errToObj(t)})}ulid(t){return this._addCheck({kind:"ulid",...M.errToObj(t)})}base64(t){return this._addCheck({kind:"base64",...M.errToObj(t)})}base64url(t){return this._addCheck({kind:"base64url",...M.errToObj(t)})}jwt(t){return this._addCheck({kind:"jwt",...M.errToObj(t)})}ip(t){return this._addCheck({kind:"ip",...M.errToObj(t)})}cidr(t){return this._addCheck({kind:"cidr",...M.errToObj(t)})}datetime(t){return"string"==typeof t?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:t}):this._addCheck({kind:"datetime",precision:void 0===t?.precision?null:t?.precision,offset:t?.offset??!1,local:t?.local??!1,...M.errToObj(t?.message)})}date(t){return this._addCheck({kind:"date",message:t})}time(t){return"string"==typeof t?this._addCheck({kind:"time",precision:null,message:t}):this._addCheck({kind:"time",precision:void 0===t?.precision?null:t?.precision,...M.errToObj(t?.message)})}duration(t){return this._addCheck({kind:"duration",...M.errToObj(t)})}regex(t,r){return this._addCheck({kind:"regex",regex:t,...M.errToObj(r)})}includes(t,r){return this._addCheck({kind:"includes",value:t,position:r?.position,...M.errToObj(r?.message)})}startsWith(t,r){return this._addCheck({kind:"startsWith",value:t,...M.errToObj(r)})}endsWith(t,r){return this._addCheck({kind:"endsWith",value:t,...M.errToObj(r)})}min(t,r){return this._addCheck({kind:"min",value:t,...M.errToObj(r)})}max(t,r){return this._addCheck({kind:"max",value:t,...M.errToObj(r)})}length(t,r){return this._addCheck({kind:"length",value:t,...M.errToObj(r)})}nonempty(t){return this.min(1,M.errToObj(t))}trim(){return new p4({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new p4({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new p4({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(t=>"datetime"===t.kind)}get isDate(){return!!this._def.checks.find(t=>"date"===t.kind)}get isTime(){return!!this._def.checks.find(t=>"time"===t.kind)}get isDuration(){return!!this._def.checks.find(t=>"duration"===t.kind)}get isEmail(){return!!this._def.checks.find(t=>"email"===t.kind)}get isURL(){return!!this._def.checks.find(t=>"url"===t.kind)}get isEmoji(){return!!this._def.checks.find(t=>"emoji"===t.kind)}get isUUID(){return!!this._def.checks.find(t=>"uuid"===t.kind)}get isNANOID(){return!!this._def.checks.find(t=>"nanoid"===t.kind)}get isCUID(){return!!this._def.checks.find(t=>"cuid"===t.kind)}get isCUID2(){return!!this._def.checks.find(t=>"cuid2"===t.kind)}get isULID(){return!!this._def.checks.find(t=>"ulid"===t.kind)}get isIP(){return!!this._def.checks.find(t=>"ip"===t.kind)}get isCIDR(){return!!this._def.checks.find(t=>"cidr"===t.kind)}get isBase64(){return!!this._def.checks.find(t=>"base64"===t.kind)}get isBase64url(){return!!this._def.checks.find(t=>"base64url"===t.kind)}get minLength(){let t=null;for(let r of this._def.checks)"min"===r.kind&&(null===t||r.value>t)&&(t=r.value);return t}get maxLength(){let t=null;for(let r of this._def.checks)"max"===r.kind&&(null===t||r.value<t)&&(t=r.value);return t}}p4.create=t=>new p4({checks:[],typeName:L.ZodString,coerce:t?.coerce??!1,...pL(t)});class p3 extends pZ{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(t){let r;if(this._def.coerce&&(t.data=Number(t.data)),this._getType(t)!==px.number){let r=this._getOrReturnCtx(t);return pO(r,{code:pT.invalid_type,expected:px.number,received:r.parsedType}),pq}let i=new pI;for(let n of this._def.checks)"int"===n.kind?z.isInteger(t.data)||(pO(r=this._getOrReturnCtx(t,r),{code:pT.invalid_type,expected:"integer",received:"float",message:n.message}),i.dirty()):"min"===n.kind?(n.inclusive?t.data<n.value:t.data<=n.value)&&(pO(r=this._getOrReturnCtx(t,r),{code:pT.too_small,minimum:n.value,type:"number",inclusive:n.inclusive,exact:!1,message:n.message}),i.dirty()):"max"===n.kind?(n.inclusive?t.data>n.value:t.data>=n.value)&&(pO(r=this._getOrReturnCtx(t,r),{code:pT.too_big,maximum:n.value,type:"number",inclusive:n.inclusive,exact:!1,message:n.message}),i.dirty()):"multipleOf"===n.kind?0!==function(t,r){let i=(t.toString().split(".")[1]||"").length,n=(r.toString().split(".")[1]||"").length,a=i>n?i:n;return Number.parseInt(t.toFixed(a).replace(".",""))%Number.parseInt(r.toFixed(a).replace(".",""))/10**a}(t.data,n.value)&&(pO(r=this._getOrReturnCtx(t,r),{code:pT.not_multiple_of,multipleOf:n.value,message:n.message}),i.dirty()):"finite"===n.kind?Number.isFinite(t.data)||(pO(r=this._getOrReturnCtx(t,r),{code:pT.not_finite,message:n.message}),i.dirty()):z.assertNever(n);return{status:i.value,value:t.data}}gte(t,r){return this.setLimit("min",t,!0,M.toString(r))}gt(t,r){return this.setLimit("min",t,!1,M.toString(r))}lte(t,r){return this.setLimit("max",t,!0,M.toString(r))}lt(t,r){return this.setLimit("max",t,!1,M.toString(r))}setLimit(t,r,i,n){return new p3({...this._def,checks:[...this._def.checks,{kind:t,value:r,inclusive:i,message:M.toString(n)}]})}_addCheck(t){return new p3({...this._def,checks:[...this._def.checks,t]})}int(t){return this._addCheck({kind:"int",message:M.toString(t)})}positive(t){return this._addCheck({kind:"min",value:0,inclusive:!1,message:M.toString(t)})}negative(t){return this._addCheck({kind:"max",value:0,inclusive:!1,message:M.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:0,inclusive:!0,message:M.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:0,inclusive:!0,message:M.toString(t)})}multipleOf(t,r){return this._addCheck({kind:"multipleOf",value:t,message:M.toString(r)})}finite(t){return this._addCheck({kind:"finite",message:M.toString(t)})}safe(t){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:M.toString(t)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:M.toString(t)})}get minValue(){let t=null;for(let r of this._def.checks)"min"===r.kind&&(null===t||r.value>t)&&(t=r.value);return t}get maxValue(){let t=null;for(let r of this._def.checks)"max"===r.kind&&(null===t||r.value<t)&&(t=r.value);return t}get isInt(){return!!this._def.checks.find(t=>"int"===t.kind||"multipleOf"===t.kind&&z.isInteger(t.value))}get isFinite(){let t=null,r=null;for(let i of this._def.checks)if("finite"===i.kind||"int"===i.kind||"multipleOf"===i.kind)return!0;else"min"===i.kind?(null===r||i.value>r)&&(r=i.value):"max"===i.kind&&(null===t||i.value<t)&&(t=i.value);return Number.isFinite(r)&&Number.isFinite(t)}}p3.create=t=>new p3({checks:[],typeName:L.ZodNumber,coerce:t?.coerce||!1,...pL(t)});class p6 extends pZ{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(t){let r;if(this._def.coerce)try{t.data=BigInt(t.data)}catch{return this._getInvalidInput(t)}if(this._getType(t)!==px.bigint)return this._getInvalidInput(t);let i=new pI;for(let n of this._def.checks)"min"===n.kind?(n.inclusive?t.data<n.value:t.data<=n.value)&&(pO(r=this._getOrReturnCtx(t,r),{code:pT.too_small,type:"bigint",minimum:n.value,inclusive:n.inclusive,message:n.message}),i.dirty()):"max"===n.kind?(n.inclusive?t.data>n.value:t.data>=n.value)&&(pO(r=this._getOrReturnCtx(t,r),{code:pT.too_big,type:"bigint",maximum:n.value,inclusive:n.inclusive,message:n.message}),i.dirty()):"multipleOf"===n.kind?t.data%n.value!==BigInt(0)&&(pO(r=this._getOrReturnCtx(t,r),{code:pT.not_multiple_of,multipleOf:n.value,message:n.message}),i.dirty()):z.assertNever(n);return{status:i.value,value:t.data}}_getInvalidInput(t){let r=this._getOrReturnCtx(t);return pO(r,{code:pT.invalid_type,expected:px.bigint,received:r.parsedType}),pq}gte(t,r){return this.setLimit("min",t,!0,M.toString(r))}gt(t,r){return this.setLimit("min",t,!1,M.toString(r))}lte(t,r){return this.setLimit("max",t,!0,M.toString(r))}lt(t,r){return this.setLimit("max",t,!1,M.toString(r))}setLimit(t,r,i,n){return new p6({...this._def,checks:[...this._def.checks,{kind:t,value:r,inclusive:i,message:M.toString(n)}]})}_addCheck(t){return new p6({...this._def,checks:[...this._def.checks,t]})}positive(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:M.toString(t)})}negative(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:M.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:M.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:M.toString(t)})}multipleOf(t,r){return this._addCheck({kind:"multipleOf",value:t,message:M.toString(r)})}get minValue(){let t=null;for(let r of this._def.checks)"min"===r.kind&&(null===t||r.value>t)&&(t=r.value);return t}get maxValue(){let t=null;for(let r of this._def.checks)"max"===r.kind&&(null===t||r.value<t)&&(t=r.value);return t}}p6.create=t=>new p6({checks:[],typeName:L.ZodBigInt,coerce:t?.coerce??!1,...pL(t)});class p5 extends pZ{_parse(t){if(this._def.coerce&&(t.data=!!t.data),this._getType(t)!==px.boolean){let r=this._getOrReturnCtx(t);return pO(r,{code:pT.invalid_type,expected:px.boolean,received:r.parsedType}),pq}return pA(t.data)}}p5.create=t=>new p5({typeName:L.ZodBoolean,coerce:t?.coerce||!1,...pL(t)});class p7 extends pZ{_parse(t){let r;if(this._def.coerce&&(t.data=new Date(t.data)),this._getType(t)!==px.date){let r=this._getOrReturnCtx(t);return pO(r,{code:pT.invalid_type,expected:px.date,received:r.parsedType}),pq}if(Number.isNaN(t.data.getTime()))return pO(this._getOrReturnCtx(t),{code:pT.invalid_date}),pq;let i=new pI;for(let n of this._def.checks)"min"===n.kind?t.data.getTime()<n.value&&(pO(r=this._getOrReturnCtx(t,r),{code:pT.too_small,message:n.message,inclusive:!0,exact:!1,minimum:n.value,type:"date"}),i.dirty()):"max"===n.kind?t.data.getTime()>n.value&&(pO(r=this._getOrReturnCtx(t,r),{code:pT.too_big,message:n.message,inclusive:!0,exact:!1,maximum:n.value,type:"date"}),i.dirty()):z.assertNever(n);return{status:i.value,value:new Date(t.data.getTime())}}_addCheck(t){return new p7({...this._def,checks:[...this._def.checks,t]})}min(t,r){return this._addCheck({kind:"min",value:t.getTime(),message:M.toString(r)})}max(t,r){return this._addCheck({kind:"max",value:t.getTime(),message:M.toString(r)})}get minDate(){let t=null;for(let r of this._def.checks)"min"===r.kind&&(null===t||r.value>t)&&(t=r.value);return null!=t?new Date(t):null}get maxDate(){let t=null;for(let r of this._def.checks)"max"===r.kind&&(null===t||r.value<t)&&(t=r.value);return null!=t?new Date(t):null}}p7.create=t=>new p7({checks:[],coerce:t?.coerce||!1,typeName:L.ZodDate,...pL(t)});class p8 extends pZ{_parse(t){if(this._getType(t)!==px.symbol){let r=this._getOrReturnCtx(t);return pO(r,{code:pT.invalid_type,expected:px.symbol,received:r.parsedType}),pq}return pA(t.data)}}p8.create=t=>new p8({typeName:L.ZodSymbol,...pL(t)});class me extends pZ{_parse(t){if(this._getType(t)!==px.undefined){let r=this._getOrReturnCtx(t);return pO(r,{code:pT.invalid_type,expected:px.undefined,received:r.parsedType}),pq}return pA(t.data)}}me.create=t=>new me({typeName:L.ZodUndefined,...pL(t)});class mt extends pZ{_parse(t){if(this._getType(t)!==px.null){let r=this._getOrReturnCtx(t);return pO(r,{code:pT.invalid_type,expected:px.null,received:r.parsedType}),pq}return pA(t.data)}}mt.create=t=>new mt({typeName:L.ZodNull,...pL(t)});class mr extends pZ{constructor(){super(...arguments),this._any=!0}_parse(t){return pA(t.data)}}mr.create=t=>new mr({typeName:L.ZodAny,...pL(t)});class mi extends pZ{constructor(){super(...arguments),this._unknown=!0}_parse(t){return pA(t.data)}}mi.create=t=>new mi({typeName:L.ZodUnknown,...pL(t)});class mn extends pZ{_parse(t){let r=this._getOrReturnCtx(t);return pO(r,{code:pT.invalid_type,expected:px.never,received:r.parsedType}),pq}}mn.create=t=>new mn({typeName:L.ZodNever,...pL(t)});class ma extends pZ{_parse(t){if(this._getType(t)!==px.undefined){let r=this._getOrReturnCtx(t);return pO(r,{code:pT.invalid_type,expected:px.void,received:r.parsedType}),pq}return pA(t.data)}}ma.create=t=>new ma({typeName:L.ZodVoid,...pL(t)});class mo extends pZ{_parse(t){let{ctx:r,status:i}=this._processInputParams(t),n=this._def;if(r.parsedType!==px.array)return pO(r,{code:pT.invalid_type,expected:px.array,received:r.parsedType}),pq;if(null!==n.exactLength){let t=r.data.length>n.exactLength.value,a=r.data.length<n.exactLength.value;(t||a)&&(pO(r,{code:t?pT.too_big:pT.too_small,minimum:a?n.exactLength.value:void 0,maximum:t?n.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:n.exactLength.message}),i.dirty())}if(null!==n.minLength&&r.data.length<n.minLength.value&&(pO(r,{code:pT.too_small,minimum:n.minLength.value,type:"array",inclusive:!0,exact:!1,message:n.minLength.message}),i.dirty()),null!==n.maxLength&&r.data.length>n.maxLength.value&&(pO(r,{code:pT.too_big,maximum:n.maxLength.value,type:"array",inclusive:!0,exact:!1,message:n.maxLength.message}),i.dirty()),r.common.async)return Promise.all([...r.data].map((t,i)=>n.type._parseAsync(new pN(r,t,r.path,i)))).then(t=>pI.mergeArray(i,t));let a=[...r.data].map((t,i)=>n.type._parseSync(new pN(r,t,r.path,i)));return pI.mergeArray(i,a)}get element(){return this._def.type}min(t,r){return new mo({...this._def,minLength:{value:t,message:M.toString(r)}})}max(t,r){return new mo({...this._def,maxLength:{value:t,message:M.toString(r)}})}length(t,r){return new mo({...this._def,exactLength:{value:t,message:M.toString(r)}})}nonempty(t){return this.min(1,t)}}mo.create=(t,r)=>new mo({type:t,minLength:null,maxLength:null,exactLength:null,typeName:L.ZodArray,...pL(r)});class ms extends pZ{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(null!==this._cached)return this._cached;let t=this._def.shape(),r=z.objectKeys(t);return this._cached={shape:t,keys:r},this._cached}_parse(t){if(this._getType(t)!==px.object){let r=this._getOrReturnCtx(t);return pO(r,{code:pT.invalid_type,expected:px.object,received:r.parsedType}),pq}let{status:r,ctx:i}=this._processInputParams(t),{shape:n,keys:a}=this._getCached(),o=[];if(!(this._def.catchall instanceof mn&&"strip"===this._def.unknownKeys))for(let t in i.data)a.includes(t)||o.push(t);let s=[];for(let t of a){let r=n[t],a=i.data[t];s.push({key:{status:"valid",value:t},value:r._parse(new pN(i,a,i.path,t)),alwaysSet:t in i.data})}if(this._def.catchall instanceof mn){let t=this._def.unknownKeys;if("passthrough"===t)for(let t of o)s.push({key:{status:"valid",value:t},value:{status:"valid",value:i.data[t]}});else if("strict"===t)o.length>0&&(pO(i,{code:pT.unrecognized_keys,keys:o}),r.dirty());else if("strip"===t);else throw Error("Internal ZodObject error: invalid unknownKeys value.")}else{let t=this._def.catchall;for(let r of o){let n=i.data[r];s.push({key:{status:"valid",value:r},value:t._parse(new pN(i,n,i.path,r)),alwaysSet:r in i.data})}}return i.common.async?Promise.resolve().then(async()=>{let t=[];for(let r of s){let i=await r.key,n=await r.value;t.push({key:i,value:n,alwaysSet:r.alwaysSet})}return t}).then(t=>pI.mergeObjectSync(r,t)):pI.mergeObjectSync(r,s)}get shape(){return this._def.shape()}strict(t){return M.errToObj,new ms({...this._def,unknownKeys:"strict",...void 0!==t?{errorMap:(r,i)=>{let n=this._def.errorMap?.(r,i).message??i.defaultError;return"unrecognized_keys"===r.code?{message:M.errToObj(t).message??n}:{message:n}}}:{}})}strip(){return new ms({...this._def,unknownKeys:"strip"})}passthrough(){return new ms({...this._def,unknownKeys:"passthrough"})}extend(t){return new ms({...this._def,shape:()=>({...this._def.shape(),...t})})}merge(t){return new ms({unknownKeys:t._def.unknownKeys,catchall:t._def.catchall,shape:()=>({...this._def.shape(),...t._def.shape()}),typeName:L.ZodObject})}setKey(t,r){return this.augment({[t]:r})}catchall(t){return new ms({...this._def,catchall:t})}pick(t){let r={};for(let i of z.objectKeys(t))t[i]&&this.shape[i]&&(r[i]=this.shape[i]);return new ms({...this._def,shape:()=>r})}omit(t){let r={};for(let i of z.objectKeys(this.shape))t[i]||(r[i]=this.shape[i]);return new ms({...this._def,shape:()=>r})}deepPartial(){return function t(r){if(r instanceof ms){let i={};for(let n in r.shape){let a=r.shape[n];i[n]=mk.create(t(a))}return new ms({...r._def,shape:()=>i})}if(r instanceof mo)return new mo({...r._def,type:t(r.element)});if(r instanceof mk)return mk.create(t(r.unwrap()));if(r instanceof mx)return mx.create(t(r.unwrap()));if(r instanceof mp)return mp.create(r.items.map(r=>t(r)));else return r}(this)}partial(t){let r={};for(let i of z.objectKeys(this.shape)){let n=this.shape[i];t&&!t[i]?r[i]=n:r[i]=n.optional()}return new ms({...this._def,shape:()=>r})}required(t){let r={};for(let i of z.objectKeys(this.shape))if(t&&!t[i])r[i]=this.shape[i];else{let t=this.shape[i];for(;t instanceof mk;)t=t._def.innerType;r[i]=t}return new ms({...this._def,shape:()=>r})}keyof(){return m_(z.objectKeys(this.shape))}}ms.create=(t,r)=>new ms({shape:()=>t,unknownKeys:"strip",catchall:mn.create(),typeName:L.ZodObject,...pL(r)}),ms.strictCreate=(t,r)=>new ms({shape:()=>t,unknownKeys:"strict",catchall:mn.create(),typeName:L.ZodObject,...pL(r)}),ms.lazycreate=(t,r)=>new ms({shape:t,unknownKeys:"strip",catchall:mn.create(),typeName:L.ZodObject,...pL(r)});class ml extends pZ{_parse(t){let{ctx:r}=this._processInputParams(t),i=this._def.options;if(r.common.async)return Promise.all(i.map(async t=>{let i={...r,common:{...r.common,issues:[]},parent:null};return{result:await t._parseAsync({data:r.data,path:r.path,parent:i}),ctx:i}})).then(function(t){for(let r of t)if("valid"===r.result.status)return r.result;for(let i of t)if("dirty"===i.result.status)return r.common.issues.push(...i.ctx.common.issues),i.result;let i=t.map(t=>new pC(t.ctx.common.issues));return pO(r,{code:pT.invalid_union,unionErrors:i}),pq});{let t,n=[];for(let a of i){let i={...r,common:{...r.common,issues:[]},parent:null},o=a._parseSync({data:r.data,path:r.path,parent:i});if("valid"===o.status)return o;"dirty"!==o.status||t||(t={result:o,ctx:i}),i.common.issues.length&&n.push(i.common.issues)}if(t)return r.common.issues.push(...t.ctx.common.issues),t.result;let a=n.map(t=>new pC(t));return pO(r,{code:pT.invalid_union,unionErrors:a}),pq}}get options(){return this._def.options}}ml.create=(t,r)=>new ml({options:t,typeName:L.ZodUnion,...pL(r)});let mc=t=>{if(t instanceof my)return mc(t.schema);if(t instanceof mR)return mc(t.innerType());if(t instanceof mv)return[t.value];if(t instanceof mb)return t.options;if(t instanceof mS)return z.objectValues(t.enum);else if(t instanceof m$)return mc(t._def.innerType);else if(t instanceof me)return[void 0];else if(t instanceof mt)return[null];else if(t instanceof mk)return[void 0,...mc(t.unwrap())];else if(t instanceof mx)return[null,...mc(t.unwrap())];else if(t instanceof mE)return mc(t.unwrap());else if(t instanceof mO)return mc(t.unwrap());else if(t instanceof mT)return mc(t._def.innerType);else return[]};class mu extends pZ{_parse(t){let{ctx:r}=this._processInputParams(t);if(r.parsedType!==px.object)return pO(r,{code:pT.invalid_type,expected:px.object,received:r.parsedType}),pq;let i=this.discriminator,n=r.data[i],a=this.optionsMap.get(n);return a?r.common.async?a._parseAsync({data:r.data,path:r.path,parent:r}):a._parseSync({data:r.data,path:r.path,parent:r}):(pO(r,{code:pT.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[i]}),pq)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(t,r,i){let n=new Map;for(let i of r){let r=mc(i.shape[t]);if(!r.length)throw Error(`A discriminator value for key \`${t}\` could not be extracted from all schema options`);for(let a of r){if(n.has(a))throw Error(`Discriminator property ${String(t)} has duplicate value ${String(a)}`);n.set(a,i)}}return new mu({typeName:L.ZodDiscriminatedUnion,discriminator:t,options:r,optionsMap:n,...pL(i)})}}class md extends pZ{_parse(t){let{status:r,ctx:i}=this._processInputParams(t),n=(t,n)=>{if("aborted"===t.status||"aborted"===n.status)return pq;let a=function t(r,i){let n=p$(r),a=p$(i);if(r===i)return{valid:!0,data:r};if(n===px.object&&a===px.object){let n=z.objectKeys(i),a=z.objectKeys(r).filter(t=>-1!==n.indexOf(t)),o={...r,...i};for(let n of(Object.prototype.hasOwnProperty.call(o,"__proto__")&&delete o.__proto__,a)){if("__proto__"===n)continue;let a=t(r[n],i[n]);if(!a.valid)return{valid:!1};o[n]=a.data}return{valid:!0,data:o}}if(n===px.array&&a===px.array){if(r.length!==i.length)return{valid:!1};let n=[];for(let a=0;a<r.length;a++){let o=t(r[a],i[a]);if(!o.valid)return{valid:!1};n.push(o.data)}return{valid:!0,data:n}}if(n===px.date&&a===px.date&&+r==+i)return{valid:!0,data:r};return{valid:!1}}(t.value,n.value);return a.valid?(("dirty"===t.status||"dirty"===n.status)&&r.dirty(),{status:r.value,value:a.data}):(pO(i,{code:pT.invalid_intersection_types}),pq)};return i.common.async?Promise.all([this._def.left._parseAsync({data:i.data,path:i.path,parent:i}),this._def.right._parseAsync({data:i.data,path:i.path,parent:i})]).then(([t,r])=>n(t,r)):n(this._def.left._parseSync({data:i.data,path:i.path,parent:i}),this._def.right._parseSync({data:i.data,path:i.path,parent:i}))}}md.create=(t,r,i)=>new md({left:t,right:r,typeName:L.ZodIntersection,...pL(i)});class mp extends pZ{_parse(t){let{status:r,ctx:i}=this._processInputParams(t);if(i.parsedType!==px.array)return pO(i,{code:pT.invalid_type,expected:px.array,received:i.parsedType}),pq;if(i.data.length<this._def.items.length)return pO(i,{code:pT.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),pq;!this._def.rest&&i.data.length>this._def.items.length&&(pO(i,{code:pT.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),r.dirty());let n=[...i.data].map((t,r)=>{let n=this._def.items[r]||this._def.rest;return n?n._parse(new pN(i,t,i.path,r)):null}).filter(t=>!!t);return i.common.async?Promise.all(n).then(t=>pI.mergeArray(r,t)):pI.mergeArray(r,n)}get items(){return this._def.items}rest(t){return new mp({...this._def,rest:t})}}mp.create=(t,r)=>{if(!Array.isArray(t))throw Error("You must pass an array of schemas to z.tuple([ ... ])");return new mp({items:t,typeName:L.ZodTuple,rest:null,...pL(r)})};class mm extends pZ{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){let{status:r,ctx:i}=this._processInputParams(t);if(i.parsedType!==px.object)return pO(i,{code:pT.invalid_type,expected:px.object,received:i.parsedType}),pq;let n=[],a=this._def.keyType,o=this._def.valueType;for(let t in i.data)n.push({key:a._parse(new pN(i,t,i.path,t)),value:o._parse(new pN(i,i.data[t],i.path,t)),alwaysSet:t in i.data});return i.common.async?pI.mergeObjectAsync(r,n):pI.mergeObjectSync(r,n)}get element(){return this._def.valueType}static create(t,r,i){return new mm(r instanceof pZ?{keyType:t,valueType:r,typeName:L.ZodRecord,...pL(i)}:{keyType:p4.create(),valueType:t,typeName:L.ZodRecord,...pL(r)})}}class mh extends pZ{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){let{status:r,ctx:i}=this._processInputParams(t);if(i.parsedType!==px.map)return pO(i,{code:pT.invalid_type,expected:px.map,received:i.parsedType}),pq;let n=this._def.keyType,a=this._def.valueType,o=[...i.data.entries()].map(([t,r],o)=>({key:n._parse(new pN(i,t,i.path,[o,"key"])),value:a._parse(new pN(i,r,i.path,[o,"value"]))}));if(i.common.async){let t=new Map;return Promise.resolve().then(async()=>{for(let i of o){let n=await i.key,a=await i.value;if("aborted"===n.status||"aborted"===a.status)return pq;("dirty"===n.status||"dirty"===a.status)&&r.dirty(),t.set(n.value,a.value)}return{status:r.value,value:t}})}{let t=new Map;for(let i of o){let n=i.key,a=i.value;if("aborted"===n.status||"aborted"===a.status)return pq;("dirty"===n.status||"dirty"===a.status)&&r.dirty(),t.set(n.value,a.value)}return{status:r.value,value:t}}}}mh.create=(t,r,i)=>new mh({valueType:r,keyType:t,typeName:L.ZodMap,...pL(i)});class mf extends pZ{_parse(t){let{status:r,ctx:i}=this._processInputParams(t);if(i.parsedType!==px.set)return pO(i,{code:pT.invalid_type,expected:px.set,received:i.parsedType}),pq;let n=this._def;null!==n.minSize&&i.data.size<n.minSize.value&&(pO(i,{code:pT.too_small,minimum:n.minSize.value,type:"set",inclusive:!0,exact:!1,message:n.minSize.message}),r.dirty()),null!==n.maxSize&&i.data.size>n.maxSize.value&&(pO(i,{code:pT.too_big,maximum:n.maxSize.value,type:"set",inclusive:!0,exact:!1,message:n.maxSize.message}),r.dirty());let a=this._def.valueType;function o(t){let i=new Set;for(let n of t){if("aborted"===n.status)return pq;"dirty"===n.status&&r.dirty(),i.add(n.value)}return{status:r.value,value:i}}let s=[...i.data.values()].map((t,r)=>a._parse(new pN(i,t,i.path,r)));return i.common.async?Promise.all(s).then(t=>o(t)):o(s)}min(t,r){return new mf({...this._def,minSize:{value:t,message:M.toString(r)}})}max(t,r){return new mf({...this._def,maxSize:{value:t,message:M.toString(r)}})}size(t,r){return this.min(t,r).max(t,r)}nonempty(t){return this.min(1,t)}}mf.create=(t,r)=>new mf({valueType:t,minSize:null,maxSize:null,typeName:L.ZodSet,...pL(r)});class mg extends pZ{constructor(){super(...arguments),this.validate=this.implement}_parse(t){let{ctx:r}=this._processInputParams(t);if(r.parsedType!==px.function)return pO(r,{code:pT.invalid_type,expected:px.function,received:r.parsedType}),pq;function i(t,i){return pP({data:t,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,pE,pE].filter(t=>!!t),issueData:{code:pT.invalid_arguments,argumentsError:i}})}function n(t,i){return pP({data:t,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,pE,pE].filter(t=>!!t),issueData:{code:pT.invalid_return_type,returnTypeError:i}})}let a={errorMap:r.common.contextualErrorMap},o=r.data;if(this._def.returns instanceof mw){let t=this;return pA(async function(...r){let s=new pC([]),l=await t._def.args.parseAsync(r,a).catch(t=>{throw s.addIssue(i(r,t)),s}),c=await Reflect.apply(o,this,l);return await t._def.returns._def.type.parseAsync(c,a).catch(t=>{throw s.addIssue(n(c,t)),s})})}{let t=this;return pA(function(...r){let s=t._def.args.safeParse(r,a);if(!s.success)throw new pC([i(r,s.error)]);let l=Reflect.apply(o,this,s.data),c=t._def.returns.safeParse(l,a);if(!c.success)throw new pC([n(l,c.error)]);return c.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...t){return new mg({...this._def,args:mp.create(t).rest(mi.create())})}returns(t){return new mg({...this._def,returns:t})}implement(t){return this.parse(t)}strictImplement(t){return this.parse(t)}static create(t,r,i){return new mg({args:t||mp.create([]).rest(mi.create()),returns:r||mi.create(),typeName:L.ZodFunction,...pL(i)})}}class my extends pZ{get schema(){return this._def.getter()}_parse(t){let{ctx:r}=this._processInputParams(t);return this._def.getter()._parse({data:r.data,path:r.path,parent:r})}}my.create=(t,r)=>new my({getter:t,typeName:L.ZodLazy,...pL(r)});class mv extends pZ{_parse(t){if(t.data!==this._def.value){let r=this._getOrReturnCtx(t);return pO(r,{received:r.data,code:pT.invalid_literal,expected:this._def.value}),pq}return{status:"valid",value:t.data}}get value(){return this._def.value}}function m_(t,r){return new mb({values:t,typeName:L.ZodEnum,...pL(r)})}mv.create=(t,r)=>new mv({value:t,typeName:L.ZodLiteral,...pL(r)});class mb extends pZ{_parse(t){if("string"!=typeof t.data){let r=this._getOrReturnCtx(t),i=this._def.values;return pO(r,{expected:z.joinValues(i),received:r.parsedType,code:pT.invalid_type}),pq}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(t.data)){let r=this._getOrReturnCtx(t),i=this._def.values;return pO(r,{received:r.data,code:pT.invalid_enum_value,options:i}),pq}return pA(t.data)}get options(){return this._def.values}get enum(){let t={};for(let r of this._def.values)t[r]=r;return t}get Values(){let t={};for(let r of this._def.values)t[r]=r;return t}get Enum(){let t={};for(let r of this._def.values)t[r]=r;return t}extract(t,r=this._def){return mb.create(t,{...this._def,...r})}exclude(t,r=this._def){return mb.create(this.options.filter(r=>!t.includes(r)),{...this._def,...r})}}mb.create=m_;class mS extends pZ{_parse(t){let r=z.getValidEnumValues(this._def.values),i=this._getOrReturnCtx(t);if(i.parsedType!==px.string&&i.parsedType!==px.number){let t=z.objectValues(r);return pO(i,{expected:z.joinValues(t),received:i.parsedType,code:pT.invalid_type}),pq}if(this._cache||(this._cache=new Set(z.getValidEnumValues(this._def.values))),!this._cache.has(t.data)){let t=z.objectValues(r);return pO(i,{received:i.data,code:pT.invalid_enum_value,options:t}),pq}return pA(t.data)}get enum(){return this._def.values}}mS.create=(t,r)=>new mS({values:t,typeName:L.ZodNativeEnum,...pL(r)});class mw extends pZ{unwrap(){return this._def.type}_parse(t){let{ctx:r}=this._processInputParams(t);return r.parsedType!==px.promise&&!1===r.common.async?(pO(r,{code:pT.invalid_type,expected:px.promise,received:r.parsedType}),pq):pA((r.parsedType===px.promise?r.data:Promise.resolve(r.data)).then(t=>this._def.type.parseAsync(t,{path:r.path,errorMap:r.common.contextualErrorMap})))}}mw.create=(t,r)=>new mw({type:t,typeName:L.ZodPromise,...pL(r)});class mR extends pZ{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===L.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(t){let{status:r,ctx:i}=this._processInputParams(t),n=this._def.effect||null,a={addIssue:t=>{pO(i,t),t.fatal?r.abort():r.dirty()},get path(){return i.path}};if(a.addIssue=a.addIssue.bind(a),"preprocess"===n.type){let t=n.transform(i.data,a);if(i.common.async)return Promise.resolve(t).then(async t=>{if("aborted"===r.value)return pq;let n=await this._def.schema._parseAsync({data:t,path:i.path,parent:i});return"aborted"===n.status?pq:"dirty"===n.status||"dirty"===r.value?pj(n.value):n});{if("aborted"===r.value)return pq;let n=this._def.schema._parseSync({data:t,path:i.path,parent:i});return"aborted"===n.status?pq:"dirty"===n.status||"dirty"===r.value?pj(n.value):n}}if("refinement"===n.type){let t=t=>{let r=n.refinement(t,a);if(i.common.async)return Promise.resolve(r);if(r instanceof Promise)throw Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return t};if(!1!==i.common.async)return this._def.schema._parseAsync({data:i.data,path:i.path,parent:i}).then(i=>"aborted"===i.status?pq:("dirty"===i.status&&r.dirty(),t(i.value).then(()=>({status:r.value,value:i.value}))));{let n=this._def.schema._parseSync({data:i.data,path:i.path,parent:i});return"aborted"===n.status?pq:("dirty"===n.status&&r.dirty(),t(n.value),{status:r.value,value:n.value})}}if("transform"===n.type)if(!1!==i.common.async)return this._def.schema._parseAsync({data:i.data,path:i.path,parent:i}).then(t=>"valid"!==t.status?pq:Promise.resolve(n.transform(t.value,a)).then(t=>({status:r.value,value:t})));else{let t=this._def.schema._parseSync({data:i.data,path:i.path,parent:i});if("valid"!==t.status)return pq;let o=n.transform(t.value,a);if(o instanceof Promise)throw Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:r.value,value:o}}z.assertNever(n)}}mR.create=(t,r,i)=>new mR({schema:t,typeName:L.ZodEffects,effect:r,...pL(i)}),mR.createWithPreprocess=(t,r,i)=>new mR({schema:r,effect:{type:"preprocess",transform:t},typeName:L.ZodEffects,...pL(i)});class mk extends pZ{_parse(t){return this._getType(t)===px.undefined?pA(void 0):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}}mk.create=(t,r)=>new mk({innerType:t,typeName:L.ZodOptional,...pL(r)});class mx extends pZ{_parse(t){return this._getType(t)===px.null?pA(null):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}}mx.create=(t,r)=>new mx({innerType:t,typeName:L.ZodNullable,...pL(r)});class m$ extends pZ{_parse(t){let{ctx:r}=this._processInputParams(t),i=r.data;return r.parsedType===px.undefined&&(i=this._def.defaultValue()),this._def.innerType._parse({data:i,path:r.path,parent:r})}removeDefault(){return this._def.innerType}}m$.create=(t,r)=>new m$({innerType:t,typeName:L.ZodDefault,defaultValue:"function"==typeof r.default?r.default:()=>r.default,...pL(r)});class mT extends pZ{_parse(t){let{ctx:r}=this._processInputParams(t),i={...r,common:{...r.common,issues:[]}},n=this._def.innerType._parse({data:i.data,path:i.path,parent:{...i}});return pz(n)?n.then(t=>({status:"valid",value:"valid"===t.status?t.value:this._def.catchValue({get error(){return new pC(i.common.issues)},input:i.data})})):{status:"valid",value:"valid"===n.status?n.value:this._def.catchValue({get error(){return new pC(i.common.issues)},input:i.data})}}removeCatch(){return this._def.innerType}}mT.create=(t,r)=>new mT({innerType:t,typeName:L.ZodCatch,catchValue:"function"==typeof r.catch?r.catch:()=>r.catch,...pL(r)});class mC extends pZ{_parse(t){if(this._getType(t)!==px.nan){let r=this._getOrReturnCtx(t);return pO(r,{code:pT.invalid_type,expected:px.nan,received:r.parsedType}),pq}return{status:"valid",value:t.data}}}mC.create=t=>new mC({typeName:L.ZodNaN,...pL(t)}),Symbol("zod_brand");class mE extends pZ{_parse(t){let{ctx:r}=this._processInputParams(t),i=r.data;return this._def.type._parse({data:i,path:r.path,parent:r})}unwrap(){return this._def.type}}class mP extends pZ{_parse(t){let{status:r,ctx:i}=this._processInputParams(t);if(i.common.async)return(async()=>{let t=await this._def.in._parseAsync({data:i.data,path:i.path,parent:i});return"aborted"===t.status?pq:"dirty"===t.status?(r.dirty(),pj(t.value)):this._def.out._parseAsync({data:t.value,path:i.path,parent:i})})();{let t=this._def.in._parseSync({data:i.data,path:i.path,parent:i});return"aborted"===t.status?pq:"dirty"===t.status?(r.dirty(),{status:"dirty",value:t.value}):this._def.out._parseSync({data:t.value,path:i.path,parent:i})}}static create(t,r){return new mP({in:t,out:r,typeName:L.ZodPipeline})}}class mO extends pZ{_parse(t){let r=this._def.innerType._parse(t),i=t=>("valid"===t.status&&(t.value=Object.freeze(t.value)),t);return pz(r)?r.then(t=>i(t)):i(r)}unwrap(){return this._def.innerType}}mO.create=(t,r)=>new mO({innerType:t,typeName:L.ZodReadonly,...pL(r)}),ms.lazycreate,(I=L||(L={})).ZodString="ZodString",I.ZodNumber="ZodNumber",I.ZodNaN="ZodNaN",I.ZodBigInt="ZodBigInt",I.ZodBoolean="ZodBoolean",I.ZodDate="ZodDate",I.ZodSymbol="ZodSymbol",I.ZodUndefined="ZodUndefined",I.ZodNull="ZodNull",I.ZodAny="ZodAny",I.ZodUnknown="ZodUnknown",I.ZodNever="ZodNever",I.ZodVoid="ZodVoid",I.ZodArray="ZodArray",I.ZodObject="ZodObject",I.ZodUnion="ZodUnion",I.ZodDiscriminatedUnion="ZodDiscriminatedUnion",I.ZodIntersection="ZodIntersection",I.ZodTuple="ZodTuple",I.ZodRecord="ZodRecord",I.ZodMap="ZodMap",I.ZodSet="ZodSet",I.ZodFunction="ZodFunction",I.ZodLazy="ZodLazy",I.ZodLiteral="ZodLiteral",I.ZodEnum="ZodEnum",I.ZodEffects="ZodEffects",I.ZodNativeEnum="ZodNativeEnum",I.ZodOptional="ZodOptional",I.ZodNullable="ZodNullable",I.ZodDefault="ZodDefault",I.ZodCatch="ZodCatch",I.ZodPromise="ZodPromise",I.ZodBranded="ZodBranded",I.ZodPipeline="ZodPipeline",I.ZodReadonly="ZodReadonly";let mI=p4.create;p3.create,mC.create,p6.create,p5.create,p7.create,p8.create,me.create,mt.create,mr.create,mi.create,mn.create,ma.create,mo.create;let mq=ms.create;ms.strictCreate,ml.create,mu.create,md.create,mp.create,mm.create,mh.create,mf.create,mg.create,my.create,mv.create,mb.create,mS.create,mw.create,mR.create,mk.create,mx.create,mR.createWithPreprocess,mP.create;let mj=(t,r)=>{let i=0;for(;i<t.length&&i<r.length&&t[i]===r[i];i++);return[(t.length-i).toString(),...r.slice(i)].join("/")};function mA(t){if("openAi"!==t.target)return{};let r=[...t.basePath,t.definitionPath,t.openAiAnyTypeName];return t.flags.hasReferencedOpenAiAnyType=!0,{$ref:"relative"===t.$refStrategy?mj(r,t.currentPath):r.join("/")}}function mz(t,r,i,n){n?.errorMessages&&i&&(t.errorMessage={...t.errorMessage,[r]:i})}function mN(t,r,i,n,a){t[r]=i,mz(t,r,n,a)}function mM(t,r){return m3(t.type._def,r)}let mL=/^[cC][^\s-]{8,}$/,mZ=/^[0-9a-z]+$/,mU=/^[0-9A-HJKMNP-TV-Z]{26}$/,mF=/^(?!\.)(?!.*\.\.)([a-zA-Z0-9_'+\-\.]*)[a-zA-Z0-9_+-]@([a-zA-Z0-9][a-zA-Z0-9\-]*\.)+[a-zA-Z]{2,}$/,mD=()=>(void 0===k&&(k=RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),k),mH=/^(?:(?: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])\/(3[0-2]|[12]?[0-9])$/,mJ=/^(([0-9a-fA-F]{1,4}:){7,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}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,mV=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,mB=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,mW=/^[a-zA-Z0-9_-]{21}$/,mG=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/;function mK(t,r){let i={type:"string"};if(t.checks)for(let n of t.checks)switch(n.kind){case"min":mN(i,"minLength","number"==typeof i.minLength?Math.max(i.minLength,n.value):n.value,n.message,r);break;case"max":mN(i,"maxLength","number"==typeof i.maxLength?Math.min(i.maxLength,n.value):n.value,n.message,r);break;case"email":switch(r.emailStrategy){case"format:email":mQ(i,"email",n.message,r);break;case"format:idn-email":mQ(i,"idn-email",n.message,r);break;case"pattern:zod":m0(i,mF,n.message,r)}break;case"url":mQ(i,"uri",n.message,r);break;case"uuid":mQ(i,"uuid",n.message,r);break;case"regex":m0(i,n.regex,n.message,r);break;case"cuid":m0(i,mL,n.message,r);break;case"cuid2":m0(i,mZ,n.message,r);break;case"startsWith":m0(i,RegExp(`^${mY(n.value,r)}`),n.message,r);break;case"endsWith":m0(i,RegExp(`${mY(n.value,r)}$`),n.message,r);break;case"datetime":mQ(i,"date-time",n.message,r);break;case"date":mQ(i,"date",n.message,r);break;case"time":mQ(i,"time",n.message,r);break;case"duration":mQ(i,"duration",n.message,r);break;case"length":mN(i,"minLength","number"==typeof i.minLength?Math.max(i.minLength,n.value):n.value,n.message,r),mN(i,"maxLength","number"==typeof i.maxLength?Math.min(i.maxLength,n.value):n.value,n.message,r);break;case"includes":m0(i,RegExp(mY(n.value,r)),n.message,r);break;case"ip":"v6"!==n.version&&mQ(i,"ipv4",n.message,r),"v4"!==n.version&&mQ(i,"ipv6",n.message,r);break;case"base64url":m0(i,mB,n.message,r);break;case"jwt":m0(i,mG,n.message,r);break;case"cidr":"v6"!==n.version&&m0(i,mH,n.message,r),"v4"!==n.version&&m0(i,mJ,n.message,r);break;case"emoji":m0(i,mD(),n.message,r);break;case"ulid":m0(i,mU,n.message,r);break;case"base64":switch(r.base64Strategy){case"format:binary":mQ(i,"binary",n.message,r);break;case"contentEncoding:base64":mN(i,"contentEncoding","base64",n.message,r);break;case"pattern:zod":m0(i,mV,n.message,r)}break;case"nanoid":m0(i,mW,n.message,r)}return i}function mY(t,r){return"escape"===r.patternStrategy?function(t){let r="";for(let i=0;i<t.length;i++)mX.has(t[i])||(r+="\\"),r+=t[i];return r}(t):t}let mX=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function mQ(t,r,i,n){t.format||t.anyOf?.some(t=>t.format)?(t.anyOf||(t.anyOf=[]),t.format&&(t.anyOf.push({format:t.format,...t.errorMessage&&n.errorMessages&&{errorMessage:{format:t.errorMessage.format}}}),delete t.format,t.errorMessage&&(delete t.errorMessage.format,0===Object.keys(t.errorMessage).length&&delete t.errorMessage)),t.anyOf.push({format:r,...i&&n.errorMessages&&{errorMessage:{format:i}}})):mN(t,"format",r,i,n)}function m0(t,r,i,n){t.pattern||t.allOf?.some(t=>t.pattern)?(t.allOf||(t.allOf=[]),t.pattern&&(t.allOf.push({pattern:t.pattern,...t.errorMessage&&n.errorMessages&&{errorMessage:{pattern:t.errorMessage.pattern}}}),delete t.pattern,t.errorMessage&&(delete t.errorMessage.pattern,0===Object.keys(t.errorMessage).length&&delete t.errorMessage)),t.allOf.push({pattern:m1(r,n),...i&&n.errorMessages&&{errorMessage:{pattern:i}}})):mN(t,"pattern",m1(r,n),i,n)}function m1(t,r){if(!r.applyRegexFlags||!t.flags)return t.source;let i={i:t.flags.includes("i"),m:t.flags.includes("m"),s:t.flags.includes("s")},n=i.i?t.source.toLowerCase():t.source,a="",o=!1,s=!1,l=!1;for(let t=0;t<n.length;t++){if(o){a+=n[t],o=!1;continue}if(i.i){if(s){if(n[t].match(/[a-z]/)){l?(a+=n[t],a+=`${n[t-2]}-${n[t]}`.toUpperCase(),l=!1):"-"===n[t+1]&&n[t+2]?.match(/[a-z]/)?(a+=n[t],l=!0):a+=`${n[t]}${n[t].toUpperCase()}`;continue}}else if(n[t].match(/[a-z]/)){a+=`[${n[t]}${n[t].toUpperCase()}]`;continue}}if(i.m){if("^"===n[t]){a+=`(^|(?<=[\r
|
|
74
|
-
]))`;continue}else if("$"===
|
|
75
|
-
]))`;continue}}if(
|
|
76
|
-
`:`[${
|
|
77
|
-
]`;continue}a+=n[t],"\\"===n[t]?o=!0:s&&"]"===n[t]?s=!1:s||"["!==n[t]||(s=!0)}try{new RegExp(a)}catch{return console.warn(`Could not convert regex pattern at ${r.currentPath.join("/")} to a flag-independent form! Falling back to the flag-ignorant source`),t.source}return a}function m2(t,r){if("openAi"===r.target&&console.warn("Warning: OpenAI may not support records in schemas! Try an array of key-value pairs instead."),"openApi3"===r.target&&t.keyType?._def.typeName===L.ZodEnum)return{type:"object",required:t.keyType._def.values,properties:t.keyType._def.values.reduce((i,n)=>({...i,[n]:m3(t.valueType._def,{...r,currentPath:[...r.currentPath,"properties",n]})??mA(r)}),{}),additionalProperties:r.rejectedAdditionalProperties};let i={type:"object",additionalProperties:m3(t.valueType._def,{...r,currentPath:[...r.currentPath,"additionalProperties"]})??r.allowedAdditionalProperties};if("openApi3"===r.target)return i;if(t.keyType?._def.typeName===L.ZodString&&t.keyType._def.checks?.length){let{type:n,...a}=mK(t.keyType._def,r);return{...i,propertyNames:a}}if(t.keyType?._def.typeName===L.ZodEnum)return{...i,propertyNames:{enum:t.keyType._def.values}};if(t.keyType?._def.typeName===L.ZodBranded&&t.keyType._def.type._def.typeName===L.ZodString&&t.keyType._def.type._def.checks?.length){let{type:n,...a}=mM(t.keyType._def,r);return{...i,propertyNames:a}}return i}let m9={ZodString:"string",ZodNumber:"number",ZodBigInt:"integer",ZodBoolean:"boolean",ZodNull:"null"},m4=(t,r)=>{let i=(t.options instanceof Map?Array.from(t.options.values()):t.options).map((t,i)=>m3(t._def,{...r,currentPath:[...r.currentPath,"anyOf",`${i}`]})).filter(t=>!!t&&(!r.strictUnions||"object"==typeof t&&Object.keys(t).length>0));return i.length?{anyOf:i}:void 0};function m3(t,r,i=!1){let n=r.seen.get(t);if(r.override){let a=r.override?.(t,r,n,i);if(a!==pR)return a}if(n&&!i){let t=m6(n,r);if(void 0!==t)return t}let a={def:t,path:r.currentPath,jsonSchema:void 0};r.seen.set(t,a);let o=((t,r,i)=>{switch(r){case L.ZodString:return mK(t,i);case L.ZodNumber:let n={type:"number"};if(!t.checks)return n;for(let r of t.checks)switch(r.kind){case"int":n.type="integer",mz(n,"type",r.message,i);break;case"min":"jsonSchema7"===i.target?r.inclusive?mN(n,"minimum",r.value,r.message,i):mN(n,"exclusiveMinimum",r.value,r.message,i):(r.inclusive||(n.exclusiveMinimum=!0),mN(n,"minimum",r.value,r.message,i));break;case"max":"jsonSchema7"===i.target?r.inclusive?mN(n,"maximum",r.value,r.message,i):mN(n,"exclusiveMaximum",r.value,r.message,i):(r.inclusive||(n.exclusiveMaximum=!0),mN(n,"maximum",r.value,r.message,i));break;case"multipleOf":mN(n,"multipleOf",r.value,r.message,i)}return n;case L.ZodObject:return function(t,r){let i="openAi"===r.target,n={type:"object",properties:{}},a=[],o=t.shape();for(let t in o){let s=o[t];if(void 0===s||void 0===s._def)continue;let l=function(t){try{return t.isOptional()}catch{return!0}}(s);l&&i&&("ZodOptional"===s._def.typeName&&(s=s._def.innerType),s.isNullable()||(s=s.nullable()),l=!1);let c=m3(s._def,{...r,currentPath:[...r.currentPath,"properties",t],propertyPath:[...r.currentPath,"properties",t]});void 0!==c&&(n.properties[t]=c,l||a.push(t))}a.length&&(n.required=a);let s=function(t,r){if("ZodNever"!==t.catchall._def.typeName)return m3(t.catchall._def,{...r,currentPath:[...r.currentPath,"additionalProperties"]});switch(t.unknownKeys){case"passthrough":return r.allowedAdditionalProperties;case"strict":return r.rejectedAdditionalProperties;case"strip":return"strict"===r.removeAdditionalStrategy?r.allowedAdditionalProperties:r.rejectedAdditionalProperties}}(t,r);return void 0!==s&&(n.additionalProperties=s),n}(t,i);case L.ZodBigInt:let a={type:"integer",format:"int64"};if(!t.checks)return a;for(let r of t.checks)switch(r.kind){case"min":"jsonSchema7"===i.target?r.inclusive?mN(a,"minimum",r.value,r.message,i):mN(a,"exclusiveMinimum",r.value,r.message,i):(r.inclusive||(a.exclusiveMinimum=!0),mN(a,"minimum",r.value,r.message,i));break;case"max":"jsonSchema7"===i.target?r.inclusive?mN(a,"maximum",r.value,r.message,i):mN(a,"exclusiveMaximum",r.value,r.message,i):(r.inclusive||(a.exclusiveMaximum=!0),mN(a,"maximum",r.value,r.message,i));break;case"multipleOf":mN(a,"multipleOf",r.value,r.message,i)}return a;case L.ZodBoolean:return{type:"boolean"};case L.ZodDate:return function t(r,i,n){let a=n??i.dateStrategy;if(Array.isArray(a))return{anyOf:a.map((n,a)=>t(r,i,n))};switch(a){case"string":case"format:date-time":return{type:"string",format:"date-time"};case"format:date":return{type:"string",format:"date"};case"integer":var o=r,s=i;let l={type:"integer",format:"unix-time"};if("openApi3"===s.target)return l;for(let t of o.checks)switch(t.kind){case"min":mN(l,"minimum",t.value,t.message,s);break;case"max":mN(l,"maximum",t.value,t.message,s)}return l}}(t,i);case L.ZodUndefined:return{not:mA(i)};case L.ZodNull:return"openApi3"===i.target?{enum:["null"],nullable:!0}:{type:"null"};case L.ZodArray:let o;return o={type:"array"},t.type?._def&&t.type?._def?.typeName!==L.ZodAny&&(o.items=m3(t.type._def,{...i,currentPath:[...i.currentPath,"items"]})),t.minLength&&mN(o,"minItems",t.minLength.value,t.minLength.message,i),t.maxLength&&mN(o,"maxItems",t.maxLength.value,t.maxLength.message,i),t.exactLength&&(mN(o,"minItems",t.exactLength.value,t.exactLength.message,i),mN(o,"maxItems",t.exactLength.value,t.exactLength.message,i)),o;case L.ZodUnion:case L.ZodDiscriminatedUnion:if("openApi3"===i.target)return m4(t,i);let s=t.options instanceof Map?Array.from(t.options.values()):t.options;if(s.every(t=>t._def.typeName in m9&&(!t._def.checks||!t._def.checks.length))){let t=s.reduce((t,r)=>{let i=m9[r._def.typeName];return i&&!t.includes(i)?[...t,i]:t},[]);return{type:t.length>1?t:t[0]}}if(s.every(t=>"ZodLiteral"===t._def.typeName&&!t.description)){let t=s.reduce((t,r)=>{let i=typeof r._def.value;switch(i){case"string":case"number":case"boolean":return[...t,i];case"bigint":return[...t,"integer"];case"object":if(null===r._def.value)return[...t,"null"];default:return t}},[]);if(t.length===s.length){let r=t.filter((t,r,i)=>i.indexOf(t)===r);return{type:r.length>1?r:r[0],enum:s.reduce((t,r)=>t.includes(r._def.value)?t:[...t,r._def.value],[])}}}else if(s.every(t=>"ZodEnum"===t._def.typeName))return{type:"string",enum:s.reduce((t,r)=>[...t,...r._def.values.filter(r=>!t.includes(r))],[])};return m4(t,i);case L.ZodIntersection:let l,c,u;return l=[m3(t.left._def,{...i,currentPath:[...i.currentPath,"allOf","0"]}),m3(t.right._def,{...i,currentPath:[...i.currentPath,"allOf","1"]})].filter(t=>!!t),c="jsonSchema2019-09"===i.target?{unevaluatedProperties:!1}:void 0,u=[],l.forEach(t=>{if((!("type"in t)||"string"!==t.type)&&"allOf"in t)u.push(...t.allOf),void 0===t.unevaluatedProperties&&(c=void 0);else{let r=t;if("additionalProperties"in t&&!1===t.additionalProperties){let{additionalProperties:i,...n}=t;r=n}else c=void 0;u.push(r)}}),u.length?{allOf:u,...c}:void 0;case L.ZodTuple:return t.rest?{type:"array",minItems:t.items.length,items:t.items.map((t,r)=>m3(t._def,{...i,currentPath:[...i.currentPath,"items",`${r}`]})).reduce((t,r)=>void 0===r?t:[...t,r],[]),additionalItems:m3(t.rest._def,{...i,currentPath:[...i.currentPath,"additionalItems"]})}:{type:"array",minItems:t.items.length,maxItems:t.items.length,items:t.items.map((t,r)=>m3(t._def,{...i,currentPath:[...i.currentPath,"items",`${r}`]})).reduce((t,r)=>void 0===r?t:[...t,r],[])};case L.ZodRecord:return m2(t,i);case L.ZodLiteral:let d;return"bigint"!=(d=typeof t.value)&&"number"!==d&&"boolean"!==d&&"string"!==d?{type:Array.isArray(t.value)?"array":"object"}:"openApi3"===i.target?{type:"bigint"===d?"integer":d,enum:[t.value]}:{type:"bigint"===d?"integer":d,const:t.value};case L.ZodEnum:return{type:"string",enum:Array.from(t.values)};case L.ZodNativeEnum:let p,m,h;return p=t.values,{type:1===(h=Array.from(new Set((m=Object.keys(t.values).filter(t=>"number"!=typeof p[p[t]]).map(t=>p[t])).map(t=>typeof t)))).length?"string"===h[0]?"string":"number":["string","number"],enum:m};case L.ZodNullable:if(["ZodString","ZodNumber","ZodBigInt","ZodBoolean","ZodNull"].includes(t.innerType._def.typeName)&&(!t.innerType._def.checks||!t.innerType._def.checks.length))return"openApi3"===i.target?{type:m9[t.innerType._def.typeName],nullable:!0}:{type:[m9[t.innerType._def.typeName],"null"]};if("openApi3"===i.target){let r=m3(t.innerType._def,{...i,currentPath:[...i.currentPath]});return r&&"$ref"in r?{allOf:[r],nullable:!0}:r&&{...r,nullable:!0}}let f=m3(t.innerType._def,{...i,currentPath:[...i.currentPath,"anyOf","0"]});return f&&{anyOf:[f,{type:"null"}]};case L.ZodOptional:if(i.currentPath.toString()===i.propertyPath?.toString())return m3(t.innerType._def,i);let g=m3(t.innerType._def,{...i,currentPath:[...i.currentPath,"anyOf","1"]});return g?{anyOf:[{not:mA(i)},g]}:mA(i);case L.ZodMap:if("record"===i.mapStrategy)return m2(t,i);return{type:"array",maxItems:125,items:{type:"array",items:[m3(t.keyType._def,{...i,currentPath:[...i.currentPath,"items","items","0"]})||mA(i),m3(t.valueType._def,{...i,currentPath:[...i.currentPath,"items","items","1"]})||mA(i)],minItems:2,maxItems:2}};case L.ZodSet:let y;return y={type:"array",uniqueItems:!0,items:m3(t.valueType._def,{...i,currentPath:[...i.currentPath,"items"]})},t.minSize&&mN(y,"minItems",t.minSize.value,t.minSize.message,i),t.maxSize&&mN(y,"maxItems",t.maxSize.value,t.maxSize.message,i),y;case L.ZodLazy:return()=>t.getter()._def;case L.ZodPromise:return m3(t.type._def,i);case L.ZodNaN:case L.ZodNever:return"openAi"===i.target?void 0:{not:mA({...i,currentPath:[...i.currentPath,"not"]})};case L.ZodEffects:return"input"===i.effectStrategy?m3(t.schema._def,i):mA(i);case L.ZodAny:case L.ZodUnknown:return mA(i);case L.ZodDefault:return{...m3(t.innerType._def,i),default:t.defaultValue()};case L.ZodBranded:return mM(t,i);case L.ZodReadonly:case L.ZodCatch:return m3(t.innerType._def,i);case L.ZodPipeline:if("input"===i.pipeStrategy)return m3(t.in._def,i);if("output"===i.pipeStrategy)return m3(t.out._def,i);let v=m3(t.in._def,{...i,currentPath:[...i.currentPath,"allOf","0"]}),_=m3(t.out._def,{...i,currentPath:[...i.currentPath,"allOf",v?"1":"0"]});return{allOf:[v,_].filter(t=>void 0!==t)};case L.ZodFunction:case L.ZodVoid:case L.ZodSymbol:default:return}})(t,t.typeName,r),s="function"==typeof o?m3(o(),r):o;if(s&&m5(t,r,s),r.postProcess){let i=r.postProcess(s,t,r);return a.jsonSchema=s,i}return a.jsonSchema=s,s}let m6=(t,r)=>{switch(r.$refStrategy){case"root":return{$ref:t.path.join("/")};case"relative":return{$ref:mj(r.currentPath,t.path)};case"none":case"seen":if(t.path.length<r.currentPath.length&&t.path.every((t,i)=>r.currentPath[i]===t))return console.warn(`Recursive reference detected at ${r.currentPath.join("/")}! Defaulting to any`),mA(r);return"seen"===r.$refStrategy?mA(r):void 0}},m5=(t,r,i)=>(t.description&&(i.description=t.description,r.markdownDescription&&(i.markdownDescription=t.description)),i);function m7(t,r={}){let{strict:i=!1}=r,n=Object.entries(t),a=t=>({target:r})=>{let a={},o=[];for(let[i,s]of n)a[i]=function(t,r,i){let n=t["~standard"];if(n.jsonSchema)return n.jsonSchema[i]({target:r});if("zod"===t["~standard"].vendor&&!("_zod"in t)&&"_def"in t){let i=((t,r)=>{let i,n,a=(n=void 0!==(i="string"==typeof r?{...pk,name:r}:{...pk,...r}).name?[...i.basePath,i.definitionPath,i.name]:i.basePath,{...i,flags:{hasReferencedOpenAiAnyType:!1},currentPath:n,propertyPath:void 0,seen:new Map(Object.entries(i.definitions).map(([t,r])=>[r._def,{def:r._def,path:[...i.basePath,i.definitionPath,t],jsonSchema:void 0}]))}),o="object"==typeof r&&r.definitions?Object.entries(r.definitions).reduce((t,[r,i])=>({...t,[r]:m3(i._def,{...a,currentPath:[...a.basePath,a.definitionPath,r]},!0)??mA(a)}),{}):void 0,s="string"==typeof r?r:r?.nameStrategy==="title"?void 0:r?.name,l=m3(t._def,void 0===s?a:{...a,currentPath:[...a.basePath,a.definitionPath,s]},!1)??mA(a),c="object"==typeof r&&void 0!==r.name&&"title"===r.nameStrategy?r.name:void 0;void 0!==c&&(l.title=c),a.flags.hasReferencedOpenAiAnyType&&(o||(o={}),o[a.openAiAnyTypeName]||(o[a.openAiAnyTypeName]={type:["string","number","integer","boolean","array","null"],items:{$ref:"relative"===a.$refStrategy?"1":[...a.basePath,a.definitionPath,a.openAiAnyTypeName].join("/")}}));let u=void 0===s?o?{...l,[a.definitionPath]:o}:l:{$ref:[..."relative"===a.$refStrategy?[]:a.basePath,a.definitionPath,s].join("/"),[a.definitionPath]:{...o,[s]:l}};return"jsonSchema7"===a.target?u.$schema="http://json-schema.org/draft-07/schema#":("jsonSchema2019-09"===a.target||"openAi"===a.target)&&(u.$schema="https://json-schema.org/draft/2019-09/schema#"),"openAi"===a.target&&("anyOf"in u||"oneOf"in u||"allOf"in u||"type"in u&&Array.isArray(u.type))&&console.warn("Warning: OpenAI may not support schemas with unions as roots! Try wrapping it in an object property."),u})(t,{$refStrategy:"none",target:"openapi-3.0"===r?"openApi3":"jsonSchema7"});return delete i.$schema,i}if("zod"===n.vendor&&"_zod"in t)try{let r=nn(t);return delete r.$schema,r}catch(t){throw Error(`Failed to convert a zod schema to JSON Schema (zod v4 without "~standard.jsonSchema"). Upgrade to zod >= 4.2.0. Original error: ${t instanceof Error?t.message:String(t)}`)}throw Error(`Schema library "${n.vendor}" cannot be converted to JSON Schema. Use zod v3 (>= 3.25.76), zod >= 4.2.0, or a Standard Schema library implementing "~standard.jsonSchema".`)}(s,r,t),!function(t,r){if("function"!=typeof t.safeParse)return!1;try{let i=t.safeParse(void 0);return i.success&&("input"===r||void 0===i.data)}catch{return!1}}(s,t)&&o.push(i);let s={type:"object",properties:a};return o.length>0&&(s.required=o),i&&(s.additionalProperties=!1),s},o=async r=>{if("object"!=typeof r||null===r||Array.isArray(r))return{issues:[{message:"Expected an object."}]};let a={},o=[];for(let[t,i]of n){let n=await i["~standard"].validate(r[t]);if(n.issues)for(let r of n.issues)o.push({message:r.message,path:[t,...r.path??[]]});else(t in r||void 0!==n.value)&&(a[t]=n.value)}if(i)for(let i of Object.keys(r))i in t||o.push({message:`Unrecognized key: "${i}"`,path:[i]});return o.length>0?{issues:o}:{value:a}};return{shape:t,"~standard":{version:1,vendor:"xmcp",validate:o,jsonSchema:{input:a("input"),output:a("output")}}}}function m8(t){let r={};return!function t(i,n=""){if(i&&"object"==typeof i)for(let[a,o]of Object.entries(i)){let i=n?`${n}/${a}`:a;!o||"object"!=typeof o||Array.isArray(o)||o instanceof Date||o instanceof RegExp?r[i]=o:t(o,i)}}(t),r}let he=["ui/resourceUri","resourceUri","visibility"],ht=["prefersBorder","domain","csp","permissions","connectDomains","resourceDomains","frameDomains","baseUriDomains"];function hr(t){return"object"==typeof t&&null!==t&&Object.entries(t).every(([t,r])=>"string"==typeof t&&"object"==typeof r&&null!==r&&"parse"in r&&"function"==typeof r.parse)}function hi(t){return(t.split("/").pop()||t).replace(/\.[^/.]+$/,"")}function hn(t,r,i){return t.names?.includes(r)===!0||t.tags?.some(t=>i.includes(t))===!0}function ha(t,r){return r?new Map([...t].filter(([t,{metadata:i}])=>{if(i?.enabled===!1)return!1;let n=i?.name??hi(t),a=i?.tags??[];return(!r.include||hn(r.include,n,a))&&(!r.exclude||!hn(r.exclude,n,a))})):t}function ho(t){return Error(`[xmcp] Invalid prompt file: ${t}
|
|
78
|
-
-> Default export must be a prompt handler function.`)}
|
|
79
|
-
-> ${
|
|
80
|
-
-> Default export must be a resource handler function.`)}
|
|
81
|
-
-> ${
|
|
82
|
-
-> Default export must be a tool handler function.`)}
|
|
83
|
-
-> ${
|
|
69
|
+
`),e.enqueue(t.encode(a))}async handleGetRequest(e){let t,r;if(!e.headers.get("accept")?.includes("text/event-stream"))return this.onerror?.(Error("Not Acceptable: Client must accept text/event-stream")),this.createJsonErrorResponse(406,-32e3,"Not Acceptable: Client must accept text/event-stream");let i=this.validateSession(e);if(i)return i;let n=this.validateProtocolVersion(e);if(n)return n;if(this._eventStore){let t=e.headers.get("last-event-id");if(t)return this.replayEvents(t)}if(void 0!==this._streamMapping.get(this._standaloneSseStreamId))return this.onerror?.(Error("Conflict: Only one SSE stream is allowed per session")),this.createJsonErrorResponse(409,-32e3,"Conflict: Only one SSE stream is allowed per session");let a=new TextEncoder,o=new ReadableStream({start:e=>{t=e},cancel:()=>{void 0!==r&&clearInterval(r),this._streamMapping.get(this._standaloneSseStreamId)?.controller===t&&this._streamMapping.delete(this._standaloneSseStreamId)}}),s={"Content-Type":"text/event-stream","Cache-Control":"no-cache, no-transform",Connection:"keep-alive","X-Accel-Buffering":"no"};return void 0!==this.sessionId&&(s["mcp-session-id"]=this.sessionId),this._streamMapping.set(this._standaloneSseStreamId,{controller:t,encoder:a,cleanup:()=>{void 0!==r&&clearInterval(r),this._streamMapping.delete(this._standaloneSseStreamId);try{t.close()}catch{}}}),r=this.startKeepAlive(t,a),new Response(o,{headers:s})}async replayEvents(e){if(!this._eventStore)return this.onerror?.(Error("Event store not configured")),this.createJsonErrorResponse(400,-32e3,"Event store not configured");try{let t,r,i,n;if(this._eventStore.getStreamIdForEventId){if(!(t=await this._eventStore.getStreamIdForEventId(e)))return this.onerror?.(Error("Invalid event ID format")),this.createJsonErrorResponse(400,-32e3,"Invalid event ID format");if(void 0!==this._streamMapping.get(t))return this.onerror?.(Error("Conflict: Stream already has an active connection")),this.createJsonErrorResponse(409,-32e3,"Conflict: Stream already has an active connection")}let a={"Content-Type":"text/event-stream","Cache-Control":"no-cache, no-transform",Connection:"keep-alive","X-Accel-Buffering":"no"};void 0!==this.sessionId&&(a["mcp-session-id"]=this.sessionId);let o=new TextEncoder,s=!1,l=new ReadableStream({start:e=>{r=e},cancel:()=>{s=!0,void 0!==i&&clearInterval(i),void 0!==n&&this._streamMapping.get(n)?.controller===r&&this._streamMapping.delete(n)}}),c=new Set;if(n=await this._eventStore.replayEventsAfter(e,{send:async(e,t)=>{if(c.add(e),!this.writeSSEEvent(r,o,t,e))try{r.close()}catch{}}}),this._closed||s){try{r.close()}catch{}return this.createJsonErrorResponse(404,-32001,"Session not found")}if(this._streamMapping.get(n)?.cleanup(),this._streamMapping.set(n,{controller:r,encoder:o,replayedEventIds:c,cleanup:()=>{void 0!==i&&clearInterval(i),this._streamMapping.delete(n);try{r.close()}catch{}}}),n!==this._standaloneSseStreamId&&![...this._requestToStreamMapping.values()].includes(n)){this._streamMapping.delete(n);try{r.close()}catch{}}return this._streamMapping.get(n)?.controller===r&&(i=this.startKeepAlive(r,o)),new Response(l,{headers:a})}catch(e){return this.onerror?.(e),this.createJsonErrorResponse(500,-32e3,"Error replaying events")}}writeSSEEvent(e,t,r,i){try{let n=`event: message
|
|
70
|
+
`;return i&&(n+=`id: ${i}
|
|
71
|
+
`),n+=`data: ${JSON.stringify(r)}
|
|
72
|
+
|
|
73
|
+
`,e.enqueue(t.encode(n)),!0}catch(e){return this.onerror?.(e),!1}}handleUnsupportedRequest(){return this.onerror?.(Error("Method not allowed.")),Response.json({jsonrpc:"2.0",error:{code:-32e3,message:"Method not allowed."},id:null},{status:405,headers:{Allow:"GET, POST, DELETE","Content-Type":"application/json"}})}async handlePostRequest(e,t){try{let r,i,n,a,o,s=e.headers.get("accept");if(!s?.includes("application/json")||!s.includes("text/event-stream"))return this.onerror?.(Error("Not Acceptable: Client must accept both application/json and text/event-stream")),this.createJsonErrorResponse(406,-32e3,"Not Acceptable: Client must accept both application/json and text/event-stream");if(!uZ(e.headers.get("content-type")))return this.onerror?.(Error("Unsupported Media Type: Content-Type must be application/json")),this.createJsonErrorResponse(415,-32e3,"Unsupported Media Type: Content-Type must be application/json");if(t?.parsedBody===void 0)try{let t=await dE(e,this._maxRequestBodySize);if(t.tooLarge){let e=dP(this._maxRequestBodySize);return this.onerror?.(Error(e)),this.createJsonErrorResponse(413,-32e3,e)}r=JSON.parse(t.text)}catch(e){return this.onerror?.(e),this.createJsonErrorResponse(400,-32700,"Parse error: Invalid JSON")}else r=t.parsedBody;if(Array.isArray(r)&&r.length>100)return this.onerror?.(Error("Invalid Request: Batch must not exceed 100 messages")),this.createJsonErrorResponse(400,-32600,"Invalid Request: Batch must not exceed 100 messages");try{i=Array.isArray(r)?r.map(e=>ou.parse(e)):[ou.parse(r)]}catch(e){return this.onerror?.(e),this.createJsonErrorResponse(400,-32700,"Parse error: Invalid JSON-RPC message")}if(this._closed)return this.createJsonErrorResponse(404,-32001,"Session not found");let l=i.some(e=>ox.safeParse(e).success);if(l){if(this._initialized&&void 0!==this.sessionId)return this.onerror?.(Error("Invalid Request: Server already initialized")),this.createJsonErrorResponse(400,-32600,"Invalid Request: Server already initialized");if(i.length>1)return this.onerror?.(Error("Invalid Request: Only one initialization request is allowed")),this.createJsonErrorResponse(400,-32600,"Invalid Request: Only one initialization request is allowed");this.sessionId=this.sessionIdGenerator?.(),this._initialized=!0,this.sessionId&&this._onsessioninitialized&&await Promise.resolve(this._onsessioninitialized(this.sessionId))}if(!l){let t=this.validateSession(e);if(t)return t;let r=this.validateProtocolVersion(e);if(r)return r}if(this._closed)return this.createJsonErrorResponse(404,-32001,"Session not found");try{n=await this._checkScopeChallenge(i,t?.authInfo)}catch(e){return this.onerror?.(e),this.createJsonErrorResponse(500,-32603,"Internal server error")}if(n)return n;if(!i.some(e=>cY(e))){for(let r of i)this.onmessage?.(r,{authInfo:t?.authInfo,request:e});return new Response(null,{status:202})}let c=crypto.randomUUID(),u=i.find(e=>ox.safeParse(e).success),d=u?u.params.protocolVersion:e.headers.get("mcp-protocol-version")??"2025-03-26";if(this._enableJsonResponse)return new Promise(r=>{for(let e of(this._streamMapping.set(c,{resolveJson:r,cleanup:()=>{this._streamMapping.delete(c)}}),i))cY(e)&&this._requestToStreamMapping.set(e.id,c);for(let r of i)this.onmessage?.(r,{authInfo:t?.authInfo,request:e})});let p=new TextEncoder,m=new ReadableStream({start:e=>{a=e},cancel:()=>{void 0!==o&&clearInterval(o),this._streamMapping.get(c)?.controller===a&&this._streamMapping.delete(c)}}),h={"Content-Type":"text/event-stream","Cache-Control":"no-cache, no-transform",Connection:"keep-alive","X-Accel-Buffering":"no"};for(let e of(void 0!==this.sessionId&&(h["mcp-session-id"]=this.sessionId),i))cY(e)&&(this._streamMapping.set(c,{controller:a,encoder:p,cleanup:()=>{void 0!==o&&clearInterval(o),this._streamMapping.delete(c);try{a.close()}catch{}}}),this._requestToStreamMapping.set(e.id,c));for(let r of(await this.writePrimingEvent(a,p,c,d),i)){let i,n;cY(r)&&this._eventStore&&this.supportsEmptySSEData(d)&&(i=()=>{this.closeSSEStream(r.id)},n=()=>{this.closeStandaloneSSEStream()}),this.onmessage?.(r,{authInfo:t?.authInfo,request:e,closeSSEStream:i,closeStandaloneSSEStream:n})}return this._streamMapping.get(c)?.controller===a&&(o=this.startKeepAlive(a,p)),new Response(m,{status:200,headers:h})}catch(e){return this.onerror?.(e),this.createJsonErrorResponse(400,-32700,"Parse error",{data:String(e)})}}async handleDeleteRequest(e){let t=this.validateSession(e);if(t)return t;let r=this.validateProtocolVersion(e);if(r)return r;try{return await Promise.resolve(this._onsessionclosed?.(this.sessionId)),new Response(null,{status:200})}finally{await this.close()}}validateSession(e){if(void 0===this.sessionIdGenerator)return;if(!this._initialized)return this.onerror?.(Error("Bad Request: Server not initialized")),this.createJsonErrorResponse(400,-32e3,"Bad Request: Server not initialized");let t=e.headers.get("mcp-session-id");return t?t!==this.sessionId?(this.onerror?.(Error("Session not found")),this.createJsonErrorResponse(404,-32001,"Session not found")):void 0:(this.onerror?.(Error("Bad Request: Mcp-Session-Id header is required")),this.createJsonErrorResponse(400,-32e3,"Bad Request: Mcp-Session-Id header is required"))}validateProtocolVersion(e){let t=e.headers.get("mcp-protocol-version");if(null!==t&&!this._supportedProtocolVersions.includes(t)){let e=`Bad Request: Unsupported protocol version: ${t} (supported versions: ${this._supportedProtocolVersions.join(", ")})`;return this.onerror?.(Error(e)),this.createJsonErrorResponse(400,-32e3,e)}}async close(){if(!this._closed){for(let{cleanup:e}of(this._closed=!0,this._streamMapping.values()))e();this._streamMapping.clear(),this._requestResponseMap.clear(),this.onclose?.()}}closeSSEStream(e){let t=this._requestToStreamMapping.get(e);if(!t)return;let r=this._streamMapping.get(t);r&&r.cleanup()}closeStandaloneSSEStream(){let e=this._streamMapping.get(this._standaloneSseStreamId);e&&e.cleanup()}async send(e,t){let r=t?.relatedRequestId;if((cQ(e)||c0(e))&&(r=e.id),void 0===r){let t;if(cQ(e)||c0(e))throw Error("Cannot send a response on a standalone SSE stream unless resuming a previous client request");this._eventStore&&(t=await this._eventStore.storeEvent(this._standaloneSseStreamId,e));let r=this._streamMapping.get(this._standaloneSseStreamId);if(void 0===r)return;r.controller&&r.encoder&&(void 0===t||!r.replayedEventIds?.has(t))&&this.writeSSEEvent(r.controller,r.encoder,e,t);return}let i=this._requestToStreamMapping.get(r);if(!i)throw Error(`No connection established for request ID: ${String(r)}`);let n=this._streamMapping.get(i);if(!this._enableJsonResponse){let t;this._eventStore&&(t=await this._eventStore.storeEvent(i,e),n=this._streamMapping.get(i)),n?.controller&&n?.encoder&&(void 0===t||!n.replayedEventIds?.has(t))&&this.writeSSEEvent(n.controller,n.encoder,e,t)}if(cQ(e)||c0(e)){this._requestResponseMap.set(r,e);let t=[...this._requestToStreamMapping.entries()].filter(([e,t])=>t===i).map(([e])=>e);if(t.every(e=>this._requestResponseMap.has(e))){if(!n){if(this._enableJsonResponse)throw Error(`No connection established for request ID: ${String(r)}`);if(!this._eventStore){for(let e of(this.onerror?.(Error(`Response for request ID ${String(r)} is undeliverable: per-request stream is disconnected and no eventStore is configured`)),t))this._requestResponseMap.delete(e),this._requestToStreamMapping.delete(e);return}for(let e of t)this._requestResponseMap.delete(e),this._requestToStreamMapping.delete(e);return}if(this._enableJsonResponse&&n.resolveJson){let e={"Content-Type":"application/json"};void 0!==this.sessionId&&(e["mcp-session-id"]=this.sessionId);let r=t.map(e=>this._requestResponseMap.get(e));1===r.length?n.resolveJson(Response.json(r[0],{status:200,headers:e})):n.resolveJson(Response.json(r,{status:200,headers:e})),n.cleanup()}else n.cleanup();for(let e of t)this._requestResponseMap.delete(e),this._requestToStreamMapping.delete(e)}}}};function dq(e){if(null===e||"object"!=typeof e||Array.isArray(e))return null;let{method:t,id:r}=e;return"string"!=typeof t?null:"string"==typeof r||"number"==typeof r?r:null}function dj(e,t,r,i,n=null){return Response.json({jsonrpc:"2.0",error:{code:t,message:r,...void 0!==i&&{data:i}},id:n},{status:e,...405===e&&{headers:{Allow:"POST"}}})}function dz(e,t=null){return dj(e.httpStatus,e.code,e.message,e.data,t)}function dA(e){return e instanceof Error?e:Error(String(e))}function dN(e=null){return dj(500,-32603,"Internal server error",void 0,e)}function dM(e){if(void 0!==e.transport)throw Error("The factory returned an instance that is still serving another request. Return a new instance for each request.")}function dL(e){return{protocolVersionHeader:e.headers.get("mcp-protocol-version")??void 0,mcpMethodHeader:e.headers.get("mcp-method")??void 0,mcpNameHeader:e.headers.get("mcp-name")??void 0}}let dZ=(e,t)=>{globalThis[e]=t},dU=e=>globalThis[e];function dF({name:e,fallback:t=!0}){let r=Symbol.for(`xmcp-context-${e}`),i=Symbol.for(`xmcp-context-${e}-fallback-store`);if(dU(r))return dU(r);let n=new x,a=globalThis[i]??{current:null};dZ(i,a);let o={provider:(e,r)=>(t&&(a.current=e),n.run(e,r)),getContext:()=>{let r=n.getStore();if(r)return r;if(t&&a.current)return a.current;throw Error(`getContext() can only be used within the ${e} context.`)},setContext:r=>{let i=n.getStore()??(t?a.current:null);if(!i)throw Error(`setContext() can only be used within the ${e} context.`);Object.assign(i,r)}};return dZ(r,o),o}let dD=dF({name:"http-request-context"});dD.setContext;let dH=dD.getContext,dJ=dD.provider,dV=e=>"object"==typeof e&&null!==e&&!Array.isArray(e),dB=e=>{if(!dV(e)||"string"!=typeof e.name||"string"!=typeof e.version)return;let t={name:e.name,version:e.version};return"string"==typeof e.title&&(t.title=e.title),"string"==typeof e.websiteUrl&&(t.websiteUrl=e.websiteUrl),"string"==typeof e.description&&(t.description=e.description),t},dW=e=>{if(e&&"initialize"===e.method&&dV(e.params))return dB(e.params.clientInfo)},dG=(e,t)=>{let r=t.toLowerCase();for(let[t,i]of Object.entries(e)){if(t.toLowerCase()!==r)continue;let e=Array.isArray(i)?i[0]:i;if("string"!=typeof e)break;let n=e.trim();return n.length>0?n:void 0}};function dK(e){let{tags:t,enabled:r,...i}=e;return{...i,_meta:void 0===t?i._meta:{...i._meta,"xmcp/tags":t}}}let dY=new class{add(e,t){this.resources.set(e,t)}getAll(){return this.resources}clear(){this.resources.clear()}has(e){return this.resources.has(e)}constructor(){var e,t;e="resources",t=new Map,e in this?Object.defineProperty(this,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):this[e]=t}},dX=dF({name:"request-context",fallback:!1}),dQ=dF({name:"client-info-context"});dQ.setContext;let d0=dQ.getContext;dQ.provider;let d1=new Set(["message","mode","requestedSchema"]),d2=new Set(["elicitationId","message","mode","url"]),d9=new Set(["properties","required","type"]),d4=new Set(["default","description","format","maxLength","minLength","title","type"]),d3=new Set(["default","description","enum","enumNames","title","type"]),d6=new Set(["default","description","title","type"]),d5=new Set(["default","description","maximum","minimum","title","type"]),d7=new Set(["date","date-time","email","uri"]);function d8(e,t,r){let i=Object.keys(e).filter(e=>!t.has(e));if(0!==i.length)throw Error(`${r} includes unsupported key(s): ${i.join(", ")}.`)}function pe(e,t){if("object"!=typeof e||null===e||Array.isArray(e))throw Error(t)}function pt(e,t){if("string"!=typeof e)throw Error(t)}function pr(e,t){if("string"!=typeof e||0===e.trim().length)throw Error(t)}function pi(e,t){if(void 0!==e&&"string"!=typeof e)throw Error(t)}function pn(e,t){if(void 0!==e&&"number"!=typeof e)throw Error(t)}function pa(e,t){if(!Array.isArray(e)||e.some(e=>"string"!=typeof e))throw Error(t)}let po=new Set(["_meta","includeContext","maxTokens","messages","metadata","modelPreferences","stopSequences","systemPrompt","temperature"]),ps=new Set(["task","toolChoice","tools"]),pl=new Set(["text","image","audio"]);function pc(e,t){if("object"!=typeof e||null===e||Array.isArray(e))throw Error(t)}let pu={text:e=>"string"!=typeof e.text?{valid:!1,error:'Text content must have a "text" property of type string'}:{valid:!0},image:e=>"string"!=typeof e.data?{valid:!1,error:'Image content must have a "data" property of type string (base64-encoded image)'}:"string"!=typeof e.mimeType?{valid:!1,error:'Image content must have a "mimeType" property of type string'}:{valid:!0},audio:e=>"string"!=typeof e.data?{valid:!1,error:'Audio content must have a "data" property of type string (base64-encoded audio)'}:"string"!=typeof e.mimeType?{valid:!1,error:'Audio content must have a "mimeType" property of type string'}:{valid:!0},resource_link:e=>"string"!=typeof e.name?{valid:!1,error:'Resource link content must have a "name" property of type string'}:"string"!=typeof e.uri?{valid:!1,error:'Resource link content must have a "uri" property of type string'}:void 0!==e.title&&"string"!=typeof e.title?{valid:!1,error:'Resource link "title" property must be a string if provided'}:void 0!==e.description&&"string"!=typeof e.description?{valid:!1,error:'Resource link "description" property must be a string if provided'}:void 0!==e.mimeType&&"string"!=typeof e.mimeType?{valid:!1,error:'Resource link "mimeType" property must be a string if provided'}:{valid:!0}};function pd(e){if(!e||"object"!=typeof e)return{valid:!1,error:"Content must be an object"};if("string"!=typeof e.type)return{valid:!1,error:'Content must have a "type" property of type string'};if(void 0!==e._meta&&(null===e._meta||"object"!=typeof e._meta))return{valid:!1,error:'Content "_meta" property must be an object if provided'};let t=pu[e.type];return t?t(e):{valid:!0}}function pp(e,t,r,i){if(null===e||"object"!=typeof e||Array.isArray(e))throw Error(`Tool "${r}" ${i}: expected a plain object.`);let n=new Set(Object.keys(t)),a=Object.keys(e).filter(e=>!n.has(e));if(a.length>0)throw Error(`Tool "${r}" ${i}: unrecognized key(s): ${a.join(", ")}`);for(let[n,a]of Object.entries(t))try{a.parse(e[n])}catch(e){throw Error(`Tool "${r}" ${i}: ${e?.message??`invalid field "${n}"`}`)}}function pm(e){return!!(e&&"object"==typeof e&&Object.keys(e).some(e=>e.startsWith("ui/")))}function ph(e){let t=e.mcpReq.envelope,r=dB(t?.[aG]);if(!r)try{let e,t=dH();r=t.clientInfo??(e=t.headers,dB({name:dG(e,"x-mcp-client-name"),version:dG(e,"x-mcp-client-version"),title:dG(e,"x-mcp-client-title"),websiteUrl:dG(e,"x-mcp-client-website-url"),description:dG(e,"x-mcp-client-description")}))}catch{}if(!r)try{r=d0().clientInfo}catch{}return r}function pf(e){let t=[...e];return(e,r,i)=>(function(e,t,r){let i,n=new Map;if(e.http){let e=dH(),t=Object.fromEntries(Object.entries(e.headers).map(([e,t])=>[e,Array.isArray(t)?Object.freeze([...t]):t]));i=Object.freeze({id:e.id,headers:Object.freeze(t)})}return dX.provider(Object.freeze({clientInfo:t?Object.freeze({...t}):void 0,http:i,authInfo:e.http?.authInfo,signal:e.mcpReq.signal,set(e,t){n.set(e,t)},get:e=>n.get(e),async progress(t,r){let i=e.mcpReq._meta?.progressToken;void 0!==i&&await e.mcpReq.notify({method:"notifications/progress",params:{progressToken:i,progress:t,...void 0===r?{}:{total:r}}})},log:(t,r)=>e.mcpReq.log(t,r)}),r)})(r,ph(r),async()=>{if(0===t.length)return i();let r=Object.freeze({...function(){try{return dX.getContext()}catch{throw Error("getRequestContext() can only be used while handling an MCP request.")}}(),...e,params:Object.freeze({...e.params})}),n=-1,a=async e=>{if(e<=n)throw Error("MCP middleware next() can only be called once");n=e;let o=t[e];return o?o(r,()=>a(e+1)):i()};return a(0)})}let pg=new Set(["tools/list","prompts/get","prompts/list","resources/read","resources/list","resources/templates/list","completion/complete"]);function py(e){return e.endsWith(".tsx")}let pv=Symbol("Let zodToJsonSchema decide on which parser to use"),p_={name:void 0,$refStrategy:"root",basePath:["#"],effectStrategy:"input",pipeStrategy:"all",dateStrategy:"format:date-time",mapStrategy:"entries",removeAdditionalStrategy:"passthrough",allowedAdditionalProperties:!0,rejectedAdditionalProperties:!1,definitionPath:"definitions",target:"jsonSchema7",strictUnions:!1,definitions:{},errorMessages:!1,markdownDescription:!1,patternStrategy:"escape",applyRegexFlags:!1,emailStrategy:"format:email",base64Strategy:"contentEncoding:base64",nameStrategy:"ref",openAiAnyTypeName:"OpenAiAnyType"};(O=A||(A={})).assertEqual=e=>{},O.assertIs=function(e){},O.assertNever=function(e){throw Error()},O.arrayToEnum=e=>{let t={};for(let r of e)t[r]=r;return t},O.getValidEnumValues=e=>{let t=O.objectKeys(e).filter(t=>"number"!=typeof e[e[t]]),r={};for(let i of t)r[i]=e[i];return O.objectValues(r)},O.objectValues=e=>O.objectKeys(e).map(function(t){return e[t]}),O.objectKeys="function"==typeof Object.keys?e=>Object.keys(e):e=>{let t=[];for(let r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.push(r);return t},O.find=(e,t)=>{for(let r of e)if(t(r))return r},O.isInteger="function"==typeof Number.isInteger?e=>Number.isInteger(e):e=>"number"==typeof e&&Number.isFinite(e)&&Math.floor(e)===e,O.joinValues=function(e,t=" | "){return e.map(e=>"string"==typeof e?`'${e}'`:e).join(t)},O.jsonStringifyReplacer=(e,t)=>"bigint"==typeof t?t.toString():t,(N||(N={})).mergeShapes=(e,t)=>({...e,...t});let pb=A.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),pS=e=>{switch(typeof e){case"undefined":return pb.undefined;case"string":return pb.string;case"number":return Number.isNaN(e)?pb.nan:pb.number;case"boolean":return pb.boolean;case"function":return pb.function;case"bigint":return pb.bigint;case"symbol":return pb.symbol;case"object":if(Array.isArray(e))return pb.array;if(null===e)return pb.null;if(e.then&&"function"==typeof e.then&&e.catch&&"function"==typeof e.catch)return pb.promise;if("u">typeof Map&&e instanceof Map)return pb.map;if("u">typeof Set&&e instanceof Set)return pb.set;if("u">typeof Date&&e instanceof Date)return pb.date;return pb.object;default:return pb.unknown}},pw=A.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]);class pR extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=e=>{this.issues=[...this.issues,e]},this.addIssues=(e=[])=>{this.issues=[...this.issues,...e]};let t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}format(e){let t=e||function(e){return e.message},r={_errors:[]},i=e=>{for(let n of e.issues)if("invalid_union"===n.code)n.unionErrors.map(i);else if("invalid_return_type"===n.code)i(n.returnTypeError);else if("invalid_arguments"===n.code)i(n.argumentsError);else if(0===n.path.length)r._errors.push(t(n));else{let e=r,i=0;for(;i<n.path.length;){let r=n.path[i],a=i===n.path.length-1;if("_errors"===r){a&&e._errors.push(t(n)),i++;continue}Object.prototype.hasOwnProperty.call(e,r)||("__proto__"===r?Object.defineProperty(e,r,{value:{_errors:[]},writable:!0,enumerable:!0,configurable:!0}):e[r]={_errors:[]}),e=e[r],a&&e._errors.push(t(n)),i++}}};return i(this),r}static assert(e){if(!(e instanceof pR))throw Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,A.jsonStringifyReplacer,2)}get isEmpty(){return 0===this.issues.length}flatten(e=e=>e.message){let t=Object.create(null),r=[];for(let i of this.issues)if(i.path.length>0){let r=i.path[0];t[r]=t[r]||[],t[r].push(e(i))}else r.push(e(i));return{formErrors:r,fieldErrors:t}}get formErrors(){return this.flatten()}}pR.create=e=>new pR(e);let pk=(e,t)=>{let r;switch(e.code){case pw.invalid_type:r=e.received===pb.undefined?"Required":`Expected ${e.expected}, received ${e.received}`;break;case pw.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(e.expected,A.jsonStringifyReplacer)}`;break;case pw.unrecognized_keys:r=`Unrecognized key(s) in object: ${A.joinValues(e.keys,", ")}`;break;case pw.invalid_union:r="Invalid input";break;case pw.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${A.joinValues(e.options)}`;break;case pw.invalid_enum_value:r=`Invalid enum value. Expected ${A.joinValues(e.options)}, received '${e.received}'`;break;case pw.invalid_arguments:r="Invalid function arguments";break;case pw.invalid_return_type:r="Invalid function return type";break;case pw.invalid_date:r="Invalid date";break;case pw.invalid_string:"object"==typeof e.validation?"includes"in e.validation?(r=`Invalid input: must include "${e.validation.includes}"`,"number"==typeof e.validation.position&&(r=`${r} at one or more positions greater than or equal to ${e.validation.position}`)):"startsWith"in e.validation?r=`Invalid input: must start with "${e.validation.startsWith}"`:"endsWith"in e.validation?r=`Invalid input: must end with "${e.validation.endsWith}"`:A.assertNever(e.validation):r="regex"!==e.validation?`Invalid ${e.validation}`:"Invalid";break;case pw.too_small:r="array"===e.type?`Array must contain ${e.exact?"exactly":e.inclusive?"at least":"more than"} ${e.minimum} element(s)`:"string"===e.type?`String must contain ${e.exact?"exactly":e.inclusive?"at least":"over"} ${e.minimum} character(s)`:"number"===e.type||"bigint"===e.type?`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:"date"===e.type?`Date must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(e.minimum))}`:"Invalid input";break;case pw.too_big:r="array"===e.type?`Array must contain ${e.exact?"exactly":e.inclusive?"at most":"less than"} ${e.maximum} element(s)`:"string"===e.type?`String must contain ${e.exact?"exactly":e.inclusive?"at most":"under"} ${e.maximum} character(s)`:"number"===e.type?`Number must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:"bigint"===e.type?`BigInt must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:"date"===e.type?`Date must be ${e.exact?"exactly":e.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(e.maximum))}`:"Invalid input";break;case pw.custom:r="Invalid input";break;case pw.invalid_intersection_types:r="Intersection results could not be merged";break;case pw.not_multiple_of:r=`Number must be a multiple of ${e.multipleOf}`;break;case pw.not_finite:r="Number must be finite";break;default:r=t.defaultError,A.assertNever(e)}return{message:r}};(E=M||(M={})).errToObj=e=>"string"==typeof e?{message:e}:e||{},E.toString=e=>"string"==typeof e?e:e?.message;function px(e,t){let r=(e=>{let{data:t,path:r,errorMaps:i,issueData:n}=e,a=[...r,...n.path||[]],o={...n,path:a};if(void 0!==n.message)return{...n,path:a,message:n.message};let s="";for(let e of i.filter(e=>!!e).slice().reverse())s=e(o,{data:t,defaultError:s}).message;return{...n,path:a,message:s}})({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,pk,void 0].filter(e=>!!e)});e.common.issues.push(r)}class p${constructor(){this.value="valid"}dirty(){"valid"===this.value&&(this.value="dirty")}abort(){"aborted"!==this.value&&(this.value="aborted")}static mergeArray(e,t){let r=[];for(let i of t){if("aborted"===i.status)return pT;"dirty"===i.status&&e.dirty(),r.push(i.value)}return{status:e.value,value:r}}static async mergeObjectAsync(e,t){let r=[];for(let e of t){let t=await e.key,i=await e.value;r.push({key:t,value:i})}return p$.mergeObjectSync(e,r)}static mergeObjectSync(e,t){let r={};for(let i of t){let{key:t,value:n}=i;if("aborted"===t.status||"aborted"===n.status)return pT;"dirty"===t.status&&e.dirty(),"dirty"===n.status&&e.dirty(),"__proto__"!==t.value&&(void 0!==n.value||i.alwaysSet)&&(r[t.value]=n.value)}return{status:e.value,value:r}}}let pT=Object.freeze({status:"aborted"}),pC=e=>({status:"dirty",value:e}),pP=e=>({status:"valid",value:e}),pO=e=>"u">typeof Promise&&e instanceof Promise;class pE{constructor(e,t,r,i){this._cachedPath=[],this.parent=e,this.data=t,this._path=r,this._key=i}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}let pI=(e,t)=>{if("valid"===t.status)return{success:!0,data:t.value};if(!e.common.issues.length)throw Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let t=new pR(e.common.issues);return this._error=t,this._error}}};function pq(e){if(!e)return{};let{errorMap:t,invalid_type_error:r,required_error:i,description:n}=e;if(t&&(r||i))throw Error('Can\'t use "invalid_type_error" or "required_error" in conjunction with custom error map.');return t?{errorMap:t,description:n}:{errorMap:(t,n)=>{let{message:a}=e;return"invalid_enum_value"===t.code?{message:a??n.defaultError}:void 0===n.data?{message:a??i??n.defaultError}:"invalid_type"!==t.code?{message:n.defaultError}:{message:a??r??n.defaultError}},description:n}}class pj{get description(){return this._def.description}_getType(e){return pS(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:pS(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new p$,ctx:{common:e.parent.common,data:e.data,parsedType:pS(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let t=this._parse(e);if(pO(t))throw Error("Synchronous parse encountered promise.");return t}_parseAsync(e){return Promise.resolve(this._parse(e))}parse(e,t){let r=this.safeParse(e,t);if(r.success)return r.data;throw r.error}safeParse(e,t){let r={common:{issues:[],async:t?.async??!1,contextualErrorMap:t?.errorMap},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:pS(e)},i=this._parseSync({data:e,path:r.path,parent:r});return pI(r,i)}"~validate"(e){let t={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:pS(e)};if(!this["~standard"].async)try{let r=this._parseSync({data:e,path:[],parent:t});return"valid"===r.status?{value:r.value}:{issues:t.common.issues}}catch(e){e?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),t.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:t}).then(e=>"valid"===e.status?{value:e.value}:{issues:t.common.issues})}async parseAsync(e,t){let r=await this.safeParseAsync(e,t);if(r.success)return r.data;throw r.error}async safeParseAsync(e,t){let r={common:{issues:[],contextualErrorMap:t?.errorMap,async:!0},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:pS(e)},i=this._parse({data:e,path:r.path,parent:r});return pI(r,await (pO(i)?i:Promise.resolve(i)))}refine(e,t){return this._refinement((r,i)=>{let n=e(r),a=()=>i.addIssue({code:pw.custom,..."string"==typeof t||void 0===t?{message:t}:"function"==typeof t?t(r):t});return"u">typeof Promise&&n instanceof Promise?n.then(e=>!!e||(a(),!1)):!!n||(a(),!1)})}refinement(e,t){return this._refinement((r,i)=>!!e(r)||(i.addIssue("function"==typeof t?t(r,i):t),!1))}_refinement(e){return new mm({schema:this,typeName:L.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:e=>this["~validate"](e)}}optional(){return mh.create(this,this._def)}nullable(){return mf.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return me.create(this)}promise(){return mp.create(this,this._def)}or(e){return mr.create([this,e],this._def)}and(e){return mi.create(this,e,this._def)}transform(e){return new mm({...pq(this._def),schema:this,typeName:L.ZodEffects,effect:{type:"transform",transform:e}})}default(e){return new mg({...pq(this._def),innerType:this,defaultValue:"function"==typeof e?e:()=>e,typeName:L.ZodDefault})}brand(){return new m_({typeName:L.ZodBranded,type:this,...pq(this._def)})}catch(e){return new my({...pq(this._def),innerType:this,catchValue:"function"==typeof e?e:()=>e,typeName:L.ZodCatch})}describe(e){return new this.constructor({...this._def,description:e})}pipe(e){return mb.create(this,e)}readonly(){return mS.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}let pz=/^c[^\s-]{8,}$/i,pA=/^[0-9a-z]+$/,pN=/^[0-9A-HJKMNP-TV-Z]{26}$/i,pM=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,pL=/^[a-z0-9_-]{21}$/i,pZ=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,pU=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,pF=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,pD=/^(?:(?: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])$/,pH=/^(?:(?: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])\/(3[0-2]|[12]?[0-9])$/,pJ=/^(([0-9a-fA-F]{1,4}:){7,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}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,pV=/^(([0-9a-fA-F]{1,4}:){7,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}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,pB=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,pW=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,pG="((\\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])))",pK=RegExp(`^${pG}$`);function pY(e){let t="[0-5]\\d";e.precision?t=`${t}\\.\\d{${e.precision}}`:null==e.precision&&(t=`${t}(\\.\\d+)?`);let r=e.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${t})${r}`}class pX extends pj{_parse(e){var t,r,i,n;let a;if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==pb.string){let t=this._getOrReturnCtx(e);return px(t,{code:pw.invalid_type,expected:pb.string,received:t.parsedType}),pT}let o=new p$;for(let s of this._def.checks)if("min"===s.kind)e.data.length<s.value&&(px(a=this._getOrReturnCtx(e,a),{code:pw.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),o.dirty());else if("max"===s.kind)e.data.length>s.value&&(px(a=this._getOrReturnCtx(e,a),{code:pw.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),o.dirty());else if("length"===s.kind){let t=e.data.length>s.value,r=e.data.length<s.value;(t||r)&&(a=this._getOrReturnCtx(e,a),t?px(a,{code:pw.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}):r&&px(a,{code:pw.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}),o.dirty())}else if("email"===s.kind)pF.test(e.data)||(px(a=this._getOrReturnCtx(e,a),{validation:"email",code:pw.invalid_string,message:s.message}),o.dirty());else if("emoji"===s.kind)p||(p=RegExp("^[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$","u")),p.test(e.data)||(px(a=this._getOrReturnCtx(e,a),{validation:"emoji",code:pw.invalid_string,message:s.message}),o.dirty());else if("uuid"===s.kind)pM.test(e.data)||(px(a=this._getOrReturnCtx(e,a),{validation:"uuid",code:pw.invalid_string,message:s.message}),o.dirty());else if("nanoid"===s.kind)pL.test(e.data)||(px(a=this._getOrReturnCtx(e,a),{validation:"nanoid",code:pw.invalid_string,message:s.message}),o.dirty());else if("cuid"===s.kind)pz.test(e.data)||(px(a=this._getOrReturnCtx(e,a),{validation:"cuid",code:pw.invalid_string,message:s.message}),o.dirty());else if("cuid2"===s.kind)pA.test(e.data)||(px(a=this._getOrReturnCtx(e,a),{validation:"cuid2",code:pw.invalid_string,message:s.message}),o.dirty());else if("ulid"===s.kind)pN.test(e.data)||(px(a=this._getOrReturnCtx(e,a),{validation:"ulid",code:pw.invalid_string,message:s.message}),o.dirty());else if("url"===s.kind)try{new URL(e.data)}catch{px(a=this._getOrReturnCtx(e,a),{validation:"url",code:pw.invalid_string,message:s.message}),o.dirty()}else"regex"===s.kind?(s.regex.lastIndex=0,s.regex.test(e.data)||(px(a=this._getOrReturnCtx(e,a),{validation:"regex",code:pw.invalid_string,message:s.message}),o.dirty())):"trim"===s.kind?e.data=e.data.trim():"includes"===s.kind?e.data.includes(s.value,s.position)||(px(a=this._getOrReturnCtx(e,a),{code:pw.invalid_string,validation:{includes:s.value,position:s.position},message:s.message}),o.dirty()):"toLowerCase"===s.kind?e.data=e.data.toLowerCase():"toUpperCase"===s.kind?e.data=e.data.toUpperCase():"startsWith"===s.kind?e.data.startsWith(s.value)||(px(a=this._getOrReturnCtx(e,a),{code:pw.invalid_string,validation:{startsWith:s.value},message:s.message}),o.dirty()):"endsWith"===s.kind?e.data.endsWith(s.value)||(px(a=this._getOrReturnCtx(e,a),{code:pw.invalid_string,validation:{endsWith:s.value},message:s.message}),o.dirty()):"datetime"===s.kind?(function(e){let t=`${pG}T${pY(e)}`,r=[];return r.push(e.local?"Z?":"Z"),e.offset&&r.push("([+-]\\d{2}:?\\d{2})"),t=`${t}(${r.join("|")})`,RegExp(`^${t}$`)})(s).test(e.data)||(px(a=this._getOrReturnCtx(e,a),{code:pw.invalid_string,validation:"datetime",message:s.message}),o.dirty()):"date"===s.kind?pK.test(e.data)||(px(a=this._getOrReturnCtx(e,a),{code:pw.invalid_string,validation:"date",message:s.message}),o.dirty()):"time"===s.kind?RegExp(`^${pY(s)}$`).test(e.data)||(px(a=this._getOrReturnCtx(e,a),{code:pw.invalid_string,validation:"time",message:s.message}),o.dirty()):"duration"===s.kind?pU.test(e.data)||(px(a=this._getOrReturnCtx(e,a),{validation:"duration",code:pw.invalid_string,message:s.message}),o.dirty()):"ip"===s.kind?(t=e.data,!(("v4"===(r=s.version)||!r)&&pD.test(t)||("v6"===r||!r)&&pJ.test(t))&&1&&(px(a=this._getOrReturnCtx(e,a),{validation:"ip",code:pw.invalid_string,message:s.message}),o.dirty())):"jwt"===s.kind?!function(e,t){if(!pZ.test(e))return!1;try{let[r]=e.split(".");if(!r)return!1;let i=r.replace(/-/g,"+").replace(/_/g,"/").padEnd(r.length+(4-r.length%4)%4,"="),n=JSON.parse(atob(i));if("object"!=typeof n||null===n||"typ"in n&&n?.typ!=="JWT"||!n.alg||t&&n.alg!==t)return!1;return!0}catch{return!1}}(e.data,s.alg)&&(px(a=this._getOrReturnCtx(e,a),{validation:"jwt",code:pw.invalid_string,message:s.message}),o.dirty()):"cidr"===s.kind?(i=e.data,!(("v4"===(n=s.version)||!n)&&pH.test(i)||("v6"===n||!n)&&pV.test(i))&&1&&(px(a=this._getOrReturnCtx(e,a),{validation:"cidr",code:pw.invalid_string,message:s.message}),o.dirty())):"base64"===s.kind?pB.test(e.data)||(px(a=this._getOrReturnCtx(e,a),{validation:"base64",code:pw.invalid_string,message:s.message}),o.dirty()):"base64url"===s.kind?pW.test(e.data)||(px(a=this._getOrReturnCtx(e,a),{validation:"base64url",code:pw.invalid_string,message:s.message}),o.dirty()):A.assertNever(s);return{status:o.value,value:e.data}}_regex(e,t,r){return this.refinement(t=>e.test(t),{validation:t,code:pw.invalid_string,...M.errToObj(r)})}_addCheck(e){return new pX({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...M.errToObj(e)})}url(e){return this._addCheck({kind:"url",...M.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...M.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...M.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...M.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...M.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...M.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...M.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...M.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...M.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...M.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...M.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...M.errToObj(e)})}datetime(e){return"string"==typeof e?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:void 0===e?.precision?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...M.errToObj(e?.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return"string"==typeof e?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:void 0===e?.precision?null:e?.precision,...M.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...M.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...M.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t?.position,...M.errToObj(t?.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...M.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...M.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...M.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...M.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...M.errToObj(t)})}nonempty(e){return this.min(1,M.errToObj(e))}trim(){return new pX({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new pX({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new pX({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>"datetime"===e.kind)}get isDate(){return!!this._def.checks.find(e=>"date"===e.kind)}get isTime(){return!!this._def.checks.find(e=>"time"===e.kind)}get isDuration(){return!!this._def.checks.find(e=>"duration"===e.kind)}get isEmail(){return!!this._def.checks.find(e=>"email"===e.kind)}get isURL(){return!!this._def.checks.find(e=>"url"===e.kind)}get isEmoji(){return!!this._def.checks.find(e=>"emoji"===e.kind)}get isUUID(){return!!this._def.checks.find(e=>"uuid"===e.kind)}get isNANOID(){return!!this._def.checks.find(e=>"nanoid"===e.kind)}get isCUID(){return!!this._def.checks.find(e=>"cuid"===e.kind)}get isCUID2(){return!!this._def.checks.find(e=>"cuid2"===e.kind)}get isULID(){return!!this._def.checks.find(e=>"ulid"===e.kind)}get isIP(){return!!this._def.checks.find(e=>"ip"===e.kind)}get isCIDR(){return!!this._def.checks.find(e=>"cidr"===e.kind)}get isBase64(){return!!this._def.checks.find(e=>"base64"===e.kind)}get isBase64url(){return!!this._def.checks.find(e=>"base64url"===e.kind)}get minLength(){let e=null;for(let t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(let t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return e}}pX.create=e=>new pX({checks:[],typeName:L.ZodString,coerce:e?.coerce??!1,...pq(e)});class pQ extends pj{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){let t;if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==pb.number){let t=this._getOrReturnCtx(e);return px(t,{code:pw.invalid_type,expected:pb.number,received:t.parsedType}),pT}let r=new p$;for(let i of this._def.checks)"int"===i.kind?A.isInteger(e.data)||(px(t=this._getOrReturnCtx(e,t),{code:pw.invalid_type,expected:"integer",received:"float",message:i.message}),r.dirty()):"min"===i.kind?(i.inclusive?e.data<i.value:e.data<=i.value)&&(px(t=this._getOrReturnCtx(e,t),{code:pw.too_small,minimum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),r.dirty()):"max"===i.kind?(i.inclusive?e.data>i.value:e.data>=i.value)&&(px(t=this._getOrReturnCtx(e,t),{code:pw.too_big,maximum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),r.dirty()):"multipleOf"===i.kind?0!==function(e,t){let r=(e.toString().split(".")[1]||"").length,i=(t.toString().split(".")[1]||"").length,n=r>i?r:i;return Number.parseInt(e.toFixed(n).replace(".",""))%Number.parseInt(t.toFixed(n).replace(".",""))/10**n}(e.data,i.value)&&(px(t=this._getOrReturnCtx(e,t),{code:pw.not_multiple_of,multipleOf:i.value,message:i.message}),r.dirty()):"finite"===i.kind?Number.isFinite(e.data)||(px(t=this._getOrReturnCtx(e,t),{code:pw.not_finite,message:i.message}),r.dirty()):A.assertNever(i);return{status:r.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,M.toString(t))}gt(e,t){return this.setLimit("min",e,!1,M.toString(t))}lte(e,t){return this.setLimit("max",e,!0,M.toString(t))}lt(e,t){return this.setLimit("max",e,!1,M.toString(t))}setLimit(e,t,r,i){return new pQ({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:r,message:M.toString(i)}]})}_addCheck(e){return new pQ({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:M.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:M.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:M.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:M.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:M.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:M.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:M.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:M.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:M.toString(e)})}get minValue(){let e=null;for(let t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>"int"===e.kind||"multipleOf"===e.kind&&A.isInteger(e.value))}get isFinite(){let e=null,t=null;for(let r of this._def.checks)if("finite"===r.kind||"int"===r.kind||"multipleOf"===r.kind)return!0;else"min"===r.kind?(null===t||r.value>t)&&(t=r.value):"max"===r.kind&&(null===e||r.value<e)&&(e=r.value);return Number.isFinite(t)&&Number.isFinite(e)}}pQ.create=e=>new pQ({checks:[],typeName:L.ZodNumber,coerce:e?.coerce||!1,...pq(e)});class p0 extends pj{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){let t;if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==pb.bigint)return this._getInvalidInput(e);let r=new p$;for(let i of this._def.checks)"min"===i.kind?(i.inclusive?e.data<i.value:e.data<=i.value)&&(px(t=this._getOrReturnCtx(e,t),{code:pw.too_small,type:"bigint",minimum:i.value,inclusive:i.inclusive,message:i.message}),r.dirty()):"max"===i.kind?(i.inclusive?e.data>i.value:e.data>=i.value)&&(px(t=this._getOrReturnCtx(e,t),{code:pw.too_big,type:"bigint",maximum:i.value,inclusive:i.inclusive,message:i.message}),r.dirty()):"multipleOf"===i.kind?e.data%i.value!==BigInt(0)&&(px(t=this._getOrReturnCtx(e,t),{code:pw.not_multiple_of,multipleOf:i.value,message:i.message}),r.dirty()):A.assertNever(i);return{status:r.value,value:e.data}}_getInvalidInput(e){let t=this._getOrReturnCtx(e);return px(t,{code:pw.invalid_type,expected:pb.bigint,received:t.parsedType}),pT}gte(e,t){return this.setLimit("min",e,!0,M.toString(t))}gt(e,t){return this.setLimit("min",e,!1,M.toString(t))}lte(e,t){return this.setLimit("max",e,!0,M.toString(t))}lt(e,t){return this.setLimit("max",e,!1,M.toString(t))}setLimit(e,t,r,i){return new p0({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:r,message:M.toString(i)}]})}_addCheck(e){return new p0({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:M.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:M.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:M.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:M.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:M.toString(t)})}get minValue(){let e=null;for(let t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return e}}p0.create=e=>new p0({checks:[],typeName:L.ZodBigInt,coerce:e?.coerce??!1,...pq(e)});class p1 extends pj{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==pb.boolean){let t=this._getOrReturnCtx(e);return px(t,{code:pw.invalid_type,expected:pb.boolean,received:t.parsedType}),pT}return pP(e.data)}}p1.create=e=>new p1({typeName:L.ZodBoolean,coerce:e?.coerce||!1,...pq(e)});class p2 extends pj{_parse(e){let t;if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==pb.date){let t=this._getOrReturnCtx(e);return px(t,{code:pw.invalid_type,expected:pb.date,received:t.parsedType}),pT}if(Number.isNaN(e.data.getTime()))return px(this._getOrReturnCtx(e),{code:pw.invalid_date}),pT;let r=new p$;for(let i of this._def.checks)"min"===i.kind?e.data.getTime()<i.value&&(px(t=this._getOrReturnCtx(e,t),{code:pw.too_small,message:i.message,inclusive:!0,exact:!1,minimum:i.value,type:"date"}),r.dirty()):"max"===i.kind?e.data.getTime()>i.value&&(px(t=this._getOrReturnCtx(e,t),{code:pw.too_big,message:i.message,inclusive:!0,exact:!1,maximum:i.value,type:"date"}),r.dirty()):A.assertNever(i);return{status:r.value,value:new Date(e.data.getTime())}}_addCheck(e){return new p2({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:M.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:M.toString(t)})}get minDate(){let e=null;for(let t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return null!=e?new Date(e):null}get maxDate(){let e=null;for(let t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return null!=e?new Date(e):null}}p2.create=e=>new p2({checks:[],coerce:e?.coerce||!1,typeName:L.ZodDate,...pq(e)});class p9 extends pj{_parse(e){if(this._getType(e)!==pb.symbol){let t=this._getOrReturnCtx(e);return px(t,{code:pw.invalid_type,expected:pb.symbol,received:t.parsedType}),pT}return pP(e.data)}}p9.create=e=>new p9({typeName:L.ZodSymbol,...pq(e)});class p4 extends pj{_parse(e){if(this._getType(e)!==pb.undefined){let t=this._getOrReturnCtx(e);return px(t,{code:pw.invalid_type,expected:pb.undefined,received:t.parsedType}),pT}return pP(e.data)}}p4.create=e=>new p4({typeName:L.ZodUndefined,...pq(e)});class p3 extends pj{_parse(e){if(this._getType(e)!==pb.null){let t=this._getOrReturnCtx(e);return px(t,{code:pw.invalid_type,expected:pb.null,received:t.parsedType}),pT}return pP(e.data)}}p3.create=e=>new p3({typeName:L.ZodNull,...pq(e)});class p6 extends pj{constructor(){super(...arguments),this._any=!0}_parse(e){return pP(e.data)}}p6.create=e=>new p6({typeName:L.ZodAny,...pq(e)});class p5 extends pj{constructor(){super(...arguments),this._unknown=!0}_parse(e){return pP(e.data)}}p5.create=e=>new p5({typeName:L.ZodUnknown,...pq(e)});class p7 extends pj{_parse(e){let t=this._getOrReturnCtx(e);return px(t,{code:pw.invalid_type,expected:pb.never,received:t.parsedType}),pT}}p7.create=e=>new p7({typeName:L.ZodNever,...pq(e)});class p8 extends pj{_parse(e){if(this._getType(e)!==pb.undefined){let t=this._getOrReturnCtx(e);return px(t,{code:pw.invalid_type,expected:pb.void,received:t.parsedType}),pT}return pP(e.data)}}p8.create=e=>new p8({typeName:L.ZodVoid,...pq(e)});class me extends pj{_parse(e){let{ctx:t,status:r}=this._processInputParams(e),i=this._def;if(t.parsedType!==pb.array)return px(t,{code:pw.invalid_type,expected:pb.array,received:t.parsedType}),pT;if(null!==i.exactLength){let e=t.data.length>i.exactLength.value,n=t.data.length<i.exactLength.value;(e||n)&&(px(t,{code:e?pw.too_big:pw.too_small,minimum:n?i.exactLength.value:void 0,maximum:e?i.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:i.exactLength.message}),r.dirty())}if(null!==i.minLength&&t.data.length<i.minLength.value&&(px(t,{code:pw.too_small,minimum:i.minLength.value,type:"array",inclusive:!0,exact:!1,message:i.minLength.message}),r.dirty()),null!==i.maxLength&&t.data.length>i.maxLength.value&&(px(t,{code:pw.too_big,maximum:i.maxLength.value,type:"array",inclusive:!0,exact:!1,message:i.maxLength.message}),r.dirty()),t.common.async)return Promise.all([...t.data].map((e,r)=>i.type._parseAsync(new pE(t,e,t.path,r)))).then(e=>p$.mergeArray(r,e));let n=[...t.data].map((e,r)=>i.type._parseSync(new pE(t,e,t.path,r)));return p$.mergeArray(r,n)}get element(){return this._def.type}min(e,t){return new me({...this._def,minLength:{value:e,message:M.toString(t)}})}max(e,t){return new me({...this._def,maxLength:{value:e,message:M.toString(t)}})}length(e,t){return new me({...this._def,exactLength:{value:e,message:M.toString(t)}})}nonempty(e){return this.min(1,e)}}me.create=(e,t)=>new me({type:e,minLength:null,maxLength:null,exactLength:null,typeName:L.ZodArray,...pq(t)});class mt extends pj{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(null!==this._cached)return this._cached;let e=this._def.shape(),t=A.objectKeys(e);return this._cached={shape:e,keys:t},this._cached}_parse(e){if(this._getType(e)!==pb.object){let t=this._getOrReturnCtx(e);return px(t,{code:pw.invalid_type,expected:pb.object,received:t.parsedType}),pT}let{status:t,ctx:r}=this._processInputParams(e),{shape:i,keys:n}=this._getCached(),a=[];if(!(this._def.catchall instanceof p7&&"strip"===this._def.unknownKeys))for(let e in r.data)n.includes(e)||a.push(e);let o=[];for(let e of n){let t=i[e],n=r.data[e];o.push({key:{status:"valid",value:e},value:t._parse(new pE(r,n,r.path,e)),alwaysSet:e in r.data})}if(this._def.catchall instanceof p7){let e=this._def.unknownKeys;if("passthrough"===e)for(let e of a)o.push({key:{status:"valid",value:e},value:{status:"valid",value:r.data[e]}});else if("strict"===e)a.length>0&&(px(r,{code:pw.unrecognized_keys,keys:a}),t.dirty());else if("strip"===e);else throw Error("Internal ZodObject error: invalid unknownKeys value.")}else{let e=this._def.catchall;for(let t of a){let i=r.data[t];o.push({key:{status:"valid",value:t},value:e._parse(new pE(r,i,r.path,t)),alwaysSet:t in r.data})}}return r.common.async?Promise.resolve().then(async()=>{let e=[];for(let t of o){let r=await t.key,i=await t.value;e.push({key:r,value:i,alwaysSet:t.alwaysSet})}return e}).then(e=>p$.mergeObjectSync(t,e)):p$.mergeObjectSync(t,o)}get shape(){return this._def.shape()}strict(e){return M.errToObj,new mt({...this._def,unknownKeys:"strict",...void 0!==e?{errorMap:(t,r)=>{let i=this._def.errorMap?.(t,r).message??r.defaultError;return"unrecognized_keys"===t.code?{message:M.errToObj(e).message??i}:{message:i}}}:{}})}strip(){return new mt({...this._def,unknownKeys:"strip"})}passthrough(){return new mt({...this._def,unknownKeys:"passthrough"})}extend(e){return new mt({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new mt({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:L.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new mt({...this._def,catchall:e})}pick(e){let t={};for(let r of A.objectKeys(e))e[r]&&this.shape[r]&&(t[r]=this.shape[r]);return new mt({...this._def,shape:()=>t})}omit(e){let t={};for(let r of A.objectKeys(this.shape))e[r]||(t[r]=this.shape[r]);return new mt({...this._def,shape:()=>t})}deepPartial(){return function e(t){if(t instanceof mt){let r={};for(let i in t.shape){let n=t.shape[i];r[i]=mh.create(e(n))}return new mt({...t._def,shape:()=>r})}if(t instanceof me)return new me({...t._def,type:e(t.element)});if(t instanceof mh)return mh.create(e(t.unwrap()));if(t instanceof mf)return mf.create(e(t.unwrap()));if(t instanceof mn)return mn.create(t.items.map(t=>e(t)));else return t}(this)}partial(e){let t={};for(let r of A.objectKeys(this.shape)){let i=this.shape[r];e&&!e[r]?t[r]=i:t[r]=i.optional()}return new mt({...this._def,shape:()=>t})}required(e){let t={};for(let r of A.objectKeys(this.shape))if(e&&!e[r])t[r]=this.shape[r];else{let e=this.shape[r];for(;e instanceof mh;)e=e._def.innerType;t[r]=e}return new mt({...this._def,shape:()=>t})}keyof(){return mc(A.objectKeys(this.shape))}}mt.create=(e,t)=>new mt({shape:()=>e,unknownKeys:"strip",catchall:p7.create(),typeName:L.ZodObject,...pq(t)}),mt.strictCreate=(e,t)=>new mt({shape:()=>e,unknownKeys:"strict",catchall:p7.create(),typeName:L.ZodObject,...pq(t)}),mt.lazycreate=(e,t)=>new mt({shape:e,unknownKeys:"strip",catchall:p7.create(),typeName:L.ZodObject,...pq(t)});class mr extends pj{_parse(e){let{ctx:t}=this._processInputParams(e),r=this._def.options;if(t.common.async)return Promise.all(r.map(async e=>{let r={...t,common:{...t.common,issues:[]},parent:null};return{result:await e._parseAsync({data:t.data,path:t.path,parent:r}),ctx:r}})).then(function(e){for(let t of e)if("valid"===t.result.status)return t.result;for(let r of e)if("dirty"===r.result.status)return t.common.issues.push(...r.ctx.common.issues),r.result;let r=e.map(e=>new pR(e.ctx.common.issues));return px(t,{code:pw.invalid_union,unionErrors:r}),pT});{let e,i=[];for(let n of r){let r={...t,common:{...t.common,issues:[]},parent:null},a=n._parseSync({data:t.data,path:t.path,parent:r});if("valid"===a.status)return a;"dirty"!==a.status||e||(e={result:a,ctx:r}),r.common.issues.length&&i.push(r.common.issues)}if(e)return t.common.issues.push(...e.ctx.common.issues),e.result;let n=i.map(e=>new pR(e));return px(t,{code:pw.invalid_union,unionErrors:n}),pT}}get options(){return this._def.options}}mr.create=(e,t)=>new mr({options:e,typeName:L.ZodUnion,...pq(t)});class mi extends pj{_parse(e){let{status:t,ctx:r}=this._processInputParams(e),i=(e,i)=>{if("aborted"===e.status||"aborted"===i.status)return pT;let n=function e(t,r){let i=pS(t),n=pS(r);if(t===r)return{valid:!0,data:t};if(i===pb.object&&n===pb.object){let i=A.objectKeys(r),n=A.objectKeys(t).filter(e=>-1!==i.indexOf(e)),a={...t,...r};for(let i of(Object.prototype.hasOwnProperty.call(a,"__proto__")&&delete a.__proto__,n)){if("__proto__"===i)continue;let n=e(t[i],r[i]);if(!n.valid)return{valid:!1};a[i]=n.data}return{valid:!0,data:a}}if(i===pb.array&&n===pb.array){if(t.length!==r.length)return{valid:!1};let i=[];for(let n=0;n<t.length;n++){let a=e(t[n],r[n]);if(!a.valid)return{valid:!1};i.push(a.data)}return{valid:!0,data:i}}if(i===pb.date&&n===pb.date&&+t==+r)return{valid:!0,data:t};return{valid:!1}}(e.value,i.value);return n.valid?(("dirty"===e.status||"dirty"===i.status)&&t.dirty(),{status:t.value,value:n.data}):(px(r,{code:pw.invalid_intersection_types}),pT)};return r.common.async?Promise.all([this._def.left._parseAsync({data:r.data,path:r.path,parent:r}),this._def.right._parseAsync({data:r.data,path:r.path,parent:r})]).then(([e,t])=>i(e,t)):i(this._def.left._parseSync({data:r.data,path:r.path,parent:r}),this._def.right._parseSync({data:r.data,path:r.path,parent:r}))}}mi.create=(e,t,r)=>new mi({left:e,right:t,typeName:L.ZodIntersection,...pq(r)});class mn extends pj{_parse(e){let{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==pb.array)return px(r,{code:pw.invalid_type,expected:pb.array,received:r.parsedType}),pT;if(r.data.length<this._def.items.length)return px(r,{code:pw.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),pT;!this._def.rest&&r.data.length>this._def.items.length&&(px(r,{code:pw.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());let i=[...r.data].map((e,t)=>{let i=this._def.items[t]||this._def.rest;return i?i._parse(new pE(r,e,r.path,t)):null}).filter(e=>!!e);return r.common.async?Promise.all(i).then(e=>p$.mergeArray(t,e)):p$.mergeArray(t,i)}get items(){return this._def.items}rest(e){return new mn({...this._def,rest:e})}}mn.create=(e,t)=>{if(!Array.isArray(e))throw Error("You must pass an array of schemas to z.tuple([ ... ])");return new mn({items:e,typeName:L.ZodTuple,rest:null,...pq(t)})};class ma extends pj{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==pb.map)return px(r,{code:pw.invalid_type,expected:pb.map,received:r.parsedType}),pT;let i=this._def.keyType,n=this._def.valueType,a=[...r.data.entries()].map(([e,t],a)=>({key:i._parse(new pE(r,e,r.path,[a,"key"])),value:n._parse(new pE(r,t,r.path,[a,"value"]))}));if(r.common.async){let e=new Map;return Promise.resolve().then(async()=>{for(let r of a){let i=await r.key,n=await r.value;if("aborted"===i.status||"aborted"===n.status)return pT;("dirty"===i.status||"dirty"===n.status)&&t.dirty(),e.set(i.value,n.value)}return{status:t.value,value:e}})}{let e=new Map;for(let r of a){let i=r.key,n=r.value;if("aborted"===i.status||"aborted"===n.status)return pT;("dirty"===i.status||"dirty"===n.status)&&t.dirty(),e.set(i.value,n.value)}return{status:t.value,value:e}}}}ma.create=(e,t,r)=>new ma({valueType:t,keyType:e,typeName:L.ZodMap,...pq(r)});class mo extends pj{_parse(e){let{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==pb.set)return px(r,{code:pw.invalid_type,expected:pb.set,received:r.parsedType}),pT;let i=this._def;null!==i.minSize&&r.data.size<i.minSize.value&&(px(r,{code:pw.too_small,minimum:i.minSize.value,type:"set",inclusive:!0,exact:!1,message:i.minSize.message}),t.dirty()),null!==i.maxSize&&r.data.size>i.maxSize.value&&(px(r,{code:pw.too_big,maximum:i.maxSize.value,type:"set",inclusive:!0,exact:!1,message:i.maxSize.message}),t.dirty());let n=this._def.valueType;function a(e){let r=new Set;for(let i of e){if("aborted"===i.status)return pT;"dirty"===i.status&&t.dirty(),r.add(i.value)}return{status:t.value,value:r}}let o=[...r.data.values()].map((e,t)=>n._parse(new pE(r,e,r.path,t)));return r.common.async?Promise.all(o).then(e=>a(e)):a(o)}min(e,t){return new mo({...this._def,minSize:{value:e,message:M.toString(t)}})}max(e,t){return new mo({...this._def,maxSize:{value:e,message:M.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}mo.create=(e,t)=>new mo({valueType:e,minSize:null,maxSize:null,typeName:L.ZodSet,...pq(t)});class ms extends pj{get schema(){return this._def.getter()}_parse(e){let{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}}ms.create=(e,t)=>new ms({getter:e,typeName:L.ZodLazy,...pq(t)});class ml extends pj{_parse(e){if(e.data!==this._def.value){let t=this._getOrReturnCtx(e);return px(t,{received:t.data,code:pw.invalid_literal,expected:this._def.value}),pT}return{status:"valid",value:e.data}}get value(){return this._def.value}}function mc(e,t){return new mu({values:e,typeName:L.ZodEnum,...pq(t)})}ml.create=(e,t)=>new ml({value:e,typeName:L.ZodLiteral,...pq(t)});class mu extends pj{_parse(e){if("string"!=typeof e.data){let t=this._getOrReturnCtx(e),r=this._def.values;return px(t,{expected:A.joinValues(r),received:t.parsedType,code:pw.invalid_type}),pT}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){let t=this._getOrReturnCtx(e),r=this._def.values;return px(t,{received:t.data,code:pw.invalid_enum_value,options:r}),pT}return pP(e.data)}get options(){return this._def.values}get enum(){let e={};for(let t of this._def.values)e[t]=t;return e}get Values(){let e={};for(let t of this._def.values)e[t]=t;return e}get Enum(){let e={};for(let t of this._def.values)e[t]=t;return e}extract(e,t=this._def){return mu.create(e,{...this._def,...t})}exclude(e,t=this._def){return mu.create(this.options.filter(t=>!e.includes(t)),{...this._def,...t})}}mu.create=mc;class md extends pj{_parse(e){let t=A.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(e);if(r.parsedType!==pb.string&&r.parsedType!==pb.number){let e=A.objectValues(t);return px(r,{expected:A.joinValues(e),received:r.parsedType,code:pw.invalid_type}),pT}if(this._cache||(this._cache=new Set(A.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){let e=A.objectValues(t);return px(r,{received:r.data,code:pw.invalid_enum_value,options:e}),pT}return pP(e.data)}get enum(){return this._def.values}}md.create=(e,t)=>new md({values:e,typeName:L.ZodNativeEnum,...pq(t)});class mp extends pj{unwrap(){return this._def.type}_parse(e){let{ctx:t}=this._processInputParams(e);return t.parsedType!==pb.promise&&!1===t.common.async?(px(t,{code:pw.invalid_type,expected:pb.promise,received:t.parsedType}),pT):pP((t.parsedType===pb.promise?t.data:Promise.resolve(t.data)).then(e=>this._def.type.parseAsync(e,{path:t.path,errorMap:t.common.contextualErrorMap})))}}mp.create=(e,t)=>new mp({type:e,typeName:L.ZodPromise,...pq(t)});class mm extends pj{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===L.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:t,ctx:r}=this._processInputParams(e),i=this._def.effect||null,n={addIssue:e=>{px(r,e),e.fatal?t.abort():t.dirty()},get path(){return r.path}};if(n.addIssue=n.addIssue.bind(n),"preprocess"===i.type){let e=i.transform(r.data,n);if(r.common.async)return Promise.resolve(e).then(async e=>{if("aborted"===t.value)return pT;let i=await this._def.schema._parseAsync({data:e,path:r.path,parent:r});return"aborted"===i.status?pT:"dirty"===i.status||"dirty"===t.value?pC(i.value):i});{if("aborted"===t.value)return pT;let i=this._def.schema._parseSync({data:e,path:r.path,parent:r});return"aborted"===i.status?pT:"dirty"===i.status||"dirty"===t.value?pC(i.value):i}}if("refinement"===i.type){let e=e=>{let t=i.refinement(e,n);if(r.common.async)return Promise.resolve(t);if(t instanceof Promise)throw Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return e};if(!1!==r.common.async)return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(r=>"aborted"===r.status?pT:("dirty"===r.status&&t.dirty(),e(r.value).then(()=>({status:t.value,value:r.value}))));{let i=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});return"aborted"===i.status?pT:("dirty"===i.status&&t.dirty(),e(i.value),{status:t.value,value:i.value})}}if("transform"===i.type)if(!1!==r.common.async)return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(e=>"valid"!==e.status?pT:Promise.resolve(i.transform(e.value,n)).then(e=>({status:t.value,value:e})));else{let e=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if("valid"!==e.status)return pT;let a=i.transform(e.value,n);if(a instanceof Promise)throw Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:a}}A.assertNever(i)}}mm.create=(e,t,r)=>new mm({schema:e,typeName:L.ZodEffects,effect:t,...pq(r)}),mm.createWithPreprocess=(e,t,r)=>new mm({schema:t,effect:{type:"preprocess",transform:e},typeName:L.ZodEffects,...pq(r)});class mh extends pj{_parse(e){return this._getType(e)===pb.undefined?pP(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}mh.create=(e,t)=>new mh({innerType:e,typeName:L.ZodOptional,...pq(t)});class mf extends pj{_parse(e){return this._getType(e)===pb.null?pP(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}mf.create=(e,t)=>new mf({innerType:e,typeName:L.ZodNullable,...pq(t)});class mg extends pj{_parse(e){let{ctx:t}=this._processInputParams(e),r=t.data;return t.parsedType===pb.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}mg.create=(e,t)=>new mg({innerType:e,typeName:L.ZodDefault,defaultValue:"function"==typeof t.default?t.default:()=>t.default,...pq(t)});class my extends pj{_parse(e){let{ctx:t}=this._processInputParams(e),r={...t,common:{...t.common,issues:[]}},i=this._def.innerType._parse({data:r.data,path:r.path,parent:{...r}});return pO(i)?i.then(e=>({status:"valid",value:"valid"===e.status?e.value:this._def.catchValue({get error(){return new pR(r.common.issues)},input:r.data})})):{status:"valid",value:"valid"===i.status?i.value:this._def.catchValue({get error(){return new pR(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}}my.create=(e,t)=>new my({innerType:e,typeName:L.ZodCatch,catchValue:"function"==typeof t.catch?t.catch:()=>t.catch,...pq(t)});class mv extends pj{_parse(e){if(this._getType(e)!==pb.nan){let t=this._getOrReturnCtx(e);return px(t,{code:pw.invalid_type,expected:pb.nan,received:t.parsedType}),pT}return{status:"valid",value:e.data}}}mv.create=e=>new mv({typeName:L.ZodNaN,...pq(e)}),Symbol("zod_brand");class m_ extends pj{_parse(e){let{ctx:t}=this._processInputParams(e),r=t.data;return this._def.type._parse({data:r,path:t.path,parent:t})}unwrap(){return this._def.type}}class mb extends pj{_parse(e){let{status:t,ctx:r}=this._processInputParams(e);if(r.common.async)return(async()=>{let e=await this._def.in._parseAsync({data:r.data,path:r.path,parent:r});return"aborted"===e.status?pT:"dirty"===e.status?(t.dirty(),pC(e.value)):this._def.out._parseAsync({data:e.value,path:r.path,parent:r})})();{let e=this._def.in._parseSync({data:r.data,path:r.path,parent:r});return"aborted"===e.status?pT:"dirty"===e.status?(t.dirty(),{status:"dirty",value:e.value}):this._def.out._parseSync({data:e.value,path:r.path,parent:r})}}static create(e,t){return new mb({in:e,out:t,typeName:L.ZodPipeline})}}class mS extends pj{_parse(e){let t=this._def.innerType._parse(e),r=e=>("valid"===e.status&&(e.value=Object.freeze(e.value)),e);return pO(t)?t.then(e=>r(e)):r(t)}unwrap(){return this._def.innerType}}mS.create=(e,t)=>new mS({innerType:e,typeName:L.ZodReadonly,...pq(t)}),mt.lazycreate,(I=L||(L={})).ZodString="ZodString",I.ZodNumber="ZodNumber",I.ZodNaN="ZodNaN",I.ZodBigInt="ZodBigInt",I.ZodBoolean="ZodBoolean",I.ZodDate="ZodDate",I.ZodSymbol="ZodSymbol",I.ZodUndefined="ZodUndefined",I.ZodNull="ZodNull",I.ZodAny="ZodAny",I.ZodUnknown="ZodUnknown",I.ZodNever="ZodNever",I.ZodVoid="ZodVoid",I.ZodArray="ZodArray",I.ZodObject="ZodObject",I.ZodUnion="ZodUnion",I.ZodDiscriminatedUnion="ZodDiscriminatedUnion",I.ZodIntersection="ZodIntersection",I.ZodTuple="ZodTuple",I.ZodRecord="ZodRecord",I.ZodMap="ZodMap",I.ZodSet="ZodSet",I.ZodFunction="ZodFunction",I.ZodLazy="ZodLazy",I.ZodLiteral="ZodLiteral",I.ZodEnum="ZodEnum",I.ZodEffects="ZodEffects",I.ZodNativeEnum="ZodNativeEnum",I.ZodOptional="ZodOptional",I.ZodNullable="ZodNullable",I.ZodDefault="ZodDefault",I.ZodCatch="ZodCatch",I.ZodPromise="ZodPromise",I.ZodBranded="ZodBranded",I.ZodPipeline="ZodPipeline",I.ZodReadonly="ZodReadonly";let mw=pX.create;pQ.create,mv.create,p0.create,p1.create,p2.create,p9.create,p4.create,p3.create,p6.create,p5.create,p7.create,p8.create,me.create;let mR=mt.create;mt.strictCreate,mr.create,mi.create,mn.create,ma.create,mo.create,ms.create,ml.create,mu.create,md.create,mp.create,mm.create,mh.create,mf.create,mm.createWithPreprocess,mb.create;let mk=(e,t)=>{let r=0;for(;r<e.length&&r<t.length&&e[r]===t[r];r++);return[(e.length-r).toString(),...t.slice(r)].join("/")};function mx(e){if("openAi"!==e.target)return{};let t=[...e.basePath,e.definitionPath,e.openAiAnyTypeName];return e.flags.hasReferencedOpenAiAnyType=!0,{$ref:"relative"===e.$refStrategy?mk(t,e.currentPath):t.join("/")}}function m$(e,t,r,i){i?.errorMessages&&r&&(e.errorMessage={...e.errorMessage,[t]:r})}function mT(e,t,r,i,n){e[t]=r,m$(e,t,i,n)}function mC(e,t){return mG(e.type._def,t)}let mP=/^[cC][^\s-]{8,}$/,mO=/^[0-9a-z]+$/,mE=/^[0-9A-HJKMNP-TV-Z]{26}$/,mI=/^(?!\.)(?!.*\.\.)([a-zA-Z0-9_'+\-\.]*)[a-zA-Z0-9_+-]@([a-zA-Z0-9][a-zA-Z0-9\-]*\.)+[a-zA-Z]{2,}$/,mq=()=>(void 0===k&&(k=RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),k),mj=/^(?:(?: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])\/(3[0-2]|[12]?[0-9])$/,mz=/^(([0-9a-fA-F]{1,4}:){7,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}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,mA=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,mN=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,mM=/^[a-zA-Z0-9_-]{21}$/,mL=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/;function mZ(e,t){let r={type:"string"};if(e.checks)for(let i of e.checks)switch(i.kind){case"min":mT(r,"minLength","number"==typeof r.minLength?Math.max(r.minLength,i.value):i.value,i.message,t);break;case"max":mT(r,"maxLength","number"==typeof r.maxLength?Math.min(r.maxLength,i.value):i.value,i.message,t);break;case"email":switch(t.emailStrategy){case"format:email":mD(r,"email",i.message,t);break;case"format:idn-email":mD(r,"idn-email",i.message,t);break;case"pattern:zod":mH(r,mI,i.message,t)}break;case"url":mD(r,"uri",i.message,t);break;case"uuid":mD(r,"uuid",i.message,t);break;case"regex":mH(r,i.regex,i.message,t);break;case"cuid":mH(r,mP,i.message,t);break;case"cuid2":mH(r,mO,i.message,t);break;case"startsWith":mH(r,RegExp(`^${mU(i.value,t)}`),i.message,t);break;case"endsWith":mH(r,RegExp(`${mU(i.value,t)}$`),i.message,t);break;case"datetime":mD(r,"date-time",i.message,t);break;case"date":mD(r,"date",i.message,t);break;case"time":mD(r,"time",i.message,t);break;case"duration":mD(r,"duration",i.message,t);break;case"length":mT(r,"minLength","number"==typeof r.minLength?Math.max(r.minLength,i.value):i.value,i.message,t),mT(r,"maxLength","number"==typeof r.maxLength?Math.min(r.maxLength,i.value):i.value,i.message,t);break;case"includes":mH(r,RegExp(mU(i.value,t)),i.message,t);break;case"ip":"v6"!==i.version&&mD(r,"ipv4",i.message,t),"v4"!==i.version&&mD(r,"ipv6",i.message,t);break;case"base64url":mH(r,mN,i.message,t);break;case"jwt":mH(r,mL,i.message,t);break;case"cidr":"v6"!==i.version&&mH(r,mj,i.message,t),"v4"!==i.version&&mH(r,mz,i.message,t);break;case"emoji":mH(r,mq(),i.message,t);break;case"ulid":mH(r,mE,i.message,t);break;case"base64":switch(t.base64Strategy){case"format:binary":mD(r,"binary",i.message,t);break;case"contentEncoding:base64":mT(r,"contentEncoding","base64",i.message,t);break;case"pattern:zod":mH(r,mA,i.message,t)}break;case"nanoid":mH(r,mM,i.message,t)}return r}function mU(e,t){return"escape"===t.patternStrategy?function(e){let t="";for(let r=0;r<e.length;r++)mF.has(e[r])||(t+="\\"),t+=e[r];return t}(e):e}let mF=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function mD(e,t,r,i){e.format||e.anyOf?.some(e=>e.format)?(e.anyOf||(e.anyOf=[]),e.format&&(e.anyOf.push({format:e.format,...e.errorMessage&&i.errorMessages&&{errorMessage:{format:e.errorMessage.format}}}),delete e.format,e.errorMessage&&(delete e.errorMessage.format,0===Object.keys(e.errorMessage).length&&delete e.errorMessage)),e.anyOf.push({format:t,...r&&i.errorMessages&&{errorMessage:{format:r}}})):mT(e,"format",t,r,i)}function mH(e,t,r,i){e.pattern||e.allOf?.some(e=>e.pattern)?(e.allOf||(e.allOf=[]),e.pattern&&(e.allOf.push({pattern:e.pattern,...e.errorMessage&&i.errorMessages&&{errorMessage:{pattern:e.errorMessage.pattern}}}),delete e.pattern,e.errorMessage&&(delete e.errorMessage.pattern,0===Object.keys(e.errorMessage).length&&delete e.errorMessage)),e.allOf.push({pattern:mJ(t,i),...r&&i.errorMessages&&{errorMessage:{pattern:r}}})):mT(e,"pattern",mJ(t,i),r,i)}function mJ(e,t){if(!t.applyRegexFlags||!e.flags)return e.source;let r={i:e.flags.includes("i"),m:e.flags.includes("m"),s:e.flags.includes("s")},i=r.i?e.source.toLowerCase():e.source,n="",a=!1,o=!1,s=!1;for(let e=0;e<i.length;e++){if(a){n+=i[e],a=!1;continue}if(r.i){if(o){if(i[e].match(/[a-z]/)){s?(n+=i[e],n+=`${i[e-2]}-${i[e]}`.toUpperCase(),s=!1):"-"===i[e+1]&&i[e+2]?.match(/[a-z]/)?(n+=i[e],s=!0):n+=`${i[e]}${i[e].toUpperCase()}`;continue}}else if(i[e].match(/[a-z]/)){n+=`[${i[e]}${i[e].toUpperCase()}]`;continue}}if(r.m){if("^"===i[e]){n+=`(^|(?<=[\r
|
|
74
|
+
]))`;continue}else if("$"===i[e]){n+=`($|(?=[\r
|
|
75
|
+
]))`;continue}}if(r.s&&"."===i[e]){n+=o?`${i[e]}\r
|
|
76
|
+
`:`[${i[e]}\r
|
|
77
|
+
]`;continue}n+=i[e],"\\"===i[e]?a=!0:o&&"]"===i[e]?o=!1:o||"["!==i[e]||(o=!0)}try{new RegExp(n)}catch{return console.warn(`Could not convert regex pattern at ${t.currentPath.join("/")} to a flag-independent form! Falling back to the flag-ignorant source`),e.source}return n}function mV(e,t){if("openAi"===t.target&&console.warn("Warning: OpenAI may not support records in schemas! Try an array of key-value pairs instead."),"openApi3"===t.target&&e.keyType?._def.typeName===L.ZodEnum)return{type:"object",required:e.keyType._def.values,properties:e.keyType._def.values.reduce((r,i)=>({...r,[i]:mG(e.valueType._def,{...t,currentPath:[...t.currentPath,"properties",i]})??mx(t)}),{}),additionalProperties:t.rejectedAdditionalProperties};let r={type:"object",additionalProperties:mG(e.valueType._def,{...t,currentPath:[...t.currentPath,"additionalProperties"]})??t.allowedAdditionalProperties};if("openApi3"===t.target)return r;if(e.keyType?._def.typeName===L.ZodString&&e.keyType._def.checks?.length){let{type:i,...n}=mZ(e.keyType._def,t);return{...r,propertyNames:n}}if(e.keyType?._def.typeName===L.ZodEnum)return{...r,propertyNames:{enum:e.keyType._def.values}};if(e.keyType?._def.typeName===L.ZodBranded&&e.keyType._def.type._def.typeName===L.ZodString&&e.keyType._def.type._def.checks?.length){let{type:i,...n}=mC(e.keyType._def,t);return{...r,propertyNames:n}}return r}let mB={ZodString:"string",ZodNumber:"number",ZodBigInt:"integer",ZodBoolean:"boolean",ZodNull:"null"},mW=(e,t)=>{let r=(e.options instanceof Map?Array.from(e.options.values()):e.options).map((e,r)=>mG(e._def,{...t,currentPath:[...t.currentPath,"anyOf",`${r}`]})).filter(e=>!!e&&(!t.strictUnions||"object"==typeof e&&Object.keys(e).length>0));return r.length?{anyOf:r}:void 0};function mG(e,t,r=!1){let i=t.seen.get(e);if(t.override){let n=t.override?.(e,t,i,r);if(n!==pv)return n}if(i&&!r){let e=mK(i,t);if(void 0!==e)return e}let n={def:e,path:t.currentPath,jsonSchema:void 0};t.seen.set(e,n);let a=((e,t,r)=>{switch(t){case L.ZodString:return mZ(e,r);case L.ZodNumber:let i={type:"number"};if(!e.checks)return i;for(let t of e.checks)switch(t.kind){case"int":i.type="integer",m$(i,"type",t.message,r);break;case"min":"jsonSchema7"===r.target?t.inclusive?mT(i,"minimum",t.value,t.message,r):mT(i,"exclusiveMinimum",t.value,t.message,r):(t.inclusive||(i.exclusiveMinimum=!0),mT(i,"minimum",t.value,t.message,r));break;case"max":"jsonSchema7"===r.target?t.inclusive?mT(i,"maximum",t.value,t.message,r):mT(i,"exclusiveMaximum",t.value,t.message,r):(t.inclusive||(i.exclusiveMaximum=!0),mT(i,"maximum",t.value,t.message,r));break;case"multipleOf":mT(i,"multipleOf",t.value,t.message,r)}return i;case L.ZodObject:return function(e,t){let r="openAi"===t.target,i={type:"object",properties:{}},n=[],a=e.shape();for(let e in a){let o=a[e];if(void 0===o||void 0===o._def)continue;let s=function(e){try{return e.isOptional()}catch{return!0}}(o);s&&r&&("ZodOptional"===o._def.typeName&&(o=o._def.innerType),o.isNullable()||(o=o.nullable()),s=!1);let l=mG(o._def,{...t,currentPath:[...t.currentPath,"properties",e],propertyPath:[...t.currentPath,"properties",e]});void 0!==l&&(i.properties[e]=l,s||n.push(e))}n.length&&(i.required=n);let o=function(e,t){if("ZodNever"!==e.catchall._def.typeName)return mG(e.catchall._def,{...t,currentPath:[...t.currentPath,"additionalProperties"]});switch(e.unknownKeys){case"passthrough":return t.allowedAdditionalProperties;case"strict":return t.rejectedAdditionalProperties;case"strip":return"strict"===t.removeAdditionalStrategy?t.allowedAdditionalProperties:t.rejectedAdditionalProperties}}(e,t);return void 0!==o&&(i.additionalProperties=o),i}(e,r);case L.ZodBigInt:let n={type:"integer",format:"int64"};if(!e.checks)return n;for(let t of e.checks)switch(t.kind){case"min":"jsonSchema7"===r.target?t.inclusive?mT(n,"minimum",t.value,t.message,r):mT(n,"exclusiveMinimum",t.value,t.message,r):(t.inclusive||(n.exclusiveMinimum=!0),mT(n,"minimum",t.value,t.message,r));break;case"max":"jsonSchema7"===r.target?t.inclusive?mT(n,"maximum",t.value,t.message,r):mT(n,"exclusiveMaximum",t.value,t.message,r):(t.inclusive||(n.exclusiveMaximum=!0),mT(n,"maximum",t.value,t.message,r));break;case"multipleOf":mT(n,"multipleOf",t.value,t.message,r)}return n;case L.ZodBoolean:return{type:"boolean"};case L.ZodDate:return function e(t,r,i){let n=i??r.dateStrategy;if(Array.isArray(n))return{anyOf:n.map((i,n)=>e(t,r,i))};switch(n){case"string":case"format:date-time":return{type:"string",format:"date-time"};case"format:date":return{type:"string",format:"date"};case"integer":var a=t,o=r;let s={type:"integer",format:"unix-time"};if("openApi3"===o.target)return s;for(let e of a.checks)switch(e.kind){case"min":mT(s,"minimum",e.value,e.message,o);break;case"max":mT(s,"maximum",e.value,e.message,o)}return s}}(e,r);case L.ZodUndefined:return{not:mx(r)};case L.ZodNull:return"openApi3"===r.target?{enum:["null"],nullable:!0}:{type:"null"};case L.ZodArray:let a;return a={type:"array"},e.type?._def&&e.type?._def?.typeName!==L.ZodAny&&(a.items=mG(e.type._def,{...r,currentPath:[...r.currentPath,"items"]})),e.minLength&&mT(a,"minItems",e.minLength.value,e.minLength.message,r),e.maxLength&&mT(a,"maxItems",e.maxLength.value,e.maxLength.message,r),e.exactLength&&(mT(a,"minItems",e.exactLength.value,e.exactLength.message,r),mT(a,"maxItems",e.exactLength.value,e.exactLength.message,r)),a;case L.ZodUnion:case L.ZodDiscriminatedUnion:if("openApi3"===r.target)return mW(e,r);let o=e.options instanceof Map?Array.from(e.options.values()):e.options;if(o.every(e=>e._def.typeName in mB&&(!e._def.checks||!e._def.checks.length))){let e=o.reduce((e,t)=>{let r=mB[t._def.typeName];return r&&!e.includes(r)?[...e,r]:e},[]);return{type:e.length>1?e:e[0]}}if(o.every(e=>"ZodLiteral"===e._def.typeName&&!e.description)){let e=o.reduce((e,t)=>{let r=typeof t._def.value;switch(r){case"string":case"number":case"boolean":return[...e,r];case"bigint":return[...e,"integer"];case"object":if(null===t._def.value)return[...e,"null"];default:return e}},[]);if(e.length===o.length){let t=e.filter((e,t,r)=>r.indexOf(e)===t);return{type:t.length>1?t:t[0],enum:o.reduce((e,t)=>e.includes(t._def.value)?e:[...e,t._def.value],[])}}}else if(o.every(e=>"ZodEnum"===e._def.typeName))return{type:"string",enum:o.reduce((e,t)=>[...e,...t._def.values.filter(t=>!e.includes(t))],[])};return mW(e,r);case L.ZodIntersection:let s,l,c;return s=[mG(e.left._def,{...r,currentPath:[...r.currentPath,"allOf","0"]}),mG(e.right._def,{...r,currentPath:[...r.currentPath,"allOf","1"]})].filter(e=>!!e),l="jsonSchema2019-09"===r.target?{unevaluatedProperties:!1}:void 0,c=[],s.forEach(e=>{if((!("type"in e)||"string"!==e.type)&&"allOf"in e)c.push(...e.allOf),void 0===e.unevaluatedProperties&&(l=void 0);else{let t=e;if("additionalProperties"in e&&!1===e.additionalProperties){let{additionalProperties:r,...i}=e;t=i}else l=void 0;c.push(t)}}),c.length?{allOf:c,...l}:void 0;case L.ZodTuple:return e.rest?{type:"array",minItems:e.items.length,items:e.items.map((e,t)=>mG(e._def,{...r,currentPath:[...r.currentPath,"items",`${t}`]})).reduce((e,t)=>void 0===t?e:[...e,t],[]),additionalItems:mG(e.rest._def,{...r,currentPath:[...r.currentPath,"additionalItems"]})}:{type:"array",minItems:e.items.length,maxItems:e.items.length,items:e.items.map((e,t)=>mG(e._def,{...r,currentPath:[...r.currentPath,"items",`${t}`]})).reduce((e,t)=>void 0===t?e:[...e,t],[])};case L.ZodRecord:return mV(e,r);case L.ZodLiteral:let u;return"bigint"!=(u=typeof e.value)&&"number"!==u&&"boolean"!==u&&"string"!==u?{type:Array.isArray(e.value)?"array":"object"}:"openApi3"===r.target?{type:"bigint"===u?"integer":u,enum:[e.value]}:{type:"bigint"===u?"integer":u,const:e.value};case L.ZodEnum:return{type:"string",enum:Array.from(e.values)};case L.ZodNativeEnum:let d,p,m;return d=e.values,{type:1===(m=Array.from(new Set((p=Object.keys(e.values).filter(e=>"number"!=typeof d[d[e]]).map(e=>d[e])).map(e=>typeof e)))).length?"string"===m[0]?"string":"number":["string","number"],enum:p};case L.ZodNullable:if(["ZodString","ZodNumber","ZodBigInt","ZodBoolean","ZodNull"].includes(e.innerType._def.typeName)&&(!e.innerType._def.checks||!e.innerType._def.checks.length))return"openApi3"===r.target?{type:mB[e.innerType._def.typeName],nullable:!0}:{type:[mB[e.innerType._def.typeName],"null"]};if("openApi3"===r.target){let t=mG(e.innerType._def,{...r,currentPath:[...r.currentPath]});return t&&"$ref"in t?{allOf:[t],nullable:!0}:t&&{...t,nullable:!0}}let h=mG(e.innerType._def,{...r,currentPath:[...r.currentPath,"anyOf","0"]});return h&&{anyOf:[h,{type:"null"}]};case L.ZodOptional:if(r.currentPath.toString()===r.propertyPath?.toString())return mG(e.innerType._def,r);let f=mG(e.innerType._def,{...r,currentPath:[...r.currentPath,"anyOf","1"]});return f?{anyOf:[{not:mx(r)},f]}:mx(r);case L.ZodMap:if("record"===r.mapStrategy)return mV(e,r);return{type:"array",maxItems:125,items:{type:"array",items:[mG(e.keyType._def,{...r,currentPath:[...r.currentPath,"items","items","0"]})||mx(r),mG(e.valueType._def,{...r,currentPath:[...r.currentPath,"items","items","1"]})||mx(r)],minItems:2,maxItems:2}};case L.ZodSet:let g;return g={type:"array",uniqueItems:!0,items:mG(e.valueType._def,{...r,currentPath:[...r.currentPath,"items"]})},e.minSize&&mT(g,"minItems",e.minSize.value,e.minSize.message,r),e.maxSize&&mT(g,"maxItems",e.maxSize.value,e.maxSize.message,r),g;case L.ZodLazy:return()=>e.getter()._def;case L.ZodPromise:return mG(e.type._def,r);case L.ZodNaN:case L.ZodNever:return"openAi"===r.target?void 0:{not:mx({...r,currentPath:[...r.currentPath,"not"]})};case L.ZodEffects:return"input"===r.effectStrategy?mG(e.schema._def,r):mx(r);case L.ZodAny:case L.ZodUnknown:return mx(r);case L.ZodDefault:return{...mG(e.innerType._def,r),default:e.defaultValue()};case L.ZodBranded:return mC(e,r);case L.ZodReadonly:case L.ZodCatch:return mG(e.innerType._def,r);case L.ZodPipeline:if("input"===r.pipeStrategy)return mG(e.in._def,r);if("output"===r.pipeStrategy)return mG(e.out._def,r);let y=mG(e.in._def,{...r,currentPath:[...r.currentPath,"allOf","0"]}),v=mG(e.out._def,{...r,currentPath:[...r.currentPath,"allOf",y?"1":"0"]});return{allOf:[y,v].filter(e=>void 0!==e)};case L.ZodFunction:case L.ZodVoid:case L.ZodSymbol:default:return}})(e,e.typeName,t),o="function"==typeof a?mG(a(),t):a;if(o&&mY(e,t,o),t.postProcess){let r=t.postProcess(o,e,t);return n.jsonSchema=o,r}return n.jsonSchema=o,o}let mK=(e,t)=>{switch(t.$refStrategy){case"root":return{$ref:e.path.join("/")};case"relative":return{$ref:mk(t.currentPath,e.path)};case"none":case"seen":if(e.path.length<t.currentPath.length&&e.path.every((e,r)=>t.currentPath[r]===e))return console.warn(`Recursive reference detected at ${t.currentPath.join("/")}! Defaulting to any`),mx(t);return"seen"===t.$refStrategy?mx(t):void 0}},mY=(e,t,r)=>(e.description&&(r.description=e.description,t.markdownDescription&&(r.markdownDescription=e.description)),r);function mX(e,t={}){let{strict:r=!1}=t,i=Object.entries(e),n=e=>({target:t})=>{let n={},a=[];for(let[r,o]of i)n[r]=function(e,t,r){let i=e["~standard"];if(i.jsonSchema)return i.jsonSchema[r]({target:t});if("zod"===e["~standard"].vendor&&!("_zod"in e)&&"_def"in e){let r=((e,t)=>{let r,i,n=(i=void 0!==(r="string"==typeof t?{...p_,name:t}:{...p_,...t}).name?[...r.basePath,r.definitionPath,r.name]:r.basePath,{...r,flags:{hasReferencedOpenAiAnyType:!1},currentPath:i,propertyPath:void 0,seen:new Map(Object.entries(r.definitions).map(([e,t])=>[t._def,{def:t._def,path:[...r.basePath,r.definitionPath,e],jsonSchema:void 0}]))}),a="object"==typeof t&&t.definitions?Object.entries(t.definitions).reduce((e,[t,r])=>({...e,[t]:mG(r._def,{...n,currentPath:[...n.basePath,n.definitionPath,t]},!0)??mx(n)}),{}):void 0,o="string"==typeof t?t:t?.nameStrategy==="title"?void 0:t?.name,s=mG(e._def,void 0===o?n:{...n,currentPath:[...n.basePath,n.definitionPath,o]},!1)??mx(n),l="object"==typeof t&&void 0!==t.name&&"title"===t.nameStrategy?t.name:void 0;void 0!==l&&(s.title=l),n.flags.hasReferencedOpenAiAnyType&&(a||(a={}),a[n.openAiAnyTypeName]||(a[n.openAiAnyTypeName]={type:["string","number","integer","boolean","array","null"],items:{$ref:"relative"===n.$refStrategy?"1":[...n.basePath,n.definitionPath,n.openAiAnyTypeName].join("/")}}));let c=void 0===o?a?{...s,[n.definitionPath]:a}:s:{$ref:[..."relative"===n.$refStrategy?[]:n.basePath,n.definitionPath,o].join("/"),[n.definitionPath]:{...a,[o]:s}};return"jsonSchema7"===n.target?c.$schema="http://json-schema.org/draft-07/schema#":("jsonSchema2019-09"===n.target||"openAi"===n.target)&&(c.$schema="https://json-schema.org/draft/2019-09/schema#"),"openAi"===n.target&&("anyOf"in c||"oneOf"in c||"allOf"in c||"type"in c&&Array.isArray(c.type))&&console.warn("Warning: OpenAI may not support schemas with unions as roots! Try wrapping it in an object property."),c})(e,{$refStrategy:"none",target:"openapi-3.0"===t?"openApi3":"jsonSchema7"});return delete r.$schema,r}if("zod"===i.vendor&&"_zod"in e)try{let t=nn(e);return delete t.$schema,t}catch(e){throw Error(`Failed to convert a zod schema to JSON Schema (zod v4 without "~standard.jsonSchema"). Upgrade to zod >= 4.2.0. Original error: ${e instanceof Error?e.message:String(e)}`)}throw Error(`Schema library "${i.vendor}" cannot be converted to JSON Schema. Use zod v3 (>= 3.25.76), zod >= 4.2.0, or a Standard Schema library implementing "~standard.jsonSchema".`)}(o,t,e),!function(e,t){if("function"!=typeof e.safeParse)return!1;try{let r=e.safeParse(void 0);return r.success&&("input"===t||void 0===r.data)}catch{return!1}}(o,e)&&a.push(r);let o={type:"object",properties:n};return a.length>0&&(o.required=a),r&&(o.additionalProperties=!1),o};return{shape:e,"~standard":{version:1,vendor:"xmcp",validate:async t=>{if("object"!=typeof t||null===t||Array.isArray(t))return{issues:[{message:"Expected an object."}]};let n={},a=[];for(let[e,r]of i){let i=await r["~standard"].validate(t[e]);if(i.issues)for(let t of i.issues)a.push({message:t.message,path:[e,...t.path??[]]});else(e in t||void 0!==i.value)&&(n[e]=i.value)}if(r)for(let r of Object.keys(t))r in e||a.push({message:`Unrecognized key: "${r}"`,path:[r]});return a.length>0?{issues:a}:{value:n}},jsonSchema:{input:n("input"),output:n("output")}}}}function mQ(e){let t={};return!function e(r,i=""){if(r&&"object"==typeof r)for(let[n,a]of Object.entries(r)){let r=i?`${i}/${n}`:n;!a||"object"!=typeof a||Array.isArray(a)||a instanceof Date||a instanceof RegExp?t[r]=a:e(a,r)}}(e),t}let m0=["ui/resourceUri","resourceUri","visibility"],m1=["prefersBorder","domain","csp","permissions","connectDomains","resourceDomains","frameDomains","baseUriDomains"];function m2(e){return"object"==typeof e&&null!==e&&Object.entries(e).every(([e,t])=>"string"==typeof e&&"object"==typeof t&&null!==t&&"parse"in t&&"function"==typeof t.parse)}function m9(e){return(e.split("/").pop()||e).replace(/\.[^/.]+$/,"")}function m4(e,t,r){return e.names?.includes(t)===!0||e.tags?.some(e=>r.includes(e))===!0}function m3(e,t){return t?new Map([...e].filter(([e,{metadata:r}])=>{if(r?.enabled===!1)return!1;let i=r?.name??m9(e),n=r?.tags??[];return(!t.include||m4(t.include,i,n))&&(!t.exclude||!m4(t.exclude,i,n))})):e}function m6(e){return Error(`[xmcp] Invalid prompt file: ${e}
|
|
78
|
+
-> Default export must be a prompt handler function.`)}let m5=function(e=console){let t="";return r=>{let i=r.map(({path:e,message:t})=>`${e}:${t}`).sort().join("|");if(i===t||(t=i,0===r.length))return;r.forEach(({path:t,message:r})=>{e.warn(`[xmcp] Failed to load prompt file: ${t}
|
|
79
|
+
-> ${r}`)});let n=r.length;e.warn(`[xmcp] ${n} prompt${1===n?"":"s"} skipped due to empty files or missing default exports`)}}();function m7(e){return Error(`[xmcp] Invalid resource file: ${e}
|
|
80
|
+
-> Default export must be a resource handler function.`)}let m8=function(e=console){let t="";return r=>{let i=r.map(({path:e,message:t})=>`${e}:${t}`).sort().join("|");if(i===t||(t=i,0===r.length))return;r.forEach(({path:t,message:r})=>{e.warn(`[xmcp] Failed to load resource file: ${t}
|
|
81
|
+
-> ${r}`)});let n=r.length;e.warn(`[xmcp] ${n} resource${1===n?"":"s"} skipped due to empty files or missing default exports`)}}();function he(e){let t=e.replace(/\\/g,"/");if(!t)throw Error("Invalid tool path: path is empty");let r=t.replace(/\.[^/.]+$/,"").replace(/\//g,"_");return{normalizedPath:t,baseName:r}}function ht(e){let t=e.split("/").filter(e=>""!==e),r=t.findIndex(e=>e.match(/^\(.+\)$/));if(-1===r)return null;let i=t[t.length-1];if(i&&i.match(/^\[.+\]\.ts$/))return null;let n=t[r].slice(1,-1),a=t.slice(r+1),o=a[a.length-1];if(o&&o.includes(".")){let e=o.split(".")[0];"index"!==e?a[a.length-1]=e:a.pop()}let s=[],l=[],c=a.map(e=>{if(!e.match(/^\[.+\]$/))return l.push(e),e;{let t=e.slice(1,-1);return s.push(t),`{${t}}`}}),u=`${n}://${c.join("/")}`,d=s.length>0?"template":"direct";return{filePath:e,uriTemplate:u,scheme:n,parameters:s,pathSegments:l,type:d}}let hr={ttlMs:0,cacheScope:"private"},hi=mR({cursor:mw().optional()}).passthrough().optional(),hn=mR({uri:mw()}).passthrough();function ha({uri:e,frontmatter:t,files:r}){return{uri:e,frontmatter:t,resources:r.map(({uri:e,digest:t,size:r})=>({uri:e,digest:t,size:r}))}}function ho(e){return Error(`[xmcp] Invalid tool file: ${e}
|
|
82
|
+
-> Default export must be a tool handler function.`)}let hs=function(e=console){let t="";return r=>{let i=r.map(({path:e,message:t})=>`${e}:${t}`).sort().join("|");if(i===t||(t=i,0===r.length))return;r.forEach(({path:t,message:r})=>{e.warn(`[xmcp] Failed to load tool file: ${t}
|
|
83
|
+
-> ${r}`)});let n=r.length;e.warn(`[xmcp] ${n} tool${1===n?"":"s"} skipped due to empty files or missing default exports`)}}(),hl=INJECTED_TOOLS,hc=INJECTED_PROMPTS,hu=INJECTED_RESOURCES,hd="u"<typeof INJECTED_SKILLS?[]:INJECTED_SKILLS??[],hp=SERVER_INFO,hm=function(e,t={}){var r;let{legacy:i,onerror:n,responseMode:a}=t,o=dO(t.maxRequestBodySize);if("function"==typeof i)throw TypeError("The 'legacy' option only accepts 'stateless' or 'reject', not a handler function. To serve 2025-era traffic with your own handler, route in user land with the exported isLegacyRequest(request) predicate in front of a strict (legacy: 'reject') handler.");let l=new Set,p=!1,m=e=>{try{n?.(e)}catch{}},h=t.bus??new d$(m),f={toolsChanged:()=>h.publish({kind:"tools_list_changed"}),promptsChanged:()=>h.publish({kind:"prompts_list_changed"}),resourcesChanged:()=>h.publish({kind:"resources_list_changed"}),resourceUpdated:e=>h.publish({kind:"resource_updated",uri:e})},g=function(e){let{bus:t,onerror:r}=e,i=e.maxSubscriptions??1024,n=e.keepAliveMs??15e3,a=new Set;return{serve:function(e,o,s,l){let c,u,d,p,m,h,f;if(a.size>=i)return r?.(Error(`subscriptions/listen refused: subscription limit reached (${i})`)),dT(e.id,-32603,"Subscription limit reached");let g=(m=cL(cM).validateRequest("subscriptions/listen",e)).ok?m.value.params?.notifications:void 0;if(void 0===g)return dT(e.id,-32602,"Invalid params: 'notifications' is required and must be a valid SubscriptionFilter");let y=(h={},f=e=>void 0===s||!0===e,!0===g.toolsListChanged&&f(s?.tools?.listChanged)&&(h.toolsListChanged=!0),!0===g.promptsListChanged&&f(s?.prompts?.listChanged)&&(h.promptsListChanged=!0),!0===g.resourcesListChanged&&f(s?.resources?.listChanged)&&(h.resourcesListChanged=!0),void 0!==g.resourceSubscriptions&&g.resourceSubscriptions.length>0&&f(s?.resources?.subscribe)&&(h.resourceSubscriptions=[...g.resourceSubscriptions]),h),v=e.id,_=new TextEncoder,b=!1,S=e=>{if(!b)try{c.enqueue(_.encode(e))}catch(e){r?.(e instanceof Error?e:Error(String(e)))}},w=(e,t)=>{S(`event: message
|
|
84
|
+
data: ${JSON.stringify({jsonrpc:"2.0",method:e,params:t})}
|
|
85
|
+
|
|
86
|
+
`)},R=e=>{if(!b){e&&S(`event: message
|
|
87
|
+
data: ${JSON.stringify({jsonrpc:"2.0",id:v,result:{resultType:"complete",_meta:{[aX]:v,[aK]:l}}})}
|
|
88
|
+
|
|
89
|
+
`),b=!0;try{u?.()}catch(e){r?.(e instanceof Error?e:Error(String(e)))}void 0!==d&&clearInterval(d),p?.(),a.delete(R);try{c.close()}catch{}}},k=new ReadableStream({start(e){c=e;let r=dC({method:"notifications/subscriptions/acknowledged",params:{notifications:y}},v);(w(r.method,r.params),0===Object.keys(y).length)?R(!0):(u=t.subscribe(e=>{if(b||!function(e,t){switch(t.kind){case"tools_list_changed":return!0===e.toolsListChanged;case"prompts_list_changed":return!0===e.promptsListChanged;case"resources_list_changed":return!0===e.resourcesListChanged;case"resource_updated":return void 0!==e.resourceSubscriptions&&e.resourceSubscriptions.includes(t.uri)}}(y,e))return;let t=dC(function(e){switch(e.kind){case"tools_list_changed":return{method:"notifications/tools/list_changed",...void 0!==e.params&&{params:e.params}};case"prompts_list_changed":return{method:"notifications/prompts/list_changed",...void 0!==e.params&&{params:e.params}};case"resources_list_changed":return{method:"notifications/resources/list_changed",...void 0!==e.params&&{params:e.params}};case"resource_updated":return{method:"notifications/resources/updated",params:{...e.params,uri:e.uri}}}}(e),v);w(t.method,t.params)}),d=di(n,()=>S(": keepalive\n\n")),a.add(R))},cancel(){R(!1)}});if(void 0!==o)if(o.aborted)R(!1);else{let e=()=>R(!1);o.addEventListener("abort",e,{once:!0}),p=()=>o.removeEventListener("abort",e)}return new Response(k,{status:200,headers:{"Content-Type":"text/event-stream","Cache-Control":"no-cache, no-transform",Connection:"keep-alive","X-Accel-Buffering":"no"}})},closeAll(){for(let e of a)e(!0)},get openCount(){return a.size}}}({bus:h,maxSubscriptions:t.maxSubscriptions??1024,keepAliveMs:t.keepAliveMs??15e3,onerror:m});"json"===a&&console.warn("responseMode: 'json' drops mid-call notifications. subscriptions/listen streams are always served over SSE regardless; other notifications emitted before a result are dropped.");let y="reject"===i?void 0:(r=t.keepAliveMs,async(t,i)=>{if("POST"!==t.method.toUpperCase())return dj(405,-32e3,"Method not allowed.");try{let n=await e({era:"legacy",...i?.authInfo!==void 0&&{authInfo:i.authInfo},requestInfo:t}),a=new dI({sessionIdGenerator:void 0,...void 0!==r&&{keepAliveMs:r},...void 0!==o&&{maxRequestBodySize:o}});await n.connect(a);let s=()=>{a.close().catch(()=>{}),n.close().catch(()=>{})};t.signal?.addEventListener("abort",s,{once:!0});let l=await a.handleRequest(t,{...i?.authInfo!==void 0&&{authInfo:i.authInfo},...i?.parsedBody!==void 0&&{parsedBody:i.parsedBody}});if(null===l.body||"text/event-stream"!==uL(l.headers.get("content-type")))return s(),l;let c=l.body.getReader(),u=!1,d=()=>{u||(u=!0,s())},p=new ReadableStream({pull:async e=>{try{let{done:t,value:r}=await c.read();if(t){d(),e.close();return}void 0!==r&&e.enqueue(r)}catch(t){d(),e.error(t)}},cancel:e=>(d(),c.cancel(e).catch(()=>{}))});return new Response(p,{status:l.status,statusText:l.statusText,headers:l.headers})}catch(e){try{m?.(dA(e))}catch{}return dN(dq(i?.parsedBody))}});return{fetch:async(r,i)=>{if(p)throw Error("This MCP handler has been closed");try{return await async function(r,i){let n=i?.authInfo;if("POST"===r.method.toUpperCase()&&!uZ(r.headers.get("content-type")))return m(Error("Unsupported Media Type: Content-Type must be application/json")),dj(415,-32e3,"Unsupported Media Type: Content-Type must be application/json");let p=await async function(e,t,r=!0,i=4194304){let n,a=e.method.toUpperCase(),o=t,s=e,l=!1;if("POST"===a){if(void 0===o){let t;r&&(s=e.clone());try{let r=await dE(e,i);if(r.tooLarge)return{step:"body-too-large"};t=r.text}catch{return{step:"unreadable-body"}}try{n=0===t.length?void 0:JSON.parse(t)}catch{l=!0}l||void 0===n||(o=n)}else n=o;if(l||void 0===n)return{step:"no-json-body",forwardRequest:s}}return{step:"classified",outcome:function(e){if("POST"!==(e={...e,...void 0!==e.protocolVersionHeader&&{protocolVersionHeader:ul(e.protocolVersionHeader)},...void 0!==e.mcpMethodHeader&&{mcpMethodHeader:ul(e.mcpMethodHeader)},...void 0!==e.mcpNameHeader&&{mcpNameHeader:ul(e.mcpNameHeader)}}).httpMethod.toUpperCase())return{kind:"legacy",reason:"http-method"};let t=e.body;if(Array.isArray(t)){if(0===t.length)return ua("jsonrpc-shape","empty-batch",400,new cv(cy.InvalidRequest,"Bad Request: empty JSON-RPC batch"),!0);for(let e of t){if(cB(uc(e)?e.params:void 0))return ua("jsonrpc-shape","batch-with-modern-element",400,new cv(cy.InvalidRequest,"Bad Request: JSON-RPC batches may not contain requests for protocol revision 2026-07-28 or later"),!0);if(!(cY(e)||cX(e)||cQ(e)||c0(e)))return ua("jsonrpc-shape","batch-with-invalid-element",400,new cv(cy.InvalidRequest,"Bad Request: JSON-RPC batch contains an invalid message"),!0)}return{kind:"legacy",reason:"batch"}}return cQ(t)||c0(t)?{kind:"legacy",reason:"response"}:uc(t)&&cY(t)?function(e,t){let r=t.params,i=t.method,n=e.protocolVersionHeader,a=void 0!==n&&n>=lX;if("initialize"===i&&!function(e){if(!cB(e))return!1;let t=cW(e);if(void 0===t||!(t>=lX))return!1;let r=cV(e);return void 0!==r&&0===cG(r).length}(r)){if(a)return uo("initialize-with-modern-header",n,"an initialize request (legacy handshake) was sent with a modern MCP-Protocol-Version header");let e=uc(r)&&"string"==typeof r.protocolVersion?r.protocolVersion:void 0;return{kind:"legacy",reason:"initialize",...void 0!==e&&{requestedVersion:e}}}if(cB(r)){let a=cV(r),o=(void 0===a?[]:cG(a))[0];if(void 0!==o)return ua("envelope","envelope-invalid",400,new cv(cy.InvalidParams,`Invalid _meta envelope for protocol revision 2026-07-28: ${o.key}: ${o.problem}`,{envelope:o}),!0);let s=cW(r);return void 0!==n&&void 0!==s&&n!==s?uo("header-body-version-mismatch",n,`the body envelope names protocol version ${s} but the MCP-Protocol-Version header names ${n}`):void 0!==e.mcpMethodHeader&&e.mcpMethodHeader!==i?uo("method-header-mismatch",e.mcpMethodHeader,`the body names method ${i} but the Mcp-Method header names ${e.mcpMethodHeader}`):{kind:"modern",messageKind:"request",message:t,classification:uu(s)}}if(a){let e=cV(r),t=cG(e??{}).filter(e=>"missing"===e.problem).map(e=>e.key),i=void 0===e?["_meta"]:t.length>0?t:[aW];return ua("envelope","modern-header-without-claim",400,new cv(cy.InvalidParams,`Invalid params: the MCP-Protocol-Version header names protocol revision ${n}, but the request is missing the required per-request envelope key(s): ${i.join(", ")}`,{envelope:{missing:i}}),!0)}return{kind:"legacy",reason:"no-claim",...void 0!==n&&{requestedVersion:n}}}(e,t):uc(t)&&cX(t)?function(e,t){let r=t.params,i=t.method,n=e.protocolVersionHeader,a=void 0!==n&&n>=lX;if(cB(r)){let a=cW(r);if(void 0===a){let e=cV(r),t=(void 0===e?[]:cG(e)).find(e=>e.key===aW)??{key:aW,problem:"expected a protocol version string"};return ua("envelope","notification-envelope-invalid",400,new cv(cy.InvalidParams,`Invalid _meta envelope for protocol revision 2026-07-28: ${t.key}: ${t.problem}`,{envelope:t}),!0)}if(void 0!==n&&n!==a)return uo("notification-header-body-version-mismatch",n,`the notification envelope names protocol version ${a} but the MCP-Protocol-Version header names ${n}`);let o=uu(a);return"modern"===o.era&&void 0!==e.mcpMethodHeader&&e.mcpMethodHeader!==i?uo("notification-method-header-mismatch",e.mcpMethodHeader,`the notification body names method ${i} but the Mcp-Method header names ${e.mcpMethodHeader}`):{kind:"modern",messageKind:"notification",message:t,classification:o}}return a?void 0!==e.mcpMethodHeader&&e.mcpMethodHeader!==i?uo("notification-method-header-mismatch",e.mcpMethodHeader,`the notification body names method ${i} but the Mcp-Method header names ${e.mcpMethodHeader}`):{kind:"modern",messageKind:"notification",message:t,classification:{era:"modern",revision:n}}:{kind:"legacy",reason:"notification",...void 0!==n&&{requestedVersion:n}}}(e,t):ua("jsonrpc-shape","invalid-json-rpc-body",400,new cv(cy.InvalidRequest,"Bad Request: the request body is not a valid JSON-RPC message"),!0)}({httpMethod:a,...dL(e),...void 0!==n&&{body:n}}),body:n,parsedBody:o,forwardRequest:s}}(r,i?.parsedBody,!0,o);if("unreadable-body"===p.step)return dj(400,-32700,"Parse error: the request body could not be read");if("body-too-large"===p.step)return dj(413,-32e3,dP(o));if("no-json-body"===p.step)return void 0!==y?y(p.forwardRequest,{...void 0!==n&&{authInfo:n}}):dj(400,-32700,"Parse error: the request body is not valid JSON");let{outcome:h,body:f,parsedBody:v,forwardRequest:_}=p;try{switch(h.kind){case"reject":return m(Error(`Rejected inbound request (${h.cell}): ${h.message}`)),dz(h,dq(f));case"modern":return await async function(r,i,n){var o,p;let h=r.classification.revision;if(void 0===h||!lQ.includes(h)){let e=new cS({supported:[...lQ],requested:h??"unknown"});return m(e),dj(400,e.code,e.message,e.data,dq(r.message))}let f=function(e,t){if("request"!==t.messageKind)return;let r=t.message.method;if(void 0===e.protocolVersionHeader){let e=t.classification.revision;return uo("version-header-missing","(missing)",void 0===e?"the body carries a modern per-request envelope but the required MCP-Protocol-Version header is absent":`the body envelope names protocol version ${e} but the required MCP-Protocol-Version header is absent`,"standard-header-validation")}if(void 0===e.mcpMethodHeader)return uo("method-header-missing","(missing)",`the body names method ${r} but the required Mcp-Method header is absent`,"standard-header-validation");let i=function(e,t){let r=Object.hasOwn(us,e)?us[e]:void 0;if(void 0===r)return;let i=uc(t)?t[r]:void 0;return{field:r,value:"string"==typeof i?i:void 0}}(r,t.message.params);if(void 0===i)return;let{field:n,value:a}=i;if(void 0===e.mcpNameHeader){if(void 0===a)return;return uo("name-header-missing","(missing)",`the body carries params.${n}="${a}" but the required Mcp-Name header is absent`,"standard-header-validation")}let o=ul(e.mcpNameHeader),s=ut(o);return void 0===s?uo("name-header-invalid-encoding",o,"the Mcp-Name header carries an invalid Base64 sentinel value","standard-header-validation"):void 0!==a&&s!==a?uo("name-header-mismatch",o,`the body carries params.${n}="${a}" but the Mcp-Name header names "${s}"`,"standard-header-validation"):void 0}({httpMethod:i.method,...dL(i)},r);if(void 0!==f)return m(Error(`Rejected inbound request (${f.cell}): ${f.message}`)),dz(f,dq(r.message));let y="request"===r.messageKind?cV(r.message.params):void 0,v=y?.[aY];if("request"===r.messageKind){let e=Object.hasOwn(lG,o=r.message.method)?lG[o]:void 0;if(void 0!==e){let t=lY(e,v);if(void 0!==t){let e=new cw({requiredCapabilities:t});return m(e),dj(un[e.code]??400,e.code,e.message,e.data,r.message.id)}}}let _=await e({era:"modern",...void 0!==n&&{authInfo:n},requestInfo:i}),b=_ instanceof dg?_.server:_;if(dM(b),"request"===r.messageKind&&"subscriptions/listen"===r.message.method){let e=b.getCapabilities(),t=d(b);return _.close().catch(m),g.serve(r.message,i.signal,e,t)}if("request"===r.messageKind&&"tools/call"===r.message.method&&_ instanceof dg){let e=r.message.params,t="string"==typeof e?.name?e.name:void 0,n=void 0===t?void 0:_.toolInputSchemaJson(t);if(void 0!==n){let t=c3(n);if(void 0!==t.declarations&&t.declarations.length>0){let n=function(e,t,r){for(let i of e){let e=`Mcp-Param-${i.headerName}`,n=r.get(e),a=function(e,t){let r=e;for(let e of t){if(null===r||"object"!=typeof r)return;r=r[e]}return r}(t,i.path);if(null==a)continue;let o=function(e){if("string"==typeof e)return e;if("boolean"==typeof e)return e?"true":"false";if("number"==typeof e){if(!Number.isFinite(e)||Number.isInteger(e)&&!Number.isSafeInteger(e))return;return String(e)}}(a);if(void 0===o)continue;if(null===n)return ur("param-header-missing",e,`the body carries ${c7(i.path)}=${JSON.stringify(a)} but the ${e} header is absent`);let s=ut(n);if(void 0===s)return ur("param-header-invalid-encoding",e,`the ${e} header carries an invalid Base64 sentinel value`);if(!(("integer"===i.type||"number"===i.type)&&ue.test(s)&&"number"==typeof a?Number(s)===a:s===o))return ur("param-header-mismatch",e,`the ${e} header decodes to ${JSON.stringify(s)} but the body carries ${c7(i.path)}=${JSON.stringify(a)}`)}}(t.declarations,e?.arguments,i.headers);if(void 0!==n)return _.close().catch(m),m(Error(`Rejected inbound request (${n.cell}): ${n.message}`)),dz(n,r.message.id)}}}if("request"===r.messageKind&&_ instanceof dg)try{let e=await dl([r.message],n,e=>_.resolveScopeChallenge(e));if(void 0!==e)return _.close().catch(m),du(e,dc(n))}catch(e){return _.close().catch(m),m(dA(e)),dN(r.message.id)}dM(b),s(b,h),u(b,lQ),void 0!==y&&(p={clientInfo:y[aG],clientCapabilities:v},c(b,p));let S=b.onclose;l.add(b);let w=()=>{l.delete(b),b.onclose===w&&(b.onclose=S),S?.()};b.onclose=w;try{let e=await async function(e,t,r){let i=new dn({classification:r.classification,...void 0!==r.responseMode&&{responseMode:r.responseMode},...void 0!==r.keepAliveMs&&{keepAliveMs:r.keepAliveMs}});return await e.connect(i),i.handleMessage(t,{...void 0!==r.request&&{request:r.request},...void 0!==r.authInfo&&{authInfo:r.authInfo}})}(_,r.message,{classification:r.classification,request:i,...void 0!==n&&{authInfo:n},...void 0!==a&&{responseMode:a},...void 0!==t.keepAliveMs&&{keepAliveMs:t.keepAliveMs}});return"notification"===r.messageKind&&queueMicrotask(()=>void b.close().catch(()=>{})),e}catch(e){if(e instanceof lW&&e.code===lB.ConnectionClosed)return new Response(null,{status:499});return await b.close().catch(()=>{}),l.delete(b),m(dA(e)),dN(dq(r.message))}}(h,r,n);case"legacy":return await async function(e,t,r,i){if(void 0!==y)return y(t,{...void 0!==r&&{authInfo:r},...void 0!==i&&{parsedBody:i}});let n=function(e,t){switch(e.reason){case"http-method":return ua("http-method","modern-only-method-not-allowed",405,new cv(-32e3,"Method not allowed."),!0);case"batch":return ua("jsonrpc-shape","modern-only-batch-not-supported",400,new cv(cy.InvalidRequest,"Bad Request: JSON-RPC batches are not supported by this endpoint"),!0);case"response":return ua("jsonrpc-shape","modern-only-response-post",400,new cv(cy.InvalidRequest,"Bad Request: JSON-RPC responses cannot be posted to this endpoint"),!0);case"notification":return;case"initialize":case"no-claim":{let r=e.requestedVersion;return ua("era-classification","modern-only-missing-envelope",400,void 0===r?new cv(cy.UnsupportedProtocolVersion,"Unsupported protocol version: the request did not name a protocol version",{supported:[...t]}):new cS({supported:[...t],requested:r}),!0)}}}(e,lQ);return void 0===n?new Response(null,{status:202}):(m(Error(`Rejected 2025-era request on a modern-only endpoint (${n.cell}): ${n.message}`)),dz(n,dq(i)))}(h,_,n,v)}}catch(e){return m(dA(e)),dN(dq(f))}}(r,i)}catch(e){return m(dA(e)),dN(dq(i?.parsedBody))}},notify:f,bus:h,close:async()=>{p=!0,g.closeAll();let e=[...l].map(e=>e.close().catch(()=>{}));l.clear(),await Promise.all(e)}}}(async function(){let{instructions:e,...t}=hp,r=new dg(t,{instructions:e}),i=async function(){let{toolModules:e,skippedTools:t}=await async function(e){let t=new Map,r=[];for(let i of(await Promise.all(Object.entries(e).map(async([e,t])=>{let r=await t(),i=function(e,t){if("object"!=typeof e||null===e)throw ho(t);let r=Object.keys(e),i=e.default,n=r.filter(e=>"__esModule"!==e);if(0===r.length||1===n.length&&"default"===n[0]&&"object"==typeof i&&null!==i&&0===Object.keys(i).length)return"empty";if(!("default"in e)||void 0===e.default)return"missing-default";if("function"!=typeof e.default)throw ho(t);return"valid"}(r,e);return"empty"===i?{skipped:!0,issue:{path:e,message:"File is empty."}}:"missing-default"===i?{skipped:!0,issue:{path:e,message:"File does not export a default tool handler."}}:{skipped:!1,path:e,toolModule:r}})))){if(i.skipped){r.push(i.issue);continue}t.set(i.path,i.toolModule)}return{toolModules:t,skippedTools:r}}(hl);return hs(t),e}(),n=async function(){let{promptModules:e,skippedPrompts:t}=await async function(e){let t=new Map,r=[];for(let i of(await Promise.all(Object.entries(e).map(async([e,t])=>{let r=await t(),i=function(e,t){if("object"!=typeof e||null===e)throw m6(t);let r=Object.keys(e),i=e.default,n=r.filter(e=>"__esModule"!==e);if(0===r.length||1===n.length&&"default"===n[0]&&"object"==typeof i&&null!==i&&0===Object.keys(i).length)return"empty";if(!("default"in e)||void 0===e.default)return"missing-default";if("function"!=typeof e.default)throw m6(t);return"valid"}(r,e);return"empty"===i?{skipped:!0,issue:{path:e,message:"File is empty."}}:"missing-default"===i?{skipped:!0,issue:{path:e,message:"File does not export a default prompt handler."}}:{skipped:!1,path:e,promptModule:r}})))){if(i.skipped){r.push(i.issue);continue}t.set(i.path,i.promptModule)}return{promptModules:t,skippedPrompts:r}}(hc);return m5(t),e}(),a=async function(){let{resourceModules:e,skippedResources:t}=await async function(e){let t=new Map,r=[];for(let i of(await Promise.all(Object.entries(e).map(async([e,t])=>{let r=await t(),i=function(e,t){if("object"!=typeof e||null===e)throw m7(t);let r=Object.keys(e),i=e.default,n=r.filter(e=>"__esModule"!==e);if(0===r.length||1===n.length&&"default"===n[0]&&"object"==typeof i&&null!==i&&0===Object.keys(i).length)return"empty";if(!("default"in e)||void 0===e.default)return"missing-default";if("function"!=typeof e.default)throw m7(t);return"valid"}(r,e);return"empty"===i?{skipped:!0,issue:{path:e,message:"File is empty."}}:"missing-default"===i?{skipped:!0,issue:{path:e,message:"File does not export a default resource handler."}}:{skipped:!1,path:e,resourceModule:r}})))){if(i.skipped){r.push(i.issue);continue}t.set(i.path,i.resourceModule)}return{resourceModules:t,skippedResources:r}}(hu);return m8(t),e}(),[o,s,l]=await Promise.all([i,n,a]);return async function(e,t,r,i){let n=await INJECTED_MIDDLEWARE?.(),a=function(e){if(void 0===e)return[];let t=Array.isArray(e)?[...e]:[e];if(!t.every(e=>"function"==typeof e))throw Error("src/middleware.ts must export mcp as a function or an array of functions");return t}(n?.mcp),o="u">typeof OBSERVABILITY_CONFIG&&OBSERVABILITY_CONFIG.enabled?function(e=e=>console.error(e)){let t=new Map,r=[];function i(t){try{e(JSON.stringify({"@timestamp":new Date().toISOString(),...t}))}catch{}}return{middleware:async(e,n)=>{let a,o,s;if("tools/call"!==e.method&&"prompts/get"!==e.method&&"resources/read"!==e.method)return n();try{o=performance.now(),a={log:{level:"info"},...function(e){let t=e.http?.headers.traceparent;if("string"!=typeof t)return{};let r=/^([0-9a-f]{2})-([0-9a-f]{32})-([0-9a-f]{16})-([0-9a-f]{2})(-.*)?$/.exec(t);return!r||"ff"===r[1]||/^0+$/.test(r[2])||/^0+$/.test(r[3])||"00"===r[1]&&void 0!==r[5]?{}:{trace:{id:r[2]},parent:{id:r[3]}}}(e),transaction:{id:crypto.randomUUID()},...e.http?{http:{request:{id:e.http.id}}}:{},xmcp:{method:e.method,component:"resources/read"===e.method?function(e){try{let i=new URL(e).href;return t.get(i)??r.find(({template:e})=>e.uriTemplate.match(i))?.name??"unknown"}catch{return"unknown"}}(e.params.uri):e.params.name}}}catch{return n()}i({...a,event:{kind:"event",category:["api"],type:["start"],action:"execution.start"}});let l="unknown";try{let t=await n();try{l=e.signal.aborted?"cancelled":c1(t)?"input_required":"isError"in t&&!0===t.isError?"failure":"success","failure"===l&&(s={message:"Operation returned an error result"})}catch{}return t}catch(t){throw s={message:"cancelled"==(l=e.signal.aborted?"cancelled":"failure")?"Operation cancelled":"Operation threw an exception"},t}finally{try{i({...a,log:{level:"failure"===l?"error":"info"},event:{kind:"event",category:["api"],type:["end"],action:"execution.end",duration:Math.round((performance.now()-o)*1e6),outcome:"success"===l?"success":"failure"===l?"failure":"unknown"},xmcp:{...a.xmcp,status:l},...s?{error:s}:{}})}catch{}}},registerResource(e,i){try{"string"==typeof i?t.set(new URL(i).href,e):r.push({name:e,template:i})}catch{}}}}():void 0;o&&a.unshift(o.middleware),dY.clear();let s="u"<typeof COMPONENTS_CONFIG?void 0:COMPONENTS_CONFIG;return!function(e,t,r){let i=e.server,n=i.setRequestHandler,a=pf(t);i.setRequestHandler=(e,...t)=>{if(pg.has(e)&&1===t.length&&"function"==typeof t[0]){let e=t[0];t[0]=(t,r)=>a({method:t.method,params:t.params??{}},r,()=>e(t,r))}Reflect.apply(n,i,[e,...t])};try{r()}finally{i.setRequestHandler=n}}(e,a,()=>{var n,l;!function(e,t,r=[]){t.forEach((t,i)=>{var n,a;let o,s,l,c,u={name:m9(i),description:"No description provided"},{default:d,metadata:p,schema:m,outputSchema:h}=t;if("object"==typeof p&&null!==p&&Object.assign(u,p),!1===u.enabled)return;if("function"==typeof d&&"__x402"in d){let e=F.g.__XMCP_X402_REGISTRY;e&&e.set(u.name,d.__x402)}let f={};if(m2(m)?f=m:null!=m&&console.warn(`Invalid schema for tool "${u.name}" at ${i}. Expected Record<string, z.ZodType>`),null!=h)if(m2(h))o=h;else throw Error(`Invalid outputSchema for tool "${u.name}" at ${i}. Expected Record<string, z.ZodType>`);u.annotations={...u.annotations??{}},void 0===u.annotations.title&&(u.annotations.title=u.name),u._meta={...dK(u)._meta};let g=py(i),y=!!(n=u._meta)&&"object"==typeof n&&"ui"in n&&"object"==typeof n.ui||g,v=u._meta;if(y){let e=`ui://app/${u.name}.html`;u._meta.ui||(u._meta.ui={}),u._meta.ui.resourceUri||(u._meta.ui.resourceUri=e);let t=function(e){let t={},r={};if(e.ui&&"object"==typeof e.ui){let i=e.ui,n={},a={};for(let[e,t]of Object.entries(i))m0.includes(e)?n[e]=t:m1.includes(e)?a[e]=t:n[e]=t;Object.keys(n).length>0&&(t.ui=n),Object.keys(a).length>0&&(r.ui=a)}for(let[r,i]of Object.entries(e))"ui"!==r&&(t[r]=i);return{toolMeta:t,resourceMeta:r}}(v);v=t.toolMeta;let r=t.resourceMeta;r.ui=r.ui||{},r.ui.csp=r.ui.csp||{},r.ui.csp.resourceDomains=r.ui.csp.resourceDomains||[],r.ui.csp.resourceDomains.includes("https://esm.sh")||r.ui.csp.resourceDomains.push("https://esm.sh"),dY.add(u.name,{name:u.name,uri:e,handler:d,mimeType:"text/html;profile=mcp-app",_meta:r,toolPath:g?i:void 0})}let _=mQ(v),b=y?_:void 0;s=py(i)&&y?async(e,t)=>({content:[{type:"text",text:""}],_meta:b,structuredContent:{args:e}}):function(e,t,r,i="unknown-tool"){return async(n,a)=>{let o,s,l=e(n,(o=ph(a),s=function(e){if(!e)return;let t={};return e.headers.forEach((e,r)=>{t[r]=e}),t}(a.http?.req),{signal:a.mcpReq.signal,authInfo:a.http?.authInfo,sessionId:a.sessionId,_meta:a.mcpReq._meta,requestId:a.mcpReq.id,requestInfo:s?{headers:s}:void 0,clientInfo:o,sendNotification:e=>a.mcpReq.notify(e),sendRequest:(e,t,r)=>a.mcpReq.send(e,t,r),elicit:(e,t)=>(async function(e,t,r){let i=function(e){let t=e.mode??"form";if("url"===t)return function(e){let t;pe(e,"Elicitation request must be a plain object."),d8(e,d2,"URL elicitation"),pt(e.message,"URL elicitation requires a string message."),pr(e.elicitationId,"URL elicitation requires a non-empty elicitationId."),pr(e.url,"URL elicitation requires a non-empty URL.");try{t=new URL(e.url)}catch{throw Error("URL elicitation requires a valid http or https URL.")}if("http:"!==t.protocol&&"https:"!==t.protocol)throw Error("URL elicitation requires a valid http or https URL.")}(e),e;if("form"!==t)throw Error(`Unsupported elicitation mode "${String(e.mode)}". Expected "form" or "url".`);return function(e){pe(e,"Elicitation request must be a plain object."),d8(e,d1,"Form elicitation"),pt(e.message,"Form elicitation requires a string message.");let t=e.requestedSchema;if(pe(t,"Form elicitation requires a flat object schema."),d8(t,d9,"Form elicitation schema"),"object"!==t.type)throw Error('Form elicitation schema must use type "object".');for(let[e,r]of(pe(t.properties,"Form elicitation schema requires a properties object."),Object.entries(t.properties)))!function(e,t){if(pe(t,`Form elicitation field "${e}" must be a plain object.`),pi(t.title,`Form elicitation field "${e}" title must be a string.`),pi(t.description,`Form elicitation field "${e}" description must be a string.`),"string"===t.type&&"enum"in t){var r,i;if(d8(t,d3,`Form elicitation field "${e}"`),pa(t.enum,`Form elicitation field "${e}" enum values must be strings.`),r=t.enumNames,i=`Form elicitation field "${e}" enumNames must be strings.`,void 0!==r&&pa(r,i),void 0!==t.enumNames&&t.enumNames.length!==t.enum.length)throw Error(`Form elicitation field "${e}" enumNames length must match enum length.`);if(pi(t.default,`Form elicitation field "${e}" default must be a string.`),void 0!==t.default&&!t.enum.includes(t.default))throw Error(`Form elicitation field "${e}" default must be one of its enum values.`);return}if("string"===t.type&&!("enum"in t)){d8(t,d4,`Form elicitation field "${e}"`),pn(t.minLength,`Form elicitation field "${e}" minLength must be a number.`),pn(t.maxLength,`Form elicitation field "${e}" maxLength must be a number.`),pi(t.default,`Form elicitation field "${e}" default must be a string.`);let r=t.format;if(pi(r,`Form elicitation field "${e}" format must be a string.`),void 0!==r&&!d7.has(r))throw Error(`Form elicitation field "${e}" format must be one of: ${Array.from(d7).join(", ")}.`);return}if("boolean"===t.type){if(d8(t,d6,`Form elicitation field "${e}"`),void 0!==t.default&&"boolean"!=typeof t.default)throw Error(`Form elicitation field "${e}" default must be a boolean.`);return}if("number"===t.type||"integer"===t.type){d8(t,d5,`Form elicitation field "${e}"`),pn(t.minimum,`Form elicitation field "${e}" minimum must be a number.`),pn(t.maximum,`Form elicitation field "${e}" maximum must be a number.`),pn(t.default,`Form elicitation field "${e}" default must be a number.`);return}throw Error(`Form elicitation field "${e}" uses unsupported type "${String(t.type)}". Supported types are string, boolean, number, integer, and string enums.`)}(e,r);if(void 0!==t.required){if(!Array.isArray(t.required)||t.required.some(e=>"string"!=typeof e))throw Error("Form elicitation schema required fields must be a string array.");for(let e of t.required)if(!(e in t.properties))throw Error(`Form elicitation schema required field "${e}" is not defined in properties.`)}}(e),{...e,mode:"form"}}(t);try{let t=await e.mcpReq.elicitInput(i,r);return{...t,content:t.content??void 0}}catch(e){if(e instanceof lW&&e.code===lB.MethodNotSupportedByProtocolVersion)throw Error("extra.elicit() is not available on protocol revision 2026-07-28: server-initiated elicitation was replaced by multi round-trip requests. Return inputRequired({ ... }) from the tool handler instead (re-exported from xmcp); the client fulfils the embedded requests and retries the tool call.");throw e}})(a,e,t),sample:(e,t)=>(async function(e,t,r){let i=function(e){pc(e,"Sampling request must be a plain object.");let t=Object.keys(e),r=t.filter(e=>ps.has(e));if(r.length>0)throw Error(`Sampling request key(s) not supported by xmcp yet: ${r.join(", ")}.`);let i=t.filter(e=>!po.has(e));if(i.length>0)throw Error(`Sampling request includes unsupported key(s): ${i.join(", ")}.`);if(!Array.isArray(e.messages)||0===e.messages.length)throw Error("Sampling requires at least one message.");for(let[t,r]of e.messages.entries())!function(e,t){if(pc(t,`Sampling message at index ${e} must be a plain object.`),"user"!==t.role&&"assistant"!==t.role)throw Error(`Sampling message at index ${e} requires role "user" or "assistant".`);let r=t.content;pc(r,`Sampling message at index ${e} requires a content object.`);let i=r.type;if("string"!=typeof i||!pl.has(i))throw Error(`Sampling message at index ${e} uses unsupported content type "${String(i)}". Supported types are text, image, and audio.`);if("text"===i&&"string"!=typeof r.text)throw Error(`Sampling message at index ${e} requires string text content.`);if(("image"===i||"audio"===i)&&("string"!=typeof r.data||"string"!=typeof r.mimeType))throw Error(`Sampling message at index ${e} requires base64 data and a mimeType.`)}(t,r);if("number"!=typeof e.maxTokens)throw Error("Sampling requires a numeric maxTokens.");return e}(t);try{return await e.mcpReq.requestSampling(i,r)}catch(e){if(e instanceof lW&&e.code===lB.MethodNotSupportedByProtocolVersion)throw Error("extra.sample() is not available on protocol revision 2026-07-28: server-initiated sampling was replaced by multi round-trip requests. Return inputRequired({ ... }) with inputRequired.createMessage(...) from the tool handler instead (re-exported from xmcp); the client fulfils the embedded requests and retries the tool call.");throw e}})(a,e,t),inputResponses:a.mcpReq.inputResponses,requestState:a.mcpReq.requestState}));if(l instanceof Promise&&(l=await l),c1(l))return l;if("string"==typeof l||"number"==typeof l){if(r){let e=Object.entries(r);if(1===e.length){let[t,r]=e[0];try{return r.parse(l),{content:[{type:"text",text:"number"==typeof l?`${l}`:l}],structuredContent:{[t]:l}}}catch{}}}return pm(t)?{content:[{type:"text",text:""}],structuredContent:{args:n},_meta:t}:{content:[{type:"text",text:"number"==typeof l?`${l}`:l}]}}if(!r||!l||"object"!=typeof l||Array.isArray(l)||"structuredContent"in l||"content"in l&&Array.isArray(l.content)||"_meta"in l||"isError"in l||(pp(l,r,i,"returned data that does not match outputSchema"),l={structuredContent:l}),l&&"object"==typeof l&&"_meta"in l&&!("content"in l)&&!("structuredContent"in l)){let e=l._meta;if(pm(e))return{content:[{type:"text",text:""}],_meta:e}}if(!l||"object"!=typeof l){let e=null===l?"null":typeof l,t=void 0===l?"undefined":null===l?"null":"object"==typeof l?JSON.stringify(l,null,2):String(l);throw Error(`Tool handler must return a CallToolResult, string, or number. Got ${e}: ${t}
|
|
84
90
|
|
|
85
91
|
Expected CallToolResult format:
|
|
86
92
|
{
|
|
@@ -109,7 +115,7 @@ Or for widget metadata only:
|
|
|
109
115
|
_meta: {
|
|
110
116
|
"ui/...": ...
|
|
111
117
|
}
|
|
112
|
-
}`)}let
|
|
118
|
+
}`)}let c="content"in l&&Array.isArray(l.content),u="structuredContent"in l,d="isError"in l&&!0===l.isError;if(!c&&!u&&!d){let e=JSON.stringify(l,null,2);throw Error(`Tool handler must return at least 'content' or 'structuredContent'. Got: ${e}
|
|
113
119
|
|
|
114
120
|
Expected CallToolResult format:
|
|
115
121
|
{
|
|
@@ -130,16 +136,16 @@ Or both for backwards compatibility:
|
|
|
130
136
|
{
|
|
131
137
|
content: [{ type: "text", text: "fallback" }],
|
|
132
138
|
structuredContent: { your: "data" }
|
|
133
|
-
}`)}if(
|
|
139
|
+
}`)}if(d&&!c&&!u){let{isError:e,...t}=l,r=Object.keys(t).length>0?`Tool execution failed: ${JSON.stringify(t)}`:"Tool execution failed";l.content=[{type:"text",text:r}],c=!0}if(r&&u&&!d&&pp(l.structuredContent,r,i,"returned structuredContent that does not match outputSchema"),!c&&u&&(l.content=[{type:"text",text:JSON.stringify(l.structuredContent)}],c=!0),c)for(let e=0;e<l.content.length;e++){let t=l.content[e],r=pd(t);if(!r.valid)throw Error(`Invalid content item at index ${e}: ${r.error}
|
|
134
140
|
|
|
135
|
-
Content item: ${JSON.stringify(
|
|
141
|
+
Content item: ${JSON.stringify(t,null,2)}
|
|
136
142
|
|
|
137
143
|
Expected content formats:
|
|
138
144
|
- Text: { type: "text", text: "your text here" }
|
|
139
145
|
- Image: { type: "image", data: "base64data", mimeType: "image/jpeg" }
|
|
140
146
|
- Audio: { type: "audio", data: "base64data", mimeType: "audio/mpeg" }
|
|
141
147
|
- Resource: { type: "resource_link", name: "name", uri: "uri" }
|
|
142
|
-
All content types support an optional "_meta" object property`)}if(
|
|
148
|
+
All content types support an optional "_meta" object property`)}if(u){let e=l.structuredContent;if(null===e||"object"!=typeof e||Array.isArray(e)){let t=Array.isArray(e)?"array":typeof e;throw Error(`'structuredContent' must be a plain object (not an array or primitive). Got ${t}: ${JSON.stringify(e,null,2)}
|
|
143
149
|
|
|
144
150
|
Expected format:
|
|
145
151
|
{
|
|
@@ -147,9 +153,9 @@ Expected format:
|
|
|
147
153
|
key: "value",
|
|
148
154
|
nested: { data: "here" }
|
|
149
155
|
}
|
|
150
|
-
}`)}}return
|
|
156
|
+
}`)}}return l}}(d,b,o,u.name);let S={title:u.annotations?.title,description:u.description,inputSchema:mX(f),outputSchema:o?mX(o,{strict:!0}):void 0,annotations:u.annotations,icons:u.icons,_meta:_};e.registerTool(u.name,S,(a={name:u.name,description:S.description,annotations:S.annotations,icons:S.icons,tags:u.tags,_meta:S._meta},l=pf(r),c=Object.freeze({metadata:function e(t,r=new WeakMap){if(null===t||"object"!=typeof t)return t;let i=Object.getPrototypeOf(t);if(!Array.isArray(t)&&i!==Object.prototype&&null!==i)return t;if(r.has(t))return r.get(t);let n=Array.isArray(t)?[]:Object.create(i);for(let[i,a]of(r.set(t,n),Object.entries(t)))Object.defineProperty(n,i,{value:e(a,r),enumerable:!0,configurable:!0,writable:!0});return Object.freeze(n)}(a)}),(e,t)=>l({method:"tools/call",params:{name:c.metadata.name,arguments:e},tool:c},t,()=>s(e,t))))})}(e,m3(t,s),a),m3(r,s).forEach((t,r)=>{let i=m9(r),n={name:i,title:i,description:"No description provided"},a={},{default:o,metadata:s,schema:l}=t;if("object"==typeof s&&null!==s&&Object.assign(n,s),!1===n.enabled)return;let c=function(e,t="assistant"){return async(r,i)=>{let n,a=e(r,i);if(a instanceof Promise&&(a=await a),Array.isArray(a)||null!==a&&"object"==typeof a&&"messages"in a){let e=Array.isArray(a)?{messages:a}:a,t=await uC.GetPromptResult["~standard"].validate(e);if(t.issues){let e=t.issues.map(e=>{let t=e.path?.map(e=>"object"==typeof e?e.key:e).join(".");return`${t||"result"}: ${e.message}`});throw Error(`Invalid prompt result: ${e.join("; ")}`)}return e}if("string"==typeof a||"number"==typeof a)n={type:"text",text:"number"==typeof a?`${a}`:a};else{let e=pd(a);if(e.valid)n=a;else{let t=null===a?"null":typeof a,r=void 0===a?"undefined":null===a?"null":"object"==typeof a?JSON.stringify(a,null,2):String(a);throw Error(`Prompt handler must return a PromptContent object, string, number, PromptMessage[], or GetPromptResult. Got ${t}: ${r}
|
|
151
157
|
|
|
152
|
-
Validation error: ${
|
|
158
|
+
Validation error: ${e.error}
|
|
153
159
|
|
|
154
160
|
Expected formats:
|
|
155
161
|
- String: "your text here"
|
|
@@ -160,11 +166,11 @@ Expected formats:
|
|
|
160
166
|
- Image content: { type: "image", data: "base64data", mimeType: "image/jpeg" }
|
|
161
167
|
- Audio content: { type: "audio", data: "base64data", mimeType: "audio/mpeg" }
|
|
162
168
|
- Resource link: { type: "resource_link", name: "resource name", uri: "resource://uri" }
|
|
163
|
-
- All content types support an optional "_meta" object property`)}}if("user"!==
|
|
169
|
+
- All content types support an optional "_meta" object property`)}}if("user"!==t&&"assistant"!==t)throw Error(`Invalid role: ${t}`);return{messages:[{role:t,content:n}]}}}(o,n.role||"assistant");m2(l)?Object.assign(a,l):null!=l&&console.warn(`Invalid schema for prompt "${n.name}" at ${r}. Expected Record<string, z.ZodType>`),e.registerPrompt(n.name,{title:n.title,description:n.description,icons:n.icons,_meta:dK(n)._meta,argsSchema:mX(a)},c)}),n=m3(i,s),l=o?.registerResource,[...dY.getAll()].forEach(([t,r])=>{let i=r.mimeType||"text/html;profile=mcp-app",n=r?._meta?mQ(r._meta):void 0,a={name:r.name,description:`Auto-generated resource for ${r.name} tool`,mimeType:r.mimeType,_meta:n};l?.(r.name,r.uri),e.registerResource(r.name,r.uri,a,async(e,t)=>{if(r.mimeType&&r.toolPath)try{var n;let e,t,a=(n=r.toolPath,IS_CLOUDFLARE?function(e){let{normalizedPath:t,baseName:r}=he(e),i=5381;for(let e=0;e<t.length;e++)i=Math.imul(i,33)+t.charCodeAt(e)>>>0;let n=i.toString(16).slice(0,6).padStart(6,"0");return`${r}_${n}`}(n):function(e){let{normalizedPath:t,baseName:r}=he(e),i=F(Object(function(){var e=Error("Cannot find module 'crypto'");throw e.code="MODULE_NOT_FOUND",e}())).createHash("md5").update(t).digest("hex").slice(0,6);return`${r}_${i}`}(n)),o=function(e){if(INJECTED_CLIENT_BUNDLES)return INJECTED_CLIENT_BUNDLES[e]||null;if(!IS_CLOUDFLARE)try{let t=F(Object(function(){var e=Error("Cannot find module 'fs'");throw e.code="MODULE_NOT_FOUND",e}())),r=F(Object(function(){var e=Error("Cannot find module 'path'");throw e.code="MODULE_NOT_FOUND",e}()));for(let i of[r.join(process.cwd(),"dist","client"),r.join(process.cwd(),"client")]){let n=r.join(i,`${e}.bundle.js`),a=r.join(i,`${e}.bundle.css`);if(t.existsSync(n)){let e,r=t.readFileSync(n,"utf-8");return t.existsSync(a)&&(e=t.readFileSync(a,"utf-8")),{js:r,css:e}}}}catch{}return null}(a);if(!o)throw Error(`React client bundle not found for "${r.name}" (bundle: "${a}").
|
|
164
170
|
React tool bundles are generated automatically when you run "xmcp build" (or "xmcp dev").
|
|
165
|
-
Please re-run the build so the framework can regenerate the bundle.`);let
|
|
171
|
+
Please re-run the build so the framework can regenerate the bundle.`);let s=o.js,l=o.css,c=(e=`
|
|
166
172
|
<script type="module">
|
|
167
|
-
const componentSource = ${JSON.stringify(
|
|
173
|
+
const componentSource = ${JSON.stringify(s)};
|
|
168
174
|
const blobUrl = URL.createObjectURL(
|
|
169
175
|
new Blob([componentSource], { type: "text/javascript" })
|
|
170
176
|
);
|
|
@@ -204,18 +210,18 @@ Please re-run the build so the framework can regenerate the bundle.`);let l=s.js
|
|
|
204
210
|
requestAnimationFrame(() => {
|
|
205
211
|
URL.revokeObjectURL(blobUrl);
|
|
206
212
|
});
|
|
207
|
-
|
|
213
|
+
<\/script>`,t=l?`<style>${l}</style>`:"",`<!DOCTYPE html>
|
|
208
214
|
<html>
|
|
209
215
|
<head>
|
|
210
216
|
<meta charset="utf-8">
|
|
211
217
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
212
|
-
${
|
|
218
|
+
${t}
|
|
213
219
|
</head>
|
|
214
220
|
<body>
|
|
215
221
|
<div id="root"></div>
|
|
216
|
-
${
|
|
222
|
+
${e}
|
|
217
223
|
</body>
|
|
218
|
-
</html>`);return{contents:[{uri:
|
|
224
|
+
</html>`);return{contents:[{uri:r.uri,text:c,mimeType:i,_meta:r._meta}]}}catch(e){throw console.error(`React failed for ${r.name}:`,e),e}let a=r.handler({},t);if(a instanceof Promise&&(a=await a),"string"==typeof a)return{contents:[{uri:r.uri,text:a,mimeType:i,_meta:r._meta}]};if(a&&"object"==typeof a&&"_meta"in a&&!("content"in a))return{contents:[{uri:r.uri,text:"",mimeType:i,_meta:r._meta}]};if(a&&"object"==typeof a&&"content"in a&&Array.isArray(a.content)){let e=a.content.find(e=>"text"===e.type);if(e&&"text"===e.type&&"string"==typeof e.text)return{contents:[{uri:r.uri,text:e.text,mimeType:i,_meta:r._meta}]}}return{contents:[{uri:r.uri,text:"",mimeType:i,_meta:r._meta}]}})}),n.forEach((t,r)=>{let i={name:m9(r),description:"No description provided"},{default:n,metadata:a,schema:o,complete:s}=t;if("object"==typeof a&&null!==a&&Object.assign(i,a),!1===i.enabled)return;let c={};m2(o)?c=o:null!=o&&console.warn(`Invalid schema for resource "${i.name}" at ${r}. Expected Record<string, z.ZodType>`);let u=ht(r);if(!u)return void console.warn(`Skipping resource "${i.name}" at ${r}: Invalid file path format`);let d=u.uriTemplate;i.mimeType&&i.mimeType.includes("html")&&(d=d.endsWith(".html")?d:`${d}.html`);let p=function(e,t,r={}){let i=ht(t);if(!i)throw Error(`Invalid resource file path: ${t}. Must follow (scheme)/path/[param] convention.`);return async(t,n)=>{let a=e(function(e,t,r){let i={},n={};if(0===t.parameters.length)return n;let a=t.uriTemplate.split("://")[1]||"",o=e.split("://")[1]||"",s=a.split("/"),l=o.split("/");for(let e=0;e<s.length&&e<l.length;e++){let t=s[e],r=l[e],n=t.match(/^\{(.+)\}$/);n&&(i[n[1]]=r)}for(let e of t.parameters){let t=i[e],a=r[e];if(void 0===t)throw Error(`Missing required parameter: ${e}`);if(!a){n[e]=t;continue}try{n[e]=a.parse(t)}catch(r){throw Error(`Invalid parameter "${e}": ${t}. Validation error: ${r instanceof Error?r.message:String(r)}`)}}return n}(t.href,i,r),n);if(a instanceof Promise&&(a=await a),c1(a))return a;if("string"==typeof a)return{contents:[{uri:t.href,text:a}]};if(!a||"object"!=typeof a||!Array.isArray(a.contents)){let e=null===a?"null":typeof a,t=void 0===a?"undefined":null===a?"null":"object"==typeof a?JSON.stringify(a,null,2):String(a);throw Error(`Resource handler must return a ReadResourceResult, InputRequiredResult, or string. Got ${e}: ${t}
|
|
219
225
|
|
|
220
226
|
Expected ReadResourceResult format:
|
|
221
227
|
{
|
|
@@ -224,10 +230,4 @@ Expected ReadResourceResult format:
|
|
|
224
230
|
{ uri: "resource://uri", mimeType: "application/json", text: "json content" },
|
|
225
231
|
{ uri: "resource://uri", blob: base64data }
|
|
226
232
|
]
|
|
227
|
-
}`)}return
|
|
228
|
-
data: ${JSON.stringify({jsonrpc:"2.0",method:t,params:r})}
|
|
229
|
-
|
|
230
|
-
`)},T=t=>{if(!k){t&&x(`event: message
|
|
231
|
-
data: ${JSON.stringify({jsonrpc:"2.0",id:w,result:{resultType:"complete",_meta:{[aQ]:w,[aY]:c}}})}
|
|
232
|
-
|
|
233
|
-
`),k=!0;try{h?.()}catch(t){i?.(t instanceof Error?t:Error(String(t)))}void 0!==f&&clearInterval(f),g?.(),o.delete(T);try{m.close()}catch{}}},C=new ReadableStream({start(t){m=t;let i=dl({method:"notifications/subscriptions/acknowledged",params:{notifications:S}},w);($(i.method,i.params),0===Object.keys(S).length)?T(!0):(h=r.subscribe(t=>{if(k||!function(t,r){switch(r.kind){case"tools_list_changed":return!0===t.toolsListChanged;case"prompts_list_changed":return!0===t.promptsListChanged;case"resources_list_changed":return!0===t.resourcesListChanged;case"resource_updated":return void 0!==t.resourceSubscriptions&&t.resourceSubscriptions.includes(r.uri)}}(S,t))return;let r=dl(function(t){switch(t.kind){case"tools_list_changed":return{method:"notifications/tools/list_changed"};case"prompts_list_changed":return{method:"notifications/prompts/list_changed"};case"resources_list_changed":return{method:"notifications/resources/list_changed"};case"resource_updated":return{method:"notifications/resources/updated",params:{uri:t.uri}}}}(t),w);$(r.method,r.params)}),f=dn(a,()=>x(": keepalive\n\n")),o.add(T))},cancel(){T(!1)}});if(void 0!==s)if(s.aborted)T(!1);else{let t=()=>T(!1);s.addEventListener("abort",t,{once:!0}),g=()=>s.removeEventListener("abort",t)}return new Response(C,{status:200,headers:{"Content-Type":"text/event-stream","Cache-Control":"no-cache, no-transform",Connection:"keep-alive","X-Accel-Buffering":"no"}})},closeAll(){for(let t of o)t(!0)},get openCount(){return o.size}}}({bus:f,maxSubscriptions:r.maxSubscriptions??1024,keepAliveMs:r.keepAliveMs??15e3,onerror:h});"json"===o&&console.warn("responseMode: 'json' drops mid-call notifications. subscriptions/listen streams are always served over SSE regardless; other notifications emitted before a result are dropped.");let v="reject"===n?void 0:(i=r.keepAliveMs,async(r,n)=>{if("POST"!==r.method.toUpperCase())return dz(405,-32e3,"Method not allowed.");try{let a=await t({era:"legacy",...n?.authInfo!==void 0&&{authInfo:n.authInfo},requestInfo:r}),o=new dj({sessionIdGenerator:void 0,...void 0!==i&&{keepAliveMs:i},...void 0!==s&&{maxRequestBodySize:s}});await a.connect(o);let l=()=>{o.close().catch(()=>{}),a.close().catch(()=>{})};r.signal?.addEventListener("abort",l,{once:!0});let c=await o.handleRequest(r,{...n?.authInfo!==void 0&&{authInfo:n.authInfo},...n?.parsedBody!==void 0&&{parsedBody:n.parsedBody}});if(null===c.body||"text/event-stream"!==uL(c.headers.get("content-type")))return l(),c;let u=c.body.getReader(),d=!1,p=()=>{d||(d=!0,l())},m=new ReadableStream({pull:async t=>{try{let{done:r,value:i}=await u.read();if(r){p(),t.close();return}void 0!==i&&t.enqueue(i)}catch(r){p(),t.error(r)}},cancel:t=>(p(),u.cancel(t).catch(()=>{}))});return new Response(m,{status:c.status,statusText:c.statusText,headers:c.headers})}catch(t){try{h?.(dM(t))}catch{}return dL(dA(n?.parsedBody))}});async function _(i,n,a){var s,m;let f=i.classification.revision;if(void 0===f||!l0.includes(f)){let t=new cw({supported:[...l0],requested:f??"unknown"});return h(t),dz(400,t.code,t.message,t.data,dA(i.message))}let g=function(t,r){if("request"!==r.messageKind)return;let i=r.message.method;if(void 0===t.protocolVersionHeader){let t=r.classification.revision;return us("version-header-missing","(missing)",void 0===t?"the body carries a modern per-request envelope but the required MCP-Protocol-Version header is absent":`the body envelope names protocol version ${t} but the required MCP-Protocol-Version header is absent`,"standard-header-validation")}if(void 0===t.mcpMethodHeader)return us("method-header-missing","(missing)",`the body names method ${i} but the required Mcp-Method header is absent`,"standard-header-validation");let n=function(t,r){let i=Object.hasOwn(ul,t)?ul[t]:void 0;if(void 0===i)return;let n=uu(r)?r[i]:void 0;return{field:i,value:"string"==typeof n?n:void 0}}(i,r.message.params);if(void 0===n)return;let{field:a,value:o}=n;if(void 0===t.mcpNameHeader){if(void 0===o)return;return us("name-header-missing","(missing)",`the body carries params.${a}="${o}" but the required Mcp-Name header is absent`,"standard-header-validation")}let s=uc(t.mcpNameHeader),l=ur(s);return void 0===l?us("name-header-invalid-encoding",s,"the Mcp-Name header carries an invalid Base64 sentinel value","standard-header-validation"):void 0!==o&&l!==o?us("name-header-mismatch",s,`the body carries params.${a}="${o}" but the Mcp-Name header names "${l}"`,"standard-header-validation"):void 0}({httpMethod:n.method,...dU(n)},i);if(void 0!==g)return h(Error(`Rejected inbound request (${g.cell}): ${g.message}`)),dN(g,dA(i.message));let v="request"===i.messageKind?cB(i.message.params):void 0,_=v?.[aX];if("request"===i.messageKind){let t=Object.hasOwn(lK,s=i.message.method)?lK[s]:void 0;if(void 0!==t){let r=lX(t,_);if(void 0!==r){let t=new cR({requiredCapabilities:r});return h(t),dz(ua[t.code]??400,t.code,t.message,t.data,i.message.id)}}}let b=await t({era:"modern",...void 0!==a&&{authInfo:a},requestInfo:n}),S=b instanceof d_?b.server:b;if(dZ(S),"request"===i.messageKind&&"subscriptions/listen"===i.message.method){let t=S.getCapabilities(),r=d(S);return b.close().catch(h),y.serve(i.message,n.signal,t,r)}if("request"===i.messageKind&&"tools/call"===i.message.method&&b instanceof d_){let t=i.message.params,r="string"==typeof t?.name?t.name:void 0,a=void 0===r?void 0:b.toolInputSchemaJson(r);if(void 0!==a){let r=c6(a);if(r.valid&&r.declarations.length>0){let a=function(t,r,i){for(let n of t){let t=`Mcp-Param-${n.headerName}`,a=i.get(t),o=function(t,r){let i=t;for(let t of r){if(null===i||"object"!=typeof i)return;i=i[t]}return i}(r,n.path);if(null==o)continue;let s=function(t){if("string"==typeof t)return t;if("boolean"==typeof t)return t?"true":"false";if("number"==typeof t){if(!Number.isFinite(t)||Number.isInteger(t)&&!Number.isSafeInteger(t))return;return String(t)}}(o);if(void 0===s)continue;if(null===a)return ui("param-header-missing",t,`the body carries ${c8(n.path)}=${JSON.stringify(o)} but the ${t} header is absent`);let l=ur(a);if(void 0===l)return ui("param-header-invalid-encoding",t,`the ${t} header carries an invalid Base64 sentinel value`);if(!(("integer"===n.type||"number"===n.type)&&ut.test(l)&&"number"==typeof o?Number(l)===o:l===s))return ui("param-header-mismatch",t,`the ${t} header decodes to ${JSON.stringify(l)} but the body carries ${c8(n.path)}=${JSON.stringify(o)}`)}}(r.declarations,t?.arguments,n.headers);if(void 0!==a)return b.close().catch(h),h(Error(`Rejected inbound request (${a.cell}): ${a.message}`)),dN(a,i.message.id)}}}if("request"===i.messageKind&&b instanceof d_)try{let t=await dd([i.message],a,t=>b.resolveScopeChallenge(t));if(void 0!==t)return b.close().catch(h),dm(t,dp(a))}catch(t){return b.close().catch(h),h(dM(t)),dL(i.message.id)}dZ(S),l(S,f),u(S,l0),void 0!==v&&(m={clientInfo:v[aK],clientCapabilities:_},c(S,m));let w=S.onclose;p.add(S);let R=()=>{p.delete(S),S.onclose===R&&(S.onclose=w),w?.()};S.onclose=R;try{let t=await dP(b,i.message,{classification:i.classification,request:n,...void 0!==a&&{authInfo:a},...void 0!==o&&{responseMode:o},...void 0!==r.keepAliveMs&&{keepAliveMs:r.keepAliveMs}});return"notification"===i.messageKind&&queueMicrotask(()=>void S.close().catch(()=>{})),t}catch(t){if(t instanceof lG&&t.code===lW.ConnectionClosed)return new Response(null,{status:499});return await S.close().catch(()=>{}),p.delete(S),h(dM(t)),dL(dA(i.message))}}async function b(t,r,i,n){if(void 0!==v)return v(r,{...void 0!==i&&{authInfo:i},...void 0!==n&&{parsedBody:n}});let a=function(t,r){switch(t.reason){case"http-method":return uo("http-method","modern-only-method-not-allowed",405,new c_(-32e3,"Method not allowed."),!0);case"batch":return uo("jsonrpc-shape","modern-only-batch-not-supported",400,new c_(cv.InvalidRequest,"Bad Request: JSON-RPC batches are not supported by this endpoint"),!0);case"response":return uo("jsonrpc-shape","modern-only-response-post",400,new c_(cv.InvalidRequest,"Bad Request: JSON-RPC responses cannot be posted to this endpoint"),!0);case"notification":return;case"initialize":case"no-claim":{let i=t.requestedVersion;return uo("era-classification","modern-only-missing-envelope",400,void 0===i?new c_(cv.UnsupportedProtocolVersion,"Unsupported protocol version: the request did not name a protocol version",{supported:[...r]}):new cw({supported:[...r],requested:i}),!0)}}}(t,l0);return void 0===a?new Response(null,{status:202}):(h(Error(`Rejected 2025-era request on a modern-only endpoint (${a.cell}): ${a.message}`)),dN(a,dA(n)))}async function S(t,r){let i=r?.authInfo;if("POST"===t.method.toUpperCase()&&!uZ(t.headers.get("content-type")))return h(Error("Unsupported Media Type: Content-Type must be application/json")),dz(415,-32e3,"Unsupported Media Type: Content-Type must be application/json");let n=await dF(t,r?.parsedBody,!0,s);if("unreadable-body"===n.step)return dz(400,-32700,"Parse error: the request body could not be read");if("body-too-large"===n.step)return dz(413,-32e3,dO(s));if("no-json-body"===n.step)return void 0!==v?v(n.forwardRequest,{...void 0!==i&&{authInfo:i}}):dz(400,-32700,"Parse error: the request body is not valid JSON");let{outcome:a,body:o,parsedBody:l,forwardRequest:c}=n;try{switch(a.kind){case"reject":return h(Error(`Rejected inbound request (${a.cell}): ${a.message}`)),dN(a,dA(o));case"modern":return await _(a,t,i);case"legacy":return await b(a,c,i,l)}}catch(t){return h(dM(t)),dL(dA(o))}}return{fetch:async(t,r)=>{if(m)throw Error("This MCP handler has been closed");try{return await S(t,r)}catch(t){return h(dM(t)),dL(dA(r?.parsedBody))}},notify:g,bus:f,close:async()=>{m=!0,y.closeAll();let t=[...p].map(t=>t.close().catch(()=>{}));p.clear(),await Promise.all(t)}}}(async function(){let{instructions:t,...r}=hx,i=new d_(r,{instructions:t}),n=hT(),a=hC(),o=hE(),[s,l,c]=await Promise.all([n,a,o]);return h$(i,s,l,c)},{legacy:"stateless",maxSubscriptions:HTTP_CONFIG.maxSubscriptions});async function hO(t,r={}){let i="POST"===t.method?await t.clone().json().catch(()=>void 0):void 0;return dW({id:crypto.randomUUID(),headers:Object.fromEntries(t.headers.entries()),clientInfo:(t=>{for(let r of Array.isArray(t)?t:[t]){let t=dY(r);if(t)return t}})(i)},()=>hP.fetch(t,{parsedBody:i,authInfo:r.authInfo}))}var hI=D.r;export{hI as xmcpHandler};
|
|
233
|
+
}`)}return a.contents.forEach(e=>{e.uri||(e.uri=t.href)}),a}}(n,r,c);if("direct"===u.type)l?.(i.name,d),e.registerResource(i.name,d,dK(i),p);else{let t=Object.create(null);for(let e of u.parameters)s&&Object.hasOwn(s,e)&&(t[e]=s[e]);let r=new dy(d,{list:void 0,complete:t});l?.(i.name,r),e.registerResource(i.name,r,dK(i),async(e,t,r)=>{let i={};for(let e of u.parameters){let r=t[e],n=c[e];if(void 0===r)throw Error(`Missing required parameter: ${e}. Available variables: ${Object.keys(t)}`);n?i[e]=n.parse(r):i[e]=r}let a=n(i,r);return a instanceof Promise&&(a=await a),"string"==typeof a?{contents:[{uri:e.href,text:a}]}:a})}}),function(e,t,r,i){let n=[...m3(new Map(t.map(e=>[e.uri,{metadata:{name:e.frontmatter.name},skill:e}])),r).values()].map(({skill:e})=>e);if(0===n.length)return;for(let{frontmatter:t,files:r}of n){let n=r[0].uri.slice(0,r[0].uri.lastIndexOf("/")+1);r.forEach(({uri:r,mimeType:a,text:o,blob:s},l)=>{let c=0===l?{mimeType:a,description:t.description}:{mimeType:a},u=0===l?t.name:`${t.name}/${decodeURIComponent(r.slice(n.length))}`,d=void 0!==o?{uri:r,mimeType:a,text:o}:{uri:r,mimeType:a,blob:s??""};i?.(u,r),e.registerResource(u,r,c,()=>({contents:[d]}))})}let a=n.map(ha),o=new Map(a.map(e=>[e.uri,e]));e.server.registerCapabilities({extensions:{"io.modelcontextprotocol/skills":{}}}),e.server.setRequestHandler("skills/list",{params:hi},e=>{let t=e?.cursor===void 0?0:function(e,t){let r=0/0;try{r=Number(atob(e))}catch{}if(!Number.isSafeInteger(r)||r<=0||r>=t)throw new cv(cy.InvalidParams,`Invalid cursor: ${e}`);return r}(e.cursor,a.length),r=t+50;return{skills:a.slice(t,r),...r<a.length?{nextCursor:btoa(String(r))}:{},...hr}}),e.server.setRequestHandler("skills/get",{params:hn},({uri:e})=>{let t=o.get(e);if(!t)throw new cv(cy.InvalidParams,`No skill is served at ${e}`);return{skill:t,...hr}})}(e,hd,s,o?.registerResource)}),e}(r,o,s,l)},{legacy:"stateless",maxSubscriptions:HTTP_CONFIG.maxSubscriptions});async function hh(e,t={}){let r="POST"===e.method?await e.clone().json().catch(()=>void 0):void 0;return dJ({id:crypto.randomUUID(),headers:Object.fromEntries(e.headers.entries()),clientInfo:(e=>{for(let t of Array.isArray(e)?e:[e]){let e=dW(t);if(e)return e}})(r)},()=>hm.fetch(e,{parsedBody:r,authInfo:t.authInfo}))}var hf=D.r;export{hf as xmcpHandler};
|