@sequenzy/mcp 0.0.44 → 0.0.45

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/index.js CHANGED
@@ -26,7 +26,7 @@ var S5=Object.create;var{getPrototypeOf:R5,defineProperty:F6,getOwnPropertyNames
26
26
  newResult[${T}] = ${x}.value;
27
27
  }
28
28
 
29
- `)}L.write("payload.value = newResult;"),L.write("return payload;");let S=L.compile();return(E,x)=>S(D,E,x)},$,J=F1,z=!c4.jitless,A=z&&N6.value,U=Y.catchall,K;Q._zod.parse=(D,L)=>{K??(K=W.value);let q=D.value;if(!J(q))return D.issues.push({expected:"object",code:"invalid_type",input:q,inst:Q}),D;if(z&&A&&L?.async===!1&&L.jitless!==!0){if(!$)$=G(Y.shape);if(D=$(D,L),!U)return D;return y8([],q,D,L,K,Q)}return X(D,L)}});function sX(Q,Y,X,W){for(let $ of Q)if($.issues.length===0)return Y.value=$.value,Y;let G=Q.filter(($)=>!X1($));if(G.length===1)return Y.value=G[0].value,G[0];return Y.issues.push({code:"invalid_union",input:Y.value,inst:X,errors:Q.map(($)=>$.issues.map((J)=>T0(J,W,w0())))}),Y}var k6=F("$ZodUnion",(Q,Y)=>{i.init(Q,Y),m(Q._zod,"optin",()=>Y.options.some((G)=>G._zod.optin==="optional")?"optional":void 0),m(Q._zod,"optout",()=>Y.options.some((G)=>G._zod.optout==="optional")?"optional":void 0),m(Q._zod,"values",()=>{if(Y.options.every((G)=>G._zod.values))return new Set(Y.options.flatMap((G)=>Array.from(G._zod.values)));return}),m(Q._zod,"pattern",()=>{if(Y.options.every((G)=>G._zod.pattern)){let G=Y.options.map(($)=>$._zod.pattern);return new RegExp(`^(${G.map(($)=>d1($.source)).join("|")})$`)}return});let X=Y.options.length===1,W=Y.options[0]._zod.run;Q._zod.parse=(G,$)=>{if(X)return W(G,$);let J=!1,z=[];for(let H of Y.options){let A=H._zod.run({value:G.value,issues:[]},$);if(A instanceof Promise)z.push(A),J=!0;else{if(A.issues.length===0)return A;z.push(A)}}if(!J)return sX(z,G,Q,$);return Promise.all(z).then((H)=>{return sX(H,G,Q,$)})}}),u8=F("$ZodDiscriminatedUnion",(Q,Y)=>{k6.init(Q,Y);let X=Q._zod.parse;m(Q._zod,"propValues",()=>{let G={};for(let $ of Y.options){let J=$._zod.propValues;if(!J||Object.keys(J).length===0)throw Error(`Invalid discriminated union option at index "${Y.options.indexOf($)}"`);for(let[z,H]of Object.entries(J)){if(!G[z])G[z]=new Set;for(let A of H)G[z].add(A)}}return G});let W=I1(()=>{let G=Y.options,$=new Map;for(let J of G){let z=J._zod.propValues?.[Y.discriminator];if(!z||z.size===0)throw Error(`Invalid discriminated union option at index "${Y.options.indexOf(J)}"`);for(let H of z){if($.has(H))throw Error(`Duplicate discriminator value "${String(H)}"`);$.set(H,J)}}return $});Q._zod.parse=(G,$)=>{let J=G.value;if(!F1(J))return G.issues.push({code:"invalid_type",expected:"object",input:J,inst:Q}),G;let z=W.value.get(J?.[Y.discriminator]);if(z)return z._zod.run(G,$);if(Y.unionFallback)return X(G,$);return G.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:Y.discriminator,input:J,path:[Y.discriminator],inst:Q}),G}}),h8=F("$ZodIntersection",(Q,Y)=>{i.init(Q,Y),Q._zod.parse=(X,W)=>{let G=X.value,$=Y.left._zod.run({value:G,issues:[]},W),J=Y.right._zod.run({value:G,issues:[]},W);if($ instanceof Promise||J instanceof Promise)return Promise.all([$,J]).then(([H,A])=>{return eX(X,H,A)});return eX(X,$,J)}});function R6(Q,Y){if(Q===Y)return{valid:!0,data:Q};if(Q instanceof Date&&Y instanceof Date&&+Q===+Y)return{valid:!0,data:Q};if(Y1(Q)&&Y1(Y)){let X=Object.keys(Y),W=Object.keys(Q).filter(($)=>X.indexOf($)!==-1),G={...Q,...Y};for(let $ of W){let J=R6(Q[$],Y[$]);if(!J.valid)return{valid:!1,mergeErrorPath:[$,...J.mergeErrorPath]};G[$]=J.data}return{valid:!0,data:G}}if(Array.isArray(Q)&&Array.isArray(Y)){if(Q.length!==Y.length)return{valid:!1,mergeErrorPath:[]};let X=[];for(let W=0;W<Q.length;W++){let G=Q[W],$=Y[W],J=R6(G,$);if(!J.valid)return{valid:!1,mergeErrorPath:[W,...J.mergeErrorPath]};X.push(J.data)}return{valid:!0,data:X}}return{valid:!1,mergeErrorPath:[]}}function eX(Q,Y,X){if(Y.issues.length)Q.issues.push(...Y.issues);if(X.issues.length)Q.issues.push(...X.issues);if(X1(Q))return Q;let W=R6(Y.value,X.value);if(!W.valid)throw Error(`Unmergable intersection. Error path: ${JSON.stringify(W.mergeErrorPath)}`);return Q.value=W.data,Q}var f8=F("$ZodRecord",(Q,Y)=>{i.init(Q,Y),Q._zod.parse=(X,W)=>{let G=X.value;if(!Y1(G))return X.issues.push({expected:"record",code:"invalid_type",input:G,inst:Q}),X;let $=[];if(Y.keyType._zod.values){let J=Y.keyType._zod.values;X.value={};for(let H of J)if(typeof H==="string"||typeof H==="number"||typeof H==="symbol"){let A=Y.valueType._zod.run({value:G[H],issues:[]},W);if(A instanceof Promise)$.push(A.then((U)=>{if(U.issues.length)X.issues.push(...c0(H,U.issues));X.value[H]=U.value}));else{if(A.issues.length)X.issues.push(...c0(H,A.issues));X.value[H]=A.value}}let z;for(let H in G)if(!J.has(H))z=z??[],z.push(H);if(z&&z.length>0)X.issues.push({code:"unrecognized_keys",input:G,inst:Q,keys:z})}else{X.value={};for(let J of Reflect.ownKeys(G)){if(J==="__proto__")continue;let z=Y.keyType._zod.run({value:J,issues:[]},W);if(z instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(z.issues.length){X.issues.push({code:"invalid_key",origin:"record",issues:z.issues.map((A)=>T0(A,W,w0())),input:J,path:[J],inst:Q}),X.value[z.value]=z.value;continue}let H=Y.valueType._zod.run({value:G[J],issues:[]},W);if(H instanceof Promise)$.push(H.then((A)=>{if(A.issues.length)X.issues.push(...c0(J,A.issues));X.value[z.value]=A.value}));else{if(H.issues.length)X.issues.push(...c0(J,H.issues));X.value[z.value]=H.value}}}if($.length)return Promise.all($).then(()=>X);return X}});var l8=F("$ZodEnum",(Q,Y)=>{i.init(Q,Y);let X=M6(Y.entries),W=new Set(X);Q._zod.values=W,Q._zod.pattern=new RegExp(`^(${X.filter((G)=>Z6.has(typeof G)).map((G)=>typeof G==="string"?m0(G):G.toString()).join("|")})$`),Q._zod.parse=(G,$)=>{let J=G.value;if(W.has(J))return G;return G.issues.push({code:"invalid_value",values:X,input:J,inst:Q}),G}}),m8=F("$ZodLiteral",(Q,Y)=>{if(i.init(Q,Y),Y.values.length===0)throw Error("Cannot create literal schema with no valid values");Q._zod.values=new Set(Y.values),Q._zod.pattern=new RegExp(`^(${Y.values.map((X)=>typeof X==="string"?m0(X):X?m0(X.toString()):String(X)).join("|")})$`),Q._zod.parse=(X,W)=>{let G=X.value;if(Q._zod.values.has(G))return X;return X.issues.push({code:"invalid_value",values:Y.values,input:G,inst:Q}),X}});var c8=F("$ZodTransform",(Q,Y)=>{i.init(Q,Y),Q._zod.parse=(X,W)=>{if(W.direction==="backward")throw new i1(Q.constructor.name);let G=Y.transform(X.value,X);if(W.async)return(G instanceof Promise?G:Promise.resolve(G)).then((J)=>{return X.value=J,X});if(G instanceof Promise)throw new l0;return X.value=G,X}});function Q8(Q,Y){if(Q.issues.length&&Y===void 0)return{issues:[],value:void 0};return Q}var p8=F("$ZodOptional",(Q,Y)=>{i.init(Q,Y),Q._zod.optin="optional",Q._zod.optout="optional",m(Q._zod,"values",()=>{return Y.innerType._zod.values?new Set([...Y.innerType._zod.values,void 0]):void 0}),m(Q._zod,"pattern",()=>{let X=Y.innerType._zod.pattern;return X?new RegExp(`^(${d1(X.source)})?$`):void 0}),Q._zod.parse=(X,W)=>{if(Y.innerType._zod.optin==="optional"){let G=Y.innerType._zod.run(X,W);if(G instanceof Promise)return G.then(($)=>Q8($,X.value));return Q8(G,X.value)}if(X.value===void 0)return X;return Y.innerType._zod.run(X,W)}}),i8=F("$ZodNullable",(Q,Y)=>{i.init(Q,Y),m(Q._zod,"optin",()=>Y.innerType._zod.optin),m(Q._zod,"optout",()=>Y.innerType._zod.optout),m(Q._zod,"pattern",()=>{let X=Y.innerType._zod.pattern;return X?new RegExp(`^(${d1(X.source)}|null)$`):void 0}),m(Q._zod,"values",()=>{return Y.innerType._zod.values?new Set([...Y.innerType._zod.values,null]):void 0}),Q._zod.parse=(X,W)=>{if(X.value===null)return X;return Y.innerType._zod.run(X,W)}}),r8=F("$ZodDefault",(Q,Y)=>{i.init(Q,Y),Q._zod.optin="optional",m(Q._zod,"values",()=>Y.innerType._zod.values),Q._zod.parse=(X,W)=>{if(W.direction==="backward")return Y.innerType._zod.run(X,W);if(X.value===void 0)return X.value=Y.defaultValue,X;let G=Y.innerType._zod.run(X,W);if(G instanceof Promise)return G.then(($)=>Y8($,Y));return Y8(G,Y)}});function Y8(Q,Y){if(Q.value===void 0)Q.value=Y.defaultValue;return Q}var n8=F("$ZodPrefault",(Q,Y)=>{i.init(Q,Y),Q._zod.optin="optional",m(Q._zod,"values",()=>Y.innerType._zod.values),Q._zod.parse=(X,W)=>{if(W.direction==="backward")return Y.innerType._zod.run(X,W);if(X.value===void 0)X.value=Y.defaultValue;return Y.innerType._zod.run(X,W)}}),d8=F("$ZodNonOptional",(Q,Y)=>{i.init(Q,Y),m(Q._zod,"values",()=>{let X=Y.innerType._zod.values;return X?new Set([...X].filter((W)=>W!==void 0)):void 0}),Q._zod.parse=(X,W)=>{let G=Y.innerType._zod.run(X,W);if(G instanceof Promise)return G.then(($)=>X8($,Q));return X8(G,Q)}});function X8(Q,Y){if(!Q.issues.length&&Q.value===void 0)Q.issues.push({code:"invalid_type",expected:"nonoptional",input:Q.value,inst:Y});return Q}var o8=F("$ZodCatch",(Q,Y)=>{i.init(Q,Y),m(Q._zod,"optin",()=>Y.innerType._zod.optin),m(Q._zod,"optout",()=>Y.innerType._zod.optout),m(Q._zod,"values",()=>Y.innerType._zod.values),Q._zod.parse=(X,W)=>{if(W.direction==="backward")return Y.innerType._zod.run(X,W);let G=Y.innerType._zod.run(X,W);if(G instanceof Promise)return G.then(($)=>{if(X.value=$.value,$.issues.length)X.value=Y.catchValue({...X,error:{issues:$.issues.map((J)=>T0(J,W,w0()))},input:X.value}),X.issues=[];return X});if(X.value=G.value,G.issues.length)X.value=Y.catchValue({...X,error:{issues:G.issues.map(($)=>T0($,W,w0()))},input:X.value}),X.issues=[];return X}});var t8=F("$ZodPipe",(Q,Y)=>{i.init(Q,Y),m(Q._zod,"values",()=>Y.in._zod.values),m(Q._zod,"optin",()=>Y.in._zod.optin),m(Q._zod,"optout",()=>Y.out._zod.optout),m(Q._zod,"propValues",()=>Y.in._zod.propValues),Q._zod.parse=(X,W)=>{if(W.direction==="backward"){let $=Y.out._zod.run(X,W);if($ instanceof Promise)return $.then((J)=>e4(J,Y.in,W));return e4($,Y.in,W)}let G=Y.in._zod.run(X,W);if(G instanceof Promise)return G.then(($)=>e4($,Y.out,W));return e4(G,Y.out,W)}});function e4(Q,Y,X){if(Q.issues.length)return Q.aborted=!0,Q;return Y._zod.run({value:Q.value,issues:Q.issues},X)}var a8=F("$ZodReadonly",(Q,Y)=>{i.init(Q,Y),m(Q._zod,"propValues",()=>Y.innerType._zod.propValues),m(Q._zod,"values",()=>Y.innerType._zod.values),m(Q._zod,"optin",()=>Y.innerType._zod.optin),m(Q._zod,"optout",()=>Y.innerType._zod.optout),Q._zod.parse=(X,W)=>{if(W.direction==="backward")return Y.innerType._zod.run(X,W);let G=Y.innerType._zod.run(X,W);if(G instanceof Promise)return G.then(W8);return W8(G)}});function W8(Q){return Q.value=Object.freeze(Q.value),Q}var s8=F("$ZodCustom",(Q,Y)=>{W0.init(Q,Y),i.init(Q,Y),Q._zod.parse=(X,W)=>{return X},Q._zod.check=(X)=>{let W=X.value,G=Y.fn(W);if(G instanceof Promise)return G.then(($)=>G8($,X,W,Q));G8(G,X,W,Q);return}});function G8(Q,Y,X,W){if(!Q){let G={code:"custom",input:X,inst:W,path:[...W._zod.def.path??[]],continue:!W._zod.def.abort};if(W._zod.def.params)G.params=W._zod.def.params;Y.issues.push(j1(G))}}var wH=(Q)=>{let Y=typeof Q;switch(Y){case"number":return Number.isNaN(Q)?"NaN":"number";case"object":{if(Array.isArray(Q))return"array";if(Q===null)return"null";if(Object.getPrototypeOf(Q)!==Object.prototype&&Q.constructor)return Q.constructor.name}}return Y},bH=()=>{let Q={string:{unit:"characters",verb:"to have"},file:{unit:"bytes",verb:"to have"},array:{unit:"items",verb:"to have"},set:{unit:"items",verb:"to have"}};function Y(W){return Q[W]??null}let X={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",jwt:"JWT",template_literal:"input"};return(W)=>{switch(W.code){case"invalid_type":return`Invalid input: expected ${W.expected}, received ${wH(W.input)}`;case"invalid_value":if(W.values.length===1)return`Invalid input: expected ${n4(W.values[0])}`;return`Invalid option: expected one of ${p4(W.values,"|")}`;case"too_big":{let G=W.inclusive?"<=":"<",$=Y(W.origin);if($)return`Too big: expected ${W.origin??"value"} to have ${G}${W.maximum.toString()} ${$.unit??"elements"}`;return`Too big: expected ${W.origin??"value"} to be ${G}${W.maximum.toString()}`}case"too_small":{let G=W.inclusive?">=":">",$=Y(W.origin);if($)return`Too small: expected ${W.origin} to have ${G}${W.minimum.toString()} ${$.unit}`;return`Too small: expected ${W.origin} to be ${G}${W.minimum.toString()}`}case"invalid_format":{let G=W;if(G.format==="starts_with")return`Invalid string: must start with "${G.prefix}"`;if(G.format==="ends_with")return`Invalid string: must end with "${G.suffix}"`;if(G.format==="includes")return`Invalid string: must include "${G.includes}"`;if(G.format==="regex")return`Invalid string: must match pattern ${G.pattern}`;return`Invalid ${X[G.format]??W.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${W.divisor}`;case"unrecognized_keys":return`Unrecognized key${W.keys.length>1?"s":""}: ${p4(W.keys,", ")}`;case"invalid_key":return`Invalid key in ${W.origin}`;case"invalid_union":return"Invalid input";case"invalid_element":return`Invalid value in ${W.origin}`;default:return"Invalid input"}}};function v6(){return{localeError:bH()}}var YV=Symbol("ZodOutput"),XV=Symbol("ZodInput");class e8{constructor(){this._map=new WeakMap,this._idmap=new Map}add(Q,...Y){let X=Y[0];if(this._map.set(Q,X),X&&typeof X==="object"&&"id"in X){if(this._idmap.has(X.id))throw Error(`ID ${X.id} already exists in the registry`);this._idmap.set(X.id,Q)}return this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(Q){let Y=this._map.get(Q);if(Y&&typeof Y==="object"&&"id"in Y)this._idmap.delete(Y.id);return this._map.delete(Q),this}get(Q){let Y=Q._zod.parent;if(Y){let X={...this.get(Y)??{}};delete X.id;let W={...X,...this._map.get(Q)};return Object.keys(W).length?W:void 0}return this._map.get(Q)}has(Q){return this._map.has(Q)}}function PH(){return new e8}var Q4=PH();function QW(Q,Y){return new Q({type:"string",...j(Y)})}function YW(Q,Y){return new Q({type:"string",format:"email",check:"string_format",abort:!1,...j(Y)})}function x6(Q,Y){return new Q({type:"string",format:"guid",check:"string_format",abort:!1,...j(Y)})}function XW(Q,Y){return new Q({type:"string",format:"uuid",check:"string_format",abort:!1,...j(Y)})}function WW(Q,Y){return new Q({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...j(Y)})}function GW(Q,Y){return new Q({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...j(Y)})}function $W(Q,Y){return new Q({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...j(Y)})}function JW(Q,Y){return new Q({type:"string",format:"url",check:"string_format",abort:!1,...j(Y)})}function zW(Q,Y){return new Q({type:"string",format:"emoji",check:"string_format",abort:!1,...j(Y)})}function HW(Q,Y){return new Q({type:"string",format:"nanoid",check:"string_format",abort:!1,...j(Y)})}function AW(Q,Y){return new Q({type:"string",format:"cuid",check:"string_format",abort:!1,...j(Y)})}function UW(Q,Y){return new Q({type:"string",format:"cuid2",check:"string_format",abort:!1,...j(Y)})}function KW(Q,Y){return new Q({type:"string",format:"ulid",check:"string_format",abort:!1,...j(Y)})}function DW(Q,Y){return new Q({type:"string",format:"xid",check:"string_format",abort:!1,...j(Y)})}function BW(Q,Y){return new Q({type:"string",format:"ksuid",check:"string_format",abort:!1,...j(Y)})}function LW(Q,Y){return new Q({type:"string",format:"ipv4",check:"string_format",abort:!1,...j(Y)})}function FW(Q,Y){return new Q({type:"string",format:"ipv6",check:"string_format",abort:!1,...j(Y)})}function qW(Q,Y){return new Q({type:"string",format:"cidrv4",check:"string_format",abort:!1,...j(Y)})}function OW(Q,Y){return new Q({type:"string",format:"cidrv6",check:"string_format",abort:!1,...j(Y)})}function MW(Q,Y){return new Q({type:"string",format:"base64",check:"string_format",abort:!1,...j(Y)})}function VW(Q,Y){return new Q({type:"string",format:"base64url",check:"string_format",abort:!1,...j(Y)})}function NW(Q,Y){return new Q({type:"string",format:"e164",check:"string_format",abort:!1,...j(Y)})}function ZW(Q,Y){return new Q({type:"string",format:"jwt",check:"string_format",abort:!1,...j(Y)})}function wW(Q,Y){return new Q({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...j(Y)})}function bW(Q,Y){return new Q({type:"string",format:"date",check:"string_format",...j(Y)})}function PW(Q,Y){return new Q({type:"string",format:"time",check:"string_format",precision:null,...j(Y)})}function IW(Q,Y){return new Q({type:"string",format:"duration",check:"string_format",...j(Y)})}function jW(Q,Y){return new Q({type:"number",checks:[],...j(Y)})}function EW(Q,Y){return new Q({type:"number",check:"number_format",abort:!1,format:"safeint",...j(Y)})}function TW(Q,Y){return new Q({type:"boolean",...j(Y)})}function SW(Q,Y){return new Q({type:"null",...j(Y)})}function RW(Q){return new Q({type:"unknown"})}function CW(Q,Y){return new Q({type:"never",...j(Y)})}function XQ(Q,Y){return new E6({check:"less_than",...j(Y),value:Q,inclusive:!1})}function Y4(Q,Y){return new E6({check:"less_than",...j(Y),value:Q,inclusive:!0})}function WQ(Q,Y){return new T6({check:"greater_than",...j(Y),value:Q,inclusive:!1})}function X4(Q,Y){return new T6({check:"greater_than",...j(Y),value:Q,inclusive:!0})}function GQ(Q,Y){return new gX({check:"multiple_of",...j(Y),value:Q})}function $Q(Q,Y){return new hX({check:"max_length",...j(Y),maximum:Q})}function E1(Q,Y){return new fX({check:"min_length",...j(Y),minimum:Q})}function JQ(Q,Y){return new lX({check:"length_equals",...j(Y),length:Q})}function _6(Q,Y){return new mX({check:"string_format",format:"regex",...j(Y),pattern:Q})}function y6(Q){return new cX({check:"string_format",format:"lowercase",...j(Q)})}function g6(Q){return new pX({check:"string_format",format:"uppercase",...j(Q)})}function u6(Q,Y){return new iX({check:"string_format",format:"includes",...j(Y),includes:Q})}function h6(Q,Y){return new rX({check:"string_format",format:"starts_with",...j(Y),prefix:Q})}function f6(Q,Y){return new nX({check:"string_format",format:"ends_with",...j(Y),suffix:Q})}function q1(Q){return new dX({check:"overwrite",tx:Q})}function l6(Q){return q1((Y)=>Y.normalize(Q))}function m6(){return q1((Q)=>Q.trim())}function c6(){return q1((Q)=>Q.toLowerCase())}function p6(){return q1((Q)=>Q.toUpperCase())}function kW(Q,Y,X){return new Q({type:"array",element:Y,...j(X)})}function vW(Q,Y,X){let W=j(X);return W.abort??(W.abort=!0),new Q({type:"custom",check:"custom",fn:Y,...W})}function xW(Q,Y,X){return new Q({type:"custom",check:"custom",fn:Y,...j(X)})}function _W(Q){let Y=IH((X)=>{return X.addIssue=(W)=>{if(typeof W==="string")X.issues.push(j1(W,X.value,Y._zod.def));else{let G=W;if(G.fatal)G.continue=!1;G.code??(G.code="custom"),G.input??(G.input=X.value),G.inst??(G.inst=Y),G.continue??(G.continue=!Y._zod.def.abort),X.issues.push(j1(G))}},Q(X.value,X)});return Y}function IH(Q,Y){let X=new W0({check:"custom",...j(Y)});return X._zod.check=Q,X}function T1(Q){return!!Q._zod}function W1(Q,Y){if(T1(Q))return a1(Q,Y);return Q.safeParse(Y)}function zQ(Q){if(!Q)return;let Y;if(T1(Q))Y=Q._zod?.def?.shape;else Y=Q.shape;if(!Y)return;if(typeof Y==="function")try{return Y()}catch{return}return Y}function yW(Q){if(T1(Q)){let $=Q._zod?.def;if($){if($.value!==void 0)return $.value;if(Array.isArray($.values)&&$.values.length>0)return $.values[0]}}let X=Q._def;if(X){if(X.value!==void 0)return X.value;if(Array.isArray(X.values)&&X.values.length>0)return X.values[0]}let W=Q.value;if(W!==void 0)return W;return}var G4={};u9(G4,{time:()=>n6,duration:()=>d6,datetime:()=>i6,date:()=>r6,ZodISOTime:()=>hW,ZodISODuration:()=>fW,ZodISODateTime:()=>gW,ZodISODate:()=>uW});var gW=F("ZodISODateTime",(Q,Y)=>{q8.init(Q,Y),d.init(Q,Y)});function i6(Q){return wW(gW,Q)}var uW=F("ZodISODate",(Q,Y)=>{O8.init(Q,Y),d.init(Q,Y)});function r6(Q){return bW(uW,Q)}var hW=F("ZodISOTime",(Q,Y)=>{M8.init(Q,Y),d.init(Q,Y)});function n6(Q){return PW(hW,Q)}var fW=F("ZodISODuration",(Q,Y)=>{V8.init(Q,Y),d.init(Q,Y)});function d6(Q){return IW(fW,Q)}var lW=(Q,Y)=>{d4.init(Q,Y),Q.name="ZodError",Object.defineProperties(Q,{format:{value:(X)=>s9(Q,X)},flatten:{value:(X)=>a9(Q,X)},addIssue:{value:(X)=>{Q.issues.push(X),Q.message=JSON.stringify(Q.issues,P1,2)}},addIssues:{value:(X)=>{Q.issues.push(...X),Q.message=JSON.stringify(Q.issues,P1,2)}},isEmpty:{get(){return Q.issues.length===0}}})},lV=F("ZodError",lW),N0=F("ZodError",lW,{Parent:Error});var mW=o4(N0),cW=t4(N0),pW=t1(N0),iW=s1(N0),rW=e9(N0),nW=QX(N0),dW=YX(N0),oW=XX(N0),tW=WX(N0),aW=GX(N0),sW=$X(N0),eW=JX(N0);var s=F("ZodType",(Q,Y)=>{return i.init(Q,Y),Q.def=Y,Q.type=Y.type,Object.defineProperty(Q,"_def",{value:Y}),Q.check=(...X)=>{return Q.clone(h.mergeDefs(Y,{checks:[...Y.checks??[],...X.map((W)=>typeof W==="function"?{_zod:{check:W,def:{check:"custom"},onattach:[]}}:W)]}))},Q.clone=(X,W)=>E0(Q,X,W),Q.brand=()=>Q,Q.register=(X,W)=>{return X.add(Q,W),Q},Q.parse=(X,W)=>mW(Q,X,W,{callee:Q.parse}),Q.safeParse=(X,W)=>pW(Q,X,W),Q.parseAsync=async(X,W)=>cW(Q,X,W,{callee:Q.parseAsync}),Q.safeParseAsync=async(X,W)=>iW(Q,X,W),Q.spa=Q.safeParseAsync,Q.encode=(X,W)=>rW(Q,X,W),Q.decode=(X,W)=>nW(Q,X,W),Q.encodeAsync=async(X,W)=>dW(Q,X,W),Q.decodeAsync=async(X,W)=>oW(Q,X,W),Q.safeEncode=(X,W)=>tW(Q,X,W),Q.safeDecode=(X,W)=>aW(Q,X,W),Q.safeEncodeAsync=async(X,W)=>sW(Q,X,W),Q.safeDecodeAsync=async(X,W)=>eW(Q,X,W),Q.refine=(X,W)=>Q.check(ZA(X,W)),Q.superRefine=(X)=>Q.check(wA(X)),Q.overwrite=(X)=>Q.check(q1(X)),Q.optional=()=>a(Q),Q.nullable=()=>XG(Q),Q.nullish=()=>a(XG(Q)),Q.nonoptional=(X)=>FA(Q,X),Q.array=()=>_(Q),Q.or=(X)=>p([Q,X]),Q.and=(X)=>AQ(Q,X),Q.transform=(X)=>t6(Q,zG(X)),Q.default=(X)=>DA(Q,X),Q.prefault=(X)=>LA(Q,X),Q.catch=(X)=>OA(Q,X),Q.pipe=(X)=>t6(Q,X),Q.readonly=()=>NA(Q),Q.describe=(X)=>{let W=Q.clone();return Q4.add(W,{description:X}),W},Object.defineProperty(Q,"description",{get(){return Q4.get(Q)?.description},configurable:!0}),Q.meta=(...X)=>{if(X.length===0)return Q4.get(Q);let W=Q.clone();return Q4.add(W,X[0]),W},Q.isOptional=()=>Q.safeParse(void 0).success,Q.isNullable=()=>Q.safeParse(null).success,Q}),WG=F("_ZodString",(Q,Y)=>{YQ.init(Q,Y),s.init(Q,Y);let X=Q._zod.bag;Q.format=X.format??null,Q.minLength=X.minimum??null,Q.maxLength=X.maximum??null,Q.regex=(...W)=>Q.check(_6(...W)),Q.includes=(...W)=>Q.check(u6(...W)),Q.startsWith=(...W)=>Q.check(h6(...W)),Q.endsWith=(...W)=>Q.check(f6(...W)),Q.min=(...W)=>Q.check(E1(...W)),Q.max=(...W)=>Q.check($Q(...W)),Q.length=(...W)=>Q.check(JQ(...W)),Q.nonempty=(...W)=>Q.check(E1(1,...W)),Q.lowercase=(W)=>Q.check(y6(W)),Q.uppercase=(W)=>Q.check(g6(W)),Q.trim=()=>Q.check(m6()),Q.normalize=(...W)=>Q.check(l6(...W)),Q.toLowerCase=()=>Q.check(c6()),Q.toUpperCase=()=>Q.check(p6())}),xH=F("ZodString",(Q,Y)=>{YQ.init(Q,Y),WG.init(Q,Y),Q.email=(X)=>Q.check(YW(_H,X)),Q.url=(X)=>Q.check(JW(yH,X)),Q.jwt=(X)=>Q.check(ZW(aH,X)),Q.emoji=(X)=>Q.check(zW(gH,X)),Q.guid=(X)=>Q.check(x6(QG,X)),Q.uuid=(X)=>Q.check(XW(HQ,X)),Q.uuidv4=(X)=>Q.check(WW(HQ,X)),Q.uuidv6=(X)=>Q.check(GW(HQ,X)),Q.uuidv7=(X)=>Q.check($W(HQ,X)),Q.nanoid=(X)=>Q.check(HW(uH,X)),Q.guid=(X)=>Q.check(x6(QG,X)),Q.cuid=(X)=>Q.check(AW(hH,X)),Q.cuid2=(X)=>Q.check(UW(fH,X)),Q.ulid=(X)=>Q.check(KW(lH,X)),Q.base64=(X)=>Q.check(MW(dH,X)),Q.base64url=(X)=>Q.check(VW(oH,X)),Q.xid=(X)=>Q.check(DW(mH,X)),Q.ksuid=(X)=>Q.check(BW(cH,X)),Q.ipv4=(X)=>Q.check(LW(pH,X)),Q.ipv6=(X)=>Q.check(FW(iH,X)),Q.cidrv4=(X)=>Q.check(qW(rH,X)),Q.cidrv6=(X)=>Q.check(OW(nH,X)),Q.e164=(X)=>Q.check(NW(tH,X)),Q.datetime=(X)=>Q.check(i6(X)),Q.date=(X)=>Q.check(r6(X)),Q.time=(X)=>Q.check(n6(X)),Q.duration=(X)=>Q.check(d6(X))});function B(Q){return QW(xH,Q)}var d=F("ZodStringFormat",(Q,Y)=>{r.init(Q,Y),WG.init(Q,Y)}),_H=F("ZodEmail",(Q,Y)=>{z8.init(Q,Y),d.init(Q,Y)});var QG=F("ZodGUID",(Q,Y)=>{$8.init(Q,Y),d.init(Q,Y)});var HQ=F("ZodUUID",(Q,Y)=>{J8.init(Q,Y),d.init(Q,Y)});var yH=F("ZodURL",(Q,Y)=>{H8.init(Q,Y),d.init(Q,Y)});var gH=F("ZodEmoji",(Q,Y)=>{A8.init(Q,Y),d.init(Q,Y)});var uH=F("ZodNanoID",(Q,Y)=>{U8.init(Q,Y),d.init(Q,Y)});var hH=F("ZodCUID",(Q,Y)=>{K8.init(Q,Y),d.init(Q,Y)});var fH=F("ZodCUID2",(Q,Y)=>{D8.init(Q,Y),d.init(Q,Y)});var lH=F("ZodULID",(Q,Y)=>{B8.init(Q,Y),d.init(Q,Y)});var mH=F("ZodXID",(Q,Y)=>{L8.init(Q,Y),d.init(Q,Y)});var cH=F("ZodKSUID",(Q,Y)=>{F8.init(Q,Y),d.init(Q,Y)});var pH=F("ZodIPv4",(Q,Y)=>{N8.init(Q,Y),d.init(Q,Y)});var iH=F("ZodIPv6",(Q,Y)=>{Z8.init(Q,Y),d.init(Q,Y)});var rH=F("ZodCIDRv4",(Q,Y)=>{w8.init(Q,Y),d.init(Q,Y)});var nH=F("ZodCIDRv6",(Q,Y)=>{b8.init(Q,Y),d.init(Q,Y)});var dH=F("ZodBase64",(Q,Y)=>{I8.init(Q,Y),d.init(Q,Y)});var oH=F("ZodBase64URL",(Q,Y)=>{j8.init(Q,Y),d.init(Q,Y)});var tH=F("ZodE164",(Q,Y)=>{E8.init(Q,Y),d.init(Q,Y)});var aH=F("ZodJWT",(Q,Y)=>{T8.init(Q,Y),d.init(Q,Y)});var GG=F("ZodNumber",(Q,Y)=>{C6.init(Q,Y),s.init(Q,Y),Q.gt=(W,G)=>Q.check(WQ(W,G)),Q.gte=(W,G)=>Q.check(X4(W,G)),Q.min=(W,G)=>Q.check(X4(W,G)),Q.lt=(W,G)=>Q.check(XQ(W,G)),Q.lte=(W,G)=>Q.check(Y4(W,G)),Q.max=(W,G)=>Q.check(Y4(W,G)),Q.int=(W)=>Q.check(YG(W)),Q.safe=(W)=>Q.check(YG(W)),Q.positive=(W)=>Q.check(WQ(0,W)),Q.nonnegative=(W)=>Q.check(X4(0,W)),Q.negative=(W)=>Q.check(XQ(0,W)),Q.nonpositive=(W)=>Q.check(Y4(0,W)),Q.multipleOf=(W,G)=>Q.check(GQ(W,G)),Q.step=(W,G)=>Q.check(GQ(W,G)),Q.finite=()=>Q;let X=Q._zod.bag;Q.minValue=Math.max(X.minimum??Number.NEGATIVE_INFINITY,X.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,Q.maxValue=Math.min(X.maximum??Number.POSITIVE_INFINITY,X.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,Q.isInt=(X.format??"").includes("int")||Number.isSafeInteger(X.multipleOf??0.5),Q.isFinite=!0,Q.format=X.format??null});function l(Q){return jW(GG,Q)}var sH=F("ZodNumberFormat",(Q,Y)=>{S8.init(Q,Y),GG.init(Q,Y)});function YG(Q){return EW(sH,Q)}var eH=F("ZodBoolean",(Q,Y)=>{R8.init(Q,Y),s.init(Q,Y)});function X0(Q){return TW(eH,Q)}var QA=F("ZodNull",(Q,Y)=>{C8.init(Q,Y),s.init(Q,Y)});function a6(Q){return SW(QA,Q)}var YA=F("ZodUnknown",(Q,Y)=>{k8.init(Q,Y),s.init(Q,Y)});function o(){return RW(YA)}var XA=F("ZodNever",(Q,Y)=>{v8.init(Q,Y),s.init(Q,Y)});function WA(Q){return CW(XA,Q)}var GA=F("ZodArray",(Q,Y)=>{x8.init(Q,Y),s.init(Q,Y),Q.element=Y.element,Q.min=(X,W)=>Q.check(E1(X,W)),Q.nonempty=(X)=>Q.check(E1(1,X)),Q.max=(X,W)=>Q.check($Q(X,W)),Q.length=(X,W)=>Q.check(JQ(X,W)),Q.unwrap=()=>Q.element});function _(Q,Y){return kW(GA,Q,Y)}var $G=F("ZodObject",(Q,Y)=>{g8.init(Q,Y),s.init(Q,Y),h.defineLazy(Q,"shape",()=>{return Y.shape}),Q.keyof=()=>L0(Object.keys(Q._zod.def.shape)),Q.catchall=(X)=>Q.clone({...Q._zod.def,catchall:X}),Q.passthrough=()=>Q.clone({...Q._zod.def,catchall:o()}),Q.loose=()=>Q.clone({...Q._zod.def,catchall:o()}),Q.strict=()=>Q.clone({...Q._zod.def,catchall:WA()}),Q.strip=()=>Q.clone({...Q._zod.def,catchall:void 0}),Q.extend=(X)=>{return h.extend(Q,X)},Q.safeExtend=(X)=>{return h.safeExtend(Q,X)},Q.merge=(X)=>h.merge(Q,X),Q.pick=(X)=>h.pick(Q,X),Q.omit=(X)=>h.omit(Q,X),Q.partial=(...X)=>h.partial(HG,Q,X[0]),Q.required=(...X)=>h.required(AG,Q,X[0])});function w(Q,Y){let X={type:"object",shape:Q??{},...h.normalizeParams(Y)};return new $G(X)}function U0(Q,Y){return new $G({type:"object",shape:Q,catchall:o(),...h.normalizeParams(Y)})}var JG=F("ZodUnion",(Q,Y)=>{k6.init(Q,Y),s.init(Q,Y),Q.options=Y.options});function p(Q,Y){return new JG({type:"union",options:Q,...h.normalizeParams(Y)})}var $A=F("ZodDiscriminatedUnion",(Q,Y)=>{JG.init(Q,Y),u8.init(Q,Y)});function s6(Q,Y,X){return new $A({type:"union",options:Y,discriminator:Q,...h.normalizeParams(X)})}var JA=F("ZodIntersection",(Q,Y)=>{h8.init(Q,Y),s.init(Q,Y)});function AQ(Q,Y){return new JA({type:"intersection",left:Q,right:Y})}var zA=F("ZodRecord",(Q,Y)=>{f8.init(Q,Y),s.init(Q,Y),Q.keyType=Y.keyType,Q.valueType=Y.valueType});function t(Q,Y,X){return new zA({type:"record",keyType:Q,valueType:Y,...h.normalizeParams(X)})}var o6=F("ZodEnum",(Q,Y)=>{l8.init(Q,Y),s.init(Q,Y),Q.enum=Y.entries,Q.options=Object.values(Y.entries);let X=new Set(Object.keys(Y.entries));Q.extract=(W,G)=>{let $={};for(let J of W)if(X.has(J))$[J]=Y.entries[J];else throw Error(`Key ${J} not found in enum`);return new o6({...Y,checks:[],...h.normalizeParams(G),entries:$})},Q.exclude=(W,G)=>{let $={...Y.entries};for(let J of W)if(X.has(J))delete $[J];else throw Error(`Key ${J} not found in enum`);return new o6({...Y,checks:[],...h.normalizeParams(G),entries:$})}});function L0(Q,Y){let X=Array.isArray(Q)?Object.fromEntries(Q.map((W)=>[W,W])):Q;return new o6({type:"enum",entries:X,...h.normalizeParams(Y)})}var HA=F("ZodLiteral",(Q,Y)=>{m8.init(Q,Y),s.init(Q,Y),Q.values=new Set(Y.values),Object.defineProperty(Q,"value",{get(){if(Y.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return Y.values[0]}})});function b(Q,Y){return new HA({type:"literal",values:Array.isArray(Q)?Q:[Q],...h.normalizeParams(Y)})}var AA=F("ZodTransform",(Q,Y)=>{c8.init(Q,Y),s.init(Q,Y),Q._zod.parse=(X,W)=>{if(W.direction==="backward")throw new i1(Q.constructor.name);X.addIssue=($)=>{if(typeof $==="string")X.issues.push(h.issue($,X.value,Y));else{let J=$;if(J.fatal)J.continue=!1;J.code??(J.code="custom"),J.input??(J.input=X.value),J.inst??(J.inst=Q),X.issues.push(h.issue(J))}};let G=Y.transform(X.value,X);if(G instanceof Promise)return G.then(($)=>{return X.value=$,X});return X.value=G,X}});function zG(Q){return new AA({type:"transform",transform:Q})}var HG=F("ZodOptional",(Q,Y)=>{p8.init(Q,Y),s.init(Q,Y),Q.unwrap=()=>Q._zod.def.innerType});function a(Q){return new HG({type:"optional",innerType:Q})}var UA=F("ZodNullable",(Q,Y)=>{i8.init(Q,Y),s.init(Q,Y),Q.unwrap=()=>Q._zod.def.innerType});function XG(Q){return new UA({type:"nullable",innerType:Q})}var KA=F("ZodDefault",(Q,Y)=>{r8.init(Q,Y),s.init(Q,Y),Q.unwrap=()=>Q._zod.def.innerType,Q.removeDefault=Q.unwrap});function DA(Q,Y){return new KA({type:"default",innerType:Q,get defaultValue(){return typeof Y==="function"?Y():h.shallowClone(Y)}})}var BA=F("ZodPrefault",(Q,Y)=>{n8.init(Q,Y),s.init(Q,Y),Q.unwrap=()=>Q._zod.def.innerType});function LA(Q,Y){return new BA({type:"prefault",innerType:Q,get defaultValue(){return typeof Y==="function"?Y():h.shallowClone(Y)}})}var AG=F("ZodNonOptional",(Q,Y)=>{d8.init(Q,Y),s.init(Q,Y),Q.unwrap=()=>Q._zod.def.innerType});function FA(Q,Y){return new AG({type:"nonoptional",innerType:Q,...h.normalizeParams(Y)})}var qA=F("ZodCatch",(Q,Y)=>{o8.init(Q,Y),s.init(Q,Y),Q.unwrap=()=>Q._zod.def.innerType,Q.removeCatch=Q.unwrap});function OA(Q,Y){return new qA({type:"catch",innerType:Q,catchValue:typeof Y==="function"?Y:()=>Y})}var MA=F("ZodPipe",(Q,Y)=>{t8.init(Q,Y),s.init(Q,Y),Q.in=Y.in,Q.out=Y.out});function t6(Q,Y){return new MA({type:"pipe",in:Q,out:Y})}var VA=F("ZodReadonly",(Q,Y)=>{a8.init(Q,Y),s.init(Q,Y),Q.unwrap=()=>Q._zod.def.innerType});function NA(Q){return new VA({type:"readonly",innerType:Q})}var UG=F("ZodCustom",(Q,Y)=>{s8.init(Q,Y),s.init(Q,Y)});function KG(Q,Y){return vW(UG,Q??(()=>!0),Y)}function ZA(Q,Y={}){return xW(UG,Q,Y)}function wA(Q){return _W(Q)}function e6(Q,Y){return t6(zG(Q),Y)}w0(v6());var QY="2025-11-25";var DG=[QY,"2025-06-18","2025-03-26","2024-11-05","2024-10-07"],G1="io.modelcontextprotocol/related-task",KQ="2.0",G0=KG((Q)=>Q!==null&&(typeof Q==="object"||typeof Q==="function")),BG=p([B(),l().int()]),LG=B(),yN=U0({ttl:p([l(),a6()]).optional(),pollInterval:l().optional()}),bA=w({ttl:l().optional()}),PA=w({taskId:B()}),YY=U0({progressToken:BG.optional(),[G1]:PA.optional()}),Z0=w({_meta:YY.optional()}),$4=Z0.extend({task:bA.optional()}),FG=(Q)=>$4.safeParse(Q).success,$0=w({method:B(),params:Z0.loose().optional()}),b0=w({_meta:YY.optional()}),P0=w({method:B(),params:b0.loose().optional()}),J0=U0({_meta:YY.optional()}),DQ=p([B(),l().int()]),qG=w({jsonrpc:b(KQ),id:DQ,...$0.shape}).strict(),XY=(Q)=>qG.safeParse(Q).success,OG=w({jsonrpc:b(KQ),...P0.shape}).strict(),MG=(Q)=>OG.safeParse(Q).success,WY=w({jsonrpc:b(KQ),id:DQ,result:J0}).strict(),J4=(Q)=>WY.safeParse(Q).success;var y;(function(Q){Q[Q.ConnectionClosed=-32000]="ConnectionClosed",Q[Q.RequestTimeout=-32001]="RequestTimeout",Q[Q.ParseError=-32700]="ParseError",Q[Q.InvalidRequest=-32600]="InvalidRequest",Q[Q.MethodNotFound=-32601]="MethodNotFound",Q[Q.InvalidParams=-32602]="InvalidParams",Q[Q.InternalError=-32603]="InternalError",Q[Q.UrlElicitationRequired=-32042]="UrlElicitationRequired"})(y||(y={}));var GY=w({jsonrpc:b(KQ),id:DQ.optional(),error:w({code:l().int(),message:B(),data:o().optional()})}).strict();var VG=(Q)=>GY.safeParse(Q).success;var NG=p([qG,OG,WY,GY]),gN=p([WY,GY]),BQ=J0.strict(),IA=b0.extend({requestId:DQ.optional(),reason:B().optional()}),LQ=P0.extend({method:b("notifications/cancelled"),params:IA}),jA=w({src:B(),mimeType:B().optional(),sizes:_(B()).optional(),theme:L0(["light","dark"]).optional()}),z4=w({icons:_(jA).optional()}),S1=w({name:B(),title:B().optional()}),ZG=S1.extend({...S1.shape,...z4.shape,version:B(),websiteUrl:B().optional(),description:B().optional()}),EA=AQ(w({applyDefaults:X0().optional()}),t(B(),o())),TA=e6((Q)=>{if(Q&&typeof Q==="object"&&!Array.isArray(Q)){if(Object.keys(Q).length===0)return{form:{}}}return Q},AQ(w({form:EA.optional(),url:G0.optional()}),t(B(),o()).optional())),SA=U0({list:G0.optional(),cancel:G0.optional(),requests:U0({sampling:U0({createMessage:G0.optional()}).optional(),elicitation:U0({create:G0.optional()}).optional()}).optional()}),RA=U0({list:G0.optional(),cancel:G0.optional(),requests:U0({tools:U0({call:G0.optional()}).optional()}).optional()}),CA=w({experimental:t(B(),G0).optional(),sampling:w({context:G0.optional(),tools:G0.optional()}).optional(),elicitation:TA.optional(),roots:w({listChanged:X0().optional()}).optional(),tasks:SA.optional()}),kA=Z0.extend({protocolVersion:B(),capabilities:CA,clientInfo:ZG}),$Y=$0.extend({method:b("initialize"),params:kA});var vA=w({experimental:t(B(),G0).optional(),logging:G0.optional(),completions:G0.optional(),prompts:w({listChanged:X0().optional()}).optional(),resources:w({subscribe:X0().optional(),listChanged:X0().optional()}).optional(),tools:w({listChanged:X0().optional()}).optional(),tasks:RA.optional()}),xA=J0.extend({protocolVersion:B(),capabilities:vA,serverInfo:ZG,instructions:B().optional()}),JY=P0.extend({method:b("notifications/initialized"),params:b0.optional()});var FQ=$0.extend({method:b("ping"),params:Z0.optional()}),_A=w({progress:l(),total:a(l()),message:a(B())}),yA=w({...b0.shape,..._A.shape,progressToken:BG}),qQ=P0.extend({method:b("notifications/progress"),params:yA}),gA=Z0.extend({cursor:LG.optional()}),H4=$0.extend({params:gA.optional()}),A4=J0.extend({nextCursor:LG.optional()}),uA=L0(["working","input_required","completed","failed","cancelled"]),U4=w({taskId:B(),status:uA,ttl:p([l(),a6()]),createdAt:B(),lastUpdatedAt:B(),pollInterval:a(l()),statusMessage:a(B())}),R1=J0.extend({task:U4}),hA=b0.merge(U4),K4=P0.extend({method:b("notifications/tasks/status"),params:hA}),OQ=$0.extend({method:b("tasks/get"),params:Z0.extend({taskId:B()})}),MQ=J0.merge(U4),VQ=$0.extend({method:b("tasks/result"),params:Z0.extend({taskId:B()})}),uN=J0.loose(),NQ=H4.extend({method:b("tasks/list")}),ZQ=A4.extend({tasks:_(U4)}),wQ=$0.extend({method:b("tasks/cancel"),params:Z0.extend({taskId:B()})}),wG=J0.merge(U4),bG=w({uri:B(),mimeType:a(B()),_meta:t(B(),o()).optional()}),PG=bG.extend({text:B()}),zY=B().refine((Q)=>{try{return atob(Q),!0}catch{return!1}},{message:"Invalid Base64 string"}),IG=bG.extend({blob:zY}),D4=L0(["user","assistant"]),C1=w({audience:_(D4).optional(),priority:l().min(0).max(1).optional(),lastModified:G4.datetime({offset:!0}).optional()}),jG=w({...S1.shape,...z4.shape,uri:B(),description:a(B()),mimeType:a(B()),annotations:C1.optional(),_meta:a(U0({}))}),fA=w({...S1.shape,...z4.shape,uriTemplate:B(),description:a(B()),mimeType:a(B()),annotations:C1.optional(),_meta:a(U0({}))}),HY=H4.extend({method:b("resources/list")}),lA=A4.extend({resources:_(jG)}),mA=H4.extend({method:b("resources/templates/list")}),cA=A4.extend({resourceTemplates:_(fA)}),AY=Z0.extend({uri:B()}),pA=AY,UY=$0.extend({method:b("resources/read"),params:pA}),iA=J0.extend({contents:_(p([PG,IG]))}),rA=P0.extend({method:b("notifications/resources/list_changed"),params:b0.optional()}),nA=AY,dA=$0.extend({method:b("resources/subscribe"),params:nA}),oA=AY,tA=$0.extend({method:b("resources/unsubscribe"),params:oA}),aA=b0.extend({uri:B()}),sA=P0.extend({method:b("notifications/resources/updated"),params:aA}),eA=w({name:B(),description:a(B()),required:a(X0())}),QU=w({...S1.shape,...z4.shape,description:a(B()),arguments:a(_(eA)),_meta:a(U0({}))}),YU=H4.extend({method:b("prompts/list")}),XU=A4.extend({prompts:_(QU)}),WU=Z0.extend({name:B(),arguments:t(B(),B()).optional()}),GU=$0.extend({method:b("prompts/get"),params:WU}),KY=w({type:b("text"),text:B(),annotations:C1.optional(),_meta:t(B(),o()).optional()}),DY=w({type:b("image"),data:zY,mimeType:B(),annotations:C1.optional(),_meta:t(B(),o()).optional()}),BY=w({type:b("audio"),data:zY,mimeType:B(),annotations:C1.optional(),_meta:t(B(),o()).optional()}),$U=w({type:b("tool_use"),name:B(),id:B(),input:t(B(),o()),_meta:t(B(),o()).optional()}),JU=w({type:b("resource"),resource:p([PG,IG]),annotations:C1.optional(),_meta:t(B(),o()).optional()}),zU=jG.extend({type:b("resource_link")}),LY=p([KY,DY,BY,zU,JU]),HU=w({role:D4,content:LY}),AU=J0.extend({description:B().optional(),messages:_(HU)}),UU=P0.extend({method:b("notifications/prompts/list_changed"),params:b0.optional()}),KU=w({title:B().optional(),readOnlyHint:X0().optional(),destructiveHint:X0().optional(),idempotentHint:X0().optional(),openWorldHint:X0().optional()}),DU=w({taskSupport:L0(["required","optional","forbidden"]).optional()}),EG=w({...S1.shape,...z4.shape,description:B().optional(),inputSchema:w({type:b("object"),properties:t(B(),G0).optional(),required:_(B()).optional()}).catchall(o()),outputSchema:w({type:b("object"),properties:t(B(),G0).optional(),required:_(B()).optional()}).catchall(o()).optional(),annotations:KU.optional(),execution:DU.optional(),_meta:t(B(),o()).optional()}),FY=H4.extend({method:b("tools/list")}),BU=A4.extend({tools:_(EG)}),bQ=J0.extend({content:_(LY).default([]),structuredContent:t(B(),o()).optional(),isError:X0().optional()}),hN=bQ.or(J0.extend({toolResult:o()})),LU=$4.extend({name:B(),arguments:t(B(),o()).optional()}),B4=$0.extend({method:b("tools/call"),params:LU}),FU=P0.extend({method:b("notifications/tools/list_changed"),params:b0.optional()}),fN=w({autoRefresh:X0().default(!0),debounceMs:l().int().nonnegative().default(300)}),L4=L0(["debug","info","notice","warning","error","critical","alert","emergency"]),qU=Z0.extend({level:L4}),qY=$0.extend({method:b("logging/setLevel"),params:qU}),OU=b0.extend({level:L4,logger:B().optional(),data:o()}),MU=P0.extend({method:b("notifications/message"),params:OU}),VU=w({name:B().optional()}),NU=w({hints:_(VU).optional(),costPriority:l().min(0).max(1).optional(),speedPriority:l().min(0).max(1).optional(),intelligencePriority:l().min(0).max(1).optional()}),ZU=w({mode:L0(["auto","required","none"]).optional()}),wU=w({type:b("tool_result"),toolUseId:B().describe("The unique identifier for the corresponding tool call."),content:_(LY).default([]),structuredContent:w({}).loose().optional(),isError:X0().optional(),_meta:t(B(),o()).optional()}),bU=s6("type",[KY,DY,BY]),UQ=s6("type",[KY,DY,BY,$U,wU]),PU=w({role:D4,content:p([UQ,_(UQ)]),_meta:t(B(),o()).optional()}),IU=$4.extend({messages:_(PU),modelPreferences:NU.optional(),systemPrompt:B().optional(),includeContext:L0(["none","thisServer","allServers"]).optional(),temperature:l().optional(),maxTokens:l().int(),stopSequences:_(B()).optional(),metadata:G0.optional(),tools:_(EG).optional(),toolChoice:ZU.optional()}),jU=$0.extend({method:b("sampling/createMessage"),params:IU}),OY=J0.extend({model:B(),stopReason:a(L0(["endTurn","stopSequence","maxTokens"]).or(B())),role:D4,content:bU}),MY=J0.extend({model:B(),stopReason:a(L0(["endTurn","stopSequence","maxTokens","toolUse"]).or(B())),role:D4,content:p([UQ,_(UQ)])}),EU=w({type:b("boolean"),title:B().optional(),description:B().optional(),default:X0().optional()}),TU=w({type:b("string"),title:B().optional(),description:B().optional(),minLength:l().optional(),maxLength:l().optional(),format:L0(["email","uri","date","date-time"]).optional(),default:B().optional()}),SU=w({type:L0(["number","integer"]),title:B().optional(),description:B().optional(),minimum:l().optional(),maximum:l().optional(),default:l().optional()}),RU=w({type:b("string"),title:B().optional(),description:B().optional(),enum:_(B()),default:B().optional()}),CU=w({type:b("string"),title:B().optional(),description:B().optional(),oneOf:_(w({const:B(),title:B()})),default:B().optional()}),kU=w({type:b("string"),title:B().optional(),description:B().optional(),enum:_(B()),enumNames:_(B()).optional(),default:B().optional()}),vU=p([RU,CU]),xU=w({type:b("array"),title:B().optional(),description:B().optional(),minItems:l().optional(),maxItems:l().optional(),items:w({type:b("string"),enum:_(B())}),default:_(B()).optional()}),_U=w({type:b("array"),title:B().optional(),description:B().optional(),minItems:l().optional(),maxItems:l().optional(),items:w({anyOf:_(w({const:B(),title:B()}))}),default:_(B()).optional()}),yU=p([xU,_U]),gU=p([kU,vU,yU]),uU=p([gU,EU,TU,SU]),hU=$4.extend({mode:b("form").optional(),message:B(),requestedSchema:w({type:b("object"),properties:t(B(),uU),required:_(B()).optional()})}),fU=$4.extend({mode:b("url"),message:B(),elicitationId:B(),url:B().url()}),lU=p([hU,fU]),mU=$0.extend({method:b("elicitation/create"),params:lU}),cU=b0.extend({elicitationId:B()}),pU=P0.extend({method:b("notifications/elicitation/complete"),params:cU}),PQ=J0.extend({action:L0(["accept","decline","cancel"]),content:e6((Q)=>Q===null?void 0:Q,t(B(),p([B(),l(),X0(),_(B())])).optional())}),iU=w({type:b("ref/resource"),uri:B()});var rU=w({type:b("ref/prompt"),name:B()}),nU=Z0.extend({ref:p([rU,iU]),argument:w({name:B(),value:B()}),context:w({arguments:t(B(),B()).optional()}).optional()}),dU=$0.extend({method:b("completion/complete"),params:nU});var oU=J0.extend({completion:U0({values:_(B()).max(100),total:a(l().int()),hasMore:a(X0())})}),tU=w({uri:B().startsWith("file://"),name:B().optional(),_meta:t(B(),o()).optional()}),aU=$0.extend({method:b("roots/list"),params:Z0.optional()}),VY=J0.extend({roots:_(tU)}),sU=P0.extend({method:b("notifications/roots/list_changed"),params:b0.optional()}),lN=p([FQ,$Y,dU,qY,GU,YU,HY,mA,UY,dA,tA,B4,FY,OQ,VQ,NQ,wQ]),mN=p([LQ,qQ,JY,sU,K4]),cN=p([BQ,OY,MY,PQ,VY,MQ,ZQ,R1]),pN=p([FQ,jU,mU,aU,OQ,VQ,NQ,wQ]),iN=p([LQ,qQ,MU,sA,rA,FU,UU,K4,pU]),rN=p([BQ,xA,oU,AU,XU,lA,cA,iA,bQ,BU,MQ,ZQ,R1]);class k extends Error{constructor(Q,Y,X){super(`MCP error ${Q}: ${Y}`);this.code=Q,this.data=X,this.name="McpError"}static fromError(Q,Y,X){if(Q===y.UrlElicitationRequired&&X){let W=X;if(W.elicitations)return new TG(W.elicitations,Y)}return new k(Q,Y,X)}}class TG extends k{constructor(Q,Y=`URL elicitation${Q.length>1?"s":""} required`){super(y.UrlElicitationRequired,Y,{elicitations:Q})}get elicitations(){return this.data?.elicitations??[]}}function $1(Q){return Q==="completed"||Q==="failed"||Q==="cancelled"}var eU=Symbol("Let zodToJsonSchema decide on which parser to use");var IZ=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function NY(Q){let X=zQ(Q)?.method;if(!X)throw Error("Schema is missing a method literal");let W=yW(X);if(typeof W!=="string")throw Error("Schema method literal must be a string");return W}function ZY(Q,Y){let X=W1(Q,Y);if(!X.success)throw X.error;return X.data}var $3=60000;class wY{constructor(Q){if(this._options=Q,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(LQ,(Y)=>{this._oncancel(Y)}),this.setNotificationHandler(qQ,(Y)=>{this._onprogress(Y)}),this.setRequestHandler(FQ,(Y)=>({})),this._taskStore=Q?.taskStore,this._taskMessageQueue=Q?.taskMessageQueue,this._taskStore)this.setRequestHandler(OQ,async(Y,X)=>{let W=await this._taskStore.getTask(Y.params.taskId,X.sessionId);if(!W)throw new k(y.InvalidParams,"Failed to retrieve task: Task not found");return{...W}}),this.setRequestHandler(VQ,async(Y,X)=>{let W=async()=>{let G=Y.params.taskId;if(this._taskMessageQueue){let J;while(J=await this._taskMessageQueue.dequeue(G,X.sessionId)){if(J.type==="response"||J.type==="error"){let z=J.message,H=z.id,A=this._requestResolvers.get(H);if(A)if(this._requestResolvers.delete(H),J.type==="response")A(z);else{let U=z,K=new k(U.error.code,U.error.message,U.error.data);A(K)}else{let U=J.type==="response"?"Response":"Error";this._onerror(Error(`${U} handler missing for request ${H}`))}continue}await this._transport?.send(J.message,{relatedRequestId:X.requestId})}}let $=await this._taskStore.getTask(G,X.sessionId);if(!$)throw new k(y.InvalidParams,`Task not found: ${G}`);if(!$1($.status))return await this._waitForTaskUpdate(G,X.signal),await W();if($1($.status)){let J=await this._taskStore.getTaskResult(G,X.sessionId);return this._clearTaskQueue(G),{...J,_meta:{...J._meta,[G1]:{taskId:G}}}}return await W()};return await W()}),this.setRequestHandler(NQ,async(Y,X)=>{try{let{tasks:W,nextCursor:G}=await this._taskStore.listTasks(Y.params?.cursor,X.sessionId);return{tasks:W,nextCursor:G,_meta:{}}}catch(W){throw new k(y.InvalidParams,`Failed to list tasks: ${W instanceof Error?W.message:String(W)}`)}}),this.setRequestHandler(wQ,async(Y,X)=>{try{let W=await this._taskStore.getTask(Y.params.taskId,X.sessionId);if(!W)throw new k(y.InvalidParams,`Task not found: ${Y.params.taskId}`);if($1(W.status))throw new k(y.InvalidParams,`Cannot cancel task in terminal status: ${W.status}`);await this._taskStore.updateTaskStatus(Y.params.taskId,"cancelled","Client cancelled task execution.",X.sessionId),this._clearTaskQueue(Y.params.taskId);let G=await this._taskStore.getTask(Y.params.taskId,X.sessionId);if(!G)throw new k(y.InvalidParams,`Task not found after cancellation: ${Y.params.taskId}`);return{_meta:{},...G}}catch(W){if(W instanceof k)throw W;throw new k(y.InvalidRequest,`Failed to cancel task: ${W instanceof Error?W.message:String(W)}`)}})}async _oncancel(Q){if(!Q.params.requestId)return;this._requestHandlerAbortControllers.get(Q.params.requestId)?.abort(Q.params.reason)}_setupTimeout(Q,Y,X,W,G=!1){this._timeoutInfo.set(Q,{timeoutId:setTimeout(W,Y),startTime:Date.now(),timeout:Y,maxTotalTimeout:X,resetTimeoutOnProgress:G,onTimeout:W})}_resetTimeout(Q){let Y=this._timeoutInfo.get(Q);if(!Y)return!1;let X=Date.now()-Y.startTime;if(Y.maxTotalTimeout&&X>=Y.maxTotalTimeout)throw this._timeoutInfo.delete(Q),k.fromError(y.RequestTimeout,"Maximum total timeout exceeded",{maxTotalTimeout:Y.maxTotalTimeout,totalElapsed:X});return clearTimeout(Y.timeoutId),Y.timeoutId=setTimeout(Y.onTimeout,Y.timeout),!0}_cleanupTimeout(Q){let Y=this._timeoutInfo.get(Q);if(Y)clearTimeout(Y.timeoutId),this._timeoutInfo.delete(Q)}async connect(Q){this._transport=Q;let Y=this.transport?.onclose;this._transport.onclose=()=>{Y?.(),this._onclose()};let X=this.transport?.onerror;this._transport.onerror=(G)=>{X?.(G),this._onerror(G)};let W=this._transport?.onmessage;this._transport.onmessage=(G,$)=>{if(W?.(G,$),J4(G)||VG(G))this._onresponse(G);else if(XY(G))this._onrequest(G,$);else if(MG(G))this._onnotification(G);else this._onerror(Error(`Unknown message type: ${JSON.stringify(G)}`))},await this._transport.start()}_onclose(){let Q=this._responseHandlers;this._responseHandlers=new Map,this._progressHandlers.clear(),this._taskProgressTokens.clear(),this._pendingDebouncedNotifications.clear();let Y=k.fromError(y.ConnectionClosed,"Connection closed");this._transport=void 0,this.onclose?.();for(let X of Q.values())X(Y)}_onerror(Q){this.onerror?.(Q)}_onnotification(Q){let Y=this._notificationHandlers.get(Q.method)??this.fallbackNotificationHandler;if(Y===void 0)return;Promise.resolve().then(()=>Y(Q)).catch((X)=>this._onerror(Error(`Uncaught error in notification handler: ${X}`)))}_onrequest(Q,Y){let X=this._requestHandlers.get(Q.method)??this.fallbackRequestHandler,W=this._transport,G=Q.params?._meta?.[G1]?.taskId;if(X===void 0){let A={jsonrpc:"2.0",id:Q.id,error:{code:y.MethodNotFound,message:"Method not found"}};if(G&&this._taskMessageQueue)this._enqueueTaskMessage(G,{type:"error",message:A,timestamp:Date.now()},W?.sessionId).catch((U)=>this._onerror(Error(`Failed to enqueue error response: ${U}`)));else W?.send(A).catch((U)=>this._onerror(Error(`Failed to send an error response: ${U}`)));return}let $=new AbortController;this._requestHandlerAbortControllers.set(Q.id,$);let J=FG(Q.params)?Q.params.task:void 0,z=this._taskStore?this.requestTaskStore(Q,W?.sessionId):void 0,H={signal:$.signal,sessionId:W?.sessionId,_meta:Q.params?._meta,sendNotification:async(A)=>{let U={relatedRequestId:Q.id};if(G)U.relatedTask={taskId:G};await this.notification(A,U)},sendRequest:async(A,U,K)=>{let D={...K,relatedRequestId:Q.id};if(G&&!D.relatedTask)D.relatedTask={taskId:G};let L=D.relatedTask?.taskId??G;if(L&&z)await z.updateTaskStatus(L,"input_required");return await this.request(A,U,D)},authInfo:Y?.authInfo,requestId:Q.id,requestInfo:Y?.requestInfo,taskId:G,taskStore:z,taskRequestedTtl:J?.ttl,closeSSEStream:Y?.closeSSEStream,closeStandaloneSSEStream:Y?.closeStandaloneSSEStream};Promise.resolve().then(()=>{if(J)this.assertTaskHandlerCapability(Q.method)}).then(()=>X(Q,H)).then(async(A)=>{if($.signal.aborted)return;let U={result:A,jsonrpc:"2.0",id:Q.id};if(G&&this._taskMessageQueue)await this._enqueueTaskMessage(G,{type:"response",message:U,timestamp:Date.now()},W?.sessionId);else await W?.send(U)},async(A)=>{if($.signal.aborted)return;let U={jsonrpc:"2.0",id:Q.id,error:{code:Number.isSafeInteger(A.code)?A.code:y.InternalError,message:A.message??"Internal error",...A.data!==void 0&&{data:A.data}}};if(G&&this._taskMessageQueue)await this._enqueueTaskMessage(G,{type:"error",message:U,timestamp:Date.now()},W?.sessionId);else await W?.send(U)}).catch((A)=>this._onerror(Error(`Failed to send response: ${A}`))).finally(()=>{this._requestHandlerAbortControllers.delete(Q.id)})}_onprogress(Q){let{progressToken:Y,...X}=Q.params,W=Number(Y),G=this._progressHandlers.get(W);if(!G){this._onerror(Error(`Received a progress notification for an unknown token: ${JSON.stringify(Q)}`));return}let $=this._responseHandlers.get(W),J=this._timeoutInfo.get(W);if(J&&$&&J.resetTimeoutOnProgress)try{this._resetTimeout(W)}catch(z){this._responseHandlers.delete(W),this._progressHandlers.delete(W),this._cleanupTimeout(W),$(z);return}G(X)}_onresponse(Q){let Y=Number(Q.id),X=this._requestResolvers.get(Y);if(X){if(this._requestResolvers.delete(Y),J4(Q))X(Q);else{let $=new k(Q.error.code,Q.error.message,Q.error.data);X($)}return}let W=this._responseHandlers.get(Y);if(W===void 0){this._onerror(Error(`Received a response for an unknown message ID: ${JSON.stringify(Q)}`));return}this._responseHandlers.delete(Y),this._cleanupTimeout(Y);let G=!1;if(J4(Q)&&Q.result&&typeof Q.result==="object"){let $=Q.result;if($.task&&typeof $.task==="object"){let J=$.task;if(typeof J.taskId==="string")G=!0,this._taskProgressTokens.set(J.taskId,Y)}}if(!G)this._progressHandlers.delete(Y);if(J4(Q))W(Q);else{let $=k.fromError(Q.error.code,Q.error.message,Q.error.data);W($)}}get transport(){return this._transport}async close(){await this._transport?.close()}async*requestStream(Q,Y,X){let{task:W}=X??{};if(!W){try{yield{type:"result",result:await this.request(Q,Y,X)}}catch($){yield{type:"error",error:$ instanceof k?$:new k(y.InternalError,String($))}}return}let G;try{let $=await this.request(Q,R1,X);if($.task)G=$.task.taskId,yield{type:"taskCreated",task:$.task};else throw new k(y.InternalError,"Task creation did not return a task");while(!0){let J=await this.getTask({taskId:G},X);if(yield{type:"taskStatus",task:J},$1(J.status)){if(J.status==="completed")yield{type:"result",result:await this.getTaskResult({taskId:G},Y,X)};else if(J.status==="failed")yield{type:"error",error:new k(y.InternalError,`Task ${G} failed`)};else if(J.status==="cancelled")yield{type:"error",error:new k(y.InternalError,`Task ${G} was cancelled`)};return}if(J.status==="input_required"){yield{type:"result",result:await this.getTaskResult({taskId:G},Y,X)};return}let z=J.pollInterval??this._options?.defaultTaskPollInterval??1000;await new Promise((H)=>setTimeout(H,z)),X?.signal?.throwIfAborted()}}catch($){yield{type:"error",error:$ instanceof k?$:new k(y.InternalError,String($))}}}request(Q,Y,X){let{relatedRequestId:W,resumptionToken:G,onresumptiontoken:$,task:J,relatedTask:z}=X??{};return new Promise((H,A)=>{let U=(M)=>{A(M)};if(!this._transport){U(Error("Not connected"));return}if(this._options?.enforceStrictCapabilities===!0)try{if(this.assertCapabilityForMethod(Q.method),J)this.assertTaskCapability(Q.method)}catch(M){U(M);return}X?.signal?.throwIfAborted();let K=this._requestMessageId++,D={...Q,jsonrpc:"2.0",id:K};if(X?.onprogress)this._progressHandlers.set(K,X.onprogress),D.params={...Q.params,_meta:{...Q.params?._meta||{},progressToken:K}};if(J)D.params={...D.params,task:J};if(z)D.params={...D.params,_meta:{...D.params?._meta||{},[G1]:z}};let L=(M)=>{this._responseHandlers.delete(K),this._progressHandlers.delete(K),this._cleanupTimeout(K),this._transport?.send({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:K,reason:String(M)}},{relatedRequestId:W,resumptionToken:G,onresumptiontoken:$}).catch((E)=>this._onerror(Error(`Failed to send cancellation: ${E}`)));let S=M instanceof k?M:new k(y.RequestTimeout,String(M));A(S)};this._responseHandlers.set(K,(M)=>{if(X?.signal?.aborted)return;if(M instanceof Error)return A(M);try{let S=W1(Y,M.result);if(!S.success)A(S.error);else H(S.data)}catch(S){A(S)}}),X?.signal?.addEventListener("abort",()=>{L(X?.signal?.reason)});let q=X?.timeout??$3,O=()=>L(k.fromError(y.RequestTimeout,"Request timed out",{timeout:q}));this._setupTimeout(K,q,X?.maxTotalTimeout,O,X?.resetTimeoutOnProgress??!1);let V=z?.taskId;if(V){let M=(S)=>{let E=this._responseHandlers.get(K);if(E)E(S);else this._onerror(Error(`Response handler missing for side-channeled request ${K}`))};this._requestResolvers.set(K,M),this._enqueueTaskMessage(V,{type:"request",message:D,timestamp:Date.now()}).catch((S)=>{this._cleanupTimeout(K),A(S)})}else this._transport.send(D,{relatedRequestId:W,resumptionToken:G,onresumptiontoken:$}).catch((M)=>{this._cleanupTimeout(K),A(M)})})}async getTask(Q,Y){return this.request({method:"tasks/get",params:Q},MQ,Y)}async getTaskResult(Q,Y,X){return this.request({method:"tasks/result",params:Q},Y,X)}async listTasks(Q,Y){return this.request({method:"tasks/list",params:Q},ZQ,Y)}async cancelTask(Q,Y){return this.request({method:"tasks/cancel",params:Q},wG,Y)}async notification(Q,Y){if(!this._transport)throw Error("Not connected");this.assertNotificationCapability(Q.method);let X=Y?.relatedTask?.taskId;if(X){let J={...Q,jsonrpc:"2.0",params:{...Q.params,_meta:{...Q.params?._meta||{},[G1]:Y.relatedTask}}};await this._enqueueTaskMessage(X,{type:"notification",message:J,timestamp:Date.now()});return}if((this._options?.debouncedNotificationMethods??[]).includes(Q.method)&&!Q.params&&!Y?.relatedRequestId&&!Y?.relatedTask){if(this._pendingDebouncedNotifications.has(Q.method))return;this._pendingDebouncedNotifications.add(Q.method),Promise.resolve().then(()=>{if(this._pendingDebouncedNotifications.delete(Q.method),!this._transport)return;let J={...Q,jsonrpc:"2.0"};if(Y?.relatedTask)J={...J,params:{...J.params,_meta:{...J.params?._meta||{},[G1]:Y.relatedTask}}};this._transport?.send(J,Y).catch((z)=>this._onerror(z))});return}let $={...Q,jsonrpc:"2.0"};if(Y?.relatedTask)$={...$,params:{...$.params,_meta:{...$.params?._meta||{},[G1]:Y.relatedTask}}};await this._transport.send($,Y)}setRequestHandler(Q,Y){let X=NY(Q);this.assertRequestHandlerCapability(X),this._requestHandlers.set(X,(W,G)=>{let $=ZY(Q,W);return Promise.resolve(Y($,G))})}removeRequestHandler(Q){this._requestHandlers.delete(Q)}assertCanSetRequestHandler(Q){if(this._requestHandlers.has(Q))throw Error(`A request handler for ${Q} already exists, which would be overridden`)}setNotificationHandler(Q,Y){let X=NY(Q);this._notificationHandlers.set(X,(W)=>{let G=ZY(Q,W);return Promise.resolve(Y(G))})}removeNotificationHandler(Q){this._notificationHandlers.delete(Q)}_cleanupTaskProgressHandler(Q){let Y=this._taskProgressTokens.get(Q);if(Y!==void 0)this._progressHandlers.delete(Y),this._taskProgressTokens.delete(Q)}async _enqueueTaskMessage(Q,Y,X){if(!this._taskStore||!this._taskMessageQueue)throw Error("Cannot enqueue task message: taskStore and taskMessageQueue are not configured");let W=this._options?.maxTaskQueueSize;await this._taskMessageQueue.enqueue(Q,Y,X,W)}async _clearTaskQueue(Q,Y){if(this._taskMessageQueue){let X=await this._taskMessageQueue.dequeueAll(Q,Y);for(let W of X)if(W.type==="request"&&XY(W.message)){let G=W.message.id,$=this._requestResolvers.get(G);if($)$(new k(y.InternalError,"Task cancelled or completed")),this._requestResolvers.delete(G);else this._onerror(Error(`Resolver missing for request ${G} during task ${Q} cleanup`))}}}async _waitForTaskUpdate(Q,Y){let X=this._options?.defaultTaskPollInterval??1000;try{let W=await this._taskStore?.getTask(Q);if(W?.pollInterval)X=W.pollInterval}catch{}return new Promise((W,G)=>{if(Y.aborted){G(new k(y.InvalidRequest,"Request cancelled"));return}let $=setTimeout(W,X);Y.addEventListener("abort",()=>{clearTimeout($),G(new k(y.InvalidRequest,"Request cancelled"))},{once:!0})})}requestTaskStore(Q,Y){let X=this._taskStore;if(!X)throw Error("No task store configured");return{createTask:async(W)=>{if(!Q)throw Error("No request provided");return await X.createTask(W,Q.id,{method:Q.method,params:Q.params},Y)},getTask:async(W)=>{let G=await X.getTask(W,Y);if(!G)throw new k(y.InvalidParams,"Failed to retrieve task: Task not found");return G},storeTaskResult:async(W,G,$)=>{await X.storeTaskResult(W,G,$,Y);let J=await X.getTask(W,Y);if(J){let z=K4.parse({method:"notifications/tasks/status",params:J});if(await this.notification(z),$1(J.status))this._cleanupTaskProgressHandler(W)}},getTaskResult:(W)=>{return X.getTaskResult(W,Y)},updateTaskStatus:async(W,G,$)=>{let J=await X.getTask(W,Y);if(!J)throw new k(y.InvalidParams,`Task "${W}" not found - it may have been cleaned up`);if($1(J.status))throw new k(y.InvalidParams,`Cannot update task "${W}" from terminal status "${J.status}" to "${G}". Terminal states (completed, failed, cancelled) cannot transition to other states.`);await X.updateTaskStatus(W,G,$,Y);let z=await X.getTask(W,Y);if(z){let H=K4.parse({method:"notifications/tasks/status",params:z});if(await this.notification(H),$1(z.status))this._cleanupTaskProgressHandler(W)}},listTasks:(W)=>{return X.listTasks(W,Y)}}}}function SG(Q){return Q!==null&&typeof Q==="object"&&!Array.isArray(Q)}function RG(Q,Y){let X={...Q};for(let W in Y){let G=W,$=Y[G];if($===void 0)continue;let J=X[G];if(SG(J)&&SG($))X[G]={...J,...$};else X[G]=$}return X}var z5=g9(q9(),1),H5=g9(J5(),1);function LM(){let Q=new z5.default({strict:!1,validateFormats:!0,validateSchema:!1,allErrors:!0});return H5.default(Q),Q}class j9{constructor(Q){this._ajv=Q??LM()}getValidator(Q){let Y="$id"in Q&&typeof Q.$id==="string"?this._ajv.getSchema(Q.$id)??this._ajv.compile(Q):this._ajv.compile(Q);return(X)=>{if(Y(X))return{valid:!0,data:X,errorMessage:void 0};else return{valid:!1,data:void 0,errorMessage:this._ajv.errorsText(Y.errors)}}}}class E9{constructor(Q){this._server=Q}requestStream(Q,Y,X){return this._server.requestStream(Q,Y,X)}async getTask(Q,Y){return this._server.getTask({taskId:Q},Y)}async getTaskResult(Q,Y,X){return this._server.getTaskResult({taskId:Q},Y,X)}async listTasks(Q,Y){return this._server.listTasks(Q?{cursor:Q}:void 0,Y)}async cancelTask(Q,Y){return this._server.cancelTask({taskId:Q},Y)}}function A5(Q,Y,X){if(!Q)throw Error(`${X} does not support task creation (required for ${Y})`);switch(Y){case"tools/call":if(!Q.tools?.call)throw Error(`${X} does not support task creation for tools/call (required for ${Y})`);break;default:break}}function U5(Q,Y,X){if(!Q)throw Error(`${X} does not support task creation (required for ${Y})`);switch(Y){case"sampling/createMessage":if(!Q.sampling?.createMessage)throw Error(`${X} does not support task creation for sampling/createMessage (required for ${Y})`);break;case"elicitation/create":if(!Q.elicitation?.create)throw Error(`${X} does not support task creation for elicitation/create (required for ${Y})`);break;default:break}}class T9 extends wY{constructor(Q,Y){super(Y);if(this._serverInfo=Q,this._loggingLevels=new Map,this.LOG_LEVEL_SEVERITY=new Map(L4.options.map((X,W)=>[X,W])),this.isMessageIgnored=(X,W)=>{let G=this._loggingLevels.get(W);return G?this.LOG_LEVEL_SEVERITY.get(X)<this.LOG_LEVEL_SEVERITY.get(G):!1},this._capabilities=Y?.capabilities??{},this._instructions=Y?.instructions,this._jsonSchemaValidator=Y?.jsonSchemaValidator??new j9,this.setRequestHandler($Y,(X)=>this._oninitialize(X)),this.setNotificationHandler(JY,()=>this.oninitialized?.()),this._capabilities.logging)this.setRequestHandler(qY,async(X,W)=>{let G=W.sessionId||W.requestInfo?.headers["mcp-session-id"]||void 0,{level:$}=X.params,J=L4.safeParse($);if(J.success)this._loggingLevels.set(G,J.data);return{}})}get experimental(){if(!this._experimental)this._experimental={tasks:new E9(this)};return this._experimental}registerCapabilities(Q){if(this.transport)throw Error("Cannot register capabilities after connecting to transport");this._capabilities=RG(this._capabilities,Q)}setRequestHandler(Q,Y){let W=zQ(Q)?.method;if(!W)throw Error("Schema is missing a method literal");let G;if(T1(W)){let J=W;G=J._zod?.def?.value??J.value}else{let J=W;G=J._def?.value??J.value}if(typeof G!=="string")throw Error("Schema method literal must be a string");if(G==="tools/call"){let J=async(z,H)=>{let A=W1(B4,z);if(!A.success){let L=A.error instanceof Error?A.error.message:String(A.error);throw new k(y.InvalidParams,`Invalid tools/call request: ${L}`)}let{params:U}=A.data,K=await Promise.resolve(Y(z,H));if(U.task){let L=W1(R1,K);if(!L.success){let q=L.error instanceof Error?L.error.message:String(L.error);throw new k(y.InvalidParams,`Invalid task creation result: ${q}`)}return L.data}let D=W1(bQ,K);if(!D.success){let L=D.error instanceof Error?D.error.message:String(D.error);throw new k(y.InvalidParams,`Invalid tools/call result: ${L}`)}return D.data};return super.setRequestHandler(Q,J)}return super.setRequestHandler(Q,Y)}assertCapabilityForMethod(Q){switch(Q){case"sampling/createMessage":if(!this._clientCapabilities?.sampling)throw Error(`Client does not support sampling (required for ${Q})`);break;case"elicitation/create":if(!this._clientCapabilities?.elicitation)throw Error(`Client does not support elicitation (required for ${Q})`);break;case"roots/list":if(!this._clientCapabilities?.roots)throw Error(`Client does not support listing roots (required for ${Q})`);break;case"ping":break}}assertNotificationCapability(Q){switch(Q){case"notifications/message":if(!this._capabilities.logging)throw Error(`Server does not support logging (required for ${Q})`);break;case"notifications/resources/updated":case"notifications/resources/list_changed":if(!this._capabilities.resources)throw Error(`Server does not support notifying about resources (required for ${Q})`);break;case"notifications/tools/list_changed":if(!this._capabilities.tools)throw Error(`Server does not support notifying of tool list changes (required for ${Q})`);break;case"notifications/prompts/list_changed":if(!this._capabilities.prompts)throw Error(`Server does not support notifying of prompt list changes (required for ${Q})`);break;case"notifications/elicitation/complete":if(!this._clientCapabilities?.elicitation?.url)throw Error(`Client does not support URL elicitation (required for ${Q})`);break;case"notifications/cancelled":break;case"notifications/progress":break}}assertRequestHandlerCapability(Q){if(!this._capabilities)return;switch(Q){case"completion/complete":if(!this._capabilities.completions)throw Error(`Server does not support completions (required for ${Q})`);break;case"logging/setLevel":if(!this._capabilities.logging)throw Error(`Server does not support logging (required for ${Q})`);break;case"prompts/get":case"prompts/list":if(!this._capabilities.prompts)throw Error(`Server does not support prompts (required for ${Q})`);break;case"resources/list":case"resources/templates/list":case"resources/read":if(!this._capabilities.resources)throw Error(`Server does not support resources (required for ${Q})`);break;case"tools/call":case"tools/list":if(!this._capabilities.tools)throw Error(`Server does not support tools (required for ${Q})`);break;case"tasks/get":case"tasks/list":case"tasks/result":case"tasks/cancel":if(!this._capabilities.tasks)throw Error(`Server does not support tasks capability (required for ${Q})`);break;case"ping":case"initialize":break}}assertTaskCapability(Q){U5(this._clientCapabilities?.tasks?.requests,Q,"Client")}assertTaskHandlerCapability(Q){if(!this._capabilities)return;A5(this._capabilities.tasks?.requests,Q,"Server")}async _oninitialize(Q){let Y=Q.params.protocolVersion;return this._clientCapabilities=Q.params.capabilities,this._clientVersion=Q.params.clientInfo,{protocolVersion:DG.includes(Y)?Y:QY,capabilities:this.getCapabilities(),serverInfo:this._serverInfo,...this._instructions&&{instructions:this._instructions}}}getClientCapabilities(){return this._clientCapabilities}getClientVersion(){return this._clientVersion}getCapabilities(){return this._capabilities}async ping(){return this.request({method:"ping"},BQ)}async createMessage(Q,Y){if(Q.tools||Q.toolChoice){if(!this._clientCapabilities?.sampling?.tools)throw Error("Client does not support sampling tools capability.")}if(Q.messages.length>0){let X=Q.messages[Q.messages.length-1],W=Array.isArray(X.content)?X.content:[X.content],G=W.some((H)=>H.type==="tool_result"),$=Q.messages.length>1?Q.messages[Q.messages.length-2]:void 0,J=$?Array.isArray($.content)?$.content:[$.content]:[],z=J.some((H)=>H.type==="tool_use");if(G){if(W.some((H)=>H.type!=="tool_result"))throw Error("The last message must contain only tool_result content if any is present");if(!z)throw Error("tool_result blocks are not matching any tool_use from the previous message")}if(z){let H=new Set(J.filter((U)=>U.type==="tool_use").map((U)=>U.id)),A=new Set(W.filter((U)=>U.type==="tool_result").map((U)=>U.toolUseId));if(H.size!==A.size||![...H].every((U)=>A.has(U)))throw Error("ids of tool_result blocks and tool_use blocks from previous message do not match")}}if(Q.tools)return this.request({method:"sampling/createMessage",params:Q},MY,Y);return this.request({method:"sampling/createMessage",params:Q},OY,Y)}async elicitInput(Q,Y){switch(Q.mode??"form"){case"url":{if(!this._clientCapabilities?.elicitation?.url)throw Error("Client does not support url elicitation.");let W=Q;return this.request({method:"elicitation/create",params:W},PQ,Y)}case"form":{if(!this._clientCapabilities?.elicitation?.form)throw Error("Client does not support form elicitation.");let W=Q.mode==="form"?Q:{...Q,mode:"form"},G=await this.request({method:"elicitation/create",params:W},PQ,Y);if(G.action==="accept"&&G.content&&W.requestedSchema)try{let J=this._jsonSchemaValidator.getValidator(W.requestedSchema)(G.content);if(!J.valid)throw new k(y.InvalidParams,`Elicitation response content does not match requested schema: ${J.errorMessage}`)}catch($){if($ instanceof k)throw $;throw new k(y.InternalError,`Error validating elicitation response: ${$ instanceof Error?$.message:String($)}`)}return G}}}createElicitationCompletionNotifier(Q,Y){if(!this._clientCapabilities?.elicitation?.url)throw Error("Client does not support URL elicitation (required for notifications/elicitation/complete)");return()=>this.notification({method:"notifications/elicitation/complete",params:{elicitationId:Q}},Y)}async listRoots(Q,Y){return this.request({method:"roots/list",params:Q},VY,Y)}async sendLoggingMessage(Q,Y){if(this._capabilities.logging){if(!this.isMessageIgnored(Q.level,Y))return this.notification({method:"notifications/message",params:Q})}}async sendResourceUpdated(Q){return this.notification({method:"notifications/resources/updated",params:Q})}async sendResourceListChanged(){return this.notification({method:"notifications/resources/list_changed"})}async sendToolListChanged(){return this.notification({method:"notifications/tools/list_changed"})}async sendPromptListChanged(){return this.notification({method:"notifications/prompts/list_changed"})}}var K5={name:"@sequenzy/mcp",version:"0.0.44",mcpName:"io.github.sequenzy/mcp",description:"Sequenzy MCP server for AI-powered email marketing automation",type:"module",bin:{"sequenzy-mcp":"dist/index.js"},main:"./dist/index.js",exports:{".":"./dist/index.js","./server":"./dist/server.js","./runtime":"./dist/runtime.js","./server.json":"./server.json"},scripts:{dev:"bun --watch src/index.ts",build:"bun build src/index.ts src/server.ts src/runtime.ts --outdir dist --target node --minify",start:"node dist/index.js","type-check":"tsc --noEmit",test:"bun test","test:watch":"bun test --watch",prepublishOnly:"bun run build"},dependencies:{"@modelcontextprotocol/sdk":"^1.0.0"},devDependencies:{"@types/bun":"latest","@types/node":"^22.0.0","bun-types":"latest",typescript:"^5.8.0"},files:["dist","server.json"],keywords:["sequenzy","email","mcp","ai","claude","automation"],license:"MIT",publishConfig:{access:"public"},repository:{type:"git",url:"git+https://github.com/Sequenzy/mcp.git"},homepage:"https://sequenzy.com",bugs:{url:"https://github.com/Sequenzy/mcp/issues"}};var S9=["product-info","domain","tracking","localization","integrations","products","events","tags","labels","goals","sync-rules","api-keys","widgets","team","danger"],D5={dashboard:"/dashboard/company/{companyId}",campaigns:"/dashboard/company/{companyId}/campaign",campaign:"/dashboard/company/{companyId}/campaign/{campaignId}",campaignPreview:"/dashboard/company/{companyId}/campaign/{campaignId}?step=review",campaignList:"/dashboard/company/{companyId}/campaign/list/{status}",sequences:"/dashboard/company/{companyId}/sequences",sequence:"/dashboard/company/{companyId}/sequences/{sequenceId}",sequenceList:"/dashboard/company/{companyId}/sequences/list/{status}",settings:"/dashboard/company/{companyId}/settings",settingsTab:"/dashboard/company/{companyId}/settings?tab={tab}",emails:"/dashboard/company/{companyId}/emails",email:"/dashboard/company/{companyId}/emails/{emailId}",subscribers:"/dashboard/company/{companyId}/subscribers",sentEmails:"/dashboard/company/{companyId}/sent-emails",emailSend:"/dashboard/company/{companyId}/sent-emails/{emailSendId}",segments:"/dashboard/company/{companyId}/segments",metrics:"/dashboard/company/{companyId}/metrics",transactional:"/dashboard/company/{companyId}/transactional",transactionalEmail:"/dashboard/company/{companyId}/transactional/{transactionalId}",domain:"/dashboard/company/{companyId}/settings/domain/{domainId}",domainVerify:"/dashboard/company/{companyId}/settings/domain/{domainId}/verify"};function qM(Q){let X=(Q??process.env.SEQUENZY_APP_URL??"https://sequenzy.com").trim().replace(/\/+$/,"");return X.length>0?X:"https://sequenzy.com"}function h0(Q){let Y=Q?.trim();return Y?Y:void 0}function t0(Q){return encodeURIComponent(Q)}function Q0(Q,Y){return`${Q}${Y}`}function Y0(Q,Y=""){return`/dashboard/company/${t0(Q)}${Y}`}function B5(Q,Y,X){return Q0(Q,`${Y0(Y,"/settings")}?tab=${encodeURIComponent(X)}`)}function OM(Q,Y){let X=S9.map((W)=>[W,Y?B5(Q,Y,W):""]);return Object.fromEntries(X)}function B1(Q={},Y){let X=qM(Y),W=h0(Q.companyId),G={},$=OM(X,W);if(!W)return{appUrl:X,routeTemplates:D5,settingsTabValues:S9,urls:G,settingsUrls:$};G.dashboard=Q0(X,Y0(W)),G.campaigns=Q0(X,Y0(W,"/campaign")),G.sequences=Q0(X,Y0(W,"/sequences")),G.settings=Q0(X,Y0(W,"/settings")),G.emails=Q0(X,Y0(W,"/emails")),G.subscribers=Q0(X,Y0(W,"/subscribers")),G.sentEmails=Q0(X,Y0(W,"/sent-emails")),G.segments=Q0(X,Y0(W,"/segments")),G.metrics=Q0(X,Y0(W,"/metrics")),G.transactional=Q0(X,Y0(W,"/transactional"));let J=h0(Q.campaignId);if(J)G.campaign=Q0(X,Y0(W,`/campaign/${t0(J)}`)),G.campaignPreview=`${G.campaign}?step=review`;let z=h0(Q.sequenceId);if(z)G.sequence=Q0(X,Y0(W,`/sequences/${t0(z)}`));let H=h0(Q.emailId)??h0(Q.templateId);if(H)G.email=Q0(X,Y0(W,`/emails/${t0(H)}`)),G.template=G.email;let A=h0(Q.transactionalId);if(A)G.transactionalEmail=Q0(X,Y0(W,`/transactional/${t0(A)}`));let U=h0(Q.emailSendId);if(U)G.emailSend=Q0(X,Y0(W,`/sent-emails/${t0(U)}`));let K=h0(Q.domainId);if(K)G.domain=Q0(X,Y0(W,`/settings/domain/${t0(K)}`)),G.domainVerify=`${G.domain}/verify`;let D=h0(Q.status);if(D)G.campaignList=Q0(X,Y0(W,`/campaign/list/${t0(D)}`)),G.sequenceList=Q0(X,Y0(W,`/sequences/list/${t0(D)}`));let L=h0(Q.settingsTab);if(L)G.settingsTab=B5(X,W,L);return{appUrl:X,routeTemplates:D5,settingsTabValues:S9,urls:G,settingsUrls:$}}var L5=[{uri:"sequenzy://dashboard",name:"Dashboard Overview",description:"Live overview stats for the last 7 days",mimeType:"application/json"},{uri:"sequenzy://company",name:"Current Company",description:"The currently selected company, including localization settings",mimeType:"application/json"},{uri:"sequenzy://campaigns/recent",name:"Recent Campaigns",description:"Last 10 campaigns with status and basic stats",mimeType:"application/json"},{uri:"sequenzy://subscribers/recent",name:"Recent Subscribers",description:"Most recently added subscribers",mimeType:"application/json"},{uri:"sequenzy://subscribers/engaged",name:"Engaged Subscribers",description:"Most active/engaged subscribers",mimeType:"application/json"},{uri:"sequenzy://sequences",name:"Sequences",description:"All email sequences with status",mimeType:"application/json"},{uri:"sequenzy://templates",name:"Templates",description:"All available email templates with localization status",mimeType:"application/json"},{uri:"sequenzy://segments",name:"Segments",description:"All defined segments with subscriber counts",mimeType:"application/json"},{uri:"sequenzy://tags",name:"Tags",description:"All tags with usage counts",mimeType:"application/json"},{uri:"sequenzy://health",name:"Deliverability Health",description:"Email deliverability metrics and health status",mimeType:"application/json"},{uri:"sequenzy://app-routes",name:"Dashboard URL Routes",description:"Route templates and settings tabs for building Sequenzy dashboard links",mimeType:"application/json"}];async function F5(Q){try{let Y;switch(Q){case"sequenzy://dashboard":Y=await N("GET","/api/v1/metrics?period=7d");break;case"sequenzy://company":{let X=await N("GET","/api/v1/account"),W=s0()??X.currentCompanyId;if(!W)throw Error("No company available. Create or select a company first.");Y=await N("GET",`/api/v1/companies/${W}`);break}case"sequenzy://campaigns/recent":Y=await N("GET","/api/v1/campaigns?limit=10");break;case"sequenzy://subscribers/recent":Y=await N("GET","/api/v1/subscribers?sort=createdAt&limit=20");break;case"sequenzy://subscribers/engaged":Y=await N("GET","/api/v1/subscribers?sort=engagement&limit=20");break;case"sequenzy://sequences":Y=await N("GET","/api/v1/sequences");break;case"sequenzy://templates":Y=await N("GET","/api/v1/templates");break;case"sequenzy://segments":Y=await N("GET","/api/v1/segments");break;case"sequenzy://tags":Y=await N("GET","/api/v1/tags");break;case"sequenzy://health":Y=await N("GET","/api/v1/health/deliverability");break;case"sequenzy://app-routes":Y=B1();break;default:throw Error(`Unknown resource: ${Q}`)}return{contents:[{uri:Q,mimeType:"application/json",text:JSON.stringify(Y,null,2)}]}}catch(Y){return{contents:[{uri:Q,mimeType:"text/plain",text:a0(Y)}]}}}var h4="Sequenzy email blocks. Use `styles` for per-block background, text color, padding, border radius, border width, and border color. Top-level style aliases such as `backgroundColor`, `borderColor`, `borderWidth`, and `borderRadius` are also accepted and saved under `styles`. Use this for editor-compatible content, including conditional and repeat blocks. Repeat blocks use { type: 'repeat', source: 'items', itemAlias: 'item', children: [...] }.",A6="Replacement Sequenzy email blocks. Use `styles` for per-block background, text color, padding, border radius, border width, and border color. Top-level style aliases such as `backgroundColor`, `borderColor`, `borderWidth`, and `borderRadius` are also accepted and saved under `styles`.",M5="Sequenzy email blocks. Provide blocks or html for email steps. Use `styles` for per-block background, text color, padding, border radius, border width, and border color. Top-level style aliases such as `backgroundColor`, `borderColor`, `borderWidth`, and `borderRadius` are also accepted and saved under `styles`. Blocks can include repeat blocks over array variables such as items.",MM={type:"object",properties:{id:{type:"string",description:"Optional filter ID. Any stable string works; one will be generated if omitted."},field:{type:"string",enum:["status","tag","email","emailProvider","added","firstName","lastName","list","emailSent","emailOpened","emailClicked","emailBounced","emailComplained","attribute","event","segment","stripeProduct","stripeCurrentProduct","stripeTrialProduct"],description:"Filter field. Use `event` for custom subscriber events, `segment` for saved segment membership, and `stripeProduct`/`stripeCurrentProduct`/`stripeTrialProduct` for Stripe product-based segments. Engagement fields (`emailSent`, `emailOpened`, `emailClicked`, `emailBounced`, `emailComplained`) accept a time range as the value or a specific campaign via `campaign:<campaign_id>`."},operator:{type:"string",enum:["is","is_not","is_empty","is_not_empty","contains","not_contains","less_than","more_than","at_least","less_than_count","gte","lte","gt","lt"],description:"Filter operator. Use `is_empty` or `is_not_empty` for fields that can be blank, including custom attributes. For `stripeProduct`, use `is` or `is_not` with a raw product ID, and `at_least` or `less_than_count` with `productId:count`. For `event`, use `is`, `is_not`, `at_least`, or `less_than_count`. For engagement fields, use `is` (event happened) or `is_not` (event did not happen)."},value:{type:"string",description:"Filter value. For custom attribute empty checks, use `attributeName:` such as `last_logged_in:`. Event examples: `saas.purchase:30d`, `saas.purchase:all`, or `saas.purchase:5:30d` for thresholds. Segment values are segment IDs. Stripe product examples: `prod_123` for bought/didn't buy, `prod_123:3` for payment thresholds. Engagement examples: `7d`, `30d`, `90d`, `180d`, `all` for rolling time windows, or `campaign:<campaign_id>` to scope to a specific sent campaign (use `list_campaigns` to find IDs)."}},required:["field","operator","value"],additionalProperties:!1},VM={type:"object",properties:{kind:{type:"string",enum:["group"]},id:{type:"string",description:"Stable group ID. Any string works; one will be generated if omitted."},joinOperator:{type:"string",enum:["and","or"],description:"How children in this group combine."},children:{type:"array",minItems:1,items:{type:"object",description:'Either a filter leaf (`kind: "filter"`) or another group (`kind: "group"`).'}}},required:["kind","joinOperator","children"],additionalProperties:!0};function V5(Q){if(!Array.isArray(Q))return Q;return Q.map((Y)=>{if(typeof Y!=="object"||Y===null)return Y;let X=Y;if(typeof X.id==="string"&&X.id.trim()!=="")return X;return{...X,id:crypto.randomUUID()}})}function N5(Q){if(typeof Q!=="object"||Q===null)return Q;let Y=Q;if(Y.kind==="filter"){let X=V5([Y]);return Array.isArray(X)?X[0]:Y}if(Y.kind!=="group")return Q;return{...Y,id:typeof Y.id==="string"&&Y.id.trim()!==""?Y.id:crypto.randomUUID(),children:Array.isArray(Y.children)?Y.children.map(N5):[]}}function b1(Q,Y,X){if(Y.html!==void 0&&Y.blocks!==void 0)throw Error(`Provide either \`html\` or \`blocks\` when calling \`${Q}\`, not both.`);if(Y.blocks!==void 0&&!Array.isArray(Y.blocks))throw Error(`\`blocks\` must be an array when calling \`${Q}\`.`);if(X?.requireContent&&Y.html===void 0&&Y.blocks===void 0)throw Error(`Provide either \`html\` or \`blocks\` when calling \`${Q}\`.`)}function K6(Q,Y){if(Y.labels===void 0)return;if(!Array.isArray(Y.labels))throw Error(`\`labels\` must be an array when calling \`${Q}\`.`);if(Y.labels.some((X)=>typeof X!=="string"||X.trim().length===0))throw Error(`\`labels\` must contain only non-empty strings when calling \`${Q}\`.`)}function NM(Q){let Y=Q.filters!==void 0,X=Q.root!==void 0;if(Y&&X)throw Error("Provide either `filters` or `root` when calling `create_segment`, not both.");if(!Y&&!X)throw Error("Provide either `filters` or `root` when calling `create_segment`.");if(Y){if(!Array.isArray(Q.filters))throw Error("`filters` must be an array when calling `create_segment`.");if(Q.filters.length===0)throw Error("`filters` must include at least one filter when calling `create_segment`.")}if(X&&(typeof Q.root!=="object"||Q.root===null))throw Error("`root` must be an object when calling `create_segment`.")}function ZM(Q){if(Q.clearEnrollmentFieldPath===!0&&Q.enrollmentFieldPath!==void 0)throw Error("Provide either `enrollmentFieldPath` or `clearEnrollmentFieldPath` when calling `update_sequence`, not both.");let Y={...Q};if(delete Y.clearEnrollmentFieldPath,Q.clearEnrollmentFieldPath===!0)Y.enrollmentFieldPath=null;return Y}function wM(Q){let Y=I(Q,"subscriberId"),X=Q.fieldValues,W=X===void 0?void 0:Array.isArray(X)?X:void 0;if(X!==void 0&&W===void 0)throw Error("`fieldValues` must be an array when calling `cancel_sequence_enrollments`.");let G=W?.map((z)=>typeof z==="string"?z.trim():"").filter((z)=>z.length>0)??[];if(W?.some((z)=>typeof z!=="string")||W!==void 0&&G.length===0)throw Error("`fieldValues` must contain at least one non-empty string when calling `cancel_sequence_enrollments`.");if(Y!==void 0===G.length>0)throw Error("Provide exactly one target when calling `cancel_sequence_enrollments`: `subscriberId` or `fieldValues`.");let $=I(Q,"fieldPath"),J=I(Q,"reason");return{...Y!==void 0&&{subscriberId:Y},...$!==void 0&&{fieldPath:$},...G.length>0&&{fieldValues:G},...typeof Q.dryRun==="boolean"&&{dryRun:Q.dryRun},...J!==void 0&&{reason:J}}}function bM(Q){b1("create_campaign",Q),K6("create_campaign",Q);let Y=I(Q,"prompt")!==void 0,X=Q.html!==void 0,W=Q.blocks!==void 0,G=Q.templateId!==void 0;if(Q.prompt!==void 0&&!Y)throw Error("`prompt` cannot be empty when calling `create_campaign`.");if(Y&&(X||W||G))throw Error("Provide either `prompt`, `html`, `blocks`, or `templateId` when calling `create_campaign`, not multiple content sources.");if(!Y&&(Q.style!==void 0||Q.tone!==void 0))throw Error("`style` and `tone` can only be used with `prompt` when calling `create_campaign`.");if(!Y&&I(Q,"subject")===void 0)throw Error("`subject` is required unless `prompt` is provided when calling `create_campaign`.")}function PM(Q){if(I(Q,"scheduledAt")===void 0)throw Error("`scheduledAt` is required when calling `schedule_campaign`.");if(Q.targetLists!==void 0&&!B0(Q.targetLists))throw Error("`targetLists` must be an object when calling `schedule_campaign`.");if(Q.sendTimeOptimization!==void 0){if(typeof Q.sendTimeOptimization!=="boolean")throw Error("`sendTimeOptimization` must be a boolean when calling `schedule_campaign`.")}if(Q.spreadOverHours!==void 0){if(typeof Q.spreadOverHours!=="number"||!Number.isInteger(Q.spreadOverHours)||Q.spreadOverHours<1||Q.spreadOverHours>72)throw Error("`spreadOverHours` must be an integer between 1 and 72 when calling `schedule_campaign`.")}}function IM(Q){b1("create_transactional_email",Q);let Y=I(Q,"prompt")!==void 0,X=Q.html!==void 0,W=Q.blocks!==void 0;if(Q.prompt!==void 0&&!Y)throw Error("`prompt` cannot be empty when calling `create_transactional_email`.");if(Y&&(X||W))throw Error("Provide either `prompt`, `html`, or `blocks` when calling `create_transactional_email`, not multiple content sources.");if(!Y&&(Q.style!==void 0||Q.tone!==void 0))throw Error("`style` and `tone` can only be used with `prompt` when calling `create_transactional_email`.");if(!Y&&!X&&!W)throw Error("Provide either `prompt`, `html`, or `blocks` when calling `create_transactional_email`.");if(!Y&&I(Q,"subject")===void 0)throw Error("`subject` is required unless `prompt` is provided when calling `create_transactional_email`.")}var q5={type:"object",description:"A step to create inside a branch path. Use type:'delay' for a standalone delay, type:'email' for an email, or type:'create_discount' for a discount action.",properties:{type:{type:"string",enum:["email","delay","create_discount","discount","webhook"],description:"Branch path step type. Omit for email steps; use delay for standalone waits."},nodeType:{type:"string",enum:["logic_delay","action_email","action_create_discount","action_add_tag","action_remove_tag","action_add_to_list","action_remove_from_list","action_update_attributes","logic_wait_for_event","action_webhook"],description:"Advanced branch path node type. Prefer type unless creating a non-email action."},config:{type:"object",description:"Config for advanced nodeType steps such as tag/list/webhook/wait-for-event actions.",additionalProperties:!0},subject:{type:"string",description:"Email subject. Required for email steps."},previewText:{type:"string",description:"Email preview text."},blocks:{type:"array",description:M5,items:{type:"object"}},html:{type:"string",description:"HTML content for email steps."},delay:{type:"object",description:"Delay before this step, or the delay duration when type is delay.",properties:{days:{type:"number"},hours:{type:"number"},minutes:{type:"number"}}},delayMs:{type:"number",description:"Delay in milliseconds. Useful for standalone type:'delay' steps."},name:{type:"string",description:"Email template name for email steps."},discount:{type:"object",description:"Discount configuration for create_discount steps. Same shape as create_sequence steps.",additionalProperties:!0},label:{type:"string",description:"Node label for discount or advanced node steps."},provider:{type:"string",enum:["stripe","shopify"]},discountType:{type:"string",enum:["percent","amount"]},percentOff:{type:"number"},amountOff:{type:"number"},currency:{type:"string"},duration:{type:"string",enum:["once","forever","repeating"]},durationInMonths:{type:"number"},appliesToAllPlans:{type:"boolean"},planIds:{type:"array",items:{type:"string"}},codePrefix:{type:"string"},maxRedemptions:{type:"number"},lockToSubscriber:{type:"boolean"},expiresAt:{type:"string"},expiresInHours:{type:"number"}},additionalProperties:!1};function jM(Q){if(!Q||typeof Q!=="object")return null;let Y=Q;if(Y.success!==!1)return null;if(typeof Y.error==="string")return Error(Y.error);if(Y.error&&typeof Y.error==="object"&&typeof Y.error.message==="string")return Error(Y.error.message);if(typeof Y.message==="string")return Error(Y.message);return Error("The tool returned an unsuccessful response.")}function B0(Q){return typeof Q==="object"&&Q!==null&&!Array.isArray(Q)}function O5(Q){return Q.trim().toLowerCase().replace(/\s+/g,"-")}function EM(Q){let Y=new URLSearchParams;if(typeof Q.query==="string"&&Q.query.trim()!=="")Y.set("query",Q.query.trim());if(Array.isArray(Q.tags)&&Q.tags.length>0)Y.set("tags",Q.tags.filter((X)=>typeof X==="string"&&X.trim()!=="").join(","));if(typeof Q.segmentId==="string"&&Q.segmentId.trim()!=="")Y.set("segmentId",Q.segmentId);if(typeof Q.status==="string"&&Q.status.trim()!=="")Y.set("status",Q.status.trim());return Y.set("page",String(Q.page)),Y.set("limit",String(Q.pageSize)),Y}async function TM(Q,Y){let X=typeof Q.limit==="number"&&Number.isFinite(Q.limit)?Math.max(1,Math.trunc(Q.limit)):void 0,W=Math.min(100,Math.max(1,X??100)),G=[],$=1,J=0,z=0,H=0;while(!0){let U=EM({query:Q.query,tags:Q.tags,segmentId:Q.segmentId,status:Q.status,page:$,pageSize:W}),K=await N("GET",`/api/v1/subscribers?${U.toString()}`,void 0,Y);J=K.pagination?.total??K.subscribers.length,z=K.pagination?.totalPages??1,H+=1,G.push(...K.subscribers??[]);let D=X!==void 0&&G.length>=X,L=K.pagination?$>=K.pagination.totalPages:(K.subscribers??[]).length<W;if(D||L)break;$+=1}let A=X!==void 0?G.slice(0,X):G;return{success:!0,subscribers:A,pagination:{page:1,limit:W,total:J,totalPages:z,fetchedPages:H},returned:A.length,truncated:X!==void 0&&J>0&&A.length<J}}function SM(Q){let Y=typeof Q.email==="string"&&Q.email.trim()!==""?Q.email.trim():void 0,X=typeof Q.externalId==="string"&&Q.externalId.trim()!==""?Q.externalId.trim():void 0;return{...Y?{email:Y}:{},...X?{externalId:X}:{}}}function f4(Q,Y){let X=SM(Y);if(!X.email&&!X.externalId)throw Error(`Provide either \`email\` or \`externalId\` when calling \`${Q}\`.`);return X}function C9(Q){if(Q.email)return`/api/v1/subscribers/${encodeURIComponent(Q.email)}`;return`/api/v1/subscribers/external?externalId=${encodeURIComponent(String(Q.externalId))}`}async function R9(Q,Y){return N("GET",C9(Q),void 0,Y)}function I(Q,Y){let X=Q[Y];if(typeof X!=="string")return;let W=X.trim();return W.length>0?W:void 0}async function Z5(Q){let Y=I(Q,"companyId");if(Y)return Y;let X=s0();if(X)return X;try{return(await N("GET","/api/v1/account")).currentCompanyId??void 0}catch{return}}function l4(Q,Y){if(!B0(Q)||!Y)return Q;return{...Q,url:Y}}function w5(Q,Y){if(!B0(Q))return Q;return{...Q,...Y.campaign!==void 0&&{url:Y.campaign},...Y.campaignPreview!==void 0&&{previewUrl:Y.campaignPreview}}}function U6(Q,Y,X){if(!Array.isArray(Q)||!Y)return Q;return Q.map((W)=>{if(!B0(W))return W;let G=I(W,"id");if(!G)return W;let $=B1({companyId:Y,...X==="campaign"&&{campaignId:G},...X==="sequence"&&{sequenceId:G},...X==="template"&&{emailId:G},...X==="transactional"&&{transactionalId:G}});if(X==="campaign")return w5(W,$.urls);let J=X==="sequence"?$.urls.sequence:X==="template"?$.urls.email:$.urls.transactionalEmail;return l4(W,J)})}function RM(Q){if(!Array.isArray(Q))return Q;return Q.map((Y)=>{if(!B0(Y))return Y;let X=I(Y,"id");if(!X)return Y;let W=B1({companyId:X});return{...Y,url:W.urls.dashboard,settingsUrl:W.urls.settings}})}var CM=new Set(["get_account","select_company","create_company","get_company","list_campaigns","get_campaign","get_email_send","create_campaign","update_campaign","schedule_campaign","send_test_email","list_sequences","get_sequence","create_sequence","update_sequence","enable_sequence","disable_sequence","cancel_sequence_enrollments","list_ab_tests","get_ab_test","get_ab_test_stats","update_ab_test_variant","list_templates","get_template","create_template","update_template","list_transactional_emails","get_transactional_email","create_transactional_email","update_transactional_email"]);async function kM(Q,Y,X){if(!B0(X)||!CM.has(Q))return X;let W=B0(X.company)?X.company:void 0,$=I(X,"selectedCompanyId")??I(X,"currentCompanyId")??I(X,"companyId")??(W?I(W,"id"):void 0)??(W?I(W,"companyId"):void 0)??await Z5(Y);if(!$)return X;let J=B0(X.campaign)?X.campaign:void 0,z=B0(X.sequence)?X.sequence:void 0,H=B0(X.template)?X.template:void 0,A=B0(X.transactional)&&!Array.isArray(X.transactional)?X.transactional:void 0,U={companyId:$,campaignId:I(Y,"campaignId")??I(X,"campaignId")??(J?I(J,"id"):void 0),sequenceId:I(Y,"sequenceId")??I(X,"sequenceId")??(z?I(z,"id"):void 0),emailId:I(X,"templateId")??(H?I(H,"id"):void 0)??(A?I(A,"emailId"):void 0)??I(Y,"templateId"),transactionalId:I(Y,"transactionalId")??(A?I(A,"id"):void 0)??I(Y,"idOrSlug"),emailSendId:I(Y,"emailSendId")??I(X,"emailSendId")??(B0(X.emailSend)?I(X.emailSend,"id"):void 0),status:I(Y,"status")},K=B1(U),D=W?B1({companyId:$}):void 0;return{...X,...Array.isArray(X.companies)&&{companies:RM(X.companies)},...Array.isArray(X.campaigns)&&{campaigns:U6(X.campaigns,$,"campaign")},...Array.isArray(X.sequences)&&{sequences:U6(X.sequences,$,"sequence")},...Array.isArray(X.templates)&&{templates:U6(X.templates,$,"template")},...Array.isArray(X.transactional)&&{transactional:U6(X.transactional,$,"transactional")},...W&&D!==void 0&&{company:{...W,url:D.urls.dashboard,settingsUrl:D.urls.settings}},...J&&K.urls.campaign!==void 0&&{campaign:w5(J,K.urls)},...z&&K.urls.sequence!==void 0&&{sequence:l4(z,K.urls.sequence)},...H&&K.urls.email!==void 0&&{template:l4(H,K.urls.email)},...A&&K.urls.transactionalEmail!==void 0&&{transactional:l4(A,K.urls.transactionalEmail)},...B0(X.emailSend)&&K.urls.emailSend!==void 0&&{emailSend:l4(X.emailSend,K.urls.emailSend)},appUrls:K.urls}}var b5=[{name:"get_account",description:`Get current account information including available companies. IMPORTANT: If you have access to multiple companies, you MUST either:
29
+ `)}L.write("payload.value = newResult;"),L.write("return payload;");let S=L.compile();return(E,x)=>S(D,E,x)},$,J=F1,z=!c4.jitless,A=z&&N6.value,U=Y.catchall,K;Q._zod.parse=(D,L)=>{K??(K=W.value);let q=D.value;if(!J(q))return D.issues.push({expected:"object",code:"invalid_type",input:q,inst:Q}),D;if(z&&A&&L?.async===!1&&L.jitless!==!0){if(!$)$=G(Y.shape);if(D=$(D,L),!U)return D;return y8([],q,D,L,K,Q)}return X(D,L)}});function sX(Q,Y,X,W){for(let $ of Q)if($.issues.length===0)return Y.value=$.value,Y;let G=Q.filter(($)=>!X1($));if(G.length===1)return Y.value=G[0].value,G[0];return Y.issues.push({code:"invalid_union",input:Y.value,inst:X,errors:Q.map(($)=>$.issues.map((J)=>T0(J,W,w0())))}),Y}var k6=F("$ZodUnion",(Q,Y)=>{i.init(Q,Y),m(Q._zod,"optin",()=>Y.options.some((G)=>G._zod.optin==="optional")?"optional":void 0),m(Q._zod,"optout",()=>Y.options.some((G)=>G._zod.optout==="optional")?"optional":void 0),m(Q._zod,"values",()=>{if(Y.options.every((G)=>G._zod.values))return new Set(Y.options.flatMap((G)=>Array.from(G._zod.values)));return}),m(Q._zod,"pattern",()=>{if(Y.options.every((G)=>G._zod.pattern)){let G=Y.options.map(($)=>$._zod.pattern);return new RegExp(`^(${G.map(($)=>d1($.source)).join("|")})$`)}return});let X=Y.options.length===1,W=Y.options[0]._zod.run;Q._zod.parse=(G,$)=>{if(X)return W(G,$);let J=!1,z=[];for(let H of Y.options){let A=H._zod.run({value:G.value,issues:[]},$);if(A instanceof Promise)z.push(A),J=!0;else{if(A.issues.length===0)return A;z.push(A)}}if(!J)return sX(z,G,Q,$);return Promise.all(z).then((H)=>{return sX(H,G,Q,$)})}}),u8=F("$ZodDiscriminatedUnion",(Q,Y)=>{k6.init(Q,Y);let X=Q._zod.parse;m(Q._zod,"propValues",()=>{let G={};for(let $ of Y.options){let J=$._zod.propValues;if(!J||Object.keys(J).length===0)throw Error(`Invalid discriminated union option at index "${Y.options.indexOf($)}"`);for(let[z,H]of Object.entries(J)){if(!G[z])G[z]=new Set;for(let A of H)G[z].add(A)}}return G});let W=I1(()=>{let G=Y.options,$=new Map;for(let J of G){let z=J._zod.propValues?.[Y.discriminator];if(!z||z.size===0)throw Error(`Invalid discriminated union option at index "${Y.options.indexOf(J)}"`);for(let H of z){if($.has(H))throw Error(`Duplicate discriminator value "${String(H)}"`);$.set(H,J)}}return $});Q._zod.parse=(G,$)=>{let J=G.value;if(!F1(J))return G.issues.push({code:"invalid_type",expected:"object",input:J,inst:Q}),G;let z=W.value.get(J?.[Y.discriminator]);if(z)return z._zod.run(G,$);if(Y.unionFallback)return X(G,$);return G.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:Y.discriminator,input:J,path:[Y.discriminator],inst:Q}),G}}),h8=F("$ZodIntersection",(Q,Y)=>{i.init(Q,Y),Q._zod.parse=(X,W)=>{let G=X.value,$=Y.left._zod.run({value:G,issues:[]},W),J=Y.right._zod.run({value:G,issues:[]},W);if($ instanceof Promise||J instanceof Promise)return Promise.all([$,J]).then(([H,A])=>{return eX(X,H,A)});return eX(X,$,J)}});function R6(Q,Y){if(Q===Y)return{valid:!0,data:Q};if(Q instanceof Date&&Y instanceof Date&&+Q===+Y)return{valid:!0,data:Q};if(Y1(Q)&&Y1(Y)){let X=Object.keys(Y),W=Object.keys(Q).filter(($)=>X.indexOf($)!==-1),G={...Q,...Y};for(let $ of W){let J=R6(Q[$],Y[$]);if(!J.valid)return{valid:!1,mergeErrorPath:[$,...J.mergeErrorPath]};G[$]=J.data}return{valid:!0,data:G}}if(Array.isArray(Q)&&Array.isArray(Y)){if(Q.length!==Y.length)return{valid:!1,mergeErrorPath:[]};let X=[];for(let W=0;W<Q.length;W++){let G=Q[W],$=Y[W],J=R6(G,$);if(!J.valid)return{valid:!1,mergeErrorPath:[W,...J.mergeErrorPath]};X.push(J.data)}return{valid:!0,data:X}}return{valid:!1,mergeErrorPath:[]}}function eX(Q,Y,X){if(Y.issues.length)Q.issues.push(...Y.issues);if(X.issues.length)Q.issues.push(...X.issues);if(X1(Q))return Q;let W=R6(Y.value,X.value);if(!W.valid)throw Error(`Unmergable intersection. Error path: ${JSON.stringify(W.mergeErrorPath)}`);return Q.value=W.data,Q}var f8=F("$ZodRecord",(Q,Y)=>{i.init(Q,Y),Q._zod.parse=(X,W)=>{let G=X.value;if(!Y1(G))return X.issues.push({expected:"record",code:"invalid_type",input:G,inst:Q}),X;let $=[];if(Y.keyType._zod.values){let J=Y.keyType._zod.values;X.value={};for(let H of J)if(typeof H==="string"||typeof H==="number"||typeof H==="symbol"){let A=Y.valueType._zod.run({value:G[H],issues:[]},W);if(A instanceof Promise)$.push(A.then((U)=>{if(U.issues.length)X.issues.push(...c0(H,U.issues));X.value[H]=U.value}));else{if(A.issues.length)X.issues.push(...c0(H,A.issues));X.value[H]=A.value}}let z;for(let H in G)if(!J.has(H))z=z??[],z.push(H);if(z&&z.length>0)X.issues.push({code:"unrecognized_keys",input:G,inst:Q,keys:z})}else{X.value={};for(let J of Reflect.ownKeys(G)){if(J==="__proto__")continue;let z=Y.keyType._zod.run({value:J,issues:[]},W);if(z instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(z.issues.length){X.issues.push({code:"invalid_key",origin:"record",issues:z.issues.map((A)=>T0(A,W,w0())),input:J,path:[J],inst:Q}),X.value[z.value]=z.value;continue}let H=Y.valueType._zod.run({value:G[J],issues:[]},W);if(H instanceof Promise)$.push(H.then((A)=>{if(A.issues.length)X.issues.push(...c0(J,A.issues));X.value[z.value]=A.value}));else{if(H.issues.length)X.issues.push(...c0(J,H.issues));X.value[z.value]=H.value}}}if($.length)return Promise.all($).then(()=>X);return X}});var l8=F("$ZodEnum",(Q,Y)=>{i.init(Q,Y);let X=M6(Y.entries),W=new Set(X);Q._zod.values=W,Q._zod.pattern=new RegExp(`^(${X.filter((G)=>Z6.has(typeof G)).map((G)=>typeof G==="string"?m0(G):G.toString()).join("|")})$`),Q._zod.parse=(G,$)=>{let J=G.value;if(W.has(J))return G;return G.issues.push({code:"invalid_value",values:X,input:J,inst:Q}),G}}),m8=F("$ZodLiteral",(Q,Y)=>{if(i.init(Q,Y),Y.values.length===0)throw Error("Cannot create literal schema with no valid values");Q._zod.values=new Set(Y.values),Q._zod.pattern=new RegExp(`^(${Y.values.map((X)=>typeof X==="string"?m0(X):X?m0(X.toString()):String(X)).join("|")})$`),Q._zod.parse=(X,W)=>{let G=X.value;if(Q._zod.values.has(G))return X;return X.issues.push({code:"invalid_value",values:Y.values,input:G,inst:Q}),X}});var c8=F("$ZodTransform",(Q,Y)=>{i.init(Q,Y),Q._zod.parse=(X,W)=>{if(W.direction==="backward")throw new i1(Q.constructor.name);let G=Y.transform(X.value,X);if(W.async)return(G instanceof Promise?G:Promise.resolve(G)).then((J)=>{return X.value=J,X});if(G instanceof Promise)throw new l0;return X.value=G,X}});function Q8(Q,Y){if(Q.issues.length&&Y===void 0)return{issues:[],value:void 0};return Q}var p8=F("$ZodOptional",(Q,Y)=>{i.init(Q,Y),Q._zod.optin="optional",Q._zod.optout="optional",m(Q._zod,"values",()=>{return Y.innerType._zod.values?new Set([...Y.innerType._zod.values,void 0]):void 0}),m(Q._zod,"pattern",()=>{let X=Y.innerType._zod.pattern;return X?new RegExp(`^(${d1(X.source)})?$`):void 0}),Q._zod.parse=(X,W)=>{if(Y.innerType._zod.optin==="optional"){let G=Y.innerType._zod.run(X,W);if(G instanceof Promise)return G.then(($)=>Q8($,X.value));return Q8(G,X.value)}if(X.value===void 0)return X;return Y.innerType._zod.run(X,W)}}),i8=F("$ZodNullable",(Q,Y)=>{i.init(Q,Y),m(Q._zod,"optin",()=>Y.innerType._zod.optin),m(Q._zod,"optout",()=>Y.innerType._zod.optout),m(Q._zod,"pattern",()=>{let X=Y.innerType._zod.pattern;return X?new RegExp(`^(${d1(X.source)}|null)$`):void 0}),m(Q._zod,"values",()=>{return Y.innerType._zod.values?new Set([...Y.innerType._zod.values,null]):void 0}),Q._zod.parse=(X,W)=>{if(X.value===null)return X;return Y.innerType._zod.run(X,W)}}),r8=F("$ZodDefault",(Q,Y)=>{i.init(Q,Y),Q._zod.optin="optional",m(Q._zod,"values",()=>Y.innerType._zod.values),Q._zod.parse=(X,W)=>{if(W.direction==="backward")return Y.innerType._zod.run(X,W);if(X.value===void 0)return X.value=Y.defaultValue,X;let G=Y.innerType._zod.run(X,W);if(G instanceof Promise)return G.then(($)=>Y8($,Y));return Y8(G,Y)}});function Y8(Q,Y){if(Q.value===void 0)Q.value=Y.defaultValue;return Q}var n8=F("$ZodPrefault",(Q,Y)=>{i.init(Q,Y),Q._zod.optin="optional",m(Q._zod,"values",()=>Y.innerType._zod.values),Q._zod.parse=(X,W)=>{if(W.direction==="backward")return Y.innerType._zod.run(X,W);if(X.value===void 0)X.value=Y.defaultValue;return Y.innerType._zod.run(X,W)}}),d8=F("$ZodNonOptional",(Q,Y)=>{i.init(Q,Y),m(Q._zod,"values",()=>{let X=Y.innerType._zod.values;return X?new Set([...X].filter((W)=>W!==void 0)):void 0}),Q._zod.parse=(X,W)=>{let G=Y.innerType._zod.run(X,W);if(G instanceof Promise)return G.then(($)=>X8($,Q));return X8(G,Q)}});function X8(Q,Y){if(!Q.issues.length&&Q.value===void 0)Q.issues.push({code:"invalid_type",expected:"nonoptional",input:Q.value,inst:Y});return Q}var o8=F("$ZodCatch",(Q,Y)=>{i.init(Q,Y),m(Q._zod,"optin",()=>Y.innerType._zod.optin),m(Q._zod,"optout",()=>Y.innerType._zod.optout),m(Q._zod,"values",()=>Y.innerType._zod.values),Q._zod.parse=(X,W)=>{if(W.direction==="backward")return Y.innerType._zod.run(X,W);let G=Y.innerType._zod.run(X,W);if(G instanceof Promise)return G.then(($)=>{if(X.value=$.value,$.issues.length)X.value=Y.catchValue({...X,error:{issues:$.issues.map((J)=>T0(J,W,w0()))},input:X.value}),X.issues=[];return X});if(X.value=G.value,G.issues.length)X.value=Y.catchValue({...X,error:{issues:G.issues.map(($)=>T0($,W,w0()))},input:X.value}),X.issues=[];return X}});var t8=F("$ZodPipe",(Q,Y)=>{i.init(Q,Y),m(Q._zod,"values",()=>Y.in._zod.values),m(Q._zod,"optin",()=>Y.in._zod.optin),m(Q._zod,"optout",()=>Y.out._zod.optout),m(Q._zod,"propValues",()=>Y.in._zod.propValues),Q._zod.parse=(X,W)=>{if(W.direction==="backward"){let $=Y.out._zod.run(X,W);if($ instanceof Promise)return $.then((J)=>e4(J,Y.in,W));return e4($,Y.in,W)}let G=Y.in._zod.run(X,W);if(G instanceof Promise)return G.then(($)=>e4($,Y.out,W));return e4(G,Y.out,W)}});function e4(Q,Y,X){if(Q.issues.length)return Q.aborted=!0,Q;return Y._zod.run({value:Q.value,issues:Q.issues},X)}var a8=F("$ZodReadonly",(Q,Y)=>{i.init(Q,Y),m(Q._zod,"propValues",()=>Y.innerType._zod.propValues),m(Q._zod,"values",()=>Y.innerType._zod.values),m(Q._zod,"optin",()=>Y.innerType._zod.optin),m(Q._zod,"optout",()=>Y.innerType._zod.optout),Q._zod.parse=(X,W)=>{if(W.direction==="backward")return Y.innerType._zod.run(X,W);let G=Y.innerType._zod.run(X,W);if(G instanceof Promise)return G.then(W8);return W8(G)}});function W8(Q){return Q.value=Object.freeze(Q.value),Q}var s8=F("$ZodCustom",(Q,Y)=>{W0.init(Q,Y),i.init(Q,Y),Q._zod.parse=(X,W)=>{return X},Q._zod.check=(X)=>{let W=X.value,G=Y.fn(W);if(G instanceof Promise)return G.then(($)=>G8($,X,W,Q));G8(G,X,W,Q);return}});function G8(Q,Y,X,W){if(!Q){let G={code:"custom",input:X,inst:W,path:[...W._zod.def.path??[]],continue:!W._zod.def.abort};if(W._zod.def.params)G.params=W._zod.def.params;Y.issues.push(j1(G))}}var wH=(Q)=>{let Y=typeof Q;switch(Y){case"number":return Number.isNaN(Q)?"NaN":"number";case"object":{if(Array.isArray(Q))return"array";if(Q===null)return"null";if(Object.getPrototypeOf(Q)!==Object.prototype&&Q.constructor)return Q.constructor.name}}return Y},bH=()=>{let Q={string:{unit:"characters",verb:"to have"},file:{unit:"bytes",verb:"to have"},array:{unit:"items",verb:"to have"},set:{unit:"items",verb:"to have"}};function Y(W){return Q[W]??null}let X={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",jwt:"JWT",template_literal:"input"};return(W)=>{switch(W.code){case"invalid_type":return`Invalid input: expected ${W.expected}, received ${wH(W.input)}`;case"invalid_value":if(W.values.length===1)return`Invalid input: expected ${n4(W.values[0])}`;return`Invalid option: expected one of ${p4(W.values,"|")}`;case"too_big":{let G=W.inclusive?"<=":"<",$=Y(W.origin);if($)return`Too big: expected ${W.origin??"value"} to have ${G}${W.maximum.toString()} ${$.unit??"elements"}`;return`Too big: expected ${W.origin??"value"} to be ${G}${W.maximum.toString()}`}case"too_small":{let G=W.inclusive?">=":">",$=Y(W.origin);if($)return`Too small: expected ${W.origin} to have ${G}${W.minimum.toString()} ${$.unit}`;return`Too small: expected ${W.origin} to be ${G}${W.minimum.toString()}`}case"invalid_format":{let G=W;if(G.format==="starts_with")return`Invalid string: must start with "${G.prefix}"`;if(G.format==="ends_with")return`Invalid string: must end with "${G.suffix}"`;if(G.format==="includes")return`Invalid string: must include "${G.includes}"`;if(G.format==="regex")return`Invalid string: must match pattern ${G.pattern}`;return`Invalid ${X[G.format]??W.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${W.divisor}`;case"unrecognized_keys":return`Unrecognized key${W.keys.length>1?"s":""}: ${p4(W.keys,", ")}`;case"invalid_key":return`Invalid key in ${W.origin}`;case"invalid_union":return"Invalid input";case"invalid_element":return`Invalid value in ${W.origin}`;default:return"Invalid input"}}};function v6(){return{localeError:bH()}}var YV=Symbol("ZodOutput"),XV=Symbol("ZodInput");class e8{constructor(){this._map=new WeakMap,this._idmap=new Map}add(Q,...Y){let X=Y[0];if(this._map.set(Q,X),X&&typeof X==="object"&&"id"in X){if(this._idmap.has(X.id))throw Error(`ID ${X.id} already exists in the registry`);this._idmap.set(X.id,Q)}return this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(Q){let Y=this._map.get(Q);if(Y&&typeof Y==="object"&&"id"in Y)this._idmap.delete(Y.id);return this._map.delete(Q),this}get(Q){let Y=Q._zod.parent;if(Y){let X={...this.get(Y)??{}};delete X.id;let W={...X,...this._map.get(Q)};return Object.keys(W).length?W:void 0}return this._map.get(Q)}has(Q){return this._map.has(Q)}}function PH(){return new e8}var Q4=PH();function QW(Q,Y){return new Q({type:"string",...j(Y)})}function YW(Q,Y){return new Q({type:"string",format:"email",check:"string_format",abort:!1,...j(Y)})}function x6(Q,Y){return new Q({type:"string",format:"guid",check:"string_format",abort:!1,...j(Y)})}function XW(Q,Y){return new Q({type:"string",format:"uuid",check:"string_format",abort:!1,...j(Y)})}function WW(Q,Y){return new Q({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...j(Y)})}function GW(Q,Y){return new Q({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...j(Y)})}function $W(Q,Y){return new Q({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...j(Y)})}function JW(Q,Y){return new Q({type:"string",format:"url",check:"string_format",abort:!1,...j(Y)})}function zW(Q,Y){return new Q({type:"string",format:"emoji",check:"string_format",abort:!1,...j(Y)})}function HW(Q,Y){return new Q({type:"string",format:"nanoid",check:"string_format",abort:!1,...j(Y)})}function AW(Q,Y){return new Q({type:"string",format:"cuid",check:"string_format",abort:!1,...j(Y)})}function UW(Q,Y){return new Q({type:"string",format:"cuid2",check:"string_format",abort:!1,...j(Y)})}function KW(Q,Y){return new Q({type:"string",format:"ulid",check:"string_format",abort:!1,...j(Y)})}function DW(Q,Y){return new Q({type:"string",format:"xid",check:"string_format",abort:!1,...j(Y)})}function BW(Q,Y){return new Q({type:"string",format:"ksuid",check:"string_format",abort:!1,...j(Y)})}function LW(Q,Y){return new Q({type:"string",format:"ipv4",check:"string_format",abort:!1,...j(Y)})}function FW(Q,Y){return new Q({type:"string",format:"ipv6",check:"string_format",abort:!1,...j(Y)})}function qW(Q,Y){return new Q({type:"string",format:"cidrv4",check:"string_format",abort:!1,...j(Y)})}function OW(Q,Y){return new Q({type:"string",format:"cidrv6",check:"string_format",abort:!1,...j(Y)})}function MW(Q,Y){return new Q({type:"string",format:"base64",check:"string_format",abort:!1,...j(Y)})}function VW(Q,Y){return new Q({type:"string",format:"base64url",check:"string_format",abort:!1,...j(Y)})}function NW(Q,Y){return new Q({type:"string",format:"e164",check:"string_format",abort:!1,...j(Y)})}function ZW(Q,Y){return new Q({type:"string",format:"jwt",check:"string_format",abort:!1,...j(Y)})}function wW(Q,Y){return new Q({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...j(Y)})}function bW(Q,Y){return new Q({type:"string",format:"date",check:"string_format",...j(Y)})}function PW(Q,Y){return new Q({type:"string",format:"time",check:"string_format",precision:null,...j(Y)})}function IW(Q,Y){return new Q({type:"string",format:"duration",check:"string_format",...j(Y)})}function jW(Q,Y){return new Q({type:"number",checks:[],...j(Y)})}function EW(Q,Y){return new Q({type:"number",check:"number_format",abort:!1,format:"safeint",...j(Y)})}function TW(Q,Y){return new Q({type:"boolean",...j(Y)})}function SW(Q,Y){return new Q({type:"null",...j(Y)})}function RW(Q){return new Q({type:"unknown"})}function CW(Q,Y){return new Q({type:"never",...j(Y)})}function XQ(Q,Y){return new E6({check:"less_than",...j(Y),value:Q,inclusive:!1})}function Y4(Q,Y){return new E6({check:"less_than",...j(Y),value:Q,inclusive:!0})}function WQ(Q,Y){return new T6({check:"greater_than",...j(Y),value:Q,inclusive:!1})}function X4(Q,Y){return new T6({check:"greater_than",...j(Y),value:Q,inclusive:!0})}function GQ(Q,Y){return new gX({check:"multiple_of",...j(Y),value:Q})}function $Q(Q,Y){return new hX({check:"max_length",...j(Y),maximum:Q})}function E1(Q,Y){return new fX({check:"min_length",...j(Y),minimum:Q})}function JQ(Q,Y){return new lX({check:"length_equals",...j(Y),length:Q})}function _6(Q,Y){return new mX({check:"string_format",format:"regex",...j(Y),pattern:Q})}function y6(Q){return new cX({check:"string_format",format:"lowercase",...j(Q)})}function g6(Q){return new pX({check:"string_format",format:"uppercase",...j(Q)})}function u6(Q,Y){return new iX({check:"string_format",format:"includes",...j(Y),includes:Q})}function h6(Q,Y){return new rX({check:"string_format",format:"starts_with",...j(Y),prefix:Q})}function f6(Q,Y){return new nX({check:"string_format",format:"ends_with",...j(Y),suffix:Q})}function q1(Q){return new dX({check:"overwrite",tx:Q})}function l6(Q){return q1((Y)=>Y.normalize(Q))}function m6(){return q1((Q)=>Q.trim())}function c6(){return q1((Q)=>Q.toLowerCase())}function p6(){return q1((Q)=>Q.toUpperCase())}function kW(Q,Y,X){return new Q({type:"array",element:Y,...j(X)})}function vW(Q,Y,X){let W=j(X);return W.abort??(W.abort=!0),new Q({type:"custom",check:"custom",fn:Y,...W})}function xW(Q,Y,X){return new Q({type:"custom",check:"custom",fn:Y,...j(X)})}function _W(Q){let Y=IH((X)=>{return X.addIssue=(W)=>{if(typeof W==="string")X.issues.push(j1(W,X.value,Y._zod.def));else{let G=W;if(G.fatal)G.continue=!1;G.code??(G.code="custom"),G.input??(G.input=X.value),G.inst??(G.inst=Y),G.continue??(G.continue=!Y._zod.def.abort),X.issues.push(j1(G))}},Q(X.value,X)});return Y}function IH(Q,Y){let X=new W0({check:"custom",...j(Y)});return X._zod.check=Q,X}function T1(Q){return!!Q._zod}function W1(Q,Y){if(T1(Q))return a1(Q,Y);return Q.safeParse(Y)}function zQ(Q){if(!Q)return;let Y;if(T1(Q))Y=Q._zod?.def?.shape;else Y=Q.shape;if(!Y)return;if(typeof Y==="function")try{return Y()}catch{return}return Y}function yW(Q){if(T1(Q)){let $=Q._zod?.def;if($){if($.value!==void 0)return $.value;if(Array.isArray($.values)&&$.values.length>0)return $.values[0]}}let X=Q._def;if(X){if(X.value!==void 0)return X.value;if(Array.isArray(X.values)&&X.values.length>0)return X.values[0]}let W=Q.value;if(W!==void 0)return W;return}var G4={};u9(G4,{time:()=>n6,duration:()=>d6,datetime:()=>i6,date:()=>r6,ZodISOTime:()=>hW,ZodISODuration:()=>fW,ZodISODateTime:()=>gW,ZodISODate:()=>uW});var gW=F("ZodISODateTime",(Q,Y)=>{q8.init(Q,Y),d.init(Q,Y)});function i6(Q){return wW(gW,Q)}var uW=F("ZodISODate",(Q,Y)=>{O8.init(Q,Y),d.init(Q,Y)});function r6(Q){return bW(uW,Q)}var hW=F("ZodISOTime",(Q,Y)=>{M8.init(Q,Y),d.init(Q,Y)});function n6(Q){return PW(hW,Q)}var fW=F("ZodISODuration",(Q,Y)=>{V8.init(Q,Y),d.init(Q,Y)});function d6(Q){return IW(fW,Q)}var lW=(Q,Y)=>{d4.init(Q,Y),Q.name="ZodError",Object.defineProperties(Q,{format:{value:(X)=>s9(Q,X)},flatten:{value:(X)=>a9(Q,X)},addIssue:{value:(X)=>{Q.issues.push(X),Q.message=JSON.stringify(Q.issues,P1,2)}},addIssues:{value:(X)=>{Q.issues.push(...X),Q.message=JSON.stringify(Q.issues,P1,2)}},isEmpty:{get(){return Q.issues.length===0}}})},lV=F("ZodError",lW),N0=F("ZodError",lW,{Parent:Error});var mW=o4(N0),cW=t4(N0),pW=t1(N0),iW=s1(N0),rW=e9(N0),nW=QX(N0),dW=YX(N0),oW=XX(N0),tW=WX(N0),aW=GX(N0),sW=$X(N0),eW=JX(N0);var s=F("ZodType",(Q,Y)=>{return i.init(Q,Y),Q.def=Y,Q.type=Y.type,Object.defineProperty(Q,"_def",{value:Y}),Q.check=(...X)=>{return Q.clone(h.mergeDefs(Y,{checks:[...Y.checks??[],...X.map((W)=>typeof W==="function"?{_zod:{check:W,def:{check:"custom"},onattach:[]}}:W)]}))},Q.clone=(X,W)=>E0(Q,X,W),Q.brand=()=>Q,Q.register=(X,W)=>{return X.add(Q,W),Q},Q.parse=(X,W)=>mW(Q,X,W,{callee:Q.parse}),Q.safeParse=(X,W)=>pW(Q,X,W),Q.parseAsync=async(X,W)=>cW(Q,X,W,{callee:Q.parseAsync}),Q.safeParseAsync=async(X,W)=>iW(Q,X,W),Q.spa=Q.safeParseAsync,Q.encode=(X,W)=>rW(Q,X,W),Q.decode=(X,W)=>nW(Q,X,W),Q.encodeAsync=async(X,W)=>dW(Q,X,W),Q.decodeAsync=async(X,W)=>oW(Q,X,W),Q.safeEncode=(X,W)=>tW(Q,X,W),Q.safeDecode=(X,W)=>aW(Q,X,W),Q.safeEncodeAsync=async(X,W)=>sW(Q,X,W),Q.safeDecodeAsync=async(X,W)=>eW(Q,X,W),Q.refine=(X,W)=>Q.check(ZA(X,W)),Q.superRefine=(X)=>Q.check(wA(X)),Q.overwrite=(X)=>Q.check(q1(X)),Q.optional=()=>a(Q),Q.nullable=()=>XG(Q),Q.nullish=()=>a(XG(Q)),Q.nonoptional=(X)=>FA(Q,X),Q.array=()=>_(Q),Q.or=(X)=>p([Q,X]),Q.and=(X)=>AQ(Q,X),Q.transform=(X)=>t6(Q,zG(X)),Q.default=(X)=>DA(Q,X),Q.prefault=(X)=>LA(Q,X),Q.catch=(X)=>OA(Q,X),Q.pipe=(X)=>t6(Q,X),Q.readonly=()=>NA(Q),Q.describe=(X)=>{let W=Q.clone();return Q4.add(W,{description:X}),W},Object.defineProperty(Q,"description",{get(){return Q4.get(Q)?.description},configurable:!0}),Q.meta=(...X)=>{if(X.length===0)return Q4.get(Q);let W=Q.clone();return Q4.add(W,X[0]),W},Q.isOptional=()=>Q.safeParse(void 0).success,Q.isNullable=()=>Q.safeParse(null).success,Q}),WG=F("_ZodString",(Q,Y)=>{YQ.init(Q,Y),s.init(Q,Y);let X=Q._zod.bag;Q.format=X.format??null,Q.minLength=X.minimum??null,Q.maxLength=X.maximum??null,Q.regex=(...W)=>Q.check(_6(...W)),Q.includes=(...W)=>Q.check(u6(...W)),Q.startsWith=(...W)=>Q.check(h6(...W)),Q.endsWith=(...W)=>Q.check(f6(...W)),Q.min=(...W)=>Q.check(E1(...W)),Q.max=(...W)=>Q.check($Q(...W)),Q.length=(...W)=>Q.check(JQ(...W)),Q.nonempty=(...W)=>Q.check(E1(1,...W)),Q.lowercase=(W)=>Q.check(y6(W)),Q.uppercase=(W)=>Q.check(g6(W)),Q.trim=()=>Q.check(m6()),Q.normalize=(...W)=>Q.check(l6(...W)),Q.toLowerCase=()=>Q.check(c6()),Q.toUpperCase=()=>Q.check(p6())}),xH=F("ZodString",(Q,Y)=>{YQ.init(Q,Y),WG.init(Q,Y),Q.email=(X)=>Q.check(YW(_H,X)),Q.url=(X)=>Q.check(JW(yH,X)),Q.jwt=(X)=>Q.check(ZW(aH,X)),Q.emoji=(X)=>Q.check(zW(gH,X)),Q.guid=(X)=>Q.check(x6(QG,X)),Q.uuid=(X)=>Q.check(XW(HQ,X)),Q.uuidv4=(X)=>Q.check(WW(HQ,X)),Q.uuidv6=(X)=>Q.check(GW(HQ,X)),Q.uuidv7=(X)=>Q.check($W(HQ,X)),Q.nanoid=(X)=>Q.check(HW(uH,X)),Q.guid=(X)=>Q.check(x6(QG,X)),Q.cuid=(X)=>Q.check(AW(hH,X)),Q.cuid2=(X)=>Q.check(UW(fH,X)),Q.ulid=(X)=>Q.check(KW(lH,X)),Q.base64=(X)=>Q.check(MW(dH,X)),Q.base64url=(X)=>Q.check(VW(oH,X)),Q.xid=(X)=>Q.check(DW(mH,X)),Q.ksuid=(X)=>Q.check(BW(cH,X)),Q.ipv4=(X)=>Q.check(LW(pH,X)),Q.ipv6=(X)=>Q.check(FW(iH,X)),Q.cidrv4=(X)=>Q.check(qW(rH,X)),Q.cidrv6=(X)=>Q.check(OW(nH,X)),Q.e164=(X)=>Q.check(NW(tH,X)),Q.datetime=(X)=>Q.check(i6(X)),Q.date=(X)=>Q.check(r6(X)),Q.time=(X)=>Q.check(n6(X)),Q.duration=(X)=>Q.check(d6(X))});function B(Q){return QW(xH,Q)}var d=F("ZodStringFormat",(Q,Y)=>{r.init(Q,Y),WG.init(Q,Y)}),_H=F("ZodEmail",(Q,Y)=>{z8.init(Q,Y),d.init(Q,Y)});var QG=F("ZodGUID",(Q,Y)=>{$8.init(Q,Y),d.init(Q,Y)});var HQ=F("ZodUUID",(Q,Y)=>{J8.init(Q,Y),d.init(Q,Y)});var yH=F("ZodURL",(Q,Y)=>{H8.init(Q,Y),d.init(Q,Y)});var gH=F("ZodEmoji",(Q,Y)=>{A8.init(Q,Y),d.init(Q,Y)});var uH=F("ZodNanoID",(Q,Y)=>{U8.init(Q,Y),d.init(Q,Y)});var hH=F("ZodCUID",(Q,Y)=>{K8.init(Q,Y),d.init(Q,Y)});var fH=F("ZodCUID2",(Q,Y)=>{D8.init(Q,Y),d.init(Q,Y)});var lH=F("ZodULID",(Q,Y)=>{B8.init(Q,Y),d.init(Q,Y)});var mH=F("ZodXID",(Q,Y)=>{L8.init(Q,Y),d.init(Q,Y)});var cH=F("ZodKSUID",(Q,Y)=>{F8.init(Q,Y),d.init(Q,Y)});var pH=F("ZodIPv4",(Q,Y)=>{N8.init(Q,Y),d.init(Q,Y)});var iH=F("ZodIPv6",(Q,Y)=>{Z8.init(Q,Y),d.init(Q,Y)});var rH=F("ZodCIDRv4",(Q,Y)=>{w8.init(Q,Y),d.init(Q,Y)});var nH=F("ZodCIDRv6",(Q,Y)=>{b8.init(Q,Y),d.init(Q,Y)});var dH=F("ZodBase64",(Q,Y)=>{I8.init(Q,Y),d.init(Q,Y)});var oH=F("ZodBase64URL",(Q,Y)=>{j8.init(Q,Y),d.init(Q,Y)});var tH=F("ZodE164",(Q,Y)=>{E8.init(Q,Y),d.init(Q,Y)});var aH=F("ZodJWT",(Q,Y)=>{T8.init(Q,Y),d.init(Q,Y)});var GG=F("ZodNumber",(Q,Y)=>{C6.init(Q,Y),s.init(Q,Y),Q.gt=(W,G)=>Q.check(WQ(W,G)),Q.gte=(W,G)=>Q.check(X4(W,G)),Q.min=(W,G)=>Q.check(X4(W,G)),Q.lt=(W,G)=>Q.check(XQ(W,G)),Q.lte=(W,G)=>Q.check(Y4(W,G)),Q.max=(W,G)=>Q.check(Y4(W,G)),Q.int=(W)=>Q.check(YG(W)),Q.safe=(W)=>Q.check(YG(W)),Q.positive=(W)=>Q.check(WQ(0,W)),Q.nonnegative=(W)=>Q.check(X4(0,W)),Q.negative=(W)=>Q.check(XQ(0,W)),Q.nonpositive=(W)=>Q.check(Y4(0,W)),Q.multipleOf=(W,G)=>Q.check(GQ(W,G)),Q.step=(W,G)=>Q.check(GQ(W,G)),Q.finite=()=>Q;let X=Q._zod.bag;Q.minValue=Math.max(X.minimum??Number.NEGATIVE_INFINITY,X.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,Q.maxValue=Math.min(X.maximum??Number.POSITIVE_INFINITY,X.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,Q.isInt=(X.format??"").includes("int")||Number.isSafeInteger(X.multipleOf??0.5),Q.isFinite=!0,Q.format=X.format??null});function l(Q){return jW(GG,Q)}var sH=F("ZodNumberFormat",(Q,Y)=>{S8.init(Q,Y),GG.init(Q,Y)});function YG(Q){return EW(sH,Q)}var eH=F("ZodBoolean",(Q,Y)=>{R8.init(Q,Y),s.init(Q,Y)});function X0(Q){return TW(eH,Q)}var QA=F("ZodNull",(Q,Y)=>{C8.init(Q,Y),s.init(Q,Y)});function a6(Q){return SW(QA,Q)}var YA=F("ZodUnknown",(Q,Y)=>{k8.init(Q,Y),s.init(Q,Y)});function o(){return RW(YA)}var XA=F("ZodNever",(Q,Y)=>{v8.init(Q,Y),s.init(Q,Y)});function WA(Q){return CW(XA,Q)}var GA=F("ZodArray",(Q,Y)=>{x8.init(Q,Y),s.init(Q,Y),Q.element=Y.element,Q.min=(X,W)=>Q.check(E1(X,W)),Q.nonempty=(X)=>Q.check(E1(1,X)),Q.max=(X,W)=>Q.check($Q(X,W)),Q.length=(X,W)=>Q.check(JQ(X,W)),Q.unwrap=()=>Q.element});function _(Q,Y){return kW(GA,Q,Y)}var $G=F("ZodObject",(Q,Y)=>{g8.init(Q,Y),s.init(Q,Y),h.defineLazy(Q,"shape",()=>{return Y.shape}),Q.keyof=()=>L0(Object.keys(Q._zod.def.shape)),Q.catchall=(X)=>Q.clone({...Q._zod.def,catchall:X}),Q.passthrough=()=>Q.clone({...Q._zod.def,catchall:o()}),Q.loose=()=>Q.clone({...Q._zod.def,catchall:o()}),Q.strict=()=>Q.clone({...Q._zod.def,catchall:WA()}),Q.strip=()=>Q.clone({...Q._zod.def,catchall:void 0}),Q.extend=(X)=>{return h.extend(Q,X)},Q.safeExtend=(X)=>{return h.safeExtend(Q,X)},Q.merge=(X)=>h.merge(Q,X),Q.pick=(X)=>h.pick(Q,X),Q.omit=(X)=>h.omit(Q,X),Q.partial=(...X)=>h.partial(HG,Q,X[0]),Q.required=(...X)=>h.required(AG,Q,X[0])});function w(Q,Y){let X={type:"object",shape:Q??{},...h.normalizeParams(Y)};return new $G(X)}function U0(Q,Y){return new $G({type:"object",shape:Q,catchall:o(),...h.normalizeParams(Y)})}var JG=F("ZodUnion",(Q,Y)=>{k6.init(Q,Y),s.init(Q,Y),Q.options=Y.options});function p(Q,Y){return new JG({type:"union",options:Q,...h.normalizeParams(Y)})}var $A=F("ZodDiscriminatedUnion",(Q,Y)=>{JG.init(Q,Y),u8.init(Q,Y)});function s6(Q,Y,X){return new $A({type:"union",options:Y,discriminator:Q,...h.normalizeParams(X)})}var JA=F("ZodIntersection",(Q,Y)=>{h8.init(Q,Y),s.init(Q,Y)});function AQ(Q,Y){return new JA({type:"intersection",left:Q,right:Y})}var zA=F("ZodRecord",(Q,Y)=>{f8.init(Q,Y),s.init(Q,Y),Q.keyType=Y.keyType,Q.valueType=Y.valueType});function t(Q,Y,X){return new zA({type:"record",keyType:Q,valueType:Y,...h.normalizeParams(X)})}var o6=F("ZodEnum",(Q,Y)=>{l8.init(Q,Y),s.init(Q,Y),Q.enum=Y.entries,Q.options=Object.values(Y.entries);let X=new Set(Object.keys(Y.entries));Q.extract=(W,G)=>{let $={};for(let J of W)if(X.has(J))$[J]=Y.entries[J];else throw Error(`Key ${J} not found in enum`);return new o6({...Y,checks:[],...h.normalizeParams(G),entries:$})},Q.exclude=(W,G)=>{let $={...Y.entries};for(let J of W)if(X.has(J))delete $[J];else throw Error(`Key ${J} not found in enum`);return new o6({...Y,checks:[],...h.normalizeParams(G),entries:$})}});function L0(Q,Y){let X=Array.isArray(Q)?Object.fromEntries(Q.map((W)=>[W,W])):Q;return new o6({type:"enum",entries:X,...h.normalizeParams(Y)})}var HA=F("ZodLiteral",(Q,Y)=>{m8.init(Q,Y),s.init(Q,Y),Q.values=new Set(Y.values),Object.defineProperty(Q,"value",{get(){if(Y.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return Y.values[0]}})});function b(Q,Y){return new HA({type:"literal",values:Array.isArray(Q)?Q:[Q],...h.normalizeParams(Y)})}var AA=F("ZodTransform",(Q,Y)=>{c8.init(Q,Y),s.init(Q,Y),Q._zod.parse=(X,W)=>{if(W.direction==="backward")throw new i1(Q.constructor.name);X.addIssue=($)=>{if(typeof $==="string")X.issues.push(h.issue($,X.value,Y));else{let J=$;if(J.fatal)J.continue=!1;J.code??(J.code="custom"),J.input??(J.input=X.value),J.inst??(J.inst=Q),X.issues.push(h.issue(J))}};let G=Y.transform(X.value,X);if(G instanceof Promise)return G.then(($)=>{return X.value=$,X});return X.value=G,X}});function zG(Q){return new AA({type:"transform",transform:Q})}var HG=F("ZodOptional",(Q,Y)=>{p8.init(Q,Y),s.init(Q,Y),Q.unwrap=()=>Q._zod.def.innerType});function a(Q){return new HG({type:"optional",innerType:Q})}var UA=F("ZodNullable",(Q,Y)=>{i8.init(Q,Y),s.init(Q,Y),Q.unwrap=()=>Q._zod.def.innerType});function XG(Q){return new UA({type:"nullable",innerType:Q})}var KA=F("ZodDefault",(Q,Y)=>{r8.init(Q,Y),s.init(Q,Y),Q.unwrap=()=>Q._zod.def.innerType,Q.removeDefault=Q.unwrap});function DA(Q,Y){return new KA({type:"default",innerType:Q,get defaultValue(){return typeof Y==="function"?Y():h.shallowClone(Y)}})}var BA=F("ZodPrefault",(Q,Y)=>{n8.init(Q,Y),s.init(Q,Y),Q.unwrap=()=>Q._zod.def.innerType});function LA(Q,Y){return new BA({type:"prefault",innerType:Q,get defaultValue(){return typeof Y==="function"?Y():h.shallowClone(Y)}})}var AG=F("ZodNonOptional",(Q,Y)=>{d8.init(Q,Y),s.init(Q,Y),Q.unwrap=()=>Q._zod.def.innerType});function FA(Q,Y){return new AG({type:"nonoptional",innerType:Q,...h.normalizeParams(Y)})}var qA=F("ZodCatch",(Q,Y)=>{o8.init(Q,Y),s.init(Q,Y),Q.unwrap=()=>Q._zod.def.innerType,Q.removeCatch=Q.unwrap});function OA(Q,Y){return new qA({type:"catch",innerType:Q,catchValue:typeof Y==="function"?Y:()=>Y})}var MA=F("ZodPipe",(Q,Y)=>{t8.init(Q,Y),s.init(Q,Y),Q.in=Y.in,Q.out=Y.out});function t6(Q,Y){return new MA({type:"pipe",in:Q,out:Y})}var VA=F("ZodReadonly",(Q,Y)=>{a8.init(Q,Y),s.init(Q,Y),Q.unwrap=()=>Q._zod.def.innerType});function NA(Q){return new VA({type:"readonly",innerType:Q})}var UG=F("ZodCustom",(Q,Y)=>{s8.init(Q,Y),s.init(Q,Y)});function KG(Q,Y){return vW(UG,Q??(()=>!0),Y)}function ZA(Q,Y={}){return xW(UG,Q,Y)}function wA(Q){return _W(Q)}function e6(Q,Y){return t6(zG(Q),Y)}w0(v6());var QY="2025-11-25";var DG=[QY,"2025-06-18","2025-03-26","2024-11-05","2024-10-07"],G1="io.modelcontextprotocol/related-task",KQ="2.0",G0=KG((Q)=>Q!==null&&(typeof Q==="object"||typeof Q==="function")),BG=p([B(),l().int()]),LG=B(),yN=U0({ttl:p([l(),a6()]).optional(),pollInterval:l().optional()}),bA=w({ttl:l().optional()}),PA=w({taskId:B()}),YY=U0({progressToken:BG.optional(),[G1]:PA.optional()}),Z0=w({_meta:YY.optional()}),$4=Z0.extend({task:bA.optional()}),FG=(Q)=>$4.safeParse(Q).success,$0=w({method:B(),params:Z0.loose().optional()}),b0=w({_meta:YY.optional()}),P0=w({method:B(),params:b0.loose().optional()}),J0=U0({_meta:YY.optional()}),DQ=p([B(),l().int()]),qG=w({jsonrpc:b(KQ),id:DQ,...$0.shape}).strict(),XY=(Q)=>qG.safeParse(Q).success,OG=w({jsonrpc:b(KQ),...P0.shape}).strict(),MG=(Q)=>OG.safeParse(Q).success,WY=w({jsonrpc:b(KQ),id:DQ,result:J0}).strict(),J4=(Q)=>WY.safeParse(Q).success;var y;(function(Q){Q[Q.ConnectionClosed=-32000]="ConnectionClosed",Q[Q.RequestTimeout=-32001]="RequestTimeout",Q[Q.ParseError=-32700]="ParseError",Q[Q.InvalidRequest=-32600]="InvalidRequest",Q[Q.MethodNotFound=-32601]="MethodNotFound",Q[Q.InvalidParams=-32602]="InvalidParams",Q[Q.InternalError=-32603]="InternalError",Q[Q.UrlElicitationRequired=-32042]="UrlElicitationRequired"})(y||(y={}));var GY=w({jsonrpc:b(KQ),id:DQ.optional(),error:w({code:l().int(),message:B(),data:o().optional()})}).strict();var VG=(Q)=>GY.safeParse(Q).success;var NG=p([qG,OG,WY,GY]),gN=p([WY,GY]),BQ=J0.strict(),IA=b0.extend({requestId:DQ.optional(),reason:B().optional()}),LQ=P0.extend({method:b("notifications/cancelled"),params:IA}),jA=w({src:B(),mimeType:B().optional(),sizes:_(B()).optional(),theme:L0(["light","dark"]).optional()}),z4=w({icons:_(jA).optional()}),S1=w({name:B(),title:B().optional()}),ZG=S1.extend({...S1.shape,...z4.shape,version:B(),websiteUrl:B().optional(),description:B().optional()}),EA=AQ(w({applyDefaults:X0().optional()}),t(B(),o())),TA=e6((Q)=>{if(Q&&typeof Q==="object"&&!Array.isArray(Q)){if(Object.keys(Q).length===0)return{form:{}}}return Q},AQ(w({form:EA.optional(),url:G0.optional()}),t(B(),o()).optional())),SA=U0({list:G0.optional(),cancel:G0.optional(),requests:U0({sampling:U0({createMessage:G0.optional()}).optional(),elicitation:U0({create:G0.optional()}).optional()}).optional()}),RA=U0({list:G0.optional(),cancel:G0.optional(),requests:U0({tools:U0({call:G0.optional()}).optional()}).optional()}),CA=w({experimental:t(B(),G0).optional(),sampling:w({context:G0.optional(),tools:G0.optional()}).optional(),elicitation:TA.optional(),roots:w({listChanged:X0().optional()}).optional(),tasks:SA.optional()}),kA=Z0.extend({protocolVersion:B(),capabilities:CA,clientInfo:ZG}),$Y=$0.extend({method:b("initialize"),params:kA});var vA=w({experimental:t(B(),G0).optional(),logging:G0.optional(),completions:G0.optional(),prompts:w({listChanged:X0().optional()}).optional(),resources:w({subscribe:X0().optional(),listChanged:X0().optional()}).optional(),tools:w({listChanged:X0().optional()}).optional(),tasks:RA.optional()}),xA=J0.extend({protocolVersion:B(),capabilities:vA,serverInfo:ZG,instructions:B().optional()}),JY=P0.extend({method:b("notifications/initialized"),params:b0.optional()});var FQ=$0.extend({method:b("ping"),params:Z0.optional()}),_A=w({progress:l(),total:a(l()),message:a(B())}),yA=w({...b0.shape,..._A.shape,progressToken:BG}),qQ=P0.extend({method:b("notifications/progress"),params:yA}),gA=Z0.extend({cursor:LG.optional()}),H4=$0.extend({params:gA.optional()}),A4=J0.extend({nextCursor:LG.optional()}),uA=L0(["working","input_required","completed","failed","cancelled"]),U4=w({taskId:B(),status:uA,ttl:p([l(),a6()]),createdAt:B(),lastUpdatedAt:B(),pollInterval:a(l()),statusMessage:a(B())}),R1=J0.extend({task:U4}),hA=b0.merge(U4),K4=P0.extend({method:b("notifications/tasks/status"),params:hA}),OQ=$0.extend({method:b("tasks/get"),params:Z0.extend({taskId:B()})}),MQ=J0.merge(U4),VQ=$0.extend({method:b("tasks/result"),params:Z0.extend({taskId:B()})}),uN=J0.loose(),NQ=H4.extend({method:b("tasks/list")}),ZQ=A4.extend({tasks:_(U4)}),wQ=$0.extend({method:b("tasks/cancel"),params:Z0.extend({taskId:B()})}),wG=J0.merge(U4),bG=w({uri:B(),mimeType:a(B()),_meta:t(B(),o()).optional()}),PG=bG.extend({text:B()}),zY=B().refine((Q)=>{try{return atob(Q),!0}catch{return!1}},{message:"Invalid Base64 string"}),IG=bG.extend({blob:zY}),D4=L0(["user","assistant"]),C1=w({audience:_(D4).optional(),priority:l().min(0).max(1).optional(),lastModified:G4.datetime({offset:!0}).optional()}),jG=w({...S1.shape,...z4.shape,uri:B(),description:a(B()),mimeType:a(B()),annotations:C1.optional(),_meta:a(U0({}))}),fA=w({...S1.shape,...z4.shape,uriTemplate:B(),description:a(B()),mimeType:a(B()),annotations:C1.optional(),_meta:a(U0({}))}),HY=H4.extend({method:b("resources/list")}),lA=A4.extend({resources:_(jG)}),mA=H4.extend({method:b("resources/templates/list")}),cA=A4.extend({resourceTemplates:_(fA)}),AY=Z0.extend({uri:B()}),pA=AY,UY=$0.extend({method:b("resources/read"),params:pA}),iA=J0.extend({contents:_(p([PG,IG]))}),rA=P0.extend({method:b("notifications/resources/list_changed"),params:b0.optional()}),nA=AY,dA=$0.extend({method:b("resources/subscribe"),params:nA}),oA=AY,tA=$0.extend({method:b("resources/unsubscribe"),params:oA}),aA=b0.extend({uri:B()}),sA=P0.extend({method:b("notifications/resources/updated"),params:aA}),eA=w({name:B(),description:a(B()),required:a(X0())}),QU=w({...S1.shape,...z4.shape,description:a(B()),arguments:a(_(eA)),_meta:a(U0({}))}),YU=H4.extend({method:b("prompts/list")}),XU=A4.extend({prompts:_(QU)}),WU=Z0.extend({name:B(),arguments:t(B(),B()).optional()}),GU=$0.extend({method:b("prompts/get"),params:WU}),KY=w({type:b("text"),text:B(),annotations:C1.optional(),_meta:t(B(),o()).optional()}),DY=w({type:b("image"),data:zY,mimeType:B(),annotations:C1.optional(),_meta:t(B(),o()).optional()}),BY=w({type:b("audio"),data:zY,mimeType:B(),annotations:C1.optional(),_meta:t(B(),o()).optional()}),$U=w({type:b("tool_use"),name:B(),id:B(),input:t(B(),o()),_meta:t(B(),o()).optional()}),JU=w({type:b("resource"),resource:p([PG,IG]),annotations:C1.optional(),_meta:t(B(),o()).optional()}),zU=jG.extend({type:b("resource_link")}),LY=p([KY,DY,BY,zU,JU]),HU=w({role:D4,content:LY}),AU=J0.extend({description:B().optional(),messages:_(HU)}),UU=P0.extend({method:b("notifications/prompts/list_changed"),params:b0.optional()}),KU=w({title:B().optional(),readOnlyHint:X0().optional(),destructiveHint:X0().optional(),idempotentHint:X0().optional(),openWorldHint:X0().optional()}),DU=w({taskSupport:L0(["required","optional","forbidden"]).optional()}),EG=w({...S1.shape,...z4.shape,description:B().optional(),inputSchema:w({type:b("object"),properties:t(B(),G0).optional(),required:_(B()).optional()}).catchall(o()),outputSchema:w({type:b("object"),properties:t(B(),G0).optional(),required:_(B()).optional()}).catchall(o()).optional(),annotations:KU.optional(),execution:DU.optional(),_meta:t(B(),o()).optional()}),FY=H4.extend({method:b("tools/list")}),BU=A4.extend({tools:_(EG)}),bQ=J0.extend({content:_(LY).default([]),structuredContent:t(B(),o()).optional(),isError:X0().optional()}),hN=bQ.or(J0.extend({toolResult:o()})),LU=$4.extend({name:B(),arguments:t(B(),o()).optional()}),B4=$0.extend({method:b("tools/call"),params:LU}),FU=P0.extend({method:b("notifications/tools/list_changed"),params:b0.optional()}),fN=w({autoRefresh:X0().default(!0),debounceMs:l().int().nonnegative().default(300)}),L4=L0(["debug","info","notice","warning","error","critical","alert","emergency"]),qU=Z0.extend({level:L4}),qY=$0.extend({method:b("logging/setLevel"),params:qU}),OU=b0.extend({level:L4,logger:B().optional(),data:o()}),MU=P0.extend({method:b("notifications/message"),params:OU}),VU=w({name:B().optional()}),NU=w({hints:_(VU).optional(),costPriority:l().min(0).max(1).optional(),speedPriority:l().min(0).max(1).optional(),intelligencePriority:l().min(0).max(1).optional()}),ZU=w({mode:L0(["auto","required","none"]).optional()}),wU=w({type:b("tool_result"),toolUseId:B().describe("The unique identifier for the corresponding tool call."),content:_(LY).default([]),structuredContent:w({}).loose().optional(),isError:X0().optional(),_meta:t(B(),o()).optional()}),bU=s6("type",[KY,DY,BY]),UQ=s6("type",[KY,DY,BY,$U,wU]),PU=w({role:D4,content:p([UQ,_(UQ)]),_meta:t(B(),o()).optional()}),IU=$4.extend({messages:_(PU),modelPreferences:NU.optional(),systemPrompt:B().optional(),includeContext:L0(["none","thisServer","allServers"]).optional(),temperature:l().optional(),maxTokens:l().int(),stopSequences:_(B()).optional(),metadata:G0.optional(),tools:_(EG).optional(),toolChoice:ZU.optional()}),jU=$0.extend({method:b("sampling/createMessage"),params:IU}),OY=J0.extend({model:B(),stopReason:a(L0(["endTurn","stopSequence","maxTokens"]).or(B())),role:D4,content:bU}),MY=J0.extend({model:B(),stopReason:a(L0(["endTurn","stopSequence","maxTokens","toolUse"]).or(B())),role:D4,content:p([UQ,_(UQ)])}),EU=w({type:b("boolean"),title:B().optional(),description:B().optional(),default:X0().optional()}),TU=w({type:b("string"),title:B().optional(),description:B().optional(),minLength:l().optional(),maxLength:l().optional(),format:L0(["email","uri","date","date-time"]).optional(),default:B().optional()}),SU=w({type:L0(["number","integer"]),title:B().optional(),description:B().optional(),minimum:l().optional(),maximum:l().optional(),default:l().optional()}),RU=w({type:b("string"),title:B().optional(),description:B().optional(),enum:_(B()),default:B().optional()}),CU=w({type:b("string"),title:B().optional(),description:B().optional(),oneOf:_(w({const:B(),title:B()})),default:B().optional()}),kU=w({type:b("string"),title:B().optional(),description:B().optional(),enum:_(B()),enumNames:_(B()).optional(),default:B().optional()}),vU=p([RU,CU]),xU=w({type:b("array"),title:B().optional(),description:B().optional(),minItems:l().optional(),maxItems:l().optional(),items:w({type:b("string"),enum:_(B())}),default:_(B()).optional()}),_U=w({type:b("array"),title:B().optional(),description:B().optional(),minItems:l().optional(),maxItems:l().optional(),items:w({anyOf:_(w({const:B(),title:B()}))}),default:_(B()).optional()}),yU=p([xU,_U]),gU=p([kU,vU,yU]),uU=p([gU,EU,TU,SU]),hU=$4.extend({mode:b("form").optional(),message:B(),requestedSchema:w({type:b("object"),properties:t(B(),uU),required:_(B()).optional()})}),fU=$4.extend({mode:b("url"),message:B(),elicitationId:B(),url:B().url()}),lU=p([hU,fU]),mU=$0.extend({method:b("elicitation/create"),params:lU}),cU=b0.extend({elicitationId:B()}),pU=P0.extend({method:b("notifications/elicitation/complete"),params:cU}),PQ=J0.extend({action:L0(["accept","decline","cancel"]),content:e6((Q)=>Q===null?void 0:Q,t(B(),p([B(),l(),X0(),_(B())])).optional())}),iU=w({type:b("ref/resource"),uri:B()});var rU=w({type:b("ref/prompt"),name:B()}),nU=Z0.extend({ref:p([rU,iU]),argument:w({name:B(),value:B()}),context:w({arguments:t(B(),B()).optional()}).optional()}),dU=$0.extend({method:b("completion/complete"),params:nU});var oU=J0.extend({completion:U0({values:_(B()).max(100),total:a(l().int()),hasMore:a(X0())})}),tU=w({uri:B().startsWith("file://"),name:B().optional(),_meta:t(B(),o()).optional()}),aU=$0.extend({method:b("roots/list"),params:Z0.optional()}),VY=J0.extend({roots:_(tU)}),sU=P0.extend({method:b("notifications/roots/list_changed"),params:b0.optional()}),lN=p([FQ,$Y,dU,qY,GU,YU,HY,mA,UY,dA,tA,B4,FY,OQ,VQ,NQ,wQ]),mN=p([LQ,qQ,JY,sU,K4]),cN=p([BQ,OY,MY,PQ,VY,MQ,ZQ,R1]),pN=p([FQ,jU,mU,aU,OQ,VQ,NQ,wQ]),iN=p([LQ,qQ,MU,sA,rA,FU,UU,K4,pU]),rN=p([BQ,xA,oU,AU,XU,lA,cA,iA,bQ,BU,MQ,ZQ,R1]);class k extends Error{constructor(Q,Y,X){super(`MCP error ${Q}: ${Y}`);this.code=Q,this.data=X,this.name="McpError"}static fromError(Q,Y,X){if(Q===y.UrlElicitationRequired&&X){let W=X;if(W.elicitations)return new TG(W.elicitations,Y)}return new k(Q,Y,X)}}class TG extends k{constructor(Q,Y=`URL elicitation${Q.length>1?"s":""} required`){super(y.UrlElicitationRequired,Y,{elicitations:Q})}get elicitations(){return this.data?.elicitations??[]}}function $1(Q){return Q==="completed"||Q==="failed"||Q==="cancelled"}var eU=Symbol("Let zodToJsonSchema decide on which parser to use");var IZ=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function NY(Q){let X=zQ(Q)?.method;if(!X)throw Error("Schema is missing a method literal");let W=yW(X);if(typeof W!=="string")throw Error("Schema method literal must be a string");return W}function ZY(Q,Y){let X=W1(Q,Y);if(!X.success)throw X.error;return X.data}var $3=60000;class wY{constructor(Q){if(this._options=Q,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(LQ,(Y)=>{this._oncancel(Y)}),this.setNotificationHandler(qQ,(Y)=>{this._onprogress(Y)}),this.setRequestHandler(FQ,(Y)=>({})),this._taskStore=Q?.taskStore,this._taskMessageQueue=Q?.taskMessageQueue,this._taskStore)this.setRequestHandler(OQ,async(Y,X)=>{let W=await this._taskStore.getTask(Y.params.taskId,X.sessionId);if(!W)throw new k(y.InvalidParams,"Failed to retrieve task: Task not found");return{...W}}),this.setRequestHandler(VQ,async(Y,X)=>{let W=async()=>{let G=Y.params.taskId;if(this._taskMessageQueue){let J;while(J=await this._taskMessageQueue.dequeue(G,X.sessionId)){if(J.type==="response"||J.type==="error"){let z=J.message,H=z.id,A=this._requestResolvers.get(H);if(A)if(this._requestResolvers.delete(H),J.type==="response")A(z);else{let U=z,K=new k(U.error.code,U.error.message,U.error.data);A(K)}else{let U=J.type==="response"?"Response":"Error";this._onerror(Error(`${U} handler missing for request ${H}`))}continue}await this._transport?.send(J.message,{relatedRequestId:X.requestId})}}let $=await this._taskStore.getTask(G,X.sessionId);if(!$)throw new k(y.InvalidParams,`Task not found: ${G}`);if(!$1($.status))return await this._waitForTaskUpdate(G,X.signal),await W();if($1($.status)){let J=await this._taskStore.getTaskResult(G,X.sessionId);return this._clearTaskQueue(G),{...J,_meta:{...J._meta,[G1]:{taskId:G}}}}return await W()};return await W()}),this.setRequestHandler(NQ,async(Y,X)=>{try{let{tasks:W,nextCursor:G}=await this._taskStore.listTasks(Y.params?.cursor,X.sessionId);return{tasks:W,nextCursor:G,_meta:{}}}catch(W){throw new k(y.InvalidParams,`Failed to list tasks: ${W instanceof Error?W.message:String(W)}`)}}),this.setRequestHandler(wQ,async(Y,X)=>{try{let W=await this._taskStore.getTask(Y.params.taskId,X.sessionId);if(!W)throw new k(y.InvalidParams,`Task not found: ${Y.params.taskId}`);if($1(W.status))throw new k(y.InvalidParams,`Cannot cancel task in terminal status: ${W.status}`);await this._taskStore.updateTaskStatus(Y.params.taskId,"cancelled","Client cancelled task execution.",X.sessionId),this._clearTaskQueue(Y.params.taskId);let G=await this._taskStore.getTask(Y.params.taskId,X.sessionId);if(!G)throw new k(y.InvalidParams,`Task not found after cancellation: ${Y.params.taskId}`);return{_meta:{},...G}}catch(W){if(W instanceof k)throw W;throw new k(y.InvalidRequest,`Failed to cancel task: ${W instanceof Error?W.message:String(W)}`)}})}async _oncancel(Q){if(!Q.params.requestId)return;this._requestHandlerAbortControllers.get(Q.params.requestId)?.abort(Q.params.reason)}_setupTimeout(Q,Y,X,W,G=!1){this._timeoutInfo.set(Q,{timeoutId:setTimeout(W,Y),startTime:Date.now(),timeout:Y,maxTotalTimeout:X,resetTimeoutOnProgress:G,onTimeout:W})}_resetTimeout(Q){let Y=this._timeoutInfo.get(Q);if(!Y)return!1;let X=Date.now()-Y.startTime;if(Y.maxTotalTimeout&&X>=Y.maxTotalTimeout)throw this._timeoutInfo.delete(Q),k.fromError(y.RequestTimeout,"Maximum total timeout exceeded",{maxTotalTimeout:Y.maxTotalTimeout,totalElapsed:X});return clearTimeout(Y.timeoutId),Y.timeoutId=setTimeout(Y.onTimeout,Y.timeout),!0}_cleanupTimeout(Q){let Y=this._timeoutInfo.get(Q);if(Y)clearTimeout(Y.timeoutId),this._timeoutInfo.delete(Q)}async connect(Q){this._transport=Q;let Y=this.transport?.onclose;this._transport.onclose=()=>{Y?.(),this._onclose()};let X=this.transport?.onerror;this._transport.onerror=(G)=>{X?.(G),this._onerror(G)};let W=this._transport?.onmessage;this._transport.onmessage=(G,$)=>{if(W?.(G,$),J4(G)||VG(G))this._onresponse(G);else if(XY(G))this._onrequest(G,$);else if(MG(G))this._onnotification(G);else this._onerror(Error(`Unknown message type: ${JSON.stringify(G)}`))},await this._transport.start()}_onclose(){let Q=this._responseHandlers;this._responseHandlers=new Map,this._progressHandlers.clear(),this._taskProgressTokens.clear(),this._pendingDebouncedNotifications.clear();let Y=k.fromError(y.ConnectionClosed,"Connection closed");this._transport=void 0,this.onclose?.();for(let X of Q.values())X(Y)}_onerror(Q){this.onerror?.(Q)}_onnotification(Q){let Y=this._notificationHandlers.get(Q.method)??this.fallbackNotificationHandler;if(Y===void 0)return;Promise.resolve().then(()=>Y(Q)).catch((X)=>this._onerror(Error(`Uncaught error in notification handler: ${X}`)))}_onrequest(Q,Y){let X=this._requestHandlers.get(Q.method)??this.fallbackRequestHandler,W=this._transport,G=Q.params?._meta?.[G1]?.taskId;if(X===void 0){let A={jsonrpc:"2.0",id:Q.id,error:{code:y.MethodNotFound,message:"Method not found"}};if(G&&this._taskMessageQueue)this._enqueueTaskMessage(G,{type:"error",message:A,timestamp:Date.now()},W?.sessionId).catch((U)=>this._onerror(Error(`Failed to enqueue error response: ${U}`)));else W?.send(A).catch((U)=>this._onerror(Error(`Failed to send an error response: ${U}`)));return}let $=new AbortController;this._requestHandlerAbortControllers.set(Q.id,$);let J=FG(Q.params)?Q.params.task:void 0,z=this._taskStore?this.requestTaskStore(Q,W?.sessionId):void 0,H={signal:$.signal,sessionId:W?.sessionId,_meta:Q.params?._meta,sendNotification:async(A)=>{let U={relatedRequestId:Q.id};if(G)U.relatedTask={taskId:G};await this.notification(A,U)},sendRequest:async(A,U,K)=>{let D={...K,relatedRequestId:Q.id};if(G&&!D.relatedTask)D.relatedTask={taskId:G};let L=D.relatedTask?.taskId??G;if(L&&z)await z.updateTaskStatus(L,"input_required");return await this.request(A,U,D)},authInfo:Y?.authInfo,requestId:Q.id,requestInfo:Y?.requestInfo,taskId:G,taskStore:z,taskRequestedTtl:J?.ttl,closeSSEStream:Y?.closeSSEStream,closeStandaloneSSEStream:Y?.closeStandaloneSSEStream};Promise.resolve().then(()=>{if(J)this.assertTaskHandlerCapability(Q.method)}).then(()=>X(Q,H)).then(async(A)=>{if($.signal.aborted)return;let U={result:A,jsonrpc:"2.0",id:Q.id};if(G&&this._taskMessageQueue)await this._enqueueTaskMessage(G,{type:"response",message:U,timestamp:Date.now()},W?.sessionId);else await W?.send(U)},async(A)=>{if($.signal.aborted)return;let U={jsonrpc:"2.0",id:Q.id,error:{code:Number.isSafeInteger(A.code)?A.code:y.InternalError,message:A.message??"Internal error",...A.data!==void 0&&{data:A.data}}};if(G&&this._taskMessageQueue)await this._enqueueTaskMessage(G,{type:"error",message:U,timestamp:Date.now()},W?.sessionId);else await W?.send(U)}).catch((A)=>this._onerror(Error(`Failed to send response: ${A}`))).finally(()=>{this._requestHandlerAbortControllers.delete(Q.id)})}_onprogress(Q){let{progressToken:Y,...X}=Q.params,W=Number(Y),G=this._progressHandlers.get(W);if(!G){this._onerror(Error(`Received a progress notification for an unknown token: ${JSON.stringify(Q)}`));return}let $=this._responseHandlers.get(W),J=this._timeoutInfo.get(W);if(J&&$&&J.resetTimeoutOnProgress)try{this._resetTimeout(W)}catch(z){this._responseHandlers.delete(W),this._progressHandlers.delete(W),this._cleanupTimeout(W),$(z);return}G(X)}_onresponse(Q){let Y=Number(Q.id),X=this._requestResolvers.get(Y);if(X){if(this._requestResolvers.delete(Y),J4(Q))X(Q);else{let $=new k(Q.error.code,Q.error.message,Q.error.data);X($)}return}let W=this._responseHandlers.get(Y);if(W===void 0){this._onerror(Error(`Received a response for an unknown message ID: ${JSON.stringify(Q)}`));return}this._responseHandlers.delete(Y),this._cleanupTimeout(Y);let G=!1;if(J4(Q)&&Q.result&&typeof Q.result==="object"){let $=Q.result;if($.task&&typeof $.task==="object"){let J=$.task;if(typeof J.taskId==="string")G=!0,this._taskProgressTokens.set(J.taskId,Y)}}if(!G)this._progressHandlers.delete(Y);if(J4(Q))W(Q);else{let $=k.fromError(Q.error.code,Q.error.message,Q.error.data);W($)}}get transport(){return this._transport}async close(){await this._transport?.close()}async*requestStream(Q,Y,X){let{task:W}=X??{};if(!W){try{yield{type:"result",result:await this.request(Q,Y,X)}}catch($){yield{type:"error",error:$ instanceof k?$:new k(y.InternalError,String($))}}return}let G;try{let $=await this.request(Q,R1,X);if($.task)G=$.task.taskId,yield{type:"taskCreated",task:$.task};else throw new k(y.InternalError,"Task creation did not return a task");while(!0){let J=await this.getTask({taskId:G},X);if(yield{type:"taskStatus",task:J},$1(J.status)){if(J.status==="completed")yield{type:"result",result:await this.getTaskResult({taskId:G},Y,X)};else if(J.status==="failed")yield{type:"error",error:new k(y.InternalError,`Task ${G} failed`)};else if(J.status==="cancelled")yield{type:"error",error:new k(y.InternalError,`Task ${G} was cancelled`)};return}if(J.status==="input_required"){yield{type:"result",result:await this.getTaskResult({taskId:G},Y,X)};return}let z=J.pollInterval??this._options?.defaultTaskPollInterval??1000;await new Promise((H)=>setTimeout(H,z)),X?.signal?.throwIfAborted()}}catch($){yield{type:"error",error:$ instanceof k?$:new k(y.InternalError,String($))}}}request(Q,Y,X){let{relatedRequestId:W,resumptionToken:G,onresumptiontoken:$,task:J,relatedTask:z}=X??{};return new Promise((H,A)=>{let U=(M)=>{A(M)};if(!this._transport){U(Error("Not connected"));return}if(this._options?.enforceStrictCapabilities===!0)try{if(this.assertCapabilityForMethod(Q.method),J)this.assertTaskCapability(Q.method)}catch(M){U(M);return}X?.signal?.throwIfAborted();let K=this._requestMessageId++,D={...Q,jsonrpc:"2.0",id:K};if(X?.onprogress)this._progressHandlers.set(K,X.onprogress),D.params={...Q.params,_meta:{...Q.params?._meta||{},progressToken:K}};if(J)D.params={...D.params,task:J};if(z)D.params={...D.params,_meta:{...D.params?._meta||{},[G1]:z}};let L=(M)=>{this._responseHandlers.delete(K),this._progressHandlers.delete(K),this._cleanupTimeout(K),this._transport?.send({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:K,reason:String(M)}},{relatedRequestId:W,resumptionToken:G,onresumptiontoken:$}).catch((E)=>this._onerror(Error(`Failed to send cancellation: ${E}`)));let S=M instanceof k?M:new k(y.RequestTimeout,String(M));A(S)};this._responseHandlers.set(K,(M)=>{if(X?.signal?.aborted)return;if(M instanceof Error)return A(M);try{let S=W1(Y,M.result);if(!S.success)A(S.error);else H(S.data)}catch(S){A(S)}}),X?.signal?.addEventListener("abort",()=>{L(X?.signal?.reason)});let q=X?.timeout??$3,O=()=>L(k.fromError(y.RequestTimeout,"Request timed out",{timeout:q}));this._setupTimeout(K,q,X?.maxTotalTimeout,O,X?.resetTimeoutOnProgress??!1);let V=z?.taskId;if(V){let M=(S)=>{let E=this._responseHandlers.get(K);if(E)E(S);else this._onerror(Error(`Response handler missing for side-channeled request ${K}`))};this._requestResolvers.set(K,M),this._enqueueTaskMessage(V,{type:"request",message:D,timestamp:Date.now()}).catch((S)=>{this._cleanupTimeout(K),A(S)})}else this._transport.send(D,{relatedRequestId:W,resumptionToken:G,onresumptiontoken:$}).catch((M)=>{this._cleanupTimeout(K),A(M)})})}async getTask(Q,Y){return this.request({method:"tasks/get",params:Q},MQ,Y)}async getTaskResult(Q,Y,X){return this.request({method:"tasks/result",params:Q},Y,X)}async listTasks(Q,Y){return this.request({method:"tasks/list",params:Q},ZQ,Y)}async cancelTask(Q,Y){return this.request({method:"tasks/cancel",params:Q},wG,Y)}async notification(Q,Y){if(!this._transport)throw Error("Not connected");this.assertNotificationCapability(Q.method);let X=Y?.relatedTask?.taskId;if(X){let J={...Q,jsonrpc:"2.0",params:{...Q.params,_meta:{...Q.params?._meta||{},[G1]:Y.relatedTask}}};await this._enqueueTaskMessage(X,{type:"notification",message:J,timestamp:Date.now()});return}if((this._options?.debouncedNotificationMethods??[]).includes(Q.method)&&!Q.params&&!Y?.relatedRequestId&&!Y?.relatedTask){if(this._pendingDebouncedNotifications.has(Q.method))return;this._pendingDebouncedNotifications.add(Q.method),Promise.resolve().then(()=>{if(this._pendingDebouncedNotifications.delete(Q.method),!this._transport)return;let J={...Q,jsonrpc:"2.0"};if(Y?.relatedTask)J={...J,params:{...J.params,_meta:{...J.params?._meta||{},[G1]:Y.relatedTask}}};this._transport?.send(J,Y).catch((z)=>this._onerror(z))});return}let $={...Q,jsonrpc:"2.0"};if(Y?.relatedTask)$={...$,params:{...$.params,_meta:{...$.params?._meta||{},[G1]:Y.relatedTask}}};await this._transport.send($,Y)}setRequestHandler(Q,Y){let X=NY(Q);this.assertRequestHandlerCapability(X),this._requestHandlers.set(X,(W,G)=>{let $=ZY(Q,W);return Promise.resolve(Y($,G))})}removeRequestHandler(Q){this._requestHandlers.delete(Q)}assertCanSetRequestHandler(Q){if(this._requestHandlers.has(Q))throw Error(`A request handler for ${Q} already exists, which would be overridden`)}setNotificationHandler(Q,Y){let X=NY(Q);this._notificationHandlers.set(X,(W)=>{let G=ZY(Q,W);return Promise.resolve(Y(G))})}removeNotificationHandler(Q){this._notificationHandlers.delete(Q)}_cleanupTaskProgressHandler(Q){let Y=this._taskProgressTokens.get(Q);if(Y!==void 0)this._progressHandlers.delete(Y),this._taskProgressTokens.delete(Q)}async _enqueueTaskMessage(Q,Y,X){if(!this._taskStore||!this._taskMessageQueue)throw Error("Cannot enqueue task message: taskStore and taskMessageQueue are not configured");let W=this._options?.maxTaskQueueSize;await this._taskMessageQueue.enqueue(Q,Y,X,W)}async _clearTaskQueue(Q,Y){if(this._taskMessageQueue){let X=await this._taskMessageQueue.dequeueAll(Q,Y);for(let W of X)if(W.type==="request"&&XY(W.message)){let G=W.message.id,$=this._requestResolvers.get(G);if($)$(new k(y.InternalError,"Task cancelled or completed")),this._requestResolvers.delete(G);else this._onerror(Error(`Resolver missing for request ${G} during task ${Q} cleanup`))}}}async _waitForTaskUpdate(Q,Y){let X=this._options?.defaultTaskPollInterval??1000;try{let W=await this._taskStore?.getTask(Q);if(W?.pollInterval)X=W.pollInterval}catch{}return new Promise((W,G)=>{if(Y.aborted){G(new k(y.InvalidRequest,"Request cancelled"));return}let $=setTimeout(W,X);Y.addEventListener("abort",()=>{clearTimeout($),G(new k(y.InvalidRequest,"Request cancelled"))},{once:!0})})}requestTaskStore(Q,Y){let X=this._taskStore;if(!X)throw Error("No task store configured");return{createTask:async(W)=>{if(!Q)throw Error("No request provided");return await X.createTask(W,Q.id,{method:Q.method,params:Q.params},Y)},getTask:async(W)=>{let G=await X.getTask(W,Y);if(!G)throw new k(y.InvalidParams,"Failed to retrieve task: Task not found");return G},storeTaskResult:async(W,G,$)=>{await X.storeTaskResult(W,G,$,Y);let J=await X.getTask(W,Y);if(J){let z=K4.parse({method:"notifications/tasks/status",params:J});if(await this.notification(z),$1(J.status))this._cleanupTaskProgressHandler(W)}},getTaskResult:(W)=>{return X.getTaskResult(W,Y)},updateTaskStatus:async(W,G,$)=>{let J=await X.getTask(W,Y);if(!J)throw new k(y.InvalidParams,`Task "${W}" not found - it may have been cleaned up`);if($1(J.status))throw new k(y.InvalidParams,`Cannot update task "${W}" from terminal status "${J.status}" to "${G}". Terminal states (completed, failed, cancelled) cannot transition to other states.`);await X.updateTaskStatus(W,G,$,Y);let z=await X.getTask(W,Y);if(z){let H=K4.parse({method:"notifications/tasks/status",params:z});if(await this.notification(H),$1(z.status))this._cleanupTaskProgressHandler(W)}},listTasks:(W)=>{return X.listTasks(W,Y)}}}}function SG(Q){return Q!==null&&typeof Q==="object"&&!Array.isArray(Q)}function RG(Q,Y){let X={...Q};for(let W in Y){let G=W,$=Y[G];if($===void 0)continue;let J=X[G];if(SG(J)&&SG($))X[G]={...J,...$};else X[G]=$}return X}var z5=g9(q9(),1),H5=g9(J5(),1);function LM(){let Q=new z5.default({strict:!1,validateFormats:!0,validateSchema:!1,allErrors:!0});return H5.default(Q),Q}class j9{constructor(Q){this._ajv=Q??LM()}getValidator(Q){let Y="$id"in Q&&typeof Q.$id==="string"?this._ajv.getSchema(Q.$id)??this._ajv.compile(Q):this._ajv.compile(Q);return(X)=>{if(Y(X))return{valid:!0,data:X,errorMessage:void 0};else return{valid:!1,data:void 0,errorMessage:this._ajv.errorsText(Y.errors)}}}}class E9{constructor(Q){this._server=Q}requestStream(Q,Y,X){return this._server.requestStream(Q,Y,X)}async getTask(Q,Y){return this._server.getTask({taskId:Q},Y)}async getTaskResult(Q,Y,X){return this._server.getTaskResult({taskId:Q},Y,X)}async listTasks(Q,Y){return this._server.listTasks(Q?{cursor:Q}:void 0,Y)}async cancelTask(Q,Y){return this._server.cancelTask({taskId:Q},Y)}}function A5(Q,Y,X){if(!Q)throw Error(`${X} does not support task creation (required for ${Y})`);switch(Y){case"tools/call":if(!Q.tools?.call)throw Error(`${X} does not support task creation for tools/call (required for ${Y})`);break;default:break}}function U5(Q,Y,X){if(!Q)throw Error(`${X} does not support task creation (required for ${Y})`);switch(Y){case"sampling/createMessage":if(!Q.sampling?.createMessage)throw Error(`${X} does not support task creation for sampling/createMessage (required for ${Y})`);break;case"elicitation/create":if(!Q.elicitation?.create)throw Error(`${X} does not support task creation for elicitation/create (required for ${Y})`);break;default:break}}class T9 extends wY{constructor(Q,Y){super(Y);if(this._serverInfo=Q,this._loggingLevels=new Map,this.LOG_LEVEL_SEVERITY=new Map(L4.options.map((X,W)=>[X,W])),this.isMessageIgnored=(X,W)=>{let G=this._loggingLevels.get(W);return G?this.LOG_LEVEL_SEVERITY.get(X)<this.LOG_LEVEL_SEVERITY.get(G):!1},this._capabilities=Y?.capabilities??{},this._instructions=Y?.instructions,this._jsonSchemaValidator=Y?.jsonSchemaValidator??new j9,this.setRequestHandler($Y,(X)=>this._oninitialize(X)),this.setNotificationHandler(JY,()=>this.oninitialized?.()),this._capabilities.logging)this.setRequestHandler(qY,async(X,W)=>{let G=W.sessionId||W.requestInfo?.headers["mcp-session-id"]||void 0,{level:$}=X.params,J=L4.safeParse($);if(J.success)this._loggingLevels.set(G,J.data);return{}})}get experimental(){if(!this._experimental)this._experimental={tasks:new E9(this)};return this._experimental}registerCapabilities(Q){if(this.transport)throw Error("Cannot register capabilities after connecting to transport");this._capabilities=RG(this._capabilities,Q)}setRequestHandler(Q,Y){let W=zQ(Q)?.method;if(!W)throw Error("Schema is missing a method literal");let G;if(T1(W)){let J=W;G=J._zod?.def?.value??J.value}else{let J=W;G=J._def?.value??J.value}if(typeof G!=="string")throw Error("Schema method literal must be a string");if(G==="tools/call"){let J=async(z,H)=>{let A=W1(B4,z);if(!A.success){let L=A.error instanceof Error?A.error.message:String(A.error);throw new k(y.InvalidParams,`Invalid tools/call request: ${L}`)}let{params:U}=A.data,K=await Promise.resolve(Y(z,H));if(U.task){let L=W1(R1,K);if(!L.success){let q=L.error instanceof Error?L.error.message:String(L.error);throw new k(y.InvalidParams,`Invalid task creation result: ${q}`)}return L.data}let D=W1(bQ,K);if(!D.success){let L=D.error instanceof Error?D.error.message:String(D.error);throw new k(y.InvalidParams,`Invalid tools/call result: ${L}`)}return D.data};return super.setRequestHandler(Q,J)}return super.setRequestHandler(Q,Y)}assertCapabilityForMethod(Q){switch(Q){case"sampling/createMessage":if(!this._clientCapabilities?.sampling)throw Error(`Client does not support sampling (required for ${Q})`);break;case"elicitation/create":if(!this._clientCapabilities?.elicitation)throw Error(`Client does not support elicitation (required for ${Q})`);break;case"roots/list":if(!this._clientCapabilities?.roots)throw Error(`Client does not support listing roots (required for ${Q})`);break;case"ping":break}}assertNotificationCapability(Q){switch(Q){case"notifications/message":if(!this._capabilities.logging)throw Error(`Server does not support logging (required for ${Q})`);break;case"notifications/resources/updated":case"notifications/resources/list_changed":if(!this._capabilities.resources)throw Error(`Server does not support notifying about resources (required for ${Q})`);break;case"notifications/tools/list_changed":if(!this._capabilities.tools)throw Error(`Server does not support notifying of tool list changes (required for ${Q})`);break;case"notifications/prompts/list_changed":if(!this._capabilities.prompts)throw Error(`Server does not support notifying of prompt list changes (required for ${Q})`);break;case"notifications/elicitation/complete":if(!this._clientCapabilities?.elicitation?.url)throw Error(`Client does not support URL elicitation (required for ${Q})`);break;case"notifications/cancelled":break;case"notifications/progress":break}}assertRequestHandlerCapability(Q){if(!this._capabilities)return;switch(Q){case"completion/complete":if(!this._capabilities.completions)throw Error(`Server does not support completions (required for ${Q})`);break;case"logging/setLevel":if(!this._capabilities.logging)throw Error(`Server does not support logging (required for ${Q})`);break;case"prompts/get":case"prompts/list":if(!this._capabilities.prompts)throw Error(`Server does not support prompts (required for ${Q})`);break;case"resources/list":case"resources/templates/list":case"resources/read":if(!this._capabilities.resources)throw Error(`Server does not support resources (required for ${Q})`);break;case"tools/call":case"tools/list":if(!this._capabilities.tools)throw Error(`Server does not support tools (required for ${Q})`);break;case"tasks/get":case"tasks/list":case"tasks/result":case"tasks/cancel":if(!this._capabilities.tasks)throw Error(`Server does not support tasks capability (required for ${Q})`);break;case"ping":case"initialize":break}}assertTaskCapability(Q){U5(this._clientCapabilities?.tasks?.requests,Q,"Client")}assertTaskHandlerCapability(Q){if(!this._capabilities)return;A5(this._capabilities.tasks?.requests,Q,"Server")}async _oninitialize(Q){let Y=Q.params.protocolVersion;return this._clientCapabilities=Q.params.capabilities,this._clientVersion=Q.params.clientInfo,{protocolVersion:DG.includes(Y)?Y:QY,capabilities:this.getCapabilities(),serverInfo:this._serverInfo,...this._instructions&&{instructions:this._instructions}}}getClientCapabilities(){return this._clientCapabilities}getClientVersion(){return this._clientVersion}getCapabilities(){return this._capabilities}async ping(){return this.request({method:"ping"},BQ)}async createMessage(Q,Y){if(Q.tools||Q.toolChoice){if(!this._clientCapabilities?.sampling?.tools)throw Error("Client does not support sampling tools capability.")}if(Q.messages.length>0){let X=Q.messages[Q.messages.length-1],W=Array.isArray(X.content)?X.content:[X.content],G=W.some((H)=>H.type==="tool_result"),$=Q.messages.length>1?Q.messages[Q.messages.length-2]:void 0,J=$?Array.isArray($.content)?$.content:[$.content]:[],z=J.some((H)=>H.type==="tool_use");if(G){if(W.some((H)=>H.type!=="tool_result"))throw Error("The last message must contain only tool_result content if any is present");if(!z)throw Error("tool_result blocks are not matching any tool_use from the previous message")}if(z){let H=new Set(J.filter((U)=>U.type==="tool_use").map((U)=>U.id)),A=new Set(W.filter((U)=>U.type==="tool_result").map((U)=>U.toolUseId));if(H.size!==A.size||![...H].every((U)=>A.has(U)))throw Error("ids of tool_result blocks and tool_use blocks from previous message do not match")}}if(Q.tools)return this.request({method:"sampling/createMessage",params:Q},MY,Y);return this.request({method:"sampling/createMessage",params:Q},OY,Y)}async elicitInput(Q,Y){switch(Q.mode??"form"){case"url":{if(!this._clientCapabilities?.elicitation?.url)throw Error("Client does not support url elicitation.");let W=Q;return this.request({method:"elicitation/create",params:W},PQ,Y)}case"form":{if(!this._clientCapabilities?.elicitation?.form)throw Error("Client does not support form elicitation.");let W=Q.mode==="form"?Q:{...Q,mode:"form"},G=await this.request({method:"elicitation/create",params:W},PQ,Y);if(G.action==="accept"&&G.content&&W.requestedSchema)try{let J=this._jsonSchemaValidator.getValidator(W.requestedSchema)(G.content);if(!J.valid)throw new k(y.InvalidParams,`Elicitation response content does not match requested schema: ${J.errorMessage}`)}catch($){if($ instanceof k)throw $;throw new k(y.InternalError,`Error validating elicitation response: ${$ instanceof Error?$.message:String($)}`)}return G}}}createElicitationCompletionNotifier(Q,Y){if(!this._clientCapabilities?.elicitation?.url)throw Error("Client does not support URL elicitation (required for notifications/elicitation/complete)");return()=>this.notification({method:"notifications/elicitation/complete",params:{elicitationId:Q}},Y)}async listRoots(Q,Y){return this.request({method:"roots/list",params:Q},VY,Y)}async sendLoggingMessage(Q,Y){if(this._capabilities.logging){if(!this.isMessageIgnored(Q.level,Y))return this.notification({method:"notifications/message",params:Q})}}async sendResourceUpdated(Q){return this.notification({method:"notifications/resources/updated",params:Q})}async sendResourceListChanged(){return this.notification({method:"notifications/resources/list_changed"})}async sendToolListChanged(){return this.notification({method:"notifications/tools/list_changed"})}async sendPromptListChanged(){return this.notification({method:"notifications/prompts/list_changed"})}}var K5={name:"@sequenzy/mcp",version:"0.0.45",mcpName:"io.github.sequenzy/mcp",description:"Sequenzy MCP server for AI-powered email marketing automation",type:"module",bin:{"sequenzy-mcp":"dist/index.js"},main:"./dist/index.js",exports:{".":"./dist/index.js","./server":"./dist/server.js","./runtime":"./dist/runtime.js","./server.json":"./server.json"},scripts:{dev:"bun --watch src/index.ts",build:"bun build src/index.ts src/server.ts src/runtime.ts --outdir dist --target node --minify",start:"node dist/index.js","type-check":"tsc --noEmit",test:"bun test","test:watch":"bun test --watch",prepublishOnly:"bun run build"},dependencies:{"@modelcontextprotocol/sdk":"^1.0.0"},devDependencies:{"@types/bun":"latest","@types/node":"^22.0.0","bun-types":"latest",typescript:"^5.8.0"},files:["dist","server.json"],keywords:["sequenzy","email","mcp","ai","claude","automation"],license:"MIT",publishConfig:{access:"public"},repository:{type:"git",url:"git+https://github.com/Sequenzy/mcp.git"},homepage:"https://sequenzy.com",bugs:{url:"https://github.com/Sequenzy/mcp/issues"}};var S9=["product-info","domain","tracking","localization","integrations","products","events","tags","labels","goals","sync-rules","api-keys","widgets","team","danger"],D5={dashboard:"/dashboard/company/{companyId}",campaigns:"/dashboard/company/{companyId}/campaign",campaign:"/dashboard/company/{companyId}/campaign/{campaignId}",campaignPreview:"/dashboard/company/{companyId}/campaign/{campaignId}?step=review",campaignList:"/dashboard/company/{companyId}/campaign/list/{status}",sequences:"/dashboard/company/{companyId}/sequences",sequence:"/dashboard/company/{companyId}/sequences/{sequenceId}",sequenceList:"/dashboard/company/{companyId}/sequences/list/{status}",settings:"/dashboard/company/{companyId}/settings",settingsTab:"/dashboard/company/{companyId}/settings?tab={tab}",emails:"/dashboard/company/{companyId}/emails",email:"/dashboard/company/{companyId}/emails/{emailId}",subscribers:"/dashboard/company/{companyId}/subscribers",sentEmails:"/dashboard/company/{companyId}/sent-emails",emailSend:"/dashboard/company/{companyId}/sent-emails/{emailSendId}",segments:"/dashboard/company/{companyId}/segments",metrics:"/dashboard/company/{companyId}/metrics",transactional:"/dashboard/company/{companyId}/transactional",transactionalEmail:"/dashboard/company/{companyId}/transactional/{transactionalId}",domain:"/dashboard/company/{companyId}/settings/domain/{domainId}",domainVerify:"/dashboard/company/{companyId}/settings/domain/{domainId}/verify"};function qM(Q){let X=(Q??process.env.SEQUENZY_APP_URL??"https://sequenzy.com").trim().replace(/\/+$/,"");return X.length>0?X:"https://sequenzy.com"}function h0(Q){let Y=Q?.trim();return Y?Y:void 0}function t0(Q){return encodeURIComponent(Q)}function Q0(Q,Y){return`${Q}${Y}`}function Y0(Q,Y=""){return`/dashboard/company/${t0(Q)}${Y}`}function B5(Q,Y,X){return Q0(Q,`${Y0(Y,"/settings")}?tab=${encodeURIComponent(X)}`)}function OM(Q,Y){let X=S9.map((W)=>[W,Y?B5(Q,Y,W):""]);return Object.fromEntries(X)}function B1(Q={},Y){let X=qM(Y),W=h0(Q.companyId),G={},$=OM(X,W);if(!W)return{appUrl:X,routeTemplates:D5,settingsTabValues:S9,urls:G,settingsUrls:$};G.dashboard=Q0(X,Y0(W)),G.campaigns=Q0(X,Y0(W,"/campaign")),G.sequences=Q0(X,Y0(W,"/sequences")),G.settings=Q0(X,Y0(W,"/settings")),G.emails=Q0(X,Y0(W,"/emails")),G.subscribers=Q0(X,Y0(W,"/subscribers")),G.sentEmails=Q0(X,Y0(W,"/sent-emails")),G.segments=Q0(X,Y0(W,"/segments")),G.metrics=Q0(X,Y0(W,"/metrics")),G.transactional=Q0(X,Y0(W,"/transactional"));let J=h0(Q.campaignId);if(J)G.campaign=Q0(X,Y0(W,`/campaign/${t0(J)}`)),G.campaignPreview=`${G.campaign}?step=review`;let z=h0(Q.sequenceId);if(z)G.sequence=Q0(X,Y0(W,`/sequences/${t0(z)}`));let H=h0(Q.emailId)??h0(Q.templateId);if(H)G.email=Q0(X,Y0(W,`/emails/${t0(H)}`)),G.template=G.email;let A=h0(Q.transactionalId);if(A)G.transactionalEmail=Q0(X,Y0(W,`/transactional/${t0(A)}`));let U=h0(Q.emailSendId);if(U)G.emailSend=Q0(X,Y0(W,`/sent-emails/${t0(U)}`));let K=h0(Q.domainId);if(K)G.domain=Q0(X,Y0(W,`/settings/domain/${t0(K)}`)),G.domainVerify=`${G.domain}/verify`;let D=h0(Q.status);if(D)G.campaignList=Q0(X,Y0(W,`/campaign/list/${t0(D)}`)),G.sequenceList=Q0(X,Y0(W,`/sequences/list/${t0(D)}`));let L=h0(Q.settingsTab);if(L)G.settingsTab=B5(X,W,L);return{appUrl:X,routeTemplates:D5,settingsTabValues:S9,urls:G,settingsUrls:$}}var L5=[{uri:"sequenzy://dashboard",name:"Dashboard Overview",description:"Live overview stats for the last 7 days",mimeType:"application/json"},{uri:"sequenzy://company",name:"Current Company",description:"The currently selected company, including localization settings",mimeType:"application/json"},{uri:"sequenzy://campaigns/recent",name:"Recent Campaigns",description:"Last 10 campaigns with status and basic stats",mimeType:"application/json"},{uri:"sequenzy://subscribers/recent",name:"Recent Subscribers",description:"Most recently added subscribers",mimeType:"application/json"},{uri:"sequenzy://subscribers/engaged",name:"Engaged Subscribers",description:"Most active/engaged subscribers",mimeType:"application/json"},{uri:"sequenzy://sequences",name:"Sequences",description:"All email sequences with status",mimeType:"application/json"},{uri:"sequenzy://templates",name:"Templates",description:"All available email templates with localization status",mimeType:"application/json"},{uri:"sequenzy://segments",name:"Segments",description:"All defined segments with subscriber counts",mimeType:"application/json"},{uri:"sequenzy://tags",name:"Tags",description:"All tags with usage counts",mimeType:"application/json"},{uri:"sequenzy://health",name:"Deliverability Health",description:"Email deliverability metrics and health status",mimeType:"application/json"},{uri:"sequenzy://app-routes",name:"Dashboard URL Routes",description:"Route templates and settings tabs for building Sequenzy dashboard links",mimeType:"application/json"}];async function F5(Q){try{let Y;switch(Q){case"sequenzy://dashboard":Y=await N("GET","/api/v1/metrics?period=7d");break;case"sequenzy://company":{let X=await N("GET","/api/v1/account"),W=s0()??X.currentCompanyId;if(!W)throw Error("No company available. Create or select a company first.");Y=await N("GET",`/api/v1/companies/${W}`);break}case"sequenzy://campaigns/recent":Y=await N("GET","/api/v1/campaigns?limit=10");break;case"sequenzy://subscribers/recent":Y=await N("GET","/api/v1/subscribers?sort=createdAt&limit=20");break;case"sequenzy://subscribers/engaged":Y=await N("GET","/api/v1/subscribers?sort=engagement&limit=20");break;case"sequenzy://sequences":Y=await N("GET","/api/v1/sequences");break;case"sequenzy://templates":Y=await N("GET","/api/v1/templates");break;case"sequenzy://segments":Y=await N("GET","/api/v1/segments");break;case"sequenzy://tags":Y=await N("GET","/api/v1/tags");break;case"sequenzy://health":Y=await N("GET","/api/v1/health/deliverability");break;case"sequenzy://app-routes":Y=B1();break;default:throw Error(`Unknown resource: ${Q}`)}return{contents:[{uri:Q,mimeType:"application/json",text:JSON.stringify(Y,null,2)}]}}catch(Y){return{contents:[{uri:Q,mimeType:"text/plain",text:a0(Y)}]}}}var h4="Sequenzy email blocks. Use `styles` for per-block background, background opacity, text color, padding, border radius, border width, and border color. Top-level style aliases such as `backgroundColor`, `backgroundOpacity`, `borderColor`, `borderWidth`, and `borderRadius` are also accepted and saved under `styles`. Use this for editor-compatible content, including conditional and repeat blocks. Repeat blocks use { type: 'repeat', source: 'items', itemAlias: 'item', children: [...] }.",A6="Replacement Sequenzy email blocks. Use `styles` for per-block background, background opacity, text color, padding, border radius, border width, and border color. Top-level style aliases such as `backgroundColor`, `backgroundOpacity`, `borderColor`, `borderWidth`, and `borderRadius` are also accepted and saved under `styles`.",M5="Sequenzy email blocks. Provide blocks or html for email steps. Use `styles` for per-block background, background opacity, text color, padding, border radius, border width, and border color. Top-level style aliases such as `backgroundColor`, `backgroundOpacity`, `borderColor`, `borderWidth`, and `borderRadius` are also accepted and saved under `styles`. Blocks can include repeat blocks over array variables such as items.",MM={type:"object",properties:{id:{type:"string",description:"Optional filter ID. Any stable string works; one will be generated if omitted."},field:{type:"string",enum:["status","tag","email","emailProvider","added","firstName","lastName","list","emailSent","emailOpened","emailClicked","emailBounced","emailComplained","attribute","event","segment","stripeProduct","stripeCurrentProduct","stripeTrialProduct"],description:"Filter field. Use `event` for custom subscriber events, `segment` for saved segment membership, and `stripeProduct`/`stripeCurrentProduct`/`stripeTrialProduct` for Stripe product-based segments. Engagement fields (`emailSent`, `emailOpened`, `emailClicked`, `emailBounced`, `emailComplained`) accept a time range as the value or a specific campaign via `campaign:<campaign_id>`."},operator:{type:"string",enum:["is","is_not","is_empty","is_not_empty","contains","not_contains","less_than","more_than","at_least","less_than_count","gte","lte","gt","lt"],description:"Filter operator. Use `is_empty` or `is_not_empty` for fields that can be blank, including custom attributes. For `stripeProduct`, use `is` or `is_not` with a raw product ID, and `at_least` or `less_than_count` with `productId:count`. For `event`, use `is`, `is_not`, `at_least`, or `less_than_count`. For engagement fields, use `is` (event happened) or `is_not` (event did not happen)."},value:{type:"string",description:"Filter value. For custom attribute empty checks, use `attributeName:` such as `last_logged_in:`. Event examples: `saas.purchase:30d`, `saas.purchase:all`, or `saas.purchase:5:30d` for thresholds. Segment values are segment IDs. Stripe product examples: `prod_123` for bought/didn't buy, `prod_123:3` for payment thresholds. Engagement examples: `7d`, `30d`, `90d`, `180d`, `all` for rolling time windows, or `campaign:<campaign_id>` to scope to a specific sent campaign (use `list_campaigns` to find IDs)."}},required:["field","operator","value"],additionalProperties:!1},VM={type:"object",properties:{kind:{type:"string",enum:["group"]},id:{type:"string",description:"Stable group ID. Any string works; one will be generated if omitted."},joinOperator:{type:"string",enum:["and","or"],description:"How children in this group combine."},children:{type:"array",minItems:1,items:{type:"object",description:'Either a filter leaf (`kind: "filter"`) or another group (`kind: "group"`).'}}},required:["kind","joinOperator","children"],additionalProperties:!0};function V5(Q){if(!Array.isArray(Q))return Q;return Q.map((Y)=>{if(typeof Y!=="object"||Y===null)return Y;let X=Y;if(typeof X.id==="string"&&X.id.trim()!=="")return X;return{...X,id:crypto.randomUUID()}})}function N5(Q){if(typeof Q!=="object"||Q===null)return Q;let Y=Q;if(Y.kind==="filter"){let X=V5([Y]);return Array.isArray(X)?X[0]:Y}if(Y.kind!=="group")return Q;return{...Y,id:typeof Y.id==="string"&&Y.id.trim()!==""?Y.id:crypto.randomUUID(),children:Array.isArray(Y.children)?Y.children.map(N5):[]}}function b1(Q,Y,X){if(Y.html!==void 0&&Y.blocks!==void 0)throw Error(`Provide either \`html\` or \`blocks\` when calling \`${Q}\`, not both.`);if(Y.blocks!==void 0&&!Array.isArray(Y.blocks))throw Error(`\`blocks\` must be an array when calling \`${Q}\`.`);if(X?.requireContent&&Y.html===void 0&&Y.blocks===void 0)throw Error(`Provide either \`html\` or \`blocks\` when calling \`${Q}\`.`)}function K6(Q,Y){if(Y.labels===void 0)return;if(!Array.isArray(Y.labels))throw Error(`\`labels\` must be an array when calling \`${Q}\`.`);if(Y.labels.some((X)=>typeof X!=="string"||X.trim().length===0))throw Error(`\`labels\` must contain only non-empty strings when calling \`${Q}\`.`)}function NM(Q){let Y=Q.filters!==void 0,X=Q.root!==void 0;if(Y&&X)throw Error("Provide either `filters` or `root` when calling `create_segment`, not both.");if(!Y&&!X)throw Error("Provide either `filters` or `root` when calling `create_segment`.");if(Y){if(!Array.isArray(Q.filters))throw Error("`filters` must be an array when calling `create_segment`.");if(Q.filters.length===0)throw Error("`filters` must include at least one filter when calling `create_segment`.")}if(X&&(typeof Q.root!=="object"||Q.root===null))throw Error("`root` must be an object when calling `create_segment`.")}function ZM(Q){if(Q.clearEnrollmentFieldPath===!0&&Q.enrollmentFieldPath!==void 0)throw Error("Provide either `enrollmentFieldPath` or `clearEnrollmentFieldPath` when calling `update_sequence`, not both.");let Y={...Q};if(delete Y.clearEnrollmentFieldPath,Q.clearEnrollmentFieldPath===!0)Y.enrollmentFieldPath=null;return Y}function wM(Q){let Y=I(Q,"subscriberId"),X=Q.fieldValues,W=X===void 0?void 0:Array.isArray(X)?X:void 0;if(X!==void 0&&W===void 0)throw Error("`fieldValues` must be an array when calling `cancel_sequence_enrollments`.");let G=W?.map((z)=>typeof z==="string"?z.trim():"").filter((z)=>z.length>0)??[];if(W?.some((z)=>typeof z!=="string")||W!==void 0&&G.length===0)throw Error("`fieldValues` must contain at least one non-empty string when calling `cancel_sequence_enrollments`.");if(Y!==void 0===G.length>0)throw Error("Provide exactly one target when calling `cancel_sequence_enrollments`: `subscriberId` or `fieldValues`.");let $=I(Q,"fieldPath"),J=I(Q,"reason");return{...Y!==void 0&&{subscriberId:Y},...$!==void 0&&{fieldPath:$},...G.length>0&&{fieldValues:G},...typeof Q.dryRun==="boolean"&&{dryRun:Q.dryRun},...J!==void 0&&{reason:J}}}function bM(Q){b1("create_campaign",Q),K6("create_campaign",Q);let Y=I(Q,"prompt")!==void 0,X=Q.html!==void 0,W=Q.blocks!==void 0,G=Q.templateId!==void 0;if(Q.prompt!==void 0&&!Y)throw Error("`prompt` cannot be empty when calling `create_campaign`.");if(Y&&(X||W||G))throw Error("Provide either `prompt`, `html`, `blocks`, or `templateId` when calling `create_campaign`, not multiple content sources.");if(!Y&&(Q.style!==void 0||Q.tone!==void 0))throw Error("`style` and `tone` can only be used with `prompt` when calling `create_campaign`.");if(!Y&&I(Q,"subject")===void 0)throw Error("`subject` is required unless `prompt` is provided when calling `create_campaign`.")}function PM(Q){if(I(Q,"scheduledAt")===void 0)throw Error("`scheduledAt` is required when calling `schedule_campaign`.");if(Q.targetLists!==void 0&&!B0(Q.targetLists))throw Error("`targetLists` must be an object when calling `schedule_campaign`.");if(Q.sendTimeOptimization!==void 0){if(typeof Q.sendTimeOptimization!=="boolean")throw Error("`sendTimeOptimization` must be a boolean when calling `schedule_campaign`.")}if(Q.spreadOverHours!==void 0){if(typeof Q.spreadOverHours!=="number"||!Number.isInteger(Q.spreadOverHours)||Q.spreadOverHours<1||Q.spreadOverHours>72)throw Error("`spreadOverHours` must be an integer between 1 and 72 when calling `schedule_campaign`.")}}function IM(Q){b1("create_transactional_email",Q);let Y=I(Q,"prompt")!==void 0,X=Q.html!==void 0,W=Q.blocks!==void 0;if(Q.prompt!==void 0&&!Y)throw Error("`prompt` cannot be empty when calling `create_transactional_email`.");if(Y&&(X||W))throw Error("Provide either `prompt`, `html`, or `blocks` when calling `create_transactional_email`, not multiple content sources.");if(!Y&&(Q.style!==void 0||Q.tone!==void 0))throw Error("`style` and `tone` can only be used with `prompt` when calling `create_transactional_email`.");if(!Y&&!X&&!W)throw Error("Provide either `prompt`, `html`, or `blocks` when calling `create_transactional_email`.");if(!Y&&I(Q,"subject")===void 0)throw Error("`subject` is required unless `prompt` is provided when calling `create_transactional_email`.")}var q5={type:"object",description:"A step to create inside a branch path. Use type:'delay' for a standalone delay, type:'email' for an email, or type:'create_discount' for a discount action.",properties:{type:{type:"string",enum:["email","delay","create_discount","discount","webhook"],description:"Branch path step type. Omit for email steps; use delay for standalone waits."},nodeType:{type:"string",enum:["logic_delay","action_email","action_create_discount","action_add_tag","action_remove_tag","action_add_to_list","action_remove_from_list","action_update_attributes","logic_wait_for_event","action_webhook"],description:"Advanced branch path node type. Prefer type unless creating a non-email action."},config:{type:"object",description:"Config for advanced nodeType steps such as tag/list/webhook/wait-for-event actions.",additionalProperties:!0},subject:{type:"string",description:"Email subject. Required for email steps."},previewText:{type:"string",description:"Email preview text."},blocks:{type:"array",description:M5,items:{type:"object"}},html:{type:"string",description:"HTML content for email steps."},delay:{type:"object",description:"Delay before this step, or the delay duration when type is delay.",properties:{days:{type:"number"},hours:{type:"number"},minutes:{type:"number"}}},delayMs:{type:"number",description:"Delay in milliseconds. Useful for standalone type:'delay' steps."},name:{type:"string",description:"Email template name for email steps."},discount:{type:"object",description:"Discount configuration for create_discount steps. Same shape as create_sequence steps.",additionalProperties:!0},label:{type:"string",description:"Node label for discount or advanced node steps."},provider:{type:"string",enum:["stripe","shopify"]},discountType:{type:"string",enum:["percent","amount"]},percentOff:{type:"number"},amountOff:{type:"number"},currency:{type:"string"},duration:{type:"string",enum:["once","forever","repeating"]},durationInMonths:{type:"number"},appliesToAllPlans:{type:"boolean"},planIds:{type:"array",items:{type:"string"}},codePrefix:{type:"string"},maxRedemptions:{type:"number"},lockToSubscriber:{type:"boolean"},expiresAt:{type:"string"},expiresInHours:{type:"number"}},additionalProperties:!1};function jM(Q){if(!Q||typeof Q!=="object")return null;let Y=Q;if(Y.success!==!1)return null;if(typeof Y.error==="string")return Error(Y.error);if(Y.error&&typeof Y.error==="object"&&typeof Y.error.message==="string")return Error(Y.error.message);if(typeof Y.message==="string")return Error(Y.message);return Error("The tool returned an unsuccessful response.")}function B0(Q){return typeof Q==="object"&&Q!==null&&!Array.isArray(Q)}function O5(Q){return Q.trim().toLowerCase().replace(/\s+/g,"-")}function EM(Q){let Y=new URLSearchParams;if(typeof Q.query==="string"&&Q.query.trim()!=="")Y.set("query",Q.query.trim());if(Array.isArray(Q.tags)&&Q.tags.length>0)Y.set("tags",Q.tags.filter((X)=>typeof X==="string"&&X.trim()!=="").join(","));if(typeof Q.segmentId==="string"&&Q.segmentId.trim()!=="")Y.set("segmentId",Q.segmentId);if(typeof Q.status==="string"&&Q.status.trim()!=="")Y.set("status",Q.status.trim());return Y.set("page",String(Q.page)),Y.set("limit",String(Q.pageSize)),Y}async function TM(Q,Y){let X=typeof Q.limit==="number"&&Number.isFinite(Q.limit)?Math.max(1,Math.trunc(Q.limit)):void 0,W=Math.min(100,Math.max(1,X??100)),G=[],$=1,J=0,z=0,H=0;while(!0){let U=EM({query:Q.query,tags:Q.tags,segmentId:Q.segmentId,status:Q.status,page:$,pageSize:W}),K=await N("GET",`/api/v1/subscribers?${U.toString()}`,void 0,Y);J=K.pagination?.total??K.subscribers.length,z=K.pagination?.totalPages??1,H+=1,G.push(...K.subscribers??[]);let D=X!==void 0&&G.length>=X,L=K.pagination?$>=K.pagination.totalPages:(K.subscribers??[]).length<W;if(D||L)break;$+=1}let A=X!==void 0?G.slice(0,X):G;return{success:!0,subscribers:A,pagination:{page:1,limit:W,total:J,totalPages:z,fetchedPages:H},returned:A.length,truncated:X!==void 0&&J>0&&A.length<J}}function SM(Q){let Y=typeof Q.email==="string"&&Q.email.trim()!==""?Q.email.trim():void 0,X=typeof Q.externalId==="string"&&Q.externalId.trim()!==""?Q.externalId.trim():void 0;return{...Y?{email:Y}:{},...X?{externalId:X}:{}}}function f4(Q,Y){let X=SM(Y);if(!X.email&&!X.externalId)throw Error(`Provide either \`email\` or \`externalId\` when calling \`${Q}\`.`);return X}function C9(Q){if(Q.email)return`/api/v1/subscribers/${encodeURIComponent(Q.email)}`;return`/api/v1/subscribers/external?externalId=${encodeURIComponent(String(Q.externalId))}`}async function R9(Q,Y){return N("GET",C9(Q),void 0,Y)}function I(Q,Y){let X=Q[Y];if(typeof X!=="string")return;let W=X.trim();return W.length>0?W:void 0}async function Z5(Q){let Y=I(Q,"companyId");if(Y)return Y;let X=s0();if(X)return X;try{return(await N("GET","/api/v1/account")).currentCompanyId??void 0}catch{return}}function l4(Q,Y){if(!B0(Q)||!Y)return Q;return{...Q,url:Y}}function w5(Q,Y){if(!B0(Q))return Q;return{...Q,...Y.campaign!==void 0&&{url:Y.campaign},...Y.campaignPreview!==void 0&&{previewUrl:Y.campaignPreview}}}function U6(Q,Y,X){if(!Array.isArray(Q)||!Y)return Q;return Q.map((W)=>{if(!B0(W))return W;let G=I(W,"id");if(!G)return W;let $=B1({companyId:Y,...X==="campaign"&&{campaignId:G},...X==="sequence"&&{sequenceId:G},...X==="template"&&{emailId:G},...X==="transactional"&&{transactionalId:G}});if(X==="campaign")return w5(W,$.urls);let J=X==="sequence"?$.urls.sequence:X==="template"?$.urls.email:$.urls.transactionalEmail;return l4(W,J)})}function RM(Q){if(!Array.isArray(Q))return Q;return Q.map((Y)=>{if(!B0(Y))return Y;let X=I(Y,"id");if(!X)return Y;let W=B1({companyId:X});return{...Y,url:W.urls.dashboard,settingsUrl:W.urls.settings}})}var CM=new Set(["get_account","select_company","create_company","get_company","list_campaigns","get_campaign","get_email_send","create_campaign","update_campaign","schedule_campaign","send_test_email","list_sequences","get_sequence","create_sequence","update_sequence","enable_sequence","disable_sequence","cancel_sequence_enrollments","list_ab_tests","get_ab_test","get_ab_test_stats","update_ab_test_variant","list_templates","get_template","create_template","update_template","list_transactional_emails","get_transactional_email","create_transactional_email","update_transactional_email"]);async function kM(Q,Y,X){if(!B0(X)||!CM.has(Q))return X;let W=B0(X.company)?X.company:void 0,$=I(X,"selectedCompanyId")??I(X,"currentCompanyId")??I(X,"companyId")??(W?I(W,"id"):void 0)??(W?I(W,"companyId"):void 0)??await Z5(Y);if(!$)return X;let J=B0(X.campaign)?X.campaign:void 0,z=B0(X.sequence)?X.sequence:void 0,H=B0(X.template)?X.template:void 0,A=B0(X.transactional)&&!Array.isArray(X.transactional)?X.transactional:void 0,U={companyId:$,campaignId:I(Y,"campaignId")??I(X,"campaignId")??(J?I(J,"id"):void 0),sequenceId:I(Y,"sequenceId")??I(X,"sequenceId")??(z?I(z,"id"):void 0),emailId:I(X,"templateId")??(H?I(H,"id"):void 0)??(A?I(A,"emailId"):void 0)??I(Y,"templateId"),transactionalId:I(Y,"transactionalId")??(A?I(A,"id"):void 0)??I(Y,"idOrSlug"),emailSendId:I(Y,"emailSendId")??I(X,"emailSendId")??(B0(X.emailSend)?I(X.emailSend,"id"):void 0),status:I(Y,"status")},K=B1(U),D=W?B1({companyId:$}):void 0;return{...X,...Array.isArray(X.companies)&&{companies:RM(X.companies)},...Array.isArray(X.campaigns)&&{campaigns:U6(X.campaigns,$,"campaign")},...Array.isArray(X.sequences)&&{sequences:U6(X.sequences,$,"sequence")},...Array.isArray(X.templates)&&{templates:U6(X.templates,$,"template")},...Array.isArray(X.transactional)&&{transactional:U6(X.transactional,$,"transactional")},...W&&D!==void 0&&{company:{...W,url:D.urls.dashboard,settingsUrl:D.urls.settings}},...J&&K.urls.campaign!==void 0&&{campaign:w5(J,K.urls)},...z&&K.urls.sequence!==void 0&&{sequence:l4(z,K.urls.sequence)},...H&&K.urls.email!==void 0&&{template:l4(H,K.urls.email)},...A&&K.urls.transactionalEmail!==void 0&&{transactional:l4(A,K.urls.transactionalEmail)},...B0(X.emailSend)&&K.urls.emailSend!==void 0&&{emailSend:l4(X.emailSend,K.urls.emailSend)},appUrls:K.urls}}var b5=[{name:"get_account",description:`Get current account information including available companies. IMPORTANT: If you have access to multiple companies, you MUST either:
30
30
  1. Call select_company first to choose which company to work with, OR
31
31
  2. Pass companyId explicitly in each tool call
32
32
 
package/dist/server.js CHANGED
@@ -25,7 +25,7 @@ var w5=Object.create;var{getPrototypeOf:b5,defineProperty:L6,getOwnPropertyNames
25
25
  newResult[${T}] = ${x}.value;
26
26
  }
27
27
 
28
- `)}L.write("payload.value = newResult;"),L.write("return payload;");let S=L.compile();return(E,x)=>S(D,E,x)},z,J=L1,$=!m4.jitless,A=$&&V6.value,U=Y.catchall,K;Q._zod.parse=(D,L)=>{K??(K=W.value);let q=D.value;if(!J(q))return D.issues.push({expected:"object",code:"invalid_type",input:q,inst:Q}),D;if($&&A&&L?.async===!1&&L.jitless!==!0){if(!z)z=G(Y.shape);if(D=z(D,L),!U)return D;return v8([],q,D,L,K,Q)}return X(D,L)}});function dX(Q,Y,X,W){for(let z of Q)if(z.issues.length===0)return Y.value=z.value,Y;let G=Q.filter((z)=>!Q1(z));if(G.length===1)return Y.value=G[0].value,G[0];return Y.issues.push({code:"invalid_union",input:Y.value,inst:X,errors:Q.map((z)=>z.issues.map((J)=>T0(J,W,w0())))}),Y}var C6=F("$ZodUnion",(Q,Y)=>{i.init(Q,Y),m(Q._zod,"optin",()=>Y.options.some((G)=>G._zod.optin==="optional")?"optional":void 0),m(Q._zod,"optout",()=>Y.options.some((G)=>G._zod.optout==="optional")?"optional":void 0),m(Q._zod,"values",()=>{if(Y.options.every((G)=>G._zod.values))return new Set(Y.options.flatMap((G)=>Array.from(G._zod.values)));return}),m(Q._zod,"pattern",()=>{if(Y.options.every((G)=>G._zod.pattern)){let G=Y.options.map((z)=>z._zod.pattern);return new RegExp(`^(${G.map((z)=>d1(z.source)).join("|")})$`)}return});let X=Y.options.length===1,W=Y.options[0]._zod.run;Q._zod.parse=(G,z)=>{if(X)return W(G,z);let J=!1,$=[];for(let H of Y.options){let A=H._zod.run({value:G.value,issues:[]},z);if(A instanceof Promise)$.push(A),J=!0;else{if(A.issues.length===0)return A;$.push(A)}}if(!J)return dX($,G,Q,z);return Promise.all($).then((H)=>{return dX(H,G,Q,z)})}}),x8=F("$ZodDiscriminatedUnion",(Q,Y)=>{C6.init(Q,Y);let X=Q._zod.parse;m(Q._zod,"propValues",()=>{let G={};for(let z of Y.options){let J=z._zod.propValues;if(!J||Object.keys(J).length===0)throw Error(`Invalid discriminated union option at index "${Y.options.indexOf(z)}"`);for(let[$,H]of Object.entries(J)){if(!G[$])G[$]=new Set;for(let A of H)G[$].add(A)}}return G});let W=j1(()=>{let G=Y.options,z=new Map;for(let J of G){let $=J._zod.propValues?.[Y.discriminator];if(!$||$.size===0)throw Error(`Invalid discriminated union option at index "${Y.options.indexOf(J)}"`);for(let H of $){if(z.has(H))throw Error(`Duplicate discriminator value "${String(H)}"`);z.set(H,J)}}return z});Q._zod.parse=(G,z)=>{let J=G.value;if(!L1(J))return G.issues.push({code:"invalid_type",expected:"object",input:J,inst:Q}),G;let $=W.value.get(J?.[Y.discriminator]);if($)return $._zod.run(G,z);if(Y.unionFallback)return X(G,z);return G.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:Y.discriminator,input:J,path:[Y.discriminator],inst:Q}),G}}),_8=F("$ZodIntersection",(Q,Y)=>{i.init(Q,Y),Q._zod.parse=(X,W)=>{let G=X.value,z=Y.left._zod.run({value:G,issues:[]},W),J=Y.right._zod.run({value:G,issues:[]},W);if(z instanceof Promise||J instanceof Promise)return Promise.all([z,J]).then(([H,A])=>{return oX(X,H,A)});return oX(X,z,J)}});function S6(Q,Y){if(Q===Y)return{valid:!0,data:Q};if(Q instanceof Date&&Y instanceof Date&&+Q===+Y)return{valid:!0,data:Q};if(e0(Q)&&e0(Y)){let X=Object.keys(Y),W=Object.keys(Q).filter((z)=>X.indexOf(z)!==-1),G={...Q,...Y};for(let z of W){let J=S6(Q[z],Y[z]);if(!J.valid)return{valid:!1,mergeErrorPath:[z,...J.mergeErrorPath]};G[z]=J.data}return{valid:!0,data:G}}if(Array.isArray(Q)&&Array.isArray(Y)){if(Q.length!==Y.length)return{valid:!1,mergeErrorPath:[]};let X=[];for(let W=0;W<Q.length;W++){let G=Q[W],z=Y[W],J=S6(G,z);if(!J.valid)return{valid:!1,mergeErrorPath:[W,...J.mergeErrorPath]};X.push(J.data)}return{valid:!0,data:X}}return{valid:!1,mergeErrorPath:[]}}function oX(Q,Y,X){if(Y.issues.length)Q.issues.push(...Y.issues);if(X.issues.length)Q.issues.push(...X.issues);if(Q1(Q))return Q;let W=S6(Y.value,X.value);if(!W.valid)throw Error(`Unmergable intersection. Error path: ${JSON.stringify(W.mergeErrorPath)}`);return Q.value=W.data,Q}var g8=F("$ZodRecord",(Q,Y)=>{i.init(Q,Y),Q._zod.parse=(X,W)=>{let G=X.value;if(!e0(G))return X.issues.push({expected:"record",code:"invalid_type",input:G,inst:Q}),X;let z=[];if(Y.keyType._zod.values){let J=Y.keyType._zod.values;X.value={};for(let H of J)if(typeof H==="string"||typeof H==="number"||typeof H==="symbol"){let A=Y.valueType._zod.run({value:G[H],issues:[]},W);if(A instanceof Promise)z.push(A.then((U)=>{if(U.issues.length)X.issues.push(...c0(H,U.issues));X.value[H]=U.value}));else{if(A.issues.length)X.issues.push(...c0(H,A.issues));X.value[H]=A.value}}let $;for(let H in G)if(!J.has(H))$=$??[],$.push(H);if($&&$.length>0)X.issues.push({code:"unrecognized_keys",input:G,inst:Q,keys:$})}else{X.value={};for(let J of Reflect.ownKeys(G)){if(J==="__proto__")continue;let $=Y.keyType._zod.run({value:J,issues:[]},W);if($ instanceof Promise)throw Error("Async schemas not supported in object keys currently");if($.issues.length){X.issues.push({code:"invalid_key",origin:"record",issues:$.issues.map((A)=>T0(A,W,w0())),input:J,path:[J],inst:Q}),X.value[$.value]=$.value;continue}let H=Y.valueType._zod.run({value:G[J],issues:[]},W);if(H instanceof Promise)z.push(H.then((A)=>{if(A.issues.length)X.issues.push(...c0(J,A.issues));X.value[$.value]=A.value}));else{if(H.issues.length)X.issues.push(...c0(J,H.issues));X.value[$.value]=H.value}}}if(z.length)return Promise.all(z).then(()=>X);return X}});var y8=F("$ZodEnum",(Q,Y)=>{i.init(Q,Y);let X=O6(Y.entries),W=new Set(X);Q._zod.values=W,Q._zod.pattern=new RegExp(`^(${X.filter((G)=>N6.has(typeof G)).map((G)=>typeof G==="string"?m0(G):G.toString()).join("|")})$`),Q._zod.parse=(G,z)=>{let J=G.value;if(W.has(J))return G;return G.issues.push({code:"invalid_value",values:X,input:J,inst:Q}),G}}),u8=F("$ZodLiteral",(Q,Y)=>{if(i.init(Q,Y),Y.values.length===0)throw Error("Cannot create literal schema with no valid values");Q._zod.values=new Set(Y.values),Q._zod.pattern=new RegExp(`^(${Y.values.map((X)=>typeof X==="string"?m0(X):X?m0(X.toString()):String(X)).join("|")})$`),Q._zod.parse=(X,W)=>{let G=X.value;if(Q._zod.values.has(G))return X;return X.issues.push({code:"invalid_value",values:Y.values,input:G,inst:Q}),X}});var h8=F("$ZodTransform",(Q,Y)=>{i.init(Q,Y),Q._zod.parse=(X,W)=>{if(W.direction==="backward")throw new i1(Q.constructor.name);let G=Y.transform(X.value,X);if(W.async)return(G instanceof Promise?G:Promise.resolve(G)).then((J)=>{return X.value=J,X});if(G instanceof Promise)throw new l0;return X.value=G,X}});function tX(Q,Y){if(Q.issues.length&&Y===void 0)return{issues:[],value:void 0};return Q}var f8=F("$ZodOptional",(Q,Y)=>{i.init(Q,Y),Q._zod.optin="optional",Q._zod.optout="optional",m(Q._zod,"values",()=>{return Y.innerType._zod.values?new Set([...Y.innerType._zod.values,void 0]):void 0}),m(Q._zod,"pattern",()=>{let X=Y.innerType._zod.pattern;return X?new RegExp(`^(${d1(X.source)})?$`):void 0}),Q._zod.parse=(X,W)=>{if(Y.innerType._zod.optin==="optional"){let G=Y.innerType._zod.run(X,W);if(G instanceof Promise)return G.then((z)=>tX(z,X.value));return tX(G,X.value)}if(X.value===void 0)return X;return Y.innerType._zod.run(X,W)}}),l8=F("$ZodNullable",(Q,Y)=>{i.init(Q,Y),m(Q._zod,"optin",()=>Y.innerType._zod.optin),m(Q._zod,"optout",()=>Y.innerType._zod.optout),m(Q._zod,"pattern",()=>{let X=Y.innerType._zod.pattern;return X?new RegExp(`^(${d1(X.source)}|null)$`):void 0}),m(Q._zod,"values",()=>{return Y.innerType._zod.values?new Set([...Y.innerType._zod.values,null]):void 0}),Q._zod.parse=(X,W)=>{if(X.value===null)return X;return Y.innerType._zod.run(X,W)}}),m8=F("$ZodDefault",(Q,Y)=>{i.init(Q,Y),Q._zod.optin="optional",m(Q._zod,"values",()=>Y.innerType._zod.values),Q._zod.parse=(X,W)=>{if(W.direction==="backward")return Y.innerType._zod.run(X,W);if(X.value===void 0)return X.value=Y.defaultValue,X;let G=Y.innerType._zod.run(X,W);if(G instanceof Promise)return G.then((z)=>aX(z,Y));return aX(G,Y)}});function aX(Q,Y){if(Q.value===void 0)Q.value=Y.defaultValue;return Q}var c8=F("$ZodPrefault",(Q,Y)=>{i.init(Q,Y),Q._zod.optin="optional",m(Q._zod,"values",()=>Y.innerType._zod.values),Q._zod.parse=(X,W)=>{if(W.direction==="backward")return Y.innerType._zod.run(X,W);if(X.value===void 0)X.value=Y.defaultValue;return Y.innerType._zod.run(X,W)}}),p8=F("$ZodNonOptional",(Q,Y)=>{i.init(Q,Y),m(Q._zod,"values",()=>{let X=Y.innerType._zod.values;return X?new Set([...X].filter((W)=>W!==void 0)):void 0}),Q._zod.parse=(X,W)=>{let G=Y.innerType._zod.run(X,W);if(G instanceof Promise)return G.then((z)=>sX(z,Q));return sX(G,Q)}});function sX(Q,Y){if(!Q.issues.length&&Q.value===void 0)Q.issues.push({code:"invalid_type",expected:"nonoptional",input:Q.value,inst:Y});return Q}var i8=F("$ZodCatch",(Q,Y)=>{i.init(Q,Y),m(Q._zod,"optin",()=>Y.innerType._zod.optin),m(Q._zod,"optout",()=>Y.innerType._zod.optout),m(Q._zod,"values",()=>Y.innerType._zod.values),Q._zod.parse=(X,W)=>{if(W.direction==="backward")return Y.innerType._zod.run(X,W);let G=Y.innerType._zod.run(X,W);if(G instanceof Promise)return G.then((z)=>{if(X.value=z.value,z.issues.length)X.value=Y.catchValue({...X,error:{issues:z.issues.map((J)=>T0(J,W,w0()))},input:X.value}),X.issues=[];return X});if(X.value=G.value,G.issues.length)X.value=Y.catchValue({...X,error:{issues:G.issues.map((z)=>T0(z,W,w0()))},input:X.value}),X.issues=[];return X}});var r8=F("$ZodPipe",(Q,Y)=>{i.init(Q,Y),m(Q._zod,"values",()=>Y.in._zod.values),m(Q._zod,"optin",()=>Y.in._zod.optin),m(Q._zod,"optout",()=>Y.out._zod.optout),m(Q._zod,"propValues",()=>Y.in._zod.propValues),Q._zod.parse=(X,W)=>{if(W.direction==="backward"){let z=Y.out._zod.run(X,W);if(z instanceof Promise)return z.then((J)=>s4(J,Y.in,W));return s4(z,Y.in,W)}let G=Y.in._zod.run(X,W);if(G instanceof Promise)return G.then((z)=>s4(z,Y.out,W));return s4(G,Y.out,W)}});function s4(Q,Y,X){if(Q.issues.length)return Q.aborted=!0,Q;return Y._zod.run({value:Q.value,issues:Q.issues},X)}var n8=F("$ZodReadonly",(Q,Y)=>{i.init(Q,Y),m(Q._zod,"propValues",()=>Y.innerType._zod.propValues),m(Q._zod,"values",()=>Y.innerType._zod.values),m(Q._zod,"optin",()=>Y.innerType._zod.optin),m(Q._zod,"optout",()=>Y.innerType._zod.optout),Q._zod.parse=(X,W)=>{if(W.direction==="backward")return Y.innerType._zod.run(X,W);let G=Y.innerType._zod.run(X,W);if(G instanceof Promise)return G.then(eX);return eX(G)}});function eX(Q){return Q.value=Object.freeze(Q.value),Q}var d8=F("$ZodCustom",(Q,Y)=>{W0.init(Q,Y),i.init(Q,Y),Q._zod.parse=(X,W)=>{return X},Q._zod.check=(X)=>{let W=X.value,G=Y.fn(W);if(G instanceof Promise)return G.then((z)=>Q8(z,X,W,Q));Q8(G,X,W,Q);return}});function Q8(Q,Y,X,W){if(!Q){let G={code:"custom",input:X,inst:W,path:[...W._zod.def.path??[]],continue:!W._zod.def.abort};if(W._zod.def.params)G.params=W._zod.def.params;Y.issues.push(I1(G))}}var FH=(Q)=>{let Y=typeof Q;switch(Y){case"number":return Number.isNaN(Q)?"NaN":"number";case"object":{if(Array.isArray(Q))return"array";if(Q===null)return"null";if(Object.getPrototypeOf(Q)!==Object.prototype&&Q.constructor)return Q.constructor.name}}return Y},qH=()=>{let Q={string:{unit:"characters",verb:"to have"},file:{unit:"bytes",verb:"to have"},array:{unit:"items",verb:"to have"},set:{unit:"items",verb:"to have"}};function Y(W){return Q[W]??null}let X={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",jwt:"JWT",template_literal:"input"};return(W)=>{switch(W.code){case"invalid_type":return`Invalid input: expected ${W.expected}, received ${FH(W.input)}`;case"invalid_value":if(W.values.length===1)return`Invalid input: expected ${r4(W.values[0])}`;return`Invalid option: expected one of ${c4(W.values,"|")}`;case"too_big":{let G=W.inclusive?"<=":"<",z=Y(W.origin);if(z)return`Too big: expected ${W.origin??"value"} to have ${G}${W.maximum.toString()} ${z.unit??"elements"}`;return`Too big: expected ${W.origin??"value"} to be ${G}${W.maximum.toString()}`}case"too_small":{let G=W.inclusive?">=":">",z=Y(W.origin);if(z)return`Too small: expected ${W.origin} to have ${G}${W.minimum.toString()} ${z.unit}`;return`Too small: expected ${W.origin} to be ${G}${W.minimum.toString()}`}case"invalid_format":{let G=W;if(G.format==="starts_with")return`Invalid string: must start with "${G.prefix}"`;if(G.format==="ends_with")return`Invalid string: must end with "${G.suffix}"`;if(G.format==="includes")return`Invalid string: must include "${G.includes}"`;if(G.format==="regex")return`Invalid string: must match pattern ${G.pattern}`;return`Invalid ${X[G.format]??W.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${W.divisor}`;case"unrecognized_keys":return`Unrecognized key${W.keys.length>1?"s":""}: ${c4(W.keys,", ")}`;case"invalid_key":return`Invalid key in ${W.origin}`;case"invalid_union":return"Invalid input";case"invalid_element":return`Invalid value in ${W.origin}`;default:return"Invalid input"}}};function v6(){return{localeError:qH()}}var nM=Symbol("ZodOutput"),dM=Symbol("ZodInput");class o8{constructor(){this._map=new WeakMap,this._idmap=new Map}add(Q,...Y){let X=Y[0];if(this._map.set(Q,X),X&&typeof X==="object"&&"id"in X){if(this._idmap.has(X.id))throw Error(`ID ${X.id} already exists in the registry`);this._idmap.set(X.id,Q)}return this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(Q){let Y=this._map.get(Q);if(Y&&typeof Y==="object"&&"id"in Y)this._idmap.delete(Y.id);return this._map.delete(Q),this}get(Q){let Y=Q._zod.parent;if(Y){let X={...this.get(Y)??{}};delete X.id;let W={...X,...this._map.get(Q)};return Object.keys(W).length?W:void 0}return this._map.get(Q)}has(Q){return this._map.has(Q)}}function OH(){return new o8}var Q4=OH();function t8(Q,Y){return new Q({type:"string",...I(Y)})}function a8(Q,Y){return new Q({type:"string",format:"email",check:"string_format",abort:!1,...I(Y)})}function k6(Q,Y){return new Q({type:"string",format:"guid",check:"string_format",abort:!1,...I(Y)})}function s8(Q,Y){return new Q({type:"string",format:"uuid",check:"string_format",abort:!1,...I(Y)})}function e8(Q,Y){return new Q({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...I(Y)})}function QW(Q,Y){return new Q({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...I(Y)})}function YW(Q,Y){return new Q({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...I(Y)})}function XW(Q,Y){return new Q({type:"string",format:"url",check:"string_format",abort:!1,...I(Y)})}function WW(Q,Y){return new Q({type:"string",format:"emoji",check:"string_format",abort:!1,...I(Y)})}function GW(Q,Y){return new Q({type:"string",format:"nanoid",check:"string_format",abort:!1,...I(Y)})}function zW(Q,Y){return new Q({type:"string",format:"cuid",check:"string_format",abort:!1,...I(Y)})}function JW(Q,Y){return new Q({type:"string",format:"cuid2",check:"string_format",abort:!1,...I(Y)})}function $W(Q,Y){return new Q({type:"string",format:"ulid",check:"string_format",abort:!1,...I(Y)})}function HW(Q,Y){return new Q({type:"string",format:"xid",check:"string_format",abort:!1,...I(Y)})}function AW(Q,Y){return new Q({type:"string",format:"ksuid",check:"string_format",abort:!1,...I(Y)})}function UW(Q,Y){return new Q({type:"string",format:"ipv4",check:"string_format",abort:!1,...I(Y)})}function KW(Q,Y){return new Q({type:"string",format:"ipv6",check:"string_format",abort:!1,...I(Y)})}function DW(Q,Y){return new Q({type:"string",format:"cidrv4",check:"string_format",abort:!1,...I(Y)})}function BW(Q,Y){return new Q({type:"string",format:"cidrv6",check:"string_format",abort:!1,...I(Y)})}function LW(Q,Y){return new Q({type:"string",format:"base64",check:"string_format",abort:!1,...I(Y)})}function FW(Q,Y){return new Q({type:"string",format:"base64url",check:"string_format",abort:!1,...I(Y)})}function qW(Q,Y){return new Q({type:"string",format:"e164",check:"string_format",abort:!1,...I(Y)})}function OW(Q,Y){return new Q({type:"string",format:"jwt",check:"string_format",abort:!1,...I(Y)})}function MW(Q,Y){return new Q({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...I(Y)})}function VW(Q,Y){return new Q({type:"string",format:"date",check:"string_format",...I(Y)})}function NW(Q,Y){return new Q({type:"string",format:"time",check:"string_format",precision:null,...I(Y)})}function ZW(Q,Y){return new Q({type:"string",format:"duration",check:"string_format",...I(Y)})}function wW(Q,Y){return new Q({type:"number",checks:[],...I(Y)})}function bW(Q,Y){return new Q({type:"number",check:"number_format",abort:!1,format:"safeint",...I(Y)})}function PW(Q,Y){return new Q({type:"boolean",...I(Y)})}function jW(Q,Y){return new Q({type:"null",...I(Y)})}function IW(Q){return new Q({type:"unknown"})}function EW(Q,Y){return new Q({type:"never",...I(Y)})}function YQ(Q,Y){return new I6({check:"less_than",...I(Y),value:Q,inclusive:!1})}function Y4(Q,Y){return new I6({check:"less_than",...I(Y),value:Q,inclusive:!0})}function XQ(Q,Y){return new E6({check:"greater_than",...I(Y),value:Q,inclusive:!1})}function X4(Q,Y){return new E6({check:"greater_than",...I(Y),value:Q,inclusive:!0})}function WQ(Q,Y){return new kX({check:"multiple_of",...I(Y),value:Q})}function GQ(Q,Y){return new _X({check:"max_length",...I(Y),maximum:Q})}function E1(Q,Y){return new gX({check:"min_length",...I(Y),minimum:Q})}function zQ(Q,Y){return new yX({check:"length_equals",...I(Y),length:Q})}function x6(Q,Y){return new uX({check:"string_format",format:"regex",...I(Y),pattern:Q})}function _6(Q){return new hX({check:"string_format",format:"lowercase",...I(Q)})}function g6(Q){return new fX({check:"string_format",format:"uppercase",...I(Q)})}function y6(Q,Y){return new lX({check:"string_format",format:"includes",...I(Y),includes:Q})}function u6(Q,Y){return new mX({check:"string_format",format:"starts_with",...I(Y),prefix:Q})}function h6(Q,Y){return new cX({check:"string_format",format:"ends_with",...I(Y),suffix:Q})}function F1(Q){return new pX({check:"overwrite",tx:Q})}function f6(Q){return F1((Y)=>Y.normalize(Q))}function l6(){return F1((Q)=>Q.trim())}function m6(){return F1((Q)=>Q.toLowerCase())}function c6(){return F1((Q)=>Q.toUpperCase())}function TW(Q,Y,X){return new Q({type:"array",element:Y,...I(X)})}function SW(Q,Y,X){let W=I(X);return W.abort??(W.abort=!0),new Q({type:"custom",check:"custom",fn:Y,...W})}function RW(Q,Y,X){return new Q({type:"custom",check:"custom",fn:Y,...I(X)})}function CW(Q){let Y=MH((X)=>{return X.addIssue=(W)=>{if(typeof W==="string")X.issues.push(I1(W,X.value,Y._zod.def));else{let G=W;if(G.fatal)G.continue=!1;G.code??(G.code="custom"),G.input??(G.input=X.value),G.inst??(G.inst=Y),G.continue??(G.continue=!Y._zod.def.abort),X.issues.push(I1(G))}},Q(X.value,X)});return Y}function MH(Q,Y){let X=new W0({check:"custom",...I(Y)});return X._zod.check=Q,X}function T1(Q){return!!Q._zod}function Y1(Q,Y){if(T1(Q))return a1(Q,Y);return Q.safeParse(Y)}function JQ(Q){if(!Q)return;let Y;if(T1(Q))Y=Q._zod?.def?.shape;else Y=Q.shape;if(!Y)return;if(typeof Y==="function")try{return Y()}catch{return}return Y}function vW(Q){if(T1(Q)){let z=Q._zod?.def;if(z){if(z.value!==void 0)return z.value;if(Array.isArray(z.values)&&z.values.length>0)return z.values[0]}}let X=Q._def;if(X){if(X.value!==void 0)return X.value;if(Array.isArray(X.values)&&X.values.length>0)return X.values[0]}let W=Q.value;if(W!==void 0)return W;return}var G4={};x9(G4,{time:()=>r6,duration:()=>n6,datetime:()=>p6,date:()=>i6,ZodISOTime:()=>_W,ZodISODuration:()=>gW,ZodISODateTime:()=>kW,ZodISODate:()=>xW});var kW=F("ZodISODateTime",(Q,Y)=>{D8.init(Q,Y),d.init(Q,Y)});function p6(Q){return MW(kW,Q)}var xW=F("ZodISODate",(Q,Y)=>{B8.init(Q,Y),d.init(Q,Y)});function i6(Q){return VW(xW,Q)}var _W=F("ZodISOTime",(Q,Y)=>{L8.init(Q,Y),d.init(Q,Y)});function r6(Q){return NW(_W,Q)}var gW=F("ZodISODuration",(Q,Y)=>{F8.init(Q,Y),d.init(Q,Y)});function n6(Q){return ZW(gW,Q)}var yW=(Q,Y)=>{n4.init(Q,Y),Q.name="ZodError",Object.defineProperties(Q,{format:{value:(X)=>d9(Q,X)},flatten:{value:(X)=>n9(Q,X)},addIssue:{value:(X)=>{Q.issues.push(X),Q.message=JSON.stringify(Q.issues,P1,2)}},addIssues:{value:(X)=>{Q.issues.push(...X),Q.message=JSON.stringify(Q.issues,P1,2)}},isEmpty:{get(){return Q.issues.length===0}}})},kV=F("ZodError",yW),N0=F("ZodError",yW,{Parent:Error});var uW=d4(N0),hW=o4(N0),fW=t1(N0),lW=s1(N0),mW=o9(N0),cW=t9(N0),pW=a9(N0),iW=s9(N0),rW=e9(N0),nW=QX(N0),dW=YX(N0),oW=XX(N0);var s=F("ZodType",(Q,Y)=>{return i.init(Q,Y),Q.def=Y,Q.type=Y.type,Object.defineProperty(Q,"_def",{value:Y}),Q.check=(...X)=>{return Q.clone(h.mergeDefs(Y,{checks:[...Y.checks??[],...X.map((W)=>typeof W==="function"?{_zod:{check:W,def:{check:"custom"},onattach:[]}}:W)]}))},Q.clone=(X,W)=>E0(Q,X,W),Q.brand=()=>Q,Q.register=(X,W)=>{return X.add(Q,W),Q},Q.parse=(X,W)=>uW(Q,X,W,{callee:Q.parse}),Q.safeParse=(X,W)=>fW(Q,X,W),Q.parseAsync=async(X,W)=>hW(Q,X,W,{callee:Q.parseAsync}),Q.safeParseAsync=async(X,W)=>lW(Q,X,W),Q.spa=Q.safeParseAsync,Q.encode=(X,W)=>mW(Q,X,W),Q.decode=(X,W)=>cW(Q,X,W),Q.encodeAsync=async(X,W)=>pW(Q,X,W),Q.decodeAsync=async(X,W)=>iW(Q,X,W),Q.safeEncode=(X,W)=>rW(Q,X,W),Q.safeDecode=(X,W)=>nW(Q,X,W),Q.safeEncodeAsync=async(X,W)=>dW(Q,X,W),Q.safeDecodeAsync=async(X,W)=>oW(Q,X,W),Q.refine=(X,W)=>Q.check(LA(X,W)),Q.superRefine=(X)=>Q.check(FA(X)),Q.overwrite=(X)=>Q.check(F1(X)),Q.optional=()=>a(Q),Q.nullable=()=>sW(Q),Q.nullish=()=>a(sW(Q)),Q.nonoptional=(X)=>HA(Q,X),Q.array=()=>_(Q),Q.or=(X)=>p([Q,X]),Q.and=(X)=>HQ(Q,X),Q.transform=(X)=>o6(Q,WG(X)),Q.default=(X)=>zA(Q,X),Q.prefault=(X)=>$A(Q,X),Q.catch=(X)=>UA(Q,X),Q.pipe=(X)=>o6(Q,X),Q.readonly=()=>BA(Q),Q.describe=(X)=>{let W=Q.clone();return Q4.add(W,{description:X}),W},Object.defineProperty(Q,"description",{get(){return Q4.get(Q)?.description},configurable:!0}),Q.meta=(...X)=>{if(X.length===0)return Q4.get(Q);let W=Q.clone();return Q4.add(W,X[0]),W},Q.isOptional=()=>Q.safeParse(void 0).success,Q.isNullable=()=>Q.safeParse(null).success,Q}),eW=F("_ZodString",(Q,Y)=>{QQ.init(Q,Y),s.init(Q,Y);let X=Q._zod.bag;Q.format=X.format??null,Q.minLength=X.minimum??null,Q.maxLength=X.maximum??null,Q.regex=(...W)=>Q.check(x6(...W)),Q.includes=(...W)=>Q.check(y6(...W)),Q.startsWith=(...W)=>Q.check(u6(...W)),Q.endsWith=(...W)=>Q.check(h6(...W)),Q.min=(...W)=>Q.check(E1(...W)),Q.max=(...W)=>Q.check(GQ(...W)),Q.length=(...W)=>Q.check(zQ(...W)),Q.nonempty=(...W)=>Q.check(E1(1,...W)),Q.lowercase=(W)=>Q.check(_6(W)),Q.uppercase=(W)=>Q.check(g6(W)),Q.trim=()=>Q.check(l6()),Q.normalize=(...W)=>Q.check(f6(...W)),Q.toLowerCase=()=>Q.check(m6()),Q.toUpperCase=()=>Q.check(c6())}),EH=F("ZodString",(Q,Y)=>{QQ.init(Q,Y),eW.init(Q,Y),Q.email=(X)=>Q.check(a8(TH,X)),Q.url=(X)=>Q.check(XW(SH,X)),Q.jwt=(X)=>Q.check(OW(pH,X)),Q.emoji=(X)=>Q.check(WW(RH,X)),Q.guid=(X)=>Q.check(k6(tW,X)),Q.uuid=(X)=>Q.check(s8($Q,X)),Q.uuidv4=(X)=>Q.check(e8($Q,X)),Q.uuidv6=(X)=>Q.check(QW($Q,X)),Q.uuidv7=(X)=>Q.check(YW($Q,X)),Q.nanoid=(X)=>Q.check(GW(CH,X)),Q.guid=(X)=>Q.check(k6(tW,X)),Q.cuid=(X)=>Q.check(zW(vH,X)),Q.cuid2=(X)=>Q.check(JW(kH,X)),Q.ulid=(X)=>Q.check($W(xH,X)),Q.base64=(X)=>Q.check(LW(lH,X)),Q.base64url=(X)=>Q.check(FW(mH,X)),Q.xid=(X)=>Q.check(HW(_H,X)),Q.ksuid=(X)=>Q.check(AW(gH,X)),Q.ipv4=(X)=>Q.check(UW(yH,X)),Q.ipv6=(X)=>Q.check(KW(uH,X)),Q.cidrv4=(X)=>Q.check(DW(hH,X)),Q.cidrv6=(X)=>Q.check(BW(fH,X)),Q.e164=(X)=>Q.check(qW(cH,X)),Q.datetime=(X)=>Q.check(p6(X)),Q.date=(X)=>Q.check(i6(X)),Q.time=(X)=>Q.check(r6(X)),Q.duration=(X)=>Q.check(n6(X))});function B(Q){return t8(EH,Q)}var d=F("ZodStringFormat",(Q,Y)=>{r.init(Q,Y),eW.init(Q,Y)}),TH=F("ZodEmail",(Q,Y)=>{W8.init(Q,Y),d.init(Q,Y)});var tW=F("ZodGUID",(Q,Y)=>{Y8.init(Q,Y),d.init(Q,Y)});var $Q=F("ZodUUID",(Q,Y)=>{X8.init(Q,Y),d.init(Q,Y)});var SH=F("ZodURL",(Q,Y)=>{G8.init(Q,Y),d.init(Q,Y)});var RH=F("ZodEmoji",(Q,Y)=>{z8.init(Q,Y),d.init(Q,Y)});var CH=F("ZodNanoID",(Q,Y)=>{J8.init(Q,Y),d.init(Q,Y)});var vH=F("ZodCUID",(Q,Y)=>{$8.init(Q,Y),d.init(Q,Y)});var kH=F("ZodCUID2",(Q,Y)=>{H8.init(Q,Y),d.init(Q,Y)});var xH=F("ZodULID",(Q,Y)=>{A8.init(Q,Y),d.init(Q,Y)});var _H=F("ZodXID",(Q,Y)=>{U8.init(Q,Y),d.init(Q,Y)});var gH=F("ZodKSUID",(Q,Y)=>{K8.init(Q,Y),d.init(Q,Y)});var yH=F("ZodIPv4",(Q,Y)=>{q8.init(Q,Y),d.init(Q,Y)});var uH=F("ZodIPv6",(Q,Y)=>{O8.init(Q,Y),d.init(Q,Y)});var hH=F("ZodCIDRv4",(Q,Y)=>{M8.init(Q,Y),d.init(Q,Y)});var fH=F("ZodCIDRv6",(Q,Y)=>{V8.init(Q,Y),d.init(Q,Y)});var lH=F("ZodBase64",(Q,Y)=>{Z8.init(Q,Y),d.init(Q,Y)});var mH=F("ZodBase64URL",(Q,Y)=>{w8.init(Q,Y),d.init(Q,Y)});var cH=F("ZodE164",(Q,Y)=>{b8.init(Q,Y),d.init(Q,Y)});var pH=F("ZodJWT",(Q,Y)=>{P8.init(Q,Y),d.init(Q,Y)});var QG=F("ZodNumber",(Q,Y)=>{R6.init(Q,Y),s.init(Q,Y),Q.gt=(W,G)=>Q.check(XQ(W,G)),Q.gte=(W,G)=>Q.check(X4(W,G)),Q.min=(W,G)=>Q.check(X4(W,G)),Q.lt=(W,G)=>Q.check(YQ(W,G)),Q.lte=(W,G)=>Q.check(Y4(W,G)),Q.max=(W,G)=>Q.check(Y4(W,G)),Q.int=(W)=>Q.check(aW(W)),Q.safe=(W)=>Q.check(aW(W)),Q.positive=(W)=>Q.check(XQ(0,W)),Q.nonnegative=(W)=>Q.check(X4(0,W)),Q.negative=(W)=>Q.check(YQ(0,W)),Q.nonpositive=(W)=>Q.check(Y4(0,W)),Q.multipleOf=(W,G)=>Q.check(WQ(W,G)),Q.step=(W,G)=>Q.check(WQ(W,G)),Q.finite=()=>Q;let X=Q._zod.bag;Q.minValue=Math.max(X.minimum??Number.NEGATIVE_INFINITY,X.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,Q.maxValue=Math.min(X.maximum??Number.POSITIVE_INFINITY,X.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,Q.isInt=(X.format??"").includes("int")||Number.isSafeInteger(X.multipleOf??0.5),Q.isFinite=!0,Q.format=X.format??null});function l(Q){return wW(QG,Q)}var iH=F("ZodNumberFormat",(Q,Y)=>{j8.init(Q,Y),QG.init(Q,Y)});function aW(Q){return bW(iH,Q)}var rH=F("ZodBoolean",(Q,Y)=>{I8.init(Q,Y),s.init(Q,Y)});function X0(Q){return PW(rH,Q)}var nH=F("ZodNull",(Q,Y)=>{E8.init(Q,Y),s.init(Q,Y)});function t6(Q){return jW(nH,Q)}var dH=F("ZodUnknown",(Q,Y)=>{T8.init(Q,Y),s.init(Q,Y)});function o(){return IW(dH)}var oH=F("ZodNever",(Q,Y)=>{S8.init(Q,Y),s.init(Q,Y)});function tH(Q){return EW(oH,Q)}var aH=F("ZodArray",(Q,Y)=>{R8.init(Q,Y),s.init(Q,Y),Q.element=Y.element,Q.min=(X,W)=>Q.check(E1(X,W)),Q.nonempty=(X)=>Q.check(E1(1,X)),Q.max=(X,W)=>Q.check(GQ(X,W)),Q.length=(X,W)=>Q.check(zQ(X,W)),Q.unwrap=()=>Q.element});function _(Q,Y){return TW(aH,Q,Y)}var YG=F("ZodObject",(Q,Y)=>{k8.init(Q,Y),s.init(Q,Y),h.defineLazy(Q,"shape",()=>{return Y.shape}),Q.keyof=()=>L0(Object.keys(Q._zod.def.shape)),Q.catchall=(X)=>Q.clone({...Q._zod.def,catchall:X}),Q.passthrough=()=>Q.clone({...Q._zod.def,catchall:o()}),Q.loose=()=>Q.clone({...Q._zod.def,catchall:o()}),Q.strict=()=>Q.clone({...Q._zod.def,catchall:tH()}),Q.strip=()=>Q.clone({...Q._zod.def,catchall:void 0}),Q.extend=(X)=>{return h.extend(Q,X)},Q.safeExtend=(X)=>{return h.safeExtend(Q,X)},Q.merge=(X)=>h.merge(Q,X),Q.pick=(X)=>h.pick(Q,X),Q.omit=(X)=>h.omit(Q,X),Q.partial=(...X)=>h.partial(GG,Q,X[0]),Q.required=(...X)=>h.required(zG,Q,X[0])});function w(Q,Y){let X={type:"object",shape:Q??{},...h.normalizeParams(Y)};return new YG(X)}function U0(Q,Y){return new YG({type:"object",shape:Q,catchall:o(),...h.normalizeParams(Y)})}var XG=F("ZodUnion",(Q,Y)=>{C6.init(Q,Y),s.init(Q,Y),Q.options=Y.options});function p(Q,Y){return new XG({type:"union",options:Q,...h.normalizeParams(Y)})}var sH=F("ZodDiscriminatedUnion",(Q,Y)=>{XG.init(Q,Y),x8.init(Q,Y)});function a6(Q,Y,X){return new sH({type:"union",options:Y,discriminator:Q,...h.normalizeParams(X)})}var eH=F("ZodIntersection",(Q,Y)=>{_8.init(Q,Y),s.init(Q,Y)});function HQ(Q,Y){return new eH({type:"intersection",left:Q,right:Y})}var QA=F("ZodRecord",(Q,Y)=>{g8.init(Q,Y),s.init(Q,Y),Q.keyType=Y.keyType,Q.valueType=Y.valueType});function t(Q,Y,X){return new QA({type:"record",keyType:Q,valueType:Y,...h.normalizeParams(X)})}var d6=F("ZodEnum",(Q,Y)=>{y8.init(Q,Y),s.init(Q,Y),Q.enum=Y.entries,Q.options=Object.values(Y.entries);let X=new Set(Object.keys(Y.entries));Q.extract=(W,G)=>{let z={};for(let J of W)if(X.has(J))z[J]=Y.entries[J];else throw Error(`Key ${J} not found in enum`);return new d6({...Y,checks:[],...h.normalizeParams(G),entries:z})},Q.exclude=(W,G)=>{let z={...Y.entries};for(let J of W)if(X.has(J))delete z[J];else throw Error(`Key ${J} not found in enum`);return new d6({...Y,checks:[],...h.normalizeParams(G),entries:z})}});function L0(Q,Y){let X=Array.isArray(Q)?Object.fromEntries(Q.map((W)=>[W,W])):Q;return new d6({type:"enum",entries:X,...h.normalizeParams(Y)})}var YA=F("ZodLiteral",(Q,Y)=>{u8.init(Q,Y),s.init(Q,Y),Q.values=new Set(Y.values),Object.defineProperty(Q,"value",{get(){if(Y.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return Y.values[0]}})});function b(Q,Y){return new YA({type:"literal",values:Array.isArray(Q)?Q:[Q],...h.normalizeParams(Y)})}var XA=F("ZodTransform",(Q,Y)=>{h8.init(Q,Y),s.init(Q,Y),Q._zod.parse=(X,W)=>{if(W.direction==="backward")throw new i1(Q.constructor.name);X.addIssue=(z)=>{if(typeof z==="string")X.issues.push(h.issue(z,X.value,Y));else{let J=z;if(J.fatal)J.continue=!1;J.code??(J.code="custom"),J.input??(J.input=X.value),J.inst??(J.inst=Q),X.issues.push(h.issue(J))}};let G=Y.transform(X.value,X);if(G instanceof Promise)return G.then((z)=>{return X.value=z,X});return X.value=G,X}});function WG(Q){return new XA({type:"transform",transform:Q})}var GG=F("ZodOptional",(Q,Y)=>{f8.init(Q,Y),s.init(Q,Y),Q.unwrap=()=>Q._zod.def.innerType});function a(Q){return new GG({type:"optional",innerType:Q})}var WA=F("ZodNullable",(Q,Y)=>{l8.init(Q,Y),s.init(Q,Y),Q.unwrap=()=>Q._zod.def.innerType});function sW(Q){return new WA({type:"nullable",innerType:Q})}var GA=F("ZodDefault",(Q,Y)=>{m8.init(Q,Y),s.init(Q,Y),Q.unwrap=()=>Q._zod.def.innerType,Q.removeDefault=Q.unwrap});function zA(Q,Y){return new GA({type:"default",innerType:Q,get defaultValue(){return typeof Y==="function"?Y():h.shallowClone(Y)}})}var JA=F("ZodPrefault",(Q,Y)=>{c8.init(Q,Y),s.init(Q,Y),Q.unwrap=()=>Q._zod.def.innerType});function $A(Q,Y){return new JA({type:"prefault",innerType:Q,get defaultValue(){return typeof Y==="function"?Y():h.shallowClone(Y)}})}var zG=F("ZodNonOptional",(Q,Y)=>{p8.init(Q,Y),s.init(Q,Y),Q.unwrap=()=>Q._zod.def.innerType});function HA(Q,Y){return new zG({type:"nonoptional",innerType:Q,...h.normalizeParams(Y)})}var AA=F("ZodCatch",(Q,Y)=>{i8.init(Q,Y),s.init(Q,Y),Q.unwrap=()=>Q._zod.def.innerType,Q.removeCatch=Q.unwrap});function UA(Q,Y){return new AA({type:"catch",innerType:Q,catchValue:typeof Y==="function"?Y:()=>Y})}var KA=F("ZodPipe",(Q,Y)=>{r8.init(Q,Y),s.init(Q,Y),Q.in=Y.in,Q.out=Y.out});function o6(Q,Y){return new KA({type:"pipe",in:Q,out:Y})}var DA=F("ZodReadonly",(Q,Y)=>{n8.init(Q,Y),s.init(Q,Y),Q.unwrap=()=>Q._zod.def.innerType});function BA(Q){return new DA({type:"readonly",innerType:Q})}var JG=F("ZodCustom",(Q,Y)=>{d8.init(Q,Y),s.init(Q,Y)});function $G(Q,Y){return SW(JG,Q??(()=>!0),Y)}function LA(Q,Y={}){return RW(JG,Q,Y)}function FA(Q){return CW(Q)}function s6(Q,Y){return o6(WG(Q),Y)}w0(v6());var e6="2025-11-25";var HG=[e6,"2025-06-18","2025-03-26","2024-11-05","2024-10-07"],X1="io.modelcontextprotocol/related-task",UQ="2.0",G0=$G((Q)=>Q!==null&&(typeof Q==="object"||typeof Q==="function")),AG=p([B(),l().int()]),UG=B(),TN=U0({ttl:p([l(),t6()]).optional(),pollInterval:l().optional()}),qA=w({ttl:l().optional()}),OA=w({taskId:B()}),QY=U0({progressToken:AG.optional(),[X1]:OA.optional()}),Z0=w({_meta:QY.optional()}),z4=Z0.extend({task:qA.optional()}),KG=(Q)=>z4.safeParse(Q).success,z0=w({method:B(),params:Z0.loose().optional()}),b0=w({_meta:QY.optional()}),P0=w({method:B(),params:b0.loose().optional()}),J0=U0({_meta:QY.optional()}),KQ=p([B(),l().int()]),DG=w({jsonrpc:b(UQ),id:KQ,...z0.shape}).strict(),YY=(Q)=>DG.safeParse(Q).success,BG=w({jsonrpc:b(UQ),...P0.shape}).strict(),LG=(Q)=>BG.safeParse(Q).success,XY=w({jsonrpc:b(UQ),id:KQ,result:J0}).strict(),J4=(Q)=>XY.safeParse(Q).success;var g;(function(Q){Q[Q.ConnectionClosed=-32000]="ConnectionClosed",Q[Q.RequestTimeout=-32001]="RequestTimeout",Q[Q.ParseError=-32700]="ParseError",Q[Q.InvalidRequest=-32600]="InvalidRequest",Q[Q.MethodNotFound=-32601]="MethodNotFound",Q[Q.InvalidParams=-32602]="InvalidParams",Q[Q.InternalError=-32603]="InternalError",Q[Q.UrlElicitationRequired=-32042]="UrlElicitationRequired"})(g||(g={}));var WY=w({jsonrpc:b(UQ),id:KQ.optional(),error:w({code:l().int(),message:B(),data:o().optional()})}).strict();var FG=(Q)=>WY.safeParse(Q).success;var SN=p([DG,BG,XY,WY]),RN=p([XY,WY]),DQ=J0.strict(),MA=b0.extend({requestId:KQ.optional(),reason:B().optional()}),BQ=P0.extend({method:b("notifications/cancelled"),params:MA}),VA=w({src:B(),mimeType:B().optional(),sizes:_(B()).optional(),theme:L0(["light","dark"]).optional()}),$4=w({icons:_(VA).optional()}),S1=w({name:B(),title:B().optional()}),qG=S1.extend({...S1.shape,...$4.shape,version:B(),websiteUrl:B().optional(),description:B().optional()}),NA=HQ(w({applyDefaults:X0().optional()}),t(B(),o())),ZA=s6((Q)=>{if(Q&&typeof Q==="object"&&!Array.isArray(Q)){if(Object.keys(Q).length===0)return{form:{}}}return Q},HQ(w({form:NA.optional(),url:G0.optional()}),t(B(),o()).optional())),wA=U0({list:G0.optional(),cancel:G0.optional(),requests:U0({sampling:U0({createMessage:G0.optional()}).optional(),elicitation:U0({create:G0.optional()}).optional()}).optional()}),bA=U0({list:G0.optional(),cancel:G0.optional(),requests:U0({tools:U0({call:G0.optional()}).optional()}).optional()}),PA=w({experimental:t(B(),G0).optional(),sampling:w({context:G0.optional(),tools:G0.optional()}).optional(),elicitation:ZA.optional(),roots:w({listChanged:X0().optional()}).optional(),tasks:wA.optional()}),jA=Z0.extend({protocolVersion:B(),capabilities:PA,clientInfo:qG}),GY=z0.extend({method:b("initialize"),params:jA});var IA=w({experimental:t(B(),G0).optional(),logging:G0.optional(),completions:G0.optional(),prompts:w({listChanged:X0().optional()}).optional(),resources:w({subscribe:X0().optional(),listChanged:X0().optional()}).optional(),tools:w({listChanged:X0().optional()}).optional(),tasks:bA.optional()}),EA=J0.extend({protocolVersion:B(),capabilities:IA,serverInfo:qG,instructions:B().optional()}),zY=P0.extend({method:b("notifications/initialized"),params:b0.optional()});var LQ=z0.extend({method:b("ping"),params:Z0.optional()}),TA=w({progress:l(),total:a(l()),message:a(B())}),SA=w({...b0.shape,...TA.shape,progressToken:AG}),FQ=P0.extend({method:b("notifications/progress"),params:SA}),RA=Z0.extend({cursor:UG.optional()}),H4=z0.extend({params:RA.optional()}),A4=J0.extend({nextCursor:UG.optional()}),CA=L0(["working","input_required","completed","failed","cancelled"]),U4=w({taskId:B(),status:CA,ttl:p([l(),t6()]),createdAt:B(),lastUpdatedAt:B(),pollInterval:a(l()),statusMessage:a(B())}),R1=J0.extend({task:U4}),vA=b0.merge(U4),K4=P0.extend({method:b("notifications/tasks/status"),params:vA}),qQ=z0.extend({method:b("tasks/get"),params:Z0.extend({taskId:B()})}),OQ=J0.merge(U4),MQ=z0.extend({method:b("tasks/result"),params:Z0.extend({taskId:B()})}),CN=J0.loose(),VQ=H4.extend({method:b("tasks/list")}),NQ=A4.extend({tasks:_(U4)}),ZQ=z0.extend({method:b("tasks/cancel"),params:Z0.extend({taskId:B()})}),OG=J0.merge(U4),MG=w({uri:B(),mimeType:a(B()),_meta:t(B(),o()).optional()}),VG=MG.extend({text:B()}),JY=B().refine((Q)=>{try{return atob(Q),!0}catch{return!1}},{message:"Invalid Base64 string"}),NG=MG.extend({blob:JY}),D4=L0(["user","assistant"]),C1=w({audience:_(D4).optional(),priority:l().min(0).max(1).optional(),lastModified:G4.datetime({offset:!0}).optional()}),ZG=w({...S1.shape,...$4.shape,uri:B(),description:a(B()),mimeType:a(B()),annotations:C1.optional(),_meta:a(U0({}))}),kA=w({...S1.shape,...$4.shape,uriTemplate:B(),description:a(B()),mimeType:a(B()),annotations:C1.optional(),_meta:a(U0({}))}),$Y=H4.extend({method:b("resources/list")}),xA=A4.extend({resources:_(ZG)}),_A=H4.extend({method:b("resources/templates/list")}),gA=A4.extend({resourceTemplates:_(kA)}),HY=Z0.extend({uri:B()}),yA=HY,AY=z0.extend({method:b("resources/read"),params:yA}),uA=J0.extend({contents:_(p([VG,NG]))}),hA=P0.extend({method:b("notifications/resources/list_changed"),params:b0.optional()}),fA=HY,lA=z0.extend({method:b("resources/subscribe"),params:fA}),mA=HY,cA=z0.extend({method:b("resources/unsubscribe"),params:mA}),pA=b0.extend({uri:B()}),iA=P0.extend({method:b("notifications/resources/updated"),params:pA}),rA=w({name:B(),description:a(B()),required:a(X0())}),nA=w({...S1.shape,...$4.shape,description:a(B()),arguments:a(_(rA)),_meta:a(U0({}))}),dA=H4.extend({method:b("prompts/list")}),oA=A4.extend({prompts:_(nA)}),tA=Z0.extend({name:B(),arguments:t(B(),B()).optional()}),aA=z0.extend({method:b("prompts/get"),params:tA}),UY=w({type:b("text"),text:B(),annotations:C1.optional(),_meta:t(B(),o()).optional()}),KY=w({type:b("image"),data:JY,mimeType:B(),annotations:C1.optional(),_meta:t(B(),o()).optional()}),DY=w({type:b("audio"),data:JY,mimeType:B(),annotations:C1.optional(),_meta:t(B(),o()).optional()}),sA=w({type:b("tool_use"),name:B(),id:B(),input:t(B(),o()),_meta:t(B(),o()).optional()}),eA=w({type:b("resource"),resource:p([VG,NG]),annotations:C1.optional(),_meta:t(B(),o()).optional()}),QU=ZG.extend({type:b("resource_link")}),BY=p([UY,KY,DY,QU,eA]),YU=w({role:D4,content:BY}),XU=J0.extend({description:B().optional(),messages:_(YU)}),WU=P0.extend({method:b("notifications/prompts/list_changed"),params:b0.optional()}),GU=w({title:B().optional(),readOnlyHint:X0().optional(),destructiveHint:X0().optional(),idempotentHint:X0().optional(),openWorldHint:X0().optional()}),zU=w({taskSupport:L0(["required","optional","forbidden"]).optional()}),wG=w({...S1.shape,...$4.shape,description:B().optional(),inputSchema:w({type:b("object"),properties:t(B(),G0).optional(),required:_(B()).optional()}).catchall(o()),outputSchema:w({type:b("object"),properties:t(B(),G0).optional(),required:_(B()).optional()}).catchall(o()).optional(),annotations:GU.optional(),execution:zU.optional(),_meta:t(B(),o()).optional()}),LY=H4.extend({method:b("tools/list")}),JU=A4.extend({tools:_(wG)}),wQ=J0.extend({content:_(BY).default([]),structuredContent:t(B(),o()).optional(),isError:X0().optional()}),vN=wQ.or(J0.extend({toolResult:o()})),$U=z4.extend({name:B(),arguments:t(B(),o()).optional()}),B4=z0.extend({method:b("tools/call"),params:$U}),HU=P0.extend({method:b("notifications/tools/list_changed"),params:b0.optional()}),kN=w({autoRefresh:X0().default(!0),debounceMs:l().int().nonnegative().default(300)}),L4=L0(["debug","info","notice","warning","error","critical","alert","emergency"]),AU=Z0.extend({level:L4}),FY=z0.extend({method:b("logging/setLevel"),params:AU}),UU=b0.extend({level:L4,logger:B().optional(),data:o()}),KU=P0.extend({method:b("notifications/message"),params:UU}),DU=w({name:B().optional()}),BU=w({hints:_(DU).optional(),costPriority:l().min(0).max(1).optional(),speedPriority:l().min(0).max(1).optional(),intelligencePriority:l().min(0).max(1).optional()}),LU=w({mode:L0(["auto","required","none"]).optional()}),FU=w({type:b("tool_result"),toolUseId:B().describe("The unique identifier for the corresponding tool call."),content:_(BY).default([]),structuredContent:w({}).loose().optional(),isError:X0().optional(),_meta:t(B(),o()).optional()}),qU=a6("type",[UY,KY,DY]),AQ=a6("type",[UY,KY,DY,sA,FU]),OU=w({role:D4,content:p([AQ,_(AQ)]),_meta:t(B(),o()).optional()}),MU=z4.extend({messages:_(OU),modelPreferences:BU.optional(),systemPrompt:B().optional(),includeContext:L0(["none","thisServer","allServers"]).optional(),temperature:l().optional(),maxTokens:l().int(),stopSequences:_(B()).optional(),metadata:G0.optional(),tools:_(wG).optional(),toolChoice:LU.optional()}),VU=z0.extend({method:b("sampling/createMessage"),params:MU}),qY=J0.extend({model:B(),stopReason:a(L0(["endTurn","stopSequence","maxTokens"]).or(B())),role:D4,content:qU}),OY=J0.extend({model:B(),stopReason:a(L0(["endTurn","stopSequence","maxTokens","toolUse"]).or(B())),role:D4,content:p([AQ,_(AQ)])}),NU=w({type:b("boolean"),title:B().optional(),description:B().optional(),default:X0().optional()}),ZU=w({type:b("string"),title:B().optional(),description:B().optional(),minLength:l().optional(),maxLength:l().optional(),format:L0(["email","uri","date","date-time"]).optional(),default:B().optional()}),wU=w({type:L0(["number","integer"]),title:B().optional(),description:B().optional(),minimum:l().optional(),maximum:l().optional(),default:l().optional()}),bU=w({type:b("string"),title:B().optional(),description:B().optional(),enum:_(B()),default:B().optional()}),PU=w({type:b("string"),title:B().optional(),description:B().optional(),oneOf:_(w({const:B(),title:B()})),default:B().optional()}),jU=w({type:b("string"),title:B().optional(),description:B().optional(),enum:_(B()),enumNames:_(B()).optional(),default:B().optional()}),IU=p([bU,PU]),EU=w({type:b("array"),title:B().optional(),description:B().optional(),minItems:l().optional(),maxItems:l().optional(),items:w({type:b("string"),enum:_(B())}),default:_(B()).optional()}),TU=w({type:b("array"),title:B().optional(),description:B().optional(),minItems:l().optional(),maxItems:l().optional(),items:w({anyOf:_(w({const:B(),title:B()}))}),default:_(B()).optional()}),SU=p([EU,TU]),RU=p([jU,IU,SU]),CU=p([RU,NU,ZU,wU]),vU=z4.extend({mode:b("form").optional(),message:B(),requestedSchema:w({type:b("object"),properties:t(B(),CU),required:_(B()).optional()})}),kU=z4.extend({mode:b("url"),message:B(),elicitationId:B(),url:B().url()}),xU=p([vU,kU]),_U=z0.extend({method:b("elicitation/create"),params:xU}),gU=b0.extend({elicitationId:B()}),yU=P0.extend({method:b("notifications/elicitation/complete"),params:gU}),bQ=J0.extend({action:L0(["accept","decline","cancel"]),content:s6((Q)=>Q===null?void 0:Q,t(B(),p([B(),l(),X0(),_(B())])).optional())}),uU=w({type:b("ref/resource"),uri:B()});var hU=w({type:b("ref/prompt"),name:B()}),fU=Z0.extend({ref:p([hU,uU]),argument:w({name:B(),value:B()}),context:w({arguments:t(B(),B()).optional()}).optional()}),lU=z0.extend({method:b("completion/complete"),params:fU});var mU=J0.extend({completion:U0({values:_(B()).max(100),total:a(l().int()),hasMore:a(X0())})}),cU=w({uri:B().startsWith("file://"),name:B().optional(),_meta:t(B(),o()).optional()}),pU=z0.extend({method:b("roots/list"),params:Z0.optional()}),MY=J0.extend({roots:_(cU)}),iU=P0.extend({method:b("notifications/roots/list_changed"),params:b0.optional()}),xN=p([LQ,GY,lU,FY,aA,dA,$Y,_A,AY,lA,cA,B4,LY,qQ,MQ,VQ,ZQ]),_N=p([BQ,FQ,zY,iU,K4]),gN=p([DQ,qY,OY,bQ,MY,OQ,NQ,R1]),yN=p([LQ,VU,_U,pU,qQ,MQ,VQ,ZQ]),uN=p([BQ,FQ,KU,iA,hA,HU,WU,K4,yU]),hN=p([DQ,EA,mU,XU,oA,xA,gA,uA,wQ,JU,OQ,NQ,R1]);class v extends Error{constructor(Q,Y,X){super(`MCP error ${Q}: ${Y}`);this.code=Q,this.data=X,this.name="McpError"}static fromError(Q,Y,X){if(Q===g.UrlElicitationRequired&&X){let W=X;if(W.elicitations)return new bG(W.elicitations,Y)}return new v(Q,Y,X)}}class bG extends v{constructor(Q,Y=`URL elicitation${Q.length>1?"s":""} required`){super(g.UrlElicitationRequired,Y,{elicitations:Q})}get elicitations(){return this.data?.elicitations??[]}}function W1(Q){return Q==="completed"||Q==="failed"||Q==="cancelled"}var rU=Symbol("Let zodToJsonSchema decide on which parser to use");var MZ=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function VY(Q){let X=JQ(Q)?.method;if(!X)throw Error("Schema is missing a method literal");let W=vW(X);if(typeof W!=="string")throw Error("Schema method literal must be a string");return W}function NY(Q,Y){let X=Y1(Q,Y);if(!X.success)throw X.error;return X.data}var sU=60000;class ZY{constructor(Q){if(this._options=Q,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(BQ,(Y)=>{this._oncancel(Y)}),this.setNotificationHandler(FQ,(Y)=>{this._onprogress(Y)}),this.setRequestHandler(LQ,(Y)=>({})),this._taskStore=Q?.taskStore,this._taskMessageQueue=Q?.taskMessageQueue,this._taskStore)this.setRequestHandler(qQ,async(Y,X)=>{let W=await this._taskStore.getTask(Y.params.taskId,X.sessionId);if(!W)throw new v(g.InvalidParams,"Failed to retrieve task: Task not found");return{...W}}),this.setRequestHandler(MQ,async(Y,X)=>{let W=async()=>{let G=Y.params.taskId;if(this._taskMessageQueue){let J;while(J=await this._taskMessageQueue.dequeue(G,X.sessionId)){if(J.type==="response"||J.type==="error"){let $=J.message,H=$.id,A=this._requestResolvers.get(H);if(A)if(this._requestResolvers.delete(H),J.type==="response")A($);else{let U=$,K=new v(U.error.code,U.error.message,U.error.data);A(K)}else{let U=J.type==="response"?"Response":"Error";this._onerror(Error(`${U} handler missing for request ${H}`))}continue}await this._transport?.send(J.message,{relatedRequestId:X.requestId})}}let z=await this._taskStore.getTask(G,X.sessionId);if(!z)throw new v(g.InvalidParams,`Task not found: ${G}`);if(!W1(z.status))return await this._waitForTaskUpdate(G,X.signal),await W();if(W1(z.status)){let J=await this._taskStore.getTaskResult(G,X.sessionId);return this._clearTaskQueue(G),{...J,_meta:{...J._meta,[X1]:{taskId:G}}}}return await W()};return await W()}),this.setRequestHandler(VQ,async(Y,X)=>{try{let{tasks:W,nextCursor:G}=await this._taskStore.listTasks(Y.params?.cursor,X.sessionId);return{tasks:W,nextCursor:G,_meta:{}}}catch(W){throw new v(g.InvalidParams,`Failed to list tasks: ${W instanceof Error?W.message:String(W)}`)}}),this.setRequestHandler(ZQ,async(Y,X)=>{try{let W=await this._taskStore.getTask(Y.params.taskId,X.sessionId);if(!W)throw new v(g.InvalidParams,`Task not found: ${Y.params.taskId}`);if(W1(W.status))throw new v(g.InvalidParams,`Cannot cancel task in terminal status: ${W.status}`);await this._taskStore.updateTaskStatus(Y.params.taskId,"cancelled","Client cancelled task execution.",X.sessionId),this._clearTaskQueue(Y.params.taskId);let G=await this._taskStore.getTask(Y.params.taskId,X.sessionId);if(!G)throw new v(g.InvalidParams,`Task not found after cancellation: ${Y.params.taskId}`);return{_meta:{},...G}}catch(W){if(W instanceof v)throw W;throw new v(g.InvalidRequest,`Failed to cancel task: ${W instanceof Error?W.message:String(W)}`)}})}async _oncancel(Q){if(!Q.params.requestId)return;this._requestHandlerAbortControllers.get(Q.params.requestId)?.abort(Q.params.reason)}_setupTimeout(Q,Y,X,W,G=!1){this._timeoutInfo.set(Q,{timeoutId:setTimeout(W,Y),startTime:Date.now(),timeout:Y,maxTotalTimeout:X,resetTimeoutOnProgress:G,onTimeout:W})}_resetTimeout(Q){let Y=this._timeoutInfo.get(Q);if(!Y)return!1;let X=Date.now()-Y.startTime;if(Y.maxTotalTimeout&&X>=Y.maxTotalTimeout)throw this._timeoutInfo.delete(Q),v.fromError(g.RequestTimeout,"Maximum total timeout exceeded",{maxTotalTimeout:Y.maxTotalTimeout,totalElapsed:X});return clearTimeout(Y.timeoutId),Y.timeoutId=setTimeout(Y.onTimeout,Y.timeout),!0}_cleanupTimeout(Q){let Y=this._timeoutInfo.get(Q);if(Y)clearTimeout(Y.timeoutId),this._timeoutInfo.delete(Q)}async connect(Q){this._transport=Q;let Y=this.transport?.onclose;this._transport.onclose=()=>{Y?.(),this._onclose()};let X=this.transport?.onerror;this._transport.onerror=(G)=>{X?.(G),this._onerror(G)};let W=this._transport?.onmessage;this._transport.onmessage=(G,z)=>{if(W?.(G,z),J4(G)||FG(G))this._onresponse(G);else if(YY(G))this._onrequest(G,z);else if(LG(G))this._onnotification(G);else this._onerror(Error(`Unknown message type: ${JSON.stringify(G)}`))},await this._transport.start()}_onclose(){let Q=this._responseHandlers;this._responseHandlers=new Map,this._progressHandlers.clear(),this._taskProgressTokens.clear(),this._pendingDebouncedNotifications.clear();let Y=v.fromError(g.ConnectionClosed,"Connection closed");this._transport=void 0,this.onclose?.();for(let X of Q.values())X(Y)}_onerror(Q){this.onerror?.(Q)}_onnotification(Q){let Y=this._notificationHandlers.get(Q.method)??this.fallbackNotificationHandler;if(Y===void 0)return;Promise.resolve().then(()=>Y(Q)).catch((X)=>this._onerror(Error(`Uncaught error in notification handler: ${X}`)))}_onrequest(Q,Y){let X=this._requestHandlers.get(Q.method)??this.fallbackRequestHandler,W=this._transport,G=Q.params?._meta?.[X1]?.taskId;if(X===void 0){let A={jsonrpc:"2.0",id:Q.id,error:{code:g.MethodNotFound,message:"Method not found"}};if(G&&this._taskMessageQueue)this._enqueueTaskMessage(G,{type:"error",message:A,timestamp:Date.now()},W?.sessionId).catch((U)=>this._onerror(Error(`Failed to enqueue error response: ${U}`)));else W?.send(A).catch((U)=>this._onerror(Error(`Failed to send an error response: ${U}`)));return}let z=new AbortController;this._requestHandlerAbortControllers.set(Q.id,z);let J=KG(Q.params)?Q.params.task:void 0,$=this._taskStore?this.requestTaskStore(Q,W?.sessionId):void 0,H={signal:z.signal,sessionId:W?.sessionId,_meta:Q.params?._meta,sendNotification:async(A)=>{let U={relatedRequestId:Q.id};if(G)U.relatedTask={taskId:G};await this.notification(A,U)},sendRequest:async(A,U,K)=>{let D={...K,relatedRequestId:Q.id};if(G&&!D.relatedTask)D.relatedTask={taskId:G};let L=D.relatedTask?.taskId??G;if(L&&$)await $.updateTaskStatus(L,"input_required");return await this.request(A,U,D)},authInfo:Y?.authInfo,requestId:Q.id,requestInfo:Y?.requestInfo,taskId:G,taskStore:$,taskRequestedTtl:J?.ttl,closeSSEStream:Y?.closeSSEStream,closeStandaloneSSEStream:Y?.closeStandaloneSSEStream};Promise.resolve().then(()=>{if(J)this.assertTaskHandlerCapability(Q.method)}).then(()=>X(Q,H)).then(async(A)=>{if(z.signal.aborted)return;let U={result:A,jsonrpc:"2.0",id:Q.id};if(G&&this._taskMessageQueue)await this._enqueueTaskMessage(G,{type:"response",message:U,timestamp:Date.now()},W?.sessionId);else await W?.send(U)},async(A)=>{if(z.signal.aborted)return;let U={jsonrpc:"2.0",id:Q.id,error:{code:Number.isSafeInteger(A.code)?A.code:g.InternalError,message:A.message??"Internal error",...A.data!==void 0&&{data:A.data}}};if(G&&this._taskMessageQueue)await this._enqueueTaskMessage(G,{type:"error",message:U,timestamp:Date.now()},W?.sessionId);else await W?.send(U)}).catch((A)=>this._onerror(Error(`Failed to send response: ${A}`))).finally(()=>{this._requestHandlerAbortControllers.delete(Q.id)})}_onprogress(Q){let{progressToken:Y,...X}=Q.params,W=Number(Y),G=this._progressHandlers.get(W);if(!G){this._onerror(Error(`Received a progress notification for an unknown token: ${JSON.stringify(Q)}`));return}let z=this._responseHandlers.get(W),J=this._timeoutInfo.get(W);if(J&&z&&J.resetTimeoutOnProgress)try{this._resetTimeout(W)}catch($){this._responseHandlers.delete(W),this._progressHandlers.delete(W),this._cleanupTimeout(W),z($);return}G(X)}_onresponse(Q){let Y=Number(Q.id),X=this._requestResolvers.get(Y);if(X){if(this._requestResolvers.delete(Y),J4(Q))X(Q);else{let z=new v(Q.error.code,Q.error.message,Q.error.data);X(z)}return}let W=this._responseHandlers.get(Y);if(W===void 0){this._onerror(Error(`Received a response for an unknown message ID: ${JSON.stringify(Q)}`));return}this._responseHandlers.delete(Y),this._cleanupTimeout(Y);let G=!1;if(J4(Q)&&Q.result&&typeof Q.result==="object"){let z=Q.result;if(z.task&&typeof z.task==="object"){let J=z.task;if(typeof J.taskId==="string")G=!0,this._taskProgressTokens.set(J.taskId,Y)}}if(!G)this._progressHandlers.delete(Y);if(J4(Q))W(Q);else{let z=v.fromError(Q.error.code,Q.error.message,Q.error.data);W(z)}}get transport(){return this._transport}async close(){await this._transport?.close()}async*requestStream(Q,Y,X){let{task:W}=X??{};if(!W){try{yield{type:"result",result:await this.request(Q,Y,X)}}catch(z){yield{type:"error",error:z instanceof v?z:new v(g.InternalError,String(z))}}return}let G;try{let z=await this.request(Q,R1,X);if(z.task)G=z.task.taskId,yield{type:"taskCreated",task:z.task};else throw new v(g.InternalError,"Task creation did not return a task");while(!0){let J=await this.getTask({taskId:G},X);if(yield{type:"taskStatus",task:J},W1(J.status)){if(J.status==="completed")yield{type:"result",result:await this.getTaskResult({taskId:G},Y,X)};else if(J.status==="failed")yield{type:"error",error:new v(g.InternalError,`Task ${G} failed`)};else if(J.status==="cancelled")yield{type:"error",error:new v(g.InternalError,`Task ${G} was cancelled`)};return}if(J.status==="input_required"){yield{type:"result",result:await this.getTaskResult({taskId:G},Y,X)};return}let $=J.pollInterval??this._options?.defaultTaskPollInterval??1000;await new Promise((H)=>setTimeout(H,$)),X?.signal?.throwIfAborted()}}catch(z){yield{type:"error",error:z instanceof v?z:new v(g.InternalError,String(z))}}}request(Q,Y,X){let{relatedRequestId:W,resumptionToken:G,onresumptiontoken:z,task:J,relatedTask:$}=X??{};return new Promise((H,A)=>{let U=(M)=>{A(M)};if(!this._transport){U(Error("Not connected"));return}if(this._options?.enforceStrictCapabilities===!0)try{if(this.assertCapabilityForMethod(Q.method),J)this.assertTaskCapability(Q.method)}catch(M){U(M);return}X?.signal?.throwIfAborted();let K=this._requestMessageId++,D={...Q,jsonrpc:"2.0",id:K};if(X?.onprogress)this._progressHandlers.set(K,X.onprogress),D.params={...Q.params,_meta:{...Q.params?._meta||{},progressToken:K}};if(J)D.params={...D.params,task:J};if($)D.params={...D.params,_meta:{...D.params?._meta||{},[X1]:$}};let L=(M)=>{this._responseHandlers.delete(K),this._progressHandlers.delete(K),this._cleanupTimeout(K),this._transport?.send({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:K,reason:String(M)}},{relatedRequestId:W,resumptionToken:G,onresumptiontoken:z}).catch((E)=>this._onerror(Error(`Failed to send cancellation: ${E}`)));let S=M instanceof v?M:new v(g.RequestTimeout,String(M));A(S)};this._responseHandlers.set(K,(M)=>{if(X?.signal?.aborted)return;if(M instanceof Error)return A(M);try{let S=Y1(Y,M.result);if(!S.success)A(S.error);else H(S.data)}catch(S){A(S)}}),X?.signal?.addEventListener("abort",()=>{L(X?.signal?.reason)});let q=X?.timeout??sU,O=()=>L(v.fromError(g.RequestTimeout,"Request timed out",{timeout:q}));this._setupTimeout(K,q,X?.maxTotalTimeout,O,X?.resetTimeoutOnProgress??!1);let V=$?.taskId;if(V){let M=(S)=>{let E=this._responseHandlers.get(K);if(E)E(S);else this._onerror(Error(`Response handler missing for side-channeled request ${K}`))};this._requestResolvers.set(K,M),this._enqueueTaskMessage(V,{type:"request",message:D,timestamp:Date.now()}).catch((S)=>{this._cleanupTimeout(K),A(S)})}else this._transport.send(D,{relatedRequestId:W,resumptionToken:G,onresumptiontoken:z}).catch((M)=>{this._cleanupTimeout(K),A(M)})})}async getTask(Q,Y){return this.request({method:"tasks/get",params:Q},OQ,Y)}async getTaskResult(Q,Y,X){return this.request({method:"tasks/result",params:Q},Y,X)}async listTasks(Q,Y){return this.request({method:"tasks/list",params:Q},NQ,Y)}async cancelTask(Q,Y){return this.request({method:"tasks/cancel",params:Q},OG,Y)}async notification(Q,Y){if(!this._transport)throw Error("Not connected");this.assertNotificationCapability(Q.method);let X=Y?.relatedTask?.taskId;if(X){let J={...Q,jsonrpc:"2.0",params:{...Q.params,_meta:{...Q.params?._meta||{},[X1]:Y.relatedTask}}};await this._enqueueTaskMessage(X,{type:"notification",message:J,timestamp:Date.now()});return}if((this._options?.debouncedNotificationMethods??[]).includes(Q.method)&&!Q.params&&!Y?.relatedRequestId&&!Y?.relatedTask){if(this._pendingDebouncedNotifications.has(Q.method))return;this._pendingDebouncedNotifications.add(Q.method),Promise.resolve().then(()=>{if(this._pendingDebouncedNotifications.delete(Q.method),!this._transport)return;let J={...Q,jsonrpc:"2.0"};if(Y?.relatedTask)J={...J,params:{...J.params,_meta:{...J.params?._meta||{},[X1]:Y.relatedTask}}};this._transport?.send(J,Y).catch(($)=>this._onerror($))});return}let z={...Q,jsonrpc:"2.0"};if(Y?.relatedTask)z={...z,params:{...z.params,_meta:{...z.params?._meta||{},[X1]:Y.relatedTask}}};await this._transport.send(z,Y)}setRequestHandler(Q,Y){let X=VY(Q);this.assertRequestHandlerCapability(X),this._requestHandlers.set(X,(W,G)=>{let z=NY(Q,W);return Promise.resolve(Y(z,G))})}removeRequestHandler(Q){this._requestHandlers.delete(Q)}assertCanSetRequestHandler(Q){if(this._requestHandlers.has(Q))throw Error(`A request handler for ${Q} already exists, which would be overridden`)}setNotificationHandler(Q,Y){let X=VY(Q);this._notificationHandlers.set(X,(W)=>{let G=NY(Q,W);return Promise.resolve(Y(G))})}removeNotificationHandler(Q){this._notificationHandlers.delete(Q)}_cleanupTaskProgressHandler(Q){let Y=this._taskProgressTokens.get(Q);if(Y!==void 0)this._progressHandlers.delete(Y),this._taskProgressTokens.delete(Q)}async _enqueueTaskMessage(Q,Y,X){if(!this._taskStore||!this._taskMessageQueue)throw Error("Cannot enqueue task message: taskStore and taskMessageQueue are not configured");let W=this._options?.maxTaskQueueSize;await this._taskMessageQueue.enqueue(Q,Y,X,W)}async _clearTaskQueue(Q,Y){if(this._taskMessageQueue){let X=await this._taskMessageQueue.dequeueAll(Q,Y);for(let W of X)if(W.type==="request"&&YY(W.message)){let G=W.message.id,z=this._requestResolvers.get(G);if(z)z(new v(g.InternalError,"Task cancelled or completed")),this._requestResolvers.delete(G);else this._onerror(Error(`Resolver missing for request ${G} during task ${Q} cleanup`))}}}async _waitForTaskUpdate(Q,Y){let X=this._options?.defaultTaskPollInterval??1000;try{let W=await this._taskStore?.getTask(Q);if(W?.pollInterval)X=W.pollInterval}catch{}return new Promise((W,G)=>{if(Y.aborted){G(new v(g.InvalidRequest,"Request cancelled"));return}let z=setTimeout(W,X);Y.addEventListener("abort",()=>{clearTimeout(z),G(new v(g.InvalidRequest,"Request cancelled"))},{once:!0})})}requestTaskStore(Q,Y){let X=this._taskStore;if(!X)throw Error("No task store configured");return{createTask:async(W)=>{if(!Q)throw Error("No request provided");return await X.createTask(W,Q.id,{method:Q.method,params:Q.params},Y)},getTask:async(W)=>{let G=await X.getTask(W,Y);if(!G)throw new v(g.InvalidParams,"Failed to retrieve task: Task not found");return G},storeTaskResult:async(W,G,z)=>{await X.storeTaskResult(W,G,z,Y);let J=await X.getTask(W,Y);if(J){let $=K4.parse({method:"notifications/tasks/status",params:J});if(await this.notification($),W1(J.status))this._cleanupTaskProgressHandler(W)}},getTaskResult:(W)=>{return X.getTaskResult(W,Y)},updateTaskStatus:async(W,G,z)=>{let J=await X.getTask(W,Y);if(!J)throw new v(g.InvalidParams,`Task "${W}" not found - it may have been cleaned up`);if(W1(J.status))throw new v(g.InvalidParams,`Cannot update task "${W}" from terminal status "${J.status}" to "${G}". Terminal states (completed, failed, cancelled) cannot transition to other states.`);await X.updateTaskStatus(W,G,z,Y);let $=await X.getTask(W,Y);if($){let H=K4.parse({method:"notifications/tasks/status",params:$});if(await this.notification(H),W1($.status))this._cleanupTaskProgressHandler(W)}},listTasks:(W)=>{return X.listTasks(W,Y)}}}}function PG(Q){return Q!==null&&typeof Q==="object"&&!Array.isArray(Q)}function jG(Q,Y){let X={...Q};for(let W in Y){let G=W,z=Y[G];if(z===void 0)continue;let J=X[G];if(PG(J)&&PG(z))X[G]={...J,...z};else X[G]=z}return X}var X5=k9(F9(),1),W5=k9(Y5(),1);function $M(){let Q=new X5.default({strict:!1,validateFormats:!0,validateSchema:!1,allErrors:!0});return W5.default(Q),Q}class j9{constructor(Q){this._ajv=Q??$M()}getValidator(Q){let Y="$id"in Q&&typeof Q.$id==="string"?this._ajv.getSchema(Q.$id)??this._ajv.compile(Q):this._ajv.compile(Q);return(X)=>{if(Y(X))return{valid:!0,data:X,errorMessage:void 0};else return{valid:!1,data:void 0,errorMessage:this._ajv.errorsText(Y.errors)}}}}class I9{constructor(Q){this._server=Q}requestStream(Q,Y,X){return this._server.requestStream(Q,Y,X)}async getTask(Q,Y){return this._server.getTask({taskId:Q},Y)}async getTaskResult(Q,Y,X){return this._server.getTaskResult({taskId:Q},Y,X)}async listTasks(Q,Y){return this._server.listTasks(Q?{cursor:Q}:void 0,Y)}async cancelTask(Q,Y){return this._server.cancelTask({taskId:Q},Y)}}function G5(Q,Y,X){if(!Q)throw Error(`${X} does not support task creation (required for ${Y})`);switch(Y){case"tools/call":if(!Q.tools?.call)throw Error(`${X} does not support task creation for tools/call (required for ${Y})`);break;default:break}}function z5(Q,Y,X){if(!Q)throw Error(`${X} does not support task creation (required for ${Y})`);switch(Y){case"sampling/createMessage":if(!Q.sampling?.createMessage)throw Error(`${X} does not support task creation for sampling/createMessage (required for ${Y})`);break;case"elicitation/create":if(!Q.elicitation?.create)throw Error(`${X} does not support task creation for elicitation/create (required for ${Y})`);break;default:break}}class E9 extends ZY{constructor(Q,Y){super(Y);if(this._serverInfo=Q,this._loggingLevels=new Map,this.LOG_LEVEL_SEVERITY=new Map(L4.options.map((X,W)=>[X,W])),this.isMessageIgnored=(X,W)=>{let G=this._loggingLevels.get(W);return G?this.LOG_LEVEL_SEVERITY.get(X)<this.LOG_LEVEL_SEVERITY.get(G):!1},this._capabilities=Y?.capabilities??{},this._instructions=Y?.instructions,this._jsonSchemaValidator=Y?.jsonSchemaValidator??new j9,this.setRequestHandler(GY,(X)=>this._oninitialize(X)),this.setNotificationHandler(zY,()=>this.oninitialized?.()),this._capabilities.logging)this.setRequestHandler(FY,async(X,W)=>{let G=W.sessionId||W.requestInfo?.headers["mcp-session-id"]||void 0,{level:z}=X.params,J=L4.safeParse(z);if(J.success)this._loggingLevels.set(G,J.data);return{}})}get experimental(){if(!this._experimental)this._experimental={tasks:new I9(this)};return this._experimental}registerCapabilities(Q){if(this.transport)throw Error("Cannot register capabilities after connecting to transport");this._capabilities=jG(this._capabilities,Q)}setRequestHandler(Q,Y){let W=JQ(Q)?.method;if(!W)throw Error("Schema is missing a method literal");let G;if(T1(W)){let J=W;G=J._zod?.def?.value??J.value}else{let J=W;G=J._def?.value??J.value}if(typeof G!=="string")throw Error("Schema method literal must be a string");if(G==="tools/call"){let J=async($,H)=>{let A=Y1(B4,$);if(!A.success){let L=A.error instanceof Error?A.error.message:String(A.error);throw new v(g.InvalidParams,`Invalid tools/call request: ${L}`)}let{params:U}=A.data,K=await Promise.resolve(Y($,H));if(U.task){let L=Y1(R1,K);if(!L.success){let q=L.error instanceof Error?L.error.message:String(L.error);throw new v(g.InvalidParams,`Invalid task creation result: ${q}`)}return L.data}let D=Y1(wQ,K);if(!D.success){let L=D.error instanceof Error?D.error.message:String(D.error);throw new v(g.InvalidParams,`Invalid tools/call result: ${L}`)}return D.data};return super.setRequestHandler(Q,J)}return super.setRequestHandler(Q,Y)}assertCapabilityForMethod(Q){switch(Q){case"sampling/createMessage":if(!this._clientCapabilities?.sampling)throw Error(`Client does not support sampling (required for ${Q})`);break;case"elicitation/create":if(!this._clientCapabilities?.elicitation)throw Error(`Client does not support elicitation (required for ${Q})`);break;case"roots/list":if(!this._clientCapabilities?.roots)throw Error(`Client does not support listing roots (required for ${Q})`);break;case"ping":break}}assertNotificationCapability(Q){switch(Q){case"notifications/message":if(!this._capabilities.logging)throw Error(`Server does not support logging (required for ${Q})`);break;case"notifications/resources/updated":case"notifications/resources/list_changed":if(!this._capabilities.resources)throw Error(`Server does not support notifying about resources (required for ${Q})`);break;case"notifications/tools/list_changed":if(!this._capabilities.tools)throw Error(`Server does not support notifying of tool list changes (required for ${Q})`);break;case"notifications/prompts/list_changed":if(!this._capabilities.prompts)throw Error(`Server does not support notifying of prompt list changes (required for ${Q})`);break;case"notifications/elicitation/complete":if(!this._clientCapabilities?.elicitation?.url)throw Error(`Client does not support URL elicitation (required for ${Q})`);break;case"notifications/cancelled":break;case"notifications/progress":break}}assertRequestHandlerCapability(Q){if(!this._capabilities)return;switch(Q){case"completion/complete":if(!this._capabilities.completions)throw Error(`Server does not support completions (required for ${Q})`);break;case"logging/setLevel":if(!this._capabilities.logging)throw Error(`Server does not support logging (required for ${Q})`);break;case"prompts/get":case"prompts/list":if(!this._capabilities.prompts)throw Error(`Server does not support prompts (required for ${Q})`);break;case"resources/list":case"resources/templates/list":case"resources/read":if(!this._capabilities.resources)throw Error(`Server does not support resources (required for ${Q})`);break;case"tools/call":case"tools/list":if(!this._capabilities.tools)throw Error(`Server does not support tools (required for ${Q})`);break;case"tasks/get":case"tasks/list":case"tasks/result":case"tasks/cancel":if(!this._capabilities.tasks)throw Error(`Server does not support tasks capability (required for ${Q})`);break;case"ping":case"initialize":break}}assertTaskCapability(Q){z5(this._clientCapabilities?.tasks?.requests,Q,"Client")}assertTaskHandlerCapability(Q){if(!this._capabilities)return;G5(this._capabilities.tasks?.requests,Q,"Server")}async _oninitialize(Q){let Y=Q.params.protocolVersion;return this._clientCapabilities=Q.params.capabilities,this._clientVersion=Q.params.clientInfo,{protocolVersion:HG.includes(Y)?Y:e6,capabilities:this.getCapabilities(),serverInfo:this._serverInfo,...this._instructions&&{instructions:this._instructions}}}getClientCapabilities(){return this._clientCapabilities}getClientVersion(){return this._clientVersion}getCapabilities(){return this._capabilities}async ping(){return this.request({method:"ping"},DQ)}async createMessage(Q,Y){if(Q.tools||Q.toolChoice){if(!this._clientCapabilities?.sampling?.tools)throw Error("Client does not support sampling tools capability.")}if(Q.messages.length>0){let X=Q.messages[Q.messages.length-1],W=Array.isArray(X.content)?X.content:[X.content],G=W.some((H)=>H.type==="tool_result"),z=Q.messages.length>1?Q.messages[Q.messages.length-2]:void 0,J=z?Array.isArray(z.content)?z.content:[z.content]:[],$=J.some((H)=>H.type==="tool_use");if(G){if(W.some((H)=>H.type!=="tool_result"))throw Error("The last message must contain only tool_result content if any is present");if(!$)throw Error("tool_result blocks are not matching any tool_use from the previous message")}if($){let H=new Set(J.filter((U)=>U.type==="tool_use").map((U)=>U.id)),A=new Set(W.filter((U)=>U.type==="tool_result").map((U)=>U.toolUseId));if(H.size!==A.size||![...H].every((U)=>A.has(U)))throw Error("ids of tool_result blocks and tool_use blocks from previous message do not match")}}if(Q.tools)return this.request({method:"sampling/createMessage",params:Q},OY,Y);return this.request({method:"sampling/createMessage",params:Q},qY,Y)}async elicitInput(Q,Y){switch(Q.mode??"form"){case"url":{if(!this._clientCapabilities?.elicitation?.url)throw Error("Client does not support url elicitation.");let W=Q;return this.request({method:"elicitation/create",params:W},bQ,Y)}case"form":{if(!this._clientCapabilities?.elicitation?.form)throw Error("Client does not support form elicitation.");let W=Q.mode==="form"?Q:{...Q,mode:"form"},G=await this.request({method:"elicitation/create",params:W},bQ,Y);if(G.action==="accept"&&G.content&&W.requestedSchema)try{let J=this._jsonSchemaValidator.getValidator(W.requestedSchema)(G.content);if(!J.valid)throw new v(g.InvalidParams,`Elicitation response content does not match requested schema: ${J.errorMessage}`)}catch(z){if(z instanceof v)throw z;throw new v(g.InternalError,`Error validating elicitation response: ${z instanceof Error?z.message:String(z)}`)}return G}}}createElicitationCompletionNotifier(Q,Y){if(!this._clientCapabilities?.elicitation?.url)throw Error("Client does not support URL elicitation (required for notifications/elicitation/complete)");return()=>this.notification({method:"notifications/elicitation/complete",params:{elicitationId:Q}},Y)}async listRoots(Q,Y){return this.request({method:"roots/list",params:Q},MY,Y)}async sendLoggingMessage(Q,Y){if(this._capabilities.logging){if(!this.isMessageIgnored(Q.level,Y))return this.notification({method:"notifications/message",params:Q})}}async sendResourceUpdated(Q){return this.notification({method:"notifications/resources/updated",params:Q})}async sendResourceListChanged(){return this.notification({method:"notifications/resources/list_changed"})}async sendToolListChanged(){return this.notification({method:"notifications/tools/list_changed"})}async sendPromptListChanged(){return this.notification({method:"notifications/prompts/list_changed"})}}var J5={name:"@sequenzy/mcp",version:"0.0.44",mcpName:"io.github.sequenzy/mcp",description:"Sequenzy MCP server for AI-powered email marketing automation",type:"module",bin:{"sequenzy-mcp":"dist/index.js"},main:"./dist/index.js",exports:{".":"./dist/index.js","./server":"./dist/server.js","./runtime":"./dist/runtime.js","./server.json":"./server.json"},scripts:{dev:"bun --watch src/index.ts",build:"bun build src/index.ts src/server.ts src/runtime.ts --outdir dist --target node --minify",start:"node dist/index.js","type-check":"tsc --noEmit",test:"bun test","test:watch":"bun test --watch",prepublishOnly:"bun run build"},dependencies:{"@modelcontextprotocol/sdk":"^1.0.0"},devDependencies:{"@types/bun":"latest","@types/node":"^22.0.0","bun-types":"latest",typescript:"^5.8.0"},files:["dist","server.json"],keywords:["sequenzy","email","mcp","ai","claude","automation"],license:"MIT",publishConfig:{access:"public"},repository:{type:"git",url:"git+https://github.com/Sequenzy/mcp.git"},homepage:"https://sequenzy.com",bugs:{url:"https://github.com/Sequenzy/mcp/issues"}};var T9=["product-info","domain","tracking","localization","integrations","products","events","tags","labels","goals","sync-rules","api-keys","widgets","team","danger"],$5={dashboard:"/dashboard/company/{companyId}",campaigns:"/dashboard/company/{companyId}/campaign",campaign:"/dashboard/company/{companyId}/campaign/{campaignId}",campaignPreview:"/dashboard/company/{companyId}/campaign/{campaignId}?step=review",campaignList:"/dashboard/company/{companyId}/campaign/list/{status}",sequences:"/dashboard/company/{companyId}/sequences",sequence:"/dashboard/company/{companyId}/sequences/{sequenceId}",sequenceList:"/dashboard/company/{companyId}/sequences/list/{status}",settings:"/dashboard/company/{companyId}/settings",settingsTab:"/dashboard/company/{companyId}/settings?tab={tab}",emails:"/dashboard/company/{companyId}/emails",email:"/dashboard/company/{companyId}/emails/{emailId}",subscribers:"/dashboard/company/{companyId}/subscribers",sentEmails:"/dashboard/company/{companyId}/sent-emails",emailSend:"/dashboard/company/{companyId}/sent-emails/{emailSendId}",segments:"/dashboard/company/{companyId}/segments",metrics:"/dashboard/company/{companyId}/metrics",transactional:"/dashboard/company/{companyId}/transactional",transactionalEmail:"/dashboard/company/{companyId}/transactional/{transactionalId}",domain:"/dashboard/company/{companyId}/settings/domain/{domainId}",domainVerify:"/dashboard/company/{companyId}/settings/domain/{domainId}/verify"};function AM(Q){let X=(Q??process.env.SEQUENZY_APP_URL??"https://sequenzy.com").trim().replace(/\/+$/,"");return X.length>0?X:"https://sequenzy.com"}function h0(Q){let Y=Q?.trim();return Y?Y:void 0}function t0(Q){return encodeURIComponent(Q)}function Q0(Q,Y){return`${Q}${Y}`}function Y0(Q,Y=""){return`/dashboard/company/${t0(Q)}${Y}`}function H5(Q,Y,X){return Q0(Q,`${Y0(Y,"/settings")}?tab=${encodeURIComponent(X)}`)}function UM(Q,Y){let X=T9.map((W)=>[W,Y?H5(Q,Y,W):""]);return Object.fromEntries(X)}function K1(Q={},Y){let X=AM(Y),W=h0(Q.companyId),G={},z=UM(X,W);if(!W)return{appUrl:X,routeTemplates:$5,settingsTabValues:T9,urls:G,settingsUrls:z};G.dashboard=Q0(X,Y0(W)),G.campaigns=Q0(X,Y0(W,"/campaign")),G.sequences=Q0(X,Y0(W,"/sequences")),G.settings=Q0(X,Y0(W,"/settings")),G.emails=Q0(X,Y0(W,"/emails")),G.subscribers=Q0(X,Y0(W,"/subscribers")),G.sentEmails=Q0(X,Y0(W,"/sent-emails")),G.segments=Q0(X,Y0(W,"/segments")),G.metrics=Q0(X,Y0(W,"/metrics")),G.transactional=Q0(X,Y0(W,"/transactional"));let J=h0(Q.campaignId);if(J)G.campaign=Q0(X,Y0(W,`/campaign/${t0(J)}`)),G.campaignPreview=`${G.campaign}?step=review`;let $=h0(Q.sequenceId);if($)G.sequence=Q0(X,Y0(W,`/sequences/${t0($)}`));let H=h0(Q.emailId)??h0(Q.templateId);if(H)G.email=Q0(X,Y0(W,`/emails/${t0(H)}`)),G.template=G.email;let A=h0(Q.transactionalId);if(A)G.transactionalEmail=Q0(X,Y0(W,`/transactional/${t0(A)}`));let U=h0(Q.emailSendId);if(U)G.emailSend=Q0(X,Y0(W,`/sent-emails/${t0(U)}`));let K=h0(Q.domainId);if(K)G.domain=Q0(X,Y0(W,`/settings/domain/${t0(K)}`)),G.domainVerify=`${G.domain}/verify`;let D=h0(Q.status);if(D)G.campaignList=Q0(X,Y0(W,`/campaign/list/${t0(D)}`)),G.sequenceList=Q0(X,Y0(W,`/sequences/list/${t0(D)}`));let L=h0(Q.settingsTab);if(L)G.settingsTab=H5(X,W,L);return{appUrl:X,routeTemplates:$5,settingsTabValues:T9,urls:G,settingsUrls:z}}var A5=[{uri:"sequenzy://dashboard",name:"Dashboard Overview",description:"Live overview stats for the last 7 days",mimeType:"application/json"},{uri:"sequenzy://company",name:"Current Company",description:"The currently selected company, including localization settings",mimeType:"application/json"},{uri:"sequenzy://campaigns/recent",name:"Recent Campaigns",description:"Last 10 campaigns with status and basic stats",mimeType:"application/json"},{uri:"sequenzy://subscribers/recent",name:"Recent Subscribers",description:"Most recently added subscribers",mimeType:"application/json"},{uri:"sequenzy://subscribers/engaged",name:"Engaged Subscribers",description:"Most active/engaged subscribers",mimeType:"application/json"},{uri:"sequenzy://sequences",name:"Sequences",description:"All email sequences with status",mimeType:"application/json"},{uri:"sequenzy://templates",name:"Templates",description:"All available email templates with localization status",mimeType:"application/json"},{uri:"sequenzy://segments",name:"Segments",description:"All defined segments with subscriber counts",mimeType:"application/json"},{uri:"sequenzy://tags",name:"Tags",description:"All tags with usage counts",mimeType:"application/json"},{uri:"sequenzy://health",name:"Deliverability Health",description:"Email deliverability metrics and health status",mimeType:"application/json"},{uri:"sequenzy://app-routes",name:"Dashboard URL Routes",description:"Route templates and settings tabs for building Sequenzy dashboard links",mimeType:"application/json"}];async function U5(Q){try{let Y;switch(Q){case"sequenzy://dashboard":Y=await N("GET","/api/v1/metrics?period=7d");break;case"sequenzy://company":{let X=await N("GET","/api/v1/account"),W=B1()??X.currentCompanyId;if(!W)throw Error("No company available. Create or select a company first.");Y=await N("GET",`/api/v1/companies/${W}`);break}case"sequenzy://campaigns/recent":Y=await N("GET","/api/v1/campaigns?limit=10");break;case"sequenzy://subscribers/recent":Y=await N("GET","/api/v1/subscribers?sort=createdAt&limit=20");break;case"sequenzy://subscribers/engaged":Y=await N("GET","/api/v1/subscribers?sort=engagement&limit=20");break;case"sequenzy://sequences":Y=await N("GET","/api/v1/sequences");break;case"sequenzy://templates":Y=await N("GET","/api/v1/templates");break;case"sequenzy://segments":Y=await N("GET","/api/v1/segments");break;case"sequenzy://tags":Y=await N("GET","/api/v1/tags");break;case"sequenzy://health":Y=await N("GET","/api/v1/health/deliverability");break;case"sequenzy://app-routes":Y=K1();break;default:throw Error(`Unknown resource: ${Q}`)}return{contents:[{uri:Q,mimeType:"application/json",text:JSON.stringify(Y,null,2)}]}}catch(Y){return{contents:[{uri:Q,mimeType:"text/plain",text:b1(Y)}]}}}var h4="Sequenzy email blocks. Use `styles` for per-block background, text color, padding, border radius, border width, and border color. Top-level style aliases such as `backgroundColor`, `borderColor`, `borderWidth`, and `borderRadius` are also accepted and saved under `styles`. Use this for editor-compatible content, including conditional and repeat blocks. Repeat blocks use { type: 'repeat', source: 'items', itemAlias: 'item', children: [...] }.",H6="Replacement Sequenzy email blocks. Use `styles` for per-block background, text color, padding, border radius, border width, and border color. Top-level style aliases such as `backgroundColor`, `borderColor`, `borderWidth`, and `borderRadius` are also accepted and saved under `styles`.",B5="Sequenzy email blocks. Provide blocks or html for email steps. Use `styles` for per-block background, text color, padding, border radius, border width, and border color. Top-level style aliases such as `backgroundColor`, `borderColor`, `borderWidth`, and `borderRadius` are also accepted and saved under `styles`. Blocks can include repeat blocks over array variables such as items.",KM={type:"object",properties:{id:{type:"string",description:"Optional filter ID. Any stable string works; one will be generated if omitted."},field:{type:"string",enum:["status","tag","email","emailProvider","added","firstName","lastName","list","emailSent","emailOpened","emailClicked","emailBounced","emailComplained","attribute","event","segment","stripeProduct","stripeCurrentProduct","stripeTrialProduct"],description:"Filter field. Use `event` for custom subscriber events, `segment` for saved segment membership, and `stripeProduct`/`stripeCurrentProduct`/`stripeTrialProduct` for Stripe product-based segments. Engagement fields (`emailSent`, `emailOpened`, `emailClicked`, `emailBounced`, `emailComplained`) accept a time range as the value or a specific campaign via `campaign:<campaign_id>`."},operator:{type:"string",enum:["is","is_not","is_empty","is_not_empty","contains","not_contains","less_than","more_than","at_least","less_than_count","gte","lte","gt","lt"],description:"Filter operator. Use `is_empty` or `is_not_empty` for fields that can be blank, including custom attributes. For `stripeProduct`, use `is` or `is_not` with a raw product ID, and `at_least` or `less_than_count` with `productId:count`. For `event`, use `is`, `is_not`, `at_least`, or `less_than_count`. For engagement fields, use `is` (event happened) or `is_not` (event did not happen)."},value:{type:"string",description:"Filter value. For custom attribute empty checks, use `attributeName:` such as `last_logged_in:`. Event examples: `saas.purchase:30d`, `saas.purchase:all`, or `saas.purchase:5:30d` for thresholds. Segment values are segment IDs. Stripe product examples: `prod_123` for bought/didn't buy, `prod_123:3` for payment thresholds. Engagement examples: `7d`, `30d`, `90d`, `180d`, `all` for rolling time windows, or `campaign:<campaign_id>` to scope to a specific sent campaign (use `list_campaigns` to find IDs)."}},required:["field","operator","value"],additionalProperties:!1},DM={type:"object",properties:{kind:{type:"string",enum:["group"]},id:{type:"string",description:"Stable group ID. Any string works; one will be generated if omitted."},joinOperator:{type:"string",enum:["and","or"],description:"How children in this group combine."},children:{type:"array",minItems:1,items:{type:"object",description:'Either a filter leaf (`kind: "filter"`) or another group (`kind: "group"`).'}}},required:["kind","joinOperator","children"],additionalProperties:!0};function L5(Q){if(!Array.isArray(Q))return Q;return Q.map((Y)=>{if(typeof Y!=="object"||Y===null)return Y;let X=Y;if(typeof X.id==="string"&&X.id.trim()!=="")return X;return{...X,id:crypto.randomUUID()}})}function F5(Q){if(typeof Q!=="object"||Q===null)return Q;let Y=Q;if(Y.kind==="filter"){let X=L5([Y]);return Array.isArray(X)?X[0]:Y}if(Y.kind!=="group")return Q;return{...Y,id:typeof Y.id==="string"&&Y.id.trim()!==""?Y.id:crypto.randomUUID(),children:Array.isArray(Y.children)?Y.children.map(F5):[]}}function w1(Q,Y,X){if(Y.html!==void 0&&Y.blocks!==void 0)throw Error(`Provide either \`html\` or \`blocks\` when calling \`${Q}\`, not both.`);if(Y.blocks!==void 0&&!Array.isArray(Y.blocks))throw Error(`\`blocks\` must be an array when calling \`${Q}\`.`);if(X?.requireContent&&Y.html===void 0&&Y.blocks===void 0)throw Error(`Provide either \`html\` or \`blocks\` when calling \`${Q}\`.`)}function U6(Q,Y){if(Y.labels===void 0)return;if(!Array.isArray(Y.labels))throw Error(`\`labels\` must be an array when calling \`${Q}\`.`);if(Y.labels.some((X)=>typeof X!=="string"||X.trim().length===0))throw Error(`\`labels\` must contain only non-empty strings when calling \`${Q}\`.`)}function BM(Q){let Y=Q.filters!==void 0,X=Q.root!==void 0;if(Y&&X)throw Error("Provide either `filters` or `root` when calling `create_segment`, not both.");if(!Y&&!X)throw Error("Provide either `filters` or `root` when calling `create_segment`.");if(Y){if(!Array.isArray(Q.filters))throw Error("`filters` must be an array when calling `create_segment`.");if(Q.filters.length===0)throw Error("`filters` must include at least one filter when calling `create_segment`.")}if(X&&(typeof Q.root!=="object"||Q.root===null))throw Error("`root` must be an object when calling `create_segment`.")}function LM(Q){if(Q.clearEnrollmentFieldPath===!0&&Q.enrollmentFieldPath!==void 0)throw Error("Provide either `enrollmentFieldPath` or `clearEnrollmentFieldPath` when calling `update_sequence`, not both.");let Y={...Q};if(delete Y.clearEnrollmentFieldPath,Q.clearEnrollmentFieldPath===!0)Y.enrollmentFieldPath=null;return Y}function FM(Q){let Y=j(Q,"subscriberId"),X=Q.fieldValues,W=X===void 0?void 0:Array.isArray(X)?X:void 0;if(X!==void 0&&W===void 0)throw Error("`fieldValues` must be an array when calling `cancel_sequence_enrollments`.");let G=W?.map(($)=>typeof $==="string"?$.trim():"").filter(($)=>$.length>0)??[];if(W?.some(($)=>typeof $!=="string")||W!==void 0&&G.length===0)throw Error("`fieldValues` must contain at least one non-empty string when calling `cancel_sequence_enrollments`.");if(Y!==void 0===G.length>0)throw Error("Provide exactly one target when calling `cancel_sequence_enrollments`: `subscriberId` or `fieldValues`.");let z=j(Q,"fieldPath"),J=j(Q,"reason");return{...Y!==void 0&&{subscriberId:Y},...z!==void 0&&{fieldPath:z},...G.length>0&&{fieldValues:G},...typeof Q.dryRun==="boolean"&&{dryRun:Q.dryRun},...J!==void 0&&{reason:J}}}function qM(Q){w1("create_campaign",Q),U6("create_campaign",Q);let Y=j(Q,"prompt")!==void 0,X=Q.html!==void 0,W=Q.blocks!==void 0,G=Q.templateId!==void 0;if(Q.prompt!==void 0&&!Y)throw Error("`prompt` cannot be empty when calling `create_campaign`.");if(Y&&(X||W||G))throw Error("Provide either `prompt`, `html`, `blocks`, or `templateId` when calling `create_campaign`, not multiple content sources.");if(!Y&&(Q.style!==void 0||Q.tone!==void 0))throw Error("`style` and `tone` can only be used with `prompt` when calling `create_campaign`.");if(!Y&&j(Q,"subject")===void 0)throw Error("`subject` is required unless `prompt` is provided when calling `create_campaign`.")}function OM(Q){if(j(Q,"scheduledAt")===void 0)throw Error("`scheduledAt` is required when calling `schedule_campaign`.");if(Q.targetLists!==void 0&&!B0(Q.targetLists))throw Error("`targetLists` must be an object when calling `schedule_campaign`.");if(Q.sendTimeOptimization!==void 0){if(typeof Q.sendTimeOptimization!=="boolean")throw Error("`sendTimeOptimization` must be a boolean when calling `schedule_campaign`.")}if(Q.spreadOverHours!==void 0){if(typeof Q.spreadOverHours!=="number"||!Number.isInteger(Q.spreadOverHours)||Q.spreadOverHours<1||Q.spreadOverHours>72)throw Error("`spreadOverHours` must be an integer between 1 and 72 when calling `schedule_campaign`.")}}function MM(Q){w1("create_transactional_email",Q);let Y=j(Q,"prompt")!==void 0,X=Q.html!==void 0,W=Q.blocks!==void 0;if(Q.prompt!==void 0&&!Y)throw Error("`prompt` cannot be empty when calling `create_transactional_email`.");if(Y&&(X||W))throw Error("Provide either `prompt`, `html`, or `blocks` when calling `create_transactional_email`, not multiple content sources.");if(!Y&&(Q.style!==void 0||Q.tone!==void 0))throw Error("`style` and `tone` can only be used with `prompt` when calling `create_transactional_email`.");if(!Y&&!X&&!W)throw Error("Provide either `prompt`, `html`, or `blocks` when calling `create_transactional_email`.");if(!Y&&j(Q,"subject")===void 0)throw Error("`subject` is required unless `prompt` is provided when calling `create_transactional_email`.")}var K5={type:"object",description:"A step to create inside a branch path. Use type:'delay' for a standalone delay, type:'email' for an email, or type:'create_discount' for a discount action.",properties:{type:{type:"string",enum:["email","delay","create_discount","discount","webhook"],description:"Branch path step type. Omit for email steps; use delay for standalone waits."},nodeType:{type:"string",enum:["logic_delay","action_email","action_create_discount","action_add_tag","action_remove_tag","action_add_to_list","action_remove_from_list","action_update_attributes","logic_wait_for_event","action_webhook"],description:"Advanced branch path node type. Prefer type unless creating a non-email action."},config:{type:"object",description:"Config for advanced nodeType steps such as tag/list/webhook/wait-for-event actions.",additionalProperties:!0},subject:{type:"string",description:"Email subject. Required for email steps."},previewText:{type:"string",description:"Email preview text."},blocks:{type:"array",description:B5,items:{type:"object"}},html:{type:"string",description:"HTML content for email steps."},delay:{type:"object",description:"Delay before this step, or the delay duration when type is delay.",properties:{days:{type:"number"},hours:{type:"number"},minutes:{type:"number"}}},delayMs:{type:"number",description:"Delay in milliseconds. Useful for standalone type:'delay' steps."},name:{type:"string",description:"Email template name for email steps."},discount:{type:"object",description:"Discount configuration for create_discount steps. Same shape as create_sequence steps.",additionalProperties:!0},label:{type:"string",description:"Node label for discount or advanced node steps."},provider:{type:"string",enum:["stripe","shopify"]},discountType:{type:"string",enum:["percent","amount"]},percentOff:{type:"number"},amountOff:{type:"number"},currency:{type:"string"},duration:{type:"string",enum:["once","forever","repeating"]},durationInMonths:{type:"number"},appliesToAllPlans:{type:"boolean"},planIds:{type:"array",items:{type:"string"}},codePrefix:{type:"string"},maxRedemptions:{type:"number"},lockToSubscriber:{type:"boolean"},expiresAt:{type:"string"},expiresInHours:{type:"number"}},additionalProperties:!1};function VM(Q){if(!Q||typeof Q!=="object")return null;let Y=Q;if(Y.success!==!1)return null;if(typeof Y.error==="string")return Error(Y.error);if(Y.error&&typeof Y.error==="object"&&typeof Y.error.message==="string")return Error(Y.error.message);if(typeof Y.message==="string")return Error(Y.message);return Error("The tool returned an unsuccessful response.")}function B0(Q){return typeof Q==="object"&&Q!==null&&!Array.isArray(Q)}function D5(Q){return Q.trim().toLowerCase().replace(/\s+/g,"-")}function NM(Q){let Y=new URLSearchParams;if(typeof Q.query==="string"&&Q.query.trim()!=="")Y.set("query",Q.query.trim());if(Array.isArray(Q.tags)&&Q.tags.length>0)Y.set("tags",Q.tags.filter((X)=>typeof X==="string"&&X.trim()!=="").join(","));if(typeof Q.segmentId==="string"&&Q.segmentId.trim()!=="")Y.set("segmentId",Q.segmentId);if(typeof Q.status==="string"&&Q.status.trim()!=="")Y.set("status",Q.status.trim());return Y.set("page",String(Q.page)),Y.set("limit",String(Q.pageSize)),Y}async function ZM(Q,Y){let X=typeof Q.limit==="number"&&Number.isFinite(Q.limit)?Math.max(1,Math.trunc(Q.limit)):void 0,W=Math.min(100,Math.max(1,X??100)),G=[],z=1,J=0,$=0,H=0;while(!0){let U=NM({query:Q.query,tags:Q.tags,segmentId:Q.segmentId,status:Q.status,page:z,pageSize:W}),K=await N("GET",`/api/v1/subscribers?${U.toString()}`,void 0,Y);J=K.pagination?.total??K.subscribers.length,$=K.pagination?.totalPages??1,H+=1,G.push(...K.subscribers??[]);let D=X!==void 0&&G.length>=X,L=K.pagination?z>=K.pagination.totalPages:(K.subscribers??[]).length<W;if(D||L)break;z+=1}let A=X!==void 0?G.slice(0,X):G;return{success:!0,subscribers:A,pagination:{page:1,limit:W,total:J,totalPages:$,fetchedPages:H},returned:A.length,truncated:X!==void 0&&J>0&&A.length<J}}function wM(Q){let Y=typeof Q.email==="string"&&Q.email.trim()!==""?Q.email.trim():void 0,X=typeof Q.externalId==="string"&&Q.externalId.trim()!==""?Q.externalId.trim():void 0;return{...Y?{email:Y}:{},...X?{externalId:X}:{}}}function f4(Q,Y){let X=wM(Y);if(!X.email&&!X.externalId)throw Error(`Provide either \`email\` or \`externalId\` when calling \`${Q}\`.`);return X}function R9(Q){if(Q.email)return`/api/v1/subscribers/${encodeURIComponent(Q.email)}`;return`/api/v1/subscribers/external?externalId=${encodeURIComponent(String(Q.externalId))}`}async function S9(Q,Y){return N("GET",R9(Q),void 0,Y)}function j(Q,Y){let X=Q[Y];if(typeof X!=="string")return;let W=X.trim();return W.length>0?W:void 0}async function q5(Q){let Y=j(Q,"companyId");if(Y)return Y;let X=B1();if(X)return X;try{return(await N("GET","/api/v1/account")).currentCompanyId??void 0}catch{return}}function l4(Q,Y){if(!B0(Q)||!Y)return Q;return{...Q,url:Y}}function O5(Q,Y){if(!B0(Q))return Q;return{...Q,...Y.campaign!==void 0&&{url:Y.campaign},...Y.campaignPreview!==void 0&&{previewUrl:Y.campaignPreview}}}function A6(Q,Y,X){if(!Array.isArray(Q)||!Y)return Q;return Q.map((W)=>{if(!B0(W))return W;let G=j(W,"id");if(!G)return W;let z=K1({companyId:Y,...X==="campaign"&&{campaignId:G},...X==="sequence"&&{sequenceId:G},...X==="template"&&{emailId:G},...X==="transactional"&&{transactionalId:G}});if(X==="campaign")return O5(W,z.urls);let J=X==="sequence"?z.urls.sequence:X==="template"?z.urls.email:z.urls.transactionalEmail;return l4(W,J)})}function bM(Q){if(!Array.isArray(Q))return Q;return Q.map((Y)=>{if(!B0(Y))return Y;let X=j(Y,"id");if(!X)return Y;let W=K1({companyId:X});return{...Y,url:W.urls.dashboard,settingsUrl:W.urls.settings}})}var PM=new Set(["get_account","select_company","create_company","get_company","list_campaigns","get_campaign","get_email_send","create_campaign","update_campaign","schedule_campaign","send_test_email","list_sequences","get_sequence","create_sequence","update_sequence","enable_sequence","disable_sequence","cancel_sequence_enrollments","list_ab_tests","get_ab_test","get_ab_test_stats","update_ab_test_variant","list_templates","get_template","create_template","update_template","list_transactional_emails","get_transactional_email","create_transactional_email","update_transactional_email"]);async function jM(Q,Y,X){if(!B0(X)||!PM.has(Q))return X;let W=B0(X.company)?X.company:void 0,z=j(X,"selectedCompanyId")??j(X,"currentCompanyId")??j(X,"companyId")??(W?j(W,"id"):void 0)??(W?j(W,"companyId"):void 0)??await q5(Y);if(!z)return X;let J=B0(X.campaign)?X.campaign:void 0,$=B0(X.sequence)?X.sequence:void 0,H=B0(X.template)?X.template:void 0,A=B0(X.transactional)&&!Array.isArray(X.transactional)?X.transactional:void 0,U={companyId:z,campaignId:j(Y,"campaignId")??j(X,"campaignId")??(J?j(J,"id"):void 0),sequenceId:j(Y,"sequenceId")??j(X,"sequenceId")??($?j($,"id"):void 0),emailId:j(X,"templateId")??(H?j(H,"id"):void 0)??(A?j(A,"emailId"):void 0)??j(Y,"templateId"),transactionalId:j(Y,"transactionalId")??(A?j(A,"id"):void 0)??j(Y,"idOrSlug"),emailSendId:j(Y,"emailSendId")??j(X,"emailSendId")??(B0(X.emailSend)?j(X.emailSend,"id"):void 0),status:j(Y,"status")},K=K1(U),D=W?K1({companyId:z}):void 0;return{...X,...Array.isArray(X.companies)&&{companies:bM(X.companies)},...Array.isArray(X.campaigns)&&{campaigns:A6(X.campaigns,z,"campaign")},...Array.isArray(X.sequences)&&{sequences:A6(X.sequences,z,"sequence")},...Array.isArray(X.templates)&&{templates:A6(X.templates,z,"template")},...Array.isArray(X.transactional)&&{transactional:A6(X.transactional,z,"transactional")},...W&&D!==void 0&&{company:{...W,url:D.urls.dashboard,settingsUrl:D.urls.settings}},...J&&K.urls.campaign!==void 0&&{campaign:O5(J,K.urls)},...$&&K.urls.sequence!==void 0&&{sequence:l4($,K.urls.sequence)},...H&&K.urls.email!==void 0&&{template:l4(H,K.urls.email)},...A&&K.urls.transactionalEmail!==void 0&&{transactional:l4(A,K.urls.transactionalEmail)},...B0(X.emailSend)&&K.urls.emailSend!==void 0&&{emailSend:l4(X.emailSend,K.urls.emailSend)},appUrls:K.urls}}var M5=[{name:"get_account",description:`Get current account information including available companies. IMPORTANT: If you have access to multiple companies, you MUST either:
28
+ `)}L.write("payload.value = newResult;"),L.write("return payload;");let S=L.compile();return(E,x)=>S(D,E,x)},z,J=L1,$=!m4.jitless,A=$&&V6.value,U=Y.catchall,K;Q._zod.parse=(D,L)=>{K??(K=W.value);let q=D.value;if(!J(q))return D.issues.push({expected:"object",code:"invalid_type",input:q,inst:Q}),D;if($&&A&&L?.async===!1&&L.jitless!==!0){if(!z)z=G(Y.shape);if(D=z(D,L),!U)return D;return v8([],q,D,L,K,Q)}return X(D,L)}});function dX(Q,Y,X,W){for(let z of Q)if(z.issues.length===0)return Y.value=z.value,Y;let G=Q.filter((z)=>!Q1(z));if(G.length===1)return Y.value=G[0].value,G[0];return Y.issues.push({code:"invalid_union",input:Y.value,inst:X,errors:Q.map((z)=>z.issues.map((J)=>T0(J,W,w0())))}),Y}var C6=F("$ZodUnion",(Q,Y)=>{i.init(Q,Y),m(Q._zod,"optin",()=>Y.options.some((G)=>G._zod.optin==="optional")?"optional":void 0),m(Q._zod,"optout",()=>Y.options.some((G)=>G._zod.optout==="optional")?"optional":void 0),m(Q._zod,"values",()=>{if(Y.options.every((G)=>G._zod.values))return new Set(Y.options.flatMap((G)=>Array.from(G._zod.values)));return}),m(Q._zod,"pattern",()=>{if(Y.options.every((G)=>G._zod.pattern)){let G=Y.options.map((z)=>z._zod.pattern);return new RegExp(`^(${G.map((z)=>d1(z.source)).join("|")})$`)}return});let X=Y.options.length===1,W=Y.options[0]._zod.run;Q._zod.parse=(G,z)=>{if(X)return W(G,z);let J=!1,$=[];for(let H of Y.options){let A=H._zod.run({value:G.value,issues:[]},z);if(A instanceof Promise)$.push(A),J=!0;else{if(A.issues.length===0)return A;$.push(A)}}if(!J)return dX($,G,Q,z);return Promise.all($).then((H)=>{return dX(H,G,Q,z)})}}),x8=F("$ZodDiscriminatedUnion",(Q,Y)=>{C6.init(Q,Y);let X=Q._zod.parse;m(Q._zod,"propValues",()=>{let G={};for(let z of Y.options){let J=z._zod.propValues;if(!J||Object.keys(J).length===0)throw Error(`Invalid discriminated union option at index "${Y.options.indexOf(z)}"`);for(let[$,H]of Object.entries(J)){if(!G[$])G[$]=new Set;for(let A of H)G[$].add(A)}}return G});let W=j1(()=>{let G=Y.options,z=new Map;for(let J of G){let $=J._zod.propValues?.[Y.discriminator];if(!$||$.size===0)throw Error(`Invalid discriminated union option at index "${Y.options.indexOf(J)}"`);for(let H of $){if(z.has(H))throw Error(`Duplicate discriminator value "${String(H)}"`);z.set(H,J)}}return z});Q._zod.parse=(G,z)=>{let J=G.value;if(!L1(J))return G.issues.push({code:"invalid_type",expected:"object",input:J,inst:Q}),G;let $=W.value.get(J?.[Y.discriminator]);if($)return $._zod.run(G,z);if(Y.unionFallback)return X(G,z);return G.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:Y.discriminator,input:J,path:[Y.discriminator],inst:Q}),G}}),_8=F("$ZodIntersection",(Q,Y)=>{i.init(Q,Y),Q._zod.parse=(X,W)=>{let G=X.value,z=Y.left._zod.run({value:G,issues:[]},W),J=Y.right._zod.run({value:G,issues:[]},W);if(z instanceof Promise||J instanceof Promise)return Promise.all([z,J]).then(([H,A])=>{return oX(X,H,A)});return oX(X,z,J)}});function S6(Q,Y){if(Q===Y)return{valid:!0,data:Q};if(Q instanceof Date&&Y instanceof Date&&+Q===+Y)return{valid:!0,data:Q};if(e0(Q)&&e0(Y)){let X=Object.keys(Y),W=Object.keys(Q).filter((z)=>X.indexOf(z)!==-1),G={...Q,...Y};for(let z of W){let J=S6(Q[z],Y[z]);if(!J.valid)return{valid:!1,mergeErrorPath:[z,...J.mergeErrorPath]};G[z]=J.data}return{valid:!0,data:G}}if(Array.isArray(Q)&&Array.isArray(Y)){if(Q.length!==Y.length)return{valid:!1,mergeErrorPath:[]};let X=[];for(let W=0;W<Q.length;W++){let G=Q[W],z=Y[W],J=S6(G,z);if(!J.valid)return{valid:!1,mergeErrorPath:[W,...J.mergeErrorPath]};X.push(J.data)}return{valid:!0,data:X}}return{valid:!1,mergeErrorPath:[]}}function oX(Q,Y,X){if(Y.issues.length)Q.issues.push(...Y.issues);if(X.issues.length)Q.issues.push(...X.issues);if(Q1(Q))return Q;let W=S6(Y.value,X.value);if(!W.valid)throw Error(`Unmergable intersection. Error path: ${JSON.stringify(W.mergeErrorPath)}`);return Q.value=W.data,Q}var g8=F("$ZodRecord",(Q,Y)=>{i.init(Q,Y),Q._zod.parse=(X,W)=>{let G=X.value;if(!e0(G))return X.issues.push({expected:"record",code:"invalid_type",input:G,inst:Q}),X;let z=[];if(Y.keyType._zod.values){let J=Y.keyType._zod.values;X.value={};for(let H of J)if(typeof H==="string"||typeof H==="number"||typeof H==="symbol"){let A=Y.valueType._zod.run({value:G[H],issues:[]},W);if(A instanceof Promise)z.push(A.then((U)=>{if(U.issues.length)X.issues.push(...c0(H,U.issues));X.value[H]=U.value}));else{if(A.issues.length)X.issues.push(...c0(H,A.issues));X.value[H]=A.value}}let $;for(let H in G)if(!J.has(H))$=$??[],$.push(H);if($&&$.length>0)X.issues.push({code:"unrecognized_keys",input:G,inst:Q,keys:$})}else{X.value={};for(let J of Reflect.ownKeys(G)){if(J==="__proto__")continue;let $=Y.keyType._zod.run({value:J,issues:[]},W);if($ instanceof Promise)throw Error("Async schemas not supported in object keys currently");if($.issues.length){X.issues.push({code:"invalid_key",origin:"record",issues:$.issues.map((A)=>T0(A,W,w0())),input:J,path:[J],inst:Q}),X.value[$.value]=$.value;continue}let H=Y.valueType._zod.run({value:G[J],issues:[]},W);if(H instanceof Promise)z.push(H.then((A)=>{if(A.issues.length)X.issues.push(...c0(J,A.issues));X.value[$.value]=A.value}));else{if(H.issues.length)X.issues.push(...c0(J,H.issues));X.value[$.value]=H.value}}}if(z.length)return Promise.all(z).then(()=>X);return X}});var y8=F("$ZodEnum",(Q,Y)=>{i.init(Q,Y);let X=O6(Y.entries),W=new Set(X);Q._zod.values=W,Q._zod.pattern=new RegExp(`^(${X.filter((G)=>N6.has(typeof G)).map((G)=>typeof G==="string"?m0(G):G.toString()).join("|")})$`),Q._zod.parse=(G,z)=>{let J=G.value;if(W.has(J))return G;return G.issues.push({code:"invalid_value",values:X,input:J,inst:Q}),G}}),u8=F("$ZodLiteral",(Q,Y)=>{if(i.init(Q,Y),Y.values.length===0)throw Error("Cannot create literal schema with no valid values");Q._zod.values=new Set(Y.values),Q._zod.pattern=new RegExp(`^(${Y.values.map((X)=>typeof X==="string"?m0(X):X?m0(X.toString()):String(X)).join("|")})$`),Q._zod.parse=(X,W)=>{let G=X.value;if(Q._zod.values.has(G))return X;return X.issues.push({code:"invalid_value",values:Y.values,input:G,inst:Q}),X}});var h8=F("$ZodTransform",(Q,Y)=>{i.init(Q,Y),Q._zod.parse=(X,W)=>{if(W.direction==="backward")throw new i1(Q.constructor.name);let G=Y.transform(X.value,X);if(W.async)return(G instanceof Promise?G:Promise.resolve(G)).then((J)=>{return X.value=J,X});if(G instanceof Promise)throw new l0;return X.value=G,X}});function tX(Q,Y){if(Q.issues.length&&Y===void 0)return{issues:[],value:void 0};return Q}var f8=F("$ZodOptional",(Q,Y)=>{i.init(Q,Y),Q._zod.optin="optional",Q._zod.optout="optional",m(Q._zod,"values",()=>{return Y.innerType._zod.values?new Set([...Y.innerType._zod.values,void 0]):void 0}),m(Q._zod,"pattern",()=>{let X=Y.innerType._zod.pattern;return X?new RegExp(`^(${d1(X.source)})?$`):void 0}),Q._zod.parse=(X,W)=>{if(Y.innerType._zod.optin==="optional"){let G=Y.innerType._zod.run(X,W);if(G instanceof Promise)return G.then((z)=>tX(z,X.value));return tX(G,X.value)}if(X.value===void 0)return X;return Y.innerType._zod.run(X,W)}}),l8=F("$ZodNullable",(Q,Y)=>{i.init(Q,Y),m(Q._zod,"optin",()=>Y.innerType._zod.optin),m(Q._zod,"optout",()=>Y.innerType._zod.optout),m(Q._zod,"pattern",()=>{let X=Y.innerType._zod.pattern;return X?new RegExp(`^(${d1(X.source)}|null)$`):void 0}),m(Q._zod,"values",()=>{return Y.innerType._zod.values?new Set([...Y.innerType._zod.values,null]):void 0}),Q._zod.parse=(X,W)=>{if(X.value===null)return X;return Y.innerType._zod.run(X,W)}}),m8=F("$ZodDefault",(Q,Y)=>{i.init(Q,Y),Q._zod.optin="optional",m(Q._zod,"values",()=>Y.innerType._zod.values),Q._zod.parse=(X,W)=>{if(W.direction==="backward")return Y.innerType._zod.run(X,W);if(X.value===void 0)return X.value=Y.defaultValue,X;let G=Y.innerType._zod.run(X,W);if(G instanceof Promise)return G.then((z)=>aX(z,Y));return aX(G,Y)}});function aX(Q,Y){if(Q.value===void 0)Q.value=Y.defaultValue;return Q}var c8=F("$ZodPrefault",(Q,Y)=>{i.init(Q,Y),Q._zod.optin="optional",m(Q._zod,"values",()=>Y.innerType._zod.values),Q._zod.parse=(X,W)=>{if(W.direction==="backward")return Y.innerType._zod.run(X,W);if(X.value===void 0)X.value=Y.defaultValue;return Y.innerType._zod.run(X,W)}}),p8=F("$ZodNonOptional",(Q,Y)=>{i.init(Q,Y),m(Q._zod,"values",()=>{let X=Y.innerType._zod.values;return X?new Set([...X].filter((W)=>W!==void 0)):void 0}),Q._zod.parse=(X,W)=>{let G=Y.innerType._zod.run(X,W);if(G instanceof Promise)return G.then((z)=>sX(z,Q));return sX(G,Q)}});function sX(Q,Y){if(!Q.issues.length&&Q.value===void 0)Q.issues.push({code:"invalid_type",expected:"nonoptional",input:Q.value,inst:Y});return Q}var i8=F("$ZodCatch",(Q,Y)=>{i.init(Q,Y),m(Q._zod,"optin",()=>Y.innerType._zod.optin),m(Q._zod,"optout",()=>Y.innerType._zod.optout),m(Q._zod,"values",()=>Y.innerType._zod.values),Q._zod.parse=(X,W)=>{if(W.direction==="backward")return Y.innerType._zod.run(X,W);let G=Y.innerType._zod.run(X,W);if(G instanceof Promise)return G.then((z)=>{if(X.value=z.value,z.issues.length)X.value=Y.catchValue({...X,error:{issues:z.issues.map((J)=>T0(J,W,w0()))},input:X.value}),X.issues=[];return X});if(X.value=G.value,G.issues.length)X.value=Y.catchValue({...X,error:{issues:G.issues.map((z)=>T0(z,W,w0()))},input:X.value}),X.issues=[];return X}});var r8=F("$ZodPipe",(Q,Y)=>{i.init(Q,Y),m(Q._zod,"values",()=>Y.in._zod.values),m(Q._zod,"optin",()=>Y.in._zod.optin),m(Q._zod,"optout",()=>Y.out._zod.optout),m(Q._zod,"propValues",()=>Y.in._zod.propValues),Q._zod.parse=(X,W)=>{if(W.direction==="backward"){let z=Y.out._zod.run(X,W);if(z instanceof Promise)return z.then((J)=>s4(J,Y.in,W));return s4(z,Y.in,W)}let G=Y.in._zod.run(X,W);if(G instanceof Promise)return G.then((z)=>s4(z,Y.out,W));return s4(G,Y.out,W)}});function s4(Q,Y,X){if(Q.issues.length)return Q.aborted=!0,Q;return Y._zod.run({value:Q.value,issues:Q.issues},X)}var n8=F("$ZodReadonly",(Q,Y)=>{i.init(Q,Y),m(Q._zod,"propValues",()=>Y.innerType._zod.propValues),m(Q._zod,"values",()=>Y.innerType._zod.values),m(Q._zod,"optin",()=>Y.innerType._zod.optin),m(Q._zod,"optout",()=>Y.innerType._zod.optout),Q._zod.parse=(X,W)=>{if(W.direction==="backward")return Y.innerType._zod.run(X,W);let G=Y.innerType._zod.run(X,W);if(G instanceof Promise)return G.then(eX);return eX(G)}});function eX(Q){return Q.value=Object.freeze(Q.value),Q}var d8=F("$ZodCustom",(Q,Y)=>{W0.init(Q,Y),i.init(Q,Y),Q._zod.parse=(X,W)=>{return X},Q._zod.check=(X)=>{let W=X.value,G=Y.fn(W);if(G instanceof Promise)return G.then((z)=>Q8(z,X,W,Q));Q8(G,X,W,Q);return}});function Q8(Q,Y,X,W){if(!Q){let G={code:"custom",input:X,inst:W,path:[...W._zod.def.path??[]],continue:!W._zod.def.abort};if(W._zod.def.params)G.params=W._zod.def.params;Y.issues.push(I1(G))}}var FH=(Q)=>{let Y=typeof Q;switch(Y){case"number":return Number.isNaN(Q)?"NaN":"number";case"object":{if(Array.isArray(Q))return"array";if(Q===null)return"null";if(Object.getPrototypeOf(Q)!==Object.prototype&&Q.constructor)return Q.constructor.name}}return Y},qH=()=>{let Q={string:{unit:"characters",verb:"to have"},file:{unit:"bytes",verb:"to have"},array:{unit:"items",verb:"to have"},set:{unit:"items",verb:"to have"}};function Y(W){return Q[W]??null}let X={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",jwt:"JWT",template_literal:"input"};return(W)=>{switch(W.code){case"invalid_type":return`Invalid input: expected ${W.expected}, received ${FH(W.input)}`;case"invalid_value":if(W.values.length===1)return`Invalid input: expected ${r4(W.values[0])}`;return`Invalid option: expected one of ${c4(W.values,"|")}`;case"too_big":{let G=W.inclusive?"<=":"<",z=Y(W.origin);if(z)return`Too big: expected ${W.origin??"value"} to have ${G}${W.maximum.toString()} ${z.unit??"elements"}`;return`Too big: expected ${W.origin??"value"} to be ${G}${W.maximum.toString()}`}case"too_small":{let G=W.inclusive?">=":">",z=Y(W.origin);if(z)return`Too small: expected ${W.origin} to have ${G}${W.minimum.toString()} ${z.unit}`;return`Too small: expected ${W.origin} to be ${G}${W.minimum.toString()}`}case"invalid_format":{let G=W;if(G.format==="starts_with")return`Invalid string: must start with "${G.prefix}"`;if(G.format==="ends_with")return`Invalid string: must end with "${G.suffix}"`;if(G.format==="includes")return`Invalid string: must include "${G.includes}"`;if(G.format==="regex")return`Invalid string: must match pattern ${G.pattern}`;return`Invalid ${X[G.format]??W.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${W.divisor}`;case"unrecognized_keys":return`Unrecognized key${W.keys.length>1?"s":""}: ${c4(W.keys,", ")}`;case"invalid_key":return`Invalid key in ${W.origin}`;case"invalid_union":return"Invalid input";case"invalid_element":return`Invalid value in ${W.origin}`;default:return"Invalid input"}}};function v6(){return{localeError:qH()}}var nM=Symbol("ZodOutput"),dM=Symbol("ZodInput");class o8{constructor(){this._map=new WeakMap,this._idmap=new Map}add(Q,...Y){let X=Y[0];if(this._map.set(Q,X),X&&typeof X==="object"&&"id"in X){if(this._idmap.has(X.id))throw Error(`ID ${X.id} already exists in the registry`);this._idmap.set(X.id,Q)}return this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(Q){let Y=this._map.get(Q);if(Y&&typeof Y==="object"&&"id"in Y)this._idmap.delete(Y.id);return this._map.delete(Q),this}get(Q){let Y=Q._zod.parent;if(Y){let X={...this.get(Y)??{}};delete X.id;let W={...X,...this._map.get(Q)};return Object.keys(W).length?W:void 0}return this._map.get(Q)}has(Q){return this._map.has(Q)}}function OH(){return new o8}var Q4=OH();function t8(Q,Y){return new Q({type:"string",...I(Y)})}function a8(Q,Y){return new Q({type:"string",format:"email",check:"string_format",abort:!1,...I(Y)})}function k6(Q,Y){return new Q({type:"string",format:"guid",check:"string_format",abort:!1,...I(Y)})}function s8(Q,Y){return new Q({type:"string",format:"uuid",check:"string_format",abort:!1,...I(Y)})}function e8(Q,Y){return new Q({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...I(Y)})}function QW(Q,Y){return new Q({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...I(Y)})}function YW(Q,Y){return new Q({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...I(Y)})}function XW(Q,Y){return new Q({type:"string",format:"url",check:"string_format",abort:!1,...I(Y)})}function WW(Q,Y){return new Q({type:"string",format:"emoji",check:"string_format",abort:!1,...I(Y)})}function GW(Q,Y){return new Q({type:"string",format:"nanoid",check:"string_format",abort:!1,...I(Y)})}function zW(Q,Y){return new Q({type:"string",format:"cuid",check:"string_format",abort:!1,...I(Y)})}function JW(Q,Y){return new Q({type:"string",format:"cuid2",check:"string_format",abort:!1,...I(Y)})}function $W(Q,Y){return new Q({type:"string",format:"ulid",check:"string_format",abort:!1,...I(Y)})}function HW(Q,Y){return new Q({type:"string",format:"xid",check:"string_format",abort:!1,...I(Y)})}function AW(Q,Y){return new Q({type:"string",format:"ksuid",check:"string_format",abort:!1,...I(Y)})}function UW(Q,Y){return new Q({type:"string",format:"ipv4",check:"string_format",abort:!1,...I(Y)})}function KW(Q,Y){return new Q({type:"string",format:"ipv6",check:"string_format",abort:!1,...I(Y)})}function DW(Q,Y){return new Q({type:"string",format:"cidrv4",check:"string_format",abort:!1,...I(Y)})}function BW(Q,Y){return new Q({type:"string",format:"cidrv6",check:"string_format",abort:!1,...I(Y)})}function LW(Q,Y){return new Q({type:"string",format:"base64",check:"string_format",abort:!1,...I(Y)})}function FW(Q,Y){return new Q({type:"string",format:"base64url",check:"string_format",abort:!1,...I(Y)})}function qW(Q,Y){return new Q({type:"string",format:"e164",check:"string_format",abort:!1,...I(Y)})}function OW(Q,Y){return new Q({type:"string",format:"jwt",check:"string_format",abort:!1,...I(Y)})}function MW(Q,Y){return new Q({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...I(Y)})}function VW(Q,Y){return new Q({type:"string",format:"date",check:"string_format",...I(Y)})}function NW(Q,Y){return new Q({type:"string",format:"time",check:"string_format",precision:null,...I(Y)})}function ZW(Q,Y){return new Q({type:"string",format:"duration",check:"string_format",...I(Y)})}function wW(Q,Y){return new Q({type:"number",checks:[],...I(Y)})}function bW(Q,Y){return new Q({type:"number",check:"number_format",abort:!1,format:"safeint",...I(Y)})}function PW(Q,Y){return new Q({type:"boolean",...I(Y)})}function jW(Q,Y){return new Q({type:"null",...I(Y)})}function IW(Q){return new Q({type:"unknown"})}function EW(Q,Y){return new Q({type:"never",...I(Y)})}function YQ(Q,Y){return new I6({check:"less_than",...I(Y),value:Q,inclusive:!1})}function Y4(Q,Y){return new I6({check:"less_than",...I(Y),value:Q,inclusive:!0})}function XQ(Q,Y){return new E6({check:"greater_than",...I(Y),value:Q,inclusive:!1})}function X4(Q,Y){return new E6({check:"greater_than",...I(Y),value:Q,inclusive:!0})}function WQ(Q,Y){return new kX({check:"multiple_of",...I(Y),value:Q})}function GQ(Q,Y){return new _X({check:"max_length",...I(Y),maximum:Q})}function E1(Q,Y){return new gX({check:"min_length",...I(Y),minimum:Q})}function zQ(Q,Y){return new yX({check:"length_equals",...I(Y),length:Q})}function x6(Q,Y){return new uX({check:"string_format",format:"regex",...I(Y),pattern:Q})}function _6(Q){return new hX({check:"string_format",format:"lowercase",...I(Q)})}function g6(Q){return new fX({check:"string_format",format:"uppercase",...I(Q)})}function y6(Q,Y){return new lX({check:"string_format",format:"includes",...I(Y),includes:Q})}function u6(Q,Y){return new mX({check:"string_format",format:"starts_with",...I(Y),prefix:Q})}function h6(Q,Y){return new cX({check:"string_format",format:"ends_with",...I(Y),suffix:Q})}function F1(Q){return new pX({check:"overwrite",tx:Q})}function f6(Q){return F1((Y)=>Y.normalize(Q))}function l6(){return F1((Q)=>Q.trim())}function m6(){return F1((Q)=>Q.toLowerCase())}function c6(){return F1((Q)=>Q.toUpperCase())}function TW(Q,Y,X){return new Q({type:"array",element:Y,...I(X)})}function SW(Q,Y,X){let W=I(X);return W.abort??(W.abort=!0),new Q({type:"custom",check:"custom",fn:Y,...W})}function RW(Q,Y,X){return new Q({type:"custom",check:"custom",fn:Y,...I(X)})}function CW(Q){let Y=MH((X)=>{return X.addIssue=(W)=>{if(typeof W==="string")X.issues.push(I1(W,X.value,Y._zod.def));else{let G=W;if(G.fatal)G.continue=!1;G.code??(G.code="custom"),G.input??(G.input=X.value),G.inst??(G.inst=Y),G.continue??(G.continue=!Y._zod.def.abort),X.issues.push(I1(G))}},Q(X.value,X)});return Y}function MH(Q,Y){let X=new W0({check:"custom",...I(Y)});return X._zod.check=Q,X}function T1(Q){return!!Q._zod}function Y1(Q,Y){if(T1(Q))return a1(Q,Y);return Q.safeParse(Y)}function JQ(Q){if(!Q)return;let Y;if(T1(Q))Y=Q._zod?.def?.shape;else Y=Q.shape;if(!Y)return;if(typeof Y==="function")try{return Y()}catch{return}return Y}function vW(Q){if(T1(Q)){let z=Q._zod?.def;if(z){if(z.value!==void 0)return z.value;if(Array.isArray(z.values)&&z.values.length>0)return z.values[0]}}let X=Q._def;if(X){if(X.value!==void 0)return X.value;if(Array.isArray(X.values)&&X.values.length>0)return X.values[0]}let W=Q.value;if(W!==void 0)return W;return}var G4={};x9(G4,{time:()=>r6,duration:()=>n6,datetime:()=>p6,date:()=>i6,ZodISOTime:()=>_W,ZodISODuration:()=>gW,ZodISODateTime:()=>kW,ZodISODate:()=>xW});var kW=F("ZodISODateTime",(Q,Y)=>{D8.init(Q,Y),d.init(Q,Y)});function p6(Q){return MW(kW,Q)}var xW=F("ZodISODate",(Q,Y)=>{B8.init(Q,Y),d.init(Q,Y)});function i6(Q){return VW(xW,Q)}var _W=F("ZodISOTime",(Q,Y)=>{L8.init(Q,Y),d.init(Q,Y)});function r6(Q){return NW(_W,Q)}var gW=F("ZodISODuration",(Q,Y)=>{F8.init(Q,Y),d.init(Q,Y)});function n6(Q){return ZW(gW,Q)}var yW=(Q,Y)=>{n4.init(Q,Y),Q.name="ZodError",Object.defineProperties(Q,{format:{value:(X)=>d9(Q,X)},flatten:{value:(X)=>n9(Q,X)},addIssue:{value:(X)=>{Q.issues.push(X),Q.message=JSON.stringify(Q.issues,P1,2)}},addIssues:{value:(X)=>{Q.issues.push(...X),Q.message=JSON.stringify(Q.issues,P1,2)}},isEmpty:{get(){return Q.issues.length===0}}})},kV=F("ZodError",yW),N0=F("ZodError",yW,{Parent:Error});var uW=d4(N0),hW=o4(N0),fW=t1(N0),lW=s1(N0),mW=o9(N0),cW=t9(N0),pW=a9(N0),iW=s9(N0),rW=e9(N0),nW=QX(N0),dW=YX(N0),oW=XX(N0);var s=F("ZodType",(Q,Y)=>{return i.init(Q,Y),Q.def=Y,Q.type=Y.type,Object.defineProperty(Q,"_def",{value:Y}),Q.check=(...X)=>{return Q.clone(h.mergeDefs(Y,{checks:[...Y.checks??[],...X.map((W)=>typeof W==="function"?{_zod:{check:W,def:{check:"custom"},onattach:[]}}:W)]}))},Q.clone=(X,W)=>E0(Q,X,W),Q.brand=()=>Q,Q.register=(X,W)=>{return X.add(Q,W),Q},Q.parse=(X,W)=>uW(Q,X,W,{callee:Q.parse}),Q.safeParse=(X,W)=>fW(Q,X,W),Q.parseAsync=async(X,W)=>hW(Q,X,W,{callee:Q.parseAsync}),Q.safeParseAsync=async(X,W)=>lW(Q,X,W),Q.spa=Q.safeParseAsync,Q.encode=(X,W)=>mW(Q,X,W),Q.decode=(X,W)=>cW(Q,X,W),Q.encodeAsync=async(X,W)=>pW(Q,X,W),Q.decodeAsync=async(X,W)=>iW(Q,X,W),Q.safeEncode=(X,W)=>rW(Q,X,W),Q.safeDecode=(X,W)=>nW(Q,X,W),Q.safeEncodeAsync=async(X,W)=>dW(Q,X,W),Q.safeDecodeAsync=async(X,W)=>oW(Q,X,W),Q.refine=(X,W)=>Q.check(LA(X,W)),Q.superRefine=(X)=>Q.check(FA(X)),Q.overwrite=(X)=>Q.check(F1(X)),Q.optional=()=>a(Q),Q.nullable=()=>sW(Q),Q.nullish=()=>a(sW(Q)),Q.nonoptional=(X)=>HA(Q,X),Q.array=()=>_(Q),Q.or=(X)=>p([Q,X]),Q.and=(X)=>HQ(Q,X),Q.transform=(X)=>o6(Q,WG(X)),Q.default=(X)=>zA(Q,X),Q.prefault=(X)=>$A(Q,X),Q.catch=(X)=>UA(Q,X),Q.pipe=(X)=>o6(Q,X),Q.readonly=()=>BA(Q),Q.describe=(X)=>{let W=Q.clone();return Q4.add(W,{description:X}),W},Object.defineProperty(Q,"description",{get(){return Q4.get(Q)?.description},configurable:!0}),Q.meta=(...X)=>{if(X.length===0)return Q4.get(Q);let W=Q.clone();return Q4.add(W,X[0]),W},Q.isOptional=()=>Q.safeParse(void 0).success,Q.isNullable=()=>Q.safeParse(null).success,Q}),eW=F("_ZodString",(Q,Y)=>{QQ.init(Q,Y),s.init(Q,Y);let X=Q._zod.bag;Q.format=X.format??null,Q.minLength=X.minimum??null,Q.maxLength=X.maximum??null,Q.regex=(...W)=>Q.check(x6(...W)),Q.includes=(...W)=>Q.check(y6(...W)),Q.startsWith=(...W)=>Q.check(u6(...W)),Q.endsWith=(...W)=>Q.check(h6(...W)),Q.min=(...W)=>Q.check(E1(...W)),Q.max=(...W)=>Q.check(GQ(...W)),Q.length=(...W)=>Q.check(zQ(...W)),Q.nonempty=(...W)=>Q.check(E1(1,...W)),Q.lowercase=(W)=>Q.check(_6(W)),Q.uppercase=(W)=>Q.check(g6(W)),Q.trim=()=>Q.check(l6()),Q.normalize=(...W)=>Q.check(f6(...W)),Q.toLowerCase=()=>Q.check(m6()),Q.toUpperCase=()=>Q.check(c6())}),EH=F("ZodString",(Q,Y)=>{QQ.init(Q,Y),eW.init(Q,Y),Q.email=(X)=>Q.check(a8(TH,X)),Q.url=(X)=>Q.check(XW(SH,X)),Q.jwt=(X)=>Q.check(OW(pH,X)),Q.emoji=(X)=>Q.check(WW(RH,X)),Q.guid=(X)=>Q.check(k6(tW,X)),Q.uuid=(X)=>Q.check(s8($Q,X)),Q.uuidv4=(X)=>Q.check(e8($Q,X)),Q.uuidv6=(X)=>Q.check(QW($Q,X)),Q.uuidv7=(X)=>Q.check(YW($Q,X)),Q.nanoid=(X)=>Q.check(GW(CH,X)),Q.guid=(X)=>Q.check(k6(tW,X)),Q.cuid=(X)=>Q.check(zW(vH,X)),Q.cuid2=(X)=>Q.check(JW(kH,X)),Q.ulid=(X)=>Q.check($W(xH,X)),Q.base64=(X)=>Q.check(LW(lH,X)),Q.base64url=(X)=>Q.check(FW(mH,X)),Q.xid=(X)=>Q.check(HW(_H,X)),Q.ksuid=(X)=>Q.check(AW(gH,X)),Q.ipv4=(X)=>Q.check(UW(yH,X)),Q.ipv6=(X)=>Q.check(KW(uH,X)),Q.cidrv4=(X)=>Q.check(DW(hH,X)),Q.cidrv6=(X)=>Q.check(BW(fH,X)),Q.e164=(X)=>Q.check(qW(cH,X)),Q.datetime=(X)=>Q.check(p6(X)),Q.date=(X)=>Q.check(i6(X)),Q.time=(X)=>Q.check(r6(X)),Q.duration=(X)=>Q.check(n6(X))});function B(Q){return t8(EH,Q)}var d=F("ZodStringFormat",(Q,Y)=>{r.init(Q,Y),eW.init(Q,Y)}),TH=F("ZodEmail",(Q,Y)=>{W8.init(Q,Y),d.init(Q,Y)});var tW=F("ZodGUID",(Q,Y)=>{Y8.init(Q,Y),d.init(Q,Y)});var $Q=F("ZodUUID",(Q,Y)=>{X8.init(Q,Y),d.init(Q,Y)});var SH=F("ZodURL",(Q,Y)=>{G8.init(Q,Y),d.init(Q,Y)});var RH=F("ZodEmoji",(Q,Y)=>{z8.init(Q,Y),d.init(Q,Y)});var CH=F("ZodNanoID",(Q,Y)=>{J8.init(Q,Y),d.init(Q,Y)});var vH=F("ZodCUID",(Q,Y)=>{$8.init(Q,Y),d.init(Q,Y)});var kH=F("ZodCUID2",(Q,Y)=>{H8.init(Q,Y),d.init(Q,Y)});var xH=F("ZodULID",(Q,Y)=>{A8.init(Q,Y),d.init(Q,Y)});var _H=F("ZodXID",(Q,Y)=>{U8.init(Q,Y),d.init(Q,Y)});var gH=F("ZodKSUID",(Q,Y)=>{K8.init(Q,Y),d.init(Q,Y)});var yH=F("ZodIPv4",(Q,Y)=>{q8.init(Q,Y),d.init(Q,Y)});var uH=F("ZodIPv6",(Q,Y)=>{O8.init(Q,Y),d.init(Q,Y)});var hH=F("ZodCIDRv4",(Q,Y)=>{M8.init(Q,Y),d.init(Q,Y)});var fH=F("ZodCIDRv6",(Q,Y)=>{V8.init(Q,Y),d.init(Q,Y)});var lH=F("ZodBase64",(Q,Y)=>{Z8.init(Q,Y),d.init(Q,Y)});var mH=F("ZodBase64URL",(Q,Y)=>{w8.init(Q,Y),d.init(Q,Y)});var cH=F("ZodE164",(Q,Y)=>{b8.init(Q,Y),d.init(Q,Y)});var pH=F("ZodJWT",(Q,Y)=>{P8.init(Q,Y),d.init(Q,Y)});var QG=F("ZodNumber",(Q,Y)=>{R6.init(Q,Y),s.init(Q,Y),Q.gt=(W,G)=>Q.check(XQ(W,G)),Q.gte=(W,G)=>Q.check(X4(W,G)),Q.min=(W,G)=>Q.check(X4(W,G)),Q.lt=(W,G)=>Q.check(YQ(W,G)),Q.lte=(W,G)=>Q.check(Y4(W,G)),Q.max=(W,G)=>Q.check(Y4(W,G)),Q.int=(W)=>Q.check(aW(W)),Q.safe=(W)=>Q.check(aW(W)),Q.positive=(W)=>Q.check(XQ(0,W)),Q.nonnegative=(W)=>Q.check(X4(0,W)),Q.negative=(W)=>Q.check(YQ(0,W)),Q.nonpositive=(W)=>Q.check(Y4(0,W)),Q.multipleOf=(W,G)=>Q.check(WQ(W,G)),Q.step=(W,G)=>Q.check(WQ(W,G)),Q.finite=()=>Q;let X=Q._zod.bag;Q.minValue=Math.max(X.minimum??Number.NEGATIVE_INFINITY,X.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,Q.maxValue=Math.min(X.maximum??Number.POSITIVE_INFINITY,X.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,Q.isInt=(X.format??"").includes("int")||Number.isSafeInteger(X.multipleOf??0.5),Q.isFinite=!0,Q.format=X.format??null});function l(Q){return wW(QG,Q)}var iH=F("ZodNumberFormat",(Q,Y)=>{j8.init(Q,Y),QG.init(Q,Y)});function aW(Q){return bW(iH,Q)}var rH=F("ZodBoolean",(Q,Y)=>{I8.init(Q,Y),s.init(Q,Y)});function X0(Q){return PW(rH,Q)}var nH=F("ZodNull",(Q,Y)=>{E8.init(Q,Y),s.init(Q,Y)});function t6(Q){return jW(nH,Q)}var dH=F("ZodUnknown",(Q,Y)=>{T8.init(Q,Y),s.init(Q,Y)});function o(){return IW(dH)}var oH=F("ZodNever",(Q,Y)=>{S8.init(Q,Y),s.init(Q,Y)});function tH(Q){return EW(oH,Q)}var aH=F("ZodArray",(Q,Y)=>{R8.init(Q,Y),s.init(Q,Y),Q.element=Y.element,Q.min=(X,W)=>Q.check(E1(X,W)),Q.nonempty=(X)=>Q.check(E1(1,X)),Q.max=(X,W)=>Q.check(GQ(X,W)),Q.length=(X,W)=>Q.check(zQ(X,W)),Q.unwrap=()=>Q.element});function _(Q,Y){return TW(aH,Q,Y)}var YG=F("ZodObject",(Q,Y)=>{k8.init(Q,Y),s.init(Q,Y),h.defineLazy(Q,"shape",()=>{return Y.shape}),Q.keyof=()=>L0(Object.keys(Q._zod.def.shape)),Q.catchall=(X)=>Q.clone({...Q._zod.def,catchall:X}),Q.passthrough=()=>Q.clone({...Q._zod.def,catchall:o()}),Q.loose=()=>Q.clone({...Q._zod.def,catchall:o()}),Q.strict=()=>Q.clone({...Q._zod.def,catchall:tH()}),Q.strip=()=>Q.clone({...Q._zod.def,catchall:void 0}),Q.extend=(X)=>{return h.extend(Q,X)},Q.safeExtend=(X)=>{return h.safeExtend(Q,X)},Q.merge=(X)=>h.merge(Q,X),Q.pick=(X)=>h.pick(Q,X),Q.omit=(X)=>h.omit(Q,X),Q.partial=(...X)=>h.partial(GG,Q,X[0]),Q.required=(...X)=>h.required(zG,Q,X[0])});function w(Q,Y){let X={type:"object",shape:Q??{},...h.normalizeParams(Y)};return new YG(X)}function U0(Q,Y){return new YG({type:"object",shape:Q,catchall:o(),...h.normalizeParams(Y)})}var XG=F("ZodUnion",(Q,Y)=>{C6.init(Q,Y),s.init(Q,Y),Q.options=Y.options});function p(Q,Y){return new XG({type:"union",options:Q,...h.normalizeParams(Y)})}var sH=F("ZodDiscriminatedUnion",(Q,Y)=>{XG.init(Q,Y),x8.init(Q,Y)});function a6(Q,Y,X){return new sH({type:"union",options:Y,discriminator:Q,...h.normalizeParams(X)})}var eH=F("ZodIntersection",(Q,Y)=>{_8.init(Q,Y),s.init(Q,Y)});function HQ(Q,Y){return new eH({type:"intersection",left:Q,right:Y})}var QA=F("ZodRecord",(Q,Y)=>{g8.init(Q,Y),s.init(Q,Y),Q.keyType=Y.keyType,Q.valueType=Y.valueType});function t(Q,Y,X){return new QA({type:"record",keyType:Q,valueType:Y,...h.normalizeParams(X)})}var d6=F("ZodEnum",(Q,Y)=>{y8.init(Q,Y),s.init(Q,Y),Q.enum=Y.entries,Q.options=Object.values(Y.entries);let X=new Set(Object.keys(Y.entries));Q.extract=(W,G)=>{let z={};for(let J of W)if(X.has(J))z[J]=Y.entries[J];else throw Error(`Key ${J} not found in enum`);return new d6({...Y,checks:[],...h.normalizeParams(G),entries:z})},Q.exclude=(W,G)=>{let z={...Y.entries};for(let J of W)if(X.has(J))delete z[J];else throw Error(`Key ${J} not found in enum`);return new d6({...Y,checks:[],...h.normalizeParams(G),entries:z})}});function L0(Q,Y){let X=Array.isArray(Q)?Object.fromEntries(Q.map((W)=>[W,W])):Q;return new d6({type:"enum",entries:X,...h.normalizeParams(Y)})}var YA=F("ZodLiteral",(Q,Y)=>{u8.init(Q,Y),s.init(Q,Y),Q.values=new Set(Y.values),Object.defineProperty(Q,"value",{get(){if(Y.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return Y.values[0]}})});function b(Q,Y){return new YA({type:"literal",values:Array.isArray(Q)?Q:[Q],...h.normalizeParams(Y)})}var XA=F("ZodTransform",(Q,Y)=>{h8.init(Q,Y),s.init(Q,Y),Q._zod.parse=(X,W)=>{if(W.direction==="backward")throw new i1(Q.constructor.name);X.addIssue=(z)=>{if(typeof z==="string")X.issues.push(h.issue(z,X.value,Y));else{let J=z;if(J.fatal)J.continue=!1;J.code??(J.code="custom"),J.input??(J.input=X.value),J.inst??(J.inst=Q),X.issues.push(h.issue(J))}};let G=Y.transform(X.value,X);if(G instanceof Promise)return G.then((z)=>{return X.value=z,X});return X.value=G,X}});function WG(Q){return new XA({type:"transform",transform:Q})}var GG=F("ZodOptional",(Q,Y)=>{f8.init(Q,Y),s.init(Q,Y),Q.unwrap=()=>Q._zod.def.innerType});function a(Q){return new GG({type:"optional",innerType:Q})}var WA=F("ZodNullable",(Q,Y)=>{l8.init(Q,Y),s.init(Q,Y),Q.unwrap=()=>Q._zod.def.innerType});function sW(Q){return new WA({type:"nullable",innerType:Q})}var GA=F("ZodDefault",(Q,Y)=>{m8.init(Q,Y),s.init(Q,Y),Q.unwrap=()=>Q._zod.def.innerType,Q.removeDefault=Q.unwrap});function zA(Q,Y){return new GA({type:"default",innerType:Q,get defaultValue(){return typeof Y==="function"?Y():h.shallowClone(Y)}})}var JA=F("ZodPrefault",(Q,Y)=>{c8.init(Q,Y),s.init(Q,Y),Q.unwrap=()=>Q._zod.def.innerType});function $A(Q,Y){return new JA({type:"prefault",innerType:Q,get defaultValue(){return typeof Y==="function"?Y():h.shallowClone(Y)}})}var zG=F("ZodNonOptional",(Q,Y)=>{p8.init(Q,Y),s.init(Q,Y),Q.unwrap=()=>Q._zod.def.innerType});function HA(Q,Y){return new zG({type:"nonoptional",innerType:Q,...h.normalizeParams(Y)})}var AA=F("ZodCatch",(Q,Y)=>{i8.init(Q,Y),s.init(Q,Y),Q.unwrap=()=>Q._zod.def.innerType,Q.removeCatch=Q.unwrap});function UA(Q,Y){return new AA({type:"catch",innerType:Q,catchValue:typeof Y==="function"?Y:()=>Y})}var KA=F("ZodPipe",(Q,Y)=>{r8.init(Q,Y),s.init(Q,Y),Q.in=Y.in,Q.out=Y.out});function o6(Q,Y){return new KA({type:"pipe",in:Q,out:Y})}var DA=F("ZodReadonly",(Q,Y)=>{n8.init(Q,Y),s.init(Q,Y),Q.unwrap=()=>Q._zod.def.innerType});function BA(Q){return new DA({type:"readonly",innerType:Q})}var JG=F("ZodCustom",(Q,Y)=>{d8.init(Q,Y),s.init(Q,Y)});function $G(Q,Y){return SW(JG,Q??(()=>!0),Y)}function LA(Q,Y={}){return RW(JG,Q,Y)}function FA(Q){return CW(Q)}function s6(Q,Y){return o6(WG(Q),Y)}w0(v6());var e6="2025-11-25";var HG=[e6,"2025-06-18","2025-03-26","2024-11-05","2024-10-07"],X1="io.modelcontextprotocol/related-task",UQ="2.0",G0=$G((Q)=>Q!==null&&(typeof Q==="object"||typeof Q==="function")),AG=p([B(),l().int()]),UG=B(),TN=U0({ttl:p([l(),t6()]).optional(),pollInterval:l().optional()}),qA=w({ttl:l().optional()}),OA=w({taskId:B()}),QY=U0({progressToken:AG.optional(),[X1]:OA.optional()}),Z0=w({_meta:QY.optional()}),z4=Z0.extend({task:qA.optional()}),KG=(Q)=>z4.safeParse(Q).success,z0=w({method:B(),params:Z0.loose().optional()}),b0=w({_meta:QY.optional()}),P0=w({method:B(),params:b0.loose().optional()}),J0=U0({_meta:QY.optional()}),KQ=p([B(),l().int()]),DG=w({jsonrpc:b(UQ),id:KQ,...z0.shape}).strict(),YY=(Q)=>DG.safeParse(Q).success,BG=w({jsonrpc:b(UQ),...P0.shape}).strict(),LG=(Q)=>BG.safeParse(Q).success,XY=w({jsonrpc:b(UQ),id:KQ,result:J0}).strict(),J4=(Q)=>XY.safeParse(Q).success;var g;(function(Q){Q[Q.ConnectionClosed=-32000]="ConnectionClosed",Q[Q.RequestTimeout=-32001]="RequestTimeout",Q[Q.ParseError=-32700]="ParseError",Q[Q.InvalidRequest=-32600]="InvalidRequest",Q[Q.MethodNotFound=-32601]="MethodNotFound",Q[Q.InvalidParams=-32602]="InvalidParams",Q[Q.InternalError=-32603]="InternalError",Q[Q.UrlElicitationRequired=-32042]="UrlElicitationRequired"})(g||(g={}));var WY=w({jsonrpc:b(UQ),id:KQ.optional(),error:w({code:l().int(),message:B(),data:o().optional()})}).strict();var FG=(Q)=>WY.safeParse(Q).success;var SN=p([DG,BG,XY,WY]),RN=p([XY,WY]),DQ=J0.strict(),MA=b0.extend({requestId:KQ.optional(),reason:B().optional()}),BQ=P0.extend({method:b("notifications/cancelled"),params:MA}),VA=w({src:B(),mimeType:B().optional(),sizes:_(B()).optional(),theme:L0(["light","dark"]).optional()}),$4=w({icons:_(VA).optional()}),S1=w({name:B(),title:B().optional()}),qG=S1.extend({...S1.shape,...$4.shape,version:B(),websiteUrl:B().optional(),description:B().optional()}),NA=HQ(w({applyDefaults:X0().optional()}),t(B(),o())),ZA=s6((Q)=>{if(Q&&typeof Q==="object"&&!Array.isArray(Q)){if(Object.keys(Q).length===0)return{form:{}}}return Q},HQ(w({form:NA.optional(),url:G0.optional()}),t(B(),o()).optional())),wA=U0({list:G0.optional(),cancel:G0.optional(),requests:U0({sampling:U0({createMessage:G0.optional()}).optional(),elicitation:U0({create:G0.optional()}).optional()}).optional()}),bA=U0({list:G0.optional(),cancel:G0.optional(),requests:U0({tools:U0({call:G0.optional()}).optional()}).optional()}),PA=w({experimental:t(B(),G0).optional(),sampling:w({context:G0.optional(),tools:G0.optional()}).optional(),elicitation:ZA.optional(),roots:w({listChanged:X0().optional()}).optional(),tasks:wA.optional()}),jA=Z0.extend({protocolVersion:B(),capabilities:PA,clientInfo:qG}),GY=z0.extend({method:b("initialize"),params:jA});var IA=w({experimental:t(B(),G0).optional(),logging:G0.optional(),completions:G0.optional(),prompts:w({listChanged:X0().optional()}).optional(),resources:w({subscribe:X0().optional(),listChanged:X0().optional()}).optional(),tools:w({listChanged:X0().optional()}).optional(),tasks:bA.optional()}),EA=J0.extend({protocolVersion:B(),capabilities:IA,serverInfo:qG,instructions:B().optional()}),zY=P0.extend({method:b("notifications/initialized"),params:b0.optional()});var LQ=z0.extend({method:b("ping"),params:Z0.optional()}),TA=w({progress:l(),total:a(l()),message:a(B())}),SA=w({...b0.shape,...TA.shape,progressToken:AG}),FQ=P0.extend({method:b("notifications/progress"),params:SA}),RA=Z0.extend({cursor:UG.optional()}),H4=z0.extend({params:RA.optional()}),A4=J0.extend({nextCursor:UG.optional()}),CA=L0(["working","input_required","completed","failed","cancelled"]),U4=w({taskId:B(),status:CA,ttl:p([l(),t6()]),createdAt:B(),lastUpdatedAt:B(),pollInterval:a(l()),statusMessage:a(B())}),R1=J0.extend({task:U4}),vA=b0.merge(U4),K4=P0.extend({method:b("notifications/tasks/status"),params:vA}),qQ=z0.extend({method:b("tasks/get"),params:Z0.extend({taskId:B()})}),OQ=J0.merge(U4),MQ=z0.extend({method:b("tasks/result"),params:Z0.extend({taskId:B()})}),CN=J0.loose(),VQ=H4.extend({method:b("tasks/list")}),NQ=A4.extend({tasks:_(U4)}),ZQ=z0.extend({method:b("tasks/cancel"),params:Z0.extend({taskId:B()})}),OG=J0.merge(U4),MG=w({uri:B(),mimeType:a(B()),_meta:t(B(),o()).optional()}),VG=MG.extend({text:B()}),JY=B().refine((Q)=>{try{return atob(Q),!0}catch{return!1}},{message:"Invalid Base64 string"}),NG=MG.extend({blob:JY}),D4=L0(["user","assistant"]),C1=w({audience:_(D4).optional(),priority:l().min(0).max(1).optional(),lastModified:G4.datetime({offset:!0}).optional()}),ZG=w({...S1.shape,...$4.shape,uri:B(),description:a(B()),mimeType:a(B()),annotations:C1.optional(),_meta:a(U0({}))}),kA=w({...S1.shape,...$4.shape,uriTemplate:B(),description:a(B()),mimeType:a(B()),annotations:C1.optional(),_meta:a(U0({}))}),$Y=H4.extend({method:b("resources/list")}),xA=A4.extend({resources:_(ZG)}),_A=H4.extend({method:b("resources/templates/list")}),gA=A4.extend({resourceTemplates:_(kA)}),HY=Z0.extend({uri:B()}),yA=HY,AY=z0.extend({method:b("resources/read"),params:yA}),uA=J0.extend({contents:_(p([VG,NG]))}),hA=P0.extend({method:b("notifications/resources/list_changed"),params:b0.optional()}),fA=HY,lA=z0.extend({method:b("resources/subscribe"),params:fA}),mA=HY,cA=z0.extend({method:b("resources/unsubscribe"),params:mA}),pA=b0.extend({uri:B()}),iA=P0.extend({method:b("notifications/resources/updated"),params:pA}),rA=w({name:B(),description:a(B()),required:a(X0())}),nA=w({...S1.shape,...$4.shape,description:a(B()),arguments:a(_(rA)),_meta:a(U0({}))}),dA=H4.extend({method:b("prompts/list")}),oA=A4.extend({prompts:_(nA)}),tA=Z0.extend({name:B(),arguments:t(B(),B()).optional()}),aA=z0.extend({method:b("prompts/get"),params:tA}),UY=w({type:b("text"),text:B(),annotations:C1.optional(),_meta:t(B(),o()).optional()}),KY=w({type:b("image"),data:JY,mimeType:B(),annotations:C1.optional(),_meta:t(B(),o()).optional()}),DY=w({type:b("audio"),data:JY,mimeType:B(),annotations:C1.optional(),_meta:t(B(),o()).optional()}),sA=w({type:b("tool_use"),name:B(),id:B(),input:t(B(),o()),_meta:t(B(),o()).optional()}),eA=w({type:b("resource"),resource:p([VG,NG]),annotations:C1.optional(),_meta:t(B(),o()).optional()}),QU=ZG.extend({type:b("resource_link")}),BY=p([UY,KY,DY,QU,eA]),YU=w({role:D4,content:BY}),XU=J0.extend({description:B().optional(),messages:_(YU)}),WU=P0.extend({method:b("notifications/prompts/list_changed"),params:b0.optional()}),GU=w({title:B().optional(),readOnlyHint:X0().optional(),destructiveHint:X0().optional(),idempotentHint:X0().optional(),openWorldHint:X0().optional()}),zU=w({taskSupport:L0(["required","optional","forbidden"]).optional()}),wG=w({...S1.shape,...$4.shape,description:B().optional(),inputSchema:w({type:b("object"),properties:t(B(),G0).optional(),required:_(B()).optional()}).catchall(o()),outputSchema:w({type:b("object"),properties:t(B(),G0).optional(),required:_(B()).optional()}).catchall(o()).optional(),annotations:GU.optional(),execution:zU.optional(),_meta:t(B(),o()).optional()}),LY=H4.extend({method:b("tools/list")}),JU=A4.extend({tools:_(wG)}),wQ=J0.extend({content:_(BY).default([]),structuredContent:t(B(),o()).optional(),isError:X0().optional()}),vN=wQ.or(J0.extend({toolResult:o()})),$U=z4.extend({name:B(),arguments:t(B(),o()).optional()}),B4=z0.extend({method:b("tools/call"),params:$U}),HU=P0.extend({method:b("notifications/tools/list_changed"),params:b0.optional()}),kN=w({autoRefresh:X0().default(!0),debounceMs:l().int().nonnegative().default(300)}),L4=L0(["debug","info","notice","warning","error","critical","alert","emergency"]),AU=Z0.extend({level:L4}),FY=z0.extend({method:b("logging/setLevel"),params:AU}),UU=b0.extend({level:L4,logger:B().optional(),data:o()}),KU=P0.extend({method:b("notifications/message"),params:UU}),DU=w({name:B().optional()}),BU=w({hints:_(DU).optional(),costPriority:l().min(0).max(1).optional(),speedPriority:l().min(0).max(1).optional(),intelligencePriority:l().min(0).max(1).optional()}),LU=w({mode:L0(["auto","required","none"]).optional()}),FU=w({type:b("tool_result"),toolUseId:B().describe("The unique identifier for the corresponding tool call."),content:_(BY).default([]),structuredContent:w({}).loose().optional(),isError:X0().optional(),_meta:t(B(),o()).optional()}),qU=a6("type",[UY,KY,DY]),AQ=a6("type",[UY,KY,DY,sA,FU]),OU=w({role:D4,content:p([AQ,_(AQ)]),_meta:t(B(),o()).optional()}),MU=z4.extend({messages:_(OU),modelPreferences:BU.optional(),systemPrompt:B().optional(),includeContext:L0(["none","thisServer","allServers"]).optional(),temperature:l().optional(),maxTokens:l().int(),stopSequences:_(B()).optional(),metadata:G0.optional(),tools:_(wG).optional(),toolChoice:LU.optional()}),VU=z0.extend({method:b("sampling/createMessage"),params:MU}),qY=J0.extend({model:B(),stopReason:a(L0(["endTurn","stopSequence","maxTokens"]).or(B())),role:D4,content:qU}),OY=J0.extend({model:B(),stopReason:a(L0(["endTurn","stopSequence","maxTokens","toolUse"]).or(B())),role:D4,content:p([AQ,_(AQ)])}),NU=w({type:b("boolean"),title:B().optional(),description:B().optional(),default:X0().optional()}),ZU=w({type:b("string"),title:B().optional(),description:B().optional(),minLength:l().optional(),maxLength:l().optional(),format:L0(["email","uri","date","date-time"]).optional(),default:B().optional()}),wU=w({type:L0(["number","integer"]),title:B().optional(),description:B().optional(),minimum:l().optional(),maximum:l().optional(),default:l().optional()}),bU=w({type:b("string"),title:B().optional(),description:B().optional(),enum:_(B()),default:B().optional()}),PU=w({type:b("string"),title:B().optional(),description:B().optional(),oneOf:_(w({const:B(),title:B()})),default:B().optional()}),jU=w({type:b("string"),title:B().optional(),description:B().optional(),enum:_(B()),enumNames:_(B()).optional(),default:B().optional()}),IU=p([bU,PU]),EU=w({type:b("array"),title:B().optional(),description:B().optional(),minItems:l().optional(),maxItems:l().optional(),items:w({type:b("string"),enum:_(B())}),default:_(B()).optional()}),TU=w({type:b("array"),title:B().optional(),description:B().optional(),minItems:l().optional(),maxItems:l().optional(),items:w({anyOf:_(w({const:B(),title:B()}))}),default:_(B()).optional()}),SU=p([EU,TU]),RU=p([jU,IU,SU]),CU=p([RU,NU,ZU,wU]),vU=z4.extend({mode:b("form").optional(),message:B(),requestedSchema:w({type:b("object"),properties:t(B(),CU),required:_(B()).optional()})}),kU=z4.extend({mode:b("url"),message:B(),elicitationId:B(),url:B().url()}),xU=p([vU,kU]),_U=z0.extend({method:b("elicitation/create"),params:xU}),gU=b0.extend({elicitationId:B()}),yU=P0.extend({method:b("notifications/elicitation/complete"),params:gU}),bQ=J0.extend({action:L0(["accept","decline","cancel"]),content:s6((Q)=>Q===null?void 0:Q,t(B(),p([B(),l(),X0(),_(B())])).optional())}),uU=w({type:b("ref/resource"),uri:B()});var hU=w({type:b("ref/prompt"),name:B()}),fU=Z0.extend({ref:p([hU,uU]),argument:w({name:B(),value:B()}),context:w({arguments:t(B(),B()).optional()}).optional()}),lU=z0.extend({method:b("completion/complete"),params:fU});var mU=J0.extend({completion:U0({values:_(B()).max(100),total:a(l().int()),hasMore:a(X0())})}),cU=w({uri:B().startsWith("file://"),name:B().optional(),_meta:t(B(),o()).optional()}),pU=z0.extend({method:b("roots/list"),params:Z0.optional()}),MY=J0.extend({roots:_(cU)}),iU=P0.extend({method:b("notifications/roots/list_changed"),params:b0.optional()}),xN=p([LQ,GY,lU,FY,aA,dA,$Y,_A,AY,lA,cA,B4,LY,qQ,MQ,VQ,ZQ]),_N=p([BQ,FQ,zY,iU,K4]),gN=p([DQ,qY,OY,bQ,MY,OQ,NQ,R1]),yN=p([LQ,VU,_U,pU,qQ,MQ,VQ,ZQ]),uN=p([BQ,FQ,KU,iA,hA,HU,WU,K4,yU]),hN=p([DQ,EA,mU,XU,oA,xA,gA,uA,wQ,JU,OQ,NQ,R1]);class v extends Error{constructor(Q,Y,X){super(`MCP error ${Q}: ${Y}`);this.code=Q,this.data=X,this.name="McpError"}static fromError(Q,Y,X){if(Q===g.UrlElicitationRequired&&X){let W=X;if(W.elicitations)return new bG(W.elicitations,Y)}return new v(Q,Y,X)}}class bG extends v{constructor(Q,Y=`URL elicitation${Q.length>1?"s":""} required`){super(g.UrlElicitationRequired,Y,{elicitations:Q})}get elicitations(){return this.data?.elicitations??[]}}function W1(Q){return Q==="completed"||Q==="failed"||Q==="cancelled"}var rU=Symbol("Let zodToJsonSchema decide on which parser to use");var MZ=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function VY(Q){let X=JQ(Q)?.method;if(!X)throw Error("Schema is missing a method literal");let W=vW(X);if(typeof W!=="string")throw Error("Schema method literal must be a string");return W}function NY(Q,Y){let X=Y1(Q,Y);if(!X.success)throw X.error;return X.data}var sU=60000;class ZY{constructor(Q){if(this._options=Q,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(BQ,(Y)=>{this._oncancel(Y)}),this.setNotificationHandler(FQ,(Y)=>{this._onprogress(Y)}),this.setRequestHandler(LQ,(Y)=>({})),this._taskStore=Q?.taskStore,this._taskMessageQueue=Q?.taskMessageQueue,this._taskStore)this.setRequestHandler(qQ,async(Y,X)=>{let W=await this._taskStore.getTask(Y.params.taskId,X.sessionId);if(!W)throw new v(g.InvalidParams,"Failed to retrieve task: Task not found");return{...W}}),this.setRequestHandler(MQ,async(Y,X)=>{let W=async()=>{let G=Y.params.taskId;if(this._taskMessageQueue){let J;while(J=await this._taskMessageQueue.dequeue(G,X.sessionId)){if(J.type==="response"||J.type==="error"){let $=J.message,H=$.id,A=this._requestResolvers.get(H);if(A)if(this._requestResolvers.delete(H),J.type==="response")A($);else{let U=$,K=new v(U.error.code,U.error.message,U.error.data);A(K)}else{let U=J.type==="response"?"Response":"Error";this._onerror(Error(`${U} handler missing for request ${H}`))}continue}await this._transport?.send(J.message,{relatedRequestId:X.requestId})}}let z=await this._taskStore.getTask(G,X.sessionId);if(!z)throw new v(g.InvalidParams,`Task not found: ${G}`);if(!W1(z.status))return await this._waitForTaskUpdate(G,X.signal),await W();if(W1(z.status)){let J=await this._taskStore.getTaskResult(G,X.sessionId);return this._clearTaskQueue(G),{...J,_meta:{...J._meta,[X1]:{taskId:G}}}}return await W()};return await W()}),this.setRequestHandler(VQ,async(Y,X)=>{try{let{tasks:W,nextCursor:G}=await this._taskStore.listTasks(Y.params?.cursor,X.sessionId);return{tasks:W,nextCursor:G,_meta:{}}}catch(W){throw new v(g.InvalidParams,`Failed to list tasks: ${W instanceof Error?W.message:String(W)}`)}}),this.setRequestHandler(ZQ,async(Y,X)=>{try{let W=await this._taskStore.getTask(Y.params.taskId,X.sessionId);if(!W)throw new v(g.InvalidParams,`Task not found: ${Y.params.taskId}`);if(W1(W.status))throw new v(g.InvalidParams,`Cannot cancel task in terminal status: ${W.status}`);await this._taskStore.updateTaskStatus(Y.params.taskId,"cancelled","Client cancelled task execution.",X.sessionId),this._clearTaskQueue(Y.params.taskId);let G=await this._taskStore.getTask(Y.params.taskId,X.sessionId);if(!G)throw new v(g.InvalidParams,`Task not found after cancellation: ${Y.params.taskId}`);return{_meta:{},...G}}catch(W){if(W instanceof v)throw W;throw new v(g.InvalidRequest,`Failed to cancel task: ${W instanceof Error?W.message:String(W)}`)}})}async _oncancel(Q){if(!Q.params.requestId)return;this._requestHandlerAbortControllers.get(Q.params.requestId)?.abort(Q.params.reason)}_setupTimeout(Q,Y,X,W,G=!1){this._timeoutInfo.set(Q,{timeoutId:setTimeout(W,Y),startTime:Date.now(),timeout:Y,maxTotalTimeout:X,resetTimeoutOnProgress:G,onTimeout:W})}_resetTimeout(Q){let Y=this._timeoutInfo.get(Q);if(!Y)return!1;let X=Date.now()-Y.startTime;if(Y.maxTotalTimeout&&X>=Y.maxTotalTimeout)throw this._timeoutInfo.delete(Q),v.fromError(g.RequestTimeout,"Maximum total timeout exceeded",{maxTotalTimeout:Y.maxTotalTimeout,totalElapsed:X});return clearTimeout(Y.timeoutId),Y.timeoutId=setTimeout(Y.onTimeout,Y.timeout),!0}_cleanupTimeout(Q){let Y=this._timeoutInfo.get(Q);if(Y)clearTimeout(Y.timeoutId),this._timeoutInfo.delete(Q)}async connect(Q){this._transport=Q;let Y=this.transport?.onclose;this._transport.onclose=()=>{Y?.(),this._onclose()};let X=this.transport?.onerror;this._transport.onerror=(G)=>{X?.(G),this._onerror(G)};let W=this._transport?.onmessage;this._transport.onmessage=(G,z)=>{if(W?.(G,z),J4(G)||FG(G))this._onresponse(G);else if(YY(G))this._onrequest(G,z);else if(LG(G))this._onnotification(G);else this._onerror(Error(`Unknown message type: ${JSON.stringify(G)}`))},await this._transport.start()}_onclose(){let Q=this._responseHandlers;this._responseHandlers=new Map,this._progressHandlers.clear(),this._taskProgressTokens.clear(),this._pendingDebouncedNotifications.clear();let Y=v.fromError(g.ConnectionClosed,"Connection closed");this._transport=void 0,this.onclose?.();for(let X of Q.values())X(Y)}_onerror(Q){this.onerror?.(Q)}_onnotification(Q){let Y=this._notificationHandlers.get(Q.method)??this.fallbackNotificationHandler;if(Y===void 0)return;Promise.resolve().then(()=>Y(Q)).catch((X)=>this._onerror(Error(`Uncaught error in notification handler: ${X}`)))}_onrequest(Q,Y){let X=this._requestHandlers.get(Q.method)??this.fallbackRequestHandler,W=this._transport,G=Q.params?._meta?.[X1]?.taskId;if(X===void 0){let A={jsonrpc:"2.0",id:Q.id,error:{code:g.MethodNotFound,message:"Method not found"}};if(G&&this._taskMessageQueue)this._enqueueTaskMessage(G,{type:"error",message:A,timestamp:Date.now()},W?.sessionId).catch((U)=>this._onerror(Error(`Failed to enqueue error response: ${U}`)));else W?.send(A).catch((U)=>this._onerror(Error(`Failed to send an error response: ${U}`)));return}let z=new AbortController;this._requestHandlerAbortControllers.set(Q.id,z);let J=KG(Q.params)?Q.params.task:void 0,$=this._taskStore?this.requestTaskStore(Q,W?.sessionId):void 0,H={signal:z.signal,sessionId:W?.sessionId,_meta:Q.params?._meta,sendNotification:async(A)=>{let U={relatedRequestId:Q.id};if(G)U.relatedTask={taskId:G};await this.notification(A,U)},sendRequest:async(A,U,K)=>{let D={...K,relatedRequestId:Q.id};if(G&&!D.relatedTask)D.relatedTask={taskId:G};let L=D.relatedTask?.taskId??G;if(L&&$)await $.updateTaskStatus(L,"input_required");return await this.request(A,U,D)},authInfo:Y?.authInfo,requestId:Q.id,requestInfo:Y?.requestInfo,taskId:G,taskStore:$,taskRequestedTtl:J?.ttl,closeSSEStream:Y?.closeSSEStream,closeStandaloneSSEStream:Y?.closeStandaloneSSEStream};Promise.resolve().then(()=>{if(J)this.assertTaskHandlerCapability(Q.method)}).then(()=>X(Q,H)).then(async(A)=>{if(z.signal.aborted)return;let U={result:A,jsonrpc:"2.0",id:Q.id};if(G&&this._taskMessageQueue)await this._enqueueTaskMessage(G,{type:"response",message:U,timestamp:Date.now()},W?.sessionId);else await W?.send(U)},async(A)=>{if(z.signal.aborted)return;let U={jsonrpc:"2.0",id:Q.id,error:{code:Number.isSafeInteger(A.code)?A.code:g.InternalError,message:A.message??"Internal error",...A.data!==void 0&&{data:A.data}}};if(G&&this._taskMessageQueue)await this._enqueueTaskMessage(G,{type:"error",message:U,timestamp:Date.now()},W?.sessionId);else await W?.send(U)}).catch((A)=>this._onerror(Error(`Failed to send response: ${A}`))).finally(()=>{this._requestHandlerAbortControllers.delete(Q.id)})}_onprogress(Q){let{progressToken:Y,...X}=Q.params,W=Number(Y),G=this._progressHandlers.get(W);if(!G){this._onerror(Error(`Received a progress notification for an unknown token: ${JSON.stringify(Q)}`));return}let z=this._responseHandlers.get(W),J=this._timeoutInfo.get(W);if(J&&z&&J.resetTimeoutOnProgress)try{this._resetTimeout(W)}catch($){this._responseHandlers.delete(W),this._progressHandlers.delete(W),this._cleanupTimeout(W),z($);return}G(X)}_onresponse(Q){let Y=Number(Q.id),X=this._requestResolvers.get(Y);if(X){if(this._requestResolvers.delete(Y),J4(Q))X(Q);else{let z=new v(Q.error.code,Q.error.message,Q.error.data);X(z)}return}let W=this._responseHandlers.get(Y);if(W===void 0){this._onerror(Error(`Received a response for an unknown message ID: ${JSON.stringify(Q)}`));return}this._responseHandlers.delete(Y),this._cleanupTimeout(Y);let G=!1;if(J4(Q)&&Q.result&&typeof Q.result==="object"){let z=Q.result;if(z.task&&typeof z.task==="object"){let J=z.task;if(typeof J.taskId==="string")G=!0,this._taskProgressTokens.set(J.taskId,Y)}}if(!G)this._progressHandlers.delete(Y);if(J4(Q))W(Q);else{let z=v.fromError(Q.error.code,Q.error.message,Q.error.data);W(z)}}get transport(){return this._transport}async close(){await this._transport?.close()}async*requestStream(Q,Y,X){let{task:W}=X??{};if(!W){try{yield{type:"result",result:await this.request(Q,Y,X)}}catch(z){yield{type:"error",error:z instanceof v?z:new v(g.InternalError,String(z))}}return}let G;try{let z=await this.request(Q,R1,X);if(z.task)G=z.task.taskId,yield{type:"taskCreated",task:z.task};else throw new v(g.InternalError,"Task creation did not return a task");while(!0){let J=await this.getTask({taskId:G},X);if(yield{type:"taskStatus",task:J},W1(J.status)){if(J.status==="completed")yield{type:"result",result:await this.getTaskResult({taskId:G},Y,X)};else if(J.status==="failed")yield{type:"error",error:new v(g.InternalError,`Task ${G} failed`)};else if(J.status==="cancelled")yield{type:"error",error:new v(g.InternalError,`Task ${G} was cancelled`)};return}if(J.status==="input_required"){yield{type:"result",result:await this.getTaskResult({taskId:G},Y,X)};return}let $=J.pollInterval??this._options?.defaultTaskPollInterval??1000;await new Promise((H)=>setTimeout(H,$)),X?.signal?.throwIfAborted()}}catch(z){yield{type:"error",error:z instanceof v?z:new v(g.InternalError,String(z))}}}request(Q,Y,X){let{relatedRequestId:W,resumptionToken:G,onresumptiontoken:z,task:J,relatedTask:$}=X??{};return new Promise((H,A)=>{let U=(M)=>{A(M)};if(!this._transport){U(Error("Not connected"));return}if(this._options?.enforceStrictCapabilities===!0)try{if(this.assertCapabilityForMethod(Q.method),J)this.assertTaskCapability(Q.method)}catch(M){U(M);return}X?.signal?.throwIfAborted();let K=this._requestMessageId++,D={...Q,jsonrpc:"2.0",id:K};if(X?.onprogress)this._progressHandlers.set(K,X.onprogress),D.params={...Q.params,_meta:{...Q.params?._meta||{},progressToken:K}};if(J)D.params={...D.params,task:J};if($)D.params={...D.params,_meta:{...D.params?._meta||{},[X1]:$}};let L=(M)=>{this._responseHandlers.delete(K),this._progressHandlers.delete(K),this._cleanupTimeout(K),this._transport?.send({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:K,reason:String(M)}},{relatedRequestId:W,resumptionToken:G,onresumptiontoken:z}).catch((E)=>this._onerror(Error(`Failed to send cancellation: ${E}`)));let S=M instanceof v?M:new v(g.RequestTimeout,String(M));A(S)};this._responseHandlers.set(K,(M)=>{if(X?.signal?.aborted)return;if(M instanceof Error)return A(M);try{let S=Y1(Y,M.result);if(!S.success)A(S.error);else H(S.data)}catch(S){A(S)}}),X?.signal?.addEventListener("abort",()=>{L(X?.signal?.reason)});let q=X?.timeout??sU,O=()=>L(v.fromError(g.RequestTimeout,"Request timed out",{timeout:q}));this._setupTimeout(K,q,X?.maxTotalTimeout,O,X?.resetTimeoutOnProgress??!1);let V=$?.taskId;if(V){let M=(S)=>{let E=this._responseHandlers.get(K);if(E)E(S);else this._onerror(Error(`Response handler missing for side-channeled request ${K}`))};this._requestResolvers.set(K,M),this._enqueueTaskMessage(V,{type:"request",message:D,timestamp:Date.now()}).catch((S)=>{this._cleanupTimeout(K),A(S)})}else this._transport.send(D,{relatedRequestId:W,resumptionToken:G,onresumptiontoken:z}).catch((M)=>{this._cleanupTimeout(K),A(M)})})}async getTask(Q,Y){return this.request({method:"tasks/get",params:Q},OQ,Y)}async getTaskResult(Q,Y,X){return this.request({method:"tasks/result",params:Q},Y,X)}async listTasks(Q,Y){return this.request({method:"tasks/list",params:Q},NQ,Y)}async cancelTask(Q,Y){return this.request({method:"tasks/cancel",params:Q},OG,Y)}async notification(Q,Y){if(!this._transport)throw Error("Not connected");this.assertNotificationCapability(Q.method);let X=Y?.relatedTask?.taskId;if(X){let J={...Q,jsonrpc:"2.0",params:{...Q.params,_meta:{...Q.params?._meta||{},[X1]:Y.relatedTask}}};await this._enqueueTaskMessage(X,{type:"notification",message:J,timestamp:Date.now()});return}if((this._options?.debouncedNotificationMethods??[]).includes(Q.method)&&!Q.params&&!Y?.relatedRequestId&&!Y?.relatedTask){if(this._pendingDebouncedNotifications.has(Q.method))return;this._pendingDebouncedNotifications.add(Q.method),Promise.resolve().then(()=>{if(this._pendingDebouncedNotifications.delete(Q.method),!this._transport)return;let J={...Q,jsonrpc:"2.0"};if(Y?.relatedTask)J={...J,params:{...J.params,_meta:{...J.params?._meta||{},[X1]:Y.relatedTask}}};this._transport?.send(J,Y).catch(($)=>this._onerror($))});return}let z={...Q,jsonrpc:"2.0"};if(Y?.relatedTask)z={...z,params:{...z.params,_meta:{...z.params?._meta||{},[X1]:Y.relatedTask}}};await this._transport.send(z,Y)}setRequestHandler(Q,Y){let X=VY(Q);this.assertRequestHandlerCapability(X),this._requestHandlers.set(X,(W,G)=>{let z=NY(Q,W);return Promise.resolve(Y(z,G))})}removeRequestHandler(Q){this._requestHandlers.delete(Q)}assertCanSetRequestHandler(Q){if(this._requestHandlers.has(Q))throw Error(`A request handler for ${Q} already exists, which would be overridden`)}setNotificationHandler(Q,Y){let X=VY(Q);this._notificationHandlers.set(X,(W)=>{let G=NY(Q,W);return Promise.resolve(Y(G))})}removeNotificationHandler(Q){this._notificationHandlers.delete(Q)}_cleanupTaskProgressHandler(Q){let Y=this._taskProgressTokens.get(Q);if(Y!==void 0)this._progressHandlers.delete(Y),this._taskProgressTokens.delete(Q)}async _enqueueTaskMessage(Q,Y,X){if(!this._taskStore||!this._taskMessageQueue)throw Error("Cannot enqueue task message: taskStore and taskMessageQueue are not configured");let W=this._options?.maxTaskQueueSize;await this._taskMessageQueue.enqueue(Q,Y,X,W)}async _clearTaskQueue(Q,Y){if(this._taskMessageQueue){let X=await this._taskMessageQueue.dequeueAll(Q,Y);for(let W of X)if(W.type==="request"&&YY(W.message)){let G=W.message.id,z=this._requestResolvers.get(G);if(z)z(new v(g.InternalError,"Task cancelled or completed")),this._requestResolvers.delete(G);else this._onerror(Error(`Resolver missing for request ${G} during task ${Q} cleanup`))}}}async _waitForTaskUpdate(Q,Y){let X=this._options?.defaultTaskPollInterval??1000;try{let W=await this._taskStore?.getTask(Q);if(W?.pollInterval)X=W.pollInterval}catch{}return new Promise((W,G)=>{if(Y.aborted){G(new v(g.InvalidRequest,"Request cancelled"));return}let z=setTimeout(W,X);Y.addEventListener("abort",()=>{clearTimeout(z),G(new v(g.InvalidRequest,"Request cancelled"))},{once:!0})})}requestTaskStore(Q,Y){let X=this._taskStore;if(!X)throw Error("No task store configured");return{createTask:async(W)=>{if(!Q)throw Error("No request provided");return await X.createTask(W,Q.id,{method:Q.method,params:Q.params},Y)},getTask:async(W)=>{let G=await X.getTask(W,Y);if(!G)throw new v(g.InvalidParams,"Failed to retrieve task: Task not found");return G},storeTaskResult:async(W,G,z)=>{await X.storeTaskResult(W,G,z,Y);let J=await X.getTask(W,Y);if(J){let $=K4.parse({method:"notifications/tasks/status",params:J});if(await this.notification($),W1(J.status))this._cleanupTaskProgressHandler(W)}},getTaskResult:(W)=>{return X.getTaskResult(W,Y)},updateTaskStatus:async(W,G,z)=>{let J=await X.getTask(W,Y);if(!J)throw new v(g.InvalidParams,`Task "${W}" not found - it may have been cleaned up`);if(W1(J.status))throw new v(g.InvalidParams,`Cannot update task "${W}" from terminal status "${J.status}" to "${G}". Terminal states (completed, failed, cancelled) cannot transition to other states.`);await X.updateTaskStatus(W,G,z,Y);let $=await X.getTask(W,Y);if($){let H=K4.parse({method:"notifications/tasks/status",params:$});if(await this.notification(H),W1($.status))this._cleanupTaskProgressHandler(W)}},listTasks:(W)=>{return X.listTasks(W,Y)}}}}function PG(Q){return Q!==null&&typeof Q==="object"&&!Array.isArray(Q)}function jG(Q,Y){let X={...Q};for(let W in Y){let G=W,z=Y[G];if(z===void 0)continue;let J=X[G];if(PG(J)&&PG(z))X[G]={...J,...z};else X[G]=z}return X}var X5=k9(F9(),1),W5=k9(Y5(),1);function $M(){let Q=new X5.default({strict:!1,validateFormats:!0,validateSchema:!1,allErrors:!0});return W5.default(Q),Q}class j9{constructor(Q){this._ajv=Q??$M()}getValidator(Q){let Y="$id"in Q&&typeof Q.$id==="string"?this._ajv.getSchema(Q.$id)??this._ajv.compile(Q):this._ajv.compile(Q);return(X)=>{if(Y(X))return{valid:!0,data:X,errorMessage:void 0};else return{valid:!1,data:void 0,errorMessage:this._ajv.errorsText(Y.errors)}}}}class I9{constructor(Q){this._server=Q}requestStream(Q,Y,X){return this._server.requestStream(Q,Y,X)}async getTask(Q,Y){return this._server.getTask({taskId:Q},Y)}async getTaskResult(Q,Y,X){return this._server.getTaskResult({taskId:Q},Y,X)}async listTasks(Q,Y){return this._server.listTasks(Q?{cursor:Q}:void 0,Y)}async cancelTask(Q,Y){return this._server.cancelTask({taskId:Q},Y)}}function G5(Q,Y,X){if(!Q)throw Error(`${X} does not support task creation (required for ${Y})`);switch(Y){case"tools/call":if(!Q.tools?.call)throw Error(`${X} does not support task creation for tools/call (required for ${Y})`);break;default:break}}function z5(Q,Y,X){if(!Q)throw Error(`${X} does not support task creation (required for ${Y})`);switch(Y){case"sampling/createMessage":if(!Q.sampling?.createMessage)throw Error(`${X} does not support task creation for sampling/createMessage (required for ${Y})`);break;case"elicitation/create":if(!Q.elicitation?.create)throw Error(`${X} does not support task creation for elicitation/create (required for ${Y})`);break;default:break}}class E9 extends ZY{constructor(Q,Y){super(Y);if(this._serverInfo=Q,this._loggingLevels=new Map,this.LOG_LEVEL_SEVERITY=new Map(L4.options.map((X,W)=>[X,W])),this.isMessageIgnored=(X,W)=>{let G=this._loggingLevels.get(W);return G?this.LOG_LEVEL_SEVERITY.get(X)<this.LOG_LEVEL_SEVERITY.get(G):!1},this._capabilities=Y?.capabilities??{},this._instructions=Y?.instructions,this._jsonSchemaValidator=Y?.jsonSchemaValidator??new j9,this.setRequestHandler(GY,(X)=>this._oninitialize(X)),this.setNotificationHandler(zY,()=>this.oninitialized?.()),this._capabilities.logging)this.setRequestHandler(FY,async(X,W)=>{let G=W.sessionId||W.requestInfo?.headers["mcp-session-id"]||void 0,{level:z}=X.params,J=L4.safeParse(z);if(J.success)this._loggingLevels.set(G,J.data);return{}})}get experimental(){if(!this._experimental)this._experimental={tasks:new I9(this)};return this._experimental}registerCapabilities(Q){if(this.transport)throw Error("Cannot register capabilities after connecting to transport");this._capabilities=jG(this._capabilities,Q)}setRequestHandler(Q,Y){let W=JQ(Q)?.method;if(!W)throw Error("Schema is missing a method literal");let G;if(T1(W)){let J=W;G=J._zod?.def?.value??J.value}else{let J=W;G=J._def?.value??J.value}if(typeof G!=="string")throw Error("Schema method literal must be a string");if(G==="tools/call"){let J=async($,H)=>{let A=Y1(B4,$);if(!A.success){let L=A.error instanceof Error?A.error.message:String(A.error);throw new v(g.InvalidParams,`Invalid tools/call request: ${L}`)}let{params:U}=A.data,K=await Promise.resolve(Y($,H));if(U.task){let L=Y1(R1,K);if(!L.success){let q=L.error instanceof Error?L.error.message:String(L.error);throw new v(g.InvalidParams,`Invalid task creation result: ${q}`)}return L.data}let D=Y1(wQ,K);if(!D.success){let L=D.error instanceof Error?D.error.message:String(D.error);throw new v(g.InvalidParams,`Invalid tools/call result: ${L}`)}return D.data};return super.setRequestHandler(Q,J)}return super.setRequestHandler(Q,Y)}assertCapabilityForMethod(Q){switch(Q){case"sampling/createMessage":if(!this._clientCapabilities?.sampling)throw Error(`Client does not support sampling (required for ${Q})`);break;case"elicitation/create":if(!this._clientCapabilities?.elicitation)throw Error(`Client does not support elicitation (required for ${Q})`);break;case"roots/list":if(!this._clientCapabilities?.roots)throw Error(`Client does not support listing roots (required for ${Q})`);break;case"ping":break}}assertNotificationCapability(Q){switch(Q){case"notifications/message":if(!this._capabilities.logging)throw Error(`Server does not support logging (required for ${Q})`);break;case"notifications/resources/updated":case"notifications/resources/list_changed":if(!this._capabilities.resources)throw Error(`Server does not support notifying about resources (required for ${Q})`);break;case"notifications/tools/list_changed":if(!this._capabilities.tools)throw Error(`Server does not support notifying of tool list changes (required for ${Q})`);break;case"notifications/prompts/list_changed":if(!this._capabilities.prompts)throw Error(`Server does not support notifying of prompt list changes (required for ${Q})`);break;case"notifications/elicitation/complete":if(!this._clientCapabilities?.elicitation?.url)throw Error(`Client does not support URL elicitation (required for ${Q})`);break;case"notifications/cancelled":break;case"notifications/progress":break}}assertRequestHandlerCapability(Q){if(!this._capabilities)return;switch(Q){case"completion/complete":if(!this._capabilities.completions)throw Error(`Server does not support completions (required for ${Q})`);break;case"logging/setLevel":if(!this._capabilities.logging)throw Error(`Server does not support logging (required for ${Q})`);break;case"prompts/get":case"prompts/list":if(!this._capabilities.prompts)throw Error(`Server does not support prompts (required for ${Q})`);break;case"resources/list":case"resources/templates/list":case"resources/read":if(!this._capabilities.resources)throw Error(`Server does not support resources (required for ${Q})`);break;case"tools/call":case"tools/list":if(!this._capabilities.tools)throw Error(`Server does not support tools (required for ${Q})`);break;case"tasks/get":case"tasks/list":case"tasks/result":case"tasks/cancel":if(!this._capabilities.tasks)throw Error(`Server does not support tasks capability (required for ${Q})`);break;case"ping":case"initialize":break}}assertTaskCapability(Q){z5(this._clientCapabilities?.tasks?.requests,Q,"Client")}assertTaskHandlerCapability(Q){if(!this._capabilities)return;G5(this._capabilities.tasks?.requests,Q,"Server")}async _oninitialize(Q){let Y=Q.params.protocolVersion;return this._clientCapabilities=Q.params.capabilities,this._clientVersion=Q.params.clientInfo,{protocolVersion:HG.includes(Y)?Y:e6,capabilities:this.getCapabilities(),serverInfo:this._serverInfo,...this._instructions&&{instructions:this._instructions}}}getClientCapabilities(){return this._clientCapabilities}getClientVersion(){return this._clientVersion}getCapabilities(){return this._capabilities}async ping(){return this.request({method:"ping"},DQ)}async createMessage(Q,Y){if(Q.tools||Q.toolChoice){if(!this._clientCapabilities?.sampling?.tools)throw Error("Client does not support sampling tools capability.")}if(Q.messages.length>0){let X=Q.messages[Q.messages.length-1],W=Array.isArray(X.content)?X.content:[X.content],G=W.some((H)=>H.type==="tool_result"),z=Q.messages.length>1?Q.messages[Q.messages.length-2]:void 0,J=z?Array.isArray(z.content)?z.content:[z.content]:[],$=J.some((H)=>H.type==="tool_use");if(G){if(W.some((H)=>H.type!=="tool_result"))throw Error("The last message must contain only tool_result content if any is present");if(!$)throw Error("tool_result blocks are not matching any tool_use from the previous message")}if($){let H=new Set(J.filter((U)=>U.type==="tool_use").map((U)=>U.id)),A=new Set(W.filter((U)=>U.type==="tool_result").map((U)=>U.toolUseId));if(H.size!==A.size||![...H].every((U)=>A.has(U)))throw Error("ids of tool_result blocks and tool_use blocks from previous message do not match")}}if(Q.tools)return this.request({method:"sampling/createMessage",params:Q},OY,Y);return this.request({method:"sampling/createMessage",params:Q},qY,Y)}async elicitInput(Q,Y){switch(Q.mode??"form"){case"url":{if(!this._clientCapabilities?.elicitation?.url)throw Error("Client does not support url elicitation.");let W=Q;return this.request({method:"elicitation/create",params:W},bQ,Y)}case"form":{if(!this._clientCapabilities?.elicitation?.form)throw Error("Client does not support form elicitation.");let W=Q.mode==="form"?Q:{...Q,mode:"form"},G=await this.request({method:"elicitation/create",params:W},bQ,Y);if(G.action==="accept"&&G.content&&W.requestedSchema)try{let J=this._jsonSchemaValidator.getValidator(W.requestedSchema)(G.content);if(!J.valid)throw new v(g.InvalidParams,`Elicitation response content does not match requested schema: ${J.errorMessage}`)}catch(z){if(z instanceof v)throw z;throw new v(g.InternalError,`Error validating elicitation response: ${z instanceof Error?z.message:String(z)}`)}return G}}}createElicitationCompletionNotifier(Q,Y){if(!this._clientCapabilities?.elicitation?.url)throw Error("Client does not support URL elicitation (required for notifications/elicitation/complete)");return()=>this.notification({method:"notifications/elicitation/complete",params:{elicitationId:Q}},Y)}async listRoots(Q,Y){return this.request({method:"roots/list",params:Q},MY,Y)}async sendLoggingMessage(Q,Y){if(this._capabilities.logging){if(!this.isMessageIgnored(Q.level,Y))return this.notification({method:"notifications/message",params:Q})}}async sendResourceUpdated(Q){return this.notification({method:"notifications/resources/updated",params:Q})}async sendResourceListChanged(){return this.notification({method:"notifications/resources/list_changed"})}async sendToolListChanged(){return this.notification({method:"notifications/tools/list_changed"})}async sendPromptListChanged(){return this.notification({method:"notifications/prompts/list_changed"})}}var J5={name:"@sequenzy/mcp",version:"0.0.45",mcpName:"io.github.sequenzy/mcp",description:"Sequenzy MCP server for AI-powered email marketing automation",type:"module",bin:{"sequenzy-mcp":"dist/index.js"},main:"./dist/index.js",exports:{".":"./dist/index.js","./server":"./dist/server.js","./runtime":"./dist/runtime.js","./server.json":"./server.json"},scripts:{dev:"bun --watch src/index.ts",build:"bun build src/index.ts src/server.ts src/runtime.ts --outdir dist --target node --minify",start:"node dist/index.js","type-check":"tsc --noEmit",test:"bun test","test:watch":"bun test --watch",prepublishOnly:"bun run build"},dependencies:{"@modelcontextprotocol/sdk":"^1.0.0"},devDependencies:{"@types/bun":"latest","@types/node":"^22.0.0","bun-types":"latest",typescript:"^5.8.0"},files:["dist","server.json"],keywords:["sequenzy","email","mcp","ai","claude","automation"],license:"MIT",publishConfig:{access:"public"},repository:{type:"git",url:"git+https://github.com/Sequenzy/mcp.git"},homepage:"https://sequenzy.com",bugs:{url:"https://github.com/Sequenzy/mcp/issues"}};var T9=["product-info","domain","tracking","localization","integrations","products","events","tags","labels","goals","sync-rules","api-keys","widgets","team","danger"],$5={dashboard:"/dashboard/company/{companyId}",campaigns:"/dashboard/company/{companyId}/campaign",campaign:"/dashboard/company/{companyId}/campaign/{campaignId}",campaignPreview:"/dashboard/company/{companyId}/campaign/{campaignId}?step=review",campaignList:"/dashboard/company/{companyId}/campaign/list/{status}",sequences:"/dashboard/company/{companyId}/sequences",sequence:"/dashboard/company/{companyId}/sequences/{sequenceId}",sequenceList:"/dashboard/company/{companyId}/sequences/list/{status}",settings:"/dashboard/company/{companyId}/settings",settingsTab:"/dashboard/company/{companyId}/settings?tab={tab}",emails:"/dashboard/company/{companyId}/emails",email:"/dashboard/company/{companyId}/emails/{emailId}",subscribers:"/dashboard/company/{companyId}/subscribers",sentEmails:"/dashboard/company/{companyId}/sent-emails",emailSend:"/dashboard/company/{companyId}/sent-emails/{emailSendId}",segments:"/dashboard/company/{companyId}/segments",metrics:"/dashboard/company/{companyId}/metrics",transactional:"/dashboard/company/{companyId}/transactional",transactionalEmail:"/dashboard/company/{companyId}/transactional/{transactionalId}",domain:"/dashboard/company/{companyId}/settings/domain/{domainId}",domainVerify:"/dashboard/company/{companyId}/settings/domain/{domainId}/verify"};function AM(Q){let X=(Q??process.env.SEQUENZY_APP_URL??"https://sequenzy.com").trim().replace(/\/+$/,"");return X.length>0?X:"https://sequenzy.com"}function h0(Q){let Y=Q?.trim();return Y?Y:void 0}function t0(Q){return encodeURIComponent(Q)}function Q0(Q,Y){return`${Q}${Y}`}function Y0(Q,Y=""){return`/dashboard/company/${t0(Q)}${Y}`}function H5(Q,Y,X){return Q0(Q,`${Y0(Y,"/settings")}?tab=${encodeURIComponent(X)}`)}function UM(Q,Y){let X=T9.map((W)=>[W,Y?H5(Q,Y,W):""]);return Object.fromEntries(X)}function K1(Q={},Y){let X=AM(Y),W=h0(Q.companyId),G={},z=UM(X,W);if(!W)return{appUrl:X,routeTemplates:$5,settingsTabValues:T9,urls:G,settingsUrls:z};G.dashboard=Q0(X,Y0(W)),G.campaigns=Q0(X,Y0(W,"/campaign")),G.sequences=Q0(X,Y0(W,"/sequences")),G.settings=Q0(X,Y0(W,"/settings")),G.emails=Q0(X,Y0(W,"/emails")),G.subscribers=Q0(X,Y0(W,"/subscribers")),G.sentEmails=Q0(X,Y0(W,"/sent-emails")),G.segments=Q0(X,Y0(W,"/segments")),G.metrics=Q0(X,Y0(W,"/metrics")),G.transactional=Q0(X,Y0(W,"/transactional"));let J=h0(Q.campaignId);if(J)G.campaign=Q0(X,Y0(W,`/campaign/${t0(J)}`)),G.campaignPreview=`${G.campaign}?step=review`;let $=h0(Q.sequenceId);if($)G.sequence=Q0(X,Y0(W,`/sequences/${t0($)}`));let H=h0(Q.emailId)??h0(Q.templateId);if(H)G.email=Q0(X,Y0(W,`/emails/${t0(H)}`)),G.template=G.email;let A=h0(Q.transactionalId);if(A)G.transactionalEmail=Q0(X,Y0(W,`/transactional/${t0(A)}`));let U=h0(Q.emailSendId);if(U)G.emailSend=Q0(X,Y0(W,`/sent-emails/${t0(U)}`));let K=h0(Q.domainId);if(K)G.domain=Q0(X,Y0(W,`/settings/domain/${t0(K)}`)),G.domainVerify=`${G.domain}/verify`;let D=h0(Q.status);if(D)G.campaignList=Q0(X,Y0(W,`/campaign/list/${t0(D)}`)),G.sequenceList=Q0(X,Y0(W,`/sequences/list/${t0(D)}`));let L=h0(Q.settingsTab);if(L)G.settingsTab=H5(X,W,L);return{appUrl:X,routeTemplates:$5,settingsTabValues:T9,urls:G,settingsUrls:z}}var A5=[{uri:"sequenzy://dashboard",name:"Dashboard Overview",description:"Live overview stats for the last 7 days",mimeType:"application/json"},{uri:"sequenzy://company",name:"Current Company",description:"The currently selected company, including localization settings",mimeType:"application/json"},{uri:"sequenzy://campaigns/recent",name:"Recent Campaigns",description:"Last 10 campaigns with status and basic stats",mimeType:"application/json"},{uri:"sequenzy://subscribers/recent",name:"Recent Subscribers",description:"Most recently added subscribers",mimeType:"application/json"},{uri:"sequenzy://subscribers/engaged",name:"Engaged Subscribers",description:"Most active/engaged subscribers",mimeType:"application/json"},{uri:"sequenzy://sequences",name:"Sequences",description:"All email sequences with status",mimeType:"application/json"},{uri:"sequenzy://templates",name:"Templates",description:"All available email templates with localization status",mimeType:"application/json"},{uri:"sequenzy://segments",name:"Segments",description:"All defined segments with subscriber counts",mimeType:"application/json"},{uri:"sequenzy://tags",name:"Tags",description:"All tags with usage counts",mimeType:"application/json"},{uri:"sequenzy://health",name:"Deliverability Health",description:"Email deliverability metrics and health status",mimeType:"application/json"},{uri:"sequenzy://app-routes",name:"Dashboard URL Routes",description:"Route templates and settings tabs for building Sequenzy dashboard links",mimeType:"application/json"}];async function U5(Q){try{let Y;switch(Q){case"sequenzy://dashboard":Y=await N("GET","/api/v1/metrics?period=7d");break;case"sequenzy://company":{let X=await N("GET","/api/v1/account"),W=B1()??X.currentCompanyId;if(!W)throw Error("No company available. Create or select a company first.");Y=await N("GET",`/api/v1/companies/${W}`);break}case"sequenzy://campaigns/recent":Y=await N("GET","/api/v1/campaigns?limit=10");break;case"sequenzy://subscribers/recent":Y=await N("GET","/api/v1/subscribers?sort=createdAt&limit=20");break;case"sequenzy://subscribers/engaged":Y=await N("GET","/api/v1/subscribers?sort=engagement&limit=20");break;case"sequenzy://sequences":Y=await N("GET","/api/v1/sequences");break;case"sequenzy://templates":Y=await N("GET","/api/v1/templates");break;case"sequenzy://segments":Y=await N("GET","/api/v1/segments");break;case"sequenzy://tags":Y=await N("GET","/api/v1/tags");break;case"sequenzy://health":Y=await N("GET","/api/v1/health/deliverability");break;case"sequenzy://app-routes":Y=K1();break;default:throw Error(`Unknown resource: ${Q}`)}return{contents:[{uri:Q,mimeType:"application/json",text:JSON.stringify(Y,null,2)}]}}catch(Y){return{contents:[{uri:Q,mimeType:"text/plain",text:b1(Y)}]}}}var h4="Sequenzy email blocks. Use `styles` for per-block background, background opacity, text color, padding, border radius, border width, and border color. Top-level style aliases such as `backgroundColor`, `backgroundOpacity`, `borderColor`, `borderWidth`, and `borderRadius` are also accepted and saved under `styles`. Use this for editor-compatible content, including conditional and repeat blocks. Repeat blocks use { type: 'repeat', source: 'items', itemAlias: 'item', children: [...] }.",H6="Replacement Sequenzy email blocks. Use `styles` for per-block background, background opacity, text color, padding, border radius, border width, and border color. Top-level style aliases such as `backgroundColor`, `backgroundOpacity`, `borderColor`, `borderWidth`, and `borderRadius` are also accepted and saved under `styles`.",B5="Sequenzy email blocks. Provide blocks or html for email steps. Use `styles` for per-block background, background opacity, text color, padding, border radius, border width, and border color. Top-level style aliases such as `backgroundColor`, `backgroundOpacity`, `borderColor`, `borderWidth`, and `borderRadius` are also accepted and saved under `styles`. Blocks can include repeat blocks over array variables such as items.",KM={type:"object",properties:{id:{type:"string",description:"Optional filter ID. Any stable string works; one will be generated if omitted."},field:{type:"string",enum:["status","tag","email","emailProvider","added","firstName","lastName","list","emailSent","emailOpened","emailClicked","emailBounced","emailComplained","attribute","event","segment","stripeProduct","stripeCurrentProduct","stripeTrialProduct"],description:"Filter field. Use `event` for custom subscriber events, `segment` for saved segment membership, and `stripeProduct`/`stripeCurrentProduct`/`stripeTrialProduct` for Stripe product-based segments. Engagement fields (`emailSent`, `emailOpened`, `emailClicked`, `emailBounced`, `emailComplained`) accept a time range as the value or a specific campaign via `campaign:<campaign_id>`."},operator:{type:"string",enum:["is","is_not","is_empty","is_not_empty","contains","not_contains","less_than","more_than","at_least","less_than_count","gte","lte","gt","lt"],description:"Filter operator. Use `is_empty` or `is_not_empty` for fields that can be blank, including custom attributes. For `stripeProduct`, use `is` or `is_not` with a raw product ID, and `at_least` or `less_than_count` with `productId:count`. For `event`, use `is`, `is_not`, `at_least`, or `less_than_count`. For engagement fields, use `is` (event happened) or `is_not` (event did not happen)."},value:{type:"string",description:"Filter value. For custom attribute empty checks, use `attributeName:` such as `last_logged_in:`. Event examples: `saas.purchase:30d`, `saas.purchase:all`, or `saas.purchase:5:30d` for thresholds. Segment values are segment IDs. Stripe product examples: `prod_123` for bought/didn't buy, `prod_123:3` for payment thresholds. Engagement examples: `7d`, `30d`, `90d`, `180d`, `all` for rolling time windows, or `campaign:<campaign_id>` to scope to a specific sent campaign (use `list_campaigns` to find IDs)."}},required:["field","operator","value"],additionalProperties:!1},DM={type:"object",properties:{kind:{type:"string",enum:["group"]},id:{type:"string",description:"Stable group ID. Any string works; one will be generated if omitted."},joinOperator:{type:"string",enum:["and","or"],description:"How children in this group combine."},children:{type:"array",minItems:1,items:{type:"object",description:'Either a filter leaf (`kind: "filter"`) or another group (`kind: "group"`).'}}},required:["kind","joinOperator","children"],additionalProperties:!0};function L5(Q){if(!Array.isArray(Q))return Q;return Q.map((Y)=>{if(typeof Y!=="object"||Y===null)return Y;let X=Y;if(typeof X.id==="string"&&X.id.trim()!=="")return X;return{...X,id:crypto.randomUUID()}})}function F5(Q){if(typeof Q!=="object"||Q===null)return Q;let Y=Q;if(Y.kind==="filter"){let X=L5([Y]);return Array.isArray(X)?X[0]:Y}if(Y.kind!=="group")return Q;return{...Y,id:typeof Y.id==="string"&&Y.id.trim()!==""?Y.id:crypto.randomUUID(),children:Array.isArray(Y.children)?Y.children.map(F5):[]}}function w1(Q,Y,X){if(Y.html!==void 0&&Y.blocks!==void 0)throw Error(`Provide either \`html\` or \`blocks\` when calling \`${Q}\`, not both.`);if(Y.blocks!==void 0&&!Array.isArray(Y.blocks))throw Error(`\`blocks\` must be an array when calling \`${Q}\`.`);if(X?.requireContent&&Y.html===void 0&&Y.blocks===void 0)throw Error(`Provide either \`html\` or \`blocks\` when calling \`${Q}\`.`)}function U6(Q,Y){if(Y.labels===void 0)return;if(!Array.isArray(Y.labels))throw Error(`\`labels\` must be an array when calling \`${Q}\`.`);if(Y.labels.some((X)=>typeof X!=="string"||X.trim().length===0))throw Error(`\`labels\` must contain only non-empty strings when calling \`${Q}\`.`)}function BM(Q){let Y=Q.filters!==void 0,X=Q.root!==void 0;if(Y&&X)throw Error("Provide either `filters` or `root` when calling `create_segment`, not both.");if(!Y&&!X)throw Error("Provide either `filters` or `root` when calling `create_segment`.");if(Y){if(!Array.isArray(Q.filters))throw Error("`filters` must be an array when calling `create_segment`.");if(Q.filters.length===0)throw Error("`filters` must include at least one filter when calling `create_segment`.")}if(X&&(typeof Q.root!=="object"||Q.root===null))throw Error("`root` must be an object when calling `create_segment`.")}function LM(Q){if(Q.clearEnrollmentFieldPath===!0&&Q.enrollmentFieldPath!==void 0)throw Error("Provide either `enrollmentFieldPath` or `clearEnrollmentFieldPath` when calling `update_sequence`, not both.");let Y={...Q};if(delete Y.clearEnrollmentFieldPath,Q.clearEnrollmentFieldPath===!0)Y.enrollmentFieldPath=null;return Y}function FM(Q){let Y=j(Q,"subscriberId"),X=Q.fieldValues,W=X===void 0?void 0:Array.isArray(X)?X:void 0;if(X!==void 0&&W===void 0)throw Error("`fieldValues` must be an array when calling `cancel_sequence_enrollments`.");let G=W?.map(($)=>typeof $==="string"?$.trim():"").filter(($)=>$.length>0)??[];if(W?.some(($)=>typeof $!=="string")||W!==void 0&&G.length===0)throw Error("`fieldValues` must contain at least one non-empty string when calling `cancel_sequence_enrollments`.");if(Y!==void 0===G.length>0)throw Error("Provide exactly one target when calling `cancel_sequence_enrollments`: `subscriberId` or `fieldValues`.");let z=j(Q,"fieldPath"),J=j(Q,"reason");return{...Y!==void 0&&{subscriberId:Y},...z!==void 0&&{fieldPath:z},...G.length>0&&{fieldValues:G},...typeof Q.dryRun==="boolean"&&{dryRun:Q.dryRun},...J!==void 0&&{reason:J}}}function qM(Q){w1("create_campaign",Q),U6("create_campaign",Q);let Y=j(Q,"prompt")!==void 0,X=Q.html!==void 0,W=Q.blocks!==void 0,G=Q.templateId!==void 0;if(Q.prompt!==void 0&&!Y)throw Error("`prompt` cannot be empty when calling `create_campaign`.");if(Y&&(X||W||G))throw Error("Provide either `prompt`, `html`, `blocks`, or `templateId` when calling `create_campaign`, not multiple content sources.");if(!Y&&(Q.style!==void 0||Q.tone!==void 0))throw Error("`style` and `tone` can only be used with `prompt` when calling `create_campaign`.");if(!Y&&j(Q,"subject")===void 0)throw Error("`subject` is required unless `prompt` is provided when calling `create_campaign`.")}function OM(Q){if(j(Q,"scheduledAt")===void 0)throw Error("`scheduledAt` is required when calling `schedule_campaign`.");if(Q.targetLists!==void 0&&!B0(Q.targetLists))throw Error("`targetLists` must be an object when calling `schedule_campaign`.");if(Q.sendTimeOptimization!==void 0){if(typeof Q.sendTimeOptimization!=="boolean")throw Error("`sendTimeOptimization` must be a boolean when calling `schedule_campaign`.")}if(Q.spreadOverHours!==void 0){if(typeof Q.spreadOverHours!=="number"||!Number.isInteger(Q.spreadOverHours)||Q.spreadOverHours<1||Q.spreadOverHours>72)throw Error("`spreadOverHours` must be an integer between 1 and 72 when calling `schedule_campaign`.")}}function MM(Q){w1("create_transactional_email",Q);let Y=j(Q,"prompt")!==void 0,X=Q.html!==void 0,W=Q.blocks!==void 0;if(Q.prompt!==void 0&&!Y)throw Error("`prompt` cannot be empty when calling `create_transactional_email`.");if(Y&&(X||W))throw Error("Provide either `prompt`, `html`, or `blocks` when calling `create_transactional_email`, not multiple content sources.");if(!Y&&(Q.style!==void 0||Q.tone!==void 0))throw Error("`style` and `tone` can only be used with `prompt` when calling `create_transactional_email`.");if(!Y&&!X&&!W)throw Error("Provide either `prompt`, `html`, or `blocks` when calling `create_transactional_email`.");if(!Y&&j(Q,"subject")===void 0)throw Error("`subject` is required unless `prompt` is provided when calling `create_transactional_email`.")}var K5={type:"object",description:"A step to create inside a branch path. Use type:'delay' for a standalone delay, type:'email' for an email, or type:'create_discount' for a discount action.",properties:{type:{type:"string",enum:["email","delay","create_discount","discount","webhook"],description:"Branch path step type. Omit for email steps; use delay for standalone waits."},nodeType:{type:"string",enum:["logic_delay","action_email","action_create_discount","action_add_tag","action_remove_tag","action_add_to_list","action_remove_from_list","action_update_attributes","logic_wait_for_event","action_webhook"],description:"Advanced branch path node type. Prefer type unless creating a non-email action."},config:{type:"object",description:"Config for advanced nodeType steps such as tag/list/webhook/wait-for-event actions.",additionalProperties:!0},subject:{type:"string",description:"Email subject. Required for email steps."},previewText:{type:"string",description:"Email preview text."},blocks:{type:"array",description:B5,items:{type:"object"}},html:{type:"string",description:"HTML content for email steps."},delay:{type:"object",description:"Delay before this step, or the delay duration when type is delay.",properties:{days:{type:"number"},hours:{type:"number"},minutes:{type:"number"}}},delayMs:{type:"number",description:"Delay in milliseconds. Useful for standalone type:'delay' steps."},name:{type:"string",description:"Email template name for email steps."},discount:{type:"object",description:"Discount configuration for create_discount steps. Same shape as create_sequence steps.",additionalProperties:!0},label:{type:"string",description:"Node label for discount or advanced node steps."},provider:{type:"string",enum:["stripe","shopify"]},discountType:{type:"string",enum:["percent","amount"]},percentOff:{type:"number"},amountOff:{type:"number"},currency:{type:"string"},duration:{type:"string",enum:["once","forever","repeating"]},durationInMonths:{type:"number"},appliesToAllPlans:{type:"boolean"},planIds:{type:"array",items:{type:"string"}},codePrefix:{type:"string"},maxRedemptions:{type:"number"},lockToSubscriber:{type:"boolean"},expiresAt:{type:"string"},expiresInHours:{type:"number"}},additionalProperties:!1};function VM(Q){if(!Q||typeof Q!=="object")return null;let Y=Q;if(Y.success!==!1)return null;if(typeof Y.error==="string")return Error(Y.error);if(Y.error&&typeof Y.error==="object"&&typeof Y.error.message==="string")return Error(Y.error.message);if(typeof Y.message==="string")return Error(Y.message);return Error("The tool returned an unsuccessful response.")}function B0(Q){return typeof Q==="object"&&Q!==null&&!Array.isArray(Q)}function D5(Q){return Q.trim().toLowerCase().replace(/\s+/g,"-")}function NM(Q){let Y=new URLSearchParams;if(typeof Q.query==="string"&&Q.query.trim()!=="")Y.set("query",Q.query.trim());if(Array.isArray(Q.tags)&&Q.tags.length>0)Y.set("tags",Q.tags.filter((X)=>typeof X==="string"&&X.trim()!=="").join(","));if(typeof Q.segmentId==="string"&&Q.segmentId.trim()!=="")Y.set("segmentId",Q.segmentId);if(typeof Q.status==="string"&&Q.status.trim()!=="")Y.set("status",Q.status.trim());return Y.set("page",String(Q.page)),Y.set("limit",String(Q.pageSize)),Y}async function ZM(Q,Y){let X=typeof Q.limit==="number"&&Number.isFinite(Q.limit)?Math.max(1,Math.trunc(Q.limit)):void 0,W=Math.min(100,Math.max(1,X??100)),G=[],z=1,J=0,$=0,H=0;while(!0){let U=NM({query:Q.query,tags:Q.tags,segmentId:Q.segmentId,status:Q.status,page:z,pageSize:W}),K=await N("GET",`/api/v1/subscribers?${U.toString()}`,void 0,Y);J=K.pagination?.total??K.subscribers.length,$=K.pagination?.totalPages??1,H+=1,G.push(...K.subscribers??[]);let D=X!==void 0&&G.length>=X,L=K.pagination?z>=K.pagination.totalPages:(K.subscribers??[]).length<W;if(D||L)break;z+=1}let A=X!==void 0?G.slice(0,X):G;return{success:!0,subscribers:A,pagination:{page:1,limit:W,total:J,totalPages:$,fetchedPages:H},returned:A.length,truncated:X!==void 0&&J>0&&A.length<J}}function wM(Q){let Y=typeof Q.email==="string"&&Q.email.trim()!==""?Q.email.trim():void 0,X=typeof Q.externalId==="string"&&Q.externalId.trim()!==""?Q.externalId.trim():void 0;return{...Y?{email:Y}:{},...X?{externalId:X}:{}}}function f4(Q,Y){let X=wM(Y);if(!X.email&&!X.externalId)throw Error(`Provide either \`email\` or \`externalId\` when calling \`${Q}\`.`);return X}function R9(Q){if(Q.email)return`/api/v1/subscribers/${encodeURIComponent(Q.email)}`;return`/api/v1/subscribers/external?externalId=${encodeURIComponent(String(Q.externalId))}`}async function S9(Q,Y){return N("GET",R9(Q),void 0,Y)}function j(Q,Y){let X=Q[Y];if(typeof X!=="string")return;let W=X.trim();return W.length>0?W:void 0}async function q5(Q){let Y=j(Q,"companyId");if(Y)return Y;let X=B1();if(X)return X;try{return(await N("GET","/api/v1/account")).currentCompanyId??void 0}catch{return}}function l4(Q,Y){if(!B0(Q)||!Y)return Q;return{...Q,url:Y}}function O5(Q,Y){if(!B0(Q))return Q;return{...Q,...Y.campaign!==void 0&&{url:Y.campaign},...Y.campaignPreview!==void 0&&{previewUrl:Y.campaignPreview}}}function A6(Q,Y,X){if(!Array.isArray(Q)||!Y)return Q;return Q.map((W)=>{if(!B0(W))return W;let G=j(W,"id");if(!G)return W;let z=K1({companyId:Y,...X==="campaign"&&{campaignId:G},...X==="sequence"&&{sequenceId:G},...X==="template"&&{emailId:G},...X==="transactional"&&{transactionalId:G}});if(X==="campaign")return O5(W,z.urls);let J=X==="sequence"?z.urls.sequence:X==="template"?z.urls.email:z.urls.transactionalEmail;return l4(W,J)})}function bM(Q){if(!Array.isArray(Q))return Q;return Q.map((Y)=>{if(!B0(Y))return Y;let X=j(Y,"id");if(!X)return Y;let W=K1({companyId:X});return{...Y,url:W.urls.dashboard,settingsUrl:W.urls.settings}})}var PM=new Set(["get_account","select_company","create_company","get_company","list_campaigns","get_campaign","get_email_send","create_campaign","update_campaign","schedule_campaign","send_test_email","list_sequences","get_sequence","create_sequence","update_sequence","enable_sequence","disable_sequence","cancel_sequence_enrollments","list_ab_tests","get_ab_test","get_ab_test_stats","update_ab_test_variant","list_templates","get_template","create_template","update_template","list_transactional_emails","get_transactional_email","create_transactional_email","update_transactional_email"]);async function jM(Q,Y,X){if(!B0(X)||!PM.has(Q))return X;let W=B0(X.company)?X.company:void 0,z=j(X,"selectedCompanyId")??j(X,"currentCompanyId")??j(X,"companyId")??(W?j(W,"id"):void 0)??(W?j(W,"companyId"):void 0)??await q5(Y);if(!z)return X;let J=B0(X.campaign)?X.campaign:void 0,$=B0(X.sequence)?X.sequence:void 0,H=B0(X.template)?X.template:void 0,A=B0(X.transactional)&&!Array.isArray(X.transactional)?X.transactional:void 0,U={companyId:z,campaignId:j(Y,"campaignId")??j(X,"campaignId")??(J?j(J,"id"):void 0),sequenceId:j(Y,"sequenceId")??j(X,"sequenceId")??($?j($,"id"):void 0),emailId:j(X,"templateId")??(H?j(H,"id"):void 0)??(A?j(A,"emailId"):void 0)??j(Y,"templateId"),transactionalId:j(Y,"transactionalId")??(A?j(A,"id"):void 0)??j(Y,"idOrSlug"),emailSendId:j(Y,"emailSendId")??j(X,"emailSendId")??(B0(X.emailSend)?j(X.emailSend,"id"):void 0),status:j(Y,"status")},K=K1(U),D=W?K1({companyId:z}):void 0;return{...X,...Array.isArray(X.companies)&&{companies:bM(X.companies)},...Array.isArray(X.campaigns)&&{campaigns:A6(X.campaigns,z,"campaign")},...Array.isArray(X.sequences)&&{sequences:A6(X.sequences,z,"sequence")},...Array.isArray(X.templates)&&{templates:A6(X.templates,z,"template")},...Array.isArray(X.transactional)&&{transactional:A6(X.transactional,z,"transactional")},...W&&D!==void 0&&{company:{...W,url:D.urls.dashboard,settingsUrl:D.urls.settings}},...J&&K.urls.campaign!==void 0&&{campaign:O5(J,K.urls)},...$&&K.urls.sequence!==void 0&&{sequence:l4($,K.urls.sequence)},...H&&K.urls.email!==void 0&&{template:l4(H,K.urls.email)},...A&&K.urls.transactionalEmail!==void 0&&{transactional:l4(A,K.urls.transactionalEmail)},...B0(X.emailSend)&&K.urls.emailSend!==void 0&&{emailSend:l4(X.emailSend,K.urls.emailSend)},appUrls:K.urls}}var M5=[{name:"get_account",description:`Get current account information including available companies. IMPORTANT: If you have access to multiple companies, you MUST either:
29
29
  1. Call select_company first to choose which company to work with, OR
30
30
  2. Pass companyId explicitly in each tool call
31
31
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sequenzy/mcp",
3
- "version": "0.0.44",
3
+ "version": "0.0.45",
4
4
  "mcpName": "io.github.sequenzy/mcp",
5
5
  "description": "Sequenzy MCP server for AI-powered email marketing automation",
6
6
  "type": "module",
package/server.json CHANGED
@@ -6,12 +6,12 @@
6
6
  "url": "https://github.com/Sequenzy/mcp",
7
7
  "source": "github"
8
8
  },
9
- "version": "0.0.44",
9
+ "version": "0.0.45",
10
10
  "packages": [
11
11
  {
12
12
  "registryType": "npm",
13
13
  "identifier": "@sequenzy/mcp",
14
- "version": "0.0.44",
14
+ "version": "0.0.45",
15
15
  "runtime": "node",
16
16
  "transport": {
17
17
  "type": "stdio"