@atoms-tech/atoms-mcp 0.4.1 → 0.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/apps/src/apps/trace/trace-app.html +29 -25
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
|
@@ -4,38 +4,38 @@
|
|
|
4
4
|
<meta charset="UTF-8" />
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
6
|
<title>ATOMS Trace Graph</title>
|
|
7
|
-
<script type="module" crossorigin>(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const r of document.querySelectorAll('link[rel="modulepreload"]'))n(r);new MutationObserver(r=>{for(const s of r)if(s.type==="childList")for(const i of s.addedNodes)i.tagName==="LINK"&&i.rel==="modulepreload"&&n(i)}).observe(document,{childList:!0,subtree:!0});function o(r){const s={};return r.integrity&&(s.integrity=r.integrity),r.referrerPolicy&&(s.referrerPolicy=r.referrerPolicy),r.crossOrigin==="use-credentials"?s.credentials="include":r.crossOrigin==="anonymous"?s.credentials="omit":s.credentials="same-origin",s}function n(r){if(r.ep)return;r.ep=!0;const s=o(r);fetch(r.href,s)}})();function d(e,t,o){function n(c,p){var h;Object.defineProperty(c,"_zod",{value:c._zod??{},enumerable:!1}),(h=c._zod).traits??(h.traits=new Set),c._zod.traits.add(e),t(c,p);for(const m in i.prototype)m in c||Object.defineProperty(c,m,{value:i.prototype[m].bind(c)});c._zod.constr=i,c._zod.def=p}const r=o?.Parent??Object;class s extends r{}Object.defineProperty(s,"name",{value:e});function i(c){var p;const h=o?.Parent?new s:this;n(h,c),(p=h._zod).deferred??(p.deferred=[]);for(const m of h._zod.deferred)m();return h}return Object.defineProperty(i,"init",{value:n}),Object.defineProperty(i,Symbol.hasInstance,{value:c=>o?.Parent&&c instanceof o.Parent?!0:c?._zod?.traits?.has(e)}),Object.defineProperty(i,"name",{value:e}),i}class he extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}const ao={};function X(e){return ao}function ln(e){const t=Object.values(e).filter(n=>typeof n=="number");return Object.entries(e).filter(([n,r])=>t.indexOf(+n)===-1).map(([n,r])=>r)}function dn(e,t){return typeof t=="bigint"?t.toString():t}function st(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function it(e){return e==null}function at(e){const t=e.startsWith("^")?1:0,o=e.endsWith("$")?e.length-1:e.length;return e.slice(t,o)}function pn(e,t){const o=(e.toString().split(".")[1]||"").length,n=(t.toString().split(".")[1]||"").length,r=o>n?o:n,s=Number.parseInt(e.toFixed(r).replace(".","")),i=Number.parseInt(t.toFixed(r).replace(".",""));return s%i/10**r}function C(e,t,o){Object.defineProperty(e,t,{get(){{const n=o();return e[t]=n,n}},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function Ue(e,t,o){Object.defineProperty(e,t,{value:o,writable:!0,enumerable:!0,configurable:!0})}function le(e){return JSON.stringify(e)}const co=Error.captureStackTrace?Error.captureStackTrace:(...e)=>{};function Me(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const hn=st(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{const e=Function;return new e(""),!0}catch{return!1}});function Oe(e){if(Me(e)===!1)return!1;const t=e.constructor;if(t===void 0)return!0;const o=t.prototype;return!(Me(o)===!1||Object.prototype.hasOwnProperty.call(o,"isPrototypeOf")===!1)}const mn=new Set(["string","number","symbol"]);function _e(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function ie(e,t,o){const n=new e._zod.constr(t??e._zod.def);return(!t||o?.parent)&&(n._zod.parent=e),n}function g(e){const t=e;if(!t)return{};if(typeof t=="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error=="string"?{...t,error:()=>t.error}:t}function fn(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}const gn={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function vn(e,t){const o={},n=e._zod.def;for(const r in t){if(!(r in n.shape))throw new Error(`Unrecognized key: "${r}"`);t[r]&&(o[r]=n.shape[r])}return ie(e,{...e._zod.def,shape:o,checks:[]})}function _n(e,t){const o={...e._zod.def.shape},n=e._zod.def;for(const r in t){if(!(r in n.shape))throw new Error(`Unrecognized key: "${r}"`);t[r]&&delete o[r]}return ie(e,{...e._zod.def,shape:o,checks:[]})}function bn(e,t){if(!Oe(t))throw new Error("Invalid input to extend: expected a plain object");const o={...e._zod.def,get shape(){const n={...e._zod.def.shape,...t};return Ue(this,"shape",n),n},checks:[]};return ie(e,o)}function yn(e,t){return ie(e,{...e._zod.def,get shape(){const o={...e._zod.def.shape,...t._zod.def.shape};return Ue(this,"shape",o),o},catchall:t._zod.def.catchall,checks:[]})}function wn(e,t,o){const n=t._zod.def.shape,r={...n};if(o)for(const s in o){if(!(s in n))throw new Error(`Unrecognized key: "${s}"`);o[s]&&(r[s]=e?new e({type:"optional",innerType:n[s]}):n[s])}else for(const s in n)r[s]=e?new e({type:"optional",innerType:n[s]}):n[s];return ie(t,{...t._zod.def,shape:r,checks:[]})}function kn(e,t,o){const n=t._zod.def.shape,r={...n};if(o)for(const s in o){if(!(s in r))throw new Error(`Unrecognized key: "${s}"`);o[s]&&(r[s]=new e({type:"nonoptional",innerType:n[s]}))}else for(const s in n)r[s]=new e({type:"nonoptional",innerType:n[s]});return ie(t,{...t._zod.def,shape:r,checks:[]})}function pe(e,t=0){for(let o=t;o<e.issues.length;o++)if(e.issues[o]?.continue!==!0)return!0;return!1}function se(e,t){return t.map(o=>{var n;return(n=o).path??(n.path=[]),o.path.unshift(e),o})}function $e(e){return typeof e=="string"?e:e?.message}function ee(e,t,o){const n={...e,path:e.path??[]};if(!e.message){const r=$e(e.inst?._zod.def?.error?.(e))??$e(t?.error?.(e))??$e(o.customError?.(e))??$e(o.localeError?.(e))??"Invalid input";n.message=r}return delete n.inst,delete n.continue,t?.reportInput||delete n.input,n}function ct(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function me(...e){const[t,o,n]=e;return typeof t=="string"?{message:t,code:"custom",input:o,inst:n}:{...t}}const uo=(e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),Object.defineProperty(e,"message",{get(){return JSON.stringify(t,dn,2)},enumerable:!0}),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},lo=d("$ZodError",uo),po=d("$ZodError",uo,{Parent:Error});function xn(e,t=o=>o.message){const o={},n=[];for(const r of e.issues)r.path.length>0?(o[r.path[0]]=o[r.path[0]]||[],o[r.path[0]].push(t(r))):n.push(t(r));return{formErrors:n,fieldErrors:o}}function Sn(e,t){const o=t||function(s){return s.message},n={_errors:[]},r=s=>{for(const i of s.issues)if(i.code==="invalid_union"&&i.errors.length)i.errors.map(c=>r({issues:c}));else if(i.code==="invalid_key")r({issues:i.issues});else if(i.code==="invalid_element")r({issues:i.issues});else if(i.path.length===0)n._errors.push(o(i));else{let c=n,p=0;for(;p<i.path.length;){const h=i.path[p];p===i.path.length-1?(c[h]=c[h]||{_errors:[]},c[h]._errors.push(o(i))):c[h]=c[h]||{_errors:[]},c=c[h],p++}}};return r(e),n}const Tn=e=>(t,o,n,r)=>{const s=n?Object.assign(n,{async:!1}):{async:!1},i=t._zod.run({value:o,issues:[]},s);if(i instanceof Promise)throw new he;if(i.issues.length){const c=new(r?.Err??e)(i.issues.map(p=>ee(p,s,X())));throw co(c,r?.callee),c}return i.value},zn=e=>async(t,o,n,r)=>{const s=n?Object.assign(n,{async:!0}):{async:!0};let i=t._zod.run({value:o,issues:[]},s);if(i instanceof Promise&&(i=await i),i.issues.length){const c=new(r?.Err??e)(i.issues.map(p=>ee(p,s,X())));throw co(c,r?.callee),c}return i.value},ho=e=>(t,o,n)=>{const r=n?{...n,async:!1}:{async:!1},s=t._zod.run({value:o,issues:[]},r);if(s instanceof Promise)throw new he;return s.issues.length?{success:!1,error:new(e??lo)(s.issues.map(i=>ee(i,r,X())))}:{success:!0,data:s.value}},mo=ho(po),fo=e=>async(t,o,n)=>{const r=n?Object.assign(n,{async:!0}):{async:!0};let s=t._zod.run({value:o,issues:[]},r);return s instanceof Promise&&(s=await s),s.issues.length?{success:!1,error:new e(s.issues.map(i=>ee(i,r,X())))}:{success:!0,data:s.value}},Rn=fo(po),In=/^[cC][^\s-]{8,}$/,$n=/^[0-9a-z]+$/,Pn=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,En=/^[0-9a-vA-V]{20}$/,Zn=/^[A-Za-z0-9]{27}$/,Cn=/^[a-zA-Z0-9_-]{21}$/,Nn=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,qn=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,At=e=>e?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000)$/,Mn=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,On="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function An(){return new RegExp(On,"u")}const Dn=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,Ln=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})$/,Un=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,jn=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Hn=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,go=/^[A-Za-z0-9_-]*$/,Fn=/^([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+$/,Bn=/^\+(?:[0-9]){6,14}[0-9]$/,vo="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",Vn=new RegExp(`^${vo}$`);function _o(e){const t="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof e.precision=="number"?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function Wn(e){return new RegExp(`^${_o(e)}$`)}function Jn(e){const t=_o({precision:e.precision}),o=["Z"];e.local&&o.push(""),e.offset&&o.push("([+-]\\d{2}:\\d{2})");const n=`${t}(?:${o.join("|")})`;return new RegExp(`^${vo}T(?:${n})$`)}const Gn=e=>{const t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},Kn=/^\d+$/,Qn=/^-?\d+(?:\.\d+)?/i,Yn=/true|false/i,Xn=/null/i,er=/undefined/i,tr=/^[^A-Z]*$/,or=/^[^a-z]*$/,F=d("$ZodCheck",(e,t)=>{var o;e._zod??(e._zod={}),e._zod.def=t,(o=e._zod).onattach??(o.onattach=[])}),bo={number:"number",bigint:"bigint",object:"date"},yo=d("$ZodCheckLessThan",(e,t)=>{F.init(e,t);const o=bo[typeof t.value];e._zod.onattach.push(n=>{const r=n._zod.bag,s=(t.inclusive?r.maximum:r.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<s&&(t.inclusive?r.maximum=t.value:r.exclusiveMaximum=t.value)}),e._zod.check=n=>{(t.inclusive?n.value<=t.value:n.value<t.value)||n.issues.push({origin:o,code:"too_big",maximum:t.value,input:n.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),wo=d("$ZodCheckGreaterThan",(e,t)=>{F.init(e,t);const o=bo[typeof t.value];e._zod.onattach.push(n=>{const r=n._zod.bag,s=(t.inclusive?r.minimum:r.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>s&&(t.inclusive?r.minimum=t.value:r.exclusiveMinimum=t.value)}),e._zod.check=n=>{(t.inclusive?n.value>=t.value:n.value>t.value)||n.issues.push({origin:o,code:"too_small",minimum:t.value,input:n.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),nr=d("$ZodCheckMultipleOf",(e,t)=>{F.init(e,t),e._zod.onattach.push(o=>{var n;(n=o._zod.bag).multipleOf??(n.multipleOf=t.value)}),e._zod.check=o=>{if(typeof o.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof o.value=="bigint"?o.value%t.value===BigInt(0):pn(o.value,t.value)===0)||o.issues.push({origin:typeof o.value,code:"not_multiple_of",divisor:t.value,input:o.value,inst:e,continue:!t.abort})}}),rr=d("$ZodCheckNumberFormat",(e,t)=>{F.init(e,t),t.format=t.format||"float64";const o=t.format?.includes("int"),n=o?"int":"number",[r,s]=gn[t.format];e._zod.onattach.push(i=>{const c=i._zod.bag;c.format=t.format,c.minimum=r,c.maximum=s,o&&(c.pattern=Kn)}),e._zod.check=i=>{const c=i.value;if(o){if(!Number.isInteger(c)){i.issues.push({expected:n,format:t.format,code:"invalid_type",input:c,inst:e});return}if(!Number.isSafeInteger(c)){c>0?i.issues.push({input:c,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:n,continue:!t.abort}):i.issues.push({input:c,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:n,continue:!t.abort});return}}c<r&&i.issues.push({origin:"number",input:c,code:"too_small",minimum:r,inclusive:!0,inst:e,continue:!t.abort}),c>s&&i.issues.push({origin:"number",input:c,code:"too_big",maximum:s,inst:e})}}),sr=d("$ZodCheckMaxLength",(e,t)=>{var o;F.init(e,t),(o=e._zod.def).when??(o.when=n=>{const r=n.value;return!it(r)&&r.length!==void 0}),e._zod.onattach.push(n=>{const r=n._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<r&&(n._zod.bag.maximum=t.maximum)}),e._zod.check=n=>{const r=n.value;if(r.length<=t.maximum)return;const i=ct(r);n.issues.push({origin:i,code:"too_big",maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),ir=d("$ZodCheckMinLength",(e,t)=>{var o;F.init(e,t),(o=e._zod.def).when??(o.when=n=>{const r=n.value;return!it(r)&&r.length!==void 0}),e._zod.onattach.push(n=>{const r=n._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>r&&(n._zod.bag.minimum=t.minimum)}),e._zod.check=n=>{const r=n.value;if(r.length>=t.minimum)return;const i=ct(r);n.issues.push({origin:i,code:"too_small",minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),ar=d("$ZodCheckLengthEquals",(e,t)=>{var o;F.init(e,t),(o=e._zod.def).when??(o.when=n=>{const r=n.value;return!it(r)&&r.length!==void 0}),e._zod.onattach.push(n=>{const r=n._zod.bag;r.minimum=t.length,r.maximum=t.length,r.length=t.length}),e._zod.check=n=>{const r=n.value,s=r.length;if(s===t.length)return;const i=ct(r),c=s>t.length;n.issues.push({origin:i,...c?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),je=d("$ZodCheckStringFormat",(e,t)=>{var o,n;F.init(e,t),e._zod.onattach.push(r=>{const s=r._zod.bag;s.format=t.format,t.pattern&&(s.patterns??(s.patterns=new Set),s.patterns.add(t.pattern))}),t.pattern?(o=e._zod).check??(o.check=r=>{t.pattern.lastIndex=0,!t.pattern.test(r.value)&&r.issues.push({origin:"string",code:"invalid_format",format:t.format,input:r.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(n=e._zod).check??(n.check=()=>{})}),cr=d("$ZodCheckRegex",(e,t)=>{je.init(e,t),e._zod.check=o=>{t.pattern.lastIndex=0,!t.pattern.test(o.value)&&o.issues.push({origin:"string",code:"invalid_format",format:"regex",input:o.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),ur=d("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=tr),je.init(e,t)}),lr=d("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=or),je.init(e,t)}),dr=d("$ZodCheckIncludes",(e,t)=>{F.init(e,t);const o=_e(t.includes),n=new RegExp(typeof t.position=="number"?`^.{${t.position}}${o}`:o);t.pattern=n,e._zod.onattach.push(r=>{const s=r._zod.bag;s.patterns??(s.patterns=new Set),s.patterns.add(n)}),e._zod.check=r=>{r.value.includes(t.includes,t.position)||r.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:r.value,inst:e,continue:!t.abort})}}),pr=d("$ZodCheckStartsWith",(e,t)=>{F.init(e,t);const o=new RegExp(`^${_e(t.prefix)}.*`);t.pattern??(t.pattern=o),e._zod.onattach.push(n=>{const r=n._zod.bag;r.patterns??(r.patterns=new Set),r.patterns.add(o)}),e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),hr=d("$ZodCheckEndsWith",(e,t)=>{F.init(e,t);const o=new RegExp(`.*${_e(t.suffix)}$`);t.pattern??(t.pattern=o),e._zod.onattach.push(n=>{const r=n._zod.bag;r.patterns??(r.patterns=new Set),r.patterns.add(o)}),e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}}),mr=d("$ZodCheckOverwrite",(e,t)=>{F.init(e,t),e._zod.check=o=>{o.value=t.tx(o.value)}});class fr{constructor(t=[]){this.content=[],this.indent=0,this&&(this.args=t)}indented(t){this.indent+=1,t(this),this.indent-=1}write(t){if(typeof t=="function"){t(this,{execution:"sync"}),t(this,{execution:"async"});return}const n=t.split(`
|
|
7
|
+
<script type="module" crossorigin>(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const r of document.querySelectorAll('link[rel="modulepreload"]'))n(r);new MutationObserver(r=>{for(const s of r)if(s.type==="childList")for(const i of s.addedNodes)i.tagName==="LINK"&&i.rel==="modulepreload"&&n(i)}).observe(document,{childList:!0,subtree:!0});function o(r){const s={};return r.integrity&&(s.integrity=r.integrity),r.referrerPolicy&&(s.referrerPolicy=r.referrerPolicy),r.crossOrigin==="use-credentials"?s.credentials="include":r.crossOrigin==="anonymous"?s.credentials="omit":s.credentials="same-origin",s}function n(r){if(r.ep)return;r.ep=!0;const s=o(r);fetch(r.href,s)}})();function d(e,t,o){function n(u,p){var m;Object.defineProperty(u,"_zod",{value:u._zod??{},enumerable:!1}),(m=u._zod).traits??(m.traits=new Set),u._zod.traits.add(e),t(u,p);for(const f in i.prototype)f in u||Object.defineProperty(u,f,{value:i.prototype[f].bind(u)});u._zod.constr=i,u._zod.def=p}const r=o?.Parent??Object;class s extends r{}Object.defineProperty(s,"name",{value:e});function i(u){var p;const m=o?.Parent?new s:this;n(m,u),(p=m._zod).deferred??(p.deferred=[]);for(const f of m._zod.deferred)f();return m}return Object.defineProperty(i,"init",{value:n}),Object.defineProperty(i,Symbol.hasInstance,{value:u=>o?.Parent&&u instanceof o.Parent?!0:u?._zod?.traits?.has(e)}),Object.defineProperty(i,"name",{value:e}),i}class ve extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}const po={};function te(e){return po}function hn(e){const t=Object.values(e).filter(n=>typeof n=="number");return Object.entries(e).filter(([n,r])=>t.indexOf(+n)===-1).map(([n,r])=>r)}function mn(e,t){return typeof t=="bigint"?t.toString():t}function ut(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function lt(e){return e==null}function dt(e){const t=e.startsWith("^")?1:0,o=e.endsWith("$")?e.length-1:e.length;return e.slice(t,o)}function fn(e,t){const o=(e.toString().split(".")[1]||"").length,n=(t.toString().split(".")[1]||"").length,r=o>n?o:n,s=Number.parseInt(e.toFixed(r).replace(".","")),i=Number.parseInt(t.toFixed(r).replace(".",""));return s%i/10**r}function C(e,t,o){Object.defineProperty(e,t,{get(){{const n=o();return e[t]=n,n}},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function Fe(e,t,o){Object.defineProperty(e,t,{value:o,writable:!0,enumerable:!0,configurable:!0})}function me(e){return JSON.stringify(e)}const ho=Error.captureStackTrace?Error.captureStackTrace:(...e)=>{};function De(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const gn=ut(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{const e=Function;return new e(""),!0}catch{return!1}});function Le(e){if(De(e)===!1)return!1;const t=e.constructor;if(t===void 0)return!0;const o=t.prototype;return!(De(o)===!1||Object.prototype.hasOwnProperty.call(o,"isPrototypeOf")===!1)}const vn=new Set(["string","number","symbol"]);function ke(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function ie(e,t,o){const n=new e._zod.constr(t??e._zod.def);return(!t||o?.parent)&&(n._zod.parent=e),n}function g(e){const t=e;if(!t)return{};if(typeof t=="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error=="string"?{...t,error:()=>t.error}:t}function _n(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}const bn={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function yn(e,t){const o={},n=e._zod.def;for(const r in t){if(!(r in n.shape))throw new Error(`Unrecognized key: "${r}"`);t[r]&&(o[r]=n.shape[r])}return ie(e,{...e._zod.def,shape:o,checks:[]})}function wn(e,t){const o={...e._zod.def.shape},n=e._zod.def;for(const r in t){if(!(r in n.shape))throw new Error(`Unrecognized key: "${r}"`);t[r]&&delete o[r]}return ie(e,{...e._zod.def,shape:o,checks:[]})}function kn(e,t){if(!Le(t))throw new Error("Invalid input to extend: expected a plain object");const o={...e._zod.def,get shape(){const n={...e._zod.def.shape,...t};return Fe(this,"shape",n),n},checks:[]};return ie(e,o)}function xn(e,t){return ie(e,{...e._zod.def,get shape(){const o={...e._zod.def.shape,...t._zod.def.shape};return Fe(this,"shape",o),o},catchall:t._zod.def.catchall,checks:[]})}function Sn(e,t,o){const n=t._zod.def.shape,r={...n};if(o)for(const s in o){if(!(s in n))throw new Error(`Unrecognized key: "${s}"`);o[s]&&(r[s]=e?new e({type:"optional",innerType:n[s]}):n[s])}else for(const s in n)r[s]=e?new e({type:"optional",innerType:n[s]}):n[s];return ie(t,{...t._zod.def,shape:r,checks:[]})}function Tn(e,t,o){const n=t._zod.def.shape,r={...n};if(o)for(const s in o){if(!(s in r))throw new Error(`Unrecognized key: "${s}"`);o[s]&&(r[s]=new e({type:"nonoptional",innerType:n[s]}))}else for(const s in n)r[s]=new e({type:"nonoptional",innerType:n[s]});return ie(t,{...t._zod.def,shape:r,checks:[]})}function ge(e,t=0){for(let o=t;o<e.issues.length;o++)if(e.issues[o]?.continue!==!0)return!0;return!1}function se(e,t){return t.map(o=>{var n;return(n=o).path??(n.path=[]),o.path.unshift(e),o})}function Ze(e){return typeof e=="string"?e:e?.message}function oe(e,t,o){const n={...e,path:e.path??[]};if(!e.message){const r=Ze(e.inst?._zod.def?.error?.(e))??Ze(t?.error?.(e))??Ze(o.customError?.(e))??Ze(o.localeError?.(e))??"Invalid input";n.message=r}return delete n.inst,delete n.continue,t?.reportInput||delete n.input,n}function pt(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function _e(...e){const[t,o,n]=e;return typeof t=="string"?{message:t,code:"custom",input:o,inst:n}:{...t}}const mo=(e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),Object.defineProperty(e,"message",{get(){return JSON.stringify(t,mn,2)},enumerable:!0}),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},fo=d("$ZodError",mo),go=d("$ZodError",mo,{Parent:Error});function zn(e,t=o=>o.message){const o={},n=[];for(const r of e.issues)r.path.length>0?(o[r.path[0]]=o[r.path[0]]||[],o[r.path[0]].push(t(r))):n.push(t(r));return{formErrors:n,fieldErrors:o}}function Rn(e,t){const o=t||function(s){return s.message},n={_errors:[]},r=s=>{for(const i of s.issues)if(i.code==="invalid_union"&&i.errors.length)i.errors.map(u=>r({issues:u}));else if(i.code==="invalid_key")r({issues:i.issues});else if(i.code==="invalid_element")r({issues:i.issues});else if(i.path.length===0)n._errors.push(o(i));else{let u=n,p=0;for(;p<i.path.length;){const m=i.path[p];p===i.path.length-1?(u[m]=u[m]||{_errors:[]},u[m]._errors.push(o(i))):u[m]=u[m]||{_errors:[]},u=u[m],p++}}};return r(e),n}const In=e=>(t,o,n,r)=>{const s=n?Object.assign(n,{async:!1}):{async:!1},i=t._zod.run({value:o,issues:[]},s);if(i instanceof Promise)throw new ve;if(i.issues.length){const u=new(r?.Err??e)(i.issues.map(p=>oe(p,s,te())));throw ho(u,r?.callee),u}return i.value},$n=e=>async(t,o,n,r)=>{const s=n?Object.assign(n,{async:!0}):{async:!0};let i=t._zod.run({value:o,issues:[]},s);if(i instanceof Promise&&(i=await i),i.issues.length){const u=new(r?.Err??e)(i.issues.map(p=>oe(p,s,te())));throw ho(u,r?.callee),u}return i.value},vo=e=>(t,o,n)=>{const r=n?{...n,async:!1}:{async:!1},s=t._zod.run({value:o,issues:[]},r);if(s instanceof Promise)throw new ve;return s.issues.length?{success:!1,error:new(e??fo)(s.issues.map(i=>oe(i,r,te())))}:{success:!0,data:s.value}},_o=vo(go),bo=e=>async(t,o,n)=>{const r=n?Object.assign(n,{async:!0}):{async:!0};let s=t._zod.run({value:o,issues:[]},r);return s instanceof Promise&&(s=await s),s.issues.length?{success:!1,error:new e(s.issues.map(i=>oe(i,r,te())))}:{success:!0,data:s.value}},Pn=bo(go),En=/^[cC][^\s-]{8,}$/,Zn=/^[0-9a-z]+$/,Cn=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,Nn=/^[0-9a-vA-V]{20}$/,qn=/^[A-Za-z0-9]{27}$/,Mn=/^[a-zA-Z0-9_-]{21}$/,On=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,An=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,Ut=e=>e?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000)$/,Dn=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,Ln="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function jn(){return new RegExp(Ln,"u")}const Un=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,Hn=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})$/,Fn=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,Bn=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Vn=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,yo=/^[A-Za-z0-9_-]*$/,Wn=/^([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+$/,Jn=/^\+(?:[0-9]){6,14}[0-9]$/,wo="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",Gn=new RegExp(`^${wo}$`);function ko(e){const t="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof e.precision=="number"?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function Kn(e){return new RegExp(`^${ko(e)}$`)}function Qn(e){const t=ko({precision:e.precision}),o=["Z"];e.local&&o.push(""),e.offset&&o.push("([+-]\\d{2}:\\d{2})");const n=`${t}(?:${o.join("|")})`;return new RegExp(`^${wo}T(?:${n})$`)}const Yn=e=>{const t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},Xn=/^\d+$/,er=/^-?\d+(?:\.\d+)?/i,tr=/true|false/i,or=/null/i,nr=/undefined/i,rr=/^[^A-Z]*$/,sr=/^[^a-z]*$/,V=d("$ZodCheck",(e,t)=>{var o;e._zod??(e._zod={}),e._zod.def=t,(o=e._zod).onattach??(o.onattach=[])}),xo={number:"number",bigint:"bigint",object:"date"},So=d("$ZodCheckLessThan",(e,t)=>{V.init(e,t);const o=xo[typeof t.value];e._zod.onattach.push(n=>{const r=n._zod.bag,s=(t.inclusive?r.maximum:r.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<s&&(t.inclusive?r.maximum=t.value:r.exclusiveMaximum=t.value)}),e._zod.check=n=>{(t.inclusive?n.value<=t.value:n.value<t.value)||n.issues.push({origin:o,code:"too_big",maximum:t.value,input:n.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),To=d("$ZodCheckGreaterThan",(e,t)=>{V.init(e,t);const o=xo[typeof t.value];e._zod.onattach.push(n=>{const r=n._zod.bag,s=(t.inclusive?r.minimum:r.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>s&&(t.inclusive?r.minimum=t.value:r.exclusiveMinimum=t.value)}),e._zod.check=n=>{(t.inclusive?n.value>=t.value:n.value>t.value)||n.issues.push({origin:o,code:"too_small",minimum:t.value,input:n.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),ir=d("$ZodCheckMultipleOf",(e,t)=>{V.init(e,t),e._zod.onattach.push(o=>{var n;(n=o._zod.bag).multipleOf??(n.multipleOf=t.value)}),e._zod.check=o=>{if(typeof o.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof o.value=="bigint"?o.value%t.value===BigInt(0):fn(o.value,t.value)===0)||o.issues.push({origin:typeof o.value,code:"not_multiple_of",divisor:t.value,input:o.value,inst:e,continue:!t.abort})}}),ar=d("$ZodCheckNumberFormat",(e,t)=>{V.init(e,t),t.format=t.format||"float64";const o=t.format?.includes("int"),n=o?"int":"number",[r,s]=bn[t.format];e._zod.onattach.push(i=>{const u=i._zod.bag;u.format=t.format,u.minimum=r,u.maximum=s,o&&(u.pattern=Xn)}),e._zod.check=i=>{const u=i.value;if(o){if(!Number.isInteger(u)){i.issues.push({expected:n,format:t.format,code:"invalid_type",input:u,inst:e});return}if(!Number.isSafeInteger(u)){u>0?i.issues.push({input:u,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:n,continue:!t.abort}):i.issues.push({input:u,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:n,continue:!t.abort});return}}u<r&&i.issues.push({origin:"number",input:u,code:"too_small",minimum:r,inclusive:!0,inst:e,continue:!t.abort}),u>s&&i.issues.push({origin:"number",input:u,code:"too_big",maximum:s,inst:e})}}),cr=d("$ZodCheckMaxLength",(e,t)=>{var o;V.init(e,t),(o=e._zod.def).when??(o.when=n=>{const r=n.value;return!lt(r)&&r.length!==void 0}),e._zod.onattach.push(n=>{const r=n._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<r&&(n._zod.bag.maximum=t.maximum)}),e._zod.check=n=>{const r=n.value;if(r.length<=t.maximum)return;const i=pt(r);n.issues.push({origin:i,code:"too_big",maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),ur=d("$ZodCheckMinLength",(e,t)=>{var o;V.init(e,t),(o=e._zod.def).when??(o.when=n=>{const r=n.value;return!lt(r)&&r.length!==void 0}),e._zod.onattach.push(n=>{const r=n._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>r&&(n._zod.bag.minimum=t.minimum)}),e._zod.check=n=>{const r=n.value;if(r.length>=t.minimum)return;const i=pt(r);n.issues.push({origin:i,code:"too_small",minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),lr=d("$ZodCheckLengthEquals",(e,t)=>{var o;V.init(e,t),(o=e._zod.def).when??(o.when=n=>{const r=n.value;return!lt(r)&&r.length!==void 0}),e._zod.onattach.push(n=>{const r=n._zod.bag;r.minimum=t.length,r.maximum=t.length,r.length=t.length}),e._zod.check=n=>{const r=n.value,s=r.length;if(s===t.length)return;const i=pt(r),u=s>t.length;n.issues.push({origin:i,...u?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),Be=d("$ZodCheckStringFormat",(e,t)=>{var o,n;V.init(e,t),e._zod.onattach.push(r=>{const s=r._zod.bag;s.format=t.format,t.pattern&&(s.patterns??(s.patterns=new Set),s.patterns.add(t.pattern))}),t.pattern?(o=e._zod).check??(o.check=r=>{t.pattern.lastIndex=0,!t.pattern.test(r.value)&&r.issues.push({origin:"string",code:"invalid_format",format:t.format,input:r.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(n=e._zod).check??(n.check=()=>{})}),dr=d("$ZodCheckRegex",(e,t)=>{Be.init(e,t),e._zod.check=o=>{t.pattern.lastIndex=0,!t.pattern.test(o.value)&&o.issues.push({origin:"string",code:"invalid_format",format:"regex",input:o.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),pr=d("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=rr),Be.init(e,t)}),hr=d("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=sr),Be.init(e,t)}),mr=d("$ZodCheckIncludes",(e,t)=>{V.init(e,t);const o=ke(t.includes),n=new RegExp(typeof t.position=="number"?`^.{${t.position}}${o}`:o);t.pattern=n,e._zod.onattach.push(r=>{const s=r._zod.bag;s.patterns??(s.patterns=new Set),s.patterns.add(n)}),e._zod.check=r=>{r.value.includes(t.includes,t.position)||r.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:r.value,inst:e,continue:!t.abort})}}),fr=d("$ZodCheckStartsWith",(e,t)=>{V.init(e,t);const o=new RegExp(`^${ke(t.prefix)}.*`);t.pattern??(t.pattern=o),e._zod.onattach.push(n=>{const r=n._zod.bag;r.patterns??(r.patterns=new Set),r.patterns.add(o)}),e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),gr=d("$ZodCheckEndsWith",(e,t)=>{V.init(e,t);const o=new RegExp(`.*${ke(t.suffix)}$`);t.pattern??(t.pattern=o),e._zod.onattach.push(n=>{const r=n._zod.bag;r.patterns??(r.patterns=new Set),r.patterns.add(o)}),e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}}),vr=d("$ZodCheckOverwrite",(e,t)=>{V.init(e,t),e._zod.check=o=>{o.value=t.tx(o.value)}});class _r{constructor(t=[]){this.content=[],this.indent=0,this&&(this.args=t)}indented(t){this.indent+=1,t(this),this.indent-=1}write(t){if(typeof t=="function"){t(this,{execution:"sync"}),t(this,{execution:"async"});return}const n=t.split(`
|
|
8
8
|
`).filter(i=>i),r=Math.min(...n.map(i=>i.length-i.trimStart().length)),s=n.map(i=>i.slice(r)).map(i=>" ".repeat(this.indent*2)+i);for(const i of s)this.content.push(i)}compile(){const t=Function,o=this?.args,r=[...(this?.content??[""]).map(s=>` ${s}`)];return new t(...o,r.join(`
|
|
9
|
-
`))}}const
|
|
9
|
+
`))}}const br={major:4,minor:0,patch:0},Z=d("$ZodType",(e,t)=>{var o;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=br;const n=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&n.unshift(e);for(const r of n)for(const s of r._zod.onattach)s(e);if(n.length===0)(o=e._zod).deferred??(o.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{const r=(s,i,u)=>{let p=ge(s),m;for(const f of i){if(f._zod.def.when){if(!f._zod.def.when(s))continue}else if(p)continue;const h=s.issues.length,v=f._zod.check(s);if(v instanceof Promise&&u?.async===!1)throw new ve;if(m||v instanceof Promise)m=(m??Promise.resolve()).then(async()=>{await v,s.issues.length!==h&&(p||(p=ge(s,h)))});else{if(s.issues.length===h)continue;p||(p=ge(s,h))}}return m?m.then(()=>s):s};e._zod.run=(s,i)=>{const u=e._zod.parse(s,i);if(u instanceof Promise){if(i.async===!1)throw new ve;return u.then(p=>r(p,n,i))}return r(u,n,i)}}e["~standard"]={validate:r=>{try{const s=_o(e,r);return s.success?{value:s.data}:{issues:s.error?.issues}}catch{return Pn(e,r).then(i=>i.success?{value:i.data}:{issues:i.error?.issues})}},vendor:"zod",version:1}}),ht=d("$ZodString",(e,t)=>{Z.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??Yn(e._zod.bag),e._zod.parse=(o,n)=>{if(t.coerce)try{o.value=String(o.value)}catch{}return typeof o.value=="string"||o.issues.push({expected:"string",code:"invalid_type",input:o.value,inst:e}),o}}),N=d("$ZodStringFormat",(e,t)=>{Be.init(e,t),ht.init(e,t)}),yr=d("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=An),N.init(e,t)}),wr=d("$ZodUUID",(e,t)=>{if(t.version){const n={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(n===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=Ut(n))}else t.pattern??(t.pattern=Ut());N.init(e,t)}),kr=d("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=Dn),N.init(e,t)}),xr=d("$ZodURL",(e,t)=>{N.init(e,t),e._zod.check=o=>{try{const n=o.value,r=new URL(n),s=r.href;t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(r.hostname)||o.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:Wn.source,input:o.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(r.protocol.endsWith(":")?r.protocol.slice(0,-1):r.protocol)||o.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:o.value,inst:e,continue:!t.abort})),!n.endsWith("/")&&s.endsWith("/")?o.value=s.slice(0,-1):o.value=s;return}catch{o.issues.push({code:"invalid_format",format:"url",input:o.value,inst:e,continue:!t.abort})}}}),Sr=d("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=jn()),N.init(e,t)}),Tr=d("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=Mn),N.init(e,t)}),zr=d("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=En),N.init(e,t)}),Rr=d("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=Zn),N.init(e,t)}),Ir=d("$ZodULID",(e,t)=>{t.pattern??(t.pattern=Cn),N.init(e,t)}),$r=d("$ZodXID",(e,t)=>{t.pattern??(t.pattern=Nn),N.init(e,t)}),Pr=d("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=qn),N.init(e,t)}),Er=d("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=Qn(t)),N.init(e,t)}),Zr=d("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=Gn),N.init(e,t)}),Cr=d("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=Kn(t)),N.init(e,t)}),Nr=d("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=On),N.init(e,t)}),qr=d("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=Un),N.init(e,t),e._zod.onattach.push(o=>{const n=o._zod.bag;n.format="ipv4"})}),Mr=d("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=Hn),N.init(e,t),e._zod.onattach.push(o=>{const n=o._zod.bag;n.format="ipv6"}),e._zod.check=o=>{try{new URL(`http://[${o.value}]`)}catch{o.issues.push({code:"invalid_format",format:"ipv6",input:o.value,inst:e,continue:!t.abort})}}}),Or=d("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=Fn),N.init(e,t)}),Ar=d("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=Bn),N.init(e,t),e._zod.check=o=>{const[n,r]=o.value.split("/");try{if(!r)throw new Error;const s=Number(r);if(`${s}`!==r)throw new Error;if(s<0||s>128)throw new Error;new URL(`http://[${n}]`)}catch{o.issues.push({code:"invalid_format",format:"cidrv6",input:o.value,inst:e,continue:!t.abort})}}});function zo(e){if(e==="")return!0;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}const Dr=d("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=Vn),N.init(e,t),e._zod.onattach.push(o=>{o._zod.bag.contentEncoding="base64"}),e._zod.check=o=>{zo(o.value)||o.issues.push({code:"invalid_format",format:"base64",input:o.value,inst:e,continue:!t.abort})}});function Lr(e){if(!yo.test(e))return!1;const t=e.replace(/[-_]/g,n=>n==="-"?"+":"/"),o=t.padEnd(Math.ceil(t.length/4)*4,"=");return zo(o)}const jr=d("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=yo),N.init(e,t),e._zod.onattach.push(o=>{o._zod.bag.contentEncoding="base64url"}),e._zod.check=o=>{Lr(o.value)||o.issues.push({code:"invalid_format",format:"base64url",input:o.value,inst:e,continue:!t.abort})}}),Ur=d("$ZodE164",(e,t)=>{t.pattern??(t.pattern=Jn),N.init(e,t)});function Hr(e,t=null){try{const o=e.split(".");if(o.length!==3)return!1;const[n]=o;if(!n)return!1;const r=JSON.parse(atob(n));return!("typ"in r&&r?.typ!=="JWT"||!r.alg||t&&(!("alg"in r)||r.alg!==t))}catch{return!1}}const Fr=d("$ZodJWT",(e,t)=>{N.init(e,t),e._zod.check=o=>{Hr(o.value,t.alg)||o.issues.push({code:"invalid_format",format:"jwt",input:o.value,inst:e,continue:!t.abort})}}),Ro=d("$ZodNumber",(e,t)=>{Z.init(e,t),e._zod.pattern=e._zod.bag.pattern??er,e._zod.parse=(o,n)=>{if(t.coerce)try{o.value=Number(o.value)}catch{}const r=o.value;if(typeof r=="number"&&!Number.isNaN(r)&&Number.isFinite(r))return o;const s=typeof r=="number"?Number.isNaN(r)?"NaN":Number.isFinite(r)?void 0:"Infinity":void 0;return o.issues.push({expected:"number",code:"invalid_type",input:r,inst:e,...s?{received:s}:{}}),o}}),Br=d("$ZodNumber",(e,t)=>{ar.init(e,t),Ro.init(e,t)}),Vr=d("$ZodBoolean",(e,t)=>{Z.init(e,t),e._zod.pattern=tr,e._zod.parse=(o,n)=>{if(t.coerce)try{o.value=!!o.value}catch{}const r=o.value;return typeof r=="boolean"||o.issues.push({expected:"boolean",code:"invalid_type",input:r,inst:e}),o}}),Wr=d("$ZodUndefined",(e,t)=>{Z.init(e,t),e._zod.pattern=nr,e._zod.values=new Set([void 0]),e._zod.optin="optional",e._zod.optout="optional",e._zod.parse=(o,n)=>{const r=o.value;return typeof r>"u"||o.issues.push({expected:"undefined",code:"invalid_type",input:r,inst:e}),o}}),Jr=d("$ZodNull",(e,t)=>{Z.init(e,t),e._zod.pattern=or,e._zod.values=new Set([null]),e._zod.parse=(o,n)=>{const r=o.value;return r===null||o.issues.push({expected:"null",code:"invalid_type",input:r,inst:e}),o}}),Gr=d("$ZodUnknown",(e,t)=>{Z.init(e,t),e._zod.parse=o=>o}),Kr=d("$ZodNever",(e,t)=>{Z.init(e,t),e._zod.parse=(o,n)=>(o.issues.push({expected:"never",code:"invalid_type",input:o.value,inst:e}),o)});function Ht(e,t,o){e.issues.length&&t.issues.push(...se(o,e.issues)),t.value[o]=e.value}const Qr=d("$ZodArray",(e,t)=>{Z.init(e,t),e._zod.parse=(o,n)=>{const r=o.value;if(!Array.isArray(r))return o.issues.push({expected:"array",code:"invalid_type",input:r,inst:e}),o;o.value=Array(r.length);const s=[];for(let i=0;i<r.length;i++){const u=r[i],p=t.element._zod.run({value:u,issues:[]},n);p instanceof Promise?s.push(p.then(m=>Ht(m,o,i))):Ht(p,o,i)}return s.length?Promise.all(s).then(()=>o):o}});function Ce(e,t,o){e.issues.length&&t.issues.push(...se(o,e.issues)),t.value[o]=e.value}function Ft(e,t,o,n){e.issues.length?n[o]===void 0?o in n?t.value[o]=void 0:t.value[o]=e.value:t.issues.push(...se(o,e.issues)):e.value===void 0?o in n&&(t.value[o]=void 0):t.value[o]=e.value}const Yr=d("$ZodObject",(e,t)=>{Z.init(e,t);const o=ut(()=>{const h=Object.keys(t.shape);for(const b of h)if(!(t.shape[b]instanceof Z))throw new Error(`Invalid element at key "${b}": expected a Zod schema`);const v=_n(t.shape);return{shape:t.shape,keys:h,keySet:new Set(h),numKeys:h.length,optionalKeys:new Set(v)}});C(e._zod,"propValues",()=>{const h=t.shape,v={};for(const b in h){const P=h[b]._zod;if(P.values){v[b]??(v[b]=new Set);for(const A of P.values)v[b].add(A)}}return v});const n=h=>{const v=new _r(["shape","payload","ctx"]),b=o.value,P=w=>{const y=me(w);return`shape[${y}]._zod.run({ value: input[${y}], issues: [] }, ctx)`};v.write("const input = payload.value;");const A=Object.create(null);let S=0;for(const w of b.keys)A[w]=`key_${S++}`;v.write("const newResult = {}");for(const w of b.keys)if(b.optionalKeys.has(w)){const y=A[w];v.write(`const ${y} = ${P(w)};`);const z=me(w);v.write(`
|
|
10
10
|
if (${y}.issues.length) {
|
|
11
|
-
if (input[${
|
|
12
|
-
if (${
|
|
13
|
-
newResult[${
|
|
11
|
+
if (input[${z}] === undefined) {
|
|
12
|
+
if (${z} in input) {
|
|
13
|
+
newResult[${z}] = undefined;
|
|
14
14
|
}
|
|
15
15
|
} else {
|
|
16
16
|
payload.issues = payload.issues.concat(
|
|
17
17
|
${y}.issues.map((iss) => ({
|
|
18
18
|
...iss,
|
|
19
|
-
path: iss.path ? [${
|
|
19
|
+
path: iss.path ? [${z}, ...iss.path] : [${z}],
|
|
20
20
|
}))
|
|
21
21
|
);
|
|
22
22
|
}
|
|
23
23
|
} else if (${y}.value === undefined) {
|
|
24
|
-
if (${
|
|
24
|
+
if (${z} in input) newResult[${z}] = undefined;
|
|
25
25
|
} else {
|
|
26
|
-
newResult[${
|
|
26
|
+
newResult[${z}] = ${y}.value;
|
|
27
27
|
}
|
|
28
|
-
`)}else{const y=w
|
|
28
|
+
`)}else{const y=A[w];v.write(`const ${y} = ${P(w)};`),v.write(`
|
|
29
29
|
if (${y}.issues.length) payload.issues = payload.issues.concat(${y}.issues.map(iss => ({
|
|
30
30
|
...iss,
|
|
31
|
-
path: iss.path ? [${
|
|
32
|
-
})));`),v.write(`newResult[${le(k)}] = ${y}.value`)}v.write("payload.value = newResult;"),v.write("return payload;");const W=v.compile();return(k,y)=>W(f,k,y)};let r;const s=Me,i=!ao.jitless,p=i&&hn.value,h=t.catchall;let m;e._zod.parse=(f,v)=>{m??(m=o.value);const b=f.value;if(!s(b))return f.issues.push({expected:"object",code:"invalid_type",input:b,inst:e}),f;const R=[];if(i&&p&&v?.async===!1&&v.jitless!==!0)r||(r=n(t.shape)),f=r(f,v);else{f.value={};const y=m.shape;for(const T of m.keys){const K=y[T],oe=K._zod.run({value:b[T],issues:[]},v),Mt=K._zod.optin==="optional"&&K._zod.optout==="optional";oe instanceof Promise?R.push(oe.then(Ot=>Mt?Lt(Ot,f,T,b):Pe(Ot,f,T))):Mt?Lt(oe,f,T,b):Pe(oe,f,T)}}if(!h)return R.length?Promise.all(R).then(()=>f):f;const w=[],j=m.keySet,W=h._zod,k=W.def.type;for(const y of Object.keys(b)){if(j.has(y))continue;if(k==="never"){w.push(y);continue}const T=W.run({value:b[y],issues:[]},v);T instanceof Promise?R.push(T.then(K=>Pe(K,f,y))):Pe(T,f,y)}return w.length&&f.issues.push({code:"unrecognized_keys",keys:w,input:b,inst:e}),R.length?Promise.all(R).then(()=>f):f}});function Ut(e,t,o,n){for(const r of e)if(r.issues.length===0)return t.value=r.value,t;return t.issues.push({code:"invalid_union",input:t.value,inst:o,errors:e.map(r=>r.issues.map(s=>ee(s,n,X())))}),t}const So=d("$ZodUnion",(e,t)=>{Z.init(e,t),C(e._zod,"optin",()=>t.options.some(o=>o._zod.optin==="optional")?"optional":void 0),C(e._zod,"optout",()=>t.options.some(o=>o._zod.optout==="optional")?"optional":void 0),C(e._zod,"values",()=>{if(t.options.every(o=>o._zod.values))return new Set(t.options.flatMap(o=>Array.from(o._zod.values)))}),C(e._zod,"pattern",()=>{if(t.options.every(o=>o._zod.pattern)){const o=t.options.map(n=>n._zod.pattern);return new RegExp(`^(${o.map(n=>at(n.source)).join("|")})$`)}}),e._zod.parse=(o,n)=>{let r=!1;const s=[];for(const i of t.options){const c=i._zod.run({value:o.value,issues:[]},n);if(c instanceof Promise)s.push(c),r=!0;else{if(c.issues.length===0)return c;s.push(c)}}return r?Promise.all(s).then(i=>Ut(i,o,e,n)):Ut(s,o,e,n)}}),Kr=d("$ZodDiscriminatedUnion",(e,t)=>{So.init(e,t);const o=e._zod.parse;C(e._zod,"propValues",()=>{const r={};for(const s of t.options){const i=s._zod.propValues;if(!i||Object.keys(i).length===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(s)}"`);for(const[c,p]of Object.entries(i)){r[c]||(r[c]=new Set);for(const h of p)r[c].add(h)}}return r});const n=st(()=>{const r=t.options,s=new Map;for(const i of r){const c=i._zod.propValues[t.discriminator];if(!c||c.size===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(i)}"`);for(const p of c){if(s.has(p))throw new Error(`Duplicate discriminator value "${String(p)}"`);s.set(p,i)}}return s});e._zod.parse=(r,s)=>{const i=r.value;if(!Me(i))return r.issues.push({code:"invalid_type",expected:"object",input:i,inst:e}),r;const c=n.value.get(i?.[t.discriminator]);return c?c._zod.run(r,s):t.unionFallback?o(r,s):(r.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",input:i,path:[t.discriminator],inst:e}),r)}}),Qr=d("$ZodIntersection",(e,t)=>{Z.init(e,t),e._zod.parse=(o,n)=>{const r=o.value,s=t.left._zod.run({value:r,issues:[]},n),i=t.right._zod.run({value:r,issues:[]},n);return s instanceof Promise||i instanceof Promise?Promise.all([s,i]).then(([p,h])=>jt(o,p,h)):jt(o,s,i)}});function Ye(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(Oe(e)&&Oe(t)){const o=Object.keys(t),n=Object.keys(e).filter(s=>o.indexOf(s)!==-1),r={...e,...t};for(const s of n){const i=Ye(e[s],t[s]);if(!i.valid)return{valid:!1,mergeErrorPath:[s,...i.mergeErrorPath]};r[s]=i.data}return{valid:!0,data:r}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};const o=[];for(let n=0;n<e.length;n++){const r=e[n],s=t[n],i=Ye(r,s);if(!i.valid)return{valid:!1,mergeErrorPath:[n,...i.mergeErrorPath]};o.push(i.data)}return{valid:!0,data:o}}return{valid:!1,mergeErrorPath:[]}}function jt(e,t,o){if(t.issues.length&&e.issues.push(...t.issues),o.issues.length&&e.issues.push(...o.issues),pe(e))return e;const n=Ye(t.value,o.value);if(!n.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(n.mergeErrorPath)}`);return e.value=n.data,e}const Yr=d("$ZodRecord",(e,t)=>{Z.init(e,t),e._zod.parse=(o,n)=>{const r=o.value;if(!Oe(r))return o.issues.push({expected:"record",code:"invalid_type",input:r,inst:e}),o;const s=[];if(t.keyType._zod.values){const i=t.keyType._zod.values;o.value={};for(const p of i)if(typeof p=="string"||typeof p=="number"||typeof p=="symbol"){const h=t.valueType._zod.run({value:r[p],issues:[]},n);h instanceof Promise?s.push(h.then(m=>{m.issues.length&&o.issues.push(...se(p,m.issues)),o.value[p]=m.value})):(h.issues.length&&o.issues.push(...se(p,h.issues)),o.value[p]=h.value)}let c;for(const p in r)i.has(p)||(c=c??[],c.push(p));c&&c.length>0&&o.issues.push({code:"unrecognized_keys",input:r,inst:e,keys:c})}else{o.value={};for(const i of Reflect.ownKeys(r)){if(i==="__proto__")continue;const c=t.keyType._zod.run({value:i,issues:[]},n);if(c instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(c.issues.length){o.issues.push({origin:"record",code:"invalid_key",issues:c.issues.map(h=>ee(h,n,X())),input:i,path:[i],inst:e}),o.value[c.value]=c.value;continue}const p=t.valueType._zod.run({value:r[i],issues:[]},n);p instanceof Promise?s.push(p.then(h=>{h.issues.length&&o.issues.push(...se(i,h.issues)),o.value[c.value]=h.value})):(p.issues.length&&o.issues.push(...se(i,p.issues)),o.value[c.value]=p.value)}}return s.length?Promise.all(s).then(()=>o):o}}),Xr=d("$ZodEnum",(e,t)=>{Z.init(e,t);const o=ln(t.entries);e._zod.values=new Set(o),e._zod.pattern=new RegExp(`^(${o.filter(n=>mn.has(typeof n)).map(n=>typeof n=="string"?_e(n):n.toString()).join("|")})$`),e._zod.parse=(n,r)=>{const s=n.value;return e._zod.values.has(s)||n.issues.push({code:"invalid_value",values:o,input:s,inst:e}),n}}),es=d("$ZodLiteral",(e,t)=>{Z.init(e,t),e._zod.values=new Set(t.values),e._zod.pattern=new RegExp(`^(${t.values.map(o=>typeof o=="string"?_e(o):o?o.toString():String(o)).join("|")})$`),e._zod.parse=(o,n)=>{const r=o.value;return e._zod.values.has(r)||o.issues.push({code:"invalid_value",values:t.values,input:r,inst:e}),o}}),ts=d("$ZodTransform",(e,t)=>{Z.init(e,t),e._zod.parse=(o,n)=>{const r=t.transform(o.value,o);if(n.async)return(r instanceof Promise?r:Promise.resolve(r)).then(i=>(o.value=i,o));if(r instanceof Promise)throw new he;return o.value=r,o}}),os=d("$ZodOptional",(e,t)=>{Z.init(e,t),e._zod.optin="optional",e._zod.optout="optional",C(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),C(e._zod,"pattern",()=>{const o=t.innerType._zod.pattern;return o?new RegExp(`^(${at(o.source)})?$`):void 0}),e._zod.parse=(o,n)=>t.innerType._zod.optin==="optional"?t.innerType._zod.run(o,n):o.value===void 0?o:t.innerType._zod.run(o,n)}),ns=d("$ZodNullable",(e,t)=>{Z.init(e,t),C(e._zod,"optin",()=>t.innerType._zod.optin),C(e._zod,"optout",()=>t.innerType._zod.optout),C(e._zod,"pattern",()=>{const o=t.innerType._zod.pattern;return o?new RegExp(`^(${at(o.source)}|null)$`):void 0}),C(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(o,n)=>o.value===null?o:t.innerType._zod.run(o,n)}),rs=d("$ZodDefault",(e,t)=>{Z.init(e,t),e._zod.optin="optional",C(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(o,n)=>{if(o.value===void 0)return o.value=t.defaultValue,o;const r=t.innerType._zod.run(o,n);return r instanceof Promise?r.then(s=>Ht(s,t)):Ht(r,t)}});function Ht(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const ss=d("$ZodPrefault",(e,t)=>{Z.init(e,t),e._zod.optin="optional",C(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(o,n)=>(o.value===void 0&&(o.value=t.defaultValue),t.innerType._zod.run(o,n))}),is=d("$ZodNonOptional",(e,t)=>{Z.init(e,t),C(e._zod,"values",()=>{const o=t.innerType._zod.values;return o?new Set([...o].filter(n=>n!==void 0)):void 0}),e._zod.parse=(o,n)=>{const r=t.innerType._zod.run(o,n);return r instanceof Promise?r.then(s=>Ft(s,e)):Ft(r,e)}});function Ft(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}const as=d("$ZodCatch",(e,t)=>{Z.init(e,t),e._zod.optin="optional",C(e._zod,"optout",()=>t.innerType._zod.optout),C(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(o,n)=>{const r=t.innerType._zod.run(o,n);return r instanceof Promise?r.then(s=>(o.value=s.value,s.issues.length&&(o.value=t.catchValue({...o,error:{issues:s.issues.map(i=>ee(i,n,X()))},input:o.value}),o.issues=[]),o)):(o.value=r.value,r.issues.length&&(o.value=t.catchValue({...o,error:{issues:r.issues.map(s=>ee(s,n,X()))},input:o.value}),o.issues=[]),o)}}),cs=d("$ZodPipe",(e,t)=>{Z.init(e,t),C(e._zod,"values",()=>t.in._zod.values),C(e._zod,"optin",()=>t.in._zod.optin),C(e._zod,"optout",()=>t.out._zod.optout),e._zod.parse=(o,n)=>{const r=t.in._zod.run(o,n);return r instanceof Promise?r.then(s=>Bt(s,t,n)):Bt(r,t,n)}});function Bt(e,t,o){return pe(e)?e:t.out._zod.run({value:e.value,issues:e.issues},o)}const us=d("$ZodReadonly",(e,t)=>{Z.init(e,t),C(e._zod,"propValues",()=>t.innerType._zod.propValues),C(e._zod,"values",()=>t.innerType._zod.values),C(e._zod,"optin",()=>t.innerType._zod.optin),C(e._zod,"optout",()=>t.innerType._zod.optout),e._zod.parse=(o,n)=>{const r=t.innerType._zod.run(o,n);return r instanceof Promise?r.then(Vt):Vt(r)}});function Vt(e){return e.value=Object.freeze(e.value),e}const ls=d("$ZodCustom",(e,t)=>{F.init(e,t),Z.init(e,t),e._zod.parse=(o,n)=>o,e._zod.check=o=>{const n=o.value,r=t.fn(n);if(r instanceof Promise)return r.then(s=>Wt(s,o,n,e));Wt(r,o,n,e)}});function Wt(e,t,o,n){if(!e){const r={code:"custom",input:o,inst:n,path:[...n._zod.def.path??[]],continue:!n._zod.def.abort};n._zod.def.params&&(r.params=n._zod.def.params),t.issues.push(me(r))}}class ds{constructor(){this._map=new Map,this._idmap=new Map}add(t,...o){const n=o[0];if(this._map.set(t,n),n&&typeof n=="object"&&"id"in n){if(this._idmap.has(n.id))throw new Error(`ID ${n.id} already exists in the registry`);this._idmap.set(n.id,t)}return this}clear(){return this._map=new Map,this._idmap=new Map,this}remove(t){const o=this._map.get(t);return o&&typeof o=="object"&&"id"in o&&this._idmap.delete(o.id),this._map.delete(t),this}get(t){const o=t._zod.parent;if(o){const n={...this.get(o)??{}};return delete n.id,{...n,...this._map.get(t)}}return this._map.get(t)}has(t){return this._map.has(t)}}function ps(){return new ds}const Ee=ps();function hs(e,t){return new e({type:"string",...g(t)})}function ms(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...g(t)})}function Jt(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...g(t)})}function fs(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...g(t)})}function gs(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...g(t)})}function vs(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...g(t)})}function _s(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...g(t)})}function bs(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...g(t)})}function ys(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...g(t)})}function ws(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...g(t)})}function ks(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...g(t)})}function xs(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...g(t)})}function Ss(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...g(t)})}function Ts(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...g(t)})}function zs(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...g(t)})}function Rs(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...g(t)})}function Is(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...g(t)})}function $s(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...g(t)})}function Ps(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...g(t)})}function Es(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...g(t)})}function Zs(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...g(t)})}function Cs(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...g(t)})}function Ns(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...g(t)})}function qs(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...g(t)})}function Ms(e,t){return new e({type:"string",format:"date",check:"string_format",...g(t)})}function Os(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...g(t)})}function As(e,t){return new e({type:"string",format:"duration",check:"string_format",...g(t)})}function Ds(e,t){return new e({type:"number",checks:[],...g(t)})}function Ls(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...g(t)})}function Us(e,t){return new e({type:"boolean",...g(t)})}function js(e,t){return new e({type:"undefined",...g(t)})}function Hs(e,t){return new e({type:"null",...g(t)})}function Fs(e){return new e({type:"unknown"})}function Bs(e,t){return new e({type:"never",...g(t)})}function Gt(e,t){return new yo({check:"less_than",...g(t),value:e,inclusive:!1})}function Je(e,t){return new yo({check:"less_than",...g(t),value:e,inclusive:!0})}function Kt(e,t){return new wo({check:"greater_than",...g(t),value:e,inclusive:!1})}function Ge(e,t){return new wo({check:"greater_than",...g(t),value:e,inclusive:!0})}function Qt(e,t){return new nr({check:"multiple_of",...g(t),value:e})}function To(e,t){return new sr({check:"max_length",...g(t),maximum:e})}function Ae(e,t){return new ir({check:"min_length",...g(t),minimum:e})}function zo(e,t){return new ar({check:"length_equals",...g(t),length:e})}function Vs(e,t){return new cr({check:"string_format",format:"regex",...g(t),pattern:e})}function Ws(e){return new ur({check:"string_format",format:"lowercase",...g(e)})}function Js(e){return new lr({check:"string_format",format:"uppercase",...g(e)})}function Gs(e,t){return new dr({check:"string_format",format:"includes",...g(t),includes:e})}function Ks(e,t){return new pr({check:"string_format",format:"starts_with",...g(t),prefix:e})}function Qs(e,t){return new hr({check:"string_format",format:"ends_with",...g(t),suffix:e})}function be(e){return new mr({check:"overwrite",tx:e})}function Ys(e){return be(t=>t.normalize(e))}function Xs(){return be(e=>e.trim())}function ei(){return be(e=>e.toLowerCase())}function ti(){return be(e=>e.toUpperCase())}function oi(e,t,o){return new e({type:"array",element:t,...g(o)})}function ni(e,t,o){const n=g(o);return n.abort??(n.abort=!0),new e({type:"custom",check:"custom",fn:t,...n})}function ri(e,t,o){return new e({type:"custom",check:"custom",fn:t,...g(o)})}function lt(e){return!!e._zod}function Ro(e,t){return lt(e)?mo(e,t):e.safeParse(t)}function si(e){if(!e)return;let t;if(lt(e)?t=e._zod?.def?.shape:t=e.shape,!!t){if(typeof t=="function")try{return t()}catch{return}return t}}function ii(e){if(lt(e)){const s=e._zod?.def;if(s){if(s.value!==void 0)return s.value;if(Array.isArray(s.values)&&s.values.length>0)return s.values[0]}}const o=e._def;if(o){if(o.value!==void 0)return o.value;if(Array.isArray(o.values)&&o.values.length>0)return o.values[0]}const n=e.value;if(n!==void 0)return n}const ai=d("ZodISODateTime",(e,t)=>{Ir.init(e,t),M.init(e,t)});function Io(e){return qs(ai,e)}const ci=d("ZodISODate",(e,t)=>{$r.init(e,t),M.init(e,t)});function ui(e){return Ms(ci,e)}const li=d("ZodISOTime",(e,t)=>{Pr.init(e,t),M.init(e,t)});function di(e){return Os(li,e)}const pi=d("ZodISODuration",(e,t)=>{Er.init(e,t),M.init(e,t)});function hi(e){return As(pi,e)}const mi=(e,t)=>{lo.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:o=>Sn(e,o)},flatten:{value:o=>xn(e,o)},addIssue:{value:o=>e.issues.push(o)},addIssues:{value:o=>e.issues.push(...o)},isEmpty:{get(){return e.issues.length===0}}})},He=d("ZodError",mi,{Parent:Error}),fi=Tn(He),gi=zn(He),vi=ho(He),_i=fo(He),q=d("ZodType",(e,t)=>(Z.init(e,t),e.def=t,Object.defineProperty(e,"_def",{value:t}),e.check=(...o)=>e.clone({...t,checks:[...t.checks??[],...o.map(n=>typeof n=="function"?{_zod:{check:n,def:{check:"custom"},onattach:[]}}:n)]}),e.clone=(o,n)=>ie(e,o,n),e.brand=()=>e,e.register=((o,n)=>(o.add(e,n),e)),e.parse=(o,n)=>fi(e,o,n,{callee:e.parse}),e.safeParse=(o,n)=>vi(e,o,n),e.parseAsync=async(o,n)=>gi(e,o,n,{callee:e.parseAsync}),e.safeParseAsync=async(o,n)=>_i(e,o,n),e.spa=e.safeParseAsync,e.refine=(o,n)=>e.check(ua(o,n)),e.superRefine=o=>e.check(la(o)),e.overwrite=o=>e.check(be(o)),e.optional=()=>O(e),e.nullable=()=>eo(e),e.nullish=()=>O(eo(e)),e.nonoptional=o=>ta(e,o),e.array=()=>_(e),e.or=o=>S([e,o]),e.and=o=>dt(e,o),e.transform=o=>tt(e,qo(o)),e.default=o=>Yi(e,o),e.prefault=o=>ea(e,o),e.catch=o=>na(e,o),e.pipe=o=>tt(e,o),e.readonly=()=>ia(e),e.describe=o=>{const n=e.clone();return Ee.add(n,{description:o}),n},Object.defineProperty(e,"description",{get(){return Ee.get(e)?.description},configurable:!0}),e.meta=(...o)=>{if(o.length===0)return Ee.get(e);const n=e.clone();return Ee.add(n,o[0]),n},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e)),$o=d("_ZodString",(e,t)=>{ut.init(e,t),q.init(e,t);const o=e._zod.bag;e.format=o.format??null,e.minLength=o.minimum??null,e.maxLength=o.maximum??null,e.regex=(...n)=>e.check(Vs(...n)),e.includes=(...n)=>e.check(Gs(...n)),e.startsWith=(...n)=>e.check(Ks(...n)),e.endsWith=(...n)=>e.check(Qs(...n)),e.min=(...n)=>e.check(Ae(...n)),e.max=(...n)=>e.check(To(...n)),e.length=(...n)=>e.check(zo(...n)),e.nonempty=(...n)=>e.check(Ae(1,...n)),e.lowercase=n=>e.check(Ws(n)),e.uppercase=n=>e.check(Js(n)),e.trim=()=>e.check(Xs()),e.normalize=(...n)=>e.check(Ys(...n)),e.toLowerCase=()=>e.check(ei()),e.toUpperCase=()=>e.check(ti())}),bi=d("ZodString",(e,t)=>{ut.init(e,t),$o.init(e,t),e.email=o=>e.check(ms(yi,o)),e.url=o=>e.check(bs(wi,o)),e.jwt=o=>e.check(Ns(Mi,o)),e.emoji=o=>e.check(ys(ki,o)),e.guid=o=>e.check(Jt(Yt,o)),e.uuid=o=>e.check(fs(Ze,o)),e.uuidv4=o=>e.check(gs(Ze,o)),e.uuidv6=o=>e.check(vs(Ze,o)),e.uuidv7=o=>e.check(_s(Ze,o)),e.nanoid=o=>e.check(ws(xi,o)),e.guid=o=>e.check(Jt(Yt,o)),e.cuid=o=>e.check(ks(Si,o)),e.cuid2=o=>e.check(xs(Ti,o)),e.ulid=o=>e.check(Ss(zi,o)),e.base64=o=>e.check(Es(Ci,o)),e.base64url=o=>e.check(Zs(Ni,o)),e.xid=o=>e.check(Ts(Ri,o)),e.ksuid=o=>e.check(zs(Ii,o)),e.ipv4=o=>e.check(Rs($i,o)),e.ipv6=o=>e.check(Is(Pi,o)),e.cidrv4=o=>e.check($s(Ei,o)),e.cidrv6=o=>e.check(Ps(Zi,o)),e.e164=o=>e.check(Cs(qi,o)),e.datetime=o=>e.check(Io(o)),e.date=o=>e.check(ui(o)),e.time=o=>e.check(di(o)),e.duration=o=>e.check(hi(o))});function u(e){return hs(bi,e)}const M=d("ZodStringFormat",(e,t)=>{N.init(e,t),$o.init(e,t)}),yi=d("ZodEmail",(e,t)=>{br.init(e,t),M.init(e,t)}),Yt=d("ZodGUID",(e,t)=>{vr.init(e,t),M.init(e,t)}),Ze=d("ZodUUID",(e,t)=>{_r.init(e,t),M.init(e,t)}),wi=d("ZodURL",(e,t)=>{yr.init(e,t),M.init(e,t)}),ki=d("ZodEmoji",(e,t)=>{wr.init(e,t),M.init(e,t)}),xi=d("ZodNanoID",(e,t)=>{kr.init(e,t),M.init(e,t)}),Si=d("ZodCUID",(e,t)=>{xr.init(e,t),M.init(e,t)}),Ti=d("ZodCUID2",(e,t)=>{Sr.init(e,t),M.init(e,t)}),zi=d("ZodULID",(e,t)=>{Tr.init(e,t),M.init(e,t)}),Ri=d("ZodXID",(e,t)=>{zr.init(e,t),M.init(e,t)}),Ii=d("ZodKSUID",(e,t)=>{Rr.init(e,t),M.init(e,t)}),$i=d("ZodIPv4",(e,t)=>{Zr.init(e,t),M.init(e,t)}),Pi=d("ZodIPv6",(e,t)=>{Cr.init(e,t),M.init(e,t)}),Ei=d("ZodCIDRv4",(e,t)=>{Nr.init(e,t),M.init(e,t)}),Zi=d("ZodCIDRv6",(e,t)=>{qr.init(e,t),M.init(e,t)}),Ci=d("ZodBase64",(e,t)=>{Mr.init(e,t),M.init(e,t)}),Ni=d("ZodBase64URL",(e,t)=>{Ar.init(e,t),M.init(e,t)}),qi=d("ZodE164",(e,t)=>{Dr.init(e,t),M.init(e,t)}),Mi=d("ZodJWT",(e,t)=>{Ur.init(e,t),M.init(e,t)}),Po=d("ZodNumber",(e,t)=>{xo.init(e,t),q.init(e,t),e.gt=(n,r)=>e.check(Kt(n,r)),e.gte=(n,r)=>e.check(Ge(n,r)),e.min=(n,r)=>e.check(Ge(n,r)),e.lt=(n,r)=>e.check(Gt(n,r)),e.lte=(n,r)=>e.check(Je(n,r)),e.max=(n,r)=>e.check(Je(n,r)),e.int=n=>e.check(Xt(n)),e.safe=n=>e.check(Xt(n)),e.positive=n=>e.check(Kt(0,n)),e.nonnegative=n=>e.check(Ge(0,n)),e.negative=n=>e.check(Gt(0,n)),e.nonpositive=n=>e.check(Je(0,n)),e.multipleOf=(n,r)=>e.check(Qt(n,r)),e.step=(n,r)=>e.check(Qt(n,r)),e.finite=()=>e;const o=e._zod.bag;e.minValue=Math.max(o.minimum??Number.NEGATIVE_INFINITY,o.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(o.maximum??Number.POSITIVE_INFINITY,o.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(o.format??"").includes("int")||Number.isSafeInteger(o.multipleOf??.5),e.isFinite=!0,e.format=o.format??null});function x(e){return Ds(Po,e)}const Oi=d("ZodNumberFormat",(e,t)=>{jr.init(e,t),Po.init(e,t)});function Xt(e){return Ls(Oi,e)}const Ai=d("ZodBoolean",(e,t)=>{Hr.init(e,t),q.init(e,t)});function E(e){return Us(Ai,e)}const Di=d("ZodUndefined",(e,t)=>{Fr.init(e,t),q.init(e,t)});function Xe(e){return js(Di,e)}const Li=d("ZodNull",(e,t)=>{Br.init(e,t),q.init(e,t)});function Eo(e){return Hs(Li,e)}const Ui=d("ZodUnknown",(e,t)=>{Vr.init(e,t),q.init(e,t)});function P(){return Fs(Ui)}const ji=d("ZodNever",(e,t)=>{Wr.init(e,t),q.init(e,t)});function Hi(e){return Bs(ji,e)}const Fi=d("ZodArray",(e,t)=>{Jr.init(e,t),q.init(e,t),e.element=t.element,e.min=(o,n)=>e.check(Ae(o,n)),e.nonempty=o=>e.check(Ae(1,o)),e.max=(o,n)=>e.check(To(o,n)),e.length=(o,n)=>e.check(zo(o,n)),e.unwrap=()=>e.element});function _(e,t){return oi(Fi,e,t)}const Zo=d("ZodObject",(e,t)=>{Gr.init(e,t),q.init(e,t),C(e,"shape",()=>t.shape),e.keyof=()=>B(Object.keys(e._zod.def.shape)),e.catchall=o=>e.clone({...e._zod.def,catchall:o}),e.passthrough=()=>e.clone({...e._zod.def,catchall:P()}),e.loose=()=>e.clone({...e._zod.def,catchall:P()}),e.strict=()=>e.clone({...e._zod.def,catchall:Hi()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=o=>bn(e,o),e.merge=o=>yn(e,o),e.pick=o=>vn(e,o),e.omit=o=>_n(e,o),e.partial=(...o)=>wn(Mo,e,o[0]),e.required=(...o)=>kn(Oo,e,o[0])});function l(e,t){const o={type:"object",get shape(){return Ue(this,"shape",{...e}),this.shape},...g(t)};return new Zo(o)}function H(e,t){return new Zo({type:"object",get shape(){return Ue(this,"shape",{...e}),this.shape},catchall:P(),...g(t)})}const Co=d("ZodUnion",(e,t)=>{So.init(e,t),q.init(e,t),e.options=t.options});function S(e,t){return new Co({type:"union",options:e,...g(t)})}const Bi=d("ZodDiscriminatedUnion",(e,t)=>{Co.init(e,t),Kr.init(e,t)});function No(e,t,o){return new Bi({type:"union",options:t,discriminator:e,...g(o)})}const Vi=d("ZodIntersection",(e,t)=>{Qr.init(e,t),q.init(e,t)});function dt(e,t){return new Vi({type:"intersection",left:e,right:t})}const Wi=d("ZodRecord",(e,t)=>{Yr.init(e,t),q.init(e,t),e.keyType=t.keyType,e.valueType=t.valueType});function $(e,t,o){return new Wi({type:"record",keyType:e,valueType:t,...g(o)})}const et=d("ZodEnum",(e,t)=>{Xr.init(e,t),q.init(e,t),e.enum=t.entries,e.options=Object.values(t.entries);const o=new Set(Object.keys(t.entries));e.extract=(n,r)=>{const s={};for(const i of n)if(o.has(i))s[i]=t.entries[i];else throw new Error(`Key ${i} not found in enum`);return new et({...t,checks:[],...g(r),entries:s})},e.exclude=(n,r)=>{const s={...t.entries};for(const i of n)if(o.has(i))delete s[i];else throw new Error(`Key ${i} not found in enum`);return new et({...t,checks:[],...g(r),entries:s})}});function B(e,t){const o=Array.isArray(e)?Object.fromEntries(e.map(n=>[n,n])):e;return new et({type:"enum",entries:o,...g(t)})}const Ji=d("ZodLiteral",(e,t)=>{es.init(e,t),q.init(e,t),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function a(e,t){return new Ji({type:"literal",values:Array.isArray(e)?e:[e],...g(t)})}const Gi=d("ZodTransform",(e,t)=>{ts.init(e,t),q.init(e,t),e._zod.parse=(o,n)=>{o.addIssue=s=>{if(typeof s=="string")o.issues.push(me(s,o.value,t));else{const i=s;i.fatal&&(i.continue=!1),i.code??(i.code="custom"),i.input??(i.input=o.value),i.inst??(i.inst=e),i.continue??(i.continue=!0),o.issues.push(me(i))}};const r=t.transform(o.value,o);return r instanceof Promise?r.then(s=>(o.value=s,o)):(o.value=r,o)}});function qo(e){return new Gi({type:"transform",transform:e})}const Mo=d("ZodOptional",(e,t)=>{os.init(e,t),q.init(e,t),e.unwrap=()=>e._zod.def.innerType});function O(e){return new Mo({type:"optional",innerType:e})}const Ki=d("ZodNullable",(e,t)=>{ns.init(e,t),q.init(e,t),e.unwrap=()=>e._zod.def.innerType});function eo(e){return new Ki({type:"nullable",innerType:e})}const Qi=d("ZodDefault",(e,t)=>{rs.init(e,t),q.init(e,t),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Yi(e,t){return new Qi({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():t}})}const Xi=d("ZodPrefault",(e,t)=>{ss.init(e,t),q.init(e,t),e.unwrap=()=>e._zod.def.innerType});function ea(e,t){return new Xi({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():t}})}const Oo=d("ZodNonOptional",(e,t)=>{is.init(e,t),q.init(e,t),e.unwrap=()=>e._zod.def.innerType});function ta(e,t){return new Oo({type:"nonoptional",innerType:e,...g(t)})}const oa=d("ZodCatch",(e,t)=>{as.init(e,t),q.init(e,t),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function na(e,t){return new oa({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}const ra=d("ZodPipe",(e,t)=>{cs.init(e,t),q.init(e,t),e.in=t.in,e.out=t.out});function tt(e,t){return new ra({type:"pipe",in:e,out:t})}const sa=d("ZodReadonly",(e,t)=>{us.init(e,t),q.init(e,t)});function ia(e){return new sa({type:"readonly",innerType:e})}const Ao=d("ZodCustom",(e,t)=>{ls.init(e,t),q.init(e,t)});function aa(e){const t=new F({check:"custom"});return t._zod.check=e,t}function ca(e,t){return ni(Ao,e??(()=>!0),t)}function ua(e,t={}){return ri(Ao,e,t)}function la(e){const t=aa(o=>(o.addIssue=n=>{if(typeof n=="string")o.issues.push(me(n,o.value,t._zod.def));else{const r=n;r.fatal&&(r.continue=!1),r.code??(r.code="custom"),r.input??(r.input=o.value),r.inst??(r.inst=t),r.continue??(r.continue=!t._zod.def.abort),o.issues.push(me(r))}},e(o.value,o)));return t}function Do(e,t){return tt(qo(e),t)}const re="io.modelcontextprotocol/related-task",Fe="2.0",A=ca(e=>e!==null&&(typeof e=="object"||typeof e=="function")),Lo=S([u(),x().int()]),Uo=u();H({ttl:S([x(),Eo()]).optional(),pollInterval:x().optional()});const da=l({ttl:x().optional()}),pa=l({taskId:u()}),pt=H({progressToken:Lo.optional(),[re]:pa.optional()}),V=l({_meta:pt.optional()}),ye=V.extend({task:da.optional()}),ha=e=>ye.safeParse(e).success,D=l({method:u(),params:V.loose().optional()}),J=l({_meta:pt.optional()}),G=l({method:u(),params:J.loose().optional()}),L=H({_meta:pt.optional()}),we=S([u(),x().int()]),jo=l({jsonrpc:a(Fe),id:we,...D.shape}).strict(),to=e=>jo.safeParse(e).success,Ho=l({jsonrpc:a(Fe),...G.shape}).strict(),ma=e=>Ho.safeParse(e).success,ht=l({jsonrpc:a(Fe),id:we,result:L}).strict(),Ce=e=>ht.safeParse(e).success;var I;(function(e){e[e.ConnectionClosed=-32e3]="ConnectionClosed",e[e.RequestTimeout=-32001]="RequestTimeout",e[e.ParseError=-32700]="ParseError",e[e.InvalidRequest=-32600]="InvalidRequest",e[e.MethodNotFound=-32601]="MethodNotFound",e[e.InvalidParams=-32602]="InvalidParams",e[e.InternalError=-32603]="InternalError",e[e.UrlElicitationRequired=-32042]="UrlElicitationRequired"})(I||(I={}));const mt=l({jsonrpc:a(Fe),id:we.optional(),error:l({code:x().int(),message:u(),data:P().optional()})}).strict(),fa=e=>mt.safeParse(e).success,ga=S([jo,Ho,ht,mt]);S([ht,mt]);const ft=L.strict(),va=J.extend({requestId:we.optional(),reason:u().optional()}),gt=G.extend({method:a("notifications/cancelled"),params:va}),_a=l({src:u(),mimeType:u().optional(),sizes:_(u()).optional(),theme:B(["light","dark"]).optional()}),ke=l({icons:_(_a).optional()}),ce=l({name:u(),title:u().optional()}),Be=ce.extend({...ce.shape,...ke.shape,version:u(),websiteUrl:u().optional(),description:u().optional()}),ba=dt(l({applyDefaults:E().optional()}),$(u(),P())),ya=Do(e=>e&&typeof e=="object"&&!Array.isArray(e)&&Object.keys(e).length===0?{form:{}}:e,dt(l({form:ba.optional(),url:A.optional()}),$(u(),P()).optional())),wa=H({list:A.optional(),cancel:A.optional(),requests:H({sampling:H({createMessage:A.optional()}).optional(),elicitation:H({create:A.optional()}).optional()}).optional()}),ka=H({list:A.optional(),cancel:A.optional(),requests:H({tools:H({call:A.optional()}).optional()}).optional()}),xa=l({experimental:$(u(),A).optional(),sampling:l({context:A.optional(),tools:A.optional()}).optional(),elicitation:ya.optional(),roots:l({listChanged:E().optional()}).optional(),tasks:wa.optional()}),Sa=V.extend({protocolVersion:u(),capabilities:xa,clientInfo:Be}),Ta=D.extend({method:a("initialize"),params:Sa}),za=l({experimental:$(u(),A).optional(),logging:A.optional(),completions:A.optional(),prompts:l({listChanged:E().optional()}).optional(),resources:l({subscribe:E().optional(),listChanged:E().optional()}).optional(),tools:l({listChanged:E().optional()}).optional(),tasks:ka.optional()}),Ra=L.extend({protocolVersion:u(),capabilities:za,serverInfo:Be,instructions:u().optional()}),Ia=G.extend({method:a("notifications/initialized"),params:J.optional()}),Ve=D.extend({method:a("ping"),params:V.optional()}),$a=l({progress:x(),total:O(x()),message:O(u())}),Pa=l({...J.shape,...$a.shape,progressToken:Lo}),vt=G.extend({method:a("notifications/progress"),params:Pa}),Ea=V.extend({cursor:Uo.optional()}),xe=D.extend({params:Ea.optional()}),Se=L.extend({nextCursor:Uo.optional()}),Za=B(["working","input_required","completed","failed","cancelled"]),Te=l({taskId:u(),status:Za,ttl:S([x(),Eo()]),createdAt:u(),lastUpdatedAt:u(),pollInterval:O(x()),statusMessage:O(u())}),_t=L.extend({task:Te}),Ca=J.merge(Te),De=G.extend({method:a("notifications/tasks/status"),params:Ca}),bt=D.extend({method:a("tasks/get"),params:V.extend({taskId:u()})}),yt=L.merge(Te),wt=D.extend({method:a("tasks/result"),params:V.extend({taskId:u()})});L.loose();const kt=xe.extend({method:a("tasks/list")}),xt=Se.extend({tasks:_(Te)}),St=D.extend({method:a("tasks/cancel"),params:V.extend({taskId:u()})}),Na=L.merge(Te),Fo=l({uri:u(),mimeType:O(u()),_meta:$(u(),P()).optional()}),Bo=Fo.extend({text:u()}),Tt=u().refine(e=>{try{return atob(e),!0}catch{return!1}},{message:"Invalid Base64 string"}),Vo=Fo.extend({blob:Tt}),ze=B(["user","assistant"]),ue=l({audience:_(ze).optional(),priority:x().min(0).max(1).optional(),lastModified:Io({offset:!0}).optional()}),Wo=l({...ce.shape,...ke.shape,uri:u(),description:O(u()),mimeType:O(u()),annotations:ue.optional(),_meta:O(H({}))}),qa=l({...ce.shape,...ke.shape,uriTemplate:u(),description:O(u()),mimeType:O(u()),annotations:ue.optional(),_meta:O(H({}))}),Ma=xe.extend({method:a("resources/list")}),Jo=Se.extend({resources:_(Wo)}),Oa=xe.extend({method:a("resources/templates/list")}),Aa=Se.extend({resourceTemplates:_(qa)}),zt=V.extend({uri:u()}),Da=zt,La=D.extend({method:a("resources/read"),params:Da}),Go=L.extend({contents:_(S([Bo,Vo]))}),Ua=G.extend({method:a("notifications/resources/list_changed"),params:J.optional()}),ja=zt,Ha=D.extend({method:a("resources/subscribe"),params:ja}),Fa=zt,Ba=D.extend({method:a("resources/unsubscribe"),params:Fa}),Va=J.extend({uri:u()}),Wa=G.extend({method:a("notifications/resources/updated"),params:Va}),Ja=l({name:u(),description:O(u()),required:O(E())}),Ga=l({...ce.shape,...ke.shape,description:O(u()),arguments:O(_(Ja)),_meta:O(H({}))}),Ka=xe.extend({method:a("prompts/list")}),Qa=Se.extend({prompts:_(Ga)}),Ya=V.extend({name:u(),arguments:$(u(),u()).optional()}),Xa=D.extend({method:a("prompts/get"),params:Ya}),Rt=l({type:a("text"),text:u(),annotations:ue.optional(),_meta:$(u(),P()).optional()}),It=l({type:a("image"),data:Tt,mimeType:u(),annotations:ue.optional(),_meta:$(u(),P()).optional()}),$t=l({type:a("audio"),data:Tt,mimeType:u(),annotations:ue.optional(),_meta:$(u(),P()).optional()}),ec=l({type:a("tool_use"),name:u(),id:u(),input:$(u(),P()),_meta:$(u(),P()).optional()}),Ko=l({type:a("resource"),resource:S([Bo,Vo]),annotations:ue.optional(),_meta:$(u(),P()).optional()}),Qo=Wo.extend({type:a("resource_link")}),Re=S([Rt,It,$t,Qo,Ko]),tc=l({role:ze,content:Re}),oc=L.extend({description:u().optional(),messages:_(tc)}),nc=G.extend({method:a("notifications/prompts/list_changed"),params:J.optional()}),rc=l({title:u().optional(),readOnlyHint:E().optional(),destructiveHint:E().optional(),idempotentHint:E().optional(),openWorldHint:E().optional()}),sc=l({taskSupport:B(["required","optional","forbidden"]).optional()}),Pt=l({...ce.shape,...ke.shape,description:u().optional(),inputSchema:l({type:a("object"),properties:$(u(),A).optional(),required:_(u()).optional()}).catchall(P()),outputSchema:l({type:a("object"),properties:$(u(),A).optional(),required:_(u()).optional()}).catchall(P()).optional(),annotations:rc.optional(),execution:sc.optional(),_meta:$(u(),P()).optional()}),Yo=xe.extend({method:a("tools/list")}),ic=Se.extend({tools:_(Pt)}),We=L.extend({content:_(Re).default([]),structuredContent:$(u(),P()).optional(),isError:E().optional()});We.or(L.extend({toolResult:P()}));const ac=ye.extend({name:u(),arguments:$(u(),P()).optional()}),Xo=D.extend({method:a("tools/call"),params:ac}),cc=G.extend({method:a("notifications/tools/list_changed"),params:J.optional()});l({autoRefresh:E().default(!0),debounceMs:x().int().nonnegative().default(300)});const en=B(["debug","info","notice","warning","error","critical","alert","emergency"]),uc=V.extend({level:en}),lc=D.extend({method:a("logging/setLevel"),params:uc}),dc=J.extend({level:en,logger:u().optional(),data:P()}),pc=G.extend({method:a("notifications/message"),params:dc}),hc=l({name:u().optional()}),mc=l({hints:_(hc).optional(),costPriority:x().min(0).max(1).optional(),speedPriority:x().min(0).max(1).optional(),intelligencePriority:x().min(0).max(1).optional()}),fc=l({mode:B(["auto","required","none"]).optional()}),gc=l({type:a("tool_result"),toolUseId:u().describe("The unique identifier for the corresponding tool call."),content:_(Re).default([]),structuredContent:l({}).loose().optional(),isError:E().optional(),_meta:$(u(),P()).optional()}),vc=No("type",[Rt,It,$t]),Le=No("type",[Rt,It,$t,ec,gc]),_c=l({role:ze,content:S([Le,_(Le)]),_meta:$(u(),P()).optional()}),bc=ye.extend({messages:_(_c),modelPreferences:mc.optional(),systemPrompt:u().optional(),includeContext:B(["none","thisServer","allServers"]).optional(),temperature:x().optional(),maxTokens:x().int(),stopSequences:_(u()).optional(),metadata:A.optional(),tools:_(Pt).optional(),toolChoice:fc.optional()}),yc=D.extend({method:a("sampling/createMessage"),params:bc}),wc=L.extend({model:u(),stopReason:O(B(["endTurn","stopSequence","maxTokens"]).or(u())),role:ze,content:vc}),kc=L.extend({model:u(),stopReason:O(B(["endTurn","stopSequence","maxTokens","toolUse"]).or(u())),role:ze,content:S([Le,_(Le)])}),xc=l({type:a("boolean"),title:u().optional(),description:u().optional(),default:E().optional()}),Sc=l({type:a("string"),title:u().optional(),description:u().optional(),minLength:x().optional(),maxLength:x().optional(),format:B(["email","uri","date","date-time"]).optional(),default:u().optional()}),Tc=l({type:B(["number","integer"]),title:u().optional(),description:u().optional(),minimum:x().optional(),maximum:x().optional(),default:x().optional()}),zc=l({type:a("string"),title:u().optional(),description:u().optional(),enum:_(u()),default:u().optional()}),Rc=l({type:a("string"),title:u().optional(),description:u().optional(),oneOf:_(l({const:u(),title:u()})),default:u().optional()}),Ic=l({type:a("string"),title:u().optional(),description:u().optional(),enum:_(u()),enumNames:_(u()).optional(),default:u().optional()}),$c=S([zc,Rc]),Pc=l({type:a("array"),title:u().optional(),description:u().optional(),minItems:x().optional(),maxItems:x().optional(),items:l({type:a("string"),enum:_(u())}),default:_(u()).optional()}),Ec=l({type:a("array"),title:u().optional(),description:u().optional(),minItems:x().optional(),maxItems:x().optional(),items:l({anyOf:_(l({const:u(),title:u()}))}),default:_(u()).optional()}),Zc=S([Pc,Ec]),Cc=S([Ic,$c,Zc]),Nc=S([Cc,xc,Sc,Tc]),qc=ye.extend({mode:a("form").optional(),message:u(),requestedSchema:l({type:a("object"),properties:$(u(),Nc),required:_(u()).optional()})}),Mc=ye.extend({mode:a("url"),message:u(),elicitationId:u(),url:u().url()}),Oc=S([qc,Mc]),Ac=D.extend({method:a("elicitation/create"),params:Oc}),Dc=J.extend({elicitationId:u()}),Lc=G.extend({method:a("notifications/elicitation/complete"),params:Dc}),Uc=L.extend({action:B(["accept","decline","cancel"]),content:Do(e=>e===null?void 0:e,$(u(),S([u(),x(),E(),_(u())])).optional())}),jc=l({type:a("ref/resource"),uri:u()}),Hc=l({type:a("ref/prompt"),name:u()}),Fc=V.extend({ref:S([Hc,jc]),argument:l({name:u(),value:u()}),context:l({arguments:$(u(),u()).optional()}).optional()}),Bc=D.extend({method:a("completion/complete"),params:Fc}),Vc=L.extend({completion:H({values:_(u()).max(100),total:O(x().int()),hasMore:O(E())})}),Wc=l({uri:u().startsWith("file://"),name:u().optional(),_meta:$(u(),P()).optional()}),Jc=D.extend({method:a("roots/list"),params:V.optional()}),Gc=L.extend({roots:_(Wc)}),Kc=G.extend({method:a("notifications/roots/list_changed"),params:J.optional()});S([Ve,Ta,Bc,lc,Xa,Ka,Ma,Oa,La,Ha,Ba,Xo,Yo,bt,wt,kt,St]);S([gt,vt,Ia,Kc,De]);S([ft,wc,kc,Uc,Gc,yt,xt,_t]);S([Ve,yc,Ac,Jc,bt,wt,kt,St]);S([gt,vt,pc,Wa,Ua,cc,nc,De,Lc]);S([ft,Ra,Vc,oc,Qa,Jo,Aa,Go,We,ic,yt,xt,_t]);class z extends Error{constructor(t,o,n){super(`MCP error ${t}: ${o}`),this.code=t,this.data=n,this.name="McpError"}static fromError(t,o,n){if(t===I.UrlElicitationRequired&&n){const r=n;if(r.elicitations)return new Qc(r.elicitations,o)}return new z(t,o,n)}}class Qc extends z{constructor(t,o=`URL elicitation${t.length>1?"s":""} required`){super(I.UrlElicitationRequired,o,{elicitations:t})}get elicitations(){return this.data?.elicitations??[]}}function ne(e){return e==="completed"||e==="failed"||e==="cancelled"}new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function oo(e){const o=si(e)?.method;if(!o)throw new Error("Schema is missing a method literal");const n=ii(o);if(typeof n!="string")throw new Error("Schema method literal must be a string");return n}function no(e,t){const o=Ro(e,t);if(!o.success)throw o.error;return o.data}const Yc=6e4;class Xc{constructor(t){this._options=t,this._requestMessageId=0,this._requestHandlers=new Map,this._requestHandlerAbortControllers=new Map,this._notificationHandlers=new Map,this._responseHandlers=new Map,this._progressHandlers=new Map,this._timeoutInfo=new Map,this._pendingDebouncedNotifications=new Set,this._taskProgressTokens=new Map,this._requestResolvers=new Map,this.setNotificationHandler(gt,o=>{this._oncancel(o)}),this.setNotificationHandler(vt,o=>{this._onprogress(o)}),this.setRequestHandler(Ve,o=>({})),this._taskStore=t?.taskStore,this._taskMessageQueue=t?.taskMessageQueue,this._taskStore&&(this.setRequestHandler(bt,async(o,n)=>{const r=await this._taskStore.getTask(o.params.taskId,n.sessionId);if(!r)throw new z(I.InvalidParams,"Failed to retrieve task: Task not found");return{...r}}),this.setRequestHandler(wt,async(o,n)=>{const r=async()=>{const s=o.params.taskId;if(this._taskMessageQueue){let c;for(;c=await this._taskMessageQueue.dequeue(s,n.sessionId);){if(c.type==="response"||c.type==="error"){const p=c.message,h=p.id,m=this._requestResolvers.get(h);if(m)if(this._requestResolvers.delete(h),c.type==="response")m(p);else{const f=p,v=new z(f.error.code,f.error.message,f.error.data);m(v)}else{const f=c.type==="response"?"Response":"Error";this._onerror(new Error(`${f} handler missing for request ${h}`))}continue}await this._transport?.send(c.message,{relatedRequestId:n.requestId})}}const i=await this._taskStore.getTask(s,n.sessionId);if(!i)throw new z(I.InvalidParams,`Task not found: ${s}`);if(!ne(i.status))return await this._waitForTaskUpdate(s,n.signal),await r();if(ne(i.status)){const c=await this._taskStore.getTaskResult(s,n.sessionId);return this._clearTaskQueue(s),{...c,_meta:{...c._meta,[re]:{taskId:s}}}}return await r()};return await r()}),this.setRequestHandler(kt,async(o,n)=>{try{const{tasks:r,nextCursor:s}=await this._taskStore.listTasks(o.params?.cursor,n.sessionId);return{tasks:r,nextCursor:s,_meta:{}}}catch(r){throw new z(I.InvalidParams,`Failed to list tasks: ${r instanceof Error?r.message:String(r)}`)}}),this.setRequestHandler(St,async(o,n)=>{try{const r=await this._taskStore.getTask(o.params.taskId,n.sessionId);if(!r)throw new z(I.InvalidParams,`Task not found: ${o.params.taskId}`);if(ne(r.status))throw new z(I.InvalidParams,`Cannot cancel task in terminal status: ${r.status}`);await this._taskStore.updateTaskStatus(o.params.taskId,"cancelled","Client cancelled task execution.",n.sessionId),this._clearTaskQueue(o.params.taskId);const s=await this._taskStore.getTask(o.params.taskId,n.sessionId);if(!s)throw new z(I.InvalidParams,`Task not found after cancellation: ${o.params.taskId}`);return{_meta:{},...s}}catch(r){throw r instanceof z?r:new z(I.InvalidRequest,`Failed to cancel task: ${r instanceof Error?r.message:String(r)}`)}}))}async _oncancel(t){if(!t.params.requestId)return;this._requestHandlerAbortControllers.get(t.params.requestId)?.abort(t.params.reason)}_setupTimeout(t,o,n,r,s=!1){this._timeoutInfo.set(t,{timeoutId:setTimeout(r,o),startTime:Date.now(),timeout:o,maxTotalTimeout:n,resetTimeoutOnProgress:s,onTimeout:r})}_resetTimeout(t){const o=this._timeoutInfo.get(t);if(!o)return!1;const n=Date.now()-o.startTime;if(o.maxTotalTimeout&&n>=o.maxTotalTimeout)throw this._timeoutInfo.delete(t),z.fromError(I.RequestTimeout,"Maximum total timeout exceeded",{maxTotalTimeout:o.maxTotalTimeout,totalElapsed:n});return clearTimeout(o.timeoutId),o.timeoutId=setTimeout(o.onTimeout,o.timeout),!0}_cleanupTimeout(t){const o=this._timeoutInfo.get(t);o&&(clearTimeout(o.timeoutId),this._timeoutInfo.delete(t))}async connect(t){if(this._transport)throw new Error("Already connected to a transport. Call close() before connecting to a new transport, or use a separate Protocol instance per connection.");this._transport=t;const o=this.transport?.onclose;this._transport.onclose=()=>{o?.(),this._onclose()};const n=this.transport?.onerror;this._transport.onerror=s=>{n?.(s),this._onerror(s)};const r=this._transport?.onmessage;this._transport.onmessage=(s,i)=>{r?.(s,i),Ce(s)||fa(s)?this._onresponse(s):to(s)?this._onrequest(s,i):ma(s)?this._onnotification(s):this._onerror(new Error(`Unknown message type: ${JSON.stringify(s)}`))},await this._transport.start()}_onclose(){const t=this._responseHandlers;this._responseHandlers=new Map,this._progressHandlers.clear(),this._taskProgressTokens.clear(),this._pendingDebouncedNotifications.clear();for(const n of this._requestHandlerAbortControllers.values())n.abort();this._requestHandlerAbortControllers.clear();const o=z.fromError(I.ConnectionClosed,"Connection closed");this._transport=void 0,this.onclose?.();for(const n of t.values())n(o)}_onerror(t){this.onerror?.(t)}_onnotification(t){const o=this._notificationHandlers.get(t.method)??this.fallbackNotificationHandler;o!==void 0&&Promise.resolve().then(()=>o(t)).catch(n=>this._onerror(new Error(`Uncaught error in notification handler: ${n}`)))}_onrequest(t,o){const n=this._requestHandlers.get(t.method)??this.fallbackRequestHandler,r=this._transport,s=t.params?._meta?.[re]?.taskId;if(n===void 0){const m={jsonrpc:"2.0",id:t.id,error:{code:I.MethodNotFound,message:"Method not found"}};s&&this._taskMessageQueue?this._enqueueTaskMessage(s,{type:"error",message:m,timestamp:Date.now()},r?.sessionId).catch(f=>this._onerror(new Error(`Failed to enqueue error response: ${f}`))):r?.send(m).catch(f=>this._onerror(new Error(`Failed to send an error response: ${f}`)));return}const i=new AbortController;this._requestHandlerAbortControllers.set(t.id,i);const c=ha(t.params)?t.params.task:void 0,p=this._taskStore?this.requestTaskStore(t,r?.sessionId):void 0,h={signal:i.signal,sessionId:r?.sessionId,_meta:t.params?._meta,sendNotification:async m=>{if(i.signal.aborted)return;const f={relatedRequestId:t.id};s&&(f.relatedTask={taskId:s}),await this.notification(m,f)},sendRequest:async(m,f,v)=>{if(i.signal.aborted)throw new z(I.ConnectionClosed,"Request was cancelled");const b={...v,relatedRequestId:t.id};s&&!b.relatedTask&&(b.relatedTask={taskId:s});const R=b.relatedTask?.taskId??s;return R&&p&&await p.updateTaskStatus(R,"input_required"),await this.request(m,f,b)},authInfo:o?.authInfo,requestId:t.id,requestInfo:o?.requestInfo,taskId:s,taskStore:p,taskRequestedTtl:c?.ttl,closeSSEStream:o?.closeSSEStream,closeStandaloneSSEStream:o?.closeStandaloneSSEStream};Promise.resolve().then(()=>{c&&this.assertTaskHandlerCapability(t.method)}).then(()=>n(t,h)).then(async m=>{if(i.signal.aborted)return;const f={result:m,jsonrpc:"2.0",id:t.id};s&&this._taskMessageQueue?await this._enqueueTaskMessage(s,{type:"response",message:f,timestamp:Date.now()},r?.sessionId):await r?.send(f)},async m=>{if(i.signal.aborted)return;const f={jsonrpc:"2.0",id:t.id,error:{code:Number.isSafeInteger(m.code)?m.code:I.InternalError,message:m.message??"Internal error",...m.data!==void 0&&{data:m.data}}};s&&this._taskMessageQueue?await this._enqueueTaskMessage(s,{type:"error",message:f,timestamp:Date.now()},r?.sessionId):await r?.send(f)}).catch(m=>this._onerror(new Error(`Failed to send response: ${m}`))).finally(()=>{this._requestHandlerAbortControllers.delete(t.id)})}_onprogress(t){const{progressToken:o,...n}=t.params,r=Number(o),s=this._progressHandlers.get(r);if(!s){this._onerror(new Error(`Received a progress notification for an unknown token: ${JSON.stringify(t)}`));return}const i=this._responseHandlers.get(r),c=this._timeoutInfo.get(r);if(c&&i&&c.resetTimeoutOnProgress)try{this._resetTimeout(r)}catch(p){this._responseHandlers.delete(r),this._progressHandlers.delete(r),this._cleanupTimeout(r),i(p);return}s(n)}_onresponse(t){const o=Number(t.id),n=this._requestResolvers.get(o);if(n){if(this._requestResolvers.delete(o),Ce(t))n(t);else{const i=new z(t.error.code,t.error.message,t.error.data);n(i)}return}const r=this._responseHandlers.get(o);if(r===void 0){this._onerror(new Error(`Received a response for an unknown message ID: ${JSON.stringify(t)}`));return}this._responseHandlers.delete(o),this._cleanupTimeout(o);let s=!1;if(Ce(t)&&t.result&&typeof t.result=="object"){const i=t.result;if(i.task&&typeof i.task=="object"){const c=i.task;typeof c.taskId=="string"&&(s=!0,this._taskProgressTokens.set(c.taskId,o))}}if(s||this._progressHandlers.delete(o),Ce(t))r(t);else{const i=z.fromError(t.error.code,t.error.message,t.error.data);r(i)}}get transport(){return this._transport}async close(){await this._transport?.close()}async*requestStream(t,o,n){const{task:r}=n??{};if(!r){try{yield{type:"result",result:await this.request(t,o,n)}}catch(i){yield{type:"error",error:i instanceof z?i:new z(I.InternalError,String(i))}}return}let s;try{const i=await this.request(t,_t,n);if(i.task)s=i.task.taskId,yield{type:"taskCreated",task:i.task};else throw new z(I.InternalError,"Task creation did not return a task");for(;;){const c=await this.getTask({taskId:s},n);if(yield{type:"taskStatus",task:c},ne(c.status)){c.status==="completed"?yield{type:"result",result:await this.getTaskResult({taskId:s},o,n)}:c.status==="failed"?yield{type:"error",error:new z(I.InternalError,`Task ${s} failed`)}:c.status==="cancelled"&&(yield{type:"error",error:new z(I.InternalError,`Task ${s} was cancelled`)});return}if(c.status==="input_required"){yield{type:"result",result:await this.getTaskResult({taskId:s},o,n)};return}const p=c.pollInterval??this._options?.defaultTaskPollInterval??1e3;await new Promise(h=>setTimeout(h,p)),n?.signal?.throwIfAborted()}}catch(i){yield{type:"error",error:i instanceof z?i:new z(I.InternalError,String(i))}}}request(t,o,n){const{relatedRequestId:r,resumptionToken:s,onresumptiontoken:i,task:c,relatedTask:p}=n??{};return new Promise((h,m)=>{const f=k=>{m(k)};if(!this._transport){f(new Error("Not connected"));return}if(this._options?.enforceStrictCapabilities===!0)try{this.assertCapabilityForMethod(t.method),c&&this.assertTaskCapability(t.method)}catch(k){f(k);return}n?.signal?.throwIfAborted();const v=this._requestMessageId++,b={...t,jsonrpc:"2.0",id:v};n?.onprogress&&(this._progressHandlers.set(v,n.onprogress),b.params={...t.params,_meta:{...t.params?._meta||{},progressToken:v}}),c&&(b.params={...b.params,task:c}),p&&(b.params={...b.params,_meta:{...b.params?._meta||{},[re]:p}});const R=k=>{this._responseHandlers.delete(v),this._progressHandlers.delete(v),this._cleanupTimeout(v),this._transport?.send({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:v,reason:String(k)}},{relatedRequestId:r,resumptionToken:s,onresumptiontoken:i}).catch(T=>this._onerror(new Error(`Failed to send cancellation: ${T}`)));const y=k instanceof z?k:new z(I.RequestTimeout,String(k));m(y)};this._responseHandlers.set(v,k=>{if(!n?.signal?.aborted){if(k instanceof Error)return m(k);try{const y=Ro(o,k.result);y.success?h(y.data):m(y.error)}catch(y){m(y)}}}),n?.signal?.addEventListener("abort",()=>{R(n?.signal?.reason)});const w=n?.timeout??Yc,j=()=>R(z.fromError(I.RequestTimeout,"Request timed out",{timeout:w}));this._setupTimeout(v,w,n?.maxTotalTimeout,j,n?.resetTimeoutOnProgress??!1);const W=p?.taskId;if(W){const k=y=>{const T=this._responseHandlers.get(v);T?T(y):this._onerror(new Error(`Response handler missing for side-channeled request ${v}`))};this._requestResolvers.set(v,k),this._enqueueTaskMessage(W,{type:"request",message:b,timestamp:Date.now()}).catch(y=>{this._cleanupTimeout(v),m(y)})}else this._transport.send(b,{relatedRequestId:r,resumptionToken:s,onresumptiontoken:i}).catch(k=>{this._cleanupTimeout(v),m(k)})})}async getTask(t,o){return this.request({method:"tasks/get",params:t},yt,o)}async getTaskResult(t,o,n){return this.request({method:"tasks/result",params:t},o,n)}async listTasks(t,o){return this.request({method:"tasks/list",params:t},xt,o)}async cancelTask(t,o){return this.request({method:"tasks/cancel",params:t},Na,o)}async notification(t,o){if(!this._transport)throw new Error("Not connected");this.assertNotificationCapability(t.method);const n=o?.relatedTask?.taskId;if(n){const c={...t,jsonrpc:"2.0",params:{...t.params,_meta:{...t.params?._meta||{},[re]:o.relatedTask}}};await this._enqueueTaskMessage(n,{type:"notification",message:c,timestamp:Date.now()});return}if((this._options?.debouncedNotificationMethods??[]).includes(t.method)&&!t.params&&!o?.relatedRequestId&&!o?.relatedTask){if(this._pendingDebouncedNotifications.has(t.method))return;this._pendingDebouncedNotifications.add(t.method),Promise.resolve().then(()=>{if(this._pendingDebouncedNotifications.delete(t.method),!this._transport)return;let c={...t,jsonrpc:"2.0"};o?.relatedTask&&(c={...c,params:{...c.params,_meta:{...c.params?._meta||{},[re]:o.relatedTask}}}),this._transport?.send(c,o).catch(p=>this._onerror(p))});return}let i={...t,jsonrpc:"2.0"};o?.relatedTask&&(i={...i,params:{...i.params,_meta:{...i.params?._meta||{},[re]:o.relatedTask}}}),await this._transport.send(i,o)}setRequestHandler(t,o){const n=oo(t);this.assertRequestHandlerCapability(n),this._requestHandlers.set(n,(r,s)=>{const i=no(t,r);return Promise.resolve(o(i,s))})}removeRequestHandler(t){this._requestHandlers.delete(t)}assertCanSetRequestHandler(t){if(this._requestHandlers.has(t))throw new Error(`A request handler for ${t} already exists, which would be overridden`)}setNotificationHandler(t,o){const n=oo(t);this._notificationHandlers.set(n,r=>{const s=no(t,r);return Promise.resolve(o(s))})}removeNotificationHandler(t){this._notificationHandlers.delete(t)}_cleanupTaskProgressHandler(t){const o=this._taskProgressTokens.get(t);o!==void 0&&(this._progressHandlers.delete(o),this._taskProgressTokens.delete(t))}async _enqueueTaskMessage(t,o,n){if(!this._taskStore||!this._taskMessageQueue)throw new Error("Cannot enqueue task message: taskStore and taskMessageQueue are not configured");const r=this._options?.maxTaskQueueSize;await this._taskMessageQueue.enqueue(t,o,n,r)}async _clearTaskQueue(t,o){if(this._taskMessageQueue){const n=await this._taskMessageQueue.dequeueAll(t,o);for(const r of n)if(r.type==="request"&&to(r.message)){const s=r.message.id,i=this._requestResolvers.get(s);i?(i(new z(I.InternalError,"Task cancelled or completed")),this._requestResolvers.delete(s)):this._onerror(new Error(`Resolver missing for request ${s} during task ${t} cleanup`))}}}async _waitForTaskUpdate(t,o){let n=this._options?.defaultTaskPollInterval??1e3;try{const r=await this._taskStore?.getTask(t);r?.pollInterval&&(n=r.pollInterval)}catch{}return new Promise((r,s)=>{if(o.aborted){s(new z(I.InvalidRequest,"Request cancelled"));return}const i=setTimeout(r,n);o.addEventListener("abort",()=>{clearTimeout(i),s(new z(I.InvalidRequest,"Request cancelled"))},{once:!0})})}requestTaskStore(t,o){const n=this._taskStore;if(!n)throw new Error("No task store configured");return{createTask:async r=>{if(!t)throw new Error("No request provided");return await n.createTask(r,t.id,{method:t.method,params:t.params},o)},getTask:async r=>{const s=await n.getTask(r,o);if(!s)throw new z(I.InvalidParams,"Failed to retrieve task: Task not found");return s},storeTaskResult:async(r,s,i)=>{await n.storeTaskResult(r,s,i,o);const c=await n.getTask(r,o);if(c){const p=De.parse({method:"notifications/tasks/status",params:c});await this.notification(p),ne(c.status)&&this._cleanupTaskProgressHandler(r)}},getTaskResult:r=>n.getTaskResult(r,o),updateTaskStatus:async(r,s,i)=>{const c=await n.getTask(r,o);if(!c)throw new z(I.InvalidParams,`Task "${r}" not found - it may have been cleaned up`);if(ne(c.status))throw new z(I.InvalidParams,`Cannot update task "${r}" from terminal status "${c.status}" to "${s}". Terminal states (completed, failed, cancelled) cannot transition to other states.`);await n.updateTaskStatus(r,s,i,o);const p=await n.getTask(r,o);if(p){const h=De.parse({method:"notifications/tasks/status",params:p});await this.notification(h),ne(p.status)&&this._cleanupTaskProgressHandler(r)}},listTasks:r=>n.listTasks(r,o)}}}var eu="2026-01-26",tu="ui/notifications/tool-input-partial";class tn{eventTarget;eventSource;messageListener;constructor(t=window.parent,o){this.eventTarget=t,this.eventSource=o,this.messageListener=n=>{if(o&&n.source!==this.eventSource){console.debug("Ignoring message from unknown source",n);return}let r=ga.safeParse(n.data);r.success?(console.debug("Parsed message",r.data),this.onmessage?.(r.data)):n.data?.jsonrpc!=="2.0"?console.debug("Ignoring non-JSON-RPC message",r.error.message,n):(console.error("Failed to parse message",r.error.message,n),this.onerror?.(Error("Invalid JSON-RPC message received: "+r.error.message)))}}async start(){window.addEventListener("message",this.messageListener)}async send(t,o){t.method!==tu&&console.debug("Sending message",t),this.eventTarget.postMessage(t,"*")}async close(){window.removeEventListener("message",this.messageListener),this.onclose?.()}onclose;onerror;onmessage;sessionId;setProtocolVersion}var ou=S([a("light"),a("dark")]).describe("Color theme preference for the host environment."),fe=S([a("inline"),a("fullscreen"),a("pip")]).describe("Display mode for UI presentation."),nu=S([a("--color-background-primary"),a("--color-background-secondary"),a("--color-background-tertiary"),a("--color-background-inverse"),a("--color-background-ghost"),a("--color-background-info"),a("--color-background-danger"),a("--color-background-success"),a("--color-background-warning"),a("--color-background-disabled"),a("--color-text-primary"),a("--color-text-secondary"),a("--color-text-tertiary"),a("--color-text-inverse"),a("--color-text-ghost"),a("--color-text-info"),a("--color-text-danger"),a("--color-text-success"),a("--color-text-warning"),a("--color-text-disabled"),a("--color-border-primary"),a("--color-border-secondary"),a("--color-border-tertiary"),a("--color-border-inverse"),a("--color-border-ghost"),a("--color-border-info"),a("--color-border-danger"),a("--color-border-success"),a("--color-border-warning"),a("--color-border-disabled"),a("--color-ring-primary"),a("--color-ring-secondary"),a("--color-ring-inverse"),a("--color-ring-info"),a("--color-ring-danger"),a("--color-ring-success"),a("--color-ring-warning"),a("--font-sans"),a("--font-mono"),a("--font-weight-normal"),a("--font-weight-medium"),a("--font-weight-semibold"),a("--font-weight-bold"),a("--font-text-xs-size"),a("--font-text-sm-size"),a("--font-text-md-size"),a("--font-text-lg-size"),a("--font-heading-xs-size"),a("--font-heading-sm-size"),a("--font-heading-md-size"),a("--font-heading-lg-size"),a("--font-heading-xl-size"),a("--font-heading-2xl-size"),a("--font-heading-3xl-size"),a("--font-text-xs-line-height"),a("--font-text-sm-line-height"),a("--font-text-md-line-height"),a("--font-text-lg-line-height"),a("--font-heading-xs-line-height"),a("--font-heading-sm-line-height"),a("--font-heading-md-line-height"),a("--font-heading-lg-line-height"),a("--font-heading-xl-line-height"),a("--font-heading-2xl-line-height"),a("--font-heading-3xl-line-height"),a("--border-radius-xs"),a("--border-radius-sm"),a("--border-radius-md"),a("--border-radius-lg"),a("--border-radius-xl"),a("--border-radius-full"),a("--border-width-regular"),a("--shadow-hairline"),a("--shadow-sm"),a("--shadow-md"),a("--shadow-lg")]).describe("CSS variable keys available to MCP apps for theming."),ru=$(nu.describe(`Style variables for theming MCP apps.
|
|
31
|
+
path: iss.path ? [${me(w)}, ...iss.path] : [${me(w)}]
|
|
32
|
+
})));`),v.write(`newResult[${me(w)}] = ${y}.value`)}v.write("payload.value = newResult;"),v.write("return payload;");const D=v.compile();return(w,y)=>D(h,w,y)};let r;const s=De,i=!po.jitless,p=i&&gn.value,m=t.catchall;let f;e._zod.parse=(h,v)=>{f??(f=o.value);const b=h.value;if(!s(b))return h.issues.push({expected:"object",code:"invalid_type",input:b,inst:e}),h;const P=[];if(i&&p&&v?.async===!1&&v.jitless!==!0)r||(r=n(t.shape)),h=r(h,v);else{h.value={};const y=f.shape;for(const z of f.keys){const F=y[z],Y=F._zod.run({value:b[z],issues:[]},v),he=F._zod.optin==="optional"&&F._zod.optout==="optional";Y instanceof Promise?P.push(Y.then(jt=>he?Ft(jt,h,z,b):Ce(jt,h,z))):he?Ft(Y,h,z,b):Ce(Y,h,z)}}if(!m)return P.length?Promise.all(P).then(()=>h):h;const A=[],S=f.keySet,D=m._zod,w=D.def.type;for(const y of Object.keys(b)){if(S.has(y))continue;if(w==="never"){A.push(y);continue}const z=D.run({value:b[y],issues:[]},v);z instanceof Promise?P.push(z.then(F=>Ce(F,h,y))):Ce(z,h,y)}return A.length&&h.issues.push({code:"unrecognized_keys",keys:A,input:b,inst:e}),P.length?Promise.all(P).then(()=>h):h}});function Bt(e,t,o,n){for(const r of e)if(r.issues.length===0)return t.value=r.value,t;return t.issues.push({code:"invalid_union",input:t.value,inst:o,errors:e.map(r=>r.issues.map(s=>oe(s,n,te())))}),t}const Io=d("$ZodUnion",(e,t)=>{Z.init(e,t),C(e._zod,"optin",()=>t.options.some(o=>o._zod.optin==="optional")?"optional":void 0),C(e._zod,"optout",()=>t.options.some(o=>o._zod.optout==="optional")?"optional":void 0),C(e._zod,"values",()=>{if(t.options.every(o=>o._zod.values))return new Set(t.options.flatMap(o=>Array.from(o._zod.values)))}),C(e._zod,"pattern",()=>{if(t.options.every(o=>o._zod.pattern)){const o=t.options.map(n=>n._zod.pattern);return new RegExp(`^(${o.map(n=>dt(n.source)).join("|")})$`)}}),e._zod.parse=(o,n)=>{let r=!1;const s=[];for(const i of t.options){const u=i._zod.run({value:o.value,issues:[]},n);if(u instanceof Promise)s.push(u),r=!0;else{if(u.issues.length===0)return u;s.push(u)}}return r?Promise.all(s).then(i=>Bt(i,o,e,n)):Bt(s,o,e,n)}}),Xr=d("$ZodDiscriminatedUnion",(e,t)=>{Io.init(e,t);const o=e._zod.parse;C(e._zod,"propValues",()=>{const r={};for(const s of t.options){const i=s._zod.propValues;if(!i||Object.keys(i).length===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(s)}"`);for(const[u,p]of Object.entries(i)){r[u]||(r[u]=new Set);for(const m of p)r[u].add(m)}}return r});const n=ut(()=>{const r=t.options,s=new Map;for(const i of r){const u=i._zod.propValues[t.discriminator];if(!u||u.size===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(i)}"`);for(const p of u){if(s.has(p))throw new Error(`Duplicate discriminator value "${String(p)}"`);s.set(p,i)}}return s});e._zod.parse=(r,s)=>{const i=r.value;if(!De(i))return r.issues.push({code:"invalid_type",expected:"object",input:i,inst:e}),r;const u=n.value.get(i?.[t.discriminator]);return u?u._zod.run(r,s):t.unionFallback?o(r,s):(r.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",input:i,path:[t.discriminator],inst:e}),r)}}),es=d("$ZodIntersection",(e,t)=>{Z.init(e,t),e._zod.parse=(o,n)=>{const r=o.value,s=t.left._zod.run({value:r,issues:[]},n),i=t.right._zod.run({value:r,issues:[]},n);return s instanceof Promise||i instanceof Promise?Promise.all([s,i]).then(([p,m])=>Vt(o,p,m)):Vt(o,s,i)}});function tt(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(Le(e)&&Le(t)){const o=Object.keys(t),n=Object.keys(e).filter(s=>o.indexOf(s)!==-1),r={...e,...t};for(const s of n){const i=tt(e[s],t[s]);if(!i.valid)return{valid:!1,mergeErrorPath:[s,...i.mergeErrorPath]};r[s]=i.data}return{valid:!0,data:r}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};const o=[];for(let n=0;n<e.length;n++){const r=e[n],s=t[n],i=tt(r,s);if(!i.valid)return{valid:!1,mergeErrorPath:[n,...i.mergeErrorPath]};o.push(i.data)}return{valid:!0,data:o}}return{valid:!1,mergeErrorPath:[]}}function Vt(e,t,o){if(t.issues.length&&e.issues.push(...t.issues),o.issues.length&&e.issues.push(...o.issues),ge(e))return e;const n=tt(t.value,o.value);if(!n.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(n.mergeErrorPath)}`);return e.value=n.data,e}const ts=d("$ZodRecord",(e,t)=>{Z.init(e,t),e._zod.parse=(o,n)=>{const r=o.value;if(!Le(r))return o.issues.push({expected:"record",code:"invalid_type",input:r,inst:e}),o;const s=[];if(t.keyType._zod.values){const i=t.keyType._zod.values;o.value={};for(const p of i)if(typeof p=="string"||typeof p=="number"||typeof p=="symbol"){const m=t.valueType._zod.run({value:r[p],issues:[]},n);m instanceof Promise?s.push(m.then(f=>{f.issues.length&&o.issues.push(...se(p,f.issues)),o.value[p]=f.value})):(m.issues.length&&o.issues.push(...se(p,m.issues)),o.value[p]=m.value)}let u;for(const p in r)i.has(p)||(u=u??[],u.push(p));u&&u.length>0&&o.issues.push({code:"unrecognized_keys",input:r,inst:e,keys:u})}else{o.value={};for(const i of Reflect.ownKeys(r)){if(i==="__proto__")continue;const u=t.keyType._zod.run({value:i,issues:[]},n);if(u instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(u.issues.length){o.issues.push({origin:"record",code:"invalid_key",issues:u.issues.map(m=>oe(m,n,te())),input:i,path:[i],inst:e}),o.value[u.value]=u.value;continue}const p=t.valueType._zod.run({value:r[i],issues:[]},n);p instanceof Promise?s.push(p.then(m=>{m.issues.length&&o.issues.push(...se(i,m.issues)),o.value[u.value]=m.value})):(p.issues.length&&o.issues.push(...se(i,p.issues)),o.value[u.value]=p.value)}}return s.length?Promise.all(s).then(()=>o):o}}),os=d("$ZodEnum",(e,t)=>{Z.init(e,t);const o=hn(t.entries);e._zod.values=new Set(o),e._zod.pattern=new RegExp(`^(${o.filter(n=>vn.has(typeof n)).map(n=>typeof n=="string"?ke(n):n.toString()).join("|")})$`),e._zod.parse=(n,r)=>{const s=n.value;return e._zod.values.has(s)||n.issues.push({code:"invalid_value",values:o,input:s,inst:e}),n}}),ns=d("$ZodLiteral",(e,t)=>{Z.init(e,t),e._zod.values=new Set(t.values),e._zod.pattern=new RegExp(`^(${t.values.map(o=>typeof o=="string"?ke(o):o?o.toString():String(o)).join("|")})$`),e._zod.parse=(o,n)=>{const r=o.value;return e._zod.values.has(r)||o.issues.push({code:"invalid_value",values:t.values,input:r,inst:e}),o}}),rs=d("$ZodTransform",(e,t)=>{Z.init(e,t),e._zod.parse=(o,n)=>{const r=t.transform(o.value,o);if(n.async)return(r instanceof Promise?r:Promise.resolve(r)).then(i=>(o.value=i,o));if(r instanceof Promise)throw new ve;return o.value=r,o}}),ss=d("$ZodOptional",(e,t)=>{Z.init(e,t),e._zod.optin="optional",e._zod.optout="optional",C(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),C(e._zod,"pattern",()=>{const o=t.innerType._zod.pattern;return o?new RegExp(`^(${dt(o.source)})?$`):void 0}),e._zod.parse=(o,n)=>t.innerType._zod.optin==="optional"?t.innerType._zod.run(o,n):o.value===void 0?o:t.innerType._zod.run(o,n)}),is=d("$ZodNullable",(e,t)=>{Z.init(e,t),C(e._zod,"optin",()=>t.innerType._zod.optin),C(e._zod,"optout",()=>t.innerType._zod.optout),C(e._zod,"pattern",()=>{const o=t.innerType._zod.pattern;return o?new RegExp(`^(${dt(o.source)}|null)$`):void 0}),C(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(o,n)=>o.value===null?o:t.innerType._zod.run(o,n)}),as=d("$ZodDefault",(e,t)=>{Z.init(e,t),e._zod.optin="optional",C(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(o,n)=>{if(o.value===void 0)return o.value=t.defaultValue,o;const r=t.innerType._zod.run(o,n);return r instanceof Promise?r.then(s=>Wt(s,t)):Wt(r,t)}});function Wt(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const cs=d("$ZodPrefault",(e,t)=>{Z.init(e,t),e._zod.optin="optional",C(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(o,n)=>(o.value===void 0&&(o.value=t.defaultValue),t.innerType._zod.run(o,n))}),us=d("$ZodNonOptional",(e,t)=>{Z.init(e,t),C(e._zod,"values",()=>{const o=t.innerType._zod.values;return o?new Set([...o].filter(n=>n!==void 0)):void 0}),e._zod.parse=(o,n)=>{const r=t.innerType._zod.run(o,n);return r instanceof Promise?r.then(s=>Jt(s,e)):Jt(r,e)}});function Jt(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}const ls=d("$ZodCatch",(e,t)=>{Z.init(e,t),e._zod.optin="optional",C(e._zod,"optout",()=>t.innerType._zod.optout),C(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(o,n)=>{const r=t.innerType._zod.run(o,n);return r instanceof Promise?r.then(s=>(o.value=s.value,s.issues.length&&(o.value=t.catchValue({...o,error:{issues:s.issues.map(i=>oe(i,n,te()))},input:o.value}),o.issues=[]),o)):(o.value=r.value,r.issues.length&&(o.value=t.catchValue({...o,error:{issues:r.issues.map(s=>oe(s,n,te()))},input:o.value}),o.issues=[]),o)}}),ds=d("$ZodPipe",(e,t)=>{Z.init(e,t),C(e._zod,"values",()=>t.in._zod.values),C(e._zod,"optin",()=>t.in._zod.optin),C(e._zod,"optout",()=>t.out._zod.optout),e._zod.parse=(o,n)=>{const r=t.in._zod.run(o,n);return r instanceof Promise?r.then(s=>Gt(s,t,n)):Gt(r,t,n)}});function Gt(e,t,o){return ge(e)?e:t.out._zod.run({value:e.value,issues:e.issues},o)}const ps=d("$ZodReadonly",(e,t)=>{Z.init(e,t),C(e._zod,"propValues",()=>t.innerType._zod.propValues),C(e._zod,"values",()=>t.innerType._zod.values),C(e._zod,"optin",()=>t.innerType._zod.optin),C(e._zod,"optout",()=>t.innerType._zod.optout),e._zod.parse=(o,n)=>{const r=t.innerType._zod.run(o,n);return r instanceof Promise?r.then(Kt):Kt(r)}});function Kt(e){return e.value=Object.freeze(e.value),e}const hs=d("$ZodCustom",(e,t)=>{V.init(e,t),Z.init(e,t),e._zod.parse=(o,n)=>o,e._zod.check=o=>{const n=o.value,r=t.fn(n);if(r instanceof Promise)return r.then(s=>Qt(s,o,n,e));Qt(r,o,n,e)}});function Qt(e,t,o,n){if(!e){const r={code:"custom",input:o,inst:n,path:[...n._zod.def.path??[]],continue:!n._zod.def.abort};n._zod.def.params&&(r.params=n._zod.def.params),t.issues.push(_e(r))}}class ms{constructor(){this._map=new Map,this._idmap=new Map}add(t,...o){const n=o[0];if(this._map.set(t,n),n&&typeof n=="object"&&"id"in n){if(this._idmap.has(n.id))throw new Error(`ID ${n.id} already exists in the registry`);this._idmap.set(n.id,t)}return this}clear(){return this._map=new Map,this._idmap=new Map,this}remove(t){const o=this._map.get(t);return o&&typeof o=="object"&&"id"in o&&this._idmap.delete(o.id),this._map.delete(t),this}get(t){const o=t._zod.parent;if(o){const n={...this.get(o)??{}};return delete n.id,{...n,...this._map.get(t)}}return this._map.get(t)}has(t){return this._map.has(t)}}function fs(){return new ms}const Ne=fs();function gs(e,t){return new e({type:"string",...g(t)})}function vs(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...g(t)})}function Yt(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...g(t)})}function _s(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...g(t)})}function bs(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...g(t)})}function ys(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...g(t)})}function ws(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...g(t)})}function ks(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...g(t)})}function xs(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...g(t)})}function Ss(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...g(t)})}function Ts(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...g(t)})}function zs(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...g(t)})}function Rs(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...g(t)})}function Is(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...g(t)})}function $s(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...g(t)})}function Ps(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...g(t)})}function Es(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...g(t)})}function Zs(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...g(t)})}function Cs(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...g(t)})}function Ns(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...g(t)})}function qs(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...g(t)})}function Ms(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...g(t)})}function Os(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...g(t)})}function As(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...g(t)})}function Ds(e,t){return new e({type:"string",format:"date",check:"string_format",...g(t)})}function Ls(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...g(t)})}function js(e,t){return new e({type:"string",format:"duration",check:"string_format",...g(t)})}function Us(e,t){return new e({type:"number",checks:[],...g(t)})}function Hs(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...g(t)})}function Fs(e,t){return new e({type:"boolean",...g(t)})}function Bs(e,t){return new e({type:"undefined",...g(t)})}function Vs(e,t){return new e({type:"null",...g(t)})}function Ws(e){return new e({type:"unknown"})}function Js(e,t){return new e({type:"never",...g(t)})}function Xt(e,t){return new So({check:"less_than",...g(t),value:e,inclusive:!1})}function Qe(e,t){return new So({check:"less_than",...g(t),value:e,inclusive:!0})}function eo(e,t){return new To({check:"greater_than",...g(t),value:e,inclusive:!1})}function Ye(e,t){return new To({check:"greater_than",...g(t),value:e,inclusive:!0})}function to(e,t){return new ir({check:"multiple_of",...g(t),value:e})}function $o(e,t){return new cr({check:"max_length",...g(t),maximum:e})}function je(e,t){return new ur({check:"min_length",...g(t),minimum:e})}function Po(e,t){return new lr({check:"length_equals",...g(t),length:e})}function Gs(e,t){return new dr({check:"string_format",format:"regex",...g(t),pattern:e})}function Ks(e){return new pr({check:"string_format",format:"lowercase",...g(e)})}function Qs(e){return new hr({check:"string_format",format:"uppercase",...g(e)})}function Ys(e,t){return new mr({check:"string_format",format:"includes",...g(t),includes:e})}function Xs(e,t){return new fr({check:"string_format",format:"starts_with",...g(t),prefix:e})}function ei(e,t){return new gr({check:"string_format",format:"ends_with",...g(t),suffix:e})}function xe(e){return new vr({check:"overwrite",tx:e})}function ti(e){return xe(t=>t.normalize(e))}function oi(){return xe(e=>e.trim())}function ni(){return xe(e=>e.toLowerCase())}function ri(){return xe(e=>e.toUpperCase())}function si(e,t,o){return new e({type:"array",element:t,...g(o)})}function ii(e,t,o){const n=g(o);return n.abort??(n.abort=!0),new e({type:"custom",check:"custom",fn:t,...n})}function ai(e,t,o){return new e({type:"custom",check:"custom",fn:t,...g(o)})}function mt(e){return!!e._zod}function Eo(e,t){return mt(e)?_o(e,t):e.safeParse(t)}function ci(e){if(!e)return;let t;if(mt(e)?t=e._zod?.def?.shape:t=e.shape,!!t){if(typeof t=="function")try{return t()}catch{return}return t}}function ui(e){if(mt(e)){const s=e._zod?.def;if(s){if(s.value!==void 0)return s.value;if(Array.isArray(s.values)&&s.values.length>0)return s.values[0]}}const o=e._def;if(o){if(o.value!==void 0)return o.value;if(Array.isArray(o.values)&&o.values.length>0)return o.values[0]}const n=e.value;if(n!==void 0)return n}const li=d("ZodISODateTime",(e,t)=>{Er.init(e,t),M.init(e,t)});function Zo(e){return As(li,e)}const di=d("ZodISODate",(e,t)=>{Zr.init(e,t),M.init(e,t)});function pi(e){return Ds(di,e)}const hi=d("ZodISOTime",(e,t)=>{Cr.init(e,t),M.init(e,t)});function mi(e){return Ls(hi,e)}const fi=d("ZodISODuration",(e,t)=>{Nr.init(e,t),M.init(e,t)});function gi(e){return js(fi,e)}const vi=(e,t)=>{fo.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:o=>Rn(e,o)},flatten:{value:o=>zn(e,o)},addIssue:{value:o=>e.issues.push(o)},addIssues:{value:o=>e.issues.push(...o)},isEmpty:{get(){return e.issues.length===0}}})},Ve=d("ZodError",vi,{Parent:Error}),_i=In(Ve),bi=$n(Ve),yi=vo(Ve),wi=bo(Ve),q=d("ZodType",(e,t)=>(Z.init(e,t),e.def=t,Object.defineProperty(e,"_def",{value:t}),e.check=(...o)=>e.clone({...t,checks:[...t.checks??[],...o.map(n=>typeof n=="function"?{_zod:{check:n,def:{check:"custom"},onattach:[]}}:n)]}),e.clone=(o,n)=>ie(e,o,n),e.brand=()=>e,e.register=((o,n)=>(o.add(e,n),e)),e.parse=(o,n)=>_i(e,o,n,{callee:e.parse}),e.safeParse=(o,n)=>yi(e,o,n),e.parseAsync=async(o,n)=>bi(e,o,n,{callee:e.parseAsync}),e.safeParseAsync=async(o,n)=>wi(e,o,n),e.spa=e.safeParseAsync,e.refine=(o,n)=>e.check(pa(o,n)),e.superRefine=o=>e.check(ha(o)),e.overwrite=o=>e.check(xe(o)),e.optional=()=>O(e),e.nullable=()=>ro(e),e.nullish=()=>O(ro(e)),e.nonoptional=o=>ra(e,o),e.array=()=>_(e),e.or=o=>x([e,o]),e.and=o=>ft(e,o),e.transform=o=>rt(e,Do(o)),e.default=o=>ta(e,o),e.prefault=o=>na(e,o),e.catch=o=>ia(e,o),e.pipe=o=>rt(e,o),e.readonly=()=>ua(e),e.describe=o=>{const n=e.clone();return Ne.add(n,{description:o}),n},Object.defineProperty(e,"description",{get(){return Ne.get(e)?.description},configurable:!0}),e.meta=(...o)=>{if(o.length===0)return Ne.get(e);const n=e.clone();return Ne.add(n,o[0]),n},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e)),Co=d("_ZodString",(e,t)=>{ht.init(e,t),q.init(e,t);const o=e._zod.bag;e.format=o.format??null,e.minLength=o.minimum??null,e.maxLength=o.maximum??null,e.regex=(...n)=>e.check(Gs(...n)),e.includes=(...n)=>e.check(Ys(...n)),e.startsWith=(...n)=>e.check(Xs(...n)),e.endsWith=(...n)=>e.check(ei(...n)),e.min=(...n)=>e.check(je(...n)),e.max=(...n)=>e.check($o(...n)),e.length=(...n)=>e.check(Po(...n)),e.nonempty=(...n)=>e.check(je(1,...n)),e.lowercase=n=>e.check(Ks(n)),e.uppercase=n=>e.check(Qs(n)),e.trim=()=>e.check(oi()),e.normalize=(...n)=>e.check(ti(...n)),e.toLowerCase=()=>e.check(ni()),e.toUpperCase=()=>e.check(ri())}),ki=d("ZodString",(e,t)=>{ht.init(e,t),Co.init(e,t),e.email=o=>e.check(vs(xi,o)),e.url=o=>e.check(ks(Si,o)),e.jwt=o=>e.check(Os(Di,o)),e.emoji=o=>e.check(xs(Ti,o)),e.guid=o=>e.check(Yt(oo,o)),e.uuid=o=>e.check(_s(qe,o)),e.uuidv4=o=>e.check(bs(qe,o)),e.uuidv6=o=>e.check(ys(qe,o)),e.uuidv7=o=>e.check(ws(qe,o)),e.nanoid=o=>e.check(Ss(zi,o)),e.guid=o=>e.check(Yt(oo,o)),e.cuid=o=>e.check(Ts(Ri,o)),e.cuid2=o=>e.check(zs(Ii,o)),e.ulid=o=>e.check(Rs($i,o)),e.base64=o=>e.check(Ns(Mi,o)),e.base64url=o=>e.check(qs(Oi,o)),e.xid=o=>e.check(Is(Pi,o)),e.ksuid=o=>e.check($s(Ei,o)),e.ipv4=o=>e.check(Ps(Zi,o)),e.ipv6=o=>e.check(Es(Ci,o)),e.cidrv4=o=>e.check(Zs(Ni,o)),e.cidrv6=o=>e.check(Cs(qi,o)),e.e164=o=>e.check(Ms(Ai,o)),e.datetime=o=>e.check(Zo(o)),e.date=o=>e.check(pi(o)),e.time=o=>e.check(mi(o)),e.duration=o=>e.check(gi(o))});function c(e){return gs(ki,e)}const M=d("ZodStringFormat",(e,t)=>{N.init(e,t),Co.init(e,t)}),xi=d("ZodEmail",(e,t)=>{kr.init(e,t),M.init(e,t)}),oo=d("ZodGUID",(e,t)=>{yr.init(e,t),M.init(e,t)}),qe=d("ZodUUID",(e,t)=>{wr.init(e,t),M.init(e,t)}),Si=d("ZodURL",(e,t)=>{xr.init(e,t),M.init(e,t)}),Ti=d("ZodEmoji",(e,t)=>{Sr.init(e,t),M.init(e,t)}),zi=d("ZodNanoID",(e,t)=>{Tr.init(e,t),M.init(e,t)}),Ri=d("ZodCUID",(e,t)=>{zr.init(e,t),M.init(e,t)}),Ii=d("ZodCUID2",(e,t)=>{Rr.init(e,t),M.init(e,t)}),$i=d("ZodULID",(e,t)=>{Ir.init(e,t),M.init(e,t)}),Pi=d("ZodXID",(e,t)=>{$r.init(e,t),M.init(e,t)}),Ei=d("ZodKSUID",(e,t)=>{Pr.init(e,t),M.init(e,t)}),Zi=d("ZodIPv4",(e,t)=>{qr.init(e,t),M.init(e,t)}),Ci=d("ZodIPv6",(e,t)=>{Mr.init(e,t),M.init(e,t)}),Ni=d("ZodCIDRv4",(e,t)=>{Or.init(e,t),M.init(e,t)}),qi=d("ZodCIDRv6",(e,t)=>{Ar.init(e,t),M.init(e,t)}),Mi=d("ZodBase64",(e,t)=>{Dr.init(e,t),M.init(e,t)}),Oi=d("ZodBase64URL",(e,t)=>{jr.init(e,t),M.init(e,t)}),Ai=d("ZodE164",(e,t)=>{Ur.init(e,t),M.init(e,t)}),Di=d("ZodJWT",(e,t)=>{Fr.init(e,t),M.init(e,t)}),No=d("ZodNumber",(e,t)=>{Ro.init(e,t),q.init(e,t),e.gt=(n,r)=>e.check(eo(n,r)),e.gte=(n,r)=>e.check(Ye(n,r)),e.min=(n,r)=>e.check(Ye(n,r)),e.lt=(n,r)=>e.check(Xt(n,r)),e.lte=(n,r)=>e.check(Qe(n,r)),e.max=(n,r)=>e.check(Qe(n,r)),e.int=n=>e.check(no(n)),e.safe=n=>e.check(no(n)),e.positive=n=>e.check(eo(0,n)),e.nonnegative=n=>e.check(Ye(0,n)),e.negative=n=>e.check(Xt(0,n)),e.nonpositive=n=>e.check(Qe(0,n)),e.multipleOf=(n,r)=>e.check(to(n,r)),e.step=(n,r)=>e.check(to(n,r)),e.finite=()=>e;const o=e._zod.bag;e.minValue=Math.max(o.minimum??Number.NEGATIVE_INFINITY,o.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(o.maximum??Number.POSITIVE_INFINITY,o.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(o.format??"").includes("int")||Number.isSafeInteger(o.multipleOf??.5),e.isFinite=!0,e.format=o.format??null});function k(e){return Us(No,e)}const Li=d("ZodNumberFormat",(e,t)=>{Br.init(e,t),No.init(e,t)});function no(e){return Hs(Li,e)}const ji=d("ZodBoolean",(e,t)=>{Vr.init(e,t),q.init(e,t)});function E(e){return Fs(ji,e)}const Ui=d("ZodUndefined",(e,t)=>{Wr.init(e,t),q.init(e,t)});function ot(e){return Bs(Ui,e)}const Hi=d("ZodNull",(e,t)=>{Jr.init(e,t),q.init(e,t)});function qo(e){return Vs(Hi,e)}const Fi=d("ZodUnknown",(e,t)=>{Gr.init(e,t),q.init(e,t)});function $(){return Ws(Fi)}const Bi=d("ZodNever",(e,t)=>{Kr.init(e,t),q.init(e,t)});function Vi(e){return Js(Bi,e)}const Wi=d("ZodArray",(e,t)=>{Qr.init(e,t),q.init(e,t),e.element=t.element,e.min=(o,n)=>e.check(je(o,n)),e.nonempty=o=>e.check(je(1,o)),e.max=(o,n)=>e.check($o(o,n)),e.length=(o,n)=>e.check(Po(o,n)),e.unwrap=()=>e.element});function _(e,t){return si(Wi,e,t)}const Mo=d("ZodObject",(e,t)=>{Yr.init(e,t),q.init(e,t),C(e,"shape",()=>t.shape),e.keyof=()=>W(Object.keys(e._zod.def.shape)),e.catchall=o=>e.clone({...e._zod.def,catchall:o}),e.passthrough=()=>e.clone({...e._zod.def,catchall:$()}),e.loose=()=>e.clone({...e._zod.def,catchall:$()}),e.strict=()=>e.clone({...e._zod.def,catchall:Vi()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=o=>kn(e,o),e.merge=o=>xn(e,o),e.pick=o=>yn(e,o),e.omit=o=>wn(e,o),e.partial=(...o)=>Sn(Lo,e,o[0]),e.required=(...o)=>Tn(jo,e,o[0])});function l(e,t){const o={type:"object",get shape(){return Fe(this,"shape",{...e}),this.shape},...g(t)};return new Mo(o)}function B(e,t){return new Mo({type:"object",get shape(){return Fe(this,"shape",{...e}),this.shape},catchall:$(),...g(t)})}const Oo=d("ZodUnion",(e,t)=>{Io.init(e,t),q.init(e,t),e.options=t.options});function x(e,t){return new Oo({type:"union",options:e,...g(t)})}const Ji=d("ZodDiscriminatedUnion",(e,t)=>{Oo.init(e,t),Xr.init(e,t)});function Ao(e,t,o){return new Ji({type:"union",options:t,discriminator:e,...g(o)})}const Gi=d("ZodIntersection",(e,t)=>{es.init(e,t),q.init(e,t)});function ft(e,t){return new Gi({type:"intersection",left:e,right:t})}const Ki=d("ZodRecord",(e,t)=>{ts.init(e,t),q.init(e,t),e.keyType=t.keyType,e.valueType=t.valueType});function I(e,t,o){return new Ki({type:"record",keyType:e,valueType:t,...g(o)})}const nt=d("ZodEnum",(e,t)=>{os.init(e,t),q.init(e,t),e.enum=t.entries,e.options=Object.values(t.entries);const o=new Set(Object.keys(t.entries));e.extract=(n,r)=>{const s={};for(const i of n)if(o.has(i))s[i]=t.entries[i];else throw new Error(`Key ${i} not found in enum`);return new nt({...t,checks:[],...g(r),entries:s})},e.exclude=(n,r)=>{const s={...t.entries};for(const i of n)if(o.has(i))delete s[i];else throw new Error(`Key ${i} not found in enum`);return new nt({...t,checks:[],...g(r),entries:s})}});function W(e,t){const o=Array.isArray(e)?Object.fromEntries(e.map(n=>[n,n])):e;return new nt({type:"enum",entries:o,...g(t)})}const Qi=d("ZodLiteral",(e,t)=>{ns.init(e,t),q.init(e,t),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function a(e,t){return new Qi({type:"literal",values:Array.isArray(e)?e:[e],...g(t)})}const Yi=d("ZodTransform",(e,t)=>{rs.init(e,t),q.init(e,t),e._zod.parse=(o,n)=>{o.addIssue=s=>{if(typeof s=="string")o.issues.push(_e(s,o.value,t));else{const i=s;i.fatal&&(i.continue=!1),i.code??(i.code="custom"),i.input??(i.input=o.value),i.inst??(i.inst=e),i.continue??(i.continue=!0),o.issues.push(_e(i))}};const r=t.transform(o.value,o);return r instanceof Promise?r.then(s=>(o.value=s,o)):(o.value=r,o)}});function Do(e){return new Yi({type:"transform",transform:e})}const Lo=d("ZodOptional",(e,t)=>{ss.init(e,t),q.init(e,t),e.unwrap=()=>e._zod.def.innerType});function O(e){return new Lo({type:"optional",innerType:e})}const Xi=d("ZodNullable",(e,t)=>{is.init(e,t),q.init(e,t),e.unwrap=()=>e._zod.def.innerType});function ro(e){return new Xi({type:"nullable",innerType:e})}const ea=d("ZodDefault",(e,t)=>{as.init(e,t),q.init(e,t),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function ta(e,t){return new ea({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():t}})}const oa=d("ZodPrefault",(e,t)=>{cs.init(e,t),q.init(e,t),e.unwrap=()=>e._zod.def.innerType});function na(e,t){return new oa({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():t}})}const jo=d("ZodNonOptional",(e,t)=>{us.init(e,t),q.init(e,t),e.unwrap=()=>e._zod.def.innerType});function ra(e,t){return new jo({type:"nonoptional",innerType:e,...g(t)})}const sa=d("ZodCatch",(e,t)=>{ls.init(e,t),q.init(e,t),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function ia(e,t){return new sa({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}const aa=d("ZodPipe",(e,t)=>{ds.init(e,t),q.init(e,t),e.in=t.in,e.out=t.out});function rt(e,t){return new aa({type:"pipe",in:e,out:t})}const ca=d("ZodReadonly",(e,t)=>{ps.init(e,t),q.init(e,t)});function ua(e){return new ca({type:"readonly",innerType:e})}const Uo=d("ZodCustom",(e,t)=>{hs.init(e,t),q.init(e,t)});function la(e){const t=new V({check:"custom"});return t._zod.check=e,t}function da(e,t){return ii(Uo,e??(()=>!0),t)}function pa(e,t={}){return ai(Uo,e,t)}function ha(e){const t=la(o=>(o.addIssue=n=>{if(typeof n=="string")o.issues.push(_e(n,o.value,t._zod.def));else{const r=n;r.fatal&&(r.continue=!1),r.code??(r.code="custom"),r.input??(r.input=o.value),r.inst??(r.inst=t),r.continue??(r.continue=!t._zod.def.abort),o.issues.push(_e(r))}},e(o.value,o)));return t}function Ho(e,t){return rt(Do(e),t)}const re="io.modelcontextprotocol/related-task",We="2.0",L=da(e=>e!==null&&(typeof e=="object"||typeof e=="function")),Fo=x([c(),k().int()]),Bo=c();B({ttl:x([k(),qo()]).optional(),pollInterval:k().optional()});const ma=l({ttl:k().optional()}),fa=l({taskId:c()}),gt=B({progressToken:Fo.optional(),[re]:fa.optional()}),J=l({_meta:gt.optional()}),Se=J.extend({task:ma.optional()}),ga=e=>Se.safeParse(e).success,j=l({method:c(),params:J.loose().optional()}),G=l({_meta:gt.optional()}),K=l({method:c(),params:G.loose().optional()}),U=B({_meta:gt.optional()}),Te=x([c(),k().int()]),Vo=l({jsonrpc:a(We),id:Te,...j.shape}).strict(),so=e=>Vo.safeParse(e).success,Wo=l({jsonrpc:a(We),...K.shape}).strict(),va=e=>Wo.safeParse(e).success,vt=l({jsonrpc:a(We),id:Te,result:U}).strict(),Me=e=>vt.safeParse(e).success;var R;(function(e){e[e.ConnectionClosed=-32e3]="ConnectionClosed",e[e.RequestTimeout=-32001]="RequestTimeout",e[e.ParseError=-32700]="ParseError",e[e.InvalidRequest=-32600]="InvalidRequest",e[e.MethodNotFound=-32601]="MethodNotFound",e[e.InvalidParams=-32602]="InvalidParams",e[e.InternalError=-32603]="InternalError",e[e.UrlElicitationRequired=-32042]="UrlElicitationRequired"})(R||(R={}));const _t=l({jsonrpc:a(We),id:Te.optional(),error:l({code:k().int(),message:c(),data:$().optional()})}).strict(),_a=e=>_t.safeParse(e).success,ba=x([Vo,Wo,vt,_t]);x([vt,_t]);const bt=U.strict(),ya=G.extend({requestId:Te.optional(),reason:c().optional()}),yt=K.extend({method:a("notifications/cancelled"),params:ya}),wa=l({src:c(),mimeType:c().optional(),sizes:_(c()).optional(),theme:W(["light","dark"]).optional()}),ze=l({icons:_(wa).optional()}),le=l({name:c(),title:c().optional()}),Je=le.extend({...le.shape,...ze.shape,version:c(),websiteUrl:c().optional(),description:c().optional()}),ka=ft(l({applyDefaults:E().optional()}),I(c(),$())),xa=Ho(e=>e&&typeof e=="object"&&!Array.isArray(e)&&Object.keys(e).length===0?{form:{}}:e,ft(l({form:ka.optional(),url:L.optional()}),I(c(),$()).optional())),Sa=B({list:L.optional(),cancel:L.optional(),requests:B({sampling:B({createMessage:L.optional()}).optional(),elicitation:B({create:L.optional()}).optional()}).optional()}),Ta=B({list:L.optional(),cancel:L.optional(),requests:B({tools:B({call:L.optional()}).optional()}).optional()}),za=l({experimental:I(c(),L).optional(),sampling:l({context:L.optional(),tools:L.optional()}).optional(),elicitation:xa.optional(),roots:l({listChanged:E().optional()}).optional(),tasks:Sa.optional()}),Ra=J.extend({protocolVersion:c(),capabilities:za,clientInfo:Je}),Ia=j.extend({method:a("initialize"),params:Ra}),$a=l({experimental:I(c(),L).optional(),logging:L.optional(),completions:L.optional(),prompts:l({listChanged:E().optional()}).optional(),resources:l({subscribe:E().optional(),listChanged:E().optional()}).optional(),tools:l({listChanged:E().optional()}).optional(),tasks:Ta.optional()}),Pa=U.extend({protocolVersion:c(),capabilities:$a,serverInfo:Je,instructions:c().optional()}),Ea=K.extend({method:a("notifications/initialized"),params:G.optional()}),Ge=j.extend({method:a("ping"),params:J.optional()}),Za=l({progress:k(),total:O(k()),message:O(c())}),Ca=l({...G.shape,...Za.shape,progressToken:Fo}),wt=K.extend({method:a("notifications/progress"),params:Ca}),Na=J.extend({cursor:Bo.optional()}),Re=j.extend({params:Na.optional()}),Ie=U.extend({nextCursor:Bo.optional()}),qa=W(["working","input_required","completed","failed","cancelled"]),$e=l({taskId:c(),status:qa,ttl:x([k(),qo()]),createdAt:c(),lastUpdatedAt:c(),pollInterval:O(k()),statusMessage:O(c())}),kt=U.extend({task:$e}),Ma=G.merge($e),Ue=K.extend({method:a("notifications/tasks/status"),params:Ma}),xt=j.extend({method:a("tasks/get"),params:J.extend({taskId:c()})}),St=U.merge($e),Tt=j.extend({method:a("tasks/result"),params:J.extend({taskId:c()})});U.loose();const zt=Re.extend({method:a("tasks/list")}),Rt=Ie.extend({tasks:_($e)}),It=j.extend({method:a("tasks/cancel"),params:J.extend({taskId:c()})}),Oa=U.merge($e),Jo=l({uri:c(),mimeType:O(c()),_meta:I(c(),$()).optional()}),Go=Jo.extend({text:c()}),$t=c().refine(e=>{try{return atob(e),!0}catch{return!1}},{message:"Invalid Base64 string"}),Ko=Jo.extend({blob:$t}),Pe=W(["user","assistant"]),pe=l({audience:_(Pe).optional(),priority:k().min(0).max(1).optional(),lastModified:Zo({offset:!0}).optional()}),Qo=l({...le.shape,...ze.shape,uri:c(),description:O(c()),mimeType:O(c()),annotations:pe.optional(),_meta:O(B({}))}),Aa=l({...le.shape,...ze.shape,uriTemplate:c(),description:O(c()),mimeType:O(c()),annotations:pe.optional(),_meta:O(B({}))}),Da=Re.extend({method:a("resources/list")}),Yo=Ie.extend({resources:_(Qo)}),La=Re.extend({method:a("resources/templates/list")}),ja=Ie.extend({resourceTemplates:_(Aa)}),Pt=J.extend({uri:c()}),Ua=Pt,Ha=j.extend({method:a("resources/read"),params:Ua}),Xo=U.extend({contents:_(x([Go,Ko]))}),Fa=K.extend({method:a("notifications/resources/list_changed"),params:G.optional()}),Ba=Pt,Va=j.extend({method:a("resources/subscribe"),params:Ba}),Wa=Pt,Ja=j.extend({method:a("resources/unsubscribe"),params:Wa}),Ga=G.extend({uri:c()}),Ka=K.extend({method:a("notifications/resources/updated"),params:Ga}),Qa=l({name:c(),description:O(c()),required:O(E())}),Ya=l({...le.shape,...ze.shape,description:O(c()),arguments:O(_(Qa)),_meta:O(B({}))}),Xa=Re.extend({method:a("prompts/list")}),ec=Ie.extend({prompts:_(Ya)}),tc=J.extend({name:c(),arguments:I(c(),c()).optional()}),oc=j.extend({method:a("prompts/get"),params:tc}),Et=l({type:a("text"),text:c(),annotations:pe.optional(),_meta:I(c(),$()).optional()}),Zt=l({type:a("image"),data:$t,mimeType:c(),annotations:pe.optional(),_meta:I(c(),$()).optional()}),Ct=l({type:a("audio"),data:$t,mimeType:c(),annotations:pe.optional(),_meta:I(c(),$()).optional()}),nc=l({type:a("tool_use"),name:c(),id:c(),input:I(c(),$()),_meta:I(c(),$()).optional()}),en=l({type:a("resource"),resource:x([Go,Ko]),annotations:pe.optional(),_meta:I(c(),$()).optional()}),tn=Qo.extend({type:a("resource_link")}),Ee=x([Et,Zt,Ct,tn,en]),rc=l({role:Pe,content:Ee}),sc=U.extend({description:c().optional(),messages:_(rc)}),ic=K.extend({method:a("notifications/prompts/list_changed"),params:G.optional()}),ac=l({title:c().optional(),readOnlyHint:E().optional(),destructiveHint:E().optional(),idempotentHint:E().optional(),openWorldHint:E().optional()}),cc=l({taskSupport:W(["required","optional","forbidden"]).optional()}),Nt=l({...le.shape,...ze.shape,description:c().optional(),inputSchema:l({type:a("object"),properties:I(c(),L).optional(),required:_(c()).optional()}).catchall($()),outputSchema:l({type:a("object"),properties:I(c(),L).optional(),required:_(c()).optional()}).catchall($()).optional(),annotations:ac.optional(),execution:cc.optional(),_meta:I(c(),$()).optional()}),on=Re.extend({method:a("tools/list")}),uc=Ie.extend({tools:_(Nt)}),Ke=U.extend({content:_(Ee).default([]),structuredContent:I(c(),$()).optional(),isError:E().optional()});Ke.or(U.extend({toolResult:$()}));const lc=Se.extend({name:c(),arguments:I(c(),$()).optional()}),nn=j.extend({method:a("tools/call"),params:lc}),dc=K.extend({method:a("notifications/tools/list_changed"),params:G.optional()});l({autoRefresh:E().default(!0),debounceMs:k().int().nonnegative().default(300)});const rn=W(["debug","info","notice","warning","error","critical","alert","emergency"]),pc=J.extend({level:rn}),hc=j.extend({method:a("logging/setLevel"),params:pc}),mc=G.extend({level:rn,logger:c().optional(),data:$()}),fc=K.extend({method:a("notifications/message"),params:mc}),gc=l({name:c().optional()}),vc=l({hints:_(gc).optional(),costPriority:k().min(0).max(1).optional(),speedPriority:k().min(0).max(1).optional(),intelligencePriority:k().min(0).max(1).optional()}),_c=l({mode:W(["auto","required","none"]).optional()}),bc=l({type:a("tool_result"),toolUseId:c().describe("The unique identifier for the corresponding tool call."),content:_(Ee).default([]),structuredContent:l({}).loose().optional(),isError:E().optional(),_meta:I(c(),$()).optional()}),yc=Ao("type",[Et,Zt,Ct]),He=Ao("type",[Et,Zt,Ct,nc,bc]),wc=l({role:Pe,content:x([He,_(He)]),_meta:I(c(),$()).optional()}),kc=Se.extend({messages:_(wc),modelPreferences:vc.optional(),systemPrompt:c().optional(),includeContext:W(["none","thisServer","allServers"]).optional(),temperature:k().optional(),maxTokens:k().int(),stopSequences:_(c()).optional(),metadata:L.optional(),tools:_(Nt).optional(),toolChoice:_c.optional()}),xc=j.extend({method:a("sampling/createMessage"),params:kc}),Sc=U.extend({model:c(),stopReason:O(W(["endTurn","stopSequence","maxTokens"]).or(c())),role:Pe,content:yc}),Tc=U.extend({model:c(),stopReason:O(W(["endTurn","stopSequence","maxTokens","toolUse"]).or(c())),role:Pe,content:x([He,_(He)])}),zc=l({type:a("boolean"),title:c().optional(),description:c().optional(),default:E().optional()}),Rc=l({type:a("string"),title:c().optional(),description:c().optional(),minLength:k().optional(),maxLength:k().optional(),format:W(["email","uri","date","date-time"]).optional(),default:c().optional()}),Ic=l({type:W(["number","integer"]),title:c().optional(),description:c().optional(),minimum:k().optional(),maximum:k().optional(),default:k().optional()}),$c=l({type:a("string"),title:c().optional(),description:c().optional(),enum:_(c()),default:c().optional()}),Pc=l({type:a("string"),title:c().optional(),description:c().optional(),oneOf:_(l({const:c(),title:c()})),default:c().optional()}),Ec=l({type:a("string"),title:c().optional(),description:c().optional(),enum:_(c()),enumNames:_(c()).optional(),default:c().optional()}),Zc=x([$c,Pc]),Cc=l({type:a("array"),title:c().optional(),description:c().optional(),minItems:k().optional(),maxItems:k().optional(),items:l({type:a("string"),enum:_(c())}),default:_(c()).optional()}),Nc=l({type:a("array"),title:c().optional(),description:c().optional(),minItems:k().optional(),maxItems:k().optional(),items:l({anyOf:_(l({const:c(),title:c()}))}),default:_(c()).optional()}),qc=x([Cc,Nc]),Mc=x([Ec,Zc,qc]),Oc=x([Mc,zc,Rc,Ic]),Ac=Se.extend({mode:a("form").optional(),message:c(),requestedSchema:l({type:a("object"),properties:I(c(),Oc),required:_(c()).optional()})}),Dc=Se.extend({mode:a("url"),message:c(),elicitationId:c(),url:c().url()}),Lc=x([Ac,Dc]),jc=j.extend({method:a("elicitation/create"),params:Lc}),Uc=G.extend({elicitationId:c()}),Hc=K.extend({method:a("notifications/elicitation/complete"),params:Uc}),Fc=U.extend({action:W(["accept","decline","cancel"]),content:Ho(e=>e===null?void 0:e,I(c(),x([c(),k(),E(),_(c())])).optional())}),Bc=l({type:a("ref/resource"),uri:c()}),Vc=l({type:a("ref/prompt"),name:c()}),Wc=J.extend({ref:x([Vc,Bc]),argument:l({name:c(),value:c()}),context:l({arguments:I(c(),c()).optional()}).optional()}),Jc=j.extend({method:a("completion/complete"),params:Wc}),Gc=U.extend({completion:B({values:_(c()).max(100),total:O(k().int()),hasMore:O(E())})}),Kc=l({uri:c().startsWith("file://"),name:c().optional(),_meta:I(c(),$()).optional()}),Qc=j.extend({method:a("roots/list"),params:J.optional()}),Yc=U.extend({roots:_(Kc)}),Xc=K.extend({method:a("notifications/roots/list_changed"),params:G.optional()});x([Ge,Ia,Jc,hc,oc,Xa,Da,La,Ha,Va,Ja,nn,on,xt,Tt,zt,It]);x([yt,wt,Ea,Xc,Ue]);x([bt,Sc,Tc,Fc,Yc,St,Rt,kt]);x([Ge,xc,jc,Qc,xt,Tt,zt,It]);x([yt,wt,fc,Ka,Fa,dc,ic,Ue,Hc]);x([bt,Pa,Gc,sc,ec,Yo,ja,Xo,Ke,uc,St,Rt,kt]);class T extends Error{constructor(t,o,n){super(`MCP error ${t}: ${o}`),this.code=t,this.data=n,this.name="McpError"}static fromError(t,o,n){if(t===R.UrlElicitationRequired&&n){const r=n;if(r.elicitations)return new eu(r.elicitations,o)}return new T(t,o,n)}}class eu extends T{constructor(t,o=`URL elicitation${t.length>1?"s":""} required`){super(R.UrlElicitationRequired,o,{elicitations:t})}get elicitations(){return this.data?.elicitations??[]}}function ne(e){return e==="completed"||e==="failed"||e==="cancelled"}new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function io(e){const o=ci(e)?.method;if(!o)throw new Error("Schema is missing a method literal");const n=ui(o);if(typeof n!="string")throw new Error("Schema method literal must be a string");return n}function ao(e,t){const o=Eo(e,t);if(!o.success)throw o.error;return o.data}const tu=6e4;class ou{constructor(t){this._options=t,this._requestMessageId=0,this._requestHandlers=new Map,this._requestHandlerAbortControllers=new Map,this._notificationHandlers=new Map,this._responseHandlers=new Map,this._progressHandlers=new Map,this._timeoutInfo=new Map,this._pendingDebouncedNotifications=new Set,this._taskProgressTokens=new Map,this._requestResolvers=new Map,this.setNotificationHandler(yt,o=>{this._oncancel(o)}),this.setNotificationHandler(wt,o=>{this._onprogress(o)}),this.setRequestHandler(Ge,o=>({})),this._taskStore=t?.taskStore,this._taskMessageQueue=t?.taskMessageQueue,this._taskStore&&(this.setRequestHandler(xt,async(o,n)=>{const r=await this._taskStore.getTask(o.params.taskId,n.sessionId);if(!r)throw new T(R.InvalidParams,"Failed to retrieve task: Task not found");return{...r}}),this.setRequestHandler(Tt,async(o,n)=>{const r=async()=>{const s=o.params.taskId;if(this._taskMessageQueue){let u;for(;u=await this._taskMessageQueue.dequeue(s,n.sessionId);){if(u.type==="response"||u.type==="error"){const p=u.message,m=p.id,f=this._requestResolvers.get(m);if(f)if(this._requestResolvers.delete(m),u.type==="response")f(p);else{const h=p,v=new T(h.error.code,h.error.message,h.error.data);f(v)}else{const h=u.type==="response"?"Response":"Error";this._onerror(new Error(`${h} handler missing for request ${m}`))}continue}await this._transport?.send(u.message,{relatedRequestId:n.requestId})}}const i=await this._taskStore.getTask(s,n.sessionId);if(!i)throw new T(R.InvalidParams,`Task not found: ${s}`);if(!ne(i.status))return await this._waitForTaskUpdate(s,n.signal),await r();if(ne(i.status)){const u=await this._taskStore.getTaskResult(s,n.sessionId);return this._clearTaskQueue(s),{...u,_meta:{...u._meta,[re]:{taskId:s}}}}return await r()};return await r()}),this.setRequestHandler(zt,async(o,n)=>{try{const{tasks:r,nextCursor:s}=await this._taskStore.listTasks(o.params?.cursor,n.sessionId);return{tasks:r,nextCursor:s,_meta:{}}}catch(r){throw new T(R.InvalidParams,`Failed to list tasks: ${r instanceof Error?r.message:String(r)}`)}}),this.setRequestHandler(It,async(o,n)=>{try{const r=await this._taskStore.getTask(o.params.taskId,n.sessionId);if(!r)throw new T(R.InvalidParams,`Task not found: ${o.params.taskId}`);if(ne(r.status))throw new T(R.InvalidParams,`Cannot cancel task in terminal status: ${r.status}`);await this._taskStore.updateTaskStatus(o.params.taskId,"cancelled","Client cancelled task execution.",n.sessionId),this._clearTaskQueue(o.params.taskId);const s=await this._taskStore.getTask(o.params.taskId,n.sessionId);if(!s)throw new T(R.InvalidParams,`Task not found after cancellation: ${o.params.taskId}`);return{_meta:{},...s}}catch(r){throw r instanceof T?r:new T(R.InvalidRequest,`Failed to cancel task: ${r instanceof Error?r.message:String(r)}`)}}))}async _oncancel(t){if(!t.params.requestId)return;this._requestHandlerAbortControllers.get(t.params.requestId)?.abort(t.params.reason)}_setupTimeout(t,o,n,r,s=!1){this._timeoutInfo.set(t,{timeoutId:setTimeout(r,o),startTime:Date.now(),timeout:o,maxTotalTimeout:n,resetTimeoutOnProgress:s,onTimeout:r})}_resetTimeout(t){const o=this._timeoutInfo.get(t);if(!o)return!1;const n=Date.now()-o.startTime;if(o.maxTotalTimeout&&n>=o.maxTotalTimeout)throw this._timeoutInfo.delete(t),T.fromError(R.RequestTimeout,"Maximum total timeout exceeded",{maxTotalTimeout:o.maxTotalTimeout,totalElapsed:n});return clearTimeout(o.timeoutId),o.timeoutId=setTimeout(o.onTimeout,o.timeout),!0}_cleanupTimeout(t){const o=this._timeoutInfo.get(t);o&&(clearTimeout(o.timeoutId),this._timeoutInfo.delete(t))}async connect(t){if(this._transport)throw new Error("Already connected to a transport. Call close() before connecting to a new transport, or use a separate Protocol instance per connection.");this._transport=t;const o=this.transport?.onclose;this._transport.onclose=()=>{o?.(),this._onclose()};const n=this.transport?.onerror;this._transport.onerror=s=>{n?.(s),this._onerror(s)};const r=this._transport?.onmessage;this._transport.onmessage=(s,i)=>{r?.(s,i),Me(s)||_a(s)?this._onresponse(s):so(s)?this._onrequest(s,i):va(s)?this._onnotification(s):this._onerror(new Error(`Unknown message type: ${JSON.stringify(s)}`))},await this._transport.start()}_onclose(){const t=this._responseHandlers;this._responseHandlers=new Map,this._progressHandlers.clear(),this._taskProgressTokens.clear(),this._pendingDebouncedNotifications.clear();for(const n of this._requestHandlerAbortControllers.values())n.abort();this._requestHandlerAbortControllers.clear();const o=T.fromError(R.ConnectionClosed,"Connection closed");this._transport=void 0,this.onclose?.();for(const n of t.values())n(o)}_onerror(t){this.onerror?.(t)}_onnotification(t){const o=this._notificationHandlers.get(t.method)??this.fallbackNotificationHandler;o!==void 0&&Promise.resolve().then(()=>o(t)).catch(n=>this._onerror(new Error(`Uncaught error in notification handler: ${n}`)))}_onrequest(t,o){const n=this._requestHandlers.get(t.method)??this.fallbackRequestHandler,r=this._transport,s=t.params?._meta?.[re]?.taskId;if(n===void 0){const f={jsonrpc:"2.0",id:t.id,error:{code:R.MethodNotFound,message:"Method not found"}};s&&this._taskMessageQueue?this._enqueueTaskMessage(s,{type:"error",message:f,timestamp:Date.now()},r?.sessionId).catch(h=>this._onerror(new Error(`Failed to enqueue error response: ${h}`))):r?.send(f).catch(h=>this._onerror(new Error(`Failed to send an error response: ${h}`)));return}const i=new AbortController;this._requestHandlerAbortControllers.set(t.id,i);const u=ga(t.params)?t.params.task:void 0,p=this._taskStore?this.requestTaskStore(t,r?.sessionId):void 0,m={signal:i.signal,sessionId:r?.sessionId,_meta:t.params?._meta,sendNotification:async f=>{if(i.signal.aborted)return;const h={relatedRequestId:t.id};s&&(h.relatedTask={taskId:s}),await this.notification(f,h)},sendRequest:async(f,h,v)=>{if(i.signal.aborted)throw new T(R.ConnectionClosed,"Request was cancelled");const b={...v,relatedRequestId:t.id};s&&!b.relatedTask&&(b.relatedTask={taskId:s});const P=b.relatedTask?.taskId??s;return P&&p&&await p.updateTaskStatus(P,"input_required"),await this.request(f,h,b)},authInfo:o?.authInfo,requestId:t.id,requestInfo:o?.requestInfo,taskId:s,taskStore:p,taskRequestedTtl:u?.ttl,closeSSEStream:o?.closeSSEStream,closeStandaloneSSEStream:o?.closeStandaloneSSEStream};Promise.resolve().then(()=>{u&&this.assertTaskHandlerCapability(t.method)}).then(()=>n(t,m)).then(async f=>{if(i.signal.aborted)return;const h={result:f,jsonrpc:"2.0",id:t.id};s&&this._taskMessageQueue?await this._enqueueTaskMessage(s,{type:"response",message:h,timestamp:Date.now()},r?.sessionId):await r?.send(h)},async f=>{if(i.signal.aborted)return;const h={jsonrpc:"2.0",id:t.id,error:{code:Number.isSafeInteger(f.code)?f.code:R.InternalError,message:f.message??"Internal error",...f.data!==void 0&&{data:f.data}}};s&&this._taskMessageQueue?await this._enqueueTaskMessage(s,{type:"error",message:h,timestamp:Date.now()},r?.sessionId):await r?.send(h)}).catch(f=>this._onerror(new Error(`Failed to send response: ${f}`))).finally(()=>{this._requestHandlerAbortControllers.delete(t.id)})}_onprogress(t){const{progressToken:o,...n}=t.params,r=Number(o),s=this._progressHandlers.get(r);if(!s){this._onerror(new Error(`Received a progress notification for an unknown token: ${JSON.stringify(t)}`));return}const i=this._responseHandlers.get(r),u=this._timeoutInfo.get(r);if(u&&i&&u.resetTimeoutOnProgress)try{this._resetTimeout(r)}catch(p){this._responseHandlers.delete(r),this._progressHandlers.delete(r),this._cleanupTimeout(r),i(p);return}s(n)}_onresponse(t){const o=Number(t.id),n=this._requestResolvers.get(o);if(n){if(this._requestResolvers.delete(o),Me(t))n(t);else{const i=new T(t.error.code,t.error.message,t.error.data);n(i)}return}const r=this._responseHandlers.get(o);if(r===void 0){this._onerror(new Error(`Received a response for an unknown message ID: ${JSON.stringify(t)}`));return}this._responseHandlers.delete(o),this._cleanupTimeout(o);let s=!1;if(Me(t)&&t.result&&typeof t.result=="object"){const i=t.result;if(i.task&&typeof i.task=="object"){const u=i.task;typeof u.taskId=="string"&&(s=!0,this._taskProgressTokens.set(u.taskId,o))}}if(s||this._progressHandlers.delete(o),Me(t))r(t);else{const i=T.fromError(t.error.code,t.error.message,t.error.data);r(i)}}get transport(){return this._transport}async close(){await this._transport?.close()}async*requestStream(t,o,n){const{task:r}=n??{};if(!r){try{yield{type:"result",result:await this.request(t,o,n)}}catch(i){yield{type:"error",error:i instanceof T?i:new T(R.InternalError,String(i))}}return}let s;try{const i=await this.request(t,kt,n);if(i.task)s=i.task.taskId,yield{type:"taskCreated",task:i.task};else throw new T(R.InternalError,"Task creation did not return a task");for(;;){const u=await this.getTask({taskId:s},n);if(yield{type:"taskStatus",task:u},ne(u.status)){u.status==="completed"?yield{type:"result",result:await this.getTaskResult({taskId:s},o,n)}:u.status==="failed"?yield{type:"error",error:new T(R.InternalError,`Task ${s} failed`)}:u.status==="cancelled"&&(yield{type:"error",error:new T(R.InternalError,`Task ${s} was cancelled`)});return}if(u.status==="input_required"){yield{type:"result",result:await this.getTaskResult({taskId:s},o,n)};return}const p=u.pollInterval??this._options?.defaultTaskPollInterval??1e3;await new Promise(m=>setTimeout(m,p)),n?.signal?.throwIfAborted()}}catch(i){yield{type:"error",error:i instanceof T?i:new T(R.InternalError,String(i))}}}request(t,o,n){const{relatedRequestId:r,resumptionToken:s,onresumptiontoken:i,task:u,relatedTask:p}=n??{};return new Promise((m,f)=>{const h=w=>{f(w)};if(!this._transport){h(new Error("Not connected"));return}if(this._options?.enforceStrictCapabilities===!0)try{this.assertCapabilityForMethod(t.method),u&&this.assertTaskCapability(t.method)}catch(w){h(w);return}n?.signal?.throwIfAborted();const v=this._requestMessageId++,b={...t,jsonrpc:"2.0",id:v};n?.onprogress&&(this._progressHandlers.set(v,n.onprogress),b.params={...t.params,_meta:{...t.params?._meta||{},progressToken:v}}),u&&(b.params={...b.params,task:u}),p&&(b.params={...b.params,_meta:{...b.params?._meta||{},[re]:p}});const P=w=>{this._responseHandlers.delete(v),this._progressHandlers.delete(v),this._cleanupTimeout(v),this._transport?.send({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:v,reason:String(w)}},{relatedRequestId:r,resumptionToken:s,onresumptiontoken:i}).catch(z=>this._onerror(new Error(`Failed to send cancellation: ${z}`)));const y=w instanceof T?w:new T(R.RequestTimeout,String(w));f(y)};this._responseHandlers.set(v,w=>{if(!n?.signal?.aborted){if(w instanceof Error)return f(w);try{const y=Eo(o,w.result);y.success?m(y.data):f(y.error)}catch(y){f(y)}}}),n?.signal?.addEventListener("abort",()=>{P(n?.signal?.reason)});const A=n?.timeout??tu,S=()=>P(T.fromError(R.RequestTimeout,"Request timed out",{timeout:A}));this._setupTimeout(v,A,n?.maxTotalTimeout,S,n?.resetTimeoutOnProgress??!1);const D=p?.taskId;if(D){const w=y=>{const z=this._responseHandlers.get(v);z?z(y):this._onerror(new Error(`Response handler missing for side-channeled request ${v}`))};this._requestResolvers.set(v,w),this._enqueueTaskMessage(D,{type:"request",message:b,timestamp:Date.now()}).catch(y=>{this._cleanupTimeout(v),f(y)})}else this._transport.send(b,{relatedRequestId:r,resumptionToken:s,onresumptiontoken:i}).catch(w=>{this._cleanupTimeout(v),f(w)})})}async getTask(t,o){return this.request({method:"tasks/get",params:t},St,o)}async getTaskResult(t,o,n){return this.request({method:"tasks/result",params:t},o,n)}async listTasks(t,o){return this.request({method:"tasks/list",params:t},Rt,o)}async cancelTask(t,o){return this.request({method:"tasks/cancel",params:t},Oa,o)}async notification(t,o){if(!this._transport)throw new Error("Not connected");this.assertNotificationCapability(t.method);const n=o?.relatedTask?.taskId;if(n){const u={...t,jsonrpc:"2.0",params:{...t.params,_meta:{...t.params?._meta||{},[re]:o.relatedTask}}};await this._enqueueTaskMessage(n,{type:"notification",message:u,timestamp:Date.now()});return}if((this._options?.debouncedNotificationMethods??[]).includes(t.method)&&!t.params&&!o?.relatedRequestId&&!o?.relatedTask){if(this._pendingDebouncedNotifications.has(t.method))return;this._pendingDebouncedNotifications.add(t.method),Promise.resolve().then(()=>{if(this._pendingDebouncedNotifications.delete(t.method),!this._transport)return;let u={...t,jsonrpc:"2.0"};o?.relatedTask&&(u={...u,params:{...u.params,_meta:{...u.params?._meta||{},[re]:o.relatedTask}}}),this._transport?.send(u,o).catch(p=>this._onerror(p))});return}let i={...t,jsonrpc:"2.0"};o?.relatedTask&&(i={...i,params:{...i.params,_meta:{...i.params?._meta||{},[re]:o.relatedTask}}}),await this._transport.send(i,o)}setRequestHandler(t,o){const n=io(t);this.assertRequestHandlerCapability(n),this._requestHandlers.set(n,(r,s)=>{const i=ao(t,r);return Promise.resolve(o(i,s))})}removeRequestHandler(t){this._requestHandlers.delete(t)}assertCanSetRequestHandler(t){if(this._requestHandlers.has(t))throw new Error(`A request handler for ${t} already exists, which would be overridden`)}setNotificationHandler(t,o){const n=io(t);this._notificationHandlers.set(n,r=>{const s=ao(t,r);return Promise.resolve(o(s))})}removeNotificationHandler(t){this._notificationHandlers.delete(t)}_cleanupTaskProgressHandler(t){const o=this._taskProgressTokens.get(t);o!==void 0&&(this._progressHandlers.delete(o),this._taskProgressTokens.delete(t))}async _enqueueTaskMessage(t,o,n){if(!this._taskStore||!this._taskMessageQueue)throw new Error("Cannot enqueue task message: taskStore and taskMessageQueue are not configured");const r=this._options?.maxTaskQueueSize;await this._taskMessageQueue.enqueue(t,o,n,r)}async _clearTaskQueue(t,o){if(this._taskMessageQueue){const n=await this._taskMessageQueue.dequeueAll(t,o);for(const r of n)if(r.type==="request"&&so(r.message)){const s=r.message.id,i=this._requestResolvers.get(s);i?(i(new T(R.InternalError,"Task cancelled or completed")),this._requestResolvers.delete(s)):this._onerror(new Error(`Resolver missing for request ${s} during task ${t} cleanup`))}}}async _waitForTaskUpdate(t,o){let n=this._options?.defaultTaskPollInterval??1e3;try{const r=await this._taskStore?.getTask(t);r?.pollInterval&&(n=r.pollInterval)}catch{}return new Promise((r,s)=>{if(o.aborted){s(new T(R.InvalidRequest,"Request cancelled"));return}const i=setTimeout(r,n);o.addEventListener("abort",()=>{clearTimeout(i),s(new T(R.InvalidRequest,"Request cancelled"))},{once:!0})})}requestTaskStore(t,o){const n=this._taskStore;if(!n)throw new Error("No task store configured");return{createTask:async r=>{if(!t)throw new Error("No request provided");return await n.createTask(r,t.id,{method:t.method,params:t.params},o)},getTask:async r=>{const s=await n.getTask(r,o);if(!s)throw new T(R.InvalidParams,"Failed to retrieve task: Task not found");return s},storeTaskResult:async(r,s,i)=>{await n.storeTaskResult(r,s,i,o);const u=await n.getTask(r,o);if(u){const p=Ue.parse({method:"notifications/tasks/status",params:u});await this.notification(p),ne(u.status)&&this._cleanupTaskProgressHandler(r)}},getTaskResult:r=>n.getTaskResult(r,o),updateTaskStatus:async(r,s,i)=>{const u=await n.getTask(r,o);if(!u)throw new T(R.InvalidParams,`Task "${r}" not found - it may have been cleaned up`);if(ne(u.status))throw new T(R.InvalidParams,`Cannot update task "${r}" from terminal status "${u.status}" to "${s}". Terminal states (completed, failed, cancelled) cannot transition to other states.`);await n.updateTaskStatus(r,s,i,o);const p=await n.getTask(r,o);if(p){const m=Ue.parse({method:"notifications/tasks/status",params:p});await this.notification(m),ne(p.status)&&this._cleanupTaskProgressHandler(r)}},listTasks:r=>n.listTasks(r,o)}}}var nu="2026-01-26",ru="ui/notifications/tool-input-partial";class sn{eventTarget;eventSource;messageListener;constructor(t=window.parent,o){this.eventTarget=t,this.eventSource=o,this.messageListener=n=>{if(o&&n.source!==this.eventSource){console.debug("Ignoring message from unknown source",n);return}let r=ba.safeParse(n.data);r.success?(console.debug("Parsed message",r.data),this.onmessage?.(r.data)):n.data?.jsonrpc!=="2.0"?console.debug("Ignoring non-JSON-RPC message",r.error.message,n):(console.error("Failed to parse message",r.error.message,n),this.onerror?.(Error("Invalid JSON-RPC message received: "+r.error.message)))}}async start(){window.addEventListener("message",this.messageListener)}async send(t,o){t.method!==ru&&console.debug("Sending message",t),this.eventTarget.postMessage(t,"*")}async close(){window.removeEventListener("message",this.messageListener),this.onclose?.()}onclose;onerror;onmessage;sessionId;setProtocolVersion}var su=x([a("light"),a("dark")]).describe("Color theme preference for the host environment."),be=x([a("inline"),a("fullscreen"),a("pip")]).describe("Display mode for UI presentation."),iu=x([a("--color-background-primary"),a("--color-background-secondary"),a("--color-background-tertiary"),a("--color-background-inverse"),a("--color-background-ghost"),a("--color-background-info"),a("--color-background-danger"),a("--color-background-success"),a("--color-background-warning"),a("--color-background-disabled"),a("--color-text-primary"),a("--color-text-secondary"),a("--color-text-tertiary"),a("--color-text-inverse"),a("--color-text-ghost"),a("--color-text-info"),a("--color-text-danger"),a("--color-text-success"),a("--color-text-warning"),a("--color-text-disabled"),a("--color-border-primary"),a("--color-border-secondary"),a("--color-border-tertiary"),a("--color-border-inverse"),a("--color-border-ghost"),a("--color-border-info"),a("--color-border-danger"),a("--color-border-success"),a("--color-border-warning"),a("--color-border-disabled"),a("--color-ring-primary"),a("--color-ring-secondary"),a("--color-ring-inverse"),a("--color-ring-info"),a("--color-ring-danger"),a("--color-ring-success"),a("--color-ring-warning"),a("--font-sans"),a("--font-mono"),a("--font-weight-normal"),a("--font-weight-medium"),a("--font-weight-semibold"),a("--font-weight-bold"),a("--font-text-xs-size"),a("--font-text-sm-size"),a("--font-text-md-size"),a("--font-text-lg-size"),a("--font-heading-xs-size"),a("--font-heading-sm-size"),a("--font-heading-md-size"),a("--font-heading-lg-size"),a("--font-heading-xl-size"),a("--font-heading-2xl-size"),a("--font-heading-3xl-size"),a("--font-text-xs-line-height"),a("--font-text-sm-line-height"),a("--font-text-md-line-height"),a("--font-text-lg-line-height"),a("--font-heading-xs-line-height"),a("--font-heading-sm-line-height"),a("--font-heading-md-line-height"),a("--font-heading-lg-line-height"),a("--font-heading-xl-line-height"),a("--font-heading-2xl-line-height"),a("--font-heading-3xl-line-height"),a("--border-radius-xs"),a("--border-radius-sm"),a("--border-radius-md"),a("--border-radius-lg"),a("--border-radius-xl"),a("--border-radius-full"),a("--border-width-regular"),a("--shadow-hairline"),a("--shadow-sm"),a("--shadow-md"),a("--shadow-lg")]).describe("CSS variable keys available to MCP apps for theming."),au=I(iu.describe(`Style variables for theming MCP apps.
|
|
33
33
|
|
|
34
34
|
Individual style keys are optional - hosts may provide any subset of these values.
|
|
35
35
|
Values are strings containing CSS values (colors, sizes, font stacks, etc.).
|
|
36
36
|
|
|
37
37
|
Note: This type uses \`Record<K, string | undefined>\` rather than \`Partial<Record<K, string>>\`
|
|
38
|
-
for compatibility with Zod schema generation. Both are functionally equivalent for validation.`),
|
|
38
|
+
for compatibility with Zod schema generation. Both are functionally equivalent for validation.`),x([c(),ot()]).describe(`Style variables for theming MCP apps.
|
|
39
39
|
|
|
40
40
|
Individual style keys are optional - hosts may provide any subset of these values.
|
|
41
41
|
Values are strings containing CSS values (colors, sizes, font stacks, etc.).
|
|
@@ -47,10 +47,10 @@ Individual style keys are optional - hosts may provide any subset of these value
|
|
|
47
47
|
Values are strings containing CSS values (colors, sizes, font stacks, etc.).
|
|
48
48
|
|
|
49
49
|
Note: This type uses \`Record<K, string | undefined>\` rather than \`Partial<Record<K, string>>\`
|
|
50
|
-
for compatibility with Zod schema generation. Both are functionally equivalent for validation.`);l({method:a("ui/open-link"),params:l({url:
|
|
50
|
+
for compatibility with Zod schema generation. Both are functionally equivalent for validation.`);l({method:a("ui/open-link"),params:l({url:c().describe("URL to open in the host's browser")})});var cu=l({isError:E().optional().describe("True if the host failed to open the URL (e.g., due to security policy).")}).passthrough(),uu=l({isError:E().optional().describe("True if the download failed (e.g., user cancelled or host denied).")}).passthrough(),lu=l({isError:E().optional().describe("True if the host rejected or failed to deliver the message.")}).passthrough();l({method:a("ui/notifications/sandbox-proxy-ready"),params:l({})});var qt=l({connectDomains:_(c()).optional().describe(`Origins for network requests (fetch/XHR/WebSocket).
|
|
51
51
|
|
|
52
52
|
- Maps to CSP \`connect-src\` directive
|
|
53
|
-
- Empty or omitted → no network connections (secure default)`),resourceDomains:_(
|
|
53
|
+
- Empty or omitted → no network connections (secure default)`),resourceDomains:_(c()).optional().describe("Origins for static resources (images, scripts, stylesheets, fonts, media).\n\n- Maps to CSP `img-src`, `script-src`, `style-src`, `font-src`, `media-src` directives\n- Wildcard subdomains supported: `https://*.example.com`\n- Empty or omitted → no network resources (secure default)"),frameDomains:_(c()).optional().describe("Origins for nested iframes.\n\n- Maps to CSP `frame-src` directive\n- Empty or omitted → no nested iframes allowed (`frame-src 'none'`)"),baseUriDomains:_(c()).optional().describe("Allowed base URIs for the document.\n\n- Maps to CSP `base-uri` directive\n- Empty or omitted → only same origin allowed (`base-uri 'self'`)")}),Mt=l({camera:l({}).optional().describe("Request camera access.\n\nMaps to Permission Policy `camera` feature."),microphone:l({}).optional().describe("Request microphone access.\n\nMaps to Permission Policy `microphone` feature."),geolocation:l({}).optional().describe("Request geolocation access.\n\nMaps to Permission Policy `geolocation` feature."),clipboardWrite:l({}).optional().describe("Request clipboard write access.\n\nMaps to Permission Policy `clipboard-write` feature.")});l({method:a("ui/notifications/size-changed"),params:l({width:k().optional().describe("New width in pixels."),height:k().optional().describe("New height in pixels.")})});var du=l({method:a("ui/notifications/tool-input"),params:l({arguments:I(c(),$().describe("Complete tool call arguments as key-value pairs.")).optional().describe("Complete tool call arguments as key-value pairs.")})}),pu=l({method:a("ui/notifications/tool-input-partial"),params:l({arguments:I(c(),$().describe("Partial tool call arguments (incomplete, may change).")).optional().describe("Partial tool call arguments (incomplete, may change).")})}),hu=l({method:a("ui/notifications/tool-cancelled"),params:l({reason:c().optional().describe('Optional reason for the cancellation (e.g., "user action", "timeout").')})}),mu=l({fonts:c().optional()}),fu=l({variables:au.optional().describe("CSS variables for theming the app."),css:mu.optional().describe("CSS blocks that apps can inject.")}),gu=l({method:a("ui/resource-teardown"),params:l({})});I(c(),$());var co=l({text:l({}).optional().describe("Host supports text content blocks."),image:l({}).optional().describe("Host supports image content blocks."),audio:l({}).optional().describe("Host supports audio content blocks."),resource:l({}).optional().describe("Host supports resource content blocks."),resourceLink:l({}).optional().describe("Host supports resource link content blocks."),structuredContent:l({}).optional().describe("Host supports structured content.")});l({method:a("ui/notifications/request-teardown"),params:l({}).optional()});var vu=l({experimental:l({}).optional().describe("Experimental features (structure TBD)."),openLinks:l({}).optional().describe("Host supports opening external URLs."),downloadFile:l({}).optional().describe("Host supports file downloads via ui/download-file."),serverTools:l({listChanged:E().optional().describe("Host supports tools/list_changed notifications.")}).optional().describe("Host can proxy tool calls to the MCP server."),serverResources:l({listChanged:E().optional().describe("Host supports resources/list_changed notifications.")}).optional().describe("Host can proxy resource reads to the MCP server."),logging:l({}).optional().describe("Host accepts log messages."),sandbox:l({permissions:Mt.optional().describe("Permissions granted by the host (camera, microphone, geolocation)."),csp:qt.optional().describe("CSP domains approved by the host.")}).optional().describe("Sandbox configuration applied by the host."),updateModelContext:co.optional().describe("Host accepts context updates (ui/update-model-context) to be included in the model's context for future turns."),message:co.optional().describe("Host supports receiving content messages (ui/message) from the view.")}),_u=l({experimental:l({}).optional().describe("Experimental features (structure TBD)."),tools:l({listChanged:E().optional().describe("App supports tools/list_changed notifications.")}).optional().describe("App exposes MCP-style tools that the host can call."),availableDisplayModes:_(be).optional().describe("Display modes the app supports.")});l({method:a("ui/notifications/initialized"),params:l({}).optional()});l({csp:qt.optional().describe("Content Security Policy configuration for UI resources."),permissions:Mt.optional().describe("Sandbox permissions requested by the UI resource."),domain:c().optional().describe(`Dedicated origin for view sandbox.
|
|
54
54
|
|
|
55
55
|
Useful when views need stable, dedicated origins for OAuth callbacks, CORS policies, or API key allowlists.
|
|
56
56
|
|
|
@@ -64,10 +64,10 @@ Boolean requesting whether a visible border and background is provided by the ho
|
|
|
64
64
|
|
|
65
65
|
- \`true\`: request visible border + background
|
|
66
66
|
- \`false\`: request no visible border + background
|
|
67
|
-
- omitted: host decides border`)});l({method:a("ui/request-display-mode"),params:l({mode:
|
|
67
|
+
- omitted: host decides border`)});l({method:a("ui/request-display-mode"),params:l({mode:be.describe("The display mode being requested.")})});var bu=l({mode:be.describe("The display mode that was actually set. May differ from requested if not supported.")}).passthrough(),yu=x([a("model"),a("app")]).describe("Tool visibility scope - who can access the tool.");l({resourceUri:c().optional(),visibility:_(yu).optional().describe(`Who can access this tool. Default: ["model", "app"]
|
|
68
68
|
- "model": Tool visible to and callable by the agent
|
|
69
|
-
- "app": Tool callable by the app from this server only`)});l({mimeTypes:_(
|
|
70
|
-
container holding the app. Specify either width or maxWidth, and either height or maxHeight.`),locale:
|
|
69
|
+
- "app": Tool callable by the app from this server only`)});l({mimeTypes:_(c()).optional().describe('Array of supported MIME types for UI resources.\nMust include `"text/html;profile=mcp-app"` for MCP Apps support.')});l({method:a("ui/download-file"),params:l({contents:_(x([en,tn])).describe("Resource contents to download — embedded (inline data) or linked (host fetches). Uses standard MCP resource types.")})});l({method:a("ui/message"),params:l({role:a("user").describe('Message role, currently only "user" is supported.'),content:_(Ee).describe("Message content blocks (text, image, etc.).")})});l({method:a("ui/notifications/sandbox-resource-ready"),params:l({html:c().describe("HTML content to load into the inner iframe."),sandbox:c().optional().describe("Optional override for the inner iframe's sandbox attribute."),csp:qt.optional().describe("CSP configuration from resource metadata."),permissions:Mt.optional().describe("Sandbox permissions from resource metadata.")})});var wu=l({method:a("ui/notifications/tool-result"),params:Ke.describe("Standard MCP tool execution result.")}),an=l({toolInfo:l({id:Te.optional().describe("JSON-RPC id of the tools/call request."),tool:Nt.describe("Tool definition including name, inputSchema, etc.")}).optional().describe("Metadata of the tool call that instantiated this App."),theme:su.optional().describe("Current color theme preference."),styles:fu.optional().describe("Style configuration for theming the app."),displayMode:be.optional().describe("How the UI is currently displayed."),availableDisplayModes:_(be).optional().describe("Display modes the host supports."),containerDimensions:x([l({height:k().describe("Fixed container height in pixels.")}),l({maxHeight:x([k(),ot()]).optional().describe("Maximum container height in pixels.")})]).and(x([l({width:k().describe("Fixed container width in pixels.")}),l({maxWidth:x([k(),ot()]).optional().describe("Maximum container width in pixels.")})])).optional().describe(`Container dimensions. Represents the dimensions of the iframe or other
|
|
70
|
+
container holding the app. Specify either width or maxWidth, and either height or maxHeight.`),locale:c().optional().describe("User's language and region preference in BCP 47 format."),timeZone:c().optional().describe("User's timezone in IANA format."),userAgent:c().optional().describe("Host application identifier."),platform:x([a("web"),a("desktop"),a("mobile")]).optional().describe("Platform type for responsive design decisions."),deviceCapabilities:l({touch:E().optional().describe("Whether the device supports touch input."),hover:E().optional().describe("Whether the device supports hover interactions.")}).optional().describe("Device input capabilities."),safeAreaInsets:l({top:k().describe("Top safe area inset in pixels."),right:k().describe("Right safe area inset in pixels."),bottom:k().describe("Bottom safe area inset in pixels."),left:k().describe("Left safe area inset in pixels.")}).optional().describe("Mobile safe area boundaries in pixels.")}).passthrough(),ku=l({method:a("ui/notifications/host-context-changed"),params:an.describe("Partial context update containing only changed fields.")});l({method:a("ui/update-model-context"),params:l({content:_(Ee).optional().describe("Context content blocks (text, image, etc.)."),structuredContent:I(c(),$().describe("Structured content for machine-readable context data.")).optional().describe("Structured content for machine-readable context data.")})});l({method:a("ui/initialize"),params:l({appInfo:Je.describe("App identification (name and version)."),appCapabilities:_u.describe("Features and capabilities this app provides."),protocolVersion:c().describe("Protocol version this app supports.")})});var xu=l({protocolVersion:c().describe('Negotiated protocol version string (e.g., "2025-11-21").'),hostInfo:Je.describe("Host application identification and version."),hostCapabilities:vu.describe("Features and capabilities provided by the host."),hostContext:an.describe("Rich context about the host environment.")}).passthrough();function Su(e,t=document.documentElement){for(let[o,n]of Object.entries(e))n!==void 0&&t.style.setProperty(o,n)}function Tu(e){if(document.getElementById("__mcp-host-fonts"))return;let t=document.createElement("style");t.id="__mcp-host-fonts",t.textContent=e,document.head.appendChild(t)}class zu extends ou{_appInfo;_capabilities;options;_hostCapabilities;_hostInfo;_hostContext;constructor(t,o={},n={autoResize:!0}){super(n),this._appInfo=t,this._capabilities=o,this.options=n,this.setRequestHandler(Ge,r=>(console.log("Received ping:",r.params),{})),this.onhostcontextchanged=()=>{}}getHostCapabilities(){return this._hostCapabilities}getHostVersion(){return this._hostInfo}getHostContext(){return this._hostContext}set ontoolinput(t){this.setNotificationHandler(du,o=>t(o.params))}set ontoolinputpartial(t){this.setNotificationHandler(pu,o=>t(o.params))}set ontoolresult(t){this.setNotificationHandler(wu,o=>t(o.params))}set ontoolcancelled(t){this.setNotificationHandler(hu,o=>t(o.params))}set onhostcontextchanged(t){this.setNotificationHandler(ku,o=>{this._hostContext={...this._hostContext,...o.params},t(o.params)})}set onteardown(t){this.setRequestHandler(gu,(o,n)=>t(o.params,n))}set oncalltool(t){this.setRequestHandler(nn,(o,n)=>t(o.params,n))}set onlisttools(t){this.setRequestHandler(on,(o,n)=>t(o.params,n))}assertCapabilityForMethod(t){}assertRequestHandlerCapability(t){switch(t){case"tools/call":case"tools/list":if(!this._capabilities.tools)throw Error(`Client does not support tool capability (required for ${t})`);return;case"ping":case"ui/resource-teardown":return;default:throw Error(`No handler for method ${t} registered`)}}assertNotificationCapability(t){}assertTaskCapability(t){throw Error("Tasks are not supported in MCP Apps")}assertTaskHandlerCapability(t){throw Error("Task handlers are not supported in MCP Apps")}async callServerTool(t,o){if(typeof t=="string")throw Error(`callServerTool() expects an object as its first argument, but received a string ("${t}"). Did you mean: callServerTool({ name: "${t}", arguments: { ... } })?`);return await this.request({method:"tools/call",params:t},Ke,o)}async readServerResource(t,o){return await this.request({method:"resources/read",params:t},Xo,o)}async listServerResources(t,o){return await this.request({method:"resources/list",params:t},Yo,o)}sendMessage(t,o){return this.request({method:"ui/message",params:t},lu,o)}sendLog(t){return this.notification({method:"notifications/message",params:t})}updateModelContext(t,o){return this.request({method:"ui/update-model-context",params:t},bt,o)}openLink(t,o){return this.request({method:"ui/open-link",params:t},cu,o)}sendOpenLink=this.openLink;downloadFile(t,o){return this.request({method:"ui/download-file",params:t},uu,o)}requestTeardown(t={}){return this.notification({method:"ui/notifications/request-teardown",params:t})}requestDisplayMode(t,o){return this.request({method:"ui/request-display-mode",params:t},bu,o)}sendSizeChanged(t){return this.notification({method:"ui/notifications/size-changed",params:t})}setupSizeChangedNotifications(){let t=!1,o=0,n=0,r=()=>{t||(t=!0,requestAnimationFrame(()=>{t=!1;let i=document.documentElement,u=i.style.width,p=i.style.height;i.style.width="fit-content",i.style.height="max-content";let m=i.getBoundingClientRect();i.style.width=u,i.style.height=p;let f=window.innerWidth-i.clientWidth,h=Math.ceil(m.width+f),v=Math.ceil(m.height);(h!==o||v!==n)&&(o=h,n=v,this.sendSizeChanged({width:h,height:v}))}))};r();let s=new ResizeObserver(r);return s.observe(document.documentElement),s.observe(document.body),()=>s.disconnect()}async connect(t=new sn(window.parent,window.parent),o){if(this.transport)throw Error("App is already connected. Call close() before connecting again.");await super.connect(t);try{let n=await this.request({method:"ui/initialize",params:{appCapabilities:this._capabilities,appInfo:this._appInfo,protocolVersion:nu}},xu,o);if(n===void 0)throw Error(`Server sent invalid initialize result: ${n}`);this._hostCapabilities=n.hostCapabilities,this._hostInfo=n.hostInfo,this._hostContext=n.hostContext,await this.notification({method:"ui/notifications/initialized"}),this.options?.autoResize&&this.setupSizeChangedNotifications()}catch(n){throw this.close(),n}}}async function Ru(e){const t=new zu({name:e.name,version:e.version});return t.ontoolresult=o=>{try{const n=o.structuredContent;if(n&&typeof n=="object"&&n.status==="success")e.onData(n.data);else if(n&&typeof n=="object"&&n.status==="error"){const r=n.message;Xe(r||"Unknown error"),e.onError?.(r||"Unknown error")}else{const r=o.content?.find(s=>s.type==="text");if(r&&"text"in r){const s=JSON.parse(r.text);s.status==="success"?e.onData(s.data):Xe(s.message||"Unknown error")}}}catch(n){const r=n instanceof Error?n.message:String(n);Xe(`Failed to parse result: ${r}`),e.onError?.(r)}},t.onhostcontextchanged=o=>{if(o.styles?.variables&&Su(o.styles.variables),o.styles?.css?.fonts&&Tu(o.styles.css.fonts),o.safeAreaInsets){const{top:n,right:r,bottom:s,left:i}=o.safeAreaInsets;document.body.style.padding=`${n}px ${r}px ${s}px ${i}px`}},t.onteardown=async()=>({}),await t.connect(new sn),t}function Xe(e){const t=document.querySelector(".atoms-error");t&&t.remove();const o=document.createElement("div");o.className="atoms-error",o.textContent=e,document.body.prepend(o)}async function Iu(e,t,o){const r=(await e.callServerTool({name:t,arguments:o})).content?.find(s=>s.type==="text");if(r&&"text"in r){const s=JSON.parse(r.text);if(s.status==="success")return s.data;throw new Error(s.message||"Tool call failed")}throw new Error("No text content in tool response")}const cn=document.createElement("style");cn.textContent=`
|
|
71
71
|
#graph-canvas {
|
|
72
72
|
display: block;
|
|
73
73
|
width: 100%;
|
|
@@ -176,33 +176,37 @@ container holding the app. Specify either width or maxWidth, and either height o
|
|
|
176
176
|
height: 12px;
|
|
177
177
|
flex-shrink: 0;
|
|
178
178
|
}
|
|
179
|
-
`;document.head.appendChild(
|
|
179
|
+
`;document.head.appendChild(cn);const H=document.getElementById("graph-canvas"),fe=document.getElementById("tooltip"),Oe=document.getElementById("loading"),Ot=document.getElementById("stats");let ee=[],Ae=[],ye=0,we=0,Q=1,At=!1,un=0,ln=0,st=null,it="",at="",X=5,ce="downstream",ue=!1,ae=null;const $u={requirement:"#a855f7","test-case":"#e4e4e7",note:"#a855f780"},uo={parent:{dash:[],color:"#888"},child:{dash:[],color:"#888"},verifies:{dash:[6,3],color:"#a855f7"},verified_by:{dash:[6,3],color:"#a855f7"},related:{dash:[2,2],color:"#666"}};function dn(e){const t=new Map,o=typeof e.root=="object"?e.root.id:e.root,n=typeof e.root=="object"?e.root.title:e.root,r=typeof e.root=="object"?e.root.type:"requirement",s=ue?e.items:e.items.filter(S=>S.type!=="test-case"),i=110,u=36,p=16,m=60,f=60,h=new Map;for(const S of s)h.has(S.depth)||h.set(S.depth,[]),h.get(S.depth).push(S);const v=Math.max(0,...Array.from(h.keys()));let b=i;for(const[,S]of h){const D=S.length*(i+p)-p;D>b&&(b=D)}const P=b/2+60;t.set(o,{id:o,title:n,type:r,relationship:"root",depth:0,x:P,y:f+u/2,vx:0,vy:0,isRoot:!0});for(let S=1;S<=v;S++){const D=h.get(S)??[],w=D.length*(i+p)-p,y=P-w/2+i/2,z=f+u/2+S*(u+m);D.forEach((F,Y)=>{t.set(F.id,{id:F.id,title:F.title,type:F.type,relationship:F.relationship,depth:F.depth,x:y+Y*(i+p),y:z,vx:0,vy:0,isRoot:!1})})}ee=Array.from(t.values()),Ae=[];for(const S of s)S.depth===1&&Ae.push({source:o,target:S.id,type:S.relationship});const A=new Map;A.set(0,[o]);for(const S of s)A.has(S.depth)||A.set(S.depth,[]),A.get(S.depth).push(S.id);for(const S of s){if(S.depth<=1)continue;const D=A.get(S.depth-1)??[];if(D.length>0){const w=t.get(S.id);if(!w)continue;let y=D[0],z=1/0;for(const F of D){const Y=t.get(F);if(!Y)continue;const he=Math.abs(Y.x-w.x);he<z&&(z=he,y=F)}Ae.push({source:y,target:S.id,type:S.relationship})}}}function ct(){if(ee.length===0)return;const e=window.devicePixelRatio||1,t=60,o=22;let n=1/0,r=1/0,s=-1/0,i=-1/0;for(const P of ee)n=Math.min(n,P.x-t),r=Math.min(r,P.y-o),s=Math.max(s,P.x+t),i=Math.max(i,P.y+o);const u=s-n,p=i-r;if(u===0||p===0)return;const m=H.width/e,f=H.height/e,h=24;Q=Math.min((m-h*2)/u,(f-h*2)/p);const v=(n+s)/2,b=(r+i)/2;ye=m/2-v*Q,we=f/2-b*Q}function de(){const e=H.getContext("2d"),t=window.devicePixelRatio||1;e.clearRect(0,0,H.width,H.height),e.save(),e.scale(t,t),e.translate(ye,we),e.scale(Q,Q);const o=new Map(ee.map(n=>[n.id,n]));for(const n of Ae){const r=o.get(n.source),s=o.get(n.target);if(!r||!s)continue;const i=uo[n.type]??uo.related;e.beginPath(),e.strokeStyle=i.color,e.lineWidth=1,e.setLineDash(i.dash);const u=r.y+18,p=s.y-18,m=(u+p)/2;e.moveTo(r.x,u),e.lineTo(r.x,m),e.lineTo(s.x,m),e.lineTo(s.x,p),e.stroke(),e.setLineDash([]);const f=6;e.beginPath(),e.moveTo(s.x,p),e.lineTo(s.x-f*.5,p-f),e.lineTo(s.x+f*.5,p-f),e.closePath(),e.fillStyle=i.color,e.fill()}for(const n of ee){const r=$u[n.type]??"#888",s=100,i=36;if(e.fillStyle="#1a1a1a",e.strokeStyle=r,e.lineWidth=n.isRoot?3:1.5,n.type==="requirement")e.beginPath(),e.rect(n.x-s/2,n.y-i/2,s,i),e.fill(),e.stroke();else if(n.type==="test-case")e.beginPath(),e.rect(n.x-s/2,n.y-i/2,s,i),e.fill(),e.stroke();else{const p=s/2,m=i/2;e.beginPath(),e.moveTo(n.x,n.y-m),e.lineTo(n.x+p,n.y),e.lineTo(n.x,n.y+m),e.lineTo(n.x-p,n.y),e.closePath(),e.fill(),e.stroke()}n.isRoot&&(e.shadowColor="#a855f7",e.shadowBlur=12,e.strokeStyle="#a855f7",e.lineWidth=2,e.stroke(),e.shadowBlur=0),e.fillStyle="#e0e0e0",e.font=`500 11px ${getComputedStyle(document.body).getPropertyValue("--font-main").trim()||"'IBM Plex Sans', sans-serif"}`,e.textAlign="center",e.textBaseline="middle";const u=n.id.length>14?n.id.substring(0,12)+"...":n.id;e.fillText(u,n.x,n.y)}e.restore()}function Dt(){const e=window.devicePixelRatio||1,t=H.getBoundingClientRect();t.width===0||t.height===0||(H.width=t.width*e,H.height=t.height*e,ee.length>0&&de())}H.addEventListener("mousedown",e=>{At=!0,un=e.clientX-ye,ln=e.clientY-we});H.addEventListener("mousemove",e=>{if(At){ye=e.clientX-un,we=e.clientY-ln,de();return}const t=H.getBoundingClientRect(),o=(e.clientX-t.left-ye)/Q,n=(e.clientY-t.top-we)/Q;let r=null;for(let s=ee.length-1;s>=0;s--){const i=ee[s];if(Math.abs(o-i.x)<55&&Math.abs(n-i.y)<18){r=i;break}}r?(fe.style.display="block",fe.style.left=`${e.clientX-t.left+12}px`,fe.style.top=`${e.clientY-t.top-10}px`,fe.innerHTML=`
|
|
180
180
|
<div class="tt-id">${r.id}</div>
|
|
181
181
|
<div class="tt-title">${r.title}</div>
|
|
182
182
|
<div class="tt-meta">${r.type} · ${r.relationship}${r.isRoot?" (root)":""}</div>
|
|
183
|
-
`):
|
|
183
|
+
`):fe.style.display="none"});H.addEventListener("mouseup",()=>{At=!1});H.addEventListener("wheel",e=>{e.preventDefault(),Q*=e.deltaY>0?.95:1.05,Q=Math.max(.1,Math.min(3,Q)),de()},{passive:!1});window.addEventListener("resize",Dt);let lo=window.devicePixelRatio||1;window.matchMedia(`(resolution: ${lo}dppx)`).addEventListener("change",()=>{lo=window.devicePixelRatio||1,Dt()});function Pu(){const e=document.getElementById("toolbar");e.innerHTML=`
|
|
184
184
|
<span class="toolbar-label">Root:</span>
|
|
185
185
|
<span class="toolbar-value" id="root-id"></span>
|
|
186
186
|
<span class="toolbar-label">Direction:</span>
|
|
187
187
|
<select class="trace-select" id="direction-select">
|
|
188
|
-
<option value="downstream"${
|
|
189
|
-
<option value="upstream"${
|
|
190
|
-
<option value="both"${
|
|
188
|
+
<option value="downstream"${ce==="downstream"?" selected":""}>Downstream</option>
|
|
189
|
+
<option value="upstream"${ce==="upstream"?" selected":""}>Upstream</option>
|
|
190
|
+
<option value="both"${ce==="both"?" selected":""}>Both</option>
|
|
191
191
|
</select>
|
|
192
192
|
<span class="toolbar-label">Depth:</span>
|
|
193
193
|
<span class="trace-stepper">
|
|
194
194
|
<button class="trace-stepper-btn" id="depth-down">-</button>
|
|
195
|
-
<span class="trace-stepper-value" id="depth-value">${
|
|
195
|
+
<span class="trace-stepper-value" id="depth-value">${X}</span>
|
|
196
196
|
<button class="trace-stepper-btn" id="depth-up">+</button>
|
|
197
197
|
</span>
|
|
198
198
|
<button class="trace-stepper-btn" id="fit-btn" title="Fit to view" style="margin-left:8px;padding:2px 10px">⤢</button>
|
|
199
|
-
|
|
199
|
+
<label style="margin-left:12px;display:flex;align-items:center;gap:4px;font-size:11px;color:var(--text-secondary);cursor:pointer;user-select:none">
|
|
200
|
+
<input type="checkbox" id="show-tests" ${ue?"checked":""} style="cursor:pointer;accent-color:#a855f7" />
|
|
201
|
+
Show Tests
|
|
202
|
+
</label>
|
|
203
|
+
`,document.getElementById("direction-select").addEventListener("change",t=>{ce=t.target.value,et()}),document.getElementById("depth-down").addEventListener("click",()=>{X>1&&(X--,document.getElementById("depth-value").textContent=String(X),et())}),document.getElementById("depth-up").addEventListener("click",()=>{X<10&&(X++,document.getElementById("depth-value").textContent=String(X),et())}),document.getElementById("fit-btn").addEventListener("click",()=>{ct(),de()}),document.getElementById("show-tests").addEventListener("change",t=>{if(ue=t.target.checked,ae){dn(ae),ct(),de();const o=ee.length,n=typeof ae.root=="object"?ae.root.id:ae.root;Ot.textContent=`${o} items traced from ${n}${ue?"":" (tests hidden)"}`}})}async function et(){if(!(!st||!it||!at)){H.style.display="none",Oe.style.display="",Oe.textContent="Reloading...";try{const e=await Iu(st,"atoms_trace",{project_id:it,item_id:at,direction:ce,depth:X});pn(e)}catch(e){Oe.style.display="none",H.style.display="block",Ot.textContent=`Error: ${e instanceof Error?e.message:String(e)}`}}}function pn(e){Oe.style.display="none",H.style.display="block",ae=e;const t=typeof e.root=="object"?e.root.id:e.root,o=typeof e.root=="object"?`${e.root.id} — ${e.root.title}`:e.root;at=t,ce=e.direction,X=e.depth_limit;const n=e.items.filter(s=>s.type==="test-case").length,r=ue?e.total_count:e.total_count-n;Ot.textContent=`${r} items traced from ${t}${!ue&&n>0?` (${n} tests hidden)`:""}`,document.getElementById("root-id").textContent=o,Dt(),dn(e),ct(),de()}const Lt=document.createElement("div");Lt.className="legend";Lt.innerHTML=`
|
|
200
204
|
<div class="legend-item"><div class="legend-shape" style="background:#a855f7"></div>Requirement</div>
|
|
201
205
|
<div class="legend-item"><div class="legend-shape" style="background:#e4e4e7"></div>Test Case</div>
|
|
202
206
|
<div class="legend-item"><div class="legend-shape" style="background:rgba(168,85,247,0.6);transform:rotate(45deg);width:10px;height:10px"></div>Note</div>
|
|
203
207
|
<div class="legend-item"><svg width="20" height="10"><line x1="0" y1="5" x2="20" y2="5" stroke="#888" stroke-width="1.5"/></svg>Parent/Child</div>
|
|
204
208
|
<div class="legend-item"><svg width="20" height="10"><line x1="0" y1="5" x2="20" y2="5" stroke="#a855f7" stroke-width="1.5" stroke-dasharray="6,3"/></svg>Verifies</div>
|
|
205
|
-
`;document.getElementById("app").appendChild(
|
|
209
|
+
`;document.getElementById("app").appendChild(Lt);Ru({name:"ATOMS Trace Graph",version:"1.0.0",onData:e=>{const t=e;t.project_id&&(it=t.project_id),Pu(),pn(t)}}).then(e=>{st=e});</script>
|
|
206
210
|
<style rel="stylesheet" crossorigin>@import"https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@400;500;600;700&family=IBM+Plex+Mono:wght@400;500&display=swap";:root{--atoms-purple: #a855f7;--atoms-purple-light: #c084fc;--atoms-purple-hover: #b975f9;--atoms-green: #22c55e;--atoms-green-light: #4ade80;--atoms-red: #ef4444;--atoms-red-light: #f87171;--atoms-amber: #f59e0b;--atoms-blue: #58a6ff;--tc-color: #e4e4e7;--note-color: rgba(168, 85, 247, .6);--bg-primary: #0c0c0c;--bg-secondary: #121212;--bg-tertiary: #181818;--text-primary: #fafafa;--text-secondary: #a0a0a0;--text-muted: #606060;--border-color: #252525;--font-main: "IBM Plex Sans", sans-serif;--font-code: "IBM Plex Mono", monospace;color-scheme:dark}*{margin:0;padding:0;box-sizing:border-box}body{font-family:var(--font-main);background:var(--bg-primary);color:var(--text-primary);line-height:1.5;-webkit-font-smoothing:antialiased}.atoms-card{background:var(--bg-secondary);border:1px solid var(--border-color);border-radius:0;padding:16px}.atoms-header{display:flex;align-items:center;gap:10px;padding:12px 16px;border-bottom:1px solid var(--border-color);background:var(--bg-secondary)}.atoms-header .logo{width:20px;height:20px}.atoms-header .title{font-size:14px;font-weight:600;color:var(--text-primary)}.atoms-header .subtitle{font-size:12px;color:var(--text-muted);margin-left:auto}.atoms-btn{display:inline-flex;align-items:center;gap:6px;padding:6px 12px;font-size:12px;font-weight:500;font-family:var(--font-main);border:1px solid var(--border-color);border-radius:0;background:var(--bg-secondary);color:var(--text-primary);cursor:pointer;transition:background .1s ease}.atoms-btn:hover{background:var(--bg-tertiary)}.atoms-btn-primary{background:var(--atoms-purple);color:#fff;border-color:var(--atoms-purple)}.atoms-btn-primary:hover{background:var(--atoms-purple-hover)}.atoms-watermark{position:fixed;bottom:8px;right:12px;display:flex;align-items:center;gap:6px;font-size:10px;color:var(--text-muted);opacity:.5;font-family:var(--font-main);pointer-events:none}.atoms-watermark img{width:14px;height:14px;opacity:.6}.atoms-loading{display:flex;align-items:center;justify-content:center;min-height:200px;color:var(--text-muted);font-size:13px}.atoms-loading:before{content:"";width:16px;height:16px;border:2px solid var(--border-color);border-top-color:var(--atoms-purple);border-radius:50%;margin-right:10px;animation:spin .6s linear infinite}@keyframes spin{to{transform:rotate(360deg)}}.atoms-error{padding:16px;background:color-mix(in srgb,var(--atoms-red) 10%,var(--bg-primary));border:1px solid var(--atoms-red);color:var(--text-primary);font-size:13px}.atoms-metrics{display:grid;grid-template-columns:repeat(auto-fit,minmax(120px,1fr));gap:12px;padding:16px}.atoms-metric{background:var(--bg-secondary);border:1px solid var(--border-color);padding:12px;text-align:center}.atoms-metric .value{font-size:24px;font-weight:700;color:var(--atoms-purple);font-variant-numeric:tabular-nums}.atoms-metric .label{font-size:11px;font-weight:500;color:var(--text-secondary);text-transform:uppercase;letter-spacing:.5px;margin-top:4px}.atoms-toolbar{display:flex;align-items:center;gap:8px;padding:8px 16px;border-bottom:1px solid var(--border-color);background:var(--bg-secondary);flex-wrap:wrap}</style>
|
|
207
211
|
</head>
|
|
208
212
|
<body>
|