@sequenzy/mcp 0.0.54 → 0.0.56
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 +12 -11
- package/dist/server.js +10 -9
- package/package.json +1 -1
- package/server.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
var r5=Object.create;var{getPrototypeOf:d5,defineProperty:ZQ,getOwnPropertyNames:o5}=Object;var t5=Object.prototype.hasOwnProperty;function a5(Q){return this[Q]}var s5,e5,oY=(Q,Y,X)=>{var W=Q!=null&&typeof Q==="object";if(W){var G=Y?s5??=new WeakMap:e5??=new WeakMap,$=G.get(Q);if($)return $}X=Q!=null?r5(d5(Q)):{};let J=Y||!Q||!Q.__esModule?ZQ(X,"default",{value:Q,enumerable:!0}):X;for(let z of o5(Q))if(!t5.call(J,z))ZQ(J,z,{get:a5.bind(Q,z),enumerable:!0});if(W)G.set(Q,J);return J};var w=(Q,Y)=>()=>(Y||Q((Y={exports:{}}).exports,Y),Y.exports);var QH=(Q)=>Q;function YH(Q,Y){this[Q]=QH.bind(null,Y)}var tY=(Q,Y)=>{for(var X in Y)ZQ(Q,X,{get:Y[X],enumerable:!0,configurable:!0,set:YH.bind(Y,X)})};var Z4=w((dG)=>{Object.defineProperty(dG,"__esModule",{value:!0});dG.regexpCode=dG.getEsmExportName=dG.getProperty=dG.safeStringify=dG.stringify=dG.strConcat=dG.addCodeArg=dG.str=dG._=dG.nil=dG._Code=dG.Name=dG.IDENTIFIER=dG._CodeOrName=void 0;class S6{}dG._CodeOrName=S6;dG.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;class x1 extends S6{constructor(Q){super();if(!dG.IDENTIFIER.test(Q))throw Error("CodeGen: name must be a valid identifier");this.str=Q}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}}dG.Name=x1;class R0 extends S6{constructor(Q){super();this._items=typeof Q==="string"?[Q]:Q}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;let Q=this._items[0];return Q===""||Q==='""'}get str(){var Q;return(Q=this._str)!==null&&Q!==void 0?Q:this._str=this._items.reduce((Y,X)=>`${Y}${X}`,"")}get names(){var Q;return(Q=this._names)!==null&&Q!==void 0?Q:this._names=this._items.reduce((Y,X)=>{if(X instanceof x1)Y[X.str]=(Y[X.str]||0)+1;return Y},{})}}dG._Code=R0;dG.nil=new R0("");function nG(Q,...Y){let X=[Q[0]],W=0;while(W<Y.length)S9(X,Y[W]),X.push(Q[++W]);return new R0(X)}dG._=nG;var T9=new R0("+");function rG(Q,...Y){let X=[V4(Q[0])],W=0;while(W<Y.length)X.push(T9),S9(X,Y[W]),X.push(T9,V4(Q[++W]));return jA(X),new R0(X)}dG.str=rG;function S9(Q,Y){if(Y instanceof R0)Q.push(...Y._items);else if(Y instanceof x1)Q.push(Y);else Q.push(EA(Y))}dG.addCodeArg=S9;function jA(Q){let Y=1;while(Y<Q.length-1){if(Q[Y]===T9){let X=PA(Q[Y-1],Q[Y+1]);if(X!==void 0){Q.splice(Y-1,3,X);continue}Q[Y++]="+"}Y++}}function PA(Q,Y){if(Y==='""')return Q;if(Q==='""')return Y;if(typeof Q=="string"){if(Y instanceof x1||Q[Q.length-1]!=='"')return;if(typeof Y!="string")return`${Q.slice(0,-1)}${Y}"`;if(Y[0]==='"')return Q.slice(0,-1)+Y.slice(1);return}if(typeof Y=="string"&&Y[0]==='"'&&!(Q instanceof x1))return`"${Q}${Y.slice(1)}`;return}function IA(Q,Y){return Y.emptyStr()?Q:Q.emptyStr()?Y:rG`${Q}${Y}`}dG.strConcat=IA;function EA(Q){return typeof Q=="number"||typeof Q=="boolean"||Q===null?Q:V4(Array.isArray(Q)?Q.join(","):Q)}function TA(Q){return new R0(V4(Q))}dG.stringify=TA;function V4(Q){return JSON.stringify(Q).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}dG.safeStringify=V4;function SA(Q){return typeof Q=="string"&&dG.IDENTIFIER.test(Q)?new R0(`.${Q}`):nG`[${Q}]`}dG.getProperty=SA;function RA(Q){if(typeof Q=="string"&&dG.IDENTIFIER.test(Q))return new R0(`${Q}`);throw Error(`CodeGen: invalid export name: ${Q}, use explicit $id name mapping`)}dG.getEsmExportName=RA;function CA(Q){return new R0(Q.toString())}dG.regexpCode=CA});var v9=w((sG)=>{Object.defineProperty(sG,"__esModule",{value:!0});sG.ValueScope=sG.ValueScopeName=sG.Scope=sG.varKinds=sG.UsedValueState=void 0;var F0=Z4();class tG extends Error{constructor(Q){super(`CodeGen: "code" for ${Q} not defined`);this.value=Q.value}}var C6;(function(Q){Q[Q.Started=0]="Started",Q[Q.Completed=1]="Completed"})(C6||(sG.UsedValueState=C6={}));sG.varKinds={const:new F0.Name("const"),let:new F0.Name("let"),var:new F0.Name("var")};class C9{constructor({prefixes:Q,parent:Y}={}){this._names={},this._prefixes=Q,this._parent=Y}toName(Q){return Q instanceof F0.Name?Q:this.name(Q)}name(Q){return new F0.Name(this._newName(Q))}_newName(Q){let Y=this._names[Q]||this._nameGroup(Q);return`${Q}${Y.index++}`}_nameGroup(Q){var Y,X;if(((X=(Y=this._parent)===null||Y===void 0?void 0:Y._prefixes)===null||X===void 0?void 0:X.has(Q))||this._prefixes&&!this._prefixes.has(Q))throw Error(`CodeGen: prefix "${Q}" is not allowed in this scope`);return this._names[Q]={prefix:Q,index:0}}}sG.Scope=C9;class k9 extends F0.Name{constructor(Q,Y){super(Y);this.prefix=Q}setValue(Q,{property:Y,itemIndex:X}){this.value=Q,this.scopePath=F0._`.${new F0.Name(Y)}[${X}]`}}sG.ValueScopeName=k9;var pA=F0._`\n`;class aG extends C9{constructor(Q){super(Q);this._values={},this._scope=Q.scope,this.opts={...Q,_n:Q.lines?pA:F0.nil}}get(){return this._scope}name(Q){return new k9(Q,this._newName(Q))}value(Q,Y){var X;if(Y.ref===void 0)throw Error("CodeGen: ref must be passed in value");let W=this.toName(Q),{prefix:G}=W,$=(X=Y.key)!==null&&X!==void 0?X:Y.ref,J=this._values[G];if(J){let U=J.get($);if(U)return U}else J=this._values[G]=new Map;J.set($,W);let z=this._scope[G]||(this._scope[G]=[]),H=z.length;return z[H]=Y.ref,W.setValue(Y,{property:G,itemIndex:H}),W}getValue(Q,Y){let X=this._values[Q];if(!X)return;return X.get(Y)}scopeRefs(Q,Y=this._values){return this._reduceValues(Y,(X)=>{if(X.scopePath===void 0)throw Error(`CodeGen: name "${X}" has no value`);return F0._`${Q}${X.scopePath}`})}scopeCode(Q=this._values,Y,X){return this._reduceValues(Q,(W)=>{if(W.value===void 0)throw Error(`CodeGen: name "${W}" has no value`);return W.value.code},Y,X)}_reduceValues(Q,Y,X={},W){let G=F0.nil;for(let $ in Q){let J=Q[$];if(!J)continue;let z=X[$]=X[$]||new Map;J.forEach((H)=>{if(z.has(H))return;z.set(H,C6.Started);let U=Y(H);if(U){let A=this.opts.es5?sG.varKinds.var:sG.varKinds.const;G=F0._`${G}${A} ${H} = ${U};${this.opts._n}`}else if(U=W===null||W===void 0?void 0:W(H))G=F0._`${G}${U}${this.opts._n}`;else throw new tG(H);z.set(H,C6.Completed)})}return G}}sG.ValueScope=aG});var v=w((O0)=>{Object.defineProperty(O0,"__esModule",{value:!0});O0.or=O0.and=O0.not=O0.CodeGen=O0.operators=O0.varKinds=O0.ValueScopeName=O0.ValueScope=O0.Scope=O0.Name=O0.regexpCode=O0.stringify=O0.getProperty=O0.nil=O0.strConcat=O0.str=O0._=void 0;var u=Z4(),C0=v9(),H1=Z4();Object.defineProperty(O0,"_",{enumerable:!0,get:function(){return H1._}});Object.defineProperty(O0,"str",{enumerable:!0,get:function(){return H1.str}});Object.defineProperty(O0,"strConcat",{enumerable:!0,get:function(){return H1.strConcat}});Object.defineProperty(O0,"nil",{enumerable:!0,get:function(){return H1.nil}});Object.defineProperty(O0,"getProperty",{enumerable:!0,get:function(){return H1.getProperty}});Object.defineProperty(O0,"stringify",{enumerable:!0,get:function(){return H1.stringify}});Object.defineProperty(O0,"regexpCode",{enumerable:!0,get:function(){return H1.regexpCode}});Object.defineProperty(O0,"Name",{enumerable:!0,get:function(){return H1.Name}});var g6=v9();Object.defineProperty(O0,"Scope",{enumerable:!0,get:function(){return g6.Scope}});Object.defineProperty(O0,"ValueScope",{enumerable:!0,get:function(){return g6.ValueScope}});Object.defineProperty(O0,"ValueScopeName",{enumerable:!0,get:function(){return g6.ValueScopeName}});Object.defineProperty(O0,"varKinds",{enumerable:!0,get:function(){return g6.varKinds}});O0.operators={GT:new u._Code(">"),GTE:new u._Code(">="),LT:new u._Code("<"),LTE:new u._Code("<="),EQ:new u._Code("==="),NEQ:new u._Code("!=="),NOT:new u._Code("!"),OR:new u._Code("||"),AND:new u._Code("&&"),ADD:new u._Code("+")};class U1{optimizeNodes(){return this}optimizeNames(Q,Y){return this}}class Q$ extends U1{constructor(Q,Y,X){super();this.varKind=Q,this.name=Y,this.rhs=X}render({es5:Q,_n:Y}){let X=Q?C0.varKinds.var:this.varKind,W=this.rhs===void 0?"":` = ${this.rhs}`;return`${X} ${this.name}${W};`+Y}optimizeNames(Q,Y){if(!Q[this.name.str])return;if(this.rhs)this.rhs=y1(this.rhs,Q,Y);return this}get names(){return this.rhs instanceof u._CodeOrName?this.rhs.names:{}}}class y9 extends U1{constructor(Q,Y,X){super();this.lhs=Q,this.rhs=Y,this.sideEffects=X}render({_n:Q}){return`${this.lhs} = ${this.rhs};`+Q}optimizeNames(Q,Y){if(this.lhs instanceof u.Name&&!Q[this.lhs.str]&&!this.sideEffects)return;return this.rhs=y1(this.rhs,Q,Y),this}get names(){let Q=this.lhs instanceof u.Name?{}:{...this.lhs.names};return y6(Q,this.rhs)}}class Y$ extends y9{constructor(Q,Y,X,W){super(Q,X,W);this.op=Y}render({_n:Q}){return`${this.lhs} ${this.op}= ${this.rhs};`+Q}}class X$ extends U1{constructor(Q){super();this.label=Q,this.names={}}render({_n:Q}){return`${this.label}:`+Q}}class W$ extends U1{constructor(Q){super();this.label=Q,this.names={}}render({_n:Q}){return`break${this.label?` ${this.label}`:""};`+Q}}class G$ extends U1{constructor(Q){super();this.error=Q}render({_n:Q}){return`throw ${this.error};`+Q}get names(){return this.error.names}}class $$ extends U1{constructor(Q){super();this.code=Q}render({_n:Q}){return`${this.code};`+Q}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames(Q,Y){return this.code=y1(this.code,Q,Y),this}get names(){return this.code instanceof u._CodeOrName?this.code.names:{}}}class u6 extends U1{constructor(Q=[]){super();this.nodes=Q}render(Q){return this.nodes.reduce((Y,X)=>Y+X.render(Q),"")}optimizeNodes(){let{nodes:Q}=this,Y=Q.length;while(Y--){let X=Q[Y].optimizeNodes();if(Array.isArray(X))Q.splice(Y,1,...X);else if(X)Q[Y]=X;else Q.splice(Y,1)}return Q.length>0?this:void 0}optimizeNames(Q,Y){let{nodes:X}=this,W=X.length;while(W--){let G=X[W];if(G.optimizeNames(Q,Y))continue;dA(Q,G.names),X.splice(W,1)}return X.length>0?this:void 0}get names(){return this.nodes.reduce((Q,Y)=>V1(Q,Y.names),{})}}class A1 extends u6{render(Q){return"{"+Q._n+super.render(Q)+"}"+Q._n}}class J$ extends u6{}class N4 extends A1{}N4.kind="else";class n0 extends A1{constructor(Q,Y){super(Y);this.condition=Q}render(Q){let Y=`if(${this.condition})`+super.render(Q);if(this.else)Y+="else "+this.else.render(Q);return Y}optimizeNodes(){super.optimizeNodes();let Q=this.condition;if(Q===!0)return this.nodes;let Y=this.else;if(Y){let X=Y.optimizeNodes();Y=this.else=Array.isArray(X)?new N4(X):X}if(Y){if(Q===!1)return Y instanceof n0?Y:Y.nodes;if(this.nodes.length)return this;return new n0(B$(Q),Y instanceof n0?[Y]:Y.nodes)}if(Q===!1||!this.nodes.length)return;return this}optimizeNames(Q,Y){var X;if(this.else=(X=this.else)===null||X===void 0?void 0:X.optimizeNames(Q,Y),!(super.optimizeNames(Q,Y)||this.else))return;return this.condition=y1(this.condition,Q,Y),this}get names(){let Q=super.names;if(y6(Q,this.condition),this.else)V1(Q,this.else.names);return Q}}n0.kind="if";class _1 extends A1{}_1.kind="for";class z$ extends _1{constructor(Q){super();this.iteration=Q}render(Q){return`for(${this.iteration})`+super.render(Q)}optimizeNames(Q,Y){if(!super.optimizeNames(Q,Y))return;return this.iteration=y1(this.iteration,Q,Y),this}get names(){return V1(super.names,this.iteration.names)}}class H$ extends _1{constructor(Q,Y,X,W){super();this.varKind=Q,this.name=Y,this.from=X,this.to=W}render(Q){let Y=Q.es5?C0.varKinds.var:this.varKind,{name:X,from:W,to:G}=this;return`for(${Y} ${X}=${W}; ${X}<${G}; ${X}++)`+super.render(Q)}get names(){let Q=y6(super.names,this.from);return y6(Q,this.to)}}class x9 extends _1{constructor(Q,Y,X,W){super();this.loop=Q,this.varKind=Y,this.name=X,this.iterable=W}render(Q){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(Q)}optimizeNames(Q,Y){if(!super.optimizeNames(Q,Y))return;return this.iterable=y1(this.iterable,Q,Y),this}get names(){return V1(super.names,this.iterable.names)}}class k6 extends A1{constructor(Q,Y,X){super();this.name=Q,this.args=Y,this.async=X}render(Q){return`${this.async?"async ":""}function ${this.name}(${this.args})`+super.render(Q)}}k6.kind="func";class v6 extends u6{render(Q){return"return "+super.render(Q)}}v6.kind="return";class U$ extends A1{render(Q){let Y="try"+super.render(Q);if(this.catch)Y+=this.catch.render(Q);if(this.finally)Y+=this.finally.render(Q);return Y}optimizeNodes(){var Q,Y;return super.optimizeNodes(),(Q=this.catch)===null||Q===void 0||Q.optimizeNodes(),(Y=this.finally)===null||Y===void 0||Y.optimizeNodes(),this}optimizeNames(Q,Y){var X,W;return super.optimizeNames(Q,Y),(X=this.catch)===null||X===void 0||X.optimizeNames(Q,Y),(W=this.finally)===null||W===void 0||W.optimizeNames(Q,Y),this}get names(){let Q=super.names;if(this.catch)V1(Q,this.catch.names);if(this.finally)V1(Q,this.finally.names);return Q}}class x6 extends A1{constructor(Q){super();this.error=Q}render(Q){return`catch(${this.error})`+super.render(Q)}}x6.kind="catch";class _6 extends A1{render(Q){return"finally"+super.render(Q)}}_6.kind="finally";class A${constructor(Q,Y={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...Y,_n:Y.lines?`
|
|
3
|
-
`:""},this._extScope=Q,this._scope=new C0.Scope({parent:Q}),this._nodes=[new J$]}toString(){return this._root.render(this.opts)}name(Q){return this._scope.name(Q)}scopeName(Q){return this._extScope.name(Q)}scopeValue(Q,Y){let X=this._extScope.value(Q,Y);return(this._values[X.prefix]||(this._values[X.prefix]=new Set)).add(X),X}getScopeValue(Q,Y){return this._extScope.getValue(Q,Y)}scopeRefs(Q){return this._extScope.scopeRefs(Q,this._values)}scopeCode(){return this._extScope.scopeCode(this._values)}_def(Q,Y,X,W){let G=this._scope.toName(Y);if(X!==void 0&&W)this._constants[G.str]=X;return this._leafNode(new Q$(Q,G,X)),G}const(Q,Y,X){return this._def(C0.varKinds.const,Q,Y,X)}let(Q,Y,X){return this._def(C0.varKinds.let,Q,Y,X)}var(Q,Y,X){return this._def(C0.varKinds.var,Q,Y,X)}assign(Q,Y,X){return this._leafNode(new y9(Q,Y,X))}add(Q,Y){return this._leafNode(new Y$(Q,O0.operators.ADD,Y))}code(Q){if(typeof Q=="function")Q();else if(Q!==u.nil)this._leafNode(new $$(Q));return this}object(...Q){let Y=["{"];for(let[X,W]of Q){if(Y.length>1)Y.push(",");if(Y.push(X),X!==W||this.opts.es5)Y.push(":"),(0,u.addCodeArg)(Y,W)}return Y.push("}"),new u._Code(Y)}if(Q,Y,X){if(this._blockNode(new n0(Q)),Y&&X)this.code(Y).else().code(X).endIf();else if(Y)this.code(Y).endIf();else if(X)throw Error('CodeGen: "else" body without "then" body');return this}elseIf(Q){return this._elseNode(new n0(Q))}else(){return this._elseNode(new N4)}endIf(){return this._endBlockNode(n0,N4)}_for(Q,Y){if(this._blockNode(Q),Y)this.code(Y).endFor();return this}for(Q,Y){return this._for(new z$(Q),Y)}forRange(Q,Y,X,W,G=this.opts.es5?C0.varKinds.var:C0.varKinds.let){let $=this._scope.toName(Q);return this._for(new H$(G,$,Y,X),()=>W($))}forOf(Q,Y,X,W=C0.varKinds.const){let G=this._scope.toName(Q);if(this.opts.es5){let $=Y instanceof u.Name?Y:this.var("_arr",Y);return this.forRange("_i",0,u._`${$}.length`,(J)=>{this.var(G,u._`${$}[${J}]`),X(G)})}return this._for(new x9("of",W,G,Y),()=>X(G))}forIn(Q,Y,X,W=this.opts.es5?C0.varKinds.var:C0.varKinds.const){if(this.opts.ownProperties)return this.forOf(Q,u._`Object.keys(${Y})`,X);let G=this._scope.toName(Q);return this._for(new x9("in",W,G,Y),()=>X(G))}endFor(){return this._endBlockNode(_1)}label(Q){return this._leafNode(new X$(Q))}break(Q){return this._leafNode(new W$(Q))}return(Q){let Y=new v6;if(this._blockNode(Y),this.code(Q),Y.nodes.length!==1)throw Error('CodeGen: "return" should have one node');return this._endBlockNode(v6)}try(Q,Y,X){if(!Y&&!X)throw Error('CodeGen: "try" without "catch" and "finally"');let W=new U$;if(this._blockNode(W),this.code(Q),Y){let G=this.name("e");this._currNode=W.catch=new x6(G),Y(G)}if(X)this._currNode=W.finally=new _6,this.code(X);return this._endBlockNode(x6,_6)}throw(Q){return this._leafNode(new G$(Q))}block(Q,Y){if(this._blockStarts.push(this._nodes.length),Q)this.code(Q).endBlock(Y);return this}endBlock(Q){let Y=this._blockStarts.pop();if(Y===void 0)throw Error("CodeGen: not in self-balancing block");let X=this._nodes.length-Y;if(X<0||Q!==void 0&&X!==Q)throw Error(`CodeGen: wrong number of nodes: ${X} vs ${Q} expected`);return this._nodes.length=Y,this}func(Q,Y=u.nil,X,W){if(this._blockNode(new k6(Q,Y,X)),W)this.code(W).endFunc();return this}endFunc(){return this._endBlockNode(k6)}optimize(Q=1){while(Q-- >0)this._root.optimizeNodes(),this._root.optimizeNames(this._root.names,this._constants)}_leafNode(Q){return this._currNode.nodes.push(Q),this}_blockNode(Q){this._currNode.nodes.push(Q),this._nodes.push(Q)}_endBlockNode(Q,Y){let X=this._currNode;if(X instanceof Q||Y&&X instanceof Y)return this._nodes.pop(),this;throw Error(`CodeGen: not in block "${Y?`${Q.kind}/${Y.kind}`:Q.kind}"`)}_elseNode(Q){let Y=this._currNode;if(!(Y instanceof n0))throw Error('CodeGen: "else" without "if"');return this._currNode=Y.else=Q,this}get _root(){return this._nodes[0]}get _currNode(){let Q=this._nodes;return Q[Q.length-1]}set _currNode(Q){let Y=this._nodes;Y[Y.length-1]=Q}}O0.CodeGen=A$;function V1(Q,Y){for(let X in Y)Q[X]=(Q[X]||0)+(Y[X]||0);return Q}function y6(Q,Y){return Y instanceof u._CodeOrName?V1(Q,Y.names):Q}function y1(Q,Y,X){if(Q instanceof u.Name)return W(Q);if(!G(Q))return Q;return new u._Code(Q._items.reduce(($,J)=>{if(J instanceof u.Name)J=W(J);if(J instanceof u._Code)$.push(...J._items);else $.push(J);return $},[]));function W($){let J=X[$.str];if(J===void 0||Y[$.str]!==1)return $;return delete Y[$.str],J}function G($){return $ instanceof u._Code&&$._items.some((J)=>J instanceof u.Name&&Y[J.str]===1&&X[J.str]!==void 0)}}function dA(Q,Y){for(let X in Y)Q[X]=(Q[X]||0)-(Y[X]||0)}function B$(Q){return typeof Q=="boolean"||typeof Q=="number"||Q===null?!Q:u._`!${_9(Q)}`}O0.not=B$;var oA=K$(O0.operators.AND);function tA(...Q){return Q.reduce(oA)}O0.and=tA;var aA=K$(O0.operators.OR);function sA(...Q){return Q.reduce(aA)}O0.or=sA;function K$(Q){return(Y,X)=>Y===u.nil?X:X===u.nil?Y:u._`${_9(Y)} ${Q} ${_9(X)}`}function _9(Q){return Q instanceof u.Name?Q:u._`(${Q})`}});var l=w((N$)=>{Object.defineProperty(N$,"__esModule",{value:!0});N$.checkStrictMode=N$.getErrorPath=N$.Type=N$.useFunc=N$.setEvaluated=N$.evaluatedPropsToName=N$.mergeEvaluated=N$.eachItem=N$.unescapeJsonPointer=N$.escapeJsonPointer=N$.escapeFragment=N$.unescapeFragment=N$.schemaRefOrVal=N$.schemaHasRulesButRef=N$.schemaHasRules=N$.checkUnknownRules=N$.alwaysValidSchema=N$.toHash=void 0;var p=v(),XB=Z4();function WB(Q){let Y={};for(let X of Q)Y[X]=!0;return Y}N$.toHash=WB;function GB(Q,Y){if(typeof Y=="boolean")return Y;if(Object.keys(Y).length===0)return!0;return F$(Q,Y),!O$(Y,Q.self.RULES.all)}N$.alwaysValidSchema=GB;function F$(Q,Y=Q.schema){let{opts:X,self:W}=Q;if(!X.strictSchema)return;if(typeof Y==="boolean")return;let G=W.RULES.keywords;for(let $ in Y)if(!G[$])Z$(Q,`unknown keyword: "${$}"`)}N$.checkUnknownRules=F$;function O$(Q,Y){if(typeof Q=="boolean")return!Q;for(let X in Q)if(Y[X])return!0;return!1}N$.schemaHasRules=O$;function $B(Q,Y){if(typeof Q=="boolean")return!Q;for(let X in Q)if(X!=="$ref"&&Y.all[X])return!0;return!1}N$.schemaHasRulesButRef=$B;function JB({topSchemaRef:Q,schemaPath:Y},X,W,G){if(!G){if(typeof X=="number"||typeof X=="boolean")return X;if(typeof X=="string")return p._`${X}`}return p._`${Q}${Y}${(0,p.getProperty)(W)}`}N$.schemaRefOrVal=JB;function zB(Q){return M$(decodeURIComponent(Q))}N$.unescapeFragment=zB;function HB(Q){return encodeURIComponent(u9(Q))}N$.escapeFragment=HB;function u9(Q){if(typeof Q=="number")return`${Q}`;return Q.replace(/~/g,"~0").replace(/\//g,"~1")}N$.escapeJsonPointer=u9;function M$(Q){return Q.replace(/~1/g,"/").replace(/~0/g,"~")}N$.unescapeJsonPointer=M$;function UB(Q,Y){if(Array.isArray(Q))for(let X of Q)Y(X);else Y(Q)}N$.eachItem=UB;function L$({mergeNames:Q,mergeToName:Y,mergeValues:X,resultToName:W}){return(G,$,J,z)=>{let H=J===void 0?$:J instanceof p.Name?($ instanceof p.Name?Q(G,$,J):Y(G,$,J),J):$ instanceof p.Name?(Y(G,J,$),$):X($,J);return z===p.Name&&!(H instanceof p.Name)?W(G,H):H}}N$.mergeEvaluated={props:L$({mergeNames:(Q,Y,X)=>Q.if(p._`${X} !== true && ${Y} !== undefined`,()=>{Q.if(p._`${Y} === true`,()=>Q.assign(X,!0),()=>Q.assign(X,p._`${X} || {}`).code(p._`Object.assign(${X}, ${Y})`))}),mergeToName:(Q,Y,X)=>Q.if(p._`${X} !== true`,()=>{if(Y===!0)Q.assign(X,!0);else Q.assign(X,p._`${X} || {}`),h9(Q,X,Y)}),mergeValues:(Q,Y)=>Q===!0?!0:{...Q,...Y},resultToName:V$}),items:L$({mergeNames:(Q,Y,X)=>Q.if(p._`${X} !== true && ${Y} !== undefined`,()=>Q.assign(X,p._`${Y} === true ? true : ${X} > ${Y} ? ${X} : ${Y}`)),mergeToName:(Q,Y,X)=>Q.if(p._`${X} !== true`,()=>Q.assign(X,Y===!0?!0:p._`${X} > ${Y} ? ${X} : ${Y}`)),mergeValues:(Q,Y)=>Q===!0?!0:Math.max(Q,Y),resultToName:(Q,Y)=>Q.var("items",Y)})};function V$(Q,Y){if(Y===!0)return Q.var("props",!0);let X=Q.var("props",p._`{}`);if(Y!==void 0)h9(Q,X,Y);return X}N$.evaluatedPropsToName=V$;function h9(Q,Y,X){Object.keys(X).forEach((W)=>Q.assign(p._`${Y}${(0,p.getProperty)(W)}`,!0))}N$.setEvaluated=h9;var q$={};function AB(Q,Y){return Q.scopeValue("func",{ref:Y,code:q$[Y.code]||(q$[Y.code]=new XB._Code(Y.code))})}N$.useFunc=AB;var g9;(function(Q){Q[Q.Num=0]="Num",Q[Q.Str=1]="Str"})(g9||(N$.Type=g9={}));function BB(Q,Y,X){if(Q instanceof p.Name){let W=Y===g9.Num;return X?W?p._`"[" + ${Q} + "]"`:p._`"['" + ${Q} + "']"`:W?p._`"/" + ${Q}`:p._`"/" + ${Q}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return X?(0,p.getProperty)(Q).toString():"/"+u9(Q)}N$.getErrorPath=BB;function Z$(Q,Y,X=Q.opts.strictSchema){if(!X)return;if(Y=`strict mode: ${Y}`,X===!0)throw Error(Y);Q.self.logger.warn(Y)}N$.checkStrictMode=Z$});var r0=w((b$)=>{Object.defineProperty(b$,"__esModule",{value:!0});var A0=v(),SB={data:new A0.Name("data"),valCxt:new A0.Name("valCxt"),instancePath:new A0.Name("instancePath"),parentData:new A0.Name("parentData"),parentDataProperty:new A0.Name("parentDataProperty"),rootData:new A0.Name("rootData"),dynamicAnchors:new A0.Name("dynamicAnchors"),vErrors:new A0.Name("vErrors"),errors:new A0.Name("errors"),this:new A0.Name("this"),self:new A0.Name("self"),scope:new A0.Name("scope"),json:new A0.Name("json"),jsonPos:new A0.Name("jsonPos"),jsonLen:new A0.Name("jsonLen"),jsonPart:new A0.Name("jsonPart")};b$.default=SB});var w4=w((E$)=>{Object.defineProperty(E$,"__esModule",{value:!0});E$.extendErrors=E$.resetErrorsCount=E$.reportExtraError=E$.reportError=E$.keyword$DataError=E$.keywordError=void 0;var h=v(),f6=l(),D0=r0();E$.keywordError={message:({keyword:Q})=>h.str`must pass "${Q}" keyword validation`};E$.keyword$DataError={message:({keyword:Q,schemaType:Y})=>Y?h.str`"${Q}" keyword must be ${Y} ($data)`:h.str`"${Q}" keyword is invalid ($data)`};function CB(Q,Y=E$.keywordError,X,W){let{it:G}=Q,{gen:$,compositeRule:J,allErrors:z}=G,H=I$(Q,Y,X);if(W!==null&&W!==void 0?W:J||z)j$($,H);else P$(G,h._`[${H}]`)}E$.reportError=CB;function kB(Q,Y=E$.keywordError,X){let{it:W}=Q,{gen:G,compositeRule:$,allErrors:J}=W,z=I$(Q,Y,X);if(j$(G,z),!($||J))P$(W,D0.default.vErrors)}E$.reportExtraError=kB;function vB(Q,Y){Q.assign(D0.default.errors,Y),Q.if(h._`${D0.default.vErrors} !== null`,()=>Q.if(Y,()=>Q.assign(h._`${D0.default.vErrors}.length`,Y),()=>Q.assign(D0.default.vErrors,null)))}E$.resetErrorsCount=vB;function xB({gen:Q,keyword:Y,schemaValue:X,data:W,errsCount:G,it:$}){if(G===void 0)throw Error("ajv implementation error");let J=Q.name("err");Q.forRange("i",G,D0.default.errors,(z)=>{if(Q.const(J,h._`${D0.default.vErrors}[${z}]`),Q.if(h._`${J}.instancePath === undefined`,()=>Q.assign(h._`${J}.instancePath`,(0,h.strConcat)(D0.default.instancePath,$.errorPath))),Q.assign(h._`${J}.schemaPath`,h.str`${$.errSchemaPath}/${Y}`),$.opts.verbose)Q.assign(h._`${J}.schema`,X),Q.assign(h._`${J}.data`,W)})}E$.extendErrors=xB;function j$(Q,Y){let X=Q.const("err",Y);Q.if(h._`${D0.default.vErrors} === null`,()=>Q.assign(D0.default.vErrors,h._`[${X}]`),h._`${D0.default.vErrors}.push(${X})`),Q.code(h._`${D0.default.errors}++`)}function P$(Q,Y){let{gen:X,validateName:W,schemaEnv:G}=Q;if(G.$async)X.throw(h._`new ${Q.ValidationError}(${Y})`);else X.assign(h._`${W}.errors`,Y),X.return(!1)}var Z1={keyword:new h.Name("keyword"),schemaPath:new h.Name("schemaPath"),params:new h.Name("params"),propertyName:new h.Name("propertyName"),message:new h.Name("message"),schema:new h.Name("schema"),parentSchema:new h.Name("parentSchema")};function I$(Q,Y,X){let{createErrors:W}=Q.it;if(W===!1)return h._`{}`;return _B(Q,Y,X)}function _B(Q,Y,X={}){let{gen:W,it:G}=Q,$=[yB(G,X),gB(Q,X)];return uB(Q,Y,$),W.object(...$)}function yB({errorPath:Q},{instancePath:Y}){let X=Y?h.str`${Q}${(0,f6.getErrorPath)(Y,f6.Type.Str)}`:Q;return[D0.default.instancePath,(0,h.strConcat)(D0.default.instancePath,X)]}function gB({keyword:Q,it:{errSchemaPath:Y}},{schemaPath:X,parentSchema:W}){let G=W?Y:h.str`${Y}/${Q}`;if(X)G=h.str`${G}${(0,f6.getErrorPath)(X,f6.Type.Str)}`;return[Z1.schemaPath,G]}function uB(Q,{params:Y,message:X},W){let{keyword:G,data:$,schemaValue:J,it:z}=Q,{opts:H,propertyName:U,topSchemaRef:A,schemaPath:B}=z;if(W.push([Z1.keyword,G],[Z1.params,typeof Y=="function"?Y(Q):Y||h._`{}`]),H.messages)W.push([Z1.message,typeof X=="function"?X(Q):X]);if(H.verbose)W.push([Z1.schema,J],[Z1.parentSchema,h._`${A}${B}`],[D0.default.data,$]);if(U)W.push([Z1.propertyName,U])}});var k$=w((R$)=>{Object.defineProperty(R$,"__esModule",{value:!0});R$.boolOrEmptySchema=R$.topBoolOrEmptySchema=void 0;var cB=w4(),pB=v(),iB=r0(),nB={message:"boolean schema is false"};function rB(Q){let{gen:Y,schema:X,validateName:W}=Q;if(X===!1)S$(Q,!1);else if(typeof X=="object"&&X.$async===!0)Y.return(iB.default.data);else Y.assign(pB._`${W}.errors`,null),Y.return(!0)}R$.topBoolOrEmptySchema=rB;function dB(Q,Y){let{gen:X,schema:W}=Q;if(W===!1)X.var(Y,!1),S$(Q);else X.var(Y,!0)}R$.boolOrEmptySchema=dB;function S$(Q,Y){let{gen:X,data:W}=Q,G={gen:X,keyword:"false schema",data:W,schema:!1,schemaCode:!1,schemaValue:!1,params:{},it:Q};(0,cB.reportError)(G,nB,void 0,Y)}});var l9=w((v$)=>{Object.defineProperty(v$,"__esModule",{value:!0});v$.getRules=v$.isJSONType=void 0;var tB=["string","number","integer","boolean","null","object","array"],aB=new Set(tB);function sB(Q){return typeof Q=="string"&&aB.has(Q)}v$.isJSONType=sB;function eB(){let Q={number:{type:"number",rules:[]},string:{type:"string",rules:[]},array:{type:"array",rules:[]},object:{type:"object",rules:[]}};return{types:{...Q,integer:!0,boolean:!0,null:!0},rules:[{rules:[]},Q.number,Q.string,Q.array,Q.object],post:{rules:[]},all:{},keywords:{}}}v$.getRules=eB});var m9=w((g$)=>{Object.defineProperty(g$,"__esModule",{value:!0});g$.shouldUseRule=g$.shouldUseGroup=g$.schemaHasRulesForType=void 0;function YK({schema:Q,self:Y},X){let W=Y.RULES.types[X];return W&&W!==!0&&_$(Q,W)}g$.schemaHasRulesForType=YK;function _$(Q,Y){return Y.rules.some((X)=>y$(Q,X))}g$.shouldUseGroup=_$;function y$(Q,Y){var X;return Q[Y.keyword]!==void 0||((X=Y.definition.implements)===null||X===void 0?void 0:X.some((W)=>Q[W]!==void 0))}g$.shouldUseRule=y$});var b4=w((m$)=>{Object.defineProperty(m$,"__esModule",{value:!0});m$.reportTypeError=m$.checkDataTypes=m$.checkDataType=m$.coerceAndCheckDataType=m$.getJSONTypes=m$.getSchemaTypes=m$.DataType=void 0;var GK=l9(),$K=m9(),JK=w4(),C=v(),h$=l(),g1;(function(Q){Q[Q.Correct=0]="Correct",Q[Q.Wrong=1]="Wrong"})(g1||(m$.DataType=g1={}));function zK(Q){let Y=f$(Q.type);if(Y.includes("null")){if(Q.nullable===!1)throw Error("type: null contradicts nullable: false")}else{if(!Y.length&&Q.nullable!==void 0)throw Error('"nullable" cannot be used without "type"');if(Q.nullable===!0)Y.push("null")}return Y}m$.getSchemaTypes=zK;function f$(Q){let Y=Array.isArray(Q)?Q:Q?[Q]:[];if(Y.every(GK.isJSONType))return Y;throw Error("type must be JSONType or JSONType[]: "+Y.join(","))}m$.getJSONTypes=f$;function HK(Q,Y){let{gen:X,data:W,opts:G}=Q,$=UK(Y,G.coerceTypes),J=Y.length>0&&!($.length===0&&Y.length===1&&(0,$K.schemaHasRulesForType)(Q,Y[0]));if(J){let z=p9(Y,W,G.strictNumbers,g1.Wrong);X.if(z,()=>{if($.length)AK(Q,Y,$);else i9(Q)})}return J}m$.coerceAndCheckDataType=HK;var l$=new Set(["string","number","integer","boolean","null"]);function UK(Q,Y){return Y?Q.filter((X)=>l$.has(X)||Y==="array"&&X==="array"):[]}function AK(Q,Y,X){let{gen:W,data:G,opts:$}=Q,J=W.let("dataType",C._`typeof ${G}`),z=W.let("coerced",C._`undefined`);if($.coerceTypes==="array")W.if(C._`${J} == 'object' && Array.isArray(${G}) && ${G}.length == 1`,()=>W.assign(G,C._`${G}[0]`).assign(J,C._`typeof ${G}`).if(p9(Y,G,$.strictNumbers),()=>W.assign(z,G)));W.if(C._`${z} !== undefined`);for(let U of X)if(l$.has(U)||U==="array"&&$.coerceTypes==="array")H(U);W.else(),i9(Q),W.endIf(),W.if(C._`${z} !== undefined`,()=>{W.assign(G,z),BK(Q,z)});function H(U){switch(U){case"string":W.elseIf(C._`${J} == "number" || ${J} == "boolean"`).assign(z,C._`"" + ${G}`).elseIf(C._`${G} === null`).assign(z,C._`""`);return;case"number":W.elseIf(C._`${J} == "boolean" || ${G} === null
|
|
2
|
+
var r5=Object.create;var{getPrototypeOf:d5,defineProperty:ZQ,getOwnPropertyNames:o5}=Object;var t5=Object.prototype.hasOwnProperty;function a5(Q){return this[Q]}var s5,e5,oY=(Q,Y,X)=>{var W=Q!=null&&typeof Q==="object";if(W){var G=Y?s5??=new WeakMap:e5??=new WeakMap,$=G.get(Q);if($)return $}X=Q!=null?r5(d5(Q)):{};let J=Y||!Q||!Q.__esModule?ZQ(X,"default",{value:Q,enumerable:!0}):X;for(let z of o5(Q))if(!t5.call(J,z))ZQ(J,z,{get:a5.bind(Q,z),enumerable:!0});if(W)G.set(Q,J);return J};var w=(Q,Y)=>()=>(Y||Q((Y={exports:{}}).exports,Y),Y.exports);var QH=(Q)=>Q;function YH(Q,Y){this[Q]=QH.bind(null,Y)}var tY=(Q,Y)=>{for(var X in Y)ZQ(Q,X,{get:Y[X],enumerable:!0,configurable:!0,set:YH.bind(Y,X)})};var Z6=w((dG)=>{Object.defineProperty(dG,"__esModule",{value:!0});dG.regexpCode=dG.getEsmExportName=dG.getProperty=dG.safeStringify=dG.stringify=dG.strConcat=dG.addCodeArg=dG.str=dG._=dG.nil=dG._Code=dG.Name=dG.IDENTIFIER=dG._CodeOrName=void 0;class S4{}dG._CodeOrName=S4;dG.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;class x1 extends S4{constructor(Q){super();if(!dG.IDENTIFIER.test(Q))throw Error("CodeGen: name must be a valid identifier");this.str=Q}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}}dG.Name=x1;class R0 extends S4{constructor(Q){super();this._items=typeof Q==="string"?[Q]:Q}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;let Q=this._items[0];return Q===""||Q==='""'}get str(){var Q;return(Q=this._str)!==null&&Q!==void 0?Q:this._str=this._items.reduce((Y,X)=>`${Y}${X}`,"")}get names(){var Q;return(Q=this._names)!==null&&Q!==void 0?Q:this._names=this._items.reduce((Y,X)=>{if(X instanceof x1)Y[X.str]=(Y[X.str]||0)+1;return Y},{})}}dG._Code=R0;dG.nil=new R0("");function nG(Q,...Y){let X=[Q[0]],W=0;while(W<Y.length)S9(X,Y[W]),X.push(Q[++W]);return new R0(X)}dG._=nG;var T9=new R0("+");function rG(Q,...Y){let X=[V6(Q[0])],W=0;while(W<Y.length)X.push(T9),S9(X,Y[W]),X.push(T9,V6(Q[++W]));return jA(X),new R0(X)}dG.str=rG;function S9(Q,Y){if(Y instanceof R0)Q.push(...Y._items);else if(Y instanceof x1)Q.push(Y);else Q.push(EA(Y))}dG.addCodeArg=S9;function jA(Q){let Y=1;while(Y<Q.length-1){if(Q[Y]===T9){let X=PA(Q[Y-1],Q[Y+1]);if(X!==void 0){Q.splice(Y-1,3,X);continue}Q[Y++]="+"}Y++}}function PA(Q,Y){if(Y==='""')return Q;if(Q==='""')return Y;if(typeof Q=="string"){if(Y instanceof x1||Q[Q.length-1]!=='"')return;if(typeof Y!="string")return`${Q.slice(0,-1)}${Y}"`;if(Y[0]==='"')return Q.slice(0,-1)+Y.slice(1);return}if(typeof Y=="string"&&Y[0]==='"'&&!(Q instanceof x1))return`"${Q}${Y.slice(1)}`;return}function IA(Q,Y){return Y.emptyStr()?Q:Q.emptyStr()?Y:rG`${Q}${Y}`}dG.strConcat=IA;function EA(Q){return typeof Q=="number"||typeof Q=="boolean"||Q===null?Q:V6(Array.isArray(Q)?Q.join(","):Q)}function TA(Q){return new R0(V6(Q))}dG.stringify=TA;function V6(Q){return JSON.stringify(Q).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}dG.safeStringify=V6;function SA(Q){return typeof Q=="string"&&dG.IDENTIFIER.test(Q)?new R0(`.${Q}`):nG`[${Q}]`}dG.getProperty=SA;function RA(Q){if(typeof Q=="string"&&dG.IDENTIFIER.test(Q))return new R0(`${Q}`);throw Error(`CodeGen: invalid export name: ${Q}, use explicit $id name mapping`)}dG.getEsmExportName=RA;function CA(Q){return new R0(Q.toString())}dG.regexpCode=CA});var v9=w((sG)=>{Object.defineProperty(sG,"__esModule",{value:!0});sG.ValueScope=sG.ValueScopeName=sG.Scope=sG.varKinds=sG.UsedValueState=void 0;var F0=Z6();class tG extends Error{constructor(Q){super(`CodeGen: "code" for ${Q} not defined`);this.value=Q.value}}var C4;(function(Q){Q[Q.Started=0]="Started",Q[Q.Completed=1]="Completed"})(C4||(sG.UsedValueState=C4={}));sG.varKinds={const:new F0.Name("const"),let:new F0.Name("let"),var:new F0.Name("var")};class C9{constructor({prefixes:Q,parent:Y}={}){this._names={},this._prefixes=Q,this._parent=Y}toName(Q){return Q instanceof F0.Name?Q:this.name(Q)}name(Q){return new F0.Name(this._newName(Q))}_newName(Q){let Y=this._names[Q]||this._nameGroup(Q);return`${Q}${Y.index++}`}_nameGroup(Q){var Y,X;if(((X=(Y=this._parent)===null||Y===void 0?void 0:Y._prefixes)===null||X===void 0?void 0:X.has(Q))||this._prefixes&&!this._prefixes.has(Q))throw Error(`CodeGen: prefix "${Q}" is not allowed in this scope`);return this._names[Q]={prefix:Q,index:0}}}sG.Scope=C9;class k9 extends F0.Name{constructor(Q,Y){super(Y);this.prefix=Q}setValue(Q,{property:Y,itemIndex:X}){this.value=Q,this.scopePath=F0._`.${new F0.Name(Y)}[${X}]`}}sG.ValueScopeName=k9;var pA=F0._`\n`;class aG extends C9{constructor(Q){super(Q);this._values={},this._scope=Q.scope,this.opts={...Q,_n:Q.lines?pA:F0.nil}}get(){return this._scope}name(Q){return new k9(Q,this._newName(Q))}value(Q,Y){var X;if(Y.ref===void 0)throw Error("CodeGen: ref must be passed in value");let W=this.toName(Q),{prefix:G}=W,$=(X=Y.key)!==null&&X!==void 0?X:Y.ref,J=this._values[G];if(J){let U=J.get($);if(U)return U}else J=this._values[G]=new Map;J.set($,W);let z=this._scope[G]||(this._scope[G]=[]),H=z.length;return z[H]=Y.ref,W.setValue(Y,{property:G,itemIndex:H}),W}getValue(Q,Y){let X=this._values[Q];if(!X)return;return X.get(Y)}scopeRefs(Q,Y=this._values){return this._reduceValues(Y,(X)=>{if(X.scopePath===void 0)throw Error(`CodeGen: name "${X}" has no value`);return F0._`${Q}${X.scopePath}`})}scopeCode(Q=this._values,Y,X){return this._reduceValues(Q,(W)=>{if(W.value===void 0)throw Error(`CodeGen: name "${W}" has no value`);return W.value.code},Y,X)}_reduceValues(Q,Y,X={},W){let G=F0.nil;for(let $ in Q){let J=Q[$];if(!J)continue;let z=X[$]=X[$]||new Map;J.forEach((H)=>{if(z.has(H))return;z.set(H,C4.Started);let U=Y(H);if(U){let A=this.opts.es5?sG.varKinds.var:sG.varKinds.const;G=F0._`${G}${A} ${H} = ${U};${this.opts._n}`}else if(U=W===null||W===void 0?void 0:W(H))G=F0._`${G}${U}${this.opts._n}`;else throw new tG(H);z.set(H,C4.Completed)})}return G}}sG.ValueScope=aG});var v=w((O0)=>{Object.defineProperty(O0,"__esModule",{value:!0});O0.or=O0.and=O0.not=O0.CodeGen=O0.operators=O0.varKinds=O0.ValueScopeName=O0.ValueScope=O0.Scope=O0.Name=O0.regexpCode=O0.stringify=O0.getProperty=O0.nil=O0.strConcat=O0.str=O0._=void 0;var u=Z6(),C0=v9(),H1=Z6();Object.defineProperty(O0,"_",{enumerable:!0,get:function(){return H1._}});Object.defineProperty(O0,"str",{enumerable:!0,get:function(){return H1.str}});Object.defineProperty(O0,"strConcat",{enumerable:!0,get:function(){return H1.strConcat}});Object.defineProperty(O0,"nil",{enumerable:!0,get:function(){return H1.nil}});Object.defineProperty(O0,"getProperty",{enumerable:!0,get:function(){return H1.getProperty}});Object.defineProperty(O0,"stringify",{enumerable:!0,get:function(){return H1.stringify}});Object.defineProperty(O0,"regexpCode",{enumerable:!0,get:function(){return H1.regexpCode}});Object.defineProperty(O0,"Name",{enumerable:!0,get:function(){return H1.Name}});var g4=v9();Object.defineProperty(O0,"Scope",{enumerable:!0,get:function(){return g4.Scope}});Object.defineProperty(O0,"ValueScope",{enumerable:!0,get:function(){return g4.ValueScope}});Object.defineProperty(O0,"ValueScopeName",{enumerable:!0,get:function(){return g4.ValueScopeName}});Object.defineProperty(O0,"varKinds",{enumerable:!0,get:function(){return g4.varKinds}});O0.operators={GT:new u._Code(">"),GTE:new u._Code(">="),LT:new u._Code("<"),LTE:new u._Code("<="),EQ:new u._Code("==="),NEQ:new u._Code("!=="),NOT:new u._Code("!"),OR:new u._Code("||"),AND:new u._Code("&&"),ADD:new u._Code("+")};class U1{optimizeNodes(){return this}optimizeNames(Q,Y){return this}}class Q$ extends U1{constructor(Q,Y,X){super();this.varKind=Q,this.name=Y,this.rhs=X}render({es5:Q,_n:Y}){let X=Q?C0.varKinds.var:this.varKind,W=this.rhs===void 0?"":` = ${this.rhs}`;return`${X} ${this.name}${W};`+Y}optimizeNames(Q,Y){if(!Q[this.name.str])return;if(this.rhs)this.rhs=y1(this.rhs,Q,Y);return this}get names(){return this.rhs instanceof u._CodeOrName?this.rhs.names:{}}}class y9 extends U1{constructor(Q,Y,X){super();this.lhs=Q,this.rhs=Y,this.sideEffects=X}render({_n:Q}){return`${this.lhs} = ${this.rhs};`+Q}optimizeNames(Q,Y){if(this.lhs instanceof u.Name&&!Q[this.lhs.str]&&!this.sideEffects)return;return this.rhs=y1(this.rhs,Q,Y),this}get names(){let Q=this.lhs instanceof u.Name?{}:{...this.lhs.names};return y4(Q,this.rhs)}}class Y$ extends y9{constructor(Q,Y,X,W){super(Q,X,W);this.op=Y}render({_n:Q}){return`${this.lhs} ${this.op}= ${this.rhs};`+Q}}class X$ extends U1{constructor(Q){super();this.label=Q,this.names={}}render({_n:Q}){return`${this.label}:`+Q}}class W$ extends U1{constructor(Q){super();this.label=Q,this.names={}}render({_n:Q}){return`break${this.label?` ${this.label}`:""};`+Q}}class G$ extends U1{constructor(Q){super();this.error=Q}render({_n:Q}){return`throw ${this.error};`+Q}get names(){return this.error.names}}class $$ extends U1{constructor(Q){super();this.code=Q}render({_n:Q}){return`${this.code};`+Q}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames(Q,Y){return this.code=y1(this.code,Q,Y),this}get names(){return this.code instanceof u._CodeOrName?this.code.names:{}}}class u4 extends U1{constructor(Q=[]){super();this.nodes=Q}render(Q){return this.nodes.reduce((Y,X)=>Y+X.render(Q),"")}optimizeNodes(){let{nodes:Q}=this,Y=Q.length;while(Y--){let X=Q[Y].optimizeNodes();if(Array.isArray(X))Q.splice(Y,1,...X);else if(X)Q[Y]=X;else Q.splice(Y,1)}return Q.length>0?this:void 0}optimizeNames(Q,Y){let{nodes:X}=this,W=X.length;while(W--){let G=X[W];if(G.optimizeNames(Q,Y))continue;dA(Q,G.names),X.splice(W,1)}return X.length>0?this:void 0}get names(){return this.nodes.reduce((Q,Y)=>V1(Q,Y.names),{})}}class A1 extends u4{render(Q){return"{"+Q._n+super.render(Q)+"}"+Q._n}}class J$ extends u4{}class N6 extends A1{}N6.kind="else";class n0 extends A1{constructor(Q,Y){super(Y);this.condition=Q}render(Q){let Y=`if(${this.condition})`+super.render(Q);if(this.else)Y+="else "+this.else.render(Q);return Y}optimizeNodes(){super.optimizeNodes();let Q=this.condition;if(Q===!0)return this.nodes;let Y=this.else;if(Y){let X=Y.optimizeNodes();Y=this.else=Array.isArray(X)?new N6(X):X}if(Y){if(Q===!1)return Y instanceof n0?Y:Y.nodes;if(this.nodes.length)return this;return new n0(B$(Q),Y instanceof n0?[Y]:Y.nodes)}if(Q===!1||!this.nodes.length)return;return this}optimizeNames(Q,Y){var X;if(this.else=(X=this.else)===null||X===void 0?void 0:X.optimizeNames(Q,Y),!(super.optimizeNames(Q,Y)||this.else))return;return this.condition=y1(this.condition,Q,Y),this}get names(){let Q=super.names;if(y4(Q,this.condition),this.else)V1(Q,this.else.names);return Q}}n0.kind="if";class _1 extends A1{}_1.kind="for";class z$ extends _1{constructor(Q){super();this.iteration=Q}render(Q){return`for(${this.iteration})`+super.render(Q)}optimizeNames(Q,Y){if(!super.optimizeNames(Q,Y))return;return this.iteration=y1(this.iteration,Q,Y),this}get names(){return V1(super.names,this.iteration.names)}}class H$ extends _1{constructor(Q,Y,X,W){super();this.varKind=Q,this.name=Y,this.from=X,this.to=W}render(Q){let Y=Q.es5?C0.varKinds.var:this.varKind,{name:X,from:W,to:G}=this;return`for(${Y} ${X}=${W}; ${X}<${G}; ${X}++)`+super.render(Q)}get names(){let Q=y4(super.names,this.from);return y4(Q,this.to)}}class x9 extends _1{constructor(Q,Y,X,W){super();this.loop=Q,this.varKind=Y,this.name=X,this.iterable=W}render(Q){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(Q)}optimizeNames(Q,Y){if(!super.optimizeNames(Q,Y))return;return this.iterable=y1(this.iterable,Q,Y),this}get names(){return V1(super.names,this.iterable.names)}}class k4 extends A1{constructor(Q,Y,X){super();this.name=Q,this.args=Y,this.async=X}render(Q){return`${this.async?"async ":""}function ${this.name}(${this.args})`+super.render(Q)}}k4.kind="func";class v4 extends u4{render(Q){return"return "+super.render(Q)}}v4.kind="return";class U$ extends A1{render(Q){let Y="try"+super.render(Q);if(this.catch)Y+=this.catch.render(Q);if(this.finally)Y+=this.finally.render(Q);return Y}optimizeNodes(){var Q,Y;return super.optimizeNodes(),(Q=this.catch)===null||Q===void 0||Q.optimizeNodes(),(Y=this.finally)===null||Y===void 0||Y.optimizeNodes(),this}optimizeNames(Q,Y){var X,W;return super.optimizeNames(Q,Y),(X=this.catch)===null||X===void 0||X.optimizeNames(Q,Y),(W=this.finally)===null||W===void 0||W.optimizeNames(Q,Y),this}get names(){let Q=super.names;if(this.catch)V1(Q,this.catch.names);if(this.finally)V1(Q,this.finally.names);return Q}}class x4 extends A1{constructor(Q){super();this.error=Q}render(Q){return`catch(${this.error})`+super.render(Q)}}x4.kind="catch";class _4 extends A1{render(Q){return"finally"+super.render(Q)}}_4.kind="finally";class A${constructor(Q,Y={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...Y,_n:Y.lines?`
|
|
3
|
+
`:""},this._extScope=Q,this._scope=new C0.Scope({parent:Q}),this._nodes=[new J$]}toString(){return this._root.render(this.opts)}name(Q){return this._scope.name(Q)}scopeName(Q){return this._extScope.name(Q)}scopeValue(Q,Y){let X=this._extScope.value(Q,Y);return(this._values[X.prefix]||(this._values[X.prefix]=new Set)).add(X),X}getScopeValue(Q,Y){return this._extScope.getValue(Q,Y)}scopeRefs(Q){return this._extScope.scopeRefs(Q,this._values)}scopeCode(){return this._extScope.scopeCode(this._values)}_def(Q,Y,X,W){let G=this._scope.toName(Y);if(X!==void 0&&W)this._constants[G.str]=X;return this._leafNode(new Q$(Q,G,X)),G}const(Q,Y,X){return this._def(C0.varKinds.const,Q,Y,X)}let(Q,Y,X){return this._def(C0.varKinds.let,Q,Y,X)}var(Q,Y,X){return this._def(C0.varKinds.var,Q,Y,X)}assign(Q,Y,X){return this._leafNode(new y9(Q,Y,X))}add(Q,Y){return this._leafNode(new Y$(Q,O0.operators.ADD,Y))}code(Q){if(typeof Q=="function")Q();else if(Q!==u.nil)this._leafNode(new $$(Q));return this}object(...Q){let Y=["{"];for(let[X,W]of Q){if(Y.length>1)Y.push(",");if(Y.push(X),X!==W||this.opts.es5)Y.push(":"),(0,u.addCodeArg)(Y,W)}return Y.push("}"),new u._Code(Y)}if(Q,Y,X){if(this._blockNode(new n0(Q)),Y&&X)this.code(Y).else().code(X).endIf();else if(Y)this.code(Y).endIf();else if(X)throw Error('CodeGen: "else" body without "then" body');return this}elseIf(Q){return this._elseNode(new n0(Q))}else(){return this._elseNode(new N6)}endIf(){return this._endBlockNode(n0,N6)}_for(Q,Y){if(this._blockNode(Q),Y)this.code(Y).endFor();return this}for(Q,Y){return this._for(new z$(Q),Y)}forRange(Q,Y,X,W,G=this.opts.es5?C0.varKinds.var:C0.varKinds.let){let $=this._scope.toName(Q);return this._for(new H$(G,$,Y,X),()=>W($))}forOf(Q,Y,X,W=C0.varKinds.const){let G=this._scope.toName(Q);if(this.opts.es5){let $=Y instanceof u.Name?Y:this.var("_arr",Y);return this.forRange("_i",0,u._`${$}.length`,(J)=>{this.var(G,u._`${$}[${J}]`),X(G)})}return this._for(new x9("of",W,G,Y),()=>X(G))}forIn(Q,Y,X,W=this.opts.es5?C0.varKinds.var:C0.varKinds.const){if(this.opts.ownProperties)return this.forOf(Q,u._`Object.keys(${Y})`,X);let G=this._scope.toName(Q);return this._for(new x9("in",W,G,Y),()=>X(G))}endFor(){return this._endBlockNode(_1)}label(Q){return this._leafNode(new X$(Q))}break(Q){return this._leafNode(new W$(Q))}return(Q){let Y=new v4;if(this._blockNode(Y),this.code(Q),Y.nodes.length!==1)throw Error('CodeGen: "return" should have one node');return this._endBlockNode(v4)}try(Q,Y,X){if(!Y&&!X)throw Error('CodeGen: "try" without "catch" and "finally"');let W=new U$;if(this._blockNode(W),this.code(Q),Y){let G=this.name("e");this._currNode=W.catch=new x4(G),Y(G)}if(X)this._currNode=W.finally=new _4,this.code(X);return this._endBlockNode(x4,_4)}throw(Q){return this._leafNode(new G$(Q))}block(Q,Y){if(this._blockStarts.push(this._nodes.length),Q)this.code(Q).endBlock(Y);return this}endBlock(Q){let Y=this._blockStarts.pop();if(Y===void 0)throw Error("CodeGen: not in self-balancing block");let X=this._nodes.length-Y;if(X<0||Q!==void 0&&X!==Q)throw Error(`CodeGen: wrong number of nodes: ${X} vs ${Q} expected`);return this._nodes.length=Y,this}func(Q,Y=u.nil,X,W){if(this._blockNode(new k4(Q,Y,X)),W)this.code(W).endFunc();return this}endFunc(){return this._endBlockNode(k4)}optimize(Q=1){while(Q-- >0)this._root.optimizeNodes(),this._root.optimizeNames(this._root.names,this._constants)}_leafNode(Q){return this._currNode.nodes.push(Q),this}_blockNode(Q){this._currNode.nodes.push(Q),this._nodes.push(Q)}_endBlockNode(Q,Y){let X=this._currNode;if(X instanceof Q||Y&&X instanceof Y)return this._nodes.pop(),this;throw Error(`CodeGen: not in block "${Y?`${Q.kind}/${Y.kind}`:Q.kind}"`)}_elseNode(Q){let Y=this._currNode;if(!(Y instanceof n0))throw Error('CodeGen: "else" without "if"');return this._currNode=Y.else=Q,this}get _root(){return this._nodes[0]}get _currNode(){let Q=this._nodes;return Q[Q.length-1]}set _currNode(Q){let Y=this._nodes;Y[Y.length-1]=Q}}O0.CodeGen=A$;function V1(Q,Y){for(let X in Y)Q[X]=(Q[X]||0)+(Y[X]||0);return Q}function y4(Q,Y){return Y instanceof u._CodeOrName?V1(Q,Y.names):Q}function y1(Q,Y,X){if(Q instanceof u.Name)return W(Q);if(!G(Q))return Q;return new u._Code(Q._items.reduce(($,J)=>{if(J instanceof u.Name)J=W(J);if(J instanceof u._Code)$.push(...J._items);else $.push(J);return $},[]));function W($){let J=X[$.str];if(J===void 0||Y[$.str]!==1)return $;return delete Y[$.str],J}function G($){return $ instanceof u._Code&&$._items.some((J)=>J instanceof u.Name&&Y[J.str]===1&&X[J.str]!==void 0)}}function dA(Q,Y){for(let X in Y)Q[X]=(Q[X]||0)-(Y[X]||0)}function B$(Q){return typeof Q=="boolean"||typeof Q=="number"||Q===null?!Q:u._`!${_9(Q)}`}O0.not=B$;var oA=K$(O0.operators.AND);function tA(...Q){return Q.reduce(oA)}O0.and=tA;var aA=K$(O0.operators.OR);function sA(...Q){return Q.reduce(aA)}O0.or=sA;function K$(Q){return(Y,X)=>Y===u.nil?X:X===u.nil?Y:u._`${_9(Y)} ${Q} ${_9(X)}`}function _9(Q){return Q instanceof u.Name?Q:u._`(${Q})`}});var l=w((N$)=>{Object.defineProperty(N$,"__esModule",{value:!0});N$.checkStrictMode=N$.getErrorPath=N$.Type=N$.useFunc=N$.setEvaluated=N$.evaluatedPropsToName=N$.mergeEvaluated=N$.eachItem=N$.unescapeJsonPointer=N$.escapeJsonPointer=N$.escapeFragment=N$.unescapeFragment=N$.schemaRefOrVal=N$.schemaHasRulesButRef=N$.schemaHasRules=N$.checkUnknownRules=N$.alwaysValidSchema=N$.toHash=void 0;var p=v(),XB=Z6();function WB(Q){let Y={};for(let X of Q)Y[X]=!0;return Y}N$.toHash=WB;function GB(Q,Y){if(typeof Y=="boolean")return Y;if(Object.keys(Y).length===0)return!0;return F$(Q,Y),!O$(Y,Q.self.RULES.all)}N$.alwaysValidSchema=GB;function F$(Q,Y=Q.schema){let{opts:X,self:W}=Q;if(!X.strictSchema)return;if(typeof Y==="boolean")return;let G=W.RULES.keywords;for(let $ in Y)if(!G[$])Z$(Q,`unknown keyword: "${$}"`)}N$.checkUnknownRules=F$;function O$(Q,Y){if(typeof Q=="boolean")return!Q;for(let X in Q)if(Y[X])return!0;return!1}N$.schemaHasRules=O$;function $B(Q,Y){if(typeof Q=="boolean")return!Q;for(let X in Q)if(X!=="$ref"&&Y.all[X])return!0;return!1}N$.schemaHasRulesButRef=$B;function JB({topSchemaRef:Q,schemaPath:Y},X,W,G){if(!G){if(typeof X=="number"||typeof X=="boolean")return X;if(typeof X=="string")return p._`${X}`}return p._`${Q}${Y}${(0,p.getProperty)(W)}`}N$.schemaRefOrVal=JB;function zB(Q){return M$(decodeURIComponent(Q))}N$.unescapeFragment=zB;function HB(Q){return encodeURIComponent(u9(Q))}N$.escapeFragment=HB;function u9(Q){if(typeof Q=="number")return`${Q}`;return Q.replace(/~/g,"~0").replace(/\//g,"~1")}N$.escapeJsonPointer=u9;function M$(Q){return Q.replace(/~1/g,"/").replace(/~0/g,"~")}N$.unescapeJsonPointer=M$;function UB(Q,Y){if(Array.isArray(Q))for(let X of Q)Y(X);else Y(Q)}N$.eachItem=UB;function L$({mergeNames:Q,mergeToName:Y,mergeValues:X,resultToName:W}){return(G,$,J,z)=>{let H=J===void 0?$:J instanceof p.Name?($ instanceof p.Name?Q(G,$,J):Y(G,$,J),J):$ instanceof p.Name?(Y(G,J,$),$):X($,J);return z===p.Name&&!(H instanceof p.Name)?W(G,H):H}}N$.mergeEvaluated={props:L$({mergeNames:(Q,Y,X)=>Q.if(p._`${X} !== true && ${Y} !== undefined`,()=>{Q.if(p._`${Y} === true`,()=>Q.assign(X,!0),()=>Q.assign(X,p._`${X} || {}`).code(p._`Object.assign(${X}, ${Y})`))}),mergeToName:(Q,Y,X)=>Q.if(p._`${X} !== true`,()=>{if(Y===!0)Q.assign(X,!0);else Q.assign(X,p._`${X} || {}`),h9(Q,X,Y)}),mergeValues:(Q,Y)=>Q===!0?!0:{...Q,...Y},resultToName:V$}),items:L$({mergeNames:(Q,Y,X)=>Q.if(p._`${X} !== true && ${Y} !== undefined`,()=>Q.assign(X,p._`${Y} === true ? true : ${X} > ${Y} ? ${X} : ${Y}`)),mergeToName:(Q,Y,X)=>Q.if(p._`${X} !== true`,()=>Q.assign(X,Y===!0?!0:p._`${X} > ${Y} ? ${X} : ${Y}`)),mergeValues:(Q,Y)=>Q===!0?!0:Math.max(Q,Y),resultToName:(Q,Y)=>Q.var("items",Y)})};function V$(Q,Y){if(Y===!0)return Q.var("props",!0);let X=Q.var("props",p._`{}`);if(Y!==void 0)h9(Q,X,Y);return X}N$.evaluatedPropsToName=V$;function h9(Q,Y,X){Object.keys(X).forEach((W)=>Q.assign(p._`${Y}${(0,p.getProperty)(W)}`,!0))}N$.setEvaluated=h9;var q$={};function AB(Q,Y){return Q.scopeValue("func",{ref:Y,code:q$[Y.code]||(q$[Y.code]=new XB._Code(Y.code))})}N$.useFunc=AB;var g9;(function(Q){Q[Q.Num=0]="Num",Q[Q.Str=1]="Str"})(g9||(N$.Type=g9={}));function BB(Q,Y,X){if(Q instanceof p.Name){let W=Y===g9.Num;return X?W?p._`"[" + ${Q} + "]"`:p._`"['" + ${Q} + "']"`:W?p._`"/" + ${Q}`:p._`"/" + ${Q}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return X?(0,p.getProperty)(Q).toString():"/"+u9(Q)}N$.getErrorPath=BB;function Z$(Q,Y,X=Q.opts.strictSchema){if(!X)return;if(Y=`strict mode: ${Y}`,X===!0)throw Error(Y);Q.self.logger.warn(Y)}N$.checkStrictMode=Z$});var r0=w((b$)=>{Object.defineProperty(b$,"__esModule",{value:!0});var A0=v(),SB={data:new A0.Name("data"),valCxt:new A0.Name("valCxt"),instancePath:new A0.Name("instancePath"),parentData:new A0.Name("parentData"),parentDataProperty:new A0.Name("parentDataProperty"),rootData:new A0.Name("rootData"),dynamicAnchors:new A0.Name("dynamicAnchors"),vErrors:new A0.Name("vErrors"),errors:new A0.Name("errors"),this:new A0.Name("this"),self:new A0.Name("self"),scope:new A0.Name("scope"),json:new A0.Name("json"),jsonPos:new A0.Name("jsonPos"),jsonLen:new A0.Name("jsonLen"),jsonPart:new A0.Name("jsonPart")};b$.default=SB});var w6=w((E$)=>{Object.defineProperty(E$,"__esModule",{value:!0});E$.extendErrors=E$.resetErrorsCount=E$.reportExtraError=E$.reportError=E$.keyword$DataError=E$.keywordError=void 0;var h=v(),f4=l(),D0=r0();E$.keywordError={message:({keyword:Q})=>h.str`must pass "${Q}" keyword validation`};E$.keyword$DataError={message:({keyword:Q,schemaType:Y})=>Y?h.str`"${Q}" keyword must be ${Y} ($data)`:h.str`"${Q}" keyword is invalid ($data)`};function CB(Q,Y=E$.keywordError,X,W){let{it:G}=Q,{gen:$,compositeRule:J,allErrors:z}=G,H=I$(Q,Y,X);if(W!==null&&W!==void 0?W:J||z)j$($,H);else P$(G,h._`[${H}]`)}E$.reportError=CB;function kB(Q,Y=E$.keywordError,X){let{it:W}=Q,{gen:G,compositeRule:$,allErrors:J}=W,z=I$(Q,Y,X);if(j$(G,z),!($||J))P$(W,D0.default.vErrors)}E$.reportExtraError=kB;function vB(Q,Y){Q.assign(D0.default.errors,Y),Q.if(h._`${D0.default.vErrors} !== null`,()=>Q.if(Y,()=>Q.assign(h._`${D0.default.vErrors}.length`,Y),()=>Q.assign(D0.default.vErrors,null)))}E$.resetErrorsCount=vB;function xB({gen:Q,keyword:Y,schemaValue:X,data:W,errsCount:G,it:$}){if(G===void 0)throw Error("ajv implementation error");let J=Q.name("err");Q.forRange("i",G,D0.default.errors,(z)=>{if(Q.const(J,h._`${D0.default.vErrors}[${z}]`),Q.if(h._`${J}.instancePath === undefined`,()=>Q.assign(h._`${J}.instancePath`,(0,h.strConcat)(D0.default.instancePath,$.errorPath))),Q.assign(h._`${J}.schemaPath`,h.str`${$.errSchemaPath}/${Y}`),$.opts.verbose)Q.assign(h._`${J}.schema`,X),Q.assign(h._`${J}.data`,W)})}E$.extendErrors=xB;function j$(Q,Y){let X=Q.const("err",Y);Q.if(h._`${D0.default.vErrors} === null`,()=>Q.assign(D0.default.vErrors,h._`[${X}]`),h._`${D0.default.vErrors}.push(${X})`),Q.code(h._`${D0.default.errors}++`)}function P$(Q,Y){let{gen:X,validateName:W,schemaEnv:G}=Q;if(G.$async)X.throw(h._`new ${Q.ValidationError}(${Y})`);else X.assign(h._`${W}.errors`,Y),X.return(!1)}var Z1={keyword:new h.Name("keyword"),schemaPath:new h.Name("schemaPath"),params:new h.Name("params"),propertyName:new h.Name("propertyName"),message:new h.Name("message"),schema:new h.Name("schema"),parentSchema:new h.Name("parentSchema")};function I$(Q,Y,X){let{createErrors:W}=Q.it;if(W===!1)return h._`{}`;return _B(Q,Y,X)}function _B(Q,Y,X={}){let{gen:W,it:G}=Q,$=[yB(G,X),gB(Q,X)];return uB(Q,Y,$),W.object(...$)}function yB({errorPath:Q},{instancePath:Y}){let X=Y?h.str`${Q}${(0,f4.getErrorPath)(Y,f4.Type.Str)}`:Q;return[D0.default.instancePath,(0,h.strConcat)(D0.default.instancePath,X)]}function gB({keyword:Q,it:{errSchemaPath:Y}},{schemaPath:X,parentSchema:W}){let G=W?Y:h.str`${Y}/${Q}`;if(X)G=h.str`${G}${(0,f4.getErrorPath)(X,f4.Type.Str)}`;return[Z1.schemaPath,G]}function uB(Q,{params:Y,message:X},W){let{keyword:G,data:$,schemaValue:J,it:z}=Q,{opts:H,propertyName:U,topSchemaRef:A,schemaPath:B}=z;if(W.push([Z1.keyword,G],[Z1.params,typeof Y=="function"?Y(Q):Y||h._`{}`]),H.messages)W.push([Z1.message,typeof X=="function"?X(Q):X]);if(H.verbose)W.push([Z1.schema,J],[Z1.parentSchema,h._`${A}${B}`],[D0.default.data,$]);if(U)W.push([Z1.propertyName,U])}});var k$=w((R$)=>{Object.defineProperty(R$,"__esModule",{value:!0});R$.boolOrEmptySchema=R$.topBoolOrEmptySchema=void 0;var cB=w6(),pB=v(),iB=r0(),nB={message:"boolean schema is false"};function rB(Q){let{gen:Y,schema:X,validateName:W}=Q;if(X===!1)S$(Q,!1);else if(typeof X=="object"&&X.$async===!0)Y.return(iB.default.data);else Y.assign(pB._`${W}.errors`,null),Y.return(!0)}R$.topBoolOrEmptySchema=rB;function dB(Q,Y){let{gen:X,schema:W}=Q;if(W===!1)X.var(Y,!1),S$(Q);else X.var(Y,!0)}R$.boolOrEmptySchema=dB;function S$(Q,Y){let{gen:X,data:W}=Q,G={gen:X,keyword:"false schema",data:W,schema:!1,schemaCode:!1,schemaValue:!1,params:{},it:Q};(0,cB.reportError)(G,nB,void 0,Y)}});var l9=w((v$)=>{Object.defineProperty(v$,"__esModule",{value:!0});v$.getRules=v$.isJSONType=void 0;var tB=["string","number","integer","boolean","null","object","array"],aB=new Set(tB);function sB(Q){return typeof Q=="string"&&aB.has(Q)}v$.isJSONType=sB;function eB(){let Q={number:{type:"number",rules:[]},string:{type:"string",rules:[]},array:{type:"array",rules:[]},object:{type:"object",rules:[]}};return{types:{...Q,integer:!0,boolean:!0,null:!0},rules:[{rules:[]},Q.number,Q.string,Q.array,Q.object],post:{rules:[]},all:{},keywords:{}}}v$.getRules=eB});var m9=w((g$)=>{Object.defineProperty(g$,"__esModule",{value:!0});g$.shouldUseRule=g$.shouldUseGroup=g$.schemaHasRulesForType=void 0;function YK({schema:Q,self:Y},X){let W=Y.RULES.types[X];return W&&W!==!0&&_$(Q,W)}g$.schemaHasRulesForType=YK;function _$(Q,Y){return Y.rules.some((X)=>y$(Q,X))}g$.shouldUseGroup=_$;function y$(Q,Y){var X;return Q[Y.keyword]!==void 0||((X=Y.definition.implements)===null||X===void 0?void 0:X.some((W)=>Q[W]!==void 0))}g$.shouldUseRule=y$});var b6=w((m$)=>{Object.defineProperty(m$,"__esModule",{value:!0});m$.reportTypeError=m$.checkDataTypes=m$.checkDataType=m$.coerceAndCheckDataType=m$.getJSONTypes=m$.getSchemaTypes=m$.DataType=void 0;var GK=l9(),$K=m9(),JK=w6(),C=v(),h$=l(),g1;(function(Q){Q[Q.Correct=0]="Correct",Q[Q.Wrong=1]="Wrong"})(g1||(m$.DataType=g1={}));function zK(Q){let Y=f$(Q.type);if(Y.includes("null")){if(Q.nullable===!1)throw Error("type: null contradicts nullable: false")}else{if(!Y.length&&Q.nullable!==void 0)throw Error('"nullable" cannot be used without "type"');if(Q.nullable===!0)Y.push("null")}return Y}m$.getSchemaTypes=zK;function f$(Q){let Y=Array.isArray(Q)?Q:Q?[Q]:[];if(Y.every(GK.isJSONType))return Y;throw Error("type must be JSONType or JSONType[]: "+Y.join(","))}m$.getJSONTypes=f$;function HK(Q,Y){let{gen:X,data:W,opts:G}=Q,$=UK(Y,G.coerceTypes),J=Y.length>0&&!($.length===0&&Y.length===1&&(0,$K.schemaHasRulesForType)(Q,Y[0]));if(J){let z=p9(Y,W,G.strictNumbers,g1.Wrong);X.if(z,()=>{if($.length)AK(Q,Y,$);else i9(Q)})}return J}m$.coerceAndCheckDataType=HK;var l$=new Set(["string","number","integer","boolean","null"]);function UK(Q,Y){return Y?Q.filter((X)=>l$.has(X)||Y==="array"&&X==="array"):[]}function AK(Q,Y,X){let{gen:W,data:G,opts:$}=Q,J=W.let("dataType",C._`typeof ${G}`),z=W.let("coerced",C._`undefined`);if($.coerceTypes==="array")W.if(C._`${J} == 'object' && Array.isArray(${G}) && ${G}.length == 1`,()=>W.assign(G,C._`${G}[0]`).assign(J,C._`typeof ${G}`).if(p9(Y,G,$.strictNumbers),()=>W.assign(z,G)));W.if(C._`${z} !== undefined`);for(let U of X)if(l$.has(U)||U==="array"&&$.coerceTypes==="array")H(U);W.else(),i9(Q),W.endIf(),W.if(C._`${z} !== undefined`,()=>{W.assign(G,z),BK(Q,z)});function H(U){switch(U){case"string":W.elseIf(C._`${J} == "number" || ${J} == "boolean"`).assign(z,C._`"" + ${G}`).elseIf(C._`${G} === null`).assign(z,C._`""`);return;case"number":W.elseIf(C._`${J} == "boolean" || ${G} === null
|
|
4
4
|
|| (${J} == "string" && ${G} && ${G} == +${G})`).assign(z,C._`+${G}`);return;case"integer":W.elseIf(C._`${J} === "boolean" || ${G} === null
|
|
5
5
|
|| (${J} === "string" && ${G} && ${G} == +${G} && !(${G} % 1))`).assign(z,C._`+${G}`);return;case"boolean":W.elseIf(C._`${G} === "false" || ${G} === 0 || ${G} === null`).assign(z,!1).elseIf(C._`${G} === "true" || ${G} === 1`).assign(z,!0);return;case"null":W.elseIf(C._`${G} === "" || ${G} === 0 || ${G} === false`),W.assign(z,null);return;case"array":W.elseIf(C._`${J} === "string" || ${J} === "number"
|
|
6
|
-
|| ${J} === "boolean" || ${G} === null`).assign(z,C._`[${G}]`)}}}function BK({gen:Q,parentData:Y,parentDataProperty:X},W){Q.if(C._`${Y} !== undefined`,()=>Q.assign(C._`${Y}[${X}]`,W))}function c9(Q,Y,X,W=g1.Correct){let G=W===g1.Correct?C.operators.EQ:C.operators.NEQ,$;switch(Q){case"null":return C._`${Y} ${G} null`;case"array":$=C._`Array.isArray(${Y})`;break;case"object":$=C._`${Y} && typeof ${Y} == "object" && !Array.isArray(${Y})`;break;case"integer":$=J(C._`!(${Y} % 1) && !isNaN(${Y})`);break;case"number":$=J();break;default:return C._`typeof ${Y} ${G} ${Q}`}return W===g1.Correct?$:(0,C.not)($);function J(z=C.nil){return(0,C.and)(C._`typeof ${Y} == "number"`,z,X?C._`isFinite(${Y})`:C.nil)}}m$.checkDataType=c9;function p9(Q,Y,X,W){if(Q.length===1)return c9(Q[0],Y,X,W);let G,$=(0,h$.toHash)(Q);if($.array&&$.object){let J=C._`typeof ${Y} != "object"`;G=$.null?J:C._`!${Y} || ${J}`,delete $.null,delete $.array,delete $.object}else G=C.nil;if($.number)delete $.integer;for(let J in $)G=(0,C.and)(G,c9(J,Y,X,W));return G}m$.checkDataTypes=p9;var KK={message:({schema:Q})=>`must be ${Q}`,params:({schema:Q,schemaValue:Y})=>typeof Q=="string"?C._`{type: ${Q}}`:C._`{type: ${Y}}`};function i9(Q){let Y=DK(Q);(0,JK.reportError)(Y,KK)}m$.reportTypeError=i9;function DK(Q){let{gen:Y,data:X,schema:W}=Q,G=(0,h$.schemaRefOrVal)(Q,W,"type");return{gen:Y,keyword:"type",data:X,schema:W.type,schemaCode:G,schemaValue:G,parentSchema:W,params:{},it:Q}}});var r$=w((i$)=>{Object.defineProperty(i$,"__esModule",{value:!0});i$.assignDefaults=void 0;var u1=v(),ZK=l();function NK(Q,Y){let{properties:X,items:W}=Q.schema;if(Y==="object"&&X)for(let G in X)p$(Q,G,X[G].default);else if(Y==="array"&&Array.isArray(W))W.forEach((G,$)=>p$(Q,$,G.default))}i$.assignDefaults=NK;function p$(Q,Y,X){let{gen:W,compositeRule:G,data:$,opts:J}=Q;if(X===void 0)return;let z=u1._`${$}${(0,u1.getProperty)(Y)}`;if(G){(0,ZK.checkStrictMode)(Q,`default is ignored for: ${z}`);return}let H=u1._`${z} === undefined`;if(J.useDefaults==="empty")H=u1._`${H} || ${z} === null || ${z} === ""`;W.if(H,u1._`${z} = ${(0,u1.stringify)(X)}`)}});var I0=w((t$)=>{Object.defineProperty(t$,"__esModule",{value:!0});t$.validateUnion=t$.validateArray=t$.usePattern=t$.callValidateCode=t$.schemaProperties=t$.allSchemaProperties=t$.noPropertyInData=t$.propertyInData=t$.isOwnProperty=t$.hasPropFunc=t$.reportMissingProp=t$.checkMissingProp=t$.checkReportMissingProp=void 0;var d=v(),n9=l(),B1=r0(),wK=l();function bK(Q,Y){let{gen:X,data:W,it:G}=Q;X.if(d9(X,W,Y,G.opts.ownProperties),()=>{Q.setParams({missingProperty:d._`${Y}`},!0),Q.error()})}t$.checkReportMissingProp=bK;function jK({gen:Q,data:Y,it:{opts:X}},W,G){return(0,d.or)(...W.map(($)=>(0,d.and)(d9(Q,Y,$,X.ownProperties),d._`${G} = ${$}`)))}t$.checkMissingProp=jK;function PK(Q,Y){Q.setParams({missingProperty:Y},!0),Q.error()}t$.reportMissingProp=PK;function d$(Q){return Q.scopeValue("func",{ref:Object.prototype.hasOwnProperty,code:d._`Object.prototype.hasOwnProperty`})}t$.hasPropFunc=d$;function r9(Q,Y,X){return d._`${d$(Q)}.call(${Y}, ${X})`}t$.isOwnProperty=r9;function IK(Q,Y,X,W){let G=d._`${Y}${(0,d.getProperty)(X)} !== undefined`;return W?d._`${G} && ${r9(Q,Y,X)}`:G}t$.propertyInData=IK;function d9(Q,Y,X,W){let G=d._`${Y}${(0,d.getProperty)(X)} === undefined`;return W?(0,d.or)(G,(0,d.not)(r9(Q,Y,X))):G}t$.noPropertyInData=d9;function o$(Q){return Q?Object.keys(Q).filter((Y)=>Y!=="__proto__"):[]}t$.allSchemaProperties=o$;function EK(Q,Y){return o$(Y).filter((X)=>!(0,n9.alwaysValidSchema)(Q,Y[X]))}t$.schemaProperties=EK;function TK({schemaCode:Q,data:Y,it:{gen:X,topSchemaRef:W,schemaPath:G,errorPath:$},it:J},z,H,U){let A=U?d._`${Q}, ${Y}, ${W}${G}`:Y,B=[[B1.default.instancePath,(0,d.strConcat)(B1.default.instancePath,$)],[B1.default.parentData,J.parentData],[B1.default.parentDataProperty,J.parentDataProperty],[B1.default.rootData,B1.default.rootData]];if(J.opts.dynamicRef)B.push([B1.default.dynamicAnchors,B1.default.dynamicAnchors]);let K=d._`${A}, ${X.object(...B)}`;return H!==d.nil?d._`${z}.call(${H}, ${K})`:d._`${z}(${K})`}t$.callValidateCode=TK;var SK=d._`new RegExp`;function RK({gen:Q,it:{opts:Y}},X){let W=Y.unicodeRegExp?"u":"",{regExp:G}=Y.code,$=G(X,W);return Q.scopeValue("pattern",{key:$.toString(),ref:$,code:d._`${G.code==="new RegExp"?SK:(0,wK.useFunc)(Q,G)}(${X}, ${W})`})}t$.usePattern=RK;function CK(Q){let{gen:Y,data:X,keyword:W,it:G}=Q,$=Y.name("valid");if(G.allErrors){let z=Y.let("valid",!0);return J(()=>Y.assign(z,!1)),z}return Y.var($,!0),J(()=>Y.break()),$;function J(z){let H=Y.const("len",d._`${X}.length`);Y.forRange("i",0,H,(U)=>{Q.subschema({keyword:W,dataProp:U,dataPropType:n9.Type.Num},$),Y.if((0,d.not)($),z)})}}t$.validateArray=CK;function kK(Q){let{gen:Y,schema:X,keyword:W,it:G}=Q;if(!Array.isArray(X))throw Error("ajv implementation error");if(X.some((H)=>(0,n9.alwaysValidSchema)(G,H))&&!G.opts.unevaluated)return;let J=Y.let("valid",!1),z=Y.name("_valid");Y.block(()=>X.forEach((H,U)=>{let A=Q.subschema({keyword:W,schemaProp:U,compositeRule:!0},z);if(Y.assign(J,d._`${J} || ${z}`),!Q.mergeValidEvaluated(A,z))Y.if((0,d.not)(J))})),Q.result(J,()=>Q.reset(),()=>Q.error(!0))}t$.validateUnion=kK});var XJ=w((QJ)=>{Object.defineProperty(QJ,"__esModule",{value:!0});QJ.validateKeywordUsage=QJ.validSchemaType=QJ.funcKeywordCode=QJ.macroKeywordCode=void 0;var L0=v(),N1=r0(),iK=I0(),nK=w4();function rK(Q,Y){let{gen:X,keyword:W,schema:G,parentSchema:$,it:J}=Q,z=Y.macro.call(J.self,G,$,J),H=e$(X,W,z);if(J.opts.validateSchema!==!1)J.self.validateSchema(z,!0);let U=X.name("valid");Q.subschema({schema:z,schemaPath:L0.nil,errSchemaPath:`${J.errSchemaPath}/${W}`,topSchemaRef:H,compositeRule:!0},U),Q.pass(U,()=>Q.error(!0))}QJ.macroKeywordCode=rK;function dK(Q,Y){var X;let{gen:W,keyword:G,schema:$,parentSchema:J,$data:z,it:H}=Q;tK(H,Y);let U=!z&&Y.compile?Y.compile.call(H.self,$,J,H):Y.validate,A=e$(W,G,U),B=W.let("valid");Q.block$data(B,K),Q.ok((X=Y.valid)!==null&&X!==void 0?X:B);function K(){if(Y.errors===!1){if(M(),Y.modifying)s$(Q);Z(()=>Q.error())}else{let V=Y.async?L():O();if(Y.modifying)s$(Q);Z(()=>oK(Q,V))}}function L(){let V=W.let("ruleErrs",null);return W.try(()=>M(L0._`await `),(S)=>W.assign(B,!1).if(L0._`${S} instanceof ${H.ValidationError}`,()=>W.assign(V,L0._`${S}.errors`),()=>W.throw(S))),V}function O(){let V=L0._`${A}.errors`;return W.assign(V,null),M(L0.nil),V}function M(V=Y.async?L0._`await `:L0.nil){let S=H.opts.passContext?N1.default.this:N1.default.self,E=!(("compile"in Y)&&!z||Y.schema===!1);W.assign(B,L0._`${V}${(0,iK.callValidateCode)(Q,A,S,E)}`,Y.modifying)}function Z(V){var S;W.if((0,L0.not)((S=Y.valid)!==null&&S!==void 0?S:B),V)}}QJ.funcKeywordCode=dK;function s$(Q){let{gen:Y,data:X,it:W}=Q;Y.if(W.parentData,()=>Y.assign(X,L0._`${W.parentData}[${W.parentDataProperty}]`))}function oK(Q,Y){let{gen:X}=Q;X.if(L0._`Array.isArray(${Y})`,()=>{X.assign(N1.default.vErrors,L0._`${N1.default.vErrors} === null ? ${Y} : ${N1.default.vErrors}.concat(${Y})`).assign(N1.default.errors,L0._`${N1.default.vErrors}.length`),(0,nK.extendErrors)(Q)},()=>Q.error())}function tK({schemaEnv:Q},Y){if(Y.async&&!Q.$async)throw Error("async keyword in sync schema")}function e$(Q,Y,X){if(X===void 0)throw Error(`keyword "${Y}" failed to compile`);return Q.scopeValue("keyword",typeof X=="function"?{ref:X}:{ref:X,code:(0,L0.stringify)(X)})}function aK(Q,Y,X=!1){return!Y.length||Y.some((W)=>W==="array"?Array.isArray(Q):W==="object"?Q&&typeof Q=="object"&&!Array.isArray(Q):typeof Q==W||X&&typeof Q>"u")}QJ.validSchemaType=aK;function sK({schema:Q,opts:Y,self:X,errSchemaPath:W},G,$){if(Array.isArray(G.keyword)?!G.keyword.includes($):G.keyword!==$)throw Error("ajv implementation error");let J=G.dependencies;if(J===null||J===void 0?void 0:J.some((z)=>!Object.prototype.hasOwnProperty.call(Q,z)))throw Error(`parent schema must have dependencies of ${$}: ${J.join(",")}`);if(G.validateSchema){if(!G.validateSchema(Q[$])){let H=`keyword "${$}" value is invalid at path "${W}": `+X.errorsText(G.validateSchema.errors);if(Y.validateSchema==="log")X.logger.error(H);else throw Error(H)}}}QJ.validateKeywordUsage=sK});var JJ=w((GJ)=>{Object.defineProperty(GJ,"__esModule",{value:!0});GJ.extendSubschemaMode=GJ.extendSubschemaData=GJ.getSubschema=void 0;var g0=v(),WJ=l();function XD(Q,{keyword:Y,schemaProp:X,schema:W,schemaPath:G,errSchemaPath:$,topSchemaRef:J}){if(Y!==void 0&&W!==void 0)throw Error('both "keyword" and "schema" passed, only one allowed');if(Y!==void 0){let z=Q.schema[Y];return X===void 0?{schema:z,schemaPath:g0._`${Q.schemaPath}${(0,g0.getProperty)(Y)}`,errSchemaPath:`${Q.errSchemaPath}/${Y}`}:{schema:z[X],schemaPath:g0._`${Q.schemaPath}${(0,g0.getProperty)(Y)}${(0,g0.getProperty)(X)}`,errSchemaPath:`${Q.errSchemaPath}/${Y}/${(0,WJ.escapeFragment)(X)}`}}if(W!==void 0){if(G===void 0||$===void 0||J===void 0)throw Error('"schemaPath", "errSchemaPath" and "topSchemaRef" are required with "schema"');return{schema:W,schemaPath:G,topSchemaRef:J,errSchemaPath:$}}throw Error('either "keyword" or "schema" must be passed')}GJ.getSubschema=XD;function WD(Q,Y,{dataProp:X,dataPropType:W,data:G,dataTypes:$,propertyName:J}){if(G!==void 0&&X!==void 0)throw Error('both "data" and "dataProp" passed, only one allowed');let{gen:z}=Y;if(X!==void 0){let{errorPath:U,dataPathArr:A,opts:B}=Y,K=z.let("data",g0._`${Y.data}${(0,g0.getProperty)(X)}`,!0);H(K),Q.errorPath=g0.str`${U}${(0,WJ.getErrorPath)(X,W,B.jsPropertySyntax)}`,Q.parentDataProperty=g0._`${X}`,Q.dataPathArr=[...A,Q.parentDataProperty]}if(G!==void 0){let U=G instanceof g0.Name?G:z.let("data",G,!0);if(H(U),J!==void 0)Q.propertyName=J}if($)Q.dataTypes=$;function H(U){Q.data=U,Q.dataLevel=Y.dataLevel+1,Q.dataTypes=[],Y.definedProperties=new Set,Q.parentData=Y.data,Q.dataNames=[...Y.dataNames,U]}}GJ.extendSubschemaData=WD;function GD(Q,{jtdDiscriminator:Y,jtdMetadata:X,compositeRule:W,createErrors:G,allErrors:$}){if(W!==void 0)Q.compositeRule=W;if(G!==void 0)Q.createErrors=G;if($!==void 0)Q.allErrors=$;Q.jtdDiscriminator=Y,Q.jtdMetadata=X}GJ.extendSubschemaMode=GD});var o9=w((SP,zJ)=>{zJ.exports=function Q(Y,X){if(Y===X)return!0;if(Y&&X&&typeof Y=="object"&&typeof X=="object"){if(Y.constructor!==X.constructor)return!1;var W,G,$;if(Array.isArray(Y)){if(W=Y.length,W!=X.length)return!1;for(G=W;G--!==0;)if(!Q(Y[G],X[G]))return!1;return!0}if(Y.constructor===RegExp)return Y.source===X.source&&Y.flags===X.flags;if(Y.valueOf!==Object.prototype.valueOf)return Y.valueOf()===X.valueOf();if(Y.toString!==Object.prototype.toString)return Y.toString()===X.toString();if($=Object.keys(Y),W=$.length,W!==Object.keys(X).length)return!1;for(G=W;G--!==0;)if(!Object.prototype.hasOwnProperty.call(X,$[G]))return!1;for(G=W;G--!==0;){var J=$[G];if(!Q(Y[J],X[J]))return!1}return!0}return Y!==Y&&X!==X}});var UJ=w((RP,HJ)=>{var K1=HJ.exports=function(Q,Y,X){if(typeof Y=="function")X=Y,Y={};X=Y.cb||X;var W=typeof X=="function"?X:X.pre||function(){},G=X.post||function(){};l6(Y,W,G,Q,"",Q)};K1.keywords={additionalItems:!0,items:!0,contains:!0,additionalProperties:!0,propertyNames:!0,not:!0,if:!0,then:!0,else:!0};K1.arrayKeywords={items:!0,allOf:!0,anyOf:!0,oneOf:!0};K1.propsKeywords={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependencies:!0};K1.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 l6(Q,Y,X,W,G,$,J,z,H,U){if(W&&typeof W=="object"&&!Array.isArray(W)){Y(W,G,$,J,z,H,U);for(var A in W){var B=W[A];if(Array.isArray(B)){if(A in K1.arrayKeywords)for(var K=0;K<B.length;K++)l6(Q,Y,X,B[K],G+"/"+A+"/"+K,$,G,A,W,K)}else if(A in K1.propsKeywords){if(B&&typeof B=="object")for(var L in B)l6(Q,Y,X,B[L],G+"/"+A+"/"+zD(L),$,G,A,W,L)}else if(A in K1.keywords||Q.allKeys&&!(A in K1.skipKeywords))l6(Q,Y,X,B,G+"/"+A,$,G,A,W)}X(W,G,$,J,z,H,U)}}function zD(Q){return Q.replace(/~/g,"~0").replace(/\//g,"~1")}});var j4=w((DJ)=>{Object.defineProperty(DJ,"__esModule",{value:!0});DJ.getSchemaRefs=DJ.resolveUrl=DJ.normalizeId=DJ._getFullPath=DJ.getFullPath=DJ.inlineRef=void 0;var HD=l(),UD=o9(),AD=UJ(),BD=new Set(["type","format","pattern","maxLength","minLength","maxProperties","minProperties","maxItems","minItems","maximum","minimum","uniqueItems","multipleOf","required","enum","const"]);function KD(Q,Y=!0){if(typeof Q=="boolean")return!0;if(Y===!0)return!t9(Q);if(!Y)return!1;return AJ(Q)<=Y}DJ.inlineRef=KD;var DD=new Set(["$ref","$recursiveRef","$recursiveAnchor","$dynamicRef","$dynamicAnchor"]);function t9(Q){for(let Y in Q){if(DD.has(Y))return!0;let X=Q[Y];if(Array.isArray(X)&&X.some(t9))return!0;if(typeof X=="object"&&t9(X))return!0}return!1}function AJ(Q){let Y=0;for(let X in Q){if(X==="$ref")return 1/0;if(Y++,BD.has(X))continue;if(typeof Q[X]=="object")(0,HD.eachItem)(Q[X],(W)=>Y+=AJ(W));if(Y===1/0)return 1/0}return Y}function BJ(Q,Y="",X){if(X!==!1)Y=h1(Y);let W=Q.parse(Y);return KJ(Q,W)}DJ.getFullPath=BJ;function KJ(Q,Y){return Q.serialize(Y).split("#")[0]+"#"}DJ._getFullPath=KJ;var LD=/#\/?$/;function h1(Q){return Q?Q.replace(LD,""):""}DJ.normalizeId=h1;function qD(Q,Y,X){return X=h1(X),Q.resolve(Y,X)}DJ.resolveUrl=qD;var FD=/^[a-z_][-a-z0-9._]*$/i;function OD(Q,Y){if(typeof Q=="boolean")return{};let{schemaId:X,uriResolver:W}=this.opts,G=h1(Q[X]||Y),$={"":G},J=BJ(W,G,!1),z={},H=new Set;return AD(Q,{allKeys:!0},(B,K,L,O)=>{if(O===void 0)return;let M=J+K,Z=$[O];if(typeof B[X]=="string")Z=V.call(this,B[X]);S.call(this,B.$anchor),S.call(this,B.$dynamicAnchor),$[K]=Z;function V(E){let _=this.opts.uriResolver.resolve;if(E=h1(Z?_(Z,E):E),H.has(E))throw A(E);H.add(E);let T=this.refs[E];if(typeof T=="string")T=this.refs[T];if(typeof T=="object")U(B,T.schema,E);else if(E!==h1(M))if(E[0]==="#")U(B,z[E],E),z[E]=B;else this.refs[E]=M;return E}function S(E){if(typeof E=="string"){if(!FD.test(E))throw Error(`invalid anchor "${E}"`);V.call(this,`#${E}`)}}}),z;function U(B,K,L){if(K!==void 0&&!UD(B,K))throw A(L)}function A(B){return Error(`reference "${B}" resolves to more than one schema`)}}DJ.getSchemaRefs=OD});var E4=w((SJ)=>{Object.defineProperty(SJ,"__esModule",{value:!0});SJ.getData=SJ.KeywordCxt=SJ.validateFunctionCode=void 0;var VJ=k$(),qJ=b4(),s9=m9(),m6=b4(),bD=r$(),I4=XJ(),a9=JJ(),P=v(),R=r0(),jD=j4(),d0=l(),P4=w4();function PD(Q){if(wJ(Q)){if(bJ(Q),NJ(Q)){TD(Q);return}}ZJ(Q,()=>(0,VJ.topBoolOrEmptySchema)(Q))}SJ.validateFunctionCode=PD;function ZJ({gen:Q,validateName:Y,schema:X,schemaEnv:W,opts:G},$){if(G.code.es5)Q.func(Y,P._`${R.default.data}, ${R.default.valCxt}`,W.$async,()=>{Q.code(P._`"use strict"; ${FJ(X,G)}`),ED(Q,G),Q.code($)});else Q.func(Y,P._`${R.default.data}, ${ID(G)}`,W.$async,()=>Q.code(FJ(X,G)).code($))}function ID(Q){return P._`{${R.default.instancePath}="", ${R.default.parentData}, ${R.default.parentDataProperty}, ${R.default.rootData}=${R.default.data}${Q.dynamicRef?P._`, ${R.default.dynamicAnchors}={}`:P.nil}}={}`}function ED(Q,Y){Q.if(R.default.valCxt,()=>{if(Q.var(R.default.instancePath,P._`${R.default.valCxt}.${R.default.instancePath}`),Q.var(R.default.parentData,P._`${R.default.valCxt}.${R.default.parentData}`),Q.var(R.default.parentDataProperty,P._`${R.default.valCxt}.${R.default.parentDataProperty}`),Q.var(R.default.rootData,P._`${R.default.valCxt}.${R.default.rootData}`),Y.dynamicRef)Q.var(R.default.dynamicAnchors,P._`${R.default.valCxt}.${R.default.dynamicAnchors}`)},()=>{if(Q.var(R.default.instancePath,P._`""`),Q.var(R.default.parentData,P._`undefined`),Q.var(R.default.parentDataProperty,P._`undefined`),Q.var(R.default.rootData,R.default.data),Y.dynamicRef)Q.var(R.default.dynamicAnchors,P._`{}`)})}function TD(Q){let{schema:Y,opts:X,gen:W}=Q;ZJ(Q,()=>{if(X.$comment&&Y.$comment)PJ(Q);if(vD(Q),W.let(R.default.vErrors,null),W.let(R.default.errors,0),X.unevaluated)SD(Q);jJ(Q),yD(Q)});return}function SD(Q){let{gen:Y,validateName:X}=Q;Q.evaluated=Y.const("evaluated",P._`${X}.evaluated`),Y.if(P._`${Q.evaluated}.dynamicProps`,()=>Y.assign(P._`${Q.evaluated}.props`,P._`undefined`)),Y.if(P._`${Q.evaluated}.dynamicItems`,()=>Y.assign(P._`${Q.evaluated}.items`,P._`undefined`))}function FJ(Q,Y){let X=typeof Q=="object"&&Q[Y.schemaId];return X&&(Y.code.source||Y.code.process)?P._`/*# sourceURL=${X} */`:P.nil}function RD(Q,Y){if(wJ(Q)){if(bJ(Q),NJ(Q)){CD(Q,Y);return}}(0,VJ.boolOrEmptySchema)(Q,Y)}function NJ({schema:Q,self:Y}){if(typeof Q=="boolean")return!Q;for(let X in Q)if(Y.RULES.all[X])return!0;return!1}function wJ(Q){return typeof Q.schema!="boolean"}function CD(Q,Y){let{schema:X,gen:W,opts:G}=Q;if(G.$comment&&X.$comment)PJ(Q);xD(Q),_D(Q);let $=W.const("_errs",R.default.errors);jJ(Q,$),W.var(Y,P._`${$} === ${R.default.errors}`)}function bJ(Q){(0,d0.checkUnknownRules)(Q),kD(Q)}function jJ(Q,Y){if(Q.opts.jtd)return OJ(Q,[],!1,Y);let X=(0,qJ.getSchemaTypes)(Q.schema),W=(0,qJ.coerceAndCheckDataType)(Q,X);OJ(Q,X,!W,Y)}function kD(Q){let{schema:Y,errSchemaPath:X,opts:W,self:G}=Q;if(Y.$ref&&W.ignoreKeywordsWithRef&&(0,d0.schemaHasRulesButRef)(Y,G.RULES))G.logger.warn(`$ref: keywords ignored in schema at path "${X}"`)}function vD(Q){let{schema:Y,opts:X}=Q;if(Y.default!==void 0&&X.useDefaults&&X.strictSchema)(0,d0.checkStrictMode)(Q,"default is ignored in the schema root")}function xD(Q){let Y=Q.schema[Q.opts.schemaId];if(Y)Q.baseId=(0,jD.resolveUrl)(Q.opts.uriResolver,Q.baseId,Y)}function _D(Q){if(Q.schema.$async&&!Q.schemaEnv.$async)throw Error("async schema in sync schema")}function PJ({gen:Q,schemaEnv:Y,schema:X,errSchemaPath:W,opts:G}){let $=X.$comment;if(G.$comment===!0)Q.code(P._`${R.default.self}.logger.log(${$})`);else if(typeof G.$comment=="function"){let J=P.str`${W}/$comment`,z=Q.scopeValue("root",{ref:Y.root});Q.code(P._`${R.default.self}.opts.$comment(${$}, ${J}, ${z}.schema)`)}}function yD(Q){let{gen:Y,schemaEnv:X,validateName:W,ValidationError:G,opts:$}=Q;if(X.$async)Y.if(P._`${R.default.errors} === 0`,()=>Y.return(R.default.data),()=>Y.throw(P._`new ${G}(${R.default.vErrors})`));else{if(Y.assign(P._`${W}.errors`,R.default.vErrors),$.unevaluated)gD(Q);Y.return(P._`${R.default.errors} === 0`)}}function gD({gen:Q,evaluated:Y,props:X,items:W}){if(X instanceof P.Name)Q.assign(P._`${Y}.props`,X);if(W instanceof P.Name)Q.assign(P._`${Y}.items`,W)}function OJ(Q,Y,X,W){let{gen:G,schema:$,data:J,allErrors:z,opts:H,self:U}=Q,{RULES:A}=U;if($.$ref&&(H.ignoreKeywordsWithRef||!(0,d0.schemaHasRulesButRef)($,A))){G.block(()=>EJ(Q,"$ref",A.all.$ref.definition));return}if(!H.jtd)uD(Q,Y);G.block(()=>{for(let K of A.rules)B(K);B(A.post)});function B(K){if(!(0,s9.shouldUseGroup)($,K))return;if(K.type){if(G.if((0,m6.checkDataType)(K.type,J,H.strictNumbers)),MJ(Q,K),Y.length===1&&Y[0]===K.type&&X)G.else(),(0,m6.reportTypeError)(Q);G.endIf()}else MJ(Q,K);if(!z)G.if(P._`${R.default.errors} === ${W||0}`)}}function MJ(Q,Y){let{gen:X,schema:W,opts:{useDefaults:G}}=Q;if(G)(0,bD.assignDefaults)(Q,Y.type);X.block(()=>{for(let $ of Y.rules)if((0,s9.shouldUseRule)(W,$))EJ(Q,$.keyword,$.definition,Y.type)})}function uD(Q,Y){if(Q.schemaEnv.meta||!Q.opts.strictTypes)return;if(hD(Q,Y),!Q.opts.allowUnionTypes)fD(Q,Y);lD(Q,Q.dataTypes)}function hD(Q,Y){if(!Y.length)return;if(!Q.dataTypes.length){Q.dataTypes=Y;return}Y.forEach((X)=>{if(!IJ(Q.dataTypes,X))e9(Q,`type "${X}" not allowed by context "${Q.dataTypes.join(",")}"`)}),cD(Q,Y)}function fD(Q,Y){if(Y.length>1&&!(Y.length===2&&Y.includes("null")))e9(Q,"use allowUnionTypes to allow union type keyword")}function lD(Q,Y){let X=Q.self.RULES.all;for(let W in X){let G=X[W];if(typeof G=="object"&&(0,s9.shouldUseRule)(Q.schema,G)){let{type:$}=G.definition;if($.length&&!$.some((J)=>mD(Y,J)))e9(Q,`missing type "${$.join(",")}" for keyword "${W}"`)}}}function mD(Q,Y){return Q.includes(Y)||Y==="number"&&Q.includes("integer")}function IJ(Q,Y){return Q.includes(Y)||Y==="integer"&&Q.includes("number")}function cD(Q,Y){let X=[];for(let W of Q.dataTypes)if(IJ(Y,W))X.push(W);else if(Y.includes("integer")&&W==="number")X.push("integer");Q.dataTypes=X}function e9(Q,Y){let X=Q.schemaEnv.baseId+Q.errSchemaPath;Y+=` at "${X}" (strictTypes)`,(0,d0.checkStrictMode)(Q,Y,Q.opts.strictTypes)}class QY{constructor(Q,Y,X){if((0,I4.validateKeywordUsage)(Q,Y,X),this.gen=Q.gen,this.allErrors=Q.allErrors,this.keyword=X,this.data=Q.data,this.schema=Q.schema[X],this.$data=Y.$data&&Q.opts.$data&&this.schema&&this.schema.$data,this.schemaValue=(0,d0.schemaRefOrVal)(Q,this.schema,X,this.$data),this.schemaType=Y.schemaType,this.parentSchema=Q.schema,this.params={},this.it=Q,this.def=Y,this.$data)this.schemaCode=Q.gen.const("vSchema",TJ(this.$data,Q));else if(this.schemaCode=this.schemaValue,!(0,I4.validSchemaType)(this.schema,Y.schemaType,Y.allowUndefined))throw Error(`${X} value must be ${JSON.stringify(Y.schemaType)}`);if("code"in Y?Y.trackErrors:Y.errors!==!1)this.errsCount=Q.gen.const("_errs",R.default.errors)}result(Q,Y,X){this.failResult((0,P.not)(Q),Y,X)}failResult(Q,Y,X){if(this.gen.if(Q),X)X();else this.error();if(Y){if(this.gen.else(),Y(),this.allErrors)this.gen.endIf()}else if(this.allErrors)this.gen.endIf();else this.gen.else()}pass(Q,Y){this.failResult((0,P.not)(Q),void 0,Y)}fail(Q){if(Q===void 0){if(this.error(),!this.allErrors)this.gen.if(!1);return}if(this.gen.if(Q),this.error(),this.allErrors)this.gen.endIf();else this.gen.else()}fail$data(Q){if(!this.$data)return this.fail(Q);let{schemaCode:Y}=this;this.fail(P._`${Y} !== undefined && (${(0,P.or)(this.invalid$data(),Q)})`)}error(Q,Y,X){if(Y){this.setParams(Y),this._error(Q,X),this.setParams({});return}this._error(Q,X)}_error(Q,Y){(Q?P4.reportExtraError:P4.reportError)(this,this.def.error,Y)}$dataError(){(0,P4.reportError)(this,this.def.$dataError||P4.keyword$DataError)}reset(){if(this.errsCount===void 0)throw Error('add "trackErrors" to keyword definition');(0,P4.resetErrorsCount)(this.gen,this.errsCount)}ok(Q){if(!this.allErrors)this.gen.if(Q)}setParams(Q,Y){if(Y)Object.assign(this.params,Q);else this.params=Q}block$data(Q,Y,X=P.nil){this.gen.block(()=>{this.check$data(Q,X),Y()})}check$data(Q=P.nil,Y=P.nil){if(!this.$data)return;let{gen:X,schemaCode:W,schemaType:G,def:$}=this;if(X.if((0,P.or)(P._`${W} === undefined`,Y)),Q!==P.nil)X.assign(Q,!0);if(G.length||$.validateSchema){if(X.elseIf(this.invalid$data()),this.$dataError(),Q!==P.nil)X.assign(Q,!1)}X.else()}invalid$data(){let{gen:Q,schemaCode:Y,schemaType:X,def:W,it:G}=this;return(0,P.or)($(),J());function $(){if(X.length){if(!(Y instanceof P.Name))throw Error("ajv implementation error");let z=Array.isArray(X)?X:[X];return P._`${(0,m6.checkDataTypes)(z,Y,G.opts.strictNumbers,m6.DataType.Wrong)}`}return P.nil}function J(){if(W.validateSchema){let z=Q.scopeValue("validate$data",{ref:W.validateSchema});return P._`!${z}(${Y})`}return P.nil}}subschema(Q,Y){let X=(0,a9.getSubschema)(this.it,Q);(0,a9.extendSubschemaData)(X,this.it,Q),(0,a9.extendSubschemaMode)(X,Q);let W={...this.it,...X,items:void 0,props:void 0};return RD(W,Y),W}mergeEvaluated(Q,Y){let{it:X,gen:W}=this;if(!X.opts.unevaluated)return;if(X.props!==!0&&Q.props!==void 0)X.props=d0.mergeEvaluated.props(W,Q.props,X.props,Y);if(X.items!==!0&&Q.items!==void 0)X.items=d0.mergeEvaluated.items(W,Q.items,X.items,Y)}mergeValidEvaluated(Q,Y){let{it:X,gen:W}=this;if(X.opts.unevaluated&&(X.props!==!0||X.items!==!0))return W.if(Y,()=>this.mergeEvaluated(Q,P.Name)),!0}}SJ.KeywordCxt=QY;function EJ(Q,Y,X,W){let G=new QY(Q,X,Y);if("code"in X)X.code(G,W);else if(G.$data&&X.validate)(0,I4.funcKeywordCode)(G,X);else if("macro"in X)(0,I4.macroKeywordCode)(G,X);else if(X.compile||X.validate)(0,I4.funcKeywordCode)(G,X)}var pD=/^\/(?:[^~]|~0|~1)*$/,iD=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function TJ(Q,{dataLevel:Y,dataNames:X,dataPathArr:W}){let G,$;if(Q==="")return R.default.rootData;if(Q[0]==="/"){if(!pD.test(Q))throw Error(`Invalid JSON-pointer: ${Q}`);G=Q,$=R.default.rootData}else{let U=iD.exec(Q);if(!U)throw Error(`Invalid JSON-pointer: ${Q}`);let A=+U[1];if(G=U[2],G==="#"){if(A>=Y)throw Error(H("property/index",A));return W[Y-A]}if(A>Y)throw Error(H("data",A));if($=X[Y-A],!G)return $}let J=$,z=G.split("/");for(let U of z)if(U)$=P._`${$}${(0,P.getProperty)((0,d0.unescapeJsonPointer)(U))}`,J=P._`${J} && ${$}`;return J;function H(U,A){return`Cannot access ${U} ${A} levels up, current level is ${Y}`}}SJ.getData=TJ});var c6=w((kJ)=>{Object.defineProperty(kJ,"__esModule",{value:!0});class CJ extends Error{constructor(Q){super("validation failed");this.errors=Q,this.ajv=this.validation=!0}}kJ.default=CJ});var T4=w((xJ)=>{Object.defineProperty(xJ,"__esModule",{value:!0});var YY=j4();class vJ extends Error{constructor(Q,Y,X,W){super(W||`can't resolve reference ${X} from id ${Y}`);this.missingRef=(0,YY.resolveUrl)(Q,Y,X),this.missingSchema=(0,YY.normalizeId)((0,YY.getFullPath)(Q,this.missingRef))}}xJ.default=vJ});var i6=w((gJ)=>{Object.defineProperty(gJ,"__esModule",{value:!0});gJ.resolveSchema=gJ.getCompilingSchema=gJ.resolveRef=gJ.compileSchema=gJ.SchemaEnv=void 0;var k0=v(),tD=c6(),w1=r0(),v0=j4(),_J=l(),aD=E4();class S4{constructor(Q){var Y;this.refs={},this.dynamicAnchors={};let X;if(typeof Q.schema=="object")X=Q.schema;this.schema=Q.schema,this.schemaId=Q.schemaId,this.root=Q.root||this,this.baseId=(Y=Q.baseId)!==null&&Y!==void 0?Y:(0,v0.normalizeId)(X===null||X===void 0?void 0:X[Q.schemaId||"$id"]),this.schemaPath=Q.schemaPath,this.localRefs=Q.localRefs,this.meta=Q.meta,this.$async=X===null||X===void 0?void 0:X.$async,this.refs={}}}gJ.SchemaEnv=S4;function WY(Q){let Y=yJ.call(this,Q);if(Y)return Y;let X=(0,v0.getFullPath)(this.opts.uriResolver,Q.root.baseId),{es5:W,lines:G}=this.opts.code,{ownProperties:$}=this.opts,J=new k0.CodeGen(this.scope,{es5:W,lines:G,ownProperties:$}),z;if(Q.$async)z=J.scopeValue("Error",{ref:tD.default,code:k0._`require("ajv/dist/runtime/validation_error").default`});let H=J.scopeName("validate");Q.validateName=H;let U={gen:J,allErrors:this.opts.allErrors,data:w1.default.data,parentData:w1.default.parentData,parentDataProperty:w1.default.parentDataProperty,dataNames:[w1.default.data],dataPathArr:[k0.nil],dataLevel:0,dataTypes:[],definedProperties:new Set,topSchemaRef:J.scopeValue("schema",this.opts.code.source===!0?{ref:Q.schema,code:(0,k0.stringify)(Q.schema)}:{ref:Q.schema}),validateName:H,ValidationError:z,schema:Q.schema,schemaEnv:Q,rootId:X,baseId:Q.baseId||X,schemaPath:k0.nil,errSchemaPath:Q.schemaPath||(this.opts.jtd?"":"#"),errorPath:k0._`""`,opts:this.opts,self:this},A;try{this._compilations.add(Q),(0,aD.validateFunctionCode)(U),J.optimize(this.opts.code.optimize);let B=J.toString();if(A=`${J.scopeRefs(w1.default.scope)}return ${B}`,this.opts.code.process)A=this.opts.code.process(A,Q);let L=Function(`${w1.default.self}`,`${w1.default.scope}`,A)(this,this.scope.get());if(this.scope.value(H,{ref:L}),L.errors=null,L.schema=Q.schema,L.schemaEnv=Q,Q.$async)L.$async=!0;if(this.opts.code.source===!0)L.source={validateName:H,validateCode:B,scopeValues:J._values};if(this.opts.unevaluated){let{props:O,items:M}=U;if(L.evaluated={props:O instanceof k0.Name?void 0:O,items:M instanceof k0.Name?void 0:M,dynamicProps:O instanceof k0.Name,dynamicItems:M instanceof k0.Name},L.source)L.source.evaluated=(0,k0.stringify)(L.evaluated)}return Q.validate=L,Q}catch(B){if(delete Q.validate,delete Q.validateName,A)this.logger.error("Error compiling schema, function code:",A);throw B}finally{this._compilations.delete(Q)}}gJ.compileSchema=WY;function sD(Q,Y,X){var W;X=(0,v0.resolveUrl)(this.opts.uriResolver,Y,X);let G=Q.refs[X];if(G)return G;let $=YL.call(this,Q,X);if($===void 0){let J=(W=Q.localRefs)===null||W===void 0?void 0:W[X],{schemaId:z}=this.opts;if(J)$=new S4({schema:J,schemaId:z,root:Q,baseId:Y})}if($===void 0)return;return Q.refs[X]=eD.call(this,$)}gJ.resolveRef=sD;function eD(Q){if((0,v0.inlineRef)(Q.schema,this.opts.inlineRefs))return Q.schema;return Q.validate?Q:WY.call(this,Q)}function yJ(Q){for(let Y of this._compilations)if(QL(Y,Q))return Y}gJ.getCompilingSchema=yJ;function QL(Q,Y){return Q.schema===Y.schema&&Q.root===Y.root&&Q.baseId===Y.baseId}function YL(Q,Y){let X;while(typeof(X=this.refs[Y])=="string")Y=X;return X||this.schemas[Y]||p6.call(this,Q,Y)}function p6(Q,Y){let X=this.opts.uriResolver.parse(Y),W=(0,v0._getFullPath)(this.opts.uriResolver,X),G=(0,v0.getFullPath)(this.opts.uriResolver,Q.baseId,void 0);if(Object.keys(Q.schema).length>0&&W===G)return XY.call(this,X,Q);let $=(0,v0.normalizeId)(W),J=this.refs[$]||this.schemas[$];if(typeof J=="string"){let z=p6.call(this,Q,J);if(typeof(z===null||z===void 0?void 0:z.schema)!=="object")return;return XY.call(this,X,z)}if(typeof(J===null||J===void 0?void 0:J.schema)!=="object")return;if(!J.validate)WY.call(this,J);if($===(0,v0.normalizeId)(Y)){let{schema:z}=J,{schemaId:H}=this.opts,U=z[H];if(U)G=(0,v0.resolveUrl)(this.opts.uriResolver,G,U);return new S4({schema:z,schemaId:H,root:Q,baseId:G})}return XY.call(this,X,J)}gJ.resolveSchema=p6;var XL=new Set(["properties","patternProperties","enum","dependencies","definitions"]);function XY(Q,{baseId:Y,schema:X,root:W}){var G;if(((G=Q.fragment)===null||G===void 0?void 0:G[0])!=="/")return;for(let z of Q.fragment.slice(1).split("/")){if(typeof X==="boolean")return;let H=X[(0,_J.unescapeFragment)(z)];if(H===void 0)return;X=H;let U=typeof X==="object"&&X[this.opts.schemaId];if(!XL.has(z)&&U)Y=(0,v0.resolveUrl)(this.opts.uriResolver,Y,U)}let $;if(typeof X!="boolean"&&X.$ref&&!(0,_J.schemaHasRulesButRef)(X,this.RULES)){let z=(0,v0.resolveUrl)(this.opts.uriResolver,Y,X.$ref);$=p6.call(this,W,z)}let{schemaId:J}=this.opts;if($=$||new S4({schema:X,schemaId:J,root:W,baseId:Y}),$.schema!==$.root.schema)return $;return}});var hJ=w((yP,zL)=>{zL.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 $Y=w((gP,cJ)=>{var HL=RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu),lJ=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 GY(Q){let Y="",X=0,W=0;for(W=0;W<Q.length;W++){if(X=Q[W].charCodeAt(0),X===48)continue;if(!(X>=48&&X<=57||X>=65&&X<=70||X>=97&&X<=102))return"";Y+=Q[W];break}for(W+=1;W<Q.length;W++){if(X=Q[W].charCodeAt(0),!(X>=48&&X<=57||X>=65&&X<=70||X>=97&&X<=102))return"";Y+=Q[W]}return Y}var UL=RegExp.prototype.test.bind(/[^!"$&'()*+,\-.;=_`a-z{}~]/u);function fJ(Q){return Q.length=0,!0}function AL(Q,Y,X){if(Q.length){let W=GY(Q);if(W!=="")Y.push(W);else return X.error=!0,!1;Q.length=0}return!0}function BL(Q){let Y=0,X={error:!1,address:"",zone:""},W=[],G=[],$=!1,J=!1,z=AL;for(let H=0;H<Q.length;H++){let U=Q[H];if(U==="["||U==="]")continue;if(U===":"){if($===!0)J=!0;if(!z(G,W,X))break;if(++Y>7){X.error=!0;break}if(H>0&&Q[H-1]===":")$=!0;W.push(":");continue}else if(U==="%"){if(!z(G,W,X))break;z=fJ}else{G.push(U);continue}}if(G.length)if(z===fJ)X.zone=G.join("");else if(J)W.push(G.join(""));else W.push(GY(G));return X.address=W.join(""),X}function mJ(Q){if(KL(Q,":")<2)return{host:Q,isIPV6:!1};let Y=BL(Q);if(!Y.error){let{address:X,address:W}=Y;if(Y.zone)X+="%"+Y.zone,W+="%25"+Y.zone;return{host:X,isIPV6:!0,escapedHost:W}}else return{host:Q,isIPV6:!1}}function KL(Q,Y){let X=0;for(let W=0;W<Q.length;W++)if(Q[W]===Y)X++;return X}function DL(Q){let Y=Q,X=[],W=-1,G=0;while(G=Y.length){if(G===1)if(Y===".")break;else if(Y==="/"){X.push("/");break}else{X.push(Y);break}else if(G===2){if(Y[0]==="."){if(Y[1]===".")break;else if(Y[1]==="/"){Y=Y.slice(2);continue}}else if(Y[0]==="/"){if(Y[1]==="."||Y[1]==="/"){X.push("/");break}}}else if(G===3){if(Y==="/.."){if(X.length!==0)X.pop();X.push("/");break}}if(Y[0]==="."){if(Y[1]==="."){if(Y[2]==="/"){Y=Y.slice(3);continue}}else if(Y[1]==="/"){Y=Y.slice(2);continue}}else if(Y[0]==="/"){if(Y[1]==="."){if(Y[2]==="/"){Y=Y.slice(2);continue}else if(Y[2]==="."){if(Y[3]==="/"){if(Y=Y.slice(3),X.length!==0)X.pop();continue}}}}if((W=Y.indexOf("/",1))===-1){X.push(Y);break}else X.push(Y.slice(0,W)),Y=Y.slice(W)}return X.join("")}function LL(Q,Y){let X=Y!==!0?escape:unescape;if(Q.scheme!==void 0)Q.scheme=X(Q.scheme);if(Q.userinfo!==void 0)Q.userinfo=X(Q.userinfo);if(Q.host!==void 0)Q.host=X(Q.host);if(Q.path!==void 0)Q.path=X(Q.path);if(Q.query!==void 0)Q.query=X(Q.query);if(Q.fragment!==void 0)Q.fragment=X(Q.fragment);return Q}function qL(Q){let Y=[];if(Q.userinfo!==void 0)Y.push(Q.userinfo),Y.push("@");if(Q.host!==void 0){let X=unescape(Q.host);if(!lJ(X)){let W=mJ(X);if(W.isIPV6===!0)X=`[${W.escapedHost}]`;else X=Q.host}Y.push(X)}if(typeof Q.port==="number"||typeof Q.port==="string")Y.push(":"),Y.push(String(Q.port));return Y.length?Y.join(""):void 0}cJ.exports={nonSimpleDomain:UL,recomposeAuthority:qL,normalizeComponentEncoding:LL,removeDotSegments:DL,isIPv4:lJ,isUUID:HL,normalizeIPv6:mJ,stringArrayToHexStripped:GY}});var dJ=w((uP,rJ)=>{var{isUUID:FL}=$Y(),OL=/([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-.:;=@]|%[\da-f]{2})+)/iu,ML=["http","https","ws","wss","urn","urn:uuid"];function VL(Q){return ML.indexOf(Q)!==-1}function JY(Q){if(Q.secure===!0)return!0;else if(Q.secure===!1)return!1;else if(Q.scheme)return Q.scheme.length===3&&(Q.scheme[0]==="w"||Q.scheme[0]==="W")&&(Q.scheme[1]==="s"||Q.scheme[1]==="S")&&(Q.scheme[2]==="s"||Q.scheme[2]==="S");else return!1}function pJ(Q){if(!Q.host)Q.error=Q.error||"HTTP URIs must have a host.";return Q}function iJ(Q){let Y=String(Q.scheme).toLowerCase()==="https";if(Q.port===(Y?443:80)||Q.port==="")Q.port=void 0;if(!Q.path)Q.path="/";return Q}function ZL(Q){return Q.secure=JY(Q),Q.resourceName=(Q.path||"/")+(Q.query?"?"+Q.query:""),Q.path=void 0,Q.query=void 0,Q}function NL(Q){if(Q.port===(JY(Q)?443:80)||Q.port==="")Q.port=void 0;if(typeof Q.secure==="boolean")Q.scheme=Q.secure?"wss":"ws",Q.secure=void 0;if(Q.resourceName){let[Y,X]=Q.resourceName.split("?");Q.path=Y&&Y!=="/"?Y:void 0,Q.query=X,Q.resourceName=void 0}return Q.fragment=void 0,Q}function wL(Q,Y){if(!Q.path)return Q.error="URN can not be parsed",Q;let X=Q.path.match(OL);if(X){let W=Y.scheme||Q.scheme||"urn";Q.nid=X[1].toLowerCase(),Q.nss=X[2];let G=`${W}:${Y.nid||Q.nid}`,$=zY(G);if(Q.path=void 0,$)Q=$.parse(Q,Y)}else Q.error=Q.error||"URN can not be parsed.";return Q}function bL(Q,Y){if(Q.nid===void 0)throw Error("URN without nid cannot be serialized");let X=Y.scheme||Q.scheme||"urn",W=Q.nid.toLowerCase(),G=`${X}:${Y.nid||W}`,$=zY(G);if($)Q=$.serialize(Q,Y);let J=Q,z=Q.nss;return J.path=`${W||Y.nid}:${z}`,Y.skipEscape=!0,J}function jL(Q,Y){let X=Q;if(X.uuid=X.nss,X.nss=void 0,!Y.tolerant&&(!X.uuid||!FL(X.uuid)))X.error=X.error||"UUID is not valid.";return X}function PL(Q){let Y=Q;return Y.nss=(Q.uuid||"").toLowerCase(),Y}var nJ={scheme:"http",domainHost:!0,parse:pJ,serialize:iJ},IL={scheme:"https",domainHost:nJ.domainHost,parse:pJ,serialize:iJ},n6={scheme:"ws",domainHost:!0,parse:ZL,serialize:NL},EL={scheme:"wss",domainHost:n6.domainHost,parse:n6.parse,serialize:n6.serialize},TL={scheme:"urn",parse:wL,serialize:bL,skipNormalize:!0},SL={scheme:"urn:uuid",parse:jL,serialize:PL,skipNormalize:!0},r6={http:nJ,https:IL,ws:n6,wss:EL,urn:TL,"urn:uuid":SL};Object.setPrototypeOf(r6,null);function zY(Q){return Q&&(r6[Q]||r6[Q.toLowerCase()])||void 0}rJ.exports={wsIsSecure:JY,SCHEMES:r6,isValidSchemeName:VL,getSchemeHandler:zY}});var aJ=w((hP,o6)=>{var{normalizeIPv6:RL,removeDotSegments:R4,recomposeAuthority:CL,normalizeComponentEncoding:d6,isIPv4:kL,nonSimpleDomain:vL}=$Y(),{SCHEMES:xL,getSchemeHandler:oJ}=dJ();function _L(Q,Y){if(typeof Q==="string")Q=u0(o0(Q,Y),Y);else if(typeof Q==="object")Q=o0(u0(Q,Y),Y);return Q}function yL(Q,Y,X){let W=X?Object.assign({scheme:"null"},X):{scheme:"null"},G=tJ(o0(Q,W),o0(Y,W),W,!0);return W.skipEscape=!0,u0(G,W)}function tJ(Q,Y,X,W){let G={};if(!W)Q=o0(u0(Q,X),X),Y=o0(u0(Y,X),X);if(X=X||{},!X.tolerant&&Y.scheme)G.scheme=Y.scheme,G.userinfo=Y.userinfo,G.host=Y.host,G.port=Y.port,G.path=R4(Y.path||""),G.query=Y.query;else{if(Y.userinfo!==void 0||Y.host!==void 0||Y.port!==void 0)G.userinfo=Y.userinfo,G.host=Y.host,G.port=Y.port,G.path=R4(Y.path||""),G.query=Y.query;else{if(!Y.path)if(G.path=Q.path,Y.query!==void 0)G.query=Y.query;else G.query=Q.query;else{if(Y.path[0]==="/")G.path=R4(Y.path);else{if((Q.userinfo!==void 0||Q.host!==void 0||Q.port!==void 0)&&!Q.path)G.path="/"+Y.path;else if(!Q.path)G.path=Y.path;else G.path=Q.path.slice(0,Q.path.lastIndexOf("/")+1)+Y.path;G.path=R4(G.path)}G.query=Y.query}G.userinfo=Q.userinfo,G.host=Q.host,G.port=Q.port}G.scheme=Q.scheme}return G.fragment=Y.fragment,G}function gL(Q,Y,X){if(typeof Q==="string")Q=unescape(Q),Q=u0(d6(o0(Q,X),!0),{...X,skipEscape:!0});else if(typeof Q==="object")Q=u0(d6(Q,!0),{...X,skipEscape:!0});if(typeof Y==="string")Y=unescape(Y),Y=u0(d6(o0(Y,X),!0),{...X,skipEscape:!0});else if(typeof Y==="object")Y=u0(d6(Y,!0),{...X,skipEscape:!0});return Q.toLowerCase()===Y.toLowerCase()}function u0(Q,Y){let X={host:Q.host,scheme:Q.scheme,userinfo:Q.userinfo,port:Q.port,path:Q.path,query:Q.query,nid:Q.nid,nss:Q.nss,uuid:Q.uuid,fragment:Q.fragment,reference:Q.reference,resourceName:Q.resourceName,secure:Q.secure,error:""},W=Object.assign({},Y),G=[],$=oJ(W.scheme||X.scheme);if($&&$.serialize)$.serialize(X,W);if(X.path!==void 0)if(!W.skipEscape){if(X.path=escape(X.path),X.scheme!==void 0)X.path=X.path.split("%3A").join(":")}else X.path=unescape(X.path);if(W.reference!=="suffix"&&X.scheme)G.push(X.scheme,":");let J=CL(X);if(J!==void 0){if(W.reference!=="suffix")G.push("//");if(G.push(J),X.path&&X.path[0]!=="/")G.push("/")}if(X.path!==void 0){let z=X.path;if(!W.absolutePath&&(!$||!$.absolutePath))z=R4(z);if(J===void 0&&z[0]==="/"&&z[1]==="/")z="/%2F"+z.slice(2);G.push(z)}if(X.query!==void 0)G.push("?",X.query);if(X.fragment!==void 0)G.push("#",X.fragment);return G.join("")}var uL=/^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u;function o0(Q,Y){let X=Object.assign({},Y),W={scheme:void 0,userinfo:void 0,host:"",port:void 0,path:"",query:void 0,fragment:void 0},G=!1;if(X.reference==="suffix")if(X.scheme)Q=X.scheme+":"+Q;else Q="//"+Q;let $=Q.match(uL);if($){if(W.scheme=$[1],W.userinfo=$[3],W.host=$[4],W.port=parseInt($[5],10),W.path=$[6]||"",W.query=$[7],W.fragment=$[8],isNaN(W.port))W.port=$[5];if(W.host)if(kL(W.host)===!1){let H=RL(W.host);W.host=H.host.toLowerCase(),G=H.isIPV6}else G=!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(X.reference&&X.reference!=="suffix"&&X.reference!==W.reference)W.error=W.error||"URI is not a "+X.reference+" reference.";let J=oJ(X.scheme||W.scheme);if(!X.unicodeSupport&&(!J||!J.unicodeSupport)){if(W.host&&(X.domainHost||J&&J.domainHost)&&G===!1&&vL(W.host))try{W.host=URL.domainToASCII(W.host.toLowerCase())}catch(z){W.error=W.error||"Host's domain name can not be converted to ASCII: "+z}}if(!J||J&&!J.skipNormalize){if(Q.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(J&&J.parse)J.parse(W,X)}else W.error=W.error||"URI can not be parsed.";return W}var HY={SCHEMES:xL,normalize:_L,resolve:yL,resolveComponent:tJ,equal:gL,serialize:u0,parse:o0};o6.exports=HY;o6.exports.default=HY;o6.exports.fastUri=HY});var Qz=w((eJ)=>{Object.defineProperty(eJ,"__esModule",{value:!0});var sJ=aJ();sJ.code='require("ajv/dist/runtime/uri").default';eJ.default=sJ});var Hz=w((t0)=>{Object.defineProperty(t0,"__esModule",{value:!0});t0.CodeGen=t0.Name=t0.nil=t0.stringify=t0.str=t0._=t0.KeywordCxt=void 0;var fL=E4();Object.defineProperty(t0,"KeywordCxt",{enumerable:!0,get:function(){return fL.KeywordCxt}});var f1=v();Object.defineProperty(t0,"_",{enumerable:!0,get:function(){return f1._}});Object.defineProperty(t0,"str",{enumerable:!0,get:function(){return f1.str}});Object.defineProperty(t0,"stringify",{enumerable:!0,get:function(){return f1.stringify}});Object.defineProperty(t0,"nil",{enumerable:!0,get:function(){return f1.nil}});Object.defineProperty(t0,"Name",{enumerable:!0,get:function(){return f1.Name}});Object.defineProperty(t0,"CodeGen",{enumerable:!0,get:function(){return f1.CodeGen}});var lL=c6(),$z=T4(),mL=l9(),C4=i6(),cL=v(),k4=j4(),t6=b4(),AY=l(),Yz=hJ(),pL=Qz(),Jz=(Q,Y)=>new RegExp(Q,Y);Jz.code="new RegExp";var iL=["removeAdditional","useDefaults","coerceTypes"],nL=new Set(["validate","serialize","parse","wrapper","root","schema","keyword","pattern","formats","validate$data","func","obj","Error"]),rL={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."},dL={ignoreKeywordsWithRef:"",jsPropertySyntax:"",unicode:'"minLength"/"maxLength" account for unicode characters by default.'},Xz=200;function oL(Q){var Y,X,W,G,$,J,z,H,U,A,B,K,L,O,M,Z,V,S,E,_,T,y0,l0,OQ,MQ;let n1=Q.strict,VQ=(Y=Q.code)===null||Y===void 0?void 0:Y.optimize,rY=VQ===!0||VQ===void 0?1:VQ||0,dY=(W=(X=Q.code)===null||X===void 0?void 0:X.regExp)!==null&&W!==void 0?W:Jz,n5=(G=Q.uriResolver)!==null&&G!==void 0?G:pL.default;return{strictSchema:(J=($=Q.strictSchema)!==null&&$!==void 0?$:n1)!==null&&J!==void 0?J:!0,strictNumbers:(H=(z=Q.strictNumbers)!==null&&z!==void 0?z:n1)!==null&&H!==void 0?H:!0,strictTypes:(A=(U=Q.strictTypes)!==null&&U!==void 0?U:n1)!==null&&A!==void 0?A:"log",strictTuples:(K=(B=Q.strictTuples)!==null&&B!==void 0?B:n1)!==null&&K!==void 0?K:"log",strictRequired:(O=(L=Q.strictRequired)!==null&&L!==void 0?L:n1)!==null&&O!==void 0?O:!1,code:Q.code?{...Q.code,optimize:rY,regExp:dY}:{optimize:rY,regExp:dY},loopRequired:(M=Q.loopRequired)!==null&&M!==void 0?M:Xz,loopEnum:(Z=Q.loopEnum)!==null&&Z!==void 0?Z:Xz,meta:(V=Q.meta)!==null&&V!==void 0?V:!0,messages:(S=Q.messages)!==null&&S!==void 0?S:!0,inlineRefs:(E=Q.inlineRefs)!==null&&E!==void 0?E:!0,schemaId:(_=Q.schemaId)!==null&&_!==void 0?_:"$id",addUsedSchema:(T=Q.addUsedSchema)!==null&&T!==void 0?T:!0,validateSchema:(y0=Q.validateSchema)!==null&&y0!==void 0?y0:!0,validateFormats:(l0=Q.validateFormats)!==null&&l0!==void 0?l0:!0,unicodeRegExp:(OQ=Q.unicodeRegExp)!==null&&OQ!==void 0?OQ:!0,int32range:(MQ=Q.int32range)!==null&&MQ!==void 0?MQ:!0,uriResolver:n5}}class a6{constructor(Q={}){this.schemas={},this.refs={},this.formats={},this._compilations=new Set,this._loading={},this._cache=new Map,Q=this.opts={...Q,...oL(Q)};let{es5:Y,lines:X}=this.opts.code;this.scope=new cL.ValueScope({scope:{},prefixes:nL,es5:Y,lines:X}),this.logger=Yq(Q.logger);let W=Q.validateFormats;if(Q.validateFormats=!1,this.RULES=(0,mL.getRules)(),Wz.call(this,rL,Q,"NOT SUPPORTED"),Wz.call(this,dL,Q,"DEPRECATED","warn"),this._metaOpts=eL.call(this),Q.formats)aL.call(this);if(this._addVocabularies(),this._addDefaultMetaSchema(),Q.keywords)sL.call(this,Q.keywords);if(typeof Q.meta=="object")this.addMetaSchema(Q.meta);tL.call(this),Q.validateFormats=W}_addVocabularies(){this.addKeyword("$async")}_addDefaultMetaSchema(){let{$data:Q,meta:Y,schemaId:X}=this.opts,W=Yz;if(X==="id")W={...Yz},W.id=W.$id,delete W.$id;if(Y&&Q)this.addMetaSchema(W,W[X],!1)}defaultMeta(){let{meta:Q,schemaId:Y}=this.opts;return this.opts.defaultMeta=typeof Q=="object"?Q[Y]||Q:void 0}validate(Q,Y){let X;if(typeof Q=="string"){if(X=this.getSchema(Q),!X)throw Error(`no schema with key or ref "${Q}"`)}else X=this.compile(Q);let W=X(Y);if(!("$async"in X))this.errors=X.errors;return W}compile(Q,Y){let X=this._addSchema(Q,Y);return X.validate||this._compileSchemaEnv(X)}compileAsync(Q,Y){if(typeof this.opts.loadSchema!="function")throw Error("options.loadSchema should be a function");let{loadSchema:X}=this.opts;return W.call(this,Q,Y);async function W(U,A){await G.call(this,U.$schema);let B=this._addSchema(U,A);return B.validate||$.call(this,B)}async function G(U){if(U&&!this.getSchema(U))await W.call(this,{$ref:U},!0)}async function $(U){try{return this._compileSchemaEnv(U)}catch(A){if(!(A instanceof $z.default))throw A;return J.call(this,A),await z.call(this,A.missingSchema),$.call(this,U)}}function J({missingSchema:U,missingRef:A}){if(this.refs[U])throw Error(`AnySchema ${U} is loaded but ${A} cannot be resolved`)}async function z(U){let A=await H.call(this,U);if(!this.refs[U])await G.call(this,A.$schema);if(!this.refs[U])this.addSchema(A,U,Y)}async function H(U){let A=this._loading[U];if(A)return A;try{return await(this._loading[U]=X(U))}finally{delete this._loading[U]}}}addSchema(Q,Y,X,W=this.opts.validateSchema){if(Array.isArray(Q)){for(let $ of Q)this.addSchema($,void 0,X,W);return this}let G;if(typeof Q==="object"){let{schemaId:$}=this.opts;if(G=Q[$],G!==void 0&&typeof G!="string")throw Error(`schema ${$} must be string`)}return Y=(0,k4.normalizeId)(Y||G),this._checkUnique(Y),this.schemas[Y]=this._addSchema(Q,X,Y,W,!0),this}addMetaSchema(Q,Y,X=this.opts.validateSchema){return this.addSchema(Q,Y,!0,X),this}validateSchema(Q,Y){if(typeof Q=="boolean")return!0;let X;if(X=Q.$schema,X!==void 0&&typeof X!="string")throw Error("$schema must be a string");if(X=X||this.opts.defaultMeta||this.defaultMeta(),!X)return this.logger.warn("meta-schema not available"),this.errors=null,!0;let W=this.validate(X,Q);if(!W&&Y){let G="schema is invalid: "+this.errorsText();if(this.opts.validateSchema==="log")this.logger.error(G);else throw Error(G)}return W}getSchema(Q){let Y;while(typeof(Y=Gz.call(this,Q))=="string")Q=Y;if(Y===void 0){let{schemaId:X}=this.opts,W=new C4.SchemaEnv({schema:{},schemaId:X});if(Y=C4.resolveSchema.call(this,W,Q),!Y)return;this.refs[Q]=Y}return Y.validate||this._compileSchemaEnv(Y)}removeSchema(Q){if(Q instanceof RegExp)return this._removeAllSchemas(this.schemas,Q),this._removeAllSchemas(this.refs,Q),this;switch(typeof Q){case"undefined":return this._removeAllSchemas(this.schemas),this._removeAllSchemas(this.refs),this._cache.clear(),this;case"string":{let Y=Gz.call(this,Q);if(typeof Y=="object")this._cache.delete(Y.schema);return delete this.schemas[Q],delete this.refs[Q],this}case"object":{let Y=Q;this._cache.delete(Y);let X=Q[this.opts.schemaId];if(X)X=(0,k4.normalizeId)(X),delete this.schemas[X],delete this.refs[X];return this}default:throw Error("ajv.removeSchema: invalid parameter")}}addVocabulary(Q){for(let Y of Q)this.addKeyword(Y);return this}addKeyword(Q,Y){let X;if(typeof Q=="string"){if(X=Q,typeof Y=="object")this.logger.warn("these parameters are deprecated, see docs for addKeyword"),Y.keyword=X}else if(typeof Q=="object"&&Y===void 0){if(Y=Q,X=Y.keyword,Array.isArray(X)&&!X.length)throw Error("addKeywords: keyword must be string or non-empty array")}else throw Error("invalid addKeywords parameters");if(Wq.call(this,X,Y),!Y)return(0,AY.eachItem)(X,(G)=>UY.call(this,G)),this;$q.call(this,Y);let W={...Y,type:(0,t6.getJSONTypes)(Y.type),schemaType:(0,t6.getJSONTypes)(Y.schemaType)};return(0,AY.eachItem)(X,W.type.length===0?(G)=>UY.call(this,G,W):(G)=>W.type.forEach(($)=>UY.call(this,G,W,$))),this}getKeyword(Q){let Y=this.RULES.all[Q];return typeof Y=="object"?Y.definition:!!Y}removeKeyword(Q){let{RULES:Y}=this;delete Y.keywords[Q],delete Y.all[Q];for(let X of Y.rules){let W=X.rules.findIndex((G)=>G.keyword===Q);if(W>=0)X.rules.splice(W,1)}return this}addFormat(Q,Y){if(typeof Y=="string")Y=new RegExp(Y);return this.formats[Q]=Y,this}errorsText(Q=this.errors,{separator:Y=", ",dataVar:X="data"}={}){if(!Q||Q.length===0)return"No errors";return Q.map((W)=>`${X}${W.instancePath} ${W.message}`).reduce((W,G)=>W+Y+G)}$dataMetaSchema(Q,Y){let X=this.RULES.all;Q=JSON.parse(JSON.stringify(Q));for(let W of Y){let G=W.split("/").slice(1),$=Q;for(let J of G)$=$[J];for(let J in X){let z=X[J];if(typeof z!="object")continue;let{$data:H}=z.definition,U=$[J];if(H&&U)$[J]=zz(U)}}return Q}_removeAllSchemas(Q,Y){for(let X in Q){let W=Q[X];if(!Y||Y.test(X)){if(typeof W=="string")delete Q[X];else if(W&&!W.meta)this._cache.delete(W.schema),delete Q[X]}}}_addSchema(Q,Y,X,W=this.opts.validateSchema,G=this.opts.addUsedSchema){let $,{schemaId:J}=this.opts;if(typeof Q=="object")$=Q[J];else if(this.opts.jtd)throw Error("schema must be object");else if(typeof Q!="boolean")throw Error("schema must be object or boolean");let z=this._cache.get(Q);if(z!==void 0)return z;X=(0,k4.normalizeId)($||X);let H=k4.getSchemaRefs.call(this,Q,X);if(z=new C4.SchemaEnv({schema:Q,schemaId:J,meta:Y,baseId:X,localRefs:H}),this._cache.set(z.schema,z),G&&!X.startsWith("#")){if(X)this._checkUnique(X);this.refs[X]=z}if(W)this.validateSchema(Q,!0);return z}_checkUnique(Q){if(this.schemas[Q]||this.refs[Q])throw Error(`schema with key or id "${Q}" already exists`)}_compileSchemaEnv(Q){if(Q.meta)this._compileMetaSchema(Q);else C4.compileSchema.call(this,Q);if(!Q.validate)throw Error("ajv implementation error");return Q.validate}_compileMetaSchema(Q){let Y=this.opts;this.opts=this._metaOpts;try{C4.compileSchema.call(this,Q)}finally{this.opts=Y}}}a6.ValidationError=lL.default;a6.MissingRefError=$z.default;t0.default=a6;function Wz(Q,Y,X,W="error"){for(let G in Q){let $=G;if($ in Y)this.logger[W](`${X}: option ${G}. ${Q[$]}`)}}function Gz(Q){return Q=(0,k4.normalizeId)(Q),this.schemas[Q]||this.refs[Q]}function tL(){let Q=this.opts.schemas;if(!Q)return;if(Array.isArray(Q))this.addSchema(Q);else for(let Y in Q)this.addSchema(Q[Y],Y)}function aL(){for(let Q in this.opts.formats){let Y=this.opts.formats[Q];if(Y)this.addFormat(Q,Y)}}function sL(Q){if(Array.isArray(Q)){this.addVocabulary(Q);return}this.logger.warn("keywords option as map is deprecated, pass array");for(let Y in Q){let X=Q[Y];if(!X.keyword)X.keyword=Y;this.addKeyword(X)}}function eL(){let Q={...this.opts};for(let Y of iL)delete Q[Y];return Q}var Qq={log(){},warn(){},error(){}};function Yq(Q){if(Q===!1)return Qq;if(Q===void 0)return console;if(Q.log&&Q.warn&&Q.error)return Q;throw Error("logger must implement log, warn and error methods")}var Xq=/^[a-z_$][a-z0-9_$:-]*$/i;function Wq(Q,Y){let{RULES:X}=this;if((0,AY.eachItem)(Q,(W)=>{if(X.keywords[W])throw Error(`Keyword ${W} is already defined`);if(!Xq.test(W))throw Error(`Keyword ${W} has invalid name`)}),!Y)return;if(Y.$data&&!(("code"in Y)||("validate"in Y)))throw Error('$data keyword must have "code" or "validate" function')}function UY(Q,Y,X){var W;let G=Y===null||Y===void 0?void 0:Y.post;if(X&&G)throw Error('keyword with "post" flag cannot have "type"');let{RULES:$}=this,J=G?$.post:$.rules.find(({type:H})=>H===X);if(!J)J={type:X,rules:[]},$.rules.push(J);if($.keywords[Q]=!0,!Y)return;let z={keyword:Q,definition:{...Y,type:(0,t6.getJSONTypes)(Y.type),schemaType:(0,t6.getJSONTypes)(Y.schemaType)}};if(Y.before)Gq.call(this,J,z,Y.before);else J.rules.push(z);$.all[Q]=z,(W=Y.implements)===null||W===void 0||W.forEach((H)=>this.addKeyword(H))}function Gq(Q,Y,X){let W=Q.rules.findIndex((G)=>G.keyword===X);if(W>=0)Q.rules.splice(W,0,Y);else Q.rules.push(Y),this.logger.warn(`rule ${X} is not defined`)}function $q(Q){let{metaSchema:Y}=Q;if(Y===void 0)return;if(Q.$data&&this.opts.$data)Y=zz(Y);Q.validateSchema=this.compile(Y,!0)}var Jq={$ref:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#"};function zz(Q){return{anyOf:[Q,Jq]}}});var Az=w((Uz)=>{Object.defineProperty(Uz,"__esModule",{value:!0});var Uq={keyword:"id",code(){throw Error('NOT SUPPORTED: keyword "id", use "$id" for schema ID')}};Uz.default=Uq});var Fz=w((Lz)=>{Object.defineProperty(Lz,"__esModule",{value:!0});Lz.callRef=Lz.getValidate=void 0;var Bq=T4(),Bz=I0(),M0=v(),l1=r0(),Kz=i6(),s6=l(),Kq={keyword:"$ref",schemaType:"string",code(Q){let{gen:Y,schema:X,it:W}=Q,{baseId:G,schemaEnv:$,validateName:J,opts:z,self:H}=W,{root:U}=$;if((X==="#"||X==="#/")&&G===U.baseId)return B();let A=Kz.resolveRef.call(H,U,G,X);if(A===void 0)throw new Bq.default(W.opts.uriResolver,G,X);if(A instanceof Kz.SchemaEnv)return K(A);return L(A);function B(){if($===U)return e6(Q,J,$,$.$async);let O=Y.scopeValue("root",{ref:U});return e6(Q,M0._`${O}.validate`,U,U.$async)}function K(O){let M=Dz(Q,O);e6(Q,M,O,O.$async)}function L(O){let M=Y.scopeValue("schema",z.code.source===!0?{ref:O,code:(0,M0.stringify)(O)}:{ref:O}),Z=Y.name("valid"),V=Q.subschema({schema:O,dataTypes:[],schemaPath:M0.nil,topSchemaRef:M,errSchemaPath:X},Z);Q.mergeEvaluated(V),Q.ok(Z)}}};function Dz(Q,Y){let{gen:X}=Q;return Y.validate?X.scopeValue("validate",{ref:Y.validate}):M0._`${X.scopeValue("wrapper",{ref:Y})}.validate`}Lz.getValidate=Dz;function e6(Q,Y,X,W){let{gen:G,it:$}=Q,{allErrors:J,schemaEnv:z,opts:H}=$,U=H.passContext?l1.default.this:M0.nil;if(W)A();else B();function A(){if(!z.$async)throw Error("async schema referenced by sync schema");let O=G.let("valid");G.try(()=>{if(G.code(M0._`await ${(0,Bz.callValidateCode)(Q,Y,U)}`),L(Y),!J)G.assign(O,!0)},(M)=>{if(G.if(M0._`!(${M} instanceof ${$.ValidationError})`,()=>G.throw(M)),K(M),!J)G.assign(O,!1)}),Q.ok(O)}function B(){Q.result((0,Bz.callValidateCode)(Q,Y,U),()=>L(Y),()=>K(Y))}function K(O){let M=M0._`${O}.errors`;G.assign(l1.default.vErrors,M0._`${l1.default.vErrors} === null ? ${M} : ${l1.default.vErrors}.concat(${M})`),G.assign(l1.default.errors,M0._`${l1.default.vErrors}.length`)}function L(O){var M;if(!$.opts.unevaluated)return;let Z=(M=X===null||X===void 0?void 0:X.validate)===null||M===void 0?void 0:M.evaluated;if($.props!==!0)if(Z&&!Z.dynamicProps){if(Z.props!==void 0)$.props=s6.mergeEvaluated.props(G,Z.props,$.props)}else{let V=G.var("props",M0._`${O}.evaluated.props`);$.props=s6.mergeEvaluated.props(G,V,$.props,M0.Name)}if($.items!==!0)if(Z&&!Z.dynamicItems){if(Z.items!==void 0)$.items=s6.mergeEvaluated.items(G,Z.items,$.items)}else{let V=G.var("items",M0._`${O}.evaluated.items`);$.items=s6.mergeEvaluated.items(G,V,$.items,M0.Name)}}}Lz.callRef=e6;Lz.default=Kq});var Mz=w((Oz)=>{Object.defineProperty(Oz,"__esModule",{value:!0});var qq=Az(),Fq=Fz(),Oq=["$schema","$id","$defs","$vocabulary",{keyword:"$comment"},"definitions",qq.default,Fq.default];Oz.default=Oq});var Zz=w((Vz)=>{Object.defineProperty(Vz,"__esModule",{value:!0});var QQ=v(),D1=QQ.operators,YQ={maximum:{okStr:"<=",ok:D1.LTE,fail:D1.GT},minimum:{okStr:">=",ok:D1.GTE,fail:D1.LT},exclusiveMaximum:{okStr:"<",ok:D1.LT,fail:D1.GTE},exclusiveMinimum:{okStr:">",ok:D1.GT,fail:D1.LTE}},Vq={message:({keyword:Q,schemaCode:Y})=>QQ.str`must be ${YQ[Q].okStr} ${Y}`,params:({keyword:Q,schemaCode:Y})=>QQ._`{comparison: ${YQ[Q].okStr}, limit: ${Y}}`},Zq={keyword:Object.keys(YQ),type:"number",schemaType:"number",$data:!0,error:Vq,code(Q){let{keyword:Y,data:X,schemaCode:W}=Q;Q.fail$data(QQ._`${X} ${YQ[Y].fail} ${W} || isNaN(${X})`)}};Vz.default=Zq});var wz=w((Nz)=>{Object.defineProperty(Nz,"__esModule",{value:!0});var v4=v(),wq={message:({schemaCode:Q})=>v4.str`must be multiple of ${Q}`,params:({schemaCode:Q})=>v4._`{multipleOf: ${Q}}`},bq={keyword:"multipleOf",type:"number",schemaType:"number",$data:!0,error:wq,code(Q){let{gen:Y,data:X,schemaCode:W,it:G}=Q,$=G.opts.multipleOfPrecision,J=Y.let("res"),z=$?v4._`Math.abs(Math.round(${J}) - ${J}) > 1e-${$}`:v4._`${J} !== parseInt(${J})`;Q.fail$data(v4._`(${W} === 0 || (${J} = ${X}/${W}, ${z}))`)}};Nz.default=bq});var Pz=w((jz)=>{Object.defineProperty(jz,"__esModule",{value:!0});function bz(Q){let Y=Q.length,X=0,W=0,G;while(W<Y)if(X++,G=Q.charCodeAt(W++),G>=55296&&G<=56319&&W<Y){if(G=Q.charCodeAt(W),(G&64512)===56320)W++}return X}jz.default=bz;bz.code='require("ajv/dist/runtime/ucs2length").default'});var Ez=w((Iz)=>{Object.defineProperty(Iz,"__esModule",{value:!0});var b1=v(),Iq=l(),Eq=Pz(),Tq={message({keyword:Q,schemaCode:Y}){let X=Q==="maxLength"?"more":"fewer";return b1.str`must NOT have ${X} than ${Y} characters`},params:({schemaCode:Q})=>b1._`{limit: ${Q}}`},Sq={keyword:["maxLength","minLength"],type:"string",schemaType:"number",$data:!0,error:Tq,code(Q){let{keyword:Y,data:X,schemaCode:W,it:G}=Q,$=Y==="maxLength"?b1.operators.GT:b1.operators.LT,J=G.opts.unicode===!1?b1._`${X}.length`:b1._`${(0,Iq.useFunc)(Q.gen,Eq.default)}(${X})`;Q.fail$data(b1._`${J} ${$} ${W}`)}};Iz.default=Sq});var Sz=w((Tz)=>{Object.defineProperty(Tz,"__esModule",{value:!0});var Cq=I0(),XQ=v(),kq={message:({schemaCode:Q})=>XQ.str`must match pattern "${Q}"`,params:({schemaCode:Q})=>XQ._`{pattern: ${Q}}`},vq={keyword:"pattern",type:"string",schemaType:"string",$data:!0,error:kq,code(Q){let{data:Y,$data:X,schema:W,schemaCode:G,it:$}=Q,J=$.opts.unicodeRegExp?"u":"",z=X?XQ._`(new RegExp(${G}, ${J}))`:(0,Cq.usePattern)(Q,W);Q.fail$data(XQ._`!${z}.test(${Y})`)}};Tz.default=vq});var Cz=w((Rz)=>{Object.defineProperty(Rz,"__esModule",{value:!0});var x4=v(),_q={message({keyword:Q,schemaCode:Y}){let X=Q==="maxProperties"?"more":"fewer";return x4.str`must NOT have ${X} than ${Y} properties`},params:({schemaCode:Q})=>x4._`{limit: ${Q}}`},yq={keyword:["maxProperties","minProperties"],type:"object",schemaType:"number",$data:!0,error:_q,code(Q){let{keyword:Y,data:X,schemaCode:W}=Q,G=Y==="maxProperties"?x4.operators.GT:x4.operators.LT;Q.fail$data(x4._`Object.keys(${X}).length ${G} ${W}`)}};Rz.default=yq});var vz=w((kz)=>{Object.defineProperty(kz,"__esModule",{value:!0});var _4=I0(),y4=v(),uq=l(),hq={message:({params:{missingProperty:Q}})=>y4.str`must have required property '${Q}'`,params:({params:{missingProperty:Q}})=>y4._`{missingProperty: ${Q}}`},fq={keyword:"required",type:"object",schemaType:"array",$data:!0,error:hq,code(Q){let{gen:Y,schema:X,schemaCode:W,data:G,$data:$,it:J}=Q,{opts:z}=J;if(!$&&X.length===0)return;let H=X.length>=z.loopRequired;if(J.allErrors)U();else A();if(z.strictRequired){let L=Q.parentSchema.properties,{definedProperties:O}=Q.it;for(let M of X)if((L===null||L===void 0?void 0:L[M])===void 0&&!O.has(M)){let Z=J.schemaEnv.baseId+J.errSchemaPath,V=`required property "${M}" is not defined at "${Z}" (strictRequired)`;(0,uq.checkStrictMode)(J,V,J.opts.strictRequired)}}function U(){if(H||$)Q.block$data(y4.nil,B);else for(let L of X)(0,_4.checkReportMissingProp)(Q,L)}function A(){let L=Y.let("missing");if(H||$){let O=Y.let("valid",!0);Q.block$data(O,()=>K(L,O)),Q.ok(O)}else Y.if((0,_4.checkMissingProp)(Q,X,L)),(0,_4.reportMissingProp)(Q,L),Y.else()}function B(){Y.forOf("prop",W,(L)=>{Q.setParams({missingProperty:L}),Y.if((0,_4.noPropertyInData)(Y,G,L,z.ownProperties),()=>Q.error())})}function K(L,O){Q.setParams({missingProperty:L}),Y.forOf(L,W,()=>{Y.assign(O,(0,_4.propertyInData)(Y,G,L,z.ownProperties)),Y.if((0,y4.not)(O),()=>{Q.error(),Y.break()})},y4.nil)}}};kz.default=fq});var _z=w((xz)=>{Object.defineProperty(xz,"__esModule",{value:!0});var g4=v(),mq={message({keyword:Q,schemaCode:Y}){let X=Q==="maxItems"?"more":"fewer";return g4.str`must NOT have ${X} than ${Y} items`},params:({schemaCode:Q})=>g4._`{limit: ${Q}}`},cq={keyword:["maxItems","minItems"],type:"array",schemaType:"number",$data:!0,error:mq,code(Q){let{keyword:Y,data:X,schemaCode:W}=Q,G=Y==="maxItems"?g4.operators.GT:g4.operators.LT;Q.fail$data(g4._`${X}.length ${G} ${W}`)}};xz.default=cq});var WQ=w((gz)=>{Object.defineProperty(gz,"__esModule",{value:!0});var yz=o9();yz.code='require("ajv/dist/runtime/equal").default';gz.default=yz});var hz=w((uz)=>{Object.defineProperty(uz,"__esModule",{value:!0});var BY=b4(),U0=v(),nq=l(),rq=WQ(),dq={message:({params:{i:Q,j:Y}})=>U0.str`must NOT have duplicate items (items ## ${Y} and ${Q} are identical)`,params:({params:{i:Q,j:Y}})=>U0._`{i: ${Q}, j: ${Y}}`},oq={keyword:"uniqueItems",type:"array",schemaType:"boolean",$data:!0,error:dq,code(Q){let{gen:Y,data:X,$data:W,schema:G,parentSchema:$,schemaCode:J,it:z}=Q;if(!W&&!G)return;let H=Y.let("valid"),U=$.items?(0,BY.getSchemaTypes)($.items):[];Q.block$data(H,A,U0._`${J} === false`),Q.ok(H);function A(){let O=Y.let("i",U0._`${X}.length`),M=Y.let("j");Q.setParams({i:O,j:M}),Y.assign(H,!0),Y.if(U0._`${O} > 1`,()=>(B()?K:L)(O,M))}function B(){return U.length>0&&!U.some((O)=>O==="object"||O==="array")}function K(O,M){let Z=Y.name("item"),V=(0,BY.checkDataTypes)(U,Z,z.opts.strictNumbers,BY.DataType.Wrong),S=Y.const("indices",U0._`{}`);Y.for(U0._`;${O}--;`,()=>{if(Y.let(Z,U0._`${X}[${O}]`),Y.if(V,U0._`continue`),U.length>1)Y.if(U0._`typeof ${Z} == "string"`,U0._`${Z} += "_"`);Y.if(U0._`typeof ${S}[${Z}] == "number"`,()=>{Y.assign(M,U0._`${S}[${Z}]`),Q.error(),Y.assign(H,!1).break()}).code(U0._`${S}[${Z}] = ${O}`)})}function L(O,M){let Z=(0,nq.useFunc)(Y,rq.default),V=Y.name("outer");Y.label(V).for(U0._`;${O}--;`,()=>Y.for(U0._`${M} = ${O}; ${M}--;`,()=>Y.if(U0._`${Z}(${X}[${O}], ${X}[${M}])`,()=>{Q.error(),Y.assign(H,!1).break(V)})))}}};uz.default=oq});var lz=w((fz)=>{Object.defineProperty(fz,"__esModule",{value:!0});var KY=v(),aq=l(),sq=WQ(),eq={message:"must be equal to constant",params:({schemaCode:Q})=>KY._`{allowedValue: ${Q}}`},QF={keyword:"const",$data:!0,error:eq,code(Q){let{gen:Y,data:X,$data:W,schemaCode:G,schema:$}=Q;if(W||$&&typeof $=="object")Q.fail$data(KY._`!${(0,aq.useFunc)(Y,sq.default)}(${X}, ${G})`);else Q.fail(KY._`${$} !== ${X}`)}};fz.default=QF});var cz=w((mz)=>{Object.defineProperty(mz,"__esModule",{value:!0});var u4=v(),XF=l(),WF=WQ(),GF={message:"must be equal to one of the allowed values",params:({schemaCode:Q})=>u4._`{allowedValues: ${Q}}`},$F={keyword:"enum",schemaType:"array",$data:!0,error:GF,code(Q){let{gen:Y,data:X,$data:W,schema:G,schemaCode:$,it:J}=Q;if(!W&&G.length===0)throw Error("enum must have non-empty array");let z=G.length>=J.opts.loopEnum,H,U=()=>H!==null&&H!==void 0?H:H=(0,XF.useFunc)(Y,WF.default),A;if(z||W)A=Y.let("valid"),Q.block$data(A,B);else{if(!Array.isArray(G))throw Error("ajv implementation error");let L=Y.const("vSchema",$);A=(0,u4.or)(...G.map((O,M)=>K(L,M)))}Q.pass(A);function B(){Y.assign(A,!1),Y.forOf("v",$,(L)=>Y.if(u4._`${U()}(${X}, ${L})`,()=>Y.assign(A,!0).break()))}function K(L,O){let M=G[O];return typeof M==="object"&&M!==null?u4._`${U()}(${X}, ${L}[${O}])`:u4._`${X} === ${M}`}}};mz.default=$F});var iz=w((pz)=>{Object.defineProperty(pz,"__esModule",{value:!0});var zF=Zz(),HF=wz(),UF=Ez(),AF=Sz(),BF=Cz(),KF=vz(),DF=_z(),LF=hz(),qF=lz(),FF=cz(),OF=[zF.default,HF.default,UF.default,AF.default,BF.default,KF.default,DF.default,LF.default,{keyword:"type",schemaType:["string","array"]},{keyword:"nullable",schemaType:"boolean"},qF.default,FF.default];pz.default=OF});var LY=w((rz)=>{Object.defineProperty(rz,"__esModule",{value:!0});rz.validateAdditionalItems=void 0;var j1=v(),DY=l(),VF={message:({params:{len:Q}})=>j1.str`must NOT have more than ${Q} items`,params:({params:{len:Q}})=>j1._`{limit: ${Q}}`},ZF={keyword:"additionalItems",type:"array",schemaType:["boolean","object"],before:"uniqueItems",error:VF,code(Q){let{parentSchema:Y,it:X}=Q,{items:W}=Y;if(!Array.isArray(W)){(0,DY.checkStrictMode)(X,'"additionalItems" is ignored when "items" is not an array of schemas');return}nz(Q,W)}};function nz(Q,Y){let{gen:X,schema:W,data:G,keyword:$,it:J}=Q;J.items=!0;let z=X.const("len",j1._`${G}.length`);if(W===!1)Q.setParams({len:Y.length}),Q.pass(j1._`${z} <= ${Y.length}`);else if(typeof W=="object"&&!(0,DY.alwaysValidSchema)(J,W)){let U=X.var("valid",j1._`${z} <= ${Y.length}`);X.if((0,j1.not)(U),()=>H(U)),Q.ok(U)}function H(U){X.forRange("i",Y.length,z,(A)=>{if(Q.subschema({keyword:$,dataProp:A,dataPropType:DY.Type.Num},U),!J.allErrors)X.if((0,j1.not)(U),()=>X.break())})}}rz.validateAdditionalItems=nz;rz.default=ZF});var qY=w((az)=>{Object.defineProperty(az,"__esModule",{value:!0});az.validateTuple=void 0;var oz=v(),GQ=l(),wF=I0(),bF={keyword:"items",type:"array",schemaType:["object","array","boolean"],before:"uniqueItems",code(Q){let{schema:Y,it:X}=Q;if(Array.isArray(Y))return tz(Q,"additionalItems",Y);if(X.items=!0,(0,GQ.alwaysValidSchema)(X,Y))return;Q.ok((0,wF.validateArray)(Q))}};function tz(Q,Y,X=Q.schema){let{gen:W,parentSchema:G,data:$,keyword:J,it:z}=Q;if(A(G),z.opts.unevaluated&&X.length&&z.items!==!0)z.items=GQ.mergeEvaluated.items(W,X.length,z.items);let H=W.name("valid"),U=W.const("len",oz._`${$}.length`);X.forEach((B,K)=>{if((0,GQ.alwaysValidSchema)(z,B))return;W.if(oz._`${U} > ${K}`,()=>Q.subschema({keyword:J,schemaProp:K,dataProp:K},H)),Q.ok(H)});function A(B){let{opts:K,errSchemaPath:L}=z,O=X.length,M=O===B.minItems&&(O===B.maxItems||B[Y]===!1);if(K.strictTuples&&!M){let Z=`"${J}" is ${O}-tuple, but minItems or maxItems/${Y} are not specified or different at path "${L}"`;(0,GQ.checkStrictMode)(z,Z,K.strictTuples)}}}az.validateTuple=tz;az.default=bF});var Q7=w((ez)=>{Object.defineProperty(ez,"__esModule",{value:!0});var PF=qY(),IF={keyword:"prefixItems",type:"array",schemaType:["array"],before:"uniqueItems",code:(Q)=>(0,PF.validateTuple)(Q,"items")};ez.default=IF});var W7=w((X7)=>{Object.defineProperty(X7,"__esModule",{value:!0});var Y7=v(),TF=l(),SF=I0(),RF=LY(),CF={message:({params:{len:Q}})=>Y7.str`must NOT have more than ${Q} items`,params:({params:{len:Q}})=>Y7._`{limit: ${Q}}`},kF={keyword:"items",type:"array",schemaType:["object","boolean"],before:"uniqueItems",error:CF,code(Q){let{schema:Y,parentSchema:X,it:W}=Q,{prefixItems:G}=X;if(W.items=!0,(0,TF.alwaysValidSchema)(W,Y))return;if(G)(0,RF.validateAdditionalItems)(Q,G);else Q.ok((0,SF.validateArray)(Q))}};X7.default=kF});var $7=w((G7)=>{Object.defineProperty(G7,"__esModule",{value:!0});var E0=v(),$Q=l(),xF={message:({params:{min:Q,max:Y}})=>Y===void 0?E0.str`must contain at least ${Q} valid item(s)`:E0.str`must contain at least ${Q} and no more than ${Y} valid item(s)`,params:({params:{min:Q,max:Y}})=>Y===void 0?E0._`{minContains: ${Q}}`:E0._`{minContains: ${Q}, maxContains: ${Y}}`},_F={keyword:"contains",type:"array",schemaType:["object","boolean"],before:"uniqueItems",trackErrors:!0,error:xF,code(Q){let{gen:Y,schema:X,parentSchema:W,data:G,it:$}=Q,J,z,{minContains:H,maxContains:U}=W;if($.opts.next)J=H===void 0?1:H,z=U;else J=1;let A=Y.const("len",E0._`${G}.length`);if(Q.setParams({min:J,max:z}),z===void 0&&J===0){(0,$Q.checkStrictMode)($,'"minContains" == 0 without "maxContains": "contains" keyword ignored');return}if(z!==void 0&&J>z){(0,$Q.checkStrictMode)($,'"minContains" > "maxContains" is always invalid'),Q.fail();return}if((0,$Q.alwaysValidSchema)($,X)){let M=E0._`${A} >= ${J}`;if(z!==void 0)M=E0._`${M} && ${A} <= ${z}`;Q.pass(M);return}$.items=!0;let B=Y.name("valid");if(z===void 0&&J===1)L(B,()=>Y.if(B,()=>Y.break()));else if(J===0){if(Y.let(B,!0),z!==void 0)Y.if(E0._`${G}.length > 0`,K)}else Y.let(B,!1),K();Q.result(B,()=>Q.reset());function K(){let M=Y.name("_valid"),Z=Y.let("count",0);L(M,()=>Y.if(M,()=>O(Z)))}function L(M,Z){Y.forRange("i",0,A,(V)=>{Q.subschema({keyword:"contains",dataProp:V,dataPropType:$Q.Type.Num,compositeRule:!0},M),Z()})}function O(M){if(Y.code(E0._`${M}++`),z===void 0)Y.if(E0._`${M} >= ${J}`,()=>Y.assign(B,!0).break());else if(Y.if(E0._`${M} > ${z}`,()=>Y.assign(B,!1).break()),J===1)Y.assign(B,!0);else Y.if(E0._`${M} >= ${J}`,()=>Y.assign(B,!0))}}};G7.default=_F});var B7=w((H7)=>{Object.defineProperty(H7,"__esModule",{value:!0});H7.validateSchemaDeps=H7.validatePropertyDeps=H7.error=void 0;var FY=v(),gF=l(),h4=I0();H7.error={message:({params:{property:Q,depsCount:Y,deps:X}})=>{let W=Y===1?"property":"properties";return FY.str`must have ${W} ${X} when property ${Q} is present`},params:({params:{property:Q,depsCount:Y,deps:X,missingProperty:W}})=>FY._`{property: ${Q},
|
|
6
|
+
|| ${J} === "boolean" || ${G} === null`).assign(z,C._`[${G}]`)}}}function BK({gen:Q,parentData:Y,parentDataProperty:X},W){Q.if(C._`${Y} !== undefined`,()=>Q.assign(C._`${Y}[${X}]`,W))}function c9(Q,Y,X,W=g1.Correct){let G=W===g1.Correct?C.operators.EQ:C.operators.NEQ,$;switch(Q){case"null":return C._`${Y} ${G} null`;case"array":$=C._`Array.isArray(${Y})`;break;case"object":$=C._`${Y} && typeof ${Y} == "object" && !Array.isArray(${Y})`;break;case"integer":$=J(C._`!(${Y} % 1) && !isNaN(${Y})`);break;case"number":$=J();break;default:return C._`typeof ${Y} ${G} ${Q}`}return W===g1.Correct?$:(0,C.not)($);function J(z=C.nil){return(0,C.and)(C._`typeof ${Y} == "number"`,z,X?C._`isFinite(${Y})`:C.nil)}}m$.checkDataType=c9;function p9(Q,Y,X,W){if(Q.length===1)return c9(Q[0],Y,X,W);let G,$=(0,h$.toHash)(Q);if($.array&&$.object){let J=C._`typeof ${Y} != "object"`;G=$.null?J:C._`!${Y} || ${J}`,delete $.null,delete $.array,delete $.object}else G=C.nil;if($.number)delete $.integer;for(let J in $)G=(0,C.and)(G,c9(J,Y,X,W));return G}m$.checkDataTypes=p9;var KK={message:({schema:Q})=>`must be ${Q}`,params:({schema:Q,schemaValue:Y})=>typeof Q=="string"?C._`{type: ${Q}}`:C._`{type: ${Y}}`};function i9(Q){let Y=DK(Q);(0,JK.reportError)(Y,KK)}m$.reportTypeError=i9;function DK(Q){let{gen:Y,data:X,schema:W}=Q,G=(0,h$.schemaRefOrVal)(Q,W,"type");return{gen:Y,keyword:"type",data:X,schema:W.type,schemaCode:G,schemaValue:G,parentSchema:W,params:{},it:Q}}});var r$=w((i$)=>{Object.defineProperty(i$,"__esModule",{value:!0});i$.assignDefaults=void 0;var u1=v(),ZK=l();function NK(Q,Y){let{properties:X,items:W}=Q.schema;if(Y==="object"&&X)for(let G in X)p$(Q,G,X[G].default);else if(Y==="array"&&Array.isArray(W))W.forEach((G,$)=>p$(Q,$,G.default))}i$.assignDefaults=NK;function p$(Q,Y,X){let{gen:W,compositeRule:G,data:$,opts:J}=Q;if(X===void 0)return;let z=u1._`${$}${(0,u1.getProperty)(Y)}`;if(G){(0,ZK.checkStrictMode)(Q,`default is ignored for: ${z}`);return}let H=u1._`${z} === undefined`;if(J.useDefaults==="empty")H=u1._`${H} || ${z} === null || ${z} === ""`;W.if(H,u1._`${z} = ${(0,u1.stringify)(X)}`)}});var I0=w((t$)=>{Object.defineProperty(t$,"__esModule",{value:!0});t$.validateUnion=t$.validateArray=t$.usePattern=t$.callValidateCode=t$.schemaProperties=t$.allSchemaProperties=t$.noPropertyInData=t$.propertyInData=t$.isOwnProperty=t$.hasPropFunc=t$.reportMissingProp=t$.checkMissingProp=t$.checkReportMissingProp=void 0;var d=v(),n9=l(),B1=r0(),wK=l();function bK(Q,Y){let{gen:X,data:W,it:G}=Q;X.if(d9(X,W,Y,G.opts.ownProperties),()=>{Q.setParams({missingProperty:d._`${Y}`},!0),Q.error()})}t$.checkReportMissingProp=bK;function jK({gen:Q,data:Y,it:{opts:X}},W,G){return(0,d.or)(...W.map(($)=>(0,d.and)(d9(Q,Y,$,X.ownProperties),d._`${G} = ${$}`)))}t$.checkMissingProp=jK;function PK(Q,Y){Q.setParams({missingProperty:Y},!0),Q.error()}t$.reportMissingProp=PK;function d$(Q){return Q.scopeValue("func",{ref:Object.prototype.hasOwnProperty,code:d._`Object.prototype.hasOwnProperty`})}t$.hasPropFunc=d$;function r9(Q,Y,X){return d._`${d$(Q)}.call(${Y}, ${X})`}t$.isOwnProperty=r9;function IK(Q,Y,X,W){let G=d._`${Y}${(0,d.getProperty)(X)} !== undefined`;return W?d._`${G} && ${r9(Q,Y,X)}`:G}t$.propertyInData=IK;function d9(Q,Y,X,W){let G=d._`${Y}${(0,d.getProperty)(X)} === undefined`;return W?(0,d.or)(G,(0,d.not)(r9(Q,Y,X))):G}t$.noPropertyInData=d9;function o$(Q){return Q?Object.keys(Q).filter((Y)=>Y!=="__proto__"):[]}t$.allSchemaProperties=o$;function EK(Q,Y){return o$(Y).filter((X)=>!(0,n9.alwaysValidSchema)(Q,Y[X]))}t$.schemaProperties=EK;function TK({schemaCode:Q,data:Y,it:{gen:X,topSchemaRef:W,schemaPath:G,errorPath:$},it:J},z,H,U){let A=U?d._`${Q}, ${Y}, ${W}${G}`:Y,B=[[B1.default.instancePath,(0,d.strConcat)(B1.default.instancePath,$)],[B1.default.parentData,J.parentData],[B1.default.parentDataProperty,J.parentDataProperty],[B1.default.rootData,B1.default.rootData]];if(J.opts.dynamicRef)B.push([B1.default.dynamicAnchors,B1.default.dynamicAnchors]);let K=d._`${A}, ${X.object(...B)}`;return H!==d.nil?d._`${z}.call(${H}, ${K})`:d._`${z}(${K})`}t$.callValidateCode=TK;var SK=d._`new RegExp`;function RK({gen:Q,it:{opts:Y}},X){let W=Y.unicodeRegExp?"u":"",{regExp:G}=Y.code,$=G(X,W);return Q.scopeValue("pattern",{key:$.toString(),ref:$,code:d._`${G.code==="new RegExp"?SK:(0,wK.useFunc)(Q,G)}(${X}, ${W})`})}t$.usePattern=RK;function CK(Q){let{gen:Y,data:X,keyword:W,it:G}=Q,$=Y.name("valid");if(G.allErrors){let z=Y.let("valid",!0);return J(()=>Y.assign(z,!1)),z}return Y.var($,!0),J(()=>Y.break()),$;function J(z){let H=Y.const("len",d._`${X}.length`);Y.forRange("i",0,H,(U)=>{Q.subschema({keyword:W,dataProp:U,dataPropType:n9.Type.Num},$),Y.if((0,d.not)($),z)})}}t$.validateArray=CK;function kK(Q){let{gen:Y,schema:X,keyword:W,it:G}=Q;if(!Array.isArray(X))throw Error("ajv implementation error");if(X.some((H)=>(0,n9.alwaysValidSchema)(G,H))&&!G.opts.unevaluated)return;let J=Y.let("valid",!1),z=Y.name("_valid");Y.block(()=>X.forEach((H,U)=>{let A=Q.subschema({keyword:W,schemaProp:U,compositeRule:!0},z);if(Y.assign(J,d._`${J} || ${z}`),!Q.mergeValidEvaluated(A,z))Y.if((0,d.not)(J))})),Q.result(J,()=>Q.reset(),()=>Q.error(!0))}t$.validateUnion=kK});var XJ=w((QJ)=>{Object.defineProperty(QJ,"__esModule",{value:!0});QJ.validateKeywordUsage=QJ.validSchemaType=QJ.funcKeywordCode=QJ.macroKeywordCode=void 0;var L0=v(),N1=r0(),iK=I0(),nK=w6();function rK(Q,Y){let{gen:X,keyword:W,schema:G,parentSchema:$,it:J}=Q,z=Y.macro.call(J.self,G,$,J),H=e$(X,W,z);if(J.opts.validateSchema!==!1)J.self.validateSchema(z,!0);let U=X.name("valid");Q.subschema({schema:z,schemaPath:L0.nil,errSchemaPath:`${J.errSchemaPath}/${W}`,topSchemaRef:H,compositeRule:!0},U),Q.pass(U,()=>Q.error(!0))}QJ.macroKeywordCode=rK;function dK(Q,Y){var X;let{gen:W,keyword:G,schema:$,parentSchema:J,$data:z,it:H}=Q;tK(H,Y);let U=!z&&Y.compile?Y.compile.call(H.self,$,J,H):Y.validate,A=e$(W,G,U),B=W.let("valid");Q.block$data(B,K),Q.ok((X=Y.valid)!==null&&X!==void 0?X:B);function K(){if(Y.errors===!1){if(M(),Y.modifying)s$(Q);Z(()=>Q.error())}else{let V=Y.async?L():O();if(Y.modifying)s$(Q);Z(()=>oK(Q,V))}}function L(){let V=W.let("ruleErrs",null);return W.try(()=>M(L0._`await `),(S)=>W.assign(B,!1).if(L0._`${S} instanceof ${H.ValidationError}`,()=>W.assign(V,L0._`${S}.errors`),()=>W.throw(S))),V}function O(){let V=L0._`${A}.errors`;return W.assign(V,null),M(L0.nil),V}function M(V=Y.async?L0._`await `:L0.nil){let S=H.opts.passContext?N1.default.this:N1.default.self,E=!(("compile"in Y)&&!z||Y.schema===!1);W.assign(B,L0._`${V}${(0,iK.callValidateCode)(Q,A,S,E)}`,Y.modifying)}function Z(V){var S;W.if((0,L0.not)((S=Y.valid)!==null&&S!==void 0?S:B),V)}}QJ.funcKeywordCode=dK;function s$(Q){let{gen:Y,data:X,it:W}=Q;Y.if(W.parentData,()=>Y.assign(X,L0._`${W.parentData}[${W.parentDataProperty}]`))}function oK(Q,Y){let{gen:X}=Q;X.if(L0._`Array.isArray(${Y})`,()=>{X.assign(N1.default.vErrors,L0._`${N1.default.vErrors} === null ? ${Y} : ${N1.default.vErrors}.concat(${Y})`).assign(N1.default.errors,L0._`${N1.default.vErrors}.length`),(0,nK.extendErrors)(Q)},()=>Q.error())}function tK({schemaEnv:Q},Y){if(Y.async&&!Q.$async)throw Error("async keyword in sync schema")}function e$(Q,Y,X){if(X===void 0)throw Error(`keyword "${Y}" failed to compile`);return Q.scopeValue("keyword",typeof X=="function"?{ref:X}:{ref:X,code:(0,L0.stringify)(X)})}function aK(Q,Y,X=!1){return!Y.length||Y.some((W)=>W==="array"?Array.isArray(Q):W==="object"?Q&&typeof Q=="object"&&!Array.isArray(Q):typeof Q==W||X&&typeof Q>"u")}QJ.validSchemaType=aK;function sK({schema:Q,opts:Y,self:X,errSchemaPath:W},G,$){if(Array.isArray(G.keyword)?!G.keyword.includes($):G.keyword!==$)throw Error("ajv implementation error");let J=G.dependencies;if(J===null||J===void 0?void 0:J.some((z)=>!Object.prototype.hasOwnProperty.call(Q,z)))throw Error(`parent schema must have dependencies of ${$}: ${J.join(",")}`);if(G.validateSchema){if(!G.validateSchema(Q[$])){let H=`keyword "${$}" value is invalid at path "${W}": `+X.errorsText(G.validateSchema.errors);if(Y.validateSchema==="log")X.logger.error(H);else throw Error(H)}}}QJ.validateKeywordUsage=sK});var JJ=w((GJ)=>{Object.defineProperty(GJ,"__esModule",{value:!0});GJ.extendSubschemaMode=GJ.extendSubschemaData=GJ.getSubschema=void 0;var g0=v(),WJ=l();function XD(Q,{keyword:Y,schemaProp:X,schema:W,schemaPath:G,errSchemaPath:$,topSchemaRef:J}){if(Y!==void 0&&W!==void 0)throw Error('both "keyword" and "schema" passed, only one allowed');if(Y!==void 0){let z=Q.schema[Y];return X===void 0?{schema:z,schemaPath:g0._`${Q.schemaPath}${(0,g0.getProperty)(Y)}`,errSchemaPath:`${Q.errSchemaPath}/${Y}`}:{schema:z[X],schemaPath:g0._`${Q.schemaPath}${(0,g0.getProperty)(Y)}${(0,g0.getProperty)(X)}`,errSchemaPath:`${Q.errSchemaPath}/${Y}/${(0,WJ.escapeFragment)(X)}`}}if(W!==void 0){if(G===void 0||$===void 0||J===void 0)throw Error('"schemaPath", "errSchemaPath" and "topSchemaRef" are required with "schema"');return{schema:W,schemaPath:G,topSchemaRef:J,errSchemaPath:$}}throw Error('either "keyword" or "schema" must be passed')}GJ.getSubschema=XD;function WD(Q,Y,{dataProp:X,dataPropType:W,data:G,dataTypes:$,propertyName:J}){if(G!==void 0&&X!==void 0)throw Error('both "data" and "dataProp" passed, only one allowed');let{gen:z}=Y;if(X!==void 0){let{errorPath:U,dataPathArr:A,opts:B}=Y,K=z.let("data",g0._`${Y.data}${(0,g0.getProperty)(X)}`,!0);H(K),Q.errorPath=g0.str`${U}${(0,WJ.getErrorPath)(X,W,B.jsPropertySyntax)}`,Q.parentDataProperty=g0._`${X}`,Q.dataPathArr=[...A,Q.parentDataProperty]}if(G!==void 0){let U=G instanceof g0.Name?G:z.let("data",G,!0);if(H(U),J!==void 0)Q.propertyName=J}if($)Q.dataTypes=$;function H(U){Q.data=U,Q.dataLevel=Y.dataLevel+1,Q.dataTypes=[],Y.definedProperties=new Set,Q.parentData=Y.data,Q.dataNames=[...Y.dataNames,U]}}GJ.extendSubschemaData=WD;function GD(Q,{jtdDiscriminator:Y,jtdMetadata:X,compositeRule:W,createErrors:G,allErrors:$}){if(W!==void 0)Q.compositeRule=W;if(G!==void 0)Q.createErrors=G;if($!==void 0)Q.allErrors=$;Q.jtdDiscriminator=Y,Q.jtdMetadata=X}GJ.extendSubschemaMode=GD});var o9=w((CP,zJ)=>{zJ.exports=function Q(Y,X){if(Y===X)return!0;if(Y&&X&&typeof Y=="object"&&typeof X=="object"){if(Y.constructor!==X.constructor)return!1;var W,G,$;if(Array.isArray(Y)){if(W=Y.length,W!=X.length)return!1;for(G=W;G--!==0;)if(!Q(Y[G],X[G]))return!1;return!0}if(Y.constructor===RegExp)return Y.source===X.source&&Y.flags===X.flags;if(Y.valueOf!==Object.prototype.valueOf)return Y.valueOf()===X.valueOf();if(Y.toString!==Object.prototype.toString)return Y.toString()===X.toString();if($=Object.keys(Y),W=$.length,W!==Object.keys(X).length)return!1;for(G=W;G--!==0;)if(!Object.prototype.hasOwnProperty.call(X,$[G]))return!1;for(G=W;G--!==0;){var J=$[G];if(!Q(Y[J],X[J]))return!1}return!0}return Y!==Y&&X!==X}});var UJ=w((kP,HJ)=>{var K1=HJ.exports=function(Q,Y,X){if(typeof Y=="function")X=Y,Y={};X=Y.cb||X;var W=typeof X=="function"?X:X.pre||function(){},G=X.post||function(){};l4(Y,W,G,Q,"",Q)};K1.keywords={additionalItems:!0,items:!0,contains:!0,additionalProperties:!0,propertyNames:!0,not:!0,if:!0,then:!0,else:!0};K1.arrayKeywords={items:!0,allOf:!0,anyOf:!0,oneOf:!0};K1.propsKeywords={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependencies:!0};K1.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 l4(Q,Y,X,W,G,$,J,z,H,U){if(W&&typeof W=="object"&&!Array.isArray(W)){Y(W,G,$,J,z,H,U);for(var A in W){var B=W[A];if(Array.isArray(B)){if(A in K1.arrayKeywords)for(var K=0;K<B.length;K++)l4(Q,Y,X,B[K],G+"/"+A+"/"+K,$,G,A,W,K)}else if(A in K1.propsKeywords){if(B&&typeof B=="object")for(var L in B)l4(Q,Y,X,B[L],G+"/"+A+"/"+zD(L),$,G,A,W,L)}else if(A in K1.keywords||Q.allKeys&&!(A in K1.skipKeywords))l4(Q,Y,X,B,G+"/"+A,$,G,A,W)}X(W,G,$,J,z,H,U)}}function zD(Q){return Q.replace(/~/g,"~0").replace(/\//g,"~1")}});var j6=w((DJ)=>{Object.defineProperty(DJ,"__esModule",{value:!0});DJ.getSchemaRefs=DJ.resolveUrl=DJ.normalizeId=DJ._getFullPath=DJ.getFullPath=DJ.inlineRef=void 0;var HD=l(),UD=o9(),AD=UJ(),BD=new Set(["type","format","pattern","maxLength","minLength","maxProperties","minProperties","maxItems","minItems","maximum","minimum","uniqueItems","multipleOf","required","enum","const"]);function KD(Q,Y=!0){if(typeof Q=="boolean")return!0;if(Y===!0)return!t9(Q);if(!Y)return!1;return AJ(Q)<=Y}DJ.inlineRef=KD;var DD=new Set(["$ref","$recursiveRef","$recursiveAnchor","$dynamicRef","$dynamicAnchor"]);function t9(Q){for(let Y in Q){if(DD.has(Y))return!0;let X=Q[Y];if(Array.isArray(X)&&X.some(t9))return!0;if(typeof X=="object"&&t9(X))return!0}return!1}function AJ(Q){let Y=0;for(let X in Q){if(X==="$ref")return 1/0;if(Y++,BD.has(X))continue;if(typeof Q[X]=="object")(0,HD.eachItem)(Q[X],(W)=>Y+=AJ(W));if(Y===1/0)return 1/0}return Y}function BJ(Q,Y="",X){if(X!==!1)Y=h1(Y);let W=Q.parse(Y);return KJ(Q,W)}DJ.getFullPath=BJ;function KJ(Q,Y){return Q.serialize(Y).split("#")[0]+"#"}DJ._getFullPath=KJ;var LD=/#\/?$/;function h1(Q){return Q?Q.replace(LD,""):""}DJ.normalizeId=h1;function qD(Q,Y,X){return X=h1(X),Q.resolve(Y,X)}DJ.resolveUrl=qD;var FD=/^[a-z_][-a-z0-9._]*$/i;function OD(Q,Y){if(typeof Q=="boolean")return{};let{schemaId:X,uriResolver:W}=this.opts,G=h1(Q[X]||Y),$={"":G},J=BJ(W,G,!1),z={},H=new Set;return AD(Q,{allKeys:!0},(B,K,L,O)=>{if(O===void 0)return;let M=J+K,Z=$[O];if(typeof B[X]=="string")Z=V.call(this,B[X]);S.call(this,B.$anchor),S.call(this,B.$dynamicAnchor),$[K]=Z;function V(E){let _=this.opts.uriResolver.resolve;if(E=h1(Z?_(Z,E):E),H.has(E))throw A(E);H.add(E);let T=this.refs[E];if(typeof T=="string")T=this.refs[T];if(typeof T=="object")U(B,T.schema,E);else if(E!==h1(M))if(E[0]==="#")U(B,z[E],E),z[E]=B;else this.refs[E]=M;return E}function S(E){if(typeof E=="string"){if(!FD.test(E))throw Error(`invalid anchor "${E}"`);V.call(this,`#${E}`)}}}),z;function U(B,K,L){if(K!==void 0&&!UD(B,K))throw A(L)}function A(B){return Error(`reference "${B}" resolves to more than one schema`)}}DJ.getSchemaRefs=OD});var E6=w((SJ)=>{Object.defineProperty(SJ,"__esModule",{value:!0});SJ.getData=SJ.KeywordCxt=SJ.validateFunctionCode=void 0;var VJ=k$(),qJ=b6(),s9=m9(),m4=b6(),bD=r$(),I6=XJ(),a9=JJ(),P=v(),R=r0(),jD=j6(),d0=l(),P6=w6();function PD(Q){if(wJ(Q)){if(bJ(Q),NJ(Q)){TD(Q);return}}ZJ(Q,()=>(0,VJ.topBoolOrEmptySchema)(Q))}SJ.validateFunctionCode=PD;function ZJ({gen:Q,validateName:Y,schema:X,schemaEnv:W,opts:G},$){if(G.code.es5)Q.func(Y,P._`${R.default.data}, ${R.default.valCxt}`,W.$async,()=>{Q.code(P._`"use strict"; ${FJ(X,G)}`),ED(Q,G),Q.code($)});else Q.func(Y,P._`${R.default.data}, ${ID(G)}`,W.$async,()=>Q.code(FJ(X,G)).code($))}function ID(Q){return P._`{${R.default.instancePath}="", ${R.default.parentData}, ${R.default.parentDataProperty}, ${R.default.rootData}=${R.default.data}${Q.dynamicRef?P._`, ${R.default.dynamicAnchors}={}`:P.nil}}={}`}function ED(Q,Y){Q.if(R.default.valCxt,()=>{if(Q.var(R.default.instancePath,P._`${R.default.valCxt}.${R.default.instancePath}`),Q.var(R.default.parentData,P._`${R.default.valCxt}.${R.default.parentData}`),Q.var(R.default.parentDataProperty,P._`${R.default.valCxt}.${R.default.parentDataProperty}`),Q.var(R.default.rootData,P._`${R.default.valCxt}.${R.default.rootData}`),Y.dynamicRef)Q.var(R.default.dynamicAnchors,P._`${R.default.valCxt}.${R.default.dynamicAnchors}`)},()=>{if(Q.var(R.default.instancePath,P._`""`),Q.var(R.default.parentData,P._`undefined`),Q.var(R.default.parentDataProperty,P._`undefined`),Q.var(R.default.rootData,R.default.data),Y.dynamicRef)Q.var(R.default.dynamicAnchors,P._`{}`)})}function TD(Q){let{schema:Y,opts:X,gen:W}=Q;ZJ(Q,()=>{if(X.$comment&&Y.$comment)PJ(Q);if(vD(Q),W.let(R.default.vErrors,null),W.let(R.default.errors,0),X.unevaluated)SD(Q);jJ(Q),yD(Q)});return}function SD(Q){let{gen:Y,validateName:X}=Q;Q.evaluated=Y.const("evaluated",P._`${X}.evaluated`),Y.if(P._`${Q.evaluated}.dynamicProps`,()=>Y.assign(P._`${Q.evaluated}.props`,P._`undefined`)),Y.if(P._`${Q.evaluated}.dynamicItems`,()=>Y.assign(P._`${Q.evaluated}.items`,P._`undefined`))}function FJ(Q,Y){let X=typeof Q=="object"&&Q[Y.schemaId];return X&&(Y.code.source||Y.code.process)?P._`/*# sourceURL=${X} */`:P.nil}function RD(Q,Y){if(wJ(Q)){if(bJ(Q),NJ(Q)){CD(Q,Y);return}}(0,VJ.boolOrEmptySchema)(Q,Y)}function NJ({schema:Q,self:Y}){if(typeof Q=="boolean")return!Q;for(let X in Q)if(Y.RULES.all[X])return!0;return!1}function wJ(Q){return typeof Q.schema!="boolean"}function CD(Q,Y){let{schema:X,gen:W,opts:G}=Q;if(G.$comment&&X.$comment)PJ(Q);xD(Q),_D(Q);let $=W.const("_errs",R.default.errors);jJ(Q,$),W.var(Y,P._`${$} === ${R.default.errors}`)}function bJ(Q){(0,d0.checkUnknownRules)(Q),kD(Q)}function jJ(Q,Y){if(Q.opts.jtd)return OJ(Q,[],!1,Y);let X=(0,qJ.getSchemaTypes)(Q.schema),W=(0,qJ.coerceAndCheckDataType)(Q,X);OJ(Q,X,!W,Y)}function kD(Q){let{schema:Y,errSchemaPath:X,opts:W,self:G}=Q;if(Y.$ref&&W.ignoreKeywordsWithRef&&(0,d0.schemaHasRulesButRef)(Y,G.RULES))G.logger.warn(`$ref: keywords ignored in schema at path "${X}"`)}function vD(Q){let{schema:Y,opts:X}=Q;if(Y.default!==void 0&&X.useDefaults&&X.strictSchema)(0,d0.checkStrictMode)(Q,"default is ignored in the schema root")}function xD(Q){let Y=Q.schema[Q.opts.schemaId];if(Y)Q.baseId=(0,jD.resolveUrl)(Q.opts.uriResolver,Q.baseId,Y)}function _D(Q){if(Q.schema.$async&&!Q.schemaEnv.$async)throw Error("async schema in sync schema")}function PJ({gen:Q,schemaEnv:Y,schema:X,errSchemaPath:W,opts:G}){let $=X.$comment;if(G.$comment===!0)Q.code(P._`${R.default.self}.logger.log(${$})`);else if(typeof G.$comment=="function"){let J=P.str`${W}/$comment`,z=Q.scopeValue("root",{ref:Y.root});Q.code(P._`${R.default.self}.opts.$comment(${$}, ${J}, ${z}.schema)`)}}function yD(Q){let{gen:Y,schemaEnv:X,validateName:W,ValidationError:G,opts:$}=Q;if(X.$async)Y.if(P._`${R.default.errors} === 0`,()=>Y.return(R.default.data),()=>Y.throw(P._`new ${G}(${R.default.vErrors})`));else{if(Y.assign(P._`${W}.errors`,R.default.vErrors),$.unevaluated)gD(Q);Y.return(P._`${R.default.errors} === 0`)}}function gD({gen:Q,evaluated:Y,props:X,items:W}){if(X instanceof P.Name)Q.assign(P._`${Y}.props`,X);if(W instanceof P.Name)Q.assign(P._`${Y}.items`,W)}function OJ(Q,Y,X,W){let{gen:G,schema:$,data:J,allErrors:z,opts:H,self:U}=Q,{RULES:A}=U;if($.$ref&&(H.ignoreKeywordsWithRef||!(0,d0.schemaHasRulesButRef)($,A))){G.block(()=>EJ(Q,"$ref",A.all.$ref.definition));return}if(!H.jtd)uD(Q,Y);G.block(()=>{for(let K of A.rules)B(K);B(A.post)});function B(K){if(!(0,s9.shouldUseGroup)($,K))return;if(K.type){if(G.if((0,m4.checkDataType)(K.type,J,H.strictNumbers)),MJ(Q,K),Y.length===1&&Y[0]===K.type&&X)G.else(),(0,m4.reportTypeError)(Q);G.endIf()}else MJ(Q,K);if(!z)G.if(P._`${R.default.errors} === ${W||0}`)}}function MJ(Q,Y){let{gen:X,schema:W,opts:{useDefaults:G}}=Q;if(G)(0,bD.assignDefaults)(Q,Y.type);X.block(()=>{for(let $ of Y.rules)if((0,s9.shouldUseRule)(W,$))EJ(Q,$.keyword,$.definition,Y.type)})}function uD(Q,Y){if(Q.schemaEnv.meta||!Q.opts.strictTypes)return;if(hD(Q,Y),!Q.opts.allowUnionTypes)fD(Q,Y);lD(Q,Q.dataTypes)}function hD(Q,Y){if(!Y.length)return;if(!Q.dataTypes.length){Q.dataTypes=Y;return}Y.forEach((X)=>{if(!IJ(Q.dataTypes,X))e9(Q,`type "${X}" not allowed by context "${Q.dataTypes.join(",")}"`)}),cD(Q,Y)}function fD(Q,Y){if(Y.length>1&&!(Y.length===2&&Y.includes("null")))e9(Q,"use allowUnionTypes to allow union type keyword")}function lD(Q,Y){let X=Q.self.RULES.all;for(let W in X){let G=X[W];if(typeof G=="object"&&(0,s9.shouldUseRule)(Q.schema,G)){let{type:$}=G.definition;if($.length&&!$.some((J)=>mD(Y,J)))e9(Q,`missing type "${$.join(",")}" for keyword "${W}"`)}}}function mD(Q,Y){return Q.includes(Y)||Y==="number"&&Q.includes("integer")}function IJ(Q,Y){return Q.includes(Y)||Y==="integer"&&Q.includes("number")}function cD(Q,Y){let X=[];for(let W of Q.dataTypes)if(IJ(Y,W))X.push(W);else if(Y.includes("integer")&&W==="number")X.push("integer");Q.dataTypes=X}function e9(Q,Y){let X=Q.schemaEnv.baseId+Q.errSchemaPath;Y+=` at "${X}" (strictTypes)`,(0,d0.checkStrictMode)(Q,Y,Q.opts.strictTypes)}class QY{constructor(Q,Y,X){if((0,I6.validateKeywordUsage)(Q,Y,X),this.gen=Q.gen,this.allErrors=Q.allErrors,this.keyword=X,this.data=Q.data,this.schema=Q.schema[X],this.$data=Y.$data&&Q.opts.$data&&this.schema&&this.schema.$data,this.schemaValue=(0,d0.schemaRefOrVal)(Q,this.schema,X,this.$data),this.schemaType=Y.schemaType,this.parentSchema=Q.schema,this.params={},this.it=Q,this.def=Y,this.$data)this.schemaCode=Q.gen.const("vSchema",TJ(this.$data,Q));else if(this.schemaCode=this.schemaValue,!(0,I6.validSchemaType)(this.schema,Y.schemaType,Y.allowUndefined))throw Error(`${X} value must be ${JSON.stringify(Y.schemaType)}`);if("code"in Y?Y.trackErrors:Y.errors!==!1)this.errsCount=Q.gen.const("_errs",R.default.errors)}result(Q,Y,X){this.failResult((0,P.not)(Q),Y,X)}failResult(Q,Y,X){if(this.gen.if(Q),X)X();else this.error();if(Y){if(this.gen.else(),Y(),this.allErrors)this.gen.endIf()}else if(this.allErrors)this.gen.endIf();else this.gen.else()}pass(Q,Y){this.failResult((0,P.not)(Q),void 0,Y)}fail(Q){if(Q===void 0){if(this.error(),!this.allErrors)this.gen.if(!1);return}if(this.gen.if(Q),this.error(),this.allErrors)this.gen.endIf();else this.gen.else()}fail$data(Q){if(!this.$data)return this.fail(Q);let{schemaCode:Y}=this;this.fail(P._`${Y} !== undefined && (${(0,P.or)(this.invalid$data(),Q)})`)}error(Q,Y,X){if(Y){this.setParams(Y),this._error(Q,X),this.setParams({});return}this._error(Q,X)}_error(Q,Y){(Q?P6.reportExtraError:P6.reportError)(this,this.def.error,Y)}$dataError(){(0,P6.reportError)(this,this.def.$dataError||P6.keyword$DataError)}reset(){if(this.errsCount===void 0)throw Error('add "trackErrors" to keyword definition');(0,P6.resetErrorsCount)(this.gen,this.errsCount)}ok(Q){if(!this.allErrors)this.gen.if(Q)}setParams(Q,Y){if(Y)Object.assign(this.params,Q);else this.params=Q}block$data(Q,Y,X=P.nil){this.gen.block(()=>{this.check$data(Q,X),Y()})}check$data(Q=P.nil,Y=P.nil){if(!this.$data)return;let{gen:X,schemaCode:W,schemaType:G,def:$}=this;if(X.if((0,P.or)(P._`${W} === undefined`,Y)),Q!==P.nil)X.assign(Q,!0);if(G.length||$.validateSchema){if(X.elseIf(this.invalid$data()),this.$dataError(),Q!==P.nil)X.assign(Q,!1)}X.else()}invalid$data(){let{gen:Q,schemaCode:Y,schemaType:X,def:W,it:G}=this;return(0,P.or)($(),J());function $(){if(X.length){if(!(Y instanceof P.Name))throw Error("ajv implementation error");let z=Array.isArray(X)?X:[X];return P._`${(0,m4.checkDataTypes)(z,Y,G.opts.strictNumbers,m4.DataType.Wrong)}`}return P.nil}function J(){if(W.validateSchema){let z=Q.scopeValue("validate$data",{ref:W.validateSchema});return P._`!${z}(${Y})`}return P.nil}}subschema(Q,Y){let X=(0,a9.getSubschema)(this.it,Q);(0,a9.extendSubschemaData)(X,this.it,Q),(0,a9.extendSubschemaMode)(X,Q);let W={...this.it,...X,items:void 0,props:void 0};return RD(W,Y),W}mergeEvaluated(Q,Y){let{it:X,gen:W}=this;if(!X.opts.unevaluated)return;if(X.props!==!0&&Q.props!==void 0)X.props=d0.mergeEvaluated.props(W,Q.props,X.props,Y);if(X.items!==!0&&Q.items!==void 0)X.items=d0.mergeEvaluated.items(W,Q.items,X.items,Y)}mergeValidEvaluated(Q,Y){let{it:X,gen:W}=this;if(X.opts.unevaluated&&(X.props!==!0||X.items!==!0))return W.if(Y,()=>this.mergeEvaluated(Q,P.Name)),!0}}SJ.KeywordCxt=QY;function EJ(Q,Y,X,W){let G=new QY(Q,X,Y);if("code"in X)X.code(G,W);else if(G.$data&&X.validate)(0,I6.funcKeywordCode)(G,X);else if("macro"in X)(0,I6.macroKeywordCode)(G,X);else if(X.compile||X.validate)(0,I6.funcKeywordCode)(G,X)}var pD=/^\/(?:[^~]|~0|~1)*$/,iD=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function TJ(Q,{dataLevel:Y,dataNames:X,dataPathArr:W}){let G,$;if(Q==="")return R.default.rootData;if(Q[0]==="/"){if(!pD.test(Q))throw Error(`Invalid JSON-pointer: ${Q}`);G=Q,$=R.default.rootData}else{let U=iD.exec(Q);if(!U)throw Error(`Invalid JSON-pointer: ${Q}`);let A=+U[1];if(G=U[2],G==="#"){if(A>=Y)throw Error(H("property/index",A));return W[Y-A]}if(A>Y)throw Error(H("data",A));if($=X[Y-A],!G)return $}let J=$,z=G.split("/");for(let U of z)if(U)$=P._`${$}${(0,P.getProperty)((0,d0.unescapeJsonPointer)(U))}`,J=P._`${J} && ${$}`;return J;function H(U,A){return`Cannot access ${U} ${A} levels up, current level is ${Y}`}}SJ.getData=TJ});var c4=w((kJ)=>{Object.defineProperty(kJ,"__esModule",{value:!0});class CJ extends Error{constructor(Q){super("validation failed");this.errors=Q,this.ajv=this.validation=!0}}kJ.default=CJ});var T6=w((xJ)=>{Object.defineProperty(xJ,"__esModule",{value:!0});var YY=j6();class vJ extends Error{constructor(Q,Y,X,W){super(W||`can't resolve reference ${X} from id ${Y}`);this.missingRef=(0,YY.resolveUrl)(Q,Y,X),this.missingSchema=(0,YY.normalizeId)((0,YY.getFullPath)(Q,this.missingRef))}}xJ.default=vJ});var i4=w((gJ)=>{Object.defineProperty(gJ,"__esModule",{value:!0});gJ.resolveSchema=gJ.getCompilingSchema=gJ.resolveRef=gJ.compileSchema=gJ.SchemaEnv=void 0;var k0=v(),tD=c4(),w1=r0(),v0=j6(),_J=l(),aD=E6();class S6{constructor(Q){var Y;this.refs={},this.dynamicAnchors={};let X;if(typeof Q.schema=="object")X=Q.schema;this.schema=Q.schema,this.schemaId=Q.schemaId,this.root=Q.root||this,this.baseId=(Y=Q.baseId)!==null&&Y!==void 0?Y:(0,v0.normalizeId)(X===null||X===void 0?void 0:X[Q.schemaId||"$id"]),this.schemaPath=Q.schemaPath,this.localRefs=Q.localRefs,this.meta=Q.meta,this.$async=X===null||X===void 0?void 0:X.$async,this.refs={}}}gJ.SchemaEnv=S6;function WY(Q){let Y=yJ.call(this,Q);if(Y)return Y;let X=(0,v0.getFullPath)(this.opts.uriResolver,Q.root.baseId),{es5:W,lines:G}=this.opts.code,{ownProperties:$}=this.opts,J=new k0.CodeGen(this.scope,{es5:W,lines:G,ownProperties:$}),z;if(Q.$async)z=J.scopeValue("Error",{ref:tD.default,code:k0._`require("ajv/dist/runtime/validation_error").default`});let H=J.scopeName("validate");Q.validateName=H;let U={gen:J,allErrors:this.opts.allErrors,data:w1.default.data,parentData:w1.default.parentData,parentDataProperty:w1.default.parentDataProperty,dataNames:[w1.default.data],dataPathArr:[k0.nil],dataLevel:0,dataTypes:[],definedProperties:new Set,topSchemaRef:J.scopeValue("schema",this.opts.code.source===!0?{ref:Q.schema,code:(0,k0.stringify)(Q.schema)}:{ref:Q.schema}),validateName:H,ValidationError:z,schema:Q.schema,schemaEnv:Q,rootId:X,baseId:Q.baseId||X,schemaPath:k0.nil,errSchemaPath:Q.schemaPath||(this.opts.jtd?"":"#"),errorPath:k0._`""`,opts:this.opts,self:this},A;try{this._compilations.add(Q),(0,aD.validateFunctionCode)(U),J.optimize(this.opts.code.optimize);let B=J.toString();if(A=`${J.scopeRefs(w1.default.scope)}return ${B}`,this.opts.code.process)A=this.opts.code.process(A,Q);let L=Function(`${w1.default.self}`,`${w1.default.scope}`,A)(this,this.scope.get());if(this.scope.value(H,{ref:L}),L.errors=null,L.schema=Q.schema,L.schemaEnv=Q,Q.$async)L.$async=!0;if(this.opts.code.source===!0)L.source={validateName:H,validateCode:B,scopeValues:J._values};if(this.opts.unevaluated){let{props:O,items:M}=U;if(L.evaluated={props:O instanceof k0.Name?void 0:O,items:M instanceof k0.Name?void 0:M,dynamicProps:O instanceof k0.Name,dynamicItems:M instanceof k0.Name},L.source)L.source.evaluated=(0,k0.stringify)(L.evaluated)}return Q.validate=L,Q}catch(B){if(delete Q.validate,delete Q.validateName,A)this.logger.error("Error compiling schema, function code:",A);throw B}finally{this._compilations.delete(Q)}}gJ.compileSchema=WY;function sD(Q,Y,X){var W;X=(0,v0.resolveUrl)(this.opts.uriResolver,Y,X);let G=Q.refs[X];if(G)return G;let $=YL.call(this,Q,X);if($===void 0){let J=(W=Q.localRefs)===null||W===void 0?void 0:W[X],{schemaId:z}=this.opts;if(J)$=new S6({schema:J,schemaId:z,root:Q,baseId:Y})}if($===void 0)return;return Q.refs[X]=eD.call(this,$)}gJ.resolveRef=sD;function eD(Q){if((0,v0.inlineRef)(Q.schema,this.opts.inlineRefs))return Q.schema;return Q.validate?Q:WY.call(this,Q)}function yJ(Q){for(let Y of this._compilations)if(QL(Y,Q))return Y}gJ.getCompilingSchema=yJ;function QL(Q,Y){return Q.schema===Y.schema&&Q.root===Y.root&&Q.baseId===Y.baseId}function YL(Q,Y){let X;while(typeof(X=this.refs[Y])=="string")Y=X;return X||this.schemas[Y]||p4.call(this,Q,Y)}function p4(Q,Y){let X=this.opts.uriResolver.parse(Y),W=(0,v0._getFullPath)(this.opts.uriResolver,X),G=(0,v0.getFullPath)(this.opts.uriResolver,Q.baseId,void 0);if(Object.keys(Q.schema).length>0&&W===G)return XY.call(this,X,Q);let $=(0,v0.normalizeId)(W),J=this.refs[$]||this.schemas[$];if(typeof J=="string"){let z=p4.call(this,Q,J);if(typeof(z===null||z===void 0?void 0:z.schema)!=="object")return;return XY.call(this,X,z)}if(typeof(J===null||J===void 0?void 0:J.schema)!=="object")return;if(!J.validate)WY.call(this,J);if($===(0,v0.normalizeId)(Y)){let{schema:z}=J,{schemaId:H}=this.opts,U=z[H];if(U)G=(0,v0.resolveUrl)(this.opts.uriResolver,G,U);return new S6({schema:z,schemaId:H,root:Q,baseId:G})}return XY.call(this,X,J)}gJ.resolveSchema=p4;var XL=new Set(["properties","patternProperties","enum","dependencies","definitions"]);function XY(Q,{baseId:Y,schema:X,root:W}){var G;if(((G=Q.fragment)===null||G===void 0?void 0:G[0])!=="/")return;for(let z of Q.fragment.slice(1).split("/")){if(typeof X==="boolean")return;let H=X[(0,_J.unescapeFragment)(z)];if(H===void 0)return;X=H;let U=typeof X==="object"&&X[this.opts.schemaId];if(!XL.has(z)&&U)Y=(0,v0.resolveUrl)(this.opts.uriResolver,Y,U)}let $;if(typeof X!="boolean"&&X.$ref&&!(0,_J.schemaHasRulesButRef)(X,this.RULES)){let z=(0,v0.resolveUrl)(this.opts.uriResolver,Y,X.$ref);$=p4.call(this,W,z)}let{schemaId:J}=this.opts;if($=$||new S6({schema:X,schemaId:J,root:W,baseId:Y}),$.schema!==$.root.schema)return $;return}});var hJ=w((uP,zL)=>{zL.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 $Y=w((hP,cJ)=>{var HL=RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu),lJ=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 GY(Q){let Y="",X=0,W=0;for(W=0;W<Q.length;W++){if(X=Q[W].charCodeAt(0),X===48)continue;if(!(X>=48&&X<=57||X>=65&&X<=70||X>=97&&X<=102))return"";Y+=Q[W];break}for(W+=1;W<Q.length;W++){if(X=Q[W].charCodeAt(0),!(X>=48&&X<=57||X>=65&&X<=70||X>=97&&X<=102))return"";Y+=Q[W]}return Y}var UL=RegExp.prototype.test.bind(/[^!"$&'()*+,\-.;=_`a-z{}~]/u);function fJ(Q){return Q.length=0,!0}function AL(Q,Y,X){if(Q.length){let W=GY(Q);if(W!=="")Y.push(W);else return X.error=!0,!1;Q.length=0}return!0}function BL(Q){let Y=0,X={error:!1,address:"",zone:""},W=[],G=[],$=!1,J=!1,z=AL;for(let H=0;H<Q.length;H++){let U=Q[H];if(U==="["||U==="]")continue;if(U===":"){if($===!0)J=!0;if(!z(G,W,X))break;if(++Y>7){X.error=!0;break}if(H>0&&Q[H-1]===":")$=!0;W.push(":");continue}else if(U==="%"){if(!z(G,W,X))break;z=fJ}else{G.push(U);continue}}if(G.length)if(z===fJ)X.zone=G.join("");else if(J)W.push(G.join(""));else W.push(GY(G));return X.address=W.join(""),X}function mJ(Q){if(KL(Q,":")<2)return{host:Q,isIPV6:!1};let Y=BL(Q);if(!Y.error){let{address:X,address:W}=Y;if(Y.zone)X+="%"+Y.zone,W+="%25"+Y.zone;return{host:X,isIPV6:!0,escapedHost:W}}else return{host:Q,isIPV6:!1}}function KL(Q,Y){let X=0;for(let W=0;W<Q.length;W++)if(Q[W]===Y)X++;return X}function DL(Q){let Y=Q,X=[],W=-1,G=0;while(G=Y.length){if(G===1)if(Y===".")break;else if(Y==="/"){X.push("/");break}else{X.push(Y);break}else if(G===2){if(Y[0]==="."){if(Y[1]===".")break;else if(Y[1]==="/"){Y=Y.slice(2);continue}}else if(Y[0]==="/"){if(Y[1]==="."||Y[1]==="/"){X.push("/");break}}}else if(G===3){if(Y==="/.."){if(X.length!==0)X.pop();X.push("/");break}}if(Y[0]==="."){if(Y[1]==="."){if(Y[2]==="/"){Y=Y.slice(3);continue}}else if(Y[1]==="/"){Y=Y.slice(2);continue}}else if(Y[0]==="/"){if(Y[1]==="."){if(Y[2]==="/"){Y=Y.slice(2);continue}else if(Y[2]==="."){if(Y[3]==="/"){if(Y=Y.slice(3),X.length!==0)X.pop();continue}}}}if((W=Y.indexOf("/",1))===-1){X.push(Y);break}else X.push(Y.slice(0,W)),Y=Y.slice(W)}return X.join("")}function LL(Q,Y){let X=Y!==!0?escape:unescape;if(Q.scheme!==void 0)Q.scheme=X(Q.scheme);if(Q.userinfo!==void 0)Q.userinfo=X(Q.userinfo);if(Q.host!==void 0)Q.host=X(Q.host);if(Q.path!==void 0)Q.path=X(Q.path);if(Q.query!==void 0)Q.query=X(Q.query);if(Q.fragment!==void 0)Q.fragment=X(Q.fragment);return Q}function qL(Q){let Y=[];if(Q.userinfo!==void 0)Y.push(Q.userinfo),Y.push("@");if(Q.host!==void 0){let X=unescape(Q.host);if(!lJ(X)){let W=mJ(X);if(W.isIPV6===!0)X=`[${W.escapedHost}]`;else X=Q.host}Y.push(X)}if(typeof Q.port==="number"||typeof Q.port==="string")Y.push(":"),Y.push(String(Q.port));return Y.length?Y.join(""):void 0}cJ.exports={nonSimpleDomain:UL,recomposeAuthority:qL,normalizeComponentEncoding:LL,removeDotSegments:DL,isIPv4:lJ,isUUID:HL,normalizeIPv6:mJ,stringArrayToHexStripped:GY}});var dJ=w((fP,rJ)=>{var{isUUID:FL}=$Y(),OL=/([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-.:;=@]|%[\da-f]{2})+)/iu,ML=["http","https","ws","wss","urn","urn:uuid"];function VL(Q){return ML.indexOf(Q)!==-1}function JY(Q){if(Q.secure===!0)return!0;else if(Q.secure===!1)return!1;else if(Q.scheme)return Q.scheme.length===3&&(Q.scheme[0]==="w"||Q.scheme[0]==="W")&&(Q.scheme[1]==="s"||Q.scheme[1]==="S")&&(Q.scheme[2]==="s"||Q.scheme[2]==="S");else return!1}function pJ(Q){if(!Q.host)Q.error=Q.error||"HTTP URIs must have a host.";return Q}function iJ(Q){let Y=String(Q.scheme).toLowerCase()==="https";if(Q.port===(Y?443:80)||Q.port==="")Q.port=void 0;if(!Q.path)Q.path="/";return Q}function ZL(Q){return Q.secure=JY(Q),Q.resourceName=(Q.path||"/")+(Q.query?"?"+Q.query:""),Q.path=void 0,Q.query=void 0,Q}function NL(Q){if(Q.port===(JY(Q)?443:80)||Q.port==="")Q.port=void 0;if(typeof Q.secure==="boolean")Q.scheme=Q.secure?"wss":"ws",Q.secure=void 0;if(Q.resourceName){let[Y,X]=Q.resourceName.split("?");Q.path=Y&&Y!=="/"?Y:void 0,Q.query=X,Q.resourceName=void 0}return Q.fragment=void 0,Q}function wL(Q,Y){if(!Q.path)return Q.error="URN can not be parsed",Q;let X=Q.path.match(OL);if(X){let W=Y.scheme||Q.scheme||"urn";Q.nid=X[1].toLowerCase(),Q.nss=X[2];let G=`${W}:${Y.nid||Q.nid}`,$=zY(G);if(Q.path=void 0,$)Q=$.parse(Q,Y)}else Q.error=Q.error||"URN can not be parsed.";return Q}function bL(Q,Y){if(Q.nid===void 0)throw Error("URN without nid cannot be serialized");let X=Y.scheme||Q.scheme||"urn",W=Q.nid.toLowerCase(),G=`${X}:${Y.nid||W}`,$=zY(G);if($)Q=$.serialize(Q,Y);let J=Q,z=Q.nss;return J.path=`${W||Y.nid}:${z}`,Y.skipEscape=!0,J}function jL(Q,Y){let X=Q;if(X.uuid=X.nss,X.nss=void 0,!Y.tolerant&&(!X.uuid||!FL(X.uuid)))X.error=X.error||"UUID is not valid.";return X}function PL(Q){let Y=Q;return Y.nss=(Q.uuid||"").toLowerCase(),Y}var nJ={scheme:"http",domainHost:!0,parse:pJ,serialize:iJ},IL={scheme:"https",domainHost:nJ.domainHost,parse:pJ,serialize:iJ},n4={scheme:"ws",domainHost:!0,parse:ZL,serialize:NL},EL={scheme:"wss",domainHost:n4.domainHost,parse:n4.parse,serialize:n4.serialize},TL={scheme:"urn",parse:wL,serialize:bL,skipNormalize:!0},SL={scheme:"urn:uuid",parse:jL,serialize:PL,skipNormalize:!0},r4={http:nJ,https:IL,ws:n4,wss:EL,urn:TL,"urn:uuid":SL};Object.setPrototypeOf(r4,null);function zY(Q){return Q&&(r4[Q]||r4[Q.toLowerCase()])||void 0}rJ.exports={wsIsSecure:JY,SCHEMES:r4,isValidSchemeName:VL,getSchemeHandler:zY}});var aJ=w((lP,o4)=>{var{normalizeIPv6:RL,removeDotSegments:R6,recomposeAuthority:CL,normalizeComponentEncoding:d4,isIPv4:kL,nonSimpleDomain:vL}=$Y(),{SCHEMES:xL,getSchemeHandler:oJ}=dJ();function _L(Q,Y){if(typeof Q==="string")Q=u0(o0(Q,Y),Y);else if(typeof Q==="object")Q=o0(u0(Q,Y),Y);return Q}function yL(Q,Y,X){let W=X?Object.assign({scheme:"null"},X):{scheme:"null"},G=tJ(o0(Q,W),o0(Y,W),W,!0);return W.skipEscape=!0,u0(G,W)}function tJ(Q,Y,X,W){let G={};if(!W)Q=o0(u0(Q,X),X),Y=o0(u0(Y,X),X);if(X=X||{},!X.tolerant&&Y.scheme)G.scheme=Y.scheme,G.userinfo=Y.userinfo,G.host=Y.host,G.port=Y.port,G.path=R6(Y.path||""),G.query=Y.query;else{if(Y.userinfo!==void 0||Y.host!==void 0||Y.port!==void 0)G.userinfo=Y.userinfo,G.host=Y.host,G.port=Y.port,G.path=R6(Y.path||""),G.query=Y.query;else{if(!Y.path)if(G.path=Q.path,Y.query!==void 0)G.query=Y.query;else G.query=Q.query;else{if(Y.path[0]==="/")G.path=R6(Y.path);else{if((Q.userinfo!==void 0||Q.host!==void 0||Q.port!==void 0)&&!Q.path)G.path="/"+Y.path;else if(!Q.path)G.path=Y.path;else G.path=Q.path.slice(0,Q.path.lastIndexOf("/")+1)+Y.path;G.path=R6(G.path)}G.query=Y.query}G.userinfo=Q.userinfo,G.host=Q.host,G.port=Q.port}G.scheme=Q.scheme}return G.fragment=Y.fragment,G}function gL(Q,Y,X){if(typeof Q==="string")Q=unescape(Q),Q=u0(d4(o0(Q,X),!0),{...X,skipEscape:!0});else if(typeof Q==="object")Q=u0(d4(Q,!0),{...X,skipEscape:!0});if(typeof Y==="string")Y=unescape(Y),Y=u0(d4(o0(Y,X),!0),{...X,skipEscape:!0});else if(typeof Y==="object")Y=u0(d4(Y,!0),{...X,skipEscape:!0});return Q.toLowerCase()===Y.toLowerCase()}function u0(Q,Y){let X={host:Q.host,scheme:Q.scheme,userinfo:Q.userinfo,port:Q.port,path:Q.path,query:Q.query,nid:Q.nid,nss:Q.nss,uuid:Q.uuid,fragment:Q.fragment,reference:Q.reference,resourceName:Q.resourceName,secure:Q.secure,error:""},W=Object.assign({},Y),G=[],$=oJ(W.scheme||X.scheme);if($&&$.serialize)$.serialize(X,W);if(X.path!==void 0)if(!W.skipEscape){if(X.path=escape(X.path),X.scheme!==void 0)X.path=X.path.split("%3A").join(":")}else X.path=unescape(X.path);if(W.reference!=="suffix"&&X.scheme)G.push(X.scheme,":");let J=CL(X);if(J!==void 0){if(W.reference!=="suffix")G.push("//");if(G.push(J),X.path&&X.path[0]!=="/")G.push("/")}if(X.path!==void 0){let z=X.path;if(!W.absolutePath&&(!$||!$.absolutePath))z=R6(z);if(J===void 0&&z[0]==="/"&&z[1]==="/")z="/%2F"+z.slice(2);G.push(z)}if(X.query!==void 0)G.push("?",X.query);if(X.fragment!==void 0)G.push("#",X.fragment);return G.join("")}var uL=/^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u;function o0(Q,Y){let X=Object.assign({},Y),W={scheme:void 0,userinfo:void 0,host:"",port:void 0,path:"",query:void 0,fragment:void 0},G=!1;if(X.reference==="suffix")if(X.scheme)Q=X.scheme+":"+Q;else Q="//"+Q;let $=Q.match(uL);if($){if(W.scheme=$[1],W.userinfo=$[3],W.host=$[4],W.port=parseInt($[5],10),W.path=$[6]||"",W.query=$[7],W.fragment=$[8],isNaN(W.port))W.port=$[5];if(W.host)if(kL(W.host)===!1){let H=RL(W.host);W.host=H.host.toLowerCase(),G=H.isIPV6}else G=!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(X.reference&&X.reference!=="suffix"&&X.reference!==W.reference)W.error=W.error||"URI is not a "+X.reference+" reference.";let J=oJ(X.scheme||W.scheme);if(!X.unicodeSupport&&(!J||!J.unicodeSupport)){if(W.host&&(X.domainHost||J&&J.domainHost)&&G===!1&&vL(W.host))try{W.host=URL.domainToASCII(W.host.toLowerCase())}catch(z){W.error=W.error||"Host's domain name can not be converted to ASCII: "+z}}if(!J||J&&!J.skipNormalize){if(Q.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(J&&J.parse)J.parse(W,X)}else W.error=W.error||"URI can not be parsed.";return W}var HY={SCHEMES:xL,normalize:_L,resolve:yL,resolveComponent:tJ,equal:gL,serialize:u0,parse:o0};o4.exports=HY;o4.exports.default=HY;o4.exports.fastUri=HY});var Qz=w((eJ)=>{Object.defineProperty(eJ,"__esModule",{value:!0});var sJ=aJ();sJ.code='require("ajv/dist/runtime/uri").default';eJ.default=sJ});var Hz=w((t0)=>{Object.defineProperty(t0,"__esModule",{value:!0});t0.CodeGen=t0.Name=t0.nil=t0.stringify=t0.str=t0._=t0.KeywordCxt=void 0;var fL=E6();Object.defineProperty(t0,"KeywordCxt",{enumerable:!0,get:function(){return fL.KeywordCxt}});var f1=v();Object.defineProperty(t0,"_",{enumerable:!0,get:function(){return f1._}});Object.defineProperty(t0,"str",{enumerable:!0,get:function(){return f1.str}});Object.defineProperty(t0,"stringify",{enumerable:!0,get:function(){return f1.stringify}});Object.defineProperty(t0,"nil",{enumerable:!0,get:function(){return f1.nil}});Object.defineProperty(t0,"Name",{enumerable:!0,get:function(){return f1.Name}});Object.defineProperty(t0,"CodeGen",{enumerable:!0,get:function(){return f1.CodeGen}});var lL=c4(),$z=T6(),mL=l9(),C6=i4(),cL=v(),k6=j6(),t4=b6(),AY=l(),Yz=hJ(),pL=Qz(),Jz=(Q,Y)=>new RegExp(Q,Y);Jz.code="new RegExp";var iL=["removeAdditional","useDefaults","coerceTypes"],nL=new Set(["validate","serialize","parse","wrapper","root","schema","keyword","pattern","formats","validate$data","func","obj","Error"]),rL={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."},dL={ignoreKeywordsWithRef:"",jsPropertySyntax:"",unicode:'"minLength"/"maxLength" account for unicode characters by default.'},Xz=200;function oL(Q){var Y,X,W,G,$,J,z,H,U,A,B,K,L,O,M,Z,V,S,E,_,T,y0,l0,OQ,MQ;let n1=Q.strict,VQ=(Y=Q.code)===null||Y===void 0?void 0:Y.optimize,rY=VQ===!0||VQ===void 0?1:VQ||0,dY=(W=(X=Q.code)===null||X===void 0?void 0:X.regExp)!==null&&W!==void 0?W:Jz,n5=(G=Q.uriResolver)!==null&&G!==void 0?G:pL.default;return{strictSchema:(J=($=Q.strictSchema)!==null&&$!==void 0?$:n1)!==null&&J!==void 0?J:!0,strictNumbers:(H=(z=Q.strictNumbers)!==null&&z!==void 0?z:n1)!==null&&H!==void 0?H:!0,strictTypes:(A=(U=Q.strictTypes)!==null&&U!==void 0?U:n1)!==null&&A!==void 0?A:"log",strictTuples:(K=(B=Q.strictTuples)!==null&&B!==void 0?B:n1)!==null&&K!==void 0?K:"log",strictRequired:(O=(L=Q.strictRequired)!==null&&L!==void 0?L:n1)!==null&&O!==void 0?O:!1,code:Q.code?{...Q.code,optimize:rY,regExp:dY}:{optimize:rY,regExp:dY},loopRequired:(M=Q.loopRequired)!==null&&M!==void 0?M:Xz,loopEnum:(Z=Q.loopEnum)!==null&&Z!==void 0?Z:Xz,meta:(V=Q.meta)!==null&&V!==void 0?V:!0,messages:(S=Q.messages)!==null&&S!==void 0?S:!0,inlineRefs:(E=Q.inlineRefs)!==null&&E!==void 0?E:!0,schemaId:(_=Q.schemaId)!==null&&_!==void 0?_:"$id",addUsedSchema:(T=Q.addUsedSchema)!==null&&T!==void 0?T:!0,validateSchema:(y0=Q.validateSchema)!==null&&y0!==void 0?y0:!0,validateFormats:(l0=Q.validateFormats)!==null&&l0!==void 0?l0:!0,unicodeRegExp:(OQ=Q.unicodeRegExp)!==null&&OQ!==void 0?OQ:!0,int32range:(MQ=Q.int32range)!==null&&MQ!==void 0?MQ:!0,uriResolver:n5}}class a4{constructor(Q={}){this.schemas={},this.refs={},this.formats={},this._compilations=new Set,this._loading={},this._cache=new Map,Q=this.opts={...Q,...oL(Q)};let{es5:Y,lines:X}=this.opts.code;this.scope=new cL.ValueScope({scope:{},prefixes:nL,es5:Y,lines:X}),this.logger=Yq(Q.logger);let W=Q.validateFormats;if(Q.validateFormats=!1,this.RULES=(0,mL.getRules)(),Wz.call(this,rL,Q,"NOT SUPPORTED"),Wz.call(this,dL,Q,"DEPRECATED","warn"),this._metaOpts=eL.call(this),Q.formats)aL.call(this);if(this._addVocabularies(),this._addDefaultMetaSchema(),Q.keywords)sL.call(this,Q.keywords);if(typeof Q.meta=="object")this.addMetaSchema(Q.meta);tL.call(this),Q.validateFormats=W}_addVocabularies(){this.addKeyword("$async")}_addDefaultMetaSchema(){let{$data:Q,meta:Y,schemaId:X}=this.opts,W=Yz;if(X==="id")W={...Yz},W.id=W.$id,delete W.$id;if(Y&&Q)this.addMetaSchema(W,W[X],!1)}defaultMeta(){let{meta:Q,schemaId:Y}=this.opts;return this.opts.defaultMeta=typeof Q=="object"?Q[Y]||Q:void 0}validate(Q,Y){let X;if(typeof Q=="string"){if(X=this.getSchema(Q),!X)throw Error(`no schema with key or ref "${Q}"`)}else X=this.compile(Q);let W=X(Y);if(!("$async"in X))this.errors=X.errors;return W}compile(Q,Y){let X=this._addSchema(Q,Y);return X.validate||this._compileSchemaEnv(X)}compileAsync(Q,Y){if(typeof this.opts.loadSchema!="function")throw Error("options.loadSchema should be a function");let{loadSchema:X}=this.opts;return W.call(this,Q,Y);async function W(U,A){await G.call(this,U.$schema);let B=this._addSchema(U,A);return B.validate||$.call(this,B)}async function G(U){if(U&&!this.getSchema(U))await W.call(this,{$ref:U},!0)}async function $(U){try{return this._compileSchemaEnv(U)}catch(A){if(!(A instanceof $z.default))throw A;return J.call(this,A),await z.call(this,A.missingSchema),$.call(this,U)}}function J({missingSchema:U,missingRef:A}){if(this.refs[U])throw Error(`AnySchema ${U} is loaded but ${A} cannot be resolved`)}async function z(U){let A=await H.call(this,U);if(!this.refs[U])await G.call(this,A.$schema);if(!this.refs[U])this.addSchema(A,U,Y)}async function H(U){let A=this._loading[U];if(A)return A;try{return await(this._loading[U]=X(U))}finally{delete this._loading[U]}}}addSchema(Q,Y,X,W=this.opts.validateSchema){if(Array.isArray(Q)){for(let $ of Q)this.addSchema($,void 0,X,W);return this}let G;if(typeof Q==="object"){let{schemaId:$}=this.opts;if(G=Q[$],G!==void 0&&typeof G!="string")throw Error(`schema ${$} must be string`)}return Y=(0,k6.normalizeId)(Y||G),this._checkUnique(Y),this.schemas[Y]=this._addSchema(Q,X,Y,W,!0),this}addMetaSchema(Q,Y,X=this.opts.validateSchema){return this.addSchema(Q,Y,!0,X),this}validateSchema(Q,Y){if(typeof Q=="boolean")return!0;let X;if(X=Q.$schema,X!==void 0&&typeof X!="string")throw Error("$schema must be a string");if(X=X||this.opts.defaultMeta||this.defaultMeta(),!X)return this.logger.warn("meta-schema not available"),this.errors=null,!0;let W=this.validate(X,Q);if(!W&&Y){let G="schema is invalid: "+this.errorsText();if(this.opts.validateSchema==="log")this.logger.error(G);else throw Error(G)}return W}getSchema(Q){let Y;while(typeof(Y=Gz.call(this,Q))=="string")Q=Y;if(Y===void 0){let{schemaId:X}=this.opts,W=new C6.SchemaEnv({schema:{},schemaId:X});if(Y=C6.resolveSchema.call(this,W,Q),!Y)return;this.refs[Q]=Y}return Y.validate||this._compileSchemaEnv(Y)}removeSchema(Q){if(Q instanceof RegExp)return this._removeAllSchemas(this.schemas,Q),this._removeAllSchemas(this.refs,Q),this;switch(typeof Q){case"undefined":return this._removeAllSchemas(this.schemas),this._removeAllSchemas(this.refs),this._cache.clear(),this;case"string":{let Y=Gz.call(this,Q);if(typeof Y=="object")this._cache.delete(Y.schema);return delete this.schemas[Q],delete this.refs[Q],this}case"object":{let Y=Q;this._cache.delete(Y);let X=Q[this.opts.schemaId];if(X)X=(0,k6.normalizeId)(X),delete this.schemas[X],delete this.refs[X];return this}default:throw Error("ajv.removeSchema: invalid parameter")}}addVocabulary(Q){for(let Y of Q)this.addKeyword(Y);return this}addKeyword(Q,Y){let X;if(typeof Q=="string"){if(X=Q,typeof Y=="object")this.logger.warn("these parameters are deprecated, see docs for addKeyword"),Y.keyword=X}else if(typeof Q=="object"&&Y===void 0){if(Y=Q,X=Y.keyword,Array.isArray(X)&&!X.length)throw Error("addKeywords: keyword must be string or non-empty array")}else throw Error("invalid addKeywords parameters");if(Wq.call(this,X,Y),!Y)return(0,AY.eachItem)(X,(G)=>UY.call(this,G)),this;$q.call(this,Y);let W={...Y,type:(0,t4.getJSONTypes)(Y.type),schemaType:(0,t4.getJSONTypes)(Y.schemaType)};return(0,AY.eachItem)(X,W.type.length===0?(G)=>UY.call(this,G,W):(G)=>W.type.forEach(($)=>UY.call(this,G,W,$))),this}getKeyword(Q){let Y=this.RULES.all[Q];return typeof Y=="object"?Y.definition:!!Y}removeKeyword(Q){let{RULES:Y}=this;delete Y.keywords[Q],delete Y.all[Q];for(let X of Y.rules){let W=X.rules.findIndex((G)=>G.keyword===Q);if(W>=0)X.rules.splice(W,1)}return this}addFormat(Q,Y){if(typeof Y=="string")Y=new RegExp(Y);return this.formats[Q]=Y,this}errorsText(Q=this.errors,{separator:Y=", ",dataVar:X="data"}={}){if(!Q||Q.length===0)return"No errors";return Q.map((W)=>`${X}${W.instancePath} ${W.message}`).reduce((W,G)=>W+Y+G)}$dataMetaSchema(Q,Y){let X=this.RULES.all;Q=JSON.parse(JSON.stringify(Q));for(let W of Y){let G=W.split("/").slice(1),$=Q;for(let J of G)$=$[J];for(let J in X){let z=X[J];if(typeof z!="object")continue;let{$data:H}=z.definition,U=$[J];if(H&&U)$[J]=zz(U)}}return Q}_removeAllSchemas(Q,Y){for(let X in Q){let W=Q[X];if(!Y||Y.test(X)){if(typeof W=="string")delete Q[X];else if(W&&!W.meta)this._cache.delete(W.schema),delete Q[X]}}}_addSchema(Q,Y,X,W=this.opts.validateSchema,G=this.opts.addUsedSchema){let $,{schemaId:J}=this.opts;if(typeof Q=="object")$=Q[J];else if(this.opts.jtd)throw Error("schema must be object");else if(typeof Q!="boolean")throw Error("schema must be object or boolean");let z=this._cache.get(Q);if(z!==void 0)return z;X=(0,k6.normalizeId)($||X);let H=k6.getSchemaRefs.call(this,Q,X);if(z=new C6.SchemaEnv({schema:Q,schemaId:J,meta:Y,baseId:X,localRefs:H}),this._cache.set(z.schema,z),G&&!X.startsWith("#")){if(X)this._checkUnique(X);this.refs[X]=z}if(W)this.validateSchema(Q,!0);return z}_checkUnique(Q){if(this.schemas[Q]||this.refs[Q])throw Error(`schema with key or id "${Q}" already exists`)}_compileSchemaEnv(Q){if(Q.meta)this._compileMetaSchema(Q);else C6.compileSchema.call(this,Q);if(!Q.validate)throw Error("ajv implementation error");return Q.validate}_compileMetaSchema(Q){let Y=this.opts;this.opts=this._metaOpts;try{C6.compileSchema.call(this,Q)}finally{this.opts=Y}}}a4.ValidationError=lL.default;a4.MissingRefError=$z.default;t0.default=a4;function Wz(Q,Y,X,W="error"){for(let G in Q){let $=G;if($ in Y)this.logger[W](`${X}: option ${G}. ${Q[$]}`)}}function Gz(Q){return Q=(0,k6.normalizeId)(Q),this.schemas[Q]||this.refs[Q]}function tL(){let Q=this.opts.schemas;if(!Q)return;if(Array.isArray(Q))this.addSchema(Q);else for(let Y in Q)this.addSchema(Q[Y],Y)}function aL(){for(let Q in this.opts.formats){let Y=this.opts.formats[Q];if(Y)this.addFormat(Q,Y)}}function sL(Q){if(Array.isArray(Q)){this.addVocabulary(Q);return}this.logger.warn("keywords option as map is deprecated, pass array");for(let Y in Q){let X=Q[Y];if(!X.keyword)X.keyword=Y;this.addKeyword(X)}}function eL(){let Q={...this.opts};for(let Y of iL)delete Q[Y];return Q}var Qq={log(){},warn(){},error(){}};function Yq(Q){if(Q===!1)return Qq;if(Q===void 0)return console;if(Q.log&&Q.warn&&Q.error)return Q;throw Error("logger must implement log, warn and error methods")}var Xq=/^[a-z_$][a-z0-9_$:-]*$/i;function Wq(Q,Y){let{RULES:X}=this;if((0,AY.eachItem)(Q,(W)=>{if(X.keywords[W])throw Error(`Keyword ${W} is already defined`);if(!Xq.test(W))throw Error(`Keyword ${W} has invalid name`)}),!Y)return;if(Y.$data&&!(("code"in Y)||("validate"in Y)))throw Error('$data keyword must have "code" or "validate" function')}function UY(Q,Y,X){var W;let G=Y===null||Y===void 0?void 0:Y.post;if(X&&G)throw Error('keyword with "post" flag cannot have "type"');let{RULES:$}=this,J=G?$.post:$.rules.find(({type:H})=>H===X);if(!J)J={type:X,rules:[]},$.rules.push(J);if($.keywords[Q]=!0,!Y)return;let z={keyword:Q,definition:{...Y,type:(0,t4.getJSONTypes)(Y.type),schemaType:(0,t4.getJSONTypes)(Y.schemaType)}};if(Y.before)Gq.call(this,J,z,Y.before);else J.rules.push(z);$.all[Q]=z,(W=Y.implements)===null||W===void 0||W.forEach((H)=>this.addKeyword(H))}function Gq(Q,Y,X){let W=Q.rules.findIndex((G)=>G.keyword===X);if(W>=0)Q.rules.splice(W,0,Y);else Q.rules.push(Y),this.logger.warn(`rule ${X} is not defined`)}function $q(Q){let{metaSchema:Y}=Q;if(Y===void 0)return;if(Q.$data&&this.opts.$data)Y=zz(Y);Q.validateSchema=this.compile(Y,!0)}var Jq={$ref:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#"};function zz(Q){return{anyOf:[Q,Jq]}}});var Az=w((Uz)=>{Object.defineProperty(Uz,"__esModule",{value:!0});var Uq={keyword:"id",code(){throw Error('NOT SUPPORTED: keyword "id", use "$id" for schema ID')}};Uz.default=Uq});var Fz=w((Lz)=>{Object.defineProperty(Lz,"__esModule",{value:!0});Lz.callRef=Lz.getValidate=void 0;var Bq=T6(),Bz=I0(),M0=v(),l1=r0(),Kz=i4(),s4=l(),Kq={keyword:"$ref",schemaType:"string",code(Q){let{gen:Y,schema:X,it:W}=Q,{baseId:G,schemaEnv:$,validateName:J,opts:z,self:H}=W,{root:U}=$;if((X==="#"||X==="#/")&&G===U.baseId)return B();let A=Kz.resolveRef.call(H,U,G,X);if(A===void 0)throw new Bq.default(W.opts.uriResolver,G,X);if(A instanceof Kz.SchemaEnv)return K(A);return L(A);function B(){if($===U)return e4(Q,J,$,$.$async);let O=Y.scopeValue("root",{ref:U});return e4(Q,M0._`${O}.validate`,U,U.$async)}function K(O){let M=Dz(Q,O);e4(Q,M,O,O.$async)}function L(O){let M=Y.scopeValue("schema",z.code.source===!0?{ref:O,code:(0,M0.stringify)(O)}:{ref:O}),Z=Y.name("valid"),V=Q.subschema({schema:O,dataTypes:[],schemaPath:M0.nil,topSchemaRef:M,errSchemaPath:X},Z);Q.mergeEvaluated(V),Q.ok(Z)}}};function Dz(Q,Y){let{gen:X}=Q;return Y.validate?X.scopeValue("validate",{ref:Y.validate}):M0._`${X.scopeValue("wrapper",{ref:Y})}.validate`}Lz.getValidate=Dz;function e4(Q,Y,X,W){let{gen:G,it:$}=Q,{allErrors:J,schemaEnv:z,opts:H}=$,U=H.passContext?l1.default.this:M0.nil;if(W)A();else B();function A(){if(!z.$async)throw Error("async schema referenced by sync schema");let O=G.let("valid");G.try(()=>{if(G.code(M0._`await ${(0,Bz.callValidateCode)(Q,Y,U)}`),L(Y),!J)G.assign(O,!0)},(M)=>{if(G.if(M0._`!(${M} instanceof ${$.ValidationError})`,()=>G.throw(M)),K(M),!J)G.assign(O,!1)}),Q.ok(O)}function B(){Q.result((0,Bz.callValidateCode)(Q,Y,U),()=>L(Y),()=>K(Y))}function K(O){let M=M0._`${O}.errors`;G.assign(l1.default.vErrors,M0._`${l1.default.vErrors} === null ? ${M} : ${l1.default.vErrors}.concat(${M})`),G.assign(l1.default.errors,M0._`${l1.default.vErrors}.length`)}function L(O){var M;if(!$.opts.unevaluated)return;let Z=(M=X===null||X===void 0?void 0:X.validate)===null||M===void 0?void 0:M.evaluated;if($.props!==!0)if(Z&&!Z.dynamicProps){if(Z.props!==void 0)$.props=s4.mergeEvaluated.props(G,Z.props,$.props)}else{let V=G.var("props",M0._`${O}.evaluated.props`);$.props=s4.mergeEvaluated.props(G,V,$.props,M0.Name)}if($.items!==!0)if(Z&&!Z.dynamicItems){if(Z.items!==void 0)$.items=s4.mergeEvaluated.items(G,Z.items,$.items)}else{let V=G.var("items",M0._`${O}.evaluated.items`);$.items=s4.mergeEvaluated.items(G,V,$.items,M0.Name)}}}Lz.callRef=e4;Lz.default=Kq});var Mz=w((Oz)=>{Object.defineProperty(Oz,"__esModule",{value:!0});var qq=Az(),Fq=Fz(),Oq=["$schema","$id","$defs","$vocabulary",{keyword:"$comment"},"definitions",qq.default,Fq.default];Oz.default=Oq});var Zz=w((Vz)=>{Object.defineProperty(Vz,"__esModule",{value:!0});var QQ=v(),D1=QQ.operators,YQ={maximum:{okStr:"<=",ok:D1.LTE,fail:D1.GT},minimum:{okStr:">=",ok:D1.GTE,fail:D1.LT},exclusiveMaximum:{okStr:"<",ok:D1.LT,fail:D1.GTE},exclusiveMinimum:{okStr:">",ok:D1.GT,fail:D1.LTE}},Vq={message:({keyword:Q,schemaCode:Y})=>QQ.str`must be ${YQ[Q].okStr} ${Y}`,params:({keyword:Q,schemaCode:Y})=>QQ._`{comparison: ${YQ[Q].okStr}, limit: ${Y}}`},Zq={keyword:Object.keys(YQ),type:"number",schemaType:"number",$data:!0,error:Vq,code(Q){let{keyword:Y,data:X,schemaCode:W}=Q;Q.fail$data(QQ._`${X} ${YQ[Y].fail} ${W} || isNaN(${X})`)}};Vz.default=Zq});var wz=w((Nz)=>{Object.defineProperty(Nz,"__esModule",{value:!0});var v6=v(),wq={message:({schemaCode:Q})=>v6.str`must be multiple of ${Q}`,params:({schemaCode:Q})=>v6._`{multipleOf: ${Q}}`},bq={keyword:"multipleOf",type:"number",schemaType:"number",$data:!0,error:wq,code(Q){let{gen:Y,data:X,schemaCode:W,it:G}=Q,$=G.opts.multipleOfPrecision,J=Y.let("res"),z=$?v6._`Math.abs(Math.round(${J}) - ${J}) > 1e-${$}`:v6._`${J} !== parseInt(${J})`;Q.fail$data(v6._`(${W} === 0 || (${J} = ${X}/${W}, ${z}))`)}};Nz.default=bq});var Pz=w((jz)=>{Object.defineProperty(jz,"__esModule",{value:!0});function bz(Q){let Y=Q.length,X=0,W=0,G;while(W<Y)if(X++,G=Q.charCodeAt(W++),G>=55296&&G<=56319&&W<Y){if(G=Q.charCodeAt(W),(G&64512)===56320)W++}return X}jz.default=bz;bz.code='require("ajv/dist/runtime/ucs2length").default'});var Ez=w((Iz)=>{Object.defineProperty(Iz,"__esModule",{value:!0});var b1=v(),Iq=l(),Eq=Pz(),Tq={message({keyword:Q,schemaCode:Y}){let X=Q==="maxLength"?"more":"fewer";return b1.str`must NOT have ${X} than ${Y} characters`},params:({schemaCode:Q})=>b1._`{limit: ${Q}}`},Sq={keyword:["maxLength","minLength"],type:"string",schemaType:"number",$data:!0,error:Tq,code(Q){let{keyword:Y,data:X,schemaCode:W,it:G}=Q,$=Y==="maxLength"?b1.operators.GT:b1.operators.LT,J=G.opts.unicode===!1?b1._`${X}.length`:b1._`${(0,Iq.useFunc)(Q.gen,Eq.default)}(${X})`;Q.fail$data(b1._`${J} ${$} ${W}`)}};Iz.default=Sq});var Sz=w((Tz)=>{Object.defineProperty(Tz,"__esModule",{value:!0});var Cq=I0(),XQ=v(),kq={message:({schemaCode:Q})=>XQ.str`must match pattern "${Q}"`,params:({schemaCode:Q})=>XQ._`{pattern: ${Q}}`},vq={keyword:"pattern",type:"string",schemaType:"string",$data:!0,error:kq,code(Q){let{data:Y,$data:X,schema:W,schemaCode:G,it:$}=Q,J=$.opts.unicodeRegExp?"u":"",z=X?XQ._`(new RegExp(${G}, ${J}))`:(0,Cq.usePattern)(Q,W);Q.fail$data(XQ._`!${z}.test(${Y})`)}};Tz.default=vq});var Cz=w((Rz)=>{Object.defineProperty(Rz,"__esModule",{value:!0});var x6=v(),_q={message({keyword:Q,schemaCode:Y}){let X=Q==="maxProperties"?"more":"fewer";return x6.str`must NOT have ${X} than ${Y} properties`},params:({schemaCode:Q})=>x6._`{limit: ${Q}}`},yq={keyword:["maxProperties","minProperties"],type:"object",schemaType:"number",$data:!0,error:_q,code(Q){let{keyword:Y,data:X,schemaCode:W}=Q,G=Y==="maxProperties"?x6.operators.GT:x6.operators.LT;Q.fail$data(x6._`Object.keys(${X}).length ${G} ${W}`)}};Rz.default=yq});var vz=w((kz)=>{Object.defineProperty(kz,"__esModule",{value:!0});var _6=I0(),y6=v(),uq=l(),hq={message:({params:{missingProperty:Q}})=>y6.str`must have required property '${Q}'`,params:({params:{missingProperty:Q}})=>y6._`{missingProperty: ${Q}}`},fq={keyword:"required",type:"object",schemaType:"array",$data:!0,error:hq,code(Q){let{gen:Y,schema:X,schemaCode:W,data:G,$data:$,it:J}=Q,{opts:z}=J;if(!$&&X.length===0)return;let H=X.length>=z.loopRequired;if(J.allErrors)U();else A();if(z.strictRequired){let L=Q.parentSchema.properties,{definedProperties:O}=Q.it;for(let M of X)if((L===null||L===void 0?void 0:L[M])===void 0&&!O.has(M)){let Z=J.schemaEnv.baseId+J.errSchemaPath,V=`required property "${M}" is not defined at "${Z}" (strictRequired)`;(0,uq.checkStrictMode)(J,V,J.opts.strictRequired)}}function U(){if(H||$)Q.block$data(y6.nil,B);else for(let L of X)(0,_6.checkReportMissingProp)(Q,L)}function A(){let L=Y.let("missing");if(H||$){let O=Y.let("valid",!0);Q.block$data(O,()=>K(L,O)),Q.ok(O)}else Y.if((0,_6.checkMissingProp)(Q,X,L)),(0,_6.reportMissingProp)(Q,L),Y.else()}function B(){Y.forOf("prop",W,(L)=>{Q.setParams({missingProperty:L}),Y.if((0,_6.noPropertyInData)(Y,G,L,z.ownProperties),()=>Q.error())})}function K(L,O){Q.setParams({missingProperty:L}),Y.forOf(L,W,()=>{Y.assign(O,(0,_6.propertyInData)(Y,G,L,z.ownProperties)),Y.if((0,y6.not)(O),()=>{Q.error(),Y.break()})},y6.nil)}}};kz.default=fq});var _z=w((xz)=>{Object.defineProperty(xz,"__esModule",{value:!0});var g6=v(),mq={message({keyword:Q,schemaCode:Y}){let X=Q==="maxItems"?"more":"fewer";return g6.str`must NOT have ${X} than ${Y} items`},params:({schemaCode:Q})=>g6._`{limit: ${Q}}`},cq={keyword:["maxItems","minItems"],type:"array",schemaType:"number",$data:!0,error:mq,code(Q){let{keyword:Y,data:X,schemaCode:W}=Q,G=Y==="maxItems"?g6.operators.GT:g6.operators.LT;Q.fail$data(g6._`${X}.length ${G} ${W}`)}};xz.default=cq});var WQ=w((gz)=>{Object.defineProperty(gz,"__esModule",{value:!0});var yz=o9();yz.code='require("ajv/dist/runtime/equal").default';gz.default=yz});var hz=w((uz)=>{Object.defineProperty(uz,"__esModule",{value:!0});var BY=b6(),U0=v(),nq=l(),rq=WQ(),dq={message:({params:{i:Q,j:Y}})=>U0.str`must NOT have duplicate items (items ## ${Y} and ${Q} are identical)`,params:({params:{i:Q,j:Y}})=>U0._`{i: ${Q}, j: ${Y}}`},oq={keyword:"uniqueItems",type:"array",schemaType:"boolean",$data:!0,error:dq,code(Q){let{gen:Y,data:X,$data:W,schema:G,parentSchema:$,schemaCode:J,it:z}=Q;if(!W&&!G)return;let H=Y.let("valid"),U=$.items?(0,BY.getSchemaTypes)($.items):[];Q.block$data(H,A,U0._`${J} === false`),Q.ok(H);function A(){let O=Y.let("i",U0._`${X}.length`),M=Y.let("j");Q.setParams({i:O,j:M}),Y.assign(H,!0),Y.if(U0._`${O} > 1`,()=>(B()?K:L)(O,M))}function B(){return U.length>0&&!U.some((O)=>O==="object"||O==="array")}function K(O,M){let Z=Y.name("item"),V=(0,BY.checkDataTypes)(U,Z,z.opts.strictNumbers,BY.DataType.Wrong),S=Y.const("indices",U0._`{}`);Y.for(U0._`;${O}--;`,()=>{if(Y.let(Z,U0._`${X}[${O}]`),Y.if(V,U0._`continue`),U.length>1)Y.if(U0._`typeof ${Z} == "string"`,U0._`${Z} += "_"`);Y.if(U0._`typeof ${S}[${Z}] == "number"`,()=>{Y.assign(M,U0._`${S}[${Z}]`),Q.error(),Y.assign(H,!1).break()}).code(U0._`${S}[${Z}] = ${O}`)})}function L(O,M){let Z=(0,nq.useFunc)(Y,rq.default),V=Y.name("outer");Y.label(V).for(U0._`;${O}--;`,()=>Y.for(U0._`${M} = ${O}; ${M}--;`,()=>Y.if(U0._`${Z}(${X}[${O}], ${X}[${M}])`,()=>{Q.error(),Y.assign(H,!1).break(V)})))}}};uz.default=oq});var lz=w((fz)=>{Object.defineProperty(fz,"__esModule",{value:!0});var KY=v(),aq=l(),sq=WQ(),eq={message:"must be equal to constant",params:({schemaCode:Q})=>KY._`{allowedValue: ${Q}}`},QF={keyword:"const",$data:!0,error:eq,code(Q){let{gen:Y,data:X,$data:W,schemaCode:G,schema:$}=Q;if(W||$&&typeof $=="object")Q.fail$data(KY._`!${(0,aq.useFunc)(Y,sq.default)}(${X}, ${G})`);else Q.fail(KY._`${$} !== ${X}`)}};fz.default=QF});var cz=w((mz)=>{Object.defineProperty(mz,"__esModule",{value:!0});var u6=v(),XF=l(),WF=WQ(),GF={message:"must be equal to one of the allowed values",params:({schemaCode:Q})=>u6._`{allowedValues: ${Q}}`},$F={keyword:"enum",schemaType:"array",$data:!0,error:GF,code(Q){let{gen:Y,data:X,$data:W,schema:G,schemaCode:$,it:J}=Q;if(!W&&G.length===0)throw Error("enum must have non-empty array");let z=G.length>=J.opts.loopEnum,H,U=()=>H!==null&&H!==void 0?H:H=(0,XF.useFunc)(Y,WF.default),A;if(z||W)A=Y.let("valid"),Q.block$data(A,B);else{if(!Array.isArray(G))throw Error("ajv implementation error");let L=Y.const("vSchema",$);A=(0,u6.or)(...G.map((O,M)=>K(L,M)))}Q.pass(A);function B(){Y.assign(A,!1),Y.forOf("v",$,(L)=>Y.if(u6._`${U()}(${X}, ${L})`,()=>Y.assign(A,!0).break()))}function K(L,O){let M=G[O];return typeof M==="object"&&M!==null?u6._`${U()}(${X}, ${L}[${O}])`:u6._`${X} === ${M}`}}};mz.default=$F});var iz=w((pz)=>{Object.defineProperty(pz,"__esModule",{value:!0});var zF=Zz(),HF=wz(),UF=Ez(),AF=Sz(),BF=Cz(),KF=vz(),DF=_z(),LF=hz(),qF=lz(),FF=cz(),OF=[zF.default,HF.default,UF.default,AF.default,BF.default,KF.default,DF.default,LF.default,{keyword:"type",schemaType:["string","array"]},{keyword:"nullable",schemaType:"boolean"},qF.default,FF.default];pz.default=OF});var LY=w((rz)=>{Object.defineProperty(rz,"__esModule",{value:!0});rz.validateAdditionalItems=void 0;var j1=v(),DY=l(),VF={message:({params:{len:Q}})=>j1.str`must NOT have more than ${Q} items`,params:({params:{len:Q}})=>j1._`{limit: ${Q}}`},ZF={keyword:"additionalItems",type:"array",schemaType:["boolean","object"],before:"uniqueItems",error:VF,code(Q){let{parentSchema:Y,it:X}=Q,{items:W}=Y;if(!Array.isArray(W)){(0,DY.checkStrictMode)(X,'"additionalItems" is ignored when "items" is not an array of schemas');return}nz(Q,W)}};function nz(Q,Y){let{gen:X,schema:W,data:G,keyword:$,it:J}=Q;J.items=!0;let z=X.const("len",j1._`${G}.length`);if(W===!1)Q.setParams({len:Y.length}),Q.pass(j1._`${z} <= ${Y.length}`);else if(typeof W=="object"&&!(0,DY.alwaysValidSchema)(J,W)){let U=X.var("valid",j1._`${z} <= ${Y.length}`);X.if((0,j1.not)(U),()=>H(U)),Q.ok(U)}function H(U){X.forRange("i",Y.length,z,(A)=>{if(Q.subschema({keyword:$,dataProp:A,dataPropType:DY.Type.Num},U),!J.allErrors)X.if((0,j1.not)(U),()=>X.break())})}}rz.validateAdditionalItems=nz;rz.default=ZF});var qY=w((az)=>{Object.defineProperty(az,"__esModule",{value:!0});az.validateTuple=void 0;var oz=v(),GQ=l(),wF=I0(),bF={keyword:"items",type:"array",schemaType:["object","array","boolean"],before:"uniqueItems",code(Q){let{schema:Y,it:X}=Q;if(Array.isArray(Y))return tz(Q,"additionalItems",Y);if(X.items=!0,(0,GQ.alwaysValidSchema)(X,Y))return;Q.ok((0,wF.validateArray)(Q))}};function tz(Q,Y,X=Q.schema){let{gen:W,parentSchema:G,data:$,keyword:J,it:z}=Q;if(A(G),z.opts.unevaluated&&X.length&&z.items!==!0)z.items=GQ.mergeEvaluated.items(W,X.length,z.items);let H=W.name("valid"),U=W.const("len",oz._`${$}.length`);X.forEach((B,K)=>{if((0,GQ.alwaysValidSchema)(z,B))return;W.if(oz._`${U} > ${K}`,()=>Q.subschema({keyword:J,schemaProp:K,dataProp:K},H)),Q.ok(H)});function A(B){let{opts:K,errSchemaPath:L}=z,O=X.length,M=O===B.minItems&&(O===B.maxItems||B[Y]===!1);if(K.strictTuples&&!M){let Z=`"${J}" is ${O}-tuple, but minItems or maxItems/${Y} are not specified or different at path "${L}"`;(0,GQ.checkStrictMode)(z,Z,K.strictTuples)}}}az.validateTuple=tz;az.default=bF});var Q7=w((ez)=>{Object.defineProperty(ez,"__esModule",{value:!0});var PF=qY(),IF={keyword:"prefixItems",type:"array",schemaType:["array"],before:"uniqueItems",code:(Q)=>(0,PF.validateTuple)(Q,"items")};ez.default=IF});var W7=w((X7)=>{Object.defineProperty(X7,"__esModule",{value:!0});var Y7=v(),TF=l(),SF=I0(),RF=LY(),CF={message:({params:{len:Q}})=>Y7.str`must NOT have more than ${Q} items`,params:({params:{len:Q}})=>Y7._`{limit: ${Q}}`},kF={keyword:"items",type:"array",schemaType:["object","boolean"],before:"uniqueItems",error:CF,code(Q){let{schema:Y,parentSchema:X,it:W}=Q,{prefixItems:G}=X;if(W.items=!0,(0,TF.alwaysValidSchema)(W,Y))return;if(G)(0,RF.validateAdditionalItems)(Q,G);else Q.ok((0,SF.validateArray)(Q))}};X7.default=kF});var $7=w((G7)=>{Object.defineProperty(G7,"__esModule",{value:!0});var E0=v(),$Q=l(),xF={message:({params:{min:Q,max:Y}})=>Y===void 0?E0.str`must contain at least ${Q} valid item(s)`:E0.str`must contain at least ${Q} and no more than ${Y} valid item(s)`,params:({params:{min:Q,max:Y}})=>Y===void 0?E0._`{minContains: ${Q}}`:E0._`{minContains: ${Q}, maxContains: ${Y}}`},_F={keyword:"contains",type:"array",schemaType:["object","boolean"],before:"uniqueItems",trackErrors:!0,error:xF,code(Q){let{gen:Y,schema:X,parentSchema:W,data:G,it:$}=Q,J,z,{minContains:H,maxContains:U}=W;if($.opts.next)J=H===void 0?1:H,z=U;else J=1;let A=Y.const("len",E0._`${G}.length`);if(Q.setParams({min:J,max:z}),z===void 0&&J===0){(0,$Q.checkStrictMode)($,'"minContains" == 0 without "maxContains": "contains" keyword ignored');return}if(z!==void 0&&J>z){(0,$Q.checkStrictMode)($,'"minContains" > "maxContains" is always invalid'),Q.fail();return}if((0,$Q.alwaysValidSchema)($,X)){let M=E0._`${A} >= ${J}`;if(z!==void 0)M=E0._`${M} && ${A} <= ${z}`;Q.pass(M);return}$.items=!0;let B=Y.name("valid");if(z===void 0&&J===1)L(B,()=>Y.if(B,()=>Y.break()));else if(J===0){if(Y.let(B,!0),z!==void 0)Y.if(E0._`${G}.length > 0`,K)}else Y.let(B,!1),K();Q.result(B,()=>Q.reset());function K(){let M=Y.name("_valid"),Z=Y.let("count",0);L(M,()=>Y.if(M,()=>O(Z)))}function L(M,Z){Y.forRange("i",0,A,(V)=>{Q.subschema({keyword:"contains",dataProp:V,dataPropType:$Q.Type.Num,compositeRule:!0},M),Z()})}function O(M){if(Y.code(E0._`${M}++`),z===void 0)Y.if(E0._`${M} >= ${J}`,()=>Y.assign(B,!0).break());else if(Y.if(E0._`${M} > ${z}`,()=>Y.assign(B,!1).break()),J===1)Y.assign(B,!0);else Y.if(E0._`${M} >= ${J}`,()=>Y.assign(B,!0))}}};G7.default=_F});var B7=w((H7)=>{Object.defineProperty(H7,"__esModule",{value:!0});H7.validateSchemaDeps=H7.validatePropertyDeps=H7.error=void 0;var FY=v(),gF=l(),h6=I0();H7.error={message:({params:{property:Q,depsCount:Y,deps:X}})=>{let W=Y===1?"property":"properties";return FY.str`must have ${W} ${X} when property ${Q} is present`},params:({params:{property:Q,depsCount:Y,deps:X,missingProperty:W}})=>FY._`{property: ${Q},
|
|
7
7
|
missingProperty: ${W},
|
|
8
8
|
depsCount: ${Y},
|
|
9
|
-
deps: ${X}}`};var uF={keyword:"dependencies",type:"object",schemaType:"object",error:H7.error,code(Q){let[Y,X]=hF(Q);J7(Q,Y),z7(Q,X)}};function hF({schema:Q}){let Y={},X={};for(let W in Q){if(W==="__proto__")continue;let G=Array.isArray(Q[W])?Y:X;G[W]=Q[W]}return[Y,X]}function J7(Q,Y=Q.schema){let{gen:X,data:W,it:G}=Q;if(Object.keys(Y).length===0)return;let $=X.let("missing");for(let J in Y){let z=Y[J];if(z.length===0)continue;let H=(0,h4.propertyInData)(X,W,J,G.opts.ownProperties);if(Q.setParams({property:J,depsCount:z.length,deps:z.join(", ")}),G.allErrors)X.if(H,()=>{for(let U of z)(0,h4.checkReportMissingProp)(Q,U)});else X.if(FY._`${H} && (${(0,h4.checkMissingProp)(Q,z,$)})`),(0,h4.reportMissingProp)(Q,$),X.else()}}H7.validatePropertyDeps=J7;function z7(Q,Y=Q.schema){let{gen:X,data:W,keyword:G,it:$}=Q,J=X.name("valid");for(let z in Y){if((0,gF.alwaysValidSchema)($,Y[z]))continue;X.if((0,h4.propertyInData)(X,W,z,$.opts.ownProperties),()=>{let H=Q.subschema({keyword:G,schemaProp:z},J);Q.mergeValidEvaluated(H,J)},()=>X.var(J,!0)),Q.ok(J)}}H7.validateSchemaDeps=z7;H7.default=uF});var L7=w((D7)=>{Object.defineProperty(D7,"__esModule",{value:!0});var K7=v(),mF=l(),cF={message:"property name must be valid",params:({params:Q})=>K7._`{propertyName: ${Q.propertyName}}`},pF={keyword:"propertyNames",type:"object",schemaType:["object","boolean"],error:cF,code(Q){let{gen:Y,schema:X,data:W,it:G}=Q;if((0,mF.alwaysValidSchema)(G,X))return;let $=Y.name("valid");Y.forIn("key",W,(J)=>{Q.setParams({propertyName:J}),Q.subschema({keyword:"propertyNames",data:J,dataTypes:["string"],propertyName:J,compositeRule:!0},$),Y.if((0,K7.not)($),()=>{if(Q.error(!0),!G.allErrors)Y.break()})}),Q.ok($)}};D7.default=pF});var OY=w((q7)=>{Object.defineProperty(q7,"__esModule",{value:!0});var JQ=I0(),x0=v(),nF=r0(),zQ=l(),rF={message:"must NOT have additional properties",params:({params:Q})=>x0._`{additionalProperty: ${Q.additionalProperty}}`},dF={keyword:"additionalProperties",type:["object"],schemaType:["boolean","object"],allowUndefined:!0,trackErrors:!0,error:rF,code(Q){let{gen:Y,schema:X,parentSchema:W,data:G,errsCount:$,it:J}=Q;if(!$)throw Error("ajv implementation error");let{allErrors:z,opts:H}=J;if(J.props=!0,H.removeAdditional!=="all"&&(0,zQ.alwaysValidSchema)(J,X))return;let U=(0,JQ.allSchemaProperties)(W.properties),A=(0,JQ.allSchemaProperties)(W.patternProperties);B(),Q.ok(x0._`${$} === ${nF.default.errors}`);function B(){Y.forIn("key",G,(Z)=>{if(!U.length&&!A.length)O(Z);else Y.if(K(Z),()=>O(Z))})}function K(Z){let V;if(U.length>8){let S=(0,zQ.schemaRefOrVal)(J,W.properties,"properties");V=(0,JQ.isOwnProperty)(Y,S,Z)}else if(U.length)V=(0,x0.or)(...U.map((S)=>x0._`${Z} === ${S}`));else V=x0.nil;if(A.length)V=(0,x0.or)(V,...A.map((S)=>x0._`${(0,JQ.usePattern)(Q,S)}.test(${Z})`));return(0,x0.not)(V)}function L(Z){Y.code(x0._`delete ${G}[${Z}]`)}function O(Z){if(H.removeAdditional==="all"||H.removeAdditional&&X===!1){L(Z);return}if(X===!1){if(Q.setParams({additionalProperty:Z}),Q.error(),!z)Y.break();return}if(typeof X=="object"&&!(0,zQ.alwaysValidSchema)(J,X)){let V=Y.name("valid");if(H.removeAdditional==="failing")M(Z,V,!1),Y.if((0,x0.not)(V),()=>{Q.reset(),L(Z)});else if(M(Z,V),!z)Y.if((0,x0.not)(V),()=>Y.break())}}function M(Z,V,S){let E={keyword:"additionalProperties",dataProp:Z,dataPropType:zQ.Type.Str};if(S===!1)Object.assign(E,{compositeRule:!0,createErrors:!1,allErrors:!1});Q.subschema(E,V)}}};q7.default=dF});var V7=w((M7)=>{Object.defineProperty(M7,"__esModule",{value:!0});var tF=E4(),F7=I0(),MY=l(),O7=OY(),aF={keyword:"properties",type:"object",schemaType:"object",code(Q){let{gen:Y,schema:X,parentSchema:W,data:G,it:$}=Q;if($.opts.removeAdditional==="all"&&W.additionalProperties===void 0)O7.default.code(new tF.KeywordCxt($,O7.default,"additionalProperties"));let J=(0,F7.allSchemaProperties)(X);for(let B of J)$.definedProperties.add(B);if($.opts.unevaluated&&J.length&&$.props!==!0)$.props=MY.mergeEvaluated.props(Y,(0,MY.toHash)(J),$.props);let z=J.filter((B)=>!(0,MY.alwaysValidSchema)($,X[B]));if(z.length===0)return;let H=Y.name("valid");for(let B of z){if(U(B))A(B);else{if(Y.if((0,F7.propertyInData)(Y,G,B,$.opts.ownProperties)),A(B),!$.allErrors)Y.else().var(H,!0);Y.endIf()}Q.it.definedProperties.add(B),Q.ok(H)}function U(B){return $.opts.useDefaults&&!$.compositeRule&&X[B].default!==void 0}function A(B){Q.subschema({keyword:"properties",schemaProp:B,dataProp:B},H)}}};M7.default=aF});var j7=w((b7)=>{Object.defineProperty(b7,"__esModule",{value:!0});var Z7=I0(),HQ=v(),N7=l(),w7=l(),eF={keyword:"patternProperties",type:"object",schemaType:"object",code(Q){let{gen:Y,schema:X,data:W,parentSchema:G,it:$}=Q,{opts:J}=$,z=(0,Z7.allSchemaProperties)(X),H=z.filter((M)=>(0,N7.alwaysValidSchema)($,X[M]));if(z.length===0||H.length===z.length&&(!$.opts.unevaluated||$.props===!0))return;let U=J.strictSchema&&!J.allowMatchingProperties&&G.properties,A=Y.name("valid");if($.props!==!0&&!($.props instanceof HQ.Name))$.props=(0,w7.evaluatedPropsToName)(Y,$.props);let{props:B}=$;K();function K(){for(let M of z){if(U)L(M);if($.allErrors)O(M);else Y.var(A,!0),O(M),Y.if(A)}}function L(M){for(let Z in U)if(new RegExp(M).test(Z))(0,N7.checkStrictMode)($,`property ${Z} matches pattern ${M} (use allowMatchingProperties)`)}function O(M){Y.forIn("key",W,(Z)=>{Y.if(HQ._`${(0,Z7.usePattern)(Q,M)}.test(${Z})`,()=>{let V=H.includes(M);if(!V)Q.subschema({keyword:"patternProperties",schemaProp:M,dataProp:Z,dataPropType:w7.Type.Str},A);if($.opts.unevaluated&&B!==!0)Y.assign(HQ._`${B}[${Z}]`,!0);else if(!V&&!$.allErrors)Y.if((0,HQ.not)(A),()=>Y.break())})})}}};b7.default=eF});var I7=w((P7)=>{Object.defineProperty(P7,"__esModule",{value:!0});var YO=l(),XO={keyword:"not",schemaType:["object","boolean"],trackErrors:!0,code(Q){let{gen:Y,schema:X,it:W}=Q;if((0,YO.alwaysValidSchema)(W,X)){Q.fail();return}let G=Y.name("valid");Q.subschema({keyword:"not",compositeRule:!0,createErrors:!1,allErrors:!1},G),Q.failResult(G,()=>Q.reset(),()=>Q.error())},error:{message:"must NOT be valid"}};P7.default=XO});var T7=w((E7)=>{Object.defineProperty(E7,"__esModule",{value:!0});var GO=I0(),$O={keyword:"anyOf",schemaType:"array",trackErrors:!0,code:GO.validateUnion,error:{message:"must match a schema in anyOf"}};E7.default=$O});var R7=w((S7)=>{Object.defineProperty(S7,"__esModule",{value:!0});var UQ=v(),zO=l(),HO={message:"must match exactly one schema in oneOf",params:({params:Q})=>UQ._`{passingSchemas: ${Q.passing}}`},UO={keyword:"oneOf",schemaType:"array",trackErrors:!0,error:HO,code(Q){let{gen:Y,schema:X,parentSchema:W,it:G}=Q;if(!Array.isArray(X))throw Error("ajv implementation error");if(G.opts.discriminator&&W.discriminator)return;let $=X,J=Y.let("valid",!1),z=Y.let("passing",null),H=Y.name("_valid");Q.setParams({passing:z}),Y.block(U),Q.result(J,()=>Q.reset(),()=>Q.error(!0));function U(){$.forEach((A,B)=>{let K;if((0,zO.alwaysValidSchema)(G,A))Y.var(H,!0);else K=Q.subschema({keyword:"oneOf",schemaProp:B,compositeRule:!0},H);if(B>0)Y.if(UQ._`${H} && ${J}`).assign(J,!1).assign(z,UQ._`[${z}, ${B}]`).else();Y.if(H,()=>{if(Y.assign(J,!0),Y.assign(z,B),K)Q.mergeEvaluated(K,UQ.Name)})})}}};S7.default=UO});var k7=w((C7)=>{Object.defineProperty(C7,"__esModule",{value:!0});var BO=l(),KO={keyword:"allOf",schemaType:"array",code(Q){let{gen:Y,schema:X,it:W}=Q;if(!Array.isArray(X))throw Error("ajv implementation error");let G=Y.name("valid");X.forEach(($,J)=>{if((0,BO.alwaysValidSchema)(W,$))return;let z=Q.subschema({keyword:"allOf",schemaProp:J},G);Q.ok(G),Q.mergeEvaluated(z)})}};C7.default=KO});var y7=w((_7)=>{Object.defineProperty(_7,"__esModule",{value:!0});var AQ=v(),x7=l(),LO={message:({params:Q})=>AQ.str`must match "${Q.ifClause}" schema`,params:({params:Q})=>AQ._`{failingKeyword: ${Q.ifClause}}`},qO={keyword:"if",schemaType:["object","boolean"],trackErrors:!0,error:LO,code(Q){let{gen:Y,parentSchema:X,it:W}=Q;if(X.then===void 0&&X.else===void 0)(0,x7.checkStrictMode)(W,'"if" without "then" and "else" is ignored');let G=v7(W,"then"),$=v7(W,"else");if(!G&&!$)return;let J=Y.let("valid",!0),z=Y.name("_valid");if(H(),Q.reset(),G&&$){let A=Y.let("ifClause");Q.setParams({ifClause:A}),Y.if(z,U("then",A),U("else",A))}else if(G)Y.if(z,U("then"));else Y.if((0,AQ.not)(z),U("else"));Q.pass(J,()=>Q.error(!0));function H(){let A=Q.subschema({keyword:"if",compositeRule:!0,createErrors:!1,allErrors:!1},z);Q.mergeEvaluated(A)}function U(A,B){return()=>{let K=Q.subschema({keyword:A},z);if(Y.assign(J,z),Q.mergeValidEvaluated(K,J),B)Y.assign(B,AQ._`${A}`);else Q.setParams({ifClause:A})}}}};function v7(Q,Y){let X=Q.schema[Y];return X!==void 0&&!(0,x7.alwaysValidSchema)(Q,X)}_7.default=qO});var u7=w((g7)=>{Object.defineProperty(g7,"__esModule",{value:!0});var OO=l(),MO={keyword:["then","else"],schemaType:["object","boolean"],code({keyword:Q,parentSchema:Y,it:X}){if(Y.if===void 0)(0,OO.checkStrictMode)(X,`"${Q}" without "if" is ignored`)}};g7.default=MO});var f7=w((h7)=>{Object.defineProperty(h7,"__esModule",{value:!0});var ZO=LY(),NO=Q7(),wO=qY(),bO=W7(),jO=$7(),PO=B7(),IO=L7(),EO=OY(),TO=V7(),SO=j7(),RO=I7(),CO=T7(),kO=R7(),vO=k7(),xO=y7(),_O=u7();function yO(Q=!1){let Y=[RO.default,CO.default,kO.default,vO.default,xO.default,_O.default,IO.default,EO.default,PO.default,TO.default,SO.default];if(Q)Y.push(NO.default,bO.default);else Y.push(ZO.default,wO.default);return Y.push(jO.default),Y}h7.default=yO});var m7=w((l7)=>{Object.defineProperty(l7,"__esModule",{value:!0});var Q0=v(),uO={message:({schemaCode:Q})=>Q0.str`must match format "${Q}"`,params:({schemaCode:Q})=>Q0._`{format: ${Q}}`},hO={keyword:"format",type:["number","string"],schemaType:"string",$data:!0,error:uO,code(Q,Y){let{gen:X,data:W,$data:G,schema:$,schemaCode:J,it:z}=Q,{opts:H,errSchemaPath:U,schemaEnv:A,self:B}=z;if(!H.validateFormats)return;if(G)K();else L();function K(){let O=X.scopeValue("formats",{ref:B.formats,code:H.code.formats}),M=X.const("fDef",Q0._`${O}[${J}]`),Z=X.let("fType"),V=X.let("format");X.if(Q0._`typeof ${M} == "object" && !(${M} instanceof RegExp)`,()=>X.assign(Z,Q0._`${M}.type || "string"`).assign(V,Q0._`${M}.validate`),()=>X.assign(Z,Q0._`"string"`).assign(V,M)),Q.fail$data((0,Q0.or)(S(),E()));function S(){if(H.strictSchema===!1)return Q0.nil;return Q0._`${J} && !${V}`}function E(){let _=A.$async?Q0._`(${M}.async ? await ${V}(${W}) : ${V}(${W}))`:Q0._`${V}(${W})`,T=Q0._`(typeof ${V} == "function" ? ${_} : ${V}.test(${W}))`;return Q0._`${V} && ${V} !== true && ${Z} === ${Y} && !${T}`}}function L(){let O=B.formats[$];if(!O){S();return}if(O===!0)return;let[M,Z,V]=E(O);if(M===Y)Q.pass(_());function S(){if(H.strictSchema===!1){B.logger.warn(T());return}throw Error(T());function T(){return`unknown format "${$}" ignored in schema at path "${U}"`}}function E(T){let y0=T instanceof RegExp?(0,Q0.regexpCode)(T):H.code.formats?Q0._`${H.code.formats}${(0,Q0.getProperty)($)}`:void 0,l0=X.scopeValue("formats",{key:$,ref:T,code:y0});if(typeof T=="object"&&!(T instanceof RegExp))return[T.type||"string",T.validate,Q0._`${l0}.validate`];return["string",T,l0]}function _(){if(typeof O=="object"&&!(O instanceof RegExp)&&O.async){if(!A.$async)throw Error("async format in sync schema");return Q0._`await ${V}(${W})`}return typeof Z=="function"?Q0._`${V}(${W})`:Q0._`${V}.test(${W})`}}}};l7.default=hO});var p7=w((c7)=>{Object.defineProperty(c7,"__esModule",{value:!0});var lO=m7(),mO=[lO.default];c7.default=mO});var r7=w((i7)=>{Object.defineProperty(i7,"__esModule",{value:!0});i7.contentVocabulary=i7.metadataVocabulary=void 0;i7.metadataVocabulary=["title","description","default","deprecated","readOnly","writeOnly","examples"];i7.contentVocabulary=["contentMediaType","contentEncoding","contentSchema"]});var t7=w((o7)=>{Object.defineProperty(o7,"__esModule",{value:!0});var iO=Mz(),nO=iz(),rO=f7(),dO=p7(),d7=r7(),oO=[iO.default,nO.default,(0,rO.default)(),dO.default,d7.metadataVocabulary,d7.contentVocabulary];o7.default=oO});var Q5=w((s7)=>{Object.defineProperty(s7,"__esModule",{value:!0});s7.DiscrError=void 0;var a7;(function(Q){Q.Tag="tag",Q.Mapping="mapping"})(a7||(s7.DiscrError=a7={}))});var W5=w((X5)=>{Object.defineProperty(X5,"__esModule",{value:!0});var m1=v(),VY=Q5(),Y5=i6(),aO=T4(),sO=l(),eO={message:({params:{discrError:Q,tagName:Y}})=>Q===VY.DiscrError.Tag?`tag "${Y}" must be string`:`value of tag "${Y}" must be in oneOf`,params:({params:{discrError:Q,tag:Y,tagName:X}})=>m1._`{error: ${Q}, tag: ${X}, tagValue: ${Y}}`},QM={keyword:"discriminator",type:"object",schemaType:"object",error:eO,code(Q){let{gen:Y,data:X,schema:W,parentSchema:G,it:$}=Q,{oneOf:J}=G;if(!$.opts.discriminator)throw Error("discriminator: requires discriminator option");let z=W.propertyName;if(typeof z!="string")throw Error("discriminator: requires propertyName");if(W.mapping)throw Error("discriminator: mapping is not supported");if(!J)throw Error("discriminator: requires oneOf keyword");let H=Y.let("valid",!1),U=Y.const("tag",m1._`${X}${(0,m1.getProperty)(z)}`);Y.if(m1._`typeof ${U} == "string"`,()=>A(),()=>Q.error(!1,{discrError:VY.DiscrError.Tag,tag:U,tagName:z})),Q.ok(H);function A(){let L=K();Y.if(!1);for(let O in L)Y.elseIf(m1._`${U} === ${O}`),Y.assign(H,B(L[O]));Y.else(),Q.error(!1,{discrError:VY.DiscrError.Mapping,tag:U,tagName:z}),Y.endIf()}function B(L){let O=Y.name("valid"),M=Q.subschema({keyword:"oneOf",schemaProp:L},O);return Q.mergeEvaluated(M,m1.Name),O}function K(){var L;let O={},M=V(G),Z=!0;for(let _=0;_<J.length;_++){let T=J[_];if((T===null||T===void 0?void 0:T.$ref)&&!(0,sO.schemaHasRulesButRef)(T,$.self.RULES)){let l0=T.$ref;if(T=Y5.resolveRef.call($.self,$.schemaEnv.root,$.baseId,l0),T instanceof Y5.SchemaEnv)T=T.schema;if(T===void 0)throw new aO.default($.opts.uriResolver,$.baseId,l0)}let y0=(L=T===null||T===void 0?void 0:T.properties)===null||L===void 0?void 0:L[z];if(typeof y0!="object")throw Error(`discriminator: oneOf subschemas (or referenced schemas) must have "properties/${z}"`);Z=Z&&(M||V(T)),S(y0,_)}if(!Z)throw Error(`discriminator: "${z}" must be required`);return O;function V({required:_}){return Array.isArray(_)&&_.includes(z)}function S(_,T){if(_.const)E(_.const,T);else if(_.enum)for(let y0 of _.enum)E(y0,T);else throw Error(`discriminator: "properties/${z}" must have "const" or "enum"`)}function E(_,T){if(typeof _!="string"||_ in O)throw Error(`discriminator: "${z}" values must be unique strings`);O[_]=T}}}};X5.default=QM});var G5=w((vI,XM)=>{XM.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 NY=w((V0,ZY)=>{Object.defineProperty(V0,"__esModule",{value:!0});V0.MissingRefError=V0.ValidationError=V0.CodeGen=V0.Name=V0.nil=V0.stringify=V0.str=V0._=V0.KeywordCxt=V0.Ajv=void 0;var WM=Hz(),GM=t7(),$M=W5(),$5=G5(),JM=["/properties"],BQ="http://json-schema.org/draft-07/schema";class f4 extends WM.default{_addVocabularies(){if(super._addVocabularies(),GM.default.forEach((Q)=>this.addVocabulary(Q)),this.opts.discriminator)this.addKeyword($M.default)}_addDefaultMetaSchema(){if(super._addDefaultMetaSchema(),!this.opts.meta)return;let Q=this.opts.$data?this.$dataMetaSchema($5,JM):$5;this.addMetaSchema(Q,BQ,!1),this.refs["http://json-schema.org/schema"]=BQ}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(BQ)?BQ:void 0)}}V0.Ajv=f4;ZY.exports=V0=f4;ZY.exports.Ajv=f4;Object.defineProperty(V0,"__esModule",{value:!0});V0.default=f4;var zM=E4();Object.defineProperty(V0,"KeywordCxt",{enumerable:!0,get:function(){return zM.KeywordCxt}});var c1=v();Object.defineProperty(V0,"_",{enumerable:!0,get:function(){return c1._}});Object.defineProperty(V0,"str",{enumerable:!0,get:function(){return c1.str}});Object.defineProperty(V0,"stringify",{enumerable:!0,get:function(){return c1.stringify}});Object.defineProperty(V0,"nil",{enumerable:!0,get:function(){return c1.nil}});Object.defineProperty(V0,"Name",{enumerable:!0,get:function(){return c1.Name}});Object.defineProperty(V0,"CodeGen",{enumerable:!0,get:function(){return c1.CodeGen}});var HM=c6();Object.defineProperty(V0,"ValidationError",{enumerable:!0,get:function(){return HM.default}});var UM=T4();Object.defineProperty(V0,"MissingRefError",{enumerable:!0,get:function(){return UM.default}})});var q5=w((D5)=>{Object.defineProperty(D5,"__esModule",{value:!0});D5.formatNames=D5.fastFormats=D5.fullFormats=void 0;function h0(Q,Y){return{validate:Q,compare:Y}}D5.fullFormats={date:h0(U5,PY),time:h0(bY(!0),IY),"date-time":h0(J5(!0),B5),"iso-time":h0(bY(),A5),"iso-date-time":h0(J5(),K5),duration:/^P(?!$)((\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+S)?)?|(\d+W)?)$/,uri:OM,"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:jM,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:MM,int32:{type:"number",validate:NM},int64:{type:"number",validate:wM},float:{type:"number",validate:H5},double:{type:"number",validate:H5},password:!0,binary:!0};D5.fastFormats={...D5.fullFormats,date:h0(/^\d\d\d\d-[0-1]\d-[0-3]\d$/,PY),time:h0(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,IY),"date-time":h0(/^\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,B5),"iso-time":h0(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,A5),"iso-date-time":h0(/^\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,K5),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};D5.formatNames=Object.keys(D5.fullFormats);function KM(Q){return Q%4===0&&(Q%100!==0||Q%400===0)}var DM=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,LM=[0,31,28,31,30,31,30,31,31,30,31,30,31];function U5(Q){let Y=DM.exec(Q);if(!Y)return!1;let X=+Y[1],W=+Y[2],G=+Y[3];return W>=1&&W<=12&&G>=1&&G<=(W===2&&KM(X)?29:LM[W])}function PY(Q,Y){if(!(Q&&Y))return;if(Q>Y)return 1;if(Q<Y)return-1;return 0}var wY=/^(\d\d):(\d\d):(\d\d(?:\.\d+)?)(z|([+-])(\d\d)(?::?(\d\d))?)?$/i;function bY(Q){return function(X){let W=wY.exec(X);if(!W)return!1;let G=+W[1],$=+W[2],J=+W[3],z=W[4],H=W[5]==="-"?-1:1,U=+(W[6]||0),A=+(W[7]||0);if(U>23||A>59||Q&&!z)return!1;if(G<=23&&$<=59&&J<60)return!0;let B=$-A*H,K=G-U*H-(B<0?1:0);return(K===23||K===-1)&&(B===59||B===-1)&&J<61}}function IY(Q,Y){if(!(Q&&Y))return;let X=new Date("2020-01-01T"+Q).valueOf(),W=new Date("2020-01-01T"+Y).valueOf();if(!(X&&W))return;return X-W}function A5(Q,Y){if(!(Q&&Y))return;let X=wY.exec(Q),W=wY.exec(Y);if(!(X&&W))return;if(Q=X[1]+X[2]+X[3],Y=W[1]+W[2]+W[3],Q>Y)return 1;if(Q<Y)return-1;return 0}var jY=/t|\s/i;function J5(Q){let Y=bY(Q);return function(W){let G=W.split(jY);return G.length===2&&U5(G[0])&&Y(G[1])}}function B5(Q,Y){if(!(Q&&Y))return;let X=new Date(Q).valueOf(),W=new Date(Y).valueOf();if(!(X&&W))return;return X-W}function K5(Q,Y){if(!(Q&&Y))return;let[X,W]=Q.split(jY),[G,$]=Y.split(jY),J=PY(X,G);if(J===void 0)return;return J||IY(W,$)}var qM=/\/|:/,FM=/^(?:[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 OM(Q){return qM.test(Q)&&FM.test(Q)}var z5=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/gm;function MM(Q){return z5.lastIndex=0,z5.test(Q)}var VM=-2147483648,ZM=2147483647;function NM(Q){return Number.isInteger(Q)&&Q<=ZM&&Q>=VM}function wM(Q){return Number.isInteger(Q)}function H5(){return!0}var bM=/[^\\]\\Z/;function jM(Q){if(bM.test(Q))return!1;try{return new RegExp(Q),!0}catch(Y){return!1}}});var O5=w((F5)=>{Object.defineProperty(F5,"__esModule",{value:!0});F5.formatLimitDefinition=void 0;var IM=NY(),_0=v(),L1=_0.operators,KQ={formatMaximum:{okStr:"<=",ok:L1.LTE,fail:L1.GT},formatMinimum:{okStr:">=",ok:L1.GTE,fail:L1.LT},formatExclusiveMaximum:{okStr:"<",ok:L1.LT,fail:L1.GTE},formatExclusiveMinimum:{okStr:">",ok:L1.GT,fail:L1.LTE}},EM={message:({keyword:Q,schemaCode:Y})=>_0.str`should be ${KQ[Q].okStr} ${Y}`,params:({keyword:Q,schemaCode:Y})=>_0._`{comparison: ${KQ[Q].okStr}, limit: ${Y}}`};F5.formatLimitDefinition={keyword:Object.keys(KQ),type:"string",schemaType:"string",$data:!0,error:EM,code(Q){let{gen:Y,data:X,schemaCode:W,keyword:G,it:$}=Q,{opts:J,self:z}=$;if(!J.validateFormats)return;let H=new IM.KeywordCxt($,z.RULES.all.format.definition,"format");if(H.$data)U();else A();function U(){let K=Y.scopeValue("formats",{ref:z.formats,code:J.code.formats}),L=Y.const("fmt",_0._`${K}[${H.schemaCode}]`);Q.fail$data((0,_0.or)(_0._`typeof ${L} != "object"`,_0._`${L} instanceof RegExp`,_0._`typeof ${L}.compare != "function"`,B(L)))}function A(){let K=H.schema,L=z.formats[K];if(!L||L===!0)return;if(typeof L!="object"||L instanceof RegExp||typeof L.compare!="function")throw Error(`"${G}": format "${K}" does not define "compare" function`);let O=Y.scopeValue("formats",{key:K,ref:L,code:J.code.formats?_0._`${J.code.formats}${(0,_0.getProperty)(K)}`:void 0});Q.fail$data(B(O))}function B(K){return _0._`${K}.compare(${X}, ${W}) ${KQ[G].fail} 0`}},dependencies:["format"]};var TM=(Q)=>{return Q.addKeyword(F5.formatLimitDefinition),Q};F5.default=TM});var N5=w((l4,Z5)=>{Object.defineProperty(l4,"__esModule",{value:!0});var p1=q5(),RM=O5(),SY=v(),M5=new SY.Name("fullFormats"),CM=new SY.Name("fastFormats"),RY=(Q,Y={keywords:!0})=>{if(Array.isArray(Y))return V5(Q,Y,p1.fullFormats,M5),Q;let[X,W]=Y.mode==="fast"?[p1.fastFormats,CM]:[p1.fullFormats,M5],G=Y.formats||p1.formatNames;if(V5(Q,G,X,W),Y.keywords)(0,RM.default)(Q);return Q};RY.get=(Q,Y="full")=>{let W=(Y==="fast"?p1.fastFormats:p1.fullFormats)[Q];if(!W)throw Error(`Unknown format "${Q}"`);return W};function V5(Q,Y,X,W){var G,$;(G=($=Q.opts.code).formats)!==null&&G!==void 0||($.formats=SY._`require("ajv-formats/dist/formats").${W}`);for(let J of Y)Q.addFormat(J,X[J])}Z5.exports=l4=RY;Object.defineProperty(l4,"__esModule",{value:!0});l4.default=RY});import{AsyncLocalStorage as GH}from"node:async_hooks";class F1 extends Error{statusCode;rawDetails;code;context;constructor(Q,Y,X,W,G){super(Q);this.statusCode=Y;this.rawDetails=X;this.code=W;this.context=G;this.name="McpApiError"}}function XH(Q){if(Q instanceof F1)return{message:Q.message,statusCode:Q.statusCode,code:Q.code,rawDetails:Q.rawDetails,context:Q.context};if(Q instanceof Error)return{message:Q.message};return{message:String(Q)}}function WH(Q){let Y=XH(Q),X=Y.message.trim()||"Unknown error",W=X.toLowerCase(),G=Y.rawDetails?.trim()||X;if(Y.context?.title||Y.context?.description||Y.context?.howToFix||Y.context?.docsUrl)return{title:Y.context.title??(Y.statusCode===409?"Request conflict":"API request failed"),description:Y.context.description??X,howToFix:Y.context.howToFix??"Review the details below, adjust the tool input, and retry.",docsUrl:Y.context.docsUrl??"https://docs.sequenzy.com/concepts/mcp",details:G};if(Y.code==="MCP_AUTH_REQUIRED"||W.includes("sequenzy_api_key environment variable is required"))return{title:"Missing MCP API key",description:"The MCP server started without a Sequenzy API key, so it cannot authenticate any tool or resource request.",howToFix:"Add `SEQUENZY_API_KEY` to the MCP server environment, or run `npx @sequenzy/setup` to configure the integration automatically.",docsUrl:"https://docs.sequenzy.com/concepts/mcp",details:G};if(Y.statusCode===401||Y.code==="UNAUTHORIZED")return{title:"Authentication failed",description:"The MCP server reached Sequenzy, but the current API key was rejected.",howToFix:"Replace `SEQUENZY_API_KEY` with a valid personal API key, then restart the MCP client so it reconnects with fresh credentials.",docsUrl:"https://docs.sequenzy.com/authentication",details:G};if(Y.statusCode===403||W.includes("access denied"))return{title:"Access denied",description:"The current API key is valid, but it does not have permission to access the requested company or action.",howToFix:"Use an API key that belongs to the right account, or select a company the key can access before retrying the tool call.",docsUrl:"https://docs.sequenzy.com/authentication",details:G};if(W.includes("no company available")||W.includes("company not found"))return{title:"Company selection required",description:"The MCP server could not resolve a company for this request.",howToFix:"Call `get_account` to inspect available companies, then call `select_company`, or pass `companyId` explicitly in the next tool call.",docsUrl:"https://docs.sequenzy.com/concepts/mcp",details:G};if(Y.statusCode===404||W.includes("not found"))return{title:"Requested resource not found",description:"Sequenzy could not find the requested campaign, template, sequence, company, or subscriber.",howToFix:"List or fetch the resource collection first, then retry the tool with a confirmed ID or email value.",docsUrl:"https://docs.sequenzy.com/concepts/mcp",details:G};if(Y.statusCode===409||W.includes("already exists"))return{title:"Resource already exists",description:"Sequenzy rejected this MCP request because it would create a duplicate resource.",howToFix:"List the existing resources first, reuse the matching resource when appropriate, or retry with a unique name or domain.",docsUrl:"https://docs.sequenzy.com/concepts/mcp",details:G};if(Y.statusCode===429||W.includes("rate limit"))return{title:"Rate limited",description:"Sequenzy temporarily slowed this MCP request because too many requests were sent too quickly.",howToFix:"Wait briefly before retrying. If the client is looping, reduce retries or add backoff before the next tool call.",docsUrl:"https://docs.sequenzy.com/concepts/mcp",details:G};if(Y.code==="NETWORK_ERROR"||W.includes("fetch failed"))return{title:"Network or configuration error",description:"The MCP server could not reach the Sequenzy API from this environment.",howToFix:"Check connectivity and verify `SEQUENZY_API_URL` if you override it in the MCP environment.",docsUrl:"https://docs.sequenzy.com/concepts/mcp",details:G};if(W.includes("unknown tool")||W.includes("unknown resource"))return{title:"Unsupported MCP request",description:"The client asked for a tool or resource name that this Sequenzy MCP server does not expose.",howToFix:"Refresh the client's tool list and call only the names returned by `list_tools` or `list_resources`.",docsUrl:"https://docs.sequenzy.com/concepts/mcp",details:G};if(W.includes("is required")||W.includes("invalid"))return{title:"Invalid MCP input",description:"The tool call was missing a required field or included an invalid value.",howToFix:"Review the tool schema, supply the missing argument, and retry the request with corrected input.",docsUrl:"https://docs.sequenzy.com/concepts/mcp",details:G};if(Y.statusCode&&Y.statusCode>=500)return{title:"Sequenzy server error",description:"The request reached Sequenzy, but the server could not complete it successfully.",howToFix:"Retry once. If it still fails, keep the details below and consult the docs before escalating.",docsUrl:"https://docs.sequenzy.com/concepts/mcp",details:G};return{title:"Tool execution failed",description:"The MCP server could not complete the requested operation.",howToFix:"Review the details below, adjust the tool input or credentials, and retry.",docsUrl:"https://docs.sequenzy.com/concepts/mcp",details:G}}function e0(Q){let Y=WH(Q);return[`Sequenzy MCP error: ${Y.title}`,`Description: ${Y.description}`,`How to fix: ${Y.howToFix}`,`Docs: ${Y.docsUrl}`,`Details: ${Y.details}`].join(`
|
|
10
|
-
`)}var $H="https://api.sequenzy.com",r1=new GH,aY=!1;function sY(){aY=!0}function eY(){return aY}var QX=null;function Q1(){let Q=r1.getStore();if(Q)return Q.selectedCompanyId??null;return QX}function n4(Q){let Y=r1.getStore();if(Y){Y.selectedCompanyId=Q;return}QX=Q}function NQ(Q,Y){return r1.run(Q,Y)}function JH(){return r1.getStore()?.apiUrl??process.env.SEQUENZY_API_URL??$H}function YX(){return r1.getStore()?.apiKey??process.env.SEQUENZY_API_KEY}function XX(){if(YX())return;console.error(e0(new F1("SEQUENZY_API_KEY environment variable is required",401,void 0,"MCP_AUTH_REQUIRED"))),process.exit(1)}function Z0(Q,Y){let X=Q[Y];return typeof X==="string"&&X.trim()!==""?X.trim():void 0}function zH(Q){if(Q===void 0)return;if(typeof Q==="string")return Q.trim()||void 0;return JSON.stringify(Q)}function HH(Q){if(!Q.trim())return{message:"Request failed"};try{let Y=JSON.parse(Q);if(typeof Y==="string")return{message:Y};let X=typeof Y.error==="object"&&Y.error!==null?Y.error:void 0,W=Z0(Y,"code")??(X?Z0(X,"code"):void 0),G=(typeof Y.error==="string"?Y.error:void 0)??(X?Z0(X,"message"):void 0)??Z0(Y,"message")??Z0(Y,"error")??Q,$=Z0(Y,"howToFix")??Z0(Y,"resolution"),J={...Z0(Y,"title")?{title:Z0(Y,"title")}:{},...Z0(Y,"description")?{description:Z0(Y,"description")}:{},...$?{howToFix:$}:{},...Z0(Y,"docsUrl")?{docsUrl:Z0(Y,"docsUrl")}:{}},z=zH(Y.details);if(Object.keys(J).length>0||z)return{message:G,...W?{code:W}:{},...z?{details:z}:{},...Object.keys(J).length>0?{context:J}:{}};if(typeof Y.error==="string")return{message:Y.error,...W?{code:W}:{}};if(X)return{message:G,...W?{code:W}:{}};return{message:G,...W?{code:W}:{}}}catch{return{message:Q}}}async function F(Q,Y,X,W){let G=YX();if(!G)throw new F1("SEQUENZY_API_KEY environment variable is required",401,void 0,"MCP_AUTH_REQUIRED");let $={"Content-Type":"application/json",Authorization:`Bearer ${G}`},J=W??Q1();if(J)$["x-company-id"]=J;let z;try{z=await fetch(`${JH()}${Y}`,{method:Q,headers:$,body:X?JSON.stringify(X):void 0})}catch(H){throw new F1(H instanceof Error?H.message:"Failed to reach Sequenzy API",0,void 0,"NETWORK_ERROR")}if(!z.ok){let H=await z.text(),U=HH(H);throw new F1(U.message,z.status,U.details??H,U.code,U.context)}return z.json()}var ZV=Object.freeze({status:"aborted"});function q(Q,Y,X){function W(z,H){var U;Object.defineProperty(z,"_zod",{value:z._zod??{},enumerable:!1}),(U=z._zod).traits??(U.traits=new Set),z._zod.traits.add(Q),Y(z,H);for(let A in J.prototype)if(!(A in z))Object.defineProperty(z,A,{value:J.prototype[A].bind(z)});z._zod.constr=J,z._zod.def=H}let G=X?.Parent??Object;class $ extends G{}Object.defineProperty($,"name",{value:Q});function J(z){var H;let U=X?.Parent?new $:this;W(U,z),(H=U._zod).deferred??(H.deferred=[]);for(let A of U._zod.deferred)A();return U}return Object.defineProperty(J,"init",{value:W}),Object.defineProperty(J,Symbol.hasInstance,{value:(z)=>{if(X?.Parent&&z instanceof X.Parent)return!0;return z?._zod?.traits?.has(Q)}}),Object.defineProperty(J,"name",{value:Q}),J}var NV=Symbol("zod_brand");class m0 extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class d1 extends Error{constructor(Q){super(`Encountered unidirectional transform during encode: ${Q}`);this.name="ZodEncodeError"}}var r4={};function b0(Q){if(Q)Object.assign(r4,Q);return r4}var f={};tY(f,{unwrapMessage:()=>o1,uint8ArrayToHex:()=>vH,uint8ArrayToBase64url:()=>CH,uint8ArrayToBase64:()=>UX,stringifyPrimitive:()=>a4,shallowClone:()=>GX,safeExtend:()=>PH,required:()=>TH,randomString:()=>MH,propertyKeyTypes:()=>IQ,promiseAllObject:()=>OH,primitiveTypes:()=>$X,prefixIssues:()=>p0,pick:()=>wH,partial:()=>EH,optionalKeys:()=>EQ,omit:()=>bH,objectClone:()=>LH,numKeys:()=>VH,nullish:()=>t1,normalizeParams:()=>I,mergeDefs:()=>X1,merge:()=>IH,jsonStringifyReplacer:()=>I1,joinValues:()=>d4,issue:()=>T1,isPlainObject:()=>W1,isObject:()=>O1,hexToUint8Array:()=>kH,getSizableOrigin:()=>zX,getParsedType:()=>ZH,getLengthableOrigin:()=>s1,getEnumValues:()=>bQ,getElementAtPath:()=>FH,floatSafeRemainder:()=>jQ,finalizeIssue:()=>S0,extend:()=>jH,escapeRegex:()=>c0,esc:()=>o4,defineLazy:()=>c,createTransparentProxy:()=>NH,cloneDef:()=>qH,clone:()=>T0,cleanRegex:()=>a1,cleanEnum:()=>SH,captureStackTrace:()=>t4,cached:()=>E1,base64urlToUint8Array:()=>RH,base64ToUint8Array:()=>HX,assignProp:()=>Y1,assertNotEqual:()=>AH,assertNever:()=>KH,assertIs:()=>BH,assertEqual:()=>UH,assert:()=>DH,allowsEval:()=>PQ,aborted:()=>G1,NUMBER_FORMAT_RANGES:()=>TQ,Class:()=>AX,BIGINT_FORMAT_RANGES:()=>JX});function UH(Q){return Q}function AH(Q){return Q}function BH(Q){}function KH(Q){throw Error()}function DH(Q){}function bQ(Q){let Y=Object.values(Q).filter((W)=>typeof W==="number");return Object.entries(Q).filter(([W,G])=>Y.indexOf(+W)===-1).map(([W,G])=>G)}function d4(Q,Y="|"){return Q.map((X)=>a4(X)).join(Y)}function I1(Q,Y){if(typeof Y==="bigint")return Y.toString();return Y}function E1(Q){return{get value(){{let X=Q();return Object.defineProperty(this,"value",{value:X}),X}throw Error("cached value already set")}}}function t1(Q){return Q===null||Q===void 0}function a1(Q){let Y=Q.startsWith("^")?1:0,X=Q.endsWith("$")?Q.length-1:Q.length;return Q.slice(Y,X)}function jQ(Q,Y){let X=(Q.toString().split(".")[1]||"").length,W=Y.toString(),G=(W.split(".")[1]||"").length;if(G===0&&/\d?e-\d?/.test(W)){let H=W.match(/\d?e-(\d?)/);if(H?.[1])G=Number.parseInt(H[1])}let $=X>G?X:G,J=Number.parseInt(Q.toFixed($).replace(".","")),z=Number.parseInt(Y.toFixed($).replace(".",""));return J%z/10**$}var WX=Symbol("evaluating");function c(Q,Y,X){let W=void 0;Object.defineProperty(Q,Y,{get(){if(W===WX)return;if(W===void 0)W=WX,W=X();return W},set(G){Object.defineProperty(Q,Y,{value:G})},configurable:!0})}function LH(Q){return Object.create(Object.getPrototypeOf(Q),Object.getOwnPropertyDescriptors(Q))}function Y1(Q,Y,X){Object.defineProperty(Q,Y,{value:X,writable:!0,enumerable:!0,configurable:!0})}function X1(...Q){let Y={};for(let X of Q){let W=Object.getOwnPropertyDescriptors(X);Object.assign(Y,W)}return Object.defineProperties({},Y)}function qH(Q){return X1(Q._zod.def)}function FH(Q,Y){if(!Y)return Q;return Y.reduce((X,W)=>X?.[W],Q)}function OH(Q){let Y=Object.keys(Q),X=Y.map((W)=>Q[W]);return Promise.all(X).then((W)=>{let G={};for(let $=0;$<Y.length;$++)G[Y[$]]=W[$];return G})}function MH(Q=10){let X="";for(let W=0;W<Q;W++)X+="abcdefghijklmnopqrstuvwxyz"[Math.floor(Math.random()*26)];return X}function o4(Q){return JSON.stringify(Q)}var t4="captureStackTrace"in Error?Error.captureStackTrace:(...Q)=>{};function O1(Q){return typeof Q==="object"&&Q!==null&&!Array.isArray(Q)}var PQ=E1(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{return new Function(""),!0}catch(Q){return!1}});function W1(Q){if(O1(Q)===!1)return!1;let Y=Q.constructor;if(Y===void 0)return!0;let X=Y.prototype;if(O1(X)===!1)return!1;if(Object.prototype.hasOwnProperty.call(X,"isPrototypeOf")===!1)return!1;return!0}function GX(Q){if(W1(Q))return{...Q};if(Array.isArray(Q))return[...Q];return Q}function VH(Q){let Y=0;for(let X in Q)if(Object.prototype.hasOwnProperty.call(Q,X))Y++;return Y}var ZH=(Q)=>{let Y=typeof Q;switch(Y){case"undefined":return"undefined";case"string":return"string";case"number":return Number.isNaN(Q)?"nan":"number";case"boolean":return"boolean";case"function":return"function";case"bigint":return"bigint";case"symbol":return"symbol";case"object":if(Array.isArray(Q))return"array";if(Q===null)return"null";if(Q.then&&typeof Q.then==="function"&&Q.catch&&typeof Q.catch==="function")return"promise";if(typeof Map<"u"&&Q instanceof Map)return"map";if(typeof Set<"u"&&Q instanceof Set)return"set";if(typeof Date<"u"&&Q instanceof Date)return"date";if(typeof File<"u"&&Q instanceof File)return"file";return"object";default:throw Error(`Unknown data type: ${Y}`)}},IQ=new Set(["string","number","symbol"]),$X=new Set(["string","number","bigint","boolean","symbol","undefined"]);function c0(Q){return Q.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function T0(Q,Y,X){let W=new Q._zod.constr(Y??Q._zod.def);if(!Y||X?.parent)W._zod.parent=Q;return W}function I(Q){let Y=Q;if(!Y)return{};if(typeof Y==="string")return{error:()=>Y};if(Y?.message!==void 0){if(Y?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");Y.error=Y.message}if(delete Y.message,typeof Y.error==="string")return{...Y,error:()=>Y.error};return Y}function NH(Q){let Y;return new Proxy({},{get(X,W,G){return Y??(Y=Q()),Reflect.get(Y,W,G)},set(X,W,G,$){return Y??(Y=Q()),Reflect.set(Y,W,G,$)},has(X,W){return Y??(Y=Q()),Reflect.has(Y,W)},deleteProperty(X,W){return Y??(Y=Q()),Reflect.deleteProperty(Y,W)},ownKeys(X){return Y??(Y=Q()),Reflect.ownKeys(Y)},getOwnPropertyDescriptor(X,W){return Y??(Y=Q()),Reflect.getOwnPropertyDescriptor(Y,W)},defineProperty(X,W,G){return Y??(Y=Q()),Reflect.defineProperty(Y,W,G)}})}function a4(Q){if(typeof Q==="bigint")return Q.toString()+"n";if(typeof Q==="string")return`"${Q}"`;return`${Q}`}function EQ(Q){return Object.keys(Q).filter((Y)=>{return Q[Y]._zod.optin==="optional"&&Q[Y]._zod.optout==="optional"})}var TQ={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-340282346638528860000000000000000000000,340282346638528860000000000000000000000],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},JX={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function wH(Q,Y){let X=Q._zod.def,W=X1(Q._zod.def,{get shape(){let G={};for(let $ in Y){if(!($ in X.shape))throw Error(`Unrecognized key: "${$}"`);if(!Y[$])continue;G[$]=X.shape[$]}return Y1(this,"shape",G),G},checks:[]});return T0(Q,W)}function bH(Q,Y){let X=Q._zod.def,W=X1(Q._zod.def,{get shape(){let G={...Q._zod.def.shape};for(let $ in Y){if(!($ in X.shape))throw Error(`Unrecognized key: "${$}"`);if(!Y[$])continue;delete G[$]}return Y1(this,"shape",G),G},checks:[]});return T0(Q,W)}function jH(Q,Y){if(!W1(Y))throw Error("Invalid input to extend: expected a plain object");let X=Q._zod.def.checks;if(X&&X.length>0)throw Error("Object schemas containing refinements cannot be extended. Use `.safeExtend()` instead.");let G=X1(Q._zod.def,{get shape(){let $={...Q._zod.def.shape,...Y};return Y1(this,"shape",$),$},checks:[]});return T0(Q,G)}function PH(Q,Y){if(!W1(Y))throw Error("Invalid input to safeExtend: expected a plain object");let X={...Q._zod.def,get shape(){let W={...Q._zod.def.shape,...Y};return Y1(this,"shape",W),W},checks:Q._zod.def.checks};return T0(Q,X)}function IH(Q,Y){let X=X1(Q._zod.def,{get shape(){let W={...Q._zod.def.shape,...Y._zod.def.shape};return Y1(this,"shape",W),W},get catchall(){return Y._zod.def.catchall},checks:[]});return T0(Q,X)}function EH(Q,Y,X){let W=X1(Y._zod.def,{get shape(){let G=Y._zod.def.shape,$={...G};if(X)for(let J in X){if(!(J in G))throw Error(`Unrecognized key: "${J}"`);if(!X[J])continue;$[J]=Q?new Q({type:"optional",innerType:G[J]}):G[J]}else for(let J in G)$[J]=Q?new Q({type:"optional",innerType:G[J]}):G[J];return Y1(this,"shape",$),$},checks:[]});return T0(Y,W)}function TH(Q,Y,X){let W=X1(Y._zod.def,{get shape(){let G=Y._zod.def.shape,$={...G};if(X)for(let J in X){if(!(J in $))throw Error(`Unrecognized key: "${J}"`);if(!X[J])continue;$[J]=new Q({type:"nonoptional",innerType:G[J]})}else for(let J in G)$[J]=new Q({type:"nonoptional",innerType:G[J]});return Y1(this,"shape",$),$},checks:[]});return T0(Y,W)}function G1(Q,Y=0){if(Q.aborted===!0)return!0;for(let X=Y;X<Q.issues.length;X++)if(Q.issues[X]?.continue!==!0)return!0;return!1}function p0(Q,Y){return Y.map((X)=>{var W;return(W=X).path??(W.path=[]),X.path.unshift(Q),X})}function o1(Q){return typeof Q==="string"?Q:Q?.message}function S0(Q,Y,X){let W={...Q,path:Q.path??[]};if(!Q.message){let G=o1(Q.inst?._zod.def?.error?.(Q))??o1(Y?.error?.(Q))??o1(X.customError?.(Q))??o1(X.localeError?.(Q))??"Invalid input";W.message=G}if(delete W.inst,delete W.continue,!Y?.reportInput)delete W.input;return W}function zX(Q){if(Q instanceof Set)return"set";if(Q instanceof Map)return"map";if(Q instanceof File)return"file";return"unknown"}function s1(Q){if(Array.isArray(Q))return"array";if(typeof Q==="string")return"string";return"unknown"}function T1(...Q){let[Y,X,W]=Q;if(typeof Y==="string")return{message:Y,code:"custom",input:X,inst:W};return{...Y}}function SH(Q){return Object.entries(Q).filter(([Y,X])=>{return Number.isNaN(Number.parseInt(Y,10))}).map((Y)=>Y[1])}function HX(Q){let Y=atob(Q),X=new Uint8Array(Y.length);for(let W=0;W<Y.length;W++)X[W]=Y.charCodeAt(W);return X}function UX(Q){let Y="";for(let X=0;X<Q.length;X++)Y+=String.fromCharCode(Q[X]);return btoa(Y)}function RH(Q){let Y=Q.replace(/-/g,"+").replace(/_/g,"/"),X="=".repeat((4-Y.length%4)%4);return HX(Y+X)}function CH(Q){return UX(Q).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function kH(Q){let Y=Q.replace(/^0x/,"");if(Y.length%2!==0)throw Error("Invalid hex string length");let X=new Uint8Array(Y.length/2);for(let W=0;W<Y.length;W+=2)X[W/2]=Number.parseInt(Y.slice(W,W+2),16);return X}function vH(Q){return Array.from(Q).map((Y)=>Y.toString(16).padStart(2,"0")).join("")}class AX{constructor(...Q){}}var BX=(Q,Y)=>{Q.name="$ZodError",Object.defineProperty(Q,"_zod",{value:Q._zod,enumerable:!1}),Object.defineProperty(Q,"issues",{value:Y,enumerable:!1}),Q.message=JSON.stringify(Y,I1,2),Object.defineProperty(Q,"toString",{value:()=>Q.message,enumerable:!1})},s4=q("$ZodError",BX),SQ=q("$ZodError",BX,{Parent:Error});function KX(Q,Y=(X)=>X.message){let X={},W=[];for(let G of Q.issues)if(G.path.length>0)X[G.path[0]]=X[G.path[0]]||[],X[G.path[0]].push(Y(G));else W.push(Y(G));return{formErrors:W,fieldErrors:X}}function DX(Q,Y=(X)=>X.message){let X={_errors:[]},W=(G)=>{for(let $ of G.issues)if($.code==="invalid_union"&&$.errors.length)$.errors.map((J)=>W({issues:J}));else if($.code==="invalid_key")W({issues:$.issues});else if($.code==="invalid_element")W({issues:$.issues});else if($.path.length===0)X._errors.push(Y($));else{let J=X,z=0;while(z<$.path.length){let H=$.path[z];if(z!==$.path.length-1)J[H]=J[H]||{_errors:[]};else J[H]=J[H]||{_errors:[]},J[H]._errors.push(Y($));J=J[H],z++}}};return W(Q),X}var e4=(Q)=>(Y,X,W,G)=>{let $=W?Object.assign(W,{async:!1}):{async:!1},J=Y._zod.run({value:X,issues:[]},$);if(J instanceof Promise)throw new m0;if(J.issues.length){let z=new(G?.Err??Q)(J.issues.map((H)=>S0(H,$,b0())));throw t4(z,G?.callee),z}return J.value};var Q6=(Q)=>async(Y,X,W,G)=>{let $=W?Object.assign(W,{async:!0}):{async:!0},J=Y._zod.run({value:X,issues:[]},$);if(J instanceof Promise)J=await J;if(J.issues.length){let z=new(G?.Err??Q)(J.issues.map((H)=>S0(H,$,b0())));throw t4(z,G?.callee),z}return J.value};var e1=(Q)=>(Y,X,W)=>{let G=W?{...W,async:!1}:{async:!1},$=Y._zod.run({value:X,issues:[]},G);if($ instanceof Promise)throw new m0;return $.issues.length?{success:!1,error:new(Q??s4)($.issues.map((J)=>S0(J,G,b0())))}:{success:!0,data:$.value}},Q4=e1(SQ),Y4=(Q)=>async(Y,X,W)=>{let G=W?Object.assign(W,{async:!0}):{async:!0},$=Y._zod.run({value:X,issues:[]},G);if($ instanceof Promise)$=await $;return $.issues.length?{success:!1,error:new Q($.issues.map((J)=>S0(J,G,b0())))}:{success:!0,data:$.value}},Y6=Y4(SQ),LX=(Q)=>(Y,X,W)=>{let G=W?Object.assign(W,{direction:"backward"}):{direction:"backward"};return e4(Q)(Y,X,G)};var qX=(Q)=>(Y,X,W)=>{return e4(Q)(Y,X,W)};var FX=(Q)=>async(Y,X,W)=>{let G=W?Object.assign(W,{direction:"backward"}):{direction:"backward"};return Q6(Q)(Y,X,G)};var OX=(Q)=>async(Y,X,W)=>{return Q6(Q)(Y,X,W)};var MX=(Q)=>(Y,X,W)=>{let G=W?Object.assign(W,{direction:"backward"}):{direction:"backward"};return e1(Q)(Y,X,G)};var VX=(Q)=>(Y,X,W)=>{return e1(Q)(Y,X,W)};var ZX=(Q)=>async(Y,X,W)=>{let G=W?Object.assign(W,{direction:"backward"}):{direction:"backward"};return Y4(Q)(Y,X,G)};var NX=(Q)=>async(Y,X,W)=>{return Y4(Q)(Y,X,W)};var wX=/^[cC][^\s-]{8,}$/,bX=/^[0-9a-z]+$/,jX=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,PX=/^[0-9a-vA-V]{20}$/,IX=/^[A-Za-z0-9]{27}$/,EX=/^[a-zA-Z0-9_-]{21}$/,TX=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;var SX=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,RQ=(Q)=>{if(!Q)return/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/;return new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${Q}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`)};var RX=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;function CX(){return new RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")}var kX=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,vX=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,xX=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,_X=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,yX=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,CQ=/^[A-Za-z0-9_-]*$/,gX=/^(?=.{1,253}\.?$)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[-0-9a-zA-Z]{0,61}[0-9a-zA-Z])?)*\.?$/;var uX=/^\+(?:[0-9]){6,14}[0-9]$/,hX="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",fX=new RegExp(`^${hX}$`);function lX(Q){return typeof Q.precision==="number"?Q.precision===-1?"(?:[01]\\d|2[0-3]):[0-5]\\d":Q.precision===0?"(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d":`(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d\\.\\d{${Q.precision}}`:"(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?"}function mX(Q){return new RegExp(`^${lX(Q)}$`)}function cX(Q){let Y=lX({precision:Q.precision}),X=["Z"];if(Q.local)X.push("");if(Q.offset)X.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");let W=`${Y}(?:${X.join("|")})`;return new RegExp(`^${hX}T(?:${W})$`)}var pX=(Q)=>{let Y=Q?`[\\s\\S]{${Q?.minimum??0},${Q?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${Y}$`)};var iX=/^-?\d+$/,nX=/^-?\d+(?:\.\d+)?/,rX=/^(?:true|false)$/i,dX=/^null$/i;var oX=/^[^A-Z]*$/,tX=/^[^a-z]*$/;var G0=q("$ZodCheck",(Q,Y)=>{var X;Q._zod??(Q._zod={}),Q._zod.def=Y,(X=Q._zod).onattach??(X.onattach=[])}),aX={number:"number",bigint:"bigint",object:"date"},kQ=q("$ZodCheckLessThan",(Q,Y)=>{G0.init(Q,Y);let X=aX[typeof Y.value];Q._zod.onattach.push((W)=>{let G=W._zod.bag,$=(Y.inclusive?G.maximum:G.exclusiveMaximum)??Number.POSITIVE_INFINITY;if(Y.value<$)if(Y.inclusive)G.maximum=Y.value;else G.exclusiveMaximum=Y.value}),Q._zod.check=(W)=>{if(Y.inclusive?W.value<=Y.value:W.value<Y.value)return;W.issues.push({origin:X,code:"too_big",maximum:Y.value,input:W.value,inclusive:Y.inclusive,inst:Q,continue:!Y.abort})}}),vQ=q("$ZodCheckGreaterThan",(Q,Y)=>{G0.init(Q,Y);let X=aX[typeof Y.value];Q._zod.onattach.push((W)=>{let G=W._zod.bag,$=(Y.inclusive?G.minimum:G.exclusiveMinimum)??Number.NEGATIVE_INFINITY;if(Y.value>$)if(Y.inclusive)G.minimum=Y.value;else G.exclusiveMinimum=Y.value}),Q._zod.check=(W)=>{if(Y.inclusive?W.value>=Y.value:W.value>Y.value)return;W.issues.push({origin:X,code:"too_small",minimum:Y.value,input:W.value,inclusive:Y.inclusive,inst:Q,continue:!Y.abort})}}),sX=q("$ZodCheckMultipleOf",(Q,Y)=>{G0.init(Q,Y),Q._zod.onattach.push((X)=>{var W;(W=X._zod.bag).multipleOf??(W.multipleOf=Y.value)}),Q._zod.check=(X)=>{if(typeof X.value!==typeof Y.value)throw Error("Cannot mix number and bigint in multiple_of check.");if(typeof X.value==="bigint"?X.value%Y.value===BigInt(0):jQ(X.value,Y.value)===0)return;X.issues.push({origin:typeof X.value,code:"not_multiple_of",divisor:Y.value,input:X.value,inst:Q,continue:!Y.abort})}}),eX=q("$ZodCheckNumberFormat",(Q,Y)=>{G0.init(Q,Y),Y.format=Y.format||"float64";let X=Y.format?.includes("int"),W=X?"int":"number",[G,$]=TQ[Y.format];Q._zod.onattach.push((J)=>{let z=J._zod.bag;if(z.format=Y.format,z.minimum=G,z.maximum=$,X)z.pattern=iX}),Q._zod.check=(J)=>{let z=J.value;if(X){if(!Number.isInteger(z)){J.issues.push({expected:W,format:Y.format,code:"invalid_type",continue:!1,input:z,inst:Q});return}if(!Number.isSafeInteger(z)){if(z>0)J.issues.push({input:z,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:Q,origin:W,continue:!Y.abort});else J.issues.push({input:z,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:Q,origin:W,continue:!Y.abort});return}}if(z<G)J.issues.push({origin:"number",input:z,code:"too_small",minimum:G,inclusive:!0,inst:Q,continue:!Y.abort});if(z>$)J.issues.push({origin:"number",input:z,code:"too_big",maximum:$,inst:Q})}});var Q8=q("$ZodCheckMaxLength",(Q,Y)=>{var X;G0.init(Q,Y),(X=Q._zod.def).when??(X.when=(W)=>{let G=W.value;return!t1(G)&&G.length!==void 0}),Q._zod.onattach.push((W)=>{let G=W._zod.bag.maximum??Number.POSITIVE_INFINITY;if(Y.maximum<G)W._zod.bag.maximum=Y.maximum}),Q._zod.check=(W)=>{let G=W.value;if(G.length<=Y.maximum)return;let J=s1(G);W.issues.push({origin:J,code:"too_big",maximum:Y.maximum,inclusive:!0,input:G,inst:Q,continue:!Y.abort})}}),Y8=q("$ZodCheckMinLength",(Q,Y)=>{var X;G0.init(Q,Y),(X=Q._zod.def).when??(X.when=(W)=>{let G=W.value;return!t1(G)&&G.length!==void 0}),Q._zod.onattach.push((W)=>{let G=W._zod.bag.minimum??Number.NEGATIVE_INFINITY;if(Y.minimum>G)W._zod.bag.minimum=Y.minimum}),Q._zod.check=(W)=>{let G=W.value;if(G.length>=Y.minimum)return;let J=s1(G);W.issues.push({origin:J,code:"too_small",minimum:Y.minimum,inclusive:!0,input:G,inst:Q,continue:!Y.abort})}}),X8=q("$ZodCheckLengthEquals",(Q,Y)=>{var X;G0.init(Q,Y),(X=Q._zod.def).when??(X.when=(W)=>{let G=W.value;return!t1(G)&&G.length!==void 0}),Q._zod.onattach.push((W)=>{let G=W._zod.bag;G.minimum=Y.length,G.maximum=Y.length,G.length=Y.length}),Q._zod.check=(W)=>{let G=W.value,$=G.length;if($===Y.length)return;let J=s1(G),z=$>Y.length;W.issues.push({origin:J,...z?{code:"too_big",maximum:Y.length}:{code:"too_small",minimum:Y.length},inclusive:!0,exact:!0,input:W.value,inst:Q,continue:!Y.abort})}}),X4=q("$ZodCheckStringFormat",(Q,Y)=>{var X,W;if(G0.init(Q,Y),Q._zod.onattach.push((G)=>{let $=G._zod.bag;if($.format=Y.format,Y.pattern)$.patterns??($.patterns=new Set),$.patterns.add(Y.pattern)}),Y.pattern)(X=Q._zod).check??(X.check=(G)=>{if(Y.pattern.lastIndex=0,Y.pattern.test(G.value))return;G.issues.push({origin:"string",code:"invalid_format",format:Y.format,input:G.value,...Y.pattern?{pattern:Y.pattern.toString()}:{},inst:Q,continue:!Y.abort})});else(W=Q._zod).check??(W.check=()=>{})}),W8=q("$ZodCheckRegex",(Q,Y)=>{X4.init(Q,Y),Q._zod.check=(X)=>{if(Y.pattern.lastIndex=0,Y.pattern.test(X.value))return;X.issues.push({origin:"string",code:"invalid_format",format:"regex",input:X.value,pattern:Y.pattern.toString(),inst:Q,continue:!Y.abort})}}),G8=q("$ZodCheckLowerCase",(Q,Y)=>{Y.pattern??(Y.pattern=oX),X4.init(Q,Y)}),$8=q("$ZodCheckUpperCase",(Q,Y)=>{Y.pattern??(Y.pattern=tX),X4.init(Q,Y)}),J8=q("$ZodCheckIncludes",(Q,Y)=>{G0.init(Q,Y);let X=c0(Y.includes),W=new RegExp(typeof Y.position==="number"?`^.{${Y.position}}${X}`:X);Y.pattern=W,Q._zod.onattach.push((G)=>{let $=G._zod.bag;$.patterns??($.patterns=new Set),$.patterns.add(W)}),Q._zod.check=(G)=>{if(G.value.includes(Y.includes,Y.position))return;G.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:Y.includes,input:G.value,inst:Q,continue:!Y.abort})}}),z8=q("$ZodCheckStartsWith",(Q,Y)=>{G0.init(Q,Y);let X=new RegExp(`^${c0(Y.prefix)}.*`);Y.pattern??(Y.pattern=X),Q._zod.onattach.push((W)=>{let G=W._zod.bag;G.patterns??(G.patterns=new Set),G.patterns.add(X)}),Q._zod.check=(W)=>{if(W.value.startsWith(Y.prefix))return;W.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:Y.prefix,input:W.value,inst:Q,continue:!Y.abort})}}),H8=q("$ZodCheckEndsWith",(Q,Y)=>{G0.init(Q,Y);let X=new RegExp(`.*${c0(Y.suffix)}$`);Y.pattern??(Y.pattern=X),Q._zod.onattach.push((W)=>{let G=W._zod.bag;G.patterns??(G.patterns=new Set),G.patterns.add(X)}),Q._zod.check=(W)=>{if(W.value.endsWith(Y.suffix))return;W.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:Y.suffix,input:W.value,inst:Q,continue:!Y.abort})}});var U8=q("$ZodCheckOverwrite",(Q,Y)=>{G0.init(Q,Y),Q._zod.check=(X)=>{X.value=Y.tx(X.value)}});class xQ{constructor(Q=[]){if(this.content=[],this.indent=0,this)this.args=Q}indented(Q){this.indent+=1,Q(this),this.indent-=1}write(Q){if(typeof Q==="function"){Q(this,{execution:"sync"}),Q(this,{execution:"async"});return}let X=Q.split(`
|
|
9
|
+
deps: ${X}}`};var uF={keyword:"dependencies",type:"object",schemaType:"object",error:H7.error,code(Q){let[Y,X]=hF(Q);J7(Q,Y),z7(Q,X)}};function hF({schema:Q}){let Y={},X={};for(let W in Q){if(W==="__proto__")continue;let G=Array.isArray(Q[W])?Y:X;G[W]=Q[W]}return[Y,X]}function J7(Q,Y=Q.schema){let{gen:X,data:W,it:G}=Q;if(Object.keys(Y).length===0)return;let $=X.let("missing");for(let J in Y){let z=Y[J];if(z.length===0)continue;let H=(0,h6.propertyInData)(X,W,J,G.opts.ownProperties);if(Q.setParams({property:J,depsCount:z.length,deps:z.join(", ")}),G.allErrors)X.if(H,()=>{for(let U of z)(0,h6.checkReportMissingProp)(Q,U)});else X.if(FY._`${H} && (${(0,h6.checkMissingProp)(Q,z,$)})`),(0,h6.reportMissingProp)(Q,$),X.else()}}H7.validatePropertyDeps=J7;function z7(Q,Y=Q.schema){let{gen:X,data:W,keyword:G,it:$}=Q,J=X.name("valid");for(let z in Y){if((0,gF.alwaysValidSchema)($,Y[z]))continue;X.if((0,h6.propertyInData)(X,W,z,$.opts.ownProperties),()=>{let H=Q.subschema({keyword:G,schemaProp:z},J);Q.mergeValidEvaluated(H,J)},()=>X.var(J,!0)),Q.ok(J)}}H7.validateSchemaDeps=z7;H7.default=uF});var L7=w((D7)=>{Object.defineProperty(D7,"__esModule",{value:!0});var K7=v(),mF=l(),cF={message:"property name must be valid",params:({params:Q})=>K7._`{propertyName: ${Q.propertyName}}`},pF={keyword:"propertyNames",type:"object",schemaType:["object","boolean"],error:cF,code(Q){let{gen:Y,schema:X,data:W,it:G}=Q;if((0,mF.alwaysValidSchema)(G,X))return;let $=Y.name("valid");Y.forIn("key",W,(J)=>{Q.setParams({propertyName:J}),Q.subschema({keyword:"propertyNames",data:J,dataTypes:["string"],propertyName:J,compositeRule:!0},$),Y.if((0,K7.not)($),()=>{if(Q.error(!0),!G.allErrors)Y.break()})}),Q.ok($)}};D7.default=pF});var OY=w((q7)=>{Object.defineProperty(q7,"__esModule",{value:!0});var JQ=I0(),x0=v(),nF=r0(),zQ=l(),rF={message:"must NOT have additional properties",params:({params:Q})=>x0._`{additionalProperty: ${Q.additionalProperty}}`},dF={keyword:"additionalProperties",type:["object"],schemaType:["boolean","object"],allowUndefined:!0,trackErrors:!0,error:rF,code(Q){let{gen:Y,schema:X,parentSchema:W,data:G,errsCount:$,it:J}=Q;if(!$)throw Error("ajv implementation error");let{allErrors:z,opts:H}=J;if(J.props=!0,H.removeAdditional!=="all"&&(0,zQ.alwaysValidSchema)(J,X))return;let U=(0,JQ.allSchemaProperties)(W.properties),A=(0,JQ.allSchemaProperties)(W.patternProperties);B(),Q.ok(x0._`${$} === ${nF.default.errors}`);function B(){Y.forIn("key",G,(Z)=>{if(!U.length&&!A.length)O(Z);else Y.if(K(Z),()=>O(Z))})}function K(Z){let V;if(U.length>8){let S=(0,zQ.schemaRefOrVal)(J,W.properties,"properties");V=(0,JQ.isOwnProperty)(Y,S,Z)}else if(U.length)V=(0,x0.or)(...U.map((S)=>x0._`${Z} === ${S}`));else V=x0.nil;if(A.length)V=(0,x0.or)(V,...A.map((S)=>x0._`${(0,JQ.usePattern)(Q,S)}.test(${Z})`));return(0,x0.not)(V)}function L(Z){Y.code(x0._`delete ${G}[${Z}]`)}function O(Z){if(H.removeAdditional==="all"||H.removeAdditional&&X===!1){L(Z);return}if(X===!1){if(Q.setParams({additionalProperty:Z}),Q.error(),!z)Y.break();return}if(typeof X=="object"&&!(0,zQ.alwaysValidSchema)(J,X)){let V=Y.name("valid");if(H.removeAdditional==="failing")M(Z,V,!1),Y.if((0,x0.not)(V),()=>{Q.reset(),L(Z)});else if(M(Z,V),!z)Y.if((0,x0.not)(V),()=>Y.break())}}function M(Z,V,S){let E={keyword:"additionalProperties",dataProp:Z,dataPropType:zQ.Type.Str};if(S===!1)Object.assign(E,{compositeRule:!0,createErrors:!1,allErrors:!1});Q.subschema(E,V)}}};q7.default=dF});var V7=w((M7)=>{Object.defineProperty(M7,"__esModule",{value:!0});var tF=E6(),F7=I0(),MY=l(),O7=OY(),aF={keyword:"properties",type:"object",schemaType:"object",code(Q){let{gen:Y,schema:X,parentSchema:W,data:G,it:$}=Q;if($.opts.removeAdditional==="all"&&W.additionalProperties===void 0)O7.default.code(new tF.KeywordCxt($,O7.default,"additionalProperties"));let J=(0,F7.allSchemaProperties)(X);for(let B of J)$.definedProperties.add(B);if($.opts.unevaluated&&J.length&&$.props!==!0)$.props=MY.mergeEvaluated.props(Y,(0,MY.toHash)(J),$.props);let z=J.filter((B)=>!(0,MY.alwaysValidSchema)($,X[B]));if(z.length===0)return;let H=Y.name("valid");for(let B of z){if(U(B))A(B);else{if(Y.if((0,F7.propertyInData)(Y,G,B,$.opts.ownProperties)),A(B),!$.allErrors)Y.else().var(H,!0);Y.endIf()}Q.it.definedProperties.add(B),Q.ok(H)}function U(B){return $.opts.useDefaults&&!$.compositeRule&&X[B].default!==void 0}function A(B){Q.subschema({keyword:"properties",schemaProp:B,dataProp:B},H)}}};M7.default=aF});var j7=w((b7)=>{Object.defineProperty(b7,"__esModule",{value:!0});var Z7=I0(),HQ=v(),N7=l(),w7=l(),eF={keyword:"patternProperties",type:"object",schemaType:"object",code(Q){let{gen:Y,schema:X,data:W,parentSchema:G,it:$}=Q,{opts:J}=$,z=(0,Z7.allSchemaProperties)(X),H=z.filter((M)=>(0,N7.alwaysValidSchema)($,X[M]));if(z.length===0||H.length===z.length&&(!$.opts.unevaluated||$.props===!0))return;let U=J.strictSchema&&!J.allowMatchingProperties&&G.properties,A=Y.name("valid");if($.props!==!0&&!($.props instanceof HQ.Name))$.props=(0,w7.evaluatedPropsToName)(Y,$.props);let{props:B}=$;K();function K(){for(let M of z){if(U)L(M);if($.allErrors)O(M);else Y.var(A,!0),O(M),Y.if(A)}}function L(M){for(let Z in U)if(new RegExp(M).test(Z))(0,N7.checkStrictMode)($,`property ${Z} matches pattern ${M} (use allowMatchingProperties)`)}function O(M){Y.forIn("key",W,(Z)=>{Y.if(HQ._`${(0,Z7.usePattern)(Q,M)}.test(${Z})`,()=>{let V=H.includes(M);if(!V)Q.subschema({keyword:"patternProperties",schemaProp:M,dataProp:Z,dataPropType:w7.Type.Str},A);if($.opts.unevaluated&&B!==!0)Y.assign(HQ._`${B}[${Z}]`,!0);else if(!V&&!$.allErrors)Y.if((0,HQ.not)(A),()=>Y.break())})})}}};b7.default=eF});var I7=w((P7)=>{Object.defineProperty(P7,"__esModule",{value:!0});var YO=l(),XO={keyword:"not",schemaType:["object","boolean"],trackErrors:!0,code(Q){let{gen:Y,schema:X,it:W}=Q;if((0,YO.alwaysValidSchema)(W,X)){Q.fail();return}let G=Y.name("valid");Q.subschema({keyword:"not",compositeRule:!0,createErrors:!1,allErrors:!1},G),Q.failResult(G,()=>Q.reset(),()=>Q.error())},error:{message:"must NOT be valid"}};P7.default=XO});var T7=w((E7)=>{Object.defineProperty(E7,"__esModule",{value:!0});var GO=I0(),$O={keyword:"anyOf",schemaType:"array",trackErrors:!0,code:GO.validateUnion,error:{message:"must match a schema in anyOf"}};E7.default=$O});var R7=w((S7)=>{Object.defineProperty(S7,"__esModule",{value:!0});var UQ=v(),zO=l(),HO={message:"must match exactly one schema in oneOf",params:({params:Q})=>UQ._`{passingSchemas: ${Q.passing}}`},UO={keyword:"oneOf",schemaType:"array",trackErrors:!0,error:HO,code(Q){let{gen:Y,schema:X,parentSchema:W,it:G}=Q;if(!Array.isArray(X))throw Error("ajv implementation error");if(G.opts.discriminator&&W.discriminator)return;let $=X,J=Y.let("valid",!1),z=Y.let("passing",null),H=Y.name("_valid");Q.setParams({passing:z}),Y.block(U),Q.result(J,()=>Q.reset(),()=>Q.error(!0));function U(){$.forEach((A,B)=>{let K;if((0,zO.alwaysValidSchema)(G,A))Y.var(H,!0);else K=Q.subschema({keyword:"oneOf",schemaProp:B,compositeRule:!0},H);if(B>0)Y.if(UQ._`${H} && ${J}`).assign(J,!1).assign(z,UQ._`[${z}, ${B}]`).else();Y.if(H,()=>{if(Y.assign(J,!0),Y.assign(z,B),K)Q.mergeEvaluated(K,UQ.Name)})})}}};S7.default=UO});var k7=w((C7)=>{Object.defineProperty(C7,"__esModule",{value:!0});var BO=l(),KO={keyword:"allOf",schemaType:"array",code(Q){let{gen:Y,schema:X,it:W}=Q;if(!Array.isArray(X))throw Error("ajv implementation error");let G=Y.name("valid");X.forEach(($,J)=>{if((0,BO.alwaysValidSchema)(W,$))return;let z=Q.subschema({keyword:"allOf",schemaProp:J},G);Q.ok(G),Q.mergeEvaluated(z)})}};C7.default=KO});var y7=w((_7)=>{Object.defineProperty(_7,"__esModule",{value:!0});var AQ=v(),x7=l(),LO={message:({params:Q})=>AQ.str`must match "${Q.ifClause}" schema`,params:({params:Q})=>AQ._`{failingKeyword: ${Q.ifClause}}`},qO={keyword:"if",schemaType:["object","boolean"],trackErrors:!0,error:LO,code(Q){let{gen:Y,parentSchema:X,it:W}=Q;if(X.then===void 0&&X.else===void 0)(0,x7.checkStrictMode)(W,'"if" without "then" and "else" is ignored');let G=v7(W,"then"),$=v7(W,"else");if(!G&&!$)return;let J=Y.let("valid",!0),z=Y.name("_valid");if(H(),Q.reset(),G&&$){let A=Y.let("ifClause");Q.setParams({ifClause:A}),Y.if(z,U("then",A),U("else",A))}else if(G)Y.if(z,U("then"));else Y.if((0,AQ.not)(z),U("else"));Q.pass(J,()=>Q.error(!0));function H(){let A=Q.subschema({keyword:"if",compositeRule:!0,createErrors:!1,allErrors:!1},z);Q.mergeEvaluated(A)}function U(A,B){return()=>{let K=Q.subschema({keyword:A},z);if(Y.assign(J,z),Q.mergeValidEvaluated(K,J),B)Y.assign(B,AQ._`${A}`);else Q.setParams({ifClause:A})}}}};function v7(Q,Y){let X=Q.schema[Y];return X!==void 0&&!(0,x7.alwaysValidSchema)(Q,X)}_7.default=qO});var u7=w((g7)=>{Object.defineProperty(g7,"__esModule",{value:!0});var OO=l(),MO={keyword:["then","else"],schemaType:["object","boolean"],code({keyword:Q,parentSchema:Y,it:X}){if(Y.if===void 0)(0,OO.checkStrictMode)(X,`"${Q}" without "if" is ignored`)}};g7.default=MO});var f7=w((h7)=>{Object.defineProperty(h7,"__esModule",{value:!0});var ZO=LY(),NO=Q7(),wO=qY(),bO=W7(),jO=$7(),PO=B7(),IO=L7(),EO=OY(),TO=V7(),SO=j7(),RO=I7(),CO=T7(),kO=R7(),vO=k7(),xO=y7(),_O=u7();function yO(Q=!1){let Y=[RO.default,CO.default,kO.default,vO.default,xO.default,_O.default,IO.default,EO.default,PO.default,TO.default,SO.default];if(Q)Y.push(NO.default,bO.default);else Y.push(ZO.default,wO.default);return Y.push(jO.default),Y}h7.default=yO});var m7=w((l7)=>{Object.defineProperty(l7,"__esModule",{value:!0});var Q0=v(),uO={message:({schemaCode:Q})=>Q0.str`must match format "${Q}"`,params:({schemaCode:Q})=>Q0._`{format: ${Q}}`},hO={keyword:"format",type:["number","string"],schemaType:"string",$data:!0,error:uO,code(Q,Y){let{gen:X,data:W,$data:G,schema:$,schemaCode:J,it:z}=Q,{opts:H,errSchemaPath:U,schemaEnv:A,self:B}=z;if(!H.validateFormats)return;if(G)K();else L();function K(){let O=X.scopeValue("formats",{ref:B.formats,code:H.code.formats}),M=X.const("fDef",Q0._`${O}[${J}]`),Z=X.let("fType"),V=X.let("format");X.if(Q0._`typeof ${M} == "object" && !(${M} instanceof RegExp)`,()=>X.assign(Z,Q0._`${M}.type || "string"`).assign(V,Q0._`${M}.validate`),()=>X.assign(Z,Q0._`"string"`).assign(V,M)),Q.fail$data((0,Q0.or)(S(),E()));function S(){if(H.strictSchema===!1)return Q0.nil;return Q0._`${J} && !${V}`}function E(){let _=A.$async?Q0._`(${M}.async ? await ${V}(${W}) : ${V}(${W}))`:Q0._`${V}(${W})`,T=Q0._`(typeof ${V} == "function" ? ${_} : ${V}.test(${W}))`;return Q0._`${V} && ${V} !== true && ${Z} === ${Y} && !${T}`}}function L(){let O=B.formats[$];if(!O){S();return}if(O===!0)return;let[M,Z,V]=E(O);if(M===Y)Q.pass(_());function S(){if(H.strictSchema===!1){B.logger.warn(T());return}throw Error(T());function T(){return`unknown format "${$}" ignored in schema at path "${U}"`}}function E(T){let y0=T instanceof RegExp?(0,Q0.regexpCode)(T):H.code.formats?Q0._`${H.code.formats}${(0,Q0.getProperty)($)}`:void 0,l0=X.scopeValue("formats",{key:$,ref:T,code:y0});if(typeof T=="object"&&!(T instanceof RegExp))return[T.type||"string",T.validate,Q0._`${l0}.validate`];return["string",T,l0]}function _(){if(typeof O=="object"&&!(O instanceof RegExp)&&O.async){if(!A.$async)throw Error("async format in sync schema");return Q0._`await ${V}(${W})`}return typeof Z=="function"?Q0._`${V}(${W})`:Q0._`${V}.test(${W})`}}}};l7.default=hO});var p7=w((c7)=>{Object.defineProperty(c7,"__esModule",{value:!0});var lO=m7(),mO=[lO.default];c7.default=mO});var r7=w((i7)=>{Object.defineProperty(i7,"__esModule",{value:!0});i7.contentVocabulary=i7.metadataVocabulary=void 0;i7.metadataVocabulary=["title","description","default","deprecated","readOnly","writeOnly","examples"];i7.contentVocabulary=["contentMediaType","contentEncoding","contentSchema"]});var t7=w((o7)=>{Object.defineProperty(o7,"__esModule",{value:!0});var iO=Mz(),nO=iz(),rO=f7(),dO=p7(),d7=r7(),oO=[iO.default,nO.default,(0,rO.default)(),dO.default,d7.metadataVocabulary,d7.contentVocabulary];o7.default=oO});var Q5=w((s7)=>{Object.defineProperty(s7,"__esModule",{value:!0});s7.DiscrError=void 0;var a7;(function(Q){Q.Tag="tag",Q.Mapping="mapping"})(a7||(s7.DiscrError=a7={}))});var W5=w((X5)=>{Object.defineProperty(X5,"__esModule",{value:!0});var m1=v(),VY=Q5(),Y5=i4(),aO=T6(),sO=l(),eO={message:({params:{discrError:Q,tagName:Y}})=>Q===VY.DiscrError.Tag?`tag "${Y}" must be string`:`value of tag "${Y}" must be in oneOf`,params:({params:{discrError:Q,tag:Y,tagName:X}})=>m1._`{error: ${Q}, tag: ${X}, tagValue: ${Y}}`},QM={keyword:"discriminator",type:"object",schemaType:"object",error:eO,code(Q){let{gen:Y,data:X,schema:W,parentSchema:G,it:$}=Q,{oneOf:J}=G;if(!$.opts.discriminator)throw Error("discriminator: requires discriminator option");let z=W.propertyName;if(typeof z!="string")throw Error("discriminator: requires propertyName");if(W.mapping)throw Error("discriminator: mapping is not supported");if(!J)throw Error("discriminator: requires oneOf keyword");let H=Y.let("valid",!1),U=Y.const("tag",m1._`${X}${(0,m1.getProperty)(z)}`);Y.if(m1._`typeof ${U} == "string"`,()=>A(),()=>Q.error(!1,{discrError:VY.DiscrError.Tag,tag:U,tagName:z})),Q.ok(H);function A(){let L=K();Y.if(!1);for(let O in L)Y.elseIf(m1._`${U} === ${O}`),Y.assign(H,B(L[O]));Y.else(),Q.error(!1,{discrError:VY.DiscrError.Mapping,tag:U,tagName:z}),Y.endIf()}function B(L){let O=Y.name("valid"),M=Q.subschema({keyword:"oneOf",schemaProp:L},O);return Q.mergeEvaluated(M,m1.Name),O}function K(){var L;let O={},M=V(G),Z=!0;for(let _=0;_<J.length;_++){let T=J[_];if((T===null||T===void 0?void 0:T.$ref)&&!(0,sO.schemaHasRulesButRef)(T,$.self.RULES)){let l0=T.$ref;if(T=Y5.resolveRef.call($.self,$.schemaEnv.root,$.baseId,l0),T instanceof Y5.SchemaEnv)T=T.schema;if(T===void 0)throw new aO.default($.opts.uriResolver,$.baseId,l0)}let y0=(L=T===null||T===void 0?void 0:T.properties)===null||L===void 0?void 0:L[z];if(typeof y0!="object")throw Error(`discriminator: oneOf subschemas (or referenced schemas) must have "properties/${z}"`);Z=Z&&(M||V(T)),S(y0,_)}if(!Z)throw Error(`discriminator: "${z}" must be required`);return O;function V({required:_}){return Array.isArray(_)&&_.includes(z)}function S(_,T){if(_.const)E(_.const,T);else if(_.enum)for(let y0 of _.enum)E(y0,T);else throw Error(`discriminator: "properties/${z}" must have "const" or "enum"`)}function E(_,T){if(typeof _!="string"||_ in O)throw Error(`discriminator: "${z}" values must be unique strings`);O[_]=T}}}};X5.default=QM});var G5=w((_I,XM)=>{XM.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 NY=w((V0,ZY)=>{Object.defineProperty(V0,"__esModule",{value:!0});V0.MissingRefError=V0.ValidationError=V0.CodeGen=V0.Name=V0.nil=V0.stringify=V0.str=V0._=V0.KeywordCxt=V0.Ajv=void 0;var WM=Hz(),GM=t7(),$M=W5(),$5=G5(),JM=["/properties"],BQ="http://json-schema.org/draft-07/schema";class f6 extends WM.default{_addVocabularies(){if(super._addVocabularies(),GM.default.forEach((Q)=>this.addVocabulary(Q)),this.opts.discriminator)this.addKeyword($M.default)}_addDefaultMetaSchema(){if(super._addDefaultMetaSchema(),!this.opts.meta)return;let Q=this.opts.$data?this.$dataMetaSchema($5,JM):$5;this.addMetaSchema(Q,BQ,!1),this.refs["http://json-schema.org/schema"]=BQ}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(BQ)?BQ:void 0)}}V0.Ajv=f6;ZY.exports=V0=f6;ZY.exports.Ajv=f6;Object.defineProperty(V0,"__esModule",{value:!0});V0.default=f6;var zM=E6();Object.defineProperty(V0,"KeywordCxt",{enumerable:!0,get:function(){return zM.KeywordCxt}});var c1=v();Object.defineProperty(V0,"_",{enumerable:!0,get:function(){return c1._}});Object.defineProperty(V0,"str",{enumerable:!0,get:function(){return c1.str}});Object.defineProperty(V0,"stringify",{enumerable:!0,get:function(){return c1.stringify}});Object.defineProperty(V0,"nil",{enumerable:!0,get:function(){return c1.nil}});Object.defineProperty(V0,"Name",{enumerable:!0,get:function(){return c1.Name}});Object.defineProperty(V0,"CodeGen",{enumerable:!0,get:function(){return c1.CodeGen}});var HM=c4();Object.defineProperty(V0,"ValidationError",{enumerable:!0,get:function(){return HM.default}});var UM=T6();Object.defineProperty(V0,"MissingRefError",{enumerable:!0,get:function(){return UM.default}})});var q5=w((D5)=>{Object.defineProperty(D5,"__esModule",{value:!0});D5.formatNames=D5.fastFormats=D5.fullFormats=void 0;function h0(Q,Y){return{validate:Q,compare:Y}}D5.fullFormats={date:h0(U5,PY),time:h0(bY(!0),IY),"date-time":h0(J5(!0),B5),"iso-time":h0(bY(),A5),"iso-date-time":h0(J5(),K5),duration:/^P(?!$)((\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+S)?)?|(\d+W)?)$/,uri:OM,"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:jM,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:MM,int32:{type:"number",validate:NM},int64:{type:"number",validate:wM},float:{type:"number",validate:H5},double:{type:"number",validate:H5},password:!0,binary:!0};D5.fastFormats={...D5.fullFormats,date:h0(/^\d\d\d\d-[0-1]\d-[0-3]\d$/,PY),time:h0(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,IY),"date-time":h0(/^\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,B5),"iso-time":h0(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,A5),"iso-date-time":h0(/^\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,K5),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};D5.formatNames=Object.keys(D5.fullFormats);function KM(Q){return Q%4===0&&(Q%100!==0||Q%400===0)}var DM=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,LM=[0,31,28,31,30,31,30,31,31,30,31,30,31];function U5(Q){let Y=DM.exec(Q);if(!Y)return!1;let X=+Y[1],W=+Y[2],G=+Y[3];return W>=1&&W<=12&&G>=1&&G<=(W===2&&KM(X)?29:LM[W])}function PY(Q,Y){if(!(Q&&Y))return;if(Q>Y)return 1;if(Q<Y)return-1;return 0}var wY=/^(\d\d):(\d\d):(\d\d(?:\.\d+)?)(z|([+-])(\d\d)(?::?(\d\d))?)?$/i;function bY(Q){return function(X){let W=wY.exec(X);if(!W)return!1;let G=+W[1],$=+W[2],J=+W[3],z=W[4],H=W[5]==="-"?-1:1,U=+(W[6]||0),A=+(W[7]||0);if(U>23||A>59||Q&&!z)return!1;if(G<=23&&$<=59&&J<60)return!0;let B=$-A*H,K=G-U*H-(B<0?1:0);return(K===23||K===-1)&&(B===59||B===-1)&&J<61}}function IY(Q,Y){if(!(Q&&Y))return;let X=new Date("2020-01-01T"+Q).valueOf(),W=new Date("2020-01-01T"+Y).valueOf();if(!(X&&W))return;return X-W}function A5(Q,Y){if(!(Q&&Y))return;let X=wY.exec(Q),W=wY.exec(Y);if(!(X&&W))return;if(Q=X[1]+X[2]+X[3],Y=W[1]+W[2]+W[3],Q>Y)return 1;if(Q<Y)return-1;return 0}var jY=/t|\s/i;function J5(Q){let Y=bY(Q);return function(W){let G=W.split(jY);return G.length===2&&U5(G[0])&&Y(G[1])}}function B5(Q,Y){if(!(Q&&Y))return;let X=new Date(Q).valueOf(),W=new Date(Y).valueOf();if(!(X&&W))return;return X-W}function K5(Q,Y){if(!(Q&&Y))return;let[X,W]=Q.split(jY),[G,$]=Y.split(jY),J=PY(X,G);if(J===void 0)return;return J||IY(W,$)}var qM=/\/|:/,FM=/^(?:[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 OM(Q){return qM.test(Q)&&FM.test(Q)}var z5=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/gm;function MM(Q){return z5.lastIndex=0,z5.test(Q)}var VM=-2147483648,ZM=2147483647;function NM(Q){return Number.isInteger(Q)&&Q<=ZM&&Q>=VM}function wM(Q){return Number.isInteger(Q)}function H5(){return!0}var bM=/[^\\]\\Z/;function jM(Q){if(bM.test(Q))return!1;try{return new RegExp(Q),!0}catch(Y){return!1}}});var O5=w((F5)=>{Object.defineProperty(F5,"__esModule",{value:!0});F5.formatLimitDefinition=void 0;var IM=NY(),_0=v(),L1=_0.operators,KQ={formatMaximum:{okStr:"<=",ok:L1.LTE,fail:L1.GT},formatMinimum:{okStr:">=",ok:L1.GTE,fail:L1.LT},formatExclusiveMaximum:{okStr:"<",ok:L1.LT,fail:L1.GTE},formatExclusiveMinimum:{okStr:">",ok:L1.GT,fail:L1.LTE}},EM={message:({keyword:Q,schemaCode:Y})=>_0.str`should be ${KQ[Q].okStr} ${Y}`,params:({keyword:Q,schemaCode:Y})=>_0._`{comparison: ${KQ[Q].okStr}, limit: ${Y}}`};F5.formatLimitDefinition={keyword:Object.keys(KQ),type:"string",schemaType:"string",$data:!0,error:EM,code(Q){let{gen:Y,data:X,schemaCode:W,keyword:G,it:$}=Q,{opts:J,self:z}=$;if(!J.validateFormats)return;let H=new IM.KeywordCxt($,z.RULES.all.format.definition,"format");if(H.$data)U();else A();function U(){let K=Y.scopeValue("formats",{ref:z.formats,code:J.code.formats}),L=Y.const("fmt",_0._`${K}[${H.schemaCode}]`);Q.fail$data((0,_0.or)(_0._`typeof ${L} != "object"`,_0._`${L} instanceof RegExp`,_0._`typeof ${L}.compare != "function"`,B(L)))}function A(){let K=H.schema,L=z.formats[K];if(!L||L===!0)return;if(typeof L!="object"||L instanceof RegExp||typeof L.compare!="function")throw Error(`"${G}": format "${K}" does not define "compare" function`);let O=Y.scopeValue("formats",{key:K,ref:L,code:J.code.formats?_0._`${J.code.formats}${(0,_0.getProperty)(K)}`:void 0});Q.fail$data(B(O))}function B(K){return _0._`${K}.compare(${X}, ${W}) ${KQ[G].fail} 0`}},dependencies:["format"]};var TM=(Q)=>{return Q.addKeyword(F5.formatLimitDefinition),Q};F5.default=TM});var N5=w((l6,Z5)=>{Object.defineProperty(l6,"__esModule",{value:!0});var p1=q5(),RM=O5(),SY=v(),M5=new SY.Name("fullFormats"),CM=new SY.Name("fastFormats"),RY=(Q,Y={keywords:!0})=>{if(Array.isArray(Y))return V5(Q,Y,p1.fullFormats,M5),Q;let[X,W]=Y.mode==="fast"?[p1.fastFormats,CM]:[p1.fullFormats,M5],G=Y.formats||p1.formatNames;if(V5(Q,G,X,W),Y.keywords)(0,RM.default)(Q);return Q};RY.get=(Q,Y="full")=>{let W=(Y==="fast"?p1.fastFormats:p1.fullFormats)[Q];if(!W)throw Error(`Unknown format "${Q}"`);return W};function V5(Q,Y,X,W){var G,$;(G=($=Q.opts.code).formats)!==null&&G!==void 0||($.formats=SY._`require("ajv-formats/dist/formats").${W}`);for(let J of Y)Q.addFormat(J,X[J])}Z5.exports=l6=RY;Object.defineProperty(l6,"__esModule",{value:!0});l6.default=RY});import{AsyncLocalStorage as GH}from"node:async_hooks";class F1 extends Error{statusCode;rawDetails;code;context;constructor(Q,Y,X,W,G){super(Q);this.statusCode=Y;this.rawDetails=X;this.code=W;this.context=G;this.name="McpApiError"}}function XH(Q){if(Q instanceof F1)return{message:Q.message,statusCode:Q.statusCode,code:Q.code,rawDetails:Q.rawDetails,context:Q.context};if(Q instanceof Error)return{message:Q.message};return{message:String(Q)}}function WH(Q){let Y=XH(Q),X=Y.message.trim()||"Unknown error",W=X.toLowerCase(),G=Y.rawDetails?.trim()||X;if(Y.context?.title||Y.context?.description||Y.context?.howToFix||Y.context?.docsUrl)return{title:Y.context.title??(Y.statusCode===409?"Request conflict":"API request failed"),description:Y.context.description??X,howToFix:Y.context.howToFix??"Review the details below, adjust the tool input, and retry.",docsUrl:Y.context.docsUrl??"https://docs.sequenzy.com/concepts/mcp",details:G};if(Y.code==="MCP_AUTH_REQUIRED"||W.includes("sequenzy_api_key environment variable is required"))return{title:"Missing MCP API key",description:"The MCP server started without a Sequenzy API key, so it cannot authenticate any tool or resource request.",howToFix:"Add `SEQUENZY_API_KEY` to the MCP server environment, or run `npx @sequenzy/setup` to configure the integration automatically.",docsUrl:"https://docs.sequenzy.com/concepts/mcp",details:G};if(Y.statusCode===401||Y.code==="UNAUTHORIZED")return{title:"Authentication failed",description:"The MCP server reached Sequenzy, but the current API key was rejected.",howToFix:"Replace `SEQUENZY_API_KEY` with a valid personal API key, then restart the MCP client so it reconnects with fresh credentials.",docsUrl:"https://docs.sequenzy.com/authentication",details:G};if(Y.statusCode===403||W.includes("access denied"))return{title:"Access denied",description:"The current API key is valid, but it does not have permission to access the requested company or action.",howToFix:"Use an API key that belongs to the right account, or select a company the key can access before retrying the tool call.",docsUrl:"https://docs.sequenzy.com/authentication",details:G};if(W.includes("no company available")||W.includes("company not found"))return{title:"Company selection required",description:"The MCP server could not resolve a company for this request.",howToFix:"Call `get_account` to inspect available companies, then call `select_company`, or pass `companyId` explicitly in the next tool call.",docsUrl:"https://docs.sequenzy.com/concepts/mcp",details:G};if(Y.statusCode===404||W.includes("not found"))return{title:"Requested resource not found",description:"Sequenzy could not find the requested campaign, template, sequence, company, or subscriber.",howToFix:"List or fetch the resource collection first, then retry the tool with a confirmed ID or email value.",docsUrl:"https://docs.sequenzy.com/concepts/mcp",details:G};if(Y.statusCode===409||W.includes("already exists"))return{title:"Resource already exists",description:"Sequenzy rejected this MCP request because it would create a duplicate resource.",howToFix:"List the existing resources first, reuse the matching resource when appropriate, or retry with a unique name or domain.",docsUrl:"https://docs.sequenzy.com/concepts/mcp",details:G};if(Y.statusCode===429||W.includes("rate limit"))return{title:"Rate limited",description:"Sequenzy temporarily slowed this MCP request because too many requests were sent too quickly.",howToFix:"Wait briefly before retrying. If the client is looping, reduce retries or add backoff before the next tool call.",docsUrl:"https://docs.sequenzy.com/concepts/mcp",details:G};if(Y.code==="NETWORK_ERROR"||W.includes("fetch failed"))return{title:"Network or configuration error",description:"The MCP server could not reach the Sequenzy API from this environment.",howToFix:"Check connectivity and verify `SEQUENZY_API_URL` if you override it in the MCP environment.",docsUrl:"https://docs.sequenzy.com/concepts/mcp",details:G};if(W.includes("unknown tool")||W.includes("unknown resource"))return{title:"Unsupported MCP request",description:"The client asked for a tool or resource name that this Sequenzy MCP server does not expose.",howToFix:"Refresh the client's tool list and call only the names returned by `list_tools` or `list_resources`.",docsUrl:"https://docs.sequenzy.com/concepts/mcp",details:G};if(W.includes("is required")||W.includes("invalid"))return{title:"Invalid MCP input",description:"The tool call was missing a required field or included an invalid value.",howToFix:"Review the tool schema, supply the missing argument, and retry the request with corrected input.",docsUrl:"https://docs.sequenzy.com/concepts/mcp",details:G};if(Y.statusCode&&Y.statusCode>=500)return{title:"Sequenzy server error",description:"The request reached Sequenzy, but the server could not complete it successfully.",howToFix:"Retry once. If it still fails, keep the details below and consult the docs before escalating.",docsUrl:"https://docs.sequenzy.com/concepts/mcp",details:G};return{title:"Tool execution failed",description:"The MCP server could not complete the requested operation.",howToFix:"Review the details below, adjust the tool input or credentials, and retry.",docsUrl:"https://docs.sequenzy.com/concepts/mcp",details:G}}function e0(Q){let Y=WH(Q);return[`Sequenzy MCP error: ${Y.title}`,`Description: ${Y.description}`,`How to fix: ${Y.howToFix}`,`Docs: ${Y.docsUrl}`,`Details: ${Y.details}`].join(`
|
|
10
|
+
`)}var $H="https://api.sequenzy.com",r1=new GH,aY=!1;function sY(){aY=!0}function eY(){return aY}var QX=null;function Q1(){let Q=r1.getStore();if(Q)return Q.selectedCompanyId??null;return QX}function n6(Q){let Y=r1.getStore();if(Y){Y.selectedCompanyId=Q;return}QX=Q}function NQ(Q,Y){return r1.run(Q,Y)}function JH(){return r1.getStore()?.apiUrl??process.env.SEQUENZY_API_URL??$H}function YX(){return r1.getStore()?.apiKey??process.env.SEQUENZY_API_KEY}function XX(){if(YX())return;console.error(e0(new F1("SEQUENZY_API_KEY environment variable is required",401,void 0,"MCP_AUTH_REQUIRED"))),process.exit(1)}function Z0(Q,Y){let X=Q[Y];return typeof X==="string"&&X.trim()!==""?X.trim():void 0}function zH(Q){if(Q===void 0)return;if(typeof Q==="string")return Q.trim()||void 0;return JSON.stringify(Q)}function HH(Q){if(!Q.trim())return{message:"Request failed"};try{let Y=JSON.parse(Q);if(typeof Y==="string")return{message:Y};let X=typeof Y.error==="object"&&Y.error!==null?Y.error:void 0,W=Z0(Y,"code")??(X?Z0(X,"code"):void 0),G=(typeof Y.error==="string"?Y.error:void 0)??(X?Z0(X,"message"):void 0)??Z0(Y,"message")??Z0(Y,"error")??Q,$=Z0(Y,"howToFix")??Z0(Y,"resolution"),J={...Z0(Y,"title")?{title:Z0(Y,"title")}:{},...Z0(Y,"description")?{description:Z0(Y,"description")}:{},...$?{howToFix:$}:{},...Z0(Y,"docsUrl")?{docsUrl:Z0(Y,"docsUrl")}:{}},z=zH(Y.details);if(Object.keys(J).length>0||z)return{message:G,...W?{code:W}:{},...z?{details:z}:{},...Object.keys(J).length>0?{context:J}:{}};if(typeof Y.error==="string")return{message:Y.error,...W?{code:W}:{}};if(X)return{message:G,...W?{code:W}:{}};return{message:G,...W?{code:W}:{}}}catch{return{message:Q}}}async function F(Q,Y,X,W){let G=YX();if(!G)throw new F1("SEQUENZY_API_KEY environment variable is required",401,void 0,"MCP_AUTH_REQUIRED");let $={"Content-Type":"application/json",Authorization:`Bearer ${G}`},J=W??Q1();if(J)$["x-company-id"]=J;let z;try{z=await fetch(`${JH()}${Y}`,{method:Q,headers:$,body:X?JSON.stringify(X):void 0})}catch(H){throw new F1(H instanceof Error?H.message:"Failed to reach Sequenzy API",0,void 0,"NETWORK_ERROR")}if(!z.ok){let H=await z.text(),U=HH(H);throw new F1(U.message,z.status,U.details??H,U.code,U.context)}return z.json()}var wV=Object.freeze({status:"aborted"});function q(Q,Y,X){function W(z,H){var U;Object.defineProperty(z,"_zod",{value:z._zod??{},enumerable:!1}),(U=z._zod).traits??(U.traits=new Set),z._zod.traits.add(Q),Y(z,H);for(let A in J.prototype)if(!(A in z))Object.defineProperty(z,A,{value:J.prototype[A].bind(z)});z._zod.constr=J,z._zod.def=H}let G=X?.Parent??Object;class $ extends G{}Object.defineProperty($,"name",{value:Q});function J(z){var H;let U=X?.Parent?new $:this;W(U,z),(H=U._zod).deferred??(H.deferred=[]);for(let A of U._zod.deferred)A();return U}return Object.defineProperty(J,"init",{value:W}),Object.defineProperty(J,Symbol.hasInstance,{value:(z)=>{if(X?.Parent&&z instanceof X.Parent)return!0;return z?._zod?.traits?.has(Q)}}),Object.defineProperty(J,"name",{value:Q}),J}var bV=Symbol("zod_brand");class m0 extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class d1 extends Error{constructor(Q){super(`Encountered unidirectional transform during encode: ${Q}`);this.name="ZodEncodeError"}}var r6={};function b0(Q){if(Q)Object.assign(r6,Q);return r6}var f={};tY(f,{unwrapMessage:()=>o1,uint8ArrayToHex:()=>vH,uint8ArrayToBase64url:()=>CH,uint8ArrayToBase64:()=>UX,stringifyPrimitive:()=>a6,shallowClone:()=>GX,safeExtend:()=>PH,required:()=>TH,randomString:()=>MH,propertyKeyTypes:()=>IQ,promiseAllObject:()=>OH,primitiveTypes:()=>$X,prefixIssues:()=>p0,pick:()=>wH,partial:()=>EH,optionalKeys:()=>EQ,omit:()=>bH,objectClone:()=>LH,numKeys:()=>VH,nullish:()=>t1,normalizeParams:()=>I,mergeDefs:()=>X1,merge:()=>IH,jsonStringifyReplacer:()=>I1,joinValues:()=>d6,issue:()=>T1,isPlainObject:()=>W1,isObject:()=>O1,hexToUint8Array:()=>kH,getSizableOrigin:()=>zX,getParsedType:()=>ZH,getLengthableOrigin:()=>s1,getEnumValues:()=>bQ,getElementAtPath:()=>FH,floatSafeRemainder:()=>jQ,finalizeIssue:()=>S0,extend:()=>jH,escapeRegex:()=>c0,esc:()=>o6,defineLazy:()=>c,createTransparentProxy:()=>NH,cloneDef:()=>qH,clone:()=>T0,cleanRegex:()=>a1,cleanEnum:()=>SH,captureStackTrace:()=>t6,cached:()=>E1,base64urlToUint8Array:()=>RH,base64ToUint8Array:()=>HX,assignProp:()=>Y1,assertNotEqual:()=>AH,assertNever:()=>KH,assertIs:()=>BH,assertEqual:()=>UH,assert:()=>DH,allowsEval:()=>PQ,aborted:()=>G1,NUMBER_FORMAT_RANGES:()=>TQ,Class:()=>AX,BIGINT_FORMAT_RANGES:()=>JX});function UH(Q){return Q}function AH(Q){return Q}function BH(Q){}function KH(Q){throw Error()}function DH(Q){}function bQ(Q){let Y=Object.values(Q).filter((W)=>typeof W==="number");return Object.entries(Q).filter(([W,G])=>Y.indexOf(+W)===-1).map(([W,G])=>G)}function d6(Q,Y="|"){return Q.map((X)=>a6(X)).join(Y)}function I1(Q,Y){if(typeof Y==="bigint")return Y.toString();return Y}function E1(Q){return{get value(){{let X=Q();return Object.defineProperty(this,"value",{value:X}),X}throw Error("cached value already set")}}}function t1(Q){return Q===null||Q===void 0}function a1(Q){let Y=Q.startsWith("^")?1:0,X=Q.endsWith("$")?Q.length-1:Q.length;return Q.slice(Y,X)}function jQ(Q,Y){let X=(Q.toString().split(".")[1]||"").length,W=Y.toString(),G=(W.split(".")[1]||"").length;if(G===0&&/\d?e-\d?/.test(W)){let H=W.match(/\d?e-(\d?)/);if(H?.[1])G=Number.parseInt(H[1])}let $=X>G?X:G,J=Number.parseInt(Q.toFixed($).replace(".","")),z=Number.parseInt(Y.toFixed($).replace(".",""));return J%z/10**$}var WX=Symbol("evaluating");function c(Q,Y,X){let W=void 0;Object.defineProperty(Q,Y,{get(){if(W===WX)return;if(W===void 0)W=WX,W=X();return W},set(G){Object.defineProperty(Q,Y,{value:G})},configurable:!0})}function LH(Q){return Object.create(Object.getPrototypeOf(Q),Object.getOwnPropertyDescriptors(Q))}function Y1(Q,Y,X){Object.defineProperty(Q,Y,{value:X,writable:!0,enumerable:!0,configurable:!0})}function X1(...Q){let Y={};for(let X of Q){let W=Object.getOwnPropertyDescriptors(X);Object.assign(Y,W)}return Object.defineProperties({},Y)}function qH(Q){return X1(Q._zod.def)}function FH(Q,Y){if(!Y)return Q;return Y.reduce((X,W)=>X?.[W],Q)}function OH(Q){let Y=Object.keys(Q),X=Y.map((W)=>Q[W]);return Promise.all(X).then((W)=>{let G={};for(let $=0;$<Y.length;$++)G[Y[$]]=W[$];return G})}function MH(Q=10){let X="";for(let W=0;W<Q;W++)X+="abcdefghijklmnopqrstuvwxyz"[Math.floor(Math.random()*26)];return X}function o6(Q){return JSON.stringify(Q)}var t6="captureStackTrace"in Error?Error.captureStackTrace:(...Q)=>{};function O1(Q){return typeof Q==="object"&&Q!==null&&!Array.isArray(Q)}var PQ=E1(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{return new Function(""),!0}catch(Q){return!1}});function W1(Q){if(O1(Q)===!1)return!1;let Y=Q.constructor;if(Y===void 0)return!0;let X=Y.prototype;if(O1(X)===!1)return!1;if(Object.prototype.hasOwnProperty.call(X,"isPrototypeOf")===!1)return!1;return!0}function GX(Q){if(W1(Q))return{...Q};if(Array.isArray(Q))return[...Q];return Q}function VH(Q){let Y=0;for(let X in Q)if(Object.prototype.hasOwnProperty.call(Q,X))Y++;return Y}var ZH=(Q)=>{let Y=typeof Q;switch(Y){case"undefined":return"undefined";case"string":return"string";case"number":return Number.isNaN(Q)?"nan":"number";case"boolean":return"boolean";case"function":return"function";case"bigint":return"bigint";case"symbol":return"symbol";case"object":if(Array.isArray(Q))return"array";if(Q===null)return"null";if(Q.then&&typeof Q.then==="function"&&Q.catch&&typeof Q.catch==="function")return"promise";if(typeof Map<"u"&&Q instanceof Map)return"map";if(typeof Set<"u"&&Q instanceof Set)return"set";if(typeof Date<"u"&&Q instanceof Date)return"date";if(typeof File<"u"&&Q instanceof File)return"file";return"object";default:throw Error(`Unknown data type: ${Y}`)}},IQ=new Set(["string","number","symbol"]),$X=new Set(["string","number","bigint","boolean","symbol","undefined"]);function c0(Q){return Q.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function T0(Q,Y,X){let W=new Q._zod.constr(Y??Q._zod.def);if(!Y||X?.parent)W._zod.parent=Q;return W}function I(Q){let Y=Q;if(!Y)return{};if(typeof Y==="string")return{error:()=>Y};if(Y?.message!==void 0){if(Y?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");Y.error=Y.message}if(delete Y.message,typeof Y.error==="string")return{...Y,error:()=>Y.error};return Y}function NH(Q){let Y;return new Proxy({},{get(X,W,G){return Y??(Y=Q()),Reflect.get(Y,W,G)},set(X,W,G,$){return Y??(Y=Q()),Reflect.set(Y,W,G,$)},has(X,W){return Y??(Y=Q()),Reflect.has(Y,W)},deleteProperty(X,W){return Y??(Y=Q()),Reflect.deleteProperty(Y,W)},ownKeys(X){return Y??(Y=Q()),Reflect.ownKeys(Y)},getOwnPropertyDescriptor(X,W){return Y??(Y=Q()),Reflect.getOwnPropertyDescriptor(Y,W)},defineProperty(X,W,G){return Y??(Y=Q()),Reflect.defineProperty(Y,W,G)}})}function a6(Q){if(typeof Q==="bigint")return Q.toString()+"n";if(typeof Q==="string")return`"${Q}"`;return`${Q}`}function EQ(Q){return Object.keys(Q).filter((Y)=>{return Q[Y]._zod.optin==="optional"&&Q[Y]._zod.optout==="optional"})}var TQ={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-340282346638528860000000000000000000000,340282346638528860000000000000000000000],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},JX={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function wH(Q,Y){let X=Q._zod.def,W=X1(Q._zod.def,{get shape(){let G={};for(let $ in Y){if(!($ in X.shape))throw Error(`Unrecognized key: "${$}"`);if(!Y[$])continue;G[$]=X.shape[$]}return Y1(this,"shape",G),G},checks:[]});return T0(Q,W)}function bH(Q,Y){let X=Q._zod.def,W=X1(Q._zod.def,{get shape(){let G={...Q._zod.def.shape};for(let $ in Y){if(!($ in X.shape))throw Error(`Unrecognized key: "${$}"`);if(!Y[$])continue;delete G[$]}return Y1(this,"shape",G),G},checks:[]});return T0(Q,W)}function jH(Q,Y){if(!W1(Y))throw Error("Invalid input to extend: expected a plain object");let X=Q._zod.def.checks;if(X&&X.length>0)throw Error("Object schemas containing refinements cannot be extended. Use `.safeExtend()` instead.");let G=X1(Q._zod.def,{get shape(){let $={...Q._zod.def.shape,...Y};return Y1(this,"shape",$),$},checks:[]});return T0(Q,G)}function PH(Q,Y){if(!W1(Y))throw Error("Invalid input to safeExtend: expected a plain object");let X={...Q._zod.def,get shape(){let W={...Q._zod.def.shape,...Y};return Y1(this,"shape",W),W},checks:Q._zod.def.checks};return T0(Q,X)}function IH(Q,Y){let X=X1(Q._zod.def,{get shape(){let W={...Q._zod.def.shape,...Y._zod.def.shape};return Y1(this,"shape",W),W},get catchall(){return Y._zod.def.catchall},checks:[]});return T0(Q,X)}function EH(Q,Y,X){let W=X1(Y._zod.def,{get shape(){let G=Y._zod.def.shape,$={...G};if(X)for(let J in X){if(!(J in G))throw Error(`Unrecognized key: "${J}"`);if(!X[J])continue;$[J]=Q?new Q({type:"optional",innerType:G[J]}):G[J]}else for(let J in G)$[J]=Q?new Q({type:"optional",innerType:G[J]}):G[J];return Y1(this,"shape",$),$},checks:[]});return T0(Y,W)}function TH(Q,Y,X){let W=X1(Y._zod.def,{get shape(){let G=Y._zod.def.shape,$={...G};if(X)for(let J in X){if(!(J in $))throw Error(`Unrecognized key: "${J}"`);if(!X[J])continue;$[J]=new Q({type:"nonoptional",innerType:G[J]})}else for(let J in G)$[J]=new Q({type:"nonoptional",innerType:G[J]});return Y1(this,"shape",$),$},checks:[]});return T0(Y,W)}function G1(Q,Y=0){if(Q.aborted===!0)return!0;for(let X=Y;X<Q.issues.length;X++)if(Q.issues[X]?.continue!==!0)return!0;return!1}function p0(Q,Y){return Y.map((X)=>{var W;return(W=X).path??(W.path=[]),X.path.unshift(Q),X})}function o1(Q){return typeof Q==="string"?Q:Q?.message}function S0(Q,Y,X){let W={...Q,path:Q.path??[]};if(!Q.message){let G=o1(Q.inst?._zod.def?.error?.(Q))??o1(Y?.error?.(Q))??o1(X.customError?.(Q))??o1(X.localeError?.(Q))??"Invalid input";W.message=G}if(delete W.inst,delete W.continue,!Y?.reportInput)delete W.input;return W}function zX(Q){if(Q instanceof Set)return"set";if(Q instanceof Map)return"map";if(Q instanceof File)return"file";return"unknown"}function s1(Q){if(Array.isArray(Q))return"array";if(typeof Q==="string")return"string";return"unknown"}function T1(...Q){let[Y,X,W]=Q;if(typeof Y==="string")return{message:Y,code:"custom",input:X,inst:W};return{...Y}}function SH(Q){return Object.entries(Q).filter(([Y,X])=>{return Number.isNaN(Number.parseInt(Y,10))}).map((Y)=>Y[1])}function HX(Q){let Y=atob(Q),X=new Uint8Array(Y.length);for(let W=0;W<Y.length;W++)X[W]=Y.charCodeAt(W);return X}function UX(Q){let Y="";for(let X=0;X<Q.length;X++)Y+=String.fromCharCode(Q[X]);return btoa(Y)}function RH(Q){let Y=Q.replace(/-/g,"+").replace(/_/g,"/"),X="=".repeat((4-Y.length%4)%4);return HX(Y+X)}function CH(Q){return UX(Q).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function kH(Q){let Y=Q.replace(/^0x/,"");if(Y.length%2!==0)throw Error("Invalid hex string length");let X=new Uint8Array(Y.length/2);for(let W=0;W<Y.length;W+=2)X[W/2]=Number.parseInt(Y.slice(W,W+2),16);return X}function vH(Q){return Array.from(Q).map((Y)=>Y.toString(16).padStart(2,"0")).join("")}class AX{constructor(...Q){}}var BX=(Q,Y)=>{Q.name="$ZodError",Object.defineProperty(Q,"_zod",{value:Q._zod,enumerable:!1}),Object.defineProperty(Q,"issues",{value:Y,enumerable:!1}),Q.message=JSON.stringify(Y,I1,2),Object.defineProperty(Q,"toString",{value:()=>Q.message,enumerable:!1})},s6=q("$ZodError",BX),SQ=q("$ZodError",BX,{Parent:Error});function KX(Q,Y=(X)=>X.message){let X={},W=[];for(let G of Q.issues)if(G.path.length>0)X[G.path[0]]=X[G.path[0]]||[],X[G.path[0]].push(Y(G));else W.push(Y(G));return{formErrors:W,fieldErrors:X}}function DX(Q,Y=(X)=>X.message){let X={_errors:[]},W=(G)=>{for(let $ of G.issues)if($.code==="invalid_union"&&$.errors.length)$.errors.map((J)=>W({issues:J}));else if($.code==="invalid_key")W({issues:$.issues});else if($.code==="invalid_element")W({issues:$.issues});else if($.path.length===0)X._errors.push(Y($));else{let J=X,z=0;while(z<$.path.length){let H=$.path[z];if(z!==$.path.length-1)J[H]=J[H]||{_errors:[]};else J[H]=J[H]||{_errors:[]},J[H]._errors.push(Y($));J=J[H],z++}}};return W(Q),X}var e6=(Q)=>(Y,X,W,G)=>{let $=W?Object.assign(W,{async:!1}):{async:!1},J=Y._zod.run({value:X,issues:[]},$);if(J instanceof Promise)throw new m0;if(J.issues.length){let z=new(G?.Err??Q)(J.issues.map((H)=>S0(H,$,b0())));throw t6(z,G?.callee),z}return J.value};var Q4=(Q)=>async(Y,X,W,G)=>{let $=W?Object.assign(W,{async:!0}):{async:!0},J=Y._zod.run({value:X,issues:[]},$);if(J instanceof Promise)J=await J;if(J.issues.length){let z=new(G?.Err??Q)(J.issues.map((H)=>S0(H,$,b0())));throw t6(z,G?.callee),z}return J.value};var e1=(Q)=>(Y,X,W)=>{let G=W?{...W,async:!1}:{async:!1},$=Y._zod.run({value:X,issues:[]},G);if($ instanceof Promise)throw new m0;return $.issues.length?{success:!1,error:new(Q??s6)($.issues.map((J)=>S0(J,G,b0())))}:{success:!0,data:$.value}},Q6=e1(SQ),Y6=(Q)=>async(Y,X,W)=>{let G=W?Object.assign(W,{async:!0}):{async:!0},$=Y._zod.run({value:X,issues:[]},G);if($ instanceof Promise)$=await $;return $.issues.length?{success:!1,error:new Q($.issues.map((J)=>S0(J,G,b0())))}:{success:!0,data:$.value}},Y4=Y6(SQ),LX=(Q)=>(Y,X,W)=>{let G=W?Object.assign(W,{direction:"backward"}):{direction:"backward"};return e6(Q)(Y,X,G)};var qX=(Q)=>(Y,X,W)=>{return e6(Q)(Y,X,W)};var FX=(Q)=>async(Y,X,W)=>{let G=W?Object.assign(W,{direction:"backward"}):{direction:"backward"};return Q4(Q)(Y,X,G)};var OX=(Q)=>async(Y,X,W)=>{return Q4(Q)(Y,X,W)};var MX=(Q)=>(Y,X,W)=>{let G=W?Object.assign(W,{direction:"backward"}):{direction:"backward"};return e1(Q)(Y,X,G)};var VX=(Q)=>(Y,X,W)=>{return e1(Q)(Y,X,W)};var ZX=(Q)=>async(Y,X,W)=>{let G=W?Object.assign(W,{direction:"backward"}):{direction:"backward"};return Y6(Q)(Y,X,G)};var NX=(Q)=>async(Y,X,W)=>{return Y6(Q)(Y,X,W)};var wX=/^[cC][^\s-]{8,}$/,bX=/^[0-9a-z]+$/,jX=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,PX=/^[0-9a-vA-V]{20}$/,IX=/^[A-Za-z0-9]{27}$/,EX=/^[a-zA-Z0-9_-]{21}$/,TX=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;var SX=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,RQ=(Q)=>{if(!Q)return/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/;return new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${Q}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`)};var RX=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;function CX(){return new RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")}var kX=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,vX=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,xX=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,_X=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,yX=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,CQ=/^[A-Za-z0-9_-]*$/,gX=/^(?=.{1,253}\.?$)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[-0-9a-zA-Z]{0,61}[0-9a-zA-Z])?)*\.?$/;var uX=/^\+(?:[0-9]){6,14}[0-9]$/,hX="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",fX=new RegExp(`^${hX}$`);function lX(Q){return typeof Q.precision==="number"?Q.precision===-1?"(?:[01]\\d|2[0-3]):[0-5]\\d":Q.precision===0?"(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d":`(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d\\.\\d{${Q.precision}}`:"(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?"}function mX(Q){return new RegExp(`^${lX(Q)}$`)}function cX(Q){let Y=lX({precision:Q.precision}),X=["Z"];if(Q.local)X.push("");if(Q.offset)X.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");let W=`${Y}(?:${X.join("|")})`;return new RegExp(`^${hX}T(?:${W})$`)}var pX=(Q)=>{let Y=Q?`[\\s\\S]{${Q?.minimum??0},${Q?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${Y}$`)};var iX=/^-?\d+$/,nX=/^-?\d+(?:\.\d+)?/,rX=/^(?:true|false)$/i,dX=/^null$/i;var oX=/^[^A-Z]*$/,tX=/^[^a-z]*$/;var G0=q("$ZodCheck",(Q,Y)=>{var X;Q._zod??(Q._zod={}),Q._zod.def=Y,(X=Q._zod).onattach??(X.onattach=[])}),aX={number:"number",bigint:"bigint",object:"date"},kQ=q("$ZodCheckLessThan",(Q,Y)=>{G0.init(Q,Y);let X=aX[typeof Y.value];Q._zod.onattach.push((W)=>{let G=W._zod.bag,$=(Y.inclusive?G.maximum:G.exclusiveMaximum)??Number.POSITIVE_INFINITY;if(Y.value<$)if(Y.inclusive)G.maximum=Y.value;else G.exclusiveMaximum=Y.value}),Q._zod.check=(W)=>{if(Y.inclusive?W.value<=Y.value:W.value<Y.value)return;W.issues.push({origin:X,code:"too_big",maximum:Y.value,input:W.value,inclusive:Y.inclusive,inst:Q,continue:!Y.abort})}}),vQ=q("$ZodCheckGreaterThan",(Q,Y)=>{G0.init(Q,Y);let X=aX[typeof Y.value];Q._zod.onattach.push((W)=>{let G=W._zod.bag,$=(Y.inclusive?G.minimum:G.exclusiveMinimum)??Number.NEGATIVE_INFINITY;if(Y.value>$)if(Y.inclusive)G.minimum=Y.value;else G.exclusiveMinimum=Y.value}),Q._zod.check=(W)=>{if(Y.inclusive?W.value>=Y.value:W.value>Y.value)return;W.issues.push({origin:X,code:"too_small",minimum:Y.value,input:W.value,inclusive:Y.inclusive,inst:Q,continue:!Y.abort})}}),sX=q("$ZodCheckMultipleOf",(Q,Y)=>{G0.init(Q,Y),Q._zod.onattach.push((X)=>{var W;(W=X._zod.bag).multipleOf??(W.multipleOf=Y.value)}),Q._zod.check=(X)=>{if(typeof X.value!==typeof Y.value)throw Error("Cannot mix number and bigint in multiple_of check.");if(typeof X.value==="bigint"?X.value%Y.value===BigInt(0):jQ(X.value,Y.value)===0)return;X.issues.push({origin:typeof X.value,code:"not_multiple_of",divisor:Y.value,input:X.value,inst:Q,continue:!Y.abort})}}),eX=q("$ZodCheckNumberFormat",(Q,Y)=>{G0.init(Q,Y),Y.format=Y.format||"float64";let X=Y.format?.includes("int"),W=X?"int":"number",[G,$]=TQ[Y.format];Q._zod.onattach.push((J)=>{let z=J._zod.bag;if(z.format=Y.format,z.minimum=G,z.maximum=$,X)z.pattern=iX}),Q._zod.check=(J)=>{let z=J.value;if(X){if(!Number.isInteger(z)){J.issues.push({expected:W,format:Y.format,code:"invalid_type",continue:!1,input:z,inst:Q});return}if(!Number.isSafeInteger(z)){if(z>0)J.issues.push({input:z,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:Q,origin:W,continue:!Y.abort});else J.issues.push({input:z,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:Q,origin:W,continue:!Y.abort});return}}if(z<G)J.issues.push({origin:"number",input:z,code:"too_small",minimum:G,inclusive:!0,inst:Q,continue:!Y.abort});if(z>$)J.issues.push({origin:"number",input:z,code:"too_big",maximum:$,inst:Q})}});var Q8=q("$ZodCheckMaxLength",(Q,Y)=>{var X;G0.init(Q,Y),(X=Q._zod.def).when??(X.when=(W)=>{let G=W.value;return!t1(G)&&G.length!==void 0}),Q._zod.onattach.push((W)=>{let G=W._zod.bag.maximum??Number.POSITIVE_INFINITY;if(Y.maximum<G)W._zod.bag.maximum=Y.maximum}),Q._zod.check=(W)=>{let G=W.value;if(G.length<=Y.maximum)return;let J=s1(G);W.issues.push({origin:J,code:"too_big",maximum:Y.maximum,inclusive:!0,input:G,inst:Q,continue:!Y.abort})}}),Y8=q("$ZodCheckMinLength",(Q,Y)=>{var X;G0.init(Q,Y),(X=Q._zod.def).when??(X.when=(W)=>{let G=W.value;return!t1(G)&&G.length!==void 0}),Q._zod.onattach.push((W)=>{let G=W._zod.bag.minimum??Number.NEGATIVE_INFINITY;if(Y.minimum>G)W._zod.bag.minimum=Y.minimum}),Q._zod.check=(W)=>{let G=W.value;if(G.length>=Y.minimum)return;let J=s1(G);W.issues.push({origin:J,code:"too_small",minimum:Y.minimum,inclusive:!0,input:G,inst:Q,continue:!Y.abort})}}),X8=q("$ZodCheckLengthEquals",(Q,Y)=>{var X;G0.init(Q,Y),(X=Q._zod.def).when??(X.when=(W)=>{let G=W.value;return!t1(G)&&G.length!==void 0}),Q._zod.onattach.push((W)=>{let G=W._zod.bag;G.minimum=Y.length,G.maximum=Y.length,G.length=Y.length}),Q._zod.check=(W)=>{let G=W.value,$=G.length;if($===Y.length)return;let J=s1(G),z=$>Y.length;W.issues.push({origin:J,...z?{code:"too_big",maximum:Y.length}:{code:"too_small",minimum:Y.length},inclusive:!0,exact:!0,input:W.value,inst:Q,continue:!Y.abort})}}),X6=q("$ZodCheckStringFormat",(Q,Y)=>{var X,W;if(G0.init(Q,Y),Q._zod.onattach.push((G)=>{let $=G._zod.bag;if($.format=Y.format,Y.pattern)$.patterns??($.patterns=new Set),$.patterns.add(Y.pattern)}),Y.pattern)(X=Q._zod).check??(X.check=(G)=>{if(Y.pattern.lastIndex=0,Y.pattern.test(G.value))return;G.issues.push({origin:"string",code:"invalid_format",format:Y.format,input:G.value,...Y.pattern?{pattern:Y.pattern.toString()}:{},inst:Q,continue:!Y.abort})});else(W=Q._zod).check??(W.check=()=>{})}),W8=q("$ZodCheckRegex",(Q,Y)=>{X6.init(Q,Y),Q._zod.check=(X)=>{if(Y.pattern.lastIndex=0,Y.pattern.test(X.value))return;X.issues.push({origin:"string",code:"invalid_format",format:"regex",input:X.value,pattern:Y.pattern.toString(),inst:Q,continue:!Y.abort})}}),G8=q("$ZodCheckLowerCase",(Q,Y)=>{Y.pattern??(Y.pattern=oX),X6.init(Q,Y)}),$8=q("$ZodCheckUpperCase",(Q,Y)=>{Y.pattern??(Y.pattern=tX),X6.init(Q,Y)}),J8=q("$ZodCheckIncludes",(Q,Y)=>{G0.init(Q,Y);let X=c0(Y.includes),W=new RegExp(typeof Y.position==="number"?`^.{${Y.position}}${X}`:X);Y.pattern=W,Q._zod.onattach.push((G)=>{let $=G._zod.bag;$.patterns??($.patterns=new Set),$.patterns.add(W)}),Q._zod.check=(G)=>{if(G.value.includes(Y.includes,Y.position))return;G.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:Y.includes,input:G.value,inst:Q,continue:!Y.abort})}}),z8=q("$ZodCheckStartsWith",(Q,Y)=>{G0.init(Q,Y);let X=new RegExp(`^${c0(Y.prefix)}.*`);Y.pattern??(Y.pattern=X),Q._zod.onattach.push((W)=>{let G=W._zod.bag;G.patterns??(G.patterns=new Set),G.patterns.add(X)}),Q._zod.check=(W)=>{if(W.value.startsWith(Y.prefix))return;W.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:Y.prefix,input:W.value,inst:Q,continue:!Y.abort})}}),H8=q("$ZodCheckEndsWith",(Q,Y)=>{G0.init(Q,Y);let X=new RegExp(`.*${c0(Y.suffix)}$`);Y.pattern??(Y.pattern=X),Q._zod.onattach.push((W)=>{let G=W._zod.bag;G.patterns??(G.patterns=new Set),G.patterns.add(X)}),Q._zod.check=(W)=>{if(W.value.endsWith(Y.suffix))return;W.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:Y.suffix,input:W.value,inst:Q,continue:!Y.abort})}});var U8=q("$ZodCheckOverwrite",(Q,Y)=>{G0.init(Q,Y),Q._zod.check=(X)=>{X.value=Y.tx(X.value)}});class xQ{constructor(Q=[]){if(this.content=[],this.indent=0,this)this.args=Q}indented(Q){this.indent+=1,Q(this),this.indent-=1}write(Q){if(typeof Q==="function"){Q(this,{execution:"sync"}),Q(this,{execution:"async"});return}let X=Q.split(`
|
|
11
11
|
`).filter(($)=>$),W=Math.min(...X.map(($)=>$.length-$.trimStart().length)),G=X.map(($)=>$.slice(W)).map(($)=>" ".repeat(this.indent*2)+$);for(let $ of G)this.content.push($)}compile(){let Q=Function,Y=this?.args,W=[...(this?.content??[""]).map((G)=>` ${G}`)];return new Q(...Y,W.join(`
|
|
12
|
-
`))}}var B8={major:4,minor:1,patch:12};var n=q("$ZodType",(Q,Y)=>{var X;Q??(Q={}),Q._zod.def=Y,Q._zod.bag=Q._zod.bag||{},Q._zod.version=B8;let W=[...Q._zod.def.checks??[]];if(Q._zod.traits.has("$ZodCheck"))W.unshift(Q);for(let G of W)for(let $ of G._zod.onattach)$(Q);if(W.length===0)(X=Q._zod).deferred??(X.deferred=[]),Q._zod.deferred?.push(()=>{Q._zod.run=Q._zod.parse});else{let G=(J,z,H)=>{let U=G1(J),A;for(let B of z){if(B._zod.def.when){if(!B._zod.def.when(J))continue}else if(U)continue;let K=J.issues.length,L=B._zod.check(J);if(L instanceof Promise&&H?.async===!1)throw new m0;if(A||L instanceof Promise)A=(A??Promise.resolve()).then(async()=>{if(await L,J.issues.length===K)return;if(!U)U=G1(J,K)});else{if(J.issues.length===K)continue;if(!U)U=G1(J,K)}}if(A)return A.then(()=>{return J});return J},$=(J,z,H)=>{if(G1(J))return J.aborted=!0,J;let U=G(z,W,H);if(U instanceof Promise){if(H.async===!1)throw new m0;return U.then((A)=>Q._zod.parse(A,H))}return Q._zod.parse(U,H)};Q._zod.run=(J,z)=>{if(z.skipChecks)return Q._zod.parse(J,z);if(z.direction==="backward"){let U=Q._zod.parse({value:J.value,issues:[]},{...z,skipChecks:!0});if(U instanceof Promise)return U.then((A)=>{return $(A,J,z)});return $(U,J,z)}let H=Q._zod.parse(J,z);if(H instanceof Promise){if(z.async===!1)throw new m0;return H.then((U)=>G(U,W,z))}return G(H,W,z)}}Q["~standard"]={validate:(G)=>{try{let $=
|
|
12
|
+
`))}}var B8={major:4,minor:1,patch:12};var n=q("$ZodType",(Q,Y)=>{var X;Q??(Q={}),Q._zod.def=Y,Q._zod.bag=Q._zod.bag||{},Q._zod.version=B8;let W=[...Q._zod.def.checks??[]];if(Q._zod.traits.has("$ZodCheck"))W.unshift(Q);for(let G of W)for(let $ of G._zod.onattach)$(Q);if(W.length===0)(X=Q._zod).deferred??(X.deferred=[]),Q._zod.deferred?.push(()=>{Q._zod.run=Q._zod.parse});else{let G=(J,z,H)=>{let U=G1(J),A;for(let B of z){if(B._zod.def.when){if(!B._zod.def.when(J))continue}else if(U)continue;let K=J.issues.length,L=B._zod.check(J);if(L instanceof Promise&&H?.async===!1)throw new m0;if(A||L instanceof Promise)A=(A??Promise.resolve()).then(async()=>{if(await L,J.issues.length===K)return;if(!U)U=G1(J,K)});else{if(J.issues.length===K)continue;if(!U)U=G1(J,K)}}if(A)return A.then(()=>{return J});return J},$=(J,z,H)=>{if(G1(J))return J.aborted=!0,J;let U=G(z,W,H);if(U instanceof Promise){if(H.async===!1)throw new m0;return U.then((A)=>Q._zod.parse(A,H))}return Q._zod.parse(U,H)};Q._zod.run=(J,z)=>{if(z.skipChecks)return Q._zod.parse(J,z);if(z.direction==="backward"){let U=Q._zod.parse({value:J.value,issues:[]},{...z,skipChecks:!0});if(U instanceof Promise)return U.then((A)=>{return $(A,J,z)});return $(U,J,z)}let H=Q._zod.parse(J,z);if(H instanceof Promise){if(z.async===!1)throw new m0;return H.then((U)=>G(U,W,z))}return G(H,W,z)}}Q["~standard"]={validate:(G)=>{try{let $=Q6(Q,G);return $.success?{value:$.data}:{issues:$.error?.issues}}catch($){return Y4(Q,G).then((J)=>J.success?{value:J.data}:{issues:J.error?.issues})}},vendor:"zod",version:1}}),$4=q("$ZodString",(Q,Y)=>{n.init(Q,Y),Q._zod.pattern=[...Q?._zod.bag?.patterns??[]].pop()??pX(Q._zod.bag),Q._zod.parse=(X,W)=>{if(Y.coerce)try{X.value=String(X.value)}catch(G){}if(typeof X.value==="string")return X;return X.issues.push({expected:"string",code:"invalid_type",input:X.value,inst:Q}),X}}),r=q("$ZodStringFormat",(Q,Y)=>{X6.init(Q,Y),$4.init(Q,Y)}),Z8=q("$ZodGUID",(Q,Y)=>{Y.pattern??(Y.pattern=SX),r.init(Q,Y)}),N8=q("$ZodUUID",(Q,Y)=>{if(Y.version){let W={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[Y.version];if(W===void 0)throw Error(`Invalid UUID version: "${Y.version}"`);Y.pattern??(Y.pattern=RQ(W))}else Y.pattern??(Y.pattern=RQ());r.init(Q,Y)}),w8=q("$ZodEmail",(Q,Y)=>{Y.pattern??(Y.pattern=RX),r.init(Q,Y)}),b8=q("$ZodURL",(Q,Y)=>{r.init(Q,Y),Q._zod.check=(X)=>{try{let W=X.value.trim(),G=new URL(W);if(Y.hostname){if(Y.hostname.lastIndex=0,!Y.hostname.test(G.hostname))X.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:gX.source,input:X.value,inst:Q,continue:!Y.abort})}if(Y.protocol){if(Y.protocol.lastIndex=0,!Y.protocol.test(G.protocol.endsWith(":")?G.protocol.slice(0,-1):G.protocol))X.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:Y.protocol.source,input:X.value,inst:Q,continue:!Y.abort})}if(Y.normalize)X.value=G.href;else X.value=W;return}catch(W){X.issues.push({code:"invalid_format",format:"url",input:X.value,inst:Q,continue:!Y.abort})}}}),j8=q("$ZodEmoji",(Q,Y)=>{Y.pattern??(Y.pattern=CX()),r.init(Q,Y)}),P8=q("$ZodNanoID",(Q,Y)=>{Y.pattern??(Y.pattern=EX),r.init(Q,Y)}),I8=q("$ZodCUID",(Q,Y)=>{Y.pattern??(Y.pattern=wX),r.init(Q,Y)}),E8=q("$ZodCUID2",(Q,Y)=>{Y.pattern??(Y.pattern=bX),r.init(Q,Y)}),T8=q("$ZodULID",(Q,Y)=>{Y.pattern??(Y.pattern=jX),r.init(Q,Y)}),S8=q("$ZodXID",(Q,Y)=>{Y.pattern??(Y.pattern=PX),r.init(Q,Y)}),R8=q("$ZodKSUID",(Q,Y)=>{Y.pattern??(Y.pattern=IX),r.init(Q,Y)}),C8=q("$ZodISODateTime",(Q,Y)=>{Y.pattern??(Y.pattern=cX(Y)),r.init(Q,Y)}),k8=q("$ZodISODate",(Q,Y)=>{Y.pattern??(Y.pattern=fX),r.init(Q,Y)}),v8=q("$ZodISOTime",(Q,Y)=>{Y.pattern??(Y.pattern=mX(Y)),r.init(Q,Y)}),x8=q("$ZodISODuration",(Q,Y)=>{Y.pattern??(Y.pattern=TX),r.init(Q,Y)}),_8=q("$ZodIPv4",(Q,Y)=>{Y.pattern??(Y.pattern=kX),r.init(Q,Y),Q._zod.onattach.push((X)=>{let W=X._zod.bag;W.format="ipv4"})}),y8=q("$ZodIPv6",(Q,Y)=>{Y.pattern??(Y.pattern=vX),r.init(Q,Y),Q._zod.onattach.push((X)=>{let W=X._zod.bag;W.format="ipv6"}),Q._zod.check=(X)=>{try{new URL(`http://[${X.value}]`)}catch{X.issues.push({code:"invalid_format",format:"ipv6",input:X.value,inst:Q,continue:!Y.abort})}}}),g8=q("$ZodCIDRv4",(Q,Y)=>{Y.pattern??(Y.pattern=xX),r.init(Q,Y)}),u8=q("$ZodCIDRv6",(Q,Y)=>{Y.pattern??(Y.pattern=_X),r.init(Q,Y),Q._zod.check=(X)=>{let W=X.value.split("/");try{if(W.length!==2)throw Error();let[G,$]=W;if(!$)throw Error();let J=Number($);if(`${J}`!==$)throw Error();if(J<0||J>128)throw Error();new URL(`http://[${G}]`)}catch{X.issues.push({code:"invalid_format",format:"cidrv6",input:X.value,inst:Q,continue:!Y.abort})}}});function h8(Q){if(Q==="")return!0;if(Q.length%4!==0)return!1;try{return atob(Q),!0}catch{return!1}}var f8=q("$ZodBase64",(Q,Y)=>{Y.pattern??(Y.pattern=yX),r.init(Q,Y),Q._zod.onattach.push((X)=>{X._zod.bag.contentEncoding="base64"}),Q._zod.check=(X)=>{if(h8(X.value))return;X.issues.push({code:"invalid_format",format:"base64",input:X.value,inst:Q,continue:!Y.abort})}});function gH(Q){if(!CQ.test(Q))return!1;let Y=Q.replace(/[-_]/g,(W)=>W==="-"?"+":"/"),X=Y.padEnd(Math.ceil(Y.length/4)*4,"=");return h8(X)}var l8=q("$ZodBase64URL",(Q,Y)=>{Y.pattern??(Y.pattern=CQ),r.init(Q,Y),Q._zod.onattach.push((X)=>{X._zod.bag.contentEncoding="base64url"}),Q._zod.check=(X)=>{if(gH(X.value))return;X.issues.push({code:"invalid_format",format:"base64url",input:X.value,inst:Q,continue:!Y.abort})}}),m8=q("$ZodE164",(Q,Y)=>{Y.pattern??(Y.pattern=uX),r.init(Q,Y)});function uH(Q,Y=null){try{let X=Q.split(".");if(X.length!==3)return!1;let[W]=X;if(!W)return!1;let G=JSON.parse(atob(W));if("typ"in G&&G?.typ!=="JWT")return!1;if(!G.alg)return!1;if(Y&&(!("alg"in G)||G.alg!==Y))return!1;return!0}catch{return!1}}var c8=q("$ZodJWT",(Q,Y)=>{r.init(Q,Y),Q._zod.check=(X)=>{if(uH(X.value,Y.alg))return;X.issues.push({code:"invalid_format",format:"jwt",input:X.value,inst:Q,continue:!Y.abort})}});var yQ=q("$ZodNumber",(Q,Y)=>{n.init(Q,Y),Q._zod.pattern=Q._zod.bag.pattern??nX,Q._zod.parse=(X,W)=>{if(Y.coerce)try{X.value=Number(X.value)}catch(J){}let G=X.value;if(typeof G==="number"&&!Number.isNaN(G)&&Number.isFinite(G))return X;let $=typeof G==="number"?Number.isNaN(G)?"NaN":!Number.isFinite(G)?"Infinity":void 0:void 0;return X.issues.push({expected:"number",code:"invalid_type",input:G,inst:Q,...$?{received:$}:{}}),X}}),p8=q("$ZodNumber",(Q,Y)=>{eX.init(Q,Y),yQ.init(Q,Y)}),i8=q("$ZodBoolean",(Q,Y)=>{n.init(Q,Y),Q._zod.pattern=rX,Q._zod.parse=(X,W)=>{if(Y.coerce)try{X.value=Boolean(X.value)}catch($){}let G=X.value;if(typeof G==="boolean")return X;return X.issues.push({expected:"boolean",code:"invalid_type",input:G,inst:Q}),X}});var n8=q("$ZodNull",(Q,Y)=>{n.init(Q,Y),Q._zod.pattern=dX,Q._zod.values=new Set([null]),Q._zod.parse=(X,W)=>{let G=X.value;if(G===null)return X;return X.issues.push({expected:"null",code:"invalid_type",input:G,inst:Q}),X}});var r8=q("$ZodUnknown",(Q,Y)=>{n.init(Q,Y),Q._zod.parse=(X)=>X}),d8=q("$ZodNever",(Q,Y)=>{n.init(Q,Y),Q._zod.parse=(X,W)=>{return X.issues.push({expected:"never",code:"invalid_type",input:X.value,inst:Q}),X}});function K8(Q,Y,X){if(Q.issues.length)Y.issues.push(...p0(X,Q.issues));Y.value[X]=Q.value}var o8=q("$ZodArray",(Q,Y)=>{n.init(Q,Y),Q._zod.parse=(X,W)=>{let G=X.value;if(!Array.isArray(G))return X.issues.push({expected:"array",code:"invalid_type",input:G,inst:Q}),X;X.value=Array(G.length);let $=[];for(let J=0;J<G.length;J++){let z=G[J],H=Y.element._zod.run({value:z,issues:[]},W);if(H instanceof Promise)$.push(H.then((U)=>K8(U,X,J)));else K8(H,X,J)}if($.length)return Promise.all($).then(()=>X);return X}});function G4(Q,Y,X,W){if(Q.issues.length)Y.issues.push(...p0(X,Q.issues));if(Q.value===void 0){if(X in W)Y.value[X]=void 0}else Y.value[X]=Q.value}function t8(Q){let Y=Object.keys(Q.shape);for(let W of Y)if(!Q.shape?.[W]?._zod?.traits?.has("$ZodType"))throw Error(`Invalid element at key "${W}": expected a Zod schema`);let X=EQ(Q.shape);return{...Q,keys:Y,keySet:new Set(Y),numKeys:Y.length,optionalKeys:new Set(X)}}function a8(Q,Y,X,W,G,$){let J=[],z=G.keySet,H=G.catchall._zod,U=H.def.type;for(let A of Object.keys(Y)){if(z.has(A))continue;if(U==="never"){J.push(A);continue}let B=H.run({value:Y[A],issues:[]},W);if(B instanceof Promise)Q.push(B.then((K)=>G4(K,X,A,Y)));else G4(B,X,A,Y)}if(J.length)X.issues.push({code:"unrecognized_keys",keys:J,input:Y,inst:$});if(!Q.length)return X;return Promise.all(Q).then(()=>{return X})}var hH=q("$ZodObject",(Q,Y)=>{if(n.init(Q,Y),!Object.getOwnPropertyDescriptor(Y,"shape")?.get){let z=Y.shape;Object.defineProperty(Y,"shape",{get:()=>{let H={...z};return Object.defineProperty(Y,"shape",{value:H}),H}})}let W=E1(()=>t8(Y));c(Q._zod,"propValues",()=>{let z=Y.shape,H={};for(let U in z){let A=z[U]._zod;if(A.values){H[U]??(H[U]=new Set);for(let B of A.values)H[U].add(B)}}return H});let G=O1,$=Y.catchall,J;Q._zod.parse=(z,H)=>{J??(J=W.value);let U=z.value;if(!G(U))return z.issues.push({expected:"object",code:"invalid_type",input:U,inst:Q}),z;z.value={};let A=[],B=J.shape;for(let K of J.keys){let O=B[K]._zod.run({value:U[K],issues:[]},H);if(O instanceof Promise)A.push(O.then((M)=>G4(M,z,K,U)));else G4(O,z,K,U)}if(!$)return A.length?Promise.all(A).then(()=>z):z;return a8(A,U,z,H,W.value,Q)}}),s8=q("$ZodObjectJIT",(Q,Y)=>{hH.init(Q,Y);let X=Q._zod.parse,W=E1(()=>t8(Y)),G=(K)=>{let L=new xQ(["shape","payload","ctx"]),O=W.value,M=(E)=>{let _=o6(E);return`shape[${_}]._zod.run({ value: input[${_}], issues: [] }, ctx)`};L.write("const input = payload.value;");let Z=Object.create(null),V=0;for(let E of O.keys)Z[E]=`key_${V++}`;L.write("const newResult = {};");for(let E of O.keys){let _=Z[E],T=o6(E);L.write(`const ${_} = ${M(E)};`),L.write(`
|
|
13
13
|
if (${_}.issues.length) {
|
|
14
14
|
payload.issues = payload.issues.concat(${_}.issues.map(iss => ({
|
|
15
15
|
...iss,
|
|
@@ -26,7 +26,7 @@ var r5=Object.create;var{getPrototypeOf:d5,defineProperty:ZQ,getOwnPropertyNames
|
|
|
26
26
|
newResult[${T}] = ${_}.value;
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
`)}L.write("payload.value = newResult;"),L.write("return payload;");let S=L.compile();return(E,_)=>S(K,E,_)},$,J=O1,z=!r4.jitless,U=z&&PQ.value,A=Y.catchall,B;Q._zod.parse=(K,L)=>{B??(B=W.value);let O=K.value;if(!J(O))return K.issues.push({expected:"object",code:"invalid_type",input:O,inst:Q}),K;if(z&&U&&L?.async===!1&&L.jitless!==!0){if(!$)$=G(Y.shape);if(K=$(K,L),!A)return K;return a8([],O,K,L,B,Q)}return X(K,L)}});function D8(Q,Y,X,W){for(let $ of Q)if($.issues.length===0)return Y.value=$.value,Y;let G=Q.filter(($)=>!G1($));if(G.length===1)return Y.value=G[0].value,G[0];return Y.issues.push({code:"invalid_union",input:Y.value,inst:X,errors:Q.map(($)=>$.issues.map((J)=>S0(J,W,b0())))}),Y}var gQ=q("$ZodUnion",(Q,Y)=>{n.init(Q,Y),c(Q._zod,"optin",()=>Y.options.some((G)=>G._zod.optin==="optional")?"optional":void 0),c(Q._zod,"optout",()=>Y.options.some((G)=>G._zod.optout==="optional")?"optional":void 0),c(Q._zod,"values",()=>{if(Y.options.every((G)=>G._zod.values))return new Set(Y.options.flatMap((G)=>Array.from(G._zod.values)));return}),c(Q._zod,"pattern",()=>{if(Y.options.every((G)=>G._zod.pattern)){let G=Y.options.map(($)=>$._zod.pattern);return new RegExp(`^(${G.map(($)=>a1($.source)).join("|")})$`)}return});let X=Y.options.length===1,W=Y.options[0]._zod.run;Q._zod.parse=(G,$)=>{if(X)return W(G,$);let J=!1,z=[];for(let H of Y.options){let U=H._zod.run({value:G.value,issues:[]},$);if(U instanceof Promise)z.push(U),J=!0;else{if(U.issues.length===0)return U;z.push(U)}}if(!J)return D8(z,G,Q,$);return Promise.all(z).then((H)=>{return D8(H,G,Q,$)})}}),e8=q("$ZodDiscriminatedUnion",(Q,Y)=>{gQ.init(Q,Y);let X=Q._zod.parse;c(Q._zod,"propValues",()=>{let G={};for(let $ of Y.options){let J=$._zod.propValues;if(!J||Object.keys(J).length===0)throw Error(`Invalid discriminated union option at index "${Y.options.indexOf($)}"`);for(let[z,H]of Object.entries(J)){if(!G[z])G[z]=new Set;for(let U of H)G[z].add(U)}}return G});let W=E1(()=>{let G=Y.options,$=new Map;for(let J of G){let z=J._zod.propValues?.[Y.discriminator];if(!z||z.size===0)throw Error(`Invalid discriminated union option at index "${Y.options.indexOf(J)}"`);for(let H of z){if($.has(H))throw Error(`Duplicate discriminator value "${String(H)}"`);$.set(H,J)}}return $});Q._zod.parse=(G,$)=>{let J=G.value;if(!O1(J))return G.issues.push({code:"invalid_type",expected:"object",input:J,inst:Q}),G;let z=W.value.get(J?.[Y.discriminator]);if(z)return z._zod.run(G,$);if(Y.unionFallback)return X(G,$);return G.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:Y.discriminator,input:J,path:[Y.discriminator],inst:Q}),G}}),QW=q("$ZodIntersection",(Q,Y)=>{n.init(Q,Y),Q._zod.parse=(X,W)=>{let G=X.value,$=Y.left._zod.run({value:G,issues:[]},W),J=Y.right._zod.run({value:G,issues:[]},W);if($ instanceof Promise||J instanceof Promise)return Promise.all([$,J]).then(([H,U])=>{return L8(X,H,U)});return L8(X,$,J)}});function _Q(Q,Y){if(Q===Y)return{valid:!0,data:Q};if(Q instanceof Date&&Y instanceof Date&&+Q===+Y)return{valid:!0,data:Q};if(W1(Q)&&W1(Y)){let X=Object.keys(Y),W=Object.keys(Q).filter(($)=>X.indexOf($)!==-1),G={...Q,...Y};for(let $ of W){let J=_Q(Q[$],Y[$]);if(!J.valid)return{valid:!1,mergeErrorPath:[$,...J.mergeErrorPath]};G[$]=J.data}return{valid:!0,data:G}}if(Array.isArray(Q)&&Array.isArray(Y)){if(Q.length!==Y.length)return{valid:!1,mergeErrorPath:[]};let X=[];for(let W=0;W<Q.length;W++){let G=Q[W],$=Y[W],J=_Q(G,$);if(!J.valid)return{valid:!1,mergeErrorPath:[W,...J.mergeErrorPath]};X.push(J.data)}return{valid:!0,data:X}}return{valid:!1,mergeErrorPath:[]}}function L8(Q,Y,X){if(Y.issues.length)Q.issues.push(...Y.issues);if(X.issues.length)Q.issues.push(...X.issues);if(G1(Q))return Q;let W=_Q(Y.value,X.value);if(!W.valid)throw Error(`Unmergable intersection. Error path: ${JSON.stringify(W.mergeErrorPath)}`);return Q.value=W.data,Q}var YW=q("$ZodRecord",(Q,Y)=>{n.init(Q,Y),Q._zod.parse=(X,W)=>{let G=X.value;if(!W1(G))return X.issues.push({expected:"record",code:"invalid_type",input:G,inst:Q}),X;let $=[];if(Y.keyType._zod.values){let J=Y.keyType._zod.values;X.value={};for(let H of J)if(typeof H==="string"||typeof H==="number"||typeof H==="symbol"){let U=Y.valueType._zod.run({value:G[H],issues:[]},W);if(U instanceof Promise)$.push(U.then((A)=>{if(A.issues.length)X.issues.push(...p0(H,A.issues));X.value[H]=A.value}));else{if(U.issues.length)X.issues.push(...p0(H,U.issues));X.value[H]=U.value}}let z;for(let H in G)if(!J.has(H))z=z??[],z.push(H);if(z&&z.length>0)X.issues.push({code:"unrecognized_keys",input:G,inst:Q,keys:z})}else{X.value={};for(let J of Reflect.ownKeys(G)){if(J==="__proto__")continue;let z=Y.keyType._zod.run({value:J,issues:[]},W);if(z instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(z.issues.length){X.issues.push({code:"invalid_key",origin:"record",issues:z.issues.map((U)=>S0(U,W,b0())),input:J,path:[J],inst:Q}),X.value[z.value]=z.value;continue}let H=Y.valueType._zod.run({value:G[J],issues:[]},W);if(H instanceof Promise)$.push(H.then((U)=>{if(U.issues.length)X.issues.push(...p0(J,U.issues));X.value[z.value]=U.value}));else{if(H.issues.length)X.issues.push(...p0(J,H.issues));X.value[z.value]=H.value}}}if($.length)return Promise.all($).then(()=>X);return X}});var XW=q("$ZodEnum",(Q,Y)=>{n.init(Q,Y);let X=bQ(Y.entries),W=new Set(X);Q._zod.values=W,Q._zod.pattern=new RegExp(`^(${X.filter((G)=>IQ.has(typeof G)).map((G)=>typeof G==="string"?c0(G):G.toString()).join("|")})$`),Q._zod.parse=(G,$)=>{let J=G.value;if(W.has(J))return G;return G.issues.push({code:"invalid_value",values:X,input:J,inst:Q}),G}}),WW=q("$ZodLiteral",(Q,Y)=>{if(n.init(Q,Y),Y.values.length===0)throw Error("Cannot create literal schema with no valid values");Q._zod.values=new Set(Y.values),Q._zod.pattern=new RegExp(`^(${Y.values.map((X)=>typeof X==="string"?c0(X):X?c0(X.toString()):String(X)).join("|")})$`),Q._zod.parse=(X,W)=>{let G=X.value;if(Q._zod.values.has(G))return X;return X.issues.push({code:"invalid_value",values:Y.values,input:G,inst:Q}),X}});var GW=q("$ZodTransform",(Q,Y)=>{n.init(Q,Y),Q._zod.parse=(X,W)=>{if(W.direction==="backward")throw new d1(Q.constructor.name);let G=Y.transform(X.value,X);if(W.async)return(G instanceof Promise?G:Promise.resolve(G)).then((J)=>{return X.value=J,X});if(G instanceof Promise)throw new m0;return X.value=G,X}});function q8(Q,Y){if(Q.issues.length&&Y===void 0)return{issues:[],value:void 0};return Q}var $W=q("$ZodOptional",(Q,Y)=>{n.init(Q,Y),Q._zod.optin="optional",Q._zod.optout="optional",c(Q._zod,"values",()=>{return Y.innerType._zod.values?new Set([...Y.innerType._zod.values,void 0]):void 0}),c(Q._zod,"pattern",()=>{let X=Y.innerType._zod.pattern;return X?new RegExp(`^(${a1(X.source)})?$`):void 0}),Q._zod.parse=(X,W)=>{if(Y.innerType._zod.optin==="optional"){let G=Y.innerType._zod.run(X,W);if(G instanceof Promise)return G.then(($)=>q8($,X.value));return q8(G,X.value)}if(X.value===void 0)return X;return Y.innerType._zod.run(X,W)}}),JW=q("$ZodNullable",(Q,Y)=>{n.init(Q,Y),c(Q._zod,"optin",()=>Y.innerType._zod.optin),c(Q._zod,"optout",()=>Y.innerType._zod.optout),c(Q._zod,"pattern",()=>{let X=Y.innerType._zod.pattern;return X?new RegExp(`^(${a1(X.source)}|null)$`):void 0}),c(Q._zod,"values",()=>{return Y.innerType._zod.values?new Set([...Y.innerType._zod.values,null]):void 0}),Q._zod.parse=(X,W)=>{if(X.value===null)return X;return Y.innerType._zod.run(X,W)}}),zW=q("$ZodDefault",(Q,Y)=>{n.init(Q,Y),Q._zod.optin="optional",c(Q._zod,"values",()=>Y.innerType._zod.values),Q._zod.parse=(X,W)=>{if(W.direction==="backward")return Y.innerType._zod.run(X,W);if(X.value===void 0)return X.value=Y.defaultValue,X;let G=Y.innerType._zod.run(X,W);if(G instanceof Promise)return G.then(($)=>F8($,Y));return F8(G,Y)}});function F8(Q,Y){if(Q.value===void 0)Q.value=Y.defaultValue;return Q}var HW=q("$ZodPrefault",(Q,Y)=>{n.init(Q,Y),Q._zod.optin="optional",c(Q._zod,"values",()=>Y.innerType._zod.values),Q._zod.parse=(X,W)=>{if(W.direction==="backward")return Y.innerType._zod.run(X,W);if(X.value===void 0)X.value=Y.defaultValue;return Y.innerType._zod.run(X,W)}}),UW=q("$ZodNonOptional",(Q,Y)=>{n.init(Q,Y),c(Q._zod,"values",()=>{let X=Y.innerType._zod.values;return X?new Set([...X].filter((W)=>W!==void 0)):void 0}),Q._zod.parse=(X,W)=>{let G=Y.innerType._zod.run(X,W);if(G instanceof Promise)return G.then(($)=>O8($,Q));return O8(G,Q)}});function O8(Q,Y){if(!Q.issues.length&&Q.value===void 0)Q.issues.push({code:"invalid_type",expected:"nonoptional",input:Q.value,inst:Y});return Q}var AW=q("$ZodCatch",(Q,Y)=>{n.init(Q,Y),c(Q._zod,"optin",()=>Y.innerType._zod.optin),c(Q._zod,"optout",()=>Y.innerType._zod.optout),c(Q._zod,"values",()=>Y.innerType._zod.values),Q._zod.parse=(X,W)=>{if(W.direction==="backward")return Y.innerType._zod.run(X,W);let G=Y.innerType._zod.run(X,W);if(G instanceof Promise)return G.then(($)=>{if(X.value=$.value,$.issues.length)X.value=Y.catchValue({...X,error:{issues:$.issues.map((J)=>S0(J,W,b0()))},input:X.value}),X.issues=[];return X});if(X.value=G.value,G.issues.length)X.value=Y.catchValue({...X,error:{issues:G.issues.map(($)=>S0($,W,b0()))},input:X.value}),X.issues=[];return X}});var BW=q("$ZodPipe",(Q,Y)=>{n.init(Q,Y),c(Q._zod,"values",()=>Y.in._zod.values),c(Q._zod,"optin",()=>Y.in._zod.optin),c(Q._zod,"optout",()=>Y.out._zod.optout),c(Q._zod,"propValues",()=>Y.in._zod.propValues),Q._zod.parse=(X,W)=>{if(W.direction==="backward"){let $=Y.out._zod.run(X,W);if($ instanceof Promise)return $.then((J)=>W6(J,Y.in,W));return W6($,Y.in,W)}let G=Y.in._zod.run(X,W);if(G instanceof Promise)return G.then(($)=>W6($,Y.out,W));return W6(G,Y.out,W)}});function W6(Q,Y,X){if(Q.issues.length)return Q.aborted=!0,Q;return Y._zod.run({value:Q.value,issues:Q.issues},X)}var KW=q("$ZodReadonly",(Q,Y)=>{n.init(Q,Y),c(Q._zod,"propValues",()=>Y.innerType._zod.propValues),c(Q._zod,"values",()=>Y.innerType._zod.values),c(Q._zod,"optin",()=>Y.innerType._zod.optin),c(Q._zod,"optout",()=>Y.innerType._zod.optout),Q._zod.parse=(X,W)=>{if(W.direction==="backward")return Y.innerType._zod.run(X,W);let G=Y.innerType._zod.run(X,W);if(G instanceof Promise)return G.then(M8);return M8(G)}});function M8(Q){return Q.value=Object.freeze(Q.value),Q}var DW=q("$ZodCustom",(Q,Y)=>{G0.init(Q,Y),n.init(Q,Y),Q._zod.parse=(X,W)=>{return X},Q._zod.check=(X)=>{let W=X.value,G=Y.fn(W);if(G instanceof Promise)return G.then(($)=>V8($,X,W,Q));V8(G,X,W,Q);return}});function V8(Q,Y,X,W){if(!Q){let G={code:"custom",input:X,inst:W,path:[...W._zod.def.path??[]],continue:!W._zod.def.abort};if(W._zod.def.params)G.params=W._zod.def.params;Y.issues.push(T1(G))}}var fH=(Q)=>{let Y=typeof Q;switch(Y){case"number":return Number.isNaN(Q)?"NaN":"number";case"object":{if(Array.isArray(Q))return"array";if(Q===null)return"null";if(Object.getPrototypeOf(Q)!==Object.prototype&&Q.constructor)return Q.constructor.name}}return Y},lH=()=>{let Q={string:{unit:"characters",verb:"to have"},file:{unit:"bytes",verb:"to have"},array:{unit:"items",verb:"to have"},set:{unit:"items",verb:"to have"}};function Y(W){return Q[W]??null}let X={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",jwt:"JWT",template_literal:"input"};return(W)=>{switch(W.code){case"invalid_type":return`Invalid input: expected ${W.expected}, received ${fH(W.input)}`;case"invalid_value":if(W.values.length===1)return`Invalid input: expected ${a4(W.values[0])}`;return`Invalid option: expected one of ${d4(W.values,"|")}`;case"too_big":{let G=W.inclusive?"<=":"<",$=Y(W.origin);if($)return`Too big: expected ${W.origin??"value"} to have ${G}${W.maximum.toString()} ${$.unit??"elements"}`;return`Too big: expected ${W.origin??"value"} to be ${G}${W.maximum.toString()}`}case"too_small":{let G=W.inclusive?">=":">",$=Y(W.origin);if($)return`Too small: expected ${W.origin} to have ${G}${W.minimum.toString()} ${$.unit}`;return`Too small: expected ${W.origin} to be ${G}${W.minimum.toString()}`}case"invalid_format":{let G=W;if(G.format==="starts_with")return`Invalid string: must start with "${G.prefix}"`;if(G.format==="ends_with")return`Invalid string: must end with "${G.suffix}"`;if(G.format==="includes")return`Invalid string: must include "${G.includes}"`;if(G.format==="regex")return`Invalid string: must match pattern ${G.pattern}`;return`Invalid ${X[G.format]??W.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${W.divisor}`;case"unrecognized_keys":return`Unrecognized key${W.keys.length>1?"s":""}: ${d4(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 uQ(){return{localeError:lH()}}var _V=Symbol("ZodOutput"),yV=Symbol("ZodInput");class LW{constructor(){this._map=new WeakMap,this._idmap=new Map}add(Q,...Y){let X=Y[0];if(this._map.set(Q,X),X&&typeof X==="object"&&"id"in X){if(this._idmap.has(X.id))throw Error(`ID ${X.id} already exists in the registry`);this._idmap.set(X.id,Q)}return this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(Q){let Y=this._map.get(Q);if(Y&&typeof Y==="object"&&"id"in Y)this._idmap.delete(Y.id);return this._map.delete(Q),this}get(Q){let Y=Q._zod.parent;if(Y){let X={...this.get(Y)??{}};delete X.id;let W={...X,...this._map.get(Q)};return Object.keys(W).length?W:void 0}return this._map.get(Q)}has(Q){return this._map.has(Q)}}function mH(){return new LW}var W4=mH();function qW(Q,Y){return new Q({type:"string",...I(Y)})}function FW(Q,Y){return new Q({type:"string",format:"email",check:"string_format",abort:!1,...I(Y)})}function hQ(Q,Y){return new Q({type:"string",format:"guid",check:"string_format",abort:!1,...I(Y)})}function OW(Q,Y){return new Q({type:"string",format:"uuid",check:"string_format",abort:!1,...I(Y)})}function MW(Q,Y){return new Q({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...I(Y)})}function VW(Q,Y){return new Q({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...I(Y)})}function ZW(Q,Y){return new Q({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...I(Y)})}function NW(Q,Y){return new Q({type:"string",format:"url",check:"string_format",abort:!1,...I(Y)})}function wW(Q,Y){return new Q({type:"string",format:"emoji",check:"string_format",abort:!1,...I(Y)})}function bW(Q,Y){return new Q({type:"string",format:"nanoid",check:"string_format",abort:!1,...I(Y)})}function jW(Q,Y){return new Q({type:"string",format:"cuid",check:"string_format",abort:!1,...I(Y)})}function PW(Q,Y){return new Q({type:"string",format:"cuid2",check:"string_format",abort:!1,...I(Y)})}function IW(Q,Y){return new Q({type:"string",format:"ulid",check:"string_format",abort:!1,...I(Y)})}function EW(Q,Y){return new Q({type:"string",format:"xid",check:"string_format",abort:!1,...I(Y)})}function TW(Q,Y){return new Q({type:"string",format:"ksuid",check:"string_format",abort:!1,...I(Y)})}function SW(Q,Y){return new Q({type:"string",format:"ipv4",check:"string_format",abort:!1,...I(Y)})}function RW(Q,Y){return new Q({type:"string",format:"ipv6",check:"string_format",abort:!1,...I(Y)})}function CW(Q,Y){return new Q({type:"string",format:"cidrv4",check:"string_format",abort:!1,...I(Y)})}function kW(Q,Y){return new Q({type:"string",format:"cidrv6",check:"string_format",abort:!1,...I(Y)})}function vW(Q,Y){return new Q({type:"string",format:"base64",check:"string_format",abort:!1,...I(Y)})}function xW(Q,Y){return new Q({type:"string",format:"base64url",check:"string_format",abort:!1,...I(Y)})}function _W(Q,Y){return new Q({type:"string",format:"e164",check:"string_format",abort:!1,...I(Y)})}function yW(Q,Y){return new Q({type:"string",format:"jwt",check:"string_format",abort:!1,...I(Y)})}function gW(Q,Y){return new Q({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...I(Y)})}function uW(Q,Y){return new Q({type:"string",format:"date",check:"string_format",...I(Y)})}function hW(Q,Y){return new Q({type:"string",format:"time",check:"string_format",precision:null,...I(Y)})}function fW(Q,Y){return new Q({type:"string",format:"duration",check:"string_format",...I(Y)})}function lW(Q,Y){return new Q({type:"number",checks:[],...I(Y)})}function mW(Q,Y){return new Q({type:"number",check:"number_format",abort:!1,format:"safeint",...I(Y)})}function cW(Q,Y){return new Q({type:"boolean",...I(Y)})}function pW(Q,Y){return new Q({type:"null",...I(Y)})}function iW(Q){return new Q({type:"unknown"})}function nW(Q,Y){return new Q({type:"never",...I(Y)})}function J6(Q,Y){return new kQ({check:"less_than",...I(Y),value:Q,inclusive:!1})}function G4(Q,Y){return new kQ({check:"less_than",...I(Y),value:Q,inclusive:!0})}function z6(Q,Y){return new vQ({check:"greater_than",...I(Y),value:Q,inclusive:!1})}function $4(Q,Y){return new vQ({check:"greater_than",...I(Y),value:Q,inclusive:!0})}function H6(Q,Y){return new sX({check:"multiple_of",...I(Y),value:Q})}function U6(Q,Y){return new Q8({check:"max_length",...I(Y),maximum:Q})}function S1(Q,Y){return new Y8({check:"min_length",...I(Y),minimum:Q})}function A6(Q,Y){return new X8({check:"length_equals",...I(Y),length:Q})}function fQ(Q,Y){return new W8({check:"string_format",format:"regex",...I(Y),pattern:Q})}function lQ(Q){return new G8({check:"string_format",format:"lowercase",...I(Q)})}function mQ(Q){return new $8({check:"string_format",format:"uppercase",...I(Q)})}function cQ(Q,Y){return new J8({check:"string_format",format:"includes",...I(Y),includes:Q})}function pQ(Q,Y){return new z8({check:"string_format",format:"starts_with",...I(Y),prefix:Q})}function iQ(Q,Y){return new H8({check:"string_format",format:"ends_with",...I(Y),suffix:Q})}function M1(Q){return new U8({check:"overwrite",tx:Q})}function nQ(Q){return M1((Y)=>Y.normalize(Q))}function rQ(){return M1((Q)=>Q.trim())}function dQ(){return M1((Q)=>Q.toLowerCase())}function oQ(){return M1((Q)=>Q.toUpperCase())}function rW(Q,Y,X){return new Q({type:"array",element:Y,...I(X)})}function dW(Q,Y,X){let W=I(X);return W.abort??(W.abort=!0),new Q({type:"custom",check:"custom",fn:Y,...W})}function oW(Q,Y,X){return new Q({type:"custom",check:"custom",fn:Y,...I(X)})}function tW(Q){let Y=cH((X)=>{return X.addIssue=(W)=>{if(typeof W==="string")X.issues.push(T1(W,X.value,Y._zod.def));else{let G=W;if(G.fatal)G.continue=!1;G.code??(G.code="custom"),G.input??(G.input=X.value),G.inst??(G.inst=Y),G.continue??(G.continue=!Y._zod.def.abort),X.issues.push(T1(G))}},Q(X.value,X)});return Y}function cH(Q,Y){let X=new G0({check:"custom",...I(Y)});return X._zod.check=Q,X}function R1(Q){return!!Q._zod}function $1(Q,Y){if(R1(Q))return Q4(Q,Y);return Q.safeParse(Y)}function B6(Q){if(!Q)return;let Y;if(R1(Q))Y=Q._zod?.def?.shape;else Y=Q.shape;if(!Y)return;if(typeof Y==="function")try{return Y()}catch{return}return Y}function aW(Q){if(R1(Q)){let $=Q._zod?.def;if($){if($.value!==void 0)return $.value;if(Array.isArray($.values)&&$.values.length>0)return $.values[0]}}let X=Q._def;if(X){if(X.value!==void 0)return X.value;if(Array.isArray(X.values)&&X.values.length>0)return X.values[0]}let W=Q.value;if(W!==void 0)return W;return}var z4={};tY(z4,{time:()=>sQ,duration:()=>eQ,datetime:()=>tQ,date:()=>aQ,ZodISOTime:()=>QG,ZodISODuration:()=>YG,ZodISODateTime:()=>sW,ZodISODate:()=>eW});var sW=q("ZodISODateTime",(Q,Y)=>{C8.init(Q,Y),o.init(Q,Y)});function tQ(Q){return gW(sW,Q)}var eW=q("ZodISODate",(Q,Y)=>{k8.init(Q,Y),o.init(Q,Y)});function aQ(Q){return uW(eW,Q)}var QG=q("ZodISOTime",(Q,Y)=>{v8.init(Q,Y),o.init(Q,Y)});function sQ(Q){return hW(QG,Q)}var YG=q("ZodISODuration",(Q,Y)=>{x8.init(Q,Y),o.init(Q,Y)});function eQ(Q){return fW(YG,Q)}var XG=(Q,Y)=>{s4.init(Q,Y),Q.name="ZodError",Object.defineProperties(Q,{format:{value:(X)=>DX(Q,X)},flatten:{value:(X)=>KX(Q,X)},addIssue:{value:(X)=>{Q.issues.push(X),Q.message=JSON.stringify(Q.issues,I1,2)}},addIssues:{value:(X)=>{Q.issues.push(...X),Q.message=JSON.stringify(Q.issues,I1,2)}},isEmpty:{get(){return Q.issues.length===0}}})},NZ=q("ZodError",XG),N0=q("ZodError",XG,{Parent:Error});var WG=e4(N0),GG=Q6(N0),$G=e1(N0),JG=Y4(N0),zG=LX(N0),HG=qX(N0),UG=FX(N0),AG=OX(N0),BG=MX(N0),KG=VX(N0),DG=ZX(N0),LG=NX(N0);var e=q("ZodType",(Q,Y)=>{return n.init(Q,Y),Q.def=Y,Q.type=Y.type,Object.defineProperty(Q,"_def",{value:Y}),Q.check=(...X)=>{return Q.clone(f.mergeDefs(Y,{checks:[...Y.checks??[],...X.map((W)=>typeof W==="function"?{_zod:{check:W,def:{check:"custom"},onattach:[]}}:W)]}))},Q.clone=(X,W)=>T0(Q,X,W),Q.brand=()=>Q,Q.register=(X,W)=>{return X.add(Q,W),Q},Q.parse=(X,W)=>WG(Q,X,W,{callee:Q.parse}),Q.safeParse=(X,W)=>$G(Q,X,W),Q.parseAsync=async(X,W)=>GG(Q,X,W,{callee:Q.parseAsync}),Q.safeParseAsync=async(X,W)=>JG(Q,X,W),Q.spa=Q.safeParseAsync,Q.encode=(X,W)=>zG(Q,X,W),Q.decode=(X,W)=>HG(Q,X,W),Q.encodeAsync=async(X,W)=>UG(Q,X,W),Q.decodeAsync=async(X,W)=>AG(Q,X,W),Q.safeEncode=(X,W)=>BG(Q,X,W),Q.safeDecode=(X,W)=>KG(Q,X,W),Q.safeEncodeAsync=async(X,W)=>DG(Q,X,W),Q.safeDecodeAsync=async(X,W)=>LG(Q,X,W),Q.refine=(X,W)=>Q.check(h3(X,W)),Q.superRefine=(X)=>Q.check(f3(X)),Q.overwrite=(X)=>Q.check(M1(X)),Q.optional=()=>s(Q),Q.nullable=()=>OG(Q),Q.nullish=()=>s(OG(Q)),Q.nonoptional=(X)=>v3(Q,X),Q.array=()=>y(Q),Q.or=(X)=>i([Q,X]),Q.and=(X)=>D6(Q,X),Q.transform=(X)=>Y9(Q,wG(X)),Q.default=(X)=>R3(Q,X),Q.prefault=(X)=>k3(Q,X),Q.catch=(X)=>_3(Q,X),Q.pipe=(X)=>Y9(Q,X),Q.readonly=()=>u3(Q),Q.describe=(X)=>{let W=Q.clone();return W4.add(W,{description:X}),W},Object.defineProperty(Q,"description",{get(){return W4.get(Q)?.description},configurable:!0}),Q.meta=(...X)=>{if(X.length===0)return W4.get(Q);let W=Q.clone();return W4.add(W,X[0]),W},Q.isOptional=()=>Q.safeParse(void 0).success,Q.isNullable=()=>Q.safeParse(null).success,Q}),MG=q("_ZodString",(Q,Y)=>{$6.init(Q,Y),e.init(Q,Y);let X=Q._zod.bag;Q.format=X.format??null,Q.minLength=X.minimum??null,Q.maxLength=X.maximum??null,Q.regex=(...W)=>Q.check(fQ(...W)),Q.includes=(...W)=>Q.check(cQ(...W)),Q.startsWith=(...W)=>Q.check(pQ(...W)),Q.endsWith=(...W)=>Q.check(iQ(...W)),Q.min=(...W)=>Q.check(S1(...W)),Q.max=(...W)=>Q.check(U6(...W)),Q.length=(...W)=>Q.check(A6(...W)),Q.nonempty=(...W)=>Q.check(S1(1,...W)),Q.lowercase=(W)=>Q.check(lQ(W)),Q.uppercase=(W)=>Q.check(mQ(W)),Q.trim=()=>Q.check(rQ()),Q.normalize=(...W)=>Q.check(nQ(...W)),Q.toLowerCase=()=>Q.check(dQ()),Q.toUpperCase=()=>Q.check(oQ())}),sH=q("ZodString",(Q,Y)=>{$6.init(Q,Y),MG.init(Q,Y),Q.email=(X)=>Q.check(FW(eH,X)),Q.url=(X)=>Q.check(NW(Q3,X)),Q.jwt=(X)=>Q.check(yW(q3,X)),Q.emoji=(X)=>Q.check(wW(Y3,X)),Q.guid=(X)=>Q.check(hQ(qG,X)),Q.uuid=(X)=>Q.check(OW(K6,X)),Q.uuidv4=(X)=>Q.check(MW(K6,X)),Q.uuidv6=(X)=>Q.check(VW(K6,X)),Q.uuidv7=(X)=>Q.check(ZW(K6,X)),Q.nanoid=(X)=>Q.check(bW(X3,X)),Q.guid=(X)=>Q.check(hQ(qG,X)),Q.cuid=(X)=>Q.check(jW(W3,X)),Q.cuid2=(X)=>Q.check(PW(G3,X)),Q.ulid=(X)=>Q.check(IW($3,X)),Q.base64=(X)=>Q.check(vW(K3,X)),Q.base64url=(X)=>Q.check(xW(D3,X)),Q.xid=(X)=>Q.check(EW(J3,X)),Q.ksuid=(X)=>Q.check(TW(z3,X)),Q.ipv4=(X)=>Q.check(SW(H3,X)),Q.ipv6=(X)=>Q.check(RW(U3,X)),Q.cidrv4=(X)=>Q.check(CW(A3,X)),Q.cidrv6=(X)=>Q.check(kW(B3,X)),Q.e164=(X)=>Q.check(_W(L3,X)),Q.datetime=(X)=>Q.check(tQ(X)),Q.date=(X)=>Q.check(aQ(X)),Q.time=(X)=>Q.check(sQ(X)),Q.duration=(X)=>Q.check(eQ(X))});function D(Q){return qW(sH,Q)}var o=q("ZodStringFormat",(Q,Y)=>{r.init(Q,Y),MG.init(Q,Y)}),eH=q("ZodEmail",(Q,Y)=>{w8.init(Q,Y),o.init(Q,Y)});var qG=q("ZodGUID",(Q,Y)=>{Z8.init(Q,Y),o.init(Q,Y)});var K6=q("ZodUUID",(Q,Y)=>{N8.init(Q,Y),o.init(Q,Y)});var Q3=q("ZodURL",(Q,Y)=>{b8.init(Q,Y),o.init(Q,Y)});var Y3=q("ZodEmoji",(Q,Y)=>{j8.init(Q,Y),o.init(Q,Y)});var X3=q("ZodNanoID",(Q,Y)=>{P8.init(Q,Y),o.init(Q,Y)});var W3=q("ZodCUID",(Q,Y)=>{I8.init(Q,Y),o.init(Q,Y)});var G3=q("ZodCUID2",(Q,Y)=>{E8.init(Q,Y),o.init(Q,Y)});var $3=q("ZodULID",(Q,Y)=>{T8.init(Q,Y),o.init(Q,Y)});var J3=q("ZodXID",(Q,Y)=>{S8.init(Q,Y),o.init(Q,Y)});var z3=q("ZodKSUID",(Q,Y)=>{R8.init(Q,Y),o.init(Q,Y)});var H3=q("ZodIPv4",(Q,Y)=>{_8.init(Q,Y),o.init(Q,Y)});var U3=q("ZodIPv6",(Q,Y)=>{y8.init(Q,Y),o.init(Q,Y)});var A3=q("ZodCIDRv4",(Q,Y)=>{g8.init(Q,Y),o.init(Q,Y)});var B3=q("ZodCIDRv6",(Q,Y)=>{u8.init(Q,Y),o.init(Q,Y)});var K3=q("ZodBase64",(Q,Y)=>{f8.init(Q,Y),o.init(Q,Y)});var D3=q("ZodBase64URL",(Q,Y)=>{l8.init(Q,Y),o.init(Q,Y)});var L3=q("ZodE164",(Q,Y)=>{m8.init(Q,Y),o.init(Q,Y)});var q3=q("ZodJWT",(Q,Y)=>{c8.init(Q,Y),o.init(Q,Y)});var VG=q("ZodNumber",(Q,Y)=>{yQ.init(Q,Y),e.init(Q,Y),Q.gt=(W,G)=>Q.check(z6(W,G)),Q.gte=(W,G)=>Q.check($4(W,G)),Q.min=(W,G)=>Q.check($4(W,G)),Q.lt=(W,G)=>Q.check(J6(W,G)),Q.lte=(W,G)=>Q.check(G4(W,G)),Q.max=(W,G)=>Q.check(G4(W,G)),Q.int=(W)=>Q.check(FG(W)),Q.safe=(W)=>Q.check(FG(W)),Q.positive=(W)=>Q.check(z6(0,W)),Q.nonnegative=(W)=>Q.check($4(0,W)),Q.negative=(W)=>Q.check(J6(0,W)),Q.nonpositive=(W)=>Q.check(G4(0,W)),Q.multipleOf=(W,G)=>Q.check(H6(W,G)),Q.step=(W,G)=>Q.check(H6(W,G)),Q.finite=()=>Q;let X=Q._zod.bag;Q.minValue=Math.max(X.minimum??Number.NEGATIVE_INFINITY,X.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,Q.maxValue=Math.min(X.maximum??Number.POSITIVE_INFINITY,X.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,Q.isInt=(X.format??"").includes("int")||Number.isSafeInteger(X.multipleOf??0.5),Q.isFinite=!0,Q.format=X.format??null});function m(Q){return lW(VG,Q)}var F3=q("ZodNumberFormat",(Q,Y)=>{p8.init(Q,Y),VG.init(Q,Y)});function FG(Q){return mW(F3,Q)}var O3=q("ZodBoolean",(Q,Y)=>{i8.init(Q,Y),e.init(Q,Y)});function W0(Q){return cW(O3,Q)}var M3=q("ZodNull",(Q,Y)=>{n8.init(Q,Y),e.init(Q,Y)});function X9(Q){return pW(M3,Q)}var V3=q("ZodUnknown",(Q,Y)=>{r8.init(Q,Y),e.init(Q,Y)});function t(){return iW(V3)}var Z3=q("ZodNever",(Q,Y)=>{d8.init(Q,Y),e.init(Q,Y)});function N3(Q){return nW(Z3,Q)}var w3=q("ZodArray",(Q,Y)=>{o8.init(Q,Y),e.init(Q,Y),Q.element=Y.element,Q.min=(X,W)=>Q.check(S1(X,W)),Q.nonempty=(X)=>Q.check(S1(1,X)),Q.max=(X,W)=>Q.check(U6(X,W)),Q.length=(X,W)=>Q.check(A6(X,W)),Q.unwrap=()=>Q.element});function y(Q,Y){return rW(w3,Q,Y)}var ZG=q("ZodObject",(Q,Y)=>{s8.init(Q,Y),e.init(Q,Y),f.defineLazy(Q,"shape",()=>{return Y.shape}),Q.keyof=()=>q0(Object.keys(Q._zod.def.shape)),Q.catchall=(X)=>Q.clone({...Q._zod.def,catchall:X}),Q.passthrough=()=>Q.clone({...Q._zod.def,catchall:t()}),Q.loose=()=>Q.clone({...Q._zod.def,catchall:t()}),Q.strict=()=>Q.clone({...Q._zod.def,catchall:N3()}),Q.strip=()=>Q.clone({...Q._zod.def,catchall:void 0}),Q.extend=(X)=>{return f.extend(Q,X)},Q.safeExtend=(X)=>{return f.safeExtend(Q,X)},Q.merge=(X)=>f.merge(Q,X),Q.pick=(X)=>f.pick(Q,X),Q.omit=(X)=>f.omit(Q,X),Q.partial=(...X)=>f.partial(bG,Q,X[0]),Q.required=(...X)=>f.required(jG,Q,X[0])});function b(Q,Y){let X={type:"object",shape:Q??{},...f.normalizeParams(Y)};return new ZG(X)}function K0(Q,Y){return new ZG({type:"object",shape:Q,catchall:t(),...f.normalizeParams(Y)})}var NG=q("ZodUnion",(Q,Y)=>{gQ.init(Q,Y),e.init(Q,Y),Q.options=Y.options});function i(Q,Y){return new NG({type:"union",options:Q,...f.normalizeParams(Y)})}var b3=q("ZodDiscriminatedUnion",(Q,Y)=>{NG.init(Q,Y),e8.init(Q,Y)});function W9(Q,Y,X){return new b3({type:"union",options:Y,discriminator:Q,...f.normalizeParams(X)})}var j3=q("ZodIntersection",(Q,Y)=>{QW.init(Q,Y),e.init(Q,Y)});function D6(Q,Y){return new j3({type:"intersection",left:Q,right:Y})}var P3=q("ZodRecord",(Q,Y)=>{YW.init(Q,Y),e.init(Q,Y),Q.keyType=Y.keyType,Q.valueType=Y.valueType});function a(Q,Y,X){return new P3({type:"record",keyType:Q,valueType:Y,...f.normalizeParams(X)})}var Q9=q("ZodEnum",(Q,Y)=>{XW.init(Q,Y),e.init(Q,Y),Q.enum=Y.entries,Q.options=Object.values(Y.entries);let X=new Set(Object.keys(Y.entries));Q.extract=(W,G)=>{let $={};for(let J of W)if(X.has(J))$[J]=Y.entries[J];else throw Error(`Key ${J} not found in enum`);return new Q9({...Y,checks:[],...f.normalizeParams(G),entries:$})},Q.exclude=(W,G)=>{let $={...Y.entries};for(let J of W)if(X.has(J))delete $[J];else throw Error(`Key ${J} not found in enum`);return new Q9({...Y,checks:[],...f.normalizeParams(G),entries:$})}});function q0(Q,Y){let X=Array.isArray(Q)?Object.fromEntries(Q.map((W)=>[W,W])):Q;return new Q9({type:"enum",entries:X,...f.normalizeParams(Y)})}var I3=q("ZodLiteral",(Q,Y)=>{WW.init(Q,Y),e.init(Q,Y),Q.values=new Set(Y.values),Object.defineProperty(Q,"value",{get(){if(Y.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return Y.values[0]}})});function j(Q,Y){return new I3({type:"literal",values:Array.isArray(Q)?Q:[Q],...f.normalizeParams(Y)})}var E3=q("ZodTransform",(Q,Y)=>{GW.init(Q,Y),e.init(Q,Y),Q._zod.parse=(X,W)=>{if(W.direction==="backward")throw new d1(Q.constructor.name);X.addIssue=($)=>{if(typeof $==="string")X.issues.push(f.issue($,X.value,Y));else{let J=$;if(J.fatal)J.continue=!1;J.code??(J.code="custom"),J.input??(J.input=X.value),J.inst??(J.inst=Q),X.issues.push(f.issue(J))}};let G=Y.transform(X.value,X);if(G instanceof Promise)return G.then(($)=>{return X.value=$,X});return X.value=G,X}});function wG(Q){return new E3({type:"transform",transform:Q})}var bG=q("ZodOptional",(Q,Y)=>{$W.init(Q,Y),e.init(Q,Y),Q.unwrap=()=>Q._zod.def.innerType});function s(Q){return new bG({type:"optional",innerType:Q})}var T3=q("ZodNullable",(Q,Y)=>{JW.init(Q,Y),e.init(Q,Y),Q.unwrap=()=>Q._zod.def.innerType});function OG(Q){return new T3({type:"nullable",innerType:Q})}var S3=q("ZodDefault",(Q,Y)=>{zW.init(Q,Y),e.init(Q,Y),Q.unwrap=()=>Q._zod.def.innerType,Q.removeDefault=Q.unwrap});function R3(Q,Y){return new S3({type:"default",innerType:Q,get defaultValue(){return typeof Y==="function"?Y():f.shallowClone(Y)}})}var C3=q("ZodPrefault",(Q,Y)=>{HW.init(Q,Y),e.init(Q,Y),Q.unwrap=()=>Q._zod.def.innerType});function k3(Q,Y){return new C3({type:"prefault",innerType:Q,get defaultValue(){return typeof Y==="function"?Y():f.shallowClone(Y)}})}var jG=q("ZodNonOptional",(Q,Y)=>{UW.init(Q,Y),e.init(Q,Y),Q.unwrap=()=>Q._zod.def.innerType});function v3(Q,Y){return new jG({type:"nonoptional",innerType:Q,...f.normalizeParams(Y)})}var x3=q("ZodCatch",(Q,Y)=>{AW.init(Q,Y),e.init(Q,Y),Q.unwrap=()=>Q._zod.def.innerType,Q.removeCatch=Q.unwrap});function _3(Q,Y){return new x3({type:"catch",innerType:Q,catchValue:typeof Y==="function"?Y:()=>Y})}var y3=q("ZodPipe",(Q,Y)=>{BW.init(Q,Y),e.init(Q,Y),Q.in=Y.in,Q.out=Y.out});function Y9(Q,Y){return new y3({type:"pipe",in:Q,out:Y})}var g3=q("ZodReadonly",(Q,Y)=>{KW.init(Q,Y),e.init(Q,Y),Q.unwrap=()=>Q._zod.def.innerType});function u3(Q){return new g3({type:"readonly",innerType:Q})}var PG=q("ZodCustom",(Q,Y)=>{DW.init(Q,Y),e.init(Q,Y)});function IG(Q,Y){return dW(PG,Q??(()=>!0),Y)}function h3(Q,Y={}){return oW(PG,Q,Y)}function f3(Q){return tW(Q)}function G9(Q,Y){return Y9(wG(Q),Y)}b0(uQ());var $9="2025-11-25";var EG=[$9,"2025-06-18","2025-03-26","2024-11-05","2024-10-07"],J1="io.modelcontextprotocol/related-task",q6="2.0",$0=IG((Q)=>Q!==null&&(typeof Q==="object"||typeof Q==="function")),TG=i([D(),m().int()]),SG=D(),FN=K0({ttl:i([m(),X9()]).optional(),pollInterval:m().optional()}),l3=b({ttl:m().optional()}),m3=b({taskId:D()}),J9=K0({progressToken:TG.optional(),[J1]:m3.optional()}),w0=b({_meta:J9.optional()}),H4=w0.extend({task:l3.optional()}),RG=(Q)=>H4.safeParse(Q).success,J0=b({method:D(),params:w0.loose().optional()}),j0=b({_meta:J9.optional()}),P0=b({method:D(),params:j0.loose().optional()}),z0=K0({_meta:J9.optional()}),F6=i([D(),m().int()]),CG=b({jsonrpc:j(q6),id:F6,...J0.shape}).strict(),z9=(Q)=>CG.safeParse(Q).success,kG=b({jsonrpc:j(q6),...P0.shape}).strict(),vG=(Q)=>kG.safeParse(Q).success,H9=b({jsonrpc:j(q6),id:F6,result:z0}).strict(),U4=(Q)=>H9.safeParse(Q).success;var g;(function(Q){Q[Q.ConnectionClosed=-32000]="ConnectionClosed",Q[Q.RequestTimeout=-32001]="RequestTimeout",Q[Q.ParseError=-32700]="ParseError",Q[Q.InvalidRequest=-32600]="InvalidRequest",Q[Q.MethodNotFound=-32601]="MethodNotFound",Q[Q.InvalidParams=-32602]="InvalidParams",Q[Q.InternalError=-32603]="InternalError",Q[Q.UrlElicitationRequired=-32042]="UrlElicitationRequired"})(g||(g={}));var U9=b({jsonrpc:j(q6),id:F6.optional(),error:b({code:m().int(),message:D(),data:t().optional()})}).strict();var xG=(Q)=>U9.safeParse(Q).success;var _G=i([CG,kG,H9,U9]),ON=i([H9,U9]),O6=z0.strict(),c3=j0.extend({requestId:F6.optional(),reason:D().optional()}),M6=P0.extend({method:j("notifications/cancelled"),params:c3}),p3=b({src:D(),mimeType:D().optional(),sizes:y(D()).optional(),theme:q0(["light","dark"]).optional()}),A4=b({icons:y(p3).optional()}),C1=b({name:D(),title:D().optional()}),yG=C1.extend({...C1.shape,...A4.shape,version:D(),websiteUrl:D().optional(),description:D().optional()}),i3=D6(b({applyDefaults:W0().optional()}),a(D(),t())),n3=G9((Q)=>{if(Q&&typeof Q==="object"&&!Array.isArray(Q)){if(Object.keys(Q).length===0)return{form:{}}}return Q},D6(b({form:i3.optional(),url:$0.optional()}),a(D(),t()).optional())),r3=K0({list:$0.optional(),cancel:$0.optional(),requests:K0({sampling:K0({createMessage:$0.optional()}).optional(),elicitation:K0({create:$0.optional()}).optional()}).optional()}),d3=K0({list:$0.optional(),cancel:$0.optional(),requests:K0({tools:K0({call:$0.optional()}).optional()}).optional()}),o3=b({experimental:a(D(),$0).optional(),sampling:b({context:$0.optional(),tools:$0.optional()}).optional(),elicitation:n3.optional(),roots:b({listChanged:W0().optional()}).optional(),tasks:r3.optional()}),t3=w0.extend({protocolVersion:D(),capabilities:o3,clientInfo:yG}),A9=J0.extend({method:j("initialize"),params:t3});var a3=b({experimental:a(D(),$0).optional(),logging:$0.optional(),completions:$0.optional(),prompts:b({listChanged:W0().optional()}).optional(),resources:b({subscribe:W0().optional(),listChanged:W0().optional()}).optional(),tools:b({listChanged:W0().optional()}).optional(),tasks:d3.optional()}),s3=z0.extend({protocolVersion:D(),capabilities:a3,serverInfo:yG,instructions:D().optional()}),B9=P0.extend({method:j("notifications/initialized"),params:j0.optional()});var V6=J0.extend({method:j("ping"),params:w0.optional()}),e3=b({progress:m(),total:s(m()),message:s(D())}),QU=b({...j0.shape,...e3.shape,progressToken:TG}),Z6=P0.extend({method:j("notifications/progress"),params:QU}),YU=w0.extend({cursor:SG.optional()}),B4=J0.extend({params:YU.optional()}),K4=z0.extend({nextCursor:SG.optional()}),XU=q0(["working","input_required","completed","failed","cancelled"]),D4=b({taskId:D(),status:XU,ttl:i([m(),X9()]),createdAt:D(),lastUpdatedAt:D(),pollInterval:s(m()),statusMessage:s(D())}),k1=z0.extend({task:D4}),WU=j0.merge(D4),L4=P0.extend({method:j("notifications/tasks/status"),params:WU}),N6=J0.extend({method:j("tasks/get"),params:w0.extend({taskId:D()})}),w6=z0.merge(D4),b6=J0.extend({method:j("tasks/result"),params:w0.extend({taskId:D()})}),MN=z0.loose(),j6=B4.extend({method:j("tasks/list")}),P6=K4.extend({tasks:y(D4)}),I6=J0.extend({method:j("tasks/cancel"),params:w0.extend({taskId:D()})}),gG=z0.merge(D4),uG=b({uri:D(),mimeType:s(D()),_meta:a(D(),t()).optional()}),hG=uG.extend({text:D()}),K9=D().refine((Q)=>{try{return atob(Q),!0}catch{return!1}},{message:"Invalid Base64 string"}),fG=uG.extend({blob:K9}),q4=q0(["user","assistant"]),v1=b({audience:y(q4).optional(),priority:m().min(0).max(1).optional(),lastModified:z4.datetime({offset:!0}).optional()}),lG=b({...C1.shape,...A4.shape,uri:D(),description:s(D()),mimeType:s(D()),annotations:v1.optional(),_meta:s(K0({}))}),GU=b({...C1.shape,...A4.shape,uriTemplate:D(),description:s(D()),mimeType:s(D()),annotations:v1.optional(),_meta:s(K0({}))}),D9=B4.extend({method:j("resources/list")}),$U=K4.extend({resources:y(lG)}),JU=B4.extend({method:j("resources/templates/list")}),zU=K4.extend({resourceTemplates:y(GU)}),L9=w0.extend({uri:D()}),HU=L9,q9=J0.extend({method:j("resources/read"),params:HU}),UU=z0.extend({contents:y(i([hG,fG]))}),AU=P0.extend({method:j("notifications/resources/list_changed"),params:j0.optional()}),BU=L9,KU=J0.extend({method:j("resources/subscribe"),params:BU}),DU=L9,LU=J0.extend({method:j("resources/unsubscribe"),params:DU}),qU=j0.extend({uri:D()}),FU=P0.extend({method:j("notifications/resources/updated"),params:qU}),OU=b({name:D(),description:s(D()),required:s(W0())}),MU=b({...C1.shape,...A4.shape,description:s(D()),arguments:s(y(OU)),_meta:s(K0({}))}),VU=B4.extend({method:j("prompts/list")}),ZU=K4.extend({prompts:y(MU)}),NU=w0.extend({name:D(),arguments:a(D(),D()).optional()}),wU=J0.extend({method:j("prompts/get"),params:NU}),F9=b({type:j("text"),text:D(),annotations:v1.optional(),_meta:a(D(),t()).optional()}),O9=b({type:j("image"),data:K9,mimeType:D(),annotations:v1.optional(),_meta:a(D(),t()).optional()}),M9=b({type:j("audio"),data:K9,mimeType:D(),annotations:v1.optional(),_meta:a(D(),t()).optional()}),bU=b({type:j("tool_use"),name:D(),id:D(),input:a(D(),t()),_meta:a(D(),t()).optional()}),jU=b({type:j("resource"),resource:i([hG,fG]),annotations:v1.optional(),_meta:a(D(),t()).optional()}),PU=lG.extend({type:j("resource_link")}),V9=i([F9,O9,M9,PU,jU]),IU=b({role:q4,content:V9}),EU=z0.extend({description:D().optional(),messages:y(IU)}),TU=P0.extend({method:j("notifications/prompts/list_changed"),params:j0.optional()}),SU=b({title:D().optional(),readOnlyHint:W0().optional(),destructiveHint:W0().optional(),idempotentHint:W0().optional(),openWorldHint:W0().optional()}),RU=b({taskSupport:q0(["required","optional","forbidden"]).optional()}),mG=b({...C1.shape,...A4.shape,description:D().optional(),inputSchema:b({type:j("object"),properties:a(D(),$0).optional(),required:y(D()).optional()}).catchall(t()),outputSchema:b({type:j("object"),properties:a(D(),$0).optional(),required:y(D()).optional()}).catchall(t()).optional(),annotations:SU.optional(),execution:RU.optional(),_meta:a(D(),t()).optional()}),Z9=B4.extend({method:j("tools/list")}),CU=K4.extend({tools:y(mG)}),E6=z0.extend({content:y(V9).default([]),structuredContent:a(D(),t()).optional(),isError:W0().optional()}),VN=E6.or(z0.extend({toolResult:t()})),kU=H4.extend({name:D(),arguments:a(D(),t()).optional()}),F4=J0.extend({method:j("tools/call"),params:kU}),vU=P0.extend({method:j("notifications/tools/list_changed"),params:j0.optional()}),ZN=b({autoRefresh:W0().default(!0),debounceMs:m().int().nonnegative().default(300)}),O4=q0(["debug","info","notice","warning","error","critical","alert","emergency"]),xU=w0.extend({level:O4}),N9=J0.extend({method:j("logging/setLevel"),params:xU}),_U=j0.extend({level:O4,logger:D().optional(),data:t()}),yU=P0.extend({method:j("notifications/message"),params:_U}),gU=b({name:D().optional()}),uU=b({hints:y(gU).optional(),costPriority:m().min(0).max(1).optional(),speedPriority:m().min(0).max(1).optional(),intelligencePriority:m().min(0).max(1).optional()}),hU=b({mode:q0(["auto","required","none"]).optional()}),fU=b({type:j("tool_result"),toolUseId:D().describe("The unique identifier for the corresponding tool call."),content:y(V9).default([]),structuredContent:b({}).loose().optional(),isError:W0().optional(),_meta:a(D(),t()).optional()}),lU=W9("type",[F9,O9,M9]),L6=W9("type",[F9,O9,M9,bU,fU]),mU=b({role:q4,content:i([L6,y(L6)]),_meta:a(D(),t()).optional()}),cU=H4.extend({messages:y(mU),modelPreferences:uU.optional(),systemPrompt:D().optional(),includeContext:q0(["none","thisServer","allServers"]).optional(),temperature:m().optional(),maxTokens:m().int(),stopSequences:y(D()).optional(),metadata:$0.optional(),tools:y(mG).optional(),toolChoice:hU.optional()}),pU=J0.extend({method:j("sampling/createMessage"),params:cU}),w9=z0.extend({model:D(),stopReason:s(q0(["endTurn","stopSequence","maxTokens"]).or(D())),role:q4,content:lU}),b9=z0.extend({model:D(),stopReason:s(q0(["endTurn","stopSequence","maxTokens","toolUse"]).or(D())),role:q4,content:i([L6,y(L6)])}),iU=b({type:j("boolean"),title:D().optional(),description:D().optional(),default:W0().optional()}),nU=b({type:j("string"),title:D().optional(),description:D().optional(),minLength:m().optional(),maxLength:m().optional(),format:q0(["email","uri","date","date-time"]).optional(),default:D().optional()}),rU=b({type:q0(["number","integer"]),title:D().optional(),description:D().optional(),minimum:m().optional(),maximum:m().optional(),default:m().optional()}),dU=b({type:j("string"),title:D().optional(),description:D().optional(),enum:y(D()),default:D().optional()}),oU=b({type:j("string"),title:D().optional(),description:D().optional(),oneOf:y(b({const:D(),title:D()})),default:D().optional()}),tU=b({type:j("string"),title:D().optional(),description:D().optional(),enum:y(D()),enumNames:y(D()).optional(),default:D().optional()}),aU=i([dU,oU]),sU=b({type:j("array"),title:D().optional(),description:D().optional(),minItems:m().optional(),maxItems:m().optional(),items:b({type:j("string"),enum:y(D())}),default:y(D()).optional()}),eU=b({type:j("array"),title:D().optional(),description:D().optional(),minItems:m().optional(),maxItems:m().optional(),items:b({anyOf:y(b({const:D(),title:D()}))}),default:y(D()).optional()}),QA=i([sU,eU]),YA=i([tU,aU,QA]),XA=i([YA,iU,nU,rU]),WA=H4.extend({mode:j("form").optional(),message:D(),requestedSchema:b({type:j("object"),properties:a(D(),XA),required:y(D()).optional()})}),GA=H4.extend({mode:j("url"),message:D(),elicitationId:D(),url:D().url()}),$A=i([WA,GA]),JA=J0.extend({method:j("elicitation/create"),params:$A}),zA=j0.extend({elicitationId:D()}),HA=P0.extend({method:j("notifications/elicitation/complete"),params:zA}),T6=z0.extend({action:q0(["accept","decline","cancel"]),content:G9((Q)=>Q===null?void 0:Q,a(D(),i([D(),m(),W0(),y(D())])).optional())}),UA=b({type:j("ref/resource"),uri:D()});var AA=b({type:j("ref/prompt"),name:D()}),BA=w0.extend({ref:i([AA,UA]),argument:b({name:D(),value:D()}),context:b({arguments:a(D(),D()).optional()}).optional()}),KA=J0.extend({method:j("completion/complete"),params:BA});var DA=z0.extend({completion:K0({values:y(D()).max(100),total:s(m().int()),hasMore:s(W0())})}),LA=b({uri:D().startsWith("file://"),name:D().optional(),_meta:a(D(),t()).optional()}),qA=J0.extend({method:j("roots/list"),params:w0.optional()}),j9=z0.extend({roots:y(LA)}),FA=P0.extend({method:j("notifications/roots/list_changed"),params:j0.optional()}),NN=i([V6,A9,KA,N9,wU,VU,D9,JU,q9,KU,LU,F4,Z9,N6,b6,j6,I6]),wN=i([M6,Z6,B9,FA,L4]),bN=i([O6,w9,b9,T6,j9,w6,P6,k1]),jN=i([V6,pU,JA,qA,N6,b6,j6,I6]),PN=i([M6,Z6,yU,FU,AU,vU,TU,L4,HA]),IN=i([O6,s3,DA,EU,ZU,$U,zU,UU,E6,CU,w6,P6,k1]);class k extends Error{constructor(Q,Y,X){super(`MCP error ${Q}: ${Y}`);this.code=Q,this.data=X,this.name="McpError"}static fromError(Q,Y,X){if(Q===g.UrlElicitationRequired&&X){let W=X;if(W.elicitations)return new cG(W.elicitations,Y)}return new k(Q,Y,X)}}class cG extends k{constructor(Q,Y=`URL elicitation${Q.length>1?"s":""} required`){super(g.UrlElicitationRequired,Y,{elicitations:Q})}get elicitations(){return this.data?.elicitations??[]}}function z1(Q){return Q==="completed"||Q==="failed"||Q==="cancelled"}var OA=Symbol("Let zodToJsonSchema decide on which parser to use");var $w=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function P9(Q){let X=B6(Q)?.method;if(!X)throw Error("Schema is missing a method literal");let W=aW(X);if(typeof W!=="string")throw Error("Schema method literal must be a string");return W}function I9(Q,Y){let X=$1(Q,Y);if(!X.success)throw X.error;return X.data}var bA=60000;class E9{constructor(Q){if(this._options=Q,this._requestMessageId=0,this._requestHandlers=new Map,this._requestHandlerAbortControllers=new Map,this._notificationHandlers=new Map,this._responseHandlers=new Map,this._progressHandlers=new Map,this._timeoutInfo=new Map,this._pendingDebouncedNotifications=new Set,this._taskProgressTokens=new Map,this._requestResolvers=new Map,this.setNotificationHandler(M6,(Y)=>{this._oncancel(Y)}),this.setNotificationHandler(Z6,(Y)=>{this._onprogress(Y)}),this.setRequestHandler(V6,(Y)=>({})),this._taskStore=Q?.taskStore,this._taskMessageQueue=Q?.taskMessageQueue,this._taskStore)this.setRequestHandler(N6,async(Y,X)=>{let W=await this._taskStore.getTask(Y.params.taskId,X.sessionId);if(!W)throw new k(g.InvalidParams,"Failed to retrieve task: Task not found");return{...W}}),this.setRequestHandler(b6,async(Y,X)=>{let W=async()=>{let G=Y.params.taskId;if(this._taskMessageQueue){let J;while(J=await this._taskMessageQueue.dequeue(G,X.sessionId)){if(J.type==="response"||J.type==="error"){let z=J.message,H=z.id,U=this._requestResolvers.get(H);if(U)if(this._requestResolvers.delete(H),J.type==="response")U(z);else{let A=z,B=new k(A.error.code,A.error.message,A.error.data);U(B)}else{let A=J.type==="response"?"Response":"Error";this._onerror(Error(`${A} handler missing for request ${H}`))}continue}await this._transport?.send(J.message,{relatedRequestId:X.requestId})}}let $=await this._taskStore.getTask(G,X.sessionId);if(!$)throw new k(g.InvalidParams,`Task not found: ${G}`);if(!z1($.status))return await this._waitForTaskUpdate(G,X.signal),await W();if(z1($.status)){let J=await this._taskStore.getTaskResult(G,X.sessionId);return this._clearTaskQueue(G),{...J,_meta:{...J._meta,[J1]:{taskId:G}}}}return await W()};return await W()}),this.setRequestHandler(j6,async(Y,X)=>{try{let{tasks:W,nextCursor:G}=await this._taskStore.listTasks(Y.params?.cursor,X.sessionId);return{tasks:W,nextCursor:G,_meta:{}}}catch(W){throw new k(g.InvalidParams,`Failed to list tasks: ${W instanceof Error?W.message:String(W)}`)}}),this.setRequestHandler(I6,async(Y,X)=>{try{let W=await this._taskStore.getTask(Y.params.taskId,X.sessionId);if(!W)throw new k(g.InvalidParams,`Task not found: ${Y.params.taskId}`);if(z1(W.status))throw new k(g.InvalidParams,`Cannot cancel task in terminal status: ${W.status}`);await this._taskStore.updateTaskStatus(Y.params.taskId,"cancelled","Client cancelled task execution.",X.sessionId),this._clearTaskQueue(Y.params.taskId);let G=await this._taskStore.getTask(Y.params.taskId,X.sessionId);if(!G)throw new k(g.InvalidParams,`Task not found after cancellation: ${Y.params.taskId}`);return{_meta:{},...G}}catch(W){if(W instanceof k)throw W;throw new k(g.InvalidRequest,`Failed to cancel task: ${W instanceof Error?W.message:String(W)}`)}})}async _oncancel(Q){if(!Q.params.requestId)return;this._requestHandlerAbortControllers.get(Q.params.requestId)?.abort(Q.params.reason)}_setupTimeout(Q,Y,X,W,G=!1){this._timeoutInfo.set(Q,{timeoutId:setTimeout(W,Y),startTime:Date.now(),timeout:Y,maxTotalTimeout:X,resetTimeoutOnProgress:G,onTimeout:W})}_resetTimeout(Q){let Y=this._timeoutInfo.get(Q);if(!Y)return!1;let X=Date.now()-Y.startTime;if(Y.maxTotalTimeout&&X>=Y.maxTotalTimeout)throw this._timeoutInfo.delete(Q),k.fromError(g.RequestTimeout,"Maximum total timeout exceeded",{maxTotalTimeout:Y.maxTotalTimeout,totalElapsed:X});return clearTimeout(Y.timeoutId),Y.timeoutId=setTimeout(Y.onTimeout,Y.timeout),!0}_cleanupTimeout(Q){let Y=this._timeoutInfo.get(Q);if(Y)clearTimeout(Y.timeoutId),this._timeoutInfo.delete(Q)}async connect(Q){this._transport=Q;let Y=this.transport?.onclose;this._transport.onclose=()=>{Y?.(),this._onclose()};let X=this.transport?.onerror;this._transport.onerror=(G)=>{X?.(G),this._onerror(G)};let W=this._transport?.onmessage;this._transport.onmessage=(G,$)=>{if(W?.(G,$),U4(G)||xG(G))this._onresponse(G);else if(z9(G))this._onrequest(G,$);else if(vG(G))this._onnotification(G);else this._onerror(Error(`Unknown message type: ${JSON.stringify(G)}`))},await this._transport.start()}_onclose(){let Q=this._responseHandlers;this._responseHandlers=new Map,this._progressHandlers.clear(),this._taskProgressTokens.clear(),this._pendingDebouncedNotifications.clear();let Y=k.fromError(g.ConnectionClosed,"Connection closed");this._transport=void 0,this.onclose?.();for(let X of Q.values())X(Y)}_onerror(Q){this.onerror?.(Q)}_onnotification(Q){let Y=this._notificationHandlers.get(Q.method)??this.fallbackNotificationHandler;if(Y===void 0)return;Promise.resolve().then(()=>Y(Q)).catch((X)=>this._onerror(Error(`Uncaught error in notification handler: ${X}`)))}_onrequest(Q,Y){let X=this._requestHandlers.get(Q.method)??this.fallbackRequestHandler,W=this._transport,G=Q.params?._meta?.[J1]?.taskId;if(X===void 0){let U={jsonrpc:"2.0",id:Q.id,error:{code:g.MethodNotFound,message:"Method not found"}};if(G&&this._taskMessageQueue)this._enqueueTaskMessage(G,{type:"error",message:U,timestamp:Date.now()},W?.sessionId).catch((A)=>this._onerror(Error(`Failed to enqueue error response: ${A}`)));else W?.send(U).catch((A)=>this._onerror(Error(`Failed to send an error response: ${A}`)));return}let $=new AbortController;this._requestHandlerAbortControllers.set(Q.id,$);let J=RG(Q.params)?Q.params.task:void 0,z=this._taskStore?this.requestTaskStore(Q,W?.sessionId):void 0,H={signal:$.signal,sessionId:W?.sessionId,_meta:Q.params?._meta,sendNotification:async(U)=>{let A={relatedRequestId:Q.id};if(G)A.relatedTask={taskId:G};await this.notification(U,A)},sendRequest:async(U,A,B)=>{let K={...B,relatedRequestId:Q.id};if(G&&!K.relatedTask)K.relatedTask={taskId:G};let L=K.relatedTask?.taskId??G;if(L&&z)await z.updateTaskStatus(L,"input_required");return await this.request(U,A,K)},authInfo:Y?.authInfo,requestId:Q.id,requestInfo:Y?.requestInfo,taskId:G,taskStore:z,taskRequestedTtl:J?.ttl,closeSSEStream:Y?.closeSSEStream,closeStandaloneSSEStream:Y?.closeStandaloneSSEStream};Promise.resolve().then(()=>{if(J)this.assertTaskHandlerCapability(Q.method)}).then(()=>X(Q,H)).then(async(U)=>{if($.signal.aborted)return;let A={result:U,jsonrpc:"2.0",id:Q.id};if(G&&this._taskMessageQueue)await this._enqueueTaskMessage(G,{type:"response",message:A,timestamp:Date.now()},W?.sessionId);else await W?.send(A)},async(U)=>{if($.signal.aborted)return;let A={jsonrpc:"2.0",id:Q.id,error:{code:Number.isSafeInteger(U.code)?U.code:g.InternalError,message:U.message??"Internal error",...U.data!==void 0&&{data:U.data}}};if(G&&this._taskMessageQueue)await this._enqueueTaskMessage(G,{type:"error",message:A,timestamp:Date.now()},W?.sessionId);else await W?.send(A)}).catch((U)=>this._onerror(Error(`Failed to send response: ${U}`))).finally(()=>{this._requestHandlerAbortControllers.delete(Q.id)})}_onprogress(Q){let{progressToken:Y,...X}=Q.params,W=Number(Y),G=this._progressHandlers.get(W);if(!G){this._onerror(Error(`Received a progress notification for an unknown token: ${JSON.stringify(Q)}`));return}let $=this._responseHandlers.get(W),J=this._timeoutInfo.get(W);if(J&&$&&J.resetTimeoutOnProgress)try{this._resetTimeout(W)}catch(z){this._responseHandlers.delete(W),this._progressHandlers.delete(W),this._cleanupTimeout(W),$(z);return}G(X)}_onresponse(Q){let Y=Number(Q.id),X=this._requestResolvers.get(Y);if(X){if(this._requestResolvers.delete(Y),U4(Q))X(Q);else{let $=new k(Q.error.code,Q.error.message,Q.error.data);X($)}return}let W=this._responseHandlers.get(Y);if(W===void 0){this._onerror(Error(`Received a response for an unknown message ID: ${JSON.stringify(Q)}`));return}this._responseHandlers.delete(Y),this._cleanupTimeout(Y);let G=!1;if(U4(Q)&&Q.result&&typeof Q.result==="object"){let $=Q.result;if($.task&&typeof $.task==="object"){let J=$.task;if(typeof J.taskId==="string")G=!0,this._taskProgressTokens.set(J.taskId,Y)}}if(!G)this._progressHandlers.delete(Y);if(U4(Q))W(Q);else{let $=k.fromError(Q.error.code,Q.error.message,Q.error.data);W($)}}get transport(){return this._transport}async close(){await this._transport?.close()}async*requestStream(Q,Y,X){let{task:W}=X??{};if(!W){try{yield{type:"result",result:await this.request(Q,Y,X)}}catch($){yield{type:"error",error:$ instanceof k?$:new k(g.InternalError,String($))}}return}let G;try{let $=await this.request(Q,k1,X);if($.task)G=$.task.taskId,yield{type:"taskCreated",task:$.task};else throw new k(g.InternalError,"Task creation did not return a task");while(!0){let J=await this.getTask({taskId:G},X);if(yield{type:"taskStatus",task:J},z1(J.status)){if(J.status==="completed")yield{type:"result",result:await this.getTaskResult({taskId:G},Y,X)};else if(J.status==="failed")yield{type:"error",error:new k(g.InternalError,`Task ${G} failed`)};else if(J.status==="cancelled")yield{type:"error",error:new k(g.InternalError,`Task ${G} was cancelled`)};return}if(J.status==="input_required"){yield{type:"result",result:await this.getTaskResult({taskId:G},Y,X)};return}let z=J.pollInterval??this._options?.defaultTaskPollInterval??1000;await new Promise((H)=>setTimeout(H,z)),X?.signal?.throwIfAborted()}}catch($){yield{type:"error",error:$ instanceof k?$:new k(g.InternalError,String($))}}}request(Q,Y,X){let{relatedRequestId:W,resumptionToken:G,onresumptiontoken:$,task:J,relatedTask:z}=X??{};return new Promise((H,U)=>{let A=(V)=>{U(V)};if(!this._transport){A(Error("Not connected"));return}if(this._options?.enforceStrictCapabilities===!0)try{if(this.assertCapabilityForMethod(Q.method),J)this.assertTaskCapability(Q.method)}catch(V){A(V);return}X?.signal?.throwIfAborted();let B=this._requestMessageId++,K={...Q,jsonrpc:"2.0",id:B};if(X?.onprogress)this._progressHandlers.set(B,X.onprogress),K.params={...Q.params,_meta:{...Q.params?._meta||{},progressToken:B}};if(J)K.params={...K.params,task:J};if(z)K.params={...K.params,_meta:{...K.params?._meta||{},[J1]:z}};let L=(V)=>{this._responseHandlers.delete(B),this._progressHandlers.delete(B),this._cleanupTimeout(B),this._transport?.send({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:B,reason:String(V)}},{relatedRequestId:W,resumptionToken:G,onresumptiontoken:$}).catch((E)=>this._onerror(Error(`Failed to send cancellation: ${E}`)));let S=V instanceof k?V:new k(g.RequestTimeout,String(V));U(S)};this._responseHandlers.set(B,(V)=>{if(X?.signal?.aborted)return;if(V instanceof Error)return U(V);try{let S=$1(Y,V.result);if(!S.success)U(S.error);else H(S.data)}catch(S){U(S)}}),X?.signal?.addEventListener("abort",()=>{L(X?.signal?.reason)});let O=X?.timeout??bA,M=()=>L(k.fromError(g.RequestTimeout,"Request timed out",{timeout:O}));this._setupTimeout(B,O,X?.maxTotalTimeout,M,X?.resetTimeoutOnProgress??!1);let Z=z?.taskId;if(Z){let V=(S)=>{let E=this._responseHandlers.get(B);if(E)E(S);else this._onerror(Error(`Response handler missing for side-channeled request ${B}`))};this._requestResolvers.set(B,V),this._enqueueTaskMessage(Z,{type:"request",message:K,timestamp:Date.now()}).catch((S)=>{this._cleanupTimeout(B),U(S)})}else this._transport.send(K,{relatedRequestId:W,resumptionToken:G,onresumptiontoken:$}).catch((V)=>{this._cleanupTimeout(B),U(V)})})}async getTask(Q,Y){return this.request({method:"tasks/get",params:Q},w6,Y)}async getTaskResult(Q,Y,X){return this.request({method:"tasks/result",params:Q},Y,X)}async listTasks(Q,Y){return this.request({method:"tasks/list",params:Q},P6,Y)}async cancelTask(Q,Y){return this.request({method:"tasks/cancel",params:Q},gG,Y)}async notification(Q,Y){if(!this._transport)throw Error("Not connected");this.assertNotificationCapability(Q.method);let X=Y?.relatedTask?.taskId;if(X){let J={...Q,jsonrpc:"2.0",params:{...Q.params,_meta:{...Q.params?._meta||{},[J1]:Y.relatedTask}}};await this._enqueueTaskMessage(X,{type:"notification",message:J,timestamp:Date.now()});return}if((this._options?.debouncedNotificationMethods??[]).includes(Q.method)&&!Q.params&&!Y?.relatedRequestId&&!Y?.relatedTask){if(this._pendingDebouncedNotifications.has(Q.method))return;this._pendingDebouncedNotifications.add(Q.method),Promise.resolve().then(()=>{if(this._pendingDebouncedNotifications.delete(Q.method),!this._transport)return;let J={...Q,jsonrpc:"2.0"};if(Y?.relatedTask)J={...J,params:{...J.params,_meta:{...J.params?._meta||{},[J1]:Y.relatedTask}}};this._transport?.send(J,Y).catch((z)=>this._onerror(z))});return}let $={...Q,jsonrpc:"2.0"};if(Y?.relatedTask)$={...$,params:{...$.params,_meta:{...$.params?._meta||{},[J1]:Y.relatedTask}}};await this._transport.send($,Y)}setRequestHandler(Q,Y){let X=P9(Q);this.assertRequestHandlerCapability(X),this._requestHandlers.set(X,(W,G)=>{let $=I9(Q,W);return Promise.resolve(Y($,G))})}removeRequestHandler(Q){this._requestHandlers.delete(Q)}assertCanSetRequestHandler(Q){if(this._requestHandlers.has(Q))throw Error(`A request handler for ${Q} already exists, which would be overridden`)}setNotificationHandler(Q,Y){let X=P9(Q);this._notificationHandlers.set(X,(W)=>{let G=I9(Q,W);return Promise.resolve(Y(G))})}removeNotificationHandler(Q){this._notificationHandlers.delete(Q)}_cleanupTaskProgressHandler(Q){let Y=this._taskProgressTokens.get(Q);if(Y!==void 0)this._progressHandlers.delete(Y),this._taskProgressTokens.delete(Q)}async _enqueueTaskMessage(Q,Y,X){if(!this._taskStore||!this._taskMessageQueue)throw Error("Cannot enqueue task message: taskStore and taskMessageQueue are not configured");let W=this._options?.maxTaskQueueSize;await this._taskMessageQueue.enqueue(Q,Y,X,W)}async _clearTaskQueue(Q,Y){if(this._taskMessageQueue){let X=await this._taskMessageQueue.dequeueAll(Q,Y);for(let W of X)if(W.type==="request"&&z9(W.message)){let G=W.message.id,$=this._requestResolvers.get(G);if($)$(new k(g.InternalError,"Task cancelled or completed")),this._requestResolvers.delete(G);else this._onerror(Error(`Resolver missing for request ${G} during task ${Q} cleanup`))}}}async _waitForTaskUpdate(Q,Y){let X=this._options?.defaultTaskPollInterval??1000;try{let W=await this._taskStore?.getTask(Q);if(W?.pollInterval)X=W.pollInterval}catch{}return new Promise((W,G)=>{if(Y.aborted){G(new k(g.InvalidRequest,"Request cancelled"));return}let $=setTimeout(W,X);Y.addEventListener("abort",()=>{clearTimeout($),G(new k(g.InvalidRequest,"Request cancelled"))},{once:!0})})}requestTaskStore(Q,Y){let X=this._taskStore;if(!X)throw Error("No task store configured");return{createTask:async(W)=>{if(!Q)throw Error("No request provided");return await X.createTask(W,Q.id,{method:Q.method,params:Q.params},Y)},getTask:async(W)=>{let G=await X.getTask(W,Y);if(!G)throw new k(g.InvalidParams,"Failed to retrieve task: Task not found");return G},storeTaskResult:async(W,G,$)=>{await X.storeTaskResult(W,G,$,Y);let J=await X.getTask(W,Y);if(J){let z=L4.parse({method:"notifications/tasks/status",params:J});if(await this.notification(z),z1(J.status))this._cleanupTaskProgressHandler(W)}},getTaskResult:(W)=>{return X.getTaskResult(W,Y)},updateTaskStatus:async(W,G,$)=>{let J=await X.getTask(W,Y);if(!J)throw new k(g.InvalidParams,`Task "${W}" not found - it may have been cleaned up`);if(z1(J.status))throw new k(g.InvalidParams,`Cannot update task "${W}" from terminal status "${J.status}" to "${G}". Terminal states (completed, failed, cancelled) cannot transition to other states.`);await X.updateTaskStatus(W,G,$,Y);let z=await X.getTask(W,Y);if(z){let H=L4.parse({method:"notifications/tasks/status",params:z});if(await this.notification(H),z1(z.status))this._cleanupTaskProgressHandler(W)}},listTasks:(W)=>{return X.listTasks(W,Y)}}}}function pG(Q){return Q!==null&&typeof Q==="object"&&!Array.isArray(Q)}function iG(Q,Y){let X={...Q};for(let W in Y){let G=W,$=Y[G];if($===void 0)continue;let J=X[G];if(pG(J)&&pG($))X[G]={...J,...$};else X[G]=$}return X}var w5=oY(NY(),1),b5=oY(N5(),1);function kM(){let Q=new w5.default({strict:!1,validateFormats:!0,validateSchema:!1,allErrors:!0});return b5.default(Q),Q}class CY{constructor(Q){this._ajv=Q??kM()}getValidator(Q){let Y="$id"in Q&&typeof Q.$id==="string"?this._ajv.getSchema(Q.$id)??this._ajv.compile(Q):this._ajv.compile(Q);return(X)=>{if(Y(X))return{valid:!0,data:X,errorMessage:void 0};else return{valid:!1,data:void 0,errorMessage:this._ajv.errorsText(Y.errors)}}}}class kY{constructor(Q){this._server=Q}requestStream(Q,Y,X){return this._server.requestStream(Q,Y,X)}async getTask(Q,Y){return this._server.getTask({taskId:Q},Y)}async getTaskResult(Q,Y,X){return this._server.getTaskResult({taskId:Q},Y,X)}async listTasks(Q,Y){return this._server.listTasks(Q?{cursor:Q}:void 0,Y)}async cancelTask(Q,Y){return this._server.cancelTask({taskId:Q},Y)}}function j5(Q,Y,X){if(!Q)throw Error(`${X} does not support task creation (required for ${Y})`);switch(Y){case"tools/call":if(!Q.tools?.call)throw Error(`${X} does not support task creation for tools/call (required for ${Y})`);break;default:break}}function P5(Q,Y,X){if(!Q)throw Error(`${X} does not support task creation (required for ${Y})`);switch(Y){case"sampling/createMessage":if(!Q.sampling?.createMessage)throw Error(`${X} does not support task creation for sampling/createMessage (required for ${Y})`);break;case"elicitation/create":if(!Q.elicitation?.create)throw Error(`${X} does not support task creation for elicitation/create (required for ${Y})`);break;default:break}}class vY extends E9{constructor(Q,Y){super(Y);if(this._serverInfo=Q,this._loggingLevels=new Map,this.LOG_LEVEL_SEVERITY=new Map(O4.options.map((X,W)=>[X,W])),this.isMessageIgnored=(X,W)=>{let G=this._loggingLevels.get(W);return G?this.LOG_LEVEL_SEVERITY.get(X)<this.LOG_LEVEL_SEVERITY.get(G):!1},this._capabilities=Y?.capabilities??{},this._instructions=Y?.instructions,this._jsonSchemaValidator=Y?.jsonSchemaValidator??new CY,this.setRequestHandler(A9,(X)=>this._oninitialize(X)),this.setNotificationHandler(B9,()=>this.oninitialized?.()),this._capabilities.logging)this.setRequestHandler(N9,async(X,W)=>{let G=W.sessionId||W.requestInfo?.headers["mcp-session-id"]||void 0,{level:$}=X.params,J=O4.safeParse($);if(J.success)this._loggingLevels.set(G,J.data);return{}})}get experimental(){if(!this._experimental)this._experimental={tasks:new kY(this)};return this._experimental}registerCapabilities(Q){if(this.transport)throw Error("Cannot register capabilities after connecting to transport");this._capabilities=iG(this._capabilities,Q)}setRequestHandler(Q,Y){let W=B6(Q)?.method;if(!W)throw Error("Schema is missing a method literal");let G;if(R1(W)){let J=W;G=J._zod?.def?.value??J.value}else{let J=W;G=J._def?.value??J.value}if(typeof G!=="string")throw Error("Schema method literal must be a string");if(G==="tools/call"){let J=async(z,H)=>{let U=$1(F4,z);if(!U.success){let L=U.error instanceof Error?U.error.message:String(U.error);throw new k(g.InvalidParams,`Invalid tools/call request: ${L}`)}let{params:A}=U.data,B=await Promise.resolve(Y(z,H));if(A.task){let L=$1(k1,B);if(!L.success){let O=L.error instanceof Error?L.error.message:String(L.error);throw new k(g.InvalidParams,`Invalid task creation result: ${O}`)}return L.data}let K=$1(E6,B);if(!K.success){let L=K.error instanceof Error?K.error.message:String(K.error);throw new k(g.InvalidParams,`Invalid tools/call result: ${L}`)}return K.data};return super.setRequestHandler(Q,J)}return super.setRequestHandler(Q,Y)}assertCapabilityForMethod(Q){switch(Q){case"sampling/createMessage":if(!this._clientCapabilities?.sampling)throw Error(`Client does not support sampling (required for ${Q})`);break;case"elicitation/create":if(!this._clientCapabilities?.elicitation)throw Error(`Client does not support elicitation (required for ${Q})`);break;case"roots/list":if(!this._clientCapabilities?.roots)throw Error(`Client does not support listing roots (required for ${Q})`);break;case"ping":break}}assertNotificationCapability(Q){switch(Q){case"notifications/message":if(!this._capabilities.logging)throw Error(`Server does not support logging (required for ${Q})`);break;case"notifications/resources/updated":case"notifications/resources/list_changed":if(!this._capabilities.resources)throw Error(`Server does not support notifying about resources (required for ${Q})`);break;case"notifications/tools/list_changed":if(!this._capabilities.tools)throw Error(`Server does not support notifying of tool list changes (required for ${Q})`);break;case"notifications/prompts/list_changed":if(!this._capabilities.prompts)throw Error(`Server does not support notifying of prompt list changes (required for ${Q})`);break;case"notifications/elicitation/complete":if(!this._clientCapabilities?.elicitation?.url)throw Error(`Client does not support URL elicitation (required for ${Q})`);break;case"notifications/cancelled":break;case"notifications/progress":break}}assertRequestHandlerCapability(Q){if(!this._capabilities)return;switch(Q){case"completion/complete":if(!this._capabilities.completions)throw Error(`Server does not support completions (required for ${Q})`);break;case"logging/setLevel":if(!this._capabilities.logging)throw Error(`Server does not support logging (required for ${Q})`);break;case"prompts/get":case"prompts/list":if(!this._capabilities.prompts)throw Error(`Server does not support prompts (required for ${Q})`);break;case"resources/list":case"resources/templates/list":case"resources/read":if(!this._capabilities.resources)throw Error(`Server does not support resources (required for ${Q})`);break;case"tools/call":case"tools/list":if(!this._capabilities.tools)throw Error(`Server does not support tools (required for ${Q})`);break;case"tasks/get":case"tasks/list":case"tasks/result":case"tasks/cancel":if(!this._capabilities.tasks)throw Error(`Server does not support tasks capability (required for ${Q})`);break;case"ping":case"initialize":break}}assertTaskCapability(Q){P5(this._clientCapabilities?.tasks?.requests,Q,"Client")}assertTaskHandlerCapability(Q){if(!this._capabilities)return;j5(this._capabilities.tasks?.requests,Q,"Server")}async _oninitialize(Q){let Y=Q.params.protocolVersion;return this._clientCapabilities=Q.params.capabilities,this._clientVersion=Q.params.clientInfo,{protocolVersion:EG.includes(Y)?Y:$9,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"},O6)}async createMessage(Q,Y){if(Q.tools||Q.toolChoice){if(!this._clientCapabilities?.sampling?.tools)throw Error("Client does not support sampling tools capability.")}if(Q.messages.length>0){let X=Q.messages[Q.messages.length-1],W=Array.isArray(X.content)?X.content:[X.content],G=W.some((H)=>H.type==="tool_result"),$=Q.messages.length>1?Q.messages[Q.messages.length-2]:void 0,J=$?Array.isArray($.content)?$.content:[$.content]:[],z=J.some((H)=>H.type==="tool_use");if(G){if(W.some((H)=>H.type!=="tool_result"))throw Error("The last message must contain only tool_result content if any is present");if(!z)throw Error("tool_result blocks are not matching any tool_use from the previous message")}if(z){let H=new Set(J.filter((A)=>A.type==="tool_use").map((A)=>A.id)),U=new Set(W.filter((A)=>A.type==="tool_result").map((A)=>A.toolUseId));if(H.size!==U.size||![...H].every((A)=>U.has(A)))throw Error("ids of tool_result blocks and tool_use blocks from previous message do not match")}}if(Q.tools)return this.request({method:"sampling/createMessage",params:Q},b9,Y);return this.request({method:"sampling/createMessage",params:Q},w9,Y)}async elicitInput(Q,Y){switch(Q.mode??"form"){case"url":{if(!this._clientCapabilities?.elicitation?.url)throw Error("Client does not support url elicitation.");let W=Q;return this.request({method:"elicitation/create",params:W},T6,Y)}case"form":{if(!this._clientCapabilities?.elicitation?.form)throw Error("Client does not support form elicitation.");let W=Q.mode==="form"?Q:{...Q,mode:"form"},G=await this.request({method:"elicitation/create",params:W},T6,Y);if(G.action==="accept"&&G.content&&W.requestedSchema)try{let J=this._jsonSchemaValidator.getValidator(W.requestedSchema)(G.content);if(!J.valid)throw new k(g.InvalidParams,`Elicitation response content does not match requested schema: ${J.errorMessage}`)}catch($){if($ instanceof k)throw $;throw new k(g.InternalError,`Error validating elicitation response: ${$ instanceof Error?$.message:String($)}`)}return G}}}createElicitationCompletionNotifier(Q,Y){if(!this._clientCapabilities?.elicitation?.url)throw Error("Client does not support URL elicitation (required for notifications/elicitation/complete)");return()=>this.notification({method:"notifications/elicitation/complete",params:{elicitationId:Q}},Y)}async listRoots(Q,Y){return this.request({method:"roots/list",params:Q},j9,Y)}async sendLoggingMessage(Q,Y){if(this._capabilities.logging){if(!this.isMessageIgnored(Q.level,Y))return this.notification({method:"notifications/message",params:Q})}}async sendResourceUpdated(Q){return this.notification({method:"notifications/resources/updated",params:Q})}async sendResourceListChanged(){return this.notification({method:"notifications/resources/list_changed"})}async sendToolListChanged(){return this.notification({method:"notifications/tools/list_changed"})}async sendPromptListChanged(){return this.notification({method:"notifications/prompts/list_changed"})}}var I5={name:"@sequenzy/mcp",version:"0.0.54",mcpName:"io.github.sequenzy/mcp",description:"Sequenzy MCP server for AI-powered email marketing automation",type:"module",bin:{"sequenzy-mcp":"dist/index.js"},main:"./dist/index.js",exports:{".":"./dist/index.js","./server":"./dist/server.js","./runtime":"./dist/runtime.js","./server.json":"./server.json"},scripts:{dev:"bun --watch src/index.ts",build:"bun build src/index.ts src/server.ts src/runtime.ts --outdir dist --target node --minify",start:"node dist/index.js","type-check":"tsc --noEmit",test:"bun test","test:watch":"bun test --watch",prepublishOnly:"bun run build"},dependencies:{"@modelcontextprotocol/sdk":"^1.0.0"},devDependencies:{"@types/bun":"latest","@types/node":"^22.0.0","bun-types":"latest",typescript:"^5.8.0"},files:["dist","server.json"],keywords:["sequenzy","email","mcp","ai","claude","automation"],license:"MIT",publishConfig:{access:"public"},repository:{type:"git",url:"git+https://github.com/Sequenzy/mcp.git"},homepage:"https://sequenzy.com",bugs:{url:"https://github.com/Sequenzy/mcp/issues"}};var xY=["product-info","domain","tracking","localization","integrations","products","events","tags","labels","goals","sync-rules","api-keys","widgets","team","danger"],E5={dashboard:"/dashboard/company/{companyId}",campaigns:"/dashboard/company/{companyId}/campaign",campaign:"/dashboard/company/{companyId}/campaign/{campaignId}",campaignPreview:"/dashboard/company/{companyId}/campaign/{campaignId}?step=review",campaignList:"/dashboard/company/{companyId}/campaign/list/{status}",sequences:"/dashboard/company/{companyId}/sequences",sequence:"/dashboard/company/{companyId}/sequences/{sequenceId}",sequenceList:"/dashboard/company/{companyId}/sequences/list/{status}",settings:"/dashboard/company/{companyId}/settings",settingsTab:"/dashboard/company/{companyId}/settings?tab={tab}",emails:"/dashboard/company/{companyId}/emails",email:"/dashboard/company/{companyId}/emails/{emailId}",subscribers:"/dashboard/company/{companyId}/subscribers",sentEmails:"/dashboard/company/{companyId}/sent-emails",emailSend:"/dashboard/company/{companyId}/sent-emails/{emailSendId}",segments:"/dashboard/company/{companyId}/segments",metrics:"/dashboard/company/{companyId}/metrics",transactional:"/dashboard/company/{companyId}/transactional",transactionalEmail:"/dashboard/company/{companyId}/transactional/{transactionalId}",domain:"/dashboard/company/{companyId}/settings/domain/{domainId}",domainVerify:"/dashboard/company/{companyId}/settings/domain/{domainId}/verify"};function xM(Q){let X=(Q??process.env.SEQUENZY_APP_URL??"https://sequenzy.com").trim().replace(/\/+$/,"");return X.length>0?X:"https://sequenzy.com"}function f0(Q){let Y=Q?.trim();return Y?Y:void 0}function a0(Q){return encodeURIComponent(Q)}function Y0(Q,Y){return`${Q}${Y}`}function X0(Q,Y=""){return`/dashboard/company/${a0(Q)}${Y}`}function T5(Q,Y,X){return Y0(Q,`${X0(Y,"/settings")}?tab=${encodeURIComponent(X)}`)}function _M(Q,Y){let X=xY.map((W)=>[W,Y?T5(Q,Y,W):""]);return Object.fromEntries(X)}function q1(Q={},Y){let X=xM(Y),W=f0(Q.companyId),G={},$=_M(X,W);if(!W)return{appUrl:X,routeTemplates:E5,settingsTabValues:xY,urls:G,settingsUrls:$};G.dashboard=Y0(X,X0(W)),G.campaigns=Y0(X,X0(W,"/campaign")),G.sequences=Y0(X,X0(W,"/sequences")),G.settings=Y0(X,X0(W,"/settings")),G.emails=Y0(X,X0(W,"/emails")),G.subscribers=Y0(X,X0(W,"/subscribers")),G.sentEmails=Y0(X,X0(W,"/sent-emails")),G.segments=Y0(X,X0(W,"/segments")),G.metrics=Y0(X,X0(W,"/metrics")),G.transactional=Y0(X,X0(W,"/transactional"));let J=f0(Q.campaignId);if(J)G.campaign=Y0(X,X0(W,`/campaign/${a0(J)}`)),G.campaignPreview=`${G.campaign}?step=review`;let z=f0(Q.sequenceId);if(z)G.sequence=Y0(X,X0(W,`/sequences/${a0(z)}`));let H=f0(Q.emailId)??f0(Q.templateId);if(H)G.email=Y0(X,X0(W,`/emails/${a0(H)}`)),G.template=G.email;let U=f0(Q.transactionalId);if(U)G.transactionalEmail=Y0(X,X0(W,`/transactional/${a0(U)}`));let A=f0(Q.emailSendId);if(A)G.emailSend=Y0(X,X0(W,`/sent-emails/${a0(A)}`));let B=f0(Q.domainId);if(B)G.domain=Y0(X,X0(W,`/settings/domain/${a0(B)}`)),G.domainVerify=`${G.domain}/verify`;let K=f0(Q.status);if(K)G.campaignList=Y0(X,X0(W,`/campaign/list/${a0(K)}`)),G.sequenceList=Y0(X,X0(W,`/sequences/list/${a0(K)}`));let L=f0(Q.settingsTab);if(L)G.settingsTab=T5(X,W,L);return{appUrl:X,routeTemplates:E5,settingsTabValues:xY,urls:G,settingsUrls:$}}var S5=[{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 R5(Q){try{let Y;switch(Q){case"sequenzy://dashboard":Y=await F("GET","/api/v1/metrics?period=7d");break;case"sequenzy://company":{let X=await F("GET","/api/v1/account"),W=Q1()??X.currentCompanyId;if(!W)throw Error("No company available. Create or select a company first.");Y=await F("GET",`/api/v1/companies/${W}`);break}case"sequenzy://campaigns/recent":Y=await F("GET","/api/v1/campaigns?limit=10");break;case"sequenzy://subscribers/recent":Y=await F("GET","/api/v1/subscribers?sort=createdAt&limit=20");break;case"sequenzy://subscribers/engaged":Y=await F("GET","/api/v1/subscribers?sort=engagement&limit=20");break;case"sequenzy://sequences":Y=await F("GET","/api/v1/sequences");break;case"sequenzy://templates":Y=await F("GET","/api/v1/templates");break;case"sequenzy://segments":Y=await F("GET","/api/v1/segments");break;case"sequenzy://tags":Y=await F("GET","/api/v1/tags");break;case"sequenzy://health":Y=await F("GET","/api/v1/health/deliverability");break;case"sequenzy://app-routes":Y=q1();break;default:throw Error(`Unknown resource: ${Q}`)}return{contents:[{uri:Q,mimeType:"application/json",text:JSON.stringify(Y,null,2)}]}}catch(Y){return{contents:[{uri:Q,mimeType:"text/plain",text:e0(Y)}]}}}import{readFileSync as yM,statSync as gM}from"node:fs";import{basename as uM}from"node:path";var m4="Sequenzy email blocks. Use `styles` for per-block background, background opacity, text color, padding, border radius, border width, and border color. Top-level style aliases such as `backgroundColor`, `backgroundOpacity`, `borderColor`, `borderWidth`, and `borderRadius` are also accepted and saved under `styles`. Use this for editor-compatible content, including conditional and repeat blocks. Repeat blocks use { type: 'repeat', source: 'items', itemAlias: 'item', children: [...] }.",i1="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`.",u5="Sequenzy email blocks. Provide blocks or html for email steps. Use `styles` for per-block background, background opacity, text color, padding, border radius, border width, and border color. Top-level style aliases such as `backgroundColor`, `backgroundOpacity`, `borderColor`, `borderWidth`, and `borderRadius` are also accepted and saved under `styles`. Blocks can include repeat blocks over array variables such as items.",C5=500,qQ=["gray","red","orange","amber","yellow","lime","green","emerald","teal","cyan","sky","blue","indigo","violet","purple","fuchsia","pink","rose"],FQ=["email.sent","email.delivered","email.delivery_delayed","email.bounced","email.complained","email.opened","email.clicked","email.unsubscribed","subscriber.invalid","subscriber.updated","subscriber.unsubscribed","sequence.finished","sequence.failed"],uY={status:["is","is_not"],tag:["contains","not_contains","is_empty","is_not_empty"],email:["contains","not_contains"],emailProvider:["is","is_not","is_empty","is_not_empty"],added:["less_than","more_than"],firstName:["contains","not_contains","is_empty","is_not_empty"],lastName:["contains","not_contains","is_empty","is_not_empty"],list:["is","is_not","is_empty","is_not_empty"],emailSent:["is","is_not","at_least","less_than_count"],emailDelivered:["is","is_not","at_least","less_than_count"],emailOpened:["is","is_not","at_least","less_than_count"],emailClicked:["is","is_not","at_least","less_than_count"],emailBounced:["is","is_temporary_bounce","is_permanent_bounce","is_not","at_least","less_than_count"],emailComplained:["is","is_not","at_least","less_than_count"],attribute:["is","is_not","is_empty","is_not_empty","gte","lte","gt","lt","contains","not_contains"],event:["is","is_not","at_least","less_than_count"],segment:["is","is_not"],stripeProduct:["is","is_not","at_least","less_than_count"],stripeCurrentProduct:["is","is_not","gte","lte","gt","lt"],stripeTrialProduct:["is","is_not","gte","lte","gt","lt"]},hM=Object.entries(uY).map(([Q,Y])=>`${Q}: ${Y.join(", ")}`).join("; "),k5={type:"object",properties:{id:{type:"string",description:"Optional filter ID. Any stable string works; one will be generated if omitted."},field:{type:"string",enum:["status","tag","email","emailProvider","added","firstName","lastName","list","emailSent","emailDelivered","emailOpened","emailClicked","emailBounced","emailComplained","attribute","event","segment","stripeProduct","stripeCurrentProduct","stripeTrialProduct"],description:"Filter field. Use `event` for custom subscriber events, `segment` for saved segment membership, and `stripeProduct`/`stripeCurrentProduct`/`stripeTrialProduct` for Stripe product-based segments. Engagement fields (`emailSent`, `emailDelivered`, `emailOpened`, `emailClicked`, `emailBounced`, `emailComplained`) accept a time range as the value or a specific campaign via `campaign:<campaign_id>`."},operator:{type:"string",enum:["is","is_not","is_empty","is_not_empty","contains","not_contains","less_than","more_than","is_temporary_bounce","is_permanent_bounce","at_least","less_than_count","gte","lte","gt","lt"],description:`Filter operator. Allowed operators by field: ${hM}.`},value:{type:"string",description:"Filter value. For custom attribute empty checks, use `attributeName:` such as `last_logged_in:`. Event examples: `saas.purchase:30d`, `saas.purchase:all`, or `saas.purchase:5:30d` for thresholds. Segment values are segment IDs. Stripe product examples: `prod_123` for bought/didn't buy/current/trialing, `prod_123:3` for payment thresholds, `prod_123:is_canceled` for products set to cancel, `prod_123:cancels_at:2026-05-26`, `prod_123:end_at:2026-05-26`, or `prod_123:start_at:7 days ago` for product-scoped dates. Engagement examples: `7d`, `30d`, `90d`, `180d`, `all` for rolling time windows, or `campaign:<campaign_id>` to scope to a specific sent campaign (use `list_campaigns` to find IDs)."}},required:["field","operator","value"],additionalProperties:!1},v5={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 hY(Q){if(!Array.isArray(Q))return Q;return Q.map((Y)=>{if(typeof Y!=="object"||Y===null)return Y;let X=Y;if(typeof X.id==="string"&&X.id.trim()!=="")return X;return{...X,id:crypto.randomUUID()}})}function fY(Q){if(typeof Q!=="object"||Q===null)return Q;let Y=Q;if(Y.kind==="filter"||"field"in Y||"operator"in Y||"value"in Y){let X=hY([Y]);return Array.isArray(X)?X[0]:Y}if(Y.kind!=="group")return Q;return{...Y,id:typeof Y.id==="string"&&Y.id.trim()!==""?Y.id:crypto.randomUUID(),children:Array.isArray(Y.children)?Y.children.map(fY):[]}}function fM(Q){let Y=Q.indexOf(":");return Y!==-1&&Q.substring(0,Y).trim().length>0}function lM(Q){let Y=Q.indexOf(":");return Y!==-1&&Q.substring(Y+1).trim().length>0}function x5(Q){if(Q==="all")return!0;let Y=Q.match(/^(\d+)d$/);if(!Y?.[1])return!1;let X=Number.parseInt(Y[1],10);return Number.isInteger(X)&&X>0}function mM(Q,Y){let X=Y.split(":");if(Q==="at_least"||Q==="less_than_count"){if(X.length<3)return'Event count filters must use "eventName:count:timeRange", like "saas.purchase:2:30d".';let $=X.slice(0,-2).join(":").trim(),J=X.at(-2),z=X.at(-1),H=J===void 0?Number.NaN:Number.parseInt(J,10);return $&&Number.isInteger(H)&&H>0&&z!==void 0&&x5(z)?null:'Event count filters must use "eventName:count:timeRange", like "saas.purchase:2:30d".'}if(X.length<2)return'Event filters must use "eventName:timeRange", like "saas.purchase:30d".';let W=X.slice(0,-1).join(":").trim(),G=X.at(-1);return W&&G!==void 0&&x5(G)?null:'Event filters must use "eventName:timeRange", like "saas.purchase:30d".'}function cM(Q){let Y=Q.indexOf(":");if(Y===-1)return{productId:Q,subfilter:null,rawValue:null};let X=Q.substring(0,Y),W=Q.substring(Y+1),G=W.indexOf(":");if(G===-1)return{productId:X,subfilter:W,rawValue:null};return{productId:X,subfilter:W.substring(0,G),rawValue:W.substring(G+1)}}function pM(Q){return Q.trim().toLowerCase().replace(/[-\s]+/g,"_")}function iM(Q){return["is_canceled","is_cancelled","canceled","cancelled","will_cancel","cancel_at_period_end","is_not_canceled","is_not_cancelled","not_canceled","not_cancelled","will_not_cancel"].includes(Q)}function nM(Q,Y){if(Y==="cancels_at"||Y==="cancel_at"||Y==="cancellation_at")return!0;if(Q==="stripeCurrentProduct")return["end_at","ends_at","period_end","period_ends_at","current_period_end"].includes(Y);return["start_at","started_at","trial_start","trial_started_at","end_at","ends_at","trial_end","trial_ends_at"].includes(Y)}function rM(Q){return["is","is_not","gte","lte","gt","lt"].includes(Q)}function dM(Q,Y,X){if(Q==="stripeProduct"){if(Y!=="at_least"&&Y!=="less_than_count")return null;let z=X.indexOf(":");if(z===-1)return null;let H=X.substring(0,z).trim(),U=Number.parseInt(X.substring(z+1).trim(),10);return H&&Number.isInteger(U)&&U>=1?null:'Stripe Product threshold filters must use "productId:count" with a count of at least 1.'}if(Q!=="stripeCurrentProduct"&&Q!=="stripeTrialProduct")return null;let{productId:W,subfilter:G,rawValue:$}=cM(X);if(!W.trim())return"Stripe product filters must include a product ID.";if(!G)return Y==="is"||Y==="is_not"?null:'Stripe current/trial date filters must use "productId:dateField:value".';let J=pM(G);if(iM(J))return Y==="is"||Y==="is_not"?null:"Stripe cancellation flag filters only support is and is_not operators.";if(!nM(Q,J))return`Unsupported Stripe product subfilter "${G}".`;if(!rM(Y))return"Stripe date filters only support is, is_not, gte, lte, gt, and lt operators.";return $?.trim()?null:'Stripe date filters must include a value like "productId:end_at:2026-05-26".'}function mY(Q){if(typeof Q!=="object"||Q===null)return"Segment filters must be objects.";let Y=Q,X=Y.field,W=Y.operator,G=Y.value;if(typeof X!=="string"||!(X in uY))return`Unsupported segment filter field "${String(X)}".`;if(typeof W!=="string")return`Segment filter "${X}" must include an operator.`;let $=uY[X];if(!$.includes(W))return`Operator "${W}" is not supported for ${X} filters. Use one of: ${$.join(", ")}.`;if(W!=="is_empty"&&W!=="is_not_empty"&&(typeof G!=="string"||G.trim().length===0))return`Segment filter "${X}" must include a value.`;if(X==="attribute"&&typeof G==="string"){if(!fM(G))return'Attribute filters must use "attributeName:value" or "attributeName:" for empty checks.';if(W!=="is_empty"&&W!=="is_not_empty"&&!lM(G))return'Attribute filters must include a value after "attributeName:".'}if(X==="event"&&typeof G==="string"){let J=mM(W,G);if(J)return J}if((X==="stripeProduct"||X==="stripeCurrentProduct"||X==="stripeTrialProduct")&&typeof G==="string"){let J=dM(X,W,G);if(J)return J}if(X==="tag"&&(W==="contains"||W==="not_contains")){if(!(typeof G==="string"&&G.split(",").map((z)=>z.trim()).some(Boolean)))return"Tag filters must include at least one tag name."}return null}function cY(Q){if(typeof Q!=="object"||Q===null)return[];let Y=Q;if(Y.kind==="filter"||"field"in Y||"operator"in Y||"value"in Y){let X=mY(Y);return X?[X]:[]}if(Array.isArray(Y.children))return Y.children.flatMap(cY);return[]}function P1(Q,Y,X){if(Y.html!==void 0&&Y.blocks!==void 0)throw Error(`Provide either \`html\` or \`blocks\` when calling \`${Q}\`, not both.`);if(Y.blocks!==void 0&&!Array.isArray(Y.blocks))throw Error(`\`blocks\` must be an array when calling \`${Q}\`.`);if(X?.requireContent&&Y.html===void 0&&Y.blocks===void 0)throw Error(`Provide either \`html\` or \`blocks\` when calling \`${Q}\`.`)}function LQ(Q,Y){if(Y.labels===void 0)return;if(!Array.isArray(Y.labels))throw Error(`\`labels\` must be an array when calling \`${Q}\`.`);if(Y.labels.some((X)=>typeof X!=="string"||X.trim().length===0))throw Error(`\`labels\` must contain only non-empty strings when calling \`${Q}\`.`)}function oM(Q){let Y=Q.filters!==void 0,X=Q.root!==void 0;if(Y&&X)throw Error("Provide either `filters` or `root` when calling `create_segment`, not both.");if(!Y&&!X)throw Error("Provide either `filters` or `root` when calling `create_segment`.");if(Y){if(!Array.isArray(Q.filters))throw Error("`filters` must be an array when calling `create_segment`.");if(Q.filters.length===0)throw Error("`filters` must include at least one filter when calling `create_segment`.")}if(X&&(typeof Q.root!=="object"||Q.root===null))throw Error("`root` must be an object when calling `create_segment`.");let W=Y?Q.filters.flatMap((G)=>{let $=mY(G);return $?[$]:[]}):cY(Q.root);if(W.length>0)throw Error(W[0]??"Invalid segment filter in `create_segment`.")}function tM(Q){let Y=Q.filters!==void 0,X=Q.root!==void 0;if(Y&&X)throw Error("Provide either `filters` or `root` when calling `update_segment`, not both.");if(Q.name===void 0&&Q.filterJoinOperator===void 0&&!Y&&!X)throw Error("Provide at least one of `name`, `filters`, `root`, or `filterJoinOperator` when calling `update_segment`.");if(Y){if(!Array.isArray(Q.filters))throw Error("`filters` must be an array when calling `update_segment`.");if(Q.filters.length===0)throw Error("`filters` must include at least one filter when calling `update_segment`.")}if(X&&(typeof Q.root!=="object"||Q.root===null))throw Error("`root` must be an object when calling `update_segment`.");let W=Y?Q.filters.flatMap((G)=>{let $=mY(G);return $?[$]:[]}):X?cY(Q.root):[];if(W.length>0)throw Error(W[0]??"Invalid segment filter in `update_segment`.")}function aM(Q){if(Q.clearEnrollmentFieldPath===!0&&Q.enrollmentFieldPath!==void 0)throw Error("Provide either `enrollmentFieldPath` or `clearEnrollmentFieldPath` when calling `update_sequence`, not both.");let Y={...Q};if(delete Y.clearEnrollmentFieldPath,Q.clearEnrollmentFieldPath===!0)Y.enrollmentFieldPath=null;return Y}function sM(Q){let Y=N(Q,"subscriberId"),X=Q.fieldValues,W=X===void 0?void 0:Array.isArray(X)?X:void 0;if(X!==void 0&&W===void 0)throw Error("`fieldValues` must be an array when calling `cancel_sequence_enrollments`.");let G=W?.map((z)=>typeof z==="string"?z.trim():"").filter((z)=>z.length>0)??[];if(W?.some((z)=>typeof z!=="string")||W!==void 0&&G.length===0)throw Error("`fieldValues` must contain at least one non-empty string when calling `cancel_sequence_enrollments`.");if(Y!==void 0===G.length>0)throw Error("Provide exactly one target when calling `cancel_sequence_enrollments`: `subscriberId` or `fieldValues`.");let $=N(Q,"fieldPath"),J=N(Q,"reason");return{...Y!==void 0&&{subscriberId:Y},...$!==void 0&&{fieldPath:$},...G.length>0&&{fieldValues:G},...typeof Q.dryRun==="boolean"&&{dryRun:Q.dryRun},...J!==void 0&&{reason:J}}}function eM(Q){P1("create_campaign",Q),LQ("create_campaign",Q);let Y=N(Q,"prompt")!==void 0,X=Q.html!==void 0,W=Q.blocks!==void 0,G=Q.templateId!==void 0;if(Q.prompt!==void 0&&!Y)throw Error("`prompt` cannot be empty when calling `create_campaign`.");if(Y&&(X||W||G))throw Error("Provide either `prompt`, `html`, `blocks`, or `templateId` when calling `create_campaign`, not multiple content sources.");if(!Y&&(Q.style!==void 0||Q.tone!==void 0))throw Error("`style` and `tone` can only be used with `prompt` when calling `create_campaign`.");if(!Y&&N(Q,"subject")===void 0)throw Error("`subject` is required unless `prompt` is provided when calling `create_campaign`.")}function QV(Q){if(N(Q,"scheduledAt")===void 0)throw Error("`scheduledAt` is required when calling `schedule_campaign`.");if(Q.targetLists!==void 0&&!B0(Q.targetLists))throw Error("`targetLists` must be an object when calling `schedule_campaign`.");if(Q.sendTimeOptimization!==void 0){if(typeof Q.sendTimeOptimization!=="boolean")throw Error("`sendTimeOptimization` must be a boolean when calling `schedule_campaign`.")}if(Q.spreadOverHours!==void 0){if(typeof Q.spreadOverHours!=="number"||!Number.isInteger(Q.spreadOverHours)||Q.spreadOverHours<1||Q.spreadOverHours>72)throw Error("`spreadOverHours` must be an integer between 1 and 72 when calling `schedule_campaign`.")}}function YV(Q){P1("create_transactional_email",Q);let Y=N(Q,"prompt")!==void 0,X=Q.html!==void 0,W=Q.blocks!==void 0;if(Q.prompt!==void 0&&!Y)throw Error("`prompt` cannot be empty when calling `create_transactional_email`.");if(Y&&(X||W))throw Error("Provide either `prompt`, `html`, or `blocks` when calling `create_transactional_email`, not multiple content sources.");if(!Y&&(Q.style!==void 0||Q.tone!==void 0))throw Error("`style` and `tone` can only be used with `prompt` when calling `create_transactional_email`.");if(!Y&&!X&&!W)throw Error("Provide either `prompt`, `html`, or `blocks` when calling `create_transactional_email`.");if(!Y&&N(Q,"subject")===void 0)throw Error("`subject` is required unless `prompt` is provided when calling `create_transactional_email`.")}var _5={type:"object",description:"A step to create inside a branch path. Use type:'delay' for a standalone delay, type:'email' for an email, or type:'create_discount' for a discount action.",properties:{type:{type:"string",enum:["email","delay","create_discount","discount","webhook"],description:"Branch path step type. Omit for email steps; use delay for standalone waits."},nodeType:{type:"string",enum:["logic_delay","action_email","action_create_discount","action_add_tag","action_remove_tag","action_add_to_list","action_remove_from_list","action_update_attributes","logic_wait_for_event","action_webhook"],description:"Advanced branch path node type. Prefer type unless creating a non-email action."},config:{type:"object",description:"Config for advanced nodeType steps such as tag/list/webhook/wait-for-event actions.",additionalProperties:!0},subject:{type:"string",description:"Email subject. Required for email steps."},previewText:{type:"string",description:"Email preview text."},blocks:{type:"array",description:u5,items:{type:"object"}},html:{type:"string",description:"HTML content for email steps."},delay:{type:"object",description:"Delay before this step, or the delay duration when type is delay.",properties:{days:{type:"number"},hours:{type:"number"},minutes:{type:"number"}}},delayMs:{type:"number",description:"Delay in milliseconds. Useful for standalone type:'delay' steps."},name:{type:"string",description:"Email template name for email steps."},discount:{type:"object",description:"Discount configuration for create_discount steps. Same shape as create_sequence steps.",additionalProperties:!0},label:{type:"string",description:"Node label for discount or advanced node steps."},provider:{type:"string",enum:["stripe","shopify"]},discountType:{type:"string",enum:["percent","amount"]},percentOff:{type:"number"},amountOff:{type:"number"},currency:{type:"string"},duration:{type:"string",enum:["once","forever","repeating"]},durationInMonths:{type:"number"},appliesToAllPlans:{type:"boolean"},planIds:{type:"array",items:{type:"string"}},codePrefix:{type:"string"},maxRedemptions:{type:"number"},lockToSubscriber:{type:"boolean"},expiresAt:{type:"string"},expiresInHours:{type:"number"}},additionalProperties:!1};function XV(Q){if(!Q||typeof Q!=="object")return null;let Y=Q;if(Y.success!==!1)return null;if(typeof Y.error==="string")return Error(Y.error);if(Y.error&&typeof Y.error==="object"&&typeof Y.error.message==="string")return Error(Y.error.message);if(typeof Y.message==="string")return Error(Y.message);return Error("The tool returned an unsuccessful response.")}function B0(Q){return typeof Q==="object"&&Q!==null&&!Array.isArray(Q)}function y5(Q){return Q.trim().toLowerCase().replace(/\s+/g,"-")}function WV(Q){let Y=new URLSearchParams;if(typeof Q.query==="string"&&Q.query.trim()!=="")Y.set("query",Q.query.trim());if(Array.isArray(Q.tags)&&Q.tags.length>0)Y.set("tags",Q.tags.filter((X)=>typeof X==="string"&&X.trim()!=="").join(","));if(typeof Q.list==="string"&&Q.list.trim()!=="")Y.set("list",Q.list.trim());if(typeof Q.listId==="string"&&Q.listId.trim()!=="")Y.set("listId",Q.listId.trim());if(typeof Q.listName==="string"&&Q.listName.trim()!=="")Y.set("listName",Q.listName.trim());if(typeof Q.segmentId==="string"&&Q.segmentId.trim()!=="")Y.set("segmentId",Q.segmentId);if(typeof Q.status==="string"&&Q.status.trim()!=="")Y.set("status",Q.status.trim());return Y.set("page",String(Q.page)),Y.set("limit",String(Q.pageSize)),Y}async function GV(Q,Y){let X=typeof Q.limit==="number"&&Number.isFinite(Q.limit)?Math.max(1,Math.trunc(Q.limit)):void 0,W=Math.min(100,Math.max(1,X??100)),G=[],$=1,J=0,z=0,H=0;while(!0){let A=WV({query:Q.query,tags:Q.tags,list:Q.list,listId:Q.listId,listName:Q.listName,segmentId:Q.segmentId,status:Q.status,page:$,pageSize:W}),B=await F("GET",`/api/v1/subscribers?${A.toString()}`,void 0,Y);J=B.pagination?.total??B.subscribers.length,z=B.pagination?.totalPages??1,H+=1,G.push(...B.subscribers??[]);let K=X!==void 0&&G.length>=X,L=B.pagination?$>=B.pagination.totalPages:(B.subscribers??[]).length<W;if(K||L)break;$+=1}let U=X!==void 0?G.slice(0,X):G;return{success:!0,subscribers:U,pagination:{page:1,limit:W,total:J,totalPages:z,fetchedPages:H},returned:U.length,truncated:X!==void 0&&J>0&&U.length<J}}function $V(Q){let Y=typeof Q.email==="string"&&Q.email.trim()!==""?Q.email.trim():void 0,X=typeof Q.externalId==="string"&&Q.externalId.trim()!==""?Q.externalId.trim():void 0;return{...Y?{email:Y}:{},...X?{externalId:X}:{}}}function c4(Q,Y){let X=$V(Y);if(!X.email&&!X.externalId)throw Error(`Provide either \`email\` or \`externalId\` when calling \`${Q}\`.`);return X}function lY(Q){if(Q.email)return`/api/v1/subscribers/${encodeURIComponent(Q.email)}`;return`/api/v1/subscribers/external?externalId=${encodeURIComponent(String(Q.externalId))}`}async function _Y(Q,Y){return F("GET",lY(Q),void 0,Y)}function N(Q,Y){let X=Q[Y];if(typeof X!=="string")return;let W=X.trim();return W.length>0?W:void 0}function x(Q,Y,X){let W=N(Y,X);if(W===void 0)throw Error(`\`${X}\` is required when calling \`${Q}\`.`);return W}function s0(Q,Y,X,W){let G=N(Y,X);if(G===void 0)return;if(!W.includes(G))throw Error(`\`${X}\` must be one of ${W.join(", ")} when calling \`${Q}\`.`);return G}function yY(Q,Y,X,W){let G=x(Q,Y,X);if(!W.includes(G))throw Error(`\`${X}\` must be one of ${W.join(", ")} when calling \`${Q}\`.`);return G}function p4(Q,Y,X,W,G){let $=Y[X];if($===void 0)return;if(typeof $!=="number"||!Number.isInteger($)||$<W||$>G)throw Error(`\`${X}\` must be an integer between ${W} and ${G} when calling \`${Q}\`.`);return $}function g5(Q,Y){if(Y.events===void 0)return;if(!Array.isArray(Y.events))throw Error(`\`events\` must be an array when calling \`${Q}\`.`);let X=Y.events.map((W,G)=>{if(typeof W!=="string"||!FQ.includes(W))throw Error(`\`events\` item ${G+1} must be one of ${FQ.join(", ")} when calling \`${Q}\`.`);return W});if(X.length===0)throw Error(`\`events\` must include at least one event type when calling \`${Q}\`.`);return X}function gY(Q,Y){if(!Array.isArray(Y.emails))throw Error(`\`emails\` must be an array when calling \`${Q}\`.`);let X=[];if(Y.emails.forEach((W,G)=>{if(typeof W!=="string")throw Error(`\`emails\` item ${G+1} must be a string when calling \`${Q}\`.`);let $=W.trim();if($.length>0)X.push($)}),X.length===0)throw Error(`\`emails\` must include at least one email address when calling \`${Q}\`.`);if(X.length>C5)throw Error(`\`emails\` must include no more than ${C5} email addresses when calling \`${Q}\`. Split larger batches into multiple calls.`);return X}var JV={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 zV(Q){let Y=Q.split(".").pop()?.toLowerCase()??"";return JV[Y]??null}var HV=104857600;async function UV(Q,Y){if(!eY())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 X=zV(Q);if(!X)throw Error("Unsupported file type. Use PDF, ePub, ZIP, image, audio, video, or text files.");let W=gM(Q).size;if(W>HV)throw Error(`File is too large (${Math.round(W/1048576)}MB). Delivery files must be 100MB or smaller.`);let G=yM(Q),$=await F("POST","/api/v1/products/delivery/upload-url",{filename:uM(Q),contentType:X,fileSizeBytes:W},Y),J=await fetch($.uploadUrl,{method:"PUT",headers:{"Content-Type":X},body:G});if(!J.ok)throw Error(`File upload failed (${J.status})`);return{url:$.publicUrl,fileName:$.fileName,fileSizeBytes:W,mimeType:X}}async function h5(Q){let Y=N(Q,"companyId");if(Y)return Y;let X=Q1();if(X)return X;try{return(await F("GET","/api/v1/account")).currentCompanyId??void 0}catch{return}}function i4(Q,Y){if(!B0(Q)||!Y)return Q;return{...Q,url:Y}}function f5(Q,Y){if(!B0(Q))return Q;return{...Q,...Y.campaign!==void 0&&{url:Y.campaign},...Y.campaignPreview!==void 0&&{previewUrl:Y.campaignPreview}}}function DQ(Q,Y,X){if(!Array.isArray(Q)||!Y)return Q;return Q.map((W)=>{if(!B0(W))return W;let G=N(W,"id");if(!G)return W;let $=q1({companyId:Y,...X==="campaign"&&{campaignId:G},...X==="sequence"&&{sequenceId:G},...X==="template"&&{emailId:G},...X==="transactional"&&{transactionalId:G}});if(X==="campaign")return f5(W,$.urls);let J=X==="sequence"?$.urls.sequence:X==="template"?$.urls.email:$.urls.transactionalEmail;return i4(W,J)})}function AV(Q){if(!Array.isArray(Q))return Q;return Q.map((Y)=>{if(!B0(Y))return Y;let X=N(Y,"id");if(!X)return Y;let W=q1({companyId:X});return{...Y,url:W.urls.dashboard,settingsUrl:W.urls.settings}})}var BV=new Set(["get_account","select_company","create_company","get_company","list_campaigns","get_campaign","get_email_send","create_campaign","update_campaign","schedule_campaign","send_test_email","cancel_campaign","pause_campaign","resume_campaign","duplicate_campaign","list_sequences","get_sequence","create_sequence","update_sequence","enable_sequence","disable_sequence","cancel_sequence_enrollments","list_ab_tests","get_ab_test","get_ab_test_stats","update_ab_test_variant","list_templates","get_template","create_template","update_template","list_transactional_emails","get_transactional_email","create_transactional_email","update_transactional_email"]);async function KV(Q,Y,X){if(!B0(X)||!BV.has(Q))return X;let W=B0(X.company)?X.company:void 0,$=N(X,"selectedCompanyId")??N(X,"currentCompanyId")??N(X,"companyId")??(W?N(W,"id"):void 0)??(W?N(W,"companyId"):void 0)??await h5(Y);if(!$)return X;let J=B0(X.campaign)?X.campaign:void 0,z=B0(X.sequence)?X.sequence:void 0,H=B0(X.template)?X.template:void 0,U=B0(X.transactional)&&!Array.isArray(X.transactional)?X.transactional:void 0,A={companyId:$,campaignId:N(Y,"campaignId")??N(X,"campaignId")??(J?N(J,"id"):void 0),sequenceId:N(Y,"sequenceId")??N(X,"sequenceId")??(z?N(z,"id"):void 0),emailId:N(X,"templateId")??(H?N(H,"id"):void 0)??(U?N(U,"emailId"):void 0)??N(Y,"templateId"),transactionalId:N(Y,"transactionalId")??(U?N(U,"id"):void 0)??N(Y,"idOrSlug"),emailSendId:N(Y,"emailSendId")??N(X,"emailSendId")??(B0(X.emailSend)?N(X.emailSend,"id"):void 0),status:N(Y,"status")},B=q1(A),K=W?q1({companyId:$}):void 0;return{...X,...Array.isArray(X.companies)&&{companies:AV(X.companies)},...Array.isArray(X.campaigns)&&{campaigns:DQ(X.campaigns,$,"campaign")},...Array.isArray(X.sequences)&&{sequences:DQ(X.sequences,$,"sequence")},...Array.isArray(X.templates)&&{templates:DQ(X.templates,$,"template")},...Array.isArray(X.transactional)&&{transactional:DQ(X.transactional,$,"transactional")},...W&&K!==void 0&&{company:{...W,url:K.urls.dashboard,settingsUrl:K.urls.settings}},...J&&B.urls.campaign!==void 0&&{campaign:f5(J,B.urls)},...z&&B.urls.sequence!==void 0&&{sequence:i4(z,B.urls.sequence)},...H&&B.urls.email!==void 0&&{template:i4(H,B.urls.email)},...U&&B.urls.transactionalEmail!==void 0&&{transactional:i4(U,B.urls.transactionalEmail)},...B0(X.emailSend)&&B.urls.emailSend!==void 0&&{emailSend:i4(X.emailSend,B.urls.emailSend)},appUrls:B.urls}}var l5=[{name:"get_account",description:`Get current account information including available companies. IMPORTANT: If you have access to multiple companies, you MUST either:
|
|
29
|
+
`)}L.write("payload.value = newResult;"),L.write("return payload;");let S=L.compile();return(E,_)=>S(K,E,_)},$,J=O1,z=!r6.jitless,U=z&&PQ.value,A=Y.catchall,B;Q._zod.parse=(K,L)=>{B??(B=W.value);let O=K.value;if(!J(O))return K.issues.push({expected:"object",code:"invalid_type",input:O,inst:Q}),K;if(z&&U&&L?.async===!1&&L.jitless!==!0){if(!$)$=G(Y.shape);if(K=$(K,L),!A)return K;return a8([],O,K,L,B,Q)}return X(K,L)}});function D8(Q,Y,X,W){for(let $ of Q)if($.issues.length===0)return Y.value=$.value,Y;let G=Q.filter(($)=>!G1($));if(G.length===1)return Y.value=G[0].value,G[0];return Y.issues.push({code:"invalid_union",input:Y.value,inst:X,errors:Q.map(($)=>$.issues.map((J)=>S0(J,W,b0())))}),Y}var gQ=q("$ZodUnion",(Q,Y)=>{n.init(Q,Y),c(Q._zod,"optin",()=>Y.options.some((G)=>G._zod.optin==="optional")?"optional":void 0),c(Q._zod,"optout",()=>Y.options.some((G)=>G._zod.optout==="optional")?"optional":void 0),c(Q._zod,"values",()=>{if(Y.options.every((G)=>G._zod.values))return new Set(Y.options.flatMap((G)=>Array.from(G._zod.values)));return}),c(Q._zod,"pattern",()=>{if(Y.options.every((G)=>G._zod.pattern)){let G=Y.options.map(($)=>$._zod.pattern);return new RegExp(`^(${G.map(($)=>a1($.source)).join("|")})$`)}return});let X=Y.options.length===1,W=Y.options[0]._zod.run;Q._zod.parse=(G,$)=>{if(X)return W(G,$);let J=!1,z=[];for(let H of Y.options){let U=H._zod.run({value:G.value,issues:[]},$);if(U instanceof Promise)z.push(U),J=!0;else{if(U.issues.length===0)return U;z.push(U)}}if(!J)return D8(z,G,Q,$);return Promise.all(z).then((H)=>{return D8(H,G,Q,$)})}}),e8=q("$ZodDiscriminatedUnion",(Q,Y)=>{gQ.init(Q,Y);let X=Q._zod.parse;c(Q._zod,"propValues",()=>{let G={};for(let $ of Y.options){let J=$._zod.propValues;if(!J||Object.keys(J).length===0)throw Error(`Invalid discriminated union option at index "${Y.options.indexOf($)}"`);for(let[z,H]of Object.entries(J)){if(!G[z])G[z]=new Set;for(let U of H)G[z].add(U)}}return G});let W=E1(()=>{let G=Y.options,$=new Map;for(let J of G){let z=J._zod.propValues?.[Y.discriminator];if(!z||z.size===0)throw Error(`Invalid discriminated union option at index "${Y.options.indexOf(J)}"`);for(let H of z){if($.has(H))throw Error(`Duplicate discriminator value "${String(H)}"`);$.set(H,J)}}return $});Q._zod.parse=(G,$)=>{let J=G.value;if(!O1(J))return G.issues.push({code:"invalid_type",expected:"object",input:J,inst:Q}),G;let z=W.value.get(J?.[Y.discriminator]);if(z)return z._zod.run(G,$);if(Y.unionFallback)return X(G,$);return G.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:Y.discriminator,input:J,path:[Y.discriminator],inst:Q}),G}}),QW=q("$ZodIntersection",(Q,Y)=>{n.init(Q,Y),Q._zod.parse=(X,W)=>{let G=X.value,$=Y.left._zod.run({value:G,issues:[]},W),J=Y.right._zod.run({value:G,issues:[]},W);if($ instanceof Promise||J instanceof Promise)return Promise.all([$,J]).then(([H,U])=>{return L8(X,H,U)});return L8(X,$,J)}});function _Q(Q,Y){if(Q===Y)return{valid:!0,data:Q};if(Q instanceof Date&&Y instanceof Date&&+Q===+Y)return{valid:!0,data:Q};if(W1(Q)&&W1(Y)){let X=Object.keys(Y),W=Object.keys(Q).filter(($)=>X.indexOf($)!==-1),G={...Q,...Y};for(let $ of W){let J=_Q(Q[$],Y[$]);if(!J.valid)return{valid:!1,mergeErrorPath:[$,...J.mergeErrorPath]};G[$]=J.data}return{valid:!0,data:G}}if(Array.isArray(Q)&&Array.isArray(Y)){if(Q.length!==Y.length)return{valid:!1,mergeErrorPath:[]};let X=[];for(let W=0;W<Q.length;W++){let G=Q[W],$=Y[W],J=_Q(G,$);if(!J.valid)return{valid:!1,mergeErrorPath:[W,...J.mergeErrorPath]};X.push(J.data)}return{valid:!0,data:X}}return{valid:!1,mergeErrorPath:[]}}function L8(Q,Y,X){if(Y.issues.length)Q.issues.push(...Y.issues);if(X.issues.length)Q.issues.push(...X.issues);if(G1(Q))return Q;let W=_Q(Y.value,X.value);if(!W.valid)throw Error(`Unmergable intersection. Error path: ${JSON.stringify(W.mergeErrorPath)}`);return Q.value=W.data,Q}var YW=q("$ZodRecord",(Q,Y)=>{n.init(Q,Y),Q._zod.parse=(X,W)=>{let G=X.value;if(!W1(G))return X.issues.push({expected:"record",code:"invalid_type",input:G,inst:Q}),X;let $=[];if(Y.keyType._zod.values){let J=Y.keyType._zod.values;X.value={};for(let H of J)if(typeof H==="string"||typeof H==="number"||typeof H==="symbol"){let U=Y.valueType._zod.run({value:G[H],issues:[]},W);if(U instanceof Promise)$.push(U.then((A)=>{if(A.issues.length)X.issues.push(...p0(H,A.issues));X.value[H]=A.value}));else{if(U.issues.length)X.issues.push(...p0(H,U.issues));X.value[H]=U.value}}let z;for(let H in G)if(!J.has(H))z=z??[],z.push(H);if(z&&z.length>0)X.issues.push({code:"unrecognized_keys",input:G,inst:Q,keys:z})}else{X.value={};for(let J of Reflect.ownKeys(G)){if(J==="__proto__")continue;let z=Y.keyType._zod.run({value:J,issues:[]},W);if(z instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(z.issues.length){X.issues.push({code:"invalid_key",origin:"record",issues:z.issues.map((U)=>S0(U,W,b0())),input:J,path:[J],inst:Q}),X.value[z.value]=z.value;continue}let H=Y.valueType._zod.run({value:G[J],issues:[]},W);if(H instanceof Promise)$.push(H.then((U)=>{if(U.issues.length)X.issues.push(...p0(J,U.issues));X.value[z.value]=U.value}));else{if(H.issues.length)X.issues.push(...p0(J,H.issues));X.value[z.value]=H.value}}}if($.length)return Promise.all($).then(()=>X);return X}});var XW=q("$ZodEnum",(Q,Y)=>{n.init(Q,Y);let X=bQ(Y.entries),W=new Set(X);Q._zod.values=W,Q._zod.pattern=new RegExp(`^(${X.filter((G)=>IQ.has(typeof G)).map((G)=>typeof G==="string"?c0(G):G.toString()).join("|")})$`),Q._zod.parse=(G,$)=>{let J=G.value;if(W.has(J))return G;return G.issues.push({code:"invalid_value",values:X,input:J,inst:Q}),G}}),WW=q("$ZodLiteral",(Q,Y)=>{if(n.init(Q,Y),Y.values.length===0)throw Error("Cannot create literal schema with no valid values");Q._zod.values=new Set(Y.values),Q._zod.pattern=new RegExp(`^(${Y.values.map((X)=>typeof X==="string"?c0(X):X?c0(X.toString()):String(X)).join("|")})$`),Q._zod.parse=(X,W)=>{let G=X.value;if(Q._zod.values.has(G))return X;return X.issues.push({code:"invalid_value",values:Y.values,input:G,inst:Q}),X}});var GW=q("$ZodTransform",(Q,Y)=>{n.init(Q,Y),Q._zod.parse=(X,W)=>{if(W.direction==="backward")throw new d1(Q.constructor.name);let G=Y.transform(X.value,X);if(W.async)return(G instanceof Promise?G:Promise.resolve(G)).then((J)=>{return X.value=J,X});if(G instanceof Promise)throw new m0;return X.value=G,X}});function q8(Q,Y){if(Q.issues.length&&Y===void 0)return{issues:[],value:void 0};return Q}var $W=q("$ZodOptional",(Q,Y)=>{n.init(Q,Y),Q._zod.optin="optional",Q._zod.optout="optional",c(Q._zod,"values",()=>{return Y.innerType._zod.values?new Set([...Y.innerType._zod.values,void 0]):void 0}),c(Q._zod,"pattern",()=>{let X=Y.innerType._zod.pattern;return X?new RegExp(`^(${a1(X.source)})?$`):void 0}),Q._zod.parse=(X,W)=>{if(Y.innerType._zod.optin==="optional"){let G=Y.innerType._zod.run(X,W);if(G instanceof Promise)return G.then(($)=>q8($,X.value));return q8(G,X.value)}if(X.value===void 0)return X;return Y.innerType._zod.run(X,W)}}),JW=q("$ZodNullable",(Q,Y)=>{n.init(Q,Y),c(Q._zod,"optin",()=>Y.innerType._zod.optin),c(Q._zod,"optout",()=>Y.innerType._zod.optout),c(Q._zod,"pattern",()=>{let X=Y.innerType._zod.pattern;return X?new RegExp(`^(${a1(X.source)}|null)$`):void 0}),c(Q._zod,"values",()=>{return Y.innerType._zod.values?new Set([...Y.innerType._zod.values,null]):void 0}),Q._zod.parse=(X,W)=>{if(X.value===null)return X;return Y.innerType._zod.run(X,W)}}),zW=q("$ZodDefault",(Q,Y)=>{n.init(Q,Y),Q._zod.optin="optional",c(Q._zod,"values",()=>Y.innerType._zod.values),Q._zod.parse=(X,W)=>{if(W.direction==="backward")return Y.innerType._zod.run(X,W);if(X.value===void 0)return X.value=Y.defaultValue,X;let G=Y.innerType._zod.run(X,W);if(G instanceof Promise)return G.then(($)=>F8($,Y));return F8(G,Y)}});function F8(Q,Y){if(Q.value===void 0)Q.value=Y.defaultValue;return Q}var HW=q("$ZodPrefault",(Q,Y)=>{n.init(Q,Y),Q._zod.optin="optional",c(Q._zod,"values",()=>Y.innerType._zod.values),Q._zod.parse=(X,W)=>{if(W.direction==="backward")return Y.innerType._zod.run(X,W);if(X.value===void 0)X.value=Y.defaultValue;return Y.innerType._zod.run(X,W)}}),UW=q("$ZodNonOptional",(Q,Y)=>{n.init(Q,Y),c(Q._zod,"values",()=>{let X=Y.innerType._zod.values;return X?new Set([...X].filter((W)=>W!==void 0)):void 0}),Q._zod.parse=(X,W)=>{let G=Y.innerType._zod.run(X,W);if(G instanceof Promise)return G.then(($)=>O8($,Q));return O8(G,Q)}});function O8(Q,Y){if(!Q.issues.length&&Q.value===void 0)Q.issues.push({code:"invalid_type",expected:"nonoptional",input:Q.value,inst:Y});return Q}var AW=q("$ZodCatch",(Q,Y)=>{n.init(Q,Y),c(Q._zod,"optin",()=>Y.innerType._zod.optin),c(Q._zod,"optout",()=>Y.innerType._zod.optout),c(Q._zod,"values",()=>Y.innerType._zod.values),Q._zod.parse=(X,W)=>{if(W.direction==="backward")return Y.innerType._zod.run(X,W);let G=Y.innerType._zod.run(X,W);if(G instanceof Promise)return G.then(($)=>{if(X.value=$.value,$.issues.length)X.value=Y.catchValue({...X,error:{issues:$.issues.map((J)=>S0(J,W,b0()))},input:X.value}),X.issues=[];return X});if(X.value=G.value,G.issues.length)X.value=Y.catchValue({...X,error:{issues:G.issues.map(($)=>S0($,W,b0()))},input:X.value}),X.issues=[];return X}});var BW=q("$ZodPipe",(Q,Y)=>{n.init(Q,Y),c(Q._zod,"values",()=>Y.in._zod.values),c(Q._zod,"optin",()=>Y.in._zod.optin),c(Q._zod,"optout",()=>Y.out._zod.optout),c(Q._zod,"propValues",()=>Y.in._zod.propValues),Q._zod.parse=(X,W)=>{if(W.direction==="backward"){let $=Y.out._zod.run(X,W);if($ instanceof Promise)return $.then((J)=>W4(J,Y.in,W));return W4($,Y.in,W)}let G=Y.in._zod.run(X,W);if(G instanceof Promise)return G.then(($)=>W4($,Y.out,W));return W4(G,Y.out,W)}});function W4(Q,Y,X){if(Q.issues.length)return Q.aborted=!0,Q;return Y._zod.run({value:Q.value,issues:Q.issues},X)}var KW=q("$ZodReadonly",(Q,Y)=>{n.init(Q,Y),c(Q._zod,"propValues",()=>Y.innerType._zod.propValues),c(Q._zod,"values",()=>Y.innerType._zod.values),c(Q._zod,"optin",()=>Y.innerType._zod.optin),c(Q._zod,"optout",()=>Y.innerType._zod.optout),Q._zod.parse=(X,W)=>{if(W.direction==="backward")return Y.innerType._zod.run(X,W);let G=Y.innerType._zod.run(X,W);if(G instanceof Promise)return G.then(M8);return M8(G)}});function M8(Q){return Q.value=Object.freeze(Q.value),Q}var DW=q("$ZodCustom",(Q,Y)=>{G0.init(Q,Y),n.init(Q,Y),Q._zod.parse=(X,W)=>{return X},Q._zod.check=(X)=>{let W=X.value,G=Y.fn(W);if(G instanceof Promise)return G.then(($)=>V8($,X,W,Q));V8(G,X,W,Q);return}});function V8(Q,Y,X,W){if(!Q){let G={code:"custom",input:X,inst:W,path:[...W._zod.def.path??[]],continue:!W._zod.def.abort};if(W._zod.def.params)G.params=W._zod.def.params;Y.issues.push(T1(G))}}var fH=(Q)=>{let Y=typeof Q;switch(Y){case"number":return Number.isNaN(Q)?"NaN":"number";case"object":{if(Array.isArray(Q))return"array";if(Q===null)return"null";if(Object.getPrototypeOf(Q)!==Object.prototype&&Q.constructor)return Q.constructor.name}}return Y},lH=()=>{let Q={string:{unit:"characters",verb:"to have"},file:{unit:"bytes",verb:"to have"},array:{unit:"items",verb:"to have"},set:{unit:"items",verb:"to have"}};function Y(W){return Q[W]??null}let X={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",jwt:"JWT",template_literal:"input"};return(W)=>{switch(W.code){case"invalid_type":return`Invalid input: expected ${W.expected}, received ${fH(W.input)}`;case"invalid_value":if(W.values.length===1)return`Invalid input: expected ${a6(W.values[0])}`;return`Invalid option: expected one of ${d6(W.values,"|")}`;case"too_big":{let G=W.inclusive?"<=":"<",$=Y(W.origin);if($)return`Too big: expected ${W.origin??"value"} to have ${G}${W.maximum.toString()} ${$.unit??"elements"}`;return`Too big: expected ${W.origin??"value"} to be ${G}${W.maximum.toString()}`}case"too_small":{let G=W.inclusive?">=":">",$=Y(W.origin);if($)return`Too small: expected ${W.origin} to have ${G}${W.minimum.toString()} ${$.unit}`;return`Too small: expected ${W.origin} to be ${G}${W.minimum.toString()}`}case"invalid_format":{let G=W;if(G.format==="starts_with")return`Invalid string: must start with "${G.prefix}"`;if(G.format==="ends_with")return`Invalid string: must end with "${G.suffix}"`;if(G.format==="includes")return`Invalid string: must include "${G.includes}"`;if(G.format==="regex")return`Invalid string: must match pattern ${G.pattern}`;return`Invalid ${X[G.format]??W.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${W.divisor}`;case"unrecognized_keys":return`Unrecognized key${W.keys.length>1?"s":""}: ${d6(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 uQ(){return{localeError:lH()}}var gV=Symbol("ZodOutput"),uV=Symbol("ZodInput");class LW{constructor(){this._map=new WeakMap,this._idmap=new Map}add(Q,...Y){let X=Y[0];if(this._map.set(Q,X),X&&typeof X==="object"&&"id"in X){if(this._idmap.has(X.id))throw Error(`ID ${X.id} already exists in the registry`);this._idmap.set(X.id,Q)}return this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(Q){let Y=this._map.get(Q);if(Y&&typeof Y==="object"&&"id"in Y)this._idmap.delete(Y.id);return this._map.delete(Q),this}get(Q){let Y=Q._zod.parent;if(Y){let X={...this.get(Y)??{}};delete X.id;let W={...X,...this._map.get(Q)};return Object.keys(W).length?W:void 0}return this._map.get(Q)}has(Q){return this._map.has(Q)}}function mH(){return new LW}var W6=mH();function qW(Q,Y){return new Q({type:"string",...I(Y)})}function FW(Q,Y){return new Q({type:"string",format:"email",check:"string_format",abort:!1,...I(Y)})}function hQ(Q,Y){return new Q({type:"string",format:"guid",check:"string_format",abort:!1,...I(Y)})}function OW(Q,Y){return new Q({type:"string",format:"uuid",check:"string_format",abort:!1,...I(Y)})}function MW(Q,Y){return new Q({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...I(Y)})}function VW(Q,Y){return new Q({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...I(Y)})}function ZW(Q,Y){return new Q({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...I(Y)})}function NW(Q,Y){return new Q({type:"string",format:"url",check:"string_format",abort:!1,...I(Y)})}function wW(Q,Y){return new Q({type:"string",format:"emoji",check:"string_format",abort:!1,...I(Y)})}function bW(Q,Y){return new Q({type:"string",format:"nanoid",check:"string_format",abort:!1,...I(Y)})}function jW(Q,Y){return new Q({type:"string",format:"cuid",check:"string_format",abort:!1,...I(Y)})}function PW(Q,Y){return new Q({type:"string",format:"cuid2",check:"string_format",abort:!1,...I(Y)})}function IW(Q,Y){return new Q({type:"string",format:"ulid",check:"string_format",abort:!1,...I(Y)})}function EW(Q,Y){return new Q({type:"string",format:"xid",check:"string_format",abort:!1,...I(Y)})}function TW(Q,Y){return new Q({type:"string",format:"ksuid",check:"string_format",abort:!1,...I(Y)})}function SW(Q,Y){return new Q({type:"string",format:"ipv4",check:"string_format",abort:!1,...I(Y)})}function RW(Q,Y){return new Q({type:"string",format:"ipv6",check:"string_format",abort:!1,...I(Y)})}function CW(Q,Y){return new Q({type:"string",format:"cidrv4",check:"string_format",abort:!1,...I(Y)})}function kW(Q,Y){return new Q({type:"string",format:"cidrv6",check:"string_format",abort:!1,...I(Y)})}function vW(Q,Y){return new Q({type:"string",format:"base64",check:"string_format",abort:!1,...I(Y)})}function xW(Q,Y){return new Q({type:"string",format:"base64url",check:"string_format",abort:!1,...I(Y)})}function _W(Q,Y){return new Q({type:"string",format:"e164",check:"string_format",abort:!1,...I(Y)})}function yW(Q,Y){return new Q({type:"string",format:"jwt",check:"string_format",abort:!1,...I(Y)})}function gW(Q,Y){return new Q({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...I(Y)})}function uW(Q,Y){return new Q({type:"string",format:"date",check:"string_format",...I(Y)})}function hW(Q,Y){return new Q({type:"string",format:"time",check:"string_format",precision:null,...I(Y)})}function fW(Q,Y){return new Q({type:"string",format:"duration",check:"string_format",...I(Y)})}function lW(Q,Y){return new Q({type:"number",checks:[],...I(Y)})}function mW(Q,Y){return new Q({type:"number",check:"number_format",abort:!1,format:"safeint",...I(Y)})}function cW(Q,Y){return new Q({type:"boolean",...I(Y)})}function pW(Q,Y){return new Q({type:"null",...I(Y)})}function iW(Q){return new Q({type:"unknown"})}function nW(Q,Y){return new Q({type:"never",...I(Y)})}function J4(Q,Y){return new kQ({check:"less_than",...I(Y),value:Q,inclusive:!1})}function G6(Q,Y){return new kQ({check:"less_than",...I(Y),value:Q,inclusive:!0})}function z4(Q,Y){return new vQ({check:"greater_than",...I(Y),value:Q,inclusive:!1})}function $6(Q,Y){return new vQ({check:"greater_than",...I(Y),value:Q,inclusive:!0})}function H4(Q,Y){return new sX({check:"multiple_of",...I(Y),value:Q})}function U4(Q,Y){return new Q8({check:"max_length",...I(Y),maximum:Q})}function S1(Q,Y){return new Y8({check:"min_length",...I(Y),minimum:Q})}function A4(Q,Y){return new X8({check:"length_equals",...I(Y),length:Q})}function fQ(Q,Y){return new W8({check:"string_format",format:"regex",...I(Y),pattern:Q})}function lQ(Q){return new G8({check:"string_format",format:"lowercase",...I(Q)})}function mQ(Q){return new $8({check:"string_format",format:"uppercase",...I(Q)})}function cQ(Q,Y){return new J8({check:"string_format",format:"includes",...I(Y),includes:Q})}function pQ(Q,Y){return new z8({check:"string_format",format:"starts_with",...I(Y),prefix:Q})}function iQ(Q,Y){return new H8({check:"string_format",format:"ends_with",...I(Y),suffix:Q})}function M1(Q){return new U8({check:"overwrite",tx:Q})}function nQ(Q){return M1((Y)=>Y.normalize(Q))}function rQ(){return M1((Q)=>Q.trim())}function dQ(){return M1((Q)=>Q.toLowerCase())}function oQ(){return M1((Q)=>Q.toUpperCase())}function rW(Q,Y,X){return new Q({type:"array",element:Y,...I(X)})}function dW(Q,Y,X){let W=I(X);return W.abort??(W.abort=!0),new Q({type:"custom",check:"custom",fn:Y,...W})}function oW(Q,Y,X){return new Q({type:"custom",check:"custom",fn:Y,...I(X)})}function tW(Q){let Y=cH((X)=>{return X.addIssue=(W)=>{if(typeof W==="string")X.issues.push(T1(W,X.value,Y._zod.def));else{let G=W;if(G.fatal)G.continue=!1;G.code??(G.code="custom"),G.input??(G.input=X.value),G.inst??(G.inst=Y),G.continue??(G.continue=!Y._zod.def.abort),X.issues.push(T1(G))}},Q(X.value,X)});return Y}function cH(Q,Y){let X=new G0({check:"custom",...I(Y)});return X._zod.check=Q,X}function R1(Q){return!!Q._zod}function $1(Q,Y){if(R1(Q))return Q6(Q,Y);return Q.safeParse(Y)}function B4(Q){if(!Q)return;let Y;if(R1(Q))Y=Q._zod?.def?.shape;else Y=Q.shape;if(!Y)return;if(typeof Y==="function")try{return Y()}catch{return}return Y}function aW(Q){if(R1(Q)){let $=Q._zod?.def;if($){if($.value!==void 0)return $.value;if(Array.isArray($.values)&&$.values.length>0)return $.values[0]}}let X=Q._def;if(X){if(X.value!==void 0)return X.value;if(Array.isArray(X.values)&&X.values.length>0)return X.values[0]}let W=Q.value;if(W!==void 0)return W;return}var z6={};tY(z6,{time:()=>sQ,duration:()=>eQ,datetime:()=>tQ,date:()=>aQ,ZodISOTime:()=>QG,ZodISODuration:()=>YG,ZodISODateTime:()=>sW,ZodISODate:()=>eW});var sW=q("ZodISODateTime",(Q,Y)=>{C8.init(Q,Y),o.init(Q,Y)});function tQ(Q){return gW(sW,Q)}var eW=q("ZodISODate",(Q,Y)=>{k8.init(Q,Y),o.init(Q,Y)});function aQ(Q){return uW(eW,Q)}var QG=q("ZodISOTime",(Q,Y)=>{v8.init(Q,Y),o.init(Q,Y)});function sQ(Q){return hW(QG,Q)}var YG=q("ZodISODuration",(Q,Y)=>{x8.init(Q,Y),o.init(Q,Y)});function eQ(Q){return fW(YG,Q)}var XG=(Q,Y)=>{s6.init(Q,Y),Q.name="ZodError",Object.defineProperties(Q,{format:{value:(X)=>DX(Q,X)},flatten:{value:(X)=>KX(Q,X)},addIssue:{value:(X)=>{Q.issues.push(X),Q.message=JSON.stringify(Q.issues,I1,2)}},addIssues:{value:(X)=>{Q.issues.push(...X),Q.message=JSON.stringify(Q.issues,I1,2)}},isEmpty:{get(){return Q.issues.length===0}}})},bZ=q("ZodError",XG),N0=q("ZodError",XG,{Parent:Error});var WG=e6(N0),GG=Q4(N0),$G=e1(N0),JG=Y6(N0),zG=LX(N0),HG=qX(N0),UG=FX(N0),AG=OX(N0),BG=MX(N0),KG=VX(N0),DG=ZX(N0),LG=NX(N0);var e=q("ZodType",(Q,Y)=>{return n.init(Q,Y),Q.def=Y,Q.type=Y.type,Object.defineProperty(Q,"_def",{value:Y}),Q.check=(...X)=>{return Q.clone(f.mergeDefs(Y,{checks:[...Y.checks??[],...X.map((W)=>typeof W==="function"?{_zod:{check:W,def:{check:"custom"},onattach:[]}}:W)]}))},Q.clone=(X,W)=>T0(Q,X,W),Q.brand=()=>Q,Q.register=(X,W)=>{return X.add(Q,W),Q},Q.parse=(X,W)=>WG(Q,X,W,{callee:Q.parse}),Q.safeParse=(X,W)=>$G(Q,X,W),Q.parseAsync=async(X,W)=>GG(Q,X,W,{callee:Q.parseAsync}),Q.safeParseAsync=async(X,W)=>JG(Q,X,W),Q.spa=Q.safeParseAsync,Q.encode=(X,W)=>zG(Q,X,W),Q.decode=(X,W)=>HG(Q,X,W),Q.encodeAsync=async(X,W)=>UG(Q,X,W),Q.decodeAsync=async(X,W)=>AG(Q,X,W),Q.safeEncode=(X,W)=>BG(Q,X,W),Q.safeDecode=(X,W)=>KG(Q,X,W),Q.safeEncodeAsync=async(X,W)=>DG(Q,X,W),Q.safeDecodeAsync=async(X,W)=>LG(Q,X,W),Q.refine=(X,W)=>Q.check(h3(X,W)),Q.superRefine=(X)=>Q.check(f3(X)),Q.overwrite=(X)=>Q.check(M1(X)),Q.optional=()=>s(Q),Q.nullable=()=>OG(Q),Q.nullish=()=>s(OG(Q)),Q.nonoptional=(X)=>v3(Q,X),Q.array=()=>y(Q),Q.or=(X)=>i([Q,X]),Q.and=(X)=>D4(Q,X),Q.transform=(X)=>Y9(Q,wG(X)),Q.default=(X)=>R3(Q,X),Q.prefault=(X)=>k3(Q,X),Q.catch=(X)=>_3(Q,X),Q.pipe=(X)=>Y9(Q,X),Q.readonly=()=>u3(Q),Q.describe=(X)=>{let W=Q.clone();return W6.add(W,{description:X}),W},Object.defineProperty(Q,"description",{get(){return W6.get(Q)?.description},configurable:!0}),Q.meta=(...X)=>{if(X.length===0)return W6.get(Q);let W=Q.clone();return W6.add(W,X[0]),W},Q.isOptional=()=>Q.safeParse(void 0).success,Q.isNullable=()=>Q.safeParse(null).success,Q}),MG=q("_ZodString",(Q,Y)=>{$4.init(Q,Y),e.init(Q,Y);let X=Q._zod.bag;Q.format=X.format??null,Q.minLength=X.minimum??null,Q.maxLength=X.maximum??null,Q.regex=(...W)=>Q.check(fQ(...W)),Q.includes=(...W)=>Q.check(cQ(...W)),Q.startsWith=(...W)=>Q.check(pQ(...W)),Q.endsWith=(...W)=>Q.check(iQ(...W)),Q.min=(...W)=>Q.check(S1(...W)),Q.max=(...W)=>Q.check(U4(...W)),Q.length=(...W)=>Q.check(A4(...W)),Q.nonempty=(...W)=>Q.check(S1(1,...W)),Q.lowercase=(W)=>Q.check(lQ(W)),Q.uppercase=(W)=>Q.check(mQ(W)),Q.trim=()=>Q.check(rQ()),Q.normalize=(...W)=>Q.check(nQ(...W)),Q.toLowerCase=()=>Q.check(dQ()),Q.toUpperCase=()=>Q.check(oQ())}),sH=q("ZodString",(Q,Y)=>{$4.init(Q,Y),MG.init(Q,Y),Q.email=(X)=>Q.check(FW(eH,X)),Q.url=(X)=>Q.check(NW(Q3,X)),Q.jwt=(X)=>Q.check(yW(q3,X)),Q.emoji=(X)=>Q.check(wW(Y3,X)),Q.guid=(X)=>Q.check(hQ(qG,X)),Q.uuid=(X)=>Q.check(OW(K4,X)),Q.uuidv4=(X)=>Q.check(MW(K4,X)),Q.uuidv6=(X)=>Q.check(VW(K4,X)),Q.uuidv7=(X)=>Q.check(ZW(K4,X)),Q.nanoid=(X)=>Q.check(bW(X3,X)),Q.guid=(X)=>Q.check(hQ(qG,X)),Q.cuid=(X)=>Q.check(jW(W3,X)),Q.cuid2=(X)=>Q.check(PW(G3,X)),Q.ulid=(X)=>Q.check(IW($3,X)),Q.base64=(X)=>Q.check(vW(K3,X)),Q.base64url=(X)=>Q.check(xW(D3,X)),Q.xid=(X)=>Q.check(EW(J3,X)),Q.ksuid=(X)=>Q.check(TW(z3,X)),Q.ipv4=(X)=>Q.check(SW(H3,X)),Q.ipv6=(X)=>Q.check(RW(U3,X)),Q.cidrv4=(X)=>Q.check(CW(A3,X)),Q.cidrv6=(X)=>Q.check(kW(B3,X)),Q.e164=(X)=>Q.check(_W(L3,X)),Q.datetime=(X)=>Q.check(tQ(X)),Q.date=(X)=>Q.check(aQ(X)),Q.time=(X)=>Q.check(sQ(X)),Q.duration=(X)=>Q.check(eQ(X))});function D(Q){return qW(sH,Q)}var o=q("ZodStringFormat",(Q,Y)=>{r.init(Q,Y),MG.init(Q,Y)}),eH=q("ZodEmail",(Q,Y)=>{w8.init(Q,Y),o.init(Q,Y)});var qG=q("ZodGUID",(Q,Y)=>{Z8.init(Q,Y),o.init(Q,Y)});var K4=q("ZodUUID",(Q,Y)=>{N8.init(Q,Y),o.init(Q,Y)});var Q3=q("ZodURL",(Q,Y)=>{b8.init(Q,Y),o.init(Q,Y)});var Y3=q("ZodEmoji",(Q,Y)=>{j8.init(Q,Y),o.init(Q,Y)});var X3=q("ZodNanoID",(Q,Y)=>{P8.init(Q,Y),o.init(Q,Y)});var W3=q("ZodCUID",(Q,Y)=>{I8.init(Q,Y),o.init(Q,Y)});var G3=q("ZodCUID2",(Q,Y)=>{E8.init(Q,Y),o.init(Q,Y)});var $3=q("ZodULID",(Q,Y)=>{T8.init(Q,Y),o.init(Q,Y)});var J3=q("ZodXID",(Q,Y)=>{S8.init(Q,Y),o.init(Q,Y)});var z3=q("ZodKSUID",(Q,Y)=>{R8.init(Q,Y),o.init(Q,Y)});var H3=q("ZodIPv4",(Q,Y)=>{_8.init(Q,Y),o.init(Q,Y)});var U3=q("ZodIPv6",(Q,Y)=>{y8.init(Q,Y),o.init(Q,Y)});var A3=q("ZodCIDRv4",(Q,Y)=>{g8.init(Q,Y),o.init(Q,Y)});var B3=q("ZodCIDRv6",(Q,Y)=>{u8.init(Q,Y),o.init(Q,Y)});var K3=q("ZodBase64",(Q,Y)=>{f8.init(Q,Y),o.init(Q,Y)});var D3=q("ZodBase64URL",(Q,Y)=>{l8.init(Q,Y),o.init(Q,Y)});var L3=q("ZodE164",(Q,Y)=>{m8.init(Q,Y),o.init(Q,Y)});var q3=q("ZodJWT",(Q,Y)=>{c8.init(Q,Y),o.init(Q,Y)});var VG=q("ZodNumber",(Q,Y)=>{yQ.init(Q,Y),e.init(Q,Y),Q.gt=(W,G)=>Q.check(z4(W,G)),Q.gte=(W,G)=>Q.check($6(W,G)),Q.min=(W,G)=>Q.check($6(W,G)),Q.lt=(W,G)=>Q.check(J4(W,G)),Q.lte=(W,G)=>Q.check(G6(W,G)),Q.max=(W,G)=>Q.check(G6(W,G)),Q.int=(W)=>Q.check(FG(W)),Q.safe=(W)=>Q.check(FG(W)),Q.positive=(W)=>Q.check(z4(0,W)),Q.nonnegative=(W)=>Q.check($6(0,W)),Q.negative=(W)=>Q.check(J4(0,W)),Q.nonpositive=(W)=>Q.check(G6(0,W)),Q.multipleOf=(W,G)=>Q.check(H4(W,G)),Q.step=(W,G)=>Q.check(H4(W,G)),Q.finite=()=>Q;let X=Q._zod.bag;Q.minValue=Math.max(X.minimum??Number.NEGATIVE_INFINITY,X.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,Q.maxValue=Math.min(X.maximum??Number.POSITIVE_INFINITY,X.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,Q.isInt=(X.format??"").includes("int")||Number.isSafeInteger(X.multipleOf??0.5),Q.isFinite=!0,Q.format=X.format??null});function m(Q){return lW(VG,Q)}var F3=q("ZodNumberFormat",(Q,Y)=>{p8.init(Q,Y),VG.init(Q,Y)});function FG(Q){return mW(F3,Q)}var O3=q("ZodBoolean",(Q,Y)=>{i8.init(Q,Y),e.init(Q,Y)});function W0(Q){return cW(O3,Q)}var M3=q("ZodNull",(Q,Y)=>{n8.init(Q,Y),e.init(Q,Y)});function X9(Q){return pW(M3,Q)}var V3=q("ZodUnknown",(Q,Y)=>{r8.init(Q,Y),e.init(Q,Y)});function t(){return iW(V3)}var Z3=q("ZodNever",(Q,Y)=>{d8.init(Q,Y),e.init(Q,Y)});function N3(Q){return nW(Z3,Q)}var w3=q("ZodArray",(Q,Y)=>{o8.init(Q,Y),e.init(Q,Y),Q.element=Y.element,Q.min=(X,W)=>Q.check(S1(X,W)),Q.nonempty=(X)=>Q.check(S1(1,X)),Q.max=(X,W)=>Q.check(U4(X,W)),Q.length=(X,W)=>Q.check(A4(X,W)),Q.unwrap=()=>Q.element});function y(Q,Y){return rW(w3,Q,Y)}var ZG=q("ZodObject",(Q,Y)=>{s8.init(Q,Y),e.init(Q,Y),f.defineLazy(Q,"shape",()=>{return Y.shape}),Q.keyof=()=>q0(Object.keys(Q._zod.def.shape)),Q.catchall=(X)=>Q.clone({...Q._zod.def,catchall:X}),Q.passthrough=()=>Q.clone({...Q._zod.def,catchall:t()}),Q.loose=()=>Q.clone({...Q._zod.def,catchall:t()}),Q.strict=()=>Q.clone({...Q._zod.def,catchall:N3()}),Q.strip=()=>Q.clone({...Q._zod.def,catchall:void 0}),Q.extend=(X)=>{return f.extend(Q,X)},Q.safeExtend=(X)=>{return f.safeExtend(Q,X)},Q.merge=(X)=>f.merge(Q,X),Q.pick=(X)=>f.pick(Q,X),Q.omit=(X)=>f.omit(Q,X),Q.partial=(...X)=>f.partial(bG,Q,X[0]),Q.required=(...X)=>f.required(jG,Q,X[0])});function b(Q,Y){let X={type:"object",shape:Q??{},...f.normalizeParams(Y)};return new ZG(X)}function K0(Q,Y){return new ZG({type:"object",shape:Q,catchall:t(),...f.normalizeParams(Y)})}var NG=q("ZodUnion",(Q,Y)=>{gQ.init(Q,Y),e.init(Q,Y),Q.options=Y.options});function i(Q,Y){return new NG({type:"union",options:Q,...f.normalizeParams(Y)})}var b3=q("ZodDiscriminatedUnion",(Q,Y)=>{NG.init(Q,Y),e8.init(Q,Y)});function W9(Q,Y,X){return new b3({type:"union",options:Y,discriminator:Q,...f.normalizeParams(X)})}var j3=q("ZodIntersection",(Q,Y)=>{QW.init(Q,Y),e.init(Q,Y)});function D4(Q,Y){return new j3({type:"intersection",left:Q,right:Y})}var P3=q("ZodRecord",(Q,Y)=>{YW.init(Q,Y),e.init(Q,Y),Q.keyType=Y.keyType,Q.valueType=Y.valueType});function a(Q,Y,X){return new P3({type:"record",keyType:Q,valueType:Y,...f.normalizeParams(X)})}var Q9=q("ZodEnum",(Q,Y)=>{XW.init(Q,Y),e.init(Q,Y),Q.enum=Y.entries,Q.options=Object.values(Y.entries);let X=new Set(Object.keys(Y.entries));Q.extract=(W,G)=>{let $={};for(let J of W)if(X.has(J))$[J]=Y.entries[J];else throw Error(`Key ${J} not found in enum`);return new Q9({...Y,checks:[],...f.normalizeParams(G),entries:$})},Q.exclude=(W,G)=>{let $={...Y.entries};for(let J of W)if(X.has(J))delete $[J];else throw Error(`Key ${J} not found in enum`);return new Q9({...Y,checks:[],...f.normalizeParams(G),entries:$})}});function q0(Q,Y){let X=Array.isArray(Q)?Object.fromEntries(Q.map((W)=>[W,W])):Q;return new Q9({type:"enum",entries:X,...f.normalizeParams(Y)})}var I3=q("ZodLiteral",(Q,Y)=>{WW.init(Q,Y),e.init(Q,Y),Q.values=new Set(Y.values),Object.defineProperty(Q,"value",{get(){if(Y.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return Y.values[0]}})});function j(Q,Y){return new I3({type:"literal",values:Array.isArray(Q)?Q:[Q],...f.normalizeParams(Y)})}var E3=q("ZodTransform",(Q,Y)=>{GW.init(Q,Y),e.init(Q,Y),Q._zod.parse=(X,W)=>{if(W.direction==="backward")throw new d1(Q.constructor.name);X.addIssue=($)=>{if(typeof $==="string")X.issues.push(f.issue($,X.value,Y));else{let J=$;if(J.fatal)J.continue=!1;J.code??(J.code="custom"),J.input??(J.input=X.value),J.inst??(J.inst=Q),X.issues.push(f.issue(J))}};let G=Y.transform(X.value,X);if(G instanceof Promise)return G.then(($)=>{return X.value=$,X});return X.value=G,X}});function wG(Q){return new E3({type:"transform",transform:Q})}var bG=q("ZodOptional",(Q,Y)=>{$W.init(Q,Y),e.init(Q,Y),Q.unwrap=()=>Q._zod.def.innerType});function s(Q){return new bG({type:"optional",innerType:Q})}var T3=q("ZodNullable",(Q,Y)=>{JW.init(Q,Y),e.init(Q,Y),Q.unwrap=()=>Q._zod.def.innerType});function OG(Q){return new T3({type:"nullable",innerType:Q})}var S3=q("ZodDefault",(Q,Y)=>{zW.init(Q,Y),e.init(Q,Y),Q.unwrap=()=>Q._zod.def.innerType,Q.removeDefault=Q.unwrap});function R3(Q,Y){return new S3({type:"default",innerType:Q,get defaultValue(){return typeof Y==="function"?Y():f.shallowClone(Y)}})}var C3=q("ZodPrefault",(Q,Y)=>{HW.init(Q,Y),e.init(Q,Y),Q.unwrap=()=>Q._zod.def.innerType});function k3(Q,Y){return new C3({type:"prefault",innerType:Q,get defaultValue(){return typeof Y==="function"?Y():f.shallowClone(Y)}})}var jG=q("ZodNonOptional",(Q,Y)=>{UW.init(Q,Y),e.init(Q,Y),Q.unwrap=()=>Q._zod.def.innerType});function v3(Q,Y){return new jG({type:"nonoptional",innerType:Q,...f.normalizeParams(Y)})}var x3=q("ZodCatch",(Q,Y)=>{AW.init(Q,Y),e.init(Q,Y),Q.unwrap=()=>Q._zod.def.innerType,Q.removeCatch=Q.unwrap});function _3(Q,Y){return new x3({type:"catch",innerType:Q,catchValue:typeof Y==="function"?Y:()=>Y})}var y3=q("ZodPipe",(Q,Y)=>{BW.init(Q,Y),e.init(Q,Y),Q.in=Y.in,Q.out=Y.out});function Y9(Q,Y){return new y3({type:"pipe",in:Q,out:Y})}var g3=q("ZodReadonly",(Q,Y)=>{KW.init(Q,Y),e.init(Q,Y),Q.unwrap=()=>Q._zod.def.innerType});function u3(Q){return new g3({type:"readonly",innerType:Q})}var PG=q("ZodCustom",(Q,Y)=>{DW.init(Q,Y),e.init(Q,Y)});function IG(Q,Y){return dW(PG,Q??(()=>!0),Y)}function h3(Q,Y={}){return oW(PG,Q,Y)}function f3(Q){return tW(Q)}function G9(Q,Y){return Y9(wG(Q),Y)}b0(uQ());var $9="2025-11-25";var EG=[$9,"2025-06-18","2025-03-26","2024-11-05","2024-10-07"],J1="io.modelcontextprotocol/related-task",q4="2.0",$0=IG((Q)=>Q!==null&&(typeof Q==="object"||typeof Q==="function")),TG=i([D(),m().int()]),SG=D(),MN=K0({ttl:i([m(),X9()]).optional(),pollInterval:m().optional()}),l3=b({ttl:m().optional()}),m3=b({taskId:D()}),J9=K0({progressToken:TG.optional(),[J1]:m3.optional()}),w0=b({_meta:J9.optional()}),H6=w0.extend({task:l3.optional()}),RG=(Q)=>H6.safeParse(Q).success,J0=b({method:D(),params:w0.loose().optional()}),j0=b({_meta:J9.optional()}),P0=b({method:D(),params:j0.loose().optional()}),z0=K0({_meta:J9.optional()}),F4=i([D(),m().int()]),CG=b({jsonrpc:j(q4),id:F4,...J0.shape}).strict(),z9=(Q)=>CG.safeParse(Q).success,kG=b({jsonrpc:j(q4),...P0.shape}).strict(),vG=(Q)=>kG.safeParse(Q).success,H9=b({jsonrpc:j(q4),id:F4,result:z0}).strict(),U6=(Q)=>H9.safeParse(Q).success;var g;(function(Q){Q[Q.ConnectionClosed=-32000]="ConnectionClosed",Q[Q.RequestTimeout=-32001]="RequestTimeout",Q[Q.ParseError=-32700]="ParseError",Q[Q.InvalidRequest=-32600]="InvalidRequest",Q[Q.MethodNotFound=-32601]="MethodNotFound",Q[Q.InvalidParams=-32602]="InvalidParams",Q[Q.InternalError=-32603]="InternalError",Q[Q.UrlElicitationRequired=-32042]="UrlElicitationRequired"})(g||(g={}));var U9=b({jsonrpc:j(q4),id:F4.optional(),error:b({code:m().int(),message:D(),data:t().optional()})}).strict();var xG=(Q)=>U9.safeParse(Q).success;var _G=i([CG,kG,H9,U9]),VN=i([H9,U9]),O4=z0.strict(),c3=j0.extend({requestId:F4.optional(),reason:D().optional()}),M4=P0.extend({method:j("notifications/cancelled"),params:c3}),p3=b({src:D(),mimeType:D().optional(),sizes:y(D()).optional(),theme:q0(["light","dark"]).optional()}),A6=b({icons:y(p3).optional()}),C1=b({name:D(),title:D().optional()}),yG=C1.extend({...C1.shape,...A6.shape,version:D(),websiteUrl:D().optional(),description:D().optional()}),i3=D4(b({applyDefaults:W0().optional()}),a(D(),t())),n3=G9((Q)=>{if(Q&&typeof Q==="object"&&!Array.isArray(Q)){if(Object.keys(Q).length===0)return{form:{}}}return Q},D4(b({form:i3.optional(),url:$0.optional()}),a(D(),t()).optional())),r3=K0({list:$0.optional(),cancel:$0.optional(),requests:K0({sampling:K0({createMessage:$0.optional()}).optional(),elicitation:K0({create:$0.optional()}).optional()}).optional()}),d3=K0({list:$0.optional(),cancel:$0.optional(),requests:K0({tools:K0({call:$0.optional()}).optional()}).optional()}),o3=b({experimental:a(D(),$0).optional(),sampling:b({context:$0.optional(),tools:$0.optional()}).optional(),elicitation:n3.optional(),roots:b({listChanged:W0().optional()}).optional(),tasks:r3.optional()}),t3=w0.extend({protocolVersion:D(),capabilities:o3,clientInfo:yG}),A9=J0.extend({method:j("initialize"),params:t3});var a3=b({experimental:a(D(),$0).optional(),logging:$0.optional(),completions:$0.optional(),prompts:b({listChanged:W0().optional()}).optional(),resources:b({subscribe:W0().optional(),listChanged:W0().optional()}).optional(),tools:b({listChanged:W0().optional()}).optional(),tasks:d3.optional()}),s3=z0.extend({protocolVersion:D(),capabilities:a3,serverInfo:yG,instructions:D().optional()}),B9=P0.extend({method:j("notifications/initialized"),params:j0.optional()});var V4=J0.extend({method:j("ping"),params:w0.optional()}),e3=b({progress:m(),total:s(m()),message:s(D())}),QU=b({...j0.shape,...e3.shape,progressToken:TG}),Z4=P0.extend({method:j("notifications/progress"),params:QU}),YU=w0.extend({cursor:SG.optional()}),B6=J0.extend({params:YU.optional()}),K6=z0.extend({nextCursor:SG.optional()}),XU=q0(["working","input_required","completed","failed","cancelled"]),D6=b({taskId:D(),status:XU,ttl:i([m(),X9()]),createdAt:D(),lastUpdatedAt:D(),pollInterval:s(m()),statusMessage:s(D())}),k1=z0.extend({task:D6}),WU=j0.merge(D6),L6=P0.extend({method:j("notifications/tasks/status"),params:WU}),N4=J0.extend({method:j("tasks/get"),params:w0.extend({taskId:D()})}),w4=z0.merge(D6),b4=J0.extend({method:j("tasks/result"),params:w0.extend({taskId:D()})}),ZN=z0.loose(),j4=B6.extend({method:j("tasks/list")}),P4=K6.extend({tasks:y(D6)}),I4=J0.extend({method:j("tasks/cancel"),params:w0.extend({taskId:D()})}),gG=z0.merge(D6),uG=b({uri:D(),mimeType:s(D()),_meta:a(D(),t()).optional()}),hG=uG.extend({text:D()}),K9=D().refine((Q)=>{try{return atob(Q),!0}catch{return!1}},{message:"Invalid Base64 string"}),fG=uG.extend({blob:K9}),q6=q0(["user","assistant"]),v1=b({audience:y(q6).optional(),priority:m().min(0).max(1).optional(),lastModified:z6.datetime({offset:!0}).optional()}),lG=b({...C1.shape,...A6.shape,uri:D(),description:s(D()),mimeType:s(D()),annotations:v1.optional(),_meta:s(K0({}))}),GU=b({...C1.shape,...A6.shape,uriTemplate:D(),description:s(D()),mimeType:s(D()),annotations:v1.optional(),_meta:s(K0({}))}),D9=B6.extend({method:j("resources/list")}),$U=K6.extend({resources:y(lG)}),JU=B6.extend({method:j("resources/templates/list")}),zU=K6.extend({resourceTemplates:y(GU)}),L9=w0.extend({uri:D()}),HU=L9,q9=J0.extend({method:j("resources/read"),params:HU}),UU=z0.extend({contents:y(i([hG,fG]))}),AU=P0.extend({method:j("notifications/resources/list_changed"),params:j0.optional()}),BU=L9,KU=J0.extend({method:j("resources/subscribe"),params:BU}),DU=L9,LU=J0.extend({method:j("resources/unsubscribe"),params:DU}),qU=j0.extend({uri:D()}),FU=P0.extend({method:j("notifications/resources/updated"),params:qU}),OU=b({name:D(),description:s(D()),required:s(W0())}),MU=b({...C1.shape,...A6.shape,description:s(D()),arguments:s(y(OU)),_meta:s(K0({}))}),VU=B6.extend({method:j("prompts/list")}),ZU=K6.extend({prompts:y(MU)}),NU=w0.extend({name:D(),arguments:a(D(),D()).optional()}),wU=J0.extend({method:j("prompts/get"),params:NU}),F9=b({type:j("text"),text:D(),annotations:v1.optional(),_meta:a(D(),t()).optional()}),O9=b({type:j("image"),data:K9,mimeType:D(),annotations:v1.optional(),_meta:a(D(),t()).optional()}),M9=b({type:j("audio"),data:K9,mimeType:D(),annotations:v1.optional(),_meta:a(D(),t()).optional()}),bU=b({type:j("tool_use"),name:D(),id:D(),input:a(D(),t()),_meta:a(D(),t()).optional()}),jU=b({type:j("resource"),resource:i([hG,fG]),annotations:v1.optional(),_meta:a(D(),t()).optional()}),PU=lG.extend({type:j("resource_link")}),V9=i([F9,O9,M9,PU,jU]),IU=b({role:q6,content:V9}),EU=z0.extend({description:D().optional(),messages:y(IU)}),TU=P0.extend({method:j("notifications/prompts/list_changed"),params:j0.optional()}),SU=b({title:D().optional(),readOnlyHint:W0().optional(),destructiveHint:W0().optional(),idempotentHint:W0().optional(),openWorldHint:W0().optional()}),RU=b({taskSupport:q0(["required","optional","forbidden"]).optional()}),mG=b({...C1.shape,...A6.shape,description:D().optional(),inputSchema:b({type:j("object"),properties:a(D(),$0).optional(),required:y(D()).optional()}).catchall(t()),outputSchema:b({type:j("object"),properties:a(D(),$0).optional(),required:y(D()).optional()}).catchall(t()).optional(),annotations:SU.optional(),execution:RU.optional(),_meta:a(D(),t()).optional()}),Z9=B6.extend({method:j("tools/list")}),CU=K6.extend({tools:y(mG)}),E4=z0.extend({content:y(V9).default([]),structuredContent:a(D(),t()).optional(),isError:W0().optional()}),NN=E4.or(z0.extend({toolResult:t()})),kU=H6.extend({name:D(),arguments:a(D(),t()).optional()}),F6=J0.extend({method:j("tools/call"),params:kU}),vU=P0.extend({method:j("notifications/tools/list_changed"),params:j0.optional()}),wN=b({autoRefresh:W0().default(!0),debounceMs:m().int().nonnegative().default(300)}),O6=q0(["debug","info","notice","warning","error","critical","alert","emergency"]),xU=w0.extend({level:O6}),N9=J0.extend({method:j("logging/setLevel"),params:xU}),_U=j0.extend({level:O6,logger:D().optional(),data:t()}),yU=P0.extend({method:j("notifications/message"),params:_U}),gU=b({name:D().optional()}),uU=b({hints:y(gU).optional(),costPriority:m().min(0).max(1).optional(),speedPriority:m().min(0).max(1).optional(),intelligencePriority:m().min(0).max(1).optional()}),hU=b({mode:q0(["auto","required","none"]).optional()}),fU=b({type:j("tool_result"),toolUseId:D().describe("The unique identifier for the corresponding tool call."),content:y(V9).default([]),structuredContent:b({}).loose().optional(),isError:W0().optional(),_meta:a(D(),t()).optional()}),lU=W9("type",[F9,O9,M9]),L4=W9("type",[F9,O9,M9,bU,fU]),mU=b({role:q6,content:i([L4,y(L4)]),_meta:a(D(),t()).optional()}),cU=H6.extend({messages:y(mU),modelPreferences:uU.optional(),systemPrompt:D().optional(),includeContext:q0(["none","thisServer","allServers"]).optional(),temperature:m().optional(),maxTokens:m().int(),stopSequences:y(D()).optional(),metadata:$0.optional(),tools:y(mG).optional(),toolChoice:hU.optional()}),pU=J0.extend({method:j("sampling/createMessage"),params:cU}),w9=z0.extend({model:D(),stopReason:s(q0(["endTurn","stopSequence","maxTokens"]).or(D())),role:q6,content:lU}),b9=z0.extend({model:D(),stopReason:s(q0(["endTurn","stopSequence","maxTokens","toolUse"]).or(D())),role:q6,content:i([L4,y(L4)])}),iU=b({type:j("boolean"),title:D().optional(),description:D().optional(),default:W0().optional()}),nU=b({type:j("string"),title:D().optional(),description:D().optional(),minLength:m().optional(),maxLength:m().optional(),format:q0(["email","uri","date","date-time"]).optional(),default:D().optional()}),rU=b({type:q0(["number","integer"]),title:D().optional(),description:D().optional(),minimum:m().optional(),maximum:m().optional(),default:m().optional()}),dU=b({type:j("string"),title:D().optional(),description:D().optional(),enum:y(D()),default:D().optional()}),oU=b({type:j("string"),title:D().optional(),description:D().optional(),oneOf:y(b({const:D(),title:D()})),default:D().optional()}),tU=b({type:j("string"),title:D().optional(),description:D().optional(),enum:y(D()),enumNames:y(D()).optional(),default:D().optional()}),aU=i([dU,oU]),sU=b({type:j("array"),title:D().optional(),description:D().optional(),minItems:m().optional(),maxItems:m().optional(),items:b({type:j("string"),enum:y(D())}),default:y(D()).optional()}),eU=b({type:j("array"),title:D().optional(),description:D().optional(),minItems:m().optional(),maxItems:m().optional(),items:b({anyOf:y(b({const:D(),title:D()}))}),default:y(D()).optional()}),QA=i([sU,eU]),YA=i([tU,aU,QA]),XA=i([YA,iU,nU,rU]),WA=H6.extend({mode:j("form").optional(),message:D(),requestedSchema:b({type:j("object"),properties:a(D(),XA),required:y(D()).optional()})}),GA=H6.extend({mode:j("url"),message:D(),elicitationId:D(),url:D().url()}),$A=i([WA,GA]),JA=J0.extend({method:j("elicitation/create"),params:$A}),zA=j0.extend({elicitationId:D()}),HA=P0.extend({method:j("notifications/elicitation/complete"),params:zA}),T4=z0.extend({action:q0(["accept","decline","cancel"]),content:G9((Q)=>Q===null?void 0:Q,a(D(),i([D(),m(),W0(),y(D())])).optional())}),UA=b({type:j("ref/resource"),uri:D()});var AA=b({type:j("ref/prompt"),name:D()}),BA=w0.extend({ref:i([AA,UA]),argument:b({name:D(),value:D()}),context:b({arguments:a(D(),D()).optional()}).optional()}),KA=J0.extend({method:j("completion/complete"),params:BA});var DA=z0.extend({completion:K0({values:y(D()).max(100),total:s(m().int()),hasMore:s(W0())})}),LA=b({uri:D().startsWith("file://"),name:D().optional(),_meta:a(D(),t()).optional()}),qA=J0.extend({method:j("roots/list"),params:w0.optional()}),j9=z0.extend({roots:y(LA)}),FA=P0.extend({method:j("notifications/roots/list_changed"),params:j0.optional()}),bN=i([V4,A9,KA,N9,wU,VU,D9,JU,q9,KU,LU,F6,Z9,N4,b4,j4,I4]),jN=i([M4,Z4,B9,FA,L6]),PN=i([O4,w9,b9,T4,j9,w4,P4,k1]),IN=i([V4,pU,JA,qA,N4,b4,j4,I4]),EN=i([M4,Z4,yU,FU,AU,vU,TU,L6,HA]),TN=i([O4,s3,DA,EU,ZU,$U,zU,UU,E4,CU,w4,P4,k1]);class k extends Error{constructor(Q,Y,X){super(`MCP error ${Q}: ${Y}`);this.code=Q,this.data=X,this.name="McpError"}static fromError(Q,Y,X){if(Q===g.UrlElicitationRequired&&X){let W=X;if(W.elicitations)return new cG(W.elicitations,Y)}return new k(Q,Y,X)}}class cG extends k{constructor(Q,Y=`URL elicitation${Q.length>1?"s":""} required`){super(g.UrlElicitationRequired,Y,{elicitations:Q})}get elicitations(){return this.data?.elicitations??[]}}function z1(Q){return Q==="completed"||Q==="failed"||Q==="cancelled"}var OA=Symbol("Let zodToJsonSchema decide on which parser to use");var zw=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function P9(Q){let X=B4(Q)?.method;if(!X)throw Error("Schema is missing a method literal");let W=aW(X);if(typeof W!=="string")throw Error("Schema method literal must be a string");return W}function I9(Q,Y){let X=$1(Q,Y);if(!X.success)throw X.error;return X.data}var bA=60000;class E9{constructor(Q){if(this._options=Q,this._requestMessageId=0,this._requestHandlers=new Map,this._requestHandlerAbortControllers=new Map,this._notificationHandlers=new Map,this._responseHandlers=new Map,this._progressHandlers=new Map,this._timeoutInfo=new Map,this._pendingDebouncedNotifications=new Set,this._taskProgressTokens=new Map,this._requestResolvers=new Map,this.setNotificationHandler(M4,(Y)=>{this._oncancel(Y)}),this.setNotificationHandler(Z4,(Y)=>{this._onprogress(Y)}),this.setRequestHandler(V4,(Y)=>({})),this._taskStore=Q?.taskStore,this._taskMessageQueue=Q?.taskMessageQueue,this._taskStore)this.setRequestHandler(N4,async(Y,X)=>{let W=await this._taskStore.getTask(Y.params.taskId,X.sessionId);if(!W)throw new k(g.InvalidParams,"Failed to retrieve task: Task not found");return{...W}}),this.setRequestHandler(b4,async(Y,X)=>{let W=async()=>{let G=Y.params.taskId;if(this._taskMessageQueue){let J;while(J=await this._taskMessageQueue.dequeue(G,X.sessionId)){if(J.type==="response"||J.type==="error"){let z=J.message,H=z.id,U=this._requestResolvers.get(H);if(U)if(this._requestResolvers.delete(H),J.type==="response")U(z);else{let A=z,B=new k(A.error.code,A.error.message,A.error.data);U(B)}else{let A=J.type==="response"?"Response":"Error";this._onerror(Error(`${A} handler missing for request ${H}`))}continue}await this._transport?.send(J.message,{relatedRequestId:X.requestId})}}let $=await this._taskStore.getTask(G,X.sessionId);if(!$)throw new k(g.InvalidParams,`Task not found: ${G}`);if(!z1($.status))return await this._waitForTaskUpdate(G,X.signal),await W();if(z1($.status)){let J=await this._taskStore.getTaskResult(G,X.sessionId);return this._clearTaskQueue(G),{...J,_meta:{...J._meta,[J1]:{taskId:G}}}}return await W()};return await W()}),this.setRequestHandler(j4,async(Y,X)=>{try{let{tasks:W,nextCursor:G}=await this._taskStore.listTasks(Y.params?.cursor,X.sessionId);return{tasks:W,nextCursor:G,_meta:{}}}catch(W){throw new k(g.InvalidParams,`Failed to list tasks: ${W instanceof Error?W.message:String(W)}`)}}),this.setRequestHandler(I4,async(Y,X)=>{try{let W=await this._taskStore.getTask(Y.params.taskId,X.sessionId);if(!W)throw new k(g.InvalidParams,`Task not found: ${Y.params.taskId}`);if(z1(W.status))throw new k(g.InvalidParams,`Cannot cancel task in terminal status: ${W.status}`);await this._taskStore.updateTaskStatus(Y.params.taskId,"cancelled","Client cancelled task execution.",X.sessionId),this._clearTaskQueue(Y.params.taskId);let G=await this._taskStore.getTask(Y.params.taskId,X.sessionId);if(!G)throw new k(g.InvalidParams,`Task not found after cancellation: ${Y.params.taskId}`);return{_meta:{},...G}}catch(W){if(W instanceof k)throw W;throw new k(g.InvalidRequest,`Failed to cancel task: ${W instanceof Error?W.message:String(W)}`)}})}async _oncancel(Q){if(!Q.params.requestId)return;this._requestHandlerAbortControllers.get(Q.params.requestId)?.abort(Q.params.reason)}_setupTimeout(Q,Y,X,W,G=!1){this._timeoutInfo.set(Q,{timeoutId:setTimeout(W,Y),startTime:Date.now(),timeout:Y,maxTotalTimeout:X,resetTimeoutOnProgress:G,onTimeout:W})}_resetTimeout(Q){let Y=this._timeoutInfo.get(Q);if(!Y)return!1;let X=Date.now()-Y.startTime;if(Y.maxTotalTimeout&&X>=Y.maxTotalTimeout)throw this._timeoutInfo.delete(Q),k.fromError(g.RequestTimeout,"Maximum total timeout exceeded",{maxTotalTimeout:Y.maxTotalTimeout,totalElapsed:X});return clearTimeout(Y.timeoutId),Y.timeoutId=setTimeout(Y.onTimeout,Y.timeout),!0}_cleanupTimeout(Q){let Y=this._timeoutInfo.get(Q);if(Y)clearTimeout(Y.timeoutId),this._timeoutInfo.delete(Q)}async connect(Q){this._transport=Q;let Y=this.transport?.onclose;this._transport.onclose=()=>{Y?.(),this._onclose()};let X=this.transport?.onerror;this._transport.onerror=(G)=>{X?.(G),this._onerror(G)};let W=this._transport?.onmessage;this._transport.onmessage=(G,$)=>{if(W?.(G,$),U6(G)||xG(G))this._onresponse(G);else if(z9(G))this._onrequest(G,$);else if(vG(G))this._onnotification(G);else this._onerror(Error(`Unknown message type: ${JSON.stringify(G)}`))},await this._transport.start()}_onclose(){let Q=this._responseHandlers;this._responseHandlers=new Map,this._progressHandlers.clear(),this._taskProgressTokens.clear(),this._pendingDebouncedNotifications.clear();let Y=k.fromError(g.ConnectionClosed,"Connection closed");this._transport=void 0,this.onclose?.();for(let X of Q.values())X(Y)}_onerror(Q){this.onerror?.(Q)}_onnotification(Q){let Y=this._notificationHandlers.get(Q.method)??this.fallbackNotificationHandler;if(Y===void 0)return;Promise.resolve().then(()=>Y(Q)).catch((X)=>this._onerror(Error(`Uncaught error in notification handler: ${X}`)))}_onrequest(Q,Y){let X=this._requestHandlers.get(Q.method)??this.fallbackRequestHandler,W=this._transport,G=Q.params?._meta?.[J1]?.taskId;if(X===void 0){let U={jsonrpc:"2.0",id:Q.id,error:{code:g.MethodNotFound,message:"Method not found"}};if(G&&this._taskMessageQueue)this._enqueueTaskMessage(G,{type:"error",message:U,timestamp:Date.now()},W?.sessionId).catch((A)=>this._onerror(Error(`Failed to enqueue error response: ${A}`)));else W?.send(U).catch((A)=>this._onerror(Error(`Failed to send an error response: ${A}`)));return}let $=new AbortController;this._requestHandlerAbortControllers.set(Q.id,$);let J=RG(Q.params)?Q.params.task:void 0,z=this._taskStore?this.requestTaskStore(Q,W?.sessionId):void 0,H={signal:$.signal,sessionId:W?.sessionId,_meta:Q.params?._meta,sendNotification:async(U)=>{let A={relatedRequestId:Q.id};if(G)A.relatedTask={taskId:G};await this.notification(U,A)},sendRequest:async(U,A,B)=>{let K={...B,relatedRequestId:Q.id};if(G&&!K.relatedTask)K.relatedTask={taskId:G};let L=K.relatedTask?.taskId??G;if(L&&z)await z.updateTaskStatus(L,"input_required");return await this.request(U,A,K)},authInfo:Y?.authInfo,requestId:Q.id,requestInfo:Y?.requestInfo,taskId:G,taskStore:z,taskRequestedTtl:J?.ttl,closeSSEStream:Y?.closeSSEStream,closeStandaloneSSEStream:Y?.closeStandaloneSSEStream};Promise.resolve().then(()=>{if(J)this.assertTaskHandlerCapability(Q.method)}).then(()=>X(Q,H)).then(async(U)=>{if($.signal.aborted)return;let A={result:U,jsonrpc:"2.0",id:Q.id};if(G&&this._taskMessageQueue)await this._enqueueTaskMessage(G,{type:"response",message:A,timestamp:Date.now()},W?.sessionId);else await W?.send(A)},async(U)=>{if($.signal.aborted)return;let A={jsonrpc:"2.0",id:Q.id,error:{code:Number.isSafeInteger(U.code)?U.code:g.InternalError,message:U.message??"Internal error",...U.data!==void 0&&{data:U.data}}};if(G&&this._taskMessageQueue)await this._enqueueTaskMessage(G,{type:"error",message:A,timestamp:Date.now()},W?.sessionId);else await W?.send(A)}).catch((U)=>this._onerror(Error(`Failed to send response: ${U}`))).finally(()=>{this._requestHandlerAbortControllers.delete(Q.id)})}_onprogress(Q){let{progressToken:Y,...X}=Q.params,W=Number(Y),G=this._progressHandlers.get(W);if(!G){this._onerror(Error(`Received a progress notification for an unknown token: ${JSON.stringify(Q)}`));return}let $=this._responseHandlers.get(W),J=this._timeoutInfo.get(W);if(J&&$&&J.resetTimeoutOnProgress)try{this._resetTimeout(W)}catch(z){this._responseHandlers.delete(W),this._progressHandlers.delete(W),this._cleanupTimeout(W),$(z);return}G(X)}_onresponse(Q){let Y=Number(Q.id),X=this._requestResolvers.get(Y);if(X){if(this._requestResolvers.delete(Y),U6(Q))X(Q);else{let $=new k(Q.error.code,Q.error.message,Q.error.data);X($)}return}let W=this._responseHandlers.get(Y);if(W===void 0){this._onerror(Error(`Received a response for an unknown message ID: ${JSON.stringify(Q)}`));return}this._responseHandlers.delete(Y),this._cleanupTimeout(Y);let G=!1;if(U6(Q)&&Q.result&&typeof Q.result==="object"){let $=Q.result;if($.task&&typeof $.task==="object"){let J=$.task;if(typeof J.taskId==="string")G=!0,this._taskProgressTokens.set(J.taskId,Y)}}if(!G)this._progressHandlers.delete(Y);if(U6(Q))W(Q);else{let $=k.fromError(Q.error.code,Q.error.message,Q.error.data);W($)}}get transport(){return this._transport}async close(){await this._transport?.close()}async*requestStream(Q,Y,X){let{task:W}=X??{};if(!W){try{yield{type:"result",result:await this.request(Q,Y,X)}}catch($){yield{type:"error",error:$ instanceof k?$:new k(g.InternalError,String($))}}return}let G;try{let $=await this.request(Q,k1,X);if($.task)G=$.task.taskId,yield{type:"taskCreated",task:$.task};else throw new k(g.InternalError,"Task creation did not return a task");while(!0){let J=await this.getTask({taskId:G},X);if(yield{type:"taskStatus",task:J},z1(J.status)){if(J.status==="completed")yield{type:"result",result:await this.getTaskResult({taskId:G},Y,X)};else if(J.status==="failed")yield{type:"error",error:new k(g.InternalError,`Task ${G} failed`)};else if(J.status==="cancelled")yield{type:"error",error:new k(g.InternalError,`Task ${G} was cancelled`)};return}if(J.status==="input_required"){yield{type:"result",result:await this.getTaskResult({taskId:G},Y,X)};return}let z=J.pollInterval??this._options?.defaultTaskPollInterval??1000;await new Promise((H)=>setTimeout(H,z)),X?.signal?.throwIfAborted()}}catch($){yield{type:"error",error:$ instanceof k?$:new k(g.InternalError,String($))}}}request(Q,Y,X){let{relatedRequestId:W,resumptionToken:G,onresumptiontoken:$,task:J,relatedTask:z}=X??{};return new Promise((H,U)=>{let A=(V)=>{U(V)};if(!this._transport){A(Error("Not connected"));return}if(this._options?.enforceStrictCapabilities===!0)try{if(this.assertCapabilityForMethod(Q.method),J)this.assertTaskCapability(Q.method)}catch(V){A(V);return}X?.signal?.throwIfAborted();let B=this._requestMessageId++,K={...Q,jsonrpc:"2.0",id:B};if(X?.onprogress)this._progressHandlers.set(B,X.onprogress),K.params={...Q.params,_meta:{...Q.params?._meta||{},progressToken:B}};if(J)K.params={...K.params,task:J};if(z)K.params={...K.params,_meta:{...K.params?._meta||{},[J1]:z}};let L=(V)=>{this._responseHandlers.delete(B),this._progressHandlers.delete(B),this._cleanupTimeout(B),this._transport?.send({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:B,reason:String(V)}},{relatedRequestId:W,resumptionToken:G,onresumptiontoken:$}).catch((E)=>this._onerror(Error(`Failed to send cancellation: ${E}`)));let S=V instanceof k?V:new k(g.RequestTimeout,String(V));U(S)};this._responseHandlers.set(B,(V)=>{if(X?.signal?.aborted)return;if(V instanceof Error)return U(V);try{let S=$1(Y,V.result);if(!S.success)U(S.error);else H(S.data)}catch(S){U(S)}}),X?.signal?.addEventListener("abort",()=>{L(X?.signal?.reason)});let O=X?.timeout??bA,M=()=>L(k.fromError(g.RequestTimeout,"Request timed out",{timeout:O}));this._setupTimeout(B,O,X?.maxTotalTimeout,M,X?.resetTimeoutOnProgress??!1);let Z=z?.taskId;if(Z){let V=(S)=>{let E=this._responseHandlers.get(B);if(E)E(S);else this._onerror(Error(`Response handler missing for side-channeled request ${B}`))};this._requestResolvers.set(B,V),this._enqueueTaskMessage(Z,{type:"request",message:K,timestamp:Date.now()}).catch((S)=>{this._cleanupTimeout(B),U(S)})}else this._transport.send(K,{relatedRequestId:W,resumptionToken:G,onresumptiontoken:$}).catch((V)=>{this._cleanupTimeout(B),U(V)})})}async getTask(Q,Y){return this.request({method:"tasks/get",params:Q},w4,Y)}async getTaskResult(Q,Y,X){return this.request({method:"tasks/result",params:Q},Y,X)}async listTasks(Q,Y){return this.request({method:"tasks/list",params:Q},P4,Y)}async cancelTask(Q,Y){return this.request({method:"tasks/cancel",params:Q},gG,Y)}async notification(Q,Y){if(!this._transport)throw Error("Not connected");this.assertNotificationCapability(Q.method);let X=Y?.relatedTask?.taskId;if(X){let J={...Q,jsonrpc:"2.0",params:{...Q.params,_meta:{...Q.params?._meta||{},[J1]:Y.relatedTask}}};await this._enqueueTaskMessage(X,{type:"notification",message:J,timestamp:Date.now()});return}if((this._options?.debouncedNotificationMethods??[]).includes(Q.method)&&!Q.params&&!Y?.relatedRequestId&&!Y?.relatedTask){if(this._pendingDebouncedNotifications.has(Q.method))return;this._pendingDebouncedNotifications.add(Q.method),Promise.resolve().then(()=>{if(this._pendingDebouncedNotifications.delete(Q.method),!this._transport)return;let J={...Q,jsonrpc:"2.0"};if(Y?.relatedTask)J={...J,params:{...J.params,_meta:{...J.params?._meta||{},[J1]:Y.relatedTask}}};this._transport?.send(J,Y).catch((z)=>this._onerror(z))});return}let $={...Q,jsonrpc:"2.0"};if(Y?.relatedTask)$={...$,params:{...$.params,_meta:{...$.params?._meta||{},[J1]:Y.relatedTask}}};await this._transport.send($,Y)}setRequestHandler(Q,Y){let X=P9(Q);this.assertRequestHandlerCapability(X),this._requestHandlers.set(X,(W,G)=>{let $=I9(Q,W);return Promise.resolve(Y($,G))})}removeRequestHandler(Q){this._requestHandlers.delete(Q)}assertCanSetRequestHandler(Q){if(this._requestHandlers.has(Q))throw Error(`A request handler for ${Q} already exists, which would be overridden`)}setNotificationHandler(Q,Y){let X=P9(Q);this._notificationHandlers.set(X,(W)=>{let G=I9(Q,W);return Promise.resolve(Y(G))})}removeNotificationHandler(Q){this._notificationHandlers.delete(Q)}_cleanupTaskProgressHandler(Q){let Y=this._taskProgressTokens.get(Q);if(Y!==void 0)this._progressHandlers.delete(Y),this._taskProgressTokens.delete(Q)}async _enqueueTaskMessage(Q,Y,X){if(!this._taskStore||!this._taskMessageQueue)throw Error("Cannot enqueue task message: taskStore and taskMessageQueue are not configured");let W=this._options?.maxTaskQueueSize;await this._taskMessageQueue.enqueue(Q,Y,X,W)}async _clearTaskQueue(Q,Y){if(this._taskMessageQueue){let X=await this._taskMessageQueue.dequeueAll(Q,Y);for(let W of X)if(W.type==="request"&&z9(W.message)){let G=W.message.id,$=this._requestResolvers.get(G);if($)$(new k(g.InternalError,"Task cancelled or completed")),this._requestResolvers.delete(G);else this._onerror(Error(`Resolver missing for request ${G} during task ${Q} cleanup`))}}}async _waitForTaskUpdate(Q,Y){let X=this._options?.defaultTaskPollInterval??1000;try{let W=await this._taskStore?.getTask(Q);if(W?.pollInterval)X=W.pollInterval}catch{}return new Promise((W,G)=>{if(Y.aborted){G(new k(g.InvalidRequest,"Request cancelled"));return}let $=setTimeout(W,X);Y.addEventListener("abort",()=>{clearTimeout($),G(new k(g.InvalidRequest,"Request cancelled"))},{once:!0})})}requestTaskStore(Q,Y){let X=this._taskStore;if(!X)throw Error("No task store configured");return{createTask:async(W)=>{if(!Q)throw Error("No request provided");return await X.createTask(W,Q.id,{method:Q.method,params:Q.params},Y)},getTask:async(W)=>{let G=await X.getTask(W,Y);if(!G)throw new k(g.InvalidParams,"Failed to retrieve task: Task not found");return G},storeTaskResult:async(W,G,$)=>{await X.storeTaskResult(W,G,$,Y);let J=await X.getTask(W,Y);if(J){let z=L6.parse({method:"notifications/tasks/status",params:J});if(await this.notification(z),z1(J.status))this._cleanupTaskProgressHandler(W)}},getTaskResult:(W)=>{return X.getTaskResult(W,Y)},updateTaskStatus:async(W,G,$)=>{let J=await X.getTask(W,Y);if(!J)throw new k(g.InvalidParams,`Task "${W}" not found - it may have been cleaned up`);if(z1(J.status))throw new k(g.InvalidParams,`Cannot update task "${W}" from terminal status "${J.status}" to "${G}". Terminal states (completed, failed, cancelled) cannot transition to other states.`);await X.updateTaskStatus(W,G,$,Y);let z=await X.getTask(W,Y);if(z){let H=L6.parse({method:"notifications/tasks/status",params:z});if(await this.notification(H),z1(z.status))this._cleanupTaskProgressHandler(W)}},listTasks:(W)=>{return X.listTasks(W,Y)}}}}function pG(Q){return Q!==null&&typeof Q==="object"&&!Array.isArray(Q)}function iG(Q,Y){let X={...Q};for(let W in Y){let G=W,$=Y[G];if($===void 0)continue;let J=X[G];if(pG(J)&&pG($))X[G]={...J,...$};else X[G]=$}return X}var w5=oY(NY(),1),b5=oY(N5(),1);function kM(){let Q=new w5.default({strict:!1,validateFormats:!0,validateSchema:!1,allErrors:!0});return b5.default(Q),Q}class CY{constructor(Q){this._ajv=Q??kM()}getValidator(Q){let Y="$id"in Q&&typeof Q.$id==="string"?this._ajv.getSchema(Q.$id)??this._ajv.compile(Q):this._ajv.compile(Q);return(X)=>{if(Y(X))return{valid:!0,data:X,errorMessage:void 0};else return{valid:!1,data:void 0,errorMessage:this._ajv.errorsText(Y.errors)}}}}class kY{constructor(Q){this._server=Q}requestStream(Q,Y,X){return this._server.requestStream(Q,Y,X)}async getTask(Q,Y){return this._server.getTask({taskId:Q},Y)}async getTaskResult(Q,Y,X){return this._server.getTaskResult({taskId:Q},Y,X)}async listTasks(Q,Y){return this._server.listTasks(Q?{cursor:Q}:void 0,Y)}async cancelTask(Q,Y){return this._server.cancelTask({taskId:Q},Y)}}function j5(Q,Y,X){if(!Q)throw Error(`${X} does not support task creation (required for ${Y})`);switch(Y){case"tools/call":if(!Q.tools?.call)throw Error(`${X} does not support task creation for tools/call (required for ${Y})`);break;default:break}}function P5(Q,Y,X){if(!Q)throw Error(`${X} does not support task creation (required for ${Y})`);switch(Y){case"sampling/createMessage":if(!Q.sampling?.createMessage)throw Error(`${X} does not support task creation for sampling/createMessage (required for ${Y})`);break;case"elicitation/create":if(!Q.elicitation?.create)throw Error(`${X} does not support task creation for elicitation/create (required for ${Y})`);break;default:break}}class vY extends E9{constructor(Q,Y){super(Y);if(this._serverInfo=Q,this._loggingLevels=new Map,this.LOG_LEVEL_SEVERITY=new Map(O6.options.map((X,W)=>[X,W])),this.isMessageIgnored=(X,W)=>{let G=this._loggingLevels.get(W);return G?this.LOG_LEVEL_SEVERITY.get(X)<this.LOG_LEVEL_SEVERITY.get(G):!1},this._capabilities=Y?.capabilities??{},this._instructions=Y?.instructions,this._jsonSchemaValidator=Y?.jsonSchemaValidator??new CY,this.setRequestHandler(A9,(X)=>this._oninitialize(X)),this.setNotificationHandler(B9,()=>this.oninitialized?.()),this._capabilities.logging)this.setRequestHandler(N9,async(X,W)=>{let G=W.sessionId||W.requestInfo?.headers["mcp-session-id"]||void 0,{level:$}=X.params,J=O6.safeParse($);if(J.success)this._loggingLevels.set(G,J.data);return{}})}get experimental(){if(!this._experimental)this._experimental={tasks:new kY(this)};return this._experimental}registerCapabilities(Q){if(this.transport)throw Error("Cannot register capabilities after connecting to transport");this._capabilities=iG(this._capabilities,Q)}setRequestHandler(Q,Y){let W=B4(Q)?.method;if(!W)throw Error("Schema is missing a method literal");let G;if(R1(W)){let J=W;G=J._zod?.def?.value??J.value}else{let J=W;G=J._def?.value??J.value}if(typeof G!=="string")throw Error("Schema method literal must be a string");if(G==="tools/call"){let J=async(z,H)=>{let U=$1(F6,z);if(!U.success){let L=U.error instanceof Error?U.error.message:String(U.error);throw new k(g.InvalidParams,`Invalid tools/call request: ${L}`)}let{params:A}=U.data,B=await Promise.resolve(Y(z,H));if(A.task){let L=$1(k1,B);if(!L.success){let O=L.error instanceof Error?L.error.message:String(L.error);throw new k(g.InvalidParams,`Invalid task creation result: ${O}`)}return L.data}let K=$1(E4,B);if(!K.success){let L=K.error instanceof Error?K.error.message:String(K.error);throw new k(g.InvalidParams,`Invalid tools/call result: ${L}`)}return K.data};return super.setRequestHandler(Q,J)}return super.setRequestHandler(Q,Y)}assertCapabilityForMethod(Q){switch(Q){case"sampling/createMessage":if(!this._clientCapabilities?.sampling)throw Error(`Client does not support sampling (required for ${Q})`);break;case"elicitation/create":if(!this._clientCapabilities?.elicitation)throw Error(`Client does not support elicitation (required for ${Q})`);break;case"roots/list":if(!this._clientCapabilities?.roots)throw Error(`Client does not support listing roots (required for ${Q})`);break;case"ping":break}}assertNotificationCapability(Q){switch(Q){case"notifications/message":if(!this._capabilities.logging)throw Error(`Server does not support logging (required for ${Q})`);break;case"notifications/resources/updated":case"notifications/resources/list_changed":if(!this._capabilities.resources)throw Error(`Server does not support notifying about resources (required for ${Q})`);break;case"notifications/tools/list_changed":if(!this._capabilities.tools)throw Error(`Server does not support notifying of tool list changes (required for ${Q})`);break;case"notifications/prompts/list_changed":if(!this._capabilities.prompts)throw Error(`Server does not support notifying of prompt list changes (required for ${Q})`);break;case"notifications/elicitation/complete":if(!this._clientCapabilities?.elicitation?.url)throw Error(`Client does not support URL elicitation (required for ${Q})`);break;case"notifications/cancelled":break;case"notifications/progress":break}}assertRequestHandlerCapability(Q){if(!this._capabilities)return;switch(Q){case"completion/complete":if(!this._capabilities.completions)throw Error(`Server does not support completions (required for ${Q})`);break;case"logging/setLevel":if(!this._capabilities.logging)throw Error(`Server does not support logging (required for ${Q})`);break;case"prompts/get":case"prompts/list":if(!this._capabilities.prompts)throw Error(`Server does not support prompts (required for ${Q})`);break;case"resources/list":case"resources/templates/list":case"resources/read":if(!this._capabilities.resources)throw Error(`Server does not support resources (required for ${Q})`);break;case"tools/call":case"tools/list":if(!this._capabilities.tools)throw Error(`Server does not support tools (required for ${Q})`);break;case"tasks/get":case"tasks/list":case"tasks/result":case"tasks/cancel":if(!this._capabilities.tasks)throw Error(`Server does not support tasks capability (required for ${Q})`);break;case"ping":case"initialize":break}}assertTaskCapability(Q){P5(this._clientCapabilities?.tasks?.requests,Q,"Client")}assertTaskHandlerCapability(Q){if(!this._capabilities)return;j5(this._capabilities.tasks?.requests,Q,"Server")}async _oninitialize(Q){let Y=Q.params.protocolVersion;return this._clientCapabilities=Q.params.capabilities,this._clientVersion=Q.params.clientInfo,{protocolVersion:EG.includes(Y)?Y:$9,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"},O4)}async createMessage(Q,Y){if(Q.tools||Q.toolChoice){if(!this._clientCapabilities?.sampling?.tools)throw Error("Client does not support sampling tools capability.")}if(Q.messages.length>0){let X=Q.messages[Q.messages.length-1],W=Array.isArray(X.content)?X.content:[X.content],G=W.some((H)=>H.type==="tool_result"),$=Q.messages.length>1?Q.messages[Q.messages.length-2]:void 0,J=$?Array.isArray($.content)?$.content:[$.content]:[],z=J.some((H)=>H.type==="tool_use");if(G){if(W.some((H)=>H.type!=="tool_result"))throw Error("The last message must contain only tool_result content if any is present");if(!z)throw Error("tool_result blocks are not matching any tool_use from the previous message")}if(z){let H=new Set(J.filter((A)=>A.type==="tool_use").map((A)=>A.id)),U=new Set(W.filter((A)=>A.type==="tool_result").map((A)=>A.toolUseId));if(H.size!==U.size||![...H].every((A)=>U.has(A)))throw Error("ids of tool_result blocks and tool_use blocks from previous message do not match")}}if(Q.tools)return this.request({method:"sampling/createMessage",params:Q},b9,Y);return this.request({method:"sampling/createMessage",params:Q},w9,Y)}async elicitInput(Q,Y){switch(Q.mode??"form"){case"url":{if(!this._clientCapabilities?.elicitation?.url)throw Error("Client does not support url elicitation.");let W=Q;return this.request({method:"elicitation/create",params:W},T4,Y)}case"form":{if(!this._clientCapabilities?.elicitation?.form)throw Error("Client does not support form elicitation.");let W=Q.mode==="form"?Q:{...Q,mode:"form"},G=await this.request({method:"elicitation/create",params:W},T4,Y);if(G.action==="accept"&&G.content&&W.requestedSchema)try{let J=this._jsonSchemaValidator.getValidator(W.requestedSchema)(G.content);if(!J.valid)throw new k(g.InvalidParams,`Elicitation response content does not match requested schema: ${J.errorMessage}`)}catch($){if($ instanceof k)throw $;throw new k(g.InternalError,`Error validating elicitation response: ${$ instanceof Error?$.message:String($)}`)}return G}}}createElicitationCompletionNotifier(Q,Y){if(!this._clientCapabilities?.elicitation?.url)throw Error("Client does not support URL elicitation (required for notifications/elicitation/complete)");return()=>this.notification({method:"notifications/elicitation/complete",params:{elicitationId:Q}},Y)}async listRoots(Q,Y){return this.request({method:"roots/list",params:Q},j9,Y)}async sendLoggingMessage(Q,Y){if(this._capabilities.logging){if(!this.isMessageIgnored(Q.level,Y))return this.notification({method:"notifications/message",params:Q})}}async sendResourceUpdated(Q){return this.notification({method:"notifications/resources/updated",params:Q})}async sendResourceListChanged(){return this.notification({method:"notifications/resources/list_changed"})}async sendToolListChanged(){return this.notification({method:"notifications/tools/list_changed"})}async sendPromptListChanged(){return this.notification({method:"notifications/prompts/list_changed"})}}var I5={name:"@sequenzy/mcp",version:"0.0.56",mcpName:"io.github.sequenzy/mcp",description:"Sequenzy MCP server for AI-powered email marketing automation",type:"module",bin:{"sequenzy-mcp":"dist/index.js"},main:"./dist/index.js",exports:{".":"./dist/index.js","./server":"./dist/server.js","./runtime":"./dist/runtime.js","./server.json":"./server.json"},scripts:{dev:"bun --watch src/index.ts",build:"bun build src/index.ts src/server.ts src/runtime.ts --outdir dist --target node --minify",start:"node dist/index.js","type-check":"tsc --noEmit",test:"bun test","test:watch":"bun test --watch",prepublishOnly:"bun run build"},dependencies:{"@modelcontextprotocol/sdk":"^1.0.0"},devDependencies:{"@types/bun":"latest","@types/node":"^22.0.0","bun-types":"latest",typescript:"^5.8.0"},files:["dist","server.json"],keywords:["sequenzy","email","mcp","ai","claude","automation"],license:"MIT",publishConfig:{access:"public"},repository:{type:"git",url:"git+https://github.com/Sequenzy/mcp.git"},homepage:"https://sequenzy.com",bugs:{url:"https://github.com/Sequenzy/mcp/issues"}};var xY=["product-info","domain","tracking","localization","integrations","products","events","tags","labels","goals","sync-rules","api-keys","widgets","team","danger"],E5={dashboard:"/dashboard/company/{companyId}",campaigns:"/dashboard/company/{companyId}/campaign",campaign:"/dashboard/company/{companyId}/campaign/{campaignId}",campaignPreview:"/dashboard/company/{companyId}/campaign/{campaignId}?step=review",campaignList:"/dashboard/company/{companyId}/campaign/list/{status}",sequences:"/dashboard/company/{companyId}/sequences",sequence:"/dashboard/company/{companyId}/sequences/{sequenceId}",sequenceList:"/dashboard/company/{companyId}/sequences/list/{status}",settings:"/dashboard/company/{companyId}/settings",settingsTab:"/dashboard/company/{companyId}/settings?tab={tab}",emails:"/dashboard/company/{companyId}/emails",email:"/dashboard/company/{companyId}/emails/{emailId}",subscribers:"/dashboard/company/{companyId}/subscribers",sentEmails:"/dashboard/company/{companyId}/sent-emails",emailSend:"/dashboard/company/{companyId}/sent-emails/{emailSendId}",segments:"/dashboard/company/{companyId}/segments",metrics:"/dashboard/company/{companyId}/metrics",transactional:"/dashboard/company/{companyId}/transactional",transactionalEmail:"/dashboard/company/{companyId}/transactional/{transactionalId}",domain:"/dashboard/company/{companyId}/settings/domain/{domainId}",domainVerify:"/dashboard/company/{companyId}/settings/domain/{domainId}/verify"};function xM(Q){let X=(Q??process.env.SEQUENZY_APP_URL??"https://sequenzy.com").trim().replace(/\/+$/,"");return X.length>0?X:"https://sequenzy.com"}function f0(Q){let Y=Q?.trim();return Y?Y:void 0}function a0(Q){return encodeURIComponent(Q)}function Y0(Q,Y){return`${Q}${Y}`}function X0(Q,Y=""){return`/dashboard/company/${a0(Q)}${Y}`}function T5(Q,Y,X){return Y0(Q,`${X0(Y,"/settings")}?tab=${encodeURIComponent(X)}`)}function _M(Q,Y){let X=xY.map((W)=>[W,Y?T5(Q,Y,W):""]);return Object.fromEntries(X)}function q1(Q={},Y){let X=xM(Y),W=f0(Q.companyId),G={},$=_M(X,W);if(!W)return{appUrl:X,routeTemplates:E5,settingsTabValues:xY,urls:G,settingsUrls:$};G.dashboard=Y0(X,X0(W)),G.campaigns=Y0(X,X0(W,"/campaign")),G.sequences=Y0(X,X0(W,"/sequences")),G.settings=Y0(X,X0(W,"/settings")),G.emails=Y0(X,X0(W,"/emails")),G.subscribers=Y0(X,X0(W,"/subscribers")),G.sentEmails=Y0(X,X0(W,"/sent-emails")),G.segments=Y0(X,X0(W,"/segments")),G.metrics=Y0(X,X0(W,"/metrics")),G.transactional=Y0(X,X0(W,"/transactional"));let J=f0(Q.campaignId);if(J)G.campaign=Y0(X,X0(W,`/campaign/${a0(J)}`)),G.campaignPreview=`${G.campaign}?step=review`;let z=f0(Q.sequenceId);if(z)G.sequence=Y0(X,X0(W,`/sequences/${a0(z)}`));let H=f0(Q.emailId)??f0(Q.templateId);if(H)G.email=Y0(X,X0(W,`/emails/${a0(H)}`)),G.template=G.email;let U=f0(Q.transactionalId);if(U)G.transactionalEmail=Y0(X,X0(W,`/transactional/${a0(U)}`));let A=f0(Q.emailSendId);if(A)G.emailSend=Y0(X,X0(W,`/sent-emails/${a0(A)}`));let B=f0(Q.domainId);if(B)G.domain=Y0(X,X0(W,`/settings/domain/${a0(B)}`)),G.domainVerify=`${G.domain}/verify`;let K=f0(Q.status);if(K)G.campaignList=Y0(X,X0(W,`/campaign/list/${a0(K)}`)),G.sequenceList=Y0(X,X0(W,`/sequences/list/${a0(K)}`));let L=f0(Q.settingsTab);if(L)G.settingsTab=T5(X,W,L);return{appUrl:X,routeTemplates:E5,settingsTabValues:xY,urls:G,settingsUrls:$}}var S5=[{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 R5(Q){try{let Y;switch(Q){case"sequenzy://dashboard":Y=await F("GET","/api/v1/metrics?period=7d");break;case"sequenzy://company":{let X=await F("GET","/api/v1/account"),W=Q1()??X.currentCompanyId;if(!W)throw Error("No company available. Create or select a company first.");Y=await F("GET",`/api/v1/companies/${W}`);break}case"sequenzy://campaigns/recent":Y=await F("GET","/api/v1/campaigns?limit=10");break;case"sequenzy://subscribers/recent":Y=await F("GET","/api/v1/subscribers?sort=createdAt&limit=20");break;case"sequenzy://subscribers/engaged":Y=await F("GET","/api/v1/subscribers?sort=engagement&limit=20");break;case"sequenzy://sequences":Y=await F("GET","/api/v1/sequences");break;case"sequenzy://templates":Y=await F("GET","/api/v1/templates");break;case"sequenzy://segments":Y=await F("GET","/api/v1/segments");break;case"sequenzy://tags":Y=await F("GET","/api/v1/tags");break;case"sequenzy://health":Y=await F("GET","/api/v1/health/deliverability");break;case"sequenzy://app-routes":Y=q1();break;default:throw Error(`Unknown resource: ${Q}`)}return{contents:[{uri:Q,mimeType:"application/json",text:JSON.stringify(Y,null,2)}]}}catch(Y){return{contents:[{uri:Q,mimeType:"text/plain",text:e0(Y)}]}}}import{readFileSync as yM,statSync as gM}from"node:fs";import{basename as uM}from"node:path";var m6="Sequenzy email blocks. Use `styles` for per-block background, background opacity, text color, padding, border radius, border width, and border color. Top-level style aliases such as `backgroundColor`, `backgroundOpacity`, `borderColor`, `borderWidth`, and `borderRadius` are also accepted and saved under `styles`. Use this for editor-compatible content, including conditional and repeat blocks. Repeat blocks use { type: 'repeat', source: 'items', itemAlias: 'item', children: [...] }.",i1="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`.",u5="Sequenzy email blocks. Provide blocks or html for email steps. Use `styles` for per-block background, background opacity, text color, padding, border radius, border width, and border color. Top-level style aliases such as `backgroundColor`, `backgroundOpacity`, `borderColor`, `borderWidth`, and `borderRadius` are also accepted and saved under `styles`. Blocks can include repeat blocks over array variables such as items.",C5=500,qQ=["gray","red","orange","amber","yellow","lime","green","emerald","teal","cyan","sky","blue","indigo","violet","purple","fuchsia","pink","rose"],FQ=["email.sent","email.delivered","email.delivery_delayed","email.bounced","email.complained","email.opened","email.clicked","email.unsubscribed","subscriber.invalid","subscriber.updated","subscriber.unsubscribed","sequence.finished","sequence.failed"],uY={status:["is","is_not"],tag:["contains","not_contains","is_empty","is_not_empty"],email:["contains","not_contains"],emailProvider:["is","is_not","is_empty","is_not_empty"],added:["less_than","more_than"],firstName:["contains","not_contains","is_empty","is_not_empty"],lastName:["contains","not_contains","is_empty","is_not_empty"],list:["is","is_not","is_empty","is_not_empty"],emailSent:["is","is_not","at_least","less_than_count"],emailDelivered:["is","is_not","at_least","less_than_count"],emailOpened:["is","is_not","at_least","less_than_count"],emailClicked:["is","is_not","at_least","less_than_count"],emailBounced:["is","is_temporary_bounce","is_permanent_bounce","is_not","at_least","less_than_count"],emailComplained:["is","is_not","at_least","less_than_count"],attribute:["is","is_not","is_empty","is_not_empty","gte","lte","gt","lt","contains","not_contains"],event:["is","is_not","at_least","less_than_count"],segment:["is","is_not"],stripeProduct:["is","is_not","at_least","less_than_count"],stripeCurrentProduct:["is","is_not","gte","lte","gt","lt"],stripeTrialProduct:["is","is_not","gte","lte","gt","lt"],commerceProduct:["is","is_not","at_least","less_than_count"]},hM=Object.entries(uY).map(([Q,Y])=>`${Q}: ${Y.join(", ")}`).join("; "),k5={type:"object",properties:{id:{type:"string",description:"Optional filter ID. Any stable string works; one will be generated if omitted."},field:{type:"string",enum:["status","tag","email","emailProvider","added","firstName","lastName","list","emailSent","emailDelivered","emailOpened","emailClicked","emailBounced","emailComplained","attribute","event","segment","stripeProduct","stripeCurrentProduct","stripeTrialProduct","commerceProduct"],description:"Filter field. 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 or a specific campaign via `campaign:<campaign_id>`."},operator:{type:"string",enum:["is","is_not","is_empty","is_not_empty","contains","not_contains","less_than","more_than","is_temporary_bounce","is_permanent_bounce","at_least","less_than_count","gte","lte","gt","lt"],description:`Filter operator. Allowed operators by field: ${hM}.`},value:{type:"string",description:"Filter value. For custom attribute empty checks, use `attributeName:` such as `last_logged_in:`. Event examples: `saas.purchase:30d`, `saas.purchase:all`, or `saas.purchase:5:30d` for thresholds. Segment values are segment IDs. Stripe product examples: `prod_123` for bought/didn't buy/current/trialing, `prod_123:3` for payment thresholds, `prod_123:is_canceled` for products set to cancel, `prod_123:cancels_at:2026-05-26`, `prod_123:end_at:2026-05-26`, or `prod_123:start_at:7 days ago` for product-scoped dates. Engagement examples: `7d`, `30d`, `90d`, `180d`, `all` for rolling time windows, or `campaign:<campaign_id>` to scope to a specific sent campaign (use `list_campaigns` to find IDs)."}},required:["field","operator","value"],additionalProperties:!1},v5={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 hY(Q){if(!Array.isArray(Q))return Q;return Q.map((Y)=>{if(typeof Y!=="object"||Y===null)return Y;let X=Y;if(typeof X.id==="string"&&X.id.trim()!=="")return X;return{...X,id:crypto.randomUUID()}})}function fY(Q){if(typeof Q!=="object"||Q===null)return Q;let Y=Q;if(Y.kind==="filter"||"field"in Y||"operator"in Y||"value"in Y){let X=hY([Y]);return Array.isArray(X)?X[0]:Y}if(Y.kind!=="group")return Q;return{...Y,id:typeof Y.id==="string"&&Y.id.trim()!==""?Y.id:crypto.randomUUID(),children:Array.isArray(Y.children)?Y.children.map(fY):[]}}function fM(Q){let Y=Q.indexOf(":");return Y!==-1&&Q.substring(0,Y).trim().length>0}function lM(Q){let Y=Q.indexOf(":");return Y!==-1&&Q.substring(Y+1).trim().length>0}function x5(Q){if(Q==="all")return!0;let Y=Q.match(/^(\d+)d$/);if(!Y?.[1])return!1;let X=Number.parseInt(Y[1],10);return Number.isInteger(X)&&X>0}function mM(Q,Y){let X=Y.split(":");if(Q==="at_least"||Q==="less_than_count"){if(X.length<3)return'Event count filters must use "eventName:count:timeRange", like "saas.purchase:2:30d".';let $=X.slice(0,-2).join(":").trim(),J=X.at(-2),z=X.at(-1),H=J===void 0?Number.NaN:Number.parseInt(J,10);return $&&Number.isInteger(H)&&H>0&&z!==void 0&&x5(z)?null:'Event count filters must use "eventName:count:timeRange", like "saas.purchase:2:30d".'}if(X.length<2)return'Event filters must use "eventName:timeRange", like "saas.purchase:30d".';let W=X.slice(0,-1).join(":").trim(),G=X.at(-1);return W&&G!==void 0&&x5(G)?null:'Event filters must use "eventName:timeRange", like "saas.purchase:30d".'}function cM(Q){let Y=Q.indexOf(":");if(Y===-1)return{productId:Q,subfilter:null,rawValue:null};let X=Q.substring(0,Y),W=Q.substring(Y+1),G=W.indexOf(":");if(G===-1)return{productId:X,subfilter:W,rawValue:null};return{productId:X,subfilter:W.substring(0,G),rawValue:W.substring(G+1)}}function pM(Q){return Q.trim().toLowerCase().replace(/[-\s]+/g,"_")}function iM(Q){return["is_canceled","is_cancelled","canceled","cancelled","will_cancel","cancel_at_period_end","is_not_canceled","is_not_cancelled","not_canceled","not_cancelled","will_not_cancel"].includes(Q)}function nM(Q,Y){if(Y==="cancels_at"||Y==="cancel_at"||Y==="cancellation_at")return!0;if(Q==="stripeCurrentProduct")return["end_at","ends_at","period_end","period_ends_at","current_period_end"].includes(Y);return["start_at","started_at","trial_start","trial_started_at","end_at","ends_at","trial_end","trial_ends_at"].includes(Y)}function rM(Q){return["is","is_not","gte","lte","gt","lt"].includes(Q)}function dM(Q,Y,X){if(Q==="stripeProduct"){if(Y!=="at_least"&&Y!=="less_than_count")return null;let z=X.indexOf(":");if(z===-1)return null;let H=X.substring(0,z).trim(),U=Number.parseInt(X.substring(z+1).trim(),10);return H&&Number.isInteger(U)&&U>=1?null:'Stripe Product threshold filters must use "productId:count" with a count of at least 1.'}if(Q!=="stripeCurrentProduct"&&Q!=="stripeTrialProduct")return null;let{productId:W,subfilter:G,rawValue:$}=cM(X);if(!W.trim())return"Stripe product filters must include a product ID.";if(!G)return Y==="is"||Y==="is_not"?null:'Stripe current/trial date filters must use "productId:dateField:value".';let J=pM(G);if(iM(J))return Y==="is"||Y==="is_not"?null:"Stripe cancellation flag filters only support is and is_not operators.";if(!nM(Q,J))return`Unsupported Stripe product subfilter "${G}".`;if(!rM(Y))return"Stripe date filters only support is, is_not, gte, lte, gt, and lt operators.";return $?.trim()?null:'Stripe date filters must include a value like "productId:end_at:2026-05-26".'}var oM=new Set(["shopify","woocommerce","api"]);function tM(Q,Y){let X=Y.trim(),W=X.indexOf(":");if(W!==-1&&oM.has(X.substring(0,W).trim()))X=X.substring(W+1).trim();if(!X)return'Purchased Product filters must include a product ID, like "shopify:42".';if(Q!=="at_least"&&Q!=="less_than_count")return null;let G=X.lastIndexOf(":");if(G===-1)return null;let $=X.substring(0,G).trim(),J=Number.parseInt(X.substring(G+1).trim(),10);return $&&Number.isInteger(J)&&J>=1?null:'Purchased Product threshold filters must use "provider:productId:count" with a count of at least 1.'}function mY(Q){if(typeof Q!=="object"||Q===null)return"Segment filters must be objects.";let Y=Q,X=Y.field,W=Y.operator,G=Y.value;if(typeof X!=="string"||!(X in uY))return`Unsupported segment filter field "${String(X)}".`;if(typeof W!=="string")return`Segment filter "${X}" must include an operator.`;let $=uY[X];if(!$.includes(W))return`Operator "${W}" is not supported for ${X} filters. Use one of: ${$.join(", ")}.`;if(W!=="is_empty"&&W!=="is_not_empty"&&(typeof G!=="string"||G.trim().length===0))return`Segment filter "${X}" must include a value.`;if(X==="attribute"&&typeof G==="string"){if(!fM(G))return'Attribute filters must use "attributeName:value" or "attributeName:" for empty checks.';if(W!=="is_empty"&&W!=="is_not_empty"&&!lM(G))return'Attribute filters must include a value after "attributeName:".'}if(X==="event"&&typeof G==="string"){let J=mM(W,G);if(J)return J}if((X==="stripeProduct"||X==="stripeCurrentProduct"||X==="stripeTrialProduct")&&typeof G==="string"){let J=dM(X,W,G);if(J)return J}if(X==="commerceProduct"&&typeof G==="string"){let J=tM(W,G);if(J)return J}if(X==="tag"&&(W==="contains"||W==="not_contains")){if(!(typeof G==="string"&&G.split(",").map((z)=>z.trim()).some(Boolean)))return"Tag filters must include at least one tag name."}return null}function cY(Q){if(typeof Q!=="object"||Q===null)return[];let Y=Q;if(Y.kind==="filter"||"field"in Y||"operator"in Y||"value"in Y){let X=mY(Y);return X?[X]:[]}if(Array.isArray(Y.children))return Y.children.flatMap(cY);return[]}function P1(Q,Y,X){if(Y.html!==void 0&&Y.blocks!==void 0)throw Error(`Provide either \`html\` or \`blocks\` when calling \`${Q}\`, not both.`);if(Y.blocks!==void 0&&!Array.isArray(Y.blocks))throw Error(`\`blocks\` must be an array when calling \`${Q}\`.`);if(X?.requireContent&&Y.html===void 0&&Y.blocks===void 0)throw Error(`Provide either \`html\` or \`blocks\` when calling \`${Q}\`.`)}function LQ(Q,Y){if(Y.labels===void 0)return;if(!Array.isArray(Y.labels))throw Error(`\`labels\` must be an array when calling \`${Q}\`.`);if(Y.labels.some((X)=>typeof X!=="string"||X.trim().length===0))throw Error(`\`labels\` must contain only non-empty strings when calling \`${Q}\`.`)}function aM(Q){let Y=Q.filters!==void 0,X=Q.root!==void 0;if(Y&&X)throw Error("Provide either `filters` or `root` when calling `create_segment`, not both.");if(!Y&&!X)throw Error("Provide either `filters` or `root` when calling `create_segment`.");if(Y){if(!Array.isArray(Q.filters))throw Error("`filters` must be an array when calling `create_segment`.");if(Q.filters.length===0)throw Error("`filters` must include at least one filter when calling `create_segment`.")}if(X&&(typeof Q.root!=="object"||Q.root===null))throw Error("`root` must be an object when calling `create_segment`.");let W=Y?Q.filters.flatMap((G)=>{let $=mY(G);return $?[$]:[]}):cY(Q.root);if(W.length>0)throw Error(W[0]??"Invalid segment filter in `create_segment`.")}function sM(Q){let Y=Q.filters!==void 0,X=Q.root!==void 0;if(Y&&X)throw Error("Provide either `filters` or `root` when calling `update_segment`, not both.");if(Q.name===void 0&&Q.filterJoinOperator===void 0&&!Y&&!X)throw Error("Provide at least one of `name`, `filters`, `root`, or `filterJoinOperator` when calling `update_segment`.");if(Y){if(!Array.isArray(Q.filters))throw Error("`filters` must be an array when calling `update_segment`.");if(Q.filters.length===0)throw Error("`filters` must include at least one filter when calling `update_segment`.")}if(X&&(typeof Q.root!=="object"||Q.root===null))throw Error("`root` must be an object when calling `update_segment`.");let W=Y?Q.filters.flatMap((G)=>{let $=mY(G);return $?[$]:[]}):X?cY(Q.root):[];if(W.length>0)throw Error(W[0]??"Invalid segment filter in `update_segment`.")}function eM(Q){if(Q.clearEnrollmentFieldPath===!0&&Q.enrollmentFieldPath!==void 0)throw Error("Provide either `enrollmentFieldPath` or `clearEnrollmentFieldPath` when calling `update_sequence`, not both.");let Y={...Q};if(delete Y.clearEnrollmentFieldPath,Q.clearEnrollmentFieldPath===!0)Y.enrollmentFieldPath=null;return Y}function QV(Q){let Y=N(Q,"subscriberId"),X=Q.fieldValues,W=X===void 0?void 0:Array.isArray(X)?X:void 0;if(X!==void 0&&W===void 0)throw Error("`fieldValues` must be an array when calling `cancel_sequence_enrollments`.");let G=W?.map((z)=>typeof z==="string"?z.trim():"").filter((z)=>z.length>0)??[];if(W?.some((z)=>typeof z!=="string")||W!==void 0&&G.length===0)throw Error("`fieldValues` must contain at least one non-empty string when calling `cancel_sequence_enrollments`.");if(Y!==void 0===G.length>0)throw Error("Provide exactly one target when calling `cancel_sequence_enrollments`: `subscriberId` or `fieldValues`.");let $=N(Q,"fieldPath"),J=N(Q,"reason");return{...Y!==void 0&&{subscriberId:Y},...$!==void 0&&{fieldPath:$},...G.length>0&&{fieldValues:G},...typeof Q.dryRun==="boolean"&&{dryRun:Q.dryRun},...J!==void 0&&{reason:J}}}function YV(Q){P1("create_campaign",Q),LQ("create_campaign",Q);let Y=N(Q,"prompt")!==void 0,X=Q.html!==void 0,W=Q.blocks!==void 0,G=Q.templateId!==void 0;if(Q.prompt!==void 0&&!Y)throw Error("`prompt` cannot be empty when calling `create_campaign`.");if(Y&&(X||W||G))throw Error("Provide either `prompt`, `html`, `blocks`, or `templateId` when calling `create_campaign`, not multiple content sources.");if(!Y&&(Q.style!==void 0||Q.tone!==void 0))throw Error("`style` and `tone` can only be used with `prompt` when calling `create_campaign`.");if(!Y&&N(Q,"subject")===void 0)throw Error("`subject` is required unless `prompt` is provided when calling `create_campaign`.")}function XV(Q){if(N(Q,"scheduledAt")===void 0)throw Error("`scheduledAt` is required when calling `schedule_campaign`.");if(Q.targetLists!==void 0&&!B0(Q.targetLists))throw Error("`targetLists` must be an object when calling `schedule_campaign`.");if(Q.sendTimeOptimization!==void 0){if(typeof Q.sendTimeOptimization!=="boolean")throw Error("`sendTimeOptimization` must be a boolean when calling `schedule_campaign`.")}if(Q.spreadOverHours!==void 0){if(typeof Q.spreadOverHours!=="number"||!Number.isInteger(Q.spreadOverHours)||Q.spreadOverHours<1||Q.spreadOverHours>72)throw Error("`spreadOverHours` must be an integer between 1 and 72 when calling `schedule_campaign`.")}}function WV(Q){P1("create_transactional_email",Q);let Y=N(Q,"prompt")!==void 0,X=Q.html!==void 0,W=Q.blocks!==void 0;if(Q.prompt!==void 0&&!Y)throw Error("`prompt` cannot be empty when calling `create_transactional_email`.");if(Y&&(X||W))throw Error("Provide either `prompt`, `html`, or `blocks` when calling `create_transactional_email`, not multiple content sources.");if(!Y&&(Q.style!==void 0||Q.tone!==void 0))throw Error("`style` and `tone` can only be used with `prompt` when calling `create_transactional_email`.");if(!Y&&!X&&!W)throw Error("Provide either `prompt`, `html`, or `blocks` when calling `create_transactional_email`.");if(!Y&&N(Q,"subject")===void 0)throw Error("`subject` is required unless `prompt` is provided when calling `create_transactional_email`.")}var _5={type:"object",description:"A step to create inside a branch path. Use type:'delay' for a standalone delay, type:'email' for an email, or type:'create_discount' for a discount action.",properties:{type:{type:"string",enum:["email","delay","create_discount","discount","webhook"],description:"Branch path step type. Omit for email steps; use delay for standalone waits."},nodeType:{type:"string",enum:["logic_delay","action_email","action_create_discount","action_add_tag","action_remove_tag","action_add_to_list","action_remove_from_list","action_update_attributes","logic_wait_for_event","action_webhook"],description:"Advanced branch path node type. Prefer type unless creating a non-email action."},config:{type:"object",description:"Config for advanced nodeType steps such as tag/list/webhook/wait-for-event actions.",additionalProperties:!0},subject:{type:"string",description:"Email subject. Required for email steps."},previewText:{type:"string",description:"Email preview text."},blocks:{type:"array",description:u5,items:{type:"object"}},html:{type:"string",description:"HTML content for email steps."},delay:{type:"object",description:"Delay before this step, or the delay duration when type is delay.",properties:{days:{type:"number"},hours:{type:"number"},minutes:{type:"number"}}},delayMs:{type:"number",description:"Delay in milliseconds. Useful for standalone type:'delay' steps."},name:{type:"string",description:"Email template name for email steps."},discount:{type:"object",description:"Discount configuration for create_discount steps. Same shape as create_sequence steps.",additionalProperties:!0},label:{type:"string",description:"Node label for discount or advanced node steps."},provider:{type:"string",enum:["stripe","shopify"]},discountType:{type:"string",enum:["percent","amount"]},percentOff:{type:"number"},amountOff:{type:"number"},currency:{type:"string"},duration:{type:"string",enum:["once","forever","repeating"]},durationInMonths:{type:"number"},appliesToAllPlans:{type:"boolean"},planIds:{type:"array",items:{type:"string"}},codePrefix:{type:"string"},maxRedemptions:{type:"number"},lockToSubscriber:{type:"boolean"},expiresAt:{type:"string"},expiresInHours:{type:"number"}},additionalProperties:!1};function GV(Q){if(!Q||typeof Q!=="object")return null;let Y=Q;if(Y.success!==!1)return null;if(typeof Y.error==="string")return Error(Y.error);if(Y.error&&typeof Y.error==="object"&&typeof Y.error.message==="string")return Error(Y.error.message);if(typeof Y.message==="string")return Error(Y.message);return Error("The tool returned an unsuccessful response.")}function B0(Q){return typeof Q==="object"&&Q!==null&&!Array.isArray(Q)}function y5(Q){return Q.trim().toLowerCase().replace(/\s+/g,"-")}function $V(Q){let Y=new URLSearchParams;if(typeof Q.query==="string"&&Q.query.trim()!=="")Y.set("query",Q.query.trim());if(Array.isArray(Q.tags)&&Q.tags.length>0)Y.set("tags",Q.tags.filter((X)=>typeof X==="string"&&X.trim()!=="").join(","));if(typeof Q.list==="string"&&Q.list.trim()!=="")Y.set("list",Q.list.trim());if(typeof Q.listId==="string"&&Q.listId.trim()!=="")Y.set("listId",Q.listId.trim());if(typeof Q.listName==="string"&&Q.listName.trim()!=="")Y.set("listName",Q.listName.trim());if(typeof Q.segmentId==="string"&&Q.segmentId.trim()!=="")Y.set("segmentId",Q.segmentId);if(typeof Q.status==="string"&&Q.status.trim()!=="")Y.set("status",Q.status.trim());return Y.set("page",String(Q.page)),Y.set("limit",String(Q.pageSize)),Y}async function JV(Q,Y){let X=typeof Q.limit==="number"&&Number.isFinite(Q.limit)?Math.max(1,Math.trunc(Q.limit)):void 0,W=Math.min(100,Math.max(1,X??100)),G=[],$=1,J=0,z=0,H=0;while(!0){let A=$V({query:Q.query,tags:Q.tags,list:Q.list,listId:Q.listId,listName:Q.listName,segmentId:Q.segmentId,status:Q.status,page:$,pageSize:W}),B=await F("GET",`/api/v1/subscribers?${A.toString()}`,void 0,Y);J=B.pagination?.total??B.subscribers.length,z=B.pagination?.totalPages??1,H+=1,G.push(...B.subscribers??[]);let K=X!==void 0&&G.length>=X,L=B.pagination?$>=B.pagination.totalPages:(B.subscribers??[]).length<W;if(K||L)break;$+=1}let U=X!==void 0?G.slice(0,X):G;return{success:!0,subscribers:U,pagination:{page:1,limit:W,total:J,totalPages:z,fetchedPages:H},returned:U.length,truncated:X!==void 0&&J>0&&U.length<J}}function zV(Q){let Y=typeof Q.email==="string"&&Q.email.trim()!==""?Q.email.trim():void 0,X=typeof Q.externalId==="string"&&Q.externalId.trim()!==""?Q.externalId.trim():void 0;return{...Y?{email:Y}:{},...X?{externalId:X}:{}}}function c6(Q,Y){let X=zV(Y);if(!X.email&&!X.externalId)throw Error(`Provide either \`email\` or \`externalId\` when calling \`${Q}\`.`);return X}function lY(Q){if(Q.email)return`/api/v1/subscribers/${encodeURIComponent(Q.email)}`;return`/api/v1/subscribers/external?externalId=${encodeURIComponent(String(Q.externalId))}`}async function _Y(Q,Y){return F("GET",lY(Q),void 0,Y)}function N(Q,Y){let X=Q[Y];if(typeof X!=="string")return;let W=X.trim();return W.length>0?W:void 0}function x(Q,Y,X){let W=N(Y,X);if(W===void 0)throw Error(`\`${X}\` is required when calling \`${Q}\`.`);return W}function s0(Q,Y,X,W){let G=N(Y,X);if(G===void 0)return;if(!W.includes(G))throw Error(`\`${X}\` must be one of ${W.join(", ")} when calling \`${Q}\`.`);return G}function yY(Q,Y,X,W){let G=x(Q,Y,X);if(!W.includes(G))throw Error(`\`${X}\` must be one of ${W.join(", ")} when calling \`${Q}\`.`);return G}function p6(Q,Y,X,W,G){let $=Y[X];if($===void 0)return;if(typeof $!=="number"||!Number.isInteger($)||$<W||$>G)throw Error(`\`${X}\` must be an integer between ${W} and ${G} when calling \`${Q}\`.`);return $}function g5(Q,Y){if(Y.events===void 0)return;if(!Array.isArray(Y.events))throw Error(`\`events\` must be an array when calling \`${Q}\`.`);let X=Y.events.map((W,G)=>{if(typeof W!=="string"||!FQ.includes(W))throw Error(`\`events\` item ${G+1} must be one of ${FQ.join(", ")} when calling \`${Q}\`.`);return W});if(X.length===0)throw Error(`\`events\` must include at least one event type when calling \`${Q}\`.`);return X}function gY(Q,Y){if(!Array.isArray(Y.emails))throw Error(`\`emails\` must be an array when calling \`${Q}\`.`);let X=[];if(Y.emails.forEach((W,G)=>{if(typeof W!=="string")throw Error(`\`emails\` item ${G+1} must be a string when calling \`${Q}\`.`);let $=W.trim();if($.length>0)X.push($)}),X.length===0)throw Error(`\`emails\` must include at least one email address when calling \`${Q}\`.`);if(X.length>C5)throw Error(`\`emails\` must include no more than ${C5} email addresses when calling \`${Q}\`. Split larger batches into multiple calls.`);return X}var HV={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 UV(Q){let Y=Q.split(".").pop()?.toLowerCase()??"";return HV[Y]??null}var AV=104857600;async function BV(Q,Y){if(!eY())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 X=UV(Q);if(!X)throw Error("Unsupported file type. Use PDF, ePub, ZIP, image, audio, video, or text files.");let W=gM(Q).size;if(W>AV)throw Error(`File is too large (${Math.round(W/1048576)}MB). Delivery files must be 100MB or smaller.`);let G=yM(Q),$=await F("POST","/api/v1/products/delivery/upload-url",{filename:uM(Q),contentType:X,fileSizeBytes:W},Y),J=await fetch($.uploadUrl,{method:"PUT",headers:{"Content-Type":X},body:G});if(!J.ok)throw Error(`File upload failed (${J.status})`);return{url:$.publicUrl,fileName:$.fileName,fileSizeBytes:W,mimeType:X}}async function h5(Q){let Y=N(Q,"companyId");if(Y)return Y;let X=Q1();if(X)return X;try{return(await F("GET","/api/v1/account")).currentCompanyId??void 0}catch{return}}function i6(Q,Y){if(!B0(Q)||!Y)return Q;return{...Q,url:Y}}function f5(Q,Y){if(!B0(Q))return Q;return{...Q,...Y.campaign!==void 0&&{url:Y.campaign},...Y.campaignPreview!==void 0&&{previewUrl:Y.campaignPreview}}}function DQ(Q,Y,X){if(!Array.isArray(Q)||!Y)return Q;return Q.map((W)=>{if(!B0(W))return W;let G=N(W,"id");if(!G)return W;let $=q1({companyId:Y,...X==="campaign"&&{campaignId:G},...X==="sequence"&&{sequenceId:G},...X==="template"&&{emailId:G},...X==="transactional"&&{transactionalId:G}});if(X==="campaign")return f5(W,$.urls);let J=X==="sequence"?$.urls.sequence:X==="template"?$.urls.email:$.urls.transactionalEmail;return i6(W,J)})}function KV(Q){if(!Array.isArray(Q))return Q;return Q.map((Y)=>{if(!B0(Y))return Y;let X=N(Y,"id");if(!X)return Y;let W=q1({companyId:X});return{...Y,url:W.urls.dashboard,settingsUrl:W.urls.settings}})}var DV=new Set(["get_account","select_company","create_company","get_company","list_campaigns","get_campaign","get_email_send","create_campaign","update_campaign","schedule_campaign","send_test_email","cancel_campaign","pause_campaign","resume_campaign","duplicate_campaign","list_sequences","get_sequence","create_sequence","update_sequence","enable_sequence","disable_sequence","cancel_sequence_enrollments","list_ab_tests","get_ab_test","get_ab_test_stats","update_ab_test_variant","list_templates","get_template","create_template","update_template","list_transactional_emails","get_transactional_email","create_transactional_email","update_transactional_email"]);async function LV(Q,Y,X){if(!B0(X)||!DV.has(Q))return X;let W=B0(X.company)?X.company:void 0,$=N(X,"selectedCompanyId")??N(X,"currentCompanyId")??N(X,"companyId")??(W?N(W,"id"):void 0)??(W?N(W,"companyId"):void 0)??await h5(Y);if(!$)return X;let J=B0(X.campaign)?X.campaign:void 0,z=B0(X.sequence)?X.sequence:void 0,H=B0(X.template)?X.template:void 0,U=B0(X.transactional)&&!Array.isArray(X.transactional)?X.transactional:void 0,A={companyId:$,campaignId:N(Y,"campaignId")??N(X,"campaignId")??(J?N(J,"id"):void 0),sequenceId:N(Y,"sequenceId")??N(X,"sequenceId")??(z?N(z,"id"):void 0),emailId:N(X,"templateId")??(H?N(H,"id"):void 0)??(U?N(U,"emailId"):void 0)??N(Y,"templateId"),transactionalId:N(Y,"transactionalId")??(U?N(U,"id"):void 0)??N(Y,"idOrSlug"),emailSendId:N(Y,"emailSendId")??N(X,"emailSendId")??(B0(X.emailSend)?N(X.emailSend,"id"):void 0),status:N(Y,"status")},B=q1(A),K=W?q1({companyId:$}):void 0;return{...X,...Array.isArray(X.companies)&&{companies:KV(X.companies)},...Array.isArray(X.campaigns)&&{campaigns:DQ(X.campaigns,$,"campaign")},...Array.isArray(X.sequences)&&{sequences:DQ(X.sequences,$,"sequence")},...Array.isArray(X.templates)&&{templates:DQ(X.templates,$,"template")},...Array.isArray(X.transactional)&&{transactional:DQ(X.transactional,$,"transactional")},...W&&K!==void 0&&{company:{...W,url:K.urls.dashboard,settingsUrl:K.urls.settings}},...J&&B.urls.campaign!==void 0&&{campaign:f5(J,B.urls)},...z&&B.urls.sequence!==void 0&&{sequence:i6(z,B.urls.sequence)},...H&&B.urls.email!==void 0&&{template:i6(H,B.urls.email)},...U&&B.urls.transactionalEmail!==void 0&&{transactional:i6(U,B.urls.transactionalEmail)},...B0(X.emailSend)&&B.urls.emailSend!==void 0&&{emailSend:i6(X.emailSend,B.urls.emailSend)},appUrls:B.urls}}var l5=[{name:"get_account",description:`Get current account information including available companies. IMPORTANT: If you have access to multiple companies, you MUST either:
|
|
30
30
|
1. Call select_company first to choose which company to work with, OR
|
|
31
31
|
2. Pass companyId explicitly in each tool call
|
|
32
32
|
|
|
@@ -48,7 +48,7 @@ Use cases:
|
|
|
48
48
|
- 'event_tracking': Tracking CUSTOM events only (not payment events - those come from the integration)
|
|
49
49
|
- 'ecommerce': Connecting a custom e-commerce platform via the Commerce API (sync products, push orders/checkouts, power abandoned cart + back-in-stock automations)
|
|
50
50
|
|
|
51
|
-
Before implementing, use create_api_key to generate an API key and save it to .env as SEQUENZY_API_KEY.`,inputSchema:{type:"object",properties:{framework:{type:"string",description:"Framework/language (nextjs, express, python, etc.)"},use_case:{type:"string",description:"Use case: 'transactional' (sending emails), 'subscribe_form' (adding subscribers), 'event_tracking' (tracking CUSTOM events only - payment events should come from Stripe/Polar/etc integration), 'ecommerce' (connecting a custom e-commerce platform via the Commerce API)"}}}},{name:"add_subscriber",description:"Add a new subscriber to your list",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID to add subscriber to. If not provided, uses the currently selected company."},email:{type:"string",description:"Subscriber email address"},externalId:{type:"string",description:"Customer-owned subscriber ID. Provide this with email when creating, or instead of email for an existing subscriber."},attributes:{type:"object",description:"Custom attributes (name, plan, etc.)"},tags:{type:"array",items:{type:"string"},description:"Tags to apply to the subscriber"},listIds:{type:"array",items:{type:"string"},description:"List IDs to add subscriber to"},status:{type:"string",description:"Initial subscriber status: active, unsubscribed, or bounced. Defaults to active."},optInMode:{type:"string",description:"Consent mode: confirmed creates active immediately when consent is verified, double_opt_in sends a confirmation email before activation, and default obeys company double opt-in settings."}},required:[]}},{name:"update_subscriber",description:"Update an existing subscriber's attributes or tags",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},email:{type:"string",description:"Subscriber email address. Provide email or externalId to identify the subscriber."},externalId:{type:"string",description:"Customer-owned subscriber ID. Provide email or externalId to identify the subscriber."},attributes:{type:"object",description:"Attributes to update"},addTags:{type:"array",items:{type:"string"},description:"Tags to add"},removeTags:{type:"array",items:{type:"string"},description:"Tags to remove"}},required:[]}},{name:"remove_subscriber",description:"Unsubscribe or delete a subscriber",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},email:{type:"string",description:"Subscriber email address. Provide email or externalId to identify the subscriber."},externalId:{type:"string",description:"Customer-owned subscriber ID. Provide email or externalId to identify the subscriber."},hardDelete:{type:"boolean",description:"If true, permanently deletes. If false, just unsubscribes."}},required:[]}},{name:"get_subscriber",description:"Get the full subscriber profile, including tags, list memberships, sequence enrollments, email stats, and recent activity",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},email:{type:"string",description:"Subscriber email address. Provide email or externalId to identify the subscriber."},externalId:{type:"string",description:"Customer-owned subscriber ID. Provide email or externalId to identify the subscriber."}},required:[]}},{name:"search_subscribers",description:"Search subscribers by free-text query, tags, list, or segment. If you omit limit, the tool fetches all pages and returns every match.",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},query:{type:"string",description:"Search query (email or name)"},tags:{type:"array",items:{type:"string"},description:"Filter by tags"},list:{type:"string",description:"Filter by subscriber list ID or exact list name. Prefer listId when known."},listId:{type:"string",description:"Filter by subscriber list ID."},listName:{type:"string",description:"Filter by exact subscriber list name when the list ID is not known."},segmentId:{type:"string",description:"Filter by segment ID"},status:{type:"string",description:"Filter by subscriber status: active, unsubscribed, or bounced."},limit:{type:"number",description:"Maximum results to return. If omitted, the tool returns all matches across pages."}}}},{name:"list_products",description:"List synced products (Stripe, Shopify, WooCommerce) including any attached digital delivery file. Useful before attaching a file or building a purchase sequence for a specific product.",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID to list products for. If not provided, uses the currently selected company."},provider:{type:"string",description:"Filter by provider: stripe, shopify, woocommerce, or manual."},search:{type:"string",description:"Filter products by title."}}}},{name:"upsert_products",description:"Create or update products in the catalog (Commerce API, keyed by your productId, stored under the api provider). Use this to add products that are not synced from Stripe/Shopify/WooCommerce, then attach a deliverable file with attach_product_file and build a purchase sequence for them.",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},products:{type:"array",description:"Products to create or update (max 100).",items:{type:"object",properties:{productId:{type:"string",description:"Your stable product identifier (used for upserts and order line items)."},title:{type:"string",description:"Product title."},description:{type:"string",description:"Product description."},imageUrl:{type:"string",description:"Product image URL."},url:{type:"string",description:"Product page URL."},priceCents:{type:"number",description:"Price in the smallest currency unit."},currency:{type:"string",description:"ISO currency code, e.g. USD."},inStock:{type:"boolean",description:"Whether the product is in stock."}},required:["productId","title"]}}},required:["products"]}},{name:"delete_product",description:"Delete a product previously pushed via upsert_products (Commerce API products only), identified by your productId.",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},productId:{type:"string",description:"Your productId used when upserting the product."}},required:["productId"]}},{name:"attach_product_file",description:"Attach a distributable file to a product, either by public URL or by uploading a local file (filePath, local MCP server only). After a purchase of the product, sequence emails can link to it with {{event.download.url}} and {{event.download.name}}.",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},productId:{type:"string",description:"Product ID from list_products, or your own productId for products pushed via upsert_products."},url:{type:"string",description:"Public http(s) URL of the file to deliver. Provide url or filePath, not both."},filePath:{type:"string",description:"Local path of a file to upload and attach (PDF, ePub, ZIP, image, audio, video, or text, up to 100MB). Only available when the MCP server runs locally on this machine."},fileName:{type:"string",description:"Display name for the file (e.g. guide.pdf). Used as {{event.download.name}}."}},required:["productId"]}},{name:"remove_product_file",description:"Remove the attached distributable file from a product.",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},productId:{type:"string",description:"Product ID from list_products, or your own productId for products pushed via upsert_products."}},required:["productId"]}},{name:"sync_products",description:"Queue a sync of the Stripe product catalog into the products list. Requires an active Stripe integration.",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."}}}},{name:"list_tags",description:"List all tags in the account",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID to list tags for. If not provided, uses the currently selected company."}}}},{name:"create_tag",description:"Create a new tag definition. The name is normalized to lowercase with hyphens (e.g. 'VIP Customer' becomes 'vip-customer'). Color defaults to gray.",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},name:{type:"string",description:"Tag name. Normalized to lowercase with hyphens."},color:{type:"string",enum:[...qQ],description:"Tag color. Defaults to gray."}},required:["name"]}},{name:"update_tag",description:"Update a tag's color. System tags cannot be updated.",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},tagId:{type:"string",description:"Tag ID. Use list_tags to find tag IDs."},color:{type:"string",enum:[...qQ],description:"New tag color."}},required:["tagId","color"]}},{name:"delete_tag",description:"Permanently delete a tag and remove it from all subscribers. This cannot be undone. System tags and tags used by sequences cannot be deleted.",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},tagId:{type:"string",description:"Tag ID. Use list_tags to find tag IDs."}},required:["tagId"]}},{name:"list_lists",description:"List all subscriber lists",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID to list lists for. If not provided, uses the currently selected company."}}}},{name:"create_list",description:"Create a new subscriber list",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID to create the list in. If not provided, uses the currently selected company."},name:{type:"string",description:"List name"},description:{type:"string",description:"List description"}},required:["name"]}},{name:"update_list",description:"Update a subscriber list's name, description, or privacy. Only the provided fields are changed.",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},listId:{type:"string",description:"Subscriber list ID to update."},name:{type:"string",description:"New list name."},description:{type:["string","null"],description:"New list description. Pass null to clear it."},isPrivate:{type:"boolean",description:"Whether the list is private."}},required:["listId"]}},{name:"delete_list",description:"Permanently delete a subscriber list and remove all of its memberships. Subscribers themselves are kept. This cannot be undone.",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},listId:{type:"string",description:"Subscriber list ID to delete."}},required:["listId"]}},{name:"add_subscribers_to_list",description:"Bulk add existing or new subscribers to a subscriber list from an email array. Existing subscribers are added to the list without requiring a per-subscriber update call.",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},listId:{type:"string",description:"Subscriber list ID to add subscribers to."},emails:{type:"array",items:{type:"string"},description:"Email addresses to add to the list. Maximum 500 per call."},duplicateStrategy:{type:"string",description:"Duplicate strategy for existing subscribers: skip, merge, or overwrite. Defaults to skip."},enrollInSequences:{type:"boolean",description:"Whether newly created subscribers should enroll in matching sequences. Defaults to false."},optInMode:{type:"string",description:"Consent mode for newly created subscribers: default, confirmed, or double_opt_in. Defaults to default."}},required:["listId","emails"]}},{name:"remove_subscribers_from_list",description:"Remove subscribers from a list by email address. Maximum 500 emails per call. Subscribers stay in the account; only the list membership is removed. Returns the removed count plus a notFound array of emails that did not match a subscriber.",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},listId:{type:"string",description:"Subscriber list ID to remove subscribers from."},emails:{type:"array",items:{type:"string"},description:"Email addresses to remove from the list. Maximum 500 per call."}},required:["listId","emails"]}},{name:"list_segments",description:"List all segments",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID to list segments for. If not provided, uses the currently selected company."}}}},{name:"create_segment",description:'Create a new segment from explicit filter rules. Use `filters` plus `filterJoinOperator` for flat legacy rules, or `root` for nested AND/OR groups such as `{ "kind": "group", "joinOperator": "and", "children": [{ "kind": "filter", "field": "attribute", "operator": "gte", "value": "mrr:50" }, { "kind": "group", "joinOperator": "or", "children": [{ "kind": "filter", "field": "tag", "operator": "contains", "value": "vip" }, { "kind": "filter", "field": "event", "operator": "is_not", "value": "saas.purchase:30d" }] }] }`. Supports `event` and `segment` fields, Stripe product purchase/current/trial/date filters, and campaign-specific engagement filters.',inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID to create the segment in. If not provided, uses the currently selected company."},name:{type:"string",description:"Segment name"},filterJoinOperator:{type:"string",enum:["and","or"],description:'How top-level filters combine. Use `"and"` to require every filter or `"or"` to match any filter.'},filters:{type:"array",items:k5,minItems:1,description:'Array of segment filters. Example custom attribute empty check: [{"id":"filter-1","field":"attribute","operator":"is_empty","value":"last_logged_in:"}]. Example Stripe purchase filter: [{"id":"filter-1","field":"stripeProduct","operator":"is","value":"prod_123"}]. Example threshold filter: [{"id":"filter-1","field":"stripeProduct","operator":"at_least","value":"prod_123:3"}]. Example trial cancellation filter: [{"id":"filter-1","field":"stripeTrialProduct","operator":"is","value":"prod_123:is_canceled"}]. Example trial end filter: [{"id":"filter-1","field":"stripeTrialProduct","operator":"is","value":"prod_123:end_at:2026-05-26"}]. Example campaign-specific engagement combo: [{"id":"filter-1","field":"emailBounced","operator":"is","value":"campaign:cmp_abc"},{"id":"filter-2","field":"emailBounced","operator":"is_not","value":"campaign:cmp_xyz"}]. Combine them with `filterJoinOperator: "or"` to match any filter.'},root:{...v5,description:"Nested filter root. Mutually exclusive with `filters` and `filterJoinOperator`."}},required:["name"]}},{name:"update_segment",description:"Update a segment's name and/or filter rules. Use the same `filters` plus `filterJoinOperator` or nested `root` shapes as create_segment; providing `filters` or `root` replaces the segment's existing rules.",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},segmentId:{type:"string",description:"Segment ID to update."},name:{type:"string",description:"New segment name."},filterJoinOperator:{type:"string",enum:["and","or"],description:'How top-level filters combine. Use `"and"` to require every filter or `"or"` to match any filter.'},filters:{type:"array",items:k5,minItems:1,description:"Replacement segment filters. Same shape and validation rules as create_segment. Mutually exclusive with `root`."},root:{...v5,description:"Replacement nested filter root. Mutually exclusive with `filters` and `filterJoinOperator`."}},required:["segmentId"]}},{name:"delete_segment",description:"Permanently delete a segment. This cannot be undone. Subscribers are not affected.",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},segmentId:{type:"string",description:"Segment ID to delete."}},required:["segmentId"]}},{name:"get_segment_count",description:"Get the number of subscribers in a segment",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},segmentId:{type:"string",description:"Segment ID"}},required:["segmentId"]}},{name:"list_templates",description:"List all email templates, including per-locale localization sync status",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."}}}},{name:"get_template",description:"Get a template's details, content, and all localized variants with sync status",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},templateId:{type:"string",description:"Template ID"}},required:["templateId"]}},{name:"create_template",description:"Create a new email template",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},name:{type:"string",description:"Template name"},subject:{type:"string",description:"Email subject line"},html:{type:"string",description:"Email HTML content. Mutually exclusive with `blocks`."},blocks:{type:"array",description:m4,items:{type:"object"}},labels:{type:"array",description:"Optional label names to assign. Missing labels are created automatically.",items:{type:"string"}}},required:["name","subject"]}},{name:"update_template",description:"Update an existing template. At least one of `name`, `subject`, `html`, `blocks`, or `labels` is required, and only those update fields are accepted.",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},templateId:{type:"string",description:"Template ID"},name:{type:"string",description:"Template name"},subject:{type:"string",description:"Email subject line"},html:{type:"string",description:"Email HTML content. Mutually exclusive with `blocks`."},blocks:{type:"array",description:m4,items:{type:"object"}},labels:{type:"array",description:"Replacement label names. Send an empty array to clear labels. Missing labels are created automatically.",items:{type:"string"}}},required:["templateId"],additionalProperties:!1}},{name:"delete_template",description:"Delete a template",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},templateId:{type:"string",description:"Template ID"}},required:["templateId"]}},{name:"list_ab_tests",description:"List A/B tests and their variants",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},sequenceId:{type:"string",description:"Optional sequence ID to filter automation A/B tests."}}}},{name:"get_ab_test",description:"Get A/B test details, variants, and per-locale localization sync status",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},abTestId:{type:"string",description:"A/B test ID"}},required:["abTestId"]}},{name:"get_ab_test_stats",description:"Get A/B test aggregate stats and per-variant stats. Supports period or custom start/end ranges.",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},abTestId:{type:"string",description:"A/B test ID"},period:{type:"string",description:"Optional period: 1h, 24h, 7d, 30d, or 90d."},start:{type:"string",description:"Custom range start as ISO 8601. Requires end."},end:{type:"string",description:"Custom range end as ISO 8601. Requires start."}},required:["abTestId"]}},{name:"restart_ab_test",description:"Run another sequence A/B test after a winner is selected. By default the winner becomes the new control; pass sourceVariantId to use another variant as the control email.",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},abTestId:{type:"string",description:"A/B test ID to restart"},sourceVariantId:{type:"string",description:"Optional variant ID to use as the new control email. Defaults to the selected winner."},testType:{type:"string",description:"Optional test type: subject or content."},winnerThreshold:{type:"number",description:"Optional number of subscribers before selecting a winner. Must be from 10 to 1000."},variantCount:{type:"number",description:"Optional total variants including the control. Must be from 2 to 4."}},required:["abTestId"],additionalProperties:!1}},{name:"update_ab_test_variant",description:"Update a draft A/B test variant. Provide at least one of subject, previewText, html, or blocks. Use either html or blocks, not both.",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},abTestId:{type:"string",description:"A/B test ID"},variantId:{type:"string",description:"A/B test variant ID"},subject:{type:"string",description:"Variant subject line"},previewText:{type:"string",description:"Variant preview text. Pass an empty string to clear it."},html:{type:"string",description:"Replacement HTML body. Mutually exclusive with blocks."},blocks:{type:"array",description:`${i1} 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:i1,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:i1,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"]}},{name:"list_campaigns",description:"List all campaigns",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID to list campaigns for. If not provided, uses the currently selected company."},status:{type:"string",description:"Filter by status (draft, scheduled, sent)"},label:{type:"string",description:"Optional label name filter. Only campaigns assigned this label are returned."}}}},{name:"get_campaign",description:"Get campaign details and stats",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},campaignId:{type:"string",description:"Campaign ID"}},required:["campaignId"]}},{name:"get_email_send",description:"Get a sent email by emailSendId, including the stored HTML body when available and the ClickHouse event timeline. If the short-lived email send row has been cleaned up, returns the retained ClickHouse events and a sparse summary.",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},emailSendId:{type:"string",description:"Email send ID to inspect."}},required:["emailSendId"]}},{name:"create_campaign",description:"Create a new campaign (as draft)",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID to create the campaign in. If not provided, uses the currently selected company."},name:{type:"string",description:"Campaign name"},subject:{type:"string",description:"Email subject line. Optional when `prompt` is provided because the generated subject will be used."},trackingCode:{type:"string",description:"Optional campaign tracking code for UTM templates. Use only when explicitly requested."},html:{type:"string",description:"Email HTML content. Mutually exclusive with `blocks`."},blocks:{type:"array",description:m4,items:{type:"object"}},prompt:{type:"string",description:"Generate campaign blocks from a prompt. Mutually exclusive with `html`, `blocks`, and `templateId`."},style:{type:"string",description:"Prompt generation style: minimal, branded, promotional. Only used with `prompt`."},tone:{type:"string",description:"Prompt generation tone: professional, casual, friendly. Only used with `prompt`."},templateId:{type:"string",description:"Use a template instead of html"},segmentId:{type:"string",description:"Target segment ID"},campaignData:{type:"object",description:"Optional campaign-scoped JSON data for repeat blocks and personalization."},computedLists:{type:"array",description:"Optional computed list definitions derived from campaignData at send time.",items:{type:"object"}},labels:{type:"array",description:"Optional label names to assign. Missing labels are created automatically.",items:{type:"string"}}},required:["name"]}},{name:"update_campaign",description:"Update a draft campaign",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},campaignId:{type:"string",description:"Campaign ID"},name:{type:"string",description:"Campaign name"},subject:{type:"string",description:"Email subject line"},trackingCode:{type:"string",description:"Optional campaign tracking code for UTM templates. Use only when explicitly requested. Send an empty string to clear it."},html:{type:"string",description:"Email HTML content. Mutually exclusive with `blocks`."},blocks:{type:"array",description:m4,items:{type:"object"}},replyTo:{type:"string",description:"Set reply-to using an existing reply profile email address for this company."},replyProfileId:{type:"string",description:"Set reply-to using a reply profile ID for this company."},campaignData:{type:"object",description:"Set campaign-scoped JSON data for repeat blocks and personalization."},computedLists:{type:"array",description:"Set computed list definitions derived from campaignData at send time.",items:{type:"object"}},labels:{type:"array",description:"Replacement label names. Send an empty array to clear labels. Missing labels are created automatically.",items:{type:"string"}}},required:["campaignId"],additionalProperties:!1}},{name:"schedule_campaign",description:"Schedule a draft or already scheduled campaign. Returns dashboard edit and preview URLs.",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},campaignId:{type:"string",description:"Campaign ID"},scheduledAt:{type:"string",description:"Future ISO 8601 timestamp for the send, for example 2026-06-01T14:00:00Z."},targetLists:{type:"object",description:"Optional campaign targeting object. Omit to use saved targeting or all active subscribers. Examples: {type:'all'}, {type:'lists', listIds:['list_123']}, {type:'segment', segmentId:'seg_123'}, or {type:'filtered', filters:[...], filterJoinOperator:'and'}.",additionalProperties:!0},sendTimeOptimization:{type:"boolean",description:"Whether to use send-time optimization."},spreadOverHours:{type:"number",description:"Spread delivery over an integer number of hours from 1 to 72. When set, spread delivery takes precedence over send-time optimization."}},required:["campaignId","scheduledAt"],additionalProperties:!1}},{name:"send_test_email",description:"Send a test email to a single address",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},campaignId:{type:"string",description:"Campaign ID to test"},to:{type:"string",description:"Email address to send test to"}},required:["campaignId","to"]}},{name:"cancel_campaign",description:"Cancel a campaign. Stops scheduled and sending campaigns (also works for paused and approval-pending ones). Remaining emails will not be sent and the campaign cannot be restarted - this cannot be undone.",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},campaignId:{type:"string",description:"Campaign ID to cancel."}},required:["campaignId"]}},{name:"pause_campaign",description:"Pause a campaign that is currently sending. Only campaigns in sending status can be paused. Use resume_campaign to continue delivery later.",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},campaignId:{type:"string",description:"Campaign ID to pause."}},required:["campaignId"]}},{name:"resume_campaign",description:"Resume a paused campaign. Only campaigns in paused status can be resumed. Optionally spread the remaining delivery over a number of hours.",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},campaignId:{type:"string",description:"Campaign ID to resume."},spreadOverHours:{type:"number",description:"Spread the remaining delivery over an integer number of hours from 1 to 72."}},required:["campaignId"]}},{name:"delete_campaign",description:"Permanently delete a campaign. This cannot be undone. Sending, scheduled, or paused campaigns must be cancelled with cancel_campaign first.",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},campaignId:{type:"string",description:"Campaign ID to delete."}},required:["campaignId"]}},{name:"duplicate_campaign",description:"Duplicate a campaign as a new draft. mode 'campaign' (default) copies the campaign and its email, 'ab_test' also duplicates the campaign's A/B test with all variants, and 'variant' copies a single variant's content as the new campaign email (requires variantId).",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},campaignId:{type:"string",description:"Campaign ID to duplicate."},mode:{type:"string",enum:["campaign","ab_test","variant"],description:"Duplication mode. Defaults to campaign."},variantId:{type:"string",description:"A/B test variant ID whose content becomes the new campaign email. Required when mode is variant."}},required:["campaignId"]}},{name:"list_sequences",description:"List all email sequences (automations)",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID to list sequences for. If not provided, uses the currently selected company."}}}},{name:"get_sequence",description:"Get sequence details plus editable step content. The response includes sequence.emails with each step's nodeId, linked emailId, subject, previewText, and blocks.",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},sequenceId:{type:"string",description:"Sequence ID"}},required:["sequenceId"],additionalProperties:!1}},{name:"create_sequence",description:`Create a new email sequence. Provide either a goal for AI generation or explicit steps. Explicit steps can include email content and create_discount actions; emails after a discount action can use merge tags such as {{discount.code}} and {{discount.percentOff}}. For AI-generated sequences, the tool polls until emails are generated (typically 30-60 seconds).
|
|
51
|
+
Before implementing, use create_api_key to generate an API key and save it to .env as SEQUENZY_API_KEY.`,inputSchema:{type:"object",properties:{framework:{type:"string",description:"Framework/language (nextjs, express, python, etc.)"},use_case:{type:"string",description:"Use case: 'transactional' (sending emails), 'subscribe_form' (adding subscribers), 'event_tracking' (tracking CUSTOM events only - payment events should come from Stripe/Polar/etc integration), 'ecommerce' (connecting a custom e-commerce platform via the Commerce API)"}}}},{name:"add_subscriber",description:"Add a new subscriber to your list",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID to add subscriber to. If not provided, uses the currently selected company."},email:{type:"string",description:"Subscriber email address"},externalId:{type:"string",description:"Customer-owned subscriber ID. Provide this with email when creating, or instead of email for an existing subscriber."},attributes:{type:"object",description:"Custom attributes (name, plan, etc.)"},tags:{type:"array",items:{type:"string"},description:"Tags to apply to the subscriber"},listIds:{type:"array",items:{type:"string"},description:"List IDs to add subscriber to"},status:{type:"string",description:"Initial subscriber status: active, unsubscribed, or bounced. Defaults to active."},optInMode:{type:"string",description:"Consent mode: confirmed creates active immediately when consent is verified, double_opt_in sends a confirmation email before activation, and default obeys company double opt-in settings."}},required:[]}},{name:"update_subscriber",description:"Update an existing subscriber's attributes or tags",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},email:{type:"string",description:"Subscriber email address. Provide email or externalId to identify the subscriber."},externalId:{type:"string",description:"Customer-owned subscriber ID. Provide email or externalId to identify the subscriber."},attributes:{type:"object",description:"Attributes to update"},addTags:{type:"array",items:{type:"string"},description:"Tags to add"},removeTags:{type:"array",items:{type:"string"},description:"Tags to remove"}},required:[]}},{name:"remove_subscriber",description:"Unsubscribe or delete a subscriber",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},email:{type:"string",description:"Subscriber email address. Provide email or externalId to identify the subscriber."},externalId:{type:"string",description:"Customer-owned subscriber ID. Provide email or externalId to identify the subscriber."},hardDelete:{type:"boolean",description:"If true, permanently deletes. If false, just unsubscribes."}},required:[]}},{name:"get_subscriber",description:"Get the full subscriber profile, including tags, list memberships, sequence enrollments, email stats, and recent activity",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},email:{type:"string",description:"Subscriber email address. Provide email or externalId to identify the subscriber."},externalId:{type:"string",description:"Customer-owned subscriber ID. Provide email or externalId to identify the subscriber."}},required:[]}},{name:"search_subscribers",description:"Search subscribers by free-text query, tags, list, or segment. If you omit limit, the tool fetches all pages and returns every match.",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},query:{type:"string",description:"Search query (email or name)"},tags:{type:"array",items:{type:"string"},description:"Filter by tags"},list:{type:"string",description:"Filter by subscriber list ID or exact list name. Prefer listId when known."},listId:{type:"string",description:"Filter by subscriber list ID."},listName:{type:"string",description:"Filter by exact subscriber list name when the list ID is not known."},segmentId:{type:"string",description:"Filter by segment ID"},status:{type:"string",description:"Filter by subscriber status: active, unsubscribed, or bounced."},limit:{type:"number",description:"Maximum results to return. If omitted, the tool returns all matches across pages."}}}},{name:"list_products",description:"List synced products (Stripe, Shopify, WooCommerce) including any attached digital delivery file. Useful before attaching a file or building a purchase sequence for a specific product.",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID to list products for. If not provided, uses the currently selected company."},provider:{type:"string",description:"Filter by provider: stripe, shopify, woocommerce, or manual."},search:{type:"string",description:"Filter products by title."}}}},{name:"upsert_products",description:"Create or update products in the catalog (Commerce API, keyed by your productId, stored under the api provider). Use this to add products that are not synced from Stripe/Shopify/WooCommerce, then attach a deliverable file with attach_product_file and build a purchase sequence for them.",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},products:{type:"array",description:"Products to create or update (max 100).",items:{type:"object",properties:{productId:{type:"string",description:"Your stable product identifier (used for upserts and order line items)."},title:{type:"string",description:"Product title."},description:{type:"string",description:"Product description."},imageUrl:{type:"string",description:"Product image URL."},url:{type:"string",description:"Product page URL."},priceCents:{type:"number",description:"Price in the smallest currency unit."},currency:{type:"string",description:"ISO currency code, e.g. USD."},inStock:{type:"boolean",description:"Whether the product is in stock."}},required:["productId","title"]}}},required:["products"]}},{name:"delete_product",description:"Delete a product previously pushed via upsert_products (Commerce API products only), identified by your productId.",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},productId:{type:"string",description:"Your productId used when upserting the product."}},required:["productId"]}},{name:"attach_product_file",description:"Attach a distributable file to a product, either by public URL or by uploading a local file (filePath, local MCP server only). After a purchase of the product, sequence emails can link to it with {{event.download.url}} and {{event.download.name}}.",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},productId:{type:"string",description:"Product ID from list_products, or your own productId for products pushed via upsert_products."},url:{type:"string",description:"Public http(s) URL of the file to deliver. Provide url or filePath, not both."},filePath:{type:"string",description:"Local path of a file to upload and attach (PDF, ePub, ZIP, image, audio, video, or text, up to 100MB). Only available when the MCP server runs locally on this machine."},fileName:{type:"string",description:"Display name for the file (e.g. guide.pdf). Used as {{event.download.name}}."}},required:["productId"]}},{name:"remove_product_file",description:"Remove the attached distributable file from a product.",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},productId:{type:"string",description:"Product ID from list_products, or your own productId for products pushed via upsert_products."}},required:["productId"]}},{name:"sync_products",description:"Queue a sync of the Stripe product catalog into the products list. Requires an active Stripe integration.",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."}}}},{name:"list_tags",description:"List all tags in the account",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID to list tags for. If not provided, uses the currently selected company."}}}},{name:"create_tag",description:"Create a new tag definition. The name is normalized to lowercase with hyphens (e.g. 'VIP Customer' becomes 'vip-customer'). Color defaults to gray.",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},name:{type:"string",description:"Tag name. Normalized to lowercase with hyphens."},color:{type:"string",enum:[...qQ],description:"Tag color. Defaults to gray."}},required:["name"]}},{name:"update_tag",description:"Update a tag's color. System tags cannot be updated.",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},tagId:{type:"string",description:"Tag ID. Use list_tags to find tag IDs."},color:{type:"string",enum:[...qQ],description:"New tag color."}},required:["tagId","color"]}},{name:"delete_tag",description:"Permanently delete a tag and remove it from all subscribers. This cannot be undone. System tags and tags used by sequences cannot be deleted.",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},tagId:{type:"string",description:"Tag ID. Use list_tags to find tag IDs."}},required:["tagId"]}},{name:"list_lists",description:"List all subscriber lists",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID to list lists for. If not provided, uses the currently selected company."}}}},{name:"create_list",description:"Create a new subscriber list",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID to create the list in. If not provided, uses the currently selected company."},name:{type:"string",description:"List name"},description:{type:"string",description:"List description"}},required:["name"]}},{name:"update_list",description:"Update a subscriber list's name, description, or privacy. Only the provided fields are changed.",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},listId:{type:"string",description:"Subscriber list ID to update."},name:{type:"string",description:"New list name."},description:{type:["string","null"],description:"New list description. Pass null to clear it."},isPrivate:{type:"boolean",description:"Whether the list is private."}},required:["listId"]}},{name:"delete_list",description:"Permanently delete a subscriber list and remove all of its memberships. Subscribers themselves are kept. This cannot be undone.",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},listId:{type:"string",description:"Subscriber list ID to delete."}},required:["listId"]}},{name:"add_subscribers_to_list",description:"Bulk add existing or new subscribers to a subscriber list from an email array. Existing subscribers are added to the list without requiring a per-subscriber update call.",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},listId:{type:"string",description:"Subscriber list ID to add subscribers to."},emails:{type:"array",items:{type:"string"},description:"Email addresses to add to the list. Maximum 500 per call."},duplicateStrategy:{type:"string",description:"Duplicate strategy for existing subscribers: skip, merge, or overwrite. Defaults to skip."},enrollInSequences:{type:"boolean",description:"Whether newly created subscribers should enroll in matching sequences. Defaults to false."},optInMode:{type:"string",description:"Consent mode for newly created subscribers: default, confirmed, or double_opt_in. Defaults to default."}},required:["listId","emails"]}},{name:"remove_subscribers_from_list",description:"Remove subscribers from a list by email address. Maximum 500 emails per call. Subscribers stay in the account; only the list membership is removed. Returns the removed count plus a notFound array of emails that did not match a subscriber.",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},listId:{type:"string",description:"Subscriber list ID to remove subscribers from."},emails:{type:"array",items:{type:"string"},description:"Email addresses to remove from the list. Maximum 500 per call."}},required:["listId","emails"]}},{name:"list_segments",description:"List all segments",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID to list segments for. If not provided, uses the currently selected company."}}}},{name:"create_segment",description:'Create a new segment from explicit filter rules. Use `filters` plus `filterJoinOperator` for flat legacy rules, or `root` for nested AND/OR groups such as `{ "kind": "group", "joinOperator": "and", "children": [{ "kind": "filter", "field": "attribute", "operator": "gte", "value": "mrr:50" }, { "kind": "group", "joinOperator": "or", "children": [{ "kind": "filter", "field": "tag", "operator": "contains", "value": "vip" }, { "kind": "filter", "field": "event", "operator": "is_not", "value": "saas.purchase:30d" }] }] }`. Supports `event` and `segment` fields, Stripe product purchase/current/trial/date filters, and campaign-specific engagement filters.',inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID to create the segment in. If not provided, uses the currently selected company."},name:{type:"string",description:"Segment name"},filterJoinOperator:{type:"string",enum:["and","or"],description:'How top-level filters combine. Use `"and"` to require every filter or `"or"` to match any filter.'},filters:{type:"array",items:k5,minItems:1,description:'Array of segment filters. Example custom attribute empty check: [{"id":"filter-1","field":"attribute","operator":"is_empty","value":"last_logged_in:"}]. Example Stripe purchase filter: [{"id":"filter-1","field":"stripeProduct","operator":"is","value":"prod_123"}]. Example threshold filter: [{"id":"filter-1","field":"stripeProduct","operator":"at_least","value":"prod_123:3"}]. Example commerce product purchase filter (value is provider:productId since product ids are provider-scoped): [{"id":"filter-1","field":"commerceProduct","operator":"is","value":"api:prod-starter-kit"}]. Example repeat-buyer filter: [{"id":"filter-1","field":"commerceProduct","operator":"at_least","value":"shopify:42:2"}]. Example trial cancellation filter: [{"id":"filter-1","field":"stripeTrialProduct","operator":"is","value":"prod_123:is_canceled"}]. Example trial end filter: [{"id":"filter-1","field":"stripeTrialProduct","operator":"is","value":"prod_123:end_at:2026-05-26"}]. Example campaign-specific engagement combo: [{"id":"filter-1","field":"emailBounced","operator":"is","value":"campaign:cmp_abc"},{"id":"filter-2","field":"emailBounced","operator":"is_not","value":"campaign:cmp_xyz"}]. Combine them with `filterJoinOperator: "or"` to match any filter.'},root:{...v5,description:"Nested filter root. Mutually exclusive with `filters` and `filterJoinOperator`."}},required:["name"]}},{name:"update_segment",description:"Update a segment's name and/or filter rules. Use the same `filters` plus `filterJoinOperator` or nested `root` shapes as create_segment; providing `filters` or `root` replaces the segment's existing rules.",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},segmentId:{type:"string",description:"Segment ID to update."},name:{type:"string",description:"New segment name."},filterJoinOperator:{type:"string",enum:["and","or"],description:'How top-level filters combine. Use `"and"` to require every filter or `"or"` to match any filter.'},filters:{type:"array",items:k5,minItems:1,description:"Replacement segment filters. Same shape and validation rules as create_segment. Mutually exclusive with `root`."},root:{...v5,description:"Replacement nested filter root. Mutually exclusive with `filters` and `filterJoinOperator`."}},required:["segmentId"]}},{name:"delete_segment",description:"Permanently delete a segment. This cannot be undone. Subscribers are not affected.",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},segmentId:{type:"string",description:"Segment ID to delete."}},required:["segmentId"]}},{name:"get_segment_count",description:"Get the number of subscribers in a segment",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},segmentId:{type:"string",description:"Segment ID"}},required:["segmentId"]}},{name:"list_templates",description:"List all email templates, including per-locale localization sync status",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."}}}},{name:"get_template",description:"Get a template's details, content, and all localized variants with sync status",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},templateId:{type:"string",description:"Template ID"}},required:["templateId"]}},{name:"create_template",description:"Create a new email template",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},name:{type:"string",description:"Template name"},subject:{type:"string",description:"Email subject line"},html:{type:"string",description:"Email HTML content. Mutually exclusive with `blocks`."},blocks:{type:"array",description:m6,items:{type:"object"}},labels:{type:"array",description:"Optional label names to assign. Missing labels are created automatically.",items:{type:"string"}}},required:["name","subject"]}},{name:"update_template",description:"Update an existing template. At least one of `name`, `subject`, `html`, `blocks`, or `labels` is required, and only those update fields are accepted.",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},templateId:{type:"string",description:"Template ID"},name:{type:"string",description:"Template name"},subject:{type:"string",description:"Email subject line"},html:{type:"string",description:"Email HTML content. Mutually exclusive with `blocks`."},blocks:{type:"array",description:m6,items:{type:"object"}},labels:{type:"array",description:"Replacement label names. Send an empty array to clear labels. Missing labels are created automatically.",items:{type:"string"}}},required:["templateId"],additionalProperties:!1}},{name:"delete_template",description:"Delete a template",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},templateId:{type:"string",description:"Template ID"}},required:["templateId"]}},{name:"list_ab_tests",description:"List A/B tests and their variants",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},sequenceId:{type:"string",description:"Optional sequence ID to filter automation A/B tests."}}}},{name:"get_ab_test",description:"Get A/B test details, variants, and per-locale localization sync status",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},abTestId:{type:"string",description:"A/B test ID"}},required:["abTestId"]}},{name:"get_ab_test_stats",description:"Get A/B test aggregate stats and per-variant stats. Supports period or custom start/end ranges.",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},abTestId:{type:"string",description:"A/B test ID"},period:{type:"string",description:"Optional period: 1h, 24h, 7d, 30d, or 90d."},start:{type:"string",description:"Custom range start as ISO 8601. Requires end."},end:{type:"string",description:"Custom range end as ISO 8601. Requires start."}},required:["abTestId"]}},{name:"restart_ab_test",description:"Run another sequence A/B test after a winner is selected. By default the winner becomes the new control; pass sourceVariantId to use another variant as the control email.",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},abTestId:{type:"string",description:"A/B test ID to restart"},sourceVariantId:{type:"string",description:"Optional variant ID to use as the new control email. Defaults to the selected winner."},testType:{type:"string",description:"Optional test type: subject or content."},winnerThreshold:{type:"number",description:"Optional number of subscribers before selecting a winner. Must be from 10 to 1000."},variantCount:{type:"number",description:"Optional total variants including the control. Must be from 2 to 4."}},required:["abTestId"],additionalProperties:!1}},{name:"update_ab_test_variant",description:"Update a draft A/B test variant. Provide at least one of subject, previewText, html, or blocks. Use either html or blocks, not both.",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},abTestId:{type:"string",description:"A/B test ID"},variantId:{type:"string",description:"A/B test variant ID"},subject:{type:"string",description:"Variant subject line"},previewText:{type:"string",description:"Variant preview text. Pass an empty string to clear it."},html:{type:"string",description:"Replacement HTML body. Mutually exclusive with blocks."},blocks:{type:"array",description:`${i1} 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:i1,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:i1,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"]}},{name:"list_campaigns",description:"List all campaigns",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID to list campaigns for. If not provided, uses the currently selected company."},status:{type:"string",description:"Filter by status (draft, scheduled, sent)"},label:{type:"string",description:"Optional label name filter. Only campaigns assigned this label are returned."}}}},{name:"get_campaign",description:"Get campaign details and stats",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},campaignId:{type:"string",description:"Campaign ID"}},required:["campaignId"]}},{name:"get_email_send",description:"Get a sent email by emailSendId, including the stored HTML body when available and the ClickHouse event timeline. If the short-lived email send row has been cleaned up, returns the retained ClickHouse events and a sparse summary.",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},emailSendId:{type:"string",description:"Email send ID to inspect."}},required:["emailSendId"]}},{name:"create_campaign",description:"Create a new campaign (as draft)",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID to create the campaign in. If not provided, uses the currently selected company."},name:{type:"string",description:"Campaign name"},subject:{type:"string",description:"Email subject line. Optional when `prompt` is provided because the generated subject will be used."},trackingCode:{type:"string",description:"Optional campaign tracking code for UTM templates. Use only when explicitly requested."},html:{type:"string",description:"Email HTML content. Mutually exclusive with `blocks`."},blocks:{type:"array",description:m6,items:{type:"object"}},prompt:{type:"string",description:"Generate campaign blocks from a prompt. Mutually exclusive with `html`, `blocks`, and `templateId`."},style:{type:"string",description:"Prompt generation style: minimal, branded, promotional. Only used with `prompt`."},tone:{type:"string",description:"Prompt generation tone: professional, casual, friendly. Only used with `prompt`."},templateId:{type:"string",description:"Use a template instead of html"},segmentId:{type:"string",description:"Target segment ID"},campaignData:{type:"object",description:"Optional campaign-scoped JSON data for repeat blocks and personalization."},computedLists:{type:"array",description:"Optional computed list definitions derived from campaignData at send time.",items:{type:"object"}},labels:{type:"array",description:"Optional label names to assign. Missing labels are created automatically.",items:{type:"string"}}},required:["name"]}},{name:"update_campaign",description:"Update a draft campaign",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},campaignId:{type:"string",description:"Campaign ID"},name:{type:"string",description:"Campaign name"},subject:{type:"string",description:"Email subject line"},trackingCode:{type:"string",description:"Optional campaign tracking code for UTM templates. Use only when explicitly requested. Send an empty string to clear it."},html:{type:"string",description:"Email HTML content. Mutually exclusive with `blocks`."},blocks:{type:"array",description:m6,items:{type:"object"}},replyTo:{type:"string",description:"Set reply-to using an existing reply profile email address for this company."},replyProfileId:{type:"string",description:"Set reply-to using a reply profile ID for this company."},campaignData:{type:"object",description:"Set campaign-scoped JSON data for repeat blocks and personalization."},computedLists:{type:"array",description:"Set computed list definitions derived from campaignData at send time.",items:{type:"object"}},labels:{type:"array",description:"Replacement label names. Send an empty array to clear labels. Missing labels are created automatically.",items:{type:"string"}}},required:["campaignId"],additionalProperties:!1}},{name:"schedule_campaign",description:"Schedule a draft or already scheduled campaign. Returns dashboard edit and preview URLs.",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},campaignId:{type:"string",description:"Campaign ID"},scheduledAt:{type:"string",description:"Future ISO 8601 timestamp for the send, for example 2026-06-01T14:00:00Z."},targetLists:{type:"object",description:"Optional campaign targeting object. Omit to use saved targeting or all active subscribers. Examples: {type:'all'}, {type:'lists', listIds:['list_123']}, {type:'segment', segmentId:'seg_123'}, or {type:'filtered', filters:[...], filterJoinOperator:'and'}.",additionalProperties:!0},sendTimeOptimization:{type:"boolean",description:"Whether to use send-time optimization."},spreadOverHours:{type:"number",description:"Spread delivery over an integer number of hours from 1 to 72. When set, spread delivery takes precedence over send-time optimization."}},required:["campaignId","scheduledAt"],additionalProperties:!1}},{name:"send_test_email",description:"Send a test email to a single address",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},campaignId:{type:"string",description:"Campaign ID to test"},to:{type:"string",description:"Email address to send test to"}},required:["campaignId","to"]}},{name:"cancel_campaign",description:"Cancel a campaign. Stops scheduled and sending campaigns (also works for paused and approval-pending ones). Remaining emails will not be sent and the campaign cannot be restarted - this cannot be undone.",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},campaignId:{type:"string",description:"Campaign ID to cancel."}},required:["campaignId"]}},{name:"pause_campaign",description:"Pause a campaign that is currently sending. Only campaigns in sending status can be paused. Use resume_campaign to continue delivery later.",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},campaignId:{type:"string",description:"Campaign ID to pause."}},required:["campaignId"]}},{name:"resume_campaign",description:"Resume a paused campaign. Only campaigns in paused status can be resumed. Optionally spread the remaining delivery over a number of hours.",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},campaignId:{type:"string",description:"Campaign ID to resume."},spreadOverHours:{type:"number",description:"Spread the remaining delivery over an integer number of hours from 1 to 72."}},required:["campaignId"]}},{name:"delete_campaign",description:"Permanently delete a campaign. This cannot be undone. Sending, scheduled, or paused campaigns must be cancelled with cancel_campaign first.",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},campaignId:{type:"string",description:"Campaign ID to delete."}},required:["campaignId"]}},{name:"duplicate_campaign",description:"Duplicate a campaign as a new draft. mode 'campaign' (default) copies the campaign and its email, 'ab_test' also duplicates the campaign's A/B test with all variants, and 'variant' copies a single variant's content as the new campaign email (requires variantId).",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},campaignId:{type:"string",description:"Campaign ID to duplicate."},mode:{type:"string",enum:["campaign","ab_test","variant"],description:"Duplication mode. Defaults to campaign."},variantId:{type:"string",description:"A/B test variant ID whose content becomes the new campaign email. Required when mode is variant."}},required:["campaignId"]}},{name:"list_sequences",description:"List all email sequences (automations)",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID to list sequences for. If not provided, uses the currently selected company."}}}},{name:"get_sequence",description:"Get sequence details plus editable step content. The response includes sequence.emails with each step's nodeId, linked emailId, subject, previewText, and blocks.",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},sequenceId:{type:"string",description:"Sequence ID"}},required:["sequenceId"],additionalProperties:!1}},{name:"create_sequence",description:`Create a new email sequence. Provide either a goal for AI generation or explicit steps. Explicit steps can include email content and create_discount actions; emails after a discount action can use merge tags such as {{discount.code}} and {{discount.percentOff}}. For AI-generated sequences, the tool polls until emails are generated (typically 30-60 seconds).
|
|
52
52
|
|
|
53
53
|
IMPORTANT GUIDELINES:
|
|
54
54
|
|
|
@@ -121,6 +121,7 @@ IMPORTANT GUIDELINES:
|
|
|
121
121
|
SINGLE-PRODUCT PURCHASE SEQUENCE (e.g. digital product delivery):
|
|
122
122
|
- trigger: event_received, eventName: "ecommerce.order_placed", propertyFilters: [{ path: "lineItems[].providerProductId", operator: "equals", value: "<productId>" }]
|
|
123
123
|
- For Stripe purchases use eventName: "saas.purchase" with propertyFilters: [{ path: "productIds", operator: "equals", value: "prod_XXX" }]
|
|
124
|
+
- To match any of several products, use operator "one_of" with an array value: [{ path: "lineItems[].providerProductId", operator: "one_of", value: ["<productId1>", "<productId2>"] }]
|
|
124
125
|
- Goal: Only start the sequence when a specific product was purchased
|
|
125
126
|
|
|
126
127
|
WELCOME SERIES:
|
|
@@ -182,6 +183,6 @@ BUILT-IN EVENTS (auto-fired by payment integrations):
|
|
|
182
183
|
|
|
183
184
|
OTHER BUILT-IN EVENTS:
|
|
184
185
|
- email.opened, email.clicked, email.replied, email.bounced, email.unsubscribed
|
|
185
|
-
- contact.subscribed, contact.unsubscribed`,inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID to create the sequence in. If not provided, uses the currently selected company."},name:{type:"string",description:"Sequence name (e.g., 'User Onboarding', 'Welcome Series')"},trigger:{type:"string",enum:["contact_added","tag_added","segment_entered","event_received","inactivity","frequency"],description:"Trigger type: 'contact_added' (when added to a list), 'tag_added' (when tag is applied), 'segment_entered' (when a contact newly enters a saved segment), 'event_received' (when custom event fires), 'inactivity' (when subscriber hasn't performed an event for X days), 'frequency' (when subscriber performs event X times in Y days)"},listId:{type:"string",description:"List ID to trigger on (for contact_added trigger). If not provided, triggers on any list."},tagName:{type:"string",description:"Tag name to trigger on (required for tag_added trigger)"},segmentId:{type:"string",description:"Segment ID to trigger on (required for segment_entered trigger). Use list_segments first to choose a saved segment."},eventName:{type:"string",description:"Event name to trigger on (required for event_received, inactivity, and frequency triggers)"},propertyFilters:{type:"array",description:"Optional event property filters for event_received triggers. The sequence only starts when the triggering event's properties match ALL filters. Use a dot-path into the event properties; use [] to match inside arrays. Examples: scope a purchase sequence to one product with { path: 'lineItems[].providerProductId', operator: 'equals', value: 'prod_123' } (ecommerce.order_placed) or { path: 'productIds', operator: 'equals', value: 'prod_123' } (saas.purchase). Max 10 filters.",items:{type:"object",properties:{path:{type:"string",description:"Dot-path into the event properties, e.g. 'lineItems[].providerProductId' or 'plan'."},operator:{type:"string",enum:["exists","not_exists","equals","not_equals","contains","greater_than","less_than"],description:"Comparison operator."},value:{type:["string","number","boolean"],description:"Value to compare against. Required for every operator except exists/not_exists."}},required:["path","operator"]}},inactiveDays:{type:"number",description:"Number of days of inactivity (required for inactivity trigger, must be >= 1)"},inactivityBaseline:{type:"string",enum:["sequence_created_at","subscriber_created_at"],description:"When to start counting inactivity for subscribers who never had the event. Defaults to sequence_created_at."},minCount:{type:"number",description:"Minimum event count (required for frequency trigger, must be >= 1)"},timeWindowDays:{type:"number",description:"Time window in days for frequency trigger (required for frequency trigger, must be >= 1)"},emailCount:{type:"number",description:"Number of emails in the sequence (default: 5, max: 10)"},goal:{type:"string",description:"What this sequence should accomplish for AI generation. Be specific to the app's actual features and user journey. Avoid generic goals that don't match the app's business model."},enrollmentMode:{type:"string",enum:["unlimited","one_time","matching_field"],description:"Sequence re-entry mode. Use 'matching_field' only for event_received triggers when duplicate active runs should be blocked per event field value."},enrollmentFieldPath:{type:"string",description:"Dot-path event property used by enrollmentMode='matching_field', such as 'order.id' or 'product.providerVariantId'. Leave omitted for Shopify back-in-stock/replenishment product-variant defaults."},stopCondition:{type:"object",description:"Optional explicit auto-stop condition. Use { type: 'has_tag', value: 'customer' } to end the sequence when a subscriber gets a tag, { type: 'does_not_have_tag', value: 'trial' } when a tag is removed, { type: 'removed_from_list', value: 'list_123' } when they leave a list, { type: 'event_received', value: 'onboarding.completed' } when an event is tracked, or { type: 'none', value: null } for no auto-stop.",properties:{type:{type:"string",enum:["none","has_tag","does_not_have_tag","added_to_list","removed_from_list","event_received"],description:"Stop condition type."},value:{type:["string","null"],description:"Tag name, list ID, or event name for the stop condition. Use null or omit for type 'none'."}},required:["type"]},steps:{type:"array",description:"Explicit sequence steps. Omit type for email steps, or use type: 'create_discount' for a Stripe discount action. Later email steps can reference the most recent discount with {{discount.code}}, {{discount.percentOff}}, {{discount.amountOff}}, and {{discount.expiresAt}}.",items:{type:"object",properties:{type:{type:"string",enum:["email","create_discount","discount"],description:"Step type. Omit or use 'email' for email content. Use 'create_discount' to generate a discount code before later emails."},subject:{type:"string",description:"Email subject. Required for email steps."},previewText:{type:"string",description:"Email preview text."},blocks:{type:"array",description:u5,items:{type:"object"}},html:{type:"string",description:"HTML content for email steps. Will be converted to Sequenzy blocks."},delay:{type:"object",description:"Delay before this step.",properties:{days:{type:"number"},hours:{type:"number"},minutes:{type:"number"}}},name:{type:"string",description:"Email template name for email steps."},discount:{type:"object",description:"Discount configuration for create_discount steps. Prefer this nested shape for new integrations; legacy top-level discount fields are still accepted.",properties:{label:{type:"string",description:"Builder label for the discount step."},provider:{type:"string",enum:["stripe"],description:"Discount provider. Currently only 'stripe'."},discountType:{type:"string",enum:["percent","amount"],description:"Discount type."},percentOff:{type:"number",description:"Percent discount from 1 to 100. Required when discountType is percent."},amountOff:{type:"number",description:"Fixed amount discount in the smallest currency unit, for example 500 for $5. Required when discountType is amount."},currency:{type:"string",description:"ISO currency for amount discounts. Defaults to usd."},duration:{type:"string",enum:["once","forever","repeating"],description:"Stripe coupon duration. Defaults to once."},durationInMonths:{type:"number",description:"Required for repeating discounts."},appliesToAllPlans:{type:"boolean",description:"Whether the discount applies to all plans. Defaults to true."},planIds:{type:"array",description:"Stripe product IDs, such as prod_abc123, when appliesToAllPlans is false.",items:{type:"string"}},codePrefix:{type:"string",description:"Optional prefix for generated promotion codes."},maxRedemptions:{type:"number",description:"Maximum promotion code redemptions. Use 1 for subscriber-specific codes."},lockToSubscriber:{type:"boolean",description:"Stripe-only. Restrict each generated promotion code to the matched subscriber's Stripe customer."},expiresAt:{type:"string",description:"Optional future expiration date or ISO timestamp."},expiresInHours:{type:"number",description:"Optional relative expiration in hours, resolved when each subscriber's code is created (e.g., 48 for a 48-hour window per subscriber). Takes precedence over expiresAt."},name:{type:"string",description:"Optional provider coupon name."}}},label:{type:"string",description:"Legacy top-level discount label. Prefer discount.label."},provider:{type:"string",enum:["stripe"],description:"Legacy top-level discount provider. Prefer discount.provider."},discountType:{type:"string",enum:["percent","amount"],description:"Legacy top-level discount type. Prefer discount.discountType."},percentOff:{type:"number",description:"Percent discount from 1 to 100. Required when discountType is percent."},amountOff:{type:"number",description:"Fixed amount discount in the smallest currency unit, for example 500 for $5. Required when discountType is amount."},currency:{type:"string",description:"ISO currency for amount discounts. Defaults to usd."},duration:{type:"string",enum:["once","forever","repeating"],description:"Stripe coupon duration. Defaults to once."},durationInMonths:{type:"number",description:"Required for repeating discounts."},appliesToAllPlans:{type:"boolean",description:"Whether the discount applies to all plans. Defaults to true."},planIds:{type:"array",description:"Stripe product IDs, such as prod_abc123, when appliesToAllPlans is false.",items:{type:"string"}},codePrefix:{type:"string",description:"Optional prefix for generated promotion codes."},maxRedemptions:{type:"number",description:"Maximum promotion code redemptions. Use 1 for subscriber-specific codes."},lockToSubscriber:{type:"boolean",description:"Legacy top-level Stripe-only flag. Prefer discount.lockToSubscriber."},expiresAt:{type:"string",description:"Optional future expiration date or ISO timestamp."},expiresInHours:{type:"number",description:"Optional relative expiration in hours, resolved when each subscriber's code is created (e.g., 48 for a 48-hour window per subscriber). Takes precedence over expiresAt."}}}}},required:["name","trigger"]}},{name:"update_sequence",description:"Update an existing sequence. To target a specific step, use the emailId or nodeId returned in get_sequence.sequence.emails. You can also update enrollmentMode and enrollmentFieldPath for event-triggered matching-field enrollment. When inserting an if/else branch, include steps for every branch arm and elseSteps so the branch is usable immediately. Branch conditions support tags, lists, saved segments, custom events, clicked links, and subscriber field comparisons.",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},sequenceId:{type:"string",description:"Sequence ID"},name:{type:"string",description:"Sequence name"},enrollmentMode:{type:"string",enum:["unlimited","one_time","matching_field"],description:"Updated sequence re-entry mode. 'matching_field' is only valid for event-based sequence triggers."},enrollmentFieldPath:{type:"string",description:"Dot-path event property used by enrollmentMode='matching_field', such as 'order.id' or 'product.providerVariantId'. Omit to leave unchanged. Use clearEnrollmentFieldPath to clear it."},clearEnrollmentFieldPath:{type:"boolean",description:"Set true to clear enrollmentFieldPath without sending a nullable schema value."},stopCondition:{type:"object",description:"Update the sequence auto-stop condition. Example: { type: 'has_tag', value: 'customer' } ends the sequence when the subscriber has that tag. Use { type: 'removed_from_list', value: 'list_123' } to stop when they leave a list, or { type: 'none', value: null } to clear it.",properties:{type:{type:"string",enum:["none","has_tag","does_not_have_tag","added_to_list","removed_from_list","event_received"]},value:{type:["string","null"],description:"Tag name, list ID, or event name for the stop condition."}},required:["type"]},branch:{type:"object",description:"Insert an if/else branch into an existing sequence. The branch is inserted after afterNodeId and creates an if path plus an else fallback path. Use get_sequence first to choose afterNodeId. Each branch condition should include steps, and elseSteps is required unless allowEmptyPaths is true. Conditions support tags, lists, saved segments, events, clicked links, and field comparisons. Use activityScope for event_received and link_clicked checks.",properties:{afterNodeId:{type:"string",description:"Existing node ID to insert the branch after. Use a nodeId from get_sequence.sequence.nodes or get_sequence.sequence.emails."},label:{type:"string",description:"Optional branch node label."},branches:{type:"array",description:"Conditional branches evaluated in order. An else fallback is created automatically.",items:{type:"object",properties:{id:{type:"string",description:"Optional stable branch ID. Defaults to branch-0, branch-1, etc."},label:{type:"string",description:"Display label, e.g. 'If has customer tag'."},conditionType:{type:"string",enum:["has_tag","in_list","in_segment","event_received","link_clicked","field_equals","field_contains","field_greater_than","field_less_than"],description:"Condition type for this branch."},tagName:{type:"string",description:"Tag name for has_tag conditions. This can be used instead of tagId."},tagId:{type:"string",description:"Tag ID or tag name for has_tag conditions."},listId:{type:"string",description:"List ID for in_list conditions."},segmentId:{type:"string",description:"Segment ID for in_segment conditions."},segmentName:{type:"string",description:"Optional display name for in_segment conditions."},eventName:{type:"string",description:"Event name for event_received conditions, such as project.invite.accepted."},linkUrl:{type:"string",description:"Optional URL substring for link_clicked conditions. Omit to match any clicked link."},activityScope:{type:"string",enum:["ever","this_sequence","previous_email"],description:"Scope for event_received and link_clicked conditions. Omit to check ever."},fieldName:{type:"string",description:"Subscriber attribute name for field conditions."},fieldValue:{type:"string",description:"Comparison value for field conditions."},steps:{type:"array",description:"Steps to create inside this branch path. Required by default so the branch is not an empty placeholder.",items:_5}},required:["conditionType"]}},elseSteps:{type:"array",description:"Steps to create inside the else fallback path. Required by default so the else arm is usable.",items:_5},allowEmptyPaths:{type:"boolean",description:"Set true only when intentionally creating empty UI placeholders. Normal API/MCP use should omit this and provide branch steps plus elseSteps."}},required:["afterNodeId","branches"]},emails:{type:"array",description:"Updated sequence emails. If you omit emailId/nodeId, items are matched by existing step order.",items:{type:"object",properties:{emailId:{type:"string",description:"Optional target linked email template ID for a step. Use the emailId returned in get_sequence.sequence.emails."},nodeId:{type:"string",description:"Optional target action_email node ID for a step. Use the nodeId returned in get_sequence.sequence.emails."},name:{type:"string",description:"Updated step/template name"},subject:{type:"string",description:"Updated email subject"},previewText:{type:"string",description:"Updated preview text"},html:{type:"string",description:"Updated HTML content. Will be converted to Sequenzy blocks."},htmlContent:{type:"string",description:"Alias for html. Use this when updating HTML content for a step."},blocks:{type:"array",description:i1,items:{type:"object"}}}}},steps:{type:"array",description:"Alias for emails. Supports the same fields and matching rules.",items:{type:"object",properties:{emailId:{type:"string",description:"Optional target linked email template ID for a step. Use the emailId returned in get_sequence.sequence.emails."},nodeId:{type:"string",description:"Optional target action_email node ID for a step. Use the nodeId returned in get_sequence.sequence.emails."},name:{type:"string",description:"Updated step/template name"},subject:{type:"string",description:"Updated email subject"},previewText:{type:"string",description:"Updated preview text"},html:{type:"string",description:"Updated HTML content. Will be converted to Sequenzy blocks."},htmlContent:{type:"string",description:"Alias for html. Use this when updating HTML content for a step."},blocks:{type:"array",description:i1,items:{type:"object"}}}}}},required:["sequenceId"]}},{name:"enable_sequence",description:"Enable/activate a sequence. IMPORTANT: Only call this when the user EXPLICITLY asks to enable or activate a sequence. Never enable sequences automatically after creation - the user must review the content first.",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},sequenceId:{type:"string",description:"Sequence ID"}},required:["sequenceId"]}},{name:"disable_sequence",description:"Disable/pause a sequence",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},sequenceId:{type:"string",description:"Sequence ID"}},required:["sequenceId"]}},{name:"enroll_subscribers_in_sequence",description:"Manually enroll subscribers in a sequence by email address. Maximum 500 emails per call. Only active subscribers are enrolled: unknown emails are returned in `notFound`, while inactive subscribers and subscribers already actively enrolled in the sequence are counted in `skipped`. By default enrollment starts at the first step after the trigger; pass targetNodeId to start at a specific step.",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},sequenceId:{type:"string",description:"Sequence ID to enroll subscribers in."},emails:{type:"array",items:{type:"string"},description:"Email addresses of subscribers to enroll. Maximum 500 per call."},targetNodeId:{type:"string",description:"Optional node ID to start enrollment at. Use a non-trigger nodeId from get_sequence. Defaults to the first step after the trigger."}},required:["sequenceId","emails"]}},{name:"cancel_sequence_enrollments",description:"Cancel active/waiting enrollments in one sequence. Provide sequenceId and exactly one target: subscriberId for one subscriber, or fieldValues to match stored entry event properties. For fieldValues, fieldPath is optional when the sequence has enrollmentFieldPath configured; otherwise provide a dot path such as order.id.",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},sequenceId:{type:"string",description:"Sequence ID whose enrollments should be cancelled."},subscriberId:{type:"string",description:"Subscriber ID to cancel in this sequence. Provide subscriberId or fieldValues, not both."},fieldPath:{type:"string",description:"Dot-path inside the token's stored entry event properties, such as order.id or event.id. Optional when the sequence has enrollmentFieldPath configured."},fieldValues:{type:"array",items:{type:"string"},description:"Entry field values to match. Cancels all active/waiting enrollments in the sequence whose entry field value is in this list. Provide fieldValues or subscriberId, not both."},dryRun:{type:"boolean",description:"When true, returns matching enrollments without cancelling them. Field-value cancellation defaults to dryRun on the API unless explicitly false."},reason:{type:"string",description:"Optional cancellation reason stored on matched enrollment tokens."}},required:["sequenceId"],additionalProperties:!1}},{name:"delete_sequence",description:"Delete a sequence",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},sequenceId:{type:"string",description:"Sequence ID"}},required:["sequenceId"]}},{name:"list_transactional_emails",description:"List transactional email templates, including their API slugs and linked email IDs",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."}}}},{name:"get_transactional_email",description:"Get a transactional email by ID or slug, including subject, preview text, blocks, variables, and linked dashboard URLs",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},idOrSlug:{type:"string",description:"Transactional email ID or API slug, for example `welcome-email`."}},required:["idOrSlug"]}},{name:"create_transactional_email",description:"Create a saved transactional email template with an API slug. Provide `prompt` to generate the email with AI, or provide either `html` or Sequenzy `blocks` for the email body.",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},name:{type:"string",description:"Transactional email name."},slug:{type:"string",description:"Optional API slug used when sending by slug, for example `password-reset`. If omitted, Sequenzy generates one from the name."},subject:{type:"string",description:"Email subject line. Optional when `prompt` is provided because the generated subject will be used."},previewText:{type:["string","null"],description:"Email preview text."},html:{type:"string",description:"Email HTML content. Mutually exclusive with `blocks`."},blocks:{type:"array",description:`${m4} Mutually exclusive with \`html\`.`,items:{type:"object"}},prompt:{type:"string",description:"Generate transactional email blocks from a prompt. Mutually exclusive with `html` and `blocks`."},style:{type:"string",description:"Prompt generation style: minimal, branded, promotional. Only used with `prompt`."},tone:{type:"string",description:"Prompt generation tone: professional, casual, friendly. Only used with `prompt`."},enabled:{type:"boolean",description:"Whether this transactional email can be sent immediately. Defaults to true."}},required:["name"],additionalProperties:!1}},{name:"update_transactional_email",description:"Update a transactional email by ID or slug. At least one of `name`, `enabled`, `subject`, `previewText`, `html`, or `blocks` is required. Use `html` or `blocks` to replace the linked email body.",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},idOrSlug:{type:"string",description:"Transactional email ID or API slug, for example `welcome-email`."},name:{type:"string",description:"Transactional email name."},enabled:{type:"boolean",description:"Whether this transactional email can be sent."},subject:{type:"string",description:"Email subject line."},previewText:{type:["string","null"],description:"Email preview text."},html:{type:"string",description:"Email HTML content. Mutually exclusive with `blocks`."},blocks:{type:"array",description:`${i1} Mutually exclusive with \`html\`.`,items:{type:"object"}}},required:["idOrSlug"],additionalProperties:!1}},{name:"send_email",description:"Send a transactional email to a single recipient",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},to:{type:"string",description:"Recipient email address"},subject:{type:"string",description:"Email subject (required if not using templateId)"},html:{type:"string",description:"Email HTML content (required if not using templateId)"},templateId:{type:"string",description:"Template ID to use (alternative to html)"},variables:{type:"object",description:"Variables for template personalization. Nested objects and arrays are supported for repeat blocks, for example { items: [...] }."},subscriberExternalId:{type:"string",description:"Customer-owned subscriber ID for attaching analytics/localization on single-recipient sends."}},required:["to"]}},{name:"get_stats",description:"Get overview statistics for a time period",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},period:{type:"string",description:"Time period: 7d, 30d, or 90d (default: 7d)"}}}},{name:"get_campaign_stats",description:"Get detailed statistics for a campaign",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},campaignId:{type:"string",description:"Campaign ID"}},required:["campaignId"]}},{name:"get_sequence_stats",description:"Get statistics for a sequence, including per-step failed subscribers and failure reasons",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},sequenceId:{type:"string",description:"Sequence ID"}},required:["sequenceId"]}},{name:"get_subscriber_activity",description:"Get recent activity, email stats, and current sequence enrollments for a subscriber",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},email:{type:"string",description:"Subscriber email address. Provide email or externalId to identify the subscriber."},externalId:{type:"string",description:"Customer-owned subscriber ID. Provide email or externalId to identify the subscriber."}},required:[]}},{name:"list_team_members",description:"List team members for the company, including the owner, members with their roles, and pending or expired invitations.",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."}}}},{name:"invite_team_member",description:"Invite a team member by email with role admin or viewer. Existing Sequenzy users are added to the team immediately; others receive an email invitation. Billing access (canManageBilling) can only be granted by the company owner.",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},email:{type:"string",description:"Email address of the person to invite."},role:{type:"string",enum:["admin","viewer"],description:"Team role. Admins can manage the workspace; viewers have read-only access."},canManageBilling:{type:"boolean",description:"Whether the member can manage billing. Only the company owner can grant billing access. Defaults to false."}},required:["email","role"]}},{name:"cancel_team_invitation",description:"Cancel a pending team invitation. Invitations that have already been accepted cannot be cancelled.",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},invitationId:{type:"string",description:"Invitation ID to cancel. Use list_team_members to find pending invitations."}},required:["invitationId"]}},{name:"list_conversations",description:"List inbox conversations (email replies from subscribers). Filter by status, free-text search, or unread state, with pagination.",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},status:{type:"string",enum:["open","closed","all"],description:"Filter by conversation status. Defaults to all."},search:{type:"string",description:"Free-text search across conversation subjects and participants."},unread:{type:"boolean",description:"Set true to only return conversations with unread messages."},page:{type:"number",description:"Page number. Defaults to 1."},limit:{type:"number",description:"Results per page, from 1 to 100. Defaults to 20."}}}},{name:"get_conversation",description:"Get a conversation with its full message history, subscriber details, and context.",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},conversationId:{type:"string",description:"Conversation ID."}},required:["conversationId"]}},{name:"reply_to_conversation",description:"Send a reply in a conversation, or add an internal note. type 'outbound' (default) emails the subscriber and requires bodyText or bodyHtml; type 'note' adds a private team-only note. Replying to a closed conversation reopens it.",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},conversationId:{type:"string",description:"Conversation ID to reply in."},type:{type:"string",enum:["outbound","note"],description:"Message type: outbound emails the subscriber, note is internal-only. Defaults to outbound."},subject:{type:"string",description:"Optional subject override. Defaults to the conversation subject."},bodyText:{type:"string",description:"Plain-text message body."},bodyHtml:{type:"string",description:"HTML message body."}},required:["conversationId"]}},{name:"update_conversation_status",description:"Open or close a conversation.",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},conversationId:{type:"string",description:"Conversation ID."},status:{type:"string",enum:["open","closed"],description:"New conversation status."}},required:["conversationId","status"]}},{name:"mark_conversation_read",description:"Mark all unread inbound messages in a conversation as read.",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},conversationId:{type:"string",description:"Conversation ID."}},required:["conversationId"]}},{name:"list_webhooks",description:"List outbound webhook endpoints and their subscribed event types.",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."}}}},{name:"create_webhook",description:"Create an outbound webhook endpoint. IMPORTANT: the response includes a signingSecret that is returned only once - show it to the user immediately so they can store it and verify webhook signatures. If events is omitted, a default set of event types is subscribed.",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},name:{type:"string",description:"Webhook endpoint name."},url:{type:"string",description:"HTTPS URL that will receive webhook events."},events:{type:"array",items:{type:"string",enum:[...FQ]},description:"Event types to subscribe to. If omitted, a default set is used."}},required:["name","url"]}},{name:"update_webhook",description:"Update an outbound webhook endpoint's name, URL, subscribed events, or status (enabled/disabled). Providing events replaces the existing event list.",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},webhookId:{type:"string",description:"Webhook endpoint ID."},name:{type:"string",description:"New webhook endpoint name."},url:{type:"string",description:"New HTTPS URL that will receive webhook events."},events:{type:"array",items:{type:"string",enum:[...FQ]},description:"Replacement event type subscriptions."},status:{type:"string",enum:["enabled","disabled"],description:"Enable or disable deliveries to this endpoint."}},required:["webhookId"]}},{name:"delete_webhook",description:"Permanently delete an outbound webhook endpoint along with its delivery history. This cannot be undone. To keep the endpoint but stop deliveries, use update_webhook with status disabled instead.",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},webhookId:{type:"string",description:"Webhook endpoint ID to delete."}},required:["webhookId"]}},{name:"test_webhook",description:"Send a test event to an outbound webhook endpoint to verify it is reachable and signatures can be validated.",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},webhookId:{type:"string",description:"Webhook endpoint ID to test."}},required:["webhookId"]}},{name:"list_webhook_deliveries",description:"List recent delivery attempts for an outbound webhook endpoint, including status and response codes.",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},webhookId:{type:"string",description:"Webhook endpoint ID."},limit:{type:"number",description:"Maximum number of deliveries to return, from 1 to 100. Defaults to 20."}},required:["webhookId"]}},{name:"replay_webhook_delivery",description:"Replay a previous webhook delivery, re-sending the same event payload to the endpoint.",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},webhookId:{type:"string",description:"Webhook endpoint ID."},deliveryId:{type:"string",description:"Delivery ID to replay. Use list_webhook_deliveries to find delivery IDs."}},required:["webhookId","deliveryId"]}},{name:"generate_email",description:"Generate email blocks from a prompt",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},prompt:{type:"string",description:"Description of the email to generate"},style:{type:"string",description:"Style: minimal, branded, promotional"},tone:{type:"string",description:"Tone: professional, casual, friendly"}},required:["prompt"]}},{name:"generate_sequence",description:"[DEPRECATED - Use create_sequence instead] Generate a multi-email sequence from a goal. Note: create_sequence now handles AI generation automatically.",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},goal:{type:"string",description:"Goal of the sequence (e.g., 'onboard new SaaS trial users')"},emailCount:{type:"number",description:"Number of emails in the sequence (default: 5, max: 10)"},durationDays:{type:"number",description:"Total duration in days (default: 14)"}},required:["goal"]}},{name:"generate_subject_lines",description:"Generate A/B test subject line variants",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},topic:{type:"string",description:"Topic or context for the subject lines"},count:{type:"number",description:"Number of variants to generate (default: 5)"}},required:["topic"]}}];async function m5(Q,Y){try{let X;switch(Q){case"get_account":{let G=await F("GET","/api/v1/account"),$=Q1();X={...G,selectedCompanyId:$??G.currentCompanyId};break}case"select_company":{let G=Y.companyId,$=await F("GET","/api/v1/account"),J=$.companies?.find((z)=>z.id===G);if(!J)throw Error(`Company not found. Available companies: ${$.companies?.map((z)=>`${z.name} (${z.id})`).join(", ")??"none"}`);n4(G),X={success:!0,message:`Switched to company: ${J.name}`,companyId:J.id,companyName:J.name};break}case"get_app_urls":{let G=await h5(Y);X={...q1({companyId:G,campaignId:N(Y,"campaignId"),sequenceId:N(Y,"sequenceId"),emailId:N(Y,"emailId")??N(Y,"templateId"),transactionalId:N(Y,"transactionalId"),emailSendId:N(Y,"emailSendId"),domainId:N(Y,"domainId"),status:N(Y,"status"),settingsTab:N(Y,"settingsTab")}),...G===void 0&&{note:"No company ID is selected. Call get_account, select_company, or pass companyId to get concrete dashboard URLs."}};break}case"create_company":{let G=await F("POST","/api/v1/companies",{name:Y.name,domain:Y.domain});if(!G.success)throw Error("Failed to create company");let $=G.company.id,J=6,z=0,H=G.company.status;while(H==="processing"&&z<J){await new Promise((B)=>setTimeout(B,20000)),z++;let A=await F("GET",`/api/v1/companies/${$}`);if(A.success)H=A.company.status}n4($);let U=await F("GET",`/api/v1/companies/${$}`);X={success:!0,company:U.company,message:H==="processing"?"Company created but still processing. You can continue using it while processing completes.":`Company '${U.company.name}' created and ready to use.`,autoSelected:!0};break}case"get_company":{let G=Y.companyId;X=await F("GET",`/api/v1/companies/${G}`);break}case"create_api_key":{let G=Y.companyId;X=await F("POST","/api/v1/api-keys",{name:Y.name},G);break}case"list_websites":{let G=Y.companyId;X=await F("GET","/api/v1/websites",void 0,G);break}case"add_website":{let G=Y.companyId;X=await F("POST","/api/v1/websites",{domain:Y.domain},G);break}case"check_website":{let G=Y.companyId;X=await F("GET",`/api/v1/websites/${Y.domain}`,void 0,G);break}case"get_integration_guide":X=await F("POST","/api/v1/integration-guide",Y);break;case"add_subscriber":{let G=Y.companyId,$=c4("add_subscriber",Y);X=await F("POST","/api/v1/subscribers",{...$,customAttributes:Y.attributes,tags:Y.tags,lists:Y.listIds,...Y.status!==void 0&&{status:Y.status},...Y.optInMode!==void 0&&{optInMode:Y.optInMode}},G);break}case"update_subscriber":{let G=Y.companyId,$=c4("update_subscriber",Y),J=await _Y($,G),z=Array.isArray(J.subscriber.tags)?J.subscriber.tags.filter((K)=>typeof K==="string"):[],H=Array.isArray(Y.addTags)?Y.addTags.filter((K)=>typeof K==="string"&&K.trim()!=="").map(y5):[],U=new Set(Array.isArray(Y.removeTags)?Y.removeTags.filter((K)=>typeof K==="string"&&K.trim()!=="").map(y5):[]),A=z.filter((K)=>!U.has(K));for(let K of H)if(!A.includes(K))A.push(K);let B={};if($.email&&$.externalId)B.externalId=$.externalId;if(B0(Y.attributes))B.customAttributes={...B0(J.subscriber.customAttributes)?J.subscriber.customAttributes:{},...Y.attributes};if(Y.addTags||Y.removeTags)B.tags=A;X=await F("PATCH",lY($),B,G);break}case"remove_subscriber":{let G=Y.companyId,$=c4("remove_subscriber",Y),J=lY($);if(Y.hardDelete===!0)X=await F("DELETE",J,void 0,G);else X=await F("PATCH",J,{status:"unsubscribed"},G);break}case"get_subscriber":{let G=Y.companyId,$=c4("get_subscriber",Y);X=await _Y($,G);break}case"search_subscribers":{let G=Y.companyId;X=await GV(Y,G);break}case"list_products":{let G=Y.companyId,$=new URLSearchParams;if(typeof Y.provider==="string"&&Y.provider.trim())$.set("provider",Y.provider.trim());if(typeof Y.search==="string"&&Y.search.trim())$.set("search",Y.search.trim());let J=$.size>0?`?${$.toString()}`:"";X=await F("GET",`/api/v1/products${J}`,void 0,G);break}case"upsert_products":{let G=Y.companyId;if(!Array.isArray(Y.products)||Y.products.length===0)throw Error("`products` must be a non-empty array when calling `upsert_products`.");X=await F("POST","/api/v1/products",{products:Y.products},G);break}case"delete_product":{let G=Y.companyId,$=x("delete_product",Y,"productId");X=await F("DELETE",`/api/v1/products/${encodeURIComponent($)}`,void 0,G);break}case"attach_product_file":{let G=Y.companyId,$=x("attach_product_file",Y,"productId"),J=N(Y,"url"),z=N(Y,"filePath");if(J===void 0===(z===void 0))throw Error("Provide either `url` or `filePath` (not both) when calling `attach_product_file`.");let H;if(z!==void 0){let U=await UV(z,G);H={url:U.url,source:"upload",fileName:N(Y,"fileName")??U.fileName,fileSizeBytes:U.fileSizeBytes,mimeType:U.mimeType}}else{H={url:J};let U=N(Y,"fileName");if(U)H.fileName=U}X=await F("PUT",`/api/v1/products/${encodeURIComponent($)}/delivery`,H,G);break}case"remove_product_file":{let G=Y.companyId,$=x("remove_product_file",Y,"productId");X=await F("DELETE",`/api/v1/products/${encodeURIComponent($)}/delivery`,void 0,G);break}case"sync_products":{let G=Y.companyId;X=await F("POST","/api/v1/products/sync",void 0,G);break}case"list_tags":{let G=Y.companyId;X=await F("GET","/api/v1/tags",void 0,G);break}case"create_tag":{let G=Y.companyId,$=x("create_tag",Y,"name"),J=s0("create_tag",Y,"color",qQ);X=await F("POST","/api/v1/tags",{name:$,...J!==void 0&&{color:J}},G);break}case"update_tag":{let G=Y.companyId,$=x("update_tag",Y,"tagId"),J=yY("update_tag",Y,"color",qQ);X=await F("PATCH",`/api/v1/tags/${encodeURIComponent($)}`,{color:J},G);break}case"delete_tag":{let G=Y.companyId,$=x("delete_tag",Y,"tagId");X=await F("DELETE",`/api/v1/tags/${encodeURIComponent($)}`,void 0,G);break}case"list_lists":{let G=Y.companyId;X=await F("GET","/api/v1/lists",void 0,G);break}case"create_list":{let G=Y.companyId;X=await F("POST","/api/v1/lists",Y,G);break}case"update_list":{let G=Y.companyId,$=x("update_list",Y,"listId");if(Y.name===void 0&&Y.description===void 0&&Y.isPrivate===void 0)throw Error("Provide at least one of `name`, `description`, or `isPrivate` when calling `update_list`.");if(Y.name!==void 0&&N(Y,"name")===void 0)throw Error("`name` cannot be empty when calling `update_list`.");if(Y.description!==void 0&&Y.description!==null&&typeof Y.description!=="string")throw Error("`description` must be a string or null when calling `update_list`.");if(Y.isPrivate!==void 0&&typeof Y.isPrivate!=="boolean")throw Error("`isPrivate` must be a boolean when calling `update_list`.");X=await F("PATCH",`/api/v1/lists/${encodeURIComponent($)}`,{...Y.name!==void 0&&{name:N(Y,"name")},...Y.description!==void 0&&{description:Y.description},...Y.isPrivate!==void 0&&{isPrivate:Y.isPrivate}},G);break}case"delete_list":{let G=Y.companyId,$=x("delete_list",Y,"listId");X=await F("DELETE",`/api/v1/lists/${encodeURIComponent($)}`,void 0,G);break}case"add_subscribers_to_list":{let G=Y.companyId,$=x("add_subscribers_to_list",Y,"listId"),J=gY("add_subscribers_to_list",Y),z=s0("add_subscribers_to_list",Y,"duplicateStrategy",["skip","merge","overwrite"])??"skip",H=s0("add_subscribers_to_list",Y,"optInMode",["default","confirmed","double_opt_in"])??"default";X=await F("POST",`/api/v1/lists/${encodeURIComponent($)}/subscribers`,{emails:J,duplicateStrategy:z,enrollInSequences:Y.enrollInSequences===!0,optInMode:H},G);break}case"remove_subscribers_from_list":{let G=Y.companyId,$=x("remove_subscribers_from_list",Y,"listId"),J=gY("remove_subscribers_from_list",Y);X=await F("POST",`/api/v1/lists/${encodeURIComponent($)}/subscribers/remove`,{emails:J},G);break}case"list_segments":{let G=Y.companyId;X=await F("GET","/api/v1/segments",void 0,G);break}case"create_segment":{oM(Y);let G=Y.companyId;X=await F("POST","/api/v1/segments",{...Y,...Y.filters!==void 0?{filters:hY(Y.filters)}:{},...Y.root!==void 0?{root:fY(Y.root)}:{}},G);break}case"update_segment":{tM(Y);let G=Y.companyId,$=x("update_segment",Y,"segmentId"),J=N(Y,"name"),z=s0("update_segment",Y,"filterJoinOperator",["and","or"]);X=await F("PATCH",`/api/v1/segments/${encodeURIComponent($)}`,{...J!==void 0&&{name:J},...z!==void 0&&{filterJoinOperator:z},...Y.filters!==void 0?{filters:hY(Y.filters)}:{},...Y.root!==void 0?{root:fY(Y.root)}:{}},G);break}case"delete_segment":{let G=Y.companyId,$=x("delete_segment",Y,"segmentId");X=await F("DELETE",`/api/v1/segments/${encodeURIComponent($)}`,void 0,G);break}case"get_segment_count":{let G=Y.companyId;X=await F("GET",`/api/v1/segments/${Y.segmentId}/count`,void 0,G);break}case"list_templates":{let G=Y.companyId,$=new URLSearchParams,J=N(Y,"label");if(J)$.set("label",J);X=await F("GET",`/api/v1/templates${$.size>0?`?${$}`:""}`,void 0,G);break}case"get_template":{let G=Y.companyId;X=await F("GET",`/api/v1/templates/${Y.templateId}`,void 0,G);break}case"create_template":{let G=Y.companyId;P1("create_template",Y,{requireContent:!0}),LQ("create_template",Y),X=await F("POST","/api/v1/templates",Y,G);break}case"update_template":{let G=Y.companyId,$=new Set(["companyId","templateId","name","subject","html","blocks","labels"]),J=Object.keys(Y).filter((z)=>!$.has(z));if(J.length>0)throw Error(`\`update_template\` accepts only \`name\`, \`subject\`, \`html\`, \`blocks\`, and \`labels\` update fields. Unsupported field${J.length===1?"":"s"}: ${J.map((z)=>`\`${z}\``).join(", ")}.`);if(P1("update_template",Y),LQ("update_template",Y),Y.name===void 0&&Y.subject===void 0&&Y.html===void 0&&Y.blocks===void 0&&Y.labels===void 0)throw Error("Provide at least one of `name`, `subject`, `html`, `blocks`, or `labels` when calling `update_template`.");X=await F("PUT",`/api/v1/templates/${Y.templateId}`,Y,G);break}case"delete_template":{let G=Y.companyId;X=await F("DELETE",`/api/v1/templates/${Y.templateId}`,void 0,G);break}case"list_ab_tests":{let G=Y.companyId,$=new URLSearchParams,J=N(Y,"sequenceId");if(J)$.set("sequenceId",J);X=await F("GET",`/api/v1/ab-tests${$.size>0?`?${$}`:""}`,void 0,G);break}case"get_ab_test":{let G=Y.companyId;X=await F("GET",`/api/v1/ab-tests/${Y.abTestId}`,void 0,G);break}case"get_ab_test_stats":{let G=Y.companyId,$=new URLSearchParams,J=N(Y,"period"),z=N(Y,"start"),H=N(Y,"end");if(J)$.set("period",J);if(z)$.set("start",z);if(H)$.set("end",H);X=await F("GET",`/api/v1/ab-tests/${Y.abTestId}/stats${$.size>0?`?${$}`:""}`,void 0,G);break}case"restart_ab_test":{let G=Y.companyId,$=new Set(["companyId","abTestId","sourceVariantId","testType","winnerThreshold","variantCount"]),J=Object.keys(Y).filter((A)=>!$.has(A));if(J.length>0)throw Error(`\`restart_ab_test\` accepts only \`sourceVariantId\`, \`testType\`, \`winnerThreshold\`, and \`variantCount\` option fields. Unsupported field${J.length===1?"":"s"}: ${J.map((A)=>`\`${A}\``).join(", ")}.`);let z=N(Y,"testType");if(z!==void 0&&z!=="subject"&&z!=="content")throw Error("`restart_ab_test` testType must be `subject` or `content`.");let H=Y.winnerThreshold===void 0?void 0:Number(Y.winnerThreshold);if(H!==void 0&&(!Number.isInteger(H)||H<10||H>1000))throw Error("`restart_ab_test` winnerThreshold must be an integer from 10 to 1000.");let U=Y.variantCount===void 0?void 0:Number(Y.variantCount);if(U!==void 0&&(!Number.isInteger(U)||U<2||U>4))throw Error("`restart_ab_test` variantCount must be an integer from 2 to 4.");X=await F("POST",`/api/v1/ab-tests/${Y.abTestId}/restart`,{sourceVariantId:N(Y,"sourceVariantId"),testType:z,winnerThreshold:H,variantCount:U},G);break}case"update_ab_test_variant":{let G=Y.companyId,$=new Set(["companyId","abTestId","variantId","subject","previewText","html","blocks"]),J=Object.keys(Y).filter((z)=>!$.has(z));if(J.length>0)throw Error(`\`update_ab_test_variant\` accepts only \`subject\`, \`previewText\`, \`html\`, and \`blocks\` update fields. Unsupported field${J.length===1?"":"s"}: ${J.map((z)=>`\`${z}\``).join(", ")}.`);if(P1("update_ab_test_variant",Y),Y.subject===void 0&&Y.previewText===void 0&&Y.html===void 0&&Y.blocks===void 0)throw Error("Provide at least one of `subject`, `previewText`, `html`, or `blocks` when calling `update_ab_test_variant`.");X=await F("PATCH",`/api/v1/ab-tests/${Y.abTestId}/variants/${Y.variantId}`,Y,G);break}case"create_ab_test":{let G=Y.companyId,$=x("create_ab_test",Y,"campaignId"),J=N(Y,"name"),z=p4("create_ab_test",Y,"testPercentage",5,50),H=p4("create_ab_test",Y,"testDurationMinutes",15,1440),U=s0("create_ab_test",Y,"winnerCriteria",["open_rate","click_rate"]);if(Y.variants!==void 0){if(!Array.isArray(Y.variants))throw Error("`variants` must be an array when calling `create_ab_test`.");Y.variants.forEach((A,B)=>{if(!B0(A)||typeof A.subject!=="string"||A.subject.trim()==="")throw Error(`\`variants\` item ${B+1} must include a non-empty \`subject\` when calling \`create_ab_test\`.`);if(A.blocks!==void 0&&!Array.isArray(A.blocks))throw Error(`\`variants\` item ${B+1} \`blocks\` must be an array when calling \`create_ab_test\`.`)})}X=await F("POST","/api/v1/ab-tests",{campaignId:$,...J!==void 0&&{name:J},...z!==void 0&&{testPercentage:z},...H!==void 0&&{testDurationMinutes:H},...U!==void 0&&{winnerCriteria:U},...Y.variants!==void 0&&{variants:Y.variants}},G);break}case"add_ab_test_variant":{let G=Y.companyId,$=x("add_ab_test_variant",Y,"abTestId"),J=x("add_ab_test_variant",Y,"subject"),z=N(Y,"previewText");if(Y.blocks!==void 0&&!Array.isArray(Y.blocks))throw Error("`blocks` must be an array when calling `add_ab_test_variant`.");X=await F("POST",`/api/v1/ab-tests/${encodeURIComponent($)}/variants`,{subject:J,...z!==void 0&&{previewText:z},...Y.blocks!==void 0&&{blocks:Y.blocks}},G);break}case"delete_ab_test_variant":{let G=Y.companyId,$=x("delete_ab_test_variant",Y,"abTestId"),J=x("delete_ab_test_variant",Y,"variantId");X=await F("DELETE",`/api/v1/ab-tests/${encodeURIComponent($)}/variants/${encodeURIComponent(J)}`,void 0,G);break}case"delete_ab_test":{let G=Y.companyId,$=x("delete_ab_test",Y,"abTestId");X=await F("DELETE",`/api/v1/ab-tests/${encodeURIComponent($)}`,void 0,G);break}case"list_campaigns":{let G=Y.companyId,$=new URLSearchParams;if(Y.status)$.set("status",String(Y.status));let J=N(Y,"label");if(J)$.set("label",J);X=await F("GET",`/api/v1/campaigns?${$}`,void 0,G);break}case"get_campaign":{let G=Y.companyId;X=await F("GET",`/api/v1/campaigns/${Y.campaignId}`,void 0,G);break}case"get_email_send":{let G=Y.companyId;X=await F("GET",`/api/v1/email-sends/${encodeURIComponent(String(Y.emailSendId))}`,void 0,G);break}case"create_campaign":{let G=Y.companyId;eM(Y);let $=N(Y,"prompt");if($!==void 0){let J=await F("POST","/api/v1/generate/email",{prompt:$,...Y.style!==void 0&&{style:Y.style},...Y.tone!==void 0&&{tone:Y.tone}},G),z=N(Y,"subject")??(typeof J.subject==="string"&&J.subject.trim()!==""?J.subject.trim():void 0);if(!z)throw Error("`create_campaign` prompt generation did not return a subject. Provide `subject` explicitly.");let H=Array.isArray(J.blocks)&&J.blocks.length>0?J.blocks:void 0,U=typeof J.html==="string"&&J.html.trim()!==""?J.html:void 0;if(H===void 0&&U===void 0)throw Error("`create_campaign` prompt generation did not return email blocks. Try again or provide `html` or `blocks` explicitly.");X=await F("POST","/api/v1/campaigns",{name:Y.name,subject:z,...H!==void 0?{blocks:H}:{html:U},...Y.segmentId!==void 0&&{segmentId:Y.segmentId},...Y.trackingCode!==void 0&&{trackingCode:Y.trackingCode},...Y.campaignData!==void 0&&{campaignData:Y.campaignData},...Y.computedLists!==void 0&&{computedLists:Y.computedLists},...Y.labels!==void 0&&{labels:Y.labels}},G);break}X=await F("POST","/api/v1/campaigns",Y,G);break}case"update_campaign":{let G=Y.companyId,$=new Set(["companyId","campaignId","name","subject","trackingCode","html","blocks","replyTo","replyProfileId","campaignData","computedLists","labels"]),J=Object.keys(Y).filter((z)=>!$.has(z));if(J.length>0)throw Error(`\`update_campaign\` accepts only \`name\`, \`subject\`, \`trackingCode\`, \`html\`, \`blocks\`, \`replyTo\`, \`replyProfileId\`, \`campaignData\`, \`computedLists\`, and \`labels\` update fields. Unsupported field${J.length===1?"":"s"}: ${J.map((z)=>`\`${z}\``).join(", ")}.`);if(P1("update_campaign",Y),LQ("update_campaign",Y),Y.replyTo!==void 0&&Y.replyProfileId!==void 0)throw Error("Provide either `replyTo` or `replyProfileId` when calling `update_campaign`, not both.");if(Y.name===void 0&&Y.subject===void 0&&Y.trackingCode===void 0&&Y.html===void 0&&Y.blocks===void 0&&Y.replyTo===void 0&&Y.replyProfileId===void 0&&Y.campaignData===void 0&&Y.computedLists===void 0&&Y.labels===void 0)throw Error("Provide at least one of `name`, `subject`, `trackingCode`, `html`, `blocks`, `replyTo`, `replyProfileId`, `campaignData`, `computedLists`, or `labels` when calling `update_campaign`.");X=await F("PUT",`/api/v1/campaigns/${Y.campaignId}`,Y,G);break}case"schedule_campaign":{let G=Y.companyId,$=new Set(["companyId","campaignId","scheduledAt","targetLists","sendTimeOptimization","spreadOverHours"]),J=Object.keys(Y).filter((z)=>!$.has(z));if(J.length>0)throw Error(`\`schedule_campaign\` accepts only \`campaignId\`, \`scheduledAt\`, \`targetLists\`, \`sendTimeOptimization\`, and \`spreadOverHours\`. Unsupported field${J.length===1?"":"s"}: ${J.map((z)=>`\`${z}\``).join(", ")}.`);QV(Y),X=await F("POST",`/api/v1/campaigns/${Y.campaignId}/schedule`,{scheduledAt:Y.scheduledAt,...Y.targetLists!==void 0&&{targetLists:Y.targetLists},...Y.sendTimeOptimization!==void 0&&{sendTimeOptimization:Y.sendTimeOptimization},...Y.spreadOverHours!==void 0&&{spreadOverHours:Y.spreadOverHours}},G);break}case"send_test_email":{let G=Y.companyId;X=await F("POST",`/api/v1/campaigns/${Y.campaignId}/test`,{to:Y.to},G);break}case"cancel_campaign":{let G=Y.companyId,$=x("cancel_campaign",Y,"campaignId");X=await F("POST",`/api/v1/campaigns/${encodeURIComponent($)}/cancel`,void 0,G);break}case"pause_campaign":{let G=Y.companyId,$=x("pause_campaign",Y,"campaignId");X=await F("POST",`/api/v1/campaigns/${encodeURIComponent($)}/pause`,void 0,G);break}case"resume_campaign":{let G=Y.companyId,$=x("resume_campaign",Y,"campaignId"),J=p4("resume_campaign",Y,"spreadOverHours",1,72);X=await F("POST",`/api/v1/campaigns/${encodeURIComponent($)}/resume`,{...J!==void 0&&{spreadOverHours:J}},G);break}case"delete_campaign":{let G=Y.companyId,$=x("delete_campaign",Y,"campaignId");X=await F("DELETE",`/api/v1/campaigns/${encodeURIComponent($)}`,void 0,G);break}case"duplicate_campaign":{let G=Y.companyId,$=x("duplicate_campaign",Y,"campaignId"),J=s0("duplicate_campaign",Y,"mode",["campaign","ab_test","variant"]),z=N(Y,"variantId");if(J==="variant"&&z===void 0)throw Error("`variantId` is required when calling `duplicate_campaign` with mode `variant`.");X=await F("POST",`/api/v1/campaigns/${encodeURIComponent($)}/duplicate`,{...J!==void 0&&{mode:J},...z!==void 0&&{variantId:z}},G);break}case"list_sequences":{let G=Y.companyId;X=await F("GET","/api/v1/sequences",void 0,G);break}case"get_sequence":{let G=Y.companyId;X=await F("GET",`/api/v1/sequences/${Y.sequenceId}`,void 0,G);break}case"create_sequence":{let G=Y.companyId,$=Array.isArray(Y.steps)&&Y.steps.length>0,J=await F("POST","/api/v1/sequences",Y,G);if(!J.success){X=J;break}let z=J.sequence.id;if($){let K=await F("GET",`/api/v1/sequences/${z}`,void 0,G);if(K.success)X={success:!0,sequence:K.sequence,message:`Sequence "${K.sequence.name}" created with explicit steps. Review it before enabling.`};else X=K;break}let H=6,U=0,A="pending";while(A!=="complete"&&U<H){await new Promise((L)=>setTimeout(L,20000)),U++;let K=await F("GET",`/api/v1/sequences/${z}`,void 0,G);if(K.success)A=K.sequence.enrichmentStatus}let B=await F("GET",`/api/v1/sequences/${z}`,void 0,G);if(B.success)X={success:!0,sequence:B.sequence,message:B.sequence.enrichmentStatus==="complete"?`Sequence "${B.sequence.name}" created with ${B.sequence.emailCount} AI-generated emails. The sequence is ready to review and enable.`:`Sequence "${B.sequence.name}" created. Email enrichment is still in progress (${B.sequence.enrichedCount}/${B.sequence.emailCount} emails generated). You can check status with get_sequence.`};else X=B;break}case"update_sequence":{let G=Y.companyId,$=aM(Y);X=await F("PUT",`/api/v1/sequences/${Y.sequenceId}`,$,G);break}case"enable_sequence":{let G=Y.companyId;X=await F("POST",`/api/v1/sequences/${Y.sequenceId}/enable`,void 0,G);break}case"disable_sequence":{let G=Y.companyId;X=await F("POST",`/api/v1/sequences/${Y.sequenceId}/disable`,void 0,G);break}case"enroll_subscribers_in_sequence":{let G=Y.companyId,$=x("enroll_subscribers_in_sequence",Y,"sequenceId"),J=gY("enroll_subscribers_in_sequence",Y),z=N(Y,"targetNodeId");X=await F("POST",`/api/v1/sequences/${encodeURIComponent($)}/enroll`,{emails:J,...z!==void 0&&{targetNodeId:z}},G);break}case"cancel_sequence_enrollments":{let G=Y.companyId,$=sM(Y);X=await F("POST",`/api/v1/sequences/${Y.sequenceId}/enrollments/cancel`,$,G);break}case"delete_sequence":{let G=Y.companyId;X=await F("DELETE",`/api/v1/sequences/${Y.sequenceId}`,void 0,G);break}case"list_transactional_emails":{let G=Y.companyId;X=await F("GET","/api/v1/transactional",void 0,G);break}case"get_transactional_email":{let G=Y.companyId;X=await F("GET",`/api/v1/transactional/${Y.idOrSlug}`,void 0,G);break}case"create_transactional_email":{let G=Y.companyId,$=new Set(["companyId","name","slug","subject","previewText","html","blocks","prompt","style","tone","enabled"]),J=Object.keys(Y).filter((U)=>!$.has(U));if(J.length>0)throw Error(`\`create_transactional_email\` accepts only \`name\`, \`slug\`, \`subject\`, \`previewText\`, \`html\`, \`blocks\`, \`prompt\`, \`style\`, \`tone\`, and \`enabled\` fields. Unsupported field${J.length===1?"":"s"}: ${J.map((U)=>`\`${U}\``).join(", ")}.`);YV(Y);let z=N(Y,"prompt");if(z!==void 0){let U={companyId:G??Q1()??"",name:typeof Y.name==="string"&&Y.name.trim()!==""?Y.name.trim():"",slug:typeof Y.slug==="string"&&Y.slug.trim()!==""?Y.slug.trim():"",promptLength:z.length,style:typeof Y.style==="string"?Y.style:"",tone:typeof Y.tone==="string"?Y.tone:""};try{console.error("[mcp:create_transactional_email] generating from prompt",U);let A=await F("POST","/api/v1/generate/email",{prompt:z,...Y.style!==void 0&&{style:Y.style},...Y.tone!==void 0&&{tone:Y.tone}},G);console.error("[mcp:create_transactional_email] prompt generation complete",{...U,subject:A.subject??"",previewTextLength:typeof A.previewText==="string"?A.previewText.length:0,blockCount:Array.isArray(A.blocks)?A.blocks.length:0,htmlLength:typeof A.html==="string"?A.html.length:0});let B=N(Y,"subject")??(typeof A.subject==="string"&&A.subject.trim()!==""?A.subject.trim():void 0);if(!B)throw Error("`create_transactional_email` prompt generation did not return a subject. Provide `subject` explicitly.");let K=Array.isArray(A.blocks)&&A.blocks.length>0?A.blocks:void 0,L=typeof A.html==="string"&&A.html.trim()!==""?A.html:void 0,O=N(Y,"previewText")??(typeof A.previewText==="string"?A.previewText.trim():void 0);if(K===void 0&&L===void 0)throw Error("`create_transactional_email` prompt generation did not return email blocks. Try again or provide `html` or `blocks` explicitly.");console.error("[mcp:create_transactional_email] creating generated transactional",{...U,subject:B,contentSource:K!==void 0?"blocks":"html",blockCount:K?.length??0,htmlLength:L?.length??0}),X=await F("POST","/api/v1/transactional",{name:Y.name,...Y.slug!==void 0&&{slug:Y.slug},subject:B,...O!==void 0&&{previewText:O},...K!==void 0?{blocks:K}:{html:L},...Y.enabled!==void 0&&{enabled:Y.enabled}},G),console.error("[mcp:create_transactional_email] generated transactional created",U)}catch(A){throw console.error("[mcp:create_transactional_email] prompt-based create failed",{...U,error:A instanceof Error?A.message:String(A)}),A}break}let H=Object.fromEntries(Object.entries(Y).filter(([U])=>U!=="companyId"));X=await F("POST","/api/v1/transactional",H,G);break}case"update_transactional_email":{let G=Y.companyId,$=new Set(["companyId","idOrSlug","name","enabled","subject","previewText","html","blocks"]),J=Object.keys(Y).filter((H)=>!$.has(H));if(J.length>0)throw Error(`\`update_transactional_email\` accepts only \`name\`, \`enabled\`, \`subject\`, \`previewText\`, \`html\`, and \`blocks\` update fields. Unsupported field${J.length===1?"":"s"}: ${J.map((H)=>`\`${H}\``).join(", ")}.`);if(P1("update_transactional_email",Y),Y.name===void 0&&Y.enabled===void 0&&Y.subject===void 0&&Y.previewText===void 0&&Y.html===void 0&&Y.blocks===void 0)throw Error("Provide at least one of `name`, `enabled`, `subject`, `previewText`, `html`, or `blocks` when calling `update_transactional_email`.");let z=Object.fromEntries(Object.entries(Y).filter(([H])=>H!=="companyId"&&H!=="idOrSlug"));X=await F("PATCH",`/api/v1/transactional/${Y.idOrSlug}`,z,G);break}case"send_email":{let G=Y.companyId;X=await F("POST","/api/v1/transactional/send",Y,G);break}case"get_stats":{let G=Y.companyId,$=Y.period??"7d";X=await F("GET",`/api/v1/metrics?period=${$}`,void 0,G);break}case"get_campaign_stats":{let G=Y.companyId;X=await F("GET",`/api/v1/metrics/campaigns/${Y.campaignId}`,void 0,G);break}case"get_sequence_stats":{let G=Y.companyId;X=await F("GET",`/api/v1/metrics/sequences/${Y.sequenceId}`,void 0,G);break}case"get_subscriber_activity":{let G=Y.companyId,$=c4("get_subscriber_activity",Y),J=await _Y($,G);X={success:J.success,email:J.subscriber.email,emailStats:J.subscriber.emailStats??null,activity:J.subscriber.activity??[],sequenceEnrollments:J.subscriber.sequenceEnrollments??[]};break}case"list_team_members":{let G=Y.companyId;X=await F("GET","/api/v1/team",void 0,G);break}case"invite_team_member":{let G=Y.companyId,$=x("invite_team_member",Y,"email"),J=yY("invite_team_member",Y,"role",["admin","viewer"]);if(Y.canManageBilling!==void 0&&typeof Y.canManageBilling!=="boolean")throw Error("`canManageBilling` must be a boolean when calling `invite_team_member`.");X=await F("POST","/api/v1/team/invitations",{email:$,role:J,...Y.canManageBilling!==void 0&&{canManageBilling:Y.canManageBilling}},G);break}case"cancel_team_invitation":{let G=Y.companyId,$=x("cancel_team_invitation",Y,"invitationId");X=await F("DELETE",`/api/v1/team/invitations/${encodeURIComponent($)}`,void 0,G);break}case"list_conversations":{let G=Y.companyId,$=new URLSearchParams,J=s0("list_conversations",Y,"status",["open","closed","all"]);if(J)$.set("status",J);let z=N(Y,"search");if(z)$.set("search",z);if(Y.unread!==void 0){if(typeof Y.unread!=="boolean")throw Error("`unread` must be a boolean when calling `list_conversations`.");if(Y.unread)$.set("unread","true")}if(Y.page!==void 0){if(typeof Y.page!=="number"||!Number.isInteger(Y.page)||Y.page<1)throw Error("`page` must be a positive integer when calling `list_conversations`.");$.set("page",String(Y.page))}let H=p4("list_conversations",Y,"limit",1,100);if(H!==void 0)$.set("limit",String(H));X=await F("GET",`/api/v1/conversations${$.size>0?`?${$}`:""}`,void 0,G);break}case"get_conversation":{let G=Y.companyId,$=x("get_conversation",Y,"conversationId");X=await F("GET",`/api/v1/conversations/${encodeURIComponent($)}`,void 0,G);break}case"reply_to_conversation":{let G=Y.companyId,$=x("reply_to_conversation",Y,"conversationId"),J=s0("reply_to_conversation",Y,"type",["outbound","note"])??"outbound",z=N(Y,"subject"),H=N(Y,"bodyText"),U=N(Y,"bodyHtml");if(J==="outbound"&&H===void 0&&U===void 0)throw Error("Provide `bodyText` or `bodyHtml` when calling `reply_to_conversation` with an outbound message.");X=await F("POST",`/api/v1/conversations/${encodeURIComponent($)}/messages`,{type:J,...z!==void 0&&{subject:z},...H!==void 0&&{bodyText:H},...U!==void 0&&{bodyHtml:U}},G);break}case"update_conversation_status":{let G=Y.companyId,$=x("update_conversation_status",Y,"conversationId"),J=yY("update_conversation_status",Y,"status",["open","closed"]);X=await F("POST",`/api/v1/conversations/${encodeURIComponent($)}/status`,{status:J},G);break}case"mark_conversation_read":{let G=Y.companyId,$=x("mark_conversation_read",Y,"conversationId");X=await F("POST",`/api/v1/conversations/${encodeURIComponent($)}/read`,void 0,G);break}case"list_webhooks":{let G=Y.companyId;X=await F("GET","/api/v1/webhooks",void 0,G);break}case"create_webhook":{let G=Y.companyId,$=x("create_webhook",Y,"name"),J=x("create_webhook",Y,"url"),z=g5("create_webhook",Y);X=await F("POST","/api/v1/webhooks",{name:$,url:J,...z!==void 0&&{events:z}},G);break}case"update_webhook":{let G=Y.companyId,$=x("update_webhook",Y,"webhookId"),J=N(Y,"name"),z=N(Y,"url"),H=g5("update_webhook",Y),U=s0("update_webhook",Y,"status",["enabled","disabled"]);if(J===void 0&&z===void 0&&H===void 0&&U===void 0)throw Error("Provide at least one of `name`, `url`, `events`, or `status` when calling `update_webhook`.");X=await F("PATCH",`/api/v1/webhooks/${encodeURIComponent($)}`,{...J!==void 0&&{name:J},...z!==void 0&&{url:z},...H!==void 0&&{events:H},...U!==void 0&&{status:U}},G);break}case"delete_webhook":{let G=Y.companyId,$=x("delete_webhook",Y,"webhookId");X=await F("DELETE",`/api/v1/webhooks/${encodeURIComponent($)}`,void 0,G);break}case"test_webhook":{let G=Y.companyId,$=x("test_webhook",Y,"webhookId");X=await F("POST",`/api/v1/webhooks/${encodeURIComponent($)}/test`,void 0,G);break}case"list_webhook_deliveries":{let G=Y.companyId,$=x("list_webhook_deliveries",Y,"webhookId"),J=p4("list_webhook_deliveries",Y,"limit",1,100),z=new URLSearchParams;if(J!==void 0)z.set("limit",String(J));X=await F("GET",`/api/v1/webhooks/${encodeURIComponent($)}/deliveries${z.size>0?`?${z}`:""}`,void 0,G);break}case"replay_webhook_delivery":{let G=Y.companyId,$=x("replay_webhook_delivery",Y,"webhookId"),J=x("replay_webhook_delivery",Y,"deliveryId");X=await F("POST",`/api/v1/webhooks/${encodeURIComponent($)}/deliveries/${encodeURIComponent(J)}/replay`,void 0,G);break}case"generate_email":{let G=Y.companyId;X=await F("POST","/api/v1/generate/email",Y,G);break}case"generate_sequence":{let G=Y.companyId;X=await F("POST","/api/v1/generate/sequence",Y,G);break}case"generate_subject_lines":{let G=Y.companyId;X=await F("POST","/api/v1/generate/subjects",Y,G);break}default:throw Error(`Unknown tool: ${Q}`)}let W=XV(X);if(W)throw W;return X=await KV(Q,Y,X),{content:[{type:"text",text:JSON.stringify(X,null,2)}]}}catch(X){return{isError:!0,content:[{type:"text",text:e0(X)}]}}}async function c5(Q,Y,X){let W=Y.getRequestContext?.(Q)??{};try{return await NQ(W,X)}finally{await Y.onRequestContextUpdated?.(W,Q)}}function pY(Q={}){let Y=new vY({name:"sequenzy",version:I5.version},{capabilities:{tools:{},resources:{}}});return Y.setRequestHandler(Z9,async()=>{return{tools:l5}}),Y.setRequestHandler(F4,async(X,W)=>{let{name:G,arguments:$}=X.params;return c5(W,Q,()=>m5(G,$??{}))}),Y.setRequestHandler(D9,async()=>{return{resources:S5}}),Y.setRequestHandler(q9,async(X,W)=>{let{uri:G}=X.params;return c5(W,Q,()=>R5(G))}),Y}import i5 from"node:process";class iY{append(Q){this._buffer=this._buffer?Buffer.concat([this._buffer,Q]):Q}readMessage(){if(!this._buffer)return null;let Q=this._buffer.indexOf(`
|
|
186
|
-
`);if(Q===-1)return null;let Y=this._buffer.toString("utf8",0,Q).replace(/\r$/,"");return this._buffer=this._buffer.subarray(Q+1),
|
|
187
|
-
`}class nY{constructor(Q=i5.stdin,Y=i5.stdout){this._stdin=Q,this._stdout=Y,this._readBuffer=new iY,this._started=!1,this._ondata=(X)=>{this._readBuffer.append(X),this.processReadBuffer()},this._onerror=(X)=>{this.onerror?.(X)}}async start(){if(this._started)throw Error("StdioServerTransport already started! If using Server class, note that connect() calls start() automatically.");this._started=!0,this._stdin.on("data",this._ondata),this._stdin.on("error",this._onerror)}processReadBuffer(){while(!0)try{let Q=this._readBuffer.readMessage();if(Q===null)break;this.onmessage?.(Q)}catch(Q){this.onerror?.(Q)}}async close(){if(this._stdin.off("data",this._ondata),this._stdin.off("error",this._onerror),this._stdin.listenerCount("data")===0)this._stdin.pause();this._readBuffer.clear(),this.onclose?.()}send(Q){return new Promise((Y)=>{let X=p5(Q);if(this._stdout.write(X))Y();else this._stdout.once("drain",Y)})}}async function
|
|
186
|
+
- contact.subscribed, contact.unsubscribed`,inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID to create the sequence in. If not provided, uses the currently selected company."},name:{type:"string",description:"Sequence name (e.g., 'User Onboarding', 'Welcome Series')"},trigger:{type:"string",enum:["contact_added","tag_added","segment_entered","event_received","inactivity","frequency"],description:"Trigger type: 'contact_added' (when added to a list), 'tag_added' (when tag is applied), 'segment_entered' (when a contact newly enters a saved segment), 'event_received' (when custom event fires), 'inactivity' (when subscriber hasn't performed an event for X days), 'frequency' (when subscriber performs event X times in Y days)"},listId:{type:"string",description:"List ID to trigger on (for contact_added trigger). If not provided, triggers on any list."},tagName:{type:"string",description:"Tag name to trigger on (required for tag_added trigger)"},segmentId:{type:"string",description:"Segment ID to trigger on (required for segment_entered trigger). Use list_segments first to choose a saved segment."},eventName:{type:"string",description:"Event name to trigger on (required for event_received, inactivity, and frequency triggers)"},propertyFilters:{type:"array",description:"Optional event property filters for event_received triggers. The sequence only starts when the triggering event's properties match ALL filters. Use a dot-path into the event properties; use [] to match inside arrays. Examples: scope a purchase sequence to one product with { path: 'lineItems[].providerProductId', operator: 'equals', value: 'prod_123' } (ecommerce.order_placed) or { path: 'productIds', operator: 'equals', value: 'prod_123' } (saas.purchase); to match any of several products use { path: 'lineItems[].providerProductId', operator: 'one_of', value: ['prod_123', 'prod_456'] }. Max 10 filters.",items:{type:"object",properties:{path:{type:"string",description:"Dot-path into the event properties, e.g. 'lineItems[].providerProductId' or 'plan'."},operator:{type:"string",enum:["exists","not_exists","equals","not_equals","one_of","contains","greater_than","less_than"],description:"Comparison operator. one_of matches when the property equals any entry of the value array."},value:{type:["string","number","boolean","array"],items:{type:["string","number"]},maxItems:50,description:"Value to compare against. Required for every operator except exists/not_exists. For one_of, pass an array of strings or numbers (max 50 values); all other operators take a single value."}},required:["path","operator"]}},inactiveDays:{type:"number",description:"Number of days of inactivity (required for inactivity trigger, must be >= 1)"},inactivityBaseline:{type:"string",enum:["sequence_created_at","subscriber_created_at"],description:"When to start counting inactivity for subscribers who never had the event. Defaults to sequence_created_at."},minCount:{type:"number",description:"Minimum event count (required for frequency trigger, must be >= 1)"},timeWindowDays:{type:"number",description:"Time window in days for frequency trigger (required for frequency trigger, must be >= 1)"},emailCount:{type:"number",description:"Number of emails in the sequence (default: 5, max: 10)"},goal:{type:"string",description:"What this sequence should accomplish for AI generation. Be specific to the app's actual features and user journey. Avoid generic goals that don't match the app's business model."},enrollmentMode:{type:"string",enum:["unlimited","one_time","matching_field"],description:"Sequence re-entry mode. Use 'matching_field' only for event_received triggers when duplicate active runs should be blocked per event field value."},enrollmentFieldPath:{type:"string",description:"Dot-path event property used by enrollmentMode='matching_field', such as 'order.id' or 'product.providerVariantId'. Leave omitted for Shopify back-in-stock/replenishment product-variant defaults."},stopCondition:{type:"object",description:"Optional explicit auto-stop condition. Use { type: 'has_tag', value: 'customer' } to end the sequence when a subscriber gets a tag, { type: 'does_not_have_tag', value: 'trial' } when a tag is removed, { type: 'removed_from_list', value: 'list_123' } when they leave a list, { type: 'event_received', value: 'onboarding.completed' } when an event is tracked, or { type: 'none', value: null } for no auto-stop.",properties:{type:{type:"string",enum:["none","has_tag","does_not_have_tag","added_to_list","removed_from_list","event_received"],description:"Stop condition type."},value:{type:["string","null"],description:"Tag name, list ID, or event name for the stop condition. Use null or omit for type 'none'."}},required:["type"]},steps:{type:"array",description:"Explicit sequence steps. Omit type for email steps, or use type: 'create_discount' for a Stripe discount action. Later email steps can reference the most recent discount with {{discount.code}}, {{discount.percentOff}}, {{discount.amountOff}}, and {{discount.expiresAt}}.",items:{type:"object",properties:{type:{type:"string",enum:["email","create_discount","discount"],description:"Step type. Omit or use 'email' for email content. Use 'create_discount' to generate a discount code before later emails."},subject:{type:"string",description:"Email subject. Required for email steps."},previewText:{type:"string",description:"Email preview text."},blocks:{type:"array",description:u5,items:{type:"object"}},html:{type:"string",description:"HTML content for email steps. Will be converted to Sequenzy blocks."},delay:{type:"object",description:"Delay before this step.",properties:{days:{type:"number"},hours:{type:"number"},minutes:{type:"number"}}},name:{type:"string",description:"Email template name for email steps."},discount:{type:"object",description:"Discount configuration for create_discount steps. Prefer this nested shape for new integrations; legacy top-level discount fields are still accepted.",properties:{label:{type:"string",description:"Builder label for the discount step."},provider:{type:"string",enum:["stripe"],description:"Discount provider. Currently only 'stripe'."},discountType:{type:"string",enum:["percent","amount"],description:"Discount type."},percentOff:{type:"number",description:"Percent discount from 1 to 100. Required when discountType is percent."},amountOff:{type:"number",description:"Fixed amount discount in the smallest currency unit, for example 500 for $5. Required when discountType is amount."},currency:{type:"string",description:"ISO currency for amount discounts. Defaults to usd."},duration:{type:"string",enum:["once","forever","repeating"],description:"Stripe coupon duration. Defaults to once."},durationInMonths:{type:"number",description:"Required for repeating discounts."},appliesToAllPlans:{type:"boolean",description:"Whether the discount applies to all plans. Defaults to true."},planIds:{type:"array",description:"Stripe product IDs, such as prod_abc123, when appliesToAllPlans is false.",items:{type:"string"}},codePrefix:{type:"string",description:"Optional prefix for generated promotion codes."},maxRedemptions:{type:"number",description:"Maximum promotion code redemptions. Use 1 for subscriber-specific codes."},lockToSubscriber:{type:"boolean",description:"Stripe-only. Restrict each generated promotion code to the matched subscriber's Stripe customer."},expiresAt:{type:"string",description:"Optional future expiration date or ISO timestamp."},expiresInHours:{type:"number",description:"Optional relative expiration in hours, resolved when each subscriber's code is created (e.g., 48 for a 48-hour window per subscriber). Takes precedence over expiresAt."},name:{type:"string",description:"Optional provider coupon name."}}},label:{type:"string",description:"Legacy top-level discount label. Prefer discount.label."},provider:{type:"string",enum:["stripe"],description:"Legacy top-level discount provider. Prefer discount.provider."},discountType:{type:"string",enum:["percent","amount"],description:"Legacy top-level discount type. Prefer discount.discountType."},percentOff:{type:"number",description:"Percent discount from 1 to 100. Required when discountType is percent."},amountOff:{type:"number",description:"Fixed amount discount in the smallest currency unit, for example 500 for $5. Required when discountType is amount."},currency:{type:"string",description:"ISO currency for amount discounts. Defaults to usd."},duration:{type:"string",enum:["once","forever","repeating"],description:"Stripe coupon duration. Defaults to once."},durationInMonths:{type:"number",description:"Required for repeating discounts."},appliesToAllPlans:{type:"boolean",description:"Whether the discount applies to all plans. Defaults to true."},planIds:{type:"array",description:"Stripe product IDs, such as prod_abc123, when appliesToAllPlans is false.",items:{type:"string"}},codePrefix:{type:"string",description:"Optional prefix for generated promotion codes."},maxRedemptions:{type:"number",description:"Maximum promotion code redemptions. Use 1 for subscriber-specific codes."},lockToSubscriber:{type:"boolean",description:"Legacy top-level Stripe-only flag. Prefer discount.lockToSubscriber."},expiresAt:{type:"string",description:"Optional future expiration date or ISO timestamp."},expiresInHours:{type:"number",description:"Optional relative expiration in hours, resolved when each subscriber's code is created (e.g., 48 for a 48-hour window per subscriber). Takes precedence over expiresAt."}}}}},required:["name","trigger"]}},{name:"update_sequence",description:"Update an existing sequence. To target a specific step, use the emailId or nodeId returned in get_sequence.sequence.emails. You can also update enrollmentMode and enrollmentFieldPath for event-triggered matching-field enrollment. When inserting an if/else branch, include steps for every branch arm and elseSteps so the branch is usable immediately. Branch conditions support tags, lists, saved segments, custom events, clicked links, and subscriber field comparisons.",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},sequenceId:{type:"string",description:"Sequence ID"},name:{type:"string",description:"Sequence name"},enrollmentMode:{type:"string",enum:["unlimited","one_time","matching_field"],description:"Updated sequence re-entry mode. 'matching_field' is only valid for event-based sequence triggers."},enrollmentFieldPath:{type:"string",description:"Dot-path event property used by enrollmentMode='matching_field', such as 'order.id' or 'product.providerVariantId'. Omit to leave unchanged. Use clearEnrollmentFieldPath to clear it."},clearEnrollmentFieldPath:{type:"boolean",description:"Set true to clear enrollmentFieldPath without sending a nullable schema value."},stopCondition:{type:"object",description:"Update the sequence auto-stop condition. Example: { type: 'has_tag', value: 'customer' } ends the sequence when the subscriber has that tag. Use { type: 'removed_from_list', value: 'list_123' } to stop when they leave a list, or { type: 'none', value: null } to clear it.",properties:{type:{type:"string",enum:["none","has_tag","does_not_have_tag","added_to_list","removed_from_list","event_received"]},value:{type:["string","null"],description:"Tag name, list ID, or event name for the stop condition."}},required:["type"]},branch:{type:"object",description:"Insert an if/else branch into an existing sequence. The branch is inserted after afterNodeId and creates an if path plus an else fallback path. Use get_sequence first to choose afterNodeId. Each branch condition should include steps, and elseSteps is required unless allowEmptyPaths is true. Conditions support tags, lists, saved segments, events, clicked links, and field comparisons. Use activityScope for event_received and link_clicked checks.",properties:{afterNodeId:{type:"string",description:"Existing node ID to insert the branch after. Use a nodeId from get_sequence.sequence.nodes or get_sequence.sequence.emails."},label:{type:"string",description:"Optional branch node label."},branches:{type:"array",description:"Conditional branches evaluated in order. An else fallback is created automatically.",items:{type:"object",properties:{id:{type:"string",description:"Optional stable branch ID. Defaults to branch-0, branch-1, etc."},label:{type:"string",description:"Display label, e.g. 'If has customer tag'."},conditionType:{type:"string",enum:["has_tag","in_list","in_segment","event_received","link_clicked","field_equals","field_contains","field_greater_than","field_less_than"],description:"Condition type for this branch."},tagName:{type:"string",description:"Tag name for has_tag conditions. This can be used instead of tagId."},tagId:{type:"string",description:"Tag ID or tag name for has_tag conditions."},listId:{type:"string",description:"List ID for in_list conditions."},segmentId:{type:"string",description:"Segment ID for in_segment conditions."},segmentName:{type:"string",description:"Optional display name for in_segment conditions."},eventName:{type:"string",description:"Event name for event_received conditions, such as project.invite.accepted."},linkUrl:{type:"string",description:"Optional URL substring for link_clicked conditions. Omit to match any clicked link."},activityScope:{type:"string",enum:["ever","this_sequence","previous_email"],description:"Scope for event_received and link_clicked conditions. Omit to check ever."},fieldName:{type:"string",description:"Subscriber attribute name for field conditions."},fieldValue:{type:"string",description:"Comparison value for field conditions."},steps:{type:"array",description:"Steps to create inside this branch path. Required by default so the branch is not an empty placeholder.",items:_5}},required:["conditionType"]}},elseSteps:{type:"array",description:"Steps to create inside the else fallback path. Required by default so the else arm is usable.",items:_5},allowEmptyPaths:{type:"boolean",description:"Set true only when intentionally creating empty UI placeholders. Normal API/MCP use should omit this and provide branch steps plus elseSteps."}},required:["afterNodeId","branches"]},emails:{type:"array",description:"Updated sequence emails. If you omit emailId/nodeId, items are matched by existing step order.",items:{type:"object",properties:{emailId:{type:"string",description:"Optional target linked email template ID for a step. Use the emailId returned in get_sequence.sequence.emails."},nodeId:{type:"string",description:"Optional target action_email node ID for a step. Use the nodeId returned in get_sequence.sequence.emails."},name:{type:"string",description:"Updated step/template name"},subject:{type:"string",description:"Updated email subject"},previewText:{type:"string",description:"Updated preview text"},html:{type:"string",description:"Updated HTML content. Will be converted to Sequenzy blocks."},htmlContent:{type:"string",description:"Alias for html. Use this when updating HTML content for a step."},blocks:{type:"array",description:i1,items:{type:"object"}}}}},steps:{type:"array",description:"Alias for emails. Supports the same fields and matching rules.",items:{type:"object",properties:{emailId:{type:"string",description:"Optional target linked email template ID for a step. Use the emailId returned in get_sequence.sequence.emails."},nodeId:{type:"string",description:"Optional target action_email node ID for a step. Use the nodeId returned in get_sequence.sequence.emails."},name:{type:"string",description:"Updated step/template name"},subject:{type:"string",description:"Updated email subject"},previewText:{type:"string",description:"Updated preview text"},html:{type:"string",description:"Updated HTML content. Will be converted to Sequenzy blocks."},htmlContent:{type:"string",description:"Alias for html. Use this when updating HTML content for a step."},blocks:{type:"array",description:i1,items:{type:"object"}}}}}},required:["sequenceId"]}},{name:"enable_sequence",description:"Enable/activate a sequence. IMPORTANT: Only call this when the user EXPLICITLY asks to enable or activate a sequence. Never enable sequences automatically after creation - the user must review the content first.",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},sequenceId:{type:"string",description:"Sequence ID"}},required:["sequenceId"]}},{name:"disable_sequence",description:"Disable/pause a sequence",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},sequenceId:{type:"string",description:"Sequence ID"}},required:["sequenceId"]}},{name:"enroll_subscribers_in_sequence",description:"Manually enroll subscribers in a sequence by email address. Maximum 500 emails per call. Only active subscribers are enrolled: unknown emails are returned in `notFound`, while inactive subscribers and subscribers already actively enrolled in the sequence are counted in `skipped`. By default enrollment starts at the first step after the trigger; pass targetNodeId to start at a specific step.",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},sequenceId:{type:"string",description:"Sequence ID to enroll subscribers in."},emails:{type:"array",items:{type:"string"},description:"Email addresses of subscribers to enroll. Maximum 500 per call."},targetNodeId:{type:"string",description:"Optional node ID to start enrollment at. Use a non-trigger nodeId from get_sequence. Defaults to the first step after the trigger."}},required:["sequenceId","emails"]}},{name:"cancel_sequence_enrollments",description:"Cancel active/waiting enrollments in one sequence. Provide sequenceId and exactly one target: subscriberId for one subscriber, or fieldValues to match stored entry event properties. For fieldValues, fieldPath is optional when the sequence has enrollmentFieldPath configured; otherwise provide a dot path such as order.id.",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},sequenceId:{type:"string",description:"Sequence ID whose enrollments should be cancelled."},subscriberId:{type:"string",description:"Subscriber ID to cancel in this sequence. Provide subscriberId or fieldValues, not both."},fieldPath:{type:"string",description:"Dot-path inside the token's stored entry event properties, such as order.id or event.id. Optional when the sequence has enrollmentFieldPath configured."},fieldValues:{type:"array",items:{type:"string"},description:"Entry field values to match. Cancels all active/waiting enrollments in the sequence whose entry field value is in this list. Provide fieldValues or subscriberId, not both."},dryRun:{type:"boolean",description:"When true, returns matching enrollments without cancelling them. Field-value cancellation defaults to dryRun on the API unless explicitly false."},reason:{type:"string",description:"Optional cancellation reason stored on matched enrollment tokens."}},required:["sequenceId"],additionalProperties:!1}},{name:"delete_sequence",description:"Delete a sequence",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},sequenceId:{type:"string",description:"Sequence ID"}},required:["sequenceId"]}},{name:"list_transactional_emails",description:"List transactional email templates, including their API slugs and linked email IDs",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."}}}},{name:"get_transactional_email",description:"Get a transactional email by ID or slug, including subject, preview text, blocks, variables, and linked dashboard URLs",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},idOrSlug:{type:"string",description:"Transactional email ID or API slug, for example `welcome-email`."}},required:["idOrSlug"]}},{name:"create_transactional_email",description:"Create a saved transactional email template with an API slug. Provide `prompt` to generate the email with AI, or provide either `html` or Sequenzy `blocks` for the email body.",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},name:{type:"string",description:"Transactional email name."},slug:{type:"string",description:"Optional API slug used when sending by slug, for example `password-reset`. If omitted, Sequenzy generates one from the name."},subject:{type:"string",description:"Email subject line. Optional when `prompt` is provided because the generated subject will be used."},previewText:{type:["string","null"],description:"Email preview text."},html:{type:"string",description:"Email HTML content. Mutually exclusive with `blocks`."},blocks:{type:"array",description:`${m6} Mutually exclusive with \`html\`.`,items:{type:"object"}},prompt:{type:"string",description:"Generate transactional email blocks from a prompt. Mutually exclusive with `html` and `blocks`."},style:{type:"string",description:"Prompt generation style: minimal, branded, promotional. Only used with `prompt`."},tone:{type:"string",description:"Prompt generation tone: professional, casual, friendly. Only used with `prompt`."},enabled:{type:"boolean",description:"Whether this transactional email can be sent immediately. Defaults to true."}},required:["name"],additionalProperties:!1}},{name:"update_transactional_email",description:"Update a transactional email by ID or slug. At least one of `name`, `enabled`, `subject`, `previewText`, `html`, or `blocks` is required. Use `html` or `blocks` to replace the linked email body.",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},idOrSlug:{type:"string",description:"Transactional email ID or API slug, for example `welcome-email`."},name:{type:"string",description:"Transactional email name."},enabled:{type:"boolean",description:"Whether this transactional email can be sent."},subject:{type:"string",description:"Email subject line."},previewText:{type:["string","null"],description:"Email preview text."},html:{type:"string",description:"Email HTML content. Mutually exclusive with `blocks`."},blocks:{type:"array",description:`${i1} Mutually exclusive with \`html\`.`,items:{type:"object"}}},required:["idOrSlug"],additionalProperties:!1}},{name:"send_email",description:"Send a transactional email to a single recipient",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},to:{type:"string",description:"Recipient email address"},subject:{type:"string",description:"Email subject (required if not using templateId)"},html:{type:"string",description:"Email HTML content (required if not using templateId)"},templateId:{type:"string",description:"Template ID to use (alternative to html)"},variables:{type:"object",description:"Variables for template personalization. Nested objects and arrays are supported for repeat blocks, for example { items: [...] }."},subscriberExternalId:{type:"string",description:"Customer-owned subscriber ID for attaching analytics/localization on single-recipient sends."}},required:["to"]}},{name:"get_stats",description:"Get overview statistics for a time period",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},period:{type:"string",description:"Time period: 7d, 30d, or 90d (default: 7d)"}}}},{name:"get_campaign_stats",description:"Get detailed statistics for a campaign, including attributed conversions and revenue (revenueCents)",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},campaignId:{type:"string",description:"Campaign ID"}},required:["campaignId"]}},{name:"get_sequence_stats",description:"Get statistics for a sequence, including attributed conversions and revenue (revenueCents) plus per-step failed subscribers and failure reasons",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},sequenceId:{type:"string",description:"Sequence ID"}},required:["sequenceId"]}},{name:"get_subscriber_activity",description:"Get recent activity, email stats, and current sequence enrollments for a subscriber",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},email:{type:"string",description:"Subscriber email address. Provide email or externalId to identify the subscriber."},externalId:{type:"string",description:"Customer-owned subscriber ID. Provide email or externalId to identify the subscriber."}},required:[]}},{name:"list_team_members",description:"List team members for the company, including the owner, members with their roles, and pending or expired invitations.",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."}}}},{name:"invite_team_member",description:"Invite a team member by email with role admin or viewer. Existing Sequenzy users are added to the team immediately; others receive an email invitation. Billing access (canManageBilling) can only be granted by the company owner.",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},email:{type:"string",description:"Email address of the person to invite."},role:{type:"string",enum:["admin","viewer"],description:"Team role. Admins can manage the workspace; viewers have read-only access."},canManageBilling:{type:"boolean",description:"Whether the member can manage billing. Only the company owner can grant billing access. Defaults to false."}},required:["email","role"]}},{name:"cancel_team_invitation",description:"Cancel a pending team invitation. Invitations that have already been accepted cannot be cancelled.",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},invitationId:{type:"string",description:"Invitation ID to cancel. Use list_team_members to find pending invitations."}},required:["invitationId"]}},{name:"list_conversations",description:"List inbox conversations (email replies from subscribers). Filter by status, free-text search, or unread state, with pagination.",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},status:{type:"string",enum:["open","closed","all"],description:"Filter by conversation status. Defaults to all."},search:{type:"string",description:"Free-text search across conversation subjects and participants."},unread:{type:"boolean",description:"Set true to only return conversations with unread messages."},page:{type:"number",description:"Page number. Defaults to 1."},limit:{type:"number",description:"Results per page, from 1 to 100. Defaults to 20."}}}},{name:"get_conversation",description:"Get a conversation with its full message history, subscriber details, and context.",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},conversationId:{type:"string",description:"Conversation ID."}},required:["conversationId"]}},{name:"reply_to_conversation",description:"Send a reply in a conversation, or add an internal note. type 'outbound' (default) emails the subscriber and requires bodyText or bodyHtml; type 'note' adds a private team-only note. Replying to a closed conversation reopens it.",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},conversationId:{type:"string",description:"Conversation ID to reply in."},type:{type:"string",enum:["outbound","note"],description:"Message type: outbound emails the subscriber, note is internal-only. Defaults to outbound."},subject:{type:"string",description:"Optional subject override. Defaults to the conversation subject."},bodyText:{type:"string",description:"Plain-text message body."},bodyHtml:{type:"string",description:"HTML message body."}},required:["conversationId"]}},{name:"update_conversation_status",description:"Open or close a conversation.",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},conversationId:{type:"string",description:"Conversation ID."},status:{type:"string",enum:["open","closed"],description:"New conversation status."}},required:["conversationId","status"]}},{name:"mark_conversation_read",description:"Mark all unread inbound messages in a conversation as read.",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},conversationId:{type:"string",description:"Conversation ID."}},required:["conversationId"]}},{name:"list_webhooks",description:"List outbound webhook endpoints and their subscribed event types.",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."}}}},{name:"create_webhook",description:"Create an outbound webhook endpoint. IMPORTANT: the response includes a signingSecret that is returned only once - show it to the user immediately so they can store it and verify webhook signatures. If events is omitted, a default set of event types is subscribed.",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},name:{type:"string",description:"Webhook endpoint name."},url:{type:"string",description:"HTTPS URL that will receive webhook events."},events:{type:"array",items:{type:"string",enum:[...FQ]},description:"Event types to subscribe to. If omitted, a default set is used."}},required:["name","url"]}},{name:"update_webhook",description:"Update an outbound webhook endpoint's name, URL, subscribed events, or status (enabled/disabled). Providing events replaces the existing event list.",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},webhookId:{type:"string",description:"Webhook endpoint ID."},name:{type:"string",description:"New webhook endpoint name."},url:{type:"string",description:"New HTTPS URL that will receive webhook events."},events:{type:"array",items:{type:"string",enum:[...FQ]},description:"Replacement event type subscriptions."},status:{type:"string",enum:["enabled","disabled"],description:"Enable or disable deliveries to this endpoint."}},required:["webhookId"]}},{name:"delete_webhook",description:"Permanently delete an outbound webhook endpoint along with its delivery history. This cannot be undone. To keep the endpoint but stop deliveries, use update_webhook with status disabled instead.",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},webhookId:{type:"string",description:"Webhook endpoint ID to delete."}},required:["webhookId"]}},{name:"test_webhook",description:"Send a test event to an outbound webhook endpoint to verify it is reachable and signatures can be validated.",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},webhookId:{type:"string",description:"Webhook endpoint ID to test."}},required:["webhookId"]}},{name:"list_webhook_deliveries",description:"List recent delivery attempts for an outbound webhook endpoint, including status and response codes.",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},webhookId:{type:"string",description:"Webhook endpoint ID."},limit:{type:"number",description:"Maximum number of deliveries to return, from 1 to 100. Defaults to 20."}},required:["webhookId"]}},{name:"replay_webhook_delivery",description:"Replay a previous webhook delivery, re-sending the same event payload to the endpoint.",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},webhookId:{type:"string",description:"Webhook endpoint ID."},deliveryId:{type:"string",description:"Delivery ID to replay. Use list_webhook_deliveries to find delivery IDs."}},required:["webhookId","deliveryId"]}},{name:"generate_email",description:"Generate email blocks from a prompt",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},prompt:{type:"string",description:"Description of the email to generate"},style:{type:"string",description:"Style: minimal, branded, promotional"},tone:{type:"string",description:"Tone: professional, casual, friendly"}},required:["prompt"]}},{name:"generate_sequence",description:"[DEPRECATED - Use create_sequence instead] Generate a multi-email sequence from a goal. Note: create_sequence now handles AI generation automatically.",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},goal:{type:"string",description:"Goal of the sequence (e.g., 'onboard new SaaS trial users')"},emailCount:{type:"number",description:"Number of emails in the sequence (default: 5, max: 10)"},durationDays:{type:"number",description:"Total duration in days (default: 14)"}},required:["goal"]}},{name:"generate_subject_lines",description:"Generate A/B test subject line variants",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},topic:{type:"string",description:"Topic or context for the subject lines"},count:{type:"number",description:"Number of variants to generate (default: 5)"}},required:["topic"]}}];async function m5(Q,Y){try{let X;switch(Q){case"get_account":{let G=await F("GET","/api/v1/account"),$=Q1();X={...G,selectedCompanyId:$??G.currentCompanyId};break}case"select_company":{let G=Y.companyId,$=await F("GET","/api/v1/account"),J=$.companies?.find((z)=>z.id===G);if(!J)throw Error(`Company not found. Available companies: ${$.companies?.map((z)=>`${z.name} (${z.id})`).join(", ")??"none"}`);n6(G),X={success:!0,message:`Switched to company: ${J.name}`,companyId:J.id,companyName:J.name};break}case"get_app_urls":{let G=await h5(Y);X={...q1({companyId:G,campaignId:N(Y,"campaignId"),sequenceId:N(Y,"sequenceId"),emailId:N(Y,"emailId")??N(Y,"templateId"),transactionalId:N(Y,"transactionalId"),emailSendId:N(Y,"emailSendId"),domainId:N(Y,"domainId"),status:N(Y,"status"),settingsTab:N(Y,"settingsTab")}),...G===void 0&&{note:"No company ID is selected. Call get_account, select_company, or pass companyId to get concrete dashboard URLs."}};break}case"create_company":{let G=await F("POST","/api/v1/companies",{name:Y.name,domain:Y.domain});if(!G.success)throw Error("Failed to create company");let $=G.company.id,J=6,z=0,H=G.company.status;while(H==="processing"&&z<J){await new Promise((B)=>setTimeout(B,20000)),z++;let A=await F("GET",`/api/v1/companies/${$}`);if(A.success)H=A.company.status}n6($);let U=await F("GET",`/api/v1/companies/${$}`);X={success:!0,company:U.company,message:H==="processing"?"Company created but still processing. You can continue using it while processing completes.":`Company '${U.company.name}' created and ready to use.`,autoSelected:!0};break}case"get_company":{let G=Y.companyId;X=await F("GET",`/api/v1/companies/${G}`);break}case"create_api_key":{let G=Y.companyId;X=await F("POST","/api/v1/api-keys",{name:Y.name},G);break}case"list_websites":{let G=Y.companyId;X=await F("GET","/api/v1/websites",void 0,G);break}case"add_website":{let G=Y.companyId;X=await F("POST","/api/v1/websites",{domain:Y.domain},G);break}case"check_website":{let G=Y.companyId;X=await F("GET",`/api/v1/websites/${Y.domain}`,void 0,G);break}case"get_integration_guide":X=await F("POST","/api/v1/integration-guide",Y);break;case"add_subscriber":{let G=Y.companyId,$=c6("add_subscriber",Y);X=await F("POST","/api/v1/subscribers",{...$,customAttributes:Y.attributes,tags:Y.tags,lists:Y.listIds,...Y.status!==void 0&&{status:Y.status},...Y.optInMode!==void 0&&{optInMode:Y.optInMode}},G);break}case"update_subscriber":{let G=Y.companyId,$=c6("update_subscriber",Y),J=await _Y($,G),z=Array.isArray(J.subscriber.tags)?J.subscriber.tags.filter((K)=>typeof K==="string"):[],H=Array.isArray(Y.addTags)?Y.addTags.filter((K)=>typeof K==="string"&&K.trim()!=="").map(y5):[],U=new Set(Array.isArray(Y.removeTags)?Y.removeTags.filter((K)=>typeof K==="string"&&K.trim()!=="").map(y5):[]),A=z.filter((K)=>!U.has(K));for(let K of H)if(!A.includes(K))A.push(K);let B={};if($.email&&$.externalId)B.externalId=$.externalId;if(B0(Y.attributes))B.customAttributes={...B0(J.subscriber.customAttributes)?J.subscriber.customAttributes:{},...Y.attributes};if(Y.addTags||Y.removeTags)B.tags=A;X=await F("PATCH",lY($),B,G);break}case"remove_subscriber":{let G=Y.companyId,$=c6("remove_subscriber",Y),J=lY($);if(Y.hardDelete===!0)X=await F("DELETE",J,void 0,G);else X=await F("PATCH",J,{status:"unsubscribed"},G);break}case"get_subscriber":{let G=Y.companyId,$=c6("get_subscriber",Y);X=await _Y($,G);break}case"search_subscribers":{let G=Y.companyId;X=await JV(Y,G);break}case"list_products":{let G=Y.companyId,$=new URLSearchParams;if(typeof Y.provider==="string"&&Y.provider.trim())$.set("provider",Y.provider.trim());if(typeof Y.search==="string"&&Y.search.trim())$.set("search",Y.search.trim());let J=$.size>0?`?${$.toString()}`:"";X=await F("GET",`/api/v1/products${J}`,void 0,G);break}case"upsert_products":{let G=Y.companyId;if(!Array.isArray(Y.products)||Y.products.length===0)throw Error("`products` must be a non-empty array when calling `upsert_products`.");X=await F("POST","/api/v1/products",{products:Y.products},G);break}case"delete_product":{let G=Y.companyId,$=x("delete_product",Y,"productId");X=await F("DELETE",`/api/v1/products/${encodeURIComponent($)}`,void 0,G);break}case"attach_product_file":{let G=Y.companyId,$=x("attach_product_file",Y,"productId"),J=N(Y,"url"),z=N(Y,"filePath");if(J===void 0===(z===void 0))throw Error("Provide either `url` or `filePath` (not both) when calling `attach_product_file`.");let H;if(z!==void 0){let U=await BV(z,G);H={url:U.url,source:"upload",fileName:N(Y,"fileName")??U.fileName,fileSizeBytes:U.fileSizeBytes,mimeType:U.mimeType}}else{H={url:J};let U=N(Y,"fileName");if(U)H.fileName=U}X=await F("PUT",`/api/v1/products/${encodeURIComponent($)}/delivery`,H,G);break}case"remove_product_file":{let G=Y.companyId,$=x("remove_product_file",Y,"productId");X=await F("DELETE",`/api/v1/products/${encodeURIComponent($)}/delivery`,void 0,G);break}case"sync_products":{let G=Y.companyId;X=await F("POST","/api/v1/products/sync",void 0,G);break}case"list_tags":{let G=Y.companyId;X=await F("GET","/api/v1/tags",void 0,G);break}case"create_tag":{let G=Y.companyId,$=x("create_tag",Y,"name"),J=s0("create_tag",Y,"color",qQ);X=await F("POST","/api/v1/tags",{name:$,...J!==void 0&&{color:J}},G);break}case"update_tag":{let G=Y.companyId,$=x("update_tag",Y,"tagId"),J=yY("update_tag",Y,"color",qQ);X=await F("PATCH",`/api/v1/tags/${encodeURIComponent($)}`,{color:J},G);break}case"delete_tag":{let G=Y.companyId,$=x("delete_tag",Y,"tagId");X=await F("DELETE",`/api/v1/tags/${encodeURIComponent($)}`,void 0,G);break}case"list_lists":{let G=Y.companyId;X=await F("GET","/api/v1/lists",void 0,G);break}case"create_list":{let G=Y.companyId;X=await F("POST","/api/v1/lists",Y,G);break}case"update_list":{let G=Y.companyId,$=x("update_list",Y,"listId");if(Y.name===void 0&&Y.description===void 0&&Y.isPrivate===void 0)throw Error("Provide at least one of `name`, `description`, or `isPrivate` when calling `update_list`.");if(Y.name!==void 0&&N(Y,"name")===void 0)throw Error("`name` cannot be empty when calling `update_list`.");if(Y.description!==void 0&&Y.description!==null&&typeof Y.description!=="string")throw Error("`description` must be a string or null when calling `update_list`.");if(Y.isPrivate!==void 0&&typeof Y.isPrivate!=="boolean")throw Error("`isPrivate` must be a boolean when calling `update_list`.");X=await F("PATCH",`/api/v1/lists/${encodeURIComponent($)}`,{...Y.name!==void 0&&{name:N(Y,"name")},...Y.description!==void 0&&{description:Y.description},...Y.isPrivate!==void 0&&{isPrivate:Y.isPrivate}},G);break}case"delete_list":{let G=Y.companyId,$=x("delete_list",Y,"listId");X=await F("DELETE",`/api/v1/lists/${encodeURIComponent($)}`,void 0,G);break}case"add_subscribers_to_list":{let G=Y.companyId,$=x("add_subscribers_to_list",Y,"listId"),J=gY("add_subscribers_to_list",Y),z=s0("add_subscribers_to_list",Y,"duplicateStrategy",["skip","merge","overwrite"])??"skip",H=s0("add_subscribers_to_list",Y,"optInMode",["default","confirmed","double_opt_in"])??"default";X=await F("POST",`/api/v1/lists/${encodeURIComponent($)}/subscribers`,{emails:J,duplicateStrategy:z,enrollInSequences:Y.enrollInSequences===!0,optInMode:H},G);break}case"remove_subscribers_from_list":{let G=Y.companyId,$=x("remove_subscribers_from_list",Y,"listId"),J=gY("remove_subscribers_from_list",Y);X=await F("POST",`/api/v1/lists/${encodeURIComponent($)}/subscribers/remove`,{emails:J},G);break}case"list_segments":{let G=Y.companyId;X=await F("GET","/api/v1/segments",void 0,G);break}case"create_segment":{aM(Y);let G=Y.companyId;X=await F("POST","/api/v1/segments",{...Y,...Y.filters!==void 0?{filters:hY(Y.filters)}:{},...Y.root!==void 0?{root:fY(Y.root)}:{}},G);break}case"update_segment":{sM(Y);let G=Y.companyId,$=x("update_segment",Y,"segmentId"),J=N(Y,"name"),z=s0("update_segment",Y,"filterJoinOperator",["and","or"]);X=await F("PATCH",`/api/v1/segments/${encodeURIComponent($)}`,{...J!==void 0&&{name:J},...z!==void 0&&{filterJoinOperator:z},...Y.filters!==void 0?{filters:hY(Y.filters)}:{},...Y.root!==void 0?{root:fY(Y.root)}:{}},G);break}case"delete_segment":{let G=Y.companyId,$=x("delete_segment",Y,"segmentId");X=await F("DELETE",`/api/v1/segments/${encodeURIComponent($)}`,void 0,G);break}case"get_segment_count":{let G=Y.companyId;X=await F("GET",`/api/v1/segments/${Y.segmentId}/count`,void 0,G);break}case"list_templates":{let G=Y.companyId,$=new URLSearchParams,J=N(Y,"label");if(J)$.set("label",J);X=await F("GET",`/api/v1/templates${$.size>0?`?${$}`:""}`,void 0,G);break}case"get_template":{let G=Y.companyId;X=await F("GET",`/api/v1/templates/${Y.templateId}`,void 0,G);break}case"create_template":{let G=Y.companyId;P1("create_template",Y,{requireContent:!0}),LQ("create_template",Y),X=await F("POST","/api/v1/templates",Y,G);break}case"update_template":{let G=Y.companyId,$=new Set(["companyId","templateId","name","subject","html","blocks","labels"]),J=Object.keys(Y).filter((z)=>!$.has(z));if(J.length>0)throw Error(`\`update_template\` accepts only \`name\`, \`subject\`, \`html\`, \`blocks\`, and \`labels\` update fields. Unsupported field${J.length===1?"":"s"}: ${J.map((z)=>`\`${z}\``).join(", ")}.`);if(P1("update_template",Y),LQ("update_template",Y),Y.name===void 0&&Y.subject===void 0&&Y.html===void 0&&Y.blocks===void 0&&Y.labels===void 0)throw Error("Provide at least one of `name`, `subject`, `html`, `blocks`, or `labels` when calling `update_template`.");X=await F("PUT",`/api/v1/templates/${Y.templateId}`,Y,G);break}case"delete_template":{let G=Y.companyId;X=await F("DELETE",`/api/v1/templates/${Y.templateId}`,void 0,G);break}case"list_ab_tests":{let G=Y.companyId,$=new URLSearchParams,J=N(Y,"sequenceId");if(J)$.set("sequenceId",J);X=await F("GET",`/api/v1/ab-tests${$.size>0?`?${$}`:""}`,void 0,G);break}case"get_ab_test":{let G=Y.companyId;X=await F("GET",`/api/v1/ab-tests/${Y.abTestId}`,void 0,G);break}case"get_ab_test_stats":{let G=Y.companyId,$=new URLSearchParams,J=N(Y,"period"),z=N(Y,"start"),H=N(Y,"end");if(J)$.set("period",J);if(z)$.set("start",z);if(H)$.set("end",H);X=await F("GET",`/api/v1/ab-tests/${Y.abTestId}/stats${$.size>0?`?${$}`:""}`,void 0,G);break}case"restart_ab_test":{let G=Y.companyId,$=new Set(["companyId","abTestId","sourceVariantId","testType","winnerThreshold","variantCount"]),J=Object.keys(Y).filter((A)=>!$.has(A));if(J.length>0)throw Error(`\`restart_ab_test\` accepts only \`sourceVariantId\`, \`testType\`, \`winnerThreshold\`, and \`variantCount\` option fields. Unsupported field${J.length===1?"":"s"}: ${J.map((A)=>`\`${A}\``).join(", ")}.`);let z=N(Y,"testType");if(z!==void 0&&z!=="subject"&&z!=="content")throw Error("`restart_ab_test` testType must be `subject` or `content`.");let H=Y.winnerThreshold===void 0?void 0:Number(Y.winnerThreshold);if(H!==void 0&&(!Number.isInteger(H)||H<10||H>1000))throw Error("`restart_ab_test` winnerThreshold must be an integer from 10 to 1000.");let U=Y.variantCount===void 0?void 0:Number(Y.variantCount);if(U!==void 0&&(!Number.isInteger(U)||U<2||U>4))throw Error("`restart_ab_test` variantCount must be an integer from 2 to 4.");X=await F("POST",`/api/v1/ab-tests/${Y.abTestId}/restart`,{sourceVariantId:N(Y,"sourceVariantId"),testType:z,winnerThreshold:H,variantCount:U},G);break}case"update_ab_test_variant":{let G=Y.companyId,$=new Set(["companyId","abTestId","variantId","subject","previewText","html","blocks"]),J=Object.keys(Y).filter((z)=>!$.has(z));if(J.length>0)throw Error(`\`update_ab_test_variant\` accepts only \`subject\`, \`previewText\`, \`html\`, and \`blocks\` update fields. Unsupported field${J.length===1?"":"s"}: ${J.map((z)=>`\`${z}\``).join(", ")}.`);if(P1("update_ab_test_variant",Y),Y.subject===void 0&&Y.previewText===void 0&&Y.html===void 0&&Y.blocks===void 0)throw Error("Provide at least one of `subject`, `previewText`, `html`, or `blocks` when calling `update_ab_test_variant`.");X=await F("PATCH",`/api/v1/ab-tests/${Y.abTestId}/variants/${Y.variantId}`,Y,G);break}case"create_ab_test":{let G=Y.companyId,$=x("create_ab_test",Y,"campaignId"),J=N(Y,"name"),z=p6("create_ab_test",Y,"testPercentage",5,50),H=p6("create_ab_test",Y,"testDurationMinutes",15,1440),U=s0("create_ab_test",Y,"winnerCriteria",["open_rate","click_rate"]);if(Y.variants!==void 0){if(!Array.isArray(Y.variants))throw Error("`variants` must be an array when calling `create_ab_test`.");Y.variants.forEach((A,B)=>{if(!B0(A)||typeof A.subject!=="string"||A.subject.trim()==="")throw Error(`\`variants\` item ${B+1} must include a non-empty \`subject\` when calling \`create_ab_test\`.`);if(A.blocks!==void 0&&!Array.isArray(A.blocks))throw Error(`\`variants\` item ${B+1} \`blocks\` must be an array when calling \`create_ab_test\`.`)})}X=await F("POST","/api/v1/ab-tests",{campaignId:$,...J!==void 0&&{name:J},...z!==void 0&&{testPercentage:z},...H!==void 0&&{testDurationMinutes:H},...U!==void 0&&{winnerCriteria:U},...Y.variants!==void 0&&{variants:Y.variants}},G);break}case"add_ab_test_variant":{let G=Y.companyId,$=x("add_ab_test_variant",Y,"abTestId"),J=x("add_ab_test_variant",Y,"subject"),z=N(Y,"previewText");if(Y.blocks!==void 0&&!Array.isArray(Y.blocks))throw Error("`blocks` must be an array when calling `add_ab_test_variant`.");X=await F("POST",`/api/v1/ab-tests/${encodeURIComponent($)}/variants`,{subject:J,...z!==void 0&&{previewText:z},...Y.blocks!==void 0&&{blocks:Y.blocks}},G);break}case"delete_ab_test_variant":{let G=Y.companyId,$=x("delete_ab_test_variant",Y,"abTestId"),J=x("delete_ab_test_variant",Y,"variantId");X=await F("DELETE",`/api/v1/ab-tests/${encodeURIComponent($)}/variants/${encodeURIComponent(J)}`,void 0,G);break}case"delete_ab_test":{let G=Y.companyId,$=x("delete_ab_test",Y,"abTestId");X=await F("DELETE",`/api/v1/ab-tests/${encodeURIComponent($)}`,void 0,G);break}case"list_campaigns":{let G=Y.companyId,$=new URLSearchParams;if(Y.status)$.set("status",String(Y.status));let J=N(Y,"label");if(J)$.set("label",J);X=await F("GET",`/api/v1/campaigns?${$}`,void 0,G);break}case"get_campaign":{let G=Y.companyId;X=await F("GET",`/api/v1/campaigns/${Y.campaignId}`,void 0,G);break}case"get_email_send":{let G=Y.companyId;X=await F("GET",`/api/v1/email-sends/${encodeURIComponent(String(Y.emailSendId))}`,void 0,G);break}case"create_campaign":{let G=Y.companyId;YV(Y);let $=N(Y,"prompt");if($!==void 0){let J=await F("POST","/api/v1/generate/email",{prompt:$,...Y.style!==void 0&&{style:Y.style},...Y.tone!==void 0&&{tone:Y.tone}},G),z=N(Y,"subject")??(typeof J.subject==="string"&&J.subject.trim()!==""?J.subject.trim():void 0);if(!z)throw Error("`create_campaign` prompt generation did not return a subject. Provide `subject` explicitly.");let H=Array.isArray(J.blocks)&&J.blocks.length>0?J.blocks:void 0,U=typeof J.html==="string"&&J.html.trim()!==""?J.html:void 0;if(H===void 0&&U===void 0)throw Error("`create_campaign` prompt generation did not return email blocks. Try again or provide `html` or `blocks` explicitly.");X=await F("POST","/api/v1/campaigns",{name:Y.name,subject:z,...H!==void 0?{blocks:H}:{html:U},...Y.segmentId!==void 0&&{segmentId:Y.segmentId},...Y.trackingCode!==void 0&&{trackingCode:Y.trackingCode},...Y.campaignData!==void 0&&{campaignData:Y.campaignData},...Y.computedLists!==void 0&&{computedLists:Y.computedLists},...Y.labels!==void 0&&{labels:Y.labels}},G);break}X=await F("POST","/api/v1/campaigns",Y,G);break}case"update_campaign":{let G=Y.companyId,$=new Set(["companyId","campaignId","name","subject","trackingCode","html","blocks","replyTo","replyProfileId","campaignData","computedLists","labels"]),J=Object.keys(Y).filter((z)=>!$.has(z));if(J.length>0)throw Error(`\`update_campaign\` accepts only \`name\`, \`subject\`, \`trackingCode\`, \`html\`, \`blocks\`, \`replyTo\`, \`replyProfileId\`, \`campaignData\`, \`computedLists\`, and \`labels\` update fields. Unsupported field${J.length===1?"":"s"}: ${J.map((z)=>`\`${z}\``).join(", ")}.`);if(P1("update_campaign",Y),LQ("update_campaign",Y),Y.replyTo!==void 0&&Y.replyProfileId!==void 0)throw Error("Provide either `replyTo` or `replyProfileId` when calling `update_campaign`, not both.");if(Y.name===void 0&&Y.subject===void 0&&Y.trackingCode===void 0&&Y.html===void 0&&Y.blocks===void 0&&Y.replyTo===void 0&&Y.replyProfileId===void 0&&Y.campaignData===void 0&&Y.computedLists===void 0&&Y.labels===void 0)throw Error("Provide at least one of `name`, `subject`, `trackingCode`, `html`, `blocks`, `replyTo`, `replyProfileId`, `campaignData`, `computedLists`, or `labels` when calling `update_campaign`.");X=await F("PUT",`/api/v1/campaigns/${Y.campaignId}`,Y,G);break}case"schedule_campaign":{let G=Y.companyId,$=new Set(["companyId","campaignId","scheduledAt","targetLists","sendTimeOptimization","spreadOverHours"]),J=Object.keys(Y).filter((z)=>!$.has(z));if(J.length>0)throw Error(`\`schedule_campaign\` accepts only \`campaignId\`, \`scheduledAt\`, \`targetLists\`, \`sendTimeOptimization\`, and \`spreadOverHours\`. Unsupported field${J.length===1?"":"s"}: ${J.map((z)=>`\`${z}\``).join(", ")}.`);XV(Y),X=await F("POST",`/api/v1/campaigns/${Y.campaignId}/schedule`,{scheduledAt:Y.scheduledAt,...Y.targetLists!==void 0&&{targetLists:Y.targetLists},...Y.sendTimeOptimization!==void 0&&{sendTimeOptimization:Y.sendTimeOptimization},...Y.spreadOverHours!==void 0&&{spreadOverHours:Y.spreadOverHours}},G);break}case"send_test_email":{let G=Y.companyId;X=await F("POST",`/api/v1/campaigns/${Y.campaignId}/test`,{to:Y.to},G);break}case"cancel_campaign":{let G=Y.companyId,$=x("cancel_campaign",Y,"campaignId");X=await F("POST",`/api/v1/campaigns/${encodeURIComponent($)}/cancel`,void 0,G);break}case"pause_campaign":{let G=Y.companyId,$=x("pause_campaign",Y,"campaignId");X=await F("POST",`/api/v1/campaigns/${encodeURIComponent($)}/pause`,void 0,G);break}case"resume_campaign":{let G=Y.companyId,$=x("resume_campaign",Y,"campaignId"),J=p6("resume_campaign",Y,"spreadOverHours",1,72);X=await F("POST",`/api/v1/campaigns/${encodeURIComponent($)}/resume`,{...J!==void 0&&{spreadOverHours:J}},G);break}case"delete_campaign":{let G=Y.companyId,$=x("delete_campaign",Y,"campaignId");X=await F("DELETE",`/api/v1/campaigns/${encodeURIComponent($)}`,void 0,G);break}case"duplicate_campaign":{let G=Y.companyId,$=x("duplicate_campaign",Y,"campaignId"),J=s0("duplicate_campaign",Y,"mode",["campaign","ab_test","variant"]),z=N(Y,"variantId");if(J==="variant"&&z===void 0)throw Error("`variantId` is required when calling `duplicate_campaign` with mode `variant`.");X=await F("POST",`/api/v1/campaigns/${encodeURIComponent($)}/duplicate`,{...J!==void 0&&{mode:J},...z!==void 0&&{variantId:z}},G);break}case"list_sequences":{let G=Y.companyId;X=await F("GET","/api/v1/sequences",void 0,G);break}case"get_sequence":{let G=Y.companyId;X=await F("GET",`/api/v1/sequences/${Y.sequenceId}`,void 0,G);break}case"create_sequence":{let G=Y.companyId,$=Array.isArray(Y.steps)&&Y.steps.length>0,J=await F("POST","/api/v1/sequences",Y,G);if(!J.success){X=J;break}let z=J.sequence.id;if($){let K=await F("GET",`/api/v1/sequences/${z}`,void 0,G);if(K.success)X={success:!0,sequence:K.sequence,message:`Sequence "${K.sequence.name}" created with explicit steps. Review it before enabling.`};else X=K;break}let H=6,U=0,A="pending";while(A!=="complete"&&U<H){await new Promise((L)=>setTimeout(L,20000)),U++;let K=await F("GET",`/api/v1/sequences/${z}`,void 0,G);if(K.success)A=K.sequence.enrichmentStatus}let B=await F("GET",`/api/v1/sequences/${z}`,void 0,G);if(B.success)X={success:!0,sequence:B.sequence,message:B.sequence.enrichmentStatus==="complete"?`Sequence "${B.sequence.name}" created with ${B.sequence.emailCount} AI-generated emails. The sequence is ready to review and enable.`:`Sequence "${B.sequence.name}" created. Email enrichment is still in progress (${B.sequence.enrichedCount}/${B.sequence.emailCount} emails generated). You can check status with get_sequence.`};else X=B;break}case"update_sequence":{let G=Y.companyId,$=eM(Y);X=await F("PUT",`/api/v1/sequences/${Y.sequenceId}`,$,G);break}case"enable_sequence":{let G=Y.companyId;X=await F("POST",`/api/v1/sequences/${Y.sequenceId}/enable`,void 0,G);break}case"disable_sequence":{let G=Y.companyId;X=await F("POST",`/api/v1/sequences/${Y.sequenceId}/disable`,void 0,G);break}case"enroll_subscribers_in_sequence":{let G=Y.companyId,$=x("enroll_subscribers_in_sequence",Y,"sequenceId"),J=gY("enroll_subscribers_in_sequence",Y),z=N(Y,"targetNodeId");X=await F("POST",`/api/v1/sequences/${encodeURIComponent($)}/enroll`,{emails:J,...z!==void 0&&{targetNodeId:z}},G);break}case"cancel_sequence_enrollments":{let G=Y.companyId,$=QV(Y);X=await F("POST",`/api/v1/sequences/${Y.sequenceId}/enrollments/cancel`,$,G);break}case"delete_sequence":{let G=Y.companyId;X=await F("DELETE",`/api/v1/sequences/${Y.sequenceId}`,void 0,G);break}case"list_transactional_emails":{let G=Y.companyId;X=await F("GET","/api/v1/transactional",void 0,G);break}case"get_transactional_email":{let G=Y.companyId;X=await F("GET",`/api/v1/transactional/${Y.idOrSlug}`,void 0,G);break}case"create_transactional_email":{let G=Y.companyId,$=new Set(["companyId","name","slug","subject","previewText","html","blocks","prompt","style","tone","enabled"]),J=Object.keys(Y).filter((U)=>!$.has(U));if(J.length>0)throw Error(`\`create_transactional_email\` accepts only \`name\`, \`slug\`, \`subject\`, \`previewText\`, \`html\`, \`blocks\`, \`prompt\`, \`style\`, \`tone\`, and \`enabled\` fields. Unsupported field${J.length===1?"":"s"}: ${J.map((U)=>`\`${U}\``).join(", ")}.`);WV(Y);let z=N(Y,"prompt");if(z!==void 0){let U={companyId:G??Q1()??"",name:typeof Y.name==="string"&&Y.name.trim()!==""?Y.name.trim():"",slug:typeof Y.slug==="string"&&Y.slug.trim()!==""?Y.slug.trim():"",promptLength:z.length,style:typeof Y.style==="string"?Y.style:"",tone:typeof Y.tone==="string"?Y.tone:""};try{console.error("[mcp:create_transactional_email] generating from prompt",U);let A=await F("POST","/api/v1/generate/email",{prompt:z,...Y.style!==void 0&&{style:Y.style},...Y.tone!==void 0&&{tone:Y.tone}},G);console.error("[mcp:create_transactional_email] prompt generation complete",{...U,subject:A.subject??"",previewTextLength:typeof A.previewText==="string"?A.previewText.length:0,blockCount:Array.isArray(A.blocks)?A.blocks.length:0,htmlLength:typeof A.html==="string"?A.html.length:0});let B=N(Y,"subject")??(typeof A.subject==="string"&&A.subject.trim()!==""?A.subject.trim():void 0);if(!B)throw Error("`create_transactional_email` prompt generation did not return a subject. Provide `subject` explicitly.");let K=Array.isArray(A.blocks)&&A.blocks.length>0?A.blocks:void 0,L=typeof A.html==="string"&&A.html.trim()!==""?A.html:void 0,O=N(Y,"previewText")??(typeof A.previewText==="string"?A.previewText.trim():void 0);if(K===void 0&&L===void 0)throw Error("`create_transactional_email` prompt generation did not return email blocks. Try again or provide `html` or `blocks` explicitly.");console.error("[mcp:create_transactional_email] creating generated transactional",{...U,subject:B,contentSource:K!==void 0?"blocks":"html",blockCount:K?.length??0,htmlLength:L?.length??0}),X=await F("POST","/api/v1/transactional",{name:Y.name,...Y.slug!==void 0&&{slug:Y.slug},subject:B,...O!==void 0&&{previewText:O},...K!==void 0?{blocks:K}:{html:L},...Y.enabled!==void 0&&{enabled:Y.enabled}},G),console.error("[mcp:create_transactional_email] generated transactional created",U)}catch(A){throw console.error("[mcp:create_transactional_email] prompt-based create failed",{...U,error:A instanceof Error?A.message:String(A)}),A}break}let H=Object.fromEntries(Object.entries(Y).filter(([U])=>U!=="companyId"));X=await F("POST","/api/v1/transactional",H,G);break}case"update_transactional_email":{let G=Y.companyId,$=new Set(["companyId","idOrSlug","name","enabled","subject","previewText","html","blocks"]),J=Object.keys(Y).filter((H)=>!$.has(H));if(J.length>0)throw Error(`\`update_transactional_email\` accepts only \`name\`, \`enabled\`, \`subject\`, \`previewText\`, \`html\`, and \`blocks\` update fields. Unsupported field${J.length===1?"":"s"}: ${J.map((H)=>`\`${H}\``).join(", ")}.`);if(P1("update_transactional_email",Y),Y.name===void 0&&Y.enabled===void 0&&Y.subject===void 0&&Y.previewText===void 0&&Y.html===void 0&&Y.blocks===void 0)throw Error("Provide at least one of `name`, `enabled`, `subject`, `previewText`, `html`, or `blocks` when calling `update_transactional_email`.");let z=Object.fromEntries(Object.entries(Y).filter(([H])=>H!=="companyId"&&H!=="idOrSlug"));X=await F("PATCH",`/api/v1/transactional/${Y.idOrSlug}`,z,G);break}case"send_email":{let G=Y.companyId;X=await F("POST","/api/v1/transactional/send",Y,G);break}case"get_stats":{let G=Y.companyId,$=Y.period??"7d";X=await F("GET",`/api/v1/metrics?period=${$}`,void 0,G);break}case"get_campaign_stats":{let G=Y.companyId;X=await F("GET",`/api/v1/metrics/campaigns/${Y.campaignId}`,void 0,G);break}case"get_sequence_stats":{let G=Y.companyId;X=await F("GET",`/api/v1/metrics/sequences/${Y.sequenceId}`,void 0,G);break}case"get_subscriber_activity":{let G=Y.companyId,$=c6("get_subscriber_activity",Y),J=await _Y($,G);X={success:J.success,email:J.subscriber.email,emailStats:J.subscriber.emailStats??null,activity:J.subscriber.activity??[],sequenceEnrollments:J.subscriber.sequenceEnrollments??[]};break}case"list_team_members":{let G=Y.companyId;X=await F("GET","/api/v1/team",void 0,G);break}case"invite_team_member":{let G=Y.companyId,$=x("invite_team_member",Y,"email"),J=yY("invite_team_member",Y,"role",["admin","viewer"]);if(Y.canManageBilling!==void 0&&typeof Y.canManageBilling!=="boolean")throw Error("`canManageBilling` must be a boolean when calling `invite_team_member`.");X=await F("POST","/api/v1/team/invitations",{email:$,role:J,...Y.canManageBilling!==void 0&&{canManageBilling:Y.canManageBilling}},G);break}case"cancel_team_invitation":{let G=Y.companyId,$=x("cancel_team_invitation",Y,"invitationId");X=await F("DELETE",`/api/v1/team/invitations/${encodeURIComponent($)}`,void 0,G);break}case"list_conversations":{let G=Y.companyId,$=new URLSearchParams,J=s0("list_conversations",Y,"status",["open","closed","all"]);if(J)$.set("status",J);let z=N(Y,"search");if(z)$.set("search",z);if(Y.unread!==void 0){if(typeof Y.unread!=="boolean")throw Error("`unread` must be a boolean when calling `list_conversations`.");if(Y.unread)$.set("unread","true")}if(Y.page!==void 0){if(typeof Y.page!=="number"||!Number.isInteger(Y.page)||Y.page<1)throw Error("`page` must be a positive integer when calling `list_conversations`.");$.set("page",String(Y.page))}let H=p6("list_conversations",Y,"limit",1,100);if(H!==void 0)$.set("limit",String(H));X=await F("GET",`/api/v1/conversations${$.size>0?`?${$}`:""}`,void 0,G);break}case"get_conversation":{let G=Y.companyId,$=x("get_conversation",Y,"conversationId");X=await F("GET",`/api/v1/conversations/${encodeURIComponent($)}`,void 0,G);break}case"reply_to_conversation":{let G=Y.companyId,$=x("reply_to_conversation",Y,"conversationId"),J=s0("reply_to_conversation",Y,"type",["outbound","note"])??"outbound",z=N(Y,"subject"),H=N(Y,"bodyText"),U=N(Y,"bodyHtml");if(J==="outbound"&&H===void 0&&U===void 0)throw Error("Provide `bodyText` or `bodyHtml` when calling `reply_to_conversation` with an outbound message.");X=await F("POST",`/api/v1/conversations/${encodeURIComponent($)}/messages`,{type:J,...z!==void 0&&{subject:z},...H!==void 0&&{bodyText:H},...U!==void 0&&{bodyHtml:U}},G);break}case"update_conversation_status":{let G=Y.companyId,$=x("update_conversation_status",Y,"conversationId"),J=yY("update_conversation_status",Y,"status",["open","closed"]);X=await F("POST",`/api/v1/conversations/${encodeURIComponent($)}/status`,{status:J},G);break}case"mark_conversation_read":{let G=Y.companyId,$=x("mark_conversation_read",Y,"conversationId");X=await F("POST",`/api/v1/conversations/${encodeURIComponent($)}/read`,void 0,G);break}case"list_webhooks":{let G=Y.companyId;X=await F("GET","/api/v1/webhooks",void 0,G);break}case"create_webhook":{let G=Y.companyId,$=x("create_webhook",Y,"name"),J=x("create_webhook",Y,"url"),z=g5("create_webhook",Y);X=await F("POST","/api/v1/webhooks",{name:$,url:J,...z!==void 0&&{events:z}},G);break}case"update_webhook":{let G=Y.companyId,$=x("update_webhook",Y,"webhookId"),J=N(Y,"name"),z=N(Y,"url"),H=g5("update_webhook",Y),U=s0("update_webhook",Y,"status",["enabled","disabled"]);if(J===void 0&&z===void 0&&H===void 0&&U===void 0)throw Error("Provide at least one of `name`, `url`, `events`, or `status` when calling `update_webhook`.");X=await F("PATCH",`/api/v1/webhooks/${encodeURIComponent($)}`,{...J!==void 0&&{name:J},...z!==void 0&&{url:z},...H!==void 0&&{events:H},...U!==void 0&&{status:U}},G);break}case"delete_webhook":{let G=Y.companyId,$=x("delete_webhook",Y,"webhookId");X=await F("DELETE",`/api/v1/webhooks/${encodeURIComponent($)}`,void 0,G);break}case"test_webhook":{let G=Y.companyId,$=x("test_webhook",Y,"webhookId");X=await F("POST",`/api/v1/webhooks/${encodeURIComponent($)}/test`,void 0,G);break}case"list_webhook_deliveries":{let G=Y.companyId,$=x("list_webhook_deliveries",Y,"webhookId"),J=p6("list_webhook_deliveries",Y,"limit",1,100),z=new URLSearchParams;if(J!==void 0)z.set("limit",String(J));X=await F("GET",`/api/v1/webhooks/${encodeURIComponent($)}/deliveries${z.size>0?`?${z}`:""}`,void 0,G);break}case"replay_webhook_delivery":{let G=Y.companyId,$=x("replay_webhook_delivery",Y,"webhookId"),J=x("replay_webhook_delivery",Y,"deliveryId");X=await F("POST",`/api/v1/webhooks/${encodeURIComponent($)}/deliveries/${encodeURIComponent(J)}/replay`,void 0,G);break}case"generate_email":{let G=Y.companyId;X=await F("POST","/api/v1/generate/email",Y,G);break}case"generate_sequence":{let G=Y.companyId;X=await F("POST","/api/v1/generate/sequence",Y,G);break}case"generate_subject_lines":{let G=Y.companyId;X=await F("POST","/api/v1/generate/subjects",Y,G);break}default:throw Error(`Unknown tool: ${Q}`)}let W=GV(X);if(W)throw W;return X=await LV(Q,Y,X),{content:[{type:"text",text:JSON.stringify(X,null,2)}]}}catch(X){return{isError:!0,content:[{type:"text",text:e0(X)}]}}}async function c5(Q,Y,X){let W=Y.getRequestContext?.(Q)??{};try{return await NQ(W,X)}finally{await Y.onRequestContextUpdated?.(W,Q)}}function pY(Q={}){let Y=new vY({name:"sequenzy",version:I5.version},{capabilities:{tools:{},resources:{}}});return Y.setRequestHandler(Z9,async()=>{return{tools:l5}}),Y.setRequestHandler(F6,async(X,W)=>{let{name:G,arguments:$}=X.params;return c5(W,Q,()=>m5(G,$??{}))}),Y.setRequestHandler(D9,async()=>{return{resources:S5}}),Y.setRequestHandler(q9,async(X,W)=>{let{uri:G}=X.params;return c5(W,Q,()=>R5(G))}),Y}import i5 from"node:process";class iY{append(Q){this._buffer=this._buffer?Buffer.concat([this._buffer,Q]):Q}readMessage(){if(!this._buffer)return null;let Q=this._buffer.indexOf(`
|
|
187
|
+
`);if(Q===-1)return null;let Y=this._buffer.toString("utf8",0,Q).replace(/\r$/,"");return this._buffer=this._buffer.subarray(Q+1),qV(Y)}clear(){this._buffer=void 0}}function qV(Q){return _G.parse(JSON.parse(Q))}function p5(Q){return JSON.stringify(Q)+`
|
|
188
|
+
`}class nY{constructor(Q=i5.stdin,Y=i5.stdout){this._stdin=Q,this._stdout=Y,this._readBuffer=new iY,this._started=!1,this._ondata=(X)=>{this._readBuffer.append(X),this.processReadBuffer()},this._onerror=(X)=>{this.onerror?.(X)}}async start(){if(this._started)throw Error("StdioServerTransport already started! If using Server class, note that connect() calls start() automatically.");this._started=!0,this._stdin.on("data",this._ondata),this._stdin.on("error",this._onerror)}processReadBuffer(){while(!0)try{let Q=this._readBuffer.readMessage();if(Q===null)break;this.onmessage?.(Q)}catch(Q){this.onerror?.(Q)}}async close(){if(this._stdin.off("data",this._ondata),this._stdin.off("error",this._onerror),this._stdin.listenerCount("data")===0)this._stdin.pause();this._readBuffer.clear(),this.onclose?.()}send(Q){return new Promise((Y)=>{let X=p5(Q);if(this._stdout.write(X))Y();else this._stdout.once("drain",Y)})}}async function FV(){XX(),sY();let Q=pY(),Y=new nY;await Q.connect(Y),console.error("Sequenzy MCP server running on stdio")}FV().catch((Q)=>{console.error(e0(Q)),process.exit(1)});export{NQ as withMcpRequestContext,n6 as setSelectedCompanyId,Q1 as getSelectedCompanyId,pY as createSequenzyMcpServer,F as apiRequest};
|