@clickmax/studio-bridge 0.0.0 → 12.5.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,51 +0,0 @@
1
- function e(e){let t=Object.values(e).filter(e=>typeof e==`number`);return Object.entries(e).filter(([e,n])=>t.indexOf(+e)===-1).map(([e,t])=>t)}function t(e,t=`|`){return e.map(e=>ne(e)).join(t)}function n(e,t){return typeof t==`bigint`?t.toString():t}function r(e){return{get value(){{let t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function i(e){return e==null}function a(e){let t=+!!e.startsWith(`^`),n=e.endsWith(`$`)?e.length-1:e.length;return e.slice(t,n)}function o(e,t){let n=e/t,r=Math.round(n),i=4*2**-52*Math.max(Math.abs(n),1);return Math.abs(n-r)<i?0:n-r}var s=Symbol(`evaluating`);function c(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==s)return r===void 0&&(r=s,r=n()),r},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function l(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function u(...e){let t={};for(let n of e){let e=Object.getOwnPropertyDescriptors(n);Object.assign(t,e)}return Object.defineProperties({},t)}function d(e){return JSON.stringify(e)}function f(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,``).replace(/[\s_-]+/g,`-`).replace(/^-+|-+$/g,``)}var p=`captureStackTrace`in Error?Error.captureStackTrace:(...e)=>{};function m(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var h=r(()=>{if(Ie.jitless||typeof navigator<`u`&&navigator?.userAgent?.includes(`Cloudflare`))return!1;try{return Function(``),!0}catch{return!1}});function g(e){if(m(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!=`function`)return!0;let n=t.prototype;return m(n)!==!1&&Object.prototype.hasOwnProperty.call(n,`isPrototypeOf`)!==!1}function ee(e){return g(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}var te=new Set([`string`,`number`,`symbol`]);function _(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function v(e,t,n){let r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function y(e){let t=e;if(!t)return{};if(typeof t==`string`)return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error==`string`?{...t,error:()=>t.error}:t}function ne(e){return typeof e==`bigint`?e.toString()+`n`:typeof e==`string`?`"${e}"`:`${e}`}function re(e){return Object.keys(e).filter(t=>e[t]._zod.optin!==void 0&&e[t]._zod.optout===`optional`)}var ie={safeint:[-(2**53-1),2**53-1],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function ae(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.pick() cannot be used on object schemas containing refinements`);return v(e,u(e._zod.def,{get shape(){let e={};for(let r of Reflect.ownKeys(t)){if(!Object.prototype.hasOwnProperty.call(n.shape,r))throw Error(`Unrecognized key: "${String(r)}"`);t[r]&&l(e,r,n.shape[r])}return l(this,`shape`,e),e},checks:[]}))}function oe(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.omit() cannot be used on object schemas containing refinements`);return v(e,u(e._zod.def,{get shape(){let r={...e._zod.def.shape};for(let e of Reflect.ownKeys(t)){if(!Object.prototype.hasOwnProperty.call(n.shape,e))throw Error(`Unrecognized key: "${String(e)}"`);t[e]&&delete r[e]}return l(this,`shape`,r),r},checks:[]}))}function se(e,t){if(!g(t))throw Error(`Invalid input to extend: expected a plain object`);let n=e._zod.def.checks;if(n&&n.length>0){let n=e._zod.def.shape;for(let e of Reflect.ownKeys(t))if(Object.getOwnPropertyDescriptor(n,e)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return v(e,u(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return l(this,`shape`,n),n}}))}function ce(e,t){if(!g(t))throw Error(`Invalid input to safeExtend: expected a plain object`);return v(e,u(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return l(this,`shape`,n),n}}))}function le(e,t){if(!t?._zod?.def)throw Error("Invalid input to merge: expected an object schema. To merge a plain shape, use `.extend()`.");if(e._zod.def.checks?.length)throw Error(`.merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.`);return v(e,u(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t._zod.def.shape};return l(this,`shape`,n),n},get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]}))}function ue(e,t,n,r=`partial`){let i=t._zod.def.checks;if(i&&i.length>0)throw Error(`.${r}() cannot be used on object schemas containing refinements`);return v(t,u(t._zod.def,{get shape(){let r=t._zod.def.shape,i={...r};if(n)for(let t of Reflect.ownKeys(n)){if(!Object.prototype.hasOwnProperty.call(r,t))throw Error(`Unrecognized key: "${String(t)}"`);n[t]&&(i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t])}else for(let t of Reflect.ownKeys(r))i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t];return l(this,`shape`,i),i},checks:[]}))}function de(e,t,n){return v(t,u(t._zod.def,{get shape(){let r=t._zod.def.shape,i={...r};if(n)for(let t of Reflect.ownKeys(n)){if(!Object.prototype.hasOwnProperty.call(i,t))throw Error(`Unrecognized key: "${String(t)}"`);n[t]&&(i[t]=new e({type:`nonoptional`,innerType:r[t]}))}else for(let t of Reflect.ownKeys(r))i[t]=new e({type:`nonoptional`,innerType:r[t]});return l(this,`shape`,i),i}}))}function fe(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function pe(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue===!1)return!0;return!1}function me(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function he(e){return typeof e==`string`?e:e?.message}function ge(e,t,n){var r;for(let i=t;i<e.length;i++)(r=e[i]).schema??(r.schema=n)}function b(e,t,n){var r;let i=e.inst?._zod?.traits;i?.has(`$ZodType`)&&(i.has(`$ZodCheck`)?(r=e).schema??(r.schema=e.inst):e.schema=e.inst);let a=e.schema===e.inst?void 0:e.schema?._zod.def?.error,o=e.message?e.message:he(e.inst?._zod.def?.error?.(e))??he(a?.(e))??he(t?.error?.(e))??he(n.customError?.(e))??he(n.localeError?.(e))??`Invalid input`,{inst:s,schema:c,continue:l,input:u,...d}=e;return d.path??=[],d.message=o,t?.reportInput&&(d.input=u),d}var _e=/[\uD800-\uDBFF]/;function ve(e){let t=e.length;if(!_e.test(e))return t;let n=t;for(let r=0;r<t-1;r++)(e.charCodeAt(r)&64512)==55296&&(e.charCodeAt(r+1)&64512)==56320&&(n--,r++);return n}function ye(e){return Array.isArray(e)?`array`:typeof e==`string`?`string`:`unknown`}function x(e){let t=typeof e;switch(t){case`number`:return Number.isNaN(e)?`nan`:`number`;case`object`:{if(e===null)return`null`;if(Array.isArray(e))return`array`;let t=e;if(t&&Object.getPrototypeOf(t)!==Object.prototype&&`constructor`in t&&t.constructor)return t.constructor.name}}return t}function S(...e){let[t,n,r]=e;return typeof t==`string`?{message:t,code:`custom`,input:n,inst:r}:{...t}}function be(e,t){for(let n in t){let r=Object.getOwnPropertyDescriptor(t,n);r.get?Object.defineProperty(e,n,{...r,enumerable:!1}):Ce(e,n,r.value)}}function xe(e,t,n,r=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:r,value:n}),n}function Se(e,t,n){return xe(e,t,n,!1)}function Ce(e,t,n){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?n:xe(this,t,n.bind(this))},set(e){xe(this,t,e)}})}function we(e,t){let n=Object.getPrototypeOf(e);return t in n?void 0:n}var Te,C=!1,Ee={configurable:!0,get(){C=!0}};function w(e,t,n){let r=Object.getPrototypeOf(e._zod);if(t in r&&Te!==e._zod){Te=void 0;return}Te=e._zod,Object.defineProperty(r,t,{configurable:!0,get(){Object.defineProperty(this,t,Ee);let e=C;C=!1;try{let r=n(this);return C?delete this[t]:Object.defineProperty(this,t,{configurable:!0,writable:!0,value:r}),C||=e,r}catch(n){throw delete this[t],C||=e,n}},set(e){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:e})}})}function De(e,t,n,r){let i=we(e,t);i&&Object.defineProperty(i,t,{configurable:!0,get(){let e={configurable:!0,writable:!0,enumerable:r,value:void 0};return Object.defineProperty(this,t,e),e.value=n(this),Object.defineProperty(this,t,e),e.value},set(e){Object.defineProperty(this,t,{configurable:!0,writable:!0,enumerable:r,value:e})}})}var Oe=`~constantCatch`;function ke(e){let t=()=>e;return t[Oe]=!0,t}var Ae,T=Object.freeze({status:`aborted`}),je={value:void 0,enumerable:!1},Me=`captureStackTrace`in Error?Error:null;function Ne(e){let t=Me;if(t){let n=t.stackTraceLimit;if(typeof n==`number`){try{t.stackTraceLimit=0}catch{return Me=null,new e}try{return new e}finally{t.stackTraceLimit=n}}}return new e}function E(e,t,n,r){let i={};function a(e){this.def=e,this.constr=d,this.traits=new Set}a.prototype=i;let o=n,s=o&&new WeakSet;function c(n,r){if(!n._zod){je.value=new a(r);try{Object.defineProperty(n,"_zod",je)}finally{je.value=void 0}}if(n._zod.traits.has(e))return;if(n._zod.traits.add(e),t(n,r),s){let e=Object.getPrototypeOf(n),t=n._zod.constr.prototype,r=e;for(;r&&r!==t;)r=Object.getPrototypeOf(r);let i=r??e;s.has(i)||(s.add(i),be(i,o))}let i=d.prototype;for(let e in i)Object.prototype.hasOwnProperty.call(i,e)&&(e in n||(n[e]=i[e].bind(n)))}let l=r?.Parent??Object;class u extends l{}Object.defineProperty(u,"name",{value:e});function d(e){let t=r?.Parent?Ne(u):this;c(t,e);let n=t._zod.deferred;if(n){for(let e of n)e();t._zod.deferred=void 0}let i=globalThis.__zod_globalConfig?.postProcessor;return i&&i(t),t}return Object.defineProperty(d,"init",{value:c}),Object.defineProperty(d,Symbol.hasInstance,{value:t=>r?.Parent&&t instanceof r.Parent?!0:t?._zod?.traits?.has(e)}),Object.defineProperty(d,"name",{value:e}),d}var Pe=class extends Error{constructor(){super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`)}},Fe=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name=`ZodEncodeError`}};(Ae=globalThis).__zod_globalConfig??(Ae.__zod_globalConfig={});var Ie=globalThis.__zod_globalConfig;function Le(e){return e&&Object.assign(Ie,e),Ie}function Re(){let e=this._zod;return e.message??=JSON.stringify(e.def,n,2),e.message}function ze(e){this._zod.message=e}var Be={get:Re,set:ze,enumerable:!0,configurable:!0},Ve={value:void 0,enumerable:!1},He={value:void 0,enumerable:!1},Ue=new WeakSet([Object.prototype,Error.prototype]),We=(e,t)=>{e.name=`$ZodError`,Ve.value=e._zod,Object.defineProperty(e,"_zod",Ve),He.value=t,Object.defineProperty(e,"issues",He),Ve.value=void 0,He.value=void 0,Object.defineProperty(e,"message",Be);let n=Object.getPrototypeOf(e);Ue.has(n)||(Ue.add(n),Object.defineProperty(n,"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})}}))},Ge=E(`$ZodError`,We),Ke=E(`$ZodError`,We,void 0,{Parent:Error});function qe(e,t,n){return Object.prototype.hasOwnProperty.call(e,t)||(t===`__proto__`?Object.defineProperty(e,t,{value:n(),writable:!0,enumerable:!0,configurable:!0}):e[t]=n()),e[t]}function Je(e,t=e=>e.message){let n={},r=[];for(let i of e.issues)i.path.length>0?qe(n,i.path[0],()=>[]).push(t(i)):r.push(t(i));return{formErrors:r,fieldErrors:n}}function Ye(e,t=e=>e.message){let n={_errors:[]},r=(e,i=[])=>{for(let a of e.issues)if(a.code===`invalid_union`&&a.errors.length)a.errors.map(e=>r({issues:e},[...i,...a.path]));else if(a.code===`invalid_key`)r({issues:a.issues},[...i,...a.path]);else if(a.code===`invalid_element`)r({issues:a.issues},[...i,...a.path]);else{let e=[...i,...a.path];if(e.length===0)n._errors.push(t(a));else{let r=n,i=0;for(;i<e.length;){let n=e[i],o=i===e.length-1;if(n===`_errors`){o&&r._errors.push(t(a)),i++;continue}Object.prototype.hasOwnProperty.call(r,n)||Object.defineProperty(r,n,{value:{_errors:[]},enumerable:!0,writable:!0,configurable:!0});let s=r[n];o&&s._errors.push(t(a)),r=s,i++}}}};return r(e),n}function Xe(e,t){return{callee:t?.callee??e,Err:t?.Err}}var Ze=e=>{let t=(n,r,i,a)=>{let o=i?{...i,async:!1}:{async:!1},s=n._zod.run({value:r,issues:[]},o);if(s instanceof Promise)throw new Pe;if(s.issues.length){let n=new((a?.Err)??e)(s.issues.map(e=>b(e,o,Le())));throw p(n,a?.callee??t),n}return s.value};return t},Qe=e=>{let t=async(n,r,i,a)=>{let o=i?{...i,async:!0}:{async:!0},s=n._zod.run({value:r,issues:[]},o);if(s instanceof Promise&&(s=await s),s.issues.length){let n=new((a?.Err)??e)(s.issues.map(e=>b(e,o,Le())));throw p(n,a?.callee??t),n}return s.value};return t},$e=e=>(t,n,r)=>{let i=r?{...r,async:!1}:{async:!1},a=t._zod.run({value:n,issues:[]},i);if(a instanceof Promise)throw new Pe;return a.issues.length?{success:!1,error:new(e??Ge)(a.issues.map(e=>b(e,i,Le())))}:{success:!0,data:a.value}},et=$e(Ke),D=e=>async(t,n,r)=>{let i=r?{...r,async:!0}:{async:!0},a=t._zod.run({value:n,issues:[]},i);return a instanceof Promise&&(a=await a),a.issues.length?{success:!1,error:new e(a.issues.map(e=>b(e,i,Le())))}:{success:!0,data:a.value}},tt=D(Ke),nt=e=>{let t=Ze(e),n=(e,r,i,a)=>{let o=i?{...i,direction:`backward`}:{direction:`backward`};return t(e,r,o,Xe(n,a))};return n},rt=e=>{let t=Ze(e),n=(e,r,i,a)=>t(e,r,i,Xe(n,a));return n},it=e=>{let t=Qe(e),n=async(e,r,i,a)=>{let o=i?{...i,direction:`backward`}:{direction:`backward`};return await t(e,r,o,Xe(n,a))};return n},at=e=>{let t=Qe(e),n=async(e,r,i,a)=>await t(e,r,i,Xe(n,a));return n},ot=e=>(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return $e(e)(t,n,i)},st=e=>(t,n,r)=>$e(e)(t,n,r),ct=e=>async(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return D(e)(t,n,i)},lt=e=>async(t,n,r)=>D(e)(t,n,r),ut=/^[cC][0-9a-z]{6,}$/,dt=/^[0-9a-z]+$/,ft=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,pt=/^[0-9a-vA-V]{20}$/,mt=/^[A-Za-z0-9]{27}$/,ht=/^[a-zA-Z0-9_-]{21}$/;function gt(e){return RegExp(`^[a-zA-Z0-9_-]{${e}}$`)}var _t=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,vt=/^([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})$/,yt=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)$/,bt=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,xt=`^[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$`;function St(){return new RegExp(xt,`u`)}var Ct=/^(?:(?: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])$/,wt=/^(([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}|:))$/,Tt=/^((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])$/,Et=/^(([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])$/,Dt=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Ot=/^[A-Za-z0-9_-]*$/,kt=/^https?$/,At=/^\+[1-9]\d{6,14}$/,jt=`(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))`;function Mt(e){return RegExp(`^${e}$`)}var Nt=Mt(jt);function Pt(e){let t=`(?:[01]\\d|2[0-3]):[0-5]\\d`;return typeof e.precision==`number`?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:e.seconds?`${t}:[0-5]\\d(?:\\.\\d+)?`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function Ft(e){return RegExp(`^${Pt(e)}$`)}function It(e){let t=[`Z`];e.offset&&t.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);let n=`${Pt({precision:e.precision,seconds:!0})}(?:${t.join(`|`)})`,r=e.local?`${n}|${Pt({precision:e.precision})}`:n;return RegExp(`^${jt}T(?:${r})$`)}var Lt=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??``}}`:`[\\s\\S]*`;return RegExp(`^${t}$`)},Rt=/^-?\d+$/,zt=/^-?\d+(?:\.\d+)?$/,Bt=/^(?:true|false)$/i,Vt=/^null$/i,Ht=/^[^A-Z]*$/,Ut=/^[^a-z]*$/,O=E(`$ZodCheck`,(e,t)=>{var n;e._zod??={},e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),Wt=e=>{let t=e.value;return!i(t)&&t.length!==void 0},Gt={number:`number`,bigint:`bigint`,object:`date`},Kt=E(`$ZodCheckLessThan`,(e,t)=>{O.init(e,t);let n=Gt[typeof t.value];e._zod.onattach.push(e=>{let n=e._zod.bag,r=(t.inclusive?n.maximum:n.exclusiveMaximum)??1/0;t.value<r&&(t.inclusive?n.maximum=t.value:n.exclusiveMaximum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:Gt[typeof r.value]??n,code:`too_big`,maximum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),qt=E(`$ZodCheckGreaterThan`,(e,t)=>{O.init(e,t);let n=Gt[typeof t.value];e._zod.onattach.push(e=>{let n=e._zod.bag,r=(t.inclusive?n.minimum:n.exclusiveMinimum)??-1/0;t.value>r&&(t.inclusive?n.minimum=t.value:n.exclusiveMinimum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:Gt[typeof r.value]??n,code:`too_small`,minimum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Jt=E(`$ZodCheckMultipleOf`,(e,t)=>{O.init(e,t),e._zod.onattach.push(e=>{var n;(n=e._zod.bag).multipleOf??(n.multipleOf=t.value)}),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw Error(`Cannot mix number and bigint in multiple_of check.`);(typeof n.value==`bigint`?t.value!==BigInt(0)&&n.value%t.value===BigInt(0):o(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:`not_multiple_of`,divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),Yt=E(`$ZodCheckNumberFormat`,(e,t)=>{O.init(e,t),t.format=t.format||`float64`;let n=t.format?.includes(`int`),r=n?`int`:`number`,[i,a]=ie[t.format];e._zod.onattach.push(e=>{let r=e._zod.bag;r.format=t.format,r.minimum=i,r.maximum=a,n&&(r.pattern=Rt)}),e._zod.check=o=>{let s=o.value;if(n){if(!Number.isInteger(s)){o.issues.push({expected:r,format:t.format,code:`invalid_type`,continue:!1,input:s,inst:e});return}if(!Number.isSafeInteger(s)){s>0?o.issues.push({input:s,code:`too_big`,maximum:2**53-1,note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort}):o.issues.push({input:s,code:`too_small`,minimum:-(2**53-1),note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort});return}}s<i&&o.issues.push({origin:`number`,input:s,code:`too_small`,minimum:i,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})}}),Xt=E(`$ZodCheckMaxLength`,(e,t)=>{var n;O.init(e,t),(n=e._zod.def).when??(n.when=Wt),e._zod.onattach.push(e=>{let n=e._zod.bag.maximum??1/0;t.maximum<n&&(e._zod.bag.maximum=t.maximum)}),e._zod.check=n=>{let r=n.value,i=r.length;if((typeof r==`string`&&i>t.maximum?ve(r):i)<=t.maximum)return;let a=ye(r);n.issues.push({origin:a,code:`too_big`,maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),Zt=E(`$ZodCheckMinLength`,(e,t)=>{var n;O.init(e,t),(n=e._zod.def).when??(n.when=Wt),e._zod.onattach.push(e=>{let n=e._zod.bag.minimum??-1/0;t.minimum>n&&(e._zod.bag.minimum=t.minimum)}),e._zod.check=n=>{let r=n.value,i=r.length;if((typeof r==`string`&&i>=t.minimum&&i<t.minimum*2?ve(r):i)>=t.minimum)return;let a=ye(r);n.issues.push({origin:a,code:`too_small`,minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),Qt=E(`$ZodCheckLengthEquals`,(e,t)=>{var n;O.init(e,t),(n=e._zod.def).when??(n.when=Wt),e._zod.onattach.push(e=>{let n=e._zod.bag;n.minimum=t.length,n.maximum=t.length,n.length=t.length}),e._zod.check=n=>{let r=n.value,i=r.length,a=typeof r==`string`&&i>=t.length&&i<=t.length*2?ve(r):i;if(a===t.length)return;let o=ye(r),s=a>t.length;n.issues.push({origin:o,...s?{code:`too_big`,maximum:t.length}:{code:`too_small`,minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),$t=E(`$ZodCheckStringFormat`,(e,t)=>{var n,r;O.init(e,t),e._zod.onattach.push(e=>{let n=e._zod.bag;n.format=t.format,t.pattern&&(n.patterns??=new Set,n.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),en=E(`$ZodCheckRegex`,(e,t)=>{$t.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:`regex`,input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),tn=E(`$ZodCheckLowerCase`,(e,t)=>{t.pattern??=Ht,$t.init(e,t)}),nn=E(`$ZodCheckUpperCase`,(e,t)=>{t.pattern??=Ut,$t.init(e,t)}),rn=E(`$ZodCheckIncludes`,(e,t)=>{O.init(e,t);let n=_(t.includes),r=new RegExp(typeof t.position==`number`?`^.{${t.position},}${n}`:n);t.pattern=r,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(r)}),e._zod.check=n=>{n.value.includes(t.includes,t.position)||n.issues.push({origin:`string`,code:`invalid_format`,format:`includes`,includes:t.includes,input:n.value,inst:e,continue:!t.abort})}}),an=E(`$ZodCheckStartsWith`,(e,t)=>{O.init(e,t);let n=RegExp(`^${_(t.prefix)}.*`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(n)}),e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`starts_with`,prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),on=E(`$ZodCheckEndsWith`,(e,t)=>{O.init(e,t);let n=RegExp(`.*${_(t.suffix)}$`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(n)}),e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`ends_with`,suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}}),sn=E(`$ZodCheckOverwrite`,(e,t)=>{O.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}}),cn=class{constructor(e=[],t={}){this.content=[],this.indent=0,this.args=e,this.closed=t}indented(e){this.indent+=1,e(this),--this.indent}write(e){if(typeof e==`function`){e(this,{execution:`sync`}),e(this,{execution:`async`});return}let t=e.split(`
2
- `).filter(e=>e),n=Math.min(...t.map(e=>e.length-e.trimStart().length)),r=t.map(e=>e.slice(n)).map(e=>` `.repeat(this.indent*2)+e);for(let e of r)this.content.push(e)}compile(){let e=Function,t=this?.content??[``];return new e(...Object.keys(this.closed),`return function (${this.args.join(`, `)}) {\n${t.join(`
3
- `)}\n};`)(...Object.values(this.closed))}},ln={major:4,minor:5,patch:4},k=E(`$ZodType`,(e,t)=>{var n;e??={},e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=ln;let r=e._zod.def.checks,i=e._zod.traits.has(`$ZodCheck`)?[e,...r??[]]:r?.length?[...r]:[];for(let t of i)for(let n of t._zod.onattach)n(e);if(i.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let t=(t,n,r)=>{if(t.memo)return t;let i=fe(t),a;for(let o of n){if(o._zod.def.when){if(pe(t)||!o._zod.def.when(t))continue}else if(i)continue;let n=t.issues.length,s=o._zod.check(t);if(s instanceof Promise&&r?.async===!1)throw new Pe;if(a||s instanceof Promise)a=(a??Promise.resolve()).then(async()=>{await s,t.issues.length!==n&&(ge(t.issues,n,e),i||=fe(t,n))});else{if(t.issues.length===n)continue;ge(t.issues,n,e),i||=fe(t,n)}}return a?a.then(()=>t):t},n=(n,r,a)=>{if(fe(n))return n.aborted=!0,n;let o=t(r,i,a);if(o instanceof Promise){if(a.async===!1)throw new Pe;return o.then(t=>e._zod.parse(t,a))}return e._zod.parse(o,a)};e._zod.run=(r,a)=>{if(a.skipChecks)return e._zod.parse(r,a);if(a.direction===`backward`){let t=e._zod.parse({value:r.value,issues:[]},{...a,skipChecks:!0});return t instanceof Promise?t.then(e=>n(e,r,a)):n(t,r,a)}let o=e._zod.parse(r,a);if(o instanceof Promise){if(a.async===!1)throw new Pe;return o.then(e=>t(e,i,a))}return t(o,i,a)}}},{get"~standard"(){return Se(this,`~standard`,dn(this))},set"~standard"(e){xe(this,`~standard`,e)}}),un=e=>e.success?{value:e.data}:{issues:e.error?.issues};function dn(e){return{validate:t=>{try{return un(et(e,t))}catch{return tt(e,t).then(un)}},vendor:`zod`,version:1}}var fn=E(`$ZodString`,(e,t)=>{k.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??Lt(e._zod.bag),e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value==`string`||n.issues.push({expected:`string`,code:`invalid_type`,input:n.value,inst:e}),n}}),A=E(`$ZodStringFormat`,(e,t)=>{$t.init(e,t),fn.init(e,t)}),pn=E(`$ZodGUID`,(e,t)=>{t.pattern??=vt,A.init(e,t)}),mn=E(`$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(e===void 0)throw Error(`Invalid UUID version: "${t.version}"`);t.pattern??=yt(e)}else t.pattern??=yt();A.init(e,t)}),hn=E(`$ZodEmail`,(e,t)=>{t.pattern??=bt,A.init(e,t)});function gn(e,t){if(!t.normalize&&t.protocol?.source===kt.source&&!/^https?:\/\//i.test(e))return 1;try{return new URL(e)}catch{return 2}}var _n=/[\t\n\r]/g;function vn(e){return e.replace(_n,``)}function yn(e,t){return t.lastIndex=0,t.test(e.hostname)}function bn(e,t){return t.lastIndex=0,t.test(e.protocol.endsWith(`:`)?e.protocol.slice(0,-1):e.protocol)}var xn=E(`$ZodURL`,(e,t)=>{A.init(e,t),e._zod.check=n=>{try{let r=n.value.trim(),i=gn(r,t);if(i===1){n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid URL format`,input:n.value,inst:e,continue:!t.abort});return}if(i===2){n.issues.push({code:`invalid_format`,format:`url`,input:n.value,inst:e,continue:!t.abort});return}t.hostname&&!yn(i,t.hostname)&&n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid hostname`,pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort}),t.protocol&&!bn(i,t.protocol)&&n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid protocol`,pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort}),n.value=t.normalize?i.href:vn(r);return}catch{n.issues.push({code:`invalid_format`,format:`url`,input:n.value,inst:e,continue:!t.abort})}}}),Sn=E(`$ZodEmoji`,(e,t)=>{t.pattern??=St(),A.init(e,t)}),Cn=E(`$ZodNanoID`,(e,t)=>{if(t.length!==void 0&&(!Number.isInteger(t.length)||t.length<1))throw Error(`Invalid nanoid length: ${t.length}`);t.pattern??=t.length===void 0?ht:gt(t.length),A.init(e,t)}),wn=E(`$ZodCUID`,(e,t)=>{t.pattern??=ut,A.init(e,t)}),Tn=E(`$ZodCUID2`,(e,t)=>{t.pattern??=dt,A.init(e,t)}),En=E(`$ZodULID`,(e,t)=>{t.pattern??=ft,A.init(e,t)}),Dn=E(`$ZodXID`,(e,t)=>{t.pattern??=pt,A.init(e,t)}),On=E(`$ZodKSUID`,(e,t)=>{t.pattern??=mt,A.init(e,t)}),kn=E(`$ZodISODateTime`,(e,t)=>{t.pattern??=It(t),A.init(e,t),(t.local||t.precision===-1)&&(e._zod.bag.laxFormat=!0,e._zod.onattach.push(e=>{e._zod.bag.laxFormat=!0}))}),An=E(`$ZodISODate`,(e,t)=>{t.pattern??=Nt,A.init(e,t)}),jn=E(`$ZodISOTime`,(e,t)=>{t.pattern??=Ft(t),A.init(e,t)}),Mn=E(`$ZodISODuration`,(e,t)=>{t.pattern??=_t,A.init(e,t)}),Nn=E(`$ZodIPv4`,(e,t)=>{t.pattern??=Ct,A.init(e,t),e._zod.bag.format=`ipv4`}),Pn=/^[0-9a-fA-F:.]+$/;function Fn(e){if(!Pn.test(e))return!1;try{return new URL(`http://[${e}]`),!0}catch{return!1}}var In=E(`$ZodIPv6`,(e,t)=>{t.pattern??=wt,A.init(e,t),e._zod.bag.format=`ipv6`,e._zod.check=n=>{Fn(n.value)||n.issues.push({code:`invalid_format`,format:`ipv6`,input:n.value,inst:e,continue:!t.abort})}}),Ln=E(`$ZodCIDRv4`,(e,t)=>{t.pattern??=Tt,A.init(e,t)});function Rn(e){let t=e.split(`/`);if(t.length!==2)return!1;let[n,r]=t;if(!r)return!1;let i=Number(r);return`${i}`!==r||i<0||i>128?!1:Fn(n)}var zn=E(`$ZodCIDRv6`,(e,t)=>{t.pattern??=Et,A.init(e,t),e._zod.check=n=>{Rn(n.value)||n.issues.push({code:`invalid_format`,format:`cidrv6`,input:n.value,inst:e,continue:!t.abort})}});function Bn(e){if(e===``)return!0;if(/\s/.test(e)||e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}var Vn=E(`$ZodBase64`,(e,t)=>{t.pattern??=Dt,A.init(e,t),e._zod.bag.contentEncoding=`base64`,e._zod.check=n=>{Bn(n.value)||n.issues.push({code:`invalid_format`,format:`base64`,input:n.value,inst:e,continue:!t.abort})}});function Hn(e){if(!Ot.test(e))return!1;let t=e.replace(/[-_]/g,e=>e===`-`?`+`:`/`);return Bn(t.padEnd(Math.ceil(t.length/4)*4,`=`))}var Un=E(`$ZodBase64URL`,(e,t)=>{t.pattern??=Ot,A.init(e,t),e._zod.bag.contentEncoding=`base64url`,e._zod.check=n=>{Hn(n.value)||n.issues.push({code:`invalid_format`,format:`base64url`,input:n.value,inst:e,continue:!t.abort})}}),Wn=E(`$ZodE164`,(e,t)=>{t.pattern??=At,A.init(e,t)});function Gn(e,t=null){try{let n=e.split(`.`);if(n.length!==3)return!1;let[r]=n;if(!r)return!1;let i=JSON.parse(atob(r));return!(`typ`in i&&i?.typ!==`JWT`||!i.alg||t&&(!(`alg`in i)||i.alg!==t))}catch{return!1}}var Kn=E(`$ZodJWT`,(e,t)=>{A.init(e,t),e._zod.check=n=>{Gn(n.value,t.alg)||n.issues.push({code:`invalid_format`,format:`jwt`,input:n.value,inst:e,continue:!t.abort})}}),qn=E(`$ZodNumber`,(e,t)=>{k.init(e,t),e._zod.pattern=e._zod.bag.pattern??zt,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}let i=n.value;if(typeof i==`number`&&!Number.isNaN(i)&&Number.isFinite(i))return n;let a=typeof i==`number`?Number.isNaN(i)?`NaN`:Number.isFinite(i)?void 0:String(i):void 0;return n.issues.push({expected:`number`,code:`invalid_type`,input:i,inst:e,...a?{received:a}:{}}),n}}),Jn=E(`$ZodNumberFormat`,(e,t)=>{Yt.init(e,t),qn.init(e,t)}),Yn=E(`$ZodBoolean`,(e,t)=>{k.init(e,t),e._zod.pattern=Bt,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=!!n.value}catch{}let i=n.value;return typeof i==`boolean`||n.issues.push({expected:`boolean`,code:`invalid_type`,input:i,inst:e}),n}}),Xn=E(`$ZodNull`,(e,t)=>{k.init(e,t),e._zod.pattern=Vt,e._zod.values=new Set([null]),e._zod.parse=(t,n)=>{let r=t.value;return r===null||t.issues.push({expected:`null`,code:`invalid_type`,input:r,inst:e}),t}}),Zn=E(`$ZodAny`,(e,t)=>{k.init(e,t),e._zod.parse=e=>e}),Qn=E(`$ZodUnknown`,(e,t)=>{k.init(e,t),e._zod.parse=e=>e}),$n=E(`$ZodNever`,(e,t)=>{k.init(e,t),e._zod.parse=(t,n)=>(t.issues.push({expected:`never`,code:`invalid_type`,input:t.value,inst:e}),t)});function er(e,t,n){e.issues.length&&t.issues.push(...me(n,e.issues)),t.value[n]=e.value}var tr=E(`$ZodArray`,(e,t)=>{k.init(e,t);let n=Ie.memoizer;n?.attach(e),e._zod.parse=(r,i)=>{let a=r.value;if(!Array.isArray(a))return r.issues.push({expected:`array`,code:`invalid_type`,input:a,inst:e}),r;r.value=n?n.alloc(e,r,Array(a.length),i):Array(a.length);let o=[];for(let e=0;e<a.length;e++){let n=a[e],s=t.element._zod.run({value:n,issues:[]},i);s instanceof Promise?o.push(s.then(t=>er(t,r,e))):er(s,r,e)}return o.length?Promise.all(o).then(()=>r):r}});function nr(e,t,n,r,i,a){let o=n in r,s=a===`optional`;if(!(!o&&s&&i===`optional`)){if(e.issues.length){if(i!==void 0&&s&&!o)return;t.issues.push(...me(n,e.issues))}if(!o&&i===void 0){e.issues.length||t.issues.push({code:`invalid_type`,expected:`nonoptional`,input:void 0,path:[n]});return}e.value===void 0?o&&(t.value[n]=void 0):t.value[n]=e.value}}var rr=[];function ir(e){let t=Object.keys(e.shape),n=Object.getOwnPropertySymbols(e.shape),r=n.length?n:rr,i=r.length?[...t,...r]:t;for(let t of i)if(!e.shape?.[t]?._zod?.traits?.has(`$ZodType`))throw Error(`Invalid element at key "${String(t)}": expected a Zod schema`);let a=re(e.shape);return{...e,allKeys:i,symbolKeys:r,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(a)}}function ar(e,t,n,r,i,a){let o=[],s=i.keySet,c=i.catchall._zod,l=c.def.type,u=c.optin,d=c.optout;for(let i in t){if(s.has(i))continue;if(i===`__proto__`){l===`never`&&o.push(i);continue}if(l===`never`){o.push(i);continue}let a=c.run({value:t[i],issues:[]},r);a instanceof Promise?e.push(a.then(e=>nr(e,n,i,t,u,d))):nr(a,n,i,t,u,d)}return o.length&&n.issues.push({code:`unrecognized_keys`,keys:o,input:t,inst:a,continue:!0}),e.length?Promise.all(e).then(()=>n):n}var or=new WeakMap,sr=E(`$ZodObject`,(e,t)=>{if(k.init(e,t),!Object.getOwnPropertyDescriptor(t,`shape`)?.get){let e=t.shape;or.set(t,e),Object.defineProperty(t,"shape",{get:()=>{let n={...e};return Object.defineProperty(t,"shape",{value:n}),or.set(t,n),n}})}let n=r(()=>ir(t));w(e,`propValues`,e=>{let t=e.def.shape,n={};for(let e in t){let r=t[e]._zod;if(r.values){Object.prototype.hasOwnProperty.call(n,e)||l(n,e,new Set);for(let t of r.values)n[e].add(t);r.optin!==void 0&&n[e].add(void 0)}}return n});let i=m,a=t.catchall,o,s=Ie.memoizer;s?.attach(e),e._zod.parse=(t,r)=>{o??=n.value;let c=t.value;if(!i(c))return t.issues.push({expected:`object`,code:`invalid_type`,input:c,inst:e}),t;t.value=s?s.alloc(e,t,{},r):{};let l=[],u=o.shape;for(let e of o.allKeys){if(e===`__proto__`)continue;let n=u[e],i=n._zod.optin,a=n._zod.optout,o=n._zod.run({value:c[e],issues:[]},r);o instanceof Promise?l.push(o.then(n=>nr(n,t,e,c,i,a))):nr(o,t,e,c,i,a)}return a?ar(l,c,t,r,n.value,e):l.length?Promise.all(l).then(()=>t):t}}),cr=E(`$ZodObjectJIT`,(e,t)=>{sr.init(e,t);let n=e._zod.parse,i=r(()=>ir(t)),a=Ie.memoizer,o=t=>{let n=i.value,r=n.symbolKeys,o=new cn([`payload`,`ctx`],{shape:t,inst:e,memo:a,syms:r}),s=e=>`shape[${e}]._zod.run({ value: input[${e}], issues: [] }, ctx)`,c=(e,t)=>`
4
- for (let i = 0; i < ${e}.issues.length; i++) {
5
- const iss = ${e}.issues[i];
6
- iss.path = iss.path ? [${t}, ...iss.path] : [${t}];
7
- payload.issues.push(iss);
8
- }`;o.write(`const input = payload.value;`);let l=Object.create(null),u=0;for(let e of n.allKeys)l[e]=`key_${u++}`;o.write(a?`const newResult = memo.alloc(inst, payload, {}, ctx);`:`const newResult = {};`);for(let e of n.allKeys){if(e===`__proto__`)continue;let n=l[e],i=typeof e==`symbol`?`syms[${r.indexOf(e)}]`:d(e),a=`${i} in input`,u=t[e],f=u?._zod?.optin,p=f!==void 0,m=u?._zod?.optout===`optional`;if(o.write(`const ${n} = ${s(i)};`),p&&m){let e=f===`optional`?`${n}_present`:`${n}.value !== undefined || ${n}_present`;o.write(`
9
- const ${n}_present = ${a};
10
- if (!${n}.issues.length || ${n}_present) {
11
- if (${n}.issues.length) {${c(n,i)}
12
- }
13
-
14
- if (${e}) {
15
- newResult[${i}] = ${n}.value;
16
- }
17
- }
18
-
19
- `)}else p?o.write(`
20
- if (${n}.issues.length) {${c(n,i)}
21
- }
22
-
23
- if (${n}.value === undefined) {
24
- if (${a}) {
25
- newResult[${i}] = undefined;
26
- }
27
- } else {
28
- newResult[${i}] = ${n}.value;
29
- }
30
-
31
- `):o.write(`
32
- const ${n}_present = ${a};
33
- if (${n}.issues.length) {${c(n,i)}
34
- }
35
- if (!${n}_present && !${n}.issues.length) {
36
- payload.issues.push({
37
- code: "invalid_type",
38
- expected: "nonoptional",
39
- input: undefined,
40
- path: [${i}]
41
- });
42
- }
43
-
44
- if (${n}_present) {
45
- newResult[${i}] = ${n}.value;
46
- }
47
-
48
- `)}return o.write(`payload.value = newResult;`),o.write(`return payload;`),o.compile()},s,c=m,l=!Ie.jitless,u=l&&h.value,f=t.catchall,p;e._zod.parse=(r,a)=>{p??=i.value;let d=r.value;return c(d)?l&&u&&a?.async===!1&&a.jitless!==!0?(s||=o(t.shape),r=s(r,a),f?ar([],d,r,a,p,e):r):n(r,a):(r.issues.push({expected:`object`,code:`invalid_type`,input:d,inst:e}),r)}});function lr(e,t,n,r){for(let n of e)if(n.issues.length===0)return t.value=n.value,t;let i=e.filter(e=>!fe(e));return i.length===1?(t.value=i[0].value,i[0]):(t.issues.push({code:`invalid_union`,input:t.value,inst:n,errors:e.map(e=>e.issues.map(e=>b(e,r,Le())))}),t)}var ur=E(`$ZodUnion`,(e,t)=>{k.init(e,t),w(e,`optin`,e=>e.def.options.some(e=>e._zod.optin===`defaulted`)?`defaulted`:e.def.options.some(e=>e._zod.optin!==void 0)?`optional`:void 0),w(e,`optout`,e=>e.def.options.some(e=>e._zod.optout===`optional`)?`optional`:void 0),w(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)))}),w(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=>a(e.source)).join(`|`)})$`)}});let n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(r,i)=>{if(n)return n(r,i);let a=!1,o=[];for(let e of t.options){let t=e._zod.run({value:r.value,issues:[]},i);if(t instanceof Promise)o.push(t),a=!0;else{if(t.issues.length===0)return t;o.push(t)}}return a?Promise.all(o).then(t=>lr(t,r,e,i)):lr(o,r,e,i)}}),dr=E(`$ZodDiscriminatedUnion`,(e,t)=>{t.inclusive=!1,ur.init(e,t);let n=e._zod.parse;w(e,`propValues`,e=>{let t={};for(let n of e.def.options){let r=n._zod.propValues;if(!r||Object.keys(r).length===0)throw Error(`Invalid discriminated union option at index "${e.def.options.indexOf(n)}"`);for(let[e,n]of Object.entries(r)){Object.prototype.hasOwnProperty.call(t,e)||l(t,e,new Set);for(let r of n)t[e].add(r)}}return t}),t.options.forEach((e,n)=>{let r=or.get(e._zod.def);if(r&&!Object.prototype.hasOwnProperty.call(r,t.discriminator))throw Error(`Invalid discriminated union option at index "${n}"`)});let i=r(()=>{let e=t.options,n=new Map;for(let r of e){let e=r._zod.propValues?.[t.discriminator];if(!e||e.size===0)throw Error(`Invalid discriminated union option at index "${t.options.indexOf(r)}"`);for(let t of e){if(n.has(t))throw Error(`Duplicate discriminator value "${String(t)}"`);n.set(t,r)}}return n});e._zod.parse=(r,a)=>{let o=r.value;if(!m(o))return r.issues.push({code:`invalid_type`,expected:`object`,input:o,inst:e}),r;let s=i.value.get(o?.[t.discriminator]);return s?s._zod.run(r,a):t.unionFallback||a.direction===`backward`?n(r,a):(r.issues.push({code:`invalid_union`,errors:[],note:`No matching discriminator`,discriminator:t.discriminator,options:Array.from(i.value.keys()),input:o,path:[t.discriminator],inst:e}),r)}}),fr=E(`$ZodIntersection`,(e,t)=>{k.init(e,t),e._zod.parse=(e,n)=>{let r=e.value,i=t.left._zod.run({value:r,issues:[]},n),a=t.right._zod.run({value:r,issues:[]},n);return i instanceof Promise||a instanceof Promise?Promise.all([i,a]).then(([t,n])=>mr(e,t,n)):mr(e,i,a)}});function pr(e,t){if(e===t||e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(g(e)&&g(t)){let n=Object.keys(t),r=Object.keys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};Object.prototype.hasOwnProperty.call(i,`__proto__`)&&delete i.__proto__;for(let n of r){if(n===`__proto__`)continue;let r=pr(e[n],t[n]);if(!r.valid)return{valid:!1,mergeErrorPath:[n,...r.mergeErrorPath]};i[n]=r.data}return{valid:!0,data:i}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let n=[];for(let r=0;r<e.length;r++){let i=e[r],a=t[r],o=pr(i,a);if(!o.valid)return{valid:!1,mergeErrorPath:[r,...o.mergeErrorPath]};n.push(o.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function mr(e,t,n){let r=new Map,i,a=new Map,o=(e,t)=>{let n;if(e.code===`unrecognized_keys`&&!e.path?.length)i??=e,n=e.keys;else if(e.code===`invalid_key`&&e.origin===`record`&&e.path?.length===1){let t=String(e.path[0]);a.has(t)||a.set(t,e),n=[t]}else return!1;for(let e of n)r.has(e)||r.set(e,{}),r.get(e)[t]=!0;return!0};for(let n of t.issues)o(n,`l`)||e.issues.push(n);for(let t of n.issues)o(t,`r`)||e.issues.push(t);let s=[...r].filter(([,e])=>e.l&&e.r).map(([e])=>e);if(s.length){let t=i?s.filter(e=>i.keys.includes(e)):[];t.length&&e.issues.push({...i,keys:t});for(let n of s)!t.includes(n)&&a.has(n)&&e.issues.push(a.get(n))}let c=pr(t.value,n.value);if(!c.valid){if(fe(e))return e;throw Error(`Unmergable intersection. Error path: ${JSON.stringify(c.mergeErrorPath)}`)}return e.value=c.data,e}var hr=E(`$ZodRecord`,(e,t)=>{k.init(e,t);let n=Ie.memoizer;n?.attach(e),e._zod.parse=(r,i)=>{let a=r.value;if(!g(a))return r.issues.push({expected:`record`,code:`invalid_type`,input:a,inst:e}),r;let o=[],s=t.keyType._zod.values;if(s&&!t.partial){r.value=n?n.alloc(e,r,{},i):{};let c=new Set;for(let n of s)if(typeof n==`string`||typeof n==`number`||typeof n==`symbol`){if(c.add(typeof n==`number`?n.toString():n),n===`__proto__`)continue;let s=t.keyType._zod.run({value:n,issues:[]},i);if(s instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(s.issues.length){r.issues.push({code:`invalid_key`,origin:`record`,issues:s.issues.map(e=>b(e,i,Le())),input:n,path:[n],inst:e});continue}let l=s.value;if(l===`__proto__`)continue;let u=t.valueType._zod.run({value:a[n],issues:[]},i);u instanceof Promise?o.push(u.then(e=>{e.issues.length&&r.issues.push(...me(n,e.issues)),r.value[l]=e.value})):(u.issues.length&&r.issues.push(...me(n,u.issues)),r.value[l]=u.value)}let l;for(let e in a)if(!c.has(e))if(t.mode===`loose`){if(e===`__proto__`)continue;r.value[e]=a[e]}else l??=[],l.push(e);l&&l.length>0&&r.issues.push({code:`unrecognized_keys`,input:a,inst:e,keys:l,continue:!0})}else{r.value=n?n.alloc(e,r,{},i):{};let c;for(let n of Reflect.ownKeys(a)){if(n===`__proto__`||!Object.prototype.propertyIsEnumerable.call(a,n))continue;let l=t.keyType._zod.run({value:n,issues:[]},i);if(l instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(typeof n==`string`&&zt.test(n)&&l.issues.length){let e=t.keyType._zod.run({value:Number(n),issues:[]},i);if(e instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);e.issues.length===0&&(l=e)}if(l.issues.length){t.mode===`loose`?r.value[n]=a[n]:s?(c??=[],c.push(n)):r.issues.push({code:`invalid_key`,origin:`record`,issues:l.issues.map(e=>b(e,i,Le())),input:n,path:[n],inst:e});continue}let u=l.value;if(u===`__proto__`)continue;let d=t.valueType._zod.run({value:a[n],issues:[]},i);d instanceof Promise?o.push(d.then(e=>{e.issues.length&&r.issues.push(...me(n,e.issues)),r.value[u]=e.value})):(d.issues.length&&r.issues.push(...me(n,d.issues)),r.value[u]=d.value)}c&&c.length>0&&r.issues.push({code:`unrecognized_keys`,input:a,inst:e,keys:c,continue:!0})}return o.length?Promise.all(o).then(()=>r):r}}),gr=E(`$ZodEnum`,(t,n)=>{k.init(t,n);let r=e(n.entries),i=new Set(r);t._zod.values=i;let a=r.filter(e=>te.has(typeof e));t._zod.pattern=RegExp(a.length?`^(${a.map(e=>_(e.toString())).join(`|`)})$`:`^[^\\s\\S]$`),t._zod.parse=(e,n)=>{let a=e.value;return i.has(a)||e.issues.push({code:`invalid_value`,values:r,input:a,inst:t}),e}}),_r=E(`$ZodLiteral`,(e,t)=>{k.init(e,t);let n=new Set(t.values);e._zod.values=n,e._zod.pattern=RegExp(t.values.length?`^(${t.values.map(e=>typeof e==`string`?_(e):e?_(e.toString()):String(e)).join(`|`)})$`:`^[^\\s\\S]$`),e._zod.parse=(r,i)=>{let a=r.value;return n.has(a)||r.issues.push({code:`invalid_value`,values:t.values,input:a,inst:e}),r}}),vr=E(`$ZodTransform`,(e,t)=>{k.init(e,t),e._zod.optin=`optional`,Ie.memoizer?.guard(e),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new Fe(e.constructor.name);let i=t.transform(n.value,n);if(r.async)return(i instanceof Promise?i:Promise.resolve(i)).then(e=>(n.value=e,n));if(i instanceof Promise)throw new Pe;return n.value=i,n}});function yr(e,t){return e.value=t.issues.length?void 0:t.value,e}var br=E(`$ZodOptional`,(e,t)=>{k.init(e,t),w(e,`optin`,e=>e.def.innerType._zod.optin===`defaulted`?`defaulted`:`optional`),e._zod.optout=`optional`,w(e,`values`,e=>{let t=e.def.innerType._zod.values;return t?new Set([...t,void 0]):void 0}),w(e,`pattern`,e=>{let t=e.def.innerType._zod.pattern;return t?RegExp(`^(${a(t.source)})?$`):void 0}),e._zod.parse=(e,n)=>{if(e.value===void 0){if(t.innerType._zod.optin!==`defaulted`)return e;let r=t.innerType._zod.run({value:e.value,issues:[]},n);return r instanceof Promise?r.then(t=>yr(e,t)):yr(e,r)}return t.innerType._zod.run(e,n)}}),xr=E(`$ZodExactOptional`,(e,t)=>{br.init(e,t),w(e,`values`,e=>e.def.innerType._zod.values),w(e,`pattern`,e=>e.def.innerType._zod.pattern),e._zod.parse=(e,n)=>t.innerType._zod.run(e,n)}),Sr=E(`$ZodNullable`,(e,t)=>{k.init(e,t),w(e,`optin`,e=>e.def.innerType._zod.optin),w(e,`optout`,e=>e.def.innerType._zod.optout),w(e,`pattern`,e=>{let t=e.def.innerType._zod.pattern;return t?RegExp(`^(${a(t.source)}|null)$`):void 0}),w(e,`values`,e=>e.def.innerType._zod.values?new Set([...e.def.innerType._zod.values,null]):void 0),e._zod.parse=(e,n)=>e.value===null?e:t.innerType._zod.run(e,n)}),Cr=E(`$ZodDefault`,(e,t)=>{k.init(e,t),e._zod.optin=`defaulted`,w(e,`values`,e=>e.def.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);if(e.value===void 0)return e.value=t.defaultValue,e;let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(e=>wr(e,t)):wr(r,t)}});function wr(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}var Tr=E(`$ZodPrefault`,(e,t)=>{k.init(e,t),e._zod.optin=`defaulted`,w(e,`values`,e=>e.def.innerType._zod.values),e._zod.parse=(e,n)=>(n.direction===`backward`||e.value===void 0&&(e.value=t.defaultValue),t.innerType._zod.run(e,n))}),Er=E(`$ZodNonOptional`,(e,t)=>{k.init(e,t),w(e,`values`,e=>{let t=e.def.innerType._zod.values;return t?new Set([...t].filter(e=>e!==void 0)):void 0}),e._zod.parse=(n,r)=>{let i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(t=>Dr(t,e)):Dr(i,e)}});function Dr(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:`invalid_type`,expected:`nonoptional`,input:e.value,inst:t}),e}function Or(e,t,n,r){return t.issues.length?(e.value=n.catchValue({...t,value:e.value,error:{issues:t.issues.map(e=>b(e,r,Le()))},input:e.value}),e):(e.value=t.value,t.memo&&(e.memo=!0),e)}var kr=E(`$ZodCatch`,(e,t)=>{k.init(e,t),w(e,`optin`,e=>e.def.innerType._zod.optin===`defaulted`?`defaulted`:`optional`),w(e,`optout`,e=>e.def.innerType._zod.optout),w(e,`values`,e=>e.def.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run({value:e.value,issues:[]},n);return r instanceof Promise?r.then(r=>Or(e,r,t,n)):Or(e,r,t,n)}}),Ar=E(`$ZodPipe`,(e,t)=>{k.init(e,t),w(e,`values`,e=>e.def.in._zod.values),w(e,`optin`,e=>e.def.in._zod.optin),w(e,`optout`,e=>e.def.out._zod.optout),w(e,`propValues`,e=>e.def.in._zod.propValues),e._zod.parse=(e,n)=>{if(n.direction===`backward`){let r=t.out._zod.run(e,n);return r instanceof Promise?r.then(e=>jr(e,t.in,n)):jr(r,t.in,n)}let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>jr(e,t.out,n)):jr(r,t.out,n)}});function jr(e,t,n){return e.issues.some(e=>e.code!==`unrecognized_keys`)?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}var Mr=E(`$ZodPreprocess`,(e,t)=>{Ar.init(e,t)}),Nr=E(`$ZodReadonly`,(e,t)=>{k.init(e,t),w(e,`propValues`,e=>e.def.innerType._zod.propValues),w(e,`values`,e=>e.def.innerType._zod.values),w(e,`optin`,e=>e.def.innerType?._zod?.optin),w(e,`optout`,e=>e.def.innerType?._zod?.optout),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(Pr):Pr(r)}});function Pr(e){return e.memo||(e.value=Object.freeze(e.value)),e}var Fr=E(`$ZodLazy`,(e,t)=>{k.init(e,t),c(e._zod,`innerType`,()=>{let e=t;return e._cachedInner||=t.getter(),e._cachedInner}),w(e,`pattern`,e=>e.innerType?._zod?.pattern),w(e,`propValues`,e=>e.innerType?._zod?.propValues),w(e,`optin`,e=>e.innerType?._zod?.optin??void 0),w(e,`optout`,e=>e.innerType?._zod?.optout??void 0),e._zod.parse=(t,n)=>e._zod.innerType._zod.run(t,n)}),Ir=E(`$ZodCustom`,(e,t)=>{O.init(e,t),k.init(e,t),e._zod.parse=(e,t)=>e,e._zod.check=n=>{let r=n.value,i=t.fn(r);if(i instanceof Promise)return i.then(t=>Lr(t,n,r,e));Lr(i,n,r,e)}});function Lr(e,t,n,r){if(!e){let e={code:`custom`,input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(e.params=r._zod.def.params),t.issues.push(S(e))}}var Rr=class extends Error{constructor(){super(`Cannot parse a reference cycle that closes through a transform`),this.name=`ZodCyclicError`}},zr=`~memo`,Br=[];function Vr(e){return e.map(e=>e.path?{...e,path:e.path.slice()}:{...e})}var Hr=new WeakMap;function Ur(e,t){let n=Hr.get(e);if(n!==void 0)return n;if(t.has(e))return!0;t.add(e);let r=!1,i=e=>{!r&&e?._zod&&Ur(e,t)&&(r=!0)},a=e._zod.def;switch(a.type){case`object`:for(let e of Reflect.ownKeys(a.shape))i(a.shape[e]);i(a.catchall);break;case`array`:i(a.element);break;case`tuple`:for(let e of a.items)i(e);i(a.rest);break;case`record`:case`map`:i(a.keyType),i(a.valueType);break;case`set`:i(a.valueType);break;case`union`:for(let e of a.options)i(e);break;case`intersection`:i(a.left),i(a.right);break;case`optional`:case`nullable`:case`default`:case`prefault`:case`catch`:case`readonly`:case`nonoptional`:case`promise`:case`success`:i(a.innerType);break;case`pipe`:i(a.in),i(a.out);break;case`function`:i(a.input),i(a.output);break;case`lazy`:i(e._zod.innerType);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 a){let t=Object.getOwnPropertyDescriptor(a,e);if(!t||t.get)continue;let n=t.value;if(!(!n||typeof n!=`object`)){if(n._zod)i(n);else if(Array.isArray(n))for(let e of n)i(e)}}}return t.delete(e),Hr.set(e,r),r}function Wr(e,t){let n=e.buckets.get(t);return n||(n=new Map,e.buckets.set(t,n)),n}var Gr,Kr=[],qr={alloc(e,t,n){let r=Gr;if(!r)return n;Gr=void 0;let i={value:n,issues:null};return r.set(t.value,i),Kr.push(i),n},guard(e){var t;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let t=e._zod.parse,n=(e,n)=>{if(n.direction!==`backward`&&Yr(n,e.value))throw new Rr;return t(e,n)};e._zod.parse=n,e._zod.run===t&&(e._zod.run=n)})},attach(e){var t;let n,r,i;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let t=e._zod.parse,a=(o,s)=>{if(n===void 0&&(n=Ur(e,new Set),!n))return e._zod.parse=t,e._zod.run===a&&(e._zod.run=t),t(o,s);let c=o.value;if(typeof c!=`object`||!c)return t(o,s);let l=s[zr];l||(l={buckets:new Map,backEdges:void 0},s[zr]=l);let u;r===s?u=i:(u=Wr(l,e),r=s,i=u);let d=u.get(c);if(d)return o.value=d.value,d.issues?d.issues.length&&o.issues.push(...Vr(d.issues)):(o.memo=!0,l.backEdges??(l.backEdges=new Set),l.backEdges.add(d.value)),o;Gr=u;let f=Kr.length,p=t(o,s);Gr=void 0;let m=Kr.length>f?Kr.pop():void 0;return p instanceof Promise?p.then(e=>(m&&(m.issues=e.issues.length?Vr(e.issues):Br),e)):(m&&(m.issues=p.issues.length?Vr(p.issues):Br),p)};e._zod.parse=a,e._zod.run===t&&(e._zod.run=a)})}};function Jr(){return qr}function Yr(e,t){let n=e[zr]?.backEdges;return n!==void 0&&typeof t==`object`&&!!t&&n.has(t)}var Xr=()=>{let e={string:{unit:`characters`,verb:`to have`},file:{unit:`bytes`,verb:`to have`},array:{unit:`items`,verb:`to have`},set:{unit:`items`,verb:`to have`},map:{unit:`entries`,verb:`to have`}};function n(t){return e[t]??null}let r={regex:`input`,email:`email address`,url:`URL`,emoji:`emoji`,uuid:`UUID`,uuidv4:`UUIDv4`,uuidv6:`UUIDv6`,nanoid:`nanoid`,guid:`GUID`,cuid:`cuid`,cuid2:`cuid2`,ulid:`ULID`,xid:`XID`,ksuid:`KSUID`,datetime:`ISO datetime`,date:`ISO date`,time:`ISO time`,duration:`ISO duration`,ipv4:`IPv4 address`,ipv6:`IPv6 address`,mac:`MAC address`,cidrv4:`IPv4 range`,cidrv6:`IPv6 range`,base64:`base64-encoded string`,base64url:`base64url-encoded string`,json_string:`JSON string`,e164:`E.164 number`,credit_card:`credit card number`,jwt:`JWT`,template_literal:`input`},i={nan:`NaN`};function a(e,t){return e===`number`&&typeof t==`number`&&!Number.isFinite(t)?String(t):i[e]??e}return e=>{switch(e.code){case`invalid_type`:return`Invalid input: expected ${a(e.expected)}, received ${a(x(e.input),e.input)}`;case`invalid_value`:return e.values.length===1?`Invalid input: expected ${ne(e.values[0])}`:`Invalid option: expected one of ${t(e.values,`|`)}`;case`too_big`:{let t=e.exact?`exactly `:e.inclusive?`<=`:`<`,r=n(e.origin);return r?`Too big: expected ${e.origin??`value`} to have ${t}${e.maximum.toString()} ${r.unit??`elements`}`:`Too big: expected ${e.origin??`value`} to be ${t}${e.maximum.toString()}`}case`too_small`:{let t=e.exact?`exactly `:e.inclusive?`>=`:`>`,r=n(e.origin);return r?`Too small: expected ${e.origin} to have ${t}${e.minimum.toString()} ${r.unit}`:`Too small: expected ${e.origin} to be ${t}${e.minimum.toString()}`}case`invalid_format`:{let t=e;return t.format===`starts_with`?`Invalid string: must start with "${t.prefix}"`:t.format===`ends_with`?`Invalid string: must end with "${t.suffix}"`:t.format===`includes`?`Invalid string: must include "${t.includes}"`:t.format===`regex`?`Invalid string: must match pattern ${t.pattern}`:`Invalid ${r[t.format]??e.format}`}case`not_multiple_of`:return`Invalid number: must be a multiple of ${e.divisor}`;case`unrecognized_keys`:return`Unrecognized key${e.keys.length>1?`s`:``}: ${t(e.keys,`, `)}`;case`invalid_key`:return`Invalid key in ${e.origin}`;case`invalid_union`:return e.options&&Array.isArray(e.options)&&e.options.length>0?`Invalid discriminator value. Expected ${e.options.map(e=>`'${e}'`).join(` | `)}`:e.inclusive===!1?`Invalid input: more than one option matched`:`Invalid input`;case`invalid_element`:return`Invalid value in ${e.origin}`;default:return`Invalid input`}}};function Zr(){return{localeError:Xr()}}var Qr,$r=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){let n=t[0];return this._map.set(e,n),n&&typeof n==`object`&&`id`in n&&this._idmap.set(n.id,e),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let t=this._map.get(e);return t&&typeof t==`object`&&`id`in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let n={...this.get(t)??{}};delete n.id;let r={...n,...this._map.get(e)};return Object.keys(r).length?r:void 0}return this._map.get(e)}has(e){return this._map.has(e)}};function ei(){return new $r}(Qr=globalThis).__zod_globalRegistry??(Qr.__zod_globalRegistry=ei());var ti=globalThis.__zod_globalRegistry;function ni(e,t){return new e({type:`string`,...y(t)})}function ri(e,t){return new e({type:`string`,format:`email`,check:`string_format`,abort:!1,...y(t)})}function ii(e,t){return new e({type:`string`,format:`guid`,check:`string_format`,abort:!1,...y(t)})}function ai(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,...y(t)})}function oi(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v4`,...y(t)})}function si(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v6`,...y(t)})}function ci(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v7`,...y(t)})}function li(e,t){return new e({type:`string`,format:`url`,check:`string_format`,abort:!1,...y(t)})}function ui(e,t){return new e({type:`string`,format:`emoji`,check:`string_format`,abort:!1,...y(t)})}function di(e,t){return new e({type:`string`,format:`nanoid`,check:`string_format`,abort:!1,...y(t)})}function fi(e,t){return new e({type:`string`,format:`cuid`,check:`string_format`,abort:!1,...y(t)})}function pi(e,t){return new e({type:`string`,format:`cuid2`,check:`string_format`,abort:!1,...y(t)})}function mi(e,t){return new e({type:`string`,format:`ulid`,check:`string_format`,abort:!1,...y(t)})}function hi(e,t){return new e({type:`string`,format:`xid`,check:`string_format`,abort:!1,...y(t)})}function gi(e,t){return new e({type:`string`,format:`ksuid`,check:`string_format`,abort:!1,...y(t)})}function _i(e,t){return new e({type:`string`,format:`ipv4`,check:`string_format`,abort:!1,...y(t)})}function vi(e,t){return new e({type:`string`,format:`ipv6`,check:`string_format`,abort:!1,...y(t)})}function yi(e,t){return new e({type:`string`,format:`cidrv4`,check:`string_format`,abort:!1,...y(t)})}function bi(e,t){return new e({type:`string`,format:`cidrv6`,check:`string_format`,abort:!1,...y(t)})}function xi(e,t){return new e({type:`string`,format:`base64`,check:`string_format`,abort:!1,...y(t)})}function Si(e,t){return new e({type:`string`,format:`base64url`,check:`string_format`,abort:!1,...y(t)})}function Ci(e,t){return new e({type:`string`,format:`e164`,check:`string_format`,abort:!1,...y(t)})}function wi(e,t){return new e({type:`string`,format:`jwt`,check:`string_format`,abort:!1,...y(t)})}function Ti(e,t){return new e({type:`string`,format:`datetime`,check:`string_format`,offset:!1,local:!1,precision:null,...y(t)})}function Ei(e,t){return new e({type:`string`,format:`date`,check:`string_format`,...y(t)})}function Di(e,t){return new e({type:`string`,format:`time`,check:`string_format`,precision:null,...y(t)})}function Oi(e,t){return new e({type:`string`,format:`duration`,check:`string_format`,...y(t)})}function ki(e,t){return new e({type:`number`,checks:[],...y(t)})}function Ai(e,t){return new e({type:`number`,coerce:!0,checks:[],...y(t)})}function ji(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`safeint`,...y(t)})}function Mi(e,t){return new e({type:`boolean`,...y(t)})}function Ni(e,t){return new e({type:`null`,...y(t)})}function Pi(e){return new e({type:`any`})}function Fi(e){return new e({type:`unknown`})}function Ii(e,t){return new e({type:`never`,...y(t)})}function Li(e,t){return new Kt({check:`less_than`,...y(t),value:e,inclusive:!1})}function Ri(e,t){return new Kt({check:`less_than`,...y(t),value:e,inclusive:!0})}function zi(e,t){return new qt({check:`greater_than`,...y(t),value:e,inclusive:!1})}function Bi(e,t){return new qt({check:`greater_than`,...y(t),value:e,inclusive:!0})}function Vi(e,t){return new Jt({check:`multiple_of`,...y(t),value:e})}function Hi(e,t){return new Xt({check:`max_length`,...y(t),maximum:e})}function Ui(e,t){return new Zt({check:`min_length`,...y(t),minimum:e})}function Wi(e,t){return new Qt({check:`length_equals`,...y(t),length:e})}function Gi(e,t){return new en({check:`string_format`,format:`regex`,...y(t),pattern:e})}function Ki(e){return new tn({check:`string_format`,format:`lowercase`,...y(e)})}function qi(e){return new nn({check:`string_format`,format:`uppercase`,...y(e)})}function Ji(e,t){return new rn({check:`string_format`,format:`includes`,...y(t),includes:e})}function Yi(e,t){return new an({check:`string_format`,format:`starts_with`,...y(t),prefix:e})}function Xi(e,t){return new on({check:`string_format`,format:`ends_with`,...y(t),suffix:e})}function Zi(e){return new sn({check:`overwrite`,tx:e})}function Qi(e){return Zi(t=>t.normalize(e))}function $i(){return Zi(e=>e.trim())}function ea(){return Zi(e=>e.toLowerCase())}function ta(){return Zi(e=>e.toUpperCase())}function na(){return Zi(e=>f(e))}function ra(e,t,n){return new e({type:`array`,element:t,...y(n)})}function ia(e,t,n){return new e({type:`custom`,check:`custom`,fn:t,...y(n)})}function aa(e,t){let n=oa(t=>(t.addIssue=e=>{if(typeof e==`string`)t.issues.push(S(e,t.value,n._zod.def));else{let r=e;r.fatal&&(r.continue=!1),r.code??=`custom`,`input`in r||(r.input=t.value),r.inst??=n,r.continue??=!n._zod.def.abort,t.issues.push(S(r))}},e(t.value,t)),t);return n}function oa(e,t){let n=new O({check:`custom`,...y(t)});return n._zod.check=e,n}function sa(e,...t){for(let n of t)for(let t of Reflect.ownKeys(n))Object.prototype.propertyIsEnumerable.call(n,t)&&l(e,t,n[t]);return e}function ca(e){let t=e?.target??`draft-2020-12`;return t===`draft-4`&&(t=`draft-04`),t===`draft-7`&&(t=`draft-07`),{processors:e.processors??{},metadataRegistry:e?.metadata??ti,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 la(e,t,n,r,i){let a=typeof t.unrepresentable==`function`?t.unrepresentable({zodSchema:e,path:r.path,message:i}):t.unrepresentable;if(a===`any`)return!1;if(a===void 0||a===`throw`)throw Error(i);return Object.assign(n,a),!0}function j(e,t,n={path:[],schemaPath:[]}){var r;let i=e._zod.def,a=t.seen.get(e);if(a)return a.count++,n.schemaPath.includes(e)&&(a.cycle=n.path),a.schema;let o={schema:{},count:1,cycle:void 0,path:n.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 r={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,o.schema,r);else{let n=o.schema,a=t.processors[i.type];if(!a)throw Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);a(e,t,n,r)}let a=e._zod.parent;a&&(o.ref||=a,j(a,t,r),t.seen.get(a).isParent=!0)}let c=t.metadataRegistry.get(e);return c&&sa(o.schema,c),t.io===`input`&&ya(e)&&(delete o.schema.examples,delete o.schema.default),t.io===`input`&&`_prefault`in o.schema&&((r=o.schema).default??(r.default=o.schema._prefault)),delete o.schema._prefault,t.seen.get(e).schema}function ua(e){return e.replace(/~/g,`~0`).replace(/\//g,`~1`)}function da(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);if(e.external&&e.sharedDefsExtractedFor===e.external)return;let r=new Map;for(let t of e.seen.entries()){let n=e.metadataRegistry.get(t[0])?.id;if(n){let e=r.get(n);if(e&&e!==t[0])throw Error(`Duplicate schema id "${n}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(n,t[0])}}let i=t=>{let r=e.target===`draft-2020-12`?`$defs`:`definitions`;if(e.external){let n=e.external.registry.get(t[0])?.id,i=e.external.uri??(e=>e);if(n)return{ref:i(n)};let a=t[1].defId??t[1].schema.id??`schema${e.counter++}`;return t[1].defId=a,{defId:a,ref:`${i(`__shared`)}#/${r}/${ua(a)}`}}let i=`#/${r}/`;if(t[1]===n&&!t[1].schema.id)return{ref:`#`};let a=t[1].schema.id??`__schema${e.counter++}`;return{defId:a,ref:i+ua(a)}},a=e=>{if(e[1].schema.$ref)return;let t=e[1],{ref:n,defId:r}=i(e);t.def={...t.schema},r&&(t.defId=r);let a=t.schema;for(let e in a)delete a[e];a.$ref=n};if(e.cycles===`throw`)for(let t of e.seen.entries()){let e=t[1];if(e.cycle)throw Error(`Cycle detected: #/${e.cycle?.join(`/`)}/<root>
49
-
50
- Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let n of e.seen.entries()){let r=n[1];if(t===n[0]){a(n);continue}if(e.external){let r=e.external.registry.get(n[0])?.id;if(t!==n[0]&&r){a(n);continue}}if(e.metadataRegistry.get(n[0])?.id){a(n);continue}if(r.cycle){a(n);continue}if(r.count>1&&e.reused===`ref`){a(n);continue}}e.external&&(e.sharedDefsExtractedFor=e.external)}function fa(e){let t=e.anyOf;if(!Array.isArray(t)||t.length===0||e.type!==void 0)return;let n=[];for(let e of t){if(!e||typeof e!=`object`)return;fa(e);let t=Object.keys(e);if(t.length!==1||t[0]!==`type`)return;let r=e.type;for(let e of Array.isArray(r)?r:[r]){if(typeof e!=`string`)return;n.includes(e)||n.push(e)}}delete e.anyOf,e.type=n.length===1?n[0]:n}var pa=new Set([`type`,`properties`,`required`,`additionalProperties`]),ma=[`oneOf`,`anyOf`];function ha(e){let t=e.additionalProperties;return t===void 0||t===!1||typeof t!=`object`||!t?null:Object.keys(t).length?t:null}function ga(e){let t=[];for(let n of e){if(typeof n!=`object`||n.type!==`object`)return null;for(let e in n)if(!pa.has(e))return null;t.push(n)}let n={},r=new Set;for(let e of t){for(let r in e.properties){if(Object.prototype.hasOwnProperty.call(n,r))continue;let e=[];for(let n of t){let t=n.properties?.[r]??ha(n);t!=null&&(e.some(e=>JSON.stringify(e)===JSON.stringify(t))||e.push(t))}l(n,r,e.length===1?e[0]:ga(e)??{allOf:e})}for(let t of e.required??[])r.add(t)}let i={type:`object`,properties:n};if(r.size&&(i.required=[...r]),t.every(e=>e.additionalProperties===!1))i.additionalProperties=!1;else{let e=[];for(let n of t){let t=ha(n);t&&!e.some(e=>JSON.stringify(e)===JSON.stringify(t))&&e.push(t)}e.length===1?i.additionalProperties=e[0]:e.length>1&&(i.additionalProperties={allOf:e})}return i}function _a(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let t of pa)if(t in e)return;let n=t.filter(e=>ma.some(t=>Array.isArray(e[t]))),r=null;if(!n.length)r=ga(t);else{let e=n[0],i=ma.find(t=>Array.isArray(e[t]));if(Object.keys(e).length!==1)return;let a=t.filter(t=>t!==e),o=e[i].map(e=>ga([...a,e]));if(o.some(e=>!e))return;r={[i]:o}}r&&(delete e.allOf,sa(e,r))}function va(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=t=>{let n=e.seen.get(t);if(n.ref===null)return;let i=n.def??n.schema,a={...i},o=n.ref;if(n.ref=null,o){r(o);let n=e.seen.get(o),s=n.schema;if(s.$ref&&(e.target===`draft-07`||e.target===`draft-04`||e.target===`openapi-3.0`)?(i.allOf=i.allOf??[],i.allOf.push(s)):sa(i,s),sa(i,a),t._zod.parent===o)for(let e in i)e!==`$ref`&&e!==`allOf`&&(e in a||delete i[e]);if(s.$ref&&n.def)for(let e in i)e!==`$ref`&&e!==`allOf`&&e in n.def&&JSON.stringify(i[e])===JSON.stringify(n.def[e])&&delete i[e]}let s=t._zod.parent;if(s&&s!==o){r(s);let t=e.seen.get(s);if(t?.schema.$ref&&(i.$ref=t.schema.$ref,t.def))for(let e in i)e!==`$ref`&&e!==`allOf`&&e in t.def&&JSON.stringify(i[e])===JSON.stringify(t.def[e])&&delete i[e]}e.override({zodSchema:t,jsonSchema:i,path:n.path??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(let t of[...e.seen.entries()].reverse())r(t[0]);if(e.target!==`openapi-3.0`)for(let t of e.seen.entries())fa(t[1].def??t[1].schema);for(let t of e.deferred)t();if(e.intersections.length){let t=new Map;for(let n of e.seen.values())for(let e of[n.schema,n.def]){let n=e?.allOf;if(!Array.isArray(n))continue;let r=t.get(n);r?r.push(e):t.set(n,[e])}for(let n of e.intersections)for(let e of t.get(n)??[])_a(e)}}let i={};if(e.target===`draft-2020-12`?i.$schema=`https://json-schema.org/draft/2020-12/schema`:e.target===`draft-07`?i.$schema=`http://json-schema.org/draft-07/schema#`:e.target===`draft-04`?i.$schema=`http://json-schema.org/draft-04/schema#`:e.target,e.external?.uri){let n=e.external.registry.get(t)?.id;if(!n)throw Error("Schema is missing an `id` property");i.$id=e.external.uri(n)}sa(i,n.defId?n.schema:n.def??n.schema);let a=e.metadataRegistry.get(t)?.id;a!==void 0&&i.id===a&&delete i.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,l(o,e.defId,e.def))}e.external&&(e.sharedEmitDoneFor=e.external),e.external||Object.keys(o).length>0&&(e.target===`draft-2020-12`?i.$defs=o:i.definitions=o);try{let n=JSON.parse(JSON.stringify(i));return Object.defineProperty(n,"~standard",{value:{...t[`~standard`],jsonSchema:{input:xa(t,`input`,e.processors),output:xa(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function ya(e,t){let n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);let r=e._zod.def;if(r.type===`transform`)return!0;if(r.type===`array`)return ya(r.element,n);if(r.type===`set`)return ya(r.valueType,n);if(r.type===`lazy`)return ya(r.getter(),n);if(r.type===`promise`||r.type===`optional`||r.type===`nonoptional`||r.type===`nullable`||r.type===`readonly`||r.type==="default"||r.type===`prefault`||r.type===`catch`)return ya(r.innerType,n);if(r.type===`intersection`)return ya(r.left,n)||ya(r.right,n);if(r.type===`record`||r.type===`map`)return ya(r.keyType,n)||ya(r.valueType,n);if(r.type===`pipe`)return e._zod.traits.has(`$ZodCodec`)?!0:ya(r.in,n)||ya(r.out,n);if(r.type===`object`){for(let e in r.shape)if(ya(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(ya(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(ya(e,n))return!0;return!!(r.rest&&ya(r.rest,n))}return!1}var ba=(e,t={})=>n=>{let r=ca({...n,processors:t});return j(e,r),da(r,e),va(r,e)},xa=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=ca({...i??{},target:a,io:t,processors:n});return j(e,o),da(o,e),va(o,e)},Sa={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},Ca=(e,t,n,r)=>{let i=n;i.type=`string`;let{minimum:a,maximum:o,format:s,patterns:c,contentEncoding:l,laxFormat:u}=e._zod.bag;if(typeof a==`number`&&(i.minLength=a),typeof o==`number`&&(i.maxLength=o),s&&(i.format=Sa[s]??s,i.format===``&&delete i.format,(s===`time`||u)&&delete i.format),l&&(i.contentEncoding=l),c&&c.size>0){let e=[...c];e.length===1?i.pattern=e[0].source:e.length>1&&(i.allOf=[...e.map(e=>({...t.target===`draft-07`||t.target===`draft-04`||t.target===`openapi-3.0`?{type:`string`}:{},pattern:e.source}))])}},wa=(e,t,n,r)=>{let i=n,{minimum:a,maximum:o,format:s,multipleOf:c,exclusiveMaximum:l,exclusiveMinimum:u}=e._zod.bag;i.type=typeof s==`string`&&s.includes(`int`)?`integer`:`number`;let d=typeof u==`number`&&u>=(a??-1/0),f=typeof l==`number`&&l<=(o??1/0),p=t.target===`draft-04`||t.target===`openapi-3.0`;d?p?(i.minimum=u,i.exclusiveMinimum=!0):i.exclusiveMinimum=u:typeof a==`number`&&(i.minimum=a),f?p?(i.maximum=l,i.exclusiveMaximum=!0):i.exclusiveMaximum=l:typeof o==`number`&&(i.maximum=o),typeof c==`number`&&(Number.isFinite(c)&&c!==0?i.multipleOf=Math.abs(c):la(e,t,i,r,`A multipleOf divisor of ${c} cannot be represented in JSON Schema`))},Ta=(e,t,n,r)=>{n.type=`boolean`},Ea=(e,t,n,r)=>{la(e,t,n,r,`BigInt cannot be represented in JSON Schema`)},Da=(e,t,n,r)=>{la(e,t,n,r,`Symbols cannot be represented in JSON Schema`)},Oa=(e,t,n,r)=>{t.target===`openapi-3.0`?(n.type=`string`,n.nullable=!0,n.enum=[null]):n.type=`null`},ka=(e,t,n,r)=>{la(e,t,n,r,`Undefined cannot be represented in JSON Schema`)},Aa=(e,t,n,r)=>{la(e,t,n,r,`Void cannot be represented in JSON Schema`)},ja=(e,t,n,r)=>{n.not={}},Ma=(e,t,n,r)=>{},Na=(e,t,n,r)=>{},Pa=(e,t,n,r)=>{la(e,t,n,r,`Date cannot be represented in JSON Schema`)},Fa=(t,n,r,i)=>{let a=t._zod.def,o=e(a.entries);if(o.length===0){r.not={};return}o.every(e=>typeof e==`number`)&&(r.type=`number`),o.every(e=>typeof e==`string`)&&(r.type=`string`),r.enum=o},Ia=(e,t,n,r)=>{let i=e._zod.def;if(i.values.length===0){n.not={};return}let a=[];for(let o of i.values)if(o===void 0){if(la(e,t,n,r,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof o==`bigint`){if(la(e,t,n,r,`BigInt literals cannot be represented in JSON Schema`))return;a.push(Number(o))}else a.push(o);if(a.length!==0)if(a.length===1){let e=a[0];n.type=e===null?`null`:typeof e,t.target===`draft-04`||t.target===`openapi-3.0`?n.enum=[e]:n.const=e}else a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),a.every(e=>typeof e==`boolean`)&&(n.type=`boolean`),a.every(e=>e===null)&&(n.type=`null`),n.enum=a},La=(e,t,n,r)=>{la(e,t,n,r,`NaN cannot be represented in JSON Schema`)},Ra=(e,t,n,r)=>{let i=n,a=e._zod.pattern;if(!a)throw Error(`Pattern not found in template literal`);i.type=`string`,i.pattern=a.source},za=(e,t,n,r)=>{let i=n,a={type:`string`,format:`binary`,contentEncoding:`binary`},{minimum:o,maximum:s,mime:c}=e._zod.bag;o!==void 0&&(a.minLength=o),s!==void 0&&(a.maxLength=s),c?c.length===1?(a.contentMediaType=c[0],Object.assign(i,a)):(Object.assign(i,a),i.anyOf=c.map(e=>({contentMediaType:e}))):Object.assign(i,a)},Ba=(e,t,n,r)=>{n.type=`boolean`},Va=(e,t,n,r)=>{la(e,t,n,r,`Custom types cannot be represented in JSON Schema`)},Ha=(e,t,n,r)=>{la(e,t,n,r,`Function types cannot be represented in JSON Schema`)},Ua=(e,t,n,r)=>{la(e,t,n,r,`Transforms cannot be represented in JSON Schema`)},Wa=(e,t,n,r)=>{la(e,t,n,r,`Map cannot be represented in JSON Schema`)},Ga=(e,t,n,r)=>{la(e,t,n,r,`Set cannot be represented in JSON Schema`)},Ka=(e,t,n,r)=>{let i=n,a=e._zod.def,{minimum:o,maximum:s}=e._zod.bag;typeof o==`number`&&(i.minItems=o),typeof s==`number`&&(i.maxItems=s),i.type=`array`,i.items=j(a.element,t,{...r,path:[...r.path,`items`]})};function qa(e){let t=e._zod.def;return t.type===`pipe`&&t.in._zod.traits.has(`$ZodTransform`)?qa(t.out):t.type===`catch`?qa(t.innerType):e._zod.optin}var Ja=(e,t,n,r)=>{let i=n,a=e._zod.def,o=a.shape;if(Object.getOwnPropertySymbols(o).length&&la(e,t,i,r,`Symbol keys cannot be represented in JSON Schema`))return;i.type=`object`,i.properties={};for(let e in o)l(i.properties,e,j(o[e],t,{...r,path:[...r.path,`properties`,e]}));let s=new Set(Object.keys(o)),c=new Set([...s].filter(e=>{let n=a.shape[e];return t.io===`input`?qa(n)===void 0:n._zod.optout===void 0}));c.size>0&&(i.required=Array.from(c)),a.catchall?._zod.def.type===`never`?i.additionalProperties=!1:a.catchall?a.catchall&&(i.additionalProperties=j(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},Ya=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>j(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},Xa=(e,t,n,r)=>{let i=e._zod.def,a=j(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=j(i.right,t,{...r,path:[...r.path,`allOf`,1]}),s=e=>`allOf`in e&&Object.keys(e).length===1,c=[...s(a)?a.allOf:[a],...s(o)?o.allOf:[o]];n.allOf=c,t.intersections.push(c)},Za=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`array`;let o=t.target===`draft-2020-12`?`prefixItems`:`items`,s=t.target===`draft-2020-12`||t.target===`openapi-3.0`?`items`:`additionalItems`,c=a.items.map((e,n)=>j(e,t,{...r,path:[...r.path,o,n]})),l=a.rest?j(a.rest,t,{...r,path:[...r.path,s,...t.target===`openapi-3.0`?[a.items.length]:[]]}):null,u=a.items.length;for(;u>0;){let e=a.items[u-1];if(!(t.io===`input`?qa(e)!==void 0:e._zod.optout===`optional`))break;u--}let d=a.items.length,f=!a.rest;t.target===`draft-2020-12`?(i.prefixItems=c,f?i.items=!1:l&&(i.items=l),u>0&&(i.minItems=u),f&&(i.maxItems=d)):t.target===`openapi-3.0`?(i.items={anyOf:c},l&&i.items.anyOf.push(l),u>0&&(i.minItems=u),f&&(i.maxItems=d)):(i.items=c,f?i.additionalItems=!1:l&&(i.additionalItems=l),u>0&&(i.minItems=u),f&&(i.maxItems=d));let{minimum:p,maximum:m}=e._zod.bag;typeof p==`number`&&(i.minItems=p),typeof m==`number`&&(i.maxItems=m)};function Qa(e,t,n){if(t.$ref){if(n.has(t))return t;n.add(t);let r=e.get(t)?.def;if(!r)return t;let i=Qa(e,r,n);return i===r?t:i}for(let r of[`anyOf`,`oneOf`]){let i=t[r];if(!Array.isArray(i))continue;let a=i.map(t=>Qa(e,t,n));a.some((e,t)=>e!==i[t])&&(t={...t,[r]:a})}let r=Array.isArray(t.type)?t.type:[t.type],i=!r.includes(`string`)&&r.some(e=>e===`number`||e===`integer`),a=t.enum??(t.const===void 0?void 0:[t.const]);if(!i&&!a?.some(e=>typeof e==`number`))return t;let{minimum:o,maximum:s,exclusiveMinimum:c,exclusiveMaximum:l,multipleOf:u,format:d,id:f,...p}=t;return p.enum?p.enum=p.enum.map(e=>typeof e==`number`?String(e):e):typeof p.const==`number`&&(p.const=String(p.const)),i?(p.type=`string`,a||(p.pattern=(r.includes(`number`)?zt:Rt).source),p):p}var $a=new WeakMap;function eo(e){let t=new Map;for(let n of e.seen.values())n.def&&!t.has(n.schema)&&t.set(n.schema,n);let n=new Map;for(let r of $a.get(e)??[]){let i=e.seen.get(r),a=(i?.def??i?.schema)?.propertyNames;if(!a||a===!0||n.has(a))continue;let o=Qa(t,a,new Set);o!==a&&n.set(a,o)}if(n.size)for(let t of e.seen.values())for(let e of[t.schema,t.def]){let t=e&&n.get(e.propertyNames);t&&(e.propertyNames=t)}}var to=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`;let o=a.keyType,s=o._zod.bag?.patterns;if(a.mode===`loose`&&s&&s.size>0){let e=j(a.valueType,t,{...r,path:[...r.path,`patternProperties`,`*`]});i.patternProperties={};for(let t of s)l(i.patternProperties,t.source,e)}else{if(t.target===`draft-07`||t.target===`draft-2020-12`){i.propertyNames=j(a.keyType,t,{...r,path:[...r.path,`propertyNames`]});let n=$a.get(t);n||(n=[],$a.set(t,n),t.deferred.push(()=>eo(t))),n.push(e)}i.additionalProperties=j(a.valueType,t,{...r,path:[...r.path,`additionalProperties`]})}let c=o._zod.values,u=t.io===`input`&&qa(a.valueType)!==void 0;if(c&&!a.partial&&!u){let e=[...c].filter(e=>typeof e==`string`||typeof e==`number`);e.length>0&&(i.required=e.map(String))}},no=(e,t,n,r)=>{let i=e._zod.def,a=j(i.innerType,t,r),o=t.seen.get(e);t.target===`openapi-3.0`?(o.ref=i.innerType,n.nullable=!0):n.anyOf=[a,{type:`null`}]},ro=(e,t,n,r)=>{let i=e._zod.def;j(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},io=Symbol();function ao(e,t,n,r,i){let a=!1,o=JSON.stringify(e,(e,t)=>typeof t==`bigint`?(a=!0,null):t);return a?(la(t,n,r,i,`BigInt defaults cannot be represented in JSON Schema`),io):JSON.parse(o)}var oo=(e,t,n,r)=>{let i=e._zod.def;j(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o=ao(i.defaultValue,e,t,n,r);o!==io&&(n.default=o)},so=(e,t,n,r)=>{let i=e._zod.def;j(i.innerType,t,r);let a=t.seen.get(e);if(a.ref=i.innerType,t.io!==`input`)return;let o=ao(i.defaultValue,e,t,n,r);o!==io&&(n._prefault=o)},co=(e,t,n,r)=>{let i=e._zod.def;j(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{la(e,t,n,r,`Dynamic catch values are not supported in JSON Schema`);return}n.default=o},lo=(e,t,n,r)=>{let i=e._zod.def,a=i.in._zod.traits.has(`$ZodTransform`),o=t.io===`input`?a?i.out:i.in:i.out;j(o,t,r);let s=t.seen.get(e);s.ref=o},uo=(e,t,n,r)=>{let i=e._zod.def;j(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},fo=(e,t,n,r)=>{let i=e._zod.def;j(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},po=(e,t,n,r)=>{let i=e._zod.def;j(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},mo=(e,t,n,r)=>{let i=e._zod.innerType;j(i,t,r);let a=t.seen.get(e);a.ref=i},ho={string:Ca,number:wa,boolean:Ta,bigint:Ea,symbol:Da,null:Oa,undefined:ka,void:Aa,never:ja,any:Ma,unknown:Na,date:Pa,enum:Fa,literal:Ia,nan:La,template_literal:Ra,file:za,success:Ba,custom:Va,function:Ha,transform:Ua,map:Wa,set:Ga,array:Ka,object:Ja,union:Ya,intersection:Xa,tuple:Za,record:to,nullable:no,nonoptional:ro,default:oo,prefault:so,catch:co,pipe:lo,readonly:uo,promise:fo,optional:po,lazy:mo};function go(e,t){if(`_idmap`in e){let n=e,r=ca({...t,processors:ho}),i={};for(let e of n._idmap.entries()){let[t,n]=e;j(n,r)}let a={};r.external={registry:n,uri:t?.uri,defs:i};for(let e of n._idmap.entries()){let[t,n]=e;da(r,n),l(a,t,va(r,n))}return Object.keys(i).length>0&&(a.__shared={[r.target===`draft-2020-12`?`$defs`:`definitions`]:i}),{schemas:a}}let n=ca({...t,processors:ho});return j(e,n),da(n,e),va(n,e)}var _o=new WeakSet([Object.prototype,Error.prototype]);function vo(e,t,n){Object.defineProperty(e,t,{configurable:!0,enumerable:!1,get(){let e=n(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})}})}var yo=E(`ZodError`,(e,t)=>{Ge.init(e,t),e.name=`ZodError`;let r=Object.getPrototypeOf(e);_o.has(r)||(_o.add(r),vo(r,`format`,e=>t=>Ye(e,t)),vo(r,`flatten`,e=>t=>Je(e,t)),vo(r,`addIssue`,e=>t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,n,2)}),vo(r,`addIssues`,e=>t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,n,2)}),Object.defineProperty(r,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}}))},void 0,{Parent:Error}),bo=Ze(yo),xo=Qe(yo),So=$e(yo),Co=D(yo),wo=nt(yo),To=rt(yo),Eo=it(yo),Do=at(yo),Oo=ot(yo),ko=st(yo),Ao=ct(yo),jo=lt(yo);function Mo(){Ie.localeError||Le(Zr())}function No(){Ie.memoizer||Le({memoizer:Jr()})}var M=E(`ZodType`,(e,t)=>(Mo(),k.init(e,t),e.def=t,e.type=t.type,e),{check(...e){let t=this.def;return this.clone(u(t,{checks:[...t.checks??[],...e.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return v(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(Zs(e,t))},superRefine(e,t){return this.check(Qs(e,t))},overwrite(e){return this.check(Zi(e))},optional(){return G(this)},exactOptional(){return Ms(this)},nullable(){return Ps(this)},nullish(){return G(Ps(this))},nonoptional(e){return Bs(this,e)},array(){return R(this)},or(e){return V([this,e])},and(e){return ws(this,e)},transform(e){return Ws(this,ks(e))},default(e){return Is(this,e)},prefault(e){return Rs(this,e)},catch(e){return Hs(this,e)},pipe(e){return Ws(this,e)},readonly(){return qs(this)},describe(e){let t=this.clone();return ti.add(t,{description:e}),t},meta(...e){if(e.length===0)return ti.get(this);let t=this.clone();return ti.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e,...t){return t.length===0?e(this):e(this,...t)},get"~standard"(){return Se(this,`~standard`,{...dn(this),jsonSchema:{input:xa(this,`input`),output:xa(this,`output`)}})},set"~standard"(e){xe(this,`~standard`,e)},parse:function e(t,n){return bo(this,t,n,{callee:e})},parseAsync:async function e(t,n){return await xo(this,t,n,{callee:e})},safeParse(e,t){return So(this,e,t)},async safeParseAsync(e,t){return Co(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){xe(this,`spa`,e)},encode:function e(t,n){return wo(this,t,n,{callee:e})},decode:function e(t,n){return To(this,t,n,{callee:e})},encodeAsync:async function e(t,n){return await Eo(this,t,n,{callee:e})},decodeAsync:async function e(t,n){return await Do(this,t,n,{callee:e})},safeEncode(e,t){return Oo(this,e,t)},safeDecode(e,t){return ko(this,e,t)},async safeEncodeAsync(e,t){return Ao(this,e,t)},async safeDecodeAsync(e,t){return jo(this,e,t)},toJSONSchema(e){return ba(this,{})(e)},get description(){return ti.get(this)?.description},get _def(){return this._zod.def}}),Po=E(`_ZodString`,(e,t)=>{fn.init(e,t),M.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ca(e,t,n,r);let n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null},{regex(...e){return this.check(Gi(...e))},includes(...e){return this.check(Ji(...e))},startsWith(...e){return this.check(Yi(...e))},endsWith(...e){return this.check(Xi(...e))},min(...e){return this.check(Ui(...e))},max(...e){return this.check(Hi(...e))},length(...e){return this.check(Wi(...e))},nonempty(...e){return this.check(Ui(1,...e))},lowercase(e){return this.check(Ki(e))},uppercase(e){return this.check(qi(e))},trim(){return this.check($i())},normalize(...e){return this.check(Qi(...e))},toLowerCase(){return this.check(ea())},toUpperCase(){return this.check(ta())},slugify(){return this.check(na())}}),Fo=E(`ZodString`,(e,t)=>{fn.init(e,t),Po.init(e,t)},{email(e){return this.check(ri(Bo,e))},url(e){return this.check(li(Wo,e))},jwt(e){return this.check(wi(os,e))},emoji(e){return this.check(ui(Ko,e))},guid(e){return this.check(ii(Ho,e))},uuid(e){return this.check(ai(Uo,e))},uuidv4(e){return this.check(oi(Uo,e))},uuidv6(e){return this.check(si(Uo,e))},uuidv7(e){return this.check(ci(Uo,e))},nanoid(e){return this.check(di(qo,e))},cuid(e){return this.check(fi(Jo,e))},cuid2(e){return this.check(pi(Yo,e))},ulid(e){return this.check(mi(Xo,e))},base64(e){return this.check(xi(rs,e))},base64url(e){return this.check(Si(is,e))},xid(e){return this.check(hi(Zo,e))},ksuid(e){return this.check(gi(Qo,e))},ipv4(e){return this.check(_i($o,e))},ipv6(e){return this.check(vi(es,e))},cidrv4(e){return this.check(yi(ts,e))},cidrv6(e){return this.check(bi(ns,e))},e164(e){return this.check(Ci(as,e))},datetime(e){return this.check(Ti(Io,e))},date(e){return this.check(Ei(Lo,e))},time(e){return this.check(Di(Ro,e))},duration(e){return this.check(Oi(zo,e))}});function N(e){return ni(Fo,e)}var P=E(`ZodStringFormat`,(e,t)=>{A.init(e,t),Po.init(e,t)}),Io=E(`ZodISODateTime`,(e,t)=>{kn.init(e,t),P.init(e,t)}),Lo=E(`ZodISODate`,(e,t)=>{An.init(e,t),P.init(e,t)}),Ro=E(`ZodISOTime`,(e,t)=>{jn.init(e,t),P.init(e,t)}),zo=E(`ZodISODuration`,(e,t)=>{Mn.init(e,t),P.init(e,t)}),Bo=E(`ZodEmail`,(e,t)=>{hn.init(e,t),P.init(e,t)});function Vo(e){return ri(Bo,e)}var Ho=E(`ZodGUID`,(e,t)=>{pn.init(e,t),P.init(e,t)}),Uo=E(`ZodUUID`,(e,t)=>{mn.init(e,t),P.init(e,t)}),Wo=E(`ZodURL`,(e,t)=>{xn.init(e,t),P.init(e,t)});function Go(e){return li(Wo,e)}var Ko=E(`ZodEmoji`,(e,t)=>{Sn.init(e,t),P.init(e,t)}),qo=E(`ZodNanoID`,(e,t)=>{Cn.init(e,t),P.init(e,t)}),Jo=E(`ZodCUID`,(e,t)=>{wn.init(e,t),P.init(e,t)}),Yo=E(`ZodCUID2`,(e,t)=>{Tn.init(e,t),P.init(e,t)}),Xo=E(`ZodULID`,(e,t)=>{En.init(e,t),P.init(e,t)}),Zo=E(`ZodXID`,(e,t)=>{Dn.init(e,t),P.init(e,t)}),Qo=E(`ZodKSUID`,(e,t)=>{On.init(e,t),P.init(e,t)}),$o=E(`ZodIPv4`,(e,t)=>{Nn.init(e,t),P.init(e,t)}),es=E(`ZodIPv6`,(e,t)=>{In.init(e,t),P.init(e,t)}),ts=E(`ZodCIDRv4`,(e,t)=>{Ln.init(e,t),P.init(e,t)}),ns=E(`ZodCIDRv6`,(e,t)=>{zn.init(e,t),P.init(e,t)}),rs=E(`ZodBase64`,(e,t)=>{Vn.init(e,t),P.init(e,t)}),is=E(`ZodBase64URL`,(e,t)=>{Un.init(e,t),P.init(e,t)}),as=E(`ZodE164`,(e,t)=>{Wn.init(e,t),P.init(e,t)}),os=E(`ZodJWT`,(e,t)=>{Kn.init(e,t),P.init(e,t)}),ss=E(`ZodNumber`,(e,t)=>{qn.init(e,t),M.init(e,t),e._zod.processJSONSchema=(t,n,r)=>wa(e,t,n,r);let n=e._zod.bag;e.minValue=Math.max(n.minimum??-1/0,n.exclusiveMinimum??-1/0)??null,e.maxValue=Math.min(n.maximum??1/0,n.exclusiveMaximum??1/0)??null,e.isInt=(n.format??``).includes(`int`)||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null},{gt(e,t){return this.check(zi(e,t))},gte(e,t){return this.check(Bi(e,t))},min(e,t){return this.check(Bi(e,t))},lt(e,t){return this.check(Li(e,t))},lte(e,t){return this.check(Ri(e,t))},max(e,t){return this.check(Ri(e,t))},int(e){return this.check(ls(e))},safe(e){return this.check(ls(e))},positive(e){return this.check(zi(0,e))},nonnegative(e){return this.check(Bi(0,e))},negative(e){return this.check(Li(0,e))},nonpositive(e){return this.check(Ri(0,e))},multipleOf(e,t){return this.check(Vi(e,t))},step(e,t){return this.check(Vi(e,t))},finite(){return this}});function F(e){return ki(ss,e)}var cs=E(`ZodNumberFormat`,(e,t)=>{Jn.init(e,t),ss.init(e,t)});function ls(e){return ji(cs,e)}var us=E(`ZodBoolean`,(e,t)=>{Yn.init(e,t),M.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ta(e,t,n,r)});function I(e){return Mi(us,e)}var ds=E(`ZodNull`,(e,t)=>{Xn.init(e,t),M.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Oa(e,t,n,r)});function fs(e){return Ni(ds,e)}var ps=E(`ZodAny`,(e,t)=>{Zn.init(e,t),M.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function ms(){return Pi(ps)}var hs=E(`ZodUnknown`,(e,t)=>{Qn.init(e,t),M.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function L(){return Fi(hs)}var gs=E(`ZodNever`,(e,t)=>{$n.init(e,t),M.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ja(e,t,n,r)});function _s(e){return Ii(gs,e)}var vs=E(`ZodArray`,(e,t)=>{No(),tr.init(e,t),M.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ka(e,t,n,r),e.element=t.element},{min(e,t){return this.check(Ui(e,t))},nonempty(e){return this.check(Ui(1,e))},max(e,t){return this.check(Hi(e,t))},length(e,t){return this.check(Wi(e,t))},unwrap(){return this.element}});function R(e,t){return ra(vs,e,t)}var ys=E(`ZodObject`,(e,t)=>{No(),cr.init(e,t),M.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ja(e,t,n,r),De(e,`shape`,e=>e._zod.def.shape,!1)},{keyof(){return U(Object.keys(this._zod.def.shape))},catchall(e){return this.clone({...this._zod.def,catchall:e})},passthrough(){return this.clone({...this._zod.def,catchall:L()})},loose(){return this.clone({...this._zod.def,catchall:L()})},strict(){return this.clone({...this._zod.def,catchall:_s()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(e){return se(this,e)},safeExtend(e){return ce(this,e)},merge(e){return le(this,e)},pick(e){return ae(this,e)},omit(e){return oe(this,e)},partial(...e){return ue(As,this,e[0])},exactPartial(...e){return ue(js,this,e[0],`exactPartial`)},required(...e){return de(zs,this,e[0])}});function z(e,t){return new ys({type:`object`,shape:e??{},...y(t)})}function B(e,t){return new ys({type:`object`,shape:e,catchall:L(),...y(t)})}var bs=E(`ZodUnion`,(e,t)=>{ur.init(e,t),M.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ya(e,t,n,r),e.options=t.options});function V(e,t){return new bs({type:`union`,options:e,...y(t)})}var xs=E(`ZodDiscriminatedUnion`,(e,t)=>{bs.init(e,t),dr.init(e,t)});function Ss(e,t,n){return new xs({type:`union`,options:t,discriminator:e,...y(n)})}var Cs=E(`ZodIntersection`,(e,t)=>{fr.init(e,t),M.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Xa(e,t,n,r)});function ws(e,t){return new Cs({type:`intersection`,left:e,right:t})}var Ts=E(`ZodRecord`,(e,t)=>{No(),hr.init(e,t),M.init(e,t),e._zod.processJSONSchema=(t,n,r)=>to(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType});function H(e,t,n){return!t||!t._zod?new Ts({type:`record`,keyType:N(),valueType:e,...y(t)}):new Ts({type:`record`,keyType:e,valueType:t,...y(n)})}var Es=E(`ZodEnum`,(e,t)=>{gr.init(e,t),M.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Fa(e,t,n,r),e.enum=t.entries,e.options=Object.values(t.entries);let n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{let i={};for(let r of e)if(n.has(r))i[r]=t.entries[r];else throw Error(`Key ${r} not found in enum`);return new Es({...t,checks:[],...y(r),entries:i})},e.exclude=(e,r)=>{let i={...t.entries};for(let t of e)if(n.has(t))delete i[t];else throw Error(`Key ${t} not found in enum`);return new Es({...t,checks:[],...y(r),entries:i})}});function U(e,t){return new Es({type:`enum`,entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...y(t)})}var Ds=E(`ZodLiteral`,(e,t)=>{_r.init(e,t),M.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ia(e,t,n,r),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 W(e,t){return new Ds({type:`literal`,values:Array.isArray(e)?e:[e],...y(t)})}var Os=E(`ZodTransform`,(e,t)=>{No(),vr.init(e,t),M.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ua(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new Fe(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(S(r,n.value,t));else{let t=r;t.fatal&&(t.continue=!1),t.code??=`custom`,`input`in t||(t.input=n.value),t.inst??=e,n.issues.push(S(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n)):(n.value=i,n)}});function ks(e){return new Os({type:`transform`,transform:e})}var As=E(`ZodOptional`,(e,t)=>{br.init(e,t),M.init(e,t),e._zod.processJSONSchema=(t,n,r)=>po(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function G(e){return new As({type:`optional`,innerType:e})}var js=E(`ZodExactOptional`,(e,t)=>{xr.init(e,t),M.init(e,t),e._zod.processJSONSchema=(t,n,r)=>po(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Ms(e){return new js({type:`optional`,innerType:e})}var Ns=E(`ZodNullable`,(e,t)=>{Sr.init(e,t),M.init(e,t),e._zod.processJSONSchema=(t,n,r)=>no(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Ps(e){return new Ns({type:`nullable`,innerType:e})}var Fs=E(`ZodDefault`,(e,t)=>{Cr.init(e,t),M.init(e,t),e._zod.processJSONSchema=(t,n,r)=>oo(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Is(e,t){return new Fs({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():ee(t)}})}var Ls=E(`ZodPrefault`,(e,t)=>{Tr.init(e,t),M.init(e,t),e._zod.processJSONSchema=(t,n,r)=>so(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Rs(e,t){return new Ls({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():ee(t)}})}var zs=E(`ZodNonOptional`,(e,t)=>{Er.init(e,t),M.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ro(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Bs(e,t){return new zs({type:`nonoptional`,innerType:e,...y(t)})}var Vs=E(`ZodCatch`,(e,t)=>{kr.init(e,t),M.init(e,t),e._zod.processJSONSchema=(t,n,r)=>co(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function Hs(e,t){return new Vs({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:ke(t)})}var Us=E(`ZodPipe`,(e,t)=>{Ar.init(e,t),M.init(e,t),e._zod.processJSONSchema=(t,n,r)=>lo(e,t,n,r),e.in=t.in,e.out=t.out});function Ws(e,t){return new Us({type:`pipe`,in:e,out:t})}var Gs=E(`ZodPreprocess`,(e,t)=>{Us.init(e,t),Mr.init(e,t)}),Ks=E(`ZodReadonly`,(e,t)=>{Nr.init(e,t),M.init(e,t),e._zod.processJSONSchema=(t,n,r)=>uo(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function qs(e){return new Ks({type:`readonly`,innerType:e})}var Js=E(`ZodLazy`,(e,t)=>{Fr.init(e,t),M.init(e,t),e._zod.processJSONSchema=(t,n,r)=>mo(e,t,n,r),e.unwrap=()=>e._zod.def.getter()});function Ys(e){return new Js({type:`lazy`,getter:e})}var Xs=E(`ZodCustom`,(e,t)=>{Ir.init(e,t),M.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Va(e,t,n,r)});function Zs(e,t={}){return ia(Xs,e,t)}function Qs(e,t){return aa(e,t)}function $s(e,t){return new Gs({type:`pipe`,in:ks(e),out:t})}var ec={invalid_type:`invalid_type`,too_big:`too_big`,too_small:`too_small`,invalid_format:`invalid_format`,not_multiple_of:`not_multiple_of`,unrecognized_keys:`unrecognized_keys`,invalid_union:`invalid_union`,invalid_key:`invalid_key`,invalid_element:`invalid_element`,invalid_value:`invalid_value`,custom:`custom`},tc;tc||={};function nc(e){return Ti(Io,e)}function rc(e){return Ei(Lo,e)}function ic(e){return Ai(ss,e)}var ac=[`2025-11-25`,`2025-06-18`,`2025-03-26`,`2024-11-05`,`2024-10-07`],oc=`io.modelcontextprotocol/related-task`,sc=`io.modelcontextprotocol/protocolVersion`,cc=`io.modelcontextprotocol/clientInfo`,lc=`io.modelcontextprotocol/serverInfo`,uc=`io.modelcontextprotocol/clientCapabilities`,dc=`io.modelcontextprotocol/subscriptionId`,fc=`io.modelcontextprotocol/logLevel`,pc=Ys(()=>V([N(),F(),I(),fs(),H(N(),pc),R(pc)])),K=H(N(),pc),mc=R(pc),hc=V([N(),F().int()]),gc=N(),_c=z({ttl:F().optional()}),vc=z({taskId:N()}),yc=B({progressToken:hc.optional(),[oc]:vc.optional()}),bc=z({_meta:yc.optional()}),xc=bc.extend({task:_c.optional()}),q=z({method:N(),params:bc.loose().optional()}),Sc=z({_meta:yc.optional()}),Cc=z({method:N(),params:Sc.loose().optional()}),wc=B({get[lc](){return Rc.optional().catch(void 0)}}),J=B({_meta:wc.optional()}),Tc=V([N(),F().int()]),Ec=z({jsonrpc:W(`2.0`),id:Tc,...q.shape}).strict(),Dc=z({jsonrpc:W(`2.0`),...Cc.shape}).strict(),Oc=z({jsonrpc:W(`2.0`),id:Tc,result:J}).strict(),kc=z({jsonrpc:W(`2.0`),id:Tc.optional(),error:z({code:F().int(),message:N(),data:L().optional()})}).strict(),Ac=V([Ec,Dc,Oc,kc]),jc=V([Oc,kc]),Mc=J.strict(),Nc=Sc.extend({requestId:Tc.optional(),reason:N().optional()}),Pc=Cc.extend({method:W(`notifications/cancelled`),params:Nc}),Fc=z({src:N(),mimeType:N().optional(),sizes:R(N()).optional(),theme:U([`light`,`dark`]).optional()}),Ic=z({icons:R(Fc).optional()}),Lc=z({name:N(),title:N().optional()}),Rc=Lc.extend({...Lc.shape,...Ic.shape,version:N(),websiteUrl:N().optional(),description:N().optional()}),zc=$s(e=>e&&typeof e==`object`&&!Array.isArray(e)&&Object.keys(e).length===0?{form:{}}:e,ws(z({form:ws(z({applyDefaults:I().optional()}),K).optional(),url:K.optional()}),K.optional())),Bc=B({list:K.optional(),cancel:K.optional(),requests:B({sampling:B({createMessage:K.optional()}).optional(),elicitation:B({create:K.optional()}).optional()}).optional()}),Vc=B({list:K.optional(),cancel:K.optional(),requests:B({tools:B({call:K.optional()}).optional()}).optional()}),Hc=z({experimental:H(N(),K).optional(),sampling:z({context:K.optional(),tools:K.optional()}).optional(),elicitation:zc.optional(),roots:z({listChanged:I().optional()}).optional(),tasks:Bc.optional(),extensions:H(N(),K).optional()}),Uc=bc.extend({protocolVersion:N(),capabilities:Hc,clientInfo:Rc}),Wc=q.extend({method:W(`initialize`),params:Uc}),Gc=z({experimental:H(N(),K).optional(),logging:K.optional(),completions:K.optional(),prompts:z({listChanged:I().optional()}).optional(),resources:z({subscribe:I().optional(),listChanged:I().optional()}).optional(),tools:z({listChanged:I().optional()}).optional(),tasks:Vc.optional(),extensions:H(N(),K).optional()}),Kc=J.extend({protocolVersion:N(),capabilities:Gc,serverInfo:Rc,instructions:N().optional()}),qc=Cc.extend({method:W(`notifications/initialized`),params:Sc.optional()}),Jc=q.extend({method:W(`server/discover`),params:bc.optional()}),Yc=J.extend({supportedVersions:R(N()),capabilities:Gc,instructions:N().optional()}),Xc=q.extend({method:W(`ping`),params:bc.optional()}),Zc=z({progress:F(),total:G(F()),message:G(N())}),Qc=z({...Sc.shape,...Zc.shape,progressToken:hc}),$c=Cc.extend({method:W(`notifications/progress`),params:Qc}),el=bc.extend({cursor:gc.optional()}),tl=q.extend({params:el.optional()}),nl=J.extend({nextCursor:gc.optional()}),rl=z({uri:N(),mimeType:G(N()),_meta:H(N(),L()).optional()}),il=rl.extend({text:N()}),al=N().refine(e=>{try{return atob(e),!0}catch{return!1}},{message:`Invalid Base64 string`}),ol=rl.extend({blob:al}),sl=U([`user`,`assistant`]),cl=z({audience:R(sl).optional(),priority:F().min(0).max(1).optional(),lastModified:nc({offset:!0}).optional()}),ll=z({...Lc.shape,...Ic.shape,uri:N(),description:G(N()),mimeType:G(N()),size:G(F()),annotations:cl.optional(),_meta:G(B({}))}),ul=z({...Lc.shape,...Ic.shape,uriTemplate:N(),description:G(N()),mimeType:G(N()),annotations:cl.optional(),_meta:G(B({}))}),dl=tl.extend({method:W(`resources/list`)}),fl=nl.extend({resources:R(ll)}),pl=tl.extend({method:W(`resources/templates/list`)}),ml=nl.extend({resourceTemplates:R(ul)}),hl=bc.extend({uri:N()}),gl=hl,_l=q.extend({method:W(`resources/read`),params:gl}),vl=J.extend({contents:R(V([il,ol]))}),yl=Cc.extend({method:W(`notifications/resources/list_changed`),params:Sc.optional()}),bl=hl,xl=q.extend({method:W(`resources/subscribe`),params:bl}),Sl=hl,Cl=q.extend({method:W(`resources/unsubscribe`),params:Sl}),wl=z({toolsListChanged:I().optional(),promptsListChanged:I().optional(),resourcesListChanged:I().optional(),resourceSubscriptions:R(N()).optional()}),Tl=bc.extend({notifications:wl}),El=q.extend({method:W(`subscriptions/listen`),params:Tl}),Dl=Sc.extend({notifications:wl}),Ol=Cc.extend({method:W(`notifications/subscriptions/acknowledged`),params:Dl}),kl=wc.extend({[dc]:Tc}),Al=J.extend({_meta:kl}),jl=Sc.extend({uri:N()}),Ml=Cc.extend({method:W(`notifications/resources/updated`),params:jl}),Nl=z({name:N(),description:G(N()),required:G(I())}),Pl=z({...Lc.shape,...Ic.shape,description:G(N()),arguments:G(R(Nl)),_meta:G(B({}))}),Fl=tl.extend({method:W(`prompts/list`)}),Il=nl.extend({prompts:R(Pl)}),Ll=bc.extend({name:N(),arguments:H(N(),N()).optional()}),Rl=q.extend({method:W(`prompts/get`),params:Ll}),zl=z({type:W(`text`),text:N(),annotations:cl.optional(),_meta:H(N(),L()).optional()}),Bl=z({type:W(`image`),data:al,mimeType:N(),annotations:cl.optional(),_meta:H(N(),L()).optional()}),Vl=z({type:W(`audio`),data:al,mimeType:N(),annotations:cl.optional(),_meta:H(N(),L()).optional()}),Hl=z({type:W(`tool_use`),name:N(),id:N(),input:H(N(),L()),_meta:H(N(),L()).optional()}),Ul=z({type:W(`resource`),resource:V([il,ol]),annotations:cl.optional(),_meta:H(N(),L()).optional()}),Wl=ll.extend({type:W(`resource_link`)}),Gl=V([zl,Bl,Vl,Wl,Ul]),Kl=z({role:sl,content:Gl}),ql=J.extend({description:N().optional(),messages:R(Kl)}),Jl=Cc.extend({method:W(`notifications/prompts/list_changed`),params:Sc.optional()}),Yl=z({title:N().optional(),readOnlyHint:I().optional(),destructiveHint:I().optional(),idempotentHint:I().optional(),openWorldHint:I().optional()}),Xl=z({taskSupport:U([`required`,`optional`,`forbidden`]).optional()}),Zl=z({...Lc.shape,...Ic.shape,description:N().optional(),inputSchema:z({type:W(`object`),properties:H(N(),pc).optional(),required:R(N()).optional()}).catchall(L()),outputSchema:B({$schema:N().optional()}).optional(),annotations:Yl.optional(),execution:Xl.optional(),_meta:H(N(),L()).optional()}),Ql=tl.extend({method:W(`tools/list`)}),$l=nl.extend({tools:R(Zl)}),eu=J.extend({content:R(Gl).default([]),structuredContent:L().optional(),isError:I().optional()}),tu=eu.or(J.extend({toolResult:L()})),nu=xc.extend({name:N(),arguments:H(N(),L()).optional()}),ru=q.extend({method:W(`tools/call`),params:nu}),iu=Cc.extend({method:W(`notifications/tools/list_changed`),params:Sc.optional()}),au=z({autoRefresh:I().default(!0),debounceMs:F().int().nonnegative().default(300)}),ou=U([`debug`,`info`,`notice`,`warning`,`error`,`critical`,`alert`,`emergency`]),su=bc.extend({level:ou}),cu=q.extend({method:W(`logging/setLevel`),params:su}),lu=Sc.extend({level:ou,logger:N().optional(),data:L()}),uu=Cc.extend({method:W(`notifications/message`),params:lu}),du=z({name:N().optional()}),fu=z({hints:R(du).optional(),costPriority:F().min(0).max(1).optional(),speedPriority:F().min(0).max(1).optional(),intelligencePriority:F().min(0).max(1).optional()}),pu=z({mode:U([`auto`,`required`,`none`]).optional()}),mu=z({type:W(`tool_result`),toolUseId:N().describe(`The unique identifier for the corresponding tool call.`),content:R(Gl),structuredContent:L().optional(),isError:I().optional(),_meta:H(N(),L()).optional()}),hu=Ss(`type`,[zl,Bl,Vl]),gu=Ss(`type`,[zl,Bl,Vl,Hl,mu]),_u=z({role:sl,content:V([gu,R(gu)]),_meta:H(N(),L()).optional()}),vu=xc.extend({messages:R(_u),modelPreferences:fu.optional(),systemPrompt:N().optional(),includeContext:U([`none`,`thisServer`,`allServers`]).optional(),temperature:F().optional(),maxTokens:F().int(),stopSequences:R(N()).optional(),metadata:K.optional(),tools:R(Zl).optional(),toolChoice:pu.optional()}),yu=q.extend({method:W(`sampling/createMessage`),params:vu}),bu=J.extend({model:N(),stopReason:G(U([`endTurn`,`stopSequence`,`maxTokens`]).or(N())),role:sl,content:hu}),xu=J.extend({model:N(),stopReason:G(U([`endTurn`,`stopSequence`,`maxTokens`,`toolUse`]).or(N())),role:sl,content:V([gu,R(gu)])}),Su=z({type:W(`boolean`),title:N().optional(),description:N().optional(),default:I().optional()}),Cu=z({type:W(`string`),title:N().optional(),description:N().optional(),minLength:F().optional(),maxLength:F().optional(),format:U([`email`,`uri`,`date`,`date-time`]).optional(),default:N().optional()}),wu=z({type:U([`number`,`integer`]),title:N().optional(),description:N().optional(),minimum:F().optional(),maximum:F().optional(),default:F().optional()}),Tu=z({type:W(`string`),title:N().optional(),description:N().optional(),enum:R(N()),default:N().optional()}),Eu=z({type:W(`string`),title:N().optional(),description:N().optional(),oneOf:R(z({const:N(),title:N()})),default:N().optional()}),Du=z({type:W(`string`),title:N().optional(),description:N().optional(),enum:R(N()),enumNames:R(N()).optional(),default:N().optional()}),Ou=V([Tu,Eu]),ku=z({type:W(`array`),title:N().optional(),description:N().optional(),minItems:F().optional(),maxItems:F().optional(),items:z({type:W(`string`),enum:R(N())}),default:R(N()).optional()}),Au=z({type:W(`array`),title:N().optional(),description:N().optional(),minItems:F().optional(),maxItems:F().optional(),items:z({anyOf:R(z({const:N(),title:N()}))}),default:R(N()).optional()}),ju=V([ku,Au]),Mu=V([Du,Ou,ju]),Nu=V([Mu,Su,Cu,wu]),Pu=xc.extend({mode:W(`form`).optional(),message:N(),requestedSchema:z({type:W(`object`),properties:H(N(),Nu),required:R(N()).optional()}).catchall(L())}),Fu=xc.extend({mode:W(`url`),message:N(),elicitationId:N(),url:N().url()}),Iu=V([Pu,Fu]),Lu=q.extend({method:W(`elicitation/create`),params:Iu}),Ru=Sc.extend({elicitationId:N()}),zu=Cc.extend({method:W(`notifications/elicitation/complete`),params:Ru}),Bu=J.extend({action:U([`accept`,`decline`,`cancel`]),content:$s(e=>e===null?void 0:e,H(N(),V([N(),F(),I(),R(N())])).optional())}),Vu=z({type:W(`ref/resource`),uri:N()}),Hu=z({type:W(`ref/prompt`),name:N()}),Uu=bc.extend({ref:V([Hu,Vu]),argument:z({name:N(),value:N()}),context:z({arguments:H(N(),N()).optional()}).optional()}),Wu=q.extend({method:W(`completion/complete`),params:Uu}),Gu=J.extend({completion:B({values:R(N()).max(100),total:G(F().int()),hasMore:G(I())})}),Ku=z({uri:N().startsWith(`file://`),name:N().optional(),_meta:H(N(),L()).optional()}),qu=q.extend({method:W(`roots/list`),params:bc.optional()}),Ju=J.extend({roots:R(Ku)}),Yu=Cc.extend({method:W(`notifications/roots/list_changed`),params:Sc.optional()}),Xu=B({ttl:F().optional(),pollInterval:F().optional()}),Zu=U([`working`,`input_required`,`completed`,`failed`,`cancelled`]),Qu=z({taskId:N(),status:Zu,ttl:V([F(),fs()]),createdAt:N(),lastUpdatedAt:N(),pollInterval:G(F()),statusMessage:G(N())}),$u=J.extend({task:Qu}),ed=Sc.merge(Qu),td=Cc.extend({method:W(`notifications/tasks/status`),params:ed}),nd=q.extend({method:W(`tasks/get`),params:bc.extend({taskId:N()})}),rd=J.merge(Qu),id=q.extend({method:W(`tasks/result`),params:bc.extend({taskId:N()})}),ad=J.loose(),od=tl.extend({method:W(`tasks/list`)}),sd=nl.extend({tasks:R(Qu)}),cd=q.extend({method:W(`tasks/cancel`),params:bc.extend({taskId:N()})}),ld=J.merge(Qu),ud=V([Xc,Wc,Jc,Wu,cu,Rl,Fl,dl,pl,_l,xl,Cl,El,ru,Ql]),dd=V([Pc,$c,qc,Yu]),fd=V([Mc,bu,xu,Bu,Ju]),pd=V([Xc,yu,Lu,qu]),md=V([Pc,$c,uu,Ml,yl,iu,Jl,Ol,zu]),hd=V([Mc,Kc,Yc,Gu,ql,Il,fl,ml,vl,eu,$l,Al]),gd=Go().superRefine((e,t)=>{if(!URL.canParse(e))return t.addIssue({code:ec.custom,message:`URL must be parseable`,fatal:!0}),T}).refine(e=>{let t=new URL(e);return t.protocol!==`javascript:`&&t.protocol!==`data:`&&t.protocol!==`vbscript:`},{message:`URL cannot use javascript:, data:, or vbscript: scheme`}),_d=B({resource:N().url(),authorization_servers:R(gd).optional(),jwks_uri:N().url().optional(),scopes_supported:R(N()).optional(),bearer_methods_supported:R(N()).optional(),resource_signing_alg_values_supported:R(N()).optional(),resource_name:N().optional(),resource_documentation:N().optional(),resource_policy_uri:N().url().optional(),resource_tos_uri:N().url().optional(),tls_client_certificate_bound_access_tokens:I().optional(),authorization_details_types_supported:R(N()).optional(),dpop_signing_alg_values_supported:R(N()).optional(),dpop_bound_access_tokens_required:I().optional()}),vd=B({issuer:N(),authorization_endpoint:gd,token_endpoint:gd,registration_endpoint:gd.optional(),scopes_supported:R(N()).optional(),response_types_supported:R(N()),response_modes_supported:R(N()).optional(),grant_types_supported:R(N()).optional(),token_endpoint_auth_methods_supported:R(N()).optional(),token_endpoint_auth_signing_alg_values_supported:R(N()).optional(),service_documentation:gd.optional(),revocation_endpoint:gd.optional(),revocation_endpoint_auth_methods_supported:R(N()).optional(),revocation_endpoint_auth_signing_alg_values_supported:R(N()).optional(),introspection_endpoint:N().optional(),introspection_endpoint_auth_methods_supported:R(N()).optional(),introspection_endpoint_auth_signing_alg_values_supported:R(N()).optional(),code_challenge_methods_supported:R(N()).optional(),client_id_metadata_document_supported:I().optional(),authorization_response_iss_parameter_supported:I().optional().catch(void 0)}),yd=B({issuer:N(),authorization_endpoint:gd,token_endpoint:gd,userinfo_endpoint:gd.optional(),jwks_uri:gd,registration_endpoint:gd.optional(),scopes_supported:R(N()).optional(),response_types_supported:R(N()),response_modes_supported:R(N()).optional(),grant_types_supported:R(N()).optional(),acr_values_supported:R(N()).optional(),subject_types_supported:R(N()),id_token_signing_alg_values_supported:R(N()),id_token_encryption_alg_values_supported:R(N()).optional(),id_token_encryption_enc_values_supported:R(N()).optional(),userinfo_signing_alg_values_supported:R(N()).optional(),userinfo_encryption_alg_values_supported:R(N()).optional(),userinfo_encryption_enc_values_supported:R(N()).optional(),request_object_signing_alg_values_supported:R(N()).optional(),request_object_encryption_alg_values_supported:R(N()).optional(),request_object_encryption_enc_values_supported:R(N()).optional(),token_endpoint_auth_methods_supported:R(N()).optional(),token_endpoint_auth_signing_alg_values_supported:R(N()).optional(),display_values_supported:R(N()).optional(),claim_types_supported:R(N()).optional(),claims_supported:R(N()).optional(),service_documentation:N().optional(),claims_locales_supported:R(N()).optional(),ui_locales_supported:R(N()).optional(),claims_parameter_supported:I().optional(),request_parameter_supported:I().optional(),request_uri_parameter_supported:I().optional(),require_request_uri_registration:I().optional(),op_policy_uri:gd.optional(),op_tos_uri:gd.optional(),client_id_metadata_document_supported:I().optional(),authorization_response_iss_parameter_supported:I().optional().catch(void 0)}),bd=z({...yd.shape,...vd.pick({code_challenge_methods_supported:!0}).shape}),xd=z({access_token:N(),id_token:N().optional(),token_type:N(),expires_in:ic().optional(),scope:N().optional(),refresh_token:N().optional()}).strip(),Sd=z({issued_token_type:W(`urn:ietf:params:oauth:token-type:id-jag`),access_token:N(),token_type:N().optional(),expires_in:F().optional(),scope:N().optional()}).strip(),Cd=z({error:N(),error_description:N().optional(),error_uri:N().optional()}),wd=gd.optional().or(W(``).transform(()=>void 0)),Td=z({redirect_uris:R(gd),token_endpoint_auth_method:N().optional(),grant_types:R(N()).optional(),response_types:R(N()).optional(),application_type:N().optional(),client_name:N().optional(),client_uri:gd.optional(),logo_uri:wd,scope:N().optional(),contacts:R(N()).optional(),tos_uri:wd,policy_uri:N().optional(),jwks_uri:gd.optional(),jwks:ms().optional(),software_id:N().optional(),software_version:N().optional(),software_statement:N().optional()}).strip(),Ed=z({client_id:N(),client_secret:N().optional(),client_id_issued_at:F().optional(),client_secret_expires_at:F().optional()}).strip(),Dd=Td.merge(Ed),Od=z({error:N(),error_description:N().optional()}).strip(),kd=z({token:N(),token_type_hint:N().optional()}).strip();function Ad(e,t,n){return typeof e==`object`&&!!e&&Reflect.get(e,`channel`)===t&&Reflect.get(e,`type`)===`mcp`&&Reflect.get(e,`direction`)===n&&Reflect.has(e,`payload`)}function jd(e,t,n,r,i){e.postMessage({channel:n,type:`mcp`,direction:r,payload:i},t)}var Md=class{_started=!1;_closed=!1;_allowedOrigins;_channelId;_messageHandler;_clientOrigin;onclientorigin;onclose;onerror;onmessage;constructor(e){if(!e.allowedOrigins?.length)throw Error(`At least one allowed origin must be specified`);this._allowedOrigins=new Set(e.allowedOrigins),this._channelId=e.channelId??`mcp-iframe`}get clientOrigin(){return this._clientOrigin}async start(){if(this._closed)throw Error(`IframeChildTransport cannot be restarted after it closes`);if(this._started)throw Error(`Transport already started`);this._messageHandler=e=>{if(e.source!==window.parent||!this._allowedOrigins.has(`*`)&&!this._allowedOrigins.has(e.origin)||!Ad(e.data,this._channelId,`client-to-server`))return;this._clientOrigin!==e.origin&&(this._clientOrigin=e.origin,this.onclientorigin?.(e.origin));let{payload:t}=e.data;if(t===`mcp-check-ready`){this._broadcastServerReady();return}try{let e=Ac.parse(t);this.onmessage?.(e)}catch(e){this.onerror?.(Error(`Invalid message: ${e instanceof Error?e.message:String(e)}`))}},window.addEventListener(`message`,this._messageHandler),this._started=!0,this._broadcastServerReady()}async send(e,t){if(this._closed)throw Error(`Transport is closed`);if(!this._started)throw Error(`Transport not started`);if(!this._clientOrigin){console.debug(`[IframeChildTransport] No client connected, message not sent`);return}if(window.parent===window){console.debug(`[IframeChildTransport] Not running in an iframe, message not sent`);return}jd(window.parent,this._clientOrigin,this._channelId,`server-to-client`,e)}async close(){this._closed||(this._closed=!0,this._started=!1,this._messageHandler&&=(window.removeEventListener(`message`,this._messageHandler),void 0),this._clientOrigin&&window.parent!==window&&jd(window.parent,this._clientOrigin,this._channelId,`server-to-client`,`mcp-server-stopped`),this.onclose?.())}_broadcastServerReady(){window.parent!==window&&jd(window.parent,`*`,this._channelId,`server-to-client`,`mcp-server-ready`)}},Nd=class{_started=!1;_closed=!1;_allowedOrigins;_channelId;_messageHandler;onclose;onerror;onmessage;constructor(e){if(!e.allowedOrigins?.length)throw Error(`At least one allowed origin must be specified`);this._allowedOrigins=new Set(e.allowedOrigins),this._channelId=e.channelId??`mcp-default`}async start(){if(this._closed)throw Error(`TabServerTransport cannot be restarted after it closes`);if(this._started)throw Error(`Transport already started`);this._messageHandler=e=>{if(e.source!==window||!this._allowedOrigins.has(`*`)&&!this._allowedOrigins.has(e.origin)||!Ad(e.data,this._channelId,`client-to-server`))return;let{payload:t}=e.data;if(t===`mcp-check-ready`){jd(window,`*`,this._channelId,`server-to-client`,`mcp-server-ready`);return}try{let e=Ac.parse(t);this.onmessage?.(e)}catch(e){this.onerror?.(Error(`Invalid message: ${e instanceof Error?e.message:String(e)}`))}},window.addEventListener(`message`,this._messageHandler),this._started=!0,jd(window,`*`,this._channelId,`server-to-client`,`mcp-server-ready`)}async send(e,t){if(this._closed)throw Error(`Transport is closed`);if(!this._started)throw Error(`Transport not started`);jd(window,`*`,this._channelId,`server-to-client`,e)}async close(){this._closed||(this._closed=!0,this._messageHandler&&=(window.removeEventListener(`message`,this._messageHandler),void 0),this._started&&jd(window,`*`,this._channelId,`server-to-client`,`mcp-server-stopped`),this._started=!1,this.onclose?.())}},Pd={type:`object`,properties:{}},Fd=`Failed to parse input arguments`,Id=`Tool was executed but the invocation failed. For example, the script function threw an error`,Ld=[`draft-2020-12`,`draft-07`],Rd=/^[A-Za-z0-9_.-]{1,128}$/u;function zd(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Bd(e){if(typeof e==`symbol`)throw TypeError(`Symbol values cannot be converted to a DOMString`);return String(e)}function Vd(e){let t=Reflect.get(e,`name`),n=Reflect.get(e,`description`),r=Reflect.get(e,`title`);if(t===void 0)throw TypeError(`Tool "name" is required`);if(n===void 0)throw TypeError(`Tool "description" is required`);let i=Reflect.get(e,`annotations`),a=zd(i)?i:{},o=Reflect.get(e,`inputSchema`),s=Reflect.get(e,`outputSchema`),c=Reflect.get(e,`execute`);return{name:Bd(t),...r===void 0?{}:{title:Bd(r).toWellFormed()},description:Bd(n),...o===void 0?{}:{inputSchema:o},...s===void 0?{}:{outputSchema:s},execute:c,...i===void 0?{}:{annotations:{...a.title===void 0?{}:{title:Bd(a.title).toWellFormed()},readOnlyHint:!!a.readOnlyHint,...a.destructiveHint===void 0?{}:{destructiveHint:!!a.destructiveHint},...a.idempotentHint===void 0?{}:{idempotentHint:!!a.idempotentHint},...a.openWorldHint===void 0?{}:{openWorldHint:!!a.openWorldHint},untrustedContentHint:!!a.untrustedContentHint}}}}function Hd(e){if(!zd(e))return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function Ud(e,t=new WeakSet){if(e===null||typeof e==`string`||typeof e==`boolean`)return!0;if(typeof e==`number`)return Number.isFinite(e);if(typeof e!=`object`||t.has(e))return!1;t.add(e);try{return(Array.isArray(e)?e:Hd(e)?Object.values(e):null)?.every(e=>Ud(e,t))??!1}catch{return!1}finally{t.delete(e)}}function Wd(e){return Ud(e)?e:void 0}function Gd(e){return zd(e)&&Array.isArray(e.content)}function Kd(e){if(typeof e==`string`)return e;try{return JSON.stringify(e)??String(e)}catch{return String(e)}}function qd(e){if(Gd(e))return e;let t=Wd(e);return{content:[{type:`text`,text:Kd(e)}],...t===void 0?{}:{structuredContent:t},isError:!1}}function Jd(e){return new DOMException(e,`UnknownError`)}function Yd(e){return Jd(e instanceof Error?`${Id}: ${e.message}`:Id)}function Xd(e){return new DOMException(e,`InvalidStateError`)}function Zd(e){if(e.name===``)throw Xd(`Tool "name" must be a non-empty string`);if(typeof e.name!=`string`||!Rd.test(e.name))throw Xd(`Tool "name" must be 1–128 characters and contain only ASCII alphanumeric, underscore, hyphen, or period`);if(typeof e.description!=`string`||e.description.length===0)throw Xd(`Tool "description" must be a non-empty string`);if(typeof e.execute!=`function`)throw TypeError(`Tool "execute" must be a function`)}function Qd(e){return{readOnlyHint:e.readOnlyHint??!1,untrustedContentHint:e.untrustedContentHint??!1}}function $d(e){try{let t=JSON.parse(e);if(Array.isArray(t)||zd(t))return t}catch{}throw Jd(Fd)}function ef(e){if(typeof e==`object`&&e||typeof e==`function`)try{let t=JSON.stringify(e);if(t)return t}catch{}return String(e)||`Operation succeeded`}function tf(e,t,n=()=>t?.reason){return t?t.aborted?Promise.reject(n()):new Promise((r,i)=>{let a=()=>{o(),i(n())},o=()=>t.removeEventListener(`abort`,a);t.addEventListener(`abort`,a,{once:!0}),e.then(e=>{o(),r(e)},e=>{o(),i(e)})}):e}function nf(e){let t=e.origin===`null`?e:new URL(e.origin),n=t.protocol;if([`https:`,`wss:`,`file:`,`chrome-extension:`,`moz-extension:`].includes(n))return!0;let r=t.hostname.toLowerCase(),i=r.split(`.`),a=i.length===4&&i.every(e=>/^\d{1,3}$/u.test(e)&&Number(e)<=255)&&Number(i[0])===127;return r===`::1`||r===`[::1]`||r===`localhost`||r===`localhost.`||r.endsWith(`.localhost`)||r.endsWith(`.localhost.`)||a}function rf(e){for(let t of e??[]){let e;try{e=new URL(t)}catch{throw new DOMException(`Invalid or untrustworthy origin: ${String(t)}`,`SecurityError`)}if(!nf(e))throw new DOMException(`Invalid or untrustworthy origin: ${t}`,`SecurityError`)}}function af(e){if(of(),!e)return;let t=e.defaultView?.DOMException??DOMException,n=!1;try{let t=e.defaultView;n=!!(t&&t.document===e)}catch{}if(!n)throw new t(`The associated document is not fully active`,`InvalidStateError`);let r=Reflect.get(e,`permissionsPolicy`)??Reflect.get(e,`featurePolicy`);if(r&&typeof r==`object`){let e=Reflect.get(r,`features`),n=Reflect.get(r,`allowsFeature`);if(typeof e==`function`&&typeof n==`function`){let i=Reflect.apply(e,r,[]);if(Array.isArray(i)&&i.includes(`tools`)){if(Reflect.apply(n,r,[`tools`])===!0)return;throw new t(`WebMCP is disabled by Permissions Policy`,`NotAllowedError`)}}}let i=e.defaultView;if(!(!i||i.parent===i)){try{i.parent.document;return}catch{}throw new t(`WebMCP in cross-origin frames requires native Permissions Policy support`,`NotAllowedError`)}}function of(){if(globalThis.originAgentCluster===!1&&globalThis.location?.protocol!==`file:`)throw new DOMException(``,`SecurityError`)}function sf(e){try{if(new URL(String(e)).origin!==`null`)return}catch{}throw new DOMException(`Unsupported tool origin: ${String(e)}`,`NotSupportedError`)}function cf(e){if(!zd(e))return null;let t=e[`~standard`];return zd(t)?t:null}function lf(e){let t=cf(e);return!!(t&&t.version===1&&typeof t.validate==`function`)}function uf(e){let t=cf(e);return!t||t.version!==1||!zd(t.jsonSchema)?!1:typeof t.jsonSchema.input==`function`}function df(e,t){let n={...e};return Object.defineProperty(n,"~standard",{value:t[`~standard`]}),n}function ff(e){for(let t of Ld)try{let n=mf(e[`~standard`].jsonSchema.input({target:t})),r=JSON.parse(n);if(!zd(r))throw TypeError(`inputSchema must serialize to an object`);return r}catch{}throw Error(`Failed to convert Standard JSON Schema inputSchema to a JSON Schema object`)}function pf(e){if(e===void 0)return{inputSchema:Pd};if(uf(e)){let t=ff(e),n=mf(t);return{inputSchema:lf(e)?df(t,e):t,registeredInputSchema:n}}if(lf(e))throw Error(`Standard Schema inputSchema must provide ~standard.jsonSchema.input() for tool metadata`);if(e===null||typeof e!=`object`&&typeof e!=`function`)throw TypeError(`inputSchema must be an object`);let t=mf(e),n=JSON.parse(t),r=zd(n)?n:void 0;return!r||Object.keys(r).length===0?{inputSchema:Pd,registeredInputSchema:t}:{inputSchema:r.type===void 0?{type:`object`,...r}:r,registeredInputSchema:t}}function mf(e){if(e===null||typeof e!=`object`&&typeof e!=`function`)throw TypeError(`inputSchema must be an object`);let t=JSON.stringify(e);if(t===void 0)throw TypeError(`inputSchema must be JSON-serializable`);return t}var hf=new WeakSet,gf=new WeakMap,_f=new WeakMap;function vf(e){return e.isTrusted&&(hf.has(e)||e.eventPhase!==Event.NONE&&e.target instanceof HTMLFormElement&&_f.has(e.target))}function yf(e,t){if(!vf(e))throw new DOMException(`respondWith() is only available during an agent-invoked submit event`,`InvalidStateError`);if(!e.defaultPrevented)throw new DOMException(`respondWith() requires preventDefault() during an agent-invoked submit event`,`InvalidStateError`);if(e.eventPhase===Event.NONE)throw new DOMException(`respondWith() is only available while the submit event is being dispatched`,`InvalidStateError`);hf.add(e);let n=Promise.resolve(t);gf.set(e,n),e.target instanceof HTMLFormElement&&_f.get(e.target)?.respond(e)}var bf=new Set([`email`,`password`,`search`,`tel`,`text`,`url`]),xf=new Set([...bf,`date`,`datetime-local`,`month`,`number`,`time`,`week`]);function Sf(e){return e instanceof HTMLInputElement||e instanceof HTMLSelectElement||e instanceof HTMLTextAreaElement}function Cf(e){return Reflect.get(HTMLFormElement.prototype,`elements`,e)}function wf(e,t){return Reflect.apply(Element.prototype.getAttribute,e,[t])}function Tf(e,t){return Reflect.apply(Element.prototype.hasAttribute,e,[t])}function Ef(e){return Reflect.get(Node.prototype,`isConnected`,e)}function Df(e){return Reflect.get(Element.prototype,`shadowRoot`,e)}function Of(e){return Reflect.apply(HTMLFormElement.prototype.checkValidity,e,[])}function kf(e,t){Reflect.apply(HTMLFormElement.prototype.requestSubmit,e,t?[t]:[])}function Af(e){return[...Cf(e)].filter(e=>Sf(e)&&!e.matches(`:disabled`)&&!(`readOnly`in e&&e.readOnly&&(e instanceof HTMLTextAreaElement||xf.has(e.type))))}function jf(e){let t=new Map;for(let n of Af(e)){let e=n.name.trim(),r=t.get(e);r?r.push(n):t.set(e,[n])}return t}function Mf(e){return[...e.labels??[]].map(e=>{let t=e.cloneNode(!0);return t instanceof HTMLElement?(t.querySelectorAll(`button, input, meter, output, progress, select, textarea`).forEach(e=>e.remove()),t.textContent?.trim()??``):``}).filter(Boolean).join(`; `)}function Nf(e,t){for(let n=t[0]?.parentElement;n&&n!==e;n=n.parentElement)if(n instanceof HTMLFieldSetElement&&t.every(e=>n.contains(e)))return n}function Pf(e,t){if(t.length===1){let e=t[0];return e&&(e.getAttribute(`toolparamdescription`)||Mf(e)||e.getAttribute(`aria-description`))||void 0}return Nf(e,t)?.getAttribute(`toolparamdescription`)||void 0}function Ff(e,t,n,r){let i=Pf(t,n),a=i&&r?`${i} (${r})`:i||r;return a?{...e,description:a}:e}function If(e,t){let n=e.getAttribute(t);if(n===null||n.trim()===``)return;let r=Number(n);return Number.isFinite(r)?r:void 0}function Lf(e,t){let n=e/t;return Math.abs(n-Math.round(n))<2**-52*16}function Rf(e){let t=e.getAttribute(`pattern`);if(t!==null)try{return new RegExp(t,`v`),t}catch{return}}function zf(e,t=!0){let n={type:`number`},r=If(e,`min`),i=If(e,`max`);r!==void 0&&(n.minimum=r),i!==void 0&&(n.maximum=i);let a=e.getAttribute(`step`);if(a!==`any`){let t=a===null||a===``?1:Number(a),i=Number.isFinite(t)&&t>0?t:1,o=Number(e.getAttribute(`value`));Lf(r??(Number.isFinite(o)?o:0),i)&&(n.multipleOf=i)}let o=t?Rf(e):void 0;return o!==void 0&&(n.pattern=o),n}function Bf(e,t){let n=e.getAttribute(`step`),r=n===null||n===``?60:Number(n),i=Number.isFinite(r)&&r>0?r:60;return i<1?`${t}(:[0-5][0-9](\\.[0-9]{1,3})?)?$`:i<60?`${t}(:[0-5][0-9])?$`:`${t}$`}function Vf(e){return{anyOf:e.map(e=>({type:`string`,const:e.value,title:e.textContent??``})),enum:e.map(e=>e.value)}}function Hf(e){return{anyOf:e.map(e=>{let t=Mf(e);return{type:`string`,const:e.value,...t?{title:t}:{}}}),enum:e.map(e=>e.value)}}function Uf(e,t){let n=t[0];if(n){if(t.length>1)return t.every(e=>e instanceof HTMLInputElement)?t.every(e=>e.type===`checkbox`)?Ff({type:`array`,items:{type:`string`,...Hf(t)},uniqueItems:!0},e,t):t.every(e=>e.type===`radio`)?Ff({type:`string`,...Hf(t)},e,t):void 0:void 0;if(n instanceof HTMLTextAreaElement)return Ff({type:`string`},e,t);if(n instanceof HTMLSelectElement){let r=Vf([...n.options]);return Ff(n.multiple?{type:`array`,items:{type:`string`,...r},uniqueItems:!0}:{type:`string`,...r},e,t)}if(bf.has(n.type)){let r={type:`string`},i=Rf(n);return i!==void 0&&(r.pattern=i),Ff(r,e,t)}if(n.type===`hidden`)return n.getAttribute(`toolparamdescription`)?Ff({type:`string`},e,t):void 0;if(n.type===`number`)return Ff(zf(n),e,t);if(n.type===`range`){let r=zf(n,!1);return r.minimum??=0,r.maximum??=100,Ff(r,e,t)}if(n.type===`checkbox`)return Ff({type:`boolean`},e,t);if(n.type===`radio`)return Ff({type:`string`,...Hf([n])},e,t);if(n.type===`date`)return Ff({type:`string`,format:`date`},e,t,`Dates MUST be provided in 'YYYY-MM-DD' format.`);if(n.type===`month`)return Ff({type:`string`,format:`^[0-9]{4}-(0[1-9]|1[0-2])$`},e,t);if(n.type===`week`)return Ff({type:`string`,format:`^[0-9]{4}-W(0[1-9]|[1-4][0-9]|5[0-3])$`},e,t);if(n.type===`time`)return Ff({type:`string`,format:Bf(n,`^([01][0-9]|2[0-3]):[0-5][0-9]`)},e,t);if(n.type===`datetime-local`)return Ff({type:`string`,format:Bf(n,`^[0-9]{4}-(0[1-9]|1[0-2])-[0-9]{2}T([01][0-9]|2[0-3]):[0-5][0-9]`)},e,t);if(n.type===`color`)return Ff({type:`string`,format:`^#[0-9a-zA-Z]{6}$`},e,t)}}function Wf(e){let t={},n=[];for(let[r,i]of jf(e)){if(!r)continue;let a=Uf(e,i);a&&(Object.defineProperty(t,r,{configurable:!0,enumerable:!0,value:a,writable:!0}),i.some(e=>e.required)&&n.push(r))}return{type:`object`,properties:t,required:n}}function Gf(e){return{name:wf(e,`toolname`)??``,title:wf(e,`tooltitle`)??``,description:wf(e,`tooldescription`)??``,inputSchema:Wf(e),autosubmit:Tf(e,`toolautosubmit`)}}function Kf(e){if(typeof e==`string`||typeof e==`boolean`||typeof e==`number`&&Number.isFinite(e))return String(e)}function qf(e){if(typeof e==`boolean`)return e;if(typeof e==`number`&&Number.isInteger(e))return e!==0;if(typeof e==`string`){if(e===`1`||e.toLowerCase()===`true`)return!0;if(e===`0`||e.toLowerCase()===`false`)return!1}}function Jf(e,t){if(!Array.isArray(e))return!1;let n=new Set(t);for(let t of e){let e=Kf(t);if(e===void 0||!n.delete(e))return!1}return!0}function Yf(e,t){if(t===``)return e.type!==`number`&&e.type!==`range`;let n=e.ownerDocument.createElement(`input`);return n.type=e.type,n.value=t,n.value!==``}function Xf(e,t,n){let r=t[0];if(!r||!Uf(e,t))return!1;if(t.length>1){if(!t.every(e=>e instanceof HTMLInputElement))return!1;if(t.every(e=>e.type===`checkbox`))return Jf(n,new Set(t.map(e=>e.value)));if(t.every(e=>e.type===`radio`)){let e=Kf(n);return e!==void 0&&t.some(t=>t.value===e)}return!1}if(r instanceof HTMLSelectElement){let e=new Set([...r.options].map(e=>e.value));if(r.multiple)return Jf(n,e);let t=Kf(n);return t!==void 0&&e.has(t)}if(r instanceof HTMLTextAreaElement)return Kf(n)!==void 0;if(r.type===`checkbox`)return qf(n)!==void 0;if(r.type===`radio`){let e=Kf(n);return e!==void 0&&r.value===e}let i=Kf(n);return i!==void 0&&Yf(r,i)}function Zf(e){e.dispatchEvent(new Event(`input`,{bubbles:!0,composed:!0})),e.dispatchEvent(new Event(`change`,{bubbles:!0}))}function Qf(e,t){let n=e instanceof HTMLInputElement?HTMLInputElement.prototype:HTMLTextAreaElement.prototype;Object.getOwnPropertyDescriptor(n,`value`)?.set?.call(e,t)}function $f(e,t){Object.getOwnPropertyDescriptor(HTMLInputElement.prototype,`checked`)?.set?.call(e,t)}function ep(e,t){let n=e[0];if(!n)return;if(e.length>1&&e.every(e=>e instanceof HTMLInputElement)){if(e.every(e=>e.type===`checkbox`)&&Array.isArray(t)){let n=new Set(t.map(Kf));for(let t of e){let e=n.has(t.value);t.checked!==e&&($f(t,e),Zf(t))}return}let n=Kf(t),r=e.find(e=>e.value===n);r&&!r.checked&&($f(r,!0),Zf(r));return}if(n instanceof HTMLSelectElement){if(n.multiple&&Array.isArray(t)){let e=new Set(t.map(Kf)),r=!1;for(let t of n.options){let n=e.has(t.value);t.selected!==n&&(t.selected=n,r=!0)}r&&Zf(n);return}let e=Kf(t);e!==void 0&&n.value!==e&&(n.value=e,Zf(n));return}if(n instanceof HTMLInputElement&&n.type===`checkbox`){let e=qf(t);e!==void 0&&n.checked!==e&&($f(n,e),Zf(n));return}if(n instanceof HTMLInputElement&&n.type===`radio`){Kf(t)===n.value&&!n.checked&&($f(n,!0),Zf(n));return}let r=Kf(t);r!==void 0&&n.value!==r&&(Qf(n,r),Zf(n))}function tp(e,t){if(Array.isArray(t))throw TypeError(`Declarative tool input must be an object`);let n=jf(e);for(let[r,i]of Object.entries(t)){let t=n.get(r);if(!t||!Xf(e,t,i))throw TypeError(`Invalid value for declarative form parameter "${r}"`)}for(let[e,r]of Object.entries(t))ep(n.get(e)??[],r)}function np(e){return[...Cf(e)].find(e=>!e.matches(`:disabled`)&&(e instanceof HTMLButtonElement&&e.type===`submit`||e instanceof HTMLInputElement&&[`image`,`submit`].includes(e.type)))}function rp(e){let t=[...Cf(e)].filter(e=>Sf(e)&&e.willValidate&&!e.validity.valid).map(e=>`${e.name.trim()||`{unknown}`}: ${e.validationMessage}`).join(`. `);return new DOMException(`Form validation failed: ${t}`,`UnknownError`)}function ip(e){let t=new Event(`toolactivated`);return Object.defineProperty(t,"toolName",{enumerable:!0,value:e}),t}function ap(e,t,n,r){let{form:i}=e;return e.cancelPending?.(new DOMException(`Tool execution cancelled`,`UnknownError`)),new Promise((a,o)=>{let s=!1,c=()=>{Reflect.apply(EventTarget.prototype.removeEventListener,i,[`invalid`,f,!0]),_f.delete(i),e.cancelPending===u&&delete e.cancelPending},l=e=>{s||(s=!0,c(),e())},u=e=>l(()=>o(e)),d=e=>{e.then(e=>l(()=>a(e)),e=>l(()=>o(e)))},f=e=>{e.isTrusted&&queueMicrotask(()=>{Of(i)||u(rp(i))})};if(_f.set(i,{complete(e){queueMicrotask(()=>{let t=gf.get(e);t?d(t):e.defaultPrevented?u(new DOMException(`preventDefault() requires respondWith()`,`UnknownError`)):l(()=>a(void 0))})},direct(){l(()=>a(void 0))},respond(e){queueMicrotask(()=>{let t=gf.get(e);t&&d(t)})}}),e.cancelPending=u,Reflect.apply(EventTarget.prototype.addEventListener,i,[`invalid`,f,!0]),!n){r?.focus(),window.dispatchEvent(ip(t));return}try{kf(i,r),window.dispatchEvent(ip(t))}catch(e){u(e)}})}function op(e,t){let n=!0,r=new Map,i=new Map,a=new Map,o=e=>{if(!(e instanceof SubmitEvent)||!e.isTrusted||!(e.target instanceof HTMLFormElement))return;let t=_f.get(e.target);t&&(hf.add(e),t.complete(e))},s=e=>{if(!e.isTrusted||!(e.target instanceof HTMLFormElement))return;let t=e.target;queueMicrotask(()=>{e.defaultPrevented||r.get(t)?.cancelPending?.(new DOMException(`Tool execution cancelled by form reset`,`UnknownError`))})};function c(e){a.get(e)?.disconnect(),a.delete(e),e.removeEventListener(`reset`,s,!0),e.removeEventListener(`submit`,o,!0)}function l(e){if(a.has(e))return;let t=new MutationObserver(u);a.set(e,t),t.observe(e,{attributes:!0,characterData:!0,childList:!0,subtree:!0}),e.addEventListener(`reset`,s,!0),e.addEventListener(`submit`,o,!0)}function u(){l(e);for(let e of a.keys())e instanceof ShadowRoot&&!Reflect.get(Node.prototype,`isConnected`,e.host)&&c(e);let n=new Set,o=new Map,s=new Map;for(let e of a.keys())for(let t of e.querySelectorAll(`*`)){let e=Df(t);if(e&&l(e),!(t instanceof HTMLFormElement)||!Tf(t,`toolname`)||!Tf(t,`tooldescription`)||!Ef(t))continue;let r=t;n.add(r);let a=Gf(r),c=JSON.stringify(a),u=i.get(r);if(u===c)continue;let d=u!==void 0;i.delete(r);let f=s.get(a.name);if(f&&!d){i.set(r,c);continue}if(f){let e=o.get(f);e&&(i.set(f,e.fingerprint),o.delete(f))}s.set(a.name,r),o.set(r,{definition:a,fingerprint:c})}for(let e of i.keys())n.has(e)||i.delete(e);for(let[e,t]of r)o.get(e)?.fingerprint!==t.fingerprint&&(t.cancelPending?.(new DOMException(`Tool execution cancelled because its form changed`,`UnknownError`)),t.controller.abort(),r.delete(e));for(let[e,{definition:n,fingerprint:i}]of o){if(r.has(e))continue;let a=new AbortController,o={controller:a,fingerprint:i,form:e};r.set(e,o),t.registerTool({name:n.name,title:n.title,description:n.description,inputSchema:n.inputSchema,execute(t){let r=np(e);if(!n.autosubmit&&!r)throw new DOMException(`A declarative form without toolautosubmit requires a submit button`,`UnknownError`);return tp(e,t),ap(o,n.name,n.autosubmit,r)}},{signal:a.signal}).catch(e=>{a.abort(),e?.name!==`AbortError`&&console.error(`[webmcp] declarative form tool "${n.name}" was not registered:`,e)})}}let d=()=>{},f=e.defaultView?.Element.prototype,p=f?Object.getOwnPropertyDescriptor(f,`attachShadow`):void 0;if(f&&p?.configurable){let t=f.attachShadow,r=function(r){let i=t.call(this,r);return n&&i.mode===`open`&&Reflect.get(Node.prototype,`ownerDocument`,this)===e&&Reflect.get(Node.prototype,`isConnected`,this)&&l(i),i};Object.defineProperty(f,"attachShadow",{...p,value:r}),d=()=>{f.attachShadow===r&&Object.defineProperty(f,"attachShadow",p)}}let m=()=>{},h=e.defaultView?.HTMLFormElement.prototype,g=h?Object.getOwnPropertyDescriptor(h,`submit`):void 0;if(h&&g?.configurable){let e=h.submit,t=function(){e.call(this),n&&_f.get(this)?.direct()};Object.defineProperty(h,"submit",{...g,value:t}),m=()=>{h.submit===t&&Object.defineProperty(h,"submit",g)}}return u(),()=>{n=!1,m(),d();for(let e of a.keys())c(e);i.clear();for(let e of r.values())e.cancelPending?.(new DOMException(`Tool execution cancelled`,`UnknownError`)),e.controller.abort();r.clear()}}var sp=`__isWebMCPPolyfill`,cp=Symbol(`registeredInputSchema`),lp=Symbol(`registrationSignal`),up=Symbol(`registrationAbort`),dp=[],fp=null,pp=null;function mp(){return typeof globalThis.origin==`string`?globalThis.origin:globalThis.location?.origin??``}function hp(e,t,n){let r=Object.getOwnPropertyDescriptor(e,t);try{Object.defineProperty(e,t,n)}catch(e){throw Dp(),e}dp.push({target:e,key:t,previous:r})}var gp=class extends EventTarget{#e=new Map;#t=null;#n=null;#r=e=>{this.#n?.call(this,e)};#i;#a;constructor(e){super(),this.#a=e,this.#i=e?.defaultView?.DOMException??DOMException,Object.defineProperty(this,sp,{value:!0,enumerable:!1,writable:!1,configurable:!1})}get ontoolchange(){return this.#n}set ontoolchange(e){let t=typeof e==`function`?e:null;if(t===null){this.#n=null,super.removeEventListener(`toolchange`,this.#r);return}this.#n===null&&super.addEventListener(`toolchange`,this.#r),this.#n=t}async registerTool(e,t={}){af(this.#a);let n=t?.signal,r=yp(e,this.#e);if(n?.throwIfAborted(),rf(t?.exposedTo),n?.throwIfAborted(),t?.exposedTo?.length)throw new this.#i(`Cross-document tool exposure requires native WebMCP`,`NotSupportedError`);if(this.#e.set(r.name,r),n){let e=()=>{this.#o(r.name,r)&&this.#c()};r[lp]=n,r[up]=e,n.addEventListener(`abort`,e,{once:!0})}if(await this.#c(),n?.aborted)throw n.reason}async getTools(e={}){if(af(this.#a),rf(e?.fromOrigins),e?.fromOrigins?.length)throw new this.#i(`Cross-document tool discovery requires native WebMCP`,`NotSupportedError`);let t=[...this.#e.values()].map(e=>{let t=e[cp],n=t===void 0?void 0:JSON.parse(t);return{name:e.name,title:e.title??``,description:e.description,...zd(n)?{inputSchema:n}:{},origin:mp(),window:globalThis.window,...e.annotations?{annotations:Qd(e.annotations)}:{}}}).sort((e,t)=>e.name<t.name?-1:+(e.name>t.name));return await new Promise(e=>setTimeout(e,0)),t}async executeTool(e,t,n={}){if(af(this.#a),typeof e!=`object`||!e)throw TypeError(`RegisteredTool must be an object`);for(let t of[`name`,`description`,`window`,`origin`])if(!(t in e))throw TypeError(`RegisteredTool.${t} is required`);if(sf(e.origin),e.window!==globalThis.window||e.origin!==mp())throw Jd(`Tool not found: ${e.name}`);return this.#s(e.name,t,n)}static getTestingShim(e){return e.#t??=new vp(e),e.#t}static getToolInfos(e){return[...e.#e.values()].map(e=>({name:e.name,description:e.description,...e[cp]===void 0?{}:{inputSchema:e[cp]}}))}static executeToolForTesting(e,t,n,r){return af(e.#a),e.#s(t,n,r)}static dispose(e){for(let t of e.#e.keys())e.#o(t);e.ontoolchange=null,e.#t?.dispose()}#o(e,t){let n=this.#e.get(e);if(!n||t&&n!==t)return!1;let r=n[lp],i=n[up];return r&&i&&r.removeEventListener(`abort`,i),this.#e.delete(e)}async#s(e,t,n){n?.signal?.throwIfAborted();let r=this.#e.get(e);if(!r)throw Jd(`Tool not found: ${e}`);let i=$d(t);if(n?.signal?.throwIfAborted(),r[lp]?.aborted)throw Jd(`Tool unregistered`);let a;try{let e=r[lp];a=await tf(tf(Promise.resolve(r.execute(i)),e,()=>Jd(`Tool unregistered`)),n?.signal)}catch(e){throw n?.signal?.aborted&&e===n.signal.reason||r[lp]?.aborted?e:Yd(e)}return ef(a)}async#c(){await new Promise(e=>setTimeout(e,0)),this.dispatchEvent(new Event(`toolchange`)),this.#t?.dispatchToolChange()}},_p=function(){throw TypeError(`Illegal constructor`)};Object.defineProperty(_p,"name",{value:`ModelContext`}),Object.defineProperty(_p,"prototype",{value:gp.prototype,writable:!1}),Object.setPrototypeOf(_p,EventTarget),Object.defineProperty(gp.prototype,"constructor",{configurable:!0,writable:!0,value:_p}),Object.defineProperty(gp.prototype,Symbol.toStringTag,{configurable:!0,value:`ModelContext`});for(let e of[`registerTool`,`getTools`,`executeTool`,`ontoolchange`]){let t=Object.getOwnPropertyDescriptor(gp.prototype,e);t&&Object.defineProperty(gp.prototype,e,{...t,enumerable:!0})}var vp=class extends EventTarget{_ontoolchange=null;ontoolchangeListener=e=>{this._ontoolchange?.call(this,e)};#e;constructor(e){super(),this.#e=e}listTools(){return gp.getToolInfos(this.#e)}executeTool(e,t,n){return gp.executeToolForTesting(this.#e,e,t,n)}get ontoolchange(){return this._ontoolchange}set ontoolchange(e){let t=typeof e==`function`?e:null;if(t===null){this._ontoolchange=null,super.removeEventListener(`toolchange`,this.ontoolchangeListener);return}this._ontoolchange===null&&super.addEventListener(`toolchange`,this.ontoolchangeListener),this._ontoolchange=t}dispatchToolChange(){this.dispatchEvent(new Event(`toolchange`))}dispose(){this.ontoolchange=null}};function yp(e,t){if(!e||typeof e!=`object`)throw TypeError(`registerTool(tool) requires a tool object`);let n=Vd(e);if(Zd(n),t.has(n.name))throw Xd(`Tool already registered: ${n.name}`);let r=n.inputSchema===void 0?void 0:mf(n.inputSchema);return{name:n.name,...n.title===void 0?{}:{title:n.title},description:n.description,...n.inputSchema===void 0?{}:{inputSchema:n.inputSchema},...n.annotations===void 0?{}:{annotations:n.annotations},execute:e=>Reflect.apply(n.execute,void 0,[e]),...r===void 0?{}:{[cp]:r}}}var bp=!1,xp=new WeakMap,{modelContext:Sp}={modelContext(){if(!(this instanceof Document))throw TypeError(`Illegal invocation`);return xp.get(this)}};Object.defineProperty(Sp,"name",{value:`get modelContext`});function Cp(e,t){xp.set(e,t),!Object.hasOwn(Document.prototype,`modelContext`)&&hp(Document.prototype,`modelContext`,{configurable:!0,enumerable:!0,get:Sp})}function wp(e,t){hp(e,`modelContext`,{configurable:!0,enumerable:!0,get(){return bp||(bp=!0,console.warn(`[WebMCPPolyfill] navigator.modelContext is deprecated. The May 27, 2026 WebMCP draft moved the modelContext getter from Navigator to Document — use document.modelContext instead. See https://github.com/webmachinelearning/webmcp/pull/184.`)),t}})}function Tp(){let e=SubmitEvent.prototype;`agentInvoked`in e||hp(e,`agentInvoked`,{configurable:!0,enumerable:!0,get(){return vf(this)}}),`respondWith`in e||hp(e,`respondWith`,{configurable:!0,enumerable:!0,writable:!0,value(e){yf(this,e)}})}function Ep(e){if(globalThis.isSecureContext===!1)return;let t=typeof navigator>`u`?null:navigator,n=typeof document>`u`?null:document;if(!t||!n||typeof window>`u`||n.modelContext)return;let r=t.modelContext;if(dp.length>0&&Dp(),r){Cp(n,r);return}let i=Object.getOwnPropertyDescriptor(window,`ModelContext`);if(i&&!i.configurable){if(!Object.is(Reflect.get(window,`ModelContext`),_p))throw TypeError(`Cannot install ModelContext over a non-configurable global`)}else hp(window,`ModelContext`,{configurable:!0,enumerable:!1,writable:!0,value:_p});let a=new gp(n);fp=a,Cp(n,a),bp=!1,wp(t,a),Tp(),e?.installTestingShim&&!t.modelContextTesting&&hp(t,`modelContextTesting`,{configurable:!0,enumerable:!0,writable:!1,value:gp.getTestingShim(a)}),pp=op(n,a)}function Dp(){pp?.(),pp=null,fp&&gp.dispose(fp),fp=null;for(let{target:e,key:t,previous:n}of[...dp].reverse())n?Object.defineProperty(e,t,n):Reflect.deleteProperty(e,t);dp.length=0,bp=!1}var Op=Object.defineProperty,kp=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Ap=(e,t)=>{let n={};for(var r in e)Op(n,r,{get:e[r],enumerable:!0});return t&&Op(n,Symbol.toStringTag,{value:`Module`}),n},jp=new Set([`https://json-schema.org/draft/2020-12/schema`,`http://json-schema.org/draft/2020-12/schema`]),Mp=new Set([`https://json-schema.org/draft/2019-09/schema`,`http://json-schema.org/draft/2019-09/schema`]),Np=new Set([`https://json-schema.org/draft-07/schema`,`http://json-schema.org/draft-07/schema`]),Pp=new Set([`https://json-schema.org/draft-06/schema`,`http://json-schema.org/draft-06/schema`]);function Fp(e){return typeof e==`string`&&Mp.has(e.replace(/#$/,``))}function Ip(e,t){if(!(`$schema`in e)||typeof e.$schema!=`string`)return`2020-12`;let n=e.$schema.replace(/#$/,``);if(jp.has(n))return`2020-12`;if(Mp.has(n))return`2019-09`;if(Np.has(n)||Pp.has(n))return`draft-7`;throw Error(`JSON Schema declares an unsupported dialect ("$schema": "${e.$schema.slice(0,200)}"). The default validator supports JSON Schema 2020-12, 2019-09, draft-07, and draft-06; ${t}`)}var Lp=Symbol.for(`mcp.sdk.errorBrands`);function Rp(e,t){let n=new Set,r=t;for(;typeof r==`function`;){let e=r.mcpBrand;Object.prototype.hasOwnProperty.call(r,`mcpBrand`)&&typeof e==`string`&&n.add(e),r=Object.getPrototypeOf(r)}n.size!==0&&Object.defineProperty(e,Lp,{value:n,enumerable:!1,configurable:!0})}function zp(e,t){try{if(typeof t==`object`&&t&&Object.prototype.hasOwnProperty.call(e,`mcpBrand`)&&typeof e.mcpBrand==`string`&&Object.prototype.hasOwnProperty.call(t,Lp)){let n=t[Lp];if(n&&typeof n.has==`function`&&n.has(e.mcpBrand))return!0}}catch{}return Function.prototype[Symbol.hasInstance].call(e,t)}(class e extends Error{static{Object.defineProperty(this,"mcpBrand",{value:`mcp.OAuthError`})}static[Symbol.hasInstance](e){return zp(this,e)}static isInstance(e){if(typeof this!=`function`)throw TypeError("isInstance must be called on the class (e.g. `SdkError.isInstance(value)`); for callbacks use `v => SdkError.isInstance(v)`");return zp(this,e)}constructor(e,t,n){super(t),this.code=e,this.errorUri=n,this.name=`OAuthError`,Rp(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)}});var Y=function(e){return e.NotConnected=`NOT_CONNECTED`,e.AlreadyConnected=`ALREADY_CONNECTED`,e.NotInitialized=`NOT_INITIALIZED`,e.CapabilityNotSupported=`CAPABILITY_NOT_SUPPORTED`,e.RequestTimeout=`REQUEST_TIMEOUT`,e.ConnectionClosed=`CONNECTION_CLOSED`,e.SendFailed=`SEND_FAILED`,e.InvalidResult=`INVALID_RESULT`,e.UnsupportedResultType=`UNSUPPORTED_RESULT_TYPE`,e.InputRequiredRoundsExceeded=`INPUT_REQUIRED_ROUNDS_EXCEEDED`,e.ListPaginationExceeded=`LIST_PAGINATION_EXCEEDED`,e.MethodNotSupportedByProtocolVersion=`METHOD_NOT_SUPPORTED_BY_PROTOCOL_VERSION`,e.EraNegotiationFailed=`ERA_NEGOTIATION_FAILED`,e.ClientHttpNotImplemented=`CLIENT_HTTP_NOT_IMPLEMENTED`,e.ClientHttpAuthentication=`CLIENT_HTTP_AUTHENTICATION`,e.ClientHttpForbidden=`CLIENT_HTTP_FORBIDDEN`,e.ClientHttpUnexpectedContent=`CLIENT_HTTP_UNEXPECTED_CONTENT`,e.ClientHttpFailedToOpenStream=`CLIENT_HTTP_FAILED_TO_OPEN_STREAM`,e.ClientHttpFailedToTerminateSession=`CLIENT_HTTP_FAILED_TO_TERMINATE_SESSION`,e}({}),X=class extends Error{static{Object.defineProperty(this,"mcpBrand",{value:`mcp.SdkError`})}static[Symbol.hasInstance](e){return zp(this,e)}static isInstance(e){if(typeof this!=`function`)throw TypeError("isInstance must be called on the class (e.g. `SdkError.isInstance(value)`); for callbacks use `v => SdkError.isInstance(v)`");return zp(this,e)}constructor(e,t,n){super(t),this.code=e,this.data=n,this.name=`SdkError`,Rp(this,new.target)}};(class extends X{static{Object.defineProperty(this,"mcpBrand",{value:`mcp.SdkHttpError`})}constructor(e,t,n){super(e,t,n),this.name=`SdkHttpError`}get status(){return this.data.status}get statusText(){return this.data.statusText}});function Bp(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Vp(e,t,n){return e===`elicitation`&&t===`form`&&n.form===void 0&&n.url===void 0}function Hp(e){switch(e.method){case`elicitation/create`:return e.params?.mode===`url`?{elicitation:{url:{}}}:{elicitation:{form:{}}};case`sampling/createMessage`:{let t=e.params;return t!==void 0&&(t.tools!==void 0||t.toolChoice!==void 0)?{sampling:{tools:{}}}:{sampling:{}}}case`roots/list`:return{roots:{}};default:return}}function Up(e,t){let n={};for(let[r,i]of Object.entries(e)){if(i===void 0)continue;let e=t===void 0?void 0:t[r];if(e===void 0){n[r]=i;continue}if(Bp(i)&&Bp(e)){let t={};for(let[n,a]of Object.entries(i))a!==void 0&&e[n]===void 0&&!Vp(r,n,e)&&(t[n]=a);Object.keys(t).length>0&&(n[r]=t)}}return Object.keys(n).length>0?n:void 0}var Wp=`2026-07-28`;function Gp(e){return e>=Wp}function Kp(e){return e.filter(e=>!Gp(e))}function qp(e){return e.filter(e=>Gp(e))}function Jp(e){let t=e.structuredContent;return t===void 0||!(typeof t!=`object`||!t||Array.isArray(t))||(e.content?.some(e=>e.type===`text`)??!1)?e:{...e,content:[...e.content??[],{type:`text`,text:JSON.stringify(t)}]}}var Yp=[`task`,`inputRequests`,`requestState`];function Xp(e){return typeof e!=`object`||!e||Array.isArray(e)||e.content!==void 0||Yp.some(t=>t in e)?e:{...e,content:[]}}function Zp(){let e=Ys(()=>V([N(),F(),I(),fs(),H(N(),e),R(e)])),t=H(N(),e),n=V([N(),F().int()]),r=N(),i=z({ttl:F().optional()}),a=z({taskId:N()}),o=B({progressToken:n.optional(),"io.modelcontextprotocol/related-task":a.optional()}),s=z({_meta:o.optional()}),c=s.extend({task:i.optional()}),l=z({method:N(),params:s.loose().optional()}),u=z({_meta:o.optional()}),d=z({method:N(),params:u.loose().optional()}),f=B({_meta:o.optional()}),p=V([N(),F().int()]),m=f.strict(),h=u.extend({requestId:p.optional(),reason:N().optional()}),g=d.extend({method:W(`notifications/cancelled`),params:h}),ee=z({src:N(),mimeType:N().optional(),sizes:R(N()).optional(),theme:U([`light`,`dark`]).optional()}),te=z({icons:R(ee).optional()}),_=z({name:N(),title:N().optional()}),v=_.extend({..._.shape,...te.shape,version:N(),websiteUrl:N().optional(),description:N().optional()}),y=$s(e=>e&&typeof e==`object`&&!Array.isArray(e)&&Object.keys(e).length===0?{form:{}}:e,ws(z({form:ws(z({applyDefaults:I().optional()}),t).optional(),url:t.optional()}),t.optional())),ne=B({list:t.optional(),cancel:t.optional(),requests:B({sampling:B({createMessage:t.optional()}).optional(),elicitation:B({create:t.optional()}).optional()}).optional()}),re=B({list:t.optional(),cancel:t.optional(),requests:B({tools:B({call:t.optional()}).optional()}).optional()}),ie=z({experimental:H(N(),t).optional(),sampling:z({context:t.optional(),tools:t.optional()}).optional(),elicitation:y.optional(),roots:z({listChanged:I().optional()}).optional(),tasks:ne.optional(),extensions:H(N(),t).optional()}),ae=s.extend({protocolVersion:N(),capabilities:ie,clientInfo:v}),oe=l.extend({method:W(`initialize`),params:ae}),se=z({experimental:H(N(),t).optional(),logging:t.optional(),completions:t.optional(),prompts:z({listChanged:I().optional()}).optional(),resources:z({subscribe:I().optional(),listChanged:I().optional()}).optional(),tools:z({listChanged:I().optional()}).optional(),tasks:re.optional(),extensions:H(N(),t).optional()}),ce=f.extend({protocolVersion:N(),capabilities:se,serverInfo:v,instructions:N().optional()}),le=d.extend({method:W(`notifications/initialized`),params:u.optional()}),ue=l.extend({method:W(`ping`),params:s.optional()}),de=z({progress:F(),total:G(F()),message:G(N())}),fe=z({...u.shape,...de.shape,progressToken:n}),pe=d.extend({method:W(`notifications/progress`),params:fe}),me=s.extend({cursor:r.optional()}),he=l.extend({params:me.optional()}),ge=f.extend({nextCursor:r.optional()}),b=z({uri:N(),mimeType:G(N()),_meta:H(N(),L()).optional()}),_e=b.extend({text:N()}),ve=N().refine(e=>{try{return atob(e),!0}catch{return!1}},{message:`Invalid Base64 string`}),ye=b.extend({blob:ve}),x=U([`user`,`assistant`]),S=z({audience:R(x).optional(),priority:F().min(0).max(1).optional(),lastModified:nc({offset:!0}).optional()}),be=z({..._.shape,...te.shape,uri:N(),description:G(N()),mimeType:G(N()),size:G(F()),annotations:S.optional(),_meta:G(B({}))}),xe=z({..._.shape,...te.shape,uriTemplate:N(),description:G(N()),mimeType:G(N()),annotations:S.optional(),_meta:G(B({}))}),Se=he.extend({method:W(`resources/list`)}),Ce=ge.extend({resources:R(be)}),we=he.extend({method:W(`resources/templates/list`)}),Te=ge.extend({resourceTemplates:R(xe)}),C=s.extend({uri:N()}),Ee=C,w=l.extend({method:W(`resources/read`),params:Ee}),De=f.extend({contents:R(V([_e,ye]))}),Oe=d.extend({method:W(`notifications/resources/list_changed`),params:u.optional()}),ke=C,Ae=l.extend({method:W(`resources/subscribe`),params:ke}),T=C,je=l.extend({method:W(`resources/unsubscribe`),params:T}),Me=u.extend({uri:N()}),Ne=d.extend({method:W(`notifications/resources/updated`),params:Me}),E=z({name:N(),description:G(N()),required:G(I())}),Pe=z({..._.shape,...te.shape,description:G(N()),arguments:G(R(E)),_meta:G(B({}))}),Fe=he.extend({method:W(`prompts/list`)}),Ie=ge.extend({prompts:R(Pe)}),Le=s.extend({name:N(),arguments:H(N(),N()).optional()}),Re=l.extend({method:W(`prompts/get`),params:Le}),ze=z({type:W(`text`),text:N(),annotations:S.optional(),_meta:H(N(),L()).optional()}),Be=z({type:W(`image`),data:ve,mimeType:N(),annotations:S.optional(),_meta:H(N(),L()).optional()}),Ve=z({type:W(`audio`),data:ve,mimeType:N(),annotations:S.optional(),_meta:H(N(),L()).optional()}),He=z({type:W(`tool_use`),name:N(),id:N(),input:H(N(),L()),_meta:H(N(),L()).optional()}),Ue=z({type:W(`resource`),resource:V([_e,ye]),annotations:S.optional(),_meta:H(N(),L()).optional()}),We=be.extend({type:W(`resource_link`)}),Ge=V([ze,Be,Ve,We,Ue]),Ke=z({role:x,content:Ge}),qe=f.extend({description:N().optional(),messages:R(Ke)}),Je=d.extend({method:W(`notifications/prompts/list_changed`),params:u.optional()}),Ye=z({title:N().optional(),readOnlyHint:I().optional(),destructiveHint:I().optional(),idempotentHint:I().optional(),openWorldHint:I().optional()}),Xe=z({taskSupport:U([`required`,`optional`,`forbidden`]).optional()}),Ze=z({..._.shape,...te.shape,description:N().optional(),inputSchema:z({type:W(`object`),properties:H(N(),e).optional(),required:R(N()).optional()}).catchall(L()),outputSchema:z({type:W(`object`),properties:H(N(),e).optional(),required:R(N()).optional()}).catchall(L()).optional(),annotations:Ye.optional(),execution:Xe.optional(),_meta:H(N(),L()).optional()}),Qe=he.extend({method:W(`tools/list`)}),$e=ge.extend({tools:R(Ze)}),et=f.extend({content:R(Ge),structuredContent:H(N(),L()).optional(),isError:I().optional()}),D=c.extend({name:N(),arguments:H(N(),L()).optional()}),tt=l.extend({method:W(`tools/call`),params:D}),nt=d.extend({method:W(`notifications/tools/list_changed`),params:u.optional()}),rt=U([`debug`,`info`,`notice`,`warning`,`error`,`critical`,`alert`,`emergency`]),it=s.extend({level:rt}),at=l.extend({method:W(`logging/setLevel`),params:it}),ot=u.extend({level:rt,logger:N().optional(),data:L()}),st=d.extend({method:W(`notifications/message`),params:ot}),ct=z({name:N().optional()}),lt=z({hints:R(ct).optional(),costPriority:F().min(0).max(1).optional(),speedPriority:F().min(0).max(1).optional(),intelligencePriority:F().min(0).max(1).optional()}),ut=z({mode:U([`auto`,`required`,`none`]).optional()}),dt=z({type:W(`tool_result`),toolUseId:N().describe(`The unique identifier for the corresponding tool call.`),content:R(Ge),structuredContent:z({}).loose().optional(),isError:I().optional(),_meta:H(N(),L()).optional()}),ft=Ss(`type`,[ze,Be,Ve]),pt=Ss(`type`,[ze,Be,Ve,He,dt]),mt=z({role:x,content:V([pt,R(pt)]),_meta:H(N(),L()).optional()}),ht=c.extend({messages:R(mt),modelPreferences:lt.optional(),systemPrompt:N().optional(),includeContext:U([`none`,`thisServer`,`allServers`]).optional(),temperature:F().optional(),maxTokens:F().int(),stopSequences:R(N()).optional(),metadata:t.optional(),tools:R(Ze).optional(),toolChoice:ut.optional()}),gt=l.extend({method:W(`sampling/createMessage`),params:ht}),_t=f.extend({model:N(),stopReason:G(U([`endTurn`,`stopSequence`,`maxTokens`]).or(N())),role:x,content:ft}),vt=f.extend({model:N(),stopReason:G(U([`endTurn`,`stopSequence`,`maxTokens`,`toolUse`]).or(N())),role:x,content:V([pt,R(pt)])}),yt=z({type:W(`boolean`),title:N().optional(),description:N().optional(),default:I().optional()}),bt=z({type:W(`string`),title:N().optional(),description:N().optional(),minLength:F().optional(),maxLength:F().optional(),format:U([`email`,`uri`,`date`,`date-time`]).optional(),default:N().optional()}),xt=z({type:U([`number`,`integer`]),title:N().optional(),description:N().optional(),minimum:F().optional(),maximum:F().optional(),default:F().optional()}),St=z({type:W(`string`),title:N().optional(),description:N().optional(),enum:R(N()),default:N().optional()}),Ct=z({type:W(`string`),title:N().optional(),description:N().optional(),oneOf:R(z({const:N(),title:N()})),default:N().optional()}),wt=z({type:W(`string`),title:N().optional(),description:N().optional(),enum:R(N()),enumNames:R(N()).optional(),default:N().optional()}),Tt=V([St,Ct]),Et=z({type:W(`array`),title:N().optional(),description:N().optional(),minItems:F().optional(),maxItems:F().optional(),items:z({type:W(`string`),enum:R(N())}),default:R(N()).optional()}),Dt=z({type:W(`array`),title:N().optional(),description:N().optional(),minItems:F().optional(),maxItems:F().optional(),items:z({anyOf:R(z({const:N(),title:N()}))}),default:R(N()).optional()}),Ot=V([Et,Dt]),kt=V([wt,Tt,Ot]),At=V([kt,yt,bt,xt]),jt=c.extend({mode:W(`form`).optional(),message:N(),requestedSchema:z({type:W(`object`),properties:H(N(),At),required:R(N()).optional()}).catchall(L())}),Mt=c.extend({mode:W(`url`),message:N(),elicitationId:N(),url:N().url()}),Nt=V([jt,Mt]),Pt=l.extend({method:W(`elicitation/create`),params:Nt}),Ft=u.extend({elicitationId:N()}),It=d.extend({method:W(`notifications/elicitation/complete`),params:Ft}),Lt=f.extend({action:U([`accept`,`decline`,`cancel`]),content:$s(e=>e===null?void 0:e,H(N(),V([N(),F(),I(),R(N())])).optional())}),Rt=z({type:W(`ref/resource`),uri:N()}),zt=z({type:W(`ref/prompt`),name:N()}),Bt=s.extend({ref:V([zt,Rt]),argument:z({name:N(),value:N()}),context:z({arguments:H(N(),N()).optional()}).optional()}),Vt=l.extend({method:W(`completion/complete`),params:Bt}),Ht=f.extend({completion:B({values:R(N()).max(100),total:G(F().int()),hasMore:G(I())})}),Ut=z({uri:N().startsWith(`file://`),name:N().optional(),_meta:H(N(),L()).optional()}),O=l.extend({method:W(`roots/list`),params:s.optional()}),Wt=f.extend({roots:R(Ut)}),Gt=d.extend({method:W(`notifications/roots/list_changed`),params:u.optional()}),Kt=B({ttl:F().optional(),pollInterval:F().optional()}),qt=U([`working`,`input_required`,`completed`,`failed`,`cancelled`]),Jt=z({taskId:N(),status:qt,ttl:V([F(),fs()]),createdAt:N(),lastUpdatedAt:N(),pollInterval:G(F()),statusMessage:G(N())}),Yt=f.extend({task:Jt}),Xt=u.merge(Jt),Zt=d.extend({method:W(`notifications/tasks/status`),params:Xt}),Qt=l.extend({method:W(`tasks/get`),params:s.extend({taskId:N()})}),$t=f.merge(Jt),en=l.extend({method:W(`tasks/result`),params:s.extend({taskId:N()})}),tn=f.loose(),nn=he.extend({method:W(`tasks/list`)}),rn=ge.extend({tasks:R(Jt)}),an=l.extend({method:W(`tasks/cancel`),params:s.extend({taskId:N()})});return{JSONValueSchema:e,JSONObjectSchema:t,ProgressTokenSchema:n,CursorSchema:r,TaskMetadataSchema:i,RelatedTaskMetadataSchema:a,RequestMetaSchema:o,BaseRequestParamsSchema:s,TaskAugmentedRequestParamsSchema:c,RequestSchema:l,NotificationsParamsSchema:u,NotificationSchema:d,ResultSchema:f,RequestIdSchema:p,EmptyResultSchema:m,CancelledNotificationParamsSchema:h,CancelledNotificationSchema:g,IconSchema:ee,IconsSchema:te,BaseMetadataSchema:_,ImplementationSchema:v,ClientTasksCapabilitySchema:ne,ServerTasksCapabilitySchema:re,ClientCapabilitiesSchema:ie,InitializeRequestParamsSchema:ae,InitializeRequestSchema:oe,ServerCapabilitiesSchema:se,InitializeResultSchema:ce,InitializedNotificationSchema:le,PingRequestSchema:ue,ProgressSchema:de,ProgressNotificationParamsSchema:fe,ProgressNotificationSchema:pe,PaginatedRequestParamsSchema:me,PaginatedRequestSchema:he,PaginatedResultSchema:ge,ResourceContentsSchema:b,TextResourceContentsSchema:_e,BlobResourceContentsSchema:ye,RoleSchema:x,AnnotationsSchema:S,ResourceSchema:be,ResourceTemplateSchema:xe,ListResourcesRequestSchema:Se,ListResourcesResultSchema:Ce,ListResourceTemplatesRequestSchema:we,ListResourceTemplatesResultSchema:Te,ResourceRequestParamsSchema:C,ReadResourceRequestParamsSchema:Ee,ReadResourceRequestSchema:w,ReadResourceResultSchema:De,ResourceListChangedNotificationSchema:Oe,SubscribeRequestParamsSchema:ke,SubscribeRequestSchema:Ae,UnsubscribeRequestParamsSchema:T,UnsubscribeRequestSchema:je,ResourceUpdatedNotificationParamsSchema:Me,ResourceUpdatedNotificationSchema:Ne,PromptArgumentSchema:E,PromptSchema:Pe,ListPromptsRequestSchema:Fe,ListPromptsResultSchema:Ie,GetPromptRequestParamsSchema:Le,GetPromptRequestSchema:Re,TextContentSchema:ze,ImageContentSchema:Be,AudioContentSchema:Ve,ToolUseContentSchema:He,EmbeddedResourceSchema:Ue,ResourceLinkSchema:We,ContentBlockSchema:Ge,PromptMessageSchema:Ke,GetPromptResultSchema:qe,PromptListChangedNotificationSchema:Je,ToolAnnotationsSchema:Ye,ToolExecutionSchema:Xe,ToolSchema:Ze,ListToolsRequestSchema:Qe,ListToolsResultSchema:$e,CallToolResultSchema:et,CallToolRequestParamsSchema:D,CallToolRequestSchema:tt,ToolListChangedNotificationSchema:nt,LoggingLevelSchema:rt,SetLevelRequestParamsSchema:it,SetLevelRequestSchema:at,LoggingMessageNotificationParamsSchema:ot,LoggingMessageNotificationSchema:st,ModelHintSchema:ct,ModelPreferencesSchema:lt,ToolChoiceSchema:ut,ToolResultContentSchema:dt,SamplingContentSchema:ft,SamplingMessageContentBlockSchema:pt,SamplingMessageSchema:mt,CreateMessageRequestParamsSchema:ht,CreateMessageRequestSchema:gt,CreateMessageResultSchema:_t,CreateMessageResultWithToolsSchema:vt,BooleanSchemaSchema:yt,StringSchemaSchema:bt,NumberSchemaSchema:xt,UntitledSingleSelectEnumSchemaSchema:St,TitledSingleSelectEnumSchemaSchema:Ct,LegacyTitledEnumSchemaSchema:wt,SingleSelectEnumSchemaSchema:Tt,UntitledMultiSelectEnumSchemaSchema:Et,TitledMultiSelectEnumSchemaSchema:Dt,MultiSelectEnumSchemaSchema:Ot,EnumSchemaSchema:kt,PrimitiveSchemaDefinitionSchema:At,ElicitRequestFormParamsSchema:jt,ElicitRequestURLParamsSchema:Mt,ElicitRequestParamsSchema:Nt,ElicitRequestSchema:Pt,ElicitationCompleteNotificationParamsSchema:Ft,ElicitationCompleteNotificationSchema:It,ElicitResultSchema:Lt,ResourceTemplateReferenceSchema:Rt,PromptReferenceSchema:zt,CompleteRequestParamsSchema:Bt,CompleteRequestSchema:Vt,CompleteResultSchema:Ht,RootSchema:Ut,ListRootsRequestSchema:O,ListRootsResultSchema:Wt,RootsListChangedNotificationSchema:Gt,TaskCreationParamsSchema:Kt,TaskStatusSchema:qt,TaskSchema:Jt,CreateTaskResultSchema:Yt,TaskStatusNotificationParamsSchema:Xt,TaskStatusNotificationSchema:Zt,GetTaskRequestSchema:Qt,GetTaskResultSchema:$t,GetTaskPayloadRequestSchema:en,GetTaskPayloadResultSchema:tn,ListTasksRequestSchema:nn,ListTasksResultSchema:rn,CancelTaskRequestSchema:an,CancelTaskResultSchema:f.merge(Jt),ClientRequestSchema:V([ue,oe,Vt,at,Re,Fe,Se,we,w,Ae,je,tt,Qe,Qt,en,nn,an]),ClientNotificationSchema:V([g,pe,le,Gt,Zt]),ClientResultSchema:V([m,_t,vt,Lt,Wt,$t,rn,Yt]),ServerRequestSchema:V([ue,gt,Pt,O,Qt,en,nn,an]),ServerNotificationSchema:V([g,pe,st,Ne,Oe,nt,Je,Zt,It]),ServerResultSchema:V([m,ce,Ht,qe,Ie,Ce,Te,De,et,$e,$t,rn,Yt]),CallToolResultWireSchema:L().superRefine((e,t)=>{if(!(typeof e!=`object`||!e||Array.isArray(e)||e.content!==void 0)){for(let n of Yp)if(n in e){t.addIssue({code:`custom`,message:`content is required when the body carries '${n}' — another result family cannot default into an empty tools/call success`});return}}}).transform(Xp).pipe(et)}}var Qp;function $p(){return Qp??=Zp()}function em(e){return e.type!==`object`}var tm=new Set([`const`,`enum`,`default`,`examples`]),nm=new Set([`properties`,`patternProperties`,`$defs`,`definitions`,`dependentSchemas`,`dependencies`]);function rm(e){return e!==void 0&&!(typeof e==`string`&&e.startsWith(`#`))}function im(e){let t=typeof e.$schema==`string`?e.$schema:void 0;if(rm(e.$id))return{...t!==void 0&&{$schema:t},type:`object`,properties:{result:e},required:[`result`]};let n=Fp(e.$schema)&&e.$recursiveAnchor!==!0,r=(e,t)=>{if(Array.isArray(e))return e.map(e=>r(e,!1));if(typeof e!=`object`||!e||!t&&rm(e.$id))return e;let i={},a=!1;for(let[o,s]of Object.entries(e))t?i[o]=r(s,!1):(o===`$ref`||o===`$dynamicRef`)&&typeof s==`string`?i[o]=s===`#`?`#/properties/result`:s.startsWith(`#/`)?`#/properties/result${s.slice(1)}`:s:o===`$recursiveRef`&&s===`#`&&n?a=!0:i[o]=tm.has(o)?s:nm.has(o)?r(s,!0):r(s,!1);return a&&(`$ref`in i?i.allOf=[...Array.isArray(i.allOf)?i.allOf:[],{$ref:`#/properties/result`}]:i.$ref=`#/properties/result`),i};return{...t!==void 0&&{$schema:t},type:`object`,properties:{result:r(e,!1)},required:[`result`]}}var am={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},om={"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},sm={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},cm;function lm(){if(cm)return cm;let e=$p();return cm={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}},cm}function um(e){return Object.prototype.hasOwnProperty.call(am,e)}function dm(e){return Object.prototype.hasOwnProperty.call(om,e)}function fm(e){return Object.prototype.hasOwnProperty.call(sm,e)}function pm(e){return fm(e)?lm().resultSchemas[e]:void 0}function mm(e){return um(e)?lm().requestSchemas[e]:void 0}function hm(e){return dm(e)?lm().notificationSchemas[e]:void 0}Object.keys(am),Object.keys(om);function gm(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function _m(e,t){if(e===void 0)return{ok:!1,reason:`not-in-era`};let n=e.safeParse(t);return n.success?{ok:!0,value:n.data}:{ok:!1,reason:`invalid`,message:String(n.error)}}var vm={ok:!1,reason:`not-in-era`};function ym(e){return gm(e)&&gm(e.outputSchema)&&em(e.outputSchema)}function bm(e){return e}var xm={era:`2025-11-25`,hasRequestMethod:um,hasNotificationMethod:dm,validateRequest:(e,t)=>_m(mm(e),t),validateResult:(e,t)=>_m(pm(e),t),validateNotification:(e,t)=>_m(hm(e),t),hasInputRequestMethod:()=>!1,validateInputRequest:()=>vm,validateInputResponse:()=>vm,samplingResultVariant:((e,t)=>{let n=$p();return _m(e?n.CreateMessageResultWithToolsSchema:n.CreateMessageResultSchema,t)}),outboundEnvelope:e=>void 0,validateEnvelopeMeta:e=>[],projectCallToolResult(e,t){let n=Jp(e),r=n.structuredContent;if(r===void 0)return n;let i=typeof r!=`object`||!r||Array.isArray(r),a=t!==void 0&&em(t);return!i&&!a?n:{...n,structuredContent:{result:r}}},decodeResult(e,t){if(gm(t)&&`resultType`in t){let e={...t};return delete e.resultType,{kind:`complete`,result:bm(e)}}return{kind:`complete`,result:bm(t)}},encodeResult(e,t){if(e!==`tools/list`)return t;let n=t.tools;return!Array.isArray(n)||!n.some(e=>ym(e))?t:{...t,tools:n.map(e=>ym(e)?{...e,outputSchema:im(e.outputSchema)}:e)}},encodeErrorCode:e=>e===-32002?-32602:e,checkInboundEnvelope:e=>void 0};function Sm(){let e=Ys(()=>V([N(),F(),I(),fs(),H(N(),e),R(e)])),t=H(N(),e),n=V([N(),F().int()]),r=N(),i=V([N(),F().int()]),a=U([`user`,`assistant`]),o=U([`debug`,`info`,`notice`,`warning`,`error`,`critical`,`alert`,`emergency`]),s=N().refine(e=>{try{return atob(e),!0}catch{return!1}},{message:`Invalid Base64 string`}),c=z({ttl:F().optional()}),l=z({taskId:N()}),u=B({progressToken:n.optional(),"io.modelcontextprotocol/related-task":l.optional()}),d=z({_meta:u.optional()}),f=d.extend({task:c.optional()}),p=z({_meta:u.optional()}),m=z({method:N(),params:p.loose().optional()}),h=z({src:N(),mimeType:N().optional(),sizes:R(N()).optional(),theme:U([`light`,`dark`]).optional()}),g=z({icons:R(h).optional()}),ee=z({name:N(),title:N().optional()}),te=ee.extend({...ee.shape,...g.shape,version:N(),websiteUrl:N().optional(),description:N().optional()}),_=$s(e=>e&&typeof e==`object`&&!Array.isArray(e)&&Object.keys(e).length===0?{form:{}}:e,ws(z({form:ws(z({applyDefaults:I().optional()}),t).optional(),url:t.optional()}),t.optional())),v=B({list:t.optional(),cancel:t.optional(),requests:B({sampling:B({createMessage:t.optional()}).optional(),elicitation:B({create:t.optional()}).optional()}).optional()}),y=B({list:t.optional(),cancel:t.optional(),requests:B({tools:B({call:t.optional()}).optional()}).optional()}),ne=z({experimental:H(N(),t).optional(),sampling:z({context:t.optional(),tools:t.optional()}).optional(),elicitation:_.optional(),roots:z({listChanged:I().optional()}).optional(),tasks:v.optional(),extensions:H(N(),t).optional()}),re=z({experimental:H(N(),t).optional(),logging:t.optional(),completions:t.optional(),prompts:z({listChanged:I().optional()}).optional(),resources:z({subscribe:I().optional(),listChanged:I().optional()}).optional(),tools:z({listChanged:I().optional()}).optional(),tasks:y.optional(),extensions:H(N(),t).optional()}),ie=z({progress:F(),total:G(F()),message:G(N())}),ae=z({...p.shape,...ie.shape,progressToken:n}),oe=m.extend({method:W(`notifications/progress`),params:ae}),se=p.extend({level:o,logger:N().optional(),data:L()}),ce=m.extend({method:W(`notifications/message`),params:se}),le=z({uri:N(),mimeType:G(N()),_meta:H(N(),L()).optional()}),ue=le.extend({text:N()}),de=le.extend({blob:s}),fe=z({audience:R(a).optional(),priority:F().min(0).max(1).optional(),lastModified:nc({offset:!0}).optional()}),pe=z({...ee.shape,...g.shape,uri:N(),description:G(N()),mimeType:G(N()),size:G(F()),annotations:fe.optional(),_meta:G(B({}))}),me=z({...ee.shape,...g.shape,uriTemplate:N(),description:G(N()),mimeType:G(N()),annotations:fe.optional(),_meta:G(B({}))}),he=m.extend({method:W(`notifications/resources/list_changed`),params:p.optional()}),ge=p.extend({uri:N()}),b=m.extend({method:W(`notifications/resources/updated`),params:ge}),_e=z({name:N(),description:G(N()),required:G(I())}),ve=z({...ee.shape,...g.shape,description:G(N()),arguments:G(R(_e)),_meta:G(B({}))}),ye=m.extend({method:W(`notifications/prompts/list_changed`),params:p.optional()}),x=z({type:W(`text`),text:N(),annotations:fe.optional(),_meta:H(N(),L()).optional()}),S=z({type:W(`image`),data:s,mimeType:N(),annotations:fe.optional(),_meta:H(N(),L()).optional()}),be=z({type:W(`audio`),data:s,mimeType:N(),annotations:fe.optional(),_meta:H(N(),L()).optional()}),xe=z({type:W(`tool_use`),name:N(),id:N(),input:H(N(),L()),_meta:H(N(),L()).optional()}),Se=z({type:W(`resource`),resource:V([ue,de]),annotations:fe.optional(),_meta:H(N(),L()).optional()}),Ce=pe.extend({type:W(`resource_link`)}),we=V([x,S,be,Ce,Se]),Te=z({role:a,content:we}),C=z({title:N().optional(),readOnlyHint:I().optional(),destructiveHint:I().optional(),idempotentHint:I().optional(),openWorldHint:I().optional()}),Ee=m.extend({method:W(`notifications/tools/list_changed`),params:p.optional()}),w=z({name:N().optional()}),De=z({hints:R(w).optional(),costPriority:F().min(0).max(1).optional(),speedPriority:F().min(0).max(1).optional(),intelligencePriority:F().min(0).max(1).optional()}),Oe=z({mode:U([`auto`,`required`,`none`]).optional()}),ke=z({type:W(`boolean`),title:N().optional(),description:N().optional(),default:I().optional()}),Ae=z({type:W(`string`),title:N().optional(),description:N().optional(),minLength:F().optional(),maxLength:F().optional(),format:U([`email`,`uri`,`date`,`date-time`]).optional(),default:N().optional()}),T=z({type:U([`number`,`integer`]),title:N().optional(),description:N().optional(),minimum:F().optional(),maximum:F().optional(),default:F().optional()}),je=z({type:W(`string`),title:N().optional(),description:N().optional(),enum:R(N()),default:N().optional()}),Me=z({type:W(`string`),title:N().optional(),description:N().optional(),oneOf:R(z({const:N(),title:N()})),default:N().optional()}),Ne=z({type:W(`string`),title:N().optional(),description:N().optional(),enum:R(N()),enumNames:R(N()).optional(),default:N().optional()}),E=V([je,Me]),Pe=z({type:W(`array`),title:N().optional(),description:N().optional(),minItems:F().optional(),maxItems:F().optional(),items:z({type:W(`string`),enum:R(N())}),default:R(N()).optional()}),Fe=z({type:W(`array`),title:N().optional(),description:N().optional(),minItems:F().optional(),maxItems:F().optional(),items:z({anyOf:R(z({const:N(),title:N()}))}),default:R(N()).optional()}),Ie=V([Pe,Fe]),Le=V([Ne,E,Ie]),Re=V([Le,ke,Ae,T]),ze=f.extend({mode:W(`form`).optional(),message:N(),requestedSchema:z({type:W(`object`),properties:H(N(),Re),required:R(N()).optional()}).catchall(L())}),Be=z({type:W(`ref/resource`),uri:N()}),Ve=z({type:W(`ref/prompt`),name:N()}),He=z({uri:N().startsWith(`file://`),name:N().optional(),_meta:H(N(),L()).optional()}),Ue=ne.shape,We=z({experimental:Ue.experimental,sampling:Ue.sampling,elicitation:Ue.elicitation,roots:Ue.roots,extensions:Ue.extensions}),Ge=re.shape,Ke=z({experimental:Ge.experimental,logging:Ge.logging,completions:Ge.completions,prompts:Ge.prompts,resources:Ge.resources,tools:Ge.tools,extensions:Ge.extensions}),qe=B({progressToken:n.optional(),[sc]:N(),[cc]:te.optional(),[uc]:We,[fc]:o.optional()}),Je=z({...ee.shape,...g.shape,description:N().optional(),inputSchema:B({$schema:N().optional(),type:W(`object`)}),outputSchema:B({$schema:N().optional()}).optional(),annotations:C.optional(),_meta:H(N(),L()).optional()}),Ye=z({type:W(`tool_result`),toolUseId:N(),content:R(we),structuredContent:L().optional(),isError:I().optional(),_meta:H(N(),L()).optional()}),Xe=V([x,S,be,xe,Ye]),Ze=z({role:a,content:V([Xe,R(Xe)]),_meta:H(N(),L()).optional()}),Qe=N(),$e=B({[lc]:te.optional().catch(void 0)}),et=$e.optional();function D(e){return B({_meta:et,resultType:Qe.default(`complete`),...e})}let tt=D({}),nt=D({nextCursor:r.optional()}),rt=D({content:R(we),structuredContent:L().optional(),isError:I().optional()}),it=D({ttlMs:F().int().min(0),cacheScope:U([`public`,`private`]),tools:R(Je),nextCursor:r.optional()}),at=D({ttlMs:F().int().min(0),cacheScope:U([`public`,`private`]),prompts:R(ve),nextCursor:r.optional()}),ot=D({description:N().optional(),messages:R(Te)}),st=D({ttlMs:F().int().min(0),cacheScope:U([`public`,`private`]),resources:R(pe),nextCursor:r.optional()}),ct=D({ttlMs:F().int().min(0),cacheScope:U([`public`,`private`]),resourceTemplates:R(me),nextCursor:r.optional()}),lt=D({ttlMs:F().int().min(0),cacheScope:U([`public`,`private`]),contents:R(V([ue,de]))}),ut=D({completion:z({values:R(N()).max(100),total:F().int().optional(),hasMore:I().optional()}).loose()}),dt=D({ttlMs:F().int().min(0),cacheScope:U([`public`,`private`])}),ft=D({ttlMs:F().int().min(0).catch(0),cacheScope:U([`public`,`private`]).catch(`private`),supportedVersions:R(N()),capabilities:Ke,instructions:N().optional()}),pt=z({messages:R(Ze),modelPreferences:De.optional(),systemPrompt:N().optional(),includeContext:U([`none`,`thisServer`,`allServers`]).optional(),temperature:F().optional(),maxTokens:F().int(),stopSequences:R(N()).optional(),metadata:t.optional(),tools:R(Je).optional(),toolChoice:Oe.optional()}),mt=z({method:W(`sampling/createMessage`),params:pt}),ht=z({method:W(`roots/list`),params:z({_meta:H(N(),L()).optional()}).optional()}),gt=z({...Ze.shape,model:N(),stopReason:N().optional()}),_t=z({roots:R(He)}),vt=z({action:U([`accept`,`decline`,`cancel`]),content:H(N(),V([N(),F(),I(),R(N())])).optional()}),yt=z({mode:W(`url`),message:N(),url:N().url()}),bt=V([ze,yt]),xt=z({method:W(`elicitation/create`),params:bt}),St=V([mt,ht,xt]),Ct=V([gt,_t,vt]),wt=H(N(),St),Tt=H(N(),Ct),Et=D({inputRequests:wt.optional(),requestState:N().optional()}),Dt={inputResponses:Tt.optional(),requestState:N().optional()},Ot=z({_meta:qe,...Dt}),kt=B({progressToken:n.optional()});function At(e,t){return z({method:W(e),params:z({_meta:qe,...t})})}function jt(e,t){return z({method:W(e),params:z({_meta:kt.optional(),...t}).optional()})}let Mt={name:N(),arguments:H(N(),L()).optional(),...Dt},Nt={cursor:r.optional()},Pt=At(`tools/call`,Mt),Ft=At(`tools/list`,Nt),It=At(`prompts/list`,Nt),Lt=At(`prompts/get`,{name:N(),arguments:H(N(),N()).optional(),...Dt}),Rt=At(`resources/list`,Nt),zt=At(`resources/templates/list`,Nt),Bt=At(`resources/read`,{uri:N(),...Dt}),Vt={ref:V([Ve,Be]),argument:z({name:N(),value:N()}),context:z({arguments:H(N(),N()).optional()}).optional()},Ht=At(`completion/complete`,Vt),Ut=At(`server/discover`,{}),O=z({toolsListChanged:I().optional(),promptsListChanged:I().optional(),resourcesListChanged:I().optional(),resourceSubscriptions:R(N()).optional()}),Wt={notifications:O},Gt=At(`subscriptions/listen`,Wt),Kt=$e.extend({"io.modelcontextprotocol/subscriptionId":i}),qt=B({_meta:Kt,resultType:Qe.default(`complete`)}),Jt={"tools/call":jt(`tools/call`,Mt),"tools/list":jt(`tools/list`,Nt),"prompts/get":jt(`prompts/get`,{name:N(),arguments:H(N(),N()).optional()}),"prompts/list":jt(`prompts/list`,Nt),"resources/list":jt(`resources/list`,Nt),"resources/templates/list":jt(`resources/templates/list`,Nt),"resources/read":jt(`resources/read`,{uri:N()}),"completion/complete":jt(`completion/complete`,Vt),"server/discover":jt(`server/discover`,{}),"subscriptions/listen":jt(`subscriptions/listen`,Wt)};function Yt(e){return B({_meta:et,...e})}let Xt={"tools/call":Yt({content:R(we),structuredContent:L().optional(),isError:I().optional()}),"tools/list":Yt({ttlMs:F().int().min(0),cacheScope:U([`public`,`private`]),tools:R(Je),nextCursor:r.optional()}),"prompts/get":Yt({description:N().optional(),messages:R(Te)}),"prompts/list":Yt({ttlMs:F().int().min(0),cacheScope:U([`public`,`private`]),prompts:R(ve),nextCursor:r.optional()}),"resources/list":Yt({ttlMs:F().int().min(0),cacheScope:U([`public`,`private`]),resources:R(pe),nextCursor:r.optional()}),"resources/templates/list":Yt({ttlMs:F().int().min(0),cacheScope:U([`public`,`private`]),resourceTemplates:R(me),nextCursor:r.optional()}),"resources/read":Yt({ttlMs:F().int().min(0),cacheScope:U([`public`,`private`]),contents:R(V([ue,de]))}),"completion/complete":Yt({completion:z({values:R(N()).max(100),total:F().int().optional(),hasMore:I().optional()}).loose()}),"server/discover":Yt({ttlMs:F().int().min(0).catch(0),cacheScope:U([`public`,`private`]).catch(`private`),supportedVersions:R(N()),capabilities:Ke,instructions:N().optional()}),"subscriptions/listen":Yt({})},Zt=B({"io.modelcontextprotocol/subscriptionId":i.optional()}),Qt=z({method:W(`notifications/subscriptions/acknowledged`),params:z({_meta:Zt.optional(),notifications:O})}),$t=z({_meta:Zt.optional(),requestId:i,reason:N().optional()}),en=z({method:W(`notifications/cancelled`),params:$t}),tn={"notifications/cancelled":en,"notifications/progress":oe,"notifications/message":ce,"notifications/resources/updated":b,"notifications/resources/list_changed":he,"notifications/tools/list_changed":Ee,"notifications/prompts/list_changed":ye,"notifications/subscriptions/acknowledged":Qt},nn=e=>z({jsonrpc:W(`2.0`),id:V([N(),F().int()]),result:e}).strict();return{JSONValueSchema:e,JSONObjectSchema:t,ProgressTokenSchema:n,CursorSchema:r,RequestIdSchema:i,RoleSchema:a,LoggingLevelSchema:o,TaskMetadataSchema:c,RelatedTaskMetadataSchema:l,RequestMetaSchema:u,BaseRequestParamsSchema:d,TaskAugmentedRequestParamsSchema:f,NotificationsParamsSchema:p,NotificationSchema:m,IconSchema:h,IconsSchema:g,BaseMetadataSchema:ee,ImplementationSchema:te,ClientTasksCapabilitySchema:v,ServerTasksCapabilitySchema:y,ClientCapabilitiesSchema:ne,ServerCapabilitiesSchema:re,ProgressSchema:ie,ProgressNotificationParamsSchema:ae,ProgressNotificationSchema:oe,LoggingMessageNotificationParamsSchema:se,LoggingMessageNotificationSchema:ce,ResourceContentsSchema:le,TextResourceContentsSchema:ue,BlobResourceContentsSchema:de,AnnotationsSchema:fe,ResourceSchema:pe,ResourceTemplateSchema:me,ResourceListChangedNotificationSchema:he,ResourceUpdatedNotificationParamsSchema:ge,ResourceUpdatedNotificationSchema:b,PromptArgumentSchema:_e,PromptSchema:ve,PromptListChangedNotificationSchema:ye,TextContentSchema:x,ImageContentSchema:S,AudioContentSchema:be,ToolUseContentSchema:xe,EmbeddedResourceSchema:Se,ResourceLinkSchema:Ce,ContentBlockSchema:we,PromptMessageSchema:Te,ToolAnnotationsSchema:C,ToolListChangedNotificationSchema:Ee,ModelHintSchema:w,ModelPreferencesSchema:De,ToolChoiceSchema:Oe,BooleanSchemaSchema:ke,StringSchemaSchema:Ae,NumberSchemaSchema:T,UntitledSingleSelectEnumSchemaSchema:je,TitledSingleSelectEnumSchemaSchema:Me,LegacyTitledEnumSchemaSchema:Ne,SingleSelectEnumSchemaSchema:E,UntitledMultiSelectEnumSchemaSchema:Pe,TitledMultiSelectEnumSchemaSchema:Fe,MultiSelectEnumSchemaSchema:Ie,EnumSchemaSchema:Le,PrimitiveSchemaDefinitionSchema:Re,ElicitRequestFormParamsSchema:ze,ResourceTemplateReferenceSchema:Be,PromptReferenceSchema:Ve,RootSchema:He,ClientCapabilities2026Schema:We,ServerCapabilities2026Schema:Ke,RequestMetaEnvelopeSchema:qe,ToolSchema:Je,ToolResultContentSchema:Ye,SamplingMessageContentBlockSchema:Xe,SamplingMessageSchema:Ze,ResultTypeSchema:Qe,ResultMetaSchema:$e,ResultSchema:tt,PaginatedResultSchema:nt,CallToolResultSchema:rt,ListToolsResultSchema:it,ListPromptsResultSchema:at,GetPromptResultSchema:ot,ListResourcesResultSchema:st,ListResourceTemplatesResultSchema:ct,ReadResourceResultSchema:lt,CompleteResultSchema:ut,CacheableResultSchema:dt,DiscoverResultSchema:ft,CreateMessageRequestParamsSchema:pt,CreateMessageRequestSchema:mt,ListRootsRequestSchema:ht,CreateMessageResultSchema:gt,ListRootsResultSchema:_t,ElicitResultSchema:vt,ElicitRequestURLParamsSchema:yt,ElicitRequestParamsSchema:bt,ElicitRequestSchema:xt,InputRequestSchema:St,InputResponseSchema:Ct,InputRequestsSchema:wt,InputResponsesSchema:Tt,InputRequiredResultSchema:Et,InputResponseRequestParamsSchema:Ot,CallToolRequestSchema:Pt,ListToolsRequestSchema:Ft,ListPromptsRequestSchema:It,GetPromptRequestSchema:Lt,ListResourcesRequestSchema:Rt,ListResourceTemplatesRequestSchema:zt,ReadResourceRequestSchema:Bt,CompleteRequestSchema:Ht,DiscoverRequestSchema:Ut,SubscriptionFilterSchema:O,SubscriptionsListenRequestSchema:Gt,SubscriptionsListenResultMetaSchema:Kt,SubscriptionsListenResultSchema:qt,dispatchRequestSchemas:Jt,dispatchResultSchemas:Xt,NotificationMetaSchema:Zt,SubscriptionsAcknowledgedNotificationSchema:Qt,CancelledNotificationParamsSchema:$t,CancelledNotificationSchema:en,notificationSchemas2026:tn,JSONRPCResultResponseSchema:nn(tt),CallToolResultResponseSchema:nn(V([rt,Et])),ListToolsResultResponseSchema:nn(it),ListPromptsResultResponseSchema:nn(at),GetPromptResultResponseSchema:nn(V([ot,Et])),ListResourcesResultResponseSchema:nn(st),ListResourceTemplatesResultResponseSchema:nn(ct),ReadResourceResultResponseSchema:nn(V([lt,Et])),CompleteResultResponseSchema:nn(ut),DiscoverResultResponseSchema:nn(ft)}}var Cm;function wm(){return Cm??=Sm()}var Tm=[`tools/list`,`prompts/list`,`resources/list`,`resources/templates/list`,`resources/read`,`server/discover`];function Em(e){return Tm.includes(e)}var Dm=Symbol(`modelcontextprotocol.resultCacheHintFallback`);function Om(e,t){if(t===void 0)return e;let n=e[Dm];if(n===void 0)return{...e,[Dm]:t};let r={},i=n.ttlMs??t.ttlMs;i!==void 0&&(r.ttlMs=i);let a=n.cacheScope??t.cacheScope;return a!==void 0&&(r.cacheScope=a),{...e,[Dm]:r}}function km(e){return e[Dm]}function Am(e){return typeof e==`number`&&Number.isSafeInteger(e)&&e>=0}function jm(e){return e===`public`||e===`private`}function Mm(e,t){if(e.ttlMs!==void 0&&!Am(e.ttlMs))throw RangeError(`Invalid cache hint for ${t}: ttlMs must be a non-negative safe integer (got ${String(e.ttlMs)})`);if(e.cacheScope!==void 0&&!jm(e.cacheScope))throw RangeError(`Invalid cache hint for ${t}: cacheScope must be 'public' or 'private' (got ${String(e.cacheScope)})`)}var Z=function(e){return e[e.ParseError=-32700]=`ParseError`,e[e.InvalidRequest=-32600]=`InvalidRequest`,e[e.MethodNotFound=-32601]=`MethodNotFound`,e[e.InvalidParams=-32602]=`InvalidParams`,e[e.InternalError=-32603]=`InternalError`,e[e.ResourceNotFound=-32002]=`ResourceNotFound`,e[e.MissingRequiredClientCapability=-32021]=`MissingRequiredClientCapability`,e[e.UnsupportedProtocolVersion=-32022]=`UnsupportedProtocolVersion`,e[e.UrlElicitationRequired=-32042]=`UrlElicitationRequired`,e}({}),Q=class e extends Error{static{Object.defineProperty(this,"mcpBrand",{value:`mcp.ProtocolError`})}static[Symbol.hasInstance](e){return zp(this,e)}static isInstance(e){if(typeof this!=`function`)throw TypeError("isInstance must be called on the class (e.g. `SdkError.isInstance(value)`); for callbacks use `v => SdkError.isInstance(v)`");return zp(this,e)}constructor(e,t,n){super(t),this.code=e,this.data=n,this.name=`ProtocolError`,Rp(this,new.target)}static fromError(t,n,r){if(t===Z.UrlElicitationRequired&&r){let e=r;if(e.elicitations)return new Pm(e.elicitations,n)}if(t===Z.UnsupportedProtocolVersion&&r){let e=r;if(Array.isArray(e.supported)&&typeof e.requested==`string`)return new Fm({supported:e.supported,requested:e.requested},n)}if(t===Z.InvalidParams||t===Z.ResourceNotFound){let e=r;if(typeof e?.uri==`string`&&(t===Z.ResourceNotFound||Object.keys(e).length===1))return new Nm(e.uri,n)}if(t===Z.MissingRequiredClientCapability&&r){let e=r;if(e.requiredCapabilities!==null&&typeof e.requiredCapabilities==`object`&&!Array.isArray(e.requiredCapabilities))return new Im({requiredCapabilities:e.requiredCapabilities},n)}return new e(t,n,r)}},Nm=class extends Q{static{Object.defineProperty(this,"mcpBrand",{value:`mcp.ResourceNotFoundError`})}constructor(e,t=`Resource not found: ${e}`){super(Z.InvalidParams,t,{uri:e})}get uri(){return this.data.uri}},Pm=class extends Q{static{Object.defineProperty(this,"mcpBrand",{value:`mcp.UrlElicitationRequiredError`})}constructor(e,t=`URL elicitation${e.length>1?`s`:``} required`){super(Z.UrlElicitationRequired,t,{elicitations:e})}get elicitations(){return this.data?.elicitations??[]}},Fm=class extends Q{static{Object.defineProperty(this,"mcpBrand",{value:`mcp.UnsupportedProtocolVersionError`})}constructor(e,t=`Unsupported protocol version: ${e.requested}`){super(Z.UnsupportedProtocolVersion,t,e)}get supported(){return this.data.supported}get requested(){return this.data.requested}},Im=class extends Q{static{Object.defineProperty(this,"mcpBrand",{value:`mcp.MissingRequiredClientCapabilityError`})}constructor(e,t=`Missing required client capabilities: ${Object.keys(e.requiredCapabilities).join(`, `)}`){super(Z.MissingRequiredClientCapability,t,e)}get requiredCapabilities(){return this.data.requiredCapabilities}},Lm=0,Rm=`private`,zm=[`tools/call`,`prompts/get`,`resources/read`];function Bm(e,t){let n=t.resultType;if(n===void 0)return{...t,resultType:`complete`};if(n===`complete`||zm.includes(e))return t;throw new Q(Z.InternalError,`Handler for ${e} returned resultType '${String(n)}', but results of ${e} only support 'complete' on protocol revision 2026-07-28`)}function Vm(e,t){let n=km(t);if(t.resultType!==`complete`||!Em(e))return n===void 0?t:Km(t);let r=t,i=Am(r.ttlMs)?r.ttlMs:Wm(n),a=jm(r.cacheScope)?r.cacheScope:Gm(n),o={...r,ttlMs:i,cacheScope:a};return delete o[Dm],o}function Hm(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Um(e,t){if(t===void 0)return e;let n=e._meta;return n===void 0?{...e,_meta:{[lc]:t}}:!Hm(n)||n[`io.modelcontextprotocol/serverInfo`]!==void 0?e:{...e,_meta:{...n,[lc]:t}}}function Wm(e){return e!==void 0&&Am(e.ttlMs)?e.ttlMs:Lm}function Gm(e){return e!==void 0&&jm(e.cacheScope)?e.cacheScope:Rm}function Km(e){let t={...e};return delete t[Dm],t}var qm=[`elicitation/create`,`sampling/createMessage`,`roots/list`],Jm;function Ym(){if(Jm)return Jm;let e=wm();return Jm={request:{"elicitation/create":z({method:W(`elicitation/create`),params:e.ElicitRequestParamsSchema}),"sampling/createMessage":z({method:W(`sampling/createMessage`),params:e.CreateMessageRequestParamsSchema}),"roots/list":z({method:W(`roots/list`),params:B({}).optional()})},response:{"elicitation/create":e.ElicitResultSchema,"sampling/createMessage":e.CreateMessageResultSchema,"roots/list":e.ListRootsResultSchema}},Jm}function Xm(e){return qm.includes(e)}function Zm(e){return Xm(e)?Ym().request[e]:void 0}function Qm(e){return Xm(e)?Ym().response[e]:void 0}var $m={"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},eh={"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 th(e){return Object.prototype.hasOwnProperty.call($m,e)}function nh(e){return Object.prototype.hasOwnProperty.call(eh,e)}function rh(e){return Object.prototype.hasOwnProperty.call($m,e)}function ih(e){return th(e)?wm().dispatchRequestSchemas[e]:void 0}function ah(e){return rh(e)?wm().dispatchResultSchemas[e]:void 0}function oh(e){return nh(e)?wm().notificationSchemas2026[e]:void 0}Object.keys($m),Object.keys(eh);function sh(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function ch(e,t){if(e===void 0)return{ok:!1,reason:`not-in-era`};let n=e.safeParse(t);return n.success?{ok:!0,value:n.data}:{ok:!1,reason:`invalid`,message:String(n.error)}}var lh={ok:!1,reason:`not-in-era`},uh=[sc,uc];function dh(e,t){let n=t,r=!1,i=()=>(r||=(n={...n},!0),n),a=t.tools;e===`tools/list`&&Array.isArray(a)&&a.some(e=>sh(e)&&`execution`in e)&&(i().tools=a.map(e=>{if(!sh(e)||!(`execution`in e))return e;let t={...e};return delete t.execution,t}));let o=t.capabilities;if(sh(o)&&`tasks`in o){let e={...o};delete e.tasks,i().capabilities=e}return n}var fh={era:`2026-07-28`,hasRequestMethod:th,hasNotificationMethod:nh,hasInputRequestMethod:e=>Zm(e)!==void 0,validateRequest:(e,t)=>ch(ih(e),t),validateResult:(e,t)=>ch(ah(e),t),validateNotification:(e,t)=>ch(oh(e),t),validateInputRequest:(e,t)=>ch(Zm(e),t),validateInputResponse:(e,t)=>ch(Qm(e),t),samplingResultVariant:()=>lh,outboundEnvelope(e){return{[sc]:e.protocolVersion,[cc]:e.clientInfo,[uc]:e.clientCapabilities,...e.logLevel!==void 0&&{"io.modelcontextprotocol/logLevel":e.logLevel}}},validateEnvelopeMeta(e){let t=[];for(let n of uh)n in e||t.push({key:n,problem:`missing`});let n=wm().RequestMetaEnvelopeSchema.safeParse(e);if(!n.success)for(let e of n.error.issues){let n=e.path.map(String),r=n.length>0?n.join(`.`):`_meta`;n.length===1&&t.some(e=>e.key===r&&e.problem===`missing`)||t.push({key:r,problem:e.message})}return t},projectCallToolResult:e=>Jp(e),inputRequestSchema:Zm,decodeResult(e,t){if(!sh(t))return{kind:`invalid`,error:new X(Y.InvalidResult,`Invalid result for ${e}: not an object`,{method:e})};let n=t.resultType;if(n===void 0)return{kind:`invalid`,error:new X(Y.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(typeof n!=`string`)return{kind:`invalid`,error:new X(Y.InvalidResult,`Invalid result for ${e}: non-string resultType`,{method:e,resultType:n})};if(n===`input_required`){let n=t.inputRequests,r=sh(n)?n:{},i=t.requestState;return Object.keys(r).length===0&&typeof i!=`string`?{kind:`invalid`,error:new X(Y.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:r,...typeof i==`string`&&{requestState:i}}}if(n!==`complete`)return{kind:`invalid`,error:new X(Y.UnsupportedResultType,`Unsupported result type '${n}' for ${e}`,{resultType:n,method:e})};let r=mh(),i=Object.hasOwn(r,e)?r[e]:void 0;if(i!==void 0){let n=i.safeParse(t);if(!n.success)return{kind:`invalid`,error:new X(Y.InvalidResult,`Invalid result for ${e}: ${n.error}`,{method:e})}}let a={...t};return delete a.resultType,{kind:`complete`,result:a}},encodeResult(e,t,n){return Um(Vm(e,Bm(e,dh(e,t))),n)},encodeErrorCode:e=>e===-32002?-32602:e,checkInboundEnvelope(e){if(e.envelope===void 0)return`Request is missing the required _meta envelope for protocol revision 2026-07-28 (io.modelcontextprotocol/protocolVersion, io.modelcontextprotocol/clientCapabilities)`;let t=wm().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(`; `)}`}},ph;function mh(){if(ph)return ph;let e=wm();return ph={"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},ph}var hh=`2026-07-28`;function gh(e){return e!==void 0&&Gp(e)?fh:xm}function _h(e){return e.revision===void 0?e.era===`modern`?fh.era:xm.era:gh(e.revision).era}function vh(e){return bh.some(t=>t.hasRequestMethod(e))}function yh(e){return bh.some(t=>t.hasNotificationMethod(e))}var bh=[xm,fh],xh=Ap({AnnotationsSchema:()=>cl,AudioContentSchema:()=>Vl,BaseMetadataSchema:()=>Lc,BaseRequestParamsSchema:()=>bc,BlobResourceContentsSchema:()=>ol,BooleanSchemaSchema:()=>Su,CallToolRequestParamsSchema:()=>nu,CallToolRequestSchema:()=>ru,CallToolResultSchema:()=>eu,CancelTaskRequestSchema:()=>cd,CancelTaskResultSchema:()=>ld,CancelledNotificationParamsSchema:()=>Nc,CancelledNotificationSchema:()=>Pc,ClientCapabilitiesSchema:()=>Hc,ClientNotificationSchema:()=>dd,ClientRequestSchema:()=>ud,ClientResultSchema:()=>fd,ClientTasksCapabilitySchema:()=>Bc,CompatibilityCallToolResultSchema:()=>tu,CompleteRequestParamsSchema:()=>Uu,CompleteRequestSchema:()=>Wu,CompleteResultSchema:()=>Gu,ContentBlockSchema:()=>Gl,CreateMessageRequestParamsSchema:()=>vu,CreateMessageRequestSchema:()=>yu,CreateMessageResultSchema:()=>bu,CreateMessageResultWithToolsSchema:()=>xu,CreateTaskResultSchema:()=>$u,CursorSchema:()=>gc,DiscoverRequestSchema:()=>Jc,DiscoverResultSchema:()=>Yc,ElicitRequestFormParamsSchema:()=>Pu,ElicitRequestParamsSchema:()=>Iu,ElicitRequestSchema:()=>Lu,ElicitRequestURLParamsSchema:()=>Fu,ElicitResultSchema:()=>Bu,ElicitationCompleteNotificationParamsSchema:()=>Ru,ElicitationCompleteNotificationSchema:()=>zu,EmbeddedResourceSchema:()=>Ul,EmptyResultSchema:()=>Mc,EnumSchemaSchema:()=>Mu,GetPromptRequestParamsSchema:()=>Ll,GetPromptRequestSchema:()=>Rl,GetPromptResultSchema:()=>ql,GetTaskPayloadRequestSchema:()=>id,GetTaskPayloadResultSchema:()=>ad,GetTaskRequestSchema:()=>nd,GetTaskResultSchema:()=>rd,IconSchema:()=>Fc,IconsSchema:()=>Ic,ImageContentSchema:()=>Bl,ImplementationSchema:()=>Rc,InitializeRequestParamsSchema:()=>Uc,InitializeRequestSchema:()=>Wc,InitializeResultSchema:()=>Kc,InitializedNotificationSchema:()=>qc,JSONArraySchema:()=>mc,JSONObjectSchema:()=>K,JSONRPCErrorResponseSchema:()=>kc,JSONRPCMessageSchema:()=>Ac,JSONRPCNotificationSchema:()=>Dc,JSONRPCRequestSchema:()=>Ec,JSONRPCResponseSchema:()=>jc,JSONRPCResultResponseSchema:()=>Oc,JSONValueSchema:()=>pc,LegacyTitledEnumSchemaSchema:()=>Du,ListChangedOptionsBaseSchema:()=>au,ListPromptsRequestSchema:()=>Fl,ListPromptsResultSchema:()=>Il,ListResourceTemplatesRequestSchema:()=>pl,ListResourceTemplatesResultSchema:()=>ml,ListResourcesRequestSchema:()=>dl,ListResourcesResultSchema:()=>fl,ListRootsRequestSchema:()=>qu,ListRootsResultSchema:()=>Ju,ListTasksRequestSchema:()=>od,ListTasksResultSchema:()=>sd,ListToolsRequestSchema:()=>Ql,ListToolsResultSchema:()=>$l,LoggingLevelSchema:()=>ou,LoggingMessageNotificationParamsSchema:()=>lu,LoggingMessageNotificationSchema:()=>uu,ModelHintSchema:()=>du,ModelPreferencesSchema:()=>fu,MultiSelectEnumSchemaSchema:()=>ju,NotificationSchema:()=>Cc,NotificationsParamsSchema:()=>Sc,NumberSchemaSchema:()=>wu,PaginatedRequestParamsSchema:()=>el,PaginatedRequestSchema:()=>tl,PaginatedResultSchema:()=>nl,PingRequestSchema:()=>Xc,PrimitiveSchemaDefinitionSchema:()=>Nu,ProgressNotificationParamsSchema:()=>Qc,ProgressNotificationSchema:()=>$c,ProgressSchema:()=>Zc,ProgressTokenSchema:()=>hc,PromptArgumentSchema:()=>Nl,PromptListChangedNotificationSchema:()=>Jl,PromptMessageSchema:()=>Kl,PromptReferenceSchema:()=>Hu,PromptSchema:()=>Pl,ReadResourceRequestParamsSchema:()=>gl,ReadResourceRequestSchema:()=>_l,ReadResourceResultSchema:()=>vl,RelatedTaskMetadataSchema:()=>vc,RequestIdSchema:()=>Tc,RequestMetaSchema:()=>yc,RequestSchema:()=>q,ResourceContentsSchema:()=>rl,ResourceLinkSchema:()=>Wl,ResourceListChangedNotificationSchema:()=>yl,ResourceRequestParamsSchema:()=>hl,ResourceSchema:()=>ll,ResourceTemplateReferenceSchema:()=>Vu,ResourceTemplateSchema:()=>ul,ResourceUpdatedNotificationParamsSchema:()=>jl,ResourceUpdatedNotificationSchema:()=>Ml,ResultMetaObjectSchema:()=>wc,ResultSchema:()=>J,RoleSchema:()=>sl,RootSchema:()=>Ku,RootsListChangedNotificationSchema:()=>Yu,SamplingContentSchema:()=>hu,SamplingMessageContentBlockSchema:()=>gu,SamplingMessageSchema:()=>_u,ServerCapabilitiesSchema:()=>Gc,ServerNotificationSchema:()=>md,ServerRequestSchema:()=>pd,ServerResultSchema:()=>hd,ServerTasksCapabilitySchema:()=>Vc,SetLevelRequestParamsSchema:()=>su,SetLevelRequestSchema:()=>cu,SingleSelectEnumSchemaSchema:()=>Ou,StringSchemaSchema:()=>Cu,SubscribeRequestParamsSchema:()=>bl,SubscribeRequestSchema:()=>xl,SubscriptionFilterSchema:()=>wl,SubscriptionsAcknowledgedNotificationParamsSchema:()=>Dl,SubscriptionsAcknowledgedNotificationSchema:()=>Ol,SubscriptionsListenRequestParamsSchema:()=>Tl,SubscriptionsListenRequestSchema:()=>El,SubscriptionsListenResultMetaSchema:()=>kl,SubscriptionsListenResultSchema:()=>Al,TaskAugmentedRequestParamsSchema:()=>xc,TaskCreationParamsSchema:()=>Xu,TaskMetadataSchema:()=>_c,TaskSchema:()=>Qu,TaskStatusNotificationParamsSchema:()=>ed,TaskStatusNotificationSchema:()=>td,TaskStatusSchema:()=>Zu,TextContentSchema:()=>zl,TextResourceContentsSchema:()=>il,TitledMultiSelectEnumSchemaSchema:()=>Au,TitledSingleSelectEnumSchemaSchema:()=>Eu,ToolAnnotationsSchema:()=>Yl,ToolChoiceSchema:()=>pu,ToolExecutionSchema:()=>Xl,ToolListChangedNotificationSchema:()=>iu,ToolResultContentSchema:()=>mu,ToolSchema:()=>Zl,ToolUseContentSchema:()=>Hl,UnsubscribeRequestParamsSchema:()=>Sl,UnsubscribeRequestSchema:()=>Cl,UntitledMultiSelectEnumSchemaSchema:()=>ku,UntitledSingleSelectEnumSchemaSchema:()=>Tu}),Sh=e=>Ec.safeParse(e).success,Ch=e=>Dc.safeParse(e).success,wh=e=>Oc.safeParse(e).success,Th=e=>kc.safeParse(e).success,Eh=e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&e.resultType===`input_required`;function Dh(e){if(e.params.ref.type!==`ref/prompt`)throw TypeError(`Expected CompleteRequestPrompt, but got ${e.params.ref.type}`)}function Oh(e){if(e.params.ref.type!==`ref/resource`)throw TypeError(`Expected CompleteRequestResourceTemplate, but got ${e.params.ref.type}`)}var kh=`x-mcp-header`,Ah=/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/,jh=new Set([`string`,`integer`,`boolean`,`number`]);function Mh(e){let t=[],n=new Map,r=(e,i,a)=>{if(typeof e!=`object`||!e)return;let o=e;if(kh in o){if(!a||i.length===0)return`${Fh(i)}: 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 e=o[kh];if(typeof e!=`string`||e.length===0)return`${Fh(i)}: x-mcp-header MUST be a non-empty string`;if(!Ah.test(e))return`${Fh(i)}: x-mcp-header '${e}' is not a valid RFC 9110 token (no spaces, control characters or HTTP delimiters)`;let r=typeof o.type==`string`?o.type:void 0;if(r===void 0||!jh.has(r))return`${Fh(i)}: x-mcp-header is only permitted on primitive-typed properties (string, integer, boolean); got ${r??`<none>`}`;let s=e.toLowerCase(),c=n.get(s);if(c!==void 0)return`x-mcp-header '${e}' is not case-insensitively unique (also declared as '${c}')`;n.set(s,e),t.push({path:i,headerName:e,type:r})}let s=o.properties;if(typeof s==`object`&&s)for(let[e,t]of Object.entries(s)){let n=r(t,[...i,e],a);if(n!==void 0)return n}for(let e of Nh){let t=o[e];if(t===void 0)continue;let n=Array.isArray(t)?t:typeof t==`object`&&t&&Ph.has(e)?Object.values(t):[t];for(let t of n){let n=r(t,[...i,`<${e}>`],!1);if(n!==void 0)return n}}},i=r(e,[],!0);return i===void 0?{valid:!0,declarations:t}:{valid:!1,reason:i}}var Nh=[`items`,`prefixItems`,`contains`,`additionalProperties`,`unevaluatedProperties`,`unevaluatedItems`,`propertyNames`,`patternProperties`,`dependentSchemas`,`oneOf`,`anyOf`,`allOf`,`not`,`if`,`then`,`else`,`$defs`,`definitions`],Ph=new Set([`patternProperties`,`dependentSchemas`,`$defs`,`definitions`]);function Fh(e){return e.length===0?`<root>`:e.join(`.`)}Z.InvalidRequest,Z.UnsupportedProtocolVersion,Z.InvalidParams,Z.MethodNotFound,Z.InvalidParams,Z.MissingRequiredClientCapability,Z.ParseError,Z.InvalidRequest,Z.MethodNotFound,Z.UnsupportedProtocolVersion,Z.MissingRequiredClientCapability;function Ih(e,t){return So(e,t)}function Lh(e){return new Set(e.flatMap(e=>Object.keys(e.shape)))}function Rh(e){if(e==null)return!1;let t=typeof e;return t!==`object`&&t!==`function`||!(`~standard`in e)?!1:typeof e[`~standard`]?.validate==`function`}var zh=!1,Bh=`draft-2020-12`;function Vh(e,t=`input`){let n=e[`~standard`],r;if(n.jsonSchema)r=n.jsonSchema[t]({target:Bh});else if(n.vendor===`zod`){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().`);zh||(zh=!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=go(e,{target:Bh,io:t})}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(t===`output`)return r.type===void 0&&Hh(r)?{type:`object`,...r}:r;if(r.type!==void 0&&r.type!==`object`)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}}function Hh(e){if(`properties`in e||`patternProperties`in e||`additionalProperties`in e||`required`in e)return!0;for(let t of[`oneOf`,`anyOf`,`allOf`]){let n=e[t];if(Array.isArray(n)&&n.length>0)return n.every(e=>typeof e==`object`&&!!e&&(e.type===`object`||Hh(e)))}return!1}function Uh(e){return e.path?.length?`${e.path.map(e=>String(typeof e==`object`?e.key:e)).join(`.`)}: ${e.message}`:e.message}async function Wh(e,t){let n=await e[`~standard`].validate(t);return n.issues&&n.issues.length>0?{success:!1,error:n.issues.map(e=>Uh(e)).join(`, `)}:{success:!0,data:n.value}}function Gh(e){let t=go(e,{target:Bh,io:`input`});return typeof t.pattern==`string`?t.pattern:void 0}var Kh=/\\\.\\d\{(\d+)\}/;function qh(e){let t=Kh.exec(e),n=[void 0,-1,0];return t&&n.push(Number(t[1])),[!1,!0].flatMap(e=>[!1,!0].flatMap(t=>n.map(n=>nc({local:e,offset:t,precision:n}))))}function Jh(e,t){let n;switch(e){case`email`:n=[Vo()];break;case`uri`:n=[Go()];break;case`date`:n=[rc()];break;case`date-time`:n=qh(t)}return new Set(n.map(e=>Gh(e)).filter(e=>e!==void 0))}function Yh(e,t,n){return n!==`zod`||Jh(e,t).has(t)}function Xh(e){let t=Vh(e,`input`),n=t.properties||{},r=t.required||[];return Object.entries(n).map(([e,t])=>({name:e,description:t?.description,required:r.includes(e)}))}function Zh(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Qh(e){try{return Vh(e,`input`)}catch(e){let t=e instanceof Error?e.message:String(e);throw new Q(Z.InvalidParams,`Elicitation requestedSchema must describe an object with flat primitive properties: ${t}`)}}var $h=new Set([`$comment`,`deprecated`,`description`,`examples`,`readOnly`,`title`,`writeOnly`]);function eg(e){return $h.has(e)||e.startsWith(`x-`)}var tg=new Set([`$schema`,...Object.keys(Pu.shape.requestedSchema.shape)]),ng={string:Lh([Cu,Tu,Eu,Du]),number:Lh([wu]),integer:Lh([wu]),boolean:Lh([Su]),array:Lh([ku,Au])},rg=new Set(Cu.shape.format.unwrap().options);function ig(e,t,n,r){if(!Zh(e))return e;let i=typeof e.type==`string`&&Object.hasOwn(ng,e.type)?ng[e.type]:void 0;if(i===void 0)return e;let a={};for(let[o,s]of Object.entries(e))i.has(o)||eg(o)?a[o]=s:o===`pattern`&&e.type===`string`&&typeof e.format==`string`?rg.has(e.format)?(typeof s!=`string`||!Yh(e.format,s,n))&&r.push(`${t}.${o}`):a[o]=s:r.push(`${t}.${o}`);return a}function ag(e,t){let n={},r=[];for(let[i,a]of Object.entries(e))i===`properties`&&Zh(a)?n[i]=Object.fromEntries(Object.entries(a).map(([e,n])=>[e,ig(n,`properties.${e}`,t,r)])):tg.has(i)?n[i]=a:eg(i)||r.push(i);if(r.length>0)throw new Q(Z.InvalidParams,`Elicitation requestedSchema contains unsupported JSON Schema constraint(s) after Standard Schema conversion: ${r.join(`, `)}`);return n}function og(e,t){if(!Zh(e.properties))return t;let n=Object.entries(e.properties).filter(([,e])=>!Ih(Nu,e).success).map(([e])=>`properties.${e}`);return n.length>0?n.join(`, `):t}function sg(e,t,n=``){return Array.isArray(e)&&Array.isArray(t)?e.flatMap((e,r)=>sg(e,t[r],`${n}[${r}]`)):!Zh(e)||!Zh(t)?[]:Object.entries(e).flatMap(([e,r])=>{let i=n?`${n}.${e}`:e;return Object.prototype.hasOwnProperty.call(t,e)?sg(r,t[e],i):eg(e)?[]:[i]})}function cg(e){if(!Rh(e.requestedSchema))return{...e,mode:`form`,requestedSchema:e.requestedSchema};let t=e.requestedSchema[`~standard`].vendor,n=ag(Qh(e.requestedSchema),t),r=Ih(Pu.shape.requestedSchema,n);if(!r.success)throw new Q(Z.InvalidParams,`Elicitation requestedSchema only supports flat primitive properties (string, number, integer, boolean, and string enums): ${og(n,r.error.message)}`);let i=sg(n,r.data);if(i.length>0)throw new Q(Z.InvalidParams,`Elicitation requestedSchema contains unsupported JSON Schema constraint(s) after Standard Schema conversion: ${i.join(`, `)}`);let a=(r.data.required??[]).filter(e=>!Object.prototype.hasOwnProperty.call(r.data.properties,e));if(a.length>0)throw new Q(Z.InvalidParams,`Elicitation requestedSchema lists required properties that are not defined in properties: ${a.join(`, `)}`);return{...e,mode:`form`,requestedSchema:r.data}}function lg(e){let t=e.inputRequests!==void 0&&Object.keys(e.inputRequests).length>0,n=typeof e.requestState==`string`;if(!t&&!n)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`,...e.inputRequests!==void 0&&{inputRequests:e.inputRequests},...e.requestState!==void 0&&{requestState:e.requestState}}}Object.assign(lg,{elicit(e){try{return{method:`elicitation/create`,params:cg(e)}}catch(e){throw e instanceof Q?TypeError(e.message,{cause:e}):e}},elicitUrl(e){return{method:`elicitation/create`,params:{...e,mode:`url`}}},createMessage(e){return{method:`sampling/createMessage`,params:e}},listRoots(){return{method:`roots/list`}}});function ug(e,t){return`Multi-round-trip request '${e}' still required input after ${t} rounds (inputRequired.maxRounds)`}function dg(e,t){return new Promise((n,r)=>{if(t?.aborted){r(t.reason instanceof X?t.reason:new X(Y.RequestTimeout,String(t.reason)));return}let i=setTimeout(()=>{t?.removeEventListener(`abort`,a),n()},e),a=()=>{clearTimeout(i),r(t?.reason instanceof X?t.reason:new X(Y.RequestTimeout,String(t?.reason)))};t?.addEventListener(`abort`,a,{once:!0})})}function fg(e){let t=new AbortController,n=()=>t.abort(e?.reason);return e?.addEventListener(`abort`,n,{once:!0}),e?.aborted&&t.abort(e.reason),{signal:t.signal,abort:e=>t.abort(e),dispose:()=>e?.removeEventListener(`abort`,n)}}var pg=`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`.split(`.`),mg={IdJagTokenExchangeResponseSchema:Sd,OAuthClientInformationFullSchema:Dd,OAuthClientInformationSchema:Ed,OAuthClientMetadataSchema:Td,OAuthClientRegistrationErrorSchema:Od,OAuthErrorResponseSchema:Cd,OAuthMetadataSchema:vd,OAuthProtectedResourceMetadataSchema:_d,OAuthTokenRevocationRequestSchema:kd,OAuthTokensSchema:xd,OpenIdProviderDiscoveryMetadataSchema:bd,OpenIdProviderMetadataSchema:yd},hg={},gg={};function _g(e,t){let n=e.slice(0,-6);hg[n]=t,gg[n]=e=>t.safeParse(e).success}for(let e of pg)_g(e,xh[e]);for(let[e,t]of Object.entries(mg))_g(e,t);Object.freeze(hg),Object.freeze(gg);function vg(e){switch(e){case`initialize`:case`notifications/initialized`:return gh(void 0);case`server/discover`:return gh(hh);default:return}}var yg=[sc,cc,uc,fc],bg=[`inputResponses`,`requestState`];function xg(e,t){let n=e.params;if(!Dg(n))return{message:e,lifted:{}};let r=n._meta,i=Dg(r)?yg.filter(e=>e in r):[],a=t===`request`?bg.filter(e=>e in n):[];if(i.length===0&&a.length===0)return{message:e,lifted:{}};let o={},s={...n};if(i.length>0&&Dg(r)){let e={},t={...r};for(let n of i)e[n]=r[n],delete t[n];o.envelope=e,Object.keys(t).length>0?s._meta=t:delete s._meta}for(let e of a)e===`inputResponses`&&(o.inputResponses=s[e]),e===`requestState`&&(o.requestState=s[e]),delete s[e];return{message:{...e,params:s},lifted:o}}function Sg(e,t){let n=e.validateResult(t,void 0);if(!(!n.ok&&n.reason===`not-in-era`))return{"~standard":{version:1,vendor:`mcp-wire-codec`,validate(n){let r=e.validateResult(t,n);return r.ok?{value:r.value}:{issues:[{message:r.reason===`invalid`?r.message:`not-in-era: ${t}`}]}}}}}function Cg(e){return()=>e}var wg=Cg(void 0);function Tg(e,t){return{...e,mcpReq:{...e.mcpReq,requestState:Cg(t)}}}var Eg=class{_transport;_requestMessageId=0;_requestHandlers=new Map;_requestHandlerAbortControllers=new Map;_notificationHandlers=new Map;_responseHandlers=new Map;_progressHandlers=new Map;_timeoutInfo=new Map;_pendingDebouncedNotifications=new Set;_negotiatedProtocolVersion;_supportedProtocolVersions;onclose;onerror;fallbackRequestHandler;fallbackNotificationHandler;constructor(e){this._options=e,this._supportedProtocolVersions=e?.supportedProtocolVersions??ac,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(t===void 0)return e;let n=e.params??{};return{...e,params:{...n,_meta:{...t,...n._meta}}}}_resolveNonCompleteResult(e,t){return Promise.reject(new X(Y.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){e.params.requestId&&this._requestHandlerAbortControllers.get(e.params.requestId)?.abort(e.params.reason)}_setupTimeout(e,t,n,r,i=!1){this._timeoutInfo.set(e,{timeoutId:setTimeout(r,t),startTime:Date.now(),timeout:t,maxTotalTimeout:n,resetTimeoutOnProgress:i,onTimeout:r})}_resetTimeout(e){let t=this._timeoutInfo.get(e);if(!t)return!1;let n=Date.now()-t.startTime;if(t.maxTotalTimeout&&n>=t.maxTotalTimeout)throw this._timeoutInfo.delete(e),new X(Y.RequestTimeout,`Maximum total timeout exceeded`,{maxTotalTimeout:t.maxTotalTimeout,totalElapsed:n});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 n=this.transport?.onerror;this._transport.onerror=e=>{n?.(e),this._onerror(e)};let r=this._transport?.onmessage;this._transport.onmessage=(e,t)=>{r?.(e,t),wh(e)||Th(e)?this._onresponse(e):Sh(e)?this._onrequest(e,t):Ch(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;this._responseHandlers=new Map,this._progressHandlers.clear(),this._pendingDebouncedNotifications.clear();for(let e of this._timeoutInfo.values())clearTimeout(e.timeoutId);this._timeoutInfo.clear();let t=this._requestHandlerAbortControllers;this._requestHandlerAbortControllers=new Map;let n=new X(Y.ConnectionClosed,`Connection closed`);this._transport=void 0;try{this.onclose?.()}finally{for(let t of e.values())t(n);for(let e of t.values())e.abort(n)}}_onerror(e){this.onerror?.(e)}_onnotification(e,t){let{message:n}=xg(e,`notification`),r=this._negotiatedWireCodec();if(t?.classification===void 0&&this._shouldDropInbound(e)===`drop`)return;if(t?.classification!==void 0){let e=_h(t.classification);if(e!==r.era){this._onerror(Error(`Era mismatch on inbound notification '${n.method}': classified as ${e} but this instance serves ${r.era}`));return}}if(yh(n.method)&&!r.hasNotificationMethod(n.method))return;let i=this._notificationHandlers.get(n.method),a=this.fallbackNotificationHandler;(i!==void 0||a!==void 0)&&Promise.resolve().then(()=>i===void 0?a(n):i(n,r)).catch(e=>this._onerror(Error(`Uncaught error in notification handler: ${e}`)))}_onrequest(e,t){let{message:n,lifted:r}=xg(e,`request`),i=this._negotiatedWireCodec();if(t?.classification===void 0&&this._shouldDropInbound(e)===`drop`){this._onerror(Error(`Dropped inbound request '${e.method}': not servable on this connection's protocol era`));return}let a=this._transport,o=(e,t,r)=>{let i={jsonrpc:`2.0`,id:n.id,error:{code:e,message:t,...r!==void 0&&{data:r}}};a?.send(i).catch(e=>this._onerror(Error(`Failed to send an error response: ${e}`)))};if(t?.classification!==void 0){let e=_h(t.classification);if(e!==i.era){this._onerror(Error(`Era mismatch on inbound request '${n.method}': classified as ${e} but this instance serves ${i.era}`));let r=t.classification.revision??e;o(Z.UnsupportedProtocolVersion,`Unsupported protocol version: ${r}`,{supported:this._supportedProtocolVersions,requested:r});return}}if(vh(n.method)&&!i.hasRequestMethod(n.method)){o(Z.MethodNotFound,`Method not found`);return}let s=this._requestHandlers.get(n.method)??this.fallbackRequestHandler;if(s===void 0){o(Z.MethodNotFound,`Method not found`);return}let c=i.checkInboundEnvelope(r);if(c!==void 0){o(Z.InvalidParams,c);return}let l=(e,t)=>this._notificationViaCodec(this._resolveOutboundCodec(e.method),e,{...t,relatedRequestId:n.id}),u=(e,t,r)=>this._requestWithSchemaViaCodec(this._resolveOutboundCodec(e.method),e,t,{...r,relatedRequestId:n.id}),d=new AbortController;this._requestHandlerAbortControllers.set(n.id,d);let f=r.inputResponses===void 0?void 0:Ag(r.inputResponses),p={sessionId:a?.sessionId,mcpReq:{id:n.id,method:n.method,_meta:n.params?._meta,...r.envelope!==void 0&&{envelope:r.envelope},...f!==void 0&&{inputResponses:f.accepted},...f!==void 0&&f.droppedKeys.length>0&&{droppedInputResponseKeys:f.droppedKeys},requestState:r.requestState===void 0?wg:Cg(r.requestState),signal:d.signal,send:((e,t,n)=>{let r=this._resolveOutboundCodec(e.method);if(this._assertOutboundRequestInEra(r,e.method),Rh(t))return u(e,t,n);let i=Sg(r,e.method);if(i===void 0)throw TypeError(`'${e.method}' is not a spec method; pass a result schema as the second argument to ctx.mcpReq.send().`);return u(e,i,t)}),notify:l},http:t?.authInfo?{authInfo:t.authInfo}:void 0},m=this.buildContext(p,t);Promise.resolve().then(()=>s(n,m)).then(async e=>{if(d.signal.aborted)return;let t;try{t=i.encodeResult(n.method,e,this._outboundServerInfo())}catch(e){this._onerror(Error(`Failed to encode result for ${n.method}: ${e}`)),o(Z.InternalError,`Internal error`);return}let r={result:t,jsonrpc:`2.0`,id:n.id};await a?.send(r)},async e=>{if(d.signal.aborted)return;let t=Number.isSafeInteger(e.code)?e.code:Z.InternalError,r={jsonrpc:`2.0`,id:n.id,error:{code:i.encodeErrorCode(t),message:e.message??`Internal error`,...e.data!==void 0&&{data:e.data}}};await a?.send(r)}).catch(e=>this._onerror(Error(`Failed to send response: ${e}`))).finally(()=>{this._requestHandlerAbortControllers.get(n.id)===d&&this._requestHandlerAbortControllers.delete(n.id)})}_onprogress(e){let{progressToken:t,...n}=e.params,r=Number(t),i=this._progressHandlers.get(r);if(!i){this._onerror(Error(`Received a progress notification for an unknown token: ${JSON.stringify(e)}`));return}let a=this._responseHandlers.get(r),o=this._timeoutInfo.get(r);if(o&&a&&o.resetTimeoutOnProgress)try{this._resetTimeout(r)}catch(e){this._responseHandlers.delete(r),this._progressHandlers.delete(r),this._cleanupTimeout(r),a(e);return}i(n)}_onresponse(e){let t=Number(e.id),n=this._responseHandlers.get(t);if(n===void 0){this._onerror(Error(`Received a response for an unknown message ID: ${JSON.stringify(e)}`));return}this._responseHandlers.delete(t),this._cleanupTimeout(t),this._progressHandlers.delete(t),wh(e)?n(e):n(Q.fromError(e.error.code,e.error.message,e.error.data))}get transport(){return this._transport}async close(){await this._transport?.close()}request(e,t,n){let r=this._resolveOutboundCodec(e.method);if(this._assertOutboundRequestInEra(r,e.method),Rh(t))return this._requestWithSchemaViaCodec(r,e,t,n);let i=Sg(r,e.method);if(i===void 0)throw TypeError(`'${e.method}' is not a spec method; pass a result schema as the second argument to request().`);return this._requestWithSchemaViaCodec(r,e,i,t)}_negotiatedWireCodec(){return gh(this._negotiatedProtocolVersion)}_wireCodec(){return this._negotiatedWireCodec()}_resolveOutboundCodec(e){if(this._negotiatedProtocolVersion===void 0){let t=vg(e);if(t)return t}return this._negotiatedWireCodec()}_assertOutboundRequestInEra(e,t){if(vh(t)&&!e.hasRequestMethod(t))throw new X(Y.MethodNotSupportedByProtocolVersion,`Method '${t}' is not supported by the negotiated protocol version (wire era ${e.era})`,{method:t,era:e.era})}_requestWithSchema(e,t,n){let r=this._resolveOutboundCodec(e.method);return this._assertOutboundRequestInEra(r,e.method),this._requestWithSchemaViaCodec(r,e,t,n)}_requestWithSchemaViaCodec(e,t,n,r){let{relatedRequestId:i,resumptionToken:a,onresumptiontoken:o,headers:s}=r??{},c=Date.now(),l,u;return new Promise((d,f)=>{let p=e=>{f(e)};if(!this._transport){p(Error(`Not connected`));return}if(this._options?.enforceStrictCapabilities===!0)try{this.assertCapabilityForMethod(t.method)}catch(e){p(e);return}if(r?.signal?.aborted){let e=r.signal.reason;throw e instanceof X?e:new X(Y.RequestTimeout,String(e))}let m=e.era===`2026-07-28`&&this._transport.hasPerRequestStream===!0?new AbortController:void 0,h=this._requestMessageId++;u=h;let g={...t,jsonrpc:`2.0`,id:h};r?.onprogress&&(this._progressHandlers.set(h,r.onprogress),g.params={...t.params,_meta:{...t.params?._meta,progressToken:h}});let ee=this._envelopeOutbound(g),te=!1,_=e=>{te||(this._progressHandlers.delete(h),m===void 0?this._transport?.send(this._envelopeOutbound({jsonrpc:`2.0`,method:`notifications/cancelled`,params:{requestId:h,reason:String(e)}}),{relatedRequestId:i,resumptionToken:a,onresumptiontoken:o}).catch(e=>this._onerror(Error(`Failed to send cancellation: ${e}`))):m.abort(),f(e instanceof X?e:new X(Y.RequestTimeout,String(e))))};this._responseHandlers.set(h,i=>{if(r?.signal?.aborted)return;if(te=!0,i instanceof Error)return f(i);let a;try{a=e.decodeResult(t.method,i.result)}catch(e){return f(e instanceof Error?e:Error(String(e)))}if(a.kind===`invalid`)return f(a.error);if(a.kind===`input_required`){if(r?.allowInputRequired===!0)return d(jg(a));let i={codec:e,request:t,resultSchema:n,options:r,flowStartedAt:c,retry:(r,i)=>this._requestWithSchemaViaCodec(e,r===void 0?{method:t.method}:{method:t.method,params:r},n,i)};return d(this._resolveNonCompleteResult(a,i))}let o=a.result;Wh(n,o).then(e=>{e.success?d(e.data):f(new X(Y.InvalidResult,`Invalid result for ${t.method}: ${e.error}`))},f)}),l=()=>_(r?.signal?.reason),r?.signal?.addEventListener(`abort`,l,{once:!0});let v=r?.timeout??6e4;this._setupTimeout(h,v,r?.maxTotalTimeout,()=>_(new X(Y.RequestTimeout,`Request timed out`,{timeout:v})),r?.resetTimeoutOnProgress??!1),this._transport.send(ee,{relatedRequestId:i,resumptionToken:a,onresumptiontoken:o,headers:s,requestSignal:m?.signal}).catch(e=>{this._progressHandlers.delete(h),f(e)})}).finally(()=>{l&&r?.signal?.removeEventListener(`abort`,l),u!==void 0&&(this._responseHandlers.delete(u),this._cleanupTimeout(u))})}async notification(e,t){return this._notificationViaCodec(this._resolveOutboundCodec(e.method),e,t)}async _notificationViaCodec(e,t,n){if(!this._transport)throw new X(Y.NotConnected,`Not connected`);if(yh(t.method)&&!e.hasNotificationMethod(t.method))throw new X(Y.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 r=this._envelopeOutbound({jsonrpc:`2.0`,...t});if((this._options?.debouncedNotificationMethods??[]).includes(t.method)&&!t.params&&!n?.relatedRequestId){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(r,n).catch(e=>this._onerror(e))});return}await this._transport.send(r,n)}setRequestHandler(e,t,n){this.assertRequestHandlerCapability(e);let r;if(typeof t==`function`){if(!vh(e))throw TypeError(`'${e}' is not a spec request method; pass schemas as the second argument to setRequestHandler().`);r=(n,r)=>{let i=this._negotiatedWireCodec(),a=i.validateRequest(e,n);if(!a.ok&&a.reason===`not-in-era`&&(a=i.validateInputRequest(e,n)),!a.ok)throw a.reason===`not-in-era`?new Q(Z.InternalError,`No wire schema for ${e} in the resolved era`):Error(a.message);return Promise.resolve(t(a.value,r))}}else if(n)r=async(r,i)=>{let a=await Wh(t.params,{...r.params});if(!a.success)throw new Q(Z.InvalidParams,`Invalid params for ${e}: ${a.error}`);return n(a.data,i)};else throw TypeError(`setRequestHandler: handler is required`);this._requestHandlers.set(e,this._wrapHandler(e,r))}_wrapHandler(e,t){return t}_outboundServerInfo(){}removeRequestHandler(e){this._requestHandlers.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,n){if(typeof t==`function`){if(!yh(e))throw TypeError(`'${e}' is not a spec notification method; pass schemas as the second argument to setNotificationHandler().`);this._notificationHandlers.set(e,(n,r)=>{let i=r.validateNotification(e,n);if(!i.ok)throw i.reason===`not-in-era`?new Q(Z.InternalError,`No wire schema for ${e} in the resolved era`):Error(i.message);return Promise.resolve(t(i.value))});return}if(!n)throw TypeError(`setNotificationHandler: handler is required`);this._notificationHandlers.set(e,async r=>{let i=await Wh(t.params,{...r.params});if(!i.success)throw new Q(Z.InvalidParams,`Invalid params for notification ${e}: ${i.error}`);await n(i.data,r)})}removeNotificationHandler(e){this._notificationHandlers.delete(e)}};function Dg(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Og(e,t){let n={...e};for(let e in t){let r=e,i=t[r];if(i===void 0)continue;let a=n[r];n[r]=Dg(a)&&Dg(i)?{...a,...i}:i}return n}function kg(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Ag(e){let t={},n=[];if(!kg(e))return{accepted:t,droppedKeys:n};for(let[r,i]of Object.entries(e)){if(!kg(i)||`method`in i||`result`in i){n.push(r);continue}t[r]=i}return{accepted:t,droppedKeys:n}}function jg(e){return{resultType:`input_required`,inputRequests:e.inputRequests,...e.requestState!==void 0&&{requestState:e.requestState}}}kp((e=>{var t=/; *([!#$%&'*+.^_`|~0-9A-Za-z-]+) *= *("(?:[\u000b\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\u000b\u0020-\u00ff])*"|[!#$%&'*+.^_`|~0-9A-Za-z-]+) */g,n=/\\([\u000b\u0020-\u00ff])/g,r=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/;e.parse=i;function i(e){if(!e)throw TypeError(`argument string is required`);var i=typeof e==`object`?a(e):e;if(typeof i!=`string`)throw TypeError(`argument string is required to be a string`);var s=i.indexOf(`;`),c=s===-1?i.trim():i.slice(0,s).trim();if(!r.test(c))throw TypeError(`invalid media type`);var l=new o(c.toLowerCase());if(s!==-1){var u,d,f;for(t.lastIndex=s;d=t.exec(i);){if(d.index!==s)throw TypeError(`invalid parameter format`);s+=d[0].length,u=d[1].toLowerCase(),f=d[2],f.charCodeAt(0)===34&&(f=f.slice(1,-1),f.indexOf(`\\`)!==-1&&(f=f.replace(n,`$1`))),l.parameters[u]=f}if(s!==i.length)throw TypeError(`invalid parameter format`)}return l}function a(e){var t;if(typeof e.getHeader==`function`?t=e.getHeader(`content-type`):typeof e.headers==`object`&&(t=e.headers&&e.headers[`content-type`]),typeof t!=`string`)throw TypeError(`content-type header is missing from object`);return t}function o(e){this.parameters=Object.create(null),this.type=e}}))();var Mg=/^[A-Za-z0-9._-]{1,128}$/;function Ng(e){let t=[];if(e.length===0)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`),!Mg.test(e)){let n=[...e].filter(e=>!/[A-Za-z0-9._-]/.test(e)).filter((e,t,n)=>n.indexOf(e)===t);return t.push(`Tool name contains invalid characters: ${n.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}}function Pg(e,t){if(t.length>0){console.warn(`Tool name validation warning for "${e}":`);for(let e of t)console.warn(` - ${e}`);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.`)}}function Fg(e){let t=Ng(e);return Pg(e,t.warnings),t.isValid}var Ig=1e6,Lg=1e6,Rg=1e4,zg=1e6,Bg=class e{static isTemplate(e){return/\{[^}\s]+\}/.test(e)}static validateLength(e,t,n){if(e.length>t)throw Error(`${n} exceeds maximum length of ${t} characters (got ${e.length})`)}template;parts;get variableNames(){return this.parts.flatMap(e=>typeof e==`string`?[]:e.names)}constructor(t){e.validateLength(t,Ig,`Template`),this.template=t,this.parts=this.parse(t)}toString(){return this.template}parse(t){let n=[],r=``,i=0,a=0;for(;i<t.length;)if(t[i]===`{`){r&&=(n.push(r),``);let o=t.indexOf(`}`,i);if(o===-1)throw Error(`Unclosed template expression`);if(a++,a>Rg)throw Error(`Template contains too many expressions (max ${Rg})`);let s=t.slice(i+1,o),c=this.getOperator(s),l=s.includes(`*`),u=this.getNames(s),d=u[0];for(let t of u)e.validateLength(t,Lg,`Variable name`);n.push({name:d,operator:c,names:u,exploded:l}),i=o+1}else r+=t[i],i++;return r&&n.push(r),n}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,n){return e.validateLength(t,Lg,`Variable value`),n===`+`||n===`#`?encodeURI(t):encodeURIComponent(t)}expandPart(e,t){if(e.operator===`?`||e.operator===`&`){let n=e.names.map(n=>{let r=t[n];return r===void 0?``:`${n}=${Array.isArray(r)?r.map(t=>this.encodeValue(t,e.operator)).join(`,`):this.encodeValue(r.toString(),e.operator)}`}).filter(e=>e.length>0);return n.length===0?``:(e.operator===`?`?`?`:`&`)+n.join(`&`)}if(e.names.length>1){let n=e.names.map(e=>t[e]).filter(e=>e!==void 0);return n.length===0?``:n.map(e=>Array.isArray(e)?e[0]:e).join(`,`)}let n=t[e.name];if(n===void 0)return``;let r=(Array.isArray(n)?n:[n]).map(t=>this.encodeValue(t,e.operator));switch(e.operator){case``:return r.join(`,`);case`+`:return r.join(`,`);case`#`:return`#`+r.join(`,`);case`.`:return`.`+r.join(`.`);case`/`:return`/`+r.join(`/`);default:return r.join(`,`)}}expand(e){let t=``,n=!1;for(let r of this.parts){if(typeof r==`string`){t+=r;continue}let i=this.expandPart(r,e);i&&(t+=(r.operator===`?`||r.operator===`&`)&&n?i.replace(`?`,`&`):i,(r.operator===`?`||r.operator===`&`)&&(n=!0))}return t}escapeRegExp(e){return e.replaceAll(/[.*+?^${}()|[\]\\]/g,String.raw`\$&`)}partToRegExp(t){let n=[];for(let n of t.names)e.validateLength(n,Lg,`Variable name`);if(t.operator===`?`||t.operator===`&`){for(let e=0;e<t.names.length;e++){let r=t.names[e],i=e===0?`\\`+t.operator:`&`;n.push({pattern:i+this.escapeRegExp(r)+`=([^&]+)`,name:r})}return n}let r,i=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 n.push({pattern:r,name:i}),n}match(t){e.validateLength(t,Ig,`URI`);let n=`^`,r=[];for(let e of this.parts)if(typeof e==`string`)n+=this.escapeRegExp(e);else{let t=this.partToRegExp(e);for(let{pattern:i,name:a}of t)n+=i,r.push({name:a,exploded:e.exploded})}n+=`$`,e.validateLength(n,zg,`Generated regex pattern`);let i=new RegExp(n),a=t.match(i);if(!a)return null;let o={};for(let[e,t]of r.entries()){let{name:n,exploded:r}=t,i=a[e+1],s=n.replace(`*`,``);o[s]=r&&i.includes(`,`)?i.split(`,`):i}return o}};function Vg(e){return typeof e==`object`&&!!e&&`_zod`in e}function Hg(e){return typeof e==`object`&&!!e&&!(`_zod`in e)&&`_def`in e&&typeof e._def?.typeName==`string`}function Ug(e){if(typeof e!=`object`||!e||Rh(e))return!1;let t=Object.getPrototypeOf(e);return t!==Object.prototype&&t!==null?!1:Object.values(e).every(e=>Vg(e))}function Wg(e){if(e!==void 0){if(Ug(e))return z(e);if(typeof e==`object`&&e&&!Rh(e)&&Object.values(e).some(e=>Hg(e)))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(!Rh(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 Gg(e,t){let n=t.getValidator(e);return{"~standard":{version:1,vendor:`mcp`,jsonSchema:{input:()=>e,output:()=>e},validate:e=>{let t=n(e);return t.valid?{value:t.data}:{issues:[{message:t.errorMessage}]}}}}}function Kg(e,t){let n=typeof e;if(n!==typeof t)return!1;if(Array.isArray(e)){if(!Array.isArray(t))return!1;let n=e.length;if(n!==t.length)return!1;for(let r=0;r<n;r++)if(!Kg(e[r],t[r]))return!1;return!0}if(n===`object`){if(!e||!t)return e===t;let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let r of n)if(!Kg(e[r],t[r]))return!1;return!0}return e===t}function qg(e){return encodeURI(Jg(e))}function Jg(e){return e.replace(/~/g,`~0`).replace(/\//g,`~1`)}var Yg={prefixItems:!0,items:!0,allOf:!0,anyOf:!0,oneOf:!0},Xg={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependentSchemas:!0},Zg={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},Qg=typeof self<`u`&&self.location&&self.location.origin!==`null`?new URL(self.location.origin+self.location.pathname+location.search):new URL(`https://github.com/cfworker`);function $g(e,t=Object.create(null),n=Qg,r=``){if(e&&typeof e==`object`&&!Array.isArray(e)){let i=e.$id||e.id;if(i){let a=new URL(i,n.href);a.hash.length>1?t[a.href]=e:(a.hash=``,r===``?n=a:$g(e,t,n))}}else if(e!==!0&&e!==!1)return t;let i=n.href+(r?`#`+r:``);if(t[i]!==void 0)throw Error(`Duplicate schema URI "${i}".`);if(t[i]=e,e===!0||e===!1)return t;if(e.__absolute_uri__===void 0&&Object.defineProperty(e,"__absolute_uri__",{enumerable:!1,value:i}),e.$ref&&e.__absolute_ref__===void 0){let t=new URL(e.$ref,n.href);t.hash=t.hash,Object.defineProperty(e,"__absolute_ref__",{enumerable:!1,value:t.href})}if(e.$recursiveRef&&e.__absolute_recursive_ref__===void 0){let t=new URL(e.$recursiveRef,n.href);t.hash=t.hash,Object.defineProperty(e,"__absolute_recursive_ref__",{enumerable:!1,value:t.href})}if(e.$anchor){let r=new URL(`#`+e.$anchor,n.href);t[r.href]=e}for(let i in e){if(Zg[i])continue;let a=`${r}/${qg(i)}`,o=e[i];if(Array.isArray(o)){if(Yg[i]){let e=o.length;for(let r=0;r<e;r++)$g(o[r],t,n,`${a}/${r}`)}}else if(Xg[i])for(let e in o)$g(o[e],t,n,`${a}/${qg(e)}`);else $g(o,t,n,a)}return t}var e_=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,t_=[0,31,28,31,30,31,30,31,31,30,31,30,31],n_=/^(\d\d):(\d\d):(\d\d)(\.\d+)?(z|[+-]\d\d(?::?\d\d)?)?$/i,r_=/^(?=.{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,i_=/^(?:[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,a_=/^(?:(?:[^\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,o_=/^(?:(?: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,s_=/^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i,c_=/^(?:\/(?:[^~/]|~0|~1)*)*$/,l_=/^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i,u_=/^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/,d_=e=>{if(e[0]===`"`)return!1;let[t,n,...r]=e.split(`@`);return!t||!n||r.length!==0||t.length>64||n.length>253||t[0]===`.`||t.endsWith(`.`)||t.includes(`..`)||!/^[a-z0-9.-]+$/i.test(n)||!/^[a-z0-9.!#$%&'*+/=?^_`{|}~-]+$/i.test(t)?!1:n.split(`.`).every(e=>/^[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?$/i.test(e))},f_=/^(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)$/,p_=/^((([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,m_=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));function h_(e){return e.test.bind(e)}var g_={date:v_,time:y_.bind(void 0,!1),"date-time":x_,duration:m_,uri:w_,"uri-reference":h_(i_),"uri-template":h_(a_),url:h_(o_),email:d_,hostname:h_(r_),ipv4:h_(f_),ipv6:h_(p_),regex:E_,uuid:h_(s_),"json-pointer":h_(c_),"json-pointer-uri-fragment":h_(l_),"relative-json-pointer":h_(u_)};function __(e){return e%4==0&&(e%100!=0||e%400==0)}function v_(e){let t=e.match(e_);if(!t)return!1;let n=+t[1],r=+t[2],i=+t[3];return r>=1&&r<=12&&i>=1&&i<=(r==2&&__(n)?29:t_[r])}function y_(e,t){let n=t.match(n_);if(!n)return!1;let r=+n[1],i=+n[2],a=+n[3],o=!!n[5];return(r<=23&&i<=59&&a<=59||r==23&&i==59&&a==60)&&(!e||o)}var b_=/t|\s/i;function x_(e){let t=e.split(b_);return t.length==2&&v_(t[0])&&y_(!0,t[1])}var S_=/\/|:/,C_=/^(?:[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;function w_(e){return S_.test(e)&&C_.test(e)}var T_=/[^\\]\\Z/;function E_(e){if(T_.test(e))return!1;try{return new RegExp(e,`u`),!0}catch{return!1}}function D_(e){let t=0,n=e.length,r=0,i;for(;r<n;)t++,i=e.charCodeAt(r++),i>=55296&&i<=56319&&r<n&&(i=e.charCodeAt(r),(i&64512)==56320&&r++);return t}function $(e,t,n=`2019-09`,r=$g(t),i=!0,a=null,o=`#`,s=`#`,c=Object.create(null)){if(t===!0)return{valid:!0,errors:[]};if(t===!1)return{valid:!1,errors:[{instanceLocation:o,keyword:`false`,keywordLocation:o,error:`False boolean schema.`}]};let l=typeof e,u;switch(l){case`boolean`:case`number`:case`string`:u=l;break;case`object`:u=e===null?`null`:Array.isArray(e)?`array`:`object`;break;default:throw Error(`Instances of "${l}" type are not supported.`)}let{$ref:d,$recursiveRef:f,$recursiveAnchor:p,type:m,const:h,enum:g,required:ee,not:te,anyOf:_,allOf:v,oneOf:y,if:ne,then:re,else:ie,format:ae,properties:oe,patternProperties:se,additionalProperties:ce,unevaluatedProperties:le,minProperties:ue,maxProperties:de,propertyNames:fe,dependentRequired:pe,dependentSchemas:me,dependencies:he,prefixItems:ge,items:b,additionalItems:_e,unevaluatedItems:ve,contains:ye,minContains:x,maxContains:S,minItems:be,maxItems:xe,uniqueItems:Se,minimum:Ce,maximum:we,exclusiveMinimum:Te,exclusiveMaximum:C,multipleOf:Ee,minLength:w,maxLength:De,pattern:Oe,__absolute_ref__:ke,__absolute_recursive_ref__:Ae}=t,T=[];if(p===!0&&a===null&&(a=t),f===`#`){let l=a===null?r[Ae]:a,u=`${s}/$recursiveRef`,d=$(e,a===null?t:a,n,r,i,l,o,u,c);d.valid||T.push({instanceLocation:o,keyword:`$recursiveRef`,keywordLocation:u,error:`A subschema had errors.`},...d.errors)}if(d!==void 0){let t=r[ke||d];if(t===void 0){let e=`Unresolved $ref "${d}".`;throw ke&&ke!==d&&(e+=` Absolute URI "${ke}".`),e+=`\nKnown schemas:\n- ${Object.keys(r).join(`
51
- - `)}`,Error(e)}let l=`${s}/$ref`,u=$(e,t,n,r,i,a,o,l,c);if(u.valid||T.push({instanceLocation:o,keyword:`$ref`,keywordLocation:l,error:`A subschema had errors.`},...u.errors),n===`4`||n===`7`)return{valid:T.length===0,errors:T}}if(Array.isArray(m)){let t=m.length,n=!1;for(let r=0;r<t;r++)if(u===m[r]||m[r]===`integer`&&u===`number`&&e%1==0&&e===e){n=!0;break}n||T.push({instanceLocation:o,keyword:`type`,keywordLocation:`${s}/type`,error:`Instance type "${u}" is invalid. Expected "${m.join(`", "`)}".`})}else m===`integer`?(u!==`number`||e%1||e!==e)&&T.push({instanceLocation:o,keyword:`type`,keywordLocation:`${s}/type`,error:`Instance type "${u}" is invalid. Expected "${m}".`}):m!==void 0&&u!==m&&T.push({instanceLocation:o,keyword:`type`,keywordLocation:`${s}/type`,error:`Instance type "${u}" is invalid. Expected "${m}".`});if(h!==void 0&&(u===`object`||u===`array`?Kg(e,h)||T.push({instanceLocation:o,keyword:`const`,keywordLocation:`${s}/const`,error:`Instance does not match ${JSON.stringify(h)}.`}):e!==h&&T.push({instanceLocation:o,keyword:`const`,keywordLocation:`${s}/const`,error:`Instance does not match ${JSON.stringify(h)}.`})),g!==void 0&&(u===`object`||u===`array`?g.some(t=>Kg(e,t))||T.push({instanceLocation:o,keyword:`enum`,keywordLocation:`${s}/enum`,error:`Instance does not match any of ${JSON.stringify(g)}.`}):g.some(t=>e===t)||T.push({instanceLocation:o,keyword:`enum`,keywordLocation:`${s}/enum`,error:`Instance does not match any of ${JSON.stringify(g)}.`})),te!==void 0){let t=`${s}/not`;$(e,te,n,r,i,a,o,t).valid&&T.push({instanceLocation:o,keyword:`not`,keywordLocation:t,error:`Instance matched "not" schema.`})}let je=[];if(_!==void 0){let t=`${s}/anyOf`,l=T.length,u=!1;for(let s=0;s<_.length;s++){let l=_[s],d=Object.create(c),f=$(e,l,n,r,i,p===!0?a:null,o,`${t}/${s}`,d);T.push(...f.errors),u||=f.valid,f.valid&&je.push(d)}u?T.length=l:T.splice(l,0,{instanceLocation:o,keyword:`anyOf`,keywordLocation:t,error:`Instance does not match any subschemas.`})}if(v!==void 0){let t=`${s}/allOf`,l=T.length,u=!0;for(let s=0;s<v.length;s++){let l=v[s],d=Object.create(c),f=$(e,l,n,r,i,p===!0?a:null,o,`${t}/${s}`,d);T.push(...f.errors),u&&=f.valid,f.valid&&je.push(d)}u?T.length=l:T.splice(l,0,{instanceLocation:o,keyword:`allOf`,keywordLocation:t,error:`Instance does not match every subschema.`})}if(y!==void 0){let t=`${s}/oneOf`,l=T.length,u=y.filter((s,l)=>{let u=Object.create(c),d=$(e,s,n,r,i,p===!0?a:null,o,`${t}/${l}`,u);return T.push(...d.errors),d.valid&&je.push(u),d.valid}).length;u===1?T.length=l:T.splice(l,0,{instanceLocation:o,keyword:`oneOf`,keywordLocation:t,error:`Instance does not match exactly one subschema (${u} matches).`})}if((u===`object`||u===`array`)&&Object.assign(c,...je),ne!==void 0){let t=`${s}/if`;if($(e,ne,n,r,i,a,o,t,c).valid){if(re!==void 0){let l=$(e,re,n,r,i,a,o,`${s}/then`,c);l.valid||T.push({instanceLocation:o,keyword:`if`,keywordLocation:t,error:`Instance does not match "then" schema.`},...l.errors)}}else if(ie!==void 0){let l=$(e,ie,n,r,i,a,o,`${s}/else`,c);l.valid||T.push({instanceLocation:o,keyword:`if`,keywordLocation:t,error:`Instance does not match "else" schema.`},...l.errors)}}if(u===`object`){if(ee!==void 0)for(let t of ee)t in e||T.push({instanceLocation:o,keyword:`required`,keywordLocation:`${s}/required`,error:`Instance does not have required property "${t}".`});let t=Object.keys(e);if(ue!==void 0&&t.length<ue&&T.push({instanceLocation:o,keyword:`minProperties`,keywordLocation:`${s}/minProperties`,error:`Instance does not have at least ${ue} properties.`}),de!==void 0&&t.length>de&&T.push({instanceLocation:o,keyword:`maxProperties`,keywordLocation:`${s}/maxProperties`,error:`Instance does not have at least ${de} properties.`}),fe!==void 0){let t=`${s}/propertyNames`;for(let s in e){let e=`${o}/${qg(s)}`,c=$(s,fe,n,r,i,a,e,t);c.valid||T.push({instanceLocation:o,keyword:`propertyNames`,keywordLocation:t,error:`Property name "${s}" does not match schema.`},...c.errors)}}if(pe!==void 0){let t=`${s}/dependantRequired`;for(let n in pe)if(n in e){let r=pe[n];for(let i of r)i in e||T.push({instanceLocation:o,keyword:`dependentRequired`,keywordLocation:t,error:`Instance has "${n}" but does not have "${i}".`})}}if(me!==void 0)for(let t in me){let l=`${s}/dependentSchemas`;if(t in e){let s=$(e,me[t],n,r,i,a,o,`${l}/${qg(t)}`,c);s.valid||T.push({instanceLocation:o,keyword:`dependentSchemas`,keywordLocation:l,error:`Instance has "${t}" but does not match dependant schema.`},...s.errors)}}if(he!==void 0){let t=`${s}/dependencies`;for(let s in he)if(s in e){let c=he[s];if(Array.isArray(c))for(let n of c)n in e||T.push({instanceLocation:o,keyword:`dependencies`,keywordLocation:t,error:`Instance has "${s}" but does not have "${n}".`});else{let l=$(e,c,n,r,i,a,o,`${t}/${qg(s)}`);l.valid||T.push({instanceLocation:o,keyword:`dependencies`,keywordLocation:t,error:`Instance has "${s}" but does not match dependant schema.`},...l.errors)}}}let l=Object.create(null),u=!1;if(oe!==void 0){let t=`${s}/properties`;for(let s in oe){if(!(s in e))continue;let d=`${o}/${qg(s)}`,f=$(e[s],oe[s],n,r,i,a,d,`${t}/${qg(s)}`);if(f.valid)c[s]=l[s]=!0;else if(u=i,T.push({instanceLocation:o,keyword:`properties`,keywordLocation:t,error:`Property "${s}" does not match schema.`},...f.errors),u)break}}if(!u&&se!==void 0){let t=`${s}/patternProperties`;for(let s in se){let d=new RegExp(s,`u`),f=se[s];for(let p in e){if(!d.test(p))continue;let m=`${o}/${qg(p)}`,h=$(e[p],f,n,r,i,a,m,`${t}/${qg(s)}`);h.valid?c[p]=l[p]=!0:(u=i,T.push({instanceLocation:o,keyword:`patternProperties`,keywordLocation:t,error:`Property "${p}" matches pattern "${s}" but does not match associated schema.`},...h.errors))}}}if(!u&&ce!==void 0){let t=`${s}/additionalProperties`;for(let s in e){if(l[s])continue;let d=`${o}/${qg(s)}`,f=$(e[s],ce,n,r,i,a,d,t);f.valid?c[s]=!0:(u=i,T.push({instanceLocation:o,keyword:`additionalProperties`,keywordLocation:t,error:`Property "${s}" does not match additional properties schema.`},...f.errors))}}else if(!u&&le!==void 0){let t=`${s}/unevaluatedProperties`;for(let s in e)if(!c[s]){let l=`${o}/${qg(s)}`,u=$(e[s],le,n,r,i,a,l,t);u.valid?c[s]=!0:T.push({instanceLocation:o,keyword:`unevaluatedProperties`,keywordLocation:t,error:`Property "${s}" does not match unevaluated properties schema.`},...u.errors)}}}else if(u===`array`){xe!==void 0&&e.length>xe&&T.push({instanceLocation:o,keyword:`maxItems`,keywordLocation:`${s}/maxItems`,error:`Array has too many items (${e.length} > ${xe}).`}),be!==void 0&&e.length<be&&T.push({instanceLocation:o,keyword:`minItems`,keywordLocation:`${s}/minItems`,error:`Array has too few items (${e.length} < ${be}).`});let t=e.length,l=0,u=!1;if(ge!==void 0){let d=`${s}/prefixItems`,f=Math.min(ge.length,t);for(;l<f;l++){let t=$(e[l],ge[l],n,r,i,a,`${o}/${l}`,`${d}/${l}`);if(c[l]=!0,!t.valid&&(u=i,T.push({instanceLocation:o,keyword:`prefixItems`,keywordLocation:d,error:`Items did not match schema.`},...t.errors),u))break}}if(b!==void 0){let d=`${s}/items`;if(Array.isArray(b)){let s=Math.min(b.length,t);for(;l<s;l++){let t=$(e[l],b[l],n,r,i,a,`${o}/${l}`,`${d}/${l}`);if(c[l]=!0,!t.valid&&(u=i,T.push({instanceLocation:o,keyword:`items`,keywordLocation:d,error:`Items did not match schema.`},...t.errors),u))break}}else for(;l<t;l++){let t=$(e[l],b,n,r,i,a,`${o}/${l}`,d);if(c[l]=!0,!t.valid&&(u=i,T.push({instanceLocation:o,keyword:`items`,keywordLocation:d,error:`Items did not match schema.`},...t.errors),u))break}if(!u&&_e!==void 0){let d=`${s}/additionalItems`;for(;l<t;l++){let t=$(e[l],_e,n,r,i,a,`${o}/${l}`,d);c[l]=!0,t.valid||(u=i,T.push({instanceLocation:o,keyword:`additionalItems`,keywordLocation:d,error:`Items did not match additional items schema.`},...t.errors))}}}if(ye!==void 0)if(t===0&&x===void 0)T.push({instanceLocation:o,keyword:`contains`,keywordLocation:`${s}/contains`,error:`Array is empty. It must contain at least one item matching the schema.`});else if(x!==void 0&&t<x)T.push({instanceLocation:o,keyword:`minContains`,keywordLocation:`${s}/minContains`,error:`Array has less items (${t}) than minContains (${x}).`});else{let l=`${s}/contains`,u=T.length,d=0;for(let s=0;s<t;s++){let t=$(e[s],ye,n,r,i,a,`${o}/${s}`,l);t.valid?(c[s]=!0,d++):T.push(...t.errors)}d>=(x||0)&&(T.length=u),x===void 0&&S===void 0&&d===0?T.splice(u,0,{instanceLocation:o,keyword:`contains`,keywordLocation:l,error:`Array does not contain item matching schema.`}):x!==void 0&&d<x?T.push({instanceLocation:o,keyword:`minContains`,keywordLocation:`${s}/minContains`,error:`Array must contain at least ${x} items matching schema. Only ${d} items were found.`}):S!==void 0&&d>S&&T.push({instanceLocation:o,keyword:`maxContains`,keywordLocation:`${s}/maxContains`,error:`Array may contain at most ${S} items matching schema. ${d} items were found.`})}if(!u&&ve!==void 0){let u=`${s}/unevaluatedItems`;for(;l<t;l++){if(c[l])continue;let t=$(e[l],ve,n,r,i,a,`${o}/${l}`,u);c[l]=!0,t.valid||T.push({instanceLocation:o,keyword:`unevaluatedItems`,keywordLocation:u,error:`Items did not match unevaluated items schema.`},...t.errors)}}if(Se)for(let n=0;n<t;n++){let r=e[n],i=typeof r==`object`&&!!r;for(let a=0;a<t;a++){if(n===a)continue;let t=e[a];(r===t||i&&typeof t==`object`&&t&&Kg(r,t))&&(T.push({instanceLocation:o,keyword:`uniqueItems`,keywordLocation:`${s}/uniqueItems`,error:`Duplicate items at indexes ${n} and ${a}.`}),n=2**53-1,a=2**53-1)}}}else if(u===`number`){if(n===`4`?(Ce!==void 0&&(Te===!0&&e<=Ce||e<Ce)&&T.push({instanceLocation:o,keyword:`minimum`,keywordLocation:`${s}/minimum`,error:`${e} is less than ${Te?`or equal to `:``} ${Ce}.`}),we!==void 0&&(C===!0&&e>=we||e>we)&&T.push({instanceLocation:o,keyword:`maximum`,keywordLocation:`${s}/maximum`,error:`${e} is greater than ${C?`or equal to `:``} ${we}.`})):(Ce!==void 0&&e<Ce&&T.push({instanceLocation:o,keyword:`minimum`,keywordLocation:`${s}/minimum`,error:`${e} is less than ${Ce}.`}),we!==void 0&&e>we&&T.push({instanceLocation:o,keyword:`maximum`,keywordLocation:`${s}/maximum`,error:`${e} is greater than ${we}.`}),Te!==void 0&&e<=Te&&T.push({instanceLocation:o,keyword:`exclusiveMinimum`,keywordLocation:`${s}/exclusiveMinimum`,error:`${e} is less than ${Te}.`}),C!==void 0&&e>=C&&T.push({instanceLocation:o,keyword:`exclusiveMaximum`,keywordLocation:`${s}/exclusiveMaximum`,error:`${e} is greater than or equal to ${C}.`})),Ee!==void 0){let t=e%Ee;Math.abs(0-t)>=1.1920929e-7&&Math.abs(Ee-t)>=1.1920929e-7&&T.push({instanceLocation:o,keyword:`multipleOf`,keywordLocation:`${s}/multipleOf`,error:`${e} is not a multiple of ${Ee}.`})}}else if(u===`string`){let t=w===void 0&&De===void 0?0:D_(e);w!==void 0&&t<w&&T.push({instanceLocation:o,keyword:`minLength`,keywordLocation:`${s}/minLength`,error:`String is too short (${t} < ${w}).`}),De!==void 0&&t>De&&T.push({instanceLocation:o,keyword:`maxLength`,keywordLocation:`${s}/maxLength`,error:`String is too long (${t} > ${De}).`}),Oe!==void 0&&!new RegExp(Oe,`u`).test(e)&&T.push({instanceLocation:o,keyword:`pattern`,keywordLocation:`${s}/pattern`,error:`String does not match pattern.`}),ae!==void 0&&g_[ae]&&!g_[ae](e)&&T.push({instanceLocation:o,keyword:`format`,keywordLocation:`${s}/format`,error:`String does not match format "${ae}".`})}return{valid:T.length===0,errors:T}}var O_=class{schema;draft;shortCircuit;lookup;constructor(e,t=`2019-09`,n=!0){this.schema=e,this.draft=t,this.shortCircuit=n,this.lookup=$g(e)}validate(e){return $(e,this.schema,this.draft,this.lookup,this.shortCircuit)}addSchema(e,t){t&&(e={...e,$id:t}),$g(e,this.lookup)}},k_=class{shortcircuit;draft;constructor(e){this.shortcircuit=e?.shortcircuit??!0,this.draft=e?.draft}_draftFor(e){let t=Ip(e,`pass an explicit { draft } to CfWorkerJsonSchemaValidator to validate other dialects.`);return t===`draft-7`?`7`:t}getValidator(e){let t=new O_(e,this.draft??this._draftFor(e),this.shortcircuit);return e=>{let n=t.validate(e);return n.valid?{valid:!0,data:e,errorMessage:void 0}:{valid:!1,data:void 0,errorMessage:n.errors.map(e=>`${e.instanceLocation}: ${e.error}`).join(`; `)}}}},A_=Symbol.for(`mcp.completable`);function j_(e){return!!e&&typeof e==`object`&&A_ in e}function M_(e){return e[A_]?.complete}var N_=8,P_=6e5;function F_(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??N_,roundTimeoutMs:e?.roundTimeoutMs??P_,legacyShim:e?.legacyShim??!0}}function I_(e,t,n){if(typeof n!=`object`||!n||typeof n.method!=`string`)throw new Q(Z.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 r=n,i=Hp(r);if(i===void 0)throw new Q(Z.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 L_(){let e=globalThis.crypto;if(e?.randomUUID!==void 0)return e.randomUUID();let t=new Uint8Array(16);e.getRandomValues(t),t[6]=t[6]&15|64,t[8]=t[8]&63|128;let n=[...t].map(e=>e.toString(16).padStart(2,`0`)).join(``);return`${n.slice(0,8)}-${n.slice(8,12)}-${n.slice(12,16)}-${n.slice(16,20)}-${n.slice(20)}`}function R_(e,t){if(e===`tools/call`)return{content:[{type:`text`,text:t}],isError:!0};throw new Q(Z.InternalError,t)}var z_=class{constructor(e){this._host=e}async fulfill(e,t,n,r,i){let{maxRounds:a,roundTimeoutMs:o}=this._host,s=r.mcpReq.signal,c=i,l=0;for(;;){if(l+=1,l>a)return R_(e,ug(e,a));let i=c.inputRequests,u=i!=null&&Object.keys(i).length>0,d=typeof c.requestState==`string`?c.requestState:void 0;if(!u&&d===void 0)throw new Q(Z.InternalError,`Handler for ${e} returned an input-required result with neither inputRequests nor requestState (every InputRequiredResult must include at least one of the two)`);let f;if(u){let t=this._host.resolvedClientCapabilities(r),n=[];for(let[r,a]of Object.entries(i)){let{embedded:i,required:o}=I_(e,r,a);if(i.method!==`roots/list`&&i.params===void 0)throw new Q(Z.InternalError,`Handler for ${e} returned an input request '${r}' of kind '${i.method}' without params`);if(Up(o,t)!==void 0)return R_(e,`Cannot request input '${r}' (${i.method}): the client on this 2025-era connection did not declare the required capability${t===void 0?` (no client capabilities are available on this connection — per-request legacy serving cannot receive server-to-client requests)`:``}`);n.push([r,i])}let a=fg(s);try{let e={relatedRequestId:r.mcpReq.id,timeout:o,resetTimeoutOnProgress:!0,onprogress:()=>{},signal:a.signal},t=await Promise.all(n.map(async([t,n])=>{try{return[t,await this._dispatchLeg(n,e)]}catch(e){throw a.abort(e),e}}));f=Object.fromEntries(t)}catch(t){if(s.aborted)throw t;return R_(e,`Fulfilling input required by '${e}' failed: ${t instanceof Error?t.message:String(t)}`)}finally{a.dispose()}}else await dg(250,s);let p={...r,mcpReq:{...r.mcpReq,inputResponses:f,droppedInputResponseKeys:void 0,requestState:Cg(d)}};if(d!==void 0){let t=await this._host.verifyRequestState(d,p,e);t!==void 0&&(p=Tg(p,t))}let m=await t(n,p);if(!Eh(m))return m;c=m}}async _dispatchLeg(e,t){switch(e.method){case`elicitation/create`:{let n=e.params;return n.mode===`url`&&n.elicitationId===void 0&&(n={...n,elicitationId:L_()}),await this._host.sendElicitation(n,t)}case`sampling/createMessage`:return await this._host.sendSampling(e.params,t);case`roots/list`:return await this._host.listRoots(e.params,t)}}},B_=new Set([`tools/call`,`prompts/get`,`resources/read`]),V_=class extends Eg{_clientCapabilities;_clientVersion;_capabilities;_instructions;_jsonSchemaValidator;_cacheHints;_requestStateVerify;_inputRequiredServing;_legacyShim;_legacyInputRequiredShim(){return this._legacyShim??=new z_({maxRounds:this._inputRequiredServing.maxRounds,roundTimeoutMs:this._inputRequiredServing.roundTimeoutMs,resolvedClientCapabilities:e=>this._inputRequestCapabilityView(e),verifyRequestState:(e,t,n)=>this._verifyRequestState(e,t,n),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 k_,this._requestStateVerify=t?.requestState?.verify,this._inputRequiredServing=F_(t?.inputRequired),t?.cacheHints!==void 0){for(let[e,n]of Object.entries(t.cacheHints))n!==void 0&&Mm(n,`cacheHints['${e}']`);this._cacheHints=t.cacheHints}this.setRequestHandler(`initialize`,e=>this._oninitialize(e)),this.setNotificationHandler(`notifications/initialized`,()=>this.oninitialized?.()),qp(this._supportedProtocolVersions).length>0&&this.setRequestHandler(`server/discover`,()=>this._ondiscover()),this._capabilities.logging&&this._registerLoggingHandler()}_registerLoggingHandler(){this.setRequestHandler(`logging/setLevel`,async(e,t)=>{let n=t.sessionId||t.http?.req?.headers.get(`mcp-session-id`)||void 0,{level:r}=e.params,i=Ih(ou,r);return i.success&&this._loggingLevels.set(n,i.data),{}})}buildContext(e,t){let n=e.http||t?.request||t?.closeSSEStream||t?.closeStandaloneSSEStream;return{...e,mcpReq:{...e.mcpReq,log:(t,n,r)=>{if(!this._capabilities.logging)return Promise.resolve();let i;if(this._servedModernEra()){if(i=e.mcpReq.envelope?.[fc],i===void 0)return Promise.resolve()}else i=this._loggingLevels.get(e.sessionId)??this._loggingLevels.get(void 0);return i!==void 0&&this.LOG_LEVEL_SEVERITY.get(t)<this.LOG_LEVEL_SEVERITY.get(i)?Promise.resolve():e.mcpReq.notify({method:`notifications/message`,params:{level:t,data:n,logger:r}})},elicitInput:(e,t)=>this.elicitInput(e,t),requestSampling:(e,t)=>this.createMessage(e,t)},http:n?{...e.http,req:t?.request,closeSSE:t?.closeSSEStream,closeStandaloneSSE:t?.closeStandaloneSSEStream}:void 0}}_loggingLevels=new Map;LOG_LEVEL_SEVERITY=new Map(ou.options.map((e,t)=>[e,t]));isMessageIgnored=(e,t)=>{let n=this._loggingLevels.get(t);return n?this.LOG_LEVEL_SEVERITY.get(e)<this.LOG_LEVEL_SEVERITY.get(n):!1};registerCapabilities(e){if(this.transport)throw new X(Y.AlreadyConnected,`Cannot register capabilities after connecting to transport`);let t=!!this._capabilities.logging;this._capabilities=Og(this._capabilities,e),!t&&this._capabilities.logging&&this._registerLoggingHandler()}_wrapHandler(e,t){if(e!==`tools/call`){let n=this._cacheHints?.[e],r=B_.has(e);return n===void 0&&!r?async(n,r)=>{let i=await t(n,r);if(Eh(i))throw new Q(Z.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 i}:async(i,a)=>{let o=r?await this._invokeInputRequiredCapableHandler(e,t,i,a):await t(i,a);if(Eh(o)){if(!r)throw new Q(Z.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 n===void 0?o:Om(o,n)}}return async(e,n)=>{let r=gh(this._negotiatedProtocolVersion),i=r.validateRequest(`tools/call`,e);if(!i.ok)throw new Q(i.reason===`not-in-era`?Z.InternalError:Z.InvalidParams,i.reason===`not-in-era`?`No wire schema for tools/call in the resolved era`:`Invalid tools/call request: ${i.message}`);let a=await this._invokeInputRequiredCapableHandler(`tools/call`,t,e,n);if(Eh(a))return a;let o=Xp(a),s=r.validateResult(`tools/call`,o);if(!s.ok)throw new Q(s.reason===`not-in-era`?Z.InternalError:Z.InvalidParams,s.reason===`not-in-era`?`No wire schema for tools/call in the resolved era`:`Invalid tools/call result: ${s.message}`);return s.value}}_servedModernEra(){return this._negotiatedProtocolVersion!==void 0&&Gp(this._negotiatedProtocolVersion)}async _invokeInputRequiredCapableHandler(e,t,n,r){let i=this._servedModernEra(),a=r.mcpReq.requestState();if(a!==void 0&&typeof a!=`string`)throw new Q(Z.InvalidParams,`Invalid or expired requestState`,{reason:`invalid_request_state`});let o=r;if(typeof a==`string`){let t=await this._verifyRequestState(a,r,e);t!==void 0&&(o=Tg(r,t))}let s;try{s=await t(n,o)}catch(e){throw e instanceof Q&&e.code===Z.UrlElicitationRequired&&i?new Q(Z.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.`):e}if(!Eh(s))return s;if(!i){if(!this._inputRequiredServing.legacyShim)throw new Q(Z.InternalError,`Handler for ${e} returned an input-required result, but this request is served on protocol revision ${this._negotiatedProtocolVersion??`2025-11-25`}, which has no input_required vocabulary`);return await this._legacyInputRequiredShim().fulfill(e,t,n,o,s)}let c=s.inputRequests,l=c!=null&&Object.keys(c).length>0,u=typeof s.requestState==`string`;if(!l&&!u)throw new Q(Z.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(l){let t=this._inputRequestCapabilityView(r);for(let[n,r]of Object.entries(c)){let{embedded:i,required:a}=I_(e,n,r),o=Up(a,t);if(o!==void 0)throw new Im({requiredCapabilities:o},`Cannot request input '${n}' (${i.method}): the request's client capabilities do not declare the required capability`)}}return s}async _verifyRequestState(e,t,n){if(this._requestStateVerify!==void 0)try{return await this._requestStateVerify(e,t)}catch(e){throw this.onerror?.(Error(`requestState verification rejected ${n}: ${e instanceof Error?e.message:String(e)}`)),new Q(Z.InvalidParams,`Invalid or expired requestState`,{reason:`invalid_request_state`})}}_inputRequestCapabilityView(e){return this._servedModernEra()?e.mcpReq.envelope?.[uc]:this._clientCapabilities}_assertPushApiInServedEra(e){if(this._servedModernEra())throw new X(Y.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 X(Y.CapabilityNotSupported,`Client does not support sampling (required for ${e})`);break;case`elicitation/create`:if(!this._clientCapabilities?.elicitation)throw new X(Y.CapabilityNotSupported,`Client does not support elicitation (required for ${e})`);break;case`roots/list`:if(!this._clientCapabilities?.roots)throw new X(Y.CapabilityNotSupported,`Client does not support listing roots (required for ${e})`)}}assertNotificationCapability(e){switch(e){case`notifications/message`:if(!this._capabilities.logging)throw new X(Y.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 X(Y.CapabilityNotSupported,`Server does not support notifying about resources (required for ${e})`);break;case`notifications/tools/list_changed`:if(!this._capabilities.tools)throw new X(Y.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 X(Y.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 X(Y.CapabilityNotSupported,`Client does not support URL elicitation (required for ${e})`)}}assertRequestHandlerCapability(e){switch(e){case`completion/complete`:if(!this._capabilities.completions)throw new X(Y.CapabilityNotSupported,`Server does not support completions (required for ${e})`);break;case`logging/setLevel`:if(!this._capabilities.logging)throw new X(Y.CapabilityNotSupported,`Server does not support logging (required for ${e})`);break;case`prompts/get`:case`prompts/list`:if(!this._capabilities.prompts)throw new X(Y.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 X(Y.CapabilityNotSupported,`Server does not support resources (required for ${e})`);break;case`tools/call`:case`tools/list`:if(!this._capabilities.tools)throw new X(Y.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 n=Kp(this._supportedProtocolVersions),r=n.includes(t)?t:n[0]??`2025-11-25`;return this._negotiatedProtocolVersion=r,this.transport?.setProtocolVersion?.(r),{protocolVersion:r,capabilities:this.getCapabilities(),serverInfo:this._serverInfo,...this._instructions&&{instructions:this._instructions}}}_ondiscover(){return{supportedVersions:qp(this._supportedProtocolVersions),capabilities:H_(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 X(Y.CapabilityNotSupported,`Client does not support sampling tools capability.`);if(e.messages.length>0){let t=e.messages.at(-1),n=Array.isArray(t.content)?t.content:[t.content],r=n.some(e=>e.type===`tool_result`),i=e.messages.length>1?e.messages.at(-2):void 0,a=i?Array.isArray(i.content)?i.content:[i.content]:[],o=a.some(e=>e.type===`tool_use`);if(r){if(n.some(e=>e.type!==`tool_result`))throw new Q(Z.InvalidParams,`The last message must contain only tool_result content if any is present`);if(!o)throw new Q(Z.InvalidParams,`tool_result blocks are not matching any tool_use from the previous message`)}if(o){let e=new Set(a.filter(e=>e.type===`tool_use`).map(e=>e.id)),t=new Set(n.filter(e=>e.type===`tool_result`).map(e=>e.toolUseId));if(e.size!==t.size||![...e].every(e=>t.has(e)))throw new Q(Z.InvalidParams,`ids of tool_result blocks and tool_use blocks from previous message do not match`)}}let n=!!(e.tools||e.toolChoice),r=await this.request({method:`sampling/createMessage`,params:e},t),i=this._wireCodec().samplingResultVariant(n,r);if(!i.ok)throw new X(Y.InvalidResult,`Invalid sampling/createMessage result: ${i.reason===`invalid`?i.message:i.reason}`);return i.value}async elicitInput(e,t){switch(this._assertPushApiInServedEra(`elicitation/create`),e.mode??`form`){case`url`:if(!this._clientCapabilities?.elicitation?.url)throw new X(Y.CapabilityNotSupported,`Client does not support url elicitation.`);break;case`form`:if(!this._clientCapabilities?.elicitation?.form)throw new X(Y.CapabilityNotSupported,`Client does not support form elicitation.`)}return this._sendElicitationLeg(e,t)}async _sendElicitationLeg(e,t,n){let r=e.mode??`form`,i=n?.validateAcceptedContent??!0;switch(r){case`url`:{let n=e;return this.request({method:`elicitation/create`,params:n},t)}case`form`:{let n=e.mode===`form`?e:{...e,mode:`form`},r=await this.request({method:`elicitation/create`,params:n},t);if(i&&r.action===`accept`&&r.content&&n.requestedSchema)try{let e=this._jsonSchemaValidator.getValidator(n.requestedSchema)(r.content);if(!e.valid)throw new Q(Z.InvalidParams,`Elicitation response content does not match requested schema: ${e.errorMessage}`)}catch(e){throw e instanceof Q?e:new Q(Z.InternalError,`Error validating elicitation response: ${e instanceof Error?e.message:String(e)}`)}return r}}}createElicitationCompletionNotifier(e,t){if(!this._clientCapabilities?.elicitation?.url)throw new X(Y.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`})}};function H_(e){return{...e}}var U_=class{server;_registeredResources={};_registeredResourceTemplates={};_registeredTools={};_registeredPrompts={};_toolInputSchemaJson={};toolInputSchemaJson(e){let t=this._registeredTools[e];if(!(t===void 0||!t.enabled)){if(Object.hasOwn(this._toolInputSchemaJson,e))return this._toolInputSchemaJson[e];if(t.inputSchema===void 0)return K_;try{let n=Vh(t.inputSchema,`input`);return this._toolInputSchemaJson[e]=n,n}catch{return}}}constructor(e,t){this.server=new V_(e,t),t?.capabilities?.tools&&this.setToolRequestHandlers(),t?.capabilities?.resources&&this.setResourceRequestHandlers(),t?.capabilities?.prompts&&this.setPromptRequestHandlers()}async connect(e){return await this.server.connect(e)}async close(){await this.server.close()}_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])=>{let n={name:e,title:t.title,description:t.description,inputSchema:t.inputSchema?Vh(t.inputSchema,`input`):K_,annotations:t.annotations,icons:t.icons,execution:t.execution,_meta:t._meta};return t.outputSchema&&(n.outputSchema=Vh(t.outputSchema,`output`)),n})})),this.server.setRequestHandler(`tools/call`,async(e,t)=>{let n=this._registeredTools[e.params.name];if(!n)throw new Q(Z.InvalidParams,`Tool ${e.params.name} not found`);if(!n.enabled)throw new Q(Z.InvalidParams,`Tool ${e.params.name} disabled`);try{let r=await this.validateToolInput(n,e.params.arguments,e.params.name),i=await this.executeToolHandler(n,r,t);return await this.validateToolOutput(n,i,e.params.name),Eh(i)?i:this.server.projectCallToolResult(i,n.outputSchemaJson)}catch(e){if(e instanceof Q&&e.code===Z.UrlElicitationRequired)throw e;return this.createToolError(e instanceof Error?e.message:String(e))}}),!0)}createToolError(e){return{content:[{type:`text`,text:e}],isError:!0}}async validateToolInput(e,t,n){if(!e.inputSchema)return;let r=await Wh(e.inputSchema,t??{});if(!r.success)throw new Q(Z.InvalidParams,`Input validation error: Invalid arguments for tool ${n}: ${r.error}`);return r.data}async validateToolOutput(e,t,n){if(!e.outputSchema||Eh(t)||t.isError)return;if(t.structuredContent===void 0)throw new Q(Z.InvalidParams,`Output validation error: Tool ${n} has an output schema but no structured content was provided`);let r=await Wh(e.outputSchema,t.structuredContent);if(!r.success)throw new Q(Z.InvalidParams,`Output validation error: Invalid structured content for tool ${n}: ${r.error}`)}async executeToolHandler(e,t,n){return e.executor(t,n)}_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`:return Dh(e),this.handlePromptCompletion(e,e.params.ref);case`ref/resource`:return Oh(e),this.handleResourceCompletion(e,e.params.ref);default:throw new Q(Z.InvalidParams,`Invalid completion reference: ${e.params.ref}`)}}),!0)}async handlePromptCompletion(e,t){let n=this._registeredPrompts[t.name];if(!n)throw new Q(Z.InvalidParams,`Prompt ${t.name} not found`);if(!n.enabled)throw new Q(Z.InvalidParams,`Prompt ${t.name} disabled`);if(!n.argsSchema)return X_;let r=$_(Z_(n.argsSchema)?.[e.params.argument.name]);if(!j_(r))return X_;let i=M_(r);return i?Y_(await i(e.params.argument.value,e.params.context)):X_}async handleResourceCompletion(e,t){let n=Object.values(this._registeredResourceTemplates).find(e=>e.resourceTemplate.uriTemplate.toString()===t.uri);if(!n){if(this._registeredResources[t.uri])return X_;throw new Q(Z.InvalidParams,`Resource template ${e.params.ref.uri} not found`)}let r=n.resourceTemplate.completeCallback(e.params.argument.name);return r?Y_(await r(e.params.argument.value,e.params.context)):X_}_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 n=Object.entries(this._registeredResources).filter(([e,t])=>t.enabled).map(([e,t])=>({uri:e,name:t.name,...t.metadata})),r=[];for(let e of Object.values(this._registeredResourceTemplates)){if(!e.resourceTemplate.listCallback)continue;let n=await e.resourceTemplate.listCallback(t);for(let t of n.resources)r.push({...e.metadata,...t})}return{resources:[...n,...r]}}),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 n;try{n=new URL(e.params.uri)}catch{throw new Q(Z.InvalidParams,`Resource URI ${e.params.uri} is invalid`,{uri:e.params.uri,reason:`invalid_uri`})}let r=this._registeredResources[n.toString()];if(r){if(!r.enabled)throw new Q(Z.InvalidParams,`Resource ${n} disabled`);return Om(await r.readCallback(n,t),r.cacheHint)}for(let e of Object.values(this._registeredResourceTemplates)){let r=e.resourceTemplate.uriTemplate.match(n.toString());if(r)return Om(await e.readCallback(n,r,t),e.cacheHint)}throw new Nm(e.params.uri)}),!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])=>({name:e,title:t.title,description:t.description,arguments:t.argsSchema?Xh(t.argsSchema):void 0,icons:t.icons,_meta:t._meta}))})),this.server.setRequestHandler(`prompts/get`,async(e,t)=>{let n=this._registeredPrompts[e.params.name];if(!n)throw new Q(Z.InvalidParams,`Prompt ${e.params.name} not found`);if(!n.enabled)throw new Q(Z.InvalidParams,`Prompt ${e.params.name} disabled`);return n.handler(e.params.arguments,t)}),!0)}registerResource(e,t,n,r){let i=n.cacheHint,a=n;if(i!==void 0){Mm(i,`resource ${e}`);let t={...n};delete t.cacheHint,a=t}if(typeof t==`string`){if(this._registeredResources[t])throw Error(`Resource ${t} is already registered`);let o=this._createRegisteredResource(e,n.title,t,a,r);return i!==void 0&&(o.cacheHint=i),this.setResourceRequestHandlers(),this.sendResourceListChanged(),o}{if(this._registeredResourceTemplates[e])throw Error(`Resource template ${e} is already registered`);let o=this._createRegisteredResourceTemplate(e,n.title,t,a,r);return i!==void 0&&(o.cacheHint=i),this.setResourceRequestHandlers(),this.sendResourceListChanged(),o}}_createRegisteredResource(e,t,n,r,i){let a={name:e,title:t,metadata:r,readCallback:i,enabled:!0,disable:()=>a.update({enabled:!1}),enable:()=>a.update({enabled:!0}),remove:()=>a.update({uri:null}),update:e=>{e.uri!==void 0&&e.uri!==n&&(delete this._registeredResources[n],e.uri&&(this._registeredResources[e.uri]=a)),e.name!==void 0&&(a.name=e.name),e.title!==void 0&&(a.title=e.title),e.metadata!==void 0&&(a.metadata=e.metadata),e.callback!==void 0&&(a.readCallback=e.callback),e.enabled!==void 0&&(a.enabled=e.enabled),this.sendResourceListChanged()}};return this._registeredResources[n]=a,a}_createRegisteredResourceTemplate(e,t,n,r,i){let a={resourceTemplate:n,title:t,metadata:r,readCallback:i,enabled:!0,disable:()=>a.update({enabled:!1}),enable:()=>a.update({enabled:!0}),remove:()=>a.update({name:null}),update:t=>{t.name!==void 0&&t.name!==e&&(delete this._registeredResourceTemplates[e],t.name&&(this._registeredResourceTemplates[t.name]=a)),t.title!==void 0&&(a.title=t.title),t.template!==void 0&&(a.resourceTemplate=t.template),t.metadata!==void 0&&(a.metadata=t.metadata),t.callback!==void 0&&(a.readCallback=t.callback),t.enabled!==void 0&&(a.enabled=t.enabled),this.sendResourceListChanged()}};this._registeredResourceTemplates[e]=a;let o=n.uriTemplate.variableNames;return Array.isArray(o)&&o.some(e=>!!n.completeCallback(e))&&this.setCompletionRequestHandler(),a}_createRegisteredPrompt(e,t,n,r,i,a,o){let s=r,c=i,l={title:t,description:n,argsSchema:r,icons:a,_meta:o,handler:J_(e,r,i),enabled:!0,disable:()=>l.update({enabled:!1}),enable:()=>l.update({enabled:!0}),remove:()=>l.update({name:null}),update:t=>{t.name!==void 0&&t.name!==e&&(delete this._registeredPrompts[e],t.name&&(this._registeredPrompts[t.name]=l)),t.title!==void 0&&(l.title=t.title),t.description!==void 0&&(l.description=t.description),t.icons!==void 0&&(l.icons=t.icons),t._meta!==void 0&&(l._meta=t._meta);let n=!1;t.argsSchema!==void 0&&(l.argsSchema=t.argsSchema,s=t.argsSchema,n=!0),t.callback!==void 0&&(c=t.callback,n=!0),n&&(l.handler=J_(e,s,c)),t.enabled!==void 0&&(l.enabled=t.enabled),this.sendPromptListChanged()}};if(this._registeredPrompts[e]=l,r){let e=Z_(r);e&&Object.values(e).some(e=>j_($_(e)))&&this.setCompletionRequestHandler()}return l}_createRegisteredTool(e,t,n,r,i,a,o,s,c,l){if(Fg(e),r!==void 0)try{let t=Vh(r,`input`);this._toolInputSchemaJson[e]=t;let n=Mh(t);n.valid||console.warn(`[mcp-sdk] tool '${e}' carries an invalid x-mcp-header declaration and will be excluded by conforming Streamable HTTP clients: ${n.reason}`)}catch{}let u=l,d={title:t,description:n,inputSchema:r,outputSchema:i,outputSchemaJson:q_(i),annotations:a,icons:o,execution:s,_meta:c,handler:l,executor:G_(r,l),enabled:!0,disable:()=>d.update({enabled:!1}),enable:()=>d.update({enabled:!0}),remove:()=>d.update({name:null}),update:t=>{t.name!==void 0&&t.name!==e&&(typeof t.name==`string`&&Fg(t.name),delete this._registeredTools[e],delete this._toolInputSchemaJson[e],t.name&&(delete this._toolInputSchemaJson[t.name],this._registeredTools[t.name]=d,e=t.name)),t.title!==void 0&&(d.title=t.title),t.description!==void 0&&(d.description=t.description);let n=!1;t.paramsSchema!==void 0&&(d.inputSchema=t.paramsSchema,delete this._toolInputSchemaJson[e],n=!0),t.callback!==void 0&&(d.handler=t.callback,u=t.callback,n=!0),n&&(d.executor=G_(d.inputSchema,u)),t.outputSchema!==void 0&&(d.outputSchema=t.outputSchema,d.outputSchemaJson=q_(t.outputSchema)),t.annotations!==void 0&&(d.annotations=t.annotations),t.icons!==void 0&&(d.icons=t.icons),t._meta!==void 0&&(d._meta=t._meta),t.enabled!==void 0&&(d.enabled=t.enabled),this.sendToolListChanged()}};return this._registeredTools[e]=d,this.setToolRequestHandlers(),this.sendToolListChanged(),d}registerTool(e,t,n){if(this._registeredTools[e])throw Error(`Tool ${e} is already registered`);let{title:r,description:i,inputSchema:a,outputSchema:o,annotations:s,icons:c,_meta:l}=t;return this._createRegisteredTool(e,r,i,Wg(a),Wg(o),s,c,void 0,l,n)}registerPrompt(e,t,n){if(this._registeredPrompts[e])throw Error(`Prompt ${e} is already registered`);let{title:r,description:i,argsSchema:a,icons:o,_meta:s}=t,c=this._createRegisteredPrompt(e,r,i,Wg(a),n,o,s);return this.setPromptRequestHandlers(),this.sendPromptListChanged(),c}isConnected(){return this.server.transport!==void 0}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()}},W_=class{_uriTemplate;constructor(e,t){this._callbacks=t,this._uriTemplate=typeof e==`string`?new Bg(e):e}get uriTemplate(){return this._uriTemplate}get listCallback(){return this._callbacks.list}completeCallback(e){return this._callbacks.complete?.[e]}};function G_(e,t){if(e){let e=t;return async(t,n)=>e(t,n)}let n=t;return async(e,t)=>n(t)}var K_={type:`object`,properties:{}};function q_(e){if(e!==void 0)try{return Vh(e,`output`)}catch{return}}function J_(e,t,n){if(t){let r=n;return async(n,i)=>{let a=await Wh(t,n);if(!a.success)throw new Q(Z.InvalidParams,`Invalid arguments for prompt ${e}: ${a.error}`);return r(a.data,i)}}{let e=n;return async(t,n)=>e(n)}}function Y_(e){return{completion:{values:e.map(String).slice(0,100),total:e.length,hasMore:e.length>100}}}var X_={completion:{values:[],hasMore:!1}};function Z_(e){let t=e;if(t.shape&&typeof t.shape==`object`)return t.shape}function Q_(e){return e?.type===`optional`}function $_(e){return Q_(e)?e.def?.innerType??e:e}var ev;function tv(e,t){return Gg(e,t??(ev??=new k_))}var nv=pf(void 0).inputSchema,rv=`__isBrowserMcpServer`;function iv(e){return typeof e==`object`&&!!e&&rv in e&&e[rv]===!0}function av(e){if(e===null)return{content:[{type:`text`,text:`Tool execution interrupted by navigation`}],isError:!0};let t;try{t=JSON.parse(e)}catch{return qd(e)}return Eh(t)?t:qd(t)}function ov(e){let t=Object.getOwnPropertyDescriptor(e.inputSchema,`~standard`);return t&&!t.enumerable?e.inputSchema:tv(e.inputSchema)}function sv(e){if(!e)return;let{untrustedContentHint:t,...n}=e;return n}function cv(e,t,n){let r=e.annotations?Qd(e.annotations):void 0;return{name:e.name,...e.title===void 0?{}:{title:e.title},description:e.description,...t===void 0?{}:{inputSchema:t},...r?{annotations:r}:{},execute:n}}var lv=class extends EventTarget{[rv]=!0;mcpServer;native;ownerDocument;tools=new Map;peerOrigin;stopObservingPeerOrigin;registrations=new Set;nativeToolAbortControllers=new Map;nativeBackfilledTools=new Map;pendingTools=new Map;removingNativeTools=new Set;nativeSyncQueue=Promise.resolve();nativeToolChangeQueue=Promise.resolve();nativeToolChangeListener;closed=!1;closePromise;ontoolchangeHandler=null;ontoolchangeListener=e=>{this.ontoolchangeHandler?.call(this,e)};constructor(e,t={}){super();let{native:n,...r}=t;this.mcpServer=new U_(e,{...r,capabilities:Og(r.capabilities??{},{tools:{listChanged:!0},resources:{listChanged:!0},prompts:{listChanged:!0}})}),this.native=n,this.ownerDocument=globalThis.document??null,n&&typeof n.addEventListener==`function`&&typeof n.removeEventListener==`function`&&(this.nativeToolChangeListener=()=>{this.closed||(this.nativeToolChangeQueue=this.nativeToolChangeQueue.then(async()=>{try{await this.syncNativeTools()}catch(e){console.warn(`[BrowserMcpServer] Native WebMCP tool reconciliation failed:`,e)}await this.notifyProducerToolsChanged()}))},n.addEventListener(`toolchange`,this.nativeToolChangeListener))}get ontoolchange(){return this.ontoolchangeHandler}set ontoolchange(e){let t=typeof e==`function`?e:null;if(t===null){this.ontoolchangeHandler=null,super.removeEventListener(`toolchange`,this.ontoolchangeListener);return}this.ontoolchangeHandler===null&&super.addEventListener(`toolchange`,this.ontoolchangeListener),this.ontoolchangeHandler=t}async notifyProducerToolsChanged(){this.closed||(await new Promise(e=>setTimeout(e,0)),this.closed||this.dispatchEvent(new Event(`toolchange`)))}getNativeStandardToolsApi(){let e=this.native;return e&&typeof e.executeTool==`function`?e:void 0}async registerNativeToolMirror(e,t,n,r,i){if(!this.native)return;let a=this.native.registerTool,o=n.signal?AbortSignal.any([n.signal,i.signal]):i.signal,s=t.registeredInputSchema===void 0?void 0:JSON.parse(t.registeredInputSchema);this.nativeToolAbortControllers.set(e.name,i);try{await a.call(this.native,cv(e,s,e=>r(e)),{...n,signal:o})}catch(t){throw i.abort(),this.nativeToolAbortControllers.get(e.name)===i&&this.nativeToolAbortControllers.delete(e.name),t}this.nativeToolAbortControllers.get(e.name)===i&&this.removingNativeTools.delete(e.name)}abortNativeToolMirror(e,t=this.nativeToolAbortControllers.get(e)){!t||this.nativeToolAbortControllers.get(e)!==t||(this.removingNativeTools.add(e),t.abort(),this.nativeToolAbortControllers.delete(e))}validateToolDescriptor(e){if(Zd(e),this.tools.has(e.name)||this.pendingTools.has(e.name))throw Xd(`Tool already registered: ${e.name}`);return pf(e.inputSchema)}registerToolInMcp(e,t,n,r){let i=e.outputSchema===void 0?void 0:structuredClone(e.outputSchema),a=i===void 0?void 0:tv(i),o=sv(e.annotations),s=t.inputSchema.type===void 0||t.inputSchema.type===`object`,c=s?this.mcpServer.registerTool(e.name,{...e.title===void 0?{}:{title:e.title},description:e.description,inputSchema:ov(t),...a?{outputSchema:a}:{},...o?{annotations:o}:{}},async(t,r)=>{let i=await n(t,r.mcpReq.signal);if(Eh(i))throw Error(`WebMCP tool "${e.name}" returned input_required. Multi-round tool flows require BrowserMcpServer.mcpServer.registerTool().`);return qd(i)}):void 0;return r?.length&&c?.disable(),s||console.warn(`[BrowserMcpServer] Tool "${e.name}" remains available through WebMCP but cannot be exposed over MCP because MCP input schemas require an object root.`),{item:{name:e.name,...e.title===void 0?{}:{title:e.title},description:e.description,inputSchema:t.inputSchema,...i===void 0?{}:{outputSchema:i},...e.annotations?{annotations:e.annotations}:{}},...t.registeredInputSchema===void 0?{}:{registeredInputSchema:t.registeredInputSchema},execute:n,mcpHandle:c,...r?.length?{exposedTo:r}:{}}}registerTool=async(e,t={})=>{let{signal:n,exposedTo:r}=t??{},i={...n?{signal:n}:{},...r?{exposedTo:[...r]}:{}};if(af(this.ownerDocument),this.closed)throw Xd(`BrowserMcpServer is closed`);if(!zd(e))throw TypeError(`registerTool(tool) requires a tool object`);let a=Vd(e),o=this.validateToolDescriptor(a);i.signal?.throwIfAborted(),rf(i.exposedTo),i.signal?.throwIfAborted();let s=async(e,t)=>(t?.throwIfAborted(),tf(Promise.resolve().then(()=>Reflect.apply(a.execute,void 0,[e])),t)),c=new AbortController,l,u=()=>{this.pendingTools.get(a.name)===c&&this.pendingTools.delete(a.name),l&&this.tools.get(a.name)===l?this.removeTool(a.name):this.abortNativeToolMirror(a.name,c)};i.signal?.addEventListener(`abort`,u,{once:!0}),this.pendingTools.set(a.name,c);try{if(await this.registerNativeToolMirror(a,o,i,s,c),this.closed)throw Xd(`BrowserMcpServer is closed`);i.signal?.throwIfAborted(),l=this.registerToolInMcp(a,o,s,i.exposedTo?.map(e=>{let t=new URL(e).origin;return t===`null`?e:t})),this.tools.set(a.name,l),this.applyToolExposure(),i.signal?.aborted&&(u(),i.signal.throwIfAborted())}catch(e){throw this.abortNativeToolMirror(a.name,c),i.signal?.removeEventListener(`abort`,u),i.signal?.throwIfAborted(),e}finally{this.pendingTools.get(a.name)===c&&this.pendingTools.delete(a.name)}if(i.signal&&(l.abortSignal=i.signal,l.abortListener=u),this.tools.get(a.name)===l&&(this.native?await this.nativeToolChangeQueue:await this.notifyProducerToolsChanged()),this.closed)throw Xd(`BrowserMcpServer is closed`);i.signal?.throwIfAborted()};removeTool(e,t){let n=this.tools.get(e);n&&(n.abortSignal&&n.abortListener&&n.abortSignal.removeEventListener(`abort`,n.abortListener),this.tools.delete(e),this.nativeBackfilledTools.delete(e),n.mcpHandle?.remove(),(t?.notify??!0)&&!this.native&&this.notifyProducerToolsChanged()),t?.skipNative||this.abortNativeToolMirror(e)}syncNativeTools(){let e=this.nativeSyncQueue.then(async()=>{if(this.closed)return;let e=this.getNativeStandardToolsApi();e&&await this.backfillNativeStandardTools(e)});return this.nativeSyncQueue=e.then(()=>void 0,()=>void 0),e}async backfillNativeStandardTools(e){let t=await e.getTools();if(this.closed)return;let n=new Map,r=new Set(t.map(({name:e})=>e));for(let e of this.removingNativeTools)r.has(e)||this.removingNativeTools.delete(e);for(let e of t){if(n.has(e.name)||this.pendingTools.has(e.name)||this.removingNativeTools.has(e.name))continue;let t=nv;if(e.inputSchema!==void 0)try{let n=typeof e.inputSchema==`string`?e.inputSchema:JSON.stringify(e.inputSchema),r=JSON.parse(n);t=zd(r)?r:void 0}catch{t=void 0}if(!t){console.warn(`[BrowserMcpServer] Native tool "${e.name}" was not exposed over MCP because its input schema is malformed.`);continue}let r={name:e.name,...e.title===void 0?{}:{title:e.title},description:e.description,inputSchema:t,...e.annotations?{annotations:e.annotations}:{}};n.set(e.name,{source:e,item:r,fingerprint:JSON.stringify(r)})}for(let[e,t]of this.nativeBackfilledTools){let r=n.get(e);if(!r||r.fingerprint!==t.fingerprint){this.removeTool(e,{skipNative:!0,notify:!1});continue}this.nativeBackfilledTools.set(e,r)}for(let[t,r]of n){if(this.tools.has(t))continue;let n=async(n,r)=>{let i=this.nativeBackfilledTools.get(t)?.source;if(!i)throw Error(`Native tool not found: ${t}`);let a=JSON.stringify(n);return av(r?await e.executeTool.call(this.native,i,a,{signal:r}):await e.executeTool.call(this.native,i,a))},i={name:t,...r.item.title===void 0?{}:{title:r.item.title},description:r.item.description,inputSchema:r.item.inputSchema,...r.item.annotations?{annotations:r.item.annotations}:{},execute:e=>n(e)};try{let e=this.validateToolDescriptor(i);this.tools.set(i.name,this.registerToolInMcp(i,e,n,void 0)),this.nativeBackfilledTools.set(t,r)}catch(e){console.warn(`[BrowserMcpServer] Native tool "${t}" was not exposed over MCP because its schema could not be compiled:`,e)}}}registerResource(e){if(this.closed)throw Xd(`BrowserMcpServer is closed`);let t={...e},n={...t.description===void 0?{}:{description:t.description},...t.mimeType===void 0?{}:{mimeType:t.mimeType}},r=t.uri.includes(`{`)?new W_(t.uri,{list:void 0}):void 0,i=r?this.mcpServer.registerResource(t.name,r,n,async(e,n)=>t.read(e,n)):this.mcpServer.registerResource(t.name,t.uri,n,async e=>t.read(e));return this.registrations.add(i),{unregister:()=>{this.registrations.delete(i)&&i.remove()}}}registerPrompt(e){if(this.closed)throw Xd(`BrowserMcpServer is closed`);let t={...e,...e.argsSchema===void 0?{}:{argsSchema:structuredClone(e.argsSchema)}},n=t.argsSchema===void 0?void 0:tv(t.argsSchema),r=this.mcpServer.registerPrompt(t.name,{...t.description===void 0?{}:{description:t.description},...n?{argsSchema:n}:{}},async e=>t.get(e??{}));return this.registrations.add(r),{unregister:()=>{this.registrations.delete(r)&&r.remove()}}}listTools(){return structuredClone([...this.tools.values()].map(({item:e})=>e))}async getTools(e){if(af(this.ownerDocument),this.closed)throw Xd(`BrowserMcpServer is closed`);if(this.native)return this.native.getTools(e);if(rf(e?.fromOrigins),e?.fromOrigins?.length)throw new DOMException(`Cross-document tool discovery requires native WebMCP`,`NotSupportedError`);let t=globalThis.location?.origin??``,n=globalThis.window,r=[...this.tools.values()].map(({item:e,registeredInputSchema:r})=>{let i=r===void 0?void 0:JSON.parse(r);return{name:e.name,title:e.title??``,description:e.description,...zd(i)?{inputSchema:i}:{},origin:t,window:n,...e.annotations?{annotations:Qd(e.annotations)}:{}}}).sort((e,t)=>e.name<t.name?-1:+(e.name>t.name));return await new Promise(e=>setTimeout(e,0)),r}async executeTool(e,t,n){if(af(this.ownerDocument),this.closed)throw Xd(`BrowserMcpServer is closed`);let r=this.getNativeStandardToolsApi();if(r)return r.executeTool.call(this.native,e,t,n);if(typeof e!=`object`||!e)throw TypeError(`RegisteredTool must be an object`);for(let t of[`name`,`description`,`window`,`origin`])if(!(t in e))throw TypeError(`RegisteredTool.${t} is required`);sf(e.origin);let i=globalThis.location?.origin??``,a=globalThis.window;if(e.origin!==i||e.window!==a)throw Jd(`Native tool not found: ${e.name}`);n?.signal?.throwIfAborted();let o=this.tools.get(e.name);if(!o)throw Jd(`Tool not found: ${e.name}`);let s=$d(t);try{return ef(await tf(o.execute(s,n?.signal),o.abortSignal,()=>Jd(`Tool unregistered`)))}catch(e){throw n?.signal?.aborted&&e===n.signal.reason||o.abortSignal?.aborted?e:Yd(e)}}applyToolExposure(){for(let{exposedTo:e,mcpHandle:t}of this.tools.values()){if(!e?.length||!t)continue;let n=this.peerOrigin!==void 0&&this.peerOrigin!==`null`&&e.includes(this.peerOrigin);n!==t.enabled&&(n?t.enable():t.disable())}}observePeerOrigin(e){if(this.stopObservingPeerOrigin?.(),this.stopObservingPeerOrigin=void 0,this.peerOrigin=void 0,this.applyToolExposure(),!(`clientOrigin`in e))return;let t=e;this.peerOrigin=t.clientOrigin,this.applyToolExposure();let n=t.onclientorigin,r=!0,i=e=>{n?.(e),r&&(this.peerOrigin=e,this.applyToolExposure())};t.onclientorigin=i,this.stopObservingPeerOrigin=()=>{r=!1,t.onclientorigin===i&&(t.onclientorigin=n)}}async connect(e){if(this.closed)throw Xd(`BrowserMcpServer is closed`);if(this.mcpServer.server.transport)throw Xd(`BrowserMcpServer is already connected`);this.observePeerOrigin(e);let t=this.stopObservingPeerOrigin;try{await this.mcpServer.connect(e)}catch(n){throw this.stopObservingPeerOrigin===t&&(t?.(),this.stopObservingPeerOrigin=void 0,this.peerOrigin=void 0,this.applyToolExposure()),this.mcpServer.server.transport===e&&await this.mcpServer.close(),n}}close(){return this.closePromise?this.closePromise:(this.closed=!0,this.stopObservingPeerOrigin?.(),this.stopObservingPeerOrigin=void 0,this.closePromise=(async()=>{this.native&&this.nativeToolChangeListener&&(this.native.removeEventListener(`toolchange`,this.nativeToolChangeListener),this.nativeToolChangeListener=void 0);for(let e of this.nativeToolAbortControllers.keys())this.abortNativeToolMirror(e);for(let e of this.tools.keys())this.removeTool(e,{notify:!1});for(let e of this.registrations)e.remove();this.registrations.clear(),this.nativeBackfilledTools.clear(),this.removingNativeTools.clear(),await this.mcpServer.close()})(),this.closePromise)}},uv=null;function dv(){return typeof window<`u`&&window.navigator!==void 0}function fv(){return document.modelContext??navigator.modelContext}function pv(e){let t=Object.getOwnPropertyDescriptor(e,`modelContext`);return t?t.configurable===!0:Object.isExtensible(e)}function mv(e){Object.defineProperty(document,"modelContext",{configurable:!0,enumerable:!0,writable:!1,value:e}),document.modelContext!==e&&console.error(`[WebModelContext] Failed to replace document.modelContext.`,`Descriptor:`,Object.getOwnPropertyDescriptor(document,`modelContext`))}function hv(e){Object.defineProperty(navigator,"modelContext",{configurable:!0,enumerable:!0,writable:!1,value:e}),navigator.modelContext!==e&&console.error(`[WebModelContext] Failed to replace navigator.modelContext.`,`Descriptor:`,Object.getOwnPropertyDescriptor(navigator,`modelContext`))}function gv(e,t,n){n?Object.defineProperty(e,t,n):Reflect.deleteProperty(e,t)}function _v(e,t,n){try{mv(e),hv(e)}catch(e){throw gv(document,`modelContext`,t),gv(navigator,`modelContext`,n),e}}function vv(e){if(window.parent!==window&&e?.iframeServer!==!1)return new Md(typeof e?.iframeServer==`object`?e.iframeServer:{allowedOrigins:[`*`]});if(e?.tabServer===!1)throw Error(`tabServer transport is disabled and iframe transport was not selected`);return new Nd(typeof e?.tabServer==`object`?e.tabServer:{allowedOrigins:[`*`]})}function yv(e){if(!dv()||globalThis.isSecureContext===!1||uv)return;let t=fv();if(t&&iv(t))return;Ep({installTestingShim:e?.installTestingShim??!0});let n=fv();if(!n)throw Error(`modelContext is not available`);if(!pv(document)||!pv(navigator))return;let r=vv(e?.transport),i=new lv({name:`${window.location.hostname||`localhost`}-webmcp`,version:`1.0.0`},{native:n}),a=Object.getOwnPropertyDescriptor(document,`modelContext`),o=Object.getOwnPropertyDescriptor(navigator,`modelContext`);try{_v(i,a,o),uv={server:i,transport:r,previousDocumentModelContextDescriptor:a,previousNavigatorModelContextDescriptor:o}}catch(e){throw i.close(),r.close(),e}(async()=>{try{await i.syncNativeTools()}catch(e){console.warn(`[WebModelContext] Native WebMCP tool synchronization failed:`,e)}if(uv?.server===i)try{await i.connect(r)}catch(e){console.error(`[WebModelContext] Failed to connect MCP transport:`,e),uv?.server===i&&bv()}})()}function bv(){if(!uv)return;let{server:e,transport:t,previousDocumentModelContextDescriptor:n,previousNavigatorModelContextDescriptor:r}=uv;uv=null,e.close(),t.close(),gv(document,`modelContext`,n),gv(navigator,`modelContext`,r)}if(typeof window<`u`&&typeof document<`u`){let e=window.__webModelContextOptions;if(e?.autoInitialize!==!1)try{yv(e)}catch(e){console.error(`[WebModelContext] Auto-initialization failed:`,e)}}export{bv as cleanupWebModelContext,yv as initializeWebModelContext};