@reqvire-org/ads 0.4.4 → 0.4.6

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.
Files changed (53) hide show
  1. package/README.md +11 -8
  2. package/dist/capture.mjs +1 -1
  3. package/dist/cli.mjs +1 -1
  4. package/dist/input-scope.mjs +57 -0
  5. package/dist/mcp/apps.mjs +7 -1
  6. package/dist/mcp/build-status.mjs +12 -3
  7. package/dist/mcp/drafts.mjs +7 -0
  8. package/dist/mcp/mutations.mjs +1 -1
  9. package/dist/mcp/preview-http.bundle.js +7 -0
  10. package/dist/mcp/preview-http.mjs +148 -0
  11. package/dist/mcp/preview-watch.mjs +14 -3
  12. package/dist/mcp/preview-widget.bundle.js +20 -20
  13. package/dist/mcp/resource-loader.js +1 -1
  14. package/dist/mcp/sandbox-host.mjs +6 -1
  15. package/dist/mcp/server.mjs +49 -9
  16. package/dist/mcp/showcase-host.mjs +56 -5
  17. package/dist/mcp/showcase-http.mjs +66 -0
  18. package/dist/preview-inputs.mjs +7 -2
  19. package/dist/scenario-registry.mjs +2 -2
  20. package/dist/scenarios-compiler.mjs +19 -1
  21. package/dist/showcase/client.bundle.js +54 -54
  22. package/dist/showcase/comparison.js +15 -12
  23. package/dist/showcase/connection.js +10 -0
  24. package/dist/showcase/http-client.bundle.js +9 -0
  25. package/dist/showcase/http-connection.js +86 -0
  26. package/dist/showcase/http-preview.js +81 -0
  27. package/dist/showcase-http-routes.mjs +31 -0
  28. package/dist/skills/README.md +2 -2
  29. package/dist/skills/ads-designer/references/captures.md +1 -1
  30. package/dist/skills/ads-designer/references/runtimes.md +18 -2
  31. package/dist/skills/ads-designer/references/workflows.md +16 -0
  32. package/dist/skills/ads-import/references/captures.md +1 -1
  33. package/dist/skills/ads-import/references/runtimes.md +18 -2
  34. package/dist/skills/ads-import/references/workflows.md +16 -0
  35. package/dist/skills/ads-migrate/SKILL.md +1 -0
  36. package/dist/skills/ads-migrate/references/0.4.3-to-0.4.4.md +9 -0
  37. package/dist/skills/ads-migrate/references/0.4.4-to-0.4.5.md +72 -0
  38. package/dist/skills/ads-port/references/captures.md +1 -1
  39. package/dist/skills/ads-port/references/runtimes.md +18 -2
  40. package/dist/skills/ads-port/references/workflows.md +16 -0
  41. package/dist/stage-timing.cjs +3 -2
  42. package/dist/validation-inputs.mjs +21 -3
  43. package/dist/verification/browser.mjs +2 -2
  44. package/docs/ADS.md +9 -7
  45. package/docs/ARCHITECTURE.md +56 -42
  46. package/docs/CHANGELOG.md +45 -25
  47. package/docs/GUIDE.md +15 -8
  48. package/docs/HTTP-SHOWCASE-POC.md +397 -0
  49. package/docs/MCP.md +63 -9
  50. package/docs/benchmarks/http-showcase-optimized.json +1879 -0
  51. package/docs/benchmarks/http-showcase-profile.json +308 -0
  52. package/docs/benchmarks/http-showcase.json +3069 -0
  53. package/package.json +1 -1
@@ -1,6 +1,6 @@
1
- var{create:_f,defineProperty:zi,getOwnPropertyDescriptor:bf,getOwnPropertyNames:yf,getPrototypeOf:vf}=Object,zf=Object.prototype.hasOwnProperty,Rl=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),xl=(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},wf=(e,t,o,r)=>{if(t&&typeof t==="object"||typeof t==="function"){for(var n=yf(t),i=0,s=n.length,a;i<s;i++)if(a=n[i],!zf.call(e,a)&&a!==o)zi(e,a,{get:((l)=>t[l]).bind(null,a),enumerable:!(r=bf(t,a))||r.enumerable})}return e},El=(e,t,o)=>(o=e!=null?_f(vf(e)):{},wf(t||!e||!e.__esModule?zi(o,"default",{value:e,enumerable:!0}):o,e));var Rf=new Set(["https://json-schema.org/draft/2020-12/schema","http://json-schema.org/draft/2020-12/schema"]),Pl=new Set(["https://json-schema.org/draft/2019-09/schema","http://json-schema.org/draft/2019-09/schema"]),xf=new Set(["https://json-schema.org/draft-07/schema","http://json-schema.org/draft-07/schema"]),Ef=new Set(["https://json-schema.org/draft-06/schema","http://json-schema.org/draft-06/schema"]);function Tl(e){return typeof e==="string"&&Pl.has(e.replace(/#$/,""))}function kl(e,t){if(!("$schema"in e)||typeof e.$schema!=="string")return"2020-12";let o=e.$schema.replace(/#$/,"");if(Rf.has(o))return"2020-12";if(Pl.has(o))return"2019-09";if(xf.has(o)||Ef.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 $l,Oa=Object.freeze({status:"aborted"});function v(e,t,o){function r(a,l){if(!a._zod)Object.defineProperty(a,"_zod",{value:{def:l,constr:s,traits:new Set},enumerable:!1});if(a._zod.traits.has(e))return;a._zod.traits.add(e),t(a,l);let u=s.prototype,m=Object.keys(u);for(let h=0;h<m.length;h++){let f=m[h];if(!(f in a))a[f]=u[f].bind(a)}}let n=o?.Parent??Object;class i extends n{}Object.defineProperty(i,"name",{value:e});function s(a){var l;let u=o?.Parent?new i:this;r(u,a),(l=u._zod).deferred??(l.deferred=[]);for(let m of u._zod.deferred)m();return u}return Object.defineProperty(s,"init",{value:r}),Object.defineProperty(s,Symbol.hasInstance,{value:(a)=>{if(o?.Parent&&a instanceof o.Parent)return!0;return a?._zod?.traits?.has(e)}}),Object.defineProperty(s,"name",{value:e}),s}var Pf=Symbol("zod_brand");class _t extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class Hr extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`);this.name="ZodEncodeError"}}($l=globalThis).__zod_globalConfig??($l.__zod_globalConfig={});var Io=globalThis.__zod_globalConfig;function We(e){if(e)Object.assign(Io,e);return Io}function Ri(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 Aa(e,t="|"){return e.map((o)=>La(o)).join(t)}function Fr(e,t){if(typeof t==="bigint")return t.toString();return t}function Jr(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 Ei(e){let t=e.startsWith("^")?1:0,o=e.endsWith("$")?e.length-1:e.length;return e.slice(t,o)}function Il(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 Cl=Symbol("evaluating");function me(e,t,o){let r=void 0;Object.defineProperty(e,t,{get(){if(r===Cl)return;if(r===void 0)r=Cl,r=o();return r},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function Qt(e,t,o){Object.defineProperty(e,t,{value:o,writable:!0,enumerable:!0,configurable:!0})}function Ct(...e){let t={};for(let o of e){let r=Object.getOwnPropertyDescriptors(o);Object.assign(t,r)}return Object.defineProperties({},t)}function Na(e){return JSON.stringify(e)}function Ol(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}var qa="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function Oo(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}var Ml=Jr(()=>{if(Io.jitless)return!1;if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{return new Function(""),!0}catch(e){return!1}});function Xt(e){if(Oo(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(Oo(o)===!1)return!1;if(Object.prototype.hasOwnProperty.call(o,"isPrototypeOf")===!1)return!1;return!0}function ja(e){if(Xt(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 Al=new Set(["string","number","symbol"]);function It(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function at(e,t,o){let r=new e._zod.constr(t??e._zod.def);if(!t||o?.parent)r._zod.parent=e;return r}function H(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 La(e){if(typeof e==="bigint")return e.toString()+"n";if(typeof e==="string")return`"${e}"`;return`${e}`}function Nl(e){return Object.keys(e).filter((t)=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}var ql={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 Tf(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=Ct(e._zod.def,{get shape(){let s={};for(let a in t){if(!(a in o.shape))throw Error(`Unrecognized key: "${a}"`);if(!t[a])continue;s[a]=o.shape[a]}return Qt(this,"shape",s),s},checks:[]});return at(e,i)}function kf(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=Ct(e._zod.def,{get shape(){let s={...e._zod.def.shape};for(let a in t){if(!(a in o.shape))throw Error(`Unrecognized key: "${a}"`);if(!t[a])continue;delete s[a]}return Qt(this,"shape",s),s},checks:[]});return at(e,i)}function $f(e,t){if(!Xt(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=Ct(e._zod.def,{get shape(){let i={...e._zod.def.shape,...t};return Qt(this,"shape",i),i}});return at(e,n)}function Cf(e,t){if(!Xt(t))throw Error("Invalid input to safeExtend: expected a plain object");let o=Ct(e._zod.def,{get shape(){let r={...e._zod.def.shape,...t};return Qt(this,"shape",r),r}});return at(e,o)}function If(e,t){if(e._zod.def.checks?.length)throw Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");let o=Ct(e._zod.def,{get shape(){let r={...e._zod.def.shape,...t._zod.def.shape};return Qt(this,"shape",r),r},get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return at(e,o)}function Of(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=Ct(t._zod.def,{get shape(){let a=t._zod.def.shape,l={...a};if(o)for(let u in o){if(!(u in a))throw Error(`Unrecognized key: "${u}"`);if(!o[u])continue;l[u]=e?new e({type:"optional",innerType:a[u]}):a[u]}else for(let u in a)l[u]=e?new e({type:"optional",innerType:a[u]}):a[u];return Qt(this,"shape",l),l},checks:[]});return at(t,s)}function Mf(e,t,o){let r=Ct(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 Qt(this,"shape",i),i}});return at(t,r)}function eo(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 jl(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 Ot(e,t){return t.map((o)=>{var r;return(r=o).path??(r.path=[]),o.path.unshift(e),o})}function wi(e){return typeof e==="string"?e:e?.message}function ct(e,t,o){let r=e.message?e.message:wi(e.inst?._zod.def?.error?.(e))??wi(t?.error?.(e))??wi(o.customError?.(e))??wi(o.localeError?.(e))??"Invalid input",{inst:n,continue:i,input:s,...a}=e;if(a.path??(a.path=[]),a.message=r,t?.reportInput)a.input=s;return a}function Pi(e){if(Array.isArray(e))return"array";if(typeof e==="string")return"string";return"unknown"}function Ll(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 to(...e){let[t,o,r]=e;if(typeof t==="string")return{message:t,code:"custom",input:o,inst:r};return{...t}}var Ul=(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,Fr,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},Ti=v("$ZodError",Ul),Ua=v("$ZodError",Ul,{Parent:Error});function Za(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 Da(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((a)=>r({issues:a},[...i,...s.path]));else if(s.code==="invalid_key")r({issues:s.issues},[...i,...s.path]);else if(s.code==="invalid_element")r({issues:s.issues},[...i,...s.path]);else{let a=[...i,...s.path];if(a.length===0)o._errors.push(t(s));else{let l=o,u=0;while(u<a.length){let m=a[u];if(u!==a.length-1)l[m]=l[m]||{_errors:[]};else l[m]=l[m]||{_errors:[]},l[m]._errors.push(t(s));l=l[m],u++}}}};return r(e),o}var ki=(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 _t;if(s.issues.length){let a=new(n?.Err??e)(s.issues.map((l)=>ct(l,i,We())));throw qa(a,n?.callee),a}return s.value};var $i=(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 a=new(n?.Err??e)(s.issues.map((l)=>ct(l,i,We())));throw qa(a,n?.callee),a}return s.value};var Br=(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 _t;return i.issues.length?{success:!1,error:new(e??Ti)(i.issues.map((s)=>ct(s,n,We())))}:{success:!0,data:i.value}},Zl=Br(Ua),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((s)=>ct(s,n,We())))}:{success:!0,data:i.value}},Dl=Gr(Ua),Vl=(e)=>(t,o,r)=>{let n=r?{...r,direction:"backward"}:{direction:"backward"};return ki(e)(t,o,n)};var Hl=(e)=>(t,o,r)=>ki(e)(t,o,r);var Fl=(e)=>async(t,o,r)=>{let n=r?{...r,direction:"backward"}:{direction:"backward"};return $i(e)(t,o,n)};var Jl=(e)=>async(t,o,r)=>$i(e)(t,o,r);var Bl=(e)=>(t,o,r)=>{let n=r?{...r,direction:"backward"}:{direction:"backward"};return Br(e)(t,o,n)};var Gl=(e)=>(t,o,r)=>Br(e)(t,o,r);var Wl=(e)=>async(t,o,r)=>{let n=r?{...r,direction:"backward"}:{direction:"backward"};return Gr(e)(t,o,n)};var Kl=(e)=>async(t,o,r)=>Gr(e)(t,o,r);var Yl=/^[cC][0-9a-z]{6,}$/,Ql=/^[0-9a-z]+$/,Xl=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,eu=/^[0-9a-vA-V]{20}$/,tu=/^[A-Za-z0-9]{27}$/,ou=/^[a-zA-Z0-9_-]{21}$/,ru=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;var nu=/^([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})$/,Va=(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 su=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;var Nf="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function iu(){return new RegExp(Nf,"u")}var au=/^(?:(?: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])$/,cu=/^(([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 lu=/^((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])$/,uu=/^(([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])$/,du=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Ha=/^[A-Za-z0-9_-]*$/;var pu=/^https?$/,hu=/^\+[1-9]\d{6,14}$/,mu="(?:(?:\\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])))",fu=new RegExp(`^${mu}$`);function gu(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 Su(e){return new RegExp(`^${gu(e)}$`)}function _u(e){let t=gu({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(`^${mu}T(?:${r})$`)}var bu=(e)=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)};var yu=/^-?\d+$/,Fa=/^-?\d+(?:\.\d+)?$/,vu=/^(?:true|false)$/i,zu=/^null$/i;var wu=/^undefined$/i;var Ru=/^[^A-Z]*$/,xu=/^[^a-z]*$/;var De=v("$ZodCheck",(e,t)=>{var o;e._zod??(e._zod={}),e._zod.def=t,(o=e._zod).onattach??(o.onattach=[])}),Eu={number:"number",bigint:"bigint",object:"date"},Ja=v("$ZodCheckLessThan",(e,t)=>{De.init(e,t);let o=Eu[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})}}),Ba=v("$ZodCheckGreaterThan",(e,t)=>{De.init(e,t);let o=Eu[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})}}),Pu=v("$ZodCheckMultipleOf",(e,t)=>{De.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):Il(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})}}),Tu=v("$ZodCheckNumberFormat",(e,t)=>{De.init(e,t),t.format=t.format||"float64";let o=t.format?.includes("int"),r=o?"int":"number",[n,i]=ql[t.format];e._zod.onattach.push((s)=>{let a=s._zod.bag;if(a.format=t.format,a.minimum=n,a.maximum=i,o)a.pattern=yu}),e._zod.check=(s)=>{let a=s.value;if(o){if(!Number.isInteger(a)){s.issues.push({expected:r,format:t.format,code:"invalid_type",continue:!1,input:a,inst:e});return}if(!Number.isSafeInteger(a)){if(a>0)s.issues.push({input:a,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:a,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(a<n)s.issues.push({origin:"number",input:a,code:"too_small",minimum:n,inclusive:!0,inst:e,continue:!t.abort});if(a>i)s.issues.push({origin:"number",input:a,code:"too_big",maximum:i,inclusive:!0,inst:e,continue:!t.abort})}});var ku=v("$ZodCheckMaxLength",(e,t)=>{var o;De.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 s=Pi(n);r.issues.push({origin:s,code:"too_big",maximum:t.maximum,inclusive:!0,input:n,inst:e,continue:!t.abort})}}),$u=v("$ZodCheckMinLength",(e,t)=>{var o;De.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 s=Pi(n);r.issues.push({origin:s,code:"too_small",minimum:t.minimum,inclusive:!0,input:n,inst:e,continue:!t.abort})}}),Cu=v("$ZodCheckLengthEquals",(e,t)=>{var o;De.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 s=Pi(n),a=i>t.length;r.issues.push({origin:s,...a?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:r.value,inst:e,continue:!t.abort})}}),Kr=v("$ZodCheckStringFormat",(e,t)=>{var o,r;if(De.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=()=>{})}),Iu=v("$ZodCheckRegex",(e,t)=>{Kr.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})}}),Ou=v("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=Ru),Kr.init(e,t)}),Mu=v("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=xu),Kr.init(e,t)}),Au=v("$ZodCheckIncludes",(e,t)=>{De.init(e,t);let o=It(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})}}),Nu=v("$ZodCheckStartsWith",(e,t)=>{De.init(e,t);let o=new RegExp(`^${It(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})}}),qu=v("$ZodCheckEndsWith",(e,t)=>{De.init(e,t);let o=new RegExp(`.*${It(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 ju=v("$ZodCheckOverwrite",(e,t)=>{De.init(e,t),e._zod.check=(o)=>{o.value=t.tx(o.value)}});class Ga{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:_f,defineProperty:zi,getOwnPropertyDescriptor:bf,getOwnPropertyNames:yf,getPrototypeOf:vf}=Object,zf=Object.prototype.hasOwnProperty,Rl=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),xl=(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},wf=(e,t,o,r)=>{if(t&&typeof t==="object"||typeof t==="function"){for(var n=yf(t),i=0,s=n.length,a;i<s;i++)if(a=n[i],!zf.call(e,a)&&a!==o)zi(e,a,{get:((l)=>t[l]).bind(null,a),enumerable:!(r=bf(t,a))||r.enumerable})}return e},El=(e,t,o)=>(o=e!=null?_f(vf(e)):{},wf(t||!e||!e.__esModule?zi(o,"default",{value:e,enumerable:!0}):o,e));var Rf=new Set(["https://json-schema.org/draft/2020-12/schema","http://json-schema.org/draft/2020-12/schema"]),Pl=new Set(["https://json-schema.org/draft/2019-09/schema","http://json-schema.org/draft/2019-09/schema"]),xf=new Set(["https://json-schema.org/draft-07/schema","http://json-schema.org/draft-07/schema"]),Ef=new Set(["https://json-schema.org/draft-06/schema","http://json-schema.org/draft-06/schema"]);function Tl(e){return typeof e==="string"&&Pl.has(e.replace(/#$/,""))}function kl(e,t){if(!("$schema"in e)||typeof e.$schema!=="string")return"2020-12";let o=e.$schema.replace(/#$/,"");if(Rf.has(o))return"2020-12";if(Pl.has(o))return"2019-09";if(xf.has(o)||Ef.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 $l,Oa=Object.freeze({status:"aborted"});function v(e,t,o){function r(a,l){if(!a._zod)Object.defineProperty(a,"_zod",{value:{def:l,constr:s,traits:new Set},enumerable:!1});if(a._zod.traits.has(e))return;a._zod.traits.add(e),t(a,l);let u=s.prototype,m=Object.keys(u);for(let h=0;h<m.length;h++){let f=m[h];if(!(f in a))a[f]=u[f].bind(a)}}let n=o?.Parent??Object;class i extends n{}Object.defineProperty(i,"name",{value:e});function s(a){var l;let u=o?.Parent?new i:this;r(u,a),(l=u._zod).deferred??(l.deferred=[]);for(let m of u._zod.deferred)m();return u}return Object.defineProperty(s,"init",{value:r}),Object.defineProperty(s,Symbol.hasInstance,{value:(a)=>{if(o?.Parent&&a instanceof o.Parent)return!0;return a?._zod?.traits?.has(e)}}),Object.defineProperty(s,"name",{value:e}),s}var Pf=Symbol("zod_brand");class _t extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class Hr extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`);this.name="ZodEncodeError"}}($l=globalThis).__zod_globalConfig??($l.__zod_globalConfig={});var Io=globalThis.__zod_globalConfig;function Ye(e){if(e)Object.assign(Io,e);return Io}function Ri(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 Aa(e,t="|"){return e.map((o)=>La(o)).join(t)}function Fr(e,t){if(typeof t==="bigint")return t.toString();return t}function Jr(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 Ei(e){let t=e.startsWith("^")?1:0,o=e.endsWith("$")?e.length-1:e.length;return e.slice(t,o)}function Il(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 Cl=Symbol("evaluating");function fe(e,t,o){let r=void 0;Object.defineProperty(e,t,{get(){if(r===Cl)return;if(r===void 0)r=Cl,r=o();return r},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function Qt(e,t,o){Object.defineProperty(e,t,{value:o,writable:!0,enumerable:!0,configurable:!0})}function Ct(...e){let t={};for(let o of e){let r=Object.getOwnPropertyDescriptors(o);Object.assign(t,r)}return Object.defineProperties({},t)}function Na(e){return JSON.stringify(e)}function Ol(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}var qa="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function Oo(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}var Ml=Jr(()=>{if(Io.jitless)return!1;if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{return new Function(""),!0}catch(e){return!1}});function Xt(e){if(Oo(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(Oo(o)===!1)return!1;if(Object.prototype.hasOwnProperty.call(o,"isPrototypeOf")===!1)return!1;return!0}function ja(e){if(Xt(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 Al=new Set(["string","number","symbol"]);function It(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function at(e,t,o){let r=new e._zod.constr(t??e._zod.def);if(!t||o?.parent)r._zod.parent=e;return r}function H(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 La(e){if(typeof e==="bigint")return e.toString()+"n";if(typeof e==="string")return`"${e}"`;return`${e}`}function Nl(e){return Object.keys(e).filter((t)=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}var ql={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 Tf(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=Ct(e._zod.def,{get shape(){let s={};for(let a in t){if(!(a in o.shape))throw Error(`Unrecognized key: "${a}"`);if(!t[a])continue;s[a]=o.shape[a]}return Qt(this,"shape",s),s},checks:[]});return at(e,i)}function kf(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=Ct(e._zod.def,{get shape(){let s={...e._zod.def.shape};for(let a in t){if(!(a in o.shape))throw Error(`Unrecognized key: "${a}"`);if(!t[a])continue;delete s[a]}return Qt(this,"shape",s),s},checks:[]});return at(e,i)}function $f(e,t){if(!Xt(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=Ct(e._zod.def,{get shape(){let i={...e._zod.def.shape,...t};return Qt(this,"shape",i),i}});return at(e,n)}function Cf(e,t){if(!Xt(t))throw Error("Invalid input to safeExtend: expected a plain object");let o=Ct(e._zod.def,{get shape(){let r={...e._zod.def.shape,...t};return Qt(this,"shape",r),r}});return at(e,o)}function If(e,t){if(e._zod.def.checks?.length)throw Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");let o=Ct(e._zod.def,{get shape(){let r={...e._zod.def.shape,...t._zod.def.shape};return Qt(this,"shape",r),r},get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return at(e,o)}function Of(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=Ct(t._zod.def,{get shape(){let a=t._zod.def.shape,l={...a};if(o)for(let u in o){if(!(u in a))throw Error(`Unrecognized key: "${u}"`);if(!o[u])continue;l[u]=e?new e({type:"optional",innerType:a[u]}):a[u]}else for(let u in a)l[u]=e?new e({type:"optional",innerType:a[u]}):a[u];return Qt(this,"shape",l),l},checks:[]});return at(t,s)}function Mf(e,t,o){let r=Ct(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 Qt(this,"shape",i),i}});return at(t,r)}function eo(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 jl(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 Ot(e,t){return t.map((o)=>{var r;return(r=o).path??(r.path=[]),o.path.unshift(e),o})}function wi(e){return typeof e==="string"?e:e?.message}function ct(e,t,o){let r=e.message?e.message:wi(e.inst?._zod.def?.error?.(e))??wi(t?.error?.(e))??wi(o.customError?.(e))??wi(o.localeError?.(e))??"Invalid input",{inst:n,continue:i,input:s,...a}=e;if(a.path??(a.path=[]),a.message=r,t?.reportInput)a.input=s;return a}function Pi(e){if(Array.isArray(e))return"array";if(typeof e==="string")return"string";return"unknown"}function Ll(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 to(...e){let[t,o,r]=e;if(typeof t==="string")return{message:t,code:"custom",input:o,inst:r};return{...t}}var Ul=(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,Fr,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},Ti=v("$ZodError",Ul),Ua=v("$ZodError",Ul,{Parent:Error});function Za(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 Da(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((a)=>r({issues:a},[...i,...s.path]));else if(s.code==="invalid_key")r({issues:s.issues},[...i,...s.path]);else if(s.code==="invalid_element")r({issues:s.issues},[...i,...s.path]);else{let a=[...i,...s.path];if(a.length===0)o._errors.push(t(s));else{let l=o,u=0;while(u<a.length){let m=a[u];if(u!==a.length-1)l[m]=l[m]||{_errors:[]};else l[m]=l[m]||{_errors:[]},l[m]._errors.push(t(s));l=l[m],u++}}}};return r(e),o}var ki=(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 _t;if(s.issues.length){let a=new(n?.Err??e)(s.issues.map((l)=>ct(l,i,Ye())));throw qa(a,n?.callee),a}return s.value};var $i=(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 a=new(n?.Err??e)(s.issues.map((l)=>ct(l,i,Ye())));throw qa(a,n?.callee),a}return s.value};var Br=(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 _t;return i.issues.length?{success:!1,error:new(e??Ti)(i.issues.map((s)=>ct(s,n,Ye())))}:{success:!0,data:i.value}},Zl=Br(Ua),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((s)=>ct(s,n,Ye())))}:{success:!0,data:i.value}},Dl=Gr(Ua),Vl=(e)=>(t,o,r)=>{let n=r?{...r,direction:"backward"}:{direction:"backward"};return ki(e)(t,o,n)};var Hl=(e)=>(t,o,r)=>ki(e)(t,o,r);var Fl=(e)=>async(t,o,r)=>{let n=r?{...r,direction:"backward"}:{direction:"backward"};return $i(e)(t,o,n)};var Jl=(e)=>async(t,o,r)=>$i(e)(t,o,r);var Bl=(e)=>(t,o,r)=>{let n=r?{...r,direction:"backward"}:{direction:"backward"};return Br(e)(t,o,n)};var Gl=(e)=>(t,o,r)=>Br(e)(t,o,r);var Wl=(e)=>async(t,o,r)=>{let n=r?{...r,direction:"backward"}:{direction:"backward"};return Gr(e)(t,o,n)};var Kl=(e)=>async(t,o,r)=>Gr(e)(t,o,r);var Yl=/^[cC][0-9a-z]{6,}$/,Ql=/^[0-9a-z]+$/,Xl=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,eu=/^[0-9a-vA-V]{20}$/,tu=/^[A-Za-z0-9]{27}$/,ou=/^[a-zA-Z0-9_-]{21}$/,ru=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;var nu=/^([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})$/,Va=(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 su=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;var Nf="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function iu(){return new RegExp(Nf,"u")}var au=/^(?:(?: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])$/,cu=/^(([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 lu=/^((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])$/,uu=/^(([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])$/,du=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Ha=/^[A-Za-z0-9_-]*$/;var pu=/^https?$/,hu=/^\+[1-9]\d{6,14}$/,mu="(?:(?:\\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])))",fu=new RegExp(`^${mu}$`);function gu(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 Su(e){return new RegExp(`^${gu(e)}$`)}function _u(e){let t=gu({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(`^${mu}T(?:${r})$`)}var bu=(e)=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)};var yu=/^-?\d+$/,Fa=/^-?\d+(?:\.\d+)?$/,vu=/^(?:true|false)$/i,zu=/^null$/i;var wu=/^undefined$/i;var Ru=/^[^A-Z]*$/,xu=/^[^a-z]*$/;var He=v("$ZodCheck",(e,t)=>{var o;e._zod??(e._zod={}),e._zod.def=t,(o=e._zod).onattach??(o.onattach=[])}),Eu={number:"number",bigint:"bigint",object:"date"},Ja=v("$ZodCheckLessThan",(e,t)=>{He.init(e,t);let o=Eu[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})}}),Ba=v("$ZodCheckGreaterThan",(e,t)=>{He.init(e,t);let o=Eu[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})}}),Pu=v("$ZodCheckMultipleOf",(e,t)=>{He.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):Il(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})}}),Tu=v("$ZodCheckNumberFormat",(e,t)=>{He.init(e,t),t.format=t.format||"float64";let o=t.format?.includes("int"),r=o?"int":"number",[n,i]=ql[t.format];e._zod.onattach.push((s)=>{let a=s._zod.bag;if(a.format=t.format,a.minimum=n,a.maximum=i,o)a.pattern=yu}),e._zod.check=(s)=>{let a=s.value;if(o){if(!Number.isInteger(a)){s.issues.push({expected:r,format:t.format,code:"invalid_type",continue:!1,input:a,inst:e});return}if(!Number.isSafeInteger(a)){if(a>0)s.issues.push({input:a,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:a,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(a<n)s.issues.push({origin:"number",input:a,code:"too_small",minimum:n,inclusive:!0,inst:e,continue:!t.abort});if(a>i)s.issues.push({origin:"number",input:a,code:"too_big",maximum:i,inclusive:!0,inst:e,continue:!t.abort})}});var ku=v("$ZodCheckMaxLength",(e,t)=>{var o;He.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 s=Pi(n);r.issues.push({origin:s,code:"too_big",maximum:t.maximum,inclusive:!0,input:n,inst:e,continue:!t.abort})}}),$u=v("$ZodCheckMinLength",(e,t)=>{var o;He.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 s=Pi(n);r.issues.push({origin:s,code:"too_small",minimum:t.minimum,inclusive:!0,input:n,inst:e,continue:!t.abort})}}),Cu=v("$ZodCheckLengthEquals",(e,t)=>{var o;He.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 s=Pi(n),a=i>t.length;r.issues.push({origin:s,...a?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:r.value,inst:e,continue:!t.abort})}}),Kr=v("$ZodCheckStringFormat",(e,t)=>{var o,r;if(He.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=()=>{})}),Iu=v("$ZodCheckRegex",(e,t)=>{Kr.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})}}),Ou=v("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=Ru),Kr.init(e,t)}),Mu=v("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=xu),Kr.init(e,t)}),Au=v("$ZodCheckIncludes",(e,t)=>{He.init(e,t);let o=It(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})}}),Nu=v("$ZodCheckStartsWith",(e,t)=>{He.init(e,t);let o=new RegExp(`^${It(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})}}),qu=v("$ZodCheckEndsWith",(e,t)=>{He.init(e,t);let o=new RegExp(`.*${It(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 ju=v("$ZodCheckOverwrite",(e,t)=>{He.init(e,t),e._zod.check=(o)=>{o.value=t.tx(o.value)}});class Ga{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 Uu={major:4,minor:4,patch:3};var we=v("$ZodType",(e,t)=>{var o;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Uu;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,a,l)=>{let u=eo(s),m;for(let h of a){if(h._zod.def.when){if(jl(s))continue;if(!h._zod.def.when(s))continue}else if(u)continue;let f=s.issues.length,g=h._zod.check(s);if(g instanceof Promise&&l?.async===!1)throw new _t;if(m||g instanceof Promise)m=(m??Promise.resolve()).then(async()=>{if(await g,s.issues.length===f)return;if(!u)u=eo(s,f)});else{if(s.issues.length===f)continue;if(!u)u=eo(s,f)}}if(m)return m.then(()=>s);return s},i=(s,a,l)=>{if(eo(s))return s.aborted=!0,s;let u=n(a,r,l);if(u instanceof Promise){if(l.async===!1)throw new _t;return u.then((m)=>e._zod.parse(m,l))}return e._zod.parse(u,l)};e._zod.run=(s,a)=>{if(a.skipChecks)return e._zod.parse(s,a);if(a.direction==="backward"){let u=e._zod.parse({value:s.value,issues:[]},{...a,skipChecks:!0});if(u instanceof Promise)return u.then((m)=>i(m,s,a));return i(u,s,a)}let l=e._zod.parse(s,a);if(l instanceof Promise){if(a.async===!1)throw new _t;return l.then((u)=>n(u,r,a))}return n(l,r,a)}}me(e,"~standard",()=>({validate:(n)=>{try{let i=Zl(e,n);return i.success?{value:i.data}:{issues:i.error?.issues}}catch(i){return Dl(e,n).then((s)=>s.success?{value:s.data}:{issues:s.error?.issues})}},vendor:"zod",version:1}))}),Oi=v("$ZodString",(e,t)=>{we.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??bu(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}}),Te=v("$ZodStringFormat",(e,t)=>{Kr.init(e,t),Oi.init(e,t)}),Wu=v("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=nu),Te.init(e,t)}),Ku=v("$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=Va(r))}else t.pattern??(t.pattern=Va());Te.init(e,t)}),Yu=v("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=su),Te.init(e,t)}),Qu=v("$ZodURL",(e,t)=>{Te.init(e,t),e._zod.check=(o)=>{try{let r=o.value.trim();if(!t.normalize&&t.protocol?.source===pu.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})}}}),Xu=v("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=iu()),Te.init(e,t)}),ed=v("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=ou),Te.init(e,t)}),td=v("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=Yl),Te.init(e,t)}),od=v("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=Ql),Te.init(e,t)}),rd=v("$ZodULID",(e,t)=>{t.pattern??(t.pattern=Xl),Te.init(e,t)}),nd=v("$ZodXID",(e,t)=>{t.pattern??(t.pattern=eu),Te.init(e,t)}),sd=v("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=tu),Te.init(e,t)}),id=v("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=_u(t)),Te.init(e,t)}),ad=v("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=fu),Te.init(e,t)}),cd=v("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=Su(t)),Te.init(e,t)}),ld=v("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=ru),Te.init(e,t)}),ud=v("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=au),Te.init(e,t),e._zod.bag.format="ipv4"}),dd=v("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=cu),Te.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 pd=v("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=lu),Te.init(e,t)}),hd=v("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=uu),Te.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 md(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 fd=v("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=du),Te.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=(o)=>{if(md(o.value))return;o.issues.push({code:"invalid_format",format:"base64",input:o.value,inst:e,continue:!t.abort})}});function qf(e){if(!Ha.test(e))return!1;let t=e.replace(/[-_]/g,(r)=>r==="-"?"+":"/"),o=t.padEnd(Math.ceil(t.length/4)*4,"=");return md(o)}var gd=v("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=Ha),Te.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=(o)=>{if(qf(o.value))return;o.issues.push({code:"invalid_format",format:"base64url",input:o.value,inst:e,continue:!t.abort})}}),Sd=v("$ZodE164",(e,t)=>{t.pattern??(t.pattern=hu),Te.init(e,t)});function jf(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 _d=v("$ZodJWT",(e,t)=>{Te.init(e,t),e._zod.check=(o)=>{if(jf(o.value,t.alg))return;o.issues.push({code:"invalid_format",format:"jwt",input:o.value,inst:e,continue:!t.abort})}});var Ka=v("$ZodNumber",(e,t)=>{we.init(e,t),e._zod.pattern=e._zod.bag.pattern??Fa,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}}),bd=v("$ZodNumberFormat",(e,t)=>{Tu.init(e,t),Ka.init(e,t)}),yd=v("$ZodBoolean",(e,t)=>{we.init(e,t),e._zod.pattern=vu,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 vd=v("$ZodUndefined",(e,t)=>{we.init(e,t),e._zod.pattern=wu,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}}),zd=v("$ZodNull",(e,t)=>{we.init(e,t),e._zod.pattern=zu,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}}),wd=v("$ZodAny",(e,t)=>{we.init(e,t),e._zod.parse=(o)=>o}),Rd=v("$ZodUnknown",(e,t)=>{we.init(e,t),e._zod.parse=(o)=>o}),xd=v("$ZodNever",(e,t)=>{we.init(e,t),e._zod.parse=(o,r)=>(o.issues.push({expected:"never",code:"invalid_type",input:o.value,inst:e}),o)});function Zu(e,t,o){if(e.issues.length)t.issues.push(...Ot(o,e.issues));t.value[o]=e.value}var Ed=v("$ZodArray",(e,t)=>{we.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 a=n[s],l=t.element._zod.run({value:a,issues:[]},r);if(l instanceof Promise)i.push(l.then((u)=>Zu(u,o,s)));else Zu(l,o,s)}if(i.length)return Promise.all(i).then(()=>o);return o}});function Ii(e,t,o,r,n,i){let s=o in r;if(e.issues.length){if(n&&i&&!s)return;t.issues.push(...Ot(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 Pd(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=Nl(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(o)}}function Td(e,t,o,r,n,i){let s=[],a=n.keySet,l=n.catchall._zod,u=l.def.type,m=l.optin==="optional",h=l.optout==="optional";for(let f in t){if(f==="__proto__")continue;if(a.has(f))continue;if(u==="never"){s.push(f);continue}let g=l.run({value:t[f],issues:[]},r);if(g instanceof Promise)e.push(g.then((_)=>Ii(_,o,f,t,m,h)));else Ii(g,o,f,t,m,h)}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 Lf=v("$ZodObject",(e,t)=>{if(we.init(e,t),!Object.getOwnPropertyDescriptor(t,"shape")?.get){let a=t.shape;Object.defineProperty(t,"shape",{get:()=>{let l={...a};return Object.defineProperty(t,"shape",{value:l}),l}})}let r=Jr(()=>Pd(t));me(e._zod,"propValues",()=>{let a=t.shape,l={};for(let u in a){let m=a[u]._zod;if(m.values){l[u]??(l[u]=new Set);for(let h of m.values)l[u].add(h)}}return l});let n=Oo,i=t.catchall,s;e._zod.parse=(a,l)=>{s??(s=r.value);let u=a.value;if(!n(u))return a.issues.push({expected:"object",code:"invalid_type",input:u,inst:e}),a;a.value={};let m=[],h=s.shape;for(let f of s.keys){let g=h[f],_=g._zod.optin==="optional",z=g._zod.optout==="optional",b=g._zod.run({value:u[f],issues:[]},l);if(b instanceof Promise)m.push(b.then((w)=>Ii(w,a,f,u,_,z)));else Ii(b,a,f,u,_,z)}if(!i)return m.length?Promise.all(m).then(()=>a):a;return Td(m,u,a,l,r.value,e)}}),kd=v("$ZodObjectJIT",(e,t)=>{Lf.init(e,t);let o=e._zod.parse,r=Jr(()=>Pd(t)),n=(f)=>{let g=new Ga(["shape","payload","ctx"]),_=r.value,z=(x)=>{let T=Na(x);return`shape[${T}]._zod.run({ value: input[${T}], issues: [] }, ctx)`};g.write("const input = payload.value;");let b=Object.create(null),w=0;for(let x of _.keys)b[x]=`key_${w++}`;g.write("const newResult = {};");for(let x of _.keys){let T=b[x],q=Na(x),B=f[x],ee=B?._zod?.optin==="optional",re=B?._zod?.optout==="optional";if(g.write(`const ${T} = ${z(x)};`),ee&&re)g.write(`
3
+ `))}}var Uu={major:4,minor:4,patch:3};var ye=v("$ZodType",(e,t)=>{var o;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Uu;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,a,l)=>{let u=eo(s),m;for(let h of a){if(h._zod.def.when){if(jl(s))continue;if(!h._zod.def.when(s))continue}else if(u)continue;let f=s.issues.length,g=h._zod.check(s);if(g instanceof Promise&&l?.async===!1)throw new _t;if(m||g instanceof Promise)m=(m??Promise.resolve()).then(async()=>{if(await g,s.issues.length===f)return;if(!u)u=eo(s,f)});else{if(s.issues.length===f)continue;if(!u)u=eo(s,f)}}if(m)return m.then(()=>s);return s},i=(s,a,l)=>{if(eo(s))return s.aborted=!0,s;let u=n(a,r,l);if(u instanceof Promise){if(l.async===!1)throw new _t;return u.then((m)=>e._zod.parse(m,l))}return e._zod.parse(u,l)};e._zod.run=(s,a)=>{if(a.skipChecks)return e._zod.parse(s,a);if(a.direction==="backward"){let u=e._zod.parse({value:s.value,issues:[]},{...a,skipChecks:!0});if(u instanceof Promise)return u.then((m)=>i(m,s,a));return i(u,s,a)}let l=e._zod.parse(s,a);if(l instanceof Promise){if(a.async===!1)throw new _t;return l.then((u)=>n(u,r,a))}return n(l,r,a)}}fe(e,"~standard",()=>({validate:(n)=>{try{let i=Zl(e,n);return i.success?{value:i.data}:{issues:i.error?.issues}}catch(i){return Dl(e,n).then((s)=>s.success?{value:s.data}:{issues:s.error?.issues})}},vendor:"zod",version:1}))}),Oi=v("$ZodString",(e,t)=>{ye.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??bu(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}}),Ce=v("$ZodStringFormat",(e,t)=>{Kr.init(e,t),Oi.init(e,t)}),Wu=v("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=nu),Ce.init(e,t)}),Ku=v("$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=Va(r))}else t.pattern??(t.pattern=Va());Ce.init(e,t)}),Yu=v("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=su),Ce.init(e,t)}),Qu=v("$ZodURL",(e,t)=>{Ce.init(e,t),e._zod.check=(o)=>{try{let r=o.value.trim();if(!t.normalize&&t.protocol?.source===pu.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})}}}),Xu=v("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=iu()),Ce.init(e,t)}),ed=v("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=ou),Ce.init(e,t)}),td=v("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=Yl),Ce.init(e,t)}),od=v("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=Ql),Ce.init(e,t)}),rd=v("$ZodULID",(e,t)=>{t.pattern??(t.pattern=Xl),Ce.init(e,t)}),nd=v("$ZodXID",(e,t)=>{t.pattern??(t.pattern=eu),Ce.init(e,t)}),sd=v("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=tu),Ce.init(e,t)}),id=v("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=_u(t)),Ce.init(e,t)}),ad=v("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=fu),Ce.init(e,t)}),cd=v("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=Su(t)),Ce.init(e,t)}),ld=v("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=ru),Ce.init(e,t)}),ud=v("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=au),Ce.init(e,t),e._zod.bag.format="ipv4"}),dd=v("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=cu),Ce.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 pd=v("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=lu),Ce.init(e,t)}),hd=v("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=uu),Ce.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 md(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 fd=v("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=du),Ce.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=(o)=>{if(md(o.value))return;o.issues.push({code:"invalid_format",format:"base64",input:o.value,inst:e,continue:!t.abort})}});function qf(e){if(!Ha.test(e))return!1;let t=e.replace(/[-_]/g,(r)=>r==="-"?"+":"/"),o=t.padEnd(Math.ceil(t.length/4)*4,"=");return md(o)}var gd=v("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=Ha),Ce.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=(o)=>{if(qf(o.value))return;o.issues.push({code:"invalid_format",format:"base64url",input:o.value,inst:e,continue:!t.abort})}}),Sd=v("$ZodE164",(e,t)=>{t.pattern??(t.pattern=hu),Ce.init(e,t)});function jf(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 _d=v("$ZodJWT",(e,t)=>{Ce.init(e,t),e._zod.check=(o)=>{if(jf(o.value,t.alg))return;o.issues.push({code:"invalid_format",format:"jwt",input:o.value,inst:e,continue:!t.abort})}});var Ka=v("$ZodNumber",(e,t)=>{ye.init(e,t),e._zod.pattern=e._zod.bag.pattern??Fa,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}}),bd=v("$ZodNumberFormat",(e,t)=>{Tu.init(e,t),Ka.init(e,t)}),yd=v("$ZodBoolean",(e,t)=>{ye.init(e,t),e._zod.pattern=vu,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 vd=v("$ZodUndefined",(e,t)=>{ye.init(e,t),e._zod.pattern=wu,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}}),zd=v("$ZodNull",(e,t)=>{ye.init(e,t),e._zod.pattern=zu,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}}),wd=v("$ZodAny",(e,t)=>{ye.init(e,t),e._zod.parse=(o)=>o}),Rd=v("$ZodUnknown",(e,t)=>{ye.init(e,t),e._zod.parse=(o)=>o}),xd=v("$ZodNever",(e,t)=>{ye.init(e,t),e._zod.parse=(o,r)=>(o.issues.push({expected:"never",code:"invalid_type",input:o.value,inst:e}),o)});function Zu(e,t,o){if(e.issues.length)t.issues.push(...Ot(o,e.issues));t.value[o]=e.value}var Ed=v("$ZodArray",(e,t)=>{ye.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 a=n[s],l=t.element._zod.run({value:a,issues:[]},r);if(l instanceof Promise)i.push(l.then((u)=>Zu(u,o,s)));else Zu(l,o,s)}if(i.length)return Promise.all(i).then(()=>o);return o}});function Ii(e,t,o,r,n,i){let s=o in r;if(e.issues.length){if(n&&i&&!s)return;t.issues.push(...Ot(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 Pd(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=Nl(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(o)}}function Td(e,t,o,r,n,i){let s=[],a=n.keySet,l=n.catchall._zod,u=l.def.type,m=l.optin==="optional",h=l.optout==="optional";for(let f in t){if(f==="__proto__")continue;if(a.has(f))continue;if(u==="never"){s.push(f);continue}let g=l.run({value:t[f],issues:[]},r);if(g instanceof Promise)e.push(g.then((y)=>Ii(y,o,f,t,m,h)));else Ii(g,o,f,t,m,h)}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 Lf=v("$ZodObject",(e,t)=>{if(ye.init(e,t),!Object.getOwnPropertyDescriptor(t,"shape")?.get){let a=t.shape;Object.defineProperty(t,"shape",{get:()=>{let l={...a};return Object.defineProperty(t,"shape",{value:l}),l}})}let r=Jr(()=>Pd(t));fe(e._zod,"propValues",()=>{let a=t.shape,l={};for(let u in a){let m=a[u]._zod;if(m.values){l[u]??(l[u]=new Set);for(let h of m.values)l[u].add(h)}}return l});let n=Oo,i=t.catchall,s;e._zod.parse=(a,l)=>{s??(s=r.value);let u=a.value;if(!n(u))return a.issues.push({expected:"object",code:"invalid_type",input:u,inst:e}),a;a.value={};let m=[],h=s.shape;for(let f of s.keys){let g=h[f],y=g._zod.optin==="optional",z=g._zod.optout==="optional",_=g._zod.run({value:u[f],issues:[]},l);if(_ instanceof Promise)m.push(_.then((x)=>Ii(x,a,f,u,y,z)));else Ii(_,a,f,u,y,z)}if(!i)return m.length?Promise.all(m).then(()=>a):a;return Td(m,u,a,l,r.value,e)}}),kd=v("$ZodObjectJIT",(e,t)=>{Lf.init(e,t);let o=e._zod.parse,r=Jr(()=>Pd(t)),n=(f)=>{let g=new Ga(["shape","payload","ctx"]),y=r.value,z=(R)=>{let T=Na(R);return`shape[${T}]._zod.run({ value: input[${T}], issues: [] }, ctx)`};g.write("const input = payload.value;");let _=Object.create(null),x=0;for(let R of y.keys)_[R]=`key_${x++}`;g.write("const newResult = {};");for(let R of y.keys){let T=_[R],q=Na(R),J=f[R],ae=J?._zod?.optin==="optional",re=J?._zod?.optout==="optional";if(g.write(`const ${T} = ${z(R)};`),ae&&re)g.write(`
4
4
  if (${T}.issues.length) {
5
5
  if (${q} in input) {
6
6
  payload.issues = payload.issues.concat(${T}.issues.map(iss => ({
@@ -18,7 +18,7 @@ var{create:_f,defineProperty:zi,getOwnPropertyDescriptor:bf,getOwnPropertyNames:
18
18
  newResult[${q}] = ${T}.value;
19
19
  }
20
20
 
21
- `);else if(!ee)g.write(`
21
+ `);else if(!ae)g.write(`
22
22
  const ${T}_present = ${q} in input;
23
23
  if (${T}.issues.length) {
24
24
  payload.issues = payload.issues.concat(${T}.issues.map(iss => ({
@@ -59,22 +59,22 @@ var{create:_f,defineProperty:zi,getOwnPropertyDescriptor:bf,getOwnPropertyNames:
59
59
  newResult[${q}] = ${T}.value;
60
60
  }
61
61
 
62
- `)}g.write("payload.value = newResult;"),g.write("return payload;");let C=g.compile();return(x,T)=>C(f,x,T)},i,s=Oo,a=!Io.jitless,u=a&&Ml.value,m=t.catchall,h;e._zod.parse=(f,g)=>{h??(h=r.value);let _=f.value;if(!s(_))return f.issues.push({expected:"object",code:"invalid_type",input:_,inst:e}),f;if(a&&u&&g?.async===!1&&g.jitless!==!0){if(!i)i=n(t.shape);if(f=i(f,g),!m)return f;return Td([],_,f,g,h,e)}return o(f,g)}});function Du(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)=>!eo(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)=>ct(s,r,We())))}),t}var Ya=v("$ZodUnion",(e,t)=>{we.init(e,t),me(e._zod,"optin",()=>t.options.some((r)=>r._zod.optin==="optional")?"optional":void 0),me(e._zod,"optout",()=>t.options.some((r)=>r._zod.optout==="optional")?"optional":void 0),me(e._zod,"values",()=>{if(t.options.every((r)=>r._zod.values))return new Set(t.options.flatMap((r)=>Array.from(r._zod.values)));return}),me(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)=>Ei(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 a of t.options){let l=a._zod.run({value:r.value,issues:[]},n);if(l instanceof Promise)s.push(l),i=!0;else{if(l.issues.length===0)return l;s.push(l)}}if(!i)return Du(s,r,e,n);return Promise.all(s).then((a)=>Du(a,r,e,n))}});var $d=v("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,Ya.init(e,t);let o=e._zod.parse;me(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[a,l]of Object.entries(s)){if(!n[a])n[a]=new Set;for(let u of l)n[a].add(u)}}return n});let r=Jr(()=>{let n=t.options,i=new Map;for(let s of n){let a=s._zod.propValues?.[t.discriminator];if(!a||a.size===0)throw Error(`Invalid discriminated union option at index "${t.options.indexOf(s)}"`);for(let l of a){if(i.has(l))throw Error(`Duplicate discriminator value "${String(l)}"`);i.set(l,s)}}return i});e._zod.parse=(n,i)=>{let s=n.value;if(!Oo(s))return n.issues.push({code:"invalid_type",expected:"object",input:s,inst:e}),n;let a=r.value.get(s?.[t.discriminator]);if(a)return a._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}}),Cd=v("$ZodIntersection",(e,t)=>{we.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(([l,u])=>Vu(o,l,u));return Vu(o,i,s)}});function Wa(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(Xt(e)&&Xt(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=Wa(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=Wa(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 Vu(e,t,o){let r=new Map,n;for(let a of t.issues)if(a.code==="unrecognized_keys"){n??(n=a);for(let l of a.keys){if(!r.has(l))r.set(l,{});r.get(l).l=!0}}else e.issues.push(a);for(let a of o.issues)if(a.code==="unrecognized_keys")for(let l of a.keys){if(!r.has(l))r.set(l,{});r.get(l).r=!0}else e.issues.push(a);let i=[...r].filter(([,a])=>a.l&&a.r).map(([a])=>a);if(i.length&&n)e.issues.push({...n,keys:i});if(eo(e))return e;let s=Wa(t.value,o.value);if(!s.valid)throw Error(`Unmergable intersection. Error path: ${JSON.stringify(s.mergeErrorPath)}`);return e.value=s.data,e}var Id=v("$ZodRecord",(e,t)=>{we.init(e,t),e._zod.parse=(o,r)=>{let n=o.value;if(!Xt(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 a=new Set;for(let u of s)if(typeof u==="string"||typeof u==="number"||typeof u==="symbol"){a.add(typeof u==="number"?u.toString():u);let m=t.keyType._zod.run({value:u,issues:[]},r);if(m instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(m.issues.length){o.issues.push({code:"invalid_key",origin:"record",issues:m.issues.map((g)=>ct(g,r,We())),input:u,path:[u],inst:e});continue}let h=m.value,f=t.valueType._zod.run({value:n[u],issues:[]},r);if(f instanceof Promise)i.push(f.then((g)=>{if(g.issues.length)o.issues.push(...Ot(u,g.issues));o.value[h]=g.value}));else{if(f.issues.length)o.issues.push(...Ot(u,f.issues));o.value[h]=f.value}}let l;for(let u in n)if(!a.has(u))l=l??[],l.push(u);if(l&&l.length>0)o.issues.push({code:"unrecognized_keys",input:n,inst:e,keys:l})}else{o.value={};for(let a of Reflect.ownKeys(n)){if(a==="__proto__")continue;if(!Object.prototype.propertyIsEnumerable.call(n,a))continue;let l=t.keyType._zod.run({value:a,issues:[]},r);if(l instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(typeof a==="string"&&Fa.test(a)&&l.issues.length){let h=t.keyType._zod.run({value:Number(a),issues:[]},r);if(h instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(h.issues.length===0)l=h}if(l.issues.length){if(t.mode==="loose")o.value[a]=n[a];else o.issues.push({code:"invalid_key",origin:"record",issues:l.issues.map((h)=>ct(h,r,We())),input:a,path:[a],inst:e});continue}let m=t.valueType._zod.run({value:n[a],issues:[]},r);if(m instanceof Promise)i.push(m.then((h)=>{if(h.issues.length)o.issues.push(...Ot(a,h.issues));o.value[l.value]=h.value}));else{if(m.issues.length)o.issues.push(...Ot(a,m.issues));o.value[l.value]=m.value}}}if(i.length)return Promise.all(i).then(()=>o);return o}});var Od=v("$ZodEnum",(e,t)=>{we.init(e,t);let o=Ri(t.entries),r=new Set(o);e._zod.values=r,e._zod.pattern=new RegExp(`^(${o.filter((n)=>Al.has(typeof n)).map((n)=>typeof n==="string"?It(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}}),Md=v("$ZodLiteral",(e,t)=>{if(we.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"?It(r):r?It(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 Ad=v("$ZodTransform",(e,t)=>{we.init(e,t),e._zod.optin="optional",e._zod.parse=(o,r)=>{if(r.direction==="backward")throw new Hr(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 _t;return o.value=n,o.fallback=!0,o}});function Hu(e,t){if(t===void 0&&(e.issues.length||e.fallback))return{issues:[],value:void 0};return e}var Qa=v("$ZodOptional",(e,t)=>{we.init(e,t),e._zod.optin="optional",e._zod.optout="optional",me(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),me(e._zod,"pattern",()=>{let o=t.innerType._zod.pattern;return o?new RegExp(`^(${Ei(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)=>Hu(s,n));return Hu(i,n)}if(o.value===void 0)return o;return t.innerType._zod.run(o,r)}}),Nd=v("$ZodExactOptional",(e,t)=>{Qa.init(e,t),me(e._zod,"values",()=>t.innerType._zod.values),me(e._zod,"pattern",()=>t.innerType._zod.pattern),e._zod.parse=(o,r)=>t.innerType._zod.run(o,r)}),qd=v("$ZodNullable",(e,t)=>{we.init(e,t),me(e._zod,"optin",()=>t.innerType._zod.optin),me(e._zod,"optout",()=>t.innerType._zod.optout),me(e._zod,"pattern",()=>{let o=t.innerType._zod.pattern;return o?new RegExp(`^(${Ei(o.source)}|null)$`):void 0}),me(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)}}),jd=v("$ZodDefault",(e,t)=>{we.init(e,t),e._zod.optin="optional",me(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)=>Fu(i,t));return Fu(n,t)}});function Fu(e,t){if(e.value===void 0)e.value=t.defaultValue;return e}var Ld=v("$ZodPrefault",(e,t)=>{we.init(e,t),e._zod.optin="optional",me(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)}}),Ud=v("$ZodNonOptional",(e,t)=>{we.init(e,t),me(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)=>Ju(i,e));return Ju(n,e)}});function Ju(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 Zd=v("$ZodCatch",(e,t)=>{we.init(e,t),e._zod.optin="optional",me(e._zod,"optout",()=>t.innerType._zod.optout),me(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)=>ct(s,r,We()))},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)=>ct(i,r,We()))},input:o.value}),o.issues=[],o.fallback=!0;return o}});var Xa=v("$ZodPipe",(e,t)=>{we.init(e,t),me(e._zod,"values",()=>t.in._zod.values),me(e._zod,"optin",()=>t.in._zod.optin),me(e._zod,"optout",()=>t.out._zod.optout),me(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)=>Ci(s,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 Dd=v("$ZodPreprocess",(e,t)=>{Xa.init(e,t)}),Vd=v("$ZodReadonly",(e,t)=>{we.init(e,t),me(e._zod,"propValues",()=>t.innerType._zod.propValues),me(e._zod,"values",()=>t.innerType._zod.values),me(e._zod,"optin",()=>t.innerType?._zod?.optin),me(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(Bu);return Bu(n)}});function Bu(e){return e.value=Object.freeze(e.value),e}var Hd=v("$ZodLazy",(e,t)=>{we.init(e,t),me(e._zod,"innerType",()=>{let o=t;if(!o._cachedInner)o._cachedInner=t.getter();return o._cachedInner}),me(e._zod,"pattern",()=>e._zod.innerType?._zod?.pattern),me(e._zod,"propValues",()=>e._zod.innerType?._zod?.propValues),me(e._zod,"optin",()=>e._zod.innerType?._zod?.optin??void 0),me(e._zod,"optout",()=>e._zod.innerType?._zod?.optout??void 0),e._zod.parse=(o,r)=>e._zod.innerType._zod.run(o,r)}),Fd=v("$ZodCustom",(e,t)=>{De.init(e,t),we.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)=>Gu(i,o,r,e));Gu(n,o,r,e);return}});function Gu(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(to(n))}}var Uf=()=>{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=Ll(n.input),a=r[s]??s;return`Invalid input: expected ${i}, received ${a}`}case"invalid_value":if(n.values.length===1)return`Invalid input: expected ${La(n.values[0])}`;return`Invalid option: expected one of ${Aa(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":""}: ${Aa(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 ec(){return{localeError:Uf()}}var Jd,Zf=Symbol("ZodOutput"),Df=Symbol("ZodInput");class Bd{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 Gd(){return new Bd}(Jd=globalThis).__zod_globalRegistry??(Jd.__zod_globalRegistry=Gd());var Mt=globalThis.__zod_globalRegistry;function Wd(e,t){return new e({type:"string",...H(t)})}function tc(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...H(t)})}function oc(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...H(t)})}function Kd(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...H(t)})}function Yd(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...H(t)})}function Qd(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...H(t)})}function Xd(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...H(t)})}function rc(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...H(t)})}function ep(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...H(t)})}function tp(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...H(t)})}function op(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...H(t)})}function rp(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...H(t)})}function np(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...H(t)})}function sp(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...H(t)})}function ip(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...H(t)})}function ap(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...H(t)})}function cp(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...H(t)})}function lp(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...H(t)})}function up(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...H(t)})}function dp(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...H(t)})}function pp(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...H(t)})}function hp(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...H(t)})}function mp(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...H(t)})}function fp(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...H(t)})}function gp(e,t){return new e({type:"string",format:"date",check:"string_format",...H(t)})}function Sp(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...H(t)})}function _p(e,t){return new e({type:"string",format:"duration",check:"string_format",...H(t)})}function bp(e,t){return new e({type:"number",checks:[],...H(t)})}function yp(e,t){return new e({type:"number",coerce:!0,checks:[],...H(t)})}function vp(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...H(t)})}function zp(e,t){return new e({type:"boolean",...H(t)})}function wp(e,t){return new e({type:"undefined",...H(t)})}function Rp(e,t){return new e({type:"null",...H(t)})}function xp(e){return new e({type:"any"})}function Ep(e){return new e({type:"unknown"})}function Pp(e,t){return new e({type:"never",...H(t)})}function Mi(e,t){return new Ja({check:"less_than",...H(t),value:e,inclusive:!1})}function Yr(e,t){return new Ja({check:"less_than",...H(t),value:e,inclusive:!0})}function Ai(e,t){return new Ba({check:"greater_than",...H(t),value:e,inclusive:!1})}function Qr(e,t){return new Ba({check:"greater_than",...H(t),value:e,inclusive:!0})}function Ni(e,t){return new Pu({check:"multiple_of",...H(t),value:e})}function qi(e,t){return new ku({check:"max_length",...H(t),maximum:e})}function Mo(e,t){return new $u({check:"min_length",...H(t),minimum:e})}function ji(e,t){return new Cu({check:"length_equals",...H(t),length:e})}function nc(e,t){return new Iu({check:"string_format",format:"regex",...H(t),pattern:e})}function sc(e){return new Ou({check:"string_format",format:"lowercase",...H(e)})}function ic(e){return new Mu({check:"string_format",format:"uppercase",...H(e)})}function ac(e,t){return new Au({check:"string_format",format:"includes",...H(t),includes:e})}function cc(e,t){return new Nu({check:"string_format",format:"starts_with",...H(t),prefix:e})}function lc(e,t){return new qu({check:"string_format",format:"ends_with",...H(t),suffix:e})}function At(e){return new ju({check:"overwrite",tx:e})}function uc(e){return At((t)=>t.normalize(e))}function dc(){return At((e)=>e.trim())}function pc(){return At((e)=>e.toLowerCase())}function hc(){return At((e)=>e.toUpperCase())}function mc(){return At((e)=>Ol(e))}function Tp(e,t,o){return new e({type:"array",element:t,...H(o)})}function kp(e,t,o){return new e({type:"custom",check:"custom",fn:t,...H(o)})}function $p(e,t){let o=Vf((r)=>(r.addIssue=(n)=>{if(typeof n==="string")r.issues.push(to(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(to(i))}},e(r.value,r)),t);return o}function Vf(e,t){let o=new De({check:"custom",...H(t)});return o._zod.check=e,o}function en(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??Mt,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 Re(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 a=e._zod.toJSONSchema?.();if(a)s.schema=a;else{let m={...o,schemaPath:[...o.schemaPath,e],path:o.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,s.schema,m);else{let f=s.schema,g=t.processors[n.type];if(!g)throw Error(`[toJSONSchema]: Non-representable type encountered: ${n.type}`);g(e,t,f,m)}let h=e._zod.parent;if(h){if(!s.ref)s.ref=h;Re(h,t,m),t.seen.get(h).isParent=!0}}let l=t.metadataRegistry.get(e);if(l)Object.assign(s.schema,l);if(t.io==="input"&&Ke(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 tn(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 a=e.metadataRegistry.get(s[0])?.id;if(a){let l=r.get(a);if(l&&l!==s[0])throw Error(`Duplicate schema id "${a}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(a,s[0])}}let n=(s)=>{let a=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){let h=e.external.registry.get(s[0])?.id,f=e.external.uri??((_)=>_);if(h)return{ref:f(h)};let g=s[1].defId??s[1].schema.id??`schema${e.counter++}`;return s[1].defId=g,{defId:g,ref:`${f("__shared")}#/${a}/${g}`}}if(s[1]===o)return{ref:"#"};let u=`${"#"}/${a}/`,m=s[1].schema.id??`__schema${e.counter++}`;return{defId:m,ref:u+m}},i=(s)=>{if(s[1].schema.$ref)return;let a=s[1],{ref:l,defId:u}=n(s);if(a.def={...a.schema},u)a.defId=u;let m=a.schema;for(let h in m)delete m[h];m.$ref=l};if(e.cycles==="throw")for(let s of e.seen.entries()){let a=s[1];if(a.cycle)throw Error(`Cycle detected: #/${a.cycle?.join("/")}/<root>
62
+ `)}g.write("payload.value = newResult;"),g.write("return payload;");let E=g.compile();return(R,T)=>E(f,R,T)},i,s=Oo,a=!Io.jitless,u=a&&Ml.value,m=t.catchall,h;e._zod.parse=(f,g)=>{h??(h=r.value);let y=f.value;if(!s(y))return f.issues.push({expected:"object",code:"invalid_type",input:y,inst:e}),f;if(a&&u&&g?.async===!1&&g.jitless!==!0){if(!i)i=n(t.shape);if(f=i(f,g),!m)return f;return Td([],y,f,g,h,e)}return o(f,g)}});function Du(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)=>!eo(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)=>ct(s,r,Ye())))}),t}var Ya=v("$ZodUnion",(e,t)=>{ye.init(e,t),fe(e._zod,"optin",()=>t.options.some((r)=>r._zod.optin==="optional")?"optional":void 0),fe(e._zod,"optout",()=>t.options.some((r)=>r._zod.optout==="optional")?"optional":void 0),fe(e._zod,"values",()=>{if(t.options.every((r)=>r._zod.values))return new Set(t.options.flatMap((r)=>Array.from(r._zod.values)));return}),fe(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)=>Ei(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 a of t.options){let l=a._zod.run({value:r.value,issues:[]},n);if(l instanceof Promise)s.push(l),i=!0;else{if(l.issues.length===0)return l;s.push(l)}}if(!i)return Du(s,r,e,n);return Promise.all(s).then((a)=>Du(a,r,e,n))}});var $d=v("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,Ya.init(e,t);let o=e._zod.parse;fe(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[a,l]of Object.entries(s)){if(!n[a])n[a]=new Set;for(let u of l)n[a].add(u)}}return n});let r=Jr(()=>{let n=t.options,i=new Map;for(let s of n){let a=s._zod.propValues?.[t.discriminator];if(!a||a.size===0)throw Error(`Invalid discriminated union option at index "${t.options.indexOf(s)}"`);for(let l of a){if(i.has(l))throw Error(`Duplicate discriminator value "${String(l)}"`);i.set(l,s)}}return i});e._zod.parse=(n,i)=>{let s=n.value;if(!Oo(s))return n.issues.push({code:"invalid_type",expected:"object",input:s,inst:e}),n;let a=r.value.get(s?.[t.discriminator]);if(a)return a._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}}),Cd=v("$ZodIntersection",(e,t)=>{ye.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(([l,u])=>Vu(o,l,u));return Vu(o,i,s)}});function Wa(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(Xt(e)&&Xt(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=Wa(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=Wa(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 Vu(e,t,o){let r=new Map,n;for(let a of t.issues)if(a.code==="unrecognized_keys"){n??(n=a);for(let l of a.keys){if(!r.has(l))r.set(l,{});r.get(l).l=!0}}else e.issues.push(a);for(let a of o.issues)if(a.code==="unrecognized_keys")for(let l of a.keys){if(!r.has(l))r.set(l,{});r.get(l).r=!0}else e.issues.push(a);let i=[...r].filter(([,a])=>a.l&&a.r).map(([a])=>a);if(i.length&&n)e.issues.push({...n,keys:i});if(eo(e))return e;let s=Wa(t.value,o.value);if(!s.valid)throw Error(`Unmergable intersection. Error path: ${JSON.stringify(s.mergeErrorPath)}`);return e.value=s.data,e}var Id=v("$ZodRecord",(e,t)=>{ye.init(e,t),e._zod.parse=(o,r)=>{let n=o.value;if(!Xt(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 a=new Set;for(let u of s)if(typeof u==="string"||typeof u==="number"||typeof u==="symbol"){a.add(typeof u==="number"?u.toString():u);let m=t.keyType._zod.run({value:u,issues:[]},r);if(m instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(m.issues.length){o.issues.push({code:"invalid_key",origin:"record",issues:m.issues.map((g)=>ct(g,r,Ye())),input:u,path:[u],inst:e});continue}let h=m.value,f=t.valueType._zod.run({value:n[u],issues:[]},r);if(f instanceof Promise)i.push(f.then((g)=>{if(g.issues.length)o.issues.push(...Ot(u,g.issues));o.value[h]=g.value}));else{if(f.issues.length)o.issues.push(...Ot(u,f.issues));o.value[h]=f.value}}let l;for(let u in n)if(!a.has(u))l=l??[],l.push(u);if(l&&l.length>0)o.issues.push({code:"unrecognized_keys",input:n,inst:e,keys:l})}else{o.value={};for(let a of Reflect.ownKeys(n)){if(a==="__proto__")continue;if(!Object.prototype.propertyIsEnumerable.call(n,a))continue;let l=t.keyType._zod.run({value:a,issues:[]},r);if(l instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(typeof a==="string"&&Fa.test(a)&&l.issues.length){let h=t.keyType._zod.run({value:Number(a),issues:[]},r);if(h instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(h.issues.length===0)l=h}if(l.issues.length){if(t.mode==="loose")o.value[a]=n[a];else o.issues.push({code:"invalid_key",origin:"record",issues:l.issues.map((h)=>ct(h,r,Ye())),input:a,path:[a],inst:e});continue}let m=t.valueType._zod.run({value:n[a],issues:[]},r);if(m instanceof Promise)i.push(m.then((h)=>{if(h.issues.length)o.issues.push(...Ot(a,h.issues));o.value[l.value]=h.value}));else{if(m.issues.length)o.issues.push(...Ot(a,m.issues));o.value[l.value]=m.value}}}if(i.length)return Promise.all(i).then(()=>o);return o}});var Od=v("$ZodEnum",(e,t)=>{ye.init(e,t);let o=Ri(t.entries),r=new Set(o);e._zod.values=r,e._zod.pattern=new RegExp(`^(${o.filter((n)=>Al.has(typeof n)).map((n)=>typeof n==="string"?It(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}}),Md=v("$ZodLiteral",(e,t)=>{if(ye.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"?It(r):r?It(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 Ad=v("$ZodTransform",(e,t)=>{ye.init(e,t),e._zod.optin="optional",e._zod.parse=(o,r)=>{if(r.direction==="backward")throw new Hr(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 _t;return o.value=n,o.fallback=!0,o}});function Hu(e,t){if(t===void 0&&(e.issues.length||e.fallback))return{issues:[],value:void 0};return e}var Qa=v("$ZodOptional",(e,t)=>{ye.init(e,t),e._zod.optin="optional",e._zod.optout="optional",fe(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),fe(e._zod,"pattern",()=>{let o=t.innerType._zod.pattern;return o?new RegExp(`^(${Ei(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)=>Hu(s,n));return Hu(i,n)}if(o.value===void 0)return o;return t.innerType._zod.run(o,r)}}),Nd=v("$ZodExactOptional",(e,t)=>{Qa.init(e,t),fe(e._zod,"values",()=>t.innerType._zod.values),fe(e._zod,"pattern",()=>t.innerType._zod.pattern),e._zod.parse=(o,r)=>t.innerType._zod.run(o,r)}),qd=v("$ZodNullable",(e,t)=>{ye.init(e,t),fe(e._zod,"optin",()=>t.innerType._zod.optin),fe(e._zod,"optout",()=>t.innerType._zod.optout),fe(e._zod,"pattern",()=>{let o=t.innerType._zod.pattern;return o?new RegExp(`^(${Ei(o.source)}|null)$`):void 0}),fe(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)}}),jd=v("$ZodDefault",(e,t)=>{ye.init(e,t),e._zod.optin="optional",fe(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)=>Fu(i,t));return Fu(n,t)}});function Fu(e,t){if(e.value===void 0)e.value=t.defaultValue;return e}var Ld=v("$ZodPrefault",(e,t)=>{ye.init(e,t),e._zod.optin="optional",fe(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)}}),Ud=v("$ZodNonOptional",(e,t)=>{ye.init(e,t),fe(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)=>Ju(i,e));return Ju(n,e)}});function Ju(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 Zd=v("$ZodCatch",(e,t)=>{ye.init(e,t),e._zod.optin="optional",fe(e._zod,"optout",()=>t.innerType._zod.optout),fe(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)=>ct(s,r,Ye()))},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)=>ct(i,r,Ye()))},input:o.value}),o.issues=[],o.fallback=!0;return o}});var Xa=v("$ZodPipe",(e,t)=>{ye.init(e,t),fe(e._zod,"values",()=>t.in._zod.values),fe(e._zod,"optin",()=>t.in._zod.optin),fe(e._zod,"optout",()=>t.out._zod.optout),fe(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)=>Ci(s,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 Dd=v("$ZodPreprocess",(e,t)=>{Xa.init(e,t)}),Vd=v("$ZodReadonly",(e,t)=>{ye.init(e,t),fe(e._zod,"propValues",()=>t.innerType._zod.propValues),fe(e._zod,"values",()=>t.innerType._zod.values),fe(e._zod,"optin",()=>t.innerType?._zod?.optin),fe(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(Bu);return Bu(n)}});function Bu(e){return e.value=Object.freeze(e.value),e}var Hd=v("$ZodLazy",(e,t)=>{ye.init(e,t),fe(e._zod,"innerType",()=>{let o=t;if(!o._cachedInner)o._cachedInner=t.getter();return o._cachedInner}),fe(e._zod,"pattern",()=>e._zod.innerType?._zod?.pattern),fe(e._zod,"propValues",()=>e._zod.innerType?._zod?.propValues),fe(e._zod,"optin",()=>e._zod.innerType?._zod?.optin??void 0),fe(e._zod,"optout",()=>e._zod.innerType?._zod?.optout??void 0),e._zod.parse=(o,r)=>e._zod.innerType._zod.run(o,r)}),Fd=v("$ZodCustom",(e,t)=>{He.init(e,t),ye.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)=>Gu(i,o,r,e));Gu(n,o,r,e);return}});function Gu(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(to(n))}}var Uf=()=>{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=Ll(n.input),a=r[s]??s;return`Invalid input: expected ${i}, received ${a}`}case"invalid_value":if(n.values.length===1)return`Invalid input: expected ${La(n.values[0])}`;return`Invalid option: expected one of ${Aa(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":""}: ${Aa(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 ec(){return{localeError:Uf()}}var Jd,Zf=Symbol("ZodOutput"),Df=Symbol("ZodInput");class Bd{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 Gd(){return new Bd}(Jd=globalThis).__zod_globalRegistry??(Jd.__zod_globalRegistry=Gd());var Mt=globalThis.__zod_globalRegistry;function Wd(e,t){return new e({type:"string",...H(t)})}function tc(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...H(t)})}function oc(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...H(t)})}function Kd(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...H(t)})}function Yd(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...H(t)})}function Qd(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...H(t)})}function Xd(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...H(t)})}function rc(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...H(t)})}function ep(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...H(t)})}function tp(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...H(t)})}function op(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...H(t)})}function rp(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...H(t)})}function np(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...H(t)})}function sp(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...H(t)})}function ip(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...H(t)})}function ap(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...H(t)})}function cp(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...H(t)})}function lp(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...H(t)})}function up(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...H(t)})}function dp(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...H(t)})}function pp(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...H(t)})}function hp(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...H(t)})}function mp(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...H(t)})}function fp(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...H(t)})}function gp(e,t){return new e({type:"string",format:"date",check:"string_format",...H(t)})}function Sp(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...H(t)})}function _p(e,t){return new e({type:"string",format:"duration",check:"string_format",...H(t)})}function bp(e,t){return new e({type:"number",checks:[],...H(t)})}function yp(e,t){return new e({type:"number",coerce:!0,checks:[],...H(t)})}function vp(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...H(t)})}function zp(e,t){return new e({type:"boolean",...H(t)})}function wp(e,t){return new e({type:"undefined",...H(t)})}function Rp(e,t){return new e({type:"null",...H(t)})}function xp(e){return new e({type:"any"})}function Ep(e){return new e({type:"unknown"})}function Pp(e,t){return new e({type:"never",...H(t)})}function Mi(e,t){return new Ja({check:"less_than",...H(t),value:e,inclusive:!1})}function Yr(e,t){return new Ja({check:"less_than",...H(t),value:e,inclusive:!0})}function Ai(e,t){return new Ba({check:"greater_than",...H(t),value:e,inclusive:!1})}function Qr(e,t){return new Ba({check:"greater_than",...H(t),value:e,inclusive:!0})}function Ni(e,t){return new Pu({check:"multiple_of",...H(t),value:e})}function qi(e,t){return new ku({check:"max_length",...H(t),maximum:e})}function Mo(e,t){return new $u({check:"min_length",...H(t),minimum:e})}function ji(e,t){return new Cu({check:"length_equals",...H(t),length:e})}function nc(e,t){return new Iu({check:"string_format",format:"regex",...H(t),pattern:e})}function sc(e){return new Ou({check:"string_format",format:"lowercase",...H(e)})}function ic(e){return new Mu({check:"string_format",format:"uppercase",...H(e)})}function ac(e,t){return new Au({check:"string_format",format:"includes",...H(t),includes:e})}function cc(e,t){return new Nu({check:"string_format",format:"starts_with",...H(t),prefix:e})}function lc(e,t){return new qu({check:"string_format",format:"ends_with",...H(t),suffix:e})}function At(e){return new ju({check:"overwrite",tx:e})}function uc(e){return At((t)=>t.normalize(e))}function dc(){return At((e)=>e.trim())}function pc(){return At((e)=>e.toLowerCase())}function hc(){return At((e)=>e.toUpperCase())}function mc(){return At((e)=>Ol(e))}function Tp(e,t,o){return new e({type:"array",element:t,...H(o)})}function kp(e,t,o){return new e({type:"custom",check:"custom",fn:t,...H(o)})}function $p(e,t){let o=Vf((r)=>(r.addIssue=(n)=>{if(typeof n==="string")r.issues.push(to(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(to(i))}},e(r.value,r)),t);return o}function Vf(e,t){let o=new He({check:"custom",...H(t)});return o._zod.check=e,o}function en(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??Mt,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 Re(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 a=e._zod.toJSONSchema?.();if(a)s.schema=a;else{let m={...o,schemaPath:[...o.schemaPath,e],path:o.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,s.schema,m);else{let f=s.schema,g=t.processors[n.type];if(!g)throw Error(`[toJSONSchema]: Non-representable type encountered: ${n.type}`);g(e,t,f,m)}let h=e._zod.parent;if(h){if(!s.ref)s.ref=h;Re(h,t,m),t.seen.get(h).isParent=!0}}let l=t.metadataRegistry.get(e);if(l)Object.assign(s.schema,l);if(t.io==="input"&&Qe(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 tn(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 a=e.metadataRegistry.get(s[0])?.id;if(a){let l=r.get(a);if(l&&l!==s[0])throw Error(`Duplicate schema id "${a}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(a,s[0])}}let n=(s)=>{let a=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){let h=e.external.registry.get(s[0])?.id,f=e.external.uri??((y)=>y);if(h)return{ref:f(h)};let g=s[1].defId??s[1].schema.id??`schema${e.counter++}`;return s[1].defId=g,{defId:g,ref:`${f("__shared")}#/${a}/${g}`}}if(s[1]===o)return{ref:"#"};let u=`${"#"}/${a}/`,m=s[1].schema.id??`__schema${e.counter++}`;return{defId:m,ref:u+m}},i=(s)=>{if(s[1].schema.$ref)return;let a=s[1],{ref:l,defId:u}=n(s);if(a.def={...a.schema},u)a.defId=u;let m=a.schema;for(let h in m)delete m[h];m.$ref=l};if(e.cycles==="throw")for(let s of e.seen.entries()){let a=s[1];if(a.cycle)throw Error(`Cycle detected: #/${a.cycle?.join("/")}/<root>
63
63
 
64
- Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let s of e.seen.entries()){let a=s[1];if(t===s[0]){i(s);continue}if(e.external){let u=e.external.registry.get(s[0])?.id;if(t!==s[0]&&u){i(s);continue}}if(e.metadataRegistry.get(s[0])?.id){i(s);continue}if(a.cycle){i(s);continue}if(a.count>1){if(e.reused==="ref"){i(s);continue}}}}function on(e,t){let o=e.seen.get(t);if(!o)throw Error("Unprocessed schema. This is a bug in Zod.");let r=(a)=>{let l=e.seen.get(a);if(l.ref===null)return;let u=l.def??l.schema,m={...u},h=l.ref;if(l.ref=null,h){r(h);let g=e.seen.get(h),_=g.schema;if(_.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0"))u.allOf=u.allOf??[],u.allOf.push(_);else Object.assign(u,_);if(Object.assign(u,m),a._zod.parent===h)for(let b in u){if(b==="$ref"||b==="allOf")continue;if(!(b in m))delete u[b]}if(_.$ref&&g.def)for(let b in u){if(b==="$ref"||b==="allOf")continue;if(b in g.def&&JSON.stringify(u[b])===JSON.stringify(g.def[b]))delete u[b]}}let f=a._zod.parent;if(f&&f!==h){r(f);let g=e.seen.get(f);if(g?.schema.$ref){if(u.$ref=g.schema.$ref,g.def)for(let _ in u){if(_==="$ref"||_==="allOf")continue;if(_ in g.def&&JSON.stringify(u[_])===JSON.stringify(g.def[_]))delete u[_]}}}e.override({zodSchema:a,jsonSchema:u,path:l.path??[]})};for(let a of[...e.seen.entries()].reverse())r(a[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 a=e.external.registry.get(t)?.id;if(!a)throw Error("Schema is missing an `id` property");n.$id=e.external.uri(a)}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 a of e.seen.entries()){let l=a[1];if(l.def&&l.defId){if(l.def.id===l.defId)delete l.def.id;s[l.defId]=l.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 a=JSON.parse(JSON.stringify(n));return Object.defineProperty(a,"~standard",{value:{...t["~standard"],jsonSchema:{input:Xr(t,"input",e.processors),output:Xr(t,"output",e.processors)}},enumerable:!1,writable:!1}),a}catch(a){throw Error("Error converting schema to JSON.")}}function Ke(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 Ke(r.element,o);if(r.type==="set")return Ke(r.valueType,o);if(r.type==="lazy")return Ke(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 Ke(r.innerType,o);if(r.type==="intersection")return Ke(r.left,o)||Ke(r.right,o);if(r.type==="record"||r.type==="map")return Ke(r.keyType,o)||Ke(r.valueType,o);if(r.type==="pipe"){if(e._zod.traits.has("$ZodCodec"))return!0;return Ke(r.in,o)||Ke(r.out,o)}if(r.type==="object"){for(let n in r.shape)if(Ke(r.shape[n],o))return!0;return!1}if(r.type==="union"){for(let n of r.options)if(Ke(n,o))return!0;return!1}if(r.type==="tuple"){for(let n of r.items)if(Ke(n,o))return!0;if(r.rest&&Ke(r.rest,o))return!0;return!1}return!1}var Cp=(e,t={})=>(o)=>{let r=en({...o,processors:t});return Re(e,r),tn(r,e),on(r,e)},Xr=(e,t,o={})=>(r)=>{let{libraryOptions:n,target:i}=r??{},s=en({...n??{},target:i,io:t,processors:o});return Re(e,s),tn(s,e),on(s,e)};var Hf={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},fc=(e,t,o,r)=>{let n=o;n.type="string";let{minimum:i,maximum:s,format:a,patterns:l,contentEncoding:u}=e._zod.bag;if(typeof i==="number")n.minLength=i;if(typeof s==="number")n.maxLength=s;if(a){if(n.format=Hf[a]??a,n.format==="")delete n.format;if(a==="time")delete n.format}if(u)n.contentEncoding=u;if(l&&l.size>0){let m=[...l];if(m.length===1)n.pattern=m[0].source;else if(m.length>1)n.allOf=[...m.map((h)=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:h.source}))]}},gc=(e,t,o,r)=>{let n=o,{minimum:i,maximum:s,format:a,multipleOf:l,exclusiveMaximum:u,exclusiveMinimum:m}=e._zod.bag;if(typeof a==="string"&&a.includes("int"))n.type="integer";else n.type="number";let h=typeof m==="number"&&m>=(i??Number.NEGATIVE_INFINITY),f=typeof u==="number"&&u<=(s??Number.POSITIVE_INFINITY),g=t.target==="draft-04"||t.target==="openapi-3.0";if(h)if(g)n.minimum=m,n.exclusiveMinimum=!0;else n.exclusiveMinimum=m;else if(typeof i==="number")n.minimum=i;if(f)if(g)n.maximum=u,n.exclusiveMaximum=!0;else n.exclusiveMaximum=u;else if(typeof s==="number")n.maximum=s;if(typeof l==="number")n.multipleOf=l},Sc=(e,t,o,r)=>{o.type="boolean"},Op=(e,t,o,r)=>{if(t.unrepresentable==="throw")throw Error("BigInt cannot be represented in JSON Schema")},Mp=(e,t,o,r)=>{if(t.unrepresentable==="throw")throw Error("Symbols cannot be represented in JSON Schema")},_c=(e,t,o,r)=>{if(t.target==="openapi-3.0")o.type="string",o.nullable=!0,o.enum=[null];else o.type="null"},bc=(e,t,o,r)=>{if(t.unrepresentable==="throw")throw Error("Undefined cannot be represented in JSON Schema")},Ap=(e,t,o,r)=>{if(t.unrepresentable==="throw")throw Error("Void cannot be represented in JSON Schema")},yc=(e,t,o,r)=>{o.not={}},vc=(e,t,o,r)=>{},zc=(e,t,o,r)=>{},Np=(e,t,o,r)=>{if(t.unrepresentable==="throw")throw Error("Date cannot be represented in JSON Schema")},wc=(e,t,o,r)=>{let n=e._zod.def,i=Ri(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},Rc=(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}},qp=(e,t,o,r)=>{if(t.unrepresentable==="throw")throw Error("NaN cannot be represented in JSON Schema")},jp=(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},Lp=(e,t,o,r)=>{let n=o,i={type:"string",format:"binary",contentEncoding:"binary"},{minimum:s,maximum:a,mime:l}=e._zod.bag;if(s!==void 0)i.minLength=s;if(a!==void 0)i.maxLength=a;if(l)if(l.length===1)i.contentMediaType=l[0],Object.assign(n,i);else Object.assign(n,i),n.anyOf=l.map((u)=>({contentMediaType:u}));else Object.assign(n,i)},Up=(e,t,o,r)=>{o.type="boolean"},xc=(e,t,o,r)=>{if(t.unrepresentable==="throw")throw Error("Custom types cannot be represented in JSON Schema")},Zp=(e,t,o,r)=>{if(t.unrepresentable==="throw")throw Error("Function types cannot be represented in JSON Schema")},Ec=(e,t,o,r)=>{if(t.unrepresentable==="throw")throw Error("Transforms cannot be represented in JSON Schema")},Dp=(e,t,o,r)=>{if(t.unrepresentable==="throw")throw Error("Map cannot be represented in JSON Schema")},Vp=(e,t,o,r)=>{if(t.unrepresentable==="throw")throw Error("Set cannot be represented in JSON Schema")},Pc=(e,t,o,r)=>{let n=o,i=e._zod.def,{minimum:s,maximum:a}=e._zod.bag;if(typeof s==="number")n.minItems=s;if(typeof a==="number")n.maxItems=a;n.type="array",n.items=Re(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 s=i.shape;for(let u in s)n.properties[u]=Re(s[u],t,{...r,path:[...r.path,"properties",u]});let a=new Set(Object.keys(s)),l=new Set([...a].filter((u)=>{let m=i.shape[u]._zod;if(t.io==="input")return m.optin===void 0;else return m.optout===void 0}));if(l.size>0)n.required=Array.from(l);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=Re(i.catchall,t,{...r,path:[...r.path,"additionalProperties"]})},kc=(e,t,o,r)=>{let n=e._zod.def,i=n.inclusive===!1,s=n.options.map((a,l)=>Re(a,t,{...r,path:[...r.path,i?"oneOf":"anyOf",l]}));if(i)o.oneOf=s;else o.anyOf=s},$c=(e,t,o,r)=>{let n=e._zod.def,i=Re(n.left,t,{...r,path:[...r.path,"allOf",0]}),s=Re(n.right,t,{...r,path:[...r.path,"allOf",1]}),a=(u)=>("allOf"in u)&&Object.keys(u).length===1,l=[...a(i)?i.allOf:[i],...a(s)?s.allOf:[s]];o.allOf=l},Hp=(e,t,o,r)=>{let n=o,i=e._zod.def;n.type="array";let s=t.target==="draft-2020-12"?"prefixItems":"items",a=t.target==="draft-2020-12"?"items":t.target==="openapi-3.0"?"items":"additionalItems",l=i.items.map((f,g)=>Re(f,t,{...r,path:[...r.path,s,g]})),u=i.rest?Re(i.rest,t,{...r,path:[...r.path,a,...t.target==="openapi-3.0"?[i.items.length]:[]]}):null;if(t.target==="draft-2020-12"){if(n.prefixItems=l,u)n.items=u}else if(t.target==="openapi-3.0"){if(n.items={anyOf:l},u)n.items.anyOf.push(u);if(n.minItems=l.length,!u)n.maxItems=l.length}else if(n.items=l,u)n.additionalItems=u;let{minimum:m,maximum:h}=e._zod.bag;if(typeof m==="number")n.minItems=m;if(typeof h==="number")n.maxItems=h},Cc=(e,t,o,r)=>{let n=o,i=e._zod.def;n.type="object";let s=i.keyType,l=s._zod.bag?.patterns;if(i.mode==="loose"&&l&&l.size>0){let m=Re(i.valueType,t,{...r,path:[...r.path,"patternProperties","*"]});n.patternProperties={};for(let h of l)n.patternProperties[h.source]=m}else{if(t.target==="draft-07"||t.target==="draft-2020-12")n.propertyNames=Re(i.keyType,t,{...r,path:[...r.path,"propertyNames"]});n.additionalProperties=Re(i.valueType,t,{...r,path:[...r.path,"additionalProperties"]})}let u=s._zod.values;if(u){let m=[...u].filter((h)=>typeof h==="string"||typeof h==="number");if(m.length>0)n.required=m}},Ic=(e,t,o,r)=>{let n=e._zod.def,i=Re(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"}]},Oc=(e,t,o,r)=>{let n=e._zod.def;Re(n.innerType,t,r);let i=t.seen.get(e);i.ref=n.innerType},Mc=(e,t,o,r)=>{let n=e._zod.def;Re(n.innerType,t,r);let i=t.seen.get(e);i.ref=n.innerType,o.default=JSON.parse(JSON.stringify(n.defaultValue))},Ac=(e,t,o,r)=>{let n=e._zod.def;Re(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))},Nc=(e,t,o,r)=>{let n=e._zod.def;Re(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},qc=(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;Re(s,t,r);let a=t.seen.get(e);a.ref=s},jc=(e,t,o,r)=>{let n=e._zod.def;Re(n.innerType,t,r);let i=t.seen.get(e);i.ref=n.innerType,o.readOnly=!0},Fp=(e,t,o,r)=>{let n=e._zod.def;Re(n.innerType,t,r);let i=t.seen.get(e);i.ref=n.innerType},Li=(e,t,o,r)=>{let n=e._zod.def;Re(n.innerType,t,r);let i=t.seen.get(e);i.ref=n.innerType},Lc=(e,t,o,r)=>{let n=e._zod.innerType;Re(n,t,r);let i=t.seen.get(e);i.ref=n},Ip={string:fc,number:gc,boolean:Sc,bigint:Op,symbol:Mp,null:_c,undefined:bc,void:Ap,never:yc,any:vc,unknown:zc,date:Np,enum:wc,literal:Rc,nan:qp,template_literal:jp,file:Lp,success:Up,custom:xc,function:Zp,transform:Ec,map:Dp,set:Vp,array:Pc,object:Tc,union:kc,intersection:$c,tuple:Hp,record:Cc,nullable:Ic,nonoptional:Oc,default:Mc,prefault:Ac,catch:Nc,pipe:qc,readonly:jc,promise:Fp,optional:Li,lazy:Lc};function Ui(e,t){if("_idmap"in e){let r=e,n=en({...t,processors:Ip}),i={};for(let l of r._idmap.entries()){let[u,m]=l;Re(m,n)}let s={},a={registry:r,uri:t?.uri,defs:i};n.external=a;for(let l of r._idmap.entries()){let[u,m]=l;tn(n,m),s[u]=on(n,m)}if(Object.keys(i).length>0){let l=n.target==="draft-2020-12"?"$defs":"definitions";s.__shared={[l]:i}}return{schemas:s}}let o=en({...t,processors:Ip});return Re(e,o),tn(o,e),on(o,e)}var Qf=v("ZodISODateTime",(e,t)=>{id.init(e,t),ke.init(e,t)});function No(e){return fp(Qf,e)}var Xf=v("ZodISODate",(e,t)=>{ad.init(e,t),ke.init(e,t)});function Uc(e){return gp(Xf,e)}var eg=v("ZodISOTime",(e,t)=>{cd.init(e,t),ke.init(e,t)});function Jp(e){return Sp(eg,e)}var tg=v("ZodISODuration",(e,t)=>{ld.init(e,t),ke.init(e,t)});function Bp(e){return _p(tg,e)}var og=(e,t)=>{Ti.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:(o)=>Da(e,o)},flatten:{value:(o)=>Za(e,o)},addIssue:{value:(o)=>{e.issues.push(o),e.message=JSON.stringify(e.issues,Fr,2)}},addIssues:{value:(o)=>{e.issues.push(...o),e.message=JSON.stringify(e.issues,Fr,2)}},isEmpty:{get(){return e.issues.length===0}}})};var ot=v("ZodError",og,{Parent:Error});var Wp=ki(ot),Kp=$i(ot),Di=Br(ot),Yp=Gr(ot),Qp=Vl(ot),Xp=Hl(ot),eh=Fl(ot),th=Jl(ot),oh=Bl(ot),rh=Gl(ot),nh=Wl(ot),sh=Kl(ot);var ih=new WeakMap;function rn(e,t,o){let r=Object.getPrototypeOf(e),n=ih.get(r);if(!n)n=new Set,ih.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 a=s.bind(this);return Object.defineProperty(this,i,{configurable:!0,writable:!0,enumerable:!0,value:a}),a},set(a){Object.defineProperty(this,i,{configurable:!0,writable:!0,enumerable:!0,value:a})}})}}var xe=v("ZodType",(e,t)=>(we.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:Xr(e,"input"),output:Xr(e,"output")}}),e.toJSONSchema=Cp(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.parse=(o,r)=>Wp(e,o,r,{callee:e.parse}),e.safeParse=(o,r)=>Di(e,o,r),e.parseAsync=async(o,r)=>Kp(e,o,r,{callee:e.parseAsync}),e.safeParseAsync=async(o,r)=>Yp(e,o,r),e.spa=e.safeParseAsync,e.encode=(o,r)=>Qp(e,o,r),e.decode=(o,r)=>Xp(e,o,r),e.encodeAsync=async(o,r)=>eh(e,o,r),e.decodeAsync=async(o,r)=>th(e,o,r),e.safeEncode=(o,r)=>oh(e,o,r),e.safeDecode=(o,r)=>rh(e,o,r),e.safeEncodeAsync=async(o,r)=>nh(e,o,r),e.safeDecodeAsync=async(o,r)=>sh(e,o,r),rn(e,"ZodType",{check(...o){let r=this.def;return this.clone(Ct(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 at(this,o,r)},brand(){return this},register(o,r){return o.add(this,r),this},refine(o,r){return this.check(Fg(o,r))},superRefine(o,r){return this.check(Jg(o,r))},overwrite(o){return this.check(At(o))},optional(){return J(this)},exactOptional(){return Cg(this)},nullable(){return uh(this)},nullish(){return J(uh(this))},nonoptional(o){return qg(this,o)},array(){return S(this)},or(o){return A([this,o])},and(o){return bt(this,o)},transform(o){return dh(this,yh(o))},default(o){return Mg(this,o)},prefault(o){return Ng(this,o)},catch(o){return Lg(this,o)},pipe(o){return dh(this,o)},readonly(){return Dg(this)},describe(o){let r=this.clone();return Mt.add(r,{description:o}),r},meta(...o){if(o.length===0)return Mt.get(this);let r=this.clone();return Mt.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 Mt.get(e)?.description},configurable:!0}),e)),ph=v("_ZodString",(e,t)=>{Oi.init(e,t),xe.init(e,t),e._zod.processJSONSchema=(r,n,i)=>fc(e,r,n,i);let o=e._zod.bag;e.format=o.format??null,e.minLength=o.minimum??null,e.maxLength=o.maximum??null,rn(e,"_ZodString",{regex(...r){return this.check(nc(...r))},includes(...r){return this.check(ac(...r))},startsWith(...r){return this.check(cc(...r))},endsWith(...r){return this.check(lc(...r))},min(...r){return this.check(Mo(...r))},max(...r){return this.check(qi(...r))},length(...r){return this.check(ji(...r))},nonempty(...r){return this.check(Mo(1,...r))},lowercase(r){return this.check(sc(r))},uppercase(r){return this.check(ic(r))},trim(){return this.check(dc())},normalize(...r){return this.check(uc(...r))},toLowerCase(){return this.check(pc())},toUpperCase(){return this.check(hc())},slugify(){return this.check(mc())}})}),hh=v("ZodString",(e,t)=>{Oi.init(e,t),ph.init(e,t),e.email=(o)=>e.check(tc(mh,o)),e.url=(o)=>e.check(rc(gh,o)),e.jwt=(o)=>e.check(mp(_g,o)),e.emoji=(o)=>e.check(ep(ng,o)),e.guid=(o)=>e.check(oc(ah,o)),e.uuid=(o)=>e.check(Kd(Vi,o)),e.uuidv4=(o)=>e.check(Yd(Vi,o)),e.uuidv6=(o)=>e.check(Qd(Vi,o)),e.uuidv7=(o)=>e.check(Xd(Vi,o)),e.nanoid=(o)=>e.check(tp(sg,o)),e.guid=(o)=>e.check(oc(ah,o)),e.cuid=(o)=>e.check(op(ig,o)),e.cuid2=(o)=>e.check(rp(ag,o)),e.ulid=(o)=>e.check(np(cg,o)),e.base64=(o)=>e.check(dp(fg,o)),e.base64url=(o)=>e.check(pp(gg,o)),e.xid=(o)=>e.check(sp(lg,o)),e.ksuid=(o)=>e.check(ip(ug,o)),e.ipv4=(o)=>e.check(ap(dg,o)),e.ipv6=(o)=>e.check(cp(pg,o)),e.cidrv4=(o)=>e.check(lp(hg,o)),e.cidrv6=(o)=>e.check(up(mg,o)),e.e164=(o)=>e.check(hp(Sg,o)),e.datetime=(o)=>e.check(No(o)),e.date=(o)=>e.check(Uc(o)),e.time=(o)=>e.check(Jp(o)),e.duration=(o)=>e.check(Bp(o))});function c(e){return Wd(hh,e)}var ke=v("ZodStringFormat",(e,t)=>{Te.init(e,t),ph.init(e,t)}),mh=v("ZodEmail",(e,t)=>{Yu.init(e,t),ke.init(e,t)});function fh(e){return tc(mh,e)}var ah=v("ZodGUID",(e,t)=>{Wu.init(e,t),ke.init(e,t)});var Vi=v("ZodUUID",(e,t)=>{Ku.init(e,t),ke.init(e,t)});var gh=v("ZodURL",(e,t)=>{Qu.init(e,t),ke.init(e,t)});function Hi(e){return rc(gh,e)}var ng=v("ZodEmoji",(e,t)=>{Xu.init(e,t),ke.init(e,t)});var sg=v("ZodNanoID",(e,t)=>{ed.init(e,t),ke.init(e,t)});var ig=v("ZodCUID",(e,t)=>{td.init(e,t),ke.init(e,t)});var ag=v("ZodCUID2",(e,t)=>{od.init(e,t),ke.init(e,t)});var cg=v("ZodULID",(e,t)=>{rd.init(e,t),ke.init(e,t)});var lg=v("ZodXID",(e,t)=>{nd.init(e,t),ke.init(e,t)});var ug=v("ZodKSUID",(e,t)=>{sd.init(e,t),ke.init(e,t)});var dg=v("ZodIPv4",(e,t)=>{ud.init(e,t),ke.init(e,t)});var pg=v("ZodIPv6",(e,t)=>{dd.init(e,t),ke.init(e,t)});var hg=v("ZodCIDRv4",(e,t)=>{pd.init(e,t),ke.init(e,t)});var mg=v("ZodCIDRv6",(e,t)=>{hd.init(e,t),ke.init(e,t)});var fg=v("ZodBase64",(e,t)=>{fd.init(e,t),ke.init(e,t)});var gg=v("ZodBase64URL",(e,t)=>{gd.init(e,t),ke.init(e,t)});var Sg=v("ZodE164",(e,t)=>{Sd.init(e,t),ke.init(e,t)});var _g=v("ZodJWT",(e,t)=>{_d.init(e,t),ke.init(e,t)});var Fi=v("ZodNumber",(e,t)=>{Ka.init(e,t),xe.init(e,t),e._zod.processJSONSchema=(r,n,i)=>gc(e,r,n,i),rn(e,"ZodNumber",{gt(r,n){return this.check(Ai(r,n))},gte(r,n){return this.check(Qr(r,n))},min(r,n){return this.check(Qr(r,n))},lt(r,n){return this.check(Mi(r,n))},lte(r,n){return this.check(Yr(r,n))},max(r,n){return this.check(Yr(r,n))},int(r){return this.check(ch(r))},safe(r){return this.check(ch(r))},positive(r){return this.check(Ai(0,r))},nonnegative(r){return this.check(Qr(0,r))},negative(r){return this.check(Mi(0,r))},nonpositive(r){return this.check(Yr(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 R(e){return bp(Fi,e)}var bg=v("ZodNumberFormat",(e,t)=>{bd.init(e,t),Fi.init(e,t)});function ch(e){return vp(bg,e)}var Sh=v("ZodBoolean",(e,t)=>{yd.init(e,t),xe.init(e,t),e._zod.processJSONSchema=(o,r,n)=>Sc(e,o,r,n)});function M(e){return zp(Sh,e)}var yg=v("ZodUndefined",(e,t)=>{vd.init(e,t),xe.init(e,t),e._zod.processJSONSchema=(o,r,n)=>bc(e,o,r,n)});function Dc(e){return wp(yg,e)}var vg=v("ZodNull",(e,t)=>{zd.init(e,t),xe.init(e,t),e._zod.processJSONSchema=(o,r,n)=>_c(e,o,r,n)});function oo(e){return Rp(vg,e)}var zg=v("ZodAny",(e,t)=>{wd.init(e,t),xe.init(e,t),e._zod.processJSONSchema=(o,r,n)=>vc(e,o,r,n)});function Ji(){return xp(zg)}var wg=v("ZodUnknown",(e,t)=>{Rd.init(e,t),xe.init(e,t),e._zod.processJSONSchema=(o,r,n)=>zc(e,o,r,n)});function V(){return Ep(wg)}var Rg=v("ZodNever",(e,t)=>{xd.init(e,t),xe.init(e,t),e._zod.processJSONSchema=(o,r,n)=>yc(e,o,r,n)});function Vc(e){return Pp(Rg,e)}var xg=v("ZodArray",(e,t)=>{Ed.init(e,t),xe.init(e,t),e._zod.processJSONSchema=(o,r,n)=>Pc(e,o,r,n),e.element=t.element,rn(e,"ZodArray",{min(o,r){return this.check(Mo(o,r))},nonempty(o){return this.check(Mo(1,o))},max(o,r){return this.check(qi(o,r))},length(o,r){return this.check(ji(o,r))},unwrap(){return this.element}})});function S(e,t){return Tp(xg,e,t)}var _h=v("ZodObject",(e,t)=>{kd.init(e,t),xe.init(e,t),e._zod.processJSONSchema=(o,r,n)=>Tc(e,o,r,n),me(e,"shape",()=>t.shape),rn(e,"ZodObject",{keyof(){return oe(Object.keys(this._zod.def.shape))},catchall(o){return this.clone({...this._zod.def,catchall:o})},passthrough(){return this.clone({...this._zod.def,catchall:V()})},loose(){return this.clone({...this._zod.def,catchall:V()})},strict(){return this.clone({...this._zod.def,catchall:Vc()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(o){return $f(this,o)},safeExtend(o){return Cf(this,o)},merge(o){return If(this,o)},pick(o){return Tf(this,o)},omit(o){return kf(this,o)},partial(...o){return Of(vh,this,o[0])},required(...o){return Mf(zh,this,o[0])}})});function d(e,t){let o={type:"object",shape:e??{},...H(t)};return new _h(o)}function K(e,t){return new _h({type:"object",shape:e,catchall:V(),...H(t)})}var bh=v("ZodUnion",(e,t)=>{Ya.init(e,t),xe.init(e,t),e._zod.processJSONSchema=(o,r,n)=>kc(e,o,r,n),e.options=t.options});function A(e,t){return new bh({type:"union",options:e,...H(t)})}var Eg=v("ZodDiscriminatedUnion",(e,t)=>{bh.init(e,t),$d.init(e,t)});function qo(e,t,o){return new Eg({type:"union",options:t,discriminator:e,...H(o)})}var Pg=v("ZodIntersection",(e,t)=>{Cd.init(e,t),xe.init(e,t),e._zod.processJSONSchema=(o,r,n)=>$c(e,o,r,n)});function bt(e,t){return new Pg({type:"intersection",left:e,right:t})}var lh=v("ZodRecord",(e,t)=>{Id.init(e,t),xe.init(e,t),e._zod.processJSONSchema=(o,r,n)=>Cc(e,o,r,n),e.keyType=t.keyType,e.valueType=t.valueType});function O(e,t,o){if(!t||!t._zod)return new lh({type:"record",keyType:c(),valueType:e,...H(t)});return new lh({type:"record",keyType:e,valueType:t,...H(o)})}var Zc=v("ZodEnum",(e,t)=>{Od.init(e,t),xe.init(e,t),e._zod.processJSONSchema=(r,n,i)=>wc(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 Zc({...t,checks:[],...H(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 Zc({...t,checks:[],...H(n),entries:i})}});function oe(e,t){let o=Array.isArray(e)?Object.fromEntries(e.map((r)=>[r,r])):e;return new Zc({type:"enum",entries:o,...H(t)})}var Tg=v("ZodLiteral",(e,t)=>{Md.init(e,t),xe.init(e,t),e._zod.processJSONSchema=(o,r,n)=>Rc(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 p(e,t){return new Tg({type:"literal",values:Array.isArray(e)?e:[e],...H(t)})}var kg=v("ZodTransform",(e,t)=>{Ad.init(e,t),xe.init(e,t),e._zod.processJSONSchema=(o,r,n)=>Ec(e,o,r,n),e._zod.parse=(o,r)=>{if(r.direction==="backward")throw new Hr(e.constructor.name);o.addIssue=(i)=>{if(typeof i==="string")o.issues.push(to(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(to(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 yh(e){return new kg({type:"transform",transform:e})}var vh=v("ZodOptional",(e,t)=>{Qa.init(e,t),xe.init(e,t),e._zod.processJSONSchema=(o,r,n)=>Li(e,o,r,n),e.unwrap=()=>e._zod.def.innerType});function J(e){return new vh({type:"optional",innerType:e})}var $g=v("ZodExactOptional",(e,t)=>{Nd.init(e,t),xe.init(e,t),e._zod.processJSONSchema=(o,r,n)=>Li(e,o,r,n),e.unwrap=()=>e._zod.def.innerType});function Cg(e){return new $g({type:"optional",innerType:e})}var Ig=v("ZodNullable",(e,t)=>{qd.init(e,t),xe.init(e,t),e._zod.processJSONSchema=(o,r,n)=>Ic(e,o,r,n),e.unwrap=()=>e._zod.def.innerType});function uh(e){return new Ig({type:"nullable",innerType:e})}var Og=v("ZodDefault",(e,t)=>{jd.init(e,t),xe.init(e,t),e._zod.processJSONSchema=(o,r,n)=>Mc(e,o,r,n),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Mg(e,t){return new Og({type:"default",innerType:e,get defaultValue(){return typeof t==="function"?t():ja(t)}})}var Ag=v("ZodPrefault",(e,t)=>{Ld.init(e,t),xe.init(e,t),e._zod.processJSONSchema=(o,r,n)=>Ac(e,o,r,n),e.unwrap=()=>e._zod.def.innerType});function Ng(e,t){return new Ag({type:"prefault",innerType:e,get defaultValue(){return typeof t==="function"?t():ja(t)}})}var zh=v("ZodNonOptional",(e,t)=>{Ud.init(e,t),xe.init(e,t),e._zod.processJSONSchema=(o,r,n)=>Oc(e,o,r,n),e.unwrap=()=>e._zod.def.innerType});function qg(e,t){return new zh({type:"nonoptional",innerType:e,...H(t)})}var jg=v("ZodCatch",(e,t)=>{Zd.init(e,t),xe.init(e,t),e._zod.processJSONSchema=(o,r,n)=>Nc(e,o,r,n),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function Lg(e,t){return new jg({type:"catch",innerType:e,catchValue:typeof t==="function"?t:()=>t})}var wh=v("ZodPipe",(e,t)=>{Xa.init(e,t),xe.init(e,t),e._zod.processJSONSchema=(o,r,n)=>qc(e,o,r,n),e.in=t.in,e.out=t.out});function dh(e,t){return new wh({type:"pipe",in:e,out:t})}var Ug=v("ZodPreprocess",(e,t)=>{wh.init(e,t),Dd.init(e,t)}),Zg=v("ZodReadonly",(e,t)=>{Vd.init(e,t),xe.init(e,t),e._zod.processJSONSchema=(o,r,n)=>jc(e,o,r,n),e.unwrap=()=>e._zod.def.innerType});function Dg(e){return new Zg({type:"readonly",innerType:e})}var Vg=v("ZodLazy",(e,t)=>{Hd.init(e,t),xe.init(e,t),e._zod.processJSONSchema=(o,r,n)=>Lc(e,o,r,n),e.unwrap=()=>e._zod.def.getter()});function nn(e){return new Vg({type:"lazy",getter:e})}var Hg=v("ZodCustom",(e,t)=>{Fd.init(e,t),xe.init(e,t),e._zod.processJSONSchema=(o,r,n)=>xc(e,o,r,n)});function Fg(e,t={}){return kp(Hg,e,t)}function Jg(e,t){return $p(e,t)}function ro(e,t){return new Ug({type:"pipe",in:yh(e),out:t})}var xh={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 Rh;(function(e){})(Rh||(Rh={}));function Bg(e){return yp(Fi,e)}We(ec());var sn="2025-11-25";var Bi=[sn,"2025-06-18","2025-03-26","2024-11-05","2024-10-07"],Gi="io.modelcontextprotocol/related-task",no="io.modelcontextprotocol/protocolVersion",jo="io.modelcontextprotocol/clientInfo",ht="io.modelcontextprotocol/serverInfo",so="io.modelcontextprotocol/clientCapabilities",Lo="io.modelcontextprotocol/subscriptionId",Uo="io.modelcontextprotocol/logLevel";var io="2.0";var yt=nn(()=>A([c(),R(),M(),oo(),O(c(),yt),S(yt)])),Ce=O(c(),yt),Wi=S(yt),Zo=A([c(),R().int()]),Do=c(),an=d({ttl:R().optional()}),cn=d({taskId:c()}),Vo=K({progressToken:Zo.optional(),[Gi]:cn.optional()}),Le=d({_meta:Vo.optional()}),qt=Le.extend({task:an.optional()}),Ie=d({method:c(),params:Le.loose().optional()}),Je=d({_meta:Vo.optional()}),Ve=d({method:c(),params:Je.loose().optional()}),Ho=K({get[ht](){return mt.optional().catch(void 0)}}),Oe=K({_meta:Ho.optional()}),lt=A([c(),R().int()]),Fo=d({jsonrpc:p(io),id:lt,...Ie.shape}).strict(),Jo=d({jsonrpc:p(io),...Ve.shape}).strict(),ao=d({jsonrpc:p(io),id:lt,result:Oe}).strict(),co=d({jsonrpc:p(io),id:lt.optional(),error:d({code:R().int(),message:c(),data:V().optional()})}).strict(),lo=A([Fo,Jo,ao,co]),Ki=A([ao,co]),jt=Oe.strict(),ln=Je.extend({requestId:lt.optional(),reason:c().optional()}),Bo=Ve.extend({method:p("notifications/cancelled"),params:ln}),un=d({src:c(),mimeType:c().optional(),sizes:S(c()).optional(),theme:oe(["light","dark"]).optional()}),vt=d({icons:S(un).optional()}),pt=d({name:c(),title:c().optional()}),mt=pt.extend({...pt.shape,...vt.shape,version:c(),websiteUrl:c().optional(),description:c().optional()}),Gg=bt(d({applyDefaults:M().optional()}),Ce),Wg=ro((e)=>{if(e&&typeof e==="object"&&!Array.isArray(e)&&Object.keys(e).length===0)return{form:{}};return e},bt(d({form:Gg.optional(),url:Ce.optional()}),Ce.optional())),Yi=K({list:Ce.optional(),cancel:Ce.optional(),requests:K({sampling:K({createMessage:Ce.optional()}).optional(),elicitation:K({create:Ce.optional()}).optional()}).optional()}),Qi=K({list:Ce.optional(),cancel:Ce.optional(),requests:K({tools:K({call:Ce.optional()}).optional()}).optional()}),dn=d({experimental:O(c(),Ce).optional(),sampling:d({context:Ce.optional(),tools:Ce.optional()}).optional(),elicitation:Wg.optional(),roots:d({listChanged:M().optional()}).optional(),tasks:Yi.optional(),extensions:O(c(),Ce).optional()}),pn=Le.extend({protocolVersion:c(),capabilities:dn,clientInfo:mt}),hn=Ie.extend({method:p("initialize"),params:pn}),Go=d({experimental:O(c(),Ce).optional(),logging:Ce.optional(),completions:Ce.optional(),prompts:d({listChanged:M().optional()}).optional(),resources:d({subscribe:M().optional(),listChanged:M().optional()}).optional(),tools:d({listChanged:M().optional()}).optional(),tasks:Qi.optional(),extensions:O(c(),Ce).optional()}),mn=Oe.extend({protocolVersion:c(),capabilities:Go,serverInfo:mt,instructions:c().optional()}),fn=Ve.extend({method:p("notifications/initialized"),params:Je.optional()}),gn=Ie.extend({method:p("server/discover"),params:Le.optional()}),Lt=Oe.extend({supportedVersions:S(c()),capabilities:Go,instructions:c().optional()}),Wo=Ie.extend({method:p("ping"),params:Le.optional()}),Sn=d({progress:R(),total:J(R()),message:J(c())}),_n=d({...Je.shape,...Sn.shape,progressToken:Zo}),Ko=Ve.extend({method:p("notifications/progress"),params:_n}),bn=Le.extend({cursor:Do.optional()}),zt=Ie.extend({params:bn.optional()}),wt=Oe.extend({nextCursor:Do.optional()}),Yo=d({uri:c(),mimeType:J(c()),_meta:O(c(),V()).optional()}),Qo=Yo.extend({text:c()}),Fc=c().refine((e)=>{try{return atob(e),!0}catch{return!1}},{message:"Invalid Base64 string"}),Xo=Yo.extend({blob:Fc}),Rt=oe(["user","assistant"]),ft=d({audience:S(Rt).optional(),priority:R().min(0).max(1).optional(),lastModified:No({offset:!0}).optional()}),er=d({...pt.shape,...vt.shape,uri:c(),description:J(c()),mimeType:J(c()),size:J(R()),annotations:ft.optional(),_meta:J(K({}))}),yn=d({...pt.shape,...vt.shape,uriTemplate:c(),description:J(c()),mimeType:J(c()),annotations:ft.optional(),_meta:J(K({}))}),vn=zt.extend({method:p("resources/list")}),zn=wt.extend({resources:S(er)}),wn=zt.extend({method:p("resources/templates/list")}),Rn=wt.extend({resourceTemplates:S(yn)}),uo=Le.extend({uri:c()}),xn=uo,En=Ie.extend({method:p("resources/read"),params:xn}),Pn=Oe.extend({contents:S(A([Qo,Xo]))}),Tn=Ve.extend({method:p("notifications/resources/list_changed"),params:Je.optional()}),kn=uo,$n=Ie.extend({method:p("resources/subscribe"),params:kn}),Cn=uo,In=Ie.extend({method:p("resources/unsubscribe"),params:Cn}),tr=d({toolsListChanged:M().optional(),promptsListChanged:M().optional(),resourcesListChanged:M().optional(),resourceSubscriptions:S(c()).optional()}),On=Le.extend({notifications:tr}),Mn=Ie.extend({method:p("subscriptions/listen"),params:On}),An=Je.extend({notifications:tr}),Nn=Ve.extend({method:p("notifications/subscriptions/acknowledged"),params:An}),qn=Ho.extend({[Lo]:lt}),jn=Oe.extend({_meta:qn}),Ln=Je.extend({uri:c()}),Un=Ve.extend({method:p("notifications/resources/updated"),params:Ln}),Zn=d({name:c(),description:J(c()),required:J(M())}),Dn=d({...pt.shape,...vt.shape,description:J(c()),arguments:J(S(Zn)),_meta:J(K({}))}),Vn=zt.extend({method:p("prompts/list")}),Hn=wt.extend({prompts:S(Dn)}),Fn=Le.extend({name:c(),arguments:O(c(),c()).optional()}),Jn=Ie.extend({method:p("prompts/get"),params:Fn}),po=d({type:p("text"),text:c(),annotations:ft.optional(),_meta:O(c(),V()).optional()}),ho=d({type:p("image"),data:Fc,mimeType:c(),annotations:ft.optional(),_meta:O(c(),V()).optional()}),mo=d({type:p("audio"),data:Fc,mimeType:c(),annotations:ft.optional(),_meta:O(c(),V()).optional()}),Bn=d({type:p("tool_use"),name:c(),id:c(),input:O(c(),V()),_meta:O(c(),V()).optional()}),fo=d({type:p("resource"),resource:A([Qo,Xo]),annotations:ft.optional(),_meta:O(c(),V()).optional()}),go=er.extend({type:p("resource_link")}),gt=A([po,ho,mo,go,fo]),Gn=d({role:Rt,content:gt}),Wn=Oe.extend({description:c().optional(),messages:S(Gn)}),Kn=Ve.extend({method:p("notifications/prompts/list_changed"),params:Je.optional()}),Yn=d({title:c().optional(),readOnlyHint:M().optional(),destructiveHint:M().optional(),idempotentHint:M().optional(),openWorldHint:M().optional()}),Qn=d({taskSupport:oe(["required","optional","forbidden"]).optional()}),Ut=d({...pt.shape,...vt.shape,description:c().optional(),inputSchema:d({type:p("object"),properties:O(c(),yt).optional(),required:S(c()).optional()}).catchall(V()),outputSchema:K({$schema:c().optional()}).optional(),annotations:Yn.optional(),execution:Qn.optional(),_meta:O(c(),V()).optional()}),Xn=zt.extend({method:p("tools/list")}),es=wt.extend({tools:S(Ut)}),Zt=Oe.extend({content:S(gt).default([]),structuredContent:V().optional(),isError:M().optional()}),Xi=Zt.or(Oe.extend({toolResult:V()})),ts=qt.extend({name:c(),arguments:O(c(),V()).optional()}),os=Ie.extend({method:p("tools/call"),params:ts}),rs=Ve.extend({method:p("notifications/tools/list_changed"),params:Je.optional()}),ns=d({autoRefresh:M().default(!0),debounceMs:R().int().nonnegative().default(300)}),or=oe(["debug","info","notice","warning","error","critical","alert","emergency"]),ss=Le.extend({level:or}),is=Ie.extend({method:p("logging/setLevel"),params:ss}),as=Je.extend({level:or,logger:c().optional(),data:V()}),cs=Ve.extend({method:p("notifications/message"),params:as}),ls=d({name:c().optional()}),us=d({hints:S(ls).optional(),costPriority:R().min(0).max(1).optional(),speedPriority:R().min(0).max(1).optional(),intelligencePriority:R().min(0).max(1).optional()}),ds=d({mode:oe(["auto","required","none"]).optional()}),ps=d({type:p("tool_result"),toolUseId:c().describe("The unique identifier for the corresponding tool call."),content:S(gt),structuredContent:V().optional(),isError:M().optional(),_meta:O(c(),V()).optional()}),hs=qo("type",[po,ho,mo]),Nt=qo("type",[po,ho,mo,Bn,ps]),ms=d({role:Rt,content:A([Nt,S(Nt)]),_meta:O(c(),V()).optional()}),fs=qt.extend({messages:S(ms),modelPreferences:us.optional(),systemPrompt:c().optional(),includeContext:oe(["none","thisServer","allServers"]).optional(),temperature:R().optional(),maxTokens:R().int(),stopSequences:S(c()).optional(),metadata:Ce.optional(),tools:S(Ut).optional(),toolChoice:ds.optional()}),gs=Ie.extend({method:p("sampling/createMessage"),params:fs}),Ss=Oe.extend({model:c(),stopReason:J(oe(["endTurn","stopSequence","maxTokens"]).or(c())),role:Rt,content:hs}),_s=Oe.extend({model:c(),stopReason:J(oe(["endTurn","stopSequence","maxTokens","toolUse"]).or(c())),role:Rt,content:A([Nt,S(Nt)])}),rr=d({type:p("boolean"),title:c().optional(),description:c().optional(),default:M().optional()}),So=d({type:p("string"),title:c().optional(),description:c().optional(),minLength:R().optional(),maxLength:R().optional(),format:oe(["email","uri","date","date-time"]).optional(),default:c().optional()}),_o=d({type:oe(["number","integer"]),title:c().optional(),description:c().optional(),minimum:R().optional(),maximum:R().optional(),default:R().optional()}),nr=d({type:p("string"),title:c().optional(),description:c().optional(),enum:S(c()),default:c().optional()}),sr=d({type:p("string"),title:c().optional(),description:c().optional(),oneOf:S(d({const:c(),title:c()})),default:c().optional()}),ir=d({type:p("string"),title:c().optional(),description:c().optional(),enum:S(c()),enumNames:S(c()).optional(),default:c().optional()}),bs=A([nr,sr]),ar=d({type:p("array"),title:c().optional(),description:c().optional(),minItems:R().optional(),maxItems:R().optional(),items:d({type:p("string"),enum:S(c())}),default:S(c()).optional()}),cr=d({type:p("array"),title:c().optional(),description:c().optional(),minItems:R().optional(),maxItems:R().optional(),items:d({anyOf:S(d({const:c(),title:c()}))}),default:S(c()).optional()}),ys=A([ar,cr]),vs=A([ir,bs,ys]),lr=A([vs,rr,So,_o]),bo=qt.extend({mode:p("form").optional(),message:c(),requestedSchema:d({type:p("object"),properties:O(c(),lr),required:S(c()).optional()}).catchall(V())}),zs=qt.extend({mode:p("url"),message:c(),elicitationId:c(),url:c().url()}),ws=A([bo,zs]),Rs=Ie.extend({method:p("elicitation/create"),params:ws}),xs=Je.extend({elicitationId:c()}),Es=Ve.extend({method:p("notifications/elicitation/complete"),params:xs}),Ps=Oe.extend({action:oe(["accept","decline","cancel"]),content:ro((e)=>e===null?void 0:e,O(c(),A([c(),R(),M(),S(c())])).optional())}),Ts=d({type:p("ref/resource"),uri:c()}),ks=d({type:p("ref/prompt"),name:c()}),$s=Le.extend({ref:A([ks,Ts]),argument:d({name:c(),value:c()}),context:d({arguments:O(c(),c()).optional()}).optional()}),Cs=Ie.extend({method:p("completion/complete"),params:$s}),Is=Oe.extend({completion:K({values:S(c()).max(100),total:J(R().int()),hasMore:J(M())})}),Os=d({uri:c().startsWith("file://"),name:c().optional(),_meta:O(c(),V()).optional()}),Ms=Ie.extend({method:p("roots/list"),params:Le.optional()}),As=Oe.extend({roots:S(Os)}),Ns=Ve.extend({method:p("notifications/roots/list_changed"),params:Je.optional()}),ea=K({ttl:R().optional(),pollInterval:R().optional()}),qs=oe(["working","input_required","completed","failed","cancelled"]),xt=d({taskId:c(),status:qs,ttl:A([R(),oo()]),createdAt:c(),lastUpdatedAt:c(),pollInterval:J(R()),statusMessage:J(c())}),ta=Oe.extend({task:xt}),js=Je.merge(xt),oa=Ve.extend({method:p("notifications/tasks/status"),params:js}),ra=Ie.extend({method:p("tasks/get"),params:Le.extend({taskId:c()})}),na=Oe.merge(xt),sa=Ie.extend({method:p("tasks/result"),params:Le.extend({taskId:c()})}),ia=Oe.loose(),aa=zt.extend({method:p("tasks/list")}),ca=wt.extend({tasks:S(xt)}),la=Ie.extend({method:p("tasks/cancel"),params:Le.extend({taskId:c()})}),ua=Oe.merge(xt),da=A([Wo,hn,gn,Cs,is,Jn,Vn,vn,wn,En,$n,In,Mn,os,Xn]),pa=A([Bo,Ko,fn,Ns]),ha=A([jt,Ss,_s,Ps,As]),ma=A([Wo,gs,Rs,Ms]),fa=A([Bo,Ko,cs,Un,Tn,rs,Kn,Nn,Es]),ga=A([jt,mn,Lt,Is,Wn,Hn,zn,Rn,Pn,Zt,es,jn]);var Ue=Hi().superRefine((e,t)=>{if(!URL.canParse(e))return t.addIssue({code:xh.custom,message:"URL must be parseable",fatal:!0}),Oa}).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=K({resource:c().url(),authorization_servers:S(Ue).optional(),jwks_uri:c().url().optional(),scopes_supported:S(c()).optional(),bearer_methods_supported:S(c()).optional(),resource_signing_alg_values_supported:S(c()).optional(),resource_name:c().optional(),resource_documentation:c().optional(),resource_policy_uri:c().url().optional(),resource_tos_uri:c().url().optional(),tls_client_certificate_bound_access_tokens:M().optional(),authorization_details_types_supported:S(c()).optional(),dpop_signing_alg_values_supported:S(c()).optional(),dpop_bound_access_tokens_required:M().optional()}),ur=K({issuer:c(),authorization_endpoint:Ue,token_endpoint:Ue,registration_endpoint:Ue.optional(),scopes_supported:S(c()).optional(),response_types_supported:S(c()),response_modes_supported:S(c()).optional(),grant_types_supported:S(c()).optional(),token_endpoint_auth_methods_supported:S(c()).optional(),token_endpoint_auth_signing_alg_values_supported:S(c()).optional(),service_documentation:Ue.optional(),revocation_endpoint:Ue.optional(),revocation_endpoint_auth_methods_supported:S(c()).optional(),revocation_endpoint_auth_signing_alg_values_supported:S(c()).optional(),introspection_endpoint:c().optional(),introspection_endpoint_auth_methods_supported:S(c()).optional(),introspection_endpoint_auth_signing_alg_values_supported:S(c()).optional(),code_challenge_methods_supported:S(c()).optional(),client_id_metadata_document_supported:M().optional(),authorization_response_iss_parameter_supported:M().optional().catch(void 0),dpop_signing_alg_values_supported:S(c()).optional()}),Us=K({issuer:c(),authorization_endpoint:Ue,token_endpoint:Ue,userinfo_endpoint:Ue.optional(),jwks_uri:Ue,registration_endpoint:Ue.optional(),scopes_supported:S(c()).optional(),response_types_supported:S(c()),response_modes_supported:S(c()).optional(),grant_types_supported:S(c()).optional(),acr_values_supported:S(c()).optional(),subject_types_supported:S(c()),id_token_signing_alg_values_supported:S(c()),id_token_encryption_alg_values_supported:S(c()).optional(),id_token_encryption_enc_values_supported:S(c()).optional(),userinfo_signing_alg_values_supported:S(c()).optional(),userinfo_encryption_alg_values_supported:S(c()).optional(),userinfo_encryption_enc_values_supported:S(c()).optional(),request_object_signing_alg_values_supported:S(c()).optional(),request_object_encryption_alg_values_supported:S(c()).optional(),request_object_encryption_enc_values_supported:S(c()).optional(),token_endpoint_auth_methods_supported:S(c()).optional(),token_endpoint_auth_signing_alg_values_supported:S(c()).optional(),display_values_supported:S(c()).optional(),claim_types_supported:S(c()).optional(),claims_supported:S(c()).optional(),service_documentation:c().optional(),claims_locales_supported:S(c()).optional(),ui_locales_supported:S(c()).optional(),claims_parameter_supported:M().optional(),request_parameter_supported:M().optional(),request_uri_parameter_supported:M().optional(),require_request_uri_registration:M().optional(),op_policy_uri:Ue.optional(),op_tos_uri:Ue.optional(),client_id_metadata_document_supported:M().optional(),authorization_response_iss_parameter_supported:M().optional().catch(void 0)}),Zs=d({...Us.shape,...ur.pick({code_challenge_methods_supported:!0}).shape}),dr=d({access_token:c(),id_token:c().optional(),token_type:c(),expires_in:Bg().optional(),scope:c().optional(),refresh_token:c().optional(),issuer:c().optional().catch(void 0)}).strip(),Ds=d({issued_token_type:p("urn:ietf:params:oauth:token-type:id-jag"),access_token:c(),token_type:c().optional(),expires_in:R().optional(),scope:c().optional()}).strip(),pr=d({error:c(),error_description:c().optional(),error_uri:c().optional()}),Jc=Ue.optional().or(p("").transform(()=>{return})),Vs=d({redirect_uris:S(Ue),token_endpoint_auth_method:c().optional(),grant_types:S(c()).optional(),response_types:S(c()).optional(),application_type:c().optional(),client_name:c().optional(),client_uri:Ue.optional(),logo_uri:Jc,scope:c().optional(),contacts:S(c()).optional(),tos_uri:Jc,policy_uri:c().optional(),jwks_uri:Ue.optional(),jwks:Ji().optional(),software_id:c().optional(),software_version:c().optional(),software_statement:c().optional()}).strip(),Hs=d({client_id:c(),client_secret:c().optional(),client_id_issued_at:R().optional(),client_secret_expires_at:R().optional(),issuer:c().optional().catch(void 0)}).strip(),Fs=Vs.merge(Hs),Sa=d({error:c(),error_description:c().optional()}).strip(),_a=d({token:c(),token_type_hint:c().optional()}).strip();var Yc=Symbol.for("mcp.sdk.errorBrands");function Vt(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,Yc,{value:o,enumerable:!1,configurable:!0})}function Qe(e,t){try{if(typeof t==="object"&&t!==null&&Object.prototype.hasOwnProperty.call(e,"mcpBrand")&&typeof e.mcpBrand==="string"&&Object.prototype.hasOwnProperty.call(t,Yc)){let o=t[Yc];if(o&&typeof o.has==="function"&&o.has(e.mcpBrand))return!0}}catch{}return Function.prototype[Symbol.hasInstance].call(e,t)}var Wh=class e extends Error{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.OAuthError"})}static[Symbol.hasInstance](t){return Qe(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 Qe(this,t)}constructor(t,o,r){super(o);this.code=t,this.errorUri=r,this.name="OAuthError",Vt(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)}},F=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}({}),L=class extends Error{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.SdkError"})}static[Symbol.hasInstance](e){return Qe(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 Qe(this,e)}constructor(e,t,o,r){super(t,r);this.code=e,this.data=o,this.name="SdkError",Vt(this,new.target)}},Ys=class extends L{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 Kh="2026-07-28",ol=[Kh];function Pt(e){return e>=Kh}function rl(e){return e.filter((t)=>!Pt(t))}function Qs(e){return e.filter((t)=>Pt(t))}function Yh(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 Qh=["task","inputRequests","requestState"];function Kg(e){if(e===null||typeof e!=="object"||Array.isArray(e)||e.content!==void 0||Qh.some((t)=>(t in e)))return e;return{...e,content:[]}}function Yg(){let e=nn(()=>A([c(),R(),M(),oo(),O(c(),e),S(e)])),t=O(c(),e),o=A([c(),R().int()]),r=c(),n=d({ttl:R().optional()}),i=d({taskId:c()}),s=K({progressToken:o.optional(),"io.modelcontextprotocol/related-task":i.optional()}),a=d({_meta:s.optional()}),l=a.extend({task:n.optional()}),u=d({method:c(),params:a.loose().optional()}),m=d({_meta:s.optional()}),h=d({method:c(),params:m.loose().optional()}),f=K({_meta:s.optional()}),g=A([c(),R().int()]),_=f.strict(),z=m.extend({requestId:g.optional(),reason:c().optional()}),b=h.extend({method:p("notifications/cancelled"),params:z}),w=d({src:c(),mimeType:c().optional(),sizes:S(c()).optional(),theme:oe(["light","dark"]).optional()}),C=d({icons:S(w).optional()}),x=d({name:c(),title:c().optional()}),T=x.extend({...x.shape,...C.shape,version:c(),websiteUrl:c().optional(),description:c().optional()}),q=bt(d({applyDefaults:M().optional()}),t),B=ro((Fe)=>{if(Fe&&typeof Fe==="object"&&!Array.isArray(Fe)&&Object.keys(Fe).length===0)return{form:{}};return Fe},bt(d({form:q.optional(),url:t.optional()}),t.optional())),ee=K({list:t.optional(),cancel:t.optional(),requests:K({sampling:K({createMessage:t.optional()}).optional(),elicitation:K({create:t.optional()}).optional()}).optional()}),re=K({list:t.optional(),cancel:t.optional(),requests:K({tools:K({call:t.optional()}).optional()}).optional()}),le=d({experimental:O(c(),t).optional(),sampling:d({context:t.optional(),tools:t.optional()}).optional(),elicitation:B.optional(),roots:d({listChanged:M().optional()}).optional(),tasks:ee.optional(),extensions:O(c(),t).optional()}),ve=a.extend({protocolVersion:c(),capabilities:le,clientInfo:T}),se=u.extend({method:p("initialize"),params:ve}),te=d({experimental:O(c(),t).optional(),logging:t.optional(),completions:t.optional(),prompts:d({listChanged:M().optional()}).optional(),resources:d({subscribe:M().optional(),listChanged:M().optional()}).optional(),tools:d({listChanged:M().optional()}).optional(),tasks:re.optional(),extensions:O(c(),t).optional()}),ne=f.extend({protocolVersion:c(),capabilities:te,serverInfo:T,instructions:c().optional()}),be=h.extend({method:p("notifications/initialized"),params:m.optional()}),ue=u.extend({method:p("ping"),params:a.optional()}),de=d({progress:R(),total:J(R()),message:J(c())}),Ee=d({...m.shape,...de.shape,progressToken:o}),Pe=h.extend({method:p("notifications/progress"),params:Ee}),Ae=a.extend({cursor:r.optional()}),W=u.extend({params:Ae.optional()}),ie=f.extend({nextCursor:r.optional()}),E=d({uri:c(),mimeType:J(c()),_meta:O(c(),V()).optional()}),U=E.extend({text:c()}),Q=c().refine((Fe)=>{try{return atob(Fe),!0}catch{return!1}},{message:"Invalid Base64 string"}),G=E.extend({blob:Q}),$e=oe(["user","assistant"]),fe=d({audience:S($e).optional(),priority:R().min(0).max(1).optional(),lastModified:No({offset:!0}).optional()}),ye=d({...x.shape,...C.shape,uri:c(),description:J(c()),mimeType:J(c()),size:J(R()),annotations:fe.optional(),_meta:J(K({}))}),je=d({...x.shape,...C.shape,uriTemplate:c(),description:J(c()),mimeType:J(c()),annotations:fe.optional(),_meta:J(K({}))}),pe=W.extend({method:p("resources/list")}),ze=ie.extend({resources:S(ye)}),Ne=W.extend({method:p("resources/templates/list")}),Ze=ie.extend({resourceTemplates:S(je)}),ge=a.extend({uri:c()}),ae=ge,Xe=u.extend({method:p("resources/read"),params:ae}),st=f.extend({contents:S(A([U,G]))}),he=h.extend({method:p("notifications/resources/list_changed"),params:m.optional()}),ce=ge,y=u.extend({method:p("resources/subscribe"),params:ce}),X=ge,N=u.extend({method:p("resources/unsubscribe"),params:X}),I=m.extend({uri:c()}),j=h.extend({method:p("notifications/resources/updated"),params:I}),k=d({name:c(),description:J(c()),required:J(M())}),P=d({...x.shape,...C.shape,description:J(c()),arguments:J(S(k)),_meta:J(K({}))}),Z=W.extend({method:p("prompts/list")}),D=ie.extend({prompts:S(P)}),Se=a.extend({name:c(),arguments:O(c(),c()).optional()}),Be=u.extend({method:p("prompts/get"),params:Se}),rt=d({type:p("text"),text:c(),annotations:fe.optional(),_meta:O(c(),V()).optional()}),Ht=d({type:p("image"),data:Q,mimeType:c(),annotations:fe.optional(),_meta:O(c(),V()).optional()}),Ft=d({type:p("audio"),data:Q,mimeType:c(),annotations:fe.optional(),_meta:O(c(),V()).optional()}),gr=d({type:p("tool_use"),name:c(),id:c(),input:O(c(),V()),_meta:O(c(),V()).optional()}),Tt=d({type:p("resource"),resource:A([U,G]),annotations:fe.optional(),_meta:O(c(),V()).optional()}),Sr=ye.extend({type:p("resource_link")}),nt=A([rt,Ht,Ft,Sr,Tt]),vo=d({role:$e,content:nt}),zo=f.extend({description:c().optional(),messages:S(vo)}),Jt=h.extend({method:p("notifications/prompts/list_changed"),params:m.optional()}),_r=d({title:c().optional(),readOnlyHint:M().optional(),destructiveHint:M().optional(),idempotentHint:M().optional(),openWorldHint:M().optional()}),wo=d({taskSupport:oe(["required","optional","forbidden"]).optional()}),Bt=d({...x.shape,...C.shape,description:c().optional(),inputSchema:d({type:p("object"),properties:O(c(),e).optional(),required:S(c()).optional()}).catchall(V()),outputSchema:d({type:p("object"),properties:O(c(),e).optional(),required:S(c()).optional()}).catchall(V()).optional(),annotations:_r.optional(),execution:wo.optional(),_meta:O(c(),V()).optional()}),Ro=W.extend({method:p("tools/list")}),xo=ie.extend({tools:S(Bt)}),Eo=f.extend({content:S(nt),structuredContent:O(c(),V()).optional(),isError:M().optional()}),He=l.extend({name:c(),arguments:O(c(),V()).optional()}),br=u.extend({method:p("tools/call"),params:He}),ii=h.extend({method:p("notifications/tools/list_changed"),params:m.optional()}),Po=oe(["debug","info","notice","warning","error","critical","alert","emergency"]),yr=a.extend({level:Po}),vr=u.extend({method:p("logging/setLevel"),params:yr}),zr=m.extend({level:Po,logger:c().optional(),data:V()}),wr=h.extend({method:p("notifications/message"),params:zr}),Rr=d({name:c().optional()}),xr=d({hints:S(Rr).optional(),costPriority:R().min(0).max(1).optional(),speedPriority:R().min(0).max(1).optional(),intelligencePriority:R().min(0).max(1).optional()}),Er=d({mode:oe(["auto","required","none"]).optional()}),ai=d({type:p("tool_result"),toolUseId:c().describe("The unique identifier for the corresponding tool call."),content:S(nt),structuredContent:d({}).loose().optional(),isError:M().optional(),_meta:O(c(),V()).optional()}),Pr=qo("type",[rt,Ht,Ft]),kt=qo("type",[rt,Ht,Ft,gr,ai]),Tr=d({role:$e,content:A([kt,S(kt)]),_meta:O(c(),V()).optional()}),kr=l.extend({messages:S(Tr),modelPreferences:xr.optional(),systemPrompt:c().optional(),includeContext:oe(["none","thisServer","allServers"]).optional(),temperature:R().optional(),maxTokens:R().int(),stopSequences:S(c()).optional(),metadata:t.optional(),tools:S(Bt).optional(),toolChoice:Er.optional()}),$r=u.extend({method:p("sampling/createMessage"),params:kr}),Cr=f.extend({model:c(),stopReason:J(oe(["endTurn","stopSequence","maxTokens"]).or(c())),role:$e,content:Pr}),Ir=f.extend({model:c(),stopReason:J(oe(["endTurn","stopSequence","maxTokens","toolUse"]).or(c())),role:$e,content:A([kt,S(kt)])}),Or=d({type:p("boolean"),title:c().optional(),description:c().optional(),default:M().optional()}),Mr=d({type:p("string"),title:c().optional(),description:c().optional(),minLength:R().optional(),maxLength:R().optional(),format:oe(["email","uri","date","date-time"]).optional(),default:c().optional()}),Ar=d({type:oe(["number","integer"]),title:c().optional(),description:c().optional(),minimum:R().optional(),maximum:R().optional(),default:R().optional()}),Nr=d({type:p("string"),title:c().optional(),description:c().optional(),enum:S(c()),default:c().optional()}),qr=d({type:p("string"),title:c().optional(),description:c().optional(),oneOf:S(d({const:c(),title:c()})),default:c().optional()}),jr=d({type:p("string"),title:c().optional(),description:c().optional(),enum:S(c()),enumNames:S(c()).optional(),default:c().optional()}),Lr=A([Nr,qr]),Gt=d({type:p("array"),title:c().optional(),description:c().optional(),minItems:R().optional(),maxItems:R().optional(),items:d({type:p("string"),enum:S(c())}),default:S(c()).optional()}),Wt=d({type:p("array"),title:c().optional(),description:c().optional(),minItems:R().optional(),maxItems:R().optional(),items:d({anyOf:S(d({const:c(),title:c()}))}),default:S(c()).optional()}),ci=A([Gt,Wt]),li=A([jr,Lr,ci]),et=A([li,Or,Mr,Ar]),tt=l.extend({mode:p("form").optional(),message:c(),requestedSchema:d({type:p("object"),properties:O(c(),et),required:S(c()).optional()}).catchall(V())}),Ur=l.extend({mode:p("url"),message:c(),elicitationId:c(),url:c().url()}),it=A([tt,Ur]),ui=u.extend({method:p("elicitation/create"),params:it}),di=m.extend({elicitationId:c()}),pi=h.extend({method:p("notifications/elicitation/complete"),params:di}),hi=f.extend({action:oe(["accept","decline","cancel"]),content:ro((Fe)=>Fe===null?void 0:Fe,O(c(),A([c(),R(),M(),S(c())])).optional())}),mi=d({type:p("ref/resource"),uri:c()}),fi=d({type:p("ref/prompt"),name:c()}),gi=a.extend({ref:A([fi,mi]),argument:d({name:c(),value:c()}),context:d({arguments:O(c(),c()).optional()}).optional()}),Zr=u.extend({method:p("completion/complete"),params:gi}),Si=f.extend({completion:K({values:S(c()).max(100),total:J(R().int()),hasMore:J(M())})}),_i=d({uri:c().startsWith("file://"),name:c().optional(),_meta:O(c(),V()).optional()}),To=u.extend({method:p("roots/list"),params:a.optional()}),Dr=f.extend({roots:S(_i)}),bi=h.extend({method:p("notifications/roots/list_changed"),params:m.optional()}),yi=K({ttl:R().optional(),pollInterval:R().optional()}),Vr=oe(["working","input_required","completed","failed","cancelled"]),$t=d({taskId:c(),status:Vr,ttl:A([R(),oo()]),createdAt:c(),lastUpdatedAt:c(),pollInterval:J(R()),statusMessage:J(c())}),Ye=f.extend({task:$t}),vi=m.merge($t),Kt=h.extend({method:p("notifications/tasks/status"),params:vi}),ko=u.extend({method:p("tasks/get"),params:a.extend({taskId:c()})}),$o=f.merge($t),Co=u.extend({method:p("tasks/result"),params:a.extend({taskId:c()})}),Ia=f.loose(),Ge=W.extend({method:p("tasks/list")}),qe=ie.extend({tasks:S($t)}),Yt=u.extend({method:p("tasks/cancel"),params:a.extend({taskId:c()})});return{JSONValueSchema:e,JSONObjectSchema:t,ProgressTokenSchema:o,CursorSchema:r,TaskMetadataSchema:n,RelatedTaskMetadataSchema:i,RequestMetaSchema:s,BaseRequestParamsSchema:a,TaskAugmentedRequestParamsSchema:l,RequestSchema:u,NotificationsParamsSchema:m,NotificationSchema:h,ResultSchema:f,RequestIdSchema:g,EmptyResultSchema:_,CancelledNotificationParamsSchema:z,CancelledNotificationSchema:b,IconSchema:w,IconsSchema:C,BaseMetadataSchema:x,ImplementationSchema:T,ClientTasksCapabilitySchema:ee,ServerTasksCapabilitySchema:re,ClientCapabilitiesSchema:le,InitializeRequestParamsSchema:ve,InitializeRequestSchema:se,ServerCapabilitiesSchema:te,InitializeResultSchema:ne,InitializedNotificationSchema:be,PingRequestSchema:ue,ProgressSchema:de,ProgressNotificationParamsSchema:Ee,ProgressNotificationSchema:Pe,PaginatedRequestParamsSchema:Ae,PaginatedRequestSchema:W,PaginatedResultSchema:ie,ResourceContentsSchema:E,TextResourceContentsSchema:U,BlobResourceContentsSchema:G,RoleSchema:$e,AnnotationsSchema:fe,ResourceSchema:ye,ResourceTemplateSchema:je,ListResourcesRequestSchema:pe,ListResourcesResultSchema:ze,ListResourceTemplatesRequestSchema:Ne,ListResourceTemplatesResultSchema:Ze,ResourceRequestParamsSchema:ge,ReadResourceRequestParamsSchema:ae,ReadResourceRequestSchema:Xe,ReadResourceResultSchema:st,ResourceListChangedNotificationSchema:he,SubscribeRequestParamsSchema:ce,SubscribeRequestSchema:y,UnsubscribeRequestParamsSchema:X,UnsubscribeRequestSchema:N,ResourceUpdatedNotificationParamsSchema:I,ResourceUpdatedNotificationSchema:j,PromptArgumentSchema:k,PromptSchema:P,ListPromptsRequestSchema:Z,ListPromptsResultSchema:D,GetPromptRequestParamsSchema:Se,GetPromptRequestSchema:Be,TextContentSchema:rt,ImageContentSchema:Ht,AudioContentSchema:Ft,ToolUseContentSchema:gr,EmbeddedResourceSchema:Tt,ResourceLinkSchema:Sr,ContentBlockSchema:nt,PromptMessageSchema:vo,GetPromptResultSchema:zo,PromptListChangedNotificationSchema:Jt,ToolAnnotationsSchema:_r,ToolExecutionSchema:wo,ToolSchema:Bt,ListToolsRequestSchema:Ro,ListToolsResultSchema:xo,CallToolResultSchema:Eo,CallToolRequestParamsSchema:He,CallToolRequestSchema:br,ToolListChangedNotificationSchema:ii,LoggingLevelSchema:Po,SetLevelRequestParamsSchema:yr,SetLevelRequestSchema:vr,LoggingMessageNotificationParamsSchema:zr,LoggingMessageNotificationSchema:wr,ModelHintSchema:Rr,ModelPreferencesSchema:xr,ToolChoiceSchema:Er,ToolResultContentSchema:ai,SamplingContentSchema:Pr,SamplingMessageContentBlockSchema:kt,SamplingMessageSchema:Tr,CreateMessageRequestParamsSchema:kr,CreateMessageRequestSchema:$r,CreateMessageResultSchema:Cr,CreateMessageResultWithToolsSchema:Ir,BooleanSchemaSchema:Or,StringSchemaSchema:Mr,NumberSchemaSchema:Ar,UntitledSingleSelectEnumSchemaSchema:Nr,TitledSingleSelectEnumSchemaSchema:qr,LegacyTitledEnumSchemaSchema:jr,SingleSelectEnumSchemaSchema:Lr,UntitledMultiSelectEnumSchemaSchema:Gt,TitledMultiSelectEnumSchemaSchema:Wt,MultiSelectEnumSchemaSchema:ci,EnumSchemaSchema:li,PrimitiveSchemaDefinitionSchema:et,ElicitRequestFormParamsSchema:tt,ElicitRequestURLParamsSchema:Ur,ElicitRequestParamsSchema:it,ElicitRequestSchema:ui,ElicitationCompleteNotificationParamsSchema:di,ElicitationCompleteNotificationSchema:pi,ElicitResultSchema:hi,ResourceTemplateReferenceSchema:mi,PromptReferenceSchema:fi,CompleteRequestParamsSchema:gi,CompleteRequestSchema:Zr,CompleteResultSchema:Si,RootSchema:_i,ListRootsRequestSchema:To,ListRootsResultSchema:Dr,RootsListChangedNotificationSchema:bi,TaskCreationParamsSchema:yi,TaskStatusSchema:Vr,TaskSchema:$t,CreateTaskResultSchema:Ye,TaskStatusNotificationParamsSchema:vi,TaskStatusNotificationSchema:Kt,GetTaskRequestSchema:ko,GetTaskResultSchema:$o,GetTaskPayloadRequestSchema:Co,GetTaskPayloadResultSchema:Ia,ListTasksRequestSchema:Ge,ListTasksResultSchema:qe,CancelTaskRequestSchema:Yt,CancelTaskResultSchema:f.merge($t),ClientRequestSchema:A([ue,se,Zr,vr,Be,Z,pe,Ne,Xe,y,N,br,Ro,ko,Co,Ge,Yt]),ClientNotificationSchema:A([b,Pe,be,bi,Kt]),ClientResultSchema:A([_,Cr,Ir,hi,Dr,$o,qe,Ye]),ServerRequestSchema:A([ue,$r,ui,To,ko,Co,Ge,Yt]),ServerNotificationSchema:A([b,Pe,wr,j,he,ii,Jt,Kt,pi]),ServerResultSchema:A([_,ne,Si,zo,D,ze,Ze,st,Eo,xo,$o,qe,Ye]),CallToolResultWireSchema:V().superRefine((Fe,Sf)=>{if(typeof Fe!=="object"||Fe===null||Array.isArray(Fe)||Fe.content!==void 0)return;for(let wl of Qh)if(wl in Fe){Sf.addIssue({code:"custom",message:`content is required when the body carries '${wl}' — another result family cannot default into an empty tools/call success`});return}}).transform(Kg).pipe(Eo)}}var Qg;function Xh(){return Qg??=Yg()}function em(e){return e.type!=="object"}var Xg=new Set(["const","enum","default","examples"]),eS=new Set(["properties","patternProperties","$defs","definitions","dependentSchemas","dependencies"]);function qh(e){return e!==void 0&&!(typeof e==="string"&&e.startsWith("#"))}function tS(e){let t=typeof e.$schema==="string"?e.$schema:void 0;if(qh(e.$id))return{...t!==void 0&&{$schema:t},type:"object",properties:{result:e},required:["result"]};let o=Tl(e.$schema)&&e.$recursiveAnchor!==!0,r=(n,i)=>{if(Array.isArray(n))return n.map((l)=>r(l,!1));if(n===null||typeof n!=="object")return n;if(!i&&qh(n.$id))return n;let s={},a=!1;for(let[l,u]of Object.entries(n))if(i)s[l]=r(u,!1);else if((l==="$ref"||l==="$dynamicRef")&&typeof u==="string")s[l]=u==="#"?"#/properties/result":u.startsWith("#/")?`#/properties/result${u.slice(1)}`:u;else if(l==="$recursiveRef"&&u==="#"&&o)a=!0;else if(Xg.has(l))s[l]=u;else if(eS.has(l))s[l]=r(u,!0);else s[l]=r(u,!1);if(a)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 tm={ping:null,initialize:null,"completion/complete":null,"logging/setLevel":null,"prompts/get":null,"prompts/list":null,"resources/list":null,"resources/templates/list":null,"resources/read":null,"resources/subscribe":null,"resources/unsubscribe":null,"tools/call":null,"tools/list":null,"tasks/get":null,"tasks/result":null,"tasks/list":null,"tasks/cancel":null,"sampling/createMessage":null,"elicitation/create":null,"roots/list":null},om={"notifications/cancelled":null,"notifications/progress":null,"notifications/initialized":null,"notifications/roots/list_changed":null,"notifications/tasks/status":null,"notifications/message":null,"notifications/resources/updated":null,"notifications/resources/list_changed":null,"notifications/tools/list_changed":null,"notifications/prompts/list_changed":null,"notifications/elicitation/complete":null},oS={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},ba;function nl(){if(ba)return ba;let e=Xh();return ba={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}},ba}function rm(e){return Object.prototype.hasOwnProperty.call(tm,e)}function nm(e){return Object.prototype.hasOwnProperty.call(om,e)}function rS(e){return Object.prototype.hasOwnProperty.call(oS,e)}function nS(e){return rS(e)?nl().resultSchemas[e]:void 0}function sS(e){return rm(e)?nl().requestSchemas[e]:void 0}function iS(e){return nm(e)?nl().notificationSchemas[e]:void 0}var xz=Object.keys(tm),Ez=Object.keys(om);function Qc(e){return e!==null&&typeof e==="object"&&!Array.isArray(e)}function ya(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 jh={ok:!1,reason:"not-in-era"};function Lh(e){return Qc(e)&&Qc(e.outputSchema)&&em(e.outputSchema)}function Uh(e){return e}var sl={era:"2025-11-25",hasRequestMethod:rm,hasNotificationMethod:nm,validateRequest:(e,t)=>ya(sS(e),t),validateResult:(e,t)=>ya(nS(e),t),validateNotification:(e,t)=>ya(iS(e),t),hasInputRequestMethod:()=>!1,validateInputRequest:()=>jh,validateInputResponse:()=>jh,samplingResultVariant:(e,t)=>{let o=Xh();return ya(e?o.CreateMessageResultWithToolsSchema:o.CreateMessageResultSchema,t)},outboundEnvelope:(e)=>{return},validateEnvelopeMeta:(e)=>[],projectCallToolResult(e,t){let o=Yh(e),r=o.structuredContent;if(r===void 0)return o;let n=typeof r!=="object"||r===null||Array.isArray(r),i=t!==void 0&&em(t);if(!n&&!i)return o;return{...o,structuredContent:{result:r}}},decodeResult(e,t){if(Qc(t)&&"resultType"in t){let o={...t};return delete o.resultType,{kind:"complete",result:Uh(o)}}return{kind:"complete",result:Uh(t)}},encodeResult(e,t){if(e!=="tools/list")return t;let o=t.tools;if(!Array.isArray(o)||!o.some((r)=>Lh(r)))return t;return{...t,tools:o.map((r)=>Lh(r)?{...r,outputSchema:tS(r.outputSchema)}:r)}},encodeErrorCode:(e)=>e===-32002?-32602:e,checkInboundEnvelope:(e)=>{return}};function aS(){let e=nn(()=>A([c(),R(),M(),oo(),O(c(),e),S(e)])),t=O(c(),e),o=A([c(),R().int()]),r=c(),n=A([c(),R().int()]),i=oe(["user","assistant"]),s=oe(["debug","info","notice","warning","error","critical","alert","emergency"]),a=c().refine((qe)=>{try{return atob(qe),!0}catch{return!1}},{message:"Invalid Base64 string"}),l=d({ttl:R().optional()}),u=d({taskId:c()}),m=K({progressToken:o.optional(),"io.modelcontextprotocol/related-task":u.optional()}),h=d({_meta:m.optional()}),f=h.extend({task:l.optional()}),g=d({_meta:m.optional()}),_=d({method:c(),params:g.loose().optional()}),z=d({src:c(),mimeType:c().optional(),sizes:S(c()).optional(),theme:oe(["light","dark"]).optional()}),b=d({icons:S(z).optional()}),w=d({name:c(),title:c().optional()}),C=w.extend({...w.shape,...b.shape,version:c(),websiteUrl:c().optional(),description:c().optional()}),x=bt(d({applyDefaults:M().optional()}),t),T=ro((qe)=>{if(qe&&typeof qe==="object"&&!Array.isArray(qe)&&Object.keys(qe).length===0)return{form:{}};return qe},bt(d({form:x.optional(),url:t.optional()}),t.optional())),q=K({list:t.optional(),cancel:t.optional(),requests:K({sampling:K({createMessage:t.optional()}).optional(),elicitation:K({create:t.optional()}).optional()}).optional()}),B=K({list:t.optional(),cancel:t.optional(),requests:K({tools:K({call:t.optional()}).optional()}).optional()}),ee=d({experimental:O(c(),t).optional(),sampling:d({context:t.optional(),tools:t.optional()}).optional(),elicitation:T.optional(),roots:d({listChanged:M().optional()}).optional(),tasks:q.optional(),extensions:O(c(),t).optional()}),re=d({experimental:O(c(),t).optional(),logging:t.optional(),completions:t.optional(),prompts:d({listChanged:M().optional()}).optional(),resources:d({subscribe:M().optional(),listChanged:M().optional()}).optional(),tools:d({listChanged:M().optional()}).optional(),tasks:B.optional(),extensions:O(c(),t).optional()}),le=d({progress:R(),total:J(R()),message:J(c())}),ve=d({...g.shape,...le.shape,progressToken:o}),se=_.extend({method:p("notifications/progress"),params:ve}),te=g.extend({level:s,logger:c().optional(),data:V()}),ne=_.extend({method:p("notifications/message"),params:te}),be=d({uri:c(),mimeType:J(c()),_meta:O(c(),V()).optional()}),ue=be.extend({text:c()}),de=be.extend({blob:a}),Ee=d({audience:S(i).optional(),priority:R().min(0).max(1).optional(),lastModified:No({offset:!0}).optional()}),Pe=d({...w.shape,...b.shape,uri:c(),description:J(c()),mimeType:J(c()),size:J(R()),annotations:Ee.optional(),_meta:J(K({}))}),Ae=d({...w.shape,...b.shape,uriTemplate:c(),description:J(c()),mimeType:J(c()),annotations:Ee.optional(),_meta:J(K({}))}),W=_.extend({method:p("notifications/resources/list_changed"),params:g.optional()}),ie=g.extend({uri:c()}),E=_.extend({method:p("notifications/resources/updated"),params:ie}),U=d({name:c(),description:J(c()),required:J(M())}),Q=d({...w.shape,...b.shape,description:J(c()),arguments:J(S(U)),_meta:J(K({}))}),G=_.extend({method:p("notifications/prompts/list_changed"),params:g.optional()}),$e=d({type:p("text"),text:c(),annotations:Ee.optional(),_meta:O(c(),V()).optional()}),fe=d({type:p("image"),data:a,mimeType:c(),annotations:Ee.optional(),_meta:O(c(),V()).optional()}),ye=d({type:p("audio"),data:a,mimeType:c(),annotations:Ee.optional(),_meta:O(c(),V()).optional()}),je=d({type:p("tool_use"),name:c(),id:c(),input:O(c(),V()),_meta:O(c(),V()).optional()}),pe=d({type:p("resource"),resource:A([ue,de]),annotations:Ee.optional(),_meta:O(c(),V()).optional()}),ze=Pe.extend({type:p("resource_link")}),Ne=A([$e,fe,ye,ze,pe]),Ze=d({role:i,content:Ne}),ge=d({title:c().optional(),readOnlyHint:M().optional(),destructiveHint:M().optional(),idempotentHint:M().optional(),openWorldHint:M().optional()}),ae=_.extend({method:p("notifications/tools/list_changed"),params:g.optional()}),Xe=d({name:c().optional()}),st=d({hints:S(Xe).optional(),costPriority:R().min(0).max(1).optional(),speedPriority:R().min(0).max(1).optional(),intelligencePriority:R().min(0).max(1).optional()}),he=d({mode:oe(["auto","required","none"]).optional()}),ce=d({type:p("boolean"),title:c().optional(),description:c().optional(),default:M().optional()}),y=d({type:p("string"),title:c().optional(),description:c().optional(),minLength:R().optional(),maxLength:R().optional(),format:oe(["email","uri","date","date-time"]).optional(),default:c().optional()}),X=d({type:oe(["number","integer"]),title:c().optional(),description:c().optional(),minimum:R().optional(),maximum:R().optional(),default:R().optional()}),N=d({type:p("string"),title:c().optional(),description:c().optional(),enum:S(c()),default:c().optional()}),I=d({type:p("string"),title:c().optional(),description:c().optional(),oneOf:S(d({const:c(),title:c()})),default:c().optional()}),j=d({type:p("string"),title:c().optional(),description:c().optional(),enum:S(c()),enumNames:S(c()).optional(),default:c().optional()}),k=A([N,I]),P=d({type:p("array"),title:c().optional(),description:c().optional(),minItems:R().optional(),maxItems:R().optional(),items:d({type:p("string"),enum:S(c())}),default:S(c()).optional()}),Z=d({type:p("array"),title:c().optional(),description:c().optional(),minItems:R().optional(),maxItems:R().optional(),items:d({anyOf:S(d({const:c(),title:c()}))}),default:S(c()).optional()}),D=A([P,Z]),Se=A([j,k,D]),Be=A([Se,ce,y,X]),rt=f.extend({mode:p("form").optional(),message:c(),requestedSchema:d({type:p("object"),properties:O(c(),Be),required:S(c()).optional()}).catchall(V())}),Ht=d({type:p("ref/resource"),uri:c()}),Ft=d({type:p("ref/prompt"),name:c()}),gr=d({uri:c().startsWith("file://"),name:c().optional(),_meta:O(c(),V()).optional()}),Tt=ee.shape,Sr=d({experimental:Tt.experimental,sampling:Tt.sampling,elicitation:Tt.elicitation,roots:Tt.roots,extensions:Tt.extensions}),nt=re.shape,vo=d({experimental:nt.experimental,logging:nt.logging,completions:nt.completions,prompts:nt.prompts,resources:nt.resources,tools:nt.tools,extensions:nt.extensions}),zo=K({progressToken:o.optional(),[no]:c(),[jo]:C.optional(),[so]:Sr,[Uo]:s.optional()}),Jt=d({...w.shape,...b.shape,description:c().optional(),inputSchema:K({$schema:c().optional(),type:p("object")}),outputSchema:K({$schema:c().optional()}).optional(),annotations:ge.optional(),_meta:O(c(),V()).optional()}),_r=d({type:p("tool_result"),toolUseId:c(),content:S(Ne),structuredContent:V().optional(),isError:M().optional(),_meta:O(c(),V()).optional()}),wo=A([$e,fe,ye,je,_r]),Bt=d({role:i,content:A([wo,S(wo)]),_meta:O(c(),V()).optional()}),Ro=c(),xo=K({[ht]:C.optional().catch(void 0)}),Eo=xo.optional();function He(qe){return K({_meta:Eo,resultType:Ro.default("complete"),...qe})}let br=He({}),ii=He({nextCursor:r.optional()}),Po=He({content:S(Ne),structuredContent:V().optional(),isError:M().optional()}),yr=He({ttlMs:R().int().min(0),cacheScope:oe(["public","private"]),tools:S(Jt),nextCursor:r.optional()}),vr=He({ttlMs:R().int().min(0),cacheScope:oe(["public","private"]),prompts:S(Q),nextCursor:r.optional()}),zr=He({description:c().optional(),messages:S(Ze)}),wr=He({ttlMs:R().int().min(0),cacheScope:oe(["public","private"]),resources:S(Pe),nextCursor:r.optional()}),Rr=He({ttlMs:R().int().min(0),cacheScope:oe(["public","private"]),resourceTemplates:S(Ae),nextCursor:r.optional()}),xr=He({ttlMs:R().int().min(0),cacheScope:oe(["public","private"]),contents:S(A([ue,de]))}),Er=He({completion:d({values:S(c()).max(100),total:R().int().optional(),hasMore:M().optional()}).loose()}),ai=He({ttlMs:R().int().min(0),cacheScope:oe(["public","private"])}),Pr=He({ttlMs:R().int().min(0).catch(0),cacheScope:oe(["public","private"]).catch("private"),supportedVersions:S(c()),capabilities:vo,instructions:c().optional()}),kt=d({messages:S(Bt),modelPreferences:st.optional(),systemPrompt:c().optional(),includeContext:oe(["none","thisServer","allServers"]).optional(),temperature:R().optional(),maxTokens:R().int(),stopSequences:S(c()).optional(),metadata:t.optional(),tools:S(Jt).optional(),toolChoice:he.optional()}),Tr=d({method:p("sampling/createMessage"),params:kt}),kr=d({method:p("roots/list"),params:d({_meta:O(c(),V()).optional()}).optional()}),$r=d({...Bt.shape,model:c(),stopReason:c().optional()}),Cr=d({roots:S(gr)}),Ir=d({action:oe(["accept","decline","cancel"]),content:O(c(),A([c(),R(),M(),S(c())])).optional()}),Or=d({mode:p("url"),message:c(),url:c().url()}),Mr=A([rt,Or]),Ar=d({method:p("elicitation/create"),params:Mr}),Nr=A([Tr,kr,Ar]),qr=A([$r,Cr,Ir]),jr=O(c(),Nr),Lr=O(c(),qr),Gt=He({inputRequests:jr.optional(),requestState:c().optional()}),Wt={inputResponses:Lr.optional(),requestState:c().optional()},ci=d({_meta:zo,...Wt}),li=K({progressToken:o.optional()});function et(qe,Yt){return d({method:p(qe),params:d({_meta:zo,...Yt})})}function tt(qe,Yt){return d({method:p(qe),params:d({_meta:li.optional(),...Yt}).optional()})}let Ur={name:c(),arguments:O(c(),V()).optional(),...Wt},it={cursor:r.optional()},ui=et("tools/call",Ur),di=et("tools/list",it),pi=et("prompts/list",it),hi=et("prompts/get",{name:c(),arguments:O(c(),c()).optional(),...Wt}),mi=et("resources/list",it),fi=et("resources/templates/list",it),gi=et("resources/read",{uri:c(),...Wt}),Zr={ref:A([Ft,Ht]),argument:d({name:c(),value:c()}),context:d({arguments:O(c(),c()).optional()}).optional()},Si=et("completion/complete",Zr),_i=et("server/discover",{}),To=d({toolsListChanged:M().optional(),promptsListChanged:M().optional(),resourcesListChanged:M().optional(),resourceSubscriptions:S(c()).optional()}),Dr={notifications:To},bi=et("subscriptions/listen",Dr),yi=xo.extend({"io.modelcontextprotocol/subscriptionId":n}),Vr=K({_meta:yi,resultType:Ro.default("complete")}),$t={"tools/call":tt("tools/call",Ur),"tools/list":tt("tools/list",it),"prompts/get":tt("prompts/get",{name:c(),arguments:O(c(),c()).optional()}),"prompts/list":tt("prompts/list",it),"resources/list":tt("resources/list",it),"resources/templates/list":tt("resources/templates/list",it),"resources/read":tt("resources/read",{uri:c()}),"completion/complete":tt("completion/complete",Zr),"server/discover":tt("server/discover",{}),"subscriptions/listen":tt("subscriptions/listen",Dr)};function Ye(qe){return K({_meta:Eo,...qe})}let vi={"tools/call":Ye({content:S(Ne),structuredContent:V().optional(),isError:M().optional()}),"tools/list":Ye({ttlMs:R().int().min(0),cacheScope:oe(["public","private"]),tools:S(Jt),nextCursor:r.optional()}),"prompts/get":Ye({description:c().optional(),messages:S(Ze)}),"prompts/list":Ye({ttlMs:R().int().min(0),cacheScope:oe(["public","private"]),prompts:S(Q),nextCursor:r.optional()}),"resources/list":Ye({ttlMs:R().int().min(0),cacheScope:oe(["public","private"]),resources:S(Pe),nextCursor:r.optional()}),"resources/templates/list":Ye({ttlMs:R().int().min(0),cacheScope:oe(["public","private"]),resourceTemplates:S(Ae),nextCursor:r.optional()}),"resources/read":Ye({ttlMs:R().int().min(0),cacheScope:oe(["public","private"]),contents:S(A([ue,de]))}),"completion/complete":Ye({completion:d({values:S(c()).max(100),total:R().int().optional(),hasMore:M().optional()}).loose()}),"server/discover":Ye({ttlMs:R().int().min(0).catch(0),cacheScope:oe(["public","private"]).catch("private"),supportedVersions:S(c()),capabilities:vo,instructions:c().optional()}),"subscriptions/listen":Ye({})},Kt=K({"io.modelcontextprotocol/subscriptionId":n.optional()}),ko=d({method:p("notifications/subscriptions/acknowledged"),params:d({_meta:Kt.optional(),notifications:To})}),$o=d({_meta:Kt.optional(),requestId:n,reason:c().optional()}),Co=d({method:p("notifications/cancelled"),params:$o}),Ia={"notifications/cancelled":Co,"notifications/progress":se,"notifications/message":ne,"notifications/resources/updated":E,"notifications/resources/list_changed":W,"notifications/tools/list_changed":ae,"notifications/prompts/list_changed":G,"notifications/subscriptions/acknowledged":ko},Ge=(qe)=>d({jsonrpc:p("2.0"),id:A([c(),R().int()]),result:qe}).strict();return{JSONValueSchema:e,JSONObjectSchema:t,ProgressTokenSchema:o,CursorSchema:r,RequestIdSchema:n,RoleSchema:i,LoggingLevelSchema:s,TaskMetadataSchema:l,RelatedTaskMetadataSchema:u,RequestMetaSchema:m,BaseRequestParamsSchema:h,TaskAugmentedRequestParamsSchema:f,NotificationsParamsSchema:g,NotificationSchema:_,IconSchema:z,IconsSchema:b,BaseMetadataSchema:w,ImplementationSchema:C,ClientTasksCapabilitySchema:q,ServerTasksCapabilitySchema:B,ClientCapabilitiesSchema:ee,ServerCapabilitiesSchema:re,ProgressSchema:le,ProgressNotificationParamsSchema:ve,ProgressNotificationSchema:se,LoggingMessageNotificationParamsSchema:te,LoggingMessageNotificationSchema:ne,ResourceContentsSchema:be,TextResourceContentsSchema:ue,BlobResourceContentsSchema:de,AnnotationsSchema:Ee,ResourceSchema:Pe,ResourceTemplateSchema:Ae,ResourceListChangedNotificationSchema:W,ResourceUpdatedNotificationParamsSchema:ie,ResourceUpdatedNotificationSchema:E,PromptArgumentSchema:U,PromptSchema:Q,PromptListChangedNotificationSchema:G,TextContentSchema:$e,ImageContentSchema:fe,AudioContentSchema:ye,ToolUseContentSchema:je,EmbeddedResourceSchema:pe,ResourceLinkSchema:ze,ContentBlockSchema:Ne,PromptMessageSchema:Ze,ToolAnnotationsSchema:ge,ToolListChangedNotificationSchema:ae,ModelHintSchema:Xe,ModelPreferencesSchema:st,ToolChoiceSchema:he,BooleanSchemaSchema:ce,StringSchemaSchema:y,NumberSchemaSchema:X,UntitledSingleSelectEnumSchemaSchema:N,TitledSingleSelectEnumSchemaSchema:I,LegacyTitledEnumSchemaSchema:j,SingleSelectEnumSchemaSchema:k,UntitledMultiSelectEnumSchemaSchema:P,TitledMultiSelectEnumSchemaSchema:Z,MultiSelectEnumSchemaSchema:D,EnumSchemaSchema:Se,PrimitiveSchemaDefinitionSchema:Be,ElicitRequestFormParamsSchema:rt,ResourceTemplateReferenceSchema:Ht,PromptReferenceSchema:Ft,RootSchema:gr,ClientCapabilities2026Schema:Sr,ServerCapabilities2026Schema:vo,RequestMetaEnvelopeSchema:zo,ToolSchema:Jt,ToolResultContentSchema:_r,SamplingMessageContentBlockSchema:wo,SamplingMessageSchema:Bt,ResultTypeSchema:Ro,ResultMetaSchema:xo,ResultSchema:br,PaginatedResultSchema:ii,CallToolResultSchema:Po,ListToolsResultSchema:yr,ListPromptsResultSchema:vr,GetPromptResultSchema:zr,ListResourcesResultSchema:wr,ListResourceTemplatesResultSchema:Rr,ReadResourceResultSchema:xr,CompleteResultSchema:Er,CacheableResultSchema:ai,DiscoverResultSchema:Pr,CreateMessageRequestParamsSchema:kt,CreateMessageRequestSchema:Tr,ListRootsRequestSchema:kr,CreateMessageResultSchema:$r,ListRootsResultSchema:Cr,ElicitResultSchema:Ir,ElicitRequestURLParamsSchema:Or,ElicitRequestParamsSchema:Mr,ElicitRequestSchema:Ar,InputRequestSchema:Nr,InputResponseSchema:qr,InputRequestsSchema:jr,InputResponsesSchema:Lr,InputRequiredResultSchema:Gt,InputResponseRequestParamsSchema:ci,CallToolRequestSchema:ui,ListToolsRequestSchema:di,ListPromptsRequestSchema:pi,GetPromptRequestSchema:hi,ListResourcesRequestSchema:mi,ListResourceTemplatesRequestSchema:fi,ReadResourceRequestSchema:gi,CompleteRequestSchema:Si,DiscoverRequestSchema:_i,SubscriptionFilterSchema:To,SubscriptionsListenRequestSchema:bi,SubscriptionsListenResultMetaSchema:yi,SubscriptionsListenResultSchema:Vr,dispatchRequestSchemas:$t,dispatchResultSchemas:vi,NotificationMetaSchema:Kt,SubscriptionsAcknowledgedNotificationSchema:ko,CancelledNotificationParamsSchema:$o,CancelledNotificationSchema:Co,notificationSchemas2026:Ia,JSONRPCResultResponseSchema:Ge(br),CallToolResultResponseSchema:Ge(A([Po,Gt])),ListToolsResultResponseSchema:Ge(yr),ListPromptsResultResponseSchema:Ge(vr),GetPromptResultResponseSchema:Ge(A([zr,Gt])),ListResourcesResultResponseSchema:Ge(wr),ListResourceTemplatesResultResponseSchema:Ge(Rr),ReadResourceResultResponseSchema:Ge(A([xr,Gt])),CompleteResultResponseSchema:Ge(Er),DiscoverResultResponseSchema:Ge(Pr),SubscriptionsListenResultResponseSchema:Ge(Vr)}}var cS;function Dt(){return cS??=aS()}var lS=["tools/list","prompts/list","resources/list","resources/templates/list","resources/read","server/discover"];function uS(e){return lS.includes(e)}var il=Symbol("modelcontextprotocol.resultCacheHintFallback");function dS(e){return e[il]}function sm(e){return typeof e==="number"&&Number.isSafeInteger(e)&&e>=0}function im(e){return e==="public"||e==="private"}var Y=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}({}),_e=class e extends Error{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.ProtocolError"})}static[Symbol.hasInstance](t){return Qe(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 Qe(this,t)}constructor(t,o,r){super(o);this.code=t,this.data=r,this.name="ProtocolError",Vt(this,new.target)}static fromError(t,o,r){if(t===Y.UrlElicitationRequired&&r){let n=r;if(n.elicitations)return new cm(n.elicitations,o)}if(t===Y.UnsupportedProtocolVersion&&r){let n=r;if(Array.isArray(n.supported)&&typeof n.requested==="string")return new Xs({supported:n.supported,requested:n.requested},o)}if(t===Y.InvalidParams||t===Y.ResourceNotFound){let n=r;if(typeof n?.uri==="string"&&(t===Y.ResourceNotFound||Object.keys(n).length===1))return new am(n.uri,o)}if(t===Y.MissingRequiredClientCapability&&r){let n=r;if(n.requiredCapabilities!==null&&typeof n.requiredCapabilities==="object"&&!Array.isArray(n.requiredCapabilities))return new lm({requiredCapabilities:n.requiredCapabilities},o)}return new e(t,o,r)}},am=class extends _e{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.ResourceNotFoundError"})}constructor(e,t=`Resource not found: ${e}`){super(Y.InvalidParams,t,{uri:e})}get uri(){return this.data.uri}},cm=class extends _e{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.UrlElicitationRequiredError"})}constructor(e,t=`URL elicitation${e.length>1?"s":""} required`){super(Y.UrlElicitationRequired,t,{elicitations:e})}get elicitations(){return this.data?.elicitations??[]}},Xs=class extends _e{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.UnsupportedProtocolVersionError"})}constructor(e,t=`Unsupported protocol version: ${e.requested}`){super(Y.UnsupportedProtocolVersion,t,e)}get supported(){return this.data.supported}get requested(){return this.data.requested}},lm=class extends _e{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.MissingRequiredClientCapabilityError"})}constructor(e,t=`Missing required client capabilities: ${Object.keys(e.requiredCapabilities).join(", ")}`){super(Y.MissingRequiredClientCapability,t,e)}get requiredCapabilities(){return this.data.requiredCapabilities}},pS=0,hS="private",mS=["tools/call","prompts/get","resources/read"];function fS(e,t){let o=t.resultType;if(o===void 0)return{...t,resultType:"complete"};if(o==="complete")return t;if(mS.includes(e))return t;throw new _e(Y.InternalError,`Handler for ${e} returned resultType '${String(o)}', but results of ${e} only support 'complete' on protocol revision 2026-07-28`)}function gS(e,t){let o=dS(t);if(t.resultType!=="complete"||!uS(e))return o===void 0?t:vS(t);let r=t,n=sm(r.ttlMs)?r.ttlMs:bS(o),i=im(r.cacheScope)?r.cacheScope:yS(o),s={...r,ttlMs:n,cacheScope:i};return delete s[il],s}function SS(e){return e!==null&&typeof e==="object"&&!Array.isArray(e)}function _S(e,t){if(t===void 0)return e;let o=e._meta;if(o===void 0)return{...e,_meta:{[ht]:t}};if(!SS(o))return e;if(o[ht]!==void 0)return e;return{...e,_meta:{...o,[ht]:t}}}function bS(e){return e!==void 0&&sm(e.ttlMs)?e.ttlMs:pS}function yS(e){return e!==void 0&&im(e.cacheScope)?e.cacheScope:hS}function vS(e){let t={...e};return delete t[il],t}var zS=["elicitation/create","sampling/createMessage","roots/list"],va;function um(){if(va)return va;let e=Dt();return va={request:{"elicitation/create":d({method:p("elicitation/create"),params:e.ElicitRequestParamsSchema}),"sampling/createMessage":d({method:p("sampling/createMessage"),params:e.CreateMessageRequestParamsSchema}),"roots/list":d({method:p("roots/list"),params:K({}).optional()})},response:{"elicitation/create":e.ElicitResultSchema,"sampling/createMessage":e.CreateMessageResultSchema,"roots/list":e.ListRootsResultSchema}},va}function dm(e){return zS.includes(e)}function Bc(e){return dm(e)?um().request[e]:void 0}function wS(e){return dm(e)?um().response[e]:void 0}var al={"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},pm={"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 hm(e){return Object.prototype.hasOwnProperty.call(al,e)}function mm(e){return Object.prototype.hasOwnProperty.call(pm,e)}function RS(e){return Object.prototype.hasOwnProperty.call(al,e)}function xS(e){return hm(e)?Dt().dispatchRequestSchemas[e]:void 0}function ES(e){return RS(e)?Dt().dispatchResultSchemas[e]:void 0}function PS(e){return mm(e)?Dt().notificationSchemas2026[e]:void 0}var Pz=Object.keys(al),Tz=Object.keys(pm);function Gs(e){return e!==null&&typeof e==="object"&&!Array.isArray(e)}function Js(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 TS={ok:!1,reason:"not-in-era"},kS=[no,so];function $S(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((a)=>Gs(a)&&("execution"in a)))n().tools=i.map((a)=>{if(!Gs(a)||!("execution"in a))return a;let l={...a};return delete l.execution,l});let s=t.capabilities;if(Gs(s)&&"tasks"in s){let a={...s};delete a.tasks,n().capabilities=a}return o}var cl={era:"2026-07-28",hasRequestMethod:hm,hasNotificationMethod:mm,hasInputRequestMethod:(e)=>Bc(e)!==void 0,validateRequest:(e,t)=>Js(xS(e),t),validateResult:(e,t)=>Js(ES(e),t),validateNotification:(e,t)=>Js(PS(e),t),validateInputRequest:(e,t)=>Js(Bc(e),t),validateInputResponse:(e,t)=>Js(wS(e),t),samplingResultVariant:()=>TS,outboundEnvelope(e){return{[no]:e.protocolVersion,[jo]:e.clientInfo,[so]:e.clientCapabilities,...e.logLevel!==void 0&&{[Uo]:e.logLevel}}},validateEnvelopeMeta(e){let t=[];for(let r of kS)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((s)=>s.key===i&&s.problem==="missing"))continue;t.push({key:i,problem:r.message})}return t},projectCallToolResult:(e)=>Yh(e),inputRequestSchema:Bc,decodeResult(e,t){if(!Gs(t))return{kind:"invalid",error:new L(F.InvalidResult,`Invalid result for ${e}: not an object`,{method:e})};let o=t.resultType;if(o===void 0)return{kind:"invalid",error:new L(F.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 L(F.InvalidResult,`Invalid result for ${e}: non-string resultType`,{method:e,resultType:o})};if(o==="input_required"){let s=t.inputRequests,a=Gs(s)?s:{},l=t.requestState,u=t._meta===void 0?void 0:Dt().ResultMetaSchema.safeParse(t._meta),m=u?.success?u.data:void 0;if(Object.keys(a).length===0&&typeof l!=="string")return{kind:"invalid",error:new L(F.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:a,...typeof l==="string"&&{requestState:l},...m!==void 0&&{_meta:m}}}if(o!=="complete")return{kind:"invalid",error:new L(F.UnsupportedResultType,`Unsupported result type '${o}' for ${e}`,{resultType:o,method:e})};let r=CS(),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 L(F.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 _S(gS(e,fS(e,$S(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("; ")}`}},za;function CS(){if(za)return za;let e=Dt();return za={"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},za}var xa="2026-07-28";function Et(e){return e!==void 0&&Pt(e)?cl:sl}function Zh(e){if(e.revision!==void 0)return Et(e.revision).era;return e.era==="modern"?cl.era:sl.era}function Gc(e){return fm.some((t)=>t.hasRequestMethod(e))}function Wc(e){return fm.some((t)=>t.hasNotificationMethod(e))}function Dh(e){return e==="tasks/get"||e==="tasks/cancel"}var fm=[sl,cl],IS=xl({AnnotationsSchema:()=>ft,AudioContentSchema:()=>mo,BaseMetadataSchema:()=>pt,BaseRequestParamsSchema:()=>Le,BlobResourceContentsSchema:()=>Xo,BooleanSchemaSchema:()=>rr,CallToolRequestParamsSchema:()=>ts,CallToolRequestSchema:()=>os,CallToolResultSchema:()=>Zt,CancelTaskRequestSchema:()=>la,CancelTaskResultSchema:()=>ua,CancelledNotificationParamsSchema:()=>ln,CancelledNotificationSchema:()=>Bo,ClientCapabilitiesSchema:()=>dn,ClientNotificationSchema:()=>pa,ClientRequestSchema:()=>da,ClientResultSchema:()=>ha,ClientTasksCapabilitySchema:()=>Yi,CompatibilityCallToolResultSchema:()=>Xi,CompleteRequestParamsSchema:()=>$s,CompleteRequestSchema:()=>Cs,CompleteResultSchema:()=>Is,ContentBlockSchema:()=>gt,CreateMessageRequestParamsSchema:()=>fs,CreateMessageRequestSchema:()=>gs,CreateMessageResultSchema:()=>Ss,CreateMessageResultWithToolsSchema:()=>_s,CreateTaskResultSchema:()=>ta,CursorSchema:()=>Do,DiscoverRequestSchema:()=>gn,DiscoverResultSchema:()=>Lt,ElicitRequestFormParamsSchema:()=>bo,ElicitRequestParamsSchema:()=>ws,ElicitRequestSchema:()=>Rs,ElicitRequestURLParamsSchema:()=>zs,ElicitResultSchema:()=>Ps,ElicitationCompleteNotificationParamsSchema:()=>xs,ElicitationCompleteNotificationSchema:()=>Es,EmbeddedResourceSchema:()=>fo,EmptyResultSchema:()=>jt,EnumSchemaSchema:()=>vs,GetPromptRequestParamsSchema:()=>Fn,GetPromptRequestSchema:()=>Jn,GetPromptResultSchema:()=>Wn,GetTaskPayloadRequestSchema:()=>sa,GetTaskPayloadResultSchema:()=>ia,GetTaskRequestSchema:()=>ra,GetTaskResultSchema:()=>na,IconSchema:()=>un,IconsSchema:()=>vt,ImageContentSchema:()=>ho,ImplementationSchema:()=>mt,InitializeRequestParamsSchema:()=>pn,InitializeRequestSchema:()=>hn,InitializeResultSchema:()=>mn,InitializedNotificationSchema:()=>fn,JSONArraySchema:()=>Wi,JSONObjectSchema:()=>Ce,JSONRPCErrorResponseSchema:()=>co,JSONRPCMessageSchema:()=>lo,JSONRPCNotificationSchema:()=>Jo,JSONRPCRequestSchema:()=>Fo,JSONRPCResponseSchema:()=>Ki,JSONRPCResultResponseSchema:()=>ao,JSONValueSchema:()=>yt,LegacyTitledEnumSchemaSchema:()=>ir,ListChangedOptionsBaseSchema:()=>ns,ListPromptsRequestSchema:()=>Vn,ListPromptsResultSchema:()=>Hn,ListResourceTemplatesRequestSchema:()=>wn,ListResourceTemplatesResultSchema:()=>Rn,ListResourcesRequestSchema:()=>vn,ListResourcesResultSchema:()=>zn,ListRootsRequestSchema:()=>Ms,ListRootsResultSchema:()=>As,ListTasksRequestSchema:()=>aa,ListTasksResultSchema:()=>ca,ListToolsRequestSchema:()=>Xn,ListToolsResultSchema:()=>es,LoggingLevelSchema:()=>or,LoggingMessageNotificationParamsSchema:()=>as,LoggingMessageNotificationSchema:()=>cs,ModelHintSchema:()=>ls,ModelPreferencesSchema:()=>us,MultiSelectEnumSchemaSchema:()=>ys,NotificationSchema:()=>Ve,NotificationsParamsSchema:()=>Je,NumberSchemaSchema:()=>_o,PaginatedRequestParamsSchema:()=>bn,PaginatedRequestSchema:()=>zt,PaginatedResultSchema:()=>wt,PingRequestSchema:()=>Wo,PrimitiveSchemaDefinitionSchema:()=>lr,ProgressNotificationParamsSchema:()=>_n,ProgressNotificationSchema:()=>Ko,ProgressSchema:()=>Sn,ProgressTokenSchema:()=>Zo,PromptArgumentSchema:()=>Zn,PromptListChangedNotificationSchema:()=>Kn,PromptMessageSchema:()=>Gn,PromptReferenceSchema:()=>ks,PromptSchema:()=>Dn,ReadResourceRequestParamsSchema:()=>xn,ReadResourceRequestSchema:()=>En,ReadResourceResultSchema:()=>Pn,RelatedTaskMetadataSchema:()=>cn,RequestIdSchema:()=>lt,RequestMetaSchema:()=>Vo,RequestSchema:()=>Ie,ResourceContentsSchema:()=>Yo,ResourceLinkSchema:()=>go,ResourceListChangedNotificationSchema:()=>Tn,ResourceRequestParamsSchema:()=>uo,ResourceSchema:()=>er,ResourceTemplateReferenceSchema:()=>Ts,ResourceTemplateSchema:()=>yn,ResourceUpdatedNotificationParamsSchema:()=>Ln,ResourceUpdatedNotificationSchema:()=>Un,ResultMetaObjectSchema:()=>Ho,ResultSchema:()=>Oe,RoleSchema:()=>Rt,RootSchema:()=>Os,RootsListChangedNotificationSchema:()=>Ns,SamplingContentSchema:()=>hs,SamplingMessageContentBlockSchema:()=>Nt,SamplingMessageSchema:()=>ms,ServerCapabilitiesSchema:()=>Go,ServerNotificationSchema:()=>fa,ServerRequestSchema:()=>ma,ServerResultSchema:()=>ga,ServerTasksCapabilitySchema:()=>Qi,SetLevelRequestParamsSchema:()=>ss,SetLevelRequestSchema:()=>is,SingleSelectEnumSchemaSchema:()=>bs,StringSchemaSchema:()=>So,SubscribeRequestParamsSchema:()=>kn,SubscribeRequestSchema:()=>$n,SubscriptionFilterSchema:()=>tr,SubscriptionsAcknowledgedNotificationParamsSchema:()=>An,SubscriptionsAcknowledgedNotificationSchema:()=>Nn,SubscriptionsListenRequestParamsSchema:()=>On,SubscriptionsListenRequestSchema:()=>Mn,SubscriptionsListenResultMetaSchema:()=>qn,SubscriptionsListenResultSchema:()=>jn,TaskAugmentedRequestParamsSchema:()=>qt,TaskCreationParamsSchema:()=>ea,TaskMetadataSchema:()=>an,TaskSchema:()=>xt,TaskStatusNotificationParamsSchema:()=>js,TaskStatusNotificationSchema:()=>oa,TaskStatusSchema:()=>qs,TextContentSchema:()=>po,TextResourceContentsSchema:()=>Qo,TitledMultiSelectEnumSchemaSchema:()=>cr,TitledSingleSelectEnumSchemaSchema:()=>sr,ToolAnnotationsSchema:()=>Yn,ToolChoiceSchema:()=>ds,ToolExecutionSchema:()=>Qn,ToolListChangedNotificationSchema:()=>rs,ToolResultContentSchema:()=>ps,ToolSchema:()=>Ut,ToolUseContentSchema:()=>Bn,UnsubscribeRequestParamsSchema:()=>Cn,UnsubscribeRequestSchema:()=>In,UntitledMultiSelectEnumSchemaSchema:()=>ar,UntitledSingleSelectEnumSchemaSchema:()=>nr});var Ea=(e)=>Fo.safeParse(e).success,gm=(e)=>Jo.safeParse(e).success,mr=(e)=>ao.safeParse(e).success,ei=(e)=>co.safeParse(e).success;var Sm=(e)=>typeof e==="object"&&e!==null&&!Array.isArray(e)&&e.resultType==="input_required";var OS="Mcp-Param-",Vh="x-mcp-header",MS=/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/,AS=new Set(["string","integer","boolean"]);function ll(e){let t=[],o=new Map,r,n=(s,a,l)=>{if(s===null||typeof s!=="object")return;let u=s;if(Vh in u){if(!l||a.length===0)return`${wa(a)}: x-mcp-header is only permitted on properties statically reachable via a chain of 'properties' keys (not under items, additionalProperties, oneOf/anyOf/allOf/not, if/then/else, or $ref)`;let h=u[Vh];if(typeof h!=="string"||h.length===0)return`${wa(a)}: x-mcp-header MUST be a non-empty string`;if(!MS.test(h))return`${wa(a)}: x-mcp-header '${h}' is not a valid RFC 9110 token (no spaces, control characters or HTTP delimiters)`;let f=typeof u.type==="string"?u.type:void 0;if(f===void 0||!AS.has(f)){let z=`${wa(a)}: x-mcp-header is only permitted on primitive-typed properties (string, integer, boolean); got ${f??"<none>"}`;if(f!=="number")return z;r??=z}let g=h.toLowerCase(),_=o.get(g);if(_!==void 0)return`x-mcp-header '${h}' is not case-insensitively unique (also declared as '${_}')`;o.set(g,h),t.push({path:a,headerName:h,type:f})}let m=u.properties;if(m!==null&&typeof m==="object")for(let[h,f]of Object.entries(m)){let g=n(f,[...a,h],l);if(g!==void 0)return g}for(let h of NS){let f=u[h];if(f===void 0)continue;let g=Array.isArray(f)?f:f!==null&&typeof f==="object"&&qS.has(h)?Object.values(f):[f];for(let _ of g){let z=n(_,[...a,`<${h}>`],!1);if(z!==void 0)return z}}},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 NS=["items","prefixItems","contains","additionalProperties","unevaluatedProperties","unevaluatedItems","propertyNames","patternProperties","dependentSchemas","oneOf","anyOf","allOf","not","if","then","else","$defs","definitions"],qS=new Set(["patternProperties","dependentSchemas","$defs","definitions"]);function wa(e){return e.length===0?"<root>":e.join(".")}var _m="=?base64?",bm="?=";function jS(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 LS(e){if(e.length===0)return!0;if(e.startsWith(_m)&&e.endsWith(bm))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 US(e){let t=new TextEncoder().encode(e),o="";for(let r of t)o+=String.fromCodePoint(r);return btoa(o)}function ym(e){return LS(e)?`${_m}${US(e)}${bm}`:e}function ZS(e,t){let o=e;for(let r of t){if(o===null||typeof o!=="object")return;o=o[r]}return o}function vm(e,t){let o={};for(let r of e){let n=ZS(t,r.path);if(n===void 0||n===null)continue;let i=jS(n);if(i===void 0)continue;o[`${OS}${r.headerName}`]=ym(i)}return o}var hr=-32020,kz=[{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:[Y.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:[hr,Y.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:[Y.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:[Y.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:[Y.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:[hr],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:[Y.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:[hr],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."}],$z={[Y.ParseError]:400,[Y.InvalidRequest]:400,[Y.MethodNotFound]:404,[Y.UnsupportedProtocolVersion]:400,[Y.MissingRequiredClientCapability]:400,[hr]:400};function Pa(e,t){return Di(e,t)}function Bs(e){return new Set(e.flatMap((t)=>Object.keys(t.shape)))}function Xc(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 Hh=!1,el="draft-2020-12";function DS(e,t="input"){let o=e["~standard"],r;if(o.jsonSchema)r=o.jsonSchema[t]({target:el});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(!Hh)Hh=!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:el,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 zm(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 VS=/^#\/(\$defs|definitions)\/([^/~%]+)$/;function zm(e,t=e){if("properties"in e||"patternProperties"in e||"additionalProperties"in e||"required"in e)return!0;let o=typeof e.$ref==="string"&&VS.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"||zm(i,"$id"in i?{}:t)))}return!1}function HS(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 Kc(e,t){let o=await e["~standard"].validate(t);if(o.issues&&o.issues.length>0)return{success:!1,error:o.issues.map((r)=>HS(r)).join(", ")};return{success:!0,data:o.value}}function FS(e){let t=Ui(e,{target:el,io:"input"});return typeof t.pattern==="string"?t.pattern:void 0}var JS=/\\\.\\d\{(\d+)\}/;function BS(e){let t=JS.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)=>No({local:r,offset:n,precision:i}))))}function GS(e,t){let o;switch(e){case"email":o=[fh()];break;case"uri":o=[Hi()];break;case"date":o=[Uc()];break;case"date-time":o=BS(t);break}return new Set(o.map((r)=>FS(r)).filter((r)=>r!==void 0))}function WS(e,t,o){if(o!=="zod")return!0;return GS(e,t).has(t)}function Ks(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}function KS(e){try{return DS(e,"input")}catch(t){let o=t instanceof Error?t.message:String(t);throw new _e(Y.InvalidParams,`Elicitation requestedSchema must describe an object with flat primitive properties: ${o}`)}}var YS=new Set(["$comment","deprecated","description","examples","readOnly","title","writeOnly"]);function ul(e){return YS.has(e)||e.startsWith("x-")}var QS=new Set(["$schema",...Object.keys(bo.shape.requestedSchema.shape)]),Fh={string:Bs([So,nr,sr,ir]),number:Bs([_o]),integer:Bs([_o]),boolean:Bs([rr]),array:Bs([ar,cr])},XS=new Set(So.shape.format.unwrap().options);function e_(e,t,o,r){if(!Ks(e))return e;let n=typeof e.type==="string"&&Object.hasOwn(Fh,e.type)?Fh[e.type]:void 0;if(n===void 0)return e;let i={};for(let[s,a]of Object.entries(e))if(n.has(s)||ul(s))i[s]=a;else if(s==="pattern"&&e.type==="string"&&typeof e.format==="string"){if(!XS.has(e.format))i[s]=a;else if(typeof a!=="string"||!WS(e.format,a,o))r.push(`${t}.${s}`)}else r.push(`${t}.${s}`);return i}function t_(e,t){let o={},r=[];for(let[n,i]of Object.entries(e))if(n==="properties"&&Ks(i))o[n]=Object.fromEntries(Object.entries(i).map(([s,a])=>[s,e_(a,`properties.${s}`,t,r)]));else if(QS.has(n))o[n]=i;else if(!ul(n))r.push(n);if(r.length>0)throw new _e(Y.InvalidParams,`Elicitation requestedSchema contains unsupported JSON Schema constraint(s) after Standard Schema conversion: ${r.join(", ")}`);return o}function o_(e,t){if(!Ks(e.properties))return t;let o=Object.entries(e.properties).filter(([,r])=>!Pa(lr,r).success).map(([r])=>`properties.${r}`);return o.length>0?o.join(", "):t}function tl(e,t,o=""){if(Array.isArray(e)&&Array.isArray(t))return e.flatMap((r,n)=>tl(r,t[n],`${o}[${n}]`));if(!Ks(e)||!Ks(t))return[];return Object.entries(e).flatMap(([r,n])=>{let i=o?`${o}.${r}`:r;if(!Object.prototype.hasOwnProperty.call(t,r))return ul(r)?[]:[i];return tl(n,t[r],i)})}function r_(e){if(!Xc(e.requestedSchema))return{...e,mode:"form",requestedSchema:e.requestedSchema};let t=e.requestedSchema["~standard"].vendor,o=t_(KS(e.requestedSchema),t),r=Pa(bo.shape.requestedSchema,o);if(!r.success)throw new _e(Y.InvalidParams,`Elicitation requestedSchema only supports flat primitive properties (string, number, integer, boolean, and string enums): ${o_(o,r.error.message)}`);let n=tl(o,r.data);if(n.length>0)throw new _e(Y.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 _e(Y.InvalidParams,`Elicitation requestedSchema lists required properties that are not defined in properties: ${i.join(", ")}`);return{...e,mode:"form",requestedSchema:r.data}}function n_(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 Cz=Object.assign(n_,{elicit(e){try{return{method:"elicitation/create",params:r_(e)}}catch(t){throw t instanceof _e?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 s_=!0,i_=10,a_=250;function wm(e){return{autoFulfill:e?.autoFulfill??s_,maxRounds:e?.maxRounds??i_}}function c_(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 l_(e,t){return`Multi-round-trip request '${e}' still required input after ${t} rounds (inputRequired.maxRounds)`}function u_(e,t){return new Promise((o,r)=>{if(t?.aborted){r(t.reason instanceof L?t.reason:new L(F.RequestTimeout,String(t.reason)));return}let n=setTimeout(()=>{t?.removeEventListener("abort",i),o()},e),i=()=>{clearTimeout(n),r(t?.reason instanceof L?t.reason:new L(F.RequestTimeout,String(t?.reason)))};t?.addEventListener("abort",i,{once:!0})})}function d_(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,a=e.flowStartedAt??Date.now(),l=e.firstPayload,u=0;while(!0){if(u+=1,u>t.maxRounds)throw new L(F.InputRequiredRoundsExceeded,l_(o,t.maxRounds),{rounds:t.maxRounds,lastResult:{inputRequests:l.inputRequests,...l.requestState!==void 0&&{requestState:l.requestState}}});n.onprogress?.({progress:u,message:`Fulfilling input required by '${o}' (round ${u})`});let m=Object.entries(l.inputRequests??{}),h;if(m.length>0){let _=d_(s);try{let z=await Promise.all(m.map(async([b,w])=>{try{return[b,await i.dispatchInputRequest(b,w,_.signal)]}catch(C){throw _.abort(C),C}}));h=Object.fromEntries(z)}finally{_.dispose()}}else await u_(a_,s);let f={...n.timeout!==void 0&&{timeout:n.timeout}};if(n.maxTotalTimeout!==void 0){let _=Date.now()-a,z=n.maxTotalTimeout-_;if(z<=0)throw new L(F.RequestTimeout,"Maximum total timeout exceeded",{maxTotalTimeout:n.maxTotalTimeout,totalElapsed:_});f.maxTotalTimeout=z}let g=await i.retry(c_(r,h,l.requestState),f);if(Sm(g)){l={inputRequests:g.inputRequests??{},...g.requestState!==void 0&&{requestState:g.requestState}};continue}return g}}var h_=["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"],m_={IdJagTokenExchangeResponseSchema:Ds,OAuthClientInformationFullSchema:Fs,OAuthClientInformationSchema:Hs,OAuthClientMetadataSchema:Vs,OAuthClientRegistrationErrorSchema:Sa,OAuthErrorResponseSchema:pr,OAuthMetadataSchema:ur,OAuthProtectedResourceMetadataSchema:Ls,OAuthTokenRevocationRequestSchema:_a,OAuthTokensSchema:dr,OpenIdProviderDiscoveryMetadataSchema:Zs,OpenIdProviderMetadataSchema:Us},Rm={},xm={};function Em(e,t){let o=e.slice(0,-6);Rm[o]=t,xm[o]=(r)=>t.safeParse(r).success}for(let e of h_)Em(e,IS[e]);for(let[e,t]of Object.entries(m_))Em(e,t);var f_=Object.freeze(Rm),dl=Object.freeze(xm);function g_(e){switch(e){case"initialize":case"notifications/initialized":return Et(void 0);case"server/discover":return Et(xa);default:return}}var ti=60000,S_=[no,jo,so,Uo],__=["inputResponses","requestState"];function Jh(e,t){let o=e.params;if(!Ws(o))return{message:e,lifted:{}};let r=o._meta,n=Ws(r)?S_.filter((l)=>(l in r)):[],i=t==="request"?__.filter((l)=>(l in o)):[];if(n.length===0&&i.length===0)return{message:e,lifted:{}};let s={},a={...o};if(n.length>0&&Ws(r)){let l={},u={...r};for(let m of n)l[m]=r[m],delete u[m];if(s.envelope=l,Object.keys(u).length>0)a._meta=u;else delete a._meta}for(let l of i){if(l==="inputResponses")s.inputResponses=a[l];if(l==="requestState")s.requestState=a[l];delete a[l]}return{message:{...e,params:a},lifted:s}}function Bh(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 pl(e){return()=>e}var b_=pl(void 0),y_,oi=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{y_=(e,t)=>{e._negotiatedProtocolVersion=t}}_supportedProtocolVersions;onclose;onerror;fallbackRequestHandler;fallbackNotificationHandler;constructor(e){this._options=e,this._supportedProtocolVersions=e?.supportedProtocolVersions??Bi,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 L(F.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 L(F.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),mr(n)||ei(n))this._onresponse(n);else if(Ea(n))this._onrequest(n,i);else if(gm(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 L(F.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}=Jh(e,"notification"),r=this._negotiatedWireCodec();if(t?.classification===void 0&&this._shouldDropInbound(e)==="drop")return;if(t?.classification!==void 0){let s=Zh(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(Wc(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}=Jh(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=(z,b,w)=>{let C={jsonrpc:"2.0",id:o.id,error:{code:z,message:b,...w!==void 0&&{data:w}}};i?.send(C).catch((x)=>this._onerror(Error(`Failed to send an error response: ${x}`)))};if(t?.classification!==void 0){let z=Zh(t.classification);if(z!==n.era){this._onerror(Error(`Era mismatch on inbound request '${o.method}': classified as ${z} but this instance serves ${n.era}`));let b=t.classification.revision??z;s(Y.UnsupportedProtocolVersion,`Unsupported protocol version: ${b}`,{supported:this._supportedProtocolVersions,requested:b});return}}if(Gc(o.method)&&!n.hasRequestMethod(o.method)&&!(Dh(o.method)&&this._customSchemaRequestMethods.has(o.method))){s(Y.MethodNotFound,"Method not found");return}let a=this._requestHandlers.get(o.method)??this.fallbackRequestHandler;if(a===void 0){s(Y.MethodNotFound,"Method not found");return}let l=n.checkInboundEnvelope(r);if(l!==void 0){s(Y.InvalidParams,l);return}let u=(z,b)=>this._notificationViaCodec(this._resolveOutboundCodec(z.method),z,{...b,relatedRequestId:o.id}),m=(z,b,w)=>this._requestWithSchemaViaCodec(this._resolveOutboundCodec(z.method),z,b,{...w,relatedRequestId:o.id}),h=new AbortController;this._requestHandlerAbortControllers.set(o.id,h);let f=r.inputResponses===void 0?void 0:v_(r.inputResponses),g={sessionId:i?.sessionId,mcpReq:{id:o.id,method:o.method,_meta:o.params?._meta,...r.envelope!==void 0&&{envelope:r.envelope},...f!==void 0&&{inputResponses:f.accepted},...f!==void 0&&f.droppedKeys.length>0&&{droppedInputResponseKeys:f.droppedKeys},requestState:r.requestState===void 0?b_:pl(r.requestState),signal:h.signal,send:(z,b,w)=>{let C=this._resolveOutboundCodec(z.method);if(this._assertOutboundRequestInEra(C,z.method),Xc(b))return m(z,b,w);let x=Bh(C,z.method);if(x===void 0)throw TypeError(`'${z.method}' is not a spec method; pass a result schema as the second argument to ctx.mcpReq.send().`);return m(z,x,b)},notify:u},http:t?.authInfo?{authInfo:t.authInfo}:void 0},_=this.buildContext(g,t);Promise.resolve().then(()=>a(o,_)).then(async(z)=>{if(h.signal.aborted)return;let b;try{b=n.encodeResult(o.method,z,this._outboundServerInfo())}catch(C){this._onerror(Error(`Failed to encode result for ${o.method}: ${C}`)),s(Y.InternalError,"Internal error");return}let w={result:b,jsonrpc:"2.0",id:o.id};await i?.send(w)},async(z)=>{if(h.signal.aborted)return;let b=Number.isSafeInteger(z.code)?z.code:Y.InternalError,w={jsonrpc:"2.0",id:o.id,error:{code:n.encodeErrorCode(b),message:z.message??"Internal error",...z.data!==void 0&&{data:z.data}}};await i?.send(w)}).catch((z)=>this._onerror(Error(`Failed to send response: ${z}`))).finally(()=>{if(this._requestHandlerAbortControllers.get(o.id)===h)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(a){this._responseHandlers.delete(r),this._progressHandlers.delete(r),this._cleanupTimeout(r),i(a);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),mr(e))o(e);else o(_e.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(Xc(t)){if(!Dh(e.method))this._assertOutboundRequestInEra(r,e.method);return this._requestWithSchemaViaCodec(r,e,t,o)}this._assertOutboundRequestInEra(r,e.method);let n=Bh(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 Et(this._negotiatedProtocolVersion)}_wireCodec(){return this._negotiatedWireCodec()}_resolveOutboundCodec(e){if(this._negotiatedProtocolVersion===void 0){let t=g_(e);if(t)return t}return this._negotiatedWireCodec()}_assertOutboundRequestInEra(e,t){if(Gc(t)&&!e.hasRequestMethod(t))throw new L(F.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:a}=r??{},l=Date.now(),u,m;return new Promise((h,f)=>{let g=(B)=>{f(B)};if(!this._transport){g(Error("Not connected"));return}if(this._options?.enforceStrictCapabilities===!0)try{this.assertCapabilityForMethod(t.method)}catch(B){g(B);return}if(r?.signal?.aborted){let B=r.signal.reason;throw B instanceof L?B:new L(F.RequestTimeout,String(B))}let _=e.era===xa&&this._transport.hasPerRequestStream===!0?new AbortController:void 0,z=this._requestMessageId++;m=z;let b={...t,jsonrpc:"2.0",id:z};if(r?.onprogress)this._progressHandlers.set(z,r.onprogress),b.params={...t.params,_meta:{...t.params?._meta,progressToken:z}};let w=this._envelopeOutbound(b),C=!1,x=(B)=>{if(C)return;if(this._progressHandlers.delete(z),_===void 0){if(t.method!=="initialize")this._transport?.send(this._envelopeOutbound({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:z,reason:String(B)}}),{relatedRequestId:n,resumptionToken:i,onresumptiontoken:s}).catch((ee)=>this._onerror(Error(`Failed to send cancellation: ${ee}`)))}else _.abort();f(B instanceof L?B:new L(F.RequestTimeout,String(B)))};this._responseHandlers.set(z,(B)=>{if(r?.signal?.aborted)return;if(C=!0,B instanceof Error)return f(B);let ee;try{ee=e.decodeResult(t.method,B.result)}catch(le){return f(le instanceof Error?le:Error(String(le)))}if(ee.kind==="invalid")return f(ee.error);if(ee.kind==="input_required"){if(r?.allowInputRequired===!0)return h(x_(ee));let le={codec:e,request:t,resultSchema:o,options:r,flowStartedAt:l,retry:(ve,se)=>this._requestWithSchemaViaCodec(e,ve===void 0?{method:t.method}:{method:t.method,params:ve},o,se)};return h(this._resolveNonCompleteResult(ee,le))}let re=ee.result;Kc(o,re).then((le)=>{if(le.success)h(le.data);else f(new L(F.InvalidResult,`Invalid result for ${t.method}: ${le.error}`))},f)}),u=()=>x(r?.signal?.reason),r?.signal?.addEventListener("abort",u,{once:!0});let T=r?.timeout??ti,q=()=>x(new L(F.RequestTimeout,"Request timed out",{timeout:T}));this._setupTimeout(z,T,r?.maxTotalTimeout,q,r?.resetTimeoutOnProgress??!1),this._transport.send(w,{relatedRequestId:n,resumptionToken:i,onresumptiontoken:s,headers:a,requestSignal:_?.signal}).catch((B)=>{this._progressHandlers.delete(z),f(B)})}).finally(()=>{if(u)r?.signal?.removeEventListener("abort",u);if(m!==void 0)this._responseHandlers.delete(m),this._cleanupTimeout(m)})}async notification(e,t){return await this._notificationViaCodec(this._resolveOutboundCodec(e.method),e,t)}async _notificationViaCodec(e,t,o){if(!this._transport)throw new L(F.NotConnected,"Not connected");if(Wc(t.method)&&!e.hasNotificationMethod(t.method))throw new L(F.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(!Gc(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(),a=s.validateRequest(e,n);if(!a.ok&&a.reason==="not-in-era")a=s.validateInputRequest(e,n);if(!a.ok){if(a.reason==="not-in-era")throw new _e(Y.InternalError,`No wire schema for ${e} in the resolved era`);throw Error(a.message)}return Promise.resolve(t(a.value,i))}}else if(o)r=async(n,i)=>{let s=await Kc(t.params,{...n.params});if(!s.success)throw new _e(Y.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(!Wc(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 _e(Y.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 Kc(t.params,{...r.params});if(!n.success)throw new _e(Y.InvalidParams,`Invalid params for notification ${e}: ${n.error}`);await o(n.data,r)})}removeNotificationHandler(e){this._notificationHandlers.delete(e)}};function Ws(e){return e!==null&&typeof e==="object"&&!Array.isArray(e)}function hl(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]=Ws(s)&&Ws(i)?{...s,...i}:i}return o}function Ra(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}function v_(e){let t={},o=[];if(!Ra(e))return{accepted:t,droppedKeys:o};for(let[r,n]of Object.entries(e)){if(!Ra(n)||"method"in n||"result"in n){o.push(r);continue}t[r]=n}return{accepted:t,droppedKeys:o}}function Gh(e){throw new L(F.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 z_(e,t,o,r,n){return{sessionId:n,mcpReq:{id:e,method:t,_meta:o?._meta,requestState:pl(void 0),signal:r,send:()=>Gh("send"),notify:()=>Gh("notify")}}}async function w_(e,t,o,r,n){if(!Ra(r)||typeof r.method!=="string")throw new L(F.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 L(F.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 L(F.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 a=Ra(r.params)?r.params:void 0;return await s({jsonrpc:"2.0",id:o,method:i,...a!==void 0&&{params:a}},e.buildContext(z_(o,i,a,n,e.sessionId)))}function R_(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 Pm(e,t,o,r){let{codec:n,request:i,options:s,flowStartedAt:a}=r,l={inputRequests:o.inputRequests,...o.requestState!==void 0&&{requestState:o.requestState}},u={dispatchInputRequest:(m,h,f)=>w_(e,n,m,h,f),retry:(m,h)=>r.retry(m,R_(s,h))};return p_({config:t,method:i.method,originalParams:i.params,firstPayload:l,flowStartedAt:a,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:u})}function x_(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 a=s[1];if(t===s[0]){i(s);continue}if(e.external){let u=e.external.registry.get(s[0])?.id;if(t!==s[0]&&u){i(s);continue}}if(e.metadataRegistry.get(s[0])?.id){i(s);continue}if(a.cycle){i(s);continue}if(a.count>1){if(e.reused==="ref"){i(s);continue}}}}function on(e,t){let o=e.seen.get(t);if(!o)throw Error("Unprocessed schema. This is a bug in Zod.");let r=(a)=>{let l=e.seen.get(a);if(l.ref===null)return;let u=l.def??l.schema,m={...u},h=l.ref;if(l.ref=null,h){r(h);let g=e.seen.get(h),y=g.schema;if(y.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0"))u.allOf=u.allOf??[],u.allOf.push(y);else Object.assign(u,y);if(Object.assign(u,m),a._zod.parent===h)for(let _ in u){if(_==="$ref"||_==="allOf")continue;if(!(_ in m))delete u[_]}if(y.$ref&&g.def)for(let _ in u){if(_==="$ref"||_==="allOf")continue;if(_ in g.def&&JSON.stringify(u[_])===JSON.stringify(g.def[_]))delete u[_]}}let f=a._zod.parent;if(f&&f!==h){r(f);let g=e.seen.get(f);if(g?.schema.$ref){if(u.$ref=g.schema.$ref,g.def)for(let y in u){if(y==="$ref"||y==="allOf")continue;if(y in g.def&&JSON.stringify(u[y])===JSON.stringify(g.def[y]))delete u[y]}}}e.override({zodSchema:a,jsonSchema:u,path:l.path??[]})};for(let a of[...e.seen.entries()].reverse())r(a[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 a=e.external.registry.get(t)?.id;if(!a)throw Error("Schema is missing an `id` property");n.$id=e.external.uri(a)}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 a of e.seen.entries()){let l=a[1];if(l.def&&l.defId){if(l.def.id===l.defId)delete l.def.id;s[l.defId]=l.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 a=JSON.parse(JSON.stringify(n));return Object.defineProperty(a,"~standard",{value:{...t["~standard"],jsonSchema:{input:Xr(t,"input",e.processors),output:Xr(t,"output",e.processors)}},enumerable:!1,writable:!1}),a}catch(a){throw Error("Error converting schema to JSON.")}}function Qe(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 Qe(r.element,o);if(r.type==="set")return Qe(r.valueType,o);if(r.type==="lazy")return Qe(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 Qe(r.innerType,o);if(r.type==="intersection")return Qe(r.left,o)||Qe(r.right,o);if(r.type==="record"||r.type==="map")return Qe(r.keyType,o)||Qe(r.valueType,o);if(r.type==="pipe"){if(e._zod.traits.has("$ZodCodec"))return!0;return Qe(r.in,o)||Qe(r.out,o)}if(r.type==="object"){for(let n in r.shape)if(Qe(r.shape[n],o))return!0;return!1}if(r.type==="union"){for(let n of r.options)if(Qe(n,o))return!0;return!1}if(r.type==="tuple"){for(let n of r.items)if(Qe(n,o))return!0;if(r.rest&&Qe(r.rest,o))return!0;return!1}return!1}var Cp=(e,t={})=>(o)=>{let r=en({...o,processors:t});return Re(e,r),tn(r,e),on(r,e)},Xr=(e,t,o={})=>(r)=>{let{libraryOptions:n,target:i}=r??{},s=en({...n??{},target:i,io:t,processors:o});return Re(e,s),tn(s,e),on(s,e)};var Hf={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},fc=(e,t,o,r)=>{let n=o;n.type="string";let{minimum:i,maximum:s,format:a,patterns:l,contentEncoding:u}=e._zod.bag;if(typeof i==="number")n.minLength=i;if(typeof s==="number")n.maxLength=s;if(a){if(n.format=Hf[a]??a,n.format==="")delete n.format;if(a==="time")delete n.format}if(u)n.contentEncoding=u;if(l&&l.size>0){let m=[...l];if(m.length===1)n.pattern=m[0].source;else if(m.length>1)n.allOf=[...m.map((h)=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:h.source}))]}},gc=(e,t,o,r)=>{let n=o,{minimum:i,maximum:s,format:a,multipleOf:l,exclusiveMaximum:u,exclusiveMinimum:m}=e._zod.bag;if(typeof a==="string"&&a.includes("int"))n.type="integer";else n.type="number";let h=typeof m==="number"&&m>=(i??Number.NEGATIVE_INFINITY),f=typeof u==="number"&&u<=(s??Number.POSITIVE_INFINITY),g=t.target==="draft-04"||t.target==="openapi-3.0";if(h)if(g)n.minimum=m,n.exclusiveMinimum=!0;else n.exclusiveMinimum=m;else if(typeof i==="number")n.minimum=i;if(f)if(g)n.maximum=u,n.exclusiveMaximum=!0;else n.exclusiveMaximum=u;else if(typeof s==="number")n.maximum=s;if(typeof l==="number")n.multipleOf=l},Sc=(e,t,o,r)=>{o.type="boolean"},Op=(e,t,o,r)=>{if(t.unrepresentable==="throw")throw Error("BigInt cannot be represented in JSON Schema")},Mp=(e,t,o,r)=>{if(t.unrepresentable==="throw")throw Error("Symbols cannot be represented in JSON Schema")},_c=(e,t,o,r)=>{if(t.target==="openapi-3.0")o.type="string",o.nullable=!0,o.enum=[null];else o.type="null"},bc=(e,t,o,r)=>{if(t.unrepresentable==="throw")throw Error("Undefined cannot be represented in JSON Schema")},Ap=(e,t,o,r)=>{if(t.unrepresentable==="throw")throw Error("Void cannot be represented in JSON Schema")},yc=(e,t,o,r)=>{o.not={}},vc=(e,t,o,r)=>{},zc=(e,t,o,r)=>{},Np=(e,t,o,r)=>{if(t.unrepresentable==="throw")throw Error("Date cannot be represented in JSON Schema")},wc=(e,t,o,r)=>{let n=e._zod.def,i=Ri(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},Rc=(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}},qp=(e,t,o,r)=>{if(t.unrepresentable==="throw")throw Error("NaN cannot be represented in JSON Schema")},jp=(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},Lp=(e,t,o,r)=>{let n=o,i={type:"string",format:"binary",contentEncoding:"binary"},{minimum:s,maximum:a,mime:l}=e._zod.bag;if(s!==void 0)i.minLength=s;if(a!==void 0)i.maxLength=a;if(l)if(l.length===1)i.contentMediaType=l[0],Object.assign(n,i);else Object.assign(n,i),n.anyOf=l.map((u)=>({contentMediaType:u}));else Object.assign(n,i)},Up=(e,t,o,r)=>{o.type="boolean"},xc=(e,t,o,r)=>{if(t.unrepresentable==="throw")throw Error("Custom types cannot be represented in JSON Schema")},Zp=(e,t,o,r)=>{if(t.unrepresentable==="throw")throw Error("Function types cannot be represented in JSON Schema")},Ec=(e,t,o,r)=>{if(t.unrepresentable==="throw")throw Error("Transforms cannot be represented in JSON Schema")},Dp=(e,t,o,r)=>{if(t.unrepresentable==="throw")throw Error("Map cannot be represented in JSON Schema")},Vp=(e,t,o,r)=>{if(t.unrepresentable==="throw")throw Error("Set cannot be represented in JSON Schema")},Pc=(e,t,o,r)=>{let n=o,i=e._zod.def,{minimum:s,maximum:a}=e._zod.bag;if(typeof s==="number")n.minItems=s;if(typeof a==="number")n.maxItems=a;n.type="array",n.items=Re(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 s=i.shape;for(let u in s)n.properties[u]=Re(s[u],t,{...r,path:[...r.path,"properties",u]});let a=new Set(Object.keys(s)),l=new Set([...a].filter((u)=>{let m=i.shape[u]._zod;if(t.io==="input")return m.optin===void 0;else return m.optout===void 0}));if(l.size>0)n.required=Array.from(l);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=Re(i.catchall,t,{...r,path:[...r.path,"additionalProperties"]})},kc=(e,t,o,r)=>{let n=e._zod.def,i=n.inclusive===!1,s=n.options.map((a,l)=>Re(a,t,{...r,path:[...r.path,i?"oneOf":"anyOf",l]}));if(i)o.oneOf=s;else o.anyOf=s},$c=(e,t,o,r)=>{let n=e._zod.def,i=Re(n.left,t,{...r,path:[...r.path,"allOf",0]}),s=Re(n.right,t,{...r,path:[...r.path,"allOf",1]}),a=(u)=>("allOf"in u)&&Object.keys(u).length===1,l=[...a(i)?i.allOf:[i],...a(s)?s.allOf:[s]];o.allOf=l},Hp=(e,t,o,r)=>{let n=o,i=e._zod.def;n.type="array";let s=t.target==="draft-2020-12"?"prefixItems":"items",a=t.target==="draft-2020-12"?"items":t.target==="openapi-3.0"?"items":"additionalItems",l=i.items.map((f,g)=>Re(f,t,{...r,path:[...r.path,s,g]})),u=i.rest?Re(i.rest,t,{...r,path:[...r.path,a,...t.target==="openapi-3.0"?[i.items.length]:[]]}):null;if(t.target==="draft-2020-12"){if(n.prefixItems=l,u)n.items=u}else if(t.target==="openapi-3.0"){if(n.items={anyOf:l},u)n.items.anyOf.push(u);if(n.minItems=l.length,!u)n.maxItems=l.length}else if(n.items=l,u)n.additionalItems=u;let{minimum:m,maximum:h}=e._zod.bag;if(typeof m==="number")n.minItems=m;if(typeof h==="number")n.maxItems=h},Cc=(e,t,o,r)=>{let n=o,i=e._zod.def;n.type="object";let s=i.keyType,l=s._zod.bag?.patterns;if(i.mode==="loose"&&l&&l.size>0){let m=Re(i.valueType,t,{...r,path:[...r.path,"patternProperties","*"]});n.patternProperties={};for(let h of l)n.patternProperties[h.source]=m}else{if(t.target==="draft-07"||t.target==="draft-2020-12")n.propertyNames=Re(i.keyType,t,{...r,path:[...r.path,"propertyNames"]});n.additionalProperties=Re(i.valueType,t,{...r,path:[...r.path,"additionalProperties"]})}let u=s._zod.values;if(u){let m=[...u].filter((h)=>typeof h==="string"||typeof h==="number");if(m.length>0)n.required=m}},Ic=(e,t,o,r)=>{let n=e._zod.def,i=Re(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"}]},Oc=(e,t,o,r)=>{let n=e._zod.def;Re(n.innerType,t,r);let i=t.seen.get(e);i.ref=n.innerType},Mc=(e,t,o,r)=>{let n=e._zod.def;Re(n.innerType,t,r);let i=t.seen.get(e);i.ref=n.innerType,o.default=JSON.parse(JSON.stringify(n.defaultValue))},Ac=(e,t,o,r)=>{let n=e._zod.def;Re(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))},Nc=(e,t,o,r)=>{let n=e._zod.def;Re(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},qc=(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;Re(s,t,r);let a=t.seen.get(e);a.ref=s},jc=(e,t,o,r)=>{let n=e._zod.def;Re(n.innerType,t,r);let i=t.seen.get(e);i.ref=n.innerType,o.readOnly=!0},Fp=(e,t,o,r)=>{let n=e._zod.def;Re(n.innerType,t,r);let i=t.seen.get(e);i.ref=n.innerType},Li=(e,t,o,r)=>{let n=e._zod.def;Re(n.innerType,t,r);let i=t.seen.get(e);i.ref=n.innerType},Lc=(e,t,o,r)=>{let n=e._zod.innerType;Re(n,t,r);let i=t.seen.get(e);i.ref=n},Ip={string:fc,number:gc,boolean:Sc,bigint:Op,symbol:Mp,null:_c,undefined:bc,void:Ap,never:yc,any:vc,unknown:zc,date:Np,enum:wc,literal:Rc,nan:qp,template_literal:jp,file:Lp,success:Up,custom:xc,function:Zp,transform:Ec,map:Dp,set:Vp,array:Pc,object:Tc,union:kc,intersection:$c,tuple:Hp,record:Cc,nullable:Ic,nonoptional:Oc,default:Mc,prefault:Ac,catch:Nc,pipe:qc,readonly:jc,promise:Fp,optional:Li,lazy:Lc};function Ui(e,t){if("_idmap"in e){let r=e,n=en({...t,processors:Ip}),i={};for(let l of r._idmap.entries()){let[u,m]=l;Re(m,n)}let s={},a={registry:r,uri:t?.uri,defs:i};n.external=a;for(let l of r._idmap.entries()){let[u,m]=l;tn(n,m),s[u]=on(n,m)}if(Object.keys(i).length>0){let l=n.target==="draft-2020-12"?"$defs":"definitions";s.__shared={[l]:i}}return{schemas:s}}let o=en({...t,processors:Ip});return Re(e,o),tn(o,e),on(o,e)}var Qf=v("ZodISODateTime",(e,t)=>{id.init(e,t),Ie.init(e,t)});function No(e){return fp(Qf,e)}var Xf=v("ZodISODate",(e,t)=>{ad.init(e,t),Ie.init(e,t)});function Uc(e){return gp(Xf,e)}var eg=v("ZodISOTime",(e,t)=>{cd.init(e,t),Ie.init(e,t)});function Jp(e){return Sp(eg,e)}var tg=v("ZodISODuration",(e,t)=>{ld.init(e,t),Ie.init(e,t)});function Bp(e){return _p(tg,e)}var og=(e,t)=>{Ti.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:(o)=>Da(e,o)},flatten:{value:(o)=>Za(e,o)},addIssue:{value:(o)=>{e.issues.push(o),e.message=JSON.stringify(e.issues,Fr,2)}},addIssues:{value:(o)=>{e.issues.push(...o),e.message=JSON.stringify(e.issues,Fr,2)}},isEmpty:{get(){return e.issues.length===0}}})};var rt=v("ZodError",og,{Parent:Error});var Wp=ki(rt),Kp=$i(rt),Di=Br(rt),Yp=Gr(rt),Qp=Vl(rt),Xp=Hl(rt),eh=Fl(rt),th=Jl(rt),oh=Bl(rt),rh=Gl(rt),nh=Wl(rt),sh=Kl(rt);var ih=new WeakMap;function rn(e,t,o){let r=Object.getPrototypeOf(e),n=ih.get(r);if(!n)n=new Set,ih.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 a=s.bind(this);return Object.defineProperty(this,i,{configurable:!0,writable:!0,enumerable:!0,value:a}),a},set(a){Object.defineProperty(this,i,{configurable:!0,writable:!0,enumerable:!0,value:a})}})}}var xe=v("ZodType",(e,t)=>(ye.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:Xr(e,"input"),output:Xr(e,"output")}}),e.toJSONSchema=Cp(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.parse=(o,r)=>Wp(e,o,r,{callee:e.parse}),e.safeParse=(o,r)=>Di(e,o,r),e.parseAsync=async(o,r)=>Kp(e,o,r,{callee:e.parseAsync}),e.safeParseAsync=async(o,r)=>Yp(e,o,r),e.spa=e.safeParseAsync,e.encode=(o,r)=>Qp(e,o,r),e.decode=(o,r)=>Xp(e,o,r),e.encodeAsync=async(o,r)=>eh(e,o,r),e.decodeAsync=async(o,r)=>th(e,o,r),e.safeEncode=(o,r)=>oh(e,o,r),e.safeDecode=(o,r)=>rh(e,o,r),e.safeEncodeAsync=async(o,r)=>nh(e,o,r),e.safeDecodeAsync=async(o,r)=>sh(e,o,r),rn(e,"ZodType",{check(...o){let r=this.def;return this.clone(Ct(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 at(this,o,r)},brand(){return this},register(o,r){return o.add(this,r),this},refine(o,r){return this.check(Fg(o,r))},superRefine(o,r){return this.check(Jg(o,r))},overwrite(o){return this.check(At(o))},optional(){return G(this)},exactOptional(){return Cg(this)},nullable(){return uh(this)},nullish(){return G(uh(this))},nonoptional(o){return qg(this,o)},array(){return S(this)},or(o){return M([this,o])},and(o){return bt(this,o)},transform(o){return dh(this,yh(o))},default(o){return Mg(this,o)},prefault(o){return Ng(this,o)},catch(o){return Lg(this,o)},pipe(o){return dh(this,o)},readonly(){return Dg(this)},describe(o){let r=this.clone();return Mt.add(r,{description:o}),r},meta(...o){if(o.length===0)return Mt.get(this);let r=this.clone();return Mt.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 Mt.get(e)?.description},configurable:!0}),e)),ph=v("_ZodString",(e,t)=>{Oi.init(e,t),xe.init(e,t),e._zod.processJSONSchema=(r,n,i)=>fc(e,r,n,i);let o=e._zod.bag;e.format=o.format??null,e.minLength=o.minimum??null,e.maxLength=o.maximum??null,rn(e,"_ZodString",{regex(...r){return this.check(nc(...r))},includes(...r){return this.check(ac(...r))},startsWith(...r){return this.check(cc(...r))},endsWith(...r){return this.check(lc(...r))},min(...r){return this.check(Mo(...r))},max(...r){return this.check(qi(...r))},length(...r){return this.check(ji(...r))},nonempty(...r){return this.check(Mo(1,...r))},lowercase(r){return this.check(sc(r))},uppercase(r){return this.check(ic(r))},trim(){return this.check(dc())},normalize(...r){return this.check(uc(...r))},toLowerCase(){return this.check(pc())},toUpperCase(){return this.check(hc())},slugify(){return this.check(mc())}})}),hh=v("ZodString",(e,t)=>{Oi.init(e,t),ph.init(e,t),e.email=(o)=>e.check(tc(mh,o)),e.url=(o)=>e.check(rc(gh,o)),e.jwt=(o)=>e.check(mp(_g,o)),e.emoji=(o)=>e.check(ep(ng,o)),e.guid=(o)=>e.check(oc(ah,o)),e.uuid=(o)=>e.check(Kd(Vi,o)),e.uuidv4=(o)=>e.check(Yd(Vi,o)),e.uuidv6=(o)=>e.check(Qd(Vi,o)),e.uuidv7=(o)=>e.check(Xd(Vi,o)),e.nanoid=(o)=>e.check(tp(sg,o)),e.guid=(o)=>e.check(oc(ah,o)),e.cuid=(o)=>e.check(op(ig,o)),e.cuid2=(o)=>e.check(rp(ag,o)),e.ulid=(o)=>e.check(np(cg,o)),e.base64=(o)=>e.check(dp(fg,o)),e.base64url=(o)=>e.check(pp(gg,o)),e.xid=(o)=>e.check(sp(lg,o)),e.ksuid=(o)=>e.check(ip(ug,o)),e.ipv4=(o)=>e.check(ap(dg,o)),e.ipv6=(o)=>e.check(cp(pg,o)),e.cidrv4=(o)=>e.check(lp(hg,o)),e.cidrv6=(o)=>e.check(up(mg,o)),e.e164=(o)=>e.check(hp(Sg,o)),e.datetime=(o)=>e.check(No(o)),e.date=(o)=>e.check(Uc(o)),e.time=(o)=>e.check(Jp(o)),e.duration=(o)=>e.check(Bp(o))});function c(e){return Wd(hh,e)}var Ie=v("ZodStringFormat",(e,t)=>{Ce.init(e,t),ph.init(e,t)}),mh=v("ZodEmail",(e,t)=>{Yu.init(e,t),Ie.init(e,t)});function fh(e){return tc(mh,e)}var ah=v("ZodGUID",(e,t)=>{Wu.init(e,t),Ie.init(e,t)});var Vi=v("ZodUUID",(e,t)=>{Ku.init(e,t),Ie.init(e,t)});var gh=v("ZodURL",(e,t)=>{Qu.init(e,t),Ie.init(e,t)});function Hi(e){return rc(gh,e)}var ng=v("ZodEmoji",(e,t)=>{Xu.init(e,t),Ie.init(e,t)});var sg=v("ZodNanoID",(e,t)=>{ed.init(e,t),Ie.init(e,t)});var ig=v("ZodCUID",(e,t)=>{td.init(e,t),Ie.init(e,t)});var ag=v("ZodCUID2",(e,t)=>{od.init(e,t),Ie.init(e,t)});var cg=v("ZodULID",(e,t)=>{rd.init(e,t),Ie.init(e,t)});var lg=v("ZodXID",(e,t)=>{nd.init(e,t),Ie.init(e,t)});var ug=v("ZodKSUID",(e,t)=>{sd.init(e,t),Ie.init(e,t)});var dg=v("ZodIPv4",(e,t)=>{ud.init(e,t),Ie.init(e,t)});var pg=v("ZodIPv6",(e,t)=>{dd.init(e,t),Ie.init(e,t)});var hg=v("ZodCIDRv4",(e,t)=>{pd.init(e,t),Ie.init(e,t)});var mg=v("ZodCIDRv6",(e,t)=>{hd.init(e,t),Ie.init(e,t)});var fg=v("ZodBase64",(e,t)=>{fd.init(e,t),Ie.init(e,t)});var gg=v("ZodBase64URL",(e,t)=>{gd.init(e,t),Ie.init(e,t)});var Sg=v("ZodE164",(e,t)=>{Sd.init(e,t),Ie.init(e,t)});var _g=v("ZodJWT",(e,t)=>{_d.init(e,t),Ie.init(e,t)});var Fi=v("ZodNumber",(e,t)=>{Ka.init(e,t),xe.init(e,t),e._zod.processJSONSchema=(r,n,i)=>gc(e,r,n,i),rn(e,"ZodNumber",{gt(r,n){return this.check(Ai(r,n))},gte(r,n){return this.check(Qr(r,n))},min(r,n){return this.check(Qr(r,n))},lt(r,n){return this.check(Mi(r,n))},lte(r,n){return this.check(Yr(r,n))},max(r,n){return this.check(Yr(r,n))},int(r){return this.check(ch(r))},safe(r){return this.check(ch(r))},positive(r){return this.check(Ai(0,r))},nonnegative(r){return this.check(Qr(0,r))},negative(r){return this.check(Mi(0,r))},nonpositive(r){return this.check(Yr(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 w(e){return bp(Fi,e)}var bg=v("ZodNumberFormat",(e,t)=>{bd.init(e,t),Fi.init(e,t)});function ch(e){return vp(bg,e)}var Sh=v("ZodBoolean",(e,t)=>{yd.init(e,t),xe.init(e,t),e._zod.processJSONSchema=(o,r,n)=>Sc(e,o,r,n)});function O(e){return zp(Sh,e)}var yg=v("ZodUndefined",(e,t)=>{vd.init(e,t),xe.init(e,t),e._zod.processJSONSchema=(o,r,n)=>bc(e,o,r,n)});function Dc(e){return wp(yg,e)}var vg=v("ZodNull",(e,t)=>{zd.init(e,t),xe.init(e,t),e._zod.processJSONSchema=(o,r,n)=>_c(e,o,r,n)});function oo(e){return Rp(vg,e)}var zg=v("ZodAny",(e,t)=>{wd.init(e,t),xe.init(e,t),e._zod.processJSONSchema=(o,r,n)=>vc(e,o,r,n)});function Ji(){return xp(zg)}var wg=v("ZodUnknown",(e,t)=>{Rd.init(e,t),xe.init(e,t),e._zod.processJSONSchema=(o,r,n)=>zc(e,o,r,n)});function D(){return Ep(wg)}var Rg=v("ZodNever",(e,t)=>{xd.init(e,t),xe.init(e,t),e._zod.processJSONSchema=(o,r,n)=>yc(e,o,r,n)});function Vc(e){return Pp(Rg,e)}var xg=v("ZodArray",(e,t)=>{Ed.init(e,t),xe.init(e,t),e._zod.processJSONSchema=(o,r,n)=>Pc(e,o,r,n),e.element=t.element,rn(e,"ZodArray",{min(o,r){return this.check(Mo(o,r))},nonempty(o){return this.check(Mo(1,o))},max(o,r){return this.check(qi(o,r))},length(o,r){return this.check(ji(o,r))},unwrap(){return this.element}})});function S(e,t){return Tp(xg,e,t)}var _h=v("ZodObject",(e,t)=>{kd.init(e,t),xe.init(e,t),e._zod.processJSONSchema=(o,r,n)=>Tc(e,o,r,n),fe(e,"shape",()=>t.shape),rn(e,"ZodObject",{keyof(){return oe(Object.keys(this._zod.def.shape))},catchall(o){return this.clone({...this._zod.def,catchall:o})},passthrough(){return this.clone({...this._zod.def,catchall:D()})},loose(){return this.clone({...this._zod.def,catchall:D()})},strict(){return this.clone({...this._zod.def,catchall:Vc()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(o){return $f(this,o)},safeExtend(o){return Cf(this,o)},merge(o){return If(this,o)},pick(o){return Tf(this,o)},omit(o){return kf(this,o)},partial(...o){return Of(vh,this,o[0])},required(...o){return Mf(zh,this,o[0])}})});function d(e,t){let o={type:"object",shape:e??{},...H(t)};return new _h(o)}function K(e,t){return new _h({type:"object",shape:e,catchall:D(),...H(t)})}var bh=v("ZodUnion",(e,t)=>{Ya.init(e,t),xe.init(e,t),e._zod.processJSONSchema=(o,r,n)=>kc(e,o,r,n),e.options=t.options});function M(e,t){return new bh({type:"union",options:e,...H(t)})}var Eg=v("ZodDiscriminatedUnion",(e,t)=>{bh.init(e,t),$d.init(e,t)});function qo(e,t,o){return new Eg({type:"union",options:t,discriminator:e,...H(o)})}var Pg=v("ZodIntersection",(e,t)=>{Cd.init(e,t),xe.init(e,t),e._zod.processJSONSchema=(o,r,n)=>$c(e,o,r,n)});function bt(e,t){return new Pg({type:"intersection",left:e,right:t})}var lh=v("ZodRecord",(e,t)=>{Id.init(e,t),xe.init(e,t),e._zod.processJSONSchema=(o,r,n)=>Cc(e,o,r,n),e.keyType=t.keyType,e.valueType=t.valueType});function I(e,t,o){if(!t||!t._zod)return new lh({type:"record",keyType:c(),valueType:e,...H(t)});return new lh({type:"record",keyType:e,valueType:t,...H(o)})}var Zc=v("ZodEnum",(e,t)=>{Od.init(e,t),xe.init(e,t),e._zod.processJSONSchema=(r,n,i)=>wc(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 Zc({...t,checks:[],...H(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 Zc({...t,checks:[],...H(n),entries:i})}});function oe(e,t){let o=Array.isArray(e)?Object.fromEntries(e.map((r)=>[r,r])):e;return new Zc({type:"enum",entries:o,...H(t)})}var Tg=v("ZodLiteral",(e,t)=>{Md.init(e,t),xe.init(e,t),e._zod.processJSONSchema=(o,r,n)=>Rc(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 p(e,t){return new Tg({type:"literal",values:Array.isArray(e)?e:[e],...H(t)})}var kg=v("ZodTransform",(e,t)=>{Ad.init(e,t),xe.init(e,t),e._zod.processJSONSchema=(o,r,n)=>Ec(e,o,r,n),e._zod.parse=(o,r)=>{if(r.direction==="backward")throw new Hr(e.constructor.name);o.addIssue=(i)=>{if(typeof i==="string")o.issues.push(to(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(to(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 yh(e){return new kg({type:"transform",transform:e})}var vh=v("ZodOptional",(e,t)=>{Qa.init(e,t),xe.init(e,t),e._zod.processJSONSchema=(o,r,n)=>Li(e,o,r,n),e.unwrap=()=>e._zod.def.innerType});function G(e){return new vh({type:"optional",innerType:e})}var $g=v("ZodExactOptional",(e,t)=>{Nd.init(e,t),xe.init(e,t),e._zod.processJSONSchema=(o,r,n)=>Li(e,o,r,n),e.unwrap=()=>e._zod.def.innerType});function Cg(e){return new $g({type:"optional",innerType:e})}var Ig=v("ZodNullable",(e,t)=>{qd.init(e,t),xe.init(e,t),e._zod.processJSONSchema=(o,r,n)=>Ic(e,o,r,n),e.unwrap=()=>e._zod.def.innerType});function uh(e){return new Ig({type:"nullable",innerType:e})}var Og=v("ZodDefault",(e,t)=>{jd.init(e,t),xe.init(e,t),e._zod.processJSONSchema=(o,r,n)=>Mc(e,o,r,n),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Mg(e,t){return new Og({type:"default",innerType:e,get defaultValue(){return typeof t==="function"?t():ja(t)}})}var Ag=v("ZodPrefault",(e,t)=>{Ld.init(e,t),xe.init(e,t),e._zod.processJSONSchema=(o,r,n)=>Ac(e,o,r,n),e.unwrap=()=>e._zod.def.innerType});function Ng(e,t){return new Ag({type:"prefault",innerType:e,get defaultValue(){return typeof t==="function"?t():ja(t)}})}var zh=v("ZodNonOptional",(e,t)=>{Ud.init(e,t),xe.init(e,t),e._zod.processJSONSchema=(o,r,n)=>Oc(e,o,r,n),e.unwrap=()=>e._zod.def.innerType});function qg(e,t){return new zh({type:"nonoptional",innerType:e,...H(t)})}var jg=v("ZodCatch",(e,t)=>{Zd.init(e,t),xe.init(e,t),e._zod.processJSONSchema=(o,r,n)=>Nc(e,o,r,n),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function Lg(e,t){return new jg({type:"catch",innerType:e,catchValue:typeof t==="function"?t:()=>t})}var wh=v("ZodPipe",(e,t)=>{Xa.init(e,t),xe.init(e,t),e._zod.processJSONSchema=(o,r,n)=>qc(e,o,r,n),e.in=t.in,e.out=t.out});function dh(e,t){return new wh({type:"pipe",in:e,out:t})}var Ug=v("ZodPreprocess",(e,t)=>{wh.init(e,t),Dd.init(e,t)}),Zg=v("ZodReadonly",(e,t)=>{Vd.init(e,t),xe.init(e,t),e._zod.processJSONSchema=(o,r,n)=>jc(e,o,r,n),e.unwrap=()=>e._zod.def.innerType});function Dg(e){return new Zg({type:"readonly",innerType:e})}var Vg=v("ZodLazy",(e,t)=>{Hd.init(e,t),xe.init(e,t),e._zod.processJSONSchema=(o,r,n)=>Lc(e,o,r,n),e.unwrap=()=>e._zod.def.getter()});function nn(e){return new Vg({type:"lazy",getter:e})}var Hg=v("ZodCustom",(e,t)=>{Fd.init(e,t),xe.init(e,t),e._zod.processJSONSchema=(o,r,n)=>xc(e,o,r,n)});function Fg(e,t={}){return kp(Hg,e,t)}function Jg(e,t){return $p(e,t)}function ro(e,t){return new Ug({type:"pipe",in:yh(e),out:t})}var xh={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 Rh;(function(e){})(Rh||(Rh={}));function Bg(e){return yp(Fi,e)}Ye(ec());var sn="2025-11-25";var Bi=[sn,"2025-06-18","2025-03-26","2024-11-05","2024-10-07"],Gi="io.modelcontextprotocol/related-task",no="io.modelcontextprotocol/protocolVersion",jo="io.modelcontextprotocol/clientInfo",ht="io.modelcontextprotocol/serverInfo",so="io.modelcontextprotocol/clientCapabilities",Lo="io.modelcontextprotocol/subscriptionId",Uo="io.modelcontextprotocol/logLevel";var io="2.0";var yt=nn(()=>M([c(),w(),O(),oo(),I(c(),yt),S(yt)])),Me=I(c(),yt),Wi=S(yt),Zo=M([c(),w().int()]),Do=c(),an=d({ttl:w().optional()}),cn=d({taskId:c()}),Vo=K({progressToken:Zo.optional(),[Gi]:cn.optional()}),De=d({_meta:Vo.optional()}),qt=De.extend({task:an.optional()}),Ae=d({method:c(),params:De.loose().optional()}),Ge=d({_meta:Vo.optional()}),Fe=d({method:c(),params:Ge.loose().optional()}),Ho=K({get[ht](){return mt.optional().catch(void 0)}}),Ne=K({_meta:Ho.optional()}),lt=M([c(),w().int()]),Fo=d({jsonrpc:p(io),id:lt,...Ae.shape}).strict(),Jo=d({jsonrpc:p(io),...Fe.shape}).strict(),ao=d({jsonrpc:p(io),id:lt,result:Ne}).strict(),co=d({jsonrpc:p(io),id:lt.optional(),error:d({code:w().int(),message:c(),data:D().optional()})}).strict(),lo=M([Fo,Jo,ao,co]),Ki=M([ao,co]),jt=Ne.strict(),ln=Ge.extend({requestId:lt.optional(),reason:c().optional()}),Bo=Fe.extend({method:p("notifications/cancelled"),params:ln}),un=d({src:c(),mimeType:c().optional(),sizes:S(c()).optional(),theme:oe(["light","dark"]).optional()}),vt=d({icons:S(un).optional()}),pt=d({name:c(),title:c().optional()}),mt=pt.extend({...pt.shape,...vt.shape,version:c(),websiteUrl:c().optional(),description:c().optional()}),Gg=bt(d({applyDefaults:O().optional()}),Me),Wg=ro((e)=>{if(e&&typeof e==="object"&&!Array.isArray(e)&&Object.keys(e).length===0)return{form:{}};return e},bt(d({form:Gg.optional(),url:Me.optional()}),Me.optional())),Yi=K({list:Me.optional(),cancel:Me.optional(),requests:K({sampling:K({createMessage:Me.optional()}).optional(),elicitation:K({create:Me.optional()}).optional()}).optional()}),Qi=K({list:Me.optional(),cancel:Me.optional(),requests:K({tools:K({call:Me.optional()}).optional()}).optional()}),dn=d({experimental:I(c(),Me).optional(),sampling:d({context:Me.optional(),tools:Me.optional()}).optional(),elicitation:Wg.optional(),roots:d({listChanged:O().optional()}).optional(),tasks:Yi.optional(),extensions:I(c(),Me).optional()}),pn=De.extend({protocolVersion:c(),capabilities:dn,clientInfo:mt}),hn=Ae.extend({method:p("initialize"),params:pn}),Go=d({experimental:I(c(),Me).optional(),logging:Me.optional(),completions:Me.optional(),prompts:d({listChanged:O().optional()}).optional(),resources:d({subscribe:O().optional(),listChanged:O().optional()}).optional(),tools:d({listChanged:O().optional()}).optional(),tasks:Qi.optional(),extensions:I(c(),Me).optional()}),mn=Ne.extend({protocolVersion:c(),capabilities:Go,serverInfo:mt,instructions:c().optional()}),fn=Fe.extend({method:p("notifications/initialized"),params:Ge.optional()}),gn=Ae.extend({method:p("server/discover"),params:De.optional()}),Lt=Ne.extend({supportedVersions:S(c()),capabilities:Go,instructions:c().optional()}),Wo=Ae.extend({method:p("ping"),params:De.optional()}),Sn=d({progress:w(),total:G(w()),message:G(c())}),_n=d({...Ge.shape,...Sn.shape,progressToken:Zo}),Ko=Fe.extend({method:p("notifications/progress"),params:_n}),bn=De.extend({cursor:Do.optional()}),zt=Ae.extend({params:bn.optional()}),wt=Ne.extend({nextCursor:Do.optional()}),Yo=d({uri:c(),mimeType:G(c()),_meta:I(c(),D()).optional()}),Qo=Yo.extend({text:c()}),Fc=c().refine((e)=>{try{return atob(e),!0}catch{return!1}},{message:"Invalid Base64 string"}),Xo=Yo.extend({blob:Fc}),Rt=oe(["user","assistant"]),ft=d({audience:S(Rt).optional(),priority:w().min(0).max(1).optional(),lastModified:No({offset:!0}).optional()}),er=d({...pt.shape,...vt.shape,uri:c(),description:G(c()),mimeType:G(c()),size:G(w()),annotations:ft.optional(),_meta:G(K({}))}),yn=d({...pt.shape,...vt.shape,uriTemplate:c(),description:G(c()),mimeType:G(c()),annotations:ft.optional(),_meta:G(K({}))}),vn=zt.extend({method:p("resources/list")}),zn=wt.extend({resources:S(er)}),wn=zt.extend({method:p("resources/templates/list")}),Rn=wt.extend({resourceTemplates:S(yn)}),uo=De.extend({uri:c()}),xn=uo,En=Ae.extend({method:p("resources/read"),params:xn}),Pn=Ne.extend({contents:S(M([Qo,Xo]))}),Tn=Fe.extend({method:p("notifications/resources/list_changed"),params:Ge.optional()}),kn=uo,$n=Ae.extend({method:p("resources/subscribe"),params:kn}),Cn=uo,In=Ae.extend({method:p("resources/unsubscribe"),params:Cn}),tr=d({toolsListChanged:O().optional(),promptsListChanged:O().optional(),resourcesListChanged:O().optional(),resourceSubscriptions:S(c()).optional()}),On=De.extend({notifications:tr}),Mn=Ae.extend({method:p("subscriptions/listen"),params:On}),An=Ge.extend({notifications:tr}),Nn=Fe.extend({method:p("notifications/subscriptions/acknowledged"),params:An}),qn=Ho.extend({[Lo]:lt}),jn=Ne.extend({_meta:qn}),Ln=Ge.extend({uri:c()}),Un=Fe.extend({method:p("notifications/resources/updated"),params:Ln}),Zn=d({name:c(),description:G(c()),required:G(O())}),Dn=d({...pt.shape,...vt.shape,description:G(c()),arguments:G(S(Zn)),_meta:G(K({}))}),Vn=zt.extend({method:p("prompts/list")}),Hn=wt.extend({prompts:S(Dn)}),Fn=De.extend({name:c(),arguments:I(c(),c()).optional()}),Jn=Ae.extend({method:p("prompts/get"),params:Fn}),po=d({type:p("text"),text:c(),annotations:ft.optional(),_meta:I(c(),D()).optional()}),ho=d({type:p("image"),data:Fc,mimeType:c(),annotations:ft.optional(),_meta:I(c(),D()).optional()}),mo=d({type:p("audio"),data:Fc,mimeType:c(),annotations:ft.optional(),_meta:I(c(),D()).optional()}),Bn=d({type:p("tool_use"),name:c(),id:c(),input:I(c(),D()),_meta:I(c(),D()).optional()}),fo=d({type:p("resource"),resource:M([Qo,Xo]),annotations:ft.optional(),_meta:I(c(),D()).optional()}),go=er.extend({type:p("resource_link")}),gt=M([po,ho,mo,go,fo]),Gn=d({role:Rt,content:gt}),Wn=Ne.extend({description:c().optional(),messages:S(Gn)}),Kn=Fe.extend({method:p("notifications/prompts/list_changed"),params:Ge.optional()}),Yn=d({title:c().optional(),readOnlyHint:O().optional(),destructiveHint:O().optional(),idempotentHint:O().optional(),openWorldHint:O().optional()}),Qn=d({taskSupport:oe(["required","optional","forbidden"]).optional()}),Ut=d({...pt.shape,...vt.shape,description:c().optional(),inputSchema:d({type:p("object"),properties:I(c(),yt).optional(),required:S(c()).optional()}).catchall(D()),outputSchema:K({$schema:c().optional()}).optional(),annotations:Yn.optional(),execution:Qn.optional(),_meta:I(c(),D()).optional()}),Xn=zt.extend({method:p("tools/list")}),es=wt.extend({tools:S(Ut)}),Zt=Ne.extend({content:S(gt).default([]),structuredContent:D().optional(),isError:O().optional()}),Xi=Zt.or(Ne.extend({toolResult:D()})),ts=qt.extend({name:c(),arguments:I(c(),D()).optional()}),os=Ae.extend({method:p("tools/call"),params:ts}),rs=Fe.extend({method:p("notifications/tools/list_changed"),params:Ge.optional()}),ns=d({autoRefresh:O().default(!0),debounceMs:w().int().nonnegative().default(300)}),or=oe(["debug","info","notice","warning","error","critical","alert","emergency"]),ss=De.extend({level:or}),is=Ae.extend({method:p("logging/setLevel"),params:ss}),as=Ge.extend({level:or,logger:c().optional(),data:D()}),cs=Fe.extend({method:p("notifications/message"),params:as}),ls=d({name:c().optional()}),us=d({hints:S(ls).optional(),costPriority:w().min(0).max(1).optional(),speedPriority:w().min(0).max(1).optional(),intelligencePriority:w().min(0).max(1).optional()}),ds=d({mode:oe(["auto","required","none"]).optional()}),ps=d({type:p("tool_result"),toolUseId:c().describe("The unique identifier for the corresponding tool call."),content:S(gt),structuredContent:D().optional(),isError:O().optional(),_meta:I(c(),D()).optional()}),hs=qo("type",[po,ho,mo]),Nt=qo("type",[po,ho,mo,Bn,ps]),ms=d({role:Rt,content:M([Nt,S(Nt)]),_meta:I(c(),D()).optional()}),fs=qt.extend({messages:S(ms),modelPreferences:us.optional(),systemPrompt:c().optional(),includeContext:oe(["none","thisServer","allServers"]).optional(),temperature:w().optional(),maxTokens:w().int(),stopSequences:S(c()).optional(),metadata:Me.optional(),tools:S(Ut).optional(),toolChoice:ds.optional()}),gs=Ae.extend({method:p("sampling/createMessage"),params:fs}),Ss=Ne.extend({model:c(),stopReason:G(oe(["endTurn","stopSequence","maxTokens"]).or(c())),role:Rt,content:hs}),_s=Ne.extend({model:c(),stopReason:G(oe(["endTurn","stopSequence","maxTokens","toolUse"]).or(c())),role:Rt,content:M([Nt,S(Nt)])}),rr=d({type:p("boolean"),title:c().optional(),description:c().optional(),default:O().optional()}),So=d({type:p("string"),title:c().optional(),description:c().optional(),minLength:w().optional(),maxLength:w().optional(),format:oe(["email","uri","date","date-time"]).optional(),default:c().optional()}),_o=d({type:oe(["number","integer"]),title:c().optional(),description:c().optional(),minimum:w().optional(),maximum:w().optional(),default:w().optional()}),nr=d({type:p("string"),title:c().optional(),description:c().optional(),enum:S(c()),default:c().optional()}),sr=d({type:p("string"),title:c().optional(),description:c().optional(),oneOf:S(d({const:c(),title:c()})),default:c().optional()}),ir=d({type:p("string"),title:c().optional(),description:c().optional(),enum:S(c()),enumNames:S(c()).optional(),default:c().optional()}),bs=M([nr,sr]),ar=d({type:p("array"),title:c().optional(),description:c().optional(),minItems:w().optional(),maxItems:w().optional(),items:d({type:p("string"),enum:S(c())}),default:S(c()).optional()}),cr=d({type:p("array"),title:c().optional(),description:c().optional(),minItems:w().optional(),maxItems:w().optional(),items:d({anyOf:S(d({const:c(),title:c()}))}),default:S(c()).optional()}),ys=M([ar,cr]),vs=M([ir,bs,ys]),lr=M([vs,rr,So,_o]),bo=qt.extend({mode:p("form").optional(),message:c(),requestedSchema:d({type:p("object"),properties:I(c(),lr),required:S(c()).optional()}).catchall(D())}),zs=qt.extend({mode:p("url"),message:c(),elicitationId:c(),url:c().url()}),ws=M([bo,zs]),Rs=Ae.extend({method:p("elicitation/create"),params:ws}),xs=Ge.extend({elicitationId:c()}),Es=Fe.extend({method:p("notifications/elicitation/complete"),params:xs}),Ps=Ne.extend({action:oe(["accept","decline","cancel"]),content:ro((e)=>e===null?void 0:e,I(c(),M([c(),w(),O(),S(c())])).optional())}),Ts=d({type:p("ref/resource"),uri:c()}),ks=d({type:p("ref/prompt"),name:c()}),$s=De.extend({ref:M([ks,Ts]),argument:d({name:c(),value:c()}),context:d({arguments:I(c(),c()).optional()}).optional()}),Cs=Ae.extend({method:p("completion/complete"),params:$s}),Is=Ne.extend({completion:K({values:S(c()).max(100),total:G(w().int()),hasMore:G(O())})}),Os=d({uri:c().startsWith("file://"),name:c().optional(),_meta:I(c(),D()).optional()}),Ms=Ae.extend({method:p("roots/list"),params:De.optional()}),As=Ne.extend({roots:S(Os)}),Ns=Fe.extend({method:p("notifications/roots/list_changed"),params:Ge.optional()}),ea=K({ttl:w().optional(),pollInterval:w().optional()}),qs=oe(["working","input_required","completed","failed","cancelled"]),xt=d({taskId:c(),status:qs,ttl:M([w(),oo()]),createdAt:c(),lastUpdatedAt:c(),pollInterval:G(w()),statusMessage:G(c())}),ta=Ne.extend({task:xt}),js=Ge.merge(xt),oa=Fe.extend({method:p("notifications/tasks/status"),params:js}),ra=Ae.extend({method:p("tasks/get"),params:De.extend({taskId:c()})}),na=Ne.merge(xt),sa=Ae.extend({method:p("tasks/result"),params:De.extend({taskId:c()})}),ia=Ne.loose(),aa=zt.extend({method:p("tasks/list")}),ca=wt.extend({tasks:S(xt)}),la=Ae.extend({method:p("tasks/cancel"),params:De.extend({taskId:c()})}),ua=Ne.merge(xt),da=M([Wo,hn,gn,Cs,is,Jn,Vn,vn,wn,En,$n,In,Mn,os,Xn]),pa=M([Bo,Ko,fn,Ns]),ha=M([jt,Ss,_s,Ps,As]),ma=M([Wo,gs,Rs,Ms]),fa=M([Bo,Ko,cs,Un,Tn,rs,Kn,Nn,Es]),ga=M([jt,mn,Lt,Is,Wn,Hn,zn,Rn,Pn,Zt,es,jn]);var Ve=Hi().superRefine((e,t)=>{if(!URL.canParse(e))return t.addIssue({code:xh.custom,message:"URL must be parseable",fatal:!0}),Oa}).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=K({resource:c().url(),authorization_servers:S(Ve).optional(),jwks_uri:c().url().optional(),scopes_supported:S(c()).optional(),bearer_methods_supported:S(c()).optional(),resource_signing_alg_values_supported:S(c()).optional(),resource_name:c().optional(),resource_documentation:c().optional(),resource_policy_uri:c().url().optional(),resource_tos_uri:c().url().optional(),tls_client_certificate_bound_access_tokens:O().optional(),authorization_details_types_supported:S(c()).optional(),dpop_signing_alg_values_supported:S(c()).optional(),dpop_bound_access_tokens_required:O().optional()}),ur=K({issuer:c(),authorization_endpoint:Ve,token_endpoint:Ve,registration_endpoint:Ve.optional(),scopes_supported:S(c()).optional(),response_types_supported:S(c()),response_modes_supported:S(c()).optional(),grant_types_supported:S(c()).optional(),token_endpoint_auth_methods_supported:S(c()).optional(),token_endpoint_auth_signing_alg_values_supported:S(c()).optional(),service_documentation:Ve.optional(),revocation_endpoint:Ve.optional(),revocation_endpoint_auth_methods_supported:S(c()).optional(),revocation_endpoint_auth_signing_alg_values_supported:S(c()).optional(),introspection_endpoint:c().optional(),introspection_endpoint_auth_methods_supported:S(c()).optional(),introspection_endpoint_auth_signing_alg_values_supported:S(c()).optional(),code_challenge_methods_supported:S(c()).optional(),client_id_metadata_document_supported:O().optional(),authorization_response_iss_parameter_supported:O().optional().catch(void 0),dpop_signing_alg_values_supported:S(c()).optional()}),Us=K({issuer:c(),authorization_endpoint:Ve,token_endpoint:Ve,userinfo_endpoint:Ve.optional(),jwks_uri:Ve,registration_endpoint:Ve.optional(),scopes_supported:S(c()).optional(),response_types_supported:S(c()),response_modes_supported:S(c()).optional(),grant_types_supported:S(c()).optional(),acr_values_supported:S(c()).optional(),subject_types_supported:S(c()),id_token_signing_alg_values_supported:S(c()),id_token_encryption_alg_values_supported:S(c()).optional(),id_token_encryption_enc_values_supported:S(c()).optional(),userinfo_signing_alg_values_supported:S(c()).optional(),userinfo_encryption_alg_values_supported:S(c()).optional(),userinfo_encryption_enc_values_supported:S(c()).optional(),request_object_signing_alg_values_supported:S(c()).optional(),request_object_encryption_alg_values_supported:S(c()).optional(),request_object_encryption_enc_values_supported:S(c()).optional(),token_endpoint_auth_methods_supported:S(c()).optional(),token_endpoint_auth_signing_alg_values_supported:S(c()).optional(),display_values_supported:S(c()).optional(),claim_types_supported:S(c()).optional(),claims_supported:S(c()).optional(),service_documentation:c().optional(),claims_locales_supported:S(c()).optional(),ui_locales_supported:S(c()).optional(),claims_parameter_supported:O().optional(),request_parameter_supported:O().optional(),request_uri_parameter_supported:O().optional(),require_request_uri_registration:O().optional(),op_policy_uri:Ve.optional(),op_tos_uri:Ve.optional(),client_id_metadata_document_supported:O().optional(),authorization_response_iss_parameter_supported:O().optional().catch(void 0)}),Zs=d({...Us.shape,...ur.pick({code_challenge_methods_supported:!0}).shape}),dr=d({access_token:c(),id_token:c().optional(),token_type:c(),expires_in:Bg().optional(),scope:c().optional(),refresh_token:c().optional(),issuer:c().optional().catch(void 0)}).strip(),Ds=d({issued_token_type:p("urn:ietf:params:oauth:token-type:id-jag"),access_token:c(),token_type:c().optional(),expires_in:w().optional(),scope:c().optional()}).strip(),pr=d({error:c(),error_description:c().optional(),error_uri:c().optional()}),Jc=Ve.optional().or(p("").transform(()=>{return})),Vs=d({redirect_uris:S(Ve),token_endpoint_auth_method:c().optional(),grant_types:S(c()).optional(),response_types:S(c()).optional(),application_type:c().optional(),client_name:c().optional(),client_uri:Ve.optional(),logo_uri:Jc,scope:c().optional(),contacts:S(c()).optional(),tos_uri:Jc,policy_uri:c().optional(),jwks_uri:Ve.optional(),jwks:Ji().optional(),software_id:c().optional(),software_version:c().optional(),software_statement:c().optional()}).strip(),Hs=d({client_id:c(),client_secret:c().optional(),client_id_issued_at:w().optional(),client_secret_expires_at:w().optional(),issuer:c().optional().catch(void 0)}).strip(),Fs=Vs.merge(Hs),Sa=d({error:c(),error_description:c().optional()}).strip(),_a=d({token:c(),token_type_hint:c().optional()}).strip();var Yc=Symbol.for("mcp.sdk.errorBrands");function Vt(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,Yc,{value:o,enumerable:!1,configurable:!0})}function et(e,t){try{if(typeof t==="object"&&t!==null&&Object.prototype.hasOwnProperty.call(e,"mcpBrand")&&typeof e.mcpBrand==="string"&&Object.prototype.hasOwnProperty.call(t,Yc)){let o=t[Yc];if(o&&typeof o.has==="function"&&o.has(e.mcpBrand))return!0}}catch{}return Function.prototype[Symbol.hasInstance].call(e,t)}var Wh=class e extends Error{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.OAuthError"})}static[Symbol.hasInstance](t){return et(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 et(this,t)}constructor(t,o,r){super(o);this.code=t,this.errorUri=r,this.name="OAuthError",Vt(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)}},F=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}({}),L=class extends Error{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.SdkError"})}static[Symbol.hasInstance](e){return et(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 et(this,e)}constructor(e,t,o,r){super(t,r);this.code=e,this.data=o,this.name="SdkError",Vt(this,new.target)}},Ys=class extends L{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 Kh="2026-07-28",ol=[Kh];function Pt(e){return e>=Kh}function rl(e){return e.filter((t)=>!Pt(t))}function Qs(e){return e.filter((t)=>Pt(t))}function Yh(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 Qh=["task","inputRequests","requestState"];function Kg(e){if(e===null||typeof e!=="object"||Array.isArray(e)||e.content!==void 0||Qh.some((t)=>(t in e)))return e;return{...e,content:[]}}function Yg(){let e=nn(()=>M([c(),w(),O(),oo(),I(c(),e),S(e)])),t=I(c(),e),o=M([c(),w().int()]),r=c(),n=d({ttl:w().optional()}),i=d({taskId:c()}),s=K({progressToken:o.optional(),"io.modelcontextprotocol/related-task":i.optional()}),a=d({_meta:s.optional()}),l=a.extend({task:n.optional()}),u=d({method:c(),params:a.loose().optional()}),m=d({_meta:s.optional()}),h=d({method:c(),params:m.loose().optional()}),f=K({_meta:s.optional()}),g=M([c(),w().int()]),y=f.strict(),z=m.extend({requestId:g.optional(),reason:c().optional()}),_=h.extend({method:p("notifications/cancelled"),params:z}),x=d({src:c(),mimeType:c().optional(),sizes:S(c()).optional(),theme:oe(["light","dark"]).optional()}),E=d({icons:S(x).optional()}),R=d({name:c(),title:c().optional()}),T=R.extend({...R.shape,...E.shape,version:c(),websiteUrl:c().optional(),description:c().optional()}),q=bt(d({applyDefaults:O().optional()}),t),J=ro((Be)=>{if(Be&&typeof Be==="object"&&!Array.isArray(Be)&&Object.keys(Be).length===0)return{form:{}};return Be},bt(d({form:q.optional(),url:t.optional()}),t.optional())),ae=K({list:t.optional(),cancel:t.optional(),requests:K({sampling:K({createMessage:t.optional()}).optional(),elicitation:K({create:t.optional()}).optional()}).optional()}),re=K({list:t.optional(),cancel:t.optional(),requests:K({tools:K({call:t.optional()}).optional()}).optional()}),ie=d({experimental:I(c(),t).optional(),sampling:d({context:t.optional(),tools:t.optional()}).optional(),elicitation:J.optional(),roots:d({listChanged:O().optional()}).optional(),tasks:ae.optional(),extensions:I(c(),t).optional()}),Ee=a.extend({protocolVersion:c(),capabilities:ie,clientInfo:T}),se=u.extend({method:p("initialize"),params:Ee}),ee=d({experimental:I(c(),t).optional(),logging:t.optional(),completions:t.optional(),prompts:d({listChanged:O().optional()}).optional(),resources:d({subscribe:O().optional(),listChanged:O().optional()}).optional(),tools:d({listChanged:O().optional()}).optional(),tasks:re.optional(),extensions:I(c(),t).optional()}),le=f.extend({protocolVersion:c(),capabilities:ee,serverInfo:T,instructions:c().optional()}),ge=h.extend({method:p("notifications/initialized"),params:m.optional()}),de=u.extend({method:p("ping"),params:a.optional()}),pe=d({progress:w(),total:G(w()),message:G(c())}),ke=d({...m.shape,...pe.shape,progressToken:o}),$e=h.extend({method:p("notifications/progress"),params:ke}),Ue=a.extend({cursor:r.optional()}),W=u.extend({params:Ue.optional()}),ne=f.extend({nextCursor:r.optional()}),te=d({uri:c(),mimeType:G(c()),_meta:I(c(),D()).optional()}),Oe=te.extend({text:c()}),A=c().refine((Be)=>{try{return atob(Be),!0}catch{return!1}},{message:"Invalid Base64 string"}),V=te.extend({blob:A}),Y=oe(["user","assistant"]),B=d({audience:S(Y).optional(),priority:w().min(0).max(1).optional(),lastModified:No({offset:!0}).optional()}),ue=d({...R.shape,...E.shape,uri:c(),description:G(c()),mimeType:G(c()),size:G(w()),annotations:B.optional(),_meta:G(K({}))}),Ze=d({...R.shape,...E.shape,uriTemplate:c(),description:G(c()),mimeType:G(c()),annotations:B.optional(),_meta:G(K({}))}),ve=W.extend({method:p("resources/list")}),Pe=ne.extend({resources:S(ue)}),he=W.extend({method:p("resources/templates/list")}),Te=ne.extend({resourceTemplates:S(Ze)}),je=a.extend({uri:c()}),ze=je,be=u.extend({method:p("resources/read"),params:ze}),we=f.extend({contents:S(M([Oe,V]))}),me=h.extend({method:p("notifications/resources/list_changed"),params:m.optional()}),ce=je,b=u.extend({method:p("resources/subscribe"),params:ce}),X=je,N=u.extend({method:p("resources/unsubscribe"),params:X}),C=m.extend({uri:c()}),j=h.extend({method:p("notifications/resources/updated"),params:C}),k=d({name:c(),description:G(c()),required:G(O())}),P=d({...R.shape,...E.shape,description:G(c()),arguments:G(S(k)),_meta:G(K({}))}),U=W.extend({method:p("prompts/list")}),Z=ne.extend({prompts:S(P)}),Se=a.extend({name:c(),arguments:I(c(),c()).optional()}),We=u.extend({method:p("prompts/get"),params:Se}),nt=d({type:p("text"),text:c(),annotations:B.optional(),_meta:I(c(),D()).optional()}),Ht=d({type:p("image"),data:A,mimeType:c(),annotations:B.optional(),_meta:I(c(),D()).optional()}),Ft=d({type:p("audio"),data:A,mimeType:c(),annotations:B.optional(),_meta:I(c(),D()).optional()}),gr=d({type:p("tool_use"),name:c(),id:c(),input:I(c(),D()),_meta:I(c(),D()).optional()}),Tt=d({type:p("resource"),resource:M([Oe,V]),annotations:B.optional(),_meta:I(c(),D()).optional()}),Sr=ue.extend({type:p("resource_link")}),st=M([nt,Ht,Ft,Sr,Tt]),vo=d({role:Y,content:st}),zo=f.extend({description:c().optional(),messages:S(vo)}),Jt=h.extend({method:p("notifications/prompts/list_changed"),params:m.optional()}),_r=d({title:c().optional(),readOnlyHint:O().optional(),destructiveHint:O().optional(),idempotentHint:O().optional(),openWorldHint:O().optional()}),wo=d({taskSupport:oe(["required","optional","forbidden"]).optional()}),Bt=d({...R.shape,...E.shape,description:c().optional(),inputSchema:d({type:p("object"),properties:I(c(),e).optional(),required:S(c()).optional()}).catchall(D()),outputSchema:d({type:p("object"),properties:I(c(),e).optional(),required:S(c()).optional()}).catchall(D()).optional(),annotations:_r.optional(),execution:wo.optional(),_meta:I(c(),D()).optional()}),Ro=W.extend({method:p("tools/list")}),xo=ne.extend({tools:S(Bt)}),Eo=f.extend({content:S(st),structuredContent:I(c(),D()).optional(),isError:O().optional()}),Je=l.extend({name:c(),arguments:I(c(),D()).optional()}),br=u.extend({method:p("tools/call"),params:Je}),ii=h.extend({method:p("notifications/tools/list_changed"),params:m.optional()}),Po=oe(["debug","info","notice","warning","error","critical","alert","emergency"]),yr=a.extend({level:Po}),vr=u.extend({method:p("logging/setLevel"),params:yr}),zr=m.extend({level:Po,logger:c().optional(),data:D()}),wr=h.extend({method:p("notifications/message"),params:zr}),Rr=d({name:c().optional()}),xr=d({hints:S(Rr).optional(),costPriority:w().min(0).max(1).optional(),speedPriority:w().min(0).max(1).optional(),intelligencePriority:w().min(0).max(1).optional()}),Er=d({mode:oe(["auto","required","none"]).optional()}),ai=d({type:p("tool_result"),toolUseId:c().describe("The unique identifier for the corresponding tool call."),content:S(st),structuredContent:d({}).loose().optional(),isError:O().optional(),_meta:I(c(),D()).optional()}),Pr=qo("type",[nt,Ht,Ft]),kt=qo("type",[nt,Ht,Ft,gr,ai]),Tr=d({role:Y,content:M([kt,S(kt)]),_meta:I(c(),D()).optional()}),kr=l.extend({messages:S(Tr),modelPreferences:xr.optional(),systemPrompt:c().optional(),includeContext:oe(["none","thisServer","allServers"]).optional(),temperature:w().optional(),maxTokens:w().int(),stopSequences:S(c()).optional(),metadata:t.optional(),tools:S(Bt).optional(),toolChoice:Er.optional()}),$r=u.extend({method:p("sampling/createMessage"),params:kr}),Cr=f.extend({model:c(),stopReason:G(oe(["endTurn","stopSequence","maxTokens"]).or(c())),role:Y,content:Pr}),Ir=f.extend({model:c(),stopReason:G(oe(["endTurn","stopSequence","maxTokens","toolUse"]).or(c())),role:Y,content:M([kt,S(kt)])}),Or=d({type:p("boolean"),title:c().optional(),description:c().optional(),default:O().optional()}),Mr=d({type:p("string"),title:c().optional(),description:c().optional(),minLength:w().optional(),maxLength:w().optional(),format:oe(["email","uri","date","date-time"]).optional(),default:c().optional()}),Ar=d({type:oe(["number","integer"]),title:c().optional(),description:c().optional(),minimum:w().optional(),maximum:w().optional(),default:w().optional()}),Nr=d({type:p("string"),title:c().optional(),description:c().optional(),enum:S(c()),default:c().optional()}),qr=d({type:p("string"),title:c().optional(),description:c().optional(),oneOf:S(d({const:c(),title:c()})),default:c().optional()}),jr=d({type:p("string"),title:c().optional(),description:c().optional(),enum:S(c()),enumNames:S(c()).optional(),default:c().optional()}),Lr=M([Nr,qr]),Gt=d({type:p("array"),title:c().optional(),description:c().optional(),minItems:w().optional(),maxItems:w().optional(),items:d({type:p("string"),enum:S(c())}),default:S(c()).optional()}),Wt=d({type:p("array"),title:c().optional(),description:c().optional(),minItems:w().optional(),maxItems:w().optional(),items:d({anyOf:S(d({const:c(),title:c()}))}),default:S(c()).optional()}),ci=M([Gt,Wt]),li=M([jr,Lr,ci]),tt=M([li,Or,Mr,Ar]),ot=l.extend({mode:p("form").optional(),message:c(),requestedSchema:d({type:p("object"),properties:I(c(),tt),required:S(c()).optional()}).catchall(D())}),Ur=l.extend({mode:p("url"),message:c(),elicitationId:c(),url:c().url()}),it=M([ot,Ur]),ui=u.extend({method:p("elicitation/create"),params:it}),di=m.extend({elicitationId:c()}),pi=h.extend({method:p("notifications/elicitation/complete"),params:di}),hi=f.extend({action:oe(["accept","decline","cancel"]),content:ro((Be)=>Be===null?void 0:Be,I(c(),M([c(),w(),O(),S(c())])).optional())}),mi=d({type:p("ref/resource"),uri:c()}),fi=d({type:p("ref/prompt"),name:c()}),gi=a.extend({ref:M([fi,mi]),argument:d({name:c(),value:c()}),context:d({arguments:I(c(),c()).optional()}).optional()}),Zr=u.extend({method:p("completion/complete"),params:gi}),Si=f.extend({completion:K({values:S(c()).max(100),total:G(w().int()),hasMore:G(O())})}),_i=d({uri:c().startsWith("file://"),name:c().optional(),_meta:I(c(),D()).optional()}),To=u.extend({method:p("roots/list"),params:a.optional()}),Dr=f.extend({roots:S(_i)}),bi=h.extend({method:p("notifications/roots/list_changed"),params:m.optional()}),yi=K({ttl:w().optional(),pollInterval:w().optional()}),Vr=oe(["working","input_required","completed","failed","cancelled"]),$t=d({taskId:c(),status:Vr,ttl:M([w(),oo()]),createdAt:c(),lastUpdatedAt:c(),pollInterval:G(w()),statusMessage:G(c())}),Xe=f.extend({task:$t}),vi=m.merge($t),Kt=h.extend({method:p("notifications/tasks/status"),params:vi}),ko=u.extend({method:p("tasks/get"),params:a.extend({taskId:c()})}),$o=f.merge($t),Co=u.extend({method:p("tasks/result"),params:a.extend({taskId:c()})}),Ia=f.loose(),Ke=W.extend({method:p("tasks/list")}),Le=ne.extend({tasks:S($t)}),Yt=u.extend({method:p("tasks/cancel"),params:a.extend({taskId:c()})});return{JSONValueSchema:e,JSONObjectSchema:t,ProgressTokenSchema:o,CursorSchema:r,TaskMetadataSchema:n,RelatedTaskMetadataSchema:i,RequestMetaSchema:s,BaseRequestParamsSchema:a,TaskAugmentedRequestParamsSchema:l,RequestSchema:u,NotificationsParamsSchema:m,NotificationSchema:h,ResultSchema:f,RequestIdSchema:g,EmptyResultSchema:y,CancelledNotificationParamsSchema:z,CancelledNotificationSchema:_,IconSchema:x,IconsSchema:E,BaseMetadataSchema:R,ImplementationSchema:T,ClientTasksCapabilitySchema:ae,ServerTasksCapabilitySchema:re,ClientCapabilitiesSchema:ie,InitializeRequestParamsSchema:Ee,InitializeRequestSchema:se,ServerCapabilitiesSchema:ee,InitializeResultSchema:le,InitializedNotificationSchema:ge,PingRequestSchema:de,ProgressSchema:pe,ProgressNotificationParamsSchema:ke,ProgressNotificationSchema:$e,PaginatedRequestParamsSchema:Ue,PaginatedRequestSchema:W,PaginatedResultSchema:ne,ResourceContentsSchema:te,TextResourceContentsSchema:Oe,BlobResourceContentsSchema:V,RoleSchema:Y,AnnotationsSchema:B,ResourceSchema:ue,ResourceTemplateSchema:Ze,ListResourcesRequestSchema:ve,ListResourcesResultSchema:Pe,ListResourceTemplatesRequestSchema:he,ListResourceTemplatesResultSchema:Te,ResourceRequestParamsSchema:je,ReadResourceRequestParamsSchema:ze,ReadResourceRequestSchema:be,ReadResourceResultSchema:we,ResourceListChangedNotificationSchema:me,SubscribeRequestParamsSchema:ce,SubscribeRequestSchema:b,UnsubscribeRequestParamsSchema:X,UnsubscribeRequestSchema:N,ResourceUpdatedNotificationParamsSchema:C,ResourceUpdatedNotificationSchema:j,PromptArgumentSchema:k,PromptSchema:P,ListPromptsRequestSchema:U,ListPromptsResultSchema:Z,GetPromptRequestParamsSchema:Se,GetPromptRequestSchema:We,TextContentSchema:nt,ImageContentSchema:Ht,AudioContentSchema:Ft,ToolUseContentSchema:gr,EmbeddedResourceSchema:Tt,ResourceLinkSchema:Sr,ContentBlockSchema:st,PromptMessageSchema:vo,GetPromptResultSchema:zo,PromptListChangedNotificationSchema:Jt,ToolAnnotationsSchema:_r,ToolExecutionSchema:wo,ToolSchema:Bt,ListToolsRequestSchema:Ro,ListToolsResultSchema:xo,CallToolResultSchema:Eo,CallToolRequestParamsSchema:Je,CallToolRequestSchema:br,ToolListChangedNotificationSchema:ii,LoggingLevelSchema:Po,SetLevelRequestParamsSchema:yr,SetLevelRequestSchema:vr,LoggingMessageNotificationParamsSchema:zr,LoggingMessageNotificationSchema:wr,ModelHintSchema:Rr,ModelPreferencesSchema:xr,ToolChoiceSchema:Er,ToolResultContentSchema:ai,SamplingContentSchema:Pr,SamplingMessageContentBlockSchema:kt,SamplingMessageSchema:Tr,CreateMessageRequestParamsSchema:kr,CreateMessageRequestSchema:$r,CreateMessageResultSchema:Cr,CreateMessageResultWithToolsSchema:Ir,BooleanSchemaSchema:Or,StringSchemaSchema:Mr,NumberSchemaSchema:Ar,UntitledSingleSelectEnumSchemaSchema:Nr,TitledSingleSelectEnumSchemaSchema:qr,LegacyTitledEnumSchemaSchema:jr,SingleSelectEnumSchemaSchema:Lr,UntitledMultiSelectEnumSchemaSchema:Gt,TitledMultiSelectEnumSchemaSchema:Wt,MultiSelectEnumSchemaSchema:ci,EnumSchemaSchema:li,PrimitiveSchemaDefinitionSchema:tt,ElicitRequestFormParamsSchema:ot,ElicitRequestURLParamsSchema:Ur,ElicitRequestParamsSchema:it,ElicitRequestSchema:ui,ElicitationCompleteNotificationParamsSchema:di,ElicitationCompleteNotificationSchema:pi,ElicitResultSchema:hi,ResourceTemplateReferenceSchema:mi,PromptReferenceSchema:fi,CompleteRequestParamsSchema:gi,CompleteRequestSchema:Zr,CompleteResultSchema:Si,RootSchema:_i,ListRootsRequestSchema:To,ListRootsResultSchema:Dr,RootsListChangedNotificationSchema:bi,TaskCreationParamsSchema:yi,TaskStatusSchema:Vr,TaskSchema:$t,CreateTaskResultSchema:Xe,TaskStatusNotificationParamsSchema:vi,TaskStatusNotificationSchema:Kt,GetTaskRequestSchema:ko,GetTaskResultSchema:$o,GetTaskPayloadRequestSchema:Co,GetTaskPayloadResultSchema:Ia,ListTasksRequestSchema:Ke,ListTasksResultSchema:Le,CancelTaskRequestSchema:Yt,CancelTaskResultSchema:f.merge($t),ClientRequestSchema:M([de,se,Zr,vr,We,U,ve,he,be,b,N,br,Ro,ko,Co,Ke,Yt]),ClientNotificationSchema:M([_,$e,ge,bi,Kt]),ClientResultSchema:M([y,Cr,Ir,hi,Dr,$o,Le,Xe]),ServerRequestSchema:M([de,$r,ui,To,ko,Co,Ke,Yt]),ServerNotificationSchema:M([_,$e,wr,j,me,ii,Jt,Kt,pi]),ServerResultSchema:M([y,le,Si,zo,Z,Pe,Te,we,Eo,xo,$o,Le,Xe]),CallToolResultWireSchema:D().superRefine((Be,Sf)=>{if(typeof Be!=="object"||Be===null||Array.isArray(Be)||Be.content!==void 0)return;for(let wl of Qh)if(wl in Be){Sf.addIssue({code:"custom",message:`content is required when the body carries '${wl}' — another result family cannot default into an empty tools/call success`});return}}).transform(Kg).pipe(Eo)}}var Qg;function Xh(){return Qg??=Yg()}function em(e){return e.type!=="object"}var Xg=new Set(["const","enum","default","examples"]),eS=new Set(["properties","patternProperties","$defs","definitions","dependentSchemas","dependencies"]);function qh(e){return e!==void 0&&!(typeof e==="string"&&e.startsWith("#"))}function tS(e){let t=typeof e.$schema==="string"?e.$schema:void 0;if(qh(e.$id))return{...t!==void 0&&{$schema:t},type:"object",properties:{result:e},required:["result"]};let o=Tl(e.$schema)&&e.$recursiveAnchor!==!0,r=(n,i)=>{if(Array.isArray(n))return n.map((l)=>r(l,!1));if(n===null||typeof n!=="object")return n;if(!i&&qh(n.$id))return n;let s={},a=!1;for(let[l,u]of Object.entries(n))if(i)s[l]=r(u,!1);else if((l==="$ref"||l==="$dynamicRef")&&typeof u==="string")s[l]=u==="#"?"#/properties/result":u.startsWith("#/")?`#/properties/result${u.slice(1)}`:u;else if(l==="$recursiveRef"&&u==="#"&&o)a=!0;else if(Xg.has(l))s[l]=u;else if(eS.has(l))s[l]=r(u,!0);else s[l]=r(u,!1);if(a)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 tm={ping:null,initialize:null,"completion/complete":null,"logging/setLevel":null,"prompts/get":null,"prompts/list":null,"resources/list":null,"resources/templates/list":null,"resources/read":null,"resources/subscribe":null,"resources/unsubscribe":null,"tools/call":null,"tools/list":null,"tasks/get":null,"tasks/result":null,"tasks/list":null,"tasks/cancel":null,"sampling/createMessage":null,"elicitation/create":null,"roots/list":null},om={"notifications/cancelled":null,"notifications/progress":null,"notifications/initialized":null,"notifications/roots/list_changed":null,"notifications/tasks/status":null,"notifications/message":null,"notifications/resources/updated":null,"notifications/resources/list_changed":null,"notifications/tools/list_changed":null,"notifications/prompts/list_changed":null,"notifications/elicitation/complete":null},oS={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},ba;function nl(){if(ba)return ba;let e=Xh();return ba={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}},ba}function rm(e){return Object.prototype.hasOwnProperty.call(tm,e)}function nm(e){return Object.prototype.hasOwnProperty.call(om,e)}function rS(e){return Object.prototype.hasOwnProperty.call(oS,e)}function nS(e){return rS(e)?nl().resultSchemas[e]:void 0}function sS(e){return rm(e)?nl().requestSchemas[e]:void 0}function iS(e){return nm(e)?nl().notificationSchemas[e]:void 0}var Ez=Object.keys(tm),Pz=Object.keys(om);function Qc(e){return e!==null&&typeof e==="object"&&!Array.isArray(e)}function ya(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 jh={ok:!1,reason:"not-in-era"};function Lh(e){return Qc(e)&&Qc(e.outputSchema)&&em(e.outputSchema)}function Uh(e){return e}var sl={era:"2025-11-25",hasRequestMethod:rm,hasNotificationMethod:nm,validateRequest:(e,t)=>ya(sS(e),t),validateResult:(e,t)=>ya(nS(e),t),validateNotification:(e,t)=>ya(iS(e),t),hasInputRequestMethod:()=>!1,validateInputRequest:()=>jh,validateInputResponse:()=>jh,samplingResultVariant:(e,t)=>{let o=Xh();return ya(e?o.CreateMessageResultWithToolsSchema:o.CreateMessageResultSchema,t)},outboundEnvelope:(e)=>{return},validateEnvelopeMeta:(e)=>[],projectCallToolResult(e,t){let o=Yh(e),r=o.structuredContent;if(r===void 0)return o;let n=typeof r!=="object"||r===null||Array.isArray(r),i=t!==void 0&&em(t);if(!n&&!i)return o;return{...o,structuredContent:{result:r}}},decodeResult(e,t){if(Qc(t)&&"resultType"in t){let o={...t};return delete o.resultType,{kind:"complete",result:Uh(o)}}return{kind:"complete",result:Uh(t)}},encodeResult(e,t){if(e!=="tools/list")return t;let o=t.tools;if(!Array.isArray(o)||!o.some((r)=>Lh(r)))return t;return{...t,tools:o.map((r)=>Lh(r)?{...r,outputSchema:tS(r.outputSchema)}:r)}},encodeErrorCode:(e)=>e===-32002?-32602:e,checkInboundEnvelope:(e)=>{return}};function aS(){let e=nn(()=>M([c(),w(),O(),oo(),I(c(),e),S(e)])),t=I(c(),e),o=M([c(),w().int()]),r=c(),n=M([c(),w().int()]),i=oe(["user","assistant"]),s=oe(["debug","info","notice","warning","error","critical","alert","emergency"]),a=c().refine((Le)=>{try{return atob(Le),!0}catch{return!1}},{message:"Invalid Base64 string"}),l=d({ttl:w().optional()}),u=d({taskId:c()}),m=K({progressToken:o.optional(),"io.modelcontextprotocol/related-task":u.optional()}),h=d({_meta:m.optional()}),f=h.extend({task:l.optional()}),g=d({_meta:m.optional()}),y=d({method:c(),params:g.loose().optional()}),z=d({src:c(),mimeType:c().optional(),sizes:S(c()).optional(),theme:oe(["light","dark"]).optional()}),_=d({icons:S(z).optional()}),x=d({name:c(),title:c().optional()}),E=x.extend({...x.shape,..._.shape,version:c(),websiteUrl:c().optional(),description:c().optional()}),R=bt(d({applyDefaults:O().optional()}),t),T=ro((Le)=>{if(Le&&typeof Le==="object"&&!Array.isArray(Le)&&Object.keys(Le).length===0)return{form:{}};return Le},bt(d({form:R.optional(),url:t.optional()}),t.optional())),q=K({list:t.optional(),cancel:t.optional(),requests:K({sampling:K({createMessage:t.optional()}).optional(),elicitation:K({create:t.optional()}).optional()}).optional()}),J=K({list:t.optional(),cancel:t.optional(),requests:K({tools:K({call:t.optional()}).optional()}).optional()}),ae=d({experimental:I(c(),t).optional(),sampling:d({context:t.optional(),tools:t.optional()}).optional(),elicitation:T.optional(),roots:d({listChanged:O().optional()}).optional(),tasks:q.optional(),extensions:I(c(),t).optional()}),re=d({experimental:I(c(),t).optional(),logging:t.optional(),completions:t.optional(),prompts:d({listChanged:O().optional()}).optional(),resources:d({subscribe:O().optional(),listChanged:O().optional()}).optional(),tools:d({listChanged:O().optional()}).optional(),tasks:J.optional(),extensions:I(c(),t).optional()}),ie=d({progress:w(),total:G(w()),message:G(c())}),Ee=d({...g.shape,...ie.shape,progressToken:o}),se=y.extend({method:p("notifications/progress"),params:Ee}),ee=g.extend({level:s,logger:c().optional(),data:D()}),le=y.extend({method:p("notifications/message"),params:ee}),ge=d({uri:c(),mimeType:G(c()),_meta:I(c(),D()).optional()}),de=ge.extend({text:c()}),pe=ge.extend({blob:a}),ke=d({audience:S(i).optional(),priority:w().min(0).max(1).optional(),lastModified:No({offset:!0}).optional()}),$e=d({...x.shape,..._.shape,uri:c(),description:G(c()),mimeType:G(c()),size:G(w()),annotations:ke.optional(),_meta:G(K({}))}),Ue=d({...x.shape,..._.shape,uriTemplate:c(),description:G(c()),mimeType:G(c()),annotations:ke.optional(),_meta:G(K({}))}),W=y.extend({method:p("notifications/resources/list_changed"),params:g.optional()}),ne=g.extend({uri:c()}),te=y.extend({method:p("notifications/resources/updated"),params:ne}),Oe=d({name:c(),description:G(c()),required:G(O())}),A=d({...x.shape,..._.shape,description:G(c()),arguments:G(S(Oe)),_meta:G(K({}))}),V=y.extend({method:p("notifications/prompts/list_changed"),params:g.optional()}),Y=d({type:p("text"),text:c(),annotations:ke.optional(),_meta:I(c(),D()).optional()}),B=d({type:p("image"),data:a,mimeType:c(),annotations:ke.optional(),_meta:I(c(),D()).optional()}),ue=d({type:p("audio"),data:a,mimeType:c(),annotations:ke.optional(),_meta:I(c(),D()).optional()}),Ze=d({type:p("tool_use"),name:c(),id:c(),input:I(c(),D()),_meta:I(c(),D()).optional()}),ve=d({type:p("resource"),resource:M([de,pe]),annotations:ke.optional(),_meta:I(c(),D()).optional()}),Pe=$e.extend({type:p("resource_link")}),he=M([Y,B,ue,Pe,ve]),Te=d({role:i,content:he}),je=d({title:c().optional(),readOnlyHint:O().optional(),destructiveHint:O().optional(),idempotentHint:O().optional(),openWorldHint:O().optional()}),ze=y.extend({method:p("notifications/tools/list_changed"),params:g.optional()}),be=d({name:c().optional()}),we=d({hints:S(be).optional(),costPriority:w().min(0).max(1).optional(),speedPriority:w().min(0).max(1).optional(),intelligencePriority:w().min(0).max(1).optional()}),me=d({mode:oe(["auto","required","none"]).optional()}),ce=d({type:p("boolean"),title:c().optional(),description:c().optional(),default:O().optional()}),b=d({type:p("string"),title:c().optional(),description:c().optional(),minLength:w().optional(),maxLength:w().optional(),format:oe(["email","uri","date","date-time"]).optional(),default:c().optional()}),X=d({type:oe(["number","integer"]),title:c().optional(),description:c().optional(),minimum:w().optional(),maximum:w().optional(),default:w().optional()}),N=d({type:p("string"),title:c().optional(),description:c().optional(),enum:S(c()),default:c().optional()}),C=d({type:p("string"),title:c().optional(),description:c().optional(),oneOf:S(d({const:c(),title:c()})),default:c().optional()}),j=d({type:p("string"),title:c().optional(),description:c().optional(),enum:S(c()),enumNames:S(c()).optional(),default:c().optional()}),k=M([N,C]),P=d({type:p("array"),title:c().optional(),description:c().optional(),minItems:w().optional(),maxItems:w().optional(),items:d({type:p("string"),enum:S(c())}),default:S(c()).optional()}),U=d({type:p("array"),title:c().optional(),description:c().optional(),minItems:w().optional(),maxItems:w().optional(),items:d({anyOf:S(d({const:c(),title:c()}))}),default:S(c()).optional()}),Z=M([P,U]),Se=M([j,k,Z]),We=M([Se,ce,b,X]),nt=f.extend({mode:p("form").optional(),message:c(),requestedSchema:d({type:p("object"),properties:I(c(),We),required:S(c()).optional()}).catchall(D())}),Ht=d({type:p("ref/resource"),uri:c()}),Ft=d({type:p("ref/prompt"),name:c()}),gr=d({uri:c().startsWith("file://"),name:c().optional(),_meta:I(c(),D()).optional()}),Tt=ae.shape,Sr=d({experimental:Tt.experimental,sampling:Tt.sampling,elicitation:Tt.elicitation,roots:Tt.roots,extensions:Tt.extensions}),st=re.shape,vo=d({experimental:st.experimental,logging:st.logging,completions:st.completions,prompts:st.prompts,resources:st.resources,tools:st.tools,extensions:st.extensions}),zo=K({progressToken:o.optional(),[no]:c(),[jo]:E.optional(),[so]:Sr,[Uo]:s.optional()}),Jt=d({...x.shape,..._.shape,description:c().optional(),inputSchema:K({$schema:c().optional(),type:p("object")}),outputSchema:K({$schema:c().optional()}).optional(),annotations:je.optional(),_meta:I(c(),D()).optional()}),_r=d({type:p("tool_result"),toolUseId:c(),content:S(he),structuredContent:D().optional(),isError:O().optional(),_meta:I(c(),D()).optional()}),wo=M([Y,B,ue,Ze,_r]),Bt=d({role:i,content:M([wo,S(wo)]),_meta:I(c(),D()).optional()}),Ro=c(),xo=K({[ht]:E.optional().catch(void 0)}),Eo=xo.optional();function Je(Le){return K({_meta:Eo,resultType:Ro.default("complete"),...Le})}let br=Je({}),ii=Je({nextCursor:r.optional()}),Po=Je({content:S(he),structuredContent:D().optional(),isError:O().optional()}),yr=Je({ttlMs:w().int().min(0),cacheScope:oe(["public","private"]),tools:S(Jt),nextCursor:r.optional()}),vr=Je({ttlMs:w().int().min(0),cacheScope:oe(["public","private"]),prompts:S(A),nextCursor:r.optional()}),zr=Je({description:c().optional(),messages:S(Te)}),wr=Je({ttlMs:w().int().min(0),cacheScope:oe(["public","private"]),resources:S($e),nextCursor:r.optional()}),Rr=Je({ttlMs:w().int().min(0),cacheScope:oe(["public","private"]),resourceTemplates:S(Ue),nextCursor:r.optional()}),xr=Je({ttlMs:w().int().min(0),cacheScope:oe(["public","private"]),contents:S(M([de,pe]))}),Er=Je({completion:d({values:S(c()).max(100),total:w().int().optional(),hasMore:O().optional()}).loose()}),ai=Je({ttlMs:w().int().min(0),cacheScope:oe(["public","private"])}),Pr=Je({ttlMs:w().int().min(0).catch(0),cacheScope:oe(["public","private"]).catch("private"),supportedVersions:S(c()),capabilities:vo,instructions:c().optional()}),kt=d({messages:S(Bt),modelPreferences:we.optional(),systemPrompt:c().optional(),includeContext:oe(["none","thisServer","allServers"]).optional(),temperature:w().optional(),maxTokens:w().int(),stopSequences:S(c()).optional(),metadata:t.optional(),tools:S(Jt).optional(),toolChoice:me.optional()}),Tr=d({method:p("sampling/createMessage"),params:kt}),kr=d({method:p("roots/list"),params:d({_meta:I(c(),D()).optional()}).optional()}),$r=d({...Bt.shape,model:c(),stopReason:c().optional()}),Cr=d({roots:S(gr)}),Ir=d({action:oe(["accept","decline","cancel"]),content:I(c(),M([c(),w(),O(),S(c())])).optional()}),Or=d({mode:p("url"),message:c(),url:c().url()}),Mr=M([nt,Or]),Ar=d({method:p("elicitation/create"),params:Mr}),Nr=M([Tr,kr,Ar]),qr=M([$r,Cr,Ir]),jr=I(c(),Nr),Lr=I(c(),qr),Gt=Je({inputRequests:jr.optional(),requestState:c().optional()}),Wt={inputResponses:Lr.optional(),requestState:c().optional()},ci=d({_meta:zo,...Wt}),li=K({progressToken:o.optional()});function tt(Le,Yt){return d({method:p(Le),params:d({_meta:zo,...Yt})})}function ot(Le,Yt){return d({method:p(Le),params:d({_meta:li.optional(),...Yt}).optional()})}let Ur={name:c(),arguments:I(c(),D()).optional(),...Wt},it={cursor:r.optional()},ui=tt("tools/call",Ur),di=tt("tools/list",it),pi=tt("prompts/list",it),hi=tt("prompts/get",{name:c(),arguments:I(c(),c()).optional(),...Wt}),mi=tt("resources/list",it),fi=tt("resources/templates/list",it),gi=tt("resources/read",{uri:c(),...Wt}),Zr={ref:M([Ft,Ht]),argument:d({name:c(),value:c()}),context:d({arguments:I(c(),c()).optional()}).optional()},Si=tt("completion/complete",Zr),_i=tt("server/discover",{}),To=d({toolsListChanged:O().optional(),promptsListChanged:O().optional(),resourcesListChanged:O().optional(),resourceSubscriptions:S(c()).optional()}),Dr={notifications:To},bi=tt("subscriptions/listen",Dr),yi=xo.extend({"io.modelcontextprotocol/subscriptionId":n}),Vr=K({_meta:yi,resultType:Ro.default("complete")}),$t={"tools/call":ot("tools/call",Ur),"tools/list":ot("tools/list",it),"prompts/get":ot("prompts/get",{name:c(),arguments:I(c(),c()).optional()}),"prompts/list":ot("prompts/list",it),"resources/list":ot("resources/list",it),"resources/templates/list":ot("resources/templates/list",it),"resources/read":ot("resources/read",{uri:c()}),"completion/complete":ot("completion/complete",Zr),"server/discover":ot("server/discover",{}),"subscriptions/listen":ot("subscriptions/listen",Dr)};function Xe(Le){return K({_meta:Eo,...Le})}let vi={"tools/call":Xe({content:S(he),structuredContent:D().optional(),isError:O().optional()}),"tools/list":Xe({ttlMs:w().int().min(0),cacheScope:oe(["public","private"]),tools:S(Jt),nextCursor:r.optional()}),"prompts/get":Xe({description:c().optional(),messages:S(Te)}),"prompts/list":Xe({ttlMs:w().int().min(0),cacheScope:oe(["public","private"]),prompts:S(A),nextCursor:r.optional()}),"resources/list":Xe({ttlMs:w().int().min(0),cacheScope:oe(["public","private"]),resources:S($e),nextCursor:r.optional()}),"resources/templates/list":Xe({ttlMs:w().int().min(0),cacheScope:oe(["public","private"]),resourceTemplates:S(Ue),nextCursor:r.optional()}),"resources/read":Xe({ttlMs:w().int().min(0),cacheScope:oe(["public","private"]),contents:S(M([de,pe]))}),"completion/complete":Xe({completion:d({values:S(c()).max(100),total:w().int().optional(),hasMore:O().optional()}).loose()}),"server/discover":Xe({ttlMs:w().int().min(0).catch(0),cacheScope:oe(["public","private"]).catch("private"),supportedVersions:S(c()),capabilities:vo,instructions:c().optional()}),"subscriptions/listen":Xe({})},Kt=K({"io.modelcontextprotocol/subscriptionId":n.optional()}),ko=d({method:p("notifications/subscriptions/acknowledged"),params:d({_meta:Kt.optional(),notifications:To})}),$o=d({_meta:Kt.optional(),requestId:n,reason:c().optional()}),Co=d({method:p("notifications/cancelled"),params:$o}),Ia={"notifications/cancelled":Co,"notifications/progress":se,"notifications/message":le,"notifications/resources/updated":te,"notifications/resources/list_changed":W,"notifications/tools/list_changed":ze,"notifications/prompts/list_changed":V,"notifications/subscriptions/acknowledged":ko},Ke=(Le)=>d({jsonrpc:p("2.0"),id:M([c(),w().int()]),result:Le}).strict();return{JSONValueSchema:e,JSONObjectSchema:t,ProgressTokenSchema:o,CursorSchema:r,RequestIdSchema:n,RoleSchema:i,LoggingLevelSchema:s,TaskMetadataSchema:l,RelatedTaskMetadataSchema:u,RequestMetaSchema:m,BaseRequestParamsSchema:h,TaskAugmentedRequestParamsSchema:f,NotificationsParamsSchema:g,NotificationSchema:y,IconSchema:z,IconsSchema:_,BaseMetadataSchema:x,ImplementationSchema:E,ClientTasksCapabilitySchema:q,ServerTasksCapabilitySchema:J,ClientCapabilitiesSchema:ae,ServerCapabilitiesSchema:re,ProgressSchema:ie,ProgressNotificationParamsSchema:Ee,ProgressNotificationSchema:se,LoggingMessageNotificationParamsSchema:ee,LoggingMessageNotificationSchema:le,ResourceContentsSchema:ge,TextResourceContentsSchema:de,BlobResourceContentsSchema:pe,AnnotationsSchema:ke,ResourceSchema:$e,ResourceTemplateSchema:Ue,ResourceListChangedNotificationSchema:W,ResourceUpdatedNotificationParamsSchema:ne,ResourceUpdatedNotificationSchema:te,PromptArgumentSchema:Oe,PromptSchema:A,PromptListChangedNotificationSchema:V,TextContentSchema:Y,ImageContentSchema:B,AudioContentSchema:ue,ToolUseContentSchema:Ze,EmbeddedResourceSchema:ve,ResourceLinkSchema:Pe,ContentBlockSchema:he,PromptMessageSchema:Te,ToolAnnotationsSchema:je,ToolListChangedNotificationSchema:ze,ModelHintSchema:be,ModelPreferencesSchema:we,ToolChoiceSchema:me,BooleanSchemaSchema:ce,StringSchemaSchema:b,NumberSchemaSchema:X,UntitledSingleSelectEnumSchemaSchema:N,TitledSingleSelectEnumSchemaSchema:C,LegacyTitledEnumSchemaSchema:j,SingleSelectEnumSchemaSchema:k,UntitledMultiSelectEnumSchemaSchema:P,TitledMultiSelectEnumSchemaSchema:U,MultiSelectEnumSchemaSchema:Z,EnumSchemaSchema:Se,PrimitiveSchemaDefinitionSchema:We,ElicitRequestFormParamsSchema:nt,ResourceTemplateReferenceSchema:Ht,PromptReferenceSchema:Ft,RootSchema:gr,ClientCapabilities2026Schema:Sr,ServerCapabilities2026Schema:vo,RequestMetaEnvelopeSchema:zo,ToolSchema:Jt,ToolResultContentSchema:_r,SamplingMessageContentBlockSchema:wo,SamplingMessageSchema:Bt,ResultTypeSchema:Ro,ResultMetaSchema:xo,ResultSchema:br,PaginatedResultSchema:ii,CallToolResultSchema:Po,ListToolsResultSchema:yr,ListPromptsResultSchema:vr,GetPromptResultSchema:zr,ListResourcesResultSchema:wr,ListResourceTemplatesResultSchema:Rr,ReadResourceResultSchema:xr,CompleteResultSchema:Er,CacheableResultSchema:ai,DiscoverResultSchema:Pr,CreateMessageRequestParamsSchema:kt,CreateMessageRequestSchema:Tr,ListRootsRequestSchema:kr,CreateMessageResultSchema:$r,ListRootsResultSchema:Cr,ElicitResultSchema:Ir,ElicitRequestURLParamsSchema:Or,ElicitRequestParamsSchema:Mr,ElicitRequestSchema:Ar,InputRequestSchema:Nr,InputResponseSchema:qr,InputRequestsSchema:jr,InputResponsesSchema:Lr,InputRequiredResultSchema:Gt,InputResponseRequestParamsSchema:ci,CallToolRequestSchema:ui,ListToolsRequestSchema:di,ListPromptsRequestSchema:pi,GetPromptRequestSchema:hi,ListResourcesRequestSchema:mi,ListResourceTemplatesRequestSchema:fi,ReadResourceRequestSchema:gi,CompleteRequestSchema:Si,DiscoverRequestSchema:_i,SubscriptionFilterSchema:To,SubscriptionsListenRequestSchema:bi,SubscriptionsListenResultMetaSchema:yi,SubscriptionsListenResultSchema:Vr,dispatchRequestSchemas:$t,dispatchResultSchemas:vi,NotificationMetaSchema:Kt,SubscriptionsAcknowledgedNotificationSchema:ko,CancelledNotificationParamsSchema:$o,CancelledNotificationSchema:Co,notificationSchemas2026:Ia,JSONRPCResultResponseSchema:Ke(br),CallToolResultResponseSchema:Ke(M([Po,Gt])),ListToolsResultResponseSchema:Ke(yr),ListPromptsResultResponseSchema:Ke(vr),GetPromptResultResponseSchema:Ke(M([zr,Gt])),ListResourcesResultResponseSchema:Ke(wr),ListResourceTemplatesResultResponseSchema:Ke(Rr),ReadResourceResultResponseSchema:Ke(M([xr,Gt])),CompleteResultResponseSchema:Ke(Er),DiscoverResultResponseSchema:Ke(Pr),SubscriptionsListenResultResponseSchema:Ke(Vr)}}var cS;function Dt(){return cS??=aS()}var lS=["tools/list","prompts/list","resources/list","resources/templates/list","resources/read","server/discover"];function uS(e){return lS.includes(e)}var il=Symbol("modelcontextprotocol.resultCacheHintFallback");function dS(e){return e[il]}function sm(e){return typeof e==="number"&&Number.isSafeInteger(e)&&e>=0}function im(e){return e==="public"||e==="private"}var Q=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}({}),_e=class e extends Error{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.ProtocolError"})}static[Symbol.hasInstance](t){return et(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 et(this,t)}constructor(t,o,r){super(o);this.code=t,this.data=r,this.name="ProtocolError",Vt(this,new.target)}static fromError(t,o,r){if(t===Q.UrlElicitationRequired&&r){let n=r;if(n.elicitations)return new cm(n.elicitations,o)}if(t===Q.UnsupportedProtocolVersion&&r){let n=r;if(Array.isArray(n.supported)&&typeof n.requested==="string")return new Xs({supported:n.supported,requested:n.requested},o)}if(t===Q.InvalidParams||t===Q.ResourceNotFound){let n=r;if(typeof n?.uri==="string"&&(t===Q.ResourceNotFound||Object.keys(n).length===1))return new am(n.uri,o)}if(t===Q.MissingRequiredClientCapability&&r){let n=r;if(n.requiredCapabilities!==null&&typeof n.requiredCapabilities==="object"&&!Array.isArray(n.requiredCapabilities))return new lm({requiredCapabilities:n.requiredCapabilities},o)}return new e(t,o,r)}},am=class extends _e{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.ResourceNotFoundError"})}constructor(e,t=`Resource not found: ${e}`){super(Q.InvalidParams,t,{uri:e})}get uri(){return this.data.uri}},cm=class extends _e{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.UrlElicitationRequiredError"})}constructor(e,t=`URL elicitation${e.length>1?"s":""} required`){super(Q.UrlElicitationRequired,t,{elicitations:e})}get elicitations(){return this.data?.elicitations??[]}},Xs=class extends _e{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.UnsupportedProtocolVersionError"})}constructor(e,t=`Unsupported protocol version: ${e.requested}`){super(Q.UnsupportedProtocolVersion,t,e)}get supported(){return this.data.supported}get requested(){return this.data.requested}},lm=class extends _e{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.MissingRequiredClientCapabilityError"})}constructor(e,t=`Missing required client capabilities: ${Object.keys(e.requiredCapabilities).join(", ")}`){super(Q.MissingRequiredClientCapability,t,e)}get requiredCapabilities(){return this.data.requiredCapabilities}},pS=0,hS="private",mS=["tools/call","prompts/get","resources/read"];function fS(e,t){let o=t.resultType;if(o===void 0)return{...t,resultType:"complete"};if(o==="complete")return t;if(mS.includes(e))return t;throw new _e(Q.InternalError,`Handler for ${e} returned resultType '${String(o)}', but results of ${e} only support 'complete' on protocol revision 2026-07-28`)}function gS(e,t){let o=dS(t);if(t.resultType!=="complete"||!uS(e))return o===void 0?t:vS(t);let r=t,n=sm(r.ttlMs)?r.ttlMs:bS(o),i=im(r.cacheScope)?r.cacheScope:yS(o),s={...r,ttlMs:n,cacheScope:i};return delete s[il],s}function SS(e){return e!==null&&typeof e==="object"&&!Array.isArray(e)}function _S(e,t){if(t===void 0)return e;let o=e._meta;if(o===void 0)return{...e,_meta:{[ht]:t}};if(!SS(o))return e;if(o[ht]!==void 0)return e;return{...e,_meta:{...o,[ht]:t}}}function bS(e){return e!==void 0&&sm(e.ttlMs)?e.ttlMs:pS}function yS(e){return e!==void 0&&im(e.cacheScope)?e.cacheScope:hS}function vS(e){let t={...e};return delete t[il],t}var zS=["elicitation/create","sampling/createMessage","roots/list"],va;function um(){if(va)return va;let e=Dt();return va={request:{"elicitation/create":d({method:p("elicitation/create"),params:e.ElicitRequestParamsSchema}),"sampling/createMessage":d({method:p("sampling/createMessage"),params:e.CreateMessageRequestParamsSchema}),"roots/list":d({method:p("roots/list"),params:K({}).optional()})},response:{"elicitation/create":e.ElicitResultSchema,"sampling/createMessage":e.CreateMessageResultSchema,"roots/list":e.ListRootsResultSchema}},va}function dm(e){return zS.includes(e)}function Bc(e){return dm(e)?um().request[e]:void 0}function wS(e){return dm(e)?um().response[e]:void 0}var al={"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},pm={"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 hm(e){return Object.prototype.hasOwnProperty.call(al,e)}function mm(e){return Object.prototype.hasOwnProperty.call(pm,e)}function RS(e){return Object.prototype.hasOwnProperty.call(al,e)}function xS(e){return hm(e)?Dt().dispatchRequestSchemas[e]:void 0}function ES(e){return RS(e)?Dt().dispatchResultSchemas[e]:void 0}function PS(e){return mm(e)?Dt().notificationSchemas2026[e]:void 0}var Tz=Object.keys(al),kz=Object.keys(pm);function Gs(e){return e!==null&&typeof e==="object"&&!Array.isArray(e)}function Js(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 TS={ok:!1,reason:"not-in-era"},kS=[no,so];function $S(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((a)=>Gs(a)&&("execution"in a)))n().tools=i.map((a)=>{if(!Gs(a)||!("execution"in a))return a;let l={...a};return delete l.execution,l});let s=t.capabilities;if(Gs(s)&&"tasks"in s){let a={...s};delete a.tasks,n().capabilities=a}return o}var cl={era:"2026-07-28",hasRequestMethod:hm,hasNotificationMethod:mm,hasInputRequestMethod:(e)=>Bc(e)!==void 0,validateRequest:(e,t)=>Js(xS(e),t),validateResult:(e,t)=>Js(ES(e),t),validateNotification:(e,t)=>Js(PS(e),t),validateInputRequest:(e,t)=>Js(Bc(e),t),validateInputResponse:(e,t)=>Js(wS(e),t),samplingResultVariant:()=>TS,outboundEnvelope(e){return{[no]:e.protocolVersion,[jo]:e.clientInfo,[so]:e.clientCapabilities,...e.logLevel!==void 0&&{[Uo]:e.logLevel}}},validateEnvelopeMeta(e){let t=[];for(let r of kS)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((s)=>s.key===i&&s.problem==="missing"))continue;t.push({key:i,problem:r.message})}return t},projectCallToolResult:(e)=>Yh(e),inputRequestSchema:Bc,decodeResult(e,t){if(!Gs(t))return{kind:"invalid",error:new L(F.InvalidResult,`Invalid result for ${e}: not an object`,{method:e})};let o=t.resultType;if(o===void 0)return{kind:"invalid",error:new L(F.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 L(F.InvalidResult,`Invalid result for ${e}: non-string resultType`,{method:e,resultType:o})};if(o==="input_required"){let s=t.inputRequests,a=Gs(s)?s:{},l=t.requestState,u=t._meta===void 0?void 0:Dt().ResultMetaSchema.safeParse(t._meta),m=u?.success?u.data:void 0;if(Object.keys(a).length===0&&typeof l!=="string")return{kind:"invalid",error:new L(F.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:a,...typeof l==="string"&&{requestState:l},...m!==void 0&&{_meta:m}}}if(o!=="complete")return{kind:"invalid",error:new L(F.UnsupportedResultType,`Unsupported result type '${o}' for ${e}`,{resultType:o,method:e})};let r=CS(),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 L(F.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 _S(gS(e,fS(e,$S(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("; ")}`}},za;function CS(){if(za)return za;let e=Dt();return za={"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},za}var xa="2026-07-28";function Et(e){return e!==void 0&&Pt(e)?cl:sl}function Zh(e){if(e.revision!==void 0)return Et(e.revision).era;return e.era==="modern"?cl.era:sl.era}function Gc(e){return fm.some((t)=>t.hasRequestMethod(e))}function Wc(e){return fm.some((t)=>t.hasNotificationMethod(e))}function Dh(e){return e==="tasks/get"||e==="tasks/cancel"}var fm=[sl,cl],IS=xl({AnnotationsSchema:()=>ft,AudioContentSchema:()=>mo,BaseMetadataSchema:()=>pt,BaseRequestParamsSchema:()=>De,BlobResourceContentsSchema:()=>Xo,BooleanSchemaSchema:()=>rr,CallToolRequestParamsSchema:()=>ts,CallToolRequestSchema:()=>os,CallToolResultSchema:()=>Zt,CancelTaskRequestSchema:()=>la,CancelTaskResultSchema:()=>ua,CancelledNotificationParamsSchema:()=>ln,CancelledNotificationSchema:()=>Bo,ClientCapabilitiesSchema:()=>dn,ClientNotificationSchema:()=>pa,ClientRequestSchema:()=>da,ClientResultSchema:()=>ha,ClientTasksCapabilitySchema:()=>Yi,CompatibilityCallToolResultSchema:()=>Xi,CompleteRequestParamsSchema:()=>$s,CompleteRequestSchema:()=>Cs,CompleteResultSchema:()=>Is,ContentBlockSchema:()=>gt,CreateMessageRequestParamsSchema:()=>fs,CreateMessageRequestSchema:()=>gs,CreateMessageResultSchema:()=>Ss,CreateMessageResultWithToolsSchema:()=>_s,CreateTaskResultSchema:()=>ta,CursorSchema:()=>Do,DiscoverRequestSchema:()=>gn,DiscoverResultSchema:()=>Lt,ElicitRequestFormParamsSchema:()=>bo,ElicitRequestParamsSchema:()=>ws,ElicitRequestSchema:()=>Rs,ElicitRequestURLParamsSchema:()=>zs,ElicitResultSchema:()=>Ps,ElicitationCompleteNotificationParamsSchema:()=>xs,ElicitationCompleteNotificationSchema:()=>Es,EmbeddedResourceSchema:()=>fo,EmptyResultSchema:()=>jt,EnumSchemaSchema:()=>vs,GetPromptRequestParamsSchema:()=>Fn,GetPromptRequestSchema:()=>Jn,GetPromptResultSchema:()=>Wn,GetTaskPayloadRequestSchema:()=>sa,GetTaskPayloadResultSchema:()=>ia,GetTaskRequestSchema:()=>ra,GetTaskResultSchema:()=>na,IconSchema:()=>un,IconsSchema:()=>vt,ImageContentSchema:()=>ho,ImplementationSchema:()=>mt,InitializeRequestParamsSchema:()=>pn,InitializeRequestSchema:()=>hn,InitializeResultSchema:()=>mn,InitializedNotificationSchema:()=>fn,JSONArraySchema:()=>Wi,JSONObjectSchema:()=>Me,JSONRPCErrorResponseSchema:()=>co,JSONRPCMessageSchema:()=>lo,JSONRPCNotificationSchema:()=>Jo,JSONRPCRequestSchema:()=>Fo,JSONRPCResponseSchema:()=>Ki,JSONRPCResultResponseSchema:()=>ao,JSONValueSchema:()=>yt,LegacyTitledEnumSchemaSchema:()=>ir,ListChangedOptionsBaseSchema:()=>ns,ListPromptsRequestSchema:()=>Vn,ListPromptsResultSchema:()=>Hn,ListResourceTemplatesRequestSchema:()=>wn,ListResourceTemplatesResultSchema:()=>Rn,ListResourcesRequestSchema:()=>vn,ListResourcesResultSchema:()=>zn,ListRootsRequestSchema:()=>Ms,ListRootsResultSchema:()=>As,ListTasksRequestSchema:()=>aa,ListTasksResultSchema:()=>ca,ListToolsRequestSchema:()=>Xn,ListToolsResultSchema:()=>es,LoggingLevelSchema:()=>or,LoggingMessageNotificationParamsSchema:()=>as,LoggingMessageNotificationSchema:()=>cs,ModelHintSchema:()=>ls,ModelPreferencesSchema:()=>us,MultiSelectEnumSchemaSchema:()=>ys,NotificationSchema:()=>Fe,NotificationsParamsSchema:()=>Ge,NumberSchemaSchema:()=>_o,PaginatedRequestParamsSchema:()=>bn,PaginatedRequestSchema:()=>zt,PaginatedResultSchema:()=>wt,PingRequestSchema:()=>Wo,PrimitiveSchemaDefinitionSchema:()=>lr,ProgressNotificationParamsSchema:()=>_n,ProgressNotificationSchema:()=>Ko,ProgressSchema:()=>Sn,ProgressTokenSchema:()=>Zo,PromptArgumentSchema:()=>Zn,PromptListChangedNotificationSchema:()=>Kn,PromptMessageSchema:()=>Gn,PromptReferenceSchema:()=>ks,PromptSchema:()=>Dn,ReadResourceRequestParamsSchema:()=>xn,ReadResourceRequestSchema:()=>En,ReadResourceResultSchema:()=>Pn,RelatedTaskMetadataSchema:()=>cn,RequestIdSchema:()=>lt,RequestMetaSchema:()=>Vo,RequestSchema:()=>Ae,ResourceContentsSchema:()=>Yo,ResourceLinkSchema:()=>go,ResourceListChangedNotificationSchema:()=>Tn,ResourceRequestParamsSchema:()=>uo,ResourceSchema:()=>er,ResourceTemplateReferenceSchema:()=>Ts,ResourceTemplateSchema:()=>yn,ResourceUpdatedNotificationParamsSchema:()=>Ln,ResourceUpdatedNotificationSchema:()=>Un,ResultMetaObjectSchema:()=>Ho,ResultSchema:()=>Ne,RoleSchema:()=>Rt,RootSchema:()=>Os,RootsListChangedNotificationSchema:()=>Ns,SamplingContentSchema:()=>hs,SamplingMessageContentBlockSchema:()=>Nt,SamplingMessageSchema:()=>ms,ServerCapabilitiesSchema:()=>Go,ServerNotificationSchema:()=>fa,ServerRequestSchema:()=>ma,ServerResultSchema:()=>ga,ServerTasksCapabilitySchema:()=>Qi,SetLevelRequestParamsSchema:()=>ss,SetLevelRequestSchema:()=>is,SingleSelectEnumSchemaSchema:()=>bs,StringSchemaSchema:()=>So,SubscribeRequestParamsSchema:()=>kn,SubscribeRequestSchema:()=>$n,SubscriptionFilterSchema:()=>tr,SubscriptionsAcknowledgedNotificationParamsSchema:()=>An,SubscriptionsAcknowledgedNotificationSchema:()=>Nn,SubscriptionsListenRequestParamsSchema:()=>On,SubscriptionsListenRequestSchema:()=>Mn,SubscriptionsListenResultMetaSchema:()=>qn,SubscriptionsListenResultSchema:()=>jn,TaskAugmentedRequestParamsSchema:()=>qt,TaskCreationParamsSchema:()=>ea,TaskMetadataSchema:()=>an,TaskSchema:()=>xt,TaskStatusNotificationParamsSchema:()=>js,TaskStatusNotificationSchema:()=>oa,TaskStatusSchema:()=>qs,TextContentSchema:()=>po,TextResourceContentsSchema:()=>Qo,TitledMultiSelectEnumSchemaSchema:()=>cr,TitledSingleSelectEnumSchemaSchema:()=>sr,ToolAnnotationsSchema:()=>Yn,ToolChoiceSchema:()=>ds,ToolExecutionSchema:()=>Qn,ToolListChangedNotificationSchema:()=>rs,ToolResultContentSchema:()=>ps,ToolSchema:()=>Ut,ToolUseContentSchema:()=>Bn,UnsubscribeRequestParamsSchema:()=>Cn,UnsubscribeRequestSchema:()=>In,UntitledMultiSelectEnumSchemaSchema:()=>ar,UntitledSingleSelectEnumSchemaSchema:()=>nr});var Ea=(e)=>Fo.safeParse(e).success,gm=(e)=>Jo.safeParse(e).success,mr=(e)=>ao.safeParse(e).success,ei=(e)=>co.safeParse(e).success;var Sm=(e)=>typeof e==="object"&&e!==null&&!Array.isArray(e)&&e.resultType==="input_required";var OS="Mcp-Param-",Vh="x-mcp-header",MS=/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/,AS=new Set(["string","integer","boolean"]);function ll(e){let t=[],o=new Map,r,n=(s,a,l)=>{if(s===null||typeof s!=="object")return;let u=s;if(Vh in u){if(!l||a.length===0)return`${wa(a)}: x-mcp-header is only permitted on properties statically reachable via a chain of 'properties' keys (not under items, additionalProperties, oneOf/anyOf/allOf/not, if/then/else, or $ref)`;let h=u[Vh];if(typeof h!=="string"||h.length===0)return`${wa(a)}: x-mcp-header MUST be a non-empty string`;if(!MS.test(h))return`${wa(a)}: x-mcp-header '${h}' is not a valid RFC 9110 token (no spaces, control characters or HTTP delimiters)`;let f=typeof u.type==="string"?u.type:void 0;if(f===void 0||!AS.has(f)){let z=`${wa(a)}: x-mcp-header is only permitted on primitive-typed properties (string, integer, boolean); got ${f??"<none>"}`;if(f!=="number")return z;r??=z}let g=h.toLowerCase(),y=o.get(g);if(y!==void 0)return`x-mcp-header '${h}' is not case-insensitively unique (also declared as '${y}')`;o.set(g,h),t.push({path:a,headerName:h,type:f})}let m=u.properties;if(m!==null&&typeof m==="object")for(let[h,f]of Object.entries(m)){let g=n(f,[...a,h],l);if(g!==void 0)return g}for(let h of NS){let f=u[h];if(f===void 0)continue;let g=Array.isArray(f)?f:f!==null&&typeof f==="object"&&qS.has(h)?Object.values(f):[f];for(let y of g){let z=n(y,[...a,`<${h}>`],!1);if(z!==void 0)return z}}},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 NS=["items","prefixItems","contains","additionalProperties","unevaluatedProperties","unevaluatedItems","propertyNames","patternProperties","dependentSchemas","oneOf","anyOf","allOf","not","if","then","else","$defs","definitions"],qS=new Set(["patternProperties","dependentSchemas","$defs","definitions"]);function wa(e){return e.length===0?"<root>":e.join(".")}var _m="=?base64?",bm="?=";function jS(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 LS(e){if(e.length===0)return!0;if(e.startsWith(_m)&&e.endsWith(bm))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 US(e){let t=new TextEncoder().encode(e),o="";for(let r of t)o+=String.fromCodePoint(r);return btoa(o)}function ym(e){return LS(e)?`${_m}${US(e)}${bm}`:e}function ZS(e,t){let o=e;for(let r of t){if(o===null||typeof o!=="object")return;o=o[r]}return o}function vm(e,t){let o={};for(let r of e){let n=ZS(t,r.path);if(n===void 0||n===null)continue;let i=jS(n);if(i===void 0)continue;o[`${OS}${r.headerName}`]=ym(i)}return o}var hr=-32020,$z=[{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:[Q.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:[hr,Q.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:[Q.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:[Q.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:[Q.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:[hr],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:[Q.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:[hr],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."}],Cz={[Q.ParseError]:400,[Q.InvalidRequest]:400,[Q.MethodNotFound]:404,[Q.UnsupportedProtocolVersion]:400,[Q.MissingRequiredClientCapability]:400,[hr]:400};function Pa(e,t){return Di(e,t)}function Bs(e){return new Set(e.flatMap((t)=>Object.keys(t.shape)))}function Xc(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 Hh=!1,el="draft-2020-12";function DS(e,t="input"){let o=e["~standard"],r;if(o.jsonSchema)r=o.jsonSchema[t]({target:el});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(!Hh)Hh=!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:el,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 zm(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 VS=/^#\/(\$defs|definitions)\/([^/~%]+)$/;function zm(e,t=e){if("properties"in e||"patternProperties"in e||"additionalProperties"in e||"required"in e)return!0;let o=typeof e.$ref==="string"&&VS.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"||zm(i,"$id"in i?{}:t)))}return!1}function HS(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 Kc(e,t){let o=await e["~standard"].validate(t);if(o.issues&&o.issues.length>0)return{success:!1,error:o.issues.map((r)=>HS(r)).join(", ")};return{success:!0,data:o.value}}function FS(e){let t=Ui(e,{target:el,io:"input"});return typeof t.pattern==="string"?t.pattern:void 0}var JS=/\\\.\\d\{(\d+)\}/;function BS(e){let t=JS.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)=>No({local:r,offset:n,precision:i}))))}function GS(e,t){let o;switch(e){case"email":o=[fh()];break;case"uri":o=[Hi()];break;case"date":o=[Uc()];break;case"date-time":o=BS(t);break}return new Set(o.map((r)=>FS(r)).filter((r)=>r!==void 0))}function WS(e,t,o){if(o!=="zod")return!0;return GS(e,t).has(t)}function Ks(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}function KS(e){try{return DS(e,"input")}catch(t){let o=t instanceof Error?t.message:String(t);throw new _e(Q.InvalidParams,`Elicitation requestedSchema must describe an object with flat primitive properties: ${o}`)}}var YS=new Set(["$comment","deprecated","description","examples","readOnly","title","writeOnly"]);function ul(e){return YS.has(e)||e.startsWith("x-")}var QS=new Set(["$schema",...Object.keys(bo.shape.requestedSchema.shape)]),Fh={string:Bs([So,nr,sr,ir]),number:Bs([_o]),integer:Bs([_o]),boolean:Bs([rr]),array:Bs([ar,cr])},XS=new Set(So.shape.format.unwrap().options);function e_(e,t,o,r){if(!Ks(e))return e;let n=typeof e.type==="string"&&Object.hasOwn(Fh,e.type)?Fh[e.type]:void 0;if(n===void 0)return e;let i={};for(let[s,a]of Object.entries(e))if(n.has(s)||ul(s))i[s]=a;else if(s==="pattern"&&e.type==="string"&&typeof e.format==="string"){if(!XS.has(e.format))i[s]=a;else if(typeof a!=="string"||!WS(e.format,a,o))r.push(`${t}.${s}`)}else r.push(`${t}.${s}`);return i}function t_(e,t){let o={},r=[];for(let[n,i]of Object.entries(e))if(n==="properties"&&Ks(i))o[n]=Object.fromEntries(Object.entries(i).map(([s,a])=>[s,e_(a,`properties.${s}`,t,r)]));else if(QS.has(n))o[n]=i;else if(!ul(n))r.push(n);if(r.length>0)throw new _e(Q.InvalidParams,`Elicitation requestedSchema contains unsupported JSON Schema constraint(s) after Standard Schema conversion: ${r.join(", ")}`);return o}function o_(e,t){if(!Ks(e.properties))return t;let o=Object.entries(e.properties).filter(([,r])=>!Pa(lr,r).success).map(([r])=>`properties.${r}`);return o.length>0?o.join(", "):t}function tl(e,t,o=""){if(Array.isArray(e)&&Array.isArray(t))return e.flatMap((r,n)=>tl(r,t[n],`${o}[${n}]`));if(!Ks(e)||!Ks(t))return[];return Object.entries(e).flatMap(([r,n])=>{let i=o?`${o}.${r}`:r;if(!Object.prototype.hasOwnProperty.call(t,r))return ul(r)?[]:[i];return tl(n,t[r],i)})}function r_(e){if(!Xc(e.requestedSchema))return{...e,mode:"form",requestedSchema:e.requestedSchema};let t=e.requestedSchema["~standard"].vendor,o=t_(KS(e.requestedSchema),t),r=Pa(bo.shape.requestedSchema,o);if(!r.success)throw new _e(Q.InvalidParams,`Elicitation requestedSchema only supports flat primitive properties (string, number, integer, boolean, and string enums): ${o_(o,r.error.message)}`);let n=tl(o,r.data);if(n.length>0)throw new _e(Q.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 _e(Q.InvalidParams,`Elicitation requestedSchema lists required properties that are not defined in properties: ${i.join(", ")}`);return{...e,mode:"form",requestedSchema:r.data}}function n_(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 Iz=Object.assign(n_,{elicit(e){try{return{method:"elicitation/create",params:r_(e)}}catch(t){throw t instanceof _e?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 s_=!0,i_=10,a_=250;function wm(e){return{autoFulfill:e?.autoFulfill??s_,maxRounds:e?.maxRounds??i_}}function c_(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 l_(e,t){return`Multi-round-trip request '${e}' still required input after ${t} rounds (inputRequired.maxRounds)`}function u_(e,t){return new Promise((o,r)=>{if(t?.aborted){r(t.reason instanceof L?t.reason:new L(F.RequestTimeout,String(t.reason)));return}let n=setTimeout(()=>{t?.removeEventListener("abort",i),o()},e),i=()=>{clearTimeout(n),r(t?.reason instanceof L?t.reason:new L(F.RequestTimeout,String(t?.reason)))};t?.addEventListener("abort",i,{once:!0})})}function d_(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,a=e.flowStartedAt??Date.now(),l=e.firstPayload,u=0;while(!0){if(u+=1,u>t.maxRounds)throw new L(F.InputRequiredRoundsExceeded,l_(o,t.maxRounds),{rounds:t.maxRounds,lastResult:{inputRequests:l.inputRequests,...l.requestState!==void 0&&{requestState:l.requestState}}});n.onprogress?.({progress:u,message:`Fulfilling input required by '${o}' (round ${u})`});let m=Object.entries(l.inputRequests??{}),h;if(m.length>0){let y=d_(s);try{let z=await Promise.all(m.map(async([_,x])=>{try{return[_,await i.dispatchInputRequest(_,x,y.signal)]}catch(E){throw y.abort(E),E}}));h=Object.fromEntries(z)}finally{y.dispose()}}else await u_(a_,s);let f={...n.timeout!==void 0&&{timeout:n.timeout}};if(n.maxTotalTimeout!==void 0){let y=Date.now()-a,z=n.maxTotalTimeout-y;if(z<=0)throw new L(F.RequestTimeout,"Maximum total timeout exceeded",{maxTotalTimeout:n.maxTotalTimeout,totalElapsed:y});f.maxTotalTimeout=z}let g=await i.retry(c_(r,h,l.requestState),f);if(Sm(g)){l={inputRequests:g.inputRequests??{},...g.requestState!==void 0&&{requestState:g.requestState}};continue}return g}}var h_=["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"],m_={IdJagTokenExchangeResponseSchema:Ds,OAuthClientInformationFullSchema:Fs,OAuthClientInformationSchema:Hs,OAuthClientMetadataSchema:Vs,OAuthClientRegistrationErrorSchema:Sa,OAuthErrorResponseSchema:pr,OAuthMetadataSchema:ur,OAuthProtectedResourceMetadataSchema:Ls,OAuthTokenRevocationRequestSchema:_a,OAuthTokensSchema:dr,OpenIdProviderDiscoveryMetadataSchema:Zs,OpenIdProviderMetadataSchema:Us},Rm={},xm={};function Em(e,t){let o=e.slice(0,-6);Rm[o]=t,xm[o]=(r)=>t.safeParse(r).success}for(let e of h_)Em(e,IS[e]);for(let[e,t]of Object.entries(m_))Em(e,t);var f_=Object.freeze(Rm),dl=Object.freeze(xm);function g_(e){switch(e){case"initialize":case"notifications/initialized":return Et(void 0);case"server/discover":return Et(xa);default:return}}var ti=60000,S_=[no,jo,so,Uo],__=["inputResponses","requestState"];function Jh(e,t){let o=e.params;if(!Ws(o))return{message:e,lifted:{}};let r=o._meta,n=Ws(r)?S_.filter((l)=>(l in r)):[],i=t==="request"?__.filter((l)=>(l in o)):[];if(n.length===0&&i.length===0)return{message:e,lifted:{}};let s={},a={...o};if(n.length>0&&Ws(r)){let l={},u={...r};for(let m of n)l[m]=r[m],delete u[m];if(s.envelope=l,Object.keys(u).length>0)a._meta=u;else delete a._meta}for(let l of i){if(l==="inputResponses")s.inputResponses=a[l];if(l==="requestState")s.requestState=a[l];delete a[l]}return{message:{...e,params:a},lifted:s}}function Bh(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 pl(e){return()=>e}var b_=pl(void 0),y_,oi=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{y_=(e,t)=>{e._negotiatedProtocolVersion=t}}_supportedProtocolVersions;onclose;onerror;fallbackRequestHandler;fallbackNotificationHandler;constructor(e){this._options=e,this._supportedProtocolVersions=e?.supportedProtocolVersions??Bi,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 L(F.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 L(F.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),mr(n)||ei(n))this._onresponse(n);else if(Ea(n))this._onrequest(n,i);else if(gm(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 L(F.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}=Jh(e,"notification"),r=this._negotiatedWireCodec();if(t?.classification===void 0&&this._shouldDropInbound(e)==="drop")return;if(t?.classification!==void 0){let s=Zh(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(Wc(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}=Jh(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=(z,_,x)=>{let E={jsonrpc:"2.0",id:o.id,error:{code:z,message:_,...x!==void 0&&{data:x}}};i?.send(E).catch((R)=>this._onerror(Error(`Failed to send an error response: ${R}`)))};if(t?.classification!==void 0){let z=Zh(t.classification);if(z!==n.era){this._onerror(Error(`Era mismatch on inbound request '${o.method}': classified as ${z} but this instance serves ${n.era}`));let _=t.classification.revision??z;s(Q.UnsupportedProtocolVersion,`Unsupported protocol version: ${_}`,{supported:this._supportedProtocolVersions,requested:_});return}}if(Gc(o.method)&&!n.hasRequestMethod(o.method)&&!(Dh(o.method)&&this._customSchemaRequestMethods.has(o.method))){s(Q.MethodNotFound,"Method not found");return}let a=this._requestHandlers.get(o.method)??this.fallbackRequestHandler;if(a===void 0){s(Q.MethodNotFound,"Method not found");return}let l=n.checkInboundEnvelope(r);if(l!==void 0){s(Q.InvalidParams,l);return}let u=(z,_)=>this._notificationViaCodec(this._resolveOutboundCodec(z.method),z,{..._,relatedRequestId:o.id}),m=(z,_,x)=>this._requestWithSchemaViaCodec(this._resolveOutboundCodec(z.method),z,_,{...x,relatedRequestId:o.id}),h=new AbortController;this._requestHandlerAbortControllers.set(o.id,h);let f=r.inputResponses===void 0?void 0:v_(r.inputResponses),g={sessionId:i?.sessionId,mcpReq:{id:o.id,method:o.method,_meta:o.params?._meta,...r.envelope!==void 0&&{envelope:r.envelope},...f!==void 0&&{inputResponses:f.accepted},...f!==void 0&&f.droppedKeys.length>0&&{droppedInputResponseKeys:f.droppedKeys},requestState:r.requestState===void 0?b_:pl(r.requestState),signal:h.signal,send:(z,_,x)=>{let E=this._resolveOutboundCodec(z.method);if(this._assertOutboundRequestInEra(E,z.method),Xc(_))return m(z,_,x);let R=Bh(E,z.method);if(R===void 0)throw TypeError(`'${z.method}' is not a spec method; pass a result schema as the second argument to ctx.mcpReq.send().`);return m(z,R,_)},notify:u},http:t?.authInfo?{authInfo:t.authInfo}:void 0},y=this.buildContext(g,t);Promise.resolve().then(()=>a(o,y)).then(async(z)=>{if(h.signal.aborted)return;let _;try{_=n.encodeResult(o.method,z,this._outboundServerInfo())}catch(E){this._onerror(Error(`Failed to encode result for ${o.method}: ${E}`)),s(Q.InternalError,"Internal error");return}let x={result:_,jsonrpc:"2.0",id:o.id};await i?.send(x)},async(z)=>{if(h.signal.aborted)return;let _=Number.isSafeInteger(z.code)?z.code:Q.InternalError,x={jsonrpc:"2.0",id:o.id,error:{code:n.encodeErrorCode(_),message:z.message??"Internal error",...z.data!==void 0&&{data:z.data}}};await i?.send(x)}).catch((z)=>this._onerror(Error(`Failed to send response: ${z}`))).finally(()=>{if(this._requestHandlerAbortControllers.get(o.id)===h)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(a){this._responseHandlers.delete(r),this._progressHandlers.delete(r),this._cleanupTimeout(r),i(a);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),mr(e))o(e);else o(_e.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(Xc(t)){if(!Dh(e.method))this._assertOutboundRequestInEra(r,e.method);return this._requestWithSchemaViaCodec(r,e,t,o)}this._assertOutboundRequestInEra(r,e.method);let n=Bh(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 Et(this._negotiatedProtocolVersion)}_wireCodec(){return this._negotiatedWireCodec()}_resolveOutboundCodec(e){if(this._negotiatedProtocolVersion===void 0){let t=g_(e);if(t)return t}return this._negotiatedWireCodec()}_assertOutboundRequestInEra(e,t){if(Gc(t)&&!e.hasRequestMethod(t))throw new L(F.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:a}=r??{},l=Date.now(),u,m;return new Promise((h,f)=>{let g=(J)=>{f(J)};if(!this._transport){g(Error("Not connected"));return}if(this._options?.enforceStrictCapabilities===!0)try{this.assertCapabilityForMethod(t.method)}catch(J){g(J);return}if(r?.signal?.aborted){let J=r.signal.reason;throw J instanceof L?J:new L(F.RequestTimeout,String(J))}let y=e.era===xa&&this._transport.hasPerRequestStream===!0?new AbortController:void 0,z=this._requestMessageId++;m=z;let _={...t,jsonrpc:"2.0",id:z};if(r?.onprogress)this._progressHandlers.set(z,r.onprogress),_.params={...t.params,_meta:{...t.params?._meta,progressToken:z}};let x=this._envelopeOutbound(_),E=!1,R=(J)=>{if(E)return;if(this._progressHandlers.delete(z),y===void 0){if(t.method!=="initialize")this._transport?.send(this._envelopeOutbound({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:z,reason:String(J)}}),{relatedRequestId:n,resumptionToken:i,onresumptiontoken:s}).catch((ae)=>this._onerror(Error(`Failed to send cancellation: ${ae}`)))}else y.abort();f(J instanceof L?J:new L(F.RequestTimeout,String(J)))};this._responseHandlers.set(z,(J)=>{if(r?.signal?.aborted)return;if(E=!0,J instanceof Error)return f(J);let ae;try{ae=e.decodeResult(t.method,J.result)}catch(ie){return f(ie instanceof Error?ie:Error(String(ie)))}if(ae.kind==="invalid")return f(ae.error);if(ae.kind==="input_required"){if(r?.allowInputRequired===!0)return h(x_(ae));let ie={codec:e,request:t,resultSchema:o,options:r,flowStartedAt:l,retry:(Ee,se)=>this._requestWithSchemaViaCodec(e,Ee===void 0?{method:t.method}:{method:t.method,params:Ee},o,se)};return h(this._resolveNonCompleteResult(ae,ie))}let re=ae.result;Kc(o,re).then((ie)=>{if(ie.success)h(ie.data);else f(new L(F.InvalidResult,`Invalid result for ${t.method}: ${ie.error}`))},f)}),u=()=>R(r?.signal?.reason),r?.signal?.addEventListener("abort",u,{once:!0});let T=r?.timeout??ti,q=()=>R(new L(F.RequestTimeout,"Request timed out",{timeout:T}));this._setupTimeout(z,T,r?.maxTotalTimeout,q,r?.resetTimeoutOnProgress??!1),this._transport.send(x,{relatedRequestId:n,resumptionToken:i,onresumptiontoken:s,headers:a,requestSignal:y?.signal}).catch((J)=>{this._progressHandlers.delete(z),f(J)})}).finally(()=>{if(u)r?.signal?.removeEventListener("abort",u);if(m!==void 0)this._responseHandlers.delete(m),this._cleanupTimeout(m)})}async notification(e,t){return await this._notificationViaCodec(this._resolveOutboundCodec(e.method),e,t)}async _notificationViaCodec(e,t,o){if(!this._transport)throw new L(F.NotConnected,"Not connected");if(Wc(t.method)&&!e.hasNotificationMethod(t.method))throw new L(F.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(!Gc(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(),a=s.validateRequest(e,n);if(!a.ok&&a.reason==="not-in-era")a=s.validateInputRequest(e,n);if(!a.ok){if(a.reason==="not-in-era")throw new _e(Q.InternalError,`No wire schema for ${e} in the resolved era`);throw Error(a.message)}return Promise.resolve(t(a.value,i))}}else if(o)r=async(n,i)=>{let s=await Kc(t.params,{...n.params});if(!s.success)throw new _e(Q.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(!Wc(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 _e(Q.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 Kc(t.params,{...r.params});if(!n.success)throw new _e(Q.InvalidParams,`Invalid params for notification ${e}: ${n.error}`);await o(n.data,r)})}removeNotificationHandler(e){this._notificationHandlers.delete(e)}};function Ws(e){return e!==null&&typeof e==="object"&&!Array.isArray(e)}function hl(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]=Ws(s)&&Ws(i)?{...s,...i}:i}return o}function Ra(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}function v_(e){let t={},o=[];if(!Ra(e))return{accepted:t,droppedKeys:o};for(let[r,n]of Object.entries(e)){if(!Ra(n)||"method"in n||"result"in n){o.push(r);continue}t[r]=n}return{accepted:t,droppedKeys:o}}function Gh(e){throw new L(F.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 z_(e,t,o,r,n){return{sessionId:n,mcpReq:{id:e,method:t,_meta:o?._meta,requestState:pl(void 0),signal:r,send:()=>Gh("send"),notify:()=>Gh("notify")}}}async function w_(e,t,o,r,n){if(!Ra(r)||typeof r.method!=="string")throw new L(F.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 L(F.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 L(F.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 a=Ra(r.params)?r.params:void 0;return await s({jsonrpc:"2.0",id:o,method:i,...a!==void 0&&{params:a}},e.buildContext(z_(o,i,a,n,e.sessionId)))}function R_(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 Pm(e,t,o,r){let{codec:n,request:i,options:s,flowStartedAt:a}=r,l={inputRequests:o.inputRequests,...o.requestState!==void 0&&{requestState:o.requestState}},u={dispatchInputRequest:(m,h,f)=>w_(e,n,m,h,f),retry:(m,h)=>r.retry(m,R_(s,h))};return p_({config:t,method:i.method,originalParams:i.params,firstPayload:l,flowStartedAt:a,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:u})}function x_(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 E_=Rl((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(a){if(!a)throw TypeError("argument string is required");var l=typeof a==="object"?i(a):a;if(typeof l!=="string")throw TypeError("argument string is required to be a string");var u=l.indexOf(";"),m=u!==-1?l.slice(0,u).trim():l.trim();if(!r.test(m))throw TypeError("invalid media type");var h=new s(m.toLowerCase());if(u!==-1){var f,g,_;t.lastIndex=u;while(g=t.exec(l)){if(g.index!==u)throw TypeError("invalid parameter format");if(u+=g[0].length,f=g[1].toLowerCase(),_=g[2],_.charCodeAt(0)===34){if(_=_.slice(1,-1),_.indexOf("\\")!==-1)_=_.replace(o,"$1")}h.parameters[f]=_}if(u!==l.length)throw TypeError("invalid parameter format")}return h}function i(a){var l;if(typeof a.getHeader==="function")l=a.getHeader("content-type");else if(typeof a.headers==="object")l=a.headers&&a.headers["content-type"];if(typeof l!=="string")throw TypeError("content-type header is missing from object");return l}function s(a){this.parameters=Object.create(null),this.type=a}}),Iz=El(E_(),1);function ri(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(!ri(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(!ri(e[i],t[i]))return!1;return!0}return e===t}function ut(e){return encodeURI(P_(e))}function P_(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}var T_={prefixItems:!0,items:!0,allOf:!0,anyOf:!0,oneOf:!0},k_={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependentSchemas:!0},$_={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},C_=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 yo(e,t=Object.create(null),o=C_,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 yo(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($_[i])continue;let s=`${r}/${ut(i)}`,a=e[i];if(Array.isArray(a)){if(T_[i]){let l=a.length;for(let u=0;u<l;u++)yo(a[u],t,o,`${s}/${u}`)}}else if(k_[i])for(let l in a)yo(a[l],t,o,`${s}/${ut(l)}`);else yo(a,t,o,s)}return t}var I_=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,O_=[0,31,28,31,30,31,30,31,31,30,31,30,31],M_=/^(\d\d):(\d\d):(\d\d)(\.\d+)?(z|[+-]\d\d(?::?\d\d)?)?$/i,A_=/^(?=.{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,N_=/^(?:[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,q_=/^(?:(?:[^\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,j_=/^(?:(?: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,L_=/^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i,U_=/^(?:\/(?:[^~/]|~0|~1)*)*$/,Z_=/^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i,D_=/^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/,V_=(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))},H_=/^(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)$/,F_=/^((([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,J_=(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 St(e){return e.test.bind(e)}var Tm={date:km,time:$m.bind(void 0,!1),"date-time":W_,duration:J_,uri:Q_,"uri-reference":St(N_),"uri-template":St(q_),url:St(j_),email:V_,hostname:St(A_),ipv4:St(H_),ipv6:St(F_),regex:eb,uuid:St(L_),"json-pointer":St(U_),"json-pointer-uri-fragment":St(Z_),"relative-json-pointer":St(D_)};function B_(e){return e%4===0&&(e%100!==0||e%400===0)}function km(e){let t=e.match(I_);if(!t)return!1;let o=+t[1],r=+t[2],n=+t[3];return r>=1&&r<=12&&n>=1&&n<=(r==2&&B_(o)?29:O_[r])}function $m(e,t){let o=t.match(M_);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 G_=/t|\s/i;function W_(e){let t=e.split(G_);return t.length==2&&km(t[0])&&$m(!0,t[1])}var K_=/\/|:/,Y_=/^(?:[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 Q_(e){return K_.test(e)&&Y_.test(e)}var X_=/[^\\]\\Z/;function eb(e){if(X_.test(e))return!1;try{return new RegExp(e,"u"),!0}catch(t){return!1}}function tb(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 Me(e,t,o="2019-09",r=yo(t),n=!0,i=null,s="#",a="#",l=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 u=typeof e,m;switch(u){case"boolean":case"number":case"string":m=u;break;case"object":if(e===null)m="null";else if(Array.isArray(e))m="array";else m="object";break;default:throw Error(`Instances of "${u}" type are not supported.`)}let{$ref:h,$recursiveRef:f,$recursiveAnchor:g,type:_,const:z,enum:b,required:w,not:C,anyOf:x,allOf:T,oneOf:q,if:B,then:ee,else:re,format:le,properties:ve,patternProperties:se,additionalProperties:te,unevaluatedProperties:ne,minProperties:be,maxProperties:ue,propertyNames:de,dependentRequired:Ee,dependentSchemas:Pe,dependencies:Ae,prefixItems:W,items:ie,additionalItems:E,unevaluatedItems:U,contains:Q,minContains:G,maxContains:$e,minItems:fe,maxItems:ye,uniqueItems:je,minimum:pe,maximum:ze,exclusiveMinimum:Ne,exclusiveMaximum:Ze,multipleOf:ge,minLength:ae,maxLength:Xe,pattern:st,__absolute_ref__:he,__absolute_recursive_ref__:ce}=t,y=[];if(g===!0&&i===null)i=t;if(f==="#"){let N=i===null?r[ce]:i,I=`${a}/$recursiveRef`,j=Me(e,i===null?t:i,o,r,n,N,s,I,l);if(!j.valid)y.push({instanceLocation:s,keyword:"$recursiveRef",keywordLocation:I,error:"A subschema had errors."},...j.errors)}if(h!==void 0){let N=r[he||h];if(N===void 0){let k=`Unresolved $ref "${h}".`;if(he&&he!==h)k+=` Absolute URI "${he}".`;throw k+=`
68
+ */var E_=Rl((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(a){if(!a)throw TypeError("argument string is required");var l=typeof a==="object"?i(a):a;if(typeof l!=="string")throw TypeError("argument string is required to be a string");var u=l.indexOf(";"),m=u!==-1?l.slice(0,u).trim():l.trim();if(!r.test(m))throw TypeError("invalid media type");var h=new s(m.toLowerCase());if(u!==-1){var f,g,y;t.lastIndex=u;while(g=t.exec(l)){if(g.index!==u)throw TypeError("invalid parameter format");if(u+=g[0].length,f=g[1].toLowerCase(),y=g[2],y.charCodeAt(0)===34){if(y=y.slice(1,-1),y.indexOf("\\")!==-1)y=y.replace(o,"$1")}h.parameters[f]=y}if(u!==l.length)throw TypeError("invalid parameter format")}return h}function i(a){var l;if(typeof a.getHeader==="function")l=a.getHeader("content-type");else if(typeof a.headers==="object")l=a.headers&&a.headers["content-type"];if(typeof l!=="string")throw TypeError("content-type header is missing from object");return l}function s(a){this.parameters=Object.create(null),this.type=a}}),Oz=El(E_(),1);function ri(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(!ri(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(!ri(e[i],t[i]))return!1;return!0}return e===t}function ut(e){return encodeURI(P_(e))}function P_(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}var T_={prefixItems:!0,items:!0,allOf:!0,anyOf:!0,oneOf:!0},k_={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependentSchemas:!0},$_={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},C_=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 yo(e,t=Object.create(null),o=C_,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 yo(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($_[i])continue;let s=`${r}/${ut(i)}`,a=e[i];if(Array.isArray(a)){if(T_[i]){let l=a.length;for(let u=0;u<l;u++)yo(a[u],t,o,`${s}/${u}`)}}else if(k_[i])for(let l in a)yo(a[l],t,o,`${s}/${ut(l)}`);else yo(a,t,o,s)}return t}var I_=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,O_=[0,31,28,31,30,31,30,31,31,30,31,30,31],M_=/^(\d\d):(\d\d):(\d\d)(\.\d+)?(z|[+-]\d\d(?::?\d\d)?)?$/i,A_=/^(?=.{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,N_=/^(?:[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,q_=/^(?:(?:[^\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,j_=/^(?:(?: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,L_=/^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i,U_=/^(?:\/(?:[^~/]|~0|~1)*)*$/,Z_=/^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i,D_=/^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/,V_=(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))},H_=/^(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)$/,F_=/^((([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,J_=(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 St(e){return e.test.bind(e)}var Tm={date:km,time:$m.bind(void 0,!1),"date-time":W_,duration:J_,uri:Q_,"uri-reference":St(N_),"uri-template":St(q_),url:St(j_),email:V_,hostname:St(A_),ipv4:St(H_),ipv6:St(F_),regex:eb,uuid:St(L_),"json-pointer":St(U_),"json-pointer-uri-fragment":St(Z_),"relative-json-pointer":St(D_)};function B_(e){return e%4===0&&(e%100!==0||e%400===0)}function km(e){let t=e.match(I_);if(!t)return!1;let o=+t[1],r=+t[2],n=+t[3];return r>=1&&r<=12&&n>=1&&n<=(r==2&&B_(o)?29:O_[r])}function $m(e,t){let o=t.match(M_);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 G_=/t|\s/i;function W_(e){let t=e.split(G_);return t.length==2&&km(t[0])&&$m(!0,t[1])}var K_=/\/|:/,Y_=/^(?:[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 Q_(e){return K_.test(e)&&Y_.test(e)}var X_=/[^\\]\\Z/;function eb(e){if(X_.test(e))return!1;try{return new RegExp(e,"u"),!0}catch(t){return!1}}function tb(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 qe(e,t,o="2019-09",r=yo(t),n=!0,i=null,s="#",a="#",l=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 u=typeof e,m;switch(u){case"boolean":case"number":case"string":m=u;break;case"object":if(e===null)m="null";else if(Array.isArray(e))m="array";else m="object";break;default:throw Error(`Instances of "${u}" type are not supported.`)}let{$ref:h,$recursiveRef:f,$recursiveAnchor:g,type:y,const:z,enum:_,required:x,not:E,anyOf:R,allOf:T,oneOf:q,if:J,then:ae,else:re,format:ie,properties:Ee,patternProperties:se,additionalProperties:ee,unevaluatedProperties:le,minProperties:ge,maxProperties:de,propertyNames:pe,dependentRequired:ke,dependentSchemas:$e,dependencies:Ue,prefixItems:W,items:ne,additionalItems:te,unevaluatedItems:Oe,contains:A,minContains:V,maxContains:Y,minItems:B,maxItems:ue,uniqueItems:Ze,minimum:ve,maximum:Pe,exclusiveMinimum:he,exclusiveMaximum:Te,multipleOf:je,minLength:ze,maxLength:be,pattern:we,__absolute_ref__:me,__absolute_recursive_ref__:ce}=t,b=[];if(g===!0&&i===null)i=t;if(f==="#"){let N=i===null?r[ce]:i,C=`${a}/$recursiveRef`,j=qe(e,i===null?t:i,o,r,n,N,s,C,l);if(!j.valid)b.push({instanceLocation:s,keyword:"$recursiveRef",keywordLocation:C,error:"A subschema had errors."},...j.errors)}if(h!==void 0){let N=r[me||h];if(N===void 0){let k=`Unresolved $ref "${h}".`;if(me&&me!==h)k+=` Absolute URI "${me}".`;throw k+=`
69
69
  Known schemas:
70
70
  - ${Object.keys(r).join(`
71
- - `)}`,Error(k)}let I=`${a}/$ref`,j=Me(e,N,o,r,n,i,s,I,l);if(!j.valid)y.push({instanceLocation:s,keyword:"$ref",keywordLocation:I,error:"A subschema had errors."},...j.errors);if(o==="4"||o==="7")return{valid:y.length===0,errors:y}}if(Array.isArray(_)){let N=_.length,I=!1;for(let j=0;j<N;j++)if(m===_[j]||_[j]==="integer"&&m==="number"&&e%1===0&&e===e){I=!0;break}if(!I)y.push({instanceLocation:s,keyword:"type",keywordLocation:`${a}/type`,error:`Instance type "${m}" is invalid. Expected "${_.join('", "')}".`})}else if(_==="integer"){if(m!=="number"||e%1||e!==e)y.push({instanceLocation:s,keyword:"type",keywordLocation:`${a}/type`,error:`Instance type "${m}" is invalid. Expected "${_}".`})}else if(_!==void 0&&m!==_)y.push({instanceLocation:s,keyword:"type",keywordLocation:`${a}/type`,error:`Instance type "${m}" is invalid. Expected "${_}".`});if(z!==void 0){if(m==="object"||m==="array"){if(!ri(e,z))y.push({instanceLocation:s,keyword:"const",keywordLocation:`${a}/const`,error:`Instance does not match ${JSON.stringify(z)}.`})}else if(e!==z)y.push({instanceLocation:s,keyword:"const",keywordLocation:`${a}/const`,error:`Instance does not match ${JSON.stringify(z)}.`})}if(b!==void 0){if(m==="object"||m==="array"){if(!b.some((N)=>ri(e,N)))y.push({instanceLocation:s,keyword:"enum",keywordLocation:`${a}/enum`,error:`Instance does not match any of ${JSON.stringify(b)}.`})}else if(!b.some((N)=>e===N))y.push({instanceLocation:s,keyword:"enum",keywordLocation:`${a}/enum`,error:`Instance does not match any of ${JSON.stringify(b)}.`})}if(C!==void 0){let N=`${a}/not`;if(Me(e,C,o,r,n,i,s,N).valid)y.push({instanceLocation:s,keyword:"not",keywordLocation:N,error:'Instance matched "not" schema.'})}let X=[];if(x!==void 0){let N=`${a}/anyOf`,I=y.length,j=!1;for(let k=0;k<x.length;k++){let P=x[k],Z=Object.create(l),D=Me(e,P,o,r,n,g===!0?i:null,s,`${N}/${k}`,Z);if(y.push(...D.errors),j=j||D.valid,D.valid)X.push(Z)}if(j)y.length=I;else y.splice(I,0,{instanceLocation:s,keyword:"anyOf",keywordLocation:N,error:"Instance does not match any subschemas."})}if(T!==void 0){let N=`${a}/allOf`,I=y.length,j=!0;for(let k=0;k<T.length;k++){let P=T[k],Z=Object.create(l),D=Me(e,P,o,r,n,g===!0?i:null,s,`${N}/${k}`,Z);if(y.push(...D.errors),j=j&&D.valid,D.valid)X.push(Z)}if(j)y.length=I;else y.splice(I,0,{instanceLocation:s,keyword:"allOf",keywordLocation:N,error:"Instance does not match every subschema."})}if(q!==void 0){let N=`${a}/oneOf`,I=y.length,j=q.filter((k,P)=>{let Z=Object.create(l),D=Me(e,k,o,r,n,g===!0?i:null,s,`${N}/${P}`,Z);if(y.push(...D.errors),D.valid)X.push(Z);return D.valid}).length;if(j===1)y.length=I;else y.splice(I,0,{instanceLocation:s,keyword:"oneOf",keywordLocation:N,error:`Instance does not match exactly one subschema (${j} matches).`})}if(m==="object"||m==="array")Object.assign(l,...X);if(B!==void 0){let N=`${a}/if`;if(Me(e,B,o,r,n,i,s,N,l).valid){if(ee!==void 0){let I=Me(e,ee,o,r,n,i,s,`${a}/then`,l);if(!I.valid)y.push({instanceLocation:s,keyword:"if",keywordLocation:N,error:'Instance does not match "then" schema.'},...I.errors)}}else if(re!==void 0){let I=Me(e,re,o,r,n,i,s,`${a}/else`,l);if(!I.valid)y.push({instanceLocation:s,keyword:"if",keywordLocation:N,error:'Instance does not match "else" schema.'},...I.errors)}}if(m==="object"){if(w!==void 0){for(let k of w)if(!(k in e))y.push({instanceLocation:s,keyword:"required",keywordLocation:`${a}/required`,error:`Instance does not have required property "${k}".`})}let N=Object.keys(e);if(be!==void 0&&N.length<be)y.push({instanceLocation:s,keyword:"minProperties",keywordLocation:`${a}/minProperties`,error:`Instance does not have at least ${be} properties.`});if(ue!==void 0&&N.length>ue)y.push({instanceLocation:s,keyword:"maxProperties",keywordLocation:`${a}/maxProperties`,error:`Instance does not have at least ${ue} properties.`});if(de!==void 0){let k=`${a}/propertyNames`;for(let P in e){let Z=`${s}/${ut(P)}`,D=Me(P,de,o,r,n,i,Z,k);if(!D.valid)y.push({instanceLocation:s,keyword:"propertyNames",keywordLocation:k,error:`Property name "${P}" does not match schema.`},...D.errors)}}if(Ee!==void 0){let k=`${a}/dependantRequired`;for(let P in Ee)if(P in e){let Z=Ee[P];for(let D of Z)if(!(D in e))y.push({instanceLocation:s,keyword:"dependentRequired",keywordLocation:k,error:`Instance has "${P}" but does not have "${D}".`})}}if(Pe!==void 0)for(let k in Pe){let P=`${a}/dependentSchemas`;if(k in e){let Z=Me(e,Pe[k],o,r,n,i,s,`${P}/${ut(k)}`,l);if(!Z.valid)y.push({instanceLocation:s,keyword:"dependentSchemas",keywordLocation:P,error:`Instance has "${k}" but does not match dependant schema.`},...Z.errors)}}if(Ae!==void 0){let k=`${a}/dependencies`;for(let P in Ae)if(P in e){let Z=Ae[P];if(Array.isArray(Z)){for(let D of Z)if(!(D in e))y.push({instanceLocation:s,keyword:"dependencies",keywordLocation:k,error:`Instance has "${P}" but does not have "${D}".`})}else{let D=Me(e,Z,o,r,n,i,s,`${k}/${ut(P)}`);if(!D.valid)y.push({instanceLocation:s,keyword:"dependencies",keywordLocation:k,error:`Instance has "${P}" but does not match dependant schema.`},...D.errors)}}}let I=Object.create(null),j=!1;if(ve!==void 0){let k=`${a}/properties`;for(let P in ve){if(!(P in e))continue;let Z=`${s}/${ut(P)}`,D=Me(e[P],ve[P],o,r,n,i,Z,`${k}/${ut(P)}`);if(D.valid)l[P]=I[P]=!0;else if(j=n,y.push({instanceLocation:s,keyword:"properties",keywordLocation:k,error:`Property "${P}" does not match schema.`},...D.errors),j)break}}if(!j&&se!==void 0){let k=`${a}/patternProperties`;for(let P in se){let Z=new RegExp(P,"u"),D=se[P];for(let Se in e){if(!Z.test(Se))continue;let Be=`${s}/${ut(Se)}`,rt=Me(e[Se],D,o,r,n,i,Be,`${k}/${ut(P)}`);if(rt.valid)l[Se]=I[Se]=!0;else j=n,y.push({instanceLocation:s,keyword:"patternProperties",keywordLocation:k,error:`Property "${Se}" matches pattern "${P}" but does not match associated schema.`},...rt.errors)}}}if(!j&&te!==void 0){let k=`${a}/additionalProperties`;for(let P in e){if(I[P])continue;let Z=`${s}/${ut(P)}`,D=Me(e[P],te,o,r,n,i,Z,k);if(D.valid)l[P]=!0;else j=n,y.push({instanceLocation:s,keyword:"additionalProperties",keywordLocation:k,error:`Property "${P}" does not match additional properties schema.`},...D.errors)}}else if(!j&&ne!==void 0){let k=`${a}/unevaluatedProperties`;for(let P in e)if(!l[P]){let Z=`${s}/${ut(P)}`,D=Me(e[P],ne,o,r,n,i,Z,k);if(D.valid)l[P]=!0;else y.push({instanceLocation:s,keyword:"unevaluatedProperties",keywordLocation:k,error:`Property "${P}" does not match unevaluated properties schema.`},...D.errors)}}}else if(m==="array"){if(ye!==void 0&&e.length>ye)y.push({instanceLocation:s,keyword:"maxItems",keywordLocation:`${a}/maxItems`,error:`Array has too many items (${e.length} > ${ye}).`});if(fe!==void 0&&e.length<fe)y.push({instanceLocation:s,keyword:"minItems",keywordLocation:`${a}/minItems`,error:`Array has too few items (${e.length} < ${fe}).`});let N=e.length,I=0,j=!1;if(W!==void 0){let k=`${a}/prefixItems`,P=Math.min(W.length,N);for(;I<P;I++){let Z=Me(e[I],W[I],o,r,n,i,`${s}/${I}`,`${k}/${I}`);if(l[I]=!0,!Z.valid){if(j=n,y.push({instanceLocation:s,keyword:"prefixItems",keywordLocation:k,error:"Items did not match schema."},...Z.errors),j)break}}}if(ie!==void 0){let k=`${a}/items`;if(Array.isArray(ie)){let P=Math.min(ie.length,N);for(;I<P;I++){let Z=Me(e[I],ie[I],o,r,n,i,`${s}/${I}`,`${k}/${I}`);if(l[I]=!0,!Z.valid){if(j=n,y.push({instanceLocation:s,keyword:"items",keywordLocation:k,error:"Items did not match schema."},...Z.errors),j)break}}}else for(;I<N;I++){let P=Me(e[I],ie,o,r,n,i,`${s}/${I}`,k);if(l[I]=!0,!P.valid){if(j=n,y.push({instanceLocation:s,keyword:"items",keywordLocation:k,error:"Items did not match schema."},...P.errors),j)break}}if(!j&&E!==void 0){let P=`${a}/additionalItems`;for(;I<N;I++){let Z=Me(e[I],E,o,r,n,i,`${s}/${I}`,P);if(l[I]=!0,!Z.valid)j=n,y.push({instanceLocation:s,keyword:"additionalItems",keywordLocation:P,error:"Items did not match additional items schema."},...Z.errors)}}}if(Q!==void 0)if(N===0&&G===void 0)y.push({instanceLocation:s,keyword:"contains",keywordLocation:`${a}/contains`,error:"Array is empty. It must contain at least one item matching the schema."});else if(G!==void 0&&N<G)y.push({instanceLocation:s,keyword:"minContains",keywordLocation:`${a}/minContains`,error:`Array has less items (${N}) than minContains (${G}).`});else{let k=`${a}/contains`,P=y.length,Z=0;for(let D=0;D<N;D++){let Se=Me(e[D],Q,o,r,n,i,`${s}/${D}`,k);if(Se.valid)l[D]=!0,Z++;else y.push(...Se.errors)}if(Z>=(G||0))y.length=P;if(G===void 0&&$e===void 0&&Z===0)y.splice(P,0,{instanceLocation:s,keyword:"contains",keywordLocation:k,error:"Array does not contain item matching schema."});else if(G!==void 0&&Z<G)y.push({instanceLocation:s,keyword:"minContains",keywordLocation:`${a}/minContains`,error:`Array must contain at least ${G} items matching schema. Only ${Z} items were found.`});else if($e!==void 0&&Z>$e)y.push({instanceLocation:s,keyword:"maxContains",keywordLocation:`${a}/maxContains`,error:`Array may contain at most ${$e} items matching schema. ${Z} items were found.`})}if(!j&&U!==void 0){let k=`${a}/unevaluatedItems`;for(;I<N;I++){if(l[I])continue;let P=Me(e[I],U,o,r,n,i,`${s}/${I}`,k);if(l[I]=!0,!P.valid)y.push({instanceLocation:s,keyword:"unevaluatedItems",keywordLocation:k,error:"Items did not match unevaluated items schema."},...P.errors)}}if(je)for(let k=0;k<N;k++){let P=e[k],Z=typeof P==="object"&&P!==null;for(let D=0;D<N;D++){if(k===D)continue;let Se=e[D];if(P===Se||Z&&typeof Se==="object"&&Se!==null&&ri(P,Se))y.push({instanceLocation:s,keyword:"uniqueItems",keywordLocation:`${a}/uniqueItems`,error:`Duplicate items at indexes ${k} and ${D}.`}),k=Number.MAX_SAFE_INTEGER,D=Number.MAX_SAFE_INTEGER}}}else if(m==="number"){if(o==="4"){if(pe!==void 0&&(Ne===!0&&e<=pe||e<pe))y.push({instanceLocation:s,keyword:"minimum",keywordLocation:`${a}/minimum`,error:`${e} is less than ${Ne?"or equal to ":""} ${pe}.`});if(ze!==void 0&&(Ze===!0&&e>=ze||e>ze))y.push({instanceLocation:s,keyword:"maximum",keywordLocation:`${a}/maximum`,error:`${e} is greater than ${Ze?"or equal to ":""} ${ze}.`})}else{if(pe!==void 0&&e<pe)y.push({instanceLocation:s,keyword:"minimum",keywordLocation:`${a}/minimum`,error:`${e} is less than ${pe}.`});if(ze!==void 0&&e>ze)y.push({instanceLocation:s,keyword:"maximum",keywordLocation:`${a}/maximum`,error:`${e} is greater than ${ze}.`});if(Ne!==void 0&&e<=Ne)y.push({instanceLocation:s,keyword:"exclusiveMinimum",keywordLocation:`${a}/exclusiveMinimum`,error:`${e} is less than ${Ne}.`});if(Ze!==void 0&&e>=Ze)y.push({instanceLocation:s,keyword:"exclusiveMaximum",keywordLocation:`${a}/exclusiveMaximum`,error:`${e} is greater than or equal to ${Ze}.`})}if(ge!==void 0){let N=e%ge;if(Math.abs(0-N)>=0.00000011920929&&Math.abs(ge-N)>=0.00000011920929)y.push({instanceLocation:s,keyword:"multipleOf",keywordLocation:`${a}/multipleOf`,error:`${e} is not a multiple of ${ge}.`})}}else if(m==="string"){let N=ae===void 0&&Xe===void 0?0:tb(e);if(ae!==void 0&&N<ae)y.push({instanceLocation:s,keyword:"minLength",keywordLocation:`${a}/minLength`,error:`String is too short (${N} < ${ae}).`});if(Xe!==void 0&&N>Xe)y.push({instanceLocation:s,keyword:"maxLength",keywordLocation:`${a}/maxLength`,error:`String is too long (${N} > ${Xe}).`});if(st!==void 0&&!new RegExp(st,"u").test(e))y.push({instanceLocation:s,keyword:"pattern",keywordLocation:`${a}/pattern`,error:"String does not match pattern."});if(le!==void 0&&Tm[le]&&!Tm[le](e))y.push({instanceLocation:s,keyword:"format",keywordLocation:`${a}/format`,error:`String does not match format "${le}".`})}return{valid:y.length===0,errors:y}}var ob=class{schema;draft;shortCircuit;lookup;constructor(e,t="2019-09",o=!0){this.schema=e,this.draft=t,this.shortCircuit=o,this.lookup=yo(e)}validate(e){return Me(e,this.schema,this.draft,this.lookup,this.shortCircuit)}addSchema(e,t){if(t)e={...e,$id:t};yo(e,this.lookup)}},Ta=class{shortcircuit;draft;constructor(e){this.shortcircuit=e?.shortcircuit??!0,this.draft=e?.draft}_draftFor(e){let t=kl(e,"pass an explicit { draft } to CfWorkerJsonSchemaValidator to validate other dialects.");return t==="draft-7"?"7":t}getValidator(e){let t=new ob(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 rb;rb=globalThis.crypto;var fr=class extends Error{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.OAuthClientFlowError"})}static[Symbol.hasInstance](e){return Qe(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 Qe(this,e)}constructor(e){super(e);this.name=new.target.name,Vt(this,new.target)}},lb=class extends fr{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}},ub=class extends fr{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}},db=class extends fr{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 fr{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}},hb=class extends fr{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 jm=class extends Error{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.UnauthorizedError"})}static[Symbol.hasInstance](e){return Qe(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 Qe(this,e)}constructor(e){super(e??"Unauthorized");this.name="UnauthorizedError",Vt(this,new.target)}};var ka=new Set(["tools/list","prompts/list","resources/list","resources/templates/list","server/discover"]),Lm=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(ml(e))}set(e,t){let o=ml(e),r=ka.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(!ka.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(ml(e))&&!ka.has(e.method))this._cappedSize--}evict(e){let t=`${e}\x00`,o=ka.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 ml(e){return`${e.method}\x00${JSON.stringify([e.partition??"",e.params??""])}`}function fl(e,t){return t===void 0?e:`${e}\x00${t}`}var Um=86400000,mb=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=fl(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=fl(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(fl(e,r?.params))??0)!==o)return;let n=r?.params??"",i=this._partitionFor("private"),s=this._partitionFor("public"),a=(r?.scope??"private")==="public"?s:i;try{await this._store.set({method:e,params:n,partition:a},{value:fb(t),expiresAt:r?.expiresAt,scope:r?.scope})}catch(l){this._reportError(l)}if(s!==i)try{await this._store.delete({method:e,params:n,partition:a===i?s:i})}catch(l){this._reportError(l)}}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 fb(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 gb=Symbol.for("mcp.authSeamEscape");function Sb(e){return(typeof e==="object"&&e!==null||typeof e==="function")&&e[gb]===!0}var _b=-32022,bb=new Set([-32001,-32020,-32021]);function yb(e,t){switch(e.kind){case"result":return vb(e.result,t);case"rpc-error":return Zm(e,t);case"http-error":return zb(e,t);case"network-error":return Cm(e.error,t);case"unusable-reply":return{kind:"error",error:new L(F.EraNegotiationFailed,`Version negotiation probe failed: the server answered with an unusable reply (${Dm(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 Cm(Error("Connection closed during the version negotiation probe"),t);case"timeout":if(t.transportKind==="stdio")return{kind:"legacy"};return{kind:"error",error:new L(F.RequestTimeout,`Version negotiation probe timed out after ${e.timeoutMs}ms`,{timeout:e.timeoutMs})}}}function vb(e,t){let o=Et(xa).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 Xs({supported:[...r],requested:t.requestedVersion})}}function Zm(e,t){let{code:o,message:r,data:n}=e;if(o===_b){let i=Rb(n);if(i===void 0)return{kind:"legacy"};let s=new Xs({supported:i,requested:xb(n)??t.requestedVersion},r),a=Qs(i),l=t.clientModernVersions.find((u)=>a.includes(u));if(l!==void 0)return{kind:"corrective",version:l,error:s};if(a.length>0)return{kind:"error",error:s};return t.fallbackAvailable?{kind:"legacy"}:{kind:"error",error:s}}if(bb.has(o))return{kind:"legacy"};return{kind:"legacy"}}function zb(e,t){if(e.status===401||e.status===403){let r=e.status===403;return{kind:"error",error:new Ys(r?F.ClientHttpForbidden:F.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 Ys(F.EraNegotiationFailed,`Version negotiation failed: the server answered the probe with HTTP ${e.status}`,{status:e.status,statusText:e.statusText,text:e.body})};let o=Eb(e.body);if(o!==void 0)return Zm(o,t);return{kind:"legacy"}}function Cm(e,t){if(t.environment==="browser"&&wb(e))return{kind:"legacy"};return{kind:"error",error:new L(F.EraNegotiationFailed,`Version negotiation probe failed: ${Dm(e)}`,{cause:e},{cause:e})}}function wb(e){return e instanceof TypeError||e instanceof Error&&e.name==="TypeError"}function Dm(e){return e instanceof Error?e.message:String(e)}function Rb(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 xb(e){if(typeof e!=="object"||e===null)return;let t=e.requested;return typeof t==="string"?t:void 0}function Eb(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 Pb="legacy";function Tb(e,t){let o=e?.mode??Pb;if(o==="legacy")return{kind:"legacy"};let r=e?.probe??{};if(typeof o==="object"){if(!Pt(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?Qs(t):[];return{kind:"auto",modernVersions:n.length>0?n:[...ol],fallbackAvailable:t?rl(t).length>0:!0,probe:r}}function Im(){let e=globalThis;return e.window!==void 0&&e.document!==void 0?"browser":"node"}function Om(e){return"stderr"in e&&"pid"in e?"stdio":"http"}var kb=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&&(mr(r)||ei(r))&&r.id===n.id){if(o._pending=void 0,mr(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=(l)=>{if(i)return;if(i=!0,clearTimeout(a),this._pending?.id===r)this._pending=void 0;n(l)},a=setTimeout(()=>s({kind:"timeout"}),o);this._pending={id:r,resolve:s},this._transport.send(t(r)).catch((l)=>s({kind:"send-error",error:l}))})}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,Sl.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)}}},Sl=new WeakMap;function Mm(e){let t=Sl.get(e);Sl.delete(e),t?.()}function $b(e,t,o,r){return{jsonrpc:"2.0",id:e,method:"server/discover",params:{_meta:Et(t).outboundEnvelope({protocolVersion:t,clientInfo:o,clientCapabilities:r})}}}function Cb(e){if(e instanceof L&&e.code===F.ClientHttpUnexpectedContent)return!0;return e instanceof Error&&e.name==="SyntaxError"}function Ib(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(Sb(o)||o instanceof jm||o instanceof Error&&o.name==="UnauthorizedError")return{kind:"auth-required",error:o};if(o instanceof Ys){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(Cb(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 Vm(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 kb.open(t.transport),a=async()=>{let u=n[0],m=!1,h=r;for(;;){let f=await s.exchange((z)=>$b(z,u,t.clientInfo,t.capabilities),o);if(f.kind==="timeout"&&h>0){h--;continue}let g=Ib(f,o),_=yb(g,{clientModernVersions:n,requestedVersion:u,fallbackAvailable:i,environment:t.environment,transportKind:t.transportKind});switch(_.kind){case"modern":return{era:"modern",version:_.version,discover:_.discover};case"corrective":if(m)throw _.error;m=!0,u=_.version;continue;case"legacy":{let z=g.kind==="closed"?"the connection closed during the server/discover probe":void 0;if(e.kind==="pin")throw new L(F.EraNegotiationFailed,z===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: ${z} before the server offered pinned protocol version ${e.version} (no fallback in pin mode)`);if(!e.fallbackAvailable)throw new L(F.EraNegotiationFailed,z===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: ${z} and this client supports no pre-2026-07-28 protocol version to fall back to`);if(z!==void 0&&t.disposableProbe!==!0)throw new L(F.EraNegotiationFailed,`Version negotiation failed: ${z} (this transport probed in place — the disposable sibling probe requires the SDK's base StdioClientTransport)`);return{era:"legacy"}}case"error":throw _.error}}},l;try{l=await a()}catch(u){throw s.detach(),u}return s.release(),l}function Ob(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 Mb(e,t,o,r){let i=new t.constructor({...o,stderr:"ignore"}),s=t.close,a=!1,l,u=new Promise((h,f)=>{l=()=>f(Am())});t.close=async function(){return a=!0,l?.(),s.call(t)};let m;try{let h=Vm(e,{...r,transport:i,transportKind:"stdio",disposableProbe:!0});h.catch(()=>{}),m=await Promise.race([h,u])}finally{await Ab(i),t.close=s}if(a)throw Am();return m}function Am(){return new L(F.EraNegotiationFailed,"Version negotiation failed: the transport was closed during the server/discover probe")}async function Ab(e){try{let t=e._dispose;await(typeof t==="function"?t.call(e):e.close())}catch{}}function Nm(e){let t=e._meta?.[ht];return dl.Implementation(t)?t:void 0}function $a(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)$a(i,o[n])}}if(Array.isArray(e.anyOf)){for(let o of e.anyOf)if(typeof o!=="boolean")$a(o,t)}if(Array.isArray(e.oneOf)){for(let o of e.oneOf)if(typeof o!=="boolean")$a(o,t)}}function Hm(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 Nb(e){if(typeof e==="object"&&e!==null){if(e.kind==="legacy"&&!("supportedVersions"in e)&&!("discover"in e))return e;if(e.kind==="modern"&&Lt.safeParse(e.discover).success)return e}throw new L(F.EraNegotiationFailed,"connect({ prior }): unrecognized prior — expected { kind: 'modern', discover } or { kind: 'legacy' }")}var qm={"notifications/tools/list_changed":["tools/list"],"notifications/prompts/list_changed":["prompts/list"],"notifications/resources/list_changed":["resources/list","resources/templates/list"]},qb=64,gl={},jb=class extends oi{_serverCapabilities;_serverVersion;_capabilities;_instructions;_jsonSchemaValidator;_cache;_defaultCacheTtlMs;_listMaxPages;_listChangedDebounceTimers=new Map;_listChangedConfig;_enforceStrictCapabilities;_versionNegotiation;_supportedProtocolVersionsOption;_inputRequiredDriverConfig;_listenState=new Map;_nextListenId=0;_autoOpenedSubscription;_discoverResult;static{gl.enforceStrictCapabilities=(e)=>e._enforceStrictCapabilities,gl.walkPages=(e,t,o,r)=>e._walkPages(t,o,r),gl.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 L(F.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 Ta,this._enforceStrictCapabilities=t?.enforceStrictCapabilities??!1,this._versionNegotiation=t?.versionNegotiation,this._supportedProtocolVersionsOption=t?.supportedProtocolVersions,this._inputRequiredDriverConfig=wm(t?.inputRequired),this._cache=new mb(t?.responseCacheStore??new Lm,t?.responseCacheStore!==void 0,(o)=>this._reportStoreError(o),t?.cachePartition??""),this._defaultCacheTtlMs=t?.defaultCacheTtlMs??0,this._listMaxPages=t?.listMaxPages??qb,t?.listChanged)this._listChangedConfig=t.listChanged}buildContext(e,t){return e}_shouldDropInbound(e){if(this._negotiatedProtocolVersion!==void 0&&Pt(this._negotiatedProtocolVersion)&&Ea(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 L(F.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 Pm({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=hl(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=Et(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 _e(i.reason==="not-in-era"?Y.InternalError:Y.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:a,supportsUrlMode:l}=Hm(this._capabilities.elicitation);if(s.mode==="form"&&!a)throw new _e(Y.InvalidParams,"Client does not support form-mode elicitation requests");if(s.mode==="url"&&!l)throw new _e(Y.InvalidParams,"Client does not support URL-mode elicitation requests");let u=await t(o,r),m=n.validateResult("elicitation/create",u);if(!m.ok&&m.reason==="not-in-era")m=n.validateInputResponse("elicitation/create",u);if(!m.ok)throw new _e(m.reason==="not-in-era"?Y.InternalError:Y.InvalidParams,m.reason==="not-in-era"?"No wire schema for elicitation/create in the resolved era":`Invalid elicitation result: ${m.message}`);let h=m.value,f=s.mode==="form"?s.requestedSchema:void 0;if(s.mode==="form"&&h.action==="accept"&&h.content&&f&&this._capabilities.elicitation?.form?.applyDefaults)try{$a(f,h.content)}catch{}return h};if(e==="sampling/createMessage")return async(o,r)=>{let n=Et(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 _e(i.reason==="not-in-era"?Y.InternalError:Y.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,a=await t(o,r),l=Boolean(s.tools||s.toolChoice),u=n.samplingResultVariant(l,a);if(!u.ok&&u.reason==="not-in-era")u=n.validateInputResponse("sampling/createMessage",a);if(!u.ok)throw new _e(u.reason==="not-in-era"?Y.InternalError:Y.InvalidParams,u.reason==="not-in-era"?"No result schema for sampling/createMessage in the resolved era":`Invalid sampling result: ${u.message}`);return u.value};return t}assertCapability(e,t){if(!this._serverCapabilities?.[e])throw new L(F.CapabilityNotSupported,`Server does not support ${e} (required for ${t})`)}async connect(e,t){if(t?.prior!=null)return this._connectFromPrior(e,Nb(t.prior),t);let o=Tb(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=rl(this._supportedProtocolVersions);try{let r=o[0];if(r===void 0)throw new L(F.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=Om(e),i={clientInfo:this._clientInfo,capabilities:this._capabilities,environment:Im(),defaultTimeoutMs:o?.timeout??ti},s=n==="stdio"?Ob(e):void 0;r=s===void 0?await Vm(t,{...i,transport:e,transportKind:n}):await Mb(t,e,s,i)}catch(n){throw await e.close().catch(()=>{}),Mm(e),n}if(Mm(e),await super.connect(e),r.era==="legacy"){await this._legacyHandshake(e,o);return}if(this._serverCapabilities=r.discover.capabilities,this._serverVersion=Nm(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}},a=!0;try{this._setupListChangedHandlers(s)}catch(u){a=!1,this.onerror?.(u instanceof Error?u:Error(String(u)))}let l=a?{...s.tools&&{toolsListChanged:!0},...s.prompts&&{promptsListChanged:!0},...s.resources&&{resourcesListChanged:!0}}:{};if(Object.keys(l).length>0){let u=new AbortController,m=()=>u.abort(o?.signal?.reason);if(o?.signal?.aborted)m();o?.signal?.addEventListener("abort",m);try{this._autoOpenedSubscription=await this.listen(l,{timeout:o?.timeout,signal:u.signal})}catch(h){if(o?.signal?.aborted)throw await this.close().catch(()=>{}),h;this.onerror?.(h instanceof Error?h:Error(String(h)))}finally{o?.signal?.removeEventListener("abort",m)}}}}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&&Qs(n).length>0?Qs(n):ol).find((s)=>r.supportedVersions.includes(s));if(i===void 0)throw new L(F.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=Nm(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 Pt(e)?"modern":"legacy"}getInstructions(){return this._instructions}getDiscoverResult(){return this._discoverResult}assertCapabilityForMethod(e){switch(e){case"logging/setLevel":if(!this._serverCapabilities?.logging)throw new L(F.CapabilityNotSupported,`Server does not support logging (required for ${e})`);break;case"prompts/get":case"prompts/list":if(!this._serverCapabilities?.prompts)throw new L(F.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 L(F.CapabilityNotSupported,`Server does not support resources (required for ${e})`);if(e==="resources/subscribe"&&!this._serverCapabilities.resources.subscribe)throw new L(F.CapabilityNotSupported,`Server does not support resource subscriptions (required for ${e})`);break;case"tools/call":case"tools/list":if(!this._serverCapabilities?.tools)throw new L(F.CapabilityNotSupported,`Server does not support tools (required for ${e})`);break;case"completion/complete":if(!this._serverCapabilities?.completions)throw new L(F.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 L(F.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 L(F.CapabilityNotSupported,`Client does not support sampling capability (required for ${e})`);break;case"elicitation/create":if(!this._capabilities.elicitation)throw new L(F.CapabilityNotSupported,`Client does not support elicitation capability (required for ${e})`);break;case"roots/list":if(!this._capabilities.roots)throw new L(F.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"},Lt,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),a=(u)=>{let m=u===void 0?t&&{...t}:{...t,cursor:u};return this.request({method:e,...m&&{params:m}},o)},l=await this._walkPages(e,a,r);if(delete l.nextCursor,n?.(l),i)return l;return await this._cache.write(e,l,s,this._freshness(l)),l}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 L(F.ListPaginationExceeded,`${e}: exceeded listMaxPages (${this._listMaxPages}); server pagination did not terminate`,{method:e,listMaxPages:this._listMaxPages});let a=await t(n);if(a.nextCursor===n&&JSON.stringify(o(a))===JSON.stringify(o(i)))break;o(r).push(...o(a)),i=a,n=a.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),Um),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 L?n:new L(F.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:ll(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 L(F.NotConnected,"Not connected");let o=this._negotiatedProtocolVersion;if(o===void 0||!Pt(o))throw new L(F.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 x=t.signal.reason;throw x instanceof L?x:new L(F.RequestTimeout,String(x))}let r=new AbortController,n=`listen:${this._nextListenId++}`,i="opening",s,a,l,u,m=new Promise((x,T)=>{l=x,u=T}),h,f=new Promise((x)=>{h=x}),g=(x)=>{if(i==="closed")return;let T=i==="opening";if(s!==void 0)clearTimeout(s),s=void 0;if("ack"in x){i="open",l(x.ack);return}if(i="closed",a!==void 0)t?.signal?.removeEventListener("abort",a);if(this._listenState.delete(n),r.abort(),h(x.cause),T)u(x.error??new L(F.ConnectionClosed,"subscriptions/listen closed before the server acknowledged"))},_=async()=>{r.abort(),await this.notification({method:"notifications/cancelled",params:{requestId:n}}).catch(()=>{})},z=async()=>{if(i==="closed")return;g({cause:"local"}),await _()};this._listenState.set(n,{settle:g});let b=t?.timeout??ti;if(s=setTimeout(()=>{g({cause:"remote",error:new L(F.RequestTimeout,"subscriptions/listen ack timed out",{timeout:b})}),_().catch(()=>{})},b),t?.signal){let x=t.signal;a=()=>{if(i==="closed")return;let T=x.reason;g({cause:"local",error:T instanceof Error?T:Error(String(T??"Aborted"))}),_().catch(()=>{})},x.addEventListener("abort",a,{once:!0})}let w={jsonrpc:"2.0",id:n,method:"subscriptions/listen",params:{_meta:{...this._outboundMetaEnvelope()},notifications:e}},C=(x)=>{g({cause:"remote",error:x instanceof Error?x:Error(String(x))})};try{this.transport.send(w,{requestSignal:r.signal,onRequestStreamEnd:()=>g({cause:"remote",error:Error("subscriptions/listen: stream ended")})}).catch(C)}catch(x){C(x)}return{honoredFilter:await m,close:z,closed:f}}get autoOpenedSubscription(){return this._autoOpenedSubscription}_onnotification(e,t){let o=Object.hasOwn(qm,e.method)?qm[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?.[Lo],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(ei(e))o.settle({cause:"remote",error:_e.fromError(e.error.code,e.error.message,e.error.data)});else o.settle({cause:"graceful",error:new L(F.ConnectionClosed,"subscriptions/listen: server closed the subscription gracefully before acknowledging")});return}super._onresponse(e)}_onclose(){if(this._listenState.size>0){let e=new L(F.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"&&Im()!=="browser",r=async()=>{if(!o)return t;let l;try{l=await this._resolveXMcpHeaderScan(e.name,t?.toolDefinition)}catch(m){this._reportStoreError(m)}if(!l?.valid||l.declarations.length===0)return t;let u=vm(l.declarations,e.arguments);return Object.keys(u).length===0?t:{...t,headers:{...t?.headers,...u}}},n=t?.toolDefinition===void 0?await this._cache.outputValidator(e.name,(l)=>this._compileOutputValidator(l)).catch((l)=>void this._reportStoreError(l)):this._compileOutputValidator(t.toolDefinition),i=()=>{if(n===void 0||n.ok)return;let l=n.compileError,u=(l instanceof Error?l.message:String(l)).slice(0,200);throw new _e(Y.InvalidParams,`Tool '${e.name}' has an invalid outputSchema: ${u}`)};i();let s;try{s=await this.request({method:"tools/call",params:e},await r())}catch(l){let u=l instanceof _e&&l.code===hr;if(!o||!u||t?.toolDefinition!==void 0)throw l;let m={signal:t?.signal,timeout:t?.timeout,cacheMode:"refresh"};await this._cache.evict("tools/list"),await this.listTools(void 0,m).catch((h)=>this._reportStoreError(h)),n=await this._cache.outputValidator(e.name,(h)=>this._compileOutputValidator(h)).catch((h)=>void this._reportStoreError(h)),i(),s=await this.request({method:"tools/call",params:e},await r())}let a=n!==void 0&&n.ok?n.validator:void 0;if(a){if(s.structuredContent===void 0&&!s.isError)throw new _e(Y.InvalidRequest,`Tool ${e.name} has an output schema but did not return structured content`);if(s.structuredContent!==void 0&&!s.isError)try{let l=a(s.structuredContent);if(!l.valid)throw new _e(Y.InvalidParams,`Structured content does not match the tool's output schema: ${l.errorMessage}`)}catch(l){if(l instanceof _e)throw l;throw new _e(Y.InvalidParams,`Failed to validate structured content: ${l instanceof Error?l.message:String(l)}`)}}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||Om(this.transport)==="stdio")return;let t=e.tools.filter((o)=>{let r=ll(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=Pa(ns,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:a}=o,l=async()=>{if(!i){a(null,null);return}try{a(null,await r())}catch(m){a(m instanceof Error?m:Error(String(m)),null)}},u=()=>{if(s){let m=this._listChangedDebounceTimers.get(e);if(m)clearTimeout(m);let h=setTimeout(l,s);this._listChangedDebounceTimers.set(e,h)}else l()};this.setNotificationHandler(t,u)}async sendRootsListChanged(){return this.notification({method:"notifications/roots/list_changed"})}};var pR=class extends Error{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.SseError"})}static[Symbol.hasInstance](e){return Qe(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 Qe(this,e)}constructor(e,t,o){super(`SSE error: ${t}`);this.code=e,this.event=o,Vt(this,new.target)}};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 Ym{_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 Jm(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(!Fm.has(s))Fm.add(s),console.warn(`[ext-apps] ${s}(Schema, handler) is deprecated; use ${s}("${i}", { params: Schema.shape.params }, handler).`);let a=r;return[i,{params:n.params},e==="request"?(l,u)=>a({method:i,params:l},Lb(u)):(l)=>a({method:i,params:l})]}function Lb(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 Ub="2026-01-26";var Zb="ui/notifications/tool-input-partial";class Qm{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=lo.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!==Zb)console.debug("Sending message",e);this.eventTarget.postMessage(e,"*")}async close(){window.removeEventListener("message",this.messageListener),this.onclose?.()}onclose;onerror;onmessage;sessionId;setProtocolVersion}var Db=A([p("light"),p("dark")]).describe("Color theme preference for the host environment."),ni=A([p("inline"),p("fullscreen"),p("pip")]).describe("Display mode for UI presentation."),Vb=A([p("--color-background-primary"),p("--color-background-secondary"),p("--color-background-tertiary"),p("--color-background-inverse"),p("--color-background-ghost"),p("--color-background-info"),p("--color-background-danger"),p("--color-background-success"),p("--color-background-warning"),p("--color-background-disabled"),p("--color-text-primary"),p("--color-text-secondary"),p("--color-text-tertiary"),p("--color-text-inverse"),p("--color-text-ghost"),p("--color-text-info"),p("--color-text-danger"),p("--color-text-success"),p("--color-text-warning"),p("--color-text-disabled"),p("--color-border-primary"),p("--color-border-secondary"),p("--color-border-tertiary"),p("--color-border-inverse"),p("--color-border-ghost"),p("--color-border-info"),p("--color-border-danger"),p("--color-border-success"),p("--color-border-warning"),p("--color-border-disabled"),p("--color-ring-primary"),p("--color-ring-secondary"),p("--color-ring-inverse"),p("--color-ring-info"),p("--color-ring-danger"),p("--color-ring-success"),p("--color-ring-warning"),p("--font-sans"),p("--font-mono"),p("--font-weight-normal"),p("--font-weight-medium"),p("--font-weight-semibold"),p("--font-weight-bold"),p("--font-text-xs-size"),p("--font-text-sm-size"),p("--font-text-md-size"),p("--font-text-lg-size"),p("--font-heading-xs-size"),p("--font-heading-sm-size"),p("--font-heading-md-size"),p("--font-heading-lg-size"),p("--font-heading-xl-size"),p("--font-heading-2xl-size"),p("--font-heading-3xl-size"),p("--font-text-xs-line-height"),p("--font-text-sm-line-height"),p("--font-text-md-line-height"),p("--font-text-lg-line-height"),p("--font-heading-xs-line-height"),p("--font-heading-sm-line-height"),p("--font-heading-md-line-height"),p("--font-heading-lg-line-height"),p("--font-heading-xl-line-height"),p("--font-heading-2xl-line-height"),p("--font-heading-3xl-line-height"),p("--border-radius-xs"),p("--border-radius-sm"),p("--border-radius-md"),p("--border-radius-lg"),p("--border-radius-xl"),p("--border-radius-full"),p("--border-width-regular"),p("--shadow-hairline"),p("--shadow-sm"),p("--shadow-md"),p("--shadow-lg")]).describe("CSS variable keys available to MCP apps for theming."),Hb=O(Vb.describe(`Style variables for theming MCP apps.
71
+ - `)}`,Error(k)}let C=`${a}/$ref`,j=qe(e,N,o,r,n,i,s,C,l);if(!j.valid)b.push({instanceLocation:s,keyword:"$ref",keywordLocation:C,error:"A subschema had errors."},...j.errors);if(o==="4"||o==="7")return{valid:b.length===0,errors:b}}if(Array.isArray(y)){let N=y.length,C=!1;for(let j=0;j<N;j++)if(m===y[j]||y[j]==="integer"&&m==="number"&&e%1===0&&e===e){C=!0;break}if(!C)b.push({instanceLocation:s,keyword:"type",keywordLocation:`${a}/type`,error:`Instance type "${m}" is invalid. Expected "${y.join('", "')}".`})}else if(y==="integer"){if(m!=="number"||e%1||e!==e)b.push({instanceLocation:s,keyword:"type",keywordLocation:`${a}/type`,error:`Instance type "${m}" is invalid. Expected "${y}".`})}else if(y!==void 0&&m!==y)b.push({instanceLocation:s,keyword:"type",keywordLocation:`${a}/type`,error:`Instance type "${m}" is invalid. Expected "${y}".`});if(z!==void 0){if(m==="object"||m==="array"){if(!ri(e,z))b.push({instanceLocation:s,keyword:"const",keywordLocation:`${a}/const`,error:`Instance does not match ${JSON.stringify(z)}.`})}else if(e!==z)b.push({instanceLocation:s,keyword:"const",keywordLocation:`${a}/const`,error:`Instance does not match ${JSON.stringify(z)}.`})}if(_!==void 0){if(m==="object"||m==="array"){if(!_.some((N)=>ri(e,N)))b.push({instanceLocation:s,keyword:"enum",keywordLocation:`${a}/enum`,error:`Instance does not match any of ${JSON.stringify(_)}.`})}else if(!_.some((N)=>e===N))b.push({instanceLocation:s,keyword:"enum",keywordLocation:`${a}/enum`,error:`Instance does not match any of ${JSON.stringify(_)}.`})}if(E!==void 0){let N=`${a}/not`;if(qe(e,E,o,r,n,i,s,N).valid)b.push({instanceLocation:s,keyword:"not",keywordLocation:N,error:'Instance matched "not" schema.'})}let X=[];if(R!==void 0){let N=`${a}/anyOf`,C=b.length,j=!1;for(let k=0;k<R.length;k++){let P=R[k],U=Object.create(l),Z=qe(e,P,o,r,n,g===!0?i:null,s,`${N}/${k}`,U);if(b.push(...Z.errors),j=j||Z.valid,Z.valid)X.push(U)}if(j)b.length=C;else b.splice(C,0,{instanceLocation:s,keyword:"anyOf",keywordLocation:N,error:"Instance does not match any subschemas."})}if(T!==void 0){let N=`${a}/allOf`,C=b.length,j=!0;for(let k=0;k<T.length;k++){let P=T[k],U=Object.create(l),Z=qe(e,P,o,r,n,g===!0?i:null,s,`${N}/${k}`,U);if(b.push(...Z.errors),j=j&&Z.valid,Z.valid)X.push(U)}if(j)b.length=C;else b.splice(C,0,{instanceLocation:s,keyword:"allOf",keywordLocation:N,error:"Instance does not match every subschema."})}if(q!==void 0){let N=`${a}/oneOf`,C=b.length,j=q.filter((k,P)=>{let U=Object.create(l),Z=qe(e,k,o,r,n,g===!0?i:null,s,`${N}/${P}`,U);if(b.push(...Z.errors),Z.valid)X.push(U);return Z.valid}).length;if(j===1)b.length=C;else b.splice(C,0,{instanceLocation:s,keyword:"oneOf",keywordLocation:N,error:`Instance does not match exactly one subschema (${j} matches).`})}if(m==="object"||m==="array")Object.assign(l,...X);if(J!==void 0){let N=`${a}/if`;if(qe(e,J,o,r,n,i,s,N,l).valid){if(ae!==void 0){let C=qe(e,ae,o,r,n,i,s,`${a}/then`,l);if(!C.valid)b.push({instanceLocation:s,keyword:"if",keywordLocation:N,error:'Instance does not match "then" schema.'},...C.errors)}}else if(re!==void 0){let C=qe(e,re,o,r,n,i,s,`${a}/else`,l);if(!C.valid)b.push({instanceLocation:s,keyword:"if",keywordLocation:N,error:'Instance does not match "else" schema.'},...C.errors)}}if(m==="object"){if(x!==void 0){for(let k of x)if(!(k in e))b.push({instanceLocation:s,keyword:"required",keywordLocation:`${a}/required`,error:`Instance does not have required property "${k}".`})}let N=Object.keys(e);if(ge!==void 0&&N.length<ge)b.push({instanceLocation:s,keyword:"minProperties",keywordLocation:`${a}/minProperties`,error:`Instance does not have at least ${ge} properties.`});if(de!==void 0&&N.length>de)b.push({instanceLocation:s,keyword:"maxProperties",keywordLocation:`${a}/maxProperties`,error:`Instance does not have at least ${de} properties.`});if(pe!==void 0){let k=`${a}/propertyNames`;for(let P in e){let U=`${s}/${ut(P)}`,Z=qe(P,pe,o,r,n,i,U,k);if(!Z.valid)b.push({instanceLocation:s,keyword:"propertyNames",keywordLocation:k,error:`Property name "${P}" does not match schema.`},...Z.errors)}}if(ke!==void 0){let k=`${a}/dependantRequired`;for(let P in ke)if(P in e){let U=ke[P];for(let Z of U)if(!(Z in e))b.push({instanceLocation:s,keyword:"dependentRequired",keywordLocation:k,error:`Instance has "${P}" but does not have "${Z}".`})}}if($e!==void 0)for(let k in $e){let P=`${a}/dependentSchemas`;if(k in e){let U=qe(e,$e[k],o,r,n,i,s,`${P}/${ut(k)}`,l);if(!U.valid)b.push({instanceLocation:s,keyword:"dependentSchemas",keywordLocation:P,error:`Instance has "${k}" but does not match dependant schema.`},...U.errors)}}if(Ue!==void 0){let k=`${a}/dependencies`;for(let P in Ue)if(P in e){let U=Ue[P];if(Array.isArray(U)){for(let Z of U)if(!(Z in e))b.push({instanceLocation:s,keyword:"dependencies",keywordLocation:k,error:`Instance has "${P}" but does not have "${Z}".`})}else{let Z=qe(e,U,o,r,n,i,s,`${k}/${ut(P)}`);if(!Z.valid)b.push({instanceLocation:s,keyword:"dependencies",keywordLocation:k,error:`Instance has "${P}" but does not match dependant schema.`},...Z.errors)}}}let C=Object.create(null),j=!1;if(Ee!==void 0){let k=`${a}/properties`;for(let P in Ee){if(!(P in e))continue;let U=`${s}/${ut(P)}`,Z=qe(e[P],Ee[P],o,r,n,i,U,`${k}/${ut(P)}`);if(Z.valid)l[P]=C[P]=!0;else if(j=n,b.push({instanceLocation:s,keyword:"properties",keywordLocation:k,error:`Property "${P}" does not match schema.`},...Z.errors),j)break}}if(!j&&se!==void 0){let k=`${a}/patternProperties`;for(let P in se){let U=new RegExp(P,"u"),Z=se[P];for(let Se in e){if(!U.test(Se))continue;let We=`${s}/${ut(Se)}`,nt=qe(e[Se],Z,o,r,n,i,We,`${k}/${ut(P)}`);if(nt.valid)l[Se]=C[Se]=!0;else j=n,b.push({instanceLocation:s,keyword:"patternProperties",keywordLocation:k,error:`Property "${Se}" matches pattern "${P}" but does not match associated schema.`},...nt.errors)}}}if(!j&&ee!==void 0){let k=`${a}/additionalProperties`;for(let P in e){if(C[P])continue;let U=`${s}/${ut(P)}`,Z=qe(e[P],ee,o,r,n,i,U,k);if(Z.valid)l[P]=!0;else j=n,b.push({instanceLocation:s,keyword:"additionalProperties",keywordLocation:k,error:`Property "${P}" does not match additional properties schema.`},...Z.errors)}}else if(!j&&le!==void 0){let k=`${a}/unevaluatedProperties`;for(let P in e)if(!l[P]){let U=`${s}/${ut(P)}`,Z=qe(e[P],le,o,r,n,i,U,k);if(Z.valid)l[P]=!0;else b.push({instanceLocation:s,keyword:"unevaluatedProperties",keywordLocation:k,error:`Property "${P}" does not match unevaluated properties schema.`},...Z.errors)}}}else if(m==="array"){if(ue!==void 0&&e.length>ue)b.push({instanceLocation:s,keyword:"maxItems",keywordLocation:`${a}/maxItems`,error:`Array has too many items (${e.length} > ${ue}).`});if(B!==void 0&&e.length<B)b.push({instanceLocation:s,keyword:"minItems",keywordLocation:`${a}/minItems`,error:`Array has too few items (${e.length} < ${B}).`});let N=e.length,C=0,j=!1;if(W!==void 0){let k=`${a}/prefixItems`,P=Math.min(W.length,N);for(;C<P;C++){let U=qe(e[C],W[C],o,r,n,i,`${s}/${C}`,`${k}/${C}`);if(l[C]=!0,!U.valid){if(j=n,b.push({instanceLocation:s,keyword:"prefixItems",keywordLocation:k,error:"Items did not match schema."},...U.errors),j)break}}}if(ne!==void 0){let k=`${a}/items`;if(Array.isArray(ne)){let P=Math.min(ne.length,N);for(;C<P;C++){let U=qe(e[C],ne[C],o,r,n,i,`${s}/${C}`,`${k}/${C}`);if(l[C]=!0,!U.valid){if(j=n,b.push({instanceLocation:s,keyword:"items",keywordLocation:k,error:"Items did not match schema."},...U.errors),j)break}}}else for(;C<N;C++){let P=qe(e[C],ne,o,r,n,i,`${s}/${C}`,k);if(l[C]=!0,!P.valid){if(j=n,b.push({instanceLocation:s,keyword:"items",keywordLocation:k,error:"Items did not match schema."},...P.errors),j)break}}if(!j&&te!==void 0){let P=`${a}/additionalItems`;for(;C<N;C++){let U=qe(e[C],te,o,r,n,i,`${s}/${C}`,P);if(l[C]=!0,!U.valid)j=n,b.push({instanceLocation:s,keyword:"additionalItems",keywordLocation:P,error:"Items did not match additional items schema."},...U.errors)}}}if(A!==void 0)if(N===0&&V===void 0)b.push({instanceLocation:s,keyword:"contains",keywordLocation:`${a}/contains`,error:"Array is empty. It must contain at least one item matching the schema."});else if(V!==void 0&&N<V)b.push({instanceLocation:s,keyword:"minContains",keywordLocation:`${a}/minContains`,error:`Array has less items (${N}) than minContains (${V}).`});else{let k=`${a}/contains`,P=b.length,U=0;for(let Z=0;Z<N;Z++){let Se=qe(e[Z],A,o,r,n,i,`${s}/${Z}`,k);if(Se.valid)l[Z]=!0,U++;else b.push(...Se.errors)}if(U>=(V||0))b.length=P;if(V===void 0&&Y===void 0&&U===0)b.splice(P,0,{instanceLocation:s,keyword:"contains",keywordLocation:k,error:"Array does not contain item matching schema."});else if(V!==void 0&&U<V)b.push({instanceLocation:s,keyword:"minContains",keywordLocation:`${a}/minContains`,error:`Array must contain at least ${V} items matching schema. Only ${U} items were found.`});else if(Y!==void 0&&U>Y)b.push({instanceLocation:s,keyword:"maxContains",keywordLocation:`${a}/maxContains`,error:`Array may contain at most ${Y} items matching schema. ${U} items were found.`})}if(!j&&Oe!==void 0){let k=`${a}/unevaluatedItems`;for(;C<N;C++){if(l[C])continue;let P=qe(e[C],Oe,o,r,n,i,`${s}/${C}`,k);if(l[C]=!0,!P.valid)b.push({instanceLocation:s,keyword:"unevaluatedItems",keywordLocation:k,error:"Items did not match unevaluated items schema."},...P.errors)}}if(Ze)for(let k=0;k<N;k++){let P=e[k],U=typeof P==="object"&&P!==null;for(let Z=0;Z<N;Z++){if(k===Z)continue;let Se=e[Z];if(P===Se||U&&typeof Se==="object"&&Se!==null&&ri(P,Se))b.push({instanceLocation:s,keyword:"uniqueItems",keywordLocation:`${a}/uniqueItems`,error:`Duplicate items at indexes ${k} and ${Z}.`}),k=Number.MAX_SAFE_INTEGER,Z=Number.MAX_SAFE_INTEGER}}}else if(m==="number"){if(o==="4"){if(ve!==void 0&&(he===!0&&e<=ve||e<ve))b.push({instanceLocation:s,keyword:"minimum",keywordLocation:`${a}/minimum`,error:`${e} is less than ${he?"or equal to ":""} ${ve}.`});if(Pe!==void 0&&(Te===!0&&e>=Pe||e>Pe))b.push({instanceLocation:s,keyword:"maximum",keywordLocation:`${a}/maximum`,error:`${e} is greater than ${Te?"or equal to ":""} ${Pe}.`})}else{if(ve!==void 0&&e<ve)b.push({instanceLocation:s,keyword:"minimum",keywordLocation:`${a}/minimum`,error:`${e} is less than ${ve}.`});if(Pe!==void 0&&e>Pe)b.push({instanceLocation:s,keyword:"maximum",keywordLocation:`${a}/maximum`,error:`${e} is greater than ${Pe}.`});if(he!==void 0&&e<=he)b.push({instanceLocation:s,keyword:"exclusiveMinimum",keywordLocation:`${a}/exclusiveMinimum`,error:`${e} is less than ${he}.`});if(Te!==void 0&&e>=Te)b.push({instanceLocation:s,keyword:"exclusiveMaximum",keywordLocation:`${a}/exclusiveMaximum`,error:`${e} is greater than or equal to ${Te}.`})}if(je!==void 0){let N=e%je;if(Math.abs(0-N)>=0.00000011920929&&Math.abs(je-N)>=0.00000011920929)b.push({instanceLocation:s,keyword:"multipleOf",keywordLocation:`${a}/multipleOf`,error:`${e} is not a multiple of ${je}.`})}}else if(m==="string"){let N=ze===void 0&&be===void 0?0:tb(e);if(ze!==void 0&&N<ze)b.push({instanceLocation:s,keyword:"minLength",keywordLocation:`${a}/minLength`,error:`String is too short (${N} < ${ze}).`});if(be!==void 0&&N>be)b.push({instanceLocation:s,keyword:"maxLength",keywordLocation:`${a}/maxLength`,error:`String is too long (${N} > ${be}).`});if(we!==void 0&&!new RegExp(we,"u").test(e))b.push({instanceLocation:s,keyword:"pattern",keywordLocation:`${a}/pattern`,error:"String does not match pattern."});if(ie!==void 0&&Tm[ie]&&!Tm[ie](e))b.push({instanceLocation:s,keyword:"format",keywordLocation:`${a}/format`,error:`String does not match format "${ie}".`})}return{valid:b.length===0,errors:b}}var ob=class{schema;draft;shortCircuit;lookup;constructor(e,t="2019-09",o=!0){this.schema=e,this.draft=t,this.shortCircuit=o,this.lookup=yo(e)}validate(e){return qe(e,this.schema,this.draft,this.lookup,this.shortCircuit)}addSchema(e,t){if(t)e={...e,$id:t};yo(e,this.lookup)}},Ta=class{shortcircuit;draft;constructor(e){this.shortcircuit=e?.shortcircuit??!0,this.draft=e?.draft}_draftFor(e){let t=kl(e,"pass an explicit { draft } to CfWorkerJsonSchemaValidator to validate other dialects.");return t==="draft-7"?"7":t}getValidator(e){let t=new ob(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 rb;rb=globalThis.crypto;var fr=class extends Error{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.OAuthClientFlowError"})}static[Symbol.hasInstance](e){return et(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 et(this,e)}constructor(e){super(e);this.name=new.target.name,Vt(this,new.target)}},lb=class extends fr{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}},ub=class extends fr{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}},db=class extends fr{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 fr{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}},hb=class extends fr{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 jm=class extends Error{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.UnauthorizedError"})}static[Symbol.hasInstance](e){return et(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 et(this,e)}constructor(e){super(e??"Unauthorized");this.name="UnauthorizedError",Vt(this,new.target)}};var ka=new Set(["tools/list","prompts/list","resources/list","resources/templates/list","server/discover"]),Lm=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(ml(e))}set(e,t){let o=ml(e),r=ka.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(!ka.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(ml(e))&&!ka.has(e.method))this._cappedSize--}evict(e){let t=`${e}\x00`,o=ka.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 ml(e){return`${e.method}\x00${JSON.stringify([e.partition??"",e.params??""])}`}function fl(e,t){return t===void 0?e:`${e}\x00${t}`}var Um=86400000,mb=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=fl(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=fl(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(fl(e,r?.params))??0)!==o)return;let n=r?.params??"",i=this._partitionFor("private"),s=this._partitionFor("public"),a=(r?.scope??"private")==="public"?s:i;try{await this._store.set({method:e,params:n,partition:a},{value:fb(t),expiresAt:r?.expiresAt,scope:r?.scope})}catch(l){this._reportError(l)}if(s!==i)try{await this._store.delete({method:e,params:n,partition:a===i?s:i})}catch(l){this._reportError(l)}}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 fb(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 gb=Symbol.for("mcp.authSeamEscape");function Sb(e){return(typeof e==="object"&&e!==null||typeof e==="function")&&e[gb]===!0}var _b=-32022,bb=new Set([-32001,-32020,-32021]);function yb(e,t){switch(e.kind){case"result":return vb(e.result,t);case"rpc-error":return Zm(e,t);case"http-error":return zb(e,t);case"network-error":return Cm(e.error,t);case"unusable-reply":return{kind:"error",error:new L(F.EraNegotiationFailed,`Version negotiation probe failed: the server answered with an unusable reply (${Dm(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 Cm(Error("Connection closed during the version negotiation probe"),t);case"timeout":if(t.transportKind==="stdio")return{kind:"legacy"};return{kind:"error",error:new L(F.RequestTimeout,`Version negotiation probe timed out after ${e.timeoutMs}ms`,{timeout:e.timeoutMs})}}}function vb(e,t){let o=Et(xa).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 Xs({supported:[...r],requested:t.requestedVersion})}}function Zm(e,t){let{code:o,message:r,data:n}=e;if(o===_b){let i=Rb(n);if(i===void 0)return{kind:"legacy"};let s=new Xs({supported:i,requested:xb(n)??t.requestedVersion},r),a=Qs(i),l=t.clientModernVersions.find((u)=>a.includes(u));if(l!==void 0)return{kind:"corrective",version:l,error:s};if(a.length>0)return{kind:"error",error:s};return t.fallbackAvailable?{kind:"legacy"}:{kind:"error",error:s}}if(bb.has(o))return{kind:"legacy"};return{kind:"legacy"}}function zb(e,t){if(e.status===401||e.status===403){let r=e.status===403;return{kind:"error",error:new Ys(r?F.ClientHttpForbidden:F.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 Ys(F.EraNegotiationFailed,`Version negotiation failed: the server answered the probe with HTTP ${e.status}`,{status:e.status,statusText:e.statusText,text:e.body})};let o=Eb(e.body);if(o!==void 0)return Zm(o,t);return{kind:"legacy"}}function Cm(e,t){if(t.environment==="browser"&&wb(e))return{kind:"legacy"};return{kind:"error",error:new L(F.EraNegotiationFailed,`Version negotiation probe failed: ${Dm(e)}`,{cause:e},{cause:e})}}function wb(e){return e instanceof TypeError||e instanceof Error&&e.name==="TypeError"}function Dm(e){return e instanceof Error?e.message:String(e)}function Rb(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 xb(e){if(typeof e!=="object"||e===null)return;let t=e.requested;return typeof t==="string"?t:void 0}function Eb(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 Pb="legacy";function Tb(e,t){let o=e?.mode??Pb;if(o==="legacy")return{kind:"legacy"};let r=e?.probe??{};if(typeof o==="object"){if(!Pt(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?Qs(t):[];return{kind:"auto",modernVersions:n.length>0?n:[...ol],fallbackAvailable:t?rl(t).length>0:!0,probe:r}}function Im(){let e=globalThis;return e.window!==void 0&&e.document!==void 0?"browser":"node"}function Om(e){return"stderr"in e&&"pid"in e?"stdio":"http"}var kb=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&&(mr(r)||ei(r))&&r.id===n.id){if(o._pending=void 0,mr(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=(l)=>{if(i)return;if(i=!0,clearTimeout(a),this._pending?.id===r)this._pending=void 0;n(l)},a=setTimeout(()=>s({kind:"timeout"}),o);this._pending={id:r,resolve:s},this._transport.send(t(r)).catch((l)=>s({kind:"send-error",error:l}))})}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,Sl.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)}}},Sl=new WeakMap;function Mm(e){let t=Sl.get(e);Sl.delete(e),t?.()}function $b(e,t,o,r){return{jsonrpc:"2.0",id:e,method:"server/discover",params:{_meta:Et(t).outboundEnvelope({protocolVersion:t,clientInfo:o,clientCapabilities:r})}}}function Cb(e){if(e instanceof L&&e.code===F.ClientHttpUnexpectedContent)return!0;return e instanceof Error&&e.name==="SyntaxError"}function Ib(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(Sb(o)||o instanceof jm||o instanceof Error&&o.name==="UnauthorizedError")return{kind:"auth-required",error:o};if(o instanceof Ys){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(Cb(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 Vm(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 kb.open(t.transport),a=async()=>{let u=n[0],m=!1,h=r;for(;;){let f=await s.exchange((z)=>$b(z,u,t.clientInfo,t.capabilities),o);if(f.kind==="timeout"&&h>0){h--;continue}let g=Ib(f,o),y=yb(g,{clientModernVersions:n,requestedVersion:u,fallbackAvailable:i,environment:t.environment,transportKind:t.transportKind});switch(y.kind){case"modern":return{era:"modern",version:y.version,discover:y.discover};case"corrective":if(m)throw y.error;m=!0,u=y.version;continue;case"legacy":{let z=g.kind==="closed"?"the connection closed during the server/discover probe":void 0;if(e.kind==="pin")throw new L(F.EraNegotiationFailed,z===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: ${z} before the server offered pinned protocol version ${e.version} (no fallback in pin mode)`);if(!e.fallbackAvailable)throw new L(F.EraNegotiationFailed,z===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: ${z} and this client supports no pre-2026-07-28 protocol version to fall back to`);if(z!==void 0&&t.disposableProbe!==!0)throw new L(F.EraNegotiationFailed,`Version negotiation failed: ${z} (this transport probed in place — the disposable sibling probe requires the SDK's base StdioClientTransport)`);return{era:"legacy"}}case"error":throw y.error}}},l;try{l=await a()}catch(u){throw s.detach(),u}return s.release(),l}function Ob(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 Mb(e,t,o,r){let i=new t.constructor({...o,stderr:"ignore"}),s=t.close,a=!1,l,u=new Promise((h,f)=>{l=()=>f(Am())});t.close=async function(){return a=!0,l?.(),s.call(t)};let m;try{let h=Vm(e,{...r,transport:i,transportKind:"stdio",disposableProbe:!0});h.catch(()=>{}),m=await Promise.race([h,u])}finally{await Ab(i),t.close=s}if(a)throw Am();return m}function Am(){return new L(F.EraNegotiationFailed,"Version negotiation failed: the transport was closed during the server/discover probe")}async function Ab(e){try{let t=e._dispose;await(typeof t==="function"?t.call(e):e.close())}catch{}}function Nm(e){let t=e._meta?.[ht];return dl.Implementation(t)?t:void 0}function $a(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)$a(i,o[n])}}if(Array.isArray(e.anyOf)){for(let o of e.anyOf)if(typeof o!=="boolean")$a(o,t)}if(Array.isArray(e.oneOf)){for(let o of e.oneOf)if(typeof o!=="boolean")$a(o,t)}}function Hm(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 Nb(e){if(typeof e==="object"&&e!==null){if(e.kind==="legacy"&&!("supportedVersions"in e)&&!("discover"in e))return e;if(e.kind==="modern"&&Lt.safeParse(e.discover).success)return e}throw new L(F.EraNegotiationFailed,"connect({ prior }): unrecognized prior — expected { kind: 'modern', discover } or { kind: 'legacy' }")}var qm={"notifications/tools/list_changed":["tools/list"],"notifications/prompts/list_changed":["prompts/list"],"notifications/resources/list_changed":["resources/list","resources/templates/list"]},qb=64,gl={},jb=class extends oi{_serverCapabilities;_serverVersion;_capabilities;_instructions;_jsonSchemaValidator;_cache;_defaultCacheTtlMs;_listMaxPages;_listChangedDebounceTimers=new Map;_listChangedConfig;_enforceStrictCapabilities;_versionNegotiation;_supportedProtocolVersionsOption;_inputRequiredDriverConfig;_listenState=new Map;_nextListenId=0;_autoOpenedSubscription;_discoverResult;static{gl.enforceStrictCapabilities=(e)=>e._enforceStrictCapabilities,gl.walkPages=(e,t,o,r)=>e._walkPages(t,o,r),gl.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 L(F.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 Ta,this._enforceStrictCapabilities=t?.enforceStrictCapabilities??!1,this._versionNegotiation=t?.versionNegotiation,this._supportedProtocolVersionsOption=t?.supportedProtocolVersions,this._inputRequiredDriverConfig=wm(t?.inputRequired),this._cache=new mb(t?.responseCacheStore??new Lm,t?.responseCacheStore!==void 0,(o)=>this._reportStoreError(o),t?.cachePartition??""),this._defaultCacheTtlMs=t?.defaultCacheTtlMs??0,this._listMaxPages=t?.listMaxPages??qb,t?.listChanged)this._listChangedConfig=t.listChanged}buildContext(e,t){return e}_shouldDropInbound(e){if(this._negotiatedProtocolVersion!==void 0&&Pt(this._negotiatedProtocolVersion)&&Ea(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 L(F.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 Pm({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=hl(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=Et(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 _e(i.reason==="not-in-era"?Q.InternalError:Q.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:a,supportsUrlMode:l}=Hm(this._capabilities.elicitation);if(s.mode==="form"&&!a)throw new _e(Q.InvalidParams,"Client does not support form-mode elicitation requests");if(s.mode==="url"&&!l)throw new _e(Q.InvalidParams,"Client does not support URL-mode elicitation requests");let u=await t(o,r),m=n.validateResult("elicitation/create",u);if(!m.ok&&m.reason==="not-in-era")m=n.validateInputResponse("elicitation/create",u);if(!m.ok)throw new _e(m.reason==="not-in-era"?Q.InternalError:Q.InvalidParams,m.reason==="not-in-era"?"No wire schema for elicitation/create in the resolved era":`Invalid elicitation result: ${m.message}`);let h=m.value,f=s.mode==="form"?s.requestedSchema:void 0;if(s.mode==="form"&&h.action==="accept"&&h.content&&f&&this._capabilities.elicitation?.form?.applyDefaults)try{$a(f,h.content)}catch{}return h};if(e==="sampling/createMessage")return async(o,r)=>{let n=Et(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 _e(i.reason==="not-in-era"?Q.InternalError:Q.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,a=await t(o,r),l=Boolean(s.tools||s.toolChoice),u=n.samplingResultVariant(l,a);if(!u.ok&&u.reason==="not-in-era")u=n.validateInputResponse("sampling/createMessage",a);if(!u.ok)throw new _e(u.reason==="not-in-era"?Q.InternalError:Q.InvalidParams,u.reason==="not-in-era"?"No result schema for sampling/createMessage in the resolved era":`Invalid sampling result: ${u.message}`);return u.value};return t}assertCapability(e,t){if(!this._serverCapabilities?.[e])throw new L(F.CapabilityNotSupported,`Server does not support ${e} (required for ${t})`)}async connect(e,t){if(t?.prior!=null)return this._connectFromPrior(e,Nb(t.prior),t);let o=Tb(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=rl(this._supportedProtocolVersions);try{let r=o[0];if(r===void 0)throw new L(F.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=Om(e),i={clientInfo:this._clientInfo,capabilities:this._capabilities,environment:Im(),defaultTimeoutMs:o?.timeout??ti},s=n==="stdio"?Ob(e):void 0;r=s===void 0?await Vm(t,{...i,transport:e,transportKind:n}):await Mb(t,e,s,i)}catch(n){throw await e.close().catch(()=>{}),Mm(e),n}if(Mm(e),await super.connect(e),r.era==="legacy"){await this._legacyHandshake(e,o);return}if(this._serverCapabilities=r.discover.capabilities,this._serverVersion=Nm(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}},a=!0;try{this._setupListChangedHandlers(s)}catch(u){a=!1,this.onerror?.(u instanceof Error?u:Error(String(u)))}let l=a?{...s.tools&&{toolsListChanged:!0},...s.prompts&&{promptsListChanged:!0},...s.resources&&{resourcesListChanged:!0}}:{};if(Object.keys(l).length>0){let u=new AbortController,m=()=>u.abort(o?.signal?.reason);if(o?.signal?.aborted)m();o?.signal?.addEventListener("abort",m);try{this._autoOpenedSubscription=await this.listen(l,{timeout:o?.timeout,signal:u.signal})}catch(h){if(o?.signal?.aborted)throw await this.close().catch(()=>{}),h;this.onerror?.(h instanceof Error?h:Error(String(h)))}finally{o?.signal?.removeEventListener("abort",m)}}}}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&&Qs(n).length>0?Qs(n):ol).find((s)=>r.supportedVersions.includes(s));if(i===void 0)throw new L(F.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=Nm(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 Pt(e)?"modern":"legacy"}getInstructions(){return this._instructions}getDiscoverResult(){return this._discoverResult}assertCapabilityForMethod(e){switch(e){case"logging/setLevel":if(!this._serverCapabilities?.logging)throw new L(F.CapabilityNotSupported,`Server does not support logging (required for ${e})`);break;case"prompts/get":case"prompts/list":if(!this._serverCapabilities?.prompts)throw new L(F.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 L(F.CapabilityNotSupported,`Server does not support resources (required for ${e})`);if(e==="resources/subscribe"&&!this._serverCapabilities.resources.subscribe)throw new L(F.CapabilityNotSupported,`Server does not support resource subscriptions (required for ${e})`);break;case"tools/call":case"tools/list":if(!this._serverCapabilities?.tools)throw new L(F.CapabilityNotSupported,`Server does not support tools (required for ${e})`);break;case"completion/complete":if(!this._serverCapabilities?.completions)throw new L(F.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 L(F.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 L(F.CapabilityNotSupported,`Client does not support sampling capability (required for ${e})`);break;case"elicitation/create":if(!this._capabilities.elicitation)throw new L(F.CapabilityNotSupported,`Client does not support elicitation capability (required for ${e})`);break;case"roots/list":if(!this._capabilities.roots)throw new L(F.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"},Lt,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),a=(u)=>{let m=u===void 0?t&&{...t}:{...t,cursor:u};return this.request({method:e,...m&&{params:m}},o)},l=await this._walkPages(e,a,r);if(delete l.nextCursor,n?.(l),i)return l;return await this._cache.write(e,l,s,this._freshness(l)),l}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 L(F.ListPaginationExceeded,`${e}: exceeded listMaxPages (${this._listMaxPages}); server pagination did not terminate`,{method:e,listMaxPages:this._listMaxPages});let a=await t(n);if(a.nextCursor===n&&JSON.stringify(o(a))===JSON.stringify(o(i)))break;o(r).push(...o(a)),i=a,n=a.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),Um),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 L?n:new L(F.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:ll(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 L(F.NotConnected,"Not connected");let o=this._negotiatedProtocolVersion;if(o===void 0||!Pt(o))throw new L(F.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 R=t.signal.reason;throw R instanceof L?R:new L(F.RequestTimeout,String(R))}let r=new AbortController,n=`listen:${this._nextListenId++}`,i="opening",s,a,l,u,m=new Promise((R,T)=>{l=R,u=T}),h,f=new Promise((R)=>{h=R}),g=(R)=>{if(i==="closed")return;let T=i==="opening";if(s!==void 0)clearTimeout(s),s=void 0;if("ack"in R){i="open",l(R.ack);return}if(i="closed",a!==void 0)t?.signal?.removeEventListener("abort",a);if(this._listenState.delete(n),r.abort(),h(R.cause),T)u(R.error??new L(F.ConnectionClosed,"subscriptions/listen closed before the server acknowledged"))},y=async()=>{r.abort(),await this.notification({method:"notifications/cancelled",params:{requestId:n}}).catch(()=>{})},z=async()=>{if(i==="closed")return;g({cause:"local"}),await y()};this._listenState.set(n,{settle:g});let _=t?.timeout??ti;if(s=setTimeout(()=>{g({cause:"remote",error:new L(F.RequestTimeout,"subscriptions/listen ack timed out",{timeout:_})}),y().catch(()=>{})},_),t?.signal){let R=t.signal;a=()=>{if(i==="closed")return;let T=R.reason;g({cause:"local",error:T instanceof Error?T:Error(String(T??"Aborted"))}),y().catch(()=>{})},R.addEventListener("abort",a,{once:!0})}let x={jsonrpc:"2.0",id:n,method:"subscriptions/listen",params:{_meta:{...this._outboundMetaEnvelope()},notifications:e}},E=(R)=>{g({cause:"remote",error:R instanceof Error?R:Error(String(R))})};try{this.transport.send(x,{requestSignal:r.signal,onRequestStreamEnd:()=>g({cause:"remote",error:Error("subscriptions/listen: stream ended")})}).catch(E)}catch(R){E(R)}return{honoredFilter:await m,close:z,closed:f}}get autoOpenedSubscription(){return this._autoOpenedSubscription}_onnotification(e,t){let o=Object.hasOwn(qm,e.method)?qm[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?.[Lo],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(ei(e))o.settle({cause:"remote",error:_e.fromError(e.error.code,e.error.message,e.error.data)});else o.settle({cause:"graceful",error:new L(F.ConnectionClosed,"subscriptions/listen: server closed the subscription gracefully before acknowledging")});return}super._onresponse(e)}_onclose(){if(this._listenState.size>0){let e=new L(F.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"&&Im()!=="browser",r=async()=>{if(!o)return t;let l;try{l=await this._resolveXMcpHeaderScan(e.name,t?.toolDefinition)}catch(m){this._reportStoreError(m)}if(!l?.valid||l.declarations.length===0)return t;let u=vm(l.declarations,e.arguments);return Object.keys(u).length===0?t:{...t,headers:{...t?.headers,...u}}},n=t?.toolDefinition===void 0?await this._cache.outputValidator(e.name,(l)=>this._compileOutputValidator(l)).catch((l)=>void this._reportStoreError(l)):this._compileOutputValidator(t.toolDefinition),i=()=>{if(n===void 0||n.ok)return;let l=n.compileError,u=(l instanceof Error?l.message:String(l)).slice(0,200);throw new _e(Q.InvalidParams,`Tool '${e.name}' has an invalid outputSchema: ${u}`)};i();let s;try{s=await this.request({method:"tools/call",params:e},await r())}catch(l){let u=l instanceof _e&&l.code===hr;if(!o||!u||t?.toolDefinition!==void 0)throw l;let m={signal:t?.signal,timeout:t?.timeout,cacheMode:"refresh"};await this._cache.evict("tools/list"),await this.listTools(void 0,m).catch((h)=>this._reportStoreError(h)),n=await this._cache.outputValidator(e.name,(h)=>this._compileOutputValidator(h)).catch((h)=>void this._reportStoreError(h)),i(),s=await this.request({method:"tools/call",params:e},await r())}let a=n!==void 0&&n.ok?n.validator:void 0;if(a){if(s.structuredContent===void 0&&!s.isError)throw new _e(Q.InvalidRequest,`Tool ${e.name} has an output schema but did not return structured content`);if(s.structuredContent!==void 0&&!s.isError)try{let l=a(s.structuredContent);if(!l.valid)throw new _e(Q.InvalidParams,`Structured content does not match the tool's output schema: ${l.errorMessage}`)}catch(l){if(l instanceof _e)throw l;throw new _e(Q.InvalidParams,`Failed to validate structured content: ${l instanceof Error?l.message:String(l)}`)}}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||Om(this.transport)==="stdio")return;let t=e.tools.filter((o)=>{let r=ll(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=Pa(ns,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:a}=o,l=async()=>{if(!i){a(null,null);return}try{a(null,await r())}catch(m){a(m instanceof Error?m:Error(String(m)),null)}},u=()=>{if(s){let m=this._listChangedDebounceTimers.get(e);if(m)clearTimeout(m);let h=setTimeout(l,s);this._listChangedDebounceTimers.set(e,h)}else l()};this.setNotificationHandler(t,u)}async sendRootsListChanged(){return this.notification({method:"notifications/roots/list_changed"})}};var hR=class extends Error{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.SseError"})}static[Symbol.hasInstance](e){return et(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 et(this,e)}constructor(e,t,o){super(`SSE error: ${t}`);this.code=e,this.event=o,Vt(this,new.target)}};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 Ym{_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 Jm(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(!Fm.has(s))Fm.add(s),console.warn(`[ext-apps] ${s}(Schema, handler) is deprecated; use ${s}("${i}", { params: Schema.shape.params }, handler).`);let a=r;return[i,{params:n.params},e==="request"?(l,u)=>a({method:i,params:l},Lb(u)):(l)=>a({method:i,params:l})]}function Lb(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 Ub="2026-01-26";var Zb="ui/notifications/tool-input-partial";class Qm{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=lo.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!==Zb)console.debug("Sending message",e);this.eventTarget.postMessage(e,"*")}async close(){window.removeEventListener("message",this.messageListener),this.onclose?.()}onclose;onerror;onmessage;sessionId;setProtocolVersion}var Db=M([p("light"),p("dark")]).describe("Color theme preference for the host environment."),ni=M([p("inline"),p("fullscreen"),p("pip")]).describe("Display mode for UI presentation."),Vb=M([p("--color-background-primary"),p("--color-background-secondary"),p("--color-background-tertiary"),p("--color-background-inverse"),p("--color-background-ghost"),p("--color-background-info"),p("--color-background-danger"),p("--color-background-success"),p("--color-background-warning"),p("--color-background-disabled"),p("--color-text-primary"),p("--color-text-secondary"),p("--color-text-tertiary"),p("--color-text-inverse"),p("--color-text-ghost"),p("--color-text-info"),p("--color-text-danger"),p("--color-text-success"),p("--color-text-warning"),p("--color-text-disabled"),p("--color-border-primary"),p("--color-border-secondary"),p("--color-border-tertiary"),p("--color-border-inverse"),p("--color-border-ghost"),p("--color-border-info"),p("--color-border-danger"),p("--color-border-success"),p("--color-border-warning"),p("--color-border-disabled"),p("--color-ring-primary"),p("--color-ring-secondary"),p("--color-ring-inverse"),p("--color-ring-info"),p("--color-ring-danger"),p("--color-ring-success"),p("--color-ring-warning"),p("--font-sans"),p("--font-mono"),p("--font-weight-normal"),p("--font-weight-medium"),p("--font-weight-semibold"),p("--font-weight-bold"),p("--font-text-xs-size"),p("--font-text-sm-size"),p("--font-text-md-size"),p("--font-text-lg-size"),p("--font-heading-xs-size"),p("--font-heading-sm-size"),p("--font-heading-md-size"),p("--font-heading-lg-size"),p("--font-heading-xl-size"),p("--font-heading-2xl-size"),p("--font-heading-3xl-size"),p("--font-text-xs-line-height"),p("--font-text-sm-line-height"),p("--font-text-md-line-height"),p("--font-text-lg-line-height"),p("--font-heading-xs-line-height"),p("--font-heading-sm-line-height"),p("--font-heading-md-line-height"),p("--font-heading-lg-line-height"),p("--font-heading-xl-line-height"),p("--font-heading-2xl-line-height"),p("--font-heading-3xl-line-height"),p("--border-radius-xs"),p("--border-radius-sm"),p("--border-radius-md"),p("--border-radius-lg"),p("--border-radius-xl"),p("--border-radius-full"),p("--border-width-regular"),p("--shadow-hairline"),p("--shadow-sm"),p("--shadow-md"),p("--shadow-lg")]).describe("CSS variable keys available to MCP apps for theming."),Hb=I(Vb.describe(`Style variables for theming MCP apps.
72
72
 
73
73
  Individual style keys are optional - hosts may provide any subset of these values.
74
74
  Values are strings containing CSS values (colors, sizes, font stacks, etc.).
75
75
 
76
76
  Note: This type uses \`Record<K, string | undefined>\` rather than \`Partial<Record<K, string>>\`
77
- for compatibility with Zod schema generation. Both are functionally equivalent for validation.`),A([c(),Dc()]).describe(`Style variables for theming MCP apps.
77
+ for compatibility with Zod schema generation. Both are functionally equivalent for validation.`),M([c(),Dc()]).describe(`Style variables for theming MCP apps.
78
78
 
79
79
  Individual style keys are optional - hosts may provide any subset of these values.
80
80
  Values are strings containing CSS values (colors, sizes, font stacks, etc.).
@@ -86,10 +86,10 @@ Individual style keys are optional - hosts may provide any subset of these value
86
86
  Values are strings containing CSS values (colors, sizes, font stacks, etc.).
87
87
 
88
88
  Note: This type uses \`Record<K, string | undefined>\` rather than \`Partial<Record<K, string>>\`
89
- for compatibility with Zod schema generation. Both are functionally equivalent for validation.`),wR=d({method:p("ui/open-link"),params:d({url:c().describe("URL to open in the host's browser")})}),Fb=d({isError:M().optional().describe("True if the host failed to open the URL (e.g., due to security policy).")}).passthrough(),Jb=d({isError:M().optional().describe("True if the download failed (e.g., user cancelled or host denied).")}).passthrough(),Bb=d({isError:M().optional().describe("True if the host rejected or failed to deliver the message.")}).passthrough(),RR=d({method:p("ui/notifications/sandbox-proxy-ready"),params:d({})}),_l=d({connectDomains:S(c()).optional().describe(`Origins for network requests (fetch/XHR/WebSocket).
89
+ for compatibility with Zod schema generation. Both are functionally equivalent for validation.`),RR=d({method:p("ui/open-link"),params:d({url:c().describe("URL to open in the host's browser")})}),Fb=d({isError:O().optional().describe("True if the host failed to open the URL (e.g., due to security policy).")}).passthrough(),Jb=d({isError:O().optional().describe("True if the download failed (e.g., user cancelled or host denied).")}).passthrough(),Bb=d({isError:O().optional().describe("True if the host rejected or failed to deliver the message.")}).passthrough(),xR=d({method:p("ui/notifications/sandbox-proxy-ready"),params:d({})}),_l=d({connectDomains:S(c()).optional().describe(`Origins for network requests (fetch/XHR/WebSocket).
90
90
 
91
91
  - Maps to CSP \`connect-src\` directive
92
- - Empty or omitted → no network connections (secure default)`),resourceDomains:S(c()).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:S(c()).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:S(c()).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'`)")}),bl=d({camera:d({}).optional().describe("Request camera access.\n\nMaps to Permission Policy `camera` feature."),microphone:d({}).optional().describe("Request microphone access.\n\nMaps to Permission Policy `microphone` feature."),geolocation:d({}).optional().describe("Request geolocation access.\n\nMaps to Permission Policy `geolocation` feature."),clipboardWrite:d({}).optional().describe("Request clipboard write access.\n\nMaps to Permission Policy `clipboard-write` feature.")}),xR=d({method:p("ui/notifications/size-changed"),params:d({width:R().optional().describe("New width in pixels."),height:R().optional().describe("New height in pixels.")})}),Gb=d({method:p("ui/notifications/tool-input"),params:d({arguments:O(c(),V().describe("Complete tool call arguments as key-value pairs.")).optional().describe("Complete tool call arguments as key-value pairs.")})}),Wb=d({method:p("ui/notifications/tool-input-partial"),params:d({arguments:O(c(),V().describe("Partial tool call arguments (incomplete, may change).")).optional().describe("Partial tool call arguments (incomplete, may change).")})}),Kb=d({method:p("ui/notifications/tool-cancelled"),params:d({reason:c().optional().describe('Optional reason for the cancellation (e.g., "user action", "timeout").')})}),Yb=d({fonts:c().optional()}),Qb=d({variables:Hb.optional().describe("CSS variables for theming the app."),css:Yb.optional().describe("CSS blocks that apps can inject.")}),Xb=d({method:p("ui/resource-teardown"),params:d({})}),ey=O(c(),V()),Bm=d({text:d({}).optional().describe("Host supports text content blocks."),image:d({}).optional().describe("Host supports image content blocks."),audio:d({}).optional().describe("Host supports audio content blocks."),resource:d({}).optional().describe("Host supports resource content blocks."),resourceLink:d({}).optional().describe("Host supports resource link content blocks."),structuredContent:d({}).optional().describe("Host supports structured content.")}),ER=d({method:p("ui/notifications/request-teardown"),params:d({}).optional()}),ty=d({experimental:O(c(),O(c(),Ji()).describe("Experimental features keyed by identifier.")).optional().describe("Experimental features keyed by identifier."),openLinks:d({}).optional().describe("Host supports opening external URLs."),downloadFile:d({}).optional().describe("Host supports file downloads via ui/download-file."),serverTools:d({listChanged:M().optional().describe("Host supports tools/list_changed notifications.")}).optional().describe("Host can proxy tool calls to the MCP server."),serverResources:d({listChanged:M().optional().describe("Host supports resources/list_changed notifications.")}).optional().describe("Host can proxy resource reads to the MCP server."),logging:d({}).optional().describe("Host accepts log messages."),sandbox:d({permissions:bl.optional().describe("Permissions granted by the host (camera, microphone, geolocation)."),csp:_l.optional().describe("CSP domains approved by the host.")}).optional().describe("Sandbox configuration applied by the host."),updateModelContext:Bm.optional().describe("Host accepts context updates (ui/update-model-context) to be included in the model's context for future turns."),message:Bm.optional().describe("Host supports receiving content messages (ui/message) from the view."),sampling:d({tools:d({}).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.")}),oy=d({experimental:O(c(),O(c(),Ji()).describe("Experimental features keyed by identifier.")).optional().describe("Experimental features keyed by identifier."),tools:d({listChanged:M().optional().describe("App supports tools/list_changed notifications.")}).optional().describe("App exposes MCP-style tools that the host can call."),availableDisplayModes:S(ni).optional().describe("Display modes the app supports.")}),PR=d({method:p("ui/notifications/initialized"),params:d({}).optional()}),TR=d({csp:_l.optional().describe("Content Security Policy configuration for UI resources."),permissions:bl.optional().describe("Sandbox permissions requested by the UI resource."),domain:c().optional().describe(`Dedicated origin for view sandbox.
92
+ - Empty or omitted → no network connections (secure default)`),resourceDomains:S(c()).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:S(c()).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:S(c()).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'`)")}),bl=d({camera:d({}).optional().describe("Request camera access.\n\nMaps to Permission Policy `camera` feature."),microphone:d({}).optional().describe("Request microphone access.\n\nMaps to Permission Policy `microphone` feature."),geolocation:d({}).optional().describe("Request geolocation access.\n\nMaps to Permission Policy `geolocation` feature."),clipboardWrite:d({}).optional().describe("Request clipboard write access.\n\nMaps to Permission Policy `clipboard-write` feature.")}),ER=d({method:p("ui/notifications/size-changed"),params:d({width:w().optional().describe("New width in pixels."),height:w().optional().describe("New height in pixels.")})}),Gb=d({method:p("ui/notifications/tool-input"),params:d({arguments:I(c(),D().describe("Complete tool call arguments as key-value pairs.")).optional().describe("Complete tool call arguments as key-value pairs.")})}),Wb=d({method:p("ui/notifications/tool-input-partial"),params:d({arguments:I(c(),D().describe("Partial tool call arguments (incomplete, may change).")).optional().describe("Partial tool call arguments (incomplete, may change).")})}),Kb=d({method:p("ui/notifications/tool-cancelled"),params:d({reason:c().optional().describe('Optional reason for the cancellation (e.g., "user action", "timeout").')})}),Yb=d({fonts:c().optional()}),Qb=d({variables:Hb.optional().describe("CSS variables for theming the app."),css:Yb.optional().describe("CSS blocks that apps can inject.")}),Xb=d({method:p("ui/resource-teardown"),params:d({})}),ey=I(c(),D()),Bm=d({text:d({}).optional().describe("Host supports text content blocks."),image:d({}).optional().describe("Host supports image content blocks."),audio:d({}).optional().describe("Host supports audio content blocks."),resource:d({}).optional().describe("Host supports resource content blocks."),resourceLink:d({}).optional().describe("Host supports resource link content blocks."),structuredContent:d({}).optional().describe("Host supports structured content.")}),PR=d({method:p("ui/notifications/request-teardown"),params:d({}).optional()}),ty=d({experimental:I(c(),I(c(),Ji()).describe("Experimental features keyed by identifier.")).optional().describe("Experimental features keyed by identifier."),openLinks:d({}).optional().describe("Host supports opening external URLs."),downloadFile:d({}).optional().describe("Host supports file downloads via ui/download-file."),serverTools:d({listChanged:O().optional().describe("Host supports tools/list_changed notifications.")}).optional().describe("Host can proxy tool calls to the MCP server."),serverResources:d({listChanged:O().optional().describe("Host supports resources/list_changed notifications.")}).optional().describe("Host can proxy resource reads to the MCP server."),logging:d({}).optional().describe("Host accepts log messages."),sandbox:d({permissions:bl.optional().describe("Permissions granted by the host (camera, microphone, geolocation)."),csp:_l.optional().describe("CSP domains approved by the host.")}).optional().describe("Sandbox configuration applied by the host."),updateModelContext:Bm.optional().describe("Host accepts context updates (ui/update-model-context) to be included in the model's context for future turns."),message:Bm.optional().describe("Host supports receiving content messages (ui/message) from the view."),sampling:d({tools:d({}).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.")}),oy=d({experimental:I(c(),I(c(),Ji()).describe("Experimental features keyed by identifier.")).optional().describe("Experimental features keyed by identifier."),tools:d({listChanged:O().optional().describe("App supports tools/list_changed notifications.")}).optional().describe("App exposes MCP-style tools that the host can call."),availableDisplayModes:S(ni).optional().describe("Display modes the app supports.")}),TR=d({method:p("ui/notifications/initialized"),params:d({}).optional()}),kR=d({csp:_l.optional().describe("Content Security Policy configuration for UI resources."),permissions:bl.optional().describe("Sandbox permissions requested by the UI resource."),domain:c().optional().describe(`Dedicated origin for view sandbox.
93
93
 
94
94
  Useful when views need stable, dedicated origins for OAuth callbacks, CORS policies, or API key allowlists.
95
95
 
@@ -97,19 +97,19 @@ Useful when views need stable, dedicated origins for OAuth callbacks, CORS polic
97
97
  - Hash-based subdomains (e.g., \`{hash}.claudemcpcontent.com\`)
98
98
  - URL-derived subdomains (e.g., \`www-example-com.oaiusercontent.com\`)
99
99
 
100
- If omitted, host uses default sandbox origin (typically per-conversation).`),prefersBorder:M().optional().describe(`Visual boundary preference - true if view prefers a visible border.
100
+ If omitted, host uses default sandbox origin (typically per-conversation).`),prefersBorder:O().optional().describe(`Visual boundary preference - true if view prefers a visible border.
101
101
 
102
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.
103
103
 
104
104
  - \`true\`: request visible border + background
105
105
  - \`false\`: request no visible border + background
106
- - omitted: host decides border`)}),kR=d({method:p("ui/request-display-mode"),params:d({mode:ni.describe("The display mode being requested.")})}),ry=d({mode:ni.describe("The display mode that was actually set. May differ from requested if not supported.")}).passthrough(),ny=A([p("model"),p("app")]).describe("Tool visibility scope - who can access the tool."),$R=d({resourceUri:c().optional(),visibility:S(ny).optional().describe(`Who can access this tool. Default: ["model", "app"]
106
+ - omitted: host decides border`)}),$R=d({method:p("ui/request-display-mode"),params:d({mode:ni.describe("The display mode being requested.")})}),ry=d({mode:ni.describe("The display mode that was actually set. May differ from requested if not supported.")}).passthrough(),ny=M([p("model"),p("app")]).describe("Tool visibility scope - who can access the tool."),CR=d({resourceUri:c().optional(),visibility:S(ny).optional().describe(`Who can access this tool. Default: ["model", "app"]
107
107
  - "model": Tool visible to and callable by the agent
108
- - "app": Tool callable by the app from this server only`),csp:Vc().optional(),permissions:Vc().optional()}),CR=d({mimeTypes:S(c()).optional().describe('Array of supported MIME types for UI resources.\nMust include `"text/html;profile=mcp-app"` for MCP Apps support.')}),IR=d({method:p("ui/download-file"),params:d({contents:S(A([fo,go])).describe("Resource contents to download — embedded (inline data) or linked (host fetches). Uses standard MCP resource types.")})}),OR=d({method:p("ui/message"),params:d({role:p("user").describe('Message role, currently only "user" is supported.'),content:S(gt).describe("Message content blocks (text, image, etc.).")})}),MR=d({method:p("ui/notifications/sandbox-resource-ready"),params:d({html:c().describe("HTML content to load into the inner iframe."),sandbox:c().optional().describe("Optional override for the inner iframe's sandbox attribute."),csp:_l.optional().describe("CSP configuration from resource metadata."),permissions:bl.optional().describe("Sandbox permissions from resource metadata.")})}),sy=d({method:p("ui/notifications/tool-result"),params:Zt.describe("Standard MCP tool execution result.")}),Xm=d({toolInfo:d({id:lt.optional().describe("JSON-RPC id of the tools/call request."),tool:Ut.describe("Tool definition including name, inputSchema, etc.")}).optional().describe("Metadata of the tool call that instantiated this App."),theme:Db.optional().describe("Current color theme preference."),styles:Qb.optional().describe("Style configuration for theming the app."),displayMode:ni.optional().describe("How the UI is currently displayed."),availableDisplayModes:S(ni).optional().describe("Display modes the host supports."),containerDimensions:A([d({height:R().describe("Fixed container height in pixels.")}),d({maxHeight:A([R(),Dc()]).optional().describe("Maximum container height in pixels.")})]).and(A([d({width:R().describe("Fixed container width in pixels.")}),d({maxWidth:A([R(),Dc()]).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:c().optional().describe("User's language and region preference in BCP 47 format."),timeZone:c().optional().describe("User's timezone in IANA format."),userAgent:c().optional().describe("Host application identifier."),platform:A([p("web"),p("desktop"),p("mobile")]).optional().describe("Platform type for responsive design decisions."),deviceCapabilities:d({touch:M().optional().describe("Whether the device supports touch input."),hover:M().optional().describe("Whether the device supports hover interactions.")}).optional().describe("Device input capabilities."),safeAreaInsets:d({top:R().describe("Top safe area inset in pixels."),right:R().describe("Right safe area inset in pixels."),bottom:R().describe("Bottom safe area inset in pixels."),left:R().describe("Left safe area inset in pixels.")}).optional().describe("Mobile safe area boundaries in pixels.")}).passthrough(),iy=d({method:p("ui/notifications/host-context-changed"),params:Xm.describe("Partial context update containing only changed fields.")}),AR=d({method:p("ui/update-model-context"),params:d({content:S(gt).optional().describe("Context content blocks (text, image, etc.)."),structuredContent:O(c(),V().describe("Structured content for machine-readable context data.")).optional().describe("Structured content for machine-readable context data.")})}),NR=d({method:p("ui/initialize"),params:d({appInfo:mt.describe("App identification (name and version)."),appCapabilities:oy.describe("Features and capabilities this app provides."),protocolVersion:c().describe("Protocol version this app supports.")})}),ay=d({protocolVersion:c().describe('Negotiated protocol version string (e.g., "2025-11-21").'),hostInfo:mt.describe("Host application identification and version."),hostCapabilities:ty.describe("Features and capabilities provided by the host."),hostContext:Xm.describe("Rich context about the host environment.")}).passthrough(),cy={target:"draft-2020-12"};async function Gm(e,t){let o=e["~standard"];if(o.jsonSchema)return o.jsonSchema[t](cy);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 Wm(e,t,o=""){let r=await e["~standard"].validate(t);if(r.issues){let n=r.issues.map((i)=>{let s=i.path?.map((a)=>typeof a==="object"?a.key:a).join(".");return s?`${s}: ${i.message}`:i.message}).join("; ");throw Error(o+n)}return r.value}function ly(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 Ca extends oi{_appInfo;_appCapabilities;options;_hostCapabilities;_hostInfo;_hostContext;_registeredTools={};_initializedSent=!1;_registeredEvents=new Set;_events=new Km;_methods=new Ym;setRequestHandler=(...e)=>{let[t,...o]=Jm("request",e)??e;this._methods.claim(t,"setRequestHandler"),super.setRequestHandler.call(this,t,...o)};setNotificationHandler=(...e)=>{let[t,...o]=Jm("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:Gb,toolinputpartial:Wb,toolresult:sy,toolcancelled:Kb,hostcontextchanged:iy};static ONE_SHOT_EVENTS=new Set(["toolinput","toolinputpartial","toolresult","toolcancelled"]);_everHadListener=new Set;_assertHandlerTiming(e){if(!Ca.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)We({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=ly(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(a){Object.assign(this,a),n()},remove(){if(r._registeredTools[e]!==s)return;delete r._registeredTools[e],n()},handler:async(a,l)=>{if(!s.enabled)throw Error(`Tool ${e} is disabled`);let u;if(i){let m=s.inputSchema,h=m?await Wm(m,a??{},`Invalid input for tool ${e}: `):a??{};u=await o(h,l)}else u=await o(l);if(s.outputSchema&&!u.isError)u.structuredContent=await Wm(s.outputSchema,u.structuredContent,`Invalid output for tool ${e}: `);return u}};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 Gm(r.inputSchema,"input"):{type:"object",properties:{}}};if(r.outputSchema)n.outputSchema=await Gm(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:Xb.shape.params,result:ey},(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},Bb,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},jt,t)}openLink(e,t){return this._assertInitialized("openLink"),this.request({method:"ui/open-link",params:e},Fb,t)}sendOpenLink=this.openLink;downloadFile(e,t){return this._assertInitialized("downloadFile"),this.request({method:"ui/download-file",params:e},Jb,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},ry,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 a=Math.ceil(i.getBoundingClientRect().height);i.style.height=s;let l=Math.ceil(window.innerWidth);if(l!==t||a!==o)t=l,o=a,this.sendSizeChanged({width:l,height:a})})};r();let n=new ResizeObserver(r);return n.observe(document.documentElement),n.observe(document.body),()=>n.disconnect()}async connect(e=new Qm(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:Ub}},ay,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}}}function ef(){let e=new Map,t=new Set,o=!1,r;function n(s){let l={data:e.get(s)?.data??{},callbacks:[],listeners:new Map};return e.set(s,l),{data:l.data,accept(u,m){if(!u||typeof u==="function")l.callbacks.push({deps:[s],callback:(h)=>u?.(h[0])});else l.callbacks.push({deps:typeof u==="string"?[u]:u,callback:(h)=>m?.(typeof u==="string"?h[0]:h)})},acceptExports(u,m){l.callbacks.push({deps:[s],callback:(h)=>m?.(h[0])})},dispose(u){l.dispose=u},prune(u){l.prune=u},invalidate(){o=!0},decline(){o=!0},on(u,m){let h=l.listeners.get(u)??new Set;h.add(m),l.listeners.set(u,h)},off(u,m){l.listeners.get(u)?.delete(m)},send(){throw Error("Preview hot-update custom messages are not a public transport.")}}}async function i(s){for(let a of e.values())for(let l of a.listeners.get(s)??[])await l()}return{context:n,observe(s,a,l){let u=e.get(s);if(!u)return;let m=import(a).then((h)=>{u.exports=h,u.isComponent=l});t.add(m),m.then(()=>t.delete(m),(h)=>{t.delete(m),r=h})},async update(s,a,l,u){if(await Promise.all(t),r)throw r;let m=new Map([...s].filter(([,b])=>b.hot).map(([b,w])=>[w.hot.id,{uri:b,record:w}])),h=new Map([...a].filter(([,b])=>b.hot).map(([b,w])=>[w.hot.id,{uri:b,record:w}])),f=new Map,g=new Map;for(let[b,{record:w}]of m)for(let C of[...w.imports,...w.dynamicImports]){let x=s.get(C)?.hot?.id;if(!x)continue;let T=f.get(x)??new Set;T.add(b),f.set(x,T)}function _(b,w=new Set){if(w.has(b))return!1;let C=e.get(b);if(C?.callbacks.some((q)=>q.deps.includes(b))&&h.has(b))return g.set(b,C),!0;let x=f.get(b);if(!x?.size)return!1;let T=new Set([...w,b]);for(let q of x)if(!_(q,T))return!1;return!0}for(let[b,{record:w}]of m){let C=h.get(b)?.record;if(!C||w.hot.source!==C.hot.source){if(!_(b))return!1}}if(!g.size)return!0;o=!1,await i("vite:beforeUpdate");let z=[];for(let[b,w]of g){if(!u())return!1;await w.dispose?.(w.data),z.push([b,w,await l(h.get(b).uri)])}if(!u())return!1;for(let[,b,w]of z)if(b.isComponent){let C=b.exports,x=Object.keys(w).filter((T)=>T!=="__esModule");if(!C||x.length!==Object.keys(C).filter((T)=>T!=="__esModule").length||x.some((T)=>!Object.hasOwn(C,T)||!b.isComponent(w[T])&&C[T]!==w[T]))return!1}for(let[b,w,C]of z)for(let x of w.callbacks)if(x.deps.includes(b))await x.callback(x.deps.map((T)=>T===b?C:void 0));return await i("vite:afterUpdate"),await new Promise((b)=>setTimeout(b,20)),u()&&!o},async dispose(){for(let s of e.values())await s.dispose?.(s.data),await s.prune?.(s.data);e.clear(),t.clear(),r=void 0}}}function tf(e,t){let o=[],r=new Set;function n(i){if(r.has(i))return;r.add(i);let s=e.get(i);if(!s)throw Error(`Missing preview dependency metadata: ${i}`);for(let a of[...s.imports,...s.styles,...s.references])n(a);o.push(i)}return n(t),o}function of(e,t){if(!e||e.revision===t.revision)return[];let o=(r,n)=>{let i=new Map(Object.entries(r.assets));return JSON.stringify(tf(i,n.module).map((s)=>[s,i.get(s)]))};return t.scenarios.filter((r)=>{let n=e.scenarios.find((i)=>i.id===r.id);return!n||o(e,n)!==o(t,r)}).map((r)=>r.id)}class yl{constructor(e){this.read=e,this.records=new Map,this.bytes=new Map,this.urls=new Map,this.styles=new Map,this.styleReady=new Map,this.revisions=new Set,this.loadedModules=new Set,this.executed=new Map,this.moduleHistory=new Set,this.importing=Promise.resolve(),this.mounting=Promise.resolve(),this.refreshDirty=!1,this.generation=0,this.prefetchGeneration=0,this.closed=!1,this.hot=ef(),globalThis.__adsPreviewHot=this.hot,globalThis.__dsPreviewImport=(t)=>this.importModule(t)}register(e){if(e.schemaVersion!==1||!Array.isArray(e.scenarios)||!e.assets||typeof e.revision!=="string")throw Error("Unsupported preview manifest. Rebuild previews with the installed ADS version.");if(e.refresh&&(e.refresh.version!==1||typeof e.refresh.epoch!=="string"||!e.refresh.epoch||e.refresh.epoch.length>100))throw Error("Unsupported preview refresh protocol. Reopen with the current ADS version.");let t=new Set;for(let[o,r]of Object.entries(e.assets)){if(!/^ads:\/\/assets\/[a-f0-9]{64}\.[a-z0-9]+$/.test(o)||!/^sha256:[a-f0-9]{64}$/.test(r.digest)||r.hot&&(!e.refresh||r.kind!=="module"||typeof r.hot.id!=="string"||!r.hot.id||r.hot.id.length>4096||t.has(r.hot.id)||!/^[a-f0-9]{64}$/.test(r.hot.source))||!["imports","dynamicImports","styles","references"].every((n)=>Array.isArray(r[n])&&r[n].every((i)=>Object.hasOwn(e.assets,i))))throw Error("Invalid preview dependency graph.");if(r.hot)t.add(r.hot.id);if(this.records.has(o)&&this.records.get(o).digest!==r.digest)throw Object.assign(Error("An immutable preview resource changed its content. Rebuild previews with the current ADS version."),{code:"ADS_RESOURCE_IDENTITY",category:"build",resourceUri:o})}for(let[o,r]of Object.entries(e.assets))this.records.set(o,r)}async resource(e){if(!this.bytes.has(e)){let t=(async()=>{let o=this.records.get(e);if(!o)throw Error(`Unknown preview dependency: ${e}`);let r;try{r=await this.read(e)}catch(l){throw Object.assign(Error(`Preview resource read failed for ${e}: ${l.message}`,{cause:l}),{code:"ADS_RESOURCE_READ",category:"transport",resourceUri:e})}if(this.closed)throw Error("The preview App was closed.");let n=r.contents.find((l)=>l.uri===e);if(!n)throw Object.assign(Error(`Missing preview dependency: ${e}`),{code:"ADS_RESOURCE_CONTENT",category:"build",resourceUri:e});let i=typeof n.text==="string"?new TextEncoder().encode(n.text):Uint8Array.from(atob(n.blob),(l)=>l.charCodeAt(0)),s=await crypto.subtle.digest("SHA-256",i),a="sha256:"+[...new Uint8Array(s)].map((l)=>l.toString(16).padStart(2,"0")).join("");if(i.length!==o.size||a!==o.digest)throw Object.assign(Error("Preview resource integrity check failed. Rebuild and reopen the preview."),{code:"ADS_RESOURCE_INTEGRITY",category:"build",resourceUri:e});return i})();this.bytes.set(e,t),t.catch(()=>this.bytes.delete(e))}return this.bytes.get(e)}closure(e){return tf(this.records,e)}async prefetch(e,t){if(this.closed)return;this.register(e);let o=++this.prefetchGeneration,r=new Set,n=[],i=0;for(let u of t){let m=e.scenarios.find((g)=>g.id===u);if(!m)continue;let h=this.closure(m.module).filter((g)=>!this.bytes.has(g)&&!r.has(g)),f=h.reduce((g,_)=>g+this.records.get(_).size,0);if(i+f>16777216||r.size+h.length>256)continue;i+=f,n.push(u);for(let g of h)r.add(g)}let s=[...r],a=0,l=async()=>{while(!this.closed&&o===this.prefetchGeneration&&a<s.length)await this.resource(s[a++])};return await Promise.all(Array.from({length:Math.min(3,s.length)},l)),{scenarios:n,resources:s.length}}async materialize(e){let t=this.closure(e);await Promise.all(t.map((r)=>this.resource(r)));let o={};for(let r of t){if(this.closed)throw Error("The preview App was closed.");if(this.urls.has(r))continue;let n=this.records.get(r),i=await this.resource(r);if(n.kind==="module"||n.mimeType==="text/css"||n.mimeType==="text/javascript"){let a=new TextDecoder().decode(i);for(let l of n.references){let u=this.urls.get(l);if(!u)throw Error("Unsupported cyclic asset reference.");a=a.replaceAll(l,u)}i=a}let s=URL.createObjectURL(new Blob([i],{type:n.mimeType}));if(this.urls.set(r,s),n.kind==="module")o[r]=s}if(Object.keys(o).length){let r=document.createElement("script");r.type="importmap",r.textContent=JSON.stringify({imports:o}),document.head.append(r)}return t}async importModule(e){let t=this.importing.then(()=>this.materialize(e));this.importing=t.catch(()=>{});let o=await t;await this.attachStyles(o);try{let r=await import(e);this.loadedModules.add(e);for(let n of o){let i=this.records.get(n);if(i.hot)this.executed.set(i.hot.id,{uri:n,record:i}),this.moduleHistory.add(n)}return r}catch(r){throw Error(`Preview module import failed for ${e}: ${r.message}. Inspect the App resource bridge, browser network/CSP diagnostics and current build.`,{cause:r})}}async attachStyles(e){for(let t of e){if(this.records.get(t).mimeType!=="text/css")continue;if(this.styles.has(t)){await this.styleReady.get(t);continue}let r=document.createElement("link");r.rel="stylesheet",r.href=this.urls.get(t),this.styles.set(t,r);let n=new Promise((i,s)=>{r.onload=i,r.onerror=()=>s(Error("The host CSP blocked a preview stylesheet."))});this.styleReady.set(t,n),document.head.append(r);try{await n}catch(i){throw r.remove(),this.styles.delete(t),this.styleReady.delete(t),i}}}async refreshStyles(e,t){let o=[e],r=new Set,n=new Set;for(let i=0;i<o.length;i++){let s=o[i];if(r.has(s))continue;r.add(s);for(let a of await this.materialize(s)){n.add(a);for(let l of this.records.get(a).dynamicImports)if(this.loadedModules.has(l)||this.executed.has(this.records.get(l)?.hot?.id))o.push(l)}}if(await this.attachStyles([...n]),t!==this.generation||this.closed)return!1;for(let[i,s]of this.styles)if(!n.has(i))s.remove(),this.styles.delete(i),this.styleReady.delete(i);for(let i of n)if(this.styles.has(i))document.head.append(this.styles.get(i));return!0}async mount(e,t,o){let r=++this.generation,n=this.mounting.then(()=>r!==this.generation||this.closed?!1:this.mountRevision(e,t,o,r));return this.mounting=n.catch(()=>{}),n}async mountRevision(e,t,o,r){this.register(e);let n=e.scenarios.find((h)=>h.id===t);if(!n)throw Error("The selected scenario is no longer registered.");let i=JSON.stringify(this.closure(n.module).map((h)=>[h,this.records.get(h)])),s=new Map(this.closure(n.module).map((h)=>[h,this.records.get(h)])),a=(h)=>{throw Object.assign(Error(h),{code:"ADS_PREVIEW_REOPEN"})};if(this.refreshDirty)a("An interrupted module update requires a clean preview frame.");let l=[...this.urls.keys()].reduce((h,f)=>h+this.records.get(f).size,0);if(this.records.size>4096||l>67108864)a("Reopen the preview to release retained module revisions.");if(this.mounted&&this.mounted.refresh?.epoch!==e.refresh?.epoch)a("The preview compiler changed. Reopening an isolated frame for its new runtime.");if(e.refresh&&this.mounted){let h=new Map(Object.entries(e.assets)),f=new Map([...h].filter(([,z])=>z.hot).map(([z,b])=>[b.hot.id,{uri:z,record:b}]));for(let[z,{record:b}]of this.executed){let w=f.get(z);if(w&&w.record.hot.source!==b.hot.source&&this.moduleHistory.has(w.uri))a("Restoring a previous module revision requires a clean preview frame.")}let g=new Map([...this.executed.values()].map(({uri:z,record:b})=>[z,b]));this.refreshDirty=!0;let _=await this.hot.update(g,h,(z)=>this.importModule(z),()=>r===this.generation&&!this.closed);if(r!==this.generation||this.closed)return!1;if(!_)a("This edit changes a refresh boundary. Reopening the preview with fresh component state.");this.refreshDirty=!1;for(let z of this.executed.keys())if(f.has(z))this.executed.set(z,f.get(z));if(this.mounted.id===t){if(!await this.refreshStyles(n.module,r))return!1;return this.revisions.add(n.module),this.mounted={...this.mounted,signature:i,records:s,module:n.module},!0}}if(this.mounted?.id===t&&this.mounted.container===o&&this.mounted.signature===i)return this.refreshStyles(n.module,r);if(this.revisions.add(n.module),!e.refresh&&this.revisions.size>20)throw Object.assign(Error("Reopen the preview to release retained module revisions."),{code:"ADS_PREVIEW_REOPEN"});let u=await this.importModule(n.module);if(r!==this.generation)return!1;let m=this.unmount;if(this.unmount=void 0,this.mounted=void 0,await m?.(),r!==this.generation||this.closed)return!1;if(o.replaceChildren(),!await this.refreshStyles(n.module,r))return!1;if(typeof u.mount!=="function")throw Error("The compiled scenario has no mount adapter.");if(this.unmount=u.mount(o),typeof this.unmount!=="function")throw Error("The scenario mount adapter must return an unmount callback.");return this.mounted={id:t,container:o,signature:i,records:s,module:n.module,refresh:e.refresh},!0}async dispose(){if(this.closed)return;this.closed=!0,++this.generation,++this.prefetchGeneration,await this.mounting,await this.unmount?.(),await this.hot.dispose(),this.mounted=void 0;for(let e of this.styles.values())e.remove();for(let e of this.urls.values())URL.revokeObjectURL(e);if(this.styles.clear(),this.styleReady.clear(),this.urls.clear(),this.bytes.clear(),this.records.clear(),this.revisions.clear(),this.loadedModules.clear(),this.executed.clear(),this.moduleHistory.clear(),delete globalThis.__dsPreviewImport,globalThis.__adsPreviewHot===this.hot)delete globalThis.__adsPreviewHot}}var vl="ads-preview-guide-options",rf="ads-preview-guide-state",uy=["off","hover","always"],dy=["bounds","tracks","gaps","padding","margins","mini"],DR=Object.freeze({mode:"off",bounds:!0,tracks:!1,gaps:!1,padding:!0,margins:!0,mini:!1});function si(e){return{mode:uy.includes(e?.mode)?e.mode:e?.all===!0?"always":"off",...Object.fromEntries(dy.map((o)=>[o,e?.[o]===!0]))}}function nf(e){let{mode:t,...o}=si(e);return{all:t==="always",...o}}function sf(e){let{mode:t,...o}=si(e);return t!=="off"&&Object.values(o).some(Boolean)}function af(e,{onDetails:t=()=>{}}={}){let o=e.ownerDocument,r=o.defaultView,n=(te)=>parseFloat(te)||0,i,s,a="",l,u=!1,m=[],h="components",f,g={},_=new Set,z=new r.ResizeObserver(w),b=new r.MutationObserver(w);function w(){if(u&&!s)s=r.requestAnimationFrame(le)}function C(te){let ne=te.target,be=ne?.closest?.("[data-ads-source]"),ue=ne?.closest?.('button, summary, a[href], [role="button"]'),de=be&&e.contains(be)?ue&&e.contains(ue)?ue:ne:null;if(f!==de)f=de,w()}function x(){if(f)f=null,w()}function T(te){if(!e.contains(te.relatedTarget))x(te)}function q(te){let ne=te.closest("[data-ads-source]")?.dataset.adsSource;return m.filter((be)=>be.schemaVersion===1&&be.source===ne).flatMap((be)=>be.rules.filter((ue)=>{try{return te.matches(ue.selector)}catch{return!1}}).flatMap((ue)=>ue.declarations))}function B(){let te=[...e.querySelectorAll("[data-ads-source]")].filter((ne)=>{let be=ne.getBoundingClientRect();return be.width&&be.height});if(te.length)return te;return[...(e.querySelector(".ads-preview-root")??e).children].filter((ne)=>!["STYLE","SCRIPT","LINK","H1"].includes(ne.tagName))}let ee=()=>({width:o.documentElement.clientWidth,height:o.documentElement.clientHeight});function re(te){let{width:ne,height:be}=ee(),ue={left:0,top:0,right:ne,bottom:be};for(let de=te.parentElement;de;de=de.parentElement){let Ee=r.getComputedStyle(de),Pe=de.getBoundingClientRect(),Ae=de.offsetWidth?Pe.width/de.offsetWidth:1,W=de.offsetHeight?Pe.height/de.offsetHeight:1;if(/(auto|scroll|hidden|clip)/.test(Ee.overflowX))ue.left=Math.max(ue.left,Pe.left+de.clientLeft*Ae),ue.right=Math.min(ue.right,Pe.left+(de.clientLeft+de.clientWidth)*Ae);if(/(auto|scroll|hidden|clip)/.test(Ee.overflowY))ue.top=Math.max(ue.top,Pe.top+de.clientTop*W),ue.bottom=Math.min(ue.bottom,Pe.top+(de.clientTop+de.clientHeight)*W)}return ue}function le(){if(s=void 0,!u)return;let te=B();if(f&&!e.contains(f))f=null;let ne=g.all===!0?[...te]:f?[f]:[];if(g.all===!0)for(let W of te)for(let ie of W.querySelectorAll("*")){if(ie.closest("svg")||["STYLE","SCRIPT","LINK"].includes(ie.tagName)||ne.includes(ie))continue;let E=r.getComputedStyle(ie);if(/grid|flex/.test(E.display)||["paddingTop","paddingRight","paddingBottom","paddingLeft","marginTop","marginRight","marginBottom","marginLeft"].some((U)=>n(E[U])!==0))ne.push(ie)}if(f&&!ne.includes(f))ne.push(f);let be=ne.filter((W)=>g.mini===!0||/\/components\//.test(W.closest("[data-ads-source]")?.dataset.adsSource??"")||h==="components"||h==="tokens"),ue=new Set(be.filter((W)=>!be.some((ie)=>ie!==W&&ie.contains(W)))),de=[],Ee=new Set([e]),Pe=[];for(let W of ne){let ae=function(he,ce,y,X,N,I,j=!1){let k={bounds:"bounds",content:"bounds",column:"tracks",row:"tracks",gap:"gaps",gutter:"gaps",margin:"margins",padding:"padding","mini-unit":"mini"}[N];if(y<=0||X<=0||g[k]===!1)return;let P=o.createElement("div");return P.dataset.adsGuide=N,Object.assign(P.style,{position:"absolute",left:`${he}px`,top:`${ce}px`,width:`${y}px`,height:`${X}px`,boxSizing:"border-box",...j?{border:`1px solid ${I}`}:{background:I}}),ge.append(P),P},Xe=function(he,ce,y,X){let[N,I,j,k]=he.map((Be,rt)=>Math.max(0,Be)*(rt%2?Q:G)),P=ce?E.left-k:E.left+fe[3]*Q,Z=ce?E.top-N:E.top+fe[0]*G,D=ce?E.width+k+I:E.width-(fe[1]+fe[3])*Q,Se=ce?E.height+N+j:E.height-(fe[0]+fe[2])*G;ae(P,Z,D,N,y,X),ae(P,Z+Se-j,D,j,y,X),ae(P,Z+N,k,Se-N-j,y,X),ae(P+D-I,Z+N,I,Se-N-j,y,X)},ie=r.getComputedStyle(W),E=W.getBoundingClientRect(),U=re(W);if(!E.width||!E.height||E.right<=U.left||E.left>=U.right||E.bottom<=U.top||E.top>=U.bottom)continue;Ee.add(W);let Q=W.offsetWidth?E.width/W.offsetWidth:1,G=W.offsetHeight?E.height/W.offsetHeight:1,$e=["Top","Right","Bottom","Left"],fe=$e.map((he)=>n(ie[`border${he}Width`])),ye=$e.map((he)=>n(ie[`padding${he}`])),je=$e.map((he)=>n(ie[`margin${he}`])),pe=E.left+(fe[3]+ye[3])*Q,ze=E.top+(fe[0]+ye[0])*G,Ne=E.width-(fe[1]+fe[3]+ye[1]+ye[3])*Q,Ze=E.height-(fe[0]+fe[2]+ye[0]+ye[2])*G,ge=o.createElement("div");if(ge.dataset.adsSpatialSource=W.dataset.adsSource??"measured-box",Object.assign(ge.style,{position:"fixed",inset:"0",clipPath:`inset(${U.top}px ${Math.max(0,ee().width-U.right)}px ${Math.max(0,ee().height-U.bottom)}px ${U.left}px)`}),ae(E.left,E.top,E.width,E.height,"bounds","rgb(70 120 250 / .75)",!0),ue.has(W)){let he=ie.getPropertyValue("--grid-mini-unit").trim(),ce=/^\d*\.?\d+px$/.test(he)?n(he):/^\d*\.?\d+rem$/.test(he)?n(he)*n(r.getComputedStyle(o.documentElement).fontSize):0;if(ce>0){let y=r.devicePixelRatio||1,X=Math.floor(E.left*y),N=Math.floor(E.top*y),I=Math.ceil(E.right*y)-X,j=Math.ceil(E.bottom*y)-N,k=ae(X/y,N/y,I/y,j/y,"mini-unit","transparent");if(k&&I>0&&j>0){k.dataset.adsUnit=`${ce}`,k.dataset.adsMajor=`${ce*2}`;let P=o.createElement("canvas");P.width=I,P.height=j,Object.assign(P.style,{display:"block",width:`${I/y}px`,height:`${j/y}px`,imageRendering:"pixelated"});let Z=P.getContext("2d");if(Z){let D=[ce*Q*y,ce*G*y];for(let Se=0;;Se++){let Be=Math.round(E.left*y+Se*D[0])-X;if(Be>=I)break;Z.fillStyle=Se%2?"#617dba14":"#617dba38",Z.fillRect(Be,0,1,j)}for(let Se=0;;Se++){let Be=Math.round(E.top*y+Se*D[1])-N;if(Be>=j)break;Z.fillStyle=Se%2?"#617dba14":"#617dba38",Z.fillRect(0,Be,I,1)}}k.append(P)}}}if(Xe(je,!0,"margin","rgb(234 149 43 / .2)"),h!=="composition"||f===W||g.padding===!0)Xe(ye,!1,"padding","rgb(55 186 130 / .22)");let st=q(W);if(ie.display.includes("grid")){let he=function(ce,y){let X=ce.replace(/\[[^\]]*\]/g,"").trim().split(/\s+/);if(!X.length||!X.every((P)=>/^\d*\.?\d+px$/.test(P)))return;let N=X.map(n),I=n(y==="columns"?ie.columnGap:ie.rowGap)*(y==="columns"?Q:G),j=y==="columns"&&ie.direction==="rtl",k=y==="columns"?j?pe+Ne:pe:ze;ge.dataset[y==="columns"?"adsGridColumns":"adsGridRows"]=String(N.length),N.forEach((P,Z)=>{let D=P*(y==="columns"?Q:G);if(j)k-=D;if(ae(y==="columns"?k:pe,y==="columns"?ze:k,y==="columns"?D:Ne,y==="columns"?Ze:D,y==="columns"?"column":"row","rgb(200 66 135 / .35)",!0),k+=j?0:D,Z<N.length-1)ae(y==="columns"?j?k-I:k:pe,y==="columns"?ze:k,y==="columns"?I:Ne,y==="columns"?Ze:I,"gap","rgb(200 66 135 / .12)");k+=j?-I:I})};if(he(ie.gridTemplateColumns,"columns"),st.some((ce)=>ce.property==="grid-template-rows"&&ce.value!=="none"))he(ie.gridTemplateRows,"rows");for(let ce of W.children){let y=r.getComputedStyle(ce),X=ce.getBoundingClientRect();if(y.display==="none"||!X.width||!X.height)continue;let N=n(y.marginLeft)*Q,I=n(y.marginRight)*Q;ae(X.left-N,X.top,N,X.height,"gutter","rgb(200 66 135 / .16)"),ae(X.right,X.top,I,X.height,"gutter","rgb(200 66 135 / .16)")}}if(ie.display.includes("flex")||h==="composition"){let he=[...W.children].filter((ce)=>{let y=ce.getBoundingClientRect();return y.width&&y.height});for(let ce of he){Ee.add(ce);let y=ce.getBoundingClientRect();ae(y.left,y.top,y.width,y.height,"content","rgb(70 120 250 / .5)",!0)}for(let ce=1;ce<he.length;ce++){let y=he[ce-1].getBoundingClientRect(),X=he[ce].getBoundingClientRect();if(X.top>=y.bottom)ae(Math.max(y.left,X.left),y.bottom,Math.min(y.right,X.right)-Math.max(y.left,X.left),X.top-y.bottom,"gap","rgb(200 66 135 / .16)");else if(X.left>=y.right)ae(y.right,Math.max(y.top,X.top),X.left-y.right,Math.min(y.bottom,X.bottom)-Math.max(y.top,X.top),"gap","rgb(200 66 135 / .16)");else if(y.left>=X.right)ae(X.right,Math.max(y.top,X.top),y.left-X.right,Math.min(y.bottom,X.bottom)-Math.max(y.top,X.top),"gap","rgb(200 66 135 / .16)")}}if(de.push(ge),f===W){let he=[...new Set(st.flatMap((ce)=>ce.value.match(/--[\w-]+/g)??[]))];Pe.push({label:W.getAttribute("aria-label")??W.getAttribute("role")??W.tagName.toLowerCase(),width:Math.round(E.width*10)/10,height:Math.round(E.height*10)/10,display:ie.display,padding:ye,margin:je,rowGap:ie.rowGap,columnGap:ie.columnGap,tokens:he})}}for(let W of _)if(!Ee.has(W))z.unobserve(W),_.delete(W);for(let W of Ee)if(!_.has(W))z.observe(W),_.add(W);let Ae=Pe[0];if(Ae){l=f;let W=JSON.stringify(Ae);if(W!==a)a=W,t(Ae)}else if(l&&!e.contains(l))ve();i.replaceChildren(...de)}function ve(){l=void 0,a="",t(null)}function se(te){if(u===te){w();return}if(u=te,te)i=o.createElement("div"),i.id="ads-grid-overlay",i.setAttribute("aria-hidden","true"),i.style.cssText="position:fixed;inset:0;z-index:2147483646;pointer-events:none;overflow:hidden",o.body.append(i),b.observe(e,{childList:!0,subtree:!0,attributes:!0,characterData:!0}),b.observe(o.documentElement,{attributes:!0}),e.addEventListener("pointermove",C,{passive:!0}),e.addEventListener("pointerleave",x),e.addEventListener("focusin",C),e.addEventListener("focusout",T),r.addEventListener("resize",w),o.addEventListener("scroll",w,!0),w();else r.cancelAnimationFrame(s),s=void 0,z.disconnect(),_.clear(),b.disconnect(),e.removeEventListener("pointermove",C),e.removeEventListener("pointerleave",x),e.removeEventListener("focusin",C),e.removeEventListener("focusout",T),r.removeEventListener("resize",w),o.removeEventListener("scroll",w,!0),i?.remove(),i=void 0,f=null,ve()}return{setVisible:se,setGuides(te){g=te??{},w()},setMetadata(te,ne){m=te,h=ne,f=null,ve(),w()},dispose(){se(!1)}}}function py(e){let t=e.map((o)=>({...o}));for(let o=!0;o;){o=!1;e:for(let r=0;r<t.length;r++)for(let n=r+1;n<t.length;n++){let i=t[r],s=t[n];if(i.left<=s.right&&s.left<=i.right&&i.top<=s.bottom&&s.top<=i.bottom){t[r]={left:Math.min(i.left,s.left),top:Math.min(i.top,s.top),right:Math.max(i.right,s.right),bottom:Math.max(i.bottom,s.bottom)},t.splice(n,1),o=!0;break e}}}return t}function cf(e,{decorate:t=!0}={}){let o=e.ownerDocument,r=o.defaultView,n=[],i=null,s=null,a=null,l=0,u=null,m=new r.ResizeObserver(()=>C()),h=new r.MutationObserver(()=>x()),f=()=>C();function g(T){let q=T.dataset.adsSource??"";return!q.includes(".ads.")&&n.some((B)=>q.startsWith(`${B}/`)||q.startsWith(`${B}.`))}function _(){if(u?.remove(),u=null,a)delete a.dataset.adsStaged,delete a.dataset.adsSubjectOnly}function z(T){if(T===a)return;if(a?.removeEventListener("scroll",f),m.disconnect(),_(),a=T,!a)return;a.addEventListener("scroll",f,{passive:!0}),m.observe(a)}function b(){z(e.querySelector(":scope > .ads-preview-root"));let T=!a?[]:i?[...a.querySelectorAll(i)]:n.length?[...a.querySelectorAll("[data-ads-source]")].filter(g):[],q=T.filter((re)=>!T.some((le)=>le!==re&&le.contains(re))),B=q.length===1?q[0].parentElement:null,ee=B&&(B===a||B.parentElement===a&&B.children.length===1)&&[...a.children].every((re)=>re===u||re===B||re===q[0]);return a?.toggleAttribute("data-ads-subject-only",Boolean(ee)),q}function w(){l=0;let T=b();if(!t||a?.hasAttribute("data-ads-subject-only")){if(u?.remove(),u=null,a)delete a.dataset.adsStaged;return}let q=(se)=>{let te=se.parentElement;if(!te||te===a||te.children.length!==1)return se;return[...te.childNodes].some((ne)=>ne.nodeType===3&&ne.textContent.trim())?te:se},B=py(T.map(q).flatMap((se)=>{m.observe(se);let te=se.getBoundingClientRect(),ne=s&&se.matches(s)?0:8;return te.width&&te.height?[{left:te.left-ne,top:te.top-ne,right:te.right+ne,bottom:te.bottom+ne}]:[]}));if(!B.length){_();return}let ee=a.getBoundingClientRect(),re={left:ee.left+a.clientLeft,top:ee.top+a.clientTop};if(re.right=re.left+a.clientWidth,re.bottom=re.top+a.clientHeight,!u||u.parentElement!==a)u?.remove(),u=o.createElement("div"),u.dataset.adsSubjectStage="",u.setAttribute("aria-hidden","true"),Object.assign(u.style,{position:"fixed",inset:"0",pointerEvents:"none",background:"var(--bg-canvas, Canvas)",zIndex:"-1"}),a.prepend(u);a.dataset.adsStaged="";let le=B.map((se)=>({left:Math.max(se.left,re.left),top:Math.max(se.top,re.top),right:Math.min(se.right,re.right),bottom:Math.min(se.bottom,re.bottom)})).filter((se)=>se.right>se.left&&se.bottom>se.top),ve=(se)=>`M${se.left} ${se.top}H${se.right}V${se.bottom}H${se.left}Z`;u.style.clipPath=le.length?`path("${le.map(ve).join("")}")`:"inset(50%)",u.dataset.adsStages=String(B.length)}function C(){if(!l)l=r.requestAnimationFrame(w)}function x(){b(),C()}return h.observe(e,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["class","hidden","open","data-ads-source"]}),r.addEventListener("resize",C),{setSubjects(T){n=[...T??[]],i=null,s=null,x()},setSubjectSelector(T,q=null){n=[],i=T||null,s=q,x()},refresh:x,dispose(){if(h.disconnect(),l)r.cancelAnimationFrame(l);r.removeEventListener("resize",C),z(null),_(),n=[],i=null,s=null}}}function lf(e){return Array.isArray(e)&&e.length>0&&e.every((t)=>t&&typeof t==="object"&&typeof t.token==="string"&&/^--[\w-]+$/.test(t.token)&&typeof t.property==="string"&&/^-?[a-z][a-z0-9-]*$/.test(t.property)&&typeof t.probe==="string"&&t.probe.trim().length>0)&&new Set(e.map((t)=>`${t.token}:${t.property}`)).size===e.length}function uf(e,t){let o=t.getComputedStyle(e),r=e.getBoundingClientRect();if(o.display==="none"||o.visibility!=="visible"||!e.getClientRects().length||!(r.width||r.height))return!1;for(let n=e;n;n=n.parentElement)if(Number(t.getComputedStyle(n).opacity)===0)return!1;return!0}function df(e,t){if(!lf(t))return{ok:!1,diagnostics:["Token preview needs explicit { token, property, probe } samples from the project fixture. Rebuild with the current compiler."]};let o=e.ownerDocument,{defaultView:r,documentElement:n}=o,i=[],s=[],a=[...e.querySelectorAll("[data-ads-token], [data-ads-property]")],l=new Set(t.map((u)=>`${u.token}:${u.property}`));for(let u of a)if(!l.has(`${u.dataset.adsToken}:${u.dataset.adsProperty}`))i.push(`Undeclared rendered token sample ${u.dataset.adsToken}:${u.dataset.adsProperty}.`);for(let u of t){if(!r.CSS.supports(u.property,u.probe)){i.push(`${u.token}: the fixture probe is invalid for ${u.property}.`);continue}let m=r.getComputedStyle(n).getPropertyValue(u.token).trim();if(!m||!r.CSS.supports(u.property,m)){i.push(`${u.token}: its current value is invalid for the fixture's ${u.property} binding.`);continue}let h=a.filter((g)=>g.dataset.adsToken===u.token&&g.dataset.adsProperty===u.property);if(!h.length){i.push(`${u.token} needs a rendered ${u.property} sample, not only a name/value label.`);continue}let f=!1;for(let g of h){let _=[];for(let w=g.parentElement;w&&w!==e;w=w.parentElement)if(w.tagName==="DETAILS"&&!w.open)w.open=!0,_.push(w);let z=n.getAttribute("style"),b=g.getAttribute("style");try{if(!/^(?:-[a-z]+-)?transition(?:-|$)/.test(u.property))g.style.setProperty("transition","none","important");let w=r.getComputedStyle(g).getPropertyValue(u.property),C=uf(g,r);n.style.setProperty(u.token,u.probe,"important");let x=r.getComputedStyle(g).getPropertyValue(u.property);f=Boolean(x&&x!==w&&(C||uf(g,r)))}finally{if(z===null)n.removeAttribute("style");else n.setAttribute("style",z);if(b===null)g.removeAttribute("style");else g.setAttribute("style",b);for(let w of _)w.open=!1}if(f)break}if(f)s.push(u);else i.push(`${u.token} has no visible ${u.property} sample that responds to its value. Hardcoded copies do not satisfy coverage.`)}return{ok:!i.length,verified:s,diagnostics:i}}function pf({container:e=document.getElementById("root"),bindings:t=[],auditResources:o=!1}={}){let r=[],n=[],i=[];if(!e||!Array.isArray(t)||t.length>100)return{ok:!1,diagnostics:["Invalid bounded paint-audit descriptor."],verified:n};let s=e.ownerDocument,a=s.defaultView,l=["color","fill","stroke","stop-color","background-color","border-top-color","border-right-color","border-bottom-color","border-left-color"];function u(h,f,g,_=new Set){if(h=h.trim(),["none","currentColor"].includes(h))return!0;let z=/^var\(\s*(--[\w-]+)\s*\)$/.exec(h);if(z){let C=z[1];if(!g.tokens.includes(C)||_.has(C))return!1;let x=a.getComputedStyle(f).getPropertyValue(C).trim();return!!x&&a.CSS.supports("color",x)}let b=Array.isArray(g.themes)?g.themes:[];if(b.length&&h.startsWith("var(--ads-if-")){let C=/^var\(\s*--ads-if-([a-z][a-z0-9-]*)\s*,\s*(var\(\s*--[\w-]+\s*\)|currentColor|none)\s*\)/,x=h,T=[];while(x){let q=C.exec(x);if(!q)return!1;T.push(q),x=x.slice(q[0].length).trimStart()}return T.length===b.length&&T.every((q,B)=>q[1]===b[B]&&u(q[2],f,g,_))}let w=/^url\(\s*(["']?)#([^\s"'()#\\\p{Cc}]+)\1\s*\)$/u.exec(h);if(w&&a.CSS.supports("fill",h)){let C=[...s.querySelectorAll("[id]")].filter((x)=>x.id===w[2]);return C.length===1&&["linearGradient","radialGradient","pattern"].includes(C[0].localName)&&f.contains(C[0])}return!1}for(let h of t){if(!h||typeof h.scope!=="string"||!Array.isArray(h.tokens)||typeof h.prefix!=="string"||typeof h.suffix!=="string"){r.push("Invalid paint binding metadata; rebuild previews.");continue}let f;try{f=[...e.querySelectorAll(h.scope)]}catch{r.push(`${h.owner}: invalid binding scope.`);continue}if(f.length>20)i.push(`${h.owner}: only the first 20 instances were audited; use a focused scenario for complete evidence.`);for(let g of f.slice(0,20)){let _=[g,...g.querySelectorAll("*")];if(_.length>1000){i.push(`${h.owner}: instance exceeds 1000 elements; paint effects are not established.`);continue}let z=[...g.style].filter((b)=>b.startsWith(h.prefix)&&b.endsWith(h.suffix));if(z.length>100)i.push(`${h.owner}: only the first 100 binding keys were audited.`);for(let b of z.slice(0,100)){let w=g.style.getPropertyValue(b).trim(),C=b.slice(h.prefix.length,h.suffix?-h.suffix.length:void 0);if(!/^[A-Za-z0-9_-]+$/.test(C)||!u(w,g,h)){r.push(`${h.owner}: invalid or inaccessible paint ${b}: ${w}. Use an accessible token, instance-local SVG paint server, none or currentColor.`);continue}let x=g.getAttribute("style"),T=_.map((q)=>q.getAttribute("style"));try{for(let ee of _)ee.style.setProperty("transition","none","important");let q=_.map((ee)=>l.map((re)=>a.getComputedStyle(ee).getPropertyValue(re)));g.style.setProperty(b,"rgb(17, 103, 211)","important");let B=_.some((ee,re)=>l.some((le,ve)=>a.getComputedStyle(ee).getPropertyValue(le)!==q[re][ve]));if(!B)g.style.setProperty(b,"rgb(211, 67, 23)","important"),B=_.some((ee,re)=>l.some((le,ve)=>a.getComputedStyle(ee).getPropertyValue(le)!==q[re][ve]));if(!B)i.push(`${h.owner}: ${b} has no observed paint effect in its current instance. A written variable alone is not rendering evidence; check the relevant selected/visible consumer.`);else n.push({owner:h.owner,binding:h.name,variable:b})}finally{if(_.forEach((q,B)=>{if(T[B]===null)q.removeAttribute("style");else q.setAttribute("style",T[B])}),x===null)g.removeAttribute("style");else g.setAttribute("style",x)}}for(let b of _)for(let w of["fill","stroke","stop-color"]){let C=b.getAttribute(w);if(!C)continue;let x=/^var\(\s*(--[\w-]+)\s*\)$/.exec(C);if(x&&x[1].startsWith(h.prefix)&&x[1].endsWith(h.suffix)&&!z.includes(x[1]))r.push(`${h.owner}: ${x[1]} is consumed without a value in this instance.`);if(C.startsWith("url(")&&!u(C,g,h))r.push(`${h.owner}: missing, duplicated or out-of-instance local paint resource ${C}.`)}}}let m=o?[...e.querySelectorAll("[fill], [stroke], [style]")]:[];if(m.length>1000)i.push("Only the first 1000 potential SVG paint consumers were audited.");for(let h of m.slice(0,1000))for(let f of["fill","stroke"]){let g=h.getAttribute(f)??h.style.getPropertyValue(f);if(!g?.startsWith("url("))continue;let _=/^url\(\s*(["']?)#([^\s"'()#\\\p{Cc}]+)\1\s*\)$/u.exec(g)?.[2],z=_?[...s.querySelectorAll("[id]")].filter((w)=>w.id===_):[],b=h.ownerSVGElement??(h.localName==="svg"?h:null);if(z.length!==1||!b?.contains(z[0])||!["linearGradient","radialGradient","pattern"].includes(z[0]?.localName))r.push(`Invalid, missing, duplicated or nonlocal SVG paint resource ${g}. Keep IDs isolated per rendered instance.`)}return{ok:!r.length,complete:!i.length,verified:n,diagnostics:r.slice(0,40),limits:i.slice(0,20),scope:"observed App instances and current input; repeat after updates"}}var hf=/^[a-f0-9]{64}$/,hy=/^ads:\/\/assets\/[a-f0-9]{64}\.[a-z0-9]+$/;function zl(e){if(e?.schemaVersion!==1||!["react","preact"].includes(e.framework)||!hf.test(e.revision)||!e.assets||typeof e.assets!=="object"||Array.isArray(e.assets)||!Array.isArray(e.scenarios))throw Error("Invalid preview manifest update.");let t=new Set;for(let o of e.scenarios){if(!o||typeof o.id!=="string"||t.has(o.id)||e.assets[o.module]?.kind!=="module")throw Error("Invalid updated preview scenarios.");t.add(o.id)}for(let[o,r]of Object.entries(e.assets))if(!hy.test(o)||!r||!["imports","dynamicImports","styles","references"].every((n)=>Array.isArray(r[n])&&r[n].every((i)=>Object.hasOwn(e.assets,i))))throw Error("Invalid updated preview dependencies.");return e}function mf(e,t){if(e?.version!==1)throw Error("Unsupported preview manifest update.");if(e.type==="full")return zl(e.manifest);if(!t||e.baseRevision!==t.revision)throw Error("Preview manifest update base does not match.");let o=e.header;if(!o||Object.hasOwn(o,"assets")||Object.hasOwn(o,"scenarios")||!hf.test(o.revision))throw Error("Invalid preview manifest update header.");if(e.type==="unchanged"){if(o.revision!==t.revision)throw Error("Unchanged preview revision does not match.");return zl({...o,assets:t.assets,scenarios:t.scenarios})}if(e.type!=="delta"||!e.assets?.upsert||!Array.isArray(e.assets.remove)||!Array.isArray(e.scenarios?.upsert)||!Array.isArray(e.scenarios.remove))throw Error("Invalid preview manifest delta.");let r=new Map(Object.entries(t.assets)),n=new Map(t.scenarios.map((a)=>[a.id,a]));for(let a of e.assets.remove)if(!r.delete(a))throw Error("Unknown removed preview asset.");for(let[a,l]of Object.entries(e.assets.upsert))r.set(a,l);for(let a of e.scenarios.remove)if(!n.delete(a))throw Error("Unknown removed preview scenario.");let i=new Set;for(let a of e.scenarios.upsert){if(!a||i.has(a.id))throw Error("Duplicate updated preview scenario.");i.add(a.id),n.set(a.id,a)}let s=e.scenarios.order??t.scenarios.map((a)=>a.id);if(!Array.isArray(s)||s.length!==n.size||new Set(s).size!==s.length||s.some((a)=>!n.has(a)))throw Error("Invalid updated preview scenario order.");return zl({...o,assets:Object.fromEntries(r),scenarios:s.map((a)=>n.get(a))})}function ff(e){let t=new Map,o=new Map,r=0,n,i=0,s=0,a=!0;function l(m){t.delete(m.revision),t.set(m.revision,{graph:m,size:new TextEncoder().encode(JSON.stringify(m)).byteLength});let h=[...t.values()].reduce((f,g)=>f+g.size,0);while(t.size>6||h>8388608){let f=t.keys().next().value;h-=t.get(f).size,t.delete(f)}}let u=(m)=>JSON.parse(m.contents.find((h)=>typeof h.text==="string").text);return{clear(){r++,t.clear(),o.clear(),n=void 0,a=!0},async get(m,{revision:h,session:f}={}){let g=h&&t.get(h)?.graph;if(g&&(!f||g.session===f))return{...g,transportManifestUri:m};let _=n,z=r,b=JSON.stringify([m,h,f,_?.revision]);if(!o.has(b)){let w=++i,C=(async()=>{let x;if(_&&a)try{x=await e(m+"?from="+_.revision)}catch(B){if(B.code!==-32002&&!/unknown (?:ADS )?resource|resource not found/i.test(B.message))throw B;if(z===r)a=!1;x=await e(m)}else x=await e(m);let T=u(x),q=mf(T.type?T:{version:1,type:"full",manifest:T},_);if(z===r){if(l(q),w>=s)n=q,s=w}return q})();o.set(b,C),C.then(()=>{if(o.get(b)===C)o.delete(b)},()=>{if(o.get(b)===C)o.delete(b)})}return{...await o.get(b),transportManifestUri:m}}}}async function gf(e,t=(o)=>new yl(o)){let o=document.getElementById("root"),r=document.getElementById("ads-preview-status"),n,i=async(E)=>{if(!e.getHostCapabilities()?.serverResources)throw Error("This host does not forward MCP resource reads. Open the same preview in the ADS showcase.");try{return await e.readServerResource({uri:n?n+encodeURIComponent(E):E},{timeout:15000})}catch(U){if(U.code===-32601||U.message==="Method not found")throw Error("This host does not forward MCP resource reads. Open the same preview in the ADS showcase.");throw U}},s=t(i),a=ff(i);document.documentElement.dataset.adsPreviewDelivery=e.delivery??"mcp-blob";let l,u,m,h,f,g=!1,_=0,z={},b=[],w="",C=!1,x,T,q=new Set;function B(E){if(e.getHostVersion()?.name!=="ADS showcase")return;let U=T;if(T=E,!U)return;let Q=of(U,E).filter((G)=>G!==l&&q.has(G));if(!Q.length)return;s.prefetch(E,Q).then((G)=>re("prefetched",{revision:E.revision,...G})).catch((G)=>console.warn("ADS preview prefetch",G.message))}function ee(E,U=!1){r.textContent=E,r.hidden=!E||e.getHostVersion()?.name==="ADS showcase",r.setAttribute("role",U?"alert":"status")}async function re(E,U={}){try{if(e.getHostCapabilities()?.logging)await e.sendLog({level:E==="error"?"error":"info",logger:"ads-preview",data:{state:E,id:l,...U}})}catch{}}let le=!1,ve=af(o),se=cf(o,{decorate:globalThis.__ADS_RENDER_AUDIT__!==!0}),te=".ads-token-sample:not(.ads-token-shadow):not(.ads-token-motion), .ads-token-stage-shadow, .ads-token-stage-motion, .ads-grid-example, .ads-foundation-ratios, .ads-brand-master, .ads-brand-art, .ads-brand-sizes img, .ads-pictogram-image";function ne(E){z={...z,...E,styles:{...z.styles,...E.styles}};let U=z.adsTheme??(["light","dark"].includes(z.theme)?(b.find((Q)=>Q.scheme===z.theme)??{name:z.theme}).name:void 0);if(U)document.documentElement.dataset.theme=U;if(typeof z.adsBrand==="string"&&/^[a-z][a-z0-9-]*$/.test(z.adsBrand))document.documentElement.dataset.brand=z.adsBrand;ve.setGuides(z.gridGuides),ve.setVisible(le&&z.gridOverlay===!0),be(),Pe()}function be(){document.dispatchEvent(new CustomEvent(rf,{detail:si(z.gridGuideChoices??z.gridGuides)}))}function ue(E){if(!E.detail){be();return}let U=si(E.detail);ne({gridGuideChoices:U,gridGuides:nf(U),gridOverlay:sf(U)}),re("guide-options",{options:U})}document.addEventListener(vl,ue);let de=(E)=>{if(typeof E.detail?.target==="string")re("navigate",{target:E.detail.target,token:E.detail.token})};document.addEventListener("ads-preview-navigate",de);let Ee;function Pe(){let E=z.adsFocus;if(!E||E.nonce===Ee||E.target!==l||document.documentElement.dataset.adsPreviewState!=="ready")return;Ee=E.nonce,document.dispatchEvent(new CustomEvent("ads-preview-focus",{detail:{token:E.token}}))}async function Ae(E="ads://preview/manifest",U,Q){try{return await a.get(E,{revision:U,session:Q})}catch(G){throw Object.assign(Error(G.message,{cause:G}),{code:"ADS_MANIFEST_READ",category:"transport"})}}async function W(E,U,Q=!1,G="",$e=!1,fe){let ye=Q||$e;if(!G&&E===l&&U&&U===m&&(!fe||fe===h)&&ye===C){ee(w||(ye?"Checking changes…":""),Boolean(w)),await re(w?"error":ye?"checking":"ready",w?{message:w}:{revision:m});return}let je=++_;++s.generation,l=E,le=!1,ve.setVisible(!1),q.add(E),document.documentElement.dataset.adsScenario=E,document.documentElement.dataset.adsPreviewState="loading";for(let pe of["adsPreviewErrorCategory","adsPreviewErrorCode","adsPreviewResourceUri"])delete document.documentElement.dataset[pe];w="",ee(""),await re(G?"reverting":"loading");try{let pe=performance.now(),ze=await Ae(Q?"ads://preview/live":"ads://preview/manifest",U,fe);if(je!==_)return;if(Array.isArray(ze.themes))b=ze.themes,ne({});if(U&&ze.revision!==U||fe&&ze.session!==fe){if(je===_)ee("Updating preview…"),await re("loading",{code:"ADS_PREVIEW_CHANGED"});return}if(je!==_)return;let Ne=performance.now();performance.measure("ads-preview:manifest",{start:pe,end:Ne});let Ze=await s.mount(ze,E,o);if(performance.measure("ads-preview:load-mount",{start:Ne,end:performance.now()}),!Ze||je!==_)return;let ge=ze.scenarios.find((ae)=>ae.id===E);if(o.dataset.adsScenarioKind=ge?.kind??"",ge?.foundation)se.setSubjectSelector(te,".ads-grid-example");else se.setSubjects(["components","patterns"].includes(ge?.kind)?ge.subjects:[]);if(m=ze.revision,h=ze.session,C=ye,await new Promise((ae)=>requestAnimationFrame(()=>requestAnimationFrame(ae))),await document.fonts.ready,je!==_)return;if(le=["components","patterns","composition"].includes(ge?.kind)||E==="tokens/Layout",ve.setMetadata(Object.values(ze.assets).flatMap((ae)=>ae.spatial?[ae.spatial]:[]),ge?.kind),ne({}),o.dataset.adsPaintBindings=JSON.stringify(ge?.paintBindings??[]),o.dataset.adsPaintAudit=String(Boolean(ge?.paintAudit)),o.dataset.adsPaintAuditComplete="not-requested",ge?.paintBindings?.length||ge?.paintAudit){let ae=pf({container:o,bindings:ge.paintBindings??[],auditResources:Boolean(ge.paintAudit)});if(!ae.ok)throw Object.assign(Error(`Paint binding verification failed:
110
- ${ae.diagnostics.join(`
111
- `)}`),{code:"ADS_PAINT_BINDING",category:"assertion"});if(o.dataset.adsPaintAuditComplete=String(ae.complete),!ae.complete)await re("audit-limited",{limits:ae.limits})}if(ge?.kind==="tokens"&&!ge.foundation){let ae=df(o,ge.samples);if(!ae.ok)throw w=`Token preview verification failed:
112
- ${ae.diagnostics.slice(0,20).join(`
113
- `)}`,Object.assign(Error(w),{code:"ADS_TOKEN_SAMPLE",category:"assertion"})}if(je===_){if(document.documentElement.dataset.adsPreviewRevision=m,document.documentElement.dataset.adsPreviewState=G?"error":ye?"checking":"ready",ee(G||(ye?"Checking changes…":""),Boolean(G)),await re(G?"error":ye?"checking":"ready",{revision:m,selectionRevision:u,...G?{message:G}:{}}),!ye&&!G)B(ze)}if(je===_)Pe()}catch(pe){if(je===_){if(document.documentElement.dataset.adsPreviewState="error",document.documentElement.dataset.adsPreviewErrorCategory=pe.category??"runner",document.documentElement.dataset.adsPreviewErrorCode=pe.code??"ADS_PREVIEW_STARTUP",pe.resourceUri)document.documentElement.dataset.adsPreviewResourceUri=pe.resourceUri;ee(pe.message,!0),await re("error",{message:pe.message,...pe.code?{code:pe.code}:{},...pe.category?{category:pe.category}:{},...pe.resourceUri?{resourceUri:pe.resourceUri}:{}})}}}async function ie(){if(!l||g||document.visibilityState==="hidden")return;g=!0;let E=_;try{let U=JSON.parse((await i("ads://project/build")).contents.find((G)=>typeof G.text==="string").text);if(E!==_)return;x=void 0;let Q=U.previews.find((G)=>G.id===l);if(Q?.live&&!Q.current)if(Q.live.revision!==m||U.session!==h||!C)await W(l,Q.live.revision,!0,"",!1,U.session);else ee(w||"Checking changes…",Boolean(w));else if(!Q||!Q.current){let G=Q?.diagnostics?.[0]?.message;if(G&&C){let $e=await Ae("ads://preview/manifest",U.manifestRevision,U.session);await W(l,$e.revision,!1,`Build failed. Showing the previous preview.
114
- ${G}`,!1,U.session)}ee(G?`Build failed. Showing the previous preview.
115
- ${G}`:"Rebuilding. This is the previous preview.",Boolean(G))}else{let G=await Ae("ads://preview/manifest",U.manifestRevision,U.session);if(E!==_)return;if(G.revision!==m||G.session!==h||C)await W(l,G.revision,!1,"",!1,U.session);else ee(w,Boolean(w)),B(G)}}catch(U){if(E!==_)return;let Q=`Preview freshness unavailable: ${U.message}`;if(ee(Q,!0),x!==Q)x=Q,await re("error",{message:Q})}finally{g=!1}}e.ontoolresult=(E)=>{let U=E.structuredContent?.draftScope;if(U!==n)++_,++s.generation,a.clear(),m=h=T=void 0,q.clear();n=U;let Q=E.structuredContent?.previewResult?.structuredContent??E.structuredContent;if(Q?.scenario?.id)u=Q.manifestRevision,W(Q.scenario.id,Q.manifestRevision,Q.manifestUri==="ads://preview/live","",Q.build?.current===!1,Q.build?.session)},e.onhostcontextchanged=ne,e.onteardown=async()=>(++_,a.clear(),document.removeEventListener(vl,ue),document.removeEventListener("ads-preview-navigate",de),ve.dispose(),se.dispose(),clearInterval(f),await s.dispose(),{});try{let E=performance.now();if(await e.connect(),performance.measure("ads-preview:connect",{start:E,end:performance.now()}),ne(e.getHostContext()??{}),!e.getHostCapabilities()?.serverResources)throw Error("This host does not forward MCP resource reads. Open the same preview in the ADS showcase.");f=setInterval(()=>{ie()},150);let U=document.getElementById("ads-preview-selection");if(U)W(JSON.parse(U.textContent).id)}catch(E){ee(E.message,!0)}window.addEventListener("pagehide",()=>{clearInterval(f),a.clear(),s.dispose()},{once:!0})}await gf(new Ca({name:"ADS resource preview",version:"1.0.0"},{},{autoResize:!0}));
108
+ - "app": Tool callable by the app from this server only`),csp:Vc().optional(),permissions:Vc().optional()}),IR=d({mimeTypes:S(c()).optional().describe('Array of supported MIME types for UI resources.\nMust include `"text/html;profile=mcp-app"` for MCP Apps support.')}),OR=d({method:p("ui/download-file"),params:d({contents:S(M([fo,go])).describe("Resource contents to download — embedded (inline data) or linked (host fetches). Uses standard MCP resource types.")})}),MR=d({method:p("ui/message"),params:d({role:p("user").describe('Message role, currently only "user" is supported.'),content:S(gt).describe("Message content blocks (text, image, etc.).")})}),AR=d({method:p("ui/notifications/sandbox-resource-ready"),params:d({html:c().describe("HTML content to load into the inner iframe."),sandbox:c().optional().describe("Optional override for the inner iframe's sandbox attribute."),csp:_l.optional().describe("CSP configuration from resource metadata."),permissions:bl.optional().describe("Sandbox permissions from resource metadata.")})}),sy=d({method:p("ui/notifications/tool-result"),params:Zt.describe("Standard MCP tool execution result.")}),Xm=d({toolInfo:d({id:lt.optional().describe("JSON-RPC id of the tools/call request."),tool:Ut.describe("Tool definition including name, inputSchema, etc.")}).optional().describe("Metadata of the tool call that instantiated this App."),theme:Db.optional().describe("Current color theme preference."),styles:Qb.optional().describe("Style configuration for theming the app."),displayMode:ni.optional().describe("How the UI is currently displayed."),availableDisplayModes:S(ni).optional().describe("Display modes the host supports."),containerDimensions:M([d({height:w().describe("Fixed container height in pixels.")}),d({maxHeight:M([w(),Dc()]).optional().describe("Maximum container height in pixels.")})]).and(M([d({width:w().describe("Fixed container width in pixels.")}),d({maxWidth:M([w(),Dc()]).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:c().optional().describe("User's language and region preference in BCP 47 format."),timeZone:c().optional().describe("User's timezone in IANA format."),userAgent:c().optional().describe("Host application identifier."),platform:M([p("web"),p("desktop"),p("mobile")]).optional().describe("Platform type for responsive design decisions."),deviceCapabilities:d({touch:O().optional().describe("Whether the device supports touch input."),hover:O().optional().describe("Whether the device supports hover interactions.")}).optional().describe("Device input capabilities."),safeAreaInsets:d({top:w().describe("Top safe area inset in pixels."),right:w().describe("Right safe area inset in pixels."),bottom:w().describe("Bottom safe area inset in pixels."),left:w().describe("Left safe area inset in pixels.")}).optional().describe("Mobile safe area boundaries in pixels.")}).passthrough(),iy=d({method:p("ui/notifications/host-context-changed"),params:Xm.describe("Partial context update containing only changed fields.")}),NR=d({method:p("ui/update-model-context"),params:d({content:S(gt).optional().describe("Context content blocks (text, image, etc.)."),structuredContent:I(c(),D().describe("Structured content for machine-readable context data.")).optional().describe("Structured content for machine-readable context data.")})}),qR=d({method:p("ui/initialize"),params:d({appInfo:mt.describe("App identification (name and version)."),appCapabilities:oy.describe("Features and capabilities this app provides."),protocolVersion:c().describe("Protocol version this app supports.")})}),ay=d({protocolVersion:c().describe('Negotiated protocol version string (e.g., "2025-11-21").'),hostInfo:mt.describe("Host application identification and version."),hostCapabilities:ty.describe("Features and capabilities provided by the host."),hostContext:Xm.describe("Rich context about the host environment.")}).passthrough(),cy={target:"draft-2020-12"};async function Gm(e,t){let o=e["~standard"];if(o.jsonSchema)return o.jsonSchema[t](cy);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 Wm(e,t,o=""){let r=await e["~standard"].validate(t);if(r.issues){let n=r.issues.map((i)=>{let s=i.path?.map((a)=>typeof a==="object"?a.key:a).join(".");return s?`${s}: ${i.message}`:i.message}).join("; ");throw Error(o+n)}return r.value}function ly(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 Ca extends oi{_appInfo;_appCapabilities;options;_hostCapabilities;_hostInfo;_hostContext;_registeredTools={};_initializedSent=!1;_registeredEvents=new Set;_events=new Km;_methods=new Ym;setRequestHandler=(...e)=>{let[t,...o]=Jm("request",e)??e;this._methods.claim(t,"setRequestHandler"),super.setRequestHandler.call(this,t,...o)};setNotificationHandler=(...e)=>{let[t,...o]=Jm("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:Gb,toolinputpartial:Wb,toolresult:sy,toolcancelled:Kb,hostcontextchanged:iy};static ONE_SHOT_EVENTS=new Set(["toolinput","toolinputpartial","toolresult","toolcancelled"]);_everHadListener=new Set;_assertHandlerTiming(e){if(!Ca.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)Ye({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=ly(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(a){Object.assign(this,a),n()},remove(){if(r._registeredTools[e]!==s)return;delete r._registeredTools[e],n()},handler:async(a,l)=>{if(!s.enabled)throw Error(`Tool ${e} is disabled`);let u;if(i){let m=s.inputSchema,h=m?await Wm(m,a??{},`Invalid input for tool ${e}: `):a??{};u=await o(h,l)}else u=await o(l);if(s.outputSchema&&!u.isError)u.structuredContent=await Wm(s.outputSchema,u.structuredContent,`Invalid output for tool ${e}: `);return u}};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 Gm(r.inputSchema,"input"):{type:"object",properties:{}}};if(r.outputSchema)n.outputSchema=await Gm(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:Xb.shape.params,result:ey},(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},Bb,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},jt,t)}openLink(e,t){return this._assertInitialized("openLink"),this.request({method:"ui/open-link",params:e},Fb,t)}sendOpenLink=this.openLink;downloadFile(e,t){return this._assertInitialized("downloadFile"),this.request({method:"ui/download-file",params:e},Jb,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},ry,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 a=Math.ceil(i.getBoundingClientRect().height);i.style.height=s;let l=Math.ceil(window.innerWidth);if(l!==t||a!==o)t=l,o=a,this.sendSizeChanged({width:l,height:a})})};r();let n=new ResizeObserver(r);return n.observe(document.documentElement),n.observe(document.body),()=>n.disconnect()}async connect(e=new Qm(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:Ub}},ay,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}}}function ef(){let e=new Map,t=new Set,o=!1,r;function n(s){let l={data:e.get(s)?.data??{},callbacks:[],listeners:new Map};return e.set(s,l),{data:l.data,accept(u,m){if(!u||typeof u==="function")l.callbacks.push({deps:[s],callback:(h)=>u?.(h[0])});else l.callbacks.push({deps:typeof u==="string"?[u]:u,callback:(h)=>m?.(typeof u==="string"?h[0]:h)})},acceptExports(u,m){l.callbacks.push({deps:[s],callback:(h)=>m?.(h[0])})},dispose(u){l.dispose=u},prune(u){l.prune=u},invalidate(){o=!0},decline(){o=!0},on(u,m){let h=l.listeners.get(u)??new Set;h.add(m),l.listeners.set(u,h)},off(u,m){l.listeners.get(u)?.delete(m)},send(){throw Error("Preview hot-update custom messages are not a public transport.")}}}async function i(s){for(let a of e.values())for(let l of a.listeners.get(s)??[])await l()}return{context:n,observe(s,a,l){let u=e.get(s);if(!u)return;let m=import(a).then((h)=>{u.exports=h,u.isComponent=l});t.add(m),m.then(()=>t.delete(m),(h)=>{t.delete(m),r=h})},async update(s,a,l,u){if(await Promise.all(t),r)throw r;let m=new Map([...s].filter(([,_])=>_.hot).map(([_,x])=>[x.hot.id,{uri:_,record:x}])),h=new Map([...a].filter(([,_])=>_.hot).map(([_,x])=>[x.hot.id,{uri:_,record:x}])),f=new Map,g=new Map;for(let[_,{record:x}]of m)for(let E of[...x.imports,...x.dynamicImports]){let R=s.get(E)?.hot?.id;if(!R)continue;let T=f.get(R)??new Set;T.add(_),f.set(R,T)}function y(_,x=new Set){if(x.has(_))return!1;let E=e.get(_);if(E?.callbacks.some((q)=>q.deps.includes(_))&&h.has(_))return g.set(_,E),!0;let R=f.get(_);if(!R?.size)return!1;let T=new Set([...x,_]);for(let q of R)if(!y(q,T))return!1;return!0}for(let[_,{record:x}]of m){let E=h.get(_)?.record;if(!E||x.hot.source!==E.hot.source){if(!y(_))return!1}}if(!g.size)return!0;o=!1,await i("vite:beforeUpdate");let z=[];for(let[_,x]of g){if(!u())return!1;await x.dispose?.(x.data),z.push([_,x,await l(h.get(_).uri)])}if(!u())return!1;for(let[,_,x]of z)if(_.isComponent){let E=_.exports,R=Object.keys(x).filter((T)=>T!=="__esModule");if(!E||R.length!==Object.keys(E).filter((T)=>T!=="__esModule").length||R.some((T)=>!Object.hasOwn(E,T)||!_.isComponent(x[T])&&E[T]!==x[T]))return!1}for(let[_,x,E]of z)for(let R of x.callbacks)if(R.deps.includes(_))await R.callback(R.deps.map((T)=>T===_?E:void 0));return await i("vite:afterUpdate"),await new Promise((_)=>setTimeout(_,20)),u()&&!o},async dispose(){for(let s of e.values())await s.dispose?.(s.data),await s.prune?.(s.data);e.clear(),t.clear(),r=void 0}}}async function uy(e,t){let o=await crypto.subtle.digest("SHA-256",t),r="sha256:"+[...new Uint8Array(o)].map((n)=>n.toString(16).padStart(2,"0")).join("");if(t.length!==e.size||r!==e.digest)throw Object.assign(Error("Preview resource integrity check failed. Rebuild and reopen the preview."),{code:"ADS_RESOURCE_INTEGRITY",category:"build"});return t}function tf(e,t){let o=[],r=new Set;function n(i){if(r.has(i))return;r.add(i);let s=e.get(i);if(!s)throw Error(`Missing preview dependency metadata: ${i}`);for(let a of[...s.imports,...s.styles,...s.references])n(a);o.push(i)}return n(t),o}function of(e,t){if(!e||e.revision===t.revision)return[];let o=(r,n)=>{let i=new Map(Object.entries(r.assets));return JSON.stringify(tf(i,n.module).map((s)=>[s,i.get(s)]))};return t.scenarios.filter((r)=>{let n=e.scenarios.find((i)=>i.id===r.id);return!n||o(e,n)!==o(t,r)}).map((r)=>r.id)}class yl{constructor(e){this.read=e,this.records=new Map,this.bytes=new Map,this.urls=new Map,this.styles=new Map,this.styleReady=new Map,this.revisions=new Set,this.loadedModules=new Set,this.executed=new Map,this.moduleHistory=new Set,this.importing=Promise.resolve(),this.mounting=Promise.resolve(),this.refreshDirty=!1,this.generation=0,this.prefetchGeneration=0,this.closed=!1,this.hot=ef(),globalThis.__adsPreviewHot=this.hot,globalThis.__dsPreviewImport=(t)=>this.importModule(t)}register(e){if(e.schemaVersion!==1||!Array.isArray(e.scenarios)||!e.assets||typeof e.revision!=="string")throw Error("Unsupported preview manifest. Rebuild previews with the installed ADS version.");if(e.refresh&&(e.refresh.version!==1||typeof e.refresh.epoch!=="string"||!e.refresh.epoch||e.refresh.epoch.length>100))throw Error("Unsupported preview refresh protocol. Reopen with the current ADS version.");let t=new Set;for(let[o,r]of Object.entries(e.assets)){if(!/^ads:\/\/assets\/[a-f0-9]{64}\.[a-z0-9]+$/.test(o)||!/^sha256:[a-f0-9]{64}$/.test(r.digest)||r.hot&&(!e.refresh||r.kind!=="module"||typeof r.hot.id!=="string"||!r.hot.id||r.hot.id.length>4096||t.has(r.hot.id)||!/^[a-f0-9]{64}$/.test(r.hot.source))||!["imports","dynamicImports","styles","references"].every((n)=>Array.isArray(r[n])&&r[n].every((i)=>Object.hasOwn(e.assets,i))))throw Error("Invalid preview dependency graph.");if(r.hot)t.add(r.hot.id);if(this.records.has(o)&&this.records.get(o).digest!==r.digest)throw Object.assign(Error("An immutable preview resource changed its content. Rebuild previews with the current ADS version."),{code:"ADS_RESOURCE_IDENTITY",category:"build",resourceUri:o})}for(let[o,r]of Object.entries(e.assets))this.records.set(o,r)}async resource(e){if(!this.bytes.has(e)){let t=(async()=>{let o=this.records.get(e);if(!o)throw Error(`Unknown preview dependency: ${e}`);let r;try{r=await this.read(e)}catch(s){throw Object.assign(Error(`Preview resource read failed for ${e}: ${s.message}`,{cause:s}),{code:"ADS_RESOURCE_READ",category:"transport",resourceUri:e})}if(this.closed)throw Error("The preview App was closed.");let n=r.contents.find((s)=>s.uri===e);if(!n)throw Object.assign(Error(`Missing preview dependency: ${e}`),{code:"ADS_RESOURCE_CONTENT",category:"build",resourceUri:e});let i=typeof n.text==="string"?new TextEncoder().encode(n.text):Uint8Array.from(atob(n.blob),(s)=>s.charCodeAt(0));try{return await uy(o,i)}catch(s){throw s.resourceUri=e,s}})();this.bytes.set(e,t),t.catch(()=>this.bytes.delete(e))}return this.bytes.get(e)}closure(e){return tf(this.records,e)}async prefetch(e,t){if(this.closed)return;this.register(e);let o=++this.prefetchGeneration,r=new Set,n=[],i=0;for(let u of t){let m=e.scenarios.find((g)=>g.id===u);if(!m)continue;let h=this.closure(m.module).filter((g)=>!this.bytes.has(g)&&!r.has(g)),f=h.reduce((g,y)=>g+this.records.get(y).size,0);if(i+f>16777216||r.size+h.length>256)continue;i+=f,n.push(u);for(let g of h)r.add(g)}let s=[...r],a=0,l=async()=>{while(!this.closed&&o===this.prefetchGeneration&&a<s.length)await this.resource(s[a++])};return await Promise.all(Array.from({length:Math.min(3,s.length)},l)),{scenarios:n,resources:s.length}}async materialize(e){let t=this.closure(e);await Promise.all(t.map((r)=>this.resource(r)));let o={};for(let r of t){if(this.closed)throw Error("The preview App was closed.");if(this.urls.has(r))continue;let n=this.records.get(r),i=await this.resource(r);if(n.kind==="module"||n.mimeType==="text/css"||n.mimeType==="text/javascript"){let a=new TextDecoder().decode(i);for(let l of n.references){let u=this.urls.get(l);if(!u)throw Error("Unsupported cyclic asset reference.");a=a.replaceAll(l,u)}i=a}let s=URL.createObjectURL(new Blob([i],{type:n.mimeType}));if(this.urls.set(r,s),n.kind==="module")o[r]=s}if(Object.keys(o).length){let r=document.createElement("script");r.type="importmap",r.textContent=JSON.stringify({imports:o}),document.head.append(r)}return t}async importModule(e){let t=this.importing.then(()=>this.materialize(e));this.importing=t.catch(()=>{});let o=await t;await this.attachStyles(o);try{let r=await import(e);this.loadedModules.add(e);for(let n of o){let i=this.records.get(n);if(i.hot)this.executed.set(i.hot.id,{uri:n,record:i}),this.moduleHistory.add(n)}return r}catch(r){throw Error(`Preview module import failed for ${e}: ${r.message}. Inspect the App resource bridge, browser network/CSP diagnostics and current build.`,{cause:r})}}async attachStyles(e){for(let t of e){if(this.records.get(t).mimeType!=="text/css")continue;if(this.styles.has(t)){await this.styleReady.get(t);continue}let r=document.createElement("link");r.rel="stylesheet",r.href=this.urls.get(t),this.styles.set(t,r);let n=new Promise((i,s)=>{r.onload=i,r.onerror=()=>s(Error("The host CSP blocked a preview stylesheet."))});this.styleReady.set(t,n),document.head.append(r);try{await n}catch(i){throw r.remove(),this.styles.delete(t),this.styleReady.delete(t),i}}}async refreshStyles(e,t){let o=[e],r=new Set,n=new Set;for(let i=0;i<o.length;i++){let s=o[i];if(r.has(s))continue;r.add(s);for(let a of await this.materialize(s)){n.add(a);for(let l of this.records.get(a).dynamicImports)if(this.loadedModules.has(l)||this.executed.has(this.records.get(l)?.hot?.id))o.push(l)}}if(await this.attachStyles([...n]),t!==this.generation||this.closed)return!1;for(let[i,s]of this.styles)if(!n.has(i))s.remove(),this.styles.delete(i),this.styleReady.delete(i);for(let i of n)if(this.styles.has(i))document.head.append(this.styles.get(i));return!0}async mount(e,t,o){let r=++this.generation,n=this.mounting.then(()=>r!==this.generation||this.closed?!1:this.mountRevision(e,t,o,r));return this.mounting=n.catch(()=>{}),n}async mountRevision(e,t,o,r){this.register(e);let n=e.scenarios.find((h)=>h.id===t);if(!n)throw Error("The selected scenario is no longer registered.");let i=JSON.stringify(this.closure(n.module).map((h)=>[h,this.records.get(h)])),s=new Map(this.closure(n.module).map((h)=>[h,this.records.get(h)])),a=(h)=>{throw Object.assign(Error(h),{code:"ADS_PREVIEW_REOPEN"})};if(this.refreshDirty)a("An interrupted module update requires a clean preview frame.");let l=[...this.urls.keys()].reduce((h,f)=>h+this.records.get(f).size,0);if(this.records.size>4096||l>67108864)a("Reopen the preview to release retained module revisions.");if(this.mounted&&this.mounted.refresh?.epoch!==e.refresh?.epoch)a("The preview compiler changed. Reopening an isolated frame for its new runtime.");if(e.refresh&&this.mounted){let h=new Map(Object.entries(e.assets)),f=new Map([...h].filter(([,z])=>z.hot).map(([z,_])=>[_.hot.id,{uri:z,record:_}]));for(let[z,{record:_}]of this.executed){let x=f.get(z);if(x&&x.record.hot.source!==_.hot.source&&this.moduleHistory.has(x.uri))a("Restoring a previous module revision requires a clean preview frame.")}let g=new Map([...this.executed.values()].map(({uri:z,record:_})=>[z,_]));this.refreshDirty=!0;let y=await this.hot.update(g,h,(z)=>this.importModule(z),()=>r===this.generation&&!this.closed);if(r!==this.generation||this.closed)return!1;if(!y)a("This edit changes a refresh boundary. Reopening the preview with fresh component state.");this.refreshDirty=!1;for(let z of this.executed.keys())if(f.has(z))this.executed.set(z,f.get(z));if(this.mounted.id===t){if(!await this.refreshStyles(n.module,r))return!1;return this.revisions.add(n.module),this.mounted={...this.mounted,signature:i,records:s,module:n.module},!0}}if(this.mounted?.id===t&&this.mounted.container===o&&this.mounted.signature===i)return this.refreshStyles(n.module,r);if(this.revisions.add(n.module),!e.refresh&&this.revisions.size>20)throw Object.assign(Error("Reopen the preview to release retained module revisions."),{code:"ADS_PREVIEW_REOPEN"});let u=await this.importModule(n.module);if(r!==this.generation)return!1;let m=this.unmount;if(this.unmount=void 0,this.mounted=void 0,await m?.(),r!==this.generation||this.closed)return!1;if(o.replaceChildren(),!await this.refreshStyles(n.module,r))return!1;if(typeof u.mount!=="function")throw Error("The compiled scenario has no mount adapter.");if(this.unmount=u.mount(o),typeof this.unmount!=="function")throw Error("The scenario mount adapter must return an unmount callback.");return this.mounted={id:t,container:o,signature:i,records:s,module:n.module,refresh:e.refresh},!0}async dispose(){if(this.closed)return;this.closed=!0,++this.generation,++this.prefetchGeneration,await this.mounting,await this.unmount?.(),await this.hot.dispose(),this.mounted=void 0;for(let e of this.styles.values())e.remove();for(let e of this.urls.values())URL.revokeObjectURL(e);if(this.styles.clear(),this.styleReady.clear(),this.urls.clear(),this.bytes.clear(),this.records.clear(),this.revisions.clear(),this.loadedModules.clear(),this.executed.clear(),this.moduleHistory.clear(),delete globalThis.__dsPreviewImport,globalThis.__adsPreviewHot===this.hot)delete globalThis.__adsPreviewHot}}var vl="ads-preview-guide-options",rf="ads-preview-guide-state",dy=["off","hover","always"],py=["bounds","tracks","gaps","padding","margins","mini"],VR=Object.freeze({mode:"off",bounds:!0,tracks:!1,gaps:!1,padding:!0,margins:!0,mini:!1});function si(e){return{mode:dy.includes(e?.mode)?e.mode:e?.all===!0?"always":"off",...Object.fromEntries(py.map((o)=>[o,e?.[o]===!0]))}}function nf(e){let{mode:t,...o}=si(e);return{all:t==="always",...o}}function sf(e){let{mode:t,...o}=si(e);return t!=="off"&&Object.values(o).some(Boolean)}function af(e,{onDetails:t=()=>{}}={}){let o=e.ownerDocument,r=o.defaultView,n=(ee)=>parseFloat(ee)||0,i,s,a="",l,u=!1,m=[],h="components",f,g={},y=new Set,z=new r.ResizeObserver(x),_=new r.MutationObserver(x);function x(){if(u&&!s)s=r.requestAnimationFrame(ie)}function E(ee){let le=ee.target,ge=le?.closest?.("[data-ads-source]"),de=le?.closest?.('button, summary, a[href], [role="button"]'),pe=ge&&e.contains(ge)?de&&e.contains(de)?de:le:null;if(f!==pe)f=pe,x()}function R(){if(f)f=null,x()}function T(ee){if(!e.contains(ee.relatedTarget))R(ee)}function q(ee){let le=ee.closest("[data-ads-source]")?.dataset.adsSource;return m.filter((ge)=>ge.schemaVersion===1&&ge.source===le).flatMap((ge)=>ge.rules.filter((de)=>{try{return ee.matches(de.selector)}catch{return!1}}).flatMap((de)=>de.declarations))}function J(){let ee=[...e.querySelectorAll("[data-ads-source]")].filter((le)=>{let ge=le.getBoundingClientRect();return ge.width&&ge.height});if(ee.length)return ee;return[...(e.querySelector(".ads-preview-root")??e).children].filter((le)=>!["STYLE","SCRIPT","LINK","H1"].includes(le.tagName))}let ae=()=>({width:o.documentElement.clientWidth,height:o.documentElement.clientHeight});function re(ee){let{width:le,height:ge}=ae(),de={left:0,top:0,right:le,bottom:ge};for(let pe=ee.parentElement;pe;pe=pe.parentElement){let ke=r.getComputedStyle(pe),$e=pe.getBoundingClientRect(),Ue=pe.offsetWidth?$e.width/pe.offsetWidth:1,W=pe.offsetHeight?$e.height/pe.offsetHeight:1;if(/(auto|scroll|hidden|clip)/.test(ke.overflowX))de.left=Math.max(de.left,$e.left+pe.clientLeft*Ue),de.right=Math.min(de.right,$e.left+(pe.clientLeft+pe.clientWidth)*Ue);if(/(auto|scroll|hidden|clip)/.test(ke.overflowY))de.top=Math.max(de.top,$e.top+pe.clientTop*W),de.bottom=Math.min(de.bottom,$e.top+(pe.clientTop+pe.clientHeight)*W)}return de}function ie(){if(s=void 0,!u)return;let ee=J();if(f&&!e.contains(f))f=null;let le=g.all===!0?[...ee]:f?[f]:[];if(g.all===!0)for(let W of ee)for(let ne of W.querySelectorAll("*")){if(ne.closest("svg")||["STYLE","SCRIPT","LINK"].includes(ne.tagName)||le.includes(ne))continue;let te=r.getComputedStyle(ne);if(/grid|flex/.test(te.display)||["paddingTop","paddingRight","paddingBottom","paddingLeft","marginTop","marginRight","marginBottom","marginLeft"].some((Oe)=>n(te[Oe])!==0))le.push(ne)}if(f&&!le.includes(f))le.push(f);let ge=le.filter((W)=>g.mini===!0||/\/components\//.test(W.closest("[data-ads-source]")?.dataset.adsSource??"")||h==="components"||h==="tokens"),de=new Set(ge.filter((W)=>!ge.some((ne)=>ne!==W&&ne.contains(W)))),pe=[],ke=new Set([e]),$e=[];for(let W of le){let ze=function(me,ce,b,X,N,C,j=!1){let k={bounds:"bounds",content:"bounds",column:"tracks",row:"tracks",gap:"gaps",gutter:"gaps",margin:"margins",padding:"padding","mini-unit":"mini"}[N];if(b<=0||X<=0||g[k]===!1)return;let P=o.createElement("div");return P.dataset.adsGuide=N,Object.assign(P.style,{position:"absolute",left:`${me}px`,top:`${ce}px`,width:`${b}px`,height:`${X}px`,boxSizing:"border-box",...j?{border:`1px solid ${C}`}:{background:C}}),je.append(P),P},be=function(me,ce,b,X){let[N,C,j,k]=me.map((We,nt)=>Math.max(0,We)*(nt%2?A:V)),P=ce?te.left-k:te.left+B[3]*A,U=ce?te.top-N:te.top+B[0]*V,Z=ce?te.width+k+C:te.width-(B[1]+B[3])*A,Se=ce?te.height+N+j:te.height-(B[0]+B[2])*V;ze(P,U,Z,N,b,X),ze(P,U+Se-j,Z,j,b,X),ze(P,U+N,k,Se-N-j,b,X),ze(P+Z-C,U+N,C,Se-N-j,b,X)},ne=r.getComputedStyle(W),te=W.getBoundingClientRect(),Oe=re(W);if(!te.width||!te.height||te.right<=Oe.left||te.left>=Oe.right||te.bottom<=Oe.top||te.top>=Oe.bottom)continue;ke.add(W);let A=W.offsetWidth?te.width/W.offsetWidth:1,V=W.offsetHeight?te.height/W.offsetHeight:1,Y=["Top","Right","Bottom","Left"],B=Y.map((me)=>n(ne[`border${me}Width`])),ue=Y.map((me)=>n(ne[`padding${me}`])),Ze=Y.map((me)=>n(ne[`margin${me}`])),ve=te.left+(B[3]+ue[3])*A,Pe=te.top+(B[0]+ue[0])*V,he=te.width-(B[1]+B[3]+ue[1]+ue[3])*A,Te=te.height-(B[0]+B[2]+ue[0]+ue[2])*V,je=o.createElement("div");if(je.dataset.adsSpatialSource=W.dataset.adsSource??"measured-box",Object.assign(je.style,{position:"fixed",inset:"0",clipPath:`inset(${Oe.top}px ${Math.max(0,ae().width-Oe.right)}px ${Math.max(0,ae().height-Oe.bottom)}px ${Oe.left}px)`}),ze(te.left,te.top,te.width,te.height,"bounds","rgb(70 120 250 / .75)",!0),de.has(W)){let me=ne.getPropertyValue("--grid-mini-unit").trim(),ce=/^\d*\.?\d+px$/.test(me)?n(me):/^\d*\.?\d+rem$/.test(me)?n(me)*n(r.getComputedStyle(o.documentElement).fontSize):0;if(ce>0){let b=r.devicePixelRatio||1,X=Math.floor(te.left*b),N=Math.floor(te.top*b),C=Math.ceil(te.right*b)-X,j=Math.ceil(te.bottom*b)-N,k=ze(X/b,N/b,C/b,j/b,"mini-unit","transparent");if(k&&C>0&&j>0){k.dataset.adsUnit=`${ce}`,k.dataset.adsMajor=`${ce*2}`;let P=o.createElement("canvas");P.width=C,P.height=j,Object.assign(P.style,{display:"block",width:`${C/b}px`,height:`${j/b}px`,imageRendering:"pixelated"});let U=P.getContext("2d");if(U){let Z=[ce*A*b,ce*V*b];for(let Se=0;;Se++){let We=Math.round(te.left*b+Se*Z[0])-X;if(We>=C)break;U.fillStyle=Se%2?"#617dba14":"#617dba38",U.fillRect(We,0,1,j)}for(let Se=0;;Se++){let We=Math.round(te.top*b+Se*Z[1])-N;if(We>=j)break;U.fillStyle=Se%2?"#617dba14":"#617dba38",U.fillRect(0,We,C,1)}}k.append(P)}}}if(be(Ze,!0,"margin","rgb(234 149 43 / .2)"),h!=="composition"||f===W||g.padding===!0)be(ue,!1,"padding","rgb(55 186 130 / .22)");let we=q(W);if(ne.display.includes("grid")){let me=function(ce,b){let X=ce.replace(/\[[^\]]*\]/g,"").trim().split(/\s+/);if(!X.length||!X.every((P)=>/^\d*\.?\d+px$/.test(P)))return;let N=X.map(n),C=n(b==="columns"?ne.columnGap:ne.rowGap)*(b==="columns"?A:V),j=b==="columns"&&ne.direction==="rtl",k=b==="columns"?j?ve+he:ve:Pe;je.dataset[b==="columns"?"adsGridColumns":"adsGridRows"]=String(N.length),N.forEach((P,U)=>{let Z=P*(b==="columns"?A:V);if(j)k-=Z;if(ze(b==="columns"?k:ve,b==="columns"?Pe:k,b==="columns"?Z:he,b==="columns"?Te:Z,b==="columns"?"column":"row","rgb(200 66 135 / .35)",!0),k+=j?0:Z,U<N.length-1)ze(b==="columns"?j?k-C:k:ve,b==="columns"?Pe:k,b==="columns"?C:he,b==="columns"?Te:C,"gap","rgb(200 66 135 / .12)");k+=j?-C:C})};if(me(ne.gridTemplateColumns,"columns"),we.some((ce)=>ce.property==="grid-template-rows"&&ce.value!=="none"))me(ne.gridTemplateRows,"rows");for(let ce of W.children){let b=r.getComputedStyle(ce),X=ce.getBoundingClientRect();if(b.display==="none"||!X.width||!X.height)continue;let N=n(b.marginLeft)*A,C=n(b.marginRight)*A;ze(X.left-N,X.top,N,X.height,"gutter","rgb(200 66 135 / .16)"),ze(X.right,X.top,C,X.height,"gutter","rgb(200 66 135 / .16)")}}if(ne.display.includes("flex")||h==="composition"){let me=[...W.children].filter((ce)=>{let b=ce.getBoundingClientRect();return b.width&&b.height});for(let ce of me){ke.add(ce);let b=ce.getBoundingClientRect();ze(b.left,b.top,b.width,b.height,"content","rgb(70 120 250 / .5)",!0)}for(let ce=1;ce<me.length;ce++){let b=me[ce-1].getBoundingClientRect(),X=me[ce].getBoundingClientRect();if(X.top>=b.bottom)ze(Math.max(b.left,X.left),b.bottom,Math.min(b.right,X.right)-Math.max(b.left,X.left),X.top-b.bottom,"gap","rgb(200 66 135 / .16)");else if(X.left>=b.right)ze(b.right,Math.max(b.top,X.top),X.left-b.right,Math.min(b.bottom,X.bottom)-Math.max(b.top,X.top),"gap","rgb(200 66 135 / .16)");else if(b.left>=X.right)ze(X.right,Math.max(b.top,X.top),b.left-X.right,Math.min(b.bottom,X.bottom)-Math.max(b.top,X.top),"gap","rgb(200 66 135 / .16)")}}if(pe.push(je),f===W){let me=[...new Set(we.flatMap((ce)=>ce.value.match(/--[\w-]+/g)??[]))];$e.push({label:W.getAttribute("aria-label")??W.getAttribute("role")??W.tagName.toLowerCase(),width:Math.round(te.width*10)/10,height:Math.round(te.height*10)/10,display:ne.display,padding:ue,margin:Ze,rowGap:ne.rowGap,columnGap:ne.columnGap,tokens:me})}}for(let W of y)if(!ke.has(W))z.unobserve(W),y.delete(W);for(let W of ke)if(!y.has(W))z.observe(W),y.add(W);let Ue=$e[0];if(Ue){l=f;let W=JSON.stringify(Ue);if(W!==a)a=W,t(Ue)}else if(l&&!e.contains(l))Ee();i.replaceChildren(...pe)}function Ee(){l=void 0,a="",t(null)}function se(ee){if(u===ee){x();return}if(u=ee,ee)i=o.createElement("div"),i.id="ads-grid-overlay",i.setAttribute("aria-hidden","true"),i.style.cssText="position:fixed;inset:0;z-index:2147483646;pointer-events:none;overflow:hidden",o.body.append(i),_.observe(e,{childList:!0,subtree:!0,attributes:!0,characterData:!0}),_.observe(o.documentElement,{attributes:!0}),e.addEventListener("pointermove",E,{passive:!0}),e.addEventListener("pointerleave",R),e.addEventListener("focusin",E),e.addEventListener("focusout",T),r.addEventListener("resize",x),o.addEventListener("scroll",x,!0),x();else r.cancelAnimationFrame(s),s=void 0,z.disconnect(),y.clear(),_.disconnect(),e.removeEventListener("pointermove",E),e.removeEventListener("pointerleave",R),e.removeEventListener("focusin",E),e.removeEventListener("focusout",T),r.removeEventListener("resize",x),o.removeEventListener("scroll",x,!0),i?.remove(),i=void 0,f=null,Ee()}return{setVisible:se,setGuides(ee){g=ee??{},x()},setMetadata(ee,le){m=ee,h=le,f=null,Ee(),x()},dispose(){se(!1)}}}function hy(e){let t=e.map((o)=>({...o}));for(let o=!0;o;){o=!1;e:for(let r=0;r<t.length;r++)for(let n=r+1;n<t.length;n++){let i=t[r],s=t[n];if(i.left<=s.right&&s.left<=i.right&&i.top<=s.bottom&&s.top<=i.bottom){t[r]={left:Math.min(i.left,s.left),top:Math.min(i.top,s.top),right:Math.max(i.right,s.right),bottom:Math.max(i.bottom,s.bottom)},t.splice(n,1),o=!0;break e}}}return t}function cf(e,{decorate:t=!0}={}){let o=e.ownerDocument,r=o.defaultView,n=[],i=null,s=null,a=null,l=0,u=null,m=new r.ResizeObserver(()=>E()),h=new r.MutationObserver(()=>R()),f=()=>E();function g(T){let q=T.dataset.adsSource??"";return!q.includes(".ads.")&&n.some((J)=>q.startsWith(`${J}/`)||q.startsWith(`${J}.`))}function y(){if(u?.remove(),u=null,a)delete a.dataset.adsStaged,delete a.dataset.adsSubjectOnly}function z(T){if(T===a)return;if(a?.removeEventListener("scroll",f),m.disconnect(),y(),a=T,!a)return;a.addEventListener("scroll",f,{passive:!0}),m.observe(a)}function _(){z(e.querySelector(":scope > .ads-preview-root"));let T=!a?[]:i?[...a.querySelectorAll(i)]:n.length?[...a.querySelectorAll("[data-ads-source]")].filter(g):[],q=T.filter((re)=>!T.some((ie)=>ie!==re&&ie.contains(re))),J=q.length===1?q[0].parentElement:null,ae=J&&(J===a||J.parentElement===a&&J.children.length===1)&&[...a.children].every((re)=>re===u||re===J||re===q[0]);return a?.toggleAttribute("data-ads-subject-only",Boolean(ae)),q}function x(){l=0;let T=_();if(!t||a?.hasAttribute("data-ads-subject-only")){if(u?.remove(),u=null,a)delete a.dataset.adsStaged;return}let q=(se)=>{let ee=se.parentElement;if(!ee||ee===a||ee.children.length!==1)return se;return[...ee.childNodes].some((le)=>le.nodeType===3&&le.textContent.trim())?ee:se},J=hy(T.map(q).flatMap((se)=>{m.observe(se);let ee=se.getBoundingClientRect(),le=s&&se.matches(s)?0:8;return ee.width&&ee.height?[{left:ee.left-le,top:ee.top-le,right:ee.right+le,bottom:ee.bottom+le}]:[]}));if(!J.length){y();return}let ae=a.getBoundingClientRect(),re={left:ae.left+a.clientLeft,top:ae.top+a.clientTop};if(re.right=re.left+a.clientWidth,re.bottom=re.top+a.clientHeight,!u||u.parentElement!==a)u?.remove(),u=o.createElement("div"),u.dataset.adsSubjectStage="",u.setAttribute("aria-hidden","true"),Object.assign(u.style,{position:"fixed",inset:"0",pointerEvents:"none",background:"var(--bg-canvas, Canvas)",zIndex:"-1"}),a.prepend(u);a.dataset.adsStaged="";let ie=J.map((se)=>({left:Math.max(se.left,re.left),top:Math.max(se.top,re.top),right:Math.min(se.right,re.right),bottom:Math.min(se.bottom,re.bottom)})).filter((se)=>se.right>se.left&&se.bottom>se.top),Ee=(se)=>`M${se.left} ${se.top}H${se.right}V${se.bottom}H${se.left}Z`;u.style.clipPath=ie.length?`path("${ie.map(Ee).join("")}")`:"inset(50%)",u.dataset.adsStages=String(J.length)}function E(){if(!l)l=r.requestAnimationFrame(x)}function R(){_(),E()}return h.observe(e,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["class","hidden","open","data-ads-source"]}),r.addEventListener("resize",E),{setSubjects(T){n=[...T??[]],i=null,s=null,R()},setSubjectSelector(T,q=null){n=[],i=T||null,s=q,R()},refresh:R,dispose(){if(h.disconnect(),l)r.cancelAnimationFrame(l);r.removeEventListener("resize",E),z(null),y(),n=[],i=null,s=null}}}function lf(e){return Array.isArray(e)&&e.length>0&&e.every((t)=>t&&typeof t==="object"&&typeof t.token==="string"&&/^--[\w-]+$/.test(t.token)&&typeof t.property==="string"&&/^-?[a-z][a-z0-9-]*$/.test(t.property)&&typeof t.probe==="string"&&t.probe.trim().length>0)&&new Set(e.map((t)=>`${t.token}:${t.property}`)).size===e.length}function uf(e,t){let o=t.getComputedStyle(e),r=e.getBoundingClientRect();if(o.display==="none"||o.visibility!=="visible"||!e.getClientRects().length||!(r.width||r.height))return!1;for(let n=e;n;n=n.parentElement)if(Number(t.getComputedStyle(n).opacity)===0)return!1;return!0}function df(e,t){if(!lf(t))return{ok:!1,diagnostics:["Token preview needs explicit { token, property, probe } samples from the project fixture. Rebuild with the current compiler."]};let o=e.ownerDocument,{defaultView:r,documentElement:n}=o,i=[],s=[],a=[...e.querySelectorAll("[data-ads-token], [data-ads-property]")],l=new Set(t.map((u)=>`${u.token}:${u.property}`));for(let u of a)if(!l.has(`${u.dataset.adsToken}:${u.dataset.adsProperty}`))i.push(`Undeclared rendered token sample ${u.dataset.adsToken}:${u.dataset.adsProperty}.`);for(let u of t){if(!r.CSS.supports(u.property,u.probe)){i.push(`${u.token}: the fixture probe is invalid for ${u.property}.`);continue}let m=r.getComputedStyle(n).getPropertyValue(u.token).trim();if(!m||!r.CSS.supports(u.property,m)){i.push(`${u.token}: its current value is invalid for the fixture's ${u.property} binding.`);continue}let h=a.filter((g)=>g.dataset.adsToken===u.token&&g.dataset.adsProperty===u.property);if(!h.length){i.push(`${u.token} needs a rendered ${u.property} sample, not only a name/value label.`);continue}let f=!1;for(let g of h){let y=[];for(let x=g.parentElement;x&&x!==e;x=x.parentElement)if(x.tagName==="DETAILS"&&!x.open)x.open=!0,y.push(x);let z=n.getAttribute("style"),_=g.getAttribute("style");try{if(!/^(?:-[a-z]+-)?transition(?:-|$)/.test(u.property))g.style.setProperty("transition","none","important");let x=r.getComputedStyle(g).getPropertyValue(u.property),E=uf(g,r);n.style.setProperty(u.token,u.probe,"important");let R=r.getComputedStyle(g).getPropertyValue(u.property);f=Boolean(R&&R!==x&&(E||uf(g,r)))}finally{if(z===null)n.removeAttribute("style");else n.setAttribute("style",z);if(_===null)g.removeAttribute("style");else g.setAttribute("style",_);for(let x of y)x.open=!1}if(f)break}if(f)s.push(u);else i.push(`${u.token} has no visible ${u.property} sample that responds to its value. Hardcoded copies do not satisfy coverage.`)}return{ok:!i.length,verified:s,diagnostics:i}}function pf({container:e=document.getElementById("root"),bindings:t=[],auditResources:o=!1}={}){let r=[],n=[],i=[];if(!e||!Array.isArray(t)||t.length>100)return{ok:!1,diagnostics:["Invalid bounded paint-audit descriptor."],verified:n};let s=e.ownerDocument,a=s.defaultView,l=["color","fill","stroke","stop-color","background-color","border-top-color","border-right-color","border-bottom-color","border-left-color"];function u(h,f,g,y=new Set){if(h=h.trim(),["none","currentColor"].includes(h))return!0;let z=/^var\(\s*(--[\w-]+)\s*\)$/.exec(h);if(z){let E=z[1];if(!g.tokens.includes(E)||y.has(E))return!1;let R=a.getComputedStyle(f).getPropertyValue(E).trim();return!!R&&a.CSS.supports("color",R)}let _=Array.isArray(g.themes)?g.themes:[];if(_.length&&h.startsWith("var(--ads-if-")){let E=/^var\(\s*--ads-if-([a-z][a-z0-9-]*)\s*,\s*(var\(\s*--[\w-]+\s*\)|currentColor|none)\s*\)/,R=h,T=[];while(R){let q=E.exec(R);if(!q)return!1;T.push(q),R=R.slice(q[0].length).trimStart()}return T.length===_.length&&T.every((q,J)=>q[1]===_[J]&&u(q[2],f,g,y))}let x=/^url\(\s*(["']?)#([^\s"'()#\\\p{Cc}]+)\1\s*\)$/u.exec(h);if(x&&a.CSS.supports("fill",h)){let E=[...s.querySelectorAll("[id]")].filter((R)=>R.id===x[2]);return E.length===1&&["linearGradient","radialGradient","pattern"].includes(E[0].localName)&&f.contains(E[0])}return!1}for(let h of t){if(!h||typeof h.scope!=="string"||!Array.isArray(h.tokens)||typeof h.prefix!=="string"||typeof h.suffix!=="string"){r.push("Invalid paint binding metadata; rebuild previews.");continue}let f;try{f=[...e.querySelectorAll(h.scope)]}catch{r.push(`${h.owner}: invalid binding scope.`);continue}if(f.length>20)i.push(`${h.owner}: only the first 20 instances were audited; use a focused scenario for complete evidence.`);for(let g of f.slice(0,20)){let y=[g,...g.querySelectorAll("*")];if(y.length>1000){i.push(`${h.owner}: instance exceeds 1000 elements; paint effects are not established.`);continue}let z=[...g.style].filter((_)=>_.startsWith(h.prefix)&&_.endsWith(h.suffix));if(z.length>100)i.push(`${h.owner}: only the first 100 binding keys were audited.`);for(let _ of z.slice(0,100)){let x=g.style.getPropertyValue(_).trim(),E=_.slice(h.prefix.length,h.suffix?-h.suffix.length:void 0);if(!/^[A-Za-z0-9_-]+$/.test(E)||!u(x,g,h)){r.push(`${h.owner}: invalid or inaccessible paint ${_}: ${x}. Use an accessible token, instance-local SVG paint server, none or currentColor.`);continue}let R=g.getAttribute("style"),T=y.map((q)=>q.getAttribute("style"));try{for(let ae of y)ae.style.setProperty("transition","none","important");let q=y.map((ae)=>l.map((re)=>a.getComputedStyle(ae).getPropertyValue(re)));g.style.setProperty(_,"rgb(17, 103, 211)","important");let J=y.some((ae,re)=>l.some((ie,Ee)=>a.getComputedStyle(ae).getPropertyValue(ie)!==q[re][Ee]));if(!J)g.style.setProperty(_,"rgb(211, 67, 23)","important"),J=y.some((ae,re)=>l.some((ie,Ee)=>a.getComputedStyle(ae).getPropertyValue(ie)!==q[re][Ee]));if(!J)i.push(`${h.owner}: ${_} has no observed paint effect in its current instance. A written variable alone is not rendering evidence; check the relevant selected/visible consumer.`);else n.push({owner:h.owner,binding:h.name,variable:_})}finally{if(y.forEach((q,J)=>{if(T[J]===null)q.removeAttribute("style");else q.setAttribute("style",T[J])}),R===null)g.removeAttribute("style");else g.setAttribute("style",R)}}for(let _ of y)for(let x of["fill","stroke","stop-color"]){let E=_.getAttribute(x);if(!E)continue;let R=/^var\(\s*(--[\w-]+)\s*\)$/.exec(E);if(R&&R[1].startsWith(h.prefix)&&R[1].endsWith(h.suffix)&&!z.includes(R[1]))r.push(`${h.owner}: ${R[1]} is consumed without a value in this instance.`);if(E.startsWith("url(")&&!u(E,g,h))r.push(`${h.owner}: missing, duplicated or out-of-instance local paint resource ${E}.`)}}}let m=o?[...e.querySelectorAll("[fill], [stroke], [style]")]:[];if(m.length>1000)i.push("Only the first 1000 potential SVG paint consumers were audited.");for(let h of m.slice(0,1000))for(let f of["fill","stroke"]){let g=h.getAttribute(f)??h.style.getPropertyValue(f);if(!g?.startsWith("url("))continue;let y=/^url\(\s*(["']?)#([^\s"'()#\\\p{Cc}]+)\1\s*\)$/u.exec(g)?.[2],z=y?[...s.querySelectorAll("[id]")].filter((x)=>x.id===y):[],_=h.ownerSVGElement??(h.localName==="svg"?h:null);if(z.length!==1||!_?.contains(z[0])||!["linearGradient","radialGradient","pattern"].includes(z[0]?.localName))r.push(`Invalid, missing, duplicated or nonlocal SVG paint resource ${g}. Keep IDs isolated per rendered instance.`)}return{ok:!r.length,complete:!i.length,verified:n,diagnostics:r.slice(0,40),limits:i.slice(0,20),scope:"observed App instances and current input; repeat after updates"}}var hf=/^[a-f0-9]{64}$/,my=/^ads:\/\/assets\/[a-f0-9]{64}\.[a-z0-9]+$/;function zl(e){if(e?.schemaVersion!==1||!["react","preact"].includes(e.framework)||!hf.test(e.revision)||!e.assets||typeof e.assets!=="object"||Array.isArray(e.assets)||!Array.isArray(e.scenarios))throw Error("Invalid preview manifest update.");let t=new Set;for(let o of e.scenarios){if(!o||typeof o.id!=="string"||t.has(o.id)||e.assets[o.module]?.kind!=="module")throw Error("Invalid updated preview scenarios.");t.add(o.id)}for(let[o,r]of Object.entries(e.assets))if(!my.test(o)||!r||!["imports","dynamicImports","styles","references"].every((n)=>Array.isArray(r[n])&&r[n].every((i)=>Object.hasOwn(e.assets,i))))throw Error("Invalid updated preview dependencies.");return e}function mf(e,t){if(e?.version!==1)throw Error("Unsupported preview manifest update.");if(e.type==="full")return zl(e.manifest);if(!t||e.baseRevision!==t.revision)throw Error("Preview manifest update base does not match.");let o=e.header;if(!o||Object.hasOwn(o,"assets")||Object.hasOwn(o,"scenarios")||!hf.test(o.revision))throw Error("Invalid preview manifest update header.");if(e.type==="unchanged"){if(o.revision!==t.revision)throw Error("Unchanged preview revision does not match.");return zl({...o,assets:t.assets,scenarios:t.scenarios})}if(e.type!=="delta"||!e.assets?.upsert||!Array.isArray(e.assets.remove)||!Array.isArray(e.scenarios?.upsert)||!Array.isArray(e.scenarios.remove))throw Error("Invalid preview manifest delta.");let r=new Map(Object.entries(t.assets)),n=new Map(t.scenarios.map((a)=>[a.id,a]));for(let a of e.assets.remove)if(!r.delete(a))throw Error("Unknown removed preview asset.");for(let[a,l]of Object.entries(e.assets.upsert))r.set(a,l);for(let a of e.scenarios.remove)if(!n.delete(a))throw Error("Unknown removed preview scenario.");let i=new Set;for(let a of e.scenarios.upsert){if(!a||i.has(a.id))throw Error("Duplicate updated preview scenario.");i.add(a.id),n.set(a.id,a)}let s=e.scenarios.order??t.scenarios.map((a)=>a.id);if(!Array.isArray(s)||s.length!==n.size||new Set(s).size!==s.length||s.some((a)=>!n.has(a)))throw Error("Invalid updated preview scenario order.");return zl({...o,assets:Object.fromEntries(r),scenarios:s.map((a)=>n.get(a))})}function ff(e){let t=new Map,o=new Map,r=0,n,i=0,s=0,a=!0;function l(m){t.delete(m.revision),t.set(m.revision,{graph:m,size:new TextEncoder().encode(JSON.stringify(m)).byteLength});let h=[...t.values()].reduce((f,g)=>f+g.size,0);while(t.size>6||h>8388608){let f=t.keys().next().value;h-=t.get(f).size,t.delete(f)}}let u=(m)=>JSON.parse(m.contents.find((h)=>typeof h.text==="string").text);return{clear(){r++,t.clear(),o.clear(),n=void 0,a=!0},async get(m,{revision:h,session:f}={}){let g=h&&t.get(h)?.graph;if(g&&(!f||g.session===f))return{...g,transportManifestUri:m};let y=n,z=r,_=JSON.stringify([m,h,f,y?.revision]);if(!o.has(_)){let x=++i,E=(async()=>{let R;if(y&&a)try{R=await e(m+"?from="+y.revision)}catch(J){if(J.code!==-32002&&!/unknown (?:ADS )?resource|resource not found/i.test(J.message))throw J;if(z===r)a=!1;R=await e(m)}else R=await e(m);let T=u(R),q=mf(T.type?T:{version:1,type:"full",manifest:T},y);if(z===r){if(l(q),x>=s)n=q,s=x}return q})();o.set(_,E),E.then(()=>{if(o.get(_)===E)o.delete(_)},()=>{if(o.get(_)===E)o.delete(_)})}return{...await o.get(_),transportManifestUri:m}}}}async function gf(e,t=(o)=>new yl(o)){let o=document.getElementById("root"),r=document.getElementById("ads-preview-status"),n,i=async(A)=>{if(!e.getHostCapabilities()?.serverResources)throw Error("This host does not forward MCP resource reads. Open the same preview in the ADS showcase.");try{return await e.readServerResource({uri:n?n+encodeURIComponent(A):A},{timeout:15000})}catch(V){if(V.code===-32601||V.message==="Method not found")throw Error("This host does not forward MCP resource reads. Open the same preview in the ADS showcase.");throw V}},s=t(i),a=ff(i);document.documentElement.dataset.adsPreviewDelivery=e.delivery??"mcp-blob";let l,u,m,h,f,g=!1,y,z=0,_={},x=[],E="",R=!1,T,q,J=new Set;function ae(A){if(e.getHostVersion()?.name!=="ADS showcase")return;let V=q;if(q=A,!V)return;let Y=of(V,A).filter((B)=>B!==l&&J.has(B));if(!Y.length)return;s.prefetch(A,Y).then((B)=>ie("prefetched",{revision:A.revision,...B})).catch((B)=>console.warn("ADS preview prefetch",B.message))}function re(A,V=!1){r.textContent=A,r.hidden=!A||e.getHostVersion()?.name==="ADS showcase",r.setAttribute("role",V?"alert":"status")}async function ie(A,V={}){try{if(e.getHostCapabilities()?.logging)await e.sendLog({level:A==="error"?"error":"info",logger:"ads-preview",data:{state:A,id:l,...V}})}catch{}}let Ee=!1,se=af(o),ee=cf(o,{decorate:globalThis.__ADS_RENDER_AUDIT__!==!0}),le=".ads-token-sample:not(.ads-token-shadow):not(.ads-token-motion), .ads-token-stage-shadow, .ads-token-stage-motion, .ads-grid-example, .ads-foundation-ratios, .ads-brand-master, .ads-brand-art, .ads-brand-sizes img, .ads-pictogram-image";function ge(A){_={..._,...A,styles:{..._.styles,...A.styles}};let V=_.adsTheme??(["light","dark"].includes(_.theme)?(x.find((Y)=>Y.scheme===_.theme)??{name:_.theme}).name:void 0);if(V)document.documentElement.dataset.theme=V;if(typeof _.adsBrand==="string"&&/^[a-z][a-z0-9-]*$/.test(_.adsBrand))document.documentElement.dataset.brand=_.adsBrand;se.setGuides(_.gridGuides),se.setVisible(Ee&&_.gridOverlay===!0),de(),Ue()}function de(){document.dispatchEvent(new CustomEvent(rf,{detail:si(_.gridGuideChoices??_.gridGuides)}))}function pe(A){if(!A.detail){de();return}let V=si(A.detail);ge({gridGuideChoices:V,gridGuides:nf(V),gridOverlay:sf(V)}),ie("guide-options",{options:V})}document.addEventListener(vl,pe);let ke=(A)=>{if(typeof A.detail?.target==="string")ie("navigate",{target:A.detail.target,token:A.detail.token})};document.addEventListener("ads-preview-navigate",ke);let $e;function Ue(){let A=_.adsFocus;if(!A||A.nonce===$e||A.target!==l||document.documentElement.dataset.adsPreviewState!=="ready")return;$e=A.nonce,document.dispatchEvent(new CustomEvent("ads-preview-focus",{detail:{token:A.token}}))}async function W(A="ads://preview/manifest",V,Y){try{return await(s.manifest?s.manifest(A,{revision:V,session:Y,scenario:l}):a.get(A,{revision:V,session:Y}))}catch(B){throw Object.assign(Error(B.message,{cause:B}),{code:"ADS_MANIFEST_READ",category:"transport"})}}async function ne(A,V,Y=!1,B="",ue=!1,Ze){let ve=Y||ue;if(!B&&A===l&&V&&V===m&&(!Ze||Ze===h)&&ve===R){re(E||(ve?"Checking changes…":""),Boolean(E)),await ie(E?"error":ve?"checking":"ready",E?{message:E}:{revision:m});return}let Pe=++z;++s.generation,l=A,Ee=!1,se.setVisible(!1),J.add(A),document.documentElement.dataset.adsScenario=A,document.documentElement.dataset.adsPreviewState="loading";for(let he of["adsPreviewErrorCategory","adsPreviewErrorCode","adsPreviewResourceUri"])delete document.documentElement.dataset[he];E="",re(""),await ie(B?"reverting":"loading");try{let he=performance.now(),Te=await W(Y?"ads://preview/live":"ads://preview/manifest",V,Ze);if(Pe!==z)return;if(Array.isArray(Te.themes))x=Te.themes,ge({});if(V&&Te.revision!==V||Ze&&Te.session!==Ze){if(Pe===z)re("Updating preview…"),await ie("loading",{code:"ADS_PREVIEW_CHANGED"});return}if(Pe!==z)return;let je=performance.now();performance.measure("ads-preview:manifest",{start:he,end:je});let ze=await s.mount(Te,A,o);if(performance.measure("ads-preview:load-mount",{start:je,end:performance.now()}),!ze||Pe!==z)return;let be=Te.scenarios.find((we)=>we.id===A);if(o.dataset.adsScenarioKind=be?.kind??"",be?.foundation)ee.setSubjectSelector(le,".ads-grid-example");else ee.setSubjects(["components","patterns"].includes(be?.kind)?be.subjects:[]);if(m=Te.revision,h=Te.session,R=ve,await new Promise((we)=>requestAnimationFrame(()=>requestAnimationFrame(we))),await document.fonts.ready,Pe!==z)return;if(Ee=["components","patterns","composition"].includes(be?.kind)||A==="tokens/Layout",se.setMetadata(Object.values(Te.assets).flatMap((we)=>we.spatial?[we.spatial]:[]),be?.kind),ge({}),o.dataset.adsPaintBindings=JSON.stringify(be?.paintBindings??[]),o.dataset.adsPaintAudit=String(Boolean(be?.paintAudit)),o.dataset.adsPaintAuditComplete="not-requested",be?.paintBindings?.length||be?.paintAudit){let we=pf({container:o,bindings:be.paintBindings??[],auditResources:Boolean(be.paintAudit)});if(!we.ok)throw Object.assign(Error(`Paint binding verification failed:
110
+ ${we.diagnostics.join(`
111
+ `)}`),{code:"ADS_PAINT_BINDING",category:"assertion"});if(o.dataset.adsPaintAuditComplete=String(we.complete),!we.complete)await ie("audit-limited",{limits:we.limits})}if(be?.kind==="tokens"&&!be.foundation){let we=df(o,be.samples);if(!we.ok)throw E=`Token preview verification failed:
112
+ ${we.diagnostics.slice(0,20).join(`
113
+ `)}`,Object.assign(Error(E),{code:"ADS_TOKEN_SAMPLE",category:"assertion"})}if(Pe===z){if(document.documentElement.dataset.adsPreviewRevision=m,document.documentElement.dataset.adsPreviewState=B?"error":ve?"checking":"ready",re(B||(ve?"Checking changes…":""),Boolean(B)),await ie(B?"error":ve?"checking":"ready",{revision:m,selectionRevision:u,...B?{message:B}:{}}),!ve&&!B)ae(Te)}if(Pe===z)Ue()}catch(he){if(Pe===z){if(document.documentElement.dataset.adsPreviewState="error",document.documentElement.dataset.adsPreviewErrorCategory=he.category??"runner",document.documentElement.dataset.adsPreviewErrorCode=he.code??"ADS_PREVIEW_STARTUP",he.resourceUri)document.documentElement.dataset.adsPreviewResourceUri=he.resourceUri;re(he.message,!0),await ie("error",{message:he.message,...he.code?{code:he.code}:{},...he.category?{category:he.category}:{},...he.resourceUri?{resourceUri:he.resourceUri}:{}})}}}async function te(A){if(!l)return;if(document.visibilityState==="hidden"){if(A)y=A;return}if(g){if(A)y=A;return}g=!0;let V=z;try{let Y=A??JSON.parse((await i("ads://project/build")).contents.find((ue)=>typeof ue.text==="string").text);if(V!==z)return;T=void 0;let B=Y.previews.find((ue)=>ue.id===l);if(B?.live&&!B.current)if(B.live.revision!==m||Y.session!==h||!R)await ne(l,B.live.revision,!0,"",!1,Y.session);else re(E||"Checking changes…",Boolean(E));else if(!B||!B.current){let ue=B?.diagnostics?.[0]?.message;if(ue&&R){let Ze=await W("ads://preview/manifest",Y.manifestRevision,Y.session);await ne(l,Ze.revision,!1,`Build failed. Showing the previous preview.
114
+ ${ue}`,!1,Y.session)}re(ue?`Build failed. Showing the previous preview.
115
+ ${ue}`:"Rebuilding. This is the previous preview.",Boolean(ue))}else{let ue=await W("ads://preview/manifest",Y.manifestRevision,Y.session);if(V!==z)return;if(ue.revision!==m||ue.session!==h||R)await ne(l,ue.revision,!1,"",!1,Y.session);else re(E,Boolean(E)),ae(ue)}}catch(Y){if(V!==z)return;let B=`Preview freshness unavailable: ${Y.message}`;if(re(B,!0),T!==B)T=B,await ie("error",{message:B})}finally{g=!1;let Y=y;if(y=void 0,Y)te(Y)}}e.onbuildreport=(A)=>{te(A)};let Oe=()=>{if(document.visibilityState!=="hidden")y=void 0,te()};document.addEventListener("visibilitychange",Oe),e.ontoolresult=(A)=>{let V=A.structuredContent?.draftScope;if(V!==n)++z,++s.generation,a.clear(),m=h=q=void 0,J.clear();n=V;let Y=A.structuredContent?.previewResult?.structuredContent??A.structuredContent;if(Y?.scenario?.id)u=Y.manifestRevision,ne(Y.scenario.id,Y.manifestRevision,Y.manifestUri==="ads://preview/live","",Y.build?.current===!1,Y.build?.session).then(()=>{if(e.buildPollInterval===0)te()})},e.onhostcontextchanged=ge,e.onteardown=async()=>(++z,l=y=void 0,e.onbuildreport=void 0,a.clear(),document.removeEventListener("visibilitychange",Oe),document.removeEventListener(vl,pe),document.removeEventListener("ads-preview-navigate",ke),se.dispose(),ee.dispose(),clearInterval(f),await s.dispose(),{});try{let A=performance.now();if(await e.connect(),performance.measure("ads-preview:connect",{start:A,end:performance.now()}),ge(e.getHostContext()??{}),!e.getHostCapabilities()?.serverResources)throw Error("This host does not forward MCP resource reads. Open the same preview in the ADS showcase.");let V=e.buildPollInterval??150;if(V>0)f=setInterval(()=>{te()},V);let Y=document.getElementById("ads-preview-selection");if(Y)ne(JSON.parse(Y.textContent).id)}catch(A){re(A.message,!0)}window.addEventListener("pagehide",()=>{l=y=void 0,e.onbuildreport=void 0,clearInterval(f),a.clear(),s.dispose()},{once:!0})}await gf(new Ca({name:"ADS resource preview",version:"1.0.0"},{},{autoResize:!0}));