@mcp-b/global 6.0.2 → 6.0.3

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.
@@ -61,7 +61,7 @@ var WebMCP=(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:`Modul
61
61
 
62
62
  `)}t.write(`payload.value = newResult;`),t.write(`return payload;`);let s=t.compile();return(t,n)=>s(e,t,n)},a,s=re,c=!o.jitless,l=c&&ie.value,d=t.catchall,f;e._zod.parse=(o,u)=>{f??=r.value;let p=o.value;return s(p)?c&&l&&u?.async===!1&&u.jitless!==!0?(a||=i(t.shape),o=a(o,u),d?bn([],p,o,u,f,e):o):n(o,u):(o.issues.push({expected:`object`,code:`invalid_type`,input:p,inst:e}),o)}});function Cn(e,t,n,r){for(let n of e)if(n.issues.length===0)return t.value=n.value,t;let i=e.filter(e=>!ye(e));return i.length===1?(t.value=i[0].value,i[0]):(t.issues.push({code:`invalid_union`,input:t.value,inst:n,errors:e.map(e=>e.issues.map(e=>b(e,r,s())))}),t)}let wn=r(`$ZodUnion`,(e,t)=>{T.init(e,t),h(e._zod,`optin`,()=>t.options.some(e=>e._zod.optin===`optional`)?`optional`:void 0),h(e._zod,`optout`,()=>t.options.some(e=>e._zod.optout===`optional`)?`optional`:void 0),h(e._zod,`values`,()=>{if(t.options.every(e=>e._zod.values))return new Set(t.options.flatMap(e=>Array.from(e._zod.values)))}),h(e._zod,`pattern`,()=>{if(t.options.every(e=>e._zod.pattern)){let e=t.options.map(e=>e._zod.pattern);return RegExp(`^(${e.map(e=>f(e.source)).join(`|`)})$`)}});let n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(r,i)=>{if(n)return n(r,i);let a=!1,o=[];for(let e of t.options){let t=e._zod.run({value:r.value,issues:[]},i);if(t instanceof Promise)o.push(t),a=!0;else{if(t.issues.length===0)return t;o.push(t)}}return a?Promise.all(o).then(t=>Cn(t,r,e,i)):Cn(o,r,e,i)}}),Tn=r(`$ZodDiscriminatedUnion`,(e,t)=>{t.inclusive=!1,wn.init(e,t);let n=e._zod.parse;h(e._zod,`propValues`,()=>{let e={};for(let n of t.options){let r=n._zod.propValues;if(!r||Object.keys(r).length===0)throw Error(`Invalid discriminated union option at index "${t.options.indexOf(n)}"`);for(let[t,n]of Object.entries(r)){e[t]||(e[t]=new Set);for(let r of n)e[t].add(r)}}return e});let r=u(()=>{let e=t.options,n=new Map;for(let r of e){let e=r._zod.propValues?.[t.discriminator];if(!e||e.size===0)throw Error(`Invalid discriminated union option at index "${t.options.indexOf(r)}"`);for(let t of e){if(n.has(t))throw Error(`Duplicate discriminator value "${String(t)}"`);n.set(t,r)}}return n});e._zod.parse=(i,a)=>{let o=i.value;if(!re(o))return i.issues.push({code:`invalid_type`,expected:`object`,input:o,inst:e}),i;let s=r.value.get(o?.[t.discriminator]);return s?s._zod.run(i,a):t.unionFallback||a.direction===`backward`?n(i,a):(i.issues.push({code:`invalid_union`,errors:[],note:`No matching discriminator`,discriminator:t.discriminator,options:Array.from(r.value.keys()),input:o,path:[t.discriminator],inst:e}),i)}}),En=r(`$ZodIntersection`,(e,t)=>{T.init(e,t),e._zod.parse=(e,n)=>{let r=e.value,i=t.left._zod.run({value:r,issues:[]},n),a=t.right._zod.run({value:r,issues:[]},n);return i instanceof Promise||a instanceof Promise?Promise.all([i,a]).then(([t,n])=>On(e,t,n)):On(e,i,a)}});function Dn(e,t){if(e===t||e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(ae(e)&&ae(t)){let n=Object.keys(t),r=Object.keys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};for(let n of r){let r=Dn(e[n],t[n]);if(!r.valid)return{valid:!1,mergeErrorPath:[n,...r.mergeErrorPath]};i[n]=r.data}return{valid:!0,data:i}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let n=[];for(let r=0;r<e.length;r++){let i=e[r],a=t[r],o=Dn(i,a);if(!o.valid)return{valid:!1,mergeErrorPath:[r,...o.mergeErrorPath]};n.push(o.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function On(e,t,n){let r=new Map,i;for(let n of t.issues)if(n.code===`unrecognized_keys`){i??=n;for(let e of n.keys)r.has(e)||r.set(e,{}),r.get(e).l=!0}else e.issues.push(n);for(let t of n.issues)if(t.code===`unrecognized_keys`)for(let e of t.keys)r.has(e)||r.set(e,{}),r.get(e).r=!0;else e.issues.push(t);let a=[...r].filter(([,e])=>e.l&&e.r).map(([e])=>e);if(a.length&&i&&e.issues.push({...i,keys:a}),ye(e))return e;let o=Dn(t.value,n.value);if(!o.valid)throw Error(`Unmergable intersection. Error path: ${JSON.stringify(o.mergeErrorPath)}`);return e.value=o.data,e}let kn=r(`$ZodRecord`,(e,t)=>{T.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!ae(i))return n.issues.push({expected:`record`,code:`invalid_type`,input:i,inst:e}),n;let a=[],o=t.keyType._zod.values;if(o){n.value={};let c=new Set;for(let l of o)if(typeof l==`string`||typeof l==`number`||typeof l==`symbol`){c.add(typeof l==`number`?l.toString():l);let o=t.keyType._zod.run({value:l,issues:[]},r);if(o instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(o.issues.length){n.issues.push({code:`invalid_key`,origin:`record`,issues:o.issues.map(e=>b(e,r,s())),input:l,path:[l],inst:e});continue}let u=o.value,d=t.valueType._zod.run({value:i[l],issues:[]},r);d instanceof Promise?a.push(d.then(e=>{e.issues.length&&n.issues.push(...xe(l,e.issues)),n.value[u]=e.value})):(d.issues.length&&n.issues.push(...xe(l,d.issues)),n.value[u]=d.value)}let l;for(let e in i)c.has(e)||(l??=[],l.push(e));l&&l.length>0&&n.issues.push({code:`unrecognized_keys`,input:i,inst:e,keys:l})}else{n.value={};for(let o of Reflect.ownKeys(i)){if(o===`__proto__`||!Object.prototype.propertyIsEnumerable.call(i,o))continue;let c=t.keyType._zod.run({value:o,issues:[]},r);if(c instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(typeof o==`string`&&ft.test(o)&&c.issues.length){let e=t.keyType._zod.run({value:Number(o),issues:[]},r);if(e instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);e.issues.length===0&&(c=e)}if(c.issues.length){t.mode===`loose`?n.value[o]=i[o]:n.issues.push({code:`invalid_key`,origin:`record`,issues:c.issues.map(e=>b(e,r,s())),input:o,path:[o],inst:e});continue}let l=t.valueType._zod.run({value:i[o],issues:[]},r);l instanceof Promise?a.push(l.then(e=>{e.issues.length&&n.issues.push(...xe(o,e.issues)),n.value[c.value]=e.value})):(l.issues.length&&n.issues.push(...xe(o,l.issues)),n.value[c.value]=l.value)}}return a.length?Promise.all(a).then(()=>n):n}}),An=r(`$ZodEnum`,(e,t)=>{T.init(e,t);let n=c(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=RegExp(`^(${n.filter(e=>se.has(typeof e)).map(e=>typeof e==`string`?ce(e):e.toString()).join(`|`)})$`),e._zod.parse=(t,i)=>{let a=t.value;return r.has(a)||t.issues.push({code:`invalid_value`,values:n,input:a,inst:e}),t}}),jn=r(`$ZodLiteral`,(e,t)=>{if(T.init(e,t),t.values.length===0)throw Error(`Cannot create literal schema with no valid values`);let n=new Set(t.values);e._zod.values=n,e._zod.pattern=RegExp(`^(${t.values.map(e=>typeof e==`string`?ce(e):e?ce(e.toString()):String(e)).join(`|`)})$`),e._zod.parse=(r,i)=>{let a=r.value;return n.has(a)||r.issues.push({code:`invalid_value`,values:t.values,input:a,inst:e}),r}}),Mn=r(`$ZodTransform`,(e,t)=>{T.init(e,t),e._zod.optin=`optional`,e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new a(e.constructor.name);let o=t.transform(n.value,n);if(r.async)return(o instanceof Promise?o:Promise.resolve(o)).then(e=>(n.value=e,n.fallback=!0,n));if(o instanceof Promise)throw new i;return n.value=o,n.fallback=!0,n}});function Nn(e,t){return t===void 0&&(e.issues.length||e.fallback)?{issues:[],value:void 0}:e}let Pn=r(`$ZodOptional`,(e,t)=>{T.init(e,t),e._zod.optin=`optional`,e._zod.optout=`optional`,h(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),h(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${f(e.source)})?$`):void 0}),e._zod.parse=(e,n)=>{if(t.innerType._zod.optin===`optional`){let r=e.value,i=t.innerType._zod.run(e,n);return i instanceof Promise?i.then(e=>Nn(e,r)):Nn(i,r)}return e.value===void 0?e:t.innerType._zod.run(e,n)}}),Fn=r(`$ZodExactOptional`,(e,t)=>{Pn.init(e,t),h(e._zod,`values`,()=>t.innerType._zod.values),h(e._zod,`pattern`,()=>t.innerType._zod.pattern),e._zod.parse=(e,n)=>t.innerType._zod.run(e,n)}),In=r(`$ZodNullable`,(e,t)=>{T.init(e,t),h(e._zod,`optin`,()=>t.innerType._zod.optin),h(e._zod,`optout`,()=>t.innerType._zod.optout),h(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${f(e.source)}|null)$`):void 0}),h(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(e,n)=>e.value===null?e:t.innerType._zod.run(e,n)}),Ln=r(`$ZodDefault`,(e,t)=>{T.init(e,t),e._zod.optin=`optional`,h(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);if(e.value===void 0)return e.value=t.defaultValue,e;let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(e=>Rn(e,t)):Rn(r,t)}});function Rn(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}let zn=r(`$ZodPrefault`,(e,t)=>{T.init(e,t),e._zod.optin=`optional`,h(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>(n.direction===`backward`||e.value===void 0&&(e.value=t.defaultValue),t.innerType._zod.run(e,n))}),Bn=r(`$ZodNonOptional`,(e,t)=>{T.init(e,t),h(e._zod,`values`,()=>{let e=t.innerType._zod.values;return e?new Set([...e].filter(e=>e!==void 0)):void 0}),e._zod.parse=(n,r)=>{let i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(t=>Vn(t,e)):Vn(i,e)}});function Vn(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:`invalid_type`,expected:`nonoptional`,input:e.value,inst:t}),e}let Hn=r(`$ZodCatch`,(e,t)=>{T.init(e,t),e._zod.optin=`optional`,h(e._zod,`optout`,()=>t.innerType._zod.optout),h(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(r=>(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>b(e,n,s()))},input:e.value}),e.issues=[],e.fallback=!0),e)):(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>b(e,n,s()))},input:e.value}),e.issues=[],e.fallback=!0),e)}}),Un=r(`$ZodPipe`,(e,t)=>{T.init(e,t),h(e._zod,`values`,()=>t.in._zod.values),h(e._zod,`optin`,()=>t.in._zod.optin),h(e._zod,`optout`,()=>t.out._zod.optout),h(e._zod,`propValues`,()=>t.in._zod.propValues),e._zod.parse=(e,n)=>{if(n.direction===`backward`){let r=t.out._zod.run(e,n);return r instanceof Promise?r.then(e=>Wn(e,t.in,n)):Wn(r,t.in,n)}let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>Wn(e,t.out,n)):Wn(r,t.out,n)}});function Wn(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues,fallback:e.fallback},n)}let Gn=r(`$ZodPreprocess`,(e,t)=>{Un.init(e,t)}),Kn=r(`$ZodReadonly`,(e,t)=>{T.init(e,t),h(e._zod,`propValues`,()=>t.innerType._zod.propValues),h(e._zod,`values`,()=>t.innerType._zod.values),h(e._zod,`optin`,()=>t.innerType?._zod?.optin),h(e._zod,`optout`,()=>t.innerType?._zod?.optout),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(qn):qn(r)}});function qn(e){return e.value=Object.freeze(e.value),e}let Jn=r(`$ZodLazy`,(e,t)=>{T.init(e,t),h(e._zod,`innerType`,()=>{let e=t;return e._cachedInner||=t.getter(),e._cachedInner}),h(e._zod,`pattern`,()=>e._zod.innerType?._zod?.pattern),h(e._zod,`propValues`,()=>e._zod.innerType?._zod?.propValues),h(e._zod,`optin`,()=>e._zod.innerType?._zod?.optin??void 0),h(e._zod,`optout`,()=>e._zod.innerType?._zod?.optout??void 0),e._zod.parse=(t,n)=>e._zod.innerType._zod.run(t,n)}),Yn=r(`$ZodCustom`,(e,t)=>{w.init(e,t),T.init(e,t),e._zod.parse=(e,t)=>e,e._zod.check=n=>{let r=n.value,i=t.fn(r);if(i instanceof Promise)return i.then(t=>Xn(t,n,r,e));Xn(i,n,r,e)}});function Xn(e,t,n,r){if(!e){let e={code:`custom`,input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(e.params=r._zod.def.params),t.issues.push(Ce(e))}}var Zn,Qn=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){let n=t[0];return this._map.set(e,n),n&&typeof n==`object`&&`id`in n&&this._idmap.set(n.id,e),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let t=this._map.get(e);return t&&typeof t==`object`&&`id`in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let n={...this.get(t)??{}};delete n.id;let r={...n,...this._map.get(e)};return Object.keys(r).length?r:void 0}return this._map.get(e)}has(e){return this._map.has(e)}};function $n(){return new Qn}(Zn=globalThis).__zod_globalRegistry??(Zn.__zod_globalRegistry=$n());let er=globalThis.__zod_globalRegistry;function tr(e,t){return new e({type:`string`,...v(t)})}function nr(e,t){return new e({type:`string`,format:`email`,check:`string_format`,abort:!1,...v(t)})}function rr(e,t){return new e({type:`string`,format:`guid`,check:`string_format`,abort:!1,...v(t)})}function ir(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,...v(t)})}function ar(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v4`,...v(t)})}function or(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v6`,...v(t)})}function sr(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v7`,...v(t)})}function cr(e,t){return new e({type:`string`,format:`url`,check:`string_format`,abort:!1,...v(t)})}function lr(e,t){return new e({type:`string`,format:`emoji`,check:`string_format`,abort:!1,...v(t)})}function ur(e,t){return new e({type:`string`,format:`nanoid`,check:`string_format`,abort:!1,...v(t)})}function dr(e,t){return new e({type:`string`,format:`cuid`,check:`string_format`,abort:!1,...v(t)})}function fr(e,t){return new e({type:`string`,format:`cuid2`,check:`string_format`,abort:!1,...v(t)})}function pr(e,t){return new e({type:`string`,format:`ulid`,check:`string_format`,abort:!1,...v(t)})}function mr(e,t){return new e({type:`string`,format:`xid`,check:`string_format`,abort:!1,...v(t)})}function hr(e,t){return new e({type:`string`,format:`ksuid`,check:`string_format`,abort:!1,...v(t)})}function gr(e,t){return new e({type:`string`,format:`ipv4`,check:`string_format`,abort:!1,...v(t)})}function _r(e,t){return new e({type:`string`,format:`ipv6`,check:`string_format`,abort:!1,...v(t)})}function vr(e,t){return new e({type:`string`,format:`cidrv4`,check:`string_format`,abort:!1,...v(t)})}function yr(e,t){return new e({type:`string`,format:`cidrv6`,check:`string_format`,abort:!1,...v(t)})}function br(e,t){return new e({type:`string`,format:`base64`,check:`string_format`,abort:!1,...v(t)})}function xr(e,t){return new e({type:`string`,format:`base64url`,check:`string_format`,abort:!1,...v(t)})}function Sr(e,t){return new e({type:`string`,format:`e164`,check:`string_format`,abort:!1,...v(t)})}function Cr(e,t){return new e({type:`string`,format:`jwt`,check:`string_format`,abort:!1,...v(t)})}function wr(e,t){return new e({type:`string`,format:`datetime`,check:`string_format`,offset:!1,local:!1,precision:null,...v(t)})}function Tr(e,t){return new e({type:`string`,format:`date`,check:`string_format`,...v(t)})}function Er(e,t){return new e({type:`string`,format:`time`,check:`string_format`,precision:null,...v(t)})}function Dr(e,t){return new e({type:`string`,format:`duration`,check:`string_format`,...v(t)})}function Or(e,t){return new e({type:`number`,checks:[],...v(t)})}function kr(e,t){return new e({type:`number`,coerce:!0,checks:[],...v(t)})}function Ar(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`safeint`,...v(t)})}function jr(e,t){return new e({type:`boolean`,...v(t)})}function Mr(e,t){return new e({type:`null`,...v(t)})}function Nr(e){return new e({type:`any`})}function Pr(e){return new e({type:`unknown`})}function Fr(e,t){return new e({type:`never`,...v(t)})}function Ir(e,t){return new vt({check:`less_than`,...v(t),value:e,inclusive:!1})}function Lr(e,t){return new vt({check:`less_than`,...v(t),value:e,inclusive:!0})}function Rr(e,t){return new yt({check:`greater_than`,...v(t),value:e,inclusive:!1})}function zr(e,t){return new yt({check:`greater_than`,...v(t),value:e,inclusive:!0})}function Br(e,t){return new bt({check:`multiple_of`,...v(t),value:e})}function Vr(e,t){return new St({check:`max_length`,...v(t),maximum:e})}function Hr(e,t){return new Ct({check:`min_length`,...v(t),minimum:e})}function Ur(e,t){return new wt({check:`length_equals`,...v(t),length:e})}function Wr(e,t){return new Et({check:`string_format`,format:`regex`,...v(t),pattern:e})}function Gr(e){return new Dt({check:`string_format`,format:`lowercase`,...v(e)})}function Kr(e){return new Ot({check:`string_format`,format:`uppercase`,...v(e)})}function qr(e,t){return new kt({check:`string_format`,format:`includes`,...v(t),includes:e})}function Jr(e,t){return new At({check:`string_format`,format:`starts_with`,...v(t),prefix:e})}function Yr(e,t){return new jt({check:`string_format`,format:`ends_with`,...v(t),suffix:e})}function Xr(e){return new Mt({check:`overwrite`,tx:e})}function Zr(e){return Xr(t=>t.normalize(e))}function Qr(){return Xr(e=>e.trim())}function $r(){return Xr(e=>e.toLowerCase())}function ei(){return Xr(e=>e.toUpperCase())}function ti(){return Xr(e=>te(e))}function ni(e,t,n){return new e({type:`array`,element:t,...v(n)})}function ri(e,t,n){return new e({type:`custom`,check:`custom`,fn:t,...v(n)})}function ii(e,t){let n=ai(t=>(t.addIssue=e=>{if(typeof e==`string`)t.issues.push(Ce(e,t.value,n._zod.def));else{let r=e;r.fatal&&(r.continue=!1),r.code??=`custom`,r.input??=t.value,r.inst??=n,r.continue??=!n._zod.def.abort,t.issues.push(Ce(r))}},e(t.value,t)),t);return n}function ai(e,t){let n=new w({check:`custom`,...v(t)});return n._zod.check=e,n}function oi(e){let t=e?.target??`draft-2020-12`;return t===`draft-4`&&(t=`draft-04`),t===`draft-7`&&(t=`draft-07`),{processors:e.processors??{},metadataRegistry:e?.metadata??er,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 D(e,t,n={path:[],schemaPath:[]}){var r;let i=e._zod.def,a=t.seen.get(e);if(a)return a.count++,n.schemaPath.includes(e)&&(a.cycle=n.path),a.schema;let o={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,o);let s=e._zod.toJSONSchema?.();if(s)o.schema=s;else{let r={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,o.schema,r);else{let n=o.schema,a=t.processors[i.type];if(!a)throw Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);a(e,t,n,r)}let a=e._zod.parent;a&&(o.ref||=a,D(a,t,r),t.seen.get(a).isParent=!0)}let c=t.metadataRegistry.get(e);return c&&Object.assign(o.schema,c),t.io===`input`&&li(e)&&(delete o.schema.examples,delete o.schema.default),t.io===`input`&&`_prefault`in o.schema&&((r=o.schema).default??(r.default=o.schema._prefault)),delete o.schema._prefault,t.seen.get(e).schema}function si(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=new Map;for(let t of e.seen.entries()){let n=e.metadataRegistry.get(t[0])?.id;if(n){let e=r.get(n);if(e&&e!==t[0])throw Error(`Duplicate schema id "${n}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(n,t[0])}}let i=t=>{let r=e.target===`draft-2020-12`?`$defs`:`definitions`;if(e.external){let n=e.external.registry.get(t[0])?.id,i=e.external.uri??(e=>e);if(n)return{ref:i(n)};let a=t[1].defId??t[1].schema.id??`schema${e.counter++}`;return t[1].defId=a,{defId:a,ref:`${i(`__shared`)}#/${r}/${a}`}}if(t[1]===n)return{ref:`#`};let i=`#/${r}/`,a=t[1].schema.id??`__schema${e.counter++}`;return{defId:a,ref:i+a}},a=e=>{if(e[1].schema.$ref)return;let t=e[1],{ref:n,defId:r}=i(e);t.def={...t.schema},r&&(t.defId=r);let a=t.schema;for(let e in a)delete a[e];a.$ref=n};if(e.cycles===`throw`)for(let t of e.seen.entries()){let e=t[1];if(e.cycle)throw Error(`Cycle detected: #/${e.cycle?.join(`/`)}/<root>
63
63
 
64
- Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let n of e.seen.entries()){let r=n[1];if(t===n[0]){a(n);continue}if(e.external){let r=e.external.registry.get(n[0])?.id;if(t!==n[0]&&r){a(n);continue}}if(e.metadataRegistry.get(n[0])?.id){a(n);continue}if(r.cycle){a(n);continue}if(r.count>1&&e.reused===`ref`){a(n);continue}}}function ci(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=t=>{let n=e.seen.get(t);if(n.ref===null)return;let i=n.def??n.schema,a={...i},o=n.ref;if(n.ref=null,o){r(o);let n=e.seen.get(o),s=n.schema;if(s.$ref&&(e.target===`draft-07`||e.target===`draft-04`||e.target===`openapi-3.0`)?(i.allOf=i.allOf??[],i.allOf.push(s)):Object.assign(i,s),Object.assign(i,a),t._zod.parent===o)for(let e in i)e===`$ref`||e===`allOf`||e in a||delete i[e];if(s.$ref&&n.def)for(let e in i)e===`$ref`||e===`allOf`||e in n.def&&JSON.stringify(i[e])===JSON.stringify(n.def[e])&&delete i[e]}let s=t._zod.parent;if(s&&s!==o){r(s);let t=e.seen.get(s);if(t?.schema.$ref&&(i.$ref=t.schema.$ref,t.def))for(let e in i)e===`$ref`||e===`allOf`||e in t.def&&JSON.stringify(i[e])===JSON.stringify(t.def[e])&&delete i[e]}e.override({zodSchema:t,jsonSchema:i,path:n.path??[]})};for(let t of[...e.seen.entries()].reverse())r(t[0]);let i={};if(e.target===`draft-2020-12`?i.$schema=`https://json-schema.org/draft/2020-12/schema`:e.target===`draft-07`?i.$schema=`http://json-schema.org/draft-07/schema#`:e.target===`draft-04`?i.$schema=`http://json-schema.org/draft-04/schema#`:e.target,e.external?.uri){let n=e.external.registry.get(t)?.id;if(!n)throw Error("Schema is missing an `id` property");i.$id=e.external.uri(n)}Object.assign(i,n.def??n.schema);let a=e.metadataRegistry.get(t)?.id;a!==void 0&&i.id===a&&delete i.id;let o=e.external?.defs??{};for(let t of e.seen.entries()){let e=t[1];e.def&&e.defId&&(e.def.id===e.defId&&delete e.def.id,o[e.defId]=e.def)}e.external||Object.keys(o).length>0&&(e.target===`draft-2020-12`?i.$defs=o:i.definitions=o);try{let n=JSON.parse(JSON.stringify(i));return Object.defineProperty(n,"~standard",{value:{...t[`~standard`],jsonSchema:{input:di(t,`input`,e.processors),output:di(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function li(e,t){let n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);let r=e._zod.def;if(r.type===`transform`)return!0;if(r.type===`array`)return li(r.element,n);if(r.type===`set`)return li(r.valueType,n);if(r.type===`lazy`)return li(r.getter(),n);if(r.type===`promise`||r.type===`optional`||r.type===`nonoptional`||r.type===`nullable`||r.type===`readonly`||r.type==="default"||r.type===`prefault`)return li(r.innerType,n);if(r.type===`intersection`)return li(r.left,n)||li(r.right,n);if(r.type===`record`||r.type===`map`)return li(r.keyType,n)||li(r.valueType,n);if(r.type===`pipe`)return e._zod.traits.has(`$ZodCodec`)?!0:li(r.in,n)||li(r.out,n);if(r.type===`object`){for(let e in r.shape)if(li(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(li(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(li(e,n))return!0;return!!(r.rest&&li(r.rest,n))}return!1}let ui=(e,t={})=>n=>{let r=oi({...n,processors:t});return D(e,r),si(r,e),ci(r,e)},di=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=oi({...i??{},target:a,io:t,processors:n});return D(e,o),si(o,e),ci(o,e)},fi={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},pi=(e,t,n,r)=>{let i=n;i.type=`string`;let{minimum:a,maximum:o,format:s,patterns:c,contentEncoding:l}=e._zod.bag;if(typeof a==`number`&&(i.minLength=a),typeof o==`number`&&(i.maxLength=o),s&&(i.format=fi[s]??s,i.format===``&&delete i.format,s===`time`&&delete i.format),l&&(i.contentEncoding=l),c&&c.size>0){let e=[...c];e.length===1?i.pattern=e[0].source:e.length>1&&(i.allOf=[...e.map(e=>({...t.target===`draft-07`||t.target===`draft-04`||t.target===`openapi-3.0`?{type:`string`}:{},pattern:e.source}))])}},mi=(e,t,n,r)=>{let i=n,{minimum:a,maximum:o,format:s,multipleOf:c,exclusiveMaximum:l,exclusiveMinimum:u}=e._zod.bag;typeof s==`string`&&s.includes(`int`)?i.type=`integer`:i.type=`number`;let d=typeof u==`number`&&u>=(a??-1/0),f=typeof l==`number`&&l<=(o??1/0),p=t.target===`draft-04`||t.target===`openapi-3.0`;d?p?(i.minimum=u,i.exclusiveMinimum=!0):i.exclusiveMinimum=u:typeof a==`number`&&(i.minimum=a),f?p?(i.maximum=l,i.exclusiveMaximum=!0):i.exclusiveMaximum=l:typeof o==`number`&&(i.maximum=o),typeof c==`number`&&(i.multipleOf=c)},hi=(e,t,n,r)=>{n.type=`boolean`},gi=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`BigInt cannot be represented in JSON Schema`)},_i=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Symbols cannot be represented in JSON Schema`)},vi=(e,t,n,r)=>{t.target===`openapi-3.0`?(n.type=`string`,n.nullable=!0,n.enum=[null]):n.type=`null`},yi=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Undefined cannot be represented in JSON Schema`)},bi=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Void cannot be represented in JSON Schema`)},xi=(e,t,n,r)=>{n.not={}},Si=(e,t,n,r)=>{},Ci=(e,t,n,r)=>{},wi=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Date cannot be represented in JSON Schema`)},Ti=(e,t,n,r)=>{let i=e._zod.def,a=c(i.entries);a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=a},Ei=(e,t,n,r)=>{let i=e._zod.def,a=[];for(let e of i.values)if(e===void 0){if(t.unrepresentable===`throw`)throw Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof e==`bigint`){if(t.unrepresentable===`throw`)throw Error(`BigInt literals cannot be represented in JSON Schema`);a.push(Number(e))}else a.push(e);if(a.length!==0)if(a.length===1){let e=a[0];n.type=e===null?`null`:typeof e,t.target===`draft-04`||t.target===`openapi-3.0`?n.enum=[e]:n.const=e}else a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),a.every(e=>typeof e==`boolean`)&&(n.type=`boolean`),a.every(e=>e===null)&&(n.type=`null`),n.enum=a},Di=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`NaN cannot be represented in JSON Schema`)},Oi=(e,t,n,r)=>{let i=n,a=e._zod.pattern;if(!a)throw Error(`Pattern not found in template literal`);i.type=`string`,i.pattern=a.source},ki=(e,t,n,r)=>{let i=n,a={type:`string`,format:`binary`,contentEncoding:`binary`},{minimum:o,maximum:s,mime:c}=e._zod.bag;o!==void 0&&(a.minLength=o),s!==void 0&&(a.maxLength=s),c?c.length===1?(a.contentMediaType=c[0],Object.assign(i,a)):(Object.assign(i,a),i.anyOf=c.map(e=>({contentMediaType:e}))):Object.assign(i,a)},Ai=(e,t,n,r)=>{n.type=`boolean`},ji=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Custom types cannot be represented in JSON Schema`)},Mi=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Function types cannot be represented in JSON Schema`)},Ni=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Transforms cannot be represented in JSON Schema`)},Pi=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Map cannot be represented in JSON Schema`)},Fi=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Set cannot be represented in JSON Schema`)},Ii=(e,t,n,r)=>{let i=n,a=e._zod.def,{minimum:o,maximum:s}=e._zod.bag;typeof o==`number`&&(i.minItems=o),typeof s==`number`&&(i.maxItems=s),i.type=`array`,i.items=D(a.element,t,{...r,path:[...r.path,`items`]})},Li=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`,i.properties={};let o=a.shape;for(let e in o)i.properties[e]=D(o[e],t,{...r,path:[...r.path,`properties`,e]});let s=new Set(Object.keys(o)),c=new Set([...s].filter(e=>{let n=a.shape[e]._zod;return t.io===`input`?n.optin===void 0:n.optout===void 0}));c.size>0&&(i.required=Array.from(c)),a.catchall?._zod.def.type===`never`?i.additionalProperties=!1:a.catchall?a.catchall&&(i.additionalProperties=D(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},Ri=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>D(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},zi=(e,t,n,r)=>{let i=e._zod.def,a=D(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=D(i.right,t,{...r,path:[...r.path,`allOf`,1]}),s=e=>`allOf`in e&&Object.keys(e).length===1;n.allOf=[...s(a)?a.allOf:[a],...s(o)?o.allOf:[o]]},Bi=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`array`;let o=t.target===`draft-2020-12`?`prefixItems`:`items`,s=t.target===`draft-2020-12`||t.target===`openapi-3.0`?`items`:`additionalItems`,c=a.items.map((e,n)=>D(e,t,{...r,path:[...r.path,o,n]})),l=a.rest?D(a.rest,t,{...r,path:[...r.path,s,...t.target===`openapi-3.0`?[a.items.length]:[]]}):null;t.target===`draft-2020-12`?(i.prefixItems=c,l&&(i.items=l)):t.target===`openapi-3.0`?(i.items={anyOf:c},l&&i.items.anyOf.push(l),i.minItems=c.length,l||(i.maxItems=c.length)):(i.items=c,l&&(i.additionalItems=l));let{minimum:u,maximum:d}=e._zod.bag;typeof u==`number`&&(i.minItems=u),typeof d==`number`&&(i.maxItems=d)},Vi=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`;let o=a.keyType,s=o._zod.bag?.patterns;if(a.mode===`loose`&&s&&s.size>0){let e=D(a.valueType,t,{...r,path:[...r.path,`patternProperties`,`*`]});i.patternProperties={};for(let t of s)i.patternProperties[t.source]=e}else (t.target===`draft-07`||t.target===`draft-2020-12`)&&(i.propertyNames=D(a.keyType,t,{...r,path:[...r.path,`propertyNames`]})),i.additionalProperties=D(a.valueType,t,{...r,path:[...r.path,`additionalProperties`]});let c=o._zod.values;if(c){let e=[...c].filter(e=>typeof e==`string`||typeof e==`number`);e.length>0&&(i.required=e)}},Hi=(e,t,n,r)=>{let i=e._zod.def,a=D(i.innerType,t,r),o=t.seen.get(e);t.target===`openapi-3.0`?(o.ref=i.innerType,n.nullable=!0):n.anyOf=[a,{type:`null`}]},Ui=(e,t,n,r)=>{let i=e._zod.def;D(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},Wi=(e,t,n,r)=>{let i=e._zod.def;D(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.default=JSON.parse(JSON.stringify(i.defaultValue))},Gi=(e,t,n,r)=>{let i=e._zod.def;D(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,t.io===`input`&&(n._prefault=JSON.parse(JSON.stringify(i.defaultValue)))},Ki=(e,t,n,r)=>{let i=e._zod.def;D(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{throw Error(`Dynamic catch values are not supported in JSON Schema`)}n.default=o},qi=(e,t,n,r)=>{let i=e._zod.def,a=i.in._zod.traits.has(`$ZodTransform`),o=t.io===`input`?a?i.out:i.in:i.out;D(o,t,r);let s=t.seen.get(e);s.ref=o},Ji=(e,t,n,r)=>{let i=e._zod.def;D(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},Yi=(e,t,n,r)=>{let i=e._zod.def;D(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},Xi=(e,t,n,r)=>{let i=e._zod.def;D(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},Zi=(e,t,n,r)=>{let i=e._zod.innerType;D(i,t,r);let a=t.seen.get(e);a.ref=i},Qi={string:pi,number:mi,boolean:hi,bigint:gi,symbol:_i,null:vi,undefined:yi,void:bi,never:xi,any:Si,unknown:Ci,date:wi,enum:Ti,literal:Ei,nan:Di,template_literal:Oi,file:ki,success:Ai,custom:ji,function:Mi,transform:Ni,map:Pi,set:Fi,array:Ii,object:Li,union:Ri,intersection:zi,tuple:Bi,record:Vi,nullable:Hi,nonoptional:Ui,default:Wi,prefault:Gi,catch:Ki,pipe:qi,readonly:Ji,promise:Yi,optional:Xi,lazy:Zi};function $i(e,t){if(`_idmap`in e){let n=e,r=oi({...t,processors:Qi}),i={};for(let e of n._idmap.entries()){let[t,n]=e;D(n,r)}let a={};r.external={registry:n,uri:t?.uri,defs:i};for(let e of n._idmap.entries()){let[t,n]=e;si(r,n),a[t]=ci(r,n)}return Object.keys(i).length>0&&(a.__shared={[r.target===`draft-2020-12`?`$defs`:`definitions`]:i}),{schemas:a}}let n=oi({...t,processors:Qi});return D(e,n),si(n,e),ci(n,e)}let ea=r(`ZodISODateTime`,(e,t)=>{qt.init(e,t),A.init(e,t)});function ta(e){return wr(ea,e)}let na=r(`ZodISODate`,(e,t)=>{Jt.init(e,t),A.init(e,t)});function ra(e){return Tr(na,e)}let ia=r(`ZodISOTime`,(e,t)=>{Yt.init(e,t),A.init(e,t)});function aa(e){return Er(ia,e)}let oa=r(`ZodISODuration`,(e,t)=>{Xt.init(e,t),A.init(e,t)});function sa(e){return Dr(oa,e)}let ca=r(`ZodError`,(e,t)=>{Te.init(e,t),e.name=`ZodError`,Object.defineProperties(e,{format:{value:t=>De(e,t)},flatten:{value:t=>Ee(e,t)},addIssue:{value:t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,l,2)}},addIssues:{value:t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,l,2)}},isEmpty:{get(){return e.issues.length===0}}})},{Parent:Error}),la=Oe(ca),ua=ke(ca),da=Ae(ca),fa=Me(ca),pa=S(ca),ma=Pe(ca),ha=Fe(ca),ga=Ie(ca),_a=Le(ca),va=Re(ca),ya=ze(ca),ba=Be(ca),xa=new WeakMap;function Sa(e,t,n){let r=Object.getPrototypeOf(e),i=xa.get(r);if(i||(i=new Set,xa.set(r,i)),!i.has(t)){i.add(t);for(let e in n){let t=n[e];Object.defineProperty(r,e,{configurable:!0,enumerable:!1,get(){let n=t.bind(this);return Object.defineProperty(this,e,{configurable:!0,writable:!0,enumerable:!0,value:n}),n},set(t){Object.defineProperty(this,e,{configurable:!0,writable:!0,enumerable:!0,value:t})}})}}}let O=r(`ZodType`,(e,t)=>(T.init(e,t),Object.assign(e[`~standard`],{jsonSchema:{input:di(e,`input`),output:di(e,`output`)}}),e.toJSONSchema=ui(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.parse=(t,n)=>la(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>da(e,t,n),e.parseAsync=async(t,n)=>ua(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>fa(e,t,n),e.spa=e.safeParseAsync,e.encode=(t,n)=>pa(e,t,n),e.decode=(t,n)=>ma(e,t,n),e.encodeAsync=async(t,n)=>ha(e,t,n),e.decodeAsync=async(t,n)=>ga(e,t,n),e.safeEncode=(t,n)=>_a(e,t,n),e.safeDecode=(t,n)=>va(e,t,n),e.safeEncodeAsync=async(t,n)=>ya(e,t,n),e.safeDecodeAsync=async(t,n)=>ba(e,t,n),Sa(e,`ZodType`,{check(...e){let t=this.def;return this.clone(_(t,{checks:[...t.checks??[],...e.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return le(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(Lo(e,t))},superRefine(e,t){return this.check(Ro(e,t))},overwrite(e){return this.check(Xr(e))},optional(){return V(this)},exactOptional(){return vo(this)},nullable(){return bo(this)},nullish(){return V(bo(this))},nonoptional(e){return Eo(this,e)},array(){return P(this)},or(e){return L([this,e])},and(e){return lo(this,e)},transform(e){return Ao(this,ho(e))},default(e){return So(this,e)},prefault(e){return wo(this,e)},catch(e){return Oo(this,e)},pipe(e){return Ao(this,e)},readonly(){return No(this)},describe(e){let t=this.clone();return er.add(t,{description:e}),t},meta(...e){if(e.length===0)return er.get(this);let t=this.clone();return er.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e){return e(this)}}),Object.defineProperty(e,"description",{get(){return er.get(e)?.description},configurable:!0}),e)),Ca=r(`_ZodString`,(e,t)=>{Ft.init(e,t),O.init(e,t),e._zod.processJSONSchema=(t,n,r)=>pi(e,t,n,r);let n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,Sa(e,`_ZodString`,{regex(...e){return this.check(Wr(...e))},includes(...e){return this.check(qr(...e))},startsWith(...e){return this.check(Jr(...e))},endsWith(...e){return this.check(Yr(...e))},min(...e){return this.check(Hr(...e))},max(...e){return this.check(Vr(...e))},length(...e){return this.check(Ur(...e))},nonempty(...e){return this.check(Hr(1,...e))},lowercase(e){return this.check(Gr(e))},uppercase(e){return this.check(Kr(e))},trim(){return this.check(Qr())},normalize(...e){return this.check(Zr(...e))},toLowerCase(){return this.check($r())},toUpperCase(){return this.check(ei())},slugify(){return this.check(ti())}})}),wa=r(`ZodString`,(e,t)=>{Ft.init(e,t),Ca.init(e,t),e.email=t=>e.check(nr(Ta,t)),e.url=t=>e.check(cr(ka,t)),e.jwt=t=>e.check(Cr(Ga,t)),e.emoji=t=>e.check(lr(ja,t)),e.guid=t=>e.check(rr(Da,t)),e.uuid=t=>e.check(ir(Oa,t)),e.uuidv4=t=>e.check(ar(Oa,t)),e.uuidv6=t=>e.check(or(Oa,t)),e.uuidv7=t=>e.check(sr(Oa,t)),e.nanoid=t=>e.check(ur(Ma,t)),e.guid=t=>e.check(rr(Da,t)),e.cuid=t=>e.check(dr(Na,t)),e.cuid2=t=>e.check(fr(Pa,t)),e.ulid=t=>e.check(pr(Fa,t)),e.base64=t=>e.check(br(Ha,t)),e.base64url=t=>e.check(xr(Ua,t)),e.xid=t=>e.check(mr(Ia,t)),e.ksuid=t=>e.check(hr(La,t)),e.ipv4=t=>e.check(gr(Ra,t)),e.ipv6=t=>e.check(_r(za,t)),e.cidrv4=t=>e.check(vr(Ba,t)),e.cidrv6=t=>e.check(yr(Va,t)),e.e164=t=>e.check(Sr(Wa,t)),e.datetime=t=>e.check(ta(t)),e.date=t=>e.check(ra(t)),e.time=t=>e.check(aa(t)),e.duration=t=>e.check(sa(t))});function k(e){return tr(wa,e)}let A=r(`ZodStringFormat`,(e,t)=>{E.init(e,t),Ca.init(e,t)}),Ta=r(`ZodEmail`,(e,t)=>{Rt.init(e,t),A.init(e,t)});function Ea(e){return nr(Ta,e)}let Da=r(`ZodGUID`,(e,t)=>{It.init(e,t),A.init(e,t)}),Oa=r(`ZodUUID`,(e,t)=>{Lt.init(e,t),A.init(e,t)}),ka=r(`ZodURL`,(e,t)=>{zt.init(e,t),A.init(e,t)});function Aa(e){return cr(ka,e)}let ja=r(`ZodEmoji`,(e,t)=>{Bt.init(e,t),A.init(e,t)}),Ma=r(`ZodNanoID`,(e,t)=>{Vt.init(e,t),A.init(e,t)}),Na=r(`ZodCUID`,(e,t)=>{Ht.init(e,t),A.init(e,t)}),Pa=r(`ZodCUID2`,(e,t)=>{Ut.init(e,t),A.init(e,t)}),Fa=r(`ZodULID`,(e,t)=>{Wt.init(e,t),A.init(e,t)}),Ia=r(`ZodXID`,(e,t)=>{Gt.init(e,t),A.init(e,t)}),La=r(`ZodKSUID`,(e,t)=>{Kt.init(e,t),A.init(e,t)}),Ra=r(`ZodIPv4`,(e,t)=>{Zt.init(e,t),A.init(e,t)}),za=r(`ZodIPv6`,(e,t)=>{Qt.init(e,t),A.init(e,t)}),Ba=r(`ZodCIDRv4`,(e,t)=>{$t.init(e,t),A.init(e,t)}),Va=r(`ZodCIDRv6`,(e,t)=>{en.init(e,t),A.init(e,t)}),Ha=r(`ZodBase64`,(e,t)=>{nn.init(e,t),A.init(e,t)}),Ua=r(`ZodBase64URL`,(e,t)=>{an.init(e,t),A.init(e,t)}),Wa=r(`ZodE164`,(e,t)=>{on.init(e,t),A.init(e,t)}),Ga=r(`ZodJWT`,(e,t)=>{cn.init(e,t),A.init(e,t)}),Ka=r(`ZodNumber`,(e,t)=>{ln.init(e,t),O.init(e,t),e._zod.processJSONSchema=(t,n,r)=>mi(e,t,n,r),Sa(e,`ZodNumber`,{gt(e,t){return this.check(Rr(e,t))},gte(e,t){return this.check(zr(e,t))},min(e,t){return this.check(zr(e,t))},lt(e,t){return this.check(Ir(e,t))},lte(e,t){return this.check(Lr(e,t))},max(e,t){return this.check(Lr(e,t))},int(e){return this.check(Ja(e))},safe(e){return this.check(Ja(e))},positive(e){return this.check(Rr(0,e))},nonnegative(e){return this.check(zr(0,e))},negative(e){return this.check(Ir(0,e))},nonpositive(e){return this.check(Lr(0,e))},multipleOf(e,t){return this.check(Br(e,t))},step(e,t){return this.check(Br(e,t))},finite(){return this}});let n=e._zod.bag;e.minValue=Math.max(n.minimum??-1/0,n.exclusiveMinimum??-1/0)??null,e.maxValue=Math.min(n.maximum??1/0,n.exclusiveMaximum??1/0)??null,e.isInt=(n.format??``).includes(`int`)||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null});function j(e){return Or(Ka,e)}let qa=r(`ZodNumberFormat`,(e,t)=>{un.init(e,t),Ka.init(e,t)});function Ja(e){return Ar(qa,e)}let Ya=r(`ZodBoolean`,(e,t)=>{dn.init(e,t),O.init(e,t),e._zod.processJSONSchema=(t,n,r)=>hi(e,t,n,r)});function M(e){return jr(Ya,e)}let Xa=r(`ZodNull`,(e,t)=>{fn.init(e,t),O.init(e,t),e._zod.processJSONSchema=(t,n,r)=>vi(e,t,n,r)});function Za(e){return Mr(Xa,e)}let Qa=r(`ZodAny`,(e,t)=>{pn.init(e,t),O.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function $a(){return Nr(Qa)}let eo=r(`ZodUnknown`,(e,t)=>{mn.init(e,t),O.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function N(){return Pr(eo)}let to=r(`ZodNever`,(e,t)=>{hn.init(e,t),O.init(e,t),e._zod.processJSONSchema=(t,n,r)=>xi(e,t,n,r)});function no(e){return Fr(to,e)}let ro=r(`ZodArray`,(e,t)=>{_n.init(e,t),O.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ii(e,t,n,r),e.element=t.element,Sa(e,`ZodArray`,{min(e,t){return this.check(Hr(e,t))},nonempty(e){return this.check(Hr(1,e))},max(e,t){return this.check(Vr(e,t))},length(e,t){return this.check(Ur(e,t))},unwrap(){return this.element}})});function P(e,t){return ni(ro,e,t)}let io=r(`ZodObject`,(e,t)=>{Sn.init(e,t),O.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Li(e,t,n,r),h(e,`shape`,()=>t.shape),Sa(e,`ZodObject`,{keyof(){return z(Object.keys(this._zod.def.shape))},catchall(e){return this.clone({...this._zod.def,catchall:e})},passthrough(){return this.clone({...this._zod.def,catchall:N()})},loose(){return this.clone({...this._zod.def,catchall:N()})},strict(){return this.clone({...this._zod.def,catchall:no()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(e){return me(this,e)},safeExtend(e){return he(this,e)},merge(e){return ge(this,e)},pick(e){return fe(this,e)},omit(e){return pe(this,e)},partial(...e){return _e(go,this,e[0])},required(...e){return ve(To,this,e[0])}})});function F(e,t){return new io({type:`object`,shape:e??{},...v(t)})}function I(e,t){return new io({type:`object`,shape:e,catchall:N(),...v(t)})}let ao=r(`ZodUnion`,(e,t)=>{wn.init(e,t),O.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ri(e,t,n,r),e.options=t.options});function L(e,t){return new ao({type:`union`,options:e,...v(t)})}let oo=r(`ZodDiscriminatedUnion`,(e,t)=>{ao.init(e,t),Tn.init(e,t)});function so(e,t,n){return new oo({type:`union`,options:t,discriminator:e,...v(n)})}let co=r(`ZodIntersection`,(e,t)=>{En.init(e,t),O.init(e,t),e._zod.processJSONSchema=(t,n,r)=>zi(e,t,n,r)});function lo(e,t){return new co({type:`intersection`,left:e,right:t})}let uo=r(`ZodRecord`,(e,t)=>{kn.init(e,t),O.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Vi(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType});function R(e,t,n){return!t||!t._zod?new uo({type:`record`,keyType:k(),valueType:e,...v(t)}):new uo({type:`record`,keyType:e,valueType:t,...v(n)})}let fo=r(`ZodEnum`,(e,t)=>{An.init(e,t),O.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ti(e,t,n,r),e.enum=t.entries,e.options=Object.values(t.entries);let n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{let i={};for(let r of e)if(n.has(r))i[r]=t.entries[r];else throw Error(`Key ${r} not found in enum`);return new fo({...t,checks:[],...v(r),entries:i})},e.exclude=(e,r)=>{let i={...t.entries};for(let t of e)if(n.has(t))delete i[t];else throw Error(`Key ${t} not found in enum`);return new fo({...t,checks:[],...v(r),entries:i})}});function z(e,t){return new fo({type:`enum`,entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...v(t)})}let po=r(`ZodLiteral`,(e,t)=>{jn.init(e,t),O.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ei(e,t,n,r),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function B(e,t){return new po({type:`literal`,values:Array.isArray(e)?e:[e],...v(t)})}let mo=r(`ZodTransform`,(e,t)=>{Mn.init(e,t),O.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ni(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new a(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(Ce(r,n.value,t));else{let t=r;t.fatal&&(t.continue=!1),t.code??=`custom`,t.input??=n.value,t.inst??=e,n.issues.push(Ce(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n.fallback=!0,n)):(n.value=i,n.fallback=!0,n)}});function ho(e){return new mo({type:`transform`,transform:e})}let go=r(`ZodOptional`,(e,t)=>{Pn.init(e,t),O.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Xi(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function V(e){return new go({type:`optional`,innerType:e})}let _o=r(`ZodExactOptional`,(e,t)=>{Fn.init(e,t),O.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Xi(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function vo(e){return new _o({type:`optional`,innerType:e})}let yo=r(`ZodNullable`,(e,t)=>{In.init(e,t),O.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Hi(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function bo(e){return new yo({type:`nullable`,innerType:e})}let xo=r(`ZodDefault`,(e,t)=>{Ln.init(e,t),O.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Wi(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function So(e,t){return new xo({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():oe(t)}})}let Co=r(`ZodPrefault`,(e,t)=>{zn.init(e,t),O.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Gi(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function wo(e,t){return new Co({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():oe(t)}})}let To=r(`ZodNonOptional`,(e,t)=>{Bn.init(e,t),O.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ui(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Eo(e,t){return new To({type:`nonoptional`,innerType:e,...v(t)})}let Do=r(`ZodCatch`,(e,t)=>{Hn.init(e,t),O.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ki(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function Oo(e,t){return new Do({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:()=>t})}let ko=r(`ZodPipe`,(e,t)=>{Un.init(e,t),O.init(e,t),e._zod.processJSONSchema=(t,n,r)=>qi(e,t,n,r),e.in=t.in,e.out=t.out});function Ao(e,t){return new ko({type:`pipe`,in:e,out:t})}let jo=r(`ZodPreprocess`,(e,t)=>{ko.init(e,t),Gn.init(e,t)}),Mo=r(`ZodReadonly`,(e,t)=>{Kn.init(e,t),O.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ji(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function No(e){return new Mo({type:`readonly`,innerType:e})}let Po=r(`ZodLazy`,(e,t)=>{Jn.init(e,t),O.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Zi(e,t,n,r),e.unwrap=()=>e._zod.def.getter()});function Fo(e){return new Po({type:`lazy`,getter:e})}let Io=r(`ZodCustom`,(e,t)=>{Yn.init(e,t),O.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ji(e,t,n,r)});function Lo(e,t={}){return ri(Io,e,t)}function Ro(e,t){return ii(e,t)}function zo(e,t){return new jo({type:`pipe`,in:ho(e),out:t})}let Bo={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 Vo;Vo||={};function Ho(e){return kr(Ka,e)}let Uo=[`2025-11-25`,`2025-06-18`,`2025-03-26`,`2024-11-05`,`2024-10-07`],Wo=`io.modelcontextprotocol/protocolVersion`,Go=`io.modelcontextprotocol/clientInfo`,Ko=`io.modelcontextprotocol/serverInfo`,qo=`io.modelcontextprotocol/clientCapabilities`,Jo=`io.modelcontextprotocol/logLevel`,Yo=Fo(()=>L([k(),j(),M(),Za(),R(k(),Yo),P(Yo)])),H=R(k(),Yo),Xo=P(Yo),Zo=L([k(),j().int()]),Qo=k(),$o=F({ttl:j().optional()}),es=F({taskId:k()}),ts=I({progressToken:Zo.optional(),"io.modelcontextprotocol/related-task":es.optional()}),U=F({_meta:ts.optional()}),ns=U.extend({task:$o.optional()}),W=F({method:k(),params:U.loose().optional()}),rs=F({_meta:ts.optional()}),is=F({method:k(),params:rs.loose().optional()}),as=I({get[Ko](){return ys.optional().catch(void 0)}}),G=I({_meta:as.optional()}),os=L([k(),j().int()]),ss=F({jsonrpc:B(`2.0`),id:os,...W.shape}).strict(),cs=F({jsonrpc:B(`2.0`),...is.shape}).strict(),ls=F({jsonrpc:B(`2.0`),id:os,result:G}).strict(),us=F({jsonrpc:B(`2.0`),id:os.optional(),error:F({code:j().int(),message:k(),data:N().optional()})}).strict(),ds=L([ss,cs,ls,us]),fs=L([ls,us]),ps=G.strict(),ms=rs.extend({requestId:os.optional(),reason:k().optional()}),hs=is.extend({method:B(`notifications/cancelled`),params:ms}),gs=F({src:k(),mimeType:k().optional(),sizes:P(k()).optional(),theme:z([`light`,`dark`]).optional()}),_s=F({icons:P(gs).optional()}),vs=F({name:k(),title:k().optional()}),ys=vs.extend({...vs.shape,..._s.shape,version:k(),websiteUrl:k().optional(),description:k().optional()}),bs=zo(e=>e&&typeof e==`object`&&!Array.isArray(e)&&Object.keys(e).length===0?{form:{}}:e,lo(F({form:lo(F({applyDefaults:M().optional()}),H).optional(),url:H.optional()}),H.optional())),xs=I({list:H.optional(),cancel:H.optional(),requests:I({sampling:I({createMessage:H.optional()}).optional(),elicitation:I({create:H.optional()}).optional()}).optional()}),Ss=I({list:H.optional(),cancel:H.optional(),requests:I({tools:I({call:H.optional()}).optional()}).optional()}),Cs=F({experimental:R(k(),H).optional(),sampling:F({context:H.optional(),tools:H.optional()}).optional(),elicitation:bs.optional(),roots:F({listChanged:M().optional()}).optional(),tasks:xs.optional(),extensions:R(k(),H).optional()}),ws=U.extend({protocolVersion:k(),capabilities:Cs,clientInfo:ys}),Ts=W.extend({method:B(`initialize`),params:ws}),Es=F({experimental:R(k(),H).optional(),logging:H.optional(),completions:H.optional(),prompts:F({listChanged:M().optional()}).optional(),resources:F({subscribe:M().optional(),listChanged:M().optional()}).optional(),tools:F({listChanged:M().optional()}).optional(),tasks:Ss.optional(),extensions:R(k(),H).optional()}),Ds=G.extend({protocolVersion:k(),capabilities:Es,serverInfo:ys,instructions:k().optional()}),Os=is.extend({method:B(`notifications/initialized`),params:rs.optional()}),ks=W.extend({method:B(`server/discover`),params:U.optional()}),As=G.extend({supportedVersions:P(k()),capabilities:Es,instructions:k().optional()}),js=W.extend({method:B(`ping`),params:U.optional()}),Ms=F({progress:j(),total:V(j()),message:V(k())}),Ns=F({...rs.shape,...Ms.shape,progressToken:Zo}),Ps=is.extend({method:B(`notifications/progress`),params:Ns}),Fs=U.extend({cursor:Qo.optional()}),Is=W.extend({params:Fs.optional()}),Ls=G.extend({nextCursor:Qo.optional()}),Rs=F({uri:k(),mimeType:V(k()),_meta:R(k(),N()).optional()}),zs=Rs.extend({text:k()}),Bs=k().refine(e=>{try{return atob(e),!0}catch{return!1}},{message:`Invalid Base64 string`}),Vs=Rs.extend({blob:Bs}),Hs=z([`user`,`assistant`]),Us=F({audience:P(Hs).optional(),priority:j().min(0).max(1).optional(),lastModified:ta({offset:!0}).optional()}),Ws=F({...vs.shape,..._s.shape,uri:k(),description:V(k()),mimeType:V(k()),size:V(j()),annotations:Us.optional(),_meta:V(I({}))}),Gs=F({...vs.shape,..._s.shape,uriTemplate:k(),description:V(k()),mimeType:V(k()),annotations:Us.optional(),_meta:V(I({}))}),Ks=Is.extend({method:B(`resources/list`)}),qs=Ls.extend({resources:P(Ws)}),Js=Is.extend({method:B(`resources/templates/list`)}),Ys=Ls.extend({resourceTemplates:P(Gs)}),Xs=U.extend({uri:k()}),Zs=Xs,Qs=W.extend({method:B(`resources/read`),params:Zs}),$s=G.extend({contents:P(L([zs,Vs]))}),ec=is.extend({method:B(`notifications/resources/list_changed`),params:rs.optional()}),tc=Xs,nc=W.extend({method:B(`resources/subscribe`),params:tc}),rc=Xs,ic=W.extend({method:B(`resources/unsubscribe`),params:rc}),ac=F({toolsListChanged:M().optional(),promptsListChanged:M().optional(),resourcesListChanged:M().optional(),resourceSubscriptions:P(k()).optional()}),oc=U.extend({notifications:ac}),sc=W.extend({method:B(`subscriptions/listen`),params:oc}),cc=rs.extend({notifications:ac}),lc=is.extend({method:B(`notifications/subscriptions/acknowledged`),params:cc}),uc=as.extend({"io.modelcontextprotocol/subscriptionId":os}),dc=G.extend({_meta:uc}),fc=rs.extend({uri:k()}),pc=is.extend({method:B(`notifications/resources/updated`),params:fc}),mc=F({name:k(),description:V(k()),required:V(M())}),hc=F({...vs.shape,..._s.shape,description:V(k()),arguments:V(P(mc)),_meta:V(I({}))}),gc=Is.extend({method:B(`prompts/list`)}),_c=Ls.extend({prompts:P(hc)}),vc=U.extend({name:k(),arguments:R(k(),k()).optional()}),yc=W.extend({method:B(`prompts/get`),params:vc}),bc=F({type:B(`text`),text:k(),annotations:Us.optional(),_meta:R(k(),N()).optional()}),xc=F({type:B(`image`),data:Bs,mimeType:k(),annotations:Us.optional(),_meta:R(k(),N()).optional()}),Sc=F({type:B(`audio`),data:Bs,mimeType:k(),annotations:Us.optional(),_meta:R(k(),N()).optional()}),Cc=F({type:B(`tool_use`),name:k(),id:k(),input:R(k(),N()),_meta:R(k(),N()).optional()}),wc=F({type:B(`resource`),resource:L([zs,Vs]),annotations:Us.optional(),_meta:R(k(),N()).optional()}),Tc=Ws.extend({type:B(`resource_link`)}),Ec=L([bc,xc,Sc,Tc,wc]),Dc=F({role:Hs,content:Ec}),Oc=G.extend({description:k().optional(),messages:P(Dc)}),kc=is.extend({method:B(`notifications/prompts/list_changed`),params:rs.optional()}),Ac=F({title:k().optional(),readOnlyHint:M().optional(),destructiveHint:M().optional(),idempotentHint:M().optional(),openWorldHint:M().optional()}),jc=F({taskSupport:z([`required`,`optional`,`forbidden`]).optional()}),Mc=F({...vs.shape,..._s.shape,description:k().optional(),inputSchema:F({type:B(`object`),properties:R(k(),Yo).optional(),required:P(k()).optional()}).catchall(N()),outputSchema:I({$schema:k().optional()}).optional(),annotations:Ac.optional(),execution:jc.optional(),_meta:R(k(),N()).optional()}),Nc=Is.extend({method:B(`tools/list`)}),Pc=Ls.extend({tools:P(Mc)}),Fc=G.extend({content:P(Ec).default([]),structuredContent:N().optional(),isError:M().optional()}),Ic=Fc.or(G.extend({toolResult:N()})),Lc=ns.extend({name:k(),arguments:R(k(),N()).optional()}),Rc=W.extend({method:B(`tools/call`),params:Lc}),zc=is.extend({method:B(`notifications/tools/list_changed`),params:rs.optional()}),Bc=F({autoRefresh:M().default(!0),debounceMs:j().int().nonnegative().default(300)}),Vc=z([`debug`,`info`,`notice`,`warning`,`error`,`critical`,`alert`,`emergency`]),Hc=U.extend({level:Vc}),Uc=W.extend({method:B(`logging/setLevel`),params:Hc}),Wc=rs.extend({level:Vc,logger:k().optional(),data:N()}),Gc=is.extend({method:B(`notifications/message`),params:Wc}),Kc=F({name:k().optional()}),qc=F({hints:P(Kc).optional(),costPriority:j().min(0).max(1).optional(),speedPriority:j().min(0).max(1).optional(),intelligencePriority:j().min(0).max(1).optional()}),Jc=F({mode:z([`auto`,`required`,`none`]).optional()}),Yc=F({type:B(`tool_result`),toolUseId:k().describe(`The unique identifier for the corresponding tool call.`),content:P(Ec),structuredContent:N().optional(),isError:M().optional(),_meta:R(k(),N()).optional()}),Xc=so(`type`,[bc,xc,Sc]),Zc=so(`type`,[bc,xc,Sc,Cc,Yc]),Qc=F({role:Hs,content:L([Zc,P(Zc)]),_meta:R(k(),N()).optional()}),$c=ns.extend({messages:P(Qc),modelPreferences:qc.optional(),systemPrompt:k().optional(),includeContext:z([`none`,`thisServer`,`allServers`]).optional(),temperature:j().optional(),maxTokens:j().int(),stopSequences:P(k()).optional(),metadata:H.optional(),tools:P(Mc).optional(),toolChoice:Jc.optional()}),el=W.extend({method:B(`sampling/createMessage`),params:$c}),tl=G.extend({model:k(),stopReason:V(z([`endTurn`,`stopSequence`,`maxTokens`]).or(k())),role:Hs,content:Xc}),nl=G.extend({model:k(),stopReason:V(z([`endTurn`,`stopSequence`,`maxTokens`,`toolUse`]).or(k())),role:Hs,content:L([Zc,P(Zc)])}),rl=F({type:B(`boolean`),title:k().optional(),description:k().optional(),default:M().optional()}),il=F({type:B(`string`),title:k().optional(),description:k().optional(),minLength:j().optional(),maxLength:j().optional(),format:z([`email`,`uri`,`date`,`date-time`]).optional(),default:k().optional()}),al=F({type:z([`number`,`integer`]),title:k().optional(),description:k().optional(),minimum:j().optional(),maximum:j().optional(),default:j().optional()}),ol=F({type:B(`string`),title:k().optional(),description:k().optional(),enum:P(k()),default:k().optional()}),sl=F({type:B(`string`),title:k().optional(),description:k().optional(),oneOf:P(F({const:k(),title:k()})),default:k().optional()}),cl=F({type:B(`string`),title:k().optional(),description:k().optional(),enum:P(k()),enumNames:P(k()).optional(),default:k().optional()}),ll=L([ol,sl]),ul=F({type:B(`array`),title:k().optional(),description:k().optional(),minItems:j().optional(),maxItems:j().optional(),items:F({type:B(`string`),enum:P(k())}),default:P(k()).optional()}),dl=F({type:B(`array`),title:k().optional(),description:k().optional(),minItems:j().optional(),maxItems:j().optional(),items:F({anyOf:P(F({const:k(),title:k()}))}),default:P(k()).optional()}),fl=L([ul,dl]),pl=L([cl,ll,fl]),ml=L([pl,rl,il,al]),hl=ns.extend({mode:B(`form`).optional(),message:k(),requestedSchema:F({type:B(`object`),properties:R(k(),ml),required:P(k()).optional()}).catchall(N())}),gl=ns.extend({mode:B(`url`),message:k(),elicitationId:k(),url:k().url()}),_l=L([hl,gl]),vl=W.extend({method:B(`elicitation/create`),params:_l}),yl=rs.extend({elicitationId:k()}),bl=is.extend({method:B(`notifications/elicitation/complete`),params:yl}),xl=G.extend({action:z([`accept`,`decline`,`cancel`]),content:zo(e=>e===null?void 0:e,R(k(),L([k(),j(),M(),P(k())])).optional())}),Sl=F({type:B(`ref/resource`),uri:k()}),Cl=F({type:B(`ref/prompt`),name:k()}),wl=U.extend({ref:L([Cl,Sl]),argument:F({name:k(),value:k()}),context:F({arguments:R(k(),k()).optional()}).optional()}),Tl=W.extend({method:B(`completion/complete`),params:wl}),El=G.extend({completion:I({values:P(k()).max(100),total:V(j().int()),hasMore:V(M())})}),Dl=F({uri:k().startsWith(`file://`),name:k().optional(),_meta:R(k(),N()).optional()}),Ol=W.extend({method:B(`roots/list`),params:U.optional()}),kl=G.extend({roots:P(Dl)}),Al=is.extend({method:B(`notifications/roots/list_changed`),params:rs.optional()}),jl=I({ttl:j().optional(),pollInterval:j().optional()}),Ml=z([`working`,`input_required`,`completed`,`failed`,`cancelled`]),Nl=F({taskId:k(),status:Ml,ttl:L([j(),Za()]),createdAt:k(),lastUpdatedAt:k(),pollInterval:V(j()),statusMessage:V(k())}),Pl=G.extend({task:Nl}),Fl=rs.merge(Nl),Il=is.extend({method:B(`notifications/tasks/status`),params:Fl}),Ll=W.extend({method:B(`tasks/get`),params:U.extend({taskId:k()})}),Rl=G.merge(Nl),zl=W.extend({method:B(`tasks/result`),params:U.extend({taskId:k()})}),Bl=G.loose(),Vl=Is.extend({method:B(`tasks/list`)}),Hl=Ls.extend({tasks:P(Nl)}),Ul=W.extend({method:B(`tasks/cancel`),params:U.extend({taskId:k()})}),Wl=G.merge(Nl),Gl=L([js,Ts,ks,Tl,Uc,yc,gc,Ks,Js,Qs,nc,ic,sc,Rc,Nc]),Kl=L([hs,Ps,Os,Al]),ql=L([ps,tl,nl,xl,kl]),Jl=L([js,el,vl,Ol]),Yl=L([hs,Ps,Gc,pc,ec,zc,kc,lc,bl]),Xl=L([ps,Ds,As,El,Oc,_c,qs,Ys,$s,Fc,Pc,dc]),K=Aa().superRefine((e,t)=>{if(!URL.canParse(e))return t.addIssue({code:Bo.custom,message:`URL must be parseable`,fatal:!0}),n}).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`}),Zl=I({resource:k().url(),authorization_servers:P(K).optional(),jwks_uri:k().url().optional(),scopes_supported:P(k()).optional(),bearer_methods_supported:P(k()).optional(),resource_signing_alg_values_supported:P(k()).optional(),resource_name:k().optional(),resource_documentation:k().optional(),resource_policy_uri:k().url().optional(),resource_tos_uri:k().url().optional(),tls_client_certificate_bound_access_tokens:M().optional(),authorization_details_types_supported:P(k()).optional(),dpop_signing_alg_values_supported:P(k()).optional(),dpop_bound_access_tokens_required:M().optional()}),Ql=I({issuer:k(),authorization_endpoint:K,token_endpoint:K,registration_endpoint:K.optional(),scopes_supported:P(k()).optional(),response_types_supported:P(k()),response_modes_supported:P(k()).optional(),grant_types_supported:P(k()).optional(),token_endpoint_auth_methods_supported:P(k()).optional(),token_endpoint_auth_signing_alg_values_supported:P(k()).optional(),service_documentation:K.optional(),revocation_endpoint:K.optional(),revocation_endpoint_auth_methods_supported:P(k()).optional(),revocation_endpoint_auth_signing_alg_values_supported:P(k()).optional(),introspection_endpoint:k().optional(),introspection_endpoint_auth_methods_supported:P(k()).optional(),introspection_endpoint_auth_signing_alg_values_supported:P(k()).optional(),code_challenge_methods_supported:P(k()).optional(),client_id_metadata_document_supported:M().optional(),authorization_response_iss_parameter_supported:M().optional().catch(void 0)}),$l=I({issuer:k(),authorization_endpoint:K,token_endpoint:K,userinfo_endpoint:K.optional(),jwks_uri:K,registration_endpoint:K.optional(),scopes_supported:P(k()).optional(),response_types_supported:P(k()),response_modes_supported:P(k()).optional(),grant_types_supported:P(k()).optional(),acr_values_supported:P(k()).optional(),subject_types_supported:P(k()),id_token_signing_alg_values_supported:P(k()),id_token_encryption_alg_values_supported:P(k()).optional(),id_token_encryption_enc_values_supported:P(k()).optional(),userinfo_signing_alg_values_supported:P(k()).optional(),userinfo_encryption_alg_values_supported:P(k()).optional(),userinfo_encryption_enc_values_supported:P(k()).optional(),request_object_signing_alg_values_supported:P(k()).optional(),request_object_encryption_alg_values_supported:P(k()).optional(),request_object_encryption_enc_values_supported:P(k()).optional(),token_endpoint_auth_methods_supported:P(k()).optional(),token_endpoint_auth_signing_alg_values_supported:P(k()).optional(),display_values_supported:P(k()).optional(),claim_types_supported:P(k()).optional(),claims_supported:P(k()).optional(),service_documentation:k().optional(),claims_locales_supported:P(k()).optional(),ui_locales_supported:P(k()).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:K.optional(),op_tos_uri:K.optional(),client_id_metadata_document_supported:M().optional(),authorization_response_iss_parameter_supported:M().optional().catch(void 0)}),eu=F({...$l.shape,...Ql.pick({code_challenge_methods_supported:!0}).shape}),tu=F({access_token:k(),id_token:k().optional(),token_type:k(),expires_in:Ho().optional(),scope:k().optional(),refresh_token:k().optional()}).strip(),nu=F({issued_token_type:B(`urn:ietf:params:oauth:token-type:id-jag`),access_token:k(),token_type:k().optional(),expires_in:j().optional(),scope:k().optional()}).strip(),ru=F({error:k(),error_description:k().optional(),error_uri:k().optional()}),iu=K.optional().or(B(``).transform(()=>void 0)),au=F({redirect_uris:P(K),token_endpoint_auth_method:k().optional(),grant_types:P(k()).optional(),response_types:P(k()).optional(),application_type:k().optional(),client_name:k().optional(),client_uri:K.optional(),logo_uri:iu,scope:k().optional(),contacts:P(k()).optional(),tos_uri:iu,policy_uri:k().optional(),jwks_uri:K.optional(),jwks:$a().optional(),software_id:k().optional(),software_version:k().optional(),software_statement:k().optional()}).strip(),ou=F({client_id:k(),client_secret:k().optional(),client_id_issued_at:j().optional(),client_secret_expires_at:j().optional()}).strip(),su=au.merge(ou),cu=F({error:k(),error_description:k().optional()}).strip(),lu=F({token:k(),token_type_hint:k().optional()}).strip();function uu(e,t,n){return typeof e==`object`&&!!e&&`channel`in e&&e.channel===t&&`type`in e&&e.type===`mcp`&&`direction`in e&&e.direction===n&&`payload`in e}function du(e,t,n,r,i){e.postMessage({channel:n,type:`mcp`,direction:r,payload:i},t)}var fu=class{_started=!1;_closed=!1;_allowedOrigins;_channelId;_messageHandler;_clientOrigin;onclientorigin;onclose;onerror;onmessage;constructor(e){if(!e.allowedOrigins?.length)throw Error(`At least one allowed origin must be specified`);this._allowedOrigins=new Set(e.allowedOrigins),this._channelId=e.channelId??`mcp-iframe`}get clientOrigin(){return this._clientOrigin}async start(){if(this._closed)throw Error(`IframeChildTransport cannot be restarted after it closes`);if(this._started)throw Error(`Transport already started`);this._messageHandler=e=>{if(e.source!==window.parent||!this._allowedOrigins.has(`*`)&&!this._allowedOrigins.has(e.origin)||!uu(e.data,this._channelId,`client-to-server`))return;this._clientOrigin!==e.origin&&(this._clientOrigin=e.origin,this.onclientorigin?.(e.origin));let{payload:t}=e.data;if(t===`mcp-check-ready`){this._broadcastServerReady();return}try{let e=ds.parse(t);this.onmessage?.(e)}catch(e){this.onerror?.(Error(`Invalid message: ${e instanceof Error?e.message:String(e)}`))}},window.addEventListener(`message`,this._messageHandler),this._started=!0,this._broadcastServerReady()}async send(e,t){if(this._closed)throw Error(`Transport is closed`);if(!this._started)throw Error(`Transport not started`);if(!this._clientOrigin){console.debug(`[IframeChildTransport] No client connected, message not sent`);return}if(window.parent===window){console.debug(`[IframeChildTransport] Not running in an iframe, message not sent`);return}du(window.parent,this._clientOrigin,this._channelId,`server-to-client`,e)}async close(){this._closed||(this._closed=!0,this._started=!1,this._messageHandler&&=(window.removeEventListener(`message`,this._messageHandler),void 0),this._clientOrigin&&window.parent!==window&&du(window.parent,this._clientOrigin,this._channelId,`server-to-client`,`mcp-server-stopped`),this.onclose?.())}_broadcastServerReady(){window.parent!==window&&du(window.parent,`*`,this._channelId,`server-to-client`,`mcp-server-ready`)}},pu=class{_started=!1;_closed=!1;_allowedOrigins;_channelId;_messageHandler;onclose;onerror;onmessage;constructor(e){if(!e.allowedOrigins?.length)throw Error(`At least one allowed origin must be specified`);this._allowedOrigins=new Set(e.allowedOrigins),this._channelId=e.channelId??`mcp-default`}async start(){if(this._closed)throw Error(`TabServerTransport cannot be restarted after it closes`);if(this._started)throw Error(`Transport already started`);this._messageHandler=e=>{if(e.source!==window||!this._allowedOrigins.has(`*`)&&!this._allowedOrigins.has(e.origin)||!uu(e.data,this._channelId,`client-to-server`))return;let{payload:t}=e.data;if(t===`mcp-check-ready`){du(window,`*`,this._channelId,`server-to-client`,`mcp-server-ready`);return}try{let e=ds.parse(t);this.onmessage?.(e)}catch(e){this.onerror?.(Error(`Invalid message: ${e instanceof Error?e.message:String(e)}`))}},window.addEventListener(`message`,this._messageHandler),this._started=!0,du(window,`*`,this._channelId,`server-to-client`,`mcp-server-ready`)}async send(e,t){if(this._closed)throw Error(`Transport is closed`);if(!this._started)throw Error(`Transport not started`);du(window,`*`,this._channelId,`server-to-client`,e)}async close(){this._closed||(this._closed=!0,this._messageHandler&&=(window.removeEventListener(`message`,this._messageHandler),void 0),this._started&&du(window,`*`,this._channelId,`server-to-client`,`mcp-server-stopped`),this._started=!1,this.onclose?.())}};let mu=[`consequentialHint`,`debugging`,`readOnlyHint`,`untrustedContentHint`],hu=`webmcp-polyfill`,gu=globalThis.DOMException;var _u=class{#e;#t;#n;#r=new Set;#i=new Set;#a=Promise.withResolvers();#o=new Map;#s=new Set;#c;#l=!1;constructor(e,t){this.#t=e,this.#e=e.document,this.#n=t,this.#t.addEventListener(`message`,e=>this.#d(e),!0),this.#t.addEventListener(`pagehide`,()=>{this.#l=!0;for(let e of this.#s)e.end()}),this.#t.addEventListener(`pageshow`,e=>{e.persisted&&(this.#l=!1,this.#x())});for(let e of this.#x())this.#i.add(e);this.#i.size===0?this.#a.resolve():setTimeout(()=>{this.#i.clear(),this.#a.resolve()},500)}async allowed(){return this.#l?!1:this.#h(this.#e)}async getTools(e){await this.#a.promise;let t=this.#t.origin,n=[t,...e];return(await Promise.all(this.#b().map(async e=>{if(e===this.#t)return this.#n.getTools(t).map(e=>wu(e,this.#t,t));try{let t=await this.#u(e,n,{kind:`getTools`});if(!Array.isArray(t.value))throw TypeError(`Expected a tool list from the frame`);return t.value.map(n=>wu(Tu(n),e,t.origin))}catch(e){return e instanceof gu&&e.name===`UnknownError`||console.warn(`WebMCP: could not read tools from a frame.`,e),[]}}))).flat()}async execute(e,t,n,r,i){let a=await this.#u(e,[t],{kind:`execute`,name:n,input:r},i);if(typeof a.value!=`string`)throw q();return a.value}async notify(e){await this.#a.promise;let t=[this.#t.origin,...e];for(let e of this.#b()){if(e===this.#t){await this.#n.changed();continue}try{await this.#u(e,t,{kind:`changed`})}catch{}}}#u(e,t,n,r){return new Promise((i,a)=>{if(r?.throwIfAborted(),this.#l||!this.#v(e)){a(q());return}let o=crypto.randomUUID(),{port1:s,port2:c}=new MessageChannel,l,u=()=>{clearTimeout(h),g(),r?.removeEventListener(`abort`,f),this.#o.delete(o),s.close()},d=(e=q())=>{s.postMessage({kind:`cancel`}),u(),a(e)},f=()=>d(r?.reason),p=()=>{l===void 0&&this.#C(e),d()},m=r=>{if(r.source===e){if(this.#o.delete(o),t&&!t.includes(r.origin)){d();return}l=r.origin,clearTimeout(h),n.kind!==`execute`&&n.kind!==`changed`&&(h=setTimeout(p,500)),s.postMessage(n)}},h=setTimeout(p,500),g=this.#w(e,d);s.onmessage=e=>{let t=Du(e.data);if(t?.kind===`error`){d();return}t?.kind!==`result`||l===void 0||(u(),i({value:t.value,origin:l}))},s.onmessageerror=()=>d(),r?.addEventListener(`abort`,f,{once:!0}),this.#o.set(o,m);try{e.postMessage(`${hu}:connect:${o}`,`*`,[c])}catch{c.close(),d()}})}#d(e){let t=Eu(e.data);if(!t)return;e.stopImmediatePropagation();let n=e.source;if(!e.isTrusted||!n||!Ou(n)||!this.#v(n)||e.origin===`null`||this.#l)return;if(t.kind===`announce`){let t=!this.#r.has(n);if(this.#S(n),n.postMessage(`${hu}:present`,e.origin),!t||this.#t!==this.#t.top)return;for(let e of this.#r)e!==n&&e.postMessage(`${hu}:refresh`,`*`);return}if(t.kind===`present`){this.#S(n);return}if(t.kind===`refresh`){n===this.#t.top&&this.#x();return}if(t.kind===`ready`){this.#o.get(t.id)?.(e);return}let[r]=e.ports;t.kind!==`connect`||!t.id||!r||e.ports.length!==1||(this.#S(n),this.#f(n,e.origin,t.id,r))}#f(e,t,n,r){let i=new AbortController,a=!1,o=()=>{clearTimeout(l),u(),r.close()},s=()=>{i.abort(),o()},c=()=>{r.postMessage({kind:`error`}),s()},l=setTimeout(c,500),u=this.#w(e,c);r.onmessageerror=c,r.onmessage=async n=>{let u=Du(n.data);if(u?.kind===`cancel`){s();return}if(!a){a=!0,clearTimeout(l);try{let n=await this.#p(e,t,u,i.signal);r.postMessage({kind:`result`,value:n}),o()}catch{c()}}},e.postMessage(`${hu}:ready:${n}`,t)}async#p(e,t,n,r){if(!n||!this.#v(e))throw q();if(n.kind===`permission`){let{childIndex:e,childOrigin:t}=n;if(typeof e!=`number`||!Number.isInteger(e)||e<0||typeof t!=`string`)throw q();return this.#m(e,t)}if(!await this.allowed()||!await this.#g(e,t)||!this.#v(e))throw q();if(r.throwIfAborted(),n.kind===`getTools`)return this.#n.getTools(t);if(n.kind===`execute`&&typeof n.name==`string`&&typeof n.input==`string`)return this.#n.execute(t,n.name,n.input,r);if(n.kind===`changed`){await this.#n.changed();return}throw q()}async#m(e,t){let n=this.#t[e];return n!==void 0&&await this.allowed()&&vu(this.#e,n,t)}async#h(e){let t=Su(e);if(!t)return!1;let n=Cu(e);if(n!==void 0)return n;if(t===t.parent)return!0;let r=t.location.ancestorOrigins?.[0],i=yu(t.parent,r===void 0||r===t.origin);return i?vu(i,t,t.origin)&&await this.#h(i):this.#_(t,t.origin)}async#g(e,t){let n=yu(e,t===this.#t.origin);return n?this.#h(n):this.#_(e,t)}async#_(e,t){let n=e.parent;if(n===e)return!0;let r=-1;for(let t=0;t<n.length;t++)if(n[t]===e){r=t;break}if(r<0)return!1;if(n===this.#t)return await this.allowed()&&vu(this.#e,e,t);if(await this.#a.promise,!this.#r.has(n))return!1;try{let e=await this.#u(n,void 0,{kind:`permission`,childIndex:r,childOrigin:t});return e.value===!0&&await this.#g(n,e.origin)}catch{return!1}}#v(e){try{return!e.closed&&e!==this.#t&&e.top===this.#t.top}catch{return!1}}#y(){if(this.#t.closed)return[];for(let e of this.#r)this.#v(e)||this.#r.delete(e);let e=[this.#t,...this.#r];for(let t=this.#t.parent;t!==t.parent;t=t.parent)e.push(t);let t=new Set,n=[this.#t.top];for(;n.length;){let r=n.pop();if(t.has(r))continue;t.add(r);let i=[];for(let e=0;e<r.length;e++){let t=r[e];t&&i.push(t)}for(let t of e)t!==r&&t.parent===r&&!i.includes(t)&&i.push(t);n.push(...i.reverse())}return Array.from(t).filter(e=>e===this.#t||this.#v(e))}#b(){return this.#y().filter(e=>e===this.#t||this.#r.has(e))}#x(){let e=this.#y().filter(e=>e!==this.#t);for(let t of e)t.postMessage(`${hu}:announce`,`*`);return e}#S(e){this.#r.add(e),this.#i.delete(e),this.#i.size===0&&this.#a.resolve()}#C(e){this.#r.delete(e),this.#v(e)&&e.postMessage(`${hu}:announce`,`*`)}#w(e,t){let n={peer:e,end:t};return this.#s.add(n),this.#c===void 0&&(this.#c=this.#t.setInterval(()=>{for(let e of this.#s)this.#v(e.peer)||e.end()},100)),()=>{this.#s.delete(n),this.#s.size===0&&(this.#t.clearInterval(this.#c),this.#c=void 0)}}};function vu(e,t,n){let r=e.defaultView?.origin,i=bu(e,t,n===r);if(!i)return!1;let a=(i.getAttribute(`allow`)??``).split(`;`).map(e=>e.trim().split(/\s+/u)).find(([e])=>e===`tools`);if(!a)return n===r;let o=a.length===1?[`'src'`]:a.slice(1);if(o.includes(`'none'`))return!1;let s=i.hasAttribute(`srcdoc`)?null:i.getAttribute(`src`),c=s?URL.parse(s,e.baseURI):null,l=!s||c?.protocol===`about:`?r:c?.origin;return o.some(e=>e===`*`||e===`'self'`&&n===r||e===`'src'`&&n===l||e===n)}function yu(e,t){if(t)try{return e.document}catch{return}}function bu(e,t,n){if(n)try{let n=t.frameElement;if(n?.ownerDocument===e)return n}catch{}return xu(e,t)}function xu(e,t){let n=e.querySelectorAll(`iframe, frame`);for(let e of n)if(e.contentWindow===t)return e;for(let n of e.querySelectorAll(`*`)){if(!n.shadowRoot)continue;let e=xu(n.shadowRoot,t);if(e)return e}}function Su(e){let t=e.defaultView;return t&&!t.closed&&t.document===e?t:void 0}function Cu(e){let t=e,n=Du(t.permissionsPolicy??t.featurePolicy);if(typeof n?.features!=`function`||typeof n.allowsFeature!=`function`)return;let r=n.features();return Array.isArray(r)&&r.includes(`tools`)?!!n.allowsFeature(`tools`):void 0}function wu(e,t,n){let r=e.serializedSchema===void 0?void 0:JSON.parse(e.serializedSchema);return{...e.annotations!==void 0&&{annotations:{...e.annotations}},description:e.description,...r!==void 0&&{inputSchema:r},name:e.name,origin:n,title:e.title,window:t}}function Tu(e){let t=Du(e);if(!t||typeof t.name!=`string`||typeof t.title!=`string`||typeof t.description!=`string`||t.serializedSchema!==void 0&&typeof t.serializedSchema!=`string`)throw TypeError(`Invalid tool metadata from the frame`);let n={name:t.name,title:t.title,description:t.description,annotations:void 0,serializedSchema:t.serializedSchema};if(t.annotations===void 0)return n;let r=Du(t.annotations);if(!r)throw TypeError(`Invalid tool annotations from the frame`);let i={};for(let e of mu){let t=r[e];if(t!==void 0){if(typeof t!=`boolean`)throw TypeError(`Invalid ${e} annotation from the frame`);i[e]=t}}return n.annotations=i,n}function Eu(e){if(typeof e!=`string`)return;let[t,n=``,r=``,i]=e.split(`:`);return t===hu&&i===void 0?{kind:n,id:r}:void 0}function Du(e){if(!(typeof e!=`object`||!e||Array.isArray(e)))return e}function Ou(e){try{return`postMessage`in e&&`window`in e}catch{return!1}}function q(){return new gu(`Tool execution failed`,`UnknownError`)}let ku=new WeakSet,Au=new WeakMap,ju=new WeakMap;function Mu(e){return e.isTrusted&&(ku.has(e)||e.eventPhase!==Event.NONE&&e.target instanceof HTMLFormElement&&ju.has(e.target))}function Nu(e,t){if(!Mu(e))throw new DOMException(`respondWith() is only available during an agent-invoked submit event`,`InvalidStateError`);if(!e.defaultPrevented)throw new DOMException(`respondWith() requires preventDefault() during an agent-invoked submit event`,`InvalidStateError`);if(e.eventPhase===Event.NONE)throw new DOMException(`respondWith() is only available while the submit event is being dispatched`,`InvalidStateError`);ku.add(e);let n=Promise.resolve(t);Au.set(e,n),e.target instanceof HTMLFormElement&&ju.get(e.target)?.respond(e)}let Pu=new Set([`email`,`password`,`search`,`tel`,`text`,`url`]),Fu=new Set([...Pu,`date`,`datetime-local`,`month`,`number`,`time`,`week`]);function Iu(e){return e instanceof HTMLInputElement||e instanceof HTMLSelectElement||e instanceof HTMLTextAreaElement}function Lu(e){return Object.getOwnPropertyDescriptor(HTMLFormElement.prototype,`elements`)?.get?.call(e)}function Ru(e,t){return Element.prototype.getAttribute.call(e,t)}function zu(e,t){return Element.prototype.hasAttribute.call(e,t)}function Bu(e){return Object.getOwnPropertyDescriptor(Node.prototype,`isConnected`)?.get?.call(e)}function Vu(e){return Object.getOwnPropertyDescriptor(Element.prototype,`shadowRoot`)?.get?.call(e)}function Hu(e){return HTMLFormElement.prototype.checkValidity.call(e)}function Uu(e,t){HTMLFormElement.prototype.requestSubmit.call(e,t)}function Wu(e){return[...Lu(e)].filter(e=>Iu(e)&&!e.matches(`:disabled`)&&!(`readOnly`in e&&e.readOnly&&(e instanceof HTMLTextAreaElement||Fu.has(e.type))))}function Gu(e){let t=new Map;for(let n of Wu(e)){let e=n.name.trim(),r=t.get(e);r?r.push(n):t.set(e,[n])}return t}function Ku(e){return[...e.labels??[]].map(e=>{let t=e.cloneNode(!0);return t instanceof HTMLElement?(t.querySelectorAll(`button, input, meter, output, progress, select, textarea`).forEach(e=>e.remove()),t.textContent?.trim()??``):``}).filter(Boolean).join(`; `)}function qu(e,t){for(let n=t[0]?.parentElement;n&&n!==e;n=n.parentElement)if(n instanceof HTMLFieldSetElement&&t.every(e=>n.contains(e)))return n}function Ju(e,t){if(t.length===1){let e=t[0];return e&&(e.getAttribute(`toolparamdescription`)||Ku(e)||e.getAttribute(`aria-description`))||void 0}return qu(e,t)?.getAttribute(`toolparamdescription`)||void 0}function Yu(e,t,n,r){let i=Ju(t,n),a=i&&r?`${i} (${r})`:i||r;return a?{...e,description:a}:e}function Xu(e,t){let n=e.getAttribute(t);if(n===null||n.trim()===``)return;let r=Number(n);return Number.isFinite(r)?r:void 0}function Zu(e,t){let n=Number(e.getAttribute(`step`));return Number.isFinite(n)&&n>0?n:t}function Qu(e,t){let n=e/t;return Math.abs(n-Math.round(n))<2**-52*16}function $u(e,t){let n=t.getAttribute(`pattern`);if(n===null)return e;try{new RegExp(n,`v`)}catch{return e}return{...e,pattern:n}}function ed(e){let t={type:`number`},n=Xu(e,`min`),r=Xu(e,`max`);if(n!==void 0&&(t.minimum=n),r!==void 0&&(t.maximum=r),e.getAttribute(`step`)!==`any`){let r=Zu(e,1),i=Number(e.getAttribute(`value`));Qu(n??(Number.isFinite(i)?i:0),r)&&(t.multipleOf=r)}return t}function td(e,t){let n=Zu(e,60);return n<1?`${t}(:[0-5][0-9](\\.[0-9]{1,3})?)?$`:n<60?`${t}(:[0-5][0-9])?$`:`${t}$`}function nd(e){return{anyOf:e.map(e=>({type:`string`,const:e.value,title:e.textContent??``})),enum:e.map(e=>e.value)}}function rd(e){return{anyOf:e.map(e=>{let t=Ku(e),n={type:`string`,const:e.value};return t&&(n.title=t),n}),enum:e.map(e=>e.value)}}function id(e,t){return e instanceof HTMLInputElement&&e.type===t}function ad(e){if(Pu.has(e.type))return $u({type:`string`},e);switch(e.type){case`hidden`:return e.getAttribute(`toolparamdescription`)?{type:`string`}:void 0;case`number`:return $u(ed(e),e);case`range`:{let t=ed(e);return t.minimum??=0,t.maximum??=100,t}case`checkbox`:return{type:`boolean`};case`date`:return{type:`string`,format:`date`};case`month`:return{type:`string`,format:`^[0-9]{4}-(0[1-9]|1[0-2])$`};case`week`:return{type:`string`,format:`^[0-9]{4}-W(0[1-9]|[1-4][0-9]|5[0-3])$`};case`time`:return{type:`string`,format:td(e,`^([01][0-9]|2[0-3]):[0-5][0-9]`)};case`datetime-local`:return{type:`string`,format:td(e,`^[0-9]{4}-(0[1-9]|1[0-2])-[0-9]{2}T([01][0-9]|2[0-3]):[0-5][0-9]`)};case`color`:return{type:`string`,format:`^#[0-9a-zA-Z]{6}$`};default:return}}function od(e,t){let[n]=t;if(!n)return;let r;if(t.every(e=>id(e,`radio`)))r={type:`string`,...rd(t)};else if(t.length>1)t.every(e=>id(e,`checkbox`))&&(r={type:`array`,items:{type:`string`,...rd(t)},uniqueItems:!0});else if(n instanceof HTMLTextAreaElement)r={type:`string`};else if(n instanceof HTMLSelectElement){let e=nd([...n.options]);r=n.multiple?{type:`array`,items:{type:`string`,...e},uniqueItems:!0}:{type:`string`,...e}}else r=ad(n);let i=n.type===`date`?`Dates MUST be provided in 'YYYY-MM-DD' format.`:void 0;return r&&Yu(r,e,t,i)}function sd(e){let t={},n=[];for(let[r,i]of Gu(e)){if(!r)continue;let a=od(e,i);a&&(Object.defineProperty(t,r,{configurable:!0,enumerable:!0,value:a,writable:!0}),i.some(e=>e.required)&&n.push(r))}return{type:`object`,properties:t,required:n}}function cd(e){return{name:Ru(e,`toolname`)??``,title:Ru(e,`tooltitle`)??``,description:Ru(e,`tooldescription`)??``,inputSchema:sd(e),autosubmit:zu(e,`toolautosubmit`)}}function ld(e){if(typeof e==`string`||typeof e==`boolean`||typeof e==`number`&&Number.isFinite(e))return String(e)}function ud(e){if(typeof e==`boolean`)return e;if(typeof e==`number`&&Number.isInteger(e))return e!==0;if(typeof e==`string`){if(e===`1`||e.toLowerCase()===`true`)return!0;if(e===`0`||e.toLowerCase()===`false`)return!1}}function dd(e,t){if(!Array.isArray(e))return!1;let n=new Set(t);for(let t of e){let e=ld(t);if(e===void 0||!n.delete(e))return!1}return!0}function fd(e,t){if(t===``)return e.type!==`number`&&e.type!==`range`;let n=e.ownerDocument.createElement(`input`);return n.type=e.type,n.value=t,n.value!==``}function pd(e,t,n){let[r]=t;if(!r||!od(e,t))return!1;let i=ld(n);if(t.every(e=>id(e,`radio`)))return t.some(e=>e.value===i);if(t.length>1)return dd(n,new Set(t.map(e=>e.value)));if(r instanceof HTMLSelectElement){let e=new Set([...r.options].map(e=>e.value));return r.multiple?dd(n,e):i!==void 0&&e.has(i)}return r instanceof HTMLTextAreaElement?i!==void 0:r.type===`checkbox`?ud(n)!==void 0:i!==void 0&&fd(r,i)}function md(e){e.dispatchEvent(new Event(`input`,{bubbles:!0,composed:!0})),e.dispatchEvent(new Event(`change`,{bubbles:!0}))}function hd(e,t){if(e.value===t)return;let n=e instanceof HTMLInputElement?HTMLInputElement.prototype:HTMLTextAreaElement.prototype;Object.getOwnPropertyDescriptor(n,`value`)?.set?.call(e,t),md(e)}function gd(e,t){e.checked!==t&&(Object.getOwnPropertyDescriptor(HTMLInputElement.prototype,`checked`)?.set?.call(e,t),md(e))}function _d(e,t){let[n]=e,r=ld(t),i=new Set(Array.isArray(t)?t.map(ld):[]);if(e.every(e=>id(e,`radio`))){let t=e.find(e=>e.value===r);t&&gd(t,!0)}else if(e.length>1)for(let t of e)t instanceof HTMLInputElement&&gd(t,i.has(t.value));else if(n instanceof HTMLSelectElement)if(n.multiple){let e=!1;for(let t of n.options){let n=i.has(t.value);t.selected!==n&&(t.selected=n,e=!0)}e&&md(n)}else r!==void 0&&n.value!==r&&(n.value=r,md(n));else if(n&&id(n,`checkbox`)){let e=ud(t);e!==void 0&&gd(n,e)}else n&&r!==void 0&&hd(n,r)}function vd(e,t){if(Array.isArray(t))throw q();let n=Gu(e),r=[];for(let[i,a]of Object.entries(t)){let t=n.get(i);if(!t||!pd(e,t,a))throw q();r.push({controls:t,value:a})}for(let{controls:e,value:t}of r)_d(e,t)}function yd(e){return[...Lu(e)].find(e=>!e.matches(`:disabled`)&&(e instanceof HTMLButtonElement&&e.type===`submit`||e instanceof HTMLInputElement&&[`image`,`submit`].includes(e.type)))}function bd(e,t){let n=new Event(e);return Object.defineProperty(n,"toolName",{enumerable:!0,value:t}),n}function xd(e,t,n,r,i){let{form:a}=t;return t.cancelPending?.(q()),new Promise((o,s)=>{let c=!1,l=()=>{EventTarget.prototype.removeEventListener.call(a,`invalid`,p,!0),i.removeEventListener(`abort`,m),ju.delete(a),t.cancelPending===d&&delete t.cancelPending},u=e=>{c||(c=!0,l(),e())},d=e=>u(()=>s(e)),f=e=>{t.cancelPending===d&&delete t.cancelPending,e.then(e=>u(()=>o(e??null)),e=>u(()=>s(e)))},p=e=>{e.isTrusted&&queueMicrotask(()=>{Hu(a)||d(q())})},m=()=>{u(()=>{e.dispatchEvent(bd(`toolcancel`,n.name)),s(i.reason)})};if(ju.set(a,{complete(e){setTimeout(()=>{let t=Au.get(e);t?f(t):e.defaultPrevented?d(q()):u(()=>o(null))})},direct(){u(()=>o(null))},respond(e){queueMicrotask(()=>{let t=Au.get(e);t&&f(t)})}}),t.cancelPending=d,EventTarget.prototype.addEventListener.call(a,`invalid`,p,!0),i.addEventListener(`abort`,m,{once:!0}),!n.autosubmit){r?.focus(),e.dispatchEvent(bd(`toolactivated`,n.name));return}try{Uu(a,r),e.dispatchEvent(bd(`toolactivated`,n.name))}catch(e){d(e)}})}function Sd(e){let t=SubmitEvent.prototype;if(`agentInvoked`in t&&`respondWith`in t)return;`agentInvoked`in t||Object.defineProperty(t,"agentInvoked",{configurable:!0,enumerable:!0,get(){return Mu(this)}}),`respondWith`in t||Object.defineProperty(t,"respondWith",{configurable:!0,enumerable:!0,writable:!0,value(e){Nu(this,e)}});let n=new Map,r=new Map,i=new Map,a=e=>{if(!(e instanceof SubmitEvent)||!e.isTrusted||!(e.target instanceof HTMLFormElement))return;let t=ju.get(e.target);t&&(ku.add(e),t.complete(e))},o=e=>{if(!e.isTrusted||!(e.target instanceof HTMLFormElement))return;let t=e.target;setTimeout(()=>{e.defaultPrevented||n.get(t)?.cancelPending?.(q())})};function s(e){i.get(e)?.disconnect(),i.delete(e),e.removeEventListener(`reset`,o,!0),e.removeEventListener(`submit`,a,!0)}function c(e){if(i.has(e))return;let t=new MutationObserver(l);i.set(e,t),t.observe(e,{attributes:!0,characterData:!0,childList:!0,subtree:!0}),e.addEventListener(`reset`,o,!0),e.addEventListener(`submit`,a,!0)}function l(){c(document);for(let e of i.keys())e instanceof ShadowRoot&&!e.host.isConnected&&s(e);let t=new Set,a=new Map,o=new Map;for(let e of i.keys())for(let n of e.querySelectorAll(`*`)){let e=Vu(n);if(e&&c(e),!(n instanceof HTMLFormElement)||!zu(n,`toolname`)||!zu(n,`tooldescription`)||!Bu(n))continue;let i=n;t.add(i);let s=cd(i),l=JSON.stringify(s),u=r.get(i);if(u===l)continue;r.delete(i);let d=o.get(s.name);if(d){if(u===void 0){r.set(i,l);continue}let e=a.get(d);e&&r.set(d,e.fingerprint),a.delete(d)}o.set(s.name,i),a.set(i,{definition:s,fingerprint:l})}for(let e of r.keys())t.has(e)||r.delete(e);for(let[e,t]of n)a.get(e)?.fingerprint!==t.fingerprint&&(t.cancelPending?.(q()),t.controller.abort(),n.delete(e));for(let[t,{definition:r,fingerprint:i}]of a){if(n.has(t))continue;let a=new AbortController,o={controller:a,fingerprint:i,form:t};n.set(t,o),e.registerTool({name:r.name,title:r.title,description:r.description,inputSchema:r.inputSchema,execute(n,i){let a=yd(t);if(!r.autosubmit&&!a)throw q();return vd(t,n),xd(e,o,r,a,i.signal)}},{signal:a.signal}).catch(e=>{a.abort(),!(e instanceof DOMException&&e.name===`AbortError`)&&console.error(`[webmcp] declarative form tool "${r.name}" was not registered:`,e)})}}let u=Object.getOwnPropertyDescriptor(Element.prototype,`attachShadow`);if(u?.configurable){let e=Element.prototype.attachShadow,t=function(t){let n=e.call(this,t);return n.mode===`open`&&Object.getOwnPropertyDescriptor(Node.prototype,`ownerDocument`)?.get?.call(this)===document&&Bu(this)&&c(n),n};Object.defineProperty(Element.prototype,"attachShadow",{...u,value:t})}let d=Object.getOwnPropertyDescriptor(HTMLFormElement.prototype,`submit`);if(d?.configurable){let e=HTMLFormElement.prototype.submit,t=function(){e.call(this),ju.get(this)?.direct()};Object.defineProperty(HTMLFormElement.prototype,"submit",{...d,value:t})}l()}
64
+ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let n of e.seen.entries()){let r=n[1];if(t===n[0]){a(n);continue}if(e.external){let r=e.external.registry.get(n[0])?.id;if(t!==n[0]&&r){a(n);continue}}if(e.metadataRegistry.get(n[0])?.id){a(n);continue}if(r.cycle){a(n);continue}if(r.count>1&&e.reused===`ref`){a(n);continue}}}function ci(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=t=>{let n=e.seen.get(t);if(n.ref===null)return;let i=n.def??n.schema,a={...i},o=n.ref;if(n.ref=null,o){r(o);let n=e.seen.get(o),s=n.schema;if(s.$ref&&(e.target===`draft-07`||e.target===`draft-04`||e.target===`openapi-3.0`)?(i.allOf=i.allOf??[],i.allOf.push(s)):Object.assign(i,s),Object.assign(i,a),t._zod.parent===o)for(let e in i)e===`$ref`||e===`allOf`||e in a||delete i[e];if(s.$ref&&n.def)for(let e in i)e===`$ref`||e===`allOf`||e in n.def&&JSON.stringify(i[e])===JSON.stringify(n.def[e])&&delete i[e]}let s=t._zod.parent;if(s&&s!==o){r(s);let t=e.seen.get(s);if(t?.schema.$ref&&(i.$ref=t.schema.$ref,t.def))for(let e in i)e===`$ref`||e===`allOf`||e in t.def&&JSON.stringify(i[e])===JSON.stringify(t.def[e])&&delete i[e]}e.override({zodSchema:t,jsonSchema:i,path:n.path??[]})};for(let t of[...e.seen.entries()].reverse())r(t[0]);let i={};if(e.target===`draft-2020-12`?i.$schema=`https://json-schema.org/draft/2020-12/schema`:e.target===`draft-07`?i.$schema=`http://json-schema.org/draft-07/schema#`:e.target===`draft-04`?i.$schema=`http://json-schema.org/draft-04/schema#`:e.target,e.external?.uri){let n=e.external.registry.get(t)?.id;if(!n)throw Error("Schema is missing an `id` property");i.$id=e.external.uri(n)}Object.assign(i,n.def??n.schema);let a=e.metadataRegistry.get(t)?.id;a!==void 0&&i.id===a&&delete i.id;let o=e.external?.defs??{};for(let t of e.seen.entries()){let e=t[1];e.def&&e.defId&&(e.def.id===e.defId&&delete e.def.id,o[e.defId]=e.def)}e.external||Object.keys(o).length>0&&(e.target===`draft-2020-12`?i.$defs=o:i.definitions=o);try{let n=JSON.parse(JSON.stringify(i));return Object.defineProperty(n,"~standard",{value:{...t[`~standard`],jsonSchema:{input:di(t,`input`,e.processors),output:di(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function li(e,t){let n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);let r=e._zod.def;if(r.type===`transform`)return!0;if(r.type===`array`)return li(r.element,n);if(r.type===`set`)return li(r.valueType,n);if(r.type===`lazy`)return li(r.getter(),n);if(r.type===`promise`||r.type===`optional`||r.type===`nonoptional`||r.type===`nullable`||r.type===`readonly`||r.type==="default"||r.type===`prefault`)return li(r.innerType,n);if(r.type===`intersection`)return li(r.left,n)||li(r.right,n);if(r.type===`record`||r.type===`map`)return li(r.keyType,n)||li(r.valueType,n);if(r.type===`pipe`)return e._zod.traits.has(`$ZodCodec`)?!0:li(r.in,n)||li(r.out,n);if(r.type===`object`){for(let e in r.shape)if(li(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(li(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(li(e,n))return!0;return!!(r.rest&&li(r.rest,n))}return!1}let ui=(e,t={})=>n=>{let r=oi({...n,processors:t});return D(e,r),si(r,e),ci(r,e)},di=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=oi({...i??{},target:a,io:t,processors:n});return D(e,o),si(o,e),ci(o,e)},fi={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},pi=(e,t,n,r)=>{let i=n;i.type=`string`;let{minimum:a,maximum:o,format:s,patterns:c,contentEncoding:l}=e._zod.bag;if(typeof a==`number`&&(i.minLength=a),typeof o==`number`&&(i.maxLength=o),s&&(i.format=fi[s]??s,i.format===``&&delete i.format,s===`time`&&delete i.format),l&&(i.contentEncoding=l),c&&c.size>0){let e=[...c];e.length===1?i.pattern=e[0].source:e.length>1&&(i.allOf=[...e.map(e=>({...t.target===`draft-07`||t.target===`draft-04`||t.target===`openapi-3.0`?{type:`string`}:{},pattern:e.source}))])}},mi=(e,t,n,r)=>{let i=n,{minimum:a,maximum:o,format:s,multipleOf:c,exclusiveMaximum:l,exclusiveMinimum:u}=e._zod.bag;typeof s==`string`&&s.includes(`int`)?i.type=`integer`:i.type=`number`;let d=typeof u==`number`&&u>=(a??-1/0),f=typeof l==`number`&&l<=(o??1/0),p=t.target===`draft-04`||t.target===`openapi-3.0`;d?p?(i.minimum=u,i.exclusiveMinimum=!0):i.exclusiveMinimum=u:typeof a==`number`&&(i.minimum=a),f?p?(i.maximum=l,i.exclusiveMaximum=!0):i.exclusiveMaximum=l:typeof o==`number`&&(i.maximum=o),typeof c==`number`&&(i.multipleOf=c)},hi=(e,t,n,r)=>{n.type=`boolean`},gi=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`BigInt cannot be represented in JSON Schema`)},_i=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Symbols cannot be represented in JSON Schema`)},vi=(e,t,n,r)=>{t.target===`openapi-3.0`?(n.type=`string`,n.nullable=!0,n.enum=[null]):n.type=`null`},yi=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Undefined cannot be represented in JSON Schema`)},bi=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Void cannot be represented in JSON Schema`)},xi=(e,t,n,r)=>{n.not={}},Si=(e,t,n,r)=>{},Ci=(e,t,n,r)=>{},wi=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Date cannot be represented in JSON Schema`)},Ti=(e,t,n,r)=>{let i=e._zod.def,a=c(i.entries);a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=a},Ei=(e,t,n,r)=>{let i=e._zod.def,a=[];for(let e of i.values)if(e===void 0){if(t.unrepresentable===`throw`)throw Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof e==`bigint`){if(t.unrepresentable===`throw`)throw Error(`BigInt literals cannot be represented in JSON Schema`);a.push(Number(e))}else a.push(e);if(a.length!==0)if(a.length===1){let e=a[0];n.type=e===null?`null`:typeof e,t.target===`draft-04`||t.target===`openapi-3.0`?n.enum=[e]:n.const=e}else a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),a.every(e=>typeof e==`boolean`)&&(n.type=`boolean`),a.every(e=>e===null)&&(n.type=`null`),n.enum=a},Di=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`NaN cannot be represented in JSON Schema`)},Oi=(e,t,n,r)=>{let i=n,a=e._zod.pattern;if(!a)throw Error(`Pattern not found in template literal`);i.type=`string`,i.pattern=a.source},ki=(e,t,n,r)=>{let i=n,a={type:`string`,format:`binary`,contentEncoding:`binary`},{minimum:o,maximum:s,mime:c}=e._zod.bag;o!==void 0&&(a.minLength=o),s!==void 0&&(a.maxLength=s),c?c.length===1?(a.contentMediaType=c[0],Object.assign(i,a)):(Object.assign(i,a),i.anyOf=c.map(e=>({contentMediaType:e}))):Object.assign(i,a)},Ai=(e,t,n,r)=>{n.type=`boolean`},ji=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Custom types cannot be represented in JSON Schema`)},Mi=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Function types cannot be represented in JSON Schema`)},Ni=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Transforms cannot be represented in JSON Schema`)},Pi=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Map cannot be represented in JSON Schema`)},Fi=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Set cannot be represented in JSON Schema`)},Ii=(e,t,n,r)=>{let i=n,a=e._zod.def,{minimum:o,maximum:s}=e._zod.bag;typeof o==`number`&&(i.minItems=o),typeof s==`number`&&(i.maxItems=s),i.type=`array`,i.items=D(a.element,t,{...r,path:[...r.path,`items`]})},Li=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`,i.properties={};let o=a.shape;for(let e in o)i.properties[e]=D(o[e],t,{...r,path:[...r.path,`properties`,e]});let s=new Set(Object.keys(o)),c=new Set([...s].filter(e=>{let n=a.shape[e]._zod;return t.io===`input`?n.optin===void 0:n.optout===void 0}));c.size>0&&(i.required=Array.from(c)),a.catchall?._zod.def.type===`never`?i.additionalProperties=!1:a.catchall?a.catchall&&(i.additionalProperties=D(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},Ri=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>D(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},zi=(e,t,n,r)=>{let i=e._zod.def,a=D(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=D(i.right,t,{...r,path:[...r.path,`allOf`,1]}),s=e=>`allOf`in e&&Object.keys(e).length===1;n.allOf=[...s(a)?a.allOf:[a],...s(o)?o.allOf:[o]]},Bi=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`array`;let o=t.target===`draft-2020-12`?`prefixItems`:`items`,s=t.target===`draft-2020-12`||t.target===`openapi-3.0`?`items`:`additionalItems`,c=a.items.map((e,n)=>D(e,t,{...r,path:[...r.path,o,n]})),l=a.rest?D(a.rest,t,{...r,path:[...r.path,s,...t.target===`openapi-3.0`?[a.items.length]:[]]}):null;t.target===`draft-2020-12`?(i.prefixItems=c,l&&(i.items=l)):t.target===`openapi-3.0`?(i.items={anyOf:c},l&&i.items.anyOf.push(l),i.minItems=c.length,l||(i.maxItems=c.length)):(i.items=c,l&&(i.additionalItems=l));let{minimum:u,maximum:d}=e._zod.bag;typeof u==`number`&&(i.minItems=u),typeof d==`number`&&(i.maxItems=d)},Vi=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`;let o=a.keyType,s=o._zod.bag?.patterns;if(a.mode===`loose`&&s&&s.size>0){let e=D(a.valueType,t,{...r,path:[...r.path,`patternProperties`,`*`]});i.patternProperties={};for(let t of s)i.patternProperties[t.source]=e}else (t.target===`draft-07`||t.target===`draft-2020-12`)&&(i.propertyNames=D(a.keyType,t,{...r,path:[...r.path,`propertyNames`]})),i.additionalProperties=D(a.valueType,t,{...r,path:[...r.path,`additionalProperties`]});let c=o._zod.values;if(c){let e=[...c].filter(e=>typeof e==`string`||typeof e==`number`);e.length>0&&(i.required=e)}},Hi=(e,t,n,r)=>{let i=e._zod.def,a=D(i.innerType,t,r),o=t.seen.get(e);t.target===`openapi-3.0`?(o.ref=i.innerType,n.nullable=!0):n.anyOf=[a,{type:`null`}]},Ui=(e,t,n,r)=>{let i=e._zod.def;D(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},Wi=(e,t,n,r)=>{let i=e._zod.def;D(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.default=JSON.parse(JSON.stringify(i.defaultValue))},Gi=(e,t,n,r)=>{let i=e._zod.def;D(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,t.io===`input`&&(n._prefault=JSON.parse(JSON.stringify(i.defaultValue)))},Ki=(e,t,n,r)=>{let i=e._zod.def;D(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{throw Error(`Dynamic catch values are not supported in JSON Schema`)}n.default=o},qi=(e,t,n,r)=>{let i=e._zod.def,a=i.in._zod.traits.has(`$ZodTransform`),o=t.io===`input`?a?i.out:i.in:i.out;D(o,t,r);let s=t.seen.get(e);s.ref=o},Ji=(e,t,n,r)=>{let i=e._zod.def;D(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},Yi=(e,t,n,r)=>{let i=e._zod.def;D(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},Xi=(e,t,n,r)=>{let i=e._zod.def;D(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},Zi=(e,t,n,r)=>{let i=e._zod.innerType;D(i,t,r);let a=t.seen.get(e);a.ref=i},Qi={string:pi,number:mi,boolean:hi,bigint:gi,symbol:_i,null:vi,undefined:yi,void:bi,never:xi,any:Si,unknown:Ci,date:wi,enum:Ti,literal:Ei,nan:Di,template_literal:Oi,file:ki,success:Ai,custom:ji,function:Mi,transform:Ni,map:Pi,set:Fi,array:Ii,object:Li,union:Ri,intersection:zi,tuple:Bi,record:Vi,nullable:Hi,nonoptional:Ui,default:Wi,prefault:Gi,catch:Ki,pipe:qi,readonly:Ji,promise:Yi,optional:Xi,lazy:Zi};function $i(e,t){if(`_idmap`in e){let n=e,r=oi({...t,processors:Qi}),i={};for(let e of n._idmap.entries()){let[t,n]=e;D(n,r)}let a={};r.external={registry:n,uri:t?.uri,defs:i};for(let e of n._idmap.entries()){let[t,n]=e;si(r,n),a[t]=ci(r,n)}return Object.keys(i).length>0&&(a.__shared={[r.target===`draft-2020-12`?`$defs`:`definitions`]:i}),{schemas:a}}let n=oi({...t,processors:Qi});return D(e,n),si(n,e),ci(n,e)}let ea=r(`ZodISODateTime`,(e,t)=>{qt.init(e,t),A.init(e,t)});function ta(e){return wr(ea,e)}let na=r(`ZodISODate`,(e,t)=>{Jt.init(e,t),A.init(e,t)});function ra(e){return Tr(na,e)}let ia=r(`ZodISOTime`,(e,t)=>{Yt.init(e,t),A.init(e,t)});function aa(e){return Er(ia,e)}let oa=r(`ZodISODuration`,(e,t)=>{Xt.init(e,t),A.init(e,t)});function sa(e){return Dr(oa,e)}let ca=r(`ZodError`,(e,t)=>{Te.init(e,t),e.name=`ZodError`,Object.defineProperties(e,{format:{value:t=>De(e,t)},flatten:{value:t=>Ee(e,t)},addIssue:{value:t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,l,2)}},addIssues:{value:t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,l,2)}},isEmpty:{get(){return e.issues.length===0}}})},{Parent:Error}),la=Oe(ca),ua=ke(ca),da=Ae(ca),fa=Me(ca),pa=S(ca),ma=Pe(ca),ha=Fe(ca),ga=Ie(ca),_a=Le(ca),va=Re(ca),ya=ze(ca),ba=Be(ca),xa=new WeakMap;function Sa(e,t,n){let r=Object.getPrototypeOf(e),i=xa.get(r);if(i||(i=new Set,xa.set(r,i)),!i.has(t)){i.add(t);for(let e in n){let t=n[e];Object.defineProperty(r,e,{configurable:!0,enumerable:!1,get(){let n=t.bind(this);return Object.defineProperty(this,e,{configurable:!0,writable:!0,enumerable:!0,value:n}),n},set(t){Object.defineProperty(this,e,{configurable:!0,writable:!0,enumerable:!0,value:t})}})}}}let O=r(`ZodType`,(e,t)=>(T.init(e,t),Object.assign(e[`~standard`],{jsonSchema:{input:di(e,`input`),output:di(e,`output`)}}),e.toJSONSchema=ui(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.parse=(t,n)=>la(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>da(e,t,n),e.parseAsync=async(t,n)=>ua(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>fa(e,t,n),e.spa=e.safeParseAsync,e.encode=(t,n)=>pa(e,t,n),e.decode=(t,n)=>ma(e,t,n),e.encodeAsync=async(t,n)=>ha(e,t,n),e.decodeAsync=async(t,n)=>ga(e,t,n),e.safeEncode=(t,n)=>_a(e,t,n),e.safeDecode=(t,n)=>va(e,t,n),e.safeEncodeAsync=async(t,n)=>ya(e,t,n),e.safeDecodeAsync=async(t,n)=>ba(e,t,n),Sa(e,`ZodType`,{check(...e){let t=this.def;return this.clone(_(t,{checks:[...t.checks??[],...e.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return le(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(Lo(e,t))},superRefine(e,t){return this.check(Ro(e,t))},overwrite(e){return this.check(Xr(e))},optional(){return V(this)},exactOptional(){return vo(this)},nullable(){return bo(this)},nullish(){return V(bo(this))},nonoptional(e){return Eo(this,e)},array(){return P(this)},or(e){return L([this,e])},and(e){return lo(this,e)},transform(e){return Ao(this,ho(e))},default(e){return So(this,e)},prefault(e){return wo(this,e)},catch(e){return Oo(this,e)},pipe(e){return Ao(this,e)},readonly(){return No(this)},describe(e){let t=this.clone();return er.add(t,{description:e}),t},meta(...e){if(e.length===0)return er.get(this);let t=this.clone();return er.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e){return e(this)}}),Object.defineProperty(e,"description",{get(){return er.get(e)?.description},configurable:!0}),e)),Ca=r(`_ZodString`,(e,t)=>{Ft.init(e,t),O.init(e,t),e._zod.processJSONSchema=(t,n,r)=>pi(e,t,n,r);let n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,Sa(e,`_ZodString`,{regex(...e){return this.check(Wr(...e))},includes(...e){return this.check(qr(...e))},startsWith(...e){return this.check(Jr(...e))},endsWith(...e){return this.check(Yr(...e))},min(...e){return this.check(Hr(...e))},max(...e){return this.check(Vr(...e))},length(...e){return this.check(Ur(...e))},nonempty(...e){return this.check(Hr(1,...e))},lowercase(e){return this.check(Gr(e))},uppercase(e){return this.check(Kr(e))},trim(){return this.check(Qr())},normalize(...e){return this.check(Zr(...e))},toLowerCase(){return this.check($r())},toUpperCase(){return this.check(ei())},slugify(){return this.check(ti())}})}),wa=r(`ZodString`,(e,t)=>{Ft.init(e,t),Ca.init(e,t),e.email=t=>e.check(nr(Ta,t)),e.url=t=>e.check(cr(ka,t)),e.jwt=t=>e.check(Cr(Ga,t)),e.emoji=t=>e.check(lr(ja,t)),e.guid=t=>e.check(rr(Da,t)),e.uuid=t=>e.check(ir(Oa,t)),e.uuidv4=t=>e.check(ar(Oa,t)),e.uuidv6=t=>e.check(or(Oa,t)),e.uuidv7=t=>e.check(sr(Oa,t)),e.nanoid=t=>e.check(ur(Ma,t)),e.guid=t=>e.check(rr(Da,t)),e.cuid=t=>e.check(dr(Na,t)),e.cuid2=t=>e.check(fr(Pa,t)),e.ulid=t=>e.check(pr(Fa,t)),e.base64=t=>e.check(br(Ha,t)),e.base64url=t=>e.check(xr(Ua,t)),e.xid=t=>e.check(mr(Ia,t)),e.ksuid=t=>e.check(hr(La,t)),e.ipv4=t=>e.check(gr(Ra,t)),e.ipv6=t=>e.check(_r(za,t)),e.cidrv4=t=>e.check(vr(Ba,t)),e.cidrv6=t=>e.check(yr(Va,t)),e.e164=t=>e.check(Sr(Wa,t)),e.datetime=t=>e.check(ta(t)),e.date=t=>e.check(ra(t)),e.time=t=>e.check(aa(t)),e.duration=t=>e.check(sa(t))});function k(e){return tr(wa,e)}let A=r(`ZodStringFormat`,(e,t)=>{E.init(e,t),Ca.init(e,t)}),Ta=r(`ZodEmail`,(e,t)=>{Rt.init(e,t),A.init(e,t)});function Ea(e){return nr(Ta,e)}let Da=r(`ZodGUID`,(e,t)=>{It.init(e,t),A.init(e,t)}),Oa=r(`ZodUUID`,(e,t)=>{Lt.init(e,t),A.init(e,t)}),ka=r(`ZodURL`,(e,t)=>{zt.init(e,t),A.init(e,t)});function Aa(e){return cr(ka,e)}let ja=r(`ZodEmoji`,(e,t)=>{Bt.init(e,t),A.init(e,t)}),Ma=r(`ZodNanoID`,(e,t)=>{Vt.init(e,t),A.init(e,t)}),Na=r(`ZodCUID`,(e,t)=>{Ht.init(e,t),A.init(e,t)}),Pa=r(`ZodCUID2`,(e,t)=>{Ut.init(e,t),A.init(e,t)}),Fa=r(`ZodULID`,(e,t)=>{Wt.init(e,t),A.init(e,t)}),Ia=r(`ZodXID`,(e,t)=>{Gt.init(e,t),A.init(e,t)}),La=r(`ZodKSUID`,(e,t)=>{Kt.init(e,t),A.init(e,t)}),Ra=r(`ZodIPv4`,(e,t)=>{Zt.init(e,t),A.init(e,t)}),za=r(`ZodIPv6`,(e,t)=>{Qt.init(e,t),A.init(e,t)}),Ba=r(`ZodCIDRv4`,(e,t)=>{$t.init(e,t),A.init(e,t)}),Va=r(`ZodCIDRv6`,(e,t)=>{en.init(e,t),A.init(e,t)}),Ha=r(`ZodBase64`,(e,t)=>{nn.init(e,t),A.init(e,t)}),Ua=r(`ZodBase64URL`,(e,t)=>{an.init(e,t),A.init(e,t)}),Wa=r(`ZodE164`,(e,t)=>{on.init(e,t),A.init(e,t)}),Ga=r(`ZodJWT`,(e,t)=>{cn.init(e,t),A.init(e,t)}),Ka=r(`ZodNumber`,(e,t)=>{ln.init(e,t),O.init(e,t),e._zod.processJSONSchema=(t,n,r)=>mi(e,t,n,r),Sa(e,`ZodNumber`,{gt(e,t){return this.check(Rr(e,t))},gte(e,t){return this.check(zr(e,t))},min(e,t){return this.check(zr(e,t))},lt(e,t){return this.check(Ir(e,t))},lte(e,t){return this.check(Lr(e,t))},max(e,t){return this.check(Lr(e,t))},int(e){return this.check(Ja(e))},safe(e){return this.check(Ja(e))},positive(e){return this.check(Rr(0,e))},nonnegative(e){return this.check(zr(0,e))},negative(e){return this.check(Ir(0,e))},nonpositive(e){return this.check(Lr(0,e))},multipleOf(e,t){return this.check(Br(e,t))},step(e,t){return this.check(Br(e,t))},finite(){return this}});let n=e._zod.bag;e.minValue=Math.max(n.minimum??-1/0,n.exclusiveMinimum??-1/0)??null,e.maxValue=Math.min(n.maximum??1/0,n.exclusiveMaximum??1/0)??null,e.isInt=(n.format??``).includes(`int`)||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null});function j(e){return Or(Ka,e)}let qa=r(`ZodNumberFormat`,(e,t)=>{un.init(e,t),Ka.init(e,t)});function Ja(e){return Ar(qa,e)}let Ya=r(`ZodBoolean`,(e,t)=>{dn.init(e,t),O.init(e,t),e._zod.processJSONSchema=(t,n,r)=>hi(e,t,n,r)});function M(e){return jr(Ya,e)}let Xa=r(`ZodNull`,(e,t)=>{fn.init(e,t),O.init(e,t),e._zod.processJSONSchema=(t,n,r)=>vi(e,t,n,r)});function Za(e){return Mr(Xa,e)}let Qa=r(`ZodAny`,(e,t)=>{pn.init(e,t),O.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function $a(){return Nr(Qa)}let eo=r(`ZodUnknown`,(e,t)=>{mn.init(e,t),O.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function N(){return Pr(eo)}let to=r(`ZodNever`,(e,t)=>{hn.init(e,t),O.init(e,t),e._zod.processJSONSchema=(t,n,r)=>xi(e,t,n,r)});function no(e){return Fr(to,e)}let ro=r(`ZodArray`,(e,t)=>{_n.init(e,t),O.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ii(e,t,n,r),e.element=t.element,Sa(e,`ZodArray`,{min(e,t){return this.check(Hr(e,t))},nonempty(e){return this.check(Hr(1,e))},max(e,t){return this.check(Vr(e,t))},length(e,t){return this.check(Ur(e,t))},unwrap(){return this.element}})});function P(e,t){return ni(ro,e,t)}let io=r(`ZodObject`,(e,t)=>{Sn.init(e,t),O.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Li(e,t,n,r),h(e,`shape`,()=>t.shape),Sa(e,`ZodObject`,{keyof(){return z(Object.keys(this._zod.def.shape))},catchall(e){return this.clone({...this._zod.def,catchall:e})},passthrough(){return this.clone({...this._zod.def,catchall:N()})},loose(){return this.clone({...this._zod.def,catchall:N()})},strict(){return this.clone({...this._zod.def,catchall:no()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(e){return me(this,e)},safeExtend(e){return he(this,e)},merge(e){return ge(this,e)},pick(e){return fe(this,e)},omit(e){return pe(this,e)},partial(...e){return _e(go,this,e[0])},required(...e){return ve(To,this,e[0])}})});function F(e,t){return new io({type:`object`,shape:e??{},...v(t)})}function I(e,t){return new io({type:`object`,shape:e,catchall:N(),...v(t)})}let ao=r(`ZodUnion`,(e,t)=>{wn.init(e,t),O.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ri(e,t,n,r),e.options=t.options});function L(e,t){return new ao({type:`union`,options:e,...v(t)})}let oo=r(`ZodDiscriminatedUnion`,(e,t)=>{ao.init(e,t),Tn.init(e,t)});function so(e,t,n){return new oo({type:`union`,options:t,discriminator:e,...v(n)})}let co=r(`ZodIntersection`,(e,t)=>{En.init(e,t),O.init(e,t),e._zod.processJSONSchema=(t,n,r)=>zi(e,t,n,r)});function lo(e,t){return new co({type:`intersection`,left:e,right:t})}let uo=r(`ZodRecord`,(e,t)=>{kn.init(e,t),O.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Vi(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType});function R(e,t,n){return!t||!t._zod?new uo({type:`record`,keyType:k(),valueType:e,...v(t)}):new uo({type:`record`,keyType:e,valueType:t,...v(n)})}let fo=r(`ZodEnum`,(e,t)=>{An.init(e,t),O.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ti(e,t,n,r),e.enum=t.entries,e.options=Object.values(t.entries);let n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{let i={};for(let r of e)if(n.has(r))i[r]=t.entries[r];else throw Error(`Key ${r} not found in enum`);return new fo({...t,checks:[],...v(r),entries:i})},e.exclude=(e,r)=>{let i={...t.entries};for(let t of e)if(n.has(t))delete i[t];else throw Error(`Key ${t} not found in enum`);return new fo({...t,checks:[],...v(r),entries:i})}});function z(e,t){return new fo({type:`enum`,entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...v(t)})}let po=r(`ZodLiteral`,(e,t)=>{jn.init(e,t),O.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ei(e,t,n,r),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function B(e,t){return new po({type:`literal`,values:Array.isArray(e)?e:[e],...v(t)})}let mo=r(`ZodTransform`,(e,t)=>{Mn.init(e,t),O.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ni(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new a(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(Ce(r,n.value,t));else{let t=r;t.fatal&&(t.continue=!1),t.code??=`custom`,t.input??=n.value,t.inst??=e,n.issues.push(Ce(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n.fallback=!0,n)):(n.value=i,n.fallback=!0,n)}});function ho(e){return new mo({type:`transform`,transform:e})}let go=r(`ZodOptional`,(e,t)=>{Pn.init(e,t),O.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Xi(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function V(e){return new go({type:`optional`,innerType:e})}let _o=r(`ZodExactOptional`,(e,t)=>{Fn.init(e,t),O.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Xi(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function vo(e){return new _o({type:`optional`,innerType:e})}let yo=r(`ZodNullable`,(e,t)=>{In.init(e,t),O.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Hi(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function bo(e){return new yo({type:`nullable`,innerType:e})}let xo=r(`ZodDefault`,(e,t)=>{Ln.init(e,t),O.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Wi(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function So(e,t){return new xo({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():oe(t)}})}let Co=r(`ZodPrefault`,(e,t)=>{zn.init(e,t),O.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Gi(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function wo(e,t){return new Co({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():oe(t)}})}let To=r(`ZodNonOptional`,(e,t)=>{Bn.init(e,t),O.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ui(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Eo(e,t){return new To({type:`nonoptional`,innerType:e,...v(t)})}let Do=r(`ZodCatch`,(e,t)=>{Hn.init(e,t),O.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ki(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function Oo(e,t){return new Do({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:()=>t})}let ko=r(`ZodPipe`,(e,t)=>{Un.init(e,t),O.init(e,t),e._zod.processJSONSchema=(t,n,r)=>qi(e,t,n,r),e.in=t.in,e.out=t.out});function Ao(e,t){return new ko({type:`pipe`,in:e,out:t})}let jo=r(`ZodPreprocess`,(e,t)=>{ko.init(e,t),Gn.init(e,t)}),Mo=r(`ZodReadonly`,(e,t)=>{Kn.init(e,t),O.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ji(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function No(e){return new Mo({type:`readonly`,innerType:e})}let Po=r(`ZodLazy`,(e,t)=>{Jn.init(e,t),O.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Zi(e,t,n,r),e.unwrap=()=>e._zod.def.getter()});function Fo(e){return new Po({type:`lazy`,getter:e})}let Io=r(`ZodCustom`,(e,t)=>{Yn.init(e,t),O.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ji(e,t,n,r)});function Lo(e,t={}){return ri(Io,e,t)}function Ro(e,t){return ii(e,t)}function zo(e,t){return new jo({type:`pipe`,in:ho(e),out:t})}let Bo={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 Vo;Vo||={};function Ho(e){return kr(Ka,e)}let Uo=[`2025-11-25`,`2025-06-18`,`2025-03-26`,`2024-11-05`,`2024-10-07`],Wo=`io.modelcontextprotocol/protocolVersion`,Go=`io.modelcontextprotocol/clientInfo`,Ko=`io.modelcontextprotocol/serverInfo`,qo=`io.modelcontextprotocol/clientCapabilities`,Jo=`io.modelcontextprotocol/logLevel`,Yo=Fo(()=>L([k(),j(),M(),Za(),R(k(),Yo),P(Yo)])),H=R(k(),Yo),Xo=P(Yo),Zo=L([k(),j().int()]),Qo=k(),$o=F({ttl:j().optional()}),es=F({taskId:k()}),ts=I({progressToken:Zo.optional(),"io.modelcontextprotocol/related-task":es.optional()}),U=F({_meta:ts.optional()}),ns=U.extend({task:$o.optional()}),W=F({method:k(),params:U.loose().optional()}),rs=F({_meta:ts.optional()}),is=F({method:k(),params:rs.loose().optional()}),as=I({get[Ko](){return ys.optional().catch(void 0)}}),G=I({_meta:as.optional()}),os=L([k(),j().int()]),ss=F({jsonrpc:B(`2.0`),id:os,...W.shape}).strict(),cs=F({jsonrpc:B(`2.0`),...is.shape}).strict(),ls=F({jsonrpc:B(`2.0`),id:os,result:G}).strict(),us=F({jsonrpc:B(`2.0`),id:os.optional(),error:F({code:j().int(),message:k(),data:N().optional()})}).strict(),ds=L([ss,cs,ls,us]),fs=L([ls,us]),ps=G.strict(),ms=rs.extend({requestId:os.optional(),reason:k().optional()}),hs=is.extend({method:B(`notifications/cancelled`),params:ms}),gs=F({src:k(),mimeType:k().optional(),sizes:P(k()).optional(),theme:z([`light`,`dark`]).optional()}),_s=F({icons:P(gs).optional()}),vs=F({name:k(),title:k().optional()}),ys=vs.extend({...vs.shape,..._s.shape,version:k(),websiteUrl:k().optional(),description:k().optional()}),bs=zo(e=>e&&typeof e==`object`&&!Array.isArray(e)&&Object.keys(e).length===0?{form:{}}:e,lo(F({form:lo(F({applyDefaults:M().optional()}),H).optional(),url:H.optional()}),H.optional())),xs=I({list:H.optional(),cancel:H.optional(),requests:I({sampling:I({createMessage:H.optional()}).optional(),elicitation:I({create:H.optional()}).optional()}).optional()}),Ss=I({list:H.optional(),cancel:H.optional(),requests:I({tools:I({call:H.optional()}).optional()}).optional()}),Cs=F({experimental:R(k(),H).optional(),sampling:F({context:H.optional(),tools:H.optional()}).optional(),elicitation:bs.optional(),roots:F({listChanged:M().optional()}).optional(),tasks:xs.optional(),extensions:R(k(),H).optional()}),ws=U.extend({protocolVersion:k(),capabilities:Cs,clientInfo:ys}),Ts=W.extend({method:B(`initialize`),params:ws}),Es=F({experimental:R(k(),H).optional(),logging:H.optional(),completions:H.optional(),prompts:F({listChanged:M().optional()}).optional(),resources:F({subscribe:M().optional(),listChanged:M().optional()}).optional(),tools:F({listChanged:M().optional()}).optional(),tasks:Ss.optional(),extensions:R(k(),H).optional()}),Ds=G.extend({protocolVersion:k(),capabilities:Es,serverInfo:ys,instructions:k().optional()}),Os=is.extend({method:B(`notifications/initialized`),params:rs.optional()}),ks=W.extend({method:B(`server/discover`),params:U.optional()}),As=G.extend({supportedVersions:P(k()),capabilities:Es,instructions:k().optional()}),js=W.extend({method:B(`ping`),params:U.optional()}),Ms=F({progress:j(),total:V(j()),message:V(k())}),Ns=F({...rs.shape,...Ms.shape,progressToken:Zo}),Ps=is.extend({method:B(`notifications/progress`),params:Ns}),Fs=U.extend({cursor:Qo.optional()}),Is=W.extend({params:Fs.optional()}),Ls=G.extend({nextCursor:Qo.optional()}),Rs=F({uri:k(),mimeType:V(k()),_meta:R(k(),N()).optional()}),zs=Rs.extend({text:k()}),Bs=k().refine(e=>{try{return atob(e),!0}catch{return!1}},{message:`Invalid Base64 string`}),Vs=Rs.extend({blob:Bs}),Hs=z([`user`,`assistant`]),Us=F({audience:P(Hs).optional(),priority:j().min(0).max(1).optional(),lastModified:ta({offset:!0}).optional()}),Ws=F({...vs.shape,..._s.shape,uri:k(),description:V(k()),mimeType:V(k()),size:V(j()),annotations:Us.optional(),_meta:V(I({}))}),Gs=F({...vs.shape,..._s.shape,uriTemplate:k(),description:V(k()),mimeType:V(k()),annotations:Us.optional(),_meta:V(I({}))}),Ks=Is.extend({method:B(`resources/list`)}),qs=Ls.extend({resources:P(Ws)}),Js=Is.extend({method:B(`resources/templates/list`)}),Ys=Ls.extend({resourceTemplates:P(Gs)}),Xs=U.extend({uri:k()}),Zs=Xs,Qs=W.extend({method:B(`resources/read`),params:Zs}),$s=G.extend({contents:P(L([zs,Vs]))}),ec=is.extend({method:B(`notifications/resources/list_changed`),params:rs.optional()}),tc=Xs,nc=W.extend({method:B(`resources/subscribe`),params:tc}),rc=Xs,ic=W.extend({method:B(`resources/unsubscribe`),params:rc}),ac=F({toolsListChanged:M().optional(),promptsListChanged:M().optional(),resourcesListChanged:M().optional(),resourceSubscriptions:P(k()).optional()}),oc=U.extend({notifications:ac}),sc=W.extend({method:B(`subscriptions/listen`),params:oc}),cc=rs.extend({notifications:ac}),lc=is.extend({method:B(`notifications/subscriptions/acknowledged`),params:cc}),uc=as.extend({"io.modelcontextprotocol/subscriptionId":os}),dc=G.extend({_meta:uc}),fc=rs.extend({uri:k()}),pc=is.extend({method:B(`notifications/resources/updated`),params:fc}),mc=F({name:k(),description:V(k()),required:V(M())}),hc=F({...vs.shape,..._s.shape,description:V(k()),arguments:V(P(mc)),_meta:V(I({}))}),gc=Is.extend({method:B(`prompts/list`)}),_c=Ls.extend({prompts:P(hc)}),vc=U.extend({name:k(),arguments:R(k(),k()).optional()}),yc=W.extend({method:B(`prompts/get`),params:vc}),bc=F({type:B(`text`),text:k(),annotations:Us.optional(),_meta:R(k(),N()).optional()}),xc=F({type:B(`image`),data:Bs,mimeType:k(),annotations:Us.optional(),_meta:R(k(),N()).optional()}),Sc=F({type:B(`audio`),data:Bs,mimeType:k(),annotations:Us.optional(),_meta:R(k(),N()).optional()}),Cc=F({type:B(`tool_use`),name:k(),id:k(),input:R(k(),N()),_meta:R(k(),N()).optional()}),wc=F({type:B(`resource`),resource:L([zs,Vs]),annotations:Us.optional(),_meta:R(k(),N()).optional()}),Tc=Ws.extend({type:B(`resource_link`)}),Ec=L([bc,xc,Sc,Tc,wc]),Dc=F({role:Hs,content:Ec}),Oc=G.extend({description:k().optional(),messages:P(Dc)}),kc=is.extend({method:B(`notifications/prompts/list_changed`),params:rs.optional()}),Ac=F({title:k().optional(),readOnlyHint:M().optional(),destructiveHint:M().optional(),idempotentHint:M().optional(),openWorldHint:M().optional()}),jc=F({taskSupport:z([`required`,`optional`,`forbidden`]).optional()}),Mc=F({...vs.shape,..._s.shape,description:k().optional(),inputSchema:F({type:B(`object`),properties:R(k(),Yo).optional(),required:P(k()).optional()}).catchall(N()),outputSchema:I({$schema:k().optional()}).optional(),annotations:Ac.optional(),execution:jc.optional(),_meta:R(k(),N()).optional()}),Nc=Is.extend({method:B(`tools/list`)}),Pc=Ls.extend({tools:P(Mc)}),Fc=G.extend({content:P(Ec).default([]),structuredContent:N().optional(),isError:M().optional()}),Ic=Fc.or(G.extend({toolResult:N()})),Lc=ns.extend({name:k(),arguments:R(k(),N()).optional()}),Rc=W.extend({method:B(`tools/call`),params:Lc}),zc=is.extend({method:B(`notifications/tools/list_changed`),params:rs.optional()}),Bc=F({autoRefresh:M().default(!0),debounceMs:j().int().nonnegative().default(300)}),Vc=z([`debug`,`info`,`notice`,`warning`,`error`,`critical`,`alert`,`emergency`]),Hc=U.extend({level:Vc}),Uc=W.extend({method:B(`logging/setLevel`),params:Hc}),Wc=rs.extend({level:Vc,logger:k().optional(),data:N()}),Gc=is.extend({method:B(`notifications/message`),params:Wc}),Kc=F({name:k().optional()}),qc=F({hints:P(Kc).optional(),costPriority:j().min(0).max(1).optional(),speedPriority:j().min(0).max(1).optional(),intelligencePriority:j().min(0).max(1).optional()}),Jc=F({mode:z([`auto`,`required`,`none`]).optional()}),Yc=F({type:B(`tool_result`),toolUseId:k().describe(`The unique identifier for the corresponding tool call.`),content:P(Ec),structuredContent:N().optional(),isError:M().optional(),_meta:R(k(),N()).optional()}),Xc=so(`type`,[bc,xc,Sc]),Zc=so(`type`,[bc,xc,Sc,Cc,Yc]),Qc=F({role:Hs,content:L([Zc,P(Zc)]),_meta:R(k(),N()).optional()}),$c=ns.extend({messages:P(Qc),modelPreferences:qc.optional(),systemPrompt:k().optional(),includeContext:z([`none`,`thisServer`,`allServers`]).optional(),temperature:j().optional(),maxTokens:j().int(),stopSequences:P(k()).optional(),metadata:H.optional(),tools:P(Mc).optional(),toolChoice:Jc.optional()}),el=W.extend({method:B(`sampling/createMessage`),params:$c}),tl=G.extend({model:k(),stopReason:V(z([`endTurn`,`stopSequence`,`maxTokens`]).or(k())),role:Hs,content:Xc}),nl=G.extend({model:k(),stopReason:V(z([`endTurn`,`stopSequence`,`maxTokens`,`toolUse`]).or(k())),role:Hs,content:L([Zc,P(Zc)])}),rl=F({type:B(`boolean`),title:k().optional(),description:k().optional(),default:M().optional()}),il=F({type:B(`string`),title:k().optional(),description:k().optional(),minLength:j().optional(),maxLength:j().optional(),format:z([`email`,`uri`,`date`,`date-time`]).optional(),default:k().optional()}),al=F({type:z([`number`,`integer`]),title:k().optional(),description:k().optional(),minimum:j().optional(),maximum:j().optional(),default:j().optional()}),ol=F({type:B(`string`),title:k().optional(),description:k().optional(),enum:P(k()),default:k().optional()}),sl=F({type:B(`string`),title:k().optional(),description:k().optional(),oneOf:P(F({const:k(),title:k()})),default:k().optional()}),cl=F({type:B(`string`),title:k().optional(),description:k().optional(),enum:P(k()),enumNames:P(k()).optional(),default:k().optional()}),ll=L([ol,sl]),ul=F({type:B(`array`),title:k().optional(),description:k().optional(),minItems:j().optional(),maxItems:j().optional(),items:F({type:B(`string`),enum:P(k())}),default:P(k()).optional()}),dl=F({type:B(`array`),title:k().optional(),description:k().optional(),minItems:j().optional(),maxItems:j().optional(),items:F({anyOf:P(F({const:k(),title:k()}))}),default:P(k()).optional()}),fl=L([ul,dl]),pl=L([cl,ll,fl]),ml=L([pl,rl,il,al]),hl=ns.extend({mode:B(`form`).optional(),message:k(),requestedSchema:F({type:B(`object`),properties:R(k(),ml),required:P(k()).optional()}).catchall(N())}),gl=ns.extend({mode:B(`url`),message:k(),elicitationId:k(),url:k().url()}),_l=L([hl,gl]),vl=W.extend({method:B(`elicitation/create`),params:_l}),yl=rs.extend({elicitationId:k()}),bl=is.extend({method:B(`notifications/elicitation/complete`),params:yl}),xl=G.extend({action:z([`accept`,`decline`,`cancel`]),content:zo(e=>e===null?void 0:e,R(k(),L([k(),j(),M(),P(k())])).optional())}),Sl=F({type:B(`ref/resource`),uri:k()}),Cl=F({type:B(`ref/prompt`),name:k()}),wl=U.extend({ref:L([Cl,Sl]),argument:F({name:k(),value:k()}),context:F({arguments:R(k(),k()).optional()}).optional()}),Tl=W.extend({method:B(`completion/complete`),params:wl}),El=G.extend({completion:I({values:P(k()).max(100),total:V(j().int()),hasMore:V(M())})}),Dl=F({uri:k().startsWith(`file://`),name:k().optional(),_meta:R(k(),N()).optional()}),Ol=W.extend({method:B(`roots/list`),params:U.optional()}),kl=G.extend({roots:P(Dl)}),Al=is.extend({method:B(`notifications/roots/list_changed`),params:rs.optional()}),jl=I({ttl:j().optional(),pollInterval:j().optional()}),Ml=z([`working`,`input_required`,`completed`,`failed`,`cancelled`]),Nl=F({taskId:k(),status:Ml,ttl:L([j(),Za()]),createdAt:k(),lastUpdatedAt:k(),pollInterval:V(j()),statusMessage:V(k())}),Pl=G.extend({task:Nl}),Fl=rs.merge(Nl),Il=is.extend({method:B(`notifications/tasks/status`),params:Fl}),Ll=W.extend({method:B(`tasks/get`),params:U.extend({taskId:k()})}),Rl=G.merge(Nl),zl=W.extend({method:B(`tasks/result`),params:U.extend({taskId:k()})}),Bl=G.loose(),Vl=Is.extend({method:B(`tasks/list`)}),Hl=Ls.extend({tasks:P(Nl)}),Ul=W.extend({method:B(`tasks/cancel`),params:U.extend({taskId:k()})}),Wl=G.merge(Nl),Gl=L([js,Ts,ks,Tl,Uc,yc,gc,Ks,Js,Qs,nc,ic,sc,Rc,Nc]),Kl=L([hs,Ps,Os,Al]),ql=L([ps,tl,nl,xl,kl]),Jl=L([js,el,vl,Ol]),Yl=L([hs,Ps,Gc,pc,ec,zc,kc,lc,bl]),Xl=L([ps,Ds,As,El,Oc,_c,qs,Ys,$s,Fc,Pc,dc]),K=Aa().superRefine((e,t)=>{if(!URL.canParse(e))return t.addIssue({code:Bo.custom,message:`URL must be parseable`,fatal:!0}),n}).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`}),Zl=I({resource:k().url(),authorization_servers:P(K).optional(),jwks_uri:k().url().optional(),scopes_supported:P(k()).optional(),bearer_methods_supported:P(k()).optional(),resource_signing_alg_values_supported:P(k()).optional(),resource_name:k().optional(),resource_documentation:k().optional(),resource_policy_uri:k().url().optional(),resource_tos_uri:k().url().optional(),tls_client_certificate_bound_access_tokens:M().optional(),authorization_details_types_supported:P(k()).optional(),dpop_signing_alg_values_supported:P(k()).optional(),dpop_bound_access_tokens_required:M().optional()}),Ql=I({issuer:k(),authorization_endpoint:K,token_endpoint:K,registration_endpoint:K.optional(),scopes_supported:P(k()).optional(),response_types_supported:P(k()),response_modes_supported:P(k()).optional(),grant_types_supported:P(k()).optional(),token_endpoint_auth_methods_supported:P(k()).optional(),token_endpoint_auth_signing_alg_values_supported:P(k()).optional(),service_documentation:K.optional(),revocation_endpoint:K.optional(),revocation_endpoint_auth_methods_supported:P(k()).optional(),revocation_endpoint_auth_signing_alg_values_supported:P(k()).optional(),introspection_endpoint:k().optional(),introspection_endpoint_auth_methods_supported:P(k()).optional(),introspection_endpoint_auth_signing_alg_values_supported:P(k()).optional(),code_challenge_methods_supported:P(k()).optional(),client_id_metadata_document_supported:M().optional(),authorization_response_iss_parameter_supported:M().optional().catch(void 0)}),$l=I({issuer:k(),authorization_endpoint:K,token_endpoint:K,userinfo_endpoint:K.optional(),jwks_uri:K,registration_endpoint:K.optional(),scopes_supported:P(k()).optional(),response_types_supported:P(k()),response_modes_supported:P(k()).optional(),grant_types_supported:P(k()).optional(),acr_values_supported:P(k()).optional(),subject_types_supported:P(k()),id_token_signing_alg_values_supported:P(k()),id_token_encryption_alg_values_supported:P(k()).optional(),id_token_encryption_enc_values_supported:P(k()).optional(),userinfo_signing_alg_values_supported:P(k()).optional(),userinfo_encryption_alg_values_supported:P(k()).optional(),userinfo_encryption_enc_values_supported:P(k()).optional(),request_object_signing_alg_values_supported:P(k()).optional(),request_object_encryption_alg_values_supported:P(k()).optional(),request_object_encryption_enc_values_supported:P(k()).optional(),token_endpoint_auth_methods_supported:P(k()).optional(),token_endpoint_auth_signing_alg_values_supported:P(k()).optional(),display_values_supported:P(k()).optional(),claim_types_supported:P(k()).optional(),claims_supported:P(k()).optional(),service_documentation:k().optional(),claims_locales_supported:P(k()).optional(),ui_locales_supported:P(k()).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:K.optional(),op_tos_uri:K.optional(),client_id_metadata_document_supported:M().optional(),authorization_response_iss_parameter_supported:M().optional().catch(void 0)}),eu=F({...$l.shape,...Ql.pick({code_challenge_methods_supported:!0}).shape}),tu=F({access_token:k(),id_token:k().optional(),token_type:k(),expires_in:Ho().optional(),scope:k().optional(),refresh_token:k().optional()}).strip(),nu=F({issued_token_type:B(`urn:ietf:params:oauth:token-type:id-jag`),access_token:k(),token_type:k().optional(),expires_in:j().optional(),scope:k().optional()}).strip(),ru=F({error:k(),error_description:k().optional(),error_uri:k().optional()}),iu=K.optional().or(B(``).transform(()=>void 0)),au=F({redirect_uris:P(K),token_endpoint_auth_method:k().optional(),grant_types:P(k()).optional(),response_types:P(k()).optional(),application_type:k().optional(),client_name:k().optional(),client_uri:K.optional(),logo_uri:iu,scope:k().optional(),contacts:P(k()).optional(),tos_uri:iu,policy_uri:k().optional(),jwks_uri:K.optional(),jwks:$a().optional(),software_id:k().optional(),software_version:k().optional(),software_statement:k().optional()}).strip(),ou=F({client_id:k(),client_secret:k().optional(),client_id_issued_at:j().optional(),client_secret_expires_at:j().optional()}).strip(),su=au.merge(ou),cu=F({error:k(),error_description:k().optional()}).strip(),lu=F({token:k(),token_type_hint:k().optional()}).strip();function uu(e,t,n){return typeof e==`object`&&!!e&&`channel`in e&&e.channel===t&&`type`in e&&e.type===`mcp`&&`direction`in e&&e.direction===n&&`payload`in e}function du(e,t,n,r,i){e.postMessage({channel:n,type:`mcp`,direction:r,payload:i},t)}var fu=class{_started=!1;_closed=!1;_allowedOrigins;_channelId;_messageHandler;_clientOrigin;onclientorigin;onclose;onerror;onmessage;constructor(e){if(!e.allowedOrigins?.length)throw Error(`At least one allowed origin must be specified`);this._allowedOrigins=new Set(e.allowedOrigins),this._channelId=e.channelId??`mcp-iframe`}get clientOrigin(){return this._clientOrigin}async start(){if(this._closed)throw Error(`IframeChildTransport cannot be restarted after it closes`);if(this._started)throw Error(`Transport already started`);this._messageHandler=e=>{if(e.source!==window.parent||!this._allowedOrigins.has(`*`)&&!this._allowedOrigins.has(e.origin)||!uu(e.data,this._channelId,`client-to-server`))return;this._clientOrigin!==e.origin&&(this._clientOrigin=e.origin,this.onclientorigin?.(e.origin));let{payload:t}=e.data;if(t===`mcp-check-ready`){this._broadcastServerReady();return}try{let e=ds.parse(t);this.onmessage?.(e)}catch(e){this.onerror?.(Error(`Invalid message: ${e instanceof Error?e.message:String(e)}`))}},window.addEventListener(`message`,this._messageHandler),this._started=!0,this._broadcastServerReady()}async send(e,t){if(this._closed)throw Error(`Transport is closed`);if(!this._started)throw Error(`Transport not started`);if(!this._clientOrigin){console.debug(`[IframeChildTransport] No client connected, message not sent`);return}if(window.parent===window){console.debug(`[IframeChildTransport] Not running in an iframe, message not sent`);return}du(window.parent,this._clientOrigin,this._channelId,`server-to-client`,e)}async close(){this._closed||(this._closed=!0,this._started=!1,this._messageHandler&&=(window.removeEventListener(`message`,this._messageHandler),void 0),this._clientOrigin&&window.parent!==window&&du(window.parent,this._clientOrigin,this._channelId,`server-to-client`,`mcp-server-stopped`),this.onclose?.())}_broadcastServerReady(){window.parent!==window&&du(window.parent,`*`,this._channelId,`server-to-client`,`mcp-server-ready`)}},pu=class{_started=!1;_closed=!1;_allowedOrigins;_channelId;_messageHandler;onclose;onerror;onmessage;constructor(e){if(!e.allowedOrigins?.length)throw Error(`At least one allowed origin must be specified`);this._allowedOrigins=new Set(e.allowedOrigins),this._channelId=e.channelId??`mcp-default`}async start(){if(this._closed)throw Error(`TabServerTransport cannot be restarted after it closes`);if(this._started)throw Error(`Transport already started`);this._messageHandler=e=>{if(e.source!==window||!this._allowedOrigins.has(`*`)&&!this._allowedOrigins.has(e.origin)||!uu(e.data,this._channelId,`client-to-server`))return;let{payload:t}=e.data;if(t===`mcp-check-ready`){du(window,`*`,this._channelId,`server-to-client`,`mcp-server-ready`);return}try{let e=ds.parse(t);this.onmessage?.(e)}catch(e){this.onerror?.(Error(`Invalid message: ${e instanceof Error?e.message:String(e)}`))}},window.addEventListener(`message`,this._messageHandler),this._started=!0,du(window,`*`,this._channelId,`server-to-client`,`mcp-server-ready`)}async send(e,t){if(this._closed)throw Error(`Transport is closed`);if(!this._started)throw Error(`Transport not started`);du(window,`*`,this._channelId,`server-to-client`,e)}async close(){this._closed||(this._closed=!0,this._messageHandler&&=(window.removeEventListener(`message`,this._messageHandler),void 0),this._started&&du(window,`*`,this._channelId,`server-to-client`,`mcp-server-stopped`),this._started=!1,this.onclose?.())}};let mu=[`consequentialHint`,`debugging`,`readOnlyHint`,`untrustedContentHint`],hu=`webmcp-polyfill`,gu=globalThis.DOMException;var _u=class{#e;#t;#n;#r=new Set;#i=new Set;#a=Promise.withResolvers();#o=new Map;#s=new Set;#c;#l=!1;constructor(e,t){this.#t=e,this.#e=e.document,this.#n=t,this.#t.addEventListener(`message`,e=>this.#d(e),!0),this.#t.addEventListener(`pagehide`,()=>{this.#l=!0;for(let e of this.#s)e.end()}),this.#t.addEventListener(`pageshow`,e=>{e.persisted&&(this.#l=!1,this.#x())});for(let e of this.#x())this.#i.add(e);this.#i.size===0?this.#a.resolve():setTimeout(()=>{this.#i.clear(),this.#a.resolve()},500)}async allowed(){return this.#l?!1:this.#h(this.#e)}async getTools(e){await this.#a.promise;let t=this.#t.origin,n=[t,...e];return(await Promise.all(this.#b().map(async e=>{if(e===this.#t)return this.#n.getTools(t).map(e=>wu(e,this.#t,t));try{let t=await this.#u(e,n,{kind:`getTools`});if(!Array.isArray(t.value))throw TypeError(`Expected a tool list from the frame`);return t.value.map(n=>wu(Tu(n),e,t.origin))}catch(e){return e instanceof gu&&e.name===`UnknownError`||console.warn(`WebMCP: could not read tools from a frame.`,e),[]}}))).flat()}async execute(e,t,n,r,i){let a=await this.#u(e,[t],{kind:`execute`,name:n,input:r},i);if(typeof a.value!=`string`)throw q();return a.value}async notify(e){await this.#a.promise;let t=[this.#t.origin,...e];for(let e of this.#b()){if(e===this.#t){await this.#n.changed();continue}try{await this.#u(e,t,{kind:`changed`})}catch{}}}#u(e,t,n,r){return new Promise((i,a)=>{if(r?.throwIfAborted(),this.#l||!this.#v(e)){a(q());return}let o=crypto.randomUUID(),{port1:s,port2:c}=new MessageChannel,l,u=()=>{clearTimeout(h),g(),r?.removeEventListener(`abort`,f),this.#o.delete(o),s.close()},d=(e=q())=>{s.postMessage({kind:`cancel`}),u(),a(e)},f=()=>d(r?.reason),p=()=>{l===void 0&&this.#C(e),d()},m=r=>{if(r.source===e){if(this.#o.delete(o),t&&!t.includes(r.origin)){d();return}l=r.origin,clearTimeout(h),n.kind!==`execute`&&n.kind!==`changed`&&(h=setTimeout(p,500)),s.postMessage(n)}},h=setTimeout(p,500),g=this.#w(e,d);s.onmessage=e=>{let t=Du(e.data);if(t?.kind===`error`){d();return}t?.kind!==`result`||l===void 0||(u(),i({value:t.value,origin:l}))},s.onmessageerror=()=>d(),r?.addEventListener(`abort`,f,{once:!0}),this.#o.set(o,m);try{e.postMessage(`${hu}:connect:${o}`,`*`,[c])}catch{c.close(),d()}})}#d(e){let t=Eu(e.data);if(!t)return;e.stopImmediatePropagation();let n=e.source;if(!e.isTrusted||!n||!Ou(n)||!this.#v(n)||e.origin===`null`||this.#l)return;if(t.kind===`announce`){let t=!this.#r.has(n);if(this.#S(n),n.postMessage(`${hu}:present`,e.origin),!t||this.#t!==this.#t.top)return;for(let e of this.#r)e!==n&&e.postMessage(`${hu}:refresh`,`*`);return}if(t.kind===`present`){this.#S(n);return}if(t.kind===`refresh`){n===this.#t.top&&this.#x();return}if(t.kind===`ready`){this.#o.get(t.id)?.(e);return}let[r]=e.ports;t.kind!==`connect`||!t.id||!r||e.ports.length!==1||(this.#S(n),this.#f(n,e.origin,t.id,r))}#f(e,t,n,r){let i=new AbortController,a=!1,o=()=>{clearTimeout(l),u(),r.close()},s=()=>{i.abort(),o()},c=()=>{r.postMessage({kind:`error`}),s()},l=setTimeout(c,500),u=this.#w(e,c);r.onmessageerror=c,r.onmessage=async n=>{let u=Du(n.data);if(u?.kind===`cancel`){s();return}if(!a){a=!0,clearTimeout(l);try{let n=await this.#p(e,t,u,i.signal);r.postMessage({kind:`result`,value:n}),o()}catch{c()}}},e.postMessage(`${hu}:ready:${n}`,t)}async#p(e,t,n,r){if(!n||!this.#v(e))throw q();if(n.kind===`permission`){let{childIndex:e,childOrigin:t}=n;if(typeof e!=`number`||!Number.isInteger(e)||e<0||typeof t!=`string`)throw q();return this.#m(e,t)}if(!await this.allowed()||!await this.#g(e,t)||!this.#v(e))throw q();if(r.throwIfAborted(),n.kind===`getTools`)return this.#n.getTools(t);if(n.kind===`execute`&&typeof n.name==`string`&&typeof n.input==`string`)return this.#n.execute(t,n.name,n.input,r);if(n.kind===`changed`){await this.#n.changed();return}throw q()}async#m(e,t){let n=this.#t[e];return n!==void 0&&await this.allowed()&&vu(this.#e,n,t)}async#h(e){let t=Su(e);if(!t)return!1;let n=Cu(e);if(n!==void 0)return n;if(t===t.parent)return!0;let r=t.location.ancestorOrigins?.[0],i=yu(t.parent,r===void 0||r===t.origin);return i?vu(i,t,t.origin)&&await this.#h(i):this.#_(t,t.origin)}async#g(e,t){let n=yu(e,t===this.#t.origin);return n?this.#h(n):this.#_(e,t)}async#_(e,t){let n=e.parent;if(n===e)return!0;let r=-1;for(let t=0;t<n.length;t++)if(n[t]===e){r=t;break}if(r<0)return!1;if(n===this.#t)return await this.allowed()&&vu(this.#e,e,t);if(await this.#a.promise,!this.#r.has(n))return!1;try{let e=await this.#u(n,void 0,{kind:`permission`,childIndex:r,childOrigin:t});return e.value===!0&&await this.#g(n,e.origin)}catch{return!1}}#v(e){try{return!e.closed&&e!==this.#t&&e.top===this.#t.top}catch{return!1}}#y(){if(this.#t.closed)return[];for(let e of this.#r)this.#v(e)||this.#r.delete(e);let e=[this.#t,...this.#r];for(let t=this.#t.parent;t!==t.parent;t=t.parent)e.push(t);let t=new Set,n=[this.#t.top];for(;n.length;){let r=n.pop();if(t.has(r))continue;t.add(r);let i=[];for(let e=0;e<r.length;e++){let t=r[e];t&&i.push(t)}for(let t of e)t!==r&&t.parent===r&&!i.includes(t)&&i.push(t);n.push(...i.reverse())}return Array.from(t).filter(e=>e===this.#t||this.#v(e))}#b(){return this.#y().filter(e=>e===this.#t||this.#r.has(e))}#x(){let e=this.#y().filter(e=>e!==this.#t);for(let t of e)t.postMessage(`${hu}:announce`,`*`);return e}#S(e){this.#r.add(e),this.#i.delete(e),this.#i.size===0&&this.#a.resolve()}#C(e){this.#r.delete(e),this.#v(e)&&e.postMessage(`${hu}:announce`,`*`)}#w(e,t){let n={peer:e,end:t};return this.#s.add(n),this.#c===void 0&&(this.#c=this.#t.setInterval(()=>{for(let e of this.#s)this.#v(e.peer)||e.end()},100)),()=>{this.#s.delete(n),this.#s.size===0&&(this.#t.clearInterval(this.#c),this.#c=void 0)}}};function vu(e,t,n){let r=e.defaultView?.origin,i=bu(e,t,n===r);if(!i)return!1;let a=(i.getAttribute(`allow`)??``).split(`;`).map(e=>e.trim().split(/\s+/u)).find(([e])=>e===`tools`);if(!a)return n===r;let o=a.length===1?[`'src'`]:a.slice(1);if(o.includes(`'none'`))return!1;let s=i.hasAttribute(`srcdoc`)?null:i.getAttribute(`src`),c=s?URL.parse(s,e.baseURI):null,l=!s||c?.protocol===`about:`?r:c?.origin;return o.some(e=>e===`*`||e===`'self'`&&n===r||e===`'src'`&&n===l||e===n)}function yu(e,t){if(t)try{return e.document}catch{return}}function bu(e,t,n){if(n)try{let n=t.frameElement;if(n?.ownerDocument===e)return n}catch{}return xu(e,t)}function xu(e,t){let n=e.querySelectorAll(`iframe, frame`);for(let e of n)if(e.contentWindow===t)return e;for(let n of e.querySelectorAll(`*`)){if(!n.shadowRoot)continue;let e=xu(n.shadowRoot,t);if(e)return e}}function Su(e){let t=e.defaultView;return t&&!t.closed&&t.document===e?t:void 0}function Cu(e){let t=e,n=Du(t.permissionsPolicy??t.featurePolicy);if(typeof n?.features!=`function`||typeof n.allowsFeature!=`function`)return;let r=n.features();return Array.isArray(r)&&r.includes(`tools`)?!!n.allowsFeature(`tools`):void 0}function wu(e,t,n){let r=e.serializedSchema===void 0?void 0:JSON.parse(e.serializedSchema);return{...e.annotations!==void 0&&{annotations:{...e.annotations}},description:e.description,...r!==void 0&&{inputSchema:r},name:e.name,origin:n,title:e.title,window:t}}function Tu(e){let t=Du(e);if(!t||typeof t.name!=`string`||typeof t.title!=`string`||typeof t.description!=`string`||t.serializedSchema!==void 0&&typeof t.serializedSchema!=`string`)throw TypeError(`Invalid tool metadata from the frame`);let n={name:t.name,title:t.title,description:t.description,annotations:void 0,serializedSchema:t.serializedSchema};if(t.annotations===void 0)return n;let r=Du(t.annotations);if(!r)throw TypeError(`Invalid tool annotations from the frame`);let i={};for(let e of mu){let t=r[e];if(t!==void 0){if(typeof t!=`boolean`)throw TypeError(`Invalid ${e} annotation from the frame`);i[e]=t}}return n.annotations=i,n}function Eu(e){if(typeof e!=`string`)return;let[t,n=``,r=``,i]=e.split(`:`);return t===hu&&i===void 0?{kind:n,id:r}:void 0}function Du(e){if(!(typeof e!=`object`||!e||Array.isArray(e)))return e}function Ou(e){try{return`postMessage`in e&&`window`in e}catch{return!1}}function q(){return new gu(`Tool execution failed`,`UnknownError`)}let ku=new WeakSet,Au=new WeakMap,ju=new WeakMap;function Mu(e){return e.isTrusted&&(ku.has(e)||e.eventPhase!==Event.NONE&&e.target instanceof HTMLFormElement&&ju.has(e.target))}function Nu(e,t){if(!Mu(e))throw new DOMException(`respondWith() is only available during an agent-invoked submit event`,`InvalidStateError`);if(!e.defaultPrevented)throw new DOMException(`respondWith() requires preventDefault() during an agent-invoked submit event`,`InvalidStateError`);if(e.eventPhase===Event.NONE)throw new DOMException(`respondWith() is only available while the submit event is being dispatched`,`InvalidStateError`);ku.add(e);let n=Promise.resolve(t);Au.set(e,n),e.target instanceof HTMLFormElement&&ju.get(e.target)?.respond(e)}let Pu=new Set([`email`,`password`,`search`,`tel`,`text`,`url`]),Fu=new Set([...Pu,`date`,`datetime-local`,`month`,`number`,`time`,`week`]);function Iu(e){return e instanceof HTMLInputElement||e instanceof HTMLSelectElement||e instanceof HTMLTextAreaElement}function Lu(e){return Object.getOwnPropertyDescriptor(HTMLFormElement.prototype,`elements`)?.get?.call(e)}function Ru(e,t){return Element.prototype.getAttribute.call(e,t)}function zu(e,t){return Element.prototype.hasAttribute.call(e,t)}function Bu(e){return Object.getOwnPropertyDescriptor(Node.prototype,`isConnected`)?.get?.call(e)}function Vu(e){return Object.getOwnPropertyDescriptor(Element.prototype,`shadowRoot`)?.get?.call(e)}function Hu(e){return HTMLFormElement.prototype.checkValidity.call(e)}function Uu(e,t){HTMLFormElement.prototype.requestSubmit.call(e,t)}function Wu(e){return[...Lu(e)].filter(e=>Iu(e)&&!e.matches(`:disabled`)&&!(`readOnly`in e&&e.readOnly&&(e instanceof HTMLTextAreaElement||Fu.has(e.type))))}function Gu(e){let t=new Map;for(let n of Wu(e)){let e=n.name.trim(),r=t.get(e);r?r.push(n):t.set(e,[n])}return t}function Ku(e){return[...e.labels??[]].map(e=>{let t=e.cloneNode(!0);return t instanceof HTMLElement?(t.querySelectorAll(`button, input, meter, output, progress, select, textarea`).forEach(e=>e.remove()),t.textContent?.trim()??``):``}).filter(Boolean).join(`; `)}function qu(e,t){for(let n=t[0]?.parentElement;n&&n!==e;n=n.parentElement)if(n instanceof HTMLFieldSetElement&&t.every(e=>n.contains(e)))return n}function Ju(e,t){if(t.length===1){let e=t[0];return e&&(e.getAttribute(`toolparamdescription`)||Ku(e)||e.getAttribute(`aria-description`))||void 0}return qu(e,t)?.getAttribute(`toolparamdescription`)||void 0}function Yu(e,t,n,r){let i=Ju(t,n),a=i&&r?`${i} (${r})`:i||r;return a?{...e,description:a}:e}function Xu(e,t){let n=e.getAttribute(t);if(n===null||n.trim()===``)return;let r=Number(n);return Number.isFinite(r)?r:void 0}function Zu(e,t){let n=Number(e.getAttribute(`step`));return Number.isFinite(n)&&n>0?n:t}function Qu(e,t){let n=e/t;return Math.abs(n-Math.round(n))<2**-52*16}function $u(e,t){let n=t.getAttribute(`pattern`);if(n===null)return e;try{new RegExp(n,`v`)}catch{return e}return{...e,pattern:n}}function ed(e){let t={type:`number`},n=Xu(e,`min`),r=Xu(e,`max`);if(n!==void 0&&(t.minimum=n),r!==void 0&&(t.maximum=r),e.getAttribute(`step`)!==`any`){let r=Zu(e,1),i=Number(e.getAttribute(`value`));Qu(n??(Number.isFinite(i)?i:0),r)&&(t.multipleOf=r)}return t}function td(e,t){let n=Zu(e,60);return n<1?`${t}(:[0-5][0-9](\\.[0-9]{1,3})?)?$`:n<60?`${t}(:[0-5][0-9])?$`:`${t}$`}function nd(e){return{anyOf:e.map(e=>({type:`string`,const:e.value,title:e.textContent??``})),enum:e.map(e=>e.value)}}function rd(e){return{anyOf:e.map(e=>{let t=Ku(e),n={type:`string`,const:e.value};return t&&(n.title=t),n}),enum:e.map(e=>e.value)}}function id(e,t){return e instanceof HTMLInputElement&&e.type===t}function ad(e){if(Pu.has(e.type))return $u({type:`string`},e);switch(e.type){case`hidden`:return e.getAttribute(`toolparamdescription`)?{type:`string`}:void 0;case`number`:return $u(ed(e),e);case`range`:{let t=ed(e);return t.minimum??=0,t.maximum??=100,t}case`checkbox`:return{type:`boolean`};case`date`:return{type:`string`,format:`date`};case`month`:return{type:`string`,format:`^[0-9]{4}-(0[1-9]|1[0-2])$`};case`week`:return{type:`string`,format:`^[0-9]{4}-W(0[1-9]|[1-4][0-9]|5[0-3])$`};case`time`:return{type:`string`,format:td(e,`^([01][0-9]|2[0-3]):[0-5][0-9]`)};case`datetime-local`:return{type:`string`,format:td(e,`^[0-9]{4}-(0[1-9]|1[0-2])-[0-9]{2}T([01][0-9]|2[0-3]):[0-5][0-9]`)};case`color`:return{type:`string`,format:`^#[0-9a-zA-Z]{6}$`};default:return}}function od(e,t){let[n]=t;if(!n)return;let r;if(t.every(e=>id(e,`radio`)))r={type:`string`,...rd(t)};else if(t.length>1)t.every(e=>id(e,`checkbox`))&&(r={type:`array`,items:{type:`string`,...rd(t)},uniqueItems:!0});else if(n instanceof HTMLTextAreaElement)r={type:`string`};else if(n instanceof HTMLSelectElement){let e=nd([...n.options]);r=n.multiple?{type:`array`,items:{type:`string`,...e},uniqueItems:!0}:{type:`string`,...e}}else r=ad(n);let i=n.type===`date`?`Dates MUST be provided in 'YYYY-MM-DD' format.`:void 0;return r&&Yu(r,e,t,i)}function sd(e){let t={},n=[];for(let[r,i]of Gu(e)){if(!r)continue;let a=od(e,i);a&&(Object.defineProperty(t,r,{configurable:!0,enumerable:!0,value:a,writable:!0}),i.some(e=>e.required)&&n.push(r))}return{type:`object`,properties:t,required:n}}function cd(e){return{name:Ru(e,`toolname`)??``,title:Ru(e,`tooltitle`)??``,description:Ru(e,`tooldescription`)??``,inputSchema:sd(e),autosubmit:zu(e,`toolautosubmit`)}}function ld(e){if(typeof e==`string`||typeof e==`boolean`||typeof e==`number`&&Number.isFinite(e))return String(e)}function ud(e){if(typeof e==`boolean`)return e;if(typeof e==`number`&&Number.isInteger(e))return e!==0;if(typeof e==`string`){if(e===`1`||e.toLowerCase()===`true`)return!0;if(e===`0`||e.toLowerCase()===`false`)return!1}}function dd(e,t){if(!Array.isArray(e))return!1;let n=new Set(t);for(let t of e){let e=ld(t);if(e===void 0||!n.delete(e))return!1}return!0}function fd(e,t){if(t===``)return e.type!==`number`&&e.type!==`range`;let n=e.ownerDocument.createElement(`input`);return n.type=e.type,n.value=t,n.value!==``}function pd(e,t,n){let[r]=t;if(!r||!od(e,t))return!1;let i=ld(n);if(t.every(e=>id(e,`radio`)))return t.some(e=>e.value===i);if(t.length>1)return dd(n,new Set(t.map(e=>e.value)));if(r instanceof HTMLSelectElement){let e=new Set([...r.options].map(e=>e.value));return r.multiple?dd(n,e):i!==void 0&&e.has(i)}return r instanceof HTMLTextAreaElement?i!==void 0:r.type===`checkbox`?ud(n)!==void 0:i!==void 0&&fd(r,i)}function md(e){e.dispatchEvent(new Event(`input`,{bubbles:!0,composed:!0})),e.dispatchEvent(new Event(`change`,{bubbles:!0}))}function hd(e,t){if(e.value===t)return;let n=e instanceof HTMLInputElement?HTMLInputElement.prototype:HTMLTextAreaElement.prototype;Object.getOwnPropertyDescriptor(n,`value`)?.set?.call(e,t),md(e)}function gd(e,t){e.checked!==t&&(Object.getOwnPropertyDescriptor(HTMLInputElement.prototype,`checked`)?.set?.call(e,t),md(e))}function _d(e,t){let[n]=e,r=ld(t),i=new Set(Array.isArray(t)?t.map(ld):[]);if(e.every(e=>id(e,`radio`))){let t=e.find(e=>e.value===r);t&&gd(t,!0)}else if(e.length>1)for(let t of e)t instanceof HTMLInputElement&&gd(t,i.has(t.value));else if(n instanceof HTMLSelectElement)if(n.multiple){let e=!1;for(let t of n.options){let n=i.has(t.value);t.selected!==n&&(t.selected=n,e=!0)}e&&md(n)}else r!==void 0&&n.value!==r&&(n.value=r,md(n));else if(n&&id(n,`checkbox`)){let e=ud(t);e!==void 0&&gd(n,e)}else n&&r!==void 0&&hd(n,r)}function vd(e,t){if(Array.isArray(t))throw q();let n=Gu(e),r=[];for(let[i,a]of Object.entries(t)){let t=n.get(i);if(!t||!pd(e,t,a))throw q();r.push({controls:t,value:a})}for(let{controls:e,value:t}of r)_d(e,t)}function yd(e){return[...Lu(e)].find(e=>!e.matches(`:disabled`)&&(e instanceof HTMLButtonElement&&e.type===`submit`||e instanceof HTMLInputElement&&[`image`,`submit`].includes(e.type)))}function bd(e,t){let n=new Event(e);return Object.defineProperty(n,"toolName",{enumerable:!0,value:t}),n}function xd(e,t,n,r,i){let{form:a}=t;return t.cancelPending?.(q()),new Promise((o,s)=>{let c=!1,l=()=>{EventTarget.prototype.removeEventListener.call(a,`invalid`,p,!0),i.removeEventListener(`abort`,m),ju.delete(a),t.cancelPending===d&&delete t.cancelPending},u=e=>{c||(c=!0,l(),e())},d=e=>u(()=>s(e)),f=e=>{t.cancelPending===d&&delete t.cancelPending,e.then(e=>u(()=>o(e??null)),e=>u(()=>s(e)))},p=e=>{e.isTrusted&&queueMicrotask(()=>{Hu(a)||d(q())})},m=()=>{u(()=>{e.dispatchEvent(bd(`toolcancel`,n.name)),s(i.reason)})};if(ju.set(a,{complete(e){setTimeout(()=>{let t=Au.get(e);t?f(t):e.defaultPrevented?d(q()):u(()=>o(null))})},direct(){u(()=>o(null))},respond(e){queueMicrotask(()=>{let t=Au.get(e);t&&f(t)})}}),t.cancelPending=d,EventTarget.prototype.addEventListener.call(a,`invalid`,p,!0),i.addEventListener(`abort`,m,{once:!0}),!n.autosubmit){r?.focus(),e.dispatchEvent(bd(`toolactivated`,n.name));return}try{Uu(a,r),e.dispatchEvent(bd(`toolactivated`,n.name))}catch(e){d(e)}})}function Sd(e){let t=SubmitEvent.prototype;if(`agentInvoked`in t&&`respondWith`in t)return;`agentInvoked`in t||Object.defineProperty(t,"agentInvoked",{configurable:!0,enumerable:!0,get(){return Mu(this)}}),`respondWith`in t||Object.defineProperty(t,"respondWith",{configurable:!0,enumerable:!0,writable:!0,value(e){Nu(this,e)}});let n=new Map,r=new Map,i=new Map,a=e=>{if(!(e instanceof SubmitEvent)||!e.isTrusted||!(e.target instanceof HTMLFormElement))return;let t=ju.get(e.target);t&&(ku.add(e),t.complete(e))},o=e=>{if(!e.isTrusted||!(e.target instanceof HTMLFormElement))return;let t=e.target;setTimeout(()=>{e.defaultPrevented||n.get(t)?.cancelPending?.(q())})};function s(e){i.get(e)?.disconnect(),i.delete(e),e.removeEventListener(`reset`,o,!0),e.removeEventListener(`submit`,a,!0)}function c(e){if(i.has(e))return;let t=new MutationObserver(l);i.set(e,t),t.observe(e,{attributes:!0,characterData:!0,childList:!0,subtree:!0}),e.addEventListener(`reset`,o,!0),e.addEventListener(`submit`,a,!0)}function l(){c(document);for(let e of i.keys())e instanceof ShadowRoot&&!e.host.isConnected&&s(e);let t=new Set,a=new Map,o=new Map;for(let e of i.keys())for(let i of e.querySelectorAll(`*`)){let e=Vu(i);if(e&&c(e),!(i instanceof HTMLFormElement)||!zu(i,`toolname`)||!zu(i,`tooldescription`)||!Bu(i))continue;let s=i;t.add(s);let l=cd(s),u=JSON.stringify(l);if(r.get(s)===u)continue;r.delete(s);let d=o.get(l.name);if(d){let e=e=>n.get(e)?.name===l.name;if(!e(s)||e(d)){r.set(s,u);continue}let t=a.get(d);t&&r.set(d,t.fingerprint),a.delete(d)}o.set(l.name,s),a.set(s,{definition:l,fingerprint:u})}for(let e of r.keys())t.has(e)||r.delete(e);for(let[e,t]of n)a.get(e)?.fingerprint!==t.fingerprint&&(t.cancelPending?.(q()),t.controller.abort(),n.delete(e));for(let[t,{definition:r,fingerprint:i}]of a){if(n.has(t))continue;let a=new AbortController,o={controller:a,fingerprint:i,form:t,name:r.name};n.set(t,o),e.registerTool({name:r.name,title:r.title,description:r.description,inputSchema:r.inputSchema,execute(n,i){let a=yd(t);if(!r.autosubmit&&!a)throw q();return vd(t,n),xd(e,o,r,a,i.signal)}},{signal:a.signal}).catch(e=>{a.abort(),!(e instanceof DOMException&&e.name===`AbortError`)&&console.error(`[webmcp] declarative form tool "${r.name}" was not registered:`,e)})}}let u=Object.getOwnPropertyDescriptor(Element.prototype,`attachShadow`);if(u?.configurable){let e=Element.prototype.attachShadow,t=function(t){let n=e.call(this,t);return n.mode===`open`&&Object.getOwnPropertyDescriptor(Node.prototype,`ownerDocument`)?.get?.call(this)===document&&Bu(this)&&c(n),n};Object.defineProperty(Element.prototype,"attachShadow",{...u,value:t})}let d=Object.getOwnPropertyDescriptor(HTMLFormElement.prototype,`submit`);if(d?.configurable){let e=HTMLFormElement.prototype.submit,t=function(){e.call(this),ju.get(this)?.direct()};Object.defineProperty(HTMLFormElement.prototype,"submit",{...d,value:t})}l()}
65
65
  /*!
66
66
  * Copyright (c) 2026 WebMCP polyfill contributors
67
67
  * SPDX-License-Identifier: MIT
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mcp-b/global",
3
- "version": "6.0.2",
3
+ "version": "6.0.3",
4
4
  "description": "W3C Web Model Context Protocol (WebMCP) API polyfill. Let AI agents like Claude, ChatGPT, and Gemini interact with your website via document.modelContext.",
5
5
  "keywords": [
6
6
  "ai-agents",
@@ -66,9 +66,9 @@
66
66
  },
67
67
  "dependencies": {
68
68
  "@modelcontextprotocol/server": "2.0.0",
69
- "@mcp-b/webmcp-polyfill": "6.0.2",
70
- "@mcp-b/webmcp-ts-sdk": "6.0.2",
71
- "@mcp-b/transports": "6.0.2"
69
+ "@mcp-b/webmcp-ts-sdk": "6.0.3",
70
+ "@mcp-b/webmcp-polyfill": "6.0.3",
71
+ "@mcp-b/transports": "6.0.3"
72
72
  },
73
73
  "devDependencies": {
74
74
  "@modelcontextprotocol/client": "2.2.0",