@sequenzy/mcp 0.0.112 → 0.0.113
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 +1 -1
- package/dist/server.js +2 -2
- package/package.json +1 -1
- package/server.json +2 -2
package/dist/server.js
CHANGED
|
@@ -2,7 +2,7 @@ var Sz=Object.create;var{getPrototypeOf:Rz,defineProperty:d$,getOwnPropertyNames
|
|
|
2
2
|
`:""},this._extScope=b,this._scope=new hb.Scope({parent:b}),this._nodes=[new mG]}toString(){return this._root.render(this.opts)}name(b){return this._scope.name(b)}scopeName(b){return this._extScope.name(b)}scopeValue(b,w){let $=this._extScope.value(b,w);return(this._values[$.prefix]||(this._values[$.prefix]=new Set)).add($),$}getScopeValue(b,w){return this._extScope.getValue(b,w)}scopeRefs(b){return this._extScope.scopeRefs(b,this._values)}scopeCode(){return this._extScope.scopeCode(this._values)}_def(b,w,$,W){let Q=this._scope.toName(w);if($!==void 0&&W)this._constants[Q.str]=$;return this._leafNode(new uG(b,Q,$)),Q}const(b,w,$){return this._def(hb.varKinds.const,b,w,$)}let(b,w,$){return this._def(hb.varKinds.let,b,w,$)}var(b,w,$){return this._def(hb.varKinds.var,b,w,$)}assign(b,w,$){return this._leafNode(new D6(b,w,$))}add(b,w){return this._leafNode(new yG(b,Zb.operators.ADD,w))}code(b){if(typeof b=="function")b();else if(b!==g.nil)this._leafNode(new gG(b));return this}object(...b){let w=["{"];for(let[$,W]of b){if(w.length>1)w.push(",");if(w.push($),$!==W||this.opts.es5)w.push(":"),(0,g.addCodeArg)(w,W)}return w.push("}"),new g._Code(w)}if(b,w,$){if(this._blockNode(new Ww(b)),w&&$)this.code(w).else().code($).endIf();else if(w)this.code(w).endIf();else if($)throw Error('CodeGen: "else" body without "then" body');return this}elseIf(b){return this._elseNode(new Ww(b))}else(){return this._elseNode(new f1)}endIf(){return this._endBlockNode(Ww,f1)}_for(b,w){if(this._blockNode(b),w)this.code(w).endFor();return this}for(b,w){return this._for(new nG(b),w)}forRange(b,w,$,W,Q=this.opts.es5?hb.varKinds.var:hb.varKinds.let){let G=this._scope.toName(b);return this._for(new lG(Q,G,w,$),()=>W(G))}forOf(b,w,$,W=hb.varKinds.const){let Q=this._scope.toName(b);if(this.opts.es5){let G=w instanceof g.Name?w:this.var("_arr",w);return this.forRange("_i",0,g._`${G}.length`,(X)=>{this.var(Q,g._`${G}[${X}]`),$(Q)})}return this._for(new H6("of",W,Q,w),()=>$(Q))}forIn(b,w,$,W=this.opts.es5?hb.varKinds.var:hb.varKinds.const){if(this.opts.ownProperties)return this.forOf(b,g._`Object.keys(${w})`,$);let Q=this._scope.toName(b);return this._for(new H6("in",W,Q,w),()=>$(Q))}endFor(){return this._endBlockNode(ow)}label(b){return this._leafNode(new hG(b))}break(b){return this._leafNode(new fG(b))}return(b){let w=new s0;if(this._blockNode(w),this.code(b),w.nodes.length!==1)throw Error('CodeGen: "return" should have one node');return this._endBlockNode(s0)}try(b,w,$){if(!w&&!$)throw Error('CodeGen: "try" without "catch" and "finally"');let W=new iG;if(this._blockNode(W),this.code(b),w){let Q=this.name("e");this._currNode=W.catch=new a0(Q),w(Q)}if($)this._currNode=W.finally=new b$,this.code($);return this._endBlockNode(a0,b$)}throw(b){return this._leafNode(new cG(b))}block(b,w){if(this._blockStarts.push(this._nodes.length),b)this.code(b).endBlock(w);return this}endBlock(b){let w=this._blockStarts.pop();if(w===void 0)throw Error("CodeGen: not in self-balancing block");let $=this._nodes.length-w;if($<0||b!==void 0&&$!==b)throw Error(`CodeGen: wrong number of nodes: ${$} vs ${b} expected`);return this._nodes.length=w,this}func(b,w=g.nil,$,W){if(this._blockNode(new e0(b,w,$)),W)this.code(W).endFunc();return this}endFunc(){return this._endBlockNode(e0)}optimize(b=1){while(b-- >0)this._root.optimizeNodes(),this._root.optimizeNames(this._root.names,this._constants)}_leafNode(b){return this._currNode.nodes.push(b),this}_blockNode(b){this._currNode.nodes.push(b),this._nodes.push(b)}_endBlockNode(b,w){let $=this._currNode;if($ instanceof b||w&&$ instanceof w)return this._nodes.pop(),this;throw Error(`CodeGen: not in block "${w?`${b.kind}/${w.kind}`:b.kind}"`)}_elseNode(b){let w=this._currNode;if(!(w instanceof Ww))throw Error('CodeGen: "else" without "if"');return this._currNode=w.else=b,this}get _root(){return this._nodes[0]}get _currNode(){let b=this._nodes;return b[b.length-1]}set _currNode(b){let w=this._nodes;w[w.length-1]=b}}Zb.CodeGen=pG;function Rw(b,w){for(let $ in w)b[$]=(b[$]||0)+(w[$]||0);return b}function w$(b,w){return w instanceof g._CodeOrName?Rw(b,w.names):b}function dw(b,w,$){if(b instanceof g.Name)return W(b);if(!Q(b))return b;return new g._Code(b._items.reduce((G,X)=>{if(X instanceof g.Name)X=W(X);if(X instanceof g._Code)G.push(...X._items);else G.push(X);return G},[]));function W(G){let X=$[G.str];if(X===void 0||w[G.str]!==1)return G;return delete w[G.str],X}function Q(G){return G instanceof g._Code&&G._items.some((X)=>X instanceof g.Name&&w[X.str]===1&&$[X.str]!==void 0)}}function SO(b,w){for(let $ in w)b[$]=(b[$]||0)-(w[$]||0)}function oG(b){return typeof b=="boolean"||typeof b=="number"||b===null?!b:g._`!${J6(b)}`}Zb.not=oG;var RO=dG(Zb.operators.AND);function kO(...b){return b.reduce(RO)}Zb.and=kO;var vO=dG(Zb.operators.OR);function CO(...b){return b.reduce(vO)}Zb.or=CO;function dG(b){return(w,$)=>w===g.nil?$:$===g.nil?w:g._`${J6(w)} ${b} ${J6($)}`}function J6(b){return b instanceof g.Name?b:g._`(${b})`}});var l=I((WX)=>{Object.defineProperty(WX,"__esModule",{value:!0});WX.checkStrictMode=WX.getErrorPath=WX.Type=WX.useFunc=WX.setEvaluated=WX.evaluatedPropsToName=WX.mergeEvaluated=WX.eachItem=WX.unescapeJsonPointer=WX.escapeJsonPointer=WX.escapeFragment=WX.unescapeFragment=WX.schemaRefOrVal=WX.schemaHasRulesButRef=WX.schemaHasRules=WX.checkUnknownRules=WX.alwaysValidSchema=WX.toHash=void 0;var d=u(),hO=h1();function fO(b){let w={};for(let $ of b)w[$]=!0;return w}WX.toHash=fO;function cO(b,w){if(typeof w=="boolean")return w;if(Object.keys(w).length===0)return!0;return sG(b,w),!aG(w,b.self.RULES.all)}WX.alwaysValidSchema=cO;function sG(b,w=b.schema){let{opts:$,self:W}=b;if(!$.strictSchema)return;if(typeof w==="boolean")return;let Q=W.RULES.keywords;for(let G in w)if(!Q[G])$X(b,`unknown keyword: "${G}"`)}WX.checkUnknownRules=sG;function aG(b,w){if(typeof b=="boolean")return!b;for(let $ in b)if(w[$])return!0;return!1}WX.schemaHasRules=aG;function gO(b,w){if(typeof b=="boolean")return!b;for(let $ in b)if($!=="$ref"&&w.all[$])return!0;return!1}WX.schemaHasRulesButRef=gO;function mO({topSchemaRef:b,schemaPath:w},$,W,Q){if(!Q){if(typeof $=="number"||typeof $=="boolean")return $;if(typeof $=="string")return d._`${$}`}return d._`${b}${w}${(0,d.getProperty)(W)}`}WX.schemaRefOrVal=mO;function nO(b){return bX(decodeURIComponent(b))}WX.unescapeFragment=nO;function lO(b){return encodeURIComponent(A6(b))}WX.escapeFragment=lO;function A6(b){if(typeof b=="number")return`${b}`;return b.replace(/~/g,"~0").replace(/\//g,"~1")}WX.escapeJsonPointer=A6;function bX(b){return b.replace(/~1/g,"/").replace(/~0/g,"~")}WX.unescapeJsonPointer=bX;function iO(b,w){if(Array.isArray(b))for(let $ of b)w($);else w(b)}WX.eachItem=iO;function rG({mergeNames:b,mergeToName:w,mergeValues:$,resultToName:W}){return(Q,G,X,Y)=>{let H=X===void 0?G:X instanceof d.Name?(G instanceof d.Name?b(Q,G,X):w(Q,G,X),X):G instanceof d.Name?(w(Q,X,G),G):$(G,X);return Y===d.Name&&!(H instanceof d.Name)?W(Q,H):H}}WX.mergeEvaluated={props:rG({mergeNames:(b,w,$)=>b.if(d._`${$} !== true && ${w} !== undefined`,()=>{b.if(d._`${w} === true`,()=>b.assign($,!0),()=>b.assign($,d._`${$} || {}`).code(d._`Object.assign(${$}, ${w})`))}),mergeToName:(b,w,$)=>b.if(d._`${$} !== true`,()=>{if(w===!0)b.assign($,!0);else b.assign($,d._`${$} || {}`),O6(b,$,w)}),mergeValues:(b,w)=>b===!0?!0:{...b,...w},resultToName:wX}),items:rG({mergeNames:(b,w,$)=>b.if(d._`${$} !== true && ${w} !== undefined`,()=>b.assign($,d._`${w} === true ? true : ${$} > ${w} ? ${$} : ${w}`)),mergeToName:(b,w,$)=>b.if(d._`${$} !== true`,()=>b.assign($,w===!0?!0:d._`${$} > ${w} ? ${$} : ${w}`)),mergeValues:(b,w)=>b===!0?!0:Math.max(b,w),resultToName:(b,w)=>b.var("items",w)})};function wX(b,w){if(w===!0)return b.var("props",!0);let $=b.var("props",d._`{}`);if(w!==void 0)O6(b,$,w);return $}WX.evaluatedPropsToName=wX;function O6(b,w,$){Object.keys($).forEach((W)=>b.assign(d._`${w}${(0,d.getProperty)(W)}`,!0))}WX.setEvaluated=O6;var eG={};function pO(b,w){return b.scopeValue("func",{ref:w,code:eG[w.code]||(eG[w.code]=new hO._Code(w.code))})}WX.useFunc=pO;var z6;(function(b){b[b.Num=0]="Num",b[b.Str=1]="Str"})(z6||(WX.Type=z6={}));function oO(b,w,$){if(b instanceof d.Name){let W=w===z6.Num;return $?W?d._`"[" + ${b} + "]"`:d._`"['" + ${b} + "']"`:W?d._`"/" + ${b}`:d._`"/" + ${b}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return $?(0,d.getProperty)(b).toString():"/"+A6(b)}WX.getErrorPath=oO;function $X(b,w,$=b.opts.strictSchema){if(!$)return;if(w=`strict mode: ${w}`,$===!0)throw Error(w);b.self.logger.warn(w)}WX.checkStrictMode=$X});var Qw=I((GX)=>{Object.defineProperty(GX,"__esModule",{value:!0});var Lb=u(),zq={data:new Lb.Name("data"),valCxt:new Lb.Name("valCxt"),instancePath:new Lb.Name("instancePath"),parentData:new Lb.Name("parentData"),parentDataProperty:new Lb.Name("parentDataProperty"),rootData:new Lb.Name("rootData"),dynamicAnchors:new Lb.Name("dynamicAnchors"),vErrors:new Lb.Name("vErrors"),errors:new Lb.Name("errors"),this:new Lb.Name("this"),self:new Lb.Name("self"),scope:new Lb.Name("scope"),json:new Lb.Name("json"),jsonPos:new Lb.Name("jsonPos"),jsonLen:new Lb.Name("jsonLen"),jsonPart:new Lb.Name("jsonPart")};GX.default=zq});var c1=I((JX)=>{Object.defineProperty(JX,"__esModule",{value:!0});JX.extendErrors=JX.resetErrorsCount=JX.reportExtraError=JX.reportError=JX.keyword$DataError=JX.keywordError=void 0;var m=u(),G$=l(),Bb=Qw();JX.keywordError={message:({keyword:b})=>m.str`must pass "${b}" keyword validation`};JX.keyword$DataError={message:({keyword:b,schemaType:w})=>w?m.str`"${b}" keyword must be ${w} ($data)`:m.str`"${b}" keyword is invalid ($data)`};function Oq(b,w=JX.keywordError,$,W){let{it:Q}=b,{gen:G,compositeRule:X,allErrors:Y}=Q,H=HX(b,w,$);if(W!==null&&W!==void 0?W:X||Y)XX(G,H);else YX(Q,m._`[${H}]`)}JX.reportError=Oq;function qq(b,w=JX.keywordError,$){let{it:W}=b,{gen:Q,compositeRule:G,allErrors:X}=W,Y=HX(b,w,$);if(XX(Q,Y),!(G||X))YX(W,Bb.default.vErrors)}JX.reportExtraError=qq;function Lq(b,w){b.assign(Bb.default.errors,w),b.if(m._`${Bb.default.vErrors} !== null`,()=>b.if(w,()=>b.assign(m._`${Bb.default.vErrors}.length`,w),()=>b.assign(Bb.default.vErrors,null)))}JX.resetErrorsCount=Lq;function Uq({gen:b,keyword:w,schemaValue:$,data:W,errsCount:Q,it:G}){if(Q===void 0)throw Error("ajv implementation error");let X=b.name("err");b.forRange("i",Q,Bb.default.errors,(Y)=>{if(b.const(X,m._`${Bb.default.vErrors}[${Y}]`),b.if(m._`${X}.instancePath === undefined`,()=>b.assign(m._`${X}.instancePath`,(0,m.strConcat)(Bb.default.instancePath,G.errorPath))),b.assign(m._`${X}.schemaPath`,m.str`${G.errSchemaPath}/${w}`),G.opts.verbose)b.assign(m._`${X}.schema`,$),b.assign(m._`${X}.data`,W)})}JX.extendErrors=Uq;function XX(b,w){let $=b.const("err",w);b.if(m._`${Bb.default.vErrors} === null`,()=>b.assign(Bb.default.vErrors,m._`[${$}]`),m._`${Bb.default.vErrors}.push(${$})`),b.code(m._`${Bb.default.errors}++`)}function YX(b,w){let{gen:$,validateName:W,schemaEnv:Q}=b;if(Q.$async)$.throw(m._`new ${b.ValidationError}(${w})`);else $.assign(m._`${W}.errors`,w),$.return(!1)}var kw={keyword:new m.Name("keyword"),schemaPath:new m.Name("schemaPath"),params:new m.Name("params"),propertyName:new m.Name("propertyName"),message:new m.Name("message"),schema:new m.Name("schema"),parentSchema:new m.Name("parentSchema")};function HX(b,w,$){let{createErrors:W}=b.it;if(W===!1)return m._`{}`;return Bq(b,w,$)}function Bq(b,w,$={}){let{gen:W,it:Q}=b,G=[Fq(Q,$),Kq(b,$)];return Pq(b,w,G),W.object(...G)}function Fq({errorPath:b},{instancePath:w}){let $=w?m.str`${b}${(0,G$.getErrorPath)(w,G$.Type.Str)}`:b;return[Bb.default.instancePath,(0,m.strConcat)(Bb.default.instancePath,$)]}function Kq({keyword:b,it:{errSchemaPath:w}},{schemaPath:$,parentSchema:W}){let Q=W?w:m.str`${w}/${b}`;if($)Q=m.str`${Q}${(0,G$.getErrorPath)($,G$.Type.Str)}`;return[kw.schemaPath,Q]}function Pq(b,{params:w,message:$},W){let{keyword:Q,data:G,schemaValue:X,it:Y}=b,{opts:H,propertyName:J,topSchemaRef:D,schemaPath:z}=Y;if(W.push([kw.keyword,Q],[kw.params,typeof w=="function"?w(b):w||m._`{}`]),H.messages)W.push([kw.message,typeof $=="function"?$(b):$]);if(H.verbose)W.push([kw.schema,X],[kw.parentSchema,m._`${D}${z}`],[Bb.default.data,G]);if(J)W.push([kw.propertyName,J])}});var qX=I((AX)=>{Object.defineProperty(AX,"__esModule",{value:!0});AX.boolOrEmptySchema=AX.topBoolOrEmptySchema=void 0;var Vq=c1(),Nq=u(),Eq=Qw(),Tq={message:"boolean schema is false"};function _q(b){let{gen:w,schema:$,validateName:W}=b;if($===!1)zX(b,!1);else if(typeof $=="object"&&$.$async===!0)w.return(Eq.default.data);else w.assign(Nq._`${W}.errors`,null),w.return(!0)}AX.topBoolOrEmptySchema=_q;function Sq(b,w){let{gen:$,schema:W}=b;if(W===!1)$.var(w,!1),zX(b);else $.var(w,!0)}AX.boolOrEmptySchema=Sq;function zX(b,w){let{gen:$,data:W}=b,Q={gen:$,keyword:"false schema",data:W,schema:!1,schemaCode:!1,schemaValue:!1,params:{},it:b};(0,Vq.reportError)(Q,Tq,void 0,w)}});var L6=I((LX)=>{Object.defineProperty(LX,"__esModule",{value:!0});LX.getRules=LX.isJSONType=void 0;var kq=["string","number","integer","boolean","null","object","array"],vq=new Set(kq);function Cq(b){return typeof b=="string"&&vq.has(b)}LX.isJSONType=Cq;function xq(){let b={number:{type:"number",rules:[]},string:{type:"string",rules:[]},array:{type:"array",rules:[]},object:{type:"object",rules:[]}};return{types:{...b,integer:!0,boolean:!0,null:!0},rules:[{rules:[]},b.number,b.string,b.array,b.object],post:{rules:[]},all:{},keywords:{}}}LX.getRules=xq});var U6=I((KX)=>{Object.defineProperty(KX,"__esModule",{value:!0});KX.shouldUseRule=KX.shouldUseGroup=KX.schemaHasRulesForType=void 0;function yq({schema:b,self:w},$){let W=w.RULES.types[$];return W&&W!==!0&&BX(b,W)}KX.schemaHasRulesForType=yq;function BX(b,w){return w.rules.some(($)=>FX(b,$))}KX.shouldUseGroup=BX;function FX(b,w){var $;return b[w.keyword]!==void 0||(($=w.definition.implements)===null||$===void 0?void 0:$.some((W)=>b[W]!==void 0))}KX.shouldUseRule=FX});var g1=I((IX)=>{Object.defineProperty(IX,"__esModule",{value:!0});IX.reportTypeError=IX.checkDataTypes=IX.checkDataType=IX.coerceAndCheckDataType=IX.getJSONTypes=IX.getSchemaTypes=IX.DataType=void 0;var cq=L6(),gq=U6(),mq=c1(),C=u(),MX=l(),tw;(function(b){b[b.Correct=0]="Correct",b[b.Wrong=1]="Wrong"})(tw||(IX.DataType=tw={}));function nq(b){let w=ZX(b.type);if(w.includes("null")){if(b.nullable===!1)throw Error("type: null contradicts nullable: false")}else{if(!w.length&&b.nullable!==void 0)throw Error('"nullable" cannot be used without "type"');if(b.nullable===!0)w.push("null")}return w}IX.getSchemaTypes=nq;function ZX(b){let w=Array.isArray(b)?b:b?[b]:[];if(w.every(cq.isJSONType))return w;throw Error("type must be JSONType or JSONType[]: "+w.join(","))}IX.getJSONTypes=ZX;function lq(b,w){let{gen:$,data:W,opts:Q}=b,G=iq(w,Q.coerceTypes),X=w.length>0&&!(G.length===0&&w.length===1&&(0,gq.schemaHasRulesForType)(b,w[0]));if(X){let Y=F6(w,W,Q.strictNumbers,tw.Wrong);$.if(Y,()=>{if(G.length)pq(b,w,G);else K6(b)})}return X}IX.coerceAndCheckDataType=lq;var jX=new Set(["string","number","integer","boolean","null"]);function iq(b,w){return w?b.filter(($)=>jX.has($)||w==="array"&&$==="array"):[]}function pq(b,w,$){let{gen:W,data:Q,opts:G}=b,X=W.let("dataType",C._`typeof ${Q}`),Y=W.let("coerced",C._`undefined`);if(G.coerceTypes==="array")W.if(C._`${X} == 'object' && Array.isArray(${Q}) && ${Q}.length == 1`,()=>W.assign(Q,C._`${Q}[0]`).assign(X,C._`typeof ${Q}`).if(F6(w,Q,G.strictNumbers),()=>W.assign(Y,Q)));W.if(C._`${Y} !== undefined`);for(let J of $)if(jX.has(J)||J==="array"&&G.coerceTypes==="array")H(J);W.else(),K6(b),W.endIf(),W.if(C._`${Y} !== undefined`,()=>{W.assign(Q,Y),oq(b,Y)});function H(J){switch(J){case"string":W.elseIf(C._`${X} == "number" || ${X} == "boolean"`).assign(Y,C._`"" + ${Q}`).elseIf(C._`${Q} === null`).assign(Y,C._`""`);return;case"number":W.elseIf(C._`${X} == "boolean" || ${Q} === null
|
|
3
3
|
|| (${X} == "string" && ${Q} && ${Q} == +${Q})`).assign(Y,C._`+${Q}`);return;case"integer":W.elseIf(C._`${X} === "boolean" || ${Q} === null
|
|
4
4
|
|| (${X} === "string" && ${Q} && ${Q} == +${Q} && !(${Q} % 1))`).assign(Y,C._`+${Q}`);return;case"boolean":W.elseIf(C._`${Q} === "false" || ${Q} === 0 || ${Q} === null`).assign(Y,!1).elseIf(C._`${Q} === "true" || ${Q} === 1`).assign(Y,!0);return;case"null":W.elseIf(C._`${Q} === "" || ${Q} === 0 || ${Q} === false`),W.assign(Y,null);return;case"array":W.elseIf(C._`${X} === "string" || ${X} === "number"
|
|
5
|
-
|| ${X} === "boolean" || ${Q} === null`).assign(Y,C._`[${Q}]`)}}}function oq({gen:b,parentData:w,parentDataProperty:$},W){b.if(C._`${w} !== undefined`,()=>b.assign(C._`${w}[${$}]`,W))}function B6(b,w,$,W=tw.Correct){let Q=W===tw.Correct?C.operators.EQ:C.operators.NEQ,G;switch(b){case"null":return C._`${w} ${Q} null`;case"array":G=C._`Array.isArray(${w})`;break;case"object":G=C._`${w} && typeof ${w} == "object" && !Array.isArray(${w})`;break;case"integer":G=X(C._`!(${w} % 1) && !isNaN(${w})`);break;case"number":G=X();break;default:return C._`typeof ${w} ${Q} ${b}`}return W===tw.Correct?G:(0,C.not)(G);function X(Y=C.nil){return(0,C.and)(C._`typeof ${w} == "number"`,Y,$?C._`isFinite(${w})`:C.nil)}}IX.checkDataType=B6;function F6(b,w,$,W){if(b.length===1)return B6(b[0],w,$,W);let Q,G=(0,MX.toHash)(b);if(G.array&&G.object){let X=C._`typeof ${w} != "object"`;Q=G.null?X:C._`!${w} || ${X}`,delete G.null,delete G.array,delete G.object}else Q=C.nil;if(G.number)delete G.integer;for(let X in G)Q=(0,C.and)(Q,B6(X,w,$,W));return Q}IX.checkDataTypes=F6;var dq={message:({schema:b})=>`must be ${b}`,params:({schema:b,schemaValue:w})=>typeof b=="string"?C._`{type: ${b}}`:C._`{type: ${w}}`};function K6(b){let w=tq(b);(0,mq.reportError)(w,dq)}IX.reportTypeError=K6;function tq(b){let{gen:w,data:$,schema:W}=b,Q=(0,MX.schemaRefOrVal)(b,W,"type");return{gen:w,keyword:"type",data:$,schema:W.type,schemaCode:Q,schemaValue:Q,parentSchema:W,params:{},it:b}}});var _X=I((EX)=>{Object.defineProperty(EX,"__esModule",{value:!0});EX.assignDefaults=void 0;var rw=u(),$L=l();function WL(b,w){let{properties:$,items:W}=b.schema;if(w==="object"&&$)for(let Q in $)NX(b,Q,$[Q].default);else if(w==="array"&&Array.isArray(W))W.forEach((Q,G)=>NX(b,G,Q.default))}EX.assignDefaults=WL;function NX(b,w,$){let{gen:W,compositeRule:Q,data:G,opts:X}=b;if($===void 0)return;let Y=rw._`${G}${(0,rw.getProperty)(w)}`;if(Q){(0,$L.checkStrictMode)(b,`default is ignored for: ${Y}`);return}let H=rw._`${Y} === undefined`;if(X.useDefaults==="empty")H=rw._`${H} || ${Y} === null || ${Y} === ""`;W.if(H,rw._`${Y} = ${(0,rw.stringify)($)}`)}});var vb=I((kX)=>{Object.defineProperty(kX,"__esModule",{value:!0});kX.validateUnion=kX.validateArray=kX.usePattern=kX.callValidateCode=kX.schemaProperties=kX.allSchemaProperties=kX.noPropertyInData=kX.propertyInData=kX.isOwnProperty=kX.hasPropFunc=kX.reportMissingProp=kX.checkMissingProp=kX.checkReportMissingProp=void 0;var a=u(),P6=l(),jw=Qw(),QL=l();function GL(b,w){let{gen:$,data:W,it:Q}=b;$.if(Z6($,W,w,Q.opts.ownProperties),()=>{b.setParams({missingProperty:a._`${w}`},!0),b.error()})}kX.checkReportMissingProp=GL;function XL({gen:b,data:w,it:{opts:$}},W,Q){return(0,a.or)(...W.map((G)=>(0,a.and)(Z6(b,w,G,$.ownProperties),a._`${Q} = ${G}`)))}kX.checkMissingProp=XL;function YL(b,w){b.setParams({missingProperty:w},!0),b.error()}kX.reportMissingProp=YL;function SX(b){return b.scopeValue("func",{ref:Object.prototype.hasOwnProperty,code:a._`Object.prototype.hasOwnProperty`})}kX.hasPropFunc=SX;function M6(b,w,$){return a._`${SX(b)}.call(${w}, ${$})`}kX.isOwnProperty=M6;function HL(b,w,$,W){let Q=a._`${w}${(0,a.getProperty)($)} !== undefined`;return W?a._`${Q} && ${M6(b,w,$)}`:Q}kX.propertyInData=HL;function Z6(b,w,$,W){let Q=a._`${w}${(0,a.getProperty)($)} === undefined`;return W?(0,a.or)(Q,(0,a.not)(M6(b,w,$))):Q}kX.noPropertyInData=Z6;function RX(b){return b?Object.keys(b).filter((w)=>w!=="__proto__"):[]}kX.allSchemaProperties=RX;function JL(b,w){return RX(w).filter(($)=>!(0,P6.alwaysValidSchema)(b,w[$]))}kX.schemaProperties=JL;function DL({schemaCode:b,data:w,it:{gen:$,topSchemaRef:W,schemaPath:Q,errorPath:G},it:X},Y,H,J){let D=J?a._`${b}, ${w}, ${W}${Q}`:w,z=[[jw.default.instancePath,(0,a.strConcat)(jw.default.instancePath,G)],[jw.default.parentData,X.parentData],[jw.default.parentDataProperty,X.parentDataProperty],[jw.default.rootData,jw.default.rootData]];if(X.opts.dynamicRef)z.push([jw.default.dynamicAnchors,jw.default.dynamicAnchors]);let O=a._`${D}, ${$.object(...z)}`;return H!==a.nil?a._`${Y}.call(${H}, ${O})`:a._`${Y}(${O})`}kX.callValidateCode=DL;var zL=a._`new RegExp`;function AL({gen:b,it:{opts:w}},$){let W=w.unicodeRegExp?"u":"",{regExp:Q}=w.code,G=Q($,W);return b.scopeValue("pattern",{key:G.toString(),ref:G,code:a._`${Q.code==="new RegExp"?zL:(0,QL.useFunc)(b,Q)}(${$}, ${W})`})}kX.usePattern=AL;function OL(b){let{gen:w,data:$,keyword:W,it:Q}=b,G=w.name("valid");if(Q.allErrors){let Y=w.let("valid",!0);return X(()=>w.assign(Y,!1)),Y}return w.var(G,!0),X(()=>w.break()),G;function X(Y){let H=w.const("len",a._`${$}.length`);w.forRange("i",0,H,(J)=>{b.subschema({keyword:W,dataProp:J,dataPropType:P6.Type.Num},G),w.if((0,a.not)(G),Y)})}}kX.validateArray=OL;function qL(b){let{gen:w,schema:$,keyword:W,it:Q}=b;if(!Array.isArray($))throw Error("ajv implementation error");if($.some((H)=>(0,P6.alwaysValidSchema)(Q,H))&&!Q.opts.unevaluated)return;let X=w.let("valid",!1),Y=w.name("_valid");w.block(()=>$.forEach((H,J)=>{let D=b.subschema({keyword:W,schemaProp:J,compositeRule:!0},Y);if(w.assign(X,a._`${X} || ${Y}`),!b.mergeValidEvaluated(D,Y))w.if((0,a.not)(X))})),b.result(X,()=>b.reset(),()=>b.error(!0))}kX.validateUnion=qL});var hX=I((uX)=>{Object.defineProperty(uX,"__esModule",{value:!0});uX.validateKeywordUsage=uX.validSchemaType=uX.funcKeywordCode=uX.macroKeywordCode=void 0;var Fb=u(),vw=Qw(),EL=vb(),TL=c1();function _L(b,w){let{gen:$,keyword:W,schema:Q,parentSchema:G,it:X}=b,Y=w.macro.call(X.self,Q,G,X),H=xX($,W,Y);if(X.opts.validateSchema!==!1)X.self.validateSchema(Y,!0);let J=$.name("valid");b.subschema({schema:Y,schemaPath:Fb.nil,errSchemaPath:`${X.errSchemaPath}/${W}`,topSchemaRef:H,compositeRule:!0},J),b.pass(J,()=>b.error(!0))}uX.macroKeywordCode=_L;function SL(b,w){var $;let{gen:W,keyword:Q,schema:G,parentSchema:X,$data:Y,it:H}=b;kL(H,w);let J=!Y&&w.compile?w.compile.call(H.self,G,X,H):w.validate,D=xX(W,Q,J),z=W.let("valid");b.block$data(z,O),b.ok(($=w.valid)!==null&&$!==void 0?$:z);function O(){if(w.errors===!1){if(K(),w.modifying)CX(b);Z(()=>b.error())}else{let M=w.async?q():B();if(w.modifying)CX(b);Z(()=>RL(b,M))}}function q(){let M=W.let("ruleErrs",null);return W.try(()=>K(Fb._`await `),(k)=>W.assign(z,!1).if(Fb._`${k} instanceof ${H.ValidationError}`,()=>W.assign(M,Fb._`${k}.errors`),()=>W.throw(k))),M}function B(){let M=Fb._`${D}.errors`;return W.assign(M,null),K(Fb.nil),M}function K(M=w.async?Fb._`await `:Fb.nil){let k=H.opts.passContext?vw.default.this:vw.default.self,S=!(("compile"in w)&&!Y||w.schema===!1);W.assign(z,Fb._`${M}${(0,EL.callValidateCode)(b,D,k,S)}`,w.modifying)}function Z(M){var k;W.if((0,Fb.not)((k=w.valid)!==null&&k!==void 0?k:z),M)}}uX.funcKeywordCode=SL;function CX(b){let{gen:w,data:$,it:W}=b;w.if(W.parentData,()=>w.assign($,Fb._`${W.parentData}[${W.parentDataProperty}]`))}function RL(b,w){let{gen:$}=b;$.if(Fb._`Array.isArray(${w})`,()=>{$.assign(vw.default.vErrors,Fb._`${vw.default.vErrors} === null ? ${w} : ${vw.default.vErrors}.concat(${w})`).assign(vw.default.errors,Fb._`${vw.default.vErrors}.length`),(0,TL.extendErrors)(b)},()=>b.error())}function kL({schemaEnv:b},w){if(w.async&&!b.$async)throw Error("async keyword in sync schema")}function xX(b,w,$){if($===void 0)throw Error(`keyword "${w}" failed to compile`);return b.scopeValue("keyword",typeof $=="function"?{ref:$}:{ref:$,code:(0,Fb.stringify)($)})}function vL(b,w,$=!1){return!w.length||w.some((W)=>W==="array"?Array.isArray(b):W==="object"?b&&typeof b=="object"&&!Array.isArray(b):typeof b==W||$&&typeof b>"u")}uX.validSchemaType=vL;function CL({schema:b,opts:w,self:$,errSchemaPath:W},Q,G){if(Array.isArray(Q.keyword)?!Q.keyword.includes(G):Q.keyword!==G)throw Error("ajv implementation error");let X=Q.dependencies;if(X===null||X===void 0?void 0:X.some((Y)=>!Object.prototype.hasOwnProperty.call(b,Y)))throw Error(`parent schema must have dependencies of ${G}: ${X.join(",")}`);if(Q.validateSchema){if(!Q.validateSchema(b[G])){let H=`keyword "${G}" value is invalid at path "${W}": `+$.errorsText(Q.validateSchema.errors);if(w.validateSchema==="log")$.logger.error(H);else throw Error(H)}}}uX.validateKeywordUsage=CL});var mX=I((cX)=>{Object.defineProperty(cX,"__esModule",{value:!0});cX.extendSubschemaMode=cX.extendSubschemaData=cX.getSubschema=void 0;var ob=u(),fX=l();function hL(b,{keyword:w,schemaProp:$,schema:W,schemaPath:Q,errSchemaPath:G,topSchemaRef:X}){if(w!==void 0&&W!==void 0)throw Error('both "keyword" and "schema" passed, only one allowed');if(w!==void 0){let Y=b.schema[w];return $===void 0?{schema:Y,schemaPath:ob._`${b.schemaPath}${(0,ob.getProperty)(w)}`,errSchemaPath:`${b.errSchemaPath}/${w}`}:{schema:Y[$],schemaPath:ob._`${b.schemaPath}${(0,ob.getProperty)(w)}${(0,ob.getProperty)($)}`,errSchemaPath:`${b.errSchemaPath}/${w}/${(0,fX.escapeFragment)($)}`}}if(W!==void 0){if(Q===void 0||G===void 0||X===void 0)throw Error('"schemaPath", "errSchemaPath" and "topSchemaRef" are required with "schema"');return{schema:W,schemaPath:Q,topSchemaRef:X,errSchemaPath:G}}throw Error('either "keyword" or "schema" must be passed')}cX.getSubschema=hL;function fL(b,w,{dataProp:$,dataPropType:W,data:Q,dataTypes:G,propertyName:X}){if(Q!==void 0&&$!==void 0)throw Error('both "data" and "dataProp" passed, only one allowed');let{gen:Y}=w;if($!==void 0){let{errorPath:J,dataPathArr:D,opts:z}=w,O=Y.let("data",ob._`${w.data}${(0,ob.getProperty)($)}`,!0);H(O),b.errorPath=ob.str`${J}${(0,fX.getErrorPath)($,W,z.jsPropertySyntax)}`,b.parentDataProperty=ob._`${$}`,b.dataPathArr=[...D,b.parentDataProperty]}if(Q!==void 0){let J=Q instanceof ob.Name?Q:Y.let("data",Q,!0);if(H(J),X!==void 0)b.propertyName=X}if(G)b.dataTypes=G;function H(J){b.data=J,b.dataLevel=w.dataLevel+1,b.dataTypes=[],w.definedProperties=new Set,b.parentData=w.data,b.dataNames=[...w.dataNames,J]}}cX.extendSubschemaData=fL;function cL(b,{jtdDiscriminator:w,jtdMetadata:$,compositeRule:W,createErrors:Q,allErrors:G}){if(W!==void 0)b.compositeRule=W;if(Q!==void 0)b.createErrors=Q;if(G!==void 0)b.allErrors=G;b.jtdDiscriminator=w,b.jtdMetadata=$}cX.extendSubschemaMode=cL});var j6=I((CE,nX)=>{nX.exports=function b(w,$){if(w===$)return!0;if(w&&$&&typeof w=="object"&&typeof $=="object"){if(w.constructor!==$.constructor)return!1;var W,Q,G;if(Array.isArray(w)){if(W=w.length,W!=$.length)return!1;for(Q=W;Q--!==0;)if(!b(w[Q],$[Q]))return!1;return!0}if(w.constructor===RegExp)return w.source===$.source&&w.flags===$.flags;if(w.valueOf!==Object.prototype.valueOf)return w.valueOf()===$.valueOf();if(w.toString!==Object.prototype.toString)return w.toString()===$.toString();if(G=Object.keys(w),W=G.length,W!==Object.keys($).length)return!1;for(Q=W;Q--!==0;)if(!Object.prototype.hasOwnProperty.call($,G[Q]))return!1;for(Q=W;Q--!==0;){var X=G[Q];if(!b(w[X],$[X]))return!1}return!0}return w!==w&&$!==$}});var iX=I((xE,lX)=>{var Iw=lX.exports=function(b,w,$){if(typeof w=="function")$=w,w={};$=w.cb||$;var W=typeof $=="function"?$:$.pre||function(){},Q=$.post||function(){};X$(w,W,Q,b,"",b)};Iw.keywords={additionalItems:!0,items:!0,contains:!0,additionalProperties:!0,propertyNames:!0,not:!0,if:!0,then:!0,else:!0};Iw.arrayKeywords={items:!0,allOf:!0,anyOf:!0,oneOf:!0};Iw.propsKeywords={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependencies:!0};Iw.skipKeywords={default:!0,enum:!0,const:!0,required:!0,maximum:!0,minimum:!0,exclusiveMaximum:!0,exclusiveMinimum:!0,multipleOf:!0,maxLength:!0,minLength:!0,pattern:!0,format:!0,maxItems:!0,minItems:!0,uniqueItems:!0,maxProperties:!0,minProperties:!0};function X$(b,w,$,W,Q,G,X,Y,H,J){if(W&&typeof W=="object"&&!Array.isArray(W)){w(W,Q,G,X,Y,H,J);for(var D in W){var z=W[D];if(Array.isArray(z)){if(D in Iw.arrayKeywords)for(var O=0;O<z.length;O++)X$(b,w,$,z[O],Q+"/"+D+"/"+O,G,Q,D,W,O)}else if(D in Iw.propsKeywords){if(z&&typeof z=="object")for(var q in z)X$(b,w,$,z[q],Q+"/"+D+"/"+nL(q),G,Q,D,W,q)}else if(D in Iw.keywords||b.allKeys&&!(D in Iw.skipKeywords))X$(b,w,$,z,Q+"/"+D,G,Q,D,W)}$(W,Q,G,X,Y,H,J)}}function nL(b){return b.replace(/~/g,"~0").replace(/\//g,"~1")}});var m1=I((tX)=>{Object.defineProperty(tX,"__esModule",{value:!0});tX.getSchemaRefs=tX.resolveUrl=tX.normalizeId=tX._getFullPath=tX.getFullPath=tX.inlineRef=void 0;var lL=l(),iL=j6(),pL=iX(),oL=new Set(["type","format","pattern","maxLength","minLength","maxProperties","minProperties","maxItems","minItems","maximum","minimum","uniqueItems","multipleOf","required","enum","const"]);function dL(b,w=!0){if(typeof b=="boolean")return!0;if(w===!0)return!I6(b);if(!w)return!1;return pX(b)<=w}tX.inlineRef=dL;var tL=new Set(["$ref","$recursiveRef","$recursiveAnchor","$dynamicRef","$dynamicAnchor"]);function I6(b){for(let w in b){if(tL.has(w))return!0;let $=b[w];if(Array.isArray($)&&$.some(I6))return!0;if(typeof $=="object"&&I6($))return!0}return!1}function pX(b){let w=0;for(let $ in b){if($==="$ref")return 1/0;if(w++,oL.has($))continue;if(typeof b[$]=="object")(0,lL.eachItem)(b[$],(W)=>w+=pX(W));if(w===1/0)return 1/0}return w}function oX(b,w="",$){if($!==!1)w=ew(w);let W=b.parse(w);return dX(b,W)}tX.getFullPath=oX;function dX(b,w){return b.serialize(w).split("#")[0]+"#"}tX._getFullPath=dX;var rL=/#\/?$/;function ew(b){return b?b.replace(rL,""):""}tX.normalizeId=ew;function eL(b,w,$){return $=ew($),b.resolve(w,$)}tX.resolveUrl=eL;var sL=/^[a-z_][-a-z0-9._]*$/i;function aL(b,w){if(typeof b=="boolean")return{};let{schemaId:$,uriResolver:W}=this.opts,Q=ew(b[$]||w),G={"":Q},X=oX(W,Q,!1),Y={},H=new Set;return pL(b,{allKeys:!0},(z,O,q,B)=>{if(B===void 0)return;let K=X+O,Z=G[B];if(typeof z[$]=="string")Z=M.call(this,z[$]);k.call(this,z.$anchor),k.call(this,z.$dynamicAnchor),G[O]=Z;function M(S){let h=this.opts.uriResolver.resolve;if(S=ew(Z?h(Z,S):S),H.has(S))throw D(S);H.add(S);let R=this.refs[S];if(typeof R=="string")R=this.refs[R];if(typeof R=="object")J(z,R.schema,S);else if(S!==ew(K))if(S[0]==="#")J(z,Y[S],S),Y[S]=z;else this.refs[S]=K;return S}function k(S){if(typeof S=="string"){if(!sL.test(S))throw Error(`invalid anchor "${S}"`);M.call(this,`#${S}`)}}}),Y;function J(z,O,q){if(O!==void 0&&!iL(z,O))throw D(q)}function D(z){return Error(`reference "${z}" resolves to more than one schema`)}}tX.getSchemaRefs=aL});var i1=I((zY)=>{Object.defineProperty(zY,"__esModule",{value:!0});zY.getData=zY.KeywordCxt=zY.validateFunctionCode=void 0;var wY=qX(),eX=g1(),N6=U6(),Y$=g1(),GU=_X(),l1=hX(),V6=mX(),E=u(),v=Qw(),XU=m1(),Gw=l(),n1=c1();function YU(b){if(QY(b)){if(GY(b),WY(b)){DU(b);return}}$Y(b,()=>(0,wY.topBoolOrEmptySchema)(b))}zY.validateFunctionCode=YU;function $Y({gen:b,validateName:w,schema:$,schemaEnv:W,opts:Q},G){if(Q.code.es5)b.func(w,E._`${v.default.data}, ${v.default.valCxt}`,W.$async,()=>{b.code(E._`"use strict"; ${sX($,Q)}`),JU(b,Q),b.code(G)});else b.func(w,E._`${v.default.data}, ${HU(Q)}`,W.$async,()=>b.code(sX($,Q)).code(G))}function HU(b){return E._`{${v.default.instancePath}="", ${v.default.parentData}, ${v.default.parentDataProperty}, ${v.default.rootData}=${v.default.data}${b.dynamicRef?E._`, ${v.default.dynamicAnchors}={}`:E.nil}}={}`}function JU(b,w){b.if(v.default.valCxt,()=>{if(b.var(v.default.instancePath,E._`${v.default.valCxt}.${v.default.instancePath}`),b.var(v.default.parentData,E._`${v.default.valCxt}.${v.default.parentData}`),b.var(v.default.parentDataProperty,E._`${v.default.valCxt}.${v.default.parentDataProperty}`),b.var(v.default.rootData,E._`${v.default.valCxt}.${v.default.rootData}`),w.dynamicRef)b.var(v.default.dynamicAnchors,E._`${v.default.valCxt}.${v.default.dynamicAnchors}`)},()=>{if(b.var(v.default.instancePath,E._`""`),b.var(v.default.parentData,E._`undefined`),b.var(v.default.parentDataProperty,E._`undefined`),b.var(v.default.rootData,v.default.data),w.dynamicRef)b.var(v.default.dynamicAnchors,E._`{}`)})}function DU(b){let{schema:w,opts:$,gen:W}=b;$Y(b,()=>{if($.$comment&&w.$comment)YY(b);if(LU(b),W.let(v.default.vErrors,null),W.let(v.default.errors,0),$.unevaluated)zU(b);XY(b),FU(b)});return}function zU(b){let{gen:w,validateName:$}=b;b.evaluated=w.const("evaluated",E._`${$}.evaluated`),w.if(E._`${b.evaluated}.dynamicProps`,()=>w.assign(E._`${b.evaluated}.props`,E._`undefined`)),w.if(E._`${b.evaluated}.dynamicItems`,()=>w.assign(E._`${b.evaluated}.items`,E._`undefined`))}function sX(b,w){let $=typeof b=="object"&&b[w.schemaId];return $&&(w.code.source||w.code.process)?E._`/*# sourceURL=${$} */`:E.nil}function AU(b,w){if(QY(b)){if(GY(b),WY(b)){OU(b,w);return}}(0,wY.boolOrEmptySchema)(b,w)}function WY({schema:b,self:w}){if(typeof b=="boolean")return!b;for(let $ in b)if(w.RULES.all[$])return!0;return!1}function QY(b){return typeof b.schema!="boolean"}function OU(b,w){let{schema:$,gen:W,opts:Q}=b;if(Q.$comment&&$.$comment)YY(b);UU(b),BU(b);let G=W.const("_errs",v.default.errors);XY(b,G),W.var(w,E._`${G} === ${v.default.errors}`)}function GY(b){(0,Gw.checkUnknownRules)(b),qU(b)}function XY(b,w){if(b.opts.jtd)return aX(b,[],!1,w);let $=(0,eX.getSchemaTypes)(b.schema),W=(0,eX.coerceAndCheckDataType)(b,$);aX(b,$,!W,w)}function qU(b){let{schema:w,errSchemaPath:$,opts:W,self:Q}=b;if(w.$ref&&W.ignoreKeywordsWithRef&&(0,Gw.schemaHasRulesButRef)(w,Q.RULES))Q.logger.warn(`$ref: keywords ignored in schema at path "${$}"`)}function LU(b){let{schema:w,opts:$}=b;if(w.default!==void 0&&$.useDefaults&&$.strictSchema)(0,Gw.checkStrictMode)(b,"default is ignored in the schema root")}function UU(b){let w=b.schema[b.opts.schemaId];if(w)b.baseId=(0,XU.resolveUrl)(b.opts.uriResolver,b.baseId,w)}function BU(b){if(b.schema.$async&&!b.schemaEnv.$async)throw Error("async schema in sync schema")}function YY({gen:b,schemaEnv:w,schema:$,errSchemaPath:W,opts:Q}){let G=$.$comment;if(Q.$comment===!0)b.code(E._`${v.default.self}.logger.log(${G})`);else if(typeof Q.$comment=="function"){let X=E.str`${W}/$comment`,Y=b.scopeValue("root",{ref:w.root});b.code(E._`${v.default.self}.opts.$comment(${G}, ${X}, ${Y}.schema)`)}}function FU(b){let{gen:w,schemaEnv:$,validateName:W,ValidationError:Q,opts:G}=b;if($.$async)w.if(E._`${v.default.errors} === 0`,()=>w.return(v.default.data),()=>w.throw(E._`new ${Q}(${v.default.vErrors})`));else{if(w.assign(E._`${W}.errors`,v.default.vErrors),G.unevaluated)KU(b);w.return(E._`${v.default.errors} === 0`)}}function KU({gen:b,evaluated:w,props:$,items:W}){if($ instanceof E.Name)b.assign(E._`${w}.props`,$);if(W instanceof E.Name)b.assign(E._`${w}.items`,W)}function aX(b,w,$,W){let{gen:Q,schema:G,data:X,allErrors:Y,opts:H,self:J}=b,{RULES:D}=J;if(G.$ref&&(H.ignoreKeywordsWithRef||!(0,Gw.schemaHasRulesButRef)(G,D))){Q.block(()=>JY(b,"$ref",D.all.$ref.definition));return}if(!H.jtd)PU(b,w);Q.block(()=>{for(let O of D.rules)z(O);z(D.post)});function z(O){if(!(0,N6.shouldUseGroup)(G,O))return;if(O.type){if(Q.if((0,Y$.checkDataType)(O.type,X,H.strictNumbers)),bY(b,O),w.length===1&&w[0]===O.type&&$)Q.else(),(0,Y$.reportTypeError)(b);Q.endIf()}else bY(b,O);if(!Y)Q.if(E._`${v.default.errors} === ${W||0}`)}}function bY(b,w){let{gen:$,schema:W,opts:{useDefaults:Q}}=b;if(Q)(0,GU.assignDefaults)(b,w.type);$.block(()=>{for(let G of w.rules)if((0,N6.shouldUseRule)(W,G))JY(b,G.keyword,G.definition,w.type)})}function PU(b,w){if(b.schemaEnv.meta||!b.opts.strictTypes)return;if(MU(b,w),!b.opts.allowUnionTypes)ZU(b,w);jU(b,b.dataTypes)}function MU(b,w){if(!w.length)return;if(!b.dataTypes.length){b.dataTypes=w;return}w.forEach(($)=>{if(!HY(b.dataTypes,$))E6(b,`type "${$}" not allowed by context "${b.dataTypes.join(",")}"`)}),VU(b,w)}function ZU(b,w){if(w.length>1&&!(w.length===2&&w.includes("null")))E6(b,"use allowUnionTypes to allow union type keyword")}function jU(b,w){let $=b.self.RULES.all;for(let W in $){let Q=$[W];if(typeof Q=="object"&&(0,N6.shouldUseRule)(b.schema,Q)){let{type:G}=Q.definition;if(G.length&&!G.some((X)=>IU(w,X)))E6(b,`missing type "${G.join(",")}" for keyword "${W}"`)}}}function IU(b,w){return b.includes(w)||w==="number"&&b.includes("integer")}function HY(b,w){return b.includes(w)||w==="integer"&&b.includes("number")}function VU(b,w){let $=[];for(let W of b.dataTypes)if(HY(w,W))$.push(W);else if(w.includes("integer")&&W==="number")$.push("integer");b.dataTypes=$}function E6(b,w){let $=b.schemaEnv.baseId+b.errSchemaPath;w+=` at "${$}" (strictTypes)`,(0,Gw.checkStrictMode)(b,w,b.opts.strictTypes)}class T6{constructor(b,w,$){if((0,l1.validateKeywordUsage)(b,w,$),this.gen=b.gen,this.allErrors=b.allErrors,this.keyword=$,this.data=b.data,this.schema=b.schema[$],this.$data=w.$data&&b.opts.$data&&this.schema&&this.schema.$data,this.schemaValue=(0,Gw.schemaRefOrVal)(b,this.schema,$,this.$data),this.schemaType=w.schemaType,this.parentSchema=b.schema,this.params={},this.it=b,this.def=w,this.$data)this.schemaCode=b.gen.const("vSchema",DY(this.$data,b));else if(this.schemaCode=this.schemaValue,!(0,l1.validSchemaType)(this.schema,w.schemaType,w.allowUndefined))throw Error(`${$} value must be ${JSON.stringify(w.schemaType)}`);if("code"in w?w.trackErrors:w.errors!==!1)this.errsCount=b.gen.const("_errs",v.default.errors)}result(b,w,$){this.failResult((0,E.not)(b),w,$)}failResult(b,w,$){if(this.gen.if(b),$)$();else this.error();if(w){if(this.gen.else(),w(),this.allErrors)this.gen.endIf()}else if(this.allErrors)this.gen.endIf();else this.gen.else()}pass(b,w){this.failResult((0,E.not)(b),void 0,w)}fail(b){if(b===void 0){if(this.error(),!this.allErrors)this.gen.if(!1);return}if(this.gen.if(b),this.error(),this.allErrors)this.gen.endIf();else this.gen.else()}fail$data(b){if(!this.$data)return this.fail(b);let{schemaCode:w}=this;this.fail(E._`${w} !== undefined && (${(0,E.or)(this.invalid$data(),b)})`)}error(b,w,$){if(w){this.setParams(w),this._error(b,$),this.setParams({});return}this._error(b,$)}_error(b,w){(b?n1.reportExtraError:n1.reportError)(this,this.def.error,w)}$dataError(){(0,n1.reportError)(this,this.def.$dataError||n1.keyword$DataError)}reset(){if(this.errsCount===void 0)throw Error('add "trackErrors" to keyword definition');(0,n1.resetErrorsCount)(this.gen,this.errsCount)}ok(b){if(!this.allErrors)this.gen.if(b)}setParams(b,w){if(w)Object.assign(this.params,b);else this.params=b}block$data(b,w,$=E.nil){this.gen.block(()=>{this.check$data(b,$),w()})}check$data(b=E.nil,w=E.nil){if(!this.$data)return;let{gen:$,schemaCode:W,schemaType:Q,def:G}=this;if($.if((0,E.or)(E._`${W} === undefined`,w)),b!==E.nil)$.assign(b,!0);if(Q.length||G.validateSchema){if($.elseIf(this.invalid$data()),this.$dataError(),b!==E.nil)$.assign(b,!1)}$.else()}invalid$data(){let{gen:b,schemaCode:w,schemaType:$,def:W,it:Q}=this;return(0,E.or)(G(),X());function G(){if($.length){if(!(w instanceof E.Name))throw Error("ajv implementation error");let Y=Array.isArray($)?$:[$];return E._`${(0,Y$.checkDataTypes)(Y,w,Q.opts.strictNumbers,Y$.DataType.Wrong)}`}return E.nil}function X(){if(W.validateSchema){let Y=b.scopeValue("validate$data",{ref:W.validateSchema});return E._`!${Y}(${w})`}return E.nil}}subschema(b,w){let $=(0,V6.getSubschema)(this.it,b);(0,V6.extendSubschemaData)($,this.it,b),(0,V6.extendSubschemaMode)($,b);let W={...this.it,...$,items:void 0,props:void 0};return AU(W,w),W}mergeEvaluated(b,w){let{it:$,gen:W}=this;if(!$.opts.unevaluated)return;if($.props!==!0&&b.props!==void 0)$.props=Gw.mergeEvaluated.props(W,b.props,$.props,w);if($.items!==!0&&b.items!==void 0)$.items=Gw.mergeEvaluated.items(W,b.items,$.items,w)}mergeValidEvaluated(b,w){let{it:$,gen:W}=this;if($.opts.unevaluated&&($.props!==!0||$.items!==!0))return W.if(w,()=>this.mergeEvaluated(b,E.Name)),!0}}zY.KeywordCxt=T6;function JY(b,w,$,W){let Q=new T6(b,$,w);if("code"in $)$.code(Q,W);else if(Q.$data&&$.validate)(0,l1.funcKeywordCode)(Q,$);else if("macro"in $)(0,l1.macroKeywordCode)(Q,$);else if($.compile||$.validate)(0,l1.funcKeywordCode)(Q,$)}var NU=/^\/(?:[^~]|~0|~1)*$/,EU=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function DY(b,{dataLevel:w,dataNames:$,dataPathArr:W}){let Q,G;if(b==="")return v.default.rootData;if(b[0]==="/"){if(!NU.test(b))throw Error(`Invalid JSON-pointer: ${b}`);Q=b,G=v.default.rootData}else{let J=EU.exec(b);if(!J)throw Error(`Invalid JSON-pointer: ${b}`);let D=+J[1];if(Q=J[2],Q==="#"){if(D>=w)throw Error(H("property/index",D));return W[w-D]}if(D>w)throw Error(H("data",D));if(G=$[w-D],!Q)return G}let X=G,Y=Q.split("/");for(let J of Y)if(J)G=E._`${G}${(0,E.getProperty)((0,Gw.unescapeJsonPointer)(J))}`,X=E._`${X} && ${G}`;return X;function H(J,D){return`Cannot access ${J} ${D} levels up, current level is ${w}`}}zY.getData=DY});var H$=I((qY)=>{Object.defineProperty(qY,"__esModule",{value:!0});class OY extends Error{constructor(b){super("validation failed");this.errors=b,this.ajv=this.validation=!0}}qY.default=OY});var p1=I((UY)=>{Object.defineProperty(UY,"__esModule",{value:!0});var _6=m1();class LY extends Error{constructor(b,w,$,W){super(W||`can't resolve reference ${$} from id ${w}`);this.missingRef=(0,_6.resolveUrl)(b,w,$),this.missingSchema=(0,_6.normalizeId)((0,_6.getFullPath)(b,this.missingRef))}}UY.default=LY});var D$=I((KY)=>{Object.defineProperty(KY,"__esModule",{value:!0});KY.resolveSchema=KY.getCompilingSchema=KY.resolveRef=KY.compileSchema=KY.SchemaEnv=void 0;var fb=u(),kU=H$(),Cw=Qw(),cb=m1(),BY=l(),vU=i1();class o1{constructor(b){var w;this.refs={},this.dynamicAnchors={};let $;if(typeof b.schema=="object")$=b.schema;this.schema=b.schema,this.schemaId=b.schemaId,this.root=b.root||this,this.baseId=(w=b.baseId)!==null&&w!==void 0?w:(0,cb.normalizeId)($===null||$===void 0?void 0:$[b.schemaId||"$id"]),this.schemaPath=b.schemaPath,this.localRefs=b.localRefs,this.meta=b.meta,this.$async=$===null||$===void 0?void 0:$.$async,this.refs={}}}KY.SchemaEnv=o1;function R6(b){let w=FY.call(this,b);if(w)return w;let $=(0,cb.getFullPath)(this.opts.uriResolver,b.root.baseId),{es5:W,lines:Q}=this.opts.code,{ownProperties:G}=this.opts,X=new fb.CodeGen(this.scope,{es5:W,lines:Q,ownProperties:G}),Y;if(b.$async)Y=X.scopeValue("Error",{ref:kU.default,code:fb._`require("ajv/dist/runtime/validation_error").default`});let H=X.scopeName("validate");b.validateName=H;let J={gen:X,allErrors:this.opts.allErrors,data:Cw.default.data,parentData:Cw.default.parentData,parentDataProperty:Cw.default.parentDataProperty,dataNames:[Cw.default.data],dataPathArr:[fb.nil],dataLevel:0,dataTypes:[],definedProperties:new Set,topSchemaRef:X.scopeValue("schema",this.opts.code.source===!0?{ref:b.schema,code:(0,fb.stringify)(b.schema)}:{ref:b.schema}),validateName:H,ValidationError:Y,schema:b.schema,schemaEnv:b,rootId:$,baseId:b.baseId||$,schemaPath:fb.nil,errSchemaPath:b.schemaPath||(this.opts.jtd?"":"#"),errorPath:fb._`""`,opts:this.opts,self:this},D;try{this._compilations.add(b),(0,vU.validateFunctionCode)(J),X.optimize(this.opts.code.optimize);let z=X.toString();if(D=`${X.scopeRefs(Cw.default.scope)}return ${z}`,this.opts.code.process)D=this.opts.code.process(D,b);let q=Function(`${Cw.default.self}`,`${Cw.default.scope}`,D)(this,this.scope.get());if(this.scope.value(H,{ref:q}),q.errors=null,q.schema=b.schema,q.schemaEnv=b,b.$async)q.$async=!0;if(this.opts.code.source===!0)q.source={validateName:H,validateCode:z,scopeValues:X._values};if(this.opts.unevaluated){let{props:B,items:K}=J;if(q.evaluated={props:B instanceof fb.Name?void 0:B,items:K instanceof fb.Name?void 0:K,dynamicProps:B instanceof fb.Name,dynamicItems:K instanceof fb.Name},q.source)q.source.evaluated=(0,fb.stringify)(q.evaluated)}return b.validate=q,b}catch(z){if(delete b.validate,delete b.validateName,D)this.logger.error("Error compiling schema, function code:",D);throw z}finally{this._compilations.delete(b)}}KY.compileSchema=R6;function CU(b,w,$){var W;$=(0,cb.resolveUrl)(this.opts.uriResolver,w,$);let Q=b.refs[$];if(Q)return Q;let G=yU.call(this,b,$);if(G===void 0){let X=(W=b.localRefs)===null||W===void 0?void 0:W[$],{schemaId:Y}=this.opts;if(X)G=new o1({schema:X,schemaId:Y,root:b,baseId:w})}if(G===void 0)return;return b.refs[$]=xU.call(this,G)}KY.resolveRef=CU;function xU(b){if((0,cb.inlineRef)(b.schema,this.opts.inlineRefs))return b.schema;return b.validate?b:R6.call(this,b)}function FY(b){for(let w of this._compilations)if(uU(w,b))return w}KY.getCompilingSchema=FY;function uU(b,w){return b.schema===w.schema&&b.root===w.root&&b.baseId===w.baseId}function yU(b,w){let $;while(typeof($=this.refs[w])=="string")w=$;return $||this.schemas[w]||J$.call(this,b,w)}function J$(b,w){let $=this.opts.uriResolver.parse(w),W=(0,cb._getFullPath)(this.opts.uriResolver,$),Q=(0,cb.getFullPath)(this.opts.uriResolver,b.baseId,void 0);if(Object.keys(b.schema).length>0&&W===Q)return S6.call(this,$,b);let G=(0,cb.normalizeId)(W),X=this.refs[G]||this.schemas[G];if(typeof X=="string"){let Y=J$.call(this,b,X);if(typeof(Y===null||Y===void 0?void 0:Y.schema)!=="object")return;return S6.call(this,$,Y)}if(typeof(X===null||X===void 0?void 0:X.schema)!=="object")return;if(!X.validate)R6.call(this,X);if(G===(0,cb.normalizeId)(w)){let{schema:Y}=X,{schemaId:H}=this.opts,J=Y[H];if(J)Q=(0,cb.resolveUrl)(this.opts.uriResolver,Q,J);return new o1({schema:Y,schemaId:H,root:b,baseId:Q})}return S6.call(this,$,X)}KY.resolveSchema=J$;var hU=new Set(["properties","patternProperties","enum","dependencies","definitions"]);function S6(b,{baseId:w,schema:$,root:W}){var Q;if(((Q=b.fragment)===null||Q===void 0?void 0:Q[0])!=="/")return;for(let Y of b.fragment.slice(1).split("/")){if(typeof $==="boolean")return;let H=$[(0,BY.unescapeFragment)(Y)];if(H===void 0)return;$=H;let J=typeof $==="object"&&$[this.opts.schemaId];if(!hU.has(Y)&&J)w=(0,cb.resolveUrl)(this.opts.uriResolver,w,J)}let G;if(typeof $!="boolean"&&$.$ref&&!(0,BY.schemaHasRulesButRef)($,this.RULES)){let Y=(0,cb.resolveUrl)(this.opts.uriResolver,w,$.$ref);G=J$.call(this,W,Y)}let{schemaId:X}=this.opts;if(G=G||new o1({schema:$,schemaId:X,root:W,baseId:w}),G.schema!==G.root.schema)return G;return}});var MY=I((gE,nU)=>{nU.exports={$id:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#",description:"Meta-schema for $data reference (JSON AnySchema extension proposal)",type:"object",required:["$data"],properties:{$data:{type:"string",anyOf:[{format:"relative-json-pointer"},{format:"json-pointer"}]}},additionalProperties:!1}});var v6=I((mE,VY)=>{var lU=RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu),jY=RegExp.prototype.test.bind(/^(?:(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)$/u);function k6(b){let w="",$=0,W=0;for(W=0;W<b.length;W++){if($=b[W].charCodeAt(0),$===48)continue;if(!($>=48&&$<=57||$>=65&&$<=70||$>=97&&$<=102))return"";w+=b[W];break}for(W+=1;W<b.length;W++){if($=b[W].charCodeAt(0),!($>=48&&$<=57||$>=65&&$<=70||$>=97&&$<=102))return"";w+=b[W]}return w}var iU=RegExp.prototype.test.bind(/[^!"$&'()*+,\-.;=_`a-z{}~]/u);function ZY(b){return b.length=0,!0}function pU(b,w,$){if(b.length){let W=k6(b);if(W!=="")w.push(W);else return $.error=!0,!1;b.length=0}return!0}function oU(b){let w=0,$={error:!1,address:"",zone:""},W=[],Q=[],G=!1,X=!1,Y=pU;for(let H=0;H<b.length;H++){let J=b[H];if(J==="["||J==="]")continue;if(J===":"){if(G===!0)X=!0;if(!Y(Q,W,$))break;if(++w>7){$.error=!0;break}if(H>0&&b[H-1]===":")G=!0;W.push(":");continue}else if(J==="%"){if(!Y(Q,W,$))break;Y=ZY}else{Q.push(J);continue}}if(Q.length)if(Y===ZY)$.zone=Q.join("");else if(X)W.push(Q.join(""));else W.push(k6(Q));return $.address=W.join(""),$}function IY(b){if(dU(b,":")<2)return{host:b,isIPV6:!1};let w=oU(b);if(!w.error){let{address:$,address:W}=w;if(w.zone)$+="%"+w.zone,W+="%25"+w.zone;return{host:$,isIPV6:!0,escapedHost:W}}else return{host:b,isIPV6:!1}}function dU(b,w){let $=0;for(let W=0;W<b.length;W++)if(b[W]===w)$++;return $}function tU(b){let w=b,$=[],W=-1,Q=0;while(Q=w.length){if(Q===1)if(w===".")break;else if(w==="/"){$.push("/");break}else{$.push(w);break}else if(Q===2){if(w[0]==="."){if(w[1]===".")break;else if(w[1]==="/"){w=w.slice(2);continue}}else if(w[0]==="/"){if(w[1]==="."||w[1]==="/"){$.push("/");break}}}else if(Q===3){if(w==="/.."){if($.length!==0)$.pop();$.push("/");break}}if(w[0]==="."){if(w[1]==="."){if(w[2]==="/"){w=w.slice(3);continue}}else if(w[1]==="/"){w=w.slice(2);continue}}else if(w[0]==="/"){if(w[1]==="."){if(w[2]==="/"){w=w.slice(2);continue}else if(w[2]==="."){if(w[3]==="/"){if(w=w.slice(3),$.length!==0)$.pop();continue}}}}if((W=w.indexOf("/",1))===-1){$.push(w);break}else $.push(w.slice(0,W)),w=w.slice(W)}return $.join("")}function rU(b,w){let $=w!==!0?escape:unescape;if(b.scheme!==void 0)b.scheme=$(b.scheme);if(b.userinfo!==void 0)b.userinfo=$(b.userinfo);if(b.host!==void 0)b.host=$(b.host);if(b.path!==void 0)b.path=$(b.path);if(b.query!==void 0)b.query=$(b.query);if(b.fragment!==void 0)b.fragment=$(b.fragment);return b}function eU(b){let w=[];if(b.userinfo!==void 0)w.push(b.userinfo),w.push("@");if(b.host!==void 0){let $=unescape(b.host);if(!jY($)){let W=IY($);if(W.isIPV6===!0)$=`[${W.escapedHost}]`;else $=b.host}w.push($)}if(typeof b.port==="number"||typeof b.port==="string")w.push(":"),w.push(String(b.port));return w.length?w.join(""):void 0}VY.exports={nonSimpleDomain:iU,recomposeAuthority:eU,normalizeComponentEncoding:rU,removeDotSegments:tU,isIPv4:jY,isUUID:lU,normalizeIPv6:IY,stringArrayToHexStripped:k6}});var SY=I((nE,_Y)=>{var{isUUID:sU}=v6(),aU=/([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-.:;=@]|%[\da-f]{2})+)/iu,b3=["http","https","ws","wss","urn","urn:uuid"];function w3(b){return b3.indexOf(b)!==-1}function C6(b){if(b.secure===!0)return!0;else if(b.secure===!1)return!1;else if(b.scheme)return b.scheme.length===3&&(b.scheme[0]==="w"||b.scheme[0]==="W")&&(b.scheme[1]==="s"||b.scheme[1]==="S")&&(b.scheme[2]==="s"||b.scheme[2]==="S");else return!1}function NY(b){if(!b.host)b.error=b.error||"HTTP URIs must have a host.";return b}function EY(b){let w=String(b.scheme).toLowerCase()==="https";if(b.port===(w?443:80)||b.port==="")b.port=void 0;if(!b.path)b.path="/";return b}function $3(b){return b.secure=C6(b),b.resourceName=(b.path||"/")+(b.query?"?"+b.query:""),b.path=void 0,b.query=void 0,b}function W3(b){if(b.port===(C6(b)?443:80)||b.port==="")b.port=void 0;if(typeof b.secure==="boolean")b.scheme=b.secure?"wss":"ws",b.secure=void 0;if(b.resourceName){let[w,$]=b.resourceName.split("?");b.path=w&&w!=="/"?w:void 0,b.query=$,b.resourceName=void 0}return b.fragment=void 0,b}function Q3(b,w){if(!b.path)return b.error="URN can not be parsed",b;let $=b.path.match(aU);if($){let W=w.scheme||b.scheme||"urn";b.nid=$[1].toLowerCase(),b.nss=$[2];let Q=`${W}:${w.nid||b.nid}`,G=x6(Q);if(b.path=void 0,G)b=G.parse(b,w)}else b.error=b.error||"URN can not be parsed.";return b}function G3(b,w){if(b.nid===void 0)throw Error("URN without nid cannot be serialized");let $=w.scheme||b.scheme||"urn",W=b.nid.toLowerCase(),Q=`${$}:${w.nid||W}`,G=x6(Q);if(G)b=G.serialize(b,w);let X=b,Y=b.nss;return X.path=`${W||w.nid}:${Y}`,w.skipEscape=!0,X}function X3(b,w){let $=b;if($.uuid=$.nss,$.nss=void 0,!w.tolerant&&(!$.uuid||!sU($.uuid)))$.error=$.error||"UUID is not valid.";return $}function Y3(b){let w=b;return w.nss=(b.uuid||"").toLowerCase(),w}var TY={scheme:"http",domainHost:!0,parse:NY,serialize:EY},H3={scheme:"https",domainHost:TY.domainHost,parse:NY,serialize:EY},z$={scheme:"ws",domainHost:!0,parse:$3,serialize:W3},J3={scheme:"wss",domainHost:z$.domainHost,parse:z$.parse,serialize:z$.serialize},D3={scheme:"urn",parse:Q3,serialize:G3,skipNormalize:!0},z3={scheme:"urn:uuid",parse:X3,serialize:Y3,skipNormalize:!0},A$={http:TY,https:H3,ws:z$,wss:J3,urn:D3,"urn:uuid":z3};Object.setPrototypeOf(A$,null);function x6(b){return b&&(A$[b]||A$[b.toLowerCase()])||void 0}_Y.exports={wsIsSecure:C6,SCHEMES:A$,isValidSchemeName:w3,getSchemeHandler:x6}});var vY=I((lE,q$)=>{var{normalizeIPv6:A3,removeDotSegments:d1,recomposeAuthority:O3,normalizeComponentEncoding:O$,isIPv4:q3,nonSimpleDomain:L3}=v6(),{SCHEMES:U3,getSchemeHandler:RY}=SY();function B3(b,w){if(typeof b==="string")b=db(Xw(b,w),w);else if(typeof b==="object")b=Xw(db(b,w),w);return b}function F3(b,w,$){let W=$?Object.assign({scheme:"null"},$):{scheme:"null"},Q=kY(Xw(b,W),Xw(w,W),W,!0);return W.skipEscape=!0,db(Q,W)}function kY(b,w,$,W){let Q={};if(!W)b=Xw(db(b,$),$),w=Xw(db(w,$),$);if($=$||{},!$.tolerant&&w.scheme)Q.scheme=w.scheme,Q.userinfo=w.userinfo,Q.host=w.host,Q.port=w.port,Q.path=d1(w.path||""),Q.query=w.query;else{if(w.userinfo!==void 0||w.host!==void 0||w.port!==void 0)Q.userinfo=w.userinfo,Q.host=w.host,Q.port=w.port,Q.path=d1(w.path||""),Q.query=w.query;else{if(!w.path)if(Q.path=b.path,w.query!==void 0)Q.query=w.query;else Q.query=b.query;else{if(w.path[0]==="/")Q.path=d1(w.path);else{if((b.userinfo!==void 0||b.host!==void 0||b.port!==void 0)&&!b.path)Q.path="/"+w.path;else if(!b.path)Q.path=w.path;else Q.path=b.path.slice(0,b.path.lastIndexOf("/")+1)+w.path;Q.path=d1(Q.path)}Q.query=w.query}Q.userinfo=b.userinfo,Q.host=b.host,Q.port=b.port}Q.scheme=b.scheme}return Q.fragment=w.fragment,Q}function K3(b,w,$){if(typeof b==="string")b=unescape(b),b=db(O$(Xw(b,$),!0),{...$,skipEscape:!0});else if(typeof b==="object")b=db(O$(b,!0),{...$,skipEscape:!0});if(typeof w==="string")w=unescape(w),w=db(O$(Xw(w,$),!0),{...$,skipEscape:!0});else if(typeof w==="object")w=db(O$(w,!0),{...$,skipEscape:!0});return b.toLowerCase()===w.toLowerCase()}function db(b,w){let $={host:b.host,scheme:b.scheme,userinfo:b.userinfo,port:b.port,path:b.path,query:b.query,nid:b.nid,nss:b.nss,uuid:b.uuid,fragment:b.fragment,reference:b.reference,resourceName:b.resourceName,secure:b.secure,error:""},W=Object.assign({},w),Q=[],G=RY(W.scheme||$.scheme);if(G&&G.serialize)G.serialize($,W);if($.path!==void 0)if(!W.skipEscape){if($.path=escape($.path),$.scheme!==void 0)$.path=$.path.split("%3A").join(":")}else $.path=unescape($.path);if(W.reference!=="suffix"&&$.scheme)Q.push($.scheme,":");let X=O3($);if(X!==void 0){if(W.reference!=="suffix")Q.push("//");if(Q.push(X),$.path&&$.path[0]!=="/")Q.push("/")}if($.path!==void 0){let Y=$.path;if(!W.absolutePath&&(!G||!G.absolutePath))Y=d1(Y);if(X===void 0&&Y[0]==="/"&&Y[1]==="/")Y="/%2F"+Y.slice(2);Q.push(Y)}if($.query!==void 0)Q.push("?",$.query);if($.fragment!==void 0)Q.push("#",$.fragment);return Q.join("")}var P3=/^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u;function Xw(b,w){let $=Object.assign({},w),W={scheme:void 0,userinfo:void 0,host:"",port:void 0,path:"",query:void 0,fragment:void 0},Q=!1;if($.reference==="suffix")if($.scheme)b=$.scheme+":"+b;else b="//"+b;let G=b.match(P3);if(G){if(W.scheme=G[1],W.userinfo=G[3],W.host=G[4],W.port=parseInt(G[5],10),W.path=G[6]||"",W.query=G[7],W.fragment=G[8],isNaN(W.port))W.port=G[5];if(W.host)if(q3(W.host)===!1){let H=A3(W.host);W.host=H.host.toLowerCase(),Q=H.isIPV6}else Q=!0;if(W.scheme===void 0&&W.userinfo===void 0&&W.host===void 0&&W.port===void 0&&W.query===void 0&&!W.path)W.reference="same-document";else if(W.scheme===void 0)W.reference="relative";else if(W.fragment===void 0)W.reference="absolute";else W.reference="uri";if($.reference&&$.reference!=="suffix"&&$.reference!==W.reference)W.error=W.error||"URI is not a "+$.reference+" reference.";let X=RY($.scheme||W.scheme);if(!$.unicodeSupport&&(!X||!X.unicodeSupport)){if(W.host&&($.domainHost||X&&X.domainHost)&&Q===!1&&L3(W.host))try{W.host=URL.domainToASCII(W.host.toLowerCase())}catch(Y){W.error=W.error||"Host's domain name can not be converted to ASCII: "+Y}}if(!X||X&&!X.skipNormalize){if(b.indexOf("%")!==-1){if(W.scheme!==void 0)W.scheme=unescape(W.scheme);if(W.host!==void 0)W.host=unescape(W.host)}if(W.path)W.path=escape(unescape(W.path));if(W.fragment)W.fragment=encodeURI(decodeURIComponent(W.fragment))}if(X&&X.parse)X.parse(W,$)}else W.error=W.error||"URI can not be parsed.";return W}var u6={SCHEMES:U3,normalize:B3,resolve:F3,resolveComponent:kY,equal:K3,serialize:db,parse:Xw};q$.exports=u6;q$.exports.default=u6;q$.exports.fastUri=u6});var uY=I((xY)=>{Object.defineProperty(xY,"__esModule",{value:!0});var CY=vY();CY.code='require("ajv/dist/runtime/uri").default';xY.default=CY});var lY=I((Yw)=>{Object.defineProperty(Yw,"__esModule",{value:!0});Yw.CodeGen=Yw.Name=Yw.nil=Yw.stringify=Yw.str=Yw._=Yw.KeywordCxt=void 0;var Z3=i1();Object.defineProperty(Yw,"KeywordCxt",{enumerable:!0,get:function(){return Z3.KeywordCxt}});var sw=u();Object.defineProperty(Yw,"_",{enumerable:!0,get:function(){return sw._}});Object.defineProperty(Yw,"str",{enumerable:!0,get:function(){return sw.str}});Object.defineProperty(Yw,"stringify",{enumerable:!0,get:function(){return sw.stringify}});Object.defineProperty(Yw,"nil",{enumerable:!0,get:function(){return sw.nil}});Object.defineProperty(Yw,"Name",{enumerable:!0,get:function(){return sw.Name}});Object.defineProperty(Yw,"CodeGen",{enumerable:!0,get:function(){return sw.CodeGen}});var j3=H$(),gY=p1(),I3=L6(),t1=D$(),V3=u(),r1=m1(),L$=g1(),h6=l(),yY=MY(),N3=uY(),mY=(b,w)=>new RegExp(b,w);mY.code="new RegExp";var E3=["removeAdditional","useDefaults","coerceTypes"],T3=new Set(["validate","serialize","parse","wrapper","root","schema","keyword","pattern","formats","validate$data","func","obj","Error"]),_3={errorDataPath:"",format:"`validateFormats: false` can be used instead.",nullable:'"nullable" keyword is supported by default.',jsonPointers:"Deprecated jsPropertySyntax can be used instead.",extendRefs:"Deprecated ignoreKeywordsWithRef can be used instead.",missingRefs:"Pass empty schema with $id that should be ignored to ajv.addSchema.",processCode:"Use option `code: {process: (code, schemaEnv: object) => string}`",sourceCode:"Use option `code: {source: true}`",strictDefaults:"It is default now, see option `strict`.",strictKeywords:"It is default now, see option `strict`.",uniqueItems:'"uniqueItems" keyword is always validated.',unknownFormats:"Disable strict mode or pass `true` to `ajv.addFormat` (or `formats` option).",cache:"Map is used as cache, schema object as key.",serialize:"Map is used as cache, schema object as key.",ajvErrors:"It is default now."},S3={ignoreKeywordsWithRef:"",jsPropertySyntax:"",unicode:'"minLength"/"maxLength" account for unicode characters by default.'},hY=200;function R3(b){var w,$,W,Q,G,X,Y,H,J,D,z,O,q,B,K,Z,M,k,S,h,R,ib,sb,i$,p$;let D1=b.strict,o$=(w=b.code)===null||w===void 0?void 0:w.optimize,TW=o$===!0||o$===void 0?1:o$||0,_W=(W=($=b.code)===null||$===void 0?void 0:$.regExp)!==null&&W!==void 0?W:mY,_z=(Q=b.uriResolver)!==null&&Q!==void 0?Q:N3.default;return{strictSchema:(X=(G=b.strictSchema)!==null&&G!==void 0?G:D1)!==null&&X!==void 0?X:!0,strictNumbers:(H=(Y=b.strictNumbers)!==null&&Y!==void 0?Y:D1)!==null&&H!==void 0?H:!0,strictTypes:(D=(J=b.strictTypes)!==null&&J!==void 0?J:D1)!==null&&D!==void 0?D:"log",strictTuples:(O=(z=b.strictTuples)!==null&&z!==void 0?z:D1)!==null&&O!==void 0?O:"log",strictRequired:(B=(q=b.strictRequired)!==null&&q!==void 0?q:D1)!==null&&B!==void 0?B:!1,code:b.code?{...b.code,optimize:TW,regExp:_W}:{optimize:TW,regExp:_W},loopRequired:(K=b.loopRequired)!==null&&K!==void 0?K:hY,loopEnum:(Z=b.loopEnum)!==null&&Z!==void 0?Z:hY,meta:(M=b.meta)!==null&&M!==void 0?M:!0,messages:(k=b.messages)!==null&&k!==void 0?k:!0,inlineRefs:(S=b.inlineRefs)!==null&&S!==void 0?S:!0,schemaId:(h=b.schemaId)!==null&&h!==void 0?h:"$id",addUsedSchema:(R=b.addUsedSchema)!==null&&R!==void 0?R:!0,validateSchema:(ib=b.validateSchema)!==null&&ib!==void 0?ib:!0,validateFormats:(sb=b.validateFormats)!==null&&sb!==void 0?sb:!0,unicodeRegExp:(i$=b.unicodeRegExp)!==null&&i$!==void 0?i$:!0,int32range:(p$=b.int32range)!==null&&p$!==void 0?p$:!0,uriResolver:_z}}class U${constructor(b={}){this.schemas={},this.refs={},this.formats={},this._compilations=new Set,this._loading={},this._cache=new Map,b=this.opts={...b,...R3(b)};let{es5:w,lines:$}=this.opts.code;this.scope=new V3.ValueScope({scope:{},prefixes:T3,es5:w,lines:$}),this.logger=y3(b.logger);let W=b.validateFormats;if(b.validateFormats=!1,this.RULES=(0,I3.getRules)(),fY.call(this,_3,b,"NOT SUPPORTED"),fY.call(this,S3,b,"DEPRECATED","warn"),this._metaOpts=x3.call(this),b.formats)v3.call(this);if(this._addVocabularies(),this._addDefaultMetaSchema(),b.keywords)C3.call(this,b.keywords);if(typeof b.meta=="object")this.addMetaSchema(b.meta);k3.call(this),b.validateFormats=W}_addVocabularies(){this.addKeyword("$async")}_addDefaultMetaSchema(){let{$data:b,meta:w,schemaId:$}=this.opts,W=yY;if($==="id")W={...yY},W.id=W.$id,delete W.$id;if(w&&b)this.addMetaSchema(W,W[$],!1)}defaultMeta(){let{meta:b,schemaId:w}=this.opts;return this.opts.defaultMeta=typeof b=="object"?b[w]||b:void 0}validate(b,w){let $;if(typeof b=="string"){if($=this.getSchema(b),!$)throw Error(`no schema with key or ref "${b}"`)}else $=this.compile(b);let W=$(w);if(!("$async"in $))this.errors=$.errors;return W}compile(b,w){let $=this._addSchema(b,w);return $.validate||this._compileSchemaEnv($)}compileAsync(b,w){if(typeof this.opts.loadSchema!="function")throw Error("options.loadSchema should be a function");let{loadSchema:$}=this.opts;return W.call(this,b,w);async function W(J,D){await Q.call(this,J.$schema);let z=this._addSchema(J,D);return z.validate||G.call(this,z)}async function Q(J){if(J&&!this.getSchema(J))await W.call(this,{$ref:J},!0)}async function G(J){try{return this._compileSchemaEnv(J)}catch(D){if(!(D instanceof gY.default))throw D;return X.call(this,D),await Y.call(this,D.missingSchema),G.call(this,J)}}function X({missingSchema:J,missingRef:D}){if(this.refs[J])throw Error(`AnySchema ${J} is loaded but ${D} cannot be resolved`)}async function Y(J){let D=await H.call(this,J);if(!this.refs[J])await Q.call(this,D.$schema);if(!this.refs[J])this.addSchema(D,J,w)}async function H(J){let D=this._loading[J];if(D)return D;try{return await(this._loading[J]=$(J))}finally{delete this._loading[J]}}}addSchema(b,w,$,W=this.opts.validateSchema){if(Array.isArray(b)){for(let G of b)this.addSchema(G,void 0,$,W);return this}let Q;if(typeof b==="object"){let{schemaId:G}=this.opts;if(Q=b[G],Q!==void 0&&typeof Q!="string")throw Error(`schema ${G} must be string`)}return w=(0,r1.normalizeId)(w||Q),this._checkUnique(w),this.schemas[w]=this._addSchema(b,$,w,W,!0),this}addMetaSchema(b,w,$=this.opts.validateSchema){return this.addSchema(b,w,!0,$),this}validateSchema(b,w){if(typeof b=="boolean")return!0;let $;if($=b.$schema,$!==void 0&&typeof $!="string")throw Error("$schema must be a string");if($=$||this.opts.defaultMeta||this.defaultMeta(),!$)return this.logger.warn("meta-schema not available"),this.errors=null,!0;let W=this.validate($,b);if(!W&&w){let Q="schema is invalid: "+this.errorsText();if(this.opts.validateSchema==="log")this.logger.error(Q);else throw Error(Q)}return W}getSchema(b){let w;while(typeof(w=cY.call(this,b))=="string")b=w;if(w===void 0){let{schemaId:$}=this.opts,W=new t1.SchemaEnv({schema:{},schemaId:$});if(w=t1.resolveSchema.call(this,W,b),!w)return;this.refs[b]=w}return w.validate||this._compileSchemaEnv(w)}removeSchema(b){if(b instanceof RegExp)return this._removeAllSchemas(this.schemas,b),this._removeAllSchemas(this.refs,b),this;switch(typeof b){case"undefined":return this._removeAllSchemas(this.schemas),this._removeAllSchemas(this.refs),this._cache.clear(),this;case"string":{let w=cY.call(this,b);if(typeof w=="object")this._cache.delete(w.schema);return delete this.schemas[b],delete this.refs[b],this}case"object":{let w=b;this._cache.delete(w);let $=b[this.opts.schemaId];if($)$=(0,r1.normalizeId)($),delete this.schemas[$],delete this.refs[$];return this}default:throw Error("ajv.removeSchema: invalid parameter")}}addVocabulary(b){for(let w of b)this.addKeyword(w);return this}addKeyword(b,w){let $;if(typeof b=="string"){if($=b,typeof w=="object")this.logger.warn("these parameters are deprecated, see docs for addKeyword"),w.keyword=$}else if(typeof b=="object"&&w===void 0){if(w=b,$=w.keyword,Array.isArray($)&&!$.length)throw Error("addKeywords: keyword must be string or non-empty array")}else throw Error("invalid addKeywords parameters");if(f3.call(this,$,w),!w)return(0,h6.eachItem)($,(Q)=>y6.call(this,Q)),this;g3.call(this,w);let W={...w,type:(0,L$.getJSONTypes)(w.type),schemaType:(0,L$.getJSONTypes)(w.schemaType)};return(0,h6.eachItem)($,W.type.length===0?(Q)=>y6.call(this,Q,W):(Q)=>W.type.forEach((G)=>y6.call(this,Q,W,G))),this}getKeyword(b){let w=this.RULES.all[b];return typeof w=="object"?w.definition:!!w}removeKeyword(b){let{RULES:w}=this;delete w.keywords[b],delete w.all[b];for(let $ of w.rules){let W=$.rules.findIndex((Q)=>Q.keyword===b);if(W>=0)$.rules.splice(W,1)}return this}addFormat(b,w){if(typeof w=="string")w=new RegExp(w);return this.formats[b]=w,this}errorsText(b=this.errors,{separator:w=", ",dataVar:$="data"}={}){if(!b||b.length===0)return"No errors";return b.map((W)=>`${$}${W.instancePath} ${W.message}`).reduce((W,Q)=>W+w+Q)}$dataMetaSchema(b,w){let $=this.RULES.all;b=JSON.parse(JSON.stringify(b));for(let W of w){let Q=W.split("/").slice(1),G=b;for(let X of Q)G=G[X];for(let X in $){let Y=$[X];if(typeof Y!="object")continue;let{$data:H}=Y.definition,J=G[X];if(H&&J)G[X]=nY(J)}}return b}_removeAllSchemas(b,w){for(let $ in b){let W=b[$];if(!w||w.test($)){if(typeof W=="string")delete b[$];else if(W&&!W.meta)this._cache.delete(W.schema),delete b[$]}}}_addSchema(b,w,$,W=this.opts.validateSchema,Q=this.opts.addUsedSchema){let G,{schemaId:X}=this.opts;if(typeof b=="object")G=b[X];else if(this.opts.jtd)throw Error("schema must be object");else if(typeof b!="boolean")throw Error("schema must be object or boolean");let Y=this._cache.get(b);if(Y!==void 0)return Y;$=(0,r1.normalizeId)(G||$);let H=r1.getSchemaRefs.call(this,b,$);if(Y=new t1.SchemaEnv({schema:b,schemaId:X,meta:w,baseId:$,localRefs:H}),this._cache.set(Y.schema,Y),Q&&!$.startsWith("#")){if($)this._checkUnique($);this.refs[$]=Y}if(W)this.validateSchema(b,!0);return Y}_checkUnique(b){if(this.schemas[b]||this.refs[b])throw Error(`schema with key or id "${b}" already exists`)}_compileSchemaEnv(b){if(b.meta)this._compileMetaSchema(b);else t1.compileSchema.call(this,b);if(!b.validate)throw Error("ajv implementation error");return b.validate}_compileMetaSchema(b){let w=this.opts;this.opts=this._metaOpts;try{t1.compileSchema.call(this,b)}finally{this.opts=w}}}U$.ValidationError=j3.default;U$.MissingRefError=gY.default;Yw.default=U$;function fY(b,w,$,W="error"){for(let Q in b){let G=Q;if(G in w)this.logger[W](`${$}: option ${Q}. ${b[G]}`)}}function cY(b){return b=(0,r1.normalizeId)(b),this.schemas[b]||this.refs[b]}function k3(){let b=this.opts.schemas;if(!b)return;if(Array.isArray(b))this.addSchema(b);else for(let w in b)this.addSchema(b[w],w)}function v3(){for(let b in this.opts.formats){let w=this.opts.formats[b];if(w)this.addFormat(b,w)}}function C3(b){if(Array.isArray(b)){this.addVocabulary(b);return}this.logger.warn("keywords option as map is deprecated, pass array");for(let w in b){let $=b[w];if(!$.keyword)$.keyword=w;this.addKeyword($)}}function x3(){let b={...this.opts};for(let w of E3)delete b[w];return b}var u3={log(){},warn(){},error(){}};function y3(b){if(b===!1)return u3;if(b===void 0)return console;if(b.log&&b.warn&&b.error)return b;throw Error("logger must implement log, warn and error methods")}var h3=/^[a-z_$][a-z0-9_$:-]*$/i;function f3(b,w){let{RULES:$}=this;if((0,h6.eachItem)(b,(W)=>{if($.keywords[W])throw Error(`Keyword ${W} is already defined`);if(!h3.test(W))throw Error(`Keyword ${W} has invalid name`)}),!w)return;if(w.$data&&!(("code"in w)||("validate"in w)))throw Error('$data keyword must have "code" or "validate" function')}function y6(b,w,$){var W;let Q=w===null||w===void 0?void 0:w.post;if($&&Q)throw Error('keyword with "post" flag cannot have "type"');let{RULES:G}=this,X=Q?G.post:G.rules.find(({type:H})=>H===$);if(!X)X={type:$,rules:[]},G.rules.push(X);if(G.keywords[b]=!0,!w)return;let Y={keyword:b,definition:{...w,type:(0,L$.getJSONTypes)(w.type),schemaType:(0,L$.getJSONTypes)(w.schemaType)}};if(w.before)c3.call(this,X,Y,w.before);else X.rules.push(Y);G.all[b]=Y,(W=w.implements)===null||W===void 0||W.forEach((H)=>this.addKeyword(H))}function c3(b,w,$){let W=b.rules.findIndex((Q)=>Q.keyword===$);if(W>=0)b.rules.splice(W,0,w);else b.rules.push(w),this.logger.warn(`rule ${$} is not defined`)}function g3(b){let{metaSchema:w}=b;if(w===void 0)return;if(b.$data&&this.opts.$data)w=nY(w);b.validateSchema=this.compile(w,!0)}var m3={$ref:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#"};function nY(b){return{anyOf:[b,m3]}}});var pY=I((iY)=>{Object.defineProperty(iY,"__esModule",{value:!0});var i3={keyword:"id",code(){throw Error('NOT SUPPORTED: keyword "id", use "$id" for schema ID')}};iY.default=i3});var sY=I((rY)=>{Object.defineProperty(rY,"__esModule",{value:!0});rY.callRef=rY.getValidate=void 0;var o3=p1(),oY=vb(),jb=u(),aw=Qw(),dY=D$(),B$=l(),d3={keyword:"$ref",schemaType:"string",code(b){let{gen:w,schema:$,it:W}=b,{baseId:Q,schemaEnv:G,validateName:X,opts:Y,self:H}=W,{root:J}=G;if(($==="#"||$==="#/")&&Q===J.baseId)return z();let D=dY.resolveRef.call(H,J,Q,$);if(D===void 0)throw new o3.default(W.opts.uriResolver,Q,$);if(D instanceof dY.SchemaEnv)return O(D);return q(D);function z(){if(G===J)return F$(b,X,G,G.$async);let B=w.scopeValue("root",{ref:J});return F$(b,jb._`${B}.validate`,J,J.$async)}function O(B){let K=tY(b,B);F$(b,K,B,B.$async)}function q(B){let K=w.scopeValue("schema",Y.code.source===!0?{ref:B,code:(0,jb.stringify)(B)}:{ref:B}),Z=w.name("valid"),M=b.subschema({schema:B,dataTypes:[],schemaPath:jb.nil,topSchemaRef:K,errSchemaPath:$},Z);b.mergeEvaluated(M),b.ok(Z)}}};function tY(b,w){let{gen:$}=b;return w.validate?$.scopeValue("validate",{ref:w.validate}):jb._`${$.scopeValue("wrapper",{ref:w})}.validate`}rY.getValidate=tY;function F$(b,w,$,W){let{gen:Q,it:G}=b,{allErrors:X,schemaEnv:Y,opts:H}=G,J=H.passContext?aw.default.this:jb.nil;if(W)D();else z();function D(){if(!Y.$async)throw Error("async schema referenced by sync schema");let B=Q.let("valid");Q.try(()=>{if(Q.code(jb._`await ${(0,oY.callValidateCode)(b,w,J)}`),q(w),!X)Q.assign(B,!0)},(K)=>{if(Q.if(jb._`!(${K} instanceof ${G.ValidationError})`,()=>Q.throw(K)),O(K),!X)Q.assign(B,!1)}),b.ok(B)}function z(){b.result((0,oY.callValidateCode)(b,w,J),()=>q(w),()=>O(w))}function O(B){let K=jb._`${B}.errors`;Q.assign(aw.default.vErrors,jb._`${aw.default.vErrors} === null ? ${K} : ${aw.default.vErrors}.concat(${K})`),Q.assign(aw.default.errors,jb._`${aw.default.vErrors}.length`)}function q(B){var K;if(!G.opts.unevaluated)return;let Z=(K=$===null||$===void 0?void 0:$.validate)===null||K===void 0?void 0:K.evaluated;if(G.props!==!0)if(Z&&!Z.dynamicProps){if(Z.props!==void 0)G.props=B$.mergeEvaluated.props(Q,Z.props,G.props)}else{let M=Q.var("props",jb._`${B}.evaluated.props`);G.props=B$.mergeEvaluated.props(Q,M,G.props,jb.Name)}if(G.items!==!0)if(Z&&!Z.dynamicItems){if(Z.items!==void 0)G.items=B$.mergeEvaluated.items(Q,Z.items,G.items)}else{let M=Q.var("items",jb._`${B}.evaluated.items`);G.items=B$.mergeEvaluated.items(Q,M,G.items,jb.Name)}}}rY.callRef=F$;rY.default=d3});var bH=I((aY)=>{Object.defineProperty(aY,"__esModule",{value:!0});var e3=pY(),s3=sY(),a3=["$schema","$id","$defs","$vocabulary",{keyword:"$comment"},"definitions",e3.default,s3.default];aY.default=a3});var $H=I((wH)=>{Object.defineProperty(wH,"__esModule",{value:!0});var K$=u(),Vw=K$.operators,P$={maximum:{okStr:"<=",ok:Vw.LTE,fail:Vw.GT},minimum:{okStr:">=",ok:Vw.GTE,fail:Vw.LT},exclusiveMaximum:{okStr:"<",ok:Vw.LT,fail:Vw.GTE},exclusiveMinimum:{okStr:">",ok:Vw.GT,fail:Vw.LTE}},wB={message:({keyword:b,schemaCode:w})=>K$.str`must be ${P$[b].okStr} ${w}`,params:({keyword:b,schemaCode:w})=>K$._`{comparison: ${P$[b].okStr}, limit: ${w}}`},$B={keyword:Object.keys(P$),type:"number",schemaType:"number",$data:!0,error:wB,code(b){let{keyword:w,data:$,schemaCode:W}=b;b.fail$data(K$._`${$} ${P$[w].fail} ${W} || isNaN(${$})`)}};wH.default=$B});var QH=I((WH)=>{Object.defineProperty(WH,"__esModule",{value:!0});var e1=u(),QB={message:({schemaCode:b})=>e1.str`must be multiple of ${b}`,params:({schemaCode:b})=>e1._`{multipleOf: ${b}}`},GB={keyword:"multipleOf",type:"number",schemaType:"number",$data:!0,error:QB,code(b){let{gen:w,data:$,schemaCode:W,it:Q}=b,G=Q.opts.multipleOfPrecision,X=w.let("res"),Y=G?e1._`Math.abs(Math.round(${X}) - ${X}) > 1e-${G}`:e1._`${X} !== parseInt(${X})`;b.fail$data(e1._`(${W} === 0 || (${X} = ${$}/${W}, ${Y}))`)}};WH.default=GB});var YH=I((XH)=>{Object.defineProperty(XH,"__esModule",{value:!0});function GH(b){let w=b.length,$=0,W=0,Q;while(W<w)if($++,Q=b.charCodeAt(W++),Q>=55296&&Q<=56319&&W<w){if(Q=b.charCodeAt(W),(Q&64512)===56320)W++}return $}XH.default=GH;GH.code='require("ajv/dist/runtime/ucs2length").default'});var JH=I((HH)=>{Object.defineProperty(HH,"__esModule",{value:!0});var xw=u(),HB=l(),JB=YH(),DB={message({keyword:b,schemaCode:w}){let $=b==="maxLength"?"more":"fewer";return xw.str`must NOT have ${$} than ${w} characters`},params:({schemaCode:b})=>xw._`{limit: ${b}}`},zB={keyword:["maxLength","minLength"],type:"string",schemaType:"number",$data:!0,error:DB,code(b){let{keyword:w,data:$,schemaCode:W,it:Q}=b,G=w==="maxLength"?xw.operators.GT:xw.operators.LT,X=Q.opts.unicode===!1?xw._`${$}.length`:xw._`${(0,HB.useFunc)(b.gen,JB.default)}(${$})`;b.fail$data(xw._`${X} ${G} ${W}`)}};HH.default=zB});var zH=I((DH)=>{Object.defineProperty(DH,"__esModule",{value:!0});var OB=vb(),M$=u(),qB={message:({schemaCode:b})=>M$.str`must match pattern "${b}"`,params:({schemaCode:b})=>M$._`{pattern: ${b}}`},LB={keyword:"pattern",type:"string",schemaType:"string",$data:!0,error:qB,code(b){let{data:w,$data:$,schema:W,schemaCode:Q,it:G}=b,X=G.opts.unicodeRegExp?"u":"",Y=$?M$._`(new RegExp(${Q}, ${X}))`:(0,OB.usePattern)(b,W);b.fail$data(M$._`!${Y}.test(${w})`)}};DH.default=LB});var OH=I((AH)=>{Object.defineProperty(AH,"__esModule",{value:!0});var s1=u(),BB={message({keyword:b,schemaCode:w}){let $=b==="maxProperties"?"more":"fewer";return s1.str`must NOT have ${$} than ${w} properties`},params:({schemaCode:b})=>s1._`{limit: ${b}}`},FB={keyword:["maxProperties","minProperties"],type:"object",schemaType:"number",$data:!0,error:BB,code(b){let{keyword:w,data:$,schemaCode:W}=b,Q=w==="maxProperties"?s1.operators.GT:s1.operators.LT;b.fail$data(s1._`Object.keys(${$}).length ${Q} ${W}`)}};AH.default=FB});var LH=I((qH)=>{Object.defineProperty(qH,"__esModule",{value:!0});var a1=vb(),b0=u(),PB=l(),MB={message:({params:{missingProperty:b}})=>b0.str`must have required property '${b}'`,params:({params:{missingProperty:b}})=>b0._`{missingProperty: ${b}}`},ZB={keyword:"required",type:"object",schemaType:"array",$data:!0,error:MB,code(b){let{gen:w,schema:$,schemaCode:W,data:Q,$data:G,it:X}=b,{opts:Y}=X;if(!G&&$.length===0)return;let H=$.length>=Y.loopRequired;if(X.allErrors)J();else D();if(Y.strictRequired){let q=b.parentSchema.properties,{definedProperties:B}=b.it;for(let K of $)if((q===null||q===void 0?void 0:q[K])===void 0&&!B.has(K)){let Z=X.schemaEnv.baseId+X.errSchemaPath,M=`required property "${K}" is not defined at "${Z}" (strictRequired)`;(0,PB.checkStrictMode)(X,M,X.opts.strictRequired)}}function J(){if(H||G)b.block$data(b0.nil,z);else for(let q of $)(0,a1.checkReportMissingProp)(b,q)}function D(){let q=w.let("missing");if(H||G){let B=w.let("valid",!0);b.block$data(B,()=>O(q,B)),b.ok(B)}else w.if((0,a1.checkMissingProp)(b,$,q)),(0,a1.reportMissingProp)(b,q),w.else()}function z(){w.forOf("prop",W,(q)=>{b.setParams({missingProperty:q}),w.if((0,a1.noPropertyInData)(w,Q,q,Y.ownProperties),()=>b.error())})}function O(q,B){b.setParams({missingProperty:q}),w.forOf(q,W,()=>{w.assign(B,(0,a1.propertyInData)(w,Q,q,Y.ownProperties)),w.if((0,b0.not)(B),()=>{b.error(),w.break()})},b0.nil)}}};qH.default=ZB});var BH=I((UH)=>{Object.defineProperty(UH,"__esModule",{value:!0});var w0=u(),IB={message({keyword:b,schemaCode:w}){let $=b==="maxItems"?"more":"fewer";return w0.str`must NOT have ${$} than ${w} items`},params:({schemaCode:b})=>w0._`{limit: ${b}}`},VB={keyword:["maxItems","minItems"],type:"array",schemaType:"number",$data:!0,error:IB,code(b){let{keyword:w,data:$,schemaCode:W}=b,Q=w==="maxItems"?w0.operators.GT:w0.operators.LT;b.fail$data(w0._`${$}.length ${Q} ${W}`)}};UH.default=VB});var Z$=I((KH)=>{Object.defineProperty(KH,"__esModule",{value:!0});var FH=j6();FH.code='require("ajv/dist/runtime/equal").default';KH.default=FH});var MH=I((PH)=>{Object.defineProperty(PH,"__esModule",{value:!0});var f6=g1(),qb=u(),TB=l(),_B=Z$(),SB={message:({params:{i:b,j:w}})=>qb.str`must NOT have duplicate items (items ## ${w} and ${b} are identical)`,params:({params:{i:b,j:w}})=>qb._`{i: ${b}, j: ${w}}`},RB={keyword:"uniqueItems",type:"array",schemaType:"boolean",$data:!0,error:SB,code(b){let{gen:w,data:$,$data:W,schema:Q,parentSchema:G,schemaCode:X,it:Y}=b;if(!W&&!Q)return;let H=w.let("valid"),J=G.items?(0,f6.getSchemaTypes)(G.items):[];b.block$data(H,D,qb._`${X} === false`),b.ok(H);function D(){let B=w.let("i",qb._`${$}.length`),K=w.let("j");b.setParams({i:B,j:K}),w.assign(H,!0),w.if(qb._`${B} > 1`,()=>(z()?O:q)(B,K))}function z(){return J.length>0&&!J.some((B)=>B==="object"||B==="array")}function O(B,K){let Z=w.name("item"),M=(0,f6.checkDataTypes)(J,Z,Y.opts.strictNumbers,f6.DataType.Wrong),k=w.const("indices",qb._`{}`);w.for(qb._`;${B}--;`,()=>{if(w.let(Z,qb._`${$}[${B}]`),w.if(M,qb._`continue`),J.length>1)w.if(qb._`typeof ${Z} == "string"`,qb._`${Z} += "_"`);w.if(qb._`typeof ${k}[${Z}] == "number"`,()=>{w.assign(K,qb._`${k}[${Z}]`),b.error(),w.assign(H,!1).break()}).code(qb._`${k}[${Z}] = ${B}`)})}function q(B,K){let Z=(0,TB.useFunc)(w,_B.default),M=w.name("outer");w.label(M).for(qb._`;${B}--;`,()=>w.for(qb._`${K} = ${B}; ${K}--;`,()=>w.if(qb._`${Z}(${$}[${B}], ${$}[${K}])`,()=>{b.error(),w.assign(H,!1).break(M)})))}}};PH.default=RB});var jH=I((ZH)=>{Object.defineProperty(ZH,"__esModule",{value:!0});var c6=u(),vB=l(),CB=Z$(),xB={message:"must be equal to constant",params:({schemaCode:b})=>c6._`{allowedValue: ${b}}`},uB={keyword:"const",$data:!0,error:xB,code(b){let{gen:w,data:$,$data:W,schemaCode:Q,schema:G}=b;if(W||G&&typeof G=="object")b.fail$data(c6._`!${(0,vB.useFunc)(w,CB.default)}(${$}, ${Q})`);else b.fail(c6._`${G} !== ${$}`)}};ZH.default=uB});var VH=I((IH)=>{Object.defineProperty(IH,"__esModule",{value:!0});var $0=u(),hB=l(),fB=Z$(),cB={message:"must be equal to one of the allowed values",params:({schemaCode:b})=>$0._`{allowedValues: ${b}}`},gB={keyword:"enum",schemaType:"array",$data:!0,error:cB,code(b){let{gen:w,data:$,$data:W,schema:Q,schemaCode:G,it:X}=b;if(!W&&Q.length===0)throw Error("enum must have non-empty array");let Y=Q.length>=X.opts.loopEnum,H,J=()=>H!==null&&H!==void 0?H:H=(0,hB.useFunc)(w,fB.default),D;if(Y||W)D=w.let("valid"),b.block$data(D,z);else{if(!Array.isArray(Q))throw Error("ajv implementation error");let q=w.const("vSchema",G);D=(0,$0.or)(...Q.map((B,K)=>O(q,K)))}b.pass(D);function z(){w.assign(D,!1),w.forOf("v",G,(q)=>w.if($0._`${J()}(${$}, ${q})`,()=>w.assign(D,!0).break()))}function O(q,B){let K=Q[B];return typeof K==="object"&&K!==null?$0._`${J()}(${$}, ${q}[${B}])`:$0._`${$} === ${K}`}}};IH.default=gB});var EH=I((NH)=>{Object.defineProperty(NH,"__esModule",{value:!0});var nB=$H(),lB=QH(),iB=JH(),pB=zH(),oB=OH(),dB=LH(),tB=BH(),rB=MH(),eB=jH(),sB=VH(),aB=[nB.default,lB.default,iB.default,pB.default,oB.default,dB.default,tB.default,rB.default,{keyword:"type",schemaType:["string","array"]},{keyword:"nullable",schemaType:"boolean"},eB.default,sB.default];NH.default=aB});var m6=I((_H)=>{Object.defineProperty(_H,"__esModule",{value:!0});_H.validateAdditionalItems=void 0;var uw=u(),g6=l(),wF={message:({params:{len:b}})=>uw.str`must NOT have more than ${b} items`,params:({params:{len:b}})=>uw._`{limit: ${b}}`},$F={keyword:"additionalItems",type:"array",schemaType:["boolean","object"],before:"uniqueItems",error:wF,code(b){let{parentSchema:w,it:$}=b,{items:W}=w;if(!Array.isArray(W)){(0,g6.checkStrictMode)($,'"additionalItems" is ignored when "items" is not an array of schemas');return}TH(b,W)}};function TH(b,w){let{gen:$,schema:W,data:Q,keyword:G,it:X}=b;X.items=!0;let Y=$.const("len",uw._`${Q}.length`);if(W===!1)b.setParams({len:w.length}),b.pass(uw._`${Y} <= ${w.length}`);else if(typeof W=="object"&&!(0,g6.alwaysValidSchema)(X,W)){let J=$.var("valid",uw._`${Y} <= ${w.length}`);$.if((0,uw.not)(J),()=>H(J)),b.ok(J)}function H(J){$.forRange("i",w.length,Y,(D)=>{if(b.subschema({keyword:G,dataProp:D,dataPropType:g6.Type.Num},J),!X.allErrors)$.if((0,uw.not)(J),()=>$.break())})}}_H.validateAdditionalItems=TH;_H.default=$F});var n6=I((vH)=>{Object.defineProperty(vH,"__esModule",{value:!0});vH.validateTuple=void 0;var RH=u(),j$=l(),QF=vb(),GF={keyword:"items",type:"array",schemaType:["object","array","boolean"],before:"uniqueItems",code(b){let{schema:w,it:$}=b;if(Array.isArray(w))return kH(b,"additionalItems",w);if($.items=!0,(0,j$.alwaysValidSchema)($,w))return;b.ok((0,QF.validateArray)(b))}};function kH(b,w,$=b.schema){let{gen:W,parentSchema:Q,data:G,keyword:X,it:Y}=b;if(D(Q),Y.opts.unevaluated&&$.length&&Y.items!==!0)Y.items=j$.mergeEvaluated.items(W,$.length,Y.items);let H=W.name("valid"),J=W.const("len",RH._`${G}.length`);$.forEach((z,O)=>{if((0,j$.alwaysValidSchema)(Y,z))return;W.if(RH._`${J} > ${O}`,()=>b.subschema({keyword:X,schemaProp:O,dataProp:O},H)),b.ok(H)});function D(z){let{opts:O,errSchemaPath:q}=Y,B=$.length,K=B===z.minItems&&(B===z.maxItems||z[w]===!1);if(O.strictTuples&&!K){let Z=`"${X}" is ${B}-tuple, but minItems or maxItems/${w} are not specified or different at path "${q}"`;(0,j$.checkStrictMode)(Y,Z,O.strictTuples)}}}vH.validateTuple=kH;vH.default=GF});var uH=I((xH)=>{Object.defineProperty(xH,"__esModule",{value:!0});var YF=n6(),HF={keyword:"prefixItems",type:"array",schemaType:["array"],before:"uniqueItems",code:(b)=>(0,YF.validateTuple)(b,"items")};xH.default=HF});var fH=I((hH)=>{Object.defineProperty(hH,"__esModule",{value:!0});var yH=u(),DF=l(),zF=vb(),AF=m6(),OF={message:({params:{len:b}})=>yH.str`must NOT have more than ${b} items`,params:({params:{len:b}})=>yH._`{limit: ${b}}`},qF={keyword:"items",type:"array",schemaType:["object","boolean"],before:"uniqueItems",error:OF,code(b){let{schema:w,parentSchema:$,it:W}=b,{prefixItems:Q}=$;if(W.items=!0,(0,DF.alwaysValidSchema)(W,w))return;if(Q)(0,AF.validateAdditionalItems)(b,Q);else b.ok((0,zF.validateArray)(b))}};hH.default=qF});var gH=I((cH)=>{Object.defineProperty(cH,"__esModule",{value:!0});var Cb=u(),I$=l(),UF={message:({params:{min:b,max:w}})=>w===void 0?Cb.str`must contain at least ${b} valid item(s)`:Cb.str`must contain at least ${b} and no more than ${w} valid item(s)`,params:({params:{min:b,max:w}})=>w===void 0?Cb._`{minContains: ${b}}`:Cb._`{minContains: ${b}, maxContains: ${w}}`},BF={keyword:"contains",type:"array",schemaType:["object","boolean"],before:"uniqueItems",trackErrors:!0,error:UF,code(b){let{gen:w,schema:$,parentSchema:W,data:Q,it:G}=b,X,Y,{minContains:H,maxContains:J}=W;if(G.opts.next)X=H===void 0?1:H,Y=J;else X=1;let D=w.const("len",Cb._`${Q}.length`);if(b.setParams({min:X,max:Y}),Y===void 0&&X===0){(0,I$.checkStrictMode)(G,'"minContains" == 0 without "maxContains": "contains" keyword ignored');return}if(Y!==void 0&&X>Y){(0,I$.checkStrictMode)(G,'"minContains" > "maxContains" is always invalid'),b.fail();return}if((0,I$.alwaysValidSchema)(G,$)){let K=Cb._`${D} >= ${X}`;if(Y!==void 0)K=Cb._`${K} && ${D} <= ${Y}`;b.pass(K);return}G.items=!0;let z=w.name("valid");if(Y===void 0&&X===1)q(z,()=>w.if(z,()=>w.break()));else if(X===0){if(w.let(z,!0),Y!==void 0)w.if(Cb._`${Q}.length > 0`,O)}else w.let(z,!1),O();b.result(z,()=>b.reset());function O(){let K=w.name("_valid"),Z=w.let("count",0);q(K,()=>w.if(K,()=>B(Z)))}function q(K,Z){w.forRange("i",0,D,(M)=>{b.subschema({keyword:"contains",dataProp:M,dataPropType:I$.Type.Num,compositeRule:!0},K),Z()})}function B(K){if(w.code(Cb._`${K}++`),Y===void 0)w.if(Cb._`${K} >= ${X}`,()=>w.assign(z,!0).break());else if(w.if(Cb._`${K} > ${Y}`,()=>w.assign(z,!1).break()),X===1)w.assign(z,!0);else w.if(Cb._`${K} >= ${X}`,()=>w.assign(z,!0))}}};cH.default=BF});var oH=I((lH)=>{Object.defineProperty(lH,"__esModule",{value:!0});lH.validateSchemaDeps=lH.validatePropertyDeps=lH.error=void 0;var l6=u(),KF=l(),W0=vb();lH.error={message:({params:{property:b,depsCount:w,deps:$}})=>{let W=w===1?"property":"properties";return l6.str`must have ${W} ${$} when property ${b} is present`},params:({params:{property:b,depsCount:w,deps:$,missingProperty:W}})=>l6._`{property: ${b},
|
|
5
|
+
|| ${X} === "boolean" || ${Q} === null`).assign(Y,C._`[${Q}]`)}}}function oq({gen:b,parentData:w,parentDataProperty:$},W){b.if(C._`${w} !== undefined`,()=>b.assign(C._`${w}[${$}]`,W))}function B6(b,w,$,W=tw.Correct){let Q=W===tw.Correct?C.operators.EQ:C.operators.NEQ,G;switch(b){case"null":return C._`${w} ${Q} null`;case"array":G=C._`Array.isArray(${w})`;break;case"object":G=C._`${w} && typeof ${w} == "object" && !Array.isArray(${w})`;break;case"integer":G=X(C._`!(${w} % 1) && !isNaN(${w})`);break;case"number":G=X();break;default:return C._`typeof ${w} ${Q} ${b}`}return W===tw.Correct?G:(0,C.not)(G);function X(Y=C.nil){return(0,C.and)(C._`typeof ${w} == "number"`,Y,$?C._`isFinite(${w})`:C.nil)}}IX.checkDataType=B6;function F6(b,w,$,W){if(b.length===1)return B6(b[0],w,$,W);let Q,G=(0,MX.toHash)(b);if(G.array&&G.object){let X=C._`typeof ${w} != "object"`;Q=G.null?X:C._`!${w} || ${X}`,delete G.null,delete G.array,delete G.object}else Q=C.nil;if(G.number)delete G.integer;for(let X in G)Q=(0,C.and)(Q,B6(X,w,$,W));return Q}IX.checkDataTypes=F6;var dq={message:({schema:b})=>`must be ${b}`,params:({schema:b,schemaValue:w})=>typeof b=="string"?C._`{type: ${b}}`:C._`{type: ${w}}`};function K6(b){let w=tq(b);(0,mq.reportError)(w,dq)}IX.reportTypeError=K6;function tq(b){let{gen:w,data:$,schema:W}=b,Q=(0,MX.schemaRefOrVal)(b,W,"type");return{gen:w,keyword:"type",data:$,schema:W.type,schemaCode:Q,schemaValue:Q,parentSchema:W,params:{},it:b}}});var _X=I((EX)=>{Object.defineProperty(EX,"__esModule",{value:!0});EX.assignDefaults=void 0;var rw=u(),$L=l();function WL(b,w){let{properties:$,items:W}=b.schema;if(w==="object"&&$)for(let Q in $)NX(b,Q,$[Q].default);else if(w==="array"&&Array.isArray(W))W.forEach((Q,G)=>NX(b,G,Q.default))}EX.assignDefaults=WL;function NX(b,w,$){let{gen:W,compositeRule:Q,data:G,opts:X}=b;if($===void 0)return;let Y=rw._`${G}${(0,rw.getProperty)(w)}`;if(Q){(0,$L.checkStrictMode)(b,`default is ignored for: ${Y}`);return}let H=rw._`${Y} === undefined`;if(X.useDefaults==="empty")H=rw._`${H} || ${Y} === null || ${Y} === ""`;W.if(H,rw._`${Y} = ${(0,rw.stringify)($)}`)}});var vb=I((kX)=>{Object.defineProperty(kX,"__esModule",{value:!0});kX.validateUnion=kX.validateArray=kX.usePattern=kX.callValidateCode=kX.schemaProperties=kX.allSchemaProperties=kX.noPropertyInData=kX.propertyInData=kX.isOwnProperty=kX.hasPropFunc=kX.reportMissingProp=kX.checkMissingProp=kX.checkReportMissingProp=void 0;var a=u(),P6=l(),jw=Qw(),QL=l();function GL(b,w){let{gen:$,data:W,it:Q}=b;$.if(Z6($,W,w,Q.opts.ownProperties),()=>{b.setParams({missingProperty:a._`${w}`},!0),b.error()})}kX.checkReportMissingProp=GL;function XL({gen:b,data:w,it:{opts:$}},W,Q){return(0,a.or)(...W.map((G)=>(0,a.and)(Z6(b,w,G,$.ownProperties),a._`${Q} = ${G}`)))}kX.checkMissingProp=XL;function YL(b,w){b.setParams({missingProperty:w},!0),b.error()}kX.reportMissingProp=YL;function SX(b){return b.scopeValue("func",{ref:Object.prototype.hasOwnProperty,code:a._`Object.prototype.hasOwnProperty`})}kX.hasPropFunc=SX;function M6(b,w,$){return a._`${SX(b)}.call(${w}, ${$})`}kX.isOwnProperty=M6;function HL(b,w,$,W){let Q=a._`${w}${(0,a.getProperty)($)} !== undefined`;return W?a._`${Q} && ${M6(b,w,$)}`:Q}kX.propertyInData=HL;function Z6(b,w,$,W){let Q=a._`${w}${(0,a.getProperty)($)} === undefined`;return W?(0,a.or)(Q,(0,a.not)(M6(b,w,$))):Q}kX.noPropertyInData=Z6;function RX(b){return b?Object.keys(b).filter((w)=>w!=="__proto__"):[]}kX.allSchemaProperties=RX;function JL(b,w){return RX(w).filter(($)=>!(0,P6.alwaysValidSchema)(b,w[$]))}kX.schemaProperties=JL;function DL({schemaCode:b,data:w,it:{gen:$,topSchemaRef:W,schemaPath:Q,errorPath:G},it:X},Y,H,J){let D=J?a._`${b}, ${w}, ${W}${Q}`:w,z=[[jw.default.instancePath,(0,a.strConcat)(jw.default.instancePath,G)],[jw.default.parentData,X.parentData],[jw.default.parentDataProperty,X.parentDataProperty],[jw.default.rootData,jw.default.rootData]];if(X.opts.dynamicRef)z.push([jw.default.dynamicAnchors,jw.default.dynamicAnchors]);let O=a._`${D}, ${$.object(...z)}`;return H!==a.nil?a._`${Y}.call(${H}, ${O})`:a._`${Y}(${O})`}kX.callValidateCode=DL;var zL=a._`new RegExp`;function AL({gen:b,it:{opts:w}},$){let W=w.unicodeRegExp?"u":"",{regExp:Q}=w.code,G=Q($,W);return b.scopeValue("pattern",{key:G.toString(),ref:G,code:a._`${Q.code==="new RegExp"?zL:(0,QL.useFunc)(b,Q)}(${$}, ${W})`})}kX.usePattern=AL;function OL(b){let{gen:w,data:$,keyword:W,it:Q}=b,G=w.name("valid");if(Q.allErrors){let Y=w.let("valid",!0);return X(()=>w.assign(Y,!1)),Y}return w.var(G,!0),X(()=>w.break()),G;function X(Y){let H=w.const("len",a._`${$}.length`);w.forRange("i",0,H,(J)=>{b.subschema({keyword:W,dataProp:J,dataPropType:P6.Type.Num},G),w.if((0,a.not)(G),Y)})}}kX.validateArray=OL;function qL(b){let{gen:w,schema:$,keyword:W,it:Q}=b;if(!Array.isArray($))throw Error("ajv implementation error");if($.some((H)=>(0,P6.alwaysValidSchema)(Q,H))&&!Q.opts.unevaluated)return;let X=w.let("valid",!1),Y=w.name("_valid");w.block(()=>$.forEach((H,J)=>{let D=b.subschema({keyword:W,schemaProp:J,compositeRule:!0},Y);if(w.assign(X,a._`${X} || ${Y}`),!b.mergeValidEvaluated(D,Y))w.if((0,a.not)(X))})),b.result(X,()=>b.reset(),()=>b.error(!0))}kX.validateUnion=qL});var hX=I((uX)=>{Object.defineProperty(uX,"__esModule",{value:!0});uX.validateKeywordUsage=uX.validSchemaType=uX.funcKeywordCode=uX.macroKeywordCode=void 0;var Fb=u(),vw=Qw(),EL=vb(),TL=c1();function _L(b,w){let{gen:$,keyword:W,schema:Q,parentSchema:G,it:X}=b,Y=w.macro.call(X.self,Q,G,X),H=xX($,W,Y);if(X.opts.validateSchema!==!1)X.self.validateSchema(Y,!0);let J=$.name("valid");b.subschema({schema:Y,schemaPath:Fb.nil,errSchemaPath:`${X.errSchemaPath}/${W}`,topSchemaRef:H,compositeRule:!0},J),b.pass(J,()=>b.error(!0))}uX.macroKeywordCode=_L;function SL(b,w){var $;let{gen:W,keyword:Q,schema:G,parentSchema:X,$data:Y,it:H}=b;kL(H,w);let J=!Y&&w.compile?w.compile.call(H.self,G,X,H):w.validate,D=xX(W,Q,J),z=W.let("valid");b.block$data(z,O),b.ok(($=w.valid)!==null&&$!==void 0?$:z);function O(){if(w.errors===!1){if(K(),w.modifying)CX(b);Z(()=>b.error())}else{let M=w.async?q():B();if(w.modifying)CX(b);Z(()=>RL(b,M))}}function q(){let M=W.let("ruleErrs",null);return W.try(()=>K(Fb._`await `),(k)=>W.assign(z,!1).if(Fb._`${k} instanceof ${H.ValidationError}`,()=>W.assign(M,Fb._`${k}.errors`),()=>W.throw(k))),M}function B(){let M=Fb._`${D}.errors`;return W.assign(M,null),K(Fb.nil),M}function K(M=w.async?Fb._`await `:Fb.nil){let k=H.opts.passContext?vw.default.this:vw.default.self,S=!(("compile"in w)&&!Y||w.schema===!1);W.assign(z,Fb._`${M}${(0,EL.callValidateCode)(b,D,k,S)}`,w.modifying)}function Z(M){var k;W.if((0,Fb.not)((k=w.valid)!==null&&k!==void 0?k:z),M)}}uX.funcKeywordCode=SL;function CX(b){let{gen:w,data:$,it:W}=b;w.if(W.parentData,()=>w.assign($,Fb._`${W.parentData}[${W.parentDataProperty}]`))}function RL(b,w){let{gen:$}=b;$.if(Fb._`Array.isArray(${w})`,()=>{$.assign(vw.default.vErrors,Fb._`${vw.default.vErrors} === null ? ${w} : ${vw.default.vErrors}.concat(${w})`).assign(vw.default.errors,Fb._`${vw.default.vErrors}.length`),(0,TL.extendErrors)(b)},()=>b.error())}function kL({schemaEnv:b},w){if(w.async&&!b.$async)throw Error("async keyword in sync schema")}function xX(b,w,$){if($===void 0)throw Error(`keyword "${w}" failed to compile`);return b.scopeValue("keyword",typeof $=="function"?{ref:$}:{ref:$,code:(0,Fb.stringify)($)})}function vL(b,w,$=!1){return!w.length||w.some((W)=>W==="array"?Array.isArray(b):W==="object"?b&&typeof b=="object"&&!Array.isArray(b):typeof b==W||$&&typeof b>"u")}uX.validSchemaType=vL;function CL({schema:b,opts:w,self:$,errSchemaPath:W},Q,G){if(Array.isArray(Q.keyword)?!Q.keyword.includes(G):Q.keyword!==G)throw Error("ajv implementation error");let X=Q.dependencies;if(X===null||X===void 0?void 0:X.some((Y)=>!Object.prototype.hasOwnProperty.call(b,Y)))throw Error(`parent schema must have dependencies of ${G}: ${X.join(",")}`);if(Q.validateSchema){if(!Q.validateSchema(b[G])){let H=`keyword "${G}" value is invalid at path "${W}": `+$.errorsText(Q.validateSchema.errors);if(w.validateSchema==="log")$.logger.error(H);else throw Error(H)}}}uX.validateKeywordUsage=CL});var mX=I((cX)=>{Object.defineProperty(cX,"__esModule",{value:!0});cX.extendSubschemaMode=cX.extendSubschemaData=cX.getSubschema=void 0;var ob=u(),fX=l();function hL(b,{keyword:w,schemaProp:$,schema:W,schemaPath:Q,errSchemaPath:G,topSchemaRef:X}){if(w!==void 0&&W!==void 0)throw Error('both "keyword" and "schema" passed, only one allowed');if(w!==void 0){let Y=b.schema[w];return $===void 0?{schema:Y,schemaPath:ob._`${b.schemaPath}${(0,ob.getProperty)(w)}`,errSchemaPath:`${b.errSchemaPath}/${w}`}:{schema:Y[$],schemaPath:ob._`${b.schemaPath}${(0,ob.getProperty)(w)}${(0,ob.getProperty)($)}`,errSchemaPath:`${b.errSchemaPath}/${w}/${(0,fX.escapeFragment)($)}`}}if(W!==void 0){if(Q===void 0||G===void 0||X===void 0)throw Error('"schemaPath", "errSchemaPath" and "topSchemaRef" are required with "schema"');return{schema:W,schemaPath:Q,topSchemaRef:X,errSchemaPath:G}}throw Error('either "keyword" or "schema" must be passed')}cX.getSubschema=hL;function fL(b,w,{dataProp:$,dataPropType:W,data:Q,dataTypes:G,propertyName:X}){if(Q!==void 0&&$!==void 0)throw Error('both "data" and "dataProp" passed, only one allowed');let{gen:Y}=w;if($!==void 0){let{errorPath:J,dataPathArr:D,opts:z}=w,O=Y.let("data",ob._`${w.data}${(0,ob.getProperty)($)}`,!0);H(O),b.errorPath=ob.str`${J}${(0,fX.getErrorPath)($,W,z.jsPropertySyntax)}`,b.parentDataProperty=ob._`${$}`,b.dataPathArr=[...D,b.parentDataProperty]}if(Q!==void 0){let J=Q instanceof ob.Name?Q:Y.let("data",Q,!0);if(H(J),X!==void 0)b.propertyName=X}if(G)b.dataTypes=G;function H(J){b.data=J,b.dataLevel=w.dataLevel+1,b.dataTypes=[],w.definedProperties=new Set,b.parentData=w.data,b.dataNames=[...w.dataNames,J]}}cX.extendSubschemaData=fL;function cL(b,{jtdDiscriminator:w,jtdMetadata:$,compositeRule:W,createErrors:Q,allErrors:G}){if(W!==void 0)b.compositeRule=W;if(Q!==void 0)b.createErrors=Q;if(G!==void 0)b.allErrors=G;b.jtdDiscriminator=w,b.jtdMetadata=$}cX.extendSubschemaMode=cL});var j6=I((CE,nX)=>{nX.exports=function b(w,$){if(w===$)return!0;if(w&&$&&typeof w=="object"&&typeof $=="object"){if(w.constructor!==$.constructor)return!1;var W,Q,G;if(Array.isArray(w)){if(W=w.length,W!=$.length)return!1;for(Q=W;Q--!==0;)if(!b(w[Q],$[Q]))return!1;return!0}if(w.constructor===RegExp)return w.source===$.source&&w.flags===$.flags;if(w.valueOf!==Object.prototype.valueOf)return w.valueOf()===$.valueOf();if(w.toString!==Object.prototype.toString)return w.toString()===$.toString();if(G=Object.keys(w),W=G.length,W!==Object.keys($).length)return!1;for(Q=W;Q--!==0;)if(!Object.prototype.hasOwnProperty.call($,G[Q]))return!1;for(Q=W;Q--!==0;){var X=G[Q];if(!b(w[X],$[X]))return!1}return!0}return w!==w&&$!==$}});var iX=I((xE,lX)=>{var Iw=lX.exports=function(b,w,$){if(typeof w=="function")$=w,w={};$=w.cb||$;var W=typeof $=="function"?$:$.pre||function(){},Q=$.post||function(){};X$(w,W,Q,b,"",b)};Iw.keywords={additionalItems:!0,items:!0,contains:!0,additionalProperties:!0,propertyNames:!0,not:!0,if:!0,then:!0,else:!0};Iw.arrayKeywords={items:!0,allOf:!0,anyOf:!0,oneOf:!0};Iw.propsKeywords={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependencies:!0};Iw.skipKeywords={default:!0,enum:!0,const:!0,required:!0,maximum:!0,minimum:!0,exclusiveMaximum:!0,exclusiveMinimum:!0,multipleOf:!0,maxLength:!0,minLength:!0,pattern:!0,format:!0,maxItems:!0,minItems:!0,uniqueItems:!0,maxProperties:!0,minProperties:!0};function X$(b,w,$,W,Q,G,X,Y,H,J){if(W&&typeof W=="object"&&!Array.isArray(W)){w(W,Q,G,X,Y,H,J);for(var D in W){var z=W[D];if(Array.isArray(z)){if(D in Iw.arrayKeywords)for(var O=0;O<z.length;O++)X$(b,w,$,z[O],Q+"/"+D+"/"+O,G,Q,D,W,O)}else if(D in Iw.propsKeywords){if(z&&typeof z=="object")for(var q in z)X$(b,w,$,z[q],Q+"/"+D+"/"+nL(q),G,Q,D,W,q)}else if(D in Iw.keywords||b.allKeys&&!(D in Iw.skipKeywords))X$(b,w,$,z,Q+"/"+D,G,Q,D,W)}$(W,Q,G,X,Y,H,J)}}function nL(b){return b.replace(/~/g,"~0").replace(/\//g,"~1")}});var m1=I((tX)=>{Object.defineProperty(tX,"__esModule",{value:!0});tX.getSchemaRefs=tX.resolveUrl=tX.normalizeId=tX._getFullPath=tX.getFullPath=tX.inlineRef=void 0;var lL=l(),iL=j6(),pL=iX(),oL=new Set(["type","format","pattern","maxLength","minLength","maxProperties","minProperties","maxItems","minItems","maximum","minimum","uniqueItems","multipleOf","required","enum","const"]);function dL(b,w=!0){if(typeof b=="boolean")return!0;if(w===!0)return!I6(b);if(!w)return!1;return pX(b)<=w}tX.inlineRef=dL;var tL=new Set(["$ref","$recursiveRef","$recursiveAnchor","$dynamicRef","$dynamicAnchor"]);function I6(b){for(let w in b){if(tL.has(w))return!0;let $=b[w];if(Array.isArray($)&&$.some(I6))return!0;if(typeof $=="object"&&I6($))return!0}return!1}function pX(b){let w=0;for(let $ in b){if($==="$ref")return 1/0;if(w++,oL.has($))continue;if(typeof b[$]=="object")(0,lL.eachItem)(b[$],(W)=>w+=pX(W));if(w===1/0)return 1/0}return w}function oX(b,w="",$){if($!==!1)w=ew(w);let W=b.parse(w);return dX(b,W)}tX.getFullPath=oX;function dX(b,w){return b.serialize(w).split("#")[0]+"#"}tX._getFullPath=dX;var rL=/#\/?$/;function ew(b){return b?b.replace(rL,""):""}tX.normalizeId=ew;function eL(b,w,$){return $=ew($),b.resolve(w,$)}tX.resolveUrl=eL;var sL=/^[a-z_][-a-z0-9._]*$/i;function aL(b,w){if(typeof b=="boolean")return{};let{schemaId:$,uriResolver:W}=this.opts,Q=ew(b[$]||w),G={"":Q},X=oX(W,Q,!1),Y={},H=new Set;return pL(b,{allKeys:!0},(z,O,q,B)=>{if(B===void 0)return;let K=X+O,Z=G[B];if(typeof z[$]=="string")Z=M.call(this,z[$]);k.call(this,z.$anchor),k.call(this,z.$dynamicAnchor),G[O]=Z;function M(S){let h=this.opts.uriResolver.resolve;if(S=ew(Z?h(Z,S):S),H.has(S))throw D(S);H.add(S);let R=this.refs[S];if(typeof R=="string")R=this.refs[R];if(typeof R=="object")J(z,R.schema,S);else if(S!==ew(K))if(S[0]==="#")J(z,Y[S],S),Y[S]=z;else this.refs[S]=K;return S}function k(S){if(typeof S=="string"){if(!sL.test(S))throw Error(`invalid anchor "${S}"`);M.call(this,`#${S}`)}}}),Y;function J(z,O,q){if(O!==void 0&&!iL(z,O))throw D(q)}function D(z){return Error(`reference "${z}" resolves to more than one schema`)}}tX.getSchemaRefs=aL});var i1=I((zY)=>{Object.defineProperty(zY,"__esModule",{value:!0});zY.getData=zY.KeywordCxt=zY.validateFunctionCode=void 0;var wY=qX(),eX=g1(),N6=U6(),Y$=g1(),G3=_X(),l1=hX(),V6=mX(),E=u(),v=Qw(),X3=m1(),Gw=l(),n1=c1();function Y3(b){if(QY(b)){if(GY(b),WY(b)){D3(b);return}}$Y(b,()=>(0,wY.topBoolOrEmptySchema)(b))}zY.validateFunctionCode=Y3;function $Y({gen:b,validateName:w,schema:$,schemaEnv:W,opts:Q},G){if(Q.code.es5)b.func(w,E._`${v.default.data}, ${v.default.valCxt}`,W.$async,()=>{b.code(E._`"use strict"; ${sX($,Q)}`),J3(b,Q),b.code(G)});else b.func(w,E._`${v.default.data}, ${H3(Q)}`,W.$async,()=>b.code(sX($,Q)).code(G))}function H3(b){return E._`{${v.default.instancePath}="", ${v.default.parentData}, ${v.default.parentDataProperty}, ${v.default.rootData}=${v.default.data}${b.dynamicRef?E._`, ${v.default.dynamicAnchors}={}`:E.nil}}={}`}function J3(b,w){b.if(v.default.valCxt,()=>{if(b.var(v.default.instancePath,E._`${v.default.valCxt}.${v.default.instancePath}`),b.var(v.default.parentData,E._`${v.default.valCxt}.${v.default.parentData}`),b.var(v.default.parentDataProperty,E._`${v.default.valCxt}.${v.default.parentDataProperty}`),b.var(v.default.rootData,E._`${v.default.valCxt}.${v.default.rootData}`),w.dynamicRef)b.var(v.default.dynamicAnchors,E._`${v.default.valCxt}.${v.default.dynamicAnchors}`)},()=>{if(b.var(v.default.instancePath,E._`""`),b.var(v.default.parentData,E._`undefined`),b.var(v.default.parentDataProperty,E._`undefined`),b.var(v.default.rootData,v.default.data),w.dynamicRef)b.var(v.default.dynamicAnchors,E._`{}`)})}function D3(b){let{schema:w,opts:$,gen:W}=b;$Y(b,()=>{if($.$comment&&w.$comment)YY(b);if(L3(b),W.let(v.default.vErrors,null),W.let(v.default.errors,0),$.unevaluated)z3(b);XY(b),F3(b)});return}function z3(b){let{gen:w,validateName:$}=b;b.evaluated=w.const("evaluated",E._`${$}.evaluated`),w.if(E._`${b.evaluated}.dynamicProps`,()=>w.assign(E._`${b.evaluated}.props`,E._`undefined`)),w.if(E._`${b.evaluated}.dynamicItems`,()=>w.assign(E._`${b.evaluated}.items`,E._`undefined`))}function sX(b,w){let $=typeof b=="object"&&b[w.schemaId];return $&&(w.code.source||w.code.process)?E._`/*# sourceURL=${$} */`:E.nil}function A3(b,w){if(QY(b)){if(GY(b),WY(b)){O3(b,w);return}}(0,wY.boolOrEmptySchema)(b,w)}function WY({schema:b,self:w}){if(typeof b=="boolean")return!b;for(let $ in b)if(w.RULES.all[$])return!0;return!1}function QY(b){return typeof b.schema!="boolean"}function O3(b,w){let{schema:$,gen:W,opts:Q}=b;if(Q.$comment&&$.$comment)YY(b);U3(b),B3(b);let G=W.const("_errs",v.default.errors);XY(b,G),W.var(w,E._`${G} === ${v.default.errors}`)}function GY(b){(0,Gw.checkUnknownRules)(b),q3(b)}function XY(b,w){if(b.opts.jtd)return aX(b,[],!1,w);let $=(0,eX.getSchemaTypes)(b.schema),W=(0,eX.coerceAndCheckDataType)(b,$);aX(b,$,!W,w)}function q3(b){let{schema:w,errSchemaPath:$,opts:W,self:Q}=b;if(w.$ref&&W.ignoreKeywordsWithRef&&(0,Gw.schemaHasRulesButRef)(w,Q.RULES))Q.logger.warn(`$ref: keywords ignored in schema at path "${$}"`)}function L3(b){let{schema:w,opts:$}=b;if(w.default!==void 0&&$.useDefaults&&$.strictSchema)(0,Gw.checkStrictMode)(b,"default is ignored in the schema root")}function U3(b){let w=b.schema[b.opts.schemaId];if(w)b.baseId=(0,X3.resolveUrl)(b.opts.uriResolver,b.baseId,w)}function B3(b){if(b.schema.$async&&!b.schemaEnv.$async)throw Error("async schema in sync schema")}function YY({gen:b,schemaEnv:w,schema:$,errSchemaPath:W,opts:Q}){let G=$.$comment;if(Q.$comment===!0)b.code(E._`${v.default.self}.logger.log(${G})`);else if(typeof Q.$comment=="function"){let X=E.str`${W}/$comment`,Y=b.scopeValue("root",{ref:w.root});b.code(E._`${v.default.self}.opts.$comment(${G}, ${X}, ${Y}.schema)`)}}function F3(b){let{gen:w,schemaEnv:$,validateName:W,ValidationError:Q,opts:G}=b;if($.$async)w.if(E._`${v.default.errors} === 0`,()=>w.return(v.default.data),()=>w.throw(E._`new ${Q}(${v.default.vErrors})`));else{if(w.assign(E._`${W}.errors`,v.default.vErrors),G.unevaluated)K3(b);w.return(E._`${v.default.errors} === 0`)}}function K3({gen:b,evaluated:w,props:$,items:W}){if($ instanceof E.Name)b.assign(E._`${w}.props`,$);if(W instanceof E.Name)b.assign(E._`${w}.items`,W)}function aX(b,w,$,W){let{gen:Q,schema:G,data:X,allErrors:Y,opts:H,self:J}=b,{RULES:D}=J;if(G.$ref&&(H.ignoreKeywordsWithRef||!(0,Gw.schemaHasRulesButRef)(G,D))){Q.block(()=>JY(b,"$ref",D.all.$ref.definition));return}if(!H.jtd)P3(b,w);Q.block(()=>{for(let O of D.rules)z(O);z(D.post)});function z(O){if(!(0,N6.shouldUseGroup)(G,O))return;if(O.type){if(Q.if((0,Y$.checkDataType)(O.type,X,H.strictNumbers)),bY(b,O),w.length===1&&w[0]===O.type&&$)Q.else(),(0,Y$.reportTypeError)(b);Q.endIf()}else bY(b,O);if(!Y)Q.if(E._`${v.default.errors} === ${W||0}`)}}function bY(b,w){let{gen:$,schema:W,opts:{useDefaults:Q}}=b;if(Q)(0,G3.assignDefaults)(b,w.type);$.block(()=>{for(let G of w.rules)if((0,N6.shouldUseRule)(W,G))JY(b,G.keyword,G.definition,w.type)})}function P3(b,w){if(b.schemaEnv.meta||!b.opts.strictTypes)return;if(M3(b,w),!b.opts.allowUnionTypes)Z3(b,w);j3(b,b.dataTypes)}function M3(b,w){if(!w.length)return;if(!b.dataTypes.length){b.dataTypes=w;return}w.forEach(($)=>{if(!HY(b.dataTypes,$))E6(b,`type "${$}" not allowed by context "${b.dataTypes.join(",")}"`)}),V3(b,w)}function Z3(b,w){if(w.length>1&&!(w.length===2&&w.includes("null")))E6(b,"use allowUnionTypes to allow union type keyword")}function j3(b,w){let $=b.self.RULES.all;for(let W in $){let Q=$[W];if(typeof Q=="object"&&(0,N6.shouldUseRule)(b.schema,Q)){let{type:G}=Q.definition;if(G.length&&!G.some((X)=>I3(w,X)))E6(b,`missing type "${G.join(",")}" for keyword "${W}"`)}}}function I3(b,w){return b.includes(w)||w==="number"&&b.includes("integer")}function HY(b,w){return b.includes(w)||w==="integer"&&b.includes("number")}function V3(b,w){let $=[];for(let W of b.dataTypes)if(HY(w,W))$.push(W);else if(w.includes("integer")&&W==="number")$.push("integer");b.dataTypes=$}function E6(b,w){let $=b.schemaEnv.baseId+b.errSchemaPath;w+=` at "${$}" (strictTypes)`,(0,Gw.checkStrictMode)(b,w,b.opts.strictTypes)}class T6{constructor(b,w,$){if((0,l1.validateKeywordUsage)(b,w,$),this.gen=b.gen,this.allErrors=b.allErrors,this.keyword=$,this.data=b.data,this.schema=b.schema[$],this.$data=w.$data&&b.opts.$data&&this.schema&&this.schema.$data,this.schemaValue=(0,Gw.schemaRefOrVal)(b,this.schema,$,this.$data),this.schemaType=w.schemaType,this.parentSchema=b.schema,this.params={},this.it=b,this.def=w,this.$data)this.schemaCode=b.gen.const("vSchema",DY(this.$data,b));else if(this.schemaCode=this.schemaValue,!(0,l1.validSchemaType)(this.schema,w.schemaType,w.allowUndefined))throw Error(`${$} value must be ${JSON.stringify(w.schemaType)}`);if("code"in w?w.trackErrors:w.errors!==!1)this.errsCount=b.gen.const("_errs",v.default.errors)}result(b,w,$){this.failResult((0,E.not)(b),w,$)}failResult(b,w,$){if(this.gen.if(b),$)$();else this.error();if(w){if(this.gen.else(),w(),this.allErrors)this.gen.endIf()}else if(this.allErrors)this.gen.endIf();else this.gen.else()}pass(b,w){this.failResult((0,E.not)(b),void 0,w)}fail(b){if(b===void 0){if(this.error(),!this.allErrors)this.gen.if(!1);return}if(this.gen.if(b),this.error(),this.allErrors)this.gen.endIf();else this.gen.else()}fail$data(b){if(!this.$data)return this.fail(b);let{schemaCode:w}=this;this.fail(E._`${w} !== undefined && (${(0,E.or)(this.invalid$data(),b)})`)}error(b,w,$){if(w){this.setParams(w),this._error(b,$),this.setParams({});return}this._error(b,$)}_error(b,w){(b?n1.reportExtraError:n1.reportError)(this,this.def.error,w)}$dataError(){(0,n1.reportError)(this,this.def.$dataError||n1.keyword$DataError)}reset(){if(this.errsCount===void 0)throw Error('add "trackErrors" to keyword definition');(0,n1.resetErrorsCount)(this.gen,this.errsCount)}ok(b){if(!this.allErrors)this.gen.if(b)}setParams(b,w){if(w)Object.assign(this.params,b);else this.params=b}block$data(b,w,$=E.nil){this.gen.block(()=>{this.check$data(b,$),w()})}check$data(b=E.nil,w=E.nil){if(!this.$data)return;let{gen:$,schemaCode:W,schemaType:Q,def:G}=this;if($.if((0,E.or)(E._`${W} === undefined`,w)),b!==E.nil)$.assign(b,!0);if(Q.length||G.validateSchema){if($.elseIf(this.invalid$data()),this.$dataError(),b!==E.nil)$.assign(b,!1)}$.else()}invalid$data(){let{gen:b,schemaCode:w,schemaType:$,def:W,it:Q}=this;return(0,E.or)(G(),X());function G(){if($.length){if(!(w instanceof E.Name))throw Error("ajv implementation error");let Y=Array.isArray($)?$:[$];return E._`${(0,Y$.checkDataTypes)(Y,w,Q.opts.strictNumbers,Y$.DataType.Wrong)}`}return E.nil}function X(){if(W.validateSchema){let Y=b.scopeValue("validate$data",{ref:W.validateSchema});return E._`!${Y}(${w})`}return E.nil}}subschema(b,w){let $=(0,V6.getSubschema)(this.it,b);(0,V6.extendSubschemaData)($,this.it,b),(0,V6.extendSubschemaMode)($,b);let W={...this.it,...$,items:void 0,props:void 0};return A3(W,w),W}mergeEvaluated(b,w){let{it:$,gen:W}=this;if(!$.opts.unevaluated)return;if($.props!==!0&&b.props!==void 0)$.props=Gw.mergeEvaluated.props(W,b.props,$.props,w);if($.items!==!0&&b.items!==void 0)$.items=Gw.mergeEvaluated.items(W,b.items,$.items,w)}mergeValidEvaluated(b,w){let{it:$,gen:W}=this;if($.opts.unevaluated&&($.props!==!0||$.items!==!0))return W.if(w,()=>this.mergeEvaluated(b,E.Name)),!0}}zY.KeywordCxt=T6;function JY(b,w,$,W){let Q=new T6(b,$,w);if("code"in $)$.code(Q,W);else if(Q.$data&&$.validate)(0,l1.funcKeywordCode)(Q,$);else if("macro"in $)(0,l1.macroKeywordCode)(Q,$);else if($.compile||$.validate)(0,l1.funcKeywordCode)(Q,$)}var N3=/^\/(?:[^~]|~0|~1)*$/,E3=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function DY(b,{dataLevel:w,dataNames:$,dataPathArr:W}){let Q,G;if(b==="")return v.default.rootData;if(b[0]==="/"){if(!N3.test(b))throw Error(`Invalid JSON-pointer: ${b}`);Q=b,G=v.default.rootData}else{let J=E3.exec(b);if(!J)throw Error(`Invalid JSON-pointer: ${b}`);let D=+J[1];if(Q=J[2],Q==="#"){if(D>=w)throw Error(H("property/index",D));return W[w-D]}if(D>w)throw Error(H("data",D));if(G=$[w-D],!Q)return G}let X=G,Y=Q.split("/");for(let J of Y)if(J)G=E._`${G}${(0,E.getProperty)((0,Gw.unescapeJsonPointer)(J))}`,X=E._`${X} && ${G}`;return X;function H(J,D){return`Cannot access ${J} ${D} levels up, current level is ${w}`}}zY.getData=DY});var H$=I((qY)=>{Object.defineProperty(qY,"__esModule",{value:!0});class OY extends Error{constructor(b){super("validation failed");this.errors=b,this.ajv=this.validation=!0}}qY.default=OY});var p1=I((UY)=>{Object.defineProperty(UY,"__esModule",{value:!0});var _6=m1();class LY extends Error{constructor(b,w,$,W){super(W||`can't resolve reference ${$} from id ${w}`);this.missingRef=(0,_6.resolveUrl)(b,w,$),this.missingSchema=(0,_6.normalizeId)((0,_6.getFullPath)(b,this.missingRef))}}UY.default=LY});var D$=I((KY)=>{Object.defineProperty(KY,"__esModule",{value:!0});KY.resolveSchema=KY.getCompilingSchema=KY.resolveRef=KY.compileSchema=KY.SchemaEnv=void 0;var fb=u(),k3=H$(),Cw=Qw(),cb=m1(),BY=l(),v3=i1();class o1{constructor(b){var w;this.refs={},this.dynamicAnchors={};let $;if(typeof b.schema=="object")$=b.schema;this.schema=b.schema,this.schemaId=b.schemaId,this.root=b.root||this,this.baseId=(w=b.baseId)!==null&&w!==void 0?w:(0,cb.normalizeId)($===null||$===void 0?void 0:$[b.schemaId||"$id"]),this.schemaPath=b.schemaPath,this.localRefs=b.localRefs,this.meta=b.meta,this.$async=$===null||$===void 0?void 0:$.$async,this.refs={}}}KY.SchemaEnv=o1;function R6(b){let w=FY.call(this,b);if(w)return w;let $=(0,cb.getFullPath)(this.opts.uriResolver,b.root.baseId),{es5:W,lines:Q}=this.opts.code,{ownProperties:G}=this.opts,X=new fb.CodeGen(this.scope,{es5:W,lines:Q,ownProperties:G}),Y;if(b.$async)Y=X.scopeValue("Error",{ref:k3.default,code:fb._`require("ajv/dist/runtime/validation_error").default`});let H=X.scopeName("validate");b.validateName=H;let J={gen:X,allErrors:this.opts.allErrors,data:Cw.default.data,parentData:Cw.default.parentData,parentDataProperty:Cw.default.parentDataProperty,dataNames:[Cw.default.data],dataPathArr:[fb.nil],dataLevel:0,dataTypes:[],definedProperties:new Set,topSchemaRef:X.scopeValue("schema",this.opts.code.source===!0?{ref:b.schema,code:(0,fb.stringify)(b.schema)}:{ref:b.schema}),validateName:H,ValidationError:Y,schema:b.schema,schemaEnv:b,rootId:$,baseId:b.baseId||$,schemaPath:fb.nil,errSchemaPath:b.schemaPath||(this.opts.jtd?"":"#"),errorPath:fb._`""`,opts:this.opts,self:this},D;try{this._compilations.add(b),(0,v3.validateFunctionCode)(J),X.optimize(this.opts.code.optimize);let z=X.toString();if(D=`${X.scopeRefs(Cw.default.scope)}return ${z}`,this.opts.code.process)D=this.opts.code.process(D,b);let q=Function(`${Cw.default.self}`,`${Cw.default.scope}`,D)(this,this.scope.get());if(this.scope.value(H,{ref:q}),q.errors=null,q.schema=b.schema,q.schemaEnv=b,b.$async)q.$async=!0;if(this.opts.code.source===!0)q.source={validateName:H,validateCode:z,scopeValues:X._values};if(this.opts.unevaluated){let{props:B,items:K}=J;if(q.evaluated={props:B instanceof fb.Name?void 0:B,items:K instanceof fb.Name?void 0:K,dynamicProps:B instanceof fb.Name,dynamicItems:K instanceof fb.Name},q.source)q.source.evaluated=(0,fb.stringify)(q.evaluated)}return b.validate=q,b}catch(z){if(delete b.validate,delete b.validateName,D)this.logger.error("Error compiling schema, function code:",D);throw z}finally{this._compilations.delete(b)}}KY.compileSchema=R6;function C3(b,w,$){var W;$=(0,cb.resolveUrl)(this.opts.uriResolver,w,$);let Q=b.refs[$];if(Q)return Q;let G=y3.call(this,b,$);if(G===void 0){let X=(W=b.localRefs)===null||W===void 0?void 0:W[$],{schemaId:Y}=this.opts;if(X)G=new o1({schema:X,schemaId:Y,root:b,baseId:w})}if(G===void 0)return;return b.refs[$]=x3.call(this,G)}KY.resolveRef=C3;function x3(b){if((0,cb.inlineRef)(b.schema,this.opts.inlineRefs))return b.schema;return b.validate?b:R6.call(this,b)}function FY(b){for(let w of this._compilations)if(u3(w,b))return w}KY.getCompilingSchema=FY;function u3(b,w){return b.schema===w.schema&&b.root===w.root&&b.baseId===w.baseId}function y3(b,w){let $;while(typeof($=this.refs[w])=="string")w=$;return $||this.schemas[w]||J$.call(this,b,w)}function J$(b,w){let $=this.opts.uriResolver.parse(w),W=(0,cb._getFullPath)(this.opts.uriResolver,$),Q=(0,cb.getFullPath)(this.opts.uriResolver,b.baseId,void 0);if(Object.keys(b.schema).length>0&&W===Q)return S6.call(this,$,b);let G=(0,cb.normalizeId)(W),X=this.refs[G]||this.schemas[G];if(typeof X=="string"){let Y=J$.call(this,b,X);if(typeof(Y===null||Y===void 0?void 0:Y.schema)!=="object")return;return S6.call(this,$,Y)}if(typeof(X===null||X===void 0?void 0:X.schema)!=="object")return;if(!X.validate)R6.call(this,X);if(G===(0,cb.normalizeId)(w)){let{schema:Y}=X,{schemaId:H}=this.opts,J=Y[H];if(J)Q=(0,cb.resolveUrl)(this.opts.uriResolver,Q,J);return new o1({schema:Y,schemaId:H,root:b,baseId:Q})}return S6.call(this,$,X)}KY.resolveSchema=J$;var h3=new Set(["properties","patternProperties","enum","dependencies","definitions"]);function S6(b,{baseId:w,schema:$,root:W}){var Q;if(((Q=b.fragment)===null||Q===void 0?void 0:Q[0])!=="/")return;for(let Y of b.fragment.slice(1).split("/")){if(typeof $==="boolean")return;let H=$[(0,BY.unescapeFragment)(Y)];if(H===void 0)return;$=H;let J=typeof $==="object"&&$[this.opts.schemaId];if(!h3.has(Y)&&J)w=(0,cb.resolveUrl)(this.opts.uriResolver,w,J)}let G;if(typeof $!="boolean"&&$.$ref&&!(0,BY.schemaHasRulesButRef)($,this.RULES)){let Y=(0,cb.resolveUrl)(this.opts.uriResolver,w,$.$ref);G=J$.call(this,W,Y)}let{schemaId:X}=this.opts;if(G=G||new o1({schema:$,schemaId:X,root:W,baseId:w}),G.schema!==G.root.schema)return G;return}});var MY=I((gE,n3)=>{n3.exports={$id:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#",description:"Meta-schema for $data reference (JSON AnySchema extension proposal)",type:"object",required:["$data"],properties:{$data:{type:"string",anyOf:[{format:"relative-json-pointer"},{format:"json-pointer"}]}},additionalProperties:!1}});var v6=I((mE,VY)=>{var l3=RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu),jY=RegExp.prototype.test.bind(/^(?:(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)$/u);function k6(b){let w="",$=0,W=0;for(W=0;W<b.length;W++){if($=b[W].charCodeAt(0),$===48)continue;if(!($>=48&&$<=57||$>=65&&$<=70||$>=97&&$<=102))return"";w+=b[W];break}for(W+=1;W<b.length;W++){if($=b[W].charCodeAt(0),!($>=48&&$<=57||$>=65&&$<=70||$>=97&&$<=102))return"";w+=b[W]}return w}var i3=RegExp.prototype.test.bind(/[^!"$&'()*+,\-.;=_`a-z{}~]/u);function ZY(b){return b.length=0,!0}function p3(b,w,$){if(b.length){let W=k6(b);if(W!=="")w.push(W);else return $.error=!0,!1;b.length=0}return!0}function o3(b){let w=0,$={error:!1,address:"",zone:""},W=[],Q=[],G=!1,X=!1,Y=p3;for(let H=0;H<b.length;H++){let J=b[H];if(J==="["||J==="]")continue;if(J===":"){if(G===!0)X=!0;if(!Y(Q,W,$))break;if(++w>7){$.error=!0;break}if(H>0&&b[H-1]===":")G=!0;W.push(":");continue}else if(J==="%"){if(!Y(Q,W,$))break;Y=ZY}else{Q.push(J);continue}}if(Q.length)if(Y===ZY)$.zone=Q.join("");else if(X)W.push(Q.join(""));else W.push(k6(Q));return $.address=W.join(""),$}function IY(b){if(d3(b,":")<2)return{host:b,isIPV6:!1};let w=o3(b);if(!w.error){let{address:$,address:W}=w;if(w.zone)$+="%"+w.zone,W+="%25"+w.zone;return{host:$,isIPV6:!0,escapedHost:W}}else return{host:b,isIPV6:!1}}function d3(b,w){let $=0;for(let W=0;W<b.length;W++)if(b[W]===w)$++;return $}function t3(b){let w=b,$=[],W=-1,Q=0;while(Q=w.length){if(Q===1)if(w===".")break;else if(w==="/"){$.push("/");break}else{$.push(w);break}else if(Q===2){if(w[0]==="."){if(w[1]===".")break;else if(w[1]==="/"){w=w.slice(2);continue}}else if(w[0]==="/"){if(w[1]==="."||w[1]==="/"){$.push("/");break}}}else if(Q===3){if(w==="/.."){if($.length!==0)$.pop();$.push("/");break}}if(w[0]==="."){if(w[1]==="."){if(w[2]==="/"){w=w.slice(3);continue}}else if(w[1]==="/"){w=w.slice(2);continue}}else if(w[0]==="/"){if(w[1]==="."){if(w[2]==="/"){w=w.slice(2);continue}else if(w[2]==="."){if(w[3]==="/"){if(w=w.slice(3),$.length!==0)$.pop();continue}}}}if((W=w.indexOf("/",1))===-1){$.push(w);break}else $.push(w.slice(0,W)),w=w.slice(W)}return $.join("")}function r3(b,w){let $=w!==!0?escape:unescape;if(b.scheme!==void 0)b.scheme=$(b.scheme);if(b.userinfo!==void 0)b.userinfo=$(b.userinfo);if(b.host!==void 0)b.host=$(b.host);if(b.path!==void 0)b.path=$(b.path);if(b.query!==void 0)b.query=$(b.query);if(b.fragment!==void 0)b.fragment=$(b.fragment);return b}function e3(b){let w=[];if(b.userinfo!==void 0)w.push(b.userinfo),w.push("@");if(b.host!==void 0){let $=unescape(b.host);if(!jY($)){let W=IY($);if(W.isIPV6===!0)$=`[${W.escapedHost}]`;else $=b.host}w.push($)}if(typeof b.port==="number"||typeof b.port==="string")w.push(":"),w.push(String(b.port));return w.length?w.join(""):void 0}VY.exports={nonSimpleDomain:i3,recomposeAuthority:e3,normalizeComponentEncoding:r3,removeDotSegments:t3,isIPv4:jY,isUUID:l3,normalizeIPv6:IY,stringArrayToHexStripped:k6}});var SY=I((nE,_Y)=>{var{isUUID:s3}=v6(),a3=/([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-.:;=@]|%[\da-f]{2})+)/iu,bU=["http","https","ws","wss","urn","urn:uuid"];function wU(b){return bU.indexOf(b)!==-1}function C6(b){if(b.secure===!0)return!0;else if(b.secure===!1)return!1;else if(b.scheme)return b.scheme.length===3&&(b.scheme[0]==="w"||b.scheme[0]==="W")&&(b.scheme[1]==="s"||b.scheme[1]==="S")&&(b.scheme[2]==="s"||b.scheme[2]==="S");else return!1}function NY(b){if(!b.host)b.error=b.error||"HTTP URIs must have a host.";return b}function EY(b){let w=String(b.scheme).toLowerCase()==="https";if(b.port===(w?443:80)||b.port==="")b.port=void 0;if(!b.path)b.path="/";return b}function $U(b){return b.secure=C6(b),b.resourceName=(b.path||"/")+(b.query?"?"+b.query:""),b.path=void 0,b.query=void 0,b}function WU(b){if(b.port===(C6(b)?443:80)||b.port==="")b.port=void 0;if(typeof b.secure==="boolean")b.scheme=b.secure?"wss":"ws",b.secure=void 0;if(b.resourceName){let[w,$]=b.resourceName.split("?");b.path=w&&w!=="/"?w:void 0,b.query=$,b.resourceName=void 0}return b.fragment=void 0,b}function QU(b,w){if(!b.path)return b.error="URN can not be parsed",b;let $=b.path.match(a3);if($){let W=w.scheme||b.scheme||"urn";b.nid=$[1].toLowerCase(),b.nss=$[2];let Q=`${W}:${w.nid||b.nid}`,G=x6(Q);if(b.path=void 0,G)b=G.parse(b,w)}else b.error=b.error||"URN can not be parsed.";return b}function GU(b,w){if(b.nid===void 0)throw Error("URN without nid cannot be serialized");let $=w.scheme||b.scheme||"urn",W=b.nid.toLowerCase(),Q=`${$}:${w.nid||W}`,G=x6(Q);if(G)b=G.serialize(b,w);let X=b,Y=b.nss;return X.path=`${W||w.nid}:${Y}`,w.skipEscape=!0,X}function XU(b,w){let $=b;if($.uuid=$.nss,$.nss=void 0,!w.tolerant&&(!$.uuid||!s3($.uuid)))$.error=$.error||"UUID is not valid.";return $}function YU(b){let w=b;return w.nss=(b.uuid||"").toLowerCase(),w}var TY={scheme:"http",domainHost:!0,parse:NY,serialize:EY},HU={scheme:"https",domainHost:TY.domainHost,parse:NY,serialize:EY},z$={scheme:"ws",domainHost:!0,parse:$U,serialize:WU},JU={scheme:"wss",domainHost:z$.domainHost,parse:z$.parse,serialize:z$.serialize},DU={scheme:"urn",parse:QU,serialize:GU,skipNormalize:!0},zU={scheme:"urn:uuid",parse:XU,serialize:YU,skipNormalize:!0},A$={http:TY,https:HU,ws:z$,wss:JU,urn:DU,"urn:uuid":zU};Object.setPrototypeOf(A$,null);function x6(b){return b&&(A$[b]||A$[b.toLowerCase()])||void 0}_Y.exports={wsIsSecure:C6,SCHEMES:A$,isValidSchemeName:wU,getSchemeHandler:x6}});var vY=I((lE,q$)=>{var{normalizeIPv6:AU,removeDotSegments:d1,recomposeAuthority:OU,normalizeComponentEncoding:O$,isIPv4:qU,nonSimpleDomain:LU}=v6(),{SCHEMES:UU,getSchemeHandler:RY}=SY();function BU(b,w){if(typeof b==="string")b=db(Xw(b,w),w);else if(typeof b==="object")b=Xw(db(b,w),w);return b}function FU(b,w,$){let W=$?Object.assign({scheme:"null"},$):{scheme:"null"},Q=kY(Xw(b,W),Xw(w,W),W,!0);return W.skipEscape=!0,db(Q,W)}function kY(b,w,$,W){let Q={};if(!W)b=Xw(db(b,$),$),w=Xw(db(w,$),$);if($=$||{},!$.tolerant&&w.scheme)Q.scheme=w.scheme,Q.userinfo=w.userinfo,Q.host=w.host,Q.port=w.port,Q.path=d1(w.path||""),Q.query=w.query;else{if(w.userinfo!==void 0||w.host!==void 0||w.port!==void 0)Q.userinfo=w.userinfo,Q.host=w.host,Q.port=w.port,Q.path=d1(w.path||""),Q.query=w.query;else{if(!w.path)if(Q.path=b.path,w.query!==void 0)Q.query=w.query;else Q.query=b.query;else{if(w.path[0]==="/")Q.path=d1(w.path);else{if((b.userinfo!==void 0||b.host!==void 0||b.port!==void 0)&&!b.path)Q.path="/"+w.path;else if(!b.path)Q.path=w.path;else Q.path=b.path.slice(0,b.path.lastIndexOf("/")+1)+w.path;Q.path=d1(Q.path)}Q.query=w.query}Q.userinfo=b.userinfo,Q.host=b.host,Q.port=b.port}Q.scheme=b.scheme}return Q.fragment=w.fragment,Q}function KU(b,w,$){if(typeof b==="string")b=unescape(b),b=db(O$(Xw(b,$),!0),{...$,skipEscape:!0});else if(typeof b==="object")b=db(O$(b,!0),{...$,skipEscape:!0});if(typeof w==="string")w=unescape(w),w=db(O$(Xw(w,$),!0),{...$,skipEscape:!0});else if(typeof w==="object")w=db(O$(w,!0),{...$,skipEscape:!0});return b.toLowerCase()===w.toLowerCase()}function db(b,w){let $={host:b.host,scheme:b.scheme,userinfo:b.userinfo,port:b.port,path:b.path,query:b.query,nid:b.nid,nss:b.nss,uuid:b.uuid,fragment:b.fragment,reference:b.reference,resourceName:b.resourceName,secure:b.secure,error:""},W=Object.assign({},w),Q=[],G=RY(W.scheme||$.scheme);if(G&&G.serialize)G.serialize($,W);if($.path!==void 0)if(!W.skipEscape){if($.path=escape($.path),$.scheme!==void 0)$.path=$.path.split("%3A").join(":")}else $.path=unescape($.path);if(W.reference!=="suffix"&&$.scheme)Q.push($.scheme,":");let X=OU($);if(X!==void 0){if(W.reference!=="suffix")Q.push("//");if(Q.push(X),$.path&&$.path[0]!=="/")Q.push("/")}if($.path!==void 0){let Y=$.path;if(!W.absolutePath&&(!G||!G.absolutePath))Y=d1(Y);if(X===void 0&&Y[0]==="/"&&Y[1]==="/")Y="/%2F"+Y.slice(2);Q.push(Y)}if($.query!==void 0)Q.push("?",$.query);if($.fragment!==void 0)Q.push("#",$.fragment);return Q.join("")}var PU=/^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u;function Xw(b,w){let $=Object.assign({},w),W={scheme:void 0,userinfo:void 0,host:"",port:void 0,path:"",query:void 0,fragment:void 0},Q=!1;if($.reference==="suffix")if($.scheme)b=$.scheme+":"+b;else b="//"+b;let G=b.match(PU);if(G){if(W.scheme=G[1],W.userinfo=G[3],W.host=G[4],W.port=parseInt(G[5],10),W.path=G[6]||"",W.query=G[7],W.fragment=G[8],isNaN(W.port))W.port=G[5];if(W.host)if(qU(W.host)===!1){let H=AU(W.host);W.host=H.host.toLowerCase(),Q=H.isIPV6}else Q=!0;if(W.scheme===void 0&&W.userinfo===void 0&&W.host===void 0&&W.port===void 0&&W.query===void 0&&!W.path)W.reference="same-document";else if(W.scheme===void 0)W.reference="relative";else if(W.fragment===void 0)W.reference="absolute";else W.reference="uri";if($.reference&&$.reference!=="suffix"&&$.reference!==W.reference)W.error=W.error||"URI is not a "+$.reference+" reference.";let X=RY($.scheme||W.scheme);if(!$.unicodeSupport&&(!X||!X.unicodeSupport)){if(W.host&&($.domainHost||X&&X.domainHost)&&Q===!1&&LU(W.host))try{W.host=URL.domainToASCII(W.host.toLowerCase())}catch(Y){W.error=W.error||"Host's domain name can not be converted to ASCII: "+Y}}if(!X||X&&!X.skipNormalize){if(b.indexOf("%")!==-1){if(W.scheme!==void 0)W.scheme=unescape(W.scheme);if(W.host!==void 0)W.host=unescape(W.host)}if(W.path)W.path=escape(unescape(W.path));if(W.fragment)W.fragment=encodeURI(decodeURIComponent(W.fragment))}if(X&&X.parse)X.parse(W,$)}else W.error=W.error||"URI can not be parsed.";return W}var u6={SCHEMES:UU,normalize:BU,resolve:FU,resolveComponent:kY,equal:KU,serialize:db,parse:Xw};q$.exports=u6;q$.exports.default=u6;q$.exports.fastUri=u6});var uY=I((xY)=>{Object.defineProperty(xY,"__esModule",{value:!0});var CY=vY();CY.code='require("ajv/dist/runtime/uri").default';xY.default=CY});var lY=I((Yw)=>{Object.defineProperty(Yw,"__esModule",{value:!0});Yw.CodeGen=Yw.Name=Yw.nil=Yw.stringify=Yw.str=Yw._=Yw.KeywordCxt=void 0;var ZU=i1();Object.defineProperty(Yw,"KeywordCxt",{enumerable:!0,get:function(){return ZU.KeywordCxt}});var sw=u();Object.defineProperty(Yw,"_",{enumerable:!0,get:function(){return sw._}});Object.defineProperty(Yw,"str",{enumerable:!0,get:function(){return sw.str}});Object.defineProperty(Yw,"stringify",{enumerable:!0,get:function(){return sw.stringify}});Object.defineProperty(Yw,"nil",{enumerable:!0,get:function(){return sw.nil}});Object.defineProperty(Yw,"Name",{enumerable:!0,get:function(){return sw.Name}});Object.defineProperty(Yw,"CodeGen",{enumerable:!0,get:function(){return sw.CodeGen}});var jU=H$(),gY=p1(),IU=L6(),t1=D$(),VU=u(),r1=m1(),L$=g1(),h6=l(),yY=MY(),NU=uY(),mY=(b,w)=>new RegExp(b,w);mY.code="new RegExp";var EU=["removeAdditional","useDefaults","coerceTypes"],TU=new Set(["validate","serialize","parse","wrapper","root","schema","keyword","pattern","formats","validate$data","func","obj","Error"]),_U={errorDataPath:"",format:"`validateFormats: false` can be used instead.",nullable:'"nullable" keyword is supported by default.',jsonPointers:"Deprecated jsPropertySyntax can be used instead.",extendRefs:"Deprecated ignoreKeywordsWithRef can be used instead.",missingRefs:"Pass empty schema with $id that should be ignored to ajv.addSchema.",processCode:"Use option `code: {process: (code, schemaEnv: object) => string}`",sourceCode:"Use option `code: {source: true}`",strictDefaults:"It is default now, see option `strict`.",strictKeywords:"It is default now, see option `strict`.",uniqueItems:'"uniqueItems" keyword is always validated.',unknownFormats:"Disable strict mode or pass `true` to `ajv.addFormat` (or `formats` option).",cache:"Map is used as cache, schema object as key.",serialize:"Map is used as cache, schema object as key.",ajvErrors:"It is default now."},SU={ignoreKeywordsWithRef:"",jsPropertySyntax:"",unicode:'"minLength"/"maxLength" account for unicode characters by default.'},hY=200;function RU(b){var w,$,W,Q,G,X,Y,H,J,D,z,O,q,B,K,Z,M,k,S,h,R,ib,sb,i$,p$;let D1=b.strict,o$=(w=b.code)===null||w===void 0?void 0:w.optimize,TW=o$===!0||o$===void 0?1:o$||0,_W=(W=($=b.code)===null||$===void 0?void 0:$.regExp)!==null&&W!==void 0?W:mY,_z=(Q=b.uriResolver)!==null&&Q!==void 0?Q:NU.default;return{strictSchema:(X=(G=b.strictSchema)!==null&&G!==void 0?G:D1)!==null&&X!==void 0?X:!0,strictNumbers:(H=(Y=b.strictNumbers)!==null&&Y!==void 0?Y:D1)!==null&&H!==void 0?H:!0,strictTypes:(D=(J=b.strictTypes)!==null&&J!==void 0?J:D1)!==null&&D!==void 0?D:"log",strictTuples:(O=(z=b.strictTuples)!==null&&z!==void 0?z:D1)!==null&&O!==void 0?O:"log",strictRequired:(B=(q=b.strictRequired)!==null&&q!==void 0?q:D1)!==null&&B!==void 0?B:!1,code:b.code?{...b.code,optimize:TW,regExp:_W}:{optimize:TW,regExp:_W},loopRequired:(K=b.loopRequired)!==null&&K!==void 0?K:hY,loopEnum:(Z=b.loopEnum)!==null&&Z!==void 0?Z:hY,meta:(M=b.meta)!==null&&M!==void 0?M:!0,messages:(k=b.messages)!==null&&k!==void 0?k:!0,inlineRefs:(S=b.inlineRefs)!==null&&S!==void 0?S:!0,schemaId:(h=b.schemaId)!==null&&h!==void 0?h:"$id",addUsedSchema:(R=b.addUsedSchema)!==null&&R!==void 0?R:!0,validateSchema:(ib=b.validateSchema)!==null&&ib!==void 0?ib:!0,validateFormats:(sb=b.validateFormats)!==null&&sb!==void 0?sb:!0,unicodeRegExp:(i$=b.unicodeRegExp)!==null&&i$!==void 0?i$:!0,int32range:(p$=b.int32range)!==null&&p$!==void 0?p$:!0,uriResolver:_z}}class U${constructor(b={}){this.schemas={},this.refs={},this.formats={},this._compilations=new Set,this._loading={},this._cache=new Map,b=this.opts={...b,...RU(b)};let{es5:w,lines:$}=this.opts.code;this.scope=new VU.ValueScope({scope:{},prefixes:TU,es5:w,lines:$}),this.logger=yU(b.logger);let W=b.validateFormats;if(b.validateFormats=!1,this.RULES=(0,IU.getRules)(),fY.call(this,_U,b,"NOT SUPPORTED"),fY.call(this,SU,b,"DEPRECATED","warn"),this._metaOpts=xU.call(this),b.formats)vU.call(this);if(this._addVocabularies(),this._addDefaultMetaSchema(),b.keywords)CU.call(this,b.keywords);if(typeof b.meta=="object")this.addMetaSchema(b.meta);kU.call(this),b.validateFormats=W}_addVocabularies(){this.addKeyword("$async")}_addDefaultMetaSchema(){let{$data:b,meta:w,schemaId:$}=this.opts,W=yY;if($==="id")W={...yY},W.id=W.$id,delete W.$id;if(w&&b)this.addMetaSchema(W,W[$],!1)}defaultMeta(){let{meta:b,schemaId:w}=this.opts;return this.opts.defaultMeta=typeof b=="object"?b[w]||b:void 0}validate(b,w){let $;if(typeof b=="string"){if($=this.getSchema(b),!$)throw Error(`no schema with key or ref "${b}"`)}else $=this.compile(b);let W=$(w);if(!("$async"in $))this.errors=$.errors;return W}compile(b,w){let $=this._addSchema(b,w);return $.validate||this._compileSchemaEnv($)}compileAsync(b,w){if(typeof this.opts.loadSchema!="function")throw Error("options.loadSchema should be a function");let{loadSchema:$}=this.opts;return W.call(this,b,w);async function W(J,D){await Q.call(this,J.$schema);let z=this._addSchema(J,D);return z.validate||G.call(this,z)}async function Q(J){if(J&&!this.getSchema(J))await W.call(this,{$ref:J},!0)}async function G(J){try{return this._compileSchemaEnv(J)}catch(D){if(!(D instanceof gY.default))throw D;return X.call(this,D),await Y.call(this,D.missingSchema),G.call(this,J)}}function X({missingSchema:J,missingRef:D}){if(this.refs[J])throw Error(`AnySchema ${J} is loaded but ${D} cannot be resolved`)}async function Y(J){let D=await H.call(this,J);if(!this.refs[J])await Q.call(this,D.$schema);if(!this.refs[J])this.addSchema(D,J,w)}async function H(J){let D=this._loading[J];if(D)return D;try{return await(this._loading[J]=$(J))}finally{delete this._loading[J]}}}addSchema(b,w,$,W=this.opts.validateSchema){if(Array.isArray(b)){for(let G of b)this.addSchema(G,void 0,$,W);return this}let Q;if(typeof b==="object"){let{schemaId:G}=this.opts;if(Q=b[G],Q!==void 0&&typeof Q!="string")throw Error(`schema ${G} must be string`)}return w=(0,r1.normalizeId)(w||Q),this._checkUnique(w),this.schemas[w]=this._addSchema(b,$,w,W,!0),this}addMetaSchema(b,w,$=this.opts.validateSchema){return this.addSchema(b,w,!0,$),this}validateSchema(b,w){if(typeof b=="boolean")return!0;let $;if($=b.$schema,$!==void 0&&typeof $!="string")throw Error("$schema must be a string");if($=$||this.opts.defaultMeta||this.defaultMeta(),!$)return this.logger.warn("meta-schema not available"),this.errors=null,!0;let W=this.validate($,b);if(!W&&w){let Q="schema is invalid: "+this.errorsText();if(this.opts.validateSchema==="log")this.logger.error(Q);else throw Error(Q)}return W}getSchema(b){let w;while(typeof(w=cY.call(this,b))=="string")b=w;if(w===void 0){let{schemaId:$}=this.opts,W=new t1.SchemaEnv({schema:{},schemaId:$});if(w=t1.resolveSchema.call(this,W,b),!w)return;this.refs[b]=w}return w.validate||this._compileSchemaEnv(w)}removeSchema(b){if(b instanceof RegExp)return this._removeAllSchemas(this.schemas,b),this._removeAllSchemas(this.refs,b),this;switch(typeof b){case"undefined":return this._removeAllSchemas(this.schemas),this._removeAllSchemas(this.refs),this._cache.clear(),this;case"string":{let w=cY.call(this,b);if(typeof w=="object")this._cache.delete(w.schema);return delete this.schemas[b],delete this.refs[b],this}case"object":{let w=b;this._cache.delete(w);let $=b[this.opts.schemaId];if($)$=(0,r1.normalizeId)($),delete this.schemas[$],delete this.refs[$];return this}default:throw Error("ajv.removeSchema: invalid parameter")}}addVocabulary(b){for(let w of b)this.addKeyword(w);return this}addKeyword(b,w){let $;if(typeof b=="string"){if($=b,typeof w=="object")this.logger.warn("these parameters are deprecated, see docs for addKeyword"),w.keyword=$}else if(typeof b=="object"&&w===void 0){if(w=b,$=w.keyword,Array.isArray($)&&!$.length)throw Error("addKeywords: keyword must be string or non-empty array")}else throw Error("invalid addKeywords parameters");if(fU.call(this,$,w),!w)return(0,h6.eachItem)($,(Q)=>y6.call(this,Q)),this;gU.call(this,w);let W={...w,type:(0,L$.getJSONTypes)(w.type),schemaType:(0,L$.getJSONTypes)(w.schemaType)};return(0,h6.eachItem)($,W.type.length===0?(Q)=>y6.call(this,Q,W):(Q)=>W.type.forEach((G)=>y6.call(this,Q,W,G))),this}getKeyword(b){let w=this.RULES.all[b];return typeof w=="object"?w.definition:!!w}removeKeyword(b){let{RULES:w}=this;delete w.keywords[b],delete w.all[b];for(let $ of w.rules){let W=$.rules.findIndex((Q)=>Q.keyword===b);if(W>=0)$.rules.splice(W,1)}return this}addFormat(b,w){if(typeof w=="string")w=new RegExp(w);return this.formats[b]=w,this}errorsText(b=this.errors,{separator:w=", ",dataVar:$="data"}={}){if(!b||b.length===0)return"No errors";return b.map((W)=>`${$}${W.instancePath} ${W.message}`).reduce((W,Q)=>W+w+Q)}$dataMetaSchema(b,w){let $=this.RULES.all;b=JSON.parse(JSON.stringify(b));for(let W of w){let Q=W.split("/").slice(1),G=b;for(let X of Q)G=G[X];for(let X in $){let Y=$[X];if(typeof Y!="object")continue;let{$data:H}=Y.definition,J=G[X];if(H&&J)G[X]=nY(J)}}return b}_removeAllSchemas(b,w){for(let $ in b){let W=b[$];if(!w||w.test($)){if(typeof W=="string")delete b[$];else if(W&&!W.meta)this._cache.delete(W.schema),delete b[$]}}}_addSchema(b,w,$,W=this.opts.validateSchema,Q=this.opts.addUsedSchema){let G,{schemaId:X}=this.opts;if(typeof b=="object")G=b[X];else if(this.opts.jtd)throw Error("schema must be object");else if(typeof b!="boolean")throw Error("schema must be object or boolean");let Y=this._cache.get(b);if(Y!==void 0)return Y;$=(0,r1.normalizeId)(G||$);let H=r1.getSchemaRefs.call(this,b,$);if(Y=new t1.SchemaEnv({schema:b,schemaId:X,meta:w,baseId:$,localRefs:H}),this._cache.set(Y.schema,Y),Q&&!$.startsWith("#")){if($)this._checkUnique($);this.refs[$]=Y}if(W)this.validateSchema(b,!0);return Y}_checkUnique(b){if(this.schemas[b]||this.refs[b])throw Error(`schema with key or id "${b}" already exists`)}_compileSchemaEnv(b){if(b.meta)this._compileMetaSchema(b);else t1.compileSchema.call(this,b);if(!b.validate)throw Error("ajv implementation error");return b.validate}_compileMetaSchema(b){let w=this.opts;this.opts=this._metaOpts;try{t1.compileSchema.call(this,b)}finally{this.opts=w}}}U$.ValidationError=jU.default;U$.MissingRefError=gY.default;Yw.default=U$;function fY(b,w,$,W="error"){for(let Q in b){let G=Q;if(G in w)this.logger[W](`${$}: option ${Q}. ${b[G]}`)}}function cY(b){return b=(0,r1.normalizeId)(b),this.schemas[b]||this.refs[b]}function kU(){let b=this.opts.schemas;if(!b)return;if(Array.isArray(b))this.addSchema(b);else for(let w in b)this.addSchema(b[w],w)}function vU(){for(let b in this.opts.formats){let w=this.opts.formats[b];if(w)this.addFormat(b,w)}}function CU(b){if(Array.isArray(b)){this.addVocabulary(b);return}this.logger.warn("keywords option as map is deprecated, pass array");for(let w in b){let $=b[w];if(!$.keyword)$.keyword=w;this.addKeyword($)}}function xU(){let b={...this.opts};for(let w of EU)delete b[w];return b}var uU={log(){},warn(){},error(){}};function yU(b){if(b===!1)return uU;if(b===void 0)return console;if(b.log&&b.warn&&b.error)return b;throw Error("logger must implement log, warn and error methods")}var hU=/^[a-z_$][a-z0-9_$:-]*$/i;function fU(b,w){let{RULES:$}=this;if((0,h6.eachItem)(b,(W)=>{if($.keywords[W])throw Error(`Keyword ${W} is already defined`);if(!hU.test(W))throw Error(`Keyword ${W} has invalid name`)}),!w)return;if(w.$data&&!(("code"in w)||("validate"in w)))throw Error('$data keyword must have "code" or "validate" function')}function y6(b,w,$){var W;let Q=w===null||w===void 0?void 0:w.post;if($&&Q)throw Error('keyword with "post" flag cannot have "type"');let{RULES:G}=this,X=Q?G.post:G.rules.find(({type:H})=>H===$);if(!X)X={type:$,rules:[]},G.rules.push(X);if(G.keywords[b]=!0,!w)return;let Y={keyword:b,definition:{...w,type:(0,L$.getJSONTypes)(w.type),schemaType:(0,L$.getJSONTypes)(w.schemaType)}};if(w.before)cU.call(this,X,Y,w.before);else X.rules.push(Y);G.all[b]=Y,(W=w.implements)===null||W===void 0||W.forEach((H)=>this.addKeyword(H))}function cU(b,w,$){let W=b.rules.findIndex((Q)=>Q.keyword===$);if(W>=0)b.rules.splice(W,0,w);else b.rules.push(w),this.logger.warn(`rule ${$} is not defined`)}function gU(b){let{metaSchema:w}=b;if(w===void 0)return;if(b.$data&&this.opts.$data)w=nY(w);b.validateSchema=this.compile(w,!0)}var mU={$ref:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#"};function nY(b){return{anyOf:[b,mU]}}});var pY=I((iY)=>{Object.defineProperty(iY,"__esModule",{value:!0});var iU={keyword:"id",code(){throw Error('NOT SUPPORTED: keyword "id", use "$id" for schema ID')}};iY.default=iU});var sY=I((rY)=>{Object.defineProperty(rY,"__esModule",{value:!0});rY.callRef=rY.getValidate=void 0;var oU=p1(),oY=vb(),jb=u(),aw=Qw(),dY=D$(),B$=l(),dU={keyword:"$ref",schemaType:"string",code(b){let{gen:w,schema:$,it:W}=b,{baseId:Q,schemaEnv:G,validateName:X,opts:Y,self:H}=W,{root:J}=G;if(($==="#"||$==="#/")&&Q===J.baseId)return z();let D=dY.resolveRef.call(H,J,Q,$);if(D===void 0)throw new oU.default(W.opts.uriResolver,Q,$);if(D instanceof dY.SchemaEnv)return O(D);return q(D);function z(){if(G===J)return F$(b,X,G,G.$async);let B=w.scopeValue("root",{ref:J});return F$(b,jb._`${B}.validate`,J,J.$async)}function O(B){let K=tY(b,B);F$(b,K,B,B.$async)}function q(B){let K=w.scopeValue("schema",Y.code.source===!0?{ref:B,code:(0,jb.stringify)(B)}:{ref:B}),Z=w.name("valid"),M=b.subschema({schema:B,dataTypes:[],schemaPath:jb.nil,topSchemaRef:K,errSchemaPath:$},Z);b.mergeEvaluated(M),b.ok(Z)}}};function tY(b,w){let{gen:$}=b;return w.validate?$.scopeValue("validate",{ref:w.validate}):jb._`${$.scopeValue("wrapper",{ref:w})}.validate`}rY.getValidate=tY;function F$(b,w,$,W){let{gen:Q,it:G}=b,{allErrors:X,schemaEnv:Y,opts:H}=G,J=H.passContext?aw.default.this:jb.nil;if(W)D();else z();function D(){if(!Y.$async)throw Error("async schema referenced by sync schema");let B=Q.let("valid");Q.try(()=>{if(Q.code(jb._`await ${(0,oY.callValidateCode)(b,w,J)}`),q(w),!X)Q.assign(B,!0)},(K)=>{if(Q.if(jb._`!(${K} instanceof ${G.ValidationError})`,()=>Q.throw(K)),O(K),!X)Q.assign(B,!1)}),b.ok(B)}function z(){b.result((0,oY.callValidateCode)(b,w,J),()=>q(w),()=>O(w))}function O(B){let K=jb._`${B}.errors`;Q.assign(aw.default.vErrors,jb._`${aw.default.vErrors} === null ? ${K} : ${aw.default.vErrors}.concat(${K})`),Q.assign(aw.default.errors,jb._`${aw.default.vErrors}.length`)}function q(B){var K;if(!G.opts.unevaluated)return;let Z=(K=$===null||$===void 0?void 0:$.validate)===null||K===void 0?void 0:K.evaluated;if(G.props!==!0)if(Z&&!Z.dynamicProps){if(Z.props!==void 0)G.props=B$.mergeEvaluated.props(Q,Z.props,G.props)}else{let M=Q.var("props",jb._`${B}.evaluated.props`);G.props=B$.mergeEvaluated.props(Q,M,G.props,jb.Name)}if(G.items!==!0)if(Z&&!Z.dynamicItems){if(Z.items!==void 0)G.items=B$.mergeEvaluated.items(Q,Z.items,G.items)}else{let M=Q.var("items",jb._`${B}.evaluated.items`);G.items=B$.mergeEvaluated.items(Q,M,G.items,jb.Name)}}}rY.callRef=F$;rY.default=dU});var bH=I((aY)=>{Object.defineProperty(aY,"__esModule",{value:!0});var eU=pY(),sU=sY(),aU=["$schema","$id","$defs","$vocabulary",{keyword:"$comment"},"definitions",eU.default,sU.default];aY.default=aU});var $H=I((wH)=>{Object.defineProperty(wH,"__esModule",{value:!0});var K$=u(),Vw=K$.operators,P$={maximum:{okStr:"<=",ok:Vw.LTE,fail:Vw.GT},minimum:{okStr:">=",ok:Vw.GTE,fail:Vw.LT},exclusiveMaximum:{okStr:"<",ok:Vw.LT,fail:Vw.GTE},exclusiveMinimum:{okStr:">",ok:Vw.GT,fail:Vw.LTE}},wB={message:({keyword:b,schemaCode:w})=>K$.str`must be ${P$[b].okStr} ${w}`,params:({keyword:b,schemaCode:w})=>K$._`{comparison: ${P$[b].okStr}, limit: ${w}}`},$B={keyword:Object.keys(P$),type:"number",schemaType:"number",$data:!0,error:wB,code(b){let{keyword:w,data:$,schemaCode:W}=b;b.fail$data(K$._`${$} ${P$[w].fail} ${W} || isNaN(${$})`)}};wH.default=$B});var QH=I((WH)=>{Object.defineProperty(WH,"__esModule",{value:!0});var e1=u(),QB={message:({schemaCode:b})=>e1.str`must be multiple of ${b}`,params:({schemaCode:b})=>e1._`{multipleOf: ${b}}`},GB={keyword:"multipleOf",type:"number",schemaType:"number",$data:!0,error:QB,code(b){let{gen:w,data:$,schemaCode:W,it:Q}=b,G=Q.opts.multipleOfPrecision,X=w.let("res"),Y=G?e1._`Math.abs(Math.round(${X}) - ${X}) > 1e-${G}`:e1._`${X} !== parseInt(${X})`;b.fail$data(e1._`(${W} === 0 || (${X} = ${$}/${W}, ${Y}))`)}};WH.default=GB});var YH=I((XH)=>{Object.defineProperty(XH,"__esModule",{value:!0});function GH(b){let w=b.length,$=0,W=0,Q;while(W<w)if($++,Q=b.charCodeAt(W++),Q>=55296&&Q<=56319&&W<w){if(Q=b.charCodeAt(W),(Q&64512)===56320)W++}return $}XH.default=GH;GH.code='require("ajv/dist/runtime/ucs2length").default'});var JH=I((HH)=>{Object.defineProperty(HH,"__esModule",{value:!0});var xw=u(),HB=l(),JB=YH(),DB={message({keyword:b,schemaCode:w}){let $=b==="maxLength"?"more":"fewer";return xw.str`must NOT have ${$} than ${w} characters`},params:({schemaCode:b})=>xw._`{limit: ${b}}`},zB={keyword:["maxLength","minLength"],type:"string",schemaType:"number",$data:!0,error:DB,code(b){let{keyword:w,data:$,schemaCode:W,it:Q}=b,G=w==="maxLength"?xw.operators.GT:xw.operators.LT,X=Q.opts.unicode===!1?xw._`${$}.length`:xw._`${(0,HB.useFunc)(b.gen,JB.default)}(${$})`;b.fail$data(xw._`${X} ${G} ${W}`)}};HH.default=zB});var zH=I((DH)=>{Object.defineProperty(DH,"__esModule",{value:!0});var OB=vb(),M$=u(),qB={message:({schemaCode:b})=>M$.str`must match pattern "${b}"`,params:({schemaCode:b})=>M$._`{pattern: ${b}}`},LB={keyword:"pattern",type:"string",schemaType:"string",$data:!0,error:qB,code(b){let{data:w,$data:$,schema:W,schemaCode:Q,it:G}=b,X=G.opts.unicodeRegExp?"u":"",Y=$?M$._`(new RegExp(${Q}, ${X}))`:(0,OB.usePattern)(b,W);b.fail$data(M$._`!${Y}.test(${w})`)}};DH.default=LB});var OH=I((AH)=>{Object.defineProperty(AH,"__esModule",{value:!0});var s1=u(),BB={message({keyword:b,schemaCode:w}){let $=b==="maxProperties"?"more":"fewer";return s1.str`must NOT have ${$} than ${w} properties`},params:({schemaCode:b})=>s1._`{limit: ${b}}`},FB={keyword:["maxProperties","minProperties"],type:"object",schemaType:"number",$data:!0,error:BB,code(b){let{keyword:w,data:$,schemaCode:W}=b,Q=w==="maxProperties"?s1.operators.GT:s1.operators.LT;b.fail$data(s1._`Object.keys(${$}).length ${Q} ${W}`)}};AH.default=FB});var LH=I((qH)=>{Object.defineProperty(qH,"__esModule",{value:!0});var a1=vb(),b0=u(),PB=l(),MB={message:({params:{missingProperty:b}})=>b0.str`must have required property '${b}'`,params:({params:{missingProperty:b}})=>b0._`{missingProperty: ${b}}`},ZB={keyword:"required",type:"object",schemaType:"array",$data:!0,error:MB,code(b){let{gen:w,schema:$,schemaCode:W,data:Q,$data:G,it:X}=b,{opts:Y}=X;if(!G&&$.length===0)return;let H=$.length>=Y.loopRequired;if(X.allErrors)J();else D();if(Y.strictRequired){let q=b.parentSchema.properties,{definedProperties:B}=b.it;for(let K of $)if((q===null||q===void 0?void 0:q[K])===void 0&&!B.has(K)){let Z=X.schemaEnv.baseId+X.errSchemaPath,M=`required property "${K}" is not defined at "${Z}" (strictRequired)`;(0,PB.checkStrictMode)(X,M,X.opts.strictRequired)}}function J(){if(H||G)b.block$data(b0.nil,z);else for(let q of $)(0,a1.checkReportMissingProp)(b,q)}function D(){let q=w.let("missing");if(H||G){let B=w.let("valid",!0);b.block$data(B,()=>O(q,B)),b.ok(B)}else w.if((0,a1.checkMissingProp)(b,$,q)),(0,a1.reportMissingProp)(b,q),w.else()}function z(){w.forOf("prop",W,(q)=>{b.setParams({missingProperty:q}),w.if((0,a1.noPropertyInData)(w,Q,q,Y.ownProperties),()=>b.error())})}function O(q,B){b.setParams({missingProperty:q}),w.forOf(q,W,()=>{w.assign(B,(0,a1.propertyInData)(w,Q,q,Y.ownProperties)),w.if((0,b0.not)(B),()=>{b.error(),w.break()})},b0.nil)}}};qH.default=ZB});var BH=I((UH)=>{Object.defineProperty(UH,"__esModule",{value:!0});var w0=u(),IB={message({keyword:b,schemaCode:w}){let $=b==="maxItems"?"more":"fewer";return w0.str`must NOT have ${$} than ${w} items`},params:({schemaCode:b})=>w0._`{limit: ${b}}`},VB={keyword:["maxItems","minItems"],type:"array",schemaType:"number",$data:!0,error:IB,code(b){let{keyword:w,data:$,schemaCode:W}=b,Q=w==="maxItems"?w0.operators.GT:w0.operators.LT;b.fail$data(w0._`${$}.length ${Q} ${W}`)}};UH.default=VB});var Z$=I((KH)=>{Object.defineProperty(KH,"__esModule",{value:!0});var FH=j6();FH.code='require("ajv/dist/runtime/equal").default';KH.default=FH});var MH=I((PH)=>{Object.defineProperty(PH,"__esModule",{value:!0});var f6=g1(),qb=u(),TB=l(),_B=Z$(),SB={message:({params:{i:b,j:w}})=>qb.str`must NOT have duplicate items (items ## ${w} and ${b} are identical)`,params:({params:{i:b,j:w}})=>qb._`{i: ${b}, j: ${w}}`},RB={keyword:"uniqueItems",type:"array",schemaType:"boolean",$data:!0,error:SB,code(b){let{gen:w,data:$,$data:W,schema:Q,parentSchema:G,schemaCode:X,it:Y}=b;if(!W&&!Q)return;let H=w.let("valid"),J=G.items?(0,f6.getSchemaTypes)(G.items):[];b.block$data(H,D,qb._`${X} === false`),b.ok(H);function D(){let B=w.let("i",qb._`${$}.length`),K=w.let("j");b.setParams({i:B,j:K}),w.assign(H,!0),w.if(qb._`${B} > 1`,()=>(z()?O:q)(B,K))}function z(){return J.length>0&&!J.some((B)=>B==="object"||B==="array")}function O(B,K){let Z=w.name("item"),M=(0,f6.checkDataTypes)(J,Z,Y.opts.strictNumbers,f6.DataType.Wrong),k=w.const("indices",qb._`{}`);w.for(qb._`;${B}--;`,()=>{if(w.let(Z,qb._`${$}[${B}]`),w.if(M,qb._`continue`),J.length>1)w.if(qb._`typeof ${Z} == "string"`,qb._`${Z} += "_"`);w.if(qb._`typeof ${k}[${Z}] == "number"`,()=>{w.assign(K,qb._`${k}[${Z}]`),b.error(),w.assign(H,!1).break()}).code(qb._`${k}[${Z}] = ${B}`)})}function q(B,K){let Z=(0,TB.useFunc)(w,_B.default),M=w.name("outer");w.label(M).for(qb._`;${B}--;`,()=>w.for(qb._`${K} = ${B}; ${K}--;`,()=>w.if(qb._`${Z}(${$}[${B}], ${$}[${K}])`,()=>{b.error(),w.assign(H,!1).break(M)})))}}};PH.default=RB});var jH=I((ZH)=>{Object.defineProperty(ZH,"__esModule",{value:!0});var c6=u(),vB=l(),CB=Z$(),xB={message:"must be equal to constant",params:({schemaCode:b})=>c6._`{allowedValue: ${b}}`},uB={keyword:"const",$data:!0,error:xB,code(b){let{gen:w,data:$,$data:W,schemaCode:Q,schema:G}=b;if(W||G&&typeof G=="object")b.fail$data(c6._`!${(0,vB.useFunc)(w,CB.default)}(${$}, ${Q})`);else b.fail(c6._`${G} !== ${$}`)}};ZH.default=uB});var VH=I((IH)=>{Object.defineProperty(IH,"__esModule",{value:!0});var $0=u(),hB=l(),fB=Z$(),cB={message:"must be equal to one of the allowed values",params:({schemaCode:b})=>$0._`{allowedValues: ${b}}`},gB={keyword:"enum",schemaType:"array",$data:!0,error:cB,code(b){let{gen:w,data:$,$data:W,schema:Q,schemaCode:G,it:X}=b;if(!W&&Q.length===0)throw Error("enum must have non-empty array");let Y=Q.length>=X.opts.loopEnum,H,J=()=>H!==null&&H!==void 0?H:H=(0,hB.useFunc)(w,fB.default),D;if(Y||W)D=w.let("valid"),b.block$data(D,z);else{if(!Array.isArray(Q))throw Error("ajv implementation error");let q=w.const("vSchema",G);D=(0,$0.or)(...Q.map((B,K)=>O(q,K)))}b.pass(D);function z(){w.assign(D,!1),w.forOf("v",G,(q)=>w.if($0._`${J()}(${$}, ${q})`,()=>w.assign(D,!0).break()))}function O(q,B){let K=Q[B];return typeof K==="object"&&K!==null?$0._`${J()}(${$}, ${q}[${B}])`:$0._`${$} === ${K}`}}};IH.default=gB});var EH=I((NH)=>{Object.defineProperty(NH,"__esModule",{value:!0});var nB=$H(),lB=QH(),iB=JH(),pB=zH(),oB=OH(),dB=LH(),tB=BH(),rB=MH(),eB=jH(),sB=VH(),aB=[nB.default,lB.default,iB.default,pB.default,oB.default,dB.default,tB.default,rB.default,{keyword:"type",schemaType:["string","array"]},{keyword:"nullable",schemaType:"boolean"},eB.default,sB.default];NH.default=aB});var m6=I((_H)=>{Object.defineProperty(_H,"__esModule",{value:!0});_H.validateAdditionalItems=void 0;var uw=u(),g6=l(),wF={message:({params:{len:b}})=>uw.str`must NOT have more than ${b} items`,params:({params:{len:b}})=>uw._`{limit: ${b}}`},$F={keyword:"additionalItems",type:"array",schemaType:["boolean","object"],before:"uniqueItems",error:wF,code(b){let{parentSchema:w,it:$}=b,{items:W}=w;if(!Array.isArray(W)){(0,g6.checkStrictMode)($,'"additionalItems" is ignored when "items" is not an array of schemas');return}TH(b,W)}};function TH(b,w){let{gen:$,schema:W,data:Q,keyword:G,it:X}=b;X.items=!0;let Y=$.const("len",uw._`${Q}.length`);if(W===!1)b.setParams({len:w.length}),b.pass(uw._`${Y} <= ${w.length}`);else if(typeof W=="object"&&!(0,g6.alwaysValidSchema)(X,W)){let J=$.var("valid",uw._`${Y} <= ${w.length}`);$.if((0,uw.not)(J),()=>H(J)),b.ok(J)}function H(J){$.forRange("i",w.length,Y,(D)=>{if(b.subschema({keyword:G,dataProp:D,dataPropType:g6.Type.Num},J),!X.allErrors)$.if((0,uw.not)(J),()=>$.break())})}}_H.validateAdditionalItems=TH;_H.default=$F});var n6=I((vH)=>{Object.defineProperty(vH,"__esModule",{value:!0});vH.validateTuple=void 0;var RH=u(),j$=l(),QF=vb(),GF={keyword:"items",type:"array",schemaType:["object","array","boolean"],before:"uniqueItems",code(b){let{schema:w,it:$}=b;if(Array.isArray(w))return kH(b,"additionalItems",w);if($.items=!0,(0,j$.alwaysValidSchema)($,w))return;b.ok((0,QF.validateArray)(b))}};function kH(b,w,$=b.schema){let{gen:W,parentSchema:Q,data:G,keyword:X,it:Y}=b;if(D(Q),Y.opts.unevaluated&&$.length&&Y.items!==!0)Y.items=j$.mergeEvaluated.items(W,$.length,Y.items);let H=W.name("valid"),J=W.const("len",RH._`${G}.length`);$.forEach((z,O)=>{if((0,j$.alwaysValidSchema)(Y,z))return;W.if(RH._`${J} > ${O}`,()=>b.subschema({keyword:X,schemaProp:O,dataProp:O},H)),b.ok(H)});function D(z){let{opts:O,errSchemaPath:q}=Y,B=$.length,K=B===z.minItems&&(B===z.maxItems||z[w]===!1);if(O.strictTuples&&!K){let Z=`"${X}" is ${B}-tuple, but minItems or maxItems/${w} are not specified or different at path "${q}"`;(0,j$.checkStrictMode)(Y,Z,O.strictTuples)}}}vH.validateTuple=kH;vH.default=GF});var uH=I((xH)=>{Object.defineProperty(xH,"__esModule",{value:!0});var YF=n6(),HF={keyword:"prefixItems",type:"array",schemaType:["array"],before:"uniqueItems",code:(b)=>(0,YF.validateTuple)(b,"items")};xH.default=HF});var fH=I((hH)=>{Object.defineProperty(hH,"__esModule",{value:!0});var yH=u(),DF=l(),zF=vb(),AF=m6(),OF={message:({params:{len:b}})=>yH.str`must NOT have more than ${b} items`,params:({params:{len:b}})=>yH._`{limit: ${b}}`},qF={keyword:"items",type:"array",schemaType:["object","boolean"],before:"uniqueItems",error:OF,code(b){let{schema:w,parentSchema:$,it:W}=b,{prefixItems:Q}=$;if(W.items=!0,(0,DF.alwaysValidSchema)(W,w))return;if(Q)(0,AF.validateAdditionalItems)(b,Q);else b.ok((0,zF.validateArray)(b))}};hH.default=qF});var gH=I((cH)=>{Object.defineProperty(cH,"__esModule",{value:!0});var Cb=u(),I$=l(),UF={message:({params:{min:b,max:w}})=>w===void 0?Cb.str`must contain at least ${b} valid item(s)`:Cb.str`must contain at least ${b} and no more than ${w} valid item(s)`,params:({params:{min:b,max:w}})=>w===void 0?Cb._`{minContains: ${b}}`:Cb._`{minContains: ${b}, maxContains: ${w}}`},BF={keyword:"contains",type:"array",schemaType:["object","boolean"],before:"uniqueItems",trackErrors:!0,error:UF,code(b){let{gen:w,schema:$,parentSchema:W,data:Q,it:G}=b,X,Y,{minContains:H,maxContains:J}=W;if(G.opts.next)X=H===void 0?1:H,Y=J;else X=1;let D=w.const("len",Cb._`${Q}.length`);if(b.setParams({min:X,max:Y}),Y===void 0&&X===0){(0,I$.checkStrictMode)(G,'"minContains" == 0 without "maxContains": "contains" keyword ignored');return}if(Y!==void 0&&X>Y){(0,I$.checkStrictMode)(G,'"minContains" > "maxContains" is always invalid'),b.fail();return}if((0,I$.alwaysValidSchema)(G,$)){let K=Cb._`${D} >= ${X}`;if(Y!==void 0)K=Cb._`${K} && ${D} <= ${Y}`;b.pass(K);return}G.items=!0;let z=w.name("valid");if(Y===void 0&&X===1)q(z,()=>w.if(z,()=>w.break()));else if(X===0){if(w.let(z,!0),Y!==void 0)w.if(Cb._`${Q}.length > 0`,O)}else w.let(z,!1),O();b.result(z,()=>b.reset());function O(){let K=w.name("_valid"),Z=w.let("count",0);q(K,()=>w.if(K,()=>B(Z)))}function q(K,Z){w.forRange("i",0,D,(M)=>{b.subschema({keyword:"contains",dataProp:M,dataPropType:I$.Type.Num,compositeRule:!0},K),Z()})}function B(K){if(w.code(Cb._`${K}++`),Y===void 0)w.if(Cb._`${K} >= ${X}`,()=>w.assign(z,!0).break());else if(w.if(Cb._`${K} > ${Y}`,()=>w.assign(z,!1).break()),X===1)w.assign(z,!0);else w.if(Cb._`${K} >= ${X}`,()=>w.assign(z,!0))}}};cH.default=BF});var oH=I((lH)=>{Object.defineProperty(lH,"__esModule",{value:!0});lH.validateSchemaDeps=lH.validatePropertyDeps=lH.error=void 0;var l6=u(),KF=l(),W0=vb();lH.error={message:({params:{property:b,depsCount:w,deps:$}})=>{let W=w===1?"property":"properties";return l6.str`must have ${W} ${$} when property ${b} is present`},params:({params:{property:b,depsCount:w,deps:$,missingProperty:W}})=>l6._`{property: ${b},
|
|
6
6
|
missingProperty: ${W},
|
|
7
7
|
depsCount: ${w},
|
|
8
8
|
deps: ${$}}`};var PF={keyword:"dependencies",type:"object",schemaType:"object",error:lH.error,code(b){let[w,$]=MF(b);mH(b,w),nH(b,$)}};function MF({schema:b}){let w={},$={};for(let W in b){if(W==="__proto__")continue;let Q=Array.isArray(b[W])?w:$;Q[W]=b[W]}return[w,$]}function mH(b,w=b.schema){let{gen:$,data:W,it:Q}=b;if(Object.keys(w).length===0)return;let G=$.let("missing");for(let X in w){let Y=w[X];if(Y.length===0)continue;let H=(0,W0.propertyInData)($,W,X,Q.opts.ownProperties);if(b.setParams({property:X,depsCount:Y.length,deps:Y.join(", ")}),Q.allErrors)$.if(H,()=>{for(let J of Y)(0,W0.checkReportMissingProp)(b,J)});else $.if(l6._`${H} && (${(0,W0.checkMissingProp)(b,Y,G)})`),(0,W0.reportMissingProp)(b,G),$.else()}}lH.validatePropertyDeps=mH;function nH(b,w=b.schema){let{gen:$,data:W,keyword:Q,it:G}=b,X=$.name("valid");for(let Y in w){if((0,KF.alwaysValidSchema)(G,w[Y]))continue;$.if((0,W0.propertyInData)($,W,Y,G.opts.ownProperties),()=>{let H=b.subschema({keyword:Q,schemaProp:Y},X);b.mergeValidEvaluated(H,X)},()=>$.var(X,!0)),b.ok(X)}}lH.validateSchemaDeps=nH;lH.default=PF});var rH=I((tH)=>{Object.defineProperty(tH,"__esModule",{value:!0});var dH=u(),IF=l(),VF={message:"property name must be valid",params:({params:b})=>dH._`{propertyName: ${b.propertyName}}`},NF={keyword:"propertyNames",type:"object",schemaType:["object","boolean"],error:VF,code(b){let{gen:w,schema:$,data:W,it:Q}=b;if((0,IF.alwaysValidSchema)(Q,$))return;let G=w.name("valid");w.forIn("key",W,(X)=>{b.setParams({propertyName:X}),b.subschema({keyword:"propertyNames",data:X,dataTypes:["string"],propertyName:X,compositeRule:!0},G),w.if((0,dH.not)(G),()=>{if(b.error(!0),!Q.allErrors)w.break()})}),b.ok(G)}};tH.default=NF});var i6=I((eH)=>{Object.defineProperty(eH,"__esModule",{value:!0});var V$=vb(),gb=u(),TF=Qw(),N$=l(),_F={message:"must NOT have additional properties",params:({params:b})=>gb._`{additionalProperty: ${b.additionalProperty}}`},SF={keyword:"additionalProperties",type:["object"],schemaType:["boolean","object"],allowUndefined:!0,trackErrors:!0,error:_F,code(b){let{gen:w,schema:$,parentSchema:W,data:Q,errsCount:G,it:X}=b;if(!G)throw Error("ajv implementation error");let{allErrors:Y,opts:H}=X;if(X.props=!0,H.removeAdditional!=="all"&&(0,N$.alwaysValidSchema)(X,$))return;let J=(0,V$.allSchemaProperties)(W.properties),D=(0,V$.allSchemaProperties)(W.patternProperties);z(),b.ok(gb._`${G} === ${TF.default.errors}`);function z(){w.forIn("key",Q,(Z)=>{if(!J.length&&!D.length)B(Z);else w.if(O(Z),()=>B(Z))})}function O(Z){let M;if(J.length>8){let k=(0,N$.schemaRefOrVal)(X,W.properties,"properties");M=(0,V$.isOwnProperty)(w,k,Z)}else if(J.length)M=(0,gb.or)(...J.map((k)=>gb._`${Z} === ${k}`));else M=gb.nil;if(D.length)M=(0,gb.or)(M,...D.map((k)=>gb._`${(0,V$.usePattern)(b,k)}.test(${Z})`));return(0,gb.not)(M)}function q(Z){w.code(gb._`delete ${Q}[${Z}]`)}function B(Z){if(H.removeAdditional==="all"||H.removeAdditional&&$===!1){q(Z);return}if($===!1){if(b.setParams({additionalProperty:Z}),b.error(),!Y)w.break();return}if(typeof $=="object"&&!(0,N$.alwaysValidSchema)(X,$)){let M=w.name("valid");if(H.removeAdditional==="failing")K(Z,M,!1),w.if((0,gb.not)(M),()=>{b.reset(),q(Z)});else if(K(Z,M),!Y)w.if((0,gb.not)(M),()=>w.break())}}function K(Z,M,k){let S={keyword:"additionalProperties",dataProp:Z,dataPropType:N$.Type.Str};if(k===!1)Object.assign(S,{compositeRule:!0,createErrors:!1,allErrors:!1});b.subschema(S,M)}}};eH.default=SF});var wJ=I((bJ)=>{Object.defineProperty(bJ,"__esModule",{value:!0});var kF=i1(),sH=vb(),p6=l(),aH=i6(),vF={keyword:"properties",type:"object",schemaType:"object",code(b){let{gen:w,schema:$,parentSchema:W,data:Q,it:G}=b;if(G.opts.removeAdditional==="all"&&W.additionalProperties===void 0)aH.default.code(new kF.KeywordCxt(G,aH.default,"additionalProperties"));let X=(0,sH.allSchemaProperties)($);for(let z of X)G.definedProperties.add(z);if(G.opts.unevaluated&&X.length&&G.props!==!0)G.props=p6.mergeEvaluated.props(w,(0,p6.toHash)(X),G.props);let Y=X.filter((z)=>!(0,p6.alwaysValidSchema)(G,$[z]));if(Y.length===0)return;let H=w.name("valid");for(let z of Y){if(J(z))D(z);else{if(w.if((0,sH.propertyInData)(w,Q,z,G.opts.ownProperties)),D(z),!G.allErrors)w.else().var(H,!0);w.endIf()}b.it.definedProperties.add(z),b.ok(H)}function J(z){return G.opts.useDefaults&&!G.compositeRule&&$[z].default!==void 0}function D(z){b.subschema({keyword:"properties",schemaProp:z,dataProp:z},H)}}};bJ.default=vF});var XJ=I((GJ)=>{Object.defineProperty(GJ,"__esModule",{value:!0});var $J=vb(),E$=u(),WJ=l(),QJ=l(),xF={keyword:"patternProperties",type:"object",schemaType:"object",code(b){let{gen:w,schema:$,data:W,parentSchema:Q,it:G}=b,{opts:X}=G,Y=(0,$J.allSchemaProperties)($),H=Y.filter((K)=>(0,WJ.alwaysValidSchema)(G,$[K]));if(Y.length===0||H.length===Y.length&&(!G.opts.unevaluated||G.props===!0))return;let J=X.strictSchema&&!X.allowMatchingProperties&&Q.properties,D=w.name("valid");if(G.props!==!0&&!(G.props instanceof E$.Name))G.props=(0,QJ.evaluatedPropsToName)(w,G.props);let{props:z}=G;O();function O(){for(let K of Y){if(J)q(K);if(G.allErrors)B(K);else w.var(D,!0),B(K),w.if(D)}}function q(K){for(let Z in J)if(new RegExp(K).test(Z))(0,WJ.checkStrictMode)(G,`property ${Z} matches pattern ${K} (use allowMatchingProperties)`)}function B(K){w.forIn("key",W,(Z)=>{w.if(E$._`${(0,$J.usePattern)(b,K)}.test(${Z})`,()=>{let M=H.includes(K);if(!M)b.subschema({keyword:"patternProperties",schemaProp:K,dataProp:Z,dataPropType:QJ.Type.Str},D);if(G.opts.unevaluated&&z!==!0)w.assign(E$._`${z}[${Z}]`,!0);else if(!M&&!G.allErrors)w.if((0,E$.not)(D),()=>w.break())})})}}};GJ.default=xF});var HJ=I((YJ)=>{Object.defineProperty(YJ,"__esModule",{value:!0});var yF=l(),hF={keyword:"not",schemaType:["object","boolean"],trackErrors:!0,code(b){let{gen:w,schema:$,it:W}=b;if((0,yF.alwaysValidSchema)(W,$)){b.fail();return}let Q=w.name("valid");b.subschema({keyword:"not",compositeRule:!0,createErrors:!1,allErrors:!1},Q),b.failResult(Q,()=>b.reset(),()=>b.error())},error:{message:"must NOT be valid"}};YJ.default=hF});var DJ=I((JJ)=>{Object.defineProperty(JJ,"__esModule",{value:!0});var cF=vb(),gF={keyword:"anyOf",schemaType:"array",trackErrors:!0,code:cF.validateUnion,error:{message:"must match a schema in anyOf"}};JJ.default=gF});var AJ=I((zJ)=>{Object.defineProperty(zJ,"__esModule",{value:!0});var T$=u(),nF=l(),lF={message:"must match exactly one schema in oneOf",params:({params:b})=>T$._`{passingSchemas: ${b.passing}}`},iF={keyword:"oneOf",schemaType:"array",trackErrors:!0,error:lF,code(b){let{gen:w,schema:$,parentSchema:W,it:Q}=b;if(!Array.isArray($))throw Error("ajv implementation error");if(Q.opts.discriminator&&W.discriminator)return;let G=$,X=w.let("valid",!1),Y=w.let("passing",null),H=w.name("_valid");b.setParams({passing:Y}),w.block(J),b.result(X,()=>b.reset(),()=>b.error(!0));function J(){G.forEach((D,z)=>{let O;if((0,nF.alwaysValidSchema)(Q,D))w.var(H,!0);else O=b.subschema({keyword:"oneOf",schemaProp:z,compositeRule:!0},H);if(z>0)w.if(T$._`${H} && ${X}`).assign(X,!1).assign(Y,T$._`[${Y}, ${z}]`).else();w.if(H,()=>{if(w.assign(X,!0),w.assign(Y,z),O)b.mergeEvaluated(O,T$.Name)})})}}};zJ.default=iF});var qJ=I((OJ)=>{Object.defineProperty(OJ,"__esModule",{value:!0});var oF=l(),dF={keyword:"allOf",schemaType:"array",code(b){let{gen:w,schema:$,it:W}=b;if(!Array.isArray($))throw Error("ajv implementation error");let Q=w.name("valid");$.forEach((G,X)=>{if((0,oF.alwaysValidSchema)(W,G))return;let Y=b.subschema({keyword:"allOf",schemaProp:X},Q);b.ok(Q),b.mergeEvaluated(Y)})}};OJ.default=dF});var FJ=I((BJ)=>{Object.defineProperty(BJ,"__esModule",{value:!0});var _$=u(),UJ=l(),rF={message:({params:b})=>_$.str`must match "${b.ifClause}" schema`,params:({params:b})=>_$._`{failingKeyword: ${b.ifClause}}`},eF={keyword:"if",schemaType:["object","boolean"],trackErrors:!0,error:rF,code(b){let{gen:w,parentSchema:$,it:W}=b;if($.then===void 0&&$.else===void 0)(0,UJ.checkStrictMode)(W,'"if" without "then" and "else" is ignored');let Q=LJ(W,"then"),G=LJ(W,"else");if(!Q&&!G)return;let X=w.let("valid",!0),Y=w.name("_valid");if(H(),b.reset(),Q&&G){let D=w.let("ifClause");b.setParams({ifClause:D}),w.if(Y,J("then",D),J("else",D))}else if(Q)w.if(Y,J("then"));else w.if((0,_$.not)(Y),J("else"));b.pass(X,()=>b.error(!0));function H(){let D=b.subschema({keyword:"if",compositeRule:!0,createErrors:!1,allErrors:!1},Y);b.mergeEvaluated(D)}function J(D,z){return()=>{let O=b.subschema({keyword:D},Y);if(w.assign(X,Y),b.mergeValidEvaluated(O,X),z)w.assign(z,_$._`${D}`);else b.setParams({ifClause:D})}}}};function LJ(b,w){let $=b.schema[w];return $!==void 0&&!(0,UJ.alwaysValidSchema)(b,$)}BJ.default=eF});var PJ=I((KJ)=>{Object.defineProperty(KJ,"__esModule",{value:!0});var aF=l(),bK={keyword:["then","else"],schemaType:["object","boolean"],code({keyword:b,parentSchema:w,it:$}){if(w.if===void 0)(0,aF.checkStrictMode)($,`"${b}" without "if" is ignored`)}};KJ.default=bK});var ZJ=I((MJ)=>{Object.defineProperty(MJ,"__esModule",{value:!0});var $K=m6(),WK=uH(),QK=n6(),GK=fH(),XK=gH(),YK=oH(),HK=rH(),JK=i6(),DK=wJ(),zK=XJ(),AK=HJ(),OK=DJ(),qK=AJ(),LK=qJ(),UK=FJ(),BK=PJ();function FK(b=!1){let w=[AK.default,OK.default,qK.default,LK.default,UK.default,BK.default,HK.default,JK.default,YK.default,DK.default,zK.default];if(b)w.push(WK.default,GK.default);else w.push($K.default,QK.default);return w.push(XK.default),w}MJ.default=FK});var IJ=I((jJ)=>{Object.defineProperty(jJ,"__esModule",{value:!0});var Gb=u(),PK={message:({schemaCode:b})=>Gb.str`must match format "${b}"`,params:({schemaCode:b})=>Gb._`{format: ${b}}`},MK={keyword:"format",type:["number","string"],schemaType:"string",$data:!0,error:PK,code(b,w){let{gen:$,data:W,$data:Q,schema:G,schemaCode:X,it:Y}=b,{opts:H,errSchemaPath:J,schemaEnv:D,self:z}=Y;if(!H.validateFormats)return;if(Q)O();else q();function O(){let B=$.scopeValue("formats",{ref:z.formats,code:H.code.formats}),K=$.const("fDef",Gb._`${B}[${X}]`),Z=$.let("fType"),M=$.let("format");$.if(Gb._`typeof ${K} == "object" && !(${K} instanceof RegExp)`,()=>$.assign(Z,Gb._`${K}.type || "string"`).assign(M,Gb._`${K}.validate`),()=>$.assign(Z,Gb._`"string"`).assign(M,K)),b.fail$data((0,Gb.or)(k(),S()));function k(){if(H.strictSchema===!1)return Gb.nil;return Gb._`${X} && !${M}`}function S(){let h=D.$async?Gb._`(${K}.async ? await ${M}(${W}) : ${M}(${W}))`:Gb._`${M}(${W})`,R=Gb._`(typeof ${M} == "function" ? ${h} : ${M}.test(${W}))`;return Gb._`${M} && ${M} !== true && ${Z} === ${w} && !${R}`}}function q(){let B=z.formats[G];if(!B){k();return}if(B===!0)return;let[K,Z,M]=S(B);if(K===w)b.pass(h());function k(){if(H.strictSchema===!1){z.logger.warn(R());return}throw Error(R());function R(){return`unknown format "${G}" ignored in schema at path "${J}"`}}function S(R){let ib=R instanceof RegExp?(0,Gb.regexpCode)(R):H.code.formats?Gb._`${H.code.formats}${(0,Gb.getProperty)(G)}`:void 0,sb=$.scopeValue("formats",{key:G,ref:R,code:ib});if(typeof R=="object"&&!(R instanceof RegExp))return[R.type||"string",R.validate,Gb._`${sb}.validate`];return["string",R,sb]}function h(){if(typeof B=="object"&&!(B instanceof RegExp)&&B.async){if(!D.$async)throw Error("async format in sync schema");return Gb._`await ${M}(${W})`}return typeof Z=="function"?Gb._`${M}(${W})`:Gb._`${M}.test(${W})`}}}};jJ.default=MK});var NJ=I((VJ)=>{Object.defineProperty(VJ,"__esModule",{value:!0});var jK=IJ(),IK=[jK.default];VJ.default=IK});var _J=I((EJ)=>{Object.defineProperty(EJ,"__esModule",{value:!0});EJ.contentVocabulary=EJ.metadataVocabulary=void 0;EJ.metadataVocabulary=["title","description","default","deprecated","readOnly","writeOnly","examples"];EJ.contentVocabulary=["contentMediaType","contentEncoding","contentSchema"]});var kJ=I((RJ)=>{Object.defineProperty(RJ,"__esModule",{value:!0});var EK=bH(),TK=EH(),_K=ZJ(),SK=NJ(),SJ=_J(),RK=[EK.default,TK.default,(0,_K.default)(),SK.default,SJ.metadataVocabulary,SJ.contentVocabulary];RJ.default=RK});var uJ=I((CJ)=>{Object.defineProperty(CJ,"__esModule",{value:!0});CJ.DiscrError=void 0;var vJ;(function(b){b.Tag="tag",b.Mapping="mapping"})(vJ||(CJ.DiscrError=vJ={}))});var fJ=I((hJ)=>{Object.defineProperty(hJ,"__esModule",{value:!0});var b1=u(),o6=uJ(),yJ=D$(),vK=p1(),CK=l(),xK={message:({params:{discrError:b,tagName:w}})=>b===o6.DiscrError.Tag?`tag "${w}" must be string`:`value of tag "${w}" must be in oneOf`,params:({params:{discrError:b,tag:w,tagName:$}})=>b1._`{error: ${b}, tag: ${$}, tagValue: ${w}}`},uK={keyword:"discriminator",type:"object",schemaType:"object",error:xK,code(b){let{gen:w,data:$,schema:W,parentSchema:Q,it:G}=b,{oneOf:X}=Q;if(!G.opts.discriminator)throw Error("discriminator: requires discriminator option");let Y=W.propertyName;if(typeof Y!="string")throw Error("discriminator: requires propertyName");if(W.mapping)throw Error("discriminator: mapping is not supported");if(!X)throw Error("discriminator: requires oneOf keyword");let H=w.let("valid",!1),J=w.const("tag",b1._`${$}${(0,b1.getProperty)(Y)}`);w.if(b1._`typeof ${J} == "string"`,()=>D(),()=>b.error(!1,{discrError:o6.DiscrError.Tag,tag:J,tagName:Y})),b.ok(H);function D(){let q=O();w.if(!1);for(let B in q)w.elseIf(b1._`${J} === ${B}`),w.assign(H,z(q[B]));w.else(),b.error(!1,{discrError:o6.DiscrError.Mapping,tag:J,tagName:Y}),w.endIf()}function z(q){let B=w.name("valid"),K=b.subschema({keyword:"oneOf",schemaProp:q},B);return b.mergeEvaluated(K,b1.Name),B}function O(){var q;let B={},K=M(Q),Z=!0;for(let h=0;h<X.length;h++){let R=X[h];if((R===null||R===void 0?void 0:R.$ref)&&!(0,CK.schemaHasRulesButRef)(R,G.self.RULES)){let sb=R.$ref;if(R=yJ.resolveRef.call(G.self,G.schemaEnv.root,G.baseId,sb),R instanceof yJ.SchemaEnv)R=R.schema;if(R===void 0)throw new vK.default(G.opts.uriResolver,G.baseId,sb)}let ib=(q=R===null||R===void 0?void 0:R.properties)===null||q===void 0?void 0:q[Y];if(typeof ib!="object")throw Error(`discriminator: oneOf subschemas (or referenced schemas) must have "properties/${Y}"`);Z=Z&&(K||M(R)),k(ib,h)}if(!Z)throw Error(`discriminator: "${Y}" must be required`);return B;function M({required:h}){return Array.isArray(h)&&h.includes(Y)}function k(h,R){if(h.const)S(h.const,R);else if(h.enum)for(let ib of h.enum)S(ib,R);else throw Error(`discriminator: "properties/${Y}" must have "const" or "enum"`)}function S(h,R){if(typeof h!="string"||h in B)throw Error(`discriminator: "${Y}" values must be unique strings`);B[h]=R}}}};hJ.default=uK});var cJ=I((hT,hK)=>{hK.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 t6=I((Ib,d6)=>{Object.defineProperty(Ib,"__esModule",{value:!0});Ib.MissingRefError=Ib.ValidationError=Ib.CodeGen=Ib.Name=Ib.nil=Ib.stringify=Ib.str=Ib._=Ib.KeywordCxt=Ib.Ajv=void 0;var fK=lY(),cK=kJ(),gK=fJ(),gJ=cJ(),mK=["/properties"],S$="http://json-schema.org/draft-07/schema";class Q0 extends fK.default{_addVocabularies(){if(super._addVocabularies(),cK.default.forEach((b)=>this.addVocabulary(b)),this.opts.discriminator)this.addKeyword(gK.default)}_addDefaultMetaSchema(){if(super._addDefaultMetaSchema(),!this.opts.meta)return;let b=this.opts.$data?this.$dataMetaSchema(gJ,mK):gJ;this.addMetaSchema(b,S$,!1),this.refs["http://json-schema.org/schema"]=S$}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(S$)?S$:void 0)}}Ib.Ajv=Q0;d6.exports=Ib=Q0;d6.exports.Ajv=Q0;Object.defineProperty(Ib,"__esModule",{value:!0});Ib.default=Q0;var nK=i1();Object.defineProperty(Ib,"KeywordCxt",{enumerable:!0,get:function(){return nK.KeywordCxt}});var w1=u();Object.defineProperty(Ib,"_",{enumerable:!0,get:function(){return w1._}});Object.defineProperty(Ib,"str",{enumerable:!0,get:function(){return w1.str}});Object.defineProperty(Ib,"stringify",{enumerable:!0,get:function(){return w1.stringify}});Object.defineProperty(Ib,"nil",{enumerable:!0,get:function(){return w1.nil}});Object.defineProperty(Ib,"Name",{enumerable:!0,get:function(){return w1.Name}});Object.defineProperty(Ib,"CodeGen",{enumerable:!0,get:function(){return w1.CodeGen}});var lK=H$();Object.defineProperty(Ib,"ValidationError",{enumerable:!0,get:function(){return lK.default}});var iK=p1();Object.defineProperty(Ib,"MissingRefError",{enumerable:!0,get:function(){return iK.default}})});var eJ=I((tJ)=>{Object.defineProperty(tJ,"__esModule",{value:!0});tJ.formatNames=tJ.fastFormats=tJ.fullFormats=void 0;function tb(b,w){return{validate:b,compare:w}}tJ.fullFormats={date:tb(iJ,a6),time:tb(e6(!0),bW),"date-time":tb(mJ(!0),oJ),"iso-time":tb(e6(),pJ),"iso-date-time":tb(mJ(),dJ),duration:/^P(?!$)((\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+S)?)?|(\d+W)?)$/,uri:aK,"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:XP,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:bP,int32:{type:"number",validate:WP},int64:{type:"number",validate:QP},float:{type:"number",validate:lJ},double:{type:"number",validate:lJ},password:!0,binary:!0};tJ.fastFormats={...tJ.fullFormats,date:tb(/^\d\d\d\d-[0-1]\d-[0-3]\d$/,a6),time:tb(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,bW),"date-time":tb(/^\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,oJ),"iso-time":tb(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,pJ),"iso-date-time":tb(/^\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,dJ),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};tJ.formatNames=Object.keys(tJ.fullFormats);function dK(b){return b%4===0&&(b%100!==0||b%400===0)}var tK=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,rK=[0,31,28,31,30,31,30,31,31,30,31,30,31];function iJ(b){let w=tK.exec(b);if(!w)return!1;let $=+w[1],W=+w[2],Q=+w[3];return W>=1&&W<=12&&Q>=1&&Q<=(W===2&&dK($)?29:rK[W])}function a6(b,w){if(!(b&&w))return;if(b>w)return 1;if(b<w)return-1;return 0}var r6=/^(\d\d):(\d\d):(\d\d(?:\.\d+)?)(z|([+-])(\d\d)(?::?(\d\d))?)?$/i;function e6(b){return function($){let W=r6.exec($);if(!W)return!1;let Q=+W[1],G=+W[2],X=+W[3],Y=W[4],H=W[5]==="-"?-1:1,J=+(W[6]||0),D=+(W[7]||0);if(J>23||D>59||b&&!Y)return!1;if(Q<=23&&G<=59&&X<60)return!0;let z=G-D*H,O=Q-J*H-(z<0?1:0);return(O===23||O===-1)&&(z===59||z===-1)&&X<61}}function bW(b,w){if(!(b&&w))return;let $=new Date("2020-01-01T"+b).valueOf(),W=new Date("2020-01-01T"+w).valueOf();if(!($&&W))return;return $-W}function pJ(b,w){if(!(b&&w))return;let $=r6.exec(b),W=r6.exec(w);if(!($&&W))return;if(b=$[1]+$[2]+$[3],w=W[1]+W[2]+W[3],b>w)return 1;if(b<w)return-1;return 0}var s6=/t|\s/i;function mJ(b){let w=e6(b);return function(W){let Q=W.split(s6);return Q.length===2&&iJ(Q[0])&&w(Q[1])}}function oJ(b,w){if(!(b&&w))return;let $=new Date(b).valueOf(),W=new Date(w).valueOf();if(!($&&W))return;return $-W}function dJ(b,w){if(!(b&&w))return;let[$,W]=b.split(s6),[Q,G]=w.split(s6),X=a6($,Q);if(X===void 0)return;return X||bW(W,G)}var eK=/\/|:/,sK=/^(?:[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 aK(b){return eK.test(b)&&sK.test(b)}var nJ=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/gm;function bP(b){return nJ.lastIndex=0,nJ.test(b)}var wP=-2147483648,$P=2147483647;function WP(b){return Number.isInteger(b)&&b<=$P&&b>=wP}function QP(b){return Number.isInteger(b)}function lJ(){return!0}var GP=/[^\\]\\Z/;function XP(b){if(GP.test(b))return!1;try{return new RegExp(b),!0}catch(w){return!1}}});var aJ=I((sJ)=>{Object.defineProperty(sJ,"__esModule",{value:!0});sJ.formatLimitDefinition=void 0;var HP=t6(),mb=u(),Nw=mb.operators,R$={formatMaximum:{okStr:"<=",ok:Nw.LTE,fail:Nw.GT},formatMinimum:{okStr:">=",ok:Nw.GTE,fail:Nw.LT},formatExclusiveMaximum:{okStr:"<",ok:Nw.LT,fail:Nw.GTE},formatExclusiveMinimum:{okStr:">",ok:Nw.GT,fail:Nw.LTE}},JP={message:({keyword:b,schemaCode:w})=>mb.str`should be ${R$[b].okStr} ${w}`,params:({keyword:b,schemaCode:w})=>mb._`{comparison: ${R$[b].okStr}, limit: ${w}}`};sJ.formatLimitDefinition={keyword:Object.keys(R$),type:"string",schemaType:"string",$data:!0,error:JP,code(b){let{gen:w,data:$,schemaCode:W,keyword:Q,it:G}=b,{opts:X,self:Y}=G;if(!X.validateFormats)return;let H=new HP.KeywordCxt(G,Y.RULES.all.format.definition,"format");if(H.$data)J();else D();function J(){let O=w.scopeValue("formats",{ref:Y.formats,code:X.code.formats}),q=w.const("fmt",mb._`${O}[${H.schemaCode}]`);b.fail$data((0,mb.or)(mb._`typeof ${q} != "object"`,mb._`${q} instanceof RegExp`,mb._`typeof ${q}.compare != "function"`,z(q)))}function D(){let O=H.schema,q=Y.formats[O];if(!q||q===!0)return;if(typeof q!="object"||q instanceof RegExp||typeof q.compare!="function")throw Error(`"${Q}": format "${O}" does not define "compare" function`);let B=w.scopeValue("formats",{key:O,ref:q,code:X.code.formats?mb._`${X.code.formats}${(0,mb.getProperty)(O)}`:void 0});b.fail$data(z(B))}function z(O){return mb._`${O}.compare(${$}, ${W}) ${R$[Q].fail} 0`}},dependencies:["format"]};var DP=(b)=>{return b.addKeyword(sJ.formatLimitDefinition),b};sJ.default=DP});var WD=I((G0,$D)=>{Object.defineProperty(G0,"__esModule",{value:!0});var $1=eJ(),AP=aJ(),WW=u(),bD=new WW.Name("fullFormats"),OP=new WW.Name("fastFormats"),QW=(b,w={keywords:!0})=>{if(Array.isArray(w))return wD(b,w,$1.fullFormats,bD),b;let[$,W]=w.mode==="fast"?[$1.fastFormats,OP]:[$1.fullFormats,bD],Q=w.formats||$1.formatNames;if(wD(b,Q,$,W),w.keywords)(0,AP.default)(b);return b};QW.get=(b,w="full")=>{let W=(w==="fast"?$1.fastFormats:$1.fullFormats)[b];if(!W)throw Error(`Unknown format "${b}"`);return W};function wD(b,w,$,W){var Q,G;(Q=(G=b.opts.code).formats)!==null&&Q!==void 0||(G.formats=WW._`require("ajv-formats/dist/formats").${W}`);for(let X of w)b.addFormat(X,$[X])}$D.exports=G0=QW;Object.defineProperty(G0,"__esModule",{value:!0});G0.default=QW});import{AsyncLocalStorage as mz}from"node:async_hooks";class pb extends Error{statusCode;rawDetails;code;context;constructor(b,w,$,W,Q){super(b);this.statusCode=w;this.rawDetails=$;this.code=W;this.context=Q;this.name="McpApiError"}}function fz(b){if(b instanceof pb)return{message:b.message,statusCode:b.statusCode,code:b.code,rawDetails:b.rawDetails,context:b.context};if(b instanceof Error)return{message:b.message};return{message:String(b)}}function cz(b){let w=b.match(/api key is missing required scopes?:\s*(.+)$/i);if(!w?.[1])return[];return w[1].match(/[a-z_]+:[a-z_]+/gi)??[]}function gz(b){let w=fz(b),$=w.message.trim()||"Unknown error",W=$.toLowerCase(),Q=w.rawDetails?.trim()||$;if(w.context?.title||w.context?.description||w.context?.howToFix||w.context?.docsUrl)return{title:w.context.title??(w.statusCode===409?"Request conflict":"API request failed"),description:w.context.description??$,howToFix:w.context.howToFix??"Review the details below, adjust the tool input, and retry.",docsUrl:w.context.docsUrl??"https://docs.sequenzy.com/concepts/mcp",details:Q};if(w.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:Q};if(w.statusCode===401||w.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:Q};let G=cz($);if(G.length>0){let X=G.map((H)=>`\`${H}\``).join(", "),Y=G.every((H)=>H.endsWith(":read"))?"the Read-only or Safer agent access preset":"Safer agent access when it covers the task, or Custom permissions";return{title:"API key permission required",description:`The current API key is valid, but this operation requires the missing ${G.length===1?"scope":"scopes"}: ${X}.`,howToFix:`For a local API-key connection, call \`get_account\` to inspect \`apiKeyPermissions\` and open \`apiKeyPermissions.manageUrl\` (or \`companies[].settingsUrl\` → API Keys). If \`get_account\` also requires \`account:read\`, open ${"https://sequenzy.com/dashboard"} directly and use the MCP setup or Settings → API Keys. Create a replacement key with ${Y} including ${X}, replace \`SEQUENZY_API_KEY\`, and restart the client. For hosted OAuth MCP, disconnect and reauthorize the Sequenzy connection with a preset or Custom permissions including ${X}. Existing key permissions cannot be edited in place.`,docsUrl:"https://docs.sequenzy.com/concepts/mcp",details:Q}}if(w.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:Q};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:Q};if(w.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:Q};if(w.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:Q};if(w.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:Q};if(w.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:Q};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:Q};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:Q};if(w.statusCode&&w.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:Q};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:Q}}function yw(b){let w=gz(b);return[`Sequenzy MCP error: ${w.title}`,`Description: ${w.description}`,`How to fix: ${w.howToFix}`,`Docs: ${w.docsUrl}`,`Details: ${w.details}`].join(`
|
|
@@ -25,7 +25,7 @@ var Sz=Object.create;var{getPrototypeOf:Rz,defineProperty:d$,getOwnPropertyNames
|
|
|
25
25
|
newResult[${R}] = ${h}.value;
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
`)}q.write("payload.value = newResult;"),q.write("return payload;");let k=q.compile();return(S,h)=>k(O,S,h)},G,X=_w,Y=!A0.jitless,J=Y&&a$.value,D=w.catchall,z;b._zod.parse=(O,q)=>{z??(z=W.value);let B=O.value;if(!X(B))return O.issues.push({expected:"object",code:"invalid_type",input:B,inst:b}),O;if(Y&&J&&q?.async===!1&&q.jitless!==!0){if(!G)G=Q(w.shape);if(O=G(O,q),!D)return O;return C9([],B,O,q,z,b)}return $(O,q)}});function rQ(b,w,$,W){for(let G of b)if(G.issues.length===0)return w.value=G.value,w;let Q=b.filter((G)=>!Uw(G));if(Q.length===1)return w.value=Q[0].value,Q[0];return w.issues.push({code:"invalid_union",input:w.value,inst:$,errors:b.map((G)=>G.issues.map((X)=>ub(X,W,Sb())))}),w}var z4=U("$ZodUnion",(b,w)=>{e.init(b,w),o(b._zod,"optin",()=>w.options.some((Q)=>Q._zod.optin==="optional")?"optional":void 0),o(b._zod,"optout",()=>w.options.some((Q)=>Q._zod.optout==="optional")?"optional":void 0),o(b._zod,"values",()=>{if(w.options.every((Q)=>Q._zod.values))return new Set(w.options.flatMap((Q)=>Array.from(Q._zod.values)));return}),o(b._zod,"pattern",()=>{if(w.options.every((Q)=>Q._zod.pattern)){let Q=w.options.map((G)=>G._zod.pattern);return new RegExp(`^(${Q.map((G)=>L1(G.source)).join("|")})$`)}return});let $=w.options.length===1,W=w.options[0]._zod.run;b._zod.parse=(Q,G)=>{if($)return W(Q,G);let X=!1,Y=[];for(let H of w.options){let J=H._zod.run({value:Q.value,issues:[]},G);if(J instanceof Promise)Y.push(J),X=!0;else{if(J.issues.length===0)return J;Y.push(J)}}if(!X)return rQ(Y,Q,b,G);return Promise.all(Y).then((H)=>{return rQ(H,Q,b,G)})}}),u9=U("$ZodDiscriminatedUnion",(b,w)=>{z4.init(b,w);let $=b._zod.parse;o(b._zod,"propValues",()=>{let Q={};for(let G of w.options){let X=G._zod.propValues;if(!X||Object.keys(X).length===0)throw Error(`Invalid discriminated union option at index "${w.options.indexOf(G)}"`);for(let[Y,H]of Object.entries(X)){if(!Q[Y])Q[Y]=new Set;for(let J of H)Q[Y].add(J)}}return Q});let W=fw(()=>{let Q=w.options,G=new Map;for(let X of Q){let Y=X._zod.propValues?.[w.discriminator];if(!Y||Y.size===0)throw Error(`Invalid discriminated union option at index "${w.options.indexOf(X)}"`);for(let H of Y){if(G.has(H))throw Error(`Duplicate discriminator value "${String(H)}"`);G.set(H,X)}}return G});b._zod.parse=(Q,G)=>{let X=Q.value;if(!_w(X))return Q.issues.push({code:"invalid_type",expected:"object",input:X,inst:b}),Q;let Y=W.value.get(X?.[w.discriminator]);if(Y)return Y._zod.run(Q,G);if(w.unionFallback)return $(Q,G);return Q.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:w.discriminator,input:X,path:[w.discriminator],inst:b}),Q}}),y9=U("$ZodIntersection",(b,w)=>{e.init(b,w),b._zod.parse=($,W)=>{let Q=$.value,G=w.left._zod.run({value:Q,issues:[]},W),X=w.right._zod.run({value:Q,issues:[]},W);if(G instanceof Promise||X instanceof Promise)return Promise.all([G,X]).then(([H,J])=>{return eQ($,H,J)});return eQ($,G,X)}});function J4(b,w){if(b===w)return{valid:!0,data:b};if(b instanceof Date&&w instanceof Date&&+b===+w)return{valid:!0,data:b};if(Lw(b)&&Lw(w)){let $=Object.keys(w),W=Object.keys(b).filter((G)=>$.indexOf(G)!==-1),Q={...b,...w};for(let G of W){let X=J4(b[G],w[G]);if(!X.valid)return{valid:!1,mergeErrorPath:[G,...X.mergeErrorPath]};Q[G]=X.data}return{valid:!0,data:Q}}if(Array.isArray(b)&&Array.isArray(w)){if(b.length!==w.length)return{valid:!1,mergeErrorPath:[]};let $=[];for(let W=0;W<b.length;W++){let Q=b[W],G=w[W],X=J4(Q,G);if(!X.valid)return{valid:!1,mergeErrorPath:[W,...X.mergeErrorPath]};$.push(X.data)}return{valid:!0,data:$}}return{valid:!1,mergeErrorPath:[]}}function eQ(b,w,$){if(w.issues.length)b.issues.push(...w.issues);if($.issues.length)b.issues.push(...$.issues);if(Uw(b))return b;let W=J4(w.value,$.value);if(!W.valid)throw Error(`Unmergable intersection. Error path: ${JSON.stringify(W.mergeErrorPath)}`);return b.value=W.data,b}var h9=U("$ZodRecord",(b,w)=>{e.init(b,w),b._zod.parse=($,W)=>{let Q=$.value;if(!Lw(Q))return $.issues.push({expected:"record",code:"invalid_type",input:Q,inst:b}),$;let G=[];if(w.keyType._zod.values){let X=w.keyType._zod.values;$.value={};for(let H of X)if(typeof H==="string"||typeof H==="number"||typeof H==="symbol"){let J=w.valueType._zod.run({value:Q[H],issues:[]},W);if(J instanceof Promise)G.push(J.then((D)=>{if(D.issues.length)$.issues.push(...ww(H,D.issues));$.value[H]=D.value}));else{if(J.issues.length)$.issues.push(...ww(H,J.issues));$.value[H]=J.value}}let Y;for(let H in Q)if(!X.has(H))Y=Y??[],Y.push(H);if(Y&&Y.length>0)$.issues.push({code:"unrecognized_keys",input:Q,inst:b,keys:Y})}else{$.value={};for(let X of Reflect.ownKeys(Q)){if(X==="__proto__")continue;let Y=w.keyType._zod.run({value:X,issues:[]},W);if(Y instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(Y.issues.length){$.issues.push({code:"invalid_key",origin:"record",issues:Y.issues.map((J)=>ub(J,W,Sb())),input:X,path:[X],inst:b}),$.value[Y.value]=Y.value;continue}let H=w.valueType._zod.run({value:Q[X],issues:[]},W);if(H instanceof Promise)G.push(H.then((J)=>{if(J.issues.length)$.issues.push(...ww(X,J.issues));$.value[Y.value]=J.value}));else{if(H.issues.length)$.issues.push(...ww(X,H.issues));$.value[Y.value]=H.value}}}if(G.length)return Promise.all(G).then(()=>$);return $}});var f9=U("$ZodEnum",(b,w)=>{e.init(b,w);let $=e$(w.entries),W=new Set($);b._zod.values=W,b._zod.pattern=new RegExp(`^(${$.filter((Q)=>b4.has(typeof Q)).map((Q)=>typeof Q==="string"?bw(Q):Q.toString()).join("|")})$`),b._zod.parse=(Q,G)=>{let X=Q.value;if(W.has(X))return Q;return Q.issues.push({code:"invalid_value",values:$,input:X,inst:b}),Q}}),c9=U("$ZodLiteral",(b,w)=>{if(e.init(b,w),w.values.length===0)throw Error("Cannot create literal schema with no valid values");b._zod.values=new Set(w.values),b._zod.pattern=new RegExp(`^(${w.values.map(($)=>typeof $==="string"?bw($):$?bw($.toString()):String($)).join("|")})$`),b._zod.parse=($,W)=>{let Q=$.value;if(b._zod.values.has(Q))return $;return $.issues.push({code:"invalid_value",values:w.values,input:Q,inst:b}),$}});var g9=U("$ZodTransform",(b,w)=>{e.init(b,w),b._zod.parse=($,W)=>{if(W.direction==="backward")throw new A1(b.constructor.name);let Q=w.transform($.value,$);if(W.async)return(Q instanceof Promise?Q:Promise.resolve(Q)).then((X)=>{return $.value=X,$});if(Q instanceof Promise)throw new ab;return $.value=Q,$}});function sQ(b,w){if(b.issues.length&&w===void 0)return{issues:[],value:void 0};return b}var m9=U("$ZodOptional",(b,w)=>{e.init(b,w),b._zod.optin="optional",b._zod.optout="optional",o(b._zod,"values",()=>{return w.innerType._zod.values?new Set([...w.innerType._zod.values,void 0]):void 0}),o(b._zod,"pattern",()=>{let $=w.innerType._zod.pattern;return $?new RegExp(`^(${L1($.source)})?$`):void 0}),b._zod.parse=($,W)=>{if(w.innerType._zod.optin==="optional"){let Q=w.innerType._zod.run($,W);if(Q instanceof Promise)return Q.then((G)=>sQ(G,$.value));return sQ(Q,$.value)}if($.value===void 0)return $;return w.innerType._zod.run($,W)}}),n9=U("$ZodNullable",(b,w)=>{e.init(b,w),o(b._zod,"optin",()=>w.innerType._zod.optin),o(b._zod,"optout",()=>w.innerType._zod.optout),o(b._zod,"pattern",()=>{let $=w.innerType._zod.pattern;return $?new RegExp(`^(${L1($.source)}|null)$`):void 0}),o(b._zod,"values",()=>{return w.innerType._zod.values?new Set([...w.innerType._zod.values,null]):void 0}),b._zod.parse=($,W)=>{if($.value===null)return $;return w.innerType._zod.run($,W)}}),l9=U("$ZodDefault",(b,w)=>{e.init(b,w),b._zod.optin="optional",o(b._zod,"values",()=>w.innerType._zod.values),b._zod.parse=($,W)=>{if(W.direction==="backward")return w.innerType._zod.run($,W);if($.value===void 0)return $.value=w.defaultValue,$;let Q=w.innerType._zod.run($,W);if(Q instanceof Promise)return Q.then((G)=>aQ(G,w));return aQ(Q,w)}});function aQ(b,w){if(b.value===void 0)b.value=w.defaultValue;return b}var i9=U("$ZodPrefault",(b,w)=>{e.init(b,w),b._zod.optin="optional",o(b._zod,"values",()=>w.innerType._zod.values),b._zod.parse=($,W)=>{if(W.direction==="backward")return w.innerType._zod.run($,W);if($.value===void 0)$.value=w.defaultValue;return w.innerType._zod.run($,W)}}),p9=U("$ZodNonOptional",(b,w)=>{e.init(b,w),o(b._zod,"values",()=>{let $=w.innerType._zod.values;return $?new Set([...$].filter((W)=>W!==void 0)):void 0}),b._zod.parse=($,W)=>{let Q=w.innerType._zod.run($,W);if(Q instanceof Promise)return Q.then((G)=>b9(G,b));return b9(Q,b)}});function b9(b,w){if(!b.issues.length&&b.value===void 0)b.issues.push({code:"invalid_type",expected:"nonoptional",input:b.value,inst:w});return b}var o9=U("$ZodCatch",(b,w)=>{e.init(b,w),o(b._zod,"optin",()=>w.innerType._zod.optin),o(b._zod,"optout",()=>w.innerType._zod.optout),o(b._zod,"values",()=>w.innerType._zod.values),b._zod.parse=($,W)=>{if(W.direction==="backward")return w.innerType._zod.run($,W);let Q=w.innerType._zod.run($,W);if(Q instanceof Promise)return Q.then((G)=>{if($.value=G.value,G.issues.length)$.value=w.catchValue({...$,error:{issues:G.issues.map((X)=>ub(X,W,Sb()))},input:$.value}),$.issues=[];return $});if($.value=Q.value,Q.issues.length)$.value=w.catchValue({...$,error:{issues:Q.issues.map((G)=>ub(G,W,Sb()))},input:$.value}),$.issues=[];return $}});var d9=U("$ZodPipe",(b,w)=>{e.init(b,w),o(b._zod,"values",()=>w.in._zod.values),o(b._zod,"optin",()=>w.in._zod.optin),o(b._zod,"optout",()=>w.out._zod.optout),o(b._zod,"propValues",()=>w.in._zod.propValues),b._zod.parse=($,W)=>{if(W.direction==="backward"){let G=w.out._zod.run($,W);if(G instanceof Promise)return G.then((X)=>Z0(X,w.in,W));return Z0(G,w.in,W)}let Q=w.in._zod.run($,W);if(Q instanceof Promise)return Q.then((G)=>Z0(G,w.out,W));return Z0(Q,w.out,W)}});function Z0(b,w,$){if(b.issues.length)return b.aborted=!0,b;return w._zod.run({value:b.value,issues:b.issues},$)}var t9=U("$ZodReadonly",(b,w)=>{e.init(b,w),o(b._zod,"propValues",()=>w.innerType._zod.propValues),o(b._zod,"values",()=>w.innerType._zod.values),o(b._zod,"optin",()=>w.innerType._zod.optin),o(b._zod,"optout",()=>w.innerType._zod.optout),b._zod.parse=($,W)=>{if(W.direction==="backward")return w.innerType._zod.run($,W);let Q=w.innerType._zod.run($,W);if(Q instanceof Promise)return Q.then(w9);return w9(Q)}});function w9(b){return b.value=Object.freeze(b.value),b}var r9=U("$ZodCustom",(b,w)=>{Jb.init(b,w),e.init(b,w),b._zod.parse=($,W)=>{return $},b._zod.check=($)=>{let W=$.value,Q=w.fn(W);if(Q instanceof Promise)return Q.then((G)=>$9(G,$,W,b));$9(Q,$,W,b);return}});function $9(b,w,$,W){if(!b){let Q={code:"custom",input:$,inst:W,path:[...W._zod.def.path??[]],continue:!W._zod.def.abort};if(W._zod.def.params)Q.params=W._zod.def.params;w.issues.push(cw(Q))}}var Z7=(b)=>{let w=typeof b;switch(w){case"number":return Number.isNaN(b)?"NaN":"number";case"object":{if(Array.isArray(b))return"array";if(b===null)return"null";if(Object.getPrototypeOf(b)!==Object.prototype&&b.constructor)return b.constructor.name}}return w},j7=()=>{let b={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 w(W){return b[W]??null}let $={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 ${Z7(W.input)}`;case"invalid_value":if(W.values.length===1)return`Invalid input: expected ${U0(W.values[0])}`;return`Invalid option: expected one of ${O0(W.values,"|")}`;case"too_big":{let Q=W.inclusive?"<=":"<",G=w(W.origin);if(G)return`Too big: expected ${W.origin??"value"} to have ${Q}${W.maximum.toString()} ${G.unit??"elements"}`;return`Too big: expected ${W.origin??"value"} to be ${Q}${W.maximum.toString()}`}case"too_small":{let Q=W.inclusive?">=":">",G=w(W.origin);if(G)return`Too small: expected ${W.origin} to have ${Q}${W.minimum.toString()} ${G.unit}`;return`Too small: expected ${W.origin} to be ${Q}${W.minimum.toString()}`}case"invalid_format":{let Q=W;if(Q.format==="starts_with")return`Invalid string: must start with "${Q.prefix}"`;if(Q.format==="ends_with")return`Invalid string: must end with "${Q.suffix}"`;if(Q.format==="includes")return`Invalid string: must include "${Q.includes}"`;if(Q.format==="regex")return`Invalid string: must match pattern ${Q.pattern}`;return`Invalid ${$[Q.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":""}: ${O0(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 A4(){return{localeError:j7()}}var fM=Symbol("ZodOutput"),cM=Symbol("ZodInput");class e9{constructor(){this._map=new WeakMap,this._idmap=new Map}add(b,...w){let $=w[0];if(this._map.set(b,$),$&&typeof $==="object"&&"id"in $){if(this._idmap.has($.id))throw Error(`ID ${$.id} already exists in the registry`);this._idmap.set($.id,b)}return this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(b){let w=this._map.get(b);if(w&&typeof w==="object"&&"id"in w)this._idmap.delete(w.id);return this._map.delete(b),this}get(b){let w=b._zod.parent;if(w){let $={...this.get(w)??{}};delete $.id;let W={...$,...this._map.get(b)};return Object.keys(W).length?W:void 0}return this._map.get(b)}has(b){return this._map.has(b)}}function I7(){return new e9}var M1=I7();function s9(b,w){return new b({type:"string",..._(w)})}function a9(b,w){return new b({type:"string",format:"email",check:"string_format",abort:!1,..._(w)})}function O4(b,w){return new b({type:"string",format:"guid",check:"string_format",abort:!1,..._(w)})}function b8(b,w){return new b({type:"string",format:"uuid",check:"string_format",abort:!1,..._(w)})}function w8(b,w){return new b({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",..._(w)})}function $8(b,w){return new b({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",..._(w)})}function W8(b,w){return new b({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",..._(w)})}function Q8(b,w){return new b({type:"string",format:"url",check:"string_format",abort:!1,..._(w)})}function G8(b,w){return new b({type:"string",format:"emoji",check:"string_format",abort:!1,..._(w)})}function X8(b,w){return new b({type:"string",format:"nanoid",check:"string_format",abort:!1,..._(w)})}function Y8(b,w){return new b({type:"string",format:"cuid",check:"string_format",abort:!1,..._(w)})}function H8(b,w){return new b({type:"string",format:"cuid2",check:"string_format",abort:!1,..._(w)})}function J8(b,w){return new b({type:"string",format:"ulid",check:"string_format",abort:!1,..._(w)})}function D8(b,w){return new b({type:"string",format:"xid",check:"string_format",abort:!1,..._(w)})}function z8(b,w){return new b({type:"string",format:"ksuid",check:"string_format",abort:!1,..._(w)})}function A8(b,w){return new b({type:"string",format:"ipv4",check:"string_format",abort:!1,..._(w)})}function O8(b,w){return new b({type:"string",format:"ipv6",check:"string_format",abort:!1,..._(w)})}function q8(b,w){return new b({type:"string",format:"cidrv4",check:"string_format",abort:!1,..._(w)})}function L8(b,w){return new b({type:"string",format:"cidrv6",check:"string_format",abort:!1,..._(w)})}function U8(b,w){return new b({type:"string",format:"base64",check:"string_format",abort:!1,..._(w)})}function B8(b,w){return new b({type:"string",format:"base64url",check:"string_format",abort:!1,..._(w)})}function F8(b,w){return new b({type:"string",format:"e164",check:"string_format",abort:!1,..._(w)})}function K8(b,w){return new b({type:"string",format:"jwt",check:"string_format",abort:!1,..._(w)})}function P8(b,w){return new b({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,..._(w)})}function M8(b,w){return new b({type:"string",format:"date",check:"string_format",..._(w)})}function Z8(b,w){return new b({type:"string",format:"time",check:"string_format",precision:null,..._(w)})}function j8(b,w){return new b({type:"string",format:"duration",check:"string_format",..._(w)})}function I8(b,w){return new b({type:"number",checks:[],..._(w)})}function V8(b,w){return new b({type:"number",check:"number_format",abort:!1,format:"safeint",..._(w)})}function N8(b,w){return new b({type:"boolean",..._(w)})}function E8(b,w){return new b({type:"null",..._(w)})}function T8(b){return new b({type:"unknown"})}function _8(b,w){return new b({type:"never",..._(w)})}function V0(b,w){return new X4({check:"less_than",..._(w),value:b,inclusive:!1})}function Z1(b,w){return new X4({check:"less_than",..._(w),value:b,inclusive:!0})}function N0(b,w){return new Y4({check:"greater_than",..._(w),value:b,inclusive:!1})}function j1(b,w){return new Y4({check:"greater_than",..._(w),value:b,inclusive:!0})}function E0(b,w){return new xQ({check:"multiple_of",..._(w),value:b})}function T0(b,w){return new yQ({check:"max_length",..._(w),maximum:b})}function gw(b,w){return new hQ({check:"min_length",..._(w),minimum:b})}function _0(b,w){return new fQ({check:"length_equals",..._(w),length:b})}function q4(b,w){return new cQ({check:"string_format",format:"regex",..._(w),pattern:b})}function L4(b){return new gQ({check:"string_format",format:"lowercase",..._(b)})}function U4(b){return new mQ({check:"string_format",format:"uppercase",..._(b)})}function B4(b,w){return new nQ({check:"string_format",format:"includes",..._(w),includes:b})}function F4(b,w){return new lQ({check:"string_format",format:"starts_with",..._(w),prefix:b})}function K4(b,w){return new iQ({check:"string_format",format:"ends_with",..._(w),suffix:b})}function Sw(b){return new pQ({check:"overwrite",tx:b})}function P4(b){return Sw((w)=>w.normalize(b))}function M4(){return Sw((b)=>b.trim())}function Z4(){return Sw((b)=>b.toLowerCase())}function j4(){return Sw((b)=>b.toUpperCase())}function S8(b,w,$){return new b({type:"array",element:w,..._($)})}function R8(b,w,$){let W=_($);return W.abort??(W.abort=!0),new b({type:"custom",check:"custom",fn:w,...W})}function k8(b,w,$){return new b({type:"custom",check:"custom",fn:w,..._($)})}function v8(b){let w=V7(($)=>{return $.addIssue=(W)=>{if(typeof W==="string")$.issues.push(cw(W,$.value,w._zod.def));else{let Q=W;if(Q.fatal)Q.continue=!1;Q.code??(Q.code="custom"),Q.input??(Q.input=$.value),Q.inst??(Q.inst=w),Q.continue??(Q.continue=!w._zod.def.abort),$.issues.push(cw(Q))}},b($.value,$)});return w}function V7(b,w){let $=new Jb({check:"custom",..._(w)});return $._zod.check=b,$}function mw(b){return!!b._zod}function Bw(b,w){if(mw(b))return F1(b,w);return b.safeParse(w)}function S0(b){if(!b)return;let w;if(mw(b))w=b._zod?.def?.shape;else w=b.shape;if(!w)return;if(typeof w==="function")try{return w()}catch{return}return w}function C8(b){if(mw(b)){let G=b._zod?.def;if(G){if(G.value!==void 0)return G.value;if(Array.isArray(G.values)&&G.values.length>0)return G.values[0]}}let $=b._def;if($){if($.value!==void 0)return $.value;if(Array.isArray($.values)&&$.values.length>0)return $.values[0]}let W=b.value;if(W!==void 0)return W;return}var V1={};RW(V1,{time:()=>N4,duration:()=>E4,datetime:()=>I4,date:()=>V4,ZodISOTime:()=>y8,ZodISODuration:()=>h8,ZodISODateTime:()=>x8,ZodISODate:()=>u8});var x8=U("ZodISODateTime",(b,w)=>{q9.init(b,w),bb.init(b,w)});function I4(b){return P8(x8,b)}var u8=U("ZodISODate",(b,w)=>{L9.init(b,w),bb.init(b,w)});function V4(b){return M8(u8,b)}var y8=U("ZodISOTime",(b,w)=>{U9.init(b,w),bb.init(b,w)});function N4(b){return Z8(y8,b)}var h8=U("ZodISODuration",(b,w)=>{B9.init(b,w),bb.init(b,w)});function E4(b){return j8(h8,b)}var f8=(b,w)=>{B0.init(b,w),b.name="ZodError",Object.defineProperties(b,{format:{value:($)=>rW(b,$)},flatten:{value:($)=>tW(b,$)},addIssue:{value:($)=>{b.issues.push($),b.message=JSON.stringify(b.issues,hw,2)}},addIssues:{value:($)=>{b.issues.push(...$),b.message=JSON.stringify(b.issues,hw,2)}},isEmpty:{get(){return b.issues.length===0}}})},VZ=U("ZodError",f8),Eb=U("ZodError",f8,{Parent:Error});var c8=F0(Eb),g8=K0(Eb),m8=B1(Eb),n8=K1(Eb),l8=eW(Eb),i8=sW(Eb),p8=aW(Eb),o8=bQ(Eb),d8=wQ(Eb),t8=$Q(Eb),r8=WQ(Eb),e8=QQ(Eb);var Qb=U("ZodType",(b,w)=>{return e.init(b,w),b.def=w,b.type=w.type,Object.defineProperty(b,"_def",{value:w}),b.check=(...$)=>{return b.clone(n.mergeDefs(w,{checks:[...w.checks??[],...$.map((W)=>typeof W==="function"?{_zod:{check:W,def:{check:"custom"},onattach:[]}}:W)]}))},b.clone=($,W)=>xb(b,$,W),b.brand=()=>b,b.register=($,W)=>{return $.add(b,W),b},b.parse=($,W)=>c8(b,$,W,{callee:b.parse}),b.safeParse=($,W)=>m8(b,$,W),b.parseAsync=async($,W)=>g8(b,$,W,{callee:b.parseAsync}),b.safeParseAsync=async($,W)=>n8(b,$,W),b.spa=b.safeParseAsync,b.encode=($,W)=>l8(b,$,W),b.decode=($,W)=>i8(b,$,W),b.encodeAsync=async($,W)=>p8(b,$,W),b.decodeAsync=async($,W)=>o8(b,$,W),b.safeEncode=($,W)=>d8(b,$,W),b.safeDecode=($,W)=>t8(b,$,W),b.safeEncodeAsync=async($,W)=>r8(b,$,W),b.safeDecodeAsync=async($,W)=>e8(b,$,W),b.refine=($,W)=>b.check(MA($,W)),b.superRefine=($)=>b.check(ZA($)),b.overwrite=($)=>b.check(Sw($)),b.optional=()=>Wb(b),b.nullable=()=>bG(b),b.nullish=()=>Wb(bG(b)),b.nonoptional=($)=>LA(b,$),b.array=()=>f(b),b.or=($)=>r([b,$]),b.and=($)=>k0(b,$),b.transform=($)=>_4(b,GG($)),b.default=($)=>AA(b,$),b.prefault=($)=>qA(b,$),b.catch=($)=>BA(b,$),b.pipe=($)=>_4(b,$),b.readonly=()=>PA(b),b.describe=($)=>{let W=b.clone();return M1.add(W,{description:$}),W},Object.defineProperty(b,"description",{get(){return M1.get(b)?.description},configurable:!0}),b.meta=(...$)=>{if($.length===0)return M1.get(b);let W=b.clone();return M1.add(W,$[0]),W},b.isOptional=()=>b.safeParse(void 0).success,b.isNullable=()=>b.safeParse(null).success,b}),wG=U("_ZodString",(b,w)=>{I0.init(b,w),Qb.init(b,w);let $=b._zod.bag;b.format=$.format??null,b.minLength=$.minimum??null,b.maxLength=$.maximum??null,b.regex=(...W)=>b.check(q4(...W)),b.includes=(...W)=>b.check(B4(...W)),b.startsWith=(...W)=>b.check(F4(...W)),b.endsWith=(...W)=>b.check(K4(...W)),b.min=(...W)=>b.check(gw(...W)),b.max=(...W)=>b.check(T0(...W)),b.length=(...W)=>b.check(_0(...W)),b.nonempty=(...W)=>b.check(gw(1,...W)),b.lowercase=(W)=>b.check(L4(W)),b.uppercase=(W)=>b.check(U4(W)),b.trim=()=>b.check(M4()),b.normalize=(...W)=>b.check(P4(...W)),b.toLowerCase=()=>b.check(Z4()),b.toUpperCase=()=>b.check(j4())}),C7=U("ZodString",(b,w)=>{I0.init(b,w),wG.init(b,w),b.email=($)=>b.check(a9(x7,$)),b.url=($)=>b.check(Q8(u7,$)),b.jwt=($)=>b.check(K8(e7,$)),b.emoji=($)=>b.check(G8(y7,$)),b.guid=($)=>b.check(O4(s8,$)),b.uuid=($)=>b.check(b8(R0,$)),b.uuidv4=($)=>b.check(w8(R0,$)),b.uuidv6=($)=>b.check($8(R0,$)),b.uuidv7=($)=>b.check(W8(R0,$)),b.nanoid=($)=>b.check(X8(h7,$)),b.guid=($)=>b.check(O4(s8,$)),b.cuid=($)=>b.check(Y8(f7,$)),b.cuid2=($)=>b.check(H8(c7,$)),b.ulid=($)=>b.check(J8(g7,$)),b.base64=($)=>b.check(U8(d7,$)),b.base64url=($)=>b.check(B8(t7,$)),b.xid=($)=>b.check(D8(m7,$)),b.ksuid=($)=>b.check(z8(n7,$)),b.ipv4=($)=>b.check(A8(l7,$)),b.ipv6=($)=>b.check(O8(i7,$)),b.cidrv4=($)=>b.check(q8(p7,$)),b.cidrv6=($)=>b.check(L8(o7,$)),b.e164=($)=>b.check(F8(r7,$)),b.datetime=($)=>b.check(I4($)),b.date=($)=>b.check(V4($)),b.time=($)=>b.check(N4($)),b.duration=($)=>b.check(E4($))});function L(b){return s9(C7,b)}var bb=U("ZodStringFormat",(b,w)=>{s.init(b,w),wG.init(b,w)}),x7=U("ZodEmail",(b,w)=>{G9.init(b,w),bb.init(b,w)});var s8=U("ZodGUID",(b,w)=>{W9.init(b,w),bb.init(b,w)});var R0=U("ZodUUID",(b,w)=>{Q9.init(b,w),bb.init(b,w)});var u7=U("ZodURL",(b,w)=>{X9.init(b,w),bb.init(b,w)});var y7=U("ZodEmoji",(b,w)=>{Y9.init(b,w),bb.init(b,w)});var h7=U("ZodNanoID",(b,w)=>{H9.init(b,w),bb.init(b,w)});var f7=U("ZodCUID",(b,w)=>{J9.init(b,w),bb.init(b,w)});var c7=U("ZodCUID2",(b,w)=>{D9.init(b,w),bb.init(b,w)});var g7=U("ZodULID",(b,w)=>{z9.init(b,w),bb.init(b,w)});var m7=U("ZodXID",(b,w)=>{A9.init(b,w),bb.init(b,w)});var n7=U("ZodKSUID",(b,w)=>{O9.init(b,w),bb.init(b,w)});var l7=U("ZodIPv4",(b,w)=>{F9.init(b,w),bb.init(b,w)});var i7=U("ZodIPv6",(b,w)=>{K9.init(b,w),bb.init(b,w)});var p7=U("ZodCIDRv4",(b,w)=>{P9.init(b,w),bb.init(b,w)});var o7=U("ZodCIDRv6",(b,w)=>{M9.init(b,w),bb.init(b,w)});var d7=U("ZodBase64",(b,w)=>{j9.init(b,w),bb.init(b,w)});var t7=U("ZodBase64URL",(b,w)=>{I9.init(b,w),bb.init(b,w)});var r7=U("ZodE164",(b,w)=>{V9.init(b,w),bb.init(b,w)});var e7=U("ZodJWT",(b,w)=>{N9.init(b,w),bb.init(b,w)});var $G=U("ZodNumber",(b,w)=>{D4.init(b,w),Qb.init(b,w),b.gt=(W,Q)=>b.check(N0(W,Q)),b.gte=(W,Q)=>b.check(j1(W,Q)),b.min=(W,Q)=>b.check(j1(W,Q)),b.lt=(W,Q)=>b.check(V0(W,Q)),b.lte=(W,Q)=>b.check(Z1(W,Q)),b.max=(W,Q)=>b.check(Z1(W,Q)),b.int=(W)=>b.check(a8(W)),b.safe=(W)=>b.check(a8(W)),b.positive=(W)=>b.check(N0(0,W)),b.nonnegative=(W)=>b.check(j1(0,W)),b.negative=(W)=>b.check(V0(0,W)),b.nonpositive=(W)=>b.check(Z1(0,W)),b.multipleOf=(W,Q)=>b.check(E0(W,Q)),b.step=(W,Q)=>b.check(E0(W,Q)),b.finite=()=>b;let $=b._zod.bag;b.minValue=Math.max($.minimum??Number.NEGATIVE_INFINITY,$.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,b.maxValue=Math.min($.maximum??Number.POSITIVE_INFINITY,$.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,b.isInt=($.format??"").includes("int")||Number.isSafeInteger($.multipleOf??0.5),b.isFinite=!0,b.format=$.format??null});function p(b){return I8($G,b)}var s7=U("ZodNumberFormat",(b,w)=>{E9.init(b,w),$G.init(b,w)});function a8(b){return V8(s7,b)}var a7=U("ZodBoolean",(b,w)=>{T9.init(b,w),Qb.init(b,w)});function Hb(b){return N8(a7,b)}var bA=U("ZodNull",(b,w)=>{_9.init(b,w),Qb.init(b,w)});function S4(b){return E8(bA,b)}var wA=U("ZodUnknown",(b,w)=>{S9.init(b,w),Qb.init(b,w)});function wb(){return T8(wA)}var $A=U("ZodNever",(b,w)=>{R9.init(b,w),Qb.init(b,w)});function WA(b){return _8($A,b)}var QA=U("ZodArray",(b,w)=>{k9.init(b,w),Qb.init(b,w),b.element=w.element,b.min=($,W)=>b.check(gw($,W)),b.nonempty=($)=>b.check(gw(1,$)),b.max=($,W)=>b.check(T0($,W)),b.length=($,W)=>b.check(_0($,W)),b.unwrap=()=>b.element});function f(b,w){return S8(QA,b,w)}var WG=U("ZodObject",(b,w)=>{x9.init(b,w),Qb.init(b,w),n.defineLazy(b,"shape",()=>{return w.shape}),b.keyof=()=>Pb(Object.keys(b._zod.def.shape)),b.catchall=($)=>b.clone({...b._zod.def,catchall:$}),b.passthrough=()=>b.clone({...b._zod.def,catchall:wb()}),b.loose=()=>b.clone({...b._zod.def,catchall:wb()}),b.strict=()=>b.clone({...b._zod.def,catchall:WA()}),b.strip=()=>b.clone({...b._zod.def,catchall:void 0}),b.extend=($)=>{return n.extend(b,$)},b.safeExtend=($)=>{return n.safeExtend(b,$)},b.merge=($)=>n.merge(b,$),b.pick=($)=>n.pick(b,$),b.omit=($)=>n.omit(b,$),b.partial=(...$)=>n.partial(XG,b,$[0]),b.required=(...$)=>n.required(YG,b,$[0])});function V(b,w){let $={type:"object",shape:b??{},...n.normalizeParams(w)};return new WG($)}function Ub(b,w){return new WG({type:"object",shape:b,catchall:wb(),...n.normalizeParams(w)})}var QG=U("ZodUnion",(b,w)=>{z4.init(b,w),Qb.init(b,w),b.options=w.options});function r(b,w){return new QG({type:"union",options:b,...n.normalizeParams(w)})}var GA=U("ZodDiscriminatedUnion",(b,w)=>{QG.init(b,w),u9.init(b,w)});function R4(b,w,$){return new GA({type:"union",options:w,discriminator:b,...n.normalizeParams($)})}var XA=U("ZodIntersection",(b,w)=>{y9.init(b,w),Qb.init(b,w)});function k0(b,w){return new XA({type:"intersection",left:b,right:w})}var YA=U("ZodRecord",(b,w)=>{h9.init(b,w),Qb.init(b,w),b.keyType=w.keyType,b.valueType=w.valueType});function $b(b,w,$){return new YA({type:"record",keyType:b,valueType:w,...n.normalizeParams($)})}var T4=U("ZodEnum",(b,w)=>{f9.init(b,w),Qb.init(b,w),b.enum=w.entries,b.options=Object.values(w.entries);let $=new Set(Object.keys(w.entries));b.extract=(W,Q)=>{let G={};for(let X of W)if($.has(X))G[X]=w.entries[X];else throw Error(`Key ${X} not found in enum`);return new T4({...w,checks:[],...n.normalizeParams(Q),entries:G})},b.exclude=(W,Q)=>{let G={...w.entries};for(let X of W)if($.has(X))delete G[X];else throw Error(`Key ${X} not found in enum`);return new T4({...w,checks:[],...n.normalizeParams(Q),entries:G})}});function Pb(b,w){let $=Array.isArray(b)?Object.fromEntries(b.map((W)=>[W,W])):b;return new T4({type:"enum",entries:$,...n.normalizeParams(w)})}var HA=U("ZodLiteral",(b,w)=>{c9.init(b,w),Qb.init(b,w),b.values=new Set(w.values),Object.defineProperty(b,"value",{get(){if(w.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return w.values[0]}})});function N(b,w){return new HA({type:"literal",values:Array.isArray(b)?b:[b],...n.normalizeParams(w)})}var JA=U("ZodTransform",(b,w)=>{g9.init(b,w),Qb.init(b,w),b._zod.parse=($,W)=>{if(W.direction==="backward")throw new A1(b.constructor.name);$.addIssue=(G)=>{if(typeof G==="string")$.issues.push(n.issue(G,$.value,w));else{let X=G;if(X.fatal)X.continue=!1;X.code??(X.code="custom"),X.input??(X.input=$.value),X.inst??(X.inst=b),$.issues.push(n.issue(X))}};let Q=w.transform($.value,$);if(Q instanceof Promise)return Q.then((G)=>{return $.value=G,$});return $.value=Q,$}});function GG(b){return new JA({type:"transform",transform:b})}var XG=U("ZodOptional",(b,w)=>{m9.init(b,w),Qb.init(b,w),b.unwrap=()=>b._zod.def.innerType});function Wb(b){return new XG({type:"optional",innerType:b})}var DA=U("ZodNullable",(b,w)=>{n9.init(b,w),Qb.init(b,w),b.unwrap=()=>b._zod.def.innerType});function bG(b){return new DA({type:"nullable",innerType:b})}var zA=U("ZodDefault",(b,w)=>{l9.init(b,w),Qb.init(b,w),b.unwrap=()=>b._zod.def.innerType,b.removeDefault=b.unwrap});function AA(b,w){return new zA({type:"default",innerType:b,get defaultValue(){return typeof w==="function"?w():n.shallowClone(w)}})}var OA=U("ZodPrefault",(b,w)=>{i9.init(b,w),Qb.init(b,w),b.unwrap=()=>b._zod.def.innerType});function qA(b,w){return new OA({type:"prefault",innerType:b,get defaultValue(){return typeof w==="function"?w():n.shallowClone(w)}})}var YG=U("ZodNonOptional",(b,w)=>{p9.init(b,w),Qb.init(b,w),b.unwrap=()=>b._zod.def.innerType});function LA(b,w){return new YG({type:"nonoptional",innerType:b,...n.normalizeParams(w)})}var UA=U("ZodCatch",(b,w)=>{o9.init(b,w),Qb.init(b,w),b.unwrap=()=>b._zod.def.innerType,b.removeCatch=b.unwrap});function BA(b,w){return new UA({type:"catch",innerType:b,catchValue:typeof w==="function"?w:()=>w})}var FA=U("ZodPipe",(b,w)=>{d9.init(b,w),Qb.init(b,w),b.in=w.in,b.out=w.out});function _4(b,w){return new FA({type:"pipe",in:b,out:w})}var KA=U("ZodReadonly",(b,w)=>{t9.init(b,w),Qb.init(b,w),b.unwrap=()=>b._zod.def.innerType});function PA(b){return new KA({type:"readonly",innerType:b})}var HG=U("ZodCustom",(b,w)=>{r9.init(b,w),Qb.init(b,w)});function JG(b,w){return R8(HG,b??(()=>!0),w)}function MA(b,w={}){return k8(HG,b,w)}function ZA(b){return v8(b)}function k4(b,w){return _4(GG(b),w)}Sb(A4());var v4="2025-11-25";var DG=[v4,"2025-06-18","2025-03-26","2024-11-05","2024-10-07"],Fw="io.modelcontextprotocol/related-task",C0="2.0",Db=JG((b)=>b!==null&&(typeof b==="object"||typeof b==="function")),zG=r([L(),p().int()]),AG=L(),Pj=Ub({ttl:r([p(),S4()]).optional(),pollInterval:p().optional()}),jA=V({ttl:p().optional()}),IA=V({taskId:L()}),C4=Ub({progressToken:zG.optional(),[Fw]:IA.optional()}),Tb=V({_meta:C4.optional()}),N1=Tb.extend({task:jA.optional()}),OG=(b)=>N1.safeParse(b).success,zb=V({method:L(),params:Tb.loose().optional()}),Rb=V({_meta:C4.optional()}),kb=V({method:L(),params:Rb.loose().optional()}),Ab=Ub({_meta:C4.optional()}),x0=r([L(),p().int()]),qG=V({jsonrpc:N(C0),id:x0,...zb.shape}).strict(),x4=(b)=>qG.safeParse(b).success,LG=V({jsonrpc:N(C0),...kb.shape}).strict(),UG=(b)=>LG.safeParse(b).success,u4=V({jsonrpc:N(C0),id:x0,result:Ab}).strict(),E1=(b)=>u4.safeParse(b).success;var c;(function(b){b[b.ConnectionClosed=-32000]="ConnectionClosed",b[b.RequestTimeout=-32001]="RequestTimeout",b[b.ParseError=-32700]="ParseError",b[b.InvalidRequest=-32600]="InvalidRequest",b[b.MethodNotFound=-32601]="MethodNotFound",b[b.InvalidParams=-32602]="InvalidParams",b[b.InternalError=-32603]="InternalError",b[b.UrlElicitationRequired=-32042]="UrlElicitationRequired"})(c||(c={}));var y4=V({jsonrpc:N(C0),id:x0.optional(),error:V({code:p().int(),message:L(),data:wb().optional()})}).strict();var BG=(b)=>y4.safeParse(b).success;var Mj=r([qG,LG,u4,y4]),Zj=r([u4,y4]),u0=Ab.strict(),VA=Rb.extend({requestId:x0.optional(),reason:L().optional()}),y0=kb.extend({method:N("notifications/cancelled"),params:VA}),NA=V({src:L(),mimeType:L().optional(),sizes:f(L()).optional(),theme:Pb(["light","dark"]).optional()}),T1=V({icons:f(NA).optional()}),nw=V({name:L(),title:L().optional()}),FG=nw.extend({...nw.shape,...T1.shape,version:L(),websiteUrl:L().optional(),description:L().optional()}),EA=k0(V({applyDefaults:Hb().optional()}),$b(L(),wb())),TA=k4((b)=>{if(b&&typeof b==="object"&&!Array.isArray(b)){if(Object.keys(b).length===0)return{form:{}}}return b},k0(V({form:EA.optional(),url:Db.optional()}),$b(L(),wb()).optional())),_A=Ub({list:Db.optional(),cancel:Db.optional(),requests:Ub({sampling:Ub({createMessage:Db.optional()}).optional(),elicitation:Ub({create:Db.optional()}).optional()}).optional()}),SA=Ub({list:Db.optional(),cancel:Db.optional(),requests:Ub({tools:Ub({call:Db.optional()}).optional()}).optional()}),RA=V({experimental:$b(L(),Db).optional(),sampling:V({context:Db.optional(),tools:Db.optional()}).optional(),elicitation:TA.optional(),roots:V({listChanged:Hb().optional()}).optional(),tasks:_A.optional()}),kA=Tb.extend({protocolVersion:L(),capabilities:RA,clientInfo:FG}),h4=zb.extend({method:N("initialize"),params:kA});var vA=V({experimental:$b(L(),Db).optional(),logging:Db.optional(),completions:Db.optional(),prompts:V({listChanged:Hb().optional()}).optional(),resources:V({subscribe:Hb().optional(),listChanged:Hb().optional()}).optional(),tools:V({listChanged:Hb().optional()}).optional(),tasks:SA.optional()}),CA=Ab.extend({protocolVersion:L(),capabilities:vA,serverInfo:FG,instructions:L().optional()}),f4=kb.extend({method:N("notifications/initialized"),params:Rb.optional()});var h0=zb.extend({method:N("ping"),params:Tb.optional()}),xA=V({progress:p(),total:Wb(p()),message:Wb(L())}),uA=V({...Rb.shape,...xA.shape,progressToken:zG}),f0=kb.extend({method:N("notifications/progress"),params:uA}),yA=Tb.extend({cursor:AG.optional()}),_1=zb.extend({params:yA.optional()}),S1=Ab.extend({nextCursor:AG.optional()}),hA=Pb(["working","input_required","completed","failed","cancelled"]),R1=V({taskId:L(),status:hA,ttl:r([p(),S4()]),createdAt:L(),lastUpdatedAt:L(),pollInterval:Wb(p()),statusMessage:Wb(L())}),lw=Ab.extend({task:R1}),fA=Rb.merge(R1),k1=kb.extend({method:N("notifications/tasks/status"),params:fA}),c0=zb.extend({method:N("tasks/get"),params:Tb.extend({taskId:L()})}),g0=Ab.merge(R1),m0=zb.extend({method:N("tasks/result"),params:Tb.extend({taskId:L()})}),jj=Ab.loose(),n0=_1.extend({method:N("tasks/list")}),l0=S1.extend({tasks:f(R1)}),i0=zb.extend({method:N("tasks/cancel"),params:Tb.extend({taskId:L()})}),KG=Ab.merge(R1),PG=V({uri:L(),mimeType:Wb(L()),_meta:$b(L(),wb()).optional()}),MG=PG.extend({text:L()}),c4=L().refine((b)=>{try{return atob(b),!0}catch{return!1}},{message:"Invalid Base64 string"}),ZG=PG.extend({blob:c4}),v1=Pb(["user","assistant"]),iw=V({audience:f(v1).optional(),priority:p().min(0).max(1).optional(),lastModified:V1.datetime({offset:!0}).optional()}),jG=V({...nw.shape,...T1.shape,uri:L(),description:Wb(L()),mimeType:Wb(L()),annotations:iw.optional(),_meta:Wb(Ub({}))}),cA=V({...nw.shape,...T1.shape,uriTemplate:L(),description:Wb(L()),mimeType:Wb(L()),annotations:iw.optional(),_meta:Wb(Ub({}))}),g4=_1.extend({method:N("resources/list")}),gA=S1.extend({resources:f(jG)}),mA=_1.extend({method:N("resources/templates/list")}),nA=S1.extend({resourceTemplates:f(cA)}),m4=Tb.extend({uri:L()}),lA=m4,n4=zb.extend({method:N("resources/read"),params:lA}),iA=Ab.extend({contents:f(r([MG,ZG]))}),pA=kb.extend({method:N("notifications/resources/list_changed"),params:Rb.optional()}),oA=m4,dA=zb.extend({method:N("resources/subscribe"),params:oA}),tA=m4,rA=zb.extend({method:N("resources/unsubscribe"),params:tA}),eA=Rb.extend({uri:L()}),sA=kb.extend({method:N("notifications/resources/updated"),params:eA}),aA=V({name:L(),description:Wb(L()),required:Wb(Hb())}),b5=V({...nw.shape,...T1.shape,description:Wb(L()),arguments:Wb(f(aA)),_meta:Wb(Ub({}))}),w5=_1.extend({method:N("prompts/list")}),$5=S1.extend({prompts:f(b5)}),W5=Tb.extend({name:L(),arguments:$b(L(),L()).optional()}),Q5=zb.extend({method:N("prompts/get"),params:W5}),l4=V({type:N("text"),text:L(),annotations:iw.optional(),_meta:$b(L(),wb()).optional()}),i4=V({type:N("image"),data:c4,mimeType:L(),annotations:iw.optional(),_meta:$b(L(),wb()).optional()}),p4=V({type:N("audio"),data:c4,mimeType:L(),annotations:iw.optional(),_meta:$b(L(),wb()).optional()}),G5=V({type:N("tool_use"),name:L(),id:L(),input:$b(L(),wb()),_meta:$b(L(),wb()).optional()}),X5=V({type:N("resource"),resource:r([MG,ZG]),annotations:iw.optional(),_meta:$b(L(),wb()).optional()}),Y5=jG.extend({type:N("resource_link")}),o4=r([l4,i4,p4,Y5,X5]),H5=V({role:v1,content:o4}),J5=Ab.extend({description:L().optional(),messages:f(H5)}),D5=kb.extend({method:N("notifications/prompts/list_changed"),params:Rb.optional()}),z5=V({title:L().optional(),readOnlyHint:Hb().optional(),destructiveHint:Hb().optional(),idempotentHint:Hb().optional(),openWorldHint:Hb().optional()}),A5=V({taskSupport:Pb(["required","optional","forbidden"]).optional()}),IG=V({...nw.shape,...T1.shape,description:L().optional(),inputSchema:V({type:N("object"),properties:$b(L(),Db).optional(),required:f(L()).optional()}).catchall(wb()),outputSchema:V({type:N("object"),properties:$b(L(),Db).optional(),required:f(L()).optional()}).catchall(wb()).optional(),annotations:z5.optional(),execution:A5.optional(),_meta:$b(L(),wb()).optional()}),d4=_1.extend({method:N("tools/list")}),O5=S1.extend({tools:f(IG)}),p0=Ab.extend({content:f(o4).default([]),structuredContent:$b(L(),wb()).optional(),isError:Hb().optional()}),Ij=p0.or(Ab.extend({toolResult:wb()})),q5=N1.extend({name:L(),arguments:$b(L(),wb()).optional()}),C1=zb.extend({method:N("tools/call"),params:q5}),L5=kb.extend({method:N("notifications/tools/list_changed"),params:Rb.optional()}),Vj=V({autoRefresh:Hb().default(!0),debounceMs:p().int().nonnegative().default(300)}),x1=Pb(["debug","info","notice","warning","error","critical","alert","emergency"]),U5=Tb.extend({level:x1}),t4=zb.extend({method:N("logging/setLevel"),params:U5}),B5=Rb.extend({level:x1,logger:L().optional(),data:wb()}),F5=kb.extend({method:N("notifications/message"),params:B5}),K5=V({name:L().optional()}),P5=V({hints:f(K5).optional(),costPriority:p().min(0).max(1).optional(),speedPriority:p().min(0).max(1).optional(),intelligencePriority:p().min(0).max(1).optional()}),M5=V({mode:Pb(["auto","required","none"]).optional()}),Z5=V({type:N("tool_result"),toolUseId:L().describe("The unique identifier for the corresponding tool call."),content:f(o4).default([]),structuredContent:V({}).loose().optional(),isError:Hb().optional(),_meta:$b(L(),wb()).optional()}),j5=R4("type",[l4,i4,p4]),v0=R4("type",[l4,i4,p4,G5,Z5]),I5=V({role:v1,content:r([v0,f(v0)]),_meta:$b(L(),wb()).optional()}),V5=N1.extend({messages:f(I5),modelPreferences:P5.optional(),systemPrompt:L().optional(),includeContext:Pb(["none","thisServer","allServers"]).optional(),temperature:p().optional(),maxTokens:p().int(),stopSequences:f(L()).optional(),metadata:Db.optional(),tools:f(IG).optional(),toolChoice:M5.optional()}),N5=zb.extend({method:N("sampling/createMessage"),params:V5}),r4=Ab.extend({model:L(),stopReason:Wb(Pb(["endTurn","stopSequence","maxTokens"]).or(L())),role:v1,content:j5}),e4=Ab.extend({model:L(),stopReason:Wb(Pb(["endTurn","stopSequence","maxTokens","toolUse"]).or(L())),role:v1,content:r([v0,f(v0)])}),E5=V({type:N("boolean"),title:L().optional(),description:L().optional(),default:Hb().optional()}),T5=V({type:N("string"),title:L().optional(),description:L().optional(),minLength:p().optional(),maxLength:p().optional(),format:Pb(["email","uri","date","date-time"]).optional(),default:L().optional()}),_5=V({type:Pb(["number","integer"]),title:L().optional(),description:L().optional(),minimum:p().optional(),maximum:p().optional(),default:p().optional()}),S5=V({type:N("string"),title:L().optional(),description:L().optional(),enum:f(L()),default:L().optional()}),R5=V({type:N("string"),title:L().optional(),description:L().optional(),oneOf:f(V({const:L(),title:L()})),default:L().optional()}),k5=V({type:N("string"),title:L().optional(),description:L().optional(),enum:f(L()),enumNames:f(L()).optional(),default:L().optional()}),v5=r([S5,R5]),C5=V({type:N("array"),title:L().optional(),description:L().optional(),minItems:p().optional(),maxItems:p().optional(),items:V({type:N("string"),enum:f(L())}),default:f(L()).optional()}),x5=V({type:N("array"),title:L().optional(),description:L().optional(),minItems:p().optional(),maxItems:p().optional(),items:V({anyOf:f(V({const:L(),title:L()}))}),default:f(L()).optional()}),u5=r([C5,x5]),y5=r([k5,v5,u5]),h5=r([y5,E5,T5,_5]),f5=N1.extend({mode:N("form").optional(),message:L(),requestedSchema:V({type:N("object"),properties:$b(L(),h5),required:f(L()).optional()})}),c5=N1.extend({mode:N("url"),message:L(),elicitationId:L(),url:L().url()}),g5=r([f5,c5]),m5=zb.extend({method:N("elicitation/create"),params:g5}),n5=Rb.extend({elicitationId:L()}),l5=kb.extend({method:N("notifications/elicitation/complete"),params:n5}),o0=Ab.extend({action:Pb(["accept","decline","cancel"]),content:k4((b)=>b===null?void 0:b,$b(L(),r([L(),p(),Hb(),f(L())])).optional())}),i5=V({type:N("ref/resource"),uri:L()});var p5=V({type:N("ref/prompt"),name:L()}),o5=Tb.extend({ref:r([p5,i5]),argument:V({name:L(),value:L()}),context:V({arguments:$b(L(),L()).optional()}).optional()}),d5=zb.extend({method:N("completion/complete"),params:o5});var t5=Ab.extend({completion:Ub({values:f(L()).max(100),total:Wb(p().int()),hasMore:Wb(Hb())})}),r5=V({uri:L().startsWith("file://"),name:L().optional(),_meta:$b(L(),wb()).optional()}),e5=zb.extend({method:N("roots/list"),params:Tb.optional()}),s4=Ab.extend({roots:f(r5)}),s5=kb.extend({method:N("notifications/roots/list_changed"),params:Rb.optional()}),Nj=r([h0,h4,d5,t4,Q5,w5,g4,mA,n4,dA,rA,C1,d4,c0,m0,n0,i0]),Ej=r([y0,f0,f4,s5,k1]),Tj=r([u0,r4,e4,o0,s4,g0,l0,lw]),_j=r([h0,N5,m5,e5,c0,m0,n0,i0]),Sj=r([y0,f0,F5,sA,pA,L5,D5,k1,l5]),Rj=r([u0,CA,t5,J5,$5,gA,nA,iA,p0,O5,g0,l0,lw]);class x extends Error{constructor(b,w,$){super(`MCP error ${b}: ${w}`);this.code=b,this.data=$,this.name="McpError"}static fromError(b,w,$){if(b===c.UrlElicitationRequired&&$){let W=$;if(W.elicitations)return new VG(W.elicitations,w)}return new x(b,w,$)}}class VG extends x{constructor(b,w=`URL elicitation${b.length>1?"s":""} required`){super(c.UrlElicitationRequired,w,{elicitations:b})}get elicitations(){return this.data?.elicitations??[]}}function Kw(b){return b==="completed"||b==="failed"||b==="cancelled"}var a5=Symbol("Let zodToJsonSchema decide on which parser to use");var DI=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function a4(b){let $=S0(b)?.method;if(!$)throw Error("Schema is missing a method literal");let W=C8($);if(typeof W!=="string")throw Error("Schema method literal must be a string");return W}function b6(b,w){let $=Bw(b,w);if(!$.success)throw $.error;return $.data}var GO=60000;class w6{constructor(b){if(this._options=b,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(y0,(w)=>{this._oncancel(w)}),this.setNotificationHandler(f0,(w)=>{this._onprogress(w)}),this.setRequestHandler(h0,(w)=>({})),this._taskStore=b?.taskStore,this._taskMessageQueue=b?.taskMessageQueue,this._taskStore)this.setRequestHandler(c0,async(w,$)=>{let W=await this._taskStore.getTask(w.params.taskId,$.sessionId);if(!W)throw new x(c.InvalidParams,"Failed to retrieve task: Task not found");return{...W}}),this.setRequestHandler(m0,async(w,$)=>{let W=async()=>{let Q=w.params.taskId;if(this._taskMessageQueue){let X;while(X=await this._taskMessageQueue.dequeue(Q,$.sessionId)){if(X.type==="response"||X.type==="error"){let Y=X.message,H=Y.id,J=this._requestResolvers.get(H);if(J)if(this._requestResolvers.delete(H),X.type==="response")J(Y);else{let D=Y,z=new x(D.error.code,D.error.message,D.error.data);J(z)}else{let D=X.type==="response"?"Response":"Error";this._onerror(Error(`${D} handler missing for request ${H}`))}continue}await this._transport?.send(X.message,{relatedRequestId:$.requestId})}}let G=await this._taskStore.getTask(Q,$.sessionId);if(!G)throw new x(c.InvalidParams,`Task not found: ${Q}`);if(!Kw(G.status))return await this._waitForTaskUpdate(Q,$.signal),await W();if(Kw(G.status)){let X=await this._taskStore.getTaskResult(Q,$.sessionId);return this._clearTaskQueue(Q),{...X,_meta:{...X._meta,[Fw]:{taskId:Q}}}}return await W()};return await W()}),this.setRequestHandler(n0,async(w,$)=>{try{let{tasks:W,nextCursor:Q}=await this._taskStore.listTasks(w.params?.cursor,$.sessionId);return{tasks:W,nextCursor:Q,_meta:{}}}catch(W){throw new x(c.InvalidParams,`Failed to list tasks: ${W instanceof Error?W.message:String(W)}`)}}),this.setRequestHandler(i0,async(w,$)=>{try{let W=await this._taskStore.getTask(w.params.taskId,$.sessionId);if(!W)throw new x(c.InvalidParams,`Task not found: ${w.params.taskId}`);if(Kw(W.status))throw new x(c.InvalidParams,`Cannot cancel task in terminal status: ${W.status}`);await this._taskStore.updateTaskStatus(w.params.taskId,"cancelled","Client cancelled task execution.",$.sessionId),this._clearTaskQueue(w.params.taskId);let Q=await this._taskStore.getTask(w.params.taskId,$.sessionId);if(!Q)throw new x(c.InvalidParams,`Task not found after cancellation: ${w.params.taskId}`);return{_meta:{},...Q}}catch(W){if(W instanceof x)throw W;throw new x(c.InvalidRequest,`Failed to cancel task: ${W instanceof Error?W.message:String(W)}`)}})}async _oncancel(b){if(!b.params.requestId)return;this._requestHandlerAbortControllers.get(b.params.requestId)?.abort(b.params.reason)}_setupTimeout(b,w,$,W,Q=!1){this._timeoutInfo.set(b,{timeoutId:setTimeout(W,w),startTime:Date.now(),timeout:w,maxTotalTimeout:$,resetTimeoutOnProgress:Q,onTimeout:W})}_resetTimeout(b){let w=this._timeoutInfo.get(b);if(!w)return!1;let $=Date.now()-w.startTime;if(w.maxTotalTimeout&&$>=w.maxTotalTimeout)throw this._timeoutInfo.delete(b),x.fromError(c.RequestTimeout,"Maximum total timeout exceeded",{maxTotalTimeout:w.maxTotalTimeout,totalElapsed:$});return clearTimeout(w.timeoutId),w.timeoutId=setTimeout(w.onTimeout,w.timeout),!0}_cleanupTimeout(b){let w=this._timeoutInfo.get(b);if(w)clearTimeout(w.timeoutId),this._timeoutInfo.delete(b)}async connect(b){this._transport=b;let w=this.transport?.onclose;this._transport.onclose=()=>{w?.(),this._onclose()};let $=this.transport?.onerror;this._transport.onerror=(Q)=>{$?.(Q),this._onerror(Q)};let W=this._transport?.onmessage;this._transport.onmessage=(Q,G)=>{if(W?.(Q,G),E1(Q)||BG(Q))this._onresponse(Q);else if(x4(Q))this._onrequest(Q,G);else if(UG(Q))this._onnotification(Q);else this._onerror(Error(`Unknown message type: ${JSON.stringify(Q)}`))},await this._transport.start()}_onclose(){let b=this._responseHandlers;this._responseHandlers=new Map,this._progressHandlers.clear(),this._taskProgressTokens.clear(),this._pendingDebouncedNotifications.clear();let w=x.fromError(c.ConnectionClosed,"Connection closed");this._transport=void 0,this.onclose?.();for(let $ of b.values())$(w)}_onerror(b){this.onerror?.(b)}_onnotification(b){let w=this._notificationHandlers.get(b.method)??this.fallbackNotificationHandler;if(w===void 0)return;Promise.resolve().then(()=>w(b)).catch(($)=>this._onerror(Error(`Uncaught error in notification handler: ${$}`)))}_onrequest(b,w){let $=this._requestHandlers.get(b.method)??this.fallbackRequestHandler,W=this._transport,Q=b.params?._meta?.[Fw]?.taskId;if($===void 0){let J={jsonrpc:"2.0",id:b.id,error:{code:c.MethodNotFound,message:"Method not found"}};if(Q&&this._taskMessageQueue)this._enqueueTaskMessage(Q,{type:"error",message:J,timestamp:Date.now()},W?.sessionId).catch((D)=>this._onerror(Error(`Failed to enqueue error response: ${D}`)));else W?.send(J).catch((D)=>this._onerror(Error(`Failed to send an error response: ${D}`)));return}let G=new AbortController;this._requestHandlerAbortControllers.set(b.id,G);let X=OG(b.params)?b.params.task:void 0,Y=this._taskStore?this.requestTaskStore(b,W?.sessionId):void 0,H={signal:G.signal,sessionId:W?.sessionId,_meta:b.params?._meta,sendNotification:async(J)=>{let D={relatedRequestId:b.id};if(Q)D.relatedTask={taskId:Q};await this.notification(J,D)},sendRequest:async(J,D,z)=>{let O={...z,relatedRequestId:b.id};if(Q&&!O.relatedTask)O.relatedTask={taskId:Q};let q=O.relatedTask?.taskId??Q;if(q&&Y)await Y.updateTaskStatus(q,"input_required");return await this.request(J,D,O)},authInfo:w?.authInfo,requestId:b.id,requestInfo:w?.requestInfo,taskId:Q,taskStore:Y,taskRequestedTtl:X?.ttl,closeSSEStream:w?.closeSSEStream,closeStandaloneSSEStream:w?.closeStandaloneSSEStream};Promise.resolve().then(()=>{if(X)this.assertTaskHandlerCapability(b.method)}).then(()=>$(b,H)).then(async(J)=>{if(G.signal.aborted)return;let D={result:J,jsonrpc:"2.0",id:b.id};if(Q&&this._taskMessageQueue)await this._enqueueTaskMessage(Q,{type:"response",message:D,timestamp:Date.now()},W?.sessionId);else await W?.send(D)},async(J)=>{if(G.signal.aborted)return;let D={jsonrpc:"2.0",id:b.id,error:{code:Number.isSafeInteger(J.code)?J.code:c.InternalError,message:J.message??"Internal error",...J.data!==void 0&&{data:J.data}}};if(Q&&this._taskMessageQueue)await this._enqueueTaskMessage(Q,{type:"error",message:D,timestamp:Date.now()},W?.sessionId);else await W?.send(D)}).catch((J)=>this._onerror(Error(`Failed to send response: ${J}`))).finally(()=>{this._requestHandlerAbortControllers.delete(b.id)})}_onprogress(b){let{progressToken:w,...$}=b.params,W=Number(w),Q=this._progressHandlers.get(W);if(!Q){this._onerror(Error(`Received a progress notification for an unknown token: ${JSON.stringify(b)}`));return}let G=this._responseHandlers.get(W),X=this._timeoutInfo.get(W);if(X&&G&&X.resetTimeoutOnProgress)try{this._resetTimeout(W)}catch(Y){this._responseHandlers.delete(W),this._progressHandlers.delete(W),this._cleanupTimeout(W),G(Y);return}Q($)}_onresponse(b){let w=Number(b.id),$=this._requestResolvers.get(w);if($){if(this._requestResolvers.delete(w),E1(b))$(b);else{let G=new x(b.error.code,b.error.message,b.error.data);$(G)}return}let W=this._responseHandlers.get(w);if(W===void 0){this._onerror(Error(`Received a response for an unknown message ID: ${JSON.stringify(b)}`));return}this._responseHandlers.delete(w),this._cleanupTimeout(w);let Q=!1;if(E1(b)&&b.result&&typeof b.result==="object"){let G=b.result;if(G.task&&typeof G.task==="object"){let X=G.task;if(typeof X.taskId==="string")Q=!0,this._taskProgressTokens.set(X.taskId,w)}}if(!Q)this._progressHandlers.delete(w);if(E1(b))W(b);else{let G=x.fromError(b.error.code,b.error.message,b.error.data);W(G)}}get transport(){return this._transport}async close(){await this._transport?.close()}async*requestStream(b,w,$){let{task:W}=$??{};if(!W){try{yield{type:"result",result:await this.request(b,w,$)}}catch(G){yield{type:"error",error:G instanceof x?G:new x(c.InternalError,String(G))}}return}let Q;try{let G=await this.request(b,lw,$);if(G.task)Q=G.task.taskId,yield{type:"taskCreated",task:G.task};else throw new x(c.InternalError,"Task creation did not return a task");while(!0){let X=await this.getTask({taskId:Q},$);if(yield{type:"taskStatus",task:X},Kw(X.status)){if(X.status==="completed")yield{type:"result",result:await this.getTaskResult({taskId:Q},w,$)};else if(X.status==="failed")yield{type:"error",error:new x(c.InternalError,`Task ${Q} failed`)};else if(X.status==="cancelled")yield{type:"error",error:new x(c.InternalError,`Task ${Q} was cancelled`)};return}if(X.status==="input_required"){yield{type:"result",result:await this.getTaskResult({taskId:Q},w,$)};return}let Y=X.pollInterval??this._options?.defaultTaskPollInterval??1000;await new Promise((H)=>setTimeout(H,Y)),$?.signal?.throwIfAborted()}}catch(G){yield{type:"error",error:G instanceof x?G:new x(c.InternalError,String(G))}}}request(b,w,$){let{relatedRequestId:W,resumptionToken:Q,onresumptiontoken:G,task:X,relatedTask:Y}=$??{};return new Promise((H,J)=>{let D=(M)=>{J(M)};if(!this._transport){D(Error("Not connected"));return}if(this._options?.enforceStrictCapabilities===!0)try{if(this.assertCapabilityForMethod(b.method),X)this.assertTaskCapability(b.method)}catch(M){D(M);return}$?.signal?.throwIfAborted();let z=this._requestMessageId++,O={...b,jsonrpc:"2.0",id:z};if($?.onprogress)this._progressHandlers.set(z,$.onprogress),O.params={...b.params,_meta:{...b.params?._meta||{},progressToken:z}};if(X)O.params={...O.params,task:X};if(Y)O.params={...O.params,_meta:{...O.params?._meta||{},[Fw]:Y}};let q=(M)=>{this._responseHandlers.delete(z),this._progressHandlers.delete(z),this._cleanupTimeout(z),this._transport?.send({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:z,reason:String(M)}},{relatedRequestId:W,resumptionToken:Q,onresumptiontoken:G}).catch((S)=>this._onerror(Error(`Failed to send cancellation: ${S}`)));let k=M instanceof x?M:new x(c.RequestTimeout,String(M));J(k)};this._responseHandlers.set(z,(M)=>{if($?.signal?.aborted)return;if(M instanceof Error)return J(M);try{let k=Bw(w,M.result);if(!k.success)J(k.error);else H(k.data)}catch(k){J(k)}}),$?.signal?.addEventListener("abort",()=>{q($?.signal?.reason)});let B=$?.timeout??GO,K=()=>q(x.fromError(c.RequestTimeout,"Request timed out",{timeout:B}));this._setupTimeout(z,B,$?.maxTotalTimeout,K,$?.resetTimeoutOnProgress??!1);let Z=Y?.taskId;if(Z){let M=(k)=>{let S=this._responseHandlers.get(z);if(S)S(k);else this._onerror(Error(`Response handler missing for side-channeled request ${z}`))};this._requestResolvers.set(z,M),this._enqueueTaskMessage(Z,{type:"request",message:O,timestamp:Date.now()}).catch((k)=>{this._cleanupTimeout(z),J(k)})}else this._transport.send(O,{relatedRequestId:W,resumptionToken:Q,onresumptiontoken:G}).catch((M)=>{this._cleanupTimeout(z),J(M)})})}async getTask(b,w){return this.request({method:"tasks/get",params:b},g0,w)}async getTaskResult(b,w,$){return this.request({method:"tasks/result",params:b},w,$)}async listTasks(b,w){return this.request({method:"tasks/list",params:b},l0,w)}async cancelTask(b,w){return this.request({method:"tasks/cancel",params:b},KG,w)}async notification(b,w){if(!this._transport)throw Error("Not connected");this.assertNotificationCapability(b.method);let $=w?.relatedTask?.taskId;if($){let X={...b,jsonrpc:"2.0",params:{...b.params,_meta:{...b.params?._meta||{},[Fw]:w.relatedTask}}};await this._enqueueTaskMessage($,{type:"notification",message:X,timestamp:Date.now()});return}if((this._options?.debouncedNotificationMethods??[]).includes(b.method)&&!b.params&&!w?.relatedRequestId&&!w?.relatedTask){if(this._pendingDebouncedNotifications.has(b.method))return;this._pendingDebouncedNotifications.add(b.method),Promise.resolve().then(()=>{if(this._pendingDebouncedNotifications.delete(b.method),!this._transport)return;let X={...b,jsonrpc:"2.0"};if(w?.relatedTask)X={...X,params:{...X.params,_meta:{...X.params?._meta||{},[Fw]:w.relatedTask}}};this._transport?.send(X,w).catch((Y)=>this._onerror(Y))});return}let G={...b,jsonrpc:"2.0"};if(w?.relatedTask)G={...G,params:{...G.params,_meta:{...G.params?._meta||{},[Fw]:w.relatedTask}}};await this._transport.send(G,w)}setRequestHandler(b,w){let $=a4(b);this.assertRequestHandlerCapability($),this._requestHandlers.set($,(W,Q)=>{let G=b6(b,W);return Promise.resolve(w(G,Q))})}removeRequestHandler(b){this._requestHandlers.delete(b)}assertCanSetRequestHandler(b){if(this._requestHandlers.has(b))throw Error(`A request handler for ${b} already exists, which would be overridden`)}setNotificationHandler(b,w){let $=a4(b);this._notificationHandlers.set($,(W)=>{let Q=b6(b,W);return Promise.resolve(w(Q))})}removeNotificationHandler(b){this._notificationHandlers.delete(b)}_cleanupTaskProgressHandler(b){let w=this._taskProgressTokens.get(b);if(w!==void 0)this._progressHandlers.delete(w),this._taskProgressTokens.delete(b)}async _enqueueTaskMessage(b,w,$){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(b,w,$,W)}async _clearTaskQueue(b,w){if(this._taskMessageQueue){let $=await this._taskMessageQueue.dequeueAll(b,w);for(let W of $)if(W.type==="request"&&x4(W.message)){let Q=W.message.id,G=this._requestResolvers.get(Q);if(G)G(new x(c.InternalError,"Task cancelled or completed")),this._requestResolvers.delete(Q);else this._onerror(Error(`Resolver missing for request ${Q} during task ${b} cleanup`))}}}async _waitForTaskUpdate(b,w){let $=this._options?.defaultTaskPollInterval??1000;try{let W=await this._taskStore?.getTask(b);if(W?.pollInterval)$=W.pollInterval}catch{}return new Promise((W,Q)=>{if(w.aborted){Q(new x(c.InvalidRequest,"Request cancelled"));return}let G=setTimeout(W,$);w.addEventListener("abort",()=>{clearTimeout(G),Q(new x(c.InvalidRequest,"Request cancelled"))},{once:!0})})}requestTaskStore(b,w){let $=this._taskStore;if(!$)throw Error("No task store configured");return{createTask:async(W)=>{if(!b)throw Error("No request provided");return await $.createTask(W,b.id,{method:b.method,params:b.params},w)},getTask:async(W)=>{let Q=await $.getTask(W,w);if(!Q)throw new x(c.InvalidParams,"Failed to retrieve task: Task not found");return Q},storeTaskResult:async(W,Q,G)=>{await $.storeTaskResult(W,Q,G,w);let X=await $.getTask(W,w);if(X){let Y=k1.parse({method:"notifications/tasks/status",params:X});if(await this.notification(Y),Kw(X.status))this._cleanupTaskProgressHandler(W)}},getTaskResult:(W)=>{return $.getTaskResult(W,w)},updateTaskStatus:async(W,Q,G)=>{let X=await $.getTask(W,w);if(!X)throw new x(c.InvalidParams,`Task "${W}" not found - it may have been cleaned up`);if(Kw(X.status))throw new x(c.InvalidParams,`Cannot update task "${W}" from terminal status "${X.status}" to "${Q}". Terminal states (completed, failed, cancelled) cannot transition to other states.`);await $.updateTaskStatus(W,Q,G,w);let Y=await $.getTask(W,w);if(Y){let H=k1.parse({method:"notifications/tasks/status",params:Y});if(await this.notification(H),Kw(Y.status))this._cleanupTaskProgressHandler(W)}},listTasks:(W)=>{return $.listTasks(W,w)}}}}function NG(b){return b!==null&&typeof b==="object"&&!Array.isArray(b)}function EG(b,w){let $={...b};for(let W in w){let Q=W,G=w[Q];if(G===void 0)continue;let X=$[Q];if(NG(X)&&NG(G))$[Q]={...X,...G};else $[Q]=G}return $}var QD=SW(t6(),1),GD=SW(WD(),1);function qP(){let b=new QD.default({strict:!1,validateFormats:!0,validateSchema:!1,allErrors:!0});return GD.default(b),b}class GW{constructor(b){this._ajv=b??qP()}getValidator(b){let w="$id"in b&&typeof b.$id==="string"?this._ajv.getSchema(b.$id)??this._ajv.compile(b):this._ajv.compile(b);return($)=>{if(w($))return{valid:!0,data:$,errorMessage:void 0};else return{valid:!1,data:void 0,errorMessage:this._ajv.errorsText(w.errors)}}}}class XW{constructor(b){this._server=b}requestStream(b,w,$){return this._server.requestStream(b,w,$)}async getTask(b,w){return this._server.getTask({taskId:b},w)}async getTaskResult(b,w,$){return this._server.getTaskResult({taskId:b},w,$)}async listTasks(b,w){return this._server.listTasks(b?{cursor:b}:void 0,w)}async cancelTask(b,w){return this._server.cancelTask({taskId:b},w)}}function XD(b,w,$){if(!b)throw Error(`${$} does not support task creation (required for ${w})`);switch(w){case"tools/call":if(!b.tools?.call)throw Error(`${$} does not support task creation for tools/call (required for ${w})`);break;default:break}}function YD(b,w,$){if(!b)throw Error(`${$} does not support task creation (required for ${w})`);switch(w){case"sampling/createMessage":if(!b.sampling?.createMessage)throw Error(`${$} does not support task creation for sampling/createMessage (required for ${w})`);break;case"elicitation/create":if(!b.elicitation?.create)throw Error(`${$} does not support task creation for elicitation/create (required for ${w})`);break;default:break}}class YW extends w6{constructor(b,w){super(w);if(this._serverInfo=b,this._loggingLevels=new Map,this.LOG_LEVEL_SEVERITY=new Map(x1.options.map(($,W)=>[$,W])),this.isMessageIgnored=($,W)=>{let Q=this._loggingLevels.get(W);return Q?this.LOG_LEVEL_SEVERITY.get($)<this.LOG_LEVEL_SEVERITY.get(Q):!1},this._capabilities=w?.capabilities??{},this._instructions=w?.instructions,this._jsonSchemaValidator=w?.jsonSchemaValidator??new GW,this.setRequestHandler(h4,($)=>this._oninitialize($)),this.setNotificationHandler(f4,()=>this.oninitialized?.()),this._capabilities.logging)this.setRequestHandler(t4,async($,W)=>{let Q=W.sessionId||W.requestInfo?.headers["mcp-session-id"]||void 0,{level:G}=$.params,X=x1.safeParse(G);if(X.success)this._loggingLevels.set(Q,X.data);return{}})}get experimental(){if(!this._experimental)this._experimental={tasks:new XW(this)};return this._experimental}registerCapabilities(b){if(this.transport)throw Error("Cannot register capabilities after connecting to transport");this._capabilities=EG(this._capabilities,b)}setRequestHandler(b,w){let W=S0(b)?.method;if(!W)throw Error("Schema is missing a method literal");let Q;if(mw(W)){let X=W;Q=X._zod?.def?.value??X.value}else{let X=W;Q=X._def?.value??X.value}if(typeof Q!=="string")throw Error("Schema method literal must be a string");if(Q==="tools/call"){let X=async(Y,H)=>{let J=Bw(C1,Y);if(!J.success){let q=J.error instanceof Error?J.error.message:String(J.error);throw new x(c.InvalidParams,`Invalid tools/call request: ${q}`)}let{params:D}=J.data,z=await Promise.resolve(w(Y,H));if(D.task){let q=Bw(lw,z);if(!q.success){let B=q.error instanceof Error?q.error.message:String(q.error);throw new x(c.InvalidParams,`Invalid task creation result: ${B}`)}return q.data}let O=Bw(p0,z);if(!O.success){let q=O.error instanceof Error?O.error.message:String(O.error);throw new x(c.InvalidParams,`Invalid tools/call result: ${q}`)}return O.data};return super.setRequestHandler(b,X)}return super.setRequestHandler(b,w)}assertCapabilityForMethod(b){switch(b){case"sampling/createMessage":if(!this._clientCapabilities?.sampling)throw Error(`Client does not support sampling (required for ${b})`);break;case"elicitation/create":if(!this._clientCapabilities?.elicitation)throw Error(`Client does not support elicitation (required for ${b})`);break;case"roots/list":if(!this._clientCapabilities?.roots)throw Error(`Client does not support listing roots (required for ${b})`);break;case"ping":break}}assertNotificationCapability(b){switch(b){case"notifications/message":if(!this._capabilities.logging)throw Error(`Server does not support logging (required for ${b})`);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 ${b})`);break;case"notifications/tools/list_changed":if(!this._capabilities.tools)throw Error(`Server does not support notifying of tool list changes (required for ${b})`);break;case"notifications/prompts/list_changed":if(!this._capabilities.prompts)throw Error(`Server does not support notifying of prompt list changes (required for ${b})`);break;case"notifications/elicitation/complete":if(!this._clientCapabilities?.elicitation?.url)throw Error(`Client does not support URL elicitation (required for ${b})`);break;case"notifications/cancelled":break;case"notifications/progress":break}}assertRequestHandlerCapability(b){if(!this._capabilities)return;switch(b){case"completion/complete":if(!this._capabilities.completions)throw Error(`Server does not support completions (required for ${b})`);break;case"logging/setLevel":if(!this._capabilities.logging)throw Error(`Server does not support logging (required for ${b})`);break;case"prompts/get":case"prompts/list":if(!this._capabilities.prompts)throw Error(`Server does not support prompts (required for ${b})`);break;case"resources/list":case"resources/templates/list":case"resources/read":if(!this._capabilities.resources)throw Error(`Server does not support resources (required for ${b})`);break;case"tools/call":case"tools/list":if(!this._capabilities.tools)throw Error(`Server does not support tools (required for ${b})`);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 ${b})`);break;case"ping":case"initialize":break}}assertTaskCapability(b){YD(this._clientCapabilities?.tasks?.requests,b,"Client")}assertTaskHandlerCapability(b){if(!this._capabilities)return;XD(this._capabilities.tasks?.requests,b,"Server")}async _oninitialize(b){let w=b.params.protocolVersion;return this._clientCapabilities=b.params.capabilities,this._clientVersion=b.params.clientInfo,{protocolVersion:DG.includes(w)?w:v4,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"},u0)}async createMessage(b,w){if(b.tools||b.toolChoice){if(!this._clientCapabilities?.sampling?.tools)throw Error("Client does not support sampling tools capability.")}if(b.messages.length>0){let $=b.messages[b.messages.length-1],W=Array.isArray($.content)?$.content:[$.content],Q=W.some((H)=>H.type==="tool_result"),G=b.messages.length>1?b.messages[b.messages.length-2]:void 0,X=G?Array.isArray(G.content)?G.content:[G.content]:[],Y=X.some((H)=>H.type==="tool_use");if(Q){if(W.some((H)=>H.type!=="tool_result"))throw Error("The last message must contain only tool_result content if any is present");if(!Y)throw Error("tool_result blocks are not matching any tool_use from the previous message")}if(Y){let H=new Set(X.filter((D)=>D.type==="tool_use").map((D)=>D.id)),J=new Set(W.filter((D)=>D.type==="tool_result").map((D)=>D.toolUseId));if(H.size!==J.size||![...H].every((D)=>J.has(D)))throw Error("ids of tool_result blocks and tool_use blocks from previous message do not match")}}if(b.tools)return this.request({method:"sampling/createMessage",params:b},e4,w);return this.request({method:"sampling/createMessage",params:b},r4,w)}async elicitInput(b,w){switch(b.mode??"form"){case"url":{if(!this._clientCapabilities?.elicitation?.url)throw Error("Client does not support url elicitation.");let W=b;return this.request({method:"elicitation/create",params:W},o0,w)}case"form":{if(!this._clientCapabilities?.elicitation?.form)throw Error("Client does not support form elicitation.");let W=b.mode==="form"?b:{...b,mode:"form"},Q=await this.request({method:"elicitation/create",params:W},o0,w);if(Q.action==="accept"&&Q.content&&W.requestedSchema)try{let X=this._jsonSchemaValidator.getValidator(W.requestedSchema)(Q.content);if(!X.valid)throw new x(c.InvalidParams,`Elicitation response content does not match requested schema: ${X.errorMessage}`)}catch(G){if(G instanceof x)throw G;throw new x(c.InternalError,`Error validating elicitation response: ${G instanceof Error?G.message:String(G)}`)}return Q}}}createElicitationCompletionNotifier(b,w){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:b}},w)}async listRoots(b,w){return this.request({method:"roots/list",params:b},s4,w)}async sendLoggingMessage(b,w){if(this._capabilities.logging){if(!this.isMessageIgnored(b.level,w))return this.notification({method:"notifications/message",params:b})}}async sendResourceUpdated(b){return this.notification({method:"notifications/resources/updated",params:b})}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 HD={name:"@sequenzy/mcp",version:"0.0.112",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":"bunx --bun 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:"^7.0.2"},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 HW=["product-info","domain","tracking","localization","integrations","products","events","tags","labels","goals","sync-rules","api-keys","widgets","team","danger"],JD={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}",landingPages:"/dashboard/company/{companyId}/landing-pages",landingPage:"/dashboard/company/{companyId}/landing-pages/{landingPageId}",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 UP(b){let $=(b??process.env.SEQUENZY_APP_URL??"https://sequenzy.com").trim().replace(/\/+$/,"");return $.length>0?$:"https://sequenzy.com"}function nb(b){let w=b?.trim();return w?w:void 0}function rb(b){return encodeURIComponent(b)}function Xb(b,w){return`${b}${w}`}function Yb(b,w=""){return`/dashboard/company/${rb(b)}${w}`}function DD(b,w,$){return Xb(b,`${Yb(w,"/settings")}?tab=${encodeURIComponent($)}`)}function BP(b,w){let $=HW.map((W)=>[W,w?DD(b,w,W):""]);return Object.fromEntries($)}function Hw(b={},w){let $=UP(w),W=nb(b.companyId),Q={},G=BP($,W);if(!W)return{appUrl:$,routeTemplates:JD,settingsTabValues:HW,urls:Q,settingsUrls:G};Q.dashboard=Xb($,Yb(W)),Q.campaigns=Xb($,Yb(W,"/campaign")),Q.landingPages=Xb($,Yb(W,"/landing-pages")),Q.sequences=Xb($,Yb(W,"/sequences")),Q.settings=Xb($,Yb(W,"/settings")),Q.emails=Xb($,Yb(W,"/emails")),Q.subscribers=Xb($,Yb(W,"/subscribers")),Q.sentEmails=Xb($,Yb(W,"/sent-emails")),Q.segments=Xb($,Yb(W,"/segments")),Q.metrics=Xb($,Yb(W,"/metrics")),Q.transactional=Xb($,Yb(W,"/transactional"));let X=nb(b.campaignId);if(X)Q.campaign=Xb($,Yb(W,`/campaign/${rb(X)}`)),Q.campaignPreview=`${Q.campaign}?step=review`;let Y=nb(b.landingPageId);if(Y)Q.landingPage=Xb($,Yb(W,`/landing-pages/${rb(Y)}`));let H=nb(b.sequenceId);if(H)Q.sequence=Xb($,Yb(W,`/sequences/${rb(H)}`));let J=nb(b.emailId)??nb(b.templateId);if(J)Q.email=Xb($,Yb(W,`/emails/${rb(J)}`)),Q.template=Q.email;let D=nb(b.transactionalId);if(D)Q.transactionalEmail=Xb($,Yb(W,`/transactional/${rb(D)}`));let z=nb(b.emailSendId);if(z)Q.emailSend=Xb($,Yb(W,`/sent-emails/${rb(z)}`));let O=nb(b.domainId);if(O)Q.domain=Xb($,Yb(W,`/settings/domain/${rb(O)}`)),Q.domainVerify=`${Q.domain}/verify`;let q=nb(b.status);if(q)Q.campaignList=Xb($,Yb(W,`/campaign/list/${rb(q)}`)),Q.sequenceList=Xb($,Yb(W,`/sequences/list/${rb(q)}`));let B=nb(b.settingsTab);if(B)Q.settingsTab=DD($,W,B);return{appUrl:$,routeTemplates:JD,settingsTabValues:HW,urls:Q,settingsUrls:G}}var zD=[{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 AD(b){try{let w;switch(b){case"sequenzy://dashboard":w=await A("GET","/api/v1/metrics?period=7d");break;case"sequenzy://company":{let $=await A("GET","/api/v1/account"),W=Tw()??$.currentCompanyId;if(!W)throw Error("No company available. Create or select a company first.");w=await A("GET",`/api/v1/companies/${W}`);break}case"sequenzy://campaigns/recent":w=await A("GET","/api/v1/campaigns?limit=10");break;case"sequenzy://subscribers/recent":w=await A("GET","/api/v1/subscribers?sort=createdAt&limit=20");break;case"sequenzy://subscribers/engaged":w=await A("GET","/api/v1/subscribers?sort=engagement&limit=20");break;case"sequenzy://sequences":w=await A("GET","/api/v1/sequences");break;case"sequenzy://templates":w=await A("GET","/api/v1/templates");break;case"sequenzy://segments":w=await A("GET","/api/v1/segments");break;case"sequenzy://tags":w=await A("GET","/api/v1/tags");break;case"sequenzy://health":w=await A("GET","/api/v1/health/deliverability");break;case"sequenzy://app-routes":w=Hw();break;default:throw Error(`Unknown resource: ${b}`)}return{contents:[{uri:b,mimeType:"application/json",text:JSON.stringify(w,null,2)}]}}catch(w){return{contents:[{uri:b,mimeType:"text/plain",text:yw(w)}]}}}function y(b){return typeof b==="object"&&b!==null&&!Array.isArray(b)}function F(b,w){let $=b[w];if(typeof $!=="string")return;let W=$.trim();return W.length>0?W:void 0}function j(b,w,$){let W=F(w,$);if(W===void 0)throw Error(`\`${$}\` is required when calling \`${b}\`.`);return W}var Ew='For exact historical Poll/NPS respondents, use field `pollResponse`, operator `is`, and a JSON value shaped like {"v":1,"campaignId":"camp_123","blockId":"poll_1","match":{"kind":"answer","value":"loved"}}. For NPS buckets, use match {"kind":"npsBucket","bucket":"promoters"}; bucket may be `promoters`, `passives`, or `detractors`.',Jw='Sequenzy email blocks. Use this for editor-compatible content, including conditional and repeat blocks. For provider-migrated HTML from another email platform, prefer the `html` field instead; Sequenzy stores it as one raw HTML block to preserve the original design. 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`. Repeat blocks use { type: \'repeat\', source: \'items\', itemAlias: \'item\', children: [...] }. Any block accepts a `conditions` array so it only renders for matching recipients. To branch on a value passed in transactional `variables` or an automation `event` payload, use { "id": "c1", "field": "variable", "operator": "is", "value": "plan:pro" }; "attribute" uses the same "name:value" form, while "email"/"firstName"/"lastName" use a plain comparison value. Live subscriber fields are "status", "tag", "list", "segment", "event", "emailProvider", "phone", "smsStatus", "added", "stripeProduct", "stripeCurrentProduct", "stripeTrialProduct", "commerceProduct", "emailSent", "emailDelivered", "emailOpened", "emailClicked", "emailBounced", and "emailComplained". They use the same field-specific values and operators as segment filters, for example { "id": "c2", "field": "segment", "operator": "is", "value": "seg_123" }, { "id": "c3", "field": "tag", "operator": "contains", "value": "vip" }, or { "id": "c4", "field": "event", "operator": "at_least", "value": "purchase:3:30d" }. Supported operators across fields are is, is_not, contains, not_contains, gt, gte, lt, lte, less_than, more_than, at_least, less_than_count, is_empty, is_not_empty, is_temporary_bounce, and is_permanent_bounce; each field accepts only its segment-filter operators. Recipients without a stored subscriber match use the OTHERWISE branch or hide a conditionally displayed block. For if/else, use a { type: "conditional-group", conditions: [...], ifBranch: { children: [...] }, elseBranch: { children: [...] } } block. Polls and NPS surveys use a native poll block. For answer buttons use { "type": "poll", "variant": "options", "question": "What did you think?", "options": [{ "label": "Loved it", "value": "loved" }, { "label": "Not for me", "value": "not_for_me" }], "attributeKey": "email_feedback" }. For NPS use { "type": "poll", "variant": "nps", "question": "How likely are you to recommend us?", "options": [], "attributeKey": "nps_score", "npsLowLabel": "Not likely", "npsHighLabel": "Very likely" }. `attributeKey` stores the latest response for segmentation. Optional `appearance` picks the answer style: "soft" (default), "pill", "outline", "filled", "pop" (hard-shadow boxes), "brutal" (square uppercase slabs), "quiz" (A/B/C letter badges), or "minimal" (bare ruled rows). Optional `confirmationMessage` customizes the hosted thank-you page; set `redirectUrl` only when respondents should land on another page. For a new image, call `upload_image_asset` first and insert its returned `imageBlock`. A responsive fixed-height screenshot crop uses { "type": "image", "src": "https://...", "alt": "Product dashboard", "width": 100, "widthType": "percent", "height": 320, "objectFit": "cover", "align": "center" }.',Dw='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`. Any block accepts a `conditions` array so it only renders for matching recipients. To branch on a value passed in transactional `variables` or an automation `event` payload, use { "id": "c1", "field": "variable", "operator": "is", "value": "plan:pro" }; "attribute" uses the same "name:value" form, while "email"/"firstName"/"lastName" use a plain comparison value. Live subscriber fields are "status", "tag", "list", "segment", "event", "emailProvider", "phone", "smsStatus", "added", "stripeProduct", "stripeCurrentProduct", "stripeTrialProduct", "commerceProduct", "emailSent", "emailDelivered", "emailOpened", "emailClicked", "emailBounced", and "emailComplained". They use the same field-specific values and operators as segment filters, for example { "id": "c2", "field": "segment", "operator": "is", "value": "seg_123" }, { "id": "c3", "field": "tag", "operator": "contains", "value": "vip" }, or { "id": "c4", "field": "event", "operator": "at_least", "value": "purchase:3:30d" }. Supported operators across fields are is, is_not, contains, not_contains, gt, gte, lt, lte, less_than, more_than, at_least, less_than_count, is_empty, is_not_empty, is_temporary_bounce, and is_permanent_bounce; each field accepts only its segment-filter operators. Recipients without a stored subscriber match use the OTHERWISE branch or hide a conditionally displayed block. For if/else, use a { type: "conditional-group", conditions: [...], ifBranch: { children: [...] }, elseBranch: { children: [...] } } block. Polls and NPS surveys use a native poll block. For answer buttons use { "type": "poll", "variant": "options", "question": "What did you think?", "options": [{ "label": "Loved it", "value": "loved" }, { "label": "Not for me", "value": "not_for_me" }], "attributeKey": "email_feedback" }. For NPS use { "type": "poll", "variant": "nps", "question": "How likely are you to recommend us?", "options": [], "attributeKey": "nps_score", "npsLowLabel": "Not likely", "npsHighLabel": "Very likely" }. `attributeKey` stores the latest response for segmentation. Optional `appearance` picks the answer style: "soft" (default), "pill", "outline", "filled", "pop" (hard-shadow boxes), "brutal" (square uppercase slabs), "quiz" (A/B/C letter badges), or "minimal" (bare ruled rows). Optional `confirmationMessage` customizes the hosted thank-you page; set `redirectUrl` only when respondents should land on another page. For a new image, call `upload_image_asset` first and insert its returned `imageBlock`. A responsive fixed-height screenshot crop uses { "type": "image", "src": "https://...", "alt": "Product dashboard", "width": 100, "widthType": "percent", "height": 320, "objectFit": "cover", "align": "center" }.',W1='Sequenzy email blocks. Provide blocks or html for email steps. For migrated provider HTML, prefer `html`; Sequenzy stores it as one raw HTML block and does not recreate it as native 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`. Blocks can include repeat blocks over array variables such as items. Any block accepts a `conditions` array so it only renders for matching recipients. To branch on a value passed in transactional `variables` or an automation `event` payload, use { "id": "c1", "field": "variable", "operator": "is", "value": "plan:pro" }; "attribute" uses the same "name:value" form, while "email"/"firstName"/"lastName" use a plain comparison value. Live subscriber fields are "status", "tag", "list", "segment", "event", "emailProvider", "phone", "smsStatus", "added", "stripeProduct", "stripeCurrentProduct", "stripeTrialProduct", "commerceProduct", "emailSent", "emailDelivered", "emailOpened", "emailClicked", "emailBounced", and "emailComplained". They use the same field-specific values and operators as segment filters, for example { "id": "c2", "field": "segment", "operator": "is", "value": "seg_123" }, { "id": "c3", "field": "tag", "operator": "contains", "value": "vip" }, or { "id": "c4", "field": "event", "operator": "at_least", "value": "purchase:3:30d" }. Supported operators across fields are is, is_not, contains, not_contains, gt, gte, lt, lte, less_than, more_than, at_least, less_than_count, is_empty, is_not_empty, is_temporary_bounce, and is_permanent_bounce; each field accepts only its segment-filter operators. Recipients without a stored subscriber match use the OTHERWISE branch or hide a conditionally displayed block. For if/else, use a { type: "conditional-group", conditions: [...], ifBranch: { children: [...] }, elseBranch: { children: [...] } } block. Polls and NPS surveys use a native poll block. For answer buttons use { "type": "poll", "variant": "options", "question": "What did you think?", "options": [{ "label": "Loved it", "value": "loved" }, { "label": "Not for me", "value": "not_for_me" }], "attributeKey": "email_feedback" }. For NPS use { "type": "poll", "variant": "nps", "question": "How likely are you to recommend us?", "options": [], "attributeKey": "nps_score", "npsLowLabel": "Not likely", "npsHighLabel": "Very likely" }. `attributeKey` stores the latest response for segmentation. Optional `appearance` picks the answer style: "soft" (default), "pill", "outline", "filled", "pop" (hard-shadow boxes), "brutal" (square uppercase slabs), "quiz" (A/B/C letter badges), or "minimal" (bare ruled rows). Optional `confirmationMessage` customizes the hosted thank-you page; set `redirectUrl` only when respondents should land on another page. For a new image, call `upload_image_asset` first and insert its returned `imageBlock`. A responsive fixed-height screenshot crop uses { "type": "image", "src": "https://...", "alt": "Product dashboard", "width": 100, "widthType": "percent", "height": 320, "objectFit": "cover", "align": "center" }.',X0="Complete Sequenzy landing page content JSON. Use this when replacing the page structure. The content must be the editor-compatible landing page schema with version, template, seo, theme, and blocks. Landing pages must include exactly one footer block and at most one form block.",OD="Optional template key for default content, such as from-scratch, waitlist, lead-magnet, launch, demo-request, webinar, newsletter, product-hunt, pricing-offer, agency-lead-gen, or feature-announcement.",JW=500,DW=500,lb={type:"boolean",description:"If true, include machine-classified bot/scanner opens and clicks. Defaults to false, so metrics and activity are human-only."},k$=["send","delivery","bounce","complaint","open","click","unsubscribe","delivery_delay"],v$={type:"object",description:"Optional send window for every email step in the sequence. When set, email actions that become due outside the window wait until the next allowed local time. Omit days to allow every day.",properties:{enabled:{type:"boolean",description:"Set false to disable the sending window when creating a sequence. For updates, prefer clearSendingWindow."},timezone:{type:"string",description:"IANA timezone for the window, e.g. Europe/Kiev or America/New_York."},startTime:{type:"string",description:"Earliest local send time in 24-hour HH:mm format, e.g. 08:00."},endTime:{type:"string",description:"Latest local send cutoff in 24-hour HH:mm format, e.g. 20:00. Must be later than startTime."},days:{type:"array",description:"Allowed local days. Use full names or short names such as monday, tuesday, mon, tue. Omit for every day.",items:{type:"string"}}},additionalProperties:!1},FP={type:"object",description:"Offset relative to a wait-until date.",properties:{days:{type:"number"},hours:{type:"number"},minutes:{type:"number"}},additionalProperties:!1},Q1={type:"object",description:"Wait until a date from the trigger event before this step. Use this for renewal reminders, appointment follow-ups, trial-expiry nudges, and other subscriber-specific dates. The field value must be an ISO date string or Unix timestamp.",properties:{field:{type:"string",description:"Dot-path into the trigger event properties, e.g. renews_at or booking.startsAt."},untilDateField:{type:"string",description:"Alias for field."},offset:FP,days:{type:"number",description:"Offset days shorthand. Ignored when offset is provided."},hours:{type:"number",description:"Offset hours shorthand. Ignored when offset is provided."},minutes:{type:"number",description:"Offset minutes shorthand. Ignored when offset is provided."},direction:{type:"string",enum:["before","after"],description:"Whether the offset applies before or after the resolved date. Defaults to after."},untilOffsetDirection:{type:"string",enum:["before","after"],description:"Alias for direction."},missingAction:{type:"string",enum:["continue","exit"],description:"What to do if the event field is missing or invalid. Defaults to continue."},untilMissingAction:{type:"string",enum:["continue","exit"],description:"Alias for missingAction."}},additionalProperties:!1},G1={type:"object",description:"Fixed delay before this step. For a dynamic wait-until-date delay, either set mode:'until_date' plus untilDateField here, or use waitUntil.",properties:{days:{type:"number"},hours:{type:"number"},minutes:{type:"number"},mode:{type:"string",enum:["duration","until_date"],description:"Use duration for a fixed wait, or until_date to resolve a date from the trigger event."},untilDateField:{type:"string",description:"For mode:'until_date', dot-path into the trigger event properties."},field:{type:"string",description:"Alias for untilDateField."},untilOffsetDirection:{type:"string",enum:["before","after"],description:"For mode:'until_date', whether days/hours/minutes are before or after the event date. Defaults to after."},direction:{type:"string",enum:["before","after"],description:"Alias for untilOffsetDirection."},untilMissingAction:{type:"string",enum:["continue","exit"],description:"For mode:'until_date', what to do when the field is missing or invalid. Defaults to continue."},missingAction:{type:"string",enum:["continue","exit"],description:"Alias for untilMissingAction."}},additionalProperties:!1},zW={type:"object",description:"Type-aware patch for the existing node. Start from get_sequence.sequence.nodes[].config. For logic_delay, set exactly one of delay ({ days, hours, minutes }), delayMs, or waitUntil; optional label is also accepted. For action_email, use name/label, subject, previewText, html/htmlContent or blocks, isTransactional, and sender/reply identity fields. For action_sms, use text, blocks, imageUrls, label, or ineligibleAction. Other node types accept their editable config keys. Managed IDs, nodeType conversion, and branch path IDs/count are not editable here; use edit_sequence_graph for topology. Webhook header patches are merged, and redacted values from get_sequence must be omitted or replaced with a real new value.",additionalProperties:!0},C$={type:"object",properties:{nodeId:{type:"string",description:"Existing node ID from get_sequence.sequence.nodes[].id."},changes:zW,expectedUpdatedAt:{type:"string",description:"Required optimistic-concurrency value from get_sequence.sequence.nodes[].updatedAt. The update is rejected if that node or its linked email content changed after it was read."}},required:["nodeId","changes","expectedUpdatedAt"],additionalProperties:!1},X1=["gray","red","orange","amber","yellow","lime","green","emerald","teal","cyan","sky","blue","indigo","violet","purple","fuchsia","pink","rose"],Y1=["email.sent","email.delivered","email.delivery_delayed","email.bounced","email.complained","email.opened","email.clicked","email.replied","email.unsubscribed","sms.sent","sms.delivered","sms.failed","sms.opted_out","subscriber.invalid","subscriber.updated","subscriber.unsubscribed","subscriber.list_subscribed","subscriber.list_unsubscribed","sequence.finished","sequence.failed","poll.answered"];var KP=new Set(["get_account","get_app_urls","get_company","get_sync_rules","get_shopify_automation_settings","list_websites","check_website","get_integration_guide","get_subscriber","list_subscriber_notes","search_subscribers","list_products","list_tags","list_lists","list_segments","get_segment_count","list_audience_syncs","list_ad_accounts","list_templates","get_template","list_ab_tests","get_ab_test","get_ab_test_stats","list_campaigns","get_campaign","get_email_send","list_landing_pages","get_landing_page","list_sequences","get_sequence","list_transactional_emails","get_transactional_email","get_stats","get_campaign_stats","get_sequence_stats","list_campaign_events","list_sequence_events","get_subscriber_activity","list_team_members","list_conversations","get_conversation","list_webhooks","list_webhook_deliveries","generate_email","generate_sequence","generate_subject_lines","generate_sms","get_sms_settings"]),PP=new Set(["select_company","create_company","update_company","update_sync_rules","update_shopify_automation_settings","create_api_key","add_sending_domain","add_website","verify_sending_domain","add_subscriber","update_subscriber","add_subscriber_note","remove_subscriber","delete_subscriber_note","upsert_products","delete_product","attach_product_file","remove_product_file","upload_image_asset","sync_products","create_tag","update_tag","delete_tag","create_list","update_list","delete_list","add_subscribers_to_list","remove_subscribers_from_list","create_segment","update_segment","delete_segment","create_audience_sync","update_audience_sync","delete_audience_sync","sync_audience_now","create_template","update_template","set_template_localization","sync_template_localizations","delete_template","restart_ab_test","update_ab_test_variant","create_ab_test","add_ab_test_variant","delete_ab_test_variant","delete_ab_test","create_campaign","update_campaign","schedule_campaign","send_test_email","send_test_sms","cancel_campaign","pause_campaign","resume_campaign","delete_campaign","duplicate_campaign","resend_campaign_to_non_openers","create_landing_page","update_landing_page","delete_landing_page","publish_landing_page","unpublish_landing_page","connect_landing_page_domain","update_landing_page_domain_settings","create_sequence","update_sequence","update_sequence_node","update_sequence_nodes","edit_sequence_graph","insert_sequence_step","enable_sequence","disable_sequence","pause_sequence_enrollments","resume_sequence_enrollments","enroll_subscribers_in_sequence","cancel_sequence_enrollments","delete_sequence","create_transactional_email","update_transactional_email","send_email","invite_team_member","cancel_team_invitation","reply_to_conversation","update_conversation_status","mark_conversation_read","create_webhook","update_webhook","delete_webhook","test_webhook","replay_webhook_delivery","submit_feedback"]),MP=new Set(["send_test_email","send_test_sms","schedule_campaign","resume_campaign","publish_landing_page","connect_landing_page_domain","update_landing_page_domain_settings","add_sending_domain","add_website","verify_sending_domain","enable_sequence","resume_sequence_enrollments","send_email","invite_team_member","reply_to_conversation","create_webhook","update_webhook","test_webhook","replay_webhook_delivery"]),ZP=new Set(["remove_subscriber","delete_subscriber_note","delete_product","remove_product_file","delete_tag","delete_list","remove_subscribers_from_list","delete_segment","delete_audience_sync","delete_template","restart_ab_test","delete_ab_test_variant","delete_ab_test","cancel_campaign","delete_campaign","delete_landing_page","unpublish_landing_page","disable_sequence","edit_sequence_graph","cancel_sequence_enrollments","delete_sequence","cancel_team_invitation","delete_webhook"]);function jP(b){let w=KP.has(b),$=PP.has(b);if(w===$)throw Error(`MCP tool "${b}" must be classified as exactly one of read-only or mutating.`);return{readOnlyHint:w,destructiveHint:w?!1:ZP.has(b),openWorldHint:MP.has(b)}}function qD(b){return{...b,annotations:{...b.annotations,...jP(b.name)}}}var AW={status:["is","is_not"],phone:["is_not_empty","is_empty"],smsStatus:["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"],pollResponse:["is"],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"],commerceProduct:["is","is_not","at_least","less_than_count"]},IP=Object.entries(AW).map(([b,w])=>`${b}: ${w.join(", ")}`).join("; "),OW={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","phone","smsStatus","tag","email","emailProvider","added","firstName","lastName","list","emailSent","emailDelivered","emailOpened","emailClicked","emailBounced","emailComplained","attribute","event","pollResponse","segment","stripeProduct","stripeCurrentProduct","stripeTrialProduct","commerceProduct"],description:`Filter field. Use \`phone\` with is_not_empty/is_empty to check whether a subscriber has a phone number, and \`smsStatus\` (is/is_not one of \`subscribed\`, \`unsubscribed\`, \`not_subscribed\`) for SMS marketing consent. Use \`event\` for custom subscriber events, \`segment\` for saved segment membership, \`stripeProduct\`/\`stripeCurrentProduct\`/\`stripeTrialProduct\` for Stripe product-based segments, and \`commerceProduct\` for products purchased through commerce orders - the value is \`provider:productId\` (provider one of \`shopify\`, \`woocommerce\`, \`api\`; product ids are provider-scoped), optionally with an order-count threshold (\`provider:productId:count\`) for at_least/less_than_count; a bare product id matches the id on any provider. Engagement fields (\`emailSent\`, \`emailDelivered\`, \`emailOpened\`, \`emailClicked\`, \`emailBounced\`, \`emailComplained\`) accept a time range as the value, a specific campaign via \`campaign:<campaign_id>\`, or \`count:timeRange\` (e.g. \`10:30d\`, \`10:all\`) with at_least/less_than_count to segment by number of opens/clicks. ${Ew}`},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: ${IP}.`},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, \`campaign:<campaign_id>\` to scope to a specific sent campaign (use \`list_campaigns\` to find IDs), or \`count:timeRange\` like \`10:30d\` / \`10:all\` with at_least/less_than_count operators (e.g. emailClicked at_least \`10:all\` = clicked 10 or more times ever). ${Ew}`}},required:["field","operator","value"],additionalProperties:!1},qW={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 x$(b){if(!Array.isArray(b))return b;return b.map((w)=>{if(typeof w!=="object"||w===null)return w;let $=w;if(typeof $.id==="string"&&$.id.trim()!=="")return $;return{...$,id:crypto.randomUUID()}})}function u$(b){if(typeof b!=="object"||b===null)return b;let w=b;if(w.kind==="filter"||"field"in w||"operator"in w||"value"in w){let $=x$([w]);return Array.isArray($)?$[0]:w}if(w.kind!=="group")return b;return{...w,id:typeof w.id==="string"&&w.id.trim()!==""?w.id:crypto.randomUUID(),children:Array.isArray(w.children)?w.children.map(u$):[]}}function VP(b){let w=b.indexOf(":");return w!==-1&&b.substring(0,w).trim().length>0}function NP(b){let w=b.indexOf(":");return w!==-1&&b.substring(w+1).trim().length>0}function LD(b){if(b==="all")return!0;let w=b.match(/^(\d+)d$/);if(!w?.[1])return!1;let $=Number.parseInt(w[1],10);return Number.isInteger($)&&$>0}function EP(b,w){let $=w.split(":");if(b==="at_least"||b==="less_than_count"){if($.length<3)return'Event count filters must use "eventName:count:timeRange", like "saas.purchase:2:30d".';let G=$.slice(0,-2).join(":").trim(),X=$.at(-2),Y=$.at(-1),H=X===void 0?Number.NaN:Number.parseInt(X,10);return G&&Number.isInteger(H)&&H>0&&Y!==void 0&&LD(Y)?null:'Event count filters must use "eventName:count:timeRange", like "saas.purchase:2:30d".'}if($.length<2)return'Event filters must use "eventName:timeRange", like "saas.purchase:30d".';let W=$.slice(0,-1).join(":").trim(),Q=$.at(-1);return W&&Q!==void 0&&LD(Q)?null:'Event filters must use "eventName:timeRange", like "saas.purchase:30d".'}function TP(b){let w=b.indexOf(":");if(w===-1)return{productId:b,subfilter:null,rawValue:null};let $=b.substring(0,w),W=b.substring(w+1),Q=W.indexOf(":");if(Q===-1)return{productId:$,subfilter:W,rawValue:null};return{productId:$,subfilter:W.substring(0,Q),rawValue:W.substring(Q+1)}}function _P(b){return b.trim().toLowerCase().replace(/[-\s]+/g,"_")}function SP(b){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(b)}function RP(b,w){if(w==="cancels_at"||w==="cancel_at"||w==="cancellation_at")return!0;if(b==="stripeCurrentProduct")return["end_at","ends_at","period_end","period_ends_at","current_period_end"].includes(w);return["start_at","started_at","trial_start","trial_started_at","end_at","ends_at","trial_end","trial_ends_at"].includes(w)}function kP(b){return["is","is_not","gte","lte","gt","lt"].includes(b)}function vP(b,w,$){if(b==="stripeProduct"){if(w!=="at_least"&&w!=="less_than_count")return null;let Y=$.indexOf(":");if(Y===-1)return null;let H=$.substring(0,Y).trim(),J=Number.parseInt($.substring(Y+1).trim(),10);return H&&Number.isInteger(J)&&J>=1?null:'Stripe Product threshold filters must use "productId:count" with a count of at least 1.'}if(b!=="stripeCurrentProduct"&&b!=="stripeTrialProduct")return null;let{productId:W,subfilter:Q,rawValue:G}=TP($);if(!W.trim())return"Stripe product filters must include a product ID.";if(!Q)return w==="is"||w==="is_not"?null:'Stripe current/trial date filters must use "productId:dateField:value".';let X=_P(Q);if(SP(X))return w==="is"||w==="is_not"?null:"Stripe cancellation flag filters only support is and is_not operators.";if(!RP(b,X))return`Unsupported Stripe product subfilter "${Q}".`;if(!kP(w))return"Stripe date filters only support is, is_not, gte, lte, gt, and lt operators.";return G?.trim()?null:'Stripe date filters must include a value like "productId:end_at:2026-05-26".'}var CP=new Set(["shopify","woocommerce","api"]);function xP(b,w){let $=w.trim(),W=$.indexOf(":");if(W!==-1&&CP.has($.substring(0,W).trim()))$=$.substring(W+1).trim();if(!$)return'Purchased Product filters must include a product ID, like "shopify:42".';if(b!=="at_least"&&b!=="less_than_count")return null;let Q=$.lastIndexOf(":");if(Q===-1)return null;let G=$.substring(0,Q).trim(),X=Number.parseInt($.substring(Q+1).trim(),10);return G&&Number.isInteger(X)&&X>=1?null:'Purchased Product threshold filters must use "provider:productId:count" with a count of at least 1.'}function uP(b){let w;try{w=JSON.parse(b)}catch{return`Poll response filters must use valid JSON. ${Ew}`}if(!y(w)||w.v!==1||typeof w.campaignId!=="string"||!w.campaignId.trim()||typeof w.blockId!=="string"||!w.blockId.trim()||!y(w.match))return`Poll response filter context is invalid. ${Ew}`;let $=w.match;if($.kind==="answer"&&typeof $.value==="string"&&$.value.length>0)return null;if($.kind==="npsBucket"&&($.bucket==="promoters"||$.bucket==="passives"||$.bucket==="detractors"))return null;return`Poll response filter match is invalid. ${Ew}`}function y$(b){if(typeof b!=="object"||b===null)return"Segment filters must be objects.";let w=b,$=w.field,W=w.operator,Q=w.value;if(typeof $!=="string"||!($ in AW))return`Unsupported segment filter field "${String($)}".`;if(typeof W!=="string")return`Segment filter "${$}" must include an operator.`;let G=AW[$];if(!G.includes(W))return`Operator "${W}" is not supported for ${$} filters. Use one of: ${G.join(", ")}.`;if(W!=="is_empty"&&W!=="is_not_empty"&&(typeof Q!=="string"||Q.trim().length===0))return`Segment filter "${$}" must include a value.`;if($==="attribute"&&typeof Q==="string"){if(!VP(Q))return'Attribute filters must use "attributeName:value" or "attributeName:" for empty checks.';if(W!=="is_empty"&&W!=="is_not_empty"&&!NP(Q))return'Attribute filters must include a value after "attributeName:".'}if($==="event"&&typeof Q==="string"){let X=EP(W,Q);if(X)return X}if($==="pollResponse"&&typeof Q==="string"){let X=uP(Q);if(X)return X}if(($==="stripeProduct"||$==="stripeCurrentProduct"||$==="stripeTrialProduct")&&typeof Q==="string"){let X=vP($,W,Q);if(X)return X}if($==="commerceProduct"&&typeof Q==="string"){let X=xP(W,Q);if(X)return X}if($==="tag"&&(W==="contains"||W==="not_contains")){if(!(typeof Q==="string"&&Q.split(",").map((Y)=>Y.trim()).some(Boolean)))return"Tag filters must include at least one tag name."}return null}function h$(b){if(typeof b!=="object"||b===null)return[];let w=b;if(w.kind==="filter"||"field"in w||"operator"in w||"value"in w){let $=y$(w);return $?[$]:[]}if(Array.isArray(w.children))return w.children.flatMap(h$);return[]}function _b(b,w,$){if(w.html!==void 0&&w.blocks!==void 0)throw Error(`Provide either \`html\` or \`blocks\` when calling \`${b}\`, not both.`);if(w.blocks!==void 0&&!Array.isArray(w.blocks))throw Error(`\`blocks\` must be an array when calling \`${b}\`.`);if($?.requireContent&&w.html===void 0&&w.blocks===void 0)throw Error(`Provide either \`html\` or \`blocks\` when calling \`${b}\`.`)}function H1(b,w){if(w.labels===void 0)return;if(!Array.isArray(w.labels))throw Error(`\`labels\` must be an array when calling \`${b}\`.`);if(w.labels.some(($)=>typeof $!=="string"||$.trim().length===0))throw Error(`\`labels\` must contain only non-empty strings when calling \`${b}\`.`)}function FD(b){let w=b.filters!==void 0,$=b.root!==void 0;if(w&&$)throw Error("Provide either `filters` or `root` when calling `create_segment`, not both.");if(!w&&!$)throw Error("Provide either `filters` or `root` when calling `create_segment`.");if(w){if(!Array.isArray(b.filters))throw Error("`filters` must be an array when calling `create_segment`.");if(b.filters.length===0)throw Error("`filters` must include at least one filter when calling `create_segment`.")}if($&&(typeof b.root!=="object"||b.root===null))throw Error("`root` must be an object when calling `create_segment`.");let W=w?b.filters.flatMap((Q)=>{let G=y$(Q);return G?[G]:[]}):h$(b.root);if(W.length>0)throw Error(W[0]??"Invalid segment filter in `create_segment`.")}function KD(b){let w=b.filters!==void 0,$=b.root!==void 0;if(w&&$)throw Error("Provide either `filters` or `root` when calling `update_segment`, not both.");if(b.name===void 0&&b.filterJoinOperator===void 0&&!w&&!$)throw Error("Provide at least one of `name`, `filters`, `root`, or `filterJoinOperator` when calling `update_segment`.");if(w){if(!Array.isArray(b.filters))throw Error("`filters` must be an array when calling `update_segment`.");if(b.filters.length===0)throw Error("`filters` must include at least one filter when calling `update_segment`.")}if($&&(typeof b.root!=="object"||b.root===null))throw Error("`root` must be an object when calling `update_segment`.");let W=w?b.filters.flatMap((Q)=>{let G=y$(Q);return G?[G]:[]}):$?h$(b.root):[];if(W.length>0)throw Error(W[0]??"Invalid segment filter in `update_segment`.")}var LW=["name","description","logoUrl","founderName","primaryColor","brandColors","valueProps","testimonials","toneVoice","companyContext","emailLengthPreference","socialLinks","privacyPolicyUrl","termsUrl","address","language","pricing","fontFamily","emailDirection","fromEmail","fromName","replyTo","replyToName"];function UW(b,w,$){if(w[$]!==void 0&&!y(w[$]))throw Error(`\`${$}\` must be an object when calling \`${b}\`.`)}function UD(b,w,$){if(w[$]!==void 0&&!Array.isArray(w[$]))throw Error(`\`${$}\` must be an array when calling \`${b}\`.`)}function PD(b){let w=new Set(["companyId",...LW]),$=Object.keys(b).filter((Q)=>!w.has(Q));if($.length>0)throw Error(`\`update_company\` accepts only company product-info fields. Unsupported field${$.length===1?"":"s"}: ${$.map((Q)=>`\`${Q}\``).join(", ")}.`);let W={};for(let Q of LW)if(b[Q]!==void 0)W[Q]=b[Q];if(Object.keys(W).length===0)throw Error(`Provide at least one of ${LW.map((Q)=>`\`${Q}\``).join(", ")} when calling \`update_company\`.`);for(let Q of["name","description","logoUrl","founderName","primaryColor","toneVoice","companyContext","emailLengthPreference","privacyPolicyUrl","termsUrl","address","language","fontFamily","emailDirection","fromEmail","fromName","replyTo","replyToName"])if(b[Q]!==void 0&&typeof b[Q]!=="string")throw Error(`\`${Q}\` must be a string when calling \`update_company\`.`);if(UW("update_company",b,"brandColors"),UW("update_company",b,"socialLinks"),UW("update_company",b,"pricing"),UD("update_company",b,"valueProps"),UD("update_company",b,"testimonials"),typeof b.primaryColor==="string"&&!/^#[0-9a-f]{6}$/i.test(b.primaryColor.trim()))throw Error("`primaryColor` must be a 6-digit hex color such as #f97316 when calling `update_company`.");for(let Q of["fromEmail","replyTo"]){let G=b[Q];if(typeof G==="string"&&!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(G.trim()))throw Error(`\`${Q}\` must be a valid email address when calling \`update_company\`.`)}if(b.fromName!==void 0&&b.fromEmail===void 0)throw Error("`fromName` requires `fromEmail` when calling `update_company`.");if(b.replyToName!==void 0&&b.replyTo===void 0)throw Error("`replyToName` requires `replyTo` when calling `update_company`.");return W}var MD=["senderProfileId","fromEmail","fromName","replyProfileId","replyTo","replyToName"];function yP(b){return MD.some((w)=>b[w]!==void 0)}function hP(b){if(typeof b.nodeType==="string")return b.nodeType==="action_email";return b.type===void 0||b.type==="email"}function f$(b,w,$){for(let W of MD){let Q=$[W];if(Q!==void 0&&typeof Q!=="string")throw Error(`\`${W}\` must be a string for ${w} when calling \`${b}\`.`)}if($.senderProfileId!==void 0&&$.fromEmail!==void 0)throw Error(`Provide either \`senderProfileId\` or \`fromEmail\` for ${w} when calling \`${b}\`, not both.`);if($.replyProfileId!==void 0&&$.replyTo!==void 0)throw Error(`Provide either \`replyProfileId\` or \`replyTo\` for ${w} when calling \`${b}\`, not both.`);if($.replyToName!==void 0&&$.replyTo===void 0)throw Error(`\`replyToName\` requires \`replyTo\` for ${w} when calling \`${b}\`.`)}function FW(b,w,$){if(yP($)&&!hP($))throw Error(`Sender identity fields are only supported for email steps at ${w} when calling \`${b}\`.`);f$(b,w,$)}function BD(b,w,$){if(!Array.isArray($))return;$.forEach((W,Q)=>{if(y(W))f$(b,`${w}[${Q}]`,W)})}function BW(b,w,$){if(!Array.isArray($))return;$.forEach((W,Q)=>{if(y(W))FW(b,`${w}[${Q}]`,W)})}function fP(b){if(BD("update_sequence","emails",b.emails),BD("update_sequence","steps",b.steps),y(b.insertSteps))BW("update_sequence","insertSteps.steps",b.insertSteps.steps);if(!y(b.branch))return;if(Array.isArray(b.branch.branches))b.branch.branches.forEach(($,W)=>{if(y($))BW("update_sequence",`branch.branches[${W}].steps`,$.steps)});BW("update_sequence","branch.elseSteps",b.branch.elseSteps)}function ZD(b){if(b.fromEmail!==void 0&&b.senderProfileId!==void 0)throw Error("Provide either `fromEmail` or `senderProfileId` when calling `update_sequence`, not both.");if(b.replyTo!==void 0&&b.replyProfileId!==void 0)throw Error("Provide either `replyTo` or `replyProfileId` when calling `update_sequence`, not both.");if(b.fromName!==void 0&&b.fromEmail===void 0)throw Error("`fromName` requires `fromEmail` when calling `update_sequence`.");if(b.replyToName!==void 0&&b.replyTo===void 0)throw Error("`replyToName` requires `replyTo` when calling `update_sequence`.");if(b.clearEnrollmentFieldPath===!0&&b.enrollmentFieldPath!==void 0)throw Error("Provide either `enrollmentFieldPath` or `clearEnrollmentFieldPath` when calling `update_sequence`, not both.");if(b.clearSendingWindow===!0&&b.sendingWindow!==void 0)throw Error("Provide either `sendingWindow` or `clearSendingWindow` when calling `update_sequence`, not both.");if(b.clearBccEmails===!0&&b.bccEmails!==void 0)throw Error("Provide either `bccEmails` or `clearBccEmails` when calling `update_sequence`, not both.");if(b.branch!==void 0&&b.insertSteps!==void 0)throw Error("Provide either `branch` or `insertSteps` when calling `update_sequence`, not both.");fP(b);let w={...b};if(delete w.clearEnrollmentFieldPath,delete w.clearSendingWindow,delete w.clearBccEmails,b.clearEnrollmentFieldPath===!0)w.enrollmentFieldPath=null;if(b.clearSendingWindow===!0)w.sendingWindow=null;if(b.clearBccEmails===!0)w.bccEmails=null;return w}function jD(b,w,$){let W=j(b,w,"nodeId");if(!y(w.changes)||Object.keys(w.changes).length===0)throw Error(`\`changes\` must be a non-empty object for ${$} when calling \`${b}\`.`);let Q=j(b,w,"expectedUpdatedAt");return{nodeId:W,changes:w.changes,expectedUpdatedAt:Q}}function ID(b){let w=jD("update_sequence_node",b,"the node update");return{...b.confirmLiveChange!==void 0&&{confirmLiveChange:b.confirmLiveChange},nodeUpdates:[w]}}function VD(b){if(!Array.isArray(b.updates)||b.updates.length===0)throw Error("`updates` must be a non-empty array when calling `update_sequence_nodes`.");let w=new Set,$=b.updates.map((W,Q)=>{if(!y(W))throw Error(`\`updates[${Q}]\` must be an object when calling \`update_sequence_nodes\`.`);let G=jD("update_sequence_nodes",W,`updates[${Q}]`),X=String(G.nodeId);if(w.has(X))throw Error(`\`updates[${Q}]\` targets duplicate nodeId '${X}' when calling \`update_sequence_nodes\`.`);return w.add(X),G});return{...b.confirmLiveChange!==void 0&&{confirmLiveChange:b.confirmLiveChange},nodeUpdates:$}}function ND(b){let w=j("edit_sequence_graph",b,"action"),$=j("edit_sequence_graph",b,"graphRevision");if(!new Set(["move_node","delete_node","duplicate_node","replace_edges"]).has(w))throw Error("`action` must be `move_node`, `delete_node`, `duplicate_node`, or `replace_edges` when calling `edit_sequence_graph`.");let Q=F(b,"nodeId"),G=F(b,"afterNodeId"),X=F(b,"beforeNodeId"),Y=b.edges;if(w!=="replace_edges"&&!Q)throw Error(`\`nodeId\` is required for ${w} when calling \`edit_sequence_graph\`.`);if(w==="replace_edges"&&Q)throw Error("`nodeId` is not used with `replace_edges` when calling `edit_sequence_graph`.");let H=w==="move_node"||w==="duplicate_node";if(H&&(G?1:0)+(X?1:0)!==1)throw Error(`Provide exactly one of \`afterNodeId\` or \`beforeNodeId\` for ${w} when calling \`edit_sequence_graph\`.`);if(!H&&(G||X))throw Error(`\`afterNodeId\` and \`beforeNodeId\` are not used with ${w} when calling \`edit_sequence_graph\`.`);if((w==="replace_edges"||w==="delete_node"&&Y!==void 0)&&(!Array.isArray(Y)||Y.length===0))throw Error(`\`edges\` must contain the complete replacement topology for ${w} when calling \`edit_sequence_graph\`.`);if((w==="move_node"||w==="duplicate_node")&&Y!==void 0)throw Error(`\`edges\` is not used with ${w} when calling \`edit_sequence_graph\`.`);let J=Array.isArray(Y)?Y.map((D,z)=>{if(!y(D))throw Error(`\`edges\` item ${z+1} must be an object when calling \`edit_sequence_graph\`.`);let O=j("edit_sequence_graph",D,"sourceNodeId"),q=j("edit_sequence_graph",D,"targetNodeId");if(D.condition!==void 0&&D.condition!==null&&!y(D.condition))throw Error(`\`edges\` item ${z+1} \`condition\` must be an object when calling \`edit_sequence_graph\`.`);return{sourceNodeId:O,targetNodeId:q,...y(D.condition)?{condition:D.condition}:{}}}):void 0;return{...b.confirmStructuralChange!==void 0&&{confirmStructuralChange:b.confirmStructuralChange},graphEdit:{action:w,expectedRevision:$,...Q?{nodeId:Q}:{},...G?{afterNodeId:G}:{},...X?{beforeNodeId:X}:{},...J?{edges:J}:{}}}}function ED(b){let w=b.type==="sms",$;if(w){FW("insert_sequence_step","SMS step",b);let Q=F(b,"text"),G=Array.isArray(b.blocks)&&b.blocks.length>0;if(Q===void 0&&!G)throw Error("Provide `text` (or `blocks`) when inserting an SMS step with `insert_sequence_step`.");$={type:"sms"};for(let X of["text","blocks","imageUrls","label","name","ineligibleAction","delay","delayMs","waitUntil"])if(b[X]!==void 0)$[X]=b[X]}else{_b("insert_sequence_step",b,{requireContent:!0}),f$("insert_sequence_step","email step",b),$={subject:j("insert_sequence_step",b,"subject")};for(let Q of["name","previewText","html","blocks","delay","delayMs","waitUntil","senderProfileId","fromEmail","fromName","replyProfileId","replyTo","replyToName"])if(b[Q]!==void 0)$[Q]=b[Q]}let W={steps:[$]};if(b.afterNodeId!==void 0)W.afterNodeId=b.afterNodeId;return{...b.confirmStructuralChange!==void 0&&{confirmStructuralChange:b.confirmStructuralChange},insertSteps:W}}function TD(b){let w=F(b,"subscriberId"),$=b.fieldValues,W=$===void 0?void 0:Array.isArray($)?$:void 0;if($!==void 0&&W===void 0)throw Error("`fieldValues` must be an array when calling `cancel_sequence_enrollments`.");let Q=W?.map((Y)=>typeof Y==="string"?Y.trim():"").filter((Y)=>Y.length>0)??[];if(W?.some((Y)=>typeof Y!=="string")||W!==void 0&&Q.length===0)throw Error("`fieldValues` must contain at least one non-empty string when calling `cancel_sequence_enrollments`.");if(w!==void 0===Q.length>0)throw Error("Provide exactly one target when calling `cancel_sequence_enrollments`: `subscriberId` or `fieldValues`.");let G=F(b,"fieldPath"),X=F(b,"reason");return{...w!==void 0&&{subscriberId:w},...G!==void 0&&{fieldPath:G},...Q.length>0&&{fieldValues:Q},...typeof b.dryRun==="boolean"&&{dryRun:b.dryRun},...X!==void 0&&{reason:X}}}function _D(b){_b("create_campaign",b),H1("create_campaign",b);let w=F(b,"prompt")!==void 0,$=b.html!==void 0,W=b.blocks!==void 0,Q=b.templateId!==void 0;if(b.prompt!==void 0&&!w)throw Error("`prompt` cannot be empty when calling `create_campaign`.");if(w&&($||W||Q))throw Error("Provide either `prompt`, `html`, `blocks`, or `templateId` when calling `create_campaign`, not multiple content sources.");if(!w&&(b.style!==void 0||b.tone!==void 0))throw Error("`style` and `tone` can only be used with `prompt` when calling `create_campaign`.");if(!w&&F(b,"subject")===void 0)throw Error("`subject` is required unless `prompt` is provided when calling `create_campaign`.")}function SD(b){_b("create_template",b),H1("create_template",b);let w=F(b,"prompt")!==void 0,$=[w,b.html!==void 0,b.blocks!==void 0].filter(Boolean).length;if(b.prompt!==void 0&&!w)throw Error("`prompt` cannot be empty when calling `create_template`.");if($!==1)throw Error("Provide exactly one of `prompt`, `html`, or `blocks` when calling `create_template`.");if(!w&&(b.style!==void 0||b.tone!==void 0))throw Error("`style` and `tone` can only be used with `prompt` when calling `create_template`.");if(!w&&F(b,"subject")===void 0)throw Error("`subject` is required unless `prompt` is provided when calling `create_template`.")}function RD(b){if(F(b,"scheduledAt")===void 0)throw Error("`scheduledAt` is required when calling `schedule_campaign`.");if(b.targetLists!==void 0&&!y(b.targetLists))throw Error("`targetLists` must be an object when calling `schedule_campaign`.");if(b.sendTimeOptimization!==void 0){if(typeof b.sendTimeOptimization!=="boolean")throw Error("`sendTimeOptimization` must be a boolean when calling `schedule_campaign`.")}if(b.spreadOverHours!==void 0){if(typeof b.spreadOverHours!=="number"||!Number.isInteger(b.spreadOverHours)||b.spreadOverHours<1||b.spreadOverHours>72)throw Error("`spreadOverHours` must be an integer between 1 and 72 when calling `schedule_campaign`.")}if(b.recurringInterval!==void 0&&b.recurringInterval!=="weekly"&&b.recurringInterval!=="monthly")throw Error("`recurringInterval` must be 'weekly' or 'monthly' when calling `schedule_campaign`.")}function c$(b,w,$){let W=new Set(["companyId","landingPageId","name","slug","content"]),Q=Object.keys(w).filter((G)=>!W.has(G));if(Q.length>0)throw Error(`\`${b}\` accepts only \`name\`, \`slug\`, and \`content\` update fields. Unsupported field${Q.length===1?"":"s"}: ${Q.map((G)=>`\`${G}\``).join(", ")}.`);if($.requireUpdate&&w.name===void 0&&w.slug===void 0&&w.content===void 0)throw Error(`Provide at least one of \`name\`, \`slug\`, or \`content\` when calling \`${b}\`.`);return{...w.name!==void 0&&{name:w.name},...w.slug!==void 0&&{slug:w.slug},...w.content!==void 0&&{content:w.content}}}function kD(b){let w=new Set(["companyId","domain","verify"]),$=Object.keys(b).filter((W)=>!w.has(W));if($.length>0)throw Error(`\`update_landing_page_domain_settings\` accepts only \`domain\` and \`verify\`. Unsupported field${$.length===1?"":"s"}: ${$.map((W)=>`\`${W}\``).join(", ")}.`);if(b.domain===void 0&&b.verify!==!0)throw Error("Provide `domain` or `verify: true` when calling `update_landing_page_domain_settings`.");return{...b.domain!==void 0&&{domain:b.domain},...typeof b.verify==="boolean"&&{verify:b.verify}}}function vD(b){_b("create_transactional_email",b);let w=F(b,"prompt")!==void 0,$=b.html!==void 0,W=b.blocks!==void 0;if(b.prompt!==void 0&&!w)throw Error("`prompt` cannot be empty when calling `create_transactional_email`.");if(w&&($||W))throw Error("Provide either `prompt`, `html`, or `blocks` when calling `create_transactional_email`, not multiple content sources.");if(!w&&(b.style!==void 0||b.tone!==void 0))throw Error("`style` and `tone` can only be used with `prompt` when calling `create_transactional_email`.");if(!w&&!$&&!W)throw Error("Provide either `prompt`, `html`, or `blocks` when calling `create_transactional_email`.");if(!w&&F(b,"subject")===void 0)throw Error("`subject` is required unless `prompt` is provided when calling `create_transactional_email`.")}var Y0={type:"object",description:"Update Subscriber config. firstName, lastName, and customAttributeUpdates values may use trigger-event merge tags such as {{event.plan}}. Number and boolean values must be a literal or one standalone merge tag and are coerced after resolution.",properties:{label:{type:"string"},firstName:{type:["string","null"],description:"First name literal or merge tag; null clears the field."},lastName:{type:["string","null"],description:"Last name literal or merge tag; null clears the field."},status:{type:"string",enum:["active","unsubscribed","bounced"]},customAttributeUpdates:{type:"array",items:{type:"object",properties:{name:{type:"string"},value:{type:["string","number","boolean","null"],description:"Literal scalar, null to delete, or a standalone merge tag such as {{event.plan}}, {{event.amount}}, or {{event.active}}."},valueType:{type:"string",enum:["text","number","boolean"]}},required:["name","value"]}}},additionalProperties:!0},KW={senderProfileId:{type:"string",description:"Sender profile for this step's From identity. Mutually exclusive with fromEmail."},fromEmail:{type:"string",description:"From address for this step. Its domain must be configured and verified. Mutually exclusive with senderProfileId."},fromName:{type:"string",description:"Display name override for this step. Alone it only changes the visible name; with fromEmail it also names a newly created sender profile."},replyProfileId:{type:"string",description:"Reply profile for this step's Reply-To. Mutually exclusive with replyTo."},replyTo:{type:"string",description:"Reply-To address for this step. Mutually exclusive with replyProfileId."},replyToName:{type:"string",description:"Display name for a newly created reply profile. Requires replyTo."}},g$={type:"object",description:"A step to create inside a sequence path. Use type:'delay' for a standalone delay, type:'email' for an email, type:'create_discount' for a discount action, or type:'condition' for a condition gate.",properties:{type:{type:"string",enum:["email","delay","create_discount","discount","update_subscriber","condition","webhook"],description:"Sequence path step type. Omit for email steps; use delay for standalone waits or update_subscriber for action_update_attributes."},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","logic_condition","action_webhook"],description:"Advanced sequence path node type. Prefer type unless creating a non-email action."},config:{...Y0,description:"Config for advanced nodeType steps. For action_update_attributes, use the documented Update Subscriber fields and trigger-event merge tags; other node types accept their normal config fields.",additionalProperties:!0},subject:{type:"string",description:"Email subject. Required for email steps."},previewText:{type:"string",description:"Email preview text."},blocks:{type:"array",description:W1,items:{type:"object"}},html:{type:"string",description:"HTML content for email steps. Stored as one raw HTML block. Use this for imported provider HTML."},delay:G1,delayMs:{type:"number",description:"Delay in milliseconds. Useful for standalone type:'delay' steps."},waitUntil:Q1,name:{type:"string",description:"Email template name for email steps."},senderProfileId:{type:"string",description:"Sender profile for this email step. Omit to inherit the effective identity of the nearest sequence email. After a branch merge, only fields shared by every incoming path are inherited; conflicting fields use sequence or company defaults."},fromEmail:{type:"string",description:"From address for this email step. Its domain must be verified. Mutually exclusive with senderProfileId."},fromName:{type:"string",description:"Display name override for this email step. With fromEmail, also names a newly created sender profile."},replyProfileId:{type:"string",description:"Reply profile for this email step. Omit to inherit the effective Reply-To of the nearest sequence email. After a branch merge, only fields shared by every incoming path are inherited; conflicting fields use sequence or company defaults."},replyTo:{type:"string",description:"Reply-To address for this email step. Mutually exclusive with replyProfileId."},replyToName:{type:"string",description:"Display name for a newly created reply profile. Requires replyTo."},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"],description:"Discount provider. Use stripe to dynamically create a Stripe coupon plus promotion code, or shopify to dynamically create a Shopify Admin discount code."},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 CD(b){if(!b||typeof b!=="object")return null;let w=b;if(w.success!==!1)return null;if(typeof w.error==="string")return Error(w.error);if(w.error&&typeof w.error==="object"&&typeof w.error.message==="string")return Error(w.error.message);if(typeof w.message==="string")return Error(w.message);return Error("The tool returned an unsuccessful response.")}function PW(b){return b.trim().toLowerCase().replace(/\s+/g,"-")}function cP(b){let w=new URLSearchParams;if(typeof b.query==="string"&&b.query.trim()!=="")w.set("query",b.query.trim());if(Array.isArray(b.tags)&&b.tags.length>0)w.set("tags",b.tags.filter(($)=>typeof $==="string"&&$.trim()!=="").join(","));if(typeof b.list==="string"&&b.list.trim()!=="")w.set("list",b.list.trim());if(typeof b.listId==="string"&&b.listId.trim()!=="")w.set("listId",b.listId.trim());if(typeof b.listName==="string"&&b.listName.trim()!=="")w.set("listName",b.listName.trim());if(typeof b.segmentId==="string"&&b.segmentId.trim()!=="")w.set("segmentId",b.segmentId);if(typeof b.status==="string"&&b.status.trim()!=="")w.set("status",b.status.trim());return w.set("page",String(b.page)),w.set("limit",String(b.pageSize)),w}async function uD(b,w){let $=typeof b.limit==="number"&&Number.isFinite(b.limit)?Math.max(1,Math.trunc(b.limit)):void 0,W=Math.min(100,Math.max(1,$??100)),Q=[],G=1,X=0,Y=0,H=0;while(!0){let D=cP({query:b.query,tags:b.tags,list:b.list,listId:b.listId,listName:b.listName,segmentId:b.segmentId,status:b.status,page:G,pageSize:W}),z=await A("GET",`/api/v1/subscribers?${D.toString()}`,void 0,w);X=z.pagination?.total??z.subscribers.length,Y=z.pagination?.totalPages??1,H+=1,Q.push(...z.subscribers??[]);let O=$!==void 0&&Q.length>=$,q=z.pagination?G>=z.pagination.totalPages:(z.subscribers??[]).length<W;if(O||q)break;G+=1}let J=$!==void 0?Q.slice(0,$):Q;return{success:!0,subscribers:J,pagination:{page:1,limit:W,total:X,totalPages:Y,fetchedPages:H},returned:J.length,truncated:$!==void 0&&X>0&&J.length<X}}function gP(b){let w=typeof b.email==="string"&&b.email.trim()!==""?b.email.trim():void 0,$=typeof b.externalId==="string"&&b.externalId.trim()!==""?b.externalId.trim():void 0;return{...w?{email:w}:{},...$?{externalId:$}:{}}}function Aw(b,w){let $=gP(w);if(!$.email&&!$.externalId)throw Error(`Provide either \`email\` or \`externalId\` when calling \`${b}\`.`);return $}function m$(b,w){let $=new URLSearchParams;if(w?.includeMachineEngagement)$.set("includeMachineEngagement","true");let W=$.toString(),Q=W?`?${W}`:"";if(b.email)return`/api/v1/subscribers/${encodeURIComponent(b.email)}${Q}`;return $.set("externalId",String(b.externalId)),`/api/v1/subscribers/external?${$.toString()}`}function MW(b){if(b.email)return`/api/v1/subscribers/${encodeURIComponent(b.email)}/notes`;let w=new URLSearchParams;return w.set("externalId",String(b.externalId)),`/api/v1/subscribers/external/notes?${w.toString()}`}async function H0(b,w,$){return A("GET",m$(b,$),void 0,w)}function Vb(b,w,$,W){let Q=F(w,$);if(Q===void 0)return;if(!W.includes(Q))throw Error(`\`${$}\` must be one of ${W.join(", ")} when calling \`${b}\`.`);return Q}function J0(b,w,$,W){let Q=j(b,w,$);if(!W.includes(Q))throw Error(`\`${$}\` must be one of ${W.join(", ")} when calling \`${b}\`.`);return Q}function zw(b,w,$,W,Q){let G=w[$];if(G===void 0)return;if(typeof G!=="number"||!Number.isInteger(G)||G<W||G>Q)throw Error(`\`${$}\` must be an integer between ${W} and ${Q} when calling \`${b}\`.`);return G}function mP(b,w){let $=[],W=Vb(b,w,"eventType",k$);if(W)$.push(W);if(w.eventTypes!==void 0){if(!Array.isArray(w.eventTypes))throw Error(`\`eventTypes\` must be an array when calling \`${b}\`.`);w.eventTypes.forEach((Q,G)=>{if(typeof Q!=="string")throw Error(`\`eventTypes\` item ${G+1} must be a string when calling \`${b}\`.`);let X=Q.trim();if(!k$.includes(X))throw Error(`\`eventTypes\` item ${G+1} must be one of ${k$.join(", ")} when calling \`${b}\`.`);$.push(X)})}return[...new Set($)]}function ZW(b,w){let $=new URLSearchParams,W=mP(b,w);if(W.length>0)$.set("eventTypes",W.join(","));let Q=Vb(b,w,"period",["1h","24h","7d","30d","90d"]);if(Q)$.set("period",Q);let G=F(w,"start");if(G)$.set("start",G);let X=F(w,"end");if(X)$.set("end",X);let Y=zw(b,w,"page",1,1e6);if(Y!==void 0)$.set("page",String(Y));let H=zw(b,w,"limit",1,500);if(H!==void 0)$.set("limit",String(H));if(w.includeMachineEngagement===!0)$.set("includeMachineEngagement","true");return $}function jW(b,w){if(w.events===void 0)return;if(!Array.isArray(w.events))throw Error(`\`events\` must be an array when calling \`${b}\`.`);let $=w.events.map((W,Q)=>{if(typeof W!=="string"||!Y1.includes(W))throw Error(`\`events\` item ${Q+1} must be one of ${Y1.join(", ")} when calling \`${b}\`.`);return W});if($.length===0)throw Error(`\`events\` must include at least one event type when calling \`${b}\`.`);return $}function IW(b,w){if(!Array.isArray(w.emails))throw Error(`\`emails\` must be an array when calling \`${b}\`.`);let $=[];if(w.emails.forEach((W,Q)=>{if(typeof W!=="string")throw Error(`\`emails\` item ${Q+1} must be a string when calling \`${b}\`.`);let G=W.trim();if(G.length>0)$.push(G)}),$.length===0)throw Error(`\`emails\` must include at least one email address when calling \`${b}\`.`);if($.length>JW)throw Error(`\`emails\` must include no more than ${JW} email addresses when calling \`${b}\`. Split larger batches into multiple calls.`);return $}function xD(b,w,$,W){let Q=w[$];if(Q===void 0)return;if(!Array.isArray(Q))throw Error(`\`${$}\` must be an array when calling \`${b}\`.`);let G=[];if(Q.forEach((X,Y)=>{if(typeof X!=="string")throw Error(`\`${$}\` item ${Y+1} must be a string when calling \`${b}\`.`);let H=X.trim();if(H.length>0)G.push(H)}),G.length===0)throw Error(`\`${$}\` must include at least one ${W} when calling \`${b}\`.`);return G}function yD(b){let $=xD("enroll_subscribers_in_sequence",b,"emails","email address"),W=xD("enroll_subscribers_in_sequence",b,"subscriberIds","subscriber ID"),Q=($?.length??0)+(W?.length??0);if(Q===0)throw Error("Provide `emails` or `subscriberIds` when calling `enroll_subscribers_in_sequence`.");if(Q>DW)throw Error(`\`emails\` and \`subscriberIds\` must include no more than ${DW} total targets when calling \`enroll_subscribers_in_sequence\`. Split larger batches into multiple calls.`);let G=F(b,"targetNodeId");return{...$!==void 0&&{emails:$},...W!==void 0&&{subscriberIds:W},...G!==void 0&&{targetNodeId:G}}}import{readFileSync as nP,statSync as lP}from"node:fs";import{basename as iP}from"node:path";var pP={pdf:"application/pdf",epub:"application/epub+zip",zip:"application/zip",png:"image/png",jpg:"image/jpeg",jpeg:"image/jpeg",gif:"image/gif",webp:"image/webp",mp3:"audio/mpeg",wav:"audio/wav",mp4:"video/mp4",txt:"text/plain",csv:"text/csv"};function oP(b){let w=b.split(".").pop()?.toLowerCase()??"";return pP[w]??null}var dP=104857600;async function hD(b,w){if(!z0())throw Error("`filePath` is only supported when the MCP server runs locally on your machine. Host the file somewhere public and pass `url` instead.");let $=oP(b);if(!$)throw Error("Unsupported file type. Use PDF, ePub, ZIP, image, audio, video, or text files.");let W=lP(b).size;if(W>dP)throw Error(`File is too large (${Math.round(W/1048576)}MB). Delivery files must be 100MB or smaller.`);let Q=nP(b),G=await A("POST","/api/v1/products/delivery/upload-url",{filename:iP(b),contentType:$,fileSizeBytes:W},w),X=await fetch(G.uploadUrl,{method:"PUT",headers:{"Content-Type":$},body:Q});if(!X.ok)throw Error(`File upload failed (${X.status})`);return{url:G.publicUrl,fileName:G.fileName,fileSizeBytes:W,mimeType:$}}async function n$(b){let w=F(b,"companyId");if(w)return w;let $=Tw();if($)return $;try{return(await A("GET","/api/v1/account")).currentCompanyId??void 0}catch{return}}async function fD(b,w){let $=await n$(w);if(!$)throw Error(`A company is required when calling \`${b}\`. Call \`get_account\`, then \`select_company\`, or pass \`companyId\` explicitly.`);return $}function J1(b,w){if(!y(b)||!w)return b;return{...b,url:w}}function cD(b,w){if(!y(b))return b;return{...b,...w.campaign!==void 0&&{url:w.campaign},...w.campaignPreview!==void 0&&{previewUrl:w.campaignPreview}}}function D0(b,w,$){if(!Array.isArray(b)||!w)return b;return b.map((W)=>{if(!y(W))return W;let Q=F(W,"id");if(!Q)return W;let G=Hw({companyId:w,...$==="campaign"&&{campaignId:Q},...$==="landingPage"&&{landingPageId:Q},...$==="sequence"&&{sequenceId:Q},...$==="template"&&{emailId:Q},...$==="transactional"&&{transactionalId:Q}});if($==="campaign")return cD(W,G.urls);let X=$==="sequence"?G.urls.sequence:$==="landingPage"?G.urls.landingPage:$==="template"?G.urls.email:G.urls.transactionalEmail;return J1(W,X)})}function tP(b){if(!Array.isArray(b))return b;return b.map((w)=>{if(!y(w))return w;let $=F(w,"id");if(!$)return w;let W=Hw({companyId:$});return{...w,url:W.urls.dashboard,settingsUrl:W.urls.settings}})}var VW=new Set(["get_account","select_company","create_company","get_company","update_company","list_campaigns","get_campaign","get_email_send","create_campaign","update_campaign","schedule_campaign","send_test_email","cancel_campaign","pause_campaign","resume_campaign","duplicate_campaign","resend_campaign_to_non_openers","list_landing_pages","get_landing_page","create_landing_page","update_landing_page","publish_landing_page","unpublish_landing_page","delete_landing_page","list_sequences","get_sequence","create_sequence","update_sequence","update_sequence_node","update_sequence_nodes","edit_sequence_graph","insert_sequence_step","enable_sequence","disable_sequence","pause_sequence_enrollments","resume_sequence_enrollments","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","set_template_localization","sync_template_localizations","list_transactional_emails","get_transactional_email","create_transactional_email","update_transactional_email"]);async function gD(b,w,$){if(!y($)||!VW.has(b))return $;let W=y($.company)?$.company:void 0,G=F($,"selectedCompanyId")??F($,"currentCompanyId")??F($,"companyId")??(W?F(W,"id"):void 0)??(W?F(W,"companyId"):void 0)??await n$(w);if(!G)return $;let X=y($.campaign)?$.campaign:void 0,Y=y($.sequence)?$.sequence:void 0,H=y($.landingPage)?$.landingPage:void 0,J=y($.template)?$.template:void 0,D=y($.transactional)&&!Array.isArray($.transactional)?$.transactional:void 0,z={companyId:G,campaignId:F(w,"campaignId")??F($,"campaignId")??(X?F(X,"id"):void 0),landingPageId:F(w,"landingPageId")??F($,"landingPageId")??(H?F(H,"id"):void 0),sequenceId:F(w,"sequenceId")??F($,"sequenceId")??(Y?F(Y,"id"):void 0),emailId:F($,"templateId")??(J?F(J,"id"):void 0)??(D?F(D,"emailId"):void 0)??F(w,"templateId"),transactionalId:F(w,"transactionalId")??(D?F(D,"id"):void 0)??F(w,"idOrSlug"),emailSendId:F(w,"emailSendId")??F($,"emailSendId")??(y($.emailSend)?F($.emailSend,"id"):void 0),status:F(w,"status")},O=Hw(z),q=W?Hw({companyId:G}):void 0;return{...$,...Array.isArray($.companies)&&{companies:tP($.companies)},...Array.isArray($.campaigns)&&{campaigns:D0($.campaigns,G,"campaign")},...Array.isArray($.landingPages)&&{landingPages:D0($.landingPages,G,"landingPage")},...Array.isArray($.sequences)&&{sequences:D0($.sequences,G,"sequence")},...Array.isArray($.templates)&&{templates:D0($.templates,G,"template")},...Array.isArray($.transactional)&&{transactional:D0($.transactional,G,"transactional")},...W&&q!==void 0&&{company:{...W,url:q.urls.dashboard,settingsUrl:q.urls.settings}},...X&&O.urls.campaign!==void 0&&{campaign:cD(X,O.urls)},...Y&&O.urls.sequence!==void 0&&{sequence:J1(Y,O.urls.sequence)},...H&&O.urls.landingPage!==void 0&&{landingPage:J1(H,O.urls.landingPage)},...J&&O.urls.email!==void 0&&{template:J1(J,O.urls.email)},...D&&O.urls.transactionalEmail!==void 0&&{transactional:J1(D,O.urls.transactionalEmail)},...y($.emailSend)&&O.urls.emailSend!==void 0&&{emailSend:J1($.emailSend,O.urls.emailSend)},appUrls:O.urls}}import{readFileSync as rP,statSync as eP}from"node:fs";import{basename as sP,extname as nD}from"node:path";var EW=5242880,aP=Math.ceil(EW/3)*4,bM=Math.ceil(aP*1.05)+256,lD={".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".webp":"image/webp"},wM=new Set(Object.values(lD));function NW(b){return b?.split(";")[0]?.trim().toLowerCase()||void 0}function $M(b){return lD[nD(b).toLowerCase()]}function WM(b){let w=nD(b);return(w?b.slice(0,-w.length):b).replace(/[-_]+/g," ").trim()||"Image"}function QM(b){if(b.length>bM)throw Error("Image assets must be 5MB or smaller.")}function GM(b){let w=0,$=0;for(let Q=0;Q<b.length;Q+=1){let G=b.charCodeAt(Q);if(G===9||G===10||G===11||G===12||G===13||G===32)continue;w+=1,$=G===61?$+1:0}if(Math.floor(w*3/4)-Math.min($,2)>EW)throw Error("Image assets must be 5MB or smaller.")}function XM(b){QM(b);let w=b.trim(),$=/^data:([^;,]+);base64,([\s\S]+)$/i.exec(w),W=$?.[2]??w;GM(W);let Q=W.replace(/\s+/g,"");if(Q.length===0||Q.length%4===1||!/^[A-Za-z0-9+/]*={0,2}$/.test(Q))throw Error("`imageBase64` must contain valid base64 image bytes.");return{bytes:Buffer.from(Q,"base64"),...$?.[1]?{dataUrlContentType:NW($[1])}:{}}}function mD(b){if(b<=0)throw Error("The image file is empty.");if(b>EW)throw Error("Image assets must be 5MB or smaller.")}function YM(b){let w=$M(b.filename)??NW(b.explicitContentType)??NW(b.dataUrlContentType);if(!w||!wM.has(w))throw Error("Unsupported image type. Use PNG, JPEG, GIF, or WebP.");return w}function HM(b){let w,$,W;if(b.filePath!==void 0){if(!z0())throw Error("`filePath` is only supported when the MCP server runs locally on your machine. For a remote MCP connection, pass `imageBase64` and `filename` instead.");let G=eP(b.filePath).size;mD(G),w=rP(b.filePath),$=b.filename??sP(b.filePath)}else{if(!b.imageBase64)throw Error("Provide either `filePath` or `imageBase64` when uploading an image asset.");if(!b.filename)throw Error("`filename` is required with `imageBase64` when uploading an image asset.");let G=XM(b.imageBase64);w=G.bytes,W=G.dataUrlContentType,$=b.filename,mD(w.byteLength)}let Q=YM({filename:$,explicitContentType:b.contentType,dataUrlContentType:W});return{bytes:w,filename:$,contentType:Q,altText:b.altText??WM($)}}async function iD(b){let w=HM(b),$=w.bytes.byteLength,W=await A("POST","/api/v1/media/upload-url",{filename:w.filename,contentType:w.contentType,fileSizeBytes:$},b.companyId);return await fW(W.uploadUrl,w.bytes,w.contentType,b.companyId),(await A("POST","/api/v1/media/complete-upload",{key:W.key,filename:W.fileName,contentType:w.contentType,fileSizeBytes:$,...b.sourceWidth!==void 0&&{width:b.sourceWidth},...b.sourceHeight!==void 0&&{height:b.sourceHeight},altText:w.altText},b.companyId)).asset}var JM={type:"boolean",description:"Whether the Sequenzy operation succeeded."},DM={type:"string",description:"Human-readable status, confirmation, or next-step message."},zM={type:"string",description:"Additional context about the result."};function t(b){return{type:"object",description:b,additionalProperties:!0}}function AM(b){return{type:"array",description:b,items:t("One item in the returned collection.")}}function T(b){return{type:"string",description:b}}function Kb(b){return{type:"number",description:b}}function eb(b){return{type:"boolean",description:b}}function P(b){return t(`The ${b} record returned by Sequenzy.`)}function i(b){return AM(`List of ${b} records returned by Sequenzy.`)}var OM={appUrls:t("Dashboard URLs for relevant Sequenzy resources."),url:T("Primary dashboard URL for this result."),settingsUrl:T("Company settings URL when available.")},qM={success:JM,message:DM,note:zM,items:{type:"array",description:"Fallback array wrapper used only when a tool returns a bare array.",items:t("One returned item.")},value:t("Fallback object wrapper used only when a tool returns a non-object value.")},LM={get_account:{account:P("account"),companies:i("company"),apiKeyPermissions:t("Current API key preset and scopes, whether common marketing work is discoverable, any missing marketing read scopes, and the API Keys management URL."),currentCompanyId:T("Company ID selected by the authenticated API key, when available."),selectedCompanyId:T("Company ID selected locally for subsequent MCP calls, when available.")},select_company:{companyId:T("Selected company ID."),companyName:T("Selected company name.")},get_app_urls:{dashboard:T("Company dashboard URL."),settings:T("Company settings URL."),campaign:T("Campaign editor URL."),landingPage:T("Landing page editor URL."),sequence:T("Sequence editor URL."),email:T("Email editor URL."),transactionalEmail:T("Transactional email URL."),emailSend:T("Sent email detail URL."),domain:T("Sending domain settings URL."),urls:t("All generated URLs keyed by resource type.")},create_company:{company:P("company"),autoSelected:eb("Whether the new company was selected for subsequent MCP calls.")},update_company:{company:P("company")},get_company:{company:P("company")},get_sync_rules:{syncRules:{type:"array",description:"Effective sync rules for the company.",items:t("One sync rule.")},isDefault:eb("Whether the company still uses the platform default rules.")},update_sync_rules:{syncRules:{type:"array",description:"Effective sync rules after the update.",items:t("One sync rule.")},isDefault:eb("Whether the company now uses the platform default rules.")},get_shopify_automation_settings:{browseAbandonment:t("Effective browse-abandonment settings (defaults applied)."),priceDrop:t("Effective price-drop settings (defaults applied)."),shopDomain:T("Connected Shopify store domain.")},update_shopify_automation_settings:{browseAbandonment:t("Effective browse-abandonment settings after the update."),priceDrop:t("Effective price-drop settings after the update."),shopDomain:T("Connected Shopify store domain.")},create_api_key:{apiKey:t("Created API key metadata: the newly created secret in `key`, plus `scopes` listing the assigned permission scopes (null when the key has full access)."),key:T("Newly created API key if the API response uses the short key field.")},list_websites:{websites:i("sender website")},add_website:{website:P("Sending domain with the SPF, DKIM, MAIL FROM, and inbound DNS records required for setup.")},add_sending_domain:{website:P("Sending domain with the SPF, DKIM, MAIL FROM, and inbound DNS records required for setup.")},check_website:{website:P("sender website"),ready:eb("Whether the sender website is ready."),status:T("Current processing or verification status.")},verify_sending_domain:{website:P("Sending domain with current aggregate, SPF, DKIM, and MAIL FROM verification details."),verified:eb("Whether the sending domain passed the fresh verification check."),message:T("Verification result summary.")},get_integration_guide:{guide:P("integration guide"),code:T("Generated integration code or example."),steps:{type:"array",description:"Setup steps for the requested integration.",items:t("One setup step.")}},add_subscriber:{subscriber:P("subscriber")},update_subscriber:{subscriber:P("subscriber")},remove_subscriber:{subscriber:P("subscriber"),hardDeleted:eb("Whether the subscriber was permanently deleted.")},get_subscriber:{subscriber:P("subscriber")},list_subscriber_notes:{notes:i("subscriber note")},add_subscriber_note:{note:P("subscriber note")},delete_subscriber_note:{id:T("Deleted subscriber note ID."),deleted:eb("Whether the subscriber note was deleted.")},search_subscribers:{subscribers:i("subscriber"),pagination:t("Pagination metadata."),returned:Kb("Number of subscribers returned."),truncated:eb("Whether the result was truncated by the requested limit.")},list_products:{products:i("product")},upsert_products:{products:i("product"),created:Kb("Number of products created."),updated:Kb("Number of products updated.")},delete_product:{productId:T("Deleted product ID.")},attach_product_file:{product:P("product"),delivery:P("digital delivery file")},remove_product_file:{product:P("product")},upload_image_asset:{asset:P("hosted image asset"),imageBlock:t("Ready-to-insert Sequenzy image block using the hosted asset URL.")},sync_products:{job:P("product sync job"),jobId:T("Queued product sync job ID.")},list_tags:{tags:i("tag")},create_tag:{tag:P("tag")},update_tag:{tag:P("tag")},delete_tag:{tagId:T("Deleted tag ID.")},list_lists:{lists:i("list")},create_list:{list:P("list")},update_list:{list:P("list")},delete_list:{listId:T("Deleted list ID.")},add_subscribers_to_list:{list:P("list"),added:Kb("Number of subscribers added to the list."),skipped:Kb("Number of subscribers skipped.")},remove_subscribers_from_list:{list:P("list"),removed:Kb("Number of subscribers removed from the list."),skipped:Kb("Number of subscribers skipped.")},list_segments:{segments:i("segment")},create_segment:{segment:P("segment")},update_segment:{segment:P("segment")},delete_segment:{segmentId:T("Deleted segment ID.")},get_segment_count:{count:Kb("Number of subscribers matching the segment."),segmentId:T("Segment ID that was counted.")},list_audience_syncs:{audienceSyncs:i("audience sync")},list_ad_accounts:{adAccounts:i("ad account")},create_audience_sync:{audienceSync:P("audience sync")},update_audience_sync:{audienceSync:P("audience sync")},delete_audience_sync:{audienceSyncId:T("Deleted audience sync ID.")},sync_audience_now:{audienceSync:P("audience sync"),job:P("audience sync job"),jobId:T("Queued audience sync job ID.")},list_templates:{templates:i("email template")},get_template:{template:P("email template")},create_template:{template:P("email template")},update_template:{template:P("email template")},set_template_localization:{templateId:T("Localized template ID."),localization:P("template localization")},sync_template_localizations:{templateId:T("Template ID queued for localization."),queuedLocales:{type:"array",description:"Locale codes queued for AI translation.",items:T("One queued locale code.")},queuedVariantCount:Kb("Number of localized variants queued for translation.")},delete_template:{templateId:T("Deleted template ID.")},list_ab_tests:{abTests:i("A/B test")},get_ab_test:{abTest:P("A/B test")},get_ab_test_stats:{abTest:P("A/B test"),stats:P("A/B test statistics")},restart_ab_test:{abTest:P("A/B test")},update_ab_test_variant:{abTest:P("A/B test"),variant:P("A/B test variant")},create_ab_test:{abTest:P("A/B test")},add_ab_test_variant:{abTest:P("A/B test"),variant:P("A/B test variant")},delete_ab_test_variant:{abTest:P("A/B test"),variantId:T("Deleted A/B test variant ID.")},delete_ab_test:{abTestId:T("Deleted A/B test ID.")},list_campaigns:{campaigns:i("campaign")},get_campaign:{campaign:P("campaign")},get_email_send:{emailSend:P("email send")},create_campaign:{campaign:P("campaign")},update_campaign:{campaign:P("campaign")},schedule_campaign:{campaign:P("campaign"),scheduledAt:T("Scheduled send timestamp.")},send_test_email:{emailSend:P("test email send"),recipient:T("Test email recipient.")},send_test_sms:{smsSendId:T("Created test SMS send ID."),toPhone:T("Normalized E.164 destination phone.")},cancel_campaign:{campaign:P("campaign")},pause_campaign:{campaign:P("campaign")},resume_campaign:{campaign:P("campaign")},delete_campaign:{campaignId:T("Deleted campaign ID.")},duplicate_campaign:{campaign:P("duplicated campaign")},resend_campaign_to_non_openers:{campaign:P("non-opener resend draft campaign"),estimatedNonOpenerCount:Kb("Estimated number of subscribers who haven't opened the original campaign.")},list_landing_pages:{landingPages:i("landing page")},get_landing_page:{landingPage:P("landing page")},create_landing_page:{landingPage:P("landing page")},update_landing_page:{landingPage:P("landing page")},delete_landing_page:{landingPageId:T("Deleted landing page ID.")},publish_landing_page:{landingPage:P("landing page")},unpublish_landing_page:{landingPage:P("landing page")},connect_landing_page_domain:{landingPage:P("landing page"),domain:T("Connected landing page domain.")},update_landing_page_domain_settings:{landingPage:P("landing page"),domain:T("Landing page domain.")},list_sequences:{sequences:i("sequence")},get_sequence:{sequence:P("sequence")},create_sequence:{sequence:P("sequence"),eventTrackingCode:T("Ready-to-adapt code for sending a custom trigger event, including any matching-field property."),eventTracking:t("Custom-event endpoint, payload contract, example payload, documentation URL, and get_integration_guide arguments."),requiredEvents:{type:"array",description:"Event names the application or an integration must send.",items:T("One required event name.")}},update_sequence:{sequence:P("sequence")},update_sequence_node:{sequence:P("sequence")},update_sequence_nodes:{sequence:P("sequence")},edit_sequence_graph:{sequence:P("sequence")},insert_sequence_step:{sequence:P("sequence"),insertedNodeIds:{type:"array",description:"Node IDs created for the inserted step, including any delay node.",items:T("Inserted automation node ID.")},insertedEmailIds:{type:"array",description:"Email template IDs created for the inserted step.",items:T("Inserted email template ID.")},insertedEmailCount:Kb("Number of email steps inserted.")},enable_sequence:{sequence:P("sequence")},disable_sequence:{sequence:P("sequence")},pause_sequence_enrollments:{sequenceId:T("Sequence ID."),enrollmentPaused:eb("Whether new sequence enrollments are paused.")},resume_sequence_enrollments:{sequenceId:T("Sequence ID."),enrollmentPaused:eb("Whether new sequence enrollments are paused.")},enroll_subscribers_in_sequence:{sequence:P("sequence"),enrollments:i("sequence enrollment"),enrolled:Kb("Number of subscribers enrolled."),skipped:Kb("Number of subscribers skipped.")},cancel_sequence_enrollments:{sequence:P("sequence"),cancelled:Kb("Number of enrollments cancelled."),skipped:Kb("Number of enrollments skipped.")},delete_sequence:{sequenceId:T("Deleted sequence ID.")},list_transactional_emails:{transactional:i("transactional email")},get_transactional_email:{transactional:P("transactional email")},create_transactional_email:{transactional:P("transactional email")},update_transactional_email:{transactional:P("transactional email")},send_email:{emailSend:P("transactional email send"),transactional:P("transactional email")},get_stats:{stats:P("account or company statistics")},get_campaign_stats:{campaign:P("campaign"),stats:P("campaign statistics"),clickedLinks:{type:"array",description:"Per-link click breakdown, most clicked first (top 20). Each entry has url, clicks, and percentage (that link's share of every recorded link click). Present only when the campaign has tracked link clicks.",items:t("One clicked link with url/clicks/share.")},polls:{type:"array",description:`Poll and NPS summaries. Each subscriber counts once per campaign poll block using their latest answer to that block; NPS entries include score, average, and promoter/passive/detractor counts. To list the exact historical respondents behind a count, use the summary blockId and the get_campaign_stats campaignId with create_segment. ${Ew} A summary's attributeKey identifies the subscriber attribute that stores their current/latest response and may be overwritten by a later poll that reuses the key.`,items:t("One poll or NPS results summary.")}},get_sequence_stats:{sequence:P("sequence"),stats:P("sequence statistics")},list_campaign_events:{events:i("campaign email event"),pagination:t("Pagination metadata.")},list_sequence_events:{events:i("sequence email event"),pagination:t("Pagination metadata.")},get_subscriber_activity:{activity:i("subscriber activity event"),subscribers:i("subscriber"),pagination:t("Pagination metadata.")},list_team_members:{members:i("team member"),invitations:i("team invitation")},invite_team_member:{invitation:P("team invitation")},cancel_team_invitation:{invitationId:T("Cancelled invitation ID.")},list_conversations:{conversations:i("inbox conversation"),pagination:t("Pagination metadata.")},get_conversation:{conversation:P("inbox conversation"),messages:i("conversation message")},reply_to_conversation:{conversation:P("inbox conversation"),message:P("conversation message")},update_conversation_status:{conversation:P("inbox conversation")},mark_conversation_read:{conversation:P("inbox conversation")},list_webhooks:{webhooks:i("outbound webhook")},create_webhook:{webhook:P("outbound webhook")},update_webhook:{webhook:P("outbound webhook")},delete_webhook:{webhookId:T("Deleted outbound webhook ID.")},test_webhook:{webhook:P("outbound webhook"),delivery:P("test webhook delivery")},list_webhook_deliveries:{deliveries:i("webhook delivery")},replay_webhook_delivery:{delivery:P("webhook delivery"),job:P("webhook replay job")},generate_email:{email:P("generated email"),html:T("Generated HTML email body."),blocks:{type:"array",description:"Generated Sequenzy email blocks, wrapped with company branding (logo + footer) unless applyBranding was false.",items:t("One generated email block.")},subject:T("Generated subject line."),previewText:T("Generated inbox preview text.")},generate_sequence:{sequence:P("generated sequence"),steps:i("generated sequence step")},generate_subject_lines:{subjectLines:{type:"array",description:"Generated subject line variants.",items:T("One generated subject line.")},variants:i("generated subject line variant")},generate_sms:{prompt:T("The prompt the messages were generated for."),messages:{type:"array",description:"Generated SMS message variants with encoding and segment counts.",items:t("One generated SMS message.")}},get_sms_settings:{sms:t("SMS add-on status: enabled, planEligible, creditsBalance, brandPrefix, numbers, readyToSend (paid plan or credits plus an active number).")},submit_feedback:{}};function UM(b){let w=LM[b];if(w===void 0)throw Error(`MCP tool "${b}" must define outputSchema properties.`);return{type:"object",description:`Structured content returned by the \`${b}\` MCP tool.`,properties:{...qM,...w,...VW.has(b)?OM:{}},additionalProperties:!0}}function pD(b){return{...b,outputSchema:UM(b.name)}}function oD(b){if(y(b))return b;if(Array.isArray(b))return{items:b};return{value:b}}var dD=[{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."},includeMachineEngagement:lb},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:`${Dw} Mutually exclusive with html.`,items:{type:"object"}}},required:["abTestId","variantId"],additionalProperties:!1}},{name:"create_ab_test",description:"Create a campaign A/B test. Control variant A is created automatically from the campaign's current email; optionally provide extra variants. The campaign must be in draft or rejected status, and each campaign can only have one A/B test.",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},campaignId:{type:"string",description:"Draft campaign ID to create the A/B test for."},name:{type:"string",description:"Optional A/B test name."},testPercentage:{type:"number",description:"Percentage of the audience used for the test phase, from 5 to 50. Defaults to 20."},testDurationMinutes:{type:"number",description:"Test phase duration in minutes before the winner is selected, from 15 to 1440. Defaults to 240."},winnerCriteria:{type:"string",enum:["open_rate","click_rate"],description:"Winner selection criteria. Defaults to open_rate."},variants:{type:"array",description:"Optional extra variants to create in addition to control variant A.",items:{type:"object",properties:{subject:{type:"string",description:"Variant subject line."},previewText:{type:"string",description:"Variant preview text."},blocks:{type:"array",description:Dw,items:{type:"object"}}},required:["subject"]}}},required:["campaignId"]}},{name:"add_ab_test_variant",description:"Add a variant to a draft campaign A/B test. Variants cannot be added after the test has started.",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"},subject:{type:"string",description:"Variant subject line."},previewText:{type:"string",description:"Variant preview text."},blocks:{type:"array",description:Dw,items:{type:"object"}}},required:["abTestId","subject"]}},{name:"delete_ab_test_variant",description:"Permanently delete a variant from a draft campaign A/B test. This cannot be undone. Variant A is the control and cannot be deleted, and the test must keep at least the minimum number of variants. Variants cannot be removed after the test has started.",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 to delete."}},required:["abTestId","variantId"]}},{name:"delete_ab_test",description:"Permanently delete a campaign A/B test and all of its variants. This cannot be undone. Running tests (testing or winner_selected) cannot be deleted, and the linked campaign must be in draft or rejected 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 to delete."}},required:["abTestId"]}}];var tD=[{name:"get_account",description:`Get current account information including available companies, the current API key's permission scopes, and the API Keys management URL. Call this after a missing-scope error to inspect access and find the replacement-key settings. IMPORTANT: If you have access to multiple companies, you MUST either:
|
|
28
|
+
`)}q.write("payload.value = newResult;"),q.write("return payload;");let k=q.compile();return(S,h)=>k(O,S,h)},G,X=_w,Y=!A0.jitless,J=Y&&a$.value,D=w.catchall,z;b._zod.parse=(O,q)=>{z??(z=W.value);let B=O.value;if(!X(B))return O.issues.push({expected:"object",code:"invalid_type",input:B,inst:b}),O;if(Y&&J&&q?.async===!1&&q.jitless!==!0){if(!G)G=Q(w.shape);if(O=G(O,q),!D)return O;return C9([],B,O,q,z,b)}return $(O,q)}});function rQ(b,w,$,W){for(let G of b)if(G.issues.length===0)return w.value=G.value,w;let Q=b.filter((G)=>!Uw(G));if(Q.length===1)return w.value=Q[0].value,Q[0];return w.issues.push({code:"invalid_union",input:w.value,inst:$,errors:b.map((G)=>G.issues.map((X)=>ub(X,W,Sb())))}),w}var z4=U("$ZodUnion",(b,w)=>{e.init(b,w),o(b._zod,"optin",()=>w.options.some((Q)=>Q._zod.optin==="optional")?"optional":void 0),o(b._zod,"optout",()=>w.options.some((Q)=>Q._zod.optout==="optional")?"optional":void 0),o(b._zod,"values",()=>{if(w.options.every((Q)=>Q._zod.values))return new Set(w.options.flatMap((Q)=>Array.from(Q._zod.values)));return}),o(b._zod,"pattern",()=>{if(w.options.every((Q)=>Q._zod.pattern)){let Q=w.options.map((G)=>G._zod.pattern);return new RegExp(`^(${Q.map((G)=>L1(G.source)).join("|")})$`)}return});let $=w.options.length===1,W=w.options[0]._zod.run;b._zod.parse=(Q,G)=>{if($)return W(Q,G);let X=!1,Y=[];for(let H of w.options){let J=H._zod.run({value:Q.value,issues:[]},G);if(J instanceof Promise)Y.push(J),X=!0;else{if(J.issues.length===0)return J;Y.push(J)}}if(!X)return rQ(Y,Q,b,G);return Promise.all(Y).then((H)=>{return rQ(H,Q,b,G)})}}),u9=U("$ZodDiscriminatedUnion",(b,w)=>{z4.init(b,w);let $=b._zod.parse;o(b._zod,"propValues",()=>{let Q={};for(let G of w.options){let X=G._zod.propValues;if(!X||Object.keys(X).length===0)throw Error(`Invalid discriminated union option at index "${w.options.indexOf(G)}"`);for(let[Y,H]of Object.entries(X)){if(!Q[Y])Q[Y]=new Set;for(let J of H)Q[Y].add(J)}}return Q});let W=fw(()=>{let Q=w.options,G=new Map;for(let X of Q){let Y=X._zod.propValues?.[w.discriminator];if(!Y||Y.size===0)throw Error(`Invalid discriminated union option at index "${w.options.indexOf(X)}"`);for(let H of Y){if(G.has(H))throw Error(`Duplicate discriminator value "${String(H)}"`);G.set(H,X)}}return G});b._zod.parse=(Q,G)=>{let X=Q.value;if(!_w(X))return Q.issues.push({code:"invalid_type",expected:"object",input:X,inst:b}),Q;let Y=W.value.get(X?.[w.discriminator]);if(Y)return Y._zod.run(Q,G);if(w.unionFallback)return $(Q,G);return Q.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:w.discriminator,input:X,path:[w.discriminator],inst:b}),Q}}),y9=U("$ZodIntersection",(b,w)=>{e.init(b,w),b._zod.parse=($,W)=>{let Q=$.value,G=w.left._zod.run({value:Q,issues:[]},W),X=w.right._zod.run({value:Q,issues:[]},W);if(G instanceof Promise||X instanceof Promise)return Promise.all([G,X]).then(([H,J])=>{return eQ($,H,J)});return eQ($,G,X)}});function J4(b,w){if(b===w)return{valid:!0,data:b};if(b instanceof Date&&w instanceof Date&&+b===+w)return{valid:!0,data:b};if(Lw(b)&&Lw(w)){let $=Object.keys(w),W=Object.keys(b).filter((G)=>$.indexOf(G)!==-1),Q={...b,...w};for(let G of W){let X=J4(b[G],w[G]);if(!X.valid)return{valid:!1,mergeErrorPath:[G,...X.mergeErrorPath]};Q[G]=X.data}return{valid:!0,data:Q}}if(Array.isArray(b)&&Array.isArray(w)){if(b.length!==w.length)return{valid:!1,mergeErrorPath:[]};let $=[];for(let W=0;W<b.length;W++){let Q=b[W],G=w[W],X=J4(Q,G);if(!X.valid)return{valid:!1,mergeErrorPath:[W,...X.mergeErrorPath]};$.push(X.data)}return{valid:!0,data:$}}return{valid:!1,mergeErrorPath:[]}}function eQ(b,w,$){if(w.issues.length)b.issues.push(...w.issues);if($.issues.length)b.issues.push(...$.issues);if(Uw(b))return b;let W=J4(w.value,$.value);if(!W.valid)throw Error(`Unmergable intersection. Error path: ${JSON.stringify(W.mergeErrorPath)}`);return b.value=W.data,b}var h9=U("$ZodRecord",(b,w)=>{e.init(b,w),b._zod.parse=($,W)=>{let Q=$.value;if(!Lw(Q))return $.issues.push({expected:"record",code:"invalid_type",input:Q,inst:b}),$;let G=[];if(w.keyType._zod.values){let X=w.keyType._zod.values;$.value={};for(let H of X)if(typeof H==="string"||typeof H==="number"||typeof H==="symbol"){let J=w.valueType._zod.run({value:Q[H],issues:[]},W);if(J instanceof Promise)G.push(J.then((D)=>{if(D.issues.length)$.issues.push(...ww(H,D.issues));$.value[H]=D.value}));else{if(J.issues.length)$.issues.push(...ww(H,J.issues));$.value[H]=J.value}}let Y;for(let H in Q)if(!X.has(H))Y=Y??[],Y.push(H);if(Y&&Y.length>0)$.issues.push({code:"unrecognized_keys",input:Q,inst:b,keys:Y})}else{$.value={};for(let X of Reflect.ownKeys(Q)){if(X==="__proto__")continue;let Y=w.keyType._zod.run({value:X,issues:[]},W);if(Y instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(Y.issues.length){$.issues.push({code:"invalid_key",origin:"record",issues:Y.issues.map((J)=>ub(J,W,Sb())),input:X,path:[X],inst:b}),$.value[Y.value]=Y.value;continue}let H=w.valueType._zod.run({value:Q[X],issues:[]},W);if(H instanceof Promise)G.push(H.then((J)=>{if(J.issues.length)$.issues.push(...ww(X,J.issues));$.value[Y.value]=J.value}));else{if(H.issues.length)$.issues.push(...ww(X,H.issues));$.value[Y.value]=H.value}}}if(G.length)return Promise.all(G).then(()=>$);return $}});var f9=U("$ZodEnum",(b,w)=>{e.init(b,w);let $=e$(w.entries),W=new Set($);b._zod.values=W,b._zod.pattern=new RegExp(`^(${$.filter((Q)=>b4.has(typeof Q)).map((Q)=>typeof Q==="string"?bw(Q):Q.toString()).join("|")})$`),b._zod.parse=(Q,G)=>{let X=Q.value;if(W.has(X))return Q;return Q.issues.push({code:"invalid_value",values:$,input:X,inst:b}),Q}}),c9=U("$ZodLiteral",(b,w)=>{if(e.init(b,w),w.values.length===0)throw Error("Cannot create literal schema with no valid values");b._zod.values=new Set(w.values),b._zod.pattern=new RegExp(`^(${w.values.map(($)=>typeof $==="string"?bw($):$?bw($.toString()):String($)).join("|")})$`),b._zod.parse=($,W)=>{let Q=$.value;if(b._zod.values.has(Q))return $;return $.issues.push({code:"invalid_value",values:w.values,input:Q,inst:b}),$}});var g9=U("$ZodTransform",(b,w)=>{e.init(b,w),b._zod.parse=($,W)=>{if(W.direction==="backward")throw new A1(b.constructor.name);let Q=w.transform($.value,$);if(W.async)return(Q instanceof Promise?Q:Promise.resolve(Q)).then((X)=>{return $.value=X,$});if(Q instanceof Promise)throw new ab;return $.value=Q,$}});function sQ(b,w){if(b.issues.length&&w===void 0)return{issues:[],value:void 0};return b}var m9=U("$ZodOptional",(b,w)=>{e.init(b,w),b._zod.optin="optional",b._zod.optout="optional",o(b._zod,"values",()=>{return w.innerType._zod.values?new Set([...w.innerType._zod.values,void 0]):void 0}),o(b._zod,"pattern",()=>{let $=w.innerType._zod.pattern;return $?new RegExp(`^(${L1($.source)})?$`):void 0}),b._zod.parse=($,W)=>{if(w.innerType._zod.optin==="optional"){let Q=w.innerType._zod.run($,W);if(Q instanceof Promise)return Q.then((G)=>sQ(G,$.value));return sQ(Q,$.value)}if($.value===void 0)return $;return w.innerType._zod.run($,W)}}),n9=U("$ZodNullable",(b,w)=>{e.init(b,w),o(b._zod,"optin",()=>w.innerType._zod.optin),o(b._zod,"optout",()=>w.innerType._zod.optout),o(b._zod,"pattern",()=>{let $=w.innerType._zod.pattern;return $?new RegExp(`^(${L1($.source)}|null)$`):void 0}),o(b._zod,"values",()=>{return w.innerType._zod.values?new Set([...w.innerType._zod.values,null]):void 0}),b._zod.parse=($,W)=>{if($.value===null)return $;return w.innerType._zod.run($,W)}}),l9=U("$ZodDefault",(b,w)=>{e.init(b,w),b._zod.optin="optional",o(b._zod,"values",()=>w.innerType._zod.values),b._zod.parse=($,W)=>{if(W.direction==="backward")return w.innerType._zod.run($,W);if($.value===void 0)return $.value=w.defaultValue,$;let Q=w.innerType._zod.run($,W);if(Q instanceof Promise)return Q.then((G)=>aQ(G,w));return aQ(Q,w)}});function aQ(b,w){if(b.value===void 0)b.value=w.defaultValue;return b}var i9=U("$ZodPrefault",(b,w)=>{e.init(b,w),b._zod.optin="optional",o(b._zod,"values",()=>w.innerType._zod.values),b._zod.parse=($,W)=>{if(W.direction==="backward")return w.innerType._zod.run($,W);if($.value===void 0)$.value=w.defaultValue;return w.innerType._zod.run($,W)}}),p9=U("$ZodNonOptional",(b,w)=>{e.init(b,w),o(b._zod,"values",()=>{let $=w.innerType._zod.values;return $?new Set([...$].filter((W)=>W!==void 0)):void 0}),b._zod.parse=($,W)=>{let Q=w.innerType._zod.run($,W);if(Q instanceof Promise)return Q.then((G)=>b9(G,b));return b9(Q,b)}});function b9(b,w){if(!b.issues.length&&b.value===void 0)b.issues.push({code:"invalid_type",expected:"nonoptional",input:b.value,inst:w});return b}var o9=U("$ZodCatch",(b,w)=>{e.init(b,w),o(b._zod,"optin",()=>w.innerType._zod.optin),o(b._zod,"optout",()=>w.innerType._zod.optout),o(b._zod,"values",()=>w.innerType._zod.values),b._zod.parse=($,W)=>{if(W.direction==="backward")return w.innerType._zod.run($,W);let Q=w.innerType._zod.run($,W);if(Q instanceof Promise)return Q.then((G)=>{if($.value=G.value,G.issues.length)$.value=w.catchValue({...$,error:{issues:G.issues.map((X)=>ub(X,W,Sb()))},input:$.value}),$.issues=[];return $});if($.value=Q.value,Q.issues.length)$.value=w.catchValue({...$,error:{issues:Q.issues.map((G)=>ub(G,W,Sb()))},input:$.value}),$.issues=[];return $}});var d9=U("$ZodPipe",(b,w)=>{e.init(b,w),o(b._zod,"values",()=>w.in._zod.values),o(b._zod,"optin",()=>w.in._zod.optin),o(b._zod,"optout",()=>w.out._zod.optout),o(b._zod,"propValues",()=>w.in._zod.propValues),b._zod.parse=($,W)=>{if(W.direction==="backward"){let G=w.out._zod.run($,W);if(G instanceof Promise)return G.then((X)=>Z0(X,w.in,W));return Z0(G,w.in,W)}let Q=w.in._zod.run($,W);if(Q instanceof Promise)return Q.then((G)=>Z0(G,w.out,W));return Z0(Q,w.out,W)}});function Z0(b,w,$){if(b.issues.length)return b.aborted=!0,b;return w._zod.run({value:b.value,issues:b.issues},$)}var t9=U("$ZodReadonly",(b,w)=>{e.init(b,w),o(b._zod,"propValues",()=>w.innerType._zod.propValues),o(b._zod,"values",()=>w.innerType._zod.values),o(b._zod,"optin",()=>w.innerType._zod.optin),o(b._zod,"optout",()=>w.innerType._zod.optout),b._zod.parse=($,W)=>{if(W.direction==="backward")return w.innerType._zod.run($,W);let Q=w.innerType._zod.run($,W);if(Q instanceof Promise)return Q.then(w9);return w9(Q)}});function w9(b){return b.value=Object.freeze(b.value),b}var r9=U("$ZodCustom",(b,w)=>{Jb.init(b,w),e.init(b,w),b._zod.parse=($,W)=>{return $},b._zod.check=($)=>{let W=$.value,Q=w.fn(W);if(Q instanceof Promise)return Q.then((G)=>$9(G,$,W,b));$9(Q,$,W,b);return}});function $9(b,w,$,W){if(!b){let Q={code:"custom",input:$,inst:W,path:[...W._zod.def.path??[]],continue:!W._zod.def.abort};if(W._zod.def.params)Q.params=W._zod.def.params;w.issues.push(cw(Q))}}var Z7=(b)=>{let w=typeof b;switch(w){case"number":return Number.isNaN(b)?"NaN":"number";case"object":{if(Array.isArray(b))return"array";if(b===null)return"null";if(Object.getPrototypeOf(b)!==Object.prototype&&b.constructor)return b.constructor.name}}return w},j7=()=>{let b={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 w(W){return b[W]??null}let $={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 ${Z7(W.input)}`;case"invalid_value":if(W.values.length===1)return`Invalid input: expected ${U0(W.values[0])}`;return`Invalid option: expected one of ${O0(W.values,"|")}`;case"too_big":{let Q=W.inclusive?"<=":"<",G=w(W.origin);if(G)return`Too big: expected ${W.origin??"value"} to have ${Q}${W.maximum.toString()} ${G.unit??"elements"}`;return`Too big: expected ${W.origin??"value"} to be ${Q}${W.maximum.toString()}`}case"too_small":{let Q=W.inclusive?">=":">",G=w(W.origin);if(G)return`Too small: expected ${W.origin} to have ${Q}${W.minimum.toString()} ${G.unit}`;return`Too small: expected ${W.origin} to be ${Q}${W.minimum.toString()}`}case"invalid_format":{let Q=W;if(Q.format==="starts_with")return`Invalid string: must start with "${Q.prefix}"`;if(Q.format==="ends_with")return`Invalid string: must end with "${Q.suffix}"`;if(Q.format==="includes")return`Invalid string: must include "${Q.includes}"`;if(Q.format==="regex")return`Invalid string: must match pattern ${Q.pattern}`;return`Invalid ${$[Q.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":""}: ${O0(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 A4(){return{localeError:j7()}}var fM=Symbol("ZodOutput"),cM=Symbol("ZodInput");class e9{constructor(){this._map=new WeakMap,this._idmap=new Map}add(b,...w){let $=w[0];if(this._map.set(b,$),$&&typeof $==="object"&&"id"in $){if(this._idmap.has($.id))throw Error(`ID ${$.id} already exists in the registry`);this._idmap.set($.id,b)}return this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(b){let w=this._map.get(b);if(w&&typeof w==="object"&&"id"in w)this._idmap.delete(w.id);return this._map.delete(b),this}get(b){let w=b._zod.parent;if(w){let $={...this.get(w)??{}};delete $.id;let W={...$,...this._map.get(b)};return Object.keys(W).length?W:void 0}return this._map.get(b)}has(b){return this._map.has(b)}}function I7(){return new e9}var M1=I7();function s9(b,w){return new b({type:"string",..._(w)})}function a9(b,w){return new b({type:"string",format:"email",check:"string_format",abort:!1,..._(w)})}function O4(b,w){return new b({type:"string",format:"guid",check:"string_format",abort:!1,..._(w)})}function b8(b,w){return new b({type:"string",format:"uuid",check:"string_format",abort:!1,..._(w)})}function w8(b,w){return new b({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",..._(w)})}function $8(b,w){return new b({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",..._(w)})}function W8(b,w){return new b({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",..._(w)})}function Q8(b,w){return new b({type:"string",format:"url",check:"string_format",abort:!1,..._(w)})}function G8(b,w){return new b({type:"string",format:"emoji",check:"string_format",abort:!1,..._(w)})}function X8(b,w){return new b({type:"string",format:"nanoid",check:"string_format",abort:!1,..._(w)})}function Y8(b,w){return new b({type:"string",format:"cuid",check:"string_format",abort:!1,..._(w)})}function H8(b,w){return new b({type:"string",format:"cuid2",check:"string_format",abort:!1,..._(w)})}function J8(b,w){return new b({type:"string",format:"ulid",check:"string_format",abort:!1,..._(w)})}function D8(b,w){return new b({type:"string",format:"xid",check:"string_format",abort:!1,..._(w)})}function z8(b,w){return new b({type:"string",format:"ksuid",check:"string_format",abort:!1,..._(w)})}function A8(b,w){return new b({type:"string",format:"ipv4",check:"string_format",abort:!1,..._(w)})}function O8(b,w){return new b({type:"string",format:"ipv6",check:"string_format",abort:!1,..._(w)})}function q8(b,w){return new b({type:"string",format:"cidrv4",check:"string_format",abort:!1,..._(w)})}function L8(b,w){return new b({type:"string",format:"cidrv6",check:"string_format",abort:!1,..._(w)})}function U8(b,w){return new b({type:"string",format:"base64",check:"string_format",abort:!1,..._(w)})}function B8(b,w){return new b({type:"string",format:"base64url",check:"string_format",abort:!1,..._(w)})}function F8(b,w){return new b({type:"string",format:"e164",check:"string_format",abort:!1,..._(w)})}function K8(b,w){return new b({type:"string",format:"jwt",check:"string_format",abort:!1,..._(w)})}function P8(b,w){return new b({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,..._(w)})}function M8(b,w){return new b({type:"string",format:"date",check:"string_format",..._(w)})}function Z8(b,w){return new b({type:"string",format:"time",check:"string_format",precision:null,..._(w)})}function j8(b,w){return new b({type:"string",format:"duration",check:"string_format",..._(w)})}function I8(b,w){return new b({type:"number",checks:[],..._(w)})}function V8(b,w){return new b({type:"number",check:"number_format",abort:!1,format:"safeint",..._(w)})}function N8(b,w){return new b({type:"boolean",..._(w)})}function E8(b,w){return new b({type:"null",..._(w)})}function T8(b){return new b({type:"unknown"})}function _8(b,w){return new b({type:"never",..._(w)})}function V0(b,w){return new X4({check:"less_than",..._(w),value:b,inclusive:!1})}function Z1(b,w){return new X4({check:"less_than",..._(w),value:b,inclusive:!0})}function N0(b,w){return new Y4({check:"greater_than",..._(w),value:b,inclusive:!1})}function j1(b,w){return new Y4({check:"greater_than",..._(w),value:b,inclusive:!0})}function E0(b,w){return new xQ({check:"multiple_of",..._(w),value:b})}function T0(b,w){return new yQ({check:"max_length",..._(w),maximum:b})}function gw(b,w){return new hQ({check:"min_length",..._(w),minimum:b})}function _0(b,w){return new fQ({check:"length_equals",..._(w),length:b})}function q4(b,w){return new cQ({check:"string_format",format:"regex",..._(w),pattern:b})}function L4(b){return new gQ({check:"string_format",format:"lowercase",..._(b)})}function U4(b){return new mQ({check:"string_format",format:"uppercase",..._(b)})}function B4(b,w){return new nQ({check:"string_format",format:"includes",..._(w),includes:b})}function F4(b,w){return new lQ({check:"string_format",format:"starts_with",..._(w),prefix:b})}function K4(b,w){return new iQ({check:"string_format",format:"ends_with",..._(w),suffix:b})}function Sw(b){return new pQ({check:"overwrite",tx:b})}function P4(b){return Sw((w)=>w.normalize(b))}function M4(){return Sw((b)=>b.trim())}function Z4(){return Sw((b)=>b.toLowerCase())}function j4(){return Sw((b)=>b.toUpperCase())}function S8(b,w,$){return new b({type:"array",element:w,..._($)})}function R8(b,w,$){let W=_($);return W.abort??(W.abort=!0),new b({type:"custom",check:"custom",fn:w,...W})}function k8(b,w,$){return new b({type:"custom",check:"custom",fn:w,..._($)})}function v8(b){let w=V7(($)=>{return $.addIssue=(W)=>{if(typeof W==="string")$.issues.push(cw(W,$.value,w._zod.def));else{let Q=W;if(Q.fatal)Q.continue=!1;Q.code??(Q.code="custom"),Q.input??(Q.input=$.value),Q.inst??(Q.inst=w),Q.continue??(Q.continue=!w._zod.def.abort),$.issues.push(cw(Q))}},b($.value,$)});return w}function V7(b,w){let $=new Jb({check:"custom",..._(w)});return $._zod.check=b,$}function mw(b){return!!b._zod}function Bw(b,w){if(mw(b))return F1(b,w);return b.safeParse(w)}function S0(b){if(!b)return;let w;if(mw(b))w=b._zod?.def?.shape;else w=b.shape;if(!w)return;if(typeof w==="function")try{return w()}catch{return}return w}function C8(b){if(mw(b)){let G=b._zod?.def;if(G){if(G.value!==void 0)return G.value;if(Array.isArray(G.values)&&G.values.length>0)return G.values[0]}}let $=b._def;if($){if($.value!==void 0)return $.value;if(Array.isArray($.values)&&$.values.length>0)return $.values[0]}let W=b.value;if(W!==void 0)return W;return}var V1={};RW(V1,{time:()=>N4,duration:()=>E4,datetime:()=>I4,date:()=>V4,ZodISOTime:()=>y8,ZodISODuration:()=>h8,ZodISODateTime:()=>x8,ZodISODate:()=>u8});var x8=U("ZodISODateTime",(b,w)=>{q9.init(b,w),bb.init(b,w)});function I4(b){return P8(x8,b)}var u8=U("ZodISODate",(b,w)=>{L9.init(b,w),bb.init(b,w)});function V4(b){return M8(u8,b)}var y8=U("ZodISOTime",(b,w)=>{U9.init(b,w),bb.init(b,w)});function N4(b){return Z8(y8,b)}var h8=U("ZodISODuration",(b,w)=>{B9.init(b,w),bb.init(b,w)});function E4(b){return j8(h8,b)}var f8=(b,w)=>{B0.init(b,w),b.name="ZodError",Object.defineProperties(b,{format:{value:($)=>rW(b,$)},flatten:{value:($)=>tW(b,$)},addIssue:{value:($)=>{b.issues.push($),b.message=JSON.stringify(b.issues,hw,2)}},addIssues:{value:($)=>{b.issues.push(...$),b.message=JSON.stringify(b.issues,hw,2)}},isEmpty:{get(){return b.issues.length===0}}})},VZ=U("ZodError",f8),Eb=U("ZodError",f8,{Parent:Error});var c8=F0(Eb),g8=K0(Eb),m8=B1(Eb),n8=K1(Eb),l8=eW(Eb),i8=sW(Eb),p8=aW(Eb),o8=bQ(Eb),d8=wQ(Eb),t8=$Q(Eb),r8=WQ(Eb),e8=QQ(Eb);var Qb=U("ZodType",(b,w)=>{return e.init(b,w),b.def=w,b.type=w.type,Object.defineProperty(b,"_def",{value:w}),b.check=(...$)=>{return b.clone(n.mergeDefs(w,{checks:[...w.checks??[],...$.map((W)=>typeof W==="function"?{_zod:{check:W,def:{check:"custom"},onattach:[]}}:W)]}))},b.clone=($,W)=>xb(b,$,W),b.brand=()=>b,b.register=($,W)=>{return $.add(b,W),b},b.parse=($,W)=>c8(b,$,W,{callee:b.parse}),b.safeParse=($,W)=>m8(b,$,W),b.parseAsync=async($,W)=>g8(b,$,W,{callee:b.parseAsync}),b.safeParseAsync=async($,W)=>n8(b,$,W),b.spa=b.safeParseAsync,b.encode=($,W)=>l8(b,$,W),b.decode=($,W)=>i8(b,$,W),b.encodeAsync=async($,W)=>p8(b,$,W),b.decodeAsync=async($,W)=>o8(b,$,W),b.safeEncode=($,W)=>d8(b,$,W),b.safeDecode=($,W)=>t8(b,$,W),b.safeEncodeAsync=async($,W)=>r8(b,$,W),b.safeDecodeAsync=async($,W)=>e8(b,$,W),b.refine=($,W)=>b.check(MA($,W)),b.superRefine=($)=>b.check(ZA($)),b.overwrite=($)=>b.check(Sw($)),b.optional=()=>Wb(b),b.nullable=()=>bG(b),b.nullish=()=>Wb(bG(b)),b.nonoptional=($)=>LA(b,$),b.array=()=>f(b),b.or=($)=>r([b,$]),b.and=($)=>k0(b,$),b.transform=($)=>_4(b,GG($)),b.default=($)=>AA(b,$),b.prefault=($)=>qA(b,$),b.catch=($)=>BA(b,$),b.pipe=($)=>_4(b,$),b.readonly=()=>PA(b),b.describe=($)=>{let W=b.clone();return M1.add(W,{description:$}),W},Object.defineProperty(b,"description",{get(){return M1.get(b)?.description},configurable:!0}),b.meta=(...$)=>{if($.length===0)return M1.get(b);let W=b.clone();return M1.add(W,$[0]),W},b.isOptional=()=>b.safeParse(void 0).success,b.isNullable=()=>b.safeParse(null).success,b}),wG=U("_ZodString",(b,w)=>{I0.init(b,w),Qb.init(b,w);let $=b._zod.bag;b.format=$.format??null,b.minLength=$.minimum??null,b.maxLength=$.maximum??null,b.regex=(...W)=>b.check(q4(...W)),b.includes=(...W)=>b.check(B4(...W)),b.startsWith=(...W)=>b.check(F4(...W)),b.endsWith=(...W)=>b.check(K4(...W)),b.min=(...W)=>b.check(gw(...W)),b.max=(...W)=>b.check(T0(...W)),b.length=(...W)=>b.check(_0(...W)),b.nonempty=(...W)=>b.check(gw(1,...W)),b.lowercase=(W)=>b.check(L4(W)),b.uppercase=(W)=>b.check(U4(W)),b.trim=()=>b.check(M4()),b.normalize=(...W)=>b.check(P4(...W)),b.toLowerCase=()=>b.check(Z4()),b.toUpperCase=()=>b.check(j4())}),C7=U("ZodString",(b,w)=>{I0.init(b,w),wG.init(b,w),b.email=($)=>b.check(a9(x7,$)),b.url=($)=>b.check(Q8(u7,$)),b.jwt=($)=>b.check(K8(e7,$)),b.emoji=($)=>b.check(G8(y7,$)),b.guid=($)=>b.check(O4(s8,$)),b.uuid=($)=>b.check(b8(R0,$)),b.uuidv4=($)=>b.check(w8(R0,$)),b.uuidv6=($)=>b.check($8(R0,$)),b.uuidv7=($)=>b.check(W8(R0,$)),b.nanoid=($)=>b.check(X8(h7,$)),b.guid=($)=>b.check(O4(s8,$)),b.cuid=($)=>b.check(Y8(f7,$)),b.cuid2=($)=>b.check(H8(c7,$)),b.ulid=($)=>b.check(J8(g7,$)),b.base64=($)=>b.check(U8(d7,$)),b.base64url=($)=>b.check(B8(t7,$)),b.xid=($)=>b.check(D8(m7,$)),b.ksuid=($)=>b.check(z8(n7,$)),b.ipv4=($)=>b.check(A8(l7,$)),b.ipv6=($)=>b.check(O8(i7,$)),b.cidrv4=($)=>b.check(q8(p7,$)),b.cidrv6=($)=>b.check(L8(o7,$)),b.e164=($)=>b.check(F8(r7,$)),b.datetime=($)=>b.check(I4($)),b.date=($)=>b.check(V4($)),b.time=($)=>b.check(N4($)),b.duration=($)=>b.check(E4($))});function L(b){return s9(C7,b)}var bb=U("ZodStringFormat",(b,w)=>{s.init(b,w),wG.init(b,w)}),x7=U("ZodEmail",(b,w)=>{G9.init(b,w),bb.init(b,w)});var s8=U("ZodGUID",(b,w)=>{W9.init(b,w),bb.init(b,w)});var R0=U("ZodUUID",(b,w)=>{Q9.init(b,w),bb.init(b,w)});var u7=U("ZodURL",(b,w)=>{X9.init(b,w),bb.init(b,w)});var y7=U("ZodEmoji",(b,w)=>{Y9.init(b,w),bb.init(b,w)});var h7=U("ZodNanoID",(b,w)=>{H9.init(b,w),bb.init(b,w)});var f7=U("ZodCUID",(b,w)=>{J9.init(b,w),bb.init(b,w)});var c7=U("ZodCUID2",(b,w)=>{D9.init(b,w),bb.init(b,w)});var g7=U("ZodULID",(b,w)=>{z9.init(b,w),bb.init(b,w)});var m7=U("ZodXID",(b,w)=>{A9.init(b,w),bb.init(b,w)});var n7=U("ZodKSUID",(b,w)=>{O9.init(b,w),bb.init(b,w)});var l7=U("ZodIPv4",(b,w)=>{F9.init(b,w),bb.init(b,w)});var i7=U("ZodIPv6",(b,w)=>{K9.init(b,w),bb.init(b,w)});var p7=U("ZodCIDRv4",(b,w)=>{P9.init(b,w),bb.init(b,w)});var o7=U("ZodCIDRv6",(b,w)=>{M9.init(b,w),bb.init(b,w)});var d7=U("ZodBase64",(b,w)=>{j9.init(b,w),bb.init(b,w)});var t7=U("ZodBase64URL",(b,w)=>{I9.init(b,w),bb.init(b,w)});var r7=U("ZodE164",(b,w)=>{V9.init(b,w),bb.init(b,w)});var e7=U("ZodJWT",(b,w)=>{N9.init(b,w),bb.init(b,w)});var $G=U("ZodNumber",(b,w)=>{D4.init(b,w),Qb.init(b,w),b.gt=(W,Q)=>b.check(N0(W,Q)),b.gte=(W,Q)=>b.check(j1(W,Q)),b.min=(W,Q)=>b.check(j1(W,Q)),b.lt=(W,Q)=>b.check(V0(W,Q)),b.lte=(W,Q)=>b.check(Z1(W,Q)),b.max=(W,Q)=>b.check(Z1(W,Q)),b.int=(W)=>b.check(a8(W)),b.safe=(W)=>b.check(a8(W)),b.positive=(W)=>b.check(N0(0,W)),b.nonnegative=(W)=>b.check(j1(0,W)),b.negative=(W)=>b.check(V0(0,W)),b.nonpositive=(W)=>b.check(Z1(0,W)),b.multipleOf=(W,Q)=>b.check(E0(W,Q)),b.step=(W,Q)=>b.check(E0(W,Q)),b.finite=()=>b;let $=b._zod.bag;b.minValue=Math.max($.minimum??Number.NEGATIVE_INFINITY,$.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,b.maxValue=Math.min($.maximum??Number.POSITIVE_INFINITY,$.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,b.isInt=($.format??"").includes("int")||Number.isSafeInteger($.multipleOf??0.5),b.isFinite=!0,b.format=$.format??null});function p(b){return I8($G,b)}var s7=U("ZodNumberFormat",(b,w)=>{E9.init(b,w),$G.init(b,w)});function a8(b){return V8(s7,b)}var a7=U("ZodBoolean",(b,w)=>{T9.init(b,w),Qb.init(b,w)});function Hb(b){return N8(a7,b)}var bA=U("ZodNull",(b,w)=>{_9.init(b,w),Qb.init(b,w)});function S4(b){return E8(bA,b)}var wA=U("ZodUnknown",(b,w)=>{S9.init(b,w),Qb.init(b,w)});function wb(){return T8(wA)}var $A=U("ZodNever",(b,w)=>{R9.init(b,w),Qb.init(b,w)});function WA(b){return _8($A,b)}var QA=U("ZodArray",(b,w)=>{k9.init(b,w),Qb.init(b,w),b.element=w.element,b.min=($,W)=>b.check(gw($,W)),b.nonempty=($)=>b.check(gw(1,$)),b.max=($,W)=>b.check(T0($,W)),b.length=($,W)=>b.check(_0($,W)),b.unwrap=()=>b.element});function f(b,w){return S8(QA,b,w)}var WG=U("ZodObject",(b,w)=>{x9.init(b,w),Qb.init(b,w),n.defineLazy(b,"shape",()=>{return w.shape}),b.keyof=()=>Pb(Object.keys(b._zod.def.shape)),b.catchall=($)=>b.clone({...b._zod.def,catchall:$}),b.passthrough=()=>b.clone({...b._zod.def,catchall:wb()}),b.loose=()=>b.clone({...b._zod.def,catchall:wb()}),b.strict=()=>b.clone({...b._zod.def,catchall:WA()}),b.strip=()=>b.clone({...b._zod.def,catchall:void 0}),b.extend=($)=>{return n.extend(b,$)},b.safeExtend=($)=>{return n.safeExtend(b,$)},b.merge=($)=>n.merge(b,$),b.pick=($)=>n.pick(b,$),b.omit=($)=>n.omit(b,$),b.partial=(...$)=>n.partial(XG,b,$[0]),b.required=(...$)=>n.required(YG,b,$[0])});function V(b,w){let $={type:"object",shape:b??{},...n.normalizeParams(w)};return new WG($)}function Ub(b,w){return new WG({type:"object",shape:b,catchall:wb(),...n.normalizeParams(w)})}var QG=U("ZodUnion",(b,w)=>{z4.init(b,w),Qb.init(b,w),b.options=w.options});function r(b,w){return new QG({type:"union",options:b,...n.normalizeParams(w)})}var GA=U("ZodDiscriminatedUnion",(b,w)=>{QG.init(b,w),u9.init(b,w)});function R4(b,w,$){return new GA({type:"union",options:w,discriminator:b,...n.normalizeParams($)})}var XA=U("ZodIntersection",(b,w)=>{y9.init(b,w),Qb.init(b,w)});function k0(b,w){return new XA({type:"intersection",left:b,right:w})}var YA=U("ZodRecord",(b,w)=>{h9.init(b,w),Qb.init(b,w),b.keyType=w.keyType,b.valueType=w.valueType});function $b(b,w,$){return new YA({type:"record",keyType:b,valueType:w,...n.normalizeParams($)})}var T4=U("ZodEnum",(b,w)=>{f9.init(b,w),Qb.init(b,w),b.enum=w.entries,b.options=Object.values(w.entries);let $=new Set(Object.keys(w.entries));b.extract=(W,Q)=>{let G={};for(let X of W)if($.has(X))G[X]=w.entries[X];else throw Error(`Key ${X} not found in enum`);return new T4({...w,checks:[],...n.normalizeParams(Q),entries:G})},b.exclude=(W,Q)=>{let G={...w.entries};for(let X of W)if($.has(X))delete G[X];else throw Error(`Key ${X} not found in enum`);return new T4({...w,checks:[],...n.normalizeParams(Q),entries:G})}});function Pb(b,w){let $=Array.isArray(b)?Object.fromEntries(b.map((W)=>[W,W])):b;return new T4({type:"enum",entries:$,...n.normalizeParams(w)})}var HA=U("ZodLiteral",(b,w)=>{c9.init(b,w),Qb.init(b,w),b.values=new Set(w.values),Object.defineProperty(b,"value",{get(){if(w.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return w.values[0]}})});function N(b,w){return new HA({type:"literal",values:Array.isArray(b)?b:[b],...n.normalizeParams(w)})}var JA=U("ZodTransform",(b,w)=>{g9.init(b,w),Qb.init(b,w),b._zod.parse=($,W)=>{if(W.direction==="backward")throw new A1(b.constructor.name);$.addIssue=(G)=>{if(typeof G==="string")$.issues.push(n.issue(G,$.value,w));else{let X=G;if(X.fatal)X.continue=!1;X.code??(X.code="custom"),X.input??(X.input=$.value),X.inst??(X.inst=b),$.issues.push(n.issue(X))}};let Q=w.transform($.value,$);if(Q instanceof Promise)return Q.then((G)=>{return $.value=G,$});return $.value=Q,$}});function GG(b){return new JA({type:"transform",transform:b})}var XG=U("ZodOptional",(b,w)=>{m9.init(b,w),Qb.init(b,w),b.unwrap=()=>b._zod.def.innerType});function Wb(b){return new XG({type:"optional",innerType:b})}var DA=U("ZodNullable",(b,w)=>{n9.init(b,w),Qb.init(b,w),b.unwrap=()=>b._zod.def.innerType});function bG(b){return new DA({type:"nullable",innerType:b})}var zA=U("ZodDefault",(b,w)=>{l9.init(b,w),Qb.init(b,w),b.unwrap=()=>b._zod.def.innerType,b.removeDefault=b.unwrap});function AA(b,w){return new zA({type:"default",innerType:b,get defaultValue(){return typeof w==="function"?w():n.shallowClone(w)}})}var OA=U("ZodPrefault",(b,w)=>{i9.init(b,w),Qb.init(b,w),b.unwrap=()=>b._zod.def.innerType});function qA(b,w){return new OA({type:"prefault",innerType:b,get defaultValue(){return typeof w==="function"?w():n.shallowClone(w)}})}var YG=U("ZodNonOptional",(b,w)=>{p9.init(b,w),Qb.init(b,w),b.unwrap=()=>b._zod.def.innerType});function LA(b,w){return new YG({type:"nonoptional",innerType:b,...n.normalizeParams(w)})}var UA=U("ZodCatch",(b,w)=>{o9.init(b,w),Qb.init(b,w),b.unwrap=()=>b._zod.def.innerType,b.removeCatch=b.unwrap});function BA(b,w){return new UA({type:"catch",innerType:b,catchValue:typeof w==="function"?w:()=>w})}var FA=U("ZodPipe",(b,w)=>{d9.init(b,w),Qb.init(b,w),b.in=w.in,b.out=w.out});function _4(b,w){return new FA({type:"pipe",in:b,out:w})}var KA=U("ZodReadonly",(b,w)=>{t9.init(b,w),Qb.init(b,w),b.unwrap=()=>b._zod.def.innerType});function PA(b){return new KA({type:"readonly",innerType:b})}var HG=U("ZodCustom",(b,w)=>{r9.init(b,w),Qb.init(b,w)});function JG(b,w){return R8(HG,b??(()=>!0),w)}function MA(b,w={}){return k8(HG,b,w)}function ZA(b){return v8(b)}function k4(b,w){return _4(GG(b),w)}Sb(A4());var v4="2025-11-25";var DG=[v4,"2025-06-18","2025-03-26","2024-11-05","2024-10-07"],Fw="io.modelcontextprotocol/related-task",C0="2.0",Db=JG((b)=>b!==null&&(typeof b==="object"||typeof b==="function")),zG=r([L(),p().int()]),AG=L(),Pj=Ub({ttl:r([p(),S4()]).optional(),pollInterval:p().optional()}),jA=V({ttl:p().optional()}),IA=V({taskId:L()}),C4=Ub({progressToken:zG.optional(),[Fw]:IA.optional()}),Tb=V({_meta:C4.optional()}),N1=Tb.extend({task:jA.optional()}),OG=(b)=>N1.safeParse(b).success,zb=V({method:L(),params:Tb.loose().optional()}),Rb=V({_meta:C4.optional()}),kb=V({method:L(),params:Rb.loose().optional()}),Ab=Ub({_meta:C4.optional()}),x0=r([L(),p().int()]),qG=V({jsonrpc:N(C0),id:x0,...zb.shape}).strict(),x4=(b)=>qG.safeParse(b).success,LG=V({jsonrpc:N(C0),...kb.shape}).strict(),UG=(b)=>LG.safeParse(b).success,u4=V({jsonrpc:N(C0),id:x0,result:Ab}).strict(),E1=(b)=>u4.safeParse(b).success;var c;(function(b){b[b.ConnectionClosed=-32000]="ConnectionClosed",b[b.RequestTimeout=-32001]="RequestTimeout",b[b.ParseError=-32700]="ParseError",b[b.InvalidRequest=-32600]="InvalidRequest",b[b.MethodNotFound=-32601]="MethodNotFound",b[b.InvalidParams=-32602]="InvalidParams",b[b.InternalError=-32603]="InternalError",b[b.UrlElicitationRequired=-32042]="UrlElicitationRequired"})(c||(c={}));var y4=V({jsonrpc:N(C0),id:x0.optional(),error:V({code:p().int(),message:L(),data:wb().optional()})}).strict();var BG=(b)=>y4.safeParse(b).success;var Mj=r([qG,LG,u4,y4]),Zj=r([u4,y4]),u0=Ab.strict(),VA=Rb.extend({requestId:x0.optional(),reason:L().optional()}),y0=kb.extend({method:N("notifications/cancelled"),params:VA}),NA=V({src:L(),mimeType:L().optional(),sizes:f(L()).optional(),theme:Pb(["light","dark"]).optional()}),T1=V({icons:f(NA).optional()}),nw=V({name:L(),title:L().optional()}),FG=nw.extend({...nw.shape,...T1.shape,version:L(),websiteUrl:L().optional(),description:L().optional()}),EA=k0(V({applyDefaults:Hb().optional()}),$b(L(),wb())),TA=k4((b)=>{if(b&&typeof b==="object"&&!Array.isArray(b)){if(Object.keys(b).length===0)return{form:{}}}return b},k0(V({form:EA.optional(),url:Db.optional()}),$b(L(),wb()).optional())),_A=Ub({list:Db.optional(),cancel:Db.optional(),requests:Ub({sampling:Ub({createMessage:Db.optional()}).optional(),elicitation:Ub({create:Db.optional()}).optional()}).optional()}),SA=Ub({list:Db.optional(),cancel:Db.optional(),requests:Ub({tools:Ub({call:Db.optional()}).optional()}).optional()}),RA=V({experimental:$b(L(),Db).optional(),sampling:V({context:Db.optional(),tools:Db.optional()}).optional(),elicitation:TA.optional(),roots:V({listChanged:Hb().optional()}).optional(),tasks:_A.optional()}),kA=Tb.extend({protocolVersion:L(),capabilities:RA,clientInfo:FG}),h4=zb.extend({method:N("initialize"),params:kA});var vA=V({experimental:$b(L(),Db).optional(),logging:Db.optional(),completions:Db.optional(),prompts:V({listChanged:Hb().optional()}).optional(),resources:V({subscribe:Hb().optional(),listChanged:Hb().optional()}).optional(),tools:V({listChanged:Hb().optional()}).optional(),tasks:SA.optional()}),CA=Ab.extend({protocolVersion:L(),capabilities:vA,serverInfo:FG,instructions:L().optional()}),f4=kb.extend({method:N("notifications/initialized"),params:Rb.optional()});var h0=zb.extend({method:N("ping"),params:Tb.optional()}),xA=V({progress:p(),total:Wb(p()),message:Wb(L())}),uA=V({...Rb.shape,...xA.shape,progressToken:zG}),f0=kb.extend({method:N("notifications/progress"),params:uA}),yA=Tb.extend({cursor:AG.optional()}),_1=zb.extend({params:yA.optional()}),S1=Ab.extend({nextCursor:AG.optional()}),hA=Pb(["working","input_required","completed","failed","cancelled"]),R1=V({taskId:L(),status:hA,ttl:r([p(),S4()]),createdAt:L(),lastUpdatedAt:L(),pollInterval:Wb(p()),statusMessage:Wb(L())}),lw=Ab.extend({task:R1}),fA=Rb.merge(R1),k1=kb.extend({method:N("notifications/tasks/status"),params:fA}),c0=zb.extend({method:N("tasks/get"),params:Tb.extend({taskId:L()})}),g0=Ab.merge(R1),m0=zb.extend({method:N("tasks/result"),params:Tb.extend({taskId:L()})}),jj=Ab.loose(),n0=_1.extend({method:N("tasks/list")}),l0=S1.extend({tasks:f(R1)}),i0=zb.extend({method:N("tasks/cancel"),params:Tb.extend({taskId:L()})}),KG=Ab.merge(R1),PG=V({uri:L(),mimeType:Wb(L()),_meta:$b(L(),wb()).optional()}),MG=PG.extend({text:L()}),c4=L().refine((b)=>{try{return atob(b),!0}catch{return!1}},{message:"Invalid Base64 string"}),ZG=PG.extend({blob:c4}),v1=Pb(["user","assistant"]),iw=V({audience:f(v1).optional(),priority:p().min(0).max(1).optional(),lastModified:V1.datetime({offset:!0}).optional()}),jG=V({...nw.shape,...T1.shape,uri:L(),description:Wb(L()),mimeType:Wb(L()),annotations:iw.optional(),_meta:Wb(Ub({}))}),cA=V({...nw.shape,...T1.shape,uriTemplate:L(),description:Wb(L()),mimeType:Wb(L()),annotations:iw.optional(),_meta:Wb(Ub({}))}),g4=_1.extend({method:N("resources/list")}),gA=S1.extend({resources:f(jG)}),mA=_1.extend({method:N("resources/templates/list")}),nA=S1.extend({resourceTemplates:f(cA)}),m4=Tb.extend({uri:L()}),lA=m4,n4=zb.extend({method:N("resources/read"),params:lA}),iA=Ab.extend({contents:f(r([MG,ZG]))}),pA=kb.extend({method:N("notifications/resources/list_changed"),params:Rb.optional()}),oA=m4,dA=zb.extend({method:N("resources/subscribe"),params:oA}),tA=m4,rA=zb.extend({method:N("resources/unsubscribe"),params:tA}),eA=Rb.extend({uri:L()}),sA=kb.extend({method:N("notifications/resources/updated"),params:eA}),aA=V({name:L(),description:Wb(L()),required:Wb(Hb())}),b5=V({...nw.shape,...T1.shape,description:Wb(L()),arguments:Wb(f(aA)),_meta:Wb(Ub({}))}),w5=_1.extend({method:N("prompts/list")}),$5=S1.extend({prompts:f(b5)}),W5=Tb.extend({name:L(),arguments:$b(L(),L()).optional()}),Q5=zb.extend({method:N("prompts/get"),params:W5}),l4=V({type:N("text"),text:L(),annotations:iw.optional(),_meta:$b(L(),wb()).optional()}),i4=V({type:N("image"),data:c4,mimeType:L(),annotations:iw.optional(),_meta:$b(L(),wb()).optional()}),p4=V({type:N("audio"),data:c4,mimeType:L(),annotations:iw.optional(),_meta:$b(L(),wb()).optional()}),G5=V({type:N("tool_use"),name:L(),id:L(),input:$b(L(),wb()),_meta:$b(L(),wb()).optional()}),X5=V({type:N("resource"),resource:r([MG,ZG]),annotations:iw.optional(),_meta:$b(L(),wb()).optional()}),Y5=jG.extend({type:N("resource_link")}),o4=r([l4,i4,p4,Y5,X5]),H5=V({role:v1,content:o4}),J5=Ab.extend({description:L().optional(),messages:f(H5)}),D5=kb.extend({method:N("notifications/prompts/list_changed"),params:Rb.optional()}),z5=V({title:L().optional(),readOnlyHint:Hb().optional(),destructiveHint:Hb().optional(),idempotentHint:Hb().optional(),openWorldHint:Hb().optional()}),A5=V({taskSupport:Pb(["required","optional","forbidden"]).optional()}),IG=V({...nw.shape,...T1.shape,description:L().optional(),inputSchema:V({type:N("object"),properties:$b(L(),Db).optional(),required:f(L()).optional()}).catchall(wb()),outputSchema:V({type:N("object"),properties:$b(L(),Db).optional(),required:f(L()).optional()}).catchall(wb()).optional(),annotations:z5.optional(),execution:A5.optional(),_meta:$b(L(),wb()).optional()}),d4=_1.extend({method:N("tools/list")}),O5=S1.extend({tools:f(IG)}),p0=Ab.extend({content:f(o4).default([]),structuredContent:$b(L(),wb()).optional(),isError:Hb().optional()}),Ij=p0.or(Ab.extend({toolResult:wb()})),q5=N1.extend({name:L(),arguments:$b(L(),wb()).optional()}),C1=zb.extend({method:N("tools/call"),params:q5}),L5=kb.extend({method:N("notifications/tools/list_changed"),params:Rb.optional()}),Vj=V({autoRefresh:Hb().default(!0),debounceMs:p().int().nonnegative().default(300)}),x1=Pb(["debug","info","notice","warning","error","critical","alert","emergency"]),U5=Tb.extend({level:x1}),t4=zb.extend({method:N("logging/setLevel"),params:U5}),B5=Rb.extend({level:x1,logger:L().optional(),data:wb()}),F5=kb.extend({method:N("notifications/message"),params:B5}),K5=V({name:L().optional()}),P5=V({hints:f(K5).optional(),costPriority:p().min(0).max(1).optional(),speedPriority:p().min(0).max(1).optional(),intelligencePriority:p().min(0).max(1).optional()}),M5=V({mode:Pb(["auto","required","none"]).optional()}),Z5=V({type:N("tool_result"),toolUseId:L().describe("The unique identifier for the corresponding tool call."),content:f(o4).default([]),structuredContent:V({}).loose().optional(),isError:Hb().optional(),_meta:$b(L(),wb()).optional()}),j5=R4("type",[l4,i4,p4]),v0=R4("type",[l4,i4,p4,G5,Z5]),I5=V({role:v1,content:r([v0,f(v0)]),_meta:$b(L(),wb()).optional()}),V5=N1.extend({messages:f(I5),modelPreferences:P5.optional(),systemPrompt:L().optional(),includeContext:Pb(["none","thisServer","allServers"]).optional(),temperature:p().optional(),maxTokens:p().int(),stopSequences:f(L()).optional(),metadata:Db.optional(),tools:f(IG).optional(),toolChoice:M5.optional()}),N5=zb.extend({method:N("sampling/createMessage"),params:V5}),r4=Ab.extend({model:L(),stopReason:Wb(Pb(["endTurn","stopSequence","maxTokens"]).or(L())),role:v1,content:j5}),e4=Ab.extend({model:L(),stopReason:Wb(Pb(["endTurn","stopSequence","maxTokens","toolUse"]).or(L())),role:v1,content:r([v0,f(v0)])}),E5=V({type:N("boolean"),title:L().optional(),description:L().optional(),default:Hb().optional()}),T5=V({type:N("string"),title:L().optional(),description:L().optional(),minLength:p().optional(),maxLength:p().optional(),format:Pb(["email","uri","date","date-time"]).optional(),default:L().optional()}),_5=V({type:Pb(["number","integer"]),title:L().optional(),description:L().optional(),minimum:p().optional(),maximum:p().optional(),default:p().optional()}),S5=V({type:N("string"),title:L().optional(),description:L().optional(),enum:f(L()),default:L().optional()}),R5=V({type:N("string"),title:L().optional(),description:L().optional(),oneOf:f(V({const:L(),title:L()})),default:L().optional()}),k5=V({type:N("string"),title:L().optional(),description:L().optional(),enum:f(L()),enumNames:f(L()).optional(),default:L().optional()}),v5=r([S5,R5]),C5=V({type:N("array"),title:L().optional(),description:L().optional(),minItems:p().optional(),maxItems:p().optional(),items:V({type:N("string"),enum:f(L())}),default:f(L()).optional()}),x5=V({type:N("array"),title:L().optional(),description:L().optional(),minItems:p().optional(),maxItems:p().optional(),items:V({anyOf:f(V({const:L(),title:L()}))}),default:f(L()).optional()}),u5=r([C5,x5]),y5=r([k5,v5,u5]),h5=r([y5,E5,T5,_5]),f5=N1.extend({mode:N("form").optional(),message:L(),requestedSchema:V({type:N("object"),properties:$b(L(),h5),required:f(L()).optional()})}),c5=N1.extend({mode:N("url"),message:L(),elicitationId:L(),url:L().url()}),g5=r([f5,c5]),m5=zb.extend({method:N("elicitation/create"),params:g5}),n5=Rb.extend({elicitationId:L()}),l5=kb.extend({method:N("notifications/elicitation/complete"),params:n5}),o0=Ab.extend({action:Pb(["accept","decline","cancel"]),content:k4((b)=>b===null?void 0:b,$b(L(),r([L(),p(),Hb(),f(L())])).optional())}),i5=V({type:N("ref/resource"),uri:L()});var p5=V({type:N("ref/prompt"),name:L()}),o5=Tb.extend({ref:r([p5,i5]),argument:V({name:L(),value:L()}),context:V({arguments:$b(L(),L()).optional()}).optional()}),d5=zb.extend({method:N("completion/complete"),params:o5});var t5=Ab.extend({completion:Ub({values:f(L()).max(100),total:Wb(p().int()),hasMore:Wb(Hb())})}),r5=V({uri:L().startsWith("file://"),name:L().optional(),_meta:$b(L(),wb()).optional()}),e5=zb.extend({method:N("roots/list"),params:Tb.optional()}),s4=Ab.extend({roots:f(r5)}),s5=kb.extend({method:N("notifications/roots/list_changed"),params:Rb.optional()}),Nj=r([h0,h4,d5,t4,Q5,w5,g4,mA,n4,dA,rA,C1,d4,c0,m0,n0,i0]),Ej=r([y0,f0,f4,s5,k1]),Tj=r([u0,r4,e4,o0,s4,g0,l0,lw]),_j=r([h0,N5,m5,e5,c0,m0,n0,i0]),Sj=r([y0,f0,F5,sA,pA,L5,D5,k1,l5]),Rj=r([u0,CA,t5,J5,$5,gA,nA,iA,p0,O5,g0,l0,lw]);class x extends Error{constructor(b,w,$){super(`MCP error ${b}: ${w}`);this.code=b,this.data=$,this.name="McpError"}static fromError(b,w,$){if(b===c.UrlElicitationRequired&&$){let W=$;if(W.elicitations)return new VG(W.elicitations,w)}return new x(b,w,$)}}class VG extends x{constructor(b,w=`URL elicitation${b.length>1?"s":""} required`){super(c.UrlElicitationRequired,w,{elicitations:b})}get elicitations(){return this.data?.elicitations??[]}}function Kw(b){return b==="completed"||b==="failed"||b==="cancelled"}var a5=Symbol("Let zodToJsonSchema decide on which parser to use");var DI=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function a4(b){let $=S0(b)?.method;if(!$)throw Error("Schema is missing a method literal");let W=C8($);if(typeof W!=="string")throw Error("Schema method literal must be a string");return W}function b6(b,w){let $=Bw(b,w);if(!$.success)throw $.error;return $.data}var GO=60000;class w6{constructor(b){if(this._options=b,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(y0,(w)=>{this._oncancel(w)}),this.setNotificationHandler(f0,(w)=>{this._onprogress(w)}),this.setRequestHandler(h0,(w)=>({})),this._taskStore=b?.taskStore,this._taskMessageQueue=b?.taskMessageQueue,this._taskStore)this.setRequestHandler(c0,async(w,$)=>{let W=await this._taskStore.getTask(w.params.taskId,$.sessionId);if(!W)throw new x(c.InvalidParams,"Failed to retrieve task: Task not found");return{...W}}),this.setRequestHandler(m0,async(w,$)=>{let W=async()=>{let Q=w.params.taskId;if(this._taskMessageQueue){let X;while(X=await this._taskMessageQueue.dequeue(Q,$.sessionId)){if(X.type==="response"||X.type==="error"){let Y=X.message,H=Y.id,J=this._requestResolvers.get(H);if(J)if(this._requestResolvers.delete(H),X.type==="response")J(Y);else{let D=Y,z=new x(D.error.code,D.error.message,D.error.data);J(z)}else{let D=X.type==="response"?"Response":"Error";this._onerror(Error(`${D} handler missing for request ${H}`))}continue}await this._transport?.send(X.message,{relatedRequestId:$.requestId})}}let G=await this._taskStore.getTask(Q,$.sessionId);if(!G)throw new x(c.InvalidParams,`Task not found: ${Q}`);if(!Kw(G.status))return await this._waitForTaskUpdate(Q,$.signal),await W();if(Kw(G.status)){let X=await this._taskStore.getTaskResult(Q,$.sessionId);return this._clearTaskQueue(Q),{...X,_meta:{...X._meta,[Fw]:{taskId:Q}}}}return await W()};return await W()}),this.setRequestHandler(n0,async(w,$)=>{try{let{tasks:W,nextCursor:Q}=await this._taskStore.listTasks(w.params?.cursor,$.sessionId);return{tasks:W,nextCursor:Q,_meta:{}}}catch(W){throw new x(c.InvalidParams,`Failed to list tasks: ${W instanceof Error?W.message:String(W)}`)}}),this.setRequestHandler(i0,async(w,$)=>{try{let W=await this._taskStore.getTask(w.params.taskId,$.sessionId);if(!W)throw new x(c.InvalidParams,`Task not found: ${w.params.taskId}`);if(Kw(W.status))throw new x(c.InvalidParams,`Cannot cancel task in terminal status: ${W.status}`);await this._taskStore.updateTaskStatus(w.params.taskId,"cancelled","Client cancelled task execution.",$.sessionId),this._clearTaskQueue(w.params.taskId);let Q=await this._taskStore.getTask(w.params.taskId,$.sessionId);if(!Q)throw new x(c.InvalidParams,`Task not found after cancellation: ${w.params.taskId}`);return{_meta:{},...Q}}catch(W){if(W instanceof x)throw W;throw new x(c.InvalidRequest,`Failed to cancel task: ${W instanceof Error?W.message:String(W)}`)}})}async _oncancel(b){if(!b.params.requestId)return;this._requestHandlerAbortControllers.get(b.params.requestId)?.abort(b.params.reason)}_setupTimeout(b,w,$,W,Q=!1){this._timeoutInfo.set(b,{timeoutId:setTimeout(W,w),startTime:Date.now(),timeout:w,maxTotalTimeout:$,resetTimeoutOnProgress:Q,onTimeout:W})}_resetTimeout(b){let w=this._timeoutInfo.get(b);if(!w)return!1;let $=Date.now()-w.startTime;if(w.maxTotalTimeout&&$>=w.maxTotalTimeout)throw this._timeoutInfo.delete(b),x.fromError(c.RequestTimeout,"Maximum total timeout exceeded",{maxTotalTimeout:w.maxTotalTimeout,totalElapsed:$});return clearTimeout(w.timeoutId),w.timeoutId=setTimeout(w.onTimeout,w.timeout),!0}_cleanupTimeout(b){let w=this._timeoutInfo.get(b);if(w)clearTimeout(w.timeoutId),this._timeoutInfo.delete(b)}async connect(b){this._transport=b;let w=this.transport?.onclose;this._transport.onclose=()=>{w?.(),this._onclose()};let $=this.transport?.onerror;this._transport.onerror=(Q)=>{$?.(Q),this._onerror(Q)};let W=this._transport?.onmessage;this._transport.onmessage=(Q,G)=>{if(W?.(Q,G),E1(Q)||BG(Q))this._onresponse(Q);else if(x4(Q))this._onrequest(Q,G);else if(UG(Q))this._onnotification(Q);else this._onerror(Error(`Unknown message type: ${JSON.stringify(Q)}`))},await this._transport.start()}_onclose(){let b=this._responseHandlers;this._responseHandlers=new Map,this._progressHandlers.clear(),this._taskProgressTokens.clear(),this._pendingDebouncedNotifications.clear();let w=x.fromError(c.ConnectionClosed,"Connection closed");this._transport=void 0,this.onclose?.();for(let $ of b.values())$(w)}_onerror(b){this.onerror?.(b)}_onnotification(b){let w=this._notificationHandlers.get(b.method)??this.fallbackNotificationHandler;if(w===void 0)return;Promise.resolve().then(()=>w(b)).catch(($)=>this._onerror(Error(`Uncaught error in notification handler: ${$}`)))}_onrequest(b,w){let $=this._requestHandlers.get(b.method)??this.fallbackRequestHandler,W=this._transport,Q=b.params?._meta?.[Fw]?.taskId;if($===void 0){let J={jsonrpc:"2.0",id:b.id,error:{code:c.MethodNotFound,message:"Method not found"}};if(Q&&this._taskMessageQueue)this._enqueueTaskMessage(Q,{type:"error",message:J,timestamp:Date.now()},W?.sessionId).catch((D)=>this._onerror(Error(`Failed to enqueue error response: ${D}`)));else W?.send(J).catch((D)=>this._onerror(Error(`Failed to send an error response: ${D}`)));return}let G=new AbortController;this._requestHandlerAbortControllers.set(b.id,G);let X=OG(b.params)?b.params.task:void 0,Y=this._taskStore?this.requestTaskStore(b,W?.sessionId):void 0,H={signal:G.signal,sessionId:W?.sessionId,_meta:b.params?._meta,sendNotification:async(J)=>{let D={relatedRequestId:b.id};if(Q)D.relatedTask={taskId:Q};await this.notification(J,D)},sendRequest:async(J,D,z)=>{let O={...z,relatedRequestId:b.id};if(Q&&!O.relatedTask)O.relatedTask={taskId:Q};let q=O.relatedTask?.taskId??Q;if(q&&Y)await Y.updateTaskStatus(q,"input_required");return await this.request(J,D,O)},authInfo:w?.authInfo,requestId:b.id,requestInfo:w?.requestInfo,taskId:Q,taskStore:Y,taskRequestedTtl:X?.ttl,closeSSEStream:w?.closeSSEStream,closeStandaloneSSEStream:w?.closeStandaloneSSEStream};Promise.resolve().then(()=>{if(X)this.assertTaskHandlerCapability(b.method)}).then(()=>$(b,H)).then(async(J)=>{if(G.signal.aborted)return;let D={result:J,jsonrpc:"2.0",id:b.id};if(Q&&this._taskMessageQueue)await this._enqueueTaskMessage(Q,{type:"response",message:D,timestamp:Date.now()},W?.sessionId);else await W?.send(D)},async(J)=>{if(G.signal.aborted)return;let D={jsonrpc:"2.0",id:b.id,error:{code:Number.isSafeInteger(J.code)?J.code:c.InternalError,message:J.message??"Internal error",...J.data!==void 0&&{data:J.data}}};if(Q&&this._taskMessageQueue)await this._enqueueTaskMessage(Q,{type:"error",message:D,timestamp:Date.now()},W?.sessionId);else await W?.send(D)}).catch((J)=>this._onerror(Error(`Failed to send response: ${J}`))).finally(()=>{this._requestHandlerAbortControllers.delete(b.id)})}_onprogress(b){let{progressToken:w,...$}=b.params,W=Number(w),Q=this._progressHandlers.get(W);if(!Q){this._onerror(Error(`Received a progress notification for an unknown token: ${JSON.stringify(b)}`));return}let G=this._responseHandlers.get(W),X=this._timeoutInfo.get(W);if(X&&G&&X.resetTimeoutOnProgress)try{this._resetTimeout(W)}catch(Y){this._responseHandlers.delete(W),this._progressHandlers.delete(W),this._cleanupTimeout(W),G(Y);return}Q($)}_onresponse(b){let w=Number(b.id),$=this._requestResolvers.get(w);if($){if(this._requestResolvers.delete(w),E1(b))$(b);else{let G=new x(b.error.code,b.error.message,b.error.data);$(G)}return}let W=this._responseHandlers.get(w);if(W===void 0){this._onerror(Error(`Received a response for an unknown message ID: ${JSON.stringify(b)}`));return}this._responseHandlers.delete(w),this._cleanupTimeout(w);let Q=!1;if(E1(b)&&b.result&&typeof b.result==="object"){let G=b.result;if(G.task&&typeof G.task==="object"){let X=G.task;if(typeof X.taskId==="string")Q=!0,this._taskProgressTokens.set(X.taskId,w)}}if(!Q)this._progressHandlers.delete(w);if(E1(b))W(b);else{let G=x.fromError(b.error.code,b.error.message,b.error.data);W(G)}}get transport(){return this._transport}async close(){await this._transport?.close()}async*requestStream(b,w,$){let{task:W}=$??{};if(!W){try{yield{type:"result",result:await this.request(b,w,$)}}catch(G){yield{type:"error",error:G instanceof x?G:new x(c.InternalError,String(G))}}return}let Q;try{let G=await this.request(b,lw,$);if(G.task)Q=G.task.taskId,yield{type:"taskCreated",task:G.task};else throw new x(c.InternalError,"Task creation did not return a task");while(!0){let X=await this.getTask({taskId:Q},$);if(yield{type:"taskStatus",task:X},Kw(X.status)){if(X.status==="completed")yield{type:"result",result:await this.getTaskResult({taskId:Q},w,$)};else if(X.status==="failed")yield{type:"error",error:new x(c.InternalError,`Task ${Q} failed`)};else if(X.status==="cancelled")yield{type:"error",error:new x(c.InternalError,`Task ${Q} was cancelled`)};return}if(X.status==="input_required"){yield{type:"result",result:await this.getTaskResult({taskId:Q},w,$)};return}let Y=X.pollInterval??this._options?.defaultTaskPollInterval??1000;await new Promise((H)=>setTimeout(H,Y)),$?.signal?.throwIfAborted()}}catch(G){yield{type:"error",error:G instanceof x?G:new x(c.InternalError,String(G))}}}request(b,w,$){let{relatedRequestId:W,resumptionToken:Q,onresumptiontoken:G,task:X,relatedTask:Y}=$??{};return new Promise((H,J)=>{let D=(M)=>{J(M)};if(!this._transport){D(Error("Not connected"));return}if(this._options?.enforceStrictCapabilities===!0)try{if(this.assertCapabilityForMethod(b.method),X)this.assertTaskCapability(b.method)}catch(M){D(M);return}$?.signal?.throwIfAborted();let z=this._requestMessageId++,O={...b,jsonrpc:"2.0",id:z};if($?.onprogress)this._progressHandlers.set(z,$.onprogress),O.params={...b.params,_meta:{...b.params?._meta||{},progressToken:z}};if(X)O.params={...O.params,task:X};if(Y)O.params={...O.params,_meta:{...O.params?._meta||{},[Fw]:Y}};let q=(M)=>{this._responseHandlers.delete(z),this._progressHandlers.delete(z),this._cleanupTimeout(z),this._transport?.send({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:z,reason:String(M)}},{relatedRequestId:W,resumptionToken:Q,onresumptiontoken:G}).catch((S)=>this._onerror(Error(`Failed to send cancellation: ${S}`)));let k=M instanceof x?M:new x(c.RequestTimeout,String(M));J(k)};this._responseHandlers.set(z,(M)=>{if($?.signal?.aborted)return;if(M instanceof Error)return J(M);try{let k=Bw(w,M.result);if(!k.success)J(k.error);else H(k.data)}catch(k){J(k)}}),$?.signal?.addEventListener("abort",()=>{q($?.signal?.reason)});let B=$?.timeout??GO,K=()=>q(x.fromError(c.RequestTimeout,"Request timed out",{timeout:B}));this._setupTimeout(z,B,$?.maxTotalTimeout,K,$?.resetTimeoutOnProgress??!1);let Z=Y?.taskId;if(Z){let M=(k)=>{let S=this._responseHandlers.get(z);if(S)S(k);else this._onerror(Error(`Response handler missing for side-channeled request ${z}`))};this._requestResolvers.set(z,M),this._enqueueTaskMessage(Z,{type:"request",message:O,timestamp:Date.now()}).catch((k)=>{this._cleanupTimeout(z),J(k)})}else this._transport.send(O,{relatedRequestId:W,resumptionToken:Q,onresumptiontoken:G}).catch((M)=>{this._cleanupTimeout(z),J(M)})})}async getTask(b,w){return this.request({method:"tasks/get",params:b},g0,w)}async getTaskResult(b,w,$){return this.request({method:"tasks/result",params:b},w,$)}async listTasks(b,w){return this.request({method:"tasks/list",params:b},l0,w)}async cancelTask(b,w){return this.request({method:"tasks/cancel",params:b},KG,w)}async notification(b,w){if(!this._transport)throw Error("Not connected");this.assertNotificationCapability(b.method);let $=w?.relatedTask?.taskId;if($){let X={...b,jsonrpc:"2.0",params:{...b.params,_meta:{...b.params?._meta||{},[Fw]:w.relatedTask}}};await this._enqueueTaskMessage($,{type:"notification",message:X,timestamp:Date.now()});return}if((this._options?.debouncedNotificationMethods??[]).includes(b.method)&&!b.params&&!w?.relatedRequestId&&!w?.relatedTask){if(this._pendingDebouncedNotifications.has(b.method))return;this._pendingDebouncedNotifications.add(b.method),Promise.resolve().then(()=>{if(this._pendingDebouncedNotifications.delete(b.method),!this._transport)return;let X={...b,jsonrpc:"2.0"};if(w?.relatedTask)X={...X,params:{...X.params,_meta:{...X.params?._meta||{},[Fw]:w.relatedTask}}};this._transport?.send(X,w).catch((Y)=>this._onerror(Y))});return}let G={...b,jsonrpc:"2.0"};if(w?.relatedTask)G={...G,params:{...G.params,_meta:{...G.params?._meta||{},[Fw]:w.relatedTask}}};await this._transport.send(G,w)}setRequestHandler(b,w){let $=a4(b);this.assertRequestHandlerCapability($),this._requestHandlers.set($,(W,Q)=>{let G=b6(b,W);return Promise.resolve(w(G,Q))})}removeRequestHandler(b){this._requestHandlers.delete(b)}assertCanSetRequestHandler(b){if(this._requestHandlers.has(b))throw Error(`A request handler for ${b} already exists, which would be overridden`)}setNotificationHandler(b,w){let $=a4(b);this._notificationHandlers.set($,(W)=>{let Q=b6(b,W);return Promise.resolve(w(Q))})}removeNotificationHandler(b){this._notificationHandlers.delete(b)}_cleanupTaskProgressHandler(b){let w=this._taskProgressTokens.get(b);if(w!==void 0)this._progressHandlers.delete(w),this._taskProgressTokens.delete(b)}async _enqueueTaskMessage(b,w,$){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(b,w,$,W)}async _clearTaskQueue(b,w){if(this._taskMessageQueue){let $=await this._taskMessageQueue.dequeueAll(b,w);for(let W of $)if(W.type==="request"&&x4(W.message)){let Q=W.message.id,G=this._requestResolvers.get(Q);if(G)G(new x(c.InternalError,"Task cancelled or completed")),this._requestResolvers.delete(Q);else this._onerror(Error(`Resolver missing for request ${Q} during task ${b} cleanup`))}}}async _waitForTaskUpdate(b,w){let $=this._options?.defaultTaskPollInterval??1000;try{let W=await this._taskStore?.getTask(b);if(W?.pollInterval)$=W.pollInterval}catch{}return new Promise((W,Q)=>{if(w.aborted){Q(new x(c.InvalidRequest,"Request cancelled"));return}let G=setTimeout(W,$);w.addEventListener("abort",()=>{clearTimeout(G),Q(new x(c.InvalidRequest,"Request cancelled"))},{once:!0})})}requestTaskStore(b,w){let $=this._taskStore;if(!$)throw Error("No task store configured");return{createTask:async(W)=>{if(!b)throw Error("No request provided");return await $.createTask(W,b.id,{method:b.method,params:b.params},w)},getTask:async(W)=>{let Q=await $.getTask(W,w);if(!Q)throw new x(c.InvalidParams,"Failed to retrieve task: Task not found");return Q},storeTaskResult:async(W,Q,G)=>{await $.storeTaskResult(W,Q,G,w);let X=await $.getTask(W,w);if(X){let Y=k1.parse({method:"notifications/tasks/status",params:X});if(await this.notification(Y),Kw(X.status))this._cleanupTaskProgressHandler(W)}},getTaskResult:(W)=>{return $.getTaskResult(W,w)},updateTaskStatus:async(W,Q,G)=>{let X=await $.getTask(W,w);if(!X)throw new x(c.InvalidParams,`Task "${W}" not found - it may have been cleaned up`);if(Kw(X.status))throw new x(c.InvalidParams,`Cannot update task "${W}" from terminal status "${X.status}" to "${Q}". Terminal states (completed, failed, cancelled) cannot transition to other states.`);await $.updateTaskStatus(W,Q,G,w);let Y=await $.getTask(W,w);if(Y){let H=k1.parse({method:"notifications/tasks/status",params:Y});if(await this.notification(H),Kw(Y.status))this._cleanupTaskProgressHandler(W)}},listTasks:(W)=>{return $.listTasks(W,w)}}}}function NG(b){return b!==null&&typeof b==="object"&&!Array.isArray(b)}function EG(b,w){let $={...b};for(let W in w){let Q=W,G=w[Q];if(G===void 0)continue;let X=$[Q];if(NG(X)&&NG(G))$[Q]={...X,...G};else $[Q]=G}return $}var QD=SW(t6(),1),GD=SW(WD(),1);function qP(){let b=new QD.default({strict:!1,validateFormats:!0,validateSchema:!1,allErrors:!0});return GD.default(b),b}class GW{constructor(b){this._ajv=b??qP()}getValidator(b){let w="$id"in b&&typeof b.$id==="string"?this._ajv.getSchema(b.$id)??this._ajv.compile(b):this._ajv.compile(b);return($)=>{if(w($))return{valid:!0,data:$,errorMessage:void 0};else return{valid:!1,data:void 0,errorMessage:this._ajv.errorsText(w.errors)}}}}class XW{constructor(b){this._server=b}requestStream(b,w,$){return this._server.requestStream(b,w,$)}async getTask(b,w){return this._server.getTask({taskId:b},w)}async getTaskResult(b,w,$){return this._server.getTaskResult({taskId:b},w,$)}async listTasks(b,w){return this._server.listTasks(b?{cursor:b}:void 0,w)}async cancelTask(b,w){return this._server.cancelTask({taskId:b},w)}}function XD(b,w,$){if(!b)throw Error(`${$} does not support task creation (required for ${w})`);switch(w){case"tools/call":if(!b.tools?.call)throw Error(`${$} does not support task creation for tools/call (required for ${w})`);break;default:break}}function YD(b,w,$){if(!b)throw Error(`${$} does not support task creation (required for ${w})`);switch(w){case"sampling/createMessage":if(!b.sampling?.createMessage)throw Error(`${$} does not support task creation for sampling/createMessage (required for ${w})`);break;case"elicitation/create":if(!b.elicitation?.create)throw Error(`${$} does not support task creation for elicitation/create (required for ${w})`);break;default:break}}class YW extends w6{constructor(b,w){super(w);if(this._serverInfo=b,this._loggingLevels=new Map,this.LOG_LEVEL_SEVERITY=new Map(x1.options.map(($,W)=>[$,W])),this.isMessageIgnored=($,W)=>{let Q=this._loggingLevels.get(W);return Q?this.LOG_LEVEL_SEVERITY.get($)<this.LOG_LEVEL_SEVERITY.get(Q):!1},this._capabilities=w?.capabilities??{},this._instructions=w?.instructions,this._jsonSchemaValidator=w?.jsonSchemaValidator??new GW,this.setRequestHandler(h4,($)=>this._oninitialize($)),this.setNotificationHandler(f4,()=>this.oninitialized?.()),this._capabilities.logging)this.setRequestHandler(t4,async($,W)=>{let Q=W.sessionId||W.requestInfo?.headers["mcp-session-id"]||void 0,{level:G}=$.params,X=x1.safeParse(G);if(X.success)this._loggingLevels.set(Q,X.data);return{}})}get experimental(){if(!this._experimental)this._experimental={tasks:new XW(this)};return this._experimental}registerCapabilities(b){if(this.transport)throw Error("Cannot register capabilities after connecting to transport");this._capabilities=EG(this._capabilities,b)}setRequestHandler(b,w){let W=S0(b)?.method;if(!W)throw Error("Schema is missing a method literal");let Q;if(mw(W)){let X=W;Q=X._zod?.def?.value??X.value}else{let X=W;Q=X._def?.value??X.value}if(typeof Q!=="string")throw Error("Schema method literal must be a string");if(Q==="tools/call"){let X=async(Y,H)=>{let J=Bw(C1,Y);if(!J.success){let q=J.error instanceof Error?J.error.message:String(J.error);throw new x(c.InvalidParams,`Invalid tools/call request: ${q}`)}let{params:D}=J.data,z=await Promise.resolve(w(Y,H));if(D.task){let q=Bw(lw,z);if(!q.success){let B=q.error instanceof Error?q.error.message:String(q.error);throw new x(c.InvalidParams,`Invalid task creation result: ${B}`)}return q.data}let O=Bw(p0,z);if(!O.success){let q=O.error instanceof Error?O.error.message:String(O.error);throw new x(c.InvalidParams,`Invalid tools/call result: ${q}`)}return O.data};return super.setRequestHandler(b,X)}return super.setRequestHandler(b,w)}assertCapabilityForMethod(b){switch(b){case"sampling/createMessage":if(!this._clientCapabilities?.sampling)throw Error(`Client does not support sampling (required for ${b})`);break;case"elicitation/create":if(!this._clientCapabilities?.elicitation)throw Error(`Client does not support elicitation (required for ${b})`);break;case"roots/list":if(!this._clientCapabilities?.roots)throw Error(`Client does not support listing roots (required for ${b})`);break;case"ping":break}}assertNotificationCapability(b){switch(b){case"notifications/message":if(!this._capabilities.logging)throw Error(`Server does not support logging (required for ${b})`);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 ${b})`);break;case"notifications/tools/list_changed":if(!this._capabilities.tools)throw Error(`Server does not support notifying of tool list changes (required for ${b})`);break;case"notifications/prompts/list_changed":if(!this._capabilities.prompts)throw Error(`Server does not support notifying of prompt list changes (required for ${b})`);break;case"notifications/elicitation/complete":if(!this._clientCapabilities?.elicitation?.url)throw Error(`Client does not support URL elicitation (required for ${b})`);break;case"notifications/cancelled":break;case"notifications/progress":break}}assertRequestHandlerCapability(b){if(!this._capabilities)return;switch(b){case"completion/complete":if(!this._capabilities.completions)throw Error(`Server does not support completions (required for ${b})`);break;case"logging/setLevel":if(!this._capabilities.logging)throw Error(`Server does not support logging (required for ${b})`);break;case"prompts/get":case"prompts/list":if(!this._capabilities.prompts)throw Error(`Server does not support prompts (required for ${b})`);break;case"resources/list":case"resources/templates/list":case"resources/read":if(!this._capabilities.resources)throw Error(`Server does not support resources (required for ${b})`);break;case"tools/call":case"tools/list":if(!this._capabilities.tools)throw Error(`Server does not support tools (required for ${b})`);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 ${b})`);break;case"ping":case"initialize":break}}assertTaskCapability(b){YD(this._clientCapabilities?.tasks?.requests,b,"Client")}assertTaskHandlerCapability(b){if(!this._capabilities)return;XD(this._capabilities.tasks?.requests,b,"Server")}async _oninitialize(b){let w=b.params.protocolVersion;return this._clientCapabilities=b.params.capabilities,this._clientVersion=b.params.clientInfo,{protocolVersion:DG.includes(w)?w:v4,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"},u0)}async createMessage(b,w){if(b.tools||b.toolChoice){if(!this._clientCapabilities?.sampling?.tools)throw Error("Client does not support sampling tools capability.")}if(b.messages.length>0){let $=b.messages[b.messages.length-1],W=Array.isArray($.content)?$.content:[$.content],Q=W.some((H)=>H.type==="tool_result"),G=b.messages.length>1?b.messages[b.messages.length-2]:void 0,X=G?Array.isArray(G.content)?G.content:[G.content]:[],Y=X.some((H)=>H.type==="tool_use");if(Q){if(W.some((H)=>H.type!=="tool_result"))throw Error("The last message must contain only tool_result content if any is present");if(!Y)throw Error("tool_result blocks are not matching any tool_use from the previous message")}if(Y){let H=new Set(X.filter((D)=>D.type==="tool_use").map((D)=>D.id)),J=new Set(W.filter((D)=>D.type==="tool_result").map((D)=>D.toolUseId));if(H.size!==J.size||![...H].every((D)=>J.has(D)))throw Error("ids of tool_result blocks and tool_use blocks from previous message do not match")}}if(b.tools)return this.request({method:"sampling/createMessage",params:b},e4,w);return this.request({method:"sampling/createMessage",params:b},r4,w)}async elicitInput(b,w){switch(b.mode??"form"){case"url":{if(!this._clientCapabilities?.elicitation?.url)throw Error("Client does not support url elicitation.");let W=b;return this.request({method:"elicitation/create",params:W},o0,w)}case"form":{if(!this._clientCapabilities?.elicitation?.form)throw Error("Client does not support form elicitation.");let W=b.mode==="form"?b:{...b,mode:"form"},Q=await this.request({method:"elicitation/create",params:W},o0,w);if(Q.action==="accept"&&Q.content&&W.requestedSchema)try{let X=this._jsonSchemaValidator.getValidator(W.requestedSchema)(Q.content);if(!X.valid)throw new x(c.InvalidParams,`Elicitation response content does not match requested schema: ${X.errorMessage}`)}catch(G){if(G instanceof x)throw G;throw new x(c.InternalError,`Error validating elicitation response: ${G instanceof Error?G.message:String(G)}`)}return Q}}}createElicitationCompletionNotifier(b,w){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:b}},w)}async listRoots(b,w){return this.request({method:"roots/list",params:b},s4,w)}async sendLoggingMessage(b,w){if(this._capabilities.logging){if(!this.isMessageIgnored(b.level,w))return this.notification({method:"notifications/message",params:b})}}async sendResourceUpdated(b){return this.notification({method:"notifications/resources/updated",params:b})}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 HD={name:"@sequenzy/mcp",version:"0.0.113",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":"bunx --bun 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:"^7.0.2"},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 HW=["product-info","domain","tracking","localization","integrations","products","events","tags","labels","goals","sync-rules","api-keys","widgets","team","danger"],JD={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}",landingPages:"/dashboard/company/{companyId}/landing-pages",landingPage:"/dashboard/company/{companyId}/landing-pages/{landingPageId}",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 UP(b){let $=(b??process.env.SEQUENZY_APP_URL??"https://sequenzy.com").trim().replace(/\/+$/,"");return $.length>0?$:"https://sequenzy.com"}function nb(b){let w=b?.trim();return w?w:void 0}function rb(b){return encodeURIComponent(b)}function Xb(b,w){return`${b}${w}`}function Yb(b,w=""){return`/dashboard/company/${rb(b)}${w}`}function DD(b,w,$){return Xb(b,`${Yb(w,"/settings")}?tab=${encodeURIComponent($)}`)}function BP(b,w){let $=HW.map((W)=>[W,w?DD(b,w,W):""]);return Object.fromEntries($)}function Hw(b={},w){let $=UP(w),W=nb(b.companyId),Q={},G=BP($,W);if(!W)return{appUrl:$,routeTemplates:JD,settingsTabValues:HW,urls:Q,settingsUrls:G};Q.dashboard=Xb($,Yb(W)),Q.campaigns=Xb($,Yb(W,"/campaign")),Q.landingPages=Xb($,Yb(W,"/landing-pages")),Q.sequences=Xb($,Yb(W,"/sequences")),Q.settings=Xb($,Yb(W,"/settings")),Q.emails=Xb($,Yb(W,"/emails")),Q.subscribers=Xb($,Yb(W,"/subscribers")),Q.sentEmails=Xb($,Yb(W,"/sent-emails")),Q.segments=Xb($,Yb(W,"/segments")),Q.metrics=Xb($,Yb(W,"/metrics")),Q.transactional=Xb($,Yb(W,"/transactional"));let X=nb(b.campaignId);if(X)Q.campaign=Xb($,Yb(W,`/campaign/${rb(X)}`)),Q.campaignPreview=`${Q.campaign}?step=review`;let Y=nb(b.landingPageId);if(Y)Q.landingPage=Xb($,Yb(W,`/landing-pages/${rb(Y)}`));let H=nb(b.sequenceId);if(H)Q.sequence=Xb($,Yb(W,`/sequences/${rb(H)}`));let J=nb(b.emailId)??nb(b.templateId);if(J)Q.email=Xb($,Yb(W,`/emails/${rb(J)}`)),Q.template=Q.email;let D=nb(b.transactionalId);if(D)Q.transactionalEmail=Xb($,Yb(W,`/transactional/${rb(D)}`));let z=nb(b.emailSendId);if(z)Q.emailSend=Xb($,Yb(W,`/sent-emails/${rb(z)}`));let O=nb(b.domainId);if(O)Q.domain=Xb($,Yb(W,`/settings/domain/${rb(O)}`)),Q.domainVerify=`${Q.domain}/verify`;let q=nb(b.status);if(q)Q.campaignList=Xb($,Yb(W,`/campaign/list/${rb(q)}`)),Q.sequenceList=Xb($,Yb(W,`/sequences/list/${rb(q)}`));let B=nb(b.settingsTab);if(B)Q.settingsTab=DD($,W,B);return{appUrl:$,routeTemplates:JD,settingsTabValues:HW,urls:Q,settingsUrls:G}}var zD=[{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 AD(b){try{let w;switch(b){case"sequenzy://dashboard":w=await A("GET","/api/v1/metrics?period=7d");break;case"sequenzy://company":{let $=await A("GET","/api/v1/account"),W=Tw()??$.currentCompanyId;if(!W)throw Error("No company available. Create or select a company first.");w=await A("GET",`/api/v1/companies/${W}`);break}case"sequenzy://campaigns/recent":w=await A("GET","/api/v1/campaigns?limit=10");break;case"sequenzy://subscribers/recent":w=await A("GET","/api/v1/subscribers?sort=createdAt&limit=20");break;case"sequenzy://subscribers/engaged":w=await A("GET","/api/v1/subscribers?sort=engagement&limit=20");break;case"sequenzy://sequences":w=await A("GET","/api/v1/sequences");break;case"sequenzy://templates":w=await A("GET","/api/v1/templates");break;case"sequenzy://segments":w=await A("GET","/api/v1/segments");break;case"sequenzy://tags":w=await A("GET","/api/v1/tags");break;case"sequenzy://health":w=await A("GET","/api/v1/health/deliverability");break;case"sequenzy://app-routes":w=Hw();break;default:throw Error(`Unknown resource: ${b}`)}return{contents:[{uri:b,mimeType:"application/json",text:JSON.stringify(w,null,2)}]}}catch(w){return{contents:[{uri:b,mimeType:"text/plain",text:yw(w)}]}}}function y(b){return typeof b==="object"&&b!==null&&!Array.isArray(b)}function F(b,w){let $=b[w];if(typeof $!=="string")return;let W=$.trim();return W.length>0?W:void 0}function j(b,w,$){let W=F(w,$);if(W===void 0)throw Error(`\`${$}\` is required when calling \`${b}\`.`);return W}var Ew='For exact historical Poll/NPS respondents, use field `pollResponse`, operator `is`, and a JSON value shaped like {"v":1,"campaignId":"camp_123","blockId":"poll_1","match":{"kind":"answer","value":"loved"}}. For NPS buckets, use match {"kind":"npsBucket","bucket":"promoters"}; bucket may be `promoters`, `passives`, or `detractors`.',Jw='Sequenzy email blocks. Use this for editor-compatible content, including conditional and repeat blocks. For provider-migrated HTML from another email platform, prefer the `html` field instead; Sequenzy stores it as one raw HTML block to preserve the original design. 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`. Repeat blocks use { type: \'repeat\', source: \'items\', itemAlias: \'item\', children: [...] }. Any block accepts a `conditions` array so it only renders for matching recipients. To branch on a value passed in transactional `variables` or an automation `event` payload, use { "id": "c1", "field": "variable", "operator": "is", "value": "plan:pro" }; "attribute" uses the same "name:value" form, while "email"/"firstName"/"lastName" use a plain comparison value. Live subscriber fields are "status", "tag", "list", "segment", "event", "emailProvider", "phone", "smsStatus", "added", "stripeProduct", "stripeCurrentProduct", "stripeTrialProduct", "commerceProduct", "emailSent", "emailDelivered", "emailOpened", "emailClicked", "emailBounced", and "emailComplained". They use the same field-specific values and operators as segment filters, for example { "id": "c2", "field": "segment", "operator": "is", "value": "seg_123" }, { "id": "c3", "field": "tag", "operator": "contains", "value": "vip" }, or { "id": "c4", "field": "event", "operator": "at_least", "value": "purchase:3:30d" }. Supported operators across fields are is, is_not, contains, not_contains, gt, gte, lt, lte, less_than, more_than, at_least, less_than_count, is_empty, is_not_empty, is_temporary_bounce, and is_permanent_bounce; each field accepts only its segment-filter operators. Recipients without a stored subscriber match use the OTHERWISE branch or hide a conditionally displayed block. For if/else, use a { type: "conditional-group", conditions: [...], ifBranch: { children: [...] }, elseBranch: { children: [...] } } block. Polls and NPS surveys use a native poll block. For answer buttons use { "type": "poll", "variant": "options", "question": "What did you think?", "options": [{ "label": "Loved it", "value": "loved" }, { "label": "Not for me", "value": "not_for_me" }], "attributeKey": "email_feedback" }. For NPS use { "type": "poll", "variant": "nps", "question": "How likely are you to recommend us?", "options": [], "attributeKey": "nps_score", "npsLowLabel": "Not likely", "npsHighLabel": "Very likely" }. `attributeKey` stores the latest response for segmentation. Optional `appearance` picks the answer style: "soft" (default), "pill", "outline", "filled", "pop" (hard-shadow boxes), "brutal" (square uppercase slabs), "quiz" (A/B/C letter badges), or "minimal" (bare ruled rows). Optional `confirmationMessage` customizes the hosted thank-you page; set `redirectUrl` only when respondents should land on another page. For a new image, call `upload_image_asset` first and insert its returned `imageBlock`. A responsive fixed-height screenshot crop uses { "type": "image", "src": "https://...", "alt": "Product dashboard", "width": 100, "widthType": "percent", "height": 320, "objectFit": "cover", "align": "center" }.',Dw='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`. Any block accepts a `conditions` array so it only renders for matching recipients. To branch on a value passed in transactional `variables` or an automation `event` payload, use { "id": "c1", "field": "variable", "operator": "is", "value": "plan:pro" }; "attribute" uses the same "name:value" form, while "email"/"firstName"/"lastName" use a plain comparison value. Live subscriber fields are "status", "tag", "list", "segment", "event", "emailProvider", "phone", "smsStatus", "added", "stripeProduct", "stripeCurrentProduct", "stripeTrialProduct", "commerceProduct", "emailSent", "emailDelivered", "emailOpened", "emailClicked", "emailBounced", and "emailComplained". They use the same field-specific values and operators as segment filters, for example { "id": "c2", "field": "segment", "operator": "is", "value": "seg_123" }, { "id": "c3", "field": "tag", "operator": "contains", "value": "vip" }, or { "id": "c4", "field": "event", "operator": "at_least", "value": "purchase:3:30d" }. Supported operators across fields are is, is_not, contains, not_contains, gt, gte, lt, lte, less_than, more_than, at_least, less_than_count, is_empty, is_not_empty, is_temporary_bounce, and is_permanent_bounce; each field accepts only its segment-filter operators. Recipients without a stored subscriber match use the OTHERWISE branch or hide a conditionally displayed block. For if/else, use a { type: "conditional-group", conditions: [...], ifBranch: { children: [...] }, elseBranch: { children: [...] } } block. Polls and NPS surveys use a native poll block. For answer buttons use { "type": "poll", "variant": "options", "question": "What did you think?", "options": [{ "label": "Loved it", "value": "loved" }, { "label": "Not for me", "value": "not_for_me" }], "attributeKey": "email_feedback" }. For NPS use { "type": "poll", "variant": "nps", "question": "How likely are you to recommend us?", "options": [], "attributeKey": "nps_score", "npsLowLabel": "Not likely", "npsHighLabel": "Very likely" }. `attributeKey` stores the latest response for segmentation. Optional `appearance` picks the answer style: "soft" (default), "pill", "outline", "filled", "pop" (hard-shadow boxes), "brutal" (square uppercase slabs), "quiz" (A/B/C letter badges), or "minimal" (bare ruled rows). Optional `confirmationMessage` customizes the hosted thank-you page; set `redirectUrl` only when respondents should land on another page. For a new image, call `upload_image_asset` first and insert its returned `imageBlock`. A responsive fixed-height screenshot crop uses { "type": "image", "src": "https://...", "alt": "Product dashboard", "width": 100, "widthType": "percent", "height": 320, "objectFit": "cover", "align": "center" }.',W1='Sequenzy email blocks. Provide blocks or html for email steps. For migrated provider HTML, prefer `html`; Sequenzy stores it as one raw HTML block and does not recreate it as native 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`. Blocks can include repeat blocks over array variables such as items. Any block accepts a `conditions` array so it only renders for matching recipients. To branch on a value passed in transactional `variables` or an automation `event` payload, use { "id": "c1", "field": "variable", "operator": "is", "value": "plan:pro" }; "attribute" uses the same "name:value" form, while "email"/"firstName"/"lastName" use a plain comparison value. Live subscriber fields are "status", "tag", "list", "segment", "event", "emailProvider", "phone", "smsStatus", "added", "stripeProduct", "stripeCurrentProduct", "stripeTrialProduct", "commerceProduct", "emailSent", "emailDelivered", "emailOpened", "emailClicked", "emailBounced", and "emailComplained". They use the same field-specific values and operators as segment filters, for example { "id": "c2", "field": "segment", "operator": "is", "value": "seg_123" }, { "id": "c3", "field": "tag", "operator": "contains", "value": "vip" }, or { "id": "c4", "field": "event", "operator": "at_least", "value": "purchase:3:30d" }. Supported operators across fields are is, is_not, contains, not_contains, gt, gte, lt, lte, less_than, more_than, at_least, less_than_count, is_empty, is_not_empty, is_temporary_bounce, and is_permanent_bounce; each field accepts only its segment-filter operators. Recipients without a stored subscriber match use the OTHERWISE branch or hide a conditionally displayed block. For if/else, use a { type: "conditional-group", conditions: [...], ifBranch: { children: [...] }, elseBranch: { children: [...] } } block. Polls and NPS surveys use a native poll block. For answer buttons use { "type": "poll", "variant": "options", "question": "What did you think?", "options": [{ "label": "Loved it", "value": "loved" }, { "label": "Not for me", "value": "not_for_me" }], "attributeKey": "email_feedback" }. For NPS use { "type": "poll", "variant": "nps", "question": "How likely are you to recommend us?", "options": [], "attributeKey": "nps_score", "npsLowLabel": "Not likely", "npsHighLabel": "Very likely" }. `attributeKey` stores the latest response for segmentation. Optional `appearance` picks the answer style: "soft" (default), "pill", "outline", "filled", "pop" (hard-shadow boxes), "brutal" (square uppercase slabs), "quiz" (A/B/C letter badges), or "minimal" (bare ruled rows). Optional `confirmationMessage` customizes the hosted thank-you page; set `redirectUrl` only when respondents should land on another page. For a new image, call `upload_image_asset` first and insert its returned `imageBlock`. A responsive fixed-height screenshot crop uses { "type": "image", "src": "https://...", "alt": "Product dashboard", "width": 100, "widthType": "percent", "height": 320, "objectFit": "cover", "align": "center" }.',X0="Complete Sequenzy landing page content JSON. Use this when replacing the page structure. The content must be the editor-compatible landing page schema with version, template, seo, theme, and blocks. Landing pages must include exactly one footer block and at most one form block.",OD="Optional template key for default content, such as from-scratch, waitlist, lead-magnet, launch, demo-request, webinar, newsletter, product-hunt, pricing-offer, agency-lead-gen, or feature-announcement.",JW=500,DW=500,lb={type:"boolean",description:"If true, include machine-classified bot/scanner opens and clicks. Defaults to false, so metrics and activity are human-only."},k$=["send","delivery","bounce","complaint","open","click","unsubscribe","delivery_delay"],v$={type:"object",description:"Optional send window for every email step in the sequence. When set, email actions that become due outside the window wait until the next allowed local time. Omit days to allow every day.",properties:{enabled:{type:"boolean",description:"Set false to disable the sending window when creating a sequence. For updates, prefer clearSendingWindow."},timezone:{type:"string",description:"IANA timezone for the window, e.g. Europe/Kiev or America/New_York."},startTime:{type:"string",description:"Earliest local send time in 24-hour HH:mm format, e.g. 08:00."},endTime:{type:"string",description:"Latest local send cutoff in 24-hour HH:mm format, e.g. 20:00. Must be later than startTime."},days:{type:"array",description:"Allowed local days. Use full names or short names such as monday, tuesday, mon, tue. Omit for every day.",items:{type:"string"}}},additionalProperties:!1},FP={type:"object",description:"Offset relative to a wait-until date.",properties:{days:{type:"number"},hours:{type:"number"},minutes:{type:"number"}},additionalProperties:!1},Q1={type:"object",description:"Wait until a date from the trigger event before this step. Use this for renewal reminders, appointment follow-ups, trial-expiry nudges, and other subscriber-specific dates. The field value must be an ISO date string or Unix timestamp.",properties:{field:{type:"string",description:"Dot-path into the trigger event properties, e.g. renews_at or booking.startsAt."},untilDateField:{type:"string",description:"Alias for field."},offset:FP,days:{type:"number",description:"Offset days shorthand. Ignored when offset is provided."},hours:{type:"number",description:"Offset hours shorthand. Ignored when offset is provided."},minutes:{type:"number",description:"Offset minutes shorthand. Ignored when offset is provided."},direction:{type:"string",enum:["before","after"],description:"Whether the offset applies before or after the resolved date. Defaults to after."},untilOffsetDirection:{type:"string",enum:["before","after"],description:"Alias for direction."},missingAction:{type:"string",enum:["continue","exit"],description:"What to do if the event field is missing or invalid. Defaults to continue."},untilMissingAction:{type:"string",enum:["continue","exit"],description:"Alias for missingAction."}},additionalProperties:!1},G1={type:"object",description:"Fixed delay before this step. For a dynamic wait-until-date delay, either set mode:'until_date' plus untilDateField here, or use waitUntil.",properties:{days:{type:"number"},hours:{type:"number"},minutes:{type:"number"},mode:{type:"string",enum:["duration","until_date"],description:"Use duration for a fixed wait, or until_date to resolve a date from the trigger event."},untilDateField:{type:"string",description:"For mode:'until_date', dot-path into the trigger event properties."},field:{type:"string",description:"Alias for untilDateField."},untilOffsetDirection:{type:"string",enum:["before","after"],description:"For mode:'until_date', whether days/hours/minutes are before or after the event date. Defaults to after."},direction:{type:"string",enum:["before","after"],description:"Alias for untilOffsetDirection."},untilMissingAction:{type:"string",enum:["continue","exit"],description:"For mode:'until_date', what to do when the field is missing or invalid. Defaults to continue."},missingAction:{type:"string",enum:["continue","exit"],description:"Alias for untilMissingAction."}},additionalProperties:!1},zW={type:"object",description:"Type-aware patch for the existing node. Start from get_sequence.sequence.nodes[].config. For logic_delay, set exactly one of delay ({ days, hours, minutes }), delayMs, or waitUntil; optional label is also accepted. For action_email, use name/label, subject, previewText, html/htmlContent or blocks, isTransactional, and sender/reply identity fields. For action_sms, use text, blocks, imageUrls, label, or ineligibleAction. Other node types accept their editable config keys. Managed IDs, nodeType conversion, and branch path IDs/count are not editable here; use edit_sequence_graph for topology. Webhook header patches are merged, and redacted values from get_sequence must be omitted or replaced with a real new value.",additionalProperties:!0},C$={type:"object",properties:{nodeId:{type:"string",description:"Existing node ID from get_sequence.sequence.nodes[].id."},changes:zW,expectedUpdatedAt:{type:"string",description:"Required optimistic-concurrency value from get_sequence.sequence.nodes[].updatedAt. The update is rejected if that node or its linked email content changed after it was read."}},required:["nodeId","changes","expectedUpdatedAt"],additionalProperties:!1},X1=["gray","red","orange","amber","yellow","lime","green","emerald","teal","cyan","sky","blue","indigo","violet","purple","fuchsia","pink","rose"],Y1=["email.sent","email.delivered","email.delivery_delayed","email.bounced","email.complained","email.opened","email.clicked","email.replied","email.unsubscribed","sms.sent","sms.delivered","sms.failed","sms.opted_out","subscriber.invalid","subscriber.updated","subscriber.unsubscribed","subscriber.list_subscribed","subscriber.list_unsubscribed","sequence.finished","sequence.failed","poll.answered"];var KP=new Set(["get_account","get_app_urls","get_company","get_sync_rules","get_shopify_automation_settings","list_websites","check_website","get_integration_guide","get_subscriber","list_subscriber_notes","search_subscribers","list_products","list_tags","list_lists","list_segments","get_segment_count","list_audience_syncs","list_ad_accounts","list_templates","get_template","list_ab_tests","get_ab_test","get_ab_test_stats","list_campaigns","get_campaign","get_email_send","list_landing_pages","get_landing_page","list_sequences","get_sequence","list_transactional_emails","get_transactional_email","get_stats","get_campaign_stats","get_sequence_stats","list_campaign_events","list_sequence_events","get_subscriber_activity","list_team_members","list_conversations","get_conversation","list_webhooks","list_webhook_deliveries","generate_email","generate_sequence","generate_subject_lines","generate_sms","get_sms_settings"]),PP=new Set(["select_company","create_company","update_company","update_sync_rules","update_shopify_automation_settings","create_api_key","add_sending_domain","add_website","verify_sending_domain","add_subscriber","update_subscriber","add_subscriber_note","remove_subscriber","delete_subscriber_note","upsert_products","delete_product","attach_product_file","remove_product_file","upload_image_asset","sync_products","create_tag","update_tag","delete_tag","create_list","update_list","delete_list","add_subscribers_to_list","remove_subscribers_from_list","create_segment","update_segment","delete_segment","create_audience_sync","update_audience_sync","delete_audience_sync","sync_audience_now","create_template","update_template","set_template_localization","sync_template_localizations","delete_template","restart_ab_test","update_ab_test_variant","create_ab_test","add_ab_test_variant","delete_ab_test_variant","delete_ab_test","create_campaign","update_campaign","schedule_campaign","send_test_email","send_test_sms","cancel_campaign","pause_campaign","resume_campaign","delete_campaign","duplicate_campaign","resend_campaign_to_non_openers","create_landing_page","update_landing_page","delete_landing_page","publish_landing_page","unpublish_landing_page","connect_landing_page_domain","update_landing_page_domain_settings","create_sequence","update_sequence","update_sequence_node","update_sequence_nodes","edit_sequence_graph","insert_sequence_step","enable_sequence","disable_sequence","pause_sequence_enrollments","resume_sequence_enrollments","enroll_subscribers_in_sequence","cancel_sequence_enrollments","delete_sequence","create_transactional_email","update_transactional_email","send_email","invite_team_member","cancel_team_invitation","reply_to_conversation","update_conversation_status","mark_conversation_read","create_webhook","update_webhook","delete_webhook","test_webhook","replay_webhook_delivery","submit_feedback"]),MP=new Set(["send_test_email","send_test_sms","schedule_campaign","resume_campaign","publish_landing_page","connect_landing_page_domain","update_landing_page_domain_settings","add_sending_domain","add_website","verify_sending_domain","enable_sequence","resume_sequence_enrollments","send_email","invite_team_member","reply_to_conversation","create_webhook","update_webhook","test_webhook","replay_webhook_delivery"]),ZP=new Set(["remove_subscriber","delete_subscriber_note","delete_product","remove_product_file","delete_tag","delete_list","remove_subscribers_from_list","delete_segment","delete_audience_sync","delete_template","restart_ab_test","delete_ab_test_variant","delete_ab_test","cancel_campaign","delete_campaign","delete_landing_page","unpublish_landing_page","disable_sequence","edit_sequence_graph","cancel_sequence_enrollments","delete_sequence","cancel_team_invitation","delete_webhook"]);function jP(b){let w=KP.has(b),$=PP.has(b);if(w===$)throw Error(`MCP tool "${b}" must be classified as exactly one of read-only or mutating.`);return{readOnlyHint:w,destructiveHint:w?!1:ZP.has(b),openWorldHint:MP.has(b)}}function qD(b){return{...b,annotations:{...b.annotations,...jP(b.name)}}}var AW={status:["is","is_not"],phone:["is_not_empty","is_empty"],smsStatus:["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"],pollResponse:["is"],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"],commerceProduct:["is","is_not","at_least","less_than_count"]},IP=Object.entries(AW).map(([b,w])=>`${b}: ${w.join(", ")}`).join("; "),OW={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","phone","smsStatus","tag","email","emailProvider","added","firstName","lastName","list","emailSent","emailDelivered","emailOpened","emailClicked","emailBounced","emailComplained","attribute","event","pollResponse","segment","stripeProduct","stripeCurrentProduct","stripeTrialProduct","commerceProduct"],description:`Filter field. Use \`phone\` with is_not_empty/is_empty to check whether a subscriber has a phone number, and \`smsStatus\` (is/is_not one of \`subscribed\`, \`unsubscribed\`, \`not_subscribed\`) for SMS marketing consent. Use \`event\` for custom subscriber events, \`segment\` for saved segment membership, \`stripeProduct\`/\`stripeCurrentProduct\`/\`stripeTrialProduct\` for Stripe product-based segments, and \`commerceProduct\` for products purchased through commerce orders - the value is \`provider:productId\` (provider one of \`shopify\`, \`woocommerce\`, \`api\`; product ids are provider-scoped), optionally with an order-count threshold (\`provider:productId:count\`) for at_least/less_than_count; a bare product id matches the id on any provider. Engagement fields (\`emailSent\`, \`emailDelivered\`, \`emailOpened\`, \`emailClicked\`, \`emailBounced\`, \`emailComplained\`) accept a time range as the value, a specific campaign via \`campaign:<campaign_id>\`, or \`count:timeRange\` (e.g. \`10:30d\`, \`10:all\`) with at_least/less_than_count to segment by number of opens/clicks. ${Ew}`},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: ${IP}.`},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, \`campaign:<campaign_id>\` to scope to a specific sent campaign (use \`list_campaigns\` to find IDs), or \`count:timeRange\` like \`10:30d\` / \`10:all\` with at_least/less_than_count operators (e.g. emailClicked at_least \`10:all\` = clicked 10 or more times ever). ${Ew}`}},required:["field","operator","value"],additionalProperties:!1},qW={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 x$(b){if(!Array.isArray(b))return b;return b.map((w)=>{if(typeof w!=="object"||w===null)return w;let $=w;if(typeof $.id==="string"&&$.id.trim()!=="")return $;return{...$,id:crypto.randomUUID()}})}function u$(b){if(typeof b!=="object"||b===null)return b;let w=b;if(w.kind==="filter"||"field"in w||"operator"in w||"value"in w){let $=x$([w]);return Array.isArray($)?$[0]:w}if(w.kind!=="group")return b;return{...w,id:typeof w.id==="string"&&w.id.trim()!==""?w.id:crypto.randomUUID(),children:Array.isArray(w.children)?w.children.map(u$):[]}}function VP(b){let w=b.indexOf(":");return w!==-1&&b.substring(0,w).trim().length>0}function NP(b){let w=b.indexOf(":");return w!==-1&&b.substring(w+1).trim().length>0}function LD(b){if(b==="all")return!0;let w=b.match(/^(\d+)d$/);if(!w?.[1])return!1;let $=Number.parseInt(w[1],10);return Number.isInteger($)&&$>0}function EP(b,w){let $=w.split(":");if(b==="at_least"||b==="less_than_count"){if($.length<3)return'Event count filters must use "eventName:count:timeRange", like "saas.purchase:2:30d".';let G=$.slice(0,-2).join(":").trim(),X=$.at(-2),Y=$.at(-1),H=X===void 0?Number.NaN:Number.parseInt(X,10);return G&&Number.isInteger(H)&&H>0&&Y!==void 0&&LD(Y)?null:'Event count filters must use "eventName:count:timeRange", like "saas.purchase:2:30d".'}if($.length<2)return'Event filters must use "eventName:timeRange", like "saas.purchase:30d".';let W=$.slice(0,-1).join(":").trim(),Q=$.at(-1);return W&&Q!==void 0&&LD(Q)?null:'Event filters must use "eventName:timeRange", like "saas.purchase:30d".'}function TP(b){let w=b.indexOf(":");if(w===-1)return{productId:b,subfilter:null,rawValue:null};let $=b.substring(0,w),W=b.substring(w+1),Q=W.indexOf(":");if(Q===-1)return{productId:$,subfilter:W,rawValue:null};return{productId:$,subfilter:W.substring(0,Q),rawValue:W.substring(Q+1)}}function _P(b){return b.trim().toLowerCase().replace(/[-\s]+/g,"_")}function SP(b){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(b)}function RP(b,w){if(w==="cancels_at"||w==="cancel_at"||w==="cancellation_at")return!0;if(b==="stripeCurrentProduct")return["end_at","ends_at","period_end","period_ends_at","current_period_end"].includes(w);return["start_at","started_at","trial_start","trial_started_at","end_at","ends_at","trial_end","trial_ends_at"].includes(w)}function kP(b){return["is","is_not","gte","lte","gt","lt"].includes(b)}function vP(b,w,$){if(b==="stripeProduct"){if(w!=="at_least"&&w!=="less_than_count")return null;let Y=$.indexOf(":");if(Y===-1)return null;let H=$.substring(0,Y).trim(),J=Number.parseInt($.substring(Y+1).trim(),10);return H&&Number.isInteger(J)&&J>=1?null:'Stripe Product threshold filters must use "productId:count" with a count of at least 1.'}if(b!=="stripeCurrentProduct"&&b!=="stripeTrialProduct")return null;let{productId:W,subfilter:Q,rawValue:G}=TP($);if(!W.trim())return"Stripe product filters must include a product ID.";if(!Q)return w==="is"||w==="is_not"?null:'Stripe current/trial date filters must use "productId:dateField:value".';let X=_P(Q);if(SP(X))return w==="is"||w==="is_not"?null:"Stripe cancellation flag filters only support is and is_not operators.";if(!RP(b,X))return`Unsupported Stripe product subfilter "${Q}".`;if(!kP(w))return"Stripe date filters only support is, is_not, gte, lte, gt, and lt operators.";return G?.trim()?null:'Stripe date filters must include a value like "productId:end_at:2026-05-26".'}var CP=new Set(["shopify","woocommerce","api"]);function xP(b,w){let $=w.trim(),W=$.indexOf(":");if(W!==-1&&CP.has($.substring(0,W).trim()))$=$.substring(W+1).trim();if(!$)return'Purchased Product filters must include a product ID, like "shopify:42".';if(b!=="at_least"&&b!=="less_than_count")return null;let Q=$.lastIndexOf(":");if(Q===-1)return null;let G=$.substring(0,Q).trim(),X=Number.parseInt($.substring(Q+1).trim(),10);return G&&Number.isInteger(X)&&X>=1?null:'Purchased Product threshold filters must use "provider:productId:count" with a count of at least 1.'}function uP(b){let w;try{w=JSON.parse(b)}catch{return`Poll response filters must use valid JSON. ${Ew}`}if(!y(w)||w.v!==1||typeof w.campaignId!=="string"||!w.campaignId.trim()||typeof w.blockId!=="string"||!w.blockId.trim()||!y(w.match))return`Poll response filter context is invalid. ${Ew}`;let $=w.match;if($.kind==="answer"&&typeof $.value==="string"&&$.value.length>0)return null;if($.kind==="npsBucket"&&($.bucket==="promoters"||$.bucket==="passives"||$.bucket==="detractors"))return null;return`Poll response filter match is invalid. ${Ew}`}function y$(b){if(typeof b!=="object"||b===null)return"Segment filters must be objects.";let w=b,$=w.field,W=w.operator,Q=w.value;if(typeof $!=="string"||!($ in AW))return`Unsupported segment filter field "${String($)}".`;if(typeof W!=="string")return`Segment filter "${$}" must include an operator.`;let G=AW[$];if(!G.includes(W))return`Operator "${W}" is not supported for ${$} filters. Use one of: ${G.join(", ")}.`;if(W!=="is_empty"&&W!=="is_not_empty"&&(typeof Q!=="string"||Q.trim().length===0))return`Segment filter "${$}" must include a value.`;if($==="attribute"&&typeof Q==="string"){if(!VP(Q))return'Attribute filters must use "attributeName:value" or "attributeName:" for empty checks.';if(W!=="is_empty"&&W!=="is_not_empty"&&!NP(Q))return'Attribute filters must include a value after "attributeName:".'}if($==="event"&&typeof Q==="string"){let X=EP(W,Q);if(X)return X}if($==="pollResponse"&&typeof Q==="string"){let X=uP(Q);if(X)return X}if(($==="stripeProduct"||$==="stripeCurrentProduct"||$==="stripeTrialProduct")&&typeof Q==="string"){let X=vP($,W,Q);if(X)return X}if($==="commerceProduct"&&typeof Q==="string"){let X=xP(W,Q);if(X)return X}if($==="tag"&&(W==="contains"||W==="not_contains")){if(!(typeof Q==="string"&&Q.split(",").map((Y)=>Y.trim()).some(Boolean)))return"Tag filters must include at least one tag name."}return null}function h$(b){if(typeof b!=="object"||b===null)return[];let w=b;if(w.kind==="filter"||"field"in w||"operator"in w||"value"in w){let $=y$(w);return $?[$]:[]}if(Array.isArray(w.children))return w.children.flatMap(h$);return[]}function _b(b,w,$){if(w.html!==void 0&&w.blocks!==void 0)throw Error(`Provide either \`html\` or \`blocks\` when calling \`${b}\`, not both.`);if(w.blocks!==void 0&&!Array.isArray(w.blocks))throw Error(`\`blocks\` must be an array when calling \`${b}\`.`);if($?.requireContent&&w.html===void 0&&w.blocks===void 0)throw Error(`Provide either \`html\` or \`blocks\` when calling \`${b}\`.`)}function H1(b,w){if(w.labels===void 0)return;if(!Array.isArray(w.labels))throw Error(`\`labels\` must be an array when calling \`${b}\`.`);if(w.labels.some(($)=>typeof $!=="string"||$.trim().length===0))throw Error(`\`labels\` must contain only non-empty strings when calling \`${b}\`.`)}function FD(b){let w=b.filters!==void 0,$=b.root!==void 0;if(w&&$)throw Error("Provide either `filters` or `root` when calling `create_segment`, not both.");if(!w&&!$)throw Error("Provide either `filters` or `root` when calling `create_segment`.");if(w){if(!Array.isArray(b.filters))throw Error("`filters` must be an array when calling `create_segment`.");if(b.filters.length===0)throw Error("`filters` must include at least one filter when calling `create_segment`.")}if($&&(typeof b.root!=="object"||b.root===null))throw Error("`root` must be an object when calling `create_segment`.");let W=w?b.filters.flatMap((Q)=>{let G=y$(Q);return G?[G]:[]}):h$(b.root);if(W.length>0)throw Error(W[0]??"Invalid segment filter in `create_segment`.")}function KD(b){let w=b.filters!==void 0,$=b.root!==void 0;if(w&&$)throw Error("Provide either `filters` or `root` when calling `update_segment`, not both.");if(b.name===void 0&&b.filterJoinOperator===void 0&&!w&&!$)throw Error("Provide at least one of `name`, `filters`, `root`, or `filterJoinOperator` when calling `update_segment`.");if(w){if(!Array.isArray(b.filters))throw Error("`filters` must be an array when calling `update_segment`.");if(b.filters.length===0)throw Error("`filters` must include at least one filter when calling `update_segment`.")}if($&&(typeof b.root!=="object"||b.root===null))throw Error("`root` must be an object when calling `update_segment`.");let W=w?b.filters.flatMap((Q)=>{let G=y$(Q);return G?[G]:[]}):$?h$(b.root):[];if(W.length>0)throw Error(W[0]??"Invalid segment filter in `update_segment`.")}var LW=["name","description","logoUrl","founderName","primaryColor","brandColors","valueProps","testimonials","toneVoice","companyContext","emailLengthPreference","socialLinks","privacyPolicyUrl","termsUrl","address","language","pricing","fontFamily","emailDirection","fromEmail","fromName","replyTo","replyToName"];function UW(b,w,$){if(w[$]!==void 0&&!y(w[$]))throw Error(`\`${$}\` must be an object when calling \`${b}\`.`)}function UD(b,w,$){if(w[$]!==void 0&&!Array.isArray(w[$]))throw Error(`\`${$}\` must be an array when calling \`${b}\`.`)}function PD(b){let w=new Set(["companyId",...LW]),$=Object.keys(b).filter((Q)=>!w.has(Q));if($.length>0)throw Error(`\`update_company\` accepts only company product-info fields. Unsupported field${$.length===1?"":"s"}: ${$.map((Q)=>`\`${Q}\``).join(", ")}.`);let W={};for(let Q of LW)if(b[Q]!==void 0)W[Q]=b[Q];if(Object.keys(W).length===0)throw Error(`Provide at least one of ${LW.map((Q)=>`\`${Q}\``).join(", ")} when calling \`update_company\`.`);for(let Q of["name","description","logoUrl","founderName","primaryColor","toneVoice","companyContext","emailLengthPreference","privacyPolicyUrl","termsUrl","address","language","fontFamily","emailDirection","fromEmail","fromName","replyTo","replyToName"])if(b[Q]!==void 0&&typeof b[Q]!=="string")throw Error(`\`${Q}\` must be a string when calling \`update_company\`.`);if(UW("update_company",b,"brandColors"),UW("update_company",b,"socialLinks"),UW("update_company",b,"pricing"),UD("update_company",b,"valueProps"),UD("update_company",b,"testimonials"),typeof b.primaryColor==="string"&&!/^#[0-9a-f]{6}$/i.test(b.primaryColor.trim()))throw Error("`primaryColor` must be a 6-digit hex color such as #f97316 when calling `update_company`.");for(let Q of["fromEmail","replyTo"]){let G=b[Q];if(typeof G==="string"&&!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(G.trim()))throw Error(`\`${Q}\` must be a valid email address when calling \`update_company\`.`)}if(b.fromName!==void 0&&b.fromEmail===void 0)throw Error("`fromName` requires `fromEmail` when calling `update_company`.");if(b.replyToName!==void 0&&b.replyTo===void 0)throw Error("`replyToName` requires `replyTo` when calling `update_company`.");return W}var MD=["senderProfileId","fromEmail","fromName","replyProfileId","replyTo","replyToName"];function yP(b){return MD.some((w)=>b[w]!==void 0)}function hP(b){if(typeof b.nodeType==="string")return b.nodeType==="action_email";return b.type===void 0||b.type==="email"}function f$(b,w,$){for(let W of MD){let Q=$[W];if(Q!==void 0&&typeof Q!=="string")throw Error(`\`${W}\` must be a string for ${w} when calling \`${b}\`.`)}if($.senderProfileId!==void 0&&$.fromEmail!==void 0)throw Error(`Provide either \`senderProfileId\` or \`fromEmail\` for ${w} when calling \`${b}\`, not both.`);if($.replyProfileId!==void 0&&$.replyTo!==void 0)throw Error(`Provide either \`replyProfileId\` or \`replyTo\` for ${w} when calling \`${b}\`, not both.`);if($.replyToName!==void 0&&$.replyTo===void 0)throw Error(`\`replyToName\` requires \`replyTo\` for ${w} when calling \`${b}\`.`)}function FW(b,w,$){if(yP($)&&!hP($))throw Error(`Sender identity fields are only supported for email steps at ${w} when calling \`${b}\`.`);f$(b,w,$)}function BD(b,w,$){if(!Array.isArray($))return;$.forEach((W,Q)=>{if(y(W))f$(b,`${w}[${Q}]`,W)})}function BW(b,w,$){if(!Array.isArray($))return;$.forEach((W,Q)=>{if(y(W))FW(b,`${w}[${Q}]`,W)})}function fP(b){if(BD("update_sequence","emails",b.emails),BD("update_sequence","steps",b.steps),y(b.insertSteps))BW("update_sequence","insertSteps.steps",b.insertSteps.steps);if(!y(b.branch))return;if(Array.isArray(b.branch.branches))b.branch.branches.forEach(($,W)=>{if(y($))BW("update_sequence",`branch.branches[${W}].steps`,$.steps)});BW("update_sequence","branch.elseSteps",b.branch.elseSteps)}function ZD(b){if(b.fromEmail!==void 0&&b.senderProfileId!==void 0)throw Error("Provide either `fromEmail` or `senderProfileId` when calling `update_sequence`, not both.");if(b.replyTo!==void 0&&b.replyProfileId!==void 0)throw Error("Provide either `replyTo` or `replyProfileId` when calling `update_sequence`, not both.");if(b.fromName!==void 0&&b.fromEmail===void 0)throw Error("`fromName` requires `fromEmail` when calling `update_sequence`.");if(b.replyToName!==void 0&&b.replyTo===void 0)throw Error("`replyToName` requires `replyTo` when calling `update_sequence`.");if(b.clearEnrollmentFieldPath===!0&&b.enrollmentFieldPath!==void 0)throw Error("Provide either `enrollmentFieldPath` or `clearEnrollmentFieldPath` when calling `update_sequence`, not both.");if(b.clearSendingWindow===!0&&b.sendingWindow!==void 0)throw Error("Provide either `sendingWindow` or `clearSendingWindow` when calling `update_sequence`, not both.");if(b.clearBccEmails===!0&&b.bccEmails!==void 0)throw Error("Provide either `bccEmails` or `clearBccEmails` when calling `update_sequence`, not both.");if(b.branch!==void 0&&b.insertSteps!==void 0)throw Error("Provide either `branch` or `insertSteps` when calling `update_sequence`, not both.");fP(b);let w={...b};if(delete w.clearEnrollmentFieldPath,delete w.clearSendingWindow,delete w.clearBccEmails,b.clearEnrollmentFieldPath===!0)w.enrollmentFieldPath=null;if(b.clearSendingWindow===!0)w.sendingWindow=null;if(b.clearBccEmails===!0)w.bccEmails=null;return w}function jD(b,w,$){let W=j(b,w,"nodeId");if(!y(w.changes)||Object.keys(w.changes).length===0)throw Error(`\`changes\` must be a non-empty object for ${$} when calling \`${b}\`.`);let Q=j(b,w,"expectedUpdatedAt");return{nodeId:W,changes:w.changes,expectedUpdatedAt:Q}}function ID(b){let w=jD("update_sequence_node",b,"the node update");return{...b.confirmLiveChange!==void 0&&{confirmLiveChange:b.confirmLiveChange},nodeUpdates:[w]}}function VD(b){if(!Array.isArray(b.updates)||b.updates.length===0)throw Error("`updates` must be a non-empty array when calling `update_sequence_nodes`.");let w=new Set,$=b.updates.map((W,Q)=>{if(!y(W))throw Error(`\`updates[${Q}]\` must be an object when calling \`update_sequence_nodes\`.`);let G=jD("update_sequence_nodes",W,`updates[${Q}]`),X=String(G.nodeId);if(w.has(X))throw Error(`\`updates[${Q}]\` targets duplicate nodeId '${X}' when calling \`update_sequence_nodes\`.`);return w.add(X),G});return{...b.confirmLiveChange!==void 0&&{confirmLiveChange:b.confirmLiveChange},nodeUpdates:$}}function ND(b){let w=j("edit_sequence_graph",b,"action"),$=j("edit_sequence_graph",b,"graphRevision");if(!new Set(["move_node","delete_node","duplicate_node","replace_edges"]).has(w))throw Error("`action` must be `move_node`, `delete_node`, `duplicate_node`, or `replace_edges` when calling `edit_sequence_graph`.");let Q=F(b,"nodeId"),G=F(b,"afterNodeId"),X=F(b,"beforeNodeId"),Y=b.edges;if(w!=="replace_edges"&&!Q)throw Error(`\`nodeId\` is required for ${w} when calling \`edit_sequence_graph\`.`);if(w==="replace_edges"&&Q)throw Error("`nodeId` is not used with `replace_edges` when calling `edit_sequence_graph`.");let H=w==="move_node"||w==="duplicate_node";if(H&&(G?1:0)+(X?1:0)!==1)throw Error(`Provide exactly one of \`afterNodeId\` or \`beforeNodeId\` for ${w} when calling \`edit_sequence_graph\`.`);if(!H&&(G||X))throw Error(`\`afterNodeId\` and \`beforeNodeId\` are not used with ${w} when calling \`edit_sequence_graph\`.`);if((w==="replace_edges"||w==="delete_node"&&Y!==void 0)&&(!Array.isArray(Y)||Y.length===0))throw Error(`\`edges\` must contain the complete replacement topology for ${w} when calling \`edit_sequence_graph\`.`);if((w==="move_node"||w==="duplicate_node")&&Y!==void 0)throw Error(`\`edges\` is not used with ${w} when calling \`edit_sequence_graph\`.`);let J=Array.isArray(Y)?Y.map((D,z)=>{if(!y(D))throw Error(`\`edges\` item ${z+1} must be an object when calling \`edit_sequence_graph\`.`);let O=j("edit_sequence_graph",D,"sourceNodeId"),q=j("edit_sequence_graph",D,"targetNodeId");if(D.condition!==void 0&&D.condition!==null&&!y(D.condition))throw Error(`\`edges\` item ${z+1} \`condition\` must be an object when calling \`edit_sequence_graph\`.`);return{sourceNodeId:O,targetNodeId:q,...y(D.condition)?{condition:D.condition}:{}}}):void 0;return{...b.confirmStructuralChange!==void 0&&{confirmStructuralChange:b.confirmStructuralChange},graphEdit:{action:w,expectedRevision:$,...Q?{nodeId:Q}:{},...G?{afterNodeId:G}:{},...X?{beforeNodeId:X}:{},...J?{edges:J}:{}}}}function ED(b){let w=b.type==="sms",$;if(w){FW("insert_sequence_step","SMS step",b);let Q=F(b,"text"),G=Array.isArray(b.blocks)&&b.blocks.length>0;if(Q===void 0&&!G)throw Error("Provide `text` (or `blocks`) when inserting an SMS step with `insert_sequence_step`.");$={type:"sms"};for(let X of["text","blocks","imageUrls","label","name","ineligibleAction","delay","delayMs","waitUntil"])if(b[X]!==void 0)$[X]=b[X]}else{_b("insert_sequence_step",b,{requireContent:!0}),f$("insert_sequence_step","email step",b),$={subject:j("insert_sequence_step",b,"subject")};for(let Q of["name","previewText","html","blocks","delay","delayMs","waitUntil","senderProfileId","fromEmail","fromName","replyProfileId","replyTo","replyToName"])if(b[Q]!==void 0)$[Q]=b[Q]}let W={steps:[$]};if(b.afterNodeId!==void 0)W.afterNodeId=b.afterNodeId;return{...b.confirmStructuralChange!==void 0&&{confirmStructuralChange:b.confirmStructuralChange},insertSteps:W}}function TD(b){let w=F(b,"subscriberId"),$=b.fieldValues,W=$===void 0?void 0:Array.isArray($)?$:void 0;if($!==void 0&&W===void 0)throw Error("`fieldValues` must be an array when calling `cancel_sequence_enrollments`.");let Q=W?.map((Y)=>typeof Y==="string"?Y.trim():"").filter((Y)=>Y.length>0)??[];if(W?.some((Y)=>typeof Y!=="string")||W!==void 0&&Q.length===0)throw Error("`fieldValues` must contain at least one non-empty string when calling `cancel_sequence_enrollments`.");if(w!==void 0===Q.length>0)throw Error("Provide exactly one target when calling `cancel_sequence_enrollments`: `subscriberId` or `fieldValues`.");let G=F(b,"fieldPath"),X=F(b,"reason");return{...w!==void 0&&{subscriberId:w},...G!==void 0&&{fieldPath:G},...Q.length>0&&{fieldValues:Q},...typeof b.dryRun==="boolean"&&{dryRun:b.dryRun},...X!==void 0&&{reason:X}}}function _D(b){_b("create_campaign",b),H1("create_campaign",b);let w=F(b,"prompt")!==void 0,$=b.html!==void 0,W=b.blocks!==void 0,Q=b.templateId!==void 0;if(b.prompt!==void 0&&!w)throw Error("`prompt` cannot be empty when calling `create_campaign`.");if(w&&($||W||Q))throw Error("Provide either `prompt`, `html`, `blocks`, or `templateId` when calling `create_campaign`, not multiple content sources.");if(!w&&(b.style!==void 0||b.tone!==void 0))throw Error("`style` and `tone` can only be used with `prompt` when calling `create_campaign`.");if(!w&&F(b,"subject")===void 0)throw Error("`subject` is required unless `prompt` is provided when calling `create_campaign`.")}function SD(b){_b("create_template",b),H1("create_template",b);let w=F(b,"prompt")!==void 0,$=[w,b.html!==void 0,b.blocks!==void 0].filter(Boolean).length;if(b.prompt!==void 0&&!w)throw Error("`prompt` cannot be empty when calling `create_template`.");if($!==1)throw Error("Provide exactly one of `prompt`, `html`, or `blocks` when calling `create_template`.");if(!w&&(b.style!==void 0||b.tone!==void 0))throw Error("`style` and `tone` can only be used with `prompt` when calling `create_template`.");if(!w&&F(b,"subject")===void 0)throw Error("`subject` is required unless `prompt` is provided when calling `create_template`.")}function RD(b){if(F(b,"scheduledAt")===void 0)throw Error("`scheduledAt` is required when calling `schedule_campaign`.");if(b.targetLists!==void 0&&!y(b.targetLists))throw Error("`targetLists` must be an object when calling `schedule_campaign`.");if(b.sendTimeOptimization!==void 0){if(typeof b.sendTimeOptimization!=="boolean")throw Error("`sendTimeOptimization` must be a boolean when calling `schedule_campaign`.")}if(b.spreadOverHours!==void 0){if(typeof b.spreadOverHours!=="number"||!Number.isInteger(b.spreadOverHours)||b.spreadOverHours<1||b.spreadOverHours>72)throw Error("`spreadOverHours` must be an integer between 1 and 72 when calling `schedule_campaign`.")}if(b.recurringInterval!==void 0&&b.recurringInterval!=="weekly"&&b.recurringInterval!=="monthly")throw Error("`recurringInterval` must be 'weekly' or 'monthly' when calling `schedule_campaign`.")}function c$(b,w,$){let W=new Set(["companyId","landingPageId","name","slug","content"]),Q=Object.keys(w).filter((G)=>!W.has(G));if(Q.length>0)throw Error(`\`${b}\` accepts only \`name\`, \`slug\`, and \`content\` update fields. Unsupported field${Q.length===1?"":"s"}: ${Q.map((G)=>`\`${G}\``).join(", ")}.`);if($.requireUpdate&&w.name===void 0&&w.slug===void 0&&w.content===void 0)throw Error(`Provide at least one of \`name\`, \`slug\`, or \`content\` when calling \`${b}\`.`);return{...w.name!==void 0&&{name:w.name},...w.slug!==void 0&&{slug:w.slug},...w.content!==void 0&&{content:w.content}}}function kD(b){let w=new Set(["companyId","domain","verify"]),$=Object.keys(b).filter((W)=>!w.has(W));if($.length>0)throw Error(`\`update_landing_page_domain_settings\` accepts only \`domain\` and \`verify\`. Unsupported field${$.length===1?"":"s"}: ${$.map((W)=>`\`${W}\``).join(", ")}.`);if(b.domain===void 0&&b.verify!==!0)throw Error("Provide `domain` or `verify: true` when calling `update_landing_page_domain_settings`.");return{...b.domain!==void 0&&{domain:b.domain},...typeof b.verify==="boolean"&&{verify:b.verify}}}function vD(b){_b("create_transactional_email",b);let w=F(b,"prompt")!==void 0,$=b.html!==void 0,W=b.blocks!==void 0;if(b.prompt!==void 0&&!w)throw Error("`prompt` cannot be empty when calling `create_transactional_email`.");if(w&&($||W))throw Error("Provide either `prompt`, `html`, or `blocks` when calling `create_transactional_email`, not multiple content sources.");if(!w&&(b.style!==void 0||b.tone!==void 0))throw Error("`style` and `tone` can only be used with `prompt` when calling `create_transactional_email`.");if(!w&&!$&&!W)throw Error("Provide either `prompt`, `html`, or `blocks` when calling `create_transactional_email`.");if(!w&&F(b,"subject")===void 0)throw Error("`subject` is required unless `prompt` is provided when calling `create_transactional_email`.")}var Y0={type:"object",description:"Update Subscriber config. firstName, lastName, and customAttributeUpdates values may use trigger-event merge tags such as {{event.plan}}. Number and boolean values must be a literal or one standalone merge tag and are coerced after resolution.",properties:{label:{type:"string"},firstName:{type:["string","null"],description:"First name literal or merge tag; null clears the field."},lastName:{type:["string","null"],description:"Last name literal or merge tag; null clears the field."},status:{type:"string",enum:["active","unsubscribed","bounced"]},customAttributeUpdates:{type:"array",items:{type:"object",properties:{name:{type:"string"},value:{type:["string","number","boolean","null"],description:"Literal scalar, null to delete, or a standalone merge tag such as {{event.plan}}, {{event.amount}}, or {{event.active}}."},valueType:{type:"string",enum:["text","number","boolean"]}},required:["name","value"]}}},additionalProperties:!0},KW={senderProfileId:{type:"string",description:"Sender profile for this step's From identity. Mutually exclusive with fromEmail."},fromEmail:{type:"string",description:"From address for this step. Its domain must be configured and verified. Mutually exclusive with senderProfileId."},fromName:{type:"string",description:"Display name override for this step. Alone it only changes the visible name; with fromEmail it also names a newly created sender profile."},replyProfileId:{type:"string",description:"Reply profile for this step's Reply-To. Mutually exclusive with replyTo."},replyTo:{type:"string",description:"Reply-To address for this step. Mutually exclusive with replyProfileId."},replyToName:{type:"string",description:"Display name for a newly created reply profile. Requires replyTo."}},g$={type:"object",description:"A step to create inside a sequence path. Use type:'delay' for a standalone delay, type:'email' for an email, type:'create_discount' for a discount action, or type:'condition' for a condition gate.",properties:{type:{type:"string",enum:["email","delay","create_discount","discount","update_subscriber","condition","webhook"],description:"Sequence path step type. Omit for email steps; use delay for standalone waits or update_subscriber for action_update_attributes."},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","logic_condition","action_webhook"],description:"Advanced sequence path node type. Prefer type unless creating a non-email action."},config:{...Y0,description:"Config for advanced nodeType steps. For action_update_attributes, use the documented Update Subscriber fields and trigger-event merge tags; other node types accept their normal config fields.",additionalProperties:!0},subject:{type:"string",description:"Email subject. Required for email steps."},previewText:{type:"string",description:"Email preview text."},blocks:{type:"array",description:W1,items:{type:"object"}},html:{type:"string",description:"HTML content for email steps. Stored as one raw HTML block. Use this for imported provider HTML."},delay:G1,delayMs:{type:"number",description:"Delay in milliseconds. Useful for standalone type:'delay' steps."},waitUntil:Q1,name:{type:"string",description:"Email template name for email steps."},senderProfileId:{type:"string",description:"Sender profile for this email step. Omit to inherit the effective identity of the nearest sequence email. After a branch merge, only fields shared by every incoming path are inherited; conflicting fields use sequence or company defaults."},fromEmail:{type:"string",description:"From address for this email step. Its domain must be verified. Mutually exclusive with senderProfileId."},fromName:{type:"string",description:"Display name override for this email step. With fromEmail, also names a newly created sender profile."},replyProfileId:{type:"string",description:"Reply profile for this email step. Omit to inherit the effective Reply-To of the nearest sequence email. After a branch merge, only fields shared by every incoming path are inherited; conflicting fields use sequence or company defaults."},replyTo:{type:"string",description:"Reply-To address for this email step. Mutually exclusive with replyProfileId."},replyToName:{type:"string",description:"Display name for a newly created reply profile. Requires replyTo."},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"],description:"Discount provider. Use stripe to dynamically create a Stripe coupon plus promotion code, or shopify to dynamically create a Shopify Admin discount code."},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 CD(b){if(!b||typeof b!=="object")return null;let w=b;if(w.success!==!1)return null;if(typeof w.error==="string")return Error(w.error);if(w.error&&typeof w.error==="object"&&typeof w.error.message==="string")return Error(w.error.message);if(typeof w.message==="string")return Error(w.message);return Error("The tool returned an unsuccessful response.")}function PW(b){return b.trim().toLowerCase().replace(/\s+/g,"-")}function cP(b){let w=new URLSearchParams;if(typeof b.query==="string"&&b.query.trim()!=="")w.set("query",b.query.trim());if(Array.isArray(b.tags)&&b.tags.length>0)w.set("tags",b.tags.filter(($)=>typeof $==="string"&&$.trim()!=="").join(","));if(typeof b.list==="string"&&b.list.trim()!=="")w.set("list",b.list.trim());if(typeof b.listId==="string"&&b.listId.trim()!=="")w.set("listId",b.listId.trim());if(typeof b.listName==="string"&&b.listName.trim()!=="")w.set("listName",b.listName.trim());if(typeof b.segmentId==="string"&&b.segmentId.trim()!=="")w.set("segmentId",b.segmentId);if(typeof b.status==="string"&&b.status.trim()!=="")w.set("status",b.status.trim());return w.set("page",String(b.page)),w.set("limit",String(b.pageSize)),w}async function uD(b,w){let $=typeof b.limit==="number"&&Number.isFinite(b.limit)?Math.max(1,Math.trunc(b.limit)):void 0,W=Math.min(100,Math.max(1,$??100)),Q=[],G=1,X=0,Y=0,H=0;while(!0){let D=cP({query:b.query,tags:b.tags,list:b.list,listId:b.listId,listName:b.listName,segmentId:b.segmentId,status:b.status,page:G,pageSize:W}),z=await A("GET",`/api/v1/subscribers?${D.toString()}`,void 0,w);X=z.pagination?.total??z.subscribers.length,Y=z.pagination?.totalPages??1,H+=1,Q.push(...z.subscribers??[]);let O=$!==void 0&&Q.length>=$,q=z.pagination?G>=z.pagination.totalPages:(z.subscribers??[]).length<W;if(O||q)break;G+=1}let J=$!==void 0?Q.slice(0,$):Q;return{success:!0,subscribers:J,pagination:{page:1,limit:W,total:X,totalPages:Y,fetchedPages:H},returned:J.length,truncated:$!==void 0&&X>0&&J.length<X}}function gP(b){let w=typeof b.email==="string"&&b.email.trim()!==""?b.email.trim():void 0,$=typeof b.externalId==="string"&&b.externalId.trim()!==""?b.externalId.trim():void 0;return{...w?{email:w}:{},...$?{externalId:$}:{}}}function Aw(b,w){let $=gP(w);if(!$.email&&!$.externalId)throw Error(`Provide either \`email\` or \`externalId\` when calling \`${b}\`.`);return $}function m$(b,w){let $=new URLSearchParams;if(w?.includeMachineEngagement)$.set("includeMachineEngagement","true");let W=$.toString(),Q=W?`?${W}`:"";if(b.email)return`/api/v1/subscribers/${encodeURIComponent(b.email)}${Q}`;return $.set("externalId",String(b.externalId)),`/api/v1/subscribers/external?${$.toString()}`}function MW(b){if(b.email)return`/api/v1/subscribers/${encodeURIComponent(b.email)}/notes`;let w=new URLSearchParams;return w.set("externalId",String(b.externalId)),`/api/v1/subscribers/external/notes?${w.toString()}`}async function H0(b,w,$){return A("GET",m$(b,$),void 0,w)}function Vb(b,w,$,W){let Q=F(w,$);if(Q===void 0)return;if(!W.includes(Q))throw Error(`\`${$}\` must be one of ${W.join(", ")} when calling \`${b}\`.`);return Q}function J0(b,w,$,W){let Q=j(b,w,$);if(!W.includes(Q))throw Error(`\`${$}\` must be one of ${W.join(", ")} when calling \`${b}\`.`);return Q}function zw(b,w,$,W,Q){let G=w[$];if(G===void 0)return;if(typeof G!=="number"||!Number.isInteger(G)||G<W||G>Q)throw Error(`\`${$}\` must be an integer between ${W} and ${Q} when calling \`${b}\`.`);return G}function mP(b,w){let $=[],W=Vb(b,w,"eventType",k$);if(W)$.push(W);if(w.eventTypes!==void 0){if(!Array.isArray(w.eventTypes))throw Error(`\`eventTypes\` must be an array when calling \`${b}\`.`);w.eventTypes.forEach((Q,G)=>{if(typeof Q!=="string")throw Error(`\`eventTypes\` item ${G+1} must be a string when calling \`${b}\`.`);let X=Q.trim();if(!k$.includes(X))throw Error(`\`eventTypes\` item ${G+1} must be one of ${k$.join(", ")} when calling \`${b}\`.`);$.push(X)})}return[...new Set($)]}function ZW(b,w){let $=new URLSearchParams,W=mP(b,w);if(W.length>0)$.set("eventTypes",W.join(","));let Q=Vb(b,w,"period",["1h","24h","7d","30d","90d"]);if(Q)$.set("period",Q);let G=F(w,"start");if(G)$.set("start",G);let X=F(w,"end");if(X)$.set("end",X);let Y=zw(b,w,"page",1,1e6);if(Y!==void 0)$.set("page",String(Y));let H=zw(b,w,"limit",1,500);if(H!==void 0)$.set("limit",String(H));if(w.includeMachineEngagement===!0)$.set("includeMachineEngagement","true");return $}function jW(b,w){if(w.events===void 0)return;if(!Array.isArray(w.events))throw Error(`\`events\` must be an array when calling \`${b}\`.`);let $=w.events.map((W,Q)=>{if(typeof W!=="string"||!Y1.includes(W))throw Error(`\`events\` item ${Q+1} must be one of ${Y1.join(", ")} when calling \`${b}\`.`);return W});if($.length===0)throw Error(`\`events\` must include at least one event type when calling \`${b}\`.`);return $}function IW(b,w){if(!Array.isArray(w.emails))throw Error(`\`emails\` must be an array when calling \`${b}\`.`);let $=[];if(w.emails.forEach((W,Q)=>{if(typeof W!=="string")throw Error(`\`emails\` item ${Q+1} must be a string when calling \`${b}\`.`);let G=W.trim();if(G.length>0)$.push(G)}),$.length===0)throw Error(`\`emails\` must include at least one email address when calling \`${b}\`.`);if($.length>JW)throw Error(`\`emails\` must include no more than ${JW} email addresses when calling \`${b}\`. Split larger batches into multiple calls.`);return $}function xD(b,w,$,W){let Q=w[$];if(Q===void 0)return;if(!Array.isArray(Q))throw Error(`\`${$}\` must be an array when calling \`${b}\`.`);let G=[];if(Q.forEach((X,Y)=>{if(typeof X!=="string")throw Error(`\`${$}\` item ${Y+1} must be a string when calling \`${b}\`.`);let H=X.trim();if(H.length>0)G.push(H)}),G.length===0)throw Error(`\`${$}\` must include at least one ${W} when calling \`${b}\`.`);return G}function yD(b){let $=xD("enroll_subscribers_in_sequence",b,"emails","email address"),W=xD("enroll_subscribers_in_sequence",b,"subscriberIds","subscriber ID"),Q=($?.length??0)+(W?.length??0);if(Q===0)throw Error("Provide `emails` or `subscriberIds` when calling `enroll_subscribers_in_sequence`.");if(Q>DW)throw Error(`\`emails\` and \`subscriberIds\` must include no more than ${DW} total targets when calling \`enroll_subscribers_in_sequence\`. Split larger batches into multiple calls.`);let G=F(b,"targetNodeId");return{...$!==void 0&&{emails:$},...W!==void 0&&{subscriberIds:W},...G!==void 0&&{targetNodeId:G}}}import{readFileSync as nP,statSync as lP}from"node:fs";import{basename as iP}from"node:path";var pP={pdf:"application/pdf",epub:"application/epub+zip",zip:"application/zip",png:"image/png",jpg:"image/jpeg",jpeg:"image/jpeg",gif:"image/gif",webp:"image/webp",mp3:"audio/mpeg",wav:"audio/wav",mp4:"video/mp4",txt:"text/plain",csv:"text/csv"};function oP(b){let w=b.split(".").pop()?.toLowerCase()??"";return pP[w]??null}var dP=104857600;async function hD(b,w){if(!z0())throw Error("`filePath` is only supported when the MCP server runs locally on your machine. Host the file somewhere public and pass `url` instead.");let $=oP(b);if(!$)throw Error("Unsupported file type. Use PDF, ePub, ZIP, image, audio, video, or text files.");let W=lP(b).size;if(W>dP)throw Error(`File is too large (${Math.round(W/1048576)}MB). Delivery files must be 100MB or smaller.`);let Q=nP(b),G=await A("POST","/api/v1/products/delivery/upload-url",{filename:iP(b),contentType:$,fileSizeBytes:W},w),X=await fetch(G.uploadUrl,{method:"PUT",headers:{"Content-Type":$},body:Q});if(!X.ok)throw Error(`File upload failed (${X.status})`);return{url:G.publicUrl,fileName:G.fileName,fileSizeBytes:W,mimeType:$}}async function n$(b){let w=F(b,"companyId");if(w)return w;let $=Tw();if($)return $;try{return(await A("GET","/api/v1/account")).currentCompanyId??void 0}catch{return}}async function fD(b,w){let $=await n$(w);if(!$)throw Error(`A company is required when calling \`${b}\`. Call \`get_account\`, then \`select_company\`, or pass \`companyId\` explicitly.`);return $}function J1(b,w){if(!y(b)||!w)return b;return{...b,url:w}}function cD(b,w){if(!y(b))return b;return{...b,...w.campaign!==void 0&&{url:w.campaign},...w.campaignPreview!==void 0&&{previewUrl:w.campaignPreview}}}function D0(b,w,$){if(!Array.isArray(b)||!w)return b;return b.map((W)=>{if(!y(W))return W;let Q=F(W,"id");if(!Q)return W;let G=Hw({companyId:w,...$==="campaign"&&{campaignId:Q},...$==="landingPage"&&{landingPageId:Q},...$==="sequence"&&{sequenceId:Q},...$==="template"&&{emailId:Q},...$==="transactional"&&{transactionalId:Q}});if($==="campaign")return cD(W,G.urls);let X=$==="sequence"?G.urls.sequence:$==="landingPage"?G.urls.landingPage:$==="template"?G.urls.email:G.urls.transactionalEmail;return J1(W,X)})}function tP(b){if(!Array.isArray(b))return b;return b.map((w)=>{if(!y(w))return w;let $=F(w,"id");if(!$)return w;let W=Hw({companyId:$});return{...w,url:W.urls.dashboard,settingsUrl:W.urls.settings}})}var VW=new Set(["get_account","select_company","create_company","get_company","update_company","list_campaigns","get_campaign","get_email_send","create_campaign","update_campaign","schedule_campaign","send_test_email","cancel_campaign","pause_campaign","resume_campaign","duplicate_campaign","resend_campaign_to_non_openers","list_landing_pages","get_landing_page","create_landing_page","update_landing_page","publish_landing_page","unpublish_landing_page","delete_landing_page","list_sequences","get_sequence","create_sequence","update_sequence","update_sequence_node","update_sequence_nodes","edit_sequence_graph","insert_sequence_step","enable_sequence","disable_sequence","pause_sequence_enrollments","resume_sequence_enrollments","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","set_template_localization","sync_template_localizations","list_transactional_emails","get_transactional_email","create_transactional_email","update_transactional_email"]);async function gD(b,w,$){if(!y($)||!VW.has(b))return $;let W=y($.company)?$.company:void 0,G=F($,"selectedCompanyId")??F($,"currentCompanyId")??F($,"companyId")??(W?F(W,"id"):void 0)??(W?F(W,"companyId"):void 0)??await n$(w);if(!G)return $;let X=y($.campaign)?$.campaign:void 0,Y=y($.sequence)?$.sequence:void 0,H=y($.landingPage)?$.landingPage:void 0,J=y($.template)?$.template:void 0,D=y($.transactional)&&!Array.isArray($.transactional)?$.transactional:void 0,z={companyId:G,campaignId:F(w,"campaignId")??F($,"campaignId")??(X?F(X,"id"):void 0),landingPageId:F(w,"landingPageId")??F($,"landingPageId")??(H?F(H,"id"):void 0),sequenceId:F(w,"sequenceId")??F($,"sequenceId")??(Y?F(Y,"id"):void 0),emailId:F($,"templateId")??(J?F(J,"id"):void 0)??(D?F(D,"emailId"):void 0)??F(w,"templateId"),transactionalId:F(w,"transactionalId")??(D?F(D,"id"):void 0)??F(w,"idOrSlug"),emailSendId:F(w,"emailSendId")??F($,"emailSendId")??(y($.emailSend)?F($.emailSend,"id"):void 0),status:F(w,"status")},O=Hw(z),q=W?Hw({companyId:G}):void 0;return{...$,...Array.isArray($.companies)&&{companies:tP($.companies)},...Array.isArray($.campaigns)&&{campaigns:D0($.campaigns,G,"campaign")},...Array.isArray($.landingPages)&&{landingPages:D0($.landingPages,G,"landingPage")},...Array.isArray($.sequences)&&{sequences:D0($.sequences,G,"sequence")},...Array.isArray($.templates)&&{templates:D0($.templates,G,"template")},...Array.isArray($.transactional)&&{transactional:D0($.transactional,G,"transactional")},...W&&q!==void 0&&{company:{...W,url:q.urls.dashboard,settingsUrl:q.urls.settings}},...X&&O.urls.campaign!==void 0&&{campaign:cD(X,O.urls)},...Y&&O.urls.sequence!==void 0&&{sequence:J1(Y,O.urls.sequence)},...H&&O.urls.landingPage!==void 0&&{landingPage:J1(H,O.urls.landingPage)},...J&&O.urls.email!==void 0&&{template:J1(J,O.urls.email)},...D&&O.urls.transactionalEmail!==void 0&&{transactional:J1(D,O.urls.transactionalEmail)},...y($.emailSend)&&O.urls.emailSend!==void 0&&{emailSend:J1($.emailSend,O.urls.emailSend)},appUrls:O.urls}}import{readFileSync as rP,statSync as eP}from"node:fs";import{basename as sP,extname as nD}from"node:path";var EW=5242880,aP=Math.ceil(EW/3)*4,bM=Math.ceil(aP*1.05)+256,lD={".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".webp":"image/webp"},wM=new Set(Object.values(lD));function NW(b){return b?.split(";")[0]?.trim().toLowerCase()||void 0}function $M(b){return lD[nD(b).toLowerCase()]}function WM(b){let w=nD(b);return(w?b.slice(0,-w.length):b).replace(/[-_]+/g," ").trim()||"Image"}function QM(b){if(b.length>bM)throw Error("Image assets must be 5MB or smaller.")}function GM(b){let w=0,$=0;for(let Q=0;Q<b.length;Q+=1){let G=b.charCodeAt(Q);if(G===9||G===10||G===11||G===12||G===13||G===32)continue;w+=1,$=G===61?$+1:0}if(Math.floor(w*3/4)-Math.min($,2)>EW)throw Error("Image assets must be 5MB or smaller.")}function XM(b){QM(b);let w=b.trim(),$=/^data:([^;,]+);base64,([\s\S]+)$/i.exec(w),W=$?.[2]??w;GM(W);let Q=W.replace(/\s+/g,"");if(Q.length===0||Q.length%4===1||!/^[A-Za-z0-9+/]*={0,2}$/.test(Q))throw Error("`imageBase64` must contain valid base64 image bytes.");return{bytes:Buffer.from(Q,"base64"),...$?.[1]?{dataUrlContentType:NW($[1])}:{}}}function mD(b){if(b<=0)throw Error("The image file is empty.");if(b>EW)throw Error("Image assets must be 5MB or smaller.")}function YM(b){let w=$M(b.filename)??NW(b.explicitContentType)??NW(b.dataUrlContentType);if(!w||!wM.has(w))throw Error("Unsupported image type. Use PNG, JPEG, GIF, or WebP.");return w}function HM(b){let w,$,W;if(b.filePath!==void 0){if(!z0())throw Error("`filePath` is only supported when the MCP server runs locally on your machine. For a remote MCP connection, pass `imageBase64` and `filename` instead.");let G=eP(b.filePath).size;mD(G),w=rP(b.filePath),$=b.filename??sP(b.filePath)}else{if(!b.imageBase64)throw Error("Provide either `filePath` or `imageBase64` when uploading an image asset.");if(!b.filename)throw Error("`filename` is required with `imageBase64` when uploading an image asset.");let G=XM(b.imageBase64);w=G.bytes,W=G.dataUrlContentType,$=b.filename,mD(w.byteLength)}let Q=YM({filename:$,explicitContentType:b.contentType,dataUrlContentType:W});return{bytes:w,filename:$,contentType:Q,altText:b.altText??WM($)}}async function iD(b){let w=HM(b),$=w.bytes.byteLength,W=await A("POST","/api/v1/media/upload-url",{filename:w.filename,contentType:w.contentType,fileSizeBytes:$},b.companyId);return await fW(W.uploadUrl,w.bytes,w.contentType,b.companyId),(await A("POST","/api/v1/media/complete-upload",{key:W.key,filename:W.fileName,contentType:w.contentType,fileSizeBytes:$,...b.sourceWidth!==void 0&&{width:b.sourceWidth},...b.sourceHeight!==void 0&&{height:b.sourceHeight},altText:w.altText},b.companyId)).asset}var JM={type:"boolean",description:"Whether the Sequenzy operation succeeded."},DM={type:"string",description:"Human-readable status, confirmation, or next-step message."},zM={type:"string",description:"Additional context about the result."};function t(b){return{type:"object",description:b,additionalProperties:!0}}function AM(b){return{type:"array",description:b,items:t("One item in the returned collection.")}}function T(b){return{type:"string",description:b}}function Kb(b){return{type:"number",description:b}}function eb(b){return{type:"boolean",description:b}}function P(b){return t(`The ${b} record returned by Sequenzy.`)}function i(b){return AM(`List of ${b} records returned by Sequenzy.`)}var OM={appUrls:t("Dashboard URLs for relevant Sequenzy resources."),url:T("Primary dashboard URL for this result."),settingsUrl:T("Company settings URL when available.")},qM={success:JM,message:DM,note:zM,items:{type:"array",description:"Fallback array wrapper used only when a tool returns a bare array.",items:t("One returned item.")},value:t("Fallback object wrapper used only when a tool returns a non-object value.")},LM={get_account:{account:P("account"),companies:i("company"),apiKeyPermissions:t("Current API key preset and scopes, whether common marketing work is discoverable, any missing marketing read scopes, and the API Keys management URL."),currentCompanyId:T("Company ID selected by the authenticated API key, when available."),selectedCompanyId:T("Company ID selected locally for subsequent MCP calls, when available.")},select_company:{companyId:T("Selected company ID."),companyName:T("Selected company name.")},get_app_urls:{dashboard:T("Company dashboard URL."),settings:T("Company settings URL."),campaign:T("Campaign editor URL."),landingPage:T("Landing page editor URL."),sequence:T("Sequence editor URL."),email:T("Email editor URL."),transactionalEmail:T("Transactional email URL."),emailSend:T("Sent email detail URL."),domain:T("Sending domain settings URL."),urls:t("All generated URLs keyed by resource type.")},create_company:{company:P("company"),autoSelected:eb("Whether the new company was selected for subsequent MCP calls.")},update_company:{company:P("company")},get_company:{company:P("company")},get_sync_rules:{syncRules:{type:"array",description:"Effective sync rules for the company.",items:t("One sync rule.")},isDefault:eb("Whether the company still uses the platform default rules.")},update_sync_rules:{syncRules:{type:"array",description:"Effective sync rules after the update.",items:t("One sync rule.")},isDefault:eb("Whether the company now uses the platform default rules.")},get_shopify_automation_settings:{browseAbandonment:t("Effective browse-abandonment settings (defaults applied)."),priceDrop:t("Effective price-drop settings (defaults applied)."),shopDomain:T("Connected Shopify store domain.")},update_shopify_automation_settings:{browseAbandonment:t("Effective browse-abandonment settings after the update."),priceDrop:t("Effective price-drop settings after the update."),shopDomain:T("Connected Shopify store domain.")},create_api_key:{apiKey:t("Created API key metadata: the newly created secret in `key`, plus `scopes` listing the assigned permission scopes (null when the key has full access)."),key:T("Newly created API key if the API response uses the short key field.")},list_websites:{websites:i("sender website")},add_website:{website:P("Sending domain with the SPF, DKIM, MAIL FROM, and inbound DNS records required for setup.")},add_sending_domain:{website:P("Sending domain with the SPF, DKIM, MAIL FROM, and inbound DNS records required for setup.")},check_website:{website:P("sender website"),ready:eb("Whether the sender website is ready."),status:T("Current processing or verification status.")},verify_sending_domain:{website:P("Sending domain with current aggregate, SPF, DKIM, and MAIL FROM verification details."),verified:eb("Whether the sending domain passed the fresh verification check."),message:T("Verification result summary.")},get_integration_guide:{guide:P("integration guide"),code:T("Generated integration code or example."),steps:{type:"array",description:"Setup steps for the requested integration.",items:t("One setup step.")}},add_subscriber:{subscriber:P("subscriber")},update_subscriber:{subscriber:P("subscriber")},remove_subscriber:{subscriber:P("subscriber"),hardDeleted:eb("Whether the subscriber was permanently deleted.")},get_subscriber:{subscriber:P("subscriber")},list_subscriber_notes:{notes:i("subscriber note")},add_subscriber_note:{note:P("subscriber note")},delete_subscriber_note:{id:T("Deleted subscriber note ID."),deleted:eb("Whether the subscriber note was deleted.")},search_subscribers:{subscribers:i("subscriber"),pagination:t("Pagination metadata."),returned:Kb("Number of subscribers returned."),truncated:eb("Whether the result was truncated by the requested limit.")},list_products:{products:i("product")},upsert_products:{products:i("product"),created:Kb("Number of products created."),updated:Kb("Number of products updated.")},delete_product:{productId:T("Deleted product ID.")},attach_product_file:{product:P("product"),delivery:P("digital delivery file")},remove_product_file:{product:P("product")},upload_image_asset:{asset:P("hosted image asset"),imageBlock:t("Ready-to-insert Sequenzy image block using the hosted asset URL.")},sync_products:{job:P("product sync job"),jobId:T("Queued product sync job ID.")},list_tags:{tags:i("tag")},create_tag:{tag:P("tag")},update_tag:{tag:P("tag")},delete_tag:{tagId:T("Deleted tag ID.")},list_lists:{lists:i("list")},create_list:{list:P("list")},update_list:{list:P("list")},delete_list:{listId:T("Deleted list ID.")},add_subscribers_to_list:{list:P("list"),added:Kb("Number of subscribers added to the list."),skipped:Kb("Number of subscribers skipped.")},remove_subscribers_from_list:{list:P("list"),removed:Kb("Number of subscribers removed from the list."),skipped:Kb("Number of subscribers skipped.")},list_segments:{segments:i("segment")},create_segment:{segment:P("segment")},update_segment:{segment:P("segment")},delete_segment:{segmentId:T("Deleted segment ID.")},get_segment_count:{count:Kb("Number of subscribers matching the segment."),segmentId:T("Segment ID that was counted.")},list_audience_syncs:{audienceSyncs:i("audience sync")},list_ad_accounts:{adAccounts:i("ad account")},create_audience_sync:{audienceSync:P("audience sync")},update_audience_sync:{audienceSync:P("audience sync")},delete_audience_sync:{audienceSyncId:T("Deleted audience sync ID.")},sync_audience_now:{audienceSync:P("audience sync"),job:P("audience sync job"),jobId:T("Queued audience sync job ID.")},list_templates:{templates:i("email template")},get_template:{template:P("email template")},create_template:{template:P("email template")},update_template:{template:P("email template")},set_template_localization:{templateId:T("Localized template ID."),localization:P("template localization")},sync_template_localizations:{templateId:T("Template ID queued for localization."),queuedLocales:{type:"array",description:"Locale codes queued for AI translation.",items:T("One queued locale code.")},queuedVariantCount:Kb("Number of localized variants queued for translation.")},delete_template:{templateId:T("Deleted template ID.")},list_ab_tests:{abTests:i("A/B test")},get_ab_test:{abTest:P("A/B test")},get_ab_test_stats:{abTest:P("A/B test"),stats:P("A/B test statistics")},restart_ab_test:{abTest:P("A/B test")},update_ab_test_variant:{abTest:P("A/B test"),variant:P("A/B test variant")},create_ab_test:{abTest:P("A/B test")},add_ab_test_variant:{abTest:P("A/B test"),variant:P("A/B test variant")},delete_ab_test_variant:{abTest:P("A/B test"),variantId:T("Deleted A/B test variant ID.")},delete_ab_test:{abTestId:T("Deleted A/B test ID.")},list_campaigns:{campaigns:i("campaign")},get_campaign:{campaign:P("campaign")},get_email_send:{emailSend:P("email send")},create_campaign:{campaign:P("campaign")},update_campaign:{campaign:P("campaign")},schedule_campaign:{campaign:P("campaign"),scheduledAt:T("Scheduled send timestamp.")},send_test_email:{emailSend:P("test email send"),recipient:T("Test email recipient.")},send_test_sms:{smsSendId:T("Created test SMS send ID."),toPhone:T("Normalized E.164 destination phone.")},cancel_campaign:{campaign:P("campaign")},pause_campaign:{campaign:P("campaign")},resume_campaign:{campaign:P("campaign")},delete_campaign:{campaignId:T("Deleted campaign ID.")},duplicate_campaign:{campaign:P("duplicated campaign")},resend_campaign_to_non_openers:{campaign:P("non-opener resend draft campaign"),estimatedNonOpenerCount:Kb("Estimated number of subscribers who haven't opened the original campaign.")},list_landing_pages:{landingPages:i("landing page")},get_landing_page:{landingPage:P("landing page")},create_landing_page:{landingPage:P("landing page")},update_landing_page:{landingPage:P("landing page")},delete_landing_page:{landingPageId:T("Deleted landing page ID.")},publish_landing_page:{landingPage:P("landing page")},unpublish_landing_page:{landingPage:P("landing page")},connect_landing_page_domain:{landingPage:P("landing page"),domain:T("Connected landing page domain.")},update_landing_page_domain_settings:{landingPage:P("landing page"),domain:T("Landing page domain.")},list_sequences:{sequences:i("sequence")},get_sequence:{sequence:P("sequence")},create_sequence:{sequence:P("sequence"),eventTrackingCode:T("Ready-to-adapt code for sending a custom trigger event, including any matching-field property."),eventTracking:t("Custom-event endpoint, payload contract, example payload, documentation URL, and get_integration_guide arguments."),requiredEvents:{type:"array",description:"Event names the application or an integration must send.",items:T("One required event name.")}},update_sequence:{sequence:P("sequence")},update_sequence_node:{sequence:P("sequence")},update_sequence_nodes:{sequence:P("sequence")},edit_sequence_graph:{sequence:P("sequence")},insert_sequence_step:{sequence:P("sequence"),insertedNodeIds:{type:"array",description:"Node IDs created for the inserted step, including any delay node.",items:T("Inserted automation node ID.")},insertedEmailIds:{type:"array",description:"Email template IDs created for the inserted step.",items:T("Inserted email template ID.")},insertedEmailCount:Kb("Number of email steps inserted.")},enable_sequence:{sequence:P("sequence")},disable_sequence:{sequence:P("sequence")},pause_sequence_enrollments:{sequenceId:T("Sequence ID."),enrollmentPaused:eb("Whether new sequence enrollments are paused.")},resume_sequence_enrollments:{sequenceId:T("Sequence ID."),enrollmentPaused:eb("Whether new sequence enrollments are paused.")},enroll_subscribers_in_sequence:{sequence:P("sequence"),enrollments:i("sequence enrollment"),enrolled:Kb("Number of subscribers enrolled."),skipped:Kb("Number of subscribers skipped.")},cancel_sequence_enrollments:{sequence:P("sequence"),cancelled:Kb("Number of enrollments cancelled."),skipped:Kb("Number of enrollments skipped.")},delete_sequence:{sequenceId:T("Deleted sequence ID.")},list_transactional_emails:{transactional:i("transactional email")},get_transactional_email:{transactional:P("transactional email")},create_transactional_email:{transactional:P("transactional email")},update_transactional_email:{transactional:P("transactional email")},send_email:{emailSend:P("transactional email send"),transactional:P("transactional email")},get_stats:{stats:P("account or company statistics")},get_campaign_stats:{campaign:P("campaign"),stats:P("campaign statistics"),clickedLinks:{type:"array",description:"Per-link click breakdown, most clicked first (top 20). Each entry has url, clicks, and percentage (that link's share of every recorded link click). Present only when the campaign has tracked link clicks.",items:t("One clicked link with url/clicks/share.")},polls:{type:"array",description:`Poll and NPS summaries. Each subscriber counts once per campaign poll block using their latest answer to that block; NPS entries include score, average, and promoter/passive/detractor counts. To list the exact historical respondents behind a count, use the summary blockId and the get_campaign_stats campaignId with create_segment. ${Ew} A summary's attributeKey identifies the subscriber attribute that stores their current/latest response and may be overwritten by a later poll that reuses the key.`,items:t("One poll or NPS results summary.")}},get_sequence_stats:{sequence:P("sequence"),stats:P("sequence statistics")},list_campaign_events:{events:i("campaign email event"),pagination:t("Pagination metadata.")},list_sequence_events:{events:i("sequence email event"),pagination:t("Pagination metadata.")},get_subscriber_activity:{activity:i("subscriber activity event"),subscribers:i("subscriber"),pagination:t("Pagination metadata.")},list_team_members:{members:i("team member"),invitations:i("team invitation")},invite_team_member:{invitation:P("team invitation")},cancel_team_invitation:{invitationId:T("Cancelled invitation ID.")},list_conversations:{conversations:i("inbox conversation"),pagination:t("Pagination metadata.")},get_conversation:{conversation:P("inbox conversation"),messages:i("conversation message")},reply_to_conversation:{conversation:P("inbox conversation"),message:P("conversation message")},update_conversation_status:{conversation:P("inbox conversation")},mark_conversation_read:{conversation:P("inbox conversation")},list_webhooks:{webhooks:i("outbound webhook")},create_webhook:{webhook:P("outbound webhook")},update_webhook:{webhook:P("outbound webhook")},delete_webhook:{webhookId:T("Deleted outbound webhook ID.")},test_webhook:{webhook:P("outbound webhook"),delivery:P("test webhook delivery")},list_webhook_deliveries:{deliveries:i("webhook delivery")},replay_webhook_delivery:{delivery:P("webhook delivery"),job:P("webhook replay job")},generate_email:{email:P("generated email"),html:T("Generated HTML email body."),blocks:{type:"array",description:"Generated Sequenzy email blocks, wrapped with company branding (logo + footer) unless applyBranding was false.",items:t("One generated email block.")},subject:T("Generated subject line."),previewText:T("Generated inbox preview text.")},generate_sequence:{sequence:P("generated sequence"),steps:i("generated sequence step")},generate_subject_lines:{subjectLines:{type:"array",description:"Generated subject line variants.",items:T("One generated subject line.")},variants:i("generated subject line variant")},generate_sms:{prompt:T("The prompt the messages were generated for."),messages:{type:"array",description:"Generated SMS message variants with encoding and segment counts.",items:t("One generated SMS message.")}},get_sms_settings:{sms:t("SMS add-on status: enabled, planEligible, creditsBalance, brandPrefix, numbers, readyToSend (paid plan or credits plus an active number).")},submit_feedback:{}};function UM(b){let w=LM[b];if(w===void 0)throw Error(`MCP tool "${b}" must define outputSchema properties.`);return{type:"object",description:`Structured content returned by the \`${b}\` MCP tool.`,properties:{...qM,...w,...VW.has(b)?OM:{}},additionalProperties:!0}}function pD(b){return{...b,outputSchema:UM(b.name)}}function oD(b){if(y(b))return b;if(Array.isArray(b))return{items:b};return{value:b}}var dD=[{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."},includeMachineEngagement:lb},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:`${Dw} Mutually exclusive with html.`,items:{type:"object"}}},required:["abTestId","variantId"],additionalProperties:!1}},{name:"create_ab_test",description:"Create a campaign A/B test. Control variant A is created automatically from the campaign's current email; optionally provide extra variants. The campaign must be in draft or rejected status, and each campaign can only have one A/B test.",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},campaignId:{type:"string",description:"Draft campaign ID to create the A/B test for."},name:{type:"string",description:"Optional A/B test name."},testPercentage:{type:"number",description:"Percentage of the audience used for the test phase, from 5 to 50. Defaults to 20."},testDurationMinutes:{type:"number",description:"Test phase duration in minutes before the winner is selected, from 15 to 1440. Defaults to 240."},winnerCriteria:{type:"string",enum:["open_rate","click_rate"],description:"Winner selection criteria. Defaults to open_rate."},variants:{type:"array",description:"Optional extra variants to create in addition to control variant A.",items:{type:"object",properties:{subject:{type:"string",description:"Variant subject line."},previewText:{type:"string",description:"Variant preview text."},blocks:{type:"array",description:Dw,items:{type:"object"}}},required:["subject"]}}},required:["campaignId"]}},{name:"add_ab_test_variant",description:"Add a variant to a draft campaign A/B test. Variants cannot be added after the test has started.",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"},subject:{type:"string",description:"Variant subject line."},previewText:{type:"string",description:"Variant preview text."},blocks:{type:"array",description:Dw,items:{type:"object"}}},required:["abTestId","subject"]}},{name:"delete_ab_test_variant",description:"Permanently delete a variant from a draft campaign A/B test. This cannot be undone. Variant A is the control and cannot be deleted, and the test must keep at least the minimum number of variants. Variants cannot be removed after the test has started.",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 to delete."}},required:["abTestId","variantId"]}},{name:"delete_ab_test",description:"Permanently delete a campaign A/B test and all of its variants. This cannot be undone. Running tests (testing or winner_selected) cannot be deleted, and the linked campaign must be in draft or rejected 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 to delete."}},required:["abTestId"]}}];var tD=[{name:"get_account",description:`Get current account information including available companies, the current API key's permission scopes, and the API Keys management URL. Call this after a missing-scope error to inspect access and find the replacement-key settings. IMPORTANT: If you have access to multiple companies, you MUST either:
|
|
29
29
|
1. Call select_company first to choose which company to work with, OR
|
|
30
30
|
2. Pass companyId explicitly in each tool call
|
|
31
31
|
|