@reqvire-org/ads 0.3.52 → 0.3.53
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/assets.mjs +15 -1
- package/dist/browser-audit/first-render.mjs +22 -0
- package/dist/browser-audit/image-shape.mjs +36 -0
- package/dist/browser-audit/render-states.mjs +61 -35
- package/dist/browser-audit/worker.mjs +47 -12
- package/dist/browser-audit.mjs +69 -11
- package/dist/check.mjs +4 -1
- package/dist/cli.mjs +1 -1
- package/dist/config.mjs +3 -1
- package/dist/finding-rules.mjs +8 -1
- package/dist/font-rules.mjs +103 -0
- package/dist/fonts-generated.mjs +30 -12
- package/dist/mcp/preview-widget.bundle.js +50 -47
- package/dist/mcp/project-widget.bundle.js +45 -42
- package/dist/mcp/server.mjs +2 -2
- package/dist/mcp/widget.bundle.js +49 -46
- package/dist/showcase/client.bundle.js +27 -27
- package/dist/skills/ads-designer/SKILL.md +5 -3
- package/dist/skills/ads-designer/references/branding.md +2 -2
- package/dist/skills/ads-designer/references/performance.md +54 -4
- package/dist/starters/react/design-system/brand/Icons/AppIcon/AppIcon.ads.fixture.ts +1 -1
- package/dist/starters/react/design-system/brand/Identity/Logo/Logo.ads.fixture.ts +2 -2
- package/dist/starters/react/design-system/components/Content/Logo/Logo.tsx +2 -2
- package/docs/ARCHITECTURE.md +26 -2
- package/docs/CHANGELOG.md +58 -12
- package/docs/GUIDE.md +35 -3
- package/package.json +7 -7
|
@@ -1,77 +1,80 @@
|
|
|
1
|
-
var{create:Lm,defineProperty:zi,getOwnPropertyDescriptor:Um,getOwnPropertyNames:Zm,getPrototypeOf:Dm}=Object,Hm=Object.prototype.hasOwnProperty,gl=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Sl=(e,t)=>{let o={};for(var r in e)zi(o,r,{get:e[r],enumerable:!0});if(t)zi(o,Symbol.toStringTag,{value:"Module"});return o},Fm=(e,t,o,r)=>{if(t&&typeof t==="object"||typeof t==="function"){for(var n=Zm(t),i=0,a=n.length,u;i<a;i++)if(u=n[i],!Hm.call(e,u)&&u!==o)zi(e,u,{get:((d)=>t[d]).bind(null,u),enumerable:!(r=Um(t,u))||r.enumerable})}return e},_l=(e,t,o)=>(o=e!=null?Lm(Dm(e)):{},Fm(t||!e||!e.__esModule?zi(o,"default",{value:e,enumerable:!0}):o,e));var Vm=new Set(["https://json-schema.org/draft/2019-09/schema","http://json-schema.org/draft/2019-09/schema"]);function bl(e){return typeof e==="string"&&Vm.has(e.replace(/#$/,""))}var yl,Ca=Object.freeze({status:"aborted"});function m(e,t,o){function r(u,d){if(!u._zod)Object.defineProperty(u,"_zod",{value:{def:d,constr:a,traits:new Set},enumerable:!1});if(u._zod.traits.has(e))return;u._zod.traits.add(e),t(u,d);let p=a.prototype,f=Object.keys(p);for(let b=0;b<f.length;b++){let y=f[b];if(!(y in u))u[y]=p[y].bind(u)}}let n=o?.Parent??Object;class i extends n{}Object.defineProperty(i,"name",{value:e});function a(u){var d;let p=o?.Parent?new i:this;r(p,u),(d=p._zod).deferred??(d.deferred=[]);for(let f of p._zod.deferred)f();return p}return Object.defineProperty(a,"init",{value:r}),Object.defineProperty(a,Symbol.hasInstance,{value:(u)=>{if(o?.Parent&&u instanceof o.Parent)return!0;return u?._zod?.traits?.has(e)}}),Object.defineProperty(a,"name",{value:e}),a}var Jm=Symbol("zod_brand");class Le extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class Jr extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`);this.name="ZodEncodeError"}}(yl=globalThis).__zod_globalConfig??(yl.__zod_globalConfig={});var mo=globalThis.__zod_globalConfig;function ce(e){if(e)Object.assign(mo,e);return mo}function wi(e){let t=Object.values(e).filter((r)=>typeof r==="number");return Object.entries(e).filter(([r,n])=>t.indexOf(+r)===-1).map(([r,n])=>n)}function Oa(e,t="|"){return e.map((o)=>Aa(o)).join(t)}function Br(e,t){if(typeof t==="bigint")return t.toString();return t}function Wr(e){return{get value(){{let o=e();return Object.defineProperty(this,"value",{value:o}),o}throw Error("cached value already set")}}}function xi(e){return e===null||e===void 0}function Ti(e){let t=e.startsWith("^")?1:0,o=e.endsWith("$")?e.length-1:e.length;return e.slice(t,o)}function zl(e,t){let o=e/t,r=Math.round(o),n=Number.EPSILON*Math.max(Math.abs(o),1);if(Math.abs(o-r)<n)return 0;return o-r}var vl=Symbol("evaluating");function O(e,t,o){let r=void 0;Object.defineProperty(e,t,{get(){if(r===vl)return;if(r===void 0)r=vl,r=o();return r},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function Pt(e,t,o){Object.defineProperty(e,t,{value:o,writable:!0,enumerable:!0,configurable:!0})}function rt(...e){let t={};for(let o of e){let r=Object.getOwnPropertyDescriptors(o);Object.assign(t,r)}return Object.defineProperties({},t)}function Ma(e){return JSON.stringify(e)}function Rl(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}var qa="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function fo(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}var wl=Wr(()=>{if(mo.jitless)return!1;if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{return new Function(""),!0}catch(e){return!1}});function kt(e){if(fo(e)===!1)return!1;let t=e.constructor;if(t===void 0)return!0;if(typeof t!=="function")return!0;let o=t.prototype;if(fo(o)===!1)return!1;if(Object.prototype.hasOwnProperty.call(o,"isPrototypeOf")===!1)return!1;return!0}function Na(e){if(kt(e))return{...e};if(Array.isArray(e))return[...e];if(e instanceof Map)return new Map(e);if(e instanceof Set)return new Set(e);return e}var xl=new Set(["string","number","symbol"]);function nt(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function xe(e,t,o){let r=new e._zod.constr(t??e._zod.def);if(!t||o?.parent)r._zod.parent=e;return r}function w(e){let t=e;if(!t)return{};if(typeof t==="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");t.error=t.message}if(delete t.message,typeof t.error==="string")return{...t,error:()=>t.error};return t}function Aa(e){if(typeof e==="bigint")return e.toString()+"n";if(typeof e==="string")return`"${e}"`;return`${e}`}function Tl(e){return Object.keys(e).filter((t)=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}var El={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-340282346638528860000000000000000000000,340282346638528860000000000000000000000],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function Bm(e,t){let o=e._zod.def,r=o.checks;if(r&&r.length>0)throw Error(".pick() cannot be used on object schemas containing refinements");let i=rt(e._zod.def,{get shape(){let a={};for(let u in t){if(!(u in o.shape))throw Error(`Unrecognized key: "${u}"`);if(!t[u])continue;a[u]=o.shape[u]}return Pt(this,"shape",a),a},checks:[]});return xe(e,i)}function Wm(e,t){let o=e._zod.def,r=o.checks;if(r&&r.length>0)throw Error(".omit() cannot be used on object schemas containing refinements");let i=rt(e._zod.def,{get shape(){let a={...e._zod.def.shape};for(let u in t){if(!(u in o.shape))throw Error(`Unrecognized key: "${u}"`);if(!t[u])continue;delete a[u]}return Pt(this,"shape",a),a},checks:[]});return xe(e,i)}function Km(e,t){if(!kt(t))throw Error("Invalid input to extend: expected a plain object");let o=e._zod.def.checks;if(o&&o.length>0){let i=e._zod.def.shape;for(let a in t)if(Object.getOwnPropertyDescriptor(i,a)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}let n=rt(e._zod.def,{get shape(){let i={...e._zod.def.shape,...t};return Pt(this,"shape",i),i}});return xe(e,n)}function Gm(e,t){if(!kt(t))throw Error("Invalid input to safeExtend: expected a plain object");let o=rt(e._zod.def,{get shape(){let r={...e._zod.def.shape,...t};return Pt(this,"shape",r),r}});return xe(e,o)}function Ym(e,t){if(e._zod.def.checks?.length)throw Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");let o=rt(e._zod.def,{get shape(){let r={...e._zod.def.shape,...t._zod.def.shape};return Pt(this,"shape",r),r},get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return xe(e,o)}function Qm(e,t,o){let n=t._zod.def.checks;if(n&&n.length>0)throw Error(".partial() cannot be used on object schemas containing refinements");let a=rt(t._zod.def,{get shape(){let u=t._zod.def.shape,d={...u};if(o)for(let p in o){if(!(p in u))throw Error(`Unrecognized key: "${p}"`);if(!o[p])continue;d[p]=e?new e({type:"optional",innerType:u[p]}):u[p]}else for(let p in u)d[p]=e?new e({type:"optional",innerType:u[p]}):u[p];return Pt(this,"shape",d),d},checks:[]});return xe(t,a)}function Xm(e,t,o){let r=rt(t._zod.def,{get shape(){let n=t._zod.def.shape,i={...n};if(o)for(let a in o){if(!(a in i))throw Error(`Unrecognized key: "${a}"`);if(!o[a])continue;i[a]=new e({type:"nonoptional",innerType:n[a]})}else for(let a in n)i[a]=new e({type:"nonoptional",innerType:n[a]});return Pt(this,"shape",i),i}});return xe(t,r)}function $t(e,t=0){if(e.aborted===!0)return!0;for(let o=t;o<e.issues.length;o++)if(e.issues[o]?.continue!==!0)return!0;return!1}function Pl(e,t=0){if(e.aborted===!0)return!0;for(let o=t;o<e.issues.length;o++)if(e.issues[o]?.continue===!1)return!0;return!1}function st(e,t){return t.map((o)=>{var r;return(r=o).path??(r.path=[]),o.path.unshift(e),o})}function Ri(e){return typeof e==="string"?e:e?.message}function Te(e,t,o){let r=e.message?e.message:Ri(e.inst?._zod.def?.error?.(e))??Ri(t?.error?.(e))??Ri(o.customError?.(e))??Ri(o.localeError?.(e))??"Invalid input",{inst:n,continue:i,input:a,...u}=e;if(u.path??(u.path=[]),u.message=r,t?.reportInput)u.input=a;return u}function Ei(e){if(Array.isArray(e))return"array";if(typeof e==="string")return"string";return"unknown"}function kl(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 o=e;if(o&&Object.getPrototypeOf(o)!==Object.prototype&&"constructor"in o&&o.constructor)return o.constructor.name}}return t}function Ct(...e){let[t,o,r]=e;if(typeof t==="string")return{message:t,code:"custom",input:o,inst:r};return{...t}}var $l=(e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,Br,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},Pi=m("$ZodError",$l),ja=m("$ZodError",$l,{Parent:Error});function La(e,t=(o)=>o.message){let o={},r=[];for(let n of e.issues)if(n.path.length>0)o[n.path[0]]=o[n.path[0]]||[],o[n.path[0]].push(t(n));else r.push(t(n));return{formErrors:r,fieldErrors:o}}function Ua(e,t=(o)=>o.message){let o={_errors:[]},r=(n,i=[])=>{for(let a of n.issues)if(a.code==="invalid_union"&&a.errors.length)a.errors.map((u)=>r({issues:u},[...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 u=[...i,...a.path];if(u.length===0)o._errors.push(t(a));else{let d=o,p=0;while(p<u.length){let f=u[p];if(p!==u.length-1)d[f]=d[f]||{_errors:[]};else d[f]=d[f]||{_errors:[]},d[f]._errors.push(t(a));d=d[f],p++}}}};return r(e),o}var ki=(e)=>(t,o,r,n)=>{let i=r?{...r,async:!1}:{async:!1},a=t._zod.run({value:o,issues:[]},i);if(a instanceof Promise)throw new Le;if(a.issues.length){let u=new(n?.Err??e)(a.issues.map((d)=>Te(d,i,ce())));throw qa(u,n?.callee),u}return a.value};var $i=(e)=>async(t,o,r,n)=>{let i=r?{...r,async:!0}:{async:!0},a=t._zod.run({value:o,issues:[]},i);if(a instanceof Promise)a=await a;if(a.issues.length){let u=new(n?.Err??e)(a.issues.map((d)=>Te(d,i,ce())));throw qa(u,n?.callee),u}return a.value};var Kr=(e)=>(t,o,r)=>{let n=r?{...r,async:!1}:{async:!1},i=t._zod.run({value:o,issues:[]},n);if(i instanceof Promise)throw new Le;return i.issues.length?{success:!1,error:new(e??Pi)(i.issues.map((a)=>Te(a,n,ce())))}:{success:!0,data:i.value}},Cl=Kr(ja),Gr=(e)=>async(t,o,r)=>{let n=r?{...r,async:!0}:{async:!0},i=t._zod.run({value:o,issues:[]},n);if(i instanceof Promise)i=await i;return i.issues.length?{success:!1,error:new e(i.issues.map((a)=>Te(a,n,ce())))}:{success:!0,data:i.value}},Il=Gr(ja),Ol=(e)=>(t,o,r)=>{let n=r?{...r,direction:"backward"}:{direction:"backward"};return ki(e)(t,o,n)};var Ml=(e)=>(t,o,r)=>ki(e)(t,o,r);var ql=(e)=>async(t,o,r)=>{let n=r?{...r,direction:"backward"}:{direction:"backward"};return $i(e)(t,o,n)};var Nl=(e)=>async(t,o,r)=>$i(e)(t,o,r);var Al=(e)=>(t,o,r)=>{let n=r?{...r,direction:"backward"}:{direction:"backward"};return Kr(e)(t,o,n)};var jl=(e)=>(t,o,r)=>Kr(e)(t,o,r);var Ll=(e)=>async(t,o,r)=>{let n=r?{...r,direction:"backward"}:{direction:"backward"};return Gr(e)(t,o,n)};var Ul=(e)=>async(t,o,r)=>Gr(e)(t,o,r);var Zl=/^[cC][0-9a-z]{6,}$/,Dl=/^[0-9a-z]+$/,Hl=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,Fl=/^[0-9a-vA-V]{20}$/,Vl=/^[A-Za-z0-9]{27}$/,Jl=/^[a-zA-Z0-9_-]{21}$/,Bl=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;var Wl=/^([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})$/,Za=(e)=>{if(!e)return/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/;return new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`)};var Kl=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;var tf="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function Gl(){return new RegExp(tf,"u")}var Yl=/^(?:(?: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])$/,Ql=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/;var Xl=/^((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])$/,eu=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,tu=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Da=/^[A-Za-z0-9_-]*$/;var ou=/^https?$/,ru=/^\+[1-9]\d{6,14}$/,nu="(?:(?:\\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])))",su=new RegExp(`^${nu}$`);function iu(e){return typeof e.precision==="number"?e.precision===-1?"(?:[01]\\d|2[0-3]):[0-5]\\d":e.precision===0?"(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d":`(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d\\.\\d{${e.precision}}`:"(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?"}function au(e){return new RegExp(`^${iu(e)}$`)}function cu(e){let t=iu({precision:e.precision}),o=["Z"];if(e.local)o.push("");if(e.offset)o.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");let r=`${t}(?:${o.join("|")})`;return new RegExp(`^${nu}T(?:${r})$`)}var lu=(e)=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)};var uu=/^-?\d+$/,Ha=/^-?\d+(?:\.\d+)?$/,du=/^(?:true|false)$/i,pu=/^null$/i;var hu=/^undefined$/i;var mu=/^[^A-Z]*$/,fu=/^[^a-z]*$/;var X=m("$ZodCheck",(e,t)=>{var o;e._zod??(e._zod={}),e._zod.def=t,(o=e._zod).onattach??(o.onattach=[])}),gu={number:"number",bigint:"bigint",object:"date"},Fa=m("$ZodCheckLessThan",(e,t)=>{X.init(e,t);let o=gu[typeof t.value];e._zod.onattach.push((r)=>{let n=r._zod.bag,i=(t.inclusive?n.maximum:n.exclusiveMaximum)??Number.POSITIVE_INFINITY;if(t.value<i)if(t.inclusive)n.maximum=t.value;else n.exclusiveMaximum=t.value}),e._zod.check=(r)=>{if(t.inclusive?r.value<=t.value:r.value<t.value)return;r.issues.push({origin:o,code:"too_big",maximum:typeof t.value==="object"?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Va=m("$ZodCheckGreaterThan",(e,t)=>{X.init(e,t);let o=gu[typeof t.value];e._zod.onattach.push((r)=>{let n=r._zod.bag,i=(t.inclusive?n.minimum:n.exclusiveMinimum)??Number.NEGATIVE_INFINITY;if(t.value>i)if(t.inclusive)n.minimum=t.value;else n.exclusiveMinimum=t.value}),e._zod.check=(r)=>{if(t.inclusive?r.value>=t.value:r.value>t.value)return;r.issues.push({origin:o,code:"too_small",minimum:typeof t.value==="object"?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Su=m("$ZodCheckMultipleOf",(e,t)=>{X.init(e,t),e._zod.onattach.push((o)=>{var r;(r=o._zod.bag).multipleOf??(r.multipleOf=t.value)}),e._zod.check=(o)=>{if(typeof o.value!==typeof t.value)throw Error("Cannot mix number and bigint in multiple_of check.");if(typeof o.value==="bigint"?o.value%t.value===BigInt(0):zl(o.value,t.value)===0)return;o.issues.push({origin:typeof o.value,code:"not_multiple_of",divisor:t.value,input:o.value,inst:e,continue:!t.abort})}}),_u=m("$ZodCheckNumberFormat",(e,t)=>{X.init(e,t),t.format=t.format||"float64";let o=t.format?.includes("int"),r=o?"int":"number",[n,i]=El[t.format];e._zod.onattach.push((a)=>{let u=a._zod.bag;if(u.format=t.format,u.minimum=n,u.maximum=i,o)u.pattern=uu}),e._zod.check=(a)=>{let u=a.value;if(o){if(!Number.isInteger(u)){a.issues.push({expected:r,format:t.format,code:"invalid_type",continue:!1,input:u,inst:e});return}if(!Number.isSafeInteger(u)){if(u>0)a.issues.push({input:u,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,inclusive:!0,continue:!t.abort});else a.issues.push({input:u,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,inclusive:!0,continue:!t.abort});return}}if(u<n)a.issues.push({origin:"number",input:u,code:"too_small",minimum:n,inclusive:!0,inst:e,continue:!t.abort});if(u>i)a.issues.push({origin:"number",input:u,code:"too_big",maximum:i,inclusive:!0,inst:e,continue:!t.abort})}});var bu=m("$ZodCheckMaxLength",(e,t)=>{var o;X.init(e,t),(o=e._zod.def).when??(o.when=(r)=>{let n=r.value;return!xi(n)&&n.length!==void 0}),e._zod.onattach.push((r)=>{let n=r._zod.bag.maximum??Number.POSITIVE_INFINITY;if(t.maximum<n)r._zod.bag.maximum=t.maximum}),e._zod.check=(r)=>{let n=r.value;if(n.length<=t.maximum)return;let a=Ei(n);r.issues.push({origin:a,code:"too_big",maximum:t.maximum,inclusive:!0,input:n,inst:e,continue:!t.abort})}}),yu=m("$ZodCheckMinLength",(e,t)=>{var o;X.init(e,t),(o=e._zod.def).when??(o.when=(r)=>{let n=r.value;return!xi(n)&&n.length!==void 0}),e._zod.onattach.push((r)=>{let n=r._zod.bag.minimum??Number.NEGATIVE_INFINITY;if(t.minimum>n)r._zod.bag.minimum=t.minimum}),e._zod.check=(r)=>{let n=r.value;if(n.length>=t.minimum)return;let a=Ei(n);r.issues.push({origin:a,code:"too_small",minimum:t.minimum,inclusive:!0,input:n,inst:e,continue:!t.abort})}}),vu=m("$ZodCheckLengthEquals",(e,t)=>{var o;X.init(e,t),(o=e._zod.def).when??(o.when=(r)=>{let n=r.value;return!xi(n)&&n.length!==void 0}),e._zod.onattach.push((r)=>{let n=r._zod.bag;n.minimum=t.length,n.maximum=t.length,n.length=t.length}),e._zod.check=(r)=>{let n=r.value,i=n.length;if(i===t.length)return;let a=Ei(n),u=i>t.length;r.issues.push({origin:a,...u?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:r.value,inst:e,continue:!t.abort})}}),Qr=m("$ZodCheckStringFormat",(e,t)=>{var o,r;if(X.init(e,t),e._zod.onattach.push((n)=>{let i=n._zod.bag;if(i.format=t.format,t.pattern)i.patterns??(i.patterns=new Set),i.patterns.add(t.pattern)}),t.pattern)(o=e._zod).check??(o.check=(n)=>{if(t.pattern.lastIndex=0,t.pattern.test(n.value))return;n.issues.push({origin:"string",code:"invalid_format",format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})});else(r=e._zod).check??(r.check=()=>{})}),zu=m("$ZodCheckRegex",(e,t)=>{Qr.init(e,t),e._zod.check=(o)=>{if(t.pattern.lastIndex=0,t.pattern.test(o.value))return;o.issues.push({origin:"string",code:"invalid_format",format:"regex",input:o.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),Ru=m("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=mu),Qr.init(e,t)}),wu=m("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=fu),Qr.init(e,t)}),xu=m("$ZodCheckIncludes",(e,t)=>{X.init(e,t);let o=nt(t.includes),r=new RegExp(typeof t.position==="number"?`^.{${t.position}}${o}`:o);t.pattern=r,e._zod.onattach.push((n)=>{let i=n._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(r)}),e._zod.check=(n)=>{if(n.value.includes(t.includes,t.position))return;n.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:n.value,inst:e,continue:!t.abort})}}),Tu=m("$ZodCheckStartsWith",(e,t)=>{X.init(e,t);let o=new RegExp(`^${nt(t.prefix)}.*`);t.pattern??(t.pattern=o),e._zod.onattach.push((r)=>{let n=r._zod.bag;n.patterns??(n.patterns=new Set),n.patterns.add(o)}),e._zod.check=(r)=>{if(r.value.startsWith(t.prefix))return;r.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:r.value,inst:e,continue:!t.abort})}}),Eu=m("$ZodCheckEndsWith",(e,t)=>{X.init(e,t);let o=new RegExp(`.*${nt(t.suffix)}$`);t.pattern??(t.pattern=o),e._zod.onattach.push((r)=>{let n=r._zod.bag;n.patterns??(n.patterns=new Set),n.patterns.add(o)}),e._zod.check=(r)=>{if(r.value.endsWith(t.suffix))return;r.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:r.value,inst:e,continue:!t.abort})}});var Pu=m("$ZodCheckOverwrite",(e,t)=>{X.init(e,t),e._zod.check=(o)=>{o.value=t.tx(o.value)}});class Ja{constructor(e=[]){if(this.content=[],this.indent=0,this)this.args=e}indented(e){this.indent+=1,e(this),this.indent-=1}write(e){if(typeof e==="function"){e(this,{execution:"sync"}),e(this,{execution:"async"});return}let o=e.split(`
|
|
1
|
+
var{create:Mf,defineProperty:Ai,getOwnPropertyDescriptor:qf,getOwnPropertyNames:Nf,getPrototypeOf:Af}=Object,jf=Object.prototype.hasOwnProperty,Dl=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Hl=(e,t)=>{let o={};for(var r in e)Ai(o,r,{get:e[r],enumerable:!0});if(t)Ai(o,Symbol.toStringTag,{value:"Module"});return o},Lf=(e,t,o,r)=>{if(t&&typeof t==="object"||typeof t==="function"){for(var n=Nf(t),i=0,s=n.length,c;i<s;i++)if(c=n[i],!jf.call(e,c)&&c!==o)Ai(e,c,{get:((d)=>t[d]).bind(null,c),enumerable:!(r=qf(t,c))||r.enumerable})}return e},Fl=(e,t,o)=>(o=e!=null?Mf(Af(e)):{},Lf(t||!e||!e.__esModule?Ai(o,"default",{value:e,enumerable:!0}):o,e));var Uf=new Set(["https://json-schema.org/draft/2020-12/schema","http://json-schema.org/draft/2020-12/schema"]),Vl=new Set(["https://json-schema.org/draft/2019-09/schema","http://json-schema.org/draft/2019-09/schema"]),Zf=new Set(["https://json-schema.org/draft-07/schema","http://json-schema.org/draft-07/schema"]),Df=new Set(["https://json-schema.org/draft-06/schema","http://json-schema.org/draft-06/schema"]);function Jl(e){return typeof e==="string"&&Vl.has(e.replace(/#$/,""))}function Bl(e,t){if(!("$schema"in e)||typeof e.$schema!=="string")return"2020-12";let o=e.$schema.replace(/#$/,"");if(Uf.has(o))return"2020-12";if(Vl.has(o))return"2019-09";if(Zf.has(o)||Df.has(o))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 Wl,Ya=Object.freeze({status:"aborted"});function g(e,t,o){function r(c,d){if(!c._zod)Object.defineProperty(c,"_zod",{value:{def:d,constr:s,traits:new Set},enumerable:!1});if(c._zod.traits.has(e))return;c._zod.traits.add(e),t(c,d);let p=s.prototype,h=Object.keys(p);for(let f=0;f<h.length;f++){let S=h[f];if(!(S in c))c[S]=p[S].bind(c)}}let n=o?.Parent??Object;class i extends n{}Object.defineProperty(i,"name",{value:e});function s(c){var d;let p=o?.Parent?new i:this;r(p,c),(d=p._zod).deferred??(d.deferred=[]);for(let h of p._zod.deferred)h();return p}return Object.defineProperty(s,"init",{value:r}),Object.defineProperty(s,Symbol.hasInstance,{value:(c)=>{if(o?.Parent&&c instanceof o.Parent)return!0;return c?._zod?.traits?.has(e)}}),Object.defineProperty(s,"name",{value:e}),s}var Hf=Symbol("zod_brand");class bt extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class nn extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`);this.name="ZodEncodeError"}}(Wl=globalThis).__zod_globalConfig??(Wl.__zod_globalConfig={});var Do=globalThis.__zod_globalConfig;function ze(e){if(e)Object.assign(Do,e);return Do}function Li(e){let t=Object.values(e).filter((r)=>typeof r==="number");return Object.entries(e).filter(([r,n])=>t.indexOf(+r)===-1).map(([r,n])=>n)}function Xa(e,t="|"){return e.map((o)=>rc(o)).join(t)}function sn(e,t){if(typeof t==="bigint")return t.toString();return t}function an(e){return{get value(){{let o=e();return Object.defineProperty(this,"value",{value:o}),o}throw Error("cached value already set")}}}function Ui(e){return e===null||e===void 0}function Zi(e){let t=e.startsWith("^")?1:0,o=e.endsWith("$")?e.length-1:e.length;return e.slice(t,o)}function Gl(e,t){let o=e/t,r=Math.round(o),n=Number.EPSILON*Math.max(Math.abs(o),1);if(Math.abs(o-r)<n)return 0;return o-r}var Kl=Symbol("evaluating");function V(e,t,o){let r=void 0;Object.defineProperty(e,t,{get(){if(r===Kl)return;if(r===void 0)r=Kl,r=o();return r},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function ao(e,t,o){Object.defineProperty(e,t,{value:o,writable:!0,enumerable:!0,configurable:!0})}function jt(...e){let t={};for(let o of e){let r=Object.getOwnPropertyDescriptors(o);Object.assign(t,r)}return Object.defineProperties({},t)}function ec(e){return JSON.stringify(e)}function Yl(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}var tc="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function Ho(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}var Ql=an(()=>{if(Do.jitless)return!1;if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{return new Function(""),!0}catch(e){return!1}});function co(e){if(Ho(e)===!1)return!1;let t=e.constructor;if(t===void 0)return!0;if(typeof t!=="function")return!0;let o=t.prototype;if(Ho(o)===!1)return!1;if(Object.prototype.hasOwnProperty.call(o,"isPrototypeOf")===!1)return!1;return!0}function oc(e){if(co(e))return{...e};if(Array.isArray(e))return[...e];if(e instanceof Map)return new Map(e);if(e instanceof Set)return new Set(e);return e}var Xl=new Set(["string","number","symbol"]);function Lt(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Ye(e,t,o){let r=new e._zod.constr(t??e._zod.def);if(!t||o?.parent)r._zod.parent=e;return r}function I(e){let t=e;if(!t)return{};if(typeof t==="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");t.error=t.message}if(delete t.message,typeof t.error==="string")return{...t,error:()=>t.error};return t}function rc(e){if(typeof e==="bigint")return e.toString()+"n";if(typeof e==="string")return`"${e}"`;return`${e}`}function eu(e){return Object.keys(e).filter((t)=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}var tu={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-340282346638528860000000000000000000000,340282346638528860000000000000000000000],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function Ff(e,t){let o=e._zod.def,r=o.checks;if(r&&r.length>0)throw Error(".pick() cannot be used on object schemas containing refinements");let i=jt(e._zod.def,{get shape(){let s={};for(let c in t){if(!(c in o.shape))throw Error(`Unrecognized key: "${c}"`);if(!t[c])continue;s[c]=o.shape[c]}return ao(this,"shape",s),s},checks:[]});return Ye(e,i)}function Vf(e,t){let o=e._zod.def,r=o.checks;if(r&&r.length>0)throw Error(".omit() cannot be used on object schemas containing refinements");let i=jt(e._zod.def,{get shape(){let s={...e._zod.def.shape};for(let c in t){if(!(c in o.shape))throw Error(`Unrecognized key: "${c}"`);if(!t[c])continue;delete s[c]}return ao(this,"shape",s),s},checks:[]});return Ye(e,i)}function Jf(e,t){if(!co(t))throw Error("Invalid input to extend: expected a plain object");let o=e._zod.def.checks;if(o&&o.length>0){let i=e._zod.def.shape;for(let s in t)if(Object.getOwnPropertyDescriptor(i,s)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}let n=jt(e._zod.def,{get shape(){let i={...e._zod.def.shape,...t};return ao(this,"shape",i),i}});return Ye(e,n)}function Bf(e,t){if(!co(t))throw Error("Invalid input to safeExtend: expected a plain object");let o=jt(e._zod.def,{get shape(){let r={...e._zod.def.shape,...t};return ao(this,"shape",r),r}});return Ye(e,o)}function Wf(e,t){if(e._zod.def.checks?.length)throw Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");let o=jt(e._zod.def,{get shape(){let r={...e._zod.def.shape,...t._zod.def.shape};return ao(this,"shape",r),r},get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return Ye(e,o)}function Kf(e,t,o){let n=t._zod.def.checks;if(n&&n.length>0)throw Error(".partial() cannot be used on object schemas containing refinements");let s=jt(t._zod.def,{get shape(){let c=t._zod.def.shape,d={...c};if(o)for(let p in o){if(!(p in c))throw Error(`Unrecognized key: "${p}"`);if(!o[p])continue;d[p]=e?new e({type:"optional",innerType:c[p]}):c[p]}else for(let p in c)d[p]=e?new e({type:"optional",innerType:c[p]}):c[p];return ao(this,"shape",d),d},checks:[]});return Ye(t,s)}function Gf(e,t,o){let r=jt(t._zod.def,{get shape(){let n=t._zod.def.shape,i={...n};if(o)for(let s in o){if(!(s in i))throw Error(`Unrecognized key: "${s}"`);if(!o[s])continue;i[s]=new e({type:"nonoptional",innerType:n[s]})}else for(let s in n)i[s]=new e({type:"nonoptional",innerType:n[s]});return ao(this,"shape",i),i}});return Ye(t,r)}function lo(e,t=0){if(e.aborted===!0)return!0;for(let o=t;o<e.issues.length;o++)if(e.issues[o]?.continue!==!0)return!0;return!1}function ou(e,t=0){if(e.aborted===!0)return!0;for(let o=t;o<e.issues.length;o++)if(e.issues[o]?.continue===!1)return!0;return!1}function Ut(e,t){return t.map((o)=>{var r;return(r=o).path??(r.path=[]),o.path.unshift(e),o})}function ji(e){return typeof e==="string"?e:e?.message}function Qe(e,t,o){let r=e.message?e.message:ji(e.inst?._zod.def?.error?.(e))??ji(t?.error?.(e))??ji(o.customError?.(e))??ji(o.localeError?.(e))??"Invalid input",{inst:n,continue:i,input:s,...c}=e;if(c.path??(c.path=[]),c.message=r,t?.reportInput)c.input=s;return c}function Di(e){if(Array.isArray(e))return"array";if(typeof e==="string")return"string";return"unknown"}function ru(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 o=e;if(o&&Object.getPrototypeOf(o)!==Object.prototype&&"constructor"in o&&o.constructor)return o.constructor.name}}return t}function uo(...e){let[t,o,r]=e;if(typeof t==="string")return{message:t,code:"custom",input:o,inst:r};return{...t}}var nu=(e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,sn,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},Hi=g("$ZodError",nu),nc=g("$ZodError",nu,{Parent:Error});function sc(e,t=(o)=>o.message){let o={},r=[];for(let n of e.issues)if(n.path.length>0)o[n.path[0]]=o[n.path[0]]||[],o[n.path[0]].push(t(n));else r.push(t(n));return{formErrors:r,fieldErrors:o}}function ic(e,t=(o)=>o.message){let o={_errors:[]},r=(n,i=[])=>{for(let s of n.issues)if(s.code==="invalid_union"&&s.errors.length)s.errors.map((c)=>r({issues:c},[...i,...s.path]));else if(s.code==="invalid_key")r({issues:s.issues},[...i,...s.path]);else if(s.code==="invalid_element")r({issues:s.issues},[...i,...s.path]);else{let c=[...i,...s.path];if(c.length===0)o._errors.push(t(s));else{let d=o,p=0;while(p<c.length){let h=c[p];if(p!==c.length-1)d[h]=d[h]||{_errors:[]};else d[h]=d[h]||{_errors:[]},d[h]._errors.push(t(s));d=d[h],p++}}}};return r(e),o}var Fi=(e)=>(t,o,r,n)=>{let i=r?{...r,async:!1}:{async:!1},s=t._zod.run({value:o,issues:[]},i);if(s instanceof Promise)throw new bt;if(s.issues.length){let c=new(n?.Err??e)(s.issues.map((d)=>Qe(d,i,ze())));throw tc(c,n?.callee),c}return s.value};var Vi=(e)=>async(t,o,r,n)=>{let i=r?{...r,async:!0}:{async:!0},s=t._zod.run({value:o,issues:[]},i);if(s instanceof Promise)s=await s;if(s.issues.length){let c=new(n?.Err??e)(s.issues.map((d)=>Qe(d,i,ze())));throw tc(c,n?.callee),c}return s.value};var cn=(e)=>(t,o,r)=>{let n=r?{...r,async:!1}:{async:!1},i=t._zod.run({value:o,issues:[]},n);if(i instanceof Promise)throw new bt;return i.issues.length?{success:!1,error:new(e??Hi)(i.issues.map((s)=>Qe(s,n,ze())))}:{success:!0,data:i.value}},su=cn(nc),ln=(e)=>async(t,o,r)=>{let n=r?{...r,async:!0}:{async:!0},i=t._zod.run({value:o,issues:[]},n);if(i instanceof Promise)i=await i;return i.issues.length?{success:!1,error:new e(i.issues.map((s)=>Qe(s,n,ze())))}:{success:!0,data:i.value}},iu=ln(nc),au=(e)=>(t,o,r)=>{let n=r?{...r,direction:"backward"}:{direction:"backward"};return Fi(e)(t,o,n)};var cu=(e)=>(t,o,r)=>Fi(e)(t,o,r);var lu=(e)=>async(t,o,r)=>{let n=r?{...r,direction:"backward"}:{direction:"backward"};return Vi(e)(t,o,n)};var uu=(e)=>async(t,o,r)=>Vi(e)(t,o,r);var du=(e)=>(t,o,r)=>{let n=r?{...r,direction:"backward"}:{direction:"backward"};return cn(e)(t,o,n)};var pu=(e)=>(t,o,r)=>cn(e)(t,o,r);var hu=(e)=>async(t,o,r)=>{let n=r?{...r,direction:"backward"}:{direction:"backward"};return ln(e)(t,o,n)};var mu=(e)=>async(t,o,r)=>ln(e)(t,o,r);var fu=/^[cC][0-9a-z]{6,}$/,gu=/^[0-9a-z]+$/,Su=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,_u=/^[0-9a-vA-V]{20}$/,bu=/^[A-Za-z0-9]{27}$/,yu=/^[a-zA-Z0-9_-]{21}$/,vu=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;var zu=/^([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})$/,ac=(e)=>{if(!e)return/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/;return new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`)};var Ru=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;var Qf="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function wu(){return new RegExp(Qf,"u")}var xu=/^(?:(?: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])$/,Eu=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/;var Tu=/^((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])$/,Pu=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,ku=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,cc=/^[A-Za-z0-9_-]*$/;var $u=/^https?$/,Cu=/^\+[1-9]\d{6,14}$/,Iu="(?:(?:\\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])))",Ou=new RegExp(`^${Iu}$`);function Mu(e){return typeof e.precision==="number"?e.precision===-1?"(?:[01]\\d|2[0-3]):[0-5]\\d":e.precision===0?"(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d":`(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d\\.\\d{${e.precision}}`:"(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?"}function qu(e){return new RegExp(`^${Mu(e)}$`)}function Nu(e){let t=Mu({precision:e.precision}),o=["Z"];if(e.local)o.push("");if(e.offset)o.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");let r=`${t}(?:${o.join("|")})`;return new RegExp(`^${Iu}T(?:${r})$`)}var Au=(e)=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)};var ju=/^-?\d+$/,lc=/^-?\d+(?:\.\d+)?$/,Lu=/^(?:true|false)$/i,Uu=/^null$/i;var Zu=/^undefined$/i;var Du=/^[^A-Z]*$/,Hu=/^[^a-z]*$/;var pe=g("$ZodCheck",(e,t)=>{var o;e._zod??(e._zod={}),e._zod.def=t,(o=e._zod).onattach??(o.onattach=[])}),Fu={number:"number",bigint:"bigint",object:"date"},uc=g("$ZodCheckLessThan",(e,t)=>{pe.init(e,t);let o=Fu[typeof t.value];e._zod.onattach.push((r)=>{let n=r._zod.bag,i=(t.inclusive?n.maximum:n.exclusiveMaximum)??Number.POSITIVE_INFINITY;if(t.value<i)if(t.inclusive)n.maximum=t.value;else n.exclusiveMaximum=t.value}),e._zod.check=(r)=>{if(t.inclusive?r.value<=t.value:r.value<t.value)return;r.issues.push({origin:o,code:"too_big",maximum:typeof t.value==="object"?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),dc=g("$ZodCheckGreaterThan",(e,t)=>{pe.init(e,t);let o=Fu[typeof t.value];e._zod.onattach.push((r)=>{let n=r._zod.bag,i=(t.inclusive?n.minimum:n.exclusiveMinimum)??Number.NEGATIVE_INFINITY;if(t.value>i)if(t.inclusive)n.minimum=t.value;else n.exclusiveMinimum=t.value}),e._zod.check=(r)=>{if(t.inclusive?r.value>=t.value:r.value>t.value)return;r.issues.push({origin:o,code:"too_small",minimum:typeof t.value==="object"?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Vu=g("$ZodCheckMultipleOf",(e,t)=>{pe.init(e,t),e._zod.onattach.push((o)=>{var r;(r=o._zod.bag).multipleOf??(r.multipleOf=t.value)}),e._zod.check=(o)=>{if(typeof o.value!==typeof t.value)throw Error("Cannot mix number and bigint in multiple_of check.");if(typeof o.value==="bigint"?o.value%t.value===BigInt(0):Gl(o.value,t.value)===0)return;o.issues.push({origin:typeof o.value,code:"not_multiple_of",divisor:t.value,input:o.value,inst:e,continue:!t.abort})}}),Ju=g("$ZodCheckNumberFormat",(e,t)=>{pe.init(e,t),t.format=t.format||"float64";let o=t.format?.includes("int"),r=o?"int":"number",[n,i]=tu[t.format];e._zod.onattach.push((s)=>{let c=s._zod.bag;if(c.format=t.format,c.minimum=n,c.maximum=i,o)c.pattern=ju}),e._zod.check=(s)=>{let c=s.value;if(o){if(!Number.isInteger(c)){s.issues.push({expected:r,format:t.format,code:"invalid_type",continue:!1,input:c,inst:e});return}if(!Number.isSafeInteger(c)){if(c>0)s.issues.push({input:c,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,inclusive:!0,continue:!t.abort});else s.issues.push({input:c,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,inclusive:!0,continue:!t.abort});return}}if(c<n)s.issues.push({origin:"number",input:c,code:"too_small",minimum:n,inclusive:!0,inst:e,continue:!t.abort});if(c>i)s.issues.push({origin:"number",input:c,code:"too_big",maximum:i,inclusive:!0,inst:e,continue:!t.abort})}});var Bu=g("$ZodCheckMaxLength",(e,t)=>{var o;pe.init(e,t),(o=e._zod.def).when??(o.when=(r)=>{let n=r.value;return!Ui(n)&&n.length!==void 0}),e._zod.onattach.push((r)=>{let n=r._zod.bag.maximum??Number.POSITIVE_INFINITY;if(t.maximum<n)r._zod.bag.maximum=t.maximum}),e._zod.check=(r)=>{let n=r.value;if(n.length<=t.maximum)return;let s=Di(n);r.issues.push({origin:s,code:"too_big",maximum:t.maximum,inclusive:!0,input:n,inst:e,continue:!t.abort})}}),Wu=g("$ZodCheckMinLength",(e,t)=>{var o;pe.init(e,t),(o=e._zod.def).when??(o.when=(r)=>{let n=r.value;return!Ui(n)&&n.length!==void 0}),e._zod.onattach.push((r)=>{let n=r._zod.bag.minimum??Number.NEGATIVE_INFINITY;if(t.minimum>n)r._zod.bag.minimum=t.minimum}),e._zod.check=(r)=>{let n=r.value;if(n.length>=t.minimum)return;let s=Di(n);r.issues.push({origin:s,code:"too_small",minimum:t.minimum,inclusive:!0,input:n,inst:e,continue:!t.abort})}}),Ku=g("$ZodCheckLengthEquals",(e,t)=>{var o;pe.init(e,t),(o=e._zod.def).when??(o.when=(r)=>{let n=r.value;return!Ui(n)&&n.length!==void 0}),e._zod.onattach.push((r)=>{let n=r._zod.bag;n.minimum=t.length,n.maximum=t.length,n.length=t.length}),e._zod.check=(r)=>{let n=r.value,i=n.length;if(i===t.length)return;let s=Di(n),c=i>t.length;r.issues.push({origin:s,...c?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:r.value,inst:e,continue:!t.abort})}}),dn=g("$ZodCheckStringFormat",(e,t)=>{var o,r;if(pe.init(e,t),e._zod.onattach.push((n)=>{let i=n._zod.bag;if(i.format=t.format,t.pattern)i.patterns??(i.patterns=new Set),i.patterns.add(t.pattern)}),t.pattern)(o=e._zod).check??(o.check=(n)=>{if(t.pattern.lastIndex=0,t.pattern.test(n.value))return;n.issues.push({origin:"string",code:"invalid_format",format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})});else(r=e._zod).check??(r.check=()=>{})}),Gu=g("$ZodCheckRegex",(e,t)=>{dn.init(e,t),e._zod.check=(o)=>{if(t.pattern.lastIndex=0,t.pattern.test(o.value))return;o.issues.push({origin:"string",code:"invalid_format",format:"regex",input:o.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),Yu=g("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=Du),dn.init(e,t)}),Qu=g("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=Hu),dn.init(e,t)}),Xu=g("$ZodCheckIncludes",(e,t)=>{pe.init(e,t);let o=Lt(t.includes),r=new RegExp(typeof t.position==="number"?`^.{${t.position}}${o}`:o);t.pattern=r,e._zod.onattach.push((n)=>{let i=n._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(r)}),e._zod.check=(n)=>{if(n.value.includes(t.includes,t.position))return;n.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:n.value,inst:e,continue:!t.abort})}}),ed=g("$ZodCheckStartsWith",(e,t)=>{pe.init(e,t);let o=new RegExp(`^${Lt(t.prefix)}.*`);t.pattern??(t.pattern=o),e._zod.onattach.push((r)=>{let n=r._zod.bag;n.patterns??(n.patterns=new Set),n.patterns.add(o)}),e._zod.check=(r)=>{if(r.value.startsWith(t.prefix))return;r.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:r.value,inst:e,continue:!t.abort})}}),td=g("$ZodCheckEndsWith",(e,t)=>{pe.init(e,t);let o=new RegExp(`.*${Lt(t.suffix)}$`);t.pattern??(t.pattern=o),e._zod.onattach.push((r)=>{let n=r._zod.bag;n.patterns??(n.patterns=new Set),n.patterns.add(o)}),e._zod.check=(r)=>{if(r.value.endsWith(t.suffix))return;r.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:r.value,inst:e,continue:!t.abort})}});var od=g("$ZodCheckOverwrite",(e,t)=>{pe.init(e,t),e._zod.check=(o)=>{o.value=t.tx(o.value)}});class pc{constructor(e=[]){if(this.content=[],this.indent=0,this)this.args=e}indented(e){this.indent+=1,e(this),this.indent-=1}write(e){if(typeof e==="function"){e(this,{execution:"sync"}),e(this,{execution:"async"});return}let o=e.split(`
|
|
2
2
|
`).filter((i)=>i),r=Math.min(...o.map((i)=>i.length-i.trimStart().length)),n=o.map((i)=>i.slice(r)).map((i)=>" ".repeat(this.indent*2)+i);for(let i of n)this.content.push(i)}compile(){let e=Function,t=this?.args,r=[...(this?.content??[""]).map((n)=>` ${n}`)];return new e(...t,r.join(`
|
|
3
|
-
`))}}var $u={major:4,minor:4,patch:3};var N=m("$ZodType",(e,t)=>{var o;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=$u;let r=[...e._zod.def.checks??[]];if(e._zod.traits.has("$ZodCheck"))r.unshift(e);for(let n of r)for(let i of n._zod.onattach)i(e);if(r.length===0)(o=e._zod).deferred??(o.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let n=(a,u,d)=>{let p=$t(a),f;for(let b of u){if(b._zod.def.when){if(Pl(a))continue;if(!b._zod.def.when(a))continue}else if(p)continue;let y=a.issues.length,z=b._zod.check(a);if(z instanceof Promise&&d?.async===!1)throw new Le;if(f||z instanceof Promise)f=(f??Promise.resolve()).then(async()=>{if(await z,a.issues.length===y)return;if(!p)p=$t(a,y)});else{if(a.issues.length===y)continue;if(!p)p=$t(a,y)}}if(f)return f.then(()=>a);return a},i=(a,u,d)=>{if($t(a))return a.aborted=!0,a;let p=n(u,r,d);if(p instanceof Promise){if(d.async===!1)throw new Le;return p.then((f)=>e._zod.parse(f,d))}return e._zod.parse(p,d)};e._zod.run=(a,u)=>{if(u.skipChecks)return e._zod.parse(a,u);if(u.direction==="backward"){let p=e._zod.parse({value:a.value,issues:[]},{...u,skipChecks:!0});if(p instanceof Promise)return p.then((f)=>i(f,a,u));return i(p,a,u)}let d=e._zod.parse(a,u);if(d instanceof Promise){if(u.async===!1)throw new Le;return d.then((p)=>n(p,r,u))}return n(d,r,u)}}O(e,"~standard",()=>({validate:(n)=>{try{let i=Cl(e,n);return i.success?{value:i.data}:{issues:i.error?.issues}}catch(i){return Il(e,n).then((a)=>a.success?{value:a.data}:{issues:a.error?.issues})}},vendor:"zod",version:1}))}),Oi=m("$ZodString",(e,t)=>{N.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??lu(e._zod.bag),e._zod.parse=(o,r)=>{if(t.coerce)try{o.value=String(o.value)}catch(n){}if(typeof o.value==="string")return o;return o.issues.push({expected:"string",code:"invalid_type",input:o.value,inst:e}),o}}),Z=m("$ZodStringFormat",(e,t)=>{Qr.init(e,t),Oi.init(e,t)}),Lu=m("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=Wl),Z.init(e,t)}),Uu=m("$ZodUUID",(e,t)=>{if(t.version){let r={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(r===void 0)throw Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=Za(r))}else t.pattern??(t.pattern=Za());Z.init(e,t)}),Zu=m("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=Kl),Z.init(e,t)}),Du=m("$ZodURL",(e,t)=>{Z.init(e,t),e._zod.check=(o)=>{try{let r=o.value.trim();if(!t.normalize&&t.protocol?.source===ou.source){if(!/^https?:\/\//i.test(r)){o.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:o.value,inst:e,continue:!t.abort});return}}let n=new URL(r);if(t.hostname){if(t.hostname.lastIndex=0,!t.hostname.test(n.hostname))o.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:o.value,inst:e,continue:!t.abort})}if(t.protocol){if(t.protocol.lastIndex=0,!t.protocol.test(n.protocol.endsWith(":")?n.protocol.slice(0,-1):n.protocol))o.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:o.value,inst:e,continue:!t.abort})}if(t.normalize)o.value=n.href;else o.value=r;return}catch(r){o.issues.push({code:"invalid_format",format:"url",input:o.value,inst:e,continue:!t.abort})}}}),Hu=m("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=Gl()),Z.init(e,t)}),Fu=m("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=Jl),Z.init(e,t)}),Vu=m("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=Zl),Z.init(e,t)}),Ju=m("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=Dl),Z.init(e,t)}),Bu=m("$ZodULID",(e,t)=>{t.pattern??(t.pattern=Hl),Z.init(e,t)}),Wu=m("$ZodXID",(e,t)=>{t.pattern??(t.pattern=Fl),Z.init(e,t)}),Ku=m("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=Vl),Z.init(e,t)}),Gu=m("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=cu(t)),Z.init(e,t)}),Yu=m("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=su),Z.init(e,t)}),Qu=m("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=au(t)),Z.init(e,t)}),Xu=m("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=Bl),Z.init(e,t)}),ed=m("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=Yl),Z.init(e,t),e._zod.bag.format="ipv4"}),td=m("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=Ql),Z.init(e,t),e._zod.bag.format="ipv6",e._zod.check=(o)=>{try{new URL(`http://[${o.value}]`)}catch{o.issues.push({code:"invalid_format",format:"ipv6",input:o.value,inst:e,continue:!t.abort})}}});var od=m("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=Xl),Z.init(e,t)}),rd=m("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=eu),Z.init(e,t),e._zod.check=(o)=>{let r=o.value.split("/");try{if(r.length!==2)throw Error();let[n,i]=r;if(!i)throw Error();let a=Number(i);if(`${a}`!==i)throw Error();if(a<0||a>128)throw Error();new URL(`http://[${n}]`)}catch{o.issues.push({code:"invalid_format",format:"cidrv6",input:o.value,inst:e,continue:!t.abort})}}});function nd(e){if(e==="")return!0;if(/\s/.test(e))return!1;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}var sd=m("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=tu),Z.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=(o)=>{if(nd(o.value))return;o.issues.push({code:"invalid_format",format:"base64",input:o.value,inst:e,continue:!t.abort})}});function of(e){if(!Da.test(e))return!1;let t=e.replace(/[-_]/g,(r)=>r==="-"?"+":"/"),o=t.padEnd(Math.ceil(t.length/4)*4,"=");return nd(o)}var id=m("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=Da),Z.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=(o)=>{if(of(o.value))return;o.issues.push({code:"invalid_format",format:"base64url",input:o.value,inst:e,continue:!t.abort})}}),ad=m("$ZodE164",(e,t)=>{t.pattern??(t.pattern=ru),Z.init(e,t)});function rf(e,t=null){try{let o=e.split(".");if(o.length!==3)return!1;let[r]=o;if(!r)return!1;let n=JSON.parse(atob(r));if("typ"in n&&n?.typ!=="JWT")return!1;if(!n.alg)return!1;if(t&&(!("alg"in n)||n.alg!==t))return!1;return!0}catch{return!1}}var cd=m("$ZodJWT",(e,t)=>{Z.init(e,t),e._zod.check=(o)=>{if(rf(o.value,t.alg))return;o.issues.push({code:"invalid_format",format:"jwt",input:o.value,inst:e,continue:!t.abort})}});var Wa=m("$ZodNumber",(e,t)=>{N.init(e,t),e._zod.pattern=e._zod.bag.pattern??Ha,e._zod.parse=(o,r)=>{if(t.coerce)try{o.value=Number(o.value)}catch(a){}let n=o.value;if(typeof n==="number"&&!Number.isNaN(n)&&Number.isFinite(n))return o;let i=typeof n==="number"?Number.isNaN(n)?"NaN":!Number.isFinite(n)?"Infinity":void 0:void 0;return o.issues.push({expected:"number",code:"invalid_type",input:n,inst:e,...i?{received:i}:{}}),o}}),ld=m("$ZodNumberFormat",(e,t)=>{_u.init(e,t),Wa.init(e,t)}),ud=m("$ZodBoolean",(e,t)=>{N.init(e,t),e._zod.pattern=du,e._zod.parse=(o,r)=>{if(t.coerce)try{o.value=Boolean(o.value)}catch(i){}let n=o.value;if(typeof n==="boolean")return o;return o.issues.push({expected:"boolean",code:"invalid_type",input:n,inst:e}),o}});var dd=m("$ZodUndefined",(e,t)=>{N.init(e,t),e._zod.pattern=hu,e._zod.values=new Set([void 0]),e._zod.parse=(o,r)=>{let n=o.value;if(typeof n>"u")return o;return o.issues.push({expected:"undefined",code:"invalid_type",input:n,inst:e}),o}}),pd=m("$ZodNull",(e,t)=>{N.init(e,t),e._zod.pattern=pu,e._zod.values=new Set([null]),e._zod.parse=(o,r)=>{let n=o.value;if(n===null)return o;return o.issues.push({expected:"null",code:"invalid_type",input:n,inst:e}),o}}),hd=m("$ZodAny",(e,t)=>{N.init(e,t),e._zod.parse=(o)=>o}),md=m("$ZodUnknown",(e,t)=>{N.init(e,t),e._zod.parse=(o)=>o}),fd=m("$ZodNever",(e,t)=>{N.init(e,t),e._zod.parse=(o,r)=>(o.issues.push({expected:"never",code:"invalid_type",input:o.value,inst:e}),o)});function Cu(e,t,o){if(e.issues.length)t.issues.push(...st(o,e.issues));t.value[o]=e.value}var gd=m("$ZodArray",(e,t)=>{N.init(e,t),e._zod.parse=(o,r)=>{let n=o.value;if(!Array.isArray(n))return o.issues.push({expected:"array",code:"invalid_type",input:n,inst:e}),o;o.value=Array(n.length);let i=[];for(let a=0;a<n.length;a++){let u=n[a],d=t.element._zod.run({value:u,issues:[]},r);if(d instanceof Promise)i.push(d.then((p)=>Cu(p,o,a)));else Cu(d,o,a)}if(i.length)return Promise.all(i).then(()=>o);return o}});function Ii(e,t,o,r,n,i){let a=o in r;if(e.issues.length){if(n&&i&&!a)return;t.issues.push(...st(o,e.issues))}if(!a&&!n){if(!e.issues.length)t.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[o]});return}if(e.value===void 0){if(a)t.value[o]=void 0}else t.value[o]=e.value}function Sd(e){let t=Object.keys(e.shape);for(let r of t)if(!e.shape?.[r]?._zod?.traits?.has("$ZodType"))throw Error(`Invalid element at key "${r}": expected a Zod schema`);let o=Tl(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(o)}}function _d(e,t,o,r,n,i){let a=[],u=n.keySet,d=n.catchall._zod,p=d.def.type,f=d.optin==="optional",b=d.optout==="optional";for(let y in t){if(y==="__proto__")continue;if(u.has(y))continue;if(p==="never"){a.push(y);continue}let z=d.run({value:t[y],issues:[]},r);if(z instanceof Promise)e.push(z.then((E)=>Ii(E,o,y,t,f,b)));else Ii(z,o,y,t,f,b)}if(a.length)o.issues.push({code:"unrecognized_keys",keys:a,input:t,inst:i});if(!e.length)return o;return Promise.all(e).then(()=>o)}var nf=m("$ZodObject",(e,t)=>{if(N.init(e,t),!Object.getOwnPropertyDescriptor(t,"shape")?.get){let u=t.shape;Object.defineProperty(t,"shape",{get:()=>{let d={...u};return Object.defineProperty(t,"shape",{value:d}),d}})}let r=Wr(()=>Sd(t));O(e._zod,"propValues",()=>{let u=t.shape,d={};for(let p in u){let f=u[p]._zod;if(f.values){d[p]??(d[p]=new Set);for(let b of f.values)d[p].add(b)}}return d});let n=fo,i=t.catchall,a;e._zod.parse=(u,d)=>{a??(a=r.value);let p=u.value;if(!n(p))return u.issues.push({expected:"object",code:"invalid_type",input:p,inst:e}),u;u.value={};let f=[],b=a.shape;for(let y of a.keys){let z=b[y],E=z._zod.optin==="optional",P=z._zod.optout==="optional",k=z._zod.run({value:p[y],issues:[]},d);if(k instanceof Promise)f.push(k.then((A)=>Ii(A,u,y,p,E,P)));else Ii(k,u,y,p,E,P)}if(!i)return f.length?Promise.all(f).then(()=>u):u;return _d(f,p,u,d,r.value,e)}}),bd=m("$ZodObjectJIT",(e,t)=>{nf.init(e,t);let o=e._zod.parse,r=Wr(()=>Sd(t)),n=(y)=>{let z=new Ja(["shape","payload","ctx"]),E=r.value,P=(q)=>{let M=Ma(q);return`shape[${M}]._zod.run({ value: input[${M}], issues: [] }, ctx)`};z.write("const input = payload.value;");let k=Object.create(null),A=0;for(let q of E.keys)k[q]=`key_${A++}`;z.write("const newResult = {};");for(let q of E.keys){let M=k[q],D=Ma(q),U=y[q],G=U?._zod?.optin==="optional",Ne=U?._zod?.optout==="optional";if(z.write(`const ${M} = ${P(q)};`),G&&Ne)z.write(`
|
|
4
|
-
if (${
|
|
5
|
-
if (${
|
|
6
|
-
payload.issues = payload.issues.concat(${
|
|
3
|
+
`))}}var nd={major:4,minor:4,patch:3};var G=g("$ZodType",(e,t)=>{var o;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=nd;let r=[...e._zod.def.checks??[]];if(e._zod.traits.has("$ZodCheck"))r.unshift(e);for(let n of r)for(let i of n._zod.onattach)i(e);if(r.length===0)(o=e._zod).deferred??(o.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let n=(s,c,d)=>{let p=lo(s),h;for(let f of c){if(f._zod.def.when){if(ou(s))continue;if(!f._zod.def.when(s))continue}else if(p)continue;let S=s.issues.length,b=f._zod.check(s);if(b instanceof Promise&&d?.async===!1)throw new bt;if(h||b instanceof Promise)h=(h??Promise.resolve()).then(async()=>{if(await b,s.issues.length===S)return;if(!p)p=lo(s,S)});else{if(s.issues.length===S)continue;if(!p)p=lo(s,S)}}if(h)return h.then(()=>s);return s},i=(s,c,d)=>{if(lo(s))return s.aborted=!0,s;let p=n(c,r,d);if(p instanceof Promise){if(d.async===!1)throw new bt;return p.then((h)=>e._zod.parse(h,d))}return e._zod.parse(p,d)};e._zod.run=(s,c)=>{if(c.skipChecks)return e._zod.parse(s,c);if(c.direction==="backward"){let p=e._zod.parse({value:s.value,issues:[]},{...c,skipChecks:!0});if(p instanceof Promise)return p.then((h)=>i(h,s,c));return i(p,s,c)}let d=e._zod.parse(s,c);if(d instanceof Promise){if(c.async===!1)throw new bt;return d.then((p)=>n(p,r,c))}return n(d,r,c)}}V(e,"~standard",()=>({validate:(n)=>{try{let i=su(e,n);return i.success?{value:i.data}:{issues:i.error?.issues}}catch(i){return iu(e,n).then((s)=>s.success?{value:s.data}:{issues:s.error?.issues})}},vendor:"zod",version:1}))}),Wi=g("$ZodString",(e,t)=>{G.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??Au(e._zod.bag),e._zod.parse=(o,r)=>{if(t.coerce)try{o.value=String(o.value)}catch(n){}if(typeof o.value==="string")return o;return o.issues.push({expected:"string",code:"invalid_type",input:o.value,inst:e}),o}}),ee=g("$ZodStringFormat",(e,t)=>{dn.init(e,t),Wi.init(e,t)}),hd=g("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=zu),ee.init(e,t)}),md=g("$ZodUUID",(e,t)=>{if(t.version){let r={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(r===void 0)throw Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=ac(r))}else t.pattern??(t.pattern=ac());ee.init(e,t)}),fd=g("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=Ru),ee.init(e,t)}),gd=g("$ZodURL",(e,t)=>{ee.init(e,t),e._zod.check=(o)=>{try{let r=o.value.trim();if(!t.normalize&&t.protocol?.source===$u.source){if(!/^https?:\/\//i.test(r)){o.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:o.value,inst:e,continue:!t.abort});return}}let n=new URL(r);if(t.hostname){if(t.hostname.lastIndex=0,!t.hostname.test(n.hostname))o.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:o.value,inst:e,continue:!t.abort})}if(t.protocol){if(t.protocol.lastIndex=0,!t.protocol.test(n.protocol.endsWith(":")?n.protocol.slice(0,-1):n.protocol))o.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:o.value,inst:e,continue:!t.abort})}if(t.normalize)o.value=n.href;else o.value=r;return}catch(r){o.issues.push({code:"invalid_format",format:"url",input:o.value,inst:e,continue:!t.abort})}}}),Sd=g("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=wu()),ee.init(e,t)}),_d=g("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=yu),ee.init(e,t)}),bd=g("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=fu),ee.init(e,t)}),yd=g("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=gu),ee.init(e,t)}),vd=g("$ZodULID",(e,t)=>{t.pattern??(t.pattern=Su),ee.init(e,t)}),zd=g("$ZodXID",(e,t)=>{t.pattern??(t.pattern=_u),ee.init(e,t)}),Rd=g("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=bu),ee.init(e,t)}),wd=g("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=Nu(t)),ee.init(e,t)}),xd=g("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=Ou),ee.init(e,t)}),Ed=g("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=qu(t)),ee.init(e,t)}),Td=g("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=vu),ee.init(e,t)}),Pd=g("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=xu),ee.init(e,t),e._zod.bag.format="ipv4"}),kd=g("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=Eu),ee.init(e,t),e._zod.bag.format="ipv6",e._zod.check=(o)=>{try{new URL(`http://[${o.value}]`)}catch{o.issues.push({code:"invalid_format",format:"ipv6",input:o.value,inst:e,continue:!t.abort})}}});var $d=g("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=Tu),ee.init(e,t)}),Cd=g("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=Pu),ee.init(e,t),e._zod.check=(o)=>{let r=o.value.split("/");try{if(r.length!==2)throw Error();let[n,i]=r;if(!i)throw Error();let s=Number(i);if(`${s}`!==i)throw Error();if(s<0||s>128)throw Error();new URL(`http://[${n}]`)}catch{o.issues.push({code:"invalid_format",format:"cidrv6",input:o.value,inst:e,continue:!t.abort})}}});function Id(e){if(e==="")return!0;if(/\s/.test(e))return!1;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}var Od=g("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=ku),ee.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=(o)=>{if(Id(o.value))return;o.issues.push({code:"invalid_format",format:"base64",input:o.value,inst:e,continue:!t.abort})}});function Xf(e){if(!cc.test(e))return!1;let t=e.replace(/[-_]/g,(r)=>r==="-"?"+":"/"),o=t.padEnd(Math.ceil(t.length/4)*4,"=");return Id(o)}var Md=g("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=cc),ee.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=(o)=>{if(Xf(o.value))return;o.issues.push({code:"invalid_format",format:"base64url",input:o.value,inst:e,continue:!t.abort})}}),qd=g("$ZodE164",(e,t)=>{t.pattern??(t.pattern=Cu),ee.init(e,t)});function eg(e,t=null){try{let o=e.split(".");if(o.length!==3)return!1;let[r]=o;if(!r)return!1;let n=JSON.parse(atob(r));if("typ"in n&&n?.typ!=="JWT")return!1;if(!n.alg)return!1;if(t&&(!("alg"in n)||n.alg!==t))return!1;return!0}catch{return!1}}var Nd=g("$ZodJWT",(e,t)=>{ee.init(e,t),e._zod.check=(o)=>{if(eg(o.value,t.alg))return;o.issues.push({code:"invalid_format",format:"jwt",input:o.value,inst:e,continue:!t.abort})}});var mc=g("$ZodNumber",(e,t)=>{G.init(e,t),e._zod.pattern=e._zod.bag.pattern??lc,e._zod.parse=(o,r)=>{if(t.coerce)try{o.value=Number(o.value)}catch(s){}let n=o.value;if(typeof n==="number"&&!Number.isNaN(n)&&Number.isFinite(n))return o;let i=typeof n==="number"?Number.isNaN(n)?"NaN":!Number.isFinite(n)?"Infinity":void 0:void 0;return o.issues.push({expected:"number",code:"invalid_type",input:n,inst:e,...i?{received:i}:{}}),o}}),Ad=g("$ZodNumberFormat",(e,t)=>{Ju.init(e,t),mc.init(e,t)}),jd=g("$ZodBoolean",(e,t)=>{G.init(e,t),e._zod.pattern=Lu,e._zod.parse=(o,r)=>{if(t.coerce)try{o.value=Boolean(o.value)}catch(i){}let n=o.value;if(typeof n==="boolean")return o;return o.issues.push({expected:"boolean",code:"invalid_type",input:n,inst:e}),o}});var Ld=g("$ZodUndefined",(e,t)=>{G.init(e,t),e._zod.pattern=Zu,e._zod.values=new Set([void 0]),e._zod.parse=(o,r)=>{let n=o.value;if(typeof n>"u")return o;return o.issues.push({expected:"undefined",code:"invalid_type",input:n,inst:e}),o}}),Ud=g("$ZodNull",(e,t)=>{G.init(e,t),e._zod.pattern=Uu,e._zod.values=new Set([null]),e._zod.parse=(o,r)=>{let n=o.value;if(n===null)return o;return o.issues.push({expected:"null",code:"invalid_type",input:n,inst:e}),o}}),Zd=g("$ZodAny",(e,t)=>{G.init(e,t),e._zod.parse=(o)=>o}),Dd=g("$ZodUnknown",(e,t)=>{G.init(e,t),e._zod.parse=(o)=>o}),Hd=g("$ZodNever",(e,t)=>{G.init(e,t),e._zod.parse=(o,r)=>(o.issues.push({expected:"never",code:"invalid_type",input:o.value,inst:e}),o)});function sd(e,t,o){if(e.issues.length)t.issues.push(...Ut(o,e.issues));t.value[o]=e.value}var Fd=g("$ZodArray",(e,t)=>{G.init(e,t),e._zod.parse=(o,r)=>{let n=o.value;if(!Array.isArray(n))return o.issues.push({expected:"array",code:"invalid_type",input:n,inst:e}),o;o.value=Array(n.length);let i=[];for(let s=0;s<n.length;s++){let c=n[s],d=t.element._zod.run({value:c,issues:[]},r);if(d instanceof Promise)i.push(d.then((p)=>sd(p,o,s)));else sd(d,o,s)}if(i.length)return Promise.all(i).then(()=>o);return o}});function Bi(e,t,o,r,n,i){let s=o in r;if(e.issues.length){if(n&&i&&!s)return;t.issues.push(...Ut(o,e.issues))}if(!s&&!n){if(!e.issues.length)t.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[o]});return}if(e.value===void 0){if(s)t.value[o]=void 0}else t.value[o]=e.value}function Vd(e){let t=Object.keys(e.shape);for(let r of t)if(!e.shape?.[r]?._zod?.traits?.has("$ZodType"))throw Error(`Invalid element at key "${r}": expected a Zod schema`);let o=eu(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(o)}}function Jd(e,t,o,r,n,i){let s=[],c=n.keySet,d=n.catchall._zod,p=d.def.type,h=d.optin==="optional",f=d.optout==="optional";for(let S in t){if(S==="__proto__")continue;if(c.has(S))continue;if(p==="never"){s.push(S);continue}let b=d.run({value:t[S],issues:[]},r);if(b instanceof Promise)e.push(b.then((R)=>Bi(R,o,S,t,h,f)));else Bi(b,o,S,t,h,f)}if(s.length)o.issues.push({code:"unrecognized_keys",keys:s,input:t,inst:i});if(!e.length)return o;return Promise.all(e).then(()=>o)}var tg=g("$ZodObject",(e,t)=>{if(G.init(e,t),!Object.getOwnPropertyDescriptor(t,"shape")?.get){let c=t.shape;Object.defineProperty(t,"shape",{get:()=>{let d={...c};return Object.defineProperty(t,"shape",{value:d}),d}})}let r=an(()=>Vd(t));V(e._zod,"propValues",()=>{let c=t.shape,d={};for(let p in c){let h=c[p]._zod;if(h.values){d[p]??(d[p]=new Set);for(let f of h.values)d[p].add(f)}}return d});let n=Ho,i=t.catchall,s;e._zod.parse=(c,d)=>{s??(s=r.value);let p=c.value;if(!n(p))return c.issues.push({expected:"object",code:"invalid_type",input:p,inst:e}),c;c.value={};let h=[],f=s.shape;for(let S of s.keys){let b=f[S],R=b._zod.optin==="optional",w=b._zod.optout==="optional",O=b._zod.run({value:p[S],issues:[]},d);if(O instanceof Promise)h.push(O.then((J)=>Bi(J,c,S,p,R,w)));else Bi(O,c,S,p,R,w)}if(!i)return h.length?Promise.all(h).then(()=>c):c;return Jd(h,p,c,d,r.value,e)}}),Bd=g("$ZodObjectJIT",(e,t)=>{tg.init(e,t);let o=e._zod.parse,r=an(()=>Vd(t)),n=(S)=>{let b=new pc(["shape","payload","ctx"]),R=r.value,w=(j)=>{let F=ec(j);return`shape[${F}]._zod.run({ value: input[${F}], issues: [] }, ctx)`};b.write("const input = payload.value;");let O=Object.create(null),J=0;for(let j of R.keys)O[j]=`key_${J++}`;b.write("const newResult = {};");for(let j of R.keys){let F=O[j],Y=ec(j),K=S[j],ie=K?._zod?.optin==="optional",Le=K?._zod?.optout==="optional";if(b.write(`const ${F} = ${w(j)};`),ie&&Le)b.write(`
|
|
4
|
+
if (${F}.issues.length) {
|
|
5
|
+
if (${Y} in input) {
|
|
6
|
+
payload.issues = payload.issues.concat(${F}.issues.map(iss => ({
|
|
7
7
|
...iss,
|
|
8
|
-
path: iss.path ? [${
|
|
8
|
+
path: iss.path ? [${Y}, ...iss.path] : [${Y}]
|
|
9
9
|
})));
|
|
10
10
|
}
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
if (${
|
|
14
|
-
if (${
|
|
15
|
-
newResult[${
|
|
13
|
+
if (${F}.value === undefined) {
|
|
14
|
+
if (${Y} in input) {
|
|
15
|
+
newResult[${Y}] = undefined;
|
|
16
16
|
}
|
|
17
17
|
} else {
|
|
18
|
-
newResult[${
|
|
18
|
+
newResult[${Y}] = ${F}.value;
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
`);else if(!
|
|
22
|
-
const ${
|
|
23
|
-
if (${
|
|
24
|
-
payload.issues = payload.issues.concat(${
|
|
21
|
+
`);else if(!ie)b.write(`
|
|
22
|
+
const ${F}_present = ${Y} in input;
|
|
23
|
+
if (${F}.issues.length) {
|
|
24
|
+
payload.issues = payload.issues.concat(${F}.issues.map(iss => ({
|
|
25
25
|
...iss,
|
|
26
|
-
path: iss.path ? [${
|
|
26
|
+
path: iss.path ? [${Y}, ...iss.path] : [${Y}]
|
|
27
27
|
})));
|
|
28
28
|
}
|
|
29
|
-
if (!${
|
|
29
|
+
if (!${F}_present && !${F}.issues.length) {
|
|
30
30
|
payload.issues.push({
|
|
31
31
|
code: "invalid_type",
|
|
32
32
|
expected: "nonoptional",
|
|
33
33
|
input: undefined,
|
|
34
|
-
path: [${
|
|
34
|
+
path: [${Y}]
|
|
35
35
|
});
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
if (${
|
|
39
|
-
if (${
|
|
40
|
-
newResult[${
|
|
38
|
+
if (${F}_present) {
|
|
39
|
+
if (${F}.value === undefined) {
|
|
40
|
+
newResult[${Y}] = undefined;
|
|
41
41
|
} else {
|
|
42
|
-
newResult[${
|
|
42
|
+
newResult[${Y}] = ${F}.value;
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
`);else
|
|
47
|
-
if (${
|
|
48
|
-
payload.issues = payload.issues.concat(${
|
|
46
|
+
`);else b.write(`
|
|
47
|
+
if (${F}.issues.length) {
|
|
48
|
+
payload.issues = payload.issues.concat(${F}.issues.map(iss => ({
|
|
49
49
|
...iss,
|
|
50
|
-
path: iss.path ? [${
|
|
50
|
+
path: iss.path ? [${Y}, ...iss.path] : [${Y}]
|
|
51
51
|
})));
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
-
if (${
|
|
55
|
-
if (${
|
|
56
|
-
newResult[${
|
|
54
|
+
if (${F}.value === undefined) {
|
|
55
|
+
if (${Y} in input) {
|
|
56
|
+
newResult[${Y}] = undefined;
|
|
57
57
|
}
|
|
58
58
|
} else {
|
|
59
|
-
newResult[${
|
|
59
|
+
newResult[${Y}] = ${F}.value;
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
-
`)}z.write("payload.value = newResult;"),z.write("return payload;");let B=z.compile();return(q,M)=>B(y,q,M)},i,a=fo,u=!mo.jitless,p=u&&wl.value,f=t.catchall,b;e._zod.parse=(y,z)=>{b??(b=r.value);let E=y.value;if(!a(E))return y.issues.push({expected:"object",code:"invalid_type",input:E,inst:e}),y;if(u&&p&&z?.async===!1&&z.jitless!==!0){if(!i)i=n(t.shape);if(y=i(y,z),!f)return y;return _d([],E,y,z,b,e)}return o(y,z)}});function Iu(e,t,o,r){for(let i of e)if(i.issues.length===0)return t.value=i.value,t;let n=e.filter((i)=>!$t(i));if(n.length===1)return t.value=n[0].value,n[0];return t.issues.push({code:"invalid_union",input:t.value,inst:o,errors:e.map((i)=>i.issues.map((a)=>Te(a,r,ce())))}),t}var Ka=m("$ZodUnion",(e,t)=>{N.init(e,t),O(e._zod,"optin",()=>t.options.some((r)=>r._zod.optin==="optional")?"optional":void 0),O(e._zod,"optout",()=>t.options.some((r)=>r._zod.optout==="optional")?"optional":void 0),O(e._zod,"values",()=>{if(t.options.every((r)=>r._zod.values))return new Set(t.options.flatMap((r)=>Array.from(r._zod.values)));return}),O(e._zod,"pattern",()=>{if(t.options.every((r)=>r._zod.pattern)){let r=t.options.map((n)=>n._zod.pattern);return new RegExp(`^(${r.map((n)=>Ti(n.source)).join("|")})$`)}return});let o=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(r,n)=>{if(o)return o(r,n);let i=!1,a=[];for(let u of t.options){let d=u._zod.run({value:r.value,issues:[]},n);if(d instanceof Promise)a.push(d),i=!0;else{if(d.issues.length===0)return d;a.push(d)}}if(!i)return Iu(a,r,e,n);return Promise.all(a).then((u)=>Iu(u,r,e,n))}});var yd=m("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,Ka.init(e,t);let o=e._zod.parse;O(e._zod,"propValues",()=>{let n={};for(let i of t.options){let a=i._zod.propValues;if(!a||Object.keys(a).length===0)throw Error(`Invalid discriminated union option at index "${t.options.indexOf(i)}"`);for(let[u,d]of Object.entries(a)){if(!n[u])n[u]=new Set;for(let p of d)n[u].add(p)}}return n});let r=Wr(()=>{let n=t.options,i=new Map;for(let a of n){let u=a._zod.propValues?.[t.discriminator];if(!u||u.size===0)throw Error(`Invalid discriminated union option at index "${t.options.indexOf(a)}"`);for(let d of u){if(i.has(d))throw Error(`Duplicate discriminator value "${String(d)}"`);i.set(d,a)}}return i});e._zod.parse=(n,i)=>{let a=n.value;if(!fo(a))return n.issues.push({code:"invalid_type",expected:"object",input:a,inst:e}),n;let u=r.value.get(a?.[t.discriminator]);if(u)return u._zod.run(n,i);if(t.unionFallback||i.direction==="backward")return o(n,i);return n.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,options:Array.from(r.value.keys()),input:a,path:[t.discriminator],inst:e}),n}}),vd=m("$ZodIntersection",(e,t)=>{N.init(e,t),e._zod.parse=(o,r)=>{let n=o.value,i=t.left._zod.run({value:n,issues:[]},r),a=t.right._zod.run({value:n,issues:[]},r);if(i instanceof Promise||a instanceof Promise)return Promise.all([i,a]).then(([d,p])=>Ou(o,d,p));return Ou(o,i,a)}});function Ba(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e===+t)return{valid:!0,data:e};if(kt(e)&&kt(t)){let o=Object.keys(t),r=Object.keys(e).filter((i)=>o.indexOf(i)!==-1),n={...e,...t};for(let i of r){let a=Ba(e[i],t[i]);if(!a.valid)return{valid:!1,mergeErrorPath:[i,...a.mergeErrorPath]};n[i]=a.data}return{valid:!0,data:n}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let o=[];for(let r=0;r<e.length;r++){let n=e[r],i=t[r],a=Ba(n,i);if(!a.valid)return{valid:!1,mergeErrorPath:[r,...a.mergeErrorPath]};o.push(a.data)}return{valid:!0,data:o}}return{valid:!1,mergeErrorPath:[]}}function Ou(e,t,o){let r=new Map,n;for(let u of t.issues)if(u.code==="unrecognized_keys"){n??(n=u);for(let d of u.keys){if(!r.has(d))r.set(d,{});r.get(d).l=!0}}else e.issues.push(u);for(let u of o.issues)if(u.code==="unrecognized_keys")for(let d of u.keys){if(!r.has(d))r.set(d,{});r.get(d).r=!0}else e.issues.push(u);let i=[...r].filter(([,u])=>u.l&&u.r).map(([u])=>u);if(i.length&&n)e.issues.push({...n,keys:i});if($t(e))return e;let a=Ba(t.value,o.value);if(!a.valid)throw Error(`Unmergable intersection. Error path: ${JSON.stringify(a.mergeErrorPath)}`);return e.value=a.data,e}var zd=m("$ZodRecord",(e,t)=>{N.init(e,t),e._zod.parse=(o,r)=>{let n=o.value;if(!kt(n))return o.issues.push({expected:"record",code:"invalid_type",input:n,inst:e}),o;let i=[],a=t.keyType._zod.values;if(a){o.value={};let u=new Set;for(let p of a)if(typeof p==="string"||typeof p==="number"||typeof p==="symbol"){u.add(typeof p==="number"?p.toString():p);let f=t.keyType._zod.run({value:p,issues:[]},r);if(f instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(f.issues.length){o.issues.push({code:"invalid_key",origin:"record",issues:f.issues.map((z)=>Te(z,r,ce())),input:p,path:[p],inst:e});continue}let b=f.value,y=t.valueType._zod.run({value:n[p],issues:[]},r);if(y instanceof Promise)i.push(y.then((z)=>{if(z.issues.length)o.issues.push(...st(p,z.issues));o.value[b]=z.value}));else{if(y.issues.length)o.issues.push(...st(p,y.issues));o.value[b]=y.value}}let d;for(let p in n)if(!u.has(p))d=d??[],d.push(p);if(d&&d.length>0)o.issues.push({code:"unrecognized_keys",input:n,inst:e,keys:d})}else{o.value={};for(let u of Reflect.ownKeys(n)){if(u==="__proto__")continue;if(!Object.prototype.propertyIsEnumerable.call(n,u))continue;let d=t.keyType._zod.run({value:u,issues:[]},r);if(d instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(typeof u==="string"&&Ha.test(u)&&d.issues.length){let b=t.keyType._zod.run({value:Number(u),issues:[]},r);if(b instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(b.issues.length===0)d=b}if(d.issues.length){if(t.mode==="loose")o.value[u]=n[u];else o.issues.push({code:"invalid_key",origin:"record",issues:d.issues.map((b)=>Te(b,r,ce())),input:u,path:[u],inst:e});continue}let f=t.valueType._zod.run({value:n[u],issues:[]},r);if(f instanceof Promise)i.push(f.then((b)=>{if(b.issues.length)o.issues.push(...st(u,b.issues));o.value[d.value]=b.value}));else{if(f.issues.length)o.issues.push(...st(u,f.issues));o.value[d.value]=f.value}}}if(i.length)return Promise.all(i).then(()=>o);return o}});var Rd=m("$ZodEnum",(e,t)=>{N.init(e,t);let o=wi(t.entries),r=new Set(o);e._zod.values=r,e._zod.pattern=new RegExp(`^(${o.filter((n)=>xl.has(typeof n)).map((n)=>typeof n==="string"?nt(n):n.toString()).join("|")})$`),e._zod.parse=(n,i)=>{let a=n.value;if(r.has(a))return n;return n.issues.push({code:"invalid_value",values:o,input:a,inst:e}),n}}),wd=m("$ZodLiteral",(e,t)=>{if(N.init(e,t),t.values.length===0)throw Error("Cannot create literal schema with no valid values");let o=new Set(t.values);e._zod.values=o,e._zod.pattern=new RegExp(`^(${t.values.map((r)=>typeof r==="string"?nt(r):r?nt(r.toString()):String(r)).join("|")})$`),e._zod.parse=(r,n)=>{let i=r.value;if(o.has(i))return r;return r.issues.push({code:"invalid_value",values:t.values,input:i,inst:e}),r}});var xd=m("$ZodTransform",(e,t)=>{N.init(e,t),e._zod.optin="optional",e._zod.parse=(o,r)=>{if(r.direction==="backward")throw new Jr(e.constructor.name);let n=t.transform(o.value,o);if(r.async)return(n instanceof Promise?n:Promise.resolve(n)).then((a)=>(o.value=a,o.fallback=!0,o));if(n instanceof Promise)throw new Le;return o.value=n,o.fallback=!0,o}});function Mu(e,t){if(t===void 0&&(e.issues.length||e.fallback))return{issues:[],value:void 0};return e}var Ga=m("$ZodOptional",(e,t)=>{N.init(e,t),e._zod.optin="optional",e._zod.optout="optional",O(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),O(e._zod,"pattern",()=>{let o=t.innerType._zod.pattern;return o?new RegExp(`^(${Ti(o.source)})?$`):void 0}),e._zod.parse=(o,r)=>{if(t.innerType._zod.optin==="optional"){let n=o.value,i=t.innerType._zod.run(o,r);if(i instanceof Promise)return i.then((a)=>Mu(a,n));return Mu(i,n)}if(o.value===void 0)return o;return t.innerType._zod.run(o,r)}}),Td=m("$ZodExactOptional",(e,t)=>{Ga.init(e,t),O(e._zod,"values",()=>t.innerType._zod.values),O(e._zod,"pattern",()=>t.innerType._zod.pattern),e._zod.parse=(o,r)=>t.innerType._zod.run(o,r)}),Ed=m("$ZodNullable",(e,t)=>{N.init(e,t),O(e._zod,"optin",()=>t.innerType._zod.optin),O(e._zod,"optout",()=>t.innerType._zod.optout),O(e._zod,"pattern",()=>{let o=t.innerType._zod.pattern;return o?new RegExp(`^(${Ti(o.source)}|null)$`):void 0}),O(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(o,r)=>{if(o.value===null)return o;return t.innerType._zod.run(o,r)}}),Pd=m("$ZodDefault",(e,t)=>{N.init(e,t),e._zod.optin="optional",O(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(o,r)=>{if(r.direction==="backward")return t.innerType._zod.run(o,r);if(o.value===void 0)return o.value=t.defaultValue,o;let n=t.innerType._zod.run(o,r);if(n instanceof Promise)return n.then((i)=>qu(i,t));return qu(n,t)}});function qu(e,t){if(e.value===void 0)e.value=t.defaultValue;return e}var kd=m("$ZodPrefault",(e,t)=>{N.init(e,t),e._zod.optin="optional",O(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(o,r)=>{if(r.direction==="backward")return t.innerType._zod.run(o,r);if(o.value===void 0)o.value=t.defaultValue;return t.innerType._zod.run(o,r)}}),$d=m("$ZodNonOptional",(e,t)=>{N.init(e,t),O(e._zod,"values",()=>{let o=t.innerType._zod.values;return o?new Set([...o].filter((r)=>r!==void 0)):void 0}),e._zod.parse=(o,r)=>{let n=t.innerType._zod.run(o,r);if(n instanceof Promise)return n.then((i)=>Nu(i,e));return Nu(n,e)}});function Nu(e,t){if(!e.issues.length&&e.value===void 0)e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t});return e}var Cd=m("$ZodCatch",(e,t)=>{N.init(e,t),e._zod.optin="optional",O(e._zod,"optout",()=>t.innerType._zod.optout),O(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(o,r)=>{if(r.direction==="backward")return t.innerType._zod.run(o,r);let n=t.innerType._zod.run(o,r);if(n instanceof Promise)return n.then((i)=>{if(o.value=i.value,i.issues.length)o.value=t.catchValue({...o,error:{issues:i.issues.map((a)=>Te(a,r,ce()))},input:o.value}),o.issues=[],o.fallback=!0;return o});if(o.value=n.value,n.issues.length)o.value=t.catchValue({...o,error:{issues:n.issues.map((i)=>Te(i,r,ce()))},input:o.value}),o.issues=[],o.fallback=!0;return o}});var Ya=m("$ZodPipe",(e,t)=>{N.init(e,t),O(e._zod,"values",()=>t.in._zod.values),O(e._zod,"optin",()=>t.in._zod.optin),O(e._zod,"optout",()=>t.out._zod.optout),O(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(o,r)=>{if(r.direction==="backward"){let i=t.out._zod.run(o,r);if(i instanceof Promise)return i.then((a)=>Ci(a,t.in,r));return Ci(i,t.in,r)}let n=t.in._zod.run(o,r);if(n instanceof Promise)return n.then((i)=>Ci(i,t.out,r));return Ci(n,t.out,r)}});function Ci(e,t,o){if(e.issues.length)return e.aborted=!0,e;return t._zod.run({value:e.value,issues:e.issues,fallback:e.fallback},o)}var Id=m("$ZodPreprocess",(e,t)=>{Ya.init(e,t)}),Od=m("$ZodReadonly",(e,t)=>{N.init(e,t),O(e._zod,"propValues",()=>t.innerType._zod.propValues),O(e._zod,"values",()=>t.innerType._zod.values),O(e._zod,"optin",()=>t.innerType?._zod?.optin),O(e._zod,"optout",()=>t.innerType?._zod?.optout),e._zod.parse=(o,r)=>{if(r.direction==="backward")return t.innerType._zod.run(o,r);let n=t.innerType._zod.run(o,r);if(n instanceof Promise)return n.then(Au);return Au(n)}});function Au(e){return e.value=Object.freeze(e.value),e}var Md=m("$ZodLazy",(e,t)=>{N.init(e,t),O(e._zod,"innerType",()=>{let o=t;if(!o._cachedInner)o._cachedInner=t.getter();return o._cachedInner}),O(e._zod,"pattern",()=>e._zod.innerType?._zod?.pattern),O(e._zod,"propValues",()=>e._zod.innerType?._zod?.propValues),O(e._zod,"optin",()=>e._zod.innerType?._zod?.optin??void 0),O(e._zod,"optout",()=>e._zod.innerType?._zod?.optout??void 0),e._zod.parse=(o,r)=>e._zod.innerType._zod.run(o,r)}),qd=m("$ZodCustom",(e,t)=>{X.init(e,t),N.init(e,t),e._zod.parse=(o,r)=>o,e._zod.check=(o)=>{let r=o.value,n=t.fn(r);if(n instanceof Promise)return n.then((i)=>ju(i,o,r,e));ju(n,o,r,e);return}});function ju(e,t,o,r){if(!e){let n={code:"custom",input:o,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};if(r._zod.def.params)n.params=r._zod.def.params;t.issues.push(Ct(n))}}var sf=()=>{let e={string:{unit:"characters",verb:"to have"},file:{unit:"bytes",verb:"to have"},array:{unit:"items",verb:"to have"},set:{unit:"items",verb:"to have"},map:{unit:"entries",verb:"to have"}};function t(n){return e[n]??null}let o={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",mac:"MAC address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",jwt:"JWT",template_literal:"input"},r={nan:"NaN"};return(n)=>{switch(n.code){case"invalid_type":{let i=r[n.expected]??n.expected,a=kl(n.input),u=r[a]??a;return`Invalid input: expected ${i}, received ${u}`}case"invalid_value":if(n.values.length===1)return`Invalid input: expected ${Aa(n.values[0])}`;return`Invalid option: expected one of ${Oa(n.values,"|")}`;case"too_big":{let i=n.inclusive?"<=":"<",a=t(n.origin);if(a)return`Too big: expected ${n.origin??"value"} to have ${i}${n.maximum.toString()} ${a.unit??"elements"}`;return`Too big: expected ${n.origin??"value"} to be ${i}${n.maximum.toString()}`}case"too_small":{let i=n.inclusive?">=":">",a=t(n.origin);if(a)return`Too small: expected ${n.origin} to have ${i}${n.minimum.toString()} ${a.unit}`;return`Too small: expected ${n.origin} to be ${i}${n.minimum.toString()}`}case"invalid_format":{let i=n;if(i.format==="starts_with")return`Invalid string: must start with "${i.prefix}"`;if(i.format==="ends_with")return`Invalid string: must end with "${i.suffix}"`;if(i.format==="includes")return`Invalid string: must include "${i.includes}"`;if(i.format==="regex")return`Invalid string: must match pattern ${i.pattern}`;return`Invalid ${o[i.format]??n.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${n.divisor}`;case"unrecognized_keys":return`Unrecognized key${n.keys.length>1?"s":""}: ${Oa(n.keys,", ")}`;case"invalid_key":return`Invalid key in ${n.origin}`;case"invalid_union":if(n.options&&Array.isArray(n.options)&&n.options.length>0)return`Invalid discriminator value. Expected ${n.options.map((a)=>`'${a}'`).join(" | ")}`;return"Invalid input";case"invalid_element":return`Invalid value in ${n.origin}`;default:return"Invalid input"}}};function Qa(){return{localeError:sf()}}var Nd,af=Symbol("ZodOutput"),cf=Symbol("ZodInput");class Ad{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){let o=t[0];if(this._map.set(e,o),o&&typeof o==="object"&&"id"in o)this._idmap.set(o.id,e);return this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let t=this._map.get(e);if(t&&typeof t==="object"&&"id"in t)this._idmap.delete(t.id);return this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let o={...this.get(t)??{}};delete o.id;let r={...o,...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 jd(){return new Ad}(Nd=globalThis).__zod_globalRegistry??(Nd.__zod_globalRegistry=jd());var it=globalThis.__zod_globalRegistry;function Ld(e,t){return new e({type:"string",...w(t)})}function Xa(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...w(t)})}function ec(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...w(t)})}function Ud(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...w(t)})}function Zd(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...w(t)})}function Dd(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...w(t)})}function Hd(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...w(t)})}function tc(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...w(t)})}function Fd(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...w(t)})}function Vd(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...w(t)})}function Jd(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...w(t)})}function Bd(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...w(t)})}function Wd(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...w(t)})}function Kd(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...w(t)})}function Gd(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...w(t)})}function Yd(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...w(t)})}function Qd(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...w(t)})}function Xd(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...w(t)})}function ep(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...w(t)})}function tp(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...w(t)})}function op(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...w(t)})}function rp(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...w(t)})}function np(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...w(t)})}function sp(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...w(t)})}function ip(e,t){return new e({type:"string",format:"date",check:"string_format",...w(t)})}function ap(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...w(t)})}function cp(e,t){return new e({type:"string",format:"duration",check:"string_format",...w(t)})}function lp(e,t){return new e({type:"number",checks:[],...w(t)})}function up(e,t){return new e({type:"number",coerce:!0,checks:[],...w(t)})}function dp(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...w(t)})}function pp(e,t){return new e({type:"boolean",...w(t)})}function hp(e,t){return new e({type:"undefined",...w(t)})}function mp(e,t){return new e({type:"null",...w(t)})}function fp(e){return new e({type:"any"})}function gp(e){return new e({type:"unknown"})}function Sp(e,t){return new e({type:"never",...w(t)})}function Mi(e,t){return new Fa({check:"less_than",...w(t),value:e,inclusive:!1})}function Xr(e,t){return new Fa({check:"less_than",...w(t),value:e,inclusive:!0})}function qi(e,t){return new Va({check:"greater_than",...w(t),value:e,inclusive:!1})}function en(e,t){return new Va({check:"greater_than",...w(t),value:e,inclusive:!0})}function Ni(e,t){return new Su({check:"multiple_of",...w(t),value:e})}function Ai(e,t){return new bu({check:"max_length",...w(t),maximum:e})}function go(e,t){return new yu({check:"min_length",...w(t),minimum:e})}function ji(e,t){return new vu({check:"length_equals",...w(t),length:e})}function oc(e,t){return new zu({check:"string_format",format:"regex",...w(t),pattern:e})}function rc(e){return new Ru({check:"string_format",format:"lowercase",...w(e)})}function nc(e){return new wu({check:"string_format",format:"uppercase",...w(e)})}function sc(e,t){return new xu({check:"string_format",format:"includes",...w(t),includes:e})}function ic(e,t){return new Tu({check:"string_format",format:"starts_with",...w(t),prefix:e})}function ac(e,t){return new Eu({check:"string_format",format:"ends_with",...w(t),suffix:e})}function at(e){return new Pu({check:"overwrite",tx:e})}function cc(e){return at((t)=>t.normalize(e))}function lc(){return at((e)=>e.trim())}function uc(){return at((e)=>e.toLowerCase())}function dc(){return at((e)=>e.toUpperCase())}function pc(){return at((e)=>Rl(e))}function _p(e,t,o){return new e({type:"array",element:t,...w(o)})}function bp(e,t,o){return new e({type:"custom",check:"custom",fn:t,...w(o)})}function yp(e,t){let o=lf((r)=>(r.addIssue=(n)=>{if(typeof n==="string")r.issues.push(Ct(n,r.value,o._zod.def));else{let i=n;if(i.fatal)i.continue=!1;i.code??(i.code="custom"),i.input??(i.input=r.value),i.inst??(i.inst=o),i.continue??(i.continue=!o._zod.def.abort),r.issues.push(Ct(i))}},e(r.value,r)),t);return o}function lf(e,t){let o=new X({check:"custom",...w(t)});return o._zod.check=e,o}function on(e){let t=e?.target??"draft-2020-12";if(t==="draft-4")t="draft-04";if(t==="draft-7")t="draft-07";return{processors:e.processors??{},metadataRegistry:e?.metadata??it,target:t,unrepresentable:e?.unrepresentable??"throw",override:e?.override??(()=>{}),io:e?.io??"output",counter:0,seen:new Map,cycles:e?.cycles??"ref",reused:e?.reused??"inline",external:e?.external??void 0}}function j(e,t,o={path:[],schemaPath:[]}){var r;let n=e._zod.def,i=t.seen.get(e);if(i){if(i.count++,o.schemaPath.includes(e))i.cycle=o.path;return i.schema}let a={schema:{},count:1,cycle:void 0,path:o.path};t.seen.set(e,a);let u=e._zod.toJSONSchema?.();if(u)a.schema=u;else{let f={...o,schemaPath:[...o.schemaPath,e],path:o.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,a.schema,f);else{let y=a.schema,z=t.processors[n.type];if(!z)throw Error(`[toJSONSchema]: Non-representable type encountered: ${n.type}`);z(e,t,y,f)}let b=e._zod.parent;if(b){if(!a.ref)a.ref=b;j(b,t,f),t.seen.get(b).isParent=!0}}let d=t.metadataRegistry.get(e);if(d)Object.assign(a.schema,d);if(t.io==="input"&&le(e))delete a.schema.examples,delete a.schema.default;if(t.io==="input"&&"_prefault"in a.schema)(r=a.schema).default??(r.default=a.schema._prefault);return delete a.schema._prefault,t.seen.get(e).schema}function rn(e,t){let o=e.seen.get(t);if(!o)throw Error("Unprocessed schema. This is a bug in Zod.");let r=new Map;for(let a of e.seen.entries()){let u=e.metadataRegistry.get(a[0])?.id;if(u){let d=r.get(u);if(d&&d!==a[0])throw Error(`Duplicate schema id "${u}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(u,a[0])}}let n=(a)=>{let u=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){let b=e.external.registry.get(a[0])?.id,y=e.external.uri??((E)=>E);if(b)return{ref:y(b)};let z=a[1].defId??a[1].schema.id??`schema${e.counter++}`;return a[1].defId=z,{defId:z,ref:`${y("__shared")}#/${u}/${z}`}}if(a[1]===o)return{ref:"#"};let p=`${"#"}/${u}/`,f=a[1].schema.id??`__schema${e.counter++}`;return{defId:f,ref:p+f}},i=(a)=>{if(a[1].schema.$ref)return;let u=a[1],{ref:d,defId:p}=n(a);if(u.def={...u.schema},p)u.defId=p;let f=u.schema;for(let b in f)delete f[b];f.$ref=d};if(e.cycles==="throw")for(let a of e.seen.entries()){let u=a[1];if(u.cycle)throw Error(`Cycle detected: #/${u.cycle?.join("/")}/<root>
|
|
62
|
+
`)}b.write("payload.value = newResult;"),b.write("return payload;");let B=b.compile();return(j,F)=>B(S,j,F)},i,s=Ho,c=!Do.jitless,p=c&&Ql.value,h=t.catchall,f;e._zod.parse=(S,b)=>{f??(f=r.value);let R=S.value;if(!s(R))return S.issues.push({expected:"object",code:"invalid_type",input:R,inst:e}),S;if(c&&p&&b?.async===!1&&b.jitless!==!0){if(!i)i=n(t.shape);if(S=i(S,b),!h)return S;return Jd([],R,S,b,f,e)}return o(S,b)}});function id(e,t,o,r){for(let i of e)if(i.issues.length===0)return t.value=i.value,t;let n=e.filter((i)=>!lo(i));if(n.length===1)return t.value=n[0].value,n[0];return t.issues.push({code:"invalid_union",input:t.value,inst:o,errors:e.map((i)=>i.issues.map((s)=>Qe(s,r,ze())))}),t}var fc=g("$ZodUnion",(e,t)=>{G.init(e,t),V(e._zod,"optin",()=>t.options.some((r)=>r._zod.optin==="optional")?"optional":void 0),V(e._zod,"optout",()=>t.options.some((r)=>r._zod.optout==="optional")?"optional":void 0),V(e._zod,"values",()=>{if(t.options.every((r)=>r._zod.values))return new Set(t.options.flatMap((r)=>Array.from(r._zod.values)));return}),V(e._zod,"pattern",()=>{if(t.options.every((r)=>r._zod.pattern)){let r=t.options.map((n)=>n._zod.pattern);return new RegExp(`^(${r.map((n)=>Zi(n.source)).join("|")})$`)}return});let o=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(r,n)=>{if(o)return o(r,n);let i=!1,s=[];for(let c of t.options){let d=c._zod.run({value:r.value,issues:[]},n);if(d instanceof Promise)s.push(d),i=!0;else{if(d.issues.length===0)return d;s.push(d)}}if(!i)return id(s,r,e,n);return Promise.all(s).then((c)=>id(c,r,e,n))}});var Wd=g("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,fc.init(e,t);let o=e._zod.parse;V(e._zod,"propValues",()=>{let n={};for(let i of t.options){let s=i._zod.propValues;if(!s||Object.keys(s).length===0)throw Error(`Invalid discriminated union option at index "${t.options.indexOf(i)}"`);for(let[c,d]of Object.entries(s)){if(!n[c])n[c]=new Set;for(let p of d)n[c].add(p)}}return n});let r=an(()=>{let n=t.options,i=new Map;for(let s of n){let c=s._zod.propValues?.[t.discriminator];if(!c||c.size===0)throw Error(`Invalid discriminated union option at index "${t.options.indexOf(s)}"`);for(let d of c){if(i.has(d))throw Error(`Duplicate discriminator value "${String(d)}"`);i.set(d,s)}}return i});e._zod.parse=(n,i)=>{let s=n.value;if(!Ho(s))return n.issues.push({code:"invalid_type",expected:"object",input:s,inst:e}),n;let c=r.value.get(s?.[t.discriminator]);if(c)return c._zod.run(n,i);if(t.unionFallback||i.direction==="backward")return o(n,i);return n.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,options:Array.from(r.value.keys()),input:s,path:[t.discriminator],inst:e}),n}}),Kd=g("$ZodIntersection",(e,t)=>{G.init(e,t),e._zod.parse=(o,r)=>{let n=o.value,i=t.left._zod.run({value:n,issues:[]},r),s=t.right._zod.run({value:n,issues:[]},r);if(i instanceof Promise||s instanceof Promise)return Promise.all([i,s]).then(([d,p])=>ad(o,d,p));return ad(o,i,s)}});function hc(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e===+t)return{valid:!0,data:e};if(co(e)&&co(t)){let o=Object.keys(t),r=Object.keys(e).filter((i)=>o.indexOf(i)!==-1),n={...e,...t};for(let i of r){let s=hc(e[i],t[i]);if(!s.valid)return{valid:!1,mergeErrorPath:[i,...s.mergeErrorPath]};n[i]=s.data}return{valid:!0,data:n}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let o=[];for(let r=0;r<e.length;r++){let n=e[r],i=t[r],s=hc(n,i);if(!s.valid)return{valid:!1,mergeErrorPath:[r,...s.mergeErrorPath]};o.push(s.data)}return{valid:!0,data:o}}return{valid:!1,mergeErrorPath:[]}}function ad(e,t,o){let r=new Map,n;for(let c of t.issues)if(c.code==="unrecognized_keys"){n??(n=c);for(let d of c.keys){if(!r.has(d))r.set(d,{});r.get(d).l=!0}}else e.issues.push(c);for(let c of o.issues)if(c.code==="unrecognized_keys")for(let d of c.keys){if(!r.has(d))r.set(d,{});r.get(d).r=!0}else e.issues.push(c);let i=[...r].filter(([,c])=>c.l&&c.r).map(([c])=>c);if(i.length&&n)e.issues.push({...n,keys:i});if(lo(e))return e;let s=hc(t.value,o.value);if(!s.valid)throw Error(`Unmergable intersection. Error path: ${JSON.stringify(s.mergeErrorPath)}`);return e.value=s.data,e}var Gd=g("$ZodRecord",(e,t)=>{G.init(e,t),e._zod.parse=(o,r)=>{let n=o.value;if(!co(n))return o.issues.push({expected:"record",code:"invalid_type",input:n,inst:e}),o;let i=[],s=t.keyType._zod.values;if(s){o.value={};let c=new Set;for(let p of s)if(typeof p==="string"||typeof p==="number"||typeof p==="symbol"){c.add(typeof p==="number"?p.toString():p);let h=t.keyType._zod.run({value:p,issues:[]},r);if(h instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(h.issues.length){o.issues.push({code:"invalid_key",origin:"record",issues:h.issues.map((b)=>Qe(b,r,ze())),input:p,path:[p],inst:e});continue}let f=h.value,S=t.valueType._zod.run({value:n[p],issues:[]},r);if(S instanceof Promise)i.push(S.then((b)=>{if(b.issues.length)o.issues.push(...Ut(p,b.issues));o.value[f]=b.value}));else{if(S.issues.length)o.issues.push(...Ut(p,S.issues));o.value[f]=S.value}}let d;for(let p in n)if(!c.has(p))d=d??[],d.push(p);if(d&&d.length>0)o.issues.push({code:"unrecognized_keys",input:n,inst:e,keys:d})}else{o.value={};for(let c of Reflect.ownKeys(n)){if(c==="__proto__")continue;if(!Object.prototype.propertyIsEnumerable.call(n,c))continue;let d=t.keyType._zod.run({value:c,issues:[]},r);if(d instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(typeof c==="string"&&lc.test(c)&&d.issues.length){let f=t.keyType._zod.run({value:Number(c),issues:[]},r);if(f instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(f.issues.length===0)d=f}if(d.issues.length){if(t.mode==="loose")o.value[c]=n[c];else o.issues.push({code:"invalid_key",origin:"record",issues:d.issues.map((f)=>Qe(f,r,ze())),input:c,path:[c],inst:e});continue}let h=t.valueType._zod.run({value:n[c],issues:[]},r);if(h instanceof Promise)i.push(h.then((f)=>{if(f.issues.length)o.issues.push(...Ut(c,f.issues));o.value[d.value]=f.value}));else{if(h.issues.length)o.issues.push(...Ut(c,h.issues));o.value[d.value]=h.value}}}if(i.length)return Promise.all(i).then(()=>o);return o}});var Yd=g("$ZodEnum",(e,t)=>{G.init(e,t);let o=Li(t.entries),r=new Set(o);e._zod.values=r,e._zod.pattern=new RegExp(`^(${o.filter((n)=>Xl.has(typeof n)).map((n)=>typeof n==="string"?Lt(n):n.toString()).join("|")})$`),e._zod.parse=(n,i)=>{let s=n.value;if(r.has(s))return n;return n.issues.push({code:"invalid_value",values:o,input:s,inst:e}),n}}),Qd=g("$ZodLiteral",(e,t)=>{if(G.init(e,t),t.values.length===0)throw Error("Cannot create literal schema with no valid values");let o=new Set(t.values);e._zod.values=o,e._zod.pattern=new RegExp(`^(${t.values.map((r)=>typeof r==="string"?Lt(r):r?Lt(r.toString()):String(r)).join("|")})$`),e._zod.parse=(r,n)=>{let i=r.value;if(o.has(i))return r;return r.issues.push({code:"invalid_value",values:t.values,input:i,inst:e}),r}});var Xd=g("$ZodTransform",(e,t)=>{G.init(e,t),e._zod.optin="optional",e._zod.parse=(o,r)=>{if(r.direction==="backward")throw new nn(e.constructor.name);let n=t.transform(o.value,o);if(r.async)return(n instanceof Promise?n:Promise.resolve(n)).then((s)=>(o.value=s,o.fallback=!0,o));if(n instanceof Promise)throw new bt;return o.value=n,o.fallback=!0,o}});function cd(e,t){if(t===void 0&&(e.issues.length||e.fallback))return{issues:[],value:void 0};return e}var gc=g("$ZodOptional",(e,t)=>{G.init(e,t),e._zod.optin="optional",e._zod.optout="optional",V(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),V(e._zod,"pattern",()=>{let o=t.innerType._zod.pattern;return o?new RegExp(`^(${Zi(o.source)})?$`):void 0}),e._zod.parse=(o,r)=>{if(t.innerType._zod.optin==="optional"){let n=o.value,i=t.innerType._zod.run(o,r);if(i instanceof Promise)return i.then((s)=>cd(s,n));return cd(i,n)}if(o.value===void 0)return o;return t.innerType._zod.run(o,r)}}),ep=g("$ZodExactOptional",(e,t)=>{gc.init(e,t),V(e._zod,"values",()=>t.innerType._zod.values),V(e._zod,"pattern",()=>t.innerType._zod.pattern),e._zod.parse=(o,r)=>t.innerType._zod.run(o,r)}),tp=g("$ZodNullable",(e,t)=>{G.init(e,t),V(e._zod,"optin",()=>t.innerType._zod.optin),V(e._zod,"optout",()=>t.innerType._zod.optout),V(e._zod,"pattern",()=>{let o=t.innerType._zod.pattern;return o?new RegExp(`^(${Zi(o.source)}|null)$`):void 0}),V(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(o,r)=>{if(o.value===null)return o;return t.innerType._zod.run(o,r)}}),op=g("$ZodDefault",(e,t)=>{G.init(e,t),e._zod.optin="optional",V(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(o,r)=>{if(r.direction==="backward")return t.innerType._zod.run(o,r);if(o.value===void 0)return o.value=t.defaultValue,o;let n=t.innerType._zod.run(o,r);if(n instanceof Promise)return n.then((i)=>ld(i,t));return ld(n,t)}});function ld(e,t){if(e.value===void 0)e.value=t.defaultValue;return e}var rp=g("$ZodPrefault",(e,t)=>{G.init(e,t),e._zod.optin="optional",V(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(o,r)=>{if(r.direction==="backward")return t.innerType._zod.run(o,r);if(o.value===void 0)o.value=t.defaultValue;return t.innerType._zod.run(o,r)}}),np=g("$ZodNonOptional",(e,t)=>{G.init(e,t),V(e._zod,"values",()=>{let o=t.innerType._zod.values;return o?new Set([...o].filter((r)=>r!==void 0)):void 0}),e._zod.parse=(o,r)=>{let n=t.innerType._zod.run(o,r);if(n instanceof Promise)return n.then((i)=>ud(i,e));return ud(n,e)}});function ud(e,t){if(!e.issues.length&&e.value===void 0)e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t});return e}var sp=g("$ZodCatch",(e,t)=>{G.init(e,t),e._zod.optin="optional",V(e._zod,"optout",()=>t.innerType._zod.optout),V(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(o,r)=>{if(r.direction==="backward")return t.innerType._zod.run(o,r);let n=t.innerType._zod.run(o,r);if(n instanceof Promise)return n.then((i)=>{if(o.value=i.value,i.issues.length)o.value=t.catchValue({...o,error:{issues:i.issues.map((s)=>Qe(s,r,ze()))},input:o.value}),o.issues=[],o.fallback=!0;return o});if(o.value=n.value,n.issues.length)o.value=t.catchValue({...o,error:{issues:n.issues.map((i)=>Qe(i,r,ze()))},input:o.value}),o.issues=[],o.fallback=!0;return o}});var Sc=g("$ZodPipe",(e,t)=>{G.init(e,t),V(e._zod,"values",()=>t.in._zod.values),V(e._zod,"optin",()=>t.in._zod.optin),V(e._zod,"optout",()=>t.out._zod.optout),V(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(o,r)=>{if(r.direction==="backward"){let i=t.out._zod.run(o,r);if(i instanceof Promise)return i.then((s)=>Ji(s,t.in,r));return Ji(i,t.in,r)}let n=t.in._zod.run(o,r);if(n instanceof Promise)return n.then((i)=>Ji(i,t.out,r));return Ji(n,t.out,r)}});function Ji(e,t,o){if(e.issues.length)return e.aborted=!0,e;return t._zod.run({value:e.value,issues:e.issues,fallback:e.fallback},o)}var ip=g("$ZodPreprocess",(e,t)=>{Sc.init(e,t)}),ap=g("$ZodReadonly",(e,t)=>{G.init(e,t),V(e._zod,"propValues",()=>t.innerType._zod.propValues),V(e._zod,"values",()=>t.innerType._zod.values),V(e._zod,"optin",()=>t.innerType?._zod?.optin),V(e._zod,"optout",()=>t.innerType?._zod?.optout),e._zod.parse=(o,r)=>{if(r.direction==="backward")return t.innerType._zod.run(o,r);let n=t.innerType._zod.run(o,r);if(n instanceof Promise)return n.then(dd);return dd(n)}});function dd(e){return e.value=Object.freeze(e.value),e}var cp=g("$ZodLazy",(e,t)=>{G.init(e,t),V(e._zod,"innerType",()=>{let o=t;if(!o._cachedInner)o._cachedInner=t.getter();return o._cachedInner}),V(e._zod,"pattern",()=>e._zod.innerType?._zod?.pattern),V(e._zod,"propValues",()=>e._zod.innerType?._zod?.propValues),V(e._zod,"optin",()=>e._zod.innerType?._zod?.optin??void 0),V(e._zod,"optout",()=>e._zod.innerType?._zod?.optout??void 0),e._zod.parse=(o,r)=>e._zod.innerType._zod.run(o,r)}),lp=g("$ZodCustom",(e,t)=>{pe.init(e,t),G.init(e,t),e._zod.parse=(o,r)=>o,e._zod.check=(o)=>{let r=o.value,n=t.fn(r);if(n instanceof Promise)return n.then((i)=>pd(i,o,r,e));pd(n,o,r,e);return}});function pd(e,t,o,r){if(!e){let n={code:"custom",input:o,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};if(r._zod.def.params)n.params=r._zod.def.params;t.issues.push(uo(n))}}var og=()=>{let e={string:{unit:"characters",verb:"to have"},file:{unit:"bytes",verb:"to have"},array:{unit:"items",verb:"to have"},set:{unit:"items",verb:"to have"},map:{unit:"entries",verb:"to have"}};function t(n){return e[n]??null}let o={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",mac:"MAC address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",jwt:"JWT",template_literal:"input"},r={nan:"NaN"};return(n)=>{switch(n.code){case"invalid_type":{let i=r[n.expected]??n.expected,s=ru(n.input),c=r[s]??s;return`Invalid input: expected ${i}, received ${c}`}case"invalid_value":if(n.values.length===1)return`Invalid input: expected ${rc(n.values[0])}`;return`Invalid option: expected one of ${Xa(n.values,"|")}`;case"too_big":{let i=n.inclusive?"<=":"<",s=t(n.origin);if(s)return`Too big: expected ${n.origin??"value"} to have ${i}${n.maximum.toString()} ${s.unit??"elements"}`;return`Too big: expected ${n.origin??"value"} to be ${i}${n.maximum.toString()}`}case"too_small":{let i=n.inclusive?">=":">",s=t(n.origin);if(s)return`Too small: expected ${n.origin} to have ${i}${n.minimum.toString()} ${s.unit}`;return`Too small: expected ${n.origin} to be ${i}${n.minimum.toString()}`}case"invalid_format":{let i=n;if(i.format==="starts_with")return`Invalid string: must start with "${i.prefix}"`;if(i.format==="ends_with")return`Invalid string: must end with "${i.suffix}"`;if(i.format==="includes")return`Invalid string: must include "${i.includes}"`;if(i.format==="regex")return`Invalid string: must match pattern ${i.pattern}`;return`Invalid ${o[i.format]??n.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${n.divisor}`;case"unrecognized_keys":return`Unrecognized key${n.keys.length>1?"s":""}: ${Xa(n.keys,", ")}`;case"invalid_key":return`Invalid key in ${n.origin}`;case"invalid_union":if(n.options&&Array.isArray(n.options)&&n.options.length>0)return`Invalid discriminator value. Expected ${n.options.map((s)=>`'${s}'`).join(" | ")}`;return"Invalid input";case"invalid_element":return`Invalid value in ${n.origin}`;default:return"Invalid input"}}};function _c(){return{localeError:og()}}var up,rg=Symbol("ZodOutput"),ng=Symbol("ZodInput");class dp{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){let o=t[0];if(this._map.set(e,o),o&&typeof o==="object"&&"id"in o)this._idmap.set(o.id,e);return this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let t=this._map.get(e);if(t&&typeof t==="object"&&"id"in t)this._idmap.delete(t.id);return this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let o={...this.get(t)??{}};delete o.id;let r={...o,...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 pp(){return new dp}(up=globalThis).__zod_globalRegistry??(up.__zod_globalRegistry=pp());var Zt=globalThis.__zod_globalRegistry;function hp(e,t){return new e({type:"string",...I(t)})}function bc(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...I(t)})}function yc(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...I(t)})}function mp(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...I(t)})}function fp(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...I(t)})}function gp(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...I(t)})}function Sp(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...I(t)})}function vc(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...I(t)})}function _p(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...I(t)})}function bp(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...I(t)})}function yp(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...I(t)})}function vp(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...I(t)})}function zp(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...I(t)})}function Rp(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...I(t)})}function wp(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...I(t)})}function xp(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...I(t)})}function Ep(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...I(t)})}function Tp(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...I(t)})}function Pp(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...I(t)})}function kp(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...I(t)})}function $p(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...I(t)})}function Cp(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...I(t)})}function Ip(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...I(t)})}function Op(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...I(t)})}function Mp(e,t){return new e({type:"string",format:"date",check:"string_format",...I(t)})}function qp(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...I(t)})}function Np(e,t){return new e({type:"string",format:"duration",check:"string_format",...I(t)})}function Ap(e,t){return new e({type:"number",checks:[],...I(t)})}function jp(e,t){return new e({type:"number",coerce:!0,checks:[],...I(t)})}function Lp(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...I(t)})}function Up(e,t){return new e({type:"boolean",...I(t)})}function Zp(e,t){return new e({type:"undefined",...I(t)})}function Dp(e,t){return new e({type:"null",...I(t)})}function Hp(e){return new e({type:"any"})}function Fp(e){return new e({type:"unknown"})}function Vp(e,t){return new e({type:"never",...I(t)})}function Ki(e,t){return new uc({check:"less_than",...I(t),value:e,inclusive:!1})}function pn(e,t){return new uc({check:"less_than",...I(t),value:e,inclusive:!0})}function Gi(e,t){return new dc({check:"greater_than",...I(t),value:e,inclusive:!1})}function hn(e,t){return new dc({check:"greater_than",...I(t),value:e,inclusive:!0})}function Yi(e,t){return new Vu({check:"multiple_of",...I(t),value:e})}function Qi(e,t){return new Bu({check:"max_length",...I(t),maximum:e})}function Fo(e,t){return new Wu({check:"min_length",...I(t),minimum:e})}function Xi(e,t){return new Ku({check:"length_equals",...I(t),length:e})}function zc(e,t){return new Gu({check:"string_format",format:"regex",...I(t),pattern:e})}function Rc(e){return new Yu({check:"string_format",format:"lowercase",...I(e)})}function wc(e){return new Qu({check:"string_format",format:"uppercase",...I(e)})}function xc(e,t){return new Xu({check:"string_format",format:"includes",...I(t),includes:e})}function Ec(e,t){return new ed({check:"string_format",format:"starts_with",...I(t),prefix:e})}function Tc(e,t){return new td({check:"string_format",format:"ends_with",...I(t),suffix:e})}function Dt(e){return new od({check:"overwrite",tx:e})}function Pc(e){return Dt((t)=>t.normalize(e))}function kc(){return Dt((e)=>e.trim())}function $c(){return Dt((e)=>e.toLowerCase())}function Cc(){return Dt((e)=>e.toUpperCase())}function Ic(){return Dt((e)=>Yl(e))}function Jp(e,t,o){return new e({type:"array",element:t,...I(o)})}function Bp(e,t,o){return new e({type:"custom",check:"custom",fn:t,...I(o)})}function Wp(e,t){let o=sg((r)=>(r.addIssue=(n)=>{if(typeof n==="string")r.issues.push(uo(n,r.value,o._zod.def));else{let i=n;if(i.fatal)i.continue=!1;i.code??(i.code="custom"),i.input??(i.input=r.value),i.inst??(i.inst=o),i.continue??(i.continue=!o._zod.def.abort),r.issues.push(uo(i))}},e(r.value,r)),t);return o}function sg(e,t){let o=new pe({check:"custom",...I(t)});return o._zod.check=e,o}function fn(e){let t=e?.target??"draft-2020-12";if(t==="draft-4")t="draft-04";if(t==="draft-7")t="draft-07";return{processors:e.processors??{},metadataRegistry:e?.metadata??Zt,target:t,unrepresentable:e?.unrepresentable??"throw",override:e?.override??(()=>{}),io:e?.io??"output",counter:0,seen:new Map,cycles:e?.cycles??"ref",reused:e?.reused??"inline",external:e?.external??void 0}}function Q(e,t,o={path:[],schemaPath:[]}){var r;let n=e._zod.def,i=t.seen.get(e);if(i){if(i.count++,o.schemaPath.includes(e))i.cycle=o.path;return i.schema}let s={schema:{},count:1,cycle:void 0,path:o.path};t.seen.set(e,s);let c=e._zod.toJSONSchema?.();if(c)s.schema=c;else{let h={...o,schemaPath:[...o.schemaPath,e],path:o.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,s.schema,h);else{let S=s.schema,b=t.processors[n.type];if(!b)throw Error(`[toJSONSchema]: Non-representable type encountered: ${n.type}`);b(e,t,S,h)}let f=e._zod.parent;if(f){if(!s.ref)s.ref=f;Q(f,t,h),t.seen.get(f).isParent=!0}}let d=t.metadataRegistry.get(e);if(d)Object.assign(s.schema,d);if(t.io==="input"&&Re(e))delete s.schema.examples,delete s.schema.default;if(t.io==="input"&&"_prefault"in s.schema)(r=s.schema).default??(r.default=s.schema._prefault);return delete s.schema._prefault,t.seen.get(e).schema}function gn(e,t){let o=e.seen.get(t);if(!o)throw Error("Unprocessed schema. This is a bug in Zod.");let r=new Map;for(let s of e.seen.entries()){let c=e.metadataRegistry.get(s[0])?.id;if(c){let d=r.get(c);if(d&&d!==s[0])throw Error(`Duplicate schema id "${c}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(c,s[0])}}let n=(s)=>{let c=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){let f=e.external.registry.get(s[0])?.id,S=e.external.uri??((R)=>R);if(f)return{ref:S(f)};let b=s[1].defId??s[1].schema.id??`schema${e.counter++}`;return s[1].defId=b,{defId:b,ref:`${S("__shared")}#/${c}/${b}`}}if(s[1]===o)return{ref:"#"};let p=`${"#"}/${c}/`,h=s[1].schema.id??`__schema${e.counter++}`;return{defId:h,ref:p+h}},i=(s)=>{if(s[1].schema.$ref)return;let c=s[1],{ref:d,defId:p}=n(s);if(c.def={...c.schema},p)c.defId=p;let h=c.schema;for(let f in h)delete h[f];h.$ref=d};if(e.cycles==="throw")for(let s of e.seen.entries()){let c=s[1];if(c.cycle)throw Error(`Cycle detected: #/${c.cycle?.join("/")}/<root>
|
|
63
63
|
|
|
64
|
-
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let a of e.seen.entries()){let u=a[1];if(t===a[0]){i(a);continue}if(e.external){let p=e.external.registry.get(a[0])?.id;if(t!==a[0]&&p){i(a);continue}}if(e.metadataRegistry.get(a[0])?.id){i(a);continue}if(u.cycle){i(a);continue}if(u.count>1){if(e.reused==="ref"){i(a);continue}}}}function nn(e,t){let o=e.seen.get(t);if(!o)throw Error("Unprocessed schema. This is a bug in Zod.");let r=(u)=>{let d=e.seen.get(u);if(d.ref===null)return;let p=d.def??d.schema,f={...p},b=d.ref;if(d.ref=null,b){r(b);let z=e.seen.get(b),E=z.schema;if(E.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0"))p.allOf=p.allOf??[],p.allOf.push(E);else Object.assign(p,E);if(Object.assign(p,f),u._zod.parent===b)for(let k in p){if(k==="$ref"||k==="allOf")continue;if(!(k in f))delete p[k]}if(E.$ref&&z.def)for(let k in p){if(k==="$ref"||k==="allOf")continue;if(k in z.def&&JSON.stringify(p[k])===JSON.stringify(z.def[k]))delete p[k]}}let y=u._zod.parent;if(y&&y!==b){r(y);let z=e.seen.get(y);if(z?.schema.$ref){if(p.$ref=z.schema.$ref,z.def)for(let E in p){if(E==="$ref"||E==="allOf")continue;if(E in z.def&&JSON.stringify(p[E])===JSON.stringify(z.def[E]))delete p[E]}}}e.override({zodSchema:u,jsonSchema:p,path:d.path??[]})};for(let u of[...e.seen.entries()].reverse())r(u[0]);let n={};if(e.target==="draft-2020-12")n.$schema="https://json-schema.org/draft/2020-12/schema";else if(e.target==="draft-07")n.$schema="http://json-schema.org/draft-07/schema#";else if(e.target==="draft-04")n.$schema="http://json-schema.org/draft-04/schema#";else if(e.target==="openapi-3.0");if(e.external?.uri){let u=e.external.registry.get(t)?.id;if(!u)throw Error("Schema is missing an `id` property");n.$id=e.external.uri(u)}Object.assign(n,o.def??o.schema);let i=e.metadataRegistry.get(t)?.id;if(i!==void 0&&n.id===i)delete n.id;let a=e.external?.defs??{};for(let u of e.seen.entries()){let d=u[1];if(d.def&&d.defId){if(d.def.id===d.defId)delete d.def.id;a[d.defId]=d.def}}if(e.external);else if(Object.keys(a).length>0)if(e.target==="draft-2020-12")n.$defs=a;else n.definitions=a;try{let u=JSON.parse(JSON.stringify(n));return Object.defineProperty(u,"~standard",{value:{...t["~standard"],jsonSchema:{input:tn(t,"input",e.processors),output:tn(t,"output",e.processors)}},enumerable:!1,writable:!1}),u}catch(u){throw Error("Error converting schema to JSON.")}}function le(e,t){let o=t??{seen:new Set};if(o.seen.has(e))return!1;o.seen.add(e);let r=e._zod.def;if(r.type==="transform")return!0;if(r.type==="array")return le(r.element,o);if(r.type==="set")return le(r.valueType,o);if(r.type==="lazy")return le(r.getter(),o);if(r.type==="promise"||r.type==="optional"||r.type==="nonoptional"||r.type==="nullable"||r.type==="readonly"||r.type==="default"||r.type==="prefault")return le(r.innerType,o);if(r.type==="intersection")return le(r.left,o)||le(r.right,o);if(r.type==="record"||r.type==="map")return le(r.keyType,o)||le(r.valueType,o);if(r.type==="pipe"){if(e._zod.traits.has("$ZodCodec"))return!0;return le(r.in,o)||le(r.out,o)}if(r.type==="object"){for(let n in r.shape)if(le(r.shape[n],o))return!0;return!1}if(r.type==="union"){for(let n of r.options)if(le(n,o))return!0;return!1}if(r.type==="tuple"){for(let n of r.items)if(le(n,o))return!0;if(r.rest&&le(r.rest,o))return!0;return!1}return!1}var vp=(e,t={})=>(o)=>{let r=on({...o,processors:t});return j(e,r),rn(r,e),nn(r,e)},tn=(e,t,o={})=>(r)=>{let{libraryOptions:n,target:i}=r??{},a=on({...n??{},target:i,io:t,processors:o});return j(e,a),rn(a,e),nn(a,e)};var uf={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},hc=(e,t,o,r)=>{let n=o;n.type="string";let{minimum:i,maximum:a,format:u,patterns:d,contentEncoding:p}=e._zod.bag;if(typeof i==="number")n.minLength=i;if(typeof a==="number")n.maxLength=a;if(u){if(n.format=uf[u]??u,n.format==="")delete n.format;if(u==="time")delete n.format}if(p)n.contentEncoding=p;if(d&&d.size>0){let f=[...d];if(f.length===1)n.pattern=f[0].source;else if(f.length>1)n.allOf=[...f.map((b)=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:b.source}))]}},mc=(e,t,o,r)=>{let n=o,{minimum:i,maximum:a,format:u,multipleOf:d,exclusiveMaximum:p,exclusiveMinimum:f}=e._zod.bag;if(typeof u==="string"&&u.includes("int"))n.type="integer";else n.type="number";let b=typeof f==="number"&&f>=(i??Number.NEGATIVE_INFINITY),y=typeof p==="number"&&p<=(a??Number.POSITIVE_INFINITY),z=t.target==="draft-04"||t.target==="openapi-3.0";if(b)if(z)n.minimum=f,n.exclusiveMinimum=!0;else n.exclusiveMinimum=f;else if(typeof i==="number")n.minimum=i;if(y)if(z)n.maximum=p,n.exclusiveMaximum=!0;else n.exclusiveMaximum=p;else if(typeof a==="number")n.maximum=a;if(typeof d==="number")n.multipleOf=d},fc=(e,t,o,r)=>{o.type="boolean"},Rp=(e,t,o,r)=>{if(t.unrepresentable==="throw")throw Error("BigInt cannot be represented in JSON Schema")},wp=(e,t,o,r)=>{if(t.unrepresentable==="throw")throw Error("Symbols cannot be represented in JSON Schema")},gc=(e,t,o,r)=>{if(t.target==="openapi-3.0")o.type="string",o.nullable=!0,o.enum=[null];else o.type="null"},Sc=(e,t,o,r)=>{if(t.unrepresentable==="throw")throw Error("Undefined cannot be represented in JSON Schema")},xp=(e,t,o,r)=>{if(t.unrepresentable==="throw")throw Error("Void cannot be represented in JSON Schema")},_c=(e,t,o,r)=>{o.not={}},bc=(e,t,o,r)=>{},yc=(e,t,o,r)=>{},Tp=(e,t,o,r)=>{if(t.unrepresentable==="throw")throw Error("Date cannot be represented in JSON Schema")},vc=(e,t,o,r)=>{let n=e._zod.def,i=wi(n.entries);if(i.every((a)=>typeof a==="number"))o.type="number";if(i.every((a)=>typeof a==="string"))o.type="string";o.enum=i},zc=(e,t,o,r)=>{let n=e._zod.def,i=[];for(let a of n.values)if(a===void 0){if(t.unrepresentable==="throw")throw Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof a==="bigint")if(t.unrepresentable==="throw")throw Error("BigInt literals cannot be represented in JSON Schema");else i.push(Number(a));else i.push(a);if(i.length===0);else if(i.length===1){let a=i[0];if(o.type=a===null?"null":typeof a,t.target==="draft-04"||t.target==="openapi-3.0")o.enum=[a];else o.const=a}else{if(i.every((a)=>typeof a==="number"))o.type="number";if(i.every((a)=>typeof a==="string"))o.type="string";if(i.every((a)=>typeof a==="boolean"))o.type="boolean";if(i.every((a)=>a===null))o.type="null";o.enum=i}},Ep=(e,t,o,r)=>{if(t.unrepresentable==="throw")throw Error("NaN cannot be represented in JSON Schema")},Pp=(e,t,o,r)=>{let n=o,i=e._zod.pattern;if(!i)throw Error("Pattern not found in template literal");n.type="string",n.pattern=i.source},kp=(e,t,o,r)=>{let n=o,i={type:"string",format:"binary",contentEncoding:"binary"},{minimum:a,maximum:u,mime:d}=e._zod.bag;if(a!==void 0)i.minLength=a;if(u!==void 0)i.maxLength=u;if(d)if(d.length===1)i.contentMediaType=d[0],Object.assign(n,i);else Object.assign(n,i),n.anyOf=d.map((p)=>({contentMediaType:p}));else Object.assign(n,i)},$p=(e,t,o,r)=>{o.type="boolean"},Rc=(e,t,o,r)=>{if(t.unrepresentable==="throw")throw Error("Custom types cannot be represented in JSON Schema")},Cp=(e,t,o,r)=>{if(t.unrepresentable==="throw")throw Error("Function types cannot be represented in JSON Schema")},wc=(e,t,o,r)=>{if(t.unrepresentable==="throw")throw Error("Transforms cannot be represented in JSON Schema")},Ip=(e,t,o,r)=>{if(t.unrepresentable==="throw")throw Error("Map cannot be represented in JSON Schema")},Op=(e,t,o,r)=>{if(t.unrepresentable==="throw")throw Error("Set cannot be represented in JSON Schema")},xc=(e,t,o,r)=>{let n=o,i=e._zod.def,{minimum:a,maximum:u}=e._zod.bag;if(typeof a==="number")n.minItems=a;if(typeof u==="number")n.maxItems=u;n.type="array",n.items=j(i.element,t,{...r,path:[...r.path,"items"]})},Tc=(e,t,o,r)=>{let n=o,i=e._zod.def;n.type="object",n.properties={};let a=i.shape;for(let p in a)n.properties[p]=j(a[p],t,{...r,path:[...r.path,"properties",p]});let u=new Set(Object.keys(a)),d=new Set([...u].filter((p)=>{let f=i.shape[p]._zod;if(t.io==="input")return f.optin===void 0;else return f.optout===void 0}));if(d.size>0)n.required=Array.from(d);if(i.catchall?._zod.def.type==="never")n.additionalProperties=!1;else if(!i.catchall){if(t.io==="output")n.additionalProperties=!1}else if(i.catchall)n.additionalProperties=j(i.catchall,t,{...r,path:[...r.path,"additionalProperties"]})},Ec=(e,t,o,r)=>{let n=e._zod.def,i=n.inclusive===!1,a=n.options.map((u,d)=>j(u,t,{...r,path:[...r.path,i?"oneOf":"anyOf",d]}));if(i)o.oneOf=a;else o.anyOf=a},Pc=(e,t,o,r)=>{let n=e._zod.def,i=j(n.left,t,{...r,path:[...r.path,"allOf",0]}),a=j(n.right,t,{...r,path:[...r.path,"allOf",1]}),u=(p)=>("allOf"in p)&&Object.keys(p).length===1,d=[...u(i)?i.allOf:[i],...u(a)?a.allOf:[a]];o.allOf=d},Mp=(e,t,o,r)=>{let n=o,i=e._zod.def;n.type="array";let a=t.target==="draft-2020-12"?"prefixItems":"items",u=t.target==="draft-2020-12"?"items":t.target==="openapi-3.0"?"items":"additionalItems",d=i.items.map((y,z)=>j(y,t,{...r,path:[...r.path,a,z]})),p=i.rest?j(i.rest,t,{...r,path:[...r.path,u,...t.target==="openapi-3.0"?[i.items.length]:[]]}):null;if(t.target==="draft-2020-12"){if(n.prefixItems=d,p)n.items=p}else if(t.target==="openapi-3.0"){if(n.items={anyOf:d},p)n.items.anyOf.push(p);if(n.minItems=d.length,!p)n.maxItems=d.length}else if(n.items=d,p)n.additionalItems=p;let{minimum:f,maximum:b}=e._zod.bag;if(typeof f==="number")n.minItems=f;if(typeof b==="number")n.maxItems=b},kc=(e,t,o,r)=>{let n=o,i=e._zod.def;n.type="object";let a=i.keyType,d=a._zod.bag?.patterns;if(i.mode==="loose"&&d&&d.size>0){let f=j(i.valueType,t,{...r,path:[...r.path,"patternProperties","*"]});n.patternProperties={};for(let b of d)n.patternProperties[b.source]=f}else{if(t.target==="draft-07"||t.target==="draft-2020-12")n.propertyNames=j(i.keyType,t,{...r,path:[...r.path,"propertyNames"]});n.additionalProperties=j(i.valueType,t,{...r,path:[...r.path,"additionalProperties"]})}let p=a._zod.values;if(p){let f=[...p].filter((b)=>typeof b==="string"||typeof b==="number");if(f.length>0)n.required=f}},$c=(e,t,o,r)=>{let n=e._zod.def,i=j(n.innerType,t,r),a=t.seen.get(e);if(t.target==="openapi-3.0")a.ref=n.innerType,o.nullable=!0;else o.anyOf=[i,{type:"null"}]},Cc=(e,t,o,r)=>{let n=e._zod.def;j(n.innerType,t,r);let i=t.seen.get(e);i.ref=n.innerType},Ic=(e,t,o,r)=>{let n=e._zod.def;j(n.innerType,t,r);let i=t.seen.get(e);i.ref=n.innerType,o.default=JSON.parse(JSON.stringify(n.defaultValue))},Oc=(e,t,o,r)=>{let n=e._zod.def;j(n.innerType,t,r);let i=t.seen.get(e);if(i.ref=n.innerType,t.io==="input")o._prefault=JSON.parse(JSON.stringify(n.defaultValue))},Mc=(e,t,o,r)=>{let n=e._zod.def;j(n.innerType,t,r);let i=t.seen.get(e);i.ref=n.innerType;let a;try{a=n.catchValue(void 0)}catch{throw Error("Dynamic catch values are not supported in JSON Schema")}o.default=a},qc=(e,t,o,r)=>{let n=e._zod.def,i=n.in._zod.traits.has("$ZodTransform"),a=t.io==="input"?i?n.out:n.in:n.out;j(a,t,r);let u=t.seen.get(e);u.ref=a},Nc=(e,t,o,r)=>{let n=e._zod.def;j(n.innerType,t,r);let i=t.seen.get(e);i.ref=n.innerType,o.readOnly=!0},qp=(e,t,o,r)=>{let n=e._zod.def;j(n.innerType,t,r);let i=t.seen.get(e);i.ref=n.innerType},Li=(e,t,o,r)=>{let n=e._zod.def;j(n.innerType,t,r);let i=t.seen.get(e);i.ref=n.innerType},Ac=(e,t,o,r)=>{let n=e._zod.innerType;j(n,t,r);let i=t.seen.get(e);i.ref=n},zp={string:hc,number:mc,boolean:fc,bigint:Rp,symbol:wp,null:gc,undefined:Sc,void:xp,never:_c,any:bc,unknown:yc,date:Tp,enum:vc,literal:zc,nan:Ep,template_literal:Pp,file:kp,success:$p,custom:Rc,function:Cp,transform:wc,map:Ip,set:Op,array:xc,object:Tc,union:Ec,intersection:Pc,tuple:Mp,record:kc,nullable:$c,nonoptional:Cc,default:Ic,prefault:Oc,catch:Mc,pipe:qc,readonly:Nc,promise:qp,optional:Li,lazy:Ac};function Ui(e,t){if("_idmap"in e){let r=e,n=on({...t,processors:zp}),i={};for(let d of r._idmap.entries()){let[p,f]=d;j(f,n)}let a={},u={registry:r,uri:t?.uri,defs:i};n.external=u;for(let d of r._idmap.entries()){let[p,f]=d;rn(n,f),a[p]=nn(n,f)}if(Object.keys(i).length>0){let d=n.target==="draft-2020-12"?"$defs":"definitions";a.__shared={[d]:i}}return{schemas:a}}let o=on({...t,processors:zp});return j(e,o),rn(o,e),nn(o,e)}var _f=m("ZodISODateTime",(e,t)=>{Gu.init(e,t),H.init(e,t)});function _o(e){return sp(_f,e)}var bf=m("ZodISODate",(e,t)=>{Yu.init(e,t),H.init(e,t)});function jc(e){return ip(bf,e)}var yf=m("ZodISOTime",(e,t)=>{Qu.init(e,t),H.init(e,t)});function Np(e){return ap(yf,e)}var vf=m("ZodISODuration",(e,t)=>{Xu.init(e,t),H.init(e,t)});function Ap(e){return cp(vf,e)}var zf=(e,t)=>{Pi.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:(o)=>Ua(e,o)},flatten:{value:(o)=>La(e,o)},addIssue:{value:(o)=>{e.issues.push(o),e.message=JSON.stringify(e.issues,Br,2)}},addIssues:{value:(o)=>{e.issues.push(...o),e.message=JSON.stringify(e.issues,Br,2)}},isEmpty:{get(){return e.issues.length===0}}})};var me=m("ZodError",zf,{Parent:Error});var Lp=ki(me),Up=$i(me),Di=Kr(me),Zp=Gr(me),Dp=Ol(me),Hp=Ml(me),Fp=ql(me),Vp=Nl(me),Jp=Al(me),Bp=jl(me),Wp=Ll(me),Kp=Ul(me);var Gp=new WeakMap;function sn(e,t,o){let r=Object.getPrototypeOf(e),n=Gp.get(r);if(!n)n=new Set,Gp.set(r,n);if(n.has(t))return;n.add(t);for(let i in o){let a=o[i];Object.defineProperty(r,i,{configurable:!0,enumerable:!1,get(){let u=a.bind(this);return Object.defineProperty(this,i,{configurable:!0,writable:!0,enumerable:!0,value:u}),u},set(u){Object.defineProperty(this,i,{configurable:!0,writable:!0,enumerable:!0,value:u})}})}}var L=m("ZodType",(e,t)=>(N.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:tn(e,"input"),output:tn(e,"output")}}),e.toJSONSchema=vp(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.parse=(o,r)=>Lp(e,o,r,{callee:e.parse}),e.safeParse=(o,r)=>Di(e,o,r),e.parseAsync=async(o,r)=>Up(e,o,r,{callee:e.parseAsync}),e.safeParseAsync=async(o,r)=>Zp(e,o,r),e.spa=e.safeParseAsync,e.encode=(o,r)=>Dp(e,o,r),e.decode=(o,r)=>Hp(e,o,r),e.encodeAsync=async(o,r)=>Fp(e,o,r),e.decodeAsync=async(o,r)=>Vp(e,o,r),e.safeEncode=(o,r)=>Jp(e,o,r),e.safeDecode=(o,r)=>Bp(e,o,r),e.safeEncodeAsync=async(o,r)=>Wp(e,o,r),e.safeDecodeAsync=async(o,r)=>Kp(e,o,r),sn(e,"ZodType",{check(...o){let r=this.def;return this.clone(rt(r,{checks:[...r.checks??[],...o.map((n)=>typeof n==="function"?{_zod:{check:n,def:{check:"custom"},onattach:[]}}:n)]}),{parent:!0})},with(...o){return this.check(...o)},clone(o,r){return xe(this,o,r)},brand(){return this},register(o,r){return o.add(this,r),this},refine(o,r){return this.check(dg(o,r))},superRefine(o,r){return this.check(pg(o,r))},overwrite(o){return this.check(at(o))},optional(){return x(this)},exactOptional(){return Yf(this)},nullable(){return eh(this)},nullish(){return x(eh(this))},nonoptional(o){return rg(this,o)},array(){return h(this)},or(o){return _([this,o])},and(o){return Ue(this,o)},transform(o){return th(this,uh(o))},default(o){return eg(this,o)},prefault(o){return og(this,o)},catch(o){return sg(this,o)},pipe(o){return th(this,o)},readonly(){return cg(this)},describe(o){let r=this.clone();return it.add(r,{description:o}),r},meta(...o){if(o.length===0)return it.get(this);let r=this.clone();return it.add(r,o[0]),r},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(o){return o(this)}}),Object.defineProperty(e,"description",{get(){return it.get(e)?.description},configurable:!0}),e)),oh=m("_ZodString",(e,t)=>{Oi.init(e,t),L.init(e,t),e._zod.processJSONSchema=(r,n,i)=>hc(e,r,n,i);let o=e._zod.bag;e.format=o.format??null,e.minLength=o.minimum??null,e.maxLength=o.maximum??null,sn(e,"_ZodString",{regex(...r){return this.check(oc(...r))},includes(...r){return this.check(sc(...r))},startsWith(...r){return this.check(ic(...r))},endsWith(...r){return this.check(ac(...r))},min(...r){return this.check(go(...r))},max(...r){return this.check(Ai(...r))},length(...r){return this.check(ji(...r))},nonempty(...r){return this.check(go(1,...r))},lowercase(r){return this.check(rc(r))},uppercase(r){return this.check(nc(r))},trim(){return this.check(lc())},normalize(...r){return this.check(cc(...r))},toLowerCase(){return this.check(uc())},toUpperCase(){return this.check(dc())},slugify(){return this.check(pc())}})}),rh=m("ZodString",(e,t)=>{Oi.init(e,t),oh.init(e,t),e.email=(o)=>e.check(Xa(nh,o)),e.url=(o)=>e.check(tc(ih,o)),e.jwt=(o)=>e.check(np(jf,o)),e.emoji=(o)=>e.check(Fd(wf,o)),e.guid=(o)=>e.check(ec(Yp,o)),e.uuid=(o)=>e.check(Ud(Hi,o)),e.uuidv4=(o)=>e.check(Zd(Hi,o)),e.uuidv6=(o)=>e.check(Dd(Hi,o)),e.uuidv7=(o)=>e.check(Hd(Hi,o)),e.nanoid=(o)=>e.check(Vd(xf,o)),e.guid=(o)=>e.check(ec(Yp,o)),e.cuid=(o)=>e.check(Jd(Tf,o)),e.cuid2=(o)=>e.check(Bd(Ef,o)),e.ulid=(o)=>e.check(Wd(Pf,o)),e.base64=(o)=>e.check(tp(qf,o)),e.base64url=(o)=>e.check(op(Nf,o)),e.xid=(o)=>e.check(Kd(kf,o)),e.ksuid=(o)=>e.check(Gd($f,o)),e.ipv4=(o)=>e.check(Yd(Cf,o)),e.ipv6=(o)=>e.check(Qd(If,o)),e.cidrv4=(o)=>e.check(Xd(Of,o)),e.cidrv6=(o)=>e.check(ep(Mf,o)),e.e164=(o)=>e.check(rp(Af,o)),e.datetime=(o)=>e.check(_o(o)),e.date=(o)=>e.check(jc(o)),e.time=(o)=>e.check(Np(o)),e.duration=(o)=>e.check(Ap(o))});function s(e){return Ld(rh,e)}var H=m("ZodStringFormat",(e,t)=>{Z.init(e,t),oh.init(e,t)}),nh=m("ZodEmail",(e,t)=>{Zu.init(e,t),H.init(e,t)});function sh(e){return Xa(nh,e)}var Yp=m("ZodGUID",(e,t)=>{Lu.init(e,t),H.init(e,t)});var Hi=m("ZodUUID",(e,t)=>{Uu.init(e,t),H.init(e,t)});var ih=m("ZodURL",(e,t)=>{Du.init(e,t),H.init(e,t)});function Fi(e){return tc(ih,e)}var wf=m("ZodEmoji",(e,t)=>{Hu.init(e,t),H.init(e,t)});var xf=m("ZodNanoID",(e,t)=>{Fu.init(e,t),H.init(e,t)});var Tf=m("ZodCUID",(e,t)=>{Vu.init(e,t),H.init(e,t)});var Ef=m("ZodCUID2",(e,t)=>{Ju.init(e,t),H.init(e,t)});var Pf=m("ZodULID",(e,t)=>{Bu.init(e,t),H.init(e,t)});var kf=m("ZodXID",(e,t)=>{Wu.init(e,t),H.init(e,t)});var $f=m("ZodKSUID",(e,t)=>{Ku.init(e,t),H.init(e,t)});var Cf=m("ZodIPv4",(e,t)=>{ed.init(e,t),H.init(e,t)});var If=m("ZodIPv6",(e,t)=>{td.init(e,t),H.init(e,t)});var Of=m("ZodCIDRv4",(e,t)=>{od.init(e,t),H.init(e,t)});var Mf=m("ZodCIDRv6",(e,t)=>{rd.init(e,t),H.init(e,t)});var qf=m("ZodBase64",(e,t)=>{sd.init(e,t),H.init(e,t)});var Nf=m("ZodBase64URL",(e,t)=>{id.init(e,t),H.init(e,t)});var Af=m("ZodE164",(e,t)=>{ad.init(e,t),H.init(e,t)});var jf=m("ZodJWT",(e,t)=>{cd.init(e,t),H.init(e,t)});var Vi=m("ZodNumber",(e,t)=>{Wa.init(e,t),L.init(e,t),e._zod.processJSONSchema=(r,n,i)=>mc(e,r,n,i),sn(e,"ZodNumber",{gt(r,n){return this.check(qi(r,n))},gte(r,n){return this.check(en(r,n))},min(r,n){return this.check(en(r,n))},lt(r,n){return this.check(Mi(r,n))},lte(r,n){return this.check(Xr(r,n))},max(r,n){return this.check(Xr(r,n))},int(r){return this.check(Qp(r))},safe(r){return this.check(Qp(r))},positive(r){return this.check(qi(0,r))},nonnegative(r){return this.check(en(0,r))},negative(r){return this.check(Mi(0,r))},nonpositive(r){return this.check(Xr(0,r))},multipleOf(r,n){return this.check(Ni(r,n))},step(r,n){return this.check(Ni(r,n))},finite(){return this}});let o=e._zod.bag;e.minValue=Math.max(o.minimum??Number.NEGATIVE_INFINITY,o.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(o.maximum??Number.POSITIVE_INFINITY,o.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(o.format??"").includes("int")||Number.isSafeInteger(o.multipleOf??0.5),e.isFinite=!0,e.format=o.format??null});function g(e){return lp(Vi,e)}var Lf=m("ZodNumberFormat",(e,t)=>{ld.init(e,t),Vi.init(e,t)});function Qp(e){return dp(Lf,e)}var ah=m("ZodBoolean",(e,t)=>{ud.init(e,t),L.init(e,t),e._zod.processJSONSchema=(o,r,n)=>fc(e,o,r,n)});function v(e){return pp(ah,e)}var Uf=m("ZodUndefined",(e,t)=>{dd.init(e,t),L.init(e,t),e._zod.processJSONSchema=(o,r,n)=>Sc(e,o,r,n)});function bo(e){return hp(Uf,e)}var Zf=m("ZodNull",(e,t)=>{pd.init(e,t),L.init(e,t),e._zod.processJSONSchema=(o,r,n)=>gc(e,o,r,n)});function It(e){return mp(Zf,e)}var Df=m("ZodAny",(e,t)=>{hd.init(e,t),L.init(e,t),e._zod.processJSONSchema=(o,r,n)=>bc(e,o,r,n)});function yo(){return fp(Df)}var Hf=m("ZodUnknown",(e,t)=>{md.init(e,t),L.init(e,t),e._zod.processJSONSchema=(o,r,n)=>yc(e,o,r,n)});function R(){return gp(Hf)}var Ff=m("ZodNever",(e,t)=>{fd.init(e,t),L.init(e,t),e._zod.processJSONSchema=(o,r,n)=>_c(e,o,r,n)});function an(e){return Sp(Ff,e)}var Vf=m("ZodArray",(e,t)=>{gd.init(e,t),L.init(e,t),e._zod.processJSONSchema=(o,r,n)=>xc(e,o,r,n),e.element=t.element,sn(e,"ZodArray",{min(o,r){return this.check(go(o,r))},nonempty(o){return this.check(go(1,o))},max(o,r){return this.check(Ai(o,r))},length(o,r){return this.check(ji(o,r))},unwrap(){return this.element}})});function h(e,t){return _p(Vf,e,t)}var ch=m("ZodObject",(e,t)=>{bd.init(e,t),L.init(e,t),e._zod.processJSONSchema=(o,r,n)=>Tc(e,o,r,n),O(e,"shape",()=>t.shape),sn(e,"ZodObject",{keyof(){return C(Object.keys(this._zod.def.shape))},catchall(o){return this.clone({...this._zod.def,catchall:o})},passthrough(){return this.clone({...this._zod.def,catchall:R()})},loose(){return this.clone({...this._zod.def,catchall:R()})},strict(){return this.clone({...this._zod.def,catchall:an()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(o){return Km(this,o)},safeExtend(o){return Gm(this,o)},merge(o){return Ym(this,o)},pick(o){return Bm(this,o)},omit(o){return Wm(this,o)},partial(...o){return Qm(dh,this,o[0])},required(...o){return Xm(ph,this,o[0])}})});function c(e,t){let o={type:"object",shape:e??{},...w(t)};return new ch(o)}function T(e,t){return new ch({type:"object",shape:e,catchall:R(),...w(t)})}var lh=m("ZodUnion",(e,t)=>{Ka.init(e,t),L.init(e,t),e._zod.processJSONSchema=(o,r,n)=>Ec(e,o,r,n),e.options=t.options});function _(e,t){return new lh({type:"union",options:e,...w(t)})}var Jf=m("ZodDiscriminatedUnion",(e,t)=>{lh.init(e,t),yd.init(e,t)});function vo(e,t,o){return new Jf({type:"union",options:t,discriminator:e,...w(o)})}var Bf=m("ZodIntersection",(e,t)=>{vd.init(e,t),L.init(e,t),e._zod.processJSONSchema=(o,r,n)=>Pc(e,o,r,n)});function Ue(e,t){return new Bf({type:"intersection",left:e,right:t})}var Xp=m("ZodRecord",(e,t)=>{zd.init(e,t),L.init(e,t),e._zod.processJSONSchema=(o,r,n)=>kc(e,o,r,n),e.keyType=t.keyType,e.valueType=t.valueType});function S(e,t,o){if(!t||!t._zod)return new Xp({type:"record",keyType:s(),valueType:e,...w(t)});return new Xp({type:"record",keyType:e,valueType:t,...w(o)})}var Lc=m("ZodEnum",(e,t)=>{Rd.init(e,t),L.init(e,t),e._zod.processJSONSchema=(r,n,i)=>vc(e,r,n,i),e.enum=t.entries,e.options=Object.values(t.entries);let o=new Set(Object.keys(t.entries));e.extract=(r,n)=>{let i={};for(let a of r)if(o.has(a))i[a]=t.entries[a];else throw Error(`Key ${a} not found in enum`);return new Lc({...t,checks:[],...w(n),entries:i})},e.exclude=(r,n)=>{let i={...t.entries};for(let a of r)if(o.has(a))delete i[a];else throw Error(`Key ${a} not found in enum`);return new Lc({...t,checks:[],...w(n),entries:i})}});function C(e,t){let o=Array.isArray(e)?Object.fromEntries(e.map((r)=>[r,r])):e;return new Lc({type:"enum",entries:o,...w(t)})}var Wf=m("ZodLiteral",(e,t)=>{wd.init(e,t),L.init(e,t),e._zod.processJSONSchema=(o,r,n)=>zc(e,o,r,n),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function l(e,t){return new Wf({type:"literal",values:Array.isArray(e)?e:[e],...w(t)})}var Kf=m("ZodTransform",(e,t)=>{xd.init(e,t),L.init(e,t),e._zod.processJSONSchema=(o,r,n)=>wc(e,o,r,n),e._zod.parse=(o,r)=>{if(r.direction==="backward")throw new Jr(e.constructor.name);o.addIssue=(i)=>{if(typeof i==="string")o.issues.push(Ct(i,o.value,t));else{let a=i;if(a.fatal)a.continue=!1;a.code??(a.code="custom"),a.input??(a.input=o.value),a.inst??(a.inst=e),o.issues.push(Ct(a))}};let n=t.transform(o.value,o);if(n instanceof Promise)return n.then((i)=>(o.value=i,o.fallback=!0,o));return o.value=n,o.fallback=!0,o}});function uh(e){return new Kf({type:"transform",transform:e})}var dh=m("ZodOptional",(e,t)=>{Ga.init(e,t),L.init(e,t),e._zod.processJSONSchema=(o,r,n)=>Li(e,o,r,n),e.unwrap=()=>e._zod.def.innerType});function x(e){return new dh({type:"optional",innerType:e})}var Gf=m("ZodExactOptional",(e,t)=>{Td.init(e,t),L.init(e,t),e._zod.processJSONSchema=(o,r,n)=>Li(e,o,r,n),e.unwrap=()=>e._zod.def.innerType});function Yf(e){return new Gf({type:"optional",innerType:e})}var Qf=m("ZodNullable",(e,t)=>{Ed.init(e,t),L.init(e,t),e._zod.processJSONSchema=(o,r,n)=>$c(e,o,r,n),e.unwrap=()=>e._zod.def.innerType});function eh(e){return new Qf({type:"nullable",innerType:e})}var Xf=m("ZodDefault",(e,t)=>{Pd.init(e,t),L.init(e,t),e._zod.processJSONSchema=(o,r,n)=>Ic(e,o,r,n),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function eg(e,t){return new Xf({type:"default",innerType:e,get defaultValue(){return typeof t==="function"?t():Na(t)}})}var tg=m("ZodPrefault",(e,t)=>{kd.init(e,t),L.init(e,t),e._zod.processJSONSchema=(o,r,n)=>Oc(e,o,r,n),e.unwrap=()=>e._zod.def.innerType});function og(e,t){return new tg({type:"prefault",innerType:e,get defaultValue(){return typeof t==="function"?t():Na(t)}})}var ph=m("ZodNonOptional",(e,t)=>{$d.init(e,t),L.init(e,t),e._zod.processJSONSchema=(o,r,n)=>Cc(e,o,r,n),e.unwrap=()=>e._zod.def.innerType});function rg(e,t){return new ph({type:"nonoptional",innerType:e,...w(t)})}var ng=m("ZodCatch",(e,t)=>{Cd.init(e,t),L.init(e,t),e._zod.processJSONSchema=(o,r,n)=>Mc(e,o,r,n),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function sg(e,t){return new ng({type:"catch",innerType:e,catchValue:typeof t==="function"?t:()=>t})}var hh=m("ZodPipe",(e,t)=>{Ya.init(e,t),L.init(e,t),e._zod.processJSONSchema=(o,r,n)=>qc(e,o,r,n),e.in=t.in,e.out=t.out});function th(e,t){return new hh({type:"pipe",in:e,out:t})}var ig=m("ZodPreprocess",(e,t)=>{hh.init(e,t),Id.init(e,t)}),ag=m("ZodReadonly",(e,t)=>{Od.init(e,t),L.init(e,t),e._zod.processJSONSchema=(o,r,n)=>Nc(e,o,r,n),e.unwrap=()=>e._zod.def.innerType});function cg(e){return new ag({type:"readonly",innerType:e})}var lg=m("ZodLazy",(e,t)=>{Md.init(e,t),L.init(e,t),e._zod.processJSONSchema=(o,r,n)=>Ac(e,o,r,n),e.unwrap=()=>e._zod.def.getter()});function cn(e){return new lg({type:"lazy",getter:e})}var ug=m("ZodCustom",(e,t)=>{qd.init(e,t),L.init(e,t),e._zod.processJSONSchema=(o,r,n)=>Rc(e,o,r,n)});function dg(e,t={}){return bp(ug,e,t)}function pg(e,t){return yp(e,t)}function Ot(e,t){return new ig({type:"pipe",in:uh(e),out:t})}var fh={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"};var mh;(function(e){})(mh||(mh={}));function hg(e){return up(Vi,e)}ce(Qa());var Bi="2025-11-25";var Wi=[Bi,"2025-06-18","2025-03-26","2024-11-05","2024-10-07"],Ki="io.modelcontextprotocol/related-task",Mt="io.modelcontextprotocol/protocolVersion",zo="io.modelcontextprotocol/clientInfo",lt="io.modelcontextprotocol/serverInfo",qt="io.modelcontextprotocol/clientCapabilities",Gi="io.modelcontextprotocol/subscriptionId",Ro="io.modelcontextprotocol/logLevel";var Nt="2.0";var Ze=cn(()=>_([s(),g(),v(),It(),S(s(),Ze),h(Ze)])),F=S(s(),Ze),Yi=h(Ze),wo=_([s(),g().int()]),xo=s(),ln=c({ttl:g().optional()}),un=c({taskId:s()}),To=T({progressToken:wo.optional(),[Ki]:un.optional()}),Q=c({_meta:To.optional()}),ut=Q.extend({task:ln.optional()}),V=c({method:s(),params:Q.loose().optional()}),se=c({_meta:To.optional()}),ee=c({method:s(),params:se.loose().optional()}),Eo=T({get[lt](){return ge.optional().catch(void 0)}}),J=T({_meta:Eo.optional()}),fe=_([s(),g().int()]),Po=c({jsonrpc:l(Nt),id:fe,...V.shape}).strict(),ko=c({jsonrpc:l(Nt),...ee.shape}).strict(),At=c({jsonrpc:l(Nt),id:fe,result:J}).strict(),jt=c({jsonrpc:l(Nt),id:fe.optional(),error:c({code:g().int(),message:s(),data:R().optional()})}).strict(),De=_([Po,ko,At,jt]),Qi=_([At,jt]),Ce=J.strict(),dn=se.extend({requestId:fe.optional(),reason:s().optional()}),$o=ee.extend({method:l("notifications/cancelled"),params:dn}),pn=c({src:s(),mimeType:s().optional(),sizes:h(s()).optional(),theme:C(["light","dark"]).optional()}),He=c({icons:h(pn).optional()}),$e=c({name:s(),title:s().optional()}),ge=$e.extend({...$e.shape,...He.shape,version:s(),websiteUrl:s().optional(),description:s().optional()}),fg=Ue(c({applyDefaults:v().optional()}),F),gg=Ot((e)=>{if(e&&typeof e==="object"&&!Array.isArray(e)&&Object.keys(e).length===0)return{form:{}};return e},Ue(c({form:fg.optional(),url:F.optional()}),F.optional())),Xi=T({list:F.optional(),cancel:F.optional(),requests:T({sampling:T({createMessage:F.optional()}).optional(),elicitation:T({create:F.optional()}).optional()}).optional()}),ea=T({list:F.optional(),cancel:F.optional(),requests:T({tools:T({call:F.optional()}).optional()}).optional()}),hn=c({experimental:S(s(),F).optional(),sampling:c({context:F.optional(),tools:F.optional()}).optional(),elicitation:gg.optional(),roots:c({listChanged:v().optional()}).optional(),tasks:Xi.optional(),extensions:S(s(),F).optional()}),mn=Q.extend({protocolVersion:s(),capabilities:hn,clientInfo:ge}),fn=V.extend({method:l("initialize"),params:mn}),Co=c({experimental:S(s(),F).optional(),logging:F.optional(),completions:F.optional(),prompts:c({listChanged:v().optional()}).optional(),resources:c({subscribe:v().optional(),listChanged:v().optional()}).optional(),tools:c({listChanged:v().optional()}).optional(),tasks:ea.optional(),extensions:S(s(),F).optional()}),gn=J.extend({protocolVersion:s(),capabilities:Co,serverInfo:ge,instructions:s().optional()}),Sn=ee.extend({method:l("notifications/initialized"),params:se.optional()}),_n=V.extend({method:l("server/discover"),params:Q.optional()}),Io=J.extend({supportedVersions:h(s()),capabilities:Co,instructions:s().optional()}),Oo=V.extend({method:l("ping"),params:Q.optional()}),bn=c({progress:g(),total:x(g()),message:x(s())}),yn=c({...se.shape,...bn.shape,progressToken:wo}),Mo=ee.extend({method:l("notifications/progress"),params:yn}),vn=Q.extend({cursor:xo.optional()}),Fe=V.extend({params:vn.optional()}),Ve=J.extend({nextCursor:xo.optional()}),qo=c({uri:s(),mimeType:x(s()),_meta:S(s(),R()).optional()}),No=qo.extend({text:s()}),Zc=s().refine((e)=>{try{return atob(e),!0}catch{return!1}},{message:"Invalid Base64 string"}),Ao=qo.extend({blob:Zc}),Je=C(["user","assistant"]),Ie=c({audience:h(Je).optional(),priority:g().min(0).max(1).optional(),lastModified:_o({offset:!0}).optional()}),jo=c({...$e.shape,...He.shape,uri:s(),description:x(s()),mimeType:x(s()),size:x(g()),annotations:Ie.optional(),_meta:x(T({}))}),zn=c({...$e.shape,...He.shape,uriTemplate:s(),description:x(s()),mimeType:x(s()),annotations:Ie.optional(),_meta:x(T({}))}),Rn=Fe.extend({method:l("resources/list")}),wn=Ve.extend({resources:h(jo)}),xn=Fe.extend({method:l("resources/templates/list")}),Tn=Ve.extend({resourceTemplates:h(zn)}),Lt=Q.extend({uri:s()}),En=Lt,Pn=V.extend({method:l("resources/read"),params:En}),kn=J.extend({contents:h(_([No,Ao]))}),$n=ee.extend({method:l("notifications/resources/list_changed"),params:se.optional()}),Cn=Lt,In=V.extend({method:l("resources/subscribe"),params:Cn}),On=Lt,Mn=V.extend({method:l("resources/unsubscribe"),params:On}),Lo=c({toolsListChanged:v().optional(),promptsListChanged:v().optional(),resourcesListChanged:v().optional(),resourceSubscriptions:h(s()).optional()}),qn=Q.extend({notifications:Lo}),Nn=V.extend({method:l("subscriptions/listen"),params:qn}),An=se.extend({notifications:Lo}),jn=ee.extend({method:l("notifications/subscriptions/acknowledged"),params:An}),Ln=Eo.extend({[Gi]:fe}),Un=J.extend({_meta:Ln}),Zn=se.extend({uri:s()}),Dn=ee.extend({method:l("notifications/resources/updated"),params:Zn}),Hn=c({name:s(),description:x(s()),required:x(v())}),Fn=c({...$e.shape,...He.shape,description:x(s()),arguments:x(h(Hn)),_meta:x(T({}))}),Vn=Fe.extend({method:l("prompts/list")}),Jn=Ve.extend({prompts:h(Fn)}),Bn=Q.extend({name:s(),arguments:S(s(),s()).optional()}),Wn=V.extend({method:l("prompts/get"),params:Bn}),Ut=c({type:l("text"),text:s(),annotations:Ie.optional(),_meta:S(s(),R()).optional()}),Zt=c({type:l("image"),data:Zc,mimeType:s(),annotations:Ie.optional(),_meta:S(s(),R()).optional()}),Dt=c({type:l("audio"),data:Zc,mimeType:s(),annotations:Ie.optional(),_meta:S(s(),R()).optional()}),Kn=c({type:l("tool_use"),name:s(),id:s(),input:S(s(),R()),_meta:S(s(),R()).optional()}),Be=c({type:l("resource"),resource:_([No,Ao]),annotations:Ie.optional(),_meta:S(s(),R()).optional()}),We=jo.extend({type:l("resource_link")}),Se=_([Ut,Zt,Dt,We,Be]),Gn=c({role:Je,content:Se}),Yn=J.extend({description:s().optional(),messages:h(Gn)}),Qn=ee.extend({method:l("notifications/prompts/list_changed"),params:se.optional()}),Xn=c({title:s().optional(),readOnlyHint:v().optional(),destructiveHint:v().optional(),idempotentHint:v().optional(),openWorldHint:v().optional()}),es=c({taskSupport:C(["required","optional","forbidden"]).optional()}),Oe=c({...$e.shape,...He.shape,description:s().optional(),inputSchema:c({type:l("object"),properties:S(s(),Ze).optional(),required:h(s()).optional()}).catchall(R()),outputSchema:T({$schema:s().optional()}).optional(),annotations:Xn.optional(),execution:es.optional(),_meta:S(s(),R()).optional()}),ts=Fe.extend({method:l("tools/list")}),os=Ve.extend({tools:h(Oe)}),Me=J.extend({content:h(Se).default([]),structuredContent:R().optional(),isError:v().optional()}),ta=Me.or(J.extend({toolResult:R()})),rs=ut.extend({name:s(),arguments:S(s(),R()).optional()}),ns=V.extend({method:l("tools/call"),params:rs}),ss=ee.extend({method:l("notifications/tools/list_changed"),params:se.optional()}),oa=c({autoRefresh:v().default(!0),debounceMs:g().int().nonnegative().default(300)}),Uo=C(["debug","info","notice","warning","error","critical","alert","emergency"]),is=Q.extend({level:Uo}),as=V.extend({method:l("logging/setLevel"),params:is}),cs=se.extend({level:Uo,logger:s().optional(),data:R()}),Ht=ee.extend({method:l("notifications/message"),params:cs}),ls=c({name:s().optional()}),us=c({hints:h(ls).optional(),costPriority:g().min(0).max(1).optional(),speedPriority:g().min(0).max(1).optional(),intelligencePriority:g().min(0).max(1).optional()}),ds=c({mode:C(["auto","required","none"]).optional()}),ps=c({type:l("tool_result"),toolUseId:s().describe("The unique identifier for the corresponding tool call."),content:h(Se),structuredContent:R().optional(),isError:v().optional(),_meta:S(s(),R()).optional()}),hs=vo("type",[Ut,Zt,Dt]),ct=vo("type",[Ut,Zt,Dt,Kn,ps]),ms=c({role:Je,content:_([ct,h(ct)]),_meta:S(s(),R()).optional()}),fs=ut.extend({messages:h(ms),modelPreferences:us.optional(),systemPrompt:s().optional(),includeContext:C(["none","thisServer","allServers"]).optional(),temperature:g().optional(),maxTokens:g().int(),stopSequences:h(s()).optional(),metadata:F.optional(),tools:h(Oe).optional(),toolChoice:ds.optional()}),gs=V.extend({method:l("sampling/createMessage"),params:fs}),Ss=J.extend({model:s(),stopReason:x(C(["endTurn","stopSequence","maxTokens"]).or(s())),role:Je,content:hs}),_s=J.extend({model:s(),stopReason:x(C(["endTurn","stopSequence","maxTokens","toolUse"]).or(s())),role:Je,content:_([ct,h(ct)])}),Zo=c({type:l("boolean"),title:s().optional(),description:s().optional(),default:v().optional()}),Ft=c({type:l("string"),title:s().optional(),description:s().optional(),minLength:g().optional(),maxLength:g().optional(),format:C(["email","uri","date","date-time"]).optional(),default:s().optional()}),Vt=c({type:C(["number","integer"]),title:s().optional(),description:s().optional(),minimum:g().optional(),maximum:g().optional(),default:g().optional()}),Do=c({type:l("string"),title:s().optional(),description:s().optional(),enum:h(s()),default:s().optional()}),Ho=c({type:l("string"),title:s().optional(),description:s().optional(),oneOf:h(c({const:s(),title:s()})),default:s().optional()}),Fo=c({type:l("string"),title:s().optional(),description:s().optional(),enum:h(s()),enumNames:h(s()).optional(),default:s().optional()}),bs=_([Do,Ho]),Vo=c({type:l("array"),title:s().optional(),description:s().optional(),minItems:g().optional(),maxItems:g().optional(),items:c({type:l("string"),enum:h(s())}),default:h(s()).optional()}),Jo=c({type:l("array"),title:s().optional(),description:s().optional(),minItems:g().optional(),maxItems:g().optional(),items:c({anyOf:h(c({const:s(),title:s()}))}),default:h(s()).optional()}),ys=_([Vo,Jo]),vs=_([Fo,bs,ys]),Bo=_([vs,Zo,Ft,Vt]),Jt=ut.extend({mode:l("form").optional(),message:s(),requestedSchema:c({type:l("object"),properties:S(s(),Bo),required:h(s()).optional()}).catchall(R())}),zs=ut.extend({mode:l("url"),message:s(),elicitationId:s(),url:s().url()}),Rs=_([Jt,zs]),ws=V.extend({method:l("elicitation/create"),params:Rs}),xs=se.extend({elicitationId:s()}),Ts=ee.extend({method:l("notifications/elicitation/complete"),params:xs}),Es=J.extend({action:C(["accept","decline","cancel"]),content:Ot((e)=>e===null?void 0:e,S(s(),_([s(),g(),v(),h(s())])).optional())}),Ps=c({type:l("ref/resource"),uri:s()}),ks=c({type:l("ref/prompt"),name:s()}),$s=Q.extend({ref:_([ks,Ps]),argument:c({name:s(),value:s()}),context:c({arguments:S(s(),s()).optional()}).optional()}),Cs=V.extend({method:l("completion/complete"),params:$s}),Is=J.extend({completion:T({values:h(s()).max(100),total:x(g().int()),hasMore:x(v())})}),Os=c({uri:s().startsWith("file://"),name:s().optional(),_meta:S(s(),R()).optional()}),Ms=V.extend({method:l("roots/list"),params:Q.optional()}),qs=J.extend({roots:h(Os)}),Ns=ee.extend({method:l("notifications/roots/list_changed"),params:se.optional()}),ra=T({ttl:g().optional(),pollInterval:g().optional()}),As=C(["working","input_required","completed","failed","cancelled"]),Ke=c({taskId:s(),status:As,ttl:_([g(),It()]),createdAt:s(),lastUpdatedAt:s(),pollInterval:x(g()),statusMessage:x(s())}),na=J.extend({task:Ke}),js=se.merge(Ke),sa=ee.extend({method:l("notifications/tasks/status"),params:js}),ia=V.extend({method:l("tasks/get"),params:Q.extend({taskId:s()})}),aa=J.merge(Ke),ca=V.extend({method:l("tasks/result"),params:Q.extend({taskId:s()})}),la=J.loose(),ua=Fe.extend({method:l("tasks/list")}),da=Ve.extend({tasks:h(Ke)}),pa=V.extend({method:l("tasks/cancel"),params:Q.extend({taskId:s()})}),ha=J.merge(Ke),ma=_([Oo,fn,_n,Cs,as,Wn,Vn,Rn,xn,Pn,In,Mn,Nn,ns,ts]),fa=_([$o,Mo,Sn,Ns]),ga=_([Ce,Ss,_s,Es,qs]),Sa=_([Oo,gs,ws,Ms]),_a=_([$o,Mo,Ht,Dn,$n,ss,Qn,jn,Ts]),ba=_([Ce,gn,Io,Is,Yn,Jn,wn,Tn,kn,Me,os,Un]),Y=Fi().superRefine((e,t)=>{if(!URL.canParse(e))return t.addIssue({code:fh.custom,message:"URL must be parseable",fatal:!0}),Ca}).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"}),Ls=T({resource:s().url(),authorization_servers:h(Y).optional(),jwks_uri:s().url().optional(),scopes_supported:h(s()).optional(),bearer_methods_supported:h(s()).optional(),resource_signing_alg_values_supported:h(s()).optional(),resource_name:s().optional(),resource_documentation:s().optional(),resource_policy_uri:s().url().optional(),resource_tos_uri:s().url().optional(),tls_client_certificate_bound_access_tokens:v().optional(),authorization_details_types_supported:h(s()).optional(),dpop_signing_alg_values_supported:h(s()).optional(),dpop_bound_access_tokens_required:v().optional()}),Wo=T({issuer:s(),authorization_endpoint:Y,token_endpoint:Y,registration_endpoint:Y.optional(),scopes_supported:h(s()).optional(),response_types_supported:h(s()),response_modes_supported:h(s()).optional(),grant_types_supported:h(s()).optional(),token_endpoint_auth_methods_supported:h(s()).optional(),token_endpoint_auth_signing_alg_values_supported:h(s()).optional(),service_documentation:Y.optional(),revocation_endpoint:Y.optional(),revocation_endpoint_auth_methods_supported:h(s()).optional(),revocation_endpoint_auth_signing_alg_values_supported:h(s()).optional(),introspection_endpoint:s().optional(),introspection_endpoint_auth_methods_supported:h(s()).optional(),introspection_endpoint_auth_signing_alg_values_supported:h(s()).optional(),code_challenge_methods_supported:h(s()).optional(),client_id_metadata_document_supported:v().optional(),authorization_response_iss_parameter_supported:v().optional().catch(void 0),dpop_signing_alg_values_supported:h(s()).optional()}),Us=T({issuer:s(),authorization_endpoint:Y,token_endpoint:Y,userinfo_endpoint:Y.optional(),jwks_uri:Y,registration_endpoint:Y.optional(),scopes_supported:h(s()).optional(),response_types_supported:h(s()),response_modes_supported:h(s()).optional(),grant_types_supported:h(s()).optional(),acr_values_supported:h(s()).optional(),subject_types_supported:h(s()),id_token_signing_alg_values_supported:h(s()),id_token_encryption_alg_values_supported:h(s()).optional(),id_token_encryption_enc_values_supported:h(s()).optional(),userinfo_signing_alg_values_supported:h(s()).optional(),userinfo_encryption_alg_values_supported:h(s()).optional(),userinfo_encryption_enc_values_supported:h(s()).optional(),request_object_signing_alg_values_supported:h(s()).optional(),request_object_encryption_alg_values_supported:h(s()).optional(),request_object_encryption_enc_values_supported:h(s()).optional(),token_endpoint_auth_methods_supported:h(s()).optional(),token_endpoint_auth_signing_alg_values_supported:h(s()).optional(),display_values_supported:h(s()).optional(),claim_types_supported:h(s()).optional(),claims_supported:h(s()).optional(),service_documentation:s().optional(),claims_locales_supported:h(s()).optional(),ui_locales_supported:h(s()).optional(),claims_parameter_supported:v().optional(),request_parameter_supported:v().optional(),request_uri_parameter_supported:v().optional(),require_request_uri_registration:v().optional(),op_policy_uri:Y.optional(),op_tos_uri:Y.optional(),client_id_metadata_document_supported:v().optional(),authorization_response_iss_parameter_supported:v().optional().catch(void 0)}),Zs=c({...Us.shape,...Wo.pick({code_challenge_methods_supported:!0}).shape}),Ds=c({access_token:s(),id_token:s().optional(),token_type:s(),expires_in:hg().optional(),scope:s().optional(),refresh_token:s().optional(),issuer:s().optional().catch(void 0)}).strip(),Hs=c({issued_token_type:l("urn:ietf:params:oauth:token-type:id-jag"),access_token:s(),token_type:s().optional(),expires_in:g().optional(),scope:s().optional()}).strip(),Fs=c({error:s(),error_description:s().optional(),error_uri:s().optional()}),Uc=Y.optional().or(l("").transform(()=>{return})),Vs=c({redirect_uris:h(Y),token_endpoint_auth_method:s().optional(),grant_types:h(s()).optional(),response_types:h(s()).optional(),application_type:s().optional(),client_name:s().optional(),client_uri:Y.optional(),logo_uri:Uc,scope:s().optional(),contacts:h(s()).optional(),tos_uri:Uc,policy_uri:s().optional(),jwks_uri:Y.optional(),jwks:yo().optional(),software_id:s().optional(),software_version:s().optional(),software_statement:s().optional()}).strip(),Js=c({client_id:s(),client_secret:s().optional(),client_id_issued_at:g().optional(),client_secret_expires_at:g().optional(),issuer:s().optional().catch(void 0)}).strip(),Bs=Vs.merge(Js),ya=c({error:s(),error_description:s().optional()}).strip(),va=c({token:s(),token_type_hint:s().optional()}).strip();var Bc=Symbol.for("mcp.sdk.errorBrands");function Bt(e,t){let o=new Set,r=t;while(typeof r==="function"){let n=r.mcpBrand;if(Object.prototype.hasOwnProperty.call(r,"mcpBrand")&&typeof n==="string")o.add(n);r=Object.getPrototypeOf(r)}if(o.size===0)return;Object.defineProperty(e,Bc,{value:o,enumerable:!1,configurable:!0})}function _e(e,t){try{if(typeof t==="object"&&t!==null&&Object.prototype.hasOwnProperty.call(e,"mcpBrand")&&typeof e.mcpBrand==="string"&&Object.prototype.hasOwnProperty.call(t,Bc)){let o=t[Bc];if(o&&typeof o.has==="function"&&o.has(e.mcpBrand))return!0}}catch{}return Function.prototype[Symbol.hasInstance].call(e,t)}var Sg=class e extends Error{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.OAuthError"})}static[Symbol.hasInstance](t){return _e(this,t)}static isInstance(t){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 _e(this,t)}constructor(t,o,r){super(o);this.code=t,this.errorUri=r,this.name="OAuthError",Bt(this,new.target)}toResponseObject(){let t={error:this.code,error_description:this.message};if(this.errorUri)t.error_uri=this.errorUri;return t}static fromResponse(t){return new e(t.error,t.error_description??t.error,t.error_uri)}},te=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}({}),K=class extends Error{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.SdkError"})}static[Symbol.hasInstance](e){return _e(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 _e(this,e)}constructor(e,t,o,r){super(t,r);this.code=e,this.data=o,this.name="SdkError",Bt(this,new.target)}},_g=class extends K{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.SdkHttpError"})}constructor(e,t,o,r){super(e,t,o,r);this.name="SdkHttpError"}get status(){return this.data.status}get statusText(){return this.data.statusText}};var bg="2026-07-28";function Ah(e){return e>=bg}function jh(e){let t=e.structuredContent;if(t===void 0)return e;if(!(typeof t!=="object"||t===null||Array.isArray(t)))return e;if(e.content?.some((o)=>o.type==="text")??!1)return e;return{...e,content:[...e.content??[],{type:"text",text:JSON.stringify(t)}]}}var Lh=["task","inputRequests","requestState"];function yg(e){if(e===null||typeof e!=="object"||Array.isArray(e)||e.content!==void 0||Lh.some((t)=>(t in e)))return e;return{...e,content:[]}}function vg(){let e=cn(()=>_([s(),g(),v(),It(),S(s(),e),h(e)])),t=S(s(),e),o=_([s(),g().int()]),r=s(),n=c({ttl:g().optional()}),i=c({taskId:s()}),a=T({progressToken:o.optional(),"io.modelcontextprotocol/related-task":i.optional()}),u=c({_meta:a.optional()}),d=u.extend({task:n.optional()}),p=c({method:s(),params:u.loose().optional()}),f=c({_meta:a.optional()}),b=c({method:s(),params:f.loose().optional()}),y=T({_meta:a.optional()}),z=_([s(),g().int()]),E=y.strict(),P=f.extend({requestId:z.optional(),reason:s().optional()}),k=b.extend({method:l("notifications/cancelled"),params:P}),A=c({src:s(),mimeType:s().optional(),sizes:h(s()).optional(),theme:C(["light","dark"]).optional()}),B=c({icons:h(A).optional()}),q=c({name:s(),title:s().optional()}),M=q.extend({...q.shape,...B.shape,version:s(),websiteUrl:s().optional(),description:s().optional()}),D=Ue(c({applyDefaults:v().optional()}),t),U=Ot((ne)=>{if(ne&&typeof ne==="object"&&!Array.isArray(ne)&&Object.keys(ne).length===0)return{form:{}};return ne},Ue(c({form:D.optional(),url:t.optional()}),t.optional())),G=T({list:t.optional(),cancel:t.optional(),requests:T({sampling:T({createMessage:t.optional()}).optional(),elicitation:T({create:t.optional()}).optional()}).optional()}),Ne=T({list:t.optional(),cancel:t.optional(),requests:T({tools:T({call:t.optional()}).optional()}).optional()}),ie=c({experimental:S(s(),t).optional(),sampling:c({context:t.optional(),tools:t.optional()}).optional(),elicitation:U.optional(),roots:c({listChanged:v().optional()}).optional(),tasks:G.optional(),extensions:S(s(),t).optional()}),Ge=u.extend({protocolVersion:s(),capabilities:ie,clientInfo:M}),mt=p.extend({method:l("initialize"),params:Ge}),Yo=c({experimental:S(s(),t).optional(),logging:t.optional(),completions:t.optional(),prompts:c({listChanged:v().optional()}).optional(),resources:c({subscribe:v().optional(),listChanged:v().optional()}).optional(),tools:c({listChanged:v().optional()}).optional(),tasks:Ne.optional(),extensions:S(s(),t).optional()}),Qo=y.extend({protocolVersion:s(),capabilities:Yo,serverInfo:M,instructions:s().optional()}),Gt=b.extend({method:l("notifications/initialized"),params:f.optional()}),Ye=p.extend({method:l("ping"),params:u.optional()}),ft=c({progress:g(),total:x(g()),message:x(s())}),Ee=c({...f.shape,...ft.shape,progressToken:o}),Qe=b.extend({method:l("notifications/progress"),params:Ee}),Yt=u.extend({cursor:r.optional()}),Ae=p.extend({params:Yt.optional()}),je=y.extend({nextCursor:r.optional()}),Qt=c({uri:s(),mimeType:x(s()),_meta:S(s(),R()).optional()}),Xt=Qt.extend({text:s()}),gt=s().refine((ne)=>{try{return atob(ne),!0}catch{return!1}},{message:"Invalid Base64 string"}),eo=Qt.extend({blob:gt}),Pe=C(["user","assistant"]),Re=c({audience:h(Pe).optional(),priority:g().min(0).max(1).optional(),lastModified:_o({offset:!0}).optional()}),St=c({...q.shape,...B.shape,uri:s(),description:x(s()),mimeType:x(s()),size:x(g()),annotations:Re.optional(),_meta:x(T({}))}),Xo=c({...q.shape,...B.shape,uriTemplate:s(),description:x(s()),mimeType:x(s()),annotations:Re.optional(),_meta:x(T({}))}),er=Ae.extend({method:l("resources/list")}),tr=je.extend({resources:h(St)}),Xe=Ae.extend({method:l("resources/templates/list")}),to=je.extend({resourceTemplates:h(Xo)}),_t=u.extend({uri:s()}),or=_t,rr=p.extend({method:l("resources/read"),params:or}),nr=y.extend({contents:h(_([Xt,eo]))}),sr=b.extend({method:l("notifications/resources/list_changed"),params:f.optional()}),ir=_t,ar=p.extend({method:l("resources/subscribe"),params:ir}),cr=_t,lr=p.extend({method:l("resources/unsubscribe"),params:cr}),ur=f.extend({uri:s()}),dr=b.extend({method:l("notifications/resources/updated"),params:ur}),pr=c({name:s(),description:x(s()),required:x(v())}),hr=c({...q.shape,...B.shape,description:x(s()),arguments:x(h(pr)),_meta:x(T({}))}),mr=Ae.extend({method:l("prompts/list")}),fr=je.extend({prompts:h(hr)}),gr=u.extend({name:s(),arguments:S(s(),s()).optional()}),Sr=p.extend({method:l("prompts/get"),params:gr}),bt=c({type:l("text"),text:s(),annotations:Re.optional(),_meta:S(s(),R()).optional()}),yt=c({type:l("image"),data:gt,mimeType:s(),annotations:Re.optional(),_meta:S(s(),R()).optional()}),vt=c({type:l("audio"),data:gt,mimeType:s(),annotations:Re.optional(),_meta:S(s(),R()).optional()}),_r=c({type:l("tool_use"),name:s(),id:s(),input:S(s(),R()),_meta:S(s(),R()).optional()}),et=c({type:l("resource"),resource:_([Xt,eo]),annotations:Re.optional(),_meta:S(s(),R()).optional()}),br=St.extend({type:l("resource_link")}),ye=_([bt,yt,vt,br,et]),oo=c({role:Pe,content:ye}),ro=y.extend({description:s().optional(),messages:h(oo)}),zt=b.extend({method:l("notifications/prompts/list_changed"),params:f.optional()}),yr=c({title:s().optional(),readOnlyHint:v().optional(),destructiveHint:v().optional(),idempotentHint:v().optional(),openWorldHint:v().optional()}),no=c({taskSupport:C(["required","optional","forbidden"]).optional()}),Rt=c({...q.shape,...B.shape,description:s().optional(),inputSchema:c({type:l("object"),properties:S(s(),e).optional(),required:h(s()).optional()}).catchall(R()),outputSchema:c({type:l("object"),properties:S(s(),e).optional(),required:h(s()).optional()}).catchall(R()).optional(),annotations:yr.optional(),execution:no.optional(),_meta:S(s(),R()).optional()}),so=Ae.extend({method:l("tools/list")}),io=je.extend({tools:h(Rt)}),ao=y.extend({content:h(ye),structuredContent:S(s(),R()).optional(),isError:v().optional()}),re=d.extend({name:s(),arguments:S(s(),R()).optional()}),vr=p.extend({method:l("tools/call"),params:re}),ii=b.extend({method:l("notifications/tools/list_changed"),params:f.optional()}),co=C(["debug","info","notice","warning","error","critical","alert","emergency"]),zr=u.extend({level:co}),Rr=p.extend({method:l("logging/setLevel"),params:zr}),wr=f.extend({level:co,logger:s().optional(),data:R()}),xr=b.extend({method:l("notifications/message"),params:wr}),Tr=c({name:s().optional()}),Er=c({hints:h(Tr).optional(),costPriority:g().min(0).max(1).optional(),speedPriority:g().min(0).max(1).optional(),intelligencePriority:g().min(0).max(1).optional()}),Pr=c({mode:C(["auto","required","none"]).optional()}),ai=c({type:l("tool_result"),toolUseId:s().describe("The unique identifier for the corresponding tool call."),content:h(ye),structuredContent:c({}).loose().optional(),isError:v().optional(),_meta:S(s(),R()).optional()}),kr=vo("type",[bt,yt,vt]),tt=vo("type",[bt,yt,vt,_r,ai]),$r=c({role:Pe,content:_([tt,h(tt)]),_meta:S(s(),R()).optional()}),Cr=d.extend({messages:h($r),modelPreferences:Er.optional(),systemPrompt:s().optional(),includeContext:C(["none","thisServer","allServers"]).optional(),temperature:g().optional(),maxTokens:g().int(),stopSequences:h(s()).optional(),metadata:t.optional(),tools:h(Rt).optional(),toolChoice:Pr.optional()}),Ir=p.extend({method:l("sampling/createMessage"),params:Cr}),Or=y.extend({model:s(),stopReason:x(C(["endTurn","stopSequence","maxTokens"]).or(s())),role:Pe,content:kr}),Mr=y.extend({model:s(),stopReason:x(C(["endTurn","stopSequence","maxTokens","toolUse"]).or(s())),role:Pe,content:_([tt,h(tt)])}),qr=c({type:l("boolean"),title:s().optional(),description:s().optional(),default:v().optional()}),Nr=c({type:l("string"),title:s().optional(),description:s().optional(),minLength:g().optional(),maxLength:g().optional(),format:C(["email","uri","date","date-time"]).optional(),default:s().optional()}),Ar=c({type:C(["number","integer"]),title:s().optional(),description:s().optional(),minimum:g().optional(),maximum:g().optional(),default:g().optional()}),jr=c({type:l("string"),title:s().optional(),description:s().optional(),enum:h(s()),default:s().optional()}),Lr=c({type:l("string"),title:s().optional(),description:s().optional(),oneOf:h(c({const:s(),title:s()})),default:s().optional()}),Ur=c({type:l("string"),title:s().optional(),description:s().optional(),enum:h(s()),enumNames:h(s()).optional(),default:s().optional()}),Zr=_([jr,Lr]),wt=c({type:l("array"),title:s().optional(),description:s().optional(),minItems:g().optional(),maxItems:g().optional(),items:c({type:l("string"),enum:h(s())}),default:h(s()).optional()}),xt=c({type:l("array"),title:s().optional(),description:s().optional(),minItems:g().optional(),maxItems:g().optional(),items:c({anyOf:h(c({const:s(),title:s()}))}),default:h(s()).optional()}),ci=_([wt,xt]),li=_([Ur,Zr,ci]),pe=_([li,qr,Nr,Ar]),he=d.extend({mode:l("form").optional(),message:s(),requestedSchema:c({type:l("object"),properties:S(s(),pe),required:h(s()).optional()}).catchall(R())}),Dr=d.extend({mode:l("url"),message:s(),elicitationId:s(),url:s().url()}),we=_([he,Dr]),ui=p.extend({method:l("elicitation/create"),params:we}),di=f.extend({elicitationId:s()}),pi=b.extend({method:l("notifications/elicitation/complete"),params:di}),hi=y.extend({action:C(["accept","decline","cancel"]),content:Ot((ne)=>ne===null?void 0:ne,S(s(),_([s(),g(),v(),h(s())])).optional())}),mi=c({type:l("ref/resource"),uri:s()}),fi=c({type:l("ref/prompt"),name:s()}),gi=u.extend({ref:_([fi,mi]),argument:c({name:s(),value:s()}),context:c({arguments:S(s(),s()).optional()}).optional()}),Hr=p.extend({method:l("completion/complete"),params:gi}),Si=y.extend({completion:T({values:h(s()).max(100),total:x(g().int()),hasMore:x(v())})}),_i=c({uri:s().startsWith("file://"),name:s().optional(),_meta:S(s(),R()).optional()}),lo=p.extend({method:l("roots/list"),params:u.optional()}),Fr=y.extend({roots:h(_i)}),bi=b.extend({method:l("notifications/roots/list_changed"),params:f.optional()}),yi=T({ttl:g().optional(),pollInterval:g().optional()}),Vr=C(["working","input_required","completed","failed","cancelled"]),ot=c({taskId:s(),status:Vr,ttl:_([g(),It()]),createdAt:s(),lastUpdatedAt:s(),pollInterval:x(g()),statusMessage:x(s())}),de=y.extend({task:ot}),vi=f.merge(ot),Tt=b.extend({method:l("notifications/tasks/status"),params:vi}),uo=p.extend({method:l("tasks/get"),params:u.extend({taskId:s()})}),po=y.merge(ot),ho=p.extend({method:l("tasks/result"),params:u.extend({taskId:s()})}),$a=y.loose(),ae=Ae.extend({method:l("tasks/list")}),W=je.extend({tasks:h(ot)}),Et=p.extend({method:l("tasks/cancel"),params:u.extend({taskId:s()})});return{JSONValueSchema:e,JSONObjectSchema:t,ProgressTokenSchema:o,CursorSchema:r,TaskMetadataSchema:n,RelatedTaskMetadataSchema:i,RequestMetaSchema:a,BaseRequestParamsSchema:u,TaskAugmentedRequestParamsSchema:d,RequestSchema:p,NotificationsParamsSchema:f,NotificationSchema:b,ResultSchema:y,RequestIdSchema:z,EmptyResultSchema:E,CancelledNotificationParamsSchema:P,CancelledNotificationSchema:k,IconSchema:A,IconsSchema:B,BaseMetadataSchema:q,ImplementationSchema:M,ClientTasksCapabilitySchema:G,ServerTasksCapabilitySchema:Ne,ClientCapabilitiesSchema:ie,InitializeRequestParamsSchema:Ge,InitializeRequestSchema:mt,ServerCapabilitiesSchema:Yo,InitializeResultSchema:Qo,InitializedNotificationSchema:Gt,PingRequestSchema:Ye,ProgressSchema:ft,ProgressNotificationParamsSchema:Ee,ProgressNotificationSchema:Qe,PaginatedRequestParamsSchema:Yt,PaginatedRequestSchema:Ae,PaginatedResultSchema:je,ResourceContentsSchema:Qt,TextResourceContentsSchema:Xt,BlobResourceContentsSchema:eo,RoleSchema:Pe,AnnotationsSchema:Re,ResourceSchema:St,ResourceTemplateSchema:Xo,ListResourcesRequestSchema:er,ListResourcesResultSchema:tr,ListResourceTemplatesRequestSchema:Xe,ListResourceTemplatesResultSchema:to,ResourceRequestParamsSchema:_t,ReadResourceRequestParamsSchema:or,ReadResourceRequestSchema:rr,ReadResourceResultSchema:nr,ResourceListChangedNotificationSchema:sr,SubscribeRequestParamsSchema:ir,SubscribeRequestSchema:ar,UnsubscribeRequestParamsSchema:cr,UnsubscribeRequestSchema:lr,ResourceUpdatedNotificationParamsSchema:ur,ResourceUpdatedNotificationSchema:dr,PromptArgumentSchema:pr,PromptSchema:hr,ListPromptsRequestSchema:mr,ListPromptsResultSchema:fr,GetPromptRequestParamsSchema:gr,GetPromptRequestSchema:Sr,TextContentSchema:bt,ImageContentSchema:yt,AudioContentSchema:vt,ToolUseContentSchema:_r,EmbeddedResourceSchema:et,ResourceLinkSchema:br,ContentBlockSchema:ye,PromptMessageSchema:oo,GetPromptResultSchema:ro,PromptListChangedNotificationSchema:zt,ToolAnnotationsSchema:yr,ToolExecutionSchema:no,ToolSchema:Rt,ListToolsRequestSchema:so,ListToolsResultSchema:io,CallToolResultSchema:ao,CallToolRequestParamsSchema:re,CallToolRequestSchema:vr,ToolListChangedNotificationSchema:ii,LoggingLevelSchema:co,SetLevelRequestParamsSchema:zr,SetLevelRequestSchema:Rr,LoggingMessageNotificationParamsSchema:wr,LoggingMessageNotificationSchema:xr,ModelHintSchema:Tr,ModelPreferencesSchema:Er,ToolChoiceSchema:Pr,ToolResultContentSchema:ai,SamplingContentSchema:kr,SamplingMessageContentBlockSchema:tt,SamplingMessageSchema:$r,CreateMessageRequestParamsSchema:Cr,CreateMessageRequestSchema:Ir,CreateMessageResultSchema:Or,CreateMessageResultWithToolsSchema:Mr,BooleanSchemaSchema:qr,StringSchemaSchema:Nr,NumberSchemaSchema:Ar,UntitledSingleSelectEnumSchemaSchema:jr,TitledSingleSelectEnumSchemaSchema:Lr,LegacyTitledEnumSchemaSchema:Ur,SingleSelectEnumSchemaSchema:Zr,UntitledMultiSelectEnumSchemaSchema:wt,TitledMultiSelectEnumSchemaSchema:xt,MultiSelectEnumSchemaSchema:ci,EnumSchemaSchema:li,PrimitiveSchemaDefinitionSchema:pe,ElicitRequestFormParamsSchema:he,ElicitRequestURLParamsSchema:Dr,ElicitRequestParamsSchema:we,ElicitRequestSchema:ui,ElicitationCompleteNotificationParamsSchema:di,ElicitationCompleteNotificationSchema:pi,ElicitResultSchema:hi,ResourceTemplateReferenceSchema:mi,PromptReferenceSchema:fi,CompleteRequestParamsSchema:gi,CompleteRequestSchema:Hr,CompleteResultSchema:Si,RootSchema:_i,ListRootsRequestSchema:lo,ListRootsResultSchema:Fr,RootsListChangedNotificationSchema:bi,TaskCreationParamsSchema:yi,TaskStatusSchema:Vr,TaskSchema:ot,CreateTaskResultSchema:de,TaskStatusNotificationParamsSchema:vi,TaskStatusNotificationSchema:Tt,GetTaskRequestSchema:uo,GetTaskResultSchema:po,GetTaskPayloadRequestSchema:ho,GetTaskPayloadResultSchema:$a,ListTasksRequestSchema:ae,ListTasksResultSchema:W,CancelTaskRequestSchema:Et,CancelTaskResultSchema:y.merge(ot),ClientRequestSchema:_([Ye,mt,Hr,Rr,Sr,mr,er,Xe,rr,ar,lr,vr,so,uo,ho,ae,Et]),ClientNotificationSchema:_([k,Qe,Gt,bi,Tt]),ClientResultSchema:_([E,Or,Mr,hi,Fr,po,W,de]),ServerRequestSchema:_([Ye,Ir,ui,lo,uo,ho,ae,Et]),ServerNotificationSchema:_([k,Qe,xr,dr,sr,ii,zt,Tt,pi]),ServerResultSchema:_([E,Qo,Si,ro,fr,tr,to,nr,ao,io,po,W,de]),CallToolResultWireSchema:R().superRefine((ne,jm)=>{if(typeof ne!=="object"||ne===null||Array.isArray(ne)||ne.content!==void 0)return;for(let fl of Lh)if(fl in ne){jm.addIssue({code:"custom",message:`content is required when the body carries '${fl}' — another result family cannot default into an empty tools/call success`});return}}).transform(yg).pipe(ao)}}var zg;function Uh(){return zg??=vg()}function Zh(e){return e.type!=="object"}var Rg=new Set(["const","enum","default","examples"]),wg=new Set(["properties","patternProperties","$defs","definitions","dependentSchemas","dependencies"]);function Th(e){return e!==void 0&&!(typeof e==="string"&&e.startsWith("#"))}function xg(e){let t=typeof e.$schema==="string"?e.$schema:void 0;if(Th(e.$id))return{...t!==void 0&&{$schema:t},type:"object",properties:{result:e},required:["result"]};let o=bl(e.$schema)&&e.$recursiveAnchor!==!0,r=(n,i)=>{if(Array.isArray(n))return n.map((d)=>r(d,!1));if(n===null||typeof n!=="object")return n;if(!i&&Th(n.$id))return n;let a={},u=!1;for(let[d,p]of Object.entries(n))if(i)a[d]=r(p,!1);else if((d==="$ref"||d==="$dynamicRef")&&typeof p==="string")a[d]=p==="#"?"#/properties/result":p.startsWith("#/")?`#/properties/result${p.slice(1)}`:p;else if(d==="$recursiveRef"&&p==="#"&&o)u=!0;else if(Rg.has(d))a[d]=p;else if(wg.has(d))a[d]=r(p,!0);else a[d]=r(p,!1);if(u)if("$ref"in a)a.allOf=[...Array.isArray(a.allOf)?a.allOf:[],{$ref:"#/properties/result"}];else a.$ref="#/properties/result";return a};return{...t!==void 0&&{$schema:t},type:"object",properties:{result:r(e,!1)},required:["result"]}}var Dh={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},Hh={"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},Tg={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},za;function Xc(){if(za)return za;let e=Uh();return za={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}},za}function Fh(e){return Object.prototype.hasOwnProperty.call(Dh,e)}function Vh(e){return Object.prototype.hasOwnProperty.call(Hh,e)}function Eg(e){return Object.prototype.hasOwnProperty.call(Tg,e)}function Pg(e){return Eg(e)?Xc().resultSchemas[e]:void 0}function kg(e){return Fh(e)?Xc().requestSchemas[e]:void 0}function $g(e){return Vh(e)?Xc().notificationSchemas[e]:void 0}var lv=Object.keys(Dh),uv=Object.keys(Hh);function Wc(e){return e!==null&&typeof e==="object"&&!Array.isArray(e)}function Ra(e,t){if(e===void 0)return{ok:!1,reason:"not-in-era"};let o=e.safeParse(t);return o.success?{ok:!0,value:o.data}:{ok:!1,reason:"invalid",message:String(o.error)}}var Eh={ok:!1,reason:"not-in-era"};function Ph(e){return Wc(e)&&Wc(e.outputSchema)&&Zh(e.outputSchema)}function kh(e){return e}var el={era:"2025-11-25",hasRequestMethod:Fh,hasNotificationMethod:Vh,validateRequest:(e,t)=>Ra(kg(e),t),validateResult:(e,t)=>Ra(Pg(e),t),validateNotification:(e,t)=>Ra($g(e),t),hasInputRequestMethod:()=>!1,validateInputRequest:()=>Eh,validateInputResponse:()=>Eh,samplingResultVariant:(e,t)=>{let o=Uh();return Ra(e?o.CreateMessageResultWithToolsSchema:o.CreateMessageResultSchema,t)},outboundEnvelope:(e)=>{return},validateEnvelopeMeta:(e)=>[],projectCallToolResult(e,t){let o=jh(e),r=o.structuredContent;if(r===void 0)return o;let n=typeof r!=="object"||r===null||Array.isArray(r),i=t!==void 0&&Zh(t);if(!n&&!i)return o;return{...o,structuredContent:{result:r}}},decodeResult(e,t){if(Wc(t)&&"resultType"in t){let o={...t};return delete o.resultType,{kind:"complete",result:kh(o)}}return{kind:"complete",result:kh(t)}},encodeResult(e,t){if(e!=="tools/list")return t;let o=t.tools;if(!Array.isArray(o)||!o.some((r)=>Ph(r)))return t;return{...t,tools:o.map((r)=>Ph(r)?{...r,outputSchema:xg(r.outputSchema)}:r)}},encodeErrorCode:(e)=>e===-32002?-32602:e,checkInboundEnvelope:(e)=>{return}};function Cg(){let e=cn(()=>_([s(),g(),v(),It(),S(s(),e),h(e)])),t=S(s(),e),o=_([s(),g().int()]),r=s(),n=_([s(),g().int()]),i=C(["user","assistant"]),a=C(["debug","info","notice","warning","error","critical","alert","emergency"]),u=s().refine((W)=>{try{return atob(W),!0}catch{return!1}},{message:"Invalid Base64 string"}),d=c({ttl:g().optional()}),p=c({taskId:s()}),f=T({progressToken:o.optional(),"io.modelcontextprotocol/related-task":p.optional()}),b=c({_meta:f.optional()}),y=b.extend({task:d.optional()}),z=c({_meta:f.optional()}),E=c({method:s(),params:z.loose().optional()}),P=c({src:s(),mimeType:s().optional(),sizes:h(s()).optional(),theme:C(["light","dark"]).optional()}),k=c({icons:h(P).optional()}),A=c({name:s(),title:s().optional()}),B=A.extend({...A.shape,...k.shape,version:s(),websiteUrl:s().optional(),description:s().optional()}),q=Ue(c({applyDefaults:v().optional()}),t),M=Ot((W)=>{if(W&&typeof W==="object"&&!Array.isArray(W)&&Object.keys(W).length===0)return{form:{}};return W},Ue(c({form:q.optional(),url:t.optional()}),t.optional())),D=T({list:t.optional(),cancel:t.optional(),requests:T({sampling:T({createMessage:t.optional()}).optional(),elicitation:T({create:t.optional()}).optional()}).optional()}),U=T({list:t.optional(),cancel:t.optional(),requests:T({tools:T({call:t.optional()}).optional()}).optional()}),G=c({experimental:S(s(),t).optional(),sampling:c({context:t.optional(),tools:t.optional()}).optional(),elicitation:M.optional(),roots:c({listChanged:v().optional()}).optional(),tasks:D.optional(),extensions:S(s(),t).optional()}),Ne=c({experimental:S(s(),t).optional(),logging:t.optional(),completions:t.optional(),prompts:c({listChanged:v().optional()}).optional(),resources:c({subscribe:v().optional(),listChanged:v().optional()}).optional(),tools:c({listChanged:v().optional()}).optional(),tasks:U.optional(),extensions:S(s(),t).optional()}),ie=c({progress:g(),total:x(g()),message:x(s())}),Ge=c({...z.shape,...ie.shape,progressToken:o}),mt=E.extend({method:l("notifications/progress"),params:Ge}),Yo=z.extend({level:a,logger:s().optional(),data:R()}),Qo=E.extend({method:l("notifications/message"),params:Yo}),Gt=c({uri:s(),mimeType:x(s()),_meta:S(s(),R()).optional()}),Ye=Gt.extend({text:s()}),ft=Gt.extend({blob:u}),Ee=c({audience:h(i).optional(),priority:g().min(0).max(1).optional(),lastModified:_o({offset:!0}).optional()}),Qe=c({...A.shape,...k.shape,uri:s(),description:x(s()),mimeType:x(s()),size:x(g()),annotations:Ee.optional(),_meta:x(T({}))}),Yt=c({...A.shape,...k.shape,uriTemplate:s(),description:x(s()),mimeType:x(s()),annotations:Ee.optional(),_meta:x(T({}))}),Ae=E.extend({method:l("notifications/resources/list_changed"),params:z.optional()}),je=z.extend({uri:s()}),Qt=E.extend({method:l("notifications/resources/updated"),params:je}),Xt=c({name:s(),description:x(s()),required:x(v())}),gt=c({...A.shape,...k.shape,description:x(s()),arguments:x(h(Xt)),_meta:x(T({}))}),eo=E.extend({method:l("notifications/prompts/list_changed"),params:z.optional()}),Pe=c({type:l("text"),text:s(),annotations:Ee.optional(),_meta:S(s(),R()).optional()}),Re=c({type:l("image"),data:u,mimeType:s(),annotations:Ee.optional(),_meta:S(s(),R()).optional()}),St=c({type:l("audio"),data:u,mimeType:s(),annotations:Ee.optional(),_meta:S(s(),R()).optional()}),Xo=c({type:l("tool_use"),name:s(),id:s(),input:S(s(),R()),_meta:S(s(),R()).optional()}),er=c({type:l("resource"),resource:_([Ye,ft]),annotations:Ee.optional(),_meta:S(s(),R()).optional()}),tr=Qe.extend({type:l("resource_link")}),Xe=_([Pe,Re,St,tr,er]),to=c({role:i,content:Xe}),_t=c({title:s().optional(),readOnlyHint:v().optional(),destructiveHint:v().optional(),idempotentHint:v().optional(),openWorldHint:v().optional()}),or=E.extend({method:l("notifications/tools/list_changed"),params:z.optional()}),rr=c({name:s().optional()}),nr=c({hints:h(rr).optional(),costPriority:g().min(0).max(1).optional(),speedPriority:g().min(0).max(1).optional(),intelligencePriority:g().min(0).max(1).optional()}),sr=c({mode:C(["auto","required","none"]).optional()}),ir=c({type:l("boolean"),title:s().optional(),description:s().optional(),default:v().optional()}),ar=c({type:l("string"),title:s().optional(),description:s().optional(),minLength:g().optional(),maxLength:g().optional(),format:C(["email","uri","date","date-time"]).optional(),default:s().optional()}),cr=c({type:C(["number","integer"]),title:s().optional(),description:s().optional(),minimum:g().optional(),maximum:g().optional(),default:g().optional()}),lr=c({type:l("string"),title:s().optional(),description:s().optional(),enum:h(s()),default:s().optional()}),ur=c({type:l("string"),title:s().optional(),description:s().optional(),oneOf:h(c({const:s(),title:s()})),default:s().optional()}),dr=c({type:l("string"),title:s().optional(),description:s().optional(),enum:h(s()),enumNames:h(s()).optional(),default:s().optional()}),pr=_([lr,ur]),hr=c({type:l("array"),title:s().optional(),description:s().optional(),minItems:g().optional(),maxItems:g().optional(),items:c({type:l("string"),enum:h(s())}),default:h(s()).optional()}),mr=c({type:l("array"),title:s().optional(),description:s().optional(),minItems:g().optional(),maxItems:g().optional(),items:c({anyOf:h(c({const:s(),title:s()}))}),default:h(s()).optional()}),fr=_([hr,mr]),gr=_([dr,pr,fr]),Sr=_([gr,ir,ar,cr]),bt=y.extend({mode:l("form").optional(),message:s(),requestedSchema:c({type:l("object"),properties:S(s(),Sr),required:h(s()).optional()}).catchall(R())}),yt=c({type:l("ref/resource"),uri:s()}),vt=c({type:l("ref/prompt"),name:s()}),_r=c({uri:s().startsWith("file://"),name:s().optional(),_meta:S(s(),R()).optional()}),et=G.shape,br=c({experimental:et.experimental,sampling:et.sampling,elicitation:et.elicitation,roots:et.roots,extensions:et.extensions}),ye=Ne.shape,oo=c({experimental:ye.experimental,logging:ye.logging,completions:ye.completions,prompts:ye.prompts,resources:ye.resources,tools:ye.tools,extensions:ye.extensions}),ro=T({progressToken:o.optional(),[Mt]:s(),[zo]:B.optional(),[qt]:br,[Ro]:a.optional()}),zt=c({...A.shape,...k.shape,description:s().optional(),inputSchema:T({$schema:s().optional(),type:l("object")}),outputSchema:T({$schema:s().optional()}).optional(),annotations:_t.optional(),_meta:S(s(),R()).optional()}),yr=c({type:l("tool_result"),toolUseId:s(),content:h(Xe),structuredContent:R().optional(),isError:v().optional(),_meta:S(s(),R()).optional()}),no=_([Pe,Re,St,Xo,yr]),Rt=c({role:i,content:_([no,h(no)]),_meta:S(s(),R()).optional()}),so=s(),io=T({[lt]:B.optional().catch(void 0)}),ao=io.optional();function re(W){return T({_meta:ao,resultType:so.default("complete"),...W})}let vr=re({}),ii=re({nextCursor:r.optional()}),co=re({content:h(Xe),structuredContent:R().optional(),isError:v().optional()}),zr=re({ttlMs:g().int().min(0),cacheScope:C(["public","private"]),tools:h(zt),nextCursor:r.optional()}),Rr=re({ttlMs:g().int().min(0),cacheScope:C(["public","private"]),prompts:h(gt),nextCursor:r.optional()}),wr=re({description:s().optional(),messages:h(to)}),xr=re({ttlMs:g().int().min(0),cacheScope:C(["public","private"]),resources:h(Qe),nextCursor:r.optional()}),Tr=re({ttlMs:g().int().min(0),cacheScope:C(["public","private"]),resourceTemplates:h(Yt),nextCursor:r.optional()}),Er=re({ttlMs:g().int().min(0),cacheScope:C(["public","private"]),contents:h(_([Ye,ft]))}),Pr=re({completion:c({values:h(s()).max(100),total:g().int().optional(),hasMore:v().optional()}).loose()}),ai=re({ttlMs:g().int().min(0),cacheScope:C(["public","private"])}),kr=re({ttlMs:g().int().min(0).catch(0),cacheScope:C(["public","private"]).catch("private"),supportedVersions:h(s()),capabilities:oo,instructions:s().optional()}),tt=c({messages:h(Rt),modelPreferences:nr.optional(),systemPrompt:s().optional(),includeContext:C(["none","thisServer","allServers"]).optional(),temperature:g().optional(),maxTokens:g().int(),stopSequences:h(s()).optional(),metadata:t.optional(),tools:h(zt).optional(),toolChoice:sr.optional()}),$r=c({method:l("sampling/createMessage"),params:tt}),Cr=c({method:l("roots/list"),params:c({_meta:S(s(),R()).optional()}).optional()}),Ir=c({...Rt.shape,model:s(),stopReason:s().optional()}),Or=c({roots:h(_r)}),Mr=c({action:C(["accept","decline","cancel"]),content:S(s(),_([s(),g(),v(),h(s())])).optional()}),qr=c({mode:l("url"),message:s(),url:s().url()}),Nr=_([bt,qr]),Ar=c({method:l("elicitation/create"),params:Nr}),jr=_([$r,Cr,Ar]),Lr=_([Ir,Or,Mr]),Ur=S(s(),jr),Zr=S(s(),Lr),wt=re({inputRequests:Ur.optional(),requestState:s().optional()}),xt={inputResponses:Zr.optional(),requestState:s().optional()},ci=c({_meta:ro,...xt}),li=T({progressToken:o.optional()});function pe(W,Et){return c({method:l(W),params:c({_meta:ro,...Et})})}function he(W,Et){return c({method:l(W),params:c({_meta:li.optional(),...Et}).optional()})}let Dr={name:s(),arguments:S(s(),R()).optional(),...xt},we={cursor:r.optional()},ui=pe("tools/call",Dr),di=pe("tools/list",we),pi=pe("prompts/list",we),hi=pe("prompts/get",{name:s(),arguments:S(s(),s()).optional(),...xt}),mi=pe("resources/list",we),fi=pe("resources/templates/list",we),gi=pe("resources/read",{uri:s(),...xt}),Hr={ref:_([vt,yt]),argument:c({name:s(),value:s()}),context:c({arguments:S(s(),s()).optional()}).optional()},Si=pe("completion/complete",Hr),_i=pe("server/discover",{}),lo=c({toolsListChanged:v().optional(),promptsListChanged:v().optional(),resourcesListChanged:v().optional(),resourceSubscriptions:h(s()).optional()}),Fr={notifications:lo},bi=pe("subscriptions/listen",Fr),yi=io.extend({"io.modelcontextprotocol/subscriptionId":n}),Vr=T({_meta:yi,resultType:so.default("complete")}),ot={"tools/call":he("tools/call",Dr),"tools/list":he("tools/list",we),"prompts/get":he("prompts/get",{name:s(),arguments:S(s(),s()).optional()}),"prompts/list":he("prompts/list",we),"resources/list":he("resources/list",we),"resources/templates/list":he("resources/templates/list",we),"resources/read":he("resources/read",{uri:s()}),"completion/complete":he("completion/complete",Hr),"server/discover":he("server/discover",{}),"subscriptions/listen":he("subscriptions/listen",Fr)};function de(W){return T({_meta:ao,...W})}let vi={"tools/call":de({content:h(Xe),structuredContent:R().optional(),isError:v().optional()}),"tools/list":de({ttlMs:g().int().min(0),cacheScope:C(["public","private"]),tools:h(zt),nextCursor:r.optional()}),"prompts/get":de({description:s().optional(),messages:h(to)}),"prompts/list":de({ttlMs:g().int().min(0),cacheScope:C(["public","private"]),prompts:h(gt),nextCursor:r.optional()}),"resources/list":de({ttlMs:g().int().min(0),cacheScope:C(["public","private"]),resources:h(Qe),nextCursor:r.optional()}),"resources/templates/list":de({ttlMs:g().int().min(0),cacheScope:C(["public","private"]),resourceTemplates:h(Yt),nextCursor:r.optional()}),"resources/read":de({ttlMs:g().int().min(0),cacheScope:C(["public","private"]),contents:h(_([Ye,ft]))}),"completion/complete":de({completion:c({values:h(s()).max(100),total:g().int().optional(),hasMore:v().optional()}).loose()}),"server/discover":de({ttlMs:g().int().min(0).catch(0),cacheScope:C(["public","private"]).catch("private"),supportedVersions:h(s()),capabilities:oo,instructions:s().optional()}),"subscriptions/listen":de({})},Tt=T({"io.modelcontextprotocol/subscriptionId":n.optional()}),uo=c({method:l("notifications/subscriptions/acknowledged"),params:c({_meta:Tt.optional(),notifications:lo})}),po=c({_meta:Tt.optional(),requestId:n,reason:s().optional()}),ho=c({method:l("notifications/cancelled"),params:po}),$a={"notifications/cancelled":ho,"notifications/progress":mt,"notifications/message":Qo,"notifications/resources/updated":Qt,"notifications/resources/list_changed":Ae,"notifications/tools/list_changed":or,"notifications/prompts/list_changed":eo,"notifications/subscriptions/acknowledged":uo},ae=(W)=>c({jsonrpc:l("2.0"),id:_([s(),g().int()]),result:W}).strict();return{JSONValueSchema:e,JSONObjectSchema:t,ProgressTokenSchema:o,CursorSchema:r,RequestIdSchema:n,RoleSchema:i,LoggingLevelSchema:a,TaskMetadataSchema:d,RelatedTaskMetadataSchema:p,RequestMetaSchema:f,BaseRequestParamsSchema:b,TaskAugmentedRequestParamsSchema:y,NotificationsParamsSchema:z,NotificationSchema:E,IconSchema:P,IconsSchema:k,BaseMetadataSchema:A,ImplementationSchema:B,ClientTasksCapabilitySchema:D,ServerTasksCapabilitySchema:U,ClientCapabilitiesSchema:G,ServerCapabilitiesSchema:Ne,ProgressSchema:ie,ProgressNotificationParamsSchema:Ge,ProgressNotificationSchema:mt,LoggingMessageNotificationParamsSchema:Yo,LoggingMessageNotificationSchema:Qo,ResourceContentsSchema:Gt,TextResourceContentsSchema:Ye,BlobResourceContentsSchema:ft,AnnotationsSchema:Ee,ResourceSchema:Qe,ResourceTemplateSchema:Yt,ResourceListChangedNotificationSchema:Ae,ResourceUpdatedNotificationParamsSchema:je,ResourceUpdatedNotificationSchema:Qt,PromptArgumentSchema:Xt,PromptSchema:gt,PromptListChangedNotificationSchema:eo,TextContentSchema:Pe,ImageContentSchema:Re,AudioContentSchema:St,ToolUseContentSchema:Xo,EmbeddedResourceSchema:er,ResourceLinkSchema:tr,ContentBlockSchema:Xe,PromptMessageSchema:to,ToolAnnotationsSchema:_t,ToolListChangedNotificationSchema:or,ModelHintSchema:rr,ModelPreferencesSchema:nr,ToolChoiceSchema:sr,BooleanSchemaSchema:ir,StringSchemaSchema:ar,NumberSchemaSchema:cr,UntitledSingleSelectEnumSchemaSchema:lr,TitledSingleSelectEnumSchemaSchema:ur,LegacyTitledEnumSchemaSchema:dr,SingleSelectEnumSchemaSchema:pr,UntitledMultiSelectEnumSchemaSchema:hr,TitledMultiSelectEnumSchemaSchema:mr,MultiSelectEnumSchemaSchema:fr,EnumSchemaSchema:gr,PrimitiveSchemaDefinitionSchema:Sr,ElicitRequestFormParamsSchema:bt,ResourceTemplateReferenceSchema:yt,PromptReferenceSchema:vt,RootSchema:_r,ClientCapabilities2026Schema:br,ServerCapabilities2026Schema:oo,RequestMetaEnvelopeSchema:ro,ToolSchema:zt,ToolResultContentSchema:yr,SamplingMessageContentBlockSchema:no,SamplingMessageSchema:Rt,ResultTypeSchema:so,ResultMetaSchema:io,ResultSchema:vr,PaginatedResultSchema:ii,CallToolResultSchema:co,ListToolsResultSchema:zr,ListPromptsResultSchema:Rr,GetPromptResultSchema:wr,ListResourcesResultSchema:xr,ListResourceTemplatesResultSchema:Tr,ReadResourceResultSchema:Er,CompleteResultSchema:Pr,CacheableResultSchema:ai,DiscoverResultSchema:kr,CreateMessageRequestParamsSchema:tt,CreateMessageRequestSchema:$r,ListRootsRequestSchema:Cr,CreateMessageResultSchema:Ir,ListRootsResultSchema:Or,ElicitResultSchema:Mr,ElicitRequestURLParamsSchema:qr,ElicitRequestParamsSchema:Nr,ElicitRequestSchema:Ar,InputRequestSchema:jr,InputResponseSchema:Lr,InputRequestsSchema:Ur,InputResponsesSchema:Zr,InputRequiredResultSchema:wt,InputResponseRequestParamsSchema:ci,CallToolRequestSchema:ui,ListToolsRequestSchema:di,ListPromptsRequestSchema:pi,GetPromptRequestSchema:hi,ListResourcesRequestSchema:mi,ListResourceTemplatesRequestSchema:fi,ReadResourceRequestSchema:gi,CompleteRequestSchema:Si,DiscoverRequestSchema:_i,SubscriptionFilterSchema:lo,SubscriptionsListenRequestSchema:bi,SubscriptionsListenResultMetaSchema:yi,SubscriptionsListenResultSchema:Vr,dispatchRequestSchemas:ot,dispatchResultSchemas:vi,NotificationMetaSchema:Tt,SubscriptionsAcknowledgedNotificationSchema:uo,CancelledNotificationParamsSchema:po,CancelledNotificationSchema:ho,notificationSchemas2026:$a,JSONRPCResultResponseSchema:ae(vr),CallToolResultResponseSchema:ae(_([co,wt])),ListToolsResultResponseSchema:ae(zr),ListPromptsResultResponseSchema:ae(Rr),GetPromptResultResponseSchema:ae(_([wr,wt])),ListResourcesResultResponseSchema:ae(xr),ListResourceTemplatesResultResponseSchema:ae(Tr),ReadResourceResultResponseSchema:ae(_([Er,wt])),CompleteResultResponseSchema:ae(Pr),DiscoverResultResponseSchema:ae(kr),SubscriptionsListenResultResponseSchema:ae(Vr)}}var Ig;function dt(){return Ig??=Cg()}var Og=["tools/list","prompts/list","resources/list","resources/templates/list","resources/read","server/discover"];function Mg(e){return Og.includes(e)}var tl=Symbol("modelcontextprotocol.resultCacheHintFallback");function qg(e){return e[tl]}function Jh(e){return typeof e==="number"&&Number.isSafeInteger(e)&&e>=0}function Bh(e){return e==="public"||e==="private"}var I=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}({}),oe=class e extends Error{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.ProtocolError"})}static[Symbol.hasInstance](t){return _e(this,t)}static isInstance(t){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 _e(this,t)}constructor(t,o,r){super(o);this.code=t,this.data=r,this.name="ProtocolError",Bt(this,new.target)}static fromError(t,o,r){if(t===I.UrlElicitationRequired&&r){let n=r;if(n.elicitations)return new Kh(n.elicitations,o)}if(t===I.UnsupportedProtocolVersion&&r){let n=r;if(Array.isArray(n.supported)&&typeof n.requested==="string")return new Gh({supported:n.supported,requested:n.requested},o)}if(t===I.InvalidParams||t===I.ResourceNotFound){let n=r;if(typeof n?.uri==="string"&&(t===I.ResourceNotFound||Object.keys(n).length===1))return new Wh(n.uri,o)}if(t===I.MissingRequiredClientCapability&&r){let n=r;if(n.requiredCapabilities!==null&&typeof n.requiredCapabilities==="object"&&!Array.isArray(n.requiredCapabilities))return new Yh({requiredCapabilities:n.requiredCapabilities},o)}return new e(t,o,r)}},Wh=class extends oe{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.ResourceNotFoundError"})}constructor(e,t=`Resource not found: ${e}`){super(I.InvalidParams,t,{uri:e})}get uri(){return this.data.uri}},Kh=class extends oe{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.UrlElicitationRequiredError"})}constructor(e,t=`URL elicitation${e.length>1?"s":""} required`){super(I.UrlElicitationRequired,t,{elicitations:e})}get elicitations(){return this.data?.elicitations??[]}},Gh=class extends oe{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.UnsupportedProtocolVersionError"})}constructor(e,t=`Unsupported protocol version: ${e.requested}`){super(I.UnsupportedProtocolVersion,t,e)}get supported(){return this.data.supported}get requested(){return this.data.requested}},Yh=class extends oe{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.MissingRequiredClientCapabilityError"})}constructor(e,t=`Missing required client capabilities: ${Object.keys(e.requiredCapabilities).join(", ")}`){super(I.MissingRequiredClientCapability,t,e)}get requiredCapabilities(){return this.data.requiredCapabilities}},Ng=0,Ag="private",jg=["tools/call","prompts/get","resources/read"];function Lg(e,t){let o=t.resultType;if(o===void 0)return{...t,resultType:"complete"};if(o==="complete")return t;if(jg.includes(e))return t;throw new oe(I.InternalError,`Handler for ${e} returned resultType '${String(o)}', but results of ${e} only support 'complete' on protocol revision 2026-07-28`)}function Ug(e,t){let o=qg(t);if(t.resultType!=="complete"||!Mg(e))return o===void 0?t:Vg(t);let r=t,n=Jh(r.ttlMs)?r.ttlMs:Hg(o),i=Bh(r.cacheScope)?r.cacheScope:Fg(o),a={...r,ttlMs:n,cacheScope:i};return delete a[tl],a}function Zg(e){return e!==null&&typeof e==="object"&&!Array.isArray(e)}function Dg(e,t){if(t===void 0)return e;let o=e._meta;if(o===void 0)return{...e,_meta:{[lt]:t}};if(!Zg(o))return e;if(o[lt]!==void 0)return e;return{...e,_meta:{...o,[lt]:t}}}function Hg(e){return e!==void 0&&Jh(e.ttlMs)?e.ttlMs:Ng}function Fg(e){return e!==void 0&&Bh(e.cacheScope)?e.cacheScope:Ag}function Vg(e){let t={...e};return delete t[tl],t}var Jg=["elicitation/create","sampling/createMessage","roots/list"],wa;function Qh(){if(wa)return wa;let e=dt();return wa={request:{"elicitation/create":c({method:l("elicitation/create"),params:e.ElicitRequestParamsSchema}),"sampling/createMessage":c({method:l("sampling/createMessage"),params:e.CreateMessageRequestParamsSchema}),"roots/list":c({method:l("roots/list"),params:T({}).optional()})},response:{"elicitation/create":e.ElicitResultSchema,"sampling/createMessage":e.CreateMessageResultSchema,"roots/list":e.ListRootsResultSchema}},wa}function Xh(e){return Jg.includes(e)}function Dc(e){return Xh(e)?Qh().request[e]:void 0}function Bg(e){return Xh(e)?Qh().response[e]:void 0}var ol={"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},em={"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 tm(e){return Object.prototype.hasOwnProperty.call(ol,e)}function om(e){return Object.prototype.hasOwnProperty.call(em,e)}function Wg(e){return Object.prototype.hasOwnProperty.call(ol,e)}function Kg(e){return tm(e)?dt().dispatchRequestSchemas[e]:void 0}function Gg(e){return Wg(e)?dt().dispatchResultSchemas[e]:void 0}function Yg(e){return om(e)?dt().notificationSchemas2026[e]:void 0}var dv=Object.keys(ol),pv=Object.keys(em);function Gs(e){return e!==null&&typeof e==="object"&&!Array.isArray(e)}function Ws(e,t){if(e===void 0)return{ok:!1,reason:"not-in-era"};let o=e.safeParse(t);return o.success?{ok:!0,value:o.data}:{ok:!1,reason:"invalid",message:String(o.error)}}var Qg={ok:!1,reason:"not-in-era"},Xg=[Mt,qt];function eS(e,t){let o=t,r=!1,n=()=>{if(!r)o={...o},r=!0;return o},i=t.tools;if(e==="tools/list"&&Array.isArray(i)&&i.some((u)=>Gs(u)&&("execution"in u)))n().tools=i.map((u)=>{if(!Gs(u)||!("execution"in u))return u;let d={...u};return delete d.execution,d});let a=t.capabilities;if(Gs(a)&&"tasks"in a){let u={...a};delete u.tasks,n().capabilities=u}return o}var rl={era:"2026-07-28",hasRequestMethod:tm,hasNotificationMethod:om,hasInputRequestMethod:(e)=>Dc(e)!==void 0,validateRequest:(e,t)=>Ws(Kg(e),t),validateResult:(e,t)=>Ws(Gg(e),t),validateNotification:(e,t)=>Ws(Yg(e),t),validateInputRequest:(e,t)=>Ws(Dc(e),t),validateInputResponse:(e,t)=>Ws(Bg(e),t),samplingResultVariant:()=>Qg,outboundEnvelope(e){return{[Mt]:e.protocolVersion,[zo]:e.clientInfo,[qt]:e.clientCapabilities,...e.logLevel!==void 0&&{[Ro]:e.logLevel}}},validateEnvelopeMeta(e){let t=[];for(let r of Xg)if(!(r in e))t.push({key:r,problem:"missing"});let o=dt().RequestMetaEnvelopeSchema.safeParse(e);if(!o.success)for(let r of o.error.issues){let n=r.path.map(String),i=n.length>0?n.join("."):"_meta";if(n.length===1&&t.some((a)=>a.key===i&&a.problem==="missing"))continue;t.push({key:i,problem:r.message})}return t},projectCallToolResult:(e)=>jh(e),inputRequestSchema:Dc,decodeResult(e,t){if(!Gs(t))return{kind:"invalid",error:new K(te.InvalidResult,`Invalid result for ${e}: not an object`,{method:e})};let o=t.resultType;if(o===void 0)return{kind:"invalid",error:new K(te.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 o!=="string")return{kind:"invalid",error:new K(te.InvalidResult,`Invalid result for ${e}: non-string resultType`,{method:e,resultType:o})};if(o==="input_required"){let a=t.inputRequests,u=Gs(a)?a:{},d=t.requestState,p=t._meta===void 0?void 0:dt().ResultMetaSchema.safeParse(t._meta),f=p?.success?p.data:void 0;if(Object.keys(u).length===0&&typeof d!=="string")return{kind:"invalid",error:new K(te.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"})};return{kind:"input_required",inputRequests:u,...typeof d==="string"&&{requestState:d},...f!==void 0&&{_meta:f}}}if(o!=="complete")return{kind:"invalid",error:new K(te.UnsupportedResultType,`Unsupported result type '${o}' for ${e}`,{resultType:o,method:e})};let r=tS(),n=Object.hasOwn(r,e)?r[e]:void 0;if(n!==void 0){let a=n.safeParse(t);if(!a.success)return{kind:"invalid",error:new K(te.InvalidResult,`Invalid result for ${e}: ${a.error}`,{method:e})}}let i={...t};return delete i.resultType,{kind:"complete",result:i}},encodeResult(e,t,o){return Dg(Ug(e,Lg(e,eS(e,t))),o)},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=dt().RequestMetaEnvelopeSchema.safeParse(e.envelope);if(!t.success)return`Invalid _meta envelope for protocol revision 2026-07-28: ${t.error.issues.map((o)=>o.message).join("; ")}`}},xa;function tS(){if(xa)return xa;let e=dt();return xa={"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},xa}var nl="2026-07-28";function Qs(e){return e!==void 0&&Ah(e)?rl:el}function $h(e){if(e.revision!==void 0)return Qs(e.revision).era;return e.era==="modern"?rl.era:el.era}function Hc(e){return rm.some((t)=>t.hasRequestMethod(e))}function Fc(e){return rm.some((t)=>t.hasNotificationMethod(e))}function Ch(e){return e==="tasks/get"||e==="tasks/cancel"}var rm=[el,rl],oS=Sl({AnnotationsSchema:()=>Ie,AudioContentSchema:()=>Dt,BaseMetadataSchema:()=>$e,BaseRequestParamsSchema:()=>Q,BlobResourceContentsSchema:()=>Ao,BooleanSchemaSchema:()=>Zo,CallToolRequestParamsSchema:()=>rs,CallToolRequestSchema:()=>ns,CallToolResultSchema:()=>Me,CancelTaskRequestSchema:()=>pa,CancelTaskResultSchema:()=>ha,CancelledNotificationParamsSchema:()=>dn,CancelledNotificationSchema:()=>$o,ClientCapabilitiesSchema:()=>hn,ClientNotificationSchema:()=>fa,ClientRequestSchema:()=>ma,ClientResultSchema:()=>ga,ClientTasksCapabilitySchema:()=>Xi,CompatibilityCallToolResultSchema:()=>ta,CompleteRequestParamsSchema:()=>$s,CompleteRequestSchema:()=>Cs,CompleteResultSchema:()=>Is,ContentBlockSchema:()=>Se,CreateMessageRequestParamsSchema:()=>fs,CreateMessageRequestSchema:()=>gs,CreateMessageResultSchema:()=>Ss,CreateMessageResultWithToolsSchema:()=>_s,CreateTaskResultSchema:()=>na,CursorSchema:()=>xo,DiscoverRequestSchema:()=>_n,DiscoverResultSchema:()=>Io,ElicitRequestFormParamsSchema:()=>Jt,ElicitRequestParamsSchema:()=>Rs,ElicitRequestSchema:()=>ws,ElicitRequestURLParamsSchema:()=>zs,ElicitResultSchema:()=>Es,ElicitationCompleteNotificationParamsSchema:()=>xs,ElicitationCompleteNotificationSchema:()=>Ts,EmbeddedResourceSchema:()=>Be,EmptyResultSchema:()=>Ce,EnumSchemaSchema:()=>vs,GetPromptRequestParamsSchema:()=>Bn,GetPromptRequestSchema:()=>Wn,GetPromptResultSchema:()=>Yn,GetTaskPayloadRequestSchema:()=>ca,GetTaskPayloadResultSchema:()=>la,GetTaskRequestSchema:()=>ia,GetTaskResultSchema:()=>aa,IconSchema:()=>pn,IconsSchema:()=>He,ImageContentSchema:()=>Zt,ImplementationSchema:()=>ge,InitializeRequestParamsSchema:()=>mn,InitializeRequestSchema:()=>fn,InitializeResultSchema:()=>gn,InitializedNotificationSchema:()=>Sn,JSONArraySchema:()=>Yi,JSONObjectSchema:()=>F,JSONRPCErrorResponseSchema:()=>jt,JSONRPCMessageSchema:()=>De,JSONRPCNotificationSchema:()=>ko,JSONRPCRequestSchema:()=>Po,JSONRPCResponseSchema:()=>Qi,JSONRPCResultResponseSchema:()=>At,JSONValueSchema:()=>Ze,LegacyTitledEnumSchemaSchema:()=>Fo,ListChangedOptionsBaseSchema:()=>oa,ListPromptsRequestSchema:()=>Vn,ListPromptsResultSchema:()=>Jn,ListResourceTemplatesRequestSchema:()=>xn,ListResourceTemplatesResultSchema:()=>Tn,ListResourcesRequestSchema:()=>Rn,ListResourcesResultSchema:()=>wn,ListRootsRequestSchema:()=>Ms,ListRootsResultSchema:()=>qs,ListTasksRequestSchema:()=>ua,ListTasksResultSchema:()=>da,ListToolsRequestSchema:()=>ts,ListToolsResultSchema:()=>os,LoggingLevelSchema:()=>Uo,LoggingMessageNotificationParamsSchema:()=>cs,LoggingMessageNotificationSchema:()=>Ht,ModelHintSchema:()=>ls,ModelPreferencesSchema:()=>us,MultiSelectEnumSchemaSchema:()=>ys,NotificationSchema:()=>ee,NotificationsParamsSchema:()=>se,NumberSchemaSchema:()=>Vt,PaginatedRequestParamsSchema:()=>vn,PaginatedRequestSchema:()=>Fe,PaginatedResultSchema:()=>Ve,PingRequestSchema:()=>Oo,PrimitiveSchemaDefinitionSchema:()=>Bo,ProgressNotificationParamsSchema:()=>yn,ProgressNotificationSchema:()=>Mo,ProgressSchema:()=>bn,ProgressTokenSchema:()=>wo,PromptArgumentSchema:()=>Hn,PromptListChangedNotificationSchema:()=>Qn,PromptMessageSchema:()=>Gn,PromptReferenceSchema:()=>ks,PromptSchema:()=>Fn,ReadResourceRequestParamsSchema:()=>En,ReadResourceRequestSchema:()=>Pn,ReadResourceResultSchema:()=>kn,RelatedTaskMetadataSchema:()=>un,RequestIdSchema:()=>fe,RequestMetaSchema:()=>To,RequestSchema:()=>V,ResourceContentsSchema:()=>qo,ResourceLinkSchema:()=>We,ResourceListChangedNotificationSchema:()=>$n,ResourceRequestParamsSchema:()=>Lt,ResourceSchema:()=>jo,ResourceTemplateReferenceSchema:()=>Ps,ResourceTemplateSchema:()=>zn,ResourceUpdatedNotificationParamsSchema:()=>Zn,ResourceUpdatedNotificationSchema:()=>Dn,ResultMetaObjectSchema:()=>Eo,ResultSchema:()=>J,RoleSchema:()=>Je,RootSchema:()=>Os,RootsListChangedNotificationSchema:()=>Ns,SamplingContentSchema:()=>hs,SamplingMessageContentBlockSchema:()=>ct,SamplingMessageSchema:()=>ms,ServerCapabilitiesSchema:()=>Co,ServerNotificationSchema:()=>_a,ServerRequestSchema:()=>Sa,ServerResultSchema:()=>ba,ServerTasksCapabilitySchema:()=>ea,SetLevelRequestParamsSchema:()=>is,SetLevelRequestSchema:()=>as,SingleSelectEnumSchemaSchema:()=>bs,StringSchemaSchema:()=>Ft,SubscribeRequestParamsSchema:()=>Cn,SubscribeRequestSchema:()=>In,SubscriptionFilterSchema:()=>Lo,SubscriptionsAcknowledgedNotificationParamsSchema:()=>An,SubscriptionsAcknowledgedNotificationSchema:()=>jn,SubscriptionsListenRequestParamsSchema:()=>qn,SubscriptionsListenRequestSchema:()=>Nn,SubscriptionsListenResultMetaSchema:()=>Ln,SubscriptionsListenResultSchema:()=>Un,TaskAugmentedRequestParamsSchema:()=>ut,TaskCreationParamsSchema:()=>ra,TaskMetadataSchema:()=>ln,TaskSchema:()=>Ke,TaskStatusNotificationParamsSchema:()=>js,TaskStatusNotificationSchema:()=>sa,TaskStatusSchema:()=>As,TextContentSchema:()=>Ut,TextResourceContentsSchema:()=>No,TitledMultiSelectEnumSchemaSchema:()=>Jo,TitledSingleSelectEnumSchemaSchema:()=>Ho,ToolAnnotationsSchema:()=>Xn,ToolChoiceSchema:()=>ds,ToolExecutionSchema:()=>es,ToolListChangedNotificationSchema:()=>ss,ToolResultContentSchema:()=>ps,ToolSchema:()=>Oe,ToolUseContentSchema:()=>Kn,UnsubscribeRequestParamsSchema:()=>On,UnsubscribeRequestSchema:()=>Mn,UntitledMultiSelectEnumSchemaSchema:()=>Vo,UntitledSingleSelectEnumSchemaSchema:()=>Do});var nm=(e)=>Po.safeParse(e).success,sm=(e)=>ko.safeParse(e).success,Kc=(e)=>At.safeParse(e).success,im=(e)=>jt.safeParse(e).success;var Ys=-32020,hv=[{rung:"http-method",order:1,evaluatedAt:"edge",codes:[-32000],conformance:[],rationale:"The modern era is POST-only; GET/DELETE are body-less 2025-era session operations and are method-routed to legacy serving (405 when legacy serving is not configured), before any body is read."},{rung:"jsonrpc-shape",order:2,evaluatedAt:"edge",codes:[I.InvalidRequest],conformance:["server-stateless"],rationale:"The body must be a JSON-RPC request or notification: posted responses and batch arrays containing a modern or invalid element are rejected before classification (element-wise batch rule); all-legacy arrays stay legacy traffic."},{rung:"era-classification",order:3,evaluatedAt:"edge",codes:[Ys,I.UnsupportedProtocolVersion],conformance:["server-stateless","http-header-validation","http-custom-header-server-validation"],rationale:"Body-primary era classification with the protocol-version header as a cross-check; a header/body disagreement is rejected with -32020 (HeaderMismatch), and an envelope-less request on a modern-only endpoint is answered with the unsupported-protocol-version error naming the supported revisions."},{rung:"envelope",order:4,evaluatedAt:"edge",codes:[I.InvalidParams],conformance:["server-stateless"],rationale:"A present envelope claim with a malformed envelope — and a missing envelope on a request whose protocol-version header names a modern revision — is an invalid-params rejection naming the offending or missing key(s); never a silent fall back to legacy handling. This is the only place an invalid-params rejection maps to HTTP 400."},{rung:"method-registry",order:5,evaluatedAt:"dispatch",codes:[I.MethodNotFound],conformance:["server-stateless"],rationale:"Method existence outranks parameter validity: a method absent from the negotiated revision’s registry (or with no handler installed) answers method-not-found before params or capabilities are looked at."},{rung:"request-params",order:6,evaluatedAt:"dispatch",codes:[I.InvalidParams],conformance:[],rationale:"Per-method params validation; emitted in-band by the dispatch layer (HTTP 200), never via the ladder status table."},{rung:"standard-header-validation",order:7,evaluatedAt:"pre-dispatch",codes:[Ys],conformance:["http-header-validation"],rationale:"SEP-2243 standard `MCP-Protocol-Version` / `Mcp-Method` / `Mcp-Name` headers — presence, sentinel decoding, and `Mcp-Name` ↔ body cross-check — are validated by the HTTP entry on a modern-classified request after the supported-revision gate and before dispatch. The spec requires `MCP-Protocol-Version` and `Mcp-Method` on every modern *request* POST (`Mcp-Name` only for the methods that mirror `params.name` / `params.uri` / `params.taskId`, see `MCP_NAME_HEADER_SOURCE`) and names them in that order, so a request missing several is answered by the earliest. Notification POSTs are exempt: the presence half runs on requests only, so a modern-enveloped notification is dispatched even with no standard headers at all. The classifier’s own header-mismatch cells (protocol-version, `Mcp-Method` mismatch) stay on the edge `era-classification` rung; this rung carries the entry-layer presence/`Mcp-Name` half — including the missing `MCP-Protocol-Version` cell, which cannot live on the edge rung without breaking body-primary classification. Evaluated before the capability gate, the factory call, and the `Mcp-Param-*` rung so a request that fails several rungs is answered by the standard-header rung first. The documented order (after method-registry 5 and request-params 6) is NOT the observed precedence: serveModern evaluates this rung immediately after the supported-revision gate, so a request that also fails a dispatch rung is answered here before the dispatch rungs (5–6) are consulted."},{rung:"client-capabilities",order:8,evaluatedAt:"pre-dispatch",codes:[I.MissingRequiredClientCapability],conformance:["server-stateless"],rationale:"The capability requirement is checked by the HTTP entry, pre-dispatch, against the validated envelope the classifier produced — pinning the spec-mandated HTTP 400 independently of how dispatch- and handler-produced errors are mapped. The documented order (after method resolution and params validation) is preserved observably only while the requirement table is empty: once a served method gains a requirement entry, a request that is missing the capability and would also fail a dispatch rung is answered by this gate first, so the entry must consult the method registry before the gate if the documented precedence is to stay observable."},{rung:"param-header-validation",order:9,evaluatedAt:"pre-dispatch",codes:[Ys],conformance:["http-custom-header-server-validation"],rationale:"SEP-2243 `Mcp-Param-*` headers are validated against the named tool’s `x-mcp-header` declarations and the body `arguments` after the tool registry is known and before dispatch reaches the handler; a missing/disagreeing/malformed header is rejected 400 / -32020 with the same shape as the standard-header cross-checks. The documented order (after method resolution and params validation) is preserved observably only when the body `arguments` would otherwise validate: the check runs pre-dispatch, so a `tools/call` that fails BOTH this rung and a dispatch-time rung (e.g. order-6 `request-params`, -32602) is answered by this gate first with 400 / -32020, not by the earlier-ordered rung."}],mv={[I.ParseError]:400,[I.InvalidRequest]:400,[I.MethodNotFound]:404,[I.UnsupportedProtocolVersion]:400,[I.MissingRequiredClientCapability]:400,[Ys]:400};function sl(e,t){return Di(e,t)}function Ks(e){return new Set(e.flatMap((t)=>Object.keys(t.shape)))}function Gc(e){if(e==null)return!1;let t=typeof e;if(t!=="object"&&t!=="function")return!1;if(!("~standard"in e))return!1;return typeof e["~standard"]?.validate==="function"}var Ih=!1,Yc="draft-2020-12";function rS(e,t="input"){let o=e["~standard"],r;if(o.jsonSchema)r=o.jsonSchema[t]({target:Yc});else if(o.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().");if(!Ih)Ih=!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=Ui(e,{target:Yc,io:t})}else throw Error(`Schema library "${o.vendor}" does not implement StandardJSONSchemaV1 (\`~standard.jsonSchema\`). Upgrade to a version that does, or wrap your JSON Schema with fromJsonSchema().`);if(t==="output"){if(r.type!==void 0)return r;return am(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 am(e){if("properties"in e||"patternProperties"in e||"additionalProperties"in e||"required"in e)return!0;for(let t of["oneOf","anyOf","allOf"]){let o=e[t];if(Array.isArray(o)&&o.length>0)return o.every((r)=>r!==null&&typeof r==="object"&&(r.type==="object"||am(r)))}return!1}function nS(e){if(!e.path?.length)return e.message;return`${e.path.map((t)=>String(typeof t==="object"?t.key:t)).join(".")}: ${e.message}`}async function Vc(e,t){let o=await e["~standard"].validate(t);if(o.issues&&o.issues.length>0)return{success:!1,error:o.issues.map((r)=>nS(r)).join(", ")};return{success:!0,data:o.value}}function sS(e){let t=Ui(e,{target:Yc,io:"input"});return typeof t.pattern==="string"?t.pattern:void 0}var iS=/\\\.\\d\{(\d+)\}/;function aS(e){let t=iS.exec(e),o=[void 0,-1,0];if(t)o.push(Number(t[1]));return[!1,!0].flatMap((r)=>[!1,!0].flatMap((n)=>o.map((i)=>_o({local:r,offset:n,precision:i}))))}function cS(e,t){let o;switch(e){case"email":o=[sh()];break;case"uri":o=[Fi()];break;case"date":o=[jc()];break;case"date-time":o=aS(t);break}return new Set(o.map((r)=>sS(r)).filter((r)=>r!==void 0))}function lS(e,t,o){if(o!=="zod")return!0;return cS(e,t).has(t)}function Xs(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}function uS(e){try{return rS(e,"input")}catch(t){let o=t instanceof Error?t.message:String(t);throw new oe(I.InvalidParams,`Elicitation requestedSchema must describe an object with flat primitive properties: ${o}`)}}var dS=new Set(["$comment","deprecated","description","examples","readOnly","title","writeOnly"]);function il(e){return dS.has(e)||e.startsWith("x-")}var pS=new Set(["$schema",...Object.keys(Jt.shape.requestedSchema.shape)]),Oh={string:Ks([Ft,Do,Ho,Fo]),number:Ks([Vt]),integer:Ks([Vt]),boolean:Ks([Zo]),array:Ks([Vo,Jo])},hS=new Set(Ft.shape.format.unwrap().options);function mS(e,t,o,r){if(!Xs(e))return e;let n=typeof e.type==="string"&&Object.hasOwn(Oh,e.type)?Oh[e.type]:void 0;if(n===void 0)return e;let i={};for(let[a,u]of Object.entries(e))if(n.has(a)||il(a))i[a]=u;else if(a==="pattern"&&e.type==="string"&&typeof e.format==="string"){if(!hS.has(e.format))i[a]=u;else if(typeof u!=="string"||!lS(e.format,u,o))r.push(`${t}.${a}`)}else r.push(`${t}.${a}`);return i}function fS(e,t){let o={},r=[];for(let[n,i]of Object.entries(e))if(n==="properties"&&Xs(i))o[n]=Object.fromEntries(Object.entries(i).map(([a,u])=>[a,mS(u,`properties.${a}`,t,r)]));else if(pS.has(n))o[n]=i;else if(!il(n))r.push(n);if(r.length>0)throw new oe(I.InvalidParams,`Elicitation requestedSchema contains unsupported JSON Schema constraint(s) after Standard Schema conversion: ${r.join(", ")}`);return o}function gS(e,t){if(!Xs(e.properties))return t;let o=Object.entries(e.properties).filter(([,r])=>!sl(Bo,r).success).map(([r])=>`properties.${r}`);return o.length>0?o.join(", "):t}function Qc(e,t,o=""){if(Array.isArray(e)&&Array.isArray(t))return e.flatMap((r,n)=>Qc(r,t[n],`${o}[${n}]`));if(!Xs(e)||!Xs(t))return[];return Object.entries(e).flatMap(([r,n])=>{let i=o?`${o}.${r}`:r;if(!Object.prototype.hasOwnProperty.call(t,r))return il(r)?[]:[i];return Qc(n,t[r],i)})}function SS(e){if(!Gc(e.requestedSchema))return{...e,mode:"form",requestedSchema:e.requestedSchema};let t=e.requestedSchema["~standard"].vendor,o=fS(uS(e.requestedSchema),t),r=sl(Jt.shape.requestedSchema,o);if(!r.success)throw new oe(I.InvalidParams,`Elicitation requestedSchema only supports flat primitive properties (string, number, integer, boolean, and string enums): ${gS(o,r.error.message)}`);let n=Qc(o,r.data);if(n.length>0)throw new oe(I.InvalidParams,`Elicitation requestedSchema contains unsupported JSON Schema constraint(s) after Standard Schema conversion: ${n.join(", ")}`);let i=(r.data.required??[]).filter((a)=>!Object.prototype.hasOwnProperty.call(r.data.properties,a));if(i.length>0)throw new oe(I.InvalidParams,`Elicitation requestedSchema lists required properties that are not defined in properties: ${i.join(", ")}`);return{...e,mode:"form",requestedSchema:r.data}}function _S(e){let t=e.inputRequests!==void 0&&Object.keys(e.inputRequests).length>0,o=typeof e.requestState==="string";if(!t&&!o)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}}}var fv=Object.assign(_S,{elicit(e){try{return{method:"elicitation/create",params:SS(e)}}catch(t){throw t instanceof oe?TypeError(t.message,{cause:t}):t}},elicitUrl(e){return{method:"elicitation/create",params:{...e,mode:"url"}}},createMessage(e){return{method:"sampling/createMessage",params:e}},listRoots(){return{method:"roots/list"}}});var bS=["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"],yS={IdJagTokenExchangeResponseSchema:Hs,OAuthClientInformationFullSchema:Bs,OAuthClientInformationSchema:Js,OAuthClientMetadataSchema:Vs,OAuthClientRegistrationErrorSchema:ya,OAuthErrorResponseSchema:Fs,OAuthMetadataSchema:Wo,OAuthProtectedResourceMetadataSchema:Ls,OAuthTokenRevocationRequestSchema:va,OAuthTokensSchema:Ds,OpenIdProviderDiscoveryMetadataSchema:Zs,OpenIdProviderMetadataSchema:Us},cm={},lm={};function um(e,t){let o=e.slice(0,-6);cm[o]=t,lm[o]=(r)=>t.safeParse(r).success}for(let e of bS)um(e,oS[e]);for(let[e,t]of Object.entries(yS))um(e,t);var vS=Object.freeze(cm),zS=Object.freeze(lm);function RS(e){switch(e){case"initialize":case"notifications/initialized":return Qs(void 0);case"server/discover":return Qs(nl);default:return}}var dm=60000,wS=[Mt,zo,qt,Ro],xS=["inputResponses","requestState"];function Mh(e,t){let o=e.params;if(!Jc(o))return{message:e,lifted:{}};let r=o._meta,n=Jc(r)?wS.filter((d)=>(d in r)):[],i=t==="request"?xS.filter((d)=>(d in o)):[];if(n.length===0&&i.length===0)return{message:e,lifted:{}};let a={},u={...o};if(n.length>0&&Jc(r)){let d={},p={...r};for(let f of n)d[f]=r[f],delete p[f];if(a.envelope=d,Object.keys(p).length>0)u._meta=p;else delete u._meta}for(let d of i){if(d==="inputResponses")a.inputResponses=u[d];if(d==="requestState")a.requestState=u[d];delete u[d]}return{message:{...e,params:u},lifted:a}}function qh(e,t){let o=e.validateResult(t,void 0);if(!o.ok&&o.reason==="not-in-era")return;return{"~standard":{version:1,vendor:"mcp-wire-codec",validate(r){let n=e.validateResult(t,r);if(n.ok)return{value:n.value};return{issues:[{message:n.reason==="invalid"?n.message:`not-in-era: ${t}`}]}}}}}function pm(e){return()=>e}var TS=pm(void 0),ES,ei=class{_transport;_requestMessageId=0;_requestHandlers=new Map;_customSchemaRequestMethods=new Set;_requestHandlerAbortControllers=new Map;_notificationHandlers=new Map;_responseHandlers=new Map;_progressHandlers=new Map;_timeoutInfo=new Map;_pendingDebouncedNotifications=new Set;_negotiatedProtocolVersion;static{ES=(e,t)=>{e._negotiatedProtocolVersion=t}}_supportedProtocolVersions;onclose;onerror;fallbackRequestHandler;fallbackNotificationHandler;constructor(e){this._options=e,this._supportedProtocolVersions=e?.supportedProtocolVersions??Wi,this.setNotificationHandler("notifications/cancelled",(t)=>{this._oncancel(t)}),this.setNotificationHandler("notifications/progress",(t)=>{this._onprogress(t)}),this.setRequestHandler("ping",(t)=>({}))}_shouldDropInbound(e){}_outboundMetaEnvelope(){}_envelopeOutbound(e){let t=this._outboundMetaEnvelope();if(t===void 0)return e;let o=e.params??{};return{...e,params:{...o,_meta:{...t,...o._meta}}}}_resolveNonCompleteResult(e,t){return Promise.reject(new K(te.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){if(e.params.requestId===void 0)return;this._requestHandlerAbortControllers.get(e.params.requestId)?.abort(e.params.reason)}_setupTimeout(e,t,o,r,n=!1){this._timeoutInfo.set(e,{timeoutId:setTimeout(r,t),startTime:Date.now(),timeout:t,maxTotalTimeout:o,resetTimeoutOnProgress:n,onTimeout:r})}_resetTimeout(e){let t=this._timeoutInfo.get(e);if(!t)return!1;let o=Date.now()-t.startTime;if(t.maxTotalTimeout&&o>=t.maxTotalTimeout)throw this._timeoutInfo.delete(e),new K(te.RequestTimeout,"Maximum total timeout exceeded",{maxTotalTimeout:t.maxTotalTimeout,totalElapsed:o});return clearTimeout(t.timeoutId),t.timeoutId=setTimeout(t.onTimeout,t.timeout),!0}_cleanupTimeout(e){let t=this._timeoutInfo.get(e);if(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 o=this.transport?.onerror;this._transport.onerror=(n)=>{o?.(n),this._onerror(n)};let r=this._transport?.onmessage;this._transport.onmessage=(n,i)=>{if(r?.(n,i),Kc(n)||im(n))this._onresponse(n);else if(nm(n))this._onrequest(n,i);else if(sm(n))this._onnotification(n,i);else this._onerror(Error(`Unknown message type: ${JSON.stringify(n)}`))},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 r of this._timeoutInfo.values())clearTimeout(r.timeoutId);this._timeoutInfo.clear();let t=this._requestHandlerAbortControllers;this._requestHandlerAbortControllers=new Map;let o=new K(te.ConnectionClosed,"Connection closed");this._transport=void 0;try{this.onclose?.()}finally{for(let r of e.values())r(o);for(let r of t.values())r.abort(o)}}_onerror(e){this.onerror?.(e)}_onnotification(e,t){let{message:o}=Mh(e,"notification"),r=this._negotiatedWireCodec();if(t?.classification===void 0&&this._shouldDropInbound(e)==="drop")return;if(t?.classification!==void 0){let a=$h(t.classification);if(a!==r.era){this._onerror(Error(`Era mismatch on inbound notification '${o.method}': classified as ${a} but this instance serves ${r.era}`));return}}if(Fc(o.method)&&!r.hasNotificationMethod(o.method))return;let n=this._notificationHandlers.get(o.method),i=this.fallbackNotificationHandler;if(n===void 0&&i===void 0)return;Promise.resolve().then(()=>n===void 0?i(o):n(o,r)).catch((a)=>this._onerror(Error(`Uncaught error in notification handler: ${a}`)))}_onrequest(e,t){let{message:o,lifted:r}=Mh(e,"request"),n=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 i=this._transport,a=(P,k,A)=>{let B={jsonrpc:"2.0",id:o.id,error:{code:P,message:k,...A!==void 0&&{data:A}}};i?.send(B).catch((q)=>this._onerror(Error(`Failed to send an error response: ${q}`)))};if(t?.classification!==void 0){let P=$h(t.classification);if(P!==n.era){this._onerror(Error(`Era mismatch on inbound request '${o.method}': classified as ${P} but this instance serves ${n.era}`));let k=t.classification.revision??P;a(I.UnsupportedProtocolVersion,`Unsupported protocol version: ${k}`,{supported:this._supportedProtocolVersions,requested:k});return}}if(Hc(o.method)&&!n.hasRequestMethod(o.method)&&!(Ch(o.method)&&this._customSchemaRequestMethods.has(o.method))){a(I.MethodNotFound,"Method not found");return}let u=this._requestHandlers.get(o.method)??this.fallbackRequestHandler;if(u===void 0){a(I.MethodNotFound,"Method not found");return}let d=n.checkInboundEnvelope(r);if(d!==void 0){a(I.InvalidParams,d);return}let p=(P,k)=>this._notificationViaCodec(this._resolveOutboundCodec(P.method),P,{...k,relatedRequestId:o.id}),f=(P,k,A)=>this._requestWithSchemaViaCodec(this._resolveOutboundCodec(P.method),P,k,{...A,relatedRequestId:o.id}),b=new AbortController;this._requestHandlerAbortControllers.set(o.id,b);let y=r.inputResponses===void 0?void 0:PS(r.inputResponses),z={sessionId:i?.sessionId,mcpReq:{id:o.id,method:o.method,_meta:o.params?._meta,...r.envelope!==void 0&&{envelope:r.envelope},...y!==void 0&&{inputResponses:y.accepted},...y!==void 0&&y.droppedKeys.length>0&&{droppedInputResponseKeys:y.droppedKeys},requestState:r.requestState===void 0?TS:pm(r.requestState),signal:b.signal,send:(P,k,A)=>{let B=this._resolveOutboundCodec(P.method);if(this._assertOutboundRequestInEra(B,P.method),Gc(k))return f(P,k,A);let q=qh(B,P.method);if(q===void 0)throw TypeError(`'${P.method}' is not a spec method; pass a result schema as the second argument to ctx.mcpReq.send().`);return f(P,q,k)},notify:p},http:t?.authInfo?{authInfo:t.authInfo}:void 0},E=this.buildContext(z,t);Promise.resolve().then(()=>u(o,E)).then(async(P)=>{if(b.signal.aborted)return;let k;try{k=n.encodeResult(o.method,P,this._outboundServerInfo())}catch(B){this._onerror(Error(`Failed to encode result for ${o.method}: ${B}`)),a(I.InternalError,"Internal error");return}let A={result:k,jsonrpc:"2.0",id:o.id};await i?.send(A)},async(P)=>{if(b.signal.aborted)return;let k=Number.isSafeInteger(P.code)?P.code:I.InternalError,A={jsonrpc:"2.0",id:o.id,error:{code:n.encodeErrorCode(k),message:P.message??"Internal error",...P.data!==void 0&&{data:P.data}}};await i?.send(A)}).catch((P)=>this._onerror(Error(`Failed to send response: ${P}`))).finally(()=>{if(this._requestHandlerAbortControllers.get(o.id)===b)this._requestHandlerAbortControllers.delete(o.id)})}_onprogress(e){let{progressToken:t,...o}=e.params,r=Number(t),n=this._progressHandlers.get(r);if(!n){this._onerror(Error(`Received a progress notification for an unknown token: ${JSON.stringify(e)}`));return}let i=this._responseHandlers.get(r),a=this._timeoutInfo.get(r);if(a&&i&&a.resetTimeoutOnProgress)try{this._resetTimeout(r)}catch(u){this._responseHandlers.delete(r),this._progressHandlers.delete(r),this._cleanupTimeout(r),i(u);return}n(o)}_onresponse(e){let t=Number(e.id),o=this._responseHandlers.get(t);if(o===void 0){this._onerror(Error(`Received a response for an unknown message ID: ${JSON.stringify(e)}`));return}if(this._responseHandlers.delete(t),this._cleanupTimeout(t),this._progressHandlers.delete(t),Kc(e))o(e);else o(oe.fromError(e.error.code,e.error.message,e.error.data))}get transport(){return this._transport}async close(){await this._transport?.close()}request(e,t,o){let r=this._resolveOutboundCodec(e.method);if(Gc(t)){if(!Ch(e.method))this._assertOutboundRequestInEra(r,e.method);return this._requestWithSchemaViaCodec(r,e,t,o)}this._assertOutboundRequestInEra(r,e.method);let n=qh(r,e.method);if(n===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,n,t)}_negotiatedWireCodec(){return Qs(this._negotiatedProtocolVersion)}_wireCodec(){return this._negotiatedWireCodec()}_resolveOutboundCodec(e){if(this._negotiatedProtocolVersion===void 0){let t=RS(e);if(t)return t}return this._negotiatedWireCodec()}_assertOutboundRequestInEra(e,t){if(Hc(t)&&!e.hasRequestMethod(t))throw new K(te.MethodNotSupportedByProtocolVersion,`Method '${t}' is not supported by the negotiated protocol version (wire era ${e.era})`,{method:t,era:e.era})}_requestWithSchema(e,t,o){let r=this._resolveOutboundCodec(e.method);return this._assertOutboundRequestInEra(r,e.method),this._requestWithSchemaViaCodec(r,e,t,o)}_requestWithSchemaViaCodec(e,t,o,r){let{relatedRequestId:n,resumptionToken:i,onresumptiontoken:a,headers:u}=r??{},d=Date.now(),p,f;return new Promise((b,y)=>{let z=(U)=>{y(U)};if(!this._transport){z(Error("Not connected"));return}if(this._options?.enforceStrictCapabilities===!0)try{this.assertCapabilityForMethod(t.method)}catch(U){z(U);return}if(r?.signal?.aborted){let U=r.signal.reason;throw U instanceof K?U:new K(te.RequestTimeout,String(U))}let E=e.era===nl&&this._transport.hasPerRequestStream===!0?new AbortController:void 0,P=this._requestMessageId++;f=P;let k={...t,jsonrpc:"2.0",id:P};if(r?.onprogress)this._progressHandlers.set(P,r.onprogress),k.params={...t.params,_meta:{...t.params?._meta,progressToken:P}};let A=this._envelopeOutbound(k),B=!1,q=(U)=>{if(B)return;if(this._progressHandlers.delete(P),E===void 0){if(t.method!=="initialize")this._transport?.send(this._envelopeOutbound({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:P,reason:String(U)}}),{relatedRequestId:n,resumptionToken:i,onresumptiontoken:a}).catch((G)=>this._onerror(Error(`Failed to send cancellation: ${G}`)))}else E.abort();y(U instanceof K?U:new K(te.RequestTimeout,String(U)))};this._responseHandlers.set(P,(U)=>{if(r?.signal?.aborted)return;if(B=!0,U instanceof Error)return y(U);let G;try{G=e.decodeResult(t.method,U.result)}catch(ie){return y(ie instanceof Error?ie:Error(String(ie)))}if(G.kind==="invalid")return y(G.error);if(G.kind==="input_required"){if(r?.allowInputRequired===!0)return b(kS(G));let ie={codec:e,request:t,resultSchema:o,options:r,flowStartedAt:d,retry:(Ge,mt)=>this._requestWithSchemaViaCodec(e,Ge===void 0?{method:t.method}:{method:t.method,params:Ge},o,mt)};return b(this._resolveNonCompleteResult(G,ie))}let Ne=G.result;Vc(o,Ne).then((ie)=>{if(ie.success)b(ie.data);else y(new K(te.InvalidResult,`Invalid result for ${t.method}: ${ie.error}`))},y)}),p=()=>q(r?.signal?.reason),r?.signal?.addEventListener("abort",p,{once:!0});let M=r?.timeout??dm,D=()=>q(new K(te.RequestTimeout,"Request timed out",{timeout:M}));this._setupTimeout(P,M,r?.maxTotalTimeout,D,r?.resetTimeoutOnProgress??!1),this._transport.send(A,{relatedRequestId:n,resumptionToken:i,onresumptiontoken:a,headers:u,requestSignal:E?.signal}).catch((U)=>{this._progressHandlers.delete(P),y(U)})}).finally(()=>{if(p)r?.signal?.removeEventListener("abort",p);if(f!==void 0)this._responseHandlers.delete(f),this._cleanupTimeout(f)})}async notification(e,t){return await this._notificationViaCodec(this._resolveOutboundCodec(e.method),e,t)}async _notificationViaCodec(e,t,o){if(!this._transport)throw new K(te.NotConnected,"Not connected");if(Fc(t.method)&&!e.hasNotificationMethod(t.method))throw new K(te.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&&o?.relatedRequestId===void 0){if(this._pendingDebouncedNotifications.has(t.method))return;this._pendingDebouncedNotifications.add(t.method),Promise.resolve().then(()=>{if(this._pendingDebouncedNotifications.delete(t.method),!this._transport)return;this._transport?.send(r,o).catch((n)=>this._onerror(n))});return}await this._transport.send(r,o)}setRequestHandler(e,t,o){this.assertRequestHandlerCapability(e);let r;if(typeof t==="function"){if(!Hc(e))throw TypeError(`'${e}' is not a spec request method; pass schemas as the second argument to setRequestHandler().`);r=(n,i)=>{let a=this._negotiatedWireCodec(),u=a.validateRequest(e,n);if(!u.ok&&u.reason==="not-in-era")u=a.validateInputRequest(e,n);if(!u.ok){if(u.reason==="not-in-era")throw new oe(I.InternalError,`No wire schema for ${e} in the resolved era`);throw Error(u.message)}return Promise.resolve(t(u.value,i))}}else if(o)r=async(n,i)=>{let a=await Vc(t.params,{...n.params});if(!a.success)throw new oe(I.InvalidParams,`Invalid params for ${e}: ${a.error}`);return o(a.data,i)};else throw TypeError("setRequestHandler: handler is required");if(typeof t==="function")this._customSchemaRequestMethods.delete(e);else this._customSchemaRequestMethods.add(e);this._requestHandlers.set(e,this._wrapHandler(e,r))}_wrapHandler(e,t){return t}_outboundServerInfo(){}removeRequestHandler(e){this._requestHandlers.delete(e),this._customSchemaRequestMethods.delete(e)}assertCanSetRequestHandler(e){if(this._requestHandlers.has(e))throw Error(`A request handler for ${e} already exists, which would be overridden`)}setNotificationHandler(e,t,o){if(typeof t==="function"){if(!Fc(e))throw TypeError(`'${e}' is not a spec notification method; pass schemas as the second argument to setNotificationHandler().`);this._notificationHandlers.set(e,(r,n)=>{let i=n.validateNotification(e,r);if(!i.ok){if(i.reason==="not-in-era")throw new oe(I.InternalError,`No wire schema for ${e} in the resolved era`);throw Error(i.message)}return Promise.resolve(t(i.value))});return}if(!o)throw TypeError("setNotificationHandler: handler is required");this._notificationHandlers.set(e,async(r)=>{let n=await Vc(t.params,{...r.params});if(!n.success)throw new oe(I.InvalidParams,`Invalid params for notification ${e}: ${n.error}`);await o(n.data,r)})}removeNotificationHandler(e){this._notificationHandlers.delete(e)}};function Jc(e){return e!==null&&typeof e==="object"&&!Array.isArray(e)}function Nh(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}function PS(e){let t={},o=[];if(!Nh(e))return{accepted:t,droppedKeys:o};for(let[r,n]of Object.entries(e)){if(!Nh(n)||"method"in n||"result"in n){o.push(r);continue}t[r]=n}return{accepted:t,droppedKeys:o}}function kS(e){return{resultType:"input_required",inputRequests:e.inputRequests,...e.requestState!==void 0&&{requestState:e.requestState},...e._meta!==void 0&&{_meta:e._meta}}}/*!
|
|
64
|
+
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let s of e.seen.entries()){let c=s[1];if(t===s[0]){i(s);continue}if(e.external){let p=e.external.registry.get(s[0])?.id;if(t!==s[0]&&p){i(s);continue}}if(e.metadataRegistry.get(s[0])?.id){i(s);continue}if(c.cycle){i(s);continue}if(c.count>1){if(e.reused==="ref"){i(s);continue}}}}function Sn(e,t){let o=e.seen.get(t);if(!o)throw Error("Unprocessed schema. This is a bug in Zod.");let r=(c)=>{let d=e.seen.get(c);if(d.ref===null)return;let p=d.def??d.schema,h={...p},f=d.ref;if(d.ref=null,f){r(f);let b=e.seen.get(f),R=b.schema;if(R.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0"))p.allOf=p.allOf??[],p.allOf.push(R);else Object.assign(p,R);if(Object.assign(p,h),c._zod.parent===f)for(let O in p){if(O==="$ref"||O==="allOf")continue;if(!(O in h))delete p[O]}if(R.$ref&&b.def)for(let O in p){if(O==="$ref"||O==="allOf")continue;if(O in b.def&&JSON.stringify(p[O])===JSON.stringify(b.def[O]))delete p[O]}}let S=c._zod.parent;if(S&&S!==f){r(S);let b=e.seen.get(S);if(b?.schema.$ref){if(p.$ref=b.schema.$ref,b.def)for(let R in p){if(R==="$ref"||R==="allOf")continue;if(R in b.def&&JSON.stringify(p[R])===JSON.stringify(b.def[R]))delete p[R]}}}e.override({zodSchema:c,jsonSchema:p,path:d.path??[]})};for(let c of[...e.seen.entries()].reverse())r(c[0]);let n={};if(e.target==="draft-2020-12")n.$schema="https://json-schema.org/draft/2020-12/schema";else if(e.target==="draft-07")n.$schema="http://json-schema.org/draft-07/schema#";else if(e.target==="draft-04")n.$schema="http://json-schema.org/draft-04/schema#";else if(e.target==="openapi-3.0");if(e.external?.uri){let c=e.external.registry.get(t)?.id;if(!c)throw Error("Schema is missing an `id` property");n.$id=e.external.uri(c)}Object.assign(n,o.def??o.schema);let i=e.metadataRegistry.get(t)?.id;if(i!==void 0&&n.id===i)delete n.id;let s=e.external?.defs??{};for(let c of e.seen.entries()){let d=c[1];if(d.def&&d.defId){if(d.def.id===d.defId)delete d.def.id;s[d.defId]=d.def}}if(e.external);else if(Object.keys(s).length>0)if(e.target==="draft-2020-12")n.$defs=s;else n.definitions=s;try{let c=JSON.parse(JSON.stringify(n));return Object.defineProperty(c,"~standard",{value:{...t["~standard"],jsonSchema:{input:mn(t,"input",e.processors),output:mn(t,"output",e.processors)}},enumerable:!1,writable:!1}),c}catch(c){throw Error("Error converting schema to JSON.")}}function Re(e,t){let o=t??{seen:new Set};if(o.seen.has(e))return!1;o.seen.add(e);let r=e._zod.def;if(r.type==="transform")return!0;if(r.type==="array")return Re(r.element,o);if(r.type==="set")return Re(r.valueType,o);if(r.type==="lazy")return Re(r.getter(),o);if(r.type==="promise"||r.type==="optional"||r.type==="nonoptional"||r.type==="nullable"||r.type==="readonly"||r.type==="default"||r.type==="prefault")return Re(r.innerType,o);if(r.type==="intersection")return Re(r.left,o)||Re(r.right,o);if(r.type==="record"||r.type==="map")return Re(r.keyType,o)||Re(r.valueType,o);if(r.type==="pipe"){if(e._zod.traits.has("$ZodCodec"))return!0;return Re(r.in,o)||Re(r.out,o)}if(r.type==="object"){for(let n in r.shape)if(Re(r.shape[n],o))return!0;return!1}if(r.type==="union"){for(let n of r.options)if(Re(n,o))return!0;return!1}if(r.type==="tuple"){for(let n of r.items)if(Re(n,o))return!0;if(r.rest&&Re(r.rest,o))return!0;return!1}return!1}var Kp=(e,t={})=>(o)=>{let r=fn({...o,processors:t});return Q(e,r),gn(r,e),Sn(r,e)},mn=(e,t,o={})=>(r)=>{let{libraryOptions:n,target:i}=r??{},s=fn({...n??{},target:i,io:t,processors:o});return Q(e,s),gn(s,e),Sn(s,e)};var ig={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},Oc=(e,t,o,r)=>{let n=o;n.type="string";let{minimum:i,maximum:s,format:c,patterns:d,contentEncoding:p}=e._zod.bag;if(typeof i==="number")n.minLength=i;if(typeof s==="number")n.maxLength=s;if(c){if(n.format=ig[c]??c,n.format==="")delete n.format;if(c==="time")delete n.format}if(p)n.contentEncoding=p;if(d&&d.size>0){let h=[...d];if(h.length===1)n.pattern=h[0].source;else if(h.length>1)n.allOf=[...h.map((f)=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:f.source}))]}},Mc=(e,t,o,r)=>{let n=o,{minimum:i,maximum:s,format:c,multipleOf:d,exclusiveMaximum:p,exclusiveMinimum:h}=e._zod.bag;if(typeof c==="string"&&c.includes("int"))n.type="integer";else n.type="number";let f=typeof h==="number"&&h>=(i??Number.NEGATIVE_INFINITY),S=typeof p==="number"&&p<=(s??Number.POSITIVE_INFINITY),b=t.target==="draft-04"||t.target==="openapi-3.0";if(f)if(b)n.minimum=h,n.exclusiveMinimum=!0;else n.exclusiveMinimum=h;else if(typeof i==="number")n.minimum=i;if(S)if(b)n.maximum=p,n.exclusiveMaximum=!0;else n.exclusiveMaximum=p;else if(typeof s==="number")n.maximum=s;if(typeof d==="number")n.multipleOf=d},qc=(e,t,o,r)=>{o.type="boolean"},Yp=(e,t,o,r)=>{if(t.unrepresentable==="throw")throw Error("BigInt cannot be represented in JSON Schema")},Qp=(e,t,o,r)=>{if(t.unrepresentable==="throw")throw Error("Symbols cannot be represented in JSON Schema")},Nc=(e,t,o,r)=>{if(t.target==="openapi-3.0")o.type="string",o.nullable=!0,o.enum=[null];else o.type="null"},Ac=(e,t,o,r)=>{if(t.unrepresentable==="throw")throw Error("Undefined cannot be represented in JSON Schema")},Xp=(e,t,o,r)=>{if(t.unrepresentable==="throw")throw Error("Void cannot be represented in JSON Schema")},jc=(e,t,o,r)=>{o.not={}},Lc=(e,t,o,r)=>{},Uc=(e,t,o,r)=>{},eh=(e,t,o,r)=>{if(t.unrepresentable==="throw")throw Error("Date cannot be represented in JSON Schema")},Zc=(e,t,o,r)=>{let n=e._zod.def,i=Li(n.entries);if(i.every((s)=>typeof s==="number"))o.type="number";if(i.every((s)=>typeof s==="string"))o.type="string";o.enum=i},Dc=(e,t,o,r)=>{let n=e._zod.def,i=[];for(let s of n.values)if(s===void 0){if(t.unrepresentable==="throw")throw Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof s==="bigint")if(t.unrepresentable==="throw")throw Error("BigInt literals cannot be represented in JSON Schema");else i.push(Number(s));else i.push(s);if(i.length===0);else if(i.length===1){let s=i[0];if(o.type=s===null?"null":typeof s,t.target==="draft-04"||t.target==="openapi-3.0")o.enum=[s];else o.const=s}else{if(i.every((s)=>typeof s==="number"))o.type="number";if(i.every((s)=>typeof s==="string"))o.type="string";if(i.every((s)=>typeof s==="boolean"))o.type="boolean";if(i.every((s)=>s===null))o.type="null";o.enum=i}},th=(e,t,o,r)=>{if(t.unrepresentable==="throw")throw Error("NaN cannot be represented in JSON Schema")},oh=(e,t,o,r)=>{let n=o,i=e._zod.pattern;if(!i)throw Error("Pattern not found in template literal");n.type="string",n.pattern=i.source},rh=(e,t,o,r)=>{let n=o,i={type:"string",format:"binary",contentEncoding:"binary"},{minimum:s,maximum:c,mime:d}=e._zod.bag;if(s!==void 0)i.minLength=s;if(c!==void 0)i.maxLength=c;if(d)if(d.length===1)i.contentMediaType=d[0],Object.assign(n,i);else Object.assign(n,i),n.anyOf=d.map((p)=>({contentMediaType:p}));else Object.assign(n,i)},nh=(e,t,o,r)=>{o.type="boolean"},Hc=(e,t,o,r)=>{if(t.unrepresentable==="throw")throw Error("Custom types cannot be represented in JSON Schema")},sh=(e,t,o,r)=>{if(t.unrepresentable==="throw")throw Error("Function types cannot be represented in JSON Schema")},Fc=(e,t,o,r)=>{if(t.unrepresentable==="throw")throw Error("Transforms cannot be represented in JSON Schema")},ih=(e,t,o,r)=>{if(t.unrepresentable==="throw")throw Error("Map cannot be represented in JSON Schema")},ah=(e,t,o,r)=>{if(t.unrepresentable==="throw")throw Error("Set cannot be represented in JSON Schema")},Vc=(e,t,o,r)=>{let n=o,i=e._zod.def,{minimum:s,maximum:c}=e._zod.bag;if(typeof s==="number")n.minItems=s;if(typeof c==="number")n.maxItems=c;n.type="array",n.items=Q(i.element,t,{...r,path:[...r.path,"items"]})},Jc=(e,t,o,r)=>{let n=o,i=e._zod.def;n.type="object",n.properties={};let s=i.shape;for(let p in s)n.properties[p]=Q(s[p],t,{...r,path:[...r.path,"properties",p]});let c=new Set(Object.keys(s)),d=new Set([...c].filter((p)=>{let h=i.shape[p]._zod;if(t.io==="input")return h.optin===void 0;else return h.optout===void 0}));if(d.size>0)n.required=Array.from(d);if(i.catchall?._zod.def.type==="never")n.additionalProperties=!1;else if(!i.catchall){if(t.io==="output")n.additionalProperties=!1}else if(i.catchall)n.additionalProperties=Q(i.catchall,t,{...r,path:[...r.path,"additionalProperties"]})},Bc=(e,t,o,r)=>{let n=e._zod.def,i=n.inclusive===!1,s=n.options.map((c,d)=>Q(c,t,{...r,path:[...r.path,i?"oneOf":"anyOf",d]}));if(i)o.oneOf=s;else o.anyOf=s},Wc=(e,t,o,r)=>{let n=e._zod.def,i=Q(n.left,t,{...r,path:[...r.path,"allOf",0]}),s=Q(n.right,t,{...r,path:[...r.path,"allOf",1]}),c=(p)=>("allOf"in p)&&Object.keys(p).length===1,d=[...c(i)?i.allOf:[i],...c(s)?s.allOf:[s]];o.allOf=d},ch=(e,t,o,r)=>{let n=o,i=e._zod.def;n.type="array";let s=t.target==="draft-2020-12"?"prefixItems":"items",c=t.target==="draft-2020-12"?"items":t.target==="openapi-3.0"?"items":"additionalItems",d=i.items.map((S,b)=>Q(S,t,{...r,path:[...r.path,s,b]})),p=i.rest?Q(i.rest,t,{...r,path:[...r.path,c,...t.target==="openapi-3.0"?[i.items.length]:[]]}):null;if(t.target==="draft-2020-12"){if(n.prefixItems=d,p)n.items=p}else if(t.target==="openapi-3.0"){if(n.items={anyOf:d},p)n.items.anyOf.push(p);if(n.minItems=d.length,!p)n.maxItems=d.length}else if(n.items=d,p)n.additionalItems=p;let{minimum:h,maximum:f}=e._zod.bag;if(typeof h==="number")n.minItems=h;if(typeof f==="number")n.maxItems=f},Kc=(e,t,o,r)=>{let n=o,i=e._zod.def;n.type="object";let s=i.keyType,d=s._zod.bag?.patterns;if(i.mode==="loose"&&d&&d.size>0){let h=Q(i.valueType,t,{...r,path:[...r.path,"patternProperties","*"]});n.patternProperties={};for(let f of d)n.patternProperties[f.source]=h}else{if(t.target==="draft-07"||t.target==="draft-2020-12")n.propertyNames=Q(i.keyType,t,{...r,path:[...r.path,"propertyNames"]});n.additionalProperties=Q(i.valueType,t,{...r,path:[...r.path,"additionalProperties"]})}let p=s._zod.values;if(p){let h=[...p].filter((f)=>typeof f==="string"||typeof f==="number");if(h.length>0)n.required=h}},Gc=(e,t,o,r)=>{let n=e._zod.def,i=Q(n.innerType,t,r),s=t.seen.get(e);if(t.target==="openapi-3.0")s.ref=n.innerType,o.nullable=!0;else o.anyOf=[i,{type:"null"}]},Yc=(e,t,o,r)=>{let n=e._zod.def;Q(n.innerType,t,r);let i=t.seen.get(e);i.ref=n.innerType},Qc=(e,t,o,r)=>{let n=e._zod.def;Q(n.innerType,t,r);let i=t.seen.get(e);i.ref=n.innerType,o.default=JSON.parse(JSON.stringify(n.defaultValue))},Xc=(e,t,o,r)=>{let n=e._zod.def;Q(n.innerType,t,r);let i=t.seen.get(e);if(i.ref=n.innerType,t.io==="input")o._prefault=JSON.parse(JSON.stringify(n.defaultValue))},el=(e,t,o,r)=>{let n=e._zod.def;Q(n.innerType,t,r);let i=t.seen.get(e);i.ref=n.innerType;let s;try{s=n.catchValue(void 0)}catch{throw Error("Dynamic catch values are not supported in JSON Schema")}o.default=s},tl=(e,t,o,r)=>{let n=e._zod.def,i=n.in._zod.traits.has("$ZodTransform"),s=t.io==="input"?i?n.out:n.in:n.out;Q(s,t,r);let c=t.seen.get(e);c.ref=s},ol=(e,t,o,r)=>{let n=e._zod.def;Q(n.innerType,t,r);let i=t.seen.get(e);i.ref=n.innerType,o.readOnly=!0},lh=(e,t,o,r)=>{let n=e._zod.def;Q(n.innerType,t,r);let i=t.seen.get(e);i.ref=n.innerType},ea=(e,t,o,r)=>{let n=e._zod.def;Q(n.innerType,t,r);let i=t.seen.get(e);i.ref=n.innerType},rl=(e,t,o,r)=>{let n=e._zod.innerType;Q(n,t,r);let i=t.seen.get(e);i.ref=n},Gp={string:Oc,number:Mc,boolean:qc,bigint:Yp,symbol:Qp,null:Nc,undefined:Ac,void:Xp,never:jc,any:Lc,unknown:Uc,date:eh,enum:Zc,literal:Dc,nan:th,template_literal:oh,file:rh,success:nh,custom:Hc,function:sh,transform:Fc,map:ih,set:ah,array:Vc,object:Jc,union:Bc,intersection:Wc,tuple:ch,record:Kc,nullable:Gc,nonoptional:Yc,default:Qc,prefault:Xc,catch:el,pipe:tl,readonly:ol,promise:lh,optional:ea,lazy:rl};function ta(e,t){if("_idmap"in e){let r=e,n=fn({...t,processors:Gp}),i={};for(let d of r._idmap.entries()){let[p,h]=d;Q(h,n)}let s={},c={registry:r,uri:t?.uri,defs:i};n.external=c;for(let d of r._idmap.entries()){let[p,h]=d;gn(n,h),s[p]=Sn(n,h)}if(Object.keys(i).length>0){let d=n.target==="draft-2020-12"?"$defs":"definitions";s.__shared={[d]:i}}return{schemas:s}}let o=fn({...t,processors:Gp});return Q(e,o),gn(o,e),Sn(o,e)}var mg=g("ZodISODateTime",(e,t)=>{wd.init(e,t),te.init(e,t)});function Jo(e){return Op(mg,e)}var fg=g("ZodISODate",(e,t)=>{xd.init(e,t),te.init(e,t)});function nl(e){return Mp(fg,e)}var gg=g("ZodISOTime",(e,t)=>{Ed.init(e,t),te.init(e,t)});function uh(e){return qp(gg,e)}var Sg=g("ZodISODuration",(e,t)=>{Td.init(e,t),te.init(e,t)});function dh(e){return Np(Sg,e)}var _g=(e,t)=>{Hi.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:(o)=>ic(e,o)},flatten:{value:(o)=>sc(e,o)},addIssue:{value:(o)=>{e.issues.push(o),e.message=JSON.stringify(e.issues,sn,2)}},addIssues:{value:(o)=>{e.issues.push(...o),e.message=JSON.stringify(e.issues,sn,2)}},isEmpty:{get(){return e.issues.length===0}}})};var Me=g("ZodError",_g,{Parent:Error});var hh=Fi(Me),mh=Vi(Me),ra=cn(Me),fh=ln(Me),gh=au(Me),Sh=cu(Me),_h=lu(Me),bh=uu(Me),yh=du(Me),vh=pu(Me),zh=hu(Me),Rh=mu(Me);var wh=new WeakMap;function _n(e,t,o){let r=Object.getPrototypeOf(e),n=wh.get(r);if(!n)n=new Set,wh.set(r,n);if(n.has(t))return;n.add(t);for(let i in o){let s=o[i];Object.defineProperty(r,i,{configurable:!0,enumerable:!1,get(){let c=s.bind(this);return Object.defineProperty(this,i,{configurable:!0,writable:!0,enumerable:!0,value:c}),c},set(c){Object.defineProperty(this,i,{configurable:!0,writable:!0,enumerable:!0,value:c})}})}}var X=g("ZodType",(e,t)=>(G.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:mn(e,"input"),output:mn(e,"output")}}),e.toJSONSchema=Kp(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.parse=(o,r)=>hh(e,o,r,{callee:e.parse}),e.safeParse=(o,r)=>ra(e,o,r),e.parseAsync=async(o,r)=>mh(e,o,r,{callee:e.parseAsync}),e.safeParseAsync=async(o,r)=>fh(e,o,r),e.spa=e.safeParseAsync,e.encode=(o,r)=>gh(e,o,r),e.decode=(o,r)=>Sh(e,o,r),e.encodeAsync=async(o,r)=>_h(e,o,r),e.decodeAsync=async(o,r)=>bh(e,o,r),e.safeEncode=(o,r)=>yh(e,o,r),e.safeDecode=(o,r)=>vh(e,o,r),e.safeEncodeAsync=async(o,r)=>zh(e,o,r),e.safeDecodeAsync=async(o,r)=>Rh(e,o,r),_n(e,"ZodType",{check(...o){let r=this.def;return this.clone(jt(r,{checks:[...r.checks??[],...o.map((n)=>typeof n==="function"?{_zod:{check:n,def:{check:"custom"},onattach:[]}}:n)]}),{parent:!0})},with(...o){return this.check(...o)},clone(o,r){return Ye(this,o,r)},brand(){return this},register(o,r){return o.add(this,r),this},refine(o,r){return this.check(aS(o,r))},superRefine(o,r){return this.check(cS(o,r))},overwrite(o){return this.check(Dt(o))},optional(){return q(this)},exactOptional(){return Bg(this)},nullable(){return Ph(this)},nullish(){return q(Ph(this))},nonoptional(o){return Xg(this,o)},array(){return m(this)},or(o){return v([this,o])},and(o){return yt(this,o)},transform(o){return kh(this,jh(o))},default(o){return Gg(this,o)},prefault(o){return Qg(this,o)},catch(o){return tS(this,o)},pipe(o){return kh(this,o)},readonly(){return nS(this)},describe(o){let r=this.clone();return Zt.add(r,{description:o}),r},meta(...o){if(o.length===0)return Zt.get(this);let r=this.clone();return Zt.add(r,o[0]),r},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(o){return o(this)}}),Object.defineProperty(e,"description",{get(){return Zt.get(e)?.description},configurable:!0}),e)),$h=g("_ZodString",(e,t)=>{Wi.init(e,t),X.init(e,t),e._zod.processJSONSchema=(r,n,i)=>Oc(e,r,n,i);let o=e._zod.bag;e.format=o.format??null,e.minLength=o.minimum??null,e.maxLength=o.maximum??null,_n(e,"_ZodString",{regex(...r){return this.check(zc(...r))},includes(...r){return this.check(xc(...r))},startsWith(...r){return this.check(Ec(...r))},endsWith(...r){return this.check(Tc(...r))},min(...r){return this.check(Fo(...r))},max(...r){return this.check(Qi(...r))},length(...r){return this.check(Xi(...r))},nonempty(...r){return this.check(Fo(1,...r))},lowercase(r){return this.check(Rc(r))},uppercase(r){return this.check(wc(r))},trim(){return this.check(kc())},normalize(...r){return this.check(Pc(...r))},toLowerCase(){return this.check($c())},toUpperCase(){return this.check(Cc())},slugify(){return this.check(Ic())}})}),Ch=g("ZodString",(e,t)=>{Wi.init(e,t),$h.init(e,t),e.email=(o)=>e.check(bc(Ih,o)),e.url=(o)=>e.check(vc(Mh,o)),e.jwt=(o)=>e.check(Ip(Mg,o)),e.emoji=(o)=>e.check(_p(yg,o)),e.guid=(o)=>e.check(yc(xh,o)),e.uuid=(o)=>e.check(mp(na,o)),e.uuidv4=(o)=>e.check(fp(na,o)),e.uuidv6=(o)=>e.check(gp(na,o)),e.uuidv7=(o)=>e.check(Sp(na,o)),e.nanoid=(o)=>e.check(bp(vg,o)),e.guid=(o)=>e.check(yc(xh,o)),e.cuid=(o)=>e.check(yp(zg,o)),e.cuid2=(o)=>e.check(vp(Rg,o)),e.ulid=(o)=>e.check(zp(wg,o)),e.base64=(o)=>e.check(kp(Cg,o)),e.base64url=(o)=>e.check($p(Ig,o)),e.xid=(o)=>e.check(Rp(xg,o)),e.ksuid=(o)=>e.check(wp(Eg,o)),e.ipv4=(o)=>e.check(xp(Tg,o)),e.ipv6=(o)=>e.check(Ep(Pg,o)),e.cidrv4=(o)=>e.check(Tp(kg,o)),e.cidrv6=(o)=>e.check(Pp($g,o)),e.e164=(o)=>e.check(Cp(Og,o)),e.datetime=(o)=>e.check(Jo(o)),e.date=(o)=>e.check(nl(o)),e.time=(o)=>e.check(uh(o)),e.duration=(o)=>e.check(dh(o))});function a(e){return hp(Ch,e)}var te=g("ZodStringFormat",(e,t)=>{ee.init(e,t),$h.init(e,t)}),Ih=g("ZodEmail",(e,t)=>{fd.init(e,t),te.init(e,t)});function Oh(e){return bc(Ih,e)}var xh=g("ZodGUID",(e,t)=>{hd.init(e,t),te.init(e,t)});var na=g("ZodUUID",(e,t)=>{md.init(e,t),te.init(e,t)});var Mh=g("ZodURL",(e,t)=>{gd.init(e,t),te.init(e,t)});function sa(e){return vc(Mh,e)}var yg=g("ZodEmoji",(e,t)=>{Sd.init(e,t),te.init(e,t)});var vg=g("ZodNanoID",(e,t)=>{_d.init(e,t),te.init(e,t)});var zg=g("ZodCUID",(e,t)=>{bd.init(e,t),te.init(e,t)});var Rg=g("ZodCUID2",(e,t)=>{yd.init(e,t),te.init(e,t)});var wg=g("ZodULID",(e,t)=>{vd.init(e,t),te.init(e,t)});var xg=g("ZodXID",(e,t)=>{zd.init(e,t),te.init(e,t)});var Eg=g("ZodKSUID",(e,t)=>{Rd.init(e,t),te.init(e,t)});var Tg=g("ZodIPv4",(e,t)=>{Pd.init(e,t),te.init(e,t)});var Pg=g("ZodIPv6",(e,t)=>{kd.init(e,t),te.init(e,t)});var kg=g("ZodCIDRv4",(e,t)=>{$d.init(e,t),te.init(e,t)});var $g=g("ZodCIDRv6",(e,t)=>{Cd.init(e,t),te.init(e,t)});var Cg=g("ZodBase64",(e,t)=>{Od.init(e,t),te.init(e,t)});var Ig=g("ZodBase64URL",(e,t)=>{Md.init(e,t),te.init(e,t)});var Og=g("ZodE164",(e,t)=>{qd.init(e,t),te.init(e,t)});var Mg=g("ZodJWT",(e,t)=>{Nd.init(e,t),te.init(e,t)});var ia=g("ZodNumber",(e,t)=>{mc.init(e,t),X.init(e,t),e._zod.processJSONSchema=(r,n,i)=>Mc(e,r,n,i),_n(e,"ZodNumber",{gt(r,n){return this.check(Gi(r,n))},gte(r,n){return this.check(hn(r,n))},min(r,n){return this.check(hn(r,n))},lt(r,n){return this.check(Ki(r,n))},lte(r,n){return this.check(pn(r,n))},max(r,n){return this.check(pn(r,n))},int(r){return this.check(Eh(r))},safe(r){return this.check(Eh(r))},positive(r){return this.check(Gi(0,r))},nonnegative(r){return this.check(hn(0,r))},negative(r){return this.check(Ki(0,r))},nonpositive(r){return this.check(pn(0,r))},multipleOf(r,n){return this.check(Yi(r,n))},step(r,n){return this.check(Yi(r,n))},finite(){return this}});let o=e._zod.bag;e.minValue=Math.max(o.minimum??Number.NEGATIVE_INFINITY,o.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(o.maximum??Number.POSITIVE_INFINITY,o.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(o.format??"").includes("int")||Number.isSafeInteger(o.multipleOf??0.5),e.isFinite=!0,e.format=o.format??null});function _(e){return Ap(ia,e)}var qg=g("ZodNumberFormat",(e,t)=>{Ad.init(e,t),ia.init(e,t)});function Eh(e){return Lp(qg,e)}var qh=g("ZodBoolean",(e,t)=>{jd.init(e,t),X.init(e,t),e._zod.processJSONSchema=(o,r,n)=>qc(e,o,r,n)});function z(e){return Up(qh,e)}var Ng=g("ZodUndefined",(e,t)=>{Ld.init(e,t),X.init(e,t),e._zod.processJSONSchema=(o,r,n)=>Ac(e,o,r,n)});function Bo(e){return Zp(Ng,e)}var Ag=g("ZodNull",(e,t)=>{Ud.init(e,t),X.init(e,t),e._zod.processJSONSchema=(o,r,n)=>Nc(e,o,r,n)});function po(e){return Dp(Ag,e)}var jg=g("ZodAny",(e,t)=>{Zd.init(e,t),X.init(e,t),e._zod.processJSONSchema=(o,r,n)=>Lc(e,o,r,n)});function Wo(){return Hp(jg)}var Lg=g("ZodUnknown",(e,t)=>{Dd.init(e,t),X.init(e,t),e._zod.processJSONSchema=(o,r,n)=>Uc(e,o,r,n)});function P(){return Fp(Lg)}var Ug=g("ZodNever",(e,t)=>{Hd.init(e,t),X.init(e,t),e._zod.processJSONSchema=(o,r,n)=>jc(e,o,r,n)});function bn(e){return Vp(Ug,e)}var Zg=g("ZodArray",(e,t)=>{Fd.init(e,t),X.init(e,t),e._zod.processJSONSchema=(o,r,n)=>Vc(e,o,r,n),e.element=t.element,_n(e,"ZodArray",{min(o,r){return this.check(Fo(o,r))},nonempty(o){return this.check(Fo(1,o))},max(o,r){return this.check(Qi(o,r))},length(o,r){return this.check(Xi(o,r))},unwrap(){return this.element}})});function m(e,t){return Jp(Zg,e,t)}var Nh=g("ZodObject",(e,t)=>{Bd.init(e,t),X.init(e,t),e._zod.processJSONSchema=(o,r,n)=>Jc(e,o,r,n),V(e,"shape",()=>t.shape),_n(e,"ZodObject",{keyof(){return D(Object.keys(this._zod.def.shape))},catchall(o){return this.clone({...this._zod.def,catchall:o})},passthrough(){return this.clone({...this._zod.def,catchall:P()})},loose(){return this.clone({...this._zod.def,catchall:P()})},strict(){return this.clone({...this._zod.def,catchall:bn()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(o){return Jf(this,o)},safeExtend(o){return Bf(this,o)},merge(o){return Wf(this,o)},pick(o){return Ff(this,o)},omit(o){return Vf(this,o)},partial(...o){return Kf(Lh,this,o[0])},required(...o){return Gf(Uh,this,o[0])}})});function l(e,t){let o={type:"object",shape:e??{},...I(t)};return new Nh(o)}function N(e,t){return new Nh({type:"object",shape:e,catchall:P(),...I(t)})}var Ah=g("ZodUnion",(e,t)=>{fc.init(e,t),X.init(e,t),e._zod.processJSONSchema=(o,r,n)=>Bc(e,o,r,n),e.options=t.options});function v(e,t){return new Ah({type:"union",options:e,...I(t)})}var Dg=g("ZodDiscriminatedUnion",(e,t)=>{Ah.init(e,t),Wd.init(e,t)});function Ko(e,t,o){return new Dg({type:"union",options:t,discriminator:e,...I(o)})}var Hg=g("ZodIntersection",(e,t)=>{Kd.init(e,t),X.init(e,t),e._zod.processJSONSchema=(o,r,n)=>Wc(e,o,r,n)});function yt(e,t){return new Hg({type:"intersection",left:e,right:t})}var Th=g("ZodRecord",(e,t)=>{Gd.init(e,t),X.init(e,t),e._zod.processJSONSchema=(o,r,n)=>Kc(e,o,r,n),e.keyType=t.keyType,e.valueType=t.valueType});function y(e,t,o){if(!t||!t._zod)return new Th({type:"record",keyType:a(),valueType:e,...I(t)});return new Th({type:"record",keyType:e,valueType:t,...I(o)})}var sl=g("ZodEnum",(e,t)=>{Yd.init(e,t),X.init(e,t),e._zod.processJSONSchema=(r,n,i)=>Zc(e,r,n,i),e.enum=t.entries,e.options=Object.values(t.entries);let o=new Set(Object.keys(t.entries));e.extract=(r,n)=>{let i={};for(let s of r)if(o.has(s))i[s]=t.entries[s];else throw Error(`Key ${s} not found in enum`);return new sl({...t,checks:[],...I(n),entries:i})},e.exclude=(r,n)=>{let i={...t.entries};for(let s of r)if(o.has(s))delete i[s];else throw Error(`Key ${s} not found in enum`);return new sl({...t,checks:[],...I(n),entries:i})}});function D(e,t){let o=Array.isArray(e)?Object.fromEntries(e.map((r)=>[r,r])):e;return new sl({type:"enum",entries:o,...I(t)})}var Fg=g("ZodLiteral",(e,t)=>{Qd.init(e,t),X.init(e,t),e._zod.processJSONSchema=(o,r,n)=>Dc(e,o,r,n),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function u(e,t){return new Fg({type:"literal",values:Array.isArray(e)?e:[e],...I(t)})}var Vg=g("ZodTransform",(e,t)=>{Xd.init(e,t),X.init(e,t),e._zod.processJSONSchema=(o,r,n)=>Fc(e,o,r,n),e._zod.parse=(o,r)=>{if(r.direction==="backward")throw new nn(e.constructor.name);o.addIssue=(i)=>{if(typeof i==="string")o.issues.push(uo(i,o.value,t));else{let s=i;if(s.fatal)s.continue=!1;s.code??(s.code="custom"),s.input??(s.input=o.value),s.inst??(s.inst=e),o.issues.push(uo(s))}};let n=t.transform(o.value,o);if(n instanceof Promise)return n.then((i)=>(o.value=i,o.fallback=!0,o));return o.value=n,o.fallback=!0,o}});function jh(e){return new Vg({type:"transform",transform:e})}var Lh=g("ZodOptional",(e,t)=>{gc.init(e,t),X.init(e,t),e._zod.processJSONSchema=(o,r,n)=>ea(e,o,r,n),e.unwrap=()=>e._zod.def.innerType});function q(e){return new Lh({type:"optional",innerType:e})}var Jg=g("ZodExactOptional",(e,t)=>{ep.init(e,t),X.init(e,t),e._zod.processJSONSchema=(o,r,n)=>ea(e,o,r,n),e.unwrap=()=>e._zod.def.innerType});function Bg(e){return new Jg({type:"optional",innerType:e})}var Wg=g("ZodNullable",(e,t)=>{tp.init(e,t),X.init(e,t),e._zod.processJSONSchema=(o,r,n)=>Gc(e,o,r,n),e.unwrap=()=>e._zod.def.innerType});function Ph(e){return new Wg({type:"nullable",innerType:e})}var Kg=g("ZodDefault",(e,t)=>{op.init(e,t),X.init(e,t),e._zod.processJSONSchema=(o,r,n)=>Qc(e,o,r,n),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Gg(e,t){return new Kg({type:"default",innerType:e,get defaultValue(){return typeof t==="function"?t():oc(t)}})}var Yg=g("ZodPrefault",(e,t)=>{rp.init(e,t),X.init(e,t),e._zod.processJSONSchema=(o,r,n)=>Xc(e,o,r,n),e.unwrap=()=>e._zod.def.innerType});function Qg(e,t){return new Yg({type:"prefault",innerType:e,get defaultValue(){return typeof t==="function"?t():oc(t)}})}var Uh=g("ZodNonOptional",(e,t)=>{np.init(e,t),X.init(e,t),e._zod.processJSONSchema=(o,r,n)=>Yc(e,o,r,n),e.unwrap=()=>e._zod.def.innerType});function Xg(e,t){return new Uh({type:"nonoptional",innerType:e,...I(t)})}var eS=g("ZodCatch",(e,t)=>{sp.init(e,t),X.init(e,t),e._zod.processJSONSchema=(o,r,n)=>el(e,o,r,n),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function tS(e,t){return new eS({type:"catch",innerType:e,catchValue:typeof t==="function"?t:()=>t})}var Zh=g("ZodPipe",(e,t)=>{Sc.init(e,t),X.init(e,t),e._zod.processJSONSchema=(o,r,n)=>tl(e,o,r,n),e.in=t.in,e.out=t.out});function kh(e,t){return new Zh({type:"pipe",in:e,out:t})}var oS=g("ZodPreprocess",(e,t)=>{Zh.init(e,t),ip.init(e,t)}),rS=g("ZodReadonly",(e,t)=>{ap.init(e,t),X.init(e,t),e._zod.processJSONSchema=(o,r,n)=>ol(e,o,r,n),e.unwrap=()=>e._zod.def.innerType});function nS(e){return new rS({type:"readonly",innerType:e})}var sS=g("ZodLazy",(e,t)=>{cp.init(e,t),X.init(e,t),e._zod.processJSONSchema=(o,r,n)=>rl(e,o,r,n),e.unwrap=()=>e._zod.def.getter()});function yn(e){return new sS({type:"lazy",getter:e})}var iS=g("ZodCustom",(e,t)=>{lp.init(e,t),X.init(e,t),e._zod.processJSONSchema=(o,r,n)=>Hc(e,o,r,n)});function aS(e,t={}){return Bp(iS,e,t)}function cS(e,t){return Wp(e,t)}function ho(e,t){return new oS({type:"pipe",in:jh(e),out:t})}var Hh={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"};var Dh;(function(e){})(Dh||(Dh={}));function lS(e){return jp(ia,e)}ze(_c());var vn="2025-11-25";var ca=[vn,"2025-06-18","2025-03-26","2024-11-05","2024-10-07"],la="io.modelcontextprotocol/related-task",mo="io.modelcontextprotocol/protocolVersion",Go="io.modelcontextprotocol/clientInfo",dt="io.modelcontextprotocol/serverInfo",fo="io.modelcontextprotocol/clientCapabilities",Yo="io.modelcontextprotocol/subscriptionId",Qo="io.modelcontextprotocol/logLevel";var go="2.0";var vt=yn(()=>v([a(),_(),z(),po(),y(a(),vt),m(vt)])),oe=y(a(),vt),ua=m(vt),Xo=v([a(),_().int()]),er=a(),zn=l({ttl:_().optional()}),Rn=l({taskId:a()}),tr=N({progressToken:Xo.optional(),[la]:Rn.optional()}),ue=l({_meta:tr.optional()}),Ft=ue.extend({task:zn.optional()}),re=l({method:a(),params:ue.loose().optional()}),Se=l({_meta:tr.optional()}),he=l({method:a(),params:Se.loose().optional()}),or=N({get[dt](){return Ne.optional().catch(void 0)}}),ne=N({_meta:or.optional()}),qe=v([a(),_().int()]),rr=l({jsonrpc:u(go),id:qe,...re.shape}).strict(),nr=l({jsonrpc:u(go),...he.shape}).strict(),So=l({jsonrpc:u(go),id:qe,result:ne}).strict(),_o=l({jsonrpc:u(go),id:qe.optional(),error:l({code:_().int(),message:a(),data:P().optional()})}).strict(),zt=v([rr,nr,So,_o]),da=v([So,_o]),pt=ne.strict(),wn=Se.extend({requestId:qe.optional(),reason:a().optional()}),sr=he.extend({method:u("notifications/cancelled"),params:wn}),xn=l({src:a(),mimeType:a().optional(),sizes:m(a()).optional(),theme:D(["light","dark"]).optional()}),Rt=l({icons:m(xn).optional()}),ut=l({name:a(),title:a().optional()}),Ne=ut.extend({...ut.shape,...Rt.shape,version:a(),websiteUrl:a().optional(),description:a().optional()}),uS=yt(l({applyDefaults:z().optional()}),oe),dS=ho((e)=>{if(e&&typeof e==="object"&&!Array.isArray(e)&&Object.keys(e).length===0)return{form:{}};return e},yt(l({form:uS.optional(),url:oe.optional()}),oe.optional())),pa=N({list:oe.optional(),cancel:oe.optional(),requests:N({sampling:N({createMessage:oe.optional()}).optional(),elicitation:N({create:oe.optional()}).optional()}).optional()}),ha=N({list:oe.optional(),cancel:oe.optional(),requests:N({tools:N({call:oe.optional()}).optional()}).optional()}),En=l({experimental:y(a(),oe).optional(),sampling:l({context:oe.optional(),tools:oe.optional()}).optional(),elicitation:dS.optional(),roots:l({listChanged:z().optional()}).optional(),tasks:pa.optional(),extensions:y(a(),oe).optional()}),Tn=ue.extend({protocolVersion:a(),capabilities:En,clientInfo:Ne}),Pn=re.extend({method:u("initialize"),params:Tn}),ir=l({experimental:y(a(),oe).optional(),logging:oe.optional(),completions:oe.optional(),prompts:l({listChanged:z().optional()}).optional(),resources:l({subscribe:z().optional(),listChanged:z().optional()}).optional(),tools:l({listChanged:z().optional()}).optional(),tasks:ha.optional(),extensions:y(a(),oe).optional()}),kn=ne.extend({protocolVersion:a(),capabilities:ir,serverInfo:Ne,instructions:a().optional()}),$n=he.extend({method:u("notifications/initialized"),params:Se.optional()}),Cn=re.extend({method:u("server/discover"),params:ue.optional()}),Vt=ne.extend({supportedVersions:m(a()),capabilities:ir,instructions:a().optional()}),ar=re.extend({method:u("ping"),params:ue.optional()}),In=l({progress:_(),total:q(_()),message:q(a())}),On=l({...Se.shape,...In.shape,progressToken:Xo}),cr=he.extend({method:u("notifications/progress"),params:On}),Mn=ue.extend({cursor:er.optional()}),wt=re.extend({params:Mn.optional()}),xt=ne.extend({nextCursor:er.optional()}),lr=l({uri:a(),mimeType:q(a()),_meta:y(a(),P()).optional()}),ur=lr.extend({text:a()}),il=a().refine((e)=>{try{return atob(e),!0}catch{return!1}},{message:"Invalid Base64 string"}),dr=lr.extend({blob:il}),Et=D(["user","assistant"]),ht=l({audience:m(Et).optional(),priority:_().min(0).max(1).optional(),lastModified:Jo({offset:!0}).optional()}),pr=l({...ut.shape,...Rt.shape,uri:a(),description:q(a()),mimeType:q(a()),size:q(_()),annotations:ht.optional(),_meta:q(N({}))}),qn=l({...ut.shape,...Rt.shape,uriTemplate:a(),description:q(a()),mimeType:q(a()),annotations:ht.optional(),_meta:q(N({}))}),Nn=wt.extend({method:u("resources/list")}),An=xt.extend({resources:m(pr)}),jn=wt.extend({method:u("resources/templates/list")}),Ln=xt.extend({resourceTemplates:m(qn)}),bo=ue.extend({uri:a()}),Un=bo,Zn=re.extend({method:u("resources/read"),params:Un}),Dn=ne.extend({contents:m(v([ur,dr]))}),Hn=he.extend({method:u("notifications/resources/list_changed"),params:Se.optional()}),Fn=bo,Vn=re.extend({method:u("resources/subscribe"),params:Fn}),Jn=bo,Bn=re.extend({method:u("resources/unsubscribe"),params:Jn}),hr=l({toolsListChanged:z().optional(),promptsListChanged:z().optional(),resourcesListChanged:z().optional(),resourceSubscriptions:m(a()).optional()}),Wn=ue.extend({notifications:hr}),Kn=re.extend({method:u("subscriptions/listen"),params:Wn}),Gn=Se.extend({notifications:hr}),Yn=he.extend({method:u("notifications/subscriptions/acknowledged"),params:Gn}),Qn=or.extend({[Yo]:qe}),Xn=ne.extend({_meta:Qn}),es=Se.extend({uri:a()}),ts=he.extend({method:u("notifications/resources/updated"),params:es}),os=l({name:a(),description:q(a()),required:q(z())}),rs=l({...ut.shape,...Rt.shape,description:q(a()),arguments:q(m(os)),_meta:q(N({}))}),ns=wt.extend({method:u("prompts/list")}),ss=xt.extend({prompts:m(rs)}),is=ue.extend({name:a(),arguments:y(a(),a()).optional()}),as=re.extend({method:u("prompts/get"),params:is}),yo=l({type:u("text"),text:a(),annotations:ht.optional(),_meta:y(a(),P()).optional()}),vo=l({type:u("image"),data:il,mimeType:a(),annotations:ht.optional(),_meta:y(a(),P()).optional()}),zo=l({type:u("audio"),data:il,mimeType:a(),annotations:ht.optional(),_meta:y(a(),P()).optional()}),cs=l({type:u("tool_use"),name:a(),id:a(),input:y(a(),P()),_meta:y(a(),P()).optional()}),Tt=l({type:u("resource"),resource:v([ur,dr]),annotations:ht.optional(),_meta:y(a(),P()).optional()}),Pt=pr.extend({type:u("resource_link")}),Ae=v([yo,vo,zo,Pt,Tt]),ls=l({role:Et,content:Ae}),us=ne.extend({description:a().optional(),messages:m(ls)}),ds=he.extend({method:u("notifications/prompts/list_changed"),params:Se.optional()}),ps=l({title:a().optional(),readOnlyHint:z().optional(),destructiveHint:z().optional(),idempotentHint:z().optional(),openWorldHint:z().optional()}),hs=l({taskSupport:D(["required","optional","forbidden"]).optional()}),mt=l({...ut.shape,...Rt.shape,description:a().optional(),inputSchema:l({type:u("object"),properties:y(a(),vt).optional(),required:m(a()).optional()}).catchall(P()),outputSchema:N({$schema:a().optional()}).optional(),annotations:ps.optional(),execution:hs.optional(),_meta:y(a(),P()).optional()}),ms=wt.extend({method:u("tools/list")}),fs=xt.extend({tools:m(mt)}),ft=ne.extend({content:m(Ae).default([]),structuredContent:P().optional(),isError:z().optional()}),ma=ft.or(ne.extend({toolResult:P()})),gs=Ft.extend({name:a(),arguments:y(a(),P()).optional()}),Ss=re.extend({method:u("tools/call"),params:gs}),_s=he.extend({method:u("notifications/tools/list_changed"),params:Se.optional()}),bs=l({autoRefresh:z().default(!0),debounceMs:_().int().nonnegative().default(300)}),mr=D(["debug","info","notice","warning","error","critical","alert","emergency"]),ys=ue.extend({level:mr}),vs=re.extend({method:u("logging/setLevel"),params:ys}),zs=Se.extend({level:mr,logger:a().optional(),data:P()}),Ro=he.extend({method:u("notifications/message"),params:zs}),Rs=l({name:a().optional()}),ws=l({hints:m(Rs).optional(),costPriority:_().min(0).max(1).optional(),speedPriority:_().min(0).max(1).optional(),intelligencePriority:_().min(0).max(1).optional()}),xs=l({mode:D(["auto","required","none"]).optional()}),Es=l({type:u("tool_result"),toolUseId:a().describe("The unique identifier for the corresponding tool call."),content:m(Ae),structuredContent:P().optional(),isError:z().optional(),_meta:y(a(),P()).optional()}),Ts=Ko("type",[yo,vo,zo]),Ht=Ko("type",[yo,vo,zo,cs,Es]),Ps=l({role:Et,content:v([Ht,m(Ht)]),_meta:y(a(),P()).optional()}),ks=Ft.extend({messages:m(Ps),modelPreferences:ws.optional(),systemPrompt:a().optional(),includeContext:D(["none","thisServer","allServers"]).optional(),temperature:_().optional(),maxTokens:_().int(),stopSequences:m(a()).optional(),metadata:oe.optional(),tools:m(mt).optional(),toolChoice:xs.optional()}),$s=re.extend({method:u("sampling/createMessage"),params:ks}),Cs=ne.extend({model:a(),stopReason:q(D(["endTurn","stopSequence","maxTokens"]).or(a())),role:Et,content:Ts}),Is=ne.extend({model:a(),stopReason:q(D(["endTurn","stopSequence","maxTokens","toolUse"]).or(a())),role:Et,content:v([Ht,m(Ht)])}),fr=l({type:u("boolean"),title:a().optional(),description:a().optional(),default:z().optional()}),wo=l({type:u("string"),title:a().optional(),description:a().optional(),minLength:_().optional(),maxLength:_().optional(),format:D(["email","uri","date","date-time"]).optional(),default:a().optional()}),xo=l({type:D(["number","integer"]),title:a().optional(),description:a().optional(),minimum:_().optional(),maximum:_().optional(),default:_().optional()}),gr=l({type:u("string"),title:a().optional(),description:a().optional(),enum:m(a()),default:a().optional()}),Sr=l({type:u("string"),title:a().optional(),description:a().optional(),oneOf:m(l({const:a(),title:a()})),default:a().optional()}),_r=l({type:u("string"),title:a().optional(),description:a().optional(),enum:m(a()),enumNames:m(a()).optional(),default:a().optional()}),Os=v([gr,Sr]),br=l({type:u("array"),title:a().optional(),description:a().optional(),minItems:_().optional(),maxItems:_().optional(),items:l({type:u("string"),enum:m(a())}),default:m(a()).optional()}),yr=l({type:u("array"),title:a().optional(),description:a().optional(),minItems:_().optional(),maxItems:_().optional(),items:l({anyOf:m(l({const:a(),title:a()}))}),default:m(a()).optional()}),Ms=v([br,yr]),qs=v([_r,Os,Ms]),vr=v([qs,fr,wo,xo]),Eo=Ft.extend({mode:u("form").optional(),message:a(),requestedSchema:l({type:u("object"),properties:y(a(),vr),required:m(a()).optional()}).catchall(P())}),Ns=Ft.extend({mode:u("url"),message:a(),elicitationId:a(),url:a().url()}),As=v([Eo,Ns]),js=re.extend({method:u("elicitation/create"),params:As}),Ls=Se.extend({elicitationId:a()}),Us=he.extend({method:u("notifications/elicitation/complete"),params:Ls}),Zs=ne.extend({action:D(["accept","decline","cancel"]),content:ho((e)=>e===null?void 0:e,y(a(),v([a(),_(),z(),m(a())])).optional())}),Ds=l({type:u("ref/resource"),uri:a()}),Hs=l({type:u("ref/prompt"),name:a()}),Fs=ue.extend({ref:v([Hs,Ds]),argument:l({name:a(),value:a()}),context:l({arguments:y(a(),a()).optional()}).optional()}),Vs=re.extend({method:u("completion/complete"),params:Fs}),Js=ne.extend({completion:N({values:m(a()).max(100),total:q(_().int()),hasMore:q(z())})}),Bs=l({uri:a().startsWith("file://"),name:a().optional(),_meta:y(a(),P()).optional()}),Ws=re.extend({method:u("roots/list"),params:ue.optional()}),Ks=ne.extend({roots:m(Bs)}),Gs=he.extend({method:u("notifications/roots/list_changed"),params:Se.optional()}),fa=N({ttl:_().optional(),pollInterval:_().optional()}),Ys=D(["working","input_required","completed","failed","cancelled"]),kt=l({taskId:a(),status:Ys,ttl:v([_(),po()]),createdAt:a(),lastUpdatedAt:a(),pollInterval:q(_()),statusMessage:q(a())}),ga=ne.extend({task:kt}),Qs=Se.merge(kt),Sa=he.extend({method:u("notifications/tasks/status"),params:Qs}),_a=re.extend({method:u("tasks/get"),params:ue.extend({taskId:a()})}),ba=ne.merge(kt),ya=re.extend({method:u("tasks/result"),params:ue.extend({taskId:a()})}),va=ne.loose(),za=wt.extend({method:u("tasks/list")}),Ra=xt.extend({tasks:m(kt)}),wa=re.extend({method:u("tasks/cancel"),params:ue.extend({taskId:a()})}),xa=ne.merge(kt),Ea=v([ar,Pn,Cn,Vs,vs,as,ns,Nn,jn,Zn,Vn,Bn,Kn,Ss,ms]),Ta=v([sr,cr,$n,Gs]),Pa=v([pt,Cs,Is,Zs,Ks]),ka=v([ar,$s,js,Ws]),$a=v([sr,cr,Ro,ts,Hn,_s,ds,Yn,Us]),Ca=v([pt,kn,Vt,Js,us,ss,An,Ln,Dn,ft,fs,Xn]);var de=sa().superRefine((e,t)=>{if(!URL.canParse(e))return t.addIssue({code:Hh.custom,message:"URL must be parseable",fatal:!0}),Ya}).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"}),Xs=N({resource:a().url(),authorization_servers:m(de).optional(),jwks_uri:a().url().optional(),scopes_supported:m(a()).optional(),bearer_methods_supported:m(a()).optional(),resource_signing_alg_values_supported:m(a()).optional(),resource_name:a().optional(),resource_documentation:a().optional(),resource_policy_uri:a().url().optional(),resource_tos_uri:a().url().optional(),tls_client_certificate_bound_access_tokens:z().optional(),authorization_details_types_supported:m(a()).optional(),dpop_signing_alg_values_supported:m(a()).optional(),dpop_bound_access_tokens_required:z().optional()}),zr=N({issuer:a(),authorization_endpoint:de,token_endpoint:de,registration_endpoint:de.optional(),scopes_supported:m(a()).optional(),response_types_supported:m(a()),response_modes_supported:m(a()).optional(),grant_types_supported:m(a()).optional(),token_endpoint_auth_methods_supported:m(a()).optional(),token_endpoint_auth_signing_alg_values_supported:m(a()).optional(),service_documentation:de.optional(),revocation_endpoint:de.optional(),revocation_endpoint_auth_methods_supported:m(a()).optional(),revocation_endpoint_auth_signing_alg_values_supported:m(a()).optional(),introspection_endpoint:a().optional(),introspection_endpoint_auth_methods_supported:m(a()).optional(),introspection_endpoint_auth_signing_alg_values_supported:m(a()).optional(),code_challenge_methods_supported:m(a()).optional(),client_id_metadata_document_supported:z().optional(),authorization_response_iss_parameter_supported:z().optional().catch(void 0),dpop_signing_alg_values_supported:m(a()).optional()}),ei=N({issuer:a(),authorization_endpoint:de,token_endpoint:de,userinfo_endpoint:de.optional(),jwks_uri:de,registration_endpoint:de.optional(),scopes_supported:m(a()).optional(),response_types_supported:m(a()),response_modes_supported:m(a()).optional(),grant_types_supported:m(a()).optional(),acr_values_supported:m(a()).optional(),subject_types_supported:m(a()),id_token_signing_alg_values_supported:m(a()),id_token_encryption_alg_values_supported:m(a()).optional(),id_token_encryption_enc_values_supported:m(a()).optional(),userinfo_signing_alg_values_supported:m(a()).optional(),userinfo_encryption_alg_values_supported:m(a()).optional(),userinfo_encryption_enc_values_supported:m(a()).optional(),request_object_signing_alg_values_supported:m(a()).optional(),request_object_encryption_alg_values_supported:m(a()).optional(),request_object_encryption_enc_values_supported:m(a()).optional(),token_endpoint_auth_methods_supported:m(a()).optional(),token_endpoint_auth_signing_alg_values_supported:m(a()).optional(),display_values_supported:m(a()).optional(),claim_types_supported:m(a()).optional(),claims_supported:m(a()).optional(),service_documentation:a().optional(),claims_locales_supported:m(a()).optional(),ui_locales_supported:m(a()).optional(),claims_parameter_supported:z().optional(),request_parameter_supported:z().optional(),request_uri_parameter_supported:z().optional(),require_request_uri_registration:z().optional(),op_policy_uri:de.optional(),op_tos_uri:de.optional(),client_id_metadata_document_supported:z().optional(),authorization_response_iss_parameter_supported:z().optional().catch(void 0)}),ti=l({...ei.shape,...zr.pick({code_challenge_methods_supported:!0}).shape}),Rr=l({access_token:a(),id_token:a().optional(),token_type:a(),expires_in:lS().optional(),scope:a().optional(),refresh_token:a().optional(),issuer:a().optional().catch(void 0)}).strip(),oi=l({issued_token_type:u("urn:ietf:params:oauth:token-type:id-jag"),access_token:a(),token_type:a().optional(),expires_in:_().optional(),scope:a().optional()}).strip(),wr=l({error:a(),error_description:a().optional(),error_uri:a().optional()}),al=de.optional().or(u("").transform(()=>{return})),ri=l({redirect_uris:m(de),token_endpoint_auth_method:a().optional(),grant_types:m(a()).optional(),response_types:m(a()).optional(),application_type:a().optional(),client_name:a().optional(),client_uri:de.optional(),logo_uri:al,scope:a().optional(),contacts:m(a()).optional(),tos_uri:al,policy_uri:a().optional(),jwks_uri:de.optional(),jwks:Wo().optional(),software_id:a().optional(),software_version:a().optional(),software_statement:a().optional()}).strip(),ni=l({client_id:a(),client_secret:a().optional(),client_id_issued_at:_().optional(),client_secret_expires_at:_().optional(),issuer:a().optional().catch(void 0)}).strip(),si=ri.merge(ni),Ia=l({error:a(),error_description:a().optional()}).strip(),Oa=l({token:a(),token_type_hint:a().optional()}).strip();var pl=Symbol.for("mcp.sdk.errorBrands");function Bt(e,t){let o=new Set,r=t;while(typeof r==="function"){let n=r.mcpBrand;if(Object.prototype.hasOwnProperty.call(r,"mcpBrand")&&typeof n==="string")o.add(n);r=Object.getPrototypeOf(r)}if(o.size===0)return;Object.defineProperty(e,pl,{value:o,enumerable:!1,configurable:!0})}function Pe(e,t){try{if(typeof t==="object"&&t!==null&&Object.prototype.hasOwnProperty.call(e,"mcpBrand")&&typeof e.mcpBrand==="string"&&Object.prototype.hasOwnProperty.call(t,pl)){let o=t[pl];if(o&&typeof o.has==="function"&&o.has(e.mcpBrand))return!0}}catch{}return Function.prototype[Symbol.hasInstance].call(e,t)}var hm=class e extends Error{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.OAuthError"})}static[Symbol.hasInstance](t){return Pe(this,t)}static isInstance(t){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 Pe(this,t)}constructor(t,o,r){super(o);this.code=t,this.errorUri=r,this.name="OAuthError",Bt(this,new.target)}toResponseObject(){let t={error:this.code,error_description:this.message};if(this.errorUri)t.error_uri=this.errorUri;return t}static fromResponse(t){return new e(t.error,t.error_description??t.error,t.error_uri)}},M=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}({}),k=class extends Error{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.SdkError"})}static[Symbol.hasInstance](e){return Pe(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 Pe(this,e)}constructor(e,t,o,r){super(t,r);this.code=e,this.data=o,this.name="SdkError",Bt(this,new.target)}},di=class extends k{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.SdkHttpError"})}constructor(e,t,o,r){super(e,t,o,r);this.name="SdkHttpError"}get status(){return this.data.status}get statusText(){return this.data.statusText}};var mm="2026-07-28",Sl=[mm];function Ct(e){return e>=mm}function _l(e){return e.filter((t)=>!Ct(t))}function pi(e){return e.filter((t)=>Ct(t))}function fm(e){let t=e.structuredContent;if(t===void 0)return e;if(!(typeof t!=="object"||t===null||Array.isArray(t)))return e;if(e.content?.some((o)=>o.type==="text")??!1)return e;return{...e,content:[...e.content??[],{type:"text",text:JSON.stringify(t)}]}}var gm=["task","inputRequests","requestState"];function pS(e){if(e===null||typeof e!=="object"||Array.isArray(e)||e.content!==void 0||gm.some((t)=>(t in e)))return e;return{...e,content:[]}}function hS(){let e=yn(()=>v([a(),_(),z(),po(),y(a(),e),m(e)])),t=y(a(),e),o=v([a(),_().int()]),r=a(),n=l({ttl:_().optional()}),i=l({taskId:a()}),s=N({progressToken:o.optional(),"io.modelcontextprotocol/related-task":i.optional()}),c=l({_meta:s.optional()}),d=c.extend({task:n.optional()}),p=l({method:a(),params:c.loose().optional()}),h=l({_meta:s.optional()}),f=l({method:a(),params:h.loose().optional()}),S=N({_meta:s.optional()}),b=v([a(),_().int()]),R=S.strict(),w=h.extend({requestId:b.optional(),reason:a().optional()}),O=f.extend({method:u("notifications/cancelled"),params:w}),J=l({src:a(),mimeType:a().optional(),sizes:m(a()).optional(),theme:D(["light","dark"]).optional()}),B=l({icons:m(J).optional()}),j=l({name:a(),title:a().optional()}),F=j.extend({...j.shape,...B.shape,version:a(),websiteUrl:a().optional(),description:a().optional()}),Y=yt(l({applyDefaults:z().optional()}),t),K=ho((ge)=>{if(ge&&typeof ge==="object"&&!Array.isArray(ge)&&Object.keys(ge).length===0)return{form:{}};return ge},yt(l({form:Y.optional(),url:t.optional()}),t.optional())),ie=N({list:t.optional(),cancel:t.optional(),requests:N({sampling:N({createMessage:t.optional()}).optional(),elicitation:N({create:t.optional()}).optional()}).optional()}),Le=N({list:t.optional(),cancel:t.optional(),requests:N({tools:N({call:t.optional()}).optional()}).optional()}),ce=l({experimental:y(a(),t).optional(),sampling:l({context:t.optional(),tools:t.optional()}).optional(),elicitation:K.optional(),roots:l({listChanged:z().optional()}).optional(),tasks:ie.optional(),extensions:y(a(),t).optional()}),Ue=c.extend({protocolVersion:a(),capabilities:ce,clientInfo:F}),We=p.extend({method:u("initialize"),params:Ue}),It=l({experimental:y(a(),t).optional(),logging:t.optional(),completions:t.optional(),prompts:l({listChanged:z().optional()}).optional(),resources:l({subscribe:z().optional(),listChanged:z().optional()}).optional(),tools:l({listChanged:z().optional()}).optional(),tasks:Le.optional(),extensions:y(a(),t).optional()}),Ot=S.extend({protocolVersion:a(),capabilities:It,serverInfo:F,instructions:a().optional()}),et=f.extend({method:u("notifications/initialized"),params:h.optional()}),Ze=p.extend({method:u("ping"),params:c.optional()}),tt=l({progress:_(),total:q(_()),message:q(a())}),xe=l({...h.shape,...tt.shape,progressToken:o}),De=f.extend({method:u("notifications/progress"),params:xe}),ot=c.extend({cursor:r.optional()}),ke=p.extend({params:ot.optional()}),_e=S.extend({nextCursor:r.optional()}),St=l({uri:a(),mimeType:q(a()),_meta:y(a(),P()).optional()}),_t=St.extend({text:a()}),rt=a().refine((ge)=>{try{return atob(ge),!0}catch{return!1}},{message:"Invalid Base64 string"}),me=St.extend({blob:rt}),be=D(["user","assistant"]),ye=l({audience:m(be).optional(),priority:_().min(0).max(1).optional(),lastModified:Jo({offset:!0}).optional()}),Ke=l({...j.shape,...B.shape,uri:a(),description:q(a()),mimeType:q(a()),size:q(_()),annotations:ye.optional(),_meta:q(N({}))}),Gt=l({...j.shape,...B.shape,uriTemplate:a(),description:q(a()),mimeType:q(a()),annotations:ye.optional(),_meta:q(N({}))}),$e=ke.extend({method:u("resources/list")}),Ce=_e.extend({resources:m(Ke)}),Ee=ke.extend({method:u("resources/templates/list")}),He=_e.extend({resourceTemplates:m(Gt)}),Fe=c.extend({uri:a()}),nt=Fe,st=p.extend({method:u("resources/read"),params:nt}),Mt=S.extend({contents:m(v([_t,me]))}),it=f.extend({method:u("notifications/resources/list_changed"),params:h.optional()}),Yt=Fe,E=p.extend({method:u("resources/subscribe"),params:Yt}),at=Fe,A=p.extend({method:u("resources/unsubscribe"),params:at}),C=h.extend({uri:a()}),H=f.extend({method:u("notifications/resources/updated"),params:C}),T=l({name:a(),description:q(a()),required:q(z())}),x=l({...j.shape,...B.shape,description:q(a()),arguments:q(m(T)),_meta:q(N({}))}),Z=ke.extend({method:u("prompts/list")}),L=_e.extend({prompts:m(x)}),le=c.extend({name:a(),arguments:y(a(),a()).optional()}),Qt=p.extend({method:u("prompts/get"),params:le}),ct=l({type:u("text"),text:a(),annotations:ye.optional(),_meta:y(a(),P()).optional()}),Xt=l({type:u("image"),data:rt,mimeType:a(),annotations:ye.optional(),_meta:y(a(),P()).optional()}),eo=l({type:u("audio"),data:rt,mimeType:a(),annotations:ye.optional(),_meta:y(a(),P()).optional()}),$r=l({type:u("tool_use"),name:a(),id:a(),input:y(a(),P()),_meta:y(a(),P()).optional()}),qt=l({type:u("resource"),resource:v([_t,me]),annotations:ye.optional(),_meta:y(a(),P()).optional()}),Cr=Ke.extend({type:u("resource_link")}),Ve=v([ct,Xt,eo,Cr,qt]),Co=l({role:be,content:Ve}),Io=S.extend({description:a().optional(),messages:m(Co)}),to=f.extend({method:u("notifications/prompts/list_changed"),params:h.optional()}),Ir=l({title:a().optional(),readOnlyHint:z().optional(),destructiveHint:z().optional(),idempotentHint:z().optional(),openWorldHint:z().optional()}),Oo=l({taskSupport:D(["required","optional","forbidden"]).optional()}),oo=l({...j.shape,...B.shape,description:a().optional(),inputSchema:l({type:u("object"),properties:y(a(),e).optional(),required:m(a()).optional()}).catchall(P()),outputSchema:l({type:u("object"),properties:y(a(),e).optional(),required:m(a()).optional()}).catchall(P()).optional(),annotations:Ir.optional(),execution:Oo.optional(),_meta:y(a(),P()).optional()}),Mo=ke.extend({method:u("tools/list")}),qo=_e.extend({tools:m(oo)}),No=S.extend({content:m(Ve),structuredContent:y(a(),P()).optional(),isError:z().optional()}),fe=d.extend({name:a(),arguments:y(a(),P()).optional()}),Or=p.extend({method:u("tools/call"),params:fe}),vi=f.extend({method:u("notifications/tools/list_changed"),params:h.optional()}),Ao=D(["debug","info","notice","warning","error","critical","alert","emergency"]),Mr=c.extend({level:Ao}),qr=p.extend({method:u("logging/setLevel"),params:Mr}),Nr=h.extend({level:Ao,logger:a().optional(),data:P()}),Ar=f.extend({method:u("notifications/message"),params:Nr}),jr=l({name:a().optional()}),Lr=l({hints:m(jr).optional(),costPriority:_().min(0).max(1).optional(),speedPriority:_().min(0).max(1).optional(),intelligencePriority:_().min(0).max(1).optional()}),Ur=l({mode:D(["auto","required","none"]).optional()}),zi=l({type:u("tool_result"),toolUseId:a().describe("The unique identifier for the corresponding tool call."),content:m(Ve),structuredContent:l({}).loose().optional(),isError:z().optional(),_meta:y(a(),P()).optional()}),Zr=Ko("type",[ct,Xt,eo]),Nt=Ko("type",[ct,Xt,eo,$r,zi]),Dr=l({role:be,content:v([Nt,m(Nt)]),_meta:y(a(),P()).optional()}),Hr=d.extend({messages:m(Dr),modelPreferences:Lr.optional(),systemPrompt:a().optional(),includeContext:D(["none","thisServer","allServers"]).optional(),temperature:_().optional(),maxTokens:_().int(),stopSequences:m(a()).optional(),metadata:t.optional(),tools:m(oo).optional(),toolChoice:Ur.optional()}),Fr=p.extend({method:u("sampling/createMessage"),params:Hr}),Vr=S.extend({model:a(),stopReason:q(D(["endTurn","stopSequence","maxTokens"]).or(a())),role:be,content:Zr}),Jr=S.extend({model:a(),stopReason:q(D(["endTurn","stopSequence","maxTokens","toolUse"]).or(a())),role:be,content:v([Nt,m(Nt)])}),Br=l({type:u("boolean"),title:a().optional(),description:a().optional(),default:z().optional()}),Wr=l({type:u("string"),title:a().optional(),description:a().optional(),minLength:_().optional(),maxLength:_().optional(),format:D(["email","uri","date","date-time"]).optional(),default:a().optional()}),Kr=l({type:D(["number","integer"]),title:a().optional(),description:a().optional(),minimum:_().optional(),maximum:_().optional(),default:_().optional()}),Gr=l({type:u("string"),title:a().optional(),description:a().optional(),enum:m(a()),default:a().optional()}),Yr=l({type:u("string"),title:a().optional(),description:a().optional(),oneOf:m(l({const:a(),title:a()})),default:a().optional()}),Qr=l({type:u("string"),title:a().optional(),description:a().optional(),enum:m(a()),enumNames:m(a()).optional(),default:a().optional()}),Xr=v([Gr,Yr]),ro=l({type:u("array"),title:a().optional(),description:a().optional(),minItems:_().optional(),maxItems:_().optional(),items:l({type:u("string"),enum:m(a())}),default:m(a()).optional()}),no=l({type:u("array"),title:a().optional(),description:a().optional(),minItems:_().optional(),maxItems:_().optional(),items:l({anyOf:m(l({const:a(),title:a()}))}),default:m(a()).optional()}),Ri=v([ro,no]),wi=v([Qr,Xr,Ri]),Ie=v([wi,Br,Wr,Kr]),Oe=d.extend({mode:u("form").optional(),message:a(),requestedSchema:l({type:u("object"),properties:y(a(),Ie),required:m(a()).optional()}).catchall(P())}),en=d.extend({mode:u("url"),message:a(),elicitationId:a(),url:a().url()}),Ge=v([Oe,en]),xi=p.extend({method:u("elicitation/create"),params:Ge}),Ei=h.extend({elicitationId:a()}),Ti=f.extend({method:u("notifications/elicitation/complete"),params:Ei}),Pi=S.extend({action:D(["accept","decline","cancel"]),content:ho((ge)=>ge===null?void 0:ge,y(a(),v([a(),_(),z(),m(a())])).optional())}),ki=l({type:u("ref/resource"),uri:a()}),$i=l({type:u("ref/prompt"),name:a()}),Ci=c.extend({ref:v([$i,ki]),argument:l({name:a(),value:a()}),context:l({arguments:y(a(),a()).optional()}).optional()}),tn=p.extend({method:u("completion/complete"),params:Ci}),Ii=S.extend({completion:N({values:m(a()).max(100),total:q(_().int()),hasMore:q(z())})}),Oi=l({uri:a().startsWith("file://"),name:a().optional(),_meta:y(a(),P()).optional()}),jo=p.extend({method:u("roots/list"),params:c.optional()}),on=S.extend({roots:m(Oi)}),Mi=f.extend({method:u("notifications/roots/list_changed"),params:h.optional()}),qi=N({ttl:_().optional(),pollInterval:_().optional()}),rn=D(["working","input_required","completed","failed","cancelled"]),At=l({taskId:a(),status:rn,ttl:v([_(),po()]),createdAt:a(),lastUpdatedAt:a(),pollInterval:q(_()),statusMessage:q(a())}),Te=S.extend({task:At}),Ni=h.merge(At),so=f.extend({method:u("notifications/tasks/status"),params:Ni}),Lo=p.extend({method:u("tasks/get"),params:c.extend({taskId:a()})}),Uo=S.merge(At),Zo=p.extend({method:u("tasks/result"),params:c.extend({taskId:a()})}),Ga=S.loose(),ve=ke.extend({method:u("tasks/list")}),ae=_e.extend({tasks:m(At)}),io=p.extend({method:u("tasks/cancel"),params:c.extend({taskId:a()})});return{JSONValueSchema:e,JSONObjectSchema:t,ProgressTokenSchema:o,CursorSchema:r,TaskMetadataSchema:n,RelatedTaskMetadataSchema:i,RequestMetaSchema:s,BaseRequestParamsSchema:c,TaskAugmentedRequestParamsSchema:d,RequestSchema:p,NotificationsParamsSchema:h,NotificationSchema:f,ResultSchema:S,RequestIdSchema:b,EmptyResultSchema:R,CancelledNotificationParamsSchema:w,CancelledNotificationSchema:O,IconSchema:J,IconsSchema:B,BaseMetadataSchema:j,ImplementationSchema:F,ClientTasksCapabilitySchema:ie,ServerTasksCapabilitySchema:Le,ClientCapabilitiesSchema:ce,InitializeRequestParamsSchema:Ue,InitializeRequestSchema:We,ServerCapabilitiesSchema:It,InitializeResultSchema:Ot,InitializedNotificationSchema:et,PingRequestSchema:Ze,ProgressSchema:tt,ProgressNotificationParamsSchema:xe,ProgressNotificationSchema:De,PaginatedRequestParamsSchema:ot,PaginatedRequestSchema:ke,PaginatedResultSchema:_e,ResourceContentsSchema:St,TextResourceContentsSchema:_t,BlobResourceContentsSchema:me,RoleSchema:be,AnnotationsSchema:ye,ResourceSchema:Ke,ResourceTemplateSchema:Gt,ListResourcesRequestSchema:$e,ListResourcesResultSchema:Ce,ListResourceTemplatesRequestSchema:Ee,ListResourceTemplatesResultSchema:He,ResourceRequestParamsSchema:Fe,ReadResourceRequestParamsSchema:nt,ReadResourceRequestSchema:st,ReadResourceResultSchema:Mt,ResourceListChangedNotificationSchema:it,SubscribeRequestParamsSchema:Yt,SubscribeRequestSchema:E,UnsubscribeRequestParamsSchema:at,UnsubscribeRequestSchema:A,ResourceUpdatedNotificationParamsSchema:C,ResourceUpdatedNotificationSchema:H,PromptArgumentSchema:T,PromptSchema:x,ListPromptsRequestSchema:Z,ListPromptsResultSchema:L,GetPromptRequestParamsSchema:le,GetPromptRequestSchema:Qt,TextContentSchema:ct,ImageContentSchema:Xt,AudioContentSchema:eo,ToolUseContentSchema:$r,EmbeddedResourceSchema:qt,ResourceLinkSchema:Cr,ContentBlockSchema:Ve,PromptMessageSchema:Co,GetPromptResultSchema:Io,PromptListChangedNotificationSchema:to,ToolAnnotationsSchema:Ir,ToolExecutionSchema:Oo,ToolSchema:oo,ListToolsRequestSchema:Mo,ListToolsResultSchema:qo,CallToolResultSchema:No,CallToolRequestParamsSchema:fe,CallToolRequestSchema:Or,ToolListChangedNotificationSchema:vi,LoggingLevelSchema:Ao,SetLevelRequestParamsSchema:Mr,SetLevelRequestSchema:qr,LoggingMessageNotificationParamsSchema:Nr,LoggingMessageNotificationSchema:Ar,ModelHintSchema:jr,ModelPreferencesSchema:Lr,ToolChoiceSchema:Ur,ToolResultContentSchema:zi,SamplingContentSchema:Zr,SamplingMessageContentBlockSchema:Nt,SamplingMessageSchema:Dr,CreateMessageRequestParamsSchema:Hr,CreateMessageRequestSchema:Fr,CreateMessageResultSchema:Vr,CreateMessageResultWithToolsSchema:Jr,BooleanSchemaSchema:Br,StringSchemaSchema:Wr,NumberSchemaSchema:Kr,UntitledSingleSelectEnumSchemaSchema:Gr,TitledSingleSelectEnumSchemaSchema:Yr,LegacyTitledEnumSchemaSchema:Qr,SingleSelectEnumSchemaSchema:Xr,UntitledMultiSelectEnumSchemaSchema:ro,TitledMultiSelectEnumSchemaSchema:no,MultiSelectEnumSchemaSchema:Ri,EnumSchemaSchema:wi,PrimitiveSchemaDefinitionSchema:Ie,ElicitRequestFormParamsSchema:Oe,ElicitRequestURLParamsSchema:en,ElicitRequestParamsSchema:Ge,ElicitRequestSchema:xi,ElicitationCompleteNotificationParamsSchema:Ei,ElicitationCompleteNotificationSchema:Ti,ElicitResultSchema:Pi,ResourceTemplateReferenceSchema:ki,PromptReferenceSchema:$i,CompleteRequestParamsSchema:Ci,CompleteRequestSchema:tn,CompleteResultSchema:Ii,RootSchema:Oi,ListRootsRequestSchema:jo,ListRootsResultSchema:on,RootsListChangedNotificationSchema:Mi,TaskCreationParamsSchema:qi,TaskStatusSchema:rn,TaskSchema:At,CreateTaskResultSchema:Te,TaskStatusNotificationParamsSchema:Ni,TaskStatusNotificationSchema:so,GetTaskRequestSchema:Lo,GetTaskResultSchema:Uo,GetTaskPayloadRequestSchema:Zo,GetTaskPayloadResultSchema:Ga,ListTasksRequestSchema:ve,ListTasksResultSchema:ae,CancelTaskRequestSchema:io,CancelTaskResultSchema:S.merge(At),ClientRequestSchema:v([Ze,We,tn,qr,Qt,Z,$e,Ee,st,E,A,Or,Mo,Lo,Zo,ve,io]),ClientNotificationSchema:v([O,De,et,Mi,so]),ClientResultSchema:v([R,Vr,Jr,Pi,on,Uo,ae,Te]),ServerRequestSchema:v([Ze,Fr,xi,jo,Lo,Zo,ve,io]),ServerNotificationSchema:v([O,De,Ar,H,it,vi,to,so,Ti]),ServerResultSchema:v([R,Ot,Ii,Io,L,Ce,He,Mt,No,qo,Uo,ae,Te]),CallToolResultWireSchema:P().superRefine((ge,Of)=>{if(typeof ge!=="object"||ge===null||Array.isArray(ge)||ge.content!==void 0)return;for(let Zl of gm)if(Zl in ge){Of.addIssue({code:"custom",message:`content is required when the body carries '${Zl}' — another result family cannot default into an empty tools/call success`});return}}).transform(pS).pipe(No)}}var mS;function Sm(){return mS??=hS()}function _m(e){return e.type!=="object"}var fS=new Set(["const","enum","default","examples"]),gS=new Set(["properties","patternProperties","$defs","definitions","dependentSchemas","dependencies"]);function tm(e){return e!==void 0&&!(typeof e==="string"&&e.startsWith("#"))}function SS(e){let t=typeof e.$schema==="string"?e.$schema:void 0;if(tm(e.$id))return{...t!==void 0&&{$schema:t},type:"object",properties:{result:e},required:["result"]};let o=Jl(e.$schema)&&e.$recursiveAnchor!==!0,r=(n,i)=>{if(Array.isArray(n))return n.map((d)=>r(d,!1));if(n===null||typeof n!=="object")return n;if(!i&&tm(n.$id))return n;let s={},c=!1;for(let[d,p]of Object.entries(n))if(i)s[d]=r(p,!1);else if((d==="$ref"||d==="$dynamicRef")&&typeof p==="string")s[d]=p==="#"?"#/properties/result":p.startsWith("#/")?`#/properties/result${p.slice(1)}`:p;else if(d==="$recursiveRef"&&p==="#"&&o)c=!0;else if(fS.has(d))s[d]=p;else if(gS.has(d))s[d]=r(p,!0);else s[d]=r(p,!1);if(c)if("$ref"in s)s.allOf=[...Array.isArray(s.allOf)?s.allOf:[],{$ref:"#/properties/result"}];else s.$ref="#/properties/result";return s};return{...t!==void 0&&{$schema:t},type:"object",properties:{result:r(e,!1)},required:["result"]}}var bm={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},ym={"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},_S={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},Ma;function bl(){if(Ma)return Ma;let e=Sm();return Ma={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}},Ma}function vm(e){return Object.prototype.hasOwnProperty.call(bm,e)}function zm(e){return Object.prototype.hasOwnProperty.call(ym,e)}function bS(e){return Object.prototype.hasOwnProperty.call(_S,e)}function yS(e){return bS(e)?bl().resultSchemas[e]:void 0}function vS(e){return vm(e)?bl().requestSchemas[e]:void 0}function zS(e){return zm(e)?bl().notificationSchemas[e]:void 0}var uR=Object.keys(bm),dR=Object.keys(ym);function hl(e){return e!==null&&typeof e==="object"&&!Array.isArray(e)}function qa(e,t){if(e===void 0)return{ok:!1,reason:"not-in-era"};let o=e.safeParse(t);return o.success?{ok:!0,value:o.data}:{ok:!1,reason:"invalid",message:String(o.error)}}var om={ok:!1,reason:"not-in-era"};function rm(e){return hl(e)&&hl(e.outputSchema)&&_m(e.outputSchema)}function nm(e){return e}var yl={era:"2025-11-25",hasRequestMethod:vm,hasNotificationMethod:zm,validateRequest:(e,t)=>qa(vS(e),t),validateResult:(e,t)=>qa(yS(e),t),validateNotification:(e,t)=>qa(zS(e),t),hasInputRequestMethod:()=>!1,validateInputRequest:()=>om,validateInputResponse:()=>om,samplingResultVariant:(e,t)=>{let o=Sm();return qa(e?o.CreateMessageResultWithToolsSchema:o.CreateMessageResultSchema,t)},outboundEnvelope:(e)=>{return},validateEnvelopeMeta:(e)=>[],projectCallToolResult(e,t){let o=fm(e),r=o.structuredContent;if(r===void 0)return o;let n=typeof r!=="object"||r===null||Array.isArray(r),i=t!==void 0&&_m(t);if(!n&&!i)return o;return{...o,structuredContent:{result:r}}},decodeResult(e,t){if(hl(t)&&"resultType"in t){let o={...t};return delete o.resultType,{kind:"complete",result:nm(o)}}return{kind:"complete",result:nm(t)}},encodeResult(e,t){if(e!=="tools/list")return t;let o=t.tools;if(!Array.isArray(o)||!o.some((r)=>rm(r)))return t;return{...t,tools:o.map((r)=>rm(r)?{...r,outputSchema:SS(r.outputSchema)}:r)}},encodeErrorCode:(e)=>e===-32002?-32602:e,checkInboundEnvelope:(e)=>{return}};function RS(){let e=yn(()=>v([a(),_(),z(),po(),y(a(),e),m(e)])),t=y(a(),e),o=v([a(),_().int()]),r=a(),n=v([a(),_().int()]),i=D(["user","assistant"]),s=D(["debug","info","notice","warning","error","critical","alert","emergency"]),c=a().refine((ae)=>{try{return atob(ae),!0}catch{return!1}},{message:"Invalid Base64 string"}),d=l({ttl:_().optional()}),p=l({taskId:a()}),h=N({progressToken:o.optional(),"io.modelcontextprotocol/related-task":p.optional()}),f=l({_meta:h.optional()}),S=f.extend({task:d.optional()}),b=l({_meta:h.optional()}),R=l({method:a(),params:b.loose().optional()}),w=l({src:a(),mimeType:a().optional(),sizes:m(a()).optional(),theme:D(["light","dark"]).optional()}),O=l({icons:m(w).optional()}),J=l({name:a(),title:a().optional()}),B=J.extend({...J.shape,...O.shape,version:a(),websiteUrl:a().optional(),description:a().optional()}),j=yt(l({applyDefaults:z().optional()}),t),F=ho((ae)=>{if(ae&&typeof ae==="object"&&!Array.isArray(ae)&&Object.keys(ae).length===0)return{form:{}};return ae},yt(l({form:j.optional(),url:t.optional()}),t.optional())),Y=N({list:t.optional(),cancel:t.optional(),requests:N({sampling:N({createMessage:t.optional()}).optional(),elicitation:N({create:t.optional()}).optional()}).optional()}),K=N({list:t.optional(),cancel:t.optional(),requests:N({tools:N({call:t.optional()}).optional()}).optional()}),ie=l({experimental:y(a(),t).optional(),sampling:l({context:t.optional(),tools:t.optional()}).optional(),elicitation:F.optional(),roots:l({listChanged:z().optional()}).optional(),tasks:Y.optional(),extensions:y(a(),t).optional()}),Le=l({experimental:y(a(),t).optional(),logging:t.optional(),completions:t.optional(),prompts:l({listChanged:z().optional()}).optional(),resources:l({subscribe:z().optional(),listChanged:z().optional()}).optional(),tools:l({listChanged:z().optional()}).optional(),tasks:K.optional(),extensions:y(a(),t).optional()}),ce=l({progress:_(),total:q(_()),message:q(a())}),Ue=l({...b.shape,...ce.shape,progressToken:o}),We=R.extend({method:u("notifications/progress"),params:Ue}),It=b.extend({level:s,logger:a().optional(),data:P()}),Ot=R.extend({method:u("notifications/message"),params:It}),et=l({uri:a(),mimeType:q(a()),_meta:y(a(),P()).optional()}),Ze=et.extend({text:a()}),tt=et.extend({blob:c}),xe=l({audience:m(i).optional(),priority:_().min(0).max(1).optional(),lastModified:Jo({offset:!0}).optional()}),De=l({...J.shape,...O.shape,uri:a(),description:q(a()),mimeType:q(a()),size:q(_()),annotations:xe.optional(),_meta:q(N({}))}),ot=l({...J.shape,...O.shape,uriTemplate:a(),description:q(a()),mimeType:q(a()),annotations:xe.optional(),_meta:q(N({}))}),ke=R.extend({method:u("notifications/resources/list_changed"),params:b.optional()}),_e=b.extend({uri:a()}),St=R.extend({method:u("notifications/resources/updated"),params:_e}),_t=l({name:a(),description:q(a()),required:q(z())}),rt=l({...J.shape,...O.shape,description:q(a()),arguments:q(m(_t)),_meta:q(N({}))}),me=R.extend({method:u("notifications/prompts/list_changed"),params:b.optional()}),be=l({type:u("text"),text:a(),annotations:xe.optional(),_meta:y(a(),P()).optional()}),ye=l({type:u("image"),data:c,mimeType:a(),annotations:xe.optional(),_meta:y(a(),P()).optional()}),Ke=l({type:u("audio"),data:c,mimeType:a(),annotations:xe.optional(),_meta:y(a(),P()).optional()}),Gt=l({type:u("tool_use"),name:a(),id:a(),input:y(a(),P()),_meta:y(a(),P()).optional()}),$e=l({type:u("resource"),resource:v([Ze,tt]),annotations:xe.optional(),_meta:y(a(),P()).optional()}),Ce=De.extend({type:u("resource_link")}),Ee=v([be,ye,Ke,Ce,$e]),He=l({role:i,content:Ee}),Fe=l({title:a().optional(),readOnlyHint:z().optional(),destructiveHint:z().optional(),idempotentHint:z().optional(),openWorldHint:z().optional()}),nt=R.extend({method:u("notifications/tools/list_changed"),params:b.optional()}),st=l({name:a().optional()}),Mt=l({hints:m(st).optional(),costPriority:_().min(0).max(1).optional(),speedPriority:_().min(0).max(1).optional(),intelligencePriority:_().min(0).max(1).optional()}),it=l({mode:D(["auto","required","none"]).optional()}),Yt=l({type:u("boolean"),title:a().optional(),description:a().optional(),default:z().optional()}),E=l({type:u("string"),title:a().optional(),description:a().optional(),minLength:_().optional(),maxLength:_().optional(),format:D(["email","uri","date","date-time"]).optional(),default:a().optional()}),at=l({type:D(["number","integer"]),title:a().optional(),description:a().optional(),minimum:_().optional(),maximum:_().optional(),default:_().optional()}),A=l({type:u("string"),title:a().optional(),description:a().optional(),enum:m(a()),default:a().optional()}),C=l({type:u("string"),title:a().optional(),description:a().optional(),oneOf:m(l({const:a(),title:a()})),default:a().optional()}),H=l({type:u("string"),title:a().optional(),description:a().optional(),enum:m(a()),enumNames:m(a()).optional(),default:a().optional()}),T=v([A,C]),x=l({type:u("array"),title:a().optional(),description:a().optional(),minItems:_().optional(),maxItems:_().optional(),items:l({type:u("string"),enum:m(a())}),default:m(a()).optional()}),Z=l({type:u("array"),title:a().optional(),description:a().optional(),minItems:_().optional(),maxItems:_().optional(),items:l({anyOf:m(l({const:a(),title:a()}))}),default:m(a()).optional()}),L=v([x,Z]),le=v([H,T,L]),Qt=v([le,Yt,E,at]),ct=S.extend({mode:u("form").optional(),message:a(),requestedSchema:l({type:u("object"),properties:y(a(),Qt),required:m(a()).optional()}).catchall(P())}),Xt=l({type:u("ref/resource"),uri:a()}),eo=l({type:u("ref/prompt"),name:a()}),$r=l({uri:a().startsWith("file://"),name:a().optional(),_meta:y(a(),P()).optional()}),qt=ie.shape,Cr=l({experimental:qt.experimental,sampling:qt.sampling,elicitation:qt.elicitation,roots:qt.roots,extensions:qt.extensions}),Ve=Le.shape,Co=l({experimental:Ve.experimental,logging:Ve.logging,completions:Ve.completions,prompts:Ve.prompts,resources:Ve.resources,tools:Ve.tools,extensions:Ve.extensions}),Io=N({progressToken:o.optional(),[mo]:a(),[Go]:B.optional(),[fo]:Cr,[Qo]:s.optional()}),to=l({...J.shape,...O.shape,description:a().optional(),inputSchema:N({$schema:a().optional(),type:u("object")}),outputSchema:N({$schema:a().optional()}).optional(),annotations:Fe.optional(),_meta:y(a(),P()).optional()}),Ir=l({type:u("tool_result"),toolUseId:a(),content:m(Ee),structuredContent:P().optional(),isError:z().optional(),_meta:y(a(),P()).optional()}),Oo=v([be,ye,Ke,Gt,Ir]),oo=l({role:i,content:v([Oo,m(Oo)]),_meta:y(a(),P()).optional()}),Mo=a(),qo=N({[dt]:B.optional().catch(void 0)}),No=qo.optional();function fe(ae){return N({_meta:No,resultType:Mo.default("complete"),...ae})}let Or=fe({}),vi=fe({nextCursor:r.optional()}),Ao=fe({content:m(Ee),structuredContent:P().optional(),isError:z().optional()}),Mr=fe({ttlMs:_().int().min(0),cacheScope:D(["public","private"]),tools:m(to),nextCursor:r.optional()}),qr=fe({ttlMs:_().int().min(0),cacheScope:D(["public","private"]),prompts:m(rt),nextCursor:r.optional()}),Nr=fe({description:a().optional(),messages:m(He)}),Ar=fe({ttlMs:_().int().min(0),cacheScope:D(["public","private"]),resources:m(De),nextCursor:r.optional()}),jr=fe({ttlMs:_().int().min(0),cacheScope:D(["public","private"]),resourceTemplates:m(ot),nextCursor:r.optional()}),Lr=fe({ttlMs:_().int().min(0),cacheScope:D(["public","private"]),contents:m(v([Ze,tt]))}),Ur=fe({completion:l({values:m(a()).max(100),total:_().int().optional(),hasMore:z().optional()}).loose()}),zi=fe({ttlMs:_().int().min(0),cacheScope:D(["public","private"])}),Zr=fe({ttlMs:_().int().min(0).catch(0),cacheScope:D(["public","private"]).catch("private"),supportedVersions:m(a()),capabilities:Co,instructions:a().optional()}),Nt=l({messages:m(oo),modelPreferences:Mt.optional(),systemPrompt:a().optional(),includeContext:D(["none","thisServer","allServers"]).optional(),temperature:_().optional(),maxTokens:_().int(),stopSequences:m(a()).optional(),metadata:t.optional(),tools:m(to).optional(),toolChoice:it.optional()}),Dr=l({method:u("sampling/createMessage"),params:Nt}),Hr=l({method:u("roots/list"),params:l({_meta:y(a(),P()).optional()}).optional()}),Fr=l({...oo.shape,model:a(),stopReason:a().optional()}),Vr=l({roots:m($r)}),Jr=l({action:D(["accept","decline","cancel"]),content:y(a(),v([a(),_(),z(),m(a())])).optional()}),Br=l({mode:u("url"),message:a(),url:a().url()}),Wr=v([ct,Br]),Kr=l({method:u("elicitation/create"),params:Wr}),Gr=v([Dr,Hr,Kr]),Yr=v([Fr,Vr,Jr]),Qr=y(a(),Gr),Xr=y(a(),Yr),ro=fe({inputRequests:Qr.optional(),requestState:a().optional()}),no={inputResponses:Xr.optional(),requestState:a().optional()},Ri=l({_meta:Io,...no}),wi=N({progressToken:o.optional()});function Ie(ae,io){return l({method:u(ae),params:l({_meta:Io,...io})})}function Oe(ae,io){return l({method:u(ae),params:l({_meta:wi.optional(),...io}).optional()})}let en={name:a(),arguments:y(a(),P()).optional(),...no},Ge={cursor:r.optional()},xi=Ie("tools/call",en),Ei=Ie("tools/list",Ge),Ti=Ie("prompts/list",Ge),Pi=Ie("prompts/get",{name:a(),arguments:y(a(),a()).optional(),...no}),ki=Ie("resources/list",Ge),$i=Ie("resources/templates/list",Ge),Ci=Ie("resources/read",{uri:a(),...no}),tn={ref:v([eo,Xt]),argument:l({name:a(),value:a()}),context:l({arguments:y(a(),a()).optional()}).optional()},Ii=Ie("completion/complete",tn),Oi=Ie("server/discover",{}),jo=l({toolsListChanged:z().optional(),promptsListChanged:z().optional(),resourcesListChanged:z().optional(),resourceSubscriptions:m(a()).optional()}),on={notifications:jo},Mi=Ie("subscriptions/listen",on),qi=qo.extend({"io.modelcontextprotocol/subscriptionId":n}),rn=N({_meta:qi,resultType:Mo.default("complete")}),At={"tools/call":Oe("tools/call",en),"tools/list":Oe("tools/list",Ge),"prompts/get":Oe("prompts/get",{name:a(),arguments:y(a(),a()).optional()}),"prompts/list":Oe("prompts/list",Ge),"resources/list":Oe("resources/list",Ge),"resources/templates/list":Oe("resources/templates/list",Ge),"resources/read":Oe("resources/read",{uri:a()}),"completion/complete":Oe("completion/complete",tn),"server/discover":Oe("server/discover",{}),"subscriptions/listen":Oe("subscriptions/listen",on)};function Te(ae){return N({_meta:No,...ae})}let Ni={"tools/call":Te({content:m(Ee),structuredContent:P().optional(),isError:z().optional()}),"tools/list":Te({ttlMs:_().int().min(0),cacheScope:D(["public","private"]),tools:m(to),nextCursor:r.optional()}),"prompts/get":Te({description:a().optional(),messages:m(He)}),"prompts/list":Te({ttlMs:_().int().min(0),cacheScope:D(["public","private"]),prompts:m(rt),nextCursor:r.optional()}),"resources/list":Te({ttlMs:_().int().min(0),cacheScope:D(["public","private"]),resources:m(De),nextCursor:r.optional()}),"resources/templates/list":Te({ttlMs:_().int().min(0),cacheScope:D(["public","private"]),resourceTemplates:m(ot),nextCursor:r.optional()}),"resources/read":Te({ttlMs:_().int().min(0),cacheScope:D(["public","private"]),contents:m(v([Ze,tt]))}),"completion/complete":Te({completion:l({values:m(a()).max(100),total:_().int().optional(),hasMore:z().optional()}).loose()}),"server/discover":Te({ttlMs:_().int().min(0).catch(0),cacheScope:D(["public","private"]).catch("private"),supportedVersions:m(a()),capabilities:Co,instructions:a().optional()}),"subscriptions/listen":Te({})},so=N({"io.modelcontextprotocol/subscriptionId":n.optional()}),Lo=l({method:u("notifications/subscriptions/acknowledged"),params:l({_meta:so.optional(),notifications:jo})}),Uo=l({_meta:so.optional(),requestId:n,reason:a().optional()}),Zo=l({method:u("notifications/cancelled"),params:Uo}),Ga={"notifications/cancelled":Zo,"notifications/progress":We,"notifications/message":Ot,"notifications/resources/updated":St,"notifications/resources/list_changed":ke,"notifications/tools/list_changed":nt,"notifications/prompts/list_changed":me,"notifications/subscriptions/acknowledged":Lo},ve=(ae)=>l({jsonrpc:u("2.0"),id:v([a(),_().int()]),result:ae}).strict();return{JSONValueSchema:e,JSONObjectSchema:t,ProgressTokenSchema:o,CursorSchema:r,RequestIdSchema:n,RoleSchema:i,LoggingLevelSchema:s,TaskMetadataSchema:d,RelatedTaskMetadataSchema:p,RequestMetaSchema:h,BaseRequestParamsSchema:f,TaskAugmentedRequestParamsSchema:S,NotificationsParamsSchema:b,NotificationSchema:R,IconSchema:w,IconsSchema:O,BaseMetadataSchema:J,ImplementationSchema:B,ClientTasksCapabilitySchema:Y,ServerTasksCapabilitySchema:K,ClientCapabilitiesSchema:ie,ServerCapabilitiesSchema:Le,ProgressSchema:ce,ProgressNotificationParamsSchema:Ue,ProgressNotificationSchema:We,LoggingMessageNotificationParamsSchema:It,LoggingMessageNotificationSchema:Ot,ResourceContentsSchema:et,TextResourceContentsSchema:Ze,BlobResourceContentsSchema:tt,AnnotationsSchema:xe,ResourceSchema:De,ResourceTemplateSchema:ot,ResourceListChangedNotificationSchema:ke,ResourceUpdatedNotificationParamsSchema:_e,ResourceUpdatedNotificationSchema:St,PromptArgumentSchema:_t,PromptSchema:rt,PromptListChangedNotificationSchema:me,TextContentSchema:be,ImageContentSchema:ye,AudioContentSchema:Ke,ToolUseContentSchema:Gt,EmbeddedResourceSchema:$e,ResourceLinkSchema:Ce,ContentBlockSchema:Ee,PromptMessageSchema:He,ToolAnnotationsSchema:Fe,ToolListChangedNotificationSchema:nt,ModelHintSchema:st,ModelPreferencesSchema:Mt,ToolChoiceSchema:it,BooleanSchemaSchema:Yt,StringSchemaSchema:E,NumberSchemaSchema:at,UntitledSingleSelectEnumSchemaSchema:A,TitledSingleSelectEnumSchemaSchema:C,LegacyTitledEnumSchemaSchema:H,SingleSelectEnumSchemaSchema:T,UntitledMultiSelectEnumSchemaSchema:x,TitledMultiSelectEnumSchemaSchema:Z,MultiSelectEnumSchemaSchema:L,EnumSchemaSchema:le,PrimitiveSchemaDefinitionSchema:Qt,ElicitRequestFormParamsSchema:ct,ResourceTemplateReferenceSchema:Xt,PromptReferenceSchema:eo,RootSchema:$r,ClientCapabilities2026Schema:Cr,ServerCapabilities2026Schema:Co,RequestMetaEnvelopeSchema:Io,ToolSchema:to,ToolResultContentSchema:Ir,SamplingMessageContentBlockSchema:Oo,SamplingMessageSchema:oo,ResultTypeSchema:Mo,ResultMetaSchema:qo,ResultSchema:Or,PaginatedResultSchema:vi,CallToolResultSchema:Ao,ListToolsResultSchema:Mr,ListPromptsResultSchema:qr,GetPromptResultSchema:Nr,ListResourcesResultSchema:Ar,ListResourceTemplatesResultSchema:jr,ReadResourceResultSchema:Lr,CompleteResultSchema:Ur,CacheableResultSchema:zi,DiscoverResultSchema:Zr,CreateMessageRequestParamsSchema:Nt,CreateMessageRequestSchema:Dr,ListRootsRequestSchema:Hr,CreateMessageResultSchema:Fr,ListRootsResultSchema:Vr,ElicitResultSchema:Jr,ElicitRequestURLParamsSchema:Br,ElicitRequestParamsSchema:Wr,ElicitRequestSchema:Kr,InputRequestSchema:Gr,InputResponseSchema:Yr,InputRequestsSchema:Qr,InputResponsesSchema:Xr,InputRequiredResultSchema:ro,InputResponseRequestParamsSchema:Ri,CallToolRequestSchema:xi,ListToolsRequestSchema:Ei,ListPromptsRequestSchema:Ti,GetPromptRequestSchema:Pi,ListResourcesRequestSchema:ki,ListResourceTemplatesRequestSchema:$i,ReadResourceRequestSchema:Ci,CompleteRequestSchema:Ii,DiscoverRequestSchema:Oi,SubscriptionFilterSchema:jo,SubscriptionsListenRequestSchema:Mi,SubscriptionsListenResultMetaSchema:qi,SubscriptionsListenResultSchema:rn,dispatchRequestSchemas:At,dispatchResultSchemas:Ni,NotificationMetaSchema:so,SubscriptionsAcknowledgedNotificationSchema:Lo,CancelledNotificationParamsSchema:Uo,CancelledNotificationSchema:Zo,notificationSchemas2026:Ga,JSONRPCResultResponseSchema:ve(Or),CallToolResultResponseSchema:ve(v([Ao,ro])),ListToolsResultResponseSchema:ve(Mr),ListPromptsResultResponseSchema:ve(qr),GetPromptResultResponseSchema:ve(v([Nr,ro])),ListResourcesResultResponseSchema:ve(Ar),ListResourceTemplatesResultResponseSchema:ve(jr),ReadResourceResultResponseSchema:ve(v([Lr,ro])),CompleteResultResponseSchema:ve(Ur),DiscoverResultResponseSchema:ve(Zr),SubscriptionsListenResultResponseSchema:ve(rn)}}var wS;function Jt(){return wS??=RS()}var xS=["tools/list","prompts/list","resources/list","resources/templates/list","resources/read","server/discover"];function ES(e){return xS.includes(e)}var vl=Symbol("modelcontextprotocol.resultCacheHintFallback");function TS(e){return e[vl]}function Rm(e){return typeof e==="number"&&Number.isSafeInteger(e)&&e>=0}function wm(e){return e==="public"||e==="private"}var U=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}({}),W=class e extends Error{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.ProtocolError"})}static[Symbol.hasInstance](t){return Pe(this,t)}static isInstance(t){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 Pe(this,t)}constructor(t,o,r){super(o);this.code=t,this.data=r,this.name="ProtocolError",Bt(this,new.target)}static fromError(t,o,r){if(t===U.UrlElicitationRequired&&r){let n=r;if(n.elicitations)return new Em(n.elicitations,o)}if(t===U.UnsupportedProtocolVersion&&r){let n=r;if(Array.isArray(n.supported)&&typeof n.requested==="string")return new hi({supported:n.supported,requested:n.requested},o)}if(t===U.InvalidParams||t===U.ResourceNotFound){let n=r;if(typeof n?.uri==="string"&&(t===U.ResourceNotFound||Object.keys(n).length===1))return new xm(n.uri,o)}if(t===U.MissingRequiredClientCapability&&r){let n=r;if(n.requiredCapabilities!==null&&typeof n.requiredCapabilities==="object"&&!Array.isArray(n.requiredCapabilities))return new Tm({requiredCapabilities:n.requiredCapabilities},o)}return new e(t,o,r)}},xm=class extends W{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.ResourceNotFoundError"})}constructor(e,t=`Resource not found: ${e}`){super(U.InvalidParams,t,{uri:e})}get uri(){return this.data.uri}},Em=class extends W{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.UrlElicitationRequiredError"})}constructor(e,t=`URL elicitation${e.length>1?"s":""} required`){super(U.UrlElicitationRequired,t,{elicitations:e})}get elicitations(){return this.data?.elicitations??[]}},hi=class extends W{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.UnsupportedProtocolVersionError"})}constructor(e,t=`Unsupported protocol version: ${e.requested}`){super(U.UnsupportedProtocolVersion,t,e)}get supported(){return this.data.supported}get requested(){return this.data.requested}},Tm=class extends W{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.MissingRequiredClientCapabilityError"})}constructor(e,t=`Missing required client capabilities: ${Object.keys(e.requiredCapabilities).join(", ")}`){super(U.MissingRequiredClientCapability,t,e)}get requiredCapabilities(){return this.data.requiredCapabilities}},PS=0,kS="private",$S=["tools/call","prompts/get","resources/read"];function CS(e,t){let o=t.resultType;if(o===void 0)return{...t,resultType:"complete"};if(o==="complete")return t;if($S.includes(e))return t;throw new W(U.InternalError,`Handler for ${e} returned resultType '${String(o)}', but results of ${e} only support 'complete' on protocol revision 2026-07-28`)}function IS(e,t){let o=TS(t);if(t.resultType!=="complete"||!ES(e))return o===void 0?t:AS(t);let r=t,n=Rm(r.ttlMs)?r.ttlMs:qS(o),i=wm(r.cacheScope)?r.cacheScope:NS(o),s={...r,ttlMs:n,cacheScope:i};return delete s[vl],s}function OS(e){return e!==null&&typeof e==="object"&&!Array.isArray(e)}function MS(e,t){if(t===void 0)return e;let o=e._meta;if(o===void 0)return{...e,_meta:{[dt]:t}};if(!OS(o))return e;if(o[dt]!==void 0)return e;return{...e,_meta:{...o,[dt]:t}}}function qS(e){return e!==void 0&&Rm(e.ttlMs)?e.ttlMs:PS}function NS(e){return e!==void 0&&wm(e.cacheScope)?e.cacheScope:kS}function AS(e){let t={...e};return delete t[vl],t}var jS=["elicitation/create","sampling/createMessage","roots/list"],Na;function Pm(){if(Na)return Na;let e=Jt();return Na={request:{"elicitation/create":l({method:u("elicitation/create"),params:e.ElicitRequestParamsSchema}),"sampling/createMessage":l({method:u("sampling/createMessage"),params:e.CreateMessageRequestParamsSchema}),"roots/list":l({method:u("roots/list"),params:N({}).optional()})},response:{"elicitation/create":e.ElicitResultSchema,"sampling/createMessage":e.CreateMessageResultSchema,"roots/list":e.ListRootsResultSchema}},Na}function km(e){return jS.includes(e)}function cl(e){return km(e)?Pm().request[e]:void 0}function LS(e){return km(e)?Pm().response[e]:void 0}var zl={"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},$m={"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 Cm(e){return Object.prototype.hasOwnProperty.call(zl,e)}function Im(e){return Object.prototype.hasOwnProperty.call($m,e)}function US(e){return Object.prototype.hasOwnProperty.call(zl,e)}function ZS(e){return Cm(e)?Jt().dispatchRequestSchemas[e]:void 0}function DS(e){return US(e)?Jt().dispatchResultSchemas[e]:void 0}function HS(e){return Im(e)?Jt().notificationSchemas2026[e]:void 0}var pR=Object.keys(zl),hR=Object.keys($m);function ci(e){return e!==null&&typeof e==="object"&&!Array.isArray(e)}function ii(e,t){if(e===void 0)return{ok:!1,reason:"not-in-era"};let o=e.safeParse(t);return o.success?{ok:!0,value:o.data}:{ok:!1,reason:"invalid",message:String(o.error)}}var FS={ok:!1,reason:"not-in-era"},VS=[mo,fo];function JS(e,t){let o=t,r=!1,n=()=>{if(!r)o={...o},r=!0;return o},i=t.tools;if(e==="tools/list"&&Array.isArray(i)&&i.some((c)=>ci(c)&&("execution"in c)))n().tools=i.map((c)=>{if(!ci(c)||!("execution"in c))return c;let d={...c};return delete d.execution,d});let s=t.capabilities;if(ci(s)&&"tasks"in s){let c={...s};delete c.tasks,n().capabilities=c}return o}var Rl={era:"2026-07-28",hasRequestMethod:Cm,hasNotificationMethod:Im,hasInputRequestMethod:(e)=>cl(e)!==void 0,validateRequest:(e,t)=>ii(ZS(e),t),validateResult:(e,t)=>ii(DS(e),t),validateNotification:(e,t)=>ii(HS(e),t),validateInputRequest:(e,t)=>ii(cl(e),t),validateInputResponse:(e,t)=>ii(LS(e),t),samplingResultVariant:()=>FS,outboundEnvelope(e){return{[mo]:e.protocolVersion,[Go]:e.clientInfo,[fo]:e.clientCapabilities,...e.logLevel!==void 0&&{[Qo]:e.logLevel}}},validateEnvelopeMeta(e){let t=[];for(let r of VS)if(!(r in e))t.push({key:r,problem:"missing"});let o=Jt().RequestMetaEnvelopeSchema.safeParse(e);if(!o.success)for(let r of o.error.issues){let n=r.path.map(String),i=n.length>0?n.join("."):"_meta";if(n.length===1&&t.some((s)=>s.key===i&&s.problem==="missing"))continue;t.push({key:i,problem:r.message})}return t},projectCallToolResult:(e)=>fm(e),inputRequestSchema:cl,decodeResult(e,t){if(!ci(t))return{kind:"invalid",error:new k(M.InvalidResult,`Invalid result for ${e}: not an object`,{method:e})};let o=t.resultType;if(o===void 0)return{kind:"invalid",error:new k(M.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 o!=="string")return{kind:"invalid",error:new k(M.InvalidResult,`Invalid result for ${e}: non-string resultType`,{method:e,resultType:o})};if(o==="input_required"){let s=t.inputRequests,c=ci(s)?s:{},d=t.requestState,p=t._meta===void 0?void 0:Jt().ResultMetaSchema.safeParse(t._meta),h=p?.success?p.data:void 0;if(Object.keys(c).length===0&&typeof d!=="string")return{kind:"invalid",error:new k(M.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"})};return{kind:"input_required",inputRequests:c,...typeof d==="string"&&{requestState:d},...h!==void 0&&{_meta:h}}}if(o!=="complete")return{kind:"invalid",error:new k(M.UnsupportedResultType,`Unsupported result type '${o}' for ${e}`,{resultType:o,method:e})};let r=BS(),n=Object.hasOwn(r,e)?r[e]:void 0;if(n!==void 0){let s=n.safeParse(t);if(!s.success)return{kind:"invalid",error:new k(M.InvalidResult,`Invalid result for ${e}: ${s.error}`,{method:e})}}let i={...t};return delete i.resultType,{kind:"complete",result:i}},encodeResult(e,t,o){return MS(IS(e,CS(e,JS(e,t))),o)},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=Jt().RequestMetaEnvelopeSchema.safeParse(e.envelope);if(!t.success)return`Invalid _meta envelope for protocol revision 2026-07-28: ${t.error.issues.map((o)=>o.message).join("; ")}`}},Aa;function BS(){if(Aa)return Aa;let e=Jt();return Aa={"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},Aa}var Ua="2026-07-28";function $t(e){return e!==void 0&&Ct(e)?Rl:yl}function sm(e){if(e.revision!==void 0)return $t(e.revision).era;return e.era==="modern"?Rl.era:yl.era}function ll(e){return Om.some((t)=>t.hasRequestMethod(e))}function ul(e){return Om.some((t)=>t.hasNotificationMethod(e))}function im(e){return e==="tasks/get"||e==="tasks/cancel"}var Om=[yl,Rl],WS=Hl({AnnotationsSchema:()=>ht,AudioContentSchema:()=>zo,BaseMetadataSchema:()=>ut,BaseRequestParamsSchema:()=>ue,BlobResourceContentsSchema:()=>dr,BooleanSchemaSchema:()=>fr,CallToolRequestParamsSchema:()=>gs,CallToolRequestSchema:()=>Ss,CallToolResultSchema:()=>ft,CancelTaskRequestSchema:()=>wa,CancelTaskResultSchema:()=>xa,CancelledNotificationParamsSchema:()=>wn,CancelledNotificationSchema:()=>sr,ClientCapabilitiesSchema:()=>En,ClientNotificationSchema:()=>Ta,ClientRequestSchema:()=>Ea,ClientResultSchema:()=>Pa,ClientTasksCapabilitySchema:()=>pa,CompatibilityCallToolResultSchema:()=>ma,CompleteRequestParamsSchema:()=>Fs,CompleteRequestSchema:()=>Vs,CompleteResultSchema:()=>Js,ContentBlockSchema:()=>Ae,CreateMessageRequestParamsSchema:()=>ks,CreateMessageRequestSchema:()=>$s,CreateMessageResultSchema:()=>Cs,CreateMessageResultWithToolsSchema:()=>Is,CreateTaskResultSchema:()=>ga,CursorSchema:()=>er,DiscoverRequestSchema:()=>Cn,DiscoverResultSchema:()=>Vt,ElicitRequestFormParamsSchema:()=>Eo,ElicitRequestParamsSchema:()=>As,ElicitRequestSchema:()=>js,ElicitRequestURLParamsSchema:()=>Ns,ElicitResultSchema:()=>Zs,ElicitationCompleteNotificationParamsSchema:()=>Ls,ElicitationCompleteNotificationSchema:()=>Us,EmbeddedResourceSchema:()=>Tt,EmptyResultSchema:()=>pt,EnumSchemaSchema:()=>qs,GetPromptRequestParamsSchema:()=>is,GetPromptRequestSchema:()=>as,GetPromptResultSchema:()=>us,GetTaskPayloadRequestSchema:()=>ya,GetTaskPayloadResultSchema:()=>va,GetTaskRequestSchema:()=>_a,GetTaskResultSchema:()=>ba,IconSchema:()=>xn,IconsSchema:()=>Rt,ImageContentSchema:()=>vo,ImplementationSchema:()=>Ne,InitializeRequestParamsSchema:()=>Tn,InitializeRequestSchema:()=>Pn,InitializeResultSchema:()=>kn,InitializedNotificationSchema:()=>$n,JSONArraySchema:()=>ua,JSONObjectSchema:()=>oe,JSONRPCErrorResponseSchema:()=>_o,JSONRPCMessageSchema:()=>zt,JSONRPCNotificationSchema:()=>nr,JSONRPCRequestSchema:()=>rr,JSONRPCResponseSchema:()=>da,JSONRPCResultResponseSchema:()=>So,JSONValueSchema:()=>vt,LegacyTitledEnumSchemaSchema:()=>_r,ListChangedOptionsBaseSchema:()=>bs,ListPromptsRequestSchema:()=>ns,ListPromptsResultSchema:()=>ss,ListResourceTemplatesRequestSchema:()=>jn,ListResourceTemplatesResultSchema:()=>Ln,ListResourcesRequestSchema:()=>Nn,ListResourcesResultSchema:()=>An,ListRootsRequestSchema:()=>Ws,ListRootsResultSchema:()=>Ks,ListTasksRequestSchema:()=>za,ListTasksResultSchema:()=>Ra,ListToolsRequestSchema:()=>ms,ListToolsResultSchema:()=>fs,LoggingLevelSchema:()=>mr,LoggingMessageNotificationParamsSchema:()=>zs,LoggingMessageNotificationSchema:()=>Ro,ModelHintSchema:()=>Rs,ModelPreferencesSchema:()=>ws,MultiSelectEnumSchemaSchema:()=>Ms,NotificationSchema:()=>he,NotificationsParamsSchema:()=>Se,NumberSchemaSchema:()=>xo,PaginatedRequestParamsSchema:()=>Mn,PaginatedRequestSchema:()=>wt,PaginatedResultSchema:()=>xt,PingRequestSchema:()=>ar,PrimitiveSchemaDefinitionSchema:()=>vr,ProgressNotificationParamsSchema:()=>On,ProgressNotificationSchema:()=>cr,ProgressSchema:()=>In,ProgressTokenSchema:()=>Xo,PromptArgumentSchema:()=>os,PromptListChangedNotificationSchema:()=>ds,PromptMessageSchema:()=>ls,PromptReferenceSchema:()=>Hs,PromptSchema:()=>rs,ReadResourceRequestParamsSchema:()=>Un,ReadResourceRequestSchema:()=>Zn,ReadResourceResultSchema:()=>Dn,RelatedTaskMetadataSchema:()=>Rn,RequestIdSchema:()=>qe,RequestMetaSchema:()=>tr,RequestSchema:()=>re,ResourceContentsSchema:()=>lr,ResourceLinkSchema:()=>Pt,ResourceListChangedNotificationSchema:()=>Hn,ResourceRequestParamsSchema:()=>bo,ResourceSchema:()=>pr,ResourceTemplateReferenceSchema:()=>Ds,ResourceTemplateSchema:()=>qn,ResourceUpdatedNotificationParamsSchema:()=>es,ResourceUpdatedNotificationSchema:()=>ts,ResultMetaObjectSchema:()=>or,ResultSchema:()=>ne,RoleSchema:()=>Et,RootSchema:()=>Bs,RootsListChangedNotificationSchema:()=>Gs,SamplingContentSchema:()=>Ts,SamplingMessageContentBlockSchema:()=>Ht,SamplingMessageSchema:()=>Ps,ServerCapabilitiesSchema:()=>ir,ServerNotificationSchema:()=>$a,ServerRequestSchema:()=>ka,ServerResultSchema:()=>Ca,ServerTasksCapabilitySchema:()=>ha,SetLevelRequestParamsSchema:()=>ys,SetLevelRequestSchema:()=>vs,SingleSelectEnumSchemaSchema:()=>Os,StringSchemaSchema:()=>wo,SubscribeRequestParamsSchema:()=>Fn,SubscribeRequestSchema:()=>Vn,SubscriptionFilterSchema:()=>hr,SubscriptionsAcknowledgedNotificationParamsSchema:()=>Gn,SubscriptionsAcknowledgedNotificationSchema:()=>Yn,SubscriptionsListenRequestParamsSchema:()=>Wn,SubscriptionsListenRequestSchema:()=>Kn,SubscriptionsListenResultMetaSchema:()=>Qn,SubscriptionsListenResultSchema:()=>Xn,TaskAugmentedRequestParamsSchema:()=>Ft,TaskCreationParamsSchema:()=>fa,TaskMetadataSchema:()=>zn,TaskSchema:()=>kt,TaskStatusNotificationParamsSchema:()=>Qs,TaskStatusNotificationSchema:()=>Sa,TaskStatusSchema:()=>Ys,TextContentSchema:()=>yo,TextResourceContentsSchema:()=>ur,TitledMultiSelectEnumSchemaSchema:()=>yr,TitledSingleSelectEnumSchemaSchema:()=>Sr,ToolAnnotationsSchema:()=>ps,ToolChoiceSchema:()=>xs,ToolExecutionSchema:()=>hs,ToolListChangedNotificationSchema:()=>_s,ToolResultContentSchema:()=>Es,ToolSchema:()=>mt,ToolUseContentSchema:()=>cs,UnsubscribeRequestParamsSchema:()=>Jn,UnsubscribeRequestSchema:()=>Bn,UntitledMultiSelectEnumSchemaSchema:()=>br,UntitledSingleSelectEnumSchemaSchema:()=>gr});var Za=(e)=>rr.safeParse(e).success,Mm=(e)=>nr.safeParse(e).success,Er=(e)=>So.safeParse(e).success,mi=(e)=>_o.safeParse(e).success;var qm=(e)=>typeof e==="object"&&e!==null&&!Array.isArray(e)&&e.resultType==="input_required";var KS="Mcp-Param-",am="x-mcp-header",GS=/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/,YS=new Set(["string","integer","boolean"]);function wl(e){let t=[],o=new Map,r,n=(s,c,d)=>{if(s===null||typeof s!=="object")return;let p=s;if(am in p){if(!d||c.length===0)return`${ja(c)}: 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 f=p[am];if(typeof f!=="string"||f.length===0)return`${ja(c)}: x-mcp-header MUST be a non-empty string`;if(!GS.test(f))return`${ja(c)}: x-mcp-header '${f}' is not a valid RFC 9110 token (no spaces, control characters or HTTP delimiters)`;let S=typeof p.type==="string"?p.type:void 0;if(S===void 0||!YS.has(S)){let w=`${ja(c)}: x-mcp-header is only permitted on primitive-typed properties (string, integer, boolean); got ${S??"<none>"}`;if(S!=="number")return w;r??=w}let b=f.toLowerCase(),R=o.get(b);if(R!==void 0)return`x-mcp-header '${f}' is not case-insensitively unique (also declared as '${R}')`;o.set(b,f),t.push({path:c,headerName:f,type:S})}let h=p.properties;if(h!==null&&typeof h==="object")for(let[f,S]of Object.entries(h)){let b=n(S,[...c,f],d);if(b!==void 0)return b}for(let f of QS){let S=p[f];if(S===void 0)continue;let b=Array.isArray(S)?S:S!==null&&typeof S==="object"&&XS.has(f)?Object.values(S):[S];for(let R of b){let w=n(R,[...c,`<${f}>`],!1);if(w!==void 0)return w}}},i=n(e,[],!0);if(i!==void 0)return{valid:!1,reason:r??i};return r===void 0?{valid:!0,declarations:t}:{valid:!1,reason:r,declarations:t}}var QS=["items","prefixItems","contains","additionalProperties","unevaluatedProperties","unevaluatedItems","propertyNames","patternProperties","dependentSchemas","oneOf","anyOf","allOf","not","if","then","else","$defs","definitions"],XS=new Set(["patternProperties","dependentSchemas","$defs","definitions"]);function ja(e){return e.length===0?"<root>":e.join(".")}var Nm="=?base64?",Am="?=";function e_(e){if(typeof e==="string")return e;if(typeof e==="boolean")return e?"true":"false";if(typeof e==="number"){if(!Number.isFinite(e))return;if(Number.isInteger(e)&&!Number.isSafeInteger(e))return;return String(e)}}function t_(e){if(e.length===0)return!0;if(e.startsWith(Nm)&&e.endsWith(Am))return!0;if(e!==e.trim())return!0;for(let t=0;t<e.length;t++){let o=e.codePointAt(t);if(o===9||o>=32&&o<=126)continue;return!0}return!1}function o_(e){let t=new TextEncoder().encode(e),o="";for(let r of t)o+=String.fromCodePoint(r);return btoa(o)}function jm(e){return t_(e)?`${Nm}${o_(e)}${Am}`:e}function r_(e,t){let o=e;for(let r of t){if(o===null||typeof o!=="object")return;o=o[r]}return o}function Lm(e,t){let o={};for(let r of e){let n=r_(t,r.path);if(n===void 0||n===null)continue;let i=e_(n);if(i===void 0)continue;o[`${KS}${r.headerName}`]=jm(i)}return o}var xr=-32020,mR=[{rung:"http-method",order:1,evaluatedAt:"edge",codes:[-32000],conformance:[],rationale:"The modern era is POST-only; GET/DELETE are body-less 2025-era session operations and are method-routed to legacy serving (405 when legacy serving is not configured), before any body is read."},{rung:"jsonrpc-shape",order:2,evaluatedAt:"edge",codes:[U.InvalidRequest],conformance:["server-stateless"],rationale:"The body must be a JSON-RPC request or notification: posted responses and batch arrays containing a modern or invalid element are rejected before classification (element-wise batch rule); all-legacy arrays stay legacy traffic."},{rung:"era-classification",order:3,evaluatedAt:"edge",codes:[xr,U.UnsupportedProtocolVersion],conformance:["server-stateless","http-header-validation","http-custom-header-server-validation"],rationale:"Body-primary era classification with the protocol-version header as a cross-check; a header/body disagreement is rejected with -32020 (HeaderMismatch), and an envelope-less request on a modern-only endpoint is answered with the unsupported-protocol-version error naming the supported revisions."},{rung:"envelope",order:4,evaluatedAt:"edge",codes:[U.InvalidParams],conformance:["server-stateless"],rationale:"A present envelope claim with a malformed envelope — and a missing envelope on a request whose protocol-version header names a modern revision — is an invalid-params rejection naming the offending or missing key(s); never a silent fall back to legacy handling. This is the only place an invalid-params rejection maps to HTTP 400."},{rung:"method-registry",order:5,evaluatedAt:"dispatch",codes:[U.MethodNotFound],conformance:["server-stateless"],rationale:"Method existence outranks parameter validity: a method absent from the negotiated revision’s registry (or with no handler installed) answers method-not-found before params or capabilities are looked at."},{rung:"request-params",order:6,evaluatedAt:"dispatch",codes:[U.InvalidParams],conformance:[],rationale:"Per-method params validation; emitted in-band by the dispatch layer (HTTP 200), never via the ladder status table."},{rung:"standard-header-validation",order:7,evaluatedAt:"pre-dispatch",codes:[xr],conformance:["http-header-validation"],rationale:"SEP-2243 standard `MCP-Protocol-Version` / `Mcp-Method` / `Mcp-Name` headers — presence, sentinel decoding, and `Mcp-Name` ↔ body cross-check — are validated by the HTTP entry on a modern-classified request after the supported-revision gate and before dispatch. The spec requires `MCP-Protocol-Version` and `Mcp-Method` on every modern *request* POST (`Mcp-Name` only for the methods that mirror `params.name` / `params.uri` / `params.taskId`, see `MCP_NAME_HEADER_SOURCE`) and names them in that order, so a request missing several is answered by the earliest. Notification POSTs are exempt: the presence half runs on requests only, so a modern-enveloped notification is dispatched even with no standard headers at all. The classifier’s own header-mismatch cells (protocol-version, `Mcp-Method` mismatch) stay on the edge `era-classification` rung; this rung carries the entry-layer presence/`Mcp-Name` half — including the missing `MCP-Protocol-Version` cell, which cannot live on the edge rung without breaking body-primary classification. Evaluated before the capability gate, the factory call, and the `Mcp-Param-*` rung so a request that fails several rungs is answered by the standard-header rung first. The documented order (after method-registry 5 and request-params 6) is NOT the observed precedence: serveModern evaluates this rung immediately after the supported-revision gate, so a request that also fails a dispatch rung is answered here before the dispatch rungs (5–6) are consulted."},{rung:"client-capabilities",order:8,evaluatedAt:"pre-dispatch",codes:[U.MissingRequiredClientCapability],conformance:["server-stateless"],rationale:"The capability requirement is checked by the HTTP entry, pre-dispatch, against the validated envelope the classifier produced — pinning the spec-mandated HTTP 400 independently of how dispatch- and handler-produced errors are mapped. The documented order (after method resolution and params validation) is preserved observably only while the requirement table is empty: once a served method gains a requirement entry, a request that is missing the capability and would also fail a dispatch rung is answered by this gate first, so the entry must consult the method registry before the gate if the documented precedence is to stay observable."},{rung:"param-header-validation",order:9,evaluatedAt:"pre-dispatch",codes:[xr],conformance:["http-custom-header-server-validation"],rationale:"SEP-2243 `Mcp-Param-*` headers are validated against the named tool’s `x-mcp-header` declarations and the body `arguments` after the tool registry is known and before dispatch reaches the handler; a missing/disagreeing/malformed header is rejected 400 / -32020 with the same shape as the standard-header cross-checks. The documented order (after method resolution and params validation) is preserved observably only when the body `arguments` would otherwise validate: the check runs pre-dispatch, so a `tools/call` that fails BOTH this rung and a dispatch-time rung (e.g. order-6 `request-params`, -32602) is answered by this gate first with 400 / -32020, not by the earlier-ordered rung."}],fR={[U.ParseError]:400,[U.InvalidRequest]:400,[U.MethodNotFound]:404,[U.UnsupportedProtocolVersion]:400,[U.MissingRequiredClientCapability]:400,[xr]:400};function Da(e,t){return ra(e,t)}function ai(e){return new Set(e.flatMap((t)=>Object.keys(t.shape)))}function ml(e){if(e==null)return!1;let t=typeof e;if(t!=="object"&&t!=="function")return!1;if(!("~standard"in e))return!1;return typeof e["~standard"]?.validate==="function"}var cm=!1,fl="draft-2020-12";function n_(e,t="input"){let o=e["~standard"],r;if(o.jsonSchema)r=o.jsonSchema[t]({target:fl});else if(o.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().");if(!cm)cm=!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=ta(e,{target:fl,io:t})}else throw Error(`Schema library "${o.vendor}" does not implement StandardJSONSchemaV1 (\`~standard.jsonSchema\`). Upgrade to a version that does, or wrap your JSON Schema with fromJsonSchema().`);if(t==="output"){if(r.type!==void 0)return r;return Um(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}}var s_=/^#\/(\$defs|definitions)\/([^/~%]+)$/;function Um(e,t=e){if("properties"in e||"patternProperties"in e||"additionalProperties"in e||"required"in e)return!0;let o=typeof e.$ref==="string"&&s_.exec(e.$ref);if(o&&t[o[1]]?.[o[2]]?.type==="object")return!0;for(let r of["oneOf","anyOf","allOf"]){let n=e[r];if(Array.isArray(n)&&n.length>0)return n.every((i)=>i!==null&&typeof i==="object"&&(i.type==="object"||Um(i,"$id"in i?{}:t)))}return!1}function i_(e){if(!e.path?.length)return e.message;return`${e.path.map((t)=>String(typeof t==="object"?t.key:t)).join(".")}: ${e.message}`}async function dl(e,t){let o=await e["~standard"].validate(t);if(o.issues&&o.issues.length>0)return{success:!1,error:o.issues.map((r)=>i_(r)).join(", ")};return{success:!0,data:o.value}}function a_(e){let t=ta(e,{target:fl,io:"input"});return typeof t.pattern==="string"?t.pattern:void 0}var c_=/\\\.\\d\{(\d+)\}/;function l_(e){let t=c_.exec(e),o=[void 0,-1,0];if(t)o.push(Number(t[1]));return[!1,!0].flatMap((r)=>[!1,!0].flatMap((n)=>o.map((i)=>Jo({local:r,offset:n,precision:i}))))}function u_(e,t){let o;switch(e){case"email":o=[Oh()];break;case"uri":o=[sa()];break;case"date":o=[nl()];break;case"date-time":o=l_(t);break}return new Set(o.map((r)=>a_(r)).filter((r)=>r!==void 0))}function d_(e,t,o){if(o!=="zod")return!0;return u_(e,t).has(t)}function ui(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}function p_(e){try{return n_(e,"input")}catch(t){let o=t instanceof Error?t.message:String(t);throw new W(U.InvalidParams,`Elicitation requestedSchema must describe an object with flat primitive properties: ${o}`)}}var h_=new Set(["$comment","deprecated","description","examples","readOnly","title","writeOnly"]);function xl(e){return h_.has(e)||e.startsWith("x-")}var m_=new Set(["$schema",...Object.keys(Eo.shape.requestedSchema.shape)]),lm={string:ai([wo,gr,Sr,_r]),number:ai([xo]),integer:ai([xo]),boolean:ai([fr]),array:ai([br,yr])},f_=new Set(wo.shape.format.unwrap().options);function g_(e,t,o,r){if(!ui(e))return e;let n=typeof e.type==="string"&&Object.hasOwn(lm,e.type)?lm[e.type]:void 0;if(n===void 0)return e;let i={};for(let[s,c]of Object.entries(e))if(n.has(s)||xl(s))i[s]=c;else if(s==="pattern"&&e.type==="string"&&typeof e.format==="string"){if(!f_.has(e.format))i[s]=c;else if(typeof c!=="string"||!d_(e.format,c,o))r.push(`${t}.${s}`)}else r.push(`${t}.${s}`);return i}function S_(e,t){let o={},r=[];for(let[n,i]of Object.entries(e))if(n==="properties"&&ui(i))o[n]=Object.fromEntries(Object.entries(i).map(([s,c])=>[s,g_(c,`properties.${s}`,t,r)]));else if(m_.has(n))o[n]=i;else if(!xl(n))r.push(n);if(r.length>0)throw new W(U.InvalidParams,`Elicitation requestedSchema contains unsupported JSON Schema constraint(s) after Standard Schema conversion: ${r.join(", ")}`);return o}function __(e,t){if(!ui(e.properties))return t;let o=Object.entries(e.properties).filter(([,r])=>!Da(vr,r).success).map(([r])=>`properties.${r}`);return o.length>0?o.join(", "):t}function gl(e,t,o=""){if(Array.isArray(e)&&Array.isArray(t))return e.flatMap((r,n)=>gl(r,t[n],`${o}[${n}]`));if(!ui(e)||!ui(t))return[];return Object.entries(e).flatMap(([r,n])=>{let i=o?`${o}.${r}`:r;if(!Object.prototype.hasOwnProperty.call(t,r))return xl(r)?[]:[i];return gl(n,t[r],i)})}function b_(e){if(!ml(e.requestedSchema))return{...e,mode:"form",requestedSchema:e.requestedSchema};let t=e.requestedSchema["~standard"].vendor,o=S_(p_(e.requestedSchema),t),r=Da(Eo.shape.requestedSchema,o);if(!r.success)throw new W(U.InvalidParams,`Elicitation requestedSchema only supports flat primitive properties (string, number, integer, boolean, and string enums): ${__(o,r.error.message)}`);let n=gl(o,r.data);if(n.length>0)throw new W(U.InvalidParams,`Elicitation requestedSchema contains unsupported JSON Schema constraint(s) after Standard Schema conversion: ${n.join(", ")}`);let i=(r.data.required??[]).filter((s)=>!Object.prototype.hasOwnProperty.call(r.data.properties,s));if(i.length>0)throw new W(U.InvalidParams,`Elicitation requestedSchema lists required properties that are not defined in properties: ${i.join(", ")}`);return{...e,mode:"form",requestedSchema:r.data}}function y_(e){let t=e.inputRequests!==void 0&&Object.keys(e.inputRequests).length>0,o=typeof e.requestState==="string";if(!t&&!o)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}}}var gR=Object.assign(y_,{elicit(e){try{return{method:"elicitation/create",params:b_(e)}}catch(t){throw t instanceof W?TypeError(t.message,{cause:t}):t}},elicitUrl(e){return{method:"elicitation/create",params:{...e,mode:"url"}}},createMessage(e){return{method:"sampling/createMessage",params:e}},listRoots(){return{method:"roots/list"}}});var v_=!0,z_=10,R_=250;function Zm(e){return{autoFulfill:e?.autoFulfill??v_,maxRounds:e?.maxRounds??z_}}function w_(e,t,o){let r=t!==void 0&&Object.keys(t).length>0;if(!r&&o===void 0)return e;return{...e,...r&&{inputResponses:t},...o!==void 0&&{requestState:o}}}function x_(e,t){return`Multi-round-trip request '${e}' still required input after ${t} rounds (inputRequired.maxRounds)`}function E_(e,t){return new Promise((o,r)=>{if(t?.aborted){r(t.reason instanceof k?t.reason:new k(M.RequestTimeout,String(t.reason)));return}let n=setTimeout(()=>{t?.removeEventListener("abort",i),o()},e),i=()=>{clearTimeout(n),r(t?.reason instanceof k?t.reason:new k(M.RequestTimeout,String(t?.reason)))};t?.addEventListener("abort",i,{once:!0})})}function T_(e){let t=new AbortController,o=()=>t.abort(e?.reason);if(e?.addEventListener("abort",o,{once:!0}),e?.aborted)t.abort(e.reason);return{signal:t.signal,abort:(r)=>t.abort(r),dispose:()=>e?.removeEventListener("abort",o)}}async function P_(e){let{config:t,method:o,originalParams:r,requestOptions:n,hooks:i,signal:s}=e,c=e.flowStartedAt??Date.now(),d=e.firstPayload,p=0;while(!0){if(p+=1,p>t.maxRounds)throw new k(M.InputRequiredRoundsExceeded,x_(o,t.maxRounds),{rounds:t.maxRounds,lastResult:{inputRequests:d.inputRequests,...d.requestState!==void 0&&{requestState:d.requestState}}});n.onprogress?.({progress:p,message:`Fulfilling input required by '${o}' (round ${p})`});let h=Object.entries(d.inputRequests??{}),f;if(h.length>0){let R=T_(s);try{let w=await Promise.all(h.map(async([O,J])=>{try{return[O,await i.dispatchInputRequest(O,J,R.signal)]}catch(B){throw R.abort(B),B}}));f=Object.fromEntries(w)}finally{R.dispose()}}else await E_(R_,s);let S={...n.timeout!==void 0&&{timeout:n.timeout}};if(n.maxTotalTimeout!==void 0){let R=Date.now()-c,w=n.maxTotalTimeout-R;if(w<=0)throw new k(M.RequestTimeout,"Maximum total timeout exceeded",{maxTotalTimeout:n.maxTotalTimeout,totalElapsed:R});S.maxTotalTimeout=w}let b=await i.retry(w_(r,f,d.requestState),S);if(qm(b)){d={inputRequests:b.inputRequests??{},...b.requestState!==void 0&&{requestState:b.requestState}};continue}return b}}var k_=["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"],$_={IdJagTokenExchangeResponseSchema:oi,OAuthClientInformationFullSchema:si,OAuthClientInformationSchema:ni,OAuthClientMetadataSchema:ri,OAuthClientRegistrationErrorSchema:Ia,OAuthErrorResponseSchema:wr,OAuthMetadataSchema:zr,OAuthProtectedResourceMetadataSchema:Xs,OAuthTokenRevocationRequestSchema:Oa,OAuthTokensSchema:Rr,OpenIdProviderDiscoveryMetadataSchema:ti,OpenIdProviderMetadataSchema:ei},Dm={},Hm={};function Fm(e,t){let o=e.slice(0,-6);Dm[o]=t,Hm[o]=(r)=>t.safeParse(r).success}for(let e of k_)Fm(e,WS[e]);for(let[e,t]of Object.entries($_))Fm(e,t);var C_=Object.freeze(Dm),El=Object.freeze(Hm);function I_(e){switch(e){case"initialize":case"notifications/initialized":return $t(void 0);case"server/discover":return $t(Ua);default:return}}var fi=60000,O_=[mo,Go,fo,Qo],M_=["inputResponses","requestState"];function um(e,t){let o=e.params;if(!li(o))return{message:e,lifted:{}};let r=o._meta,n=li(r)?O_.filter((d)=>(d in r)):[],i=t==="request"?M_.filter((d)=>(d in o)):[];if(n.length===0&&i.length===0)return{message:e,lifted:{}};let s={},c={...o};if(n.length>0&&li(r)){let d={},p={...r};for(let h of n)d[h]=r[h],delete p[h];if(s.envelope=d,Object.keys(p).length>0)c._meta=p;else delete c._meta}for(let d of i){if(d==="inputResponses")s.inputResponses=c[d];if(d==="requestState")s.requestState=c[d];delete c[d]}return{message:{...e,params:c},lifted:s}}function dm(e,t){let o=e.validateResult(t,void 0);if(!o.ok&&o.reason==="not-in-era")return;return{"~standard":{version:1,vendor:"mcp-wire-codec",validate(r){let n=e.validateResult(t,r);if(n.ok)return{value:n.value};return{issues:[{message:n.reason==="invalid"?n.message:`not-in-era: ${t}`}]}}}}}function Tl(e){return()=>e}var q_=Tl(void 0),N_,To=class{_transport;_requestMessageId=0;_requestHandlers=new Map;_customSchemaRequestMethods=new Set;_requestHandlerAbortControllers=new Map;_notificationHandlers=new Map;_responseHandlers=new Map;_progressHandlers=new Map;_timeoutInfo=new Map;_pendingDebouncedNotifications=new Set;_negotiatedProtocolVersion;static{N_=(e,t)=>{e._negotiatedProtocolVersion=t}}_supportedProtocolVersions;onclose;onerror;fallbackRequestHandler;fallbackNotificationHandler;constructor(e){this._options=e,this._supportedProtocolVersions=e?.supportedProtocolVersions??ca,this.setNotificationHandler("notifications/cancelled",(t)=>{this._oncancel(t)}),this.setNotificationHandler("notifications/progress",(t)=>{this._onprogress(t)}),this.setRequestHandler("ping",(t)=>({}))}_shouldDropInbound(e){}_outboundMetaEnvelope(){}_envelopeOutbound(e){let t=this._outboundMetaEnvelope();if(t===void 0)return e;let o=e.params??{};return{...e,params:{...o,_meta:{...t,...o._meta}}}}_resolveNonCompleteResult(e,t){return Promise.reject(new k(M.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){if(e.params.requestId===void 0)return;this._requestHandlerAbortControllers.get(e.params.requestId)?.abort(e.params.reason)}_setupTimeout(e,t,o,r,n=!1){this._timeoutInfo.set(e,{timeoutId:setTimeout(r,t),startTime:Date.now(),timeout:t,maxTotalTimeout:o,resetTimeoutOnProgress:n,onTimeout:r})}_resetTimeout(e){let t=this._timeoutInfo.get(e);if(!t)return!1;let o=Date.now()-t.startTime;if(t.maxTotalTimeout&&o>=t.maxTotalTimeout)throw this._timeoutInfo.delete(e),new k(M.RequestTimeout,"Maximum total timeout exceeded",{maxTotalTimeout:t.maxTotalTimeout,totalElapsed:o});return clearTimeout(t.timeoutId),t.timeoutId=setTimeout(t.onTimeout,t.timeout),!0}_cleanupTimeout(e){let t=this._timeoutInfo.get(e);if(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 o=this.transport?.onerror;this._transport.onerror=(n)=>{o?.(n),this._onerror(n)};let r=this._transport?.onmessage;this._transport.onmessage=(n,i)=>{if(r?.(n,i),Er(n)||mi(n))this._onresponse(n);else if(Za(n))this._onrequest(n,i);else if(Mm(n))this._onnotification(n,i);else this._onerror(Error(`Unknown message type: ${JSON.stringify(n)}`))},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 r of this._timeoutInfo.values())clearTimeout(r.timeoutId);this._timeoutInfo.clear();let t=this._requestHandlerAbortControllers;this._requestHandlerAbortControllers=new Map;let o=new k(M.ConnectionClosed,"Connection closed");this._transport=void 0;try{this.onclose?.()}finally{for(let r of e.values())r(o);for(let r of t.values())r.abort(o)}}_onerror(e){this.onerror?.(e)}_onnotification(e,t){let{message:o}=um(e,"notification"),r=this._negotiatedWireCodec();if(t?.classification===void 0&&this._shouldDropInbound(e)==="drop")return;if(t?.classification!==void 0){let s=sm(t.classification);if(s!==r.era){this._onerror(Error(`Era mismatch on inbound notification '${o.method}': classified as ${s} but this instance serves ${r.era}`));return}}if(ul(o.method)&&!r.hasNotificationMethod(o.method))return;let n=this._notificationHandlers.get(o.method),i=this.fallbackNotificationHandler;if(n===void 0&&i===void 0)return;Promise.resolve().then(()=>n===void 0?i(o):n(o,r)).catch((s)=>this._onerror(Error(`Uncaught error in notification handler: ${s}`)))}_onrequest(e,t){let{message:o,lifted:r}=um(e,"request"),n=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 i=this._transport,s=(w,O,J)=>{let B={jsonrpc:"2.0",id:o.id,error:{code:w,message:O,...J!==void 0&&{data:J}}};i?.send(B).catch((j)=>this._onerror(Error(`Failed to send an error response: ${j}`)))};if(t?.classification!==void 0){let w=sm(t.classification);if(w!==n.era){this._onerror(Error(`Era mismatch on inbound request '${o.method}': classified as ${w} but this instance serves ${n.era}`));let O=t.classification.revision??w;s(U.UnsupportedProtocolVersion,`Unsupported protocol version: ${O}`,{supported:this._supportedProtocolVersions,requested:O});return}}if(ll(o.method)&&!n.hasRequestMethod(o.method)&&!(im(o.method)&&this._customSchemaRequestMethods.has(o.method))){s(U.MethodNotFound,"Method not found");return}let c=this._requestHandlers.get(o.method)??this.fallbackRequestHandler;if(c===void 0){s(U.MethodNotFound,"Method not found");return}let d=n.checkInboundEnvelope(r);if(d!==void 0){s(U.InvalidParams,d);return}let p=(w,O)=>this._notificationViaCodec(this._resolveOutboundCodec(w.method),w,{...O,relatedRequestId:o.id}),h=(w,O,J)=>this._requestWithSchemaViaCodec(this._resolveOutboundCodec(w.method),w,O,{...J,relatedRequestId:o.id}),f=new AbortController;this._requestHandlerAbortControllers.set(o.id,f);let S=r.inputResponses===void 0?void 0:A_(r.inputResponses),b={sessionId:i?.sessionId,mcpReq:{id:o.id,method:o.method,_meta:o.params?._meta,...r.envelope!==void 0&&{envelope:r.envelope},...S!==void 0&&{inputResponses:S.accepted},...S!==void 0&&S.droppedKeys.length>0&&{droppedInputResponseKeys:S.droppedKeys},requestState:r.requestState===void 0?q_:Tl(r.requestState),signal:f.signal,send:(w,O,J)=>{let B=this._resolveOutboundCodec(w.method);if(this._assertOutboundRequestInEra(B,w.method),ml(O))return h(w,O,J);let j=dm(B,w.method);if(j===void 0)throw TypeError(`'${w.method}' is not a spec method; pass a result schema as the second argument to ctx.mcpReq.send().`);return h(w,j,O)},notify:p},http:t?.authInfo?{authInfo:t.authInfo}:void 0},R=this.buildContext(b,t);Promise.resolve().then(()=>c(o,R)).then(async(w)=>{if(f.signal.aborted)return;let O;try{O=n.encodeResult(o.method,w,this._outboundServerInfo())}catch(B){this._onerror(Error(`Failed to encode result for ${o.method}: ${B}`)),s(U.InternalError,"Internal error");return}let J={result:O,jsonrpc:"2.0",id:o.id};await i?.send(J)},async(w)=>{if(f.signal.aborted)return;let O=Number.isSafeInteger(w.code)?w.code:U.InternalError,J={jsonrpc:"2.0",id:o.id,error:{code:n.encodeErrorCode(O),message:w.message??"Internal error",...w.data!==void 0&&{data:w.data}}};await i?.send(J)}).catch((w)=>this._onerror(Error(`Failed to send response: ${w}`))).finally(()=>{if(this._requestHandlerAbortControllers.get(o.id)===f)this._requestHandlerAbortControllers.delete(o.id)})}_onprogress(e){let{progressToken:t,...o}=e.params,r=Number(t),n=this._progressHandlers.get(r);if(!n){this._onerror(Error(`Received a progress notification for an unknown token: ${JSON.stringify(e)}`));return}let i=this._responseHandlers.get(r),s=this._timeoutInfo.get(r);if(s&&i&&s.resetTimeoutOnProgress)try{this._resetTimeout(r)}catch(c){this._responseHandlers.delete(r),this._progressHandlers.delete(r),this._cleanupTimeout(r),i(c);return}n(o)}_onresponse(e){let t=Number(e.id),o=this._responseHandlers.get(t);if(o===void 0){this._onerror(Error(`Received a response for an unknown message ID: ${JSON.stringify(e)}`));return}if(this._responseHandlers.delete(t),this._cleanupTimeout(t),this._progressHandlers.delete(t),Er(e))o(e);else o(W.fromError(e.error.code,e.error.message,e.error.data))}get transport(){return this._transport}async close(){await this._transport?.close()}request(e,t,o){let r=this._resolveOutboundCodec(e.method);if(ml(t)){if(!im(e.method))this._assertOutboundRequestInEra(r,e.method);return this._requestWithSchemaViaCodec(r,e,t,o)}this._assertOutboundRequestInEra(r,e.method);let n=dm(r,e.method);if(n===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,n,t)}_negotiatedWireCodec(){return $t(this._negotiatedProtocolVersion)}_wireCodec(){return this._negotiatedWireCodec()}_resolveOutboundCodec(e){if(this._negotiatedProtocolVersion===void 0){let t=I_(e);if(t)return t}return this._negotiatedWireCodec()}_assertOutboundRequestInEra(e,t){if(ll(t)&&!e.hasRequestMethod(t))throw new k(M.MethodNotSupportedByProtocolVersion,`Method '${t}' is not supported by the negotiated protocol version (wire era ${e.era})`,{method:t,era:e.era})}_requestWithSchema(e,t,o){let r=this._resolveOutboundCodec(e.method);return this._assertOutboundRequestInEra(r,e.method),this._requestWithSchemaViaCodec(r,e,t,o)}_requestWithSchemaViaCodec(e,t,o,r){let{relatedRequestId:n,resumptionToken:i,onresumptiontoken:s,headers:c}=r??{},d=Date.now(),p,h;return new Promise((f,S)=>{let b=(K)=>{S(K)};if(!this._transport){b(Error("Not connected"));return}if(this._options?.enforceStrictCapabilities===!0)try{this.assertCapabilityForMethod(t.method)}catch(K){b(K);return}if(r?.signal?.aborted){let K=r.signal.reason;throw K instanceof k?K:new k(M.RequestTimeout,String(K))}let R=e.era===Ua&&this._transport.hasPerRequestStream===!0?new AbortController:void 0,w=this._requestMessageId++;h=w;let O={...t,jsonrpc:"2.0",id:w};if(r?.onprogress)this._progressHandlers.set(w,r.onprogress),O.params={...t.params,_meta:{...t.params?._meta,progressToken:w}};let J=this._envelopeOutbound(O),B=!1,j=(K)=>{if(B)return;if(this._progressHandlers.delete(w),R===void 0){if(t.method!=="initialize")this._transport?.send(this._envelopeOutbound({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:w,reason:String(K)}}),{relatedRequestId:n,resumptionToken:i,onresumptiontoken:s}).catch((ie)=>this._onerror(Error(`Failed to send cancellation: ${ie}`)))}else R.abort();S(K instanceof k?K:new k(M.RequestTimeout,String(K)))};this._responseHandlers.set(w,(K)=>{if(r?.signal?.aborted)return;if(B=!0,K instanceof Error)return S(K);let ie;try{ie=e.decodeResult(t.method,K.result)}catch(ce){return S(ce instanceof Error?ce:Error(String(ce)))}if(ie.kind==="invalid")return S(ie.error);if(ie.kind==="input_required"){if(r?.allowInputRequired===!0)return f(Z_(ie));let ce={codec:e,request:t,resultSchema:o,options:r,flowStartedAt:d,retry:(Ue,We)=>this._requestWithSchemaViaCodec(e,Ue===void 0?{method:t.method}:{method:t.method,params:Ue},o,We)};return f(this._resolveNonCompleteResult(ie,ce))}let Le=ie.result;dl(o,Le).then((ce)=>{if(ce.success)f(ce.data);else S(new k(M.InvalidResult,`Invalid result for ${t.method}: ${ce.error}`))},S)}),p=()=>j(r?.signal?.reason),r?.signal?.addEventListener("abort",p,{once:!0});let F=r?.timeout??fi,Y=()=>j(new k(M.RequestTimeout,"Request timed out",{timeout:F}));this._setupTimeout(w,F,r?.maxTotalTimeout,Y,r?.resetTimeoutOnProgress??!1),this._transport.send(J,{relatedRequestId:n,resumptionToken:i,onresumptiontoken:s,headers:c,requestSignal:R?.signal}).catch((K)=>{this._progressHandlers.delete(w),S(K)})}).finally(()=>{if(p)r?.signal?.removeEventListener("abort",p);if(h!==void 0)this._responseHandlers.delete(h),this._cleanupTimeout(h)})}async notification(e,t){return await this._notificationViaCodec(this._resolveOutboundCodec(e.method),e,t)}async _notificationViaCodec(e,t,o){if(!this._transport)throw new k(M.NotConnected,"Not connected");if(ul(t.method)&&!e.hasNotificationMethod(t.method))throw new k(M.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&&o?.relatedRequestId===void 0){if(this._pendingDebouncedNotifications.has(t.method))return;this._pendingDebouncedNotifications.add(t.method),Promise.resolve().then(()=>{if(this._pendingDebouncedNotifications.delete(t.method),!this._transport)return;this._transport?.send(r,o).catch((n)=>this._onerror(n))});return}await this._transport.send(r,o)}setRequestHandler(e,t,o){this.assertRequestHandlerCapability(e);let r;if(typeof t==="function"){if(!ll(e))throw TypeError(`'${e}' is not a spec request method; pass schemas as the second argument to setRequestHandler().`);r=(n,i)=>{let s=this._negotiatedWireCodec(),c=s.validateRequest(e,n);if(!c.ok&&c.reason==="not-in-era")c=s.validateInputRequest(e,n);if(!c.ok){if(c.reason==="not-in-era")throw new W(U.InternalError,`No wire schema for ${e} in the resolved era`);throw Error(c.message)}return Promise.resolve(t(c.value,i))}}else if(o)r=async(n,i)=>{let s=await dl(t.params,{...n.params});if(!s.success)throw new W(U.InvalidParams,`Invalid params for ${e}: ${s.error}`);return o(s.data,i)};else throw TypeError("setRequestHandler: handler is required");if(typeof t==="function")this._customSchemaRequestMethods.delete(e);else this._customSchemaRequestMethods.add(e);this._requestHandlers.set(e,this._wrapHandler(e,r))}_wrapHandler(e,t){return t}_outboundServerInfo(){}removeRequestHandler(e){this._requestHandlers.delete(e),this._customSchemaRequestMethods.delete(e)}assertCanSetRequestHandler(e){if(this._requestHandlers.has(e))throw Error(`A request handler for ${e} already exists, which would be overridden`)}setNotificationHandler(e,t,o){if(typeof t==="function"){if(!ul(e))throw TypeError(`'${e}' is not a spec notification method; pass schemas as the second argument to setNotificationHandler().`);this._notificationHandlers.set(e,(r,n)=>{let i=n.validateNotification(e,r);if(!i.ok){if(i.reason==="not-in-era")throw new W(U.InternalError,`No wire schema for ${e} in the resolved era`);throw Error(i.message)}return Promise.resolve(t(i.value))});return}if(!o)throw TypeError("setNotificationHandler: handler is required");this._notificationHandlers.set(e,async(r)=>{let n=await dl(t.params,{...r.params});if(!n.success)throw new W(U.InvalidParams,`Invalid params for notification ${e}: ${n.error}`);await o(n.data,r)})}removeNotificationHandler(e){this._notificationHandlers.delete(e)}};function li(e){return e!==null&&typeof e==="object"&&!Array.isArray(e)}function Pl(e,t){let o={...e};for(let r in t){let n=r,i=t[n];if(i===void 0)continue;let s=o[n];o[n]=li(s)&&li(i)?{...s,...i}:i}return o}function La(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}function A_(e){let t={},o=[];if(!La(e))return{accepted:t,droppedKeys:o};for(let[r,n]of Object.entries(e)){if(!La(n)||"method"in n||"result"in n){o.push(r);continue}t[r]=n}return{accepted:t,droppedKeys:o}}function pm(e){throw new k(M.SendFailed,`ctx.mcpReq.${e} is not available while fulfilling an embedded input request: the request is fulfilled locally and has no related peer request`)}function j_(e,t,o,r,n){return{sessionId:n,mcpReq:{id:e,method:t,_meta:o?._meta,requestState:Tl(void 0),signal:r,send:()=>pm("send"),notify:()=>pm("notify")}}}async function L_(e,t,o,r,n){if(!La(r)||typeof r.method!=="string")throw new k(M.InvalidResult,`Invalid input request '${o}': each inputRequests entry must be an embedded request object with a method`,{key:o});let i=r.method;if(!t.hasInputRequestMethod(i))throw new k(M.InvalidResult,`Invalid input request '${o}': '${i}' is not an embedded request the ${t.era} revision defines (expected elicitation/create, sampling/createMessage, or roots/list)`,{key:o,method:i});let s=e.getRequestHandler(i);if(s===void 0)throw new k(M.CapabilityNotSupported,`Cannot fulfil input request '${o}': no handler is registered for '${i}' on this client. Declare the corresponding capability and register a handler, or handle input_required results manually.`,{key:o,method:i});let c=La(r.params)?r.params:void 0;return await s({jsonrpc:"2.0",id:o,method:i,...c!==void 0&&{params:c}},e.buildContext(j_(o,i,c,n,e.sessionId)))}function U_(e,t){return{...e?.signal!==void 0&&{signal:e.signal},...e?.onprogress!==void 0&&{onprogress:e.onprogress},...e?.resetTimeoutOnProgress!==void 0&&{resetTimeoutOnProgress:e.resetTimeoutOnProgress},...e?.headers!==void 0&&{headers:e.headers},...t.timeout!==void 0&&{timeout:t.timeout},...t.maxTotalTimeout!==void 0&&{maxTotalTimeout:t.maxTotalTimeout},allowInputRequired:!0}}function Vm(e,t,o,r){let{codec:n,request:i,options:s,flowStartedAt:c}=r,d={inputRequests:o.inputRequests,...o.requestState!==void 0&&{requestState:o.requestState}},p={dispatchInputRequest:(h,f,S)=>L_(e,n,h,f,S),retry:(h,f)=>r.retry(h,U_(s,f))};return P_({config:t,method:i.method,originalParams:i.params,firstPayload:d,flowStartedAt:c,signal:s?.signal,requestOptions:{...s?.timeout!==void 0&&{timeout:s.timeout},...s?.maxTotalTimeout!==void 0&&{maxTotalTimeout:s.maxTotalTimeout},...s?.onprogress!==void 0&&{onprogress:s.onprogress}},hooks:p})}function Z_(e){return{resultType:"input_required",inputRequests:e.inputRequests,...e.requestState!==void 0&&{requestState:e.requestState},...e._meta!==void 0&&{_meta:e._meta}}}/*!
|
|
65
65
|
* content-type
|
|
66
66
|
* Copyright(c) 2015 Douglas Christopher Wilson
|
|
67
67
|
* MIT Licensed
|
|
68
|
-
*/var $S=gl((e)=>{var t=/; *([!#$%&'*+.^_`|~0-9A-Za-z-]+) *= *("(?:[\u000b\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\u000b\u0020-\u00ff])*"|[!#$%&'*+.^_`|~0-9A-Za-z-]+) */g,o=/\\([\u000b\u0020-\u00ff])/g,r=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/;e.parse=n;function n(u){if(!u)throw TypeError("argument string is required");var d=typeof u==="object"?i(u):u;if(typeof d!=="string")throw TypeError("argument string is required to be a string");var p=d.indexOf(";"),f=p!==-1?d.slice(0,p).trim():d.trim();if(!r.test(f))throw TypeError("invalid media type");var b=new a(f.toLowerCase());if(p!==-1){var y,z,E;t.lastIndex=p;while(z=t.exec(d)){if(z.index!==p)throw TypeError("invalid parameter format");if(p+=z[0].length,y=z[1].toLowerCase(),E=z[2],E.charCodeAt(0)===34){if(E=E.slice(1,-1),E.indexOf("\\")!==-1)E=E.replace(o,"$1")}b.parameters[y]=E}if(p!==d.length)throw TypeError("invalid parameter format")}return b}function i(u){var d;if(typeof u.getHeader==="function")d=u.getHeader("content-type");else if(typeof u.headers==="object")d=u.headers&&u.headers["content-type"];if(typeof d!=="string")throw TypeError("content-type header is missing from object");return d}function a(u){this.parameters=Object.create(null),this.type=u}}),gv=_l($S(),1);var Ev=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");var CS=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,IS=[0,31,28,31,30,31,30,31,31,30,31,30,31],OS=/^(\d\d):(\d\d):(\d\d)(\.\d+)?(z|[+-]\d\d(?::?\d\d)?)?$/i,MS=/^(?=.{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,qS=/^(?:[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,NS=/^(?:(?:[^\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,AS=/^(?:(?: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,jS=/^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i,LS=/^(?:\/(?:[^~/]|~0|~1)*)*$/,US=/^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i,ZS=/^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/,DS=(e)=>{if(e[0]==='"')return!1;let[t,o,...r]=e.split("@");if(!t||!o||r.length!==0||t.length>64||o.length>253)return!1;if(t[0]==="."||t.endsWith(".")||t.includes(".."))return!1;if(!/^[a-z0-9.-]+$/i.test(o)||!/^[a-z0-9.!#$%&'*+/=?^_`{|}~-]+$/i.test(t))return!1;return o.split(".").every((n)=>/^[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?$/i.test(n))},HS=/^(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)$/,FS=/^((([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,VS=(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 qe(e){return e.test.bind(e)}var Pv={date:hm,time:mm.bind(void 0,!1),"date-time":WS,duration:VS,uri:YS,"uri-reference":qe(qS),"uri-template":qe(NS),url:qe(AS),email:DS,hostname:qe(MS),ipv4:qe(HS),ipv6:qe(FS),regex:XS,uuid:qe(jS),"json-pointer":qe(LS),"json-pointer-uri-fragment":qe(US),"relative-json-pointer":qe(ZS)};function JS(e){return e%4===0&&(e%100!==0||e%400===0)}function hm(e){let t=e.match(CS);if(!t)return!1;let o=+t[1],r=+t[2],n=+t[3];return r>=1&&r<=12&&n>=1&&n<=(r==2&&JS(o)?29:IS[r])}function mm(e,t){let o=t.match(OS);if(!o)return!1;let r=+o[1],n=+o[2],i=+o[3],a=!!o[5];return(r<=23&&n<=59&&i<=59||r==23&&n==59&&i==60)&&(!e||a)}var BS=/t|\s/i;function WS(e){let t=e.split(BS);return t.length==2&&hm(t[0])&&mm(!0,t[1])}var KS=/\/|:/,GS=/^(?:[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 YS(e){return KS.test(e)&&GS.test(e)}var QS=/[^\\]\\Z/;function XS(e){if(QS.test(e))return!1;try{return new RegExp(e,"u"),!0}catch(t){return!1}}var t_;t_=globalThis.crypto;var ti=class extends Error{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.OAuthClientFlowError"})}static[Symbol.hasInstance](e){return _e(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 _e(this,e)}constructor(e){super(e);this.name=new.target.name,Bt(this,new.target)}},Rz=class extends ti{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.IssuerMismatchError"})}kind;expected;received;constructor(e,t,o){super(`Issuer mismatch in ${e==="metadata"?"authorization server metadata (RFC 8414 §3.3)":"authorization response (RFC 9207)"}: expected ${JSON.stringify(t)}, received ${JSON.stringify(o)}`);this.kind=e,this.expected=t,this.received=o}},wz=class extends ti{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.RegistrationRejectedError"})}status;body;submittedMetadata;constructor(e){super(`Dynamic Client Registration rejected (HTTP ${e.status}): ${e.body}`);this.status=e.status,this.body=e.body,this.submittedMetadata=e.submittedMetadata}},xz=class extends ti{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.InsecureTokenEndpointError"})}tokenEndpoint;constructor(e){super(`Refusing to send credentials to non-https token endpoint '${e}'. OAuth token requests MUST use TLS (localhost / *.localhost / 127.0.0.1 / ::1 are exempt).`);this.tokenEndpoint=e}},Tz=class extends ti{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.AuthorizationServerMismatchError"})}constructor(e,t){super(`Authorization server mismatch: credentials are bound to ${JSON.stringify(e)} but this call resolved ${JSON.stringify(t)}; refusing to present them to a different authorization server`);this.recordedIssuer=e,this.currentIssuer=t}},Ez=class extends ti{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.InsufficientScopeError"})}requiredScope;resourceMetadataUrl;errorDescription;constructor(e){super(`Insufficient scope${e.requiredScope?`: required "${e.requiredScope}"`:""}`);this.requiredScope=e.requiredScope,this.resourceMetadataUrl=e.resourceMetadataUrl,this.errorDescription=e.errorDescription}};var Pz=class extends Error{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.UnauthorizedError"})}static[Symbol.hasInstance](e){return _e(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 _e(this,e)}constructor(e){super(e??"Unauthorized");this.name="UnauthorizedError",Bt(this,new.target)}};var kz=class extends Error{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.SseError"})}static[Symbol.hasInstance](e){return _e(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 _e(this,e)}constructor(e,t,o){super(`SSE error: ${t}`);this.code=e,this.event=o,Bt(this,new.target)}};class ym{_eventSlots=new Map;setHandler(e,t){let o=this._ensureEventSlot(e);if(o.onHandler&&t)console.warn(`[MCP Apps] on${String(e)} handler replaced. Use addEventListener("${String(e)}", …) to add multiple listeners without replacing.`);o.onHandler=t}getHandler(e){return this._eventSlots.get(e)?.onHandler}addEventListener(e,t){this._ensureEventSlot(e).listeners.push(t)}removeEventListener(e,t){let o=this._eventSlots.get(e);if(!o)return;let r=o.listeners.indexOf(t);if(r!==-1)o.listeners.splice(r,1)}dispatch(e,t){let o=this._eventSlots.get(e);if(!o)return;o.onHandler?.(t);for(let r of[...o.listeners])r(t)}_ensureEventSlot(e){let t=this._eventSlots.get(e);if(!t)t={listeners:[]},this._eventSlots.set(e,t);return t}}class vm{_methods=new Set;claim(e,t){if(this._methods.has(e))throw Error(`Handler for "${e}" already registered (via ${t}). Use addEventListener() to attach multiple listeners, or the on* setter for replace semantics.`);this._methods.add(e)}replace(e){this._methods.add(e)}release(e){this._methods.delete(e)}has(e){return this._methods.has(e)}}var fm=new Set;function gm(e,t){let[o,r]=t,n=o?.shape;if(typeof n?.method?.value!=="string")return;let i=n.method.value,a=e==="request"?"setRequestHandler":"setNotificationHandler";if(!fm.has(a))fm.add(a),console.warn(`[ext-apps] ${a}(Schema, handler) is deprecated; use ${a}("${i}", { params: Schema.shape.params }, handler).`);let u=r;return[i,{params:n.params},e==="request"?(d,p)=>u({method:i,params:d},o_(p)):(d)=>u({method:i,params:d})]}function o_(e){return{signal:e.mcpReq.signal,requestId:e.mcpReq.id,sessionId:e.sessionId,_meta:e.mcpReq._meta,sendRequest:e.mcpReq.send,sendNotification:e.mcpReq.notify,authInfo:e.http?.authInfo}}var r_="2026-01-26";var n_="ui/notifications/tool-input-partial";class zm{eventTarget;eventSource;messageListener;constructor(e=window.parent,t){this.eventTarget=e,this.eventSource=t,this.messageListener=(o)=>{if(t&&o.source!==this.eventSource){console.debug("Ignoring message from unknown source",o);return}let r=De.safeParse(o.data);if(r.success)console.debug("Parsed message",r.data),this.onmessage?.(r.data);else if(o.data?.jsonrpc!=="2.0")console.debug("Ignoring non-JSON-RPC message",r.error.message,o);else console.error("Failed to parse message",r.error.message,o),this.onerror?.(Error("Invalid JSON-RPC message received: "+r.error.message))}}async start(){window.addEventListener("message",this.messageListener)}async send(e,t){if(e.method!==n_)console.debug("Sending message",e);this.eventTarget.postMessage(e,"*")}async close(){window.removeEventListener("message",this.messageListener),this.onclose?.()}onclose;onerror;onmessage;sessionId;setProtocolVersion}var s_=_([l("light"),l("dark")]).describe("Color theme preference for the host environment."),oi=_([l("inline"),l("fullscreen"),l("pip")]).describe("Display mode for UI presentation."),i_=_([l("--color-background-primary"),l("--color-background-secondary"),l("--color-background-tertiary"),l("--color-background-inverse"),l("--color-background-ghost"),l("--color-background-info"),l("--color-background-danger"),l("--color-background-success"),l("--color-background-warning"),l("--color-background-disabled"),l("--color-text-primary"),l("--color-text-secondary"),l("--color-text-tertiary"),l("--color-text-inverse"),l("--color-text-ghost"),l("--color-text-info"),l("--color-text-danger"),l("--color-text-success"),l("--color-text-warning"),l("--color-text-disabled"),l("--color-border-primary"),l("--color-border-secondary"),l("--color-border-tertiary"),l("--color-border-inverse"),l("--color-border-ghost"),l("--color-border-info"),l("--color-border-danger"),l("--color-border-success"),l("--color-border-warning"),l("--color-border-disabled"),l("--color-ring-primary"),l("--color-ring-secondary"),l("--color-ring-inverse"),l("--color-ring-info"),l("--color-ring-danger"),l("--color-ring-success"),l("--color-ring-warning"),l("--font-sans"),l("--font-mono"),l("--font-weight-normal"),l("--font-weight-medium"),l("--font-weight-semibold"),l("--font-weight-bold"),l("--font-text-xs-size"),l("--font-text-sm-size"),l("--font-text-md-size"),l("--font-text-lg-size"),l("--font-heading-xs-size"),l("--font-heading-sm-size"),l("--font-heading-md-size"),l("--font-heading-lg-size"),l("--font-heading-xl-size"),l("--font-heading-2xl-size"),l("--font-heading-3xl-size"),l("--font-text-xs-line-height"),l("--font-text-sm-line-height"),l("--font-text-md-line-height"),l("--font-text-lg-line-height"),l("--font-heading-xs-line-height"),l("--font-heading-sm-line-height"),l("--font-heading-md-line-height"),l("--font-heading-lg-line-height"),l("--font-heading-xl-line-height"),l("--font-heading-2xl-line-height"),l("--font-heading-3xl-line-height"),l("--border-radius-xs"),l("--border-radius-sm"),l("--border-radius-md"),l("--border-radius-lg"),l("--border-radius-xl"),l("--border-radius-full"),l("--border-width-regular"),l("--shadow-hairline"),l("--shadow-sm"),l("--shadow-md"),l("--shadow-lg")]).describe("CSS variable keys available to MCP apps for theming."),a_=S(i_.describe(`Style variables for theming MCP apps.
|
|
68
|
+
*/var D_=Dl((e)=>{var t=/; *([!#$%&'*+.^_`|~0-9A-Za-z-]+) *= *("(?:[\u000b\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\u000b\u0020-\u00ff])*"|[!#$%&'*+.^_`|~0-9A-Za-z-]+) */g,o=/\\([\u000b\u0020-\u00ff])/g,r=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/;e.parse=n;function n(c){if(!c)throw TypeError("argument string is required");var d=typeof c==="object"?i(c):c;if(typeof d!=="string")throw TypeError("argument string is required to be a string");var p=d.indexOf(";"),h=p!==-1?d.slice(0,p).trim():d.trim();if(!r.test(h))throw TypeError("invalid media type");var f=new s(h.toLowerCase());if(p!==-1){var S,b,R;t.lastIndex=p;while(b=t.exec(d)){if(b.index!==p)throw TypeError("invalid parameter format");if(p+=b[0].length,S=b[1].toLowerCase(),R=b[2],R.charCodeAt(0)===34){if(R=R.slice(1,-1),R.indexOf("\\")!==-1)R=R.replace(o,"$1")}f.parameters[S]=R}if(p!==d.length)throw TypeError("invalid parameter format")}return f}function i(c){var d;if(typeof c.getHeader==="function")d=c.getHeader("content-type");else if(typeof c.headers==="object")d=c.headers&&c.headers["content-type"];if(typeof d!=="string")throw TypeError("content-type header is missing from object");return d}function s(c){this.parameters=Object.create(null),this.type=c}}),SR=Fl(D_(),1);function gi(e,t){let o=typeof e;if(o!==typeof t)return!1;if(Array.isArray(e)){if(!Array.isArray(t))return!1;let r=e.length;if(r!==t.length)return!1;for(let n=0;n<r;n++)if(!gi(e[n],t[n]))return!1;return!0}if(o==="object"){if(!e||!t)return e===t;let r=Object.keys(e),n=Object.keys(t);if(r.length!==n.length)return!1;for(let i of r)if(!gi(e[i],t[i]))return!1;return!0}return e===t}function Xe(e){return encodeURI(H_(e))}function H_(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}var F_={prefixItems:!0,items:!0,allOf:!0,anyOf:!0,oneOf:!0},V_={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependentSchemas:!0},J_={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},B_=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 Po(e,t=Object.create(null),o=B_,r=""){if(e&&typeof e==="object"&&!Array.isArray(e)){let i=e.$id||e.id;if(i){let s=new URL(i,o.href);if(s.hash.length>1)t[s.href]=e;else if(s.hash="",r==="")o=s;else Po(e,t,o)}}else if(e!==!0&&e!==!1)return t;let n=o.href+(r?"#"+r:"");if(t[n]!==void 0)throw Error(`Duplicate schema URI "${n}".`);if(t[n]=e,e===!0||e===!1)return t;if(e.__absolute_uri__===void 0)Object.defineProperty(e,"__absolute_uri__",{enumerable:!1,value:n});if(e.$ref&&e.__absolute_ref__===void 0){let i=new URL(e.$ref,o.href);i.hash=i.hash,Object.defineProperty(e,"__absolute_ref__",{enumerable:!1,value:i.href})}if(e.$recursiveRef&&e.__absolute_recursive_ref__===void 0){let i=new URL(e.$recursiveRef,o.href);i.hash=i.hash,Object.defineProperty(e,"__absolute_recursive_ref__",{enumerable:!1,value:i.href})}if(e.$anchor){let i=new URL("#"+e.$anchor,o.href);t[i.href]=e}for(let i in e){if(J_[i])continue;let s=`${r}/${Xe(i)}`,c=e[i];if(Array.isArray(c)){if(F_[i]){let d=c.length;for(let p=0;p<d;p++)Po(c[p],t,o,`${s}/${p}`)}}else if(V_[i])for(let d in c)Po(c[d],t,o,`${s}/${Xe(d)}`);else Po(c,t,o,s)}return t}var W_=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,K_=[0,31,28,31,30,31,30,31,31,30,31,30,31],G_=/^(\d\d):(\d\d):(\d\d)(\.\d+)?(z|[+-]\d\d(?::?\d\d)?)?$/i,Y_=/^(?=.{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,Q_=/^(?:[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,X_=/^(?:(?:[^\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,eb=/^(?:(?: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,tb=/^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i,ob=/^(?:\/(?:[^~/]|~0|~1)*)*$/,rb=/^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i,nb=/^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/,sb=(e)=>{if(e[0]==='"')return!1;let[t,o,...r]=e.split("@");if(!t||!o||r.length!==0||t.length>64||o.length>253)return!1;if(t[0]==="."||t.endsWith(".")||t.includes(".."))return!1;if(!/^[a-z0-9.-]+$/i.test(o)||!/^[a-z0-9.!#$%&'*+/=?^_`{|}~-]+$/i.test(t))return!1;return o.split(".").every((n)=>/^[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?$/i.test(n))},ib=/^(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)$/,ab=/^((([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,cb=(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 gt(e){return e.test.bind(e)}var Jm={date:Bm,time:Wm.bind(void 0,!1),"date-time":db,duration:cb,uri:mb,"uri-reference":gt(Q_),"uri-template":gt(X_),url:gt(eb),email:sb,hostname:gt(Y_),ipv4:gt(ib),ipv6:gt(ab),regex:gb,uuid:gt(tb),"json-pointer":gt(ob),"json-pointer-uri-fragment":gt(rb),"relative-json-pointer":gt(nb)};function lb(e){return e%4===0&&(e%100!==0||e%400===0)}function Bm(e){let t=e.match(W_);if(!t)return!1;let o=+t[1],r=+t[2],n=+t[3];return r>=1&&r<=12&&n>=1&&n<=(r==2&&lb(o)?29:K_[r])}function Wm(e,t){let o=t.match(G_);if(!o)return!1;let r=+o[1],n=+o[2],i=+o[3],s=!!o[5];return(r<=23&&n<=59&&i<=59||r==23&&n==59&&i==60)&&(!e||s)}var ub=/t|\s/i;function db(e){let t=e.split(ub);return t.length==2&&Bm(t[0])&&Wm(!0,t[1])}var pb=/\/|:/,hb=/^(?:[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 mb(e){return pb.test(e)&&hb.test(e)}var fb=/[^\\]\\Z/;function gb(e){if(fb.test(e))return!1;try{return new RegExp(e,"u"),!0}catch(t){return!1}}function Sb(e){let t=0,o=e.length,r=0,n;while(r<o)if(t++,n=e.charCodeAt(r++),n>=55296&&n<=56319&&r<o){if(n=e.charCodeAt(r),(n&64512)==56320)r++}return t}function se(e,t,o="2019-09",r=Po(t),n=!0,i=null,s="#",c="#",d=Object.create(null)){if(t===!0)return{valid:!0,errors:[]};if(t===!1)return{valid:!1,errors:[{instanceLocation:s,keyword:"false",keywordLocation:s,error:"False boolean schema."}]};let p=typeof e,h;switch(p){case"boolean":case"number":case"string":h=p;break;case"object":if(e===null)h="null";else if(Array.isArray(e))h="array";else h="object";break;default:throw Error(`Instances of "${p}" type are not supported.`)}let{$ref:f,$recursiveRef:S,$recursiveAnchor:b,type:R,const:w,enum:O,required:J,not:B,anyOf:j,allOf:F,oneOf:Y,if:K,then:ie,else:Le,format:ce,properties:Ue,patternProperties:We,additionalProperties:It,unevaluatedProperties:Ot,minProperties:et,maxProperties:Ze,propertyNames:tt,dependentRequired:xe,dependentSchemas:De,dependencies:ot,prefixItems:ke,items:_e,additionalItems:St,unevaluatedItems:_t,contains:rt,minContains:me,maxContains:be,minItems:ye,maxItems:Ke,uniqueItems:Gt,minimum:$e,maximum:Ce,exclusiveMinimum:Ee,exclusiveMaximum:He,multipleOf:Fe,minLength:nt,maxLength:st,pattern:Mt,__absolute_ref__:it,__absolute_recursive_ref__:Yt}=t,E=[];if(b===!0&&i===null)i=t;if(S==="#"){let A=i===null?r[Yt]:i,C=`${c}/$recursiveRef`,H=se(e,i===null?t:i,o,r,n,A,s,C,d);if(!H.valid)E.push({instanceLocation:s,keyword:"$recursiveRef",keywordLocation:C,error:"A subschema had errors."},...H.errors)}if(f!==void 0){let A=r[it||f];if(A===void 0){let T=`Unresolved $ref "${f}".`;if(it&&it!==f)T+=` Absolute URI "${it}".`;throw T+=`
|
|
69
|
+
Known schemas:
|
|
70
|
+
- ${Object.keys(r).join(`
|
|
71
|
+
- `)}`,Error(T)}let C=`${c}/$ref`,H=se(e,A,o,r,n,i,s,C,d);if(!H.valid)E.push({instanceLocation:s,keyword:"$ref",keywordLocation:C,error:"A subschema had errors."},...H.errors);if(o==="4"||o==="7")return{valid:E.length===0,errors:E}}if(Array.isArray(R)){let A=R.length,C=!1;for(let H=0;H<A;H++)if(h===R[H]||R[H]==="integer"&&h==="number"&&e%1===0&&e===e){C=!0;break}if(!C)E.push({instanceLocation:s,keyword:"type",keywordLocation:`${c}/type`,error:`Instance type "${h}" is invalid. Expected "${R.join('", "')}".`})}else if(R==="integer"){if(h!=="number"||e%1||e!==e)E.push({instanceLocation:s,keyword:"type",keywordLocation:`${c}/type`,error:`Instance type "${h}" is invalid. Expected "${R}".`})}else if(R!==void 0&&h!==R)E.push({instanceLocation:s,keyword:"type",keywordLocation:`${c}/type`,error:`Instance type "${h}" is invalid. Expected "${R}".`});if(w!==void 0){if(h==="object"||h==="array"){if(!gi(e,w))E.push({instanceLocation:s,keyword:"const",keywordLocation:`${c}/const`,error:`Instance does not match ${JSON.stringify(w)}.`})}else if(e!==w)E.push({instanceLocation:s,keyword:"const",keywordLocation:`${c}/const`,error:`Instance does not match ${JSON.stringify(w)}.`})}if(O!==void 0){if(h==="object"||h==="array"){if(!O.some((A)=>gi(e,A)))E.push({instanceLocation:s,keyword:"enum",keywordLocation:`${c}/enum`,error:`Instance does not match any of ${JSON.stringify(O)}.`})}else if(!O.some((A)=>e===A))E.push({instanceLocation:s,keyword:"enum",keywordLocation:`${c}/enum`,error:`Instance does not match any of ${JSON.stringify(O)}.`})}if(B!==void 0){let A=`${c}/not`;if(se(e,B,o,r,n,i,s,A).valid)E.push({instanceLocation:s,keyword:"not",keywordLocation:A,error:'Instance matched "not" schema.'})}let at=[];if(j!==void 0){let A=`${c}/anyOf`,C=E.length,H=!1;for(let T=0;T<j.length;T++){let x=j[T],Z=Object.create(d),L=se(e,x,o,r,n,b===!0?i:null,s,`${A}/${T}`,Z);if(E.push(...L.errors),H=H||L.valid,L.valid)at.push(Z)}if(H)E.length=C;else E.splice(C,0,{instanceLocation:s,keyword:"anyOf",keywordLocation:A,error:"Instance does not match any subschemas."})}if(F!==void 0){let A=`${c}/allOf`,C=E.length,H=!0;for(let T=0;T<F.length;T++){let x=F[T],Z=Object.create(d),L=se(e,x,o,r,n,b===!0?i:null,s,`${A}/${T}`,Z);if(E.push(...L.errors),H=H&&L.valid,L.valid)at.push(Z)}if(H)E.length=C;else E.splice(C,0,{instanceLocation:s,keyword:"allOf",keywordLocation:A,error:"Instance does not match every subschema."})}if(Y!==void 0){let A=`${c}/oneOf`,C=E.length,H=Y.filter((T,x)=>{let Z=Object.create(d),L=se(e,T,o,r,n,b===!0?i:null,s,`${A}/${x}`,Z);if(E.push(...L.errors),L.valid)at.push(Z);return L.valid}).length;if(H===1)E.length=C;else E.splice(C,0,{instanceLocation:s,keyword:"oneOf",keywordLocation:A,error:`Instance does not match exactly one subschema (${H} matches).`})}if(h==="object"||h==="array")Object.assign(d,...at);if(K!==void 0){let A=`${c}/if`;if(se(e,K,o,r,n,i,s,A,d).valid){if(ie!==void 0){let C=se(e,ie,o,r,n,i,s,`${c}/then`,d);if(!C.valid)E.push({instanceLocation:s,keyword:"if",keywordLocation:A,error:'Instance does not match "then" schema.'},...C.errors)}}else if(Le!==void 0){let C=se(e,Le,o,r,n,i,s,`${c}/else`,d);if(!C.valid)E.push({instanceLocation:s,keyword:"if",keywordLocation:A,error:'Instance does not match "else" schema.'},...C.errors)}}if(h==="object"){if(J!==void 0){for(let T of J)if(!(T in e))E.push({instanceLocation:s,keyword:"required",keywordLocation:`${c}/required`,error:`Instance does not have required property "${T}".`})}let A=Object.keys(e);if(et!==void 0&&A.length<et)E.push({instanceLocation:s,keyword:"minProperties",keywordLocation:`${c}/minProperties`,error:`Instance does not have at least ${et} properties.`});if(Ze!==void 0&&A.length>Ze)E.push({instanceLocation:s,keyword:"maxProperties",keywordLocation:`${c}/maxProperties`,error:`Instance does not have at least ${Ze} properties.`});if(tt!==void 0){let T=`${c}/propertyNames`;for(let x in e){let Z=`${s}/${Xe(x)}`,L=se(x,tt,o,r,n,i,Z,T);if(!L.valid)E.push({instanceLocation:s,keyword:"propertyNames",keywordLocation:T,error:`Property name "${x}" does not match schema.`},...L.errors)}}if(xe!==void 0){let T=`${c}/dependantRequired`;for(let x in xe)if(x in e){let Z=xe[x];for(let L of Z)if(!(L in e))E.push({instanceLocation:s,keyword:"dependentRequired",keywordLocation:T,error:`Instance has "${x}" but does not have "${L}".`})}}if(De!==void 0)for(let T in De){let x=`${c}/dependentSchemas`;if(T in e){let Z=se(e,De[T],o,r,n,i,s,`${x}/${Xe(T)}`,d);if(!Z.valid)E.push({instanceLocation:s,keyword:"dependentSchemas",keywordLocation:x,error:`Instance has "${T}" but does not match dependant schema.`},...Z.errors)}}if(ot!==void 0){let T=`${c}/dependencies`;for(let x in ot)if(x in e){let Z=ot[x];if(Array.isArray(Z)){for(let L of Z)if(!(L in e))E.push({instanceLocation:s,keyword:"dependencies",keywordLocation:T,error:`Instance has "${x}" but does not have "${L}".`})}else{let L=se(e,Z,o,r,n,i,s,`${T}/${Xe(x)}`);if(!L.valid)E.push({instanceLocation:s,keyword:"dependencies",keywordLocation:T,error:`Instance has "${x}" but does not match dependant schema.`},...L.errors)}}}let C=Object.create(null),H=!1;if(Ue!==void 0){let T=`${c}/properties`;for(let x in Ue){if(!(x in e))continue;let Z=`${s}/${Xe(x)}`,L=se(e[x],Ue[x],o,r,n,i,Z,`${T}/${Xe(x)}`);if(L.valid)d[x]=C[x]=!0;else if(H=n,E.push({instanceLocation:s,keyword:"properties",keywordLocation:T,error:`Property "${x}" does not match schema.`},...L.errors),H)break}}if(!H&&We!==void 0){let T=`${c}/patternProperties`;for(let x in We){let Z=new RegExp(x,"u"),L=We[x];for(let le in e){if(!Z.test(le))continue;let Qt=`${s}/${Xe(le)}`,ct=se(e[le],L,o,r,n,i,Qt,`${T}/${Xe(x)}`);if(ct.valid)d[le]=C[le]=!0;else H=n,E.push({instanceLocation:s,keyword:"patternProperties",keywordLocation:T,error:`Property "${le}" matches pattern "${x}" but does not match associated schema.`},...ct.errors)}}}if(!H&&It!==void 0){let T=`${c}/additionalProperties`;for(let x in e){if(C[x])continue;let Z=`${s}/${Xe(x)}`,L=se(e[x],It,o,r,n,i,Z,T);if(L.valid)d[x]=!0;else H=n,E.push({instanceLocation:s,keyword:"additionalProperties",keywordLocation:T,error:`Property "${x}" does not match additional properties schema.`},...L.errors)}}else if(!H&&Ot!==void 0){let T=`${c}/unevaluatedProperties`;for(let x in e)if(!d[x]){let Z=`${s}/${Xe(x)}`,L=se(e[x],Ot,o,r,n,i,Z,T);if(L.valid)d[x]=!0;else E.push({instanceLocation:s,keyword:"unevaluatedProperties",keywordLocation:T,error:`Property "${x}" does not match unevaluated properties schema.`},...L.errors)}}}else if(h==="array"){if(Ke!==void 0&&e.length>Ke)E.push({instanceLocation:s,keyword:"maxItems",keywordLocation:`${c}/maxItems`,error:`Array has too many items (${e.length} > ${Ke}).`});if(ye!==void 0&&e.length<ye)E.push({instanceLocation:s,keyword:"minItems",keywordLocation:`${c}/minItems`,error:`Array has too few items (${e.length} < ${ye}).`});let A=e.length,C=0,H=!1;if(ke!==void 0){let T=`${c}/prefixItems`,x=Math.min(ke.length,A);for(;C<x;C++){let Z=se(e[C],ke[C],o,r,n,i,`${s}/${C}`,`${T}/${C}`);if(d[C]=!0,!Z.valid){if(H=n,E.push({instanceLocation:s,keyword:"prefixItems",keywordLocation:T,error:"Items did not match schema."},...Z.errors),H)break}}}if(_e!==void 0){let T=`${c}/items`;if(Array.isArray(_e)){let x=Math.min(_e.length,A);for(;C<x;C++){let Z=se(e[C],_e[C],o,r,n,i,`${s}/${C}`,`${T}/${C}`);if(d[C]=!0,!Z.valid){if(H=n,E.push({instanceLocation:s,keyword:"items",keywordLocation:T,error:"Items did not match schema."},...Z.errors),H)break}}}else for(;C<A;C++){let x=se(e[C],_e,o,r,n,i,`${s}/${C}`,T);if(d[C]=!0,!x.valid){if(H=n,E.push({instanceLocation:s,keyword:"items",keywordLocation:T,error:"Items did not match schema."},...x.errors),H)break}}if(!H&&St!==void 0){let x=`${c}/additionalItems`;for(;C<A;C++){let Z=se(e[C],St,o,r,n,i,`${s}/${C}`,x);if(d[C]=!0,!Z.valid)H=n,E.push({instanceLocation:s,keyword:"additionalItems",keywordLocation:x,error:"Items did not match additional items schema."},...Z.errors)}}}if(rt!==void 0)if(A===0&&me===void 0)E.push({instanceLocation:s,keyword:"contains",keywordLocation:`${c}/contains`,error:"Array is empty. It must contain at least one item matching the schema."});else if(me!==void 0&&A<me)E.push({instanceLocation:s,keyword:"minContains",keywordLocation:`${c}/minContains`,error:`Array has less items (${A}) than minContains (${me}).`});else{let T=`${c}/contains`,x=E.length,Z=0;for(let L=0;L<A;L++){let le=se(e[L],rt,o,r,n,i,`${s}/${L}`,T);if(le.valid)d[L]=!0,Z++;else E.push(...le.errors)}if(Z>=(me||0))E.length=x;if(me===void 0&&be===void 0&&Z===0)E.splice(x,0,{instanceLocation:s,keyword:"contains",keywordLocation:T,error:"Array does not contain item matching schema."});else if(me!==void 0&&Z<me)E.push({instanceLocation:s,keyword:"minContains",keywordLocation:`${c}/minContains`,error:`Array must contain at least ${me} items matching schema. Only ${Z} items were found.`});else if(be!==void 0&&Z>be)E.push({instanceLocation:s,keyword:"maxContains",keywordLocation:`${c}/maxContains`,error:`Array may contain at most ${be} items matching schema. ${Z} items were found.`})}if(!H&&_t!==void 0){let T=`${c}/unevaluatedItems`;for(;C<A;C++){if(d[C])continue;let x=se(e[C],_t,o,r,n,i,`${s}/${C}`,T);if(d[C]=!0,!x.valid)E.push({instanceLocation:s,keyword:"unevaluatedItems",keywordLocation:T,error:"Items did not match unevaluated items schema."},...x.errors)}}if(Gt)for(let T=0;T<A;T++){let x=e[T],Z=typeof x==="object"&&x!==null;for(let L=0;L<A;L++){if(T===L)continue;let le=e[L];if(x===le||Z&&typeof le==="object"&&le!==null&&gi(x,le))E.push({instanceLocation:s,keyword:"uniqueItems",keywordLocation:`${c}/uniqueItems`,error:`Duplicate items at indexes ${T} and ${L}.`}),T=Number.MAX_SAFE_INTEGER,L=Number.MAX_SAFE_INTEGER}}}else if(h==="number"){if(o==="4"){if($e!==void 0&&(Ee===!0&&e<=$e||e<$e))E.push({instanceLocation:s,keyword:"minimum",keywordLocation:`${c}/minimum`,error:`${e} is less than ${Ee?"or equal to ":""} ${$e}.`});if(Ce!==void 0&&(He===!0&&e>=Ce||e>Ce))E.push({instanceLocation:s,keyword:"maximum",keywordLocation:`${c}/maximum`,error:`${e} is greater than ${He?"or equal to ":""} ${Ce}.`})}else{if($e!==void 0&&e<$e)E.push({instanceLocation:s,keyword:"minimum",keywordLocation:`${c}/minimum`,error:`${e} is less than ${$e}.`});if(Ce!==void 0&&e>Ce)E.push({instanceLocation:s,keyword:"maximum",keywordLocation:`${c}/maximum`,error:`${e} is greater than ${Ce}.`});if(Ee!==void 0&&e<=Ee)E.push({instanceLocation:s,keyword:"exclusiveMinimum",keywordLocation:`${c}/exclusiveMinimum`,error:`${e} is less than ${Ee}.`});if(He!==void 0&&e>=He)E.push({instanceLocation:s,keyword:"exclusiveMaximum",keywordLocation:`${c}/exclusiveMaximum`,error:`${e} is greater than or equal to ${He}.`})}if(Fe!==void 0){let A=e%Fe;if(Math.abs(0-A)>=0.00000011920929&&Math.abs(Fe-A)>=0.00000011920929)E.push({instanceLocation:s,keyword:"multipleOf",keywordLocation:`${c}/multipleOf`,error:`${e} is not a multiple of ${Fe}.`})}}else if(h==="string"){let A=nt===void 0&&st===void 0?0:Sb(e);if(nt!==void 0&&A<nt)E.push({instanceLocation:s,keyword:"minLength",keywordLocation:`${c}/minLength`,error:`String is too short (${A} < ${nt}).`});if(st!==void 0&&A>st)E.push({instanceLocation:s,keyword:"maxLength",keywordLocation:`${c}/maxLength`,error:`String is too long (${A} > ${st}).`});if(Mt!==void 0&&!new RegExp(Mt,"u").test(e))E.push({instanceLocation:s,keyword:"pattern",keywordLocation:`${c}/pattern`,error:"String does not match pattern."});if(ce!==void 0&&Jm[ce]&&!Jm[ce](e))E.push({instanceLocation:s,keyword:"format",keywordLocation:`${c}/format`,error:`String does not match format "${ce}".`})}return{valid:E.length===0,errors:E}}var _b=class{schema;draft;shortCircuit;lookup;constructor(e,t="2019-09",o=!0){this.schema=e,this.draft=t,this.shortCircuit=o,this.lookup=Po(e)}validate(e){return se(e,this.schema,this.draft,this.lookup,this.shortCircuit)}addSchema(e,t){if(t)e={...e,$id:t};Po(e,this.lookup)}},Ha=class{shortcircuit;draft;constructor(e){this.shortcircuit=e?.shortcircuit??!0,this.draft=e?.draft}_draftFor(e){let t=Bl(e,"pass an explicit { draft } to CfWorkerJsonSchemaValidator to validate other dialects.");return t==="draft-7"?"7":t}getValidator(e){let t=new _b(e,this.draft??this._draftFor(e),this.shortcircuit);return(o)=>{let r=t.validate(o);return r.valid?{valid:!0,data:o,errorMessage:void 0}:{valid:!1,data:void 0,errorMessage:r.errors.map((n)=>`${n.instanceLocation}: ${n.error}`).join("; ")}}}};var bb;bb=globalThis.crypto;var Tr=class extends Error{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.OAuthClientFlowError"})}static[Symbol.hasInstance](e){return Pe(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 Pe(this,e)}constructor(e){super(e);this.name=new.target.name,Bt(this,new.target)}},xb=class extends Tr{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.IssuerMismatchError"})}kind;expected;received;constructor(e,t,o){super(`Issuer mismatch in ${e==="metadata"?"authorization server metadata (RFC 8414 §3.3)":"authorization response (RFC 9207)"}: expected ${JSON.stringify(t)}, received ${JSON.stringify(o)}`);this.kind=e,this.expected=t,this.received=o}},Eb=class extends Tr{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.RegistrationRejectedError"})}status;body;submittedMetadata;constructor(e){super(`Dynamic Client Registration rejected (HTTP ${e.status}): ${e.body}`);this.status=e.status,this.body=e.body,this.submittedMetadata=e.submittedMetadata}},Tb=class extends Tr{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.InsecureTokenEndpointError"})}tokenEndpoint;constructor(e){super(`Refusing to send credentials to non-https token endpoint '${e}'. OAuth token requests MUST use TLS (localhost / *.localhost / 127.0.0.1 / ::1 are exempt).`);this.tokenEndpoint=e}},Pb=class extends Tr{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.AuthorizationServerMismatchError"})}constructor(e,t){super(`Authorization server mismatch: credentials are bound to ${JSON.stringify(e)} but this call resolved ${JSON.stringify(t)}; refusing to present them to a different authorization server`);this.recordedIssuer=e,this.currentIssuer=t}},kb=class extends Tr{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.InsufficientScopeError"})}requiredScope;resourceMetadataUrl;errorDescription;constructor(e){super(`Insufficient scope${e.requiredScope?`: required "${e.requiredScope}"`:""}`);this.requiredScope=e.requiredScope,this.resourceMetadataUrl=e.resourceMetadataUrl,this.errorDescription=e.errorDescription}};var of=class extends Error{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.UnauthorizedError"})}static[Symbol.hasInstance](e){return Pe(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 Pe(this,e)}constructor(e){super(e??"Unauthorized");this.name="UnauthorizedError",Bt(this,new.target)}};var Fa=new Set(["tools/list","prompts/list","resources/list","resources/templates/list","server/discover"]),rf=class{_entries=new Map;_maxEntries;_stamp=0;_cappedSize=0;constructor(e){this._maxEntries=e?.maxEntries??512}get size(){return this._entries.size}get(e){return this._entries.get(kl(e))}set(e,t){let o=kl(e),r=Fa.has(e.method),n=!this._entries.has(o);if(!r&&n&&this._maxEntries>0&&this._cappedSize>=this._maxEntries){for(let s of this._entries.keys())if(!Fa.has(s.slice(0,s.indexOf("\x00")))){this._entries.delete(s),this._cappedSize--;break}}let i=++this._stamp;if(this._entries.set(o,{...t,stamp:i}),n&&!r)this._cappedSize++;return i}delete(e){if(this._entries.delete(kl(e))&&!Fa.has(e.method))this._cappedSize--}evict(e){let t=`${e}\x00`,o=Fa.has(e);for(let r of this._entries.keys())if(r.startsWith(t)){if(this._entries.delete(r),!o)this._cappedSize--}}clear(){this._entries.clear(),this._cappedSize=0}};function kl(e){return`${e.method}\x00${JSON.stringify([e.partition??"",e.params??""])}`}function $l(e,t){return t===void 0?e:`${e}\x00${t}`}var nf=86400000,$b=class{_evictionGeneration=new Map;_toolIndex;_toolOutputValidatorIndex;_serverIdentity="";constructor(e,t,o=()=>{},r="",n=Date.now){this._store=e,this._isUserSupplied=t,this._reportError=o,this._cachePartition=r,this._now=n}now(){return this._now()}setServerIdentity(e){this._serverIdentity=e}_partitionFor(e){return JSON.stringify([this._serverIdentity,e==="public"?"":this._cachePartition])}async _probe(e,t){let o={method:e,params:t??""},r=this._partitionFor("private"),n=await this._store.get({...o,partition:r});if(n!==void 0)return n;let i=this._partitionFor("public");if(i===r)return;let s=await this._store.get({...o,partition:i});return s?.scope==="public"?s:void 0}async evict(e){this._evictionGeneration.set(e,(this._evictionGeneration.get(e)??0)+1),await this._deleteBoth(e,"")}async _deleteBoth(e,t){let o=this._partitionFor("private"),r=this._partitionFor("public");try{await this._store.delete({method:e,params:t,partition:o})}catch(n){this._reportError(n)}if(r!==o)try{await this._store.delete({method:e,params:t,partition:r})}catch(n){this._reportError(n)}}async evictKey(e,t){let o=$l(e,t),r=this._evictionGeneration.get(o);if(r!==void 0)this._evictionGeneration.set(o,r+1);await this._deleteBoth(e,t)}captureGeneration(e,t){let o=$l(e,t),r=this._evictionGeneration.get(o)??0;return this._evictionGeneration.set(o,r),r}async write(e,t,o,r){if((this._evictionGeneration.get($l(e,r?.params))??0)!==o)return;let n=r?.params??"",i=this._partitionFor("private"),s=this._partitionFor("public"),c=(r?.scope??"private")==="public"?s:i;try{await this._store.set({method:e,params:n,partition:c},{value:Cb(t),expiresAt:r?.expiresAt,scope:r?.scope})}catch(d){this._reportError(d)}if(s!==i)try{await this._store.delete({method:e,params:n,partition:c===i?s:i})}catch(d){this._reportError(d)}}async read(e,t){let o=await this._probe(e,t);if(o?.expiresAt===void 0||!(o.expiresAt>this.now()))return;try{let r=JSON.parse(o.value);if(typeof r!=="object"||r===null||Array.isArray(r))throw TypeError("cached document is not an object");return{value:r}}catch(r){this._reportError(r),await this._deleteBoth(e,t??"");return}}resetForReconnect(){if(!this._isUserSupplied)this._store.clear();this._evictionGeneration.clear(),this._toolIndex=void 0,this._toolOutputValidatorIndex=void 0,this._serverIdentity=""}async toolDefinition(e){let t=await this._probe("tools/list");if(t===void 0){this._toolIndex=void 0;return}if(this._toolIndex?.stamp!==t.stamp){let o=this._decodeListTools(t),r=new Map;if(o!==void 0)for(let n of o.tools)r.set(n.name,n);this._toolIndex={stamp:t.stamp,byName:r}}return this._toolIndex.byName.get(e)}async outputValidator(e,t){let o=await this._probe("tools/list");if(o===void 0){this._toolOutputValidatorIndex=void 0;return}if(this._toolOutputValidatorIndex?.stamp!==o.stamp){let r=this._decodeListTools(o)??{tools:[]},n=new Map;for(let i of r.tools){let s=t(i);if(s!==void 0)n.set(i.name,s)}this._toolOutputValidatorIndex={stamp:o.stamp,byName:n}}return this._toolOutputValidatorIndex.byName.get(e)}_decodeListTools(e){try{let t=JSON.parse(e.value);if(!Array.isArray(t?.tools)||!t.tools.every((o)=>o!==null&&typeof o==="object"))throw TypeError("cached tools/list document has a malformed tools array");return t}catch(t){this._reportError(t);return}}};function Cb(e){let t;try{t=JSON.stringify(e)}catch(o){throw TypeError(`cache value is not JSON-serializable: ${o instanceof Error?o.message:String(o)}`)}if(typeof t!=="string")throw TypeError("cache value is not JSON-serializable: it has no JSON representation");return t}var Ib=Symbol.for("mcp.authSeamEscape");function Ob(e){return(typeof e==="object"&&e!==null||typeof e==="function")&&e[Ib]===!0}var Mb=-32022,qb=new Set([-32001,-32020,-32021]);function Nb(e,t){switch(e.kind){case"result":return Ab(e.result,t);case"rpc-error":return sf(e,t);case"http-error":return jb(e,t);case"network-error":return Km(e.error,t);case"unusable-reply":return{kind:"error",error:new k(M.EraNegotiationFailed,`Version negotiation probe failed: the server answered with an unusable reply (${af(e.error)})`,{cause:e.error},{cause:e.error})};case"auth-required":return{kind:"error",error:e.error};case"closed":if(t.transportKind==="stdio")return{kind:"legacy"};return Km(Error("Connection closed during the version negotiation probe"),t);case"timeout":if(t.transportKind==="stdio")return{kind:"legacy"};return{kind:"error",error:new k(M.RequestTimeout,`Version negotiation probe timed out after ${e.timeoutMs}ms`,{timeout:e.timeoutMs})}}}function Ab(e,t){let o=$t(Ua).validateResult("server/discover",e);if(!o.ok)return{kind:"legacy"};let r=o.value.supportedVersions,n=t.clientModernVersions.find((i)=>r.includes(i));if(n!==void 0)return{kind:"modern",version:n,discover:o.value};if(t.fallbackAvailable)return{kind:"legacy"};return{kind:"error",error:new hi({supported:[...r],requested:t.requestedVersion})}}function sf(e,t){let{code:o,message:r,data:n}=e;if(o===Mb){let i=Ub(n);if(i===void 0)return{kind:"legacy"};let s=new hi({supported:i,requested:Zb(n)??t.requestedVersion},r),c=pi(i),d=t.clientModernVersions.find((p)=>c.includes(p));if(d!==void 0)return{kind:"corrective",version:d,error:s};if(c.length>0)return{kind:"error",error:s};return t.fallbackAvailable?{kind:"legacy"}:{kind:"error",error:s}}if(qb.has(o))return{kind:"legacy"};return{kind:"legacy"}}function jb(e,t){if(e.status===401||e.status===403){let r=e.status===403;return{kind:"error",error:new di(r?M.ClientHttpForbidden:M.ClientHttpAuthentication,`Version negotiation failed: ${r?"the server denied access (HTTP 403)":"the server requires authorization (HTTP 401)"}`,{status:e.status,statusText:e.statusText,text:e.body})}}if(e.status>=500)return{kind:"error",error:new di(M.EraNegotiationFailed,`Version negotiation failed: the server answered the probe with HTTP ${e.status}`,{status:e.status,statusText:e.statusText,text:e.body})};let o=Db(e.body);if(o!==void 0)return sf(o,t);return{kind:"legacy"}}function Km(e,t){if(t.environment==="browser"&&Lb(e))return{kind:"legacy"};return{kind:"error",error:new k(M.EraNegotiationFailed,`Version negotiation probe failed: ${af(e)}`,{cause:e},{cause:e})}}function Lb(e){return e instanceof TypeError||e instanceof Error&&e.name==="TypeError"}function af(e){return e instanceof Error?e.message:String(e)}function Ub(e){if(typeof e!=="object"||e===null)return;let t=e.supported;if(!Array.isArray(t)||t.length===0||!t.every((o)=>typeof o==="string"))return;return t}function Zb(e){if(typeof e!=="object"||e===null)return;let t=e.requested;return typeof t==="string"?t:void 0}function Db(e){if(e===void 0||e==="")return;let t;try{t=JSON.parse(e)}catch{return}if(typeof t!=="object"||t===null)return;let o=t.error;if(typeof o!=="object"||o===null)return;let{code:r,message:n,data:i}=o;if(typeof r!=="number")return;return{code:r,message:typeof n==="string"?n:"",data:i}}var Hb="legacy";function Fb(e,t){let o=e?.mode??Hb;if(o==="legacy")return{kind:"legacy"};let r=e?.probe??{};if(typeof o==="object"){if(!Ct(o.pin))throw TypeError(`versionNegotiation: { pin: '${o.pin}' } is not a modern protocol revision — pinning is for 2026-07-28 and later; omit versionNegotiation (or use mode: 'legacy') for 2025-era servers.`);return{kind:"pin",version:o.pin,probe:r}}let n=t?pi(t):[];return{kind:"auto",modernVersions:n.length>0?n:[...Sl],fallbackAvailable:t?_l(t).length>0:!0,probe:r}}function Gm(){let e=globalThis;return e.window!==void 0&&e.document!==void 0?"browser":"node"}function Ym(e){return"stderr"in e&&"pid"in e?"stdio":"http"}var Vb=class e{_pending;_probeCounter=0;_savedOnMessage;_savedOnError;_savedOnClose;_closeDelivered=!1;constructor(t){this._transport=t,this._savedOnMessage=t.onmessage,this._savedOnError=t.onerror,this._savedOnClose=t.onclose}static async open(t){let o=new e(t);t.onmessage=(r)=>{let n=o._pending;if(n!==void 0&&(Er(r)||mi(r))&&r.id===n.id){if(o._pending=void 0,Er(r))n.resolve({kind:"response",result:r.result});else n.resolve({kind:"response",error:r.error});return}},t.onerror=(r)=>{o._savedOnError?.(r)},t.onclose=()=>{let r=o._pending;if(r!==void 0)o._pending=void 0,r.resolve({kind:"closed"});o._closeDelivered=!0,o._savedOnClose?.()};try{await t.start()}catch(r){throw o.detach(),r}return o}async exchange(t,o){let r=`server-discover-probe-${++this._probeCounter}`;return new Promise((n)=>{let i=!1,s=(d)=>{if(i)return;if(i=!0,clearTimeout(c),this._pending?.id===r)this._pending=void 0;n(d)},c=setTimeout(()=>s({kind:"timeout"}),o);this._pending={id:r,resolve:s},this._transport.send(t(r)).catch((d)=>s({kind:"send-error",error:d}))})}detach(){if(this._pending=void 0,this._transport.onmessage=this._savedOnMessage,this._transport.onerror=this._savedOnError,this._closeDelivered&&this._savedOnClose!==void 0){let t=this._savedOnClose,o=this._transport,r=!1,n=()=>{if(!r){r=!0;return}t()};o.onclose=n,Il.set(o,()=>{if(o.onclose===n)o.onclose=t})}else this._transport.onclose=this._savedOnClose}release(){this.detach();let t=this._transport,o=t.start,r=!0;t.start=async function(){if(r){r=!1,t.start=o;return}return o.call(t)}}},Il=new WeakMap;function Qm(e){let t=Il.get(e);Il.delete(e),t?.()}function Jb(e,t,o,r){return{jsonrpc:"2.0",id:e,method:"server/discover",params:{_meta:$t(t).outboundEnvelope({protocolVersion:t,clientInfo:o,clientCapabilities:r})}}}function Bb(e){if(e instanceof k&&e.code===M.ClientHttpUnexpectedContent)return!0;return e instanceof Error&&e.name==="SyntaxError"}function Wb(e,t){switch(e.kind){case"response":return e.error===void 0?{kind:"result",result:e.result}:{kind:"rpc-error",...e.error};case"send-error":{let o=e.error;if(Ob(o)||o instanceof of||o instanceof Error&&o.name==="UnauthorizedError")return{kind:"auth-required",error:o};if(o instanceof di){let r=o.data?.text;return{kind:"http-error",status:o.data.status,body:typeof r==="string"?r:void 0,statusText:o.data.statusText}}if(Bb(o))return{kind:"unusable-reply",error:o};return{kind:"network-error",error:o}}case"closed":return{kind:"closed"};case"timeout":return{kind:"timeout",timeoutMs:t}}}async function cf(e,t){let o=e.probe.timeoutMs??t.defaultTimeoutMs,r=Math.max(0,e.probe.maxRetries??0),n=e.kind==="pin"?[e.version]:e.modernVersions,i=e.kind==="auto"&&e.fallbackAvailable,s=await Vb.open(t.transport),c=async()=>{let p=n[0],h=!1,f=r;for(;;){let S=await s.exchange((w)=>Jb(w,p,t.clientInfo,t.capabilities),o);if(S.kind==="timeout"&&f>0){f--;continue}let b=Wb(S,o),R=Nb(b,{clientModernVersions:n,requestedVersion:p,fallbackAvailable:i,environment:t.environment,transportKind:t.transportKind});switch(R.kind){case"modern":return{era:"modern",version:R.version,discover:R.discover};case"corrective":if(h)throw R.error;h=!0,p=R.version;continue;case"legacy":{let w=b.kind==="closed"?"the connection closed during the server/discover probe":void 0;if(e.kind==="pin")throw new k(M.EraNegotiationFailed,w===void 0?`Version negotiation failed: the server did not offer pinned protocol version ${e.version} via server/discover (no fallback in pin mode)`:`Version negotiation failed: ${w} before the server offered pinned protocol version ${e.version} (no fallback in pin mode)`);if(!e.fallbackAvailable)throw new k(M.EraNegotiationFailed,w===void 0?"Version negotiation failed: the server gave no modern evidence and this client supports no pre-2026-07-28 protocol version to fall back to":`Version negotiation failed: ${w} and this client supports no pre-2026-07-28 protocol version to fall back to`);if(w!==void 0&&t.disposableProbe!==!0)throw new k(M.EraNegotiationFailed,`Version negotiation failed: ${w} (this transport probed in place — the disposable sibling probe requires the SDK's base StdioClientTransport)`);return{era:"legacy"}}case"error":throw R.error}}},d;try{d=await c()}catch(p){throw s.detach(),p}return s.release(),d}function Kb(e){let t=Object.getPrototypeOf(e);if(t===null||!Object.prototype.hasOwnProperty.call(t,"_dispose"))return;let o=e._serverParams;return typeof o==="object"&&o!==null&&typeof o.command==="string"?o:void 0}async function Gb(e,t,o,r){let i=new t.constructor({...o,stderr:"ignore"}),s=t.close,c=!1,d,p=new Promise((f,S)=>{d=()=>S(Xm())});t.close=async function(){return c=!0,d?.(),s.call(t)};let h;try{let f=cf(e,{...r,transport:i,transportKind:"stdio",disposableProbe:!0});f.catch(()=>{}),h=await Promise.race([f,p])}finally{await Yb(i),t.close=s}if(c)throw Xm();return h}function Xm(){return new k(M.EraNegotiationFailed,"Version negotiation failed: the transport was closed during the server/discover probe")}async function Yb(e){try{let t=e._dispose;await(typeof t==="function"?t.call(e):e.close())}catch{}}function ef(e){let t=e._meta?.[dt];return El.Implementation(t)?t:void 0}function Va(e,t){if(!e||t===null||typeof t!=="object")return;if(e.type==="object"&&e.properties&&typeof e.properties==="object"){let o=t,r=e.properties;for(let n of Object.keys(r)){let i=r[n];if(o[n]===void 0&&Object.prototype.hasOwnProperty.call(i,"default"))o[n]=i.default;if(o[n]!==void 0)Va(i,o[n])}}if(Array.isArray(e.anyOf)){for(let o of e.anyOf)if(typeof o!=="boolean")Va(o,t)}if(Array.isArray(e.oneOf)){for(let o of e.oneOf)if(typeof o!=="boolean")Va(o,t)}}function lf(e){if(!e)return{supportsFormMode:!1,supportsUrlMode:!1};let t=e.form!==void 0,o=e.url!==void 0;return{supportsFormMode:t||!t&&!o,supportsUrlMode:o}}function Qb(e){if(typeof e==="object"&&e!==null){if(e.kind==="legacy"&&!("supportedVersions"in e)&&!("discover"in e))return e;if(e.kind==="modern"&&Vt.safeParse(e.discover).success)return e}throw new k(M.EraNegotiationFailed,"connect({ prior }): unrecognized prior — expected { kind: 'modern', discover } or { kind: 'legacy' }")}var tf={"notifications/tools/list_changed":["tools/list"],"notifications/prompts/list_changed":["prompts/list"],"notifications/resources/list_changed":["resources/list","resources/templates/list"]},Xb=64,Cl={},ey=class extends To{_serverCapabilities;_serverVersion;_capabilities;_instructions;_jsonSchemaValidator;_cache;_defaultCacheTtlMs;_listMaxPages;_listChangedDebounceTimers=new Map;_listChangedConfig;_enforceStrictCapabilities;_versionNegotiation;_supportedProtocolVersionsOption;_inputRequiredDriverConfig;_listenState=new Map;_nextListenId=0;_autoOpenedSubscription;_discoverResult;static{Cl.enforceStrictCapabilities=(e)=>e._enforceStrictCapabilities,Cl.walkPages=(e,t,o,r)=>e._walkPages(t,o,r),Cl.readResource=(e,t,o)=>e._readResource(t,o)}_resetConnectionState(){if(this._negotiatedProtocolVersion=void 0,this._serverCapabilities=void 0,this._serverVersion=void 0,this._instructions=void 0,this._discoverResult=void 0,this._autoOpenedSubscription=void 0,this._listenState.size>0){let e=new k(M.ConnectionClosed,"subscriptions/listen: client reconnected or closed; subscription state from the previous connection was reset");for(let t of this._listenState.values())t.settle({cause:"remote",error:e})}this._listenState.clear();for(let e of this._listChangedDebounceTimers.values())clearTimeout(e);this._listChangedDebounceTimers.clear(),this._cache.resetForReconnect()}async close(){try{await super.close()}finally{this._resetConnectionState()}}constructor(e,t){super(t);if(this._clientInfo=e,this._capabilities=t?.capabilities?{...t.capabilities}:{},this._jsonSchemaValidator=t?.jsonSchemaValidator??new Ha,this._enforceStrictCapabilities=t?.enforceStrictCapabilities??!1,this._versionNegotiation=t?.versionNegotiation,this._supportedProtocolVersionsOption=t?.supportedProtocolVersions,this._inputRequiredDriverConfig=Zm(t?.inputRequired),this._cache=new $b(t?.responseCacheStore??new rf,t?.responseCacheStore!==void 0,(o)=>this._reportStoreError(o),t?.cachePartition??""),this._defaultCacheTtlMs=t?.defaultCacheTtlMs??0,this._listMaxPages=t?.listMaxPages??Xb,t?.listChanged)this._listChangedConfig=t.listChanged}buildContext(e,t){return e}_shouldDropInbound(e){if(this._negotiatedProtocolVersion!==void 0&&Ct(this._negotiatedProtocolVersion)&&Za(e))return"drop"}_outboundMetaEnvelope(){let e=this._negotiatedProtocolVersion;if(e===void 0)return;return this._wireCodec().outboundEnvelope({protocolVersion:e,clientInfo:this._clientInfo,clientCapabilities:this._capabilities})}_resolveNonCompleteResult(e,t){if(!this._inputRequiredDriverConfig.autoFulfill)return Promise.reject(new k(M.UnsupportedResultType,`Unsupported result type 'input_required' for ${t.request.method}: multi-round-trip auto-fulfilment is not enabled on this instance — pass allowInputRequired: true to handle it manually, or enable inputRequired.autoFulfill`,{resultType:"input_required",method:t.request.method}));return Vm({getRequestHandler:(o)=>this._getRequestHandler(o),buildContext:(o)=>this.buildContext(o,void 0),sessionId:this.transport?.sessionId},this._inputRequiredDriverConfig,e,t)}_setupListChangedHandlers(e){if(e.tools&&this._serverCapabilities?.tools?.listChanged)this._setupListChangedHandler("tools","notifications/tools/list_changed",e.tools,async()=>(await this.listTools(void 0,{cacheMode:"refresh"})).tools);if(e.prompts&&this._serverCapabilities?.prompts?.listChanged)this._setupListChangedHandler("prompts","notifications/prompts/list_changed",e.prompts,async()=>(await this.listPrompts(void 0,{cacheMode:"refresh"})).prompts);if(e.resources&&this._serverCapabilities?.resources?.listChanged)this._setupListChangedHandler("resources","notifications/resources/list_changed",e.resources,async()=>(await this.listResources(void 0,{cacheMode:"refresh"})).resources)}registerCapabilities(e){if(this.transport)throw Error("Cannot register capabilities after connecting to transport");this._capabilities=Pl(this._capabilities,e)}setVersionNegotiation(e){if(this.transport)throw Error("Cannot configure version negotiation after connecting to transport");this._versionNegotiation=e}_wrapHandler(e,t){if(e==="elicitation/create")return async(o,r)=>{let n=$t(this._negotiatedProtocolVersion),i=n.validateRequest("elicitation/create",o);if(!i.ok&&i.reason==="not-in-era")i=n.validateInputRequest("elicitation/create",o);if(!i.ok)throw new W(i.reason==="not-in-era"?U.InternalError:U.InvalidParams,i.reason==="not-in-era"?"No wire schema for elicitation/create in the resolved era":`Invalid elicitation request: ${i.message}`);let{params:s}=i.value;s.mode=s.mode??"form";let{supportsFormMode:c,supportsUrlMode:d}=lf(this._capabilities.elicitation);if(s.mode==="form"&&!c)throw new W(U.InvalidParams,"Client does not support form-mode elicitation requests");if(s.mode==="url"&&!d)throw new W(U.InvalidParams,"Client does not support URL-mode elicitation requests");let p=await t(o,r),h=n.validateResult("elicitation/create",p);if(!h.ok&&h.reason==="not-in-era")h=n.validateInputResponse("elicitation/create",p);if(!h.ok)throw new W(h.reason==="not-in-era"?U.InternalError:U.InvalidParams,h.reason==="not-in-era"?"No wire schema for elicitation/create in the resolved era":`Invalid elicitation result: ${h.message}`);let f=h.value,S=s.mode==="form"?s.requestedSchema:void 0;if(s.mode==="form"&&f.action==="accept"&&f.content&&S&&this._capabilities.elicitation?.form?.applyDefaults)try{Va(S,f.content)}catch{}return f};if(e==="sampling/createMessage")return async(o,r)=>{let n=$t(this._negotiatedProtocolVersion),i=n.validateRequest("sampling/createMessage",o);if(!i.ok&&i.reason==="not-in-era")i=n.validateInputRequest("sampling/createMessage",o);if(!i.ok)throw new W(i.reason==="not-in-era"?U.InternalError:U.InvalidParams,i.reason==="not-in-era"?"No wire schema for sampling/createMessage in the resolved era":`Invalid sampling request: ${i.message}`);let{params:s}=i.value,c=await t(o,r),d=Boolean(s.tools||s.toolChoice),p=n.samplingResultVariant(d,c);if(!p.ok&&p.reason==="not-in-era")p=n.validateInputResponse("sampling/createMessage",c);if(!p.ok)throw new W(p.reason==="not-in-era"?U.InternalError:U.InvalidParams,p.reason==="not-in-era"?"No result schema for sampling/createMessage in the resolved era":`Invalid sampling result: ${p.message}`);return p.value};return t}assertCapability(e,t){if(!this._serverCapabilities?.[e])throw new k(M.CapabilityNotSupported,`Server does not support ${e} (required for ${t})`)}async connect(e,t){if(t?.prior!=null)return this._connectFromPrior(e,Qb(t.prior),t);let o=Fb(this._versionNegotiation,this._supportedProtocolVersionsOption);if(o.kind!=="legacy")return this._connectNegotiated(e,o,t);return this._connectPlainLegacy(e,t)}async _connectPlainLegacy(e,t){if(await super.connect(e),e.sessionId!==void 0){let o=this._negotiatedProtocolVersion;if(o!==void 0)e.setProtocolVersion?.(o);return}this._resetConnectionState(),await this._legacyHandshake(e,t)}async _legacyHandshake(e,t){let o=_l(this._supportedProtocolVersions);try{let r=o[0];if(r===void 0)throw new k(M.EraNegotiationFailed,"Cannot run the initialize handshake: supportedProtocolVersions contains no pre-2026-07-28 protocol version");let n=await this.request({method:"initialize",params:{protocolVersion:r,capabilities:this._capabilities,clientInfo:this._clientInfo}},t);if(n===void 0)throw Error(`Server sent invalid initialize result: ${n}`);if(!o.includes(n.protocolVersion))throw Error(`Server's protocol version is not supported: ${n.protocolVersion}`);if(this._serverCapabilities=n.capabilities,this._serverVersion=n.serverInfo,this._cache.setServerIdentity(this._deriveServerIdentity(e)),e.setProtocolVersion)e.setProtocolVersion(n.protocolVersion);if(this._instructions=n.instructions,await this.notification({method:"notifications/initialized"}),this._negotiatedProtocolVersion=n.protocolVersion,this._listChangedConfig)this._setupListChangedHandlers(this._listChangedConfig)}catch(r){throw this.close(),r}}async _connectNegotiated(e,t,o){if(e.sessionId!==void 0){await super.connect(e);let n=this._negotiatedProtocolVersion;if(n!==void 0&&e.setProtocolVersion)e.setProtocolVersion(n);return}this._resetConnectionState();let r;try{let n=Ym(e),i={clientInfo:this._clientInfo,capabilities:this._capabilities,environment:Gm(),defaultTimeoutMs:o?.timeout??fi},s=n==="stdio"?Kb(e):void 0;r=s===void 0?await cf(t,{...i,transport:e,transportKind:n}):await Gb(t,e,s,i)}catch(n){throw await e.close().catch(()=>{}),Qm(e),n}if(Qm(e),await super.connect(e),r.era==="legacy"){await this._legacyHandshake(e,o);return}if(this._serverCapabilities=r.discover.capabilities,this._serverVersion=ef(r.discover),this._cache.setServerIdentity(this._deriveServerIdentity(e)),this._instructions=r.discover.instructions,this._discoverResult=r.discover,this._negotiatedProtocolVersion=r.version,e.setProtocolVersion)e.setProtocolVersion(r.version);if(this._listChangedConfig){let n=this._listChangedConfig,i=this._serverCapabilities,s={...n.tools&&i?.tools?.listChanged&&{tools:n.tools},...n.prompts&&i?.prompts?.listChanged&&{prompts:n.prompts},...n.resources&&i?.resources?.listChanged&&{resources:n.resources}},c=!0;try{this._setupListChangedHandlers(s)}catch(p){c=!1,this.onerror?.(p instanceof Error?p:Error(String(p)))}let d=c?{...s.tools&&{toolsListChanged:!0},...s.prompts&&{promptsListChanged:!0},...s.resources&&{resourcesListChanged:!0}}:{};if(Object.keys(d).length>0){let p=new AbortController,h=()=>p.abort(o?.signal?.reason);if(o?.signal?.aborted)h();o?.signal?.addEventListener("abort",h);try{this._autoOpenedSubscription=await this.listen(d,{timeout:o?.timeout,signal:p.signal})}catch(f){if(o?.signal?.aborted)throw await this.close().catch(()=>{}),f;this.onerror?.(f instanceof Error?f:Error(String(f)))}finally{o?.signal?.removeEventListener("abort",h)}}}}async _connectFromPrior(e,t,o){if(t.kind==="legacy")return this._connectPlainLegacy(e,o);let r=t.discover;this._resetConnectionState();let n=this._supportedProtocolVersionsOption,i=(n&&pi(n).length>0?pi(n):Sl).find((s)=>r.supportedVersions.includes(s));if(i===void 0)throw new k(M.EraNegotiationFailed,"connect({ prior }) with a modern verdict requires a 2026-07-28+ mutual protocol version; the supplied DiscoverResult and this client's supportedProtocolVersions have no modern overlap. For a server known to be legacy, pass prior: { kind: 'legacy' } to skip the probe and initialize directly, or use versionNegotiation: { mode: 'auto' } to re-probe with legacy fallback.");if(await super.connect(e),this._discoverResult=r,this._serverCapabilities=r.capabilities,this._serverVersion=ef(r),this._cache.setServerIdentity(this._deriveServerIdentity(e)),this._instructions=r.instructions,this._negotiatedProtocolVersion=i,e.setProtocolVersion?.(i),this._listChangedConfig)try{this._setupListChangedHandlers(this._listChangedConfig)}catch(s){this.onerror?.(s instanceof Error?s:Error(String(s)))}}getServerCapabilities(){return this._serverCapabilities}getServerVersion(){return this._serverVersion}_deriveServerIdentity(e){let t=this._serverVersion;if(t!==void 0)return`${t.name}@${t.version}`;return e.sessionId??`anonymous:${Date.now()}-${Math.random().toString(36).slice(2)}`}getNegotiatedProtocolVersion(){return this._negotiatedProtocolVersion}getProtocolEra(){let e=this._negotiatedProtocolVersion;if(e===void 0)return;return Ct(e)?"modern":"legacy"}getInstructions(){return this._instructions}getDiscoverResult(){return this._discoverResult}assertCapabilityForMethod(e){switch(e){case"logging/setLevel":if(!this._serverCapabilities?.logging)throw new k(M.CapabilityNotSupported,`Server does not support logging (required for ${e})`);break;case"prompts/get":case"prompts/list":if(!this._serverCapabilities?.prompts)throw new k(M.CapabilityNotSupported,`Server does not support prompts (required for ${e})`);break;case"resources/list":case"resources/templates/list":case"resources/read":case"resources/subscribe":case"resources/unsubscribe":if(!this._serverCapabilities?.resources)throw new k(M.CapabilityNotSupported,`Server does not support resources (required for ${e})`);if(e==="resources/subscribe"&&!this._serverCapabilities.resources.subscribe)throw new k(M.CapabilityNotSupported,`Server does not support resource subscriptions (required for ${e})`);break;case"tools/call":case"tools/list":if(!this._serverCapabilities?.tools)throw new k(M.CapabilityNotSupported,`Server does not support tools (required for ${e})`);break;case"completion/complete":if(!this._serverCapabilities?.completions)throw new k(M.CapabilityNotSupported,`Server does not support completions (required for ${e})`);break;case"initialize":break;case"server/discover":break;case"ping":break}}assertNotificationCapability(e){switch(e){case"notifications/roots/list_changed":if(!this._capabilities.roots?.listChanged)throw new k(M.CapabilityNotSupported,`Client does not support roots list changed notifications (required for ${e})`);break;case"notifications/initialized":break;case"notifications/cancelled":break;case"notifications/progress":break}}assertRequestHandlerCapability(e){switch(e){case"sampling/createMessage":if(!this._capabilities.sampling)throw new k(M.CapabilityNotSupported,`Client does not support sampling capability (required for ${e})`);break;case"elicitation/create":if(!this._capabilities.elicitation)throw new k(M.CapabilityNotSupported,`Client does not support elicitation capability (required for ${e})`);break;case"roots/list":if(!this._capabilities.roots)throw new k(M.CapabilityNotSupported,`Client does not support roots capability (required for ${e})`);break;case"ping":break}}async ping(e){return this.request({method:"ping"},e)}async discover(e){let t=await this._requestWithSchema({method:"server/discover"},Vt,e);return this._discoverResult=t,t}async complete(e,t){return this.request({method:"completion/complete",params:e},t)}async setLoggingLevel(e,t){return this.request({method:"logging/setLevel",params:{level:e}},t)}async getPrompt(e,t){return this.request({method:"prompts/get",params:e},t)}async listPrompts(e,t){if(!this._serverCapabilities?.prompts&&!this._enforceStrictCapabilities)return console.debug("Client.listPrompts() called but server does not advertise prompts capability - returning empty list"),{prompts:[]};if(e?.cursor!==void 0)return this.request({method:"prompts/list",params:e},t);let o=await this._serveFromCache("prompts/list",void 0,t);if(o!==void 0)return o;return this._listAllPages("prompts/list",e,t,(r)=>r.prompts)}async listResources(e,t){if(!this._serverCapabilities?.resources&&!this._enforceStrictCapabilities)return console.debug("Client.listResources() called but server does not advertise resources capability - returning empty list"),{resources:[]};if(e?.cursor!==void 0)return this.request({method:"resources/list",params:e},t);let o=await this._serveFromCache("resources/list",void 0,t);if(o!==void 0)return o;return this._listAllPages("resources/list",e,t,(r)=>r.resources)}async listResourceTemplates(e,t){if(!this._serverCapabilities?.resources&&!this._enforceStrictCapabilities)return console.debug("Client.listResourceTemplates() called but server does not advertise resources capability - returning empty list"),{resourceTemplates:[]};if(e?.cursor!==void 0)return this.request({method:"resources/templates/list",params:e},t);let o=await this._serveFromCache("resources/templates/list",void 0,t);if(o!==void 0)return o;return this._listAllPages("resources/templates/list",e,t,(r)=>r.resourceTemplates)}async _listAllPages(e,t,o,r,n){let i=o?.cacheMode==="bypass",s=this._cache.captureGeneration(e),c=(p)=>{let h=p===void 0?t&&{...t}:{...t,cursor:p};return this.request({method:e,...h&&{params:h}},o)},d=await this._walkPages(e,c,r);if(delete d.nextCursor,n?.(d),i)return d;return await this._cache.write(e,d,s,this._freshness(d)),d}async _walkPages(e,t,o){let r=await t(void 0),n=r.nextCursor,i=r,s=1;while(n!==void 0){if(this._listMaxPages!==0&&s>=this._listMaxPages)throw new k(M.ListPaginationExceeded,`${e}: exceeded listMaxPages (${this._listMaxPages}); server pagination did not terminate`,{method:e,listMaxPages:this._listMaxPages});let c=await t(n);if(c.nextCursor===n&&JSON.stringify(o(c))===JSON.stringify(o(i)))break;o(r).push(...o(c)),i=c,n=c.nextCursor,s++}return r}_freshness(e,t){let o=e,r=typeof o.ttlMs==="number"?o.ttlMs:this._defaultCacheTtlMs,n=o.cacheScope==="public"?"public":"private";return{expiresAt:this._cache.now()+Math.min(Math.max(0,r),nf),scope:n,params:t}}async _serveFromCache(e,t,o){if(o?.cacheMode==="bypass"||o?.cacheMode==="refresh")return;let r=await this._cache.read(e,t).catch((n)=>void this._reportStoreError(n));if(r!==void 0){if(o?.signal?.aborted){let n=o.signal.reason;throw n instanceof k?n:new k(M.RequestTimeout,String(n))}return r.value}}_reportStoreError(e){this.onerror?.(e instanceof Error?e:Error(String(e)))}_compileOutputValidator(e){if(!e.outputSchema)return;try{return{ok:!0,validator:this._jsonSchemaValidator.getValidator(e.outputSchema)}}catch(t){return{ok:!1,compileError:t}}}async _resolveXMcpHeaderScan(e,t){let o=t??await this._cache.toolDefinition(e);return o===void 0?void 0:wl(o.inputSchema)}async readResource(e,t){let{result:o}=await this._readResource(e,t);return o}async _readResource(e,t){let o=await this._serveFromCache("resources/read",e.uri,t);if(o!==void 0)return{result:o,cached:!0};let r=this._cache.captureGeneration("resources/read",e.uri),n=await this.request({method:"resources/read",params:e},t);if(t?.cacheMode!=="bypass"){let i=this._freshness(n,e.uri);if(i.expiresAt>this._cache.now())await this._cache.write("resources/read",n,r,i);else if(t?.cacheMode==="refresh")await this._cache.evictKey("resources/read",e.uri)}return{result:n,cached:!1}}async subscribeResource(e,t){return this.request({method:"resources/subscribe",params:e},t)}async unsubscribeResource(e,t){return this.request({method:"resources/unsubscribe",params:e},t)}async listen(e,t){if(this.transport===void 0)throw new k(M.NotConnected,"Not connected");let o=this._negotiatedProtocolVersion;if(o===void 0||!Ct(o))throw new k(M.MethodNotSupportedByProtocolVersion,`subscriptions/listen requires a 2026-07-28-era connection (negotiated: ${o??"none"}). On a 2025-era connection, change notifications are delivered unsolicited: use ClientOptions.listChanged and resources/subscribe instead.`,{method:"subscriptions/listen",protocolVersion:o});if(t?.signal?.aborted){let j=t.signal.reason;throw j instanceof k?j:new k(M.RequestTimeout,String(j))}let r=new AbortController,n=`listen:${this._nextListenId++}`,i="opening",s,c,d,p,h=new Promise((j,F)=>{d=j,p=F}),f,S=new Promise((j)=>{f=j}),b=(j)=>{if(i==="closed")return;let F=i==="opening";if(s!==void 0)clearTimeout(s),s=void 0;if("ack"in j){i="open",d(j.ack);return}if(i="closed",c!==void 0)t?.signal?.removeEventListener("abort",c);if(this._listenState.delete(n),r.abort(),f(j.cause),F)p(j.error??new k(M.ConnectionClosed,"subscriptions/listen closed before the server acknowledged"))},R=async()=>{r.abort(),await this.notification({method:"notifications/cancelled",params:{requestId:n}}).catch(()=>{})},w=async()=>{if(i==="closed")return;b({cause:"local"}),await R()};this._listenState.set(n,{settle:b});let O=t?.timeout??fi;if(s=setTimeout(()=>{b({cause:"remote",error:new k(M.RequestTimeout,"subscriptions/listen ack timed out",{timeout:O})}),R().catch(()=>{})},O),t?.signal){let j=t.signal;c=()=>{if(i==="closed")return;let F=j.reason;b({cause:"local",error:F instanceof Error?F:Error(String(F??"Aborted"))}),R().catch(()=>{})},j.addEventListener("abort",c,{once:!0})}let J={jsonrpc:"2.0",id:n,method:"subscriptions/listen",params:{_meta:{...this._outboundMetaEnvelope()},notifications:e}},B=(j)=>{b({cause:"remote",error:j instanceof Error?j:Error(String(j))})};try{this.transport.send(J,{requestSignal:r.signal,onRequestStreamEnd:()=>b({cause:"remote",error:Error("subscriptions/listen: stream ended")})}).catch(B)}catch(j){B(j)}return{honoredFilter:await h,close:w,closed:S}}get autoOpenedSubscription(){return this._autoOpenedSubscription}_onnotification(e,t){let o=Object.hasOwn(tf,e.method)?tf[e.method]:void 0;if(e.method==="notifications/resources/updated"){let r=e.params?.uri;if(typeof r==="string")this._cache.evictKey("resources/read",r)}else if(o!==void 0)for(let r of o)this._cache.evict(r);if(e.method==="notifications/subscriptions/acknowledged"){let r=e.params?._meta?.[Yo],n=typeof r==="string"?this._listenState.get(r):void 0;if(n!==void 0){let i=this._wireCodec().validateNotification("notifications/subscriptions/acknowledged",e);n.settle({ack:i.ok?i.value.params.notifications:{}});return}}if(e.method==="notifications/cancelled"){let r=e.params?.requestId,n=typeof r==="string"?this._listenState.get(r):void 0;if(n!==void 0){n.settle({cause:"remote",error:Error("subscriptions/listen: server cancelled the subscription")});return}}super._onnotification(e,t)}_onresponse(e){let t=e.id,o=typeof t==="string"?this._listenState.get(t):void 0;if(o!==void 0){if(mi(e))o.settle({cause:"remote",error:W.fromError(e.error.code,e.error.message,e.error.data)});else o.settle({cause:"graceful",error:new k(M.ConnectionClosed,"subscriptions/listen: server closed the subscription gracefully before acknowledging")});return}super._onresponse(e)}_onclose(){if(this._listenState.size>0){let e=new k(M.ConnectionClosed,"Connection closed");for(let t of this._listenState.values())t.settle({cause:"remote",error:e});this._listenState.clear()}super._onclose()}async callTool(e,t){let o=this.getProtocolEra()==="modern"&&Gm()!=="browser",r=async()=>{if(!o)return t;let d;try{d=await this._resolveXMcpHeaderScan(e.name,t?.toolDefinition)}catch(h){this._reportStoreError(h)}if(!d?.valid||d.declarations.length===0)return t;let p=Lm(d.declarations,e.arguments);return Object.keys(p).length===0?t:{...t,headers:{...t?.headers,...p}}},n=t?.toolDefinition===void 0?await this._cache.outputValidator(e.name,(d)=>this._compileOutputValidator(d)).catch((d)=>void this._reportStoreError(d)):this._compileOutputValidator(t.toolDefinition),i=()=>{if(n===void 0||n.ok)return;let d=n.compileError,p=(d instanceof Error?d.message:String(d)).slice(0,200);throw new W(U.InvalidParams,`Tool '${e.name}' has an invalid outputSchema: ${p}`)};i();let s;try{s=await this.request({method:"tools/call",params:e},await r())}catch(d){let p=d instanceof W&&d.code===xr;if(!o||!p||t?.toolDefinition!==void 0)throw d;let h={signal:t?.signal,timeout:t?.timeout,cacheMode:"refresh"};await this._cache.evict("tools/list"),await this.listTools(void 0,h).catch((f)=>this._reportStoreError(f)),n=await this._cache.outputValidator(e.name,(f)=>this._compileOutputValidator(f)).catch((f)=>void this._reportStoreError(f)),i(),s=await this.request({method:"tools/call",params:e},await r())}let c=n!==void 0&&n.ok?n.validator:void 0;if(c){if(s.structuredContent===void 0&&!s.isError)throw new W(U.InvalidRequest,`Tool ${e.name} has an output schema but did not return structured content`);if(s.structuredContent!==void 0&&!s.isError)try{let d=c(s.structuredContent);if(!d.valid)throw new W(U.InvalidParams,`Structured content does not match the tool's output schema: ${d.errorMessage}`)}catch(d){if(d instanceof W)throw d;throw new W(U.InvalidParams,`Failed to validate structured content: ${d instanceof Error?d.message:String(d)}`)}}return s}async listTools(e,t){if(!this._serverCapabilities?.tools&&!this._enforceStrictCapabilities)return console.debug("Client.listTools() called but server does not advertise tools capability - returning empty list"),{tools:[]};if(e?.cursor!==void 0){let r=await this.request({method:"tools/list",params:e},t);return this._excludeInvalidXMcpHeaderTools(r),r}let o=await this._serveFromCache("tools/list",void 0,t);if(o!==void 0)return o;return this._listAllPages("tools/list",e,t,(r)=>r.tools,(r)=>this._excludeInvalidXMcpHeaderTools(r))}_excludeInvalidXMcpHeaderTools(e){if(this.getProtocolEra()!=="modern"||!this.transport||Ym(this.transport)==="stdio")return;let t=e.tools.filter((o)=>{let r=wl(o.inputSchema);if(!r.valid)return console.warn(`[mcp-sdk] excluding tool '${o.name}' from tools/list: invalid x-mcp-header declaration — ${r.reason}`),!1;return!0});if(t.length!==e.tools.length)e.tools=t}_setupListChangedHandler(e,t,o,r){let n=Da(bs,o);if(!n.success)throw Error(`Invalid ${e} listChanged options: ${n.error.message}`);if(typeof o.onChanged!=="function")throw TypeError(`Invalid ${e} listChanged options: onChanged must be a function`);let{autoRefresh:i,debounceMs:s}=n.data,{onChanged:c}=o,d=async()=>{if(!i){c(null,null);return}try{c(null,await r())}catch(h){c(h instanceof Error?h:Error(String(h)),null)}},p=()=>{if(s){let h=this._listChangedDebounceTimers.get(e);if(h)clearTimeout(h);let f=setTimeout(d,s);this._listChangedDebounceTimers.set(e,f)}else d()};this.setNotificationHandler(t,p)}async sendRootsListChanged(){return this.notification({method:"notifications/roots/list_changed"})}};var Yw=class extends Error{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.SseError"})}static[Symbol.hasInstance](e){return Pe(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 Pe(this,e)}constructor(e,t,o){super(`SSE error: ${t}`);this.code=e,this.event=o,Bt(this,new.target)}};class ff{_eventSlots=new Map;setHandler(e,t){let o=this._ensureEventSlot(e);if(o.onHandler&&t)console.warn(`[MCP Apps] on${String(e)} handler replaced. Use addEventListener("${String(e)}", …) to add multiple listeners without replacing.`);o.onHandler=t}getHandler(e){return this._eventSlots.get(e)?.onHandler}addEventListener(e,t){this._ensureEventSlot(e).listeners.push(t)}removeEventListener(e,t){let o=this._eventSlots.get(e);if(!o)return;let r=o.listeners.indexOf(t);if(r!==-1)o.listeners.splice(r,1)}dispatch(e,t){let o=this._eventSlots.get(e);if(!o)return;o.onHandler?.(t);for(let r of[...o.listeners])r(t)}_ensureEventSlot(e){let t=this._eventSlots.get(e);if(!t)t={listeners:[]},this._eventSlots.set(e,t);return t}}class gf{_methods=new Set;claim(e,t){if(this._methods.has(e))throw Error(`Handler for "${e}" already registered (via ${t}). Use addEventListener() to attach multiple listeners, or the on* setter for replace semantics.`);this._methods.add(e)}replace(e){this._methods.add(e)}release(e){this._methods.delete(e)}has(e){return this._methods.has(e)}}var uf=new Set;function df(e,t){let[o,r]=t,n=o?.shape;if(typeof n?.method?.value!=="string")return;let i=n.method.value,s=e==="request"?"setRequestHandler":"setNotificationHandler";if(!uf.has(s))uf.add(s),console.warn(`[ext-apps] ${s}(Schema, handler) is deprecated; use ${s}("${i}", { params: Schema.shape.params }, handler).`);let c=r;return[i,{params:n.params},e==="request"?(d,p)=>c({method:i,params:d},ty(p)):(d)=>c({method:i,params:d})]}function ty(e){return{signal:e.mcpReq.signal,requestId:e.mcpReq.id,sessionId:e.sessionId,_meta:e.mcpReq._meta,sendRequest:e.mcpReq.send,sendNotification:e.mcpReq.notify,authInfo:e.http?.authInfo}}var oy="2026-01-26";var ry="ui/notifications/tool-input-partial";class Sf{eventTarget;eventSource;messageListener;constructor(e=window.parent,t){this.eventTarget=e,this.eventSource=t,this.messageListener=(o)=>{if(t&&o.source!==this.eventSource){console.debug("Ignoring message from unknown source",o);return}let r=zt.safeParse(o.data);if(r.success)console.debug("Parsed message",r.data),this.onmessage?.(r.data);else if(o.data?.jsonrpc!=="2.0")console.debug("Ignoring non-JSON-RPC message",r.error.message,o);else console.error("Failed to parse message",r.error.message,o),this.onerror?.(Error("Invalid JSON-RPC message received: "+r.error.message))}}async start(){window.addEventListener("message",this.messageListener)}async send(e,t){if(e.method!==ry)console.debug("Sending message",e);this.eventTarget.postMessage(e,"*")}async close(){window.removeEventListener("message",this.messageListener),this.onclose?.()}onclose;onerror;onmessage;sessionId;setProtocolVersion}var ny=v([u("light"),u("dark")]).describe("Color theme preference for the host environment."),Si=v([u("inline"),u("fullscreen"),u("pip")]).describe("Display mode for UI presentation."),sy=v([u("--color-background-primary"),u("--color-background-secondary"),u("--color-background-tertiary"),u("--color-background-inverse"),u("--color-background-ghost"),u("--color-background-info"),u("--color-background-danger"),u("--color-background-success"),u("--color-background-warning"),u("--color-background-disabled"),u("--color-text-primary"),u("--color-text-secondary"),u("--color-text-tertiary"),u("--color-text-inverse"),u("--color-text-ghost"),u("--color-text-info"),u("--color-text-danger"),u("--color-text-success"),u("--color-text-warning"),u("--color-text-disabled"),u("--color-border-primary"),u("--color-border-secondary"),u("--color-border-tertiary"),u("--color-border-inverse"),u("--color-border-ghost"),u("--color-border-info"),u("--color-border-danger"),u("--color-border-success"),u("--color-border-warning"),u("--color-border-disabled"),u("--color-ring-primary"),u("--color-ring-secondary"),u("--color-ring-inverse"),u("--color-ring-info"),u("--color-ring-danger"),u("--color-ring-success"),u("--color-ring-warning"),u("--font-sans"),u("--font-mono"),u("--font-weight-normal"),u("--font-weight-medium"),u("--font-weight-semibold"),u("--font-weight-bold"),u("--font-text-xs-size"),u("--font-text-sm-size"),u("--font-text-md-size"),u("--font-text-lg-size"),u("--font-heading-xs-size"),u("--font-heading-sm-size"),u("--font-heading-md-size"),u("--font-heading-lg-size"),u("--font-heading-xl-size"),u("--font-heading-2xl-size"),u("--font-heading-3xl-size"),u("--font-text-xs-line-height"),u("--font-text-sm-line-height"),u("--font-text-md-line-height"),u("--font-text-lg-line-height"),u("--font-heading-xs-line-height"),u("--font-heading-sm-line-height"),u("--font-heading-md-line-height"),u("--font-heading-lg-line-height"),u("--font-heading-xl-line-height"),u("--font-heading-2xl-line-height"),u("--font-heading-3xl-line-height"),u("--border-radius-xs"),u("--border-radius-sm"),u("--border-radius-md"),u("--border-radius-lg"),u("--border-radius-xl"),u("--border-radius-full"),u("--border-width-regular"),u("--shadow-hairline"),u("--shadow-sm"),u("--shadow-md"),u("--shadow-lg")]).describe("CSS variable keys available to MCP apps for theming."),iy=y(sy.describe(`Style variables for theming MCP apps.
|
|
69
72
|
|
|
70
73
|
Individual style keys are optional - hosts may provide any subset of these values.
|
|
71
74
|
Values are strings containing CSS values (colors, sizes, font stacks, etc.).
|
|
72
75
|
|
|
73
76
|
Note: This type uses \`Record<K, string | undefined>\` rather than \`Partial<Record<K, string>>\`
|
|
74
|
-
for compatibility with Zod schema generation. Both are functionally equivalent for validation.`),
|
|
77
|
+
for compatibility with Zod schema generation. Both are functionally equivalent for validation.`),v([a(),Bo()]).describe(`Style variables for theming MCP apps.
|
|
75
78
|
|
|
76
79
|
Individual style keys are optional - hosts may provide any subset of these values.
|
|
77
80
|
Values are strings containing CSS values (colors, sizes, font stacks, etc.).
|
|
@@ -83,10 +86,10 @@ Individual style keys are optional - hosts may provide any subset of these value
|
|
|
83
86
|
Values are strings containing CSS values (colors, sizes, font stacks, etc.).
|
|
84
87
|
|
|
85
88
|
Note: This type uses \`Record<K, string | undefined>\` rather than \`Partial<Record<K, string>>\`
|
|
86
|
-
for compatibility with Zod schema generation. Both are functionally equivalent for validation.`),
|
|
89
|
+
for compatibility with Zod schema generation. Both are functionally equivalent for validation.`),cx=l({method:u("ui/open-link"),params:l({url:a().describe("URL to open in the host's browser")})}),ay=l({isError:z().optional().describe("True if the host failed to open the URL (e.g., due to security policy).")}).passthrough(),cy=l({isError:z().optional().describe("True if the download failed (e.g., user cancelled or host denied).")}).passthrough(),ly=l({isError:z().optional().describe("True if the host rejected or failed to deliver the message.")}).passthrough(),lx=l({method:u("ui/notifications/sandbox-proxy-ready"),params:l({})}),Ol=l({connectDomains:m(a()).optional().describe(`Origins for network requests (fetch/XHR/WebSocket).
|
|
87
90
|
|
|
88
91
|
- Maps to CSP \`connect-src\` directive
|
|
89
|
-
- Empty or omitted → no network connections (secure default)`),resourceDomains:
|
|
92
|
+
- Empty or omitted → no network connections (secure default)`),resourceDomains:m(a()).optional().describe("Origins for static resources (images, scripts, stylesheets, fonts, media).\n\n- Maps to CSP `img-src`, `script-src`, `style-src`, `font-src`, `media-src` directives\n- Wildcard subdomains supported: `https://*.example.com`\n- Empty or omitted → no network resources (secure default)"),frameDomains:m(a()).optional().describe("Origins for nested iframes.\n\n- Maps to CSP `frame-src` directive\n- Empty or omitted → no nested iframes allowed (`frame-src 'none'`)"),baseUriDomains:m(a()).optional().describe("Allowed base URIs for the document.\n\n- Maps to CSP `base-uri` directive\n- Empty or omitted → only same origin allowed (`base-uri 'self'`)")}),Ml=l({camera:l({}).optional().describe("Request camera access.\n\nMaps to Permission Policy `camera` feature."),microphone:l({}).optional().describe("Request microphone access.\n\nMaps to Permission Policy `microphone` feature."),geolocation:l({}).optional().describe("Request geolocation access.\n\nMaps to Permission Policy `geolocation` feature."),clipboardWrite:l({}).optional().describe("Request clipboard write access.\n\nMaps to Permission Policy `clipboard-write` feature.")}),ux=l({method:u("ui/notifications/size-changed"),params:l({width:_().optional().describe("New width in pixels."),height:_().optional().describe("New height in pixels.")})}),uy=l({method:u("ui/notifications/tool-input"),params:l({arguments:y(a(),P().describe("Complete tool call arguments as key-value pairs.")).optional().describe("Complete tool call arguments as key-value pairs.")})}),dy=l({method:u("ui/notifications/tool-input-partial"),params:l({arguments:y(a(),P().describe("Partial tool call arguments (incomplete, may change).")).optional().describe("Partial tool call arguments (incomplete, may change).")})}),py=l({method:u("ui/notifications/tool-cancelled"),params:l({reason:a().optional().describe('Optional reason for the cancellation (e.g., "user action", "timeout").')})}),hy=l({fonts:a().optional()}),my=l({variables:iy.optional().describe("CSS variables for theming the app."),css:hy.optional().describe("CSS blocks that apps can inject.")}),fy=l({method:u("ui/resource-teardown"),params:l({})}),gy=y(a(),P()),pf=l({text:l({}).optional().describe("Host supports text content blocks."),image:l({}).optional().describe("Host supports image content blocks."),audio:l({}).optional().describe("Host supports audio content blocks."),resource:l({}).optional().describe("Host supports resource content blocks."),resourceLink:l({}).optional().describe("Host supports resource link content blocks."),structuredContent:l({}).optional().describe("Host supports structured content.")}),dx=l({method:u("ui/notifications/request-teardown"),params:l({}).optional()}),Sy=l({experimental:y(a(),y(a(),Wo()).describe("Experimental features keyed by identifier.")).optional().describe("Experimental features keyed by identifier."),openLinks:l({}).optional().describe("Host supports opening external URLs."),downloadFile:l({}).optional().describe("Host supports file downloads via ui/download-file."),serverTools:l({listChanged:z().optional().describe("Host supports tools/list_changed notifications.")}).optional().describe("Host can proxy tool calls to the MCP server."),serverResources:l({listChanged:z().optional().describe("Host supports resources/list_changed notifications.")}).optional().describe("Host can proxy resource reads to the MCP server."),logging:l({}).optional().describe("Host accepts log messages."),sandbox:l({permissions:Ml.optional().describe("Permissions granted by the host (camera, microphone, geolocation)."),csp:Ol.optional().describe("CSP domains approved by the host.")}).optional().describe("Sandbox configuration applied by the host."),updateModelContext:pf.optional().describe("Host accepts context updates (ui/update-model-context) to be included in the model's context for future turns."),message:pf.optional().describe("Host supports receiving content messages (ui/message) from the view."),sampling:l({tools:l({}).optional().describe("Host supports tool use via `tools` and `toolChoice` parameters.")}).optional().describe("Host supports LLM sampling (sampling/createMessage) from the view.\nMirrors the MCP `ClientCapabilities.sampling` shape so hosts can pass it through.")}),_y=l({experimental:y(a(),y(a(),Wo()).describe("Experimental features keyed by identifier.")).optional().describe("Experimental features keyed by identifier."),tools:l({listChanged:z().optional().describe("App supports tools/list_changed notifications.")}).optional().describe("App exposes MCP-style tools that the host can call."),availableDisplayModes:m(Si).optional().describe("Display modes the app supports.")}),px=l({method:u("ui/notifications/initialized"),params:l({}).optional()}),hx=l({csp:Ol.optional().describe("Content Security Policy configuration for UI resources."),permissions:Ml.optional().describe("Sandbox permissions requested by the UI resource."),domain:a().optional().describe(`Dedicated origin for view sandbox.
|
|
90
93
|
|
|
91
94
|
Useful when views need stable, dedicated origins for OAuth callbacks, CORS policies, or API key allowlists.
|
|
92
95
|
|
|
@@ -94,22 +97,22 @@ Useful when views need stable, dedicated origins for OAuth callbacks, CORS polic
|
|
|
94
97
|
- Hash-based subdomains (e.g., \`{hash}.claudemcpcontent.com\`)
|
|
95
98
|
- URL-derived subdomains (e.g., \`www-example-com.oaiusercontent.com\`)
|
|
96
99
|
|
|
97
|
-
If omitted, host uses default sandbox origin (typically per-conversation).`),prefersBorder:
|
|
100
|
+
If omitted, host uses default sandbox origin (typically per-conversation).`),prefersBorder:z().optional().describe(`Visual boundary preference - true if view prefers a visible border.
|
|
98
101
|
|
|
99
102
|
Boolean requesting whether a visible border and background is provided by the host. Specifying an explicit value for this is recommended because hosts' defaults may vary.
|
|
100
103
|
|
|
101
104
|
- \`true\`: request visible border + background
|
|
102
105
|
- \`false\`: request no visible border + background
|
|
103
|
-
- omitted: host decides border`)}),
|
|
106
|
+
- omitted: host decides border`)}),mx=l({method:u("ui/request-display-mode"),params:l({mode:Si.describe("The display mode being requested.")})}),by=l({mode:Si.describe("The display mode that was actually set. May differ from requested if not supported.")}).passthrough(),yy=v([u("model"),u("app")]).describe("Tool visibility scope - who can access the tool."),fx=l({resourceUri:a().optional(),visibility:m(yy).optional().describe(`Who can access this tool. Default: ["model", "app"]
|
|
104
107
|
- "model": Tool visible to and callable by the agent
|
|
105
|
-
- "app": Tool callable by the app from this server only`),csp:
|
|
106
|
-
container holding the app. Specify either width or maxWidth, and either height or maxHeight.`),locale:s().optional().describe("User's language and region preference in BCP 47 format."),timeZone:s().optional().describe("User's timezone in IANA format."),userAgent:s().optional().describe("Host application identifier."),platform:_([l("web"),l("desktop"),l("mobile")]).optional().describe("Platform type for responsive design decisions."),deviceCapabilities:c({touch:v().optional().describe("Whether the device supports touch input."),hover:v().optional().describe("Whether the device supports hover interactions.")}).optional().describe("Device input capabilities."),safeAreaInsets:c({top:g().describe("Top safe area inset in pixels."),right:g().describe("Right safe area inset in pixels."),bottom:g().describe("Bottom safe area inset in pixels."),left:g().describe("Left safe area inset in pixels.")}).optional().describe("Mobile safe area boundaries in pixels.")}).passthrough(),R_=c({method:l("ui/notifications/host-context-changed"),params:Rm.describe("Partial context update containing only changed fields.")}),nR=c({method:l("ui/update-model-context"),params:c({content:h(Se).optional().describe("Context content blocks (text, image, etc.)."),structuredContent:S(s(),R().describe("Structured content for machine-readable context data.")).optional().describe("Structured content for machine-readable context data.")})}),sR=c({method:l("ui/initialize"),params:c({appInfo:ge.describe("App identification (name and version)."),appCapabilities:b_.describe("Features and capabilities this app provides."),protocolVersion:s().describe("Protocol version this app supports.")})}),w_=c({protocolVersion:s().describe('Negotiated protocol version string (e.g., "2025-11-21").'),hostInfo:ge.describe("Host application identification and version."),hostCapabilities:__.describe("Features and capabilities provided by the host."),hostContext:Rm.describe("Rich context about the host environment.")}).passthrough(),x_={target:"draft-2020-12"};async function _m(e,t){let o=e["~standard"];if(o.jsonSchema)return o.jsonSchema[t](x_);throw Error(`Schema (vendor: ${o.vendor}) does not implement Standard JSON Schema (~standard.jsonSchema). Use a library that does (zod v4, ArkType, Valibot) or wrap your schema accordingly.`)}async function bm(e,t,o=""){let r=await e["~standard"].validate(t);if(r.issues){let n=r.issues.map((i)=>{let a=i.path?.map((u)=>typeof u==="object"?u.key:u).join(".");return a?`${a}: ${i.message}`:i.message}).join("; ");throw Error(o+n)}return r.value}function T_(e,t){let o={...e,...t};if(t.experimental!==void 0)o.experimental={...e.experimental,...t.experimental};if(t.tools!==void 0)o.tools={...e.tools,...t.tools};return o}class Ta extends ei{_appInfo;_appCapabilities;options;_hostCapabilities;_hostInfo;_hostContext;_registeredTools={};_initializedSent=!1;_registeredEvents=new Set;_events=new ym;_methods=new vm;setRequestHandler=(...e)=>{let[t,...o]=gm("request",e)??e;this._methods.claim(t,"setRequestHandler"),super.setRequestHandler.call(this,t,...o)};setNotificationHandler=(...e)=>{let[t,...o]=gm("notification",e)??e;this._methods.claim(t,"setNotificationHandler"),super.setNotificationHandler.call(this,t,...o)};removeRequestHandler=(e)=>{this._methods.release(e),super.removeRequestHandler(e)};removeNotificationHandler=(e)=>{this._methods.release(e),super.removeNotificationHandler(e)};replaceRequestHandler=(e,...t)=>{this._methods.replace(e),super.setRequestHandler.call(this,e,...t)};_assertInitialized(e){if(this._initializedSent)return;let t=`[ext-apps] App.${e}() called before connect() completed the ui/initialize handshake. Await app.connect() before calling this method, or move data loading to an ontoolresult handler.`;if(this.options?.strict)throw Error(t);console.warn(`${t}. This will throw in a future release.`)}eventSchemas={toolinput:d_,toolinputpartial:p_,toolresult:z_,toolcancelled:h_,hostcontextchanged:R_};static ONE_SHOT_EVENTS=new Set(["toolinput","toolinputpartial","toolresult","toolcancelled"]);_everHadListener=new Set;_assertHandlerTiming(e){if(!Ta.ONE_SHOT_EVENTS.has(e)||this._everHadListener.has(e))return;if(this._everHadListener.add(e),!this._initializedSent)return;let t=`[ext-apps] "${String(e)}" handler registered after connect() completed the ui/initialize handshake. The host may have already sent this notification. Register handlers before calling app.connect().`;if(this.options?.strict)throw Error(t);console.warn(t)}setEventHandler(e,t){if(t)this._assertHandlerTiming(e);this._ensureEventSlot(e),this._events.setHandler(e,t)}addEventListener(e,t){this._assertHandlerTiming(e),this._ensureEventSlot(e),this._events.addEventListener(e,t)}removeEventListener(e,t){this._events.removeEventListener(e,t)}_ensureEventSlot(e){if(this._registeredEvents.has(e))return;let t=this.eventSchemas[e];if(!t)throw Error(`Unknown event: ${String(e)}`);this.setNotificationHandler(t.shape.method.value,{params:t.shape.params},(o)=>{let r=o;if(e==="hostcontextchanged")this._hostContext={...this._hostContext,...r};this._events.dispatch(e,r)}),this._registeredEvents.add(e)}getEventHandler(e){return this._events.getHandler(e)}warnIfRequestHandlerReplaced(e,t,o){if(t&&o)console.warn(`[MCP Apps] ${e} handler replaced. Previous handler will no longer be called.`)}constructor(e,t={},o={autoResize:!0}){super(o);if(this._appInfo=e,this._appCapabilities=t,this.options=o,this._methods.replace("notifications/cancelled"),this._methods.replace("notifications/progress"),!o.allowUnsafeEval)ce({jitless:!0});this.replaceRequestHandler("ping",(r)=>(console.log("Received ping:",r.params),{})),this.setEventHandler("hostcontextchanged",void 0)}buildContext(e){return e}registerAppCapabilities(e){if(this.transport)throw Error("Cannot register capabilities after transport is established");this._appCapabilities=T_(this._appCapabilities,e)}registerTool(e,t,o){if(this._registeredTools[e])throw Error(`Tool ${e} is already registered`);let r=this,n=()=>{if(r._initializedSent&&r._appCapabilities.tools?.listChanged)r.sendToolListChanged()},i=t.inputSchema!==void 0,a={title:t.title,description:t.description,inputSchema:t.inputSchema,outputSchema:t.outputSchema,annotations:t.annotations,_meta:t._meta,enabled:!0,enable(){this.enabled=!0,n()},disable(){this.enabled=!1,n()},update(u){Object.assign(this,u),n()},remove(){if(r._registeredTools[e]!==a)return;delete r._registeredTools[e],n()},handler:async(u,d)=>{if(!a.enabled)throw Error(`Tool ${e} is disabled`);let p;if(i){let f=a.inputSchema,b=f?await bm(f,u??{},`Invalid input for tool ${e}: `):u??{};p=await o(b,d)}else p=await o(d);if(a.outputSchema&&!p.isError)p.structuredContent=await bm(a.outputSchema,p.structuredContent,`Invalid output for tool ${e}: `);return p}};if(this._registeredTools[e]=a,!this._appCapabilities.tools&&!this.transport)this.registerAppCapabilities({tools:{listChanged:!0}});return this.ensureToolHandlersInitialized(),n(),a}_toolHandlersInitialized=!1;ensureToolHandlersInitialized(){if(this._toolHandlersInitialized)return;this._toolHandlersInitialized=!0,this.oncalltool=async(e,t)=>{let o=this._registeredTools[e.name];if(!o)throw Error(`Tool ${e.name} not found`);return o.handler(e.arguments,t)},this.onlisttools=async(e,t)=>({tools:await Promise.all(Object.entries(this._registeredTools).filter(([o,r])=>r.enabled).map(async([o,r])=>{let n={name:o,title:r.title,description:r.description,inputSchema:r.inputSchema?await _m(r.inputSchema,"input"):{type:"object",properties:{}}};if(r.outputSchema)n.outputSchema=await _m(r.outputSchema,"output");if(r.annotations)n.annotations=r.annotations;if(r._meta)n._meta=r._meta;return n}))})}async sendToolListChanged(e={}){this._assertInitialized("sendToolListChanged"),await this.notification({method:"notifications/tools/list_changed",params:e})}getHostCapabilities(){return this._hostCapabilities}getHostVersion(){return this._hostInfo}getHostContext(){return this._hostContext}get ontoolinput(){return this.getEventHandler("toolinput")}set ontoolinput(e){this.setEventHandler("toolinput",e)}get ontoolinputpartial(){return this.getEventHandler("toolinputpartial")}set ontoolinputpartial(e){this.setEventHandler("toolinputpartial",e)}get ontoolresult(){return this.getEventHandler("toolresult")}set ontoolresult(e){this.setEventHandler("toolresult",e)}get ontoolcancelled(){return this.getEventHandler("toolcancelled")}set ontoolcancelled(e){this.setEventHandler("toolcancelled",e)}get onhostcontextchanged(){return this.getEventHandler("hostcontextchanged")}set onhostcontextchanged(e){this.setEventHandler("hostcontextchanged",e)}_onteardown;get onteardown(){return this._onteardown}set onteardown(e){this.warnIfRequestHandlerReplaced("onteardown",this._onteardown,e),this._onteardown=e,this.replaceRequestHandler("ui/resource-teardown",{params:g_.shape.params,result:S_},(t,o)=>{if(!this._onteardown)throw Error("No onteardown handler set");return this._onteardown(t,o)})}_oncalltool;get oncalltool(){return this._oncalltool}set oncalltool(e){this.warnIfRequestHandlerReplaced("oncalltool",this._oncalltool,e),this._oncalltool=e,this.replaceRequestHandler("tools/call",(t,o)=>{if(!this._oncalltool)throw Error("No oncalltool handler set");return this._oncalltool(t.params,o)})}_onlisttools;get onlisttools(){return this._onlisttools}set onlisttools(e){this.warnIfRequestHandlerReplaced("onlisttools",this._onlisttools,e),this._onlisttools=e,this.replaceRequestHandler("tools/list",(t,o)=>{if(!this._onlisttools)throw Error("No onlisttools handler set");return this._onlisttools(t.params,o)})}assertCapabilityForMethod(e){switch(e){case"sampling/createMessage":if(!this._hostCapabilities?.sampling)throw Error(`Host does not support sampling (required for ${e})`);break}}assertRequestHandlerCapability(e){switch(e){case"tools/call":case"tools/list":if(!this._appCapabilities.tools)throw Error(`Client does not support tool capability (required for ${e})`);return;default:return}}assertNotificationCapability(e){}async callServerTool(e,t){if(this._assertInitialized("callServerTool"),typeof e==="string")throw Error(`callServerTool() expects an object as its first argument, but received a string ("${e}"). Did you mean: callServerTool({ name: "${e}", arguments: { ... } })?`);return await this.request({method:"tools/call",params:e},{onprogress:()=>{},resetTimeoutOnProgress:!0,...t})}async readServerResource(e,t){return this._assertInitialized("readServerResource"),await this.request({method:"resources/read",params:e},t)}async listServerResources(e,t){return this._assertInitialized("listServerResources"),await this.request({method:"resources/list",params:e},t)}async createSamplingMessage(e,t){return this._assertInitialized("createSamplingMessage"),await this.request({method:"sampling/createMessage",params:e},t)}sendMessage(e,t){return this._assertInitialized("sendMessage"),this.request({method:"ui/message",params:e},u_,t)}sendLog(e){return this.notification({method:"notifications/message",params:e})}updateModelContext(e,t){return this._assertInitialized("updateModelContext"),this.request({method:"ui/update-model-context",params:e},Ce,t)}openLink(e,t){return this._assertInitialized("openLink"),this.request({method:"ui/open-link",params:e},c_,t)}sendOpenLink=this.openLink;downloadFile(e,t){return this._assertInitialized("downloadFile"),this.request({method:"ui/download-file",params:e},l_,t)}requestTeardown(e={}){return this.notification({method:"ui/notifications/request-teardown",params:e})}requestDisplayMode(e,t){return this._assertInitialized("requestDisplayMode"),this.request({method:"ui/request-display-mode",params:e},y_,t)}sendSizeChanged(e){return this.notification({method:"ui/notifications/size-changed",params:e})}setupSizeChangedNotifications(){let e=!1,t=0,o=0,r=()=>{if(e)return;e=!0,requestAnimationFrame(()=>{e=!1;let i=document.documentElement,a=i.style.height;i.style.height="max-content";let u=Math.ceil(i.getBoundingClientRect().height);i.style.height=a;let d=Math.ceil(window.innerWidth);if(d!==t||u!==o)t=d,o=u,this.sendSizeChanged({width:d,height:u})})};r();let n=new ResizeObserver(r);return n.observe(document.documentElement),n.observe(document.body),()=>n.disconnect()}async connect(e=new zm(window.parent,window.parent),t){if(this.transport)throw Error("App is already connected. Call close() before connecting again.");this._initializedSent=!1;try{await super.connect(e);let o=await this.request({method:"ui/initialize",params:{appCapabilities:this._appCapabilities,appInfo:this._appInfo,protocolVersion:r_}},w_,t);if(o===void 0)throw Error(`Server sent invalid initialize result: ${o}`);if(this._hostCapabilities=o.hostCapabilities,this._hostInfo=o.hostInfo,this._hostContext=o.hostContext,await this.notification({method:"ui/notifications/initialized"}),this._initializedSent=!0,this.options?.autoResize)this.setupSizeChangedNotifications()}catch(o){throw this.close(),o}}}class km{_eventSlots=new Map;setHandler(e,t){let o=this._ensureEventSlot(e);if(o.onHandler&&t)console.warn(`[MCP Apps] on${String(e)} handler replaced. Use addEventListener("${String(e)}", …) to add multiple listeners without replacing.`);o.onHandler=t}getHandler(e){return this._eventSlots.get(e)?.onHandler}addEventListener(e,t){this._ensureEventSlot(e).listeners.push(t)}removeEventListener(e,t){let o=this._eventSlots.get(e);if(!o)return;let r=o.listeners.indexOf(t);if(r!==-1)o.listeners.splice(r,1)}dispatch(e,t){let o=this._eventSlots.get(e);if(!o)return;o.onHandler?.(t);for(let r of[...o.listeners])r(t)}_ensureEventSlot(e){let t=this._eventSlots.get(e);if(!t)t={listeners:[]},this._eventSlots.set(e,t);return t}}class $m{_methods=new Set;claim(e,t){if(this._methods.has(e))throw Error(`Handler for "${e}" already registered (via ${t}). Use addEventListener() to attach multiple listeners, or the on* setter for replace semantics.`);this._methods.add(e)}replace(e){this._methods.add(e)}release(e){this._methods.delete(e)}has(e){return this._methods.has(e)}}var wm=new Set;function xm(e,t){let[o,r]=t,n=o?.shape;if(typeof n?.method?.value!=="string")return;let i=n.method.value,a=e==="request"?"setRequestHandler":"setNotificationHandler";if(!wm.has(a))wm.add(a),console.warn(`[ext-apps] ${a}(Schema, handler) is deprecated; use ${a}("${i}", { params: Schema.shape.params }, handler).`);let u=r;return[i,{params:n.params},e==="request"?(d,p)=>u({method:i,params:d},E_(p)):(d)=>u({method:i,params:d})]}function E_(e){return{signal:e.mcpReq.signal,requestId:e.mcpReq.id,sessionId:e.sessionId,_meta:e.mcpReq._meta,sendRequest:e.mcpReq.send,sendNotification:e.mcpReq.notify,authInfo:e.http?.authInfo}}var Cm="2026-01-26";var P_="ui/notifications/tool-input-partial";var k_=_([l("light"),l("dark")]).describe("Color theme preference for the host environment."),ri=_([l("inline"),l("fullscreen"),l("pip")]).describe("Display mode for UI presentation."),$_=_([l("--color-background-primary"),l("--color-background-secondary"),l("--color-background-tertiary"),l("--color-background-inverse"),l("--color-background-ghost"),l("--color-background-info"),l("--color-background-danger"),l("--color-background-success"),l("--color-background-warning"),l("--color-background-disabled"),l("--color-text-primary"),l("--color-text-secondary"),l("--color-text-tertiary"),l("--color-text-inverse"),l("--color-text-ghost"),l("--color-text-info"),l("--color-text-danger"),l("--color-text-success"),l("--color-text-warning"),l("--color-text-disabled"),l("--color-border-primary"),l("--color-border-secondary"),l("--color-border-tertiary"),l("--color-border-inverse"),l("--color-border-ghost"),l("--color-border-info"),l("--color-border-danger"),l("--color-border-success"),l("--color-border-warning"),l("--color-border-disabled"),l("--color-ring-primary"),l("--color-ring-secondary"),l("--color-ring-inverse"),l("--color-ring-info"),l("--color-ring-danger"),l("--color-ring-success"),l("--color-ring-warning"),l("--font-sans"),l("--font-mono"),l("--font-weight-normal"),l("--font-weight-medium"),l("--font-weight-semibold"),l("--font-weight-bold"),l("--font-text-xs-size"),l("--font-text-sm-size"),l("--font-text-md-size"),l("--font-text-lg-size"),l("--font-heading-xs-size"),l("--font-heading-sm-size"),l("--font-heading-md-size"),l("--font-heading-lg-size"),l("--font-heading-xl-size"),l("--font-heading-2xl-size"),l("--font-heading-3xl-size"),l("--font-text-xs-line-height"),l("--font-text-sm-line-height"),l("--font-text-md-line-height"),l("--font-text-lg-line-height"),l("--font-heading-xs-line-height"),l("--font-heading-sm-line-height"),l("--font-heading-md-line-height"),l("--font-heading-lg-line-height"),l("--font-heading-xl-line-height"),l("--font-heading-2xl-line-height"),l("--font-heading-3xl-line-height"),l("--border-radius-xs"),l("--border-radius-sm"),l("--border-radius-md"),l("--border-radius-lg"),l("--border-radius-xl"),l("--border-radius-full"),l("--border-width-regular"),l("--shadow-hairline"),l("--shadow-sm"),l("--shadow-md"),l("--shadow-lg")]).describe("CSS variable keys available to MCP apps for theming."),C_=S($_.describe(`Style variables for theming MCP apps.
|
|
108
|
+
- "app": Tool callable by the app from this server only`),csp:bn().optional(),permissions:bn().optional()}),gx=l({mimeTypes:m(a()).optional().describe('Array of supported MIME types for UI resources.\nMust include `"text/html;profile=mcp-app"` for MCP Apps support.')}),Sx=l({method:u("ui/download-file"),params:l({contents:m(v([Tt,Pt])).describe("Resource contents to download — embedded (inline data) or linked (host fetches). Uses standard MCP resource types.")})}),_x=l({method:u("ui/message"),params:l({role:u("user").describe('Message role, currently only "user" is supported.'),content:m(Ae).describe("Message content blocks (text, image, etc.).")})}),bx=l({method:u("ui/notifications/sandbox-resource-ready"),params:l({html:a().describe("HTML content to load into the inner iframe."),sandbox:a().optional().describe("Optional override for the inner iframe's sandbox attribute."),csp:Ol.optional().describe("CSP configuration from resource metadata."),permissions:Ml.optional().describe("Sandbox permissions from resource metadata.")})}),vy=l({method:u("ui/notifications/tool-result"),params:ft.describe("Standard MCP tool execution result.")}),_f=l({toolInfo:l({id:qe.optional().describe("JSON-RPC id of the tools/call request."),tool:mt.describe("Tool definition including name, inputSchema, etc.")}).optional().describe("Metadata of the tool call that instantiated this App."),theme:ny.optional().describe("Current color theme preference."),styles:my.optional().describe("Style configuration for theming the app."),displayMode:Si.optional().describe("How the UI is currently displayed."),availableDisplayModes:m(Si).optional().describe("Display modes the host supports."),containerDimensions:v([l({height:_().describe("Fixed container height in pixels.")}),l({maxHeight:v([_(),Bo()]).optional().describe("Maximum container height in pixels.")})]).and(v([l({width:_().describe("Fixed container width in pixels.")}),l({maxWidth:v([_(),Bo()]).optional().describe("Maximum container width in pixels.")})])).optional().describe(`Container dimensions. Represents the dimensions of the iframe or other
|
|
109
|
+
container holding the app. Specify either width or maxWidth, and either height or maxHeight.`),locale:a().optional().describe("User's language and region preference in BCP 47 format."),timeZone:a().optional().describe("User's timezone in IANA format."),userAgent:a().optional().describe("Host application identifier."),platform:v([u("web"),u("desktop"),u("mobile")]).optional().describe("Platform type for responsive design decisions."),deviceCapabilities:l({touch:z().optional().describe("Whether the device supports touch input."),hover:z().optional().describe("Whether the device supports hover interactions.")}).optional().describe("Device input capabilities."),safeAreaInsets:l({top:_().describe("Top safe area inset in pixels."),right:_().describe("Right safe area inset in pixels."),bottom:_().describe("Bottom safe area inset in pixels."),left:_().describe("Left safe area inset in pixels.")}).optional().describe("Mobile safe area boundaries in pixels.")}).passthrough(),zy=l({method:u("ui/notifications/host-context-changed"),params:_f.describe("Partial context update containing only changed fields.")}),yx=l({method:u("ui/update-model-context"),params:l({content:m(Ae).optional().describe("Context content blocks (text, image, etc.)."),structuredContent:y(a(),P().describe("Structured content for machine-readable context data.")).optional().describe("Structured content for machine-readable context data.")})}),vx=l({method:u("ui/initialize"),params:l({appInfo:Ne.describe("App identification (name and version)."),appCapabilities:_y.describe("Features and capabilities this app provides."),protocolVersion:a().describe("Protocol version this app supports.")})}),Ry=l({protocolVersion:a().describe('Negotiated protocol version string (e.g., "2025-11-21").'),hostInfo:Ne.describe("Host application identification and version."),hostCapabilities:Sy.describe("Features and capabilities provided by the host."),hostContext:_f.describe("Rich context about the host environment.")}).passthrough(),wy={target:"draft-2020-12"};async function hf(e,t){let o=e["~standard"];if(o.jsonSchema)return o.jsonSchema[t](wy);throw Error(`Schema (vendor: ${o.vendor}) does not implement Standard JSON Schema (~standard.jsonSchema). Use a library that does (zod v4, ArkType, Valibot) or wrap your schema accordingly.`)}async function mf(e,t,o=""){let r=await e["~standard"].validate(t);if(r.issues){let n=r.issues.map((i)=>{let s=i.path?.map((c)=>typeof c==="object"?c.key:c).join(".");return s?`${s}: ${i.message}`:i.message}).join("; ");throw Error(o+n)}return r.value}function xy(e,t){let o={...e,...t};if(t.experimental!==void 0)o.experimental={...e.experimental,...t.experimental};if(t.tools!==void 0)o.tools={...e.tools,...t.tools};return o}class Ja extends To{_appInfo;_appCapabilities;options;_hostCapabilities;_hostInfo;_hostContext;_registeredTools={};_initializedSent=!1;_registeredEvents=new Set;_events=new ff;_methods=new gf;setRequestHandler=(...e)=>{let[t,...o]=df("request",e)??e;this._methods.claim(t,"setRequestHandler"),super.setRequestHandler.call(this,t,...o)};setNotificationHandler=(...e)=>{let[t,...o]=df("notification",e)??e;this._methods.claim(t,"setNotificationHandler"),super.setNotificationHandler.call(this,t,...o)};removeRequestHandler=(e)=>{this._methods.release(e),super.removeRequestHandler(e)};removeNotificationHandler=(e)=>{this._methods.release(e),super.removeNotificationHandler(e)};replaceRequestHandler=(e,...t)=>{this._methods.replace(e),super.setRequestHandler.call(this,e,...t)};_assertInitialized(e){if(this._initializedSent)return;let t=`[ext-apps] App.${e}() called before connect() completed the ui/initialize handshake. Await app.connect() before calling this method, or move data loading to an ontoolresult handler.`;if(this.options?.strict)throw Error(t);console.warn(`${t}. This will throw in a future release.`)}eventSchemas={toolinput:uy,toolinputpartial:dy,toolresult:vy,toolcancelled:py,hostcontextchanged:zy};static ONE_SHOT_EVENTS=new Set(["toolinput","toolinputpartial","toolresult","toolcancelled"]);_everHadListener=new Set;_assertHandlerTiming(e){if(!Ja.ONE_SHOT_EVENTS.has(e)||this._everHadListener.has(e))return;if(this._everHadListener.add(e),!this._initializedSent)return;let t=`[ext-apps] "${String(e)}" handler registered after connect() completed the ui/initialize handshake. The host may have already sent this notification. Register handlers before calling app.connect().`;if(this.options?.strict)throw Error(t);console.warn(t)}setEventHandler(e,t){if(t)this._assertHandlerTiming(e);this._ensureEventSlot(e),this._events.setHandler(e,t)}addEventListener(e,t){this._assertHandlerTiming(e),this._ensureEventSlot(e),this._events.addEventListener(e,t)}removeEventListener(e,t){this._events.removeEventListener(e,t)}_ensureEventSlot(e){if(this._registeredEvents.has(e))return;let t=this.eventSchemas[e];if(!t)throw Error(`Unknown event: ${String(e)}`);this.setNotificationHandler(t.shape.method.value,{params:t.shape.params},(o)=>{let r=o;if(e==="hostcontextchanged")this._hostContext={...this._hostContext,...r};this._events.dispatch(e,r)}),this._registeredEvents.add(e)}getEventHandler(e){return this._events.getHandler(e)}warnIfRequestHandlerReplaced(e,t,o){if(t&&o)console.warn(`[MCP Apps] ${e} handler replaced. Previous handler will no longer be called.`)}constructor(e,t={},o={autoResize:!0}){super(o);if(this._appInfo=e,this._appCapabilities=t,this.options=o,this._methods.replace("notifications/cancelled"),this._methods.replace("notifications/progress"),!o.allowUnsafeEval)ze({jitless:!0});this.replaceRequestHandler("ping",(r)=>(console.log("Received ping:",r.params),{})),this.setEventHandler("hostcontextchanged",void 0)}buildContext(e){return e}registerAppCapabilities(e){if(this.transport)throw Error("Cannot register capabilities after transport is established");this._appCapabilities=xy(this._appCapabilities,e)}registerTool(e,t,o){if(this._registeredTools[e])throw Error(`Tool ${e} is already registered`);let r=this,n=()=>{if(r._initializedSent&&r._appCapabilities.tools?.listChanged)r.sendToolListChanged()},i=t.inputSchema!==void 0,s={title:t.title,description:t.description,inputSchema:t.inputSchema,outputSchema:t.outputSchema,annotations:t.annotations,_meta:t._meta,enabled:!0,enable(){this.enabled=!0,n()},disable(){this.enabled=!1,n()},update(c){Object.assign(this,c),n()},remove(){if(r._registeredTools[e]!==s)return;delete r._registeredTools[e],n()},handler:async(c,d)=>{if(!s.enabled)throw Error(`Tool ${e} is disabled`);let p;if(i){let h=s.inputSchema,f=h?await mf(h,c??{},`Invalid input for tool ${e}: `):c??{};p=await o(f,d)}else p=await o(d);if(s.outputSchema&&!p.isError)p.structuredContent=await mf(s.outputSchema,p.structuredContent,`Invalid output for tool ${e}: `);return p}};if(this._registeredTools[e]=s,!this._appCapabilities.tools&&!this.transport)this.registerAppCapabilities({tools:{listChanged:!0}});return this.ensureToolHandlersInitialized(),n(),s}_toolHandlersInitialized=!1;ensureToolHandlersInitialized(){if(this._toolHandlersInitialized)return;this._toolHandlersInitialized=!0,this.oncalltool=async(e,t)=>{let o=this._registeredTools[e.name];if(!o)throw Error(`Tool ${e.name} not found`);return o.handler(e.arguments,t)},this.onlisttools=async(e,t)=>({tools:await Promise.all(Object.entries(this._registeredTools).filter(([o,r])=>r.enabled).map(async([o,r])=>{let n={name:o,title:r.title,description:r.description,inputSchema:r.inputSchema?await hf(r.inputSchema,"input"):{type:"object",properties:{}}};if(r.outputSchema)n.outputSchema=await hf(r.outputSchema,"output");if(r.annotations)n.annotations=r.annotations;if(r._meta)n._meta=r._meta;return n}))})}async sendToolListChanged(e={}){this._assertInitialized("sendToolListChanged"),await this.notification({method:"notifications/tools/list_changed",params:e})}getHostCapabilities(){return this._hostCapabilities}getHostVersion(){return this._hostInfo}getHostContext(){return this._hostContext}get ontoolinput(){return this.getEventHandler("toolinput")}set ontoolinput(e){this.setEventHandler("toolinput",e)}get ontoolinputpartial(){return this.getEventHandler("toolinputpartial")}set ontoolinputpartial(e){this.setEventHandler("toolinputpartial",e)}get ontoolresult(){return this.getEventHandler("toolresult")}set ontoolresult(e){this.setEventHandler("toolresult",e)}get ontoolcancelled(){return this.getEventHandler("toolcancelled")}set ontoolcancelled(e){this.setEventHandler("toolcancelled",e)}get onhostcontextchanged(){return this.getEventHandler("hostcontextchanged")}set onhostcontextchanged(e){this.setEventHandler("hostcontextchanged",e)}_onteardown;get onteardown(){return this._onteardown}set onteardown(e){this.warnIfRequestHandlerReplaced("onteardown",this._onteardown,e),this._onteardown=e,this.replaceRequestHandler("ui/resource-teardown",{params:fy.shape.params,result:gy},(t,o)=>{if(!this._onteardown)throw Error("No onteardown handler set");return this._onteardown(t,o)})}_oncalltool;get oncalltool(){return this._oncalltool}set oncalltool(e){this.warnIfRequestHandlerReplaced("oncalltool",this._oncalltool,e),this._oncalltool=e,this.replaceRequestHandler("tools/call",(t,o)=>{if(!this._oncalltool)throw Error("No oncalltool handler set");return this._oncalltool(t.params,o)})}_onlisttools;get onlisttools(){return this._onlisttools}set onlisttools(e){this.warnIfRequestHandlerReplaced("onlisttools",this._onlisttools,e),this._onlisttools=e,this.replaceRequestHandler("tools/list",(t,o)=>{if(!this._onlisttools)throw Error("No onlisttools handler set");return this._onlisttools(t.params,o)})}assertCapabilityForMethod(e){switch(e){case"sampling/createMessage":if(!this._hostCapabilities?.sampling)throw Error(`Host does not support sampling (required for ${e})`);break}}assertRequestHandlerCapability(e){switch(e){case"tools/call":case"tools/list":if(!this._appCapabilities.tools)throw Error(`Client does not support tool capability (required for ${e})`);return;default:return}}assertNotificationCapability(e){}async callServerTool(e,t){if(this._assertInitialized("callServerTool"),typeof e==="string")throw Error(`callServerTool() expects an object as its first argument, but received a string ("${e}"). Did you mean: callServerTool({ name: "${e}", arguments: { ... } })?`);return await this.request({method:"tools/call",params:e},{onprogress:()=>{},resetTimeoutOnProgress:!0,...t})}async readServerResource(e,t){return this._assertInitialized("readServerResource"),await this.request({method:"resources/read",params:e},t)}async listServerResources(e,t){return this._assertInitialized("listServerResources"),await this.request({method:"resources/list",params:e},t)}async createSamplingMessage(e,t){return this._assertInitialized("createSamplingMessage"),await this.request({method:"sampling/createMessage",params:e},t)}sendMessage(e,t){return this._assertInitialized("sendMessage"),this.request({method:"ui/message",params:e},ly,t)}sendLog(e){return this.notification({method:"notifications/message",params:e})}updateModelContext(e,t){return this._assertInitialized("updateModelContext"),this.request({method:"ui/update-model-context",params:e},pt,t)}openLink(e,t){return this._assertInitialized("openLink"),this.request({method:"ui/open-link",params:e},ay,t)}sendOpenLink=this.openLink;downloadFile(e,t){return this._assertInitialized("downloadFile"),this.request({method:"ui/download-file",params:e},cy,t)}requestTeardown(e={}){return this.notification({method:"ui/notifications/request-teardown",params:e})}requestDisplayMode(e,t){return this._assertInitialized("requestDisplayMode"),this.request({method:"ui/request-display-mode",params:e},by,t)}sendSizeChanged(e){return this.notification({method:"ui/notifications/size-changed",params:e})}setupSizeChangedNotifications(){let e=!1,t=0,o=0,r=()=>{if(e)return;e=!0,requestAnimationFrame(()=>{e=!1;let i=document.documentElement,s=i.style.height;i.style.height="max-content";let c=Math.ceil(i.getBoundingClientRect().height);i.style.height=s;let d=Math.ceil(window.innerWidth);if(d!==t||c!==o)t=d,o=c,this.sendSizeChanged({width:d,height:c})})};r();let n=new ResizeObserver(r);return n.observe(document.documentElement),n.observe(document.body),()=>n.disconnect()}async connect(e=new Sf(window.parent,window.parent),t){if(this.transport)throw Error("App is already connected. Call close() before connecting again.");this._initializedSent=!1;try{await super.connect(e);let o=await this.request({method:"ui/initialize",params:{appCapabilities:this._appCapabilities,appInfo:this._appInfo,protocolVersion:oy}},Ry,t);if(o===void 0)throw Error(`Server sent invalid initialize result: ${o}`);if(this._hostCapabilities=o.hostCapabilities,this._hostInfo=o.hostInfo,this._hostContext=o.hostContext,await this.notification({method:"ui/notifications/initialized"}),this._initializedSent=!0,this.options?.autoResize)this.setupSizeChangedNotifications()}catch(o){throw this.close(),o}}}class wf{_eventSlots=new Map;setHandler(e,t){let o=this._ensureEventSlot(e);if(o.onHandler&&t)console.warn(`[MCP Apps] on${String(e)} handler replaced. Use addEventListener("${String(e)}", …) to add multiple listeners without replacing.`);o.onHandler=t}getHandler(e){return this._eventSlots.get(e)?.onHandler}addEventListener(e,t){this._ensureEventSlot(e).listeners.push(t)}removeEventListener(e,t){let o=this._eventSlots.get(e);if(!o)return;let r=o.listeners.indexOf(t);if(r!==-1)o.listeners.splice(r,1)}dispatch(e,t){let o=this._eventSlots.get(e);if(!o)return;o.onHandler?.(t);for(let r of[...o.listeners])r(t)}_ensureEventSlot(e){let t=this._eventSlots.get(e);if(!t)t={listeners:[]},this._eventSlots.set(e,t);return t}}class xf{_methods=new Set;claim(e,t){if(this._methods.has(e))throw Error(`Handler for "${e}" already registered (via ${t}). Use addEventListener() to attach multiple listeners, or the on* setter for replace semantics.`);this._methods.add(e)}replace(e){this._methods.add(e)}release(e){this._methods.delete(e)}has(e){return this._methods.has(e)}}var bf=new Set;function yf(e,t){let[o,r]=t,n=o?.shape;if(typeof n?.method?.value!=="string")return;let i=n.method.value,s=e==="request"?"setRequestHandler":"setNotificationHandler";if(!bf.has(s))bf.add(s),console.warn(`[ext-apps] ${s}(Schema, handler) is deprecated; use ${s}("${i}", { params: Schema.shape.params }, handler).`);let c=r;return[i,{params:n.params},e==="request"?(d,p)=>c({method:i,params:d},Ey(p)):(d)=>c({method:i,params:d})]}function Ey(e){return{signal:e.mcpReq.signal,requestId:e.mcpReq.id,sessionId:e.sessionId,_meta:e.mcpReq._meta,sendRequest:e.mcpReq.send,sendNotification:e.mcpReq.notify,authInfo:e.http?.authInfo}}var Ef="2026-01-26";var Ty="ui/notifications/tool-input-partial";var Py=v([u("light"),u("dark")]).describe("Color theme preference for the host environment."),_i=v([u("inline"),u("fullscreen"),u("pip")]).describe("Display mode for UI presentation."),ky=v([u("--color-background-primary"),u("--color-background-secondary"),u("--color-background-tertiary"),u("--color-background-inverse"),u("--color-background-ghost"),u("--color-background-info"),u("--color-background-danger"),u("--color-background-success"),u("--color-background-warning"),u("--color-background-disabled"),u("--color-text-primary"),u("--color-text-secondary"),u("--color-text-tertiary"),u("--color-text-inverse"),u("--color-text-ghost"),u("--color-text-info"),u("--color-text-danger"),u("--color-text-success"),u("--color-text-warning"),u("--color-text-disabled"),u("--color-border-primary"),u("--color-border-secondary"),u("--color-border-tertiary"),u("--color-border-inverse"),u("--color-border-ghost"),u("--color-border-info"),u("--color-border-danger"),u("--color-border-success"),u("--color-border-warning"),u("--color-border-disabled"),u("--color-ring-primary"),u("--color-ring-secondary"),u("--color-ring-inverse"),u("--color-ring-info"),u("--color-ring-danger"),u("--color-ring-success"),u("--color-ring-warning"),u("--font-sans"),u("--font-mono"),u("--font-weight-normal"),u("--font-weight-medium"),u("--font-weight-semibold"),u("--font-weight-bold"),u("--font-text-xs-size"),u("--font-text-sm-size"),u("--font-text-md-size"),u("--font-text-lg-size"),u("--font-heading-xs-size"),u("--font-heading-sm-size"),u("--font-heading-md-size"),u("--font-heading-lg-size"),u("--font-heading-xl-size"),u("--font-heading-2xl-size"),u("--font-heading-3xl-size"),u("--font-text-xs-line-height"),u("--font-text-sm-line-height"),u("--font-text-md-line-height"),u("--font-text-lg-line-height"),u("--font-heading-xs-line-height"),u("--font-heading-sm-line-height"),u("--font-heading-md-line-height"),u("--font-heading-lg-line-height"),u("--font-heading-xl-line-height"),u("--font-heading-2xl-line-height"),u("--font-heading-3xl-line-height"),u("--border-radius-xs"),u("--border-radius-sm"),u("--border-radius-md"),u("--border-radius-lg"),u("--border-radius-xl"),u("--border-radius-full"),u("--border-width-regular"),u("--shadow-hairline"),u("--shadow-sm"),u("--shadow-md"),u("--shadow-lg")]).describe("CSS variable keys available to MCP apps for theming."),$y=y(ky.describe(`Style variables for theming MCP apps.
|
|
107
110
|
|
|
108
111
|
Individual style keys are optional - hosts may provide any subset of these values.
|
|
109
112
|
Values are strings containing CSS values (colors, sizes, font stacks, etc.).
|
|
110
113
|
|
|
111
114
|
Note: This type uses \`Record<K, string | undefined>\` rather than \`Partial<Record<K, string>>\`
|
|
112
|
-
for compatibility with Zod schema generation. Both are functionally equivalent for validation.`),
|
|
115
|
+
for compatibility with Zod schema generation. Both are functionally equivalent for validation.`),v([a(),Bo()]).describe(`Style variables for theming MCP apps.
|
|
113
116
|
|
|
114
117
|
Individual style keys are optional - hosts may provide any subset of these values.
|
|
115
118
|
Values are strings containing CSS values (colors, sizes, font stacks, etc.).
|
|
@@ -121,10 +124,10 @@ Individual style keys are optional - hosts may provide any subset of these value
|
|
|
121
124
|
Values are strings containing CSS values (colors, sizes, font stacks, etc.).
|
|
122
125
|
|
|
123
126
|
Note: This type uses \`Record<K, string | undefined>\` rather than \`Partial<Record<K, string>>\`
|
|
124
|
-
for compatibility with Zod schema generation. Both are functionally equivalent for validation.`),
|
|
127
|
+
for compatibility with Zod schema generation. Both are functionally equivalent for validation.`),Cy=l({method:u("ui/open-link"),params:l({url:a().describe("URL to open in the host's browser")})}),Iy=l({isError:z().optional().describe("True if the host failed to open the URL (e.g., due to security policy).")}).passthrough(),Oy=l({isError:z().optional().describe("True if the download failed (e.g., user cancelled or host denied).")}).passthrough(),My=l({isError:z().optional().describe("True if the host rejected or failed to deliver the message.")}).passthrough(),qy=l({method:u("ui/notifications/sandbox-proxy-ready"),params:l({})}),ql=l({connectDomains:m(a()).optional().describe(`Origins for network requests (fetch/XHR/WebSocket).
|
|
125
128
|
|
|
126
129
|
- Maps to CSP \`connect-src\` directive
|
|
127
|
-
- Empty or omitted → no network connections (secure default)`),resourceDomains:
|
|
130
|
+
- Empty or omitted → no network connections (secure default)`),resourceDomains:m(a()).optional().describe("Origins for static resources (images, scripts, stylesheets, fonts, media).\n\n- Maps to CSP `img-src`, `script-src`, `style-src`, `font-src`, `media-src` directives\n- Wildcard subdomains supported: `https://*.example.com`\n- Empty or omitted → no network resources (secure default)"),frameDomains:m(a()).optional().describe("Origins for nested iframes.\n\n- Maps to CSP `frame-src` directive\n- Empty or omitted → no nested iframes allowed (`frame-src 'none'`)"),baseUriDomains:m(a()).optional().describe("Allowed base URIs for the document.\n\n- Maps to CSP `base-uri` directive\n- Empty or omitted → only same origin allowed (`base-uri 'self'`)")}),Nl=l({camera:l({}).optional().describe("Request camera access.\n\nMaps to Permission Policy `camera` feature."),microphone:l({}).optional().describe("Request microphone access.\n\nMaps to Permission Policy `microphone` feature."),geolocation:l({}).optional().describe("Request geolocation access.\n\nMaps to Permission Policy `geolocation` feature."),clipboardWrite:l({}).optional().describe("Request clipboard write access.\n\nMaps to Permission Policy `clipboard-write` feature.")}),Ny=l({method:u("ui/notifications/size-changed"),params:l({width:_().optional().describe("New width in pixels."),height:_().optional().describe("New height in pixels.")})}),Px=l({method:u("ui/notifications/tool-input"),params:l({arguments:y(a(),P().describe("Complete tool call arguments as key-value pairs.")).optional().describe("Complete tool call arguments as key-value pairs.")})}),kx=l({method:u("ui/notifications/tool-input-partial"),params:l({arguments:y(a(),P().describe("Partial tool call arguments (incomplete, may change).")).optional().describe("Partial tool call arguments (incomplete, may change).")})}),$x=l({method:u("ui/notifications/tool-cancelled"),params:l({reason:a().optional().describe('Optional reason for the cancellation (e.g., "user action", "timeout").')})}),Ay=l({fonts:a().optional()}),jy=l({variables:$y.optional().describe("CSS variables for theming the app."),css:Ay.optional().describe("CSS blocks that apps can inject.")}),Cx=l({method:u("ui/resource-teardown"),params:l({})}),Ly=y(a(),P()),vf=l({text:l({}).optional().describe("Host supports text content blocks."),image:l({}).optional().describe("Host supports image content blocks."),audio:l({}).optional().describe("Host supports audio content blocks."),resource:l({}).optional().describe("Host supports resource content blocks."),resourceLink:l({}).optional().describe("Host supports resource link content blocks."),structuredContent:l({}).optional().describe("Host supports structured content.")}),Uy=l({method:u("ui/notifications/request-teardown"),params:l({}).optional()}),Zy=l({experimental:y(a(),y(a(),Wo()).describe("Experimental features keyed by identifier.")).optional().describe("Experimental features keyed by identifier."),openLinks:l({}).optional().describe("Host supports opening external URLs."),downloadFile:l({}).optional().describe("Host supports file downloads via ui/download-file."),serverTools:l({listChanged:z().optional().describe("Host supports tools/list_changed notifications.")}).optional().describe("Host can proxy tool calls to the MCP server."),serverResources:l({listChanged:z().optional().describe("Host supports resources/list_changed notifications.")}).optional().describe("Host can proxy resource reads to the MCP server."),logging:l({}).optional().describe("Host accepts log messages."),sandbox:l({permissions:Nl.optional().describe("Permissions granted by the host (camera, microphone, geolocation)."),csp:ql.optional().describe("CSP domains approved by the host.")}).optional().describe("Sandbox configuration applied by the host."),updateModelContext:vf.optional().describe("Host accepts context updates (ui/update-model-context) to be included in the model's context for future turns."),message:vf.optional().describe("Host supports receiving content messages (ui/message) from the view."),sampling:l({tools:l({}).optional().describe("Host supports tool use via `tools` and `toolChoice` parameters.")}).optional().describe("Host supports LLM sampling (sampling/createMessage) from the view.\nMirrors the MCP `ClientCapabilities.sampling` shape so hosts can pass it through.")}),Dy=l({experimental:y(a(),y(a(),Wo()).describe("Experimental features keyed by identifier.")).optional().describe("Experimental features keyed by identifier."),tools:l({listChanged:z().optional().describe("App supports tools/list_changed notifications.")}).optional().describe("App exposes MCP-style tools that the host can call."),availableDisplayModes:m(_i).optional().describe("Display modes the app supports.")}),Hy=l({method:u("ui/notifications/initialized"),params:l({}).optional()}),Ix=l({csp:ql.optional().describe("Content Security Policy configuration for UI resources."),permissions:Nl.optional().describe("Sandbox permissions requested by the UI resource."),domain:a().optional().describe(`Dedicated origin for view sandbox.
|
|
128
131
|
|
|
129
132
|
Useful when views need stable, dedicated origins for OAuth callbacks, CORS policies, or API key allowlists.
|
|
130
133
|
|
|
@@ -132,13 +135,13 @@ Useful when views need stable, dedicated origins for OAuth callbacks, CORS polic
|
|
|
132
135
|
- Hash-based subdomains (e.g., \`{hash}.claudemcpcontent.com\`)
|
|
133
136
|
- URL-derived subdomains (e.g., \`www-example-com.oaiusercontent.com\`)
|
|
134
137
|
|
|
135
|
-
If omitted, host uses default sandbox origin (typically per-conversation).`),prefersBorder:
|
|
138
|
+
If omitted, host uses default sandbox origin (typically per-conversation).`),prefersBorder:z().optional().describe(`Visual boundary preference - true if view prefers a visible border.
|
|
136
139
|
|
|
137
140
|
Boolean requesting whether a visible border and background is provided by the host. Specifying an explicit value for this is recommended because hosts' defaults may vary.
|
|
138
141
|
|
|
139
142
|
- \`true\`: request visible border + background
|
|
140
143
|
- \`false\`: request no visible border + background
|
|
141
|
-
- omitted: host decides border`)}),
|
|
144
|
+
- omitted: host decides border`)}),zf=l({method:u("ui/request-display-mode"),params:l({mode:_i.describe("The display mode being requested.")})}),Rf=l({mode:_i.describe("The display mode that was actually set. May differ from requested if not supported.")}).passthrough(),Fy=v([u("model"),u("app")]).describe("Tool visibility scope - who can access the tool."),Ox=l({resourceUri:a().optional(),visibility:m(Fy).optional().describe(`Who can access this tool. Default: ["model", "app"]
|
|
142
145
|
- "model": Tool visible to and callable by the agent
|
|
143
|
-
- "app": Tool callable by the app from this server only`),csp:
|
|
144
|
-
container holding the app. Specify either width or maxWidth, and either height or maxHeight.`),locale:s().optional().describe("User's language and region preference in BCP 47 format."),timeZone:s().optional().describe("User's timezone in IANA format."),userAgent:s().optional().describe("Host application identifier."),platform:_([l("web"),l("desktop"),l("mobile")]).optional().describe("Platform type for responsive design decisions."),deviceCapabilities:c({touch:v().optional().describe("Whether the device supports touch input."),hover:v().optional().describe("Whether the device supports hover interactions.")}).optional().describe("Device input capabilities."),safeAreaInsets:c({top:g().describe("Top safe area inset in pixels."),right:g().describe("Right safe area inset in pixels."),bottom:g().describe("Bottom safe area inset in pixels."),left:g().describe("Left safe area inset in pixels.")}).optional().describe("Mobile safe area boundaries in pixels.")}).passthrough(),vR=c({method:l("ui/notifications/host-context-changed"),params:Im.describe("Partial context update containing only changed fields.")}),W_=c({method:l("ui/update-model-context"),params:c({content:h(Se).optional().describe("Context content blocks (text, image, etc.)."),structuredContent:S(s(),R().describe("Structured content for machine-readable context data.")).optional().describe("Structured content for machine-readable context data.")})}),K_=c({method:l("ui/initialize"),params:c({appInfo:ge.describe("App identification (name and version)."),appCapabilities:H_.describe("Features and capabilities this app provides."),protocolVersion:s().describe("Protocol version this app supports.")})}),G_=c({protocolVersion:s().describe('Negotiated protocol version string (e.g., "2025-11-21").'),hostInfo:ge.describe("Host application identification and version."),hostCapabilities:D_.describe("Features and capabilities provided by the host."),hostContext:Im.describe("Rich context about the host environment.")}).passthrough();class dl{eventTarget;eventSource;messageListener;constructor(e=window.parent,t){this.eventTarget=e,this.eventSource=t,this.messageListener=(o)=>{if(t&&o.source!==this.eventSource){console.debug("Ignoring message from unknown source",o);return}let r=De.safeParse(o.data);if(r.success)console.debug("Parsed message",r.data),this.onmessage?.(r.data);else if(o.data?.jsonrpc!=="2.0")console.debug("Ignoring non-JSON-RPC message",r.error.message,o);else console.error("Failed to parse message",r.error.message,o),this.onerror?.(Error("Invalid JSON-RPC message received: "+r.error.message))}}async start(){window.addEventListener("message",this.messageListener)}async send(e,t){if(e.method!==P_)console.debug("Sending message",e);this.eventTarget.postMessage(e,"*")}async close(){window.removeEventListener("message",this.messageListener),this.onclose?.()}onclose;onerror;onmessage;sessionId;setProtocolVersion}var Y_=[Cm];class pl extends ei{_client;_hostInfo;_hostCapabilities;_appCapabilities;_hostContext={};_appInfo;_initializedReceived=!1;_registeredEvents=new Set;_events=new km;_methods=new $m;setRequestHandler=(...e)=>{let[t,...o]=xm("request",e)??e;this._methods.claim(t,"setRequestHandler"),super.setRequestHandler.call(this,t,...o)};setNotificationHandler=(...e)=>{let[t,...o]=xm("notification",e)??e;this._methods.claim(t,"setNotificationHandler"),super.setNotificationHandler.call(this,t,...o)};removeRequestHandler=(e)=>{this._methods.release(e),super.removeRequestHandler(e)};removeNotificationHandler=(e)=>{this._methods.release(e),super.removeNotificationHandler(e)};replaceRequestHandler=(e,...t)=>{this._methods.replace(e),super.setRequestHandler.call(this,e,...t)};_wrapHandler(e,t){let o=super._wrapHandler(e,t);if(e==="ui/initialize"||e==="ping")return o;return async(r,n)=>{if(!this._initializedReceived)console.warn(`[ext-apps] AppBridge received '${e}' before ui/notifications/initialized. The View is calling host methods before completing the handshake; it should await app.connect() first.`);return o(r,n)}}eventSchemas={sizechange:A_,sandboxready:N_,initialized:F_,requestteardown:Z_,loggingmessage:Ht};setEventHandler(e,t){this._ensureEventSlot(e),this._events.setHandler(e,t)}getEventHandler(e){return this._events.getHandler(e)}addEventListener(e,t){this._ensureEventSlot(e),this._events.addEventListener(e,t)}removeEventListener(e,t){this._events.removeEventListener(e,t)}_ensureEventSlot(e){if(this._registeredEvents.has(e))return;let t=this.eventSchemas[e];if(!t)throw Error(`Unknown event: ${String(e)}`);let o=(r)=>{if(e==="initialized")this._initializedReceived=!0;this._events.dispatch(e,r)};if(e==="loggingmessage")this.setNotificationHandler("notifications/message",(r)=>{o(r.params)});else this.setNotificationHandler(t.shape.method.value,{params:t.shape.params},(r)=>o(r));this._registeredEvents.add(e)}warnIfRequestHandlerReplaced(e,t,o){if(t&&o)console.warn(`[MCP Apps] ${e} handler replaced. Previous handler will no longer be called.`)}constructor(e,t,o,r){super(r);this._client=e,this._hostInfo=t,this._hostCapabilities=o,this._methods.replace("notifications/cancelled"),this._methods.replace("notifications/progress"),this._ensureEventSlot("initialized"),this._hostContext=r?.hostContext||{},this.replaceRequestHandler("ui/initialize",{params:K_.shape.params,result:G_},(n)=>this._onAppsInitialize(n)),this.replaceRequestHandler("ping",(n,i)=>(this.onping?.(n.params,i),{})),this.replaceRequestHandler("ui/request-display-mode",{params:Em.shape.params,result:Pm},()=>({mode:this._hostContext.displayMode??"inline"}))}buildContext(e){return e}assertCapabilityForMethod(e){}assertRequestHandlerCapability(e){}assertNotificationCapability(e){}getAppCapabilities(){return this._appCapabilities}getAppVersion(){return this._appInfo}onping;get onsizechange(){return this.getEventHandler("sizechange")}set onsizechange(e){this.setEventHandler("sizechange",e)}get onsandboxready(){return this.getEventHandler("sandboxready")}set onsandboxready(e){this.setEventHandler("sandboxready",e)}get oninitialized(){return this.getEventHandler("initialized")}set oninitialized(e){this.setEventHandler("initialized",e)}_onmessage;get onmessage(){return this._onmessage}set onmessage(e){this.warnIfRequestHandlerReplaced("onmessage",this._onmessage,e),this._onmessage=e,this.replaceRequestHandler("ui/message",{params:B_.shape.params,result:q_},async(t,o)=>{if(!this._onmessage)throw Error("No onmessage handler set");return this._onmessage(t,o)})}_onopenlink;get onopenlink(){return this._onopenlink}set onopenlink(e){this.warnIfRequestHandlerReplaced("onopenlink",this._onopenlink,e),this._onopenlink=e,this.replaceRequestHandler("ui/open-link",{params:I_.shape.params,result:O_},async(t,o)=>{if(!this._onopenlink)throw Error("No onopenlink handler set");return this._onopenlink(t,o)})}_ondownloadfile;get ondownloadfile(){return this._ondownloadfile}set ondownloadfile(e){this.warnIfRequestHandlerReplaced("ondownloadfile",this._ondownloadfile,e),this._ondownloadfile=e,this.replaceRequestHandler("ui/download-file",{params:J_.shape.params,result:M_},async(t,o)=>{if(!this._ondownloadfile)throw Error("No ondownloadfile handler set");return this._ondownloadfile(t,o)})}get onrequestteardown(){return this.getEventHandler("requestteardown")}set onrequestteardown(e){this.setEventHandler("requestteardown",e)}_onrequestdisplaymode;get onrequestdisplaymode(){return this._onrequestdisplaymode}set onrequestdisplaymode(e){this.warnIfRequestHandlerReplaced("onrequestdisplaymode",this._onrequestdisplaymode,e),this._onrequestdisplaymode=e,this.replaceRequestHandler("ui/request-display-mode",{params:Em.shape.params,result:Pm},async(t,o)=>{if(!this._onrequestdisplaymode)throw Error("No onrequestdisplaymode handler set");return this._onrequestdisplaymode(t,o)})}get onloggingmessage(){return this.getEventHandler("loggingmessage")}set onloggingmessage(e){this.setEventHandler("loggingmessage",e)}_onupdatemodelcontext;get onupdatemodelcontext(){return this._onupdatemodelcontext}set onupdatemodelcontext(e){this.warnIfRequestHandlerReplaced("onupdatemodelcontext",this._onupdatemodelcontext,e),this._onupdatemodelcontext=e,this.replaceRequestHandler("ui/update-model-context",{params:W_.shape.params,result:Ce},async(t,o)=>{if(!this._onupdatemodelcontext)throw Error("No onupdatemodelcontext handler set");return this._onupdatemodelcontext(t,o)})}_oncalltool;get oncalltool(){return this._oncalltool}set oncalltool(e){this.warnIfRequestHandlerReplaced("oncalltool",this._oncalltool,e),this._oncalltool=e,this.replaceRequestHandler("tools/call",async(t,o)=>{if(!this._oncalltool)throw Error("No oncalltool handler set");return this._oncalltool(t.params,o)})}_oncreatesamplingmessage;get oncreatesamplingmessage(){return this._oncreatesamplingmessage}set oncreatesamplingmessage(e){this.warnIfRequestHandlerReplaced("oncreatesamplingmessage",this._oncreatesamplingmessage,e),this._oncreatesamplingmessage=e,this.replaceRequestHandler("sampling/createMessage",async(t,o)=>{if(!this._oncreatesamplingmessage)throw Error("No oncreatesamplingmessage handler set");return this._oncreatesamplingmessage(t.params,o)})}sendToolListChanged(e={}){return this.notification({method:"notifications/tools/list_changed",params:e})}_onlistresources;get onlistresources(){return this._onlistresources}set onlistresources(e){this.warnIfRequestHandlerReplaced("onlistresources",this._onlistresources,e),this._onlistresources=e,this.replaceRequestHandler("resources/list",async(t,o)=>{if(!this._onlistresources)throw Error("No onlistresources handler set");return this._onlistresources(t.params,o)})}_onlistresourcetemplates;get onlistresourcetemplates(){return this._onlistresourcetemplates}set onlistresourcetemplates(e){this.warnIfRequestHandlerReplaced("onlistresourcetemplates",this._onlistresourcetemplates,e),this._onlistresourcetemplates=e,this.replaceRequestHandler("resources/templates/list",async(t,o)=>{if(!this._onlistresourcetemplates)throw Error("No onlistresourcetemplates handler set");return this._onlistresourcetemplates(t.params,o)})}_onreadresource;get onreadresource(){return this._onreadresource}set onreadresource(e){this.warnIfRequestHandlerReplaced("onreadresource",this._onreadresource,e),this._onreadresource=e,this.replaceRequestHandler("resources/read",async(t,o)=>{if(!this._onreadresource)throw Error("No onreadresource handler set");return this._onreadresource(t.params,o)})}sendResourceListChanged(e={}){return this.notification({method:"notifications/resources/list_changed",params:e})}_onlistprompts;get onlistprompts(){return this._onlistprompts}set onlistprompts(e){this.warnIfRequestHandlerReplaced("onlistprompts",this._onlistprompts,e),this._onlistprompts=e,this.replaceRequestHandler("prompts/list",async(t,o)=>{if(!this._onlistprompts)throw Error("No onlistprompts handler set");return this._onlistprompts(t.params,o)})}sendPromptListChanged(e={}){return this.notification({method:"notifications/prompts/list_changed",params:e})}getCapabilities(){return this._hostCapabilities}async _onAppsInitialize(e){let t=e.protocolVersion;if(this._appInfo!==void 0)console.warn("[ext-apps] AppBridge received a second ui/initialize. The View may be double-mounting (e.g. React StrictMode in dev) without closing the previous App instance. Responding normally; the latest appInfo/appCapabilities replace the previous values.");return this._appCapabilities=e.appCapabilities,this._appInfo=e.appInfo,{protocolVersion:Y_.includes(t)?t:Cm,hostCapabilities:this.getCapabilities(),hostInfo:this._hostInfo,hostContext:this._hostContext}}setHostContext(e){let t={},o=!1;for(let r of Object.keys(e)){let n=this._hostContext[r],i=e[r];if(Q_(n,i))continue;t[r]=i,o=!0}if(o)this._hostContext=e,this.sendHostContextChange(t)}sendHostContextChange(e){return this.notification({method:"ui/notifications/host-context-changed",params:e})}sendToolInput(e){return this.notification({method:"ui/notifications/tool-input",params:e})}sendToolInputPartial(e){return this.notification({method:"ui/notifications/tool-input-partial",params:e})}sendToolResult(e){return this.notification({method:"ui/notifications/tool-result",params:e})}sendToolCancelled(e){return this.notification({method:"ui/notifications/tool-cancelled",params:e})}sendSandboxResourceReady(e){return this.notification({method:"ui/notifications/sandbox-resource-ready",params:e})}teardownResource(e,t){return this.request({method:"ui/resource-teardown",params:e},U_,t)}sendResourceTeardown=this.teardownResource;callTool(e,t){return this.request({method:"tools/call",params:e},t)}listTools(e,t){return this.request({method:"tools/list",params:e},t)}async connect(e){if(this.transport)throw Error("AppBridge is already connected. Call close() before connecting again.");if(this._initializedReceived=!1,this._client){let t=this._client.getServerCapabilities();if(!t)throw Error("Client server capabilities not available");if(t.tools){if(this.oncalltool=async(o,r)=>this._client.request({method:"tools/call",params:o},{signal:r.mcpReq.signal}),t.tools.listChanged)this._client.setNotificationHandler("notifications/tools/list_changed",(o)=>this.sendToolListChanged(o.params))}if(t.resources){if(this.onlistresources=async(o,r)=>this._client.request({method:"resources/list",params:o},{signal:r.mcpReq.signal}),this.onlistresourcetemplates=async(o,r)=>this._client.request({method:"resources/templates/list",params:o},{signal:r.mcpReq.signal}),this.onreadresource=async(o,r)=>this._client.request({method:"resources/read",params:o},{signal:r.mcpReq.signal}),t.resources.listChanged)this._client.setNotificationHandler("notifications/resources/list_changed",(o)=>this.sendResourceListChanged(o.params))}if(t.prompts){if(this.onlistprompts=async(o,r)=>this._client.request({method:"prompts/list",params:o},{signal:r.mcpReq.signal}),t.prompts.listChanged)this._client.setNotificationHandler("notifications/prompts/list_changed",(o)=>this.sendPromptListChanged(o.params))}}return super.connect(e)}}function Q_(e,t){return JSON.stringify(e)===JSON.stringify(t)}function Om(e,t){let o=new DOMParser().parseFromString(e,"text/html"),r=o.createElement("meta");if(r.httpEquiv="Content-Security-Policy",r.content=t,o.head.prepend(r),!o.querySelector("base[href]")){let n=o.querySelector("base")??o.createElement("base");n.setAttribute("href","about:srcdoc"),r.after(n)}return"<!doctype html>"+o.documentElement.outerHTML}var ue=new Ta({name:"ADS preview",version:"1.0.0"},{},{autoResize:!0}),Kt=document.getElementById("ads-token-root"),ht=document.getElementById("ads-widget-status"),si=document.getElementById("ads-token-theme"),Ko=document.getElementById("ads-token-brand"),Ea=document.getElementById("ads-scenario-root"),be,ze=0,Mm="",Go=30,qm=document.createElement("style");if(Kt)document.head.append(qm);var hl=()=>be?.themes??[{name:"light",scheme:"light"},{name:"dark",scheme:"dark"}];function Pa(e){let t=hl();if(e=t.find((o)=>o.name===e)?.name??t.find((o)=>o.scheme===e)?.name,!e)return;if(document.documentElement.dataset.theme=e,si)si.value=e;if(Kt&&be)pt()}function ka(e){if(!be?.brands?.some((t)=>t.name===e))return;if(document.documentElement.dataset.brand=e,Ko)Ko.value=e;if(Kt&&be)pt()}function ve(e,t){let o=document.createElement(e);return o.textContent=t,o}function X_(e){let t=ve("li","");t.dataset.token=e.name;let o=getComputedStyle(document.documentElement).getPropertyValue(e.name).trim(),r=ve("details","");r.className="token-source";let n=ve("summary","");n.title=`${e.name}: ${o||"Conditional or unset"}. Click to inspect source definitions.`;let i=ve("code",e.name);i.className="token-name";let a=ve("span",o||"Conditional or unset");n.append(i,a);let u=ve("dl","");if(u.append(ve("dt","Computed in preview"),ve("dd",o||"Conditional or unset")),e.meaning)u.append(ve("dt","Meaning"),ve("dd",e.meaning));for(let d of e.definitions)u.append(ve("dt",[d.scope,d.theme].filter(Boolean).join(" · ")),ve("dd",`${d.value} · ${d.file}:${d.line}`));return r.append(n,u),t.append(r),t}function pt(){qm.textContent=be.css;let e=be.tokens.filter((t)=>`${t.name} ${t.type??""}`.toLowerCase().includes(Mm.toLowerCase()));document.getElementById("ads-token-list").replaceChildren(...e.slice(ze,ze+Go).map(X_)),document.querySelector("footer").hidden=e.length<=Go,document.getElementById("ads-token-count").textContent=e.length?`${ze+1}–${Math.min(ze+Go,e.length)} of ${e.length}`:"No matching tokens",document.getElementById("ads-token-prev").disabled=ze===0,document.getElementById("ads-token-next").disabled=ze+Go>=e.length,ht.textContent=`${e.length} matching definitions · ${be.diagnostics.length} diagnostics`}if(Kt){if(ue.ontoolinput=()=>{if(ze=0,be)pt()},be=JSON.parse(document.getElementById("ads-token-seed").textContent),si.replaceChildren(...hl().map((e)=>Object.assign(document.createElement("option"),{value:e.name,textContent:e.name}))),Pa(hl()[0].name),be.brands?.length)Ko.replaceChildren(...be.brands.map((e)=>Object.assign(document.createElement("option"),{value:e.name,textContent:e.name}))),Ko.hidden=!1,ka(be.brands[0].name),Ko.addEventListener("change",()=>ka(Ko.value));document.getElementById("ads-token-search").addEventListener("input",(e)=>{Mm=e.target.value,ze=0,pt()}),si.addEventListener("change",()=>Pa(si.value)),document.getElementById("ads-token-prev").addEventListener("click",()=>{ze=Math.max(0,ze-Go),pt()}),document.getElementById("ads-token-next").addEventListener("click",()=>{ze+=Go,pt()}),document.getElementById("ads-token-refresh").addEventListener("click",async()=>{try{let e=await ue.readServerResource({uri:"ads://project/tokens"});be=JSON.parse(e.contents.find((t)=>("text"in t)).text),ze=0,pt()}catch(e){ht.textContent=`Refresh failed: ${e.message}`}})}var Wt,ml,Nm=!1,ni=0;async function Am(e){if(ml=e,!Nm||!Ea)return;let t=e?.structuredContent?.draftScope;e=e?.structuredContent?.previewResult??e;let o=e?.structuredContent?.scenario?.resourceUri;if(!o||!o.startsWith("ui://ads/previews/"))return;let r=++ni;if(Kt)Kt.hidden=!0,ht=document.getElementById("ads-scenario-status");Ea.hidden=!1;try{if(!ue.getHostCapabilities()?.serverResources)throw Error("This Apps host does not forward server resources. Use the project showcase URL from the tool result.");let i=(await ue.readServerResource({uri:t?t+encodeURIComponent(o):o})).contents.find((p)=>p.mimeType==="text/html;profile=mcp-app"&&typeof p.text==="string");if(!i)throw Error("Scenario HTML is unavailable.");if(r!==ni)return;if(Wt)await Wt.close(),Wt=void 0;let a=document.createElement("iframe");a.title=e.structuredContent.scenario.title,a.setAttribute("sandbox","allow-scripts allow-forms"),Ea.replaceChildren(a);let u=new pl(null,{name:"ADS scenario host",version:"1.0.0"},{serverResources:{},serverTools:{}},{hostContext:ue.getHostContext()});Wt=u,u.onreadresource=(p)=>ue.readServerResource({...p,uri:t?t+encodeURIComponent(p.uri):p.uri}),u.oncalltool=(p)=>ue.callServerTool(p),u.onsizechange=({height:p})=>{if(p)a.height=String(Math.min(1e4,Math.max(120,p)))},u.oninitialized=async()=>{if(await u.sendToolInput({arguments:{}}),await u.sendToolResult(e),r===ni)window.parent.postMessage({type:"ads-preview-ready"},"*")},await u.connect(new dl(a.contentWindow,a.contentWindow));let d="default-src 'none'; script-src 'unsafe-inline' 'wasm-unsafe-eval' blob:; style-src 'unsafe-inline'; img-src data: blob:; font-src data:; worker-src blob: data:; connect-src blob:; base-uri about:; object-src 'none'; form-action 'none'";a.srcdoc=Om(i.text,d),ht.hidden=!0}catch(n){if(r===ni)ht.hidden=!1,ht.textContent=n.message,window.parent.postMessage({type:"ads-preview-ready"},"*")}}if(Ea)ue.ontoolresult=(e)=>{Am(e)},ue.onteardown=async()=>{++ni;let e=Wt;Wt=void 0;try{await e?.teardownResource({},{timeout:500})}catch{}return await e?.close(),{}};ue.onhostcontextchanged=(e)=>{Pa(e.adsTheme??e.theme),ka(e.adsBrand),Wt?.setHostContext(e)};try{if(await ue.connect(),Nm=!0,ml)Am(ml);if(Pa(ue.getHostContext()?.adsTheme??ue.getHostContext()?.theme),ka(ue.getHostContext()?.adsBrand),Kt)document.getElementById("ads-token-refresh").disabled=!ue.getHostCapabilities()?.serverResources,pt()}catch{if(ht)ht.textContent="Apps bridge unavailable. Samples remain usable; inspect project data through ADS tools/resources."}
|
|
146
|
+
- "app": Tool callable by the app from this server only`),csp:bn().optional(),permissions:bn().optional()}),Mx=l({mimeTypes:m(a()).optional().describe('Array of supported MIME types for UI resources.\nMust include `"text/html;profile=mcp-app"` for MCP Apps support.')}),Vy=l({method:u("ui/download-file"),params:l({contents:m(v([Tt,Pt])).describe("Resource contents to download — embedded (inline data) or linked (host fetches). Uses standard MCP resource types.")})}),Jy=l({method:u("ui/message"),params:l({role:u("user").describe('Message role, currently only "user" is supported.'),content:m(Ae).describe("Message content blocks (text, image, etc.).")})}),qx=l({method:u("ui/notifications/sandbox-resource-ready"),params:l({html:a().describe("HTML content to load into the inner iframe."),sandbox:a().optional().describe("Optional override for the inner iframe's sandbox attribute."),csp:ql.optional().describe("CSP configuration from resource metadata."),permissions:Nl.optional().describe("Sandbox permissions from resource metadata.")})}),Nx=l({method:u("ui/notifications/tool-result"),params:ft.describe("Standard MCP tool execution result.")}),Tf=l({toolInfo:l({id:qe.optional().describe("JSON-RPC id of the tools/call request."),tool:mt.describe("Tool definition including name, inputSchema, etc.")}).optional().describe("Metadata of the tool call that instantiated this App."),theme:Py.optional().describe("Current color theme preference."),styles:jy.optional().describe("Style configuration for theming the app."),displayMode:_i.optional().describe("How the UI is currently displayed."),availableDisplayModes:m(_i).optional().describe("Display modes the host supports."),containerDimensions:v([l({height:_().describe("Fixed container height in pixels.")}),l({maxHeight:v([_(),Bo()]).optional().describe("Maximum container height in pixels.")})]).and(v([l({width:_().describe("Fixed container width in pixels.")}),l({maxWidth:v([_(),Bo()]).optional().describe("Maximum container width in pixels.")})])).optional().describe(`Container dimensions. Represents the dimensions of the iframe or other
|
|
147
|
+
container holding the app. Specify either width or maxWidth, and either height or maxHeight.`),locale:a().optional().describe("User's language and region preference in BCP 47 format."),timeZone:a().optional().describe("User's timezone in IANA format."),userAgent:a().optional().describe("Host application identifier."),platform:v([u("web"),u("desktop"),u("mobile")]).optional().describe("Platform type for responsive design decisions."),deviceCapabilities:l({touch:z().optional().describe("Whether the device supports touch input."),hover:z().optional().describe("Whether the device supports hover interactions.")}).optional().describe("Device input capabilities."),safeAreaInsets:l({top:_().describe("Top safe area inset in pixels."),right:_().describe("Right safe area inset in pixels."),bottom:_().describe("Bottom safe area inset in pixels."),left:_().describe("Left safe area inset in pixels.")}).optional().describe("Mobile safe area boundaries in pixels.")}).passthrough(),Ax=l({method:u("ui/notifications/host-context-changed"),params:Tf.describe("Partial context update containing only changed fields.")}),By=l({method:u("ui/update-model-context"),params:l({content:m(Ae).optional().describe("Context content blocks (text, image, etc.)."),structuredContent:y(a(),P().describe("Structured content for machine-readable context data.")).optional().describe("Structured content for machine-readable context data.")})}),Wy=l({method:u("ui/initialize"),params:l({appInfo:Ne.describe("App identification (name and version)."),appCapabilities:Dy.describe("Features and capabilities this app provides."),protocolVersion:a().describe("Protocol version this app supports.")})}),Ky=l({protocolVersion:a().describe('Negotiated protocol version string (e.g., "2025-11-21").'),hostInfo:Ne.describe("Host application identification and version."),hostCapabilities:Zy.describe("Features and capabilities provided by the host."),hostContext:Tf.describe("Rich context about the host environment.")}).passthrough();class Al{eventTarget;eventSource;messageListener;constructor(e=window.parent,t){this.eventTarget=e,this.eventSource=t,this.messageListener=(o)=>{if(t&&o.source!==this.eventSource){console.debug("Ignoring message from unknown source",o);return}let r=zt.safeParse(o.data);if(r.success)console.debug("Parsed message",r.data),this.onmessage?.(r.data);else if(o.data?.jsonrpc!=="2.0")console.debug("Ignoring non-JSON-RPC message",r.error.message,o);else console.error("Failed to parse message",r.error.message,o),this.onerror?.(Error("Invalid JSON-RPC message received: "+r.error.message))}}async start(){window.addEventListener("message",this.messageListener)}async send(e,t){if(e.method!==Ty)console.debug("Sending message",e);this.eventTarget.postMessage(e,"*")}async close(){window.removeEventListener("message",this.messageListener),this.onclose?.()}onclose;onerror;onmessage;sessionId;setProtocolVersion}var Gy=[Ef];class jl extends To{_client;_hostInfo;_hostCapabilities;_appCapabilities;_hostContext={};_appInfo;_initializedReceived=!1;_registeredEvents=new Set;_events=new wf;_methods=new xf;setRequestHandler=(...e)=>{let[t,...o]=yf("request",e)??e;this._methods.claim(t,"setRequestHandler"),super.setRequestHandler.call(this,t,...o)};setNotificationHandler=(...e)=>{let[t,...o]=yf("notification",e)??e;this._methods.claim(t,"setNotificationHandler"),super.setNotificationHandler.call(this,t,...o)};removeRequestHandler=(e)=>{this._methods.release(e),super.removeRequestHandler(e)};removeNotificationHandler=(e)=>{this._methods.release(e),super.removeNotificationHandler(e)};replaceRequestHandler=(e,...t)=>{this._methods.replace(e),super.setRequestHandler.call(this,e,...t)};_wrapHandler(e,t){let o=super._wrapHandler(e,t);if(e==="ui/initialize"||e==="ping")return o;return async(r,n)=>{if(!this._initializedReceived)console.warn(`[ext-apps] AppBridge received '${e}' before ui/notifications/initialized. The View is calling host methods before completing the handshake; it should await app.connect() first.`);return o(r,n)}}eventSchemas={sizechange:Ny,sandboxready:qy,initialized:Hy,requestteardown:Uy,loggingmessage:Ro};setEventHandler(e,t){this._ensureEventSlot(e),this._events.setHandler(e,t)}getEventHandler(e){return this._events.getHandler(e)}addEventListener(e,t){this._ensureEventSlot(e),this._events.addEventListener(e,t)}removeEventListener(e,t){this._events.removeEventListener(e,t)}_ensureEventSlot(e){if(this._registeredEvents.has(e))return;let t=this.eventSchemas[e];if(!t)throw Error(`Unknown event: ${String(e)}`);let o=(r)=>{if(e==="initialized")this._initializedReceived=!0;this._events.dispatch(e,r)};if(e==="loggingmessage")this.setNotificationHandler("notifications/message",(r)=>{o(r.params)});else this.setNotificationHandler(t.shape.method.value,{params:t.shape.params},(r)=>o(r));this._registeredEvents.add(e)}warnIfRequestHandlerReplaced(e,t,o){if(t&&o)console.warn(`[MCP Apps] ${e} handler replaced. Previous handler will no longer be called.`)}constructor(e,t,o,r){super(r);this._client=e,this._hostInfo=t,this._hostCapabilities=o,this._methods.replace("notifications/cancelled"),this._methods.replace("notifications/progress"),this._ensureEventSlot("initialized"),this._hostContext=r?.hostContext||{},this.replaceRequestHandler("ui/initialize",{params:Wy.shape.params,result:Ky},(n)=>this._onAppsInitialize(n)),this.replaceRequestHandler("ping",(n,i)=>(this.onping?.(n.params,i),{})),this.replaceRequestHandler("ui/request-display-mode",{params:zf.shape.params,result:Rf},()=>({mode:this._hostContext.displayMode??"inline"}))}buildContext(e){return e}assertCapabilityForMethod(e){}assertRequestHandlerCapability(e){}assertNotificationCapability(e){}getAppCapabilities(){return this._appCapabilities}getAppVersion(){return this._appInfo}onping;get onsizechange(){return this.getEventHandler("sizechange")}set onsizechange(e){this.setEventHandler("sizechange",e)}get onsandboxready(){return this.getEventHandler("sandboxready")}set onsandboxready(e){this.setEventHandler("sandboxready",e)}get oninitialized(){return this.getEventHandler("initialized")}set oninitialized(e){this.setEventHandler("initialized",e)}_onmessage;get onmessage(){return this._onmessage}set onmessage(e){this.warnIfRequestHandlerReplaced("onmessage",this._onmessage,e),this._onmessage=e,this.replaceRequestHandler("ui/message",{params:Jy.shape.params,result:My},async(t,o)=>{if(!this._onmessage)throw Error("No onmessage handler set");return this._onmessage(t,o)})}_onopenlink;get onopenlink(){return this._onopenlink}set onopenlink(e){this.warnIfRequestHandlerReplaced("onopenlink",this._onopenlink,e),this._onopenlink=e,this.replaceRequestHandler("ui/open-link",{params:Cy.shape.params,result:Iy},async(t,o)=>{if(!this._onopenlink)throw Error("No onopenlink handler set");return this._onopenlink(t,o)})}_ondownloadfile;get ondownloadfile(){return this._ondownloadfile}set ondownloadfile(e){this.warnIfRequestHandlerReplaced("ondownloadfile",this._ondownloadfile,e),this._ondownloadfile=e,this.replaceRequestHandler("ui/download-file",{params:Vy.shape.params,result:Oy},async(t,o)=>{if(!this._ondownloadfile)throw Error("No ondownloadfile handler set");return this._ondownloadfile(t,o)})}get onrequestteardown(){return this.getEventHandler("requestteardown")}set onrequestteardown(e){this.setEventHandler("requestteardown",e)}_onrequestdisplaymode;get onrequestdisplaymode(){return this._onrequestdisplaymode}set onrequestdisplaymode(e){this.warnIfRequestHandlerReplaced("onrequestdisplaymode",this._onrequestdisplaymode,e),this._onrequestdisplaymode=e,this.replaceRequestHandler("ui/request-display-mode",{params:zf.shape.params,result:Rf},async(t,o)=>{if(!this._onrequestdisplaymode)throw Error("No onrequestdisplaymode handler set");return this._onrequestdisplaymode(t,o)})}get onloggingmessage(){return this.getEventHandler("loggingmessage")}set onloggingmessage(e){this.setEventHandler("loggingmessage",e)}_onupdatemodelcontext;get onupdatemodelcontext(){return this._onupdatemodelcontext}set onupdatemodelcontext(e){this.warnIfRequestHandlerReplaced("onupdatemodelcontext",this._onupdatemodelcontext,e),this._onupdatemodelcontext=e,this.replaceRequestHandler("ui/update-model-context",{params:By.shape.params,result:pt},async(t,o)=>{if(!this._onupdatemodelcontext)throw Error("No onupdatemodelcontext handler set");return this._onupdatemodelcontext(t,o)})}_oncalltool;get oncalltool(){return this._oncalltool}set oncalltool(e){this.warnIfRequestHandlerReplaced("oncalltool",this._oncalltool,e),this._oncalltool=e,this.replaceRequestHandler("tools/call",async(t,o)=>{if(!this._oncalltool)throw Error("No oncalltool handler set");return this._oncalltool(t.params,o)})}_oncreatesamplingmessage;get oncreatesamplingmessage(){return this._oncreatesamplingmessage}set oncreatesamplingmessage(e){this.warnIfRequestHandlerReplaced("oncreatesamplingmessage",this._oncreatesamplingmessage,e),this._oncreatesamplingmessage=e,this.replaceRequestHandler("sampling/createMessage",async(t,o)=>{if(!this._oncreatesamplingmessage)throw Error("No oncreatesamplingmessage handler set");return this._oncreatesamplingmessage(t.params,o)})}sendToolListChanged(e={}){return this.notification({method:"notifications/tools/list_changed",params:e})}_onlistresources;get onlistresources(){return this._onlistresources}set onlistresources(e){this.warnIfRequestHandlerReplaced("onlistresources",this._onlistresources,e),this._onlistresources=e,this.replaceRequestHandler("resources/list",async(t,o)=>{if(!this._onlistresources)throw Error("No onlistresources handler set");return this._onlistresources(t.params,o)})}_onlistresourcetemplates;get onlistresourcetemplates(){return this._onlistresourcetemplates}set onlistresourcetemplates(e){this.warnIfRequestHandlerReplaced("onlistresourcetemplates",this._onlistresourcetemplates,e),this._onlistresourcetemplates=e,this.replaceRequestHandler("resources/templates/list",async(t,o)=>{if(!this._onlistresourcetemplates)throw Error("No onlistresourcetemplates handler set");return this._onlistresourcetemplates(t.params,o)})}_onreadresource;get onreadresource(){return this._onreadresource}set onreadresource(e){this.warnIfRequestHandlerReplaced("onreadresource",this._onreadresource,e),this._onreadresource=e,this.replaceRequestHandler("resources/read",async(t,o)=>{if(!this._onreadresource)throw Error("No onreadresource handler set");return this._onreadresource(t.params,o)})}sendResourceListChanged(e={}){return this.notification({method:"notifications/resources/list_changed",params:e})}_onlistprompts;get onlistprompts(){return this._onlistprompts}set onlistprompts(e){this.warnIfRequestHandlerReplaced("onlistprompts",this._onlistprompts,e),this._onlistprompts=e,this.replaceRequestHandler("prompts/list",async(t,o)=>{if(!this._onlistprompts)throw Error("No onlistprompts handler set");return this._onlistprompts(t.params,o)})}sendPromptListChanged(e={}){return this.notification({method:"notifications/prompts/list_changed",params:e})}getCapabilities(){return this._hostCapabilities}async _onAppsInitialize(e){let t=e.protocolVersion;if(this._appInfo!==void 0)console.warn("[ext-apps] AppBridge received a second ui/initialize. The View may be double-mounting (e.g. React StrictMode in dev) without closing the previous App instance. Responding normally; the latest appInfo/appCapabilities replace the previous values.");return this._appCapabilities=e.appCapabilities,this._appInfo=e.appInfo,{protocolVersion:Gy.includes(t)?t:Ef,hostCapabilities:this.getCapabilities(),hostInfo:this._hostInfo,hostContext:this._hostContext}}setHostContext(e){let t={},o=!1;for(let r of Object.keys(e)){let n=this._hostContext[r],i=e[r];if(Yy(n,i))continue;t[r]=i,o=!0}if(o)this._hostContext=e,this.sendHostContextChange(t)}sendHostContextChange(e){return this.notification({method:"ui/notifications/host-context-changed",params:e})}sendToolInput(e){return this.notification({method:"ui/notifications/tool-input",params:e})}sendToolInputPartial(e){return this.notification({method:"ui/notifications/tool-input-partial",params:e})}sendToolResult(e){return this.notification({method:"ui/notifications/tool-result",params:e})}sendToolCancelled(e){return this.notification({method:"ui/notifications/tool-cancelled",params:e})}sendSandboxResourceReady(e){return this.notification({method:"ui/notifications/sandbox-resource-ready",params:e})}teardownResource(e,t){return this.request({method:"ui/resource-teardown",params:e},Ly,t)}sendResourceTeardown=this.teardownResource;callTool(e,t){return this.request({method:"tools/call",params:e},t)}listTools(e,t){return this.request({method:"tools/list",params:e},t)}async connect(e){if(this.transport)throw Error("AppBridge is already connected. Call close() before connecting again.");if(this._initializedReceived=!1,this._client){let t=this._client.getServerCapabilities();if(!t)throw Error("Client server capabilities not available");if(t.tools){if(this.oncalltool=async(o,r)=>this._client.request({method:"tools/call",params:o},{signal:r.mcpReq.signal}),t.tools.listChanged)this._client.setNotificationHandler("notifications/tools/list_changed",(o)=>this.sendToolListChanged(o.params))}if(t.resources){if(this.onlistresources=async(o,r)=>this._client.request({method:"resources/list",params:o},{signal:r.mcpReq.signal}),this.onlistresourcetemplates=async(o,r)=>this._client.request({method:"resources/templates/list",params:o},{signal:r.mcpReq.signal}),this.onreadresource=async(o,r)=>this._client.request({method:"resources/read",params:o},{signal:r.mcpReq.signal}),t.resources.listChanged)this._client.setNotificationHandler("notifications/resources/list_changed",(o)=>this.sendResourceListChanged(o.params))}if(t.prompts){if(this.onlistprompts=async(o,r)=>this._client.request({method:"prompts/list",params:o},{signal:r.mcpReq.signal}),t.prompts.listChanged)this._client.setNotificationHandler("notifications/prompts/list_changed",(o)=>this.sendPromptListChanged(o.params))}}return super.connect(e)}}function Yy(e,t){return JSON.stringify(e)===JSON.stringify(t)}function Pf(e,t){let o=new DOMParser().parseFromString(e,"text/html"),r=o.createElement("meta");if(r.httpEquiv="Content-Security-Policy",r.content=t,o.head.prepend(r),!o.querySelector("base[href]")){let n=o.querySelector("base")??o.createElement("base");n.setAttribute("href","about:srcdoc"),r.after(n)}return"<!doctype html>"+o.documentElement.outerHTML}var we=new Ja({name:"ADS preview",version:"1.0.0"},{},{autoResize:!0}),$o=document.getElementById("ads-token-root"),Kt=document.getElementById("ads-widget-status"),yi=document.getElementById("ads-token-theme"),Pr=document.getElementById("ads-token-brand"),Ba=document.getElementById("ads-scenario-root"),je,Be=0,kf="",kr=30,$f=document.createElement("style");if($o)document.head.append($f);var Ll=()=>je?.themes??[{name:"light",scheme:"light"},{name:"dark",scheme:"dark"}];function Wa(e){let t=Ll();if(e=t.find((o)=>o.name===e)?.name??t.find((o)=>o.scheme===e)?.name,!e)return;if(document.documentElement.dataset.theme=e,yi)yi.value=e;if($o&&je)Wt()}function Ka(e){if(!je?.brands?.some((t)=>t.name===e))return;if(document.documentElement.dataset.brand=e,Pr)Pr.value=e;if($o&&je)Wt()}function Je(e,t){let o=document.createElement(e);return o.textContent=t,o}function Qy(e){let t=Je("li","");t.dataset.token=e.name;let o=getComputedStyle(document.documentElement).getPropertyValue(e.name).trim(),r=Je("details","");r.className="token-source";let n=Je("summary","");n.title=`${e.name}: ${o||"Conditional or unset"}. Click to inspect source definitions.`;let i=Je("code",e.name);i.className="token-name";let s=Je("span",o||"Conditional or unset");n.append(i,s);let c=Je("dl","");if(c.append(Je("dt","Computed in preview"),Je("dd",o||"Conditional or unset")),e.meaning)c.append(Je("dt","Meaning"),Je("dd",e.meaning));for(let d of e.definitions)c.append(Je("dt",[d.scope,d.theme].filter(Boolean).join(" · ")),Je("dd",`${d.value} · ${d.file}:${d.line}`));return r.append(n,c),t.append(r),t}function Wt(){$f.textContent=je.css;let e=je.tokens.filter((t)=>`${t.name} ${t.type??""}`.toLowerCase().includes(kf.toLowerCase()));document.getElementById("ads-token-list").replaceChildren(...e.slice(Be,Be+kr).map(Qy)),document.querySelector("footer").hidden=e.length<=kr,document.getElementById("ads-token-count").textContent=e.length?`${Be+1}–${Math.min(Be+kr,e.length)} of ${e.length}`:"No matching tokens",document.getElementById("ads-token-prev").disabled=Be===0,document.getElementById("ads-token-next").disabled=Be+kr>=e.length,Kt.textContent=`${e.length} matching definitions · ${je.diagnostics.length} diagnostics`}if($o){if(we.ontoolinput=()=>{if(Be=0,je)Wt()},je=JSON.parse(document.getElementById("ads-token-seed").textContent),yi.replaceChildren(...Ll().map((e)=>Object.assign(document.createElement("option"),{value:e.name,textContent:e.name}))),Wa(Ll()[0].name),je.brands?.length)Pr.replaceChildren(...je.brands.map((e)=>Object.assign(document.createElement("option"),{value:e.name,textContent:e.name}))),Pr.hidden=!1,Ka(je.brands[0].name),Pr.addEventListener("change",()=>Ka(Pr.value));document.getElementById("ads-token-search").addEventListener("input",(e)=>{kf=e.target.value,Be=0,Wt()}),yi.addEventListener("change",()=>Wa(yi.value)),document.getElementById("ads-token-prev").addEventListener("click",()=>{Be=Math.max(0,Be-kr),Wt()}),document.getElementById("ads-token-next").addEventListener("click",()=>{Be+=kr,Wt()}),document.getElementById("ads-token-refresh").addEventListener("click",async()=>{try{let e=await we.readServerResource({uri:"ads://project/tokens"});je=JSON.parse(e.contents.find((t)=>("text"in t)).text),Be=0,Wt()}catch(e){Kt.textContent=`Refresh failed: ${e.message}`}})}var ko,Ul,Cf=!1,bi=0;async function If(e){if(Ul=e,!Cf||!Ba)return;let t=e?.structuredContent?.draftScope;e=e?.structuredContent?.previewResult??e;let o=e?.structuredContent?.scenario?.resourceUri;if(!o||!o.startsWith("ui://ads/previews/"))return;let r=++bi;if($o)$o.hidden=!0,Kt=document.getElementById("ads-scenario-status");Ba.hidden=!1;try{if(!we.getHostCapabilities()?.serverResources)throw Error("This Apps host does not forward server resources. Use the project showcase URL from the tool result.");let i=(await we.readServerResource({uri:t?t+encodeURIComponent(o):o})).contents.find((p)=>p.mimeType==="text/html;profile=mcp-app"&&typeof p.text==="string");if(!i)throw Error("Scenario HTML is unavailable.");if(r!==bi)return;if(ko)await ko.close(),ko=void 0;let s=document.createElement("iframe");s.title=e.structuredContent.scenario.title,s.setAttribute("sandbox","allow-scripts allow-forms"),Ba.replaceChildren(s);let c=new jl(null,{name:"ADS scenario host",version:"1.0.0"},{serverResources:{},serverTools:{}},{hostContext:we.getHostContext()});ko=c,c.onreadresource=(p)=>we.readServerResource({...p,uri:t?t+encodeURIComponent(p.uri):p.uri}),c.oncalltool=(p)=>we.callServerTool(p),c.onsizechange=({height:p})=>{if(p)s.height=String(Math.min(1e4,Math.max(120,p)))},c.oninitialized=async()=>{if(await c.sendToolInput({arguments:{}}),await c.sendToolResult(e),r===bi)window.parent.postMessage({type:"ads-preview-ready"},"*")},await c.connect(new Al(s.contentWindow,s.contentWindow));let d="default-src 'none'; script-src 'unsafe-inline' 'wasm-unsafe-eval' blob:; style-src 'unsafe-inline'; img-src data: blob:; font-src data:; worker-src blob: data:; connect-src blob:; base-uri about:; object-src 'none'; form-action 'none'";s.srcdoc=Pf(i.text,d),Kt.hidden=!0}catch(n){if(r===bi)Kt.hidden=!1,Kt.textContent=n.message,window.parent.postMessage({type:"ads-preview-ready"},"*")}}if(Ba)we.ontoolresult=(e)=>{If(e)},we.onteardown=async()=>{++bi;let e=ko;ko=void 0;try{await e?.teardownResource({},{timeout:500})}catch{}return await e?.close(),{}};we.onhostcontextchanged=(e)=>{Wa(e.adsTheme??e.theme),Ka(e.adsBrand),ko?.setHostContext(e)};try{if(await we.connect(),Cf=!0,Ul)If(Ul);if(Wa(we.getHostContext()?.adsTheme??we.getHostContext()?.theme),Ka(we.getHostContext()?.adsBrand),$o)document.getElementById("ads-token-refresh").disabled=!we.getHostCapabilities()?.serverResources,Wt()}catch{if(Kt)Kt.textContent="Apps bridge unavailable. Samples remain usable; inspect project data through ADS tools/resources."}
|