@sequenzy/mcp 0.0.48 → 0.0.49

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
@@ -7,9 +7,9 @@ var _5=Object.create;var{getPrototypeOf:y5,defineProperty:F6,getOwnPropertyNames
7
7
  missingProperty: ${W},
8
8
  depsCount: ${Y},
9
9
  deps: ${X}}`};var jq={keyword:"dependencies",type:"object",schemaType:"object",error:dz.error,code(Q){let[Y,X]=Eq(Q);rz(Q,Y),nz(Q,X)}};function Eq({schema:Q}){let Y={},X={};for(let W in Q){if(W==="__proto__")continue;let G=Array.isArray(Q[W])?Y:X;G[W]=Q[W]}return[Y,X]}function rz(Q,Y=Q.schema){let{gen:X,data:W,it:G}=Q;if(Object.keys(Y).length===0)return;let $=X.let("missing");for(let J in Y){let z=Y[J];if(z.length===0)continue;let H=(0,y4.propertyInData)(X,W,J,G.opts.ownProperties);if(Q.setParams({property:J,depsCount:z.length,deps:z.join(", ")}),G.allErrors)X.if(H,()=>{for(let A of z)(0,y4.checkReportMissingProp)(Q,A)});else X.if(K9._`${H} && (${(0,y4.checkMissingProp)(Q,z,$)})`),(0,y4.reportMissingProp)(Q,$),X.else()}}dz.validatePropertyDeps=rz;function nz(Q,Y=Q.schema){let{gen:X,data:W,keyword:G,it:$}=Q,J=X.name("valid");for(let z in Y){if((0,Iq.alwaysValidSchema)($,Y[z]))continue;X.if((0,y4.propertyInData)(X,W,z,$.opts.ownProperties),()=>{let H=Q.subschema({keyword:G,schemaProp:z},J);Q.mergeValidEvaluated(H,J)},()=>X.var(J,!0)),Q.ok(J)}}dz.validateSchemaDeps=nz;dz.default=jq});var Q7=Z((ez)=>{Object.defineProperty(ez,"__esModule",{value:!0});var sz=v(),Rq=f(),Cq={message:"property name must be valid",params:({params:Q})=>sz._`{propertyName: ${Q.propertyName}}`},kq={keyword:"propertyNames",type:"object",schemaType:["object","boolean"],error:Cq,code(Q){let{gen:Y,schema:X,data:W,it:G}=Q;if((0,Rq.alwaysValidSchema)(G,X))return;let $=Y.name("valid");Y.forIn("key",W,(J)=>{Q.setParams({propertyName:J}),Q.subschema({keyword:"propertyNames",data:J,dataTypes:["string"],propertyName:J,compositeRule:!0},$),Y.if((0,sz.not)($),()=>{if(Q.error(!0),!G.allErrors)Y.break()})}),Q.ok($)}};ez.default=kq});var D9=Z((Y7)=>{Object.defineProperty(Y7,"__esModule",{value:!0});var X6=I0(),v0=v(),xq=r0(),W6=f(),_q={message:"must NOT have additional properties",params:({params:Q})=>v0._`{additionalProperty: ${Q.additionalProperty}}`},yq={keyword:"additionalProperties",type:["object"],schemaType:["boolean","object"],allowUndefined:!0,trackErrors:!0,error:_q,code(Q){let{gen:Y,schema:X,parentSchema:W,data:G,errsCount:$,it:J}=Q;if(!$)throw Error("ajv implementation error");let{allErrors:z,opts:H}=J;if(J.props=!0,H.removeAdditional!=="all"&&(0,W6.alwaysValidSchema)(J,X))return;let A=(0,X6.allSchemaProperties)(W.properties),U=(0,X6.allSchemaProperties)(W.patternProperties);K(),Q.ok(v0._`${$} === ${xq.default.errors}`);function K(){Y.forIn("key",G,(V)=>{if(!A.length&&!U.length)q(V);else Y.if(D(V),()=>q(V))})}function D(V){let M;if(A.length>8){let S=(0,W6.schemaRefOrVal)(J,W.properties,"properties");M=(0,X6.isOwnProperty)(Y,S,V)}else if(A.length)M=(0,v0.or)(...A.map((S)=>v0._`${V} === ${S}`));else M=v0.nil;if(U.length)M=(0,v0.or)(M,...U.map((S)=>v0._`${(0,X6.usePattern)(Q,S)}.test(${V})`));return(0,v0.not)(M)}function L(V){Y.code(v0._`delete ${G}[${V}]`)}function q(V){if(H.removeAdditional==="all"||H.removeAdditional&&X===!1){L(V);return}if(X===!1){if(Q.setParams({additionalProperty:V}),Q.error(),!z)Y.break();return}if(typeof X=="object"&&!(0,W6.alwaysValidSchema)(J,X)){let M=Y.name("valid");if(H.removeAdditional==="failing")O(V,M,!1),Y.if((0,v0.not)(M),()=>{Q.reset(),L(V)});else if(O(V,M),!z)Y.if((0,v0.not)(M),()=>Y.break())}}function O(V,M,S){let E={keyword:"additionalProperties",dataProp:V,dataPropType:W6.Type.Str};if(S===!1)Object.assign(E,{compositeRule:!0,createErrors:!1,allErrors:!1});Q.subschema(E,M)}}};Y7.default=yq});var $7=Z((G7)=>{Object.defineProperty(G7,"__esModule",{value:!0});var uq=P4(),X7=I0(),B9=f(),W7=D9(),hq={keyword:"properties",type:"object",schemaType:"object",code(Q){let{gen:Y,schema:X,parentSchema:W,data:G,it:$}=Q;if($.opts.removeAdditional==="all"&&W.additionalProperties===void 0)W7.default.code(new uq.KeywordCxt($,W7.default,"additionalProperties"));let J=(0,X7.allSchemaProperties)(X);for(let K of J)$.definedProperties.add(K);if($.opts.unevaluated&&J.length&&$.props!==!0)$.props=B9.mergeEvaluated.props(Y,(0,B9.toHash)(J),$.props);let z=J.filter((K)=>!(0,B9.alwaysValidSchema)($,X[K]));if(z.length===0)return;let H=Y.name("valid");for(let K of z){if(A(K))U(K);else{if(Y.if((0,X7.propertyInData)(Y,G,K,$.opts.ownProperties)),U(K),!$.allErrors)Y.else().var(H,!0);Y.endIf()}Q.it.definedProperties.add(K),Q.ok(H)}function A(K){return $.opts.useDefaults&&!$.compositeRule&&X[K].default!==void 0}function U(K){Q.subschema({keyword:"properties",schemaProp:K,dataProp:K},H)}}};G7.default=hq});var U7=Z((A7)=>{Object.defineProperty(A7,"__esModule",{value:!0});var J7=I0(),G6=v(),z7=f(),H7=f(),lq={keyword:"patternProperties",type:"object",schemaType:"object",code(Q){let{gen:Y,schema:X,data:W,parentSchema:G,it:$}=Q,{opts:J}=$,z=(0,J7.allSchemaProperties)(X),H=z.filter((O)=>(0,z7.alwaysValidSchema)($,X[O]));if(z.length===0||H.length===z.length&&(!$.opts.unevaluated||$.props===!0))return;let A=J.strictSchema&&!J.allowMatchingProperties&&G.properties,U=Y.name("valid");if($.props!==!0&&!($.props instanceof G6.Name))$.props=(0,H7.evaluatedPropsToName)(Y,$.props);let{props:K}=$;D();function D(){for(let O of z){if(A)L(O);if($.allErrors)q(O);else Y.var(U,!0),q(O),Y.if(U)}}function L(O){for(let V in A)if(new RegExp(O).test(V))(0,z7.checkStrictMode)($,`property ${V} matches pattern ${O} (use allowMatchingProperties)`)}function q(O){Y.forIn("key",W,(V)=>{Y.if(G6._`${(0,J7.usePattern)(Q,O)}.test(${V})`,()=>{let M=H.includes(O);if(!M)Q.subschema({keyword:"patternProperties",schemaProp:O,dataProp:V,dataPropType:H7.Type.Str},U);if($.opts.unevaluated&&K!==!0)Y.assign(G6._`${K}[${V}]`,!0);else if(!M&&!$.allErrors)Y.if((0,G6.not)(U),()=>Y.break())})})}}};A7.default=lq});var D7=Z((K7)=>{Object.defineProperty(K7,"__esModule",{value:!0});var cq=f(),pq={keyword:"not",schemaType:["object","boolean"],trackErrors:!0,code(Q){let{gen:Y,schema:X,it:W}=Q;if((0,cq.alwaysValidSchema)(W,X)){Q.fail();return}let G=Y.name("valid");Q.subschema({keyword:"not",compositeRule:!0,createErrors:!1,allErrors:!1},G),Q.failResult(G,()=>Q.reset(),()=>Q.error())},error:{message:"must NOT be valid"}};K7.default=pq});var L7=Z((B7)=>{Object.defineProperty(B7,"__esModule",{value:!0});var rq=I0(),nq={keyword:"anyOf",schemaType:"array",trackErrors:!0,code:rq.validateUnion,error:{message:"must match a schema in anyOf"}};B7.default=nq});var q7=Z((F7)=>{Object.defineProperty(F7,"__esModule",{value:!0});var $6=v(),oq=f(),tq={message:"must match exactly one schema in oneOf",params:({params:Q})=>$6._`{passingSchemas: ${Q.passing}}`},aq={keyword:"oneOf",schemaType:"array",trackErrors:!0,error:tq,code(Q){let{gen:Y,schema:X,parentSchema:W,it:G}=Q;if(!Array.isArray(X))throw Error("ajv implementation error");if(G.opts.discriminator&&W.discriminator)return;let $=X,J=Y.let("valid",!1),z=Y.let("passing",null),H=Y.name("_valid");Q.setParams({passing:z}),Y.block(A),Q.result(J,()=>Q.reset(),()=>Q.error(!0));function A(){$.forEach((U,K)=>{let D;if((0,oq.alwaysValidSchema)(G,U))Y.var(H,!0);else D=Q.subschema({keyword:"oneOf",schemaProp:K,compositeRule:!0},H);if(K>0)Y.if($6._`${H} && ${J}`).assign(J,!1).assign(z,$6._`[${z}, ${K}]`).else();Y.if(H,()=>{if(Y.assign(J,!0),Y.assign(z,K),D)Q.mergeEvaluated(D,$6.Name)})})}}};F7.default=aq});var M7=Z((O7)=>{Object.defineProperty(O7,"__esModule",{value:!0});var eq=f(),QO={keyword:"allOf",schemaType:"array",code(Q){let{gen:Y,schema:X,it:W}=Q;if(!Array.isArray(X))throw Error("ajv implementation error");let G=Y.name("valid");X.forEach(($,J)=>{if((0,eq.alwaysValidSchema)(W,$))return;let z=Q.subschema({keyword:"allOf",schemaProp:J},G);Q.ok(G),Q.mergeEvaluated(z)})}};O7.default=QO});var w7=Z((Z7)=>{Object.defineProperty(Z7,"__esModule",{value:!0});var J6=v(),N7=f(),XO={message:({params:Q})=>J6.str`must match "${Q.ifClause}" schema`,params:({params:Q})=>J6._`{failingKeyword: ${Q.ifClause}}`},WO={keyword:"if",schemaType:["object","boolean"],trackErrors:!0,error:XO,code(Q){let{gen:Y,parentSchema:X,it:W}=Q;if(X.then===void 0&&X.else===void 0)(0,N7.checkStrictMode)(W,'"if" without "then" and "else" is ignored');let G=V7(W,"then"),$=V7(W,"else");if(!G&&!$)return;let J=Y.let("valid",!0),z=Y.name("_valid");if(H(),Q.reset(),G&&$){let U=Y.let("ifClause");Q.setParams({ifClause:U}),Y.if(z,A("then",U),A("else",U))}else if(G)Y.if(z,A("then"));else Y.if((0,J6.not)(z),A("else"));Q.pass(J,()=>Q.error(!0));function H(){let U=Q.subschema({keyword:"if",compositeRule:!0,createErrors:!1,allErrors:!1},z);Q.mergeEvaluated(U)}function A(U,K){return()=>{let D=Q.subschema({keyword:U},z);if(Y.assign(J,z),Q.mergeValidEvaluated(D,J),K)Y.assign(K,J6._`${U}`);else Q.setParams({ifClause:U})}}}};function V7(Q,Y){let X=Q.schema[Y];return X!==void 0&&!(0,N7.alwaysValidSchema)(Q,X)}Z7.default=WO});var P7=Z((b7)=>{Object.defineProperty(b7,"__esModule",{value:!0});var $O=f(),JO={keyword:["then","else"],schemaType:["object","boolean"],code({keyword:Q,parentSchema:Y,it:X}){if(Y.if===void 0)(0,$O.checkStrictMode)(X,`"${Q}" without "if" is ignored`)}};b7.default=JO});var j7=Z((I7)=>{Object.defineProperty(I7,"__esModule",{value:!0});var HO=A9(),AO=fz(),UO=U9(),KO=cz(),DO=iz(),BO=az(),LO=Q7(),FO=D9(),qO=$7(),OO=U7(),MO=D7(),VO=L7(),NO=q7(),ZO=M7(),wO=w7(),bO=P7();function PO(Q=!1){let Y=[MO.default,VO.default,NO.default,ZO.default,wO.default,bO.default,LO.default,FO.default,BO.default,qO.default,OO.default];if(Q)Y.push(AO.default,KO.default);else Y.push(HO.default,UO.default);return Y.push(DO.default),Y}I7.default=PO});var T7=Z((E7)=>{Object.defineProperty(E7,"__esModule",{value:!0});var e=v(),jO={message:({schemaCode:Q})=>e.str`must match format "${Q}"`,params:({schemaCode:Q})=>e._`{format: ${Q}}`},EO={keyword:"format",type:["number","string"],schemaType:"string",$data:!0,error:jO,code(Q,Y){let{gen:X,data:W,$data:G,schema:$,schemaCode:J,it:z}=Q,{opts:H,errSchemaPath:A,schemaEnv:U,self:K}=z;if(!H.validateFormats)return;if(G)D();else L();function D(){let q=X.scopeValue("formats",{ref:K.formats,code:H.code.formats}),O=X.const("fDef",e._`${q}[${J}]`),V=X.let("fType"),M=X.let("format");X.if(e._`typeof ${O} == "object" && !(${O} instanceof RegExp)`,()=>X.assign(V,e._`${O}.type || "string"`).assign(M,e._`${O}.validate`),()=>X.assign(V,e._`"string"`).assign(M,O)),Q.fail$data((0,e.or)(S(),E()));function S(){if(H.strictSchema===!1)return e.nil;return e._`${J} && !${M}`}function E(){let x=U.$async?e._`(${O}.async ? await ${M}(${W}) : ${M}(${W}))`:e._`${M}(${W})`,T=e._`(typeof ${M} == "function" ? ${x} : ${M}.test(${W}))`;return e._`${M} && ${M} !== true && ${V} === ${Y} && !${T}`}}function L(){let q=K.formats[$];if(!q){S();return}if(q===!0)return;let[O,V,M]=E(q);if(O===Y)Q.pass(x());function S(){if(H.strictSchema===!1){K.logger.warn(T());return}throw Error(T());function T(){return`unknown format "${$}" ignored in schema at path "${A}"`}}function E(T){let _0=T instanceof RegExp?(0,e.regexpCode)(T):H.code.formats?e._`${H.code.formats}${(0,e.getProperty)($)}`:void 0,f0=X.scopeValue("formats",{key:$,ref:T,code:_0});if(typeof T=="object"&&!(T instanceof RegExp))return[T.type||"string",T.validate,e._`${f0}.validate`];return["string",T,f0]}function x(){if(typeof q=="object"&&!(q instanceof RegExp)&&q.async){if(!U.$async)throw Error("async format in sync schema");return e._`await ${M}(${W})`}return typeof V=="function"?e._`${M}(${W})`:e._`${M}.test(${W})`}}}};E7.default=EO});var R7=Z((S7)=>{Object.defineProperty(S7,"__esModule",{value:!0});var SO=T7(),RO=[SO.default];S7.default=RO});var v7=Z((C7)=>{Object.defineProperty(C7,"__esModule",{value:!0});C7.contentVocabulary=C7.metadataVocabulary=void 0;C7.metadataVocabulary=["title","description","default","deprecated","readOnly","writeOnly","examples"];C7.contentVocabulary=["contentMediaType","contentEncoding","contentSchema"]});var y7=Z((_7)=>{Object.defineProperty(_7,"__esModule",{value:!0});var vO=Gz(),xO=Cz(),_O=j7(),yO=R7(),x7=v7(),gO=[vO.default,xO.default,(0,_O.default)(),yO.default,x7.metadataVocabulary,x7.contentVocabulary];_7.default=gO});var f7=Z((u7)=>{Object.defineProperty(u7,"__esModule",{value:!0});u7.DiscrError=void 0;var g7;(function(Q){Q.Tag="tag",Q.Mapping="mapping"})(g7||(u7.DiscrError=g7={}))});var c7=Z((m7)=>{Object.defineProperty(m7,"__esModule",{value:!0});var f1=v(),L9=f7(),l7=lQ(),hO=I4(),fO=f(),lO={message:({params:{discrError:Q,tagName:Y}})=>Q===L9.DiscrError.Tag?`tag "${Y}" must be string`:`value of tag "${Y}" must be in oneOf`,params:({params:{discrError:Q,tag:Y,tagName:X}})=>f1._`{error: ${Q}, tag: ${X}, tagValue: ${Y}}`},mO={keyword:"discriminator",type:"object",schemaType:"object",error:lO,code(Q){let{gen:Y,data:X,schema:W,parentSchema:G,it:$}=Q,{oneOf:J}=G;if(!$.opts.discriminator)throw Error("discriminator: requires discriminator option");let z=W.propertyName;if(typeof z!="string")throw Error("discriminator: requires propertyName");if(W.mapping)throw Error("discriminator: mapping is not supported");if(!J)throw Error("discriminator: requires oneOf keyword");let H=Y.let("valid",!1),A=Y.const("tag",f1._`${X}${(0,f1.getProperty)(z)}`);Y.if(f1._`typeof ${A} == "string"`,()=>U(),()=>Q.error(!1,{discrError:L9.DiscrError.Tag,tag:A,tagName:z})),Q.ok(H);function U(){let L=D();Y.if(!1);for(let q in L)Y.elseIf(f1._`${A} === ${q}`),Y.assign(H,K(L[q]));Y.else(),Q.error(!1,{discrError:L9.DiscrError.Mapping,tag:A,tagName:z}),Y.endIf()}function K(L){let q=Y.name("valid"),O=Q.subschema({keyword:"oneOf",schemaProp:L},q);return Q.mergeEvaluated(O,f1.Name),q}function D(){var L;let q={},O=M(G),V=!0;for(let x=0;x<J.length;x++){let T=J[x];if((T===null||T===void 0?void 0:T.$ref)&&!(0,fO.schemaHasRulesButRef)(T,$.self.RULES)){let f0=T.$ref;if(T=l7.resolveRef.call($.self,$.schemaEnv.root,$.baseId,f0),T instanceof l7.SchemaEnv)T=T.schema;if(T===void 0)throw new hO.default($.opts.uriResolver,$.baseId,f0)}let _0=(L=T===null||T===void 0?void 0:T.properties)===null||L===void 0?void 0:L[z];if(typeof _0!="object")throw Error(`discriminator: oneOf subschemas (or referenced schemas) must have "properties/${z}"`);V=V&&(O||M(T)),S(_0,x)}if(!V)throw Error(`discriminator: "${z}" must be required`);return q;function M({required:x}){return Array.isArray(x)&&x.includes(z)}function S(x,T){if(x.const)E(x.const,T);else if(x.enum)for(let _0 of x.enum)E(_0,T);else throw Error(`discriminator: "properties/${z}" must have "const" or "enum"`)}function E(x,T){if(typeof x!="string"||x in q)throw Error(`discriminator: "${z}" values must be unique strings`);q[x]=T}}}};m7.default=mO});var p7=Z((Oj,pO)=>{pO.exports={$schema:"http://json-schema.org/draft-07/schema#",$id:"http://json-schema.org/draft-07/schema#",title:"Core schema meta-schema",definitions:{schemaArray:{type:"array",minItems:1,items:{$ref:"#"}},nonNegativeInteger:{type:"integer",minimum:0},nonNegativeIntegerDefault0:{allOf:[{$ref:"#/definitions/nonNegativeInteger"},{default:0}]},simpleTypes:{enum:["array","boolean","integer","null","number","object","string"]},stringArray:{type:"array",items:{type:"string"},uniqueItems:!0,default:[]}},type:["object","boolean"],properties:{$id:{type:"string",format:"uri-reference"},$schema:{type:"string",format:"uri"},$ref:{type:"string",format:"uri-reference"},$comment:{type:"string"},title:{type:"string"},description:{type:"string"},default:!0,readOnly:{type:"boolean",default:!1},examples:{type:"array",items:!0},multipleOf:{type:"number",exclusiveMinimum:0},maximum:{type:"number"},exclusiveMaximum:{type:"number"},minimum:{type:"number"},exclusiveMinimum:{type:"number"},maxLength:{$ref:"#/definitions/nonNegativeInteger"},minLength:{$ref:"#/definitions/nonNegativeIntegerDefault0"},pattern:{type:"string",format:"regex"},additionalItems:{$ref:"#"},items:{anyOf:[{$ref:"#"},{$ref:"#/definitions/schemaArray"}],default:!0},maxItems:{$ref:"#/definitions/nonNegativeInteger"},minItems:{$ref:"#/definitions/nonNegativeIntegerDefault0"},uniqueItems:{type:"boolean",default:!1},contains:{$ref:"#"},maxProperties:{$ref:"#/definitions/nonNegativeInteger"},minProperties:{$ref:"#/definitions/nonNegativeIntegerDefault0"},required:{$ref:"#/definitions/stringArray"},additionalProperties:{$ref:"#"},definitions:{type:"object",additionalProperties:{$ref:"#"},default:{}},properties:{type:"object",additionalProperties:{$ref:"#"},default:{}},patternProperties:{type:"object",additionalProperties:{$ref:"#"},propertyNames:{format:"regex"},default:{}},dependencies:{type:"object",additionalProperties:{anyOf:[{$ref:"#"},{$ref:"#/definitions/stringArray"}]}},propertyNames:{$ref:"#"},const:!0,enum:{type:"array",items:!0,minItems:1,uniqueItems:!0},type:{anyOf:[{$ref:"#/definitions/simpleTypes"},{type:"array",items:{$ref:"#/definitions/simpleTypes"},minItems:1,uniqueItems:!0}]},format:{type:"string"},contentMediaType:{type:"string"},contentEncoding:{type:"string"},if:{$ref:"#"},then:{$ref:"#"},else:{$ref:"#"},allOf:{$ref:"#/definitions/schemaArray"},anyOf:{$ref:"#/definitions/schemaArray"},oneOf:{$ref:"#/definitions/schemaArray"},not:{$ref:"#"}},default:!0}});var q9=Z((M0,F9)=>{Object.defineProperty(M0,"__esModule",{value:!0});M0.MissingRefError=M0.ValidationError=M0.CodeGen=M0.Name=M0.nil=M0.stringify=M0.str=M0._=M0.KeywordCxt=M0.Ajv=void 0;var iO=dJ(),rO=y7(),nO=c7(),i7=p7(),dO=["/properties"],z6="http://json-schema.org/draft-07/schema";class g4 extends iO.default{_addVocabularies(){if(super._addVocabularies(),rO.default.forEach((Q)=>this.addVocabulary(Q)),this.opts.discriminator)this.addKeyword(nO.default)}_addDefaultMetaSchema(){if(super._addDefaultMetaSchema(),!this.opts.meta)return;let Q=this.opts.$data?this.$dataMetaSchema(i7,dO):i7;this.addMetaSchema(Q,z6,!1),this.refs["http://json-schema.org/schema"]=z6}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(z6)?z6:void 0)}}M0.Ajv=g4;F9.exports=M0=g4;F9.exports.Ajv=g4;Object.defineProperty(M0,"__esModule",{value:!0});M0.default=g4;var oO=P4();Object.defineProperty(M0,"KeywordCxt",{enumerable:!0,get:function(){return oO.KeywordCxt}});var l1=v();Object.defineProperty(M0,"_",{enumerable:!0,get:function(){return l1._}});Object.defineProperty(M0,"str",{enumerable:!0,get:function(){return l1.str}});Object.defineProperty(M0,"stringify",{enumerable:!0,get:function(){return l1.stringify}});Object.defineProperty(M0,"nil",{enumerable:!0,get:function(){return l1.nil}});Object.defineProperty(M0,"Name",{enumerable:!0,get:function(){return l1.Name}});Object.defineProperty(M0,"CodeGen",{enumerable:!0,get:function(){return l1.CodeGen}});var tO=hQ();Object.defineProperty(M0,"ValidationError",{enumerable:!0,get:function(){return tO.default}});var aO=I4();Object.defineProperty(M0,"MissingRefError",{enumerable:!0,get:function(){return aO.default}})});var Y5=Z((e7)=>{Object.defineProperty(e7,"__esModule",{value:!0});e7.formatNames=e7.fastFormats=e7.fullFormats=void 0;function u0(Q,Y){return{validate:Q,compare:Y}}e7.fullFormats={date:u0(o7,N9),time:u0(M9(!0),Z9),"date-time":u0(r7(!0),a7),"iso-time":u0(M9(),t7),"iso-date-time":u0(r7(),s7),duration:/^P(?!$)((\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+S)?)?|(\d+W)?)$/,uri:$M,"uri-reference":/^(?:[a-z][a-z0-9+\-.]*:)?(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'"()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?(?:\?(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i,"uri-template":/^(?:(?:[^\x00-\x20"'<>%\\^`{|}]|%[0-9a-f]{2})|\{[+#./;?&=,!@|]?(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?(?:,(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?)*\})*$/i,url:/^(?:https?|ftp):\/\/(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z0-9\u{00a1}-\u{ffff}]+-)*[a-z0-9\u{00a1}-\u{ffff}]+)(?:\.(?:[a-z0-9\u{00a1}-\u{ffff}]+-)*[a-z0-9\u{00a1}-\u{ffff}]+)*(?:\.(?:[a-z\u{00a1}-\u{ffff}]{2,})))(?::\d{2,5})?(?:\/[^\s]*)?$/iu,email:/^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i,hostname:/^(?=.{1,253}\.?$)[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[-0-9a-z]{0,61}[0-9a-z])?)*\.?$/i,ipv4:/^(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)$/,ipv6:/^((([0-9a-f]{1,4}:){7}([0-9a-f]{1,4}|:))|(([0-9a-f]{1,4}:){6}(:[0-9a-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){5}(((:[0-9a-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){4}(((:[0-9a-f]{1,4}){1,3})|((:[0-9a-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){3}(((:[0-9a-f]{1,4}){1,4})|((:[0-9a-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){2}(((:[0-9a-f]{1,4}){1,5})|((:[0-9a-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){1}(((:[0-9a-f]{1,4}){1,6})|((:[0-9a-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9a-f]{1,4}){1,7})|((:[0-9a-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))$/i,regex:DM,uuid:/^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i,"json-pointer":/^(?:\/(?:[^~/]|~0|~1)*)*$/,"json-pointer-uri-fragment":/^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i,"relative-json-pointer":/^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/,byte:JM,int32:{type:"number",validate:AM},int64:{type:"number",validate:UM},float:{type:"number",validate:d7},double:{type:"number",validate:d7},password:!0,binary:!0};e7.fastFormats={...e7.fullFormats,date:u0(/^\d\d\d\d-[0-1]\d-[0-3]\d$/,N9),time:u0(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,Z9),"date-time":u0(/^\d\d\d\d-[0-1]\d-[0-3]\dt(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,a7),"iso-time":u0(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,t7),"iso-date-time":u0(/^\d\d\d\d-[0-1]\d-[0-3]\d[t\s](?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,s7),uri:/^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/)?[^\s]*$/i,"uri-reference":/^(?:(?:[a-z][a-z0-9+\-.]*:)?\/?\/)?(?:[^\\\s#][^\s#]*)?(?:#[^\\\s]*)?$/i,email:/^[a-z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)*$/i};e7.formatNames=Object.keys(e7.fullFormats);function QM(Q){return Q%4===0&&(Q%100!==0||Q%400===0)}var YM=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,XM=[0,31,28,31,30,31,30,31,31,30,31,30,31];function o7(Q){let Y=YM.exec(Q);if(!Y)return!1;let X=+Y[1],W=+Y[2],G=+Y[3];return W>=1&&W<=12&&G>=1&&G<=(W===2&&QM(X)?29:XM[W])}function N9(Q,Y){if(!(Q&&Y))return;if(Q>Y)return 1;if(Q<Y)return-1;return 0}var O9=/^(\d\d):(\d\d):(\d\d(?:\.\d+)?)(z|([+-])(\d\d)(?::?(\d\d))?)?$/i;function M9(Q){return function(X){let W=O9.exec(X);if(!W)return!1;let G=+W[1],$=+W[2],J=+W[3],z=W[4],H=W[5]==="-"?-1:1,A=+(W[6]||0),U=+(W[7]||0);if(A>23||U>59||Q&&!z)return!1;if(G<=23&&$<=59&&J<60)return!0;let K=$-U*H,D=G-A*H-(K<0?1:0);return(D===23||D===-1)&&(K===59||K===-1)&&J<61}}function Z9(Q,Y){if(!(Q&&Y))return;let X=new Date("2020-01-01T"+Q).valueOf(),W=new Date("2020-01-01T"+Y).valueOf();if(!(X&&W))return;return X-W}function t7(Q,Y){if(!(Q&&Y))return;let X=O9.exec(Q),W=O9.exec(Y);if(!(X&&W))return;if(Q=X[1]+X[2]+X[3],Y=W[1]+W[2]+W[3],Q>Y)return 1;if(Q<Y)return-1;return 0}var V9=/t|\s/i;function r7(Q){let Y=M9(Q);return function(W){let G=W.split(V9);return G.length===2&&o7(G[0])&&Y(G[1])}}function a7(Q,Y){if(!(Q&&Y))return;let X=new Date(Q).valueOf(),W=new Date(Y).valueOf();if(!(X&&W))return;return X-W}function s7(Q,Y){if(!(Q&&Y))return;let[X,W]=Q.split(V9),[G,$]=Y.split(V9),J=N9(X,G);if(J===void 0)return;return J||Z9(W,$)}var WM=/\/|:/,GM=/^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)(?:\?(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i;function $M(Q){return WM.test(Q)&&GM.test(Q)}var n7=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/gm;function JM(Q){return n7.lastIndex=0,n7.test(Q)}var zM=-2147483648,HM=2147483647;function AM(Q){return Number.isInteger(Q)&&Q<=HM&&Q>=zM}function UM(Q){return Number.isInteger(Q)}function d7(){return!0}var KM=/[^\\]\\Z/;function DM(Q){if(KM.test(Q))return!1;try{return new RegExp(Q),!0}catch(Y){return!1}}});var W5=Z((X5)=>{Object.defineProperty(X5,"__esModule",{value:!0});X5.formatLimitDefinition=void 0;var LM=q9(),x0=v(),D1=x0.operators,H6={formatMaximum:{okStr:"<=",ok:D1.LTE,fail:D1.GT},formatMinimum:{okStr:">=",ok:D1.GTE,fail:D1.LT},formatExclusiveMaximum:{okStr:"<",ok:D1.LT,fail:D1.GTE},formatExclusiveMinimum:{okStr:">",ok:D1.GT,fail:D1.LTE}},FM={message:({keyword:Q,schemaCode:Y})=>x0.str`should be ${H6[Q].okStr} ${Y}`,params:({keyword:Q,schemaCode:Y})=>x0._`{comparison: ${H6[Q].okStr}, limit: ${Y}}`};X5.formatLimitDefinition={keyword:Object.keys(H6),type:"string",schemaType:"string",$data:!0,error:FM,code(Q){let{gen:Y,data:X,schemaCode:W,keyword:G,it:$}=Q,{opts:J,self:z}=$;if(!J.validateFormats)return;let H=new LM.KeywordCxt($,z.RULES.all.format.definition,"format");if(H.$data)A();else U();function A(){let D=Y.scopeValue("formats",{ref:z.formats,code:J.code.formats}),L=Y.const("fmt",x0._`${D}[${H.schemaCode}]`);Q.fail$data((0,x0.or)(x0._`typeof ${L} != "object"`,x0._`${L} instanceof RegExp`,x0._`typeof ${L}.compare != "function"`,K(L)))}function U(){let D=H.schema,L=z.formats[D];if(!L||L===!0)return;if(typeof L!="object"||L instanceof RegExp||typeof L.compare!="function")throw Error(`"${G}": format "${D}" does not define "compare" function`);let q=Y.scopeValue("formats",{key:D,ref:L,code:J.code.formats?x0._`${J.code.formats}${(0,x0.getProperty)(D)}`:void 0});Q.fail$data(K(q))}function K(D){return x0._`${D}.compare(${X}, ${W}) ${H6[G].fail} 0`}},dependencies:["format"]};var qM=(Q)=>{return Q.addKeyword(X5.formatLimitDefinition),Q};X5.default=qM});var z5=Z((u4,J5)=>{Object.defineProperty(u4,"__esModule",{value:!0});var m1=Y5(),MM=W5(),P9=v(),G5=new P9.Name("fullFormats"),VM=new P9.Name("fastFormats"),I9=(Q,Y={keywords:!0})=>{if(Array.isArray(Y))return $5(Q,Y,m1.fullFormats,G5),Q;let[X,W]=Y.mode==="fast"?[m1.fastFormats,VM]:[m1.fullFormats,G5],G=Y.formats||m1.formatNames;if($5(Q,G,X,W),Y.keywords)(0,MM.default)(Q);return Q};I9.get=(Q,Y="full")=>{let W=(Y==="fast"?m1.fastFormats:m1.fullFormats)[Q];if(!W)throw Error(`Unknown format "${Q}"`);return W};function $5(Q,Y,X,W){var G,$;(G=($=Q.opts.code).formats)!==null&&G!==void 0||($.formats=P9._`require("ajv-formats/dist/formats").${W}`);for(let J of Y)Q.addFormat(J,X[J])}J5.exports=u4=I9;Object.defineProperty(u4,"__esModule",{value:!0});u4.default=I9});import{AsyncLocalStorage as r5}from"node:async_hooks";class L1 extends Error{statusCode;rawDetails;code;context;constructor(Q,Y,X,W,G){super(Q);this.statusCode=Y;this.rawDetails=X;this.code=W;this.context=G;this.name="McpApiError"}}function p5(Q){if(Q instanceof L1)return{message:Q.message,statusCode:Q.statusCode,code:Q.code,rawDetails:Q.rawDetails,context:Q.context};if(Q instanceof Error)return{message:Q.message};return{message:String(Q)}}function i5(Q){let Y=p5(Q),X=Y.message.trim()||"Unknown error",W=X.toLowerCase(),G=Y.rawDetails?.trim()||X;if(Y.context?.title||Y.context?.description||Y.context?.howToFix||Y.context?.docsUrl)return{title:Y.context.title??(Y.statusCode===409?"Request conflict":"API request failed"),description:Y.context.description??X,howToFix:Y.context.howToFix??"Review the details below, adjust the tool input, and retry.",docsUrl:Y.context.docsUrl??"https://docs.sequenzy.com/concepts/mcp",details:G};if(Y.code==="MCP_AUTH_REQUIRED"||W.includes("sequenzy_api_key environment variable is required"))return{title:"Missing MCP API key",description:"The MCP server started without a Sequenzy API key, so it cannot authenticate any tool or resource request.",howToFix:"Add `SEQUENZY_API_KEY` to the MCP server environment, or run `npx @sequenzy/setup` to configure the integration automatically.",docsUrl:"https://docs.sequenzy.com/concepts/mcp",details:G};if(Y.statusCode===401||Y.code==="UNAUTHORIZED")return{title:"Authentication failed",description:"The MCP server reached Sequenzy, but the current API key was rejected.",howToFix:"Replace `SEQUENZY_API_KEY` with a valid personal API key, then restart the MCP client so it reconnects with fresh credentials.",docsUrl:"https://docs.sequenzy.com/authentication",details:G};if(Y.statusCode===403||W.includes("access denied"))return{title:"Access denied",description:"The current API key is valid, but it does not have permission to access the requested company or action.",howToFix:"Use an API key that belongs to the right account, or select a company the key can access before retrying the tool call.",docsUrl:"https://docs.sequenzy.com/authentication",details:G};if(W.includes("no company available")||W.includes("company not found"))return{title:"Company selection required",description:"The MCP server could not resolve a company for this request.",howToFix:"Call `get_account` to inspect available companies, then call `select_company`, or pass `companyId` explicitly in the next tool call.",docsUrl:"https://docs.sequenzy.com/concepts/mcp",details:G};if(Y.statusCode===404||W.includes("not found"))return{title:"Requested resource not found",description:"Sequenzy could not find the requested campaign, template, sequence, company, or subscriber.",howToFix:"List or fetch the resource collection first, then retry the tool with a confirmed ID or email value.",docsUrl:"https://docs.sequenzy.com/concepts/mcp",details:G};if(Y.statusCode===409||W.includes("already exists"))return{title:"Resource already exists",description:"Sequenzy rejected this MCP request because it would create a duplicate resource.",howToFix:"List the existing resources first, reuse the matching resource when appropriate, or retry with a unique name or domain.",docsUrl:"https://docs.sequenzy.com/concepts/mcp",details:G};if(Y.statusCode===429||W.includes("rate limit"))return{title:"Rate limited",description:"Sequenzy temporarily slowed this MCP request because too many requests were sent too quickly.",howToFix:"Wait briefly before retrying. If the client is looping, reduce retries or add backoff before the next tool call.",docsUrl:"https://docs.sequenzy.com/concepts/mcp",details:G};if(Y.code==="NETWORK_ERROR"||W.includes("fetch failed"))return{title:"Network or configuration error",description:"The MCP server could not reach the Sequenzy API from this environment.",howToFix:"Check connectivity and verify `SEQUENZY_API_URL` if you override it in the MCP environment.",docsUrl:"https://docs.sequenzy.com/concepts/mcp",details:G};if(W.includes("unknown tool")||W.includes("unknown resource"))return{title:"Unsupported MCP request",description:"The client asked for a tool or resource name that this Sequenzy MCP server does not expose.",howToFix:"Refresh the client's tool list and call only the names returned by `list_tools` or `list_resources`.",docsUrl:"https://docs.sequenzy.com/concepts/mcp",details:G};if(W.includes("is required")||W.includes("invalid"))return{title:"Invalid MCP input",description:"The tool call was missing a required field or included an invalid value.",howToFix:"Review the tool schema, supply the missing argument, and retry the request with corrected input.",docsUrl:"https://docs.sequenzy.com/concepts/mcp",details:G};if(Y.statusCode&&Y.statusCode>=500)return{title:"Sequenzy server error",description:"The request reached Sequenzy, but the server could not complete it successfully.",howToFix:"Retry once. If it still fails, keep the details below and consult the docs before escalating.",docsUrl:"https://docs.sequenzy.com/concepts/mcp",details:G};return{title:"Tool execution failed",description:"The MCP server could not complete the requested operation.",howToFix:"Review the details below, adjust the tool input or credentials, and retry.",docsUrl:"https://docs.sequenzy.com/concepts/mcp",details:G}}function a0(Q){let Y=i5(Q);return[`Sequenzy MCP error: ${Y.title}`,`Description: ${Y.description}`,`How to fix: ${Y.howToFix}`,`Docs: ${Y.docsUrl}`,`Details: ${Y.details}`].join(`
10
- `)}var n5="https://api.sequenzy.com",p1=new r5,f9=null;function s0(){let Q=p1.getStore();if(Q)return Q.selectedCompanyId??null;return f9}function m4(Q){let Y=p1.getStore();if(Y){Y.selectedCompanyId=Q;return}f9=Q}function q6(Q,Y){return p1.run(Q,Y)}function d5(){return p1.getStore()?.apiUrl??process.env.SEQUENZY_API_URL??n5}function l9(){return p1.getStore()?.apiKey??process.env.SEQUENZY_API_KEY}function m9(){if(l9())return;console.error(a0(new L1("SEQUENZY_API_KEY environment variable is required",401,void 0,"MCP_AUTH_REQUIRED"))),process.exit(1)}function V0(Q,Y){let X=Q[Y];return typeof X==="string"&&X.trim()!==""?X.trim():void 0}function o5(Q){if(Q===void 0)return;if(typeof Q==="string")return Q.trim()||void 0;return JSON.stringify(Q)}function t5(Q){if(!Q.trim())return{message:"Request failed"};try{let Y=JSON.parse(Q);if(typeof Y==="string")return{message:Y};let X=typeof Y.error==="object"&&Y.error!==null?Y.error:void 0,W=V0(Y,"code")??(X?V0(X,"code"):void 0),G=(typeof Y.error==="string"?Y.error:void 0)??(X?V0(X,"message"):void 0)??V0(Y,"message")??V0(Y,"error")??Q,$=V0(Y,"howToFix")??V0(Y,"resolution"),J={...V0(Y,"title")?{title:V0(Y,"title")}:{},...V0(Y,"description")?{description:V0(Y,"description")}:{},...$?{howToFix:$}:{},...V0(Y,"docsUrl")?{docsUrl:V0(Y,"docsUrl")}:{}},z=o5(Y.details);if(Object.keys(J).length>0||z)return{message:G,...W?{code:W}:{},...z?{details:z}:{},...Object.keys(J).length>0?{context:J}:{}};if(typeof Y.error==="string")return{message:Y.error,...W?{code:W}:{}};if(X)return{message:G,...W?{code:W}:{}};return{message:G,...W?{code:W}:{}}}catch{return{message:Q}}}async function N(Q,Y,X,W){let G=l9();if(!G)throw new L1("SEQUENZY_API_KEY environment variable is required",401,void 0,"MCP_AUTH_REQUIRED");let $={"Content-Type":"application/json",Authorization:`Bearer ${G}`},J=W??s0();if(J)$["x-company-id"]=J;let z;try{z=await fetch(`${d5()}${Y}`,{method:Q,headers:$,body:X?JSON.stringify(X):void 0})}catch(H){throw new L1(H instanceof Error?H.message:"Failed to reach Sequenzy API",0,void 0,"NETWORK_ERROR")}if(!z.ok){let H=await z.text(),A=t5(H);throw new L1(A.message,z.status,A.details??H,A.code,A.context)}return z.json()}var GV=Object.freeze({status:"aborted"});function F(Q,Y,X){function W(z,H){var A;Object.defineProperty(z,"_zod",{value:z._zod??{},enumerable:!1}),(A=z._zod).traits??(A.traits=new Set),z._zod.traits.add(Q),Y(z,H);for(let U in J.prototype)if(!(U in z))Object.defineProperty(z,U,{value:J.prototype[U].bind(z)});z._zod.constr=J,z._zod.def=H}let G=X?.Parent??Object;class $ extends G{}Object.defineProperty($,"name",{value:Q});function J(z){var H;let A=X?.Parent?new $:this;W(A,z),(H=A._zod).deferred??(H.deferred=[]);for(let U of A._zod.deferred)U();return A}return Object.defineProperty(J,"init",{value:W}),Object.defineProperty(J,Symbol.hasInstance,{value:(z)=>{if(X?.Parent&&z instanceof X.Parent)return!0;return z?._zod?.traits?.has(Q)}}),Object.defineProperty(J,"name",{value:Q}),J}var $V=Symbol("zod_brand");class l0 extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class i1 extends Error{constructor(Q){super(`Encountered unidirectional transform during encode: ${Q}`);this.name="ZodEncodeError"}}var c4={};function w0(Q){if(Q)Object.assign(c4,Q);return c4}var h={};h9(h,{unwrapMessage:()=>r1,uint8ArrayToHex:()=>ZH,uint8ArrayToBase64url:()=>VH,uint8ArrayToBase64:()=>o9,stringifyPrimitive:()=>n4,shallowClone:()=>p9,safeExtend:()=>BH,required:()=>qH,randomString:()=>JH,propertyKeyTypes:()=>Z6,promiseAllObject:()=>$H,primitiveTypes:()=>i9,prefixIssues:()=>c0,pick:()=>UH,partial:()=>FH,optionalKeys:()=>w6,omit:()=>KH,objectClone:()=>XH,numKeys:()=>zH,nullish:()=>n1,normalizeParams:()=>j,mergeDefs:()=>Q1,merge:()=>LH,jsonStringifyReplacer:()=>P1,joinValues:()=>p4,issue:()=>j1,isPlainObject:()=>Y1,isObject:()=>F1,hexToUint8Array:()=>NH,getSizableOrigin:()=>n9,getParsedType:()=>HH,getLengthableOrigin:()=>o1,getEnumValues:()=>M6,getElementAtPath:()=>GH,floatSafeRemainder:()=>V6,finalizeIssue:()=>T0,extend:()=>DH,escapeRegex:()=>m0,esc:()=>i4,defineLazy:()=>m,createTransparentProxy:()=>AH,cloneDef:()=>WH,clone:()=>E0,cleanRegex:()=>d1,cleanEnum:()=>OH,captureStackTrace:()=>r4,cached:()=>I1,base64urlToUint8Array:()=>MH,base64ToUint8Array:()=>d9,assignProp:()=>e0,assertNotEqual:()=>s5,assertNever:()=>QH,assertIs:()=>e5,assertEqual:()=>a5,assert:()=>YH,allowsEval:()=>N6,aborted:()=>X1,NUMBER_FORMAT_RANGES:()=>b6,Class:()=>t9,BIGINT_FORMAT_RANGES:()=>r9});function a5(Q){return Q}function s5(Q){return Q}function e5(Q){}function QH(Q){throw Error()}function YH(Q){}function M6(Q){let Y=Object.values(Q).filter((W)=>typeof W==="number");return Object.entries(Q).filter(([W,G])=>Y.indexOf(+W)===-1).map(([W,G])=>G)}function p4(Q,Y="|"){return Q.map((X)=>n4(X)).join(Y)}function P1(Q,Y){if(typeof Y==="bigint")return Y.toString();return Y}function I1(Q){return{get value(){{let X=Q();return Object.defineProperty(this,"value",{value:X}),X}throw Error("cached value already set")}}}function n1(Q){return Q===null||Q===void 0}function d1(Q){let Y=Q.startsWith("^")?1:0,X=Q.endsWith("$")?Q.length-1:Q.length;return Q.slice(Y,X)}function V6(Q,Y){let X=(Q.toString().split(".")[1]||"").length,W=Y.toString(),G=(W.split(".")[1]||"").length;if(G===0&&/\d?e-\d?/.test(W)){let H=W.match(/\d?e-(\d?)/);if(H?.[1])G=Number.parseInt(H[1])}let $=X>G?X:G,J=Number.parseInt(Q.toFixed($).replace(".","")),z=Number.parseInt(Y.toFixed($).replace(".",""));return J%z/10**$}var c9=Symbol("evaluating");function m(Q,Y,X){let W=void 0;Object.defineProperty(Q,Y,{get(){if(W===c9)return;if(W===void 0)W=c9,W=X();return W},set(G){Object.defineProperty(Q,Y,{value:G})},configurable:!0})}function XH(Q){return Object.create(Object.getPrototypeOf(Q),Object.getOwnPropertyDescriptors(Q))}function e0(Q,Y,X){Object.defineProperty(Q,Y,{value:X,writable:!0,enumerable:!0,configurable:!0})}function Q1(...Q){let Y={};for(let X of Q){let W=Object.getOwnPropertyDescriptors(X);Object.assign(Y,W)}return Object.defineProperties({},Y)}function WH(Q){return Q1(Q._zod.def)}function GH(Q,Y){if(!Y)return Q;return Y.reduce((X,W)=>X?.[W],Q)}function $H(Q){let Y=Object.keys(Q),X=Y.map((W)=>Q[W]);return Promise.all(X).then((W)=>{let G={};for(let $=0;$<Y.length;$++)G[Y[$]]=W[$];return G})}function JH(Q=10){let X="";for(let W=0;W<Q;W++)X+="abcdefghijklmnopqrstuvwxyz"[Math.floor(Math.random()*26)];return X}function i4(Q){return JSON.stringify(Q)}var r4="captureStackTrace"in Error?Error.captureStackTrace:(...Q)=>{};function F1(Q){return typeof Q==="object"&&Q!==null&&!Array.isArray(Q)}var N6=I1(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{return new Function(""),!0}catch(Q){return!1}});function Y1(Q){if(F1(Q)===!1)return!1;let Y=Q.constructor;if(Y===void 0)return!0;let X=Y.prototype;if(F1(X)===!1)return!1;if(Object.prototype.hasOwnProperty.call(X,"isPrototypeOf")===!1)return!1;return!0}function p9(Q){if(Y1(Q))return{...Q};if(Array.isArray(Q))return[...Q];return Q}function zH(Q){let Y=0;for(let X in Q)if(Object.prototype.hasOwnProperty.call(Q,X))Y++;return Y}var HH=(Q)=>{let Y=typeof Q;switch(Y){case"undefined":return"undefined";case"string":return"string";case"number":return Number.isNaN(Q)?"nan":"number";case"boolean":return"boolean";case"function":return"function";case"bigint":return"bigint";case"symbol":return"symbol";case"object":if(Array.isArray(Q))return"array";if(Q===null)return"null";if(Q.then&&typeof Q.then==="function"&&Q.catch&&typeof Q.catch==="function")return"promise";if(typeof Map<"u"&&Q instanceof Map)return"map";if(typeof Set<"u"&&Q instanceof Set)return"set";if(typeof Date<"u"&&Q instanceof Date)return"date";if(typeof File<"u"&&Q instanceof File)return"file";return"object";default:throw Error(`Unknown data type: ${Y}`)}},Z6=new Set(["string","number","symbol"]),i9=new Set(["string","number","bigint","boolean","symbol","undefined"]);function m0(Q){return Q.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function E0(Q,Y,X){let W=new Q._zod.constr(Y??Q._zod.def);if(!Y||X?.parent)W._zod.parent=Q;return W}function j(Q){let Y=Q;if(!Y)return{};if(typeof Y==="string")return{error:()=>Y};if(Y?.message!==void 0){if(Y?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");Y.error=Y.message}if(delete Y.message,typeof Y.error==="string")return{...Y,error:()=>Y.error};return Y}function AH(Q){let Y;return new Proxy({},{get(X,W,G){return Y??(Y=Q()),Reflect.get(Y,W,G)},set(X,W,G,$){return Y??(Y=Q()),Reflect.set(Y,W,G,$)},has(X,W){return Y??(Y=Q()),Reflect.has(Y,W)},deleteProperty(X,W){return Y??(Y=Q()),Reflect.deleteProperty(Y,W)},ownKeys(X){return Y??(Y=Q()),Reflect.ownKeys(Y)},getOwnPropertyDescriptor(X,W){return Y??(Y=Q()),Reflect.getOwnPropertyDescriptor(Y,W)},defineProperty(X,W,G){return Y??(Y=Q()),Reflect.defineProperty(Y,W,G)}})}function n4(Q){if(typeof Q==="bigint")return Q.toString()+"n";if(typeof Q==="string")return`"${Q}"`;return`${Q}`}function w6(Q){return Object.keys(Q).filter((Y)=>{return Q[Y]._zod.optin==="optional"&&Q[Y]._zod.optout==="optional"})}var b6={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-340282346638528860000000000000000000000,340282346638528860000000000000000000000],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},r9={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function UH(Q,Y){let X=Q._zod.def,W=Q1(Q._zod.def,{get shape(){let G={};for(let $ in Y){if(!($ in X.shape))throw Error(`Unrecognized key: "${$}"`);if(!Y[$])continue;G[$]=X.shape[$]}return e0(this,"shape",G),G},checks:[]});return E0(Q,W)}function KH(Q,Y){let X=Q._zod.def,W=Q1(Q._zod.def,{get shape(){let G={...Q._zod.def.shape};for(let $ in Y){if(!($ in X.shape))throw Error(`Unrecognized key: "${$}"`);if(!Y[$])continue;delete G[$]}return e0(this,"shape",G),G},checks:[]});return E0(Q,W)}function DH(Q,Y){if(!Y1(Y))throw Error("Invalid input to extend: expected a plain object");let X=Q._zod.def.checks;if(X&&X.length>0)throw Error("Object schemas containing refinements cannot be extended. Use `.safeExtend()` instead.");let G=Q1(Q._zod.def,{get shape(){let $={...Q._zod.def.shape,...Y};return e0(this,"shape",$),$},checks:[]});return E0(Q,G)}function BH(Q,Y){if(!Y1(Y))throw Error("Invalid input to safeExtend: expected a plain object");let X={...Q._zod.def,get shape(){let W={...Q._zod.def.shape,...Y};return e0(this,"shape",W),W},checks:Q._zod.def.checks};return E0(Q,X)}function LH(Q,Y){let X=Q1(Q._zod.def,{get shape(){let W={...Q._zod.def.shape,...Y._zod.def.shape};return e0(this,"shape",W),W},get catchall(){return Y._zod.def.catchall},checks:[]});return E0(Q,X)}function FH(Q,Y,X){let W=Q1(Y._zod.def,{get shape(){let G=Y._zod.def.shape,$={...G};if(X)for(let J in X){if(!(J in G))throw Error(`Unrecognized key: "${J}"`);if(!X[J])continue;$[J]=Q?new Q({type:"optional",innerType:G[J]}):G[J]}else for(let J in G)$[J]=Q?new Q({type:"optional",innerType:G[J]}):G[J];return e0(this,"shape",$),$},checks:[]});return E0(Y,W)}function qH(Q,Y,X){let W=Q1(Y._zod.def,{get shape(){let G=Y._zod.def.shape,$={...G};if(X)for(let J in X){if(!(J in $))throw Error(`Unrecognized key: "${J}"`);if(!X[J])continue;$[J]=new Q({type:"nonoptional",innerType:G[J]})}else for(let J in G)$[J]=new Q({type:"nonoptional",innerType:G[J]});return e0(this,"shape",$),$},checks:[]});return E0(Y,W)}function X1(Q,Y=0){if(Q.aborted===!0)return!0;for(let X=Y;X<Q.issues.length;X++)if(Q.issues[X]?.continue!==!0)return!0;return!1}function c0(Q,Y){return Y.map((X)=>{var W;return(W=X).path??(W.path=[]),X.path.unshift(Q),X})}function r1(Q){return typeof Q==="string"?Q:Q?.message}function T0(Q,Y,X){let W={...Q,path:Q.path??[]};if(!Q.message){let G=r1(Q.inst?._zod.def?.error?.(Q))??r1(Y?.error?.(Q))??r1(X.customError?.(Q))??r1(X.localeError?.(Q))??"Invalid input";W.message=G}if(delete W.inst,delete W.continue,!Y?.reportInput)delete W.input;return W}function n9(Q){if(Q instanceof Set)return"set";if(Q instanceof Map)return"map";if(Q instanceof File)return"file";return"unknown"}function o1(Q){if(Array.isArray(Q))return"array";if(typeof Q==="string")return"string";return"unknown"}function j1(...Q){let[Y,X,W]=Q;if(typeof Y==="string")return{message:Y,code:"custom",input:X,inst:W};return{...Y}}function OH(Q){return Object.entries(Q).filter(([Y,X])=>{return Number.isNaN(Number.parseInt(Y,10))}).map((Y)=>Y[1])}function d9(Q){let Y=atob(Q),X=new Uint8Array(Y.length);for(let W=0;W<Y.length;W++)X[W]=Y.charCodeAt(W);return X}function o9(Q){let Y="";for(let X=0;X<Q.length;X++)Y+=String.fromCharCode(Q[X]);return btoa(Y)}function MH(Q){let Y=Q.replace(/-/g,"+").replace(/_/g,"/"),X="=".repeat((4-Y.length%4)%4);return d9(Y+X)}function VH(Q){return o9(Q).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function NH(Q){let Y=Q.replace(/^0x/,"");if(Y.length%2!==0)throw Error("Invalid hex string length");let X=new Uint8Array(Y.length/2);for(let W=0;W<Y.length;W+=2)X[W/2]=Number.parseInt(Y.slice(W,W+2),16);return X}function ZH(Q){return Array.from(Q).map((Y)=>Y.toString(16).padStart(2,"0")).join("")}class t9{constructor(...Q){}}var a9=(Q,Y)=>{Q.name="$ZodError",Object.defineProperty(Q,"_zod",{value:Q._zod,enumerable:!1}),Object.defineProperty(Q,"issues",{value:Y,enumerable:!1}),Q.message=JSON.stringify(Y,P1,2),Object.defineProperty(Q,"toString",{value:()=>Q.message,enumerable:!1})},d4=F("$ZodError",a9),P6=F("$ZodError",a9,{Parent:Error});function s9(Q,Y=(X)=>X.message){let X={},W=[];for(let G of Q.issues)if(G.path.length>0)X[G.path[0]]=X[G.path[0]]||[],X[G.path[0]].push(Y(G));else W.push(Y(G));return{formErrors:W,fieldErrors:X}}function e9(Q,Y=(X)=>X.message){let X={_errors:[]},W=(G)=>{for(let $ of G.issues)if($.code==="invalid_union"&&$.errors.length)$.errors.map((J)=>W({issues:J}));else if($.code==="invalid_key")W({issues:$.issues});else if($.code==="invalid_element")W({issues:$.issues});else if($.path.length===0)X._errors.push(Y($));else{let J=X,z=0;while(z<$.path.length){let H=$.path[z];if(z!==$.path.length-1)J[H]=J[H]||{_errors:[]};else J[H]=J[H]||{_errors:[]},J[H]._errors.push(Y($));J=J[H],z++}}};return W(Q),X}var o4=(Q)=>(Y,X,W,G)=>{let $=W?Object.assign(W,{async:!1}):{async:!1},J=Y._zod.run({value:X,issues:[]},$);if(J instanceof Promise)throw new l0;if(J.issues.length){let z=new(G?.Err??Q)(J.issues.map((H)=>T0(H,$,w0())));throw r4(z,G?.callee),z}return J.value};var t4=(Q)=>async(Y,X,W,G)=>{let $=W?Object.assign(W,{async:!0}):{async:!0},J=Y._zod.run({value:X,issues:[]},$);if(J instanceof Promise)J=await J;if(J.issues.length){let z=new(G?.Err??Q)(J.issues.map((H)=>T0(H,$,w0())));throw r4(z,G?.callee),z}return J.value};var t1=(Q)=>(Y,X,W)=>{let G=W?{...W,async:!1}:{async:!1},$=Y._zod.run({value:X,issues:[]},G);if($ instanceof Promise)throw new l0;return $.issues.length?{success:!1,error:new(Q??d4)($.issues.map((J)=>T0(J,G,w0())))}:{success:!0,data:$.value}},a1=t1(P6),s1=(Q)=>async(Y,X,W)=>{let G=W?Object.assign(W,{async:!0}):{async:!0},$=Y._zod.run({value:X,issues:[]},G);if($ instanceof Promise)$=await $;return $.issues.length?{success:!1,error:new Q($.issues.map((J)=>T0(J,G,w0())))}:{success:!0,data:$.value}},a4=s1(P6),Q8=(Q)=>(Y,X,W)=>{let G=W?Object.assign(W,{direction:"backward"}):{direction:"backward"};return o4(Q)(Y,X,G)};var Y8=(Q)=>(Y,X,W)=>{return o4(Q)(Y,X,W)};var X8=(Q)=>async(Y,X,W)=>{let G=W?Object.assign(W,{direction:"backward"}):{direction:"backward"};return t4(Q)(Y,X,G)};var W8=(Q)=>async(Y,X,W)=>{return t4(Q)(Y,X,W)};var G8=(Q)=>(Y,X,W)=>{let G=W?Object.assign(W,{direction:"backward"}):{direction:"backward"};return t1(Q)(Y,X,G)};var $8=(Q)=>(Y,X,W)=>{return t1(Q)(Y,X,W)};var J8=(Q)=>async(Y,X,W)=>{let G=W?Object.assign(W,{direction:"backward"}):{direction:"backward"};return s1(Q)(Y,X,G)};var z8=(Q)=>async(Y,X,W)=>{return s1(Q)(Y,X,W)};var H8=/^[cC][^\s-]{8,}$/,A8=/^[0-9a-z]+$/,U8=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,K8=/^[0-9a-vA-V]{20}$/,D8=/^[A-Za-z0-9]{27}$/,B8=/^[a-zA-Z0-9_-]{21}$/,L8=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;var F8=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,I6=(Q)=>{if(!Q)return/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/;return new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${Q}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`)};var q8=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;function O8(){return new RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")}var M8=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,V8=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,N8=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,Z8=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,w8=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,j6=/^[A-Za-z0-9_-]*$/,b8=/^(?=.{1,253}\.?$)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[-0-9a-zA-Z]{0,61}[0-9a-zA-Z])?)*\.?$/;var P8=/^\+(?:[0-9]){6,14}[0-9]$/,I8="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",j8=new RegExp(`^${I8}$`);function E8(Q){return typeof Q.precision==="number"?Q.precision===-1?"(?:[01]\\d|2[0-3]):[0-5]\\d":Q.precision===0?"(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d":`(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d\\.\\d{${Q.precision}}`:"(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?"}function T8(Q){return new RegExp(`^${E8(Q)}$`)}function S8(Q){let Y=E8({precision:Q.precision}),X=["Z"];if(Q.local)X.push("");if(Q.offset)X.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");let W=`${Y}(?:${X.join("|")})`;return new RegExp(`^${I8}T(?:${W})$`)}var R8=(Q)=>{let Y=Q?`[\\s\\S]{${Q?.minimum??0},${Q?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${Y}$`)};var C8=/^-?\d+$/,k8=/^-?\d+(?:\.\d+)?/,v8=/^(?:true|false)$/i,x8=/^null$/i;var _8=/^[^A-Z]*$/,y8=/^[^a-z]*$/;var W0=F("$ZodCheck",(Q,Y)=>{var X;Q._zod??(Q._zod={}),Q._zod.def=Y,(X=Q._zod).onattach??(X.onattach=[])}),g8={number:"number",bigint:"bigint",object:"date"},E6=F("$ZodCheckLessThan",(Q,Y)=>{W0.init(Q,Y);let X=g8[typeof Y.value];Q._zod.onattach.push((W)=>{let G=W._zod.bag,$=(Y.inclusive?G.maximum:G.exclusiveMaximum)??Number.POSITIVE_INFINITY;if(Y.value<$)if(Y.inclusive)G.maximum=Y.value;else G.exclusiveMaximum=Y.value}),Q._zod.check=(W)=>{if(Y.inclusive?W.value<=Y.value:W.value<Y.value)return;W.issues.push({origin:X,code:"too_big",maximum:Y.value,input:W.value,inclusive:Y.inclusive,inst:Q,continue:!Y.abort})}}),T6=F("$ZodCheckGreaterThan",(Q,Y)=>{W0.init(Q,Y);let X=g8[typeof Y.value];Q._zod.onattach.push((W)=>{let G=W._zod.bag,$=(Y.inclusive?G.minimum:G.exclusiveMinimum)??Number.NEGATIVE_INFINITY;if(Y.value>$)if(Y.inclusive)G.minimum=Y.value;else G.exclusiveMinimum=Y.value}),Q._zod.check=(W)=>{if(Y.inclusive?W.value>=Y.value:W.value>Y.value)return;W.issues.push({origin:X,code:"too_small",minimum:Y.value,input:W.value,inclusive:Y.inclusive,inst:Q,continue:!Y.abort})}}),u8=F("$ZodCheckMultipleOf",(Q,Y)=>{W0.init(Q,Y),Q._zod.onattach.push((X)=>{var W;(W=X._zod.bag).multipleOf??(W.multipleOf=Y.value)}),Q._zod.check=(X)=>{if(typeof X.value!==typeof Y.value)throw Error("Cannot mix number and bigint in multiple_of check.");if(typeof X.value==="bigint"?X.value%Y.value===BigInt(0):V6(X.value,Y.value)===0)return;X.issues.push({origin:typeof X.value,code:"not_multiple_of",divisor:Y.value,input:X.value,inst:Q,continue:!Y.abort})}}),h8=F("$ZodCheckNumberFormat",(Q,Y)=>{W0.init(Q,Y),Y.format=Y.format||"float64";let X=Y.format?.includes("int"),W=X?"int":"number",[G,$]=b6[Y.format];Q._zod.onattach.push((J)=>{let z=J._zod.bag;if(z.format=Y.format,z.minimum=G,z.maximum=$,X)z.pattern=C8}),Q._zod.check=(J)=>{let z=J.value;if(X){if(!Number.isInteger(z)){J.issues.push({expected:W,format:Y.format,code:"invalid_type",continue:!1,input:z,inst:Q});return}if(!Number.isSafeInteger(z)){if(z>0)J.issues.push({input:z,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:Q,origin:W,continue:!Y.abort});else J.issues.push({input:z,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:Q,origin:W,continue:!Y.abort});return}}if(z<G)J.issues.push({origin:"number",input:z,code:"too_small",minimum:G,inclusive:!0,inst:Q,continue:!Y.abort});if(z>$)J.issues.push({origin:"number",input:z,code:"too_big",maximum:$,inst:Q})}});var f8=F("$ZodCheckMaxLength",(Q,Y)=>{var X;W0.init(Q,Y),(X=Q._zod.def).when??(X.when=(W)=>{let G=W.value;return!n1(G)&&G.length!==void 0}),Q._zod.onattach.push((W)=>{let G=W._zod.bag.maximum??Number.POSITIVE_INFINITY;if(Y.maximum<G)W._zod.bag.maximum=Y.maximum}),Q._zod.check=(W)=>{let G=W.value;if(G.length<=Y.maximum)return;let J=o1(G);W.issues.push({origin:J,code:"too_big",maximum:Y.maximum,inclusive:!0,input:G,inst:Q,continue:!Y.abort})}}),l8=F("$ZodCheckMinLength",(Q,Y)=>{var X;W0.init(Q,Y),(X=Q._zod.def).when??(X.when=(W)=>{let G=W.value;return!n1(G)&&G.length!==void 0}),Q._zod.onattach.push((W)=>{let G=W._zod.bag.minimum??Number.NEGATIVE_INFINITY;if(Y.minimum>G)W._zod.bag.minimum=Y.minimum}),Q._zod.check=(W)=>{let G=W.value;if(G.length>=Y.minimum)return;let J=o1(G);W.issues.push({origin:J,code:"too_small",minimum:Y.minimum,inclusive:!0,input:G,inst:Q,continue:!Y.abort})}}),m8=F("$ZodCheckLengthEquals",(Q,Y)=>{var X;W0.init(Q,Y),(X=Q._zod.def).when??(X.when=(W)=>{let G=W.value;return!n1(G)&&G.length!==void 0}),Q._zod.onattach.push((W)=>{let G=W._zod.bag;G.minimum=Y.length,G.maximum=Y.length,G.length=Y.length}),Q._zod.check=(W)=>{let G=W.value,$=G.length;if($===Y.length)return;let J=o1(G),z=$>Y.length;W.issues.push({origin:J,...z?{code:"too_big",maximum:Y.length}:{code:"too_small",minimum:Y.length},inclusive:!0,exact:!0,input:W.value,inst:Q,continue:!Y.abort})}}),e1=F("$ZodCheckStringFormat",(Q,Y)=>{var X,W;if(W0.init(Q,Y),Q._zod.onattach.push((G)=>{let $=G._zod.bag;if($.format=Y.format,Y.pattern)$.patterns??($.patterns=new Set),$.patterns.add(Y.pattern)}),Y.pattern)(X=Q._zod).check??(X.check=(G)=>{if(Y.pattern.lastIndex=0,Y.pattern.test(G.value))return;G.issues.push({origin:"string",code:"invalid_format",format:Y.format,input:G.value,...Y.pattern?{pattern:Y.pattern.toString()}:{},inst:Q,continue:!Y.abort})});else(W=Q._zod).check??(W.check=()=>{})}),c8=F("$ZodCheckRegex",(Q,Y)=>{e1.init(Q,Y),Q._zod.check=(X)=>{if(Y.pattern.lastIndex=0,Y.pattern.test(X.value))return;X.issues.push({origin:"string",code:"invalid_format",format:"regex",input:X.value,pattern:Y.pattern.toString(),inst:Q,continue:!Y.abort})}}),p8=F("$ZodCheckLowerCase",(Q,Y)=>{Y.pattern??(Y.pattern=_8),e1.init(Q,Y)}),i8=F("$ZodCheckUpperCase",(Q,Y)=>{Y.pattern??(Y.pattern=y8),e1.init(Q,Y)}),r8=F("$ZodCheckIncludes",(Q,Y)=>{W0.init(Q,Y);let X=m0(Y.includes),W=new RegExp(typeof Y.position==="number"?`^.{${Y.position}}${X}`:X);Y.pattern=W,Q._zod.onattach.push((G)=>{let $=G._zod.bag;$.patterns??($.patterns=new Set),$.patterns.add(W)}),Q._zod.check=(G)=>{if(G.value.includes(Y.includes,Y.position))return;G.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:Y.includes,input:G.value,inst:Q,continue:!Y.abort})}}),n8=F("$ZodCheckStartsWith",(Q,Y)=>{W0.init(Q,Y);let X=new RegExp(`^${m0(Y.prefix)}.*`);Y.pattern??(Y.pattern=X),Q._zod.onattach.push((W)=>{let G=W._zod.bag;G.patterns??(G.patterns=new Set),G.patterns.add(X)}),Q._zod.check=(W)=>{if(W.value.startsWith(Y.prefix))return;W.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:Y.prefix,input:W.value,inst:Q,continue:!Y.abort})}}),d8=F("$ZodCheckEndsWith",(Q,Y)=>{W0.init(Q,Y);let X=new RegExp(`.*${m0(Y.suffix)}$`);Y.pattern??(Y.pattern=X),Q._zod.onattach.push((W)=>{let G=W._zod.bag;G.patterns??(G.patterns=new Set),G.patterns.add(X)}),Q._zod.check=(W)=>{if(W.value.endsWith(Y.suffix))return;W.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:Y.suffix,input:W.value,inst:Q,continue:!Y.abort})}});var o8=F("$ZodCheckOverwrite",(Q,Y)=>{W0.init(Q,Y),Q._zod.check=(X)=>{X.value=Y.tx(X.value)}});class S6{constructor(Q=[]){if(this.content=[],this.indent=0,this)this.args=Q}indented(Q){this.indent+=1,Q(this),this.indent-=1}write(Q){if(typeof Q==="function"){Q(this,{execution:"sync"}),Q(this,{execution:"async"});return}let X=Q.split(`
10
+ `)}var n5="https://api.sequenzy.com",p1=new r5,f9=null;function s0(){let Q=p1.getStore();if(Q)return Q.selectedCompanyId??null;return f9}function m4(Q){let Y=p1.getStore();if(Y){Y.selectedCompanyId=Q;return}f9=Q}function q6(Q,Y){return p1.run(Q,Y)}function d5(){return p1.getStore()?.apiUrl??process.env.SEQUENZY_API_URL??n5}function l9(){return p1.getStore()?.apiKey??process.env.SEQUENZY_API_KEY}function m9(){if(l9())return;console.error(a0(new L1("SEQUENZY_API_KEY environment variable is required",401,void 0,"MCP_AUTH_REQUIRED"))),process.exit(1)}function V0(Q,Y){let X=Q[Y];return typeof X==="string"&&X.trim()!==""?X.trim():void 0}function o5(Q){if(Q===void 0)return;if(typeof Q==="string")return Q.trim()||void 0;return JSON.stringify(Q)}function t5(Q){if(!Q.trim())return{message:"Request failed"};try{let Y=JSON.parse(Q);if(typeof Y==="string")return{message:Y};let X=typeof Y.error==="object"&&Y.error!==null?Y.error:void 0,W=V0(Y,"code")??(X?V0(X,"code"):void 0),G=(typeof Y.error==="string"?Y.error:void 0)??(X?V0(X,"message"):void 0)??V0(Y,"message")??V0(Y,"error")??Q,$=V0(Y,"howToFix")??V0(Y,"resolution"),J={...V0(Y,"title")?{title:V0(Y,"title")}:{},...V0(Y,"description")?{description:V0(Y,"description")}:{},...$?{howToFix:$}:{},...V0(Y,"docsUrl")?{docsUrl:V0(Y,"docsUrl")}:{}},z=o5(Y.details);if(Object.keys(J).length>0||z)return{message:G,...W?{code:W}:{},...z?{details:z}:{},...Object.keys(J).length>0?{context:J}:{}};if(typeof Y.error==="string")return{message:Y.error,...W?{code:W}:{}};if(X)return{message:G,...W?{code:W}:{}};return{message:G,...W?{code:W}:{}}}catch{return{message:Q}}}async function N(Q,Y,X,W){let G=l9();if(!G)throw new L1("SEQUENZY_API_KEY environment variable is required",401,void 0,"MCP_AUTH_REQUIRED");let $={"Content-Type":"application/json",Authorization:`Bearer ${G}`},J=W??s0();if(J)$["x-company-id"]=J;let z;try{z=await fetch(`${d5()}${Y}`,{method:Q,headers:$,body:X?JSON.stringify(X):void 0})}catch(H){throw new L1(H instanceof Error?H.message:"Failed to reach Sequenzy API",0,void 0,"NETWORK_ERROR")}if(!z.ok){let H=await z.text(),A=t5(H);throw new L1(A.message,z.status,A.details??H,A.code,A.context)}return z.json()}var GV=Object.freeze({status:"aborted"});function F(Q,Y,X){function W(z,H){var A;Object.defineProperty(z,"_zod",{value:z._zod??{},enumerable:!1}),(A=z._zod).traits??(A.traits=new Set),z._zod.traits.add(Q),Y(z,H);for(let U in J.prototype)if(!(U in z))Object.defineProperty(z,U,{value:J.prototype[U].bind(z)});z._zod.constr=J,z._zod.def=H}let G=X?.Parent??Object;class $ extends G{}Object.defineProperty($,"name",{value:Q});function J(z){var H;let A=X?.Parent?new $:this;W(A,z),(H=A._zod).deferred??(H.deferred=[]);for(let U of A._zod.deferred)U();return A}return Object.defineProperty(J,"init",{value:W}),Object.defineProperty(J,Symbol.hasInstance,{value:(z)=>{if(X?.Parent&&z instanceof X.Parent)return!0;return z?._zod?.traits?.has(Q)}}),Object.defineProperty(J,"name",{value:Q}),J}var $V=Symbol("zod_brand");class l0 extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class i1 extends Error{constructor(Q){super(`Encountered unidirectional transform during encode: ${Q}`);this.name="ZodEncodeError"}}var c4={};function w0(Q){if(Q)Object.assign(c4,Q);return c4}var h={};h9(h,{unwrapMessage:()=>r1,uint8ArrayToHex:()=>ZH,uint8ArrayToBase64url:()=>VH,uint8ArrayToBase64:()=>o9,stringifyPrimitive:()=>n4,shallowClone:()=>p9,safeExtend:()=>BH,required:()=>qH,randomString:()=>JH,propertyKeyTypes:()=>Z6,promiseAllObject:()=>$H,primitiveTypes:()=>i9,prefixIssues:()=>c0,pick:()=>UH,partial:()=>FH,optionalKeys:()=>w6,omit:()=>KH,objectClone:()=>XH,numKeys:()=>zH,nullish:()=>n1,normalizeParams:()=>j,mergeDefs:()=>Q1,merge:()=>LH,jsonStringifyReplacer:()=>P1,joinValues:()=>p4,issue:()=>j1,isPlainObject:()=>Y1,isObject:()=>F1,hexToUint8Array:()=>NH,getSizableOrigin:()=>n9,getParsedType:()=>HH,getLengthableOrigin:()=>o1,getEnumValues:()=>M6,getElementAtPath:()=>GH,floatSafeRemainder:()=>V6,finalizeIssue:()=>T0,extend:()=>DH,escapeRegex:()=>m0,esc:()=>i4,defineLazy:()=>m,createTransparentProxy:()=>AH,cloneDef:()=>WH,clone:()=>E0,cleanRegex:()=>d1,cleanEnum:()=>OH,captureStackTrace:()=>r4,cached:()=>I1,base64urlToUint8Array:()=>MH,base64ToUint8Array:()=>d9,assignProp:()=>e0,assertNotEqual:()=>s5,assertNever:()=>QH,assertIs:()=>e5,assertEqual:()=>a5,assert:()=>YH,allowsEval:()=>N6,aborted:()=>X1,NUMBER_FORMAT_RANGES:()=>b6,Class:()=>t9,BIGINT_FORMAT_RANGES:()=>r9});function a5(Q){return Q}function s5(Q){return Q}function e5(Q){}function QH(Q){throw Error()}function YH(Q){}function M6(Q){let Y=Object.values(Q).filter((W)=>typeof W==="number");return Object.entries(Q).filter(([W,G])=>Y.indexOf(+W)===-1).map(([W,G])=>G)}function p4(Q,Y="|"){return Q.map((X)=>n4(X)).join(Y)}function P1(Q,Y){if(typeof Y==="bigint")return Y.toString();return Y}function I1(Q){return{get value(){{let X=Q();return Object.defineProperty(this,"value",{value:X}),X}throw Error("cached value already set")}}}function n1(Q){return Q===null||Q===void 0}function d1(Q){let Y=Q.startsWith("^")?1:0,X=Q.endsWith("$")?Q.length-1:Q.length;return Q.slice(Y,X)}function V6(Q,Y){let X=(Q.toString().split(".")[1]||"").length,W=Y.toString(),G=(W.split(".")[1]||"").length;if(G===0&&/\d?e-\d?/.test(W)){let H=W.match(/\d?e-(\d?)/);if(H?.[1])G=Number.parseInt(H[1])}let $=X>G?X:G,J=Number.parseInt(Q.toFixed($).replace(".","")),z=Number.parseInt(Y.toFixed($).replace(".",""));return J%z/10**$}var c9=Symbol("evaluating");function m(Q,Y,X){let W=void 0;Object.defineProperty(Q,Y,{get(){if(W===c9)return;if(W===void 0)W=c9,W=X();return W},set(G){Object.defineProperty(Q,Y,{value:G})},configurable:!0})}function XH(Q){return Object.create(Object.getPrototypeOf(Q),Object.getOwnPropertyDescriptors(Q))}function e0(Q,Y,X){Object.defineProperty(Q,Y,{value:X,writable:!0,enumerable:!0,configurable:!0})}function Q1(...Q){let Y={};for(let X of Q){let W=Object.getOwnPropertyDescriptors(X);Object.assign(Y,W)}return Object.defineProperties({},Y)}function WH(Q){return Q1(Q._zod.def)}function GH(Q,Y){if(!Y)return Q;return Y.reduce((X,W)=>X?.[W],Q)}function $H(Q){let Y=Object.keys(Q),X=Y.map((W)=>Q[W]);return Promise.all(X).then((W)=>{let G={};for(let $=0;$<Y.length;$++)G[Y[$]]=W[$];return G})}function JH(Q=10){let X="";for(let W=0;W<Q;W++)X+="abcdefghijklmnopqrstuvwxyz"[Math.floor(Math.random()*26)];return X}function i4(Q){return JSON.stringify(Q)}var r4="captureStackTrace"in Error?Error.captureStackTrace:(...Q)=>{};function F1(Q){return typeof Q==="object"&&Q!==null&&!Array.isArray(Q)}var N6=I1(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{return new Function(""),!0}catch(Q){return!1}});function Y1(Q){if(F1(Q)===!1)return!1;let Y=Q.constructor;if(Y===void 0)return!0;let X=Y.prototype;if(F1(X)===!1)return!1;if(Object.prototype.hasOwnProperty.call(X,"isPrototypeOf")===!1)return!1;return!0}function p9(Q){if(Y1(Q))return{...Q};if(Array.isArray(Q))return[...Q];return Q}function zH(Q){let Y=0;for(let X in Q)if(Object.prototype.hasOwnProperty.call(Q,X))Y++;return Y}var HH=(Q)=>{let Y=typeof Q;switch(Y){case"undefined":return"undefined";case"string":return"string";case"number":return Number.isNaN(Q)?"nan":"number";case"boolean":return"boolean";case"function":return"function";case"bigint":return"bigint";case"symbol":return"symbol";case"object":if(Array.isArray(Q))return"array";if(Q===null)return"null";if(Q.then&&typeof Q.then==="function"&&Q.catch&&typeof Q.catch==="function")return"promise";if(typeof Map<"u"&&Q instanceof Map)return"map";if(typeof Set<"u"&&Q instanceof Set)return"set";if(typeof Date<"u"&&Q instanceof Date)return"date";if(typeof File<"u"&&Q instanceof File)return"file";return"object";default:throw Error(`Unknown data type: ${Y}`)}},Z6=new Set(["string","number","symbol"]),i9=new Set(["string","number","bigint","boolean","symbol","undefined"]);function m0(Q){return Q.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function E0(Q,Y,X){let W=new Q._zod.constr(Y??Q._zod.def);if(!Y||X?.parent)W._zod.parent=Q;return W}function j(Q){let Y=Q;if(!Y)return{};if(typeof Y==="string")return{error:()=>Y};if(Y?.message!==void 0){if(Y?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");Y.error=Y.message}if(delete Y.message,typeof Y.error==="string")return{...Y,error:()=>Y.error};return Y}function AH(Q){let Y;return new Proxy({},{get(X,W,G){return Y??(Y=Q()),Reflect.get(Y,W,G)},set(X,W,G,$){return Y??(Y=Q()),Reflect.set(Y,W,G,$)},has(X,W){return Y??(Y=Q()),Reflect.has(Y,W)},deleteProperty(X,W){return Y??(Y=Q()),Reflect.deleteProperty(Y,W)},ownKeys(X){return Y??(Y=Q()),Reflect.ownKeys(Y)},getOwnPropertyDescriptor(X,W){return Y??(Y=Q()),Reflect.getOwnPropertyDescriptor(Y,W)},defineProperty(X,W,G){return Y??(Y=Q()),Reflect.defineProperty(Y,W,G)}})}function n4(Q){if(typeof Q==="bigint")return Q.toString()+"n";if(typeof Q==="string")return`"${Q}"`;return`${Q}`}function w6(Q){return Object.keys(Q).filter((Y)=>{return Q[Y]._zod.optin==="optional"&&Q[Y]._zod.optout==="optional"})}var b6={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-340282346638528860000000000000000000000,340282346638528860000000000000000000000],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},r9={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function UH(Q,Y){let X=Q._zod.def,W=Q1(Q._zod.def,{get shape(){let G={};for(let $ in Y){if(!($ in X.shape))throw Error(`Unrecognized key: "${$}"`);if(!Y[$])continue;G[$]=X.shape[$]}return e0(this,"shape",G),G},checks:[]});return E0(Q,W)}function KH(Q,Y){let X=Q._zod.def,W=Q1(Q._zod.def,{get shape(){let G={...Q._zod.def.shape};for(let $ in Y){if(!($ in X.shape))throw Error(`Unrecognized key: "${$}"`);if(!Y[$])continue;delete G[$]}return e0(this,"shape",G),G},checks:[]});return E0(Q,W)}function DH(Q,Y){if(!Y1(Y))throw Error("Invalid input to extend: expected a plain object");let X=Q._zod.def.checks;if(X&&X.length>0)throw Error("Object schemas containing refinements cannot be extended. Use `.safeExtend()` instead.");let G=Q1(Q._zod.def,{get shape(){let $={...Q._zod.def.shape,...Y};return e0(this,"shape",$),$},checks:[]});return E0(Q,G)}function BH(Q,Y){if(!Y1(Y))throw Error("Invalid input to safeExtend: expected a plain object");let X={...Q._zod.def,get shape(){let W={...Q._zod.def.shape,...Y};return e0(this,"shape",W),W},checks:Q._zod.def.checks};return E0(Q,X)}function LH(Q,Y){let X=Q1(Q._zod.def,{get shape(){let W={...Q._zod.def.shape,...Y._zod.def.shape};return e0(this,"shape",W),W},get catchall(){return Y._zod.def.catchall},checks:[]});return E0(Q,X)}function FH(Q,Y,X){let W=Q1(Y._zod.def,{get shape(){let G=Y._zod.def.shape,$={...G};if(X)for(let J in X){if(!(J in G))throw Error(`Unrecognized key: "${J}"`);if(!X[J])continue;$[J]=Q?new Q({type:"optional",innerType:G[J]}):G[J]}else for(let J in G)$[J]=Q?new Q({type:"optional",innerType:G[J]}):G[J];return e0(this,"shape",$),$},checks:[]});return E0(Y,W)}function qH(Q,Y,X){let W=Q1(Y._zod.def,{get shape(){let G=Y._zod.def.shape,$={...G};if(X)for(let J in X){if(!(J in $))throw Error(`Unrecognized key: "${J}"`);if(!X[J])continue;$[J]=new Q({type:"nonoptional",innerType:G[J]})}else for(let J in G)$[J]=new Q({type:"nonoptional",innerType:G[J]});return e0(this,"shape",$),$},checks:[]});return E0(Y,W)}function X1(Q,Y=0){if(Q.aborted===!0)return!0;for(let X=Y;X<Q.issues.length;X++)if(Q.issues[X]?.continue!==!0)return!0;return!1}function c0(Q,Y){return Y.map((X)=>{var W;return(W=X).path??(W.path=[]),X.path.unshift(Q),X})}function r1(Q){return typeof Q==="string"?Q:Q?.message}function T0(Q,Y,X){let W={...Q,path:Q.path??[]};if(!Q.message){let G=r1(Q.inst?._zod.def?.error?.(Q))??r1(Y?.error?.(Q))??r1(X.customError?.(Q))??r1(X.localeError?.(Q))??"Invalid input";W.message=G}if(delete W.inst,delete W.continue,!Y?.reportInput)delete W.input;return W}function n9(Q){if(Q instanceof Set)return"set";if(Q instanceof Map)return"map";if(Q instanceof File)return"file";return"unknown"}function o1(Q){if(Array.isArray(Q))return"array";if(typeof Q==="string")return"string";return"unknown"}function j1(...Q){let[Y,X,W]=Q;if(typeof Y==="string")return{message:Y,code:"custom",input:X,inst:W};return{...Y}}function OH(Q){return Object.entries(Q).filter(([Y,X])=>{return Number.isNaN(Number.parseInt(Y,10))}).map((Y)=>Y[1])}function d9(Q){let Y=atob(Q),X=new Uint8Array(Y.length);for(let W=0;W<Y.length;W++)X[W]=Y.charCodeAt(W);return X}function o9(Q){let Y="";for(let X=0;X<Q.length;X++)Y+=String.fromCharCode(Q[X]);return btoa(Y)}function MH(Q){let Y=Q.replace(/-/g,"+").replace(/_/g,"/"),X="=".repeat((4-Y.length%4)%4);return d9(Y+X)}function VH(Q){return o9(Q).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function NH(Q){let Y=Q.replace(/^0x/,"");if(Y.length%2!==0)throw Error("Invalid hex string length");let X=new Uint8Array(Y.length/2);for(let W=0;W<Y.length;W+=2)X[W/2]=Number.parseInt(Y.slice(W,W+2),16);return X}function ZH(Q){return Array.from(Q).map((Y)=>Y.toString(16).padStart(2,"0")).join("")}class t9{constructor(...Q){}}var a9=(Q,Y)=>{Q.name="$ZodError",Object.defineProperty(Q,"_zod",{value:Q._zod,enumerable:!1}),Object.defineProperty(Q,"issues",{value:Y,enumerable:!1}),Q.message=JSON.stringify(Y,P1,2),Object.defineProperty(Q,"toString",{value:()=>Q.message,enumerable:!1})},d4=F("$ZodError",a9),P6=F("$ZodError",a9,{Parent:Error});function s9(Q,Y=(X)=>X.message){let X={},W=[];for(let G of Q.issues)if(G.path.length>0)X[G.path[0]]=X[G.path[0]]||[],X[G.path[0]].push(Y(G));else W.push(Y(G));return{formErrors:W,fieldErrors:X}}function e9(Q,Y=(X)=>X.message){let X={_errors:[]},W=(G)=>{for(let $ of G.issues)if($.code==="invalid_union"&&$.errors.length)$.errors.map((J)=>W({issues:J}));else if($.code==="invalid_key")W({issues:$.issues});else if($.code==="invalid_element")W({issues:$.issues});else if($.path.length===0)X._errors.push(Y($));else{let J=X,z=0;while(z<$.path.length){let H=$.path[z];if(z!==$.path.length-1)J[H]=J[H]||{_errors:[]};else J[H]=J[H]||{_errors:[]},J[H]._errors.push(Y($));J=J[H],z++}}};return W(Q),X}var o4=(Q)=>(Y,X,W,G)=>{let $=W?Object.assign(W,{async:!1}):{async:!1},J=Y._zod.run({value:X,issues:[]},$);if(J instanceof Promise)throw new l0;if(J.issues.length){let z=new(G?.Err??Q)(J.issues.map((H)=>T0(H,$,w0())));throw r4(z,G?.callee),z}return J.value};var t4=(Q)=>async(Y,X,W,G)=>{let $=W?Object.assign(W,{async:!0}):{async:!0},J=Y._zod.run({value:X,issues:[]},$);if(J instanceof Promise)J=await J;if(J.issues.length){let z=new(G?.Err??Q)(J.issues.map((H)=>T0(H,$,w0())));throw r4(z,G?.callee),z}return J.value};var t1=(Q)=>(Y,X,W)=>{let G=W?{...W,async:!1}:{async:!1},$=Y._zod.run({value:X,issues:[]},G);if($ instanceof Promise)throw new l0;return $.issues.length?{success:!1,error:new(Q??d4)($.issues.map((J)=>T0(J,G,w0())))}:{success:!0,data:$.value}},a1=t1(P6),s1=(Q)=>async(Y,X,W)=>{let G=W?Object.assign(W,{async:!0}):{async:!0},$=Y._zod.run({value:X,issues:[]},G);if($ instanceof Promise)$=await $;return $.issues.length?{success:!1,error:new Q($.issues.map((J)=>T0(J,G,w0())))}:{success:!0,data:$.value}},a4=s1(P6),QX=(Q)=>(Y,X,W)=>{let G=W?Object.assign(W,{direction:"backward"}):{direction:"backward"};return o4(Q)(Y,X,G)};var YX=(Q)=>(Y,X,W)=>{return o4(Q)(Y,X,W)};var XX=(Q)=>async(Y,X,W)=>{let G=W?Object.assign(W,{direction:"backward"}):{direction:"backward"};return t4(Q)(Y,X,G)};var WX=(Q)=>async(Y,X,W)=>{return t4(Q)(Y,X,W)};var GX=(Q)=>(Y,X,W)=>{let G=W?Object.assign(W,{direction:"backward"}):{direction:"backward"};return t1(Q)(Y,X,G)};var $X=(Q)=>(Y,X,W)=>{return t1(Q)(Y,X,W)};var JX=(Q)=>async(Y,X,W)=>{let G=W?Object.assign(W,{direction:"backward"}):{direction:"backward"};return s1(Q)(Y,X,G)};var zX=(Q)=>async(Y,X,W)=>{return s1(Q)(Y,X,W)};var HX=/^[cC][^\s-]{8,}$/,AX=/^[0-9a-z]+$/,UX=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,KX=/^[0-9a-vA-V]{20}$/,DX=/^[A-Za-z0-9]{27}$/,BX=/^[a-zA-Z0-9_-]{21}$/,LX=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;var FX=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,I6=(Q)=>{if(!Q)return/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/;return new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${Q}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`)};var qX=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;function OX(){return new RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")}var MX=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,VX=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,NX=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,ZX=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,wX=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,j6=/^[A-Za-z0-9_-]*$/,bX=/^(?=.{1,253}\.?$)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[-0-9a-zA-Z]{0,61}[0-9a-zA-Z])?)*\.?$/;var PX=/^\+(?:[0-9]){6,14}[0-9]$/,IX="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",jX=new RegExp(`^${IX}$`);function EX(Q){return typeof Q.precision==="number"?Q.precision===-1?"(?:[01]\\d|2[0-3]):[0-5]\\d":Q.precision===0?"(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d":`(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d\\.\\d{${Q.precision}}`:"(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?"}function TX(Q){return new RegExp(`^${EX(Q)}$`)}function SX(Q){let Y=EX({precision:Q.precision}),X=["Z"];if(Q.local)X.push("");if(Q.offset)X.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");let W=`${Y}(?:${X.join("|")})`;return new RegExp(`^${IX}T(?:${W})$`)}var RX=(Q)=>{let Y=Q?`[\\s\\S]{${Q?.minimum??0},${Q?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${Y}$`)};var CX=/^-?\d+$/,kX=/^-?\d+(?:\.\d+)?/,vX=/^(?:true|false)$/i,xX=/^null$/i;var _X=/^[^A-Z]*$/,yX=/^[^a-z]*$/;var W0=F("$ZodCheck",(Q,Y)=>{var X;Q._zod??(Q._zod={}),Q._zod.def=Y,(X=Q._zod).onattach??(X.onattach=[])}),gX={number:"number",bigint:"bigint",object:"date"},E6=F("$ZodCheckLessThan",(Q,Y)=>{W0.init(Q,Y);let X=gX[typeof Y.value];Q._zod.onattach.push((W)=>{let G=W._zod.bag,$=(Y.inclusive?G.maximum:G.exclusiveMaximum)??Number.POSITIVE_INFINITY;if(Y.value<$)if(Y.inclusive)G.maximum=Y.value;else G.exclusiveMaximum=Y.value}),Q._zod.check=(W)=>{if(Y.inclusive?W.value<=Y.value:W.value<Y.value)return;W.issues.push({origin:X,code:"too_big",maximum:Y.value,input:W.value,inclusive:Y.inclusive,inst:Q,continue:!Y.abort})}}),T6=F("$ZodCheckGreaterThan",(Q,Y)=>{W0.init(Q,Y);let X=gX[typeof Y.value];Q._zod.onattach.push((W)=>{let G=W._zod.bag,$=(Y.inclusive?G.minimum:G.exclusiveMinimum)??Number.NEGATIVE_INFINITY;if(Y.value>$)if(Y.inclusive)G.minimum=Y.value;else G.exclusiveMinimum=Y.value}),Q._zod.check=(W)=>{if(Y.inclusive?W.value>=Y.value:W.value>Y.value)return;W.issues.push({origin:X,code:"too_small",minimum:Y.value,input:W.value,inclusive:Y.inclusive,inst:Q,continue:!Y.abort})}}),uX=F("$ZodCheckMultipleOf",(Q,Y)=>{W0.init(Q,Y),Q._zod.onattach.push((X)=>{var W;(W=X._zod.bag).multipleOf??(W.multipleOf=Y.value)}),Q._zod.check=(X)=>{if(typeof X.value!==typeof Y.value)throw Error("Cannot mix number and bigint in multiple_of check.");if(typeof X.value==="bigint"?X.value%Y.value===BigInt(0):V6(X.value,Y.value)===0)return;X.issues.push({origin:typeof X.value,code:"not_multiple_of",divisor:Y.value,input:X.value,inst:Q,continue:!Y.abort})}}),hX=F("$ZodCheckNumberFormat",(Q,Y)=>{W0.init(Q,Y),Y.format=Y.format||"float64";let X=Y.format?.includes("int"),W=X?"int":"number",[G,$]=b6[Y.format];Q._zod.onattach.push((J)=>{let z=J._zod.bag;if(z.format=Y.format,z.minimum=G,z.maximum=$,X)z.pattern=CX}),Q._zod.check=(J)=>{let z=J.value;if(X){if(!Number.isInteger(z)){J.issues.push({expected:W,format:Y.format,code:"invalid_type",continue:!1,input:z,inst:Q});return}if(!Number.isSafeInteger(z)){if(z>0)J.issues.push({input:z,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:Q,origin:W,continue:!Y.abort});else J.issues.push({input:z,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:Q,origin:W,continue:!Y.abort});return}}if(z<G)J.issues.push({origin:"number",input:z,code:"too_small",minimum:G,inclusive:!0,inst:Q,continue:!Y.abort});if(z>$)J.issues.push({origin:"number",input:z,code:"too_big",maximum:$,inst:Q})}});var fX=F("$ZodCheckMaxLength",(Q,Y)=>{var X;W0.init(Q,Y),(X=Q._zod.def).when??(X.when=(W)=>{let G=W.value;return!n1(G)&&G.length!==void 0}),Q._zod.onattach.push((W)=>{let G=W._zod.bag.maximum??Number.POSITIVE_INFINITY;if(Y.maximum<G)W._zod.bag.maximum=Y.maximum}),Q._zod.check=(W)=>{let G=W.value;if(G.length<=Y.maximum)return;let J=o1(G);W.issues.push({origin:J,code:"too_big",maximum:Y.maximum,inclusive:!0,input:G,inst:Q,continue:!Y.abort})}}),lX=F("$ZodCheckMinLength",(Q,Y)=>{var X;W0.init(Q,Y),(X=Q._zod.def).when??(X.when=(W)=>{let G=W.value;return!n1(G)&&G.length!==void 0}),Q._zod.onattach.push((W)=>{let G=W._zod.bag.minimum??Number.NEGATIVE_INFINITY;if(Y.minimum>G)W._zod.bag.minimum=Y.minimum}),Q._zod.check=(W)=>{let G=W.value;if(G.length>=Y.minimum)return;let J=o1(G);W.issues.push({origin:J,code:"too_small",minimum:Y.minimum,inclusive:!0,input:G,inst:Q,continue:!Y.abort})}}),mX=F("$ZodCheckLengthEquals",(Q,Y)=>{var X;W0.init(Q,Y),(X=Q._zod.def).when??(X.when=(W)=>{let G=W.value;return!n1(G)&&G.length!==void 0}),Q._zod.onattach.push((W)=>{let G=W._zod.bag;G.minimum=Y.length,G.maximum=Y.length,G.length=Y.length}),Q._zod.check=(W)=>{let G=W.value,$=G.length;if($===Y.length)return;let J=o1(G),z=$>Y.length;W.issues.push({origin:J,...z?{code:"too_big",maximum:Y.length}:{code:"too_small",minimum:Y.length},inclusive:!0,exact:!0,input:W.value,inst:Q,continue:!Y.abort})}}),e1=F("$ZodCheckStringFormat",(Q,Y)=>{var X,W;if(W0.init(Q,Y),Q._zod.onattach.push((G)=>{let $=G._zod.bag;if($.format=Y.format,Y.pattern)$.patterns??($.patterns=new Set),$.patterns.add(Y.pattern)}),Y.pattern)(X=Q._zod).check??(X.check=(G)=>{if(Y.pattern.lastIndex=0,Y.pattern.test(G.value))return;G.issues.push({origin:"string",code:"invalid_format",format:Y.format,input:G.value,...Y.pattern?{pattern:Y.pattern.toString()}:{},inst:Q,continue:!Y.abort})});else(W=Q._zod).check??(W.check=()=>{})}),cX=F("$ZodCheckRegex",(Q,Y)=>{e1.init(Q,Y),Q._zod.check=(X)=>{if(Y.pattern.lastIndex=0,Y.pattern.test(X.value))return;X.issues.push({origin:"string",code:"invalid_format",format:"regex",input:X.value,pattern:Y.pattern.toString(),inst:Q,continue:!Y.abort})}}),pX=F("$ZodCheckLowerCase",(Q,Y)=>{Y.pattern??(Y.pattern=_X),e1.init(Q,Y)}),iX=F("$ZodCheckUpperCase",(Q,Y)=>{Y.pattern??(Y.pattern=yX),e1.init(Q,Y)}),rX=F("$ZodCheckIncludes",(Q,Y)=>{W0.init(Q,Y);let X=m0(Y.includes),W=new RegExp(typeof Y.position==="number"?`^.{${Y.position}}${X}`:X);Y.pattern=W,Q._zod.onattach.push((G)=>{let $=G._zod.bag;$.patterns??($.patterns=new Set),$.patterns.add(W)}),Q._zod.check=(G)=>{if(G.value.includes(Y.includes,Y.position))return;G.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:Y.includes,input:G.value,inst:Q,continue:!Y.abort})}}),nX=F("$ZodCheckStartsWith",(Q,Y)=>{W0.init(Q,Y);let X=new RegExp(`^${m0(Y.prefix)}.*`);Y.pattern??(Y.pattern=X),Q._zod.onattach.push((W)=>{let G=W._zod.bag;G.patterns??(G.patterns=new Set),G.patterns.add(X)}),Q._zod.check=(W)=>{if(W.value.startsWith(Y.prefix))return;W.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:Y.prefix,input:W.value,inst:Q,continue:!Y.abort})}}),dX=F("$ZodCheckEndsWith",(Q,Y)=>{W0.init(Q,Y);let X=new RegExp(`.*${m0(Y.suffix)}$`);Y.pattern??(Y.pattern=X),Q._zod.onattach.push((W)=>{let G=W._zod.bag;G.patterns??(G.patterns=new Set),G.patterns.add(X)}),Q._zod.check=(W)=>{if(W.value.endsWith(Y.suffix))return;W.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:Y.suffix,input:W.value,inst:Q,continue:!Y.abort})}});var oX=F("$ZodCheckOverwrite",(Q,Y)=>{W0.init(Q,Y),Q._zod.check=(X)=>{X.value=Y.tx(X.value)}});class S6{constructor(Q=[]){if(this.content=[],this.indent=0,this)this.args=Q}indented(Q){this.indent+=1,Q(this),this.indent-=1}write(Q){if(typeof Q==="function"){Q(this,{execution:"sync"}),Q(this,{execution:"async"});return}let X=Q.split(`
11
11
  `).filter(($)=>$),W=Math.min(...X.map(($)=>$.length-$.trimStart().length)),G=X.map(($)=>$.slice(W)).map(($)=>" ".repeat(this.indent*2)+$);for(let $ of G)this.content.push($)}compile(){let Q=Function,Y=this?.args,W=[...(this?.content??[""]).map((G)=>` ${G}`)];return new Q(...Y,W.join(`
12
- `))}}var a8={major:4,minor:1,patch:12};var i=F("$ZodType",(Q,Y)=>{var X;Q??(Q={}),Q._zod.def=Y,Q._zod.bag=Q._zod.bag||{},Q._zod.version=a8;let W=[...Q._zod.def.checks??[]];if(Q._zod.traits.has("$ZodCheck"))W.unshift(Q);for(let G of W)for(let $ of G._zod.onattach)$(Q);if(W.length===0)(X=Q._zod).deferred??(X.deferred=[]),Q._zod.deferred?.push(()=>{Q._zod.run=Q._zod.parse});else{let G=(J,z,H)=>{let A=X1(J),U;for(let K of z){if(K._zod.def.when){if(!K._zod.def.when(J))continue}else if(A)continue;let D=J.issues.length,L=K._zod.check(J);if(L instanceof Promise&&H?.async===!1)throw new l0;if(U||L instanceof Promise)U=(U??Promise.resolve()).then(async()=>{if(await L,J.issues.length===D)return;if(!A)A=X1(J,D)});else{if(J.issues.length===D)continue;if(!A)A=X1(J,D)}}if(U)return U.then(()=>{return J});return J},$=(J,z,H)=>{if(X1(J))return J.aborted=!0,J;let A=G(z,W,H);if(A instanceof Promise){if(H.async===!1)throw new l0;return A.then((U)=>Q._zod.parse(U,H))}return Q._zod.parse(A,H)};Q._zod.run=(J,z)=>{if(z.skipChecks)return Q._zod.parse(J,z);if(z.direction==="backward"){let A=Q._zod.parse({value:J.value,issues:[]},{...z,skipChecks:!0});if(A instanceof Promise)return A.then((U)=>{return $(U,J,z)});return $(A,J,z)}let H=Q._zod.parse(J,z);if(H instanceof Promise){if(z.async===!1)throw new l0;return H.then((A)=>G(A,W,z))}return G(H,W,z)}}Q["~standard"]={validate:(G)=>{try{let $=a1(Q,G);return $.success?{value:$.data}:{issues:$.error?.issues}}catch($){return a4(Q,G).then((J)=>J.success?{value:J.data}:{issues:J.error?.issues})}},vendor:"zod",version:1}}),YQ=F("$ZodString",(Q,Y)=>{i.init(Q,Y),Q._zod.pattern=[...Q?._zod.bag?.patterns??[]].pop()??R8(Q._zod.bag),Q._zod.parse=(X,W)=>{if(Y.coerce)try{X.value=String(X.value)}catch(G){}if(typeof X.value==="string")return X;return X.issues.push({expected:"string",code:"invalid_type",input:X.value,inst:Q}),X}}),r=F("$ZodStringFormat",(Q,Y)=>{e1.init(Q,Y),YQ.init(Q,Y)}),JX=F("$ZodGUID",(Q,Y)=>{Y.pattern??(Y.pattern=F8),r.init(Q,Y)}),zX=F("$ZodUUID",(Q,Y)=>{if(Y.version){let W={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[Y.version];if(W===void 0)throw Error(`Invalid UUID version: "${Y.version}"`);Y.pattern??(Y.pattern=I6(W))}else Y.pattern??(Y.pattern=I6());r.init(Q,Y)}),HX=F("$ZodEmail",(Q,Y)=>{Y.pattern??(Y.pattern=q8),r.init(Q,Y)}),AX=F("$ZodURL",(Q,Y)=>{r.init(Q,Y),Q._zod.check=(X)=>{try{let W=X.value.trim(),G=new URL(W);if(Y.hostname){if(Y.hostname.lastIndex=0,!Y.hostname.test(G.hostname))X.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:b8.source,input:X.value,inst:Q,continue:!Y.abort})}if(Y.protocol){if(Y.protocol.lastIndex=0,!Y.protocol.test(G.protocol.endsWith(":")?G.protocol.slice(0,-1):G.protocol))X.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:Y.protocol.source,input:X.value,inst:Q,continue:!Y.abort})}if(Y.normalize)X.value=G.href;else X.value=W;return}catch(W){X.issues.push({code:"invalid_format",format:"url",input:X.value,inst:Q,continue:!Y.abort})}}}),UX=F("$ZodEmoji",(Q,Y)=>{Y.pattern??(Y.pattern=O8()),r.init(Q,Y)}),KX=F("$ZodNanoID",(Q,Y)=>{Y.pattern??(Y.pattern=B8),r.init(Q,Y)}),DX=F("$ZodCUID",(Q,Y)=>{Y.pattern??(Y.pattern=H8),r.init(Q,Y)}),BX=F("$ZodCUID2",(Q,Y)=>{Y.pattern??(Y.pattern=A8),r.init(Q,Y)}),LX=F("$ZodULID",(Q,Y)=>{Y.pattern??(Y.pattern=U8),r.init(Q,Y)}),FX=F("$ZodXID",(Q,Y)=>{Y.pattern??(Y.pattern=K8),r.init(Q,Y)}),qX=F("$ZodKSUID",(Q,Y)=>{Y.pattern??(Y.pattern=D8),r.init(Q,Y)}),OX=F("$ZodISODateTime",(Q,Y)=>{Y.pattern??(Y.pattern=S8(Y)),r.init(Q,Y)}),MX=F("$ZodISODate",(Q,Y)=>{Y.pattern??(Y.pattern=j8),r.init(Q,Y)}),VX=F("$ZodISOTime",(Q,Y)=>{Y.pattern??(Y.pattern=T8(Y)),r.init(Q,Y)}),NX=F("$ZodISODuration",(Q,Y)=>{Y.pattern??(Y.pattern=L8),r.init(Q,Y)}),ZX=F("$ZodIPv4",(Q,Y)=>{Y.pattern??(Y.pattern=M8),r.init(Q,Y),Q._zod.onattach.push((X)=>{let W=X._zod.bag;W.format="ipv4"})}),wX=F("$ZodIPv6",(Q,Y)=>{Y.pattern??(Y.pattern=V8),r.init(Q,Y),Q._zod.onattach.push((X)=>{let W=X._zod.bag;W.format="ipv6"}),Q._zod.check=(X)=>{try{new URL(`http://[${X.value}]`)}catch{X.issues.push({code:"invalid_format",format:"ipv6",input:X.value,inst:Q,continue:!Y.abort})}}}),bX=F("$ZodCIDRv4",(Q,Y)=>{Y.pattern??(Y.pattern=N8),r.init(Q,Y)}),PX=F("$ZodCIDRv6",(Q,Y)=>{Y.pattern??(Y.pattern=Z8),r.init(Q,Y),Q._zod.check=(X)=>{let W=X.value.split("/");try{if(W.length!==2)throw Error();let[G,$]=W;if(!$)throw Error();let J=Number($);if(`${J}`!==$)throw Error();if(J<0||J>128)throw Error();new URL(`http://[${G}]`)}catch{X.issues.push({code:"invalid_format",format:"cidrv6",input:X.value,inst:Q,continue:!Y.abort})}}});function IX(Q){if(Q==="")return!0;if(Q.length%4!==0)return!1;try{return atob(Q),!0}catch{return!1}}var jX=F("$ZodBase64",(Q,Y)=>{Y.pattern??(Y.pattern=w8),r.init(Q,Y),Q._zod.onattach.push((X)=>{X._zod.bag.contentEncoding="base64"}),Q._zod.check=(X)=>{if(IX(X.value))return;X.issues.push({code:"invalid_format",format:"base64",input:X.value,inst:Q,continue:!Y.abort})}});function IH(Q){if(!j6.test(Q))return!1;let Y=Q.replace(/[-_]/g,(W)=>W==="-"?"+":"/"),X=Y.padEnd(Math.ceil(Y.length/4)*4,"=");return IX(X)}var EX=F("$ZodBase64URL",(Q,Y)=>{Y.pattern??(Y.pattern=j6),r.init(Q,Y),Q._zod.onattach.push((X)=>{X._zod.bag.contentEncoding="base64url"}),Q._zod.check=(X)=>{if(IH(X.value))return;X.issues.push({code:"invalid_format",format:"base64url",input:X.value,inst:Q,continue:!Y.abort})}}),TX=F("$ZodE164",(Q,Y)=>{Y.pattern??(Y.pattern=P8),r.init(Q,Y)});function jH(Q,Y=null){try{let X=Q.split(".");if(X.length!==3)return!1;let[W]=X;if(!W)return!1;let G=JSON.parse(atob(W));if("typ"in G&&G?.typ!=="JWT")return!1;if(!G.alg)return!1;if(Y&&(!("alg"in G)||G.alg!==Y))return!1;return!0}catch{return!1}}var SX=F("$ZodJWT",(Q,Y)=>{r.init(Q,Y),Q._zod.check=(X)=>{if(jH(X.value,Y.alg))return;X.issues.push({code:"invalid_format",format:"jwt",input:X.value,inst:Q,continue:!Y.abort})}});var C6=F("$ZodNumber",(Q,Y)=>{i.init(Q,Y),Q._zod.pattern=Q._zod.bag.pattern??k8,Q._zod.parse=(X,W)=>{if(Y.coerce)try{X.value=Number(X.value)}catch(J){}let G=X.value;if(typeof G==="number"&&!Number.isNaN(G)&&Number.isFinite(G))return X;let $=typeof G==="number"?Number.isNaN(G)?"NaN":!Number.isFinite(G)?"Infinity":void 0:void 0;return X.issues.push({expected:"number",code:"invalid_type",input:G,inst:Q,...$?{received:$}:{}}),X}}),RX=F("$ZodNumber",(Q,Y)=>{h8.init(Q,Y),C6.init(Q,Y)}),CX=F("$ZodBoolean",(Q,Y)=>{i.init(Q,Y),Q._zod.pattern=v8,Q._zod.parse=(X,W)=>{if(Y.coerce)try{X.value=Boolean(X.value)}catch($){}let G=X.value;if(typeof G==="boolean")return X;return X.issues.push({expected:"boolean",code:"invalid_type",input:G,inst:Q}),X}});var kX=F("$ZodNull",(Q,Y)=>{i.init(Q,Y),Q._zod.pattern=x8,Q._zod.values=new Set([null]),Q._zod.parse=(X,W)=>{let G=X.value;if(G===null)return X;return X.issues.push({expected:"null",code:"invalid_type",input:G,inst:Q}),X}});var vX=F("$ZodUnknown",(Q,Y)=>{i.init(Q,Y),Q._zod.parse=(X)=>X}),xX=F("$ZodNever",(Q,Y)=>{i.init(Q,Y),Q._zod.parse=(X,W)=>{return X.issues.push({expected:"never",code:"invalid_type",input:X.value,inst:Q}),X}});function s8(Q,Y,X){if(Q.issues.length)Y.issues.push(...c0(X,Q.issues));Y.value[X]=Q.value}var _X=F("$ZodArray",(Q,Y)=>{i.init(Q,Y),Q._zod.parse=(X,W)=>{let G=X.value;if(!Array.isArray(G))return X.issues.push({expected:"array",code:"invalid_type",input:G,inst:Q}),X;X.value=Array(G.length);let $=[];for(let J=0;J<G.length;J++){let z=G[J],H=Y.element._zod.run({value:z,issues:[]},W);if(H instanceof Promise)$.push(H.then((A)=>s8(A,X,J)));else s8(H,X,J)}if($.length)return Promise.all($).then(()=>X);return X}});function QQ(Q,Y,X,W){if(Q.issues.length)Y.issues.push(...c0(X,Q.issues));if(Q.value===void 0){if(X in W)Y.value[X]=void 0}else Y.value[X]=Q.value}function yX(Q){let Y=Object.keys(Q.shape);for(let W of Y)if(!Q.shape?.[W]?._zod?.traits?.has("$ZodType"))throw Error(`Invalid element at key "${W}": expected a Zod schema`);let X=w6(Q.shape);return{...Q,keys:Y,keySet:new Set(Y),numKeys:Y.length,optionalKeys:new Set(X)}}function gX(Q,Y,X,W,G,$){let J=[],z=G.keySet,H=G.catchall._zod,A=H.def.type;for(let U of Object.keys(Y)){if(z.has(U))continue;if(A==="never"){J.push(U);continue}let K=H.run({value:Y[U],issues:[]},W);if(K instanceof Promise)Q.push(K.then((D)=>QQ(D,X,U,Y)));else QQ(K,X,U,Y)}if(J.length)X.issues.push({code:"unrecognized_keys",keys:J,input:Y,inst:$});if(!Q.length)return X;return Promise.all(Q).then(()=>{return X})}var EH=F("$ZodObject",(Q,Y)=>{if(i.init(Q,Y),!Object.getOwnPropertyDescriptor(Y,"shape")?.get){let z=Y.shape;Object.defineProperty(Y,"shape",{get:()=>{let H={...z};return Object.defineProperty(Y,"shape",{value:H}),H}})}let W=I1(()=>yX(Y));m(Q._zod,"propValues",()=>{let z=Y.shape,H={};for(let A in z){let U=z[A]._zod;if(U.values){H[A]??(H[A]=new Set);for(let K of U.values)H[A].add(K)}}return H});let G=F1,$=Y.catchall,J;Q._zod.parse=(z,H)=>{J??(J=W.value);let A=z.value;if(!G(A))return z.issues.push({expected:"object",code:"invalid_type",input:A,inst:Q}),z;z.value={};let U=[],K=J.shape;for(let D of J.keys){let q=K[D]._zod.run({value:A[D],issues:[]},H);if(q instanceof Promise)U.push(q.then((O)=>QQ(O,z,D,A)));else QQ(q,z,D,A)}if(!$)return U.length?Promise.all(U).then(()=>z):z;return gX(U,A,z,H,W.value,Q)}}),uX=F("$ZodObjectJIT",(Q,Y)=>{EH.init(Q,Y);let X=Q._zod.parse,W=I1(()=>yX(Y)),G=(D)=>{let L=new S6(["shape","payload","ctx"]),q=W.value,O=(E)=>{let x=i4(E);return`shape[${x}]._zod.run({ value: input[${x}], issues: [] }, ctx)`};L.write("const input = payload.value;");let V=Object.create(null),M=0;for(let E of q.keys)V[E]=`key_${M++}`;L.write("const newResult = {};");for(let E of q.keys){let x=V[E],T=i4(E);L.write(`const ${x} = ${O(E)};`),L.write(`
12
+ `))}}var aX={major:4,minor:1,patch:12};var i=F("$ZodType",(Q,Y)=>{var X;Q??(Q={}),Q._zod.def=Y,Q._zod.bag=Q._zod.bag||{},Q._zod.version=aX;let W=[...Q._zod.def.checks??[]];if(Q._zod.traits.has("$ZodCheck"))W.unshift(Q);for(let G of W)for(let $ of G._zod.onattach)$(Q);if(W.length===0)(X=Q._zod).deferred??(X.deferred=[]),Q._zod.deferred?.push(()=>{Q._zod.run=Q._zod.parse});else{let G=(J,z,H)=>{let A=X1(J),U;for(let K of z){if(K._zod.def.when){if(!K._zod.def.when(J))continue}else if(A)continue;let D=J.issues.length,L=K._zod.check(J);if(L instanceof Promise&&H?.async===!1)throw new l0;if(U||L instanceof Promise)U=(U??Promise.resolve()).then(async()=>{if(await L,J.issues.length===D)return;if(!A)A=X1(J,D)});else{if(J.issues.length===D)continue;if(!A)A=X1(J,D)}}if(U)return U.then(()=>{return J});return J},$=(J,z,H)=>{if(X1(J))return J.aborted=!0,J;let A=G(z,W,H);if(A instanceof Promise){if(H.async===!1)throw new l0;return A.then((U)=>Q._zod.parse(U,H))}return Q._zod.parse(A,H)};Q._zod.run=(J,z)=>{if(z.skipChecks)return Q._zod.parse(J,z);if(z.direction==="backward"){let A=Q._zod.parse({value:J.value,issues:[]},{...z,skipChecks:!0});if(A instanceof Promise)return A.then((U)=>{return $(U,J,z)});return $(A,J,z)}let H=Q._zod.parse(J,z);if(H instanceof Promise){if(z.async===!1)throw new l0;return H.then((A)=>G(A,W,z))}return G(H,W,z)}}Q["~standard"]={validate:(G)=>{try{let $=a1(Q,G);return $.success?{value:$.data}:{issues:$.error?.issues}}catch($){return a4(Q,G).then((J)=>J.success?{value:J.data}:{issues:J.error?.issues})}},vendor:"zod",version:1}}),YQ=F("$ZodString",(Q,Y)=>{i.init(Q,Y),Q._zod.pattern=[...Q?._zod.bag?.patterns??[]].pop()??RX(Q._zod.bag),Q._zod.parse=(X,W)=>{if(Y.coerce)try{X.value=String(X.value)}catch(G){}if(typeof X.value==="string")return X;return X.issues.push({expected:"string",code:"invalid_type",input:X.value,inst:Q}),X}}),r=F("$ZodStringFormat",(Q,Y)=>{e1.init(Q,Y),YQ.init(Q,Y)}),J8=F("$ZodGUID",(Q,Y)=>{Y.pattern??(Y.pattern=FX),r.init(Q,Y)}),z8=F("$ZodUUID",(Q,Y)=>{if(Y.version){let W={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[Y.version];if(W===void 0)throw Error(`Invalid UUID version: "${Y.version}"`);Y.pattern??(Y.pattern=I6(W))}else Y.pattern??(Y.pattern=I6());r.init(Q,Y)}),H8=F("$ZodEmail",(Q,Y)=>{Y.pattern??(Y.pattern=qX),r.init(Q,Y)}),A8=F("$ZodURL",(Q,Y)=>{r.init(Q,Y),Q._zod.check=(X)=>{try{let W=X.value.trim(),G=new URL(W);if(Y.hostname){if(Y.hostname.lastIndex=0,!Y.hostname.test(G.hostname))X.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:bX.source,input:X.value,inst:Q,continue:!Y.abort})}if(Y.protocol){if(Y.protocol.lastIndex=0,!Y.protocol.test(G.protocol.endsWith(":")?G.protocol.slice(0,-1):G.protocol))X.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:Y.protocol.source,input:X.value,inst:Q,continue:!Y.abort})}if(Y.normalize)X.value=G.href;else X.value=W;return}catch(W){X.issues.push({code:"invalid_format",format:"url",input:X.value,inst:Q,continue:!Y.abort})}}}),U8=F("$ZodEmoji",(Q,Y)=>{Y.pattern??(Y.pattern=OX()),r.init(Q,Y)}),K8=F("$ZodNanoID",(Q,Y)=>{Y.pattern??(Y.pattern=BX),r.init(Q,Y)}),D8=F("$ZodCUID",(Q,Y)=>{Y.pattern??(Y.pattern=HX),r.init(Q,Y)}),B8=F("$ZodCUID2",(Q,Y)=>{Y.pattern??(Y.pattern=AX),r.init(Q,Y)}),L8=F("$ZodULID",(Q,Y)=>{Y.pattern??(Y.pattern=UX),r.init(Q,Y)}),F8=F("$ZodXID",(Q,Y)=>{Y.pattern??(Y.pattern=KX),r.init(Q,Y)}),q8=F("$ZodKSUID",(Q,Y)=>{Y.pattern??(Y.pattern=DX),r.init(Q,Y)}),O8=F("$ZodISODateTime",(Q,Y)=>{Y.pattern??(Y.pattern=SX(Y)),r.init(Q,Y)}),M8=F("$ZodISODate",(Q,Y)=>{Y.pattern??(Y.pattern=jX),r.init(Q,Y)}),V8=F("$ZodISOTime",(Q,Y)=>{Y.pattern??(Y.pattern=TX(Y)),r.init(Q,Y)}),N8=F("$ZodISODuration",(Q,Y)=>{Y.pattern??(Y.pattern=LX),r.init(Q,Y)}),Z8=F("$ZodIPv4",(Q,Y)=>{Y.pattern??(Y.pattern=MX),r.init(Q,Y),Q._zod.onattach.push((X)=>{let W=X._zod.bag;W.format="ipv4"})}),w8=F("$ZodIPv6",(Q,Y)=>{Y.pattern??(Y.pattern=VX),r.init(Q,Y),Q._zod.onattach.push((X)=>{let W=X._zod.bag;W.format="ipv6"}),Q._zod.check=(X)=>{try{new URL(`http://[${X.value}]`)}catch{X.issues.push({code:"invalid_format",format:"ipv6",input:X.value,inst:Q,continue:!Y.abort})}}}),b8=F("$ZodCIDRv4",(Q,Y)=>{Y.pattern??(Y.pattern=NX),r.init(Q,Y)}),P8=F("$ZodCIDRv6",(Q,Y)=>{Y.pattern??(Y.pattern=ZX),r.init(Q,Y),Q._zod.check=(X)=>{let W=X.value.split("/");try{if(W.length!==2)throw Error();let[G,$]=W;if(!$)throw Error();let J=Number($);if(`${J}`!==$)throw Error();if(J<0||J>128)throw Error();new URL(`http://[${G}]`)}catch{X.issues.push({code:"invalid_format",format:"cidrv6",input:X.value,inst:Q,continue:!Y.abort})}}});function I8(Q){if(Q==="")return!0;if(Q.length%4!==0)return!1;try{return atob(Q),!0}catch{return!1}}var j8=F("$ZodBase64",(Q,Y)=>{Y.pattern??(Y.pattern=wX),r.init(Q,Y),Q._zod.onattach.push((X)=>{X._zod.bag.contentEncoding="base64"}),Q._zod.check=(X)=>{if(I8(X.value))return;X.issues.push({code:"invalid_format",format:"base64",input:X.value,inst:Q,continue:!Y.abort})}});function IH(Q){if(!j6.test(Q))return!1;let Y=Q.replace(/[-_]/g,(W)=>W==="-"?"+":"/"),X=Y.padEnd(Math.ceil(Y.length/4)*4,"=");return I8(X)}var E8=F("$ZodBase64URL",(Q,Y)=>{Y.pattern??(Y.pattern=j6),r.init(Q,Y),Q._zod.onattach.push((X)=>{X._zod.bag.contentEncoding="base64url"}),Q._zod.check=(X)=>{if(IH(X.value))return;X.issues.push({code:"invalid_format",format:"base64url",input:X.value,inst:Q,continue:!Y.abort})}}),T8=F("$ZodE164",(Q,Y)=>{Y.pattern??(Y.pattern=PX),r.init(Q,Y)});function jH(Q,Y=null){try{let X=Q.split(".");if(X.length!==3)return!1;let[W]=X;if(!W)return!1;let G=JSON.parse(atob(W));if("typ"in G&&G?.typ!=="JWT")return!1;if(!G.alg)return!1;if(Y&&(!("alg"in G)||G.alg!==Y))return!1;return!0}catch{return!1}}var S8=F("$ZodJWT",(Q,Y)=>{r.init(Q,Y),Q._zod.check=(X)=>{if(jH(X.value,Y.alg))return;X.issues.push({code:"invalid_format",format:"jwt",input:X.value,inst:Q,continue:!Y.abort})}});var C6=F("$ZodNumber",(Q,Y)=>{i.init(Q,Y),Q._zod.pattern=Q._zod.bag.pattern??kX,Q._zod.parse=(X,W)=>{if(Y.coerce)try{X.value=Number(X.value)}catch(J){}let G=X.value;if(typeof G==="number"&&!Number.isNaN(G)&&Number.isFinite(G))return X;let $=typeof G==="number"?Number.isNaN(G)?"NaN":!Number.isFinite(G)?"Infinity":void 0:void 0;return X.issues.push({expected:"number",code:"invalid_type",input:G,inst:Q,...$?{received:$}:{}}),X}}),R8=F("$ZodNumber",(Q,Y)=>{hX.init(Q,Y),C6.init(Q,Y)}),C8=F("$ZodBoolean",(Q,Y)=>{i.init(Q,Y),Q._zod.pattern=vX,Q._zod.parse=(X,W)=>{if(Y.coerce)try{X.value=Boolean(X.value)}catch($){}let G=X.value;if(typeof G==="boolean")return X;return X.issues.push({expected:"boolean",code:"invalid_type",input:G,inst:Q}),X}});var k8=F("$ZodNull",(Q,Y)=>{i.init(Q,Y),Q._zod.pattern=xX,Q._zod.values=new Set([null]),Q._zod.parse=(X,W)=>{let G=X.value;if(G===null)return X;return X.issues.push({expected:"null",code:"invalid_type",input:G,inst:Q}),X}});var v8=F("$ZodUnknown",(Q,Y)=>{i.init(Q,Y),Q._zod.parse=(X)=>X}),x8=F("$ZodNever",(Q,Y)=>{i.init(Q,Y),Q._zod.parse=(X,W)=>{return X.issues.push({expected:"never",code:"invalid_type",input:X.value,inst:Q}),X}});function sX(Q,Y,X){if(Q.issues.length)Y.issues.push(...c0(X,Q.issues));Y.value[X]=Q.value}var _8=F("$ZodArray",(Q,Y)=>{i.init(Q,Y),Q._zod.parse=(X,W)=>{let G=X.value;if(!Array.isArray(G))return X.issues.push({expected:"array",code:"invalid_type",input:G,inst:Q}),X;X.value=Array(G.length);let $=[];for(let J=0;J<G.length;J++){let z=G[J],H=Y.element._zod.run({value:z,issues:[]},W);if(H instanceof Promise)$.push(H.then((A)=>sX(A,X,J)));else sX(H,X,J)}if($.length)return Promise.all($).then(()=>X);return X}});function QQ(Q,Y,X,W){if(Q.issues.length)Y.issues.push(...c0(X,Q.issues));if(Q.value===void 0){if(X in W)Y.value[X]=void 0}else Y.value[X]=Q.value}function y8(Q){let Y=Object.keys(Q.shape);for(let W of Y)if(!Q.shape?.[W]?._zod?.traits?.has("$ZodType"))throw Error(`Invalid element at key "${W}": expected a Zod schema`);let X=w6(Q.shape);return{...Q,keys:Y,keySet:new Set(Y),numKeys:Y.length,optionalKeys:new Set(X)}}function g8(Q,Y,X,W,G,$){let J=[],z=G.keySet,H=G.catchall._zod,A=H.def.type;for(let U of Object.keys(Y)){if(z.has(U))continue;if(A==="never"){J.push(U);continue}let K=H.run({value:Y[U],issues:[]},W);if(K instanceof Promise)Q.push(K.then((D)=>QQ(D,X,U,Y)));else QQ(K,X,U,Y)}if(J.length)X.issues.push({code:"unrecognized_keys",keys:J,input:Y,inst:$});if(!Q.length)return X;return Promise.all(Q).then(()=>{return X})}var EH=F("$ZodObject",(Q,Y)=>{if(i.init(Q,Y),!Object.getOwnPropertyDescriptor(Y,"shape")?.get){let z=Y.shape;Object.defineProperty(Y,"shape",{get:()=>{let H={...z};return Object.defineProperty(Y,"shape",{value:H}),H}})}let W=I1(()=>y8(Y));m(Q._zod,"propValues",()=>{let z=Y.shape,H={};for(let A in z){let U=z[A]._zod;if(U.values){H[A]??(H[A]=new Set);for(let K of U.values)H[A].add(K)}}return H});let G=F1,$=Y.catchall,J;Q._zod.parse=(z,H)=>{J??(J=W.value);let A=z.value;if(!G(A))return z.issues.push({expected:"object",code:"invalid_type",input:A,inst:Q}),z;z.value={};let U=[],K=J.shape;for(let D of J.keys){let q=K[D]._zod.run({value:A[D],issues:[]},H);if(q instanceof Promise)U.push(q.then((O)=>QQ(O,z,D,A)));else QQ(q,z,D,A)}if(!$)return U.length?Promise.all(U).then(()=>z):z;return g8(U,A,z,H,W.value,Q)}}),u8=F("$ZodObjectJIT",(Q,Y)=>{EH.init(Q,Y);let X=Q._zod.parse,W=I1(()=>y8(Y)),G=(D)=>{let L=new S6(["shape","payload","ctx"]),q=W.value,O=(E)=>{let x=i4(E);return`shape[${x}]._zod.run({ value: input[${x}], issues: [] }, ctx)`};L.write("const input = payload.value;");let V=Object.create(null),M=0;for(let E of q.keys)V[E]=`key_${M++}`;L.write("const newResult = {};");for(let E of q.keys){let x=V[E],T=i4(E);L.write(`const ${x} = ${O(E)};`),L.write(`
13
13
  if (${x}.issues.length) {
14
14
  payload.issues = payload.issues.concat(${x}.issues.map(iss => ({
15
15
  ...iss,
@@ -26,7 +26,7 @@ var _5=Object.create;var{getPrototypeOf:y5,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 gX([],q,D,L,K,Q)}return X(D,L)}});function e8(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 e8(z,G,Q,$);return Promise.all(z).then((H)=>{return e8(H,G,Q,$)})}}),hX=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}}),fX=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 QX(X,H,A)});return QX(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 QX(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 lX=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 mX=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}}),cX=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 pX=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 YX(Q,Y){if(Q.issues.length&&Y===void 0)return{issues:[],value:void 0};return Q}var iX=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(($)=>YX($,X.value));return YX(G,X.value)}if(X.value===void 0)return X;return Y.innerType._zod.run(X,W)}}),rX=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)}}),nX=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(($)=>XX($,Y));return XX(G,Y)}});function XX(Q,Y){if(Q.value===void 0)Q.value=Y.defaultValue;return Q}var dX=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)}}),oX=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(($)=>WX($,Q));return WX(G,Q)}});function WX(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 tX=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 aX=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 sX=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(GX);return GX(G)}});function GX(Q){return Q.value=Object.freeze(Q.value),Q}var eX=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(($)=>$X($,X,W,Q));$X(G,X,W,Q);return}});function $X(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 TH=(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},SH=()=>{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 ${TH(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:SH()}}var VV=Symbol("ZodOutput"),NV=Symbol("ZodInput");class QW{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 RH(){return new QW}var Q4=RH();function YW(Q,Y){return new Q({type:"string",...j(Y)})}function XW(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 WW(Q,Y){return new Q({type:"string",format:"uuid",check:"string_format",abort:!1,...j(Y)})}function GW(Q,Y){return new Q({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...j(Y)})}function $W(Q,Y){return new Q({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...j(Y)})}function JW(Q,Y){return new Q({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...j(Y)})}function zW(Q,Y){return new Q({type:"string",format:"url",check:"string_format",abort:!1,...j(Y)})}function HW(Q,Y){return new Q({type:"string",format:"emoji",check:"string_format",abort:!1,...j(Y)})}function AW(Q,Y){return new Q({type:"string",format:"nanoid",check:"string_format",abort:!1,...j(Y)})}function UW(Q,Y){return new Q({type:"string",format:"cuid",check:"string_format",abort:!1,...j(Y)})}function KW(Q,Y){return new Q({type:"string",format:"cuid2",check:"string_format",abort:!1,...j(Y)})}function DW(Q,Y){return new Q({type:"string",format:"ulid",check:"string_format",abort:!1,...j(Y)})}function BW(Q,Y){return new Q({type:"string",format:"xid",check:"string_format",abort:!1,...j(Y)})}function LW(Q,Y){return new Q({type:"string",format:"ksuid",check:"string_format",abort:!1,...j(Y)})}function FW(Q,Y){return new Q({type:"string",format:"ipv4",check:"string_format",abort:!1,...j(Y)})}function qW(Q,Y){return new Q({type:"string",format:"ipv6",check:"string_format",abort:!1,...j(Y)})}function OW(Q,Y){return new Q({type:"string",format:"cidrv4",check:"string_format",abort:!1,...j(Y)})}function MW(Q,Y){return new Q({type:"string",format:"cidrv6",check:"string_format",abort:!1,...j(Y)})}function VW(Q,Y){return new Q({type:"string",format:"base64",check:"string_format",abort:!1,...j(Y)})}function NW(Q,Y){return new Q({type:"string",format:"base64url",check:"string_format",abort:!1,...j(Y)})}function ZW(Q,Y){return new Q({type:"string",format:"e164",check:"string_format",abort:!1,...j(Y)})}function wW(Q,Y){return new Q({type:"string",format:"jwt",check:"string_format",abort:!1,...j(Y)})}function bW(Q,Y){return new Q({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...j(Y)})}function PW(Q,Y){return new Q({type:"string",format:"date",check:"string_format",...j(Y)})}function IW(Q,Y){return new Q({type:"string",format:"time",check:"string_format",precision:null,...j(Y)})}function jW(Q,Y){return new Q({type:"string",format:"duration",check:"string_format",...j(Y)})}function EW(Q,Y){return new Q({type:"number",checks:[],...j(Y)})}function TW(Q,Y){return new Q({type:"number",check:"number_format",abort:!1,format:"safeint",...j(Y)})}function SW(Q,Y){return new Q({type:"boolean",...j(Y)})}function RW(Q,Y){return new Q({type:"null",...j(Y)})}function CW(Q){return new Q({type:"unknown"})}function kW(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 u8({check:"multiple_of",...j(Y),value:Q})}function $Q(Q,Y){return new f8({check:"max_length",...j(Y),maximum:Q})}function E1(Q,Y){return new l8({check:"min_length",...j(Y),minimum:Q})}function JQ(Q,Y){return new m8({check:"length_equals",...j(Y),length:Q})}function _6(Q,Y){return new c8({check:"string_format",format:"regex",...j(Y),pattern:Q})}function y6(Q){return new p8({check:"string_format",format:"lowercase",...j(Q)})}function g6(Q){return new i8({check:"string_format",format:"uppercase",...j(Q)})}function u6(Q,Y){return new r8({check:"string_format",format:"includes",...j(Y),includes:Q})}function h6(Q,Y){return new n8({check:"string_format",format:"starts_with",...j(Y),prefix:Q})}function f6(Q,Y){return new d8({check:"string_format",format:"ends_with",...j(Y),suffix:Q})}function q1(Q){return new o8({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 vW(Q,Y,X){return new Q({type:"array",element:Y,...j(X)})}function xW(Q,Y,X){let W=j(X);return W.abort??(W.abort=!0),new Q({type:"custom",check:"custom",fn:Y,...W})}function _W(Q,Y,X){return new Q({type:"custom",check:"custom",fn:Y,...j(X)})}function yW(Q){let Y=CH((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 CH(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 gW(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={};h9(G4,{time:()=>n6,duration:()=>d6,datetime:()=>i6,date:()=>r6,ZodISOTime:()=>fW,ZodISODuration:()=>lW,ZodISODateTime:()=>uW,ZodISODate:()=>hW});var uW=F("ZodISODateTime",(Q,Y)=>{OX.init(Q,Y),d.init(Q,Y)});function i6(Q){return bW(uW,Q)}var hW=F("ZodISODate",(Q,Y)=>{MX.init(Q,Y),d.init(Q,Y)});function r6(Q){return PW(hW,Q)}var fW=F("ZodISOTime",(Q,Y)=>{VX.init(Q,Y),d.init(Q,Y)});function n6(Q){return IW(fW,Q)}var lW=F("ZodISODuration",(Q,Y)=>{NX.init(Q,Y),d.init(Q,Y)});function d6(Q){return jW(lW,Q)}var mW=(Q,Y)=>{d4.init(Q,Y),Q.name="ZodError",Object.defineProperties(Q,{format:{value:(X)=>e9(Q,X)},flatten:{value:(X)=>s9(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}}})},$N=F("ZodError",mW),N0=F("ZodError",mW,{Parent:Error});var cW=o4(N0),pW=t4(N0),iW=t1(N0),rW=s1(N0),nW=Q8(N0),dW=Y8(N0),oW=X8(N0),tW=W8(N0),aW=G8(N0),sW=$8(N0),eW=J8(N0),QG=z8(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)=>cW(Q,X,W,{callee:Q.parse}),Q.safeParse=(X,W)=>iW(Q,X,W),Q.parseAsync=async(X,W)=>pW(Q,X,W,{callee:Q.parseAsync}),Q.safeParseAsync=async(X,W)=>rW(Q,X,W),Q.spa=Q.safeParseAsync,Q.encode=(X,W)=>nW(Q,X,W),Q.decode=(X,W)=>dW(Q,X,W),Q.encodeAsync=async(X,W)=>oW(Q,X,W),Q.decodeAsync=async(X,W)=>tW(Q,X,W),Q.safeEncode=(X,W)=>aW(Q,X,W),Q.safeDecode=(X,W)=>sW(Q,X,W),Q.safeEncodeAsync=async(X,W)=>eW(Q,X,W),Q.safeDecodeAsync=async(X,W)=>QG(Q,X,W),Q.refine=(X,W)=>Q.check(EA(X,W)),Q.superRefine=(X)=>Q.check(TA(X)),Q.overwrite=(X)=>Q.check(q1(X)),Q.optional=()=>a(Q),Q.nullable=()=>WG(Q),Q.nullish=()=>a(WG(Q)),Q.nonoptional=(X)=>ZA(Q,X),Q.array=()=>_(Q),Q.or=(X)=>p([Q,X]),Q.and=(X)=>AQ(Q,X),Q.transform=(X)=>t6(Q,HG(X)),Q.default=(X)=>MA(Q,X),Q.prefault=(X)=>NA(Q,X),Q.catch=(X)=>bA(Q,X),Q.pipe=(X)=>t6(Q,X),Q.readonly=()=>jA(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}),GG=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())}),fH=F("ZodString",(Q,Y)=>{YQ.init(Q,Y),GG.init(Q,Y),Q.email=(X)=>Q.check(XW(lH,X)),Q.url=(X)=>Q.check(zW(mH,X)),Q.jwt=(X)=>Q.check(wW(WA,X)),Q.emoji=(X)=>Q.check(HW(cH,X)),Q.guid=(X)=>Q.check(x6(YG,X)),Q.uuid=(X)=>Q.check(WW(HQ,X)),Q.uuidv4=(X)=>Q.check(GW(HQ,X)),Q.uuidv6=(X)=>Q.check($W(HQ,X)),Q.uuidv7=(X)=>Q.check(JW(HQ,X)),Q.nanoid=(X)=>Q.check(AW(pH,X)),Q.guid=(X)=>Q.check(x6(YG,X)),Q.cuid=(X)=>Q.check(UW(iH,X)),Q.cuid2=(X)=>Q.check(KW(rH,X)),Q.ulid=(X)=>Q.check(DW(nH,X)),Q.base64=(X)=>Q.check(VW(QA,X)),Q.base64url=(X)=>Q.check(NW(YA,X)),Q.xid=(X)=>Q.check(BW(dH,X)),Q.ksuid=(X)=>Q.check(LW(oH,X)),Q.ipv4=(X)=>Q.check(FW(tH,X)),Q.ipv6=(X)=>Q.check(qW(aH,X)),Q.cidrv4=(X)=>Q.check(OW(sH,X)),Q.cidrv6=(X)=>Q.check(MW(eH,X)),Q.e164=(X)=>Q.check(ZW(XA,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 YW(fH,Q)}var d=F("ZodStringFormat",(Q,Y)=>{r.init(Q,Y),GG.init(Q,Y)}),lH=F("ZodEmail",(Q,Y)=>{HX.init(Q,Y),d.init(Q,Y)});var YG=F("ZodGUID",(Q,Y)=>{JX.init(Q,Y),d.init(Q,Y)});var HQ=F("ZodUUID",(Q,Y)=>{zX.init(Q,Y),d.init(Q,Y)});var mH=F("ZodURL",(Q,Y)=>{AX.init(Q,Y),d.init(Q,Y)});var cH=F("ZodEmoji",(Q,Y)=>{UX.init(Q,Y),d.init(Q,Y)});var pH=F("ZodNanoID",(Q,Y)=>{KX.init(Q,Y),d.init(Q,Y)});var iH=F("ZodCUID",(Q,Y)=>{DX.init(Q,Y),d.init(Q,Y)});var rH=F("ZodCUID2",(Q,Y)=>{BX.init(Q,Y),d.init(Q,Y)});var nH=F("ZodULID",(Q,Y)=>{LX.init(Q,Y),d.init(Q,Y)});var dH=F("ZodXID",(Q,Y)=>{FX.init(Q,Y),d.init(Q,Y)});var oH=F("ZodKSUID",(Q,Y)=>{qX.init(Q,Y),d.init(Q,Y)});var tH=F("ZodIPv4",(Q,Y)=>{ZX.init(Q,Y),d.init(Q,Y)});var aH=F("ZodIPv6",(Q,Y)=>{wX.init(Q,Y),d.init(Q,Y)});var sH=F("ZodCIDRv4",(Q,Y)=>{bX.init(Q,Y),d.init(Q,Y)});var eH=F("ZodCIDRv6",(Q,Y)=>{PX.init(Q,Y),d.init(Q,Y)});var QA=F("ZodBase64",(Q,Y)=>{jX.init(Q,Y),d.init(Q,Y)});var YA=F("ZodBase64URL",(Q,Y)=>{EX.init(Q,Y),d.init(Q,Y)});var XA=F("ZodE164",(Q,Y)=>{TX.init(Q,Y),d.init(Q,Y)});var WA=F("ZodJWT",(Q,Y)=>{SX.init(Q,Y),d.init(Q,Y)});var $G=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(XG(W)),Q.safe=(W)=>Q.check(XG(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 EW($G,Q)}var GA=F("ZodNumberFormat",(Q,Y)=>{RX.init(Q,Y),$G.init(Q,Y)});function XG(Q){return TW(GA,Q)}var $A=F("ZodBoolean",(Q,Y)=>{CX.init(Q,Y),s.init(Q,Y)});function X0(Q){return SW($A,Q)}var JA=F("ZodNull",(Q,Y)=>{kX.init(Q,Y),s.init(Q,Y)});function a6(Q){return RW(JA,Q)}var zA=F("ZodUnknown",(Q,Y)=>{vX.init(Q,Y),s.init(Q,Y)});function o(){return CW(zA)}var HA=F("ZodNever",(Q,Y)=>{xX.init(Q,Y),s.init(Q,Y)});function AA(Q){return kW(HA,Q)}var UA=F("ZodArray",(Q,Y)=>{_X.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 vW(UA,Q,Y)}var JG=F("ZodObject",(Q,Y)=>{uX.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:AA()}),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(AG,Q,X[0]),Q.required=(...X)=>h.required(UG,Q,X[0])});function w(Q,Y){let X={type:"object",shape:Q??{},...h.normalizeParams(Y)};return new JG(X)}function U0(Q,Y){return new JG({type:"object",shape:Q,catchall:o(),...h.normalizeParams(Y)})}var zG=F("ZodUnion",(Q,Y)=>{k6.init(Q,Y),s.init(Q,Y),Q.options=Y.options});function p(Q,Y){return new zG({type:"union",options:Q,...h.normalizeParams(Y)})}var KA=F("ZodDiscriminatedUnion",(Q,Y)=>{zG.init(Q,Y),hX.init(Q,Y)});function s6(Q,Y,X){return new KA({type:"union",options:Y,discriminator:Q,...h.normalizeParams(X)})}var DA=F("ZodIntersection",(Q,Y)=>{fX.init(Q,Y),s.init(Q,Y)});function AQ(Q,Y){return new DA({type:"intersection",left:Q,right:Y})}var BA=F("ZodRecord",(Q,Y)=>{lX.init(Q,Y),s.init(Q,Y),Q.keyType=Y.keyType,Q.valueType=Y.valueType});function t(Q,Y,X){return new BA({type:"record",keyType:Q,valueType:Y,...h.normalizeParams(X)})}var o6=F("ZodEnum",(Q,Y)=>{mX.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 LA=F("ZodLiteral",(Q,Y)=>{cX.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 LA({type:"literal",values:Array.isArray(Q)?Q:[Q],...h.normalizeParams(Y)})}var FA=F("ZodTransform",(Q,Y)=>{pX.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 HG(Q){return new FA({type:"transform",transform:Q})}var AG=F("ZodOptional",(Q,Y)=>{iX.init(Q,Y),s.init(Q,Y),Q.unwrap=()=>Q._zod.def.innerType});function a(Q){return new AG({type:"optional",innerType:Q})}var qA=F("ZodNullable",(Q,Y)=>{rX.init(Q,Y),s.init(Q,Y),Q.unwrap=()=>Q._zod.def.innerType});function WG(Q){return new qA({type:"nullable",innerType:Q})}var OA=F("ZodDefault",(Q,Y)=>{nX.init(Q,Y),s.init(Q,Y),Q.unwrap=()=>Q._zod.def.innerType,Q.removeDefault=Q.unwrap});function MA(Q,Y){return new OA({type:"default",innerType:Q,get defaultValue(){return typeof Y==="function"?Y():h.shallowClone(Y)}})}var VA=F("ZodPrefault",(Q,Y)=>{dX.init(Q,Y),s.init(Q,Y),Q.unwrap=()=>Q._zod.def.innerType});function NA(Q,Y){return new VA({type:"prefault",innerType:Q,get defaultValue(){return typeof Y==="function"?Y():h.shallowClone(Y)}})}var UG=F("ZodNonOptional",(Q,Y)=>{oX.init(Q,Y),s.init(Q,Y),Q.unwrap=()=>Q._zod.def.innerType});function ZA(Q,Y){return new UG({type:"nonoptional",innerType:Q,...h.normalizeParams(Y)})}var wA=F("ZodCatch",(Q,Y)=>{tX.init(Q,Y),s.init(Q,Y),Q.unwrap=()=>Q._zod.def.innerType,Q.removeCatch=Q.unwrap});function bA(Q,Y){return new wA({type:"catch",innerType:Q,catchValue:typeof Y==="function"?Y:()=>Y})}var PA=F("ZodPipe",(Q,Y)=>{aX.init(Q,Y),s.init(Q,Y),Q.in=Y.in,Q.out=Y.out});function t6(Q,Y){return new PA({type:"pipe",in:Q,out:Y})}var IA=F("ZodReadonly",(Q,Y)=>{sX.init(Q,Y),s.init(Q,Y),Q.unwrap=()=>Q._zod.def.innerType});function jA(Q){return new IA({type:"readonly",innerType:Q})}var KG=F("ZodCustom",(Q,Y)=>{eX.init(Q,Y),s.init(Q,Y)});function DG(Q,Y){return xW(KG,Q??(()=>!0),Y)}function EA(Q,Y={}){return _W(KG,Q,Y)}function TA(Q){return yW(Q)}function e6(Q,Y){return t6(HG(Q),Y)}w0(v6());var QY="2025-11-25";var BG=[QY,"2025-06-18","2025-03-26","2024-11-05","2024-10-07"],G1="io.modelcontextprotocol/related-task",KQ="2.0",G0=DG((Q)=>Q!==null&&(typeof Q==="object"||typeof Q==="function")),LG=p([B(),l().int()]),FG=B(),QZ=U0({ttl:p([l(),a6()]).optional(),pollInterval:l().optional()}),SA=w({ttl:l().optional()}),RA=w({taskId:B()}),YY=U0({progressToken:LG.optional(),[G1]:RA.optional()}),Z0=w({_meta:YY.optional()}),$4=Z0.extend({task:SA.optional()}),qG=(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()]),OG=w({jsonrpc:b(KQ),id:DQ,...$0.shape}).strict(),XY=(Q)=>OG.safeParse(Q).success,MG=w({jsonrpc:b(KQ),...P0.shape}).strict(),VG=(Q)=>MG.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 NG=(Q)=>GY.safeParse(Q).success;var ZG=p([OG,MG,WY,GY]),YZ=p([WY,GY]),BQ=J0.strict(),CA=b0.extend({requestId:DQ.optional(),reason:B().optional()}),LQ=P0.extend({method:b("notifications/cancelled"),params:CA}),kA=w({src:B(),mimeType:B().optional(),sizes:_(B()).optional(),theme:L0(["light","dark"]).optional()}),z4=w({icons:_(kA).optional()}),S1=w({name:B(),title:B().optional()}),wG=S1.extend({...S1.shape,...z4.shape,version:B(),websiteUrl:B().optional(),description:B().optional()}),vA=AQ(w({applyDefaults:X0().optional()}),t(B(),o())),xA=e6((Q)=>{if(Q&&typeof Q==="object"&&!Array.isArray(Q)){if(Object.keys(Q).length===0)return{form:{}}}return Q},AQ(w({form:vA.optional(),url:G0.optional()}),t(B(),o()).optional())),_A=U0({list:G0.optional(),cancel:G0.optional(),requests:U0({sampling:U0({createMessage:G0.optional()}).optional(),elicitation:U0({create:G0.optional()}).optional()}).optional()}),yA=U0({list:G0.optional(),cancel:G0.optional(),requests:U0({tools:U0({call:G0.optional()}).optional()}).optional()}),gA=w({experimental:t(B(),G0).optional(),sampling:w({context:G0.optional(),tools:G0.optional()}).optional(),elicitation:xA.optional(),roots:w({listChanged:X0().optional()}).optional(),tasks:_A.optional()}),uA=Z0.extend({protocolVersion:B(),capabilities:gA,clientInfo:wG}),$Y=$0.extend({method:b("initialize"),params:uA});var hA=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:yA.optional()}),fA=J0.extend({protocolVersion:B(),capabilities:hA,serverInfo:wG,instructions:B().optional()}),JY=P0.extend({method:b("notifications/initialized"),params:b0.optional()});var FQ=$0.extend({method:b("ping"),params:Z0.optional()}),lA=w({progress:l(),total:a(l()),message:a(B())}),mA=w({...b0.shape,...lA.shape,progressToken:LG}),qQ=P0.extend({method:b("notifications/progress"),params:mA}),cA=Z0.extend({cursor:FG.optional()}),H4=$0.extend({params:cA.optional()}),A4=J0.extend({nextCursor:FG.optional()}),pA=L0(["working","input_required","completed","failed","cancelled"]),U4=w({taskId:B(),status:pA,ttl:p([l(),a6()]),createdAt:B(),lastUpdatedAt:B(),pollInterval:a(l()),statusMessage:a(B())}),R1=J0.extend({task:U4}),iA=b0.merge(U4),K4=P0.extend({method:b("notifications/tasks/status"),params:iA}),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()})}),XZ=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()})}),bG=J0.merge(U4),PG=w({uri:B(),mimeType:a(B()),_meta:t(B(),o()).optional()}),IG=PG.extend({text:B()}),zY=B().refine((Q)=>{try{return atob(Q),!0}catch{return!1}},{message:"Invalid Base64 string"}),jG=PG.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()}),EG=w({...S1.shape,...z4.shape,uri:B(),description:a(B()),mimeType:a(B()),annotations:C1.optional(),_meta:a(U0({}))}),rA=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")}),nA=A4.extend({resources:_(EG)}),dA=H4.extend({method:b("resources/templates/list")}),oA=A4.extend({resourceTemplates:_(rA)}),AY=Z0.extend({uri:B()}),tA=AY,UY=$0.extend({method:b("resources/read"),params:tA}),aA=J0.extend({contents:_(p([IG,jG]))}),sA=P0.extend({method:b("notifications/resources/list_changed"),params:b0.optional()}),eA=AY,QU=$0.extend({method:b("resources/subscribe"),params:eA}),YU=AY,XU=$0.extend({method:b("resources/unsubscribe"),params:YU}),WU=b0.extend({uri:B()}),GU=P0.extend({method:b("notifications/resources/updated"),params:WU}),$U=w({name:B(),description:a(B()),required:a(X0())}),JU=w({...S1.shape,...z4.shape,description:a(B()),arguments:a(_($U)),_meta:a(U0({}))}),zU=H4.extend({method:b("prompts/list")}),HU=A4.extend({prompts:_(JU)}),AU=Z0.extend({name:B(),arguments:t(B(),B()).optional()}),UU=$0.extend({method:b("prompts/get"),params:AU}),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()}),KU=w({type:b("tool_use"),name:B(),id:B(),input:t(B(),o()),_meta:t(B(),o()).optional()}),DU=w({type:b("resource"),resource:p([IG,jG]),annotations:C1.optional(),_meta:t(B(),o()).optional()}),BU=EG.extend({type:b("resource_link")}),LY=p([KY,DY,BY,BU,DU]),LU=w({role:D4,content:LY}),FU=J0.extend({description:B().optional(),messages:_(LU)}),qU=P0.extend({method:b("notifications/prompts/list_changed"),params:b0.optional()}),OU=w({title:B().optional(),readOnlyHint:X0().optional(),destructiveHint:X0().optional(),idempotentHint:X0().optional(),openWorldHint:X0().optional()}),MU=w({taskSupport:L0(["required","optional","forbidden"]).optional()}),TG=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:OU.optional(),execution:MU.optional(),_meta:t(B(),o()).optional()}),FY=H4.extend({method:b("tools/list")}),VU=A4.extend({tools:_(TG)}),bQ=J0.extend({content:_(LY).default([]),structuredContent:t(B(),o()).optional(),isError:X0().optional()}),WZ=bQ.or(J0.extend({toolResult:o()})),NU=$4.extend({name:B(),arguments:t(B(),o()).optional()}),B4=$0.extend({method:b("tools/call"),params:NU}),ZU=P0.extend({method:b("notifications/tools/list_changed"),params:b0.optional()}),GZ=w({autoRefresh:X0().default(!0),debounceMs:l().int().nonnegative().default(300)}),L4=L0(["debug","info","notice","warning","error","critical","alert","emergency"]),wU=Z0.extend({level:L4}),qY=$0.extend({method:b("logging/setLevel"),params:wU}),bU=b0.extend({level:L4,logger:B().optional(),data:o()}),PU=P0.extend({method:b("notifications/message"),params:bU}),IU=w({name:B().optional()}),jU=w({hints:_(IU).optional(),costPriority:l().min(0).max(1).optional(),speedPriority:l().min(0).max(1).optional(),intelligencePriority:l().min(0).max(1).optional()}),EU=w({mode:L0(["auto","required","none"]).optional()}),TU=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()}),SU=s6("type",[KY,DY,BY]),UQ=s6("type",[KY,DY,BY,KU,TU]),RU=w({role:D4,content:p([UQ,_(UQ)]),_meta:t(B(),o()).optional()}),CU=$4.extend({messages:_(RU),modelPreferences:jU.optional(),systemPrompt:B().optional(),includeContext:L0(["none","thisServer","allServers"]).optional(),temperature:l().optional(),maxTokens:l().int(),stopSequences:_(B()).optional(),metadata:G0.optional(),tools:_(TG).optional(),toolChoice:EU.optional()}),kU=$0.extend({method:b("sampling/createMessage"),params:CU}),OY=J0.extend({model:B(),stopReason:a(L0(["endTurn","stopSequence","maxTokens"]).or(B())),role:D4,content:SU}),MY=J0.extend({model:B(),stopReason:a(L0(["endTurn","stopSequence","maxTokens","toolUse"]).or(B())),role:D4,content:p([UQ,_(UQ)])}),vU=w({type:b("boolean"),title:B().optional(),description:B().optional(),default:X0().optional()}),xU=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()}),_U=w({type:L0(["number","integer"]),title:B().optional(),description:B().optional(),minimum:l().optional(),maximum:l().optional(),default:l().optional()}),yU=w({type:b("string"),title:B().optional(),description:B().optional(),enum:_(B()),default:B().optional()}),gU=w({type:b("string"),title:B().optional(),description:B().optional(),oneOf:_(w({const:B(),title:B()})),default:B().optional()}),uU=w({type:b("string"),title:B().optional(),description:B().optional(),enum:_(B()),enumNames:_(B()).optional(),default:B().optional()}),hU=p([yU,gU]),fU=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()}),lU=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()}),mU=p([fU,lU]),cU=p([uU,hU,mU]),pU=p([cU,vU,xU,_U]),iU=$4.extend({mode:b("form").optional(),message:B(),requestedSchema:w({type:b("object"),properties:t(B(),pU),required:_(B()).optional()})}),rU=$4.extend({mode:b("url"),message:B(),elicitationId:B(),url:B().url()}),nU=p([iU,rU]),dU=$0.extend({method:b("elicitation/create"),params:nU}),oU=b0.extend({elicitationId:B()}),tU=P0.extend({method:b("notifications/elicitation/complete"),params:oU}),PQ=J0.extend({action:L0(["accept","decline","cancel"]),content:e6((Q)=>Q===null?void 0:Q,t(B(),p([B(),l(),X0(),_(B())])).optional())}),aU=w({type:b("ref/resource"),uri:B()});var sU=w({type:b("ref/prompt"),name:B()}),eU=Z0.extend({ref:p([sU,aU]),argument:w({name:B(),value:B()}),context:w({arguments:t(B(),B()).optional()}).optional()}),Q3=$0.extend({method:b("completion/complete"),params:eU});var Y3=J0.extend({completion:U0({values:_(B()).max(100),total:a(l().int()),hasMore:a(X0())})}),X3=w({uri:B().startsWith("file://"),name:B().optional(),_meta:t(B(),o()).optional()}),W3=$0.extend({method:b("roots/list"),params:Z0.optional()}),VY=J0.extend({roots:_(X3)}),G3=P0.extend({method:b("notifications/roots/list_changed"),params:b0.optional()}),$Z=p([FQ,$Y,Q3,qY,UU,zU,HY,dA,UY,QU,XU,B4,FY,OQ,VQ,NQ,wQ]),JZ=p([LQ,qQ,JY,G3,K4]),zZ=p([BQ,OY,MY,PQ,VY,MQ,ZQ,R1]),HZ=p([FQ,kU,dU,W3,OQ,VQ,NQ,wQ]),AZ=p([LQ,qQ,PU,GU,sA,ZU,qU,K4,tU]),UZ=p([BQ,fA,Y3,FU,HU,nA,oA,aA,bQ,VU,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 SG(W.elicitations,Y)}return new k(Q,Y,X)}}class SG 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 $3=Symbol("Let zodToJsonSchema decide on which parser to use");var cZ=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function NY(Q){let X=zQ(Q)?.method;if(!X)throw Error("Schema is missing a method literal");let W=gW(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 K3=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)||NG(G))this._onresponse(G);else if(XY(G))this._onrequest(G,$);else if(VG(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=qG(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??K3,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},bG,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 RG(Q){return Q!==null&&typeof Q==="object"&&!Array.isArray(Q)}function CG(Q,Y){let X={...Q};for(let W in Y){let G=W,$=Y[G];if($===void 0)continue;let J=X[G];if(RG(J)&&RG($))X[G]={...J,...$};else X[G]=$}return X}var H5=u9(q9(),1),A5=u9(z5(),1);function NM(){let Q=new H5.default({strict:!1,validateFormats:!0,validateSchema:!1,allErrors:!0});return A5.default(Q),Q}class j9{constructor(Q){this._ajv=Q??NM()}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 U5(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 K5(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=CG(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){K5(this._clientCapabilities?.tasks?.requests,Q,"Client")}assertTaskHandlerCapability(Q){if(!this._capabilities)return;U5(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:BG.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 D5={name:"@sequenzy/mcp",version:"0.0.48",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"],B5={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 wM(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 L5(Q,Y,X){return Q0(Q,`${Y0(Y,"/settings")}?tab=${encodeURIComponent(X)}`)}function bM(Q,Y){let X=S9.map((W)=>[W,Y?L5(Q,Y,W):""]);return Object.fromEntries(X)}function B1(Q={},Y){let X=wM(Y),W=h0(Q.companyId),G={},$=bM(X,W);if(!W)return{appUrl:X,routeTemplates:B5,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=L5(X,W,L);return{appUrl:X,routeTemplates:B5,settingsTabValues:S9,urls:G,settingsUrls:$}}var F5=[{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 q5(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`.",w5="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.",O5=100,C9={status:["is","is_not"],tag:["contains","not_contains","is_empty","is_not_empty"],email:["contains","not_contains"],emailProvider:["is","is_not","is_empty","is_not_empty"],added:["less_than","more_than"],firstName:["contains","not_contains","is_empty","is_not_empty"],lastName:["contains","not_contains","is_empty","is_not_empty"],list:["is","is_not","is_empty","is_not_empty"],emailSent:["is","is_not","at_least","less_than_count"],emailDelivered:["is","is_not","at_least","less_than_count"],emailOpened:["is","is_not","at_least","less_than_count"],emailClicked:["is","is_not","at_least","less_than_count"],emailBounced:["is","is_temporary_bounce","is_permanent_bounce","is_not","at_least","less_than_count"],emailComplained:["is","is_not","at_least","less_than_count"],attribute:["is","is_not","is_empty","is_not_empty","gte","lte","gt","lt","contains","not_contains"],event:["is","is_not","at_least","less_than_count"],segment:["is","is_not"],stripeProduct:["is","is_not","at_least","less_than_count"],stripeCurrentProduct:["is","is_not","gte","lte","gt","lt"],stripeTrialProduct:["is","is_not","gte","lte","gt","lt"]},PM=Object.entries(C9).map(([Q,Y])=>`${Q}: ${Y.join(", ")}`).join("; "),IM={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","emailDelivered","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`, `emailDelivered`, `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","is_temporary_bounce","is_permanent_bounce","at_least","less_than_count","gte","lte","gt","lt"],description:`Filter operator. Allowed operators by field: ${PM}.`},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/current/trialing, `prod_123:3` for payment thresholds, `prod_123:is_canceled` for products set to cancel, `prod_123:cancels_at:2026-05-26`, `prod_123:end_at:2026-05-26`, or `prod_123:start_at:7 days ago` for product-scoped dates. 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},jM={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 b5(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 P5(Q){if(typeof Q!=="object"||Q===null)return Q;let Y=Q;if(Y.kind==="filter"||"field"in Y||"operator"in Y||"value"in Y){let X=b5([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(P5):[]}}function EM(Q){let Y=Q.indexOf(":");return Y!==-1&&Q.substring(0,Y).trim().length>0}function TM(Q){let Y=Q.indexOf(":");return Y!==-1&&Q.substring(Y+1).trim().length>0}function M5(Q){if(Q==="all")return!0;let Y=Q.match(/^(\d+)d$/);if(!Y?.[1])return!1;let X=Number.parseInt(Y[1],10);return Number.isInteger(X)&&X>0}function SM(Q,Y){let X=Y.split(":");if(Q==="at_least"||Q==="less_than_count"){if(X.length<3)return'Event count filters must use "eventName:count:timeRange", like "saas.purchase:2:30d".';let $=X.slice(0,-2).join(":").trim(),J=X.at(-2),z=X.at(-1),H=J===void 0?Number.NaN:Number.parseInt(J,10);return $&&Number.isInteger(H)&&H>0&&z!==void 0&&M5(z)?null:'Event count filters must use "eventName:count:timeRange", like "saas.purchase:2:30d".'}if(X.length<2)return'Event filters must use "eventName:timeRange", like "saas.purchase:30d".';let W=X.slice(0,-1).join(":").trim(),G=X.at(-1);return W&&G!==void 0&&M5(G)?null:'Event filters must use "eventName:timeRange", like "saas.purchase:30d".'}function RM(Q){let Y=Q.indexOf(":");if(Y===-1)return{productId:Q,subfilter:null,rawValue:null};let X=Q.substring(0,Y),W=Q.substring(Y+1),G=W.indexOf(":");if(G===-1)return{productId:X,subfilter:W,rawValue:null};return{productId:X,subfilter:W.substring(0,G),rawValue:W.substring(G+1)}}function CM(Q){return Q.trim().toLowerCase().replace(/[-\s]+/g,"_")}function kM(Q){return["is_canceled","is_cancelled","canceled","cancelled","will_cancel","cancel_at_period_end","is_not_canceled","is_not_cancelled","not_canceled","not_cancelled","will_not_cancel"].includes(Q)}function vM(Q,Y){if(Y==="cancels_at"||Y==="cancel_at"||Y==="cancellation_at")return!0;if(Q==="stripeCurrentProduct")return["end_at","ends_at","period_end","period_ends_at","current_period_end"].includes(Y);return["start_at","started_at","trial_start","trial_started_at","end_at","ends_at","trial_end","trial_ends_at"].includes(Y)}function xM(Q){return["is","is_not","gte","lte","gt","lt"].includes(Q)}function _M(Q,Y,X){if(Q==="stripeProduct"){if(Y!=="at_least"&&Y!=="less_than_count")return null;let z=X.indexOf(":");if(z===-1)return null;let H=X.substring(0,z).trim(),A=Number.parseInt(X.substring(z+1).trim(),10);return H&&Number.isInteger(A)&&A>=1?null:'Stripe Product threshold filters must use "productId:count" with a count of at least 1.'}if(Q!=="stripeCurrentProduct"&&Q!=="stripeTrialProduct")return null;let{productId:W,subfilter:G,rawValue:$}=RM(X);if(!W.trim())return"Stripe product filters must include a product ID.";if(!G)return Y==="is"||Y==="is_not"?null:'Stripe current/trial date filters must use "productId:dateField:value".';let J=CM(G);if(kM(J))return Y==="is"||Y==="is_not"?null:"Stripe cancellation flag filters only support is and is_not operators.";if(!vM(Q,J))return`Unsupported Stripe product subfilter "${G}".`;if(!xM(Y))return"Stripe date filters only support is, is_not, gte, lte, gt, and lt operators.";return $?.trim()?null:'Stripe date filters must include a value like "productId:end_at:2026-05-26".'}function I5(Q){if(typeof Q!=="object"||Q===null)return"Segment filters must be objects.";let Y=Q,X=Y.field,W=Y.operator,G=Y.value;if(typeof X!=="string"||!(X in C9))return`Unsupported segment filter field "${String(X)}".`;if(typeof W!=="string")return`Segment filter "${X}" must include an operator.`;let $=C9[X];if(!$.includes(W))return`Operator "${W}" is not supported for ${X} filters. Use one of: ${$.join(", ")}.`;if(W!=="is_empty"&&W!=="is_not_empty"&&(typeof G!=="string"||G.trim().length===0))return`Segment filter "${X}" must include a value.`;if(X==="attribute"&&typeof G==="string"){if(!EM(G))return'Attribute filters must use "attributeName:value" or "attributeName:" for empty checks.';if(W!=="is_empty"&&W!=="is_not_empty"&&!TM(G))return'Attribute filters must include a value after "attributeName:".'}if(X==="event"&&typeof G==="string"){let J=SM(W,G);if(J)return J}if((X==="stripeProduct"||X==="stripeCurrentProduct"||X==="stripeTrialProduct")&&typeof G==="string"){let J=_M(X,W,G);if(J)return J}if(X==="tag"&&(W==="contains"||W==="not_contains")){if(!(typeof G==="string"&&G.split(",").map((z)=>z.trim()).some(Boolean)))return"Tag filters must include at least one tag name."}return null}function j5(Q){if(typeof Q!=="object"||Q===null)return[];let Y=Q;if(Y.kind==="filter"||"field"in Y||"operator"in Y||"value"in Y){let X=I5(Y);return X?[X]:[]}if(Array.isArray(Y.children))return Y.children.flatMap(j5);return[]}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 yM(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`.");let W=Y?Q.filters.flatMap((G)=>{let $=I5(G);return $?[$]:[]}):j5(Q.root);if(W.length>0)throw Error(W[0]??"Invalid segment filter in `create_segment`.")}function gM(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 uM(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 hM(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 fM(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 lM(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 V5={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:w5,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 mM(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 N5(Q){return Q.trim().toLowerCase().replace(/\s+/g,"-")}function cM(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 pM(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=cM({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 iM(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=iM(Y);if(!X.email&&!X.externalId)throw Error(`Provide either \`email\` or \`externalId\` when calling \`${Q}\`.`);return X}function k9(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",k9(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}function rM(Q,Y,X){let W=I(Y,X);if(W===void 0)throw Error(`\`${X}\` is required when calling \`${Q}\`.`);return W}function Z5(Q,Y,X,W){let G=I(Y,X);if(G===void 0)return;if(!W.includes(G))throw Error(`\`${X}\` must be one of ${W.join(", ")} when calling \`${Q}\`.`);return G}function nM(Q,Y){if(!Array.isArray(Y.emails))throw Error(`\`emails\` must be an array when calling \`${Q}\`.`);let X=[];if(Y.emails.forEach((W,G)=>{if(typeof W!=="string")throw Error(`\`emails\` item ${G+1} must be a string when calling \`${Q}\`.`);let $=W.trim();if($.length>0)X.push($)}),X.length===0)throw Error(`\`emails\` must include at least one email address when calling \`${Q}\`.`);if(X.length>O5)throw Error(`\`emails\` must include no more than ${O5} email addresses when calling \`${Q}\`. Split larger batches into multiple calls.`);return X}async function E5(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 T5(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 T5(W,$.urls);let J=X==="sequence"?$.urls.sequence:X==="template"?$.urls.email:$.urls.transactionalEmail;return l4(W,J)})}function dM(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 oM=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 tM(Q,Y,X){if(!B0(X)||!oM.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 E5(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:dM(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:T5(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 S5=[{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 g8([],q,D,L,K,Q)}return X(D,L)}});function eX(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 eX(z,G,Q,$);return Promise.all(z).then((H)=>{return eX(H,G,Q,$)})}}),h8=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}}),f8=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 Q8(X,H,A)});return Q8(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 Q8(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 l8=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 m8=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}}),c8=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 p8=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 Y8(Q,Y){if(Q.issues.length&&Y===void 0)return{issues:[],value:void 0};return Q}var i8=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(($)=>Y8($,X.value));return Y8(G,X.value)}if(X.value===void 0)return X;return Y.innerType._zod.run(X,W)}}),r8=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)}}),n8=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(($)=>X8($,Y));return X8(G,Y)}});function X8(Q,Y){if(Q.value===void 0)Q.value=Y.defaultValue;return Q}var d8=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)}}),o8=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(($)=>W8($,Q));return W8(G,Q)}});function W8(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 t8=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 a8=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 s8=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(G8);return G8(G)}});function G8(Q){return Q.value=Object.freeze(Q.value),Q}var e8=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(($)=>$8($,X,W,Q));$8(G,X,W,Q);return}});function $8(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 TH=(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},SH=()=>{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 ${TH(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:SH()}}var VV=Symbol("ZodOutput"),NV=Symbol("ZodInput");class QW{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 RH(){return new QW}var Q4=RH();function YW(Q,Y){return new Q({type:"string",...j(Y)})}function XW(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 WW(Q,Y){return new Q({type:"string",format:"uuid",check:"string_format",abort:!1,...j(Y)})}function GW(Q,Y){return new Q({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...j(Y)})}function $W(Q,Y){return new Q({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...j(Y)})}function JW(Q,Y){return new Q({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...j(Y)})}function zW(Q,Y){return new Q({type:"string",format:"url",check:"string_format",abort:!1,...j(Y)})}function HW(Q,Y){return new Q({type:"string",format:"emoji",check:"string_format",abort:!1,...j(Y)})}function AW(Q,Y){return new Q({type:"string",format:"nanoid",check:"string_format",abort:!1,...j(Y)})}function UW(Q,Y){return new Q({type:"string",format:"cuid",check:"string_format",abort:!1,...j(Y)})}function KW(Q,Y){return new Q({type:"string",format:"cuid2",check:"string_format",abort:!1,...j(Y)})}function DW(Q,Y){return new Q({type:"string",format:"ulid",check:"string_format",abort:!1,...j(Y)})}function BW(Q,Y){return new Q({type:"string",format:"xid",check:"string_format",abort:!1,...j(Y)})}function LW(Q,Y){return new Q({type:"string",format:"ksuid",check:"string_format",abort:!1,...j(Y)})}function FW(Q,Y){return new Q({type:"string",format:"ipv4",check:"string_format",abort:!1,...j(Y)})}function qW(Q,Y){return new Q({type:"string",format:"ipv6",check:"string_format",abort:!1,...j(Y)})}function OW(Q,Y){return new Q({type:"string",format:"cidrv4",check:"string_format",abort:!1,...j(Y)})}function MW(Q,Y){return new Q({type:"string",format:"cidrv6",check:"string_format",abort:!1,...j(Y)})}function VW(Q,Y){return new Q({type:"string",format:"base64",check:"string_format",abort:!1,...j(Y)})}function NW(Q,Y){return new Q({type:"string",format:"base64url",check:"string_format",abort:!1,...j(Y)})}function ZW(Q,Y){return new Q({type:"string",format:"e164",check:"string_format",abort:!1,...j(Y)})}function wW(Q,Y){return new Q({type:"string",format:"jwt",check:"string_format",abort:!1,...j(Y)})}function bW(Q,Y){return new Q({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...j(Y)})}function PW(Q,Y){return new Q({type:"string",format:"date",check:"string_format",...j(Y)})}function IW(Q,Y){return new Q({type:"string",format:"time",check:"string_format",precision:null,...j(Y)})}function jW(Q,Y){return new Q({type:"string",format:"duration",check:"string_format",...j(Y)})}function EW(Q,Y){return new Q({type:"number",checks:[],...j(Y)})}function TW(Q,Y){return new Q({type:"number",check:"number_format",abort:!1,format:"safeint",...j(Y)})}function SW(Q,Y){return new Q({type:"boolean",...j(Y)})}function RW(Q,Y){return new Q({type:"null",...j(Y)})}function CW(Q){return new Q({type:"unknown"})}function kW(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 uX({check:"multiple_of",...j(Y),value:Q})}function $Q(Q,Y){return new fX({check:"max_length",...j(Y),maximum:Q})}function E1(Q,Y){return new lX({check:"min_length",...j(Y),minimum:Q})}function JQ(Q,Y){return new mX({check:"length_equals",...j(Y),length:Q})}function _6(Q,Y){return new cX({check:"string_format",format:"regex",...j(Y),pattern:Q})}function y6(Q){return new pX({check:"string_format",format:"lowercase",...j(Q)})}function g6(Q){return new iX({check:"string_format",format:"uppercase",...j(Q)})}function u6(Q,Y){return new rX({check:"string_format",format:"includes",...j(Y),includes:Q})}function h6(Q,Y){return new nX({check:"string_format",format:"starts_with",...j(Y),prefix:Q})}function f6(Q,Y){return new dX({check:"string_format",format:"ends_with",...j(Y),suffix:Q})}function q1(Q){return new oX({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 vW(Q,Y,X){return new Q({type:"array",element:Y,...j(X)})}function xW(Q,Y,X){let W=j(X);return W.abort??(W.abort=!0),new Q({type:"custom",check:"custom",fn:Y,...W})}function _W(Q,Y,X){return new Q({type:"custom",check:"custom",fn:Y,...j(X)})}function yW(Q){let Y=CH((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 CH(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 gW(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={};h9(G4,{time:()=>n6,duration:()=>d6,datetime:()=>i6,date:()=>r6,ZodISOTime:()=>fW,ZodISODuration:()=>lW,ZodISODateTime:()=>uW,ZodISODate:()=>hW});var uW=F("ZodISODateTime",(Q,Y)=>{O8.init(Q,Y),d.init(Q,Y)});function i6(Q){return bW(uW,Q)}var hW=F("ZodISODate",(Q,Y)=>{M8.init(Q,Y),d.init(Q,Y)});function r6(Q){return PW(hW,Q)}var fW=F("ZodISOTime",(Q,Y)=>{V8.init(Q,Y),d.init(Q,Y)});function n6(Q){return IW(fW,Q)}var lW=F("ZodISODuration",(Q,Y)=>{N8.init(Q,Y),d.init(Q,Y)});function d6(Q){return jW(lW,Q)}var mW=(Q,Y)=>{d4.init(Q,Y),Q.name="ZodError",Object.defineProperties(Q,{format:{value:(X)=>e9(Q,X)},flatten:{value:(X)=>s9(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}}})},$N=F("ZodError",mW),N0=F("ZodError",mW,{Parent:Error});var cW=o4(N0),pW=t4(N0),iW=t1(N0),rW=s1(N0),nW=QX(N0),dW=YX(N0),oW=XX(N0),tW=WX(N0),aW=GX(N0),sW=$X(N0),eW=JX(N0),QG=zX(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)=>cW(Q,X,W,{callee:Q.parse}),Q.safeParse=(X,W)=>iW(Q,X,W),Q.parseAsync=async(X,W)=>pW(Q,X,W,{callee:Q.parseAsync}),Q.safeParseAsync=async(X,W)=>rW(Q,X,W),Q.spa=Q.safeParseAsync,Q.encode=(X,W)=>nW(Q,X,W),Q.decode=(X,W)=>dW(Q,X,W),Q.encodeAsync=async(X,W)=>oW(Q,X,W),Q.decodeAsync=async(X,W)=>tW(Q,X,W),Q.safeEncode=(X,W)=>aW(Q,X,W),Q.safeDecode=(X,W)=>sW(Q,X,W),Q.safeEncodeAsync=async(X,W)=>eW(Q,X,W),Q.safeDecodeAsync=async(X,W)=>QG(Q,X,W),Q.refine=(X,W)=>Q.check(EA(X,W)),Q.superRefine=(X)=>Q.check(TA(X)),Q.overwrite=(X)=>Q.check(q1(X)),Q.optional=()=>a(Q),Q.nullable=()=>WG(Q),Q.nullish=()=>a(WG(Q)),Q.nonoptional=(X)=>ZA(Q,X),Q.array=()=>_(Q),Q.or=(X)=>p([Q,X]),Q.and=(X)=>AQ(Q,X),Q.transform=(X)=>t6(Q,HG(X)),Q.default=(X)=>MA(Q,X),Q.prefault=(X)=>NA(Q,X),Q.catch=(X)=>bA(Q,X),Q.pipe=(X)=>t6(Q,X),Q.readonly=()=>jA(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}),GG=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())}),fH=F("ZodString",(Q,Y)=>{YQ.init(Q,Y),GG.init(Q,Y),Q.email=(X)=>Q.check(XW(lH,X)),Q.url=(X)=>Q.check(zW(mH,X)),Q.jwt=(X)=>Q.check(wW(WA,X)),Q.emoji=(X)=>Q.check(HW(cH,X)),Q.guid=(X)=>Q.check(x6(YG,X)),Q.uuid=(X)=>Q.check(WW(HQ,X)),Q.uuidv4=(X)=>Q.check(GW(HQ,X)),Q.uuidv6=(X)=>Q.check($W(HQ,X)),Q.uuidv7=(X)=>Q.check(JW(HQ,X)),Q.nanoid=(X)=>Q.check(AW(pH,X)),Q.guid=(X)=>Q.check(x6(YG,X)),Q.cuid=(X)=>Q.check(UW(iH,X)),Q.cuid2=(X)=>Q.check(KW(rH,X)),Q.ulid=(X)=>Q.check(DW(nH,X)),Q.base64=(X)=>Q.check(VW(QA,X)),Q.base64url=(X)=>Q.check(NW(YA,X)),Q.xid=(X)=>Q.check(BW(dH,X)),Q.ksuid=(X)=>Q.check(LW(oH,X)),Q.ipv4=(X)=>Q.check(FW(tH,X)),Q.ipv6=(X)=>Q.check(qW(aH,X)),Q.cidrv4=(X)=>Q.check(OW(sH,X)),Q.cidrv6=(X)=>Q.check(MW(eH,X)),Q.e164=(X)=>Q.check(ZW(XA,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 YW(fH,Q)}var d=F("ZodStringFormat",(Q,Y)=>{r.init(Q,Y),GG.init(Q,Y)}),lH=F("ZodEmail",(Q,Y)=>{H8.init(Q,Y),d.init(Q,Y)});var YG=F("ZodGUID",(Q,Y)=>{J8.init(Q,Y),d.init(Q,Y)});var HQ=F("ZodUUID",(Q,Y)=>{z8.init(Q,Y),d.init(Q,Y)});var mH=F("ZodURL",(Q,Y)=>{A8.init(Q,Y),d.init(Q,Y)});var cH=F("ZodEmoji",(Q,Y)=>{U8.init(Q,Y),d.init(Q,Y)});var pH=F("ZodNanoID",(Q,Y)=>{K8.init(Q,Y),d.init(Q,Y)});var iH=F("ZodCUID",(Q,Y)=>{D8.init(Q,Y),d.init(Q,Y)});var rH=F("ZodCUID2",(Q,Y)=>{B8.init(Q,Y),d.init(Q,Y)});var nH=F("ZodULID",(Q,Y)=>{L8.init(Q,Y),d.init(Q,Y)});var dH=F("ZodXID",(Q,Y)=>{F8.init(Q,Y),d.init(Q,Y)});var oH=F("ZodKSUID",(Q,Y)=>{q8.init(Q,Y),d.init(Q,Y)});var tH=F("ZodIPv4",(Q,Y)=>{Z8.init(Q,Y),d.init(Q,Y)});var aH=F("ZodIPv6",(Q,Y)=>{w8.init(Q,Y),d.init(Q,Y)});var sH=F("ZodCIDRv4",(Q,Y)=>{b8.init(Q,Y),d.init(Q,Y)});var eH=F("ZodCIDRv6",(Q,Y)=>{P8.init(Q,Y),d.init(Q,Y)});var QA=F("ZodBase64",(Q,Y)=>{j8.init(Q,Y),d.init(Q,Y)});var YA=F("ZodBase64URL",(Q,Y)=>{E8.init(Q,Y),d.init(Q,Y)});var XA=F("ZodE164",(Q,Y)=>{T8.init(Q,Y),d.init(Q,Y)});var WA=F("ZodJWT",(Q,Y)=>{S8.init(Q,Y),d.init(Q,Y)});var $G=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(XG(W)),Q.safe=(W)=>Q.check(XG(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 EW($G,Q)}var GA=F("ZodNumberFormat",(Q,Y)=>{R8.init(Q,Y),$G.init(Q,Y)});function XG(Q){return TW(GA,Q)}var $A=F("ZodBoolean",(Q,Y)=>{C8.init(Q,Y),s.init(Q,Y)});function X0(Q){return SW($A,Q)}var JA=F("ZodNull",(Q,Y)=>{k8.init(Q,Y),s.init(Q,Y)});function a6(Q){return RW(JA,Q)}var zA=F("ZodUnknown",(Q,Y)=>{v8.init(Q,Y),s.init(Q,Y)});function o(){return CW(zA)}var HA=F("ZodNever",(Q,Y)=>{x8.init(Q,Y),s.init(Q,Y)});function AA(Q){return kW(HA,Q)}var UA=F("ZodArray",(Q,Y)=>{_8.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 vW(UA,Q,Y)}var JG=F("ZodObject",(Q,Y)=>{u8.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:AA()}),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(AG,Q,X[0]),Q.required=(...X)=>h.required(UG,Q,X[0])});function w(Q,Y){let X={type:"object",shape:Q??{},...h.normalizeParams(Y)};return new JG(X)}function U0(Q,Y){return new JG({type:"object",shape:Q,catchall:o(),...h.normalizeParams(Y)})}var zG=F("ZodUnion",(Q,Y)=>{k6.init(Q,Y),s.init(Q,Y),Q.options=Y.options});function p(Q,Y){return new zG({type:"union",options:Q,...h.normalizeParams(Y)})}var KA=F("ZodDiscriminatedUnion",(Q,Y)=>{zG.init(Q,Y),h8.init(Q,Y)});function s6(Q,Y,X){return new KA({type:"union",options:Y,discriminator:Q,...h.normalizeParams(X)})}var DA=F("ZodIntersection",(Q,Y)=>{f8.init(Q,Y),s.init(Q,Y)});function AQ(Q,Y){return new DA({type:"intersection",left:Q,right:Y})}var BA=F("ZodRecord",(Q,Y)=>{l8.init(Q,Y),s.init(Q,Y),Q.keyType=Y.keyType,Q.valueType=Y.valueType});function t(Q,Y,X){return new BA({type:"record",keyType:Q,valueType:Y,...h.normalizeParams(X)})}var o6=F("ZodEnum",(Q,Y)=>{m8.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 LA=F("ZodLiteral",(Q,Y)=>{c8.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 LA({type:"literal",values:Array.isArray(Q)?Q:[Q],...h.normalizeParams(Y)})}var FA=F("ZodTransform",(Q,Y)=>{p8.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 HG(Q){return new FA({type:"transform",transform:Q})}var AG=F("ZodOptional",(Q,Y)=>{i8.init(Q,Y),s.init(Q,Y),Q.unwrap=()=>Q._zod.def.innerType});function a(Q){return new AG({type:"optional",innerType:Q})}var qA=F("ZodNullable",(Q,Y)=>{r8.init(Q,Y),s.init(Q,Y),Q.unwrap=()=>Q._zod.def.innerType});function WG(Q){return new qA({type:"nullable",innerType:Q})}var OA=F("ZodDefault",(Q,Y)=>{n8.init(Q,Y),s.init(Q,Y),Q.unwrap=()=>Q._zod.def.innerType,Q.removeDefault=Q.unwrap});function MA(Q,Y){return new OA({type:"default",innerType:Q,get defaultValue(){return typeof Y==="function"?Y():h.shallowClone(Y)}})}var VA=F("ZodPrefault",(Q,Y)=>{d8.init(Q,Y),s.init(Q,Y),Q.unwrap=()=>Q._zod.def.innerType});function NA(Q,Y){return new VA({type:"prefault",innerType:Q,get defaultValue(){return typeof Y==="function"?Y():h.shallowClone(Y)}})}var UG=F("ZodNonOptional",(Q,Y)=>{o8.init(Q,Y),s.init(Q,Y),Q.unwrap=()=>Q._zod.def.innerType});function ZA(Q,Y){return new UG({type:"nonoptional",innerType:Q,...h.normalizeParams(Y)})}var wA=F("ZodCatch",(Q,Y)=>{t8.init(Q,Y),s.init(Q,Y),Q.unwrap=()=>Q._zod.def.innerType,Q.removeCatch=Q.unwrap});function bA(Q,Y){return new wA({type:"catch",innerType:Q,catchValue:typeof Y==="function"?Y:()=>Y})}var PA=F("ZodPipe",(Q,Y)=>{a8.init(Q,Y),s.init(Q,Y),Q.in=Y.in,Q.out=Y.out});function t6(Q,Y){return new PA({type:"pipe",in:Q,out:Y})}var IA=F("ZodReadonly",(Q,Y)=>{s8.init(Q,Y),s.init(Q,Y),Q.unwrap=()=>Q._zod.def.innerType});function jA(Q){return new IA({type:"readonly",innerType:Q})}var KG=F("ZodCustom",(Q,Y)=>{e8.init(Q,Y),s.init(Q,Y)});function DG(Q,Y){return xW(KG,Q??(()=>!0),Y)}function EA(Q,Y={}){return _W(KG,Q,Y)}function TA(Q){return yW(Q)}function e6(Q,Y){return t6(HG(Q),Y)}w0(v6());var QY="2025-11-25";var BG=[QY,"2025-06-18","2025-03-26","2024-11-05","2024-10-07"],G1="io.modelcontextprotocol/related-task",KQ="2.0",G0=DG((Q)=>Q!==null&&(typeof Q==="object"||typeof Q==="function")),LG=p([B(),l().int()]),FG=B(),QZ=U0({ttl:p([l(),a6()]).optional(),pollInterval:l().optional()}),SA=w({ttl:l().optional()}),RA=w({taskId:B()}),YY=U0({progressToken:LG.optional(),[G1]:RA.optional()}),Z0=w({_meta:YY.optional()}),$4=Z0.extend({task:SA.optional()}),qG=(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()]),OG=w({jsonrpc:b(KQ),id:DQ,...$0.shape}).strict(),XY=(Q)=>OG.safeParse(Q).success,MG=w({jsonrpc:b(KQ),...P0.shape}).strict(),VG=(Q)=>MG.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 NG=(Q)=>GY.safeParse(Q).success;var ZG=p([OG,MG,WY,GY]),YZ=p([WY,GY]),BQ=J0.strict(),CA=b0.extend({requestId:DQ.optional(),reason:B().optional()}),LQ=P0.extend({method:b("notifications/cancelled"),params:CA}),kA=w({src:B(),mimeType:B().optional(),sizes:_(B()).optional(),theme:L0(["light","dark"]).optional()}),z4=w({icons:_(kA).optional()}),S1=w({name:B(),title:B().optional()}),wG=S1.extend({...S1.shape,...z4.shape,version:B(),websiteUrl:B().optional(),description:B().optional()}),vA=AQ(w({applyDefaults:X0().optional()}),t(B(),o())),xA=e6((Q)=>{if(Q&&typeof Q==="object"&&!Array.isArray(Q)){if(Object.keys(Q).length===0)return{form:{}}}return Q},AQ(w({form:vA.optional(),url:G0.optional()}),t(B(),o()).optional())),_A=U0({list:G0.optional(),cancel:G0.optional(),requests:U0({sampling:U0({createMessage:G0.optional()}).optional(),elicitation:U0({create:G0.optional()}).optional()}).optional()}),yA=U0({list:G0.optional(),cancel:G0.optional(),requests:U0({tools:U0({call:G0.optional()}).optional()}).optional()}),gA=w({experimental:t(B(),G0).optional(),sampling:w({context:G0.optional(),tools:G0.optional()}).optional(),elicitation:xA.optional(),roots:w({listChanged:X0().optional()}).optional(),tasks:_A.optional()}),uA=Z0.extend({protocolVersion:B(),capabilities:gA,clientInfo:wG}),$Y=$0.extend({method:b("initialize"),params:uA});var hA=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:yA.optional()}),fA=J0.extend({protocolVersion:B(),capabilities:hA,serverInfo:wG,instructions:B().optional()}),JY=P0.extend({method:b("notifications/initialized"),params:b0.optional()});var FQ=$0.extend({method:b("ping"),params:Z0.optional()}),lA=w({progress:l(),total:a(l()),message:a(B())}),mA=w({...b0.shape,...lA.shape,progressToken:LG}),qQ=P0.extend({method:b("notifications/progress"),params:mA}),cA=Z0.extend({cursor:FG.optional()}),H4=$0.extend({params:cA.optional()}),A4=J0.extend({nextCursor:FG.optional()}),pA=L0(["working","input_required","completed","failed","cancelled"]),U4=w({taskId:B(),status:pA,ttl:p([l(),a6()]),createdAt:B(),lastUpdatedAt:B(),pollInterval:a(l()),statusMessage:a(B())}),R1=J0.extend({task:U4}),iA=b0.merge(U4),K4=P0.extend({method:b("notifications/tasks/status"),params:iA}),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()})}),XZ=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()})}),bG=J0.merge(U4),PG=w({uri:B(),mimeType:a(B()),_meta:t(B(),o()).optional()}),IG=PG.extend({text:B()}),zY=B().refine((Q)=>{try{return atob(Q),!0}catch{return!1}},{message:"Invalid Base64 string"}),jG=PG.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()}),EG=w({...S1.shape,...z4.shape,uri:B(),description:a(B()),mimeType:a(B()),annotations:C1.optional(),_meta:a(U0({}))}),rA=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")}),nA=A4.extend({resources:_(EG)}),dA=H4.extend({method:b("resources/templates/list")}),oA=A4.extend({resourceTemplates:_(rA)}),AY=Z0.extend({uri:B()}),tA=AY,UY=$0.extend({method:b("resources/read"),params:tA}),aA=J0.extend({contents:_(p([IG,jG]))}),sA=P0.extend({method:b("notifications/resources/list_changed"),params:b0.optional()}),eA=AY,QU=$0.extend({method:b("resources/subscribe"),params:eA}),YU=AY,XU=$0.extend({method:b("resources/unsubscribe"),params:YU}),WU=b0.extend({uri:B()}),GU=P0.extend({method:b("notifications/resources/updated"),params:WU}),$U=w({name:B(),description:a(B()),required:a(X0())}),JU=w({...S1.shape,...z4.shape,description:a(B()),arguments:a(_($U)),_meta:a(U0({}))}),zU=H4.extend({method:b("prompts/list")}),HU=A4.extend({prompts:_(JU)}),AU=Z0.extend({name:B(),arguments:t(B(),B()).optional()}),UU=$0.extend({method:b("prompts/get"),params:AU}),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()}),KU=w({type:b("tool_use"),name:B(),id:B(),input:t(B(),o()),_meta:t(B(),o()).optional()}),DU=w({type:b("resource"),resource:p([IG,jG]),annotations:C1.optional(),_meta:t(B(),o()).optional()}),BU=EG.extend({type:b("resource_link")}),LY=p([KY,DY,BY,BU,DU]),LU=w({role:D4,content:LY}),FU=J0.extend({description:B().optional(),messages:_(LU)}),qU=P0.extend({method:b("notifications/prompts/list_changed"),params:b0.optional()}),OU=w({title:B().optional(),readOnlyHint:X0().optional(),destructiveHint:X0().optional(),idempotentHint:X0().optional(),openWorldHint:X0().optional()}),MU=w({taskSupport:L0(["required","optional","forbidden"]).optional()}),TG=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:OU.optional(),execution:MU.optional(),_meta:t(B(),o()).optional()}),FY=H4.extend({method:b("tools/list")}),VU=A4.extend({tools:_(TG)}),bQ=J0.extend({content:_(LY).default([]),structuredContent:t(B(),o()).optional(),isError:X0().optional()}),WZ=bQ.or(J0.extend({toolResult:o()})),NU=$4.extend({name:B(),arguments:t(B(),o()).optional()}),B4=$0.extend({method:b("tools/call"),params:NU}),ZU=P0.extend({method:b("notifications/tools/list_changed"),params:b0.optional()}),GZ=w({autoRefresh:X0().default(!0),debounceMs:l().int().nonnegative().default(300)}),L4=L0(["debug","info","notice","warning","error","critical","alert","emergency"]),wU=Z0.extend({level:L4}),qY=$0.extend({method:b("logging/setLevel"),params:wU}),bU=b0.extend({level:L4,logger:B().optional(),data:o()}),PU=P0.extend({method:b("notifications/message"),params:bU}),IU=w({name:B().optional()}),jU=w({hints:_(IU).optional(),costPriority:l().min(0).max(1).optional(),speedPriority:l().min(0).max(1).optional(),intelligencePriority:l().min(0).max(1).optional()}),EU=w({mode:L0(["auto","required","none"]).optional()}),TU=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()}),SU=s6("type",[KY,DY,BY]),UQ=s6("type",[KY,DY,BY,KU,TU]),RU=w({role:D4,content:p([UQ,_(UQ)]),_meta:t(B(),o()).optional()}),CU=$4.extend({messages:_(RU),modelPreferences:jU.optional(),systemPrompt:B().optional(),includeContext:L0(["none","thisServer","allServers"]).optional(),temperature:l().optional(),maxTokens:l().int(),stopSequences:_(B()).optional(),metadata:G0.optional(),tools:_(TG).optional(),toolChoice:EU.optional()}),kU=$0.extend({method:b("sampling/createMessage"),params:CU}),OY=J0.extend({model:B(),stopReason:a(L0(["endTurn","stopSequence","maxTokens"]).or(B())),role:D4,content:SU}),MY=J0.extend({model:B(),stopReason:a(L0(["endTurn","stopSequence","maxTokens","toolUse"]).or(B())),role:D4,content:p([UQ,_(UQ)])}),vU=w({type:b("boolean"),title:B().optional(),description:B().optional(),default:X0().optional()}),xU=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()}),_U=w({type:L0(["number","integer"]),title:B().optional(),description:B().optional(),minimum:l().optional(),maximum:l().optional(),default:l().optional()}),yU=w({type:b("string"),title:B().optional(),description:B().optional(),enum:_(B()),default:B().optional()}),gU=w({type:b("string"),title:B().optional(),description:B().optional(),oneOf:_(w({const:B(),title:B()})),default:B().optional()}),uU=w({type:b("string"),title:B().optional(),description:B().optional(),enum:_(B()),enumNames:_(B()).optional(),default:B().optional()}),hU=p([yU,gU]),fU=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()}),lU=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()}),mU=p([fU,lU]),cU=p([uU,hU,mU]),pU=p([cU,vU,xU,_U]),iU=$4.extend({mode:b("form").optional(),message:B(),requestedSchema:w({type:b("object"),properties:t(B(),pU),required:_(B()).optional()})}),rU=$4.extend({mode:b("url"),message:B(),elicitationId:B(),url:B().url()}),nU=p([iU,rU]),dU=$0.extend({method:b("elicitation/create"),params:nU}),oU=b0.extend({elicitationId:B()}),tU=P0.extend({method:b("notifications/elicitation/complete"),params:oU}),PQ=J0.extend({action:L0(["accept","decline","cancel"]),content:e6((Q)=>Q===null?void 0:Q,t(B(),p([B(),l(),X0(),_(B())])).optional())}),aU=w({type:b("ref/resource"),uri:B()});var sU=w({type:b("ref/prompt"),name:B()}),eU=Z0.extend({ref:p([sU,aU]),argument:w({name:B(),value:B()}),context:w({arguments:t(B(),B()).optional()}).optional()}),Q3=$0.extend({method:b("completion/complete"),params:eU});var Y3=J0.extend({completion:U0({values:_(B()).max(100),total:a(l().int()),hasMore:a(X0())})}),X3=w({uri:B().startsWith("file://"),name:B().optional(),_meta:t(B(),o()).optional()}),W3=$0.extend({method:b("roots/list"),params:Z0.optional()}),VY=J0.extend({roots:_(X3)}),G3=P0.extend({method:b("notifications/roots/list_changed"),params:b0.optional()}),$Z=p([FQ,$Y,Q3,qY,UU,zU,HY,dA,UY,QU,XU,B4,FY,OQ,VQ,NQ,wQ]),JZ=p([LQ,qQ,JY,G3,K4]),zZ=p([BQ,OY,MY,PQ,VY,MQ,ZQ,R1]),HZ=p([FQ,kU,dU,W3,OQ,VQ,NQ,wQ]),AZ=p([LQ,qQ,PU,GU,sA,ZU,qU,K4,tU]),UZ=p([BQ,fA,Y3,FU,HU,nA,oA,aA,bQ,VU,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 SG(W.elicitations,Y)}return new k(Q,Y,X)}}class SG 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 $3=Symbol("Let zodToJsonSchema decide on which parser to use");var cZ=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function NY(Q){let X=zQ(Q)?.method;if(!X)throw Error("Schema is missing a method literal");let W=gW(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 K3=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)||NG(G))this._onresponse(G);else if(XY(G))this._onrequest(G,$);else if(VG(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=qG(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??K3,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},bG,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 RG(Q){return Q!==null&&typeof Q==="object"&&!Array.isArray(Q)}function CG(Q,Y){let X={...Q};for(let W in Y){let G=W,$=Y[G];if($===void 0)continue;let J=X[G];if(RG(J)&&RG($))X[G]={...J,...$};else X[G]=$}return X}var H5=u9(q9(),1),A5=u9(z5(),1);function NM(){let Q=new H5.default({strict:!1,validateFormats:!0,validateSchema:!1,allErrors:!0});return A5.default(Q),Q}class j9{constructor(Q){this._ajv=Q??NM()}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 U5(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 K5(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=CG(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){K5(this._clientCapabilities?.tasks?.requests,Q,"Client")}assertTaskHandlerCapability(Q){if(!this._capabilities)return;U5(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:BG.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 D5={name:"@sequenzy/mcp",version:"0.0.49",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"],B5={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 wM(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 L5(Q,Y,X){return Q0(Q,`${Y0(Y,"/settings")}?tab=${encodeURIComponent(X)}`)}function bM(Q,Y){let X=S9.map((W)=>[W,Y?L5(Q,Y,W):""]);return Object.fromEntries(X)}function B1(Q={},Y){let X=wM(Y),W=h0(Q.companyId),G={},$=bM(X,W);if(!W)return{appUrl:X,routeTemplates:B5,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=L5(X,W,L);return{appUrl:X,routeTemplates:B5,settingsTabValues:S9,urls:G,settingsUrls:$}}var F5=[{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 q5(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`.",w5="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.",O5=500,C9={status:["is","is_not"],tag:["contains","not_contains","is_empty","is_not_empty"],email:["contains","not_contains"],emailProvider:["is","is_not","is_empty","is_not_empty"],added:["less_than","more_than"],firstName:["contains","not_contains","is_empty","is_not_empty"],lastName:["contains","not_contains","is_empty","is_not_empty"],list:["is","is_not","is_empty","is_not_empty"],emailSent:["is","is_not","at_least","less_than_count"],emailDelivered:["is","is_not","at_least","less_than_count"],emailOpened:["is","is_not","at_least","less_than_count"],emailClicked:["is","is_not","at_least","less_than_count"],emailBounced:["is","is_temporary_bounce","is_permanent_bounce","is_not","at_least","less_than_count"],emailComplained:["is","is_not","at_least","less_than_count"],attribute:["is","is_not","is_empty","is_not_empty","gte","lte","gt","lt","contains","not_contains"],event:["is","is_not","at_least","less_than_count"],segment:["is","is_not"],stripeProduct:["is","is_not","at_least","less_than_count"],stripeCurrentProduct:["is","is_not","gte","lte","gt","lt"],stripeTrialProduct:["is","is_not","gte","lte","gt","lt"]},PM=Object.entries(C9).map(([Q,Y])=>`${Q}: ${Y.join(", ")}`).join("; "),IM={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","emailDelivered","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`, `emailDelivered`, `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","is_temporary_bounce","is_permanent_bounce","at_least","less_than_count","gte","lte","gt","lt"],description:`Filter operator. Allowed operators by field: ${PM}.`},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/current/trialing, `prod_123:3` for payment thresholds, `prod_123:is_canceled` for products set to cancel, `prod_123:cancels_at:2026-05-26`, `prod_123:end_at:2026-05-26`, or `prod_123:start_at:7 days ago` for product-scoped dates. 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},jM={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 b5(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 P5(Q){if(typeof Q!=="object"||Q===null)return Q;let Y=Q;if(Y.kind==="filter"||"field"in Y||"operator"in Y||"value"in Y){let X=b5([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(P5):[]}}function EM(Q){let Y=Q.indexOf(":");return Y!==-1&&Q.substring(0,Y).trim().length>0}function TM(Q){let Y=Q.indexOf(":");return Y!==-1&&Q.substring(Y+1).trim().length>0}function M5(Q){if(Q==="all")return!0;let Y=Q.match(/^(\d+)d$/);if(!Y?.[1])return!1;let X=Number.parseInt(Y[1],10);return Number.isInteger(X)&&X>0}function SM(Q,Y){let X=Y.split(":");if(Q==="at_least"||Q==="less_than_count"){if(X.length<3)return'Event count filters must use "eventName:count:timeRange", like "saas.purchase:2:30d".';let $=X.slice(0,-2).join(":").trim(),J=X.at(-2),z=X.at(-1),H=J===void 0?Number.NaN:Number.parseInt(J,10);return $&&Number.isInteger(H)&&H>0&&z!==void 0&&M5(z)?null:'Event count filters must use "eventName:count:timeRange", like "saas.purchase:2:30d".'}if(X.length<2)return'Event filters must use "eventName:timeRange", like "saas.purchase:30d".';let W=X.slice(0,-1).join(":").trim(),G=X.at(-1);return W&&G!==void 0&&M5(G)?null:'Event filters must use "eventName:timeRange", like "saas.purchase:30d".'}function RM(Q){let Y=Q.indexOf(":");if(Y===-1)return{productId:Q,subfilter:null,rawValue:null};let X=Q.substring(0,Y),W=Q.substring(Y+1),G=W.indexOf(":");if(G===-1)return{productId:X,subfilter:W,rawValue:null};return{productId:X,subfilter:W.substring(0,G),rawValue:W.substring(G+1)}}function CM(Q){return Q.trim().toLowerCase().replace(/[-\s]+/g,"_")}function kM(Q){return["is_canceled","is_cancelled","canceled","cancelled","will_cancel","cancel_at_period_end","is_not_canceled","is_not_cancelled","not_canceled","not_cancelled","will_not_cancel"].includes(Q)}function vM(Q,Y){if(Y==="cancels_at"||Y==="cancel_at"||Y==="cancellation_at")return!0;if(Q==="stripeCurrentProduct")return["end_at","ends_at","period_end","period_ends_at","current_period_end"].includes(Y);return["start_at","started_at","trial_start","trial_started_at","end_at","ends_at","trial_end","trial_ends_at"].includes(Y)}function xM(Q){return["is","is_not","gte","lte","gt","lt"].includes(Q)}function _M(Q,Y,X){if(Q==="stripeProduct"){if(Y!=="at_least"&&Y!=="less_than_count")return null;let z=X.indexOf(":");if(z===-1)return null;let H=X.substring(0,z).trim(),A=Number.parseInt(X.substring(z+1).trim(),10);return H&&Number.isInteger(A)&&A>=1?null:'Stripe Product threshold filters must use "productId:count" with a count of at least 1.'}if(Q!=="stripeCurrentProduct"&&Q!=="stripeTrialProduct")return null;let{productId:W,subfilter:G,rawValue:$}=RM(X);if(!W.trim())return"Stripe product filters must include a product ID.";if(!G)return Y==="is"||Y==="is_not"?null:'Stripe current/trial date filters must use "productId:dateField:value".';let J=CM(G);if(kM(J))return Y==="is"||Y==="is_not"?null:"Stripe cancellation flag filters only support is and is_not operators.";if(!vM(Q,J))return`Unsupported Stripe product subfilter "${G}".`;if(!xM(Y))return"Stripe date filters only support is, is_not, gte, lte, gt, and lt operators.";return $?.trim()?null:'Stripe date filters must include a value like "productId:end_at:2026-05-26".'}function I5(Q){if(typeof Q!=="object"||Q===null)return"Segment filters must be objects.";let Y=Q,X=Y.field,W=Y.operator,G=Y.value;if(typeof X!=="string"||!(X in C9))return`Unsupported segment filter field "${String(X)}".`;if(typeof W!=="string")return`Segment filter "${X}" must include an operator.`;let $=C9[X];if(!$.includes(W))return`Operator "${W}" is not supported for ${X} filters. Use one of: ${$.join(", ")}.`;if(W!=="is_empty"&&W!=="is_not_empty"&&(typeof G!=="string"||G.trim().length===0))return`Segment filter "${X}" must include a value.`;if(X==="attribute"&&typeof G==="string"){if(!EM(G))return'Attribute filters must use "attributeName:value" or "attributeName:" for empty checks.';if(W!=="is_empty"&&W!=="is_not_empty"&&!TM(G))return'Attribute filters must include a value after "attributeName:".'}if(X==="event"&&typeof G==="string"){let J=SM(W,G);if(J)return J}if((X==="stripeProduct"||X==="stripeCurrentProduct"||X==="stripeTrialProduct")&&typeof G==="string"){let J=_M(X,W,G);if(J)return J}if(X==="tag"&&(W==="contains"||W==="not_contains")){if(!(typeof G==="string"&&G.split(",").map((z)=>z.trim()).some(Boolean)))return"Tag filters must include at least one tag name."}return null}function j5(Q){if(typeof Q!=="object"||Q===null)return[];let Y=Q;if(Y.kind==="filter"||"field"in Y||"operator"in Y||"value"in Y){let X=I5(Y);return X?[X]:[]}if(Array.isArray(Y.children))return Y.children.flatMap(j5);return[]}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 yM(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`.");let W=Y?Q.filters.flatMap((G)=>{let $=I5(G);return $?[$]:[]}):j5(Q.root);if(W.length>0)throw Error(W[0]??"Invalid segment filter in `create_segment`.")}function gM(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 uM(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 hM(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 fM(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 lM(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 V5={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:w5,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 mM(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 N5(Q){return Q.trim().toLowerCase().replace(/\s+/g,"-")}function cM(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.list==="string"&&Q.list.trim()!=="")Y.set("list",Q.list.trim());if(typeof Q.listId==="string"&&Q.listId.trim()!=="")Y.set("listId",Q.listId.trim());if(typeof Q.listName==="string"&&Q.listName.trim()!=="")Y.set("listName",Q.listName.trim());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 pM(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=cM({query:Q.query,tags:Q.tags,list:Q.list,listId:Q.listId,listName:Q.listName,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 iM(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=iM(Y);if(!X.email&&!X.externalId)throw Error(`Provide either \`email\` or \`externalId\` when calling \`${Q}\`.`);return X}function k9(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",k9(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}function rM(Q,Y,X){let W=I(Y,X);if(W===void 0)throw Error(`\`${X}\` is required when calling \`${Q}\`.`);return W}function Z5(Q,Y,X,W){let G=I(Y,X);if(G===void 0)return;if(!W.includes(G))throw Error(`\`${X}\` must be one of ${W.join(", ")} when calling \`${Q}\`.`);return G}function nM(Q,Y){if(!Array.isArray(Y.emails))throw Error(`\`emails\` must be an array when calling \`${Q}\`.`);let X=[];if(Y.emails.forEach((W,G)=>{if(typeof W!=="string")throw Error(`\`emails\` item ${G+1} must be a string when calling \`${Q}\`.`);let $=W.trim();if($.length>0)X.push($)}),X.length===0)throw Error(`\`emails\` must include at least one email address when calling \`${Q}\`.`);if(X.length>O5)throw Error(`\`emails\` must include no more than ${O5} email addresses when calling \`${Q}\`. Split larger batches into multiple calls.`);return X}async function E5(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 T5(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 T5(W,$.urls);let J=X==="sequence"?$.urls.sequence:X==="template"?$.urls.email:$.urls.transactionalEmail;return l4(W,J)})}function dM(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 oM=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 tM(Q,Y,X){if(!B0(X)||!oM.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 E5(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:dM(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:T5(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 S5=[{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
 
@@ -43,7 +43,7 @@ Use cases:
43
43
  - 'subscribe_form': Adding subscribers from signup forms
44
44
  - 'event_tracking': Tracking CUSTOM events only (not payment events - those come from the integration)
45
45
 
46
- Before implementing, use create_api_key to generate an API key and save it to .env as SEQUENZY_API_KEY.`,inputSchema:{type:"object",properties:{framework:{type:"string",description:"Framework/language (nextjs, express, python, etc.)"},use_case:{type:"string",description:"Use case: 'transactional' (sending emails), 'subscribe_form' (adding subscribers), 'event_tracking' (tracking CUSTOM events only - payment events should come from Stripe/Polar/etc integration)"}}}},{name:"add_subscriber",description:"Add a new subscriber to your list",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID to add subscriber to. If not provided, uses the currently selected company."},email:{type:"string",description:"Subscriber email address"},externalId:{type:"string",description:"Customer-owned subscriber ID. Provide this with email when creating, or instead of email for an existing subscriber."},attributes:{type:"object",description:"Custom attributes (name, plan, etc.)"},tags:{type:"array",items:{type:"string"},description:"Tags to apply to the subscriber"},listIds:{type:"array",items:{type:"string"},description:"List IDs to add subscriber to"},status:{type:"string",description:"Initial subscriber status: active, unsubscribed, or bounced. Defaults to active."},optInMode:{type:"string",description:"Consent mode: confirmed creates active immediately when consent is verified, double_opt_in sends a confirmation email before activation, and default obeys company double opt-in settings."}},required:[]}},{name:"update_subscriber",description:"Update an existing subscriber's attributes or tags",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},email:{type:"string",description:"Subscriber email address. Provide email or externalId to identify the subscriber."},externalId:{type:"string",description:"Customer-owned subscriber ID. Provide email or externalId to identify the subscriber."},attributes:{type:"object",description:"Attributes to update"},addTags:{type:"array",items:{type:"string"},description:"Tags to add"},removeTags:{type:"array",items:{type:"string"},description:"Tags to remove"}},required:[]}},{name:"remove_subscriber",description:"Unsubscribe or delete a subscriber",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},email:{type:"string",description:"Subscriber email address. Provide email or externalId to identify the subscriber."},externalId:{type:"string",description:"Customer-owned subscriber ID. Provide email or externalId to identify the subscriber."},hardDelete:{type:"boolean",description:"If true, permanently deletes. If false, just unsubscribes."}},required:[]}},{name:"get_subscriber",description:"Get the full subscriber profile, including tags, list memberships, sequence enrollments, email stats, and recent activity",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},email:{type:"string",description:"Subscriber email address. Provide email or externalId to identify the subscriber."},externalId:{type:"string",description:"Customer-owned subscriber ID. Provide email or externalId to identify the subscriber."}},required:[]}},{name:"search_subscribers",description:"Search subscribers by free-text query, tags, or segment. If you omit limit, the tool fetches all pages and returns every match.",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},query:{type:"string",description:"Search query (email or name)"},tags:{type:"array",items:{type:"string"},description:"Filter by tags"},segmentId:{type:"string",description:"Filter by segment ID"},status:{type:"string",description:"Filter by subscriber status: active, unsubscribed, or bounced."},limit:{type:"number",description:"Maximum results to return. If omitted, the tool returns all matches across pages."}}}},{name:"list_tags",description:"List all tags in the account",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID to list tags for. If not provided, uses the currently selected company."}}}},{name:"list_lists",description:"List all subscriber lists",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID to list lists for. If not provided, uses the currently selected company."}}}},{name:"create_list",description:"Create a new subscriber list",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID to create the list in. If not provided, uses the currently selected company."},name:{type:"string",description:"List name"},description:{type:"string",description:"List description"}},required:["name"]}},{name:"add_subscribers_to_list",description:"Bulk add existing or new subscribers to a subscriber list from an email array. Existing subscribers are added to the list without requiring a per-subscriber update call.",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},listId:{type:"string",description:"Subscriber list ID to add subscribers to."},emails:{type:"array",items:{type:"string"},description:"Email addresses to add to the list. Maximum 100 per call."},duplicateStrategy:{type:"string",description:"Duplicate strategy for existing subscribers: skip, merge, or overwrite. Defaults to skip."},enrollInSequences:{type:"boolean",description:"Whether newly created subscribers should enroll in matching sequences. Defaults to false."},optInMode:{type:"string",description:"Consent mode for newly created subscribers: default, confirmed, or double_opt_in. Defaults to default."}},required:["listId","emails"]}},{name:"list_segments",description:"List all segments",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID to list segments for. If not provided, uses the currently selected company."}}}},{name:"create_segment",description:'Create a new segment from explicit filter rules. Use `filters` plus `filterJoinOperator` for flat legacy rules, or `root` for nested AND/OR groups such as `{ "kind": "group", "joinOperator": "and", "children": [{ "kind": "filter", "field": "attribute", "operator": "gte", "value": "mrr:50" }, { "kind": "group", "joinOperator": "or", "children": [{ "kind": "filter", "field": "tag", "operator": "contains", "value": "vip" }, { "kind": "filter", "field": "event", "operator": "is_not", "value": "saas.purchase:30d" }] }] }`. Supports `event` and `segment` fields, Stripe product purchase/current/trial/date filters, and campaign-specific engagement filters.',inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID to create the segment in. If not provided, uses the currently selected company."},name:{type:"string",description:"Segment name"},filterJoinOperator:{type:"string",enum:["and","or"],description:'How top-level filters combine. Use `"and"` to require every filter or `"or"` to match any filter.'},filters:{type:"array",items:IM,minItems:1,description:'Array of segment filters. Example custom attribute empty check: [{"id":"filter-1","field":"attribute","operator":"is_empty","value":"last_logged_in:"}]. Example Stripe purchase filter: [{"id":"filter-1","field":"stripeProduct","operator":"is","value":"prod_123"}]. Example threshold filter: [{"id":"filter-1","field":"stripeProduct","operator":"at_least","value":"prod_123:3"}]. Example trial cancellation filter: [{"id":"filter-1","field":"stripeTrialProduct","operator":"is","value":"prod_123:is_canceled"}]. Example trial end filter: [{"id":"filter-1","field":"stripeTrialProduct","operator":"is","value":"prod_123:end_at:2026-05-26"}]. Example campaign-specific engagement combo: [{"id":"filter-1","field":"emailBounced","operator":"is","value":"campaign:cmp_abc"},{"id":"filter-2","field":"emailBounced","operator":"is_not","value":"campaign:cmp_xyz"}]. Combine them with `filterJoinOperator: "or"` to match any filter.'},root:{...jM,description:"Nested filter root. Mutually exclusive with `filters` and `filterJoinOperator`."}},required:["name"]}},{name:"get_segment_count",description:"Get the number of subscribers in a segment",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},segmentId:{type:"string",description:"Segment ID"}},required:["segmentId"]}},{name:"list_templates",description:"List all email templates, including per-locale localization sync status",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."}}}},{name:"get_template",description:"Get a template's details, content, and all localized variants with sync status",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},templateId:{type:"string",description:"Template ID"}},required:["templateId"]}},{name:"create_template",description:"Create a new email template",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},name:{type:"string",description:"Template name"},subject:{type:"string",description:"Email subject line"},html:{type:"string",description:"Email HTML content. Mutually exclusive with `blocks`."},blocks:{type:"array",description:h4,items:{type:"object"}},labels:{type:"array",description:"Optional label names to assign. Missing labels are created automatically.",items:{type:"string"}}},required:["name","subject"]}},{name:"update_template",description:"Update an existing template. At least one of `name`, `subject`, `html`, `blocks`, or `labels` is required, and only those update fields are accepted.",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},templateId:{type:"string",description:"Template ID"},name:{type:"string",description:"Template name"},subject:{type:"string",description:"Email subject line"},html:{type:"string",description:"Email HTML content. Mutually exclusive with `blocks`."},blocks:{type:"array",description:h4,items:{type:"object"}},labels:{type:"array",description:"Replacement label names. Send an empty array to clear labels. Missing labels are created automatically.",items:{type:"string"}}},required:["templateId"],additionalProperties:!1}},{name:"delete_template",description:"Delete a template",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},templateId:{type:"string",description:"Template ID"}},required:["templateId"]}},{name:"list_ab_tests",description:"List A/B tests and their variants",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},sequenceId:{type:"string",description:"Optional sequence ID to filter automation A/B tests."}}}},{name:"get_ab_test",description:"Get A/B test details, variants, and per-locale localization sync status",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},abTestId:{type:"string",description:"A/B test ID"}},required:["abTestId"]}},{name:"get_ab_test_stats",description:"Get A/B test aggregate stats and per-variant stats. Supports period or custom start/end ranges.",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},abTestId:{type:"string",description:"A/B test ID"},period:{type:"string",description:"Optional period: 1h, 24h, 7d, 30d, or 90d."},start:{type:"string",description:"Custom range start as ISO 8601. Requires end."},end:{type:"string",description:"Custom range end as ISO 8601. Requires start."}},required:["abTestId"]}},{name:"restart_ab_test",description:"Run another sequence A/B test after a winner is selected. By default the winner becomes the new control; pass sourceVariantId to use another variant as the control email.",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},abTestId:{type:"string",description:"A/B test ID to restart"},sourceVariantId:{type:"string",description:"Optional variant ID to use as the new control email. Defaults to the selected winner."},testType:{type:"string",description:"Optional test type: subject or content."},winnerThreshold:{type:"number",description:"Optional number of subscribers before selecting a winner. Must be from 10 to 1000."},variantCount:{type:"number",description:"Optional total variants including the control. Must be from 2 to 4."}},required:["abTestId"],additionalProperties:!1}},{name:"update_ab_test_variant",description:"Update a draft A/B test variant. Provide at least one of subject, previewText, html, or blocks. Use either html or blocks, not both.",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},abTestId:{type:"string",description:"A/B test ID"},variantId:{type:"string",description:"A/B test variant ID"},subject:{type:"string",description:"Variant subject line"},previewText:{type:"string",description:"Variant preview text. Pass an empty string to clear it."},html:{type:"string",description:"Replacement HTML body. Mutually exclusive with blocks."},blocks:{type:"array",description:`${A6} Mutually exclusive with html.`,items:{type:"object"}}},required:["abTestId","variantId"],additionalProperties:!1}},{name:"list_campaigns",description:"List all campaigns",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID to list campaigns for. If not provided, uses the currently selected company."},status:{type:"string",description:"Filter by status (draft, scheduled, sent)"},label:{type:"string",description:"Optional label name filter. Only campaigns assigned this label are returned."}}}},{name:"get_campaign",description:"Get campaign details and stats",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},campaignId:{type:"string",description:"Campaign ID"}},required:["campaignId"]}},{name:"get_email_send",description:"Get a sent email by emailSendId, including the stored HTML body when available and the ClickHouse event timeline. If the short-lived email send row has been cleaned up, returns the retained ClickHouse events and a sparse summary.",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},emailSendId:{type:"string",description:"Email send ID to inspect."}},required:["emailSendId"]}},{name:"create_campaign",description:"Create a new campaign (as draft)",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID to create the campaign in. If not provided, uses the currently selected company."},name:{type:"string",description:"Campaign name"},subject:{type:"string",description:"Email subject line. Optional when `prompt` is provided because the generated subject will be used."},trackingCode:{type:"string",description:"Optional campaign tracking code for UTM templates. Use only when explicitly requested."},html:{type:"string",description:"Email HTML content. Mutually exclusive with `blocks`."},blocks:{type:"array",description:h4,items:{type:"object"}},prompt:{type:"string",description:"Generate campaign blocks from a prompt. Mutually exclusive with `html`, `blocks`, and `templateId`."},style:{type:"string",description:"Prompt generation style: minimal, branded, promotional. Only used with `prompt`."},tone:{type:"string",description:"Prompt generation tone: professional, casual, friendly. Only used with `prompt`."},templateId:{type:"string",description:"Use a template instead of html"},segmentId:{type:"string",description:"Target segment ID"},campaignData:{type:"object",description:"Optional campaign-scoped JSON data for repeat blocks and personalization."},computedLists:{type:"array",description:"Optional computed list definitions derived from campaignData at send time.",items:{type:"object"}},labels:{type:"array",description:"Optional label names to assign. Missing labels are created automatically.",items:{type:"string"}}},required:["name"]}},{name:"update_campaign",description:"Update a draft campaign",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},campaignId:{type:"string",description:"Campaign ID"},name:{type:"string",description:"Campaign name"},subject:{type:"string",description:"Email subject line"},trackingCode:{type:"string",description:"Optional campaign tracking code for UTM templates. Use only when explicitly requested. Send an empty string to clear it."},html:{type:"string",description:"Email HTML content. Mutually exclusive with `blocks`."},blocks:{type:"array",description:h4,items:{type:"object"}},replyTo:{type:"string",description:"Set reply-to using an existing reply profile email address for this company."},replyProfileId:{type:"string",description:"Set reply-to using a reply profile ID for this company."},campaignData:{type:"object",description:"Set campaign-scoped JSON data for repeat blocks and personalization."},computedLists:{type:"array",description:"Set computed list definitions derived from campaignData at send time.",items:{type:"object"}},labels:{type:"array",description:"Replacement label names. Send an empty array to clear labels. Missing labels are created automatically.",items:{type:"string"}}},required:["campaignId"],additionalProperties:!1}},{name:"schedule_campaign",description:"Schedule a draft or already scheduled campaign. Returns dashboard edit and preview URLs.",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},campaignId:{type:"string",description:"Campaign ID"},scheduledAt:{type:"string",description:"Future ISO 8601 timestamp for the send, for example 2026-06-01T14:00:00Z."},targetLists:{type:"object",description:"Optional campaign targeting object. Omit to use saved targeting or all active subscribers. Examples: {type:'all'}, {type:'lists', listIds:['list_123']}, {type:'segment', segmentId:'seg_123'}, or {type:'filtered', filters:[...], filterJoinOperator:'and'}.",additionalProperties:!0},sendTimeOptimization:{type:"boolean",description:"Whether to use send-time optimization."},spreadOverHours:{type:"number",description:"Spread delivery over an integer number of hours from 1 to 72. When set, spread delivery takes precedence over send-time optimization."}},required:["campaignId","scheduledAt"],additionalProperties:!1}},{name:"send_test_email",description:"Send a test email to a single address",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},campaignId:{type:"string",description:"Campaign ID to test"},to:{type:"string",description:"Email address to send test to"}},required:["campaignId","to"]}},{name:"list_sequences",description:"List all email sequences (automations)",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID to list sequences for. If not provided, uses the currently selected company."}}}},{name:"get_sequence",description:"Get sequence details plus editable step content. The response includes sequence.emails with each step's nodeId, linked emailId, subject, previewText, and blocks.",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},sequenceId:{type:"string",description:"Sequence ID"}},required:["sequenceId"],additionalProperties:!1}},{name:"create_sequence",description:`Create a new email sequence. Provide either a goal for AI generation or explicit steps. Explicit steps can include email content and create_discount actions; emails after a discount action can use merge tags such as {{discount.code}} and {{discount.percentOff}}. For AI-generated sequences, the tool polls until emails are generated (typically 30-60 seconds).
46
+ Before implementing, use create_api_key to generate an API key and save it to .env as SEQUENZY_API_KEY.`,inputSchema:{type:"object",properties:{framework:{type:"string",description:"Framework/language (nextjs, express, python, etc.)"},use_case:{type:"string",description:"Use case: 'transactional' (sending emails), 'subscribe_form' (adding subscribers), 'event_tracking' (tracking CUSTOM events only - payment events should come from Stripe/Polar/etc integration)"}}}},{name:"add_subscriber",description:"Add a new subscriber to your list",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID to add subscriber to. If not provided, uses the currently selected company."},email:{type:"string",description:"Subscriber email address"},externalId:{type:"string",description:"Customer-owned subscriber ID. Provide this with email when creating, or instead of email for an existing subscriber."},attributes:{type:"object",description:"Custom attributes (name, plan, etc.)"},tags:{type:"array",items:{type:"string"},description:"Tags to apply to the subscriber"},listIds:{type:"array",items:{type:"string"},description:"List IDs to add subscriber to"},status:{type:"string",description:"Initial subscriber status: active, unsubscribed, or bounced. Defaults to active."},optInMode:{type:"string",description:"Consent mode: confirmed creates active immediately when consent is verified, double_opt_in sends a confirmation email before activation, and default obeys company double opt-in settings."}},required:[]}},{name:"update_subscriber",description:"Update an existing subscriber's attributes or tags",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},email:{type:"string",description:"Subscriber email address. Provide email or externalId to identify the subscriber."},externalId:{type:"string",description:"Customer-owned subscriber ID. Provide email or externalId to identify the subscriber."},attributes:{type:"object",description:"Attributes to update"},addTags:{type:"array",items:{type:"string"},description:"Tags to add"},removeTags:{type:"array",items:{type:"string"},description:"Tags to remove"}},required:[]}},{name:"remove_subscriber",description:"Unsubscribe or delete a subscriber",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},email:{type:"string",description:"Subscriber email address. Provide email or externalId to identify the subscriber."},externalId:{type:"string",description:"Customer-owned subscriber ID. Provide email or externalId to identify the subscriber."},hardDelete:{type:"boolean",description:"If true, permanently deletes. If false, just unsubscribes."}},required:[]}},{name:"get_subscriber",description:"Get the full subscriber profile, including tags, list memberships, sequence enrollments, email stats, and recent activity",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},email:{type:"string",description:"Subscriber email address. Provide email or externalId to identify the subscriber."},externalId:{type:"string",description:"Customer-owned subscriber ID. Provide email or externalId to identify the subscriber."}},required:[]}},{name:"search_subscribers",description:"Search subscribers by free-text query, tags, list, or segment. If you omit limit, the tool fetches all pages and returns every match.",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},query:{type:"string",description:"Search query (email or name)"},tags:{type:"array",items:{type:"string"},description:"Filter by tags"},list:{type:"string",description:"Filter by subscriber list ID or exact list name. Prefer listId when known."},listId:{type:"string",description:"Filter by subscriber list ID."},listName:{type:"string",description:"Filter by exact subscriber list name when the list ID is not known."},segmentId:{type:"string",description:"Filter by segment ID"},status:{type:"string",description:"Filter by subscriber status: active, unsubscribed, or bounced."},limit:{type:"number",description:"Maximum results to return. If omitted, the tool returns all matches across pages."}}}},{name:"list_tags",description:"List all tags in the account",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID to list tags for. If not provided, uses the currently selected company."}}}},{name:"list_lists",description:"List all subscriber lists",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID to list lists for. If not provided, uses the currently selected company."}}}},{name:"create_list",description:"Create a new subscriber list",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID to create the list in. If not provided, uses the currently selected company."},name:{type:"string",description:"List name"},description:{type:"string",description:"List description"}},required:["name"]}},{name:"add_subscribers_to_list",description:"Bulk add existing or new subscribers to a subscriber list from an email array. Existing subscribers are added to the list without requiring a per-subscriber update call.",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},listId:{type:"string",description:"Subscriber list ID to add subscribers to."},emails:{type:"array",items:{type:"string"},description:"Email addresses to add to the list. Maximum 500 per call."},duplicateStrategy:{type:"string",description:"Duplicate strategy for existing subscribers: skip, merge, or overwrite. Defaults to skip."},enrollInSequences:{type:"boolean",description:"Whether newly created subscribers should enroll in matching sequences. Defaults to false."},optInMode:{type:"string",description:"Consent mode for newly created subscribers: default, confirmed, or double_opt_in. Defaults to default."}},required:["listId","emails"]}},{name:"list_segments",description:"List all segments",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID to list segments for. If not provided, uses the currently selected company."}}}},{name:"create_segment",description:'Create a new segment from explicit filter rules. Use `filters` plus `filterJoinOperator` for flat legacy rules, or `root` for nested AND/OR groups such as `{ "kind": "group", "joinOperator": "and", "children": [{ "kind": "filter", "field": "attribute", "operator": "gte", "value": "mrr:50" }, { "kind": "group", "joinOperator": "or", "children": [{ "kind": "filter", "field": "tag", "operator": "contains", "value": "vip" }, { "kind": "filter", "field": "event", "operator": "is_not", "value": "saas.purchase:30d" }] }] }`. Supports `event` and `segment` fields, Stripe product purchase/current/trial/date filters, and campaign-specific engagement filters.',inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID to create the segment in. If not provided, uses the currently selected company."},name:{type:"string",description:"Segment name"},filterJoinOperator:{type:"string",enum:["and","or"],description:'How top-level filters combine. Use `"and"` to require every filter or `"or"` to match any filter.'},filters:{type:"array",items:IM,minItems:1,description:'Array of segment filters. Example custom attribute empty check: [{"id":"filter-1","field":"attribute","operator":"is_empty","value":"last_logged_in:"}]. Example Stripe purchase filter: [{"id":"filter-1","field":"stripeProduct","operator":"is","value":"prod_123"}]. Example threshold filter: [{"id":"filter-1","field":"stripeProduct","operator":"at_least","value":"prod_123:3"}]. Example trial cancellation filter: [{"id":"filter-1","field":"stripeTrialProduct","operator":"is","value":"prod_123:is_canceled"}]. Example trial end filter: [{"id":"filter-1","field":"stripeTrialProduct","operator":"is","value":"prod_123:end_at:2026-05-26"}]. Example campaign-specific engagement combo: [{"id":"filter-1","field":"emailBounced","operator":"is","value":"campaign:cmp_abc"},{"id":"filter-2","field":"emailBounced","operator":"is_not","value":"campaign:cmp_xyz"}]. Combine them with `filterJoinOperator: "or"` to match any filter.'},root:{...jM,description:"Nested filter root. Mutually exclusive with `filters` and `filterJoinOperator`."}},required:["name"]}},{name:"get_segment_count",description:"Get the number of subscribers in a segment",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},segmentId:{type:"string",description:"Segment ID"}},required:["segmentId"]}},{name:"list_templates",description:"List all email templates, including per-locale localization sync status",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."}}}},{name:"get_template",description:"Get a template's details, content, and all localized variants with sync status",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},templateId:{type:"string",description:"Template ID"}},required:["templateId"]}},{name:"create_template",description:"Create a new email template",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},name:{type:"string",description:"Template name"},subject:{type:"string",description:"Email subject line"},html:{type:"string",description:"Email HTML content. Mutually exclusive with `blocks`."},blocks:{type:"array",description:h4,items:{type:"object"}},labels:{type:"array",description:"Optional label names to assign. Missing labels are created automatically.",items:{type:"string"}}},required:["name","subject"]}},{name:"update_template",description:"Update an existing template. At least one of `name`, `subject`, `html`, `blocks`, or `labels` is required, and only those update fields are accepted.",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},templateId:{type:"string",description:"Template ID"},name:{type:"string",description:"Template name"},subject:{type:"string",description:"Email subject line"},html:{type:"string",description:"Email HTML content. Mutually exclusive with `blocks`."},blocks:{type:"array",description:h4,items:{type:"object"}},labels:{type:"array",description:"Replacement label names. Send an empty array to clear labels. Missing labels are created automatically.",items:{type:"string"}}},required:["templateId"],additionalProperties:!1}},{name:"delete_template",description:"Delete a template",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},templateId:{type:"string",description:"Template ID"}},required:["templateId"]}},{name:"list_ab_tests",description:"List A/B tests and their variants",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},sequenceId:{type:"string",description:"Optional sequence ID to filter automation A/B tests."}}}},{name:"get_ab_test",description:"Get A/B test details, variants, and per-locale localization sync status",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},abTestId:{type:"string",description:"A/B test ID"}},required:["abTestId"]}},{name:"get_ab_test_stats",description:"Get A/B test aggregate stats and per-variant stats. Supports period or custom start/end ranges.",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},abTestId:{type:"string",description:"A/B test ID"},period:{type:"string",description:"Optional period: 1h, 24h, 7d, 30d, or 90d."},start:{type:"string",description:"Custom range start as ISO 8601. Requires end."},end:{type:"string",description:"Custom range end as ISO 8601. Requires start."}},required:["abTestId"]}},{name:"restart_ab_test",description:"Run another sequence A/B test after a winner is selected. By default the winner becomes the new control; pass sourceVariantId to use another variant as the control email.",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},abTestId:{type:"string",description:"A/B test ID to restart"},sourceVariantId:{type:"string",description:"Optional variant ID to use as the new control email. Defaults to the selected winner."},testType:{type:"string",description:"Optional test type: subject or content."},winnerThreshold:{type:"number",description:"Optional number of subscribers before selecting a winner. Must be from 10 to 1000."},variantCount:{type:"number",description:"Optional total variants including the control. Must be from 2 to 4."}},required:["abTestId"],additionalProperties:!1}},{name:"update_ab_test_variant",description:"Update a draft A/B test variant. Provide at least one of subject, previewText, html, or blocks. Use either html or blocks, not both.",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},abTestId:{type:"string",description:"A/B test ID"},variantId:{type:"string",description:"A/B test variant ID"},subject:{type:"string",description:"Variant subject line"},previewText:{type:"string",description:"Variant preview text. Pass an empty string to clear it."},html:{type:"string",description:"Replacement HTML body. Mutually exclusive with blocks."},blocks:{type:"array",description:`${A6} Mutually exclusive with html.`,items:{type:"object"}}},required:["abTestId","variantId"],additionalProperties:!1}},{name:"list_campaigns",description:"List all campaigns",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID to list campaigns for. If not provided, uses the currently selected company."},status:{type:"string",description:"Filter by status (draft, scheduled, sent)"},label:{type:"string",description:"Optional label name filter. Only campaigns assigned this label are returned."}}}},{name:"get_campaign",description:"Get campaign details and stats",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},campaignId:{type:"string",description:"Campaign ID"}},required:["campaignId"]}},{name:"get_email_send",description:"Get a sent email by emailSendId, including the stored HTML body when available and the ClickHouse event timeline. If the short-lived email send row has been cleaned up, returns the retained ClickHouse events and a sparse summary.",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},emailSendId:{type:"string",description:"Email send ID to inspect."}},required:["emailSendId"]}},{name:"create_campaign",description:"Create a new campaign (as draft)",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID to create the campaign in. If not provided, uses the currently selected company."},name:{type:"string",description:"Campaign name"},subject:{type:"string",description:"Email subject line. Optional when `prompt` is provided because the generated subject will be used."},trackingCode:{type:"string",description:"Optional campaign tracking code for UTM templates. Use only when explicitly requested."},html:{type:"string",description:"Email HTML content. Mutually exclusive with `blocks`."},blocks:{type:"array",description:h4,items:{type:"object"}},prompt:{type:"string",description:"Generate campaign blocks from a prompt. Mutually exclusive with `html`, `blocks`, and `templateId`."},style:{type:"string",description:"Prompt generation style: minimal, branded, promotional. Only used with `prompt`."},tone:{type:"string",description:"Prompt generation tone: professional, casual, friendly. Only used with `prompt`."},templateId:{type:"string",description:"Use a template instead of html"},segmentId:{type:"string",description:"Target segment ID"},campaignData:{type:"object",description:"Optional campaign-scoped JSON data for repeat blocks and personalization."},computedLists:{type:"array",description:"Optional computed list definitions derived from campaignData at send time.",items:{type:"object"}},labels:{type:"array",description:"Optional label names to assign. Missing labels are created automatically.",items:{type:"string"}}},required:["name"]}},{name:"update_campaign",description:"Update a draft campaign",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},campaignId:{type:"string",description:"Campaign ID"},name:{type:"string",description:"Campaign name"},subject:{type:"string",description:"Email subject line"},trackingCode:{type:"string",description:"Optional campaign tracking code for UTM templates. Use only when explicitly requested. Send an empty string to clear it."},html:{type:"string",description:"Email HTML content. Mutually exclusive with `blocks`."},blocks:{type:"array",description:h4,items:{type:"object"}},replyTo:{type:"string",description:"Set reply-to using an existing reply profile email address for this company."},replyProfileId:{type:"string",description:"Set reply-to using a reply profile ID for this company."},campaignData:{type:"object",description:"Set campaign-scoped JSON data for repeat blocks and personalization."},computedLists:{type:"array",description:"Set computed list definitions derived from campaignData at send time.",items:{type:"object"}},labels:{type:"array",description:"Replacement label names. Send an empty array to clear labels. Missing labels are created automatically.",items:{type:"string"}}},required:["campaignId"],additionalProperties:!1}},{name:"schedule_campaign",description:"Schedule a draft or already scheduled campaign. Returns dashboard edit and preview URLs.",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},campaignId:{type:"string",description:"Campaign ID"},scheduledAt:{type:"string",description:"Future ISO 8601 timestamp for the send, for example 2026-06-01T14:00:00Z."},targetLists:{type:"object",description:"Optional campaign targeting object. Omit to use saved targeting or all active subscribers. Examples: {type:'all'}, {type:'lists', listIds:['list_123']}, {type:'segment', segmentId:'seg_123'}, or {type:'filtered', filters:[...], filterJoinOperator:'and'}.",additionalProperties:!0},sendTimeOptimization:{type:"boolean",description:"Whether to use send-time optimization."},spreadOverHours:{type:"number",description:"Spread delivery over an integer number of hours from 1 to 72. When set, spread delivery takes precedence over send-time optimization."}},required:["campaignId","scheduledAt"],additionalProperties:!1}},{name:"send_test_email",description:"Send a test email to a single address",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},campaignId:{type:"string",description:"Campaign ID to test"},to:{type:"string",description:"Email address to send test to"}},required:["campaignId","to"]}},{name:"list_sequences",description:"List all email sequences (automations)",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID to list sequences for. If not provided, uses the currently selected company."}}}},{name:"get_sequence",description:"Get sequence details plus editable step content. The response includes sequence.emails with each step's nodeId, linked emailId, subject, previewText, and blocks.",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},sequenceId:{type:"string",description:"Sequence ID"}},required:["sequenceId"],additionalProperties:!1}},{name:"create_sequence",description:`Create a new email sequence. Provide either a goal for AI generation or explicit steps. Explicit steps can include email content and create_discount actions; emails after a discount action can use merge tags such as {{discount.code}} and {{discount.percentOff}}. For AI-generated sequences, the tool polls until emails are generated (typically 30-60 seconds).
47
47
 
48
48
  IMPORTANT GUIDELINES:
49
49