@opentiny/next-sdk 0.1.15-beta.3 → 0.1.15-beta.5
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/agent/AgentModelProvider.ts +3 -7
- package/dist/WebMcpClient.d.ts +26 -165
- package/dist/WebMcpServer.d.ts +147 -36
- package/dist/index.es.dev.js +7400 -3881
- package/dist/index.es.js +16311 -13500
- package/dist/index.js +114 -114
- package/dist/index.umd.dev.js +7335 -3816
- package/dist/index.umd.js +63 -61
- package/dist/{mcpsdk@1.24.3.dev.js → mcpsdk@1.23.1.dev.js} +201 -1695
- package/dist/{mcpsdk@1.24.3.es.dev.js → mcpsdk@1.23.1.es.dev.js} +201 -1695
- package/dist/mcpsdk@1.23.1.es.js +15530 -0
- package/dist/mcpsdk@1.23.1.js +43 -0
- package/dist/webagent.dev.js +13766 -9961
- package/dist/webagent.es.dev.js +13847 -10042
- package/dist/webagent.es.js +17687 -14644
- package/dist/webagent.js +60 -58
- package/dist/webmcp-full.dev.js +6697 -3408
- package/dist/webmcp-full.es.dev.js +6672 -3383
- package/dist/webmcp-full.es.js +11482 -8820
- package/dist/webmcp-full.js +28 -28
- package/dist/webmcp.dev.js +652 -618
- package/dist/webmcp.es.dev.js +652 -618
- package/dist/webmcp.es.js +665 -626
- package/dist/webmcp.js +1 -1
- package/package.json +2 -2
- package/dist/mcpsdk@1.24.3.es.js +0 -16781
- package/dist/mcpsdk@1.24.3.js +0 -43
package/dist/webmcp-full.js
CHANGED
|
@@ -1,43 +1,43 @@
|
|
|
1
|
-
(function(Se,dr){typeof exports=="object"&&typeof module<"u"?dr(exports):typeof define=="function"&&define.amd?define(["exports"],dr):(Se=typeof globalThis<"u"?globalThis:Se||self,dr(Se.WebMCP={}))})(this,(function(Se){"use strict";function dr(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var $n={exports:{}},oa={},It={},Qt={},ca={},ua={},la={},no;function Sn(){return no||(no=1,(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.regexpCode=t.getEsmExportName=t.getProperty=t.safeStringify=t.stringify=t.strConcat=t.addCodeArg=t.str=t._=t.nil=t._Code=t.Name=t.IDENTIFIER=t._CodeOrName=void 0;class e{}t._CodeOrName=e,t.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;class r extends e{constructor(f){if(super(),!t.IDENTIFIER.test(f))throw new Error("CodeGen: name must be a valid identifier");this.str=f}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}}t.Name=r;class n extends e{constructor(f){super(),this._items=typeof f=="string"?[f]:f}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;const f=this._items[0];return f===""||f==='""'}get str(){var f;return(f=this._str)!==null&&f!==void 0?f:this._str=this._items.reduce((m,b)=>`${m}${b}`,"")}get names(){var f;return(f=this._names)!==null&&f!==void 0?f:this._names=this._items.reduce((m,b)=>(b instanceof r&&(m[b.str]=(m[b.str]||0)+1),m),{})}}t._Code=n,t.nil=new n("");function s(_,...f){const m=[_[0]];let b=0;for(;b<f.length;)o(m,f[b]),m.push(_[++b]);return new n(m)}t._=s;const a=new n("+");function i(_,...f){const m=[v(_[0])];let b=0;for(;b<f.length;)m.push(a),o(m,f[b]),m.push(a,v(_[++b]));return c(m),new n(m)}t.str=i;function o(_,f){f instanceof n?_.push(...f._items):f instanceof r?_.push(f):_.push(d(f))}t.addCodeArg=o;function c(_){let f=1;for(;f<_.length-1;){if(_[f]===a){const m=l(_[f-1],_[f+1]);if(m!==void 0){_.splice(f-1,3,m);continue}_[f++]="+"}f++}}function l(_,f){if(f==='""')return _;if(_==='""')return f;if(typeof _=="string")return f instanceof r||_[_.length-1]!=='"'?void 0:typeof f!="string"?`${_.slice(0,-1)}${f}"`:f[0]==='"'?_.slice(0,-1)+f.slice(1):void 0;if(typeof f=="string"&&f[0]==='"'&&!(_ instanceof r))return`"${_}${f.slice(1)}`}function u(_,f){return f.emptyStr()?_:_.emptyStr()?f:i`${_}${f}`}t.strConcat=u;function d(_){return typeof _=="number"||typeof _=="boolean"||_===null?_:v(Array.isArray(_)?_.join(","):_)}function g(_){return new n(v(_))}t.stringify=g;function v(_){return JSON.stringify(_).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}t.safeStringify=v;function p(_){return typeof _=="string"&&t.IDENTIFIER.test(_)?new n(`.${_}`):s`[${_}]`}t.getProperty=p;function w(_){if(typeof _=="string"&&t.IDENTIFIER.test(_))return new n(`${_}`);throw new Error(`CodeGen: invalid export name: ${_}, use explicit $id name mapping`)}t.getEsmExportName=w;function h(_){return new n(_.toString())}t.regexpCode=h})(la)),la}var da={},so;function ao(){return so||(so=1,(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.ValueScope=t.ValueScopeName=t.Scope=t.varKinds=t.UsedValueState=void 0;const e=Sn();class r extends Error{constructor(l){super(`CodeGen: "code" for ${l} not defined`),this.value=l.value}}var n;(function(c){c[c.Started=0]="Started",c[c.Completed=1]="Completed"})(n||(t.UsedValueState=n={})),t.varKinds={const:new e.Name("const"),let:new e.Name("let"),var:new e.Name("var")};class s{constructor({prefixes:l,parent:u}={}){this._names={},this._prefixes=l,this._parent=u}toName(l){return l instanceof e.Name?l:this.name(l)}name(l){return new e.Name(this._newName(l))}_newName(l){const u=this._names[l]||this._nameGroup(l);return`${l}${u.index++}`}_nameGroup(l){var u,d;if(!((d=(u=this._parent)===null||u===void 0?void 0:u._prefixes)===null||d===void 0)&&d.has(l)||this._prefixes&&!this._prefixes.has(l))throw new Error(`CodeGen: prefix "${l}" is not allowed in this scope`);return this._names[l]={prefix:l,index:0}}}t.Scope=s;class a extends e.Name{constructor(l,u){super(u),this.prefix=l}setValue(l,{property:u,itemIndex:d}){this.value=l,this.scopePath=(0,e._)`.${new e.Name(u)}[${d}]`}}t.ValueScopeName=a;const i=(0,e._)`\n`;class o extends s{constructor(l){super(l),this._values={},this._scope=l.scope,this.opts={...l,_n:l.lines?i:e.nil}}get(){return this._scope}name(l){return new a(l,this._newName(l))}value(l,u){var d;if(u.ref===void 0)throw new Error("CodeGen: ref must be passed in value");const g=this.toName(l),{prefix:v}=g,p=(d=u.key)!==null&&d!==void 0?d:u.ref;let w=this._values[v];if(w){const f=w.get(p);if(f)return f}else w=this._values[v]=new Map;w.set(p,g);const h=this._scope[v]||(this._scope[v]=[]),_=h.length;return h[_]=u.ref,g.setValue(u,{property:v,itemIndex:_}),g}getValue(l,u){const d=this._values[l];if(d)return d.get(u)}scopeRefs(l,u=this._values){return this._reduceValues(u,d=>{if(d.scopePath===void 0)throw new Error(`CodeGen: name "${d}" has no value`);return(0,e._)`${l}${d.scopePath}`})}scopeCode(l=this._values,u,d){return this._reduceValues(l,g=>{if(g.value===void 0)throw new Error(`CodeGen: name "${g}" has no value`);return g.value.code},u,d)}_reduceValues(l,u,d={},g){let v=e.nil;for(const p in l){const w=l[p];if(!w)continue;const h=d[p]=d[p]||new Map;w.forEach(_=>{if(h.has(_))return;h.set(_,n.Started);let f=u(_);if(f){const m=this.opts.es5?t.varKinds.var:t.varKinds.const;v=(0,e._)`${v}${m} ${_} = ${f};${this.opts._n}`}else if(f=g?.(_))v=(0,e._)`${v}${f}${this.opts._n}`;else throw new r(_);h.set(_,n.Completed)})}return v}}t.ValueScope=o})(da)),da}var io;function ce(){return io||(io=1,(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.or=t.and=t.not=t.CodeGen=t.operators=t.varKinds=t.ValueScopeName=t.ValueScope=t.Scope=t.Name=t.regexpCode=t.stringify=t.getProperty=t.nil=t.strConcat=t.str=t._=void 0;const e=Sn(),r=ao();var n=Sn();Object.defineProperty(t,"_",{enumerable:!0,get:function(){return n._}}),Object.defineProperty(t,"str",{enumerable:!0,get:function(){return n.str}}),Object.defineProperty(t,"strConcat",{enumerable:!0,get:function(){return n.strConcat}}),Object.defineProperty(t,"nil",{enumerable:!0,get:function(){return n.nil}}),Object.defineProperty(t,"getProperty",{enumerable:!0,get:function(){return n.getProperty}}),Object.defineProperty(t,"stringify",{enumerable:!0,get:function(){return n.stringify}}),Object.defineProperty(t,"regexpCode",{enumerable:!0,get:function(){return n.regexpCode}}),Object.defineProperty(t,"Name",{enumerable:!0,get:function(){return n.Name}});var s=ao();Object.defineProperty(t,"Scope",{enumerable:!0,get:function(){return s.Scope}}),Object.defineProperty(t,"ValueScope",{enumerable:!0,get:function(){return s.ValueScope}}),Object.defineProperty(t,"ValueScopeName",{enumerable:!0,get:function(){return s.ValueScopeName}}),Object.defineProperty(t,"varKinds",{enumerable:!0,get:function(){return s.varKinds}}),t.operators={GT:new e._Code(">"),GTE:new e._Code(">="),LT:new e._Code("<"),LTE:new e._Code("<="),EQ:new e._Code("==="),NEQ:new e._Code("!=="),NOT:new e._Code("!"),OR:new e._Code("||"),AND:new e._Code("&&"),ADD:new e._Code("+")};class a{optimizeNodes(){return this}optimizeNames($,T){return this}}class i extends a{constructor($,T,j){super(),this.varKind=$,this.name=T,this.rhs=j}render({es5:$,_n:T}){const j=$?r.varKinds.var:this.varKind,ee=this.rhs===void 0?"":` = ${this.rhs}`;return`${j} ${this.name}${ee};`+T}optimizeNames($,T){if($[this.name.str])return this.rhs&&(this.rhs=Y(this.rhs,$,T)),this}get names(){return this.rhs instanceof e._CodeOrName?this.rhs.names:{}}}class o extends a{constructor($,T,j){super(),this.lhs=$,this.rhs=T,this.sideEffects=j}render({_n:$}){return`${this.lhs} = ${this.rhs};`+$}optimizeNames($,T){if(!(this.lhs instanceof e.Name&&!$[this.lhs.str]&&!this.sideEffects))return this.rhs=Y(this.rhs,$,T),this}get names(){const $=this.lhs instanceof e.Name?{}:{...this.lhs.names};return B($,this.rhs)}}class c extends o{constructor($,T,j,ee){super($,j,ee),this.op=T}render({_n:$}){return`${this.lhs} ${this.op}= ${this.rhs};`+$}}class l extends a{constructor($){super(),this.label=$,this.names={}}render({_n:$}){return`${this.label}:`+$}}class u extends a{constructor($){super(),this.label=$,this.names={}}render({_n:$}){return`break${this.label?` ${this.label}`:""};`+$}}class d extends a{constructor($){super(),this.error=$}render({_n:$}){return`throw ${this.error};`+$}get names(){return this.error.names}}class g extends a{constructor($){super(),this.code=$}render({_n:$}){return`${this.code};`+$}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames($,T){return this.code=Y(this.code,$,T),this}get names(){return this.code instanceof e._CodeOrName?this.code.names:{}}}class v extends a{constructor($=[]){super(),this.nodes=$}render($){return this.nodes.reduce((T,j)=>T+j.render($),"")}optimizeNodes(){const{nodes:$}=this;let T=$.length;for(;T--;){const j=$[T].optimizeNodes();Array.isArray(j)?$.splice(T,1,...j):j?$[T]=j:$.splice(T,1)}return $.length>0?this:void 0}optimizeNames($,T){const{nodes:j}=this;let ee=j.length;for(;ee--;){const se=j[ee];se.optimizeNames($,T)||(ve($,se.names),j.splice(ee,1))}return j.length>0?this:void 0}get names(){return this.nodes.reduce(($,T)=>V($,T.names),{})}}class p extends v{render($){return"{"+$._n+super.render($)+"}"+$._n}}class w extends v{}class h extends p{}h.kind="else";class _ extends p{constructor($,T){super(T),this.condition=$}render($){let T=`if(${this.condition})`+super.render($);return this.else&&(T+="else "+this.else.render($)),T}optimizeNodes(){super.optimizeNodes();const $=this.condition;if($===!0)return this.nodes;let T=this.else;if(T){const j=T.optimizeNodes();T=this.else=Array.isArray(j)?new h(j):j}if(T)return $===!1?T instanceof _?T:T.nodes:this.nodes.length?this:new _(Ge($),T instanceof _?[T]:T.nodes);if(!($===!1||!this.nodes.length))return this}optimizeNames($,T){var j;if(this.else=(j=this.else)===null||j===void 0?void 0:j.optimizeNames($,T),!!(super.optimizeNames($,T)||this.else))return this.condition=Y(this.condition,$,T),this}get names(){const $=super.names;return B($,this.condition),this.else&&V($,this.else.names),$}}_.kind="if";class f extends p{}f.kind="for";class m extends f{constructor($){super(),this.iteration=$}render($){return`for(${this.iteration})`+super.render($)}optimizeNames($,T){if(super.optimizeNames($,T))return this.iteration=Y(this.iteration,$,T),this}get names(){return V(super.names,this.iteration.names)}}class b extends f{constructor($,T,j,ee){super(),this.varKind=$,this.name=T,this.from=j,this.to=ee}render($){const T=$.es5?r.varKinds.var:this.varKind,{name:j,from:ee,to:se}=this;return`for(${T} ${j}=${ee}; ${j}<${se}; ${j}++)`+super.render($)}get names(){const $=B(super.names,this.from);return B($,this.to)}}class y extends f{constructor($,T,j,ee){super(),this.loop=$,this.varKind=T,this.name=j,this.iterable=ee}render($){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render($)}optimizeNames($,T){if(super.optimizeNames($,T))return this.iterable=Y(this.iterable,$,T),this}get names(){return V(super.names,this.iterable.names)}}class k extends p{constructor($,T,j){super(),this.name=$,this.args=T,this.async=j}render($){return`${this.async?"async ":""}function ${this.name}(${this.args})`+super.render($)}}k.kind="func";class S extends v{render($){return"return "+super.render($)}}S.kind="return";class I extends p{render($){let T="try"+super.render($);return this.catch&&(T+=this.catch.render($)),this.finally&&(T+=this.finally.render($)),T}optimizeNodes(){var $,T;return super.optimizeNodes(),($=this.catch)===null||$===void 0||$.optimizeNodes(),(T=this.finally)===null||T===void 0||T.optimizeNodes(),this}optimizeNames($,T){var j,ee;return super.optimizeNames($,T),(j=this.catch)===null||j===void 0||j.optimizeNames($,T),(ee=this.finally)===null||ee===void 0||ee.optimizeNames($,T),this}get names(){const $=super.names;return this.catch&&V($,this.catch.names),this.finally&&V($,this.finally.names),$}}class C extends p{constructor($){super(),this.error=$}render($){return`catch(${this.error})`+super.render($)}}C.kind="catch";class q extends p{render($){return"finally"+super.render($)}}q.kind="finally";class N{constructor($,T={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...T,_n:T.lines?`
|
|
2
|
-
`:""},this._extScope=$,this._scope=new r.Scope({parent:$}),this._nodes=[new w]}toString(){return this._root.render(this.opts)}name($){return this._scope.name($)}scopeName($){return this._extScope.name($)}scopeValue($,T){const j=this._extScope.value($,T);return(this._values[j.prefix]||(this._values[j.prefix]=new Set)).add(j),j}getScopeValue($,T){return this._extScope.getValue($,T)}scopeRefs($){return this._extScope.scopeRefs($,this._values)}scopeCode(){return this._extScope.scopeCode(this._values)}_def($,T,j,ee){const se=this._scope.toName(T);return j!==void 0&&ee&&(this._constants[se.str]=j),this._leafNode(new i($,se,j)),se}const($,T,j){return this._def(r.varKinds.const,$,T,j)}let($,T,j){return this._def(r.varKinds.let,$,T,j)}var($,T,j){return this._def(r.varKinds.var,$,T,j)}assign($,T,j){return this._leafNode(new o($,T,j))}add($,T){return this._leafNode(new c($,t.operators.ADD,T))}code($){return typeof $=="function"?$():$!==e.nil&&this._leafNode(new g($)),this}object(...$){const T=["{"];for(const[j,ee]of $)T.length>1&&T.push(","),T.push(j),(j!==ee||this.opts.es5)&&(T.push(":"),(0,e.addCodeArg)(T,ee));return T.push("}"),new e._Code(T)}if($,T,j){if(this._blockNode(new _($)),T&&j)this.code(T).else().code(j).endIf();else if(T)this.code(T).endIf();else if(j)throw new Error('CodeGen: "else" body without "then" body');return this}elseIf($){return this._elseNode(new _($))}else(){return this._elseNode(new h)}endIf(){return this._endBlockNode(_,h)}_for($,T){return this._blockNode($),T&&this.code(T).endFor(),this}for($,T){return this._for(new m($),T)}forRange($,T,j,ee,se=this.opts.es5?r.varKinds.var:r.varKinds.let){const _e=this._scope.toName($);return this._for(new b(se,_e,T,j),()=>ee(_e))}forOf($,T,j,ee=r.varKinds.const){const se=this._scope.toName($);if(this.opts.es5){const _e=T instanceof e.Name?T:this.var("_arr",T);return this.forRange("_i",0,(0,e._)`${_e}.length`,he=>{this.var(se,(0,e._)`${_e}[${he}]`),j(se)})}return this._for(new y("of",ee,se,T),()=>j(se))}forIn($,T,j,ee=this.opts.es5?r.varKinds.var:r.varKinds.const){if(this.opts.ownProperties)return this.forOf($,(0,e._)`Object.keys(${T})`,j);const se=this._scope.toName($);return this._for(new y("in",ee,se,T),()=>j(se))}endFor(){return this._endBlockNode(f)}label($){return this._leafNode(new l($))}break($){return this._leafNode(new u($))}return($){const T=new S;if(this._blockNode(T),this.code($),T.nodes.length!==1)throw new Error('CodeGen: "return" should have one node');return this._endBlockNode(S)}try($,T,j){if(!T&&!j)throw new Error('CodeGen: "try" without "catch" and "finally"');const ee=new I;if(this._blockNode(ee),this.code($),T){const se=this.name("e");this._currNode=ee.catch=new C(se),T(se)}return j&&(this._currNode=ee.finally=new q,this.code(j)),this._endBlockNode(C,q)}throw($){return this._leafNode(new d($))}block($,T){return this._blockStarts.push(this._nodes.length),$&&this.code($).endBlock(T),this}endBlock($){const T=this._blockStarts.pop();if(T===void 0)throw new Error("CodeGen: not in self-balancing block");const j=this._nodes.length-T;if(j<0||$!==void 0&&j!==$)throw new Error(`CodeGen: wrong number of nodes: ${j} vs ${$} expected`);return this._nodes.length=T,this}func($,T=e.nil,j,ee){return this._blockNode(new k($,T,j)),ee&&this.code(ee).endFunc(),this}endFunc(){return this._endBlockNode(k)}optimize($=1){for(;$-- >0;)this._root.optimizeNodes(),this._root.optimizeNames(this._root.names,this._constants)}_leafNode($){return this._currNode.nodes.push($),this}_blockNode($){this._currNode.nodes.push($),this._nodes.push($)}_endBlockNode($,T){const j=this._currNode;if(j instanceof $||T&&j instanceof T)return this._nodes.pop(),this;throw new Error(`CodeGen: not in block "${T?`${$.kind}/${T.kind}`:$.kind}"`)}_elseNode($){const T=this._currNode;if(!(T instanceof _))throw new Error('CodeGen: "else" without "if"');return this._currNode=T.else=$,this}get _root(){return this._nodes[0]}get _currNode(){const $=this._nodes;return $[$.length-1]}set _currNode($){const T=this._nodes;T[T.length-1]=$}}t.CodeGen=N;function V(O,$){for(const T in $)O[T]=(O[T]||0)+($[T]||0);return O}function B(O,$){return $ instanceof e._CodeOrName?V(O,$.names):O}function Y(O,$,T){if(O instanceof e.Name)return j(O);if(!ee(O))return O;return new e._Code(O._items.reduce((se,_e)=>(_e instanceof e.Name&&(_e=j(_e)),_e instanceof e._Code?se.push(..._e._items):se.push(_e),se),[]));function j(se){const _e=T[se.str];return _e===void 0||$[se.str]!==1?se:(delete $[se.str],_e)}function ee(se){return se instanceof e._Code&&se._items.some(_e=>_e instanceof e.Name&&$[_e.str]===1&&T[_e.str]!==void 0)}}function ve(O,$){for(const T in $)O[T]=(O[T]||0)-($[T]||0)}function Ge(O){return typeof O=="boolean"||typeof O=="number"||O===null?!O:(0,e._)`!${M(O)}`}t.not=Ge;const Ye=P(t.operators.AND);function be(...O){return O.reduce(Ye)}t.and=be;const kt=P(t.operators.OR);function D(...O){return O.reduce(kt)}t.or=D;function P(O){return($,T)=>$===e.nil?T:T===e.nil?$:(0,e._)`${M($)} ${O} ${M(T)}`}function M(O){return O instanceof e.Name?O:(0,e._)`(${O})`}})(ua)),ua}var ue={},oo;function pe(){if(oo)return ue;oo=1,Object.defineProperty(ue,"__esModule",{value:!0}),ue.checkStrictMode=ue.getErrorPath=ue.Type=ue.useFunc=ue.setEvaluated=ue.evaluatedPropsToName=ue.mergeEvaluated=ue.eachItem=ue.unescapeJsonPointer=ue.escapeJsonPointer=ue.escapeFragment=ue.unescapeFragment=ue.schemaRefOrVal=ue.schemaHasRulesButRef=ue.schemaHasRules=ue.checkUnknownRules=ue.alwaysValidSchema=ue.toHash=void 0;const t=ce(),e=Sn();function r(y){const k={};for(const S of y)k[S]=!0;return k}ue.toHash=r;function n(y,k){return typeof k=="boolean"?k:Object.keys(k).length===0?!0:(s(y,k),!a(k,y.self.RULES.all))}ue.alwaysValidSchema=n;function s(y,k=y.schema){const{opts:S,self:I}=y;if(!S.strictSchema||typeof k=="boolean")return;const C=I.RULES.keywords;for(const q in k)C[q]||b(y,`unknown keyword: "${q}"`)}ue.checkUnknownRules=s;function a(y,k){if(typeof y=="boolean")return!y;for(const S in y)if(k[S])return!0;return!1}ue.schemaHasRules=a;function i(y,k){if(typeof y=="boolean")return!y;for(const S in y)if(S!=="$ref"&&k.all[S])return!0;return!1}ue.schemaHasRulesButRef=i;function o({topSchemaRef:y,schemaPath:k},S,I,C){if(!C){if(typeof S=="number"||typeof S=="boolean")return S;if(typeof S=="string")return(0,t._)`${S}`}return(0,t._)`${y}${k}${(0,t.getProperty)(I)}`}ue.schemaRefOrVal=o;function c(y){return d(decodeURIComponent(y))}ue.unescapeFragment=c;function l(y){return encodeURIComponent(u(y))}ue.escapeFragment=l;function u(y){return typeof y=="number"?`${y}`:y.replace(/~/g,"~0").replace(/\//g,"~1")}ue.escapeJsonPointer=u;function d(y){return y.replace(/~1/g,"/").replace(/~0/g,"~")}ue.unescapeJsonPointer=d;function g(y,k){if(Array.isArray(y))for(const S of y)k(S);else k(y)}ue.eachItem=g;function v({mergeNames:y,mergeToName:k,mergeValues:S,resultToName:I}){return(C,q,N,V)=>{const B=N===void 0?q:N instanceof t.Name?(q instanceof t.Name?y(C,q,N):k(C,q,N),N):q instanceof t.Name?(k(C,N,q),q):S(q,N);return V===t.Name&&!(B instanceof t.Name)?I(C,B):B}}ue.mergeEvaluated={props:v({mergeNames:(y,k,S)=>y.if((0,t._)`${S} !== true && ${k} !== undefined`,()=>{y.if((0,t._)`${k} === true`,()=>y.assign(S,!0),()=>y.assign(S,(0,t._)`${S} || {}`).code((0,t._)`Object.assign(${S}, ${k})`))}),mergeToName:(y,k,S)=>y.if((0,t._)`${S} !== true`,()=>{k===!0?y.assign(S,!0):(y.assign(S,(0,t._)`${S} || {}`),w(y,S,k))}),mergeValues:(y,k)=>y===!0?!0:{...y,...k},resultToName:p}),items:v({mergeNames:(y,k,S)=>y.if((0,t._)`${S} !== true && ${k} !== undefined`,()=>y.assign(S,(0,t._)`${k} === true ? true : ${S} > ${k} ? ${S} : ${k}`)),mergeToName:(y,k,S)=>y.if((0,t._)`${S} !== true`,()=>y.assign(S,k===!0?!0:(0,t._)`${S} > ${k} ? ${S} : ${k}`)),mergeValues:(y,k)=>y===!0?!0:Math.max(y,k),resultToName:(y,k)=>y.var("items",k)})};function p(y,k){if(k===!0)return y.var("props",!0);const S=y.var("props",(0,t._)`{}`);return k!==void 0&&w(y,S,k),S}ue.evaluatedPropsToName=p;function w(y,k,S){Object.keys(S).forEach(I=>y.assign((0,t._)`${k}${(0,t.getProperty)(I)}`,!0))}ue.setEvaluated=w;const h={};function _(y,k){return y.scopeValue("func",{ref:k,code:h[k.code]||(h[k.code]=new e._Code(k.code))})}ue.useFunc=_;var f;(function(y){y[y.Num=0]="Num",y[y.Str=1]="Str"})(f||(ue.Type=f={}));function m(y,k,S){if(y instanceof t.Name){const I=k===f.Num;return S?I?(0,t._)`"[" + ${y} + "]"`:(0,t._)`"['" + ${y} + "']"`:I?(0,t._)`"/" + ${y}`:(0,t._)`"/" + ${y}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return S?(0,t.getProperty)(y).toString():"/"+u(y)}ue.getErrorPath=m;function b(y,k,S=y.opts.strictSchema){if(S){if(k=`strict mode: ${k}`,S===!0)throw new Error(k);y.self.logger.warn(k)}}return ue.checkStrictMode=b,ue}var Tn={},co;function Zt(){if(co)return Tn;co=1,Object.defineProperty(Tn,"__esModule",{value:!0});const t=ce(),e={data:new t.Name("data"),valCxt:new t.Name("valCxt"),instancePath:new t.Name("instancePath"),parentData:new t.Name("parentData"),parentDataProperty:new t.Name("parentDataProperty"),rootData:new t.Name("rootData"),dynamicAnchors:new t.Name("dynamicAnchors"),vErrors:new t.Name("vErrors"),errors:new t.Name("errors"),this:new t.Name("this"),self:new t.Name("self"),scope:new t.Name("scope"),json:new t.Name("json"),jsonPos:new t.Name("jsonPos"),jsonLen:new t.Name("jsonLen"),jsonPart:new t.Name("jsonPart")};return Tn.default=e,Tn}var uo;function En(){return uo||(uo=1,(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.extendErrors=t.resetErrorsCount=t.reportExtraError=t.reportError=t.keyword$DataError=t.keywordError=void 0;const e=ce(),r=pe(),n=Zt();t.keywordError={message:({keyword:h})=>(0,e.str)`must pass "${h}" keyword validation`},t.keyword$DataError={message:({keyword:h,schemaType:_})=>_?(0,e.str)`"${h}" keyword must be ${_} ($data)`:(0,e.str)`"${h}" keyword is invalid ($data)`};function s(h,_=t.keywordError,f,m){const{it:b}=h,{gen:y,compositeRule:k,allErrors:S}=b,I=d(h,_,f);m??(k||S)?c(y,I):l(b,(0,e._)`[${I}]`)}t.reportError=s;function a(h,_=t.keywordError,f){const{it:m}=h,{gen:b,compositeRule:y,allErrors:k}=m,S=d(h,_,f);c(b,S),y||k||l(m,n.default.vErrors)}t.reportExtraError=a;function i(h,_){h.assign(n.default.errors,_),h.if((0,e._)`${n.default.vErrors} !== null`,()=>h.if(_,()=>h.assign((0,e._)`${n.default.vErrors}.length`,_),()=>h.assign(n.default.vErrors,null)))}t.resetErrorsCount=i;function o({gen:h,keyword:_,schemaValue:f,data:m,errsCount:b,it:y}){if(b===void 0)throw new Error("ajv implementation error");const k=h.name("err");h.forRange("i",b,n.default.errors,S=>{h.const(k,(0,e._)`${n.default.vErrors}[${S}]`),h.if((0,e._)`${k}.instancePath === undefined`,()=>h.assign((0,e._)`${k}.instancePath`,(0,e.strConcat)(n.default.instancePath,y.errorPath))),h.assign((0,e._)`${k}.schemaPath`,(0,e.str)`${y.errSchemaPath}/${_}`),y.opts.verbose&&(h.assign((0,e._)`${k}.schema`,f),h.assign((0,e._)`${k}.data`,m))})}t.extendErrors=o;function c(h,_){const f=h.const("err",_);h.if((0,e._)`${n.default.vErrors} === null`,()=>h.assign(n.default.vErrors,(0,e._)`[${f}]`),(0,e._)`${n.default.vErrors}.push(${f})`),h.code((0,e._)`${n.default.errors}++`)}function l(h,_){const{gen:f,validateName:m,schemaEnv:b}=h;b.$async?f.throw((0,e._)`new ${h.ValidationError}(${_})`):(f.assign((0,e._)`${m}.errors`,_),f.return(!1))}const u={keyword:new e.Name("keyword"),schemaPath:new e.Name("schemaPath"),params:new e.Name("params"),propertyName:new e.Name("propertyName"),message:new e.Name("message"),schema:new e.Name("schema"),parentSchema:new e.Name("parentSchema")};function d(h,_,f){const{createErrors:m}=h.it;return m===!1?(0,e._)`{}`:g(h,_,f)}function g(h,_,f={}){const{gen:m,it:b}=h,y=[v(b,f),p(h,f)];return w(h,_,y),m.object(...y)}function v({errorPath:h},{instancePath:_}){const f=_?(0,e.str)`${h}${(0,r.getErrorPath)(_,r.Type.Str)}`:h;return[n.default.instancePath,(0,e.strConcat)(n.default.instancePath,f)]}function p({keyword:h,it:{errSchemaPath:_}},{schemaPath:f,parentSchema:m}){let b=m?_:(0,e.str)`${_}/${h}`;return f&&(b=(0,e.str)`${b}${(0,r.getErrorPath)(f,r.Type.Str)}`),[u.schemaPath,b]}function w(h,{params:_,message:f},m){const{keyword:b,data:y,schemaValue:k,it:S}=h,{opts:I,propertyName:C,topSchemaRef:q,schemaPath:N}=S;m.push([u.keyword,b],[u.params,typeof _=="function"?_(h):_||(0,e._)`{}`]),I.messages&&m.push([u.message,typeof f=="function"?f(h):f]),I.verbose&&m.push([u.schema,k],[u.parentSchema,(0,e._)`${q}${N}`],[n.default.data,y]),C&&m.push([u.propertyName,C])}})(ca)),ca}var lo;function pd(){if(lo)return Qt;lo=1,Object.defineProperty(Qt,"__esModule",{value:!0}),Qt.boolOrEmptySchema=Qt.topBoolOrEmptySchema=void 0;const t=En(),e=ce(),r=Zt(),n={message:"boolean schema is false"};function s(o){const{gen:c,schema:l,validateName:u}=o;l===!1?i(o,!1):typeof l=="object"&&l.$async===!0?c.return(r.default.data):(c.assign((0,e._)`${u}.errors`,null),c.return(!0))}Qt.topBoolOrEmptySchema=s;function a(o,c){const{gen:l,schema:u}=o;u===!1?(l.var(c,!1),i(o)):l.var(c,!0)}Qt.boolOrEmptySchema=a;function i(o,c){const{gen:l,data:u}=o,d={gen:l,keyword:"false schema",data:u,schema:!1,schemaCode:!1,schemaValue:!1,params:{},it:o};(0,t.reportError)(d,n,void 0,c)}return Qt}var Ze={},Xt={},fo;function ho(){if(fo)return Xt;fo=1,Object.defineProperty(Xt,"__esModule",{value:!0}),Xt.getRules=Xt.isJSONType=void 0;const t=["string","number","integer","boolean","null","object","array"],e=new Set(t);function r(s){return typeof s=="string"&&e.has(s)}Xt.isJSONType=r;function n(){const s={number:{type:"number",rules:[]},string:{type:"string",rules:[]},array:{type:"array",rules:[]},object:{type:"object",rules:[]}};return{types:{...s,integer:!0,boolean:!0,null:!0},rules:[{rules:[]},s.number,s.string,s.array,s.object],post:{rules:[]},all:{},keywords:{}}}return Xt.getRules=n,Xt}var Ct={},po;function mo(){if(po)return Ct;po=1,Object.defineProperty(Ct,"__esModule",{value:!0}),Ct.shouldUseRule=Ct.shouldUseGroup=Ct.schemaHasRulesForType=void 0;function t({schema:n,self:s},a){const i=s.RULES.types[a];return i&&i!==!0&&e(n,i)}Ct.schemaHasRulesForType=t;function e(n,s){return s.rules.some(a=>r(n,a))}Ct.shouldUseGroup=e;function r(n,s){var a;return n[s.keyword]!==void 0||((a=s.definition.implements)===null||a===void 0?void 0:a.some(i=>n[i]!==void 0))}return Ct.shouldUseRule=r,Ct}var _o;function Rn(){if(_o)return Ze;_o=1,Object.defineProperty(Ze,"__esModule",{value:!0}),Ze.reportTypeError=Ze.checkDataTypes=Ze.checkDataType=Ze.coerceAndCheckDataType=Ze.getJSONTypes=Ze.getSchemaTypes=Ze.DataType=void 0;const t=ho(),e=mo(),r=En(),n=ce(),s=pe();var a;(function(f){f[f.Correct=0]="Correct",f[f.Wrong=1]="Wrong"})(a||(Ze.DataType=a={}));function i(f){const m=o(f.type);if(m.includes("null")){if(f.nullable===!1)throw new Error("type: null contradicts nullable: false")}else{if(!m.length&&f.nullable!==void 0)throw new Error('"nullable" cannot be used without "type"');f.nullable===!0&&m.push("null")}return m}Ze.getSchemaTypes=i;function o(f){const m=Array.isArray(f)?f:f?[f]:[];if(m.every(t.isJSONType))return m;throw new Error("type must be JSONType or JSONType[]: "+m.join(","))}Ze.getJSONTypes=o;function c(f,m){const{gen:b,data:y,opts:k}=f,S=u(m,k.coerceTypes),I=m.length>0&&!(S.length===0&&m.length===1&&(0,e.schemaHasRulesForType)(f,m[0]));if(I){const C=p(m,y,k.strictNumbers,a.Wrong);b.if(C,()=>{S.length?d(f,m,S):h(f)})}return I}Ze.coerceAndCheckDataType=c;const l=new Set(["string","number","integer","boolean","null"]);function u(f,m){return m?f.filter(b=>l.has(b)||m==="array"&&b==="array"):[]}function d(f,m,b){const{gen:y,data:k,opts:S}=f,I=y.let("dataType",(0,n._)`typeof ${k}`),C=y.let("coerced",(0,n._)`undefined`);S.coerceTypes==="array"&&y.if((0,n._)`${I} == 'object' && Array.isArray(${k}) && ${k}.length == 1`,()=>y.assign(k,(0,n._)`${k}[0]`).assign(I,(0,n._)`typeof ${k}`).if(p(m,k,S.strictNumbers),()=>y.assign(C,k))),y.if((0,n._)`${C} !== undefined`);for(const N of b)(l.has(N)||N==="array"&&S.coerceTypes==="array")&&q(N);y.else(),h(f),y.endIf(),y.if((0,n._)`${C} !== undefined`,()=>{y.assign(k,C),g(f,C)});function q(N){switch(N){case"string":y.elseIf((0,n._)`${I} == "number" || ${I} == "boolean"`).assign(C,(0,n._)`"" + ${k}`).elseIf((0,n._)`${k} === null`).assign(C,(0,n._)`""`);return;case"number":y.elseIf((0,n._)`${I} == "boolean" || ${k} === null
|
|
3
|
-
|| (${
|
|
4
|
-
|| (${
|
|
5
|
-
|| ${I} === "boolean" || ${k} === null`).assign(C,(0,n._)`[${k}]`)}}}function g({gen:f,parentData:m,parentDataProperty:b},y){f.if((0,n._)`${m} !== undefined`,()=>f.assign((0,n._)`${m}[${b}]`,y))}function v(f,m,b,y=a.Correct){const k=y===a.Correct?n.operators.EQ:n.operators.NEQ;let S;switch(f){case"null":return(0,n._)`${m} ${k} null`;case"array":S=(0,n._)`Array.isArray(${m})`;break;case"object":S=(0,n._)`${m} && typeof ${m} == "object" && !Array.isArray(${m})`;break;case"integer":S=I((0,n._)`!(${m} % 1) && !isNaN(${m})`);break;case"number":S=I();break;default:return(0,n._)`typeof ${m} ${k} ${f}`}return y===a.Correct?S:(0,n.not)(S);function I(C=n.nil){return(0,n.and)((0,n._)`typeof ${m} == "number"`,C,b?(0,n._)`isFinite(${m})`:n.nil)}}Ze.checkDataType=v;function p(f,m,b,y){if(f.length===1)return v(f[0],m,b,y);let k;const S=(0,s.toHash)(f);if(S.array&&S.object){const I=(0,n._)`typeof ${m} != "object"`;k=S.null?I:(0,n._)`!${m} || ${I}`,delete S.null,delete S.array,delete S.object}else k=n.nil;S.number&&delete S.integer;for(const I in S)k=(0,n.and)(k,v(I,m,b,y));return k}Ze.checkDataTypes=p;const w={message:({schema:f})=>`must be ${f}`,params:({schema:f,schemaValue:m})=>typeof f=="string"?(0,n._)`{type: ${f}}`:(0,n._)`{type: ${m}}`};function h(f){const m=_(f);(0,r.reportError)(m,w)}Ze.reportTypeError=h;function _(f){const{gen:m,data:b,schema:y}=f,k=(0,s.schemaRefOrVal)(f,y,"type");return{gen:m,keyword:"type",data:b,schema:y.type,schemaCode:k,schemaValue:k,parentSchema:y,params:{},it:f}}return Ze}var Nr={},vo;function md(){if(vo)return Nr;vo=1,Object.defineProperty(Nr,"__esModule",{value:!0}),Nr.assignDefaults=void 0;const t=ce(),e=pe();function r(s,a){const{properties:i,items:o}=s.schema;if(a==="object"&&i)for(const c in i)n(s,c,i[c].default);else a==="array"&&Array.isArray(o)&&o.forEach((c,l)=>n(s,l,c.default))}Nr.assignDefaults=r;function n(s,a,i){const{gen:o,compositeRule:c,data:l,opts:u}=s;if(i===void 0)return;const d=(0,t._)`${l}${(0,t.getProperty)(a)}`;if(c){(0,e.checkStrictMode)(s,`default is ignored for: ${d}`);return}let g=(0,t._)`${d} === undefined`;u.useDefaults==="empty"&&(g=(0,t._)`${g} || ${d} === null || ${d} === ""`),o.if(g,(0,t._)`${d} = ${(0,t.stringify)(i)}`)}return Nr}var ht={},ge={},go;function pt(){if(go)return ge;go=1,Object.defineProperty(ge,"__esModule",{value:!0}),ge.validateUnion=ge.validateArray=ge.usePattern=ge.callValidateCode=ge.schemaProperties=ge.allSchemaProperties=ge.noPropertyInData=ge.propertyInData=ge.isOwnProperty=ge.hasPropFunc=ge.reportMissingProp=ge.checkMissingProp=ge.checkReportMissingProp=void 0;const t=ce(),e=pe(),r=Zt(),n=pe();function s(f,m){const{gen:b,data:y,it:k}=f;b.if(u(b,y,m,k.opts.ownProperties),()=>{f.setParams({missingProperty:(0,t._)`${m}`},!0),f.error()})}ge.checkReportMissingProp=s;function a({gen:f,data:m,it:{opts:b}},y,k){return(0,t.or)(...y.map(S=>(0,t.and)(u(f,m,S,b.ownProperties),(0,t._)`${k} = ${S}`)))}ge.checkMissingProp=a;function i(f,m){f.setParams({missingProperty:m},!0),f.error()}ge.reportMissingProp=i;function o(f){return f.scopeValue("func",{ref:Object.prototype.hasOwnProperty,code:(0,t._)`Object.prototype.hasOwnProperty`})}ge.hasPropFunc=o;function c(f,m,b){return(0,t._)`${o(f)}.call(${m}, ${b})`}ge.isOwnProperty=c;function l(f,m,b,y){const k=(0,t._)`${m}${(0,t.getProperty)(b)} !== undefined`;return y?(0,t._)`${k} && ${c(f,m,b)}`:k}ge.propertyInData=l;function u(f,m,b,y){const k=(0,t._)`${m}${(0,t.getProperty)(b)} === undefined`;return y?(0,t.or)(k,(0,t.not)(c(f,m,b))):k}ge.noPropertyInData=u;function d(f){return f?Object.keys(f).filter(m=>m!=="__proto__"):[]}ge.allSchemaProperties=d;function g(f,m){return d(m).filter(b=>!(0,e.alwaysValidSchema)(f,m[b]))}ge.schemaProperties=g;function v({schemaCode:f,data:m,it:{gen:b,topSchemaRef:y,schemaPath:k,errorPath:S},it:I},C,q,N){const V=N?(0,t._)`${f}, ${m}, ${y}${k}`:m,B=[[r.default.instancePath,(0,t.strConcat)(r.default.instancePath,S)],[r.default.parentData,I.parentData],[r.default.parentDataProperty,I.parentDataProperty],[r.default.rootData,r.default.rootData]];I.opts.dynamicRef&&B.push([r.default.dynamicAnchors,r.default.dynamicAnchors]);const Y=(0,t._)`${V}, ${b.object(...B)}`;return q!==t.nil?(0,t._)`${C}.call(${q}, ${Y})`:(0,t._)`${C}(${Y})`}ge.callValidateCode=v;const p=(0,t._)`new RegExp`;function w({gen:f,it:{opts:m}},b){const y=m.unicodeRegExp?"u":"",{regExp:k}=m.code,S=k(b,y);return f.scopeValue("pattern",{key:S.toString(),ref:S,code:(0,t._)`${k.code==="new RegExp"?p:(0,n.useFunc)(f,k)}(${b}, ${y})`})}ge.usePattern=w;function h(f){const{gen:m,data:b,keyword:y,it:k}=f,S=m.name("valid");if(k.allErrors){const C=m.let("valid",!0);return I(()=>m.assign(C,!1)),C}return m.var(S,!0),I(()=>m.break()),S;function I(C){const q=m.const("len",(0,t._)`${b}.length`);m.forRange("i",0,q,N=>{f.subschema({keyword:y,dataProp:N,dataPropType:e.Type.Num},S),m.if((0,t.not)(S),C)})}}ge.validateArray=h;function _(f){const{gen:m,schema:b,keyword:y,it:k}=f;if(!Array.isArray(b))throw new Error("ajv implementation error");if(b.some(q=>(0,e.alwaysValidSchema)(k,q))&&!k.opts.unevaluated)return;const I=m.let("valid",!1),C=m.name("_valid");m.block(()=>b.forEach((q,N)=>{const V=f.subschema({keyword:y,schemaProp:N,compositeRule:!0},C);m.assign(I,(0,t._)`${I} || ${C}`),f.mergeValidEvaluated(V,C)||m.if((0,t.not)(I))})),f.result(I,()=>f.reset(),()=>f.error(!0))}return ge.validateUnion=_,ge}var yo;function _d(){if(yo)return ht;yo=1,Object.defineProperty(ht,"__esModule",{value:!0}),ht.validateKeywordUsage=ht.validSchemaType=ht.funcKeywordCode=ht.macroKeywordCode=void 0;const t=ce(),e=Zt(),r=pt(),n=En();function s(g,v){const{gen:p,keyword:w,schema:h,parentSchema:_,it:f}=g,m=v.macro.call(f.self,h,_,f),b=l(p,w,m);f.opts.validateSchema!==!1&&f.self.validateSchema(m,!0);const y=p.name("valid");g.subschema({schema:m,schemaPath:t.nil,errSchemaPath:`${f.errSchemaPath}/${w}`,topSchemaRef:b,compositeRule:!0},y),g.pass(y,()=>g.error(!0))}ht.macroKeywordCode=s;function a(g,v){var p;const{gen:w,keyword:h,schema:_,parentSchema:f,$data:m,it:b}=g;c(b,v);const y=!m&&v.compile?v.compile.call(b.self,_,f,b):v.validate,k=l(w,h,y),S=w.let("valid");g.block$data(S,I),g.ok((p=v.valid)!==null&&p!==void 0?p:S);function I(){if(v.errors===!1)N(),v.modifying&&i(g),V(()=>g.error());else{const B=v.async?C():q();v.modifying&&i(g),V(()=>o(g,B))}}function C(){const B=w.let("ruleErrs",null);return w.try(()=>N((0,t._)`await `),Y=>w.assign(S,!1).if((0,t._)`${Y} instanceof ${b.ValidationError}`,()=>w.assign(B,(0,t._)`${Y}.errors`),()=>w.throw(Y))),B}function q(){const B=(0,t._)`${k}.errors`;return w.assign(B,null),N(t.nil),B}function N(B=v.async?(0,t._)`await `:t.nil){const Y=b.opts.passContext?e.default.this:e.default.self,ve=!("compile"in v&&!m||v.schema===!1);w.assign(S,(0,t._)`${B}${(0,r.callValidateCode)(g,k,Y,ve)}`,v.modifying)}function V(B){var Y;w.if((0,t.not)((Y=v.valid)!==null&&Y!==void 0?Y:S),B)}}ht.funcKeywordCode=a;function i(g){const{gen:v,data:p,it:w}=g;v.if(w.parentData,()=>v.assign(p,(0,t._)`${w.parentData}[${w.parentDataProperty}]`))}function o(g,v){const{gen:p}=g;p.if((0,t._)`Array.isArray(${v})`,()=>{p.assign(e.default.vErrors,(0,t._)`${e.default.vErrors} === null ? ${v} : ${e.default.vErrors}.concat(${v})`).assign(e.default.errors,(0,t._)`${e.default.vErrors}.length`),(0,n.extendErrors)(g)},()=>g.error())}function c({schemaEnv:g},v){if(v.async&&!g.$async)throw new Error("async keyword in sync schema")}function l(g,v,p){if(p===void 0)throw new Error(`keyword "${v}" failed to compile`);return g.scopeValue("keyword",typeof p=="function"?{ref:p}:{ref:p,code:(0,t.stringify)(p)})}function u(g,v,p=!1){return!v.length||v.some(w=>w==="array"?Array.isArray(g):w==="object"?g&&typeof g=="object"&&!Array.isArray(g):typeof g==w||p&&typeof g>"u")}ht.validSchemaType=u;function d({schema:g,opts:v,self:p,errSchemaPath:w},h,_){if(Array.isArray(h.keyword)?!h.keyword.includes(_):h.keyword!==_)throw new Error("ajv implementation error");const f=h.dependencies;if(f?.some(m=>!Object.prototype.hasOwnProperty.call(g,m)))throw new Error(`parent schema must have dependencies of ${_}: ${f.join(",")}`);if(h.validateSchema&&!h.validateSchema(g[_])){const b=`keyword "${_}" value is invalid at path "${w}": `+p.errorsText(h.validateSchema.errors);if(v.validateSchema==="log")p.logger.error(b);else throw new Error(b)}}return ht.validateKeywordUsage=d,ht}var Ot={},wo;function vd(){if(wo)return Ot;wo=1,Object.defineProperty(Ot,"__esModule",{value:!0}),Ot.extendSubschemaMode=Ot.extendSubschemaData=Ot.getSubschema=void 0;const t=ce(),e=pe();function r(a,{keyword:i,schemaProp:o,schema:c,schemaPath:l,errSchemaPath:u,topSchemaRef:d}){if(i!==void 0&&c!==void 0)throw new Error('both "keyword" and "schema" passed, only one allowed');if(i!==void 0){const g=a.schema[i];return o===void 0?{schema:g,schemaPath:(0,t._)`${a.schemaPath}${(0,t.getProperty)(i)}`,errSchemaPath:`${a.errSchemaPath}/${i}`}:{schema:g[o],schemaPath:(0,t._)`${a.schemaPath}${(0,t.getProperty)(i)}${(0,t.getProperty)(o)}`,errSchemaPath:`${a.errSchemaPath}/${i}/${(0,e.escapeFragment)(o)}`}}if(c!==void 0){if(l===void 0||u===void 0||d===void 0)throw new Error('"schemaPath", "errSchemaPath" and "topSchemaRef" are required with "schema"');return{schema:c,schemaPath:l,topSchemaRef:d,errSchemaPath:u}}throw new Error('either "keyword" or "schema" must be passed')}Ot.getSubschema=r;function n(a,i,{dataProp:o,dataPropType:c,data:l,dataTypes:u,propertyName:d}){if(l!==void 0&&o!==void 0)throw new Error('both "data" and "dataProp" passed, only one allowed');const{gen:g}=i;if(o!==void 0){const{errorPath:p,dataPathArr:w,opts:h}=i,_=g.let("data",(0,t._)`${i.data}${(0,t.getProperty)(o)}`,!0);v(_),a.errorPath=(0,t.str)`${p}${(0,e.getErrorPath)(o,c,h.jsPropertySyntax)}`,a.parentDataProperty=(0,t._)`${o}`,a.dataPathArr=[...w,a.parentDataProperty]}if(l!==void 0){const p=l instanceof t.Name?l:g.let("data",l,!0);v(p),d!==void 0&&(a.propertyName=d)}u&&(a.dataTypes=u);function v(p){a.data=p,a.dataLevel=i.dataLevel+1,a.dataTypes=[],i.definedProperties=new Set,a.parentData=i.data,a.dataNames=[...i.dataNames,p]}}Ot.extendSubschemaData=n;function s(a,{jtdDiscriminator:i,jtdMetadata:o,compositeRule:c,createErrors:l,allErrors:u}){c!==void 0&&(a.compositeRule=c),l!==void 0&&(a.createErrors=l),u!==void 0&&(a.allErrors=u),a.jtdDiscriminator=i,a.jtdMetadata=o}return Ot.extendSubschemaMode=s,Ot}var Je={},fa,bo;function ko(){return bo||(bo=1,fa=function t(e,r){if(e===r)return!0;if(e&&r&&typeof e=="object"&&typeof r=="object"){if(e.constructor!==r.constructor)return!1;var n,s,a;if(Array.isArray(e)){if(n=e.length,n!=r.length)return!1;for(s=n;s--!==0;)if(!t(e[s],r[s]))return!1;return!0}if(e.constructor===RegExp)return e.source===r.source&&e.flags===r.flags;if(e.valueOf!==Object.prototype.valueOf)return e.valueOf()===r.valueOf();if(e.toString!==Object.prototype.toString)return e.toString()===r.toString();if(a=Object.keys(e),n=a.length,n!==Object.keys(r).length)return!1;for(s=n;s--!==0;)if(!Object.prototype.hasOwnProperty.call(r,a[s]))return!1;for(s=n;s--!==0;){var i=a[s];if(!t(e[i],r[i]))return!1}return!0}return e!==e&&r!==r}),fa}var ha={exports:{}},$o;function gd(){if($o)return ha.exports;$o=1;var t=ha.exports=function(n,s,a){typeof s=="function"&&(a=s,s={}),a=s.cb||a;var i=typeof a=="function"?a:a.pre||function(){},o=a.post||function(){};e(s,i,o,n,"",n)};t.keywords={additionalItems:!0,items:!0,contains:!0,additionalProperties:!0,propertyNames:!0,not:!0,if:!0,then:!0,else:!0},t.arrayKeywords={items:!0,allOf:!0,anyOf:!0,oneOf:!0},t.propsKeywords={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependencies:!0},t.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 e(n,s,a,i,o,c,l,u,d,g){if(i&&typeof i=="object"&&!Array.isArray(i)){s(i,o,c,l,u,d,g);for(var v in i){var p=i[v];if(Array.isArray(p)){if(v in t.arrayKeywords)for(var w=0;w<p.length;w++)e(n,s,a,p[w],o+"/"+v+"/"+w,c,o,v,i,w)}else if(v in t.propsKeywords){if(p&&typeof p=="object")for(var h in p)e(n,s,a,p[h],o+"/"+v+"/"+r(h),c,o,v,i,h)}else(v in t.keywords||n.allKeys&&!(v in t.skipKeywords))&&e(n,s,a,p,o+"/"+v,c,o,v,i)}a(i,o,c,l,u,d,g)}}function r(n){return n.replace(/~/g,"~0").replace(/\//g,"~1")}return ha.exports}var So;function Pn(){if(So)return Je;So=1,Object.defineProperty(Je,"__esModule",{value:!0}),Je.getSchemaRefs=Je.resolveUrl=Je.normalizeId=Je._getFullPath=Je.getFullPath=Je.inlineRef=void 0;const t=pe(),e=ko(),r=gd(),n=new Set(["type","format","pattern","maxLength","minLength","maxProperties","minProperties","maxItems","minItems","maximum","minimum","uniqueItems","multipleOf","required","enum","const"]);function s(w,h=!0){return typeof w=="boolean"?!0:h===!0?!i(w):h?o(w)<=h:!1}Je.inlineRef=s;const a=new Set(["$ref","$recursiveRef","$recursiveAnchor","$dynamicRef","$dynamicAnchor"]);function i(w){for(const h in w){if(a.has(h))return!0;const _=w[h];if(Array.isArray(_)&&_.some(i)||typeof _=="object"&&i(_))return!0}return!1}function o(w){let h=0;for(const _ in w){if(_==="$ref")return 1/0;if(h++,!n.has(_)&&(typeof w[_]=="object"&&(0,t.eachItem)(w[_],f=>h+=o(f)),h===1/0))return 1/0}return h}function c(w,h="",_){_!==!1&&(h=d(h));const f=w.parse(h);return l(w,f)}Je.getFullPath=c;function l(w,h){return w.serialize(h).split("#")[0]+"#"}Je._getFullPath=l;const u=/#\/?$/;function d(w){return w?w.replace(u,""):""}Je.normalizeId=d;function g(w,h,_){return _=d(_),w.resolve(h,_)}Je.resolveUrl=g;const v=/^[a-z_][-a-z0-9._]*$/i;function p(w,h){if(typeof w=="boolean")return{};const{schemaId:_,uriResolver:f}=this.opts,m=d(w[_]||h),b={"":m},y=c(f,m,!1),k={},S=new Set;return r(w,{allKeys:!0},(q,N,V,B)=>{if(B===void 0)return;const Y=y+N;let ve=b[B];typeof q[_]=="string"&&(ve=Ge.call(this,q[_])),Ye.call(this,q.$anchor),Ye.call(this,q.$dynamicAnchor),b[N]=ve;function Ge(be){const kt=this.opts.uriResolver.resolve;if(be=d(ve?kt(ve,be):be),S.has(be))throw C(be);S.add(be);let D=this.refs[be];return typeof D=="string"&&(D=this.refs[D]),typeof D=="object"?I(q,D.schema,be):be!==d(Y)&&(be[0]==="#"?(I(q,k[be],be),k[be]=q):this.refs[be]=Y),be}function Ye(be){if(typeof be=="string"){if(!v.test(be))throw new Error(`invalid anchor "${be}"`);Ge.call(this,`#${be}`)}}}),k;function I(q,N,V){if(N!==void 0&&!e(q,N))throw C(V)}function C(q){return new Error(`reference "${q}" resolves to more than one schema`)}}return Je.getSchemaRefs=p,Je}var To;function xn(){if(To)return It;To=1,Object.defineProperty(It,"__esModule",{value:!0}),It.getData=It.KeywordCxt=It.validateFunctionCode=void 0;const t=pd(),e=Rn(),r=mo(),n=Rn(),s=md(),a=_d(),i=vd(),o=ce(),c=Zt(),l=Pn(),u=pe(),d=En();function g(R){if(y(R)&&(S(R),b(R))){h(R);return}v(R,()=>(0,t.topBoolOrEmptySchema)(R))}It.validateFunctionCode=g;function v({gen:R,validateName:x,schema:z,schemaEnv:F,opts:ne},le){ne.code.es5?R.func(x,(0,o._)`${c.default.data}, ${c.default.valCxt}`,F.$async,()=>{R.code((0,o._)`"use strict"; ${f(z,ne)}`),w(R,ne),R.code(le)}):R.func(x,(0,o._)`${c.default.data}, ${p(ne)}`,F.$async,()=>R.code(f(z,ne)).code(le))}function p(R){return(0,o._)`{${c.default.instancePath}="", ${c.default.parentData}, ${c.default.parentDataProperty}, ${c.default.rootData}=${c.default.data}${R.dynamicRef?(0,o._)`, ${c.default.dynamicAnchors}={}`:o.nil}}={}`}function w(R,x){R.if(c.default.valCxt,()=>{R.var(c.default.instancePath,(0,o._)`${c.default.valCxt}.${c.default.instancePath}`),R.var(c.default.parentData,(0,o._)`${c.default.valCxt}.${c.default.parentData}`),R.var(c.default.parentDataProperty,(0,o._)`${c.default.valCxt}.${c.default.parentDataProperty}`),R.var(c.default.rootData,(0,o._)`${c.default.valCxt}.${c.default.rootData}`),x.dynamicRef&&R.var(c.default.dynamicAnchors,(0,o._)`${c.default.valCxt}.${c.default.dynamicAnchors}`)},()=>{R.var(c.default.instancePath,(0,o._)`""`),R.var(c.default.parentData,(0,o._)`undefined`),R.var(c.default.parentDataProperty,(0,o._)`undefined`),R.var(c.default.rootData,c.default.data),x.dynamicRef&&R.var(c.default.dynamicAnchors,(0,o._)`{}`)})}function h(R){const{schema:x,opts:z,gen:F}=R;v(R,()=>{z.$comment&&x.$comment&&B(R),q(R),F.let(c.default.vErrors,null),F.let(c.default.errors,0),z.unevaluated&&_(R),I(R),Y(R)})}function _(R){const{gen:x,validateName:z}=R;R.evaluated=x.const("evaluated",(0,o._)`${z}.evaluated`),x.if((0,o._)`${R.evaluated}.dynamicProps`,()=>x.assign((0,o._)`${R.evaluated}.props`,(0,o._)`undefined`)),x.if((0,o._)`${R.evaluated}.dynamicItems`,()=>x.assign((0,o._)`${R.evaluated}.items`,(0,o._)`undefined`))}function f(R,x){const z=typeof R=="object"&&R[x.schemaId];return z&&(x.code.source||x.code.process)?(0,o._)`/*# sourceURL=${z} */`:o.nil}function m(R,x){if(y(R)&&(S(R),b(R))){k(R,x);return}(0,t.boolOrEmptySchema)(R,x)}function b({schema:R,self:x}){if(typeof R=="boolean")return!R;for(const z in R)if(x.RULES.all[z])return!0;return!1}function y(R){return typeof R.schema!="boolean"}function k(R,x){const{schema:z,gen:F,opts:ne}=R;ne.$comment&&z.$comment&&B(R),N(R),V(R);const le=F.const("_errs",c.default.errors);I(R,le),F.var(x,(0,o._)`${le} === ${c.default.errors}`)}function S(R){(0,u.checkUnknownRules)(R),C(R)}function I(R,x){if(R.opts.jtd)return Ge(R,[],!1,x);const z=(0,e.getSchemaTypes)(R.schema),F=(0,e.coerceAndCheckDataType)(R,z);Ge(R,z,!F,x)}function C(R){const{schema:x,errSchemaPath:z,opts:F,self:ne}=R;x.$ref&&F.ignoreKeywordsWithRef&&(0,u.schemaHasRulesButRef)(x,ne.RULES)&&ne.logger.warn(`$ref: keywords ignored in schema at path "${z}"`)}function q(R){const{schema:x,opts:z}=R;x.default!==void 0&&z.useDefaults&&z.strictSchema&&(0,u.checkStrictMode)(R,"default is ignored in the schema root")}function N(R){const x=R.schema[R.opts.schemaId];x&&(R.baseId=(0,l.resolveUrl)(R.opts.uriResolver,R.baseId,x))}function V(R){if(R.schema.$async&&!R.schemaEnv.$async)throw new Error("async schema in sync schema")}function B({gen:R,schemaEnv:x,schema:z,errSchemaPath:F,opts:ne}){const le=z.$comment;if(ne.$comment===!0)R.code((0,o._)`${c.default.self}.logger.log(${le})`);else if(typeof ne.$comment=="function"){const De=(0,o.str)`${F}/$comment`,$t=R.scopeValue("root",{ref:x.root});R.code((0,o._)`${c.default.self}.opts.$comment(${le}, ${De}, ${$t}.schema)`)}}function Y(R){const{gen:x,schemaEnv:z,validateName:F,ValidationError:ne,opts:le}=R;z.$async?x.if((0,o._)`${c.default.errors} === 0`,()=>x.return(c.default.data),()=>x.throw((0,o._)`new ${ne}(${c.default.vErrors})`)):(x.assign((0,o._)`${F}.errors`,c.default.vErrors),le.unevaluated&&ve(R),x.return((0,o._)`${c.default.errors} === 0`))}function ve({gen:R,evaluated:x,props:z,items:F}){z instanceof o.Name&&R.assign((0,o._)`${x}.props`,z),F instanceof o.Name&&R.assign((0,o._)`${x}.items`,F)}function Ge(R,x,z,F){const{gen:ne,schema:le,data:De,allErrors:$t,opts:st,self:at}=R,{RULES:Ve}=at;if(le.$ref&&(st.ignoreKeywordsWithRef||!(0,u.schemaHasRulesButRef)(le,Ve))){ne.block(()=>ee(R,"$ref",Ve.all.$ref.definition));return}st.jtd||be(R,x),ne.block(()=>{for(const ft of Ve.rules)Or(ft);Or(Ve.post)});function Or(ft){(0,r.shouldUseGroup)(le,ft)&&(ft.type?(ne.if((0,n.checkDataType)(ft.type,De,st.strictNumbers)),Ye(R,ft),x.length===1&&x[0]===ft.type&&z&&(ne.else(),(0,n.reportTypeError)(R)),ne.endIf()):Ye(R,ft),$t||ne.if((0,o._)`${c.default.errors} === ${F||0}`))}}function Ye(R,x){const{gen:z,schema:F,opts:{useDefaults:ne}}=R;ne&&(0,s.assignDefaults)(R,x.type),z.block(()=>{for(const le of x.rules)(0,r.shouldUseRule)(F,le)&&ee(R,le.keyword,le.definition,x.type)})}function be(R,x){R.schemaEnv.meta||!R.opts.strictTypes||(kt(R,x),R.opts.allowUnionTypes||D(R,x),P(R,R.dataTypes))}function kt(R,x){if(x.length){if(!R.dataTypes.length){R.dataTypes=x;return}x.forEach(z=>{O(R.dataTypes,z)||T(R,`type "${z}" not allowed by context "${R.dataTypes.join(",")}"`)}),$(R,x)}}function D(R,x){x.length>1&&!(x.length===2&&x.includes("null"))&&T(R,"use allowUnionTypes to allow union type keyword")}function P(R,x){const z=R.self.RULES.all;for(const F in z){const ne=z[F];if(typeof ne=="object"&&(0,r.shouldUseRule)(R.schema,ne)){const{type:le}=ne.definition;le.length&&!le.some(De=>M(x,De))&&T(R,`missing type "${le.join(",")}" for keyword "${F}"`)}}}function M(R,x){return R.includes(x)||x==="number"&&R.includes("integer")}function O(R,x){return R.includes(x)||x==="integer"&&R.includes("number")}function $(R,x){const z=[];for(const F of R.dataTypes)O(x,F)?z.push(F):x.includes("integer")&&F==="number"&&z.push("integer");R.dataTypes=z}function T(R,x){const z=R.schemaEnv.baseId+R.errSchemaPath;x+=` at "${z}" (strictTypes)`,(0,u.checkStrictMode)(R,x,R.opts.strictTypes)}class j{constructor(x,z,F){if((0,a.validateKeywordUsage)(x,z,F),this.gen=x.gen,this.allErrors=x.allErrors,this.keyword=F,this.data=x.data,this.schema=x.schema[F],this.$data=z.$data&&x.opts.$data&&this.schema&&this.schema.$data,this.schemaValue=(0,u.schemaRefOrVal)(x,this.schema,F,this.$data),this.schemaType=z.schemaType,this.parentSchema=x.schema,this.params={},this.it=x,this.def=z,this.$data)this.schemaCode=x.gen.const("vSchema",he(this.$data,x));else if(this.schemaCode=this.schemaValue,!(0,a.validSchemaType)(this.schema,z.schemaType,z.allowUndefined))throw new Error(`${F} value must be ${JSON.stringify(z.schemaType)}`);("code"in z?z.trackErrors:z.errors!==!1)&&(this.errsCount=x.gen.const("_errs",c.default.errors))}result(x,z,F){this.failResult((0,o.not)(x),z,F)}failResult(x,z,F){this.gen.if(x),F?F():this.error(),z?(this.gen.else(),z(),this.allErrors&&this.gen.endIf()):this.allErrors?this.gen.endIf():this.gen.else()}pass(x,z){this.failResult((0,o.not)(x),void 0,z)}fail(x){if(x===void 0){this.error(),this.allErrors||this.gen.if(!1);return}this.gen.if(x),this.error(),this.allErrors?this.gen.endIf():this.gen.else()}fail$data(x){if(!this.$data)return this.fail(x);const{schemaCode:z}=this;this.fail((0,o._)`${z} !== undefined && (${(0,o.or)(this.invalid$data(),x)})`)}error(x,z,F){if(z){this.setParams(z),this._error(x,F),this.setParams({});return}this._error(x,F)}_error(x,z){(x?d.reportExtraError:d.reportError)(this,this.def.error,z)}$dataError(){(0,d.reportError)(this,this.def.$dataError||d.keyword$DataError)}reset(){if(this.errsCount===void 0)throw new Error('add "trackErrors" to keyword definition');(0,d.resetErrorsCount)(this.gen,this.errsCount)}ok(x){this.allErrors||this.gen.if(x)}setParams(x,z){z?Object.assign(this.params,x):this.params=x}block$data(x,z,F=o.nil){this.gen.block(()=>{this.check$data(x,F),z()})}check$data(x=o.nil,z=o.nil){if(!this.$data)return;const{gen:F,schemaCode:ne,schemaType:le,def:De}=this;F.if((0,o.or)((0,o._)`${ne} === undefined`,z)),x!==o.nil&&F.assign(x,!0),(le.length||De.validateSchema)&&(F.elseIf(this.invalid$data()),this.$dataError(),x!==o.nil&&F.assign(x,!1)),F.else()}invalid$data(){const{gen:x,schemaCode:z,schemaType:F,def:ne,it:le}=this;return(0,o.or)(De(),$t());function De(){if(F.length){if(!(z instanceof o.Name))throw new Error("ajv implementation error");const st=Array.isArray(F)?F:[F];return(0,o._)`${(0,n.checkDataTypes)(st,z,le.opts.strictNumbers,n.DataType.Wrong)}`}return o.nil}function $t(){if(ne.validateSchema){const st=x.scopeValue("validate$data",{ref:ne.validateSchema});return(0,o._)`!${st}(${z})`}return o.nil}}subschema(x,z){const F=(0,i.getSubschema)(this.it,x);(0,i.extendSubschemaData)(F,this.it,x),(0,i.extendSubschemaMode)(F,x);const ne={...this.it,...F,items:void 0,props:void 0};return m(ne,z),ne}mergeEvaluated(x,z){const{it:F,gen:ne}=this;F.opts.unevaluated&&(F.props!==!0&&x.props!==void 0&&(F.props=u.mergeEvaluated.props(ne,x.props,F.props,z)),F.items!==!0&&x.items!==void 0&&(F.items=u.mergeEvaluated.items(ne,x.items,F.items,z)))}mergeValidEvaluated(x,z){const{it:F,gen:ne}=this;if(F.opts.unevaluated&&(F.props!==!0||F.items!==!0))return ne.if(z,()=>this.mergeEvaluated(x,o.Name)),!0}}It.KeywordCxt=j;function ee(R,x,z,F){const ne=new j(R,z,x);"code"in z?z.code(ne,F):ne.$data&&z.validate?(0,a.funcKeywordCode)(ne,z):"macro"in z?(0,a.macroKeywordCode)(ne,z):(z.compile||z.validate)&&(0,a.funcKeywordCode)(ne,z)}const se=/^\/(?:[^~]|~0|~1)*$/,_e=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function he(R,{dataLevel:x,dataNames:z,dataPathArr:F}){let ne,le;if(R==="")return c.default.rootData;if(R[0]==="/"){if(!se.test(R))throw new Error(`Invalid JSON-pointer: ${R}`);ne=R,le=c.default.rootData}else{const at=_e.exec(R);if(!at)throw new Error(`Invalid JSON-pointer: ${R}`);const Ve=+at[1];if(ne=at[2],ne==="#"){if(Ve>=x)throw new Error(st("property/index",Ve));return F[x-Ve]}if(Ve>x)throw new Error(st("data",Ve));if(le=z[x-Ve],!ne)return le}let De=le;const $t=ne.split("/");for(const at of $t)at&&(le=(0,o._)`${le}${(0,o.getProperty)((0,u.unescapeJsonPointer)(at))}`,De=(0,o._)`${De} && ${le}`);return De;function st(at,Ve){return`Cannot access ${at} ${Ve} levels up, current level is ${x}`}}return It.getData=he,It}var In={},Eo;function pa(){if(Eo)return In;Eo=1,Object.defineProperty(In,"__esModule",{value:!0});class t extends Error{constructor(r){super("validation failed"),this.errors=r,this.ajv=this.validation=!0}}return In.default=t,In}var Cn={},Ro;function On(){if(Ro)return Cn;Ro=1,Object.defineProperty(Cn,"__esModule",{value:!0});const t=Pn();class e extends Error{constructor(n,s,a,i){super(i||`can't resolve reference ${a} from id ${s}`),this.missingRef=(0,t.resolveUrl)(n,s,a),this.missingSchema=(0,t.normalizeId)((0,t.getFullPath)(n,this.missingRef))}}return Cn.default=e,Cn}var it={},Po;function ma(){if(Po)return it;Po=1,Object.defineProperty(it,"__esModule",{value:!0}),it.resolveSchema=it.getCompilingSchema=it.resolveRef=it.compileSchema=it.SchemaEnv=void 0;const t=ce(),e=pa(),r=Zt(),n=Pn(),s=pe(),a=xn();class i{constructor(_){var f;this.refs={},this.dynamicAnchors={};let m;typeof _.schema=="object"&&(m=_.schema),this.schema=_.schema,this.schemaId=_.schemaId,this.root=_.root||this,this.baseId=(f=_.baseId)!==null&&f!==void 0?f:(0,n.normalizeId)(m?.[_.schemaId||"$id"]),this.schemaPath=_.schemaPath,this.localRefs=_.localRefs,this.meta=_.meta,this.$async=m?.$async,this.refs={}}}it.SchemaEnv=i;function o(h){const _=u.call(this,h);if(_)return _;const f=(0,n.getFullPath)(this.opts.uriResolver,h.root.baseId),{es5:m,lines:b}=this.opts.code,{ownProperties:y}=this.opts,k=new t.CodeGen(this.scope,{es5:m,lines:b,ownProperties:y});let S;h.$async&&(S=k.scopeValue("Error",{ref:e.default,code:(0,t._)`require("ajv/dist/runtime/validation_error").default`}));const I=k.scopeName("validate");h.validateName=I;const C={gen:k,allErrors:this.opts.allErrors,data:r.default.data,parentData:r.default.parentData,parentDataProperty:r.default.parentDataProperty,dataNames:[r.default.data],dataPathArr:[t.nil],dataLevel:0,dataTypes:[],definedProperties:new Set,topSchemaRef:k.scopeValue("schema",this.opts.code.source===!0?{ref:h.schema,code:(0,t.stringify)(h.schema)}:{ref:h.schema}),validateName:I,ValidationError:S,schema:h.schema,schemaEnv:h,rootId:f,baseId:h.baseId||f,schemaPath:t.nil,errSchemaPath:h.schemaPath||(this.opts.jtd?"":"#"),errorPath:(0,t._)`""`,opts:this.opts,self:this};let q;try{this._compilations.add(h),(0,a.validateFunctionCode)(C),k.optimize(this.opts.code.optimize);const N=k.toString();q=`${k.scopeRefs(r.default.scope)}return ${N}`,this.opts.code.process&&(q=this.opts.code.process(q,h));const B=new Function(`${r.default.self}`,`${r.default.scope}`,q)(this,this.scope.get());if(this.scope.value(I,{ref:B}),B.errors=null,B.schema=h.schema,B.schemaEnv=h,h.$async&&(B.$async=!0),this.opts.code.source===!0&&(B.source={validateName:I,validateCode:N,scopeValues:k._values}),this.opts.unevaluated){const{props:Y,items:ve}=C;B.evaluated={props:Y instanceof t.Name?void 0:Y,items:ve instanceof t.Name?void 0:ve,dynamicProps:Y instanceof t.Name,dynamicItems:ve instanceof t.Name},B.source&&(B.source.evaluated=(0,t.stringify)(B.evaluated))}return h.validate=B,h}catch(N){throw delete h.validate,delete h.validateName,q&&this.logger.error("Error compiling schema, function code:",q),N}finally{this._compilations.delete(h)}}it.compileSchema=o;function c(h,_,f){var m;f=(0,n.resolveUrl)(this.opts.uriResolver,_,f);const b=h.refs[f];if(b)return b;let y=g.call(this,h,f);if(y===void 0){const k=(m=h.localRefs)===null||m===void 0?void 0:m[f],{schemaId:S}=this.opts;k&&(y=new i({schema:k,schemaId:S,root:h,baseId:_}))}if(y!==void 0)return h.refs[f]=l.call(this,y)}it.resolveRef=c;function l(h){return(0,n.inlineRef)(h.schema,this.opts.inlineRefs)?h.schema:h.validate?h:o.call(this,h)}function u(h){for(const _ of this._compilations)if(d(_,h))return _}it.getCompilingSchema=u;function d(h,_){return h.schema===_.schema&&h.root===_.root&&h.baseId===_.baseId}function g(h,_){let f;for(;typeof(f=this.refs[_])=="string";)_=f;return f||this.schemas[_]||v.call(this,h,_)}function v(h,_){const f=this.opts.uriResolver.parse(_),m=(0,n._getFullPath)(this.opts.uriResolver,f);let b=(0,n.getFullPath)(this.opts.uriResolver,h.baseId,void 0);if(Object.keys(h.schema).length>0&&m===b)return w.call(this,f,h);const y=(0,n.normalizeId)(m),k=this.refs[y]||this.schemas[y];if(typeof k=="string"){const S=v.call(this,h,k);return typeof S?.schema!="object"?void 0:w.call(this,f,S)}if(typeof k?.schema=="object"){if(k.validate||o.call(this,k),y===(0,n.normalizeId)(_)){const{schema:S}=k,{schemaId:I}=this.opts,C=S[I];return C&&(b=(0,n.resolveUrl)(this.opts.uriResolver,b,C)),new i({schema:S,schemaId:I,root:h,baseId:b})}return w.call(this,f,k)}}it.resolveSchema=v;const p=new Set(["properties","patternProperties","enum","dependencies","definitions"]);function w(h,{baseId:_,schema:f,root:m}){var b;if(((b=h.fragment)===null||b===void 0?void 0:b[0])!=="/")return;for(const S of h.fragment.slice(1).split("/")){if(typeof f=="boolean")return;const I=f[(0,s.unescapeFragment)(S)];if(I===void 0)return;f=I;const C=typeof f=="object"&&f[this.opts.schemaId];!p.has(S)&&C&&(_=(0,n.resolveUrl)(this.opts.uriResolver,_,C))}let y;if(typeof f!="boolean"&&f.$ref&&!(0,s.schemaHasRulesButRef)(f,this.RULES)){const S=(0,n.resolveUrl)(this.opts.uriResolver,_,f.$ref);y=v.call(this,m,S)}const{schemaId:k}=this.opts;if(y=y||new i({schema:f,schemaId:k,root:m,baseId:_}),y.schema!==y.root.schema)return y}return it}const yd={$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 Nn={},Ar={exports:{}},_a,xo;function Io(){if(xo)return _a;xo=1;const t=RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu),e=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 r(g){let v="",p=0,w=0;for(w=0;w<g.length;w++)if(p=g[w].charCodeAt(0),p!==48){if(!(p>=48&&p<=57||p>=65&&p<=70||p>=97&&p<=102))return"";v+=g[w];break}for(w+=1;w<g.length;w++){if(p=g[w].charCodeAt(0),!(p>=48&&p<=57||p>=65&&p<=70||p>=97&&p<=102))return"";v+=g[w]}return v}const n=RegExp.prototype.test.bind(/[^!"$&'()*+,\-.;=_`a-z{}~]/u);function s(g){return g.length=0,!0}function a(g,v,p){if(g.length){const w=r(g);if(w!=="")v.push(w);else return p.error=!0,!1;g.length=0}return!0}function i(g){let v=0;const p={error:!1,address:"",zone:""},w=[],h=[];let _=!1,f=!1,m=a;for(let b=0;b<g.length;b++){const y=g[b];if(!(y==="["||y==="]"))if(y===":"){if(_===!0&&(f=!0),!m(h,w,p))break;if(++v>7){p.error=!0;break}b>0&&g[b-1]===":"&&(_=!0),w.push(":");continue}else if(y==="%"){if(!m(h,w,p))break;m=s}else{h.push(y);continue}}return h.length&&(m===s?p.zone=h.join(""):f?w.push(h.join("")):w.push(r(h))),p.address=w.join(""),p}function o(g){if(c(g,":")<2)return{host:g,isIPV6:!1};const v=i(g);if(v.error)return{host:g,isIPV6:!1};{let p=v.address,w=v.address;return v.zone&&(p+="%"+v.zone,w+="%25"+v.zone),{host:p,isIPV6:!0,escapedHost:w}}}function c(g,v){let p=0;for(let w=0;w<g.length;w++)g[w]===v&&p++;return p}function l(g){let v=g;const p=[];let w=-1,h=0;for(;h=v.length;){if(h===1){if(v===".")break;if(v==="/"){p.push("/");break}else{p.push(v);break}}else if(h===2){if(v[0]==="."){if(v[1]===".")break;if(v[1]==="/"){v=v.slice(2);continue}}else if(v[0]==="/"&&(v[1]==="."||v[1]==="/")){p.push("/");break}}else if(h===3&&v==="/.."){p.length!==0&&p.pop(),p.push("/");break}if(v[0]==="."){if(v[1]==="."){if(v[2]==="/"){v=v.slice(3);continue}}else if(v[1]==="/"){v=v.slice(2);continue}}else if(v[0]==="/"&&v[1]==="."){if(v[2]==="/"){v=v.slice(2);continue}else if(v[2]==="."&&v[3]==="/"){v=v.slice(3),p.length!==0&&p.pop();continue}}if((w=v.indexOf("/",1))===-1){p.push(v);break}else p.push(v.slice(0,w)),v=v.slice(w)}return p.join("")}function u(g,v){const p=v!==!0?escape:unescape;return g.scheme!==void 0&&(g.scheme=p(g.scheme)),g.userinfo!==void 0&&(g.userinfo=p(g.userinfo)),g.host!==void 0&&(g.host=p(g.host)),g.path!==void 0&&(g.path=p(g.path)),g.query!==void 0&&(g.query=p(g.query)),g.fragment!==void 0&&(g.fragment=p(g.fragment)),g}function d(g){const v=[];if(g.userinfo!==void 0&&(v.push(g.userinfo),v.push("@")),g.host!==void 0){let p=unescape(g.host);if(!e(p)){const w=o(p);w.isIPV6===!0?p=`[${w.escapedHost}]`:p=g.host}v.push(p)}return(typeof g.port=="number"||typeof g.port=="string")&&(v.push(":"),v.push(String(g.port))),v.length?v.join(""):void 0}return _a={nonSimpleDomain:n,recomposeAuthority:d,normalizeComponentEncoding:u,removeDotSegments:l,isIPv4:e,isUUID:t,normalizeIPv6:o,stringArrayToHexStripped:r},_a}var va,Co;function wd(){if(Co)return va;Co=1;const{isUUID:t}=Io(),e=/([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-.:;=@]|%[\da-f]{2})+)/iu,r=["http","https","ws","wss","urn","urn:uuid"];function n(y){return r.indexOf(y)!==-1}function s(y){return y.secure===!0?!0:y.secure===!1?!1:y.scheme?y.scheme.length===3&&(y.scheme[0]==="w"||y.scheme[0]==="W")&&(y.scheme[1]==="s"||y.scheme[1]==="S")&&(y.scheme[2]==="s"||y.scheme[2]==="S"):!1}function a(y){return y.host||(y.error=y.error||"HTTP URIs must have a host."),y}function i(y){const k=String(y.scheme).toLowerCase()==="https";return(y.port===(k?443:80)||y.port==="")&&(y.port=void 0),y.path||(y.path="/"),y}function o(y){return y.secure=s(y),y.resourceName=(y.path||"/")+(y.query?"?"+y.query:""),y.path=void 0,y.query=void 0,y}function c(y){if((y.port===(s(y)?443:80)||y.port==="")&&(y.port=void 0),typeof y.secure=="boolean"&&(y.scheme=y.secure?"wss":"ws",y.secure=void 0),y.resourceName){const[k,S]=y.resourceName.split("?");y.path=k&&k!=="/"?k:void 0,y.query=S,y.resourceName=void 0}return y.fragment=void 0,y}function l(y,k){if(!y.path)return y.error="URN can not be parsed",y;const S=y.path.match(e);if(S){const I=k.scheme||y.scheme||"urn";y.nid=S[1].toLowerCase(),y.nss=S[2];const C=`${I}:${k.nid||y.nid}`,q=b(C);y.path=void 0,q&&(y=q.parse(y,k))}else y.error=y.error||"URN can not be parsed.";return y}function u(y,k){if(y.nid===void 0)throw new Error("URN without nid cannot be serialized");const S=k.scheme||y.scheme||"urn",I=y.nid.toLowerCase(),C=`${S}:${k.nid||I}`,q=b(C);q&&(y=q.serialize(y,k));const N=y,V=y.nss;return N.path=`${I||k.nid}:${V}`,k.skipEscape=!0,N}function d(y,k){const S=y;return S.uuid=S.nss,S.nss=void 0,!k.tolerant&&(!S.uuid||!t(S.uuid))&&(S.error=S.error||"UUID is not valid."),S}function g(y){const k=y;return k.nss=(y.uuid||"").toLowerCase(),k}const v={scheme:"http",domainHost:!0,parse:a,serialize:i},p={scheme:"https",domainHost:v.domainHost,parse:a,serialize:i},w={scheme:"ws",domainHost:!0,parse:o,serialize:c},h={scheme:"wss",domainHost:w.domainHost,parse:w.parse,serialize:w.serialize},m={http:v,https:p,ws:w,wss:h,urn:{scheme:"urn",parse:l,serialize:u,skipNormalize:!0},"urn:uuid":{scheme:"urn:uuid",parse:d,serialize:g,skipNormalize:!0}};Object.setPrototypeOf(m,null);function b(y){return y&&(m[y]||m[y.toLowerCase()])||void 0}return va={wsIsSecure:s,SCHEMES:m,isValidSchemeName:n,getSchemeHandler:b},va}var Oo;function bd(){if(Oo)return Ar.exports;Oo=1;const{normalizeIPv6:t,removeDotSegments:e,recomposeAuthority:r,normalizeComponentEncoding:n,isIPv4:s,nonSimpleDomain:a}=Io(),{SCHEMES:i,getSchemeHandler:o}=wd();function c(h,_){return typeof h=="string"?h=g(p(h,_),_):typeof h=="object"&&(h=p(g(h,_),_)),h}function l(h,_,f){const m=f?Object.assign({scheme:"null"},f):{scheme:"null"},b=u(p(h,m),p(_,m),m,!0);return m.skipEscape=!0,g(b,m)}function u(h,_,f,m){const b={};return m||(h=p(g(h,f),f),_=p(g(_,f),f)),f=f||{},!f.tolerant&&_.scheme?(b.scheme=_.scheme,b.userinfo=_.userinfo,b.host=_.host,b.port=_.port,b.path=e(_.path||""),b.query=_.query):(_.userinfo!==void 0||_.host!==void 0||_.port!==void 0?(b.userinfo=_.userinfo,b.host=_.host,b.port=_.port,b.path=e(_.path||""),b.query=_.query):(_.path?(_.path[0]==="/"?b.path=e(_.path):((h.userinfo!==void 0||h.host!==void 0||h.port!==void 0)&&!h.path?b.path="/"+_.path:h.path?b.path=h.path.slice(0,h.path.lastIndexOf("/")+1)+_.path:b.path=_.path,b.path=e(b.path)),b.query=_.query):(b.path=h.path,_.query!==void 0?b.query=_.query:b.query=h.query),b.userinfo=h.userinfo,b.host=h.host,b.port=h.port),b.scheme=h.scheme),b.fragment=_.fragment,b}function d(h,_,f){return typeof h=="string"?(h=unescape(h),h=g(n(p(h,f),!0),{...f,skipEscape:!0})):typeof h=="object"&&(h=g(n(h,!0),{...f,skipEscape:!0})),typeof _=="string"?(_=unescape(_),_=g(n(p(_,f),!0),{...f,skipEscape:!0})):typeof _=="object"&&(_=g(n(_,!0),{...f,skipEscape:!0})),h.toLowerCase()===_.toLowerCase()}function g(h,_){const f={host:h.host,scheme:h.scheme,userinfo:h.userinfo,port:h.port,path:h.path,query:h.query,nid:h.nid,nss:h.nss,uuid:h.uuid,fragment:h.fragment,reference:h.reference,resourceName:h.resourceName,secure:h.secure,error:""},m=Object.assign({},_),b=[],y=o(m.scheme||f.scheme);y&&y.serialize&&y.serialize(f,m),f.path!==void 0&&(m.skipEscape?f.path=unescape(f.path):(f.path=escape(f.path),f.scheme!==void 0&&(f.path=f.path.split("%3A").join(":")))),m.reference!=="suffix"&&f.scheme&&b.push(f.scheme,":");const k=r(f);if(k!==void 0&&(m.reference!=="suffix"&&b.push("//"),b.push(k),f.path&&f.path[0]!=="/"&&b.push("/")),f.path!==void 0){let S=f.path;!m.absolutePath&&(!y||!y.absolutePath)&&(S=e(S)),k===void 0&&S[0]==="/"&&S[1]==="/"&&(S="/%2F"+S.slice(2)),b.push(S)}return f.query!==void 0&&b.push("?",f.query),f.fragment!==void 0&&b.push("#",f.fragment),b.join("")}const v=/^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u;function p(h,_){const f=Object.assign({},_),m={scheme:void 0,userinfo:void 0,host:"",port:void 0,path:"",query:void 0,fragment:void 0};let b=!1;f.reference==="suffix"&&(f.scheme?h=f.scheme+":"+h:h="//"+h);const y=h.match(v);if(y){if(m.scheme=y[1],m.userinfo=y[3],m.host=y[4],m.port=parseInt(y[5],10),m.path=y[6]||"",m.query=y[7],m.fragment=y[8],isNaN(m.port)&&(m.port=y[5]),m.host)if(s(m.host)===!1){const I=t(m.host);m.host=I.host.toLowerCase(),b=I.isIPV6}else b=!0;m.scheme===void 0&&m.userinfo===void 0&&m.host===void 0&&m.port===void 0&&m.query===void 0&&!m.path?m.reference="same-document":m.scheme===void 0?m.reference="relative":m.fragment===void 0?m.reference="absolute":m.reference="uri",f.reference&&f.reference!=="suffix"&&f.reference!==m.reference&&(m.error=m.error||"URI is not a "+f.reference+" reference.");const k=o(f.scheme||m.scheme);if(!f.unicodeSupport&&(!k||!k.unicodeSupport)&&m.host&&(f.domainHost||k&&k.domainHost)&&b===!1&&a(m.host))try{m.host=URL.domainToASCII(m.host.toLowerCase())}catch(S){m.error=m.error||"Host's domain name can not be converted to ASCII: "+S}(!k||k&&!k.skipNormalize)&&(h.indexOf("%")!==-1&&(m.scheme!==void 0&&(m.scheme=unescape(m.scheme)),m.host!==void 0&&(m.host=unescape(m.host))),m.path&&(m.path=escape(unescape(m.path))),m.fragment&&(m.fragment=encodeURI(decodeURIComponent(m.fragment)))),k&&k.parse&&k.parse(m,f)}else m.error=m.error||"URI can not be parsed.";return m}const w={SCHEMES:i,normalize:c,resolve:l,resolveComponent:u,equal:d,serialize:g,parse:p};return Ar.exports=w,Ar.exports.default=w,Ar.exports.fastUri=w,Ar.exports}var No;function kd(){if(No)return Nn;No=1,Object.defineProperty(Nn,"__esModule",{value:!0});const t=bd();return t.code='require("ajv/dist/runtime/uri").default',Nn.default=t,Nn}var Ao;function $d(){return Ao||(Ao=1,(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.CodeGen=t.Name=t.nil=t.stringify=t.str=t._=t.KeywordCxt=void 0;var e=xn();Object.defineProperty(t,"KeywordCxt",{enumerable:!0,get:function(){return e.KeywordCxt}});var r=ce();Object.defineProperty(t,"_",{enumerable:!0,get:function(){return r._}}),Object.defineProperty(t,"str",{enumerable:!0,get:function(){return r.str}}),Object.defineProperty(t,"stringify",{enumerable:!0,get:function(){return r.stringify}}),Object.defineProperty(t,"nil",{enumerable:!0,get:function(){return r.nil}}),Object.defineProperty(t,"Name",{enumerable:!0,get:function(){return r.Name}}),Object.defineProperty(t,"CodeGen",{enumerable:!0,get:function(){return r.CodeGen}});const n=pa(),s=On(),a=ho(),i=ma(),o=ce(),c=Pn(),l=Rn(),u=pe(),d=yd,g=kd(),v=(D,P)=>new RegExp(D,P);v.code="new RegExp";const p=["removeAdditional","useDefaults","coerceTypes"],w=new Set(["validate","serialize","parse","wrapper","root","schema","keyword","pattern","formats","validate$data","func","obj","Error"]),h={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."},_={ignoreKeywordsWithRef:"",jsPropertySyntax:"",unicode:'"minLength"/"maxLength" account for unicode characters by default.'},f=200;function m(D){var P,M,O,$,T,j,ee,se,_e,he,R,x,z,F,ne,le,De,$t,st,at,Ve,Or,ft,eo,to;const kn=D.strict,ro=(P=D.code)===null||P===void 0?void 0:P.optimize,fd=ro===!0||ro===void 0?1:ro||0,hd=(O=(M=D.code)===null||M===void 0?void 0:M.regExp)!==null&&O!==void 0?O:v,iw=($=D.uriResolver)!==null&&$!==void 0?$:g.default;return{strictSchema:(j=(T=D.strictSchema)!==null&&T!==void 0?T:kn)!==null&&j!==void 0?j:!0,strictNumbers:(se=(ee=D.strictNumbers)!==null&&ee!==void 0?ee:kn)!==null&&se!==void 0?se:!0,strictTypes:(he=(_e=D.strictTypes)!==null&&_e!==void 0?_e:kn)!==null&&he!==void 0?he:"log",strictTuples:(x=(R=D.strictTuples)!==null&&R!==void 0?R:kn)!==null&&x!==void 0?x:"log",strictRequired:(F=(z=D.strictRequired)!==null&&z!==void 0?z:kn)!==null&&F!==void 0?F:!1,code:D.code?{...D.code,optimize:fd,regExp:hd}:{optimize:fd,regExp:hd},loopRequired:(ne=D.loopRequired)!==null&&ne!==void 0?ne:f,loopEnum:(le=D.loopEnum)!==null&&le!==void 0?le:f,meta:(De=D.meta)!==null&&De!==void 0?De:!0,messages:($t=D.messages)!==null&&$t!==void 0?$t:!0,inlineRefs:(st=D.inlineRefs)!==null&&st!==void 0?st:!0,schemaId:(at=D.schemaId)!==null&&at!==void 0?at:"$id",addUsedSchema:(Ve=D.addUsedSchema)!==null&&Ve!==void 0?Ve:!0,validateSchema:(Or=D.validateSchema)!==null&&Or!==void 0?Or:!0,validateFormats:(ft=D.validateFormats)!==null&&ft!==void 0?ft:!0,unicodeRegExp:(eo=D.unicodeRegExp)!==null&&eo!==void 0?eo:!0,int32range:(to=D.int32range)!==null&&to!==void 0?to:!0,uriResolver:iw}}class b{constructor(P={}){this.schemas={},this.refs={},this.formats={},this._compilations=new Set,this._loading={},this._cache=new Map,P=this.opts={...P,...m(P)};const{es5:M,lines:O}=this.opts.code;this.scope=new o.ValueScope({scope:{},prefixes:w,es5:M,lines:O}),this.logger=V(P.logger);const $=P.validateFormats;P.validateFormats=!1,this.RULES=(0,a.getRules)(),y.call(this,h,P,"NOT SUPPORTED"),y.call(this,_,P,"DEPRECATED","warn"),this._metaOpts=q.call(this),P.formats&&I.call(this),this._addVocabularies(),this._addDefaultMetaSchema(),P.keywords&&C.call(this,P.keywords),typeof P.meta=="object"&&this.addMetaSchema(P.meta),S.call(this),P.validateFormats=$}_addVocabularies(){this.addKeyword("$async")}_addDefaultMetaSchema(){const{$data:P,meta:M,schemaId:O}=this.opts;let $=d;O==="id"&&($={...d},$.id=$.$id,delete $.$id),M&&P&&this.addMetaSchema($,$[O],!1)}defaultMeta(){const{meta:P,schemaId:M}=this.opts;return this.opts.defaultMeta=typeof P=="object"?P[M]||P:void 0}validate(P,M){let O;if(typeof P=="string"){if(O=this.getSchema(P),!O)throw new Error(`no schema with key or ref "${P}"`)}else O=this.compile(P);const $=O(M);return"$async"in O||(this.errors=O.errors),$}compile(P,M){const O=this._addSchema(P,M);return O.validate||this._compileSchemaEnv(O)}compileAsync(P,M){if(typeof this.opts.loadSchema!="function")throw new Error("options.loadSchema should be a function");const{loadSchema:O}=this.opts;return $.call(this,P,M);async function $(he,R){await T.call(this,he.$schema);const x=this._addSchema(he,R);return x.validate||j.call(this,x)}async function T(he){he&&!this.getSchema(he)&&await $.call(this,{$ref:he},!0)}async function j(he){try{return this._compileSchemaEnv(he)}catch(R){if(!(R instanceof s.default))throw R;return ee.call(this,R),await se.call(this,R.missingSchema),j.call(this,he)}}function ee({missingSchema:he,missingRef:R}){if(this.refs[he])throw new Error(`AnySchema ${he} is loaded but ${R} cannot be resolved`)}async function se(he){const R=await _e.call(this,he);this.refs[he]||await T.call(this,R.$schema),this.refs[he]||this.addSchema(R,he,M)}async function _e(he){const R=this._loading[he];if(R)return R;try{return await(this._loading[he]=O(he))}finally{delete this._loading[he]}}}addSchema(P,M,O,$=this.opts.validateSchema){if(Array.isArray(P)){for(const j of P)this.addSchema(j,void 0,O,$);return this}let T;if(typeof P=="object"){const{schemaId:j}=this.opts;if(T=P[j],T!==void 0&&typeof T!="string")throw new Error(`schema ${j} must be string`)}return M=(0,c.normalizeId)(M||T),this._checkUnique(M),this.schemas[M]=this._addSchema(P,O,M,$,!0),this}addMetaSchema(P,M,O=this.opts.validateSchema){return this.addSchema(P,M,!0,O),this}validateSchema(P,M){if(typeof P=="boolean")return!0;let O;if(O=P.$schema,O!==void 0&&typeof O!="string")throw new Error("$schema must be a string");if(O=O||this.opts.defaultMeta||this.defaultMeta(),!O)return this.logger.warn("meta-schema not available"),this.errors=null,!0;const $=this.validate(O,P);if(!$&&M){const T="schema is invalid: "+this.errorsText();if(this.opts.validateSchema==="log")this.logger.error(T);else throw new Error(T)}return $}getSchema(P){let M;for(;typeof(M=k.call(this,P))=="string";)P=M;if(M===void 0){const{schemaId:O}=this.opts,$=new i.SchemaEnv({schema:{},schemaId:O});if(M=i.resolveSchema.call(this,$,P),!M)return;this.refs[P]=M}return M.validate||this._compileSchemaEnv(M)}removeSchema(P){if(P instanceof RegExp)return this._removeAllSchemas(this.schemas,P),this._removeAllSchemas(this.refs,P),this;switch(typeof P){case"undefined":return this._removeAllSchemas(this.schemas),this._removeAllSchemas(this.refs),this._cache.clear(),this;case"string":{const M=k.call(this,P);return typeof M=="object"&&this._cache.delete(M.schema),delete this.schemas[P],delete this.refs[P],this}case"object":{const M=P;this._cache.delete(M);let O=P[this.opts.schemaId];return O&&(O=(0,c.normalizeId)(O),delete this.schemas[O],delete this.refs[O]),this}default:throw new Error("ajv.removeSchema: invalid parameter")}}addVocabulary(P){for(const M of P)this.addKeyword(M);return this}addKeyword(P,M){let O;if(typeof P=="string")O=P,typeof M=="object"&&(this.logger.warn("these parameters are deprecated, see docs for addKeyword"),M.keyword=O);else if(typeof P=="object"&&M===void 0){if(M=P,O=M.keyword,Array.isArray(O)&&!O.length)throw new Error("addKeywords: keyword must be string or non-empty array")}else throw new Error("invalid addKeywords parameters");if(Y.call(this,O,M),!M)return(0,u.eachItem)(O,T=>ve.call(this,T)),this;Ye.call(this,M);const $={...M,type:(0,l.getJSONTypes)(M.type),schemaType:(0,l.getJSONTypes)(M.schemaType)};return(0,u.eachItem)(O,$.type.length===0?T=>ve.call(this,T,$):T=>$.type.forEach(j=>ve.call(this,T,$,j))),this}getKeyword(P){const M=this.RULES.all[P];return typeof M=="object"?M.definition:!!M}removeKeyword(P){const{RULES:M}=this;delete M.keywords[P],delete M.all[P];for(const O of M.rules){const $=O.rules.findIndex(T=>T.keyword===P);$>=0&&O.rules.splice($,1)}return this}addFormat(P,M){return typeof M=="string"&&(M=new RegExp(M)),this.formats[P]=M,this}errorsText(P=this.errors,{separator:M=", ",dataVar:O="data"}={}){return!P||P.length===0?"No errors":P.map($=>`${O}${$.instancePath} ${$.message}`).reduce(($,T)=>$+M+T)}$dataMetaSchema(P,M){const O=this.RULES.all;P=JSON.parse(JSON.stringify(P));for(const $ of M){const T=$.split("/").slice(1);let j=P;for(const ee of T)j=j[ee];for(const ee in O){const se=O[ee];if(typeof se!="object")continue;const{$data:_e}=se.definition,he=j[ee];_e&&he&&(j[ee]=kt(he))}}return P}_removeAllSchemas(P,M){for(const O in P){const $=P[O];(!M||M.test(O))&&(typeof $=="string"?delete P[O]:$&&!$.meta&&(this._cache.delete($.schema),delete P[O]))}}_addSchema(P,M,O,$=this.opts.validateSchema,T=this.opts.addUsedSchema){let j;const{schemaId:ee}=this.opts;if(typeof P=="object")j=P[ee];else{if(this.opts.jtd)throw new Error("schema must be object");if(typeof P!="boolean")throw new Error("schema must be object or boolean")}let se=this._cache.get(P);if(se!==void 0)return se;O=(0,c.normalizeId)(j||O);const _e=c.getSchemaRefs.call(this,P,O);return se=new i.SchemaEnv({schema:P,schemaId:ee,meta:M,baseId:O,localRefs:_e}),this._cache.set(se.schema,se),T&&!O.startsWith("#")&&(O&&this._checkUnique(O),this.refs[O]=se),$&&this.validateSchema(P,!0),se}_checkUnique(P){if(this.schemas[P]||this.refs[P])throw new Error(`schema with key or id "${P}" already exists`)}_compileSchemaEnv(P){if(P.meta?this._compileMetaSchema(P):i.compileSchema.call(this,P),!P.validate)throw new Error("ajv implementation error");return P.validate}_compileMetaSchema(P){const M=this.opts;this.opts=this._metaOpts;try{i.compileSchema.call(this,P)}finally{this.opts=M}}}b.ValidationError=n.default,b.MissingRefError=s.default,t.default=b;function y(D,P,M,O="error"){for(const $ in D){const T=$;T in P&&this.logger[O](`${M}: option ${$}. ${D[T]}`)}}function k(D){return D=(0,c.normalizeId)(D),this.schemas[D]||this.refs[D]}function S(){const D=this.opts.schemas;if(D)if(Array.isArray(D))this.addSchema(D);else for(const P in D)this.addSchema(D[P],P)}function I(){for(const D in this.opts.formats){const P=this.opts.formats[D];P&&this.addFormat(D,P)}}function C(D){if(Array.isArray(D)){this.addVocabulary(D);return}this.logger.warn("keywords option as map is deprecated, pass array");for(const P in D){const M=D[P];M.keyword||(M.keyword=P),this.addKeyword(M)}}function q(){const D={...this.opts};for(const P of p)delete D[P];return D}const N={log(){},warn(){},error(){}};function V(D){if(D===!1)return N;if(D===void 0)return console;if(D.log&&D.warn&&D.error)return D;throw new Error("logger must implement log, warn and error methods")}const B=/^[a-z_$][a-z0-9_$:-]*$/i;function Y(D,P){const{RULES:M}=this;if((0,u.eachItem)(D,O=>{if(M.keywords[O])throw new Error(`Keyword ${O} is already defined`);if(!B.test(O))throw new Error(`Keyword ${O} has invalid name`)}),!!P&&P.$data&&!("code"in P||"validate"in P))throw new Error('$data keyword must have "code" or "validate" function')}function ve(D,P,M){var O;const $=P?.post;if(M&&$)throw new Error('keyword with "post" flag cannot have "type"');const{RULES:T}=this;let j=$?T.post:T.rules.find(({type:se})=>se===M);if(j||(j={type:M,rules:[]},T.rules.push(j)),T.keywords[D]=!0,!P)return;const ee={keyword:D,definition:{...P,type:(0,l.getJSONTypes)(P.type),schemaType:(0,l.getJSONTypes)(P.schemaType)}};P.before?Ge.call(this,j,ee,P.before):j.rules.push(ee),T.all[D]=ee,(O=P.implements)===null||O===void 0||O.forEach(se=>this.addKeyword(se))}function Ge(D,P,M){const O=D.rules.findIndex($=>$.keyword===M);O>=0?D.rules.splice(O,0,P):(D.rules.push(P),this.logger.warn(`rule ${M} is not defined`))}function Ye(D){let{metaSchema:P}=D;P!==void 0&&(D.$data&&this.opts.$data&&(P=kt(P)),D.validateSchema=this.compile(P,!0))}const be={$ref:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#"};function kt(D){return{anyOf:[D,be]}}})(oa)),oa}var An={},jn={},zn={},jo;function Sd(){if(jo)return zn;jo=1,Object.defineProperty(zn,"__esModule",{value:!0});const t={keyword:"id",code(){throw new Error('NOT SUPPORTED: keyword "id", use "$id" for schema ID')}};return zn.default=t,zn}var Lt={},zo;function Td(){if(zo)return Lt;zo=1,Object.defineProperty(Lt,"__esModule",{value:!0}),Lt.callRef=Lt.getValidate=void 0;const t=On(),e=pt(),r=ce(),n=Zt(),s=ma(),a=pe(),i={keyword:"$ref",schemaType:"string",code(l){const{gen:u,schema:d,it:g}=l,{baseId:v,schemaEnv:p,validateName:w,opts:h,self:_}=g,{root:f}=p;if((d==="#"||d==="#/")&&v===f.baseId)return b();const m=s.resolveRef.call(_,f,v,d);if(m===void 0)throw new t.default(g.opts.uriResolver,v,d);if(m instanceof s.SchemaEnv)return y(m);return k(m);function b(){if(p===f)return c(l,w,p,p.$async);const S=u.scopeValue("root",{ref:f});return c(l,(0,r._)`${S}.validate`,f,f.$async)}function y(S){const I=o(l,S);c(l,I,S,S.$async)}function k(S){const I=u.scopeValue("schema",h.code.source===!0?{ref:S,code:(0,r.stringify)(S)}:{ref:S}),C=u.name("valid"),q=l.subschema({schema:S,dataTypes:[],schemaPath:r.nil,topSchemaRef:I,errSchemaPath:d},C);l.mergeEvaluated(q),l.ok(C)}}};function o(l,u){const{gen:d}=l;return u.validate?d.scopeValue("validate",{ref:u.validate}):(0,r._)`${d.scopeValue("wrapper",{ref:u})}.validate`}Lt.getValidate=o;function c(l,u,d,g){const{gen:v,it:p}=l,{allErrors:w,schemaEnv:h,opts:_}=p,f=_.passContext?n.default.this:r.nil;g?m():b();function m(){if(!h.$async)throw new Error("async schema referenced by sync schema");const S=v.let("valid");v.try(()=>{v.code((0,r._)`await ${(0,e.callValidateCode)(l,u,f)}`),k(u),w||v.assign(S,!0)},I=>{v.if((0,r._)`!(${I} instanceof ${p.ValidationError})`,()=>v.throw(I)),y(I),w||v.assign(S,!1)}),l.ok(S)}function b(){l.result((0,e.callValidateCode)(l,u,f),()=>k(u),()=>y(u))}function y(S){const I=(0,r._)`${S}.errors`;v.assign(n.default.vErrors,(0,r._)`${n.default.vErrors} === null ? ${I} : ${n.default.vErrors}.concat(${I})`),v.assign(n.default.errors,(0,r._)`${n.default.vErrors}.length`)}function k(S){var I;if(!p.opts.unevaluated)return;const C=(I=d?.validate)===null||I===void 0?void 0:I.evaluated;if(p.props!==!0)if(C&&!C.dynamicProps)C.props!==void 0&&(p.props=a.mergeEvaluated.props(v,C.props,p.props));else{const q=v.var("props",(0,r._)`${S}.evaluated.props`);p.props=a.mergeEvaluated.props(v,q,p.props,r.Name)}if(p.items!==!0)if(C&&!C.dynamicItems)C.items!==void 0&&(p.items=a.mergeEvaluated.items(v,C.items,p.items));else{const q=v.var("items",(0,r._)`${S}.evaluated.items`);p.items=a.mergeEvaluated.items(v,q,p.items,r.Name)}}}return Lt.callRef=c,Lt.default=i,Lt}var Mo;function Ed(){if(Mo)return jn;Mo=1,Object.defineProperty(jn,"__esModule",{value:!0});const t=Sd(),e=Td(),r=["$schema","$id","$defs","$vocabulary",{keyword:"$comment"},"definitions",t.default,e.default];return jn.default=r,jn}var Mn={},qn={},qo;function Rd(){if(qo)return qn;qo=1,Object.defineProperty(qn,"__esModule",{value:!0});const t=ce(),e=t.operators,r={maximum:{okStr:"<=",ok:e.LTE,fail:e.GT},minimum:{okStr:">=",ok:e.GTE,fail:e.LT},exclusiveMaximum:{okStr:"<",ok:e.LT,fail:e.GTE},exclusiveMinimum:{okStr:">",ok:e.GT,fail:e.LTE}},n={message:({keyword:a,schemaCode:i})=>(0,t.str)`must be ${r[a].okStr} ${i}`,params:({keyword:a,schemaCode:i})=>(0,t._)`{comparison: ${r[a].okStr}, limit: ${i}}`},s={keyword:Object.keys(r),type:"number",schemaType:"number",$data:!0,error:n,code(a){const{keyword:i,data:o,schemaCode:c}=a;a.fail$data((0,t._)`${o} ${r[i].fail} ${c} || isNaN(${o})`)}};return qn.default=s,qn}var Zn={},Zo;function Pd(){if(Zo)return Zn;Zo=1,Object.defineProperty(Zn,"__esModule",{value:!0});const t=ce(),r={keyword:"multipleOf",type:"number",schemaType:"number",$data:!0,error:{message:({schemaCode:n})=>(0,t.str)`must be multiple of ${n}`,params:({schemaCode:n})=>(0,t._)`{multipleOf: ${n}}`},code(n){const{gen:s,data:a,schemaCode:i,it:o}=n,c=o.opts.multipleOfPrecision,l=s.let("res"),u=c?(0,t._)`Math.abs(Math.round(${l}) - ${l}) > 1e-${c}`:(0,t._)`${l} !== parseInt(${l})`;n.fail$data((0,t._)`(${i} === 0 || (${l} = ${a}/${i}, ${u}))`)}};return Zn.default=r,Zn}var Ln={},Un={},Lo;function xd(){if(Lo)return Un;Lo=1,Object.defineProperty(Un,"__esModule",{value:!0});function t(e){const r=e.length;let n=0,s=0,a;for(;s<r;)n++,a=e.charCodeAt(s++),a>=55296&&a<=56319&&s<r&&(a=e.charCodeAt(s),(a&64512)===56320&&s++);return n}return Un.default=t,t.code='require("ajv/dist/runtime/ucs2length").default',Un}var Uo;function Id(){if(Uo)return Ln;Uo=1,Object.defineProperty(Ln,"__esModule",{value:!0});const t=ce(),e=pe(),r=xd(),s={keyword:["maxLength","minLength"],type:"string",schemaType:"number",$data:!0,error:{message({keyword:a,schemaCode:i}){const o=a==="maxLength"?"more":"fewer";return(0,t.str)`must NOT have ${o} than ${i} characters`},params:({schemaCode:a})=>(0,t._)`{limit: ${a}}`},code(a){const{keyword:i,data:o,schemaCode:c,it:l}=a,u=i==="maxLength"?t.operators.GT:t.operators.LT,d=l.opts.unicode===!1?(0,t._)`${o}.length`:(0,t._)`${(0,e.useFunc)(a.gen,r.default)}(${o})`;a.fail$data((0,t._)`${d} ${u} ${c}`)}};return Ln.default=s,Ln}var Dn={},Do;function Cd(){if(Do)return Dn;Do=1,Object.defineProperty(Dn,"__esModule",{value:!0});const t=pt(),e=ce(),n={keyword:"pattern",type:"string",schemaType:"string",$data:!0,error:{message:({schemaCode:s})=>(0,e.str)`must match pattern "${s}"`,params:({schemaCode:s})=>(0,e._)`{pattern: ${s}}`},code(s){const{data:a,$data:i,schema:o,schemaCode:c,it:l}=s,u=l.opts.unicodeRegExp?"u":"",d=i?(0,e._)`(new RegExp(${c}, ${u}))`:(0,t.usePattern)(s,o);s.fail$data((0,e._)`!${d}.test(${a})`)}};return Dn.default=n,Dn}var Vn={},Vo;function Od(){if(Vo)return Vn;Vo=1,Object.defineProperty(Vn,"__esModule",{value:!0});const t=ce(),r={keyword:["maxProperties","minProperties"],type:"object",schemaType:"number",$data:!0,error:{message({keyword:n,schemaCode:s}){const a=n==="maxProperties"?"more":"fewer";return(0,t.str)`must NOT have ${a} than ${s} properties`},params:({schemaCode:n})=>(0,t._)`{limit: ${n}}`},code(n){const{keyword:s,data:a,schemaCode:i}=n,o=s==="maxProperties"?t.operators.GT:t.operators.LT;n.fail$data((0,t._)`Object.keys(${a}).length ${o} ${i}`)}};return Vn.default=r,Vn}var Fn={},Fo;function Nd(){if(Fo)return Fn;Fo=1,Object.defineProperty(Fn,"__esModule",{value:!0});const t=pt(),e=ce(),r=pe(),s={keyword:"required",type:"object",schemaType:"array",$data:!0,error:{message:({params:{missingProperty:a}})=>(0,e.str)`must have required property '${a}'`,params:({params:{missingProperty:a}})=>(0,e._)`{missingProperty: ${a}}`},code(a){const{gen:i,schema:o,schemaCode:c,data:l,$data:u,it:d}=a,{opts:g}=d;if(!u&&o.length===0)return;const v=o.length>=g.loopRequired;if(d.allErrors?p():w(),g.strictRequired){const f=a.parentSchema.properties,{definedProperties:m}=a.it;for(const b of o)if(f?.[b]===void 0&&!m.has(b)){const y=d.schemaEnv.baseId+d.errSchemaPath,k=`required property "${b}" is not defined at "${y}" (strictRequired)`;(0,r.checkStrictMode)(d,k,d.opts.strictRequired)}}function p(){if(v||u)a.block$data(e.nil,h);else for(const f of o)(0,t.checkReportMissingProp)(a,f)}function w(){const f=i.let("missing");if(v||u){const m=i.let("valid",!0);a.block$data(m,()=>_(f,m)),a.ok(m)}else i.if((0,t.checkMissingProp)(a,o,f)),(0,t.reportMissingProp)(a,f),i.else()}function h(){i.forOf("prop",c,f=>{a.setParams({missingProperty:f}),i.if((0,t.noPropertyInData)(i,l,f,g.ownProperties),()=>a.error())})}function _(f,m){a.setParams({missingProperty:f}),i.forOf(f,c,()=>{i.assign(m,(0,t.propertyInData)(i,l,f,g.ownProperties)),i.if((0,e.not)(m),()=>{a.error(),i.break()})},e.nil)}}};return Fn.default=s,Fn}var Hn={},Ho;function Ad(){if(Ho)return Hn;Ho=1,Object.defineProperty(Hn,"__esModule",{value:!0});const t=ce(),r={keyword:["maxItems","minItems"],type:"array",schemaType:"number",$data:!0,error:{message({keyword:n,schemaCode:s}){const a=n==="maxItems"?"more":"fewer";return(0,t.str)`must NOT have ${a} than ${s} items`},params:({schemaCode:n})=>(0,t._)`{limit: ${n}}`},code(n){const{keyword:s,data:a,schemaCode:i}=n,o=s==="maxItems"?t.operators.GT:t.operators.LT;n.fail$data((0,t._)`${a}.length ${o} ${i}`)}};return Hn.default=r,Hn}var Wn={},Jn={},Wo;function ga(){if(Wo)return Jn;Wo=1,Object.defineProperty(Jn,"__esModule",{value:!0});const t=ko();return t.code='require("ajv/dist/runtime/equal").default',Jn.default=t,Jn}var Jo;function jd(){if(Jo)return Wn;Jo=1,Object.defineProperty(Wn,"__esModule",{value:!0});const t=Rn(),e=ce(),r=pe(),n=ga(),a={keyword:"uniqueItems",type:"array",schemaType:"boolean",$data:!0,error:{message:({params:{i,j:o}})=>(0,e.str)`must NOT have duplicate items (items ## ${o} and ${i} are identical)`,params:({params:{i,j:o}})=>(0,e._)`{i: ${i}, j: ${o}}`},code(i){const{gen:o,data:c,$data:l,schema:u,parentSchema:d,schemaCode:g,it:v}=i;if(!l&&!u)return;const p=o.let("valid"),w=d.items?(0,t.getSchemaTypes)(d.items):[];i.block$data(p,h,(0,e._)`${g} === false`),i.ok(p);function h(){const b=o.let("i",(0,e._)`${c}.length`),y=o.let("j");i.setParams({i:b,j:y}),o.assign(p,!0),o.if((0,e._)`${b} > 1`,()=>(_()?f:m)(b,y))}function _(){return w.length>0&&!w.some(b=>b==="object"||b==="array")}function f(b,y){const k=o.name("item"),S=(0,t.checkDataTypes)(w,k,v.opts.strictNumbers,t.DataType.Wrong),I=o.const("indices",(0,e._)`{}`);o.for((0,e._)`;${b}--;`,()=>{o.let(k,(0,e._)`${c}[${b}]`),o.if(S,(0,e._)`continue`),w.length>1&&o.if((0,e._)`typeof ${k} == "string"`,(0,e._)`${k} += "_"`),o.if((0,e._)`typeof ${I}[${k}] == "number"`,()=>{o.assign(y,(0,e._)`${I}[${k}]`),i.error(),o.assign(p,!1).break()}).code((0,e._)`${I}[${k}] = ${b}`)})}function m(b,y){const k=(0,r.useFunc)(o,n.default),S=o.name("outer");o.label(S).for((0,e._)`;${b}--;`,()=>o.for((0,e._)`${y} = ${b}; ${y}--;`,()=>o.if((0,e._)`${k}(${c}[${b}], ${c}[${y}])`,()=>{i.error(),o.assign(p,!1).break(S)})))}}};return Wn.default=a,Wn}var Kn={},Ko;function zd(){if(Ko)return Kn;Ko=1,Object.defineProperty(Kn,"__esModule",{value:!0});const t=ce(),e=pe(),r=ga(),s={keyword:"const",$data:!0,error:{message:"must be equal to constant",params:({schemaCode:a})=>(0,t._)`{allowedValue: ${a}}`},code(a){const{gen:i,data:o,$data:c,schemaCode:l,schema:u}=a;c||u&&typeof u=="object"?a.fail$data((0,t._)`!${(0,e.useFunc)(i,r.default)}(${o}, ${l})`):a.fail((0,t._)`${u} !== ${o}`)}};return Kn.default=s,Kn}var Bn={},Bo;function Md(){if(Bo)return Bn;Bo=1,Object.defineProperty(Bn,"__esModule",{value:!0});const t=ce(),e=pe(),r=ga(),s={keyword:"enum",schemaType:"array",$data:!0,error:{message:"must be equal to one of the allowed values",params:({schemaCode:a})=>(0,t._)`{allowedValues: ${a}}`},code(a){const{gen:i,data:o,$data:c,schema:l,schemaCode:u,it:d}=a;if(!c&&l.length===0)throw new Error("enum must have non-empty array");const g=l.length>=d.opts.loopEnum;let v;const p=()=>v??(v=(0,e.useFunc)(i,r.default));let w;if(g||c)w=i.let("valid"),a.block$data(w,h);else{if(!Array.isArray(l))throw new Error("ajv implementation error");const f=i.const("vSchema",u);w=(0,t.or)(...l.map((m,b)=>_(f,b)))}a.pass(w);function h(){i.assign(w,!1),i.forOf("v",u,f=>i.if((0,t._)`${p()}(${o}, ${f})`,()=>i.assign(w,!0).break()))}function _(f,m){const b=l[m];return typeof b=="object"&&b!==null?(0,t._)`${p()}(${o}, ${f}[${m}])`:(0,t._)`${o} === ${b}`}}};return Bn.default=s,Bn}var Go;function qd(){if(Go)return Mn;Go=1,Object.defineProperty(Mn,"__esModule",{value:!0});const t=Rd(),e=Pd(),r=Id(),n=Cd(),s=Od(),a=Nd(),i=Ad(),o=jd(),c=zd(),l=Md(),u=[t.default,e.default,r.default,n.default,s.default,a.default,i.default,o.default,{keyword:"type",schemaType:["string","array"]},{keyword:"nullable",schemaType:"boolean"},c.default,l.default];return Mn.default=u,Mn}var Gn={},fr={},Yo;function Qo(){if(Yo)return fr;Yo=1,Object.defineProperty(fr,"__esModule",{value:!0}),fr.validateAdditionalItems=void 0;const t=ce(),e=pe(),n={keyword:"additionalItems",type:"array",schemaType:["boolean","object"],before:"uniqueItems",error:{message:({params:{len:a}})=>(0,t.str)`must NOT have more than ${a} items`,params:({params:{len:a}})=>(0,t._)`{limit: ${a}}`},code(a){const{parentSchema:i,it:o}=a,{items:c}=i;if(!Array.isArray(c)){(0,e.checkStrictMode)(o,'"additionalItems" is ignored when "items" is not an array of schemas');return}s(a,c)}};function s(a,i){const{gen:o,schema:c,data:l,keyword:u,it:d}=a;d.items=!0;const g=o.const("len",(0,t._)`${l}.length`);if(c===!1)a.setParams({len:i.length}),a.pass((0,t._)`${g} <= ${i.length}`);else if(typeof c=="object"&&!(0,e.alwaysValidSchema)(d,c)){const p=o.var("valid",(0,t._)`${g} <= ${i.length}`);o.if((0,t.not)(p),()=>v(p)),a.ok(p)}function v(p){o.forRange("i",i.length,g,w=>{a.subschema({keyword:u,dataProp:w,dataPropType:e.Type.Num},p),d.allErrors||o.if((0,t.not)(p),()=>o.break())})}}return fr.validateAdditionalItems=s,fr.default=n,fr}var Yn={},hr={},Xo;function ec(){if(Xo)return hr;Xo=1,Object.defineProperty(hr,"__esModule",{value:!0}),hr.validateTuple=void 0;const t=ce(),e=pe(),r=pt(),n={keyword:"items",type:"array",schemaType:["object","array","boolean"],before:"uniqueItems",code(a){const{schema:i,it:o}=a;if(Array.isArray(i))return s(a,"additionalItems",i);o.items=!0,!(0,e.alwaysValidSchema)(o,i)&&a.ok((0,r.validateArray)(a))}};function s(a,i,o=a.schema){const{gen:c,parentSchema:l,data:u,keyword:d,it:g}=a;w(l),g.opts.unevaluated&&o.length&&g.items!==!0&&(g.items=e.mergeEvaluated.items(c,o.length,g.items));const v=c.name("valid"),p=c.const("len",(0,t._)`${u}.length`);o.forEach((h,_)=>{(0,e.alwaysValidSchema)(g,h)||(c.if((0,t._)`${p} > ${_}`,()=>a.subschema({keyword:d,schemaProp:_,dataProp:_},v)),a.ok(v))});function w(h){const{opts:_,errSchemaPath:f}=g,m=o.length,b=m===h.minItems&&(m===h.maxItems||h[i]===!1);if(_.strictTuples&&!b){const y=`"${d}" is ${m}-tuple, but minItems or maxItems/${i} are not specified or different at path "${f}"`;(0,e.checkStrictMode)(g,y,_.strictTuples)}}}return hr.validateTuple=s,hr.default=n,hr}var tc;function Zd(){if(tc)return Yn;tc=1,Object.defineProperty(Yn,"__esModule",{value:!0});const t=ec(),e={keyword:"prefixItems",type:"array",schemaType:["array"],before:"uniqueItems",code:r=>(0,t.validateTuple)(r,"items")};return Yn.default=e,Yn}var Qn={},rc;function Ld(){if(rc)return Qn;rc=1,Object.defineProperty(Qn,"__esModule",{value:!0});const t=ce(),e=pe(),r=pt(),n=Qo(),a={keyword:"items",type:"array",schemaType:["object","boolean"],before:"uniqueItems",error:{message:({params:{len:i}})=>(0,t.str)`must NOT have more than ${i} items`,params:({params:{len:i}})=>(0,t._)`{limit: ${i}}`},code(i){const{schema:o,parentSchema:c,it:l}=i,{prefixItems:u}=c;l.items=!0,!(0,e.alwaysValidSchema)(l,o)&&(u?(0,n.validateAdditionalItems)(i,u):i.ok((0,r.validateArray)(i)))}};return Qn.default=a,Qn}var Xn={},nc;function Ud(){if(nc)return Xn;nc=1,Object.defineProperty(Xn,"__esModule",{value:!0});const t=ce(),e=pe(),n={keyword:"contains",type:"array",schemaType:["object","boolean"],before:"uniqueItems",trackErrors:!0,error:{message:({params:{min:s,max:a}})=>a===void 0?(0,t.str)`must contain at least ${s} valid item(s)`:(0,t.str)`must contain at least ${s} and no more than ${a} valid item(s)`,params:({params:{min:s,max:a}})=>a===void 0?(0,t._)`{minContains: ${s}}`:(0,t._)`{minContains: ${s}, maxContains: ${a}}`},code(s){const{gen:a,schema:i,parentSchema:o,data:c,it:l}=s;let u,d;const{minContains:g,maxContains:v}=o;l.opts.next?(u=g===void 0?1:g,d=v):u=1;const p=a.const("len",(0,t._)`${c}.length`);if(s.setParams({min:u,max:d}),d===void 0&&u===0){(0,e.checkStrictMode)(l,'"minContains" == 0 without "maxContains": "contains" keyword ignored');return}if(d!==void 0&&u>d){(0,e.checkStrictMode)(l,'"minContains" > "maxContains" is always invalid'),s.fail();return}if((0,e.alwaysValidSchema)(l,i)){let m=(0,t._)`${p} >= ${u}`;d!==void 0&&(m=(0,t._)`${m} && ${p} <= ${d}`),s.pass(m);return}l.items=!0;const w=a.name("valid");d===void 0&&u===1?_(w,()=>a.if(w,()=>a.break())):u===0?(a.let(w,!0),d!==void 0&&a.if((0,t._)`${c}.length > 0`,h)):(a.let(w,!1),h()),s.result(w,()=>s.reset());function h(){const m=a.name("_valid"),b=a.let("count",0);_(m,()=>a.if(m,()=>f(b)))}function _(m,b){a.forRange("i",0,p,y=>{s.subschema({keyword:"contains",dataProp:y,dataPropType:e.Type.Num,compositeRule:!0},m),b()})}function f(m){a.code((0,t._)`${m}++`),d===void 0?a.if((0,t._)`${m} >= ${u}`,()=>a.assign(w,!0).break()):(a.if((0,t._)`${m} > ${d}`,()=>a.assign(w,!1).break()),u===1?a.assign(w,!0):a.if((0,t._)`${m} >= ${u}`,()=>a.assign(w,!0)))}}};return Xn.default=n,Xn}var ya={},sc;function Dd(){return sc||(sc=1,(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.validateSchemaDeps=t.validatePropertyDeps=t.error=void 0;const e=ce(),r=pe(),n=pt();t.error={message:({params:{property:c,depsCount:l,deps:u}})=>{const d=l===1?"property":"properties";return(0,e.str)`must have ${d} ${u} when property ${c} is present`},params:({params:{property:c,depsCount:l,deps:u,missingProperty:d}})=>(0,e._)`{property: ${c},
|
|
1
|
+
(function(Ce,kr){typeof exports=="object"&&typeof module<"u"?kr(exports):typeof define=="function"&&define.amd?define(["exports"],kr):(Ce=typeof globalThis<"u"?globalThis:Ce||self,kr(Ce.WebMCP={}))})(this,(function(Ce){"use strict";function kr(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Hn={exports:{}},Do={},zt={},ur={},Vo={},Ho={},Fo={},_c;function Fn(){return _c||(_c=1,(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.regexpCode=t.getEsmExportName=t.getProperty=t.safeStringify=t.stringify=t.strConcat=t.addCodeArg=t.str=t._=t.nil=t._Code=t.Name=t.IDENTIFIER=t._CodeOrName=void 0;class e{}t._CodeOrName=e,t.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;class r extends e{constructor(h){if(super(),!t.IDENTIFIER.test(h))throw new Error("CodeGen: name must be a valid identifier");this.str=h}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}}t.Name=r;class n extends e{constructor(h){super(),this._items=typeof h=="string"?[h]:h}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;const h=this._items[0];return h===""||h==='""'}get str(){var h;return(h=this._str)!==null&&h!==void 0?h:this._str=this._items.reduce((w,$)=>`${w}${$}`,"")}get names(){var h;return(h=this._names)!==null&&h!==void 0?h:this._names=this._items.reduce((w,$)=>($ instanceof r&&(w[$.str]=(w[$.str]||0)+1),w),{})}}t._Code=n,t.nil=new n("");function s(v,...h){const w=[v[0]];let $=0;for(;$<h.length;)a(w,h[$]),w.push(v[++$]);return new n(w)}t._=s;const o=new n("+");function i(v,...h){const w=[_(v[0])];let $=0;for(;$<h.length;)w.push(o),a(w,h[$]),w.push(o,_(v[++$]));return c(w),new n(w)}t.str=i;function a(v,h){h instanceof n?v.push(...h._items):h instanceof r?v.push(h):v.push(d(h))}t.addCodeArg=a;function c(v){let h=1;for(;h<v.length-1;){if(v[h]===o){const w=u(v[h-1],v[h+1]);if(w!==void 0){v.splice(h-1,3,w);continue}v[h++]="+"}h++}}function u(v,h){if(h==='""')return v;if(v==='""')return h;if(typeof v=="string")return h instanceof r||v[v.length-1]!=='"'?void 0:typeof h!="string"?`${v.slice(0,-1)}${h}"`:h[0]==='"'?v.slice(0,-1)+h.slice(1):void 0;if(typeof h=="string"&&h[0]==='"'&&!(v instanceof r))return`"${v}${h.slice(1)}`}function l(v,h){return h.emptyStr()?v:v.emptyStr()?h:i`${v}${h}`}t.strConcat=l;function d(v){return typeof v=="number"||typeof v=="boolean"||v===null?v:_(Array.isArray(v)?v.join(","):v)}function p(v){return new n(_(v))}t.stringify=p;function _(v){return JSON.stringify(v).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}t.safeStringify=_;function m(v){return typeof v=="string"&&t.IDENTIFIER.test(v)?new n(`.${v}`):s`[${v}]`}t.getProperty=m;function g(v){if(typeof v=="string"&&t.IDENTIFIER.test(v))return new n(`${v}`);throw new Error(`CodeGen: invalid export name: ${v}, use explicit $id name mapping`)}t.getEsmExportName=g;function f(v){return new n(v.toString())}t.regexpCode=f})(Fo)),Fo}var Wo={},gc;function vc(){return gc||(gc=1,(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.ValueScope=t.ValueScopeName=t.Scope=t.varKinds=t.UsedValueState=void 0;const e=Fn();class r extends Error{constructor(u){super(`CodeGen: "code" for ${u} not defined`),this.value=u.value}}var n;(function(c){c[c.Started=0]="Started",c[c.Completed=1]="Completed"})(n||(t.UsedValueState=n={})),t.varKinds={const:new e.Name("const"),let:new e.Name("let"),var:new e.Name("var")};class s{constructor({prefixes:u,parent:l}={}){this._names={},this._prefixes=u,this._parent=l}toName(u){return u instanceof e.Name?u:this.name(u)}name(u){return new e.Name(this._newName(u))}_newName(u){const l=this._names[u]||this._nameGroup(u);return`${u}${l.index++}`}_nameGroup(u){var l,d;if(!((d=(l=this._parent)===null||l===void 0?void 0:l._prefixes)===null||d===void 0)&&d.has(u)||this._prefixes&&!this._prefixes.has(u))throw new Error(`CodeGen: prefix "${u}" is not allowed in this scope`);return this._names[u]={prefix:u,index:0}}}t.Scope=s;class o extends e.Name{constructor(u,l){super(l),this.prefix=u}setValue(u,{property:l,itemIndex:d}){this.value=u,this.scopePath=(0,e._)`.${new e.Name(l)}[${d}]`}}t.ValueScopeName=o;const i=(0,e._)`\n`;class a extends s{constructor(u){super(u),this._values={},this._scope=u.scope,this.opts={...u,_n:u.lines?i:e.nil}}get(){return this._scope}name(u){return new o(u,this._newName(u))}value(u,l){var d;if(l.ref===void 0)throw new Error("CodeGen: ref must be passed in value");const p=this.toName(u),{prefix:_}=p,m=(d=l.key)!==null&&d!==void 0?d:l.ref;let g=this._values[_];if(g){const h=g.get(m);if(h)return h}else g=this._values[_]=new Map;g.set(m,p);const f=this._scope[_]||(this._scope[_]=[]),v=f.length;return f[v]=l.ref,p.setValue(l,{property:_,itemIndex:v}),p}getValue(u,l){const d=this._values[u];if(d)return d.get(l)}scopeRefs(u,l=this._values){return this._reduceValues(l,d=>{if(d.scopePath===void 0)throw new Error(`CodeGen: name "${d}" has no value`);return(0,e._)`${u}${d.scopePath}`})}scopeCode(u=this._values,l,d){return this._reduceValues(u,p=>{if(p.value===void 0)throw new Error(`CodeGen: name "${p}" has no value`);return p.value.code},l,d)}_reduceValues(u,l,d={},p){let _=e.nil;for(const m in u){const g=u[m];if(!g)continue;const f=d[m]=d[m]||new Map;g.forEach(v=>{if(f.has(v))return;f.set(v,n.Started);let h=l(v);if(h){const w=this.opts.es5?t.varKinds.var:t.varKinds.const;_=(0,e._)`${_}${w} ${v} = ${h};${this.opts._n}`}else if(h=p?.(v))_=(0,e._)`${_}${h}${this.opts._n}`;else throw new r(v);f.set(v,n.Completed)})}return _}}t.ValueScope=a})(Wo)),Wo}var yc;function fe(){return yc||(yc=1,(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.or=t.and=t.not=t.CodeGen=t.operators=t.varKinds=t.ValueScopeName=t.ValueScope=t.Scope=t.Name=t.regexpCode=t.stringify=t.getProperty=t.nil=t.strConcat=t.str=t._=void 0;const e=Fn(),r=vc();var n=Fn();Object.defineProperty(t,"_",{enumerable:!0,get:function(){return n._}}),Object.defineProperty(t,"str",{enumerable:!0,get:function(){return n.str}}),Object.defineProperty(t,"strConcat",{enumerable:!0,get:function(){return n.strConcat}}),Object.defineProperty(t,"nil",{enumerable:!0,get:function(){return n.nil}}),Object.defineProperty(t,"getProperty",{enumerable:!0,get:function(){return n.getProperty}}),Object.defineProperty(t,"stringify",{enumerable:!0,get:function(){return n.stringify}}),Object.defineProperty(t,"regexpCode",{enumerable:!0,get:function(){return n.regexpCode}}),Object.defineProperty(t,"Name",{enumerable:!0,get:function(){return n.Name}});var s=vc();Object.defineProperty(t,"Scope",{enumerable:!0,get:function(){return s.Scope}}),Object.defineProperty(t,"ValueScope",{enumerable:!0,get:function(){return s.ValueScope}}),Object.defineProperty(t,"ValueScopeName",{enumerable:!0,get:function(){return s.ValueScopeName}}),Object.defineProperty(t,"varKinds",{enumerable:!0,get:function(){return s.varKinds}}),t.operators={GT:new e._Code(">"),GTE:new e._Code(">="),LT:new e._Code("<"),LTE:new e._Code("<="),EQ:new e._Code("==="),NEQ:new e._Code("!=="),NOT:new e._Code("!"),OR:new e._Code("||"),AND:new e._Code("&&"),ADD:new e._Code("+")};class o{optimizeNodes(){return this}optimizeNames(k,R){return this}}class i extends o{constructor(k,R,M){super(),this.varKind=k,this.name=R,this.rhs=M}render({es5:k,_n:R}){const M=k?r.varKinds.var:this.varKind,X=this.rhs===void 0?"":` = ${this.rhs}`;return`${M} ${this.name}${X};`+R}optimizeNames(k,R){if(k[this.name.str])return this.rhs&&(this.rhs=G(this.rhs,k,R)),this}get names(){return this.rhs instanceof e._CodeOrName?this.rhs.names:{}}}class a extends o{constructor(k,R,M){super(),this.lhs=k,this.rhs=R,this.sideEffects=M}render({_n:k}){return`${this.lhs} = ${this.rhs};`+k}optimizeNames(k,R){if(!(this.lhs instanceof e.Name&&!k[this.lhs.str]&&!this.sideEffects))return this.rhs=G(this.rhs,k,R),this}get names(){const k=this.lhs instanceof e.Name?{}:{...this.lhs.names};return K(k,this.rhs)}}class c extends a{constructor(k,R,M,X){super(k,M,X),this.op=R}render({_n:k}){return`${this.lhs} ${this.op}= ${this.rhs};`+k}}class u extends o{constructor(k){super(),this.label=k,this.names={}}render({_n:k}){return`${this.label}:`+k}}class l extends o{constructor(k){super(),this.label=k,this.names={}}render({_n:k}){return`break${this.label?` ${this.label}`:""};`+k}}class d extends o{constructor(k){super(),this.error=k}render({_n:k}){return`throw ${this.error};`+k}get names(){return this.error.names}}class p extends o{constructor(k){super(),this.code=k}render({_n:k}){return`${this.code};`+k}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames(k,R){return this.code=G(this.code,k,R),this}get names(){return this.code instanceof e._CodeOrName?this.code.names:{}}}class _ extends o{constructor(k=[]){super(),this.nodes=k}render(k){return this.nodes.reduce((R,M)=>R+M.render(k),"")}optimizeNodes(){const{nodes:k}=this;let R=k.length;for(;R--;){const M=k[R].optimizeNodes();Array.isArray(M)?k.splice(R,1,...M):M?k[R]=M:k.splice(R,1)}return k.length>0?this:void 0}optimizeNames(k,R){const{nodes:M}=this;let X=M.length;for(;X--;){const re=M[X];re.optimizeNames(k,R)||(ke(k,re.names),M.splice(X,1))}return M.length>0?this:void 0}get names(){return this.nodes.reduce((k,R)=>W(k,R.names),{})}}class m extends _{render(k){return"{"+k._n+super.render(k)+"}"+k._n}}class g extends _{}class f extends m{}f.kind="else";class v extends m{constructor(k,R){super(R),this.condition=k}render(k){let R=`if(${this.condition})`+super.render(k);return this.else&&(R+="else "+this.else.render(k)),R}optimizeNodes(){super.optimizeNodes();const k=this.condition;if(k===!0)return this.nodes;let R=this.else;if(R){const M=R.optimizeNodes();R=this.else=Array.isArray(M)?new f(M):M}if(R)return k===!1?R instanceof v?R:R.nodes:this.nodes.length?this:new v(tt(k),R instanceof v?[R]:R.nodes);if(!(k===!1||!this.nodes.length))return this}optimizeNames(k,R){var M;if(this.else=(M=this.else)===null||M===void 0?void 0:M.optimizeNames(k,R),!!(super.optimizeNames(k,R)||this.else))return this.condition=G(this.condition,k,R),this}get names(){const k=super.names;return K(k,this.condition),this.else&&W(k,this.else.names),k}}v.kind="if";class h extends m{}h.kind="for";class w extends h{constructor(k){super(),this.iteration=k}render(k){return`for(${this.iteration})`+super.render(k)}optimizeNames(k,R){if(super.optimizeNames(k,R))return this.iteration=G(this.iteration,k,R),this}get names(){return W(super.names,this.iteration.names)}}class $ extends h{constructor(k,R,M,X){super(),this.varKind=k,this.name=R,this.from=M,this.to=X}render(k){const R=k.es5?r.varKinds.var:this.varKind,{name:M,from:X,to:re}=this;return`for(${R} ${M}=${X}; ${M}<${re}; ${M}++)`+super.render(k)}get names(){const k=K(super.names,this.from);return K(k,this.to)}}class b extends h{constructor(k,R,M,X){super(),this.loop=k,this.varKind=R,this.name=M,this.iterable=X}render(k){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(k)}optimizeNames(k,R){if(super.optimizeNames(k,R))return this.iterable=G(this.iterable,k,R),this}get names(){return W(super.names,this.iterable.names)}}class S extends m{constructor(k,R,M){super(),this.name=k,this.args=R,this.async=M}render(k){return`${this.async?"async ":""}function ${this.name}(${this.args})`+super.render(k)}}S.kind="func";class T extends _{render(k){return"return "+super.render(k)}}T.kind="return";class N extends m{render(k){let R="try"+super.render(k);return this.catch&&(R+=this.catch.render(k)),this.finally&&(R+=this.finally.render(k)),R}optimizeNodes(){var k,R;return super.optimizeNodes(),(k=this.catch)===null||k===void 0||k.optimizeNodes(),(R=this.finally)===null||R===void 0||R.optimizeNodes(),this}optimizeNames(k,R){var M,X;return super.optimizeNames(k,R),(M=this.catch)===null||M===void 0||M.optimizeNames(k,R),(X=this.finally)===null||X===void 0||X.optimizeNames(k,R),this}get names(){const k=super.names;return this.catch&&W(k,this.catch.names),this.finally&&W(k,this.finally.names),k}}class j extends m{constructor(k){super(),this.error=k}render(k){return`catch(${this.error})`+super.render(k)}}j.kind="catch";class F extends m{render(k){return"finally"+super.render(k)}}F.kind="finally";class q{constructor(k,R={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...R,_n:R.lines?`
|
|
2
|
+
`:""},this._extScope=k,this._scope=new r.Scope({parent:k}),this._nodes=[new g]}toString(){return this._root.render(this.opts)}name(k){return this._scope.name(k)}scopeName(k){return this._extScope.name(k)}scopeValue(k,R){const M=this._extScope.value(k,R);return(this._values[M.prefix]||(this._values[M.prefix]=new Set)).add(M),M}getScopeValue(k,R){return this._extScope.getValue(k,R)}scopeRefs(k){return this._extScope.scopeRefs(k,this._values)}scopeCode(){return this._extScope.scopeCode(this._values)}_def(k,R,M,X){const re=this._scope.toName(R);return M!==void 0&&X&&(this._constants[re.str]=M),this._leafNode(new i(k,re,M)),re}const(k,R,M){return this._def(r.varKinds.const,k,R,M)}let(k,R,M){return this._def(r.varKinds.let,k,R,M)}var(k,R,M){return this._def(r.varKinds.var,k,R,M)}assign(k,R,M){return this._leafNode(new a(k,R,M))}add(k,R){return this._leafNode(new c(k,t.operators.ADD,R))}code(k){return typeof k=="function"?k():k!==e.nil&&this._leafNode(new p(k)),this}object(...k){const R=["{"];for(const[M,X]of k)R.length>1&&R.push(","),R.push(M),(M!==X||this.opts.es5)&&(R.push(":"),(0,e.addCodeArg)(R,X));return R.push("}"),new e._Code(R)}if(k,R,M){if(this._blockNode(new v(k)),R&&M)this.code(R).else().code(M).endIf();else if(R)this.code(R).endIf();else if(M)throw new Error('CodeGen: "else" body without "then" body');return this}elseIf(k){return this._elseNode(new v(k))}else(){return this._elseNode(new f)}endIf(){return this._endBlockNode(v,f)}_for(k,R){return this._blockNode(k),R&&this.code(R).endFor(),this}for(k,R){return this._for(new w(k),R)}forRange(k,R,M,X,re=this.opts.es5?r.varKinds.var:r.varKinds.let){const Se=this._scope.toName(k);return this._for(new $(re,Se,R,M),()=>X(Se))}forOf(k,R,M,X=r.varKinds.const){const re=this._scope.toName(k);if(this.opts.es5){const Se=R instanceof e.Name?R:this.var("_arr",R);return this.forRange("_i",0,(0,e._)`${Se}.length`,ve=>{this.var(re,(0,e._)`${Se}[${ve}]`),M(re)})}return this._for(new b("of",X,re,R),()=>M(re))}forIn(k,R,M,X=this.opts.es5?r.varKinds.var:r.varKinds.const){if(this.opts.ownProperties)return this.forOf(k,(0,e._)`Object.keys(${R})`,M);const re=this._scope.toName(k);return this._for(new b("in",X,re,R),()=>M(re))}endFor(){return this._endBlockNode(h)}label(k){return this._leafNode(new u(k))}break(k){return this._leafNode(new l(k))}return(k){const R=new T;if(this._blockNode(R),this.code(k),R.nodes.length!==1)throw new Error('CodeGen: "return" should have one node');return this._endBlockNode(T)}try(k,R,M){if(!R&&!M)throw new Error('CodeGen: "try" without "catch" and "finally"');const X=new N;if(this._blockNode(X),this.code(k),R){const re=this.name("e");this._currNode=X.catch=new j(re),R(re)}return M&&(this._currNode=X.finally=new F,this.code(M)),this._endBlockNode(j,F)}throw(k){return this._leafNode(new d(k))}block(k,R){return this._blockStarts.push(this._nodes.length),k&&this.code(k).endBlock(R),this}endBlock(k){const R=this._blockStarts.pop();if(R===void 0)throw new Error("CodeGen: not in self-balancing block");const M=this._nodes.length-R;if(M<0||k!==void 0&&M!==k)throw new Error(`CodeGen: wrong number of nodes: ${M} vs ${k} expected`);return this._nodes.length=R,this}func(k,R=e.nil,M,X){return this._blockNode(new S(k,R,M)),X&&this.code(X).endFunc(),this}endFunc(){return this._endBlockNode(S)}optimize(k=1){for(;k-- >0;)this._root.optimizeNodes(),this._root.optimizeNames(this._root.names,this._constants)}_leafNode(k){return this._currNode.nodes.push(k),this}_blockNode(k){this._currNode.nodes.push(k),this._nodes.push(k)}_endBlockNode(k,R){const M=this._currNode;if(M instanceof k||R&&M instanceof R)return this._nodes.pop(),this;throw new Error(`CodeGen: not in block "${R?`${k.kind}/${R.kind}`:k.kind}"`)}_elseNode(k){const R=this._currNode;if(!(R instanceof v))throw new Error('CodeGen: "else" without "if"');return this._currNode=R.else=k,this}get _root(){return this._nodes[0]}get _currNode(){const k=this._nodes;return k[k.length-1]}set _currNode(k){const R=this._nodes;R[R.length-1]=k}}t.CodeGen=q;function W(O,k){for(const R in k)O[R]=(O[R]||0)+(k[R]||0);return O}function K(O,k){return k instanceof e._CodeOrName?W(O,k.names):O}function G(O,k,R){if(O instanceof e.Name)return M(O);if(!X(O))return O;return new e._Code(O._items.reduce((re,Se)=>(Se instanceof e.Name&&(Se=M(Se)),Se instanceof e._Code?re.push(...Se._items):re.push(Se),re),[]));function M(re){const Se=R[re.str];return Se===void 0||k[re.str]!==1?re:(delete k[re.str],Se)}function X(re){return re instanceof e._Code&&re._items.some(Se=>Se instanceof e.Name&&k[Se.str]===1&&R[Se.str]!==void 0)}}function ke(O,k){for(const R in k)O[R]=(O[R]||0)-(k[R]||0)}function tt(O){return typeof O=="boolean"||typeof O=="number"||O===null?!O:(0,e._)`!${L(O)}`}t.not=tt;const rt=P(t.operators.AND);function xe(...O){return O.reduce(rt)}t.and=xe;const Ot=P(t.operators.OR);function V(...O){return O.reduce(Ot)}t.or=V;function P(O){return(k,R)=>k===e.nil?R:R===e.nil?k:(0,e._)`${L(k)} ${O} ${L(R)}`}function L(O){return O instanceof e.Name?O:(0,e._)`(${O})`}})(Ho)),Ho}var pe={},wc;function be(){if(wc)return pe;wc=1,Object.defineProperty(pe,"__esModule",{value:!0}),pe.checkStrictMode=pe.getErrorPath=pe.Type=pe.useFunc=pe.setEvaluated=pe.evaluatedPropsToName=pe.mergeEvaluated=pe.eachItem=pe.unescapeJsonPointer=pe.escapeJsonPointer=pe.escapeFragment=pe.unescapeFragment=pe.schemaRefOrVal=pe.schemaHasRulesButRef=pe.schemaHasRules=pe.checkUnknownRules=pe.alwaysValidSchema=pe.toHash=void 0;const t=fe(),e=Fn();function r(b){const S={};for(const T of b)S[T]=!0;return S}pe.toHash=r;function n(b,S){return typeof S=="boolean"?S:Object.keys(S).length===0?!0:(s(b,S),!o(S,b.self.RULES.all))}pe.alwaysValidSchema=n;function s(b,S=b.schema){const{opts:T,self:N}=b;if(!T.strictSchema||typeof S=="boolean")return;const j=N.RULES.keywords;for(const F in S)j[F]||$(b,`unknown keyword: "${F}"`)}pe.checkUnknownRules=s;function o(b,S){if(typeof b=="boolean")return!b;for(const T in b)if(S[T])return!0;return!1}pe.schemaHasRules=o;function i(b,S){if(typeof b=="boolean")return!b;for(const T in b)if(T!=="$ref"&&S.all[T])return!0;return!1}pe.schemaHasRulesButRef=i;function a({topSchemaRef:b,schemaPath:S},T,N,j){if(!j){if(typeof T=="number"||typeof T=="boolean")return T;if(typeof T=="string")return(0,t._)`${T}`}return(0,t._)`${b}${S}${(0,t.getProperty)(N)}`}pe.schemaRefOrVal=a;function c(b){return d(decodeURIComponent(b))}pe.unescapeFragment=c;function u(b){return encodeURIComponent(l(b))}pe.escapeFragment=u;function l(b){return typeof b=="number"?`${b}`:b.replace(/~/g,"~0").replace(/\//g,"~1")}pe.escapeJsonPointer=l;function d(b){return b.replace(/~1/g,"/").replace(/~0/g,"~")}pe.unescapeJsonPointer=d;function p(b,S){if(Array.isArray(b))for(const T of b)S(T);else S(b)}pe.eachItem=p;function _({mergeNames:b,mergeToName:S,mergeValues:T,resultToName:N}){return(j,F,q,W)=>{const K=q===void 0?F:q instanceof t.Name?(F instanceof t.Name?b(j,F,q):S(j,F,q),q):F instanceof t.Name?(S(j,q,F),F):T(F,q);return W===t.Name&&!(K instanceof t.Name)?N(j,K):K}}pe.mergeEvaluated={props:_({mergeNames:(b,S,T)=>b.if((0,t._)`${T} !== true && ${S} !== undefined`,()=>{b.if((0,t._)`${S} === true`,()=>b.assign(T,!0),()=>b.assign(T,(0,t._)`${T} || {}`).code((0,t._)`Object.assign(${T}, ${S})`))}),mergeToName:(b,S,T)=>b.if((0,t._)`${T} !== true`,()=>{S===!0?b.assign(T,!0):(b.assign(T,(0,t._)`${T} || {}`),g(b,T,S))}),mergeValues:(b,S)=>b===!0?!0:{...b,...S},resultToName:m}),items:_({mergeNames:(b,S,T)=>b.if((0,t._)`${T} !== true && ${S} !== undefined`,()=>b.assign(T,(0,t._)`${S} === true ? true : ${T} > ${S} ? ${T} : ${S}`)),mergeToName:(b,S,T)=>b.if((0,t._)`${T} !== true`,()=>b.assign(T,S===!0?!0:(0,t._)`${T} > ${S} ? ${T} : ${S}`)),mergeValues:(b,S)=>b===!0?!0:Math.max(b,S),resultToName:(b,S)=>b.var("items",S)})};function m(b,S){if(S===!0)return b.var("props",!0);const T=b.var("props",(0,t._)`{}`);return S!==void 0&&g(b,T,S),T}pe.evaluatedPropsToName=m;function g(b,S,T){Object.keys(T).forEach(N=>b.assign((0,t._)`${S}${(0,t.getProperty)(N)}`,!0))}pe.setEvaluated=g;const f={};function v(b,S){return b.scopeValue("func",{ref:S,code:f[S.code]||(f[S.code]=new e._Code(S.code))})}pe.useFunc=v;var h;(function(b){b[b.Num=0]="Num",b[b.Str=1]="Str"})(h||(pe.Type=h={}));function w(b,S,T){if(b instanceof t.Name){const N=S===h.Num;return T?N?(0,t._)`"[" + ${b} + "]"`:(0,t._)`"['" + ${b} + "']"`:N?(0,t._)`"/" + ${b}`:(0,t._)`"/" + ${b}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return T?(0,t.getProperty)(b).toString():"/"+l(b)}pe.getErrorPath=w;function $(b,S,T=b.opts.strictSchema){if(T){if(S=`strict mode: ${S}`,T===!0)throw new Error(S);b.self.logger.warn(S)}}return pe.checkStrictMode=$,pe}var Wn={},bc;function Bt(){if(bc)return Wn;bc=1,Object.defineProperty(Wn,"__esModule",{value:!0});const t=fe(),e={data:new t.Name("data"),valCxt:new t.Name("valCxt"),instancePath:new t.Name("instancePath"),parentData:new t.Name("parentData"),parentDataProperty:new t.Name("parentDataProperty"),rootData:new t.Name("rootData"),dynamicAnchors:new t.Name("dynamicAnchors"),vErrors:new t.Name("vErrors"),errors:new t.Name("errors"),this:new t.Name("this"),self:new t.Name("self"),scope:new t.Name("scope"),json:new t.Name("json"),jsonPos:new t.Name("jsonPos"),jsonLen:new t.Name("jsonLen"),jsonPart:new t.Name("jsonPart")};return Wn.default=e,Wn}var $c;function Jn(){return $c||($c=1,(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.extendErrors=t.resetErrorsCount=t.reportExtraError=t.reportError=t.keyword$DataError=t.keywordError=void 0;const e=fe(),r=be(),n=Bt();t.keywordError={message:({keyword:f})=>(0,e.str)`must pass "${f}" keyword validation`},t.keyword$DataError={message:({keyword:f,schemaType:v})=>v?(0,e.str)`"${f}" keyword must be ${v} ($data)`:(0,e.str)`"${f}" keyword is invalid ($data)`};function s(f,v=t.keywordError,h,w){const{it:$}=f,{gen:b,compositeRule:S,allErrors:T}=$,N=d(f,v,h);w??(S||T)?c(b,N):u($,(0,e._)`[${N}]`)}t.reportError=s;function o(f,v=t.keywordError,h){const{it:w}=f,{gen:$,compositeRule:b,allErrors:S}=w,T=d(f,v,h);c($,T),b||S||u(w,n.default.vErrors)}t.reportExtraError=o;function i(f,v){f.assign(n.default.errors,v),f.if((0,e._)`${n.default.vErrors} !== null`,()=>f.if(v,()=>f.assign((0,e._)`${n.default.vErrors}.length`,v),()=>f.assign(n.default.vErrors,null)))}t.resetErrorsCount=i;function a({gen:f,keyword:v,schemaValue:h,data:w,errsCount:$,it:b}){if($===void 0)throw new Error("ajv implementation error");const S=f.name("err");f.forRange("i",$,n.default.errors,T=>{f.const(S,(0,e._)`${n.default.vErrors}[${T}]`),f.if((0,e._)`${S}.instancePath === undefined`,()=>f.assign((0,e._)`${S}.instancePath`,(0,e.strConcat)(n.default.instancePath,b.errorPath))),f.assign((0,e._)`${S}.schemaPath`,(0,e.str)`${b.errSchemaPath}/${v}`),b.opts.verbose&&(f.assign((0,e._)`${S}.schema`,h),f.assign((0,e._)`${S}.data`,w))})}t.extendErrors=a;function c(f,v){const h=f.const("err",v);f.if((0,e._)`${n.default.vErrors} === null`,()=>f.assign(n.default.vErrors,(0,e._)`[${h}]`),(0,e._)`${n.default.vErrors}.push(${h})`),f.code((0,e._)`${n.default.errors}++`)}function u(f,v){const{gen:h,validateName:w,schemaEnv:$}=f;$.$async?h.throw((0,e._)`new ${f.ValidationError}(${v})`):(h.assign((0,e._)`${w}.errors`,v),h.return(!1))}const l={keyword:new e.Name("keyword"),schemaPath:new e.Name("schemaPath"),params:new e.Name("params"),propertyName:new e.Name("propertyName"),message:new e.Name("message"),schema:new e.Name("schema"),parentSchema:new e.Name("parentSchema")};function d(f,v,h){const{createErrors:w}=f.it;return w===!1?(0,e._)`{}`:p(f,v,h)}function p(f,v,h={}){const{gen:w,it:$}=f,b=[_($,h),m(f,h)];return g(f,v,b),w.object(...b)}function _({errorPath:f},{instancePath:v}){const h=v?(0,e.str)`${f}${(0,r.getErrorPath)(v,r.Type.Str)}`:f;return[n.default.instancePath,(0,e.strConcat)(n.default.instancePath,h)]}function m({keyword:f,it:{errSchemaPath:v}},{schemaPath:h,parentSchema:w}){let $=w?v:(0,e.str)`${v}/${f}`;return h&&($=(0,e.str)`${$}${(0,r.getErrorPath)(h,r.Type.Str)}`),[l.schemaPath,$]}function g(f,{params:v,message:h},w){const{keyword:$,data:b,schemaValue:S,it:T}=f,{opts:N,propertyName:j,topSchemaRef:F,schemaPath:q}=T;w.push([l.keyword,$],[l.params,typeof v=="function"?v(f):v||(0,e._)`{}`]),N.messages&&w.push([l.message,typeof h=="function"?h(f):h]),N.verbose&&w.push([l.schema,S],[l.parentSchema,(0,e._)`${F}${q}`],[n.default.data,b]),j&&w.push([l.propertyName,j])}})(Vo)),Vo}var Sc;function $f(){if(Sc)return ur;Sc=1,Object.defineProperty(ur,"__esModule",{value:!0}),ur.boolOrEmptySchema=ur.topBoolOrEmptySchema=void 0;const t=Jn(),e=fe(),r=Bt(),n={message:"boolean schema is false"};function s(a){const{gen:c,schema:u,validateName:l}=a;u===!1?i(a,!1):typeof u=="object"&&u.$async===!0?c.return(r.default.data):(c.assign((0,e._)`${l}.errors`,null),c.return(!0))}ur.topBoolOrEmptySchema=s;function o(a,c){const{gen:u,schema:l}=a;l===!1?(u.var(c,!1),i(a)):u.var(c,!0)}ur.boolOrEmptySchema=o;function i(a,c){const{gen:u,data:l}=a,d={gen:u,keyword:"false schema",data:l,schema:!1,schemaCode:!1,schemaValue:!1,params:{},it:a};(0,t.reportError)(d,n,void 0,c)}return ur}var De={},lr={},kc;function Tc(){if(kc)return lr;kc=1,Object.defineProperty(lr,"__esModule",{value:!0}),lr.getRules=lr.isJSONType=void 0;const t=["string","number","integer","boolean","null","object","array"],e=new Set(t);function r(s){return typeof s=="string"&&e.has(s)}lr.isJSONType=r;function n(){const s={number:{type:"number",rules:[]},string:{type:"string",rules:[]},array:{type:"array",rules:[]},object:{type:"object",rules:[]}};return{types:{...s,integer:!0,boolean:!0,null:!0},rules:[{rules:[]},s.number,s.string,s.array,s.object],post:{rules:[]},all:{},keywords:{}}}return lr.getRules=n,lr}var Ut={},Rc;function Ec(){if(Rc)return Ut;Rc=1,Object.defineProperty(Ut,"__esModule",{value:!0}),Ut.shouldUseRule=Ut.shouldUseGroup=Ut.schemaHasRulesForType=void 0;function t({schema:n,self:s},o){const i=s.RULES.types[o];return i&&i!==!0&&e(n,i)}Ut.schemaHasRulesForType=t;function e(n,s){return s.rules.some(o=>r(n,o))}Ut.shouldUseGroup=e;function r(n,s){var o;return n[s.keyword]!==void 0||((o=s.definition.implements)===null||o===void 0?void 0:o.some(i=>n[i]!==void 0))}return Ut.shouldUseRule=r,Ut}var Pc;function Bn(){if(Pc)return De;Pc=1,Object.defineProperty(De,"__esModule",{value:!0}),De.reportTypeError=De.checkDataTypes=De.checkDataType=De.coerceAndCheckDataType=De.getJSONTypes=De.getSchemaTypes=De.DataType=void 0;const t=Tc(),e=Ec(),r=Jn(),n=fe(),s=be();var o;(function(h){h[h.Correct=0]="Correct",h[h.Wrong=1]="Wrong"})(o||(De.DataType=o={}));function i(h){const w=a(h.type);if(w.includes("null")){if(h.nullable===!1)throw new Error("type: null contradicts nullable: false")}else{if(!w.length&&h.nullable!==void 0)throw new Error('"nullable" cannot be used without "type"');h.nullable===!0&&w.push("null")}return w}De.getSchemaTypes=i;function a(h){const w=Array.isArray(h)?h:h?[h]:[];if(w.every(t.isJSONType))return w;throw new Error("type must be JSONType or JSONType[]: "+w.join(","))}De.getJSONTypes=a;function c(h,w){const{gen:$,data:b,opts:S}=h,T=l(w,S.coerceTypes),N=w.length>0&&!(T.length===0&&w.length===1&&(0,e.schemaHasRulesForType)(h,w[0]));if(N){const j=m(w,b,S.strictNumbers,o.Wrong);$.if(j,()=>{T.length?d(h,w,T):f(h)})}return N}De.coerceAndCheckDataType=c;const u=new Set(["string","number","integer","boolean","null"]);function l(h,w){return w?h.filter($=>u.has($)||w==="array"&&$==="array"):[]}function d(h,w,$){const{gen:b,data:S,opts:T}=h,N=b.let("dataType",(0,n._)`typeof ${S}`),j=b.let("coerced",(0,n._)`undefined`);T.coerceTypes==="array"&&b.if((0,n._)`${N} == 'object' && Array.isArray(${S}) && ${S}.length == 1`,()=>b.assign(S,(0,n._)`${S}[0]`).assign(N,(0,n._)`typeof ${S}`).if(m(w,S,T.strictNumbers),()=>b.assign(j,S))),b.if((0,n._)`${j} !== undefined`);for(const q of $)(u.has(q)||q==="array"&&T.coerceTypes==="array")&&F(q);b.else(),f(h),b.endIf(),b.if((0,n._)`${j} !== undefined`,()=>{b.assign(S,j),p(h,j)});function F(q){switch(q){case"string":b.elseIf((0,n._)`${N} == "number" || ${N} == "boolean"`).assign(j,(0,n._)`"" + ${S}`).elseIf((0,n._)`${S} === null`).assign(j,(0,n._)`""`);return;case"number":b.elseIf((0,n._)`${N} == "boolean" || ${S} === null
|
|
3
|
+
|| (${N} == "string" && ${S} && ${S} == +${S})`).assign(j,(0,n._)`+${S}`);return;case"integer":b.elseIf((0,n._)`${N} === "boolean" || ${S} === null
|
|
4
|
+
|| (${N} === "string" && ${S} && ${S} == +${S} && !(${S} % 1))`).assign(j,(0,n._)`+${S}`);return;case"boolean":b.elseIf((0,n._)`${S} === "false" || ${S} === 0 || ${S} === null`).assign(j,!1).elseIf((0,n._)`${S} === "true" || ${S} === 1`).assign(j,!0);return;case"null":b.elseIf((0,n._)`${S} === "" || ${S} === 0 || ${S} === false`),b.assign(j,null);return;case"array":b.elseIf((0,n._)`${N} === "string" || ${N} === "number"
|
|
5
|
+
|| ${N} === "boolean" || ${S} === null`).assign(j,(0,n._)`[${S}]`)}}}function p({gen:h,parentData:w,parentDataProperty:$},b){h.if((0,n._)`${w} !== undefined`,()=>h.assign((0,n._)`${w}[${$}]`,b))}function _(h,w,$,b=o.Correct){const S=b===o.Correct?n.operators.EQ:n.operators.NEQ;let T;switch(h){case"null":return(0,n._)`${w} ${S} null`;case"array":T=(0,n._)`Array.isArray(${w})`;break;case"object":T=(0,n._)`${w} && typeof ${w} == "object" && !Array.isArray(${w})`;break;case"integer":T=N((0,n._)`!(${w} % 1) && !isNaN(${w})`);break;case"number":T=N();break;default:return(0,n._)`typeof ${w} ${S} ${h}`}return b===o.Correct?T:(0,n.not)(T);function N(j=n.nil){return(0,n.and)((0,n._)`typeof ${w} == "number"`,j,$?(0,n._)`isFinite(${w})`:n.nil)}}De.checkDataType=_;function m(h,w,$,b){if(h.length===1)return _(h[0],w,$,b);let S;const T=(0,s.toHash)(h);if(T.array&&T.object){const N=(0,n._)`typeof ${w} != "object"`;S=T.null?N:(0,n._)`!${w} || ${N}`,delete T.null,delete T.array,delete T.object}else S=n.nil;T.number&&delete T.integer;for(const N in T)S=(0,n.and)(S,_(N,w,$,b));return S}De.checkDataTypes=m;const g={message:({schema:h})=>`must be ${h}`,params:({schema:h,schemaValue:w})=>typeof h=="string"?(0,n._)`{type: ${h}}`:(0,n._)`{type: ${w}}`};function f(h){const w=v(h);(0,r.reportError)(w,g)}De.reportTypeError=f;function v(h){const{gen:w,data:$,schema:b}=h,S=(0,s.schemaRefOrVal)(h,b,"type");return{gen:w,keyword:"type",data:$,schema:b.type,schemaCode:S,schemaValue:S,parentSchema:b,params:{},it:h}}return De}var Br={},xc;function Sf(){if(xc)return Br;xc=1,Object.defineProperty(Br,"__esModule",{value:!0}),Br.assignDefaults=void 0;const t=fe(),e=be();function r(s,o){const{properties:i,items:a}=s.schema;if(o==="object"&&i)for(const c in i)n(s,c,i[c].default);else o==="array"&&Array.isArray(a)&&a.forEach((c,u)=>n(s,u,c.default))}Br.assignDefaults=r;function n(s,o,i){const{gen:a,compositeRule:c,data:u,opts:l}=s;if(i===void 0)return;const d=(0,t._)`${u}${(0,t.getProperty)(o)}`;if(c){(0,e.checkStrictMode)(s,`default is ignored for: ${d}`);return}let p=(0,t._)`${d} === undefined`;l.useDefaults==="empty"&&(p=(0,t._)`${p} || ${d} === null || ${d} === ""`),a.if(p,(0,t._)`${d} = ${(0,t.stringify)(i)}`)}return Br}var vt={},Te={},Ic;function yt(){if(Ic)return Te;Ic=1,Object.defineProperty(Te,"__esModule",{value:!0}),Te.validateUnion=Te.validateArray=Te.usePattern=Te.callValidateCode=Te.schemaProperties=Te.allSchemaProperties=Te.noPropertyInData=Te.propertyInData=Te.isOwnProperty=Te.hasPropFunc=Te.reportMissingProp=Te.checkMissingProp=Te.checkReportMissingProp=void 0;const t=fe(),e=be(),r=Bt(),n=be();function s(h,w){const{gen:$,data:b,it:S}=h;$.if(l($,b,w,S.opts.ownProperties),()=>{h.setParams({missingProperty:(0,t._)`${w}`},!0),h.error()})}Te.checkReportMissingProp=s;function o({gen:h,data:w,it:{opts:$}},b,S){return(0,t.or)(...b.map(T=>(0,t.and)(l(h,w,T,$.ownProperties),(0,t._)`${S} = ${T}`)))}Te.checkMissingProp=o;function i(h,w){h.setParams({missingProperty:w},!0),h.error()}Te.reportMissingProp=i;function a(h){return h.scopeValue("func",{ref:Object.prototype.hasOwnProperty,code:(0,t._)`Object.prototype.hasOwnProperty`})}Te.hasPropFunc=a;function c(h,w,$){return(0,t._)`${a(h)}.call(${w}, ${$})`}Te.isOwnProperty=c;function u(h,w,$,b){const S=(0,t._)`${w}${(0,t.getProperty)($)} !== undefined`;return b?(0,t._)`${S} && ${c(h,w,$)}`:S}Te.propertyInData=u;function l(h,w,$,b){const S=(0,t._)`${w}${(0,t.getProperty)($)} === undefined`;return b?(0,t.or)(S,(0,t.not)(c(h,w,$))):S}Te.noPropertyInData=l;function d(h){return h?Object.keys(h).filter(w=>w!=="__proto__"):[]}Te.allSchemaProperties=d;function p(h,w){return d(w).filter($=>!(0,e.alwaysValidSchema)(h,w[$]))}Te.schemaProperties=p;function _({schemaCode:h,data:w,it:{gen:$,topSchemaRef:b,schemaPath:S,errorPath:T},it:N},j,F,q){const W=q?(0,t._)`${h}, ${w}, ${b}${S}`:w,K=[[r.default.instancePath,(0,t.strConcat)(r.default.instancePath,T)],[r.default.parentData,N.parentData],[r.default.parentDataProperty,N.parentDataProperty],[r.default.rootData,r.default.rootData]];N.opts.dynamicRef&&K.push([r.default.dynamicAnchors,r.default.dynamicAnchors]);const G=(0,t._)`${W}, ${$.object(...K)}`;return F!==t.nil?(0,t._)`${j}.call(${F}, ${G})`:(0,t._)`${j}(${G})`}Te.callValidateCode=_;const m=(0,t._)`new RegExp`;function g({gen:h,it:{opts:w}},$){const b=w.unicodeRegExp?"u":"",{regExp:S}=w.code,T=S($,b);return h.scopeValue("pattern",{key:T.toString(),ref:T,code:(0,t._)`${S.code==="new RegExp"?m:(0,n.useFunc)(h,S)}(${$}, ${b})`})}Te.usePattern=g;function f(h){const{gen:w,data:$,keyword:b,it:S}=h,T=w.name("valid");if(S.allErrors){const j=w.let("valid",!0);return N(()=>w.assign(j,!1)),j}return w.var(T,!0),N(()=>w.break()),T;function N(j){const F=w.const("len",(0,t._)`${$}.length`);w.forRange("i",0,F,q=>{h.subschema({keyword:b,dataProp:q,dataPropType:e.Type.Num},T),w.if((0,t.not)(T),j)})}}Te.validateArray=f;function v(h){const{gen:w,schema:$,keyword:b,it:S}=h;if(!Array.isArray($))throw new Error("ajv implementation error");if($.some(F=>(0,e.alwaysValidSchema)(S,F))&&!S.opts.unevaluated)return;const N=w.let("valid",!1),j=w.name("_valid");w.block(()=>$.forEach((F,q)=>{const W=h.subschema({keyword:b,schemaProp:q,compositeRule:!0},j);w.assign(N,(0,t._)`${N} || ${j}`),h.mergeValidEvaluated(W,j)||w.if((0,t.not)(N))})),h.result(N,()=>h.reset(),()=>h.error(!0))}return Te.validateUnion=v,Te}var Cc;function kf(){if(Cc)return vt;Cc=1,Object.defineProperty(vt,"__esModule",{value:!0}),vt.validateKeywordUsage=vt.validSchemaType=vt.funcKeywordCode=vt.macroKeywordCode=void 0;const t=fe(),e=Bt(),r=yt(),n=Jn();function s(p,_){const{gen:m,keyword:g,schema:f,parentSchema:v,it:h}=p,w=_.macro.call(h.self,f,v,h),$=u(m,g,w);h.opts.validateSchema!==!1&&h.self.validateSchema(w,!0);const b=m.name("valid");p.subschema({schema:w,schemaPath:t.nil,errSchemaPath:`${h.errSchemaPath}/${g}`,topSchemaRef:$,compositeRule:!0},b),p.pass(b,()=>p.error(!0))}vt.macroKeywordCode=s;function o(p,_){var m;const{gen:g,keyword:f,schema:v,parentSchema:h,$data:w,it:$}=p;c($,_);const b=!w&&_.compile?_.compile.call($.self,v,h,$):_.validate,S=u(g,f,b),T=g.let("valid");p.block$data(T,N),p.ok((m=_.valid)!==null&&m!==void 0?m:T);function N(){if(_.errors===!1)q(),_.modifying&&i(p),W(()=>p.error());else{const K=_.async?j():F();_.modifying&&i(p),W(()=>a(p,K))}}function j(){const K=g.let("ruleErrs",null);return g.try(()=>q((0,t._)`await `),G=>g.assign(T,!1).if((0,t._)`${G} instanceof ${$.ValidationError}`,()=>g.assign(K,(0,t._)`${G}.errors`),()=>g.throw(G))),K}function F(){const K=(0,t._)`${S}.errors`;return g.assign(K,null),q(t.nil),K}function q(K=_.async?(0,t._)`await `:t.nil){const G=$.opts.passContext?e.default.this:e.default.self,ke=!("compile"in _&&!w||_.schema===!1);g.assign(T,(0,t._)`${K}${(0,r.callValidateCode)(p,S,G,ke)}`,_.modifying)}function W(K){var G;g.if((0,t.not)((G=_.valid)!==null&&G!==void 0?G:T),K)}}vt.funcKeywordCode=o;function i(p){const{gen:_,data:m,it:g}=p;_.if(g.parentData,()=>_.assign(m,(0,t._)`${g.parentData}[${g.parentDataProperty}]`))}function a(p,_){const{gen:m}=p;m.if((0,t._)`Array.isArray(${_})`,()=>{m.assign(e.default.vErrors,(0,t._)`${e.default.vErrors} === null ? ${_} : ${e.default.vErrors}.concat(${_})`).assign(e.default.errors,(0,t._)`${e.default.vErrors}.length`),(0,n.extendErrors)(p)},()=>p.error())}function c({schemaEnv:p},_){if(_.async&&!p.$async)throw new Error("async keyword in sync schema")}function u(p,_,m){if(m===void 0)throw new Error(`keyword "${_}" failed to compile`);return p.scopeValue("keyword",typeof m=="function"?{ref:m}:{ref:m,code:(0,t.stringify)(m)})}function l(p,_,m=!1){return!_.length||_.some(g=>g==="array"?Array.isArray(p):g==="object"?p&&typeof p=="object"&&!Array.isArray(p):typeof p==g||m&&typeof p>"u")}vt.validSchemaType=l;function d({schema:p,opts:_,self:m,errSchemaPath:g},f,v){if(Array.isArray(f.keyword)?!f.keyword.includes(v):f.keyword!==v)throw new Error("ajv implementation error");const h=f.dependencies;if(h?.some(w=>!Object.prototype.hasOwnProperty.call(p,w)))throw new Error(`parent schema must have dependencies of ${v}: ${h.join(",")}`);if(f.validateSchema&&!f.validateSchema(p[v])){const $=`keyword "${v}" value is invalid at path "${g}": `+m.errorsText(f.validateSchema.errors);if(_.validateSchema==="log")m.logger.error($);else throw new Error($)}}return vt.validateKeywordUsage=d,vt}var Lt={},Oc;function Tf(){if(Oc)return Lt;Oc=1,Object.defineProperty(Lt,"__esModule",{value:!0}),Lt.extendSubschemaMode=Lt.extendSubschemaData=Lt.getSubschema=void 0;const t=fe(),e=be();function r(o,{keyword:i,schemaProp:a,schema:c,schemaPath:u,errSchemaPath:l,topSchemaRef:d}){if(i!==void 0&&c!==void 0)throw new Error('both "keyword" and "schema" passed, only one allowed');if(i!==void 0){const p=o.schema[i];return a===void 0?{schema:p,schemaPath:(0,t._)`${o.schemaPath}${(0,t.getProperty)(i)}`,errSchemaPath:`${o.errSchemaPath}/${i}`}:{schema:p[a],schemaPath:(0,t._)`${o.schemaPath}${(0,t.getProperty)(i)}${(0,t.getProperty)(a)}`,errSchemaPath:`${o.errSchemaPath}/${i}/${(0,e.escapeFragment)(a)}`}}if(c!==void 0){if(u===void 0||l===void 0||d===void 0)throw new Error('"schemaPath", "errSchemaPath" and "topSchemaRef" are required with "schema"');return{schema:c,schemaPath:u,topSchemaRef:d,errSchemaPath:l}}throw new Error('either "keyword" or "schema" must be passed')}Lt.getSubschema=r;function n(o,i,{dataProp:a,dataPropType:c,data:u,dataTypes:l,propertyName:d}){if(u!==void 0&&a!==void 0)throw new Error('both "data" and "dataProp" passed, only one allowed');const{gen:p}=i;if(a!==void 0){const{errorPath:m,dataPathArr:g,opts:f}=i,v=p.let("data",(0,t._)`${i.data}${(0,t.getProperty)(a)}`,!0);_(v),o.errorPath=(0,t.str)`${m}${(0,e.getErrorPath)(a,c,f.jsPropertySyntax)}`,o.parentDataProperty=(0,t._)`${a}`,o.dataPathArr=[...g,o.parentDataProperty]}if(u!==void 0){const m=u instanceof t.Name?u:p.let("data",u,!0);_(m),d!==void 0&&(o.propertyName=d)}l&&(o.dataTypes=l);function _(m){o.data=m,o.dataLevel=i.dataLevel+1,o.dataTypes=[],i.definedProperties=new Set,o.parentData=i.data,o.dataNames=[...i.dataNames,m]}}Lt.extendSubschemaData=n;function s(o,{jtdDiscriminator:i,jtdMetadata:a,compositeRule:c,createErrors:u,allErrors:l}){c!==void 0&&(o.compositeRule=c),u!==void 0&&(o.createErrors=u),l!==void 0&&(o.allErrors=l),o.jtdDiscriminator=i,o.jtdMetadata=a}return Lt.extendSubschemaMode=s,Lt}var Qe={},Jo,Nc;function Ac(){return Nc||(Nc=1,Jo=function t(e,r){if(e===r)return!0;if(e&&r&&typeof e=="object"&&typeof r=="object"){if(e.constructor!==r.constructor)return!1;var n,s,o;if(Array.isArray(e)){if(n=e.length,n!=r.length)return!1;for(s=n;s--!==0;)if(!t(e[s],r[s]))return!1;return!0}if(e.constructor===RegExp)return e.source===r.source&&e.flags===r.flags;if(e.valueOf!==Object.prototype.valueOf)return e.valueOf()===r.valueOf();if(e.toString!==Object.prototype.toString)return e.toString()===r.toString();if(o=Object.keys(e),n=o.length,n!==Object.keys(r).length)return!1;for(s=n;s--!==0;)if(!Object.prototype.hasOwnProperty.call(r,o[s]))return!1;for(s=n;s--!==0;){var i=o[s];if(!t(e[i],r[i]))return!1}return!0}return e!==e&&r!==r}),Jo}var Bo={exports:{}},Mc;function Rf(){if(Mc)return Bo.exports;Mc=1;var t=Bo.exports=function(n,s,o){typeof s=="function"&&(o=s,s={}),o=s.cb||o;var i=typeof o=="function"?o:o.pre||function(){},a=o.post||function(){};e(s,i,a,n,"",n)};t.keywords={additionalItems:!0,items:!0,contains:!0,additionalProperties:!0,propertyNames:!0,not:!0,if:!0,then:!0,else:!0},t.arrayKeywords={items:!0,allOf:!0,anyOf:!0,oneOf:!0},t.propsKeywords={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependencies:!0},t.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 e(n,s,o,i,a,c,u,l,d,p){if(i&&typeof i=="object"&&!Array.isArray(i)){s(i,a,c,u,l,d,p);for(var _ in i){var m=i[_];if(Array.isArray(m)){if(_ in t.arrayKeywords)for(var g=0;g<m.length;g++)e(n,s,o,m[g],a+"/"+_+"/"+g,c,a,_,i,g)}else if(_ in t.propsKeywords){if(m&&typeof m=="object")for(var f in m)e(n,s,o,m[f],a+"/"+_+"/"+r(f),c,a,_,i,f)}else(_ in t.keywords||n.allKeys&&!(_ in t.skipKeywords))&&e(n,s,o,m,a+"/"+_,c,a,_,i)}o(i,a,c,u,l,d,p)}}function r(n){return n.replace(/~/g,"~0").replace(/\//g,"~1")}return Bo.exports}var jc;function Kn(){if(jc)return Qe;jc=1,Object.defineProperty(Qe,"__esModule",{value:!0}),Qe.getSchemaRefs=Qe.resolveUrl=Qe.normalizeId=Qe._getFullPath=Qe.getFullPath=Qe.inlineRef=void 0;const t=be(),e=Ac(),r=Rf(),n=new Set(["type","format","pattern","maxLength","minLength","maxProperties","minProperties","maxItems","minItems","maximum","minimum","uniqueItems","multipleOf","required","enum","const"]);function s(g,f=!0){return typeof g=="boolean"?!0:f===!0?!i(g):f?a(g)<=f:!1}Qe.inlineRef=s;const o=new Set(["$ref","$recursiveRef","$recursiveAnchor","$dynamicRef","$dynamicAnchor"]);function i(g){for(const f in g){if(o.has(f))return!0;const v=g[f];if(Array.isArray(v)&&v.some(i)||typeof v=="object"&&i(v))return!0}return!1}function a(g){let f=0;for(const v in g){if(v==="$ref")return 1/0;if(f++,!n.has(v)&&(typeof g[v]=="object"&&(0,t.eachItem)(g[v],h=>f+=a(h)),f===1/0))return 1/0}return f}function c(g,f="",v){v!==!1&&(f=d(f));const h=g.parse(f);return u(g,h)}Qe.getFullPath=c;function u(g,f){return g.serialize(f).split("#")[0]+"#"}Qe._getFullPath=u;const l=/#\/?$/;function d(g){return g?g.replace(l,""):""}Qe.normalizeId=d;function p(g,f,v){return v=d(v),g.resolve(f,v)}Qe.resolveUrl=p;const _=/^[a-z_][-a-z0-9._]*$/i;function m(g,f){if(typeof g=="boolean")return{};const{schemaId:v,uriResolver:h}=this.opts,w=d(g[v]||f),$={"":w},b=c(h,w,!1),S={},T=new Set;return r(g,{allKeys:!0},(F,q,W,K)=>{if(K===void 0)return;const G=b+q;let ke=$[K];typeof F[v]=="string"&&(ke=tt.call(this,F[v])),rt.call(this,F.$anchor),rt.call(this,F.$dynamicAnchor),$[q]=ke;function tt(xe){const Ot=this.opts.uriResolver.resolve;if(xe=d(ke?Ot(ke,xe):xe),T.has(xe))throw j(xe);T.add(xe);let V=this.refs[xe];return typeof V=="string"&&(V=this.refs[V]),typeof V=="object"?N(F,V.schema,xe):xe!==d(G)&&(xe[0]==="#"?(N(F,S[xe],xe),S[xe]=F):this.refs[xe]=G),xe}function rt(xe){if(typeof xe=="string"){if(!_.test(xe))throw new Error(`invalid anchor "${xe}"`);tt.call(this,`#${xe}`)}}}),S;function N(F,q,W){if(q!==void 0&&!e(F,q))throw j(W)}function j(F){return new Error(`reference "${F}" resolves to more than one schema`)}}return Qe.getSchemaRefs=m,Qe}var qc;function Gn(){if(qc)return zt;qc=1,Object.defineProperty(zt,"__esModule",{value:!0}),zt.getData=zt.KeywordCxt=zt.validateFunctionCode=void 0;const t=$f(),e=Bn(),r=Ec(),n=Bn(),s=Sf(),o=kf(),i=Tf(),a=fe(),c=Bt(),u=Kn(),l=be(),d=Jn();function p(E){if(b(E)&&(T(E),$(E))){f(E);return}_(E,()=>(0,t.topBoolOrEmptySchema)(E))}zt.validateFunctionCode=p;function _({gen:E,validateName:I,schema:U,schemaEnv:H,opts:te},me){te.code.es5?E.func(I,(0,a._)`${c.default.data}, ${c.default.valCxt}`,H.$async,()=>{E.code((0,a._)`"use strict"; ${h(U,te)}`),g(E,te),E.code(me)}):E.func(I,(0,a._)`${c.default.data}, ${m(te)}`,H.$async,()=>E.code(h(U,te)).code(me))}function m(E){return(0,a._)`{${c.default.instancePath}="", ${c.default.parentData}, ${c.default.parentDataProperty}, ${c.default.rootData}=${c.default.data}${E.dynamicRef?(0,a._)`, ${c.default.dynamicAnchors}={}`:a.nil}}={}`}function g(E,I){E.if(c.default.valCxt,()=>{E.var(c.default.instancePath,(0,a._)`${c.default.valCxt}.${c.default.instancePath}`),E.var(c.default.parentData,(0,a._)`${c.default.valCxt}.${c.default.parentData}`),E.var(c.default.parentDataProperty,(0,a._)`${c.default.valCxt}.${c.default.parentDataProperty}`),E.var(c.default.rootData,(0,a._)`${c.default.valCxt}.${c.default.rootData}`),I.dynamicRef&&E.var(c.default.dynamicAnchors,(0,a._)`${c.default.valCxt}.${c.default.dynamicAnchors}`)},()=>{E.var(c.default.instancePath,(0,a._)`""`),E.var(c.default.parentData,(0,a._)`undefined`),E.var(c.default.parentDataProperty,(0,a._)`undefined`),E.var(c.default.rootData,c.default.data),I.dynamicRef&&E.var(c.default.dynamicAnchors,(0,a._)`{}`)})}function f(E){const{schema:I,opts:U,gen:H}=E;_(E,()=>{U.$comment&&I.$comment&&K(E),F(E),H.let(c.default.vErrors,null),H.let(c.default.errors,0),U.unevaluated&&v(E),N(E),G(E)})}function v(E){const{gen:I,validateName:U}=E;E.evaluated=I.const("evaluated",(0,a._)`${U}.evaluated`),I.if((0,a._)`${E.evaluated}.dynamicProps`,()=>I.assign((0,a._)`${E.evaluated}.props`,(0,a._)`undefined`)),I.if((0,a._)`${E.evaluated}.dynamicItems`,()=>I.assign((0,a._)`${E.evaluated}.items`,(0,a._)`undefined`))}function h(E,I){const U=typeof E=="object"&&E[I.schemaId];return U&&(I.code.source||I.code.process)?(0,a._)`/*# sourceURL=${U} */`:a.nil}function w(E,I){if(b(E)&&(T(E),$(E))){S(E,I);return}(0,t.boolOrEmptySchema)(E,I)}function $({schema:E,self:I}){if(typeof E=="boolean")return!E;for(const U in E)if(I.RULES.all[U])return!0;return!1}function b(E){return typeof E.schema!="boolean"}function S(E,I){const{schema:U,gen:H,opts:te}=E;te.$comment&&U.$comment&&K(E),q(E),W(E);const me=H.const("_errs",c.default.errors);N(E,me),H.var(I,(0,a._)`${me} === ${c.default.errors}`)}function T(E){(0,l.checkUnknownRules)(E),j(E)}function N(E,I){if(E.opts.jtd)return tt(E,[],!1,I);const U=(0,e.getSchemaTypes)(E.schema),H=(0,e.coerceAndCheckDataType)(E,U);tt(E,U,!H,I)}function j(E){const{schema:I,errSchemaPath:U,opts:H,self:te}=E;I.$ref&&H.ignoreKeywordsWithRef&&(0,l.schemaHasRulesButRef)(I,te.RULES)&&te.logger.warn(`$ref: keywords ignored in schema at path "${U}"`)}function F(E){const{schema:I,opts:U}=E;I.default!==void 0&&U.useDefaults&&U.strictSchema&&(0,l.checkStrictMode)(E,"default is ignored in the schema root")}function q(E){const I=E.schema[E.opts.schemaId];I&&(E.baseId=(0,u.resolveUrl)(E.opts.uriResolver,E.baseId,I))}function W(E){if(E.schema.$async&&!E.schemaEnv.$async)throw new Error("async schema in sync schema")}function K({gen:E,schemaEnv:I,schema:U,errSchemaPath:H,opts:te}){const me=U.$comment;if(te.$comment===!0)E.code((0,a._)`${c.default.self}.logger.log(${me})`);else if(typeof te.$comment=="function"){const Ke=(0,a.str)`${H}/$comment`,Nt=E.scopeValue("root",{ref:I.root});E.code((0,a._)`${c.default.self}.opts.$comment(${me}, ${Ke}, ${Nt}.schema)`)}}function G(E){const{gen:I,schemaEnv:U,validateName:H,ValidationError:te,opts:me}=E;U.$async?I.if((0,a._)`${c.default.errors} === 0`,()=>I.return(c.default.data),()=>I.throw((0,a._)`new ${te}(${c.default.vErrors})`)):(I.assign((0,a._)`${H}.errors`,c.default.vErrors),me.unevaluated&&ke(E),I.return((0,a._)`${c.default.errors} === 0`))}function ke({gen:E,evaluated:I,props:U,items:H}){U instanceof a.Name&&E.assign((0,a._)`${I}.props`,U),H instanceof a.Name&&E.assign((0,a._)`${I}.items`,H)}function tt(E,I,U,H){const{gen:te,schema:me,data:Ke,allErrors:Nt,opts:at,self:ct}=E,{RULES:Ge}=ct;if(me.$ref&&(at.ignoreKeywordsWithRef||!(0,l.schemaHasRulesButRef)(me,Ge))){te.block(()=>X(E,"$ref",Ge.all.$ref.definition));return}at.jtd||xe(E,I),te.block(()=>{for(const gt of Ge.rules)Jr(gt);Jr(Ge.post)});function Jr(gt){(0,r.shouldUseGroup)(me,gt)&&(gt.type?(te.if((0,n.checkDataType)(gt.type,Ke,at.strictNumbers)),rt(E,gt),I.length===1&&I[0]===gt.type&&U&&(te.else(),(0,n.reportTypeError)(E)),te.endIf()):rt(E,gt),Nt||te.if((0,a._)`${c.default.errors} === ${H||0}`))}}function rt(E,I){const{gen:U,schema:H,opts:{useDefaults:te}}=E;te&&(0,s.assignDefaults)(E,I.type),U.block(()=>{for(const me of I.rules)(0,r.shouldUseRule)(H,me)&&X(E,me.keyword,me.definition,I.type)})}function xe(E,I){E.schemaEnv.meta||!E.opts.strictTypes||(Ot(E,I),E.opts.allowUnionTypes||V(E,I),P(E,E.dataTypes))}function Ot(E,I){if(I.length){if(!E.dataTypes.length){E.dataTypes=I;return}I.forEach(U=>{O(E.dataTypes,U)||R(E,`type "${U}" not allowed by context "${E.dataTypes.join(",")}"`)}),k(E,I)}}function V(E,I){I.length>1&&!(I.length===2&&I.includes("null"))&&R(E,"use allowUnionTypes to allow union type keyword")}function P(E,I){const U=E.self.RULES.all;for(const H in U){const te=U[H];if(typeof te=="object"&&(0,r.shouldUseRule)(E.schema,te)){const{type:me}=te.definition;me.length&&!me.some(Ke=>L(I,Ke))&&R(E,`missing type "${me.join(",")}" for keyword "${H}"`)}}}function L(E,I){return E.includes(I)||I==="number"&&E.includes("integer")}function O(E,I){return E.includes(I)||I==="integer"&&E.includes("number")}function k(E,I){const U=[];for(const H of E.dataTypes)O(I,H)?U.push(H):I.includes("integer")&&H==="number"&&U.push("integer");E.dataTypes=U}function R(E,I){const U=E.schemaEnv.baseId+E.errSchemaPath;I+=` at "${U}" (strictTypes)`,(0,l.checkStrictMode)(E,I,E.opts.strictTypes)}class M{constructor(I,U,H){if((0,o.validateKeywordUsage)(I,U,H),this.gen=I.gen,this.allErrors=I.allErrors,this.keyword=H,this.data=I.data,this.schema=I.schema[H],this.$data=U.$data&&I.opts.$data&&this.schema&&this.schema.$data,this.schemaValue=(0,l.schemaRefOrVal)(I,this.schema,H,this.$data),this.schemaType=U.schemaType,this.parentSchema=I.schema,this.params={},this.it=I,this.def=U,this.$data)this.schemaCode=I.gen.const("vSchema",ve(this.$data,I));else if(this.schemaCode=this.schemaValue,!(0,o.validSchemaType)(this.schema,U.schemaType,U.allowUndefined))throw new Error(`${H} value must be ${JSON.stringify(U.schemaType)}`);("code"in U?U.trackErrors:U.errors!==!1)&&(this.errsCount=I.gen.const("_errs",c.default.errors))}result(I,U,H){this.failResult((0,a.not)(I),U,H)}failResult(I,U,H){this.gen.if(I),H?H():this.error(),U?(this.gen.else(),U(),this.allErrors&&this.gen.endIf()):this.allErrors?this.gen.endIf():this.gen.else()}pass(I,U){this.failResult((0,a.not)(I),void 0,U)}fail(I){if(I===void 0){this.error(),this.allErrors||this.gen.if(!1);return}this.gen.if(I),this.error(),this.allErrors?this.gen.endIf():this.gen.else()}fail$data(I){if(!this.$data)return this.fail(I);const{schemaCode:U}=this;this.fail((0,a._)`${U} !== undefined && (${(0,a.or)(this.invalid$data(),I)})`)}error(I,U,H){if(U){this.setParams(U),this._error(I,H),this.setParams({});return}this._error(I,H)}_error(I,U){(I?d.reportExtraError:d.reportError)(this,this.def.error,U)}$dataError(){(0,d.reportError)(this,this.def.$dataError||d.keyword$DataError)}reset(){if(this.errsCount===void 0)throw new Error('add "trackErrors" to keyword definition');(0,d.resetErrorsCount)(this.gen,this.errsCount)}ok(I){this.allErrors||this.gen.if(I)}setParams(I,U){U?Object.assign(this.params,I):this.params=I}block$data(I,U,H=a.nil){this.gen.block(()=>{this.check$data(I,H),U()})}check$data(I=a.nil,U=a.nil){if(!this.$data)return;const{gen:H,schemaCode:te,schemaType:me,def:Ke}=this;H.if((0,a.or)((0,a._)`${te} === undefined`,U)),I!==a.nil&&H.assign(I,!0),(me.length||Ke.validateSchema)&&(H.elseIf(this.invalid$data()),this.$dataError(),I!==a.nil&&H.assign(I,!1)),H.else()}invalid$data(){const{gen:I,schemaCode:U,schemaType:H,def:te,it:me}=this;return(0,a.or)(Ke(),Nt());function Ke(){if(H.length){if(!(U instanceof a.Name))throw new Error("ajv implementation error");const at=Array.isArray(H)?H:[H];return(0,a._)`${(0,n.checkDataTypes)(at,U,me.opts.strictNumbers,n.DataType.Wrong)}`}return a.nil}function Nt(){if(te.validateSchema){const at=I.scopeValue("validate$data",{ref:te.validateSchema});return(0,a._)`!${at}(${U})`}return a.nil}}subschema(I,U){const H=(0,i.getSubschema)(this.it,I);(0,i.extendSubschemaData)(H,this.it,I),(0,i.extendSubschemaMode)(H,I);const te={...this.it,...H,items:void 0,props:void 0};return w(te,U),te}mergeEvaluated(I,U){const{it:H,gen:te}=this;H.opts.unevaluated&&(H.props!==!0&&I.props!==void 0&&(H.props=l.mergeEvaluated.props(te,I.props,H.props,U)),H.items!==!0&&I.items!==void 0&&(H.items=l.mergeEvaluated.items(te,I.items,H.items,U)))}mergeValidEvaluated(I,U){const{it:H,gen:te}=this;if(H.opts.unevaluated&&(H.props!==!0||H.items!==!0))return te.if(U,()=>this.mergeEvaluated(I,a.Name)),!0}}zt.KeywordCxt=M;function X(E,I,U,H){const te=new M(E,U,I);"code"in U?U.code(te,H):te.$data&&U.validate?(0,o.funcKeywordCode)(te,U):"macro"in U?(0,o.macroKeywordCode)(te,U):(U.compile||U.validate)&&(0,o.funcKeywordCode)(te,U)}const re=/^\/(?:[^~]|~0|~1)*$/,Se=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function ve(E,{dataLevel:I,dataNames:U,dataPathArr:H}){let te,me;if(E==="")return c.default.rootData;if(E[0]==="/"){if(!re.test(E))throw new Error(`Invalid JSON-pointer: ${E}`);te=E,me=c.default.rootData}else{const ct=Se.exec(E);if(!ct)throw new Error(`Invalid JSON-pointer: ${E}`);const Ge=+ct[1];if(te=ct[2],te==="#"){if(Ge>=I)throw new Error(at("property/index",Ge));return H[I-Ge]}if(Ge>I)throw new Error(at("data",Ge));if(me=U[I-Ge],!te)return me}let Ke=me;const Nt=te.split("/");for(const ct of Nt)ct&&(me=(0,a._)`${me}${(0,a.getProperty)((0,l.unescapeJsonPointer)(ct))}`,Ke=(0,a._)`${Ke} && ${me}`);return Ke;function at(ct,Ge){return`Cannot access ${ct} ${Ge} levels up, current level is ${I}`}}return zt.getData=ve,zt}var Yn={},zc;function Ko(){if(zc)return Yn;zc=1,Object.defineProperty(Yn,"__esModule",{value:!0});class t extends Error{constructor(r){super("validation failed"),this.errors=r,this.ajv=this.validation=!0}}return Yn.default=t,Yn}var Qn={},Uc;function Xn(){if(Uc)return Qn;Uc=1,Object.defineProperty(Qn,"__esModule",{value:!0});const t=Kn();class e extends Error{constructor(n,s,o,i){super(i||`can't resolve reference ${o} from id ${s}`),this.missingRef=(0,t.resolveUrl)(n,s,o),this.missingSchema=(0,t.normalizeId)((0,t.getFullPath)(n,this.missingRef))}}return Qn.default=e,Qn}var ut={},Lc;function Go(){if(Lc)return ut;Lc=1,Object.defineProperty(ut,"__esModule",{value:!0}),ut.resolveSchema=ut.getCompilingSchema=ut.resolveRef=ut.compileSchema=ut.SchemaEnv=void 0;const t=fe(),e=Ko(),r=Bt(),n=Kn(),s=be(),o=Gn();class i{constructor(v){var h;this.refs={},this.dynamicAnchors={};let w;typeof v.schema=="object"&&(w=v.schema),this.schema=v.schema,this.schemaId=v.schemaId,this.root=v.root||this,this.baseId=(h=v.baseId)!==null&&h!==void 0?h:(0,n.normalizeId)(w?.[v.schemaId||"$id"]),this.schemaPath=v.schemaPath,this.localRefs=v.localRefs,this.meta=v.meta,this.$async=w?.$async,this.refs={}}}ut.SchemaEnv=i;function a(f){const v=l.call(this,f);if(v)return v;const h=(0,n.getFullPath)(this.opts.uriResolver,f.root.baseId),{es5:w,lines:$}=this.opts.code,{ownProperties:b}=this.opts,S=new t.CodeGen(this.scope,{es5:w,lines:$,ownProperties:b});let T;f.$async&&(T=S.scopeValue("Error",{ref:e.default,code:(0,t._)`require("ajv/dist/runtime/validation_error").default`}));const N=S.scopeName("validate");f.validateName=N;const j={gen:S,allErrors:this.opts.allErrors,data:r.default.data,parentData:r.default.parentData,parentDataProperty:r.default.parentDataProperty,dataNames:[r.default.data],dataPathArr:[t.nil],dataLevel:0,dataTypes:[],definedProperties:new Set,topSchemaRef:S.scopeValue("schema",this.opts.code.source===!0?{ref:f.schema,code:(0,t.stringify)(f.schema)}:{ref:f.schema}),validateName:N,ValidationError:T,schema:f.schema,schemaEnv:f,rootId:h,baseId:f.baseId||h,schemaPath:t.nil,errSchemaPath:f.schemaPath||(this.opts.jtd?"":"#"),errorPath:(0,t._)`""`,opts:this.opts,self:this};let F;try{this._compilations.add(f),(0,o.validateFunctionCode)(j),S.optimize(this.opts.code.optimize);const q=S.toString();F=`${S.scopeRefs(r.default.scope)}return ${q}`,this.opts.code.process&&(F=this.opts.code.process(F,f));const K=new Function(`${r.default.self}`,`${r.default.scope}`,F)(this,this.scope.get());if(this.scope.value(N,{ref:K}),K.errors=null,K.schema=f.schema,K.schemaEnv=f,f.$async&&(K.$async=!0),this.opts.code.source===!0&&(K.source={validateName:N,validateCode:q,scopeValues:S._values}),this.opts.unevaluated){const{props:G,items:ke}=j;K.evaluated={props:G instanceof t.Name?void 0:G,items:ke instanceof t.Name?void 0:ke,dynamicProps:G instanceof t.Name,dynamicItems:ke instanceof t.Name},K.source&&(K.source.evaluated=(0,t.stringify)(K.evaluated))}return f.validate=K,f}catch(q){throw delete f.validate,delete f.validateName,F&&this.logger.error("Error compiling schema, function code:",F),q}finally{this._compilations.delete(f)}}ut.compileSchema=a;function c(f,v,h){var w;h=(0,n.resolveUrl)(this.opts.uriResolver,v,h);const $=f.refs[h];if($)return $;let b=p.call(this,f,h);if(b===void 0){const S=(w=f.localRefs)===null||w===void 0?void 0:w[h],{schemaId:T}=this.opts;S&&(b=new i({schema:S,schemaId:T,root:f,baseId:v}))}if(b!==void 0)return f.refs[h]=u.call(this,b)}ut.resolveRef=c;function u(f){return(0,n.inlineRef)(f.schema,this.opts.inlineRefs)?f.schema:f.validate?f:a.call(this,f)}function l(f){for(const v of this._compilations)if(d(v,f))return v}ut.getCompilingSchema=l;function d(f,v){return f.schema===v.schema&&f.root===v.root&&f.baseId===v.baseId}function p(f,v){let h;for(;typeof(h=this.refs[v])=="string";)v=h;return h||this.schemas[v]||_.call(this,f,v)}function _(f,v){const h=this.opts.uriResolver.parse(v),w=(0,n._getFullPath)(this.opts.uriResolver,h);let $=(0,n.getFullPath)(this.opts.uriResolver,f.baseId,void 0);if(Object.keys(f.schema).length>0&&w===$)return g.call(this,h,f);const b=(0,n.normalizeId)(w),S=this.refs[b]||this.schemas[b];if(typeof S=="string"){const T=_.call(this,f,S);return typeof T?.schema!="object"?void 0:g.call(this,h,T)}if(typeof S?.schema=="object"){if(S.validate||a.call(this,S),b===(0,n.normalizeId)(v)){const{schema:T}=S,{schemaId:N}=this.opts,j=T[N];return j&&($=(0,n.resolveUrl)(this.opts.uriResolver,$,j)),new i({schema:T,schemaId:N,root:f,baseId:$})}return g.call(this,h,S)}}ut.resolveSchema=_;const m=new Set(["properties","patternProperties","enum","dependencies","definitions"]);function g(f,{baseId:v,schema:h,root:w}){var $;if((($=f.fragment)===null||$===void 0?void 0:$[0])!=="/")return;for(const T of f.fragment.slice(1).split("/")){if(typeof h=="boolean")return;const N=h[(0,s.unescapeFragment)(T)];if(N===void 0)return;h=N;const j=typeof h=="object"&&h[this.opts.schemaId];!m.has(T)&&j&&(v=(0,n.resolveUrl)(this.opts.uriResolver,v,j))}let b;if(typeof h!="boolean"&&h.$ref&&!(0,s.schemaHasRulesButRef)(h,this.RULES)){const T=(0,n.resolveUrl)(this.opts.uriResolver,v,h.$ref);b=_.call(this,w,T)}const{schemaId:S}=this.opts;if(b=b||new i({schema:h,schemaId:S,root:w,baseId:v}),b.schema!==b.root.schema)return b}return ut}const Ef={$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 es={},Kr={exports:{}},Yo,Zc;function Dc(){if(Zc)return Yo;Zc=1;const t=RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu),e=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 r(p){let _="",m=0,g=0;for(g=0;g<p.length;g++)if(m=p[g].charCodeAt(0),m!==48){if(!(m>=48&&m<=57||m>=65&&m<=70||m>=97&&m<=102))return"";_+=p[g];break}for(g+=1;g<p.length;g++){if(m=p[g].charCodeAt(0),!(m>=48&&m<=57||m>=65&&m<=70||m>=97&&m<=102))return"";_+=p[g]}return _}const n=RegExp.prototype.test.bind(/[^!"$&'()*+,\-.;=_`a-z{}~]/u);function s(p){return p.length=0,!0}function o(p,_,m){if(p.length){const g=r(p);if(g!=="")_.push(g);else return m.error=!0,!1;p.length=0}return!0}function i(p){let _=0;const m={error:!1,address:"",zone:""},g=[],f=[];let v=!1,h=!1,w=o;for(let $=0;$<p.length;$++){const b=p[$];if(!(b==="["||b==="]"))if(b===":"){if(v===!0&&(h=!0),!w(f,g,m))break;if(++_>7){m.error=!0;break}$>0&&p[$-1]===":"&&(v=!0),g.push(":");continue}else if(b==="%"){if(!w(f,g,m))break;w=s}else{f.push(b);continue}}return f.length&&(w===s?m.zone=f.join(""):h?g.push(f.join("")):g.push(r(f))),m.address=g.join(""),m}function a(p){if(c(p,":")<2)return{host:p,isIPV6:!1};const _=i(p);if(_.error)return{host:p,isIPV6:!1};{let m=_.address,g=_.address;return _.zone&&(m+="%"+_.zone,g+="%25"+_.zone),{host:m,isIPV6:!0,escapedHost:g}}}function c(p,_){let m=0;for(let g=0;g<p.length;g++)p[g]===_&&m++;return m}function u(p){let _=p;const m=[];let g=-1,f=0;for(;f=_.length;){if(f===1){if(_===".")break;if(_==="/"){m.push("/");break}else{m.push(_);break}}else if(f===2){if(_[0]==="."){if(_[1]===".")break;if(_[1]==="/"){_=_.slice(2);continue}}else if(_[0]==="/"&&(_[1]==="."||_[1]==="/")){m.push("/");break}}else if(f===3&&_==="/.."){m.length!==0&&m.pop(),m.push("/");break}if(_[0]==="."){if(_[1]==="."){if(_[2]==="/"){_=_.slice(3);continue}}else if(_[1]==="/"){_=_.slice(2);continue}}else if(_[0]==="/"&&_[1]==="."){if(_[2]==="/"){_=_.slice(2);continue}else if(_[2]==="."&&_[3]==="/"){_=_.slice(3),m.length!==0&&m.pop();continue}}if((g=_.indexOf("/",1))===-1){m.push(_);break}else m.push(_.slice(0,g)),_=_.slice(g)}return m.join("")}function l(p,_){const m=_!==!0?escape:unescape;return p.scheme!==void 0&&(p.scheme=m(p.scheme)),p.userinfo!==void 0&&(p.userinfo=m(p.userinfo)),p.host!==void 0&&(p.host=m(p.host)),p.path!==void 0&&(p.path=m(p.path)),p.query!==void 0&&(p.query=m(p.query)),p.fragment!==void 0&&(p.fragment=m(p.fragment)),p}function d(p){const _=[];if(p.userinfo!==void 0&&(_.push(p.userinfo),_.push("@")),p.host!==void 0){let m=unescape(p.host);if(!e(m)){const g=a(m);g.isIPV6===!0?m=`[${g.escapedHost}]`:m=p.host}_.push(m)}return(typeof p.port=="number"||typeof p.port=="string")&&(_.push(":"),_.push(String(p.port))),_.length?_.join(""):void 0}return Yo={nonSimpleDomain:n,recomposeAuthority:d,normalizeComponentEncoding:l,removeDotSegments:u,isIPv4:e,isUUID:t,normalizeIPv6:a,stringArrayToHexStripped:r},Yo}var Qo,Vc;function Pf(){if(Vc)return Qo;Vc=1;const{isUUID:t}=Dc(),e=/([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-.:;=@]|%[\da-f]{2})+)/iu,r=["http","https","ws","wss","urn","urn:uuid"];function n(b){return r.indexOf(b)!==-1}function s(b){return b.secure===!0?!0:b.secure===!1?!1:b.scheme?b.scheme.length===3&&(b.scheme[0]==="w"||b.scheme[0]==="W")&&(b.scheme[1]==="s"||b.scheme[1]==="S")&&(b.scheme[2]==="s"||b.scheme[2]==="S"):!1}function o(b){return b.host||(b.error=b.error||"HTTP URIs must have a host."),b}function i(b){const S=String(b.scheme).toLowerCase()==="https";return(b.port===(S?443:80)||b.port==="")&&(b.port=void 0),b.path||(b.path="/"),b}function a(b){return b.secure=s(b),b.resourceName=(b.path||"/")+(b.query?"?"+b.query:""),b.path=void 0,b.query=void 0,b}function c(b){if((b.port===(s(b)?443:80)||b.port==="")&&(b.port=void 0),typeof b.secure=="boolean"&&(b.scheme=b.secure?"wss":"ws",b.secure=void 0),b.resourceName){const[S,T]=b.resourceName.split("?");b.path=S&&S!=="/"?S:void 0,b.query=T,b.resourceName=void 0}return b.fragment=void 0,b}function u(b,S){if(!b.path)return b.error="URN can not be parsed",b;const T=b.path.match(e);if(T){const N=S.scheme||b.scheme||"urn";b.nid=T[1].toLowerCase(),b.nss=T[2];const j=`${N}:${S.nid||b.nid}`,F=$(j);b.path=void 0,F&&(b=F.parse(b,S))}else b.error=b.error||"URN can not be parsed.";return b}function l(b,S){if(b.nid===void 0)throw new Error("URN without nid cannot be serialized");const T=S.scheme||b.scheme||"urn",N=b.nid.toLowerCase(),j=`${T}:${S.nid||N}`,F=$(j);F&&(b=F.serialize(b,S));const q=b,W=b.nss;return q.path=`${N||S.nid}:${W}`,S.skipEscape=!0,q}function d(b,S){const T=b;return T.uuid=T.nss,T.nss=void 0,!S.tolerant&&(!T.uuid||!t(T.uuid))&&(T.error=T.error||"UUID is not valid."),T}function p(b){const S=b;return S.nss=(b.uuid||"").toLowerCase(),S}const _={scheme:"http",domainHost:!0,parse:o,serialize:i},m={scheme:"https",domainHost:_.domainHost,parse:o,serialize:i},g={scheme:"ws",domainHost:!0,parse:a,serialize:c},f={scheme:"wss",domainHost:g.domainHost,parse:g.parse,serialize:g.serialize},w={http:_,https:m,ws:g,wss:f,urn:{scheme:"urn",parse:u,serialize:l,skipNormalize:!0},"urn:uuid":{scheme:"urn:uuid",parse:d,serialize:p,skipNormalize:!0}};Object.setPrototypeOf(w,null);function $(b){return b&&(w[b]||w[b.toLowerCase()])||void 0}return Qo={wsIsSecure:s,SCHEMES:w,isValidSchemeName:n,getSchemeHandler:$},Qo}var Hc;function xf(){if(Hc)return Kr.exports;Hc=1;const{normalizeIPv6:t,removeDotSegments:e,recomposeAuthority:r,normalizeComponentEncoding:n,isIPv4:s,nonSimpleDomain:o}=Dc(),{SCHEMES:i,getSchemeHandler:a}=Pf();function c(f,v){return typeof f=="string"?f=p(m(f,v),v):typeof f=="object"&&(f=m(p(f,v),v)),f}function u(f,v,h){const w=h?Object.assign({scheme:"null"},h):{scheme:"null"},$=l(m(f,w),m(v,w),w,!0);return w.skipEscape=!0,p($,w)}function l(f,v,h,w){const $={};return w||(f=m(p(f,h),h),v=m(p(v,h),h)),h=h||{},!h.tolerant&&v.scheme?($.scheme=v.scheme,$.userinfo=v.userinfo,$.host=v.host,$.port=v.port,$.path=e(v.path||""),$.query=v.query):(v.userinfo!==void 0||v.host!==void 0||v.port!==void 0?($.userinfo=v.userinfo,$.host=v.host,$.port=v.port,$.path=e(v.path||""),$.query=v.query):(v.path?(v.path[0]==="/"?$.path=e(v.path):((f.userinfo!==void 0||f.host!==void 0||f.port!==void 0)&&!f.path?$.path="/"+v.path:f.path?$.path=f.path.slice(0,f.path.lastIndexOf("/")+1)+v.path:$.path=v.path,$.path=e($.path)),$.query=v.query):($.path=f.path,v.query!==void 0?$.query=v.query:$.query=f.query),$.userinfo=f.userinfo,$.host=f.host,$.port=f.port),$.scheme=f.scheme),$.fragment=v.fragment,$}function d(f,v,h){return typeof f=="string"?(f=unescape(f),f=p(n(m(f,h),!0),{...h,skipEscape:!0})):typeof f=="object"&&(f=p(n(f,!0),{...h,skipEscape:!0})),typeof v=="string"?(v=unescape(v),v=p(n(m(v,h),!0),{...h,skipEscape:!0})):typeof v=="object"&&(v=p(n(v,!0),{...h,skipEscape:!0})),f.toLowerCase()===v.toLowerCase()}function p(f,v){const h={host:f.host,scheme:f.scheme,userinfo:f.userinfo,port:f.port,path:f.path,query:f.query,nid:f.nid,nss:f.nss,uuid:f.uuid,fragment:f.fragment,reference:f.reference,resourceName:f.resourceName,secure:f.secure,error:""},w=Object.assign({},v),$=[],b=a(w.scheme||h.scheme);b&&b.serialize&&b.serialize(h,w),h.path!==void 0&&(w.skipEscape?h.path=unescape(h.path):(h.path=escape(h.path),h.scheme!==void 0&&(h.path=h.path.split("%3A").join(":")))),w.reference!=="suffix"&&h.scheme&&$.push(h.scheme,":");const S=r(h);if(S!==void 0&&(w.reference!=="suffix"&&$.push("//"),$.push(S),h.path&&h.path[0]!=="/"&&$.push("/")),h.path!==void 0){let T=h.path;!w.absolutePath&&(!b||!b.absolutePath)&&(T=e(T)),S===void 0&&T[0]==="/"&&T[1]==="/"&&(T="/%2F"+T.slice(2)),$.push(T)}return h.query!==void 0&&$.push("?",h.query),h.fragment!==void 0&&$.push("#",h.fragment),$.join("")}const _=/^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u;function m(f,v){const h=Object.assign({},v),w={scheme:void 0,userinfo:void 0,host:"",port:void 0,path:"",query:void 0,fragment:void 0};let $=!1;h.reference==="suffix"&&(h.scheme?f=h.scheme+":"+f:f="//"+f);const b=f.match(_);if(b){if(w.scheme=b[1],w.userinfo=b[3],w.host=b[4],w.port=parseInt(b[5],10),w.path=b[6]||"",w.query=b[7],w.fragment=b[8],isNaN(w.port)&&(w.port=b[5]),w.host)if(s(w.host)===!1){const N=t(w.host);w.host=N.host.toLowerCase(),$=N.isIPV6}else $=!0;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":w.scheme===void 0?w.reference="relative":w.fragment===void 0?w.reference="absolute":w.reference="uri",h.reference&&h.reference!=="suffix"&&h.reference!==w.reference&&(w.error=w.error||"URI is not a "+h.reference+" reference.");const S=a(h.scheme||w.scheme);if(!h.unicodeSupport&&(!S||!S.unicodeSupport)&&w.host&&(h.domainHost||S&&S.domainHost)&&$===!1&&o(w.host))try{w.host=URL.domainToASCII(w.host.toLowerCase())}catch(T){w.error=w.error||"Host's domain name can not be converted to ASCII: "+T}(!S||S&&!S.skipNormalize)&&(f.indexOf("%")!==-1&&(w.scheme!==void 0&&(w.scheme=unescape(w.scheme)),w.host!==void 0&&(w.host=unescape(w.host))),w.path&&(w.path=escape(unescape(w.path))),w.fragment&&(w.fragment=encodeURI(decodeURIComponent(w.fragment)))),S&&S.parse&&S.parse(w,h)}else w.error=w.error||"URI can not be parsed.";return w}const g={SCHEMES:i,normalize:c,resolve:u,resolveComponent:l,equal:d,serialize:p,parse:m};return Kr.exports=g,Kr.exports.default=g,Kr.exports.fastUri=g,Kr.exports}var Fc;function If(){if(Fc)return es;Fc=1,Object.defineProperty(es,"__esModule",{value:!0});const t=xf();return t.code='require("ajv/dist/runtime/uri").default',es.default=t,es}var Wc;function Cf(){return Wc||(Wc=1,(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.CodeGen=t.Name=t.nil=t.stringify=t.str=t._=t.KeywordCxt=void 0;var e=Gn();Object.defineProperty(t,"KeywordCxt",{enumerable:!0,get:function(){return e.KeywordCxt}});var r=fe();Object.defineProperty(t,"_",{enumerable:!0,get:function(){return r._}}),Object.defineProperty(t,"str",{enumerable:!0,get:function(){return r.str}}),Object.defineProperty(t,"stringify",{enumerable:!0,get:function(){return r.stringify}}),Object.defineProperty(t,"nil",{enumerable:!0,get:function(){return r.nil}}),Object.defineProperty(t,"Name",{enumerable:!0,get:function(){return r.Name}}),Object.defineProperty(t,"CodeGen",{enumerable:!0,get:function(){return r.CodeGen}});const n=Ko(),s=Xn(),o=Tc(),i=Go(),a=fe(),c=Kn(),u=Bn(),l=be(),d=Ef,p=If(),_=(V,P)=>new RegExp(V,P);_.code="new RegExp";const m=["removeAdditional","useDefaults","coerceTypes"],g=new Set(["validate","serialize","parse","wrapper","root","schema","keyword","pattern","formats","validate$data","func","obj","Error"]),f={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."},v={ignoreKeywordsWithRef:"",jsPropertySyntax:"",unicode:'"minLength"/"maxLength" account for unicode characters by default.'},h=200;function w(V){var P,L,O,k,R,M,X,re,Se,ve,E,I,U,H,te,me,Ke,Nt,at,ct,Ge,Jr,gt,fc,pc;const Vn=V.strict,mc=(P=V.code)===null||P===void 0?void 0:P.optimize,yf=mc===!0||mc===void 0?1:mc||0,wf=(O=(L=V.code)===null||L===void 0?void 0:L.regExp)!==null&&O!==void 0?O:_,h1=(k=V.uriResolver)!==null&&k!==void 0?k:p.default;return{strictSchema:(M=(R=V.strictSchema)!==null&&R!==void 0?R:Vn)!==null&&M!==void 0?M:!0,strictNumbers:(re=(X=V.strictNumbers)!==null&&X!==void 0?X:Vn)!==null&&re!==void 0?re:!0,strictTypes:(ve=(Se=V.strictTypes)!==null&&Se!==void 0?Se:Vn)!==null&&ve!==void 0?ve:"log",strictTuples:(I=(E=V.strictTuples)!==null&&E!==void 0?E:Vn)!==null&&I!==void 0?I:"log",strictRequired:(H=(U=V.strictRequired)!==null&&U!==void 0?U:Vn)!==null&&H!==void 0?H:!1,code:V.code?{...V.code,optimize:yf,regExp:wf}:{optimize:yf,regExp:wf},loopRequired:(te=V.loopRequired)!==null&&te!==void 0?te:h,loopEnum:(me=V.loopEnum)!==null&&me!==void 0?me:h,meta:(Ke=V.meta)!==null&&Ke!==void 0?Ke:!0,messages:(Nt=V.messages)!==null&&Nt!==void 0?Nt:!0,inlineRefs:(at=V.inlineRefs)!==null&&at!==void 0?at:!0,schemaId:(ct=V.schemaId)!==null&&ct!==void 0?ct:"$id",addUsedSchema:(Ge=V.addUsedSchema)!==null&&Ge!==void 0?Ge:!0,validateSchema:(Jr=V.validateSchema)!==null&&Jr!==void 0?Jr:!0,validateFormats:(gt=V.validateFormats)!==null&>!==void 0?gt:!0,unicodeRegExp:(fc=V.unicodeRegExp)!==null&&fc!==void 0?fc:!0,int32range:(pc=V.int32range)!==null&&pc!==void 0?pc:!0,uriResolver:h1}}class ${constructor(P={}){this.schemas={},this.refs={},this.formats={},this._compilations=new Set,this._loading={},this._cache=new Map,P=this.opts={...P,...w(P)};const{es5:L,lines:O}=this.opts.code;this.scope=new a.ValueScope({scope:{},prefixes:g,es5:L,lines:O}),this.logger=W(P.logger);const k=P.validateFormats;P.validateFormats=!1,this.RULES=(0,o.getRules)(),b.call(this,f,P,"NOT SUPPORTED"),b.call(this,v,P,"DEPRECATED","warn"),this._metaOpts=F.call(this),P.formats&&N.call(this),this._addVocabularies(),this._addDefaultMetaSchema(),P.keywords&&j.call(this,P.keywords),typeof P.meta=="object"&&this.addMetaSchema(P.meta),T.call(this),P.validateFormats=k}_addVocabularies(){this.addKeyword("$async")}_addDefaultMetaSchema(){const{$data:P,meta:L,schemaId:O}=this.opts;let k=d;O==="id"&&(k={...d},k.id=k.$id,delete k.$id),L&&P&&this.addMetaSchema(k,k[O],!1)}defaultMeta(){const{meta:P,schemaId:L}=this.opts;return this.opts.defaultMeta=typeof P=="object"?P[L]||P:void 0}validate(P,L){let O;if(typeof P=="string"){if(O=this.getSchema(P),!O)throw new Error(`no schema with key or ref "${P}"`)}else O=this.compile(P);const k=O(L);return"$async"in O||(this.errors=O.errors),k}compile(P,L){const O=this._addSchema(P,L);return O.validate||this._compileSchemaEnv(O)}compileAsync(P,L){if(typeof this.opts.loadSchema!="function")throw new Error("options.loadSchema should be a function");const{loadSchema:O}=this.opts;return k.call(this,P,L);async function k(ve,E){await R.call(this,ve.$schema);const I=this._addSchema(ve,E);return I.validate||M.call(this,I)}async function R(ve){ve&&!this.getSchema(ve)&&await k.call(this,{$ref:ve},!0)}async function M(ve){try{return this._compileSchemaEnv(ve)}catch(E){if(!(E instanceof s.default))throw E;return X.call(this,E),await re.call(this,E.missingSchema),M.call(this,ve)}}function X({missingSchema:ve,missingRef:E}){if(this.refs[ve])throw new Error(`AnySchema ${ve} is loaded but ${E} cannot be resolved`)}async function re(ve){const E=await Se.call(this,ve);this.refs[ve]||await R.call(this,E.$schema),this.refs[ve]||this.addSchema(E,ve,L)}async function Se(ve){const E=this._loading[ve];if(E)return E;try{return await(this._loading[ve]=O(ve))}finally{delete this._loading[ve]}}}addSchema(P,L,O,k=this.opts.validateSchema){if(Array.isArray(P)){for(const M of P)this.addSchema(M,void 0,O,k);return this}let R;if(typeof P=="object"){const{schemaId:M}=this.opts;if(R=P[M],R!==void 0&&typeof R!="string")throw new Error(`schema ${M} must be string`)}return L=(0,c.normalizeId)(L||R),this._checkUnique(L),this.schemas[L]=this._addSchema(P,O,L,k,!0),this}addMetaSchema(P,L,O=this.opts.validateSchema){return this.addSchema(P,L,!0,O),this}validateSchema(P,L){if(typeof P=="boolean")return!0;let O;if(O=P.$schema,O!==void 0&&typeof O!="string")throw new Error("$schema must be a string");if(O=O||this.opts.defaultMeta||this.defaultMeta(),!O)return this.logger.warn("meta-schema not available"),this.errors=null,!0;const k=this.validate(O,P);if(!k&&L){const R="schema is invalid: "+this.errorsText();if(this.opts.validateSchema==="log")this.logger.error(R);else throw new Error(R)}return k}getSchema(P){let L;for(;typeof(L=S.call(this,P))=="string";)P=L;if(L===void 0){const{schemaId:O}=this.opts,k=new i.SchemaEnv({schema:{},schemaId:O});if(L=i.resolveSchema.call(this,k,P),!L)return;this.refs[P]=L}return L.validate||this._compileSchemaEnv(L)}removeSchema(P){if(P instanceof RegExp)return this._removeAllSchemas(this.schemas,P),this._removeAllSchemas(this.refs,P),this;switch(typeof P){case"undefined":return this._removeAllSchemas(this.schemas),this._removeAllSchemas(this.refs),this._cache.clear(),this;case"string":{const L=S.call(this,P);return typeof L=="object"&&this._cache.delete(L.schema),delete this.schemas[P],delete this.refs[P],this}case"object":{const L=P;this._cache.delete(L);let O=P[this.opts.schemaId];return O&&(O=(0,c.normalizeId)(O),delete this.schemas[O],delete this.refs[O]),this}default:throw new Error("ajv.removeSchema: invalid parameter")}}addVocabulary(P){for(const L of P)this.addKeyword(L);return this}addKeyword(P,L){let O;if(typeof P=="string")O=P,typeof L=="object"&&(this.logger.warn("these parameters are deprecated, see docs for addKeyword"),L.keyword=O);else if(typeof P=="object"&&L===void 0){if(L=P,O=L.keyword,Array.isArray(O)&&!O.length)throw new Error("addKeywords: keyword must be string or non-empty array")}else throw new Error("invalid addKeywords parameters");if(G.call(this,O,L),!L)return(0,l.eachItem)(O,R=>ke.call(this,R)),this;rt.call(this,L);const k={...L,type:(0,u.getJSONTypes)(L.type),schemaType:(0,u.getJSONTypes)(L.schemaType)};return(0,l.eachItem)(O,k.type.length===0?R=>ke.call(this,R,k):R=>k.type.forEach(M=>ke.call(this,R,k,M))),this}getKeyword(P){const L=this.RULES.all[P];return typeof L=="object"?L.definition:!!L}removeKeyword(P){const{RULES:L}=this;delete L.keywords[P],delete L.all[P];for(const O of L.rules){const k=O.rules.findIndex(R=>R.keyword===P);k>=0&&O.rules.splice(k,1)}return this}addFormat(P,L){return typeof L=="string"&&(L=new RegExp(L)),this.formats[P]=L,this}errorsText(P=this.errors,{separator:L=", ",dataVar:O="data"}={}){return!P||P.length===0?"No errors":P.map(k=>`${O}${k.instancePath} ${k.message}`).reduce((k,R)=>k+L+R)}$dataMetaSchema(P,L){const O=this.RULES.all;P=JSON.parse(JSON.stringify(P));for(const k of L){const R=k.split("/").slice(1);let M=P;for(const X of R)M=M[X];for(const X in O){const re=O[X];if(typeof re!="object")continue;const{$data:Se}=re.definition,ve=M[X];Se&&ve&&(M[X]=Ot(ve))}}return P}_removeAllSchemas(P,L){for(const O in P){const k=P[O];(!L||L.test(O))&&(typeof k=="string"?delete P[O]:k&&!k.meta&&(this._cache.delete(k.schema),delete P[O]))}}_addSchema(P,L,O,k=this.opts.validateSchema,R=this.opts.addUsedSchema){let M;const{schemaId:X}=this.opts;if(typeof P=="object")M=P[X];else{if(this.opts.jtd)throw new Error("schema must be object");if(typeof P!="boolean")throw new Error("schema must be object or boolean")}let re=this._cache.get(P);if(re!==void 0)return re;O=(0,c.normalizeId)(M||O);const Se=c.getSchemaRefs.call(this,P,O);return re=new i.SchemaEnv({schema:P,schemaId:X,meta:L,baseId:O,localRefs:Se}),this._cache.set(re.schema,re),R&&!O.startsWith("#")&&(O&&this._checkUnique(O),this.refs[O]=re),k&&this.validateSchema(P,!0),re}_checkUnique(P){if(this.schemas[P]||this.refs[P])throw new Error(`schema with key or id "${P}" already exists`)}_compileSchemaEnv(P){if(P.meta?this._compileMetaSchema(P):i.compileSchema.call(this,P),!P.validate)throw new Error("ajv implementation error");return P.validate}_compileMetaSchema(P){const L=this.opts;this.opts=this._metaOpts;try{i.compileSchema.call(this,P)}finally{this.opts=L}}}$.ValidationError=n.default,$.MissingRefError=s.default,t.default=$;function b(V,P,L,O="error"){for(const k in V){const R=k;R in P&&this.logger[O](`${L}: option ${k}. ${V[R]}`)}}function S(V){return V=(0,c.normalizeId)(V),this.schemas[V]||this.refs[V]}function T(){const V=this.opts.schemas;if(V)if(Array.isArray(V))this.addSchema(V);else for(const P in V)this.addSchema(V[P],P)}function N(){for(const V in this.opts.formats){const P=this.opts.formats[V];P&&this.addFormat(V,P)}}function j(V){if(Array.isArray(V)){this.addVocabulary(V);return}this.logger.warn("keywords option as map is deprecated, pass array");for(const P in V){const L=V[P];L.keyword||(L.keyword=P),this.addKeyword(L)}}function F(){const V={...this.opts};for(const P of m)delete V[P];return V}const q={log(){},warn(){},error(){}};function W(V){if(V===!1)return q;if(V===void 0)return console;if(V.log&&V.warn&&V.error)return V;throw new Error("logger must implement log, warn and error methods")}const K=/^[a-z_$][a-z0-9_$:-]*$/i;function G(V,P){const{RULES:L}=this;if((0,l.eachItem)(V,O=>{if(L.keywords[O])throw new Error(`Keyword ${O} is already defined`);if(!K.test(O))throw new Error(`Keyword ${O} has invalid name`)}),!!P&&P.$data&&!("code"in P||"validate"in P))throw new Error('$data keyword must have "code" or "validate" function')}function ke(V,P,L){var O;const k=P?.post;if(L&&k)throw new Error('keyword with "post" flag cannot have "type"');const{RULES:R}=this;let M=k?R.post:R.rules.find(({type:re})=>re===L);if(M||(M={type:L,rules:[]},R.rules.push(M)),R.keywords[V]=!0,!P)return;const X={keyword:V,definition:{...P,type:(0,u.getJSONTypes)(P.type),schemaType:(0,u.getJSONTypes)(P.schemaType)}};P.before?tt.call(this,M,X,P.before):M.rules.push(X),R.all[V]=X,(O=P.implements)===null||O===void 0||O.forEach(re=>this.addKeyword(re))}function tt(V,P,L){const O=V.rules.findIndex(k=>k.keyword===L);O>=0?V.rules.splice(O,0,P):(V.rules.push(P),this.logger.warn(`rule ${L} is not defined`))}function rt(V){let{metaSchema:P}=V;P!==void 0&&(V.$data&&this.opts.$data&&(P=Ot(P)),V.validateSchema=this.compile(P,!0))}const xe={$ref:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#"};function Ot(V){return{anyOf:[V,xe]}}})(Do)),Do}var ts={},rs={},ns={},Jc;function Of(){if(Jc)return ns;Jc=1,Object.defineProperty(ns,"__esModule",{value:!0});const t={keyword:"id",code(){throw new Error('NOT SUPPORTED: keyword "id", use "$id" for schema ID')}};return ns.default=t,ns}var Kt={},Bc;function Nf(){if(Bc)return Kt;Bc=1,Object.defineProperty(Kt,"__esModule",{value:!0}),Kt.callRef=Kt.getValidate=void 0;const t=Xn(),e=yt(),r=fe(),n=Bt(),s=Go(),o=be(),i={keyword:"$ref",schemaType:"string",code(u){const{gen:l,schema:d,it:p}=u,{baseId:_,schemaEnv:m,validateName:g,opts:f,self:v}=p,{root:h}=m;if((d==="#"||d==="#/")&&_===h.baseId)return $();const w=s.resolveRef.call(v,h,_,d);if(w===void 0)throw new t.default(p.opts.uriResolver,_,d);if(w instanceof s.SchemaEnv)return b(w);return S(w);function $(){if(m===h)return c(u,g,m,m.$async);const T=l.scopeValue("root",{ref:h});return c(u,(0,r._)`${T}.validate`,h,h.$async)}function b(T){const N=a(u,T);c(u,N,T,T.$async)}function S(T){const N=l.scopeValue("schema",f.code.source===!0?{ref:T,code:(0,r.stringify)(T)}:{ref:T}),j=l.name("valid"),F=u.subschema({schema:T,dataTypes:[],schemaPath:r.nil,topSchemaRef:N,errSchemaPath:d},j);u.mergeEvaluated(F),u.ok(j)}}};function a(u,l){const{gen:d}=u;return l.validate?d.scopeValue("validate",{ref:l.validate}):(0,r._)`${d.scopeValue("wrapper",{ref:l})}.validate`}Kt.getValidate=a;function c(u,l,d,p){const{gen:_,it:m}=u,{allErrors:g,schemaEnv:f,opts:v}=m,h=v.passContext?n.default.this:r.nil;p?w():$();function w(){if(!f.$async)throw new Error("async schema referenced by sync schema");const T=_.let("valid");_.try(()=>{_.code((0,r._)`await ${(0,e.callValidateCode)(u,l,h)}`),S(l),g||_.assign(T,!0)},N=>{_.if((0,r._)`!(${N} instanceof ${m.ValidationError})`,()=>_.throw(N)),b(N),g||_.assign(T,!1)}),u.ok(T)}function $(){u.result((0,e.callValidateCode)(u,l,h),()=>S(l),()=>b(l))}function b(T){const N=(0,r._)`${T}.errors`;_.assign(n.default.vErrors,(0,r._)`${n.default.vErrors} === null ? ${N} : ${n.default.vErrors}.concat(${N})`),_.assign(n.default.errors,(0,r._)`${n.default.vErrors}.length`)}function S(T){var N;if(!m.opts.unevaluated)return;const j=(N=d?.validate)===null||N===void 0?void 0:N.evaluated;if(m.props!==!0)if(j&&!j.dynamicProps)j.props!==void 0&&(m.props=o.mergeEvaluated.props(_,j.props,m.props));else{const F=_.var("props",(0,r._)`${T}.evaluated.props`);m.props=o.mergeEvaluated.props(_,F,m.props,r.Name)}if(m.items!==!0)if(j&&!j.dynamicItems)j.items!==void 0&&(m.items=o.mergeEvaluated.items(_,j.items,m.items));else{const F=_.var("items",(0,r._)`${T}.evaluated.items`);m.items=o.mergeEvaluated.items(_,F,m.items,r.Name)}}}return Kt.callRef=c,Kt.default=i,Kt}var Kc;function Af(){if(Kc)return rs;Kc=1,Object.defineProperty(rs,"__esModule",{value:!0});const t=Of(),e=Nf(),r=["$schema","$id","$defs","$vocabulary",{keyword:"$comment"},"definitions",t.default,e.default];return rs.default=r,rs}var ss={},os={},Gc;function Mf(){if(Gc)return os;Gc=1,Object.defineProperty(os,"__esModule",{value:!0});const t=fe(),e=t.operators,r={maximum:{okStr:"<=",ok:e.LTE,fail:e.GT},minimum:{okStr:">=",ok:e.GTE,fail:e.LT},exclusiveMaximum:{okStr:"<",ok:e.LT,fail:e.GTE},exclusiveMinimum:{okStr:">",ok:e.GT,fail:e.LTE}},n={message:({keyword:o,schemaCode:i})=>(0,t.str)`must be ${r[o].okStr} ${i}`,params:({keyword:o,schemaCode:i})=>(0,t._)`{comparison: ${r[o].okStr}, limit: ${i}}`},s={keyword:Object.keys(r),type:"number",schemaType:"number",$data:!0,error:n,code(o){const{keyword:i,data:a,schemaCode:c}=o;o.fail$data((0,t._)`${a} ${r[i].fail} ${c} || isNaN(${a})`)}};return os.default=s,os}var is={},Yc;function jf(){if(Yc)return is;Yc=1,Object.defineProperty(is,"__esModule",{value:!0});const t=fe(),r={keyword:"multipleOf",type:"number",schemaType:"number",$data:!0,error:{message:({schemaCode:n})=>(0,t.str)`must be multiple of ${n}`,params:({schemaCode:n})=>(0,t._)`{multipleOf: ${n}}`},code(n){const{gen:s,data:o,schemaCode:i,it:a}=n,c=a.opts.multipleOfPrecision,u=s.let("res"),l=c?(0,t._)`Math.abs(Math.round(${u}) - ${u}) > 1e-${c}`:(0,t._)`${u} !== parseInt(${u})`;n.fail$data((0,t._)`(${i} === 0 || (${u} = ${o}/${i}, ${l}))`)}};return is.default=r,is}var as={},cs={},Qc;function qf(){if(Qc)return cs;Qc=1,Object.defineProperty(cs,"__esModule",{value:!0});function t(e){const r=e.length;let n=0,s=0,o;for(;s<r;)n++,o=e.charCodeAt(s++),o>=55296&&o<=56319&&s<r&&(o=e.charCodeAt(s),(o&64512)===56320&&s++);return n}return cs.default=t,t.code='require("ajv/dist/runtime/ucs2length").default',cs}var Xc;function zf(){if(Xc)return as;Xc=1,Object.defineProperty(as,"__esModule",{value:!0});const t=fe(),e=be(),r=qf(),s={keyword:["maxLength","minLength"],type:"string",schemaType:"number",$data:!0,error:{message({keyword:o,schemaCode:i}){const a=o==="maxLength"?"more":"fewer";return(0,t.str)`must NOT have ${a} than ${i} characters`},params:({schemaCode:o})=>(0,t._)`{limit: ${o}}`},code(o){const{keyword:i,data:a,schemaCode:c,it:u}=o,l=i==="maxLength"?t.operators.GT:t.operators.LT,d=u.opts.unicode===!1?(0,t._)`${a}.length`:(0,t._)`${(0,e.useFunc)(o.gen,r.default)}(${a})`;o.fail$data((0,t._)`${d} ${l} ${c}`)}};return as.default=s,as}var us={},eu;function Uf(){if(eu)return us;eu=1,Object.defineProperty(us,"__esModule",{value:!0});const t=yt(),e=fe(),n={keyword:"pattern",type:"string",schemaType:"string",$data:!0,error:{message:({schemaCode:s})=>(0,e.str)`must match pattern "${s}"`,params:({schemaCode:s})=>(0,e._)`{pattern: ${s}}`},code(s){const{data:o,$data:i,schema:a,schemaCode:c,it:u}=s,l=u.opts.unicodeRegExp?"u":"",d=i?(0,e._)`(new RegExp(${c}, ${l}))`:(0,t.usePattern)(s,a);s.fail$data((0,e._)`!${d}.test(${o})`)}};return us.default=n,us}var ls={},tu;function Lf(){if(tu)return ls;tu=1,Object.defineProperty(ls,"__esModule",{value:!0});const t=fe(),r={keyword:["maxProperties","minProperties"],type:"object",schemaType:"number",$data:!0,error:{message({keyword:n,schemaCode:s}){const o=n==="maxProperties"?"more":"fewer";return(0,t.str)`must NOT have ${o} than ${s} properties`},params:({schemaCode:n})=>(0,t._)`{limit: ${n}}`},code(n){const{keyword:s,data:o,schemaCode:i}=n,a=s==="maxProperties"?t.operators.GT:t.operators.LT;n.fail$data((0,t._)`Object.keys(${o}).length ${a} ${i}`)}};return ls.default=r,ls}var ds={},ru;function Zf(){if(ru)return ds;ru=1,Object.defineProperty(ds,"__esModule",{value:!0});const t=yt(),e=fe(),r=be(),s={keyword:"required",type:"object",schemaType:"array",$data:!0,error:{message:({params:{missingProperty:o}})=>(0,e.str)`must have required property '${o}'`,params:({params:{missingProperty:o}})=>(0,e._)`{missingProperty: ${o}}`},code(o){const{gen:i,schema:a,schemaCode:c,data:u,$data:l,it:d}=o,{opts:p}=d;if(!l&&a.length===0)return;const _=a.length>=p.loopRequired;if(d.allErrors?m():g(),p.strictRequired){const h=o.parentSchema.properties,{definedProperties:w}=o.it;for(const $ of a)if(h?.[$]===void 0&&!w.has($)){const b=d.schemaEnv.baseId+d.errSchemaPath,S=`required property "${$}" is not defined at "${b}" (strictRequired)`;(0,r.checkStrictMode)(d,S,d.opts.strictRequired)}}function m(){if(_||l)o.block$data(e.nil,f);else for(const h of a)(0,t.checkReportMissingProp)(o,h)}function g(){const h=i.let("missing");if(_||l){const w=i.let("valid",!0);o.block$data(w,()=>v(h,w)),o.ok(w)}else i.if((0,t.checkMissingProp)(o,a,h)),(0,t.reportMissingProp)(o,h),i.else()}function f(){i.forOf("prop",c,h=>{o.setParams({missingProperty:h}),i.if((0,t.noPropertyInData)(i,u,h,p.ownProperties),()=>o.error())})}function v(h,w){o.setParams({missingProperty:h}),i.forOf(h,c,()=>{i.assign(w,(0,t.propertyInData)(i,u,h,p.ownProperties)),i.if((0,e.not)(w),()=>{o.error(),i.break()})},e.nil)}}};return ds.default=s,ds}var hs={},nu;function Df(){if(nu)return hs;nu=1,Object.defineProperty(hs,"__esModule",{value:!0});const t=fe(),r={keyword:["maxItems","minItems"],type:"array",schemaType:"number",$data:!0,error:{message({keyword:n,schemaCode:s}){const o=n==="maxItems"?"more":"fewer";return(0,t.str)`must NOT have ${o} than ${s} items`},params:({schemaCode:n})=>(0,t._)`{limit: ${n}}`},code(n){const{keyword:s,data:o,schemaCode:i}=n,a=s==="maxItems"?t.operators.GT:t.operators.LT;n.fail$data((0,t._)`${o}.length ${a} ${i}`)}};return hs.default=r,hs}var fs={},ps={},su;function Xo(){if(su)return ps;su=1,Object.defineProperty(ps,"__esModule",{value:!0});const t=Ac();return t.code='require("ajv/dist/runtime/equal").default',ps.default=t,ps}var ou;function Vf(){if(ou)return fs;ou=1,Object.defineProperty(fs,"__esModule",{value:!0});const t=Bn(),e=fe(),r=be(),n=Xo(),o={keyword:"uniqueItems",type:"array",schemaType:"boolean",$data:!0,error:{message:({params:{i,j:a}})=>(0,e.str)`must NOT have duplicate items (items ## ${a} and ${i} are identical)`,params:({params:{i,j:a}})=>(0,e._)`{i: ${i}, j: ${a}}`},code(i){const{gen:a,data:c,$data:u,schema:l,parentSchema:d,schemaCode:p,it:_}=i;if(!u&&!l)return;const m=a.let("valid"),g=d.items?(0,t.getSchemaTypes)(d.items):[];i.block$data(m,f,(0,e._)`${p} === false`),i.ok(m);function f(){const $=a.let("i",(0,e._)`${c}.length`),b=a.let("j");i.setParams({i:$,j:b}),a.assign(m,!0),a.if((0,e._)`${$} > 1`,()=>(v()?h:w)($,b))}function v(){return g.length>0&&!g.some($=>$==="object"||$==="array")}function h($,b){const S=a.name("item"),T=(0,t.checkDataTypes)(g,S,_.opts.strictNumbers,t.DataType.Wrong),N=a.const("indices",(0,e._)`{}`);a.for((0,e._)`;${$}--;`,()=>{a.let(S,(0,e._)`${c}[${$}]`),a.if(T,(0,e._)`continue`),g.length>1&&a.if((0,e._)`typeof ${S} == "string"`,(0,e._)`${S} += "_"`),a.if((0,e._)`typeof ${N}[${S}] == "number"`,()=>{a.assign(b,(0,e._)`${N}[${S}]`),i.error(),a.assign(m,!1).break()}).code((0,e._)`${N}[${S}] = ${$}`)})}function w($,b){const S=(0,r.useFunc)(a,n.default),T=a.name("outer");a.label(T).for((0,e._)`;${$}--;`,()=>a.for((0,e._)`${b} = ${$}; ${b}--;`,()=>a.if((0,e._)`${S}(${c}[${$}], ${c}[${b}])`,()=>{i.error(),a.assign(m,!1).break(T)})))}}};return fs.default=o,fs}var ms={},iu;function Hf(){if(iu)return ms;iu=1,Object.defineProperty(ms,"__esModule",{value:!0});const t=fe(),e=be(),r=Xo(),s={keyword:"const",$data:!0,error:{message:"must be equal to constant",params:({schemaCode:o})=>(0,t._)`{allowedValue: ${o}}`},code(o){const{gen:i,data:a,$data:c,schemaCode:u,schema:l}=o;c||l&&typeof l=="object"?o.fail$data((0,t._)`!${(0,e.useFunc)(i,r.default)}(${a}, ${u})`):o.fail((0,t._)`${l} !== ${a}`)}};return ms.default=s,ms}var _s={},au;function Ff(){if(au)return _s;au=1,Object.defineProperty(_s,"__esModule",{value:!0});const t=fe(),e=be(),r=Xo(),s={keyword:"enum",schemaType:"array",$data:!0,error:{message:"must be equal to one of the allowed values",params:({schemaCode:o})=>(0,t._)`{allowedValues: ${o}}`},code(o){const{gen:i,data:a,$data:c,schema:u,schemaCode:l,it:d}=o;if(!c&&u.length===0)throw new Error("enum must have non-empty array");const p=u.length>=d.opts.loopEnum;let _;const m=()=>_??(_=(0,e.useFunc)(i,r.default));let g;if(p||c)g=i.let("valid"),o.block$data(g,f);else{if(!Array.isArray(u))throw new Error("ajv implementation error");const h=i.const("vSchema",l);g=(0,t.or)(...u.map((w,$)=>v(h,$)))}o.pass(g);function f(){i.assign(g,!1),i.forOf("v",l,h=>i.if((0,t._)`${m()}(${a}, ${h})`,()=>i.assign(g,!0).break()))}function v(h,w){const $=u[w];return typeof $=="object"&&$!==null?(0,t._)`${m()}(${a}, ${h}[${w}])`:(0,t._)`${a} === ${$}`}}};return _s.default=s,_s}var cu;function Wf(){if(cu)return ss;cu=1,Object.defineProperty(ss,"__esModule",{value:!0});const t=Mf(),e=jf(),r=zf(),n=Uf(),s=Lf(),o=Zf(),i=Df(),a=Vf(),c=Hf(),u=Ff(),l=[t.default,e.default,r.default,n.default,s.default,o.default,i.default,a.default,{keyword:"type",schemaType:["string","array"]},{keyword:"nullable",schemaType:"boolean"},c.default,u.default];return ss.default=l,ss}var gs={},Tr={},uu;function lu(){if(uu)return Tr;uu=1,Object.defineProperty(Tr,"__esModule",{value:!0}),Tr.validateAdditionalItems=void 0;const t=fe(),e=be(),n={keyword:"additionalItems",type:"array",schemaType:["boolean","object"],before:"uniqueItems",error:{message:({params:{len:o}})=>(0,t.str)`must NOT have more than ${o} items`,params:({params:{len:o}})=>(0,t._)`{limit: ${o}}`},code(o){const{parentSchema:i,it:a}=o,{items:c}=i;if(!Array.isArray(c)){(0,e.checkStrictMode)(a,'"additionalItems" is ignored when "items" is not an array of schemas');return}s(o,c)}};function s(o,i){const{gen:a,schema:c,data:u,keyword:l,it:d}=o;d.items=!0;const p=a.const("len",(0,t._)`${u}.length`);if(c===!1)o.setParams({len:i.length}),o.pass((0,t._)`${p} <= ${i.length}`);else if(typeof c=="object"&&!(0,e.alwaysValidSchema)(d,c)){const m=a.var("valid",(0,t._)`${p} <= ${i.length}`);a.if((0,t.not)(m),()=>_(m)),o.ok(m)}function _(m){a.forRange("i",i.length,p,g=>{o.subschema({keyword:l,dataProp:g,dataPropType:e.Type.Num},m),d.allErrors||a.if((0,t.not)(m),()=>a.break())})}}return Tr.validateAdditionalItems=s,Tr.default=n,Tr}var vs={},Rr={},du;function hu(){if(du)return Rr;du=1,Object.defineProperty(Rr,"__esModule",{value:!0}),Rr.validateTuple=void 0;const t=fe(),e=be(),r=yt(),n={keyword:"items",type:"array",schemaType:["object","array","boolean"],before:"uniqueItems",code(o){const{schema:i,it:a}=o;if(Array.isArray(i))return s(o,"additionalItems",i);a.items=!0,!(0,e.alwaysValidSchema)(a,i)&&o.ok((0,r.validateArray)(o))}};function s(o,i,a=o.schema){const{gen:c,parentSchema:u,data:l,keyword:d,it:p}=o;g(u),p.opts.unevaluated&&a.length&&p.items!==!0&&(p.items=e.mergeEvaluated.items(c,a.length,p.items));const _=c.name("valid"),m=c.const("len",(0,t._)`${l}.length`);a.forEach((f,v)=>{(0,e.alwaysValidSchema)(p,f)||(c.if((0,t._)`${m} > ${v}`,()=>o.subschema({keyword:d,schemaProp:v,dataProp:v},_)),o.ok(_))});function g(f){const{opts:v,errSchemaPath:h}=p,w=a.length,$=w===f.minItems&&(w===f.maxItems||f[i]===!1);if(v.strictTuples&&!$){const b=`"${d}" is ${w}-tuple, but minItems or maxItems/${i} are not specified or different at path "${h}"`;(0,e.checkStrictMode)(p,b,v.strictTuples)}}}return Rr.validateTuple=s,Rr.default=n,Rr}var fu;function Jf(){if(fu)return vs;fu=1,Object.defineProperty(vs,"__esModule",{value:!0});const t=hu(),e={keyword:"prefixItems",type:"array",schemaType:["array"],before:"uniqueItems",code:r=>(0,t.validateTuple)(r,"items")};return vs.default=e,vs}var ys={},pu;function Bf(){if(pu)return ys;pu=1,Object.defineProperty(ys,"__esModule",{value:!0});const t=fe(),e=be(),r=yt(),n=lu(),o={keyword:"items",type:"array",schemaType:["object","boolean"],before:"uniqueItems",error:{message:({params:{len:i}})=>(0,t.str)`must NOT have more than ${i} items`,params:({params:{len:i}})=>(0,t._)`{limit: ${i}}`},code(i){const{schema:a,parentSchema:c,it:u}=i,{prefixItems:l}=c;u.items=!0,!(0,e.alwaysValidSchema)(u,a)&&(l?(0,n.validateAdditionalItems)(i,l):i.ok((0,r.validateArray)(i)))}};return ys.default=o,ys}var ws={},mu;function Kf(){if(mu)return ws;mu=1,Object.defineProperty(ws,"__esModule",{value:!0});const t=fe(),e=be(),n={keyword:"contains",type:"array",schemaType:["object","boolean"],before:"uniqueItems",trackErrors:!0,error:{message:({params:{min:s,max:o}})=>o===void 0?(0,t.str)`must contain at least ${s} valid item(s)`:(0,t.str)`must contain at least ${s} and no more than ${o} valid item(s)`,params:({params:{min:s,max:o}})=>o===void 0?(0,t._)`{minContains: ${s}}`:(0,t._)`{minContains: ${s}, maxContains: ${o}}`},code(s){const{gen:o,schema:i,parentSchema:a,data:c,it:u}=s;let l,d;const{minContains:p,maxContains:_}=a;u.opts.next?(l=p===void 0?1:p,d=_):l=1;const m=o.const("len",(0,t._)`${c}.length`);if(s.setParams({min:l,max:d}),d===void 0&&l===0){(0,e.checkStrictMode)(u,'"minContains" == 0 without "maxContains": "contains" keyword ignored');return}if(d!==void 0&&l>d){(0,e.checkStrictMode)(u,'"minContains" > "maxContains" is always invalid'),s.fail();return}if((0,e.alwaysValidSchema)(u,i)){let w=(0,t._)`${m} >= ${l}`;d!==void 0&&(w=(0,t._)`${w} && ${m} <= ${d}`),s.pass(w);return}u.items=!0;const g=o.name("valid");d===void 0&&l===1?v(g,()=>o.if(g,()=>o.break())):l===0?(o.let(g,!0),d!==void 0&&o.if((0,t._)`${c}.length > 0`,f)):(o.let(g,!1),f()),s.result(g,()=>s.reset());function f(){const w=o.name("_valid"),$=o.let("count",0);v(w,()=>o.if(w,()=>h($)))}function v(w,$){o.forRange("i",0,m,b=>{s.subschema({keyword:"contains",dataProp:b,dataPropType:e.Type.Num,compositeRule:!0},w),$()})}function h(w){o.code((0,t._)`${w}++`),d===void 0?o.if((0,t._)`${w} >= ${l}`,()=>o.assign(g,!0).break()):(o.if((0,t._)`${w} > ${d}`,()=>o.assign(g,!1).break()),l===1?o.assign(g,!0):o.if((0,t._)`${w} >= ${l}`,()=>o.assign(g,!0)))}}};return ws.default=n,ws}var ei={},_u;function Gf(){return _u||(_u=1,(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.validateSchemaDeps=t.validatePropertyDeps=t.error=void 0;const e=fe(),r=be(),n=yt();t.error={message:({params:{property:c,depsCount:u,deps:l}})=>{const d=u===1?"property":"properties";return(0,e.str)`must have ${d} ${l} when property ${c} is present`},params:({params:{property:c,depsCount:u,deps:l,missingProperty:d}})=>(0,e._)`{property: ${c},
|
|
6
6
|
missingProperty: ${d},
|
|
7
|
-
depsCount: ${
|
|
8
|
-
deps: ${u}}`};const s={keyword:"dependencies",type:"object",schemaType:"object",error:t.error,code(c){const[l,u]=a(c);i(c,l),o(c,u)}};function a({schema:c}){const l={},u={};for(const d in c){if(d==="__proto__")continue;const g=Array.isArray(c[d])?l:u;g[d]=c[d]}return[l,u]}function i(c,l=c.schema){const{gen:u,data:d,it:g}=c;if(Object.keys(l).length===0)return;const v=u.let("missing");for(const p in l){const w=l[p];if(w.length===0)continue;const h=(0,n.propertyInData)(u,d,p,g.opts.ownProperties);c.setParams({property:p,depsCount:w.length,deps:w.join(", ")}),g.allErrors?u.if(h,()=>{for(const _ of w)(0,n.checkReportMissingProp)(c,_)}):(u.if((0,e._)`${h} && (${(0,n.checkMissingProp)(c,w,v)})`),(0,n.reportMissingProp)(c,v),u.else())}}t.validatePropertyDeps=i;function o(c,l=c.schema){const{gen:u,data:d,keyword:g,it:v}=c,p=u.name("valid");for(const w in l)(0,r.alwaysValidSchema)(v,l[w])||(u.if((0,n.propertyInData)(u,d,w,v.opts.ownProperties),()=>{const h=c.subschema({keyword:g,schemaProp:w},p);c.mergeValidEvaluated(h,p)},()=>u.var(p,!0)),c.ok(p))}t.validateSchemaDeps=o,t.default=s})(ya)),ya}var es={},ac;function Vd(){if(ac)return es;ac=1,Object.defineProperty(es,"__esModule",{value:!0});const t=ce(),e=pe(),n={keyword:"propertyNames",type:"object",schemaType:["object","boolean"],error:{message:"property name must be valid",params:({params:s})=>(0,t._)`{propertyName: ${s.propertyName}}`},code(s){const{gen:a,schema:i,data:o,it:c}=s;if((0,e.alwaysValidSchema)(c,i))return;const l=a.name("valid");a.forIn("key",o,u=>{s.setParams({propertyName:u}),s.subschema({keyword:"propertyNames",data:u,dataTypes:["string"],propertyName:u,compositeRule:!0},l),a.if((0,t.not)(l),()=>{s.error(!0),c.allErrors||a.break()})}),s.ok(l)}};return es.default=n,es}var ts={},ic;function oc(){if(ic)return ts;ic=1,Object.defineProperty(ts,"__esModule",{value:!0});const t=pt(),e=ce(),r=Zt(),n=pe(),a={keyword:"additionalProperties",type:["object"],schemaType:["boolean","object"],allowUndefined:!0,trackErrors:!0,error:{message:"must NOT have additional properties",params:({params:i})=>(0,e._)`{additionalProperty: ${i.additionalProperty}}`},code(i){const{gen:o,schema:c,parentSchema:l,data:u,errsCount:d,it:g}=i;if(!d)throw new Error("ajv implementation error");const{allErrors:v,opts:p}=g;if(g.props=!0,p.removeAdditional!=="all"&&(0,n.alwaysValidSchema)(g,c))return;const w=(0,t.allSchemaProperties)(l.properties),h=(0,t.allSchemaProperties)(l.patternProperties);_(),i.ok((0,e._)`${d} === ${r.default.errors}`);function _(){o.forIn("key",u,k=>{!w.length&&!h.length?b(k):o.if(f(k),()=>b(k))})}function f(k){let S;if(w.length>8){const I=(0,n.schemaRefOrVal)(g,l.properties,"properties");S=(0,t.isOwnProperty)(o,I,k)}else w.length?S=(0,e.or)(...w.map(I=>(0,e._)`${k} === ${I}`)):S=e.nil;return h.length&&(S=(0,e.or)(S,...h.map(I=>(0,e._)`${(0,t.usePattern)(i,I)}.test(${k})`))),(0,e.not)(S)}function m(k){o.code((0,e._)`delete ${u}[${k}]`)}function b(k){if(p.removeAdditional==="all"||p.removeAdditional&&c===!1){m(k);return}if(c===!1){i.setParams({additionalProperty:k}),i.error(),v||o.break();return}if(typeof c=="object"&&!(0,n.alwaysValidSchema)(g,c)){const S=o.name("valid");p.removeAdditional==="failing"?(y(k,S,!1),o.if((0,e.not)(S),()=>{i.reset(),m(k)})):(y(k,S),v||o.if((0,e.not)(S),()=>o.break()))}}function y(k,S,I){const C={keyword:"additionalProperties",dataProp:k,dataPropType:n.Type.Str};I===!1&&Object.assign(C,{compositeRule:!0,createErrors:!1,allErrors:!1}),i.subschema(C,S)}}};return ts.default=a,ts}var rs={},cc;function Fd(){if(cc)return rs;cc=1,Object.defineProperty(rs,"__esModule",{value:!0});const t=xn(),e=pt(),r=pe(),n=oc(),s={keyword:"properties",type:"object",schemaType:"object",code(a){const{gen:i,schema:o,parentSchema:c,data:l,it:u}=a;u.opts.removeAdditional==="all"&&c.additionalProperties===void 0&&n.default.code(new t.KeywordCxt(u,n.default,"additionalProperties"));const d=(0,e.allSchemaProperties)(o);for(const h of d)u.definedProperties.add(h);u.opts.unevaluated&&d.length&&u.props!==!0&&(u.props=r.mergeEvaluated.props(i,(0,r.toHash)(d),u.props));const g=d.filter(h=>!(0,r.alwaysValidSchema)(u,o[h]));if(g.length===0)return;const v=i.name("valid");for(const h of g)p(h)?w(h):(i.if((0,e.propertyInData)(i,l,h,u.opts.ownProperties)),w(h),u.allErrors||i.else().var(v,!0),i.endIf()),a.it.definedProperties.add(h),a.ok(v);function p(h){return u.opts.useDefaults&&!u.compositeRule&&o[h].default!==void 0}function w(h){a.subschema({keyword:"properties",schemaProp:h,dataProp:h},v)}}};return rs.default=s,rs}var ns={},uc;function Hd(){if(uc)return ns;uc=1,Object.defineProperty(ns,"__esModule",{value:!0});const t=pt(),e=ce(),r=pe(),n=pe(),s={keyword:"patternProperties",type:"object",schemaType:"object",code(a){const{gen:i,schema:o,data:c,parentSchema:l,it:u}=a,{opts:d}=u,g=(0,t.allSchemaProperties)(o),v=g.filter(b=>(0,r.alwaysValidSchema)(u,o[b]));if(g.length===0||v.length===g.length&&(!u.opts.unevaluated||u.props===!0))return;const p=d.strictSchema&&!d.allowMatchingProperties&&l.properties,w=i.name("valid");u.props!==!0&&!(u.props instanceof e.Name)&&(u.props=(0,n.evaluatedPropsToName)(i,u.props));const{props:h}=u;_();function _(){for(const b of g)p&&f(b),u.allErrors?m(b):(i.var(w,!0),m(b),i.if(w))}function f(b){for(const y in p)new RegExp(b).test(y)&&(0,r.checkStrictMode)(u,`property ${y} matches pattern ${b} (use allowMatchingProperties)`)}function m(b){i.forIn("key",c,y=>{i.if((0,e._)`${(0,t.usePattern)(a,b)}.test(${y})`,()=>{const k=v.includes(b);k||a.subschema({keyword:"patternProperties",schemaProp:b,dataProp:y,dataPropType:n.Type.Str},w),u.opts.unevaluated&&h!==!0?i.assign((0,e._)`${h}[${y}]`,!0):!k&&!u.allErrors&&i.if((0,e.not)(w),()=>i.break())})})}}};return ns.default=s,ns}var ss={},lc;function Wd(){if(lc)return ss;lc=1,Object.defineProperty(ss,"__esModule",{value:!0});const t=pe(),e={keyword:"not",schemaType:["object","boolean"],trackErrors:!0,code(r){const{gen:n,schema:s,it:a}=r;if((0,t.alwaysValidSchema)(a,s)){r.fail();return}const i=n.name("valid");r.subschema({keyword:"not",compositeRule:!0,createErrors:!1,allErrors:!1},i),r.failResult(i,()=>r.reset(),()=>r.error())},error:{message:"must NOT be valid"}};return ss.default=e,ss}var as={},dc;function Jd(){if(dc)return as;dc=1,Object.defineProperty(as,"__esModule",{value:!0});const e={keyword:"anyOf",schemaType:"array",trackErrors:!0,code:pt().validateUnion,error:{message:"must match a schema in anyOf"}};return as.default=e,as}var is={},fc;function Kd(){if(fc)return is;fc=1,Object.defineProperty(is,"__esModule",{value:!0});const t=ce(),e=pe(),n={keyword:"oneOf",schemaType:"array",trackErrors:!0,error:{message:"must match exactly one schema in oneOf",params:({params:s})=>(0,t._)`{passingSchemas: ${s.passing}}`},code(s){const{gen:a,schema:i,parentSchema:o,it:c}=s;if(!Array.isArray(i))throw new Error("ajv implementation error");if(c.opts.discriminator&&o.discriminator)return;const l=i,u=a.let("valid",!1),d=a.let("passing",null),g=a.name("_valid");s.setParams({passing:d}),a.block(v),s.result(u,()=>s.reset(),()=>s.error(!0));function v(){l.forEach((p,w)=>{let h;(0,e.alwaysValidSchema)(c,p)?a.var(g,!0):h=s.subschema({keyword:"oneOf",schemaProp:w,compositeRule:!0},g),w>0&&a.if((0,t._)`${g} && ${u}`).assign(u,!1).assign(d,(0,t._)`[${d}, ${w}]`).else(),a.if(g,()=>{a.assign(u,!0),a.assign(d,w),h&&s.mergeEvaluated(h,t.Name)})})}}};return is.default=n,is}var os={},hc;function Bd(){if(hc)return os;hc=1,Object.defineProperty(os,"__esModule",{value:!0});const t=pe(),e={keyword:"allOf",schemaType:"array",code(r){const{gen:n,schema:s,it:a}=r;if(!Array.isArray(s))throw new Error("ajv implementation error");const i=n.name("valid");s.forEach((o,c)=>{if((0,t.alwaysValidSchema)(a,o))return;const l=r.subschema({keyword:"allOf",schemaProp:c},i);r.ok(i),r.mergeEvaluated(l)})}};return os.default=e,os}var cs={},pc;function Gd(){if(pc)return cs;pc=1,Object.defineProperty(cs,"__esModule",{value:!0});const t=ce(),e=pe(),n={keyword:"if",schemaType:["object","boolean"],trackErrors:!0,error:{message:({params:a})=>(0,t.str)`must match "${a.ifClause}" schema`,params:({params:a})=>(0,t._)`{failingKeyword: ${a.ifClause}}`},code(a){const{gen:i,parentSchema:o,it:c}=a;o.then===void 0&&o.else===void 0&&(0,e.checkStrictMode)(c,'"if" without "then" and "else" is ignored');const l=s(c,"then"),u=s(c,"else");if(!l&&!u)return;const d=i.let("valid",!0),g=i.name("_valid");if(v(),a.reset(),l&&u){const w=i.let("ifClause");a.setParams({ifClause:w}),i.if(g,p("then",w),p("else",w))}else l?i.if(g,p("then")):i.if((0,t.not)(g),p("else"));a.pass(d,()=>a.error(!0));function v(){const w=a.subschema({keyword:"if",compositeRule:!0,createErrors:!1,allErrors:!1},g);a.mergeEvaluated(w)}function p(w,h){return()=>{const _=a.subschema({keyword:w},g);i.assign(d,g),a.mergeValidEvaluated(_,d),h?i.assign(h,(0,t._)`${w}`):a.setParams({ifClause:w})}}}};function s(a,i){const o=a.schema[i];return o!==void 0&&!(0,e.alwaysValidSchema)(a,o)}return cs.default=n,cs}var us={},mc;function Yd(){if(mc)return us;mc=1,Object.defineProperty(us,"__esModule",{value:!0});const t=pe(),e={keyword:["then","else"],schemaType:["object","boolean"],code({keyword:r,parentSchema:n,it:s}){n.if===void 0&&(0,t.checkStrictMode)(s,`"${r}" without "if" is ignored`)}};return us.default=e,us}var _c;function Qd(){if(_c)return Gn;_c=1,Object.defineProperty(Gn,"__esModule",{value:!0});const t=Qo(),e=Zd(),r=ec(),n=Ld(),s=Ud(),a=Dd(),i=Vd(),o=oc(),c=Fd(),l=Hd(),u=Wd(),d=Jd(),g=Kd(),v=Bd(),p=Gd(),w=Yd();function h(_=!1){const f=[u.default,d.default,g.default,v.default,p.default,w.default,i.default,o.default,a.default,c.default,l.default];return _?f.push(e.default,n.default):f.push(t.default,r.default),f.push(s.default),f}return Gn.default=h,Gn}var ls={},ds={},vc;function Xd(){if(vc)return ds;vc=1,Object.defineProperty(ds,"__esModule",{value:!0});const t=ce(),r={keyword:"format",type:["number","string"],schemaType:"string",$data:!0,error:{message:({schemaCode:n})=>(0,t.str)`must match format "${n}"`,params:({schemaCode:n})=>(0,t._)`{format: ${n}}`},code(n,s){const{gen:a,data:i,$data:o,schema:c,schemaCode:l,it:u}=n,{opts:d,errSchemaPath:g,schemaEnv:v,self:p}=u;if(!d.validateFormats)return;o?w():h();function w(){const _=a.scopeValue("formats",{ref:p.formats,code:d.code.formats}),f=a.const("fDef",(0,t._)`${_}[${l}]`),m=a.let("fType"),b=a.let("format");a.if((0,t._)`typeof ${f} == "object" && !(${f} instanceof RegExp)`,()=>a.assign(m,(0,t._)`${f}.type || "string"`).assign(b,(0,t._)`${f}.validate`),()=>a.assign(m,(0,t._)`"string"`).assign(b,f)),n.fail$data((0,t.or)(y(),k()));function y(){return d.strictSchema===!1?t.nil:(0,t._)`${l} && !${b}`}function k(){const S=v.$async?(0,t._)`(${f}.async ? await ${b}(${i}) : ${b}(${i}))`:(0,t._)`${b}(${i})`,I=(0,t._)`(typeof ${b} == "function" ? ${S} : ${b}.test(${i}))`;return(0,t._)`${b} && ${b} !== true && ${m} === ${s} && !${I}`}}function h(){const _=p.formats[c];if(!_){y();return}if(_===!0)return;const[f,m,b]=k(_);f===s&&n.pass(S());function y(){if(d.strictSchema===!1){p.logger.warn(I());return}throw new Error(I());function I(){return`unknown format "${c}" ignored in schema at path "${g}"`}}function k(I){const C=I instanceof RegExp?(0,t.regexpCode)(I):d.code.formats?(0,t._)`${d.code.formats}${(0,t.getProperty)(c)}`:void 0,q=a.scopeValue("formats",{key:c,ref:I,code:C});return typeof I=="object"&&!(I instanceof RegExp)?[I.type||"string",I.validate,(0,t._)`${q}.validate`]:["string",I,q]}function S(){if(typeof _=="object"&&!(_ instanceof RegExp)&&_.async){if(!v.$async)throw new Error("async format in sync schema");return(0,t._)`await ${b}(${i})`}return typeof m=="function"?(0,t._)`${b}(${i})`:(0,t._)`${b}.test(${i})`}}}};return ds.default=r,ds}var gc;function ef(){if(gc)return ls;gc=1,Object.defineProperty(ls,"__esModule",{value:!0});const e=[Xd().default];return ls.default=e,ls}var er={},yc;function tf(){return yc||(yc=1,Object.defineProperty(er,"__esModule",{value:!0}),er.contentVocabulary=er.metadataVocabulary=void 0,er.metadataVocabulary=["title","description","default","deprecated","readOnly","writeOnly","examples"],er.contentVocabulary=["contentMediaType","contentEncoding","contentSchema"]),er}var wc;function rf(){if(wc)return An;wc=1,Object.defineProperty(An,"__esModule",{value:!0});const t=Ed(),e=qd(),r=Qd(),n=ef(),s=tf(),a=[t.default,e.default,(0,r.default)(),n.default,s.metadataVocabulary,s.contentVocabulary];return An.default=a,An}var fs={},jr={},bc;function nf(){if(bc)return jr;bc=1,Object.defineProperty(jr,"__esModule",{value:!0}),jr.DiscrError=void 0;var t;return(function(e){e.Tag="tag",e.Mapping="mapping"})(t||(jr.DiscrError=t={})),jr}var kc;function sf(){if(kc)return fs;kc=1,Object.defineProperty(fs,"__esModule",{value:!0});const t=ce(),e=nf(),r=ma(),n=On(),s=pe(),i={keyword:"discriminator",type:"object",schemaType:"object",error:{message:({params:{discrError:o,tagName:c}})=>o===e.DiscrError.Tag?`tag "${c}" must be string`:`value of tag "${c}" must be in oneOf`,params:({params:{discrError:o,tag:c,tagName:l}})=>(0,t._)`{error: ${o}, tag: ${l}, tagValue: ${c}}`},code(o){const{gen:c,data:l,schema:u,parentSchema:d,it:g}=o,{oneOf:v}=d;if(!g.opts.discriminator)throw new Error("discriminator: requires discriminator option");const p=u.propertyName;if(typeof p!="string")throw new Error("discriminator: requires propertyName");if(u.mapping)throw new Error("discriminator: mapping is not supported");if(!v)throw new Error("discriminator: requires oneOf keyword");const w=c.let("valid",!1),h=c.const("tag",(0,t._)`${l}${(0,t.getProperty)(p)}`);c.if((0,t._)`typeof ${h} == "string"`,()=>_(),()=>o.error(!1,{discrError:e.DiscrError.Tag,tag:h,tagName:p})),o.ok(w);function _(){const b=m();c.if(!1);for(const y in b)c.elseIf((0,t._)`${h} === ${y}`),c.assign(w,f(b[y]));c.else(),o.error(!1,{discrError:e.DiscrError.Mapping,tag:h,tagName:p}),c.endIf()}function f(b){const y=c.name("valid"),k=o.subschema({keyword:"oneOf",schemaProp:b},y);return o.mergeEvaluated(k,t.Name),y}function m(){var b;const y={},k=I(d);let S=!0;for(let N=0;N<v.length;N++){let V=v[N];if(V?.$ref&&!(0,s.schemaHasRulesButRef)(V,g.self.RULES)){const Y=V.$ref;if(V=r.resolveRef.call(g.self,g.schemaEnv.root,g.baseId,Y),V instanceof r.SchemaEnv&&(V=V.schema),V===void 0)throw new n.default(g.opts.uriResolver,g.baseId,Y)}const B=(b=V?.properties)===null||b===void 0?void 0:b[p];if(typeof B!="object")throw new Error(`discriminator: oneOf subschemas (or referenced schemas) must have "properties/${p}"`);S=S&&(k||I(V)),C(B,N)}if(!S)throw new Error(`discriminator: "${p}" must be required`);return y;function I({required:N}){return Array.isArray(N)&&N.includes(p)}function C(N,V){if(N.const)q(N.const,V);else if(N.enum)for(const B of N.enum)q(B,V);else throw new Error(`discriminator: "properties/${p}" must have "const" or "enum"`)}function q(N,V){if(typeof N!="string"||N in y)throw new Error(`discriminator: "${p}" values must be unique strings`);y[N]=V}}}};return fs.default=i,fs}const af={$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 $c;function Sc(){return $c||($c=1,(function(t,e){Object.defineProperty(e,"__esModule",{value:!0}),e.MissingRefError=e.ValidationError=e.CodeGen=e.Name=e.nil=e.stringify=e.str=e._=e.KeywordCxt=e.Ajv=void 0;const r=$d(),n=rf(),s=sf(),a=af,i=["/properties"],o="http://json-schema.org/draft-07/schema";class c extends r.default{_addVocabularies(){super._addVocabularies(),n.default.forEach(p=>this.addVocabulary(p)),this.opts.discriminator&&this.addKeyword(s.default)}_addDefaultMetaSchema(){if(super._addDefaultMetaSchema(),!this.opts.meta)return;const p=this.opts.$data?this.$dataMetaSchema(a,i):a;this.addMetaSchema(p,o,!1),this.refs["http://json-schema.org/schema"]=o}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(o)?o:void 0)}}e.Ajv=c,t.exports=e=c,t.exports.Ajv=c,Object.defineProperty(e,"__esModule",{value:!0}),e.default=c;var l=xn();Object.defineProperty(e,"KeywordCxt",{enumerable:!0,get:function(){return l.KeywordCxt}});var u=ce();Object.defineProperty(e,"_",{enumerable:!0,get:function(){return u._}}),Object.defineProperty(e,"str",{enumerable:!0,get:function(){return u.str}}),Object.defineProperty(e,"stringify",{enumerable:!0,get:function(){return u.stringify}}),Object.defineProperty(e,"nil",{enumerable:!0,get:function(){return u.nil}}),Object.defineProperty(e,"Name",{enumerable:!0,get:function(){return u.Name}}),Object.defineProperty(e,"CodeGen",{enumerable:!0,get:function(){return u.CodeGen}});var d=pa();Object.defineProperty(e,"ValidationError",{enumerable:!0,get:function(){return d.default}});var g=On();Object.defineProperty(e,"MissingRefError",{enumerable:!0,get:function(){return g.default}})})($n,$n.exports)),$n.exports}var Tc=Sc();const of=dr(Tc),cf=Object.freeze({status:"aborted"});function A(t,e,r){function n(o,c){var l;Object.defineProperty(o,"_zod",{value:o._zod??{},enumerable:!1}),(l=o._zod).traits??(l.traits=new Set),o._zod.traits.add(t),e(o,c);for(const u in i.prototype)u in o||Object.defineProperty(o,u,{value:i.prototype[u].bind(o)});o._zod.constr=i,o._zod.def=c}const s=r?.Parent??Object;class a extends s{}Object.defineProperty(a,"name",{value:t});function i(o){var c;const l=r?.Parent?new a:this;n(l,o),(c=l._zod).deferred??(c.deferred=[]);for(const u of l._zod.deferred)u();return l}return Object.defineProperty(i,"init",{value:n}),Object.defineProperty(i,Symbol.hasInstance,{value:o=>r?.Parent&&o instanceof r.Parent?!0:o?._zod?.traits?.has(t)}),Object.defineProperty(i,"name",{value:t}),i}class zr extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}const Ec={};function Ut(t){return Ec}function Rc(t){const e=Object.values(t).filter(n=>typeof n=="number");return Object.entries(t).filter(([n,s])=>e.indexOf(+n)===-1).map(([n,s])=>s)}function uf(t,e){return typeof e=="bigint"?e.toString():e}function wa(t){return{get value(){{const e=t();return Object.defineProperty(this,"value",{value:e}),e}}}}function ba(t){return t==null}function ka(t){const e=t.startsWith("^")?1:0,r=t.endsWith("$")?t.length-1:t.length;return t.slice(e,r)}function lf(t,e){const r=(t.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,s=r>n?r:n,a=Number.parseInt(t.toFixed(s).replace(".","")),i=Number.parseInt(e.toFixed(s).replace(".",""));return a%i/10**s}function Te(t,e,r){Object.defineProperty(t,e,{get(){{const n=r();return t[e]=n,n}},set(n){Object.defineProperty(t,e,{value:n})},configurable:!0})}function Mr(t,e,r){Object.defineProperty(t,e,{value:r,writable:!0,enumerable:!0,configurable:!0})}function qr(t){return JSON.stringify(t)}const Pc=Error.captureStackTrace?Error.captureStackTrace:(...t)=>{};function hs(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}const df=wa(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{const t=Function;return new t(""),!0}catch{return!1}});function ps(t){if(hs(t)===!1)return!1;const e=t.constructor;if(e===void 0)return!0;const r=e.prototype;return!(hs(r)===!1||Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)}const ff=new Set(["string","number","symbol"]);function Zr(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Dt(t,e,r){const n=new t._zod.constr(e??t._zod.def);return(!e||r?.parent)&&(n._zod.parent=t),n}function Q(t){const e=t;if(!e)return{};if(typeof e=="string")return{error:()=>e};if(e?.message!==void 0){if(e?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");e.error=e.message}return delete e.message,typeof e.error=="string"?{...e,error:()=>e.error}:e}function hf(t){return Object.keys(t).filter(e=>t[e]._zod.optin==="optional"&&t[e]._zod.optout==="optional")}const pf={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function mf(t,e){const r={},n=t._zod.def;for(const s in e){if(!(s in n.shape))throw new Error(`Unrecognized key: "${s}"`);e[s]&&(r[s]=n.shape[s])}return Dt(t,{...t._zod.def,shape:r,checks:[]})}function _f(t,e){const r={...t._zod.def.shape},n=t._zod.def;for(const s in e){if(!(s in n.shape))throw new Error(`Unrecognized key: "${s}"`);e[s]&&delete r[s]}return Dt(t,{...t._zod.def,shape:r,checks:[]})}function vf(t,e){if(!ps(e))throw new Error("Invalid input to extend: expected a plain object");const r={...t._zod.def,get shape(){const n={...t._zod.def.shape,...e};return Mr(this,"shape",n),n},checks:[]};return Dt(t,r)}function gf(t,e){return Dt(t,{...t._zod.def,get shape(){const r={...t._zod.def.shape,...e._zod.def.shape};return Mr(this,"shape",r),r},catchall:e._zod.def.catchall,checks:[]})}function yf(t,e,r){const n=e._zod.def.shape,s={...n};if(r)for(const a in r){if(!(a in n))throw new Error(`Unrecognized key: "${a}"`);r[a]&&(s[a]=t?new t({type:"optional",innerType:n[a]}):n[a])}else for(const a in n)s[a]=t?new t({type:"optional",innerType:n[a]}):n[a];return Dt(e,{...e._zod.def,shape:s,checks:[]})}function wf(t,e,r){const n=e._zod.def.shape,s={...n};if(r)for(const a in r){if(!(a in s))throw new Error(`Unrecognized key: "${a}"`);r[a]&&(s[a]=new t({type:"nonoptional",innerType:n[a]}))}else for(const a in n)s[a]=new t({type:"nonoptional",innerType:n[a]});return Dt(e,{...e._zod.def,shape:s,checks:[]})}function Lr(t,e=0){for(let r=e;r<t.issues.length;r++)if(t.issues[r]?.continue!==!0)return!0;return!1}function tr(t,e){return e.map(r=>{var n;return(n=r).path??(n.path=[]),r.path.unshift(t),r})}function ms(t){return typeof t=="string"?t:t?.message}function Vt(t,e,r){const n={...t,path:t.path??[]};if(!t.message){const s=ms(t.inst?._zod.def?.error?.(t))??ms(e?.error?.(t))??ms(r.customError?.(t))??ms(r.localeError?.(t))??"Invalid input";n.message=s}return delete n.inst,delete n.continue,e?.reportInput||delete n.input,n}function $a(t){return Array.isArray(t)?"array":typeof t=="string"?"string":"unknown"}function Ur(...t){const[e,r,n]=t;return typeof e=="string"?{message:e,code:"custom",input:r,inst:n}:{...e}}const xc=(t,e)=>{t.name="$ZodError",Object.defineProperty(t,"_zod",{value:t._zod,enumerable:!1}),Object.defineProperty(t,"issues",{value:e,enumerable:!1}),Object.defineProperty(t,"message",{get(){return JSON.stringify(e,uf,2)},enumerable:!0}),Object.defineProperty(t,"toString",{value:()=>t.message,enumerable:!1})},Ic=A("$ZodError",xc),_s=A("$ZodError",xc,{Parent:Error});function bf(t,e=r=>r.message){const r={},n=[];for(const s of t.issues)s.path.length>0?(r[s.path[0]]=r[s.path[0]]||[],r[s.path[0]].push(e(s))):n.push(e(s));return{formErrors:n,fieldErrors:r}}function kf(t,e){const r=e||function(a){return a.message},n={_errors:[]},s=a=>{for(const i of a.issues)if(i.code==="invalid_union"&&i.errors.length)i.errors.map(o=>s({issues:o}));else if(i.code==="invalid_key")s({issues:i.issues});else if(i.code==="invalid_element")s({issues:i.issues});else if(i.path.length===0)n._errors.push(r(i));else{let o=n,c=0;for(;c<i.path.length;){const l=i.path[c];c===i.path.length-1?(o[l]=o[l]||{_errors:[]},o[l]._errors.push(r(i))):o[l]=o[l]||{_errors:[]},o=o[l],c++}}};return s(t),n}const Cc=t=>(e,r,n,s)=>{const a=n?Object.assign(n,{async:!1}):{async:!1},i=e._zod.run({value:r,issues:[]},a);if(i instanceof Promise)throw new zr;if(i.issues.length){const o=new(s?.Err??t)(i.issues.map(c=>Vt(c,a,Ut())));throw Pc(o,s?.callee),o}return i.value},$f=Cc(_s),Oc=t=>async(e,r,n,s)=>{const a=n?Object.assign(n,{async:!0}):{async:!0};let i=e._zod.run({value:r,issues:[]},a);if(i instanceof Promise&&(i=await i),i.issues.length){const o=new(s?.Err??t)(i.issues.map(c=>Vt(c,a,Ut())));throw Pc(o,s?.callee),o}return i.value},Sf=Oc(_s),Nc=t=>(e,r,n)=>{const s=n?{...n,async:!1}:{async:!1},a=e._zod.run({value:r,issues:[]},s);if(a instanceof Promise)throw new zr;return a.issues.length?{success:!1,error:new(t??Ic)(a.issues.map(i=>Vt(i,s,Ut())))}:{success:!0,data:a.value}},Sa=Nc(_s),Ac=t=>async(e,r,n)=>{const s=n?Object.assign(n,{async:!0}):{async:!0};let a=e._zod.run({value:r,issues:[]},s);return a instanceof Promise&&(a=await a),a.issues.length?{success:!1,error:new t(a.issues.map(i=>Vt(i,s,Ut())))}:{success:!0,data:a.value}},Ta=Ac(_s),Tf=/^[cC][^\s-]{8,}$/,Ef=/^[0-9a-z]+$/,Rf=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,Pf=/^[0-9a-vA-V]{20}$/,xf=/^[A-Za-z0-9]{27}$/,If=/^[a-zA-Z0-9_-]{21}$/,Cf=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Of=/^([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})$/,jc=t=>t?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${t}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000)$/,Nf=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,Af="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function jf(){return new RegExp(Af,"u")}const zf=/^(?:(?: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])$/,Mf=/^(([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})$/,qf=/^((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])$/,Zf=/^(([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])$/,Lf=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,zc=/^[A-Za-z0-9_-]*$/,Uf=/^([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+$/,Df=/^\+(?:[0-9]){6,14}[0-9]$/,Mc="(?:(?:\\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])))",Vf=new RegExp(`^${Mc}$`);function qc(t){const e="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof t.precision=="number"?t.precision===-1?`${e}`:t.precision===0?`${e}:[0-5]\\d`:`${e}:[0-5]\\d\\.\\d{${t.precision}}`:`${e}(?::[0-5]\\d(?:\\.\\d+)?)?`}function Ff(t){return new RegExp(`^${qc(t)}$`)}function Hf(t){const e=qc({precision:t.precision}),r=["Z"];t.local&&r.push(""),t.offset&&r.push("([+-]\\d{2}:\\d{2})");const n=`${e}(?:${r.join("|")})`;return new RegExp(`^${Mc}T(?:${n})$`)}const Wf=t=>{const e=t?`[\\s\\S]{${t?.minimum??0},${t?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${e}$`)},Jf=/^\d+$/,Kf=/^-?\d+(?:\.\d+)?/i,Bf=/true|false/i,Gf=/null/i,Yf=/^[^A-Z]*$/,Qf=/^[^a-z]*$/,Qe=A("$ZodCheck",(t,e)=>{var r;t._zod??(t._zod={}),t._zod.def=e,(r=t._zod).onattach??(r.onattach=[])}),Zc={number:"number",bigint:"bigint",object:"date"},Lc=A("$ZodCheckLessThan",(t,e)=>{Qe.init(t,e);const r=Zc[typeof e.value];t._zod.onattach.push(n=>{const s=n._zod.bag,a=(e.inclusive?s.maximum:s.exclusiveMaximum)??Number.POSITIVE_INFINITY;e.value<a&&(e.inclusive?s.maximum=e.value:s.exclusiveMaximum=e.value)}),t._zod.check=n=>{(e.inclusive?n.value<=e.value:n.value<e.value)||n.issues.push({origin:r,code:"too_big",maximum:e.value,input:n.value,inclusive:e.inclusive,inst:t,continue:!e.abort})}}),Uc=A("$ZodCheckGreaterThan",(t,e)=>{Qe.init(t,e);const r=Zc[typeof e.value];t._zod.onattach.push(n=>{const s=n._zod.bag,a=(e.inclusive?s.minimum:s.exclusiveMinimum)??Number.NEGATIVE_INFINITY;e.value>a&&(e.inclusive?s.minimum=e.value:s.exclusiveMinimum=e.value)}),t._zod.check=n=>{(e.inclusive?n.value>=e.value:n.value>e.value)||n.issues.push({origin:r,code:"too_small",minimum:e.value,input:n.value,inclusive:e.inclusive,inst:t,continue:!e.abort})}}),Xf=A("$ZodCheckMultipleOf",(t,e)=>{Qe.init(t,e),t._zod.onattach.push(r=>{var n;(n=r._zod.bag).multipleOf??(n.multipleOf=e.value)}),t._zod.check=r=>{if(typeof r.value!=typeof e.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof r.value=="bigint"?r.value%e.value===BigInt(0):lf(r.value,e.value)===0)||r.issues.push({origin:typeof r.value,code:"not_multiple_of",divisor:e.value,input:r.value,inst:t,continue:!e.abort})}}),eh=A("$ZodCheckNumberFormat",(t,e)=>{Qe.init(t,e),e.format=e.format||"float64";const r=e.format?.includes("int"),n=r?"int":"number",[s,a]=pf[e.format];t._zod.onattach.push(i=>{const o=i._zod.bag;o.format=e.format,o.minimum=s,o.maximum=a,r&&(o.pattern=Jf)}),t._zod.check=i=>{const o=i.value;if(r){if(!Number.isInteger(o)){i.issues.push({expected:n,format:e.format,code:"invalid_type",input:o,inst:t});return}if(!Number.isSafeInteger(o)){o>0?i.issues.push({input:o,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:t,origin:n,continue:!e.abort}):i.issues.push({input:o,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:t,origin:n,continue:!e.abort});return}}o<s&&i.issues.push({origin:"number",input:o,code:"too_small",minimum:s,inclusive:!0,inst:t,continue:!e.abort}),o>a&&i.issues.push({origin:"number",input:o,code:"too_big",maximum:a,inst:t})}}),th=A("$ZodCheckMaxLength",(t,e)=>{var r;Qe.init(t,e),(r=t._zod.def).when??(r.when=n=>{const s=n.value;return!ba(s)&&s.length!==void 0}),t._zod.onattach.push(n=>{const s=n._zod.bag.maximum??Number.POSITIVE_INFINITY;e.maximum<s&&(n._zod.bag.maximum=e.maximum)}),t._zod.check=n=>{const s=n.value;if(s.length<=e.maximum)return;const i=$a(s);n.issues.push({origin:i,code:"too_big",maximum:e.maximum,inclusive:!0,input:s,inst:t,continue:!e.abort})}}),rh=A("$ZodCheckMinLength",(t,e)=>{var r;Qe.init(t,e),(r=t._zod.def).when??(r.when=n=>{const s=n.value;return!ba(s)&&s.length!==void 0}),t._zod.onattach.push(n=>{const s=n._zod.bag.minimum??Number.NEGATIVE_INFINITY;e.minimum>s&&(n._zod.bag.minimum=e.minimum)}),t._zod.check=n=>{const s=n.value;if(s.length>=e.minimum)return;const i=$a(s);n.issues.push({origin:i,code:"too_small",minimum:e.minimum,inclusive:!0,input:s,inst:t,continue:!e.abort})}}),nh=A("$ZodCheckLengthEquals",(t,e)=>{var r;Qe.init(t,e),(r=t._zod.def).when??(r.when=n=>{const s=n.value;return!ba(s)&&s.length!==void 0}),t._zod.onattach.push(n=>{const s=n._zod.bag;s.minimum=e.length,s.maximum=e.length,s.length=e.length}),t._zod.check=n=>{const s=n.value,a=s.length;if(a===e.length)return;const i=$a(s),o=a>e.length;n.issues.push({origin:i,...o?{code:"too_big",maximum:e.length}:{code:"too_small",minimum:e.length},inclusive:!0,exact:!0,input:n.value,inst:t,continue:!e.abort})}}),vs=A("$ZodCheckStringFormat",(t,e)=>{var r,n;Qe.init(t,e),t._zod.onattach.push(s=>{const a=s._zod.bag;a.format=e.format,e.pattern&&(a.patterns??(a.patterns=new Set),a.patterns.add(e.pattern))}),e.pattern?(r=t._zod).check??(r.check=s=>{e.pattern.lastIndex=0,!e.pattern.test(s.value)&&s.issues.push({origin:"string",code:"invalid_format",format:e.format,input:s.value,...e.pattern?{pattern:e.pattern.toString()}:{},inst:t,continue:!e.abort})}):(n=t._zod).check??(n.check=()=>{})}),sh=A("$ZodCheckRegex",(t,e)=>{vs.init(t,e),t._zod.check=r=>{e.pattern.lastIndex=0,!e.pattern.test(r.value)&&r.issues.push({origin:"string",code:"invalid_format",format:"regex",input:r.value,pattern:e.pattern.toString(),inst:t,continue:!e.abort})}}),ah=A("$ZodCheckLowerCase",(t,e)=>{e.pattern??(e.pattern=Yf),vs.init(t,e)}),ih=A("$ZodCheckUpperCase",(t,e)=>{e.pattern??(e.pattern=Qf),vs.init(t,e)}),oh=A("$ZodCheckIncludes",(t,e)=>{Qe.init(t,e);const r=Zr(e.includes),n=new RegExp(typeof e.position=="number"?`^.{${e.position}}${r}`:r);e.pattern=n,t._zod.onattach.push(s=>{const a=s._zod.bag;a.patterns??(a.patterns=new Set),a.patterns.add(n)}),t._zod.check=s=>{s.value.includes(e.includes,e.position)||s.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:e.includes,input:s.value,inst:t,continue:!e.abort})}}),ch=A("$ZodCheckStartsWith",(t,e)=>{Qe.init(t,e);const r=new RegExp(`^${Zr(e.prefix)}.*`);e.pattern??(e.pattern=r),t._zod.onattach.push(n=>{const s=n._zod.bag;s.patterns??(s.patterns=new Set),s.patterns.add(r)}),t._zod.check=n=>{n.value.startsWith(e.prefix)||n.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:e.prefix,input:n.value,inst:t,continue:!e.abort})}}),uh=A("$ZodCheckEndsWith",(t,e)=>{Qe.init(t,e);const r=new RegExp(`.*${Zr(e.suffix)}$`);e.pattern??(e.pattern=r),t._zod.onattach.push(n=>{const s=n._zod.bag;s.patterns??(s.patterns=new Set),s.patterns.add(r)}),t._zod.check=n=>{n.value.endsWith(e.suffix)||n.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:e.suffix,input:n.value,inst:t,continue:!e.abort})}}),lh=A("$ZodCheckOverwrite",(t,e)=>{Qe.init(t,e),t._zod.check=r=>{r.value=e.tx(r.value)}});class dh{constructor(e=[]){this.content=[],this.indent=0,this&&(this.args=e)}indented(e){this.indent+=1,e(this),this.indent-=1}write(e){if(typeof e=="function"){e(this,{execution:"sync"}),e(this,{execution:"async"});return}const n=e.split(`
|
|
9
|
-
`).filter(i=>i),s=Math.min(...n.map(i=>i.length-i.trimStart().length)),
|
|
10
|
-
`))}}const
|
|
11
|
-
if (${
|
|
12
|
-
if (input[${
|
|
13
|
-
if (${
|
|
14
|
-
newResult[${
|
|
7
|
+
depsCount: ${u},
|
|
8
|
+
deps: ${l}}`};const s={keyword:"dependencies",type:"object",schemaType:"object",error:t.error,code(c){const[u,l]=o(c);i(c,u),a(c,l)}};function o({schema:c}){const u={},l={};for(const d in c){if(d==="__proto__")continue;const p=Array.isArray(c[d])?u:l;p[d]=c[d]}return[u,l]}function i(c,u=c.schema){const{gen:l,data:d,it:p}=c;if(Object.keys(u).length===0)return;const _=l.let("missing");for(const m in u){const g=u[m];if(g.length===0)continue;const f=(0,n.propertyInData)(l,d,m,p.opts.ownProperties);c.setParams({property:m,depsCount:g.length,deps:g.join(", ")}),p.allErrors?l.if(f,()=>{for(const v of g)(0,n.checkReportMissingProp)(c,v)}):(l.if((0,e._)`${f} && (${(0,n.checkMissingProp)(c,g,_)})`),(0,n.reportMissingProp)(c,_),l.else())}}t.validatePropertyDeps=i;function a(c,u=c.schema){const{gen:l,data:d,keyword:p,it:_}=c,m=l.name("valid");for(const g in u)(0,r.alwaysValidSchema)(_,u[g])||(l.if((0,n.propertyInData)(l,d,g,_.opts.ownProperties),()=>{const f=c.subschema({keyword:p,schemaProp:g},m);c.mergeValidEvaluated(f,m)},()=>l.var(m,!0)),c.ok(m))}t.validateSchemaDeps=a,t.default=s})(ei)),ei}var bs={},gu;function Yf(){if(gu)return bs;gu=1,Object.defineProperty(bs,"__esModule",{value:!0});const t=fe(),e=be(),n={keyword:"propertyNames",type:"object",schemaType:["object","boolean"],error:{message:"property name must be valid",params:({params:s})=>(0,t._)`{propertyName: ${s.propertyName}}`},code(s){const{gen:o,schema:i,data:a,it:c}=s;if((0,e.alwaysValidSchema)(c,i))return;const u=o.name("valid");o.forIn("key",a,l=>{s.setParams({propertyName:l}),s.subschema({keyword:"propertyNames",data:l,dataTypes:["string"],propertyName:l,compositeRule:!0},u),o.if((0,t.not)(u),()=>{s.error(!0),c.allErrors||o.break()})}),s.ok(u)}};return bs.default=n,bs}var $s={},vu;function yu(){if(vu)return $s;vu=1,Object.defineProperty($s,"__esModule",{value:!0});const t=yt(),e=fe(),r=Bt(),n=be(),o={keyword:"additionalProperties",type:["object"],schemaType:["boolean","object"],allowUndefined:!0,trackErrors:!0,error:{message:"must NOT have additional properties",params:({params:i})=>(0,e._)`{additionalProperty: ${i.additionalProperty}}`},code(i){const{gen:a,schema:c,parentSchema:u,data:l,errsCount:d,it:p}=i;if(!d)throw new Error("ajv implementation error");const{allErrors:_,opts:m}=p;if(p.props=!0,m.removeAdditional!=="all"&&(0,n.alwaysValidSchema)(p,c))return;const g=(0,t.allSchemaProperties)(u.properties),f=(0,t.allSchemaProperties)(u.patternProperties);v(),i.ok((0,e._)`${d} === ${r.default.errors}`);function v(){a.forIn("key",l,S=>{!g.length&&!f.length?$(S):a.if(h(S),()=>$(S))})}function h(S){let T;if(g.length>8){const N=(0,n.schemaRefOrVal)(p,u.properties,"properties");T=(0,t.isOwnProperty)(a,N,S)}else g.length?T=(0,e.or)(...g.map(N=>(0,e._)`${S} === ${N}`)):T=e.nil;return f.length&&(T=(0,e.or)(T,...f.map(N=>(0,e._)`${(0,t.usePattern)(i,N)}.test(${S})`))),(0,e.not)(T)}function w(S){a.code((0,e._)`delete ${l}[${S}]`)}function $(S){if(m.removeAdditional==="all"||m.removeAdditional&&c===!1){w(S);return}if(c===!1){i.setParams({additionalProperty:S}),i.error(),_||a.break();return}if(typeof c=="object"&&!(0,n.alwaysValidSchema)(p,c)){const T=a.name("valid");m.removeAdditional==="failing"?(b(S,T,!1),a.if((0,e.not)(T),()=>{i.reset(),w(S)})):(b(S,T),_||a.if((0,e.not)(T),()=>a.break()))}}function b(S,T,N){const j={keyword:"additionalProperties",dataProp:S,dataPropType:n.Type.Str};N===!1&&Object.assign(j,{compositeRule:!0,createErrors:!1,allErrors:!1}),i.subschema(j,T)}}};return $s.default=o,$s}var Ss={},wu;function Qf(){if(wu)return Ss;wu=1,Object.defineProperty(Ss,"__esModule",{value:!0});const t=Gn(),e=yt(),r=be(),n=yu(),s={keyword:"properties",type:"object",schemaType:"object",code(o){const{gen:i,schema:a,parentSchema:c,data:u,it:l}=o;l.opts.removeAdditional==="all"&&c.additionalProperties===void 0&&n.default.code(new t.KeywordCxt(l,n.default,"additionalProperties"));const d=(0,e.allSchemaProperties)(a);for(const f of d)l.definedProperties.add(f);l.opts.unevaluated&&d.length&&l.props!==!0&&(l.props=r.mergeEvaluated.props(i,(0,r.toHash)(d),l.props));const p=d.filter(f=>!(0,r.alwaysValidSchema)(l,a[f]));if(p.length===0)return;const _=i.name("valid");for(const f of p)m(f)?g(f):(i.if((0,e.propertyInData)(i,u,f,l.opts.ownProperties)),g(f),l.allErrors||i.else().var(_,!0),i.endIf()),o.it.definedProperties.add(f),o.ok(_);function m(f){return l.opts.useDefaults&&!l.compositeRule&&a[f].default!==void 0}function g(f){o.subschema({keyword:"properties",schemaProp:f,dataProp:f},_)}}};return Ss.default=s,Ss}var ks={},bu;function Xf(){if(bu)return ks;bu=1,Object.defineProperty(ks,"__esModule",{value:!0});const t=yt(),e=fe(),r=be(),n=be(),s={keyword:"patternProperties",type:"object",schemaType:"object",code(o){const{gen:i,schema:a,data:c,parentSchema:u,it:l}=o,{opts:d}=l,p=(0,t.allSchemaProperties)(a),_=p.filter($=>(0,r.alwaysValidSchema)(l,a[$]));if(p.length===0||_.length===p.length&&(!l.opts.unevaluated||l.props===!0))return;const m=d.strictSchema&&!d.allowMatchingProperties&&u.properties,g=i.name("valid");l.props!==!0&&!(l.props instanceof e.Name)&&(l.props=(0,n.evaluatedPropsToName)(i,l.props));const{props:f}=l;v();function v(){for(const $ of p)m&&h($),l.allErrors?w($):(i.var(g,!0),w($),i.if(g))}function h($){for(const b in m)new RegExp($).test(b)&&(0,r.checkStrictMode)(l,`property ${b} matches pattern ${$} (use allowMatchingProperties)`)}function w($){i.forIn("key",c,b=>{i.if((0,e._)`${(0,t.usePattern)(o,$)}.test(${b})`,()=>{const S=_.includes($);S||o.subschema({keyword:"patternProperties",schemaProp:$,dataProp:b,dataPropType:n.Type.Str},g),l.opts.unevaluated&&f!==!0?i.assign((0,e._)`${f}[${b}]`,!0):!S&&!l.allErrors&&i.if((0,e.not)(g),()=>i.break())})})}}};return ks.default=s,ks}var Ts={},$u;function ep(){if($u)return Ts;$u=1,Object.defineProperty(Ts,"__esModule",{value:!0});const t=be(),e={keyword:"not",schemaType:["object","boolean"],trackErrors:!0,code(r){const{gen:n,schema:s,it:o}=r;if((0,t.alwaysValidSchema)(o,s)){r.fail();return}const i=n.name("valid");r.subschema({keyword:"not",compositeRule:!0,createErrors:!1,allErrors:!1},i),r.failResult(i,()=>r.reset(),()=>r.error())},error:{message:"must NOT be valid"}};return Ts.default=e,Ts}var Rs={},Su;function tp(){if(Su)return Rs;Su=1,Object.defineProperty(Rs,"__esModule",{value:!0});const e={keyword:"anyOf",schemaType:"array",trackErrors:!0,code:yt().validateUnion,error:{message:"must match a schema in anyOf"}};return Rs.default=e,Rs}var Es={},ku;function rp(){if(ku)return Es;ku=1,Object.defineProperty(Es,"__esModule",{value:!0});const t=fe(),e=be(),n={keyword:"oneOf",schemaType:"array",trackErrors:!0,error:{message:"must match exactly one schema in oneOf",params:({params:s})=>(0,t._)`{passingSchemas: ${s.passing}}`},code(s){const{gen:o,schema:i,parentSchema:a,it:c}=s;if(!Array.isArray(i))throw new Error("ajv implementation error");if(c.opts.discriminator&&a.discriminator)return;const u=i,l=o.let("valid",!1),d=o.let("passing",null),p=o.name("_valid");s.setParams({passing:d}),o.block(_),s.result(l,()=>s.reset(),()=>s.error(!0));function _(){u.forEach((m,g)=>{let f;(0,e.alwaysValidSchema)(c,m)?o.var(p,!0):f=s.subschema({keyword:"oneOf",schemaProp:g,compositeRule:!0},p),g>0&&o.if((0,t._)`${p} && ${l}`).assign(l,!1).assign(d,(0,t._)`[${d}, ${g}]`).else(),o.if(p,()=>{o.assign(l,!0),o.assign(d,g),f&&s.mergeEvaluated(f,t.Name)})})}}};return Es.default=n,Es}var Ps={},Tu;function np(){if(Tu)return Ps;Tu=1,Object.defineProperty(Ps,"__esModule",{value:!0});const t=be(),e={keyword:"allOf",schemaType:"array",code(r){const{gen:n,schema:s,it:o}=r;if(!Array.isArray(s))throw new Error("ajv implementation error");const i=n.name("valid");s.forEach((a,c)=>{if((0,t.alwaysValidSchema)(o,a))return;const u=r.subschema({keyword:"allOf",schemaProp:c},i);r.ok(i),r.mergeEvaluated(u)})}};return Ps.default=e,Ps}var xs={},Ru;function sp(){if(Ru)return xs;Ru=1,Object.defineProperty(xs,"__esModule",{value:!0});const t=fe(),e=be(),n={keyword:"if",schemaType:["object","boolean"],trackErrors:!0,error:{message:({params:o})=>(0,t.str)`must match "${o.ifClause}" schema`,params:({params:o})=>(0,t._)`{failingKeyword: ${o.ifClause}}`},code(o){const{gen:i,parentSchema:a,it:c}=o;a.then===void 0&&a.else===void 0&&(0,e.checkStrictMode)(c,'"if" without "then" and "else" is ignored');const u=s(c,"then"),l=s(c,"else");if(!u&&!l)return;const d=i.let("valid",!0),p=i.name("_valid");if(_(),o.reset(),u&&l){const g=i.let("ifClause");o.setParams({ifClause:g}),i.if(p,m("then",g),m("else",g))}else u?i.if(p,m("then")):i.if((0,t.not)(p),m("else"));o.pass(d,()=>o.error(!0));function _(){const g=o.subschema({keyword:"if",compositeRule:!0,createErrors:!1,allErrors:!1},p);o.mergeEvaluated(g)}function m(g,f){return()=>{const v=o.subschema({keyword:g},p);i.assign(d,p),o.mergeValidEvaluated(v,d),f?i.assign(f,(0,t._)`${g}`):o.setParams({ifClause:g})}}}};function s(o,i){const a=o.schema[i];return a!==void 0&&!(0,e.alwaysValidSchema)(o,a)}return xs.default=n,xs}var Is={},Eu;function op(){if(Eu)return Is;Eu=1,Object.defineProperty(Is,"__esModule",{value:!0});const t=be(),e={keyword:["then","else"],schemaType:["object","boolean"],code({keyword:r,parentSchema:n,it:s}){n.if===void 0&&(0,t.checkStrictMode)(s,`"${r}" without "if" is ignored`)}};return Is.default=e,Is}var Pu;function ip(){if(Pu)return gs;Pu=1,Object.defineProperty(gs,"__esModule",{value:!0});const t=lu(),e=Jf(),r=hu(),n=Bf(),s=Kf(),o=Gf(),i=Yf(),a=yu(),c=Qf(),u=Xf(),l=ep(),d=tp(),p=rp(),_=np(),m=sp(),g=op();function f(v=!1){const h=[l.default,d.default,p.default,_.default,m.default,g.default,i.default,a.default,o.default,c.default,u.default];return v?h.push(e.default,n.default):h.push(t.default,r.default),h.push(s.default),h}return gs.default=f,gs}var Cs={},Os={},xu;function ap(){if(xu)return Os;xu=1,Object.defineProperty(Os,"__esModule",{value:!0});const t=fe(),r={keyword:"format",type:["number","string"],schemaType:"string",$data:!0,error:{message:({schemaCode:n})=>(0,t.str)`must match format "${n}"`,params:({schemaCode:n})=>(0,t._)`{format: ${n}}`},code(n,s){const{gen:o,data:i,$data:a,schema:c,schemaCode:u,it:l}=n,{opts:d,errSchemaPath:p,schemaEnv:_,self:m}=l;if(!d.validateFormats)return;a?g():f();function g(){const v=o.scopeValue("formats",{ref:m.formats,code:d.code.formats}),h=o.const("fDef",(0,t._)`${v}[${u}]`),w=o.let("fType"),$=o.let("format");o.if((0,t._)`typeof ${h} == "object" && !(${h} instanceof RegExp)`,()=>o.assign(w,(0,t._)`${h}.type || "string"`).assign($,(0,t._)`${h}.validate`),()=>o.assign(w,(0,t._)`"string"`).assign($,h)),n.fail$data((0,t.or)(b(),S()));function b(){return d.strictSchema===!1?t.nil:(0,t._)`${u} && !${$}`}function S(){const T=_.$async?(0,t._)`(${h}.async ? await ${$}(${i}) : ${$}(${i}))`:(0,t._)`${$}(${i})`,N=(0,t._)`(typeof ${$} == "function" ? ${T} : ${$}.test(${i}))`;return(0,t._)`${$} && ${$} !== true && ${w} === ${s} && !${N}`}}function f(){const v=m.formats[c];if(!v){b();return}if(v===!0)return;const[h,w,$]=S(v);h===s&&n.pass(T());function b(){if(d.strictSchema===!1){m.logger.warn(N());return}throw new Error(N());function N(){return`unknown format "${c}" ignored in schema at path "${p}"`}}function S(N){const j=N instanceof RegExp?(0,t.regexpCode)(N):d.code.formats?(0,t._)`${d.code.formats}${(0,t.getProperty)(c)}`:void 0,F=o.scopeValue("formats",{key:c,ref:N,code:j});return typeof N=="object"&&!(N instanceof RegExp)?[N.type||"string",N.validate,(0,t._)`${F}.validate`]:["string",N,F]}function T(){if(typeof v=="object"&&!(v instanceof RegExp)&&v.async){if(!_.$async)throw new Error("async format in sync schema");return(0,t._)`await ${$}(${i})`}return typeof w=="function"?(0,t._)`${$}(${i})`:(0,t._)`${$}.test(${i})`}}}};return Os.default=r,Os}var Iu;function cp(){if(Iu)return Cs;Iu=1,Object.defineProperty(Cs,"__esModule",{value:!0});const e=[ap().default];return Cs.default=e,Cs}var dr={},Cu;function up(){return Cu||(Cu=1,Object.defineProperty(dr,"__esModule",{value:!0}),dr.contentVocabulary=dr.metadataVocabulary=void 0,dr.metadataVocabulary=["title","description","default","deprecated","readOnly","writeOnly","examples"],dr.contentVocabulary=["contentMediaType","contentEncoding","contentSchema"]),dr}var Ou;function lp(){if(Ou)return ts;Ou=1,Object.defineProperty(ts,"__esModule",{value:!0});const t=Af(),e=Wf(),r=ip(),n=cp(),s=up(),o=[t.default,e.default,(0,r.default)(),n.default,s.metadataVocabulary,s.contentVocabulary];return ts.default=o,ts}var Ns={},Gr={},Nu;function dp(){if(Nu)return Gr;Nu=1,Object.defineProperty(Gr,"__esModule",{value:!0}),Gr.DiscrError=void 0;var t;return(function(e){e.Tag="tag",e.Mapping="mapping"})(t||(Gr.DiscrError=t={})),Gr}var Au;function hp(){if(Au)return Ns;Au=1,Object.defineProperty(Ns,"__esModule",{value:!0});const t=fe(),e=dp(),r=Go(),n=Xn(),s=be(),i={keyword:"discriminator",type:"object",schemaType:"object",error:{message:({params:{discrError:a,tagName:c}})=>a===e.DiscrError.Tag?`tag "${c}" must be string`:`value of tag "${c}" must be in oneOf`,params:({params:{discrError:a,tag:c,tagName:u}})=>(0,t._)`{error: ${a}, tag: ${u}, tagValue: ${c}}`},code(a){const{gen:c,data:u,schema:l,parentSchema:d,it:p}=a,{oneOf:_}=d;if(!p.opts.discriminator)throw new Error("discriminator: requires discriminator option");const m=l.propertyName;if(typeof m!="string")throw new Error("discriminator: requires propertyName");if(l.mapping)throw new Error("discriminator: mapping is not supported");if(!_)throw new Error("discriminator: requires oneOf keyword");const g=c.let("valid",!1),f=c.const("tag",(0,t._)`${u}${(0,t.getProperty)(m)}`);c.if((0,t._)`typeof ${f} == "string"`,()=>v(),()=>a.error(!1,{discrError:e.DiscrError.Tag,tag:f,tagName:m})),a.ok(g);function v(){const $=w();c.if(!1);for(const b in $)c.elseIf((0,t._)`${f} === ${b}`),c.assign(g,h($[b]));c.else(),a.error(!1,{discrError:e.DiscrError.Mapping,tag:f,tagName:m}),c.endIf()}function h($){const b=c.name("valid"),S=a.subschema({keyword:"oneOf",schemaProp:$},b);return a.mergeEvaluated(S,t.Name),b}function w(){var $;const b={},S=N(d);let T=!0;for(let q=0;q<_.length;q++){let W=_[q];if(W?.$ref&&!(0,s.schemaHasRulesButRef)(W,p.self.RULES)){const G=W.$ref;if(W=r.resolveRef.call(p.self,p.schemaEnv.root,p.baseId,G),W instanceof r.SchemaEnv&&(W=W.schema),W===void 0)throw new n.default(p.opts.uriResolver,p.baseId,G)}const K=($=W?.properties)===null||$===void 0?void 0:$[m];if(typeof K!="object")throw new Error(`discriminator: oneOf subschemas (or referenced schemas) must have "properties/${m}"`);T=T&&(S||N(W)),j(K,q)}if(!T)throw new Error(`discriminator: "${m}" must be required`);return b;function N({required:q}){return Array.isArray(q)&&q.includes(m)}function j(q,W){if(q.const)F(q.const,W);else if(q.enum)for(const K of q.enum)F(K,W);else throw new Error(`discriminator: "properties/${m}" must have "const" or "enum"`)}function F(q,W){if(typeof q!="string"||q in b)throw new Error(`discriminator: "${m}" values must be unique strings`);b[q]=W}}}};return Ns.default=i,Ns}const fp={$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 Mu;function ju(){return Mu||(Mu=1,(function(t,e){Object.defineProperty(e,"__esModule",{value:!0}),e.MissingRefError=e.ValidationError=e.CodeGen=e.Name=e.nil=e.stringify=e.str=e._=e.KeywordCxt=e.Ajv=void 0;const r=Cf(),n=lp(),s=hp(),o=fp,i=["/properties"],a="http://json-schema.org/draft-07/schema";class c extends r.default{_addVocabularies(){super._addVocabularies(),n.default.forEach(m=>this.addVocabulary(m)),this.opts.discriminator&&this.addKeyword(s.default)}_addDefaultMetaSchema(){if(super._addDefaultMetaSchema(),!this.opts.meta)return;const m=this.opts.$data?this.$dataMetaSchema(o,i):o;this.addMetaSchema(m,a,!1),this.refs["http://json-schema.org/schema"]=a}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(a)?a:void 0)}}e.Ajv=c,t.exports=e=c,t.exports.Ajv=c,Object.defineProperty(e,"__esModule",{value:!0}),e.default=c;var u=Gn();Object.defineProperty(e,"KeywordCxt",{enumerable:!0,get:function(){return u.KeywordCxt}});var l=fe();Object.defineProperty(e,"_",{enumerable:!0,get:function(){return l._}}),Object.defineProperty(e,"str",{enumerable:!0,get:function(){return l.str}}),Object.defineProperty(e,"stringify",{enumerable:!0,get:function(){return l.stringify}}),Object.defineProperty(e,"nil",{enumerable:!0,get:function(){return l.nil}}),Object.defineProperty(e,"Name",{enumerable:!0,get:function(){return l.Name}}),Object.defineProperty(e,"CodeGen",{enumerable:!0,get:function(){return l.CodeGen}});var d=Ko();Object.defineProperty(e,"ValidationError",{enumerable:!0,get:function(){return d.default}});var p=Xn();Object.defineProperty(e,"MissingRefError",{enumerable:!0,get:function(){return p.default}})})(Hn,Hn.exports)),Hn.exports}var qu=ju();const zu=kr(qu),Uu=Object.freeze({status:"aborted"});function A(t,e,r){function n(a,c){var u;Object.defineProperty(a,"_zod",{value:a._zod??{},enumerable:!1}),(u=a._zod).traits??(u.traits=new Set),a._zod.traits.add(t),e(a,c);for(const l in i.prototype)l in a||Object.defineProperty(a,l,{value:i.prototype[l].bind(a)});a._zod.constr=i,a._zod.def=c}const s=r?.Parent??Object;class o extends s{}Object.defineProperty(o,"name",{value:t});function i(a){var c;const u=r?.Parent?new o:this;n(u,a),(c=u._zod).deferred??(c.deferred=[]);for(const l of u._zod.deferred)l();return u}return Object.defineProperty(i,"init",{value:n}),Object.defineProperty(i,Symbol.hasInstance,{value:a=>r?.Parent&&a instanceof r.Parent?!0:a?._zod?.traits?.has(t)}),Object.defineProperty(i,"name",{value:t}),i}class Yr extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}const Lu={};function Gt(t){return Lu}function Zu(t){const e=Object.values(t).filter(n=>typeof n=="number");return Object.entries(t).filter(([n,s])=>e.indexOf(+n)===-1).map(([n,s])=>s)}function pp(t,e){return typeof e=="bigint"?e.toString():e}function ti(t){return{get value(){{const e=t();return Object.defineProperty(this,"value",{value:e}),e}}}}function ri(t){return t==null}function ni(t){const e=t.startsWith("^")?1:0,r=t.endsWith("$")?t.length-1:t.length;return t.slice(e,r)}function mp(t,e){const r=(t.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,s=r>n?r:n,o=Number.parseInt(t.toFixed(s).replace(".","")),i=Number.parseInt(e.toFixed(s).replace(".",""));return o%i/10**s}function Oe(t,e,r){Object.defineProperty(t,e,{get(){{const n=r();return t[e]=n,n}},set(n){Object.defineProperty(t,e,{value:n})},configurable:!0})}function Qr(t,e,r){Object.defineProperty(t,e,{value:r,writable:!0,enumerable:!0,configurable:!0})}function Xr(t){return JSON.stringify(t)}const Du=Error.captureStackTrace?Error.captureStackTrace:(...t)=>{};function As(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}const _p=ti(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{const t=Function;return new t(""),!0}catch{return!1}});function Ms(t){if(As(t)===!1)return!1;const e=t.constructor;if(e===void 0)return!0;const r=e.prototype;return!(As(r)===!1||Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)}const gp=new Set(["string","number","symbol"]);function en(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Yt(t,e,r){const n=new t._zod.constr(e??t._zod.def);return(!e||r?.parent)&&(n._zod.parent=t),n}function Y(t){const e=t;if(!e)return{};if(typeof e=="string")return{error:()=>e};if(e?.message!==void 0){if(e?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");e.error=e.message}return delete e.message,typeof e.error=="string"?{...e,error:()=>e.error}:e}function vp(t){return Object.keys(t).filter(e=>t[e]._zod.optin==="optional"&&t[e]._zod.optout==="optional")}const yp={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function wp(t,e){const r={},n=t._zod.def;for(const s in e){if(!(s in n.shape))throw new Error(`Unrecognized key: "${s}"`);e[s]&&(r[s]=n.shape[s])}return Yt(t,{...t._zod.def,shape:r,checks:[]})}function bp(t,e){const r={...t._zod.def.shape},n=t._zod.def;for(const s in e){if(!(s in n.shape))throw new Error(`Unrecognized key: "${s}"`);e[s]&&delete r[s]}return Yt(t,{...t._zod.def,shape:r,checks:[]})}function $p(t,e){if(!Ms(e))throw new Error("Invalid input to extend: expected a plain object");const r={...t._zod.def,get shape(){const n={...t._zod.def.shape,...e};return Qr(this,"shape",n),n},checks:[]};return Yt(t,r)}function Sp(t,e){return Yt(t,{...t._zod.def,get shape(){const r={...t._zod.def.shape,...e._zod.def.shape};return Qr(this,"shape",r),r},catchall:e._zod.def.catchall,checks:[]})}function kp(t,e,r){const n=e._zod.def.shape,s={...n};if(r)for(const o in r){if(!(o in n))throw new Error(`Unrecognized key: "${o}"`);r[o]&&(s[o]=t?new t({type:"optional",innerType:n[o]}):n[o])}else for(const o in n)s[o]=t?new t({type:"optional",innerType:n[o]}):n[o];return Yt(e,{...e._zod.def,shape:s,checks:[]})}function Tp(t,e,r){const n=e._zod.def.shape,s={...n};if(r)for(const o in r){if(!(o in s))throw new Error(`Unrecognized key: "${o}"`);r[o]&&(s[o]=new t({type:"nonoptional",innerType:n[o]}))}else for(const o in n)s[o]=new t({type:"nonoptional",innerType:n[o]});return Yt(e,{...e._zod.def,shape:s,checks:[]})}function tn(t,e=0){for(let r=e;r<t.issues.length;r++)if(t.issues[r]?.continue!==!0)return!0;return!1}function hr(t,e){return e.map(r=>{var n;return(n=r).path??(n.path=[]),r.path.unshift(t),r})}function js(t){return typeof t=="string"?t:t?.message}function Qt(t,e,r){const n={...t,path:t.path??[]};if(!t.message){const s=js(t.inst?._zod.def?.error?.(t))??js(e?.error?.(t))??js(r.customError?.(t))??js(r.localeError?.(t))??"Invalid input";n.message=s}return delete n.inst,delete n.continue,e?.reportInput||delete n.input,n}function si(t){return Array.isArray(t)?"array":typeof t=="string"?"string":"unknown"}function rn(...t){const[e,r,n]=t;return typeof e=="string"?{message:e,code:"custom",input:r,inst:n}:{...e}}const Vu=(t,e)=>{t.name="$ZodError",Object.defineProperty(t,"_zod",{value:t._zod,enumerable:!1}),Object.defineProperty(t,"issues",{value:e,enumerable:!1}),Object.defineProperty(t,"message",{get(){return JSON.stringify(e,pp,2)},enumerable:!0}),Object.defineProperty(t,"toString",{value:()=>t.message,enumerable:!1})},Hu=A("$ZodError",Vu),qs=A("$ZodError",Vu,{Parent:Error});function Rp(t,e=r=>r.message){const r={},n=[];for(const s of t.issues)s.path.length>0?(r[s.path[0]]=r[s.path[0]]||[],r[s.path[0]].push(e(s))):n.push(e(s));return{formErrors:n,fieldErrors:r}}function Ep(t,e){const r=e||function(o){return o.message},n={_errors:[]},s=o=>{for(const i of o.issues)if(i.code==="invalid_union"&&i.errors.length)i.errors.map(a=>s({issues:a}));else if(i.code==="invalid_key")s({issues:i.issues});else if(i.code==="invalid_element")s({issues:i.issues});else if(i.path.length===0)n._errors.push(r(i));else{let a=n,c=0;for(;c<i.path.length;){const u=i.path[c];c===i.path.length-1?(a[u]=a[u]||{_errors:[]},a[u]._errors.push(r(i))):a[u]=a[u]||{_errors:[]},a=a[u],c++}}};return s(t),n}const Fu=t=>(e,r,n,s)=>{const o=n?Object.assign(n,{async:!1}):{async:!1},i=e._zod.run({value:r,issues:[]},o);if(i instanceof Promise)throw new Yr;if(i.issues.length){const a=new(s?.Err??t)(i.issues.map(c=>Qt(c,o,Gt())));throw Du(a,s?.callee),a}return i.value},Pp=Fu(qs),Wu=t=>async(e,r,n,s)=>{const o=n?Object.assign(n,{async:!0}):{async:!0};let i=e._zod.run({value:r,issues:[]},o);if(i instanceof Promise&&(i=await i),i.issues.length){const a=new(s?.Err??t)(i.issues.map(c=>Qt(c,o,Gt())));throw Du(a,s?.callee),a}return i.value},xp=Wu(qs),Ju=t=>(e,r,n)=>{const s=n?{...n,async:!1}:{async:!1},o=e._zod.run({value:r,issues:[]},s);if(o instanceof Promise)throw new Yr;return o.issues.length?{success:!1,error:new(t??Hu)(o.issues.map(i=>Qt(i,s,Gt())))}:{success:!0,data:o.value}},zs=Ju(qs),Bu=t=>async(e,r,n)=>{const s=n?Object.assign(n,{async:!0}):{async:!0};let o=e._zod.run({value:r,issues:[]},s);return o instanceof Promise&&(o=await o),o.issues.length?{success:!1,error:new t(o.issues.map(i=>Qt(i,s,Gt())))}:{success:!0,data:o.value}},oi=Bu(qs),Ip=/^[cC][^\s-]{8,}$/,Cp=/^[0-9a-z]+$/,Op=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,Np=/^[0-9a-vA-V]{20}$/,Ap=/^[A-Za-z0-9]{27}$/,Mp=/^[a-zA-Z0-9_-]{21}$/,jp=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,qp=/^([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})$/,Ku=t=>t?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${t}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000)$/,zp=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,Up="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function Lp(){return new RegExp(Up,"u")}const Zp=/^(?:(?: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])$/,Dp=/^(([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})$/,Vp=/^((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])$/,Hp=/^(([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])$/,Fp=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Gu=/^[A-Za-z0-9_-]*$/,Wp=/^([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+$/,Jp=/^\+(?:[0-9]){6,14}[0-9]$/,Yu="(?:(?:\\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])))",Bp=new RegExp(`^${Yu}$`);function Qu(t){const e="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof t.precision=="number"?t.precision===-1?`${e}`:t.precision===0?`${e}:[0-5]\\d`:`${e}:[0-5]\\d\\.\\d{${t.precision}}`:`${e}(?::[0-5]\\d(?:\\.\\d+)?)?`}function Kp(t){return new RegExp(`^${Qu(t)}$`)}function Gp(t){const e=Qu({precision:t.precision}),r=["Z"];t.local&&r.push(""),t.offset&&r.push("([+-]\\d{2}:\\d{2})");const n=`${e}(?:${r.join("|")})`;return new RegExp(`^${Yu}T(?:${n})$`)}const Yp=t=>{const e=t?`[\\s\\S]{${t?.minimum??0},${t?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${e}$`)},Qp=/^\d+$/,Xp=/^-?\d+(?:\.\d+)?/i,em=/true|false/i,tm=/null/i,rm=/^[^A-Z]*$/,nm=/^[^a-z]*$/,nt=A("$ZodCheck",(t,e)=>{var r;t._zod??(t._zod={}),t._zod.def=e,(r=t._zod).onattach??(r.onattach=[])}),Xu={number:"number",bigint:"bigint",object:"date"},el=A("$ZodCheckLessThan",(t,e)=>{nt.init(t,e);const r=Xu[typeof e.value];t._zod.onattach.push(n=>{const s=n._zod.bag,o=(e.inclusive?s.maximum:s.exclusiveMaximum)??Number.POSITIVE_INFINITY;e.value<o&&(e.inclusive?s.maximum=e.value:s.exclusiveMaximum=e.value)}),t._zod.check=n=>{(e.inclusive?n.value<=e.value:n.value<e.value)||n.issues.push({origin:r,code:"too_big",maximum:e.value,input:n.value,inclusive:e.inclusive,inst:t,continue:!e.abort})}}),tl=A("$ZodCheckGreaterThan",(t,e)=>{nt.init(t,e);const r=Xu[typeof e.value];t._zod.onattach.push(n=>{const s=n._zod.bag,o=(e.inclusive?s.minimum:s.exclusiveMinimum)??Number.NEGATIVE_INFINITY;e.value>o&&(e.inclusive?s.minimum=e.value:s.exclusiveMinimum=e.value)}),t._zod.check=n=>{(e.inclusive?n.value>=e.value:n.value>e.value)||n.issues.push({origin:r,code:"too_small",minimum:e.value,input:n.value,inclusive:e.inclusive,inst:t,continue:!e.abort})}}),sm=A("$ZodCheckMultipleOf",(t,e)=>{nt.init(t,e),t._zod.onattach.push(r=>{var n;(n=r._zod.bag).multipleOf??(n.multipleOf=e.value)}),t._zod.check=r=>{if(typeof r.value!=typeof e.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof r.value=="bigint"?r.value%e.value===BigInt(0):mp(r.value,e.value)===0)||r.issues.push({origin:typeof r.value,code:"not_multiple_of",divisor:e.value,input:r.value,inst:t,continue:!e.abort})}}),om=A("$ZodCheckNumberFormat",(t,e)=>{nt.init(t,e),e.format=e.format||"float64";const r=e.format?.includes("int"),n=r?"int":"number",[s,o]=yp[e.format];t._zod.onattach.push(i=>{const a=i._zod.bag;a.format=e.format,a.minimum=s,a.maximum=o,r&&(a.pattern=Qp)}),t._zod.check=i=>{const a=i.value;if(r){if(!Number.isInteger(a)){i.issues.push({expected:n,format:e.format,code:"invalid_type",input:a,inst:t});return}if(!Number.isSafeInteger(a)){a>0?i.issues.push({input:a,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:t,origin:n,continue:!e.abort}):i.issues.push({input:a,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:t,origin:n,continue:!e.abort});return}}a<s&&i.issues.push({origin:"number",input:a,code:"too_small",minimum:s,inclusive:!0,inst:t,continue:!e.abort}),a>o&&i.issues.push({origin:"number",input:a,code:"too_big",maximum:o,inst:t})}}),im=A("$ZodCheckMaxLength",(t,e)=>{var r;nt.init(t,e),(r=t._zod.def).when??(r.when=n=>{const s=n.value;return!ri(s)&&s.length!==void 0}),t._zod.onattach.push(n=>{const s=n._zod.bag.maximum??Number.POSITIVE_INFINITY;e.maximum<s&&(n._zod.bag.maximum=e.maximum)}),t._zod.check=n=>{const s=n.value;if(s.length<=e.maximum)return;const i=si(s);n.issues.push({origin:i,code:"too_big",maximum:e.maximum,inclusive:!0,input:s,inst:t,continue:!e.abort})}}),am=A("$ZodCheckMinLength",(t,e)=>{var r;nt.init(t,e),(r=t._zod.def).when??(r.when=n=>{const s=n.value;return!ri(s)&&s.length!==void 0}),t._zod.onattach.push(n=>{const s=n._zod.bag.minimum??Number.NEGATIVE_INFINITY;e.minimum>s&&(n._zod.bag.minimum=e.minimum)}),t._zod.check=n=>{const s=n.value;if(s.length>=e.minimum)return;const i=si(s);n.issues.push({origin:i,code:"too_small",minimum:e.minimum,inclusive:!0,input:s,inst:t,continue:!e.abort})}}),cm=A("$ZodCheckLengthEquals",(t,e)=>{var r;nt.init(t,e),(r=t._zod.def).when??(r.when=n=>{const s=n.value;return!ri(s)&&s.length!==void 0}),t._zod.onattach.push(n=>{const s=n._zod.bag;s.minimum=e.length,s.maximum=e.length,s.length=e.length}),t._zod.check=n=>{const s=n.value,o=s.length;if(o===e.length)return;const i=si(s),a=o>e.length;n.issues.push({origin:i,...a?{code:"too_big",maximum:e.length}:{code:"too_small",minimum:e.length},inclusive:!0,exact:!0,input:n.value,inst:t,continue:!e.abort})}}),Us=A("$ZodCheckStringFormat",(t,e)=>{var r,n;nt.init(t,e),t._zod.onattach.push(s=>{const o=s._zod.bag;o.format=e.format,e.pattern&&(o.patterns??(o.patterns=new Set),o.patterns.add(e.pattern))}),e.pattern?(r=t._zod).check??(r.check=s=>{e.pattern.lastIndex=0,!e.pattern.test(s.value)&&s.issues.push({origin:"string",code:"invalid_format",format:e.format,input:s.value,...e.pattern?{pattern:e.pattern.toString()}:{},inst:t,continue:!e.abort})}):(n=t._zod).check??(n.check=()=>{})}),um=A("$ZodCheckRegex",(t,e)=>{Us.init(t,e),t._zod.check=r=>{e.pattern.lastIndex=0,!e.pattern.test(r.value)&&r.issues.push({origin:"string",code:"invalid_format",format:"regex",input:r.value,pattern:e.pattern.toString(),inst:t,continue:!e.abort})}}),lm=A("$ZodCheckLowerCase",(t,e)=>{e.pattern??(e.pattern=rm),Us.init(t,e)}),dm=A("$ZodCheckUpperCase",(t,e)=>{e.pattern??(e.pattern=nm),Us.init(t,e)}),hm=A("$ZodCheckIncludes",(t,e)=>{nt.init(t,e);const r=en(e.includes),n=new RegExp(typeof e.position=="number"?`^.{${e.position}}${r}`:r);e.pattern=n,t._zod.onattach.push(s=>{const o=s._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(n)}),t._zod.check=s=>{s.value.includes(e.includes,e.position)||s.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:e.includes,input:s.value,inst:t,continue:!e.abort})}}),fm=A("$ZodCheckStartsWith",(t,e)=>{nt.init(t,e);const r=new RegExp(`^${en(e.prefix)}.*`);e.pattern??(e.pattern=r),t._zod.onattach.push(n=>{const s=n._zod.bag;s.patterns??(s.patterns=new Set),s.patterns.add(r)}),t._zod.check=n=>{n.value.startsWith(e.prefix)||n.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:e.prefix,input:n.value,inst:t,continue:!e.abort})}}),pm=A("$ZodCheckEndsWith",(t,e)=>{nt.init(t,e);const r=new RegExp(`.*${en(e.suffix)}$`);e.pattern??(e.pattern=r),t._zod.onattach.push(n=>{const s=n._zod.bag;s.patterns??(s.patterns=new Set),s.patterns.add(r)}),t._zod.check=n=>{n.value.endsWith(e.suffix)||n.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:e.suffix,input:n.value,inst:t,continue:!e.abort})}}),mm=A("$ZodCheckOverwrite",(t,e)=>{nt.init(t,e),t._zod.check=r=>{r.value=e.tx(r.value)}});class _m{constructor(e=[]){this.content=[],this.indent=0,this&&(this.args=e)}indented(e){this.indent+=1,e(this),this.indent-=1}write(e){if(typeof e=="function"){e(this,{execution:"sync"}),e(this,{execution:"async"});return}const n=e.split(`
|
|
9
|
+
`).filter(i=>i),s=Math.min(...n.map(i=>i.length-i.trimStart().length)),o=n.map(i=>i.slice(s)).map(i=>" ".repeat(this.indent*2)+i);for(const i of o)this.content.push(i)}compile(){const e=Function,r=this?.args,s=[...(this?.content??[""]).map(o=>` ${o}`)];return new e(...r,s.join(`
|
|
10
|
+
`))}}const gm={major:4,minor:0,patch:0},Ie=A("$ZodType",(t,e)=>{var r;t??(t={}),t._zod.def=e,t._zod.bag=t._zod.bag||{},t._zod.version=gm;const n=[...t._zod.def.checks??[]];t._zod.traits.has("$ZodCheck")&&n.unshift(t);for(const s of n)for(const o of s._zod.onattach)o(t);if(n.length===0)(r=t._zod).deferred??(r.deferred=[]),t._zod.deferred?.push(()=>{t._zod.run=t._zod.parse});else{const s=(o,i,a)=>{let c=tn(o),u;for(const l of i){if(l._zod.def.when){if(!l._zod.def.when(o))continue}else if(c)continue;const d=o.issues.length,p=l._zod.check(o);if(p instanceof Promise&&a?.async===!1)throw new Yr;if(u||p instanceof Promise)u=(u??Promise.resolve()).then(async()=>{await p,o.issues.length!==d&&(c||(c=tn(o,d)))});else{if(o.issues.length===d)continue;c||(c=tn(o,d))}}return u?u.then(()=>o):o};t._zod.run=(o,i)=>{const a=t._zod.parse(o,i);if(a instanceof Promise){if(i.async===!1)throw new Yr;return a.then(c=>s(c,n,i))}return s(a,n,i)}}t["~standard"]={validate:s=>{try{const o=zs(t,s);return o.success?{value:o.data}:{issues:o.error?.issues}}catch{return oi(t,s).then(i=>i.success?{value:i.data}:{issues:i.error?.issues})}},vendor:"zod",version:1}}),ii=A("$ZodString",(t,e)=>{Ie.init(t,e),t._zod.pattern=[...t?._zod.bag?.patterns??[]].pop()??Yp(t._zod.bag),t._zod.parse=(r,n)=>{if(e.coerce)try{r.value=String(r.value)}catch{}return typeof r.value=="string"||r.issues.push({expected:"string",code:"invalid_type",input:r.value,inst:t}),r}}),Ne=A("$ZodStringFormat",(t,e)=>{Us.init(t,e),ii.init(t,e)}),vm=A("$ZodGUID",(t,e)=>{e.pattern??(e.pattern=qp),Ne.init(t,e)}),ym=A("$ZodUUID",(t,e)=>{if(e.version){const n={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[e.version];if(n===void 0)throw new Error(`Invalid UUID version: "${e.version}"`);e.pattern??(e.pattern=Ku(n))}else e.pattern??(e.pattern=Ku());Ne.init(t,e)}),wm=A("$ZodEmail",(t,e)=>{e.pattern??(e.pattern=zp),Ne.init(t,e)}),bm=A("$ZodURL",(t,e)=>{Ne.init(t,e),t._zod.check=r=>{try{const n=r.value,s=new URL(n),o=s.href;e.hostname&&(e.hostname.lastIndex=0,e.hostname.test(s.hostname)||r.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:Wp.source,input:r.value,inst:t,continue:!e.abort})),e.protocol&&(e.protocol.lastIndex=0,e.protocol.test(s.protocol.endsWith(":")?s.protocol.slice(0,-1):s.protocol)||r.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:e.protocol.source,input:r.value,inst:t,continue:!e.abort})),!n.endsWith("/")&&o.endsWith("/")?r.value=o.slice(0,-1):r.value=o;return}catch{r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:t,continue:!e.abort})}}}),$m=A("$ZodEmoji",(t,e)=>{e.pattern??(e.pattern=Lp()),Ne.init(t,e)}),Sm=A("$ZodNanoID",(t,e)=>{e.pattern??(e.pattern=Mp),Ne.init(t,e)}),km=A("$ZodCUID",(t,e)=>{e.pattern??(e.pattern=Ip),Ne.init(t,e)}),Tm=A("$ZodCUID2",(t,e)=>{e.pattern??(e.pattern=Cp),Ne.init(t,e)}),Rm=A("$ZodULID",(t,e)=>{e.pattern??(e.pattern=Op),Ne.init(t,e)}),Em=A("$ZodXID",(t,e)=>{e.pattern??(e.pattern=Np),Ne.init(t,e)}),Pm=A("$ZodKSUID",(t,e)=>{e.pattern??(e.pattern=Ap),Ne.init(t,e)}),xm=A("$ZodISODateTime",(t,e)=>{e.pattern??(e.pattern=Gp(e)),Ne.init(t,e)}),Im=A("$ZodISODate",(t,e)=>{e.pattern??(e.pattern=Bp),Ne.init(t,e)}),Cm=A("$ZodISOTime",(t,e)=>{e.pattern??(e.pattern=Kp(e)),Ne.init(t,e)}),Om=A("$ZodISODuration",(t,e)=>{e.pattern??(e.pattern=jp),Ne.init(t,e)}),Nm=A("$ZodIPv4",(t,e)=>{e.pattern??(e.pattern=Zp),Ne.init(t,e),t._zod.onattach.push(r=>{const n=r._zod.bag;n.format="ipv4"})}),Am=A("$ZodIPv6",(t,e)=>{e.pattern??(e.pattern=Dp),Ne.init(t,e),t._zod.onattach.push(r=>{const n=r._zod.bag;n.format="ipv6"}),t._zod.check=r=>{try{new URL(`http://[${r.value}]`)}catch{r.issues.push({code:"invalid_format",format:"ipv6",input:r.value,inst:t,continue:!e.abort})}}}),Mm=A("$ZodCIDRv4",(t,e)=>{e.pattern??(e.pattern=Vp),Ne.init(t,e)}),jm=A("$ZodCIDRv6",(t,e)=>{e.pattern??(e.pattern=Hp),Ne.init(t,e),t._zod.check=r=>{const[n,s]=r.value.split("/");try{if(!s)throw new Error;const o=Number(s);if(`${o}`!==s)throw new Error;if(o<0||o>128)throw new Error;new URL(`http://[${n}]`)}catch{r.issues.push({code:"invalid_format",format:"cidrv6",input:r.value,inst:t,continue:!e.abort})}}});function rl(t){if(t==="")return!0;if(t.length%4!==0)return!1;try{return atob(t),!0}catch{return!1}}const qm=A("$ZodBase64",(t,e)=>{e.pattern??(e.pattern=Fp),Ne.init(t,e),t._zod.onattach.push(r=>{r._zod.bag.contentEncoding="base64"}),t._zod.check=r=>{rl(r.value)||r.issues.push({code:"invalid_format",format:"base64",input:r.value,inst:t,continue:!e.abort})}});function zm(t){if(!Gu.test(t))return!1;const e=t.replace(/[-_]/g,n=>n==="-"?"+":"/"),r=e.padEnd(Math.ceil(e.length/4)*4,"=");return rl(r)}const Um=A("$ZodBase64URL",(t,e)=>{e.pattern??(e.pattern=Gu),Ne.init(t,e),t._zod.onattach.push(r=>{r._zod.bag.contentEncoding="base64url"}),t._zod.check=r=>{zm(r.value)||r.issues.push({code:"invalid_format",format:"base64url",input:r.value,inst:t,continue:!e.abort})}}),Lm=A("$ZodE164",(t,e)=>{e.pattern??(e.pattern=Jp),Ne.init(t,e)});function Zm(t,e=null){try{const r=t.split(".");if(r.length!==3)return!1;const[n]=r;if(!n)return!1;const s=JSON.parse(atob(n));return!("typ"in s&&s?.typ!=="JWT"||!s.alg||e&&(!("alg"in s)||s.alg!==e))}catch{return!1}}const Dm=A("$ZodJWT",(t,e)=>{Ne.init(t,e),t._zod.check=r=>{Zm(r.value,e.alg)||r.issues.push({code:"invalid_format",format:"jwt",input:r.value,inst:t,continue:!e.abort})}}),nl=A("$ZodNumber",(t,e)=>{Ie.init(t,e),t._zod.pattern=t._zod.bag.pattern??Xp,t._zod.parse=(r,n)=>{if(e.coerce)try{r.value=Number(r.value)}catch{}const s=r.value;if(typeof s=="number"&&!Number.isNaN(s)&&Number.isFinite(s))return r;const o=typeof s=="number"?Number.isNaN(s)?"NaN":Number.isFinite(s)?void 0:"Infinity":void 0;return r.issues.push({expected:"number",code:"invalid_type",input:s,inst:t,...o?{received:o}:{}}),r}}),Vm=A("$ZodNumber",(t,e)=>{om.init(t,e),nl.init(t,e)}),Hm=A("$ZodBoolean",(t,e)=>{Ie.init(t,e),t._zod.pattern=em,t._zod.parse=(r,n)=>{if(e.coerce)try{r.value=!!r.value}catch{}const s=r.value;return typeof s=="boolean"||r.issues.push({expected:"boolean",code:"invalid_type",input:s,inst:t}),r}}),Fm=A("$ZodNull",(t,e)=>{Ie.init(t,e),t._zod.pattern=tm,t._zod.values=new Set([null]),t._zod.parse=(r,n)=>{const s=r.value;return s===null||r.issues.push({expected:"null",code:"invalid_type",input:s,inst:t}),r}}),Wm=A("$ZodAny",(t,e)=>{Ie.init(t,e),t._zod.parse=r=>r}),Jm=A("$ZodUnknown",(t,e)=>{Ie.init(t,e),t._zod.parse=r=>r}),Bm=A("$ZodNever",(t,e)=>{Ie.init(t,e),t._zod.parse=(r,n)=>(r.issues.push({expected:"never",code:"invalid_type",input:r.value,inst:t}),r)});function sl(t,e,r){t.issues.length&&e.issues.push(...hr(r,t.issues)),e.value[r]=t.value}const Km=A("$ZodArray",(t,e)=>{Ie.init(t,e),t._zod.parse=(r,n)=>{const s=r.value;if(!Array.isArray(s))return r.issues.push({expected:"array",code:"invalid_type",input:s,inst:t}),r;r.value=Array(s.length);const o=[];for(let i=0;i<s.length;i++){const a=s[i],c=e.element._zod.run({value:a,issues:[]},n);c instanceof Promise?o.push(c.then(u=>sl(u,r,i))):sl(c,r,i)}return o.length?Promise.all(o).then(()=>r):r}});function Ls(t,e,r){t.issues.length&&e.issues.push(...hr(r,t.issues)),e.value[r]=t.value}function ol(t,e,r,n){t.issues.length?n[r]===void 0?r in n?e.value[r]=void 0:e.value[r]=t.value:e.issues.push(...hr(r,t.issues)):t.value===void 0?r in n&&(e.value[r]=void 0):e.value[r]=t.value}const il=A("$ZodObject",(t,e)=>{Ie.init(t,e);const r=ti(()=>{const d=Object.keys(e.shape);for(const _ of d)if(!(e.shape[_]instanceof Ie))throw new Error(`Invalid element at key "${_}": expected a Zod schema`);const p=vp(e.shape);return{shape:e.shape,keys:d,keySet:new Set(d),numKeys:d.length,optionalKeys:new Set(p)}});Oe(t._zod,"propValues",()=>{const d=e.shape,p={};for(const _ in d){const m=d[_]._zod;if(m.values){p[_]??(p[_]=new Set);for(const g of m.values)p[_].add(g)}}return p});const n=d=>{const p=new _m(["shape","payload","ctx"]),_=r.value,m=h=>{const w=Xr(h);return`shape[${w}]._zod.run({ value: input[${w}], issues: [] }, ctx)`};p.write("const input = payload.value;");const g=Object.create(null);let f=0;for(const h of _.keys)g[h]=`key_${f++}`;p.write("const newResult = {}");for(const h of _.keys)if(_.optionalKeys.has(h)){const w=g[h];p.write(`const ${w} = ${m(h)};`);const $=Xr(h);p.write(`
|
|
11
|
+
if (${w}.issues.length) {
|
|
12
|
+
if (input[${$}] === undefined) {
|
|
13
|
+
if (${$} in input) {
|
|
14
|
+
newResult[${$}] = undefined;
|
|
15
15
|
}
|
|
16
16
|
} else {
|
|
17
17
|
payload.issues = payload.issues.concat(
|
|
18
|
-
${
|
|
18
|
+
${w}.issues.map((iss) => ({
|
|
19
19
|
...iss,
|
|
20
|
-
path: iss.path ? [${
|
|
20
|
+
path: iss.path ? [${$}, ...iss.path] : [${$}],
|
|
21
21
|
}))
|
|
22
22
|
);
|
|
23
23
|
}
|
|
24
|
-
} else if (${
|
|
25
|
-
if (${
|
|
24
|
+
} else if (${w}.value === undefined) {
|
|
25
|
+
if (${$} in input) newResult[${$}] = undefined;
|
|
26
26
|
} else {
|
|
27
|
-
newResult[${
|
|
27
|
+
newResult[${$}] = ${w}.value;
|
|
28
28
|
}
|
|
29
|
-
`)}else{const
|
|
30
|
-
if (${
|
|
29
|
+
`)}else{const w=g[h];p.write(`const ${w} = ${m(h)};`),p.write(`
|
|
30
|
+
if (${w}.issues.length) payload.issues = payload.issues.concat(${w}.issues.map(iss => ({
|
|
31
31
|
...iss,
|
|
32
|
-
path: iss.path ? [${
|
|
33
|
-
})));`),g.write(`newResult[${qr(f)}] = ${m}.value`)}g.write("payload.value = newResult;"),g.write("return payload;");const _=g.compile();return(f,m)=>_(d,f,m)};let s;const a=hs,i=!Ec.jitless,c=i&&df.value,l=e.catchall;let u;t._zod.parse=(d,g)=>{u??(u=r.value);const v=d.value;if(!a(v))return d.issues.push({expected:"object",code:"invalid_type",input:v,inst:t}),d;const p=[];if(i&&c&&g?.async===!1&&g.jitless!==!0)s||(s=n(e.shape)),d=s(d,g);else{d.value={};const m=u.shape;for(const b of u.keys){const y=m[b],k=y._zod.run({value:v[b],issues:[]},g),S=y._zod.optin==="optional"&&y._zod.optout==="optional";k instanceof Promise?p.push(k.then(I=>S?Hc(I,d,b,v):gs(I,d,b))):S?Hc(k,d,b,v):gs(k,d,b)}}if(!l)return p.length?Promise.all(p).then(()=>d):d;const w=[],h=u.keySet,_=l._zod,f=_.def.type;for(const m of Object.keys(v)){if(h.has(m))continue;if(f==="never"){w.push(m);continue}const b=_.run({value:v[m],issues:[]},g);b instanceof Promise?p.push(b.then(y=>gs(y,d,m))):gs(b,d,m)}return w.length&&d.issues.push({code:"unrecognized_keys",keys:w,input:v,inst:t}),p.length?Promise.all(p).then(()=>d):d}});function Jc(t,e,r,n){for(const s of t)if(s.issues.length===0)return e.value=s.value,e;return e.issues.push({code:"invalid_union",input:e.value,inst:r,errors:t.map(s=>s.issues.map(a=>Vt(a,n,Ut())))}),e}const Kc=A("$ZodUnion",(t,e)=>{ke.init(t,e),Te(t._zod,"optin",()=>e.options.some(r=>r._zod.optin==="optional")?"optional":void 0),Te(t._zod,"optout",()=>e.options.some(r=>r._zod.optout==="optional")?"optional":void 0),Te(t._zod,"values",()=>{if(e.options.every(r=>r._zod.values))return new Set(e.options.flatMap(r=>Array.from(r._zod.values)))}),Te(t._zod,"pattern",()=>{if(e.options.every(r=>r._zod.pattern)){const r=e.options.map(n=>n._zod.pattern);return new RegExp(`^(${r.map(n=>ka(n.source)).join("|")})$`)}}),t._zod.parse=(r,n)=>{let s=!1;const a=[];for(const i of e.options){const o=i._zod.run({value:r.value,issues:[]},n);if(o instanceof Promise)a.push(o),s=!0;else{if(o.issues.length===0)return o;a.push(o)}}return s?Promise.all(a).then(i=>Jc(i,r,t,n)):Jc(a,r,t,n)}}),Hh=A("$ZodDiscriminatedUnion",(t,e)=>{Kc.init(t,e);const r=t._zod.parse;Te(t._zod,"propValues",()=>{const s={};for(const a of e.options){const i=a._zod.propValues;if(!i||Object.keys(i).length===0)throw new Error(`Invalid discriminated union option at index "${e.options.indexOf(a)}"`);for(const[o,c]of Object.entries(i)){s[o]||(s[o]=new Set);for(const l of c)s[o].add(l)}}return s});const n=wa(()=>{const s=e.options,a=new Map;for(const i of s){const o=i._zod.propValues[e.discriminator];if(!o||o.size===0)throw new Error(`Invalid discriminated union option at index "${e.options.indexOf(i)}"`);for(const c of o){if(a.has(c))throw new Error(`Duplicate discriminator value "${String(c)}"`);a.set(c,i)}}return a});t._zod.parse=(s,a)=>{const i=s.value;if(!hs(i))return s.issues.push({code:"invalid_type",expected:"object",input:i,inst:t}),s;const o=n.value.get(i?.[e.discriminator]);return o?o._zod.run(s,a):e.unionFallback?r(s,a):(s.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",input:i,path:[e.discriminator],inst:t}),s)}}),Wh=A("$ZodIntersection",(t,e)=>{ke.init(t,e),t._zod.parse=(r,n)=>{const s=r.value,a=e.left._zod.run({value:s,issues:[]},n),i=e.right._zod.run({value:s,issues:[]},n);return a instanceof Promise||i instanceof Promise?Promise.all([a,i]).then(([c,l])=>Bc(r,c,l)):Bc(r,a,i)}});function Ra(t,e){if(t===e)return{valid:!0,data:t};if(t instanceof Date&&e instanceof Date&&+t==+e)return{valid:!0,data:t};if(ps(t)&&ps(e)){const r=Object.keys(e),n=Object.keys(t).filter(a=>r.indexOf(a)!==-1),s={...t,...e};for(const a of n){const i=Ra(t[a],e[a]);if(!i.valid)return{valid:!1,mergeErrorPath:[a,...i.mergeErrorPath]};s[a]=i.data}return{valid:!0,data:s}}if(Array.isArray(t)&&Array.isArray(e)){if(t.length!==e.length)return{valid:!1,mergeErrorPath:[]};const r=[];for(let n=0;n<t.length;n++){const s=t[n],a=e[n],i=Ra(s,a);if(!i.valid)return{valid:!1,mergeErrorPath:[n,...i.mergeErrorPath]};r.push(i.data)}return{valid:!0,data:r}}return{valid:!1,mergeErrorPath:[]}}function Bc(t,e,r){if(e.issues.length&&t.issues.push(...e.issues),r.issues.length&&t.issues.push(...r.issues),Lr(t))return t;const n=Ra(e.value,r.value);if(!n.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(n.mergeErrorPath)}`);return t.value=n.data,t}const Jh=A("$ZodRecord",(t,e)=>{ke.init(t,e),t._zod.parse=(r,n)=>{const s=r.value;if(!ps(s))return r.issues.push({expected:"record",code:"invalid_type",input:s,inst:t}),r;const a=[];if(e.keyType._zod.values){const i=e.keyType._zod.values;r.value={};for(const c of i)if(typeof c=="string"||typeof c=="number"||typeof c=="symbol"){const l=e.valueType._zod.run({value:s[c],issues:[]},n);l instanceof Promise?a.push(l.then(u=>{u.issues.length&&r.issues.push(...tr(c,u.issues)),r.value[c]=u.value})):(l.issues.length&&r.issues.push(...tr(c,l.issues)),r.value[c]=l.value)}let o;for(const c in s)i.has(c)||(o=o??[],o.push(c));o&&o.length>0&&r.issues.push({code:"unrecognized_keys",input:s,inst:t,keys:o})}else{r.value={};for(const i of Reflect.ownKeys(s)){if(i==="__proto__")continue;const o=e.keyType._zod.run({value:i,issues:[]},n);if(o instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(o.issues.length){r.issues.push({origin:"record",code:"invalid_key",issues:o.issues.map(l=>Vt(l,n,Ut())),input:i,path:[i],inst:t}),r.value[o.value]=o.value;continue}const c=e.valueType._zod.run({value:s[i],issues:[]},n);c instanceof Promise?a.push(c.then(l=>{l.issues.length&&r.issues.push(...tr(i,l.issues)),r.value[o.value]=l.value})):(c.issues.length&&r.issues.push(...tr(i,c.issues)),r.value[o.value]=c.value)}}return a.length?Promise.all(a).then(()=>r):r}}),Kh=A("$ZodEnum",(t,e)=>{ke.init(t,e);const r=Rc(e.entries);t._zod.values=new Set(r),t._zod.pattern=new RegExp(`^(${r.filter(n=>ff.has(typeof n)).map(n=>typeof n=="string"?Zr(n):n.toString()).join("|")})$`),t._zod.parse=(n,s)=>{const a=n.value;return t._zod.values.has(a)||n.issues.push({code:"invalid_value",values:r,input:a,inst:t}),n}}),Bh=A("$ZodLiteral",(t,e)=>{ke.init(t,e),t._zod.values=new Set(e.values),t._zod.pattern=new RegExp(`^(${e.values.map(r=>typeof r=="string"?Zr(r):r?r.toString():String(r)).join("|")})$`),t._zod.parse=(r,n)=>{const s=r.value;return t._zod.values.has(s)||r.issues.push({code:"invalid_value",values:e.values,input:s,inst:t}),r}}),Gh=A("$ZodTransform",(t,e)=>{ke.init(t,e),t._zod.parse=(r,n)=>{const s=e.transform(r.value,r);if(n.async)return(s instanceof Promise?s:Promise.resolve(s)).then(i=>(r.value=i,r));if(s instanceof Promise)throw new zr;return r.value=s,r}}),Yh=A("$ZodOptional",(t,e)=>{ke.init(t,e),t._zod.optin="optional",t._zod.optout="optional",Te(t._zod,"values",()=>e.innerType._zod.values?new Set([...e.innerType._zod.values,void 0]):void 0),Te(t._zod,"pattern",()=>{const r=e.innerType._zod.pattern;return r?new RegExp(`^(${ka(r.source)})?$`):void 0}),t._zod.parse=(r,n)=>e.innerType._zod.optin==="optional"?e.innerType._zod.run(r,n):r.value===void 0?r:e.innerType._zod.run(r,n)}),Qh=A("$ZodNullable",(t,e)=>{ke.init(t,e),Te(t._zod,"optin",()=>e.innerType._zod.optin),Te(t._zod,"optout",()=>e.innerType._zod.optout),Te(t._zod,"pattern",()=>{const r=e.innerType._zod.pattern;return r?new RegExp(`^(${ka(r.source)}|null)$`):void 0}),Te(t._zod,"values",()=>e.innerType._zod.values?new Set([...e.innerType._zod.values,null]):void 0),t._zod.parse=(r,n)=>r.value===null?r:e.innerType._zod.run(r,n)}),Xh=A("$ZodDefault",(t,e)=>{ke.init(t,e),t._zod.optin="optional",Te(t._zod,"values",()=>e.innerType._zod.values),t._zod.parse=(r,n)=>{if(r.value===void 0)return r.value=e.defaultValue,r;const s=e.innerType._zod.run(r,n);return s instanceof Promise?s.then(a=>Gc(a,e)):Gc(s,e)}});function Gc(t,e){return t.value===void 0&&(t.value=e.defaultValue),t}const ep=A("$ZodPrefault",(t,e)=>{ke.init(t,e),t._zod.optin="optional",Te(t._zod,"values",()=>e.innerType._zod.values),t._zod.parse=(r,n)=>(r.value===void 0&&(r.value=e.defaultValue),e.innerType._zod.run(r,n))}),tp=A("$ZodNonOptional",(t,e)=>{ke.init(t,e),Te(t._zod,"values",()=>{const r=e.innerType._zod.values;return r?new Set([...r].filter(n=>n!==void 0)):void 0}),t._zod.parse=(r,n)=>{const s=e.innerType._zod.run(r,n);return s instanceof Promise?s.then(a=>Yc(a,t)):Yc(s,t)}});function Yc(t,e){return!t.issues.length&&t.value===void 0&&t.issues.push({code:"invalid_type",expected:"nonoptional",input:t.value,inst:e}),t}const rp=A("$ZodCatch",(t,e)=>{ke.init(t,e),t._zod.optin="optional",Te(t._zod,"optout",()=>e.innerType._zod.optout),Te(t._zod,"values",()=>e.innerType._zod.values),t._zod.parse=(r,n)=>{const s=e.innerType._zod.run(r,n);return s instanceof Promise?s.then(a=>(r.value=a.value,a.issues.length&&(r.value=e.catchValue({...r,error:{issues:a.issues.map(i=>Vt(i,n,Ut()))},input:r.value}),r.issues=[]),r)):(r.value=s.value,s.issues.length&&(r.value=e.catchValue({...r,error:{issues:s.issues.map(a=>Vt(a,n,Ut()))},input:r.value}),r.issues=[]),r)}}),np=A("$ZodPipe",(t,e)=>{ke.init(t,e),Te(t._zod,"values",()=>e.in._zod.values),Te(t._zod,"optin",()=>e.in._zod.optin),Te(t._zod,"optout",()=>e.out._zod.optout),t._zod.parse=(r,n)=>{const s=e.in._zod.run(r,n);return s instanceof Promise?s.then(a=>Qc(a,e,n)):Qc(s,e,n)}});function Qc(t,e,r){return Lr(t)?t:e.out._zod.run({value:t.value,issues:t.issues},r)}const sp=A("$ZodReadonly",(t,e)=>{ke.init(t,e),Te(t._zod,"propValues",()=>e.innerType._zod.propValues),Te(t._zod,"values",()=>e.innerType._zod.values),Te(t._zod,"optin",()=>e.innerType._zod.optin),Te(t._zod,"optout",()=>e.innerType._zod.optout),t._zod.parse=(r,n)=>{const s=e.innerType._zod.run(r,n);return s instanceof Promise?s.then(Xc):Xc(s)}});function Xc(t){return t.value=Object.freeze(t.value),t}const ap=A("$ZodCustom",(t,e)=>{Qe.init(t,e),ke.init(t,e),t._zod.parse=(r,n)=>r,t._zod.check=r=>{const n=r.value,s=e.fn(n);if(s instanceof Promise)return s.then(a=>eu(a,r,n,t));eu(s,r,n,t)}});function eu(t,e,r,n){if(!t){const s={code:"custom",input:r,inst:n,path:[...n._zod.def.path??[]],continue:!n._zod.def.abort};n._zod.def.params&&(s.params=n._zod.def.params),e.issues.push(Ur(s))}}class tu{constructor(){this._map=new Map,this._idmap=new Map}add(e,...r){const n=r[0];if(this._map.set(e,n),n&&typeof n=="object"&&"id"in n){if(this._idmap.has(n.id))throw new Error(`ID ${n.id} already exists in the registry`);this._idmap.set(n.id,e)}return this}clear(){return this._map=new Map,this._idmap=new Map,this}remove(e){const r=this._map.get(e);return r&&typeof r=="object"&&"id"in r&&this._idmap.delete(r.id),this._map.delete(e),this}get(e){const r=e._zod.parent;if(r){const n={...this.get(r)??{}};return delete n.id,{...n,...this._map.get(e)}}return this._map.get(e)}has(e){return this._map.has(e)}}function ip(){return new tu}const Dr=ip();function op(t,e){return new t({type:"string",...Q(e)})}function cp(t,e){return new t({type:"string",format:"email",check:"string_format",abort:!1,...Q(e)})}function ru(t,e){return new t({type:"string",format:"guid",check:"string_format",abort:!1,...Q(e)})}function up(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,...Q(e)})}function lp(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...Q(e)})}function dp(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...Q(e)})}function fp(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...Q(e)})}function nu(t,e){return new t({type:"string",format:"url",check:"string_format",abort:!1,...Q(e)})}function hp(t,e){return new t({type:"string",format:"emoji",check:"string_format",abort:!1,...Q(e)})}function pp(t,e){return new t({type:"string",format:"nanoid",check:"string_format",abort:!1,...Q(e)})}function mp(t,e){return new t({type:"string",format:"cuid",check:"string_format",abort:!1,...Q(e)})}function _p(t,e){return new t({type:"string",format:"cuid2",check:"string_format",abort:!1,...Q(e)})}function vp(t,e){return new t({type:"string",format:"ulid",check:"string_format",abort:!1,...Q(e)})}function gp(t,e){return new t({type:"string",format:"xid",check:"string_format",abort:!1,...Q(e)})}function yp(t,e){return new t({type:"string",format:"ksuid",check:"string_format",abort:!1,...Q(e)})}function wp(t,e){return new t({type:"string",format:"ipv4",check:"string_format",abort:!1,...Q(e)})}function bp(t,e){return new t({type:"string",format:"ipv6",check:"string_format",abort:!1,...Q(e)})}function kp(t,e){return new t({type:"string",format:"cidrv4",check:"string_format",abort:!1,...Q(e)})}function $p(t,e){return new t({type:"string",format:"cidrv6",check:"string_format",abort:!1,...Q(e)})}function Sp(t,e){return new t({type:"string",format:"base64",check:"string_format",abort:!1,...Q(e)})}function Tp(t,e){return new t({type:"string",format:"base64url",check:"string_format",abort:!1,...Q(e)})}function Ep(t,e){return new t({type:"string",format:"e164",check:"string_format",abort:!1,...Q(e)})}function Rp(t,e){return new t({type:"string",format:"jwt",check:"string_format",abort:!1,...Q(e)})}function Pp(t,e){return new t({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...Q(e)})}function xp(t,e){return new t({type:"string",format:"date",check:"string_format",...Q(e)})}function Ip(t,e){return new t({type:"string",format:"time",check:"string_format",precision:null,...Q(e)})}function Cp(t,e){return new t({type:"string",format:"duration",check:"string_format",...Q(e)})}function Op(t,e){return new t({type:"number",checks:[],...Q(e)})}function Np(t,e){return new t({type:"number",coerce:!0,checks:[],...Q(e)})}function Ap(t,e){return new t({type:"number",check:"number_format",abort:!1,format:"safeint",...Q(e)})}function jp(t,e){return new t({type:"boolean",...Q(e)})}function zp(t,e){return new t({type:"null",...Q(e)})}function Mp(t){return new t({type:"any"})}function qp(t){return new t({type:"unknown"})}function Zp(t,e){return new t({type:"never",...Q(e)})}function su(t,e){return new Lc({check:"less_than",...Q(e),value:t,inclusive:!1})}function Pa(t,e){return new Lc({check:"less_than",...Q(e),value:t,inclusive:!0})}function au(t,e){return new Uc({check:"greater_than",...Q(e),value:t,inclusive:!1})}function xa(t,e){return new Uc({check:"greater_than",...Q(e),value:t,inclusive:!0})}function iu(t,e){return new Xf({check:"multiple_of",...Q(e),value:t})}function ou(t,e){return new th({check:"max_length",...Q(e),maximum:t})}function ys(t,e){return new rh({check:"min_length",...Q(e),minimum:t})}function cu(t,e){return new nh({check:"length_equals",...Q(e),length:t})}function Lp(t,e){return new sh({check:"string_format",format:"regex",...Q(e),pattern:t})}function Up(t){return new ah({check:"string_format",format:"lowercase",...Q(t)})}function Dp(t){return new ih({check:"string_format",format:"uppercase",...Q(t)})}function Vp(t,e){return new oh({check:"string_format",format:"includes",...Q(e),includes:t})}function Fp(t,e){return new ch({check:"string_format",format:"starts_with",...Q(e),prefix:t})}function Hp(t,e){return new uh({check:"string_format",format:"ends_with",...Q(e),suffix:t})}function Vr(t){return new lh({check:"overwrite",tx:t})}function Wp(t){return Vr(e=>e.normalize(t))}function Jp(){return Vr(t=>t.trim())}function Kp(){return Vr(t=>t.toLowerCase())}function Bp(){return Vr(t=>t.toUpperCase())}function Gp(t,e,r){return new t({type:"array",element:e,...Q(r)})}function Yp(t,e,r){const n=Q(r);return n.abort??(n.abort=!0),new t({type:"custom",check:"custom",fn:e,...n})}function Qp(t,e,r){return new t({type:"custom",check:"custom",fn:e,...Q(r)})}class uu{constructor(e){this.counter=0,this.metadataRegistry=e?.metadata??Dr,this.target=e?.target??"draft-2020-12",this.unrepresentable=e?.unrepresentable??"throw",this.override=e?.override??(()=>{}),this.io=e?.io??"output",this.seen=new Map}process(e,r={path:[],schemaPath:[]}){var n;const s=e._zod.def,a={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},i=this.seen.get(e);if(i)return i.count++,r.schemaPath.includes(e)&&(i.cycle=r.path),i.schema;const o={schema:{},count:1,cycle:void 0,path:r.path};this.seen.set(e,o);const c=e._zod.toJSONSchema?.();if(c)o.schema=c;else{const d={...r,schemaPath:[...r.schemaPath,e],path:r.path},g=e._zod.parent;if(g)o.ref=g,this.process(g,d),this.seen.get(g).isParent=!0;else{const v=o.schema;switch(s.type){case"string":{const p=v;p.type="string";const{minimum:w,maximum:h,format:_,patterns:f,contentEncoding:m}=e._zod.bag;if(typeof w=="number"&&(p.minLength=w),typeof h=="number"&&(p.maxLength=h),_&&(p.format=a[_]??_,p.format===""&&delete p.format),m&&(p.contentEncoding=m),f&&f.size>0){const b=[...f];b.length===1?p.pattern=b[0].source:b.length>1&&(o.schema.allOf=[...b.map(y=>({...this.target==="draft-7"?{type:"string"}:{},pattern:y.source}))])}break}case"number":{const p=v,{minimum:w,maximum:h,format:_,multipleOf:f,exclusiveMaximum:m,exclusiveMinimum:b}=e._zod.bag;typeof _=="string"&&_.includes("int")?p.type="integer":p.type="number",typeof b=="number"&&(p.exclusiveMinimum=b),typeof w=="number"&&(p.minimum=w,typeof b=="number"&&(b>=w?delete p.minimum:delete p.exclusiveMinimum)),typeof m=="number"&&(p.exclusiveMaximum=m),typeof h=="number"&&(p.maximum=h,typeof m=="number"&&(m<=h?delete p.maximum:delete p.exclusiveMaximum)),typeof f=="number"&&(p.multipleOf=f);break}case"boolean":{const p=v;p.type="boolean";break}case"bigint":{if(this.unrepresentable==="throw")throw new Error("BigInt cannot be represented in JSON Schema");break}case"symbol":{if(this.unrepresentable==="throw")throw new Error("Symbols cannot be represented in JSON Schema");break}case"null":{v.type="null";break}case"any":break;case"unknown":break;case"undefined":{if(this.unrepresentable==="throw")throw new Error("Undefined cannot be represented in JSON Schema");break}case"void":{if(this.unrepresentable==="throw")throw new Error("Void cannot be represented in JSON Schema");break}case"never":{v.not={};break}case"date":{if(this.unrepresentable==="throw")throw new Error("Date cannot be represented in JSON Schema");break}case"array":{const p=v,{minimum:w,maximum:h}=e._zod.bag;typeof w=="number"&&(p.minItems=w),typeof h=="number"&&(p.maxItems=h),p.type="array",p.items=this.process(s.element,{...d,path:[...d.path,"items"]});break}case"object":{const p=v;p.type="object",p.properties={};const w=s.shape;for(const f in w)p.properties[f]=this.process(w[f],{...d,path:[...d.path,"properties",f]});const h=new Set(Object.keys(w)),_=new Set([...h].filter(f=>{const m=s.shape[f]._zod;return this.io==="input"?m.optin===void 0:m.optout===void 0}));_.size>0&&(p.required=Array.from(_)),s.catchall?._zod.def.type==="never"?p.additionalProperties=!1:s.catchall?s.catchall&&(p.additionalProperties=this.process(s.catchall,{...d,path:[...d.path,"additionalProperties"]})):this.io==="output"&&(p.additionalProperties=!1);break}case"union":{const p=v;p.anyOf=s.options.map((w,h)=>this.process(w,{...d,path:[...d.path,"anyOf",h]}));break}case"intersection":{const p=v,w=this.process(s.left,{...d,path:[...d.path,"allOf",0]}),h=this.process(s.right,{...d,path:[...d.path,"allOf",1]}),_=m=>"allOf"in m&&Object.keys(m).length===1,f=[..._(w)?w.allOf:[w],..._(h)?h.allOf:[h]];p.allOf=f;break}case"tuple":{const p=v;p.type="array";const w=s.items.map((f,m)=>this.process(f,{...d,path:[...d.path,"prefixItems",m]}));if(this.target==="draft-2020-12"?p.prefixItems=w:p.items=w,s.rest){const f=this.process(s.rest,{...d,path:[...d.path,"items"]});this.target==="draft-2020-12"?p.items=f:p.additionalItems=f}s.rest&&(p.items=this.process(s.rest,{...d,path:[...d.path,"items"]}));const{minimum:h,maximum:_}=e._zod.bag;typeof h=="number"&&(p.minItems=h),typeof _=="number"&&(p.maxItems=_);break}case"record":{const p=v;p.type="object",p.propertyNames=this.process(s.keyType,{...d,path:[...d.path,"propertyNames"]}),p.additionalProperties=this.process(s.valueType,{...d,path:[...d.path,"additionalProperties"]});break}case"map":{if(this.unrepresentable==="throw")throw new Error("Map cannot be represented in JSON Schema");break}case"set":{if(this.unrepresentable==="throw")throw new Error("Set cannot be represented in JSON Schema");break}case"enum":{const p=v,w=Rc(s.entries);w.every(h=>typeof h=="number")&&(p.type="number"),w.every(h=>typeof h=="string")&&(p.type="string"),p.enum=w;break}case"literal":{const p=v,w=[];for(const h of s.values)if(h===void 0){if(this.unrepresentable==="throw")throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof h=="bigint"){if(this.unrepresentable==="throw")throw new Error("BigInt literals cannot be represented in JSON Schema");w.push(Number(h))}else w.push(h);if(w.length!==0)if(w.length===1){const h=w[0];p.type=h===null?"null":typeof h,p.const=h}else w.every(h=>typeof h=="number")&&(p.type="number"),w.every(h=>typeof h=="string")&&(p.type="string"),w.every(h=>typeof h=="boolean")&&(p.type="string"),w.every(h=>h===null)&&(p.type="null"),p.enum=w;break}case"file":{const p=v,w={type:"string",format:"binary",contentEncoding:"binary"},{minimum:h,maximum:_,mime:f}=e._zod.bag;h!==void 0&&(w.minLength=h),_!==void 0&&(w.maxLength=_),f?f.length===1?(w.contentMediaType=f[0],Object.assign(p,w)):p.anyOf=f.map(m=>({...w,contentMediaType:m})):Object.assign(p,w);break}case"transform":{if(this.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema");break}case"nullable":{const p=this.process(s.innerType,d);v.anyOf=[p,{type:"null"}];break}case"nonoptional":{this.process(s.innerType,d),o.ref=s.innerType;break}case"success":{const p=v;p.type="boolean";break}case"default":{this.process(s.innerType,d),o.ref=s.innerType,v.default=JSON.parse(JSON.stringify(s.defaultValue));break}case"prefault":{this.process(s.innerType,d),o.ref=s.innerType,this.io==="input"&&(v._prefault=JSON.parse(JSON.stringify(s.defaultValue)));break}case"catch":{this.process(s.innerType,d),o.ref=s.innerType;let p;try{p=s.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}v.default=p;break}case"nan":{if(this.unrepresentable==="throw")throw new Error("NaN cannot be represented in JSON Schema");break}case"template_literal":{const p=v,w=e._zod.pattern;if(!w)throw new Error("Pattern not found in template literal");p.type="string",p.pattern=w.source;break}case"pipe":{const p=this.io==="input"?s.in._zod.def.type==="transform"?s.out:s.in:s.out;this.process(p,d),o.ref=p;break}case"readonly":{this.process(s.innerType,d),o.ref=s.innerType,v.readOnly=!0;break}case"promise":{this.process(s.innerType,d),o.ref=s.innerType;break}case"optional":{this.process(s.innerType,d),o.ref=s.innerType;break}case"lazy":{const p=e._zod.innerType;this.process(p,d),o.ref=p;break}case"custom":{if(this.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema");break}}}}const l=this.metadataRegistry.get(e);return l&&Object.assign(o.schema,l),this.io==="input"&&Ae(e)&&(delete o.schema.examples,delete o.schema.default),this.io==="input"&&o.schema._prefault&&((n=o.schema).default??(n.default=o.schema._prefault)),delete o.schema._prefault,this.seen.get(e).schema}emit(e,r){const n={cycles:r?.cycles??"ref",reused:r?.reused??"inline",external:r?.external??void 0},s=this.seen.get(e);if(!s)throw new Error("Unprocessed schema. This is a bug in Zod.");const a=u=>{const d=this.target==="draft-2020-12"?"$defs":"definitions";if(n.external){const w=n.external.registry.get(u[0])?.id,h=n.external.uri??(f=>f);if(w)return{ref:h(w)};const _=u[1].defId??u[1].schema.id??`schema${this.counter++}`;return u[1].defId=_,{defId:_,ref:`${h("__shared")}#/${d}/${_}`}}if(u[1]===s)return{ref:"#"};const v=`#/${d}/`,p=u[1].schema.id??`__schema${this.counter++}`;return{defId:p,ref:v+p}},i=u=>{if(u[1].schema.$ref)return;const d=u[1],{ref:g,defId:v}=a(u);d.def={...d.schema},v&&(d.defId=v);const p=d.schema;for(const w in p)delete p[w];p.$ref=g};if(n.cycles==="throw")for(const u of this.seen.entries()){const d=u[1];if(d.cycle)throw new Error(`Cycle detected: #/${d.cycle?.join("/")}/<root>
|
|
32
|
+
path: iss.path ? [${Xr(h)}, ...iss.path] : [${Xr(h)}]
|
|
33
|
+
})));`),p.write(`newResult[${Xr(h)}] = ${w}.value`)}p.write("payload.value = newResult;"),p.write("return payload;");const v=p.compile();return(h,w)=>v(d,h,w)};let s;const o=As,i=!Lu.jitless,c=i&&_p.value,u=e.catchall;let l;t._zod.parse=(d,p)=>{l??(l=r.value);const _=d.value;if(!o(_))return d.issues.push({expected:"object",code:"invalid_type",input:_,inst:t}),d;const m=[];if(i&&c&&p?.async===!1&&p.jitless!==!0)s||(s=n(e.shape)),d=s(d,p);else{d.value={};const w=l.shape;for(const $ of l.keys){const b=w[$],S=b._zod.run({value:_[$],issues:[]},p),T=b._zod.optin==="optional"&&b._zod.optout==="optional";S instanceof Promise?m.push(S.then(N=>T?ol(N,d,$,_):Ls(N,d,$))):T?ol(S,d,$,_):Ls(S,d,$)}}if(!u)return m.length?Promise.all(m).then(()=>d):d;const g=[],f=l.keySet,v=u._zod,h=v.def.type;for(const w of Object.keys(_)){if(f.has(w))continue;if(h==="never"){g.push(w);continue}const $=v.run({value:_[w],issues:[]},p);$ instanceof Promise?m.push($.then(b=>Ls(b,d,w))):Ls($,d,w)}return g.length&&d.issues.push({code:"unrecognized_keys",keys:g,input:_,inst:t}),m.length?Promise.all(m).then(()=>d):d}});function al(t,e,r,n){for(const s of t)if(s.issues.length===0)return e.value=s.value,e;return e.issues.push({code:"invalid_union",input:e.value,inst:r,errors:t.map(s=>s.issues.map(o=>Qt(o,n,Gt())))}),e}const cl=A("$ZodUnion",(t,e)=>{Ie.init(t,e),Oe(t._zod,"optin",()=>e.options.some(r=>r._zod.optin==="optional")?"optional":void 0),Oe(t._zod,"optout",()=>e.options.some(r=>r._zod.optout==="optional")?"optional":void 0),Oe(t._zod,"values",()=>{if(e.options.every(r=>r._zod.values))return new Set(e.options.flatMap(r=>Array.from(r._zod.values)))}),Oe(t._zod,"pattern",()=>{if(e.options.every(r=>r._zod.pattern)){const r=e.options.map(n=>n._zod.pattern);return new RegExp(`^(${r.map(n=>ni(n.source)).join("|")})$`)}}),t._zod.parse=(r,n)=>{let s=!1;const o=[];for(const i of e.options){const a=i._zod.run({value:r.value,issues:[]},n);if(a instanceof Promise)o.push(a),s=!0;else{if(a.issues.length===0)return a;o.push(a)}}return s?Promise.all(o).then(i=>al(i,r,t,n)):al(o,r,t,n)}}),Gm=A("$ZodDiscriminatedUnion",(t,e)=>{cl.init(t,e);const r=t._zod.parse;Oe(t._zod,"propValues",()=>{const s={};for(const o of e.options){const i=o._zod.propValues;if(!i||Object.keys(i).length===0)throw new Error(`Invalid discriminated union option at index "${e.options.indexOf(o)}"`);for(const[a,c]of Object.entries(i)){s[a]||(s[a]=new Set);for(const u of c)s[a].add(u)}}return s});const n=ti(()=>{const s=e.options,o=new Map;for(const i of s){const a=i._zod.propValues[e.discriminator];if(!a||a.size===0)throw new Error(`Invalid discriminated union option at index "${e.options.indexOf(i)}"`);for(const c of a){if(o.has(c))throw new Error(`Duplicate discriminator value "${String(c)}"`);o.set(c,i)}}return o});t._zod.parse=(s,o)=>{const i=s.value;if(!As(i))return s.issues.push({code:"invalid_type",expected:"object",input:i,inst:t}),s;const a=n.value.get(i?.[e.discriminator]);return a?a._zod.run(s,o):e.unionFallback?r(s,o):(s.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",input:i,path:[e.discriminator],inst:t}),s)}}),Ym=A("$ZodIntersection",(t,e)=>{Ie.init(t,e),t._zod.parse=(r,n)=>{const s=r.value,o=e.left._zod.run({value:s,issues:[]},n),i=e.right._zod.run({value:s,issues:[]},n);return o instanceof Promise||i instanceof Promise?Promise.all([o,i]).then(([c,u])=>ul(r,c,u)):ul(r,o,i)}});function ai(t,e){if(t===e)return{valid:!0,data:t};if(t instanceof Date&&e instanceof Date&&+t==+e)return{valid:!0,data:t};if(Ms(t)&&Ms(e)){const r=Object.keys(e),n=Object.keys(t).filter(o=>r.indexOf(o)!==-1),s={...t,...e};for(const o of n){const i=ai(t[o],e[o]);if(!i.valid)return{valid:!1,mergeErrorPath:[o,...i.mergeErrorPath]};s[o]=i.data}return{valid:!0,data:s}}if(Array.isArray(t)&&Array.isArray(e)){if(t.length!==e.length)return{valid:!1,mergeErrorPath:[]};const r=[];for(let n=0;n<t.length;n++){const s=t[n],o=e[n],i=ai(s,o);if(!i.valid)return{valid:!1,mergeErrorPath:[n,...i.mergeErrorPath]};r.push(i.data)}return{valid:!0,data:r}}return{valid:!1,mergeErrorPath:[]}}function ul(t,e,r){if(e.issues.length&&t.issues.push(...e.issues),r.issues.length&&t.issues.push(...r.issues),tn(t))return t;const n=ai(e.value,r.value);if(!n.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(n.mergeErrorPath)}`);return t.value=n.data,t}const Qm=A("$ZodRecord",(t,e)=>{Ie.init(t,e),t._zod.parse=(r,n)=>{const s=r.value;if(!Ms(s))return r.issues.push({expected:"record",code:"invalid_type",input:s,inst:t}),r;const o=[];if(e.keyType._zod.values){const i=e.keyType._zod.values;r.value={};for(const c of i)if(typeof c=="string"||typeof c=="number"||typeof c=="symbol"){const u=e.valueType._zod.run({value:s[c],issues:[]},n);u instanceof Promise?o.push(u.then(l=>{l.issues.length&&r.issues.push(...hr(c,l.issues)),r.value[c]=l.value})):(u.issues.length&&r.issues.push(...hr(c,u.issues)),r.value[c]=u.value)}let a;for(const c in s)i.has(c)||(a=a??[],a.push(c));a&&a.length>0&&r.issues.push({code:"unrecognized_keys",input:s,inst:t,keys:a})}else{r.value={};for(const i of Reflect.ownKeys(s)){if(i==="__proto__")continue;const a=e.keyType._zod.run({value:i,issues:[]},n);if(a instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(a.issues.length){r.issues.push({origin:"record",code:"invalid_key",issues:a.issues.map(u=>Qt(u,n,Gt())),input:i,path:[i],inst:t}),r.value[a.value]=a.value;continue}const c=e.valueType._zod.run({value:s[i],issues:[]},n);c instanceof Promise?o.push(c.then(u=>{u.issues.length&&r.issues.push(...hr(i,u.issues)),r.value[a.value]=u.value})):(c.issues.length&&r.issues.push(...hr(i,c.issues)),r.value[a.value]=c.value)}}return o.length?Promise.all(o).then(()=>r):r}}),Xm=A("$ZodEnum",(t,e)=>{Ie.init(t,e);const r=Zu(e.entries);t._zod.values=new Set(r),t._zod.pattern=new RegExp(`^(${r.filter(n=>gp.has(typeof n)).map(n=>typeof n=="string"?en(n):n.toString()).join("|")})$`),t._zod.parse=(n,s)=>{const o=n.value;return t._zod.values.has(o)||n.issues.push({code:"invalid_value",values:r,input:o,inst:t}),n}}),e_=A("$ZodLiteral",(t,e)=>{Ie.init(t,e),t._zod.values=new Set(e.values),t._zod.pattern=new RegExp(`^(${e.values.map(r=>typeof r=="string"?en(r):r?r.toString():String(r)).join("|")})$`),t._zod.parse=(r,n)=>{const s=r.value;return t._zod.values.has(s)||r.issues.push({code:"invalid_value",values:e.values,input:s,inst:t}),r}}),t_=A("$ZodTransform",(t,e)=>{Ie.init(t,e),t._zod.parse=(r,n)=>{const s=e.transform(r.value,r);if(n.async)return(s instanceof Promise?s:Promise.resolve(s)).then(i=>(r.value=i,r));if(s instanceof Promise)throw new Yr;return r.value=s,r}}),r_=A("$ZodOptional",(t,e)=>{Ie.init(t,e),t._zod.optin="optional",t._zod.optout="optional",Oe(t._zod,"values",()=>e.innerType._zod.values?new Set([...e.innerType._zod.values,void 0]):void 0),Oe(t._zod,"pattern",()=>{const r=e.innerType._zod.pattern;return r?new RegExp(`^(${ni(r.source)})?$`):void 0}),t._zod.parse=(r,n)=>e.innerType._zod.optin==="optional"?e.innerType._zod.run(r,n):r.value===void 0?r:e.innerType._zod.run(r,n)}),n_=A("$ZodNullable",(t,e)=>{Ie.init(t,e),Oe(t._zod,"optin",()=>e.innerType._zod.optin),Oe(t._zod,"optout",()=>e.innerType._zod.optout),Oe(t._zod,"pattern",()=>{const r=e.innerType._zod.pattern;return r?new RegExp(`^(${ni(r.source)}|null)$`):void 0}),Oe(t._zod,"values",()=>e.innerType._zod.values?new Set([...e.innerType._zod.values,null]):void 0),t._zod.parse=(r,n)=>r.value===null?r:e.innerType._zod.run(r,n)}),s_=A("$ZodDefault",(t,e)=>{Ie.init(t,e),t._zod.optin="optional",Oe(t._zod,"values",()=>e.innerType._zod.values),t._zod.parse=(r,n)=>{if(r.value===void 0)return r.value=e.defaultValue,r;const s=e.innerType._zod.run(r,n);return s instanceof Promise?s.then(o=>ll(o,e)):ll(s,e)}});function ll(t,e){return t.value===void 0&&(t.value=e.defaultValue),t}const o_=A("$ZodPrefault",(t,e)=>{Ie.init(t,e),t._zod.optin="optional",Oe(t._zod,"values",()=>e.innerType._zod.values),t._zod.parse=(r,n)=>(r.value===void 0&&(r.value=e.defaultValue),e.innerType._zod.run(r,n))}),i_=A("$ZodNonOptional",(t,e)=>{Ie.init(t,e),Oe(t._zod,"values",()=>{const r=e.innerType._zod.values;return r?new Set([...r].filter(n=>n!==void 0)):void 0}),t._zod.parse=(r,n)=>{const s=e.innerType._zod.run(r,n);return s instanceof Promise?s.then(o=>dl(o,t)):dl(s,t)}});function dl(t,e){return!t.issues.length&&t.value===void 0&&t.issues.push({code:"invalid_type",expected:"nonoptional",input:t.value,inst:e}),t}const a_=A("$ZodCatch",(t,e)=>{Ie.init(t,e),t._zod.optin="optional",Oe(t._zod,"optout",()=>e.innerType._zod.optout),Oe(t._zod,"values",()=>e.innerType._zod.values),t._zod.parse=(r,n)=>{const s=e.innerType._zod.run(r,n);return s instanceof Promise?s.then(o=>(r.value=o.value,o.issues.length&&(r.value=e.catchValue({...r,error:{issues:o.issues.map(i=>Qt(i,n,Gt()))},input:r.value}),r.issues=[]),r)):(r.value=s.value,s.issues.length&&(r.value=e.catchValue({...r,error:{issues:s.issues.map(o=>Qt(o,n,Gt()))},input:r.value}),r.issues=[]),r)}}),c_=A("$ZodPipe",(t,e)=>{Ie.init(t,e),Oe(t._zod,"values",()=>e.in._zod.values),Oe(t._zod,"optin",()=>e.in._zod.optin),Oe(t._zod,"optout",()=>e.out._zod.optout),t._zod.parse=(r,n)=>{const s=e.in._zod.run(r,n);return s instanceof Promise?s.then(o=>hl(o,e,n)):hl(s,e,n)}});function hl(t,e,r){return tn(t)?t:e.out._zod.run({value:t.value,issues:t.issues},r)}const u_=A("$ZodReadonly",(t,e)=>{Ie.init(t,e),Oe(t._zod,"propValues",()=>e.innerType._zod.propValues),Oe(t._zod,"values",()=>e.innerType._zod.values),Oe(t._zod,"optin",()=>e.innerType._zod.optin),Oe(t._zod,"optout",()=>e.innerType._zod.optout),t._zod.parse=(r,n)=>{const s=e.innerType._zod.run(r,n);return s instanceof Promise?s.then(fl):fl(s)}});function fl(t){return t.value=Object.freeze(t.value),t}const l_=A("$ZodCustom",(t,e)=>{nt.init(t,e),Ie.init(t,e),t._zod.parse=(r,n)=>r,t._zod.check=r=>{const n=r.value,s=e.fn(n);if(s instanceof Promise)return s.then(o=>pl(o,r,n,t));pl(s,r,n,t)}});function pl(t,e,r,n){if(!t){const s={code:"custom",input:r,inst:n,path:[...n._zod.def.path??[]],continue:!n._zod.def.abort};n._zod.def.params&&(s.params=n._zod.def.params),e.issues.push(rn(s))}}class ml{constructor(){this._map=new Map,this._idmap=new Map}add(e,...r){const n=r[0];if(this._map.set(e,n),n&&typeof n=="object"&&"id"in n){if(this._idmap.has(n.id))throw new Error(`ID ${n.id} already exists in the registry`);this._idmap.set(n.id,e)}return this}clear(){return this._map=new Map,this._idmap=new Map,this}remove(e){const r=this._map.get(e);return r&&typeof r=="object"&&"id"in r&&this._idmap.delete(r.id),this._map.delete(e),this}get(e){const r=e._zod.parent;if(r){const n={...this.get(r)??{}};return delete n.id,{...n,...this._map.get(e)}}return this._map.get(e)}has(e){return this._map.has(e)}}function d_(){return new ml}const nn=d_();function h_(t,e){return new t({type:"string",...Y(e)})}function f_(t,e){return new t({type:"string",format:"email",check:"string_format",abort:!1,...Y(e)})}function _l(t,e){return new t({type:"string",format:"guid",check:"string_format",abort:!1,...Y(e)})}function p_(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,...Y(e)})}function m_(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...Y(e)})}function __(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...Y(e)})}function g_(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...Y(e)})}function gl(t,e){return new t({type:"string",format:"url",check:"string_format",abort:!1,...Y(e)})}function v_(t,e){return new t({type:"string",format:"emoji",check:"string_format",abort:!1,...Y(e)})}function y_(t,e){return new t({type:"string",format:"nanoid",check:"string_format",abort:!1,...Y(e)})}function w_(t,e){return new t({type:"string",format:"cuid",check:"string_format",abort:!1,...Y(e)})}function b_(t,e){return new t({type:"string",format:"cuid2",check:"string_format",abort:!1,...Y(e)})}function $_(t,e){return new t({type:"string",format:"ulid",check:"string_format",abort:!1,...Y(e)})}function S_(t,e){return new t({type:"string",format:"xid",check:"string_format",abort:!1,...Y(e)})}function k_(t,e){return new t({type:"string",format:"ksuid",check:"string_format",abort:!1,...Y(e)})}function T_(t,e){return new t({type:"string",format:"ipv4",check:"string_format",abort:!1,...Y(e)})}function R_(t,e){return new t({type:"string",format:"ipv6",check:"string_format",abort:!1,...Y(e)})}function E_(t,e){return new t({type:"string",format:"cidrv4",check:"string_format",abort:!1,...Y(e)})}function P_(t,e){return new t({type:"string",format:"cidrv6",check:"string_format",abort:!1,...Y(e)})}function x_(t,e){return new t({type:"string",format:"base64",check:"string_format",abort:!1,...Y(e)})}function I_(t,e){return new t({type:"string",format:"base64url",check:"string_format",abort:!1,...Y(e)})}function C_(t,e){return new t({type:"string",format:"e164",check:"string_format",abort:!1,...Y(e)})}function O_(t,e){return new t({type:"string",format:"jwt",check:"string_format",abort:!1,...Y(e)})}function N_(t,e){return new t({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...Y(e)})}function A_(t,e){return new t({type:"string",format:"date",check:"string_format",...Y(e)})}function M_(t,e){return new t({type:"string",format:"time",check:"string_format",precision:null,...Y(e)})}function j_(t,e){return new t({type:"string",format:"duration",check:"string_format",...Y(e)})}function q_(t,e){return new t({type:"number",checks:[],...Y(e)})}function z_(t,e){return new t({type:"number",coerce:!0,checks:[],...Y(e)})}function U_(t,e){return new t({type:"number",check:"number_format",abort:!1,format:"safeint",...Y(e)})}function L_(t,e){return new t({type:"boolean",...Y(e)})}function Z_(t,e){return new t({type:"null",...Y(e)})}function D_(t){return new t({type:"any"})}function V_(t){return new t({type:"unknown"})}function H_(t,e){return new t({type:"never",...Y(e)})}function vl(t,e){return new el({check:"less_than",...Y(e),value:t,inclusive:!1})}function ci(t,e){return new el({check:"less_than",...Y(e),value:t,inclusive:!0})}function yl(t,e){return new tl({check:"greater_than",...Y(e),value:t,inclusive:!1})}function ui(t,e){return new tl({check:"greater_than",...Y(e),value:t,inclusive:!0})}function wl(t,e){return new sm({check:"multiple_of",...Y(e),value:t})}function bl(t,e){return new im({check:"max_length",...Y(e),maximum:t})}function Zs(t,e){return new am({check:"min_length",...Y(e),minimum:t})}function $l(t,e){return new cm({check:"length_equals",...Y(e),length:t})}function F_(t,e){return new um({check:"string_format",format:"regex",...Y(e),pattern:t})}function W_(t){return new lm({check:"string_format",format:"lowercase",...Y(t)})}function J_(t){return new dm({check:"string_format",format:"uppercase",...Y(t)})}function B_(t,e){return new hm({check:"string_format",format:"includes",...Y(e),includes:t})}function K_(t,e){return new fm({check:"string_format",format:"starts_with",...Y(e),prefix:t})}function G_(t,e){return new pm({check:"string_format",format:"ends_with",...Y(e),suffix:t})}function sn(t){return new mm({check:"overwrite",tx:t})}function Y_(t){return sn(e=>e.normalize(t))}function Q_(){return sn(t=>t.trim())}function X_(){return sn(t=>t.toLowerCase())}function eg(){return sn(t=>t.toUpperCase())}function tg(t,e,r){return new t({type:"array",element:e,...Y(r)})}function rg(t,e,r){const n=Y(r);return n.abort??(n.abort=!0),new t({type:"custom",check:"custom",fn:e,...n})}function ng(t,e,r){return new t({type:"custom",check:"custom",fn:e,...Y(r)})}class Sl{constructor(e){this.counter=0,this.metadataRegistry=e?.metadata??nn,this.target=e?.target??"draft-2020-12",this.unrepresentable=e?.unrepresentable??"throw",this.override=e?.override??(()=>{}),this.io=e?.io??"output",this.seen=new Map}process(e,r={path:[],schemaPath:[]}){var n;const s=e._zod.def,o={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},i=this.seen.get(e);if(i)return i.count++,r.schemaPath.includes(e)&&(i.cycle=r.path),i.schema;const a={schema:{},count:1,cycle:void 0,path:r.path};this.seen.set(e,a);const c=e._zod.toJSONSchema?.();if(c)a.schema=c;else{const d={...r,schemaPath:[...r.schemaPath,e],path:r.path},p=e._zod.parent;if(p)a.ref=p,this.process(p,d),this.seen.get(p).isParent=!0;else{const _=a.schema;switch(s.type){case"string":{const m=_;m.type="string";const{minimum:g,maximum:f,format:v,patterns:h,contentEncoding:w}=e._zod.bag;if(typeof g=="number"&&(m.minLength=g),typeof f=="number"&&(m.maxLength=f),v&&(m.format=o[v]??v,m.format===""&&delete m.format),w&&(m.contentEncoding=w),h&&h.size>0){const $=[...h];$.length===1?m.pattern=$[0].source:$.length>1&&(a.schema.allOf=[...$.map(b=>({...this.target==="draft-7"?{type:"string"}:{},pattern:b.source}))])}break}case"number":{const m=_,{minimum:g,maximum:f,format:v,multipleOf:h,exclusiveMaximum:w,exclusiveMinimum:$}=e._zod.bag;typeof v=="string"&&v.includes("int")?m.type="integer":m.type="number",typeof $=="number"&&(m.exclusiveMinimum=$),typeof g=="number"&&(m.minimum=g,typeof $=="number"&&($>=g?delete m.minimum:delete m.exclusiveMinimum)),typeof w=="number"&&(m.exclusiveMaximum=w),typeof f=="number"&&(m.maximum=f,typeof w=="number"&&(w<=f?delete m.maximum:delete m.exclusiveMaximum)),typeof h=="number"&&(m.multipleOf=h);break}case"boolean":{const m=_;m.type="boolean";break}case"bigint":{if(this.unrepresentable==="throw")throw new Error("BigInt cannot be represented in JSON Schema");break}case"symbol":{if(this.unrepresentable==="throw")throw new Error("Symbols cannot be represented in JSON Schema");break}case"null":{_.type="null";break}case"any":break;case"unknown":break;case"undefined":{if(this.unrepresentable==="throw")throw new Error("Undefined cannot be represented in JSON Schema");break}case"void":{if(this.unrepresentable==="throw")throw new Error("Void cannot be represented in JSON Schema");break}case"never":{_.not={};break}case"date":{if(this.unrepresentable==="throw")throw new Error("Date cannot be represented in JSON Schema");break}case"array":{const m=_,{minimum:g,maximum:f}=e._zod.bag;typeof g=="number"&&(m.minItems=g),typeof f=="number"&&(m.maxItems=f),m.type="array",m.items=this.process(s.element,{...d,path:[...d.path,"items"]});break}case"object":{const m=_;m.type="object",m.properties={};const g=s.shape;for(const h in g)m.properties[h]=this.process(g[h],{...d,path:[...d.path,"properties",h]});const f=new Set(Object.keys(g)),v=new Set([...f].filter(h=>{const w=s.shape[h]._zod;return this.io==="input"?w.optin===void 0:w.optout===void 0}));v.size>0&&(m.required=Array.from(v)),s.catchall?._zod.def.type==="never"?m.additionalProperties=!1:s.catchall?s.catchall&&(m.additionalProperties=this.process(s.catchall,{...d,path:[...d.path,"additionalProperties"]})):this.io==="output"&&(m.additionalProperties=!1);break}case"union":{const m=_;m.anyOf=s.options.map((g,f)=>this.process(g,{...d,path:[...d.path,"anyOf",f]}));break}case"intersection":{const m=_,g=this.process(s.left,{...d,path:[...d.path,"allOf",0]}),f=this.process(s.right,{...d,path:[...d.path,"allOf",1]}),v=w=>"allOf"in w&&Object.keys(w).length===1,h=[...v(g)?g.allOf:[g],...v(f)?f.allOf:[f]];m.allOf=h;break}case"tuple":{const m=_;m.type="array";const g=s.items.map((h,w)=>this.process(h,{...d,path:[...d.path,"prefixItems",w]}));if(this.target==="draft-2020-12"?m.prefixItems=g:m.items=g,s.rest){const h=this.process(s.rest,{...d,path:[...d.path,"items"]});this.target==="draft-2020-12"?m.items=h:m.additionalItems=h}s.rest&&(m.items=this.process(s.rest,{...d,path:[...d.path,"items"]}));const{minimum:f,maximum:v}=e._zod.bag;typeof f=="number"&&(m.minItems=f),typeof v=="number"&&(m.maxItems=v);break}case"record":{const m=_;m.type="object",m.propertyNames=this.process(s.keyType,{...d,path:[...d.path,"propertyNames"]}),m.additionalProperties=this.process(s.valueType,{...d,path:[...d.path,"additionalProperties"]});break}case"map":{if(this.unrepresentable==="throw")throw new Error("Map cannot be represented in JSON Schema");break}case"set":{if(this.unrepresentable==="throw")throw new Error("Set cannot be represented in JSON Schema");break}case"enum":{const m=_,g=Zu(s.entries);g.every(f=>typeof f=="number")&&(m.type="number"),g.every(f=>typeof f=="string")&&(m.type="string"),m.enum=g;break}case"literal":{const m=_,g=[];for(const f of s.values)if(f===void 0){if(this.unrepresentable==="throw")throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof f=="bigint"){if(this.unrepresentable==="throw")throw new Error("BigInt literals cannot be represented in JSON Schema");g.push(Number(f))}else g.push(f);if(g.length!==0)if(g.length===1){const f=g[0];m.type=f===null?"null":typeof f,m.const=f}else g.every(f=>typeof f=="number")&&(m.type="number"),g.every(f=>typeof f=="string")&&(m.type="string"),g.every(f=>typeof f=="boolean")&&(m.type="string"),g.every(f=>f===null)&&(m.type="null"),m.enum=g;break}case"file":{const m=_,g={type:"string",format:"binary",contentEncoding:"binary"},{minimum:f,maximum:v,mime:h}=e._zod.bag;f!==void 0&&(g.minLength=f),v!==void 0&&(g.maxLength=v),h?h.length===1?(g.contentMediaType=h[0],Object.assign(m,g)):m.anyOf=h.map(w=>({...g,contentMediaType:w})):Object.assign(m,g);break}case"transform":{if(this.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema");break}case"nullable":{const m=this.process(s.innerType,d);_.anyOf=[m,{type:"null"}];break}case"nonoptional":{this.process(s.innerType,d),a.ref=s.innerType;break}case"success":{const m=_;m.type="boolean";break}case"default":{this.process(s.innerType,d),a.ref=s.innerType,_.default=JSON.parse(JSON.stringify(s.defaultValue));break}case"prefault":{this.process(s.innerType,d),a.ref=s.innerType,this.io==="input"&&(_._prefault=JSON.parse(JSON.stringify(s.defaultValue)));break}case"catch":{this.process(s.innerType,d),a.ref=s.innerType;let m;try{m=s.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}_.default=m;break}case"nan":{if(this.unrepresentable==="throw")throw new Error("NaN cannot be represented in JSON Schema");break}case"template_literal":{const m=_,g=e._zod.pattern;if(!g)throw new Error("Pattern not found in template literal");m.type="string",m.pattern=g.source;break}case"pipe":{const m=this.io==="input"?s.in._zod.def.type==="transform"?s.out:s.in:s.out;this.process(m,d),a.ref=m;break}case"readonly":{this.process(s.innerType,d),a.ref=s.innerType,_.readOnly=!0;break}case"promise":{this.process(s.innerType,d),a.ref=s.innerType;break}case"optional":{this.process(s.innerType,d),a.ref=s.innerType;break}case"lazy":{const m=e._zod.innerType;this.process(m,d),a.ref=m;break}case"custom":{if(this.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema");break}}}}const u=this.metadataRegistry.get(e);return u&&Object.assign(a.schema,u),this.io==="input"&&Ue(e)&&(delete a.schema.examples,delete a.schema.default),this.io==="input"&&a.schema._prefault&&((n=a.schema).default??(n.default=a.schema._prefault)),delete a.schema._prefault,this.seen.get(e).schema}emit(e,r){const n={cycles:r?.cycles??"ref",reused:r?.reused??"inline",external:r?.external??void 0},s=this.seen.get(e);if(!s)throw new Error("Unprocessed schema. This is a bug in Zod.");const o=l=>{const d=this.target==="draft-2020-12"?"$defs":"definitions";if(n.external){const g=n.external.registry.get(l[0])?.id,f=n.external.uri??(h=>h);if(g)return{ref:f(g)};const v=l[1].defId??l[1].schema.id??`schema${this.counter++}`;return l[1].defId=v,{defId:v,ref:`${f("__shared")}#/${d}/${v}`}}if(l[1]===s)return{ref:"#"};const _=`#/${d}/`,m=l[1].schema.id??`__schema${this.counter++}`;return{defId:m,ref:_+m}},i=l=>{if(l[1].schema.$ref)return;const d=l[1],{ref:p,defId:_}=o(l);d.def={...d.schema},_&&(d.defId=_);const m=d.schema;for(const g in m)delete m[g];m.$ref=p};if(n.cycles==="throw")for(const l of this.seen.entries()){const d=l[1];if(d.cycle)throw new Error(`Cycle detected: #/${d.cycle?.join("/")}/<root>
|
|
34
34
|
|
|
35
|
-
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const u of this.seen.entries()){const d=u[1];if(e===u[0]){i(u);continue}if(n.external){const v=n.external.registry.get(u[0])?.id;if(e!==u[0]&&v){i(u);continue}}if(this.metadataRegistry.get(u[0])?.id){i(u);continue}if(d.cycle){i(u);continue}if(d.count>1&&n.reused==="ref"){i(u);continue}}const o=(u,d)=>{const g=this.seen.get(u),v=g.def??g.schema,p={...v};if(g.ref===null)return;const w=g.ref;if(g.ref=null,w){o(w,d);const h=this.seen.get(w).schema;h.$ref&&d.target==="draft-7"?(v.allOf=v.allOf??[],v.allOf.push(h)):(Object.assign(v,h),Object.assign(v,p))}g.isParent||this.override({zodSchema:u,jsonSchema:v,path:g.path??[]})};for(const u of[...this.seen.entries()].reverse())o(u[0],{target:this.target});const c={};if(this.target==="draft-2020-12"?c.$schema="https://json-schema.org/draft/2020-12/schema":this.target==="draft-7"?c.$schema="http://json-schema.org/draft-07/schema#":console.warn(`Invalid target: ${this.target}`),n.external?.uri){const u=n.external.registry.get(e)?.id;if(!u)throw new Error("Schema is missing an `id` property");c.$id=n.external.uri(u)}Object.assign(c,s.def);const l=n.external?.defs??{};for(const u of this.seen.entries()){const d=u[1];d.def&&d.defId&&(l[d.defId]=d.def)}n.external||Object.keys(l).length>0&&(this.target==="draft-2020-12"?c.$defs=l:c.definitions=l);try{return JSON.parse(JSON.stringify(c))}catch{throw new Error("Error converting schema to JSON.")}}}function Xp(t,e){if(t instanceof tu){const n=new uu(e),s={};for(const o of t._idmap.entries()){const[c,l]=o;n.process(l)}const a={},i={registry:t,uri:e?.uri,defs:s};for(const o of t._idmap.entries()){const[c,l]=o;a[c]=n.emit(l,{...e,external:i})}if(Object.keys(s).length>0){const o=n.target==="draft-2020-12"?"$defs":"definitions";a.__shared={[o]:s}}return{schemas:a}}const r=new uu(e);return r.process(t),r.emit(t,e)}function Ae(t,e){const r=e??{seen:new Set};if(r.seen.has(t))return!1;r.seen.add(t);const s=t._zod.def;switch(s.type){case"string":case"number":case"bigint":case"boolean":case"date":case"symbol":case"undefined":case"null":case"any":case"unknown":case"never":case"void":case"literal":case"enum":case"nan":case"file":case"template_literal":return!1;case"array":return Ae(s.element,r);case"object":{for(const a in s.shape)if(Ae(s.shape[a],r))return!0;return!1}case"union":{for(const a of s.options)if(Ae(a,r))return!0;return!1}case"intersection":return Ae(s.left,r)||Ae(s.right,r);case"tuple":{for(const a of s.items)if(Ae(a,r))return!0;return!!(s.rest&&Ae(s.rest,r))}case"record":return Ae(s.keyType,r)||Ae(s.valueType,r);case"map":return Ae(s.keyType,r)||Ae(s.valueType,r);case"set":return Ae(s.valueType,r);case"promise":case"optional":case"nonoptional":case"nullable":case"readonly":return Ae(s.innerType,r);case"lazy":return Ae(s.getter(),r);case"default":return Ae(s.innerType,r);case"prefault":return Ae(s.innerType,r);case"custom":return!1;case"transform":return!0;case"pipe":return Ae(s.in,r)||Ae(s.out,r);case"success":return!1;case"catch":return!1}throw new Error(`Unknown schema type: ${s.type}`)}const em=A("ZodISODateTime",(t,e)=>{Sh.init(t,e),Ce.init(t,e)});function lu(t){return Pp(em,t)}const tm=A("ZodISODate",(t,e)=>{Th.init(t,e),Ce.init(t,e)});function rm(t){return xp(tm,t)}const nm=A("ZodISOTime",(t,e)=>{Eh.init(t,e),Ce.init(t,e)});function sm(t){return Ip(nm,t)}const am=A("ZodISODuration",(t,e)=>{Rh.init(t,e),Ce.init(t,e)});function im(t){return Cp(am,t)}const ws=A("ZodError",(t,e)=>{Ic.init(t,e),t.name="ZodError",Object.defineProperties(t,{format:{value:r=>kf(t,r)},flatten:{value:r=>bf(t,r)},addIssue:{value:r=>t.issues.push(r)},addIssues:{value:r=>t.issues.push(...r)},isEmpty:{get(){return t.issues.length===0}}})},{Parent:Error}),om=Cc(ws),cm=Oc(ws),um=Nc(ws),lm=Ac(ws),Re=A("ZodType",(t,e)=>(ke.init(t,e),t.def=e,Object.defineProperty(t,"_def",{value:e}),t.check=(...r)=>t.clone({...e,checks:[...e.checks??[],...r.map(n=>typeof n=="function"?{_zod:{check:n,def:{check:"custom"},onattach:[]}}:n)]}),t.clone=(r,n)=>Dt(t,r,n),t.brand=()=>t,t.register=((r,n)=>(r.add(t,n),t)),t.parse=(r,n)=>om(t,r,n,{callee:t.parse}),t.safeParse=(r,n)=>um(t,r,n),t.parseAsync=async(r,n)=>cm(t,r,n,{callee:t.parseAsync}),t.safeParseAsync=async(r,n)=>lm(t,r,n),t.spa=t.safeParseAsync,t.refine=(r,n)=>t.check(r_(r,n)),t.superRefine=r=>t.check(n_(r)),t.overwrite=r=>t.check(Vr(r)),t.optional=()=>re(t),t.nullable=()=>bu(t),t.nullish=()=>re(bu(t)),t.nonoptional=r=>Km(t,r),t.array=()=>H(t),t.or=r=>xe([t,r]),t.and=r=>Ca(t,r),t.transform=r=>Na(t,yu(r)),t.default=r=>Hm(t,r),t.prefault=r=>Jm(t,r),t.catch=r=>Gm(t,r),t.pipe=r=>Na(t,r),t.readonly=()=>Xm(t),t.describe=r=>{const n=t.clone();return Dr.add(n,{description:r}),n},Object.defineProperty(t,"description",{get(){return Dr.get(t)?.description},configurable:!0}),t.meta=(...r)=>{if(r.length===0)return Dr.get(t);const n=t.clone();return Dr.add(n,r[0]),n},t.isOptional=()=>t.safeParse(void 0).success,t.isNullable=()=>t.safeParse(null).success,t)),du=A("_ZodString",(t,e)=>{Ea.init(t,e),Re.init(t,e);const r=t._zod.bag;t.format=r.format??null,t.minLength=r.minimum??null,t.maxLength=r.maximum??null,t.regex=(...n)=>t.check(Lp(...n)),t.includes=(...n)=>t.check(Vp(...n)),t.startsWith=(...n)=>t.check(Fp(...n)),t.endsWith=(...n)=>t.check(Hp(...n)),t.min=(...n)=>t.check(ys(...n)),t.max=(...n)=>t.check(ou(...n)),t.length=(...n)=>t.check(cu(...n)),t.nonempty=(...n)=>t.check(ys(1,...n)),t.lowercase=n=>t.check(Up(n)),t.uppercase=n=>t.check(Dp(n)),t.trim=()=>t.check(Jp()),t.normalize=(...n)=>t.check(Wp(...n)),t.toLowerCase=()=>t.check(Kp()),t.toUpperCase=()=>t.check(Bp())}),dm=A("ZodString",(t,e)=>{Ea.init(t,e),du.init(t,e),t.email=r=>t.check(cp(fm,r)),t.url=r=>t.check(nu(hu,r)),t.jwt=r=>t.check(Rp(Pm,r)),t.emoji=r=>t.check(hp(pm,r)),t.guid=r=>t.check(ru(fu,r)),t.uuid=r=>t.check(up(bs,r)),t.uuidv4=r=>t.check(lp(bs,r)),t.uuidv6=r=>t.check(dp(bs,r)),t.uuidv7=r=>t.check(fp(bs,r)),t.nanoid=r=>t.check(pp(mm,r)),t.guid=r=>t.check(ru(fu,r)),t.cuid=r=>t.check(mp(_m,r)),t.cuid2=r=>t.check(_p(vm,r)),t.ulid=r=>t.check(vp(gm,r)),t.base64=r=>t.check(Sp(Tm,r)),t.base64url=r=>t.check(Tp(Em,r)),t.xid=r=>t.check(gp(ym,r)),t.ksuid=r=>t.check(yp(wm,r)),t.ipv4=r=>t.check(wp(bm,r)),t.ipv6=r=>t.check(bp(km,r)),t.cidrv4=r=>t.check(kp($m,r)),t.cidrv6=r=>t.check($p(Sm,r)),t.e164=r=>t.check(Ep(Rm,r)),t.datetime=r=>t.check(lu(r)),t.date=r=>t.check(rm(r)),t.time=r=>t.check(sm(r)),t.duration=r=>t.check(im(r))});function E(t){return op(dm,t)}const Ce=A("ZodStringFormat",(t,e)=>{Ee.init(t,e),du.init(t,e)}),fm=A("ZodEmail",(t,e)=>{mh.init(t,e),Ce.init(t,e)}),fu=A("ZodGUID",(t,e)=>{hh.init(t,e),Ce.init(t,e)}),bs=A("ZodUUID",(t,e)=>{ph.init(t,e),Ce.init(t,e)}),hu=A("ZodURL",(t,e)=>{_h.init(t,e),Ce.init(t,e)});function hm(t){return nu(hu,t)}const pm=A("ZodEmoji",(t,e)=>{vh.init(t,e),Ce.init(t,e)}),mm=A("ZodNanoID",(t,e)=>{gh.init(t,e),Ce.init(t,e)}),_m=A("ZodCUID",(t,e)=>{yh.init(t,e),Ce.init(t,e)}),vm=A("ZodCUID2",(t,e)=>{wh.init(t,e),Ce.init(t,e)}),gm=A("ZodULID",(t,e)=>{bh.init(t,e),Ce.init(t,e)}),ym=A("ZodXID",(t,e)=>{kh.init(t,e),Ce.init(t,e)}),wm=A("ZodKSUID",(t,e)=>{$h.init(t,e),Ce.init(t,e)}),bm=A("ZodIPv4",(t,e)=>{Ph.init(t,e),Ce.init(t,e)}),km=A("ZodIPv6",(t,e)=>{xh.init(t,e),Ce.init(t,e)}),$m=A("ZodCIDRv4",(t,e)=>{Ih.init(t,e),Ce.init(t,e)}),Sm=A("ZodCIDRv6",(t,e)=>{Ch.init(t,e),Ce.init(t,e)}),Tm=A("ZodBase64",(t,e)=>{Oh.init(t,e),Ce.init(t,e)}),Em=A("ZodBase64URL",(t,e)=>{Ah.init(t,e),Ce.init(t,e)}),Rm=A("ZodE164",(t,e)=>{jh.init(t,e),Ce.init(t,e)}),Pm=A("ZodJWT",(t,e)=>{Mh.init(t,e),Ce.init(t,e)}),Ia=A("ZodNumber",(t,e)=>{Vc.init(t,e),Re.init(t,e),t.gt=(n,s)=>t.check(au(n,s)),t.gte=(n,s)=>t.check(xa(n,s)),t.min=(n,s)=>t.check(xa(n,s)),t.lt=(n,s)=>t.check(su(n,s)),t.lte=(n,s)=>t.check(Pa(n,s)),t.max=(n,s)=>t.check(Pa(n,s)),t.int=n=>t.check(pu(n)),t.safe=n=>t.check(pu(n)),t.positive=n=>t.check(au(0,n)),t.nonnegative=n=>t.check(xa(0,n)),t.negative=n=>t.check(su(0,n)),t.nonpositive=n=>t.check(Pa(0,n)),t.multipleOf=(n,s)=>t.check(iu(n,s)),t.step=(n,s)=>t.check(iu(n,s)),t.finite=()=>t;const r=t._zod.bag;t.minValue=Math.max(r.minimum??Number.NEGATIVE_INFINITY,r.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,t.maxValue=Math.min(r.maximum??Number.POSITIVE_INFINITY,r.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,t.isInt=(r.format??"").includes("int")||Number.isSafeInteger(r.multipleOf??.5),t.isFinite=!0,t.format=r.format??null});function we(t){return Op(Ia,t)}const xm=A("ZodNumberFormat",(t,e)=>{qh.init(t,e),Ia.init(t,e)});function pu(t){return Ap(xm,t)}const Im=A("ZodBoolean",(t,e)=>{Zh.init(t,e),Re.init(t,e)});function Pe(t){return jp(Im,t)}const Cm=A("ZodNull",(t,e)=>{Lh.init(t,e),Re.init(t,e)});function mu(t){return zp(Cm,t)}const Om=A("ZodAny",(t,e)=>{Uh.init(t,e),Re.init(t,e)});function Nm(){return Mp(Om)}const Am=A("ZodUnknown",(t,e)=>{Dh.init(t,e),Re.init(t,e)});function je(){return qp(Am)}const jm=A("ZodNever",(t,e)=>{Vh.init(t,e),Re.init(t,e)});function zm(t){return Zp(jm,t)}const Mm=A("ZodArray",(t,e)=>{Fh.init(t,e),Re.init(t,e),t.element=e.element,t.min=(r,n)=>t.check(ys(r,n)),t.nonempty=r=>t.check(ys(1,r)),t.max=(r,n)=>t.check(ou(r,n)),t.length=(r,n)=>t.check(cu(r,n)),t.unwrap=()=>t.element});function H(t,e){return Gp(Mm,t,e)}const _u=A("ZodObject",(t,e)=>{Wc.init(t,e),Re.init(t,e),Te(t,"shape",()=>e.shape),t.keyof=()=>Fe(Object.keys(t._zod.def.shape)),t.catchall=r=>t.clone({...t._zod.def,catchall:r}),t.passthrough=()=>t.clone({...t._zod.def,catchall:je()}),t.loose=()=>t.clone({...t._zod.def,catchall:je()}),t.strict=()=>t.clone({...t._zod.def,catchall:zm()}),t.strip=()=>t.clone({...t._zod.def,catchall:void 0}),t.extend=r=>vf(t,r),t.merge=r=>gf(t,r),t.pick=r=>mf(t,r),t.omit=r=>_f(t,r),t.partial=(...r)=>yf(wu,t,r[0]),t.required=(...r)=>wf(ku,t,r[0])});function U(t,e){const r={type:"object",get shape(){return Mr(this,"shape",{...t}),this.shape},...Q(e)};return new _u(r)}function Xe(t,e){return new _u({type:"object",get shape(){return Mr(this,"shape",{...t}),this.shape},catchall:je(),...Q(e)})}const vu=A("ZodUnion",(t,e)=>{Kc.init(t,e),Re.init(t,e),t.options=e.options});function xe(t,e){return new vu({type:"union",options:t,...Q(e)})}const qm=A("ZodDiscriminatedUnion",(t,e)=>{vu.init(t,e),Hh.init(t,e)});function gu(t,e,r){return new qm({type:"union",options:e,discriminator:t,...Q(r)})}const Zm=A("ZodIntersection",(t,e)=>{Wh.init(t,e),Re.init(t,e)});function Ca(t,e){return new Zm({type:"intersection",left:t,right:e})}const Lm=A("ZodRecord",(t,e)=>{Jh.init(t,e),Re.init(t,e),t.keyType=e.keyType,t.valueType=e.valueType});function ze(t,e,r){return new Lm({type:"record",keyType:t,valueType:e,...Q(r)})}const Oa=A("ZodEnum",(t,e)=>{Kh.init(t,e),Re.init(t,e),t.enum=e.entries,t.options=Object.values(e.entries);const r=new Set(Object.keys(e.entries));t.extract=(n,s)=>{const a={};for(const i of n)if(r.has(i))a[i]=e.entries[i];else throw new Error(`Key ${i} not found in enum`);return new Oa({...e,checks:[],...Q(s),entries:a})},t.exclude=(n,s)=>{const a={...e.entries};for(const i of n)if(r.has(i))delete a[i];else throw new Error(`Key ${i} not found in enum`);return new Oa({...e,checks:[],...Q(s),entries:a})}});function Fe(t,e){const r=Array.isArray(t)?Object.fromEntries(t.map(n=>[n,n])):t;return new Oa({type:"enum",entries:r,...Q(e)})}const Um=A("ZodLiteral",(t,e)=>{Bh.init(t,e),Re.init(t,e),t.values=new Set(e.values),Object.defineProperty(t,"value",{get(){if(e.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return e.values[0]}})});function te(t,e){return new Um({type:"literal",values:Array.isArray(t)?t:[t],...Q(e)})}const Dm=A("ZodTransform",(t,e)=>{Gh.init(t,e),Re.init(t,e),t._zod.parse=(r,n)=>{r.addIssue=a=>{if(typeof a=="string")r.issues.push(Ur(a,r.value,e));else{const i=a;i.fatal&&(i.continue=!1),i.code??(i.code="custom"),i.input??(i.input=r.value),i.inst??(i.inst=t),i.continue??(i.continue=!0),r.issues.push(Ur(i))}};const s=e.transform(r.value,r);return s instanceof Promise?s.then(a=>(r.value=a,r)):(r.value=s,r)}});function yu(t){return new Dm({type:"transform",transform:t})}const wu=A("ZodOptional",(t,e)=>{Yh.init(t,e),Re.init(t,e),t.unwrap=()=>t._zod.def.innerType});function re(t){return new wu({type:"optional",innerType:t})}const Vm=A("ZodNullable",(t,e)=>{Qh.init(t,e),Re.init(t,e),t.unwrap=()=>t._zod.def.innerType});function bu(t){return new Vm({type:"nullable",innerType:t})}const Fm=A("ZodDefault",(t,e)=>{Xh.init(t,e),Re.init(t,e),t.unwrap=()=>t._zod.def.innerType,t.removeDefault=t.unwrap});function Hm(t,e){return new Fm({type:"default",innerType:t,get defaultValue(){return typeof e=="function"?e():e}})}const Wm=A("ZodPrefault",(t,e)=>{ep.init(t,e),Re.init(t,e),t.unwrap=()=>t._zod.def.innerType});function Jm(t,e){return new Wm({type:"prefault",innerType:t,get defaultValue(){return typeof e=="function"?e():e}})}const ku=A("ZodNonOptional",(t,e)=>{tp.init(t,e),Re.init(t,e),t.unwrap=()=>t._zod.def.innerType});function Km(t,e){return new ku({type:"nonoptional",innerType:t,...Q(e)})}const Bm=A("ZodCatch",(t,e)=>{rp.init(t,e),Re.init(t,e),t.unwrap=()=>t._zod.def.innerType,t.removeCatch=t.unwrap});function Gm(t,e){return new Bm({type:"catch",innerType:t,catchValue:typeof e=="function"?e:()=>e})}const Ym=A("ZodPipe",(t,e)=>{np.init(t,e),Re.init(t,e),t.in=e.in,t.out=e.out});function Na(t,e){return new Ym({type:"pipe",in:t,out:e})}const Qm=A("ZodReadonly",(t,e)=>{sp.init(t,e),Re.init(t,e)});function Xm(t){return new Qm({type:"readonly",innerType:t})}const $u=A("ZodCustom",(t,e)=>{ap.init(t,e),Re.init(t,e)});function e_(t){const e=new Qe({check:"custom"});return e._zod.check=t,e}function t_(t,e){return Yp($u,t??(()=>!0),e)}function r_(t,e={}){return Qp($u,t,e)}function n_(t){const e=e_(r=>(r.addIssue=n=>{if(typeof n=="string")r.issues.push(Ur(n,r.value,e._zod.def));else{const s=n;s.fatal&&(s.continue=!1),s.code??(s.code="custom"),s.input??(s.input=r.value),s.inst??(s.inst=e),s.continue??(s.continue=!e._zod.def.abort),r.issues.push(Ur(s))}},t(r.value,r)));return e}function Su(t,e){return Na(yu(t),e)}const s_={custom:"custom"};function a_(t){return Np(Ia,t)}const Fr="2025-11-25",Tu=[Fr,"2025-06-18","2025-03-26","2024-11-05","2024-10-07"],Nt="io.modelcontextprotocol/related-task",ks="2.0",St=t_(t=>t!==null&&(typeof t=="object"||typeof t=="function")),Eu=xe([E(),we().int()]),Ru=E(),i_=Xe({ttl:xe([we(),mu()]).optional(),pollInterval:we().optional()}),Aa=Xe({taskId:E()}),o_=Xe({progressToken:Eu.optional(),[Nt]:Aa.optional()}),et=Xe({task:i_.optional(),_meta:o_.optional()}),Le=U({method:E(),params:et.optional()}),rr=Xe({_meta:U({[Nt]:re(Aa)}).passthrough().optional()}),ut=U({method:E(),params:rr.optional()}),He=Xe({_meta:Xe({[Nt]:Aa.optional()}).optional()}),$s=xe([E(),we().int()]),Pu=U({jsonrpc:te(ks),id:$s,...Le.shape}).strict(),ja=t=>Pu.safeParse(t).success,xu=U({jsonrpc:te(ks),...ut.shape}).strict(),c_=t=>xu.safeParse(t).success,Iu=U({jsonrpc:te(ks),id:$s,result:He}).strict(),Hr=t=>Iu.safeParse(t).success;var G;(function(t){t[t.ConnectionClosed=-32e3]="ConnectionClosed",t[t.RequestTimeout=-32001]="RequestTimeout",t[t.ParseError=-32700]="ParseError",t[t.InvalidRequest=-32600]="InvalidRequest",t[t.MethodNotFound=-32601]="MethodNotFound",t[t.InvalidParams=-32602]="InvalidParams",t[t.InternalError=-32603]="InternalError",t[t.UrlElicitationRequired=-32042]="UrlElicitationRequired"})(G||(G={}));const Cu=U({jsonrpc:te(ks),id:$s,error:U({code:we().int(),message:E(),data:re(je())})}).strict(),u_=t=>Cu.safeParse(t).success,nr=xe([Pu,xu,Iu,Cu]),Ft=He.strict(),l_=rr.extend({requestId:$s,reason:E().optional()}),za=ut.extend({method:te("notifications/cancelled"),params:l_}),d_=U({src:E(),mimeType:E().optional(),sizes:H(E()).optional()}),Wr=U({icons:H(d_).optional()}),pr=U({name:E(),title:E().optional()}),Ou=pr.extend({...pr.shape,...Wr.shape,version:E(),websiteUrl:E().optional()}),f_=Ca(U({applyDefaults:Pe().optional()}),ze(E(),je())),h_=Su(t=>t&&typeof t=="object"&&!Array.isArray(t)&&Object.keys(t).length===0?{form:{}}:t,Ca(U({form:f_.optional(),url:St.optional()}),ze(E(),je()).optional())),p_=U({list:re(U({}).passthrough()),cancel:re(U({}).passthrough()),requests:re(U({sampling:re(U({createMessage:re(U({}).passthrough())}).passthrough()),elicitation:re(U({create:re(U({}).passthrough())}).passthrough())}).passthrough())}).passthrough(),m_=U({list:re(U({}).passthrough()),cancel:re(U({}).passthrough()),requests:re(U({tools:re(U({call:re(U({}).passthrough())}).passthrough())}).passthrough())}).passthrough(),__=U({experimental:ze(E(),St).optional(),sampling:U({context:St.optional(),tools:St.optional()}).optional(),elicitation:h_.optional(),roots:U({listChanged:Pe().optional()}).optional(),tasks:re(p_)}),v_=et.extend({protocolVersion:E(),capabilities:__,clientInfo:Ou}),Nu=Le.extend({method:te("initialize"),params:v_}),g_=U({experimental:ze(E(),St).optional(),logging:St.optional(),completions:St.optional(),prompts:re(U({listChanged:re(Pe())})),resources:U({subscribe:Pe().optional(),listChanged:Pe().optional()}).optional(),tools:U({listChanged:Pe().optional()}).optional(),tasks:re(m_)}).passthrough(),Au=He.extend({protocolVersion:E(),capabilities:g_,serverInfo:Ou,instructions:E().optional()}),Ma=ut.extend({method:te("notifications/initialized")}),y_=t=>Ma.safeParse(t).success,qa=Le.extend({method:te("ping")}),w_=U({progress:we(),total:re(we()),message:re(E())}),b_=U({...rr.shape,...w_.shape,progressToken:Eu}),Za=ut.extend({method:te("notifications/progress"),params:b_}),k_=et.extend({cursor:Ru.optional()}),Jr=Le.extend({params:k_.optional()}),Kr=He.extend({nextCursor:re(Ru)}),Br=U({taskId:E(),status:Fe(["working","input_required","completed","failed","cancelled"]),ttl:xe([we(),mu()]),createdAt:E(),lastUpdatedAt:E(),pollInterval:re(we()),statusMessage:re(E())}),mr=He.extend({task:Br}),$_=rr.merge(Br),Ss=ut.extend({method:te("notifications/tasks/status"),params:$_}),La=Le.extend({method:te("tasks/get"),params:et.extend({taskId:E()})}),Ua=He.merge(Br),Da=Le.extend({method:te("tasks/result"),params:et.extend({taskId:E()})}),Va=Jr.extend({method:te("tasks/list")}),Fa=Kr.extend({tasks:H(Br)}),S_=Le.extend({method:te("tasks/cancel"),params:et.extend({taskId:E()})}),T_=He.merge(Br),ju=U({uri:E(),mimeType:re(E()),_meta:ze(E(),je()).optional()}),zu=ju.extend({text:E()}),Ha=E().refine(t=>{try{return atob(t),!0}catch{return!1}},{message:"Invalid Base64 string"}),Mu=ju.extend({blob:Ha}),_r=U({audience:H(Fe(["user","assistant"])).optional(),priority:we().min(0).max(1).optional(),lastModified:lu({offset:!0}).optional()}),qu=U({...pr.shape,...Wr.shape,uri:E(),description:re(E()),mimeType:re(E()),annotations:_r.optional(),_meta:re(Xe({}))}),E_=U({...pr.shape,...Wr.shape,uriTemplate:E(),description:re(E()),mimeType:re(E()),annotations:_r.optional(),_meta:re(Xe({}))}),Ts=Jr.extend({method:te("resources/list")}),Zu=Kr.extend({resources:H(qu)}),Wa=Jr.extend({method:te("resources/templates/list")}),Lu=Kr.extend({resourceTemplates:H(E_)}),Ja=et.extend({uri:E()}),R_=Ja,Ka=Le.extend({method:te("resources/read"),params:R_}),Uu=He.extend({contents:H(xe([zu,Mu]))}),Du=ut.extend({method:te("notifications/resources/list_changed")}),P_=Ja,Vu=Le.extend({method:te("resources/subscribe"),params:P_}),x_=Ja,Fu=Le.extend({method:te("resources/unsubscribe"),params:x_}),I_=rr.extend({uri:E()}),Hu=ut.extend({method:te("notifications/resources/updated"),params:I_}),C_=U({name:E(),description:re(E()),required:re(Pe())}),O_=U({...pr.shape,...Wr.shape,description:re(E()),arguments:re(H(C_)),_meta:re(Xe({}))}),Ba=Jr.extend({method:te("prompts/list")}),Wu=Kr.extend({prompts:H(O_)}),N_=et.extend({name:E(),arguments:ze(E(),E()).optional()}),Ga=Le.extend({method:te("prompts/get"),params:N_}),Ya=U({type:te("text"),text:E(),annotations:_r.optional(),_meta:ze(E(),je()).optional()}),Qa=U({type:te("image"),data:Ha,mimeType:E(),annotations:_r.optional(),_meta:ze(E(),je()).optional()}),Xa=U({type:te("audio"),data:Ha,mimeType:E(),annotations:_r.optional(),_meta:ze(E(),je()).optional()}),A_=U({type:te("tool_use"),name:E(),id:E(),input:U({}).passthrough(),_meta:re(U({}).passthrough())}).passthrough(),j_=U({type:te("resource"),resource:xe([zu,Mu]),annotations:_r.optional(),_meta:ze(E(),je()).optional()}),z_=qu.extend({type:te("resource_link")}),ei=xe([Ya,Qa,Xa,z_,j_]),M_=U({role:Fe(["user","assistant"]),content:ei}),Ju=He.extend({description:re(E()),messages:H(M_)}),Ku=ut.extend({method:te("notifications/prompts/list_changed")}),q_=U({title:E().optional(),readOnlyHint:Pe().optional(),destructiveHint:Pe().optional(),idempotentHint:Pe().optional(),openWorldHint:Pe().optional()}),Z_=U({taskSupport:Fe(["required","optional","forbidden"]).optional()}),Bu=U({...pr.shape,...Wr.shape,description:E().optional(),inputSchema:U({type:te("object"),properties:ze(E(),St).optional(),required:H(E()).optional()}).catchall(je()),outputSchema:U({type:te("object"),properties:ze(E(),St).optional(),required:H(E()).optional()}).catchall(je()).optional(),annotations:re(q_),execution:re(Z_),_meta:ze(E(),je()).optional()}),ti=Jr.extend({method:te("tools/list")}),Gu=Kr.extend({tools:H(Bu)}),vr=He.extend({content:H(ei).default([]),structuredContent:ze(E(),je()).optional(),isError:re(Pe())});vr.or(He.extend({toolResult:je()}));const L_=et.extend({name:E(),arguments:re(ze(E(),je()))}),Es=Le.extend({method:te("tools/call"),params:L_}),Yu=ut.extend({method:te("notifications/tools/list_changed")}),Rs=Fe(["debug","info","notice","warning","error","critical","alert","emergency"]),U_=et.extend({level:Rs}),Ps=Le.extend({method:te("logging/setLevel"),params:U_}),D_=rr.extend({level:Rs,logger:E().optional(),data:je()}),Qu=ut.extend({method:te("notifications/message"),params:D_}),V_=U({name:E().optional()}),F_=U({hints:re(H(V_)),costPriority:re(we().min(0).max(1)),speedPriority:re(we().min(0).max(1)),intelligencePriority:re(we().min(0).max(1))}),H_=U({mode:re(Fe(["auto","required","none"]))}),W_=U({type:te("tool_result"),toolUseId:E().describe("The unique identifier for the corresponding tool call."),content:H(ei).default([]),structuredContent:U({}).passthrough().optional(),isError:re(Pe()),_meta:re(U({}).passthrough())}).passthrough(),J_=gu("type",[Ya,Qa,Xa]),xs=gu("type",[Ya,Qa,Xa,A_,W_]),K_=U({role:Fe(["user","assistant"]),content:xe([xs,H(xs)]),_meta:re(U({}).passthrough())}).passthrough(),B_=et.extend({messages:H(K_),modelPreferences:F_.optional(),systemPrompt:E().optional(),includeContext:Fe(["none","thisServer","allServers"]).optional(),temperature:we().optional(),maxTokens:we().int(),stopSequences:H(E()).optional(),metadata:St.optional(),tools:re(H(Bu)),toolChoice:re(H_)}),ri=Le.extend({method:te("sampling/createMessage"),params:B_}),Is=He.extend({model:E(),stopReason:re(Fe(["endTurn","stopSequence","maxTokens"]).or(E())),role:Fe(["user","assistant"]),content:J_}),Xu=He.extend({model:E(),stopReason:re(Fe(["endTurn","stopSequence","maxTokens","toolUse"]).or(E())),role:Fe(["user","assistant"]),content:xe([xs,H(xs)])}),G_=U({type:te("boolean"),title:E().optional(),description:E().optional(),default:Pe().optional()}),Y_=U({type:te("string"),title:E().optional(),description:E().optional(),minLength:we().optional(),maxLength:we().optional(),format:Fe(["email","uri","date","date-time"]).optional(),default:E().optional()}),Q_=U({type:Fe(["number","integer"]),title:E().optional(),description:E().optional(),minimum:we().optional(),maximum:we().optional(),default:we().optional()}),X_=U({type:te("string"),title:E().optional(),description:E().optional(),enum:H(E()),default:E().optional()}),ev=U({type:te("string"),title:E().optional(),description:E().optional(),oneOf:H(U({const:E(),title:E()})),default:E().optional()}),tv=U({type:te("string"),title:E().optional(),description:E().optional(),enum:H(E()),enumNames:H(E()).optional(),default:E().optional()}),rv=xe([X_,ev]),nv=U({type:te("array"),title:E().optional(),description:E().optional(),minItems:we().optional(),maxItems:we().optional(),items:U({type:te("string"),enum:H(E())}),default:H(E()).optional()}),sv=U({type:te("array"),title:E().optional(),description:E().optional(),minItems:we().optional(),maxItems:we().optional(),items:U({anyOf:H(U({const:E(),title:E()}))}),default:H(E()).optional()}),av=xe([nv,sv]),iv=xe([tv,rv,av]),ov=xe([iv,G_,Y_,Q_]),cv=et.extend({mode:te("form").optional(),message:E(),requestedSchema:U({type:te("object"),properties:ze(E(),ov),required:H(E()).optional()})}),uv=et.extend({mode:te("url"),message:E(),elicitationId:E(),url:E().url()}),lv=xe([cv,uv]),ni=Le.extend({method:te("elicitation/create"),params:lv}),dv=rr.extend({elicitationId:E()}),fv=ut.extend({method:te("notifications/elicitation/complete"),params:dv}),Gr=He.extend({action:Fe(["accept","decline","cancel"]),content:Su(t=>t===null?void 0:t,ze(E(),xe([E(),we(),Pe(),H(E())])).optional())}),hv=U({type:te("ref/resource"),uri:E()}),pv=U({type:te("ref/prompt"),name:E()}),mv=et.extend({ref:xe([pv,hv]),argument:U({name:E(),value:E()}),context:U({arguments:ze(E(),E()).optional()}).optional()}),si=Le.extend({method:te("completion/complete"),params:mv});function _v(t){if(t.params.ref.type!=="ref/prompt")throw new TypeError(`Expected CompleteRequestPrompt, but got ${t.params.ref.type}`)}function vv(t){if(t.params.ref.type!=="ref/resource")throw new TypeError(`Expected CompleteRequestResourceTemplate, but got ${t.params.ref.type}`)}const el=He.extend({completion:Xe({values:H(E()).max(100),total:re(we().int()),hasMore:re(Pe())})}),gv=U({uri:E().startsWith("file://"),name:E().optional(),_meta:ze(E(),je()).optional()}),tl=Le.extend({method:te("roots/list")}),ai=He.extend({roots:H(gv)}),rl=ut.extend({method:te("notifications/roots/list_changed")});xe([qa,Nu,si,Ps,Ga,Ba,Ts,Wa,Ka,Vu,Fu,Es,ti,La,Da,Va]),xe([za,Za,Ma,rl,Ss]),xe([Ft,Is,Xu,Gr,ai,Ua,Fa,mr]),xe([qa,ri,ni,tl,La,Da,Va]),xe([za,Za,Qu,Hu,Du,Yu,Ku,Ss,fv]),xe([Ft,Au,el,Ju,Wu,Zu,Lu,Uu,vr,Gu,Ua,Fa,mr]);class J extends Error{constructor(e,r,n){super(`MCP error ${e}: ${r}`),this.code=e,this.data=n,this.name="McpError"}static fromError(e,r,n){if(e===G.UrlElicitationRequired&&n){const s=n;if(s.elicitations)return new yv(s.elicitations,r)}return new J(e,r,n)}}class yv extends J{constructor(e,r=`URL elicitation${e.length>1?"s":""} required`){super(G.UrlElicitationRequired,r,{elicitations:e})}get elicitations(){var e,r;return(r=(e=this.data)===null||e===void 0?void 0:e.elicitations)!==null&&r!==void 0?r:[]}}var fe;(function(t){t.assertEqual=s=>{};function e(s){}t.assertIs=e;function r(s){throw new Error}t.assertNever=r,t.arrayToEnum=s=>{const a={};for(const i of s)a[i]=i;return a},t.getValidEnumValues=s=>{const a=t.objectKeys(s).filter(o=>typeof s[s[o]]!="number"),i={};for(const o of a)i[o]=s[o];return t.objectValues(i)},t.objectValues=s=>t.objectKeys(s).map(function(a){return s[a]}),t.objectKeys=typeof Object.keys=="function"?s=>Object.keys(s):s=>{const a=[];for(const i in s)Object.prototype.hasOwnProperty.call(s,i)&&a.push(i);return a},t.find=(s,a)=>{for(const i of s)if(a(i))return i},t.isInteger=typeof Number.isInteger=="function"?s=>Number.isInteger(s):s=>typeof s=="number"&&Number.isFinite(s)&&Math.floor(s)===s;function n(s,a=" | "){return s.map(i=>typeof i=="string"?`'${i}'`:i).join(a)}t.joinValues=n,t.jsonStringifyReplacer=(s,a)=>typeof a=="bigint"?a.toString():a})(fe||(fe={}));var ii;(function(t){t.mergeShapes=(e,r)=>({...e,...r})})(ii||(ii={}));const K=fe.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),At=t=>{switch(typeof t){case"undefined":return K.undefined;case"string":return K.string;case"number":return Number.isNaN(t)?K.nan:K.number;case"boolean":return K.boolean;case"function":return K.function;case"bigint":return K.bigint;case"symbol":return K.symbol;case"object":return Array.isArray(t)?K.array:t===null?K.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?K.promise:typeof Map<"u"&&t instanceof Map?K.map:typeof Set<"u"&&t instanceof Set?K.set:typeof Date<"u"&&t instanceof Date?K.date:K.object;default:return K.unknown}},Z=fe.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),wv=t=>JSON.stringify(t,null,2).replace(/"([^"]+)":/g,"$1:");class ot extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};const r=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,r):this.__proto__=r,this.name="ZodError",this.issues=e}format(e){const r=e||function(a){return a.message},n={_errors:[]},s=a=>{for(const i of a.issues)if(i.code==="invalid_union")i.unionErrors.map(s);else if(i.code==="invalid_return_type")s(i.returnTypeError);else if(i.code==="invalid_arguments")s(i.argumentsError);else if(i.path.length===0)n._errors.push(r(i));else{let o=n,c=0;for(;c<i.path.length;){const l=i.path[c];c===i.path.length-1?(o[l]=o[l]||{_errors:[]},o[l]._errors.push(r(i))):o[l]=o[l]||{_errors:[]},o=o[l],c++}}};return s(this),n}static assert(e){if(!(e instanceof ot))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,fe.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=r=>r.message){const r={},n=[];for(const s of this.issues)if(s.path.length>0){const a=s.path[0];r[a]=r[a]||[],r[a].push(e(s))}else n.push(e(s));return{formErrors:n,fieldErrors:r}}get formErrors(){return this.flatten()}}ot.create=t=>new ot(t);const gr=(t,e)=>{let r;switch(t.code){case Z.invalid_type:t.received===K.undefined?r="Required":r=`Expected ${t.expected}, received ${t.received}`;break;case Z.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(t.expected,fe.jsonStringifyReplacer)}`;break;case Z.unrecognized_keys:r=`Unrecognized key(s) in object: ${fe.joinValues(t.keys,", ")}`;break;case Z.invalid_union:r="Invalid input";break;case Z.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${fe.joinValues(t.options)}`;break;case Z.invalid_enum_value:r=`Invalid enum value. Expected ${fe.joinValues(t.options)}, received '${t.received}'`;break;case Z.invalid_arguments:r="Invalid function arguments";break;case Z.invalid_return_type:r="Invalid function return type";break;case Z.invalid_date:r="Invalid date";break;case Z.invalid_string:typeof t.validation=="object"?"includes"in t.validation?(r=`Invalid input: must include "${t.validation.includes}"`,typeof t.validation.position=="number"&&(r=`${r} at one or more positions greater than or equal to ${t.validation.position}`)):"startsWith"in t.validation?r=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?r=`Invalid input: must end with "${t.validation.endsWith}"`:fe.assertNever(t.validation):t.validation!=="regex"?r=`Invalid ${t.validation}`:r="Invalid";break;case Z.too_small:t.type==="array"?r=`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:t.type==="string"?r=`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:t.type==="number"?r=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="bigint"?r=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="date"?r=`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(t.minimum))}`:r="Invalid input";break;case Z.too_big:t.type==="array"?r=`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:t.type==="string"?r=`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:t.type==="number"?r=`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="bigint"?r=`BigInt must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="date"?r=`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(t.maximum))}`:r="Invalid input";break;case Z.custom:r="Invalid input";break;case Z.invalid_intersection_types:r="Intersection results could not be merged";break;case Z.not_multiple_of:r=`Number must be a multiple of ${t.multipleOf}`;break;case Z.not_finite:r="Number must be finite";break;default:r=e.defaultError,fe.assertNever(t)}return{message:r}};let nl=gr;function bv(t){nl=t}function Cs(){return nl}const Os=t=>{const{data:e,path:r,errorMaps:n,issueData:s}=t,a=[...r,...s.path||[]],i={...s,path:a};if(s.message!==void 0)return{...s,path:a,message:s.message};let o="";const c=n.filter(l=>!!l).slice().reverse();for(const l of c)o=l(i,{data:e,defaultError:o}).message;return{...s,path:a,message:o}},kv=[];function W(t,e){const r=Cs(),n=Os({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,r,r===gr?void 0:gr].filter(s=>!!s)});t.common.issues.push(n)}class We{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,r){const n=[];for(const s of r){if(s.status==="aborted")return ae;s.status==="dirty"&&e.dirty(),n.push(s.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,r){const n=[];for(const s of r){const a=await s.key,i=await s.value;n.push({key:a,value:i})}return We.mergeObjectSync(e,n)}static mergeObjectSync(e,r){const n={};for(const s of r){const{key:a,value:i}=s;if(a.status==="aborted"||i.status==="aborted")return ae;a.status==="dirty"&&e.dirty(),i.status==="dirty"&&e.dirty(),a.value!=="__proto__"&&(typeof i.value<"u"||s.alwaysSet)&&(n[a.value]=i.value)}return{status:e.value,value:n}}}const ae=Object.freeze({status:"aborted"}),yr=t=>({status:"dirty",value:t}),Ke=t=>({status:"valid",value:t}),oi=t=>t.status==="aborted",ci=t=>t.status==="dirty",sr=t=>t.status==="valid",Yr=t=>typeof Promise<"u"&&t instanceof Promise;var X;(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e?.message})(X||(X={}));class Tt{constructor(e,r,n,s){this._cachedPath=[],this.parent=e,this.data=r,this._path=n,this._key=s}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const sl=(t,e)=>{if(sr(e))return{success:!0,data:e.value};if(!t.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const r=new ot(t.common.issues);return this._error=r,this._error}}};function ie(t){if(!t)return{};const{errorMap:e,invalid_type_error:r,required_error:n,description:s}=t;if(e&&(r||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:s}:{errorMap:(i,o)=>{const{message:c}=t;return i.code==="invalid_enum_value"?{message:c??o.defaultError}:typeof o.data>"u"?{message:c??n??o.defaultError}:i.code!=="invalid_type"?{message:o.defaultError}:{message:c??r??o.defaultError}},description:s}}class oe{get description(){return this._def.description}_getType(e){return At(e.data)}_getOrReturnCtx(e,r){return r||{common:e.parent.common,data:e.data,parsedType:At(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new We,ctx:{common:e.parent.common,data:e.data,parsedType:At(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const r=this._parse(e);if(Yr(r))throw new Error("Synchronous parse encountered promise.");return r}_parseAsync(e){const r=this._parse(e);return Promise.resolve(r)}parse(e,r){const n=this.safeParse(e,r);if(n.success)return n.data;throw n.error}safeParse(e,r){const n={common:{issues:[],async:r?.async??!1,contextualErrorMap:r?.errorMap},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:At(e)},s=this._parseSync({data:e,path:n.path,parent:n});return sl(n,s)}"~validate"(e){const r={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:At(e)};if(!this["~standard"].async)try{const n=this._parseSync({data:e,path:[],parent:r});return sr(n)?{value:n.value}:{issues:r.common.issues}}catch(n){n?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),r.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:r}).then(n=>sr(n)?{value:n.value}:{issues:r.common.issues})}async parseAsync(e,r){const n=await this.safeParseAsync(e,r);if(n.success)return n.data;throw n.error}async safeParseAsync(e,r){const n={common:{issues:[],contextualErrorMap:r?.errorMap,async:!0},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:At(e)},s=this._parse({data:e,path:n.path,parent:n}),a=await(Yr(s)?s:Promise.resolve(s));return sl(n,a)}refine(e,r){const n=s=>typeof r=="string"||typeof r>"u"?{message:r}:typeof r=="function"?r(s):r;return this._refinement((s,a)=>{const i=e(s),o=()=>a.addIssue({code:Z.custom,...n(s)});return typeof Promise<"u"&&i instanceof Promise?i.then(c=>c?!0:(o(),!1)):i?!0:(o(),!1)})}refinement(e,r){return this._refinement((n,s)=>e(n)?!0:(s.addIssue(typeof r=="function"?r(n,s):r),!1))}_refinement(e){return new vt({schema:this,typeName:L.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:r=>this["~validate"](r)}}optional(){return Rt.create(this,this._def)}nullable(){return Kt.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return _t.create(this)}promise(){return $r.create(this,this._def)}or(e){return tn.create([this,e],this._def)}and(e){return rn.create(this,e,this._def)}transform(e){return new vt({...ie(this._def),schema:this,typeName:L.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const r=typeof e=="function"?e:()=>e;return new cn({...ie(this._def),innerType:this,defaultValue:r,typeName:L.ZodDefault})}brand(){return new di({typeName:L.ZodBranded,type:this,...ie(this._def)})}catch(e){const r=typeof e=="function"?e:()=>e;return new un({...ie(this._def),innerType:this,catchValue:r,typeName:L.ZodCatch})}describe(e){const r=this.constructor;return new r({...this._def,description:e})}pipe(e){return ln.create(this,e)}readonly(){return dn.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const $v=/^c[^\s-]{8,}$/i,Sv=/^[0-9a-z]+$/,Tv=/^[0-9A-HJKMNP-TV-Z]{26}$/i,Ev=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,Rv=/^[a-z0-9_-]{21}$/i,Pv=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,xv=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,Iv=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Cv="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let ui;const Ov=/^(?:(?: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])$/,Nv=/^(?:(?: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])\/(3[0-2]|[12]?[0-9])$/,Av=/^(([0-9a-fA-F]{1,4}:){7,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}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,jv=/^(([0-9a-fA-F]{1,4}:){7,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}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,zv=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Mv=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,al="((\\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])))",qv=new RegExp(`^${al}$`);function il(t){let e="[0-5]\\d";t.precision?e=`${e}\\.\\d{${t.precision}}`:t.precision==null&&(e=`${e}(\\.\\d+)?`);const r=t.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${e})${r}`}function Zv(t){return new RegExp(`^${il(t)}$`)}function ol(t){let e=`${al}T${il(t)}`;const r=[];return r.push(t.local?"Z?":"Z"),t.offset&&r.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${r.join("|")})`,new RegExp(`^${e}$`)}function Lv(t,e){return!!((e==="v4"||!e)&&Ov.test(t)||(e==="v6"||!e)&&Av.test(t))}function Uv(t,e){if(!Pv.test(t))return!1;try{const[r]=t.split(".");if(!r)return!1;const n=r.replace(/-/g,"+").replace(/_/g,"/").padEnd(r.length+(4-r.length%4)%4,"="),s=JSON.parse(atob(n));return!(typeof s!="object"||s===null||"typ"in s&&s?.typ!=="JWT"||!s.alg||e&&s.alg!==e)}catch{return!1}}function Dv(t,e){return!!((e==="v4"||!e)&&Nv.test(t)||(e==="v6"||!e)&&jv.test(t))}class mt extends oe{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==K.string){const a=this._getOrReturnCtx(e);return W(a,{code:Z.invalid_type,expected:K.string,received:a.parsedType}),ae}const n=new We;let s;for(const a of this._def.checks)if(a.kind==="min")e.data.length<a.value&&(s=this._getOrReturnCtx(e,s),W(s,{code:Z.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),n.dirty());else if(a.kind==="max")e.data.length>a.value&&(s=this._getOrReturnCtx(e,s),W(s,{code:Z.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),n.dirty());else if(a.kind==="length"){const i=e.data.length>a.value,o=e.data.length<a.value;(i||o)&&(s=this._getOrReturnCtx(e,s),i?W(s,{code:Z.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}):o&&W(s,{code:Z.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}),n.dirty())}else if(a.kind==="email")Iv.test(e.data)||(s=this._getOrReturnCtx(e,s),W(s,{validation:"email",code:Z.invalid_string,message:a.message}),n.dirty());else if(a.kind==="emoji")ui||(ui=new RegExp(Cv,"u")),ui.test(e.data)||(s=this._getOrReturnCtx(e,s),W(s,{validation:"emoji",code:Z.invalid_string,message:a.message}),n.dirty());else if(a.kind==="uuid")Ev.test(e.data)||(s=this._getOrReturnCtx(e,s),W(s,{validation:"uuid",code:Z.invalid_string,message:a.message}),n.dirty());else if(a.kind==="nanoid")Rv.test(e.data)||(s=this._getOrReturnCtx(e,s),W(s,{validation:"nanoid",code:Z.invalid_string,message:a.message}),n.dirty());else if(a.kind==="cuid")$v.test(e.data)||(s=this._getOrReturnCtx(e,s),W(s,{validation:"cuid",code:Z.invalid_string,message:a.message}),n.dirty());else if(a.kind==="cuid2")Sv.test(e.data)||(s=this._getOrReturnCtx(e,s),W(s,{validation:"cuid2",code:Z.invalid_string,message:a.message}),n.dirty());else if(a.kind==="ulid")Tv.test(e.data)||(s=this._getOrReturnCtx(e,s),W(s,{validation:"ulid",code:Z.invalid_string,message:a.message}),n.dirty());else if(a.kind==="url")try{new URL(e.data)}catch{s=this._getOrReturnCtx(e,s),W(s,{validation:"url",code:Z.invalid_string,message:a.message}),n.dirty()}else a.kind==="regex"?(a.regex.lastIndex=0,a.regex.test(e.data)||(s=this._getOrReturnCtx(e,s),W(s,{validation:"regex",code:Z.invalid_string,message:a.message}),n.dirty())):a.kind==="trim"?e.data=e.data.trim():a.kind==="includes"?e.data.includes(a.value,a.position)||(s=this._getOrReturnCtx(e,s),W(s,{code:Z.invalid_string,validation:{includes:a.value,position:a.position},message:a.message}),n.dirty()):a.kind==="toLowerCase"?e.data=e.data.toLowerCase():a.kind==="toUpperCase"?e.data=e.data.toUpperCase():a.kind==="startsWith"?e.data.startsWith(a.value)||(s=this._getOrReturnCtx(e,s),W(s,{code:Z.invalid_string,validation:{startsWith:a.value},message:a.message}),n.dirty()):a.kind==="endsWith"?e.data.endsWith(a.value)||(s=this._getOrReturnCtx(e,s),W(s,{code:Z.invalid_string,validation:{endsWith:a.value},message:a.message}),n.dirty()):a.kind==="datetime"?ol(a).test(e.data)||(s=this._getOrReturnCtx(e,s),W(s,{code:Z.invalid_string,validation:"datetime",message:a.message}),n.dirty()):a.kind==="date"?qv.test(e.data)||(s=this._getOrReturnCtx(e,s),W(s,{code:Z.invalid_string,validation:"date",message:a.message}),n.dirty()):a.kind==="time"?Zv(a).test(e.data)||(s=this._getOrReturnCtx(e,s),W(s,{code:Z.invalid_string,validation:"time",message:a.message}),n.dirty()):a.kind==="duration"?xv.test(e.data)||(s=this._getOrReturnCtx(e,s),W(s,{validation:"duration",code:Z.invalid_string,message:a.message}),n.dirty()):a.kind==="ip"?Lv(e.data,a.version)||(s=this._getOrReturnCtx(e,s),W(s,{validation:"ip",code:Z.invalid_string,message:a.message}),n.dirty()):a.kind==="jwt"?Uv(e.data,a.alg)||(s=this._getOrReturnCtx(e,s),W(s,{validation:"jwt",code:Z.invalid_string,message:a.message}),n.dirty()):a.kind==="cidr"?Dv(e.data,a.version)||(s=this._getOrReturnCtx(e,s),W(s,{validation:"cidr",code:Z.invalid_string,message:a.message}),n.dirty()):a.kind==="base64"?zv.test(e.data)||(s=this._getOrReturnCtx(e,s),W(s,{validation:"base64",code:Z.invalid_string,message:a.message}),n.dirty()):a.kind==="base64url"?Mv.test(e.data)||(s=this._getOrReturnCtx(e,s),W(s,{validation:"base64url",code:Z.invalid_string,message:a.message}),n.dirty()):fe.assertNever(a);return{status:n.value,value:e.data}}_regex(e,r,n){return this.refinement(s=>e.test(s),{validation:r,code:Z.invalid_string,...X.errToObj(n)})}_addCheck(e){return new mt({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...X.errToObj(e)})}url(e){return this._addCheck({kind:"url",...X.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...X.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...X.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...X.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...X.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...X.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...X.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...X.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...X.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...X.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...X.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...X.errToObj(e)})}datetime(e){return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof e?.precision>"u"?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...X.errToObj(e?.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof e?.precision>"u"?null:e?.precision,...X.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...X.errToObj(e)})}regex(e,r){return this._addCheck({kind:"regex",regex:e,...X.errToObj(r)})}includes(e,r){return this._addCheck({kind:"includes",value:e,position:r?.position,...X.errToObj(r?.message)})}startsWith(e,r){return this._addCheck({kind:"startsWith",value:e,...X.errToObj(r)})}endsWith(e,r){return this._addCheck({kind:"endsWith",value:e,...X.errToObj(r)})}min(e,r){return this._addCheck({kind:"min",value:e,...X.errToObj(r)})}max(e,r){return this._addCheck({kind:"max",value:e,...X.errToObj(r)})}length(e,r){return this._addCheck({kind:"length",value:e,...X.errToObj(r)})}nonempty(e){return this.min(1,X.errToObj(e))}trim(){return new mt({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new mt({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new mt({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isCIDR(){return!!this._def.checks.find(e=>e.kind==="cidr")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get isBase64url(){return!!this._def.checks.find(e=>e.kind==="base64url")}get minLength(){let e=null;for(const r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxLength(){let e=null;for(const r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}}mt.create=t=>new mt({checks:[],typeName:L.ZodString,coerce:t?.coerce??!1,...ie(t)});function Vv(t,e){const r=(t.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,s=r>n?r:n,a=Number.parseInt(t.toFixed(s).replace(".","")),i=Number.parseInt(e.toFixed(s).replace(".",""));return a%i/10**s}class Ht extends oe{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==K.number){const a=this._getOrReturnCtx(e);return W(a,{code:Z.invalid_type,expected:K.number,received:a.parsedType}),ae}let n;const s=new We;for(const a of this._def.checks)a.kind==="int"?fe.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),W(n,{code:Z.invalid_type,expected:"integer",received:"float",message:a.message}),s.dirty()):a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(n=this._getOrReturnCtx(e,n),W(n,{code:Z.too_small,minimum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),s.dirty()):a.kind==="max"?(a.inclusive?e.data>a.value:e.data>=a.value)&&(n=this._getOrReturnCtx(e,n),W(n,{code:Z.too_big,maximum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),s.dirty()):a.kind==="multipleOf"?Vv(e.data,a.value)!==0&&(n=this._getOrReturnCtx(e,n),W(n,{code:Z.not_multiple_of,multipleOf:a.value,message:a.message}),s.dirty()):a.kind==="finite"?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),W(n,{code:Z.not_finite,message:a.message}),s.dirty()):fe.assertNever(a);return{status:s.value,value:e.data}}gte(e,r){return this.setLimit("min",e,!0,X.toString(r))}gt(e,r){return this.setLimit("min",e,!1,X.toString(r))}lte(e,r){return this.setLimit("max",e,!0,X.toString(r))}lt(e,r){return this.setLimit("max",e,!1,X.toString(r))}setLimit(e,r,n,s){return new Ht({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:n,message:X.toString(s)}]})}_addCheck(e){return new Ht({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:X.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:X.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:X.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:X.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:X.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:X.toString(r)})}finite(e){return this._addCheck({kind:"finite",message:X.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:X.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:X.toString(e)})}get minValue(){let e=null;for(const r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxValue(){let e=null;for(const r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&fe.isInteger(e.value))}get isFinite(){let e=null,r=null;for(const n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(r===null||n.value>r)&&(r=n.value):n.kind==="max"&&(e===null||n.value<e)&&(e=n.value)}return Number.isFinite(r)&&Number.isFinite(e)}}Ht.create=t=>new Ht({checks:[],typeName:L.ZodNumber,coerce:t?.coerce||!1,...ie(t)});class Wt extends oe{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==K.bigint)return this._getInvalidInput(e);let n;const s=new We;for(const a of this._def.checks)a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(n=this._getOrReturnCtx(e,n),W(n,{code:Z.too_small,type:"bigint",minimum:a.value,inclusive:a.inclusive,message:a.message}),s.dirty()):a.kind==="max"?(a.inclusive?e.data>a.value:e.data>=a.value)&&(n=this._getOrReturnCtx(e,n),W(n,{code:Z.too_big,type:"bigint",maximum:a.value,inclusive:a.inclusive,message:a.message}),s.dirty()):a.kind==="multipleOf"?e.data%a.value!==BigInt(0)&&(n=this._getOrReturnCtx(e,n),W(n,{code:Z.not_multiple_of,multipleOf:a.value,message:a.message}),s.dirty()):fe.assertNever(a);return{status:s.value,value:e.data}}_getInvalidInput(e){const r=this._getOrReturnCtx(e);return W(r,{code:Z.invalid_type,expected:K.bigint,received:r.parsedType}),ae}gte(e,r){return this.setLimit("min",e,!0,X.toString(r))}gt(e,r){return this.setLimit("min",e,!1,X.toString(r))}lte(e,r){return this.setLimit("max",e,!0,X.toString(r))}lt(e,r){return this.setLimit("max",e,!1,X.toString(r))}setLimit(e,r,n,s){return new Wt({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:n,message:X.toString(s)}]})}_addCheck(e){return new Wt({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:X.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:X.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:X.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:X.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:X.toString(r)})}get minValue(){let e=null;for(const r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxValue(){let e=null;for(const r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}}Wt.create=t=>new Wt({checks:[],typeName:L.ZodBigInt,coerce:t?.coerce??!1,...ie(t)});class Qr extends oe{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==K.boolean){const n=this._getOrReturnCtx(e);return W(n,{code:Z.invalid_type,expected:K.boolean,received:n.parsedType}),ae}return Ke(e.data)}}Qr.create=t=>new Qr({typeName:L.ZodBoolean,coerce:t?.coerce||!1,...ie(t)});class ar extends oe{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==K.date){const a=this._getOrReturnCtx(e);return W(a,{code:Z.invalid_type,expected:K.date,received:a.parsedType}),ae}if(Number.isNaN(e.data.getTime())){const a=this._getOrReturnCtx(e);return W(a,{code:Z.invalid_date}),ae}const n=new We;let s;for(const a of this._def.checks)a.kind==="min"?e.data.getTime()<a.value&&(s=this._getOrReturnCtx(e,s),W(s,{code:Z.too_small,message:a.message,inclusive:!0,exact:!1,minimum:a.value,type:"date"}),n.dirty()):a.kind==="max"?e.data.getTime()>a.value&&(s=this._getOrReturnCtx(e,s),W(s,{code:Z.too_big,message:a.message,inclusive:!0,exact:!1,maximum:a.value,type:"date"}),n.dirty()):fe.assertNever(a);return{status:n.value,value:new Date(e.data.getTime())}}_addCheck(e){return new ar({...this._def,checks:[...this._def.checks,e]})}min(e,r){return this._addCheck({kind:"min",value:e.getTime(),message:X.toString(r)})}max(e,r){return this._addCheck({kind:"max",value:e.getTime(),message:X.toString(r)})}get minDate(){let e=null;for(const r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(const r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e!=null?new Date(e):null}}ar.create=t=>new ar({checks:[],coerce:t?.coerce||!1,typeName:L.ZodDate,...ie(t)});class Ns extends oe{_parse(e){if(this._getType(e)!==K.symbol){const n=this._getOrReturnCtx(e);return W(n,{code:Z.invalid_type,expected:K.symbol,received:n.parsedType}),ae}return Ke(e.data)}}Ns.create=t=>new Ns({typeName:L.ZodSymbol,...ie(t)});class Xr extends oe{_parse(e){if(this._getType(e)!==K.undefined){const n=this._getOrReturnCtx(e);return W(n,{code:Z.invalid_type,expected:K.undefined,received:n.parsedType}),ae}return Ke(e.data)}}Xr.create=t=>new Xr({typeName:L.ZodUndefined,...ie(t)});class en extends oe{_parse(e){if(this._getType(e)!==K.null){const n=this._getOrReturnCtx(e);return W(n,{code:Z.invalid_type,expected:K.null,received:n.parsedType}),ae}return Ke(e.data)}}en.create=t=>new en({typeName:L.ZodNull,...ie(t)});class wr extends oe{constructor(){super(...arguments),this._any=!0}_parse(e){return Ke(e.data)}}wr.create=t=>new wr({typeName:L.ZodAny,...ie(t)});class ir extends oe{constructor(){super(...arguments),this._unknown=!0}_parse(e){return Ke(e.data)}}ir.create=t=>new ir({typeName:L.ZodUnknown,...ie(t)});class jt extends oe{_parse(e){const r=this._getOrReturnCtx(e);return W(r,{code:Z.invalid_type,expected:K.never,received:r.parsedType}),ae}}jt.create=t=>new jt({typeName:L.ZodNever,...ie(t)});class As extends oe{_parse(e){if(this._getType(e)!==K.undefined){const n=this._getOrReturnCtx(e);return W(n,{code:Z.invalid_type,expected:K.void,received:n.parsedType}),ae}return Ke(e.data)}}As.create=t=>new As({typeName:L.ZodVoid,...ie(t)});class _t extends oe{_parse(e){const{ctx:r,status:n}=this._processInputParams(e),s=this._def;if(r.parsedType!==K.array)return W(r,{code:Z.invalid_type,expected:K.array,received:r.parsedType}),ae;if(s.exactLength!==null){const i=r.data.length>s.exactLength.value,o=r.data.length<s.exactLength.value;(i||o)&&(W(r,{code:i?Z.too_big:Z.too_small,minimum:o?s.exactLength.value:void 0,maximum:i?s.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:s.exactLength.message}),n.dirty())}if(s.minLength!==null&&r.data.length<s.minLength.value&&(W(r,{code:Z.too_small,minimum:s.minLength.value,type:"array",inclusive:!0,exact:!1,message:s.minLength.message}),n.dirty()),s.maxLength!==null&&r.data.length>s.maxLength.value&&(W(r,{code:Z.too_big,maximum:s.maxLength.value,type:"array",inclusive:!0,exact:!1,message:s.maxLength.message}),n.dirty()),r.common.async)return Promise.all([...r.data].map((i,o)=>s.type._parseAsync(new Tt(r,i,r.path,o)))).then(i=>We.mergeArray(n,i));const a=[...r.data].map((i,o)=>s.type._parseSync(new Tt(r,i,r.path,o)));return We.mergeArray(n,a)}get element(){return this._def.type}min(e,r){return new _t({...this._def,minLength:{value:e,message:X.toString(r)}})}max(e,r){return new _t({...this._def,maxLength:{value:e,message:X.toString(r)}})}length(e,r){return new _t({...this._def,exactLength:{value:e,message:X.toString(r)}})}nonempty(e){return this.min(1,e)}}_t.create=(t,e)=>new _t({type:t,minLength:null,maxLength:null,exactLength:null,typeName:L.ZodArray,...ie(e)});function br(t){if(t instanceof Oe){const e={};for(const r in t.shape){const n=t.shape[r];e[r]=Rt.create(br(n))}return new Oe({...t._def,shape:()=>e})}else return t instanceof _t?new _t({...t._def,type:br(t.element)}):t instanceof Rt?Rt.create(br(t.unwrap())):t instanceof Kt?Kt.create(br(t.unwrap())):t instanceof Et?Et.create(t.items.map(e=>br(e))):t}class Oe extends oe{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const e=this._def.shape(),r=fe.objectKeys(e);return this._cached={shape:e,keys:r},this._cached}_parse(e){if(this._getType(e)!==K.object){const l=this._getOrReturnCtx(e);return W(l,{code:Z.invalid_type,expected:K.object,received:l.parsedType}),ae}const{status:n,ctx:s}=this._processInputParams(e),{shape:a,keys:i}=this._getCached(),o=[];if(!(this._def.catchall instanceof jt&&this._def.unknownKeys==="strip"))for(const l in s.data)i.includes(l)||o.push(l);const c=[];for(const l of i){const u=a[l],d=s.data[l];c.push({key:{status:"valid",value:l},value:u._parse(new Tt(s,d,s.path,l)),alwaysSet:l in s.data})}if(this._def.catchall instanceof jt){const l=this._def.unknownKeys;if(l==="passthrough")for(const u of o)c.push({key:{status:"valid",value:u},value:{status:"valid",value:s.data[u]}});else if(l==="strict")o.length>0&&(W(s,{code:Z.unrecognized_keys,keys:o}),n.dirty());else if(l!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const l=this._def.catchall;for(const u of o){const d=s.data[u];c.push({key:{status:"valid",value:u},value:l._parse(new Tt(s,d,s.path,u)),alwaysSet:u in s.data})}}return s.common.async?Promise.resolve().then(async()=>{const l=[];for(const u of c){const d=await u.key,g=await u.value;l.push({key:d,value:g,alwaysSet:u.alwaysSet})}return l}).then(l=>We.mergeObjectSync(n,l)):We.mergeObjectSync(n,c)}get shape(){return this._def.shape()}strict(e){return X.errToObj,new Oe({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(r,n)=>{const s=this._def.errorMap?.(r,n).message??n.defaultError;return r.code==="unrecognized_keys"?{message:X.errToObj(e).message??s}:{message:s}}}:{}})}strip(){return new Oe({...this._def,unknownKeys:"strip"})}passthrough(){return new Oe({...this._def,unknownKeys:"passthrough"})}extend(e){return new Oe({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new Oe({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:L.ZodObject})}setKey(e,r){return this.augment({[e]:r})}catchall(e){return new Oe({...this._def,catchall:e})}pick(e){const r={};for(const n of fe.objectKeys(e))e[n]&&this.shape[n]&&(r[n]=this.shape[n]);return new Oe({...this._def,shape:()=>r})}omit(e){const r={};for(const n of fe.objectKeys(this.shape))e[n]||(r[n]=this.shape[n]);return new Oe({...this._def,shape:()=>r})}deepPartial(){return br(this)}partial(e){const r={};for(const n of fe.objectKeys(this.shape)){const s=this.shape[n];e&&!e[n]?r[n]=s:r[n]=s.optional()}return new Oe({...this._def,shape:()=>r})}required(e){const r={};for(const n of fe.objectKeys(this.shape))if(e&&!e[n])r[n]=this.shape[n];else{let a=this.shape[n];for(;a instanceof Rt;)a=a._def.innerType;r[n]=a}return new Oe({...this._def,shape:()=>r})}keyof(){return cl(fe.objectKeys(this.shape))}}Oe.create=(t,e)=>new Oe({shape:()=>t,unknownKeys:"strip",catchall:jt.create(),typeName:L.ZodObject,...ie(e)}),Oe.strictCreate=(t,e)=>new Oe({shape:()=>t,unknownKeys:"strict",catchall:jt.create(),typeName:L.ZodObject,...ie(e)}),Oe.lazycreate=(t,e)=>new Oe({shape:t,unknownKeys:"strip",catchall:jt.create(),typeName:L.ZodObject,...ie(e)});class tn extends oe{_parse(e){const{ctx:r}=this._processInputParams(e),n=this._def.options;function s(a){for(const o of a)if(o.result.status==="valid")return o.result;for(const o of a)if(o.result.status==="dirty")return r.common.issues.push(...o.ctx.common.issues),o.result;const i=a.map(o=>new ot(o.ctx.common.issues));return W(r,{code:Z.invalid_union,unionErrors:i}),ae}if(r.common.async)return Promise.all(n.map(async a=>{const i={...r,common:{...r.common,issues:[]},parent:null};return{result:await a._parseAsync({data:r.data,path:r.path,parent:i}),ctx:i}})).then(s);{let a;const i=[];for(const c of n){const l={...r,common:{...r.common,issues:[]},parent:null},u=c._parseSync({data:r.data,path:r.path,parent:l});if(u.status==="valid")return u;u.status==="dirty"&&!a&&(a={result:u,ctx:l}),l.common.issues.length&&i.push(l.common.issues)}if(a)return r.common.issues.push(...a.ctx.common.issues),a.result;const o=i.map(c=>new ot(c));return W(r,{code:Z.invalid_union,unionErrors:o}),ae}}get options(){return this._def.options}}tn.create=(t,e)=>new tn({options:t,typeName:L.ZodUnion,...ie(e)});const zt=t=>t instanceof sn?zt(t.schema):t instanceof vt?zt(t.innerType()):t instanceof an?[t.value]:t instanceof Jt?t.options:t instanceof on?fe.objectValues(t.enum):t instanceof cn?zt(t._def.innerType):t instanceof Xr?[void 0]:t instanceof en?[null]:t instanceof Rt?[void 0,...zt(t.unwrap())]:t instanceof Kt?[null,...zt(t.unwrap())]:t instanceof di||t instanceof dn?zt(t.unwrap()):t instanceof un?zt(t._def.innerType):[];class js extends oe{_parse(e){const{ctx:r}=this._processInputParams(e);if(r.parsedType!==K.object)return W(r,{code:Z.invalid_type,expected:K.object,received:r.parsedType}),ae;const n=this.discriminator,s=r.data[n],a=this.optionsMap.get(s);return a?r.common.async?a._parseAsync({data:r.data,path:r.path,parent:r}):a._parseSync({data:r.data,path:r.path,parent:r}):(W(r,{code:Z.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),ae)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,r,n){const s=new Map;for(const a of r){const i=zt(a.shape[e]);if(!i.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const o of i){if(s.has(o))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(o)}`);s.set(o,a)}}return new js({typeName:L.ZodDiscriminatedUnion,discriminator:e,options:r,optionsMap:s,...ie(n)})}}function li(t,e){const r=At(t),n=At(e);if(t===e)return{valid:!0,data:t};if(r===K.object&&n===K.object){const s=fe.objectKeys(e),a=fe.objectKeys(t).filter(o=>s.indexOf(o)!==-1),i={...t,...e};for(const o of a){const c=li(t[o],e[o]);if(!c.valid)return{valid:!1};i[o]=c.data}return{valid:!0,data:i}}else if(r===K.array&&n===K.array){if(t.length!==e.length)return{valid:!1};const s=[];for(let a=0;a<t.length;a++){const i=t[a],o=e[a],c=li(i,o);if(!c.valid)return{valid:!1};s.push(c.data)}return{valid:!0,data:s}}else return r===K.date&&n===K.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}class rn extends oe{_parse(e){const{status:r,ctx:n}=this._processInputParams(e),s=(a,i)=>{if(oi(a)||oi(i))return ae;const o=li(a.value,i.value);return o.valid?((ci(a)||ci(i))&&r.dirty(),{status:r.value,value:o.data}):(W(n,{code:Z.invalid_intersection_types}),ae)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([a,i])=>s(a,i)):s(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}}rn.create=(t,e,r)=>new rn({left:t,right:e,typeName:L.ZodIntersection,...ie(r)});class Et extends oe{_parse(e){const{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==K.array)return W(n,{code:Z.invalid_type,expected:K.array,received:n.parsedType}),ae;if(n.data.length<this._def.items.length)return W(n,{code:Z.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),ae;!this._def.rest&&n.data.length>this._def.items.length&&(W(n,{code:Z.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),r.dirty());const a=[...n.data].map((i,o)=>{const c=this._def.items[o]||this._def.rest;return c?c._parse(new Tt(n,i,n.path,o)):null}).filter(i=>!!i);return n.common.async?Promise.all(a).then(i=>We.mergeArray(r,i)):We.mergeArray(r,a)}get items(){return this._def.items}rest(e){return new Et({...this._def,rest:e})}}Et.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Et({items:t,typeName:L.ZodTuple,rest:null,...ie(e)})};class nn extends oe{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==K.object)return W(n,{code:Z.invalid_type,expected:K.object,received:n.parsedType}),ae;const s=[],a=this._def.keyType,i=this._def.valueType;for(const o in n.data)s.push({key:a._parse(new Tt(n,o,n.path,o)),value:i._parse(new Tt(n,n.data[o],n.path,o)),alwaysSet:o in n.data});return n.common.async?We.mergeObjectAsync(r,s):We.mergeObjectSync(r,s)}get element(){return this._def.valueType}static create(e,r,n){return r instanceof oe?new nn({keyType:e,valueType:r,typeName:L.ZodRecord,...ie(n)}):new nn({keyType:mt.create(),valueType:e,typeName:L.ZodRecord,...ie(r)})}}class zs extends oe{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==K.map)return W(n,{code:Z.invalid_type,expected:K.map,received:n.parsedType}),ae;const s=this._def.keyType,a=this._def.valueType,i=[...n.data.entries()].map(([o,c],l)=>({key:s._parse(new Tt(n,o,n.path,[l,"key"])),value:a._parse(new Tt(n,c,n.path,[l,"value"]))}));if(n.common.async){const o=new Map;return Promise.resolve().then(async()=>{for(const c of i){const l=await c.key,u=await c.value;if(l.status==="aborted"||u.status==="aborted")return ae;(l.status==="dirty"||u.status==="dirty")&&r.dirty(),o.set(l.value,u.value)}return{status:r.value,value:o}})}else{const o=new Map;for(const c of i){const l=c.key,u=c.value;if(l.status==="aborted"||u.status==="aborted")return ae;(l.status==="dirty"||u.status==="dirty")&&r.dirty(),o.set(l.value,u.value)}return{status:r.value,value:o}}}}zs.create=(t,e,r)=>new zs({valueType:e,keyType:t,typeName:L.ZodMap,...ie(r)});class or extends oe{_parse(e){const{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==K.set)return W(n,{code:Z.invalid_type,expected:K.set,received:n.parsedType}),ae;const s=this._def;s.minSize!==null&&n.data.size<s.minSize.value&&(W(n,{code:Z.too_small,minimum:s.minSize.value,type:"set",inclusive:!0,exact:!1,message:s.minSize.message}),r.dirty()),s.maxSize!==null&&n.data.size>s.maxSize.value&&(W(n,{code:Z.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),r.dirty());const a=this._def.valueType;function i(c){const l=new Set;for(const u of c){if(u.status==="aborted")return ae;u.status==="dirty"&&r.dirty(),l.add(u.value)}return{status:r.value,value:l}}const o=[...n.data.values()].map((c,l)=>a._parse(new Tt(n,c,n.path,l)));return n.common.async?Promise.all(o).then(c=>i(c)):i(o)}min(e,r){return new or({...this._def,minSize:{value:e,message:X.toString(r)}})}max(e,r){return new or({...this._def,maxSize:{value:e,message:X.toString(r)}})}size(e,r){return this.min(e,r).max(e,r)}nonempty(e){return this.min(1,e)}}or.create=(t,e)=>new or({valueType:t,minSize:null,maxSize:null,typeName:L.ZodSet,...ie(e)});class kr extends oe{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:r}=this._processInputParams(e);if(r.parsedType!==K.function)return W(r,{code:Z.invalid_type,expected:K.function,received:r.parsedType}),ae;function n(o,c){return Os({data:o,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,Cs(),gr].filter(l=>!!l),issueData:{code:Z.invalid_arguments,argumentsError:c}})}function s(o,c){return Os({data:o,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,Cs(),gr].filter(l=>!!l),issueData:{code:Z.invalid_return_type,returnTypeError:c}})}const a={errorMap:r.common.contextualErrorMap},i=r.data;if(this._def.returns instanceof $r){const o=this;return Ke(async function(...c){const l=new ot([]),u=await o._def.args.parseAsync(c,a).catch(v=>{throw l.addIssue(n(c,v)),l}),d=await Reflect.apply(i,this,u);return await o._def.returns._def.type.parseAsync(d,a).catch(v=>{throw l.addIssue(s(d,v)),l})})}else{const o=this;return Ke(function(...c){const l=o._def.args.safeParse(c,a);if(!l.success)throw new ot([n(c,l.error)]);const u=Reflect.apply(i,this,l.data),d=o._def.returns.safeParse(u,a);if(!d.success)throw new ot([s(u,d.error)]);return d.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new kr({...this._def,args:Et.create(e).rest(ir.create())})}returns(e){return new kr({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,r,n){return new kr({args:e||Et.create([]).rest(ir.create()),returns:r||ir.create(),typeName:L.ZodFunction,...ie(n)})}}class sn extends oe{get schema(){return this._def.getter()}_parse(e){const{ctx:r}=this._processInputParams(e);return this._def.getter()._parse({data:r.data,path:r.path,parent:r})}}sn.create=(t,e)=>new sn({getter:t,typeName:L.ZodLazy,...ie(e)});class an extends oe{_parse(e){if(e.data!==this._def.value){const r=this._getOrReturnCtx(e);return W(r,{received:r.data,code:Z.invalid_literal,expected:this._def.value}),ae}return{status:"valid",value:e.data}}get value(){return this._def.value}}an.create=(t,e)=>new an({value:t,typeName:L.ZodLiteral,...ie(e)});function cl(t,e){return new Jt({values:t,typeName:L.ZodEnum,...ie(e)})}class Jt extends oe{_parse(e){if(typeof e.data!="string"){const r=this._getOrReturnCtx(e),n=this._def.values;return W(r,{expected:fe.joinValues(n),received:r.parsedType,code:Z.invalid_type}),ae}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){const r=this._getOrReturnCtx(e),n=this._def.values;return W(r,{received:r.data,code:Z.invalid_enum_value,options:n}),ae}return Ke(e.data)}get options(){return this._def.values}get enum(){const e={};for(const r of this._def.values)e[r]=r;return e}get Values(){const e={};for(const r of this._def.values)e[r]=r;return e}get Enum(){const e={};for(const r of this._def.values)e[r]=r;return e}extract(e,r=this._def){return Jt.create(e,{...this._def,...r})}exclude(e,r=this._def){return Jt.create(this.options.filter(n=>!e.includes(n)),{...this._def,...r})}}Jt.create=cl;class on extends oe{_parse(e){const r=fe.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==K.string&&n.parsedType!==K.number){const s=fe.objectValues(r);return W(n,{expected:fe.joinValues(s),received:n.parsedType,code:Z.invalid_type}),ae}if(this._cache||(this._cache=new Set(fe.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){const s=fe.objectValues(r);return W(n,{received:n.data,code:Z.invalid_enum_value,options:s}),ae}return Ke(e.data)}get enum(){return this._def.values}}on.create=(t,e)=>new on({values:t,typeName:L.ZodNativeEnum,...ie(e)});class $r extends oe{unwrap(){return this._def.type}_parse(e){const{ctx:r}=this._processInputParams(e);if(r.parsedType!==K.promise&&r.common.async===!1)return W(r,{code:Z.invalid_type,expected:K.promise,received:r.parsedType}),ae;const n=r.parsedType===K.promise?r.data:Promise.resolve(r.data);return Ke(n.then(s=>this._def.type.parseAsync(s,{path:r.path,errorMap:r.common.contextualErrorMap})))}}$r.create=(t,e)=>new $r({type:t,typeName:L.ZodPromise,...ie(e)});class vt extends oe{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===L.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:r,ctx:n}=this._processInputParams(e),s=this._def.effect||null,a={addIssue:i=>{W(n,i),i.fatal?r.abort():r.dirty()},get path(){return n.path}};if(a.addIssue=a.addIssue.bind(a),s.type==="preprocess"){const i=s.transform(n.data,a);if(n.common.async)return Promise.resolve(i).then(async o=>{if(r.value==="aborted")return ae;const c=await this._def.schema._parseAsync({data:o,path:n.path,parent:n});return c.status==="aborted"?ae:c.status==="dirty"||r.value==="dirty"?yr(c.value):c});{if(r.value==="aborted")return ae;const o=this._def.schema._parseSync({data:i,path:n.path,parent:n});return o.status==="aborted"?ae:o.status==="dirty"||r.value==="dirty"?yr(o.value):o}}if(s.type==="refinement"){const i=o=>{const c=s.refinement(o,a);if(n.common.async)return Promise.resolve(c);if(c instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return o};if(n.common.async===!1){const o=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return o.status==="aborted"?ae:(o.status==="dirty"&&r.dirty(),i(o.value),{status:r.value,value:o.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(o=>o.status==="aborted"?ae:(o.status==="dirty"&&r.dirty(),i(o.value).then(()=>({status:r.value,value:o.value}))))}if(s.type==="transform")if(n.common.async===!1){const i=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!sr(i))return ae;const o=s.transform(i.value,a);if(o instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:r.value,value:o}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(i=>sr(i)?Promise.resolve(s.transform(i.value,a)).then(o=>({status:r.value,value:o})):ae);fe.assertNever(s)}}vt.create=(t,e,r)=>new vt({schema:t,typeName:L.ZodEffects,effect:e,...ie(r)}),vt.createWithPreprocess=(t,e,r)=>new vt({schema:e,effect:{type:"preprocess",transform:t},typeName:L.ZodEffects,...ie(r)});class Rt extends oe{_parse(e){return this._getType(e)===K.undefined?Ke(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Rt.create=(t,e)=>new Rt({innerType:t,typeName:L.ZodOptional,...ie(e)});class Kt extends oe{_parse(e){return this._getType(e)===K.null?Ke(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Kt.create=(t,e)=>new Kt({innerType:t,typeName:L.ZodNullable,...ie(e)});class cn extends oe{_parse(e){const{ctx:r}=this._processInputParams(e);let n=r.data;return r.parsedType===K.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:r.path,parent:r})}removeDefault(){return this._def.innerType}}cn.create=(t,e)=>new cn({innerType:t,typeName:L.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...ie(e)});class un extends oe{_parse(e){const{ctx:r}=this._processInputParams(e),n={...r,common:{...r.common,issues:[]}},s=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return Yr(s)?s.then(a=>({status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new ot(n.common.issues)},input:n.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new ot(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}}un.create=(t,e)=>new un({innerType:t,typeName:L.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...ie(e)});class Ms extends oe{_parse(e){if(this._getType(e)!==K.nan){const n=this._getOrReturnCtx(e);return W(n,{code:Z.invalid_type,expected:K.nan,received:n.parsedType}),ae}return{status:"valid",value:e.data}}}Ms.create=t=>new Ms({typeName:L.ZodNaN,...ie(t)});const Fv=Symbol("zod_brand");class di extends oe{_parse(e){const{ctx:r}=this._processInputParams(e),n=r.data;return this._def.type._parse({data:n,path:r.path,parent:r})}unwrap(){return this._def.type}}class ln extends oe{_parse(e){const{status:r,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{const a=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return a.status==="aborted"?ae:a.status==="dirty"?(r.dirty(),yr(a.value)):this._def.out._parseAsync({data:a.value,path:n.path,parent:n})})();{const s=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return s.status==="aborted"?ae:s.status==="dirty"?(r.dirty(),{status:"dirty",value:s.value}):this._def.out._parseSync({data:s.value,path:n.path,parent:n})}}static create(e,r){return new ln({in:e,out:r,typeName:L.ZodPipeline})}}class dn extends oe{_parse(e){const r=this._def.innerType._parse(e),n=s=>(sr(s)&&(s.value=Object.freeze(s.value)),s);return Yr(r)?r.then(s=>n(s)):n(r)}unwrap(){return this._def.innerType}}dn.create=(t,e)=>new dn({innerType:t,typeName:L.ZodReadonly,...ie(e)});function ul(t,e){const r=typeof t=="function"?t(e):typeof t=="string"?{message:t}:t;return typeof r=="string"?{message:r}:r}function ll(t,e={},r){return t?wr.create().superRefine((n,s)=>{const a=t(n);if(a instanceof Promise)return a.then(i=>{if(!i){const o=ul(e,n),c=o.fatal??r??!0;s.addIssue({code:"custom",...o,fatal:c})}});if(!a){const i=ul(e,n),o=i.fatal??r??!0;s.addIssue({code:"custom",...i,fatal:o})}}):wr.create()}const Hv={object:Oe.lazycreate};var L;(function(t){t.ZodString="ZodString",t.ZodNumber="ZodNumber",t.ZodNaN="ZodNaN",t.ZodBigInt="ZodBigInt",t.ZodBoolean="ZodBoolean",t.ZodDate="ZodDate",t.ZodSymbol="ZodSymbol",t.ZodUndefined="ZodUndefined",t.ZodNull="ZodNull",t.ZodAny="ZodAny",t.ZodUnknown="ZodUnknown",t.ZodNever="ZodNever",t.ZodVoid="ZodVoid",t.ZodArray="ZodArray",t.ZodObject="ZodObject",t.ZodUnion="ZodUnion",t.ZodDiscriminatedUnion="ZodDiscriminatedUnion",t.ZodIntersection="ZodIntersection",t.ZodTuple="ZodTuple",t.ZodRecord="ZodRecord",t.ZodMap="ZodMap",t.ZodSet="ZodSet",t.ZodFunction="ZodFunction",t.ZodLazy="ZodLazy",t.ZodLiteral="ZodLiteral",t.ZodEnum="ZodEnum",t.ZodEffects="ZodEffects",t.ZodNativeEnum="ZodNativeEnum",t.ZodOptional="ZodOptional",t.ZodNullable="ZodNullable",t.ZodDefault="ZodDefault",t.ZodCatch="ZodCatch",t.ZodPromise="ZodPromise",t.ZodBranded="ZodBranded",t.ZodPipeline="ZodPipeline",t.ZodReadonly="ZodReadonly"})(L||(L={}));const Wv=(t,e={message:`Input not instance of ${t.name}`})=>ll(r=>r instanceof t,e),dl=mt.create,fl=Ht.create,Jv=Ms.create,Kv=Wt.create,hl=Qr.create,Bv=ar.create,Gv=Ns.create,Yv=Xr.create,Qv=en.create,Xv=wr.create,eg=ir.create,tg=jt.create,rg=As.create,ng=_t.create,pl=Oe.create,sg=Oe.strictCreate,ag=tn.create,ig=js.create,og=rn.create,cg=Et.create,ug=nn.create,lg=zs.create,dg=or.create,fg=kr.create,hg=sn.create,pg=an.create,mg=Jt.create,_g=on.create,vg=$r.create,ml=vt.create,gg=Rt.create,yg=Kt.create,wg=vt.createWithPreprocess,bg=ln.create,kg=Object.freeze(Object.defineProperty({__proto__:null,BRAND:Fv,DIRTY:yr,EMPTY_PATH:kv,INVALID:ae,NEVER:ae,OK:Ke,ParseStatus:We,Schema:oe,ZodAny:wr,ZodArray:_t,ZodBigInt:Wt,ZodBoolean:Qr,ZodBranded:di,ZodCatch:un,ZodDate:ar,ZodDefault:cn,ZodDiscriminatedUnion:js,ZodEffects:vt,ZodEnum:Jt,ZodError:ot,get ZodFirstPartyTypeKind(){return L},ZodFunction:kr,ZodIntersection:rn,ZodIssueCode:Z,ZodLazy:sn,ZodLiteral:an,ZodMap:zs,ZodNaN:Ms,ZodNativeEnum:on,ZodNever:jt,ZodNull:en,ZodNullable:Kt,ZodNumber:Ht,ZodObject:Oe,ZodOptional:Rt,ZodParsedType:K,ZodPipeline:ln,ZodPromise:$r,ZodReadonly:dn,ZodRecord:nn,ZodSchema:oe,ZodSet:or,ZodString:mt,ZodSymbol:Ns,ZodTransformer:vt,ZodTuple:Et,ZodType:oe,ZodUndefined:Xr,ZodUnion:tn,ZodUnknown:ir,ZodVoid:As,addIssueToContext:W,any:Xv,array:ng,bigint:Kv,boolean:hl,coerce:{string:(t=>mt.create({...t,coerce:!0})),number:(t=>Ht.create({...t,coerce:!0})),boolean:(t=>Qr.create({...t,coerce:!0})),bigint:(t=>Wt.create({...t,coerce:!0})),date:(t=>ar.create({...t,coerce:!0}))},custom:ll,date:Bv,datetimeRegex:ol,defaultErrorMap:gr,discriminatedUnion:ig,effect:ml,enum:mg,function:fg,getErrorMap:Cs,getParsedType:At,instanceof:Wv,intersection:og,isAborted:oi,isAsync:Yr,isDirty:ci,isValid:sr,late:Hv,lazy:hg,literal:pg,makeIssue:Os,map:lg,nan:Jv,nativeEnum:_g,never:tg,null:Qv,nullable:yg,number:fl,object:pl,get objectUtil(){return ii},oboolean:()=>hl().optional(),onumber:()=>fl().optional(),optional:gg,ostring:()=>dl().optional(),pipeline:bg,preprocess:wg,promise:vg,quotelessJson:wv,record:ug,set:dg,setErrorMap:bv,strictObject:sg,string:dl,symbol:Gv,transformer:ml,tuple:cg,undefined:Yv,union:ag,unknown:eg,get util(){return fe},void:rg},Symbol.toStringTag,{value:"Module"})),$g=A("ZodMiniType",(t,e)=>{if(!t._zod)throw new Error("Uninitialized schema in ZodMiniType.");ke.init(t,e),t.def=e,t.parse=(r,n)=>$f(t,r,n,{callee:t.parse}),t.safeParse=(r,n)=>Sa(t,r,n),t.parseAsync=async(r,n)=>Sf(t,r,n,{callee:t.parseAsync}),t.safeParseAsync=async(r,n)=>Ta(t,r,n),t.check=(...r)=>t.clone({...e,checks:[...e.checks??[],...r.map(n=>typeof n=="function"?{_zod:{check:n,def:{check:"custom"},onattach:[]}}:n)]}),t.clone=(r,n)=>Dt(t,r,n),t.brand=()=>t,t.register=((r,n)=>(r.add(t,n),t))}),Sg=A("ZodMiniObject",(t,e)=>{Wc.init(t,e),$g.init(t,e),Te(t,"shape",()=>e.shape)});function _l(t,e){const r={type:"object",get shape(){return Mr(this,"shape",{...t}),this.shape},...Q(e)};return new Sg(r)}function lt(t){return!!t._zod}function fn(t){const e=Object.values(t);if(e.length===0)return _l({});const r=e.every(lt),n=e.every(s=>!lt(s));if(r)return _l(t);if(n)return pl(t);throw new Error("Mixed Zod versions detected in object shape.")}function gt(t,e){return lt(t)?Sa(t,e):t.safeParse(e)}async function fi(t,e){return lt(t)?await Ta(t,e):await t.safeParseAsync(e)}function Sr(t){var e,r;if(!t)return;let n;if(lt(t)?n=(r=(e=t._zod)===null||e===void 0?void 0:e.def)===null||r===void 0?void 0:r.shape:n=t.shape,!!n){if(typeof n=="function")try{return n()}catch{return}return n}}function hn(t){var e;if(t){if(typeof t=="object"){const r=t,n=t;if(!r._def&&!n._zod){const s=Object.values(t);if(s.length>0&&s.every(a=>typeof a=="object"&&a!==null&&(a._def!==void 0||a._zod!==void 0||typeof a.parse=="function")))return fn(t)}}if(lt(t)){const n=(e=t._zod)===null||e===void 0?void 0:e.def;if(n&&(n.type==="object"||n.shape!==void 0))return t}else if(t.shape!==void 0)return t}}function hi(t){if(t&&typeof t=="object"){if("message"in t&&typeof t.message=="string")return t.message;if("issues"in t&&Array.isArray(t.issues)&&t.issues.length>0){const e=t.issues[0];if(e&&typeof e=="object"&&"message"in e)return String(e.message)}try{return JSON.stringify(t)}catch{return String(t)}}return String(t)}function Tg(t){var e,r,n,s;if(lt(t))return(r=(e=t._zod)===null||e===void 0?void 0:e.def)===null||r===void 0?void 0:r.description;const a=t;return(n=t.description)!==null&&n!==void 0?n:(s=a._def)===null||s===void 0?void 0:s.description}function Eg(t){var e,r,n;if(lt(t))return((r=(e=t._zod)===null||e===void 0?void 0:e.def)===null||r===void 0?void 0:r.type)==="optional";const s=t;return typeof t.isOptional=="function"?t.isOptional():((n=s._def)===null||n===void 0?void 0:n.typeName)==="ZodOptional"}function vl(t){var e;if(lt(t)){const i=(e=t._zod)===null||e===void 0?void 0:e.def;if(i){if(i.value!==void 0)return i.value;if(Array.isArray(i.values)&&i.values.length>0)return i.values[0]}}const n=t._def;if(n){if(n.value!==void 0)return n.value;if(Array.isArray(n.values)&&n.values.length>0)return n.values[0]}const s=t.value;if(s!==void 0)return s}function cr(t){return t==="completed"||t==="failed"||t==="cancelled"}const Rg=Symbol("Let zodToJsonSchema decide on which parser to use"),gl={name:void 0,$refStrategy:"root",basePath:["#"],effectStrategy:"input",pipeStrategy:"all",dateStrategy:"format:date-time",mapStrategy:"entries",removeAdditionalStrategy:"passthrough",allowedAdditionalProperties:!0,rejectedAdditionalProperties:!1,definitionPath:"definitions",target:"jsonSchema7",strictUnions:!1,definitions:{},errorMessages:!1,markdownDescription:!1,patternStrategy:"escape",applyRegexFlags:!1,emailStrategy:"format:email",base64Strategy:"contentEncoding:base64",nameStrategy:"ref",openAiAnyTypeName:"OpenAiAnyType"},Pg=t=>typeof t=="string"?{...gl,name:t}:{...gl,...t},xg=t=>{const e=Pg(t),r=e.name!==void 0?[...e.basePath,e.definitionPath,e.name]:e.basePath;return{...e,flags:{hasReferencedOpenAiAnyType:!1},currentPath:r,propertyPath:void 0,seen:new Map(Object.entries(e.definitions).map(([n,s])=>[s._def,{def:s._def,path:[...e.basePath,e.definitionPath,n],jsonSchema:void 0}]))}};function yl(t,e,r,n){n?.errorMessages&&r&&(t.errorMessage={...t.errorMessage,[e]:r})}function ye(t,e,r,n,s){t[e]=r,yl(t,e,n,s)}const wl=(t,e)=>{let r=0;for(;r<t.length&&r<e.length&&t[r]===e[r];r++);return[(t.length-r).toString(),...e.slice(r)].join("/")};function tt(t){if(t.target!=="openAi")return{};const e=[...t.basePath,t.definitionPath,t.openAiAnyTypeName];return t.flags.hasReferencedOpenAiAnyType=!0,{$ref:t.$refStrategy==="relative"?wl(e,t.currentPath):e.join("/")}}function Ig(t,e){const r={type:"array"};return t.type?._def&&t.type?._def?.typeName!==L.ZodAny&&(r.items=me(t.type._def,{...e,currentPath:[...e.currentPath,"items"]})),t.minLength&&ye(r,"minItems",t.minLength.value,t.minLength.message,e),t.maxLength&&ye(r,"maxItems",t.maxLength.value,t.maxLength.message,e),t.exactLength&&(ye(r,"minItems",t.exactLength.value,t.exactLength.message,e),ye(r,"maxItems",t.exactLength.value,t.exactLength.message,e)),r}function Cg(t,e){const r={type:"integer",format:"int64"};if(!t.checks)return r;for(const n of t.checks)switch(n.kind){case"min":e.target==="jsonSchema7"?n.inclusive?ye(r,"minimum",n.value,n.message,e):ye(r,"exclusiveMinimum",n.value,n.message,e):(n.inclusive||(r.exclusiveMinimum=!0),ye(r,"minimum",n.value,n.message,e));break;case"max":e.target==="jsonSchema7"?n.inclusive?ye(r,"maximum",n.value,n.message,e):ye(r,"exclusiveMaximum",n.value,n.message,e):(n.inclusive||(r.exclusiveMaximum=!0),ye(r,"maximum",n.value,n.message,e));break;case"multipleOf":ye(r,"multipleOf",n.value,n.message,e);break}return r}function Og(){return{type:"boolean"}}function bl(t,e){return me(t.type._def,e)}const Ng=(t,e)=>me(t.innerType._def,e);function kl(t,e,r){const n=r??e.dateStrategy;if(Array.isArray(n))return{anyOf:n.map((s,a)=>kl(t,e,s))};switch(n){case"string":case"format:date-time":return{type:"string",format:"date-time"};case"format:date":return{type:"string",format:"date"};case"integer":return Ag(t,e)}}const Ag=(t,e)=>{const r={type:"integer",format:"unix-time"};if(e.target==="openApi3")return r;for(const n of t.checks)switch(n.kind){case"min":ye(r,"minimum",n.value,n.message,e);break;case"max":ye(r,"maximum",n.value,n.message,e);break}return r};function jg(t,e){return{...me(t.innerType._def,e),default:t.defaultValue()}}function zg(t,e){return e.effectStrategy==="input"?me(t.schema._def,e):tt(e)}function Mg(t){return{type:"string",enum:Array.from(t.values)}}const qg=t=>"type"in t&&t.type==="string"?!1:"allOf"in t;function Zg(t,e){const r=[me(t.left._def,{...e,currentPath:[...e.currentPath,"allOf","0"]}),me(t.right._def,{...e,currentPath:[...e.currentPath,"allOf","1"]})].filter(a=>!!a);let n=e.target==="jsonSchema2019-09"?{unevaluatedProperties:!1}:void 0;const s=[];return r.forEach(a=>{if(qg(a))s.push(...a.allOf),a.unevaluatedProperties===void 0&&(n=void 0);else{let i=a;if("additionalProperties"in a&&a.additionalProperties===!1){const{additionalProperties:o,...c}=a;i=c}else n=void 0;s.push(i)}}),s.length?{allOf:s,...n}:void 0}function Lg(t,e){const r=typeof t.value;return r!=="bigint"&&r!=="number"&&r!=="boolean"&&r!=="string"?{type:Array.isArray(t.value)?"array":"object"}:e.target==="openApi3"?{type:r==="bigint"?"integer":r,enum:[t.value]}:{type:r==="bigint"?"integer":r,const:t.value}}let pi;const yt={cuid:/^[cC][^\s-]{8,}$/,cuid2:/^[0-9a-z]+$/,ulid:/^[0-9A-HJKMNP-TV-Z]{26}$/,email:/^(?!\.)(?!.*\.\.)([a-zA-Z0-9_'+\-\.]*)[a-zA-Z0-9_+-]@([a-zA-Z0-9][a-zA-Z0-9\-]*\.)+[a-zA-Z]{2,}$/,emoji:()=>(pi===void 0&&(pi=RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),pi),uuid:/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/,ipv4:/^(?:(?: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])$/,ipv4Cidr:/^(?:(?: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])\/(3[0-2]|[12]?[0-9])$/,ipv6:/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,ipv6Cidr:/^(([0-9a-fA-F]{1,4}:){7,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}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,base64:/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,base64url:/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,nanoid:/^[a-zA-Z0-9_-]{21}$/,jwt:/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/};function $l(t,e){const r={type:"string"};if(t.checks)for(const n of t.checks)switch(n.kind){case"min":ye(r,"minLength",typeof r.minLength=="number"?Math.max(r.minLength,n.value):n.value,n.message,e);break;case"max":ye(r,"maxLength",typeof r.maxLength=="number"?Math.min(r.maxLength,n.value):n.value,n.message,e);break;case"email":switch(e.emailStrategy){case"format:email":wt(r,"email",n.message,e);break;case"format:idn-email":wt(r,"idn-email",n.message,e);break;case"pattern:zod":Be(r,yt.email,n.message,e);break}break;case"url":wt(r,"uri",n.message,e);break;case"uuid":wt(r,"uuid",n.message,e);break;case"regex":Be(r,n.regex,n.message,e);break;case"cuid":Be(r,yt.cuid,n.message,e);break;case"cuid2":Be(r,yt.cuid2,n.message,e);break;case"startsWith":Be(r,RegExp(`^${mi(n.value,e)}`),n.message,e);break;case"endsWith":Be(r,RegExp(`${mi(n.value,e)}$`),n.message,e);break;case"datetime":wt(r,"date-time",n.message,e);break;case"date":wt(r,"date",n.message,e);break;case"time":wt(r,"time",n.message,e);break;case"duration":wt(r,"duration",n.message,e);break;case"length":ye(r,"minLength",typeof r.minLength=="number"?Math.max(r.minLength,n.value):n.value,n.message,e),ye(r,"maxLength",typeof r.maxLength=="number"?Math.min(r.maxLength,n.value):n.value,n.message,e);break;case"includes":{Be(r,RegExp(mi(n.value,e)),n.message,e);break}case"ip":{n.version!=="v6"&&wt(r,"ipv4",n.message,e),n.version!=="v4"&&wt(r,"ipv6",n.message,e);break}case"base64url":Be(r,yt.base64url,n.message,e);break;case"jwt":Be(r,yt.jwt,n.message,e);break;case"cidr":{n.version!=="v6"&&Be(r,yt.ipv4Cidr,n.message,e),n.version!=="v4"&&Be(r,yt.ipv6Cidr,n.message,e);break}case"emoji":Be(r,yt.emoji(),n.message,e);break;case"ulid":{Be(r,yt.ulid,n.message,e);break}case"base64":{switch(e.base64Strategy){case"format:binary":{wt(r,"binary",n.message,e);break}case"contentEncoding:base64":{ye(r,"contentEncoding","base64",n.message,e);break}case"pattern:zod":{Be(r,yt.base64,n.message,e);break}}break}case"nanoid":Be(r,yt.nanoid,n.message,e)}return r}function mi(t,e){return e.patternStrategy==="escape"?Dg(t):t}const Ug=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function Dg(t){let e="";for(let r=0;r<t.length;r++)Ug.has(t[r])||(e+="\\"),e+=t[r];return e}function wt(t,e,r,n){t.format||t.anyOf?.some(s=>s.format)?(t.anyOf||(t.anyOf=[]),t.format&&(t.anyOf.push({format:t.format,...t.errorMessage&&n.errorMessages&&{errorMessage:{format:t.errorMessage.format}}}),delete t.format,t.errorMessage&&(delete t.errorMessage.format,Object.keys(t.errorMessage).length===0&&delete t.errorMessage)),t.anyOf.push({format:e,...r&&n.errorMessages&&{errorMessage:{format:r}}})):ye(t,"format",e,r,n)}function Be(t,e,r,n){t.pattern||t.allOf?.some(s=>s.pattern)?(t.allOf||(t.allOf=[]),t.pattern&&(t.allOf.push({pattern:t.pattern,...t.errorMessage&&n.errorMessages&&{errorMessage:{pattern:t.errorMessage.pattern}}}),delete t.pattern,t.errorMessage&&(delete t.errorMessage.pattern,Object.keys(t.errorMessage).length===0&&delete t.errorMessage)),t.allOf.push({pattern:Sl(e,n),...r&&n.errorMessages&&{errorMessage:{pattern:r}}})):ye(t,"pattern",Sl(e,n),r,n)}function Sl(t,e){if(!e.applyRegexFlags||!t.flags)return t.source;const r={i:t.flags.includes("i"),m:t.flags.includes("m"),s:t.flags.includes("s")},n=r.i?t.source.toLowerCase():t.source;let s="",a=!1,i=!1,o=!1;for(let c=0;c<n.length;c++){if(a){s+=n[c],a=!1;continue}if(r.i){if(i){if(n[c].match(/[a-z]/)){o?(s+=n[c],s+=`${n[c-2]}-${n[c]}`.toUpperCase(),o=!1):n[c+1]==="-"&&n[c+2]?.match(/[a-z]/)?(s+=n[c],o=!0):s+=`${n[c]}${n[c].toUpperCase()}`;continue}}else if(n[c].match(/[a-z]/)){s+=`[${n[c]}${n[c].toUpperCase()}]`;continue}}if(r.m){if(n[c]==="^"){s+=`(^|(?<=[\r
|
|
35
|
+
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const l of this.seen.entries()){const d=l[1];if(e===l[0]){i(l);continue}if(n.external){const _=n.external.registry.get(l[0])?.id;if(e!==l[0]&&_){i(l);continue}}if(this.metadataRegistry.get(l[0])?.id){i(l);continue}if(d.cycle){i(l);continue}if(d.count>1&&n.reused==="ref"){i(l);continue}}const a=(l,d)=>{const p=this.seen.get(l),_=p.def??p.schema,m={..._};if(p.ref===null)return;const g=p.ref;if(p.ref=null,g){a(g,d);const f=this.seen.get(g).schema;f.$ref&&d.target==="draft-7"?(_.allOf=_.allOf??[],_.allOf.push(f)):(Object.assign(_,f),Object.assign(_,m))}p.isParent||this.override({zodSchema:l,jsonSchema:_,path:p.path??[]})};for(const l of[...this.seen.entries()].reverse())a(l[0],{target:this.target});const c={};if(this.target==="draft-2020-12"?c.$schema="https://json-schema.org/draft/2020-12/schema":this.target==="draft-7"?c.$schema="http://json-schema.org/draft-07/schema#":console.warn(`Invalid target: ${this.target}`),n.external?.uri){const l=n.external.registry.get(e)?.id;if(!l)throw new Error("Schema is missing an `id` property");c.$id=n.external.uri(l)}Object.assign(c,s.def);const u=n.external?.defs??{};for(const l of this.seen.entries()){const d=l[1];d.def&&d.defId&&(u[d.defId]=d.def)}n.external||Object.keys(u).length>0&&(this.target==="draft-2020-12"?c.$defs=u:c.definitions=u);try{return JSON.parse(JSON.stringify(c))}catch{throw new Error("Error converting schema to JSON.")}}}function sg(t,e){if(t instanceof ml){const n=new Sl(e),s={};for(const a of t._idmap.entries()){const[c,u]=a;n.process(u)}const o={},i={registry:t,uri:e?.uri,defs:s};for(const a of t._idmap.entries()){const[c,u]=a;o[c]=n.emit(u,{...e,external:i})}if(Object.keys(s).length>0){const a=n.target==="draft-2020-12"?"$defs":"definitions";o.__shared={[a]:s}}return{schemas:o}}const r=new Sl(e);return r.process(t),r.emit(t,e)}function Ue(t,e){const r=e??{seen:new Set};if(r.seen.has(t))return!1;r.seen.add(t);const s=t._zod.def;switch(s.type){case"string":case"number":case"bigint":case"boolean":case"date":case"symbol":case"undefined":case"null":case"any":case"unknown":case"never":case"void":case"literal":case"enum":case"nan":case"file":case"template_literal":return!1;case"array":return Ue(s.element,r);case"object":{for(const o in s.shape)if(Ue(s.shape[o],r))return!0;return!1}case"union":{for(const o of s.options)if(Ue(o,r))return!0;return!1}case"intersection":return Ue(s.left,r)||Ue(s.right,r);case"tuple":{for(const o of s.items)if(Ue(o,r))return!0;return!!(s.rest&&Ue(s.rest,r))}case"record":return Ue(s.keyType,r)||Ue(s.valueType,r);case"map":return Ue(s.keyType,r)||Ue(s.valueType,r);case"set":return Ue(s.valueType,r);case"promise":case"optional":case"nonoptional":case"nullable":case"readonly":return Ue(s.innerType,r);case"lazy":return Ue(s.getter(),r);case"default":return Ue(s.innerType,r);case"prefault":return Ue(s.innerType,r);case"custom":return!1;case"transform":return!0;case"pipe":return Ue(s.in,r)||Ue(s.out,r);case"success":return!1;case"catch":return!1}throw new Error(`Unknown schema type: ${s.type}`)}const og=A("ZodISODateTime",(t,e)=>{xm.init(t,e),je.init(t,e)});function kl(t){return N_(og,t)}const ig=A("ZodISODate",(t,e)=>{Im.init(t,e),je.init(t,e)});function ag(t){return A_(ig,t)}const cg=A("ZodISOTime",(t,e)=>{Cm.init(t,e),je.init(t,e)});function ug(t){return M_(cg,t)}const lg=A("ZodISODuration",(t,e)=>{Om.init(t,e),je.init(t,e)});function dg(t){return j_(lg,t)}const Ds=A("ZodError",(t,e)=>{Hu.init(t,e),t.name="ZodError",Object.defineProperties(t,{format:{value:r=>Ep(t,r)},flatten:{value:r=>Rp(t,r)},addIssue:{value:r=>t.issues.push(r)},addIssues:{value:r=>t.issues.push(...r)},isEmpty:{get(){return t.issues.length===0}}})},{Parent:Error}),hg=Fu(Ds),fg=Wu(Ds),pg=Ju(Ds),mg=Bu(Ds),Ae=A("ZodType",(t,e)=>(Ie.init(t,e),t.def=e,Object.defineProperty(t,"_def",{value:e}),t.check=(...r)=>t.clone({...e,checks:[...e.checks??[],...r.map(n=>typeof n=="function"?{_zod:{check:n,def:{check:"custom"},onattach:[]}}:n)]}),t.clone=(r,n)=>Yt(t,r,n),t.brand=()=>t,t.register=((r,n)=>(r.add(t,n),t)),t.parse=(r,n)=>hg(t,r,n,{callee:t.parse}),t.safeParse=(r,n)=>pg(t,r,n),t.parseAsync=async(r,n)=>fg(t,r,n,{callee:t.parseAsync}),t.safeParseAsync=async(r,n)=>mg(t,r,n),t.spa=t.safeParseAsync,t.refine=(r,n)=>t.check(sv(r,n)),t.superRefine=r=>t.check(ov(r)),t.overwrite=r=>t.check(sn(r)),t.optional=()=>ee(t),t.nullable=()=>jl(t),t.nullish=()=>ee(jl(t)),t.nonoptional=r=>Yg(t,r),t.array=()=>x(t),t.or=r=>ae([t,r]),t.and=r=>on(t,r),t.transform=r=>fi(t,Al(r)),t.default=r=>Bg(t,r),t.prefault=r=>Gg(t,r),t.catch=r=>Xg(t,r),t.pipe=r=>fi(t,r),t.readonly=()=>rv(t),t.describe=r=>{const n=t.clone();return nn.add(n,{description:r}),n},Object.defineProperty(t,"description",{get(){return nn.get(t)?.description},configurable:!0}),t.meta=(...r)=>{if(r.length===0)return nn.get(t);const n=t.clone();return nn.add(n,r[0]),n},t.isOptional=()=>t.safeParse(void 0).success,t.isNullable=()=>t.safeParse(null).success,t)),Tl=A("_ZodString",(t,e)=>{ii.init(t,e),Ae.init(t,e);const r=t._zod.bag;t.format=r.format??null,t.minLength=r.minimum??null,t.maxLength=r.maximum??null,t.regex=(...n)=>t.check(F_(...n)),t.includes=(...n)=>t.check(B_(...n)),t.startsWith=(...n)=>t.check(K_(...n)),t.endsWith=(...n)=>t.check(G_(...n)),t.min=(...n)=>t.check(Zs(...n)),t.max=(...n)=>t.check(bl(...n)),t.length=(...n)=>t.check($l(...n)),t.nonempty=(...n)=>t.check(Zs(1,...n)),t.lowercase=n=>t.check(W_(n)),t.uppercase=n=>t.check(J_(n)),t.trim=()=>t.check(Q_()),t.normalize=(...n)=>t.check(Y_(...n)),t.toLowerCase=()=>t.check(X_()),t.toUpperCase=()=>t.check(eg())}),_g=A("ZodString",(t,e)=>{ii.init(t,e),Tl.init(t,e),t.email=r=>t.check(f_(gg,r)),t.url=r=>t.check(gl(El,r)),t.jwt=r=>t.check(O_(Og,r)),t.emoji=r=>t.check(v_(vg,r)),t.guid=r=>t.check(_l(Rl,r)),t.uuid=r=>t.check(p_(Vs,r)),t.uuidv4=r=>t.check(m_(Vs,r)),t.uuidv6=r=>t.check(__(Vs,r)),t.uuidv7=r=>t.check(g_(Vs,r)),t.nanoid=r=>t.check(y_(yg,r)),t.guid=r=>t.check(_l(Rl,r)),t.cuid=r=>t.check(w_(wg,r)),t.cuid2=r=>t.check(b_(bg,r)),t.ulid=r=>t.check($_($g,r)),t.base64=r=>t.check(x_(xg,r)),t.base64url=r=>t.check(I_(Ig,r)),t.xid=r=>t.check(S_(Sg,r)),t.ksuid=r=>t.check(k_(kg,r)),t.ipv4=r=>t.check(T_(Tg,r)),t.ipv6=r=>t.check(R_(Rg,r)),t.cidrv4=r=>t.check(E_(Eg,r)),t.cidrv6=r=>t.check(P_(Pg,r)),t.e164=r=>t.check(C_(Cg,r)),t.datetime=r=>t.check(kl(r)),t.date=r=>t.check(ag(r)),t.time=r=>t.check(ug(r)),t.duration=r=>t.check(dg(r))});function y(t){return h_(_g,t)}const je=A("ZodStringFormat",(t,e)=>{Ne.init(t,e),Tl.init(t,e)}),gg=A("ZodEmail",(t,e)=>{wm.init(t,e),je.init(t,e)}),Rl=A("ZodGUID",(t,e)=>{vm.init(t,e),je.init(t,e)}),Vs=A("ZodUUID",(t,e)=>{ym.init(t,e),je.init(t,e)}),El=A("ZodURL",(t,e)=>{bm.init(t,e),je.init(t,e)});function Pl(t){return gl(El,t)}const vg=A("ZodEmoji",(t,e)=>{$m.init(t,e),je.init(t,e)}),yg=A("ZodNanoID",(t,e)=>{Sm.init(t,e),je.init(t,e)}),wg=A("ZodCUID",(t,e)=>{km.init(t,e),je.init(t,e)}),bg=A("ZodCUID2",(t,e)=>{Tm.init(t,e),je.init(t,e)}),$g=A("ZodULID",(t,e)=>{Rm.init(t,e),je.init(t,e)}),Sg=A("ZodXID",(t,e)=>{Em.init(t,e),je.init(t,e)}),kg=A("ZodKSUID",(t,e)=>{Pm.init(t,e),je.init(t,e)}),Tg=A("ZodIPv4",(t,e)=>{Nm.init(t,e),je.init(t,e)}),Rg=A("ZodIPv6",(t,e)=>{Am.init(t,e),je.init(t,e)}),Eg=A("ZodCIDRv4",(t,e)=>{Mm.init(t,e),je.init(t,e)}),Pg=A("ZodCIDRv6",(t,e)=>{jm.init(t,e),je.init(t,e)}),xg=A("ZodBase64",(t,e)=>{qm.init(t,e),je.init(t,e)}),Ig=A("ZodBase64URL",(t,e)=>{Um.init(t,e),je.init(t,e)}),Cg=A("ZodE164",(t,e)=>{Lm.init(t,e),je.init(t,e)}),Og=A("ZodJWT",(t,e)=>{Dm.init(t,e),je.init(t,e)}),li=A("ZodNumber",(t,e)=>{nl.init(t,e),Ae.init(t,e),t.gt=(n,s)=>t.check(yl(n,s)),t.gte=(n,s)=>t.check(ui(n,s)),t.min=(n,s)=>t.check(ui(n,s)),t.lt=(n,s)=>t.check(vl(n,s)),t.lte=(n,s)=>t.check(ci(n,s)),t.max=(n,s)=>t.check(ci(n,s)),t.int=n=>t.check(xl(n)),t.safe=n=>t.check(xl(n)),t.positive=n=>t.check(yl(0,n)),t.nonnegative=n=>t.check(ui(0,n)),t.negative=n=>t.check(vl(0,n)),t.nonpositive=n=>t.check(ci(0,n)),t.multipleOf=(n,s)=>t.check(wl(n,s)),t.step=(n,s)=>t.check(wl(n,s)),t.finite=()=>t;const r=t._zod.bag;t.minValue=Math.max(r.minimum??Number.NEGATIVE_INFINITY,r.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,t.maxValue=Math.min(r.maximum??Number.POSITIVE_INFINITY,r.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,t.isInt=(r.format??"").includes("int")||Number.isSafeInteger(r.multipleOf??.5),t.isFinite=!0,t.format=r.format??null});function ne(t){return q_(li,t)}const Ng=A("ZodNumberFormat",(t,e)=>{Vm.init(t,e),li.init(t,e)});function xl(t){return U_(Ng,t)}const Ag=A("ZodBoolean",(t,e)=>{Hm.init(t,e),Ae.init(t,e)});function oe(t){return L_(Ag,t)}const Mg=A("ZodNull",(t,e)=>{Fm.init(t,e),Ae.init(t,e)});function Il(t){return Z_(Mg,t)}const jg=A("ZodAny",(t,e)=>{Wm.init(t,e),Ae.init(t,e)});function Cl(){return D_(jg)}const qg=A("ZodUnknown",(t,e)=>{Jm.init(t,e),Ae.init(t,e)});function de(){return V_(qg)}const zg=A("ZodNever",(t,e)=>{Bm.init(t,e),Ae.init(t,e)});function Ug(t){return H_(zg,t)}const Lg=A("ZodArray",(t,e)=>{Km.init(t,e),Ae.init(t,e),t.element=e.element,t.min=(r,n)=>t.check(Zs(r,n)),t.nonempty=r=>t.check(Zs(1,r)),t.max=(r,n)=>t.check(bl(r,n)),t.length=(r,n)=>t.check($l(r,n)),t.unwrap=()=>t.element});function x(t,e){return tg(Lg,t,e)}const Ol=A("ZodObject",(t,e)=>{il.init(t,e),Ae.init(t,e),Oe(t,"shape",()=>e.shape),t.keyof=()=>qe(Object.keys(t._zod.def.shape)),t.catchall=r=>t.clone({...t._zod.def,catchall:r}),t.passthrough=()=>t.clone({...t._zod.def,catchall:de()}),t.loose=()=>t.clone({...t._zod.def,catchall:de()}),t.strict=()=>t.clone({...t._zod.def,catchall:Ug()}),t.strip=()=>t.clone({...t._zod.def,catchall:void 0}),t.extend=r=>$p(t,r),t.merge=r=>Sp(t,r),t.pick=r=>wp(t,r),t.omit=r=>bp(t,r),t.partial=(...r)=>kp(Ml,t,r[0]),t.required=(...r)=>Tp(ql,t,r[0])});function C(t,e){const r={type:"object",get shape(){return Qr(this,"shape",{...t}),this.shape},...Y(e)};return new Ol(r)}function Ee(t,e){return new Ol({type:"object",get shape(){return Qr(this,"shape",{...t}),this.shape},catchall:de(),...Y(e)})}const Nl=A("ZodUnion",(t,e)=>{cl.init(t,e),Ae.init(t,e),t.options=e.options});function ae(t,e){return new Nl({type:"union",options:t,...Y(e)})}const Zg=A("ZodDiscriminatedUnion",(t,e)=>{Nl.init(t,e),Gm.init(t,e)});function di(t,e,r){return new Zg({type:"union",options:e,discriminator:t,...Y(r)})}const Dg=A("ZodIntersection",(t,e)=>{Ym.init(t,e),Ae.init(t,e)});function on(t,e){return new Dg({type:"intersection",left:t,right:e})}const Vg=A("ZodRecord",(t,e)=>{Qm.init(t,e),Ae.init(t,e),t.keyType=e.keyType,t.valueType=e.valueType});function ce(t,e,r){return new Vg({type:"record",keyType:t,valueType:e,...Y(r)})}const hi=A("ZodEnum",(t,e)=>{Xm.init(t,e),Ae.init(t,e),t.enum=e.entries,t.options=Object.values(e.entries);const r=new Set(Object.keys(e.entries));t.extract=(n,s)=>{const o={};for(const i of n)if(r.has(i))o[i]=e.entries[i];else throw new Error(`Key ${i} not found in enum`);return new hi({...e,checks:[],...Y(s),entries:o})},t.exclude=(n,s)=>{const o={...e.entries};for(const i of n)if(r.has(i))delete o[i];else throw new Error(`Key ${i} not found in enum`);return new hi({...e,checks:[],...Y(s),entries:o})}});function qe(t,e){const r=Array.isArray(t)?Object.fromEntries(t.map(n=>[n,n])):t;return new hi({type:"enum",entries:r,...Y(e)})}const Hg=A("ZodLiteral",(t,e)=>{e_.init(t,e),Ae.init(t,e),t.values=new Set(e.values),Object.defineProperty(t,"value",{get(){if(e.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return e.values[0]}})});function z(t,e){return new Hg({type:"literal",values:Array.isArray(t)?t:[t],...Y(e)})}const Fg=A("ZodTransform",(t,e)=>{t_.init(t,e),Ae.init(t,e),t._zod.parse=(r,n)=>{r.addIssue=o=>{if(typeof o=="string")r.issues.push(rn(o,r.value,e));else{const i=o;i.fatal&&(i.continue=!1),i.code??(i.code="custom"),i.input??(i.input=r.value),i.inst??(i.inst=t),i.continue??(i.continue=!0),r.issues.push(rn(i))}};const s=e.transform(r.value,r);return s instanceof Promise?s.then(o=>(r.value=o,r)):(r.value=s,r)}});function Al(t){return new Fg({type:"transform",transform:t})}const Ml=A("ZodOptional",(t,e)=>{r_.init(t,e),Ae.init(t,e),t.unwrap=()=>t._zod.def.innerType});function ee(t){return new Ml({type:"optional",innerType:t})}const Wg=A("ZodNullable",(t,e)=>{n_.init(t,e),Ae.init(t,e),t.unwrap=()=>t._zod.def.innerType});function jl(t){return new Wg({type:"nullable",innerType:t})}const Jg=A("ZodDefault",(t,e)=>{s_.init(t,e),Ae.init(t,e),t.unwrap=()=>t._zod.def.innerType,t.removeDefault=t.unwrap});function Bg(t,e){return new Jg({type:"default",innerType:t,get defaultValue(){return typeof e=="function"?e():e}})}const Kg=A("ZodPrefault",(t,e)=>{o_.init(t,e),Ae.init(t,e),t.unwrap=()=>t._zod.def.innerType});function Gg(t,e){return new Kg({type:"prefault",innerType:t,get defaultValue(){return typeof e=="function"?e():e}})}const ql=A("ZodNonOptional",(t,e)=>{i_.init(t,e),Ae.init(t,e),t.unwrap=()=>t._zod.def.innerType});function Yg(t,e){return new ql({type:"nonoptional",innerType:t,...Y(e)})}const Qg=A("ZodCatch",(t,e)=>{a_.init(t,e),Ae.init(t,e),t.unwrap=()=>t._zod.def.innerType,t.removeCatch=t.unwrap});function Xg(t,e){return new Qg({type:"catch",innerType:t,catchValue:typeof e=="function"?e:()=>e})}const ev=A("ZodPipe",(t,e)=>{c_.init(t,e),Ae.init(t,e),t.in=e.in,t.out=e.out});function fi(t,e){return new ev({type:"pipe",in:t,out:e})}const tv=A("ZodReadonly",(t,e)=>{u_.init(t,e),Ae.init(t,e)});function rv(t){return new tv({type:"readonly",innerType:t})}const zl=A("ZodCustom",(t,e)=>{l_.init(t,e),Ae.init(t,e)});function nv(t){const e=new nt({check:"custom"});return e._zod.check=t,e}function Ul(t,e){return rg(zl,t??(()=>!0),e)}function sv(t,e={}){return ng(zl,t,e)}function ov(t){const e=nv(r=>(r.addIssue=n=>{if(typeof n=="string")r.issues.push(rn(n,r.value,e._zod.def));else{const s=n;s.fatal&&(s.continue=!1),s.code??(s.code="custom"),s.input??(s.input=r.value),s.inst??(s.inst=e),s.continue??(s.continue=!e._zod.def.abort),r.issues.push(rn(s))}},t(r.value,r)));return e}function pi(t,e){return fi(Al(t),e)}const Ll={custom:"custom"};function iv(t){return z_(li,t)}const Hs="2025-11-25",av=[Hs,"2025-06-18","2025-03-26","2024-11-05","2024-10-07"],fr="io.modelcontextprotocol/related-task",Fs="2.0",Ve=Ul(t=>t!==null&&(typeof t=="object"||typeof t=="function")),Zl=ae([y(),ne().int()]),Dl=y();Ee({ttl:ae([ne(),Il()]).optional(),pollInterval:ne().optional()});const cv=C({ttl:ne().optional()}),uv=C({taskId:y()}),mi=Ee({progressToken:Zl.optional(),[fr]:uv.optional()}),lt=C({_meta:mi.optional()}),an=lt.extend({task:cv.optional()}),lv=t=>an.safeParse(t).success,He=C({method:y(),params:lt.loose().optional()}),ft=C({_meta:mi.optional()}),pt=C({method:y(),params:ft.loose().optional()}),Fe=Ee({_meta:mi.optional()}),Ws=ae([y(),ne().int()]),Vl=C({jsonrpc:z(Fs),id:Ws,...He.shape}).strict(),_i=t=>Vl.safeParse(t).success,Hl=C({jsonrpc:z(Fs),...pt.shape}).strict(),dv=t=>Hl.safeParse(t).success,gi=C({jsonrpc:z(Fs),id:Ws,result:Fe}).strict(),cn=t=>gi.safeParse(t).success;var ue;(function(t){t[t.ConnectionClosed=-32e3]="ConnectionClosed",t[t.RequestTimeout=-32001]="RequestTimeout",t[t.ParseError=-32700]="ParseError",t[t.InvalidRequest=-32600]="InvalidRequest",t[t.MethodNotFound=-32601]="MethodNotFound",t[t.InvalidParams=-32602]="InvalidParams",t[t.InternalError=-32603]="InternalError",t[t.UrlElicitationRequired=-32042]="UrlElicitationRequired"})(ue||(ue={}));const vi=C({jsonrpc:z(Fs),id:Ws.optional(),error:C({code:ne().int(),message:y(),data:de().optional()})}).strict(),hv=t=>vi.safeParse(t).success,Er=ae([Vl,Hl,gi,vi]);ae([gi,vi]);const pr=Fe.strict(),fv=ft.extend({requestId:Ws.optional(),reason:y().optional()}),yi=pt.extend({method:z("notifications/cancelled"),params:fv}),pv=C({src:y(),mimeType:y().optional(),sizes:x(y()).optional(),theme:qe(["light","dark"]).optional()}),un=C({icons:x(pv).optional()}),Pr=C({name:y(),title:y().optional()}),Fl=Pr.extend({...Pr.shape,...un.shape,version:y(),websiteUrl:y().optional(),description:y().optional()}),mv=on(C({applyDefaults:oe().optional()}),ce(y(),de())),_v=pi(t=>t&&typeof t=="object"&&!Array.isArray(t)&&Object.keys(t).length===0?{form:{}}:t,on(C({form:mv.optional(),url:Ve.optional()}),ce(y(),de()).optional())),gv=Ee({list:Ve.optional(),cancel:Ve.optional(),requests:Ee({sampling:Ee({createMessage:Ve.optional()}).optional(),elicitation:Ee({create:Ve.optional()}).optional()}).optional()}),vv=Ee({list:Ve.optional(),cancel:Ve.optional(),requests:Ee({tools:Ee({call:Ve.optional()}).optional()}).optional()}),yv=C({experimental:ce(y(),Ve).optional(),sampling:C({context:Ve.optional(),tools:Ve.optional()}).optional(),elicitation:_v.optional(),roots:C({listChanged:oe().optional()}).optional(),tasks:gv.optional()}),wv=lt.extend({protocolVersion:y(),capabilities:yv,clientInfo:Fl}),bv=He.extend({method:z("initialize"),params:wv}),$v=C({experimental:ce(y(),Ve).optional(),logging:Ve.optional(),completions:Ve.optional(),prompts:C({listChanged:oe().optional()}).optional(),resources:C({subscribe:oe().optional(),listChanged:oe().optional()}).optional(),tools:C({listChanged:oe().optional()}).optional(),tasks:vv.optional()}),Wl=Fe.extend({protocolVersion:y(),capabilities:$v,serverInfo:Fl,instructions:y().optional()}),Jl=pt.extend({method:z("notifications/initialized"),params:ft.optional()}),Sv=t=>Jl.safeParse(t).success,wi=He.extend({method:z("ping"),params:lt.optional()}),kv=C({progress:ne(),total:ee(ne()),message:ee(y())}),Tv=C({...ft.shape,...kv.shape,progressToken:Zl}),bi=pt.extend({method:z("notifications/progress"),params:Tv}),Rv=lt.extend({cursor:Dl.optional()}),ln=He.extend({params:Rv.optional()}),dn=Fe.extend({nextCursor:Dl.optional()}),Ev=qe(["working","input_required","completed","failed","cancelled"]),hn=C({taskId:y(),status:Ev,ttl:ae([ne(),Il()]),createdAt:y(),lastUpdatedAt:y(),pollInterval:ee(ne()),statusMessage:ee(y())}),fn=Fe.extend({task:hn}),Pv=ft.merge(hn),Js=pt.extend({method:z("notifications/tasks/status"),params:Pv}),$i=He.extend({method:z("tasks/get"),params:lt.extend({taskId:y()})}),Si=Fe.merge(hn),ki=He.extend({method:z("tasks/result"),params:lt.extend({taskId:y()})});Fe.loose();const Ti=ln.extend({method:z("tasks/list")}),Ri=dn.extend({tasks:x(hn)}),Ei=He.extend({method:z("tasks/cancel"),params:lt.extend({taskId:y()})}),xv=Fe.merge(hn),Bl=C({uri:y(),mimeType:ee(y()),_meta:ce(y(),de()).optional()}),Kl=Bl.extend({text:y()}),Pi=y().refine(t=>{try{return atob(t),!0}catch{return!1}},{message:"Invalid Base64 string"}),Gl=Bl.extend({blob:Pi}),pn=qe(["user","assistant"]),xr=C({audience:x(pn).optional(),priority:ne().min(0).max(1).optional(),lastModified:kl({offset:!0}).optional()}),Yl=C({...Pr.shape,...un.shape,uri:y(),description:ee(y()),mimeType:ee(y()),annotations:xr.optional(),_meta:ee(Ee({}))}),Iv=C({...Pr.shape,...un.shape,uriTemplate:y(),description:ee(y()),mimeType:ee(y()),annotations:xr.optional(),_meta:ee(Ee({}))}),Cv=ln.extend({method:z("resources/list")}),Ql=dn.extend({resources:x(Yl)}),Ov=ln.extend({method:z("resources/templates/list")}),Xl=dn.extend({resourceTemplates:x(Iv)}),xi=lt.extend({uri:y()}),Nv=xi,Av=He.extend({method:z("resources/read"),params:Nv}),ed=Fe.extend({contents:x(ae([Kl,Gl]))}),td=pt.extend({method:z("notifications/resources/list_changed"),params:ft.optional()}),Mv=xi,jv=He.extend({method:z("resources/subscribe"),params:Mv}),qv=xi,zv=He.extend({method:z("resources/unsubscribe"),params:qv}),Uv=ft.extend({uri:y()}),Lv=pt.extend({method:z("notifications/resources/updated"),params:Uv}),Zv=C({name:y(),description:ee(y()),required:ee(oe())}),Dv=C({...Pr.shape,...un.shape,description:ee(y()),arguments:ee(x(Zv)),_meta:ee(Ee({}))}),Vv=ln.extend({method:z("prompts/list")}),rd=dn.extend({prompts:x(Dv)}),Hv=lt.extend({name:y(),arguments:ce(y(),y()).optional()}),Fv=He.extend({method:z("prompts/get"),params:Hv}),Ii=C({type:z("text"),text:y(),annotations:xr.optional(),_meta:ce(y(),de()).optional()}),Ci=C({type:z("image"),data:Pi,mimeType:y(),annotations:xr.optional(),_meta:ce(y(),de()).optional()}),Oi=C({type:z("audio"),data:Pi,mimeType:y(),annotations:xr.optional(),_meta:ce(y(),de()).optional()}),Wv=C({type:z("tool_use"),name:y(),id:y(),input:ce(y(),de()),_meta:ce(y(),de()).optional()}),Jv=C({type:z("resource"),resource:ae([Kl,Gl]),annotations:xr.optional(),_meta:ce(y(),de()).optional()}),Bv=Yl.extend({type:z("resource_link")}),Ni=ae([Ii,Ci,Oi,Bv,Jv]),Kv=C({role:pn,content:Ni}),nd=Fe.extend({description:y().optional(),messages:x(Kv)}),sd=pt.extend({method:z("notifications/prompts/list_changed"),params:ft.optional()}),Gv=C({title:y().optional(),readOnlyHint:oe().optional(),destructiveHint:oe().optional(),idempotentHint:oe().optional(),openWorldHint:oe().optional()}),Yv=C({taskSupport:qe(["required","optional","forbidden"]).optional()}),od=C({...Pr.shape,...un.shape,description:y().optional(),inputSchema:C({type:z("object"),properties:ce(y(),Ve).optional(),required:x(y()).optional()}).catchall(de()),outputSchema:C({type:z("object"),properties:ce(y(),Ve).optional(),required:x(y()).optional()}).catchall(de()).optional(),annotations:Gv.optional(),execution:Yv.optional(),_meta:ce(y(),de()).optional()}),Qv=ln.extend({method:z("tools/list")}),id=dn.extend({tools:x(od)}),Bs=Fe.extend({content:x(Ni).default([]),structuredContent:ce(y(),de()).optional(),isError:oe().optional()});Bs.or(Fe.extend({toolResult:de()}));const Xv=an.extend({name:y(),arguments:ce(y(),de()).optional()}),ey=He.extend({method:z("tools/call"),params:Xv}),ad=pt.extend({method:z("notifications/tools/list_changed"),params:ft.optional()}),ty=C({autoRefresh:oe().default(!0),debounceMs:ne().int().nonnegative().default(300)}),cd=qe(["debug","info","notice","warning","error","critical","alert","emergency"]),ry=lt.extend({level:cd}),ny=He.extend({method:z("logging/setLevel"),params:ry}),sy=ft.extend({level:cd,logger:y().optional(),data:de()}),oy=pt.extend({method:z("notifications/message"),params:sy}),iy=C({name:y().optional()}),ay=C({hints:x(iy).optional(),costPriority:ne().min(0).max(1).optional(),speedPriority:ne().min(0).max(1).optional(),intelligencePriority:ne().min(0).max(1).optional()}),cy=C({mode:qe(["auto","required","none"]).optional()}),uy=C({type:z("tool_result"),toolUseId:y().describe("The unique identifier for the corresponding tool call."),content:x(Ni).default([]),structuredContent:C({}).loose().optional(),isError:oe().optional(),_meta:ce(y(),de()).optional()}),ly=di("type",[Ii,Ci,Oi]),Ks=di("type",[Ii,Ci,Oi,Wv,uy]),dy=C({role:pn,content:ae([Ks,x(Ks)]),_meta:ce(y(),de()).optional()}),hy=an.extend({messages:x(dy),modelPreferences:ay.optional(),systemPrompt:y().optional(),includeContext:qe(["none","thisServer","allServers"]).optional(),temperature:ne().optional(),maxTokens:ne().int(),stopSequences:x(y()).optional(),metadata:Ve.optional(),tools:x(od).optional(),toolChoice:cy.optional()}),ud=He.extend({method:z("sampling/createMessage"),params:hy}),Ai=Fe.extend({model:y(),stopReason:ee(qe(["endTurn","stopSequence","maxTokens"]).or(y())),role:pn,content:ly}),fy=Fe.extend({model:y(),stopReason:ee(qe(["endTurn","stopSequence","maxTokens","toolUse"]).or(y())),role:pn,content:ae([Ks,x(Ks)])}),py=C({type:z("boolean"),title:y().optional(),description:y().optional(),default:oe().optional()}),my=C({type:z("string"),title:y().optional(),description:y().optional(),minLength:ne().optional(),maxLength:ne().optional(),format:qe(["email","uri","date","date-time"]).optional(),default:y().optional()}),_y=C({type:qe(["number","integer"]),title:y().optional(),description:y().optional(),minimum:ne().optional(),maximum:ne().optional(),default:ne().optional()}),gy=C({type:z("string"),title:y().optional(),description:y().optional(),enum:x(y()),default:y().optional()}),vy=C({type:z("string"),title:y().optional(),description:y().optional(),oneOf:x(C({const:y(),title:y()})),default:y().optional()}),yy=C({type:z("string"),title:y().optional(),description:y().optional(),enum:x(y()),enumNames:x(y()).optional(),default:y().optional()}),wy=ae([gy,vy]),by=C({type:z("array"),title:y().optional(),description:y().optional(),minItems:ne().optional(),maxItems:ne().optional(),items:C({type:z("string"),enum:x(y())}),default:x(y()).optional()}),$y=C({type:z("array"),title:y().optional(),description:y().optional(),minItems:ne().optional(),maxItems:ne().optional(),items:C({anyOf:x(C({const:y(),title:y()}))}),default:x(y()).optional()}),Sy=ae([by,$y]),ky=ae([yy,wy,Sy]),Ty=ae([ky,py,my,_y]),Ry=an.extend({mode:z("form").optional(),message:y(),requestedSchema:C({type:z("object"),properties:ce(y(),Ty),required:x(y()).optional()})}),Ey=an.extend({mode:z("url"),message:y(),elicitationId:y(),url:y().url()}),Py=ae([Ry,Ey]),ld=He.extend({method:z("elicitation/create"),params:Py}),xy=ft.extend({elicitationId:y()}),Iy=pt.extend({method:z("notifications/elicitation/complete"),params:xy}),Mi=Fe.extend({action:qe(["accept","decline","cancel"]),content:pi(t=>t===null?void 0:t,ce(y(),ae([y(),ne(),oe(),x(y())])).optional())}),Cy=C({type:z("ref/resource"),uri:y()}),Oy=C({type:z("ref/prompt"),name:y()}),Ny=lt.extend({ref:ae([Oy,Cy]),argument:C({name:y(),value:y()}),context:C({arguments:ce(y(),y()).optional()}).optional()}),Ay=He.extend({method:z("completion/complete"),params:Ny}),dd=Fe.extend({completion:Ee({values:x(y()).max(100),total:ee(ne().int()),hasMore:ee(oe())})}),My=C({uri:y().startsWith("file://"),name:y().optional(),_meta:ce(y(),de()).optional()}),jy=He.extend({method:z("roots/list"),params:lt.optional()}),hd=Fe.extend({roots:x(My)}),qy=pt.extend({method:z("notifications/roots/list_changed"),params:ft.optional()});ae([wi,bv,Ay,ny,Fv,Vv,Cv,Ov,Av,jv,zv,ey,Qv,$i,ki,Ti,Ei]),ae([yi,bi,Jl,qy,Js]),ae([pr,Ai,fy,Mi,hd,Si,Ri,fn]),ae([wi,ud,ld,jy,$i,ki,Ti,Ei]),ae([yi,bi,oy,Lv,td,ad,sd,Js,Iy]),ae([pr,Wl,dd,nd,rd,Ql,Xl,ed,Bs,id,Si,Ri,fn]);let ie=class bf extends Error{constructor(e,r,n){super(`MCP error ${e}: ${r}`),this.code=e,this.data=n,this.name="McpError"}static fromError(e,r,n){if(e===ue.UrlElicitationRequired&&n){const s=n;if(s.elicitations)return new zy(s.elicitations,r)}return new bf(e,r,n)}},zy=class extends ie{constructor(e,r=`URL elicitation${e.length>1?"s":""} required`){super(ue.UrlElicitationRequired,r,{elicitations:e})}get elicitations(){return this.data?.elicitations??[]}};var ge;(function(t){t.assertEqual=s=>{};function e(s){}t.assertIs=e;function r(s){throw new Error}t.assertNever=r,t.arrayToEnum=s=>{const o={};for(const i of s)o[i]=i;return o},t.getValidEnumValues=s=>{const o=t.objectKeys(s).filter(a=>typeof s[s[a]]!="number"),i={};for(const a of o)i[a]=s[a];return t.objectValues(i)},t.objectValues=s=>t.objectKeys(s).map(function(o){return s[o]}),t.objectKeys=typeof Object.keys=="function"?s=>Object.keys(s):s=>{const o=[];for(const i in s)Object.prototype.hasOwnProperty.call(s,i)&&o.push(i);return o},t.find=(s,o)=>{for(const i of s)if(o(i))return i},t.isInteger=typeof Number.isInteger=="function"?s=>Number.isInteger(s):s=>typeof s=="number"&&Number.isFinite(s)&&Math.floor(s)===s;function n(s,o=" | "){return s.map(i=>typeof i=="string"?`'${i}'`:i).join(o)}t.joinValues=n,t.jsonStringifyReplacer=(s,o)=>typeof o=="bigint"?o.toString():o})(ge||(ge={}));var ji;(function(t){t.mergeShapes=(e,r)=>({...e,...r})})(ji||(ji={}));const B=ge.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Zt=t=>{switch(typeof t){case"undefined":return B.undefined;case"string":return B.string;case"number":return Number.isNaN(t)?B.nan:B.number;case"boolean":return B.boolean;case"function":return B.function;case"bigint":return B.bigint;case"symbol":return B.symbol;case"object":return Array.isArray(t)?B.array:t===null?B.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?B.promise:typeof Map<"u"&&t instanceof Map?B.map:typeof Set<"u"&&t instanceof Set?B.set:typeof Date<"u"&&t instanceof Date?B.date:B.object;default:return B.unknown}},Z=ge.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),Uy=t=>JSON.stringify(t,null,2).replace(/"([^"]+)":/g,"$1:");class dt extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};const r=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,r):this.__proto__=r,this.name="ZodError",this.issues=e}format(e){const r=e||function(o){return o.message},n={_errors:[]},s=o=>{for(const i of o.issues)if(i.code==="invalid_union")i.unionErrors.map(s);else if(i.code==="invalid_return_type")s(i.returnTypeError);else if(i.code==="invalid_arguments")s(i.argumentsError);else if(i.path.length===0)n._errors.push(r(i));else{let a=n,c=0;for(;c<i.path.length;){const u=i.path[c];c===i.path.length-1?(a[u]=a[u]||{_errors:[]},a[u]._errors.push(r(i))):a[u]=a[u]||{_errors:[]},a=a[u],c++}}};return s(this),n}static assert(e){if(!(e instanceof dt))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,ge.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=r=>r.message){const r={},n=[];for(const s of this.issues)if(s.path.length>0){const o=s.path[0];r[o]=r[o]||[],r[o].push(e(s))}else n.push(e(s));return{formErrors:n,fieldErrors:r}}get formErrors(){return this.flatten()}}dt.create=t=>new dt(t);const Ir=(t,e)=>{let r;switch(t.code){case Z.invalid_type:t.received===B.undefined?r="Required":r=`Expected ${t.expected}, received ${t.received}`;break;case Z.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(t.expected,ge.jsonStringifyReplacer)}`;break;case Z.unrecognized_keys:r=`Unrecognized key(s) in object: ${ge.joinValues(t.keys,", ")}`;break;case Z.invalid_union:r="Invalid input";break;case Z.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${ge.joinValues(t.options)}`;break;case Z.invalid_enum_value:r=`Invalid enum value. Expected ${ge.joinValues(t.options)}, received '${t.received}'`;break;case Z.invalid_arguments:r="Invalid function arguments";break;case Z.invalid_return_type:r="Invalid function return type";break;case Z.invalid_date:r="Invalid date";break;case Z.invalid_string:typeof t.validation=="object"?"includes"in t.validation?(r=`Invalid input: must include "${t.validation.includes}"`,typeof t.validation.position=="number"&&(r=`${r} at one or more positions greater than or equal to ${t.validation.position}`)):"startsWith"in t.validation?r=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?r=`Invalid input: must end with "${t.validation.endsWith}"`:ge.assertNever(t.validation):t.validation!=="regex"?r=`Invalid ${t.validation}`:r="Invalid";break;case Z.too_small:t.type==="array"?r=`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:t.type==="string"?r=`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:t.type==="number"?r=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="bigint"?r=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="date"?r=`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(t.minimum))}`:r="Invalid input";break;case Z.too_big:t.type==="array"?r=`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:t.type==="string"?r=`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:t.type==="number"?r=`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="bigint"?r=`BigInt must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="date"?r=`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(t.maximum))}`:r="Invalid input";break;case Z.custom:r="Invalid input";break;case Z.invalid_intersection_types:r="Intersection results could not be merged";break;case Z.not_multiple_of:r=`Number must be a multiple of ${t.multipleOf}`;break;case Z.not_finite:r="Number must be finite";break;default:r=e.defaultError,ge.assertNever(t)}return{message:r}};let fd=Ir;function Ly(t){fd=t}function Gs(){return fd}const Ys=t=>{const{data:e,path:r,errorMaps:n,issueData:s}=t,o=[...r,...s.path||[]],i={...s,path:o};if(s.message!==void 0)return{...s,path:o,message:s.message};let a="";const c=n.filter(u=>!!u).slice().reverse();for(const u of c)a=u(i,{data:e,defaultError:a}).message;return{...s,path:o,message:a}},Zy=[];function J(t,e){const r=Gs(),n=Ys({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,r,r===Ir?void 0:Ir].filter(s=>!!s)});t.common.issues.push(n)}class Ye{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,r){const n=[];for(const s of r){if(s.status==="aborted")return se;s.status==="dirty"&&e.dirty(),n.push(s.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,r){const n=[];for(const s of r){const o=await s.key,i=await s.value;n.push({key:o,value:i})}return Ye.mergeObjectSync(e,n)}static mergeObjectSync(e,r){const n={};for(const s of r){const{key:o,value:i}=s;if(o.status==="aborted"||i.status==="aborted")return se;o.status==="dirty"&&e.dirty(),i.status==="dirty"&&e.dirty(),o.value!=="__proto__"&&(typeof i.value<"u"||s.alwaysSet)&&(n[o.value]=i.value)}return{status:e.value,value:n}}}const se=Object.freeze({status:"aborted"}),Cr=t=>({status:"dirty",value:t}),Xe=t=>({status:"valid",value:t}),qi=t=>t.status==="aborted",zi=t=>t.status==="dirty",mr=t=>t.status==="valid",mn=t=>typeof Promise<"u"&&t instanceof Promise;var Q;(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e?.message})(Q||(Q={}));class At{constructor(e,r,n,s){this._cachedPath=[],this.parent=e,this.data=r,this._path=n,this._key=s}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const pd=(t,e)=>{if(mr(e))return{success:!0,data:e.value};if(!t.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const r=new dt(t.common.issues);return this._error=r,this._error}}};function le(t){if(!t)return{};const{errorMap:e,invalid_type_error:r,required_error:n,description:s}=t;if(e&&(r||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:s}:{errorMap:(i,a)=>{const{message:c}=t;return i.code==="invalid_enum_value"?{message:c??a.defaultError}:typeof a.data>"u"?{message:c??n??a.defaultError}:i.code!=="invalid_type"?{message:a.defaultError}:{message:c??r??a.defaultError}},description:s}}class he{get description(){return this._def.description}_getType(e){return Zt(e.data)}_getOrReturnCtx(e,r){return r||{common:e.parent.common,data:e.data,parsedType:Zt(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new Ye,ctx:{common:e.parent.common,data:e.data,parsedType:Zt(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const r=this._parse(e);if(mn(r))throw new Error("Synchronous parse encountered promise.");return r}_parseAsync(e){const r=this._parse(e);return Promise.resolve(r)}parse(e,r){const n=this.safeParse(e,r);if(n.success)return n.data;throw n.error}safeParse(e,r){const n={common:{issues:[],async:r?.async??!1,contextualErrorMap:r?.errorMap},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Zt(e)},s=this._parseSync({data:e,path:n.path,parent:n});return pd(n,s)}"~validate"(e){const r={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Zt(e)};if(!this["~standard"].async)try{const n=this._parseSync({data:e,path:[],parent:r});return mr(n)?{value:n.value}:{issues:r.common.issues}}catch(n){n?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),r.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:r}).then(n=>mr(n)?{value:n.value}:{issues:r.common.issues})}async parseAsync(e,r){const n=await this.safeParseAsync(e,r);if(n.success)return n.data;throw n.error}async safeParseAsync(e,r){const n={common:{issues:[],contextualErrorMap:r?.errorMap,async:!0},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Zt(e)},s=this._parse({data:e,path:n.path,parent:n}),o=await(mn(s)?s:Promise.resolve(s));return pd(n,o)}refine(e,r){const n=s=>typeof r=="string"||typeof r>"u"?{message:r}:typeof r=="function"?r(s):r;return this._refinement((s,o)=>{const i=e(s),a=()=>o.addIssue({code:Z.custom,...n(s)});return typeof Promise<"u"&&i instanceof Promise?i.then(c=>c?!0:(a(),!1)):i?!0:(a(),!1)})}refinement(e,r){return this._refinement((n,s)=>e(n)?!0:(s.addIssue(typeof r=="function"?r(n,s):r),!1))}_refinement(e){return new $t({schema:this,typeName:D.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:r=>this["~validate"](r)}}optional(){return jt.create(this,this._def)}nullable(){return rr.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return bt.create(this)}promise(){return Mr.create(this,this._def)}or(e){return yn.create([this,e],this._def)}and(e){return wn.create(this,e,this._def)}transform(e){return new $t({...le(this._def),schema:this,typeName:D.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const r=typeof e=="function"?e:()=>e;return new Tn({...le(this._def),innerType:this,defaultValue:r,typeName:D.ZodDefault})}brand(){return new Zi({typeName:D.ZodBranded,type:this,...le(this._def)})}catch(e){const r=typeof e=="function"?e:()=>e;return new Rn({...le(this._def),innerType:this,catchValue:r,typeName:D.ZodCatch})}describe(e){const r=this.constructor;return new r({...this._def,description:e})}pipe(e){return En.create(this,e)}readonly(){return Pn.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const Dy=/^c[^\s-]{8,}$/i,Vy=/^[0-9a-z]+$/,Hy=/^[0-9A-HJKMNP-TV-Z]{26}$/i,Fy=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,Wy=/^[a-z0-9_-]{21}$/i,Jy=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,By=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,Ky=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Gy="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let Ui;const Yy=/^(?:(?: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])$/,Qy=/^(?:(?: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])\/(3[0-2]|[12]?[0-9])$/,Xy=/^(([0-9a-fA-F]{1,4}:){7,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}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,e0=/^(([0-9a-fA-F]{1,4}:){7,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}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,t0=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,r0=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,md="((\\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])))",n0=new RegExp(`^${md}$`);function _d(t){let e="[0-5]\\d";t.precision?e=`${e}\\.\\d{${t.precision}}`:t.precision==null&&(e=`${e}(\\.\\d+)?`);const r=t.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${e})${r}`}function s0(t){return new RegExp(`^${_d(t)}$`)}function gd(t){let e=`${md}T${_d(t)}`;const r=[];return r.push(t.local?"Z?":"Z"),t.offset&&r.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${r.join("|")})`,new RegExp(`^${e}$`)}function o0(t,e){return!!((e==="v4"||!e)&&Yy.test(t)||(e==="v6"||!e)&&Xy.test(t))}function i0(t,e){if(!Jy.test(t))return!1;try{const[r]=t.split(".");if(!r)return!1;const n=r.replace(/-/g,"+").replace(/_/g,"/").padEnd(r.length+(4-r.length%4)%4,"="),s=JSON.parse(atob(n));return!(typeof s!="object"||s===null||"typ"in s&&s?.typ!=="JWT"||!s.alg||e&&s.alg!==e)}catch{return!1}}function a0(t,e){return!!((e==="v4"||!e)&&Qy.test(t)||(e==="v6"||!e)&&e0.test(t))}class wt extends he{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==B.string){const o=this._getOrReturnCtx(e);return J(o,{code:Z.invalid_type,expected:B.string,received:o.parsedType}),se}const n=new Ye;let s;for(const o of this._def.checks)if(o.kind==="min")e.data.length<o.value&&(s=this._getOrReturnCtx(e,s),J(s,{code:Z.too_small,minimum:o.value,type:"string",inclusive:!0,exact:!1,message:o.message}),n.dirty());else if(o.kind==="max")e.data.length>o.value&&(s=this._getOrReturnCtx(e,s),J(s,{code:Z.too_big,maximum:o.value,type:"string",inclusive:!0,exact:!1,message:o.message}),n.dirty());else if(o.kind==="length"){const i=e.data.length>o.value,a=e.data.length<o.value;(i||a)&&(s=this._getOrReturnCtx(e,s),i?J(s,{code:Z.too_big,maximum:o.value,type:"string",inclusive:!0,exact:!0,message:o.message}):a&&J(s,{code:Z.too_small,minimum:o.value,type:"string",inclusive:!0,exact:!0,message:o.message}),n.dirty())}else if(o.kind==="email")Ky.test(e.data)||(s=this._getOrReturnCtx(e,s),J(s,{validation:"email",code:Z.invalid_string,message:o.message}),n.dirty());else if(o.kind==="emoji")Ui||(Ui=new RegExp(Gy,"u")),Ui.test(e.data)||(s=this._getOrReturnCtx(e,s),J(s,{validation:"emoji",code:Z.invalid_string,message:o.message}),n.dirty());else if(o.kind==="uuid")Fy.test(e.data)||(s=this._getOrReturnCtx(e,s),J(s,{validation:"uuid",code:Z.invalid_string,message:o.message}),n.dirty());else if(o.kind==="nanoid")Wy.test(e.data)||(s=this._getOrReturnCtx(e,s),J(s,{validation:"nanoid",code:Z.invalid_string,message:o.message}),n.dirty());else if(o.kind==="cuid")Dy.test(e.data)||(s=this._getOrReturnCtx(e,s),J(s,{validation:"cuid",code:Z.invalid_string,message:o.message}),n.dirty());else if(o.kind==="cuid2")Vy.test(e.data)||(s=this._getOrReturnCtx(e,s),J(s,{validation:"cuid2",code:Z.invalid_string,message:o.message}),n.dirty());else if(o.kind==="ulid")Hy.test(e.data)||(s=this._getOrReturnCtx(e,s),J(s,{validation:"ulid",code:Z.invalid_string,message:o.message}),n.dirty());else if(o.kind==="url")try{new URL(e.data)}catch{s=this._getOrReturnCtx(e,s),J(s,{validation:"url",code:Z.invalid_string,message:o.message}),n.dirty()}else o.kind==="regex"?(o.regex.lastIndex=0,o.regex.test(e.data)||(s=this._getOrReturnCtx(e,s),J(s,{validation:"regex",code:Z.invalid_string,message:o.message}),n.dirty())):o.kind==="trim"?e.data=e.data.trim():o.kind==="includes"?e.data.includes(o.value,o.position)||(s=this._getOrReturnCtx(e,s),J(s,{code:Z.invalid_string,validation:{includes:o.value,position:o.position},message:o.message}),n.dirty()):o.kind==="toLowerCase"?e.data=e.data.toLowerCase():o.kind==="toUpperCase"?e.data=e.data.toUpperCase():o.kind==="startsWith"?e.data.startsWith(o.value)||(s=this._getOrReturnCtx(e,s),J(s,{code:Z.invalid_string,validation:{startsWith:o.value},message:o.message}),n.dirty()):o.kind==="endsWith"?e.data.endsWith(o.value)||(s=this._getOrReturnCtx(e,s),J(s,{code:Z.invalid_string,validation:{endsWith:o.value},message:o.message}),n.dirty()):o.kind==="datetime"?gd(o).test(e.data)||(s=this._getOrReturnCtx(e,s),J(s,{code:Z.invalid_string,validation:"datetime",message:o.message}),n.dirty()):o.kind==="date"?n0.test(e.data)||(s=this._getOrReturnCtx(e,s),J(s,{code:Z.invalid_string,validation:"date",message:o.message}),n.dirty()):o.kind==="time"?s0(o).test(e.data)||(s=this._getOrReturnCtx(e,s),J(s,{code:Z.invalid_string,validation:"time",message:o.message}),n.dirty()):o.kind==="duration"?By.test(e.data)||(s=this._getOrReturnCtx(e,s),J(s,{validation:"duration",code:Z.invalid_string,message:o.message}),n.dirty()):o.kind==="ip"?o0(e.data,o.version)||(s=this._getOrReturnCtx(e,s),J(s,{validation:"ip",code:Z.invalid_string,message:o.message}),n.dirty()):o.kind==="jwt"?i0(e.data,o.alg)||(s=this._getOrReturnCtx(e,s),J(s,{validation:"jwt",code:Z.invalid_string,message:o.message}),n.dirty()):o.kind==="cidr"?a0(e.data,o.version)||(s=this._getOrReturnCtx(e,s),J(s,{validation:"cidr",code:Z.invalid_string,message:o.message}),n.dirty()):o.kind==="base64"?t0.test(e.data)||(s=this._getOrReturnCtx(e,s),J(s,{validation:"base64",code:Z.invalid_string,message:o.message}),n.dirty()):o.kind==="base64url"?r0.test(e.data)||(s=this._getOrReturnCtx(e,s),J(s,{validation:"base64url",code:Z.invalid_string,message:o.message}),n.dirty()):ge.assertNever(o);return{status:n.value,value:e.data}}_regex(e,r,n){return this.refinement(s=>e.test(s),{validation:r,code:Z.invalid_string,...Q.errToObj(n)})}_addCheck(e){return new wt({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...Q.errToObj(e)})}url(e){return this._addCheck({kind:"url",...Q.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...Q.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...Q.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...Q.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...Q.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...Q.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...Q.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...Q.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...Q.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...Q.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...Q.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...Q.errToObj(e)})}datetime(e){return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof e?.precision>"u"?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...Q.errToObj(e?.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof e?.precision>"u"?null:e?.precision,...Q.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...Q.errToObj(e)})}regex(e,r){return this._addCheck({kind:"regex",regex:e,...Q.errToObj(r)})}includes(e,r){return this._addCheck({kind:"includes",value:e,position:r?.position,...Q.errToObj(r?.message)})}startsWith(e,r){return this._addCheck({kind:"startsWith",value:e,...Q.errToObj(r)})}endsWith(e,r){return this._addCheck({kind:"endsWith",value:e,...Q.errToObj(r)})}min(e,r){return this._addCheck({kind:"min",value:e,...Q.errToObj(r)})}max(e,r){return this._addCheck({kind:"max",value:e,...Q.errToObj(r)})}length(e,r){return this._addCheck({kind:"length",value:e,...Q.errToObj(r)})}nonempty(e){return this.min(1,Q.errToObj(e))}trim(){return new wt({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new wt({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new wt({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isCIDR(){return!!this._def.checks.find(e=>e.kind==="cidr")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get isBase64url(){return!!this._def.checks.find(e=>e.kind==="base64url")}get minLength(){let e=null;for(const r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxLength(){let e=null;for(const r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}}wt.create=t=>new wt({checks:[],typeName:D.ZodString,coerce:t?.coerce??!1,...le(t)});function c0(t,e){const r=(t.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,s=r>n?r:n,o=Number.parseInt(t.toFixed(s).replace(".","")),i=Number.parseInt(e.toFixed(s).replace(".",""));return o%i/10**s}class Xt extends he{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==B.number){const o=this._getOrReturnCtx(e);return J(o,{code:Z.invalid_type,expected:B.number,received:o.parsedType}),se}let n;const s=new Ye;for(const o of this._def.checks)o.kind==="int"?ge.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),J(n,{code:Z.invalid_type,expected:"integer",received:"float",message:o.message}),s.dirty()):o.kind==="min"?(o.inclusive?e.data<o.value:e.data<=o.value)&&(n=this._getOrReturnCtx(e,n),J(n,{code:Z.too_small,minimum:o.value,type:"number",inclusive:o.inclusive,exact:!1,message:o.message}),s.dirty()):o.kind==="max"?(o.inclusive?e.data>o.value:e.data>=o.value)&&(n=this._getOrReturnCtx(e,n),J(n,{code:Z.too_big,maximum:o.value,type:"number",inclusive:o.inclusive,exact:!1,message:o.message}),s.dirty()):o.kind==="multipleOf"?c0(e.data,o.value)!==0&&(n=this._getOrReturnCtx(e,n),J(n,{code:Z.not_multiple_of,multipleOf:o.value,message:o.message}),s.dirty()):o.kind==="finite"?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),J(n,{code:Z.not_finite,message:o.message}),s.dirty()):ge.assertNever(o);return{status:s.value,value:e.data}}gte(e,r){return this.setLimit("min",e,!0,Q.toString(r))}gt(e,r){return this.setLimit("min",e,!1,Q.toString(r))}lte(e,r){return this.setLimit("max",e,!0,Q.toString(r))}lt(e,r){return this.setLimit("max",e,!1,Q.toString(r))}setLimit(e,r,n,s){return new Xt({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:n,message:Q.toString(s)}]})}_addCheck(e){return new Xt({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:Q.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:Q.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:Q.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:Q.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:Q.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:Q.toString(r)})}finite(e){return this._addCheck({kind:"finite",message:Q.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:Q.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:Q.toString(e)})}get minValue(){let e=null;for(const r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxValue(){let e=null;for(const r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&ge.isInteger(e.value))}get isFinite(){let e=null,r=null;for(const n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(r===null||n.value>r)&&(r=n.value):n.kind==="max"&&(e===null||n.value<e)&&(e=n.value)}return Number.isFinite(r)&&Number.isFinite(e)}}Xt.create=t=>new Xt({checks:[],typeName:D.ZodNumber,coerce:t?.coerce||!1,...le(t)});class er extends he{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==B.bigint)return this._getInvalidInput(e);let n;const s=new Ye;for(const o of this._def.checks)o.kind==="min"?(o.inclusive?e.data<o.value:e.data<=o.value)&&(n=this._getOrReturnCtx(e,n),J(n,{code:Z.too_small,type:"bigint",minimum:o.value,inclusive:o.inclusive,message:o.message}),s.dirty()):o.kind==="max"?(o.inclusive?e.data>o.value:e.data>=o.value)&&(n=this._getOrReturnCtx(e,n),J(n,{code:Z.too_big,type:"bigint",maximum:o.value,inclusive:o.inclusive,message:o.message}),s.dirty()):o.kind==="multipleOf"?e.data%o.value!==BigInt(0)&&(n=this._getOrReturnCtx(e,n),J(n,{code:Z.not_multiple_of,multipleOf:o.value,message:o.message}),s.dirty()):ge.assertNever(o);return{status:s.value,value:e.data}}_getInvalidInput(e){const r=this._getOrReturnCtx(e);return J(r,{code:Z.invalid_type,expected:B.bigint,received:r.parsedType}),se}gte(e,r){return this.setLimit("min",e,!0,Q.toString(r))}gt(e,r){return this.setLimit("min",e,!1,Q.toString(r))}lte(e,r){return this.setLimit("max",e,!0,Q.toString(r))}lt(e,r){return this.setLimit("max",e,!1,Q.toString(r))}setLimit(e,r,n,s){return new er({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:n,message:Q.toString(s)}]})}_addCheck(e){return new er({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:Q.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:Q.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:Q.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:Q.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:Q.toString(r)})}get minValue(){let e=null;for(const r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxValue(){let e=null;for(const r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}}er.create=t=>new er({checks:[],typeName:D.ZodBigInt,coerce:t?.coerce??!1,...le(t)});class _n extends he{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==B.boolean){const n=this._getOrReturnCtx(e);return J(n,{code:Z.invalid_type,expected:B.boolean,received:n.parsedType}),se}return Xe(e.data)}}_n.create=t=>new _n({typeName:D.ZodBoolean,coerce:t?.coerce||!1,...le(t)});class _r extends he{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==B.date){const o=this._getOrReturnCtx(e);return J(o,{code:Z.invalid_type,expected:B.date,received:o.parsedType}),se}if(Number.isNaN(e.data.getTime())){const o=this._getOrReturnCtx(e);return J(o,{code:Z.invalid_date}),se}const n=new Ye;let s;for(const o of this._def.checks)o.kind==="min"?e.data.getTime()<o.value&&(s=this._getOrReturnCtx(e,s),J(s,{code:Z.too_small,message:o.message,inclusive:!0,exact:!1,minimum:o.value,type:"date"}),n.dirty()):o.kind==="max"?e.data.getTime()>o.value&&(s=this._getOrReturnCtx(e,s),J(s,{code:Z.too_big,message:o.message,inclusive:!0,exact:!1,maximum:o.value,type:"date"}),n.dirty()):ge.assertNever(o);return{status:n.value,value:new Date(e.data.getTime())}}_addCheck(e){return new _r({...this._def,checks:[...this._def.checks,e]})}min(e,r){return this._addCheck({kind:"min",value:e.getTime(),message:Q.toString(r)})}max(e,r){return this._addCheck({kind:"max",value:e.getTime(),message:Q.toString(r)})}get minDate(){let e=null;for(const r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(const r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e!=null?new Date(e):null}}_r.create=t=>new _r({checks:[],coerce:t?.coerce||!1,typeName:D.ZodDate,...le(t)});class Qs extends he{_parse(e){if(this._getType(e)!==B.symbol){const n=this._getOrReturnCtx(e);return J(n,{code:Z.invalid_type,expected:B.symbol,received:n.parsedType}),se}return Xe(e.data)}}Qs.create=t=>new Qs({typeName:D.ZodSymbol,...le(t)});class gn extends he{_parse(e){if(this._getType(e)!==B.undefined){const n=this._getOrReturnCtx(e);return J(n,{code:Z.invalid_type,expected:B.undefined,received:n.parsedType}),se}return Xe(e.data)}}gn.create=t=>new gn({typeName:D.ZodUndefined,...le(t)});class vn extends he{_parse(e){if(this._getType(e)!==B.null){const n=this._getOrReturnCtx(e);return J(n,{code:Z.invalid_type,expected:B.null,received:n.parsedType}),se}return Xe(e.data)}}vn.create=t=>new vn({typeName:D.ZodNull,...le(t)});class Or extends he{constructor(){super(...arguments),this._any=!0}_parse(e){return Xe(e.data)}}Or.create=t=>new Or({typeName:D.ZodAny,...le(t)});class gr extends he{constructor(){super(...arguments),this._unknown=!0}_parse(e){return Xe(e.data)}}gr.create=t=>new gr({typeName:D.ZodUnknown,...le(t)});class Dt extends he{_parse(e){const r=this._getOrReturnCtx(e);return J(r,{code:Z.invalid_type,expected:B.never,received:r.parsedType}),se}}Dt.create=t=>new Dt({typeName:D.ZodNever,...le(t)});class Xs extends he{_parse(e){if(this._getType(e)!==B.undefined){const n=this._getOrReturnCtx(e);return J(n,{code:Z.invalid_type,expected:B.void,received:n.parsedType}),se}return Xe(e.data)}}Xs.create=t=>new Xs({typeName:D.ZodVoid,...le(t)});class bt extends he{_parse(e){const{ctx:r,status:n}=this._processInputParams(e),s=this._def;if(r.parsedType!==B.array)return J(r,{code:Z.invalid_type,expected:B.array,received:r.parsedType}),se;if(s.exactLength!==null){const i=r.data.length>s.exactLength.value,a=r.data.length<s.exactLength.value;(i||a)&&(J(r,{code:i?Z.too_big:Z.too_small,minimum:a?s.exactLength.value:void 0,maximum:i?s.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:s.exactLength.message}),n.dirty())}if(s.minLength!==null&&r.data.length<s.minLength.value&&(J(r,{code:Z.too_small,minimum:s.minLength.value,type:"array",inclusive:!0,exact:!1,message:s.minLength.message}),n.dirty()),s.maxLength!==null&&r.data.length>s.maxLength.value&&(J(r,{code:Z.too_big,maximum:s.maxLength.value,type:"array",inclusive:!0,exact:!1,message:s.maxLength.message}),n.dirty()),r.common.async)return Promise.all([...r.data].map((i,a)=>s.type._parseAsync(new At(r,i,r.path,a)))).then(i=>Ye.mergeArray(n,i));const o=[...r.data].map((i,a)=>s.type._parseSync(new At(r,i,r.path,a)));return Ye.mergeArray(n,o)}get element(){return this._def.type}min(e,r){return new bt({...this._def,minLength:{value:e,message:Q.toString(r)}})}max(e,r){return new bt({...this._def,maxLength:{value:e,message:Q.toString(r)}})}length(e,r){return new bt({...this._def,exactLength:{value:e,message:Q.toString(r)}})}nonempty(e){return this.min(1,e)}}bt.create=(t,e)=>new bt({type:t,minLength:null,maxLength:null,exactLength:null,typeName:D.ZodArray,...le(e)});function Nr(t){if(t instanceof ze){const e={};for(const r in t.shape){const n=t.shape[r];e[r]=jt.create(Nr(n))}return new ze({...t._def,shape:()=>e})}else return t instanceof bt?new bt({...t._def,type:Nr(t.element)}):t instanceof jt?jt.create(Nr(t.unwrap())):t instanceof rr?rr.create(Nr(t.unwrap())):t instanceof Mt?Mt.create(t.items.map(e=>Nr(e))):t}class ze extends he{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const e=this._def.shape(),r=ge.objectKeys(e);return this._cached={shape:e,keys:r},this._cached}_parse(e){if(this._getType(e)!==B.object){const u=this._getOrReturnCtx(e);return J(u,{code:Z.invalid_type,expected:B.object,received:u.parsedType}),se}const{status:n,ctx:s}=this._processInputParams(e),{shape:o,keys:i}=this._getCached(),a=[];if(!(this._def.catchall instanceof Dt&&this._def.unknownKeys==="strip"))for(const u in s.data)i.includes(u)||a.push(u);const c=[];for(const u of i){const l=o[u],d=s.data[u];c.push({key:{status:"valid",value:u},value:l._parse(new At(s,d,s.path,u)),alwaysSet:u in s.data})}if(this._def.catchall instanceof Dt){const u=this._def.unknownKeys;if(u==="passthrough")for(const l of a)c.push({key:{status:"valid",value:l},value:{status:"valid",value:s.data[l]}});else if(u==="strict")a.length>0&&(J(s,{code:Z.unrecognized_keys,keys:a}),n.dirty());else if(u!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const u=this._def.catchall;for(const l of a){const d=s.data[l];c.push({key:{status:"valid",value:l},value:u._parse(new At(s,d,s.path,l)),alwaysSet:l in s.data})}}return s.common.async?Promise.resolve().then(async()=>{const u=[];for(const l of c){const d=await l.key,p=await l.value;u.push({key:d,value:p,alwaysSet:l.alwaysSet})}return u}).then(u=>Ye.mergeObjectSync(n,u)):Ye.mergeObjectSync(n,c)}get shape(){return this._def.shape()}strict(e){return Q.errToObj,new ze({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(r,n)=>{const s=this._def.errorMap?.(r,n).message??n.defaultError;return r.code==="unrecognized_keys"?{message:Q.errToObj(e).message??s}:{message:s}}}:{}})}strip(){return new ze({...this._def,unknownKeys:"strip"})}passthrough(){return new ze({...this._def,unknownKeys:"passthrough"})}extend(e){return new ze({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new ze({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:D.ZodObject})}setKey(e,r){return this.augment({[e]:r})}catchall(e){return new ze({...this._def,catchall:e})}pick(e){const r={};for(const n of ge.objectKeys(e))e[n]&&this.shape[n]&&(r[n]=this.shape[n]);return new ze({...this._def,shape:()=>r})}omit(e){const r={};for(const n of ge.objectKeys(this.shape))e[n]||(r[n]=this.shape[n]);return new ze({...this._def,shape:()=>r})}deepPartial(){return Nr(this)}partial(e){const r={};for(const n of ge.objectKeys(this.shape)){const s=this.shape[n];e&&!e[n]?r[n]=s:r[n]=s.optional()}return new ze({...this._def,shape:()=>r})}required(e){const r={};for(const n of ge.objectKeys(this.shape))if(e&&!e[n])r[n]=this.shape[n];else{let o=this.shape[n];for(;o instanceof jt;)o=o._def.innerType;r[n]=o}return new ze({...this._def,shape:()=>r})}keyof(){return vd(ge.objectKeys(this.shape))}}ze.create=(t,e)=>new ze({shape:()=>t,unknownKeys:"strip",catchall:Dt.create(),typeName:D.ZodObject,...le(e)}),ze.strictCreate=(t,e)=>new ze({shape:()=>t,unknownKeys:"strict",catchall:Dt.create(),typeName:D.ZodObject,...le(e)}),ze.lazycreate=(t,e)=>new ze({shape:t,unknownKeys:"strip",catchall:Dt.create(),typeName:D.ZodObject,...le(e)});class yn extends he{_parse(e){const{ctx:r}=this._processInputParams(e),n=this._def.options;function s(o){for(const a of o)if(a.result.status==="valid")return a.result;for(const a of o)if(a.result.status==="dirty")return r.common.issues.push(...a.ctx.common.issues),a.result;const i=o.map(a=>new dt(a.ctx.common.issues));return J(r,{code:Z.invalid_union,unionErrors:i}),se}if(r.common.async)return Promise.all(n.map(async o=>{const i={...r,common:{...r.common,issues:[]},parent:null};return{result:await o._parseAsync({data:r.data,path:r.path,parent:i}),ctx:i}})).then(s);{let o;const i=[];for(const c of n){const u={...r,common:{...r.common,issues:[]},parent:null},l=c._parseSync({data:r.data,path:r.path,parent:u});if(l.status==="valid")return l;l.status==="dirty"&&!o&&(o={result:l,ctx:u}),u.common.issues.length&&i.push(u.common.issues)}if(o)return r.common.issues.push(...o.ctx.common.issues),o.result;const a=i.map(c=>new dt(c));return J(r,{code:Z.invalid_union,unionErrors:a}),se}}get options(){return this._def.options}}yn.create=(t,e)=>new yn({options:t,typeName:D.ZodUnion,...le(e)});const Vt=t=>t instanceof $n?Vt(t.schema):t instanceof $t?Vt(t.innerType()):t instanceof Sn?[t.value]:t instanceof tr?t.options:t instanceof kn?ge.objectValues(t.enum):t instanceof Tn?Vt(t._def.innerType):t instanceof gn?[void 0]:t instanceof vn?[null]:t instanceof jt?[void 0,...Vt(t.unwrap())]:t instanceof rr?[null,...Vt(t.unwrap())]:t instanceof Zi||t instanceof Pn?Vt(t.unwrap()):t instanceof Rn?Vt(t._def.innerType):[];class eo extends he{_parse(e){const{ctx:r}=this._processInputParams(e);if(r.parsedType!==B.object)return J(r,{code:Z.invalid_type,expected:B.object,received:r.parsedType}),se;const n=this.discriminator,s=r.data[n],o=this.optionsMap.get(s);return o?r.common.async?o._parseAsync({data:r.data,path:r.path,parent:r}):o._parseSync({data:r.data,path:r.path,parent:r}):(J(r,{code:Z.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),se)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,r,n){const s=new Map;for(const o of r){const i=Vt(o.shape[e]);if(!i.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const a of i){if(s.has(a))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(a)}`);s.set(a,o)}}return new eo({typeName:D.ZodDiscriminatedUnion,discriminator:e,options:r,optionsMap:s,...le(n)})}}function Li(t,e){const r=Zt(t),n=Zt(e);if(t===e)return{valid:!0,data:t};if(r===B.object&&n===B.object){const s=ge.objectKeys(e),o=ge.objectKeys(t).filter(a=>s.indexOf(a)!==-1),i={...t,...e};for(const a of o){const c=Li(t[a],e[a]);if(!c.valid)return{valid:!1};i[a]=c.data}return{valid:!0,data:i}}else if(r===B.array&&n===B.array){if(t.length!==e.length)return{valid:!1};const s=[];for(let o=0;o<t.length;o++){const i=t[o],a=e[o],c=Li(i,a);if(!c.valid)return{valid:!1};s.push(c.data)}return{valid:!0,data:s}}else return r===B.date&&n===B.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}class wn extends he{_parse(e){const{status:r,ctx:n}=this._processInputParams(e),s=(o,i)=>{if(qi(o)||qi(i))return se;const a=Li(o.value,i.value);return a.valid?((zi(o)||zi(i))&&r.dirty(),{status:r.value,value:a.data}):(J(n,{code:Z.invalid_intersection_types}),se)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([o,i])=>s(o,i)):s(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}}wn.create=(t,e,r)=>new wn({left:t,right:e,typeName:D.ZodIntersection,...le(r)});class Mt extends he{_parse(e){const{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==B.array)return J(n,{code:Z.invalid_type,expected:B.array,received:n.parsedType}),se;if(n.data.length<this._def.items.length)return J(n,{code:Z.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),se;!this._def.rest&&n.data.length>this._def.items.length&&(J(n,{code:Z.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),r.dirty());const o=[...n.data].map((i,a)=>{const c=this._def.items[a]||this._def.rest;return c?c._parse(new At(n,i,n.path,a)):null}).filter(i=>!!i);return n.common.async?Promise.all(o).then(i=>Ye.mergeArray(r,i)):Ye.mergeArray(r,o)}get items(){return this._def.items}rest(e){return new Mt({...this._def,rest:e})}}Mt.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Mt({items:t,typeName:D.ZodTuple,rest:null,...le(e)})};class bn extends he{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==B.object)return J(n,{code:Z.invalid_type,expected:B.object,received:n.parsedType}),se;const s=[],o=this._def.keyType,i=this._def.valueType;for(const a in n.data)s.push({key:o._parse(new At(n,a,n.path,a)),value:i._parse(new At(n,n.data[a],n.path,a)),alwaysSet:a in n.data});return n.common.async?Ye.mergeObjectAsync(r,s):Ye.mergeObjectSync(r,s)}get element(){return this._def.valueType}static create(e,r,n){return r instanceof he?new bn({keyType:e,valueType:r,typeName:D.ZodRecord,...le(n)}):new bn({keyType:wt.create(),valueType:e,typeName:D.ZodRecord,...le(r)})}}class to extends he{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==B.map)return J(n,{code:Z.invalid_type,expected:B.map,received:n.parsedType}),se;const s=this._def.keyType,o=this._def.valueType,i=[...n.data.entries()].map(([a,c],u)=>({key:s._parse(new At(n,a,n.path,[u,"key"])),value:o._parse(new At(n,c,n.path,[u,"value"]))}));if(n.common.async){const a=new Map;return Promise.resolve().then(async()=>{for(const c of i){const u=await c.key,l=await c.value;if(u.status==="aborted"||l.status==="aborted")return se;(u.status==="dirty"||l.status==="dirty")&&r.dirty(),a.set(u.value,l.value)}return{status:r.value,value:a}})}else{const a=new Map;for(const c of i){const u=c.key,l=c.value;if(u.status==="aborted"||l.status==="aborted")return se;(u.status==="dirty"||l.status==="dirty")&&r.dirty(),a.set(u.value,l.value)}return{status:r.value,value:a}}}}to.create=(t,e,r)=>new to({valueType:e,keyType:t,typeName:D.ZodMap,...le(r)});class vr extends he{_parse(e){const{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==B.set)return J(n,{code:Z.invalid_type,expected:B.set,received:n.parsedType}),se;const s=this._def;s.minSize!==null&&n.data.size<s.minSize.value&&(J(n,{code:Z.too_small,minimum:s.minSize.value,type:"set",inclusive:!0,exact:!1,message:s.minSize.message}),r.dirty()),s.maxSize!==null&&n.data.size>s.maxSize.value&&(J(n,{code:Z.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),r.dirty());const o=this._def.valueType;function i(c){const u=new Set;for(const l of c){if(l.status==="aborted")return se;l.status==="dirty"&&r.dirty(),u.add(l.value)}return{status:r.value,value:u}}const a=[...n.data.values()].map((c,u)=>o._parse(new At(n,c,n.path,u)));return n.common.async?Promise.all(a).then(c=>i(c)):i(a)}min(e,r){return new vr({...this._def,minSize:{value:e,message:Q.toString(r)}})}max(e,r){return new vr({...this._def,maxSize:{value:e,message:Q.toString(r)}})}size(e,r){return this.min(e,r).max(e,r)}nonempty(e){return this.min(1,e)}}vr.create=(t,e)=>new vr({valueType:t,minSize:null,maxSize:null,typeName:D.ZodSet,...le(e)});class Ar extends he{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:r}=this._processInputParams(e);if(r.parsedType!==B.function)return J(r,{code:Z.invalid_type,expected:B.function,received:r.parsedType}),se;function n(a,c){return Ys({data:a,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,Gs(),Ir].filter(u=>!!u),issueData:{code:Z.invalid_arguments,argumentsError:c}})}function s(a,c){return Ys({data:a,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,Gs(),Ir].filter(u=>!!u),issueData:{code:Z.invalid_return_type,returnTypeError:c}})}const o={errorMap:r.common.contextualErrorMap},i=r.data;if(this._def.returns instanceof Mr){const a=this;return Xe(async function(...c){const u=new dt([]),l=await a._def.args.parseAsync(c,o).catch(_=>{throw u.addIssue(n(c,_)),u}),d=await Reflect.apply(i,this,l);return await a._def.returns._def.type.parseAsync(d,o).catch(_=>{throw u.addIssue(s(d,_)),u})})}else{const a=this;return Xe(function(...c){const u=a._def.args.safeParse(c,o);if(!u.success)throw new dt([n(c,u.error)]);const l=Reflect.apply(i,this,u.data),d=a._def.returns.safeParse(l,o);if(!d.success)throw new dt([s(l,d.error)]);return d.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new Ar({...this._def,args:Mt.create(e).rest(gr.create())})}returns(e){return new Ar({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,r,n){return new Ar({args:e||Mt.create([]).rest(gr.create()),returns:r||gr.create(),typeName:D.ZodFunction,...le(n)})}}class $n extends he{get schema(){return this._def.getter()}_parse(e){const{ctx:r}=this._processInputParams(e);return this._def.getter()._parse({data:r.data,path:r.path,parent:r})}}$n.create=(t,e)=>new $n({getter:t,typeName:D.ZodLazy,...le(e)});class Sn extends he{_parse(e){if(e.data!==this._def.value){const r=this._getOrReturnCtx(e);return J(r,{received:r.data,code:Z.invalid_literal,expected:this._def.value}),se}return{status:"valid",value:e.data}}get value(){return this._def.value}}Sn.create=(t,e)=>new Sn({value:t,typeName:D.ZodLiteral,...le(e)});function vd(t,e){return new tr({values:t,typeName:D.ZodEnum,...le(e)})}class tr extends he{_parse(e){if(typeof e.data!="string"){const r=this._getOrReturnCtx(e),n=this._def.values;return J(r,{expected:ge.joinValues(n),received:r.parsedType,code:Z.invalid_type}),se}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){const r=this._getOrReturnCtx(e),n=this._def.values;return J(r,{received:r.data,code:Z.invalid_enum_value,options:n}),se}return Xe(e.data)}get options(){return this._def.values}get enum(){const e={};for(const r of this._def.values)e[r]=r;return e}get Values(){const e={};for(const r of this._def.values)e[r]=r;return e}get Enum(){const e={};for(const r of this._def.values)e[r]=r;return e}extract(e,r=this._def){return tr.create(e,{...this._def,...r})}exclude(e,r=this._def){return tr.create(this.options.filter(n=>!e.includes(n)),{...this._def,...r})}}tr.create=vd;class kn extends he{_parse(e){const r=ge.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==B.string&&n.parsedType!==B.number){const s=ge.objectValues(r);return J(n,{expected:ge.joinValues(s),received:n.parsedType,code:Z.invalid_type}),se}if(this._cache||(this._cache=new Set(ge.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){const s=ge.objectValues(r);return J(n,{received:n.data,code:Z.invalid_enum_value,options:s}),se}return Xe(e.data)}get enum(){return this._def.values}}kn.create=(t,e)=>new kn({values:t,typeName:D.ZodNativeEnum,...le(e)});class Mr extends he{unwrap(){return this._def.type}_parse(e){const{ctx:r}=this._processInputParams(e);if(r.parsedType!==B.promise&&r.common.async===!1)return J(r,{code:Z.invalid_type,expected:B.promise,received:r.parsedType}),se;const n=r.parsedType===B.promise?r.data:Promise.resolve(r.data);return Xe(n.then(s=>this._def.type.parseAsync(s,{path:r.path,errorMap:r.common.contextualErrorMap})))}}Mr.create=(t,e)=>new Mr({type:t,typeName:D.ZodPromise,...le(e)});class $t extends he{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===D.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:r,ctx:n}=this._processInputParams(e),s=this._def.effect||null,o={addIssue:i=>{J(n,i),i.fatal?r.abort():r.dirty()},get path(){return n.path}};if(o.addIssue=o.addIssue.bind(o),s.type==="preprocess"){const i=s.transform(n.data,o);if(n.common.async)return Promise.resolve(i).then(async a=>{if(r.value==="aborted")return se;const c=await this._def.schema._parseAsync({data:a,path:n.path,parent:n});return c.status==="aborted"?se:c.status==="dirty"||r.value==="dirty"?Cr(c.value):c});{if(r.value==="aborted")return se;const a=this._def.schema._parseSync({data:i,path:n.path,parent:n});return a.status==="aborted"?se:a.status==="dirty"||r.value==="dirty"?Cr(a.value):a}}if(s.type==="refinement"){const i=a=>{const c=s.refinement(a,o);if(n.common.async)return Promise.resolve(c);if(c instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return a};if(n.common.async===!1){const a=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return a.status==="aborted"?se:(a.status==="dirty"&&r.dirty(),i(a.value),{status:r.value,value:a.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(a=>a.status==="aborted"?se:(a.status==="dirty"&&r.dirty(),i(a.value).then(()=>({status:r.value,value:a.value}))))}if(s.type==="transform")if(n.common.async===!1){const i=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!mr(i))return se;const a=s.transform(i.value,o);if(a instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:r.value,value:a}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(i=>mr(i)?Promise.resolve(s.transform(i.value,o)).then(a=>({status:r.value,value:a})):se);ge.assertNever(s)}}$t.create=(t,e,r)=>new $t({schema:t,typeName:D.ZodEffects,effect:e,...le(r)}),$t.createWithPreprocess=(t,e,r)=>new $t({schema:e,effect:{type:"preprocess",transform:t},typeName:D.ZodEffects,...le(r)});class jt extends he{_parse(e){return this._getType(e)===B.undefined?Xe(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}jt.create=(t,e)=>new jt({innerType:t,typeName:D.ZodOptional,...le(e)});class rr extends he{_parse(e){return this._getType(e)===B.null?Xe(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}rr.create=(t,e)=>new rr({innerType:t,typeName:D.ZodNullable,...le(e)});class Tn extends he{_parse(e){const{ctx:r}=this._processInputParams(e);let n=r.data;return r.parsedType===B.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:r.path,parent:r})}removeDefault(){return this._def.innerType}}Tn.create=(t,e)=>new Tn({innerType:t,typeName:D.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...le(e)});class Rn extends he{_parse(e){const{ctx:r}=this._processInputParams(e),n={...r,common:{...r.common,issues:[]}},s=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return mn(s)?s.then(o=>({status:"valid",value:o.status==="valid"?o.value:this._def.catchValue({get error(){return new dt(n.common.issues)},input:n.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new dt(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}}Rn.create=(t,e)=>new Rn({innerType:t,typeName:D.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...le(e)});class ro extends he{_parse(e){if(this._getType(e)!==B.nan){const n=this._getOrReturnCtx(e);return J(n,{code:Z.invalid_type,expected:B.nan,received:n.parsedType}),se}return{status:"valid",value:e.data}}}ro.create=t=>new ro({typeName:D.ZodNaN,...le(t)});const u0=Symbol("zod_brand");class Zi extends he{_parse(e){const{ctx:r}=this._processInputParams(e),n=r.data;return this._def.type._parse({data:n,path:r.path,parent:r})}unwrap(){return this._def.type}}class En extends he{_parse(e){const{status:r,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{const o=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return o.status==="aborted"?se:o.status==="dirty"?(r.dirty(),Cr(o.value)):this._def.out._parseAsync({data:o.value,path:n.path,parent:n})})();{const s=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return s.status==="aborted"?se:s.status==="dirty"?(r.dirty(),{status:"dirty",value:s.value}):this._def.out._parseSync({data:s.value,path:n.path,parent:n})}}static create(e,r){return new En({in:e,out:r,typeName:D.ZodPipeline})}}class Pn extends he{_parse(e){const r=this._def.innerType._parse(e),n=s=>(mr(s)&&(s.value=Object.freeze(s.value)),s);return mn(r)?r.then(s=>n(s)):n(r)}unwrap(){return this._def.innerType}}Pn.create=(t,e)=>new Pn({innerType:t,typeName:D.ZodReadonly,...le(e)});function yd(t,e){const r=typeof t=="function"?t(e):typeof t=="string"?{message:t}:t;return typeof r=="string"?{message:r}:r}function wd(t,e={},r){return t?Or.create().superRefine((n,s)=>{const o=t(n);if(o instanceof Promise)return o.then(i=>{if(!i){const a=yd(e,n),c=a.fatal??r??!0;s.addIssue({code:"custom",...a,fatal:c})}});if(!o){const i=yd(e,n),a=i.fatal??r??!0;s.addIssue({code:"custom",...i,fatal:a})}}):Or.create()}const l0={object:ze.lazycreate};var D;(function(t){t.ZodString="ZodString",t.ZodNumber="ZodNumber",t.ZodNaN="ZodNaN",t.ZodBigInt="ZodBigInt",t.ZodBoolean="ZodBoolean",t.ZodDate="ZodDate",t.ZodSymbol="ZodSymbol",t.ZodUndefined="ZodUndefined",t.ZodNull="ZodNull",t.ZodAny="ZodAny",t.ZodUnknown="ZodUnknown",t.ZodNever="ZodNever",t.ZodVoid="ZodVoid",t.ZodArray="ZodArray",t.ZodObject="ZodObject",t.ZodUnion="ZodUnion",t.ZodDiscriminatedUnion="ZodDiscriminatedUnion",t.ZodIntersection="ZodIntersection",t.ZodTuple="ZodTuple",t.ZodRecord="ZodRecord",t.ZodMap="ZodMap",t.ZodSet="ZodSet",t.ZodFunction="ZodFunction",t.ZodLazy="ZodLazy",t.ZodLiteral="ZodLiteral",t.ZodEnum="ZodEnum",t.ZodEffects="ZodEffects",t.ZodNativeEnum="ZodNativeEnum",t.ZodOptional="ZodOptional",t.ZodNullable="ZodNullable",t.ZodDefault="ZodDefault",t.ZodCatch="ZodCatch",t.ZodPromise="ZodPromise",t.ZodBranded="ZodBranded",t.ZodPipeline="ZodPipeline",t.ZodReadonly="ZodReadonly"})(D||(D={}));const d0=(t,e={message:`Input not instance of ${t.name}`})=>wd(r=>r instanceof t,e),bd=wt.create,$d=Xt.create,h0=ro.create,f0=er.create,Sd=_n.create,p0=_r.create,m0=Qs.create,_0=gn.create,g0=vn.create,v0=Or.create,y0=gr.create,w0=Dt.create,b0=Xs.create,$0=bt.create,kd=ze.create,S0=ze.strictCreate,k0=yn.create,T0=eo.create,R0=wn.create,E0=Mt.create,P0=bn.create,x0=to.create,I0=vr.create,C0=Ar.create,O0=$n.create,N0=Sn.create,A0=tr.create,M0=kn.create,j0=Mr.create,Td=$t.create,q0=jt.create,z0=rr.create,U0=$t.createWithPreprocess,L0=En.create,Z0=Object.freeze(Object.defineProperty({__proto__:null,BRAND:u0,DIRTY:Cr,EMPTY_PATH:Zy,INVALID:se,NEVER:se,OK:Xe,ParseStatus:Ye,Schema:he,ZodAny:Or,ZodArray:bt,ZodBigInt:er,ZodBoolean:_n,ZodBranded:Zi,ZodCatch:Rn,ZodDate:_r,ZodDefault:Tn,ZodDiscriminatedUnion:eo,ZodEffects:$t,ZodEnum:tr,ZodError:dt,get ZodFirstPartyTypeKind(){return D},ZodFunction:Ar,ZodIntersection:wn,ZodIssueCode:Z,ZodLazy:$n,ZodLiteral:Sn,ZodMap:to,ZodNaN:ro,ZodNativeEnum:kn,ZodNever:Dt,ZodNull:vn,ZodNullable:rr,ZodNumber:Xt,ZodObject:ze,ZodOptional:jt,ZodParsedType:B,ZodPipeline:En,ZodPromise:Mr,ZodReadonly:Pn,ZodRecord:bn,ZodSchema:he,ZodSet:vr,ZodString:wt,ZodSymbol:Qs,ZodTransformer:$t,ZodTuple:Mt,ZodType:he,ZodUndefined:gn,ZodUnion:yn,ZodUnknown:gr,ZodVoid:Xs,addIssueToContext:J,any:v0,array:$0,bigint:f0,boolean:Sd,coerce:{string:(t=>wt.create({...t,coerce:!0})),number:(t=>Xt.create({...t,coerce:!0})),boolean:(t=>_n.create({...t,coerce:!0})),bigint:(t=>er.create({...t,coerce:!0})),date:(t=>_r.create({...t,coerce:!0}))},custom:wd,date:p0,datetimeRegex:gd,defaultErrorMap:Ir,discriminatedUnion:T0,effect:Td,enum:A0,function:C0,getErrorMap:Gs,getParsedType:Zt,instanceof:d0,intersection:R0,isAborted:qi,isAsync:mn,isDirty:zi,isValid:mr,late:l0,lazy:O0,literal:N0,makeIssue:Ys,map:x0,nan:h0,nativeEnum:M0,never:w0,null:g0,nullable:z0,number:$d,object:kd,get objectUtil(){return ji},oboolean:()=>Sd().optional(),onumber:()=>$d().optional(),optional:q0,ostring:()=>bd().optional(),pipeline:L0,preprocess:U0,promise:j0,quotelessJson:Uy,record:P0,set:I0,setErrorMap:Ly,strictObject:S0,string:bd,symbol:m0,transformer:Td,tuple:E0,undefined:_0,union:k0,unknown:y0,get util(){return ge},void:b0},Symbol.toStringTag,{value:"Module"})),D0=A("ZodMiniType",(t,e)=>{if(!t._zod)throw new Error("Uninitialized schema in ZodMiniType.");Ie.init(t,e),t.def=e,t.parse=(r,n)=>Pp(t,r,n,{callee:t.parse}),t.safeParse=(r,n)=>zs(t,r,n),t.parseAsync=async(r,n)=>xp(t,r,n,{callee:t.parseAsync}),t.safeParseAsync=async(r,n)=>oi(t,r,n),t.check=(...r)=>t.clone({...e,checks:[...e.checks??[],...r.map(n=>typeof n=="function"?{_zod:{check:n,def:{check:"custom"},onattach:[]}}:n)]}),t.clone=(r,n)=>Yt(t,r,n),t.brand=()=>t,t.register=((r,n)=>(r.add(t,n),t))}),V0=A("ZodMiniObject",(t,e)=>{il.init(t,e),D0.init(t,e),Oe(t,"shape",()=>e.shape)});function Rd(t,e){const r={type:"object",get shape(){return Qr(this,"shape",{...t}),this.shape},...Y(e)};return new V0(r)}function no(t){return!!t._zod}function nr(t,e){return no(t)?zs(t,e):t.safeParse(e)}function Ed(t){if(!t)return;let e;if(no(t)?e=t._zod?.def?.shape:e=t.shape,!!e){if(typeof e=="function")try{return e()}catch{return}return e}}function H0(t){if(no(t)){const o=t._zod?.def;if(o){if(o.value!==void 0)return o.value;if(Array.isArray(o.values)&&o.values.length>0)return o.values[0]}}const r=t._def;if(r){if(r.value!==void 0)return r.value;if(Array.isArray(r.values)&&r.values.length>0)return r.values[0]}const n=t.value;if(n!==void 0)return n}function yr(t){return t==="completed"||t==="failed"||t==="cancelled"}const F0=Symbol("Let zodToJsonSchema decide on which parser to use"),Pd={name:void 0,$refStrategy:"root",basePath:["#"],effectStrategy:"input",pipeStrategy:"all",dateStrategy:"format:date-time",mapStrategy:"entries",removeAdditionalStrategy:"passthrough",allowedAdditionalProperties:!0,rejectedAdditionalProperties:!1,definitionPath:"definitions",target:"jsonSchema7",strictUnions:!1,definitions:{},errorMessages:!1,markdownDescription:!1,patternStrategy:"escape",applyRegexFlags:!1,emailStrategy:"format:email",base64Strategy:"contentEncoding:base64",nameStrategy:"ref",openAiAnyTypeName:"OpenAiAnyType"},W0=t=>typeof t=="string"?{...Pd,name:t}:{...Pd,...t},J0=t=>{const e=W0(t),r=e.name!==void 0?[...e.basePath,e.definitionPath,e.name]:e.basePath;return{...e,flags:{hasReferencedOpenAiAnyType:!1},currentPath:r,propertyPath:void 0,seen:new Map(Object.entries(e.definitions).map(([n,s])=>[s._def,{def:s._def,path:[...e.basePath,e.definitionPath,n],jsonSchema:void 0}]))}};function xd(t,e,r,n){n?.errorMessages&&r&&(t.errorMessage={...t.errorMessage,[e]:r})}function Re(t,e,r,n,s){t[e]=r,xd(t,e,n,s)}const Id=(t,e)=>{let r=0;for(;r<t.length&&r<e.length&&t[r]===e[r];r++);return[(t.length-r).toString(),...e.slice(r)].join("/")};function st(t){if(t.target!=="openAi")return{};const e=[...t.basePath,t.definitionPath,t.openAiAnyTypeName];return t.flags.hasReferencedOpenAiAnyType=!0,{$ref:t.$refStrategy==="relative"?Id(e,t.currentPath):e.join("/")}}function B0(t,e){const r={type:"array"};return t.type?._def&&t.type?._def?.typeName!==D.ZodAny&&(r.items=$e(t.type._def,{...e,currentPath:[...e.currentPath,"items"]})),t.minLength&&Re(r,"minItems",t.minLength.value,t.minLength.message,e),t.maxLength&&Re(r,"maxItems",t.maxLength.value,t.maxLength.message,e),t.exactLength&&(Re(r,"minItems",t.exactLength.value,t.exactLength.message,e),Re(r,"maxItems",t.exactLength.value,t.exactLength.message,e)),r}function K0(t,e){const r={type:"integer",format:"int64"};if(!t.checks)return r;for(const n of t.checks)switch(n.kind){case"min":e.target==="jsonSchema7"?n.inclusive?Re(r,"minimum",n.value,n.message,e):Re(r,"exclusiveMinimum",n.value,n.message,e):(n.inclusive||(r.exclusiveMinimum=!0),Re(r,"minimum",n.value,n.message,e));break;case"max":e.target==="jsonSchema7"?n.inclusive?Re(r,"maximum",n.value,n.message,e):Re(r,"exclusiveMaximum",n.value,n.message,e):(n.inclusive||(r.exclusiveMaximum=!0),Re(r,"maximum",n.value,n.message,e));break;case"multipleOf":Re(r,"multipleOf",n.value,n.message,e);break}return r}function G0(){return{type:"boolean"}}function Cd(t,e){return $e(t.type._def,e)}const Y0=(t,e)=>$e(t.innerType._def,e);function Od(t,e,r){const n=r??e.dateStrategy;if(Array.isArray(n))return{anyOf:n.map((s,o)=>Od(t,e,s))};switch(n){case"string":case"format:date-time":return{type:"string",format:"date-time"};case"format:date":return{type:"string",format:"date"};case"integer":return Q0(t,e)}}const Q0=(t,e)=>{const r={type:"integer",format:"unix-time"};if(e.target==="openApi3")return r;for(const n of t.checks)switch(n.kind){case"min":Re(r,"minimum",n.value,n.message,e);break;case"max":Re(r,"maximum",n.value,n.message,e);break}return r};function X0(t,e){return{...$e(t.innerType._def,e),default:t.defaultValue()}}function ew(t,e){return e.effectStrategy==="input"?$e(t.schema._def,e):st(e)}function tw(t){return{type:"string",enum:Array.from(t.values)}}const rw=t=>"type"in t&&t.type==="string"?!1:"allOf"in t;function nw(t,e){const r=[$e(t.left._def,{...e,currentPath:[...e.currentPath,"allOf","0"]}),$e(t.right._def,{...e,currentPath:[...e.currentPath,"allOf","1"]})].filter(o=>!!o);let n=e.target==="jsonSchema2019-09"?{unevaluatedProperties:!1}:void 0;const s=[];return r.forEach(o=>{if(rw(o))s.push(...o.allOf),o.unevaluatedProperties===void 0&&(n=void 0);else{let i=o;if("additionalProperties"in o&&o.additionalProperties===!1){const{additionalProperties:a,...c}=o;i=c}else n=void 0;s.push(i)}}),s.length?{allOf:s,...n}:void 0}function sw(t,e){const r=typeof t.value;return r!=="bigint"&&r!=="number"&&r!=="boolean"&&r!=="string"?{type:Array.isArray(t.value)?"array":"object"}:e.target==="openApi3"?{type:r==="bigint"?"integer":r,enum:[t.value]}:{type:r==="bigint"?"integer":r,const:t.value}}let Di;const St={cuid:/^[cC][^\s-]{8,}$/,cuid2:/^[0-9a-z]+$/,ulid:/^[0-9A-HJKMNP-TV-Z]{26}$/,email:/^(?!\.)(?!.*\.\.)([a-zA-Z0-9_'+\-\.]*)[a-zA-Z0-9_+-]@([a-zA-Z0-9][a-zA-Z0-9\-]*\.)+[a-zA-Z]{2,}$/,emoji:()=>(Di===void 0&&(Di=RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),Di),uuid:/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/,ipv4:/^(?:(?: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])$/,ipv4Cidr:/^(?:(?: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])\/(3[0-2]|[12]?[0-9])$/,ipv6:/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,ipv6Cidr:/^(([0-9a-fA-F]{1,4}:){7,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}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,base64:/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,base64url:/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,nanoid:/^[a-zA-Z0-9_-]{21}$/,jwt:/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/};function Nd(t,e){const r={type:"string"};if(t.checks)for(const n of t.checks)switch(n.kind){case"min":Re(r,"minLength",typeof r.minLength=="number"?Math.max(r.minLength,n.value):n.value,n.message,e);break;case"max":Re(r,"maxLength",typeof r.maxLength=="number"?Math.min(r.maxLength,n.value):n.value,n.message,e);break;case"email":switch(e.emailStrategy){case"format:email":kt(r,"email",n.message,e);break;case"format:idn-email":kt(r,"idn-email",n.message,e);break;case"pattern:zod":et(r,St.email,n.message,e);break}break;case"url":kt(r,"uri",n.message,e);break;case"uuid":kt(r,"uuid",n.message,e);break;case"regex":et(r,n.regex,n.message,e);break;case"cuid":et(r,St.cuid,n.message,e);break;case"cuid2":et(r,St.cuid2,n.message,e);break;case"startsWith":et(r,RegExp(`^${Vi(n.value,e)}`),n.message,e);break;case"endsWith":et(r,RegExp(`${Vi(n.value,e)}$`),n.message,e);break;case"datetime":kt(r,"date-time",n.message,e);break;case"date":kt(r,"date",n.message,e);break;case"time":kt(r,"time",n.message,e);break;case"duration":kt(r,"duration",n.message,e);break;case"length":Re(r,"minLength",typeof r.minLength=="number"?Math.max(r.minLength,n.value):n.value,n.message,e),Re(r,"maxLength",typeof r.maxLength=="number"?Math.min(r.maxLength,n.value):n.value,n.message,e);break;case"includes":{et(r,RegExp(Vi(n.value,e)),n.message,e);break}case"ip":{n.version!=="v6"&&kt(r,"ipv4",n.message,e),n.version!=="v4"&&kt(r,"ipv6",n.message,e);break}case"base64url":et(r,St.base64url,n.message,e);break;case"jwt":et(r,St.jwt,n.message,e);break;case"cidr":{n.version!=="v6"&&et(r,St.ipv4Cidr,n.message,e),n.version!=="v4"&&et(r,St.ipv6Cidr,n.message,e);break}case"emoji":et(r,St.emoji(),n.message,e);break;case"ulid":{et(r,St.ulid,n.message,e);break}case"base64":{switch(e.base64Strategy){case"format:binary":{kt(r,"binary",n.message,e);break}case"contentEncoding:base64":{Re(r,"contentEncoding","base64",n.message,e);break}case"pattern:zod":{et(r,St.base64,n.message,e);break}}break}case"nanoid":et(r,St.nanoid,n.message,e)}return r}function Vi(t,e){return e.patternStrategy==="escape"?iw(t):t}const ow=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function iw(t){let e="";for(let r=0;r<t.length;r++)ow.has(t[r])||(e+="\\"),e+=t[r];return e}function kt(t,e,r,n){t.format||t.anyOf?.some(s=>s.format)?(t.anyOf||(t.anyOf=[]),t.format&&(t.anyOf.push({format:t.format,...t.errorMessage&&n.errorMessages&&{errorMessage:{format:t.errorMessage.format}}}),delete t.format,t.errorMessage&&(delete t.errorMessage.format,Object.keys(t.errorMessage).length===0&&delete t.errorMessage)),t.anyOf.push({format:e,...r&&n.errorMessages&&{errorMessage:{format:r}}})):Re(t,"format",e,r,n)}function et(t,e,r,n){t.pattern||t.allOf?.some(s=>s.pattern)?(t.allOf||(t.allOf=[]),t.pattern&&(t.allOf.push({pattern:t.pattern,...t.errorMessage&&n.errorMessages&&{errorMessage:{pattern:t.errorMessage.pattern}}}),delete t.pattern,t.errorMessage&&(delete t.errorMessage.pattern,Object.keys(t.errorMessage).length===0&&delete t.errorMessage)),t.allOf.push({pattern:Ad(e,n),...r&&n.errorMessages&&{errorMessage:{pattern:r}}})):Re(t,"pattern",Ad(e,n),r,n)}function Ad(t,e){if(!e.applyRegexFlags||!t.flags)return t.source;const r={i:t.flags.includes("i"),m:t.flags.includes("m"),s:t.flags.includes("s")},n=r.i?t.source.toLowerCase():t.source;let s="",o=!1,i=!1,a=!1;for(let c=0;c<n.length;c++){if(o){s+=n[c],o=!1;continue}if(r.i){if(i){if(n[c].match(/[a-z]/)){a?(s+=n[c],s+=`${n[c-2]}-${n[c]}`.toUpperCase(),a=!1):n[c+1]==="-"&&n[c+2]?.match(/[a-z]/)?(s+=n[c],a=!0):s+=`${n[c]}${n[c].toUpperCase()}`;continue}}else if(n[c].match(/[a-z]/)){s+=`[${n[c]}${n[c].toUpperCase()}]`;continue}}if(r.m){if(n[c]==="^"){s+=`(^|(?<=[\r
|
|
36
36
|
]))`;continue}else if(n[c]==="$"){s+=`($|(?=[\r
|
|
37
37
|
]))`;continue}}if(r.s&&n[c]==="."){s+=i?`${n[c]}\r
|
|
38
38
|
`:`[${n[c]}\r
|
|
39
|
-
]`;continue}s+=n[c],n[c]==="\\"?a=!0:i&&n[c]==="]"?i=!1:!i&&n[c]==="["&&(i=!0)}try{new RegExp(s)}catch{return console.warn(`Could not convert regex pattern at ${e.currentPath.join("/")} to a flag-independent form! Falling back to the flag-ignorant source`),t.source}return s}function Tl(t,e){if(e.target==="openAi"&&console.warn("Warning: OpenAI may not support records in schemas! Try an array of key-value pairs instead."),e.target==="openApi3"&&t.keyType?._def.typeName===L.ZodEnum)return{type:"object",required:t.keyType._def.values,properties:t.keyType._def.values.reduce((n,s)=>({...n,[s]:me(t.valueType._def,{...e,currentPath:[...e.currentPath,"properties",s]})??tt(e)}),{}),additionalProperties:e.rejectedAdditionalProperties};const r={type:"object",additionalProperties:me(t.valueType._def,{...e,currentPath:[...e.currentPath,"additionalProperties"]})??e.allowedAdditionalProperties};if(e.target==="openApi3")return r;if(t.keyType?._def.typeName===L.ZodString&&t.keyType._def.checks?.length){const{type:n,...s}=$l(t.keyType._def,e);return{...r,propertyNames:s}}else{if(t.keyType?._def.typeName===L.ZodEnum)return{...r,propertyNames:{enum:t.keyType._def.values}};if(t.keyType?._def.typeName===L.ZodBranded&&t.keyType._def.type._def.typeName===L.ZodString&&t.keyType._def.type._def.checks?.length){const{type:n,...s}=bl(t.keyType._def,e);return{...r,propertyNames:s}}}return r}function Vg(t,e){if(e.mapStrategy==="record")return Tl(t,e);const r=me(t.keyType._def,{...e,currentPath:[...e.currentPath,"items","items","0"]})||tt(e),n=me(t.valueType._def,{...e,currentPath:[...e.currentPath,"items","items","1"]})||tt(e);return{type:"array",maxItems:125,items:{type:"array",items:[r,n],minItems:2,maxItems:2}}}function Fg(t){const e=t.values,n=Object.keys(t.values).filter(a=>typeof e[e[a]]!="number").map(a=>e[a]),s=Array.from(new Set(n.map(a=>typeof a)));return{type:s.length===1?s[0]==="string"?"string":"number":["string","number"],enum:n}}function Hg(t){return t.target==="openAi"?void 0:{not:tt({...t,currentPath:[...t.currentPath,"not"]})}}function Wg(t){return t.target==="openApi3"?{enum:["null"],nullable:!0}:{type:"null"}}const qs={ZodString:"string",ZodNumber:"number",ZodBigInt:"integer",ZodBoolean:"boolean",ZodNull:"null"};function Jg(t,e){if(e.target==="openApi3")return El(t,e);const r=t.options instanceof Map?Array.from(t.options.values()):t.options;if(r.every(n=>n._def.typeName in qs&&(!n._def.checks||!n._def.checks.length))){const n=r.reduce((s,a)=>{const i=qs[a._def.typeName];return i&&!s.includes(i)?[...s,i]:s},[]);return{type:n.length>1?n:n[0]}}else if(r.every(n=>n._def.typeName==="ZodLiteral"&&!n.description)){const n=r.reduce((s,a)=>{const i=typeof a._def.value;switch(i){case"string":case"number":case"boolean":return[...s,i];case"bigint":return[...s,"integer"];case"object":if(a._def.value===null)return[...s,"null"];case"symbol":case"undefined":case"function":default:return s}},[]);if(n.length===r.length){const s=n.filter((a,i,o)=>o.indexOf(a)===i);return{type:s.length>1?s:s[0],enum:r.reduce((a,i)=>a.includes(i._def.value)?a:[...a,i._def.value],[])}}}else if(r.every(n=>n._def.typeName==="ZodEnum"))return{type:"string",enum:r.reduce((n,s)=>[...n,...s._def.values.filter(a=>!n.includes(a))],[])};return El(t,e)}const El=(t,e)=>{const r=(t.options instanceof Map?Array.from(t.options.values()):t.options).map((n,s)=>me(n._def,{...e,currentPath:[...e.currentPath,"anyOf",`${s}`]})).filter(n=>!!n&&(!e.strictUnions||typeof n=="object"&&Object.keys(n).length>0));return r.length?{anyOf:r}:void 0};function Kg(t,e){if(["ZodString","ZodNumber","ZodBigInt","ZodBoolean","ZodNull"].includes(t.innerType._def.typeName)&&(!t.innerType._def.checks||!t.innerType._def.checks.length))return e.target==="openApi3"?{type:qs[t.innerType._def.typeName],nullable:!0}:{type:[qs[t.innerType._def.typeName],"null"]};if(e.target==="openApi3"){const n=me(t.innerType._def,{...e,currentPath:[...e.currentPath]});return n&&"$ref"in n?{allOf:[n],nullable:!0}:n&&{...n,nullable:!0}}const r=me(t.innerType._def,{...e,currentPath:[...e.currentPath,"anyOf","0"]});return r&&{anyOf:[r,{type:"null"}]}}function Bg(t,e){const r={type:"number"};if(!t.checks)return r;for(const n of t.checks)switch(n.kind){case"int":r.type="integer",yl(r,"type",n.message,e);break;case"min":e.target==="jsonSchema7"?n.inclusive?ye(r,"minimum",n.value,n.message,e):ye(r,"exclusiveMinimum",n.value,n.message,e):(n.inclusive||(r.exclusiveMinimum=!0),ye(r,"minimum",n.value,n.message,e));break;case"max":e.target==="jsonSchema7"?n.inclusive?ye(r,"maximum",n.value,n.message,e):ye(r,"exclusiveMaximum",n.value,n.message,e):(n.inclusive||(r.exclusiveMaximum=!0),ye(r,"maximum",n.value,n.message,e));break;case"multipleOf":ye(r,"multipleOf",n.value,n.message,e);break}return r}function Gg(t,e){const r=e.target==="openAi",n={type:"object",properties:{}},s=[],a=t.shape();for(const o in a){let c=a[o];if(c===void 0||c._def===void 0)continue;let l=Qg(c);l&&r&&(c._def.typeName==="ZodOptional"&&(c=c._def.innerType),c.isNullable()||(c=c.nullable()),l=!1);const u=me(c._def,{...e,currentPath:[...e.currentPath,"properties",o],propertyPath:[...e.currentPath,"properties",o]});u!==void 0&&(n.properties[o]=u,l||s.push(o))}s.length&&(n.required=s);const i=Yg(t,e);return i!==void 0&&(n.additionalProperties=i),n}function Yg(t,e){if(t.catchall._def.typeName!=="ZodNever")return me(t.catchall._def,{...e,currentPath:[...e.currentPath,"additionalProperties"]});switch(t.unknownKeys){case"passthrough":return e.allowedAdditionalProperties;case"strict":return e.rejectedAdditionalProperties;case"strip":return e.removeAdditionalStrategy==="strict"?e.allowedAdditionalProperties:e.rejectedAdditionalProperties}}function Qg(t){try{return t.isOptional()}catch{return!0}}const Xg=(t,e)=>{if(e.currentPath.toString()===e.propertyPath?.toString())return me(t.innerType._def,e);const r=me(t.innerType._def,{...e,currentPath:[...e.currentPath,"anyOf","1"]});return r?{anyOf:[{not:tt(e)},r]}:tt(e)},ey=(t,e)=>{if(e.pipeStrategy==="input")return me(t.in._def,e);if(e.pipeStrategy==="output")return me(t.out._def,e);const r=me(t.in._def,{...e,currentPath:[...e.currentPath,"allOf","0"]}),n=me(t.out._def,{...e,currentPath:[...e.currentPath,"allOf",r?"1":"0"]});return{allOf:[r,n].filter(s=>s!==void 0)}};function ty(t,e){return me(t.type._def,e)}function ry(t,e){const n={type:"array",uniqueItems:!0,items:me(t.valueType._def,{...e,currentPath:[...e.currentPath,"items"]})};return t.minSize&&ye(n,"minItems",t.minSize.value,t.minSize.message,e),t.maxSize&&ye(n,"maxItems",t.maxSize.value,t.maxSize.message,e),n}function ny(t,e){return t.rest?{type:"array",minItems:t.items.length,items:t.items.map((r,n)=>me(r._def,{...e,currentPath:[...e.currentPath,"items",`${n}`]})).reduce((r,n)=>n===void 0?r:[...r,n],[]),additionalItems:me(t.rest._def,{...e,currentPath:[...e.currentPath,"additionalItems"]})}:{type:"array",minItems:t.items.length,maxItems:t.items.length,items:t.items.map((r,n)=>me(r._def,{...e,currentPath:[...e.currentPath,"items",`${n}`]})).reduce((r,n)=>n===void 0?r:[...r,n],[])}}function sy(t){return{not:tt(t)}}function ay(t){return tt(t)}const iy=(t,e)=>me(t.innerType._def,e),oy=(t,e,r)=>{switch(e){case L.ZodString:return $l(t,r);case L.ZodNumber:return Bg(t,r);case L.ZodObject:return Gg(t,r);case L.ZodBigInt:return Cg(t,r);case L.ZodBoolean:return Og();case L.ZodDate:return kl(t,r);case L.ZodUndefined:return sy(r);case L.ZodNull:return Wg(r);case L.ZodArray:return Ig(t,r);case L.ZodUnion:case L.ZodDiscriminatedUnion:return Jg(t,r);case L.ZodIntersection:return Zg(t,r);case L.ZodTuple:return ny(t,r);case L.ZodRecord:return Tl(t,r);case L.ZodLiteral:return Lg(t,r);case L.ZodEnum:return Mg(t);case L.ZodNativeEnum:return Fg(t);case L.ZodNullable:return Kg(t,r);case L.ZodOptional:return Xg(t,r);case L.ZodMap:return Vg(t,r);case L.ZodSet:return ry(t,r);case L.ZodLazy:return()=>t.getter()._def;case L.ZodPromise:return ty(t,r);case L.ZodNaN:case L.ZodNever:return Hg(r);case L.ZodEffects:return zg(t,r);case L.ZodAny:return tt(r);case L.ZodUnknown:return ay(r);case L.ZodDefault:return jg(t,r);case L.ZodBranded:return bl(t,r);case L.ZodReadonly:return iy(t,r);case L.ZodCatch:return Ng(t,r);case L.ZodPipeline:return ey(t,r);case L.ZodFunction:case L.ZodVoid:case L.ZodSymbol:return;default:return(n=>{})()}};function me(t,e,r=!1){const n=e.seen.get(t);if(e.override){const o=e.override?.(t,e,n,r);if(o!==Rg)return o}if(n&&!r){const o=cy(n,e);if(o!==void 0)return o}const s={def:t,path:e.currentPath,jsonSchema:void 0};e.seen.set(t,s);const a=oy(t,t.typeName,e),i=typeof a=="function"?me(a(),e):a;if(i&&uy(t,e,i),e.postProcess){const o=e.postProcess(i,t,e);return s.jsonSchema=i,o}return s.jsonSchema=i,i}const cy=(t,e)=>{switch(e.$refStrategy){case"root":return{$ref:t.path.join("/")};case"relative":return{$ref:wl(e.currentPath,t.path)};case"none":case"seen":return t.path.length<e.currentPath.length&&t.path.every((r,n)=>e.currentPath[n]===r)?(console.warn(`Recursive reference detected at ${e.currentPath.join("/")}! Defaulting to any`),tt(e)):e.$refStrategy==="seen"?tt(e):void 0}},uy=(t,e,r)=>(t.description&&(r.description=t.description,e.markdownDescription&&(r.markdownDescription=t.description)),r),ly=(t,e)=>{const r=xg(e);let n=typeof e=="object"&&e.definitions?Object.entries(e.definitions).reduce((c,[l,u])=>({...c,[l]:me(u._def,{...r,currentPath:[...r.basePath,r.definitionPath,l]},!0)??tt(r)}),{}):void 0;const s=typeof e=="string"?e:e?.nameStrategy==="title"?void 0:e?.name,a=me(t._def,s===void 0?r:{...r,currentPath:[...r.basePath,r.definitionPath,s]},!1)??tt(r),i=typeof e=="object"&&e.name!==void 0&&e.nameStrategy==="title"?e.name:void 0;i!==void 0&&(a.title=i),r.flags.hasReferencedOpenAiAnyType&&(n||(n={}),n[r.openAiAnyTypeName]||(n[r.openAiAnyTypeName]={type:["string","number","integer","boolean","array","null"],items:{$ref:r.$refStrategy==="relative"?"1":[...r.basePath,r.definitionPath,r.openAiAnyTypeName].join("/")}}));const o=s===void 0?n?{...a,[r.definitionPath]:n}:a:{$ref:[...r.$refStrategy==="relative"?[]:r.basePath,r.definitionPath,s].join("/"),[r.definitionPath]:{...n,[s]:a}};return r.target==="jsonSchema7"?o.$schema="http://json-schema.org/draft-07/schema#":(r.target==="jsonSchema2019-09"||r.target==="openAi")&&(o.$schema="https://json-schema.org/draft/2019-09/schema#"),r.target==="openAi"&&("anyOf"in o||"oneOf"in o||"allOf"in o||"type"in o&&Array.isArray(o.type))&&console.warn("Warning: OpenAI may not support schemas with unions as roots! Try wrapping it in an object property."),o};function dy(t){return!t||t==="jsonSchema7"||t==="draft-7"?"draft-7":t==="jsonSchema2019-09"||t==="draft-2020-12"?"draft-2020-12":"draft-7"}function Rl(t,e){var r,n,s;return lt(t)?Xp(t,{target:dy(e?.target),io:(r=e?.pipeStrategy)!==null&&r!==void 0?r:"input"}):ly(t,{strictUnions:(n=e?.strictUnions)!==null&&n!==void 0?n:!0,pipeStrategy:(s=e?.pipeStrategy)!==null&&s!==void 0?s:"input"})}function Pl(t){const e=Sr(t),r=e?.method;if(!r)throw new Error("Schema is missing a method literal");const n=vl(r);if(typeof n!="string")throw new Error("Schema method literal must be a string");return n}function xl(t,e){const r=gt(t,e);if(!r.success)throw r.error;return r.data}const fy=6e4;class Il{constructor(e){this._options=e,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(za,r=>{this._oncancel(r)}),this.setNotificationHandler(Za,r=>{this._onprogress(r)}),this.setRequestHandler(qa,r=>({})),this._taskStore=e?.taskStore,this._taskMessageQueue=e?.taskMessageQueue,this._taskStore&&(this.setRequestHandler(La,async(r,n)=>{const s=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!s)throw new J(G.InvalidParams,"Failed to retrieve task: Task not found");return{...s}}),this.setRequestHandler(Da,async(r,n)=>{const s=async()=>{var a;const i=r.params.taskId;if(this._taskMessageQueue){let c;for(;c=await this._taskMessageQueue.dequeue(i,n.sessionId);){if(c.type==="response"||c.type==="error"){const l=c.message,u=l.id,d=this._requestResolvers.get(u);if(d)if(this._requestResolvers.delete(u),c.type==="response")d(l);else{const g=l,v=new J(g.error.code,g.error.message,g.error.data);d(v)}else{const g=c.type==="response"?"Response":"Error";this._onerror(new Error(`${g} handler missing for request ${u}`))}continue}await((a=this._transport)===null||a===void 0?void 0:a.send(c.message,{relatedRequestId:n.requestId}))}}const o=await this._taskStore.getTask(i,n.sessionId);if(!o)throw new J(G.InvalidParams,`Task not found: ${i}`);if(!cr(o.status))return await this._waitForTaskUpdate(i,n.signal),await s();if(cr(o.status)){const c=await this._taskStore.getTaskResult(i,n.sessionId);return this._clearTaskQueue(i),{...c,_meta:{...c._meta,[Nt]:{taskId:i}}}}return await s()};return await s()}),this.setRequestHandler(Va,async(r,n)=>{var s;try{const{tasks:a,nextCursor:i}=await this._taskStore.listTasks((s=r.params)===null||s===void 0?void 0:s.cursor,n.sessionId);return{tasks:a,nextCursor:i,_meta:{}}}catch(a){throw new J(G.InvalidParams,`Failed to list tasks: ${a instanceof Error?a.message:String(a)}`)}}),this.setRequestHandler(S_,async(r,n)=>{try{const s=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!s)throw new J(G.InvalidParams,`Task not found: ${r.params.taskId}`);if(cr(s.status))throw new J(G.InvalidParams,`Cannot cancel task in terminal status: ${s.status}`);await this._taskStore.updateTaskStatus(r.params.taskId,"cancelled","Client cancelled task execution.",n.sessionId),this._clearTaskQueue(r.params.taskId);const a=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!a)throw new J(G.InvalidParams,`Task not found after cancellation: ${r.params.taskId}`);return{_meta:{},...a}}catch(s){throw s instanceof J?s:new J(G.InvalidRequest,`Failed to cancel task: ${s instanceof Error?s.message:String(s)}`)}}))}async _oncancel(e){const r=this._requestHandlerAbortControllers.get(e.params.requestId);r?.abort(e.params.reason)}_setupTimeout(e,r,n,s,a=!1){this._timeoutInfo.set(e,{timeoutId:setTimeout(s,r),startTime:Date.now(),timeout:r,maxTotalTimeout:n,resetTimeoutOnProgress:a,onTimeout:s})}_resetTimeout(e){const r=this._timeoutInfo.get(e);if(!r)return!1;const n=Date.now()-r.startTime;if(r.maxTotalTimeout&&n>=r.maxTotalTimeout)throw this._timeoutInfo.delete(e),J.fromError(G.RequestTimeout,"Maximum total timeout exceeded",{maxTotalTimeout:r.maxTotalTimeout,totalElapsed:n});return clearTimeout(r.timeoutId),r.timeoutId=setTimeout(r.onTimeout,r.timeout),!0}_cleanupTimeout(e){const r=this._timeoutInfo.get(e);r&&(clearTimeout(r.timeoutId),this._timeoutInfo.delete(e))}async connect(e){var r,n,s;this._transport=e;const a=(r=this.transport)===null||r===void 0?void 0:r.onclose;this._transport.onclose=()=>{a?.(),this._onclose()};const i=(n=this.transport)===null||n===void 0?void 0:n.onerror;this._transport.onerror=c=>{i?.(c),this._onerror(c)};const o=(s=this._transport)===null||s===void 0?void 0:s.onmessage;this._transport.onmessage=(c,l)=>{o?.(c,l),Hr(c)||u_(c)?this._onresponse(c):ja(c)?this._onrequest(c,l):c_(c)?this._onnotification(c):this._onerror(new Error(`Unknown message type: ${JSON.stringify(c)}`))},await this._transport.start()}_onclose(){var e;const r=this._responseHandlers;this._responseHandlers=new Map,this._progressHandlers.clear(),this._taskProgressTokens.clear(),this._pendingDebouncedNotifications.clear();const n=J.fromError(G.ConnectionClosed,"Connection closed");this._transport=void 0,(e=this.onclose)===null||e===void 0||e.call(this);for(const s of r.values())s(n)}_onerror(e){var r;(r=this.onerror)===null||r===void 0||r.call(this,e)}_onnotification(e){var r;const n=(r=this._notificationHandlers.get(e.method))!==null&&r!==void 0?r:this.fallbackNotificationHandler;n!==void 0&&Promise.resolve().then(()=>n(e)).catch(s=>this._onerror(new Error(`Uncaught error in notification handler: ${s}`)))}_onrequest(e,r){var n,s,a,i,o,c;const l=(n=this._requestHandlers.get(e.method))!==null&&n!==void 0?n:this.fallbackRequestHandler,u=this._transport,d=(i=(a=(s=e.params)===null||s===void 0?void 0:s._meta)===null||a===void 0?void 0:a[Nt])===null||i===void 0?void 0:i.taskId;if(l===void 0){const h={jsonrpc:"2.0",id:e.id,error:{code:G.MethodNotFound,message:"Method not found"}};d&&this._taskMessageQueue?this._enqueueTaskMessage(d,{type:"error",message:h,timestamp:Date.now()},u?.sessionId).catch(_=>this._onerror(new Error(`Failed to enqueue error response: ${_}`))):u?.send(h).catch(_=>this._onerror(new Error(`Failed to send an error response: ${_}`)));return}const g=new AbortController;this._requestHandlerAbortControllers.set(e.id,g);const v=(o=e.params)===null||o===void 0?void 0:o.task,p=this._taskStore?this.requestTaskStore(e,u?.sessionId):void 0,w={signal:g.signal,sessionId:u?.sessionId,_meta:(c=e.params)===null||c===void 0?void 0:c._meta,sendNotification:async h=>{const _={relatedRequestId:e.id};d&&(_.relatedTask={taskId:d}),await this.notification(h,_)},sendRequest:async(h,_,f)=>{var m,b;const y={...f,relatedRequestId:e.id};d&&!y.relatedTask&&(y.relatedTask={taskId:d});const k=(b=(m=y.relatedTask)===null||m===void 0?void 0:m.taskId)!==null&&b!==void 0?b:d;return k&&p&&await p.updateTaskStatus(k,"input_required"),await this.request(h,_,y)},authInfo:r?.authInfo,requestId:e.id,requestInfo:r?.requestInfo,taskId:d,taskStore:p,taskRequestedTtl:v?.ttl,closeSSEStream:r?.closeSSEStream,closeStandaloneSSEStream:r?.closeStandaloneSSEStream};Promise.resolve().then(()=>{v&&this.assertTaskHandlerCapability(e.method)}).then(()=>l(e,w)).then(async h=>{if(g.signal.aborted)return;const _={result:h,jsonrpc:"2.0",id:e.id};d&&this._taskMessageQueue?await this._enqueueTaskMessage(d,{type:"response",message:_,timestamp:Date.now()},u?.sessionId):await u?.send(_)},async h=>{var _;if(g.signal.aborted)return;const f={jsonrpc:"2.0",id:e.id,error:{code:Number.isSafeInteger(h.code)?h.code:G.InternalError,message:(_=h.message)!==null&&_!==void 0?_:"Internal error",...h.data!==void 0&&{data:h.data}}};d&&this._taskMessageQueue?await this._enqueueTaskMessage(d,{type:"error",message:f,timestamp:Date.now()},u?.sessionId):await u?.send(f)}).catch(h=>this._onerror(new Error(`Failed to send response: ${h}`))).finally(()=>{this._requestHandlerAbortControllers.delete(e.id)})}_onprogress(e){const{progressToken:r,...n}=e.params,s=Number(r),a=this._progressHandlers.get(s);if(!a){this._onerror(new Error(`Received a progress notification for an unknown token: ${JSON.stringify(e)}`));return}const i=this._responseHandlers.get(s),o=this._timeoutInfo.get(s);if(o&&i&&o.resetTimeoutOnProgress)try{this._resetTimeout(s)}catch(c){this._responseHandlers.delete(s),this._progressHandlers.delete(s),this._cleanupTimeout(s),i(c);return}a(n)}_onresponse(e){const r=Number(e.id),n=this._requestResolvers.get(r);if(n){if(this._requestResolvers.delete(r),Hr(e))n(e);else{const i=new J(e.error.code,e.error.message,e.error.data);n(i)}return}const s=this._responseHandlers.get(r);if(s===void 0){this._onerror(new Error(`Received a response for an unknown message ID: ${JSON.stringify(e)}`));return}this._responseHandlers.delete(r),this._cleanupTimeout(r);let a=!1;if(Hr(e)&&e.result&&typeof e.result=="object"){const i=e.result;if(i.task&&typeof i.task=="object"){const o=i.task;typeof o.taskId=="string"&&(a=!0,this._taskProgressTokens.set(o.taskId,r))}}if(a||this._progressHandlers.delete(r),Hr(e))s(e);else{const i=J.fromError(e.error.code,e.error.message,e.error.data);s(i)}}get transport(){return this._transport}async close(){var e;await((e=this._transport)===null||e===void 0?void 0:e.close())}async*requestStream(e,r,n){var s,a,i,o;const{task:c}=n??{};if(!c){try{yield{type:"result",result:await this.request(e,r,n)}}catch(u){yield{type:"error",error:u instanceof J?u:new J(G.InternalError,String(u))}}return}let l;try{const u=await this.request(e,mr,n);if(u.task)l=u.task.taskId,yield{type:"taskCreated",task:u.task};else throw new J(G.InternalError,"Task creation did not return a task");for(;;){const d=await this.getTask({taskId:l},n);if(yield{type:"taskStatus",task:d},cr(d.status)){d.status==="completed"?yield{type:"result",result:await this.getTaskResult({taskId:l},r,n)}:d.status==="failed"?yield{type:"error",error:new J(G.InternalError,`Task ${l} failed`)}:d.status==="cancelled"&&(yield{type:"error",error:new J(G.InternalError,`Task ${l} was cancelled`)});return}if(d.status==="input_required"){yield{type:"result",result:await this.getTaskResult({taskId:l},r,n)};return}const g=(i=(s=d.pollInterval)!==null&&s!==void 0?s:(a=this._options)===null||a===void 0?void 0:a.defaultTaskPollInterval)!==null&&i!==void 0?i:1e3;await new Promise(v=>setTimeout(v,g)),(o=n?.signal)===null||o===void 0||o.throwIfAborted()}}catch(u){yield{type:"error",error:u instanceof J?u:new J(G.InternalError,String(u))}}}request(e,r,n){const{relatedRequestId:s,resumptionToken:a,onresumptiontoken:i,task:o,relatedTask:c}=n??{};return new Promise((l,u)=>{var d,g,v,p,w,h,_;const f=C=>{u(C)};if(!this._transport){f(new Error("Not connected"));return}if(((d=this._options)===null||d===void 0?void 0:d.enforceStrictCapabilities)===!0)try{this.assertCapabilityForMethod(e.method),o&&this.assertTaskCapability(e.method)}catch(C){f(C);return}(g=n?.signal)===null||g===void 0||g.throwIfAborted();const m=this._requestMessageId++,b={...e,jsonrpc:"2.0",id:m};n?.onprogress&&(this._progressHandlers.set(m,n.onprogress),b.params={...e.params,_meta:{...((v=e.params)===null||v===void 0?void 0:v._meta)||{},progressToken:m}}),o&&(b.params={...b.params,task:o}),c&&(b.params={...b.params,_meta:{...((p=b.params)===null||p===void 0?void 0:p._meta)||{},[Nt]:c}});const y=C=>{var q;this._responseHandlers.delete(m),this._progressHandlers.delete(m),this._cleanupTimeout(m),(q=this._transport)===null||q===void 0||q.send({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:m,reason:String(C)}},{relatedRequestId:s,resumptionToken:a,onresumptiontoken:i}).catch(V=>this._onerror(new Error(`Failed to send cancellation: ${V}`)));const N=C instanceof J?C:new J(G.RequestTimeout,String(C));u(N)};this._responseHandlers.set(m,C=>{var q;if(!(!((q=n?.signal)===null||q===void 0)&&q.aborted)){if(C instanceof Error)return u(C);try{const N=gt(r,C.result);N.success?l(N.data):u(N.error)}catch(N){u(N)}}}),(w=n?.signal)===null||w===void 0||w.addEventListener("abort",()=>{var C;y((C=n?.signal)===null||C===void 0?void 0:C.reason)});const k=(h=n?.timeout)!==null&&h!==void 0?h:fy,S=()=>y(J.fromError(G.RequestTimeout,"Request timed out",{timeout:k}));this._setupTimeout(m,k,n?.maxTotalTimeout,S,(_=n?.resetTimeoutOnProgress)!==null&&_!==void 0?_:!1);const I=c?.taskId;if(I){const C=q=>{const N=this._responseHandlers.get(m);N?N(q):this._onerror(new Error(`Response handler missing for side-channeled request ${m}`))};this._requestResolvers.set(m,C),this._enqueueTaskMessage(I,{type:"request",message:b,timestamp:Date.now()}).catch(q=>{this._cleanupTimeout(m),u(q)})}else this._transport.send(b,{relatedRequestId:s,resumptionToken:a,onresumptiontoken:i}).catch(C=>{this._cleanupTimeout(m),u(C)})})}async getTask(e,r){return this.request({method:"tasks/get",params:e},Ua,r)}async getTaskResult(e,r,n){return this.request({method:"tasks/result",params:e},r,n)}async listTasks(e,r){return this.request({method:"tasks/list",params:e},Fa,r)}async cancelTask(e,r){return this.request({method:"tasks/cancel",params:e},T_,r)}async notification(e,r){var n,s,a,i,o;if(!this._transport)throw new Error("Not connected");this.assertNotificationCapability(e.method);const c=(n=r?.relatedTask)===null||n===void 0?void 0:n.taskId;if(c){const g={...e,jsonrpc:"2.0",params:{...e.params,_meta:{...((s=e.params)===null||s===void 0?void 0:s._meta)||{},[Nt]:r.relatedTask}}};await this._enqueueTaskMessage(c,{type:"notification",message:g,timestamp:Date.now()});return}if(((i=(a=this._options)===null||a===void 0?void 0:a.debouncedNotificationMethods)!==null&&i!==void 0?i:[]).includes(e.method)&&!e.params&&!r?.relatedRequestId&&!r?.relatedTask){if(this._pendingDebouncedNotifications.has(e.method))return;this._pendingDebouncedNotifications.add(e.method),Promise.resolve().then(()=>{var g,v;if(this._pendingDebouncedNotifications.delete(e.method),!this._transport)return;let p={...e,jsonrpc:"2.0"};r?.relatedTask&&(p={...p,params:{...p.params,_meta:{...((g=p.params)===null||g===void 0?void 0:g._meta)||{},[Nt]:r.relatedTask}}}),(v=this._transport)===null||v===void 0||v.send(p,r).catch(w=>this._onerror(w))});return}let d={...e,jsonrpc:"2.0"};r?.relatedTask&&(d={...d,params:{...d.params,_meta:{...((o=d.params)===null||o===void 0?void 0:o._meta)||{},[Nt]:r.relatedTask}}}),await this._transport.send(d,r)}setRequestHandler(e,r){const n=Pl(e);this.assertRequestHandlerCapability(n),this._requestHandlers.set(n,(s,a)=>{const i=xl(e,s);return Promise.resolve(r(i,a))})}removeRequestHandler(e){this._requestHandlers.delete(e)}assertCanSetRequestHandler(e){if(this._requestHandlers.has(e))throw new Error(`A request handler for ${e} already exists, which would be overridden`)}setNotificationHandler(e,r){const n=Pl(e);this._notificationHandlers.set(n,s=>{const a=xl(e,s);return Promise.resolve(r(a))})}removeNotificationHandler(e){this._notificationHandlers.delete(e)}_cleanupTaskProgressHandler(e){const r=this._taskProgressTokens.get(e);r!==void 0&&(this._progressHandlers.delete(r),this._taskProgressTokens.delete(e))}async _enqueueTaskMessage(e,r,n){var s;if(!this._taskStore||!this._taskMessageQueue)throw new Error("Cannot enqueue task message: taskStore and taskMessageQueue are not configured");const a=(s=this._options)===null||s===void 0?void 0:s.maxTaskQueueSize;await this._taskMessageQueue.enqueue(e,r,n,a)}async _clearTaskQueue(e,r){if(this._taskMessageQueue){const n=await this._taskMessageQueue.dequeueAll(e,r);for(const s of n)if(s.type==="request"&&ja(s.message)){const a=s.message.id,i=this._requestResolvers.get(a);i?(i(new J(G.InternalError,"Task cancelled or completed")),this._requestResolvers.delete(a)):this._onerror(new Error(`Resolver missing for request ${a} during task ${e} cleanup`))}}}async _waitForTaskUpdate(e,r){var n,s,a;let i=(s=(n=this._options)===null||n===void 0?void 0:n.defaultTaskPollInterval)!==null&&s!==void 0?s:1e3;try{const o=await((a=this._taskStore)===null||a===void 0?void 0:a.getTask(e));o?.pollInterval&&(i=o.pollInterval)}catch{}return new Promise((o,c)=>{if(r.aborted){c(new J(G.InvalidRequest,"Request cancelled"));return}const l=setTimeout(o,i);r.addEventListener("abort",()=>{clearTimeout(l),c(new J(G.InvalidRequest,"Request cancelled"))},{once:!0})})}requestTaskStore(e,r){const n=this._taskStore;if(!n)throw new Error("No task store configured");return{createTask:async s=>{if(!e)throw new Error("No request provided");return await n.createTask(s,e.id,{method:e.method,params:e.params},r)},getTask:async s=>{const a=await n.getTask(s,r);if(!a)throw new J(G.InvalidParams,"Failed to retrieve task: Task not found");return a},storeTaskResult:async(s,a,i)=>{await n.storeTaskResult(s,a,i,r);const o=await n.getTask(s,r);if(o){const c=Ss.parse({method:"notifications/tasks/status",params:o});await this.notification(c),cr(o.status)&&this._cleanupTaskProgressHandler(s)}},getTaskResult:s=>n.getTaskResult(s,r),updateTaskStatus:async(s,a,i)=>{const o=await n.getTask(s,r);if(!o)throw new J(G.InvalidParams,`Task "${s}" not found - it may have been cleaned up`);if(cr(o.status))throw new J(G.InvalidParams,`Cannot update task "${s}" from terminal status "${o.status}" to "${a}". Terminal states (completed, failed, cancelled) cannot transition to other states.`);await n.updateTaskStatus(s,a,i,r);const c=await n.getTask(s,r);if(c){const l=Ss.parse({method:"notifications/tasks/status",params:c});await this.notification(l),cr(c.status)&&this._cleanupTaskProgressHandler(s)}},listTasks:s=>n.listTasks(s,r)}}}function Cl(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)}function Ol(t,e){const r={...t};for(const n in e){const s=n,a=e[s];if(a===void 0)continue;const i=r[s];Cl(i)&&Cl(a)?r[s]={...i,...a}:r[s]=a}return r}var Zs={exports:{}},_i={},Nl;function hy(){return Nl||(Nl=1,(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.formatNames=t.fastFormats=t.fullFormats=void 0;function e(N,V){return{validate:N,compare:V}}t.fullFormats={date:e(a,i),time:e(c(!0),l),"date-time":e(g(!0),v),"iso-time":e(c(),u),"iso-date-time":e(g(),p),duration:/^P(?!$)((\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+S)?)?|(\d+W)?)$/,uri:_,"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:q,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:m,int32:{type:"number",validate:k},int64:{type:"number",validate:S},float:{type:"number",validate:I},double:{type:"number",validate:I},password:!0,binary:!0},t.fastFormats={...t.fullFormats,date:e(/^\d\d\d\d-[0-1]\d-[0-3]\d$/,i),time:e(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,l),"date-time":e(/^\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,v),"iso-time":e(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,u),"iso-date-time":e(/^\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,p),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},t.formatNames=Object.keys(t.fullFormats);function r(N){return N%4===0&&(N%100!==0||N%400===0)}const n=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,s=[0,31,28,31,30,31,30,31,31,30,31,30,31];function a(N){const V=n.exec(N);if(!V)return!1;const B=+V[1],Y=+V[2],ve=+V[3];return Y>=1&&Y<=12&&ve>=1&&ve<=(Y===2&&r(B)?29:s[Y])}function i(N,V){if(N&&V)return N>V?1:N<V?-1:0}const o=/^(\d\d):(\d\d):(\d\d(?:\.\d+)?)(z|([+-])(\d\d)(?::?(\d\d))?)?$/i;function c(N){return function(B){const Y=o.exec(B);if(!Y)return!1;const ve=+Y[1],Ge=+Y[2],Ye=+Y[3],be=Y[4],kt=Y[5]==="-"?-1:1,D=+(Y[6]||0),P=+(Y[7]||0);if(D>23||P>59||N&&!be)return!1;if(ve<=23&&Ge<=59&&Ye<60)return!0;const M=Ge-P*kt,O=ve-D*kt-(M<0?1:0);return(O===23||O===-1)&&(M===59||M===-1)&&Ye<61}}function l(N,V){if(!(N&&V))return;const B=new Date("2020-01-01T"+N).valueOf(),Y=new Date("2020-01-01T"+V).valueOf();if(B&&Y)return B-Y}function u(N,V){if(!(N&&V))return;const B=o.exec(N),Y=o.exec(V);if(B&&Y)return N=B[1]+B[2]+B[3],V=Y[1]+Y[2]+Y[3],N>V?1:N<V?-1:0}const d=/t|\s/i;function g(N){const V=c(N);return function(Y){const ve=Y.split(d);return ve.length===2&&a(ve[0])&&V(ve[1])}}function v(N,V){if(!(N&&V))return;const B=new Date(N).valueOf(),Y=new Date(V).valueOf();if(B&&Y)return B-Y}function p(N,V){if(!(N&&V))return;const[B,Y]=N.split(d),[ve,Ge]=V.split(d),Ye=i(B,ve);if(Ye!==void 0)return Ye||l(Y,Ge)}const w=/\/|:/,h=/^(?:[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 _(N){return w.test(N)&&h.test(N)}const f=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/gm;function m(N){return f.lastIndex=0,f.test(N)}const b=-2147483648,y=2**31-1;function k(N){return Number.isInteger(N)&&N<=y&&N>=b}function S(N){return Number.isInteger(N)}function I(){return!0}const C=/[^\\]\\Z/;function q(N){if(C.test(N))return!1;try{return new RegExp(N),!0}catch{return!1}}})(_i)),_i}var vi={},Al;function py(){return Al||(Al=1,(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.formatLimitDefinition=void 0;const e=Sc(),r=ce(),n=r.operators,s={formatMaximum:{okStr:"<=",ok:n.LTE,fail:n.GT},formatMinimum:{okStr:">=",ok:n.GTE,fail:n.LT},formatExclusiveMaximum:{okStr:"<",ok:n.LT,fail:n.GTE},formatExclusiveMinimum:{okStr:">",ok:n.GT,fail:n.LTE}},a={message:({keyword:o,schemaCode:c})=>(0,r.str)`should be ${s[o].okStr} ${c}`,params:({keyword:o,schemaCode:c})=>(0,r._)`{comparison: ${s[o].okStr}, limit: ${c}}`};t.formatLimitDefinition={keyword:Object.keys(s),type:"string",schemaType:"string",$data:!0,error:a,code(o){const{gen:c,data:l,schemaCode:u,keyword:d,it:g}=o,{opts:v,self:p}=g;if(!v.validateFormats)return;const w=new e.KeywordCxt(g,p.RULES.all.format.definition,"format");w.$data?h():_();function h(){const m=c.scopeValue("formats",{ref:p.formats,code:v.code.formats}),b=c.const("fmt",(0,r._)`${m}[${w.schemaCode}]`);o.fail$data((0,r.or)((0,r._)`typeof ${b} != "object"`,(0,r._)`${b} instanceof RegExp`,(0,r._)`typeof ${b}.compare != "function"`,f(b)))}function _(){const m=w.schema,b=p.formats[m];if(!b||b===!0)return;if(typeof b!="object"||b instanceof RegExp||typeof b.compare!="function")throw new Error(`"${d}": format "${m}" does not define "compare" function`);const y=c.scopeValue("formats",{key:m,ref:b,code:v.code.formats?(0,r._)`${v.code.formats}${(0,r.getProperty)(m)}`:void 0});o.fail$data(f(y))}function f(m){return(0,r._)`${m}.compare(${l}, ${u}) ${s[d].fail} 0`}},dependencies:["format"]};const i=o=>(o.addKeyword(t.formatLimitDefinition),o);t.default=i})(vi)),vi}var jl;function my(){return jl||(jl=1,(function(t,e){Object.defineProperty(e,"__esModule",{value:!0});const r=hy(),n=py(),s=ce(),a=new s.Name("fullFormats"),i=new s.Name("fastFormats"),o=(l,u={keywords:!0})=>{if(Array.isArray(u))return c(l,u,r.fullFormats,a),l;const[d,g]=u.mode==="fast"?[r.fastFormats,i]:[r.fullFormats,a],v=u.formats||r.formatNames;return c(l,v,d,g),u.keywords&&(0,n.default)(l),l};o.get=(l,u="full")=>{const g=(u==="fast"?r.fastFormats:r.fullFormats)[l];if(!g)throw new Error(`Unknown format "${l}"`);return g};function c(l,u,d,g){var v,p;(v=(p=l.opts.code).formats)!==null&&v!==void 0||(p.formats=(0,s._)`require("ajv-formats/dist/formats").${g}`);for(const w of u)l.addFormat(w,d[w])}t.exports=e=o,Object.defineProperty(e,"__esModule",{value:!0}),e.default=o})(Zs,Zs.exports)),Zs.exports}var _y=my();const vy=dr(_y);function gy(){const t=new Tc.Ajv({strict:!1,validateFormats:!0,validateSchema:!1,allErrors:!0});return vy(t),t}class zl{constructor(e){this._ajv=e??gy()}getValidator(e){var r;const n="$id"in e&&typeof e.$id=="string"?(r=this._ajv.getSchema(e.$id))!==null&&r!==void 0?r:this._ajv.compile(e):this._ajv.compile(e);return s=>n(s)?{valid:!0,data:s,errorMessage:void 0}:{valid:!1,data:void 0,errorMessage:this._ajv.errorsText(n.errors)}}}class yy{constructor(e){this._client=e}async*callToolStream(e,r=vr,n){var s;const a=this._client,i={...n,task:(s=n?.task)!==null&&s!==void 0?s:a.isToolTask(e.name)?{}:void 0},o=a.requestStream({method:"tools/call",params:e},r,i),c=a.getToolOutputValidator(e.name);for await(const l of o){if(l.type==="result"&&c){const u=l.result;if(!u.structuredContent&&!u.isError){yield{type:"error",error:new J(G.InvalidRequest,`Tool ${e.name} has an output schema but did not return structured content`)};return}if(u.structuredContent)try{const d=c(u.structuredContent);if(!d.valid){yield{type:"error",error:new J(G.InvalidParams,`Structured content does not match the tool's output schema: ${d.errorMessage}`)};return}}catch(d){if(d instanceof J){yield{type:"error",error:d};return}yield{type:"error",error:new J(G.InvalidParams,`Failed to validate structured content: ${d instanceof Error?d.message:String(d)}`)};return}}yield l}}async getTask(e,r){return this._client.getTask({taskId:e},r)}async getTaskResult(e,r,n){return this._client.getTaskResult({taskId:e},r,n)}async listTasks(e,r){return this._client.listTasks(e?{cursor:e}:void 0,r)}async cancelTask(e,r){return this._client.cancelTask({taskId:e},r)}requestStream(e,r,n){return this._client.requestStream(e,r,n)}}function Ml(t,e,r){var n;if(!t)throw new Error(`${r} does not support task creation (required for ${e})`);switch(e){case"tools/call":if(!(!((n=t.tools)===null||n===void 0)&&n.call))throw new Error(`${r} does not support task creation for tools/call (required for ${e})`);break}}function ql(t,e,r){var n,s;if(!t)throw new Error(`${r} does not support task creation (required for ${e})`);switch(e){case"sampling/createMessage":if(!(!((n=t.sampling)===null||n===void 0)&&n.createMessage))throw new Error(`${r} does not support task creation for sampling/createMessage (required for ${e})`);break;case"elicitation/create":if(!(!((s=t.elicitation)===null||s===void 0)&&s.create))throw new Error(`${r} does not support task creation for elicitation/create (required for ${e})`);break}}function Ls(t,e){if(!(!t||e===null||typeof e!="object")){if(t.type==="object"&&t.properties&&typeof t.properties=="object"){const r=e,n=t.properties;for(const s of Object.keys(n)){const a=n[s];r[s]===void 0&&Object.prototype.hasOwnProperty.call(a,"default")&&(r[s]=a.default),r[s]!==void 0&&Ls(a,r[s])}}if(Array.isArray(t.anyOf))for(const r of t.anyOf)Ls(r,e);if(Array.isArray(t.oneOf))for(const r of t.oneOf)Ls(r,e)}}function wy(t){if(!t)return{supportsFormMode:!1,supportsUrlMode:!1};const e=t.form!==void 0,r=t.url!==void 0;return{supportsFormMode:e||!e&&!r,supportsUrlMode:r}}class pn extends Il{constructor(e,r){var n,s;super(r),this._clientInfo=e,this._cachedToolOutputValidators=new Map,this._cachedKnownTaskTools=new Set,this._cachedRequiredTaskTools=new Set,this._capabilities=(n=r?.capabilities)!==null&&n!==void 0?n:{},this._jsonSchemaValidator=(s=r?.jsonSchemaValidator)!==null&&s!==void 0?s:new zl}get experimental(){return this._experimental||(this._experimental={tasks:new yy(this)}),this._experimental}registerCapabilities(e){if(this.transport)throw new Error("Cannot register capabilities after connecting to transport");this._capabilities=Ol(this._capabilities,e)}setRequestHandler(e,r){var n,s,a;const i=Sr(e),o=i?.method;if(!o)throw new Error("Schema is missing a method literal");let c;if(lt(o)){const u=o,d=(n=u._zod)===null||n===void 0?void 0:n.def;c=(s=d?.value)!==null&&s!==void 0?s:u.value}else{const u=o,d=u._def;c=(a=d?.value)!==null&&a!==void 0?a:u.value}if(typeof c!="string")throw new Error("Schema method literal must be a string");const l=c;if(l==="elicitation/create"){const u=async(d,g)=>{var v,p,w;const h=gt(ni,d);if(!h.success){const C=h.error instanceof Error?h.error.message:String(h.error);throw new J(G.InvalidParams,`Invalid elicitation request: ${C}`)}const{params:_}=h.data,f=(v=_.mode)!==null&&v!==void 0?v:"form",{supportsFormMode:m,supportsUrlMode:b}=wy(this._capabilities.elicitation);if(f==="form"&&!m)throw new J(G.InvalidParams,"Client does not support form-mode elicitation requests");if(f==="url"&&!b)throw new J(G.InvalidParams,"Client does not support URL-mode elicitation requests");const y=await Promise.resolve(r(d,g));if(_.task){const C=gt(mr,y);if(!C.success){const q=C.error instanceof Error?C.error.message:String(C.error);throw new J(G.InvalidParams,`Invalid task creation result: ${q}`)}return C.data}const k=gt(Gr,y);if(!k.success){const C=k.error instanceof Error?k.error.message:String(k.error);throw new J(G.InvalidParams,`Invalid elicitation result: ${C}`)}const S=k.data,I=f==="form"?_.requestedSchema:void 0;if(f==="form"&&S.action==="accept"&&S.content&&I&&!((w=(p=this._capabilities.elicitation)===null||p===void 0?void 0:p.form)===null||w===void 0)&&w.applyDefaults)try{Ls(I,S.content)}catch{}return S};return super.setRequestHandler(e,u)}if(l==="sampling/createMessage"){const u=async(d,g)=>{const v=gt(ri,d);if(!v.success){const _=v.error instanceof Error?v.error.message:String(v.error);throw new J(G.InvalidParams,`Invalid sampling request: ${_}`)}const{params:p}=v.data,w=await Promise.resolve(r(d,g));if(p.task){const _=gt(mr,w);if(!_.success){const f=_.error instanceof Error?_.error.message:String(_.error);throw new J(G.InvalidParams,`Invalid task creation result: ${f}`)}return _.data}const h=gt(Is,w);if(!h.success){const _=h.error instanceof Error?h.error.message:String(h.error);throw new J(G.InvalidParams,`Invalid sampling result: ${_}`)}return h.data};return super.setRequestHandler(e,u)}return super.setRequestHandler(e,r)}assertCapability(e,r){var n;if(!(!((n=this._serverCapabilities)===null||n===void 0)&&n[e]))throw new Error(`Server does not support ${e} (required for ${r})`)}async connect(e,r){if(await super.connect(e),e.sessionId===void 0)try{const n=await this.request({method:"initialize",params:{protocolVersion:Fr,capabilities:this._capabilities,clientInfo:this._clientInfo}},Au,r);if(n===void 0)throw new Error(`Server sent invalid initialize result: ${n}`);if(!Tu.includes(n.protocolVersion))throw new Error(`Server's protocol version is not supported: ${n.protocolVersion}`);this._serverCapabilities=n.capabilities,this._serverVersion=n.serverInfo,e.setProtocolVersion&&e.setProtocolVersion(n.protocolVersion),this._instructions=n.instructions,await this.notification({method:"notifications/initialized"})}catch(n){throw this.close(),n}}getServerCapabilities(){return this._serverCapabilities}getServerVersion(){return this._serverVersion}getInstructions(){return this._instructions}assertCapabilityForMethod(e){var r,n,s,a,i;switch(e){case"logging/setLevel":if(!(!((r=this._serverCapabilities)===null||r===void 0)&&r.logging))throw new Error(`Server does not support logging (required for ${e})`);break;case"prompts/get":case"prompts/list":if(!(!((n=this._serverCapabilities)===null||n===void 0)&&n.prompts))throw new Error(`Server does not support prompts (required for ${e})`);break;case"resources/list":case"resources/templates/list":case"resources/read":case"resources/subscribe":case"resources/unsubscribe":if(!(!((s=this._serverCapabilities)===null||s===void 0)&&s.resources))throw new Error(`Server does not support resources (required for ${e})`);if(e==="resources/subscribe"&&!this._serverCapabilities.resources.subscribe)throw new Error(`Server does not support resource subscriptions (required for ${e})`);break;case"tools/call":case"tools/list":if(!(!((a=this._serverCapabilities)===null||a===void 0)&&a.tools))throw new Error(`Server does not support tools (required for ${e})`);break;case"completion/complete":if(!(!((i=this._serverCapabilities)===null||i===void 0)&&i.completions))throw new Error(`Server does not support completions (required for ${e})`);break}}assertNotificationCapability(e){var r;switch(e){case"notifications/roots/list_changed":if(!(!((r=this._capabilities.roots)===null||r===void 0)&&r.listChanged))throw new Error(`Client does not support roots list changed notifications (required for ${e})`);break}}assertRequestHandlerCapability(e){if(this._capabilities)switch(e){case"sampling/createMessage":if(!this._capabilities.sampling)throw new Error(`Client does not support sampling capability (required for ${e})`);break;case"elicitation/create":if(!this._capabilities.elicitation)throw new Error(`Client does not support elicitation capability (required for ${e})`);break;case"roots/list":if(!this._capabilities.roots)throw new Error(`Client does not support roots capability (required for ${e})`);break;case"tasks/get":case"tasks/list":case"tasks/result":case"tasks/cancel":if(!this._capabilities.tasks)throw new Error(`Client does not support tasks capability (required for ${e})`);break}}assertTaskCapability(e){var r,n;Ml((n=(r=this._serverCapabilities)===null||r===void 0?void 0:r.tasks)===null||n===void 0?void 0:n.requests,e,"Server")}assertTaskHandlerCapability(e){var r;this._capabilities&&ql((r=this._capabilities.tasks)===null||r===void 0?void 0:r.requests,e,"Client")}async ping(e){return this.request({method:"ping"},Ft,e)}async complete(e,r){return this.request({method:"completion/complete",params:e},el,r)}async setLoggingLevel(e,r){return this.request({method:"logging/setLevel",params:{level:e}},Ft,r)}async getPrompt(e,r){return this.request({method:"prompts/get",params:e},Ju,r)}async listPrompts(e,r){return this.request({method:"prompts/list",params:e},Wu,r)}async listResources(e,r){return this.request({method:"resources/list",params:e},Zu,r)}async listResourceTemplates(e,r){return this.request({method:"resources/templates/list",params:e},Lu,r)}async readResource(e,r){return this.request({method:"resources/read",params:e},Uu,r)}async subscribeResource(e,r){return this.request({method:"resources/subscribe",params:e},Ft,r)}async unsubscribeResource(e,r){return this.request({method:"resources/unsubscribe",params:e},Ft,r)}async callTool(e,r=vr,n){if(this.isToolTaskRequired(e.name))throw new J(G.InvalidRequest,`Tool "${e.name}" requires task-based execution. Use client.experimental.tasks.callToolStream() instead.`);const s=await this.request({method:"tools/call",params:e},r,n),a=this.getToolOutputValidator(e.name);if(a){if(!s.structuredContent&&!s.isError)throw new J(G.InvalidRequest,`Tool ${e.name} has an output schema but did not return structured content`);if(s.structuredContent)try{const i=a(s.structuredContent);if(!i.valid)throw new J(G.InvalidParams,`Structured content does not match the tool's output schema: ${i.errorMessage}`)}catch(i){throw i instanceof J?i:new J(G.InvalidParams,`Failed to validate structured content: ${i instanceof Error?i.message:String(i)}`)}}return s}isToolTask(e){var r,n,s,a;return!((a=(s=(n=(r=this._serverCapabilities)===null||r===void 0?void 0:r.tasks)===null||n===void 0?void 0:n.requests)===null||s===void 0?void 0:s.tools)===null||a===void 0)&&a.call?this._cachedKnownTaskTools.has(e):!1}isToolTaskRequired(e){return this._cachedRequiredTaskTools.has(e)}cacheToolMetadata(e){var r;this._cachedToolOutputValidators.clear(),this._cachedKnownTaskTools.clear(),this._cachedRequiredTaskTools.clear();for(const n of e){if(n.outputSchema){const a=this._jsonSchemaValidator.getValidator(n.outputSchema);this._cachedToolOutputValidators.set(n.name,a)}const s=(r=n.execution)===null||r===void 0?void 0:r.taskSupport;(s==="required"||s==="optional")&&this._cachedKnownTaskTools.add(n.name),s==="required"&&this._cachedRequiredTaskTools.add(n.name)}}getToolOutputValidator(e){return this._cachedToolOutputValidators.get(e)}async listTools(e,r){const n=await this.request({method:"tools/list",params:e},Gu,r);return this.cacheToolMetadata(n.tools),n}async sendRootsListChanged(){return this.notification({method:"notifications/roots/list_changed"})}}class Zl extends Error{constructor(e,r){super(e),this.name="ParseError",this.type=r.type,this.field=r.field,this.value=r.value,this.line=r.line}}function gi(t){}function Ll(t){if(typeof t=="function")throw new TypeError("`callbacks` must be an object, got a function instead. Did you mean `{onEvent: fn}`?");const{onEvent:e=gi,onError:r=gi,onRetry:n=gi,onComment:s}=t;let a="",i=!0,o,c="",l="";function u(w){const h=i?w.replace(/^\xEF\xBB\xBF/,""):w,[_,f]=by(`${a}${h}`);for(const m of _)d(m);a=f,i=!1}function d(w){if(w===""){v();return}if(w.startsWith(":")){s&&s(w.slice(w.startsWith(": ")?2:1));return}const h=w.indexOf(":");if(h!==-1){const _=w.slice(0,h),f=w[h+1]===" "?2:1,m=w.slice(h+f);g(_,m,w);return}g(w,"",w)}function g(w,h,_){switch(w){case"event":l=h;break;case"data":c=`${c}${h}
|
|
40
|
-
`;break;case"id":
|
|
41
|
-
`)?c.slice(0,-1):c}),
|
|
42
|
-
`,n);let i=-1;if(s!==-1&&
|
|
43
|
-
`&&n++}}return[e,r]}class Ul extends Event{constructor(e,r){var n,s;super(e),this.code=(n=r?.code)!=null?n:void 0,this.message=(s=r?.message)!=null?s:void 0}[Symbol.for("nodejs.util.inspect.custom")](e,r,n){return n(Dl(this),r)}[Symbol.for("Deno.customInspect")](e,r){return e(Dl(this),r)}}function ky(t){const e=globalThis.DOMException;return typeof e=="function"?new e(t,"SyntaxError"):new SyntaxError(t)}function yi(t){return t instanceof Error?"errors"in t&&Array.isArray(t.errors)?t.errors.map(yi).join(", "):"cause"in t&&t.cause instanceof Error?`${t}: ${yi(t.cause)}`:t.message:`${t}`}function Dl(t){return{type:t.type,message:t.message,code:t.code,defaultPrevented:t.defaultPrevented,cancelable:t.cancelable,timeStamp:t.timeStamp}}var Vl=t=>{throw TypeError(t)},wi=(t,e,r)=>e.has(t)||Vl("Cannot "+r),de=(t,e,r)=>(wi(t,e,"read from private field"),r?r.call(t):e.get(t)),Me=(t,e,r)=>e.has(t)?Vl("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),Ie=(t,e,r,n)=>(wi(t,e,"write to private field"),e.set(t,r),r),Mt=(t,e,r)=>(wi(t,e,"access private method"),r),rt,ur,Tr,Us,Ds,mn,Er,_n,Bt,Rr,Pr,xr,vn,bt,bi,ki,$i,Fl,Si,Ti,gn,Ei,Ri;class Vs extends EventTarget{constructor(e,r){var n,s;super(),Me(this,bt),this.CONNECTING=0,this.OPEN=1,this.CLOSED=2,Me(this,rt),Me(this,ur),Me(this,Tr),Me(this,Us),Me(this,Ds),Me(this,mn),Me(this,Er),Me(this,_n,null),Me(this,Bt),Me(this,Rr),Me(this,Pr,null),Me(this,xr,null),Me(this,vn,null),Me(this,ki,async a=>{var i;de(this,Rr).reset();const{body:o,redirected:c,status:l,headers:u}=a;if(l===204){Mt(this,bt,gn).call(this,"Server sent HTTP 204, not reconnecting",204),this.close();return}if(c?Ie(this,Tr,new URL(a.url)):Ie(this,Tr,void 0),l!==200){Mt(this,bt,gn).call(this,`Non-200 status code (${l})`,l);return}if(!(u.get("content-type")||"").startsWith("text/event-stream")){Mt(this,bt,gn).call(this,'Invalid content type, expected "text/event-stream"',l);return}if(de(this,rt)===this.CLOSED)return;Ie(this,rt,this.OPEN);const d=new Event("open");if((i=de(this,vn))==null||i.call(this,d),this.dispatchEvent(d),typeof o!="object"||!o||!("getReader"in o)){Mt(this,bt,gn).call(this,"Invalid response body, expected a web ReadableStream",l),this.close();return}const g=new TextDecoder,v=o.getReader();let p=!0;do{const{done:w,value:h}=await v.read();h&&de(this,Rr).feed(g.decode(h,{stream:!w})),w&&(p=!1,de(this,Rr).reset(),Mt(this,bt,Ei).call(this))}while(p)}),Me(this,$i,a=>{Ie(this,Bt,void 0),!(a.name==="AbortError"||a.type==="aborted")&&Mt(this,bt,Ei).call(this,yi(a))}),Me(this,Si,a=>{typeof a.id=="string"&&Ie(this,_n,a.id);const i=new MessageEvent(a.event||"message",{data:a.data,origin:de(this,Tr)?de(this,Tr).origin:de(this,ur).origin,lastEventId:a.id||""});de(this,xr)&&(!a.event||a.event==="message")&&de(this,xr).call(this,i),this.dispatchEvent(i)}),Me(this,Ti,a=>{Ie(this,mn,a)}),Me(this,Ri,()=>{Ie(this,Er,void 0),de(this,rt)===this.CONNECTING&&Mt(this,bt,bi).call(this)});try{if(e instanceof URL)Ie(this,ur,e);else if(typeof e=="string")Ie(this,ur,new URL(e,$y()));else throw new Error("Invalid URL")}catch{throw ky("An invalid or illegal string was specified")}Ie(this,Rr,Ll({onEvent:de(this,Si),onRetry:de(this,Ti)})),Ie(this,rt,this.CONNECTING),Ie(this,mn,3e3),Ie(this,Ds,(n=r?.fetch)!=null?n:globalThis.fetch),Ie(this,Us,(s=r?.withCredentials)!=null?s:!1),Mt(this,bt,bi).call(this)}get readyState(){return de(this,rt)}get url(){return de(this,ur).href}get withCredentials(){return de(this,Us)}get onerror(){return de(this,Pr)}set onerror(e){Ie(this,Pr,e)}get onmessage(){return de(this,xr)}set onmessage(e){Ie(this,xr,e)}get onopen(){return de(this,vn)}set onopen(e){Ie(this,vn,e)}addEventListener(e,r,n){const s=r;super.addEventListener(e,s,n)}removeEventListener(e,r,n){const s=r;super.removeEventListener(e,s,n)}close(){de(this,Er)&&clearTimeout(de(this,Er)),de(this,rt)!==this.CLOSED&&(de(this,Bt)&&de(this,Bt).abort(),Ie(this,rt,this.CLOSED),Ie(this,Bt,void 0))}}rt=new WeakMap,ur=new WeakMap,Tr=new WeakMap,Us=new WeakMap,Ds=new WeakMap,mn=new WeakMap,Er=new WeakMap,_n=new WeakMap,Bt=new WeakMap,Rr=new WeakMap,Pr=new WeakMap,xr=new WeakMap,vn=new WeakMap,bt=new WeakSet,bi=function(){Ie(this,rt,this.CONNECTING),Ie(this,Bt,new AbortController),de(this,Ds)(de(this,ur),Mt(this,bt,Fl).call(this)).then(de(this,ki)).catch(de(this,$i))},ki=new WeakMap,$i=new WeakMap,Fl=function(){var t;const e={mode:"cors",redirect:"follow",headers:{Accept:"text/event-stream",...de(this,_n)?{"Last-Event-ID":de(this,_n)}:void 0},cache:"no-store",signal:(t=de(this,Bt))==null?void 0:t.signal};return"window"in globalThis&&(e.credentials=this.withCredentials?"include":"same-origin"),e},Si=new WeakMap,Ti=new WeakMap,gn=function(t,e){var r;de(this,rt)!==this.CLOSED&&Ie(this,rt,this.CLOSED);const n=new Ul("error",{code:e,message:t});(r=de(this,Pr))==null||r.call(this,n),this.dispatchEvent(n)},Ei=function(t,e){var r;if(de(this,rt)===this.CLOSED)return;Ie(this,rt,this.CONNECTING);const n=new Ul("error",{code:e,message:t});(r=de(this,Pr))==null||r.call(this,n),this.dispatchEvent(n),Ie(this,Er,setTimeout(de(this,Ri),de(this,mn)))},Ri=new WeakMap,Vs.CONNECTING=0,Vs.OPEN=1,Vs.CLOSED=2;function $y(){const t="document"in globalThis?globalThis.document:void 0;return t&&typeof t=="object"&&"baseURI"in t&&typeof t.baseURI=="string"?t.baseURI:void 0}function Fs(t){return t?t instanceof Headers?Object.fromEntries(t.entries()):Array.isArray(t)?Object.fromEntries(t):{...t}:{}}function Hl(t=fetch,e){return e?async(r,n)=>{const s={...e,...n,headers:n?.headers?{...Fs(e.headers),...Fs(n.headers)}:e.headers};return t(r,s)}:t}let Pi;Pi=globalThis.crypto;async function Sy(t){return(await Pi).getRandomValues(new Uint8Array(t))}async function Ty(t){const e="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._~",r=Math.pow(2,8)-Math.pow(2,8)%e.length;let n="";for(;n.length<t;){const s=await Sy(t-n.length);for(const a of s)a<r&&(n+=e[a%e.length])}return n}async function Ey(t){return await Ty(t)}async function Ry(t){const e=await(await Pi).subtle.digest("SHA-256",new TextEncoder().encode(t));return btoa(String.fromCharCode(...new Uint8Array(e))).replace(/\//g,"_").replace(/\+/g,"-").replace(/=/g,"")}async function Py(t){if(t||(t=43),t<43||t>128)throw`Expected a length between 43 and 128. Received ${t}.`;const e=await Ey(t),r=await Ry(e);return{code_verifier:e,code_challenge:r}}const Ue=hm().superRefine((t,e)=>{if(!URL.canParse(t))return e.addIssue({code:s_.custom,message:"URL must be parseable",fatal:!0}),cf}).refine(t=>{const e=new URL(t);return e.protocol!=="javascript:"&&e.protocol!=="data:"&&e.protocol!=="vbscript:"},{message:"URL cannot use javascript:, data:, or vbscript: scheme"}),xy=Xe({resource:E().url(),authorization_servers:H(Ue).optional(),jwks_uri:E().url().optional(),scopes_supported:H(E()).optional(),bearer_methods_supported:H(E()).optional(),resource_signing_alg_values_supported:H(E()).optional(),resource_name:E().optional(),resource_documentation:E().optional(),resource_policy_uri:E().url().optional(),resource_tos_uri:E().url().optional(),tls_client_certificate_bound_access_tokens:Pe().optional(),authorization_details_types_supported:H(E()).optional(),dpop_signing_alg_values_supported:H(E()).optional(),dpop_bound_access_tokens_required:Pe().optional()}),Wl=Xe({issuer:E(),authorization_endpoint:Ue,token_endpoint:Ue,registration_endpoint:Ue.optional(),scopes_supported:H(E()).optional(),response_types_supported:H(E()),response_modes_supported:H(E()).optional(),grant_types_supported:H(E()).optional(),token_endpoint_auth_methods_supported:H(E()).optional(),token_endpoint_auth_signing_alg_values_supported:H(E()).optional(),service_documentation:Ue.optional(),revocation_endpoint:Ue.optional(),revocation_endpoint_auth_methods_supported:H(E()).optional(),revocation_endpoint_auth_signing_alg_values_supported:H(E()).optional(),introspection_endpoint:E().optional(),introspection_endpoint_auth_methods_supported:H(E()).optional(),introspection_endpoint_auth_signing_alg_values_supported:H(E()).optional(),code_challenge_methods_supported:H(E()).optional(),client_id_metadata_document_supported:Pe().optional()}),Iy=Xe({issuer:E(),authorization_endpoint:Ue,token_endpoint:Ue,userinfo_endpoint:Ue.optional(),jwks_uri:Ue,registration_endpoint:Ue.optional(),scopes_supported:H(E()).optional(),response_types_supported:H(E()),response_modes_supported:H(E()).optional(),grant_types_supported:H(E()).optional(),acr_values_supported:H(E()).optional(),subject_types_supported:H(E()),id_token_signing_alg_values_supported:H(E()),id_token_encryption_alg_values_supported:H(E()).optional(),id_token_encryption_enc_values_supported:H(E()).optional(),userinfo_signing_alg_values_supported:H(E()).optional(),userinfo_encryption_alg_values_supported:H(E()).optional(),userinfo_encryption_enc_values_supported:H(E()).optional(),request_object_signing_alg_values_supported:H(E()).optional(),request_object_encryption_alg_values_supported:H(E()).optional(),request_object_encryption_enc_values_supported:H(E()).optional(),token_endpoint_auth_methods_supported:H(E()).optional(),token_endpoint_auth_signing_alg_values_supported:H(E()).optional(),display_values_supported:H(E()).optional(),claim_types_supported:H(E()).optional(),claims_supported:H(E()).optional(),service_documentation:E().optional(),claims_locales_supported:H(E()).optional(),ui_locales_supported:H(E()).optional(),claims_parameter_supported:Pe().optional(),request_parameter_supported:Pe().optional(),request_uri_parameter_supported:Pe().optional(),require_request_uri_registration:Pe().optional(),op_policy_uri:Ue.optional(),op_tos_uri:Ue.optional(),client_id_metadata_document_supported:Pe().optional()}),Cy=U({...Iy.shape,...Wl.pick({code_challenge_methods_supported:!0}).shape}),Oy=U({access_token:E(),id_token:E().optional(),token_type:E(),expires_in:a_().optional(),scope:E().optional(),refresh_token:E().optional()}).strip(),Ny=U({error:E(),error_description:E().optional(),error_uri:E().optional()}),Jl=Ue.optional().or(te("").transform(()=>{})),Ay=U({redirect_uris:H(Ue),token_endpoint_auth_method:E().optional(),grant_types:H(E()).optional(),response_types:H(E()).optional(),client_name:E().optional(),client_uri:Ue.optional(),logo_uri:Jl,scope:E().optional(),contacts:H(E()).optional(),tos_uri:Jl,policy_uri:E().optional(),jwks_uri:Ue.optional(),jwks:Nm().optional(),software_id:E().optional(),software_version:E().optional(),software_statement:E().optional()}).strip(),jy=U({client_id:E(),client_secret:E().optional(),client_id_issued_at:we().optional(),client_secret_expires_at:we().optional()}).strip(),zy=Ay.merge(jy);U({error:E(),error_description:E().optional()}).strip(),U({token:E(),token_type_hint:E().optional()}).strip();function My(t){const e=typeof t=="string"?new URL(t):new URL(t.href);return e.hash="",e}function qy({requestedResource:t,configuredResource:e}){const r=typeof t=="string"?new URL(t):new URL(t.href),n=typeof e=="string"?new URL(e):new URL(e.href);if(r.origin!==n.origin||r.pathname.length<n.pathname.length)return!1;const s=r.pathname.endsWith("/")?r.pathname:r.pathname+"/",a=n.pathname.endsWith("/")?n.pathname:n.pathname+"/";return s.startsWith(a)}class qe extends Error{constructor(e,r){super(e),this.errorUri=r,this.name=this.constructor.name}toResponseObject(){const e={error:this.errorCode,error_description:this.message};return this.errorUri&&(e.error_uri=this.errorUri),e}get errorCode(){return this.constructor.errorCode}}class xi extends qe{}xi.errorCode="invalid_request";class Hs extends qe{}Hs.errorCode="invalid_client";class Ws extends qe{}Ws.errorCode="invalid_grant";class Js extends qe{}Js.errorCode="unauthorized_client";class Ii extends qe{}Ii.errorCode="unsupported_grant_type";class Ci extends qe{}Ci.errorCode="invalid_scope";class Oi extends qe{}Oi.errorCode="access_denied";class Ir extends qe{}Ir.errorCode="server_error";class Ni extends qe{}Ni.errorCode="temporarily_unavailable";class Ai extends qe{}Ai.errorCode="unsupported_response_type";class ji extends qe{}ji.errorCode="unsupported_token_type";class zi extends qe{}zi.errorCode="invalid_token";class Mi extends qe{}Mi.errorCode="method_not_allowed";class qi extends qe{}qi.errorCode="too_many_requests";class Ks extends qe{}Ks.errorCode="invalid_client_metadata";class Zi extends qe{}Zi.errorCode="insufficient_scope";class Li extends qe{}Li.errorCode="invalid_target";const Zy={[xi.errorCode]:xi,[Hs.errorCode]:Hs,[Ws.errorCode]:Ws,[Js.errorCode]:Js,[Ii.errorCode]:Ii,[Ci.errorCode]:Ci,[Oi.errorCode]:Oi,[Ir.errorCode]:Ir,[Ni.errorCode]:Ni,[Ai.errorCode]:Ai,[ji.errorCode]:ji,[zi.errorCode]:zi,[Mi.errorCode]:Mi,[qi.errorCode]:qi,[Ks.errorCode]:Ks,[Zi.errorCode]:Zi,[Li.errorCode]:Li};class dt extends Error{constructor(e){super(e??"Unauthorized")}}function Ly(t){return["client_secret_basic","client_secret_post","none"].includes(t)}const Ui="code",Di="S256";function Uy(t,e){const r=t.client_secret!==void 0;return e.length===0?r?"client_secret_post":"none":"token_endpoint_auth_method"in t&&t.token_endpoint_auth_method&&Ly(t.token_endpoint_auth_method)&&e.includes(t.token_endpoint_auth_method)?t.token_endpoint_auth_method:r&&e.includes("client_secret_basic")?"client_secret_basic":r&&e.includes("client_secret_post")?"client_secret_post":e.includes("none")?"none":r?"client_secret_post":"none"}function Dy(t,e,r,n){const{client_id:s,client_secret:a}=e;switch(t){case"client_secret_basic":Vy(s,a,r);return;case"client_secret_post":Fy(s,a,n);return;case"none":Hy(s,n);return;default:throw new Error(`Unsupported client authentication method: ${t}`)}}function Vy(t,e,r){if(!e)throw new Error("client_secret_basic authentication requires a client_secret");const n=btoa(`${t}:${e}`);r.set("Authorization",`Basic ${n}`)}function Fy(t,e,r){r.set("client_id",t),e&&r.set("client_secret",e)}function Hy(t,e){e.set("client_id",t)}async function Kl(t){const e=t instanceof Response?t.status:void 0,r=t instanceof Response?await t.text():t;try{const n=Ny.parse(JSON.parse(r)),{error:s,error_description:a,error_uri:i}=n,o=Zy[s]||Ir;return new o(a||"",i)}catch(n){const s=`${e?`HTTP ${e}: `:""}Invalid OAuth error response: ${n}. Raw body: ${r}`;return new Ir(s)}}async function lr(t,e){var r,n;try{return await Vi(t,e)}catch(s){if(s instanceof Hs||s instanceof Js)return await((r=t.invalidateCredentials)===null||r===void 0?void 0:r.call(t,"all")),await Vi(t,e);if(s instanceof Ws)return await((n=t.invalidateCredentials)===null||n===void 0?void 0:n.call(t,"tokens")),await Vi(t,e);throw s}}async function Vi(t,{serverUrl:e,authorizationCode:r,scope:n,resourceMetadataUrl:s,fetchFn:a}){var i,o;let c,l;try{c=await Ky(e,{resourceMetadataUrl:s},a),c.authorization_servers&&c.authorization_servers.length>0&&(l=c.authorization_servers[0])}catch{}l||(l=new URL("/",e));const u=await Jy(e,t,c),d=await Xy(l,{fetchFn:a});let g=await Promise.resolve(t.clientInformation());if(!g){if(r!==void 0)throw new Error("Existing OAuth client information is required when exchanging an authorization code");const f=d?.client_id_metadata_document_supported===!0,m=t.clientMetadataUrl;if(m&&!Wy(m))throw new Ks(`clientMetadataUrl must be a valid HTTPS URL with a non-root pathname, got: ${m}`);if(f&&m)g={client_id:m},await((i=t.saveClientInformation)===null||i===void 0?void 0:i.call(t,g));else{if(!t.saveClientInformation)throw new Error("OAuth client information must be saveable for dynamic registration");const y=await s0(l,{metadata:d,clientMetadata:t.clientMetadata,fetchFn:a});await t.saveClientInformation(y),g=y}}const v=!t.redirectUrl;if(r!==void 0||v){const f=await n0(t,l,{metadata:d,resource:u,authorizationCode:r,fetchFn:a});return await t.saveTokens(f),"AUTHORIZED"}const p=await t.tokens();if(p?.refresh_token)try{const f=await r0(l,{metadata:d,clientInformation:g,refreshToken:p.refresh_token,resource:u,addClientAuthentication:t.addClientAuthentication,fetchFn:a});return await t.saveTokens(f),"AUTHORIZED"}catch(f){if(!(!(f instanceof qe)||f instanceof Ir))throw f}const w=t.state?await t.state():void 0,{authorizationUrl:h,codeVerifier:_}=await e0(l,{metadata:d,clientInformation:g,state:w,redirectUrl:t.redirectUrl,scope:n||((o=c?.scopes_supported)===null||o===void 0?void 0:o.join(" "))||t.clientMetadata.scope,resource:u});return await t.saveCodeVerifier(_),await t.redirectToAuthorization(h),"REDIRECT"}function Wy(t){if(!t)return!1;try{const e=new URL(t);return e.protocol==="https:"&&e.pathname!=="/"}catch{return!1}}async function Jy(t,e,r){const n=My(t);if(e.validateResourceURL)return await e.validateResourceURL(n,r?.resource);if(r){if(!qy({requestedResource:n,configuredResource:r.resource}))throw new Error(`Protected resource ${r.resource} does not match expected ${n} (or origin)`);return new URL(r.resource)}}function Bs(t){const e=t.headers.get("WWW-Authenticate");if(!e)return{};const[r,n]=e.split(" ");if(r.toLowerCase()!=="bearer"||!n)return{};const s=Fi(t,"resource_metadata")||void 0;let a;if(s)try{a=new URL(s)}catch{}const i=Fi(t,"scope")||void 0,o=Fi(t,"error")||void 0;return{resourceMetadataUrl:a,scope:i,error:o}}function Fi(t,e){const r=t.headers.get("WWW-Authenticate");if(!r)return null;const n=new RegExp(`${e}=(?:"([^"]+)"|([^\\s,]+))`),s=r.match(n);return s?s[1]||s[2]:null}async function Ky(t,e,r=fetch){var n,s;const a=await Yy(t,"oauth-protected-resource",r,{protocolVersion:e?.protocolVersion,metadataUrl:e?.resourceMetadataUrl});if(!a||a.status===404)throw await((n=a?.body)===null||n===void 0?void 0:n.cancel()),new Error("Resource server does not implement OAuth 2.0 Protected Resource Metadata.");if(!a.ok)throw await((s=a.body)===null||s===void 0?void 0:s.cancel()),new Error(`HTTP ${a.status} trying to load well-known OAuth protected resource metadata.`);return xy.parse(await a.json())}async function Hi(t,e,r=fetch){try{return await r(t,{headers:e})}catch(n){if(n instanceof TypeError)return e?Hi(t,void 0,r):void 0;throw n}}function By(t,e="",r={}){return e.endsWith("/")&&(e=e.slice(0,-1)),r.prependPathname?`${e}/.well-known/${t}`:`/.well-known/${t}${e}`}async function Bl(t,e,r=fetch){return await Hi(t,{"MCP-Protocol-Version":e},r)}function Gy(t,e){return!t||t.status>=400&&t.status<500&&e!=="/"}async function Yy(t,e,r,n){var s,a;const i=new URL(t),o=(s=n?.protocolVersion)!==null&&s!==void 0?s:Fr;let c;if(n?.metadataUrl)c=new URL(n.metadataUrl);else{const u=By(e,i.pathname);c=new URL(u,(a=n?.metadataServerUrl)!==null&&a!==void 0?a:i),c.search=i.search}let l=await Bl(c,o,r);if(!n?.metadataUrl&&Gy(l,i.pathname)){const u=new URL(`/.well-known/${e}`,i);l=await Bl(u,o,r)}return l}function Qy(t){const e=typeof t=="string"?new URL(t):t,r=e.pathname!=="/",n=[];if(!r)return n.push({url:new URL("/.well-known/oauth-authorization-server",e.origin),type:"oauth"}),n.push({url:new URL("/.well-known/openid-configuration",e.origin),type:"oidc"}),n;let s=e.pathname;return s.endsWith("/")&&(s=s.slice(0,-1)),n.push({url:new URL(`/.well-known/oauth-authorization-server${s}`,e.origin),type:"oauth"}),n.push({url:new URL(`/.well-known/openid-configuration${s}`,e.origin),type:"oidc"}),n.push({url:new URL(`${s}/.well-known/openid-configuration`,e.origin),type:"oidc"}),n}async function Xy(t,{fetchFn:e=fetch,protocolVersion:r=Fr}={}){var n;const s={"MCP-Protocol-Version":r,Accept:"application/json"},a=Qy(t);for(const{url:i,type:o}of a){const c=await Hi(i,s,e);if(c){if(!c.ok){if(await((n=c.body)===null||n===void 0?void 0:n.cancel()),c.status>=400&&c.status<500)continue;throw new Error(`HTTP ${c.status} trying to load ${o==="oauth"?"OAuth":"OpenID provider"} metadata from ${i}`)}return o==="oauth"?Wl.parse(await c.json()):Cy.parse(await c.json())}}}async function e0(t,{metadata:e,clientInformation:r,redirectUrl:n,scope:s,state:a,resource:i}){let o;if(e){if(o=new URL(e.authorization_endpoint),!e.response_types_supported.includes(Ui))throw new Error(`Incompatible auth server: does not support response type ${Ui}`);if(e.code_challenge_methods_supported&&!e.code_challenge_methods_supported.includes(Di))throw new Error(`Incompatible auth server: does not support code challenge method ${Di}`)}else o=new URL("/authorize",t);const c=await Py(),l=c.code_verifier,u=c.code_challenge;return o.searchParams.set("response_type",Ui),o.searchParams.set("client_id",r.client_id),o.searchParams.set("code_challenge",u),o.searchParams.set("code_challenge_method",Di),o.searchParams.set("redirect_uri",String(n)),a&&o.searchParams.set("state",a),s&&o.searchParams.set("scope",s),s?.includes("offline_access")&&o.searchParams.append("prompt","consent"),i&&o.searchParams.set("resource",i.href),{authorizationUrl:o,codeVerifier:l}}function t0(t,e,r){return new URLSearchParams({grant_type:"authorization_code",code:t,code_verifier:e,redirect_uri:String(r)})}async function Gl(t,{metadata:e,tokenRequestParams:r,clientInformation:n,addClientAuthentication:s,resource:a,fetchFn:i}){var o;const c=e?.token_endpoint?new URL(e.token_endpoint):new URL("/token",t),l=new Headers({"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json"});if(a&&r.set("resource",a.href),s)await s(l,r,c,e);else if(n){const d=(o=e?.token_endpoint_auth_methods_supported)!==null&&o!==void 0?o:[],g=Uy(n,d);Dy(g,n,l,r)}const u=await(i??fetch)(c,{method:"POST",headers:l,body:r});if(!u.ok)throw await Kl(u);return Oy.parse(await u.json())}async function r0(t,{metadata:e,clientInformation:r,refreshToken:n,resource:s,addClientAuthentication:a,fetchFn:i}){const o=new URLSearchParams({grant_type:"refresh_token",refresh_token:n}),c=await Gl(t,{metadata:e,tokenRequestParams:o,clientInformation:r,addClientAuthentication:a,resource:s,fetchFn:i});return{refresh_token:n,...c}}async function n0(t,e,{metadata:r,resource:n,authorizationCode:s,fetchFn:a}={}){const i=t.clientMetadata.scope;let o;if(t.prepareTokenRequest&&(o=await t.prepareTokenRequest(i)),!o){if(!s)throw new Error("Either provider.prepareTokenRequest() or authorizationCode is required");if(!t.redirectUrl)throw new Error("redirectUrl is required for authorization_code flow");const l=await t.codeVerifier();o=t0(s,l,t.redirectUrl)}const c=await t.clientInformation();return Gl(e,{metadata:r,tokenRequestParams:o,clientInformation:c??void 0,addClientAuthentication:t.addClientAuthentication,resource:n,fetchFn:a})}async function s0(t,{metadata:e,clientMetadata:r,fetchFn:n}){let s;if(e){if(!e.registration_endpoint)throw new Error("Incompatible auth server: does not support dynamic client registration");s=new URL(e.registration_endpoint)}else s=new URL("/register",t);const a=await(n??fetch)(s,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)});if(!a.ok)throw await Kl(a);return zy.parse(await a.json())}class a0 extends Error{constructor(e,r,n){super(`SSE error: ${r}`),this.code=e,this.event=n}}class yn{constructor(e,r){this._url=e,this._resourceMetadataUrl=void 0,this._scope=void 0,this._eventSourceInit=r?.eventSourceInit,this._requestInit=r?.requestInit,this._authProvider=r?.authProvider,this._fetch=r?.fetch,this._fetchWithInit=Hl(r?.fetch,r?.requestInit)}async _authThenStart(){var e;if(!this._authProvider)throw new dt("No auth provider");let r;try{r=await lr(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})}catch(n){throw(e=this.onerror)===null||e===void 0||e.call(this,n),n}if(r!=="AUTHORIZED")throw new dt;return await this._startOrAuth()}async _commonHeaders(){var e;const r={};if(this._authProvider){const s=await this._authProvider.tokens();s&&(r.Authorization=`Bearer ${s.access_token}`)}this._protocolVersion&&(r["mcp-protocol-version"]=this._protocolVersion);const n=Fs((e=this._requestInit)===null||e===void 0?void 0:e.headers);return new Headers({...r,...n})}_startOrAuth(){var e,r,n;const s=(n=(r=(e=this===null||this===void 0?void 0:this._eventSourceInit)===null||e===void 0?void 0:e.fetch)!==null&&r!==void 0?r:this._fetch)!==null&&n!==void 0?n:fetch;return new Promise((a,i)=>{this._eventSource=new Vs(this._url.href,{...this._eventSourceInit,fetch:async(o,c)=>{const l=await this._commonHeaders();l.set("Accept","text/event-stream");const u=await s(o,{...c,headers:l});if(u.status===401&&u.headers.has("www-authenticate")){const{resourceMetadataUrl:d,scope:g}=Bs(u);this._resourceMetadataUrl=d,this._scope=g}return u}}),this._abortController=new AbortController,this._eventSource.onerror=o=>{var c;if(o.code===401&&this._authProvider){this._authThenStart().then(a,i);return}const l=new a0(o.code,o.message,o);i(l),(c=this.onerror)===null||c===void 0||c.call(this,l)},this._eventSource.onopen=()=>{},this._eventSource.addEventListener("endpoint",o=>{var c;const l=o;try{if(this._endpoint=new URL(l.data,this._url),this._endpoint.origin!==this._url.origin)throw new Error(`Endpoint origin does not match connection origin: ${this._endpoint.origin}`)}catch(u){i(u),(c=this.onerror)===null||c===void 0||c.call(this,u),this.close();return}a()}),this._eventSource.onmessage=o=>{var c,l;const u=o;let d;try{d=nr.parse(JSON.parse(u.data))}catch(g){(c=this.onerror)===null||c===void 0||c.call(this,g);return}(l=this.onmessage)===null||l===void 0||l.call(this,d)}})}async start(){if(this._eventSource)throw new Error("SSEClientTransport already started! If using Client class, note that connect() calls start() automatically.");return await this._startOrAuth()}async finishAuth(e){if(!this._authProvider)throw new dt("No auth provider");if(await lr(this._authProvider,{serverUrl:this._url,authorizationCode:e,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new dt("Failed to authorize")}async close(){var e,r,n;(e=this._abortController)===null||e===void 0||e.abort(),(r=this._eventSource)===null||r===void 0||r.close(),(n=this.onclose)===null||n===void 0||n.call(this)}async send(e){var r,n,s,a;if(!this._endpoint)throw new Error("Not connected");try{const i=await this._commonHeaders();i.set("content-type","application/json");const o={...this._requestInit,method:"POST",headers:i,body:JSON.stringify(e),signal:(r=this._abortController)===null||r===void 0?void 0:r.signal},c=await((n=this._fetch)!==null&&n!==void 0?n:fetch)(this._endpoint,o);if(!c.ok){const l=await c.text().catch(()=>null);if(c.status===401&&this._authProvider){const{resourceMetadataUrl:u,scope:d}=Bs(c);if(this._resourceMetadataUrl=u,this._scope=d,await lr(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new dt;return this.send(e)}throw new Error(`Error POSTing to endpoint (HTTP ${c.status}): ${l}`)}await((s=c.body)===null||s===void 0?void 0:s.cancel())}catch(i){throw(a=this.onerror)===null||a===void 0||a.call(this,i),i}}setProtocolVersion(e){this._protocolVersion=e}}class i0 extends TransformStream{constructor({onError:e,onRetry:r,onComment:n}={}){let s;super({start(a){s=Ll({onEvent:i=>{a.enqueue(i)},onError(i){e==="terminate"?a.error(i):typeof e=="function"&&e(i)},onRetry:r,onComment:n})},transform(a){s.feed(a)}})}}const o0={initialReconnectionDelay:1e3,maxReconnectionDelay:3e4,reconnectionDelayGrowFactor:1.5,maxRetries:2};class Cr extends Error{constructor(e,r){super(`Streamable HTTP error: ${r}`),this.code=e}}class Gs{constructor(e,r){var n;this._hasCompletedAuthFlow=!1,this._url=e,this._resourceMetadataUrl=void 0,this._scope=void 0,this._requestInit=r?.requestInit,this._authProvider=r?.authProvider,this._fetch=r?.fetch,this._fetchWithInit=Hl(r?.fetch,r?.requestInit),this._sessionId=r?.sessionId,this._reconnectionOptions=(n=r?.reconnectionOptions)!==null&&n!==void 0?n:o0}async _authThenStart(){var e;if(!this._authProvider)throw new dt("No auth provider");let r;try{r=await lr(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})}catch(n){throw(e=this.onerror)===null||e===void 0||e.call(this,n),n}if(r!=="AUTHORIZED")throw new dt;return await this._startOrAuthSse({resumptionToken:void 0})}async _commonHeaders(){var e;const r={};if(this._authProvider){const s=await this._authProvider.tokens();s&&(r.Authorization=`Bearer ${s.access_token}`)}this._sessionId&&(r["mcp-session-id"]=this._sessionId),this._protocolVersion&&(r["mcp-protocol-version"]=this._protocolVersion);const n=Fs((e=this._requestInit)===null||e===void 0?void 0:e.headers);return new Headers({...r,...n})}async _startOrAuthSse(e){var r,n,s,a;const{resumptionToken:i}=e;try{const o=await this._commonHeaders();o.set("Accept","text/event-stream"),i&&o.set("last-event-id",i);const c=await((r=this._fetch)!==null&&r!==void 0?r:fetch)(this._url,{method:"GET",headers:o,signal:(n=this._abortController)===null||n===void 0?void 0:n.signal});if(!c.ok){if(await((s=c.body)===null||s===void 0?void 0:s.cancel()),c.status===401&&this._authProvider)return await this._authThenStart();if(c.status===405)return;throw new Cr(c.status,`Failed to open SSE stream: ${c.statusText}`)}this._handleSseStream(c.body,e,!0)}catch(o){throw(a=this.onerror)===null||a===void 0||a.call(this,o),o}}_getNextReconnectionDelay(e){if(this._serverRetryMs!==void 0)return this._serverRetryMs;const r=this._reconnectionOptions.initialReconnectionDelay,n=this._reconnectionOptions.reconnectionDelayGrowFactor,s=this._reconnectionOptions.maxReconnectionDelay;return Math.min(r*Math.pow(n,e),s)}_scheduleReconnection(e,r=0){var n;const s=this._reconnectionOptions.maxRetries;if(r>=s){(n=this.onerror)===null||n===void 0||n.call(this,new Error(`Maximum reconnection attempts (${s}) exceeded.`));return}const a=this._getNextReconnectionDelay(r);this._reconnectionTimeout=setTimeout(()=>{this._startOrAuthSse(e).catch(i=>{var o;(o=this.onerror)===null||o===void 0||o.call(this,new Error(`Failed to reconnect SSE stream: ${i instanceof Error?i.message:String(i)}`)),this._scheduleReconnection(e,r+1)})},a)}_handleSseStream(e,r,n){if(!e)return;const{onresumptiontoken:s,replayMessageId:a}=r;let i,o=!1,c=!1;(async()=>{var u,d,g,v;try{const p=e.pipeThrough(new TextDecoderStream).pipeThrough(new i0({onRetry:_=>{this._serverRetryMs=_}})).getReader();for(;;){const{value:_,done:f}=await p.read();if(f)break;if(_.id&&(i=_.id,o=!0,s?.(_.id)),!!_.data&&(!_.event||_.event==="message"))try{const m=nr.parse(JSON.parse(_.data));Hr(m)&&(c=!0,a!==void 0&&(m.id=a)),(u=this.onmessage)===null||u===void 0||u.call(this,m)}catch(m){(d=this.onerror)===null||d===void 0||d.call(this,m)}}(n||o)&&!c&&this._abortController&&!this._abortController.signal.aborted&&this._scheduleReconnection({resumptionToken:i,onresumptiontoken:s,replayMessageId:a},0)}catch(p){if((g=this.onerror)===null||g===void 0||g.call(this,new Error(`SSE stream disconnected: ${p}`)),(n||o)&&!c&&this._abortController&&!this._abortController.signal.aborted)try{this._scheduleReconnection({resumptionToken:i,onresumptiontoken:s,replayMessageId:a},0)}catch(_){(v=this.onerror)===null||v===void 0||v.call(this,new Error(`Failed to reconnect: ${_ instanceof Error?_.message:String(_)}`))}}})()}async start(){if(this._abortController)throw new Error("StreamableHTTPClientTransport already started! If using Client class, note that connect() calls start() automatically.");this._abortController=new AbortController}async finishAuth(e){if(!this._authProvider)throw new dt("No auth provider");if(await lr(this._authProvider,{serverUrl:this._url,authorizationCode:e,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new dt("Failed to authorize")}async close(){var e,r;this._reconnectionTimeout&&(clearTimeout(this._reconnectionTimeout),this._reconnectionTimeout=void 0),(e=this._abortController)===null||e===void 0||e.abort(),(r=this.onclose)===null||r===void 0||r.call(this)}async send(e,r){var n,s,a,i,o,c,l;try{const{resumptionToken:u,onresumptiontoken:d}=r||{};if(u){this._startOrAuthSse({resumptionToken:u,replayMessageId:ja(e)?e.id:void 0}).catch(m=>{var b;return(b=this.onerror)===null||b===void 0?void 0:b.call(this,m)});return}const g=await this._commonHeaders();g.set("content-type","application/json"),g.set("accept","application/json, text/event-stream");const v={...this._requestInit,method:"POST",headers:g,body:JSON.stringify(e),signal:(n=this._abortController)===null||n===void 0?void 0:n.signal},p=await((s=this._fetch)!==null&&s!==void 0?s:fetch)(this._url,v),w=p.headers.get("mcp-session-id");if(w&&(this._sessionId=w),!p.ok){const m=await p.text().catch(()=>null);if(p.status===401&&this._authProvider){if(this._hasCompletedAuthFlow)throw new Cr(401,"Server returned 401 after successful authentication");const{resourceMetadataUrl:b,scope:y}=Bs(p);if(this._resourceMetadataUrl=b,this._scope=y,await lr(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new dt;return this._hasCompletedAuthFlow=!0,this.send(e)}if(p.status===403&&this._authProvider){const{resourceMetadataUrl:b,scope:y,error:k}=Bs(p);if(k==="insufficient_scope"){const S=p.headers.get("WWW-Authenticate");if(this._lastUpscopingHeader===S)throw new Cr(403,"Server returned 403 after trying upscoping");if(y&&(this._scope=y),b&&(this._resourceMetadataUrl=b),this._lastUpscopingHeader=S??void 0,await lr(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetch})!=="AUTHORIZED")throw new dt;return this.send(e)}}throw new Cr(p.status,`Error POSTing to endpoint: ${m}`)}if(this._hasCompletedAuthFlow=!1,this._lastUpscopingHeader=void 0,p.status===202){await((a=p.body)===null||a===void 0?void 0:a.cancel()),y_(e)&&this._startOrAuthSse({resumptionToken:void 0}).catch(m=>{var b;return(b=this.onerror)===null||b===void 0?void 0:b.call(this,m)});return}const _=(Array.isArray(e)?e:[e]).filter(m=>"method"in m&&"id"in m&&m.id!==void 0).length>0,f=p.headers.get("content-type");if(_)if(f?.includes("text/event-stream"))this._handleSseStream(p.body,{onresumptiontoken:d},!1);else if(f?.includes("application/json")){const m=await p.json(),b=Array.isArray(m)?m.map(y=>nr.parse(y)):[nr.parse(m)];for(const y of b)(i=this.onmessage)===null||i===void 0||i.call(this,y)}else throw await((o=p.body)===null||o===void 0?void 0:o.cancel()),new Cr(-1,`Unexpected content type: ${f}`);else await((c=p.body)===null||c===void 0?void 0:c.cancel())}catch(u){throw(l=this.onerror)===null||l===void 0||l.call(this,u),u}}get sessionId(){return this._sessionId}async terminateSession(){var e,r,n,s;if(this._sessionId)try{const a=await this._commonHeaders(),i={...this._requestInit,method:"DELETE",headers:a,signal:(e=this._abortController)===null||e===void 0?void 0:e.signal},o=await((r=this._fetch)!==null&&r!==void 0?r:fetch)(this._url,i);if(await((n=o.body)===null||n===void 0?void 0:n.cancel()),!o.ok&&o.status!==405)throw new Cr(o.status,`Failed to terminate session: ${o.statusText}`);this._sessionId=void 0}catch(a){throw(s=this.onerror)===null||s===void 0||s.call(this,a),a}}setProtocolVersion(e){this._protocolVersion=e}get protocolVersion(){return this._protocolVersion}async resumeStream(e,r){await this._startOrAuthSse({resumptionToken:e,onresumptiontoken:r?.onresumptiontoken})}}const c0="mcp";class Yl{constructor(e){this._url=e}start(){if(this._socket)throw new Error("WebSocketClientTransport already started! If using Client class, note that connect() calls start() automatically.");return new Promise((e,r)=>{this._socket=new WebSocket(this._url,c0),this._socket.onerror=n=>{var s;const a="error"in n?n.error:new Error(`WebSocket error: ${JSON.stringify(n)}`);r(a),(s=this.onerror)===null||s===void 0||s.call(this,a)},this._socket.onopen=()=>{e()},this._socket.onclose=()=>{var n;(n=this.onclose)===null||n===void 0||n.call(this)},this._socket.onmessage=n=>{var s,a;let i;try{i=nr.parse(JSON.parse(n.data))}catch(o){(s=this.onerror)===null||s===void 0||s.call(this,o);return}(a=this.onmessage)===null||a===void 0||a.call(this,i)}})}async close(){var e;(e=this._socket)===null||e===void 0||e.close()}send(e){return new Promise((r,n)=>{var s;if(!this._socket){n(new Error("Not connected"));return}(s=this._socket)===null||s===void 0||s.send(JSON.stringify(e)),r()})}}function Ys(){const t=["224340fQYLJj","function","onmessage","port2","341XVdnBD","313767JEBgqL","950bpstaX","1354759gUhUbE","wRKyh","onclose","2044SvCTUj","endpoint","24msSkHx","164VuWYGY","mOWMr","EkZCC","addEventListener","postMessage","120705iyGzUz","8878392ivIdKn","close","_listen","3619482FaLQHc","start","_endpoint","kgkem","bzNYT","MessageChannel transport error: ","stringify","onmessageerror","HvyCv","undefined","Jwyua","message","_globalObject","parse","authInfo","thraG","220pGvxgp","_port","EGhzU","onerror","data","MhriV"];return Ys=function(){return t},Ys()}(function(t,e){const r=Ne,n=Ne,s=t();for(;;)try{if(parseInt(r(417))/1*(parseInt(r(421))/2)+parseInt(r(433))/3+parseInt(r(424))/4*(-parseInt(n(429))/5)+parseInt(n(423))/6*(-parseInt(n(418))/7)+-parseInt(n(430))/8+-parseInt(r(416))/9*(-parseInt(r(405))/10)+-parseInt(r(415))/11*(-parseInt(r(411))/12)===e)break;s.push(s.shift())}catch{s.push(s.shift())}})(Ys,650197);const Ql=()=>{const t=Ne,e={EGhzU:function(r,n){return r!==n},kIrDB:"undefined",llYQe:function(r,n){return r!==n},PZfJg:function(r,n){return r(n)},Jwyua:"return this"};return typeof globalThis<"u"?globalThis:e[t(407)](typeof window,e.kIrDB)?window:e.llYQe(typeof global,e.kIrDB)?global:typeof self!==t(398)?self:e.PZfJg(Function,e[t(399)])()},u0=(t,e,r)=>{const n=Ne,s=Ne,a={};a[n(410)]=s(398),a.dBkaX=function(o,c){return o===c},a[s(393)]="function";const i=a;typeof window!==i[s(410)]?t.postMessage(e,"*",r):s(428)in t&&i.dBkaX(typeof t.postMessage,i[n(393)])&&t.postMessage(e,r)},l0=(t,e)=>{const r=Ne,n=Ne,s={};s.MbsGh="addEventListener",s.PPniK=function(i,o){return i===o},s[r(419)]=n(412),s[n(404)]="onmessage",s[r(397)]="undefined";const a=s;a.MbsGh in t&&a.PPniK(typeof t[r(427)],a.wRKyh)?t[r(427)](r(400),e):a.thraG in t&&typeof t[n(413)]!==a[n(397)]&&(t.onmessage=e)};class Qs{constructor(e){const r=Ne;this[r(406)]=e}async start(){const e=Ne,r=Ne;this[e(406)]&&(this[e(406)][e(413)]=n=>{var s,a;const i=e,o=r;try{const c=nr[i(402)](n.data[i(400)]);(s=this[i(413)])==null||s.call(this,c,n[o(409)].extra)}catch(c){const l=new Error("MessageChannel failed to parse message: "+c);(a=this[o(408)])==null||a.call(this,l)}},this._port[e(396)]=n=>{var s;const a=r,i=r,o=new Error(a(394)+JSON[i(395)](n));(s=this.onerror)==null||s.call(this,o)},this[e(406)][e(434)]())}async send(e,r){const n={lEyuq:function(s){return s()},YihNw:function(s,a){return s(a)}};return new Promise((s,a)=>{var i;const o=Ne,c=Ne;try{const l={};l[o(403)]=r?.[o(403)];const u={};u[c(400)]=e,u.extra=l,this[c(406)]&&this[o(406)].postMessage(u),n.lEyuq(s)}catch(l){const u=l instanceof Error?l:new Error(n.YihNw(String,l));(i=this[c(408)])==null||i.call(this,u),a(u)}})}async close(){var e,r;const n=Ne,s=Ne;(e=this._port)==null||e[n(431)](),this._port=void 0,(r=this[s(420)])==null||r.call(this)}}class Wi extends Qs{constructor(e,r=Ql()){const n=Ne,s=Ne,a={EkZCC:function(o,c,l,u){return o(c,l,u)}};super(),this[n(391)]=e,this[s(401)]=r;const i=new MessageChannel;this[s(406)]=i.port1,a[s(426)](u0,this[n(401)],{endpoint:this[s(391)]},[i[s(414)]])}}class Ji extends Qs{constructor(e,r=Ql()){const n=Ne,s={mOWMr:function(a,i){return a===i},kgkem:function(a,i,o){return a(i,o)}};super(),this._endpoint=e,this._globalObject=r,this[n(432)]=new Promise(a=>{const i=n,o=n;s[i(392)](l0,this[o(401)],c=>{const l=o,u=o;c.data&&s[l(425)](c.data[u(422)],this[u(391)])&&(this[u(406)]=c.ports[-1*4852+1*1601+3251],a())})})}async listen(){return this[Ne(432)]}}function Ne(t,e){const r=Ys();return Ne=function(n,s){return n=n-(17*-491+-669+9407),r[n]},Ne(t,e)}const d0=()=>{const t=new MessageChannel;return[new Qs(t.port1),new Qs(t.port2)]};(function(t,e){const r=$e,n=$e,s=t();for(;;)try{if(parseInt(r(355))/1+-parseInt(r(356))/2*(-parseInt(r(373))/3)+-parseInt(r(337))/4+parseInt(n(357))/5+-parseInt(n(389))/6*(-parseInt(r(396))/7)+parseInt(n(325))/8*(parseInt(r(382))/9)+-parseInt(r(366))/10===e)break;s.push(s.shift())}catch{s.push(s.shift())}})(Xs,-763475+-52067*10+1724410);const f0=async(t,e,r)=>{var n;const s=$e,a=$e,i={};i[s(345)]="tools/list",i.rqstG="tools/call",i.WqUnk="resources/list",i[s(329)]=a(358),i[s(365)]=s(335),i.ookoz="resources/unsubscribe",i[s(385)]=s(340),i.VTIWq="prompts/list",i.SkoRK=s(376),i.QUtUV=s(388),i.XtowM=a(332);const o=i,{id:c,method:l,params:u}=r;let d={};switch(l){case o[a(345)]:d=await e.listTools(u);break;case o.rqstG:d=await e.callTool(u);break;case o[s(334)]:d=await e[s(350)](u);break;case o[a(329)]:d=await e.listResourceTemplates(u);break;case s(372):d=await e[s(383)](u);break;case o.HgYgW:d=await e.subscribeResource(u);break;case o.ookoz:d=await e.unsubscribeResource(u);break;case o[s(385)]:d=await e.getPrompt(u);break;case o.VTIWq:d=await e.listPrompts(u);break;case o[s(344)]:d=await e[s(376)]();break;case o.QUtUV:d=await e.complete(u);break;case s(390):d=await e[s(336)](u?.level);break}const g={};g[s(361)]=d,g[s(394)]=o[s(364)],g.id=c,await((n=t?.transport)==null?void 0:n[s(392)](g))},h0=async(t,e,r)=>{var n;const s=$e,a=$e,i={};i.jQBBS="sampling/createMessage",i.EZqgC="elicitation/create",i[s(370)]=a(376),i.aVeaL=a(332);const o=i,{id:c,method:l,params:u}=r;let d={};switch(l){case s(368):const v={};v.method=l,v[a(367)]=u,d=await e.request(v,ai);break;case o[a(391)]:const p={};p.method=l,p[a(367)]=u,d=await e[a(381)](p,Is);break;case o.EZqgC:const w={};w.method=l,w.params=u,d=await e.request(w,Gr);break;case o[a(370)]:const h={};h.method=l,d=await e[a(381)](h,Ft);break}const g={};return g[a(361)]=d,g.jsonrpc=o[a(387)],g.id=c,await((n=t?.[s(371)])==null?void 0:n.send(g)),d},p0=(t,e)=>{const r=$e,n={gXsjT:function(a,i){return a===i},oegpC:r(351),lZOUC:function(a,i,o,c){return a(i,o,c)},ifIKG:"2.0"},s=t._onrequest;t._onrequest=async(a,i)=>{var o,c,l,u,d;const g=r,v=r,{id:p,method:w}=a;try{n[g(333)](w,n.oegpC)?await s[g(386)](t,a,i):await n.lZOUC(f0,t,e,a)}catch(h){const{code:_,message:f,data:m}=h;try{if(_){const b={};b.code=_,b.message=f,b.data=m;const y={};y.error=b,y[g(394)]=n[v(331)],y.id=p,await((o=t?.transport)==null?void 0:o.send(y))}else(l=(c=t?.[v(371)])==null?void 0:c.onerror)==null||l.call(c,h)}catch(b){(d=(u=t?.[g(371)])==null?void 0:u.onerror)==null||d.call(u,b)}}}},m0=(t,e)=>{const r=$e,n=$e,s={};s[r(363)]=function(i,o){return i!==o},s[r(398)]=r(353),s.hzhyg="notifications/cancelled";const a=s;t._onnotification=async i=>{var o,c;const l=r,u=n,{method:d,params:g}=i;if(a[l(363)](d,a[u(398)])&&(a[l(363)](d,a.hzhyg)||g?.forward))try{await e.notification(i)}catch(v){(c=(o=t?.transport)==null?void 0:o.onerror)==null||c.call(o,v)}}},_0=(t,e)=>async r=>{var n,s,a,i,o;const c=$e,l=$e,u={};u.SEmWX=c(332);const d=u;try{return await h0(t,e,r)}catch(g){const{code:v,message:p,data:w}=g;try{if(v){const h={};h[l(377)]=v,h.message=p,h.data=w;const _={};_[l(348)]=h,_.jsonrpc=d[c(338)],_.id=r.id,await((n=t?.transport)==null?void 0:n[l(392)](_))}else(a=(s=t?.transport)==null?void 0:s[l(339)])==null||a.call(s,g)}catch(h){(o=(i=t?.[c(371)])==null?void 0:i[l(339)])==null||o.call(i,h)}}},v0=(t,e)=>async r=>{var n,s,a;const i=$e,o=$e,c={};c.dtUgZ=function(g,v){return g!==v},c.jgCIb=i(353),c.uUjKY="2.0";const l=c,{method:u,params:d}=r;if(l.dtUgZ(u,l.jgCIb)&&(u!==i(400)||d?.forward))try{const g={...r};g[i(394)]=l[o(352)],await((n=e?.[i(371)])==null?void 0:n[i(392)](g))}catch(g){(a=(s=t?.[i(371)])==null?void 0:s[o(339)])==null||a.call(s,g)}};function $e(t,e){const r=Xs();return $e=function(n,s){return n=n-(-1017+-1439*-1+-97),r[n]},$e(t,e)}const g0=(t,e)=>async r=>{var n,s,a,i,o,c;const l=$e,u=$e,d={};d[l(401)]=u(332);const g=d;try{await((n=e?.transport)==null?void 0:n.send(r))}catch(v){const{code:p,message:w,data:h}=v;try{if(p){const _={};_.code=p,_[l(399)]=w,_.data=h;const f={};f[l(348)]=_,f[l(394)]=g.OhJjz,f.id=r.id,await((s=t?.[l(371)])==null?void 0:s.send(f))}else(i=(a=t?.transport)==null?void 0:a[u(339)])==null||i.call(a,v)}catch(_){(c=(o=t?.transport)==null?void 0:o.onerror)==null||c.call(o,_)}}},Ki=()=>{const t=$e,e=$e,r={vnkqu:function(l,u){return l!==u},wxDWr:function(l,u){return l(u)},GdkkV:function(l,u){return l===u}},n=[],s=(l,u)=>{const d=$e,g=$e;if(u){const v=[];for(const p of n)try{v.push(p(l,u))}catch{}for(const p of v)if(r[d(379)](p,null))return p}else for(const v of n)try{r[g(343)](v,l)}catch{}},a=l=>{const u=$e;r[u(384)](typeof l,u(369))&&!n.includes(l)&&n.push(l)},i=l=>{const u=n.indexOf(l);u!==-1&&n.splice(u,1*-6854+-264+7119)},o=()=>{const l=$e;n[l(374)]=7102*1+5522+-526*24},c={};return c[t(346)]=s,c[e(330)]=a,c.removeListener=i,c[t(359)]=o,c},y0=t=>{const e=$e,r=$e,n={xwPeb:function(s){return s()},Mfvzm:function(s){return s()}};{const{handleListener:s,addListener:a,removeListener:i,clearListener:o}=n[e(326)](Ki);t._onresponse=s,t[e(395)]=a,t.removeResponseListener=i,t.clearResponseListener=o}{const{handleListener:s,addListener:a,removeListener:i,clearListener:o}=n[r(326)](Ki);t[r(328)]=s,t.addRequestListener=a,t[r(354)]=i,t[r(341)]=o}{const{handleListener:s,addListener:a,removeListener:i,clearListener:o}=n[e(375)](Ki);t[e(342)]=s,t[e(327)]=a,t.removeNotificationListener=i,t.clearNotificationListener=o}};function Xs(){const t=["uUjKY","notifications/initialized","removeRequestListener","96194JysfjF","36346SGEWAV","1357830AJaOeY","resources/templates/list","clearListener","iQqcJ","result","tqDZP","sSeCz","XtowM","HgYgW","3913230mjiatC","params","roots/list","function","bfmJT","transport","resources/read","27FNuDmk","length","Mfvzm","ping","code","_onresponse","vnkqu","cjSoZ","request","9gIMIPC","readResource","GdkkV","ptMjy","call","aVeaL","completion/complete","5035122lFbpzR","logging/setLevel","jQBBS","send","_requestHandlers","jsonrpc","addResponseListener","7SpcenI","ElOQH","MDIkN","message","notifications/cancelled","OhJjz","clear","672216JzFEyR","xwPeb","addNotificationListener","fallbackRequestHandler","sYzPD","addListener","ifIKG","2.0","gXsjT","WqUnk","resources/subscribe","setLoggingLevel","2491772kFUWFh","SEmWX","onerror","prompts/get","clearRequestListener","fallbackNotificationHandler","wxDWr","SkoRK","uTeHc","handleListener","Zybtx","error","originalOnResponse","listResources","initialize"];return Xs=function(){return t},Xs()}const w0=(t,{beforeInit:e,afterInit:r}={})=>{const n=$e,s=$e,a={tqDZP:function(o,c){return o===c},cjSoZ:"function",iQqcJ:n(378),Zybtx:function(o,c){return o(c)},ElOQH:function(o){return o()}},i=new Map(t._notificationHandlers);t[n(393)][n(402)](),t._notificationHandlers[n(402)](),a.tqDZP(typeof e,a[n(380)])&&e(),a[n(362)](t._onresponse.name,a[n(360)])&&(t[s(349)]=t._onresponse),a[n(347)](y0,t),t.addResponseListener(o=>{const c=s;t.originalOnResponse[c(386)](t,o)}),a.tqDZP(typeof r,a[s(380)])&&a[n(397)](r),t[s(327)](o=>{const{method:c}=o,l=i.get(c);a.tqDZP(typeof l,a.cjSoZ)&&l(o)})},b0=Pt,k0=Pt;(function(t,e){const r=Pt,n=Pt,s=t();for(;;)try{if(-parseInt(r(393))/1+parseInt(r(397))/2*(-parseInt(r(400))/3)+-parseInt(n(398))/4+parseInt(r(390))/5*(parseInt(n(388))/6)+-parseInt(r(389))/7+-parseInt(r(402))/8*(-parseInt(n(395))/9)+parseInt(n(399))/10*(parseInt(n(385))/11)===e)break;s.push(s.shift())}catch{s.push(s.shift())}})(ea,-1*-881393+2*180895+1*-644809);function Pt(t,e){const r=ea();return Pt=function(n,s){return n=n-(-1861+-499*4+4241),r[n]},Pt(t,e)}function ea(){const t=["toString","getRandomValues","2101mUsYMI","EQHzo","padStart","30UvDAkd","1609706yzlqYx","974735GrhZVO","randomUUID","REzPF","562771BvAnoG","dHTfU","2047455boiYXf","randomBytes","14664qHAdbF","3772144jLpQch","52310AkWksx","318MkjaVb","from","40WRwnSc"];return ea=function(){return t},ea()}const $0=()=>{const t=Pt,e=Pt,r={};r.REzPF=function(s,a){return s&a},r.suJHI=function(s,a){return s===a},r[t(386)]=function(s,a){return s&a},r[e(394)]="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx";const n=r;return n.suJHI(typeof crypto,"object")&&crypto.randomUUID?crypto[e(391)]():n.dHTfU.replace(/[xy]/g,s=>{const a=t,i=t,o=n[a(392)](crypto[a(384)](new Uint8Array(8663+2*-4331))[741*2+-1385*-2+4252*-1],15);return(n.suJHI(s,"x")?o:n[i(386)](o,-4377+4*1095)|5079+461*-11).toString(9449+4*-461+-7589)})},S0=t=>{const e=Pt,r=Pt,n=new Uint8Array(t);return crypto.getRandomValues(n),Array[e(401)](n,s=>s[r(403)](-3*1739+-6509+2*5871)[e(387)](2,"0")).join("")},Gt={};Gt[b0(391)]=$0,Gt[k0(396)]=S0;const ct=xt;(function(t,e){const r=xt,n=xt,s=t();for(;;)try{if(parseInt(r(521))/1*(parseInt(n(499))/2)+parseInt(n(543))/3*(parseInt(n(514))/4)+parseInt(r(502))/5*(parseInt(n(539))/6)+parseInt(r(553))/7+parseInt(r(516))/8*(-parseInt(r(518))/9)+-parseInt(r(531))/10+-parseInt(r(545))/11*(parseInt(r(541))/12)===e)break;s.push(s.shift())}catch{s.push(s.shift())}})(ta,1472653*1+-2*-897917+-2275789);const T0=(t,e)=>{const r=xt,n=xt,s={FyYHt:function(c,l,u){return c(l,u)},Fxtoq:function(c,l,u){return c(l,u)}};p0(t,e),m0(t,e);const a=_0(e,t),i=s[r(510)](g0,e,t),o=s[n(549)](v0,e,t);e[n(537)](a),e[r(519)](i),e.addNotificationListener(o),t[n(556)]=()=>{const c=n;e.removeRequestListener(a),e[c(530)](i),e[c(529)](o)}},Bi=(t,e,r)=>{const n=xt,s={pMiva:function(o,c){return o instanceof c},TeTEy:n(546),fyZbd:function(o,c,l){return o(c,l)}},a=()=>{var o;const c=n;s.pMiva(r,yn)&&((o=r._eventSource)==null||o.addEventListener(s[c(547)],()=>{var l;const u=c;(l=r[u(509)])==null||l[u(546)]()})),T0(t,e)},i={};i.afterInit=a,s.fyZbd(w0,e,i)},Xl=(t,e=Gt.randomUUID())=>{const r=xt,n=xt,s={OfssH:function(u,d,g){return u(d,g)}},a={};a[r(528)]=e;const i=a,o={};o[r(528)]=e;const c={};c[n(558)]=o,c[r(534)]=r(524);const l={requestInit:c,eventSourceInit:{async fetch(u,d){const g=r,v=n,p=new Headers(d?.[g(558)]||{});Object.entries(i)[v(498)](([h,_])=>{p[v(527)](h,_)});const w={...d};return w[v(558)]=p,s.OfssH(fetch,u,w)},withCredentials:!0}};return t&&(l.requestInit[r(558)].Authorization=r(533)+t,i.Authorization="Bearer "+t),l},ed=(t,e=Gt[ct(517)]())=>{const r=ct,n=ct,s={};s.nwQhY="include";const a=s,i={};i["stream-session-id"]=e;const o={};o.headers=i,o.credentials=a[r(520)];const c={};c[r(544)]=o;const l=c;return t&&(l.requestInit.headers[n(552)]=n(533)+t),l},Gi=async(t,e,r)=>{const n=ct,s=ct,a={CFfFC:function(o){return o()},egwVO:function(o,c,l,u){return o(c,l,u)}},i=a.CFfFC(r);try{return await t[n(538)](i),i}catch(o){if(o instanceof dt){const c=await e();return await i[s(505)](c),await a[n(525)](Gi,t,e,r)}else throw o}};function xt(t,e){const r=ta();return xt=function(n,s){return n=n-498,r[n]},xt(t,e)}const td=(t,e)=>{const r=ct,n=ct,s={};s.RsKXs=function(i,o){return i in o},s.PBhps="waitForOAuthCode",s[r(535)]="function",s[r(507)]="waitForOAuthCode need to be provided when authProvider is provided";const a=s;if(a.RsKXs(a[n(551)],t))return t[n(523)];if(typeof e===a.yTKoP)return e;throw new Error(a.RZhOv)},E0=async t=>{const e=ct,r=ct,n={TFSRn:function(C,q,N){return C(q,N)},HwvVa:"mcp-sse-proxy-client",ufTHS:function(C){return C()},WIVYl:function(C,q,N,V){return C(q,N,V)},jniGY:"sessionId"},{client:s,url:a,token:i,sessionId:o,authProvider:c,requestInit:l,eventSourceInit:u,waitForOAuthCode:d}=t,g={};g.authProvider=c,g.requestInit=l,g.eventSourceInit=u;const v=g,p=o||Gt.randomUUID(),w=n[e(506)](Xl,i,p);if(l){const C={...w.requestInit,...l};C.headers={...w[e(544)].headers,...l.headers},v.requestInit=C}else v[r(544)]=w.requestInit;if(u){const C={...w[e(559)],...u};v.eventSourceInit=C}else v.eventSourceInit=w.eventSourceInit;const h={};h.listChanged=!0;const _={};_.roots=h,_.sampling={},_[e(511)]={};const f=_,m={};m[r(536)]=n.HwvVa,m.version=e(526);const b={};b.capabilities=f;const y=new pn(m,b),k=()=>new yn(new URL(a),v);let S=n[r(504)](k);if(c){const C=n[e(506)](td,c,d);S=await n[r(513)](Gi,y,C,k)}else await y[e(538)](S);n[r(513)](Bi,y,s,S),S[r(557)]=S[r(542)].searchParams[r(532)](n.jniGY);const I={};return I.transport=S,I.sessionId=S[e(557)],I};function ta(){const t=["ufTHS","finishAuth","TFSRn","RZhOv","Vajmx","_eventSource","FyYHt","elicitation","transport","WIVYl","13320uyrBtN","sampling","8WTwLJD","randomUUID","6438654bkJHij","addResponseListener","nwQhY","11721GVgRMJ","?sessionId=","waitForOAuthCode","include","egwVO","1.0.0","set","sse-session-id","removeNotificationListener","removeResponseListener","11838520fNkjrV","get","Bearer ","credentials","yTKoP","name","addRequestListener","connect","18VhCgQv","mcp-socket-proxy-client","2819364JNqkQZ","_endpoint","699JyrxCR","requestInit","44ofbsvb","close","TeTEy","QgzDy","Fxtoq","roots","PBhps","Authorization","11309130xGCFwl","&token=","version","onclose","sessionId","headers","eventSourceInit","forEach","62FcOkCa","mcp-stream-proxy-client","zXcpO","1794855cQEXDT","biJOc"];return ta=function(){return t},ta()}const R0=async t=>{const e=ct,r=ct,n={Vajmx:e(500),biJOc:function(C){return C()},zXcpO:function(C,q,N){return C(q,N)},zDnjZ:function(C,q,N,V){return C(q,N,V)},FQMAh:function(C,q,N,V){return C(q,N,V)}},{client:s,url:a,token:i,sessionId:o,authProvider:c,requestInit:l,reconnectionOptions:u,waitForOAuthCode:d}=t,g={};g.authProvider=c,g.requestInit=l,g.reconnectionOptions=u;const v=g,p=o||Gt.randomUUID(),w=ed(i,p);if(l){const C={...w.requestInit,...l};C.headers={...w.requestInit.headers,...l.headers},v[e(544)]=C}else v.requestInit=w.requestInit;const h={};h.listChanged=!0;const _={};_[r(550)]=h,_.sampling={},_.elicitation={};const f=_,m={};m[e(536)]=n[r(508)],m[e(555)]="1.0.0";const b={};b.capabilities=f;const y=new pn(m,b),k=()=>new Gs(new URL(a),v);let S=n[e(503)](k);if(c){const C=n[e(501)](td,c,d);S=await n.zDnjZ(Gi,y,C,k)}else await y.connect(S);n.FQMAh(Bi,y,s,S);const I={};return I.transport=S,I[r(557)]=S.sessionId,I},P0=async t=>{const e=ct,r=ct,n={QgzDy:e(540),jkaVB:function(_,f,m,b){return _(f,m,b)}},{client:s,url:a,token:i,sessionId:o}=t,c={};c.listChanged=!0;const l={};l[e(550)]=c,l[e(515)]={},l[r(511)]={};const u=l,d={};d.name=n[r(548)],d[r(555)]=r(526);const g={};g.capabilities=u;const v=new pn(d,g),p=o||Gt[r(517)](),w=new Yl(new URL(a+e(522)+p+r(554)+i));await v.connect(w),n.jkaVB(Bi,v,s,w);const h={};return h[e(512)]=w,h[r(557)]=p,h},wn=nt,ra=nt;function nt(t,e){const r=na();return nt=function(n,s){return n=n-(-16761+51*337),r[n]},nt(t,e)}(function(t,e){const r=nt,n=nt,s=t();for(;;)try{if(-parseInt(r(440))/1+-parseInt(r(458))/2*(parseInt(r(448))/3)+-parseInt(r(451))/4*(parseInt(n(449))/5)+-parseInt(n(455))/6+-parseInt(r(427))/7+-parseInt(n(438))/8*(parseInt(n(459))/9)+parseInt(r(430))/10*(parseInt(n(436))/11)===e)break;s.push(s.shift())}catch{s.push(s.shift())}})(na,-220880+1*-333337+-2*-384996);function na(){const t=["650XPHLhD","redirectToAuthorization","10856jPvMVb","GET","qcFPW","_redirectUrl","2187414WnlGuZ","resolve","tokens","3976YyOqUl","27ejNHsa","Content-Type","waitForOAuthCode","2903796yvWZFa","_clientMetadata","application/x-www-form-urlencoded","10beEWJk","json","code","_callBackPromise","reject","saveClientInformation","20776349mLNCcF","_codeVerifier","629912aTknXq","_tokens","52074GwcpRo","state","_state","_redirectCallback","_clientInformation","redirect_uris","Failed to redirect: ","clientInformation","381aduWsB"];return na=function(){return t},na()}const x0=()=>Gt.randomBytes(3485*1+-261+-3184);class I0{constructor(e){const r=nt,n=nt;this._callBackPromise={};const{clientMetadata:s,state:a,redirectCallback:i,getAuthCodeByState:o,waitForOAuthCode:c}=e;this[r(428)]=s,this[r(454)]=s[r(445)][0],this._state=a||x0(),this._redirectCallback=i||this.redirectCallbackFunction,this._getAuthCodeByState=o||this.getAuthCodeByStateFunction,this[n(426)]=c||this.waitForOAuthCodeFunction()}async redirectCallbackFunction(e){var r,n,s,a,i,o;const c=nt,l=nt,u={qITTp:function(p,w,h){return p(w,h)},qcFPW:c(452)},d=await u.qITTp(fetch,e,{method:u[c(453)]});!d.ok&&((n=(r=this._callBackPromise).reject)==null||n.call(r,l(446)+d.statusText));const g=await this._getAuthCodeByState(this[l(454)],this[c(442)]);if(!g.ok){(a=(s=this[c(433)]).reject)==null||a.call(s,"Failed to fetch auth code: "+g.statusText);return}const v=await g[c(431)]();(o=(i=this[l(433)])[c(456)])==null||o.call(i,v[c(432)])}async getAuthCodeByStateFunction(e,r){const n=nt,s=nt,a={};a.tuSmb=n(429);const i=a,o={};o[n(460)]=i.tuSmb;const c={};return c[s(441)]=r,fetch(e,{method:"POST",headers:o,body:new URLSearchParams(c)})}waitForOAuthCodeFunction(){const e=nt,r=this[e(433)];return()=>new Promise((n,s)=>{const a=e;r.resolve=n,r[a(434)]=s})}get redirectUrl(){return this[nt(454)]}get clientMetadata(){return this._clientMetadata}state(){return this._state}[wn(447)](){return this[wn(444)]}[ra(435)](e){const r=wn;this[r(444)]=e}[ra(457)](){return this[ra(439)]}saveTokens(e){this._tokens=e}[ra(450)](e){this[wn(443)](e)}saveCodeVerifier(e){this._codeVerifier=e}codeVerifier(){if(!this[wn(437)])throw new Error("No code verifier saved");return this._codeVerifier}}(function(t,e){for(var r=aa,n=aa,s=t();;)try{var a=parseInt(r(361))/1*(parseInt(n(363))/2)+-parseInt(r(358))/3+parseInt(r(359))/4*(parseInt(r(357))/5)+parseInt(n(354))/6*(parseInt(r(360))/7)+parseInt(n(362))/8+parseInt(n(364))/9+-parseInt(n(356))/10*(parseInt(r(355))/11);if(a===e)break;s.push(s.shift())}catch{s.push(s.shift())}})(sa,-73523*-3+1*-407717+530518);function sa(){var t=["40ecBYYe","1095owKKYD","486870YOVwZy","5752xWiyTO","561484biNVMw","1fWJmxQ","1866064SPnyhb","1109522vMiuMX","1602351pPEGwH","12sVyMLL","2573296LTwOhv"];return sa=function(){return t},sa()}function aa(t,e){var r=sa();return aa=function(n,s){n=n-(-1*-642+503*-5+2227);var a=r[n];return a},aa(t,e)}class C0{constructor(e){this._server=e}requestStream(e,r,n){return this._server.requestStream(e,r,n)}async getTask(e,r){return this._server.getTask({taskId:e},r)}async getTaskResult(e,r,n){return this._server.getTaskResult({taskId:e},r,n)}async listTasks(e,r){return this._server.listTasks(e?{cursor:e}:void 0,r)}async cancelTask(e,r){return this._server.cancelTask({taskId:e},r)}}class O0 extends Il{constructor(e,r){var n,s;super(r),this._serverInfo=e,this._loggingLevels=new Map,this.LOG_LEVEL_SEVERITY=new Map(Rs.options.map((a,i)=>[a,i])),this.isMessageIgnored=(a,i)=>{const o=this._loggingLevels.get(i);return o?this.LOG_LEVEL_SEVERITY.get(a)<this.LOG_LEVEL_SEVERITY.get(o):!1},this._capabilities=(n=r?.capabilities)!==null&&n!==void 0?n:{},this._instructions=r?.instructions,this._jsonSchemaValidator=(s=r?.jsonSchemaValidator)!==null&&s!==void 0?s:new zl,this.setRequestHandler(Nu,a=>this._oninitialize(a)),this.setNotificationHandler(Ma,()=>{var a;return(a=this.oninitialized)===null||a===void 0?void 0:a.call(this)}),this._capabilities.logging&&this.setRequestHandler(Ps,async(a,i)=>{var o;const c=i.sessionId||((o=i.requestInfo)===null||o===void 0?void 0:o.headers["mcp-session-id"])||void 0,{level:l}=a.params,u=Rs.safeParse(l);return u.success&&this._loggingLevels.set(c,u.data),{}})}get experimental(){return this._experimental||(this._experimental={tasks:new C0(this)}),this._experimental}registerCapabilities(e){if(this.transport)throw new Error("Cannot register capabilities after connecting to transport");this._capabilities=Ol(this._capabilities,e)}setRequestHandler(e,r){var n,s,a;const i=Sr(e),o=i?.method;if(!o)throw new Error("Schema is missing a method literal");let c;if(lt(o)){const u=o,d=(n=u._zod)===null||n===void 0?void 0:n.def;c=(s=d?.value)!==null&&s!==void 0?s:u.value}else{const u=o,d=u._def;c=(a=d?.value)!==null&&a!==void 0?a:u.value}if(typeof c!="string")throw new Error("Schema method literal must be a string");if(c==="tools/call"){const u=async(d,g)=>{const v=gt(Es,d);if(!v.success){const _=v.error instanceof Error?v.error.message:String(v.error);throw new J(G.InvalidParams,`Invalid tools/call request: ${_}`)}const{params:p}=v.data,w=await Promise.resolve(r(d,g));if(p.task){const _=gt(mr,w);if(!_.success){const f=_.error instanceof Error?_.error.message:String(_.error);throw new J(G.InvalidParams,`Invalid task creation result: ${f}`)}return _.data}const h=gt(vr,w);if(!h.success){const _=h.error instanceof Error?h.error.message:String(h.error);throw new J(G.InvalidParams,`Invalid tools/call result: ${_}`)}return h.data};return super.setRequestHandler(e,u)}return super.setRequestHandler(e,r)}assertCapabilityForMethod(e){var r,n,s;switch(e){case"sampling/createMessage":if(!(!((r=this._clientCapabilities)===null||r===void 0)&&r.sampling))throw new Error(`Client does not support sampling (required for ${e})`);break;case"elicitation/create":if(!(!((n=this._clientCapabilities)===null||n===void 0)&&n.elicitation))throw new Error(`Client does not support elicitation (required for ${e})`);break;case"roots/list":if(!(!((s=this._clientCapabilities)===null||s===void 0)&&s.roots))throw new Error(`Client does not support listing roots (required for ${e})`);break}}assertNotificationCapability(e){var r,n;switch(e){case"notifications/message":if(!this._capabilities.logging)throw new Error(`Server does not support logging (required for ${e})`);break;case"notifications/resources/updated":case"notifications/resources/list_changed":if(!this._capabilities.resources)throw new Error(`Server does not support notifying about resources (required for ${e})`);break;case"notifications/tools/list_changed":if(!this._capabilities.tools)throw new Error(`Server does not support notifying of tool list changes (required for ${e})`);break;case"notifications/prompts/list_changed":if(!this._capabilities.prompts)throw new Error(`Server does not support notifying of prompt list changes (required for ${e})`);break;case"notifications/elicitation/complete":if(!(!((n=(r=this._clientCapabilities)===null||r===void 0?void 0:r.elicitation)===null||n===void 0)&&n.url))throw new Error(`Client does not support URL elicitation (required for ${e})`);break}}assertRequestHandlerCapability(e){if(this._capabilities)switch(e){case"completion/complete":if(!this._capabilities.completions)throw new Error(`Server does not support completions (required for ${e})`);break;case"logging/setLevel":if(!this._capabilities.logging)throw new Error(`Server does not support logging (required for ${e})`);break;case"prompts/get":case"prompts/list":if(!this._capabilities.prompts)throw new Error(`Server does not support prompts (required for ${e})`);break;case"resources/list":case"resources/templates/list":case"resources/read":if(!this._capabilities.resources)throw new Error(`Server does not support resources (required for ${e})`);break;case"tools/call":case"tools/list":if(!this._capabilities.tools)throw new Error(`Server does not support tools (required for ${e})`);break;case"tasks/get":case"tasks/list":case"tasks/result":case"tasks/cancel":if(!this._capabilities.tasks)throw new Error(`Server does not support tasks capability (required for ${e})`);break}}assertTaskCapability(e){var r,n;ql((n=(r=this._clientCapabilities)===null||r===void 0?void 0:r.tasks)===null||n===void 0?void 0:n.requests,e,"Client")}assertTaskHandlerCapability(e){var r;this._capabilities&&Ml((r=this._capabilities.tasks)===null||r===void 0?void 0:r.requests,e,"Server")}async _oninitialize(e){const r=e.params.protocolVersion;return this._clientCapabilities=e.params.capabilities,this._clientVersion=e.params.clientInfo,{protocolVersion:Tu.includes(r)?r:Fr,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"},Ft)}async createMessage(e,r){var n,s;if((e.tools||e.toolChoice)&&!(!((s=(n=this._clientCapabilities)===null||n===void 0?void 0:n.sampling)===null||s===void 0)&&s.tools))throw new Error("Client does not support sampling tools capability.");if(e.messages.length>0){const a=e.messages[e.messages.length-1],i=Array.isArray(a.content)?a.content:[a.content],o=i.some(d=>d.type==="tool_result"),c=e.messages.length>1?e.messages[e.messages.length-2]:void 0,l=c?Array.isArray(c.content)?c.content:[c.content]:[],u=l.some(d=>d.type==="tool_use");if(o){if(i.some(d=>d.type!=="tool_result"))throw new Error("The last message must contain only tool_result content if any is present");if(!u)throw new Error("tool_result blocks are not matching any tool_use from the previous message")}if(u){const d=new Set(l.filter(v=>v.type==="tool_use").map(v=>v.id)),g=new Set(i.filter(v=>v.type==="tool_result").map(v=>v.toolUseId));if(d.size!==g.size||![...d].every(v=>g.has(v)))throw new Error("ids of tool_result blocks and tool_use blocks from previous message do not match")}}return e.tools?this.request({method:"sampling/createMessage",params:e},Xu,r):this.request({method:"sampling/createMessage",params:e},Is,r)}async elicitInput(e,r){var n,s,a,i,o;switch((n=e.mode)!==null&&n!==void 0?n:"form"){case"url":{if(!(!((a=(s=this._clientCapabilities)===null||s===void 0?void 0:s.elicitation)===null||a===void 0)&&a.url))throw new Error("Client does not support url elicitation.");const l=e;return this.request({method:"elicitation/create",params:l},Gr,r)}case"form":{if(!(!((o=(i=this._clientCapabilities)===null||i===void 0?void 0:i.elicitation)===null||o===void 0)&&o.form))throw new Error("Client does not support form elicitation.");const l=e.mode==="form"?e:{...e,mode:"form"},u=await this.request({method:"elicitation/create",params:l},Gr,r);if(u.action==="accept"&&u.content&&l.requestedSchema)try{const g=this._jsonSchemaValidator.getValidator(l.requestedSchema)(u.content);if(!g.valid)throw new J(G.InvalidParams,`Elicitation response content does not match requested schema: ${g.errorMessage}`)}catch(d){throw d instanceof J?d:new J(G.InternalError,`Error validating elicitation response: ${d instanceof Error?d.message:String(d)}`)}return u}}}createElicitationCompletionNotifier(e,r){var n,s;if(!(!((s=(n=this._clientCapabilities)===null||n===void 0?void 0:n.elicitation)===null||s===void 0)&&s.url))throw new Error("Client does not support URL elicitation (required for notifications/elicitation/complete)");return()=>this.notification({method:"notifications/elicitation/complete",params:{elicitationId:e}},r)}async listRoots(e,r){return this.request({method:"roots/list",params:e},ai,r)}async sendLoggingMessage(e,r){if(this._capabilities.logging&&!this.isMessageIgnored(e.level,r))return this.notification({method:"notifications/message",params:e})}async sendResourceUpdated(e){return this.notification({method:"notifications/resources/updated",params:e})}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"})}}const Yi=Symbol.for("mcp.completable");function N0(t,e){return Object.defineProperty(t,Yi,{value:{complete:e},enumerable:!1,writable:!1,configurable:!1}),t}function A0(t){return!!t&&typeof t=="object"&&Yi in t}function j0(t){const e=t[Yi];return e?.complete}var rd;(function(t){t.Completable="McpCompletable"})(rd||(rd={}));const nd=1e6,Qi=1e6,sd=1e4,z0=1e6;class qt{static isTemplate(e){return/\{[^}\s]+\}/.test(e)}static validateLength(e,r,n){if(e.length>r)throw new Error(`${n} exceeds maximum length of ${r} characters (got ${e.length})`)}get variableNames(){return this.parts.flatMap(e=>typeof e=="string"?[]:e.names)}constructor(e){qt.validateLength(e,nd,"Template"),this.template=e,this.parts=this.parse(e)}toString(){return this.template}parse(e){const r=[];let n="",s=0,a=0;for(;s<e.length;)if(e[s]==="{"){n&&(r.push(n),n="");const i=e.indexOf("}",s);if(i===-1)throw new Error("Unclosed template expression");if(a++,a>sd)throw new Error(`Template contains too many expressions (max ${sd})`);const o=e.slice(s+1,i),c=this.getOperator(o),l=o.includes("*"),u=this.getNames(o),d=u[0];for(const g of u)qt.validateLength(g,Qi,"Variable name");r.push({name:d,operator:c,names:u,exploded:l}),s=i+1}else n+=e[s],s++;return n&&r.push(n),r}getOperator(e){return["+","#",".","/","?","&"].find(n=>e.startsWith(n))||""}getNames(e){const r=this.getOperator(e);return e.slice(r.length).split(",").map(n=>n.replace("*","").trim()).filter(n=>n.length>0)}encodeValue(e,r){return qt.validateLength(e,Qi,"Variable value"),r==="+"||r==="#"?encodeURI(e):encodeURIComponent(e)}expandPart(e,r){if(e.operator==="?"||e.operator==="&"){const i=e.names.map(c=>{const l=r[c];if(l===void 0)return"";const u=Array.isArray(l)?l.map(d=>this.encodeValue(d,e.operator)).join(","):this.encodeValue(l.toString(),e.operator);return`${c}=${u}`}).filter(c=>c.length>0);return i.length===0?"":(e.operator==="?"?"?":"&")+i.join("&")}if(e.names.length>1){const i=e.names.map(o=>r[o]).filter(o=>o!==void 0);return i.length===0?"":i.map(o=>Array.isArray(o)?o[0]:o).join(",")}const n=r[e.name];if(n===void 0)return"";const a=(Array.isArray(n)?n:[n]).map(i=>this.encodeValue(i,e.operator));switch(e.operator){case"":return a.join(",");case"+":return a.join(",");case"#":return"#"+a.join(",");case".":return"."+a.join(".");case"/":return"/"+a.join("/");default:return a.join(",")}}expand(e){let r="",n=!1;for(const s of this.parts){if(typeof s=="string"){r+=s;continue}const a=this.expandPart(s,e);a&&((s.operator==="?"||s.operator==="&")&&n?r+=a.replace("?","&"):r+=a,(s.operator==="?"||s.operator==="&")&&(n=!0))}return r}escapeRegExp(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}partToRegExp(e){const r=[];for(const a of e.names)qt.validateLength(a,Qi,"Variable name");if(e.operator==="?"||e.operator==="&"){for(let a=0;a<e.names.length;a++){const i=e.names[a],o=a===0?"\\"+e.operator:"&";r.push({pattern:o+this.escapeRegExp(i)+"=([^&]+)",name:i})}return r}let n;const s=e.name;switch(e.operator){case"":n=e.exploded?"([^/]+(?:,[^/]+)*)":"([^/,]+)";break;case"+":case"#":n="(.+)";break;case".":n="\\.([^/,]+)";break;case"/":n="/"+(e.exploded?"([^/]+(?:,[^/]+)*)":"([^/,]+)");break;default:n="([^/]+)"}return r.push({pattern:n,name:s}),r}match(e){qt.validateLength(e,nd,"URI");let r="^";const n=[];for(const o of this.parts)if(typeof o=="string")r+=this.escapeRegExp(o);else{const c=this.partToRegExp(o);for(const{pattern:l,name:u}of c)r+=l,n.push({name:u,exploded:o.exploded})}r+="$",qt.validateLength(r,z0,"Generated regex pattern");const s=new RegExp(r),a=e.match(s);if(!a)return null;const i={};for(let o=0;o<n.length;o++){const{name:c,exploded:l}=n[o],u=a[o+1],d=c.replace("*","");l&&u.includes(",")?i[d]=u.split(","):i[d]=u}return i}}const M0=/^[A-Za-z0-9._-]{1,128}$/;function q0(t){const e=[];if(t.length===0)return{isValid:!1,warnings:["Tool name cannot be empty"]};if(t.length>128)return{isValid:!1,warnings:[`Tool name exceeds maximum length of 128 characters (current: ${t.length})`]};if(t.includes(" ")&&e.push("Tool name contains spaces, which may cause parsing issues"),t.includes(",")&&e.push("Tool name contains commas, which may cause parsing issues"),(t.startsWith("-")||t.endsWith("-"))&&e.push("Tool name starts or ends with a dash, which may cause parsing issues in some contexts"),(t.startsWith(".")||t.endsWith("."))&&e.push("Tool name starts or ends with a dot, which may cause parsing issues in some contexts"),!M0.test(t)){const r=t.split("").filter(n=>!/[A-Za-z0-9._-]/.test(n)).filter((n,s,a)=>a.indexOf(n)===s);return e.push(`Tool name contains invalid characters: ${r.map(n=>`"${n}"`).join(", ")}`,"Allowed characters are: A-Z, a-z, 0-9, underscore (_), dash (-), and dot (.)"),{isValid:!1,warnings:e}}return{isValid:!0,warnings:e}}function Z0(t,e){if(e.length>0){console.warn(`Tool name validation warning for "${t}":`);for(const r of e)console.warn(` - ${r}`);console.warn("Tool registration will proceed, but this may cause compatibility issues."),console.warn("Consider updating the tool name to conform to the MCP tool naming standard."),console.warn("See SEP: Specify Format for Tool Names (https://github.com/modelcontextprotocol/modelcontextprotocol/issues/986) for more details.")}}function ad(t){const e=q0(t);return Z0(t,e.warnings),e.isValid}class L0{constructor(e){this._mcpServer=e}registerToolTask(e,r,n){const s={taskSupport:"required",...r.execution};if(s.taskSupport==="forbidden")throw new Error(`Cannot register task-based tool '${e}' with taskSupport 'forbidden'. Use registerTool() instead.`);return this._mcpServer._createRegisteredTool(e,r.title,r.description,r.inputSchema,r.outputSchema,r.annotations,s,r._meta,n)}}class id{constructor(e,r){this._registeredResources={},this._registeredResourceTemplates={},this._registeredTools={},this._registeredPrompts={},this._toolHandlersInitialized=!1,this._completionHandlerInitialized=!1,this._resourceHandlersInitialized=!1,this._promptHandlersInitialized=!1,this.server=new O0(e,r)}get experimental(){return this._experimental||(this._experimental={tasks:new L0(this)}),this._experimental}async connect(e){return await this.server.connect(e)}async close(){await this.server.close()}setToolRequestHandlers(){this._toolHandlersInitialized||(this.server.assertCanSetRequestHandler(Yt(ti)),this.server.assertCanSetRequestHandler(Yt(Es)),this.server.registerCapabilities({tools:{listChanged:!0}}),this.server.setRequestHandler(ti,()=>({tools:Object.entries(this._registeredTools).filter(([,e])=>e.enabled).map(([e,r])=>{const n={name:e,title:r.title,description:r.description,inputSchema:(()=>{const s=hn(r.inputSchema);return s?Rl(s,{strictUnions:!0,pipeStrategy:"input"}):D0})(),annotations:r.annotations,execution:r.execution,_meta:r._meta};if(r.outputSchema){const s=hn(r.outputSchema);s&&(n.outputSchema=Rl(s,{strictUnions:!0,pipeStrategy:"output"}))}return n})})),this.server.setRequestHandler(Es,async(e,r)=>{var n;try{const s=this._registeredTools[e.params.name];if(!s)throw new J(G.InvalidParams,`Tool ${e.params.name} not found`);if(!s.enabled)throw new J(G.InvalidParams,`Tool ${e.params.name} disabled`);const a=!!e.params.task,i=(n=s.execution)===null||n===void 0?void 0:n.taskSupport,o="createTask"in s.handler;if((i==="required"||i==="optional")&&!o)throw new J(G.InternalError,`Tool ${e.params.name} has taskSupport '${i}' but was not registered with registerToolTask`);if(i==="required"&&!a)throw new J(G.MethodNotFound,`Tool ${e.params.name} requires task augmentation (taskSupport: 'required')`);if(i==="optional"&&!a&&o)return await this.handleAutomaticTaskPolling(s,e,r);const c=await this.validateToolInput(s,e.params.arguments,e.params.name),l=await this.executeToolHandler(s,c,r);return a||await this.validateToolOutput(s,l,e.params.name),l}catch(s){if(s instanceof J&&s.code===G.UrlElicitationRequired)throw s;return this.createToolError(s instanceof Error?s.message:String(s))}}),this._toolHandlersInitialized=!0)}createToolError(e){return{content:[{type:"text",text:e}],isError:!0}}async validateToolInput(e,r,n){if(!e.inputSchema)return;const s=hn(e.inputSchema),a=s??e.inputSchema,i=await fi(a,r);if(!i.success){const o="error"in i?i.error:"Unknown error",c=hi(o);throw new J(G.InvalidParams,`Input validation error: Invalid arguments for tool ${n}: ${c}`)}return i.data}async validateToolOutput(e,r,n){if(!e.outputSchema||!("content"in r)||r.isError)return;if(!r.structuredContent)throw new J(G.InvalidParams,`Output validation error: Tool ${n} has an output schema but no structured content was provided`);const s=hn(e.outputSchema),a=await fi(s,r.structuredContent);if(!a.success){const i="error"in a?a.error:"Unknown error",o=hi(i);throw new J(G.InvalidParams,`Output validation error: Invalid structured content for tool ${n}: ${o}`)}}async executeToolHandler(e,r,n){const s=e.handler;if("createTask"in s){if(!n.taskStore)throw new Error("No task store provided.");const i={...n,taskStore:n.taskStore};if(e.inputSchema){const o=s;return await Promise.resolve(o.createTask(r,i))}else{const o=s;return await Promise.resolve(o.createTask(i))}}if(e.inputSchema){const i=s;return await Promise.resolve(i(r,n))}else{const i=s;return await Promise.resolve(i(n))}}async handleAutomaticTaskPolling(e,r,n){var s;if(!n.taskStore)throw new Error("No task store provided for task-capable tool.");const a=await this.validateToolInput(e,r.params.arguments,r.params.name),i=e.handler,o={...n,taskStore:n.taskStore},c=a?await Promise.resolve(i.createTask(a,o)):await Promise.resolve(i.createTask(o)),l=c.task.taskId;let u=c.task;const d=(s=u.pollInterval)!==null&&s!==void 0?s:5e3;for(;u.status!=="completed"&&u.status!=="failed"&&u.status!=="cancelled";){await new Promise(v=>setTimeout(v,d));const g=await n.taskStore.getTask(l);if(!g)throw new J(G.InternalError,`Task ${l} not found during polling`);u=g}return await n.taskStore.getTaskResult(l)}setCompletionRequestHandler(){this._completionHandlerInitialized||(this.server.assertCanSetRequestHandler(Yt(si)),this.server.registerCapabilities({completions:{}}),this.server.setRequestHandler(si,async e=>{switch(e.params.ref.type){case"ref/prompt":return _v(e),this.handlePromptCompletion(e,e.params.ref);case"ref/resource":return vv(e),this.handleResourceCompletion(e,e.params.ref);default:throw new J(G.InvalidParams,`Invalid completion reference: ${e.params.ref}`)}}),this._completionHandlerInitialized=!0)}async handlePromptCompletion(e,r){const n=this._registeredPrompts[r.name];if(!n)throw new J(G.InvalidParams,`Prompt ${r.name} not found`);if(!n.enabled)throw new J(G.InvalidParams,`Prompt ${r.name} disabled`);if(!n.argsSchema)return bn;const s=Sr(n.argsSchema),a=s?.[e.params.argument.name];if(!A0(a))return bn;const i=j0(a);if(!i)return bn;const o=await i(e.params.argument.value,e.params.context);return ud(o)}async handleResourceCompletion(e,r){const n=Object.values(this._registeredResourceTemplates).find(i=>i.resourceTemplate.uriTemplate.toString()===r.uri);if(!n){if(this._registeredResources[r.uri])return bn;throw new J(G.InvalidParams,`Resource template ${e.params.ref.uri} not found`)}const s=n.resourceTemplate.completeCallback(e.params.argument.name);if(!s)return bn;const a=await s(e.params.argument.value,e.params.context);return ud(a)}setResourceRequestHandlers(){this._resourceHandlersInitialized||(this.server.assertCanSetRequestHandler(Yt(Ts)),this.server.assertCanSetRequestHandler(Yt(Wa)),this.server.assertCanSetRequestHandler(Yt(Ka)),this.server.registerCapabilities({resources:{listChanged:!0}}),this.server.setRequestHandler(Ts,async(e,r)=>{const n=Object.entries(this._registeredResources).filter(([a,i])=>i.enabled).map(([a,i])=>({uri:a,name:i.name,...i.metadata})),s=[];for(const a of Object.values(this._registeredResourceTemplates)){if(!a.resourceTemplate.listCallback)continue;const i=await a.resourceTemplate.listCallback(r);for(const o of i.resources)s.push({...a.metadata,...o})}return{resources:[...n,...s]}}),this.server.setRequestHandler(Wa,async()=>({resourceTemplates:Object.entries(this._registeredResourceTemplates).map(([r,n])=>({name:r,uriTemplate:n.resourceTemplate.uriTemplate.toString(),...n.metadata}))})),this.server.setRequestHandler(Ka,async(e,r)=>{const n=new URL(e.params.uri),s=this._registeredResources[n.toString()];if(s){if(!s.enabled)throw new J(G.InvalidParams,`Resource ${n} disabled`);return s.readCallback(n,r)}for(const a of Object.values(this._registeredResourceTemplates)){const i=a.resourceTemplate.uriTemplate.match(n.toString());if(i)return a.readCallback(n,i,r)}throw new J(G.InvalidParams,`Resource ${n} not found`)}),this.setCompletionRequestHandler(),this._resourceHandlersInitialized=!0)}setPromptRequestHandlers(){this._promptHandlersInitialized||(this.server.assertCanSetRequestHandler(Yt(Ba)),this.server.assertCanSetRequestHandler(Yt(Ga)),this.server.registerCapabilities({prompts:{listChanged:!0}}),this.server.setRequestHandler(Ba,()=>({prompts:Object.entries(this._registeredPrompts).filter(([,e])=>e.enabled).map(([e,r])=>({name:e,title:r.title,description:r.description,arguments:r.argsSchema?F0(r.argsSchema):void 0}))})),this.server.setRequestHandler(Ga,async(e,r)=>{const n=this._registeredPrompts[e.params.name];if(!n)throw new J(G.InvalidParams,`Prompt ${e.params.name} not found`);if(!n.enabled)throw new J(G.InvalidParams,`Prompt ${e.params.name} disabled`);if(n.argsSchema){const s=hn(n.argsSchema),a=await fi(s,e.params.arguments);if(!a.success){const c="error"in a?a.error:"Unknown error",l=hi(c);throw new J(G.InvalidParams,`Invalid arguments for prompt ${e.params.name}: ${l}`)}const i=a.data,o=n.callback;return await Promise.resolve(o(i,r))}else{const s=n.callback;return await Promise.resolve(s(r))}}),this.setCompletionRequestHandler(),this._promptHandlersInitialized=!0)}resource(e,r,...n){let s;typeof n[0]=="object"&&(s=n.shift());const a=n[0];if(typeof r=="string"){if(this._registeredResources[r])throw new Error(`Resource ${r} is already registered`);const i=this._createRegisteredResource(e,void 0,r,s,a);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),i}else{if(this._registeredResourceTemplates[e])throw new Error(`Resource template ${e} is already registered`);const i=this._createRegisteredResourceTemplate(e,void 0,r,s,a);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),i}}registerResource(e,r,n,s){if(typeof r=="string"){if(this._registeredResources[r])throw new Error(`Resource ${r} is already registered`);const a=this._createRegisteredResource(e,n.title,r,n,s);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),a}else{if(this._registeredResourceTemplates[e])throw new Error(`Resource template ${e} is already registered`);const a=this._createRegisteredResourceTemplate(e,n.title,r,n,s);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),a}}_createRegisteredResource(e,r,n,s,a){const i={name:e,title:r,metadata:s,readCallback:a,enabled:!0,disable:()=>i.update({enabled:!1}),enable:()=>i.update({enabled:!0}),remove:()=>i.update({uri:null}),update:o=>{typeof o.uri<"u"&&o.uri!==n&&(delete this._registeredResources[n],o.uri&&(this._registeredResources[o.uri]=i)),typeof o.name<"u"&&(i.name=o.name),typeof o.title<"u"&&(i.title=o.title),typeof o.metadata<"u"&&(i.metadata=o.metadata),typeof o.callback<"u"&&(i.readCallback=o.callback),typeof o.enabled<"u"&&(i.enabled=o.enabled),this.sendResourceListChanged()}};return this._registeredResources[n]=i,i}_createRegisteredResourceTemplate(e,r,n,s,a){const i={resourceTemplate:n,title:r,metadata:s,readCallback:a,enabled:!0,disable:()=>i.update({enabled:!1}),enable:()=>i.update({enabled:!0}),remove:()=>i.update({name:null}),update:o=>{typeof o.name<"u"&&o.name!==e&&(delete this._registeredResourceTemplates[e],o.name&&(this._registeredResourceTemplates[o.name]=i)),typeof o.title<"u"&&(i.title=o.title),typeof o.template<"u"&&(i.resourceTemplate=o.template),typeof o.metadata<"u"&&(i.metadata=o.metadata),typeof o.callback<"u"&&(i.readCallback=o.callback),typeof o.enabled<"u"&&(i.enabled=o.enabled),this.sendResourceListChanged()}};return this._registeredResourceTemplates[e]=i,i}_createRegisteredPrompt(e,r,n,s,a){const i={title:r,description:n,argsSchema:s===void 0?void 0:fn(s),callback:a,enabled:!0,disable:()=>i.update({enabled:!1}),enable:()=>i.update({enabled:!0}),remove:()=>i.update({name:null}),update:o=>{typeof o.name<"u"&&o.name!==e&&(delete this._registeredPrompts[e],o.name&&(this._registeredPrompts[o.name]=i)),typeof o.title<"u"&&(i.title=o.title),typeof o.description<"u"&&(i.description=o.description),typeof o.argsSchema<"u"&&(i.argsSchema=fn(o.argsSchema)),typeof o.callback<"u"&&(i.callback=o.callback),typeof o.enabled<"u"&&(i.enabled=o.enabled),this.sendPromptListChanged()}};return this._registeredPrompts[e]=i,i}_createRegisteredTool(e,r,n,s,a,i,o,c,l){ad(e);const u={title:r,description:n,inputSchema:cd(s),outputSchema:cd(a),annotations:i,execution:o,_meta:c,handler:l,enabled:!0,disable:()=>u.update({enabled:!1}),enable:()=>u.update({enabled:!0}),remove:()=>u.update({name:null}),update:d=>{typeof d.name<"u"&&d.name!==e&&(typeof d.name=="string"&&ad(d.name),delete this._registeredTools[e],d.name&&(this._registeredTools[d.name]=u)),typeof d.title<"u"&&(u.title=d.title),typeof d.description<"u"&&(u.description=d.description),typeof d.paramsSchema<"u"&&(u.inputSchema=fn(d.paramsSchema)),typeof d.callback<"u"&&(u.handler=d.callback),typeof d.annotations<"u"&&(u.annotations=d.annotations),typeof d._meta<"u"&&(u._meta=d._meta),typeof d.enabled<"u"&&(u.enabled=d.enabled),this.sendToolListChanged()}};return this._registeredTools[e]=u,this.setToolRequestHandlers(),this.sendToolListChanged(),u}tool(e,...r){if(this._registeredTools[e])throw new Error(`Tool ${e} is already registered`);let n,s,a,i;if(typeof r[0]=="string"&&(n=r.shift()),r.length>1){const c=r[0];Xi(c)?(s=r.shift(),r.length>1&&typeof r[0]=="object"&&r[0]!==null&&!Xi(r[0])&&(i=r.shift())):typeof c=="object"&&c!==null&&(i=r.shift())}const o=r[0];return this._createRegisteredTool(e,void 0,n,s,a,i,{taskSupport:"forbidden"},void 0,o)}registerTool(e,r,n){if(this._registeredTools[e])throw new Error(`Tool ${e} is already registered`);const{title:s,description:a,inputSchema:i,outputSchema:o,annotations:c,_meta:l}=r;return this._createRegisteredTool(e,s,a,i,o,c,{taskSupport:"forbidden"},l,n)}prompt(e,...r){if(this._registeredPrompts[e])throw new Error(`Prompt ${e} is already registered`);let n;typeof r[0]=="string"&&(n=r.shift());let s;r.length>1&&(s=r.shift());const a=r[0],i=this._createRegisteredPrompt(e,void 0,n,s,a);return this.setPromptRequestHandlers(),this.sendPromptListChanged(),i}registerPrompt(e,r,n){if(this._registeredPrompts[e])throw new Error(`Prompt ${e} is already registered`);const{title:s,description:a,argsSchema:i}=r,o=this._createRegisteredPrompt(e,s,a,i,n);return this.setPromptRequestHandlers(),this.sendPromptListChanged(),o}isConnected(){return this.server.transport!==void 0}async sendLoggingMessage(e,r){return this.server.sendLoggingMessage(e,r)}sendResourceListChanged(){this.isConnected()&&this.server.sendResourceListChanged()}sendToolListChanged(){this.isConnected()&&this.server.sendToolListChanged()}sendPromptListChanged(){this.isConnected()&&this.server.sendPromptListChanged()}}class U0{constructor(e,r){this._callbacks=r,this._uriTemplate=typeof e=="string"?new qt(e):e}get uriTemplate(){return this._uriTemplate}get listCallback(){return this._callbacks.list}completeCallback(e){var r;return(r=this._callbacks.complete)===null||r===void 0?void 0:r[e]}}const D0={type:"object",properties:{}};function od(t){return t!==null&&typeof t=="object"&&"parse"in t&&typeof t.parse=="function"&&"safeParse"in t&&typeof t.safeParse=="function"}function V0(t){return"_def"in t||"_zod"in t||od(t)}function Xi(t){return typeof t!="object"||t===null||V0(t)?!1:Object.keys(t).length===0?!0:Object.values(t).some(od)}function cd(t){if(t)return Xi(t)?fn(t):t}function F0(t){const e=Sr(t);return e?Object.entries(e).map(([r,n])=>{const s=Tg(n),a=Eg(n);return{name:r,description:s,required:!a}}):[]}function Yt(t){const e=Sr(t),r=e?.method;if(!r)throw new Error("Schema is missing a method literal");const n=vl(r);if(typeof n=="string")return n;throw new Error("Schema method literal must be a string")}function ud(t){return{completion:{values:t.slice(0,100),total:t.length,hasMore:t.length>100}}}const bn={completion:{values:[],hasMore:!1}};class H0{constructor(e,r){const n={name:"web-mcp-server",version:"1.0.0"},s={prompts:{listChanged:!0},resources:{subscribe:!0,listChanged:!0},tools:{listChanged:!0},completions:{},logging:{}};this.server=new id(e||n,r||{capabilities:s}),this.server.server.oninitialized=()=>{this.oninitialized?.()},this.server.server.onclose=()=>{this.onclose?.()},this.server.server.onerror=a=>{this.onerror?.(a)},this.server.server.setRequestHandler(Ps,async()=>({}))}async connect(e){return typeof e.start=="function"?(this.transport=e,this.transport.onclose=void 0,this.transport.onerror=void 0,this.transport.onmessage=void 0):(this.transport=new Ji(e),await this.transport.listen()),await this.server.connect(this.transport),this.transport}async close(){await this.server.close()}registerTool(e,r,n){return this.server.registerTool(e,r,n)}registerPrompt(e,r,n){return this.server.registerPrompt(e,r,n)}registerResource(e,r,n,s){return typeof r=="string"?this.server.registerResource(e,r,n,s):this.server.registerResource(e,r,n,s)}isConnected(){return this.server.isConnected()}sendResourceListChanged(){this.server.sendResourceListChanged()}sendToolListChanged(){this.server.sendToolListChanged()}sendPromptListChanged(){this.server.sendPromptListChanged()}getClientCapabilities(){return this.server.server.getClientCapabilities()}getClientVersion(){return this.server.server.getClientVersion()}async ping(){return await this.server.server.ping()}async createMessage(e,r){return await this.server.server.createMessage(e,r)}async elicitInput(e,r){return await this.server.server.elicitInput(e,r)}async listRoots(e,r){return await this.server.server.listRoots(e,r)}async sendLoggingMessage(e){return await this.server.server.sendLoggingMessage(e)}async sendResourceUpdated(e){return await this.server.server.sendResourceUpdated(e)}request(e,r,n){return this.server.server.request(e,r,n)}async notification(e,r){return await this.server.server.notification(e,r)}setRequestHandler(e,r){this.server.server.setRequestHandler(e,r)}removeRequestHandler(e){this.server.server.removeRequestHandler(e)}setNotificationHandler(e,r){this.server.server.setNotificationHandler(e,r)}removeNotificationHandler(e){this.server.server.removeNotificationHandler(e)}onSubscribe(e){this.server.server.setRequestHandler(Vu,e)}onUnsubscribe(e){this.server.server.setRequestHandler(Fu,e)}onSetLogLevel(e){this.server.server.setRequestHandler(Ps,e)}onListResources(e){this.server.server.setRequestHandler(Ts,e)}onRootsListChanged(e){this.server.server.setNotificationHandler(rl,e)}async onPagehide(e){e.persisted||this.transport&&typeof this.transport.close=="function"&&await this.transport.close()}}const W0=(t,e)=>new Ji(t,e),J0=()=>d0(),K0=t=>t instanceof Ji,B0=t=>t instanceof id;class G0{constructor(e,r){const n={name:"web-mcp-client",version:"1.0.0"},s={roots:{listChanged:!0},sampling:{},elicitation:{}};this.client=new pn(e||n,r||{capabilities:s}),this.client.onclose=()=>{this.onclose?.()},this.client.onerror=a=>{this.onerror?.(a)}}async connect(e){if(typeof e.start=="function")return this.transport=e,this.transport.onclose=void 0,this.transport.onerror=void 0,this.transport.onmessage=void 0,await this.client.connect(this.transport),{transport:this.transport,sessionId:this.transport.sessionId};const{url:r,token:n,sessionId:s,type:a,agent:i,onError:o}=e;if(i===!0){const u={client:this.client,url:r,token:n,sessionId:s};let d;return await(async()=>{const{transport:v,sessionId:p}=a==="sse"?await E0(u):a==="socket"?await P0(u):await R0(u);v.onerror=async w=>{o?.(w)},d={transport:v,sessionId:p}})(),d}const c=new URL(r);let l;if(a==="channel"&&(l=new Wi(r),await this.client.connect(l)),a==="sse"){const u=Xl(n,s);l=new yn(c,u),await this.client.connect(l)}if(a==="socket"&&(l=new Yl(new URL(`${r}?sessionId=${s}&token=${n}`)),l.sessionId=s,await this.client.connect(l)),typeof l>"u"){const u=ed(n,s);l=new Gs(c,u),await this.client.connect(l)}return this.transport=l,{transport:this.transport,sessionId:this.transport.sessionId}}async close(){await this.client.close()}getServerCapabilities(){return this.client.getServerCapabilities()}getServerVersion(){return this.client.getServerVersion()}getInstructions(){return this.client.getInstructions()}async ping(e){return await this.client.ping(e)}async complete(e,r){return await this.client.complete(e,r)}async setLoggingLevel(e,r){return await this.client.setLoggingLevel(e,r)}async getPrompt(e,r){return await this.client.getPrompt(e,r)}async listPrompts(e,r){return await this.client.listPrompts(e,r)}async listResources(e,r){return await this.client.listResources(e,r)}async listResourceTemplates(e,r){return await this.client.listResourceTemplates(e,r)}async readResource(e,r){return await this.client.readResource(e,r)}async subscribeResource(e,r){return await this.client.subscribeResource(e,r)}async unsubscribeResource(e,r){return await this.client.unsubscribeResource(e,r)}async callTool(e,r){return await this.client.callTool(e,vr,r)}async listTools(e,r){return await this.client.listTools(e,r)}async sendRootsListChanged(){return await this.client.sendRootsListChanged()}request(e,r,n){return this.client.request(e,r,n)}async notification(e,r){return await this.client.notification(e,r)}setRequestHandler(e,r){this.client.setRequestHandler(e,r)}removeRequestHandler(e){this.client.removeRequestHandler(e)}setNotificationHandler(e,r){this.client.setNotificationHandler(e,r)}removeNotificationHandler(e){this.client.removeNotificationHandler(e)}onElicit(e){this.client.setRequestHandler(ni,e)}onCreateMessage(e){this.client.setRequestHandler(ri,e)}onListRoots(e){this.client.setRequestHandler(tl,e)}onToolListChanged(e){this.client.setNotificationHandler(Yu,e)}onPromptListChanged(e){this.client.setNotificationHandler(Ku,e)}onResourceListChanged(e){this.client.setNotificationHandler(Du,e)}onResourceUpdated(e){this.client.setNotificationHandler(Hu,e)}onLoggingMessage(e){this.client.setNotificationHandler(Qu,e)}async onPagehide(e){e.persisted||(ld(this.transport)?await this.transport.terminateSession():this.transport&&typeof this.transport.close=="function"&&await this.transport.close())}}const Y0=(t,e)=>new yn(t,e),Q0=(t,e)=>new Gs(t,e),X0=(t,e)=>new Wi(t,e),ew=t=>t instanceof yn,ld=t=>t instanceof Gs,tw=t=>t instanceof Wi,rw=t=>t instanceof pn;function nw(t){var e;return t.title!==void 0&&t.title!==""?t.title:"annotations"in t&&(!((e=t.annotations)===null||e===void 0)&&e.title)?t.annotations.title:t.name}const sw=()=>typeof crypto<"u"&&crypto.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,t=>{const e=Math.random()*16|0;return(t==="x"?e:e&3|8).toString(16)}),ia=(t,e,r)=>{window.postMessage({type:t,direction:r,data:e},"*")},dd=(t,e,r)=>{const n=async function(s){s.source===window&&s.data.type===t&&s.data.direction===r&&await e(s.data.data)};return window.addEventListener("message",n),()=>window.removeEventListener("message",n)};class aw{constructor(e=null){this._isStarted=!1,this._isClosed=!1,this._lastRegistration=null,this.sessionId=e||sw(),this._messageListener1=dd("sidepanel-ready-to-page",()=>{this._lastRegistration&&this._isStarted&&this.notifyRegistration(this._lastRegistration).catch(r=>{console.error("【Page Svr Transport】 notifyRegistration失败:",r)})},"content->page"),this._messageListener2=dd("mcp-client-to-server-to-page",r=>{if(r.sessionId!==this.sessionId)return;console.log("【Page Svr Transport】 即将处理 mcpMessage",r.mcpMessage);const n=nr.parse(r.mcpMessage);this.onmessage?.(n),r.mcpMessage.params?.name&&ia("update-page-app-message",{status:"run",message:r.mcpMessage.params?.name},"page->content")},"content->page")}_throwError(e,r){if(e()){const n=new Error(r);throw console.log(r,n),this.onerror&&this.onerror(n),n}}async start(){if(!this._isStarted){if(this._isClosed)throw new Error("【Page Svr Transport】 已关闭,无法重新启动");this._isStarted=!0}}async send(e,r){this._throwError(()=>!this._isStarted,"【Page Svr Transport】 未启动,无法发送消息"),this._throwError(()=>this._isClosed,"【Page Svr Transport】 已关闭,无法发送消息"),ia("mcp-server-to-client-from-page",{sessionId:this.sessionId,mcpMessage:e},"page->content"),"result"in e&&e.result?.content&&ia("update-page-app-message",{status:"ready",message:""},"page->content")}async notifyRegistration(e){this._throwError(()=>!this._isStarted,"【Page Svr Transport】 未启动,无法注册消息"),this._lastRegistration=e;try{ia("mcp-server-register-from-page",{sessionId:this.sessionId,serverInfo:{...e,url:window.location.origin,title:document.title}},"page->content")}catch(r){this._throwError(()=>!0,"【Page Svr Transport】 注册 server 失败"+String(r))}}async close(){if(!this._isClosed)try{this._messageListener1&&this._messageListener1(),this._messageListener2&&this._messageListener2(),this._isClosed=!0,this._isStarted=!1,this.onclose&&this.onclose()}catch(e){this._throwError(()=>!0,"【Page Svr Transport】 关闭时发生错误"+String(e))}}}Se.Ajv=of,Se.AuthClientProvider=I0,Se.ExtensionPageServerTransport=aw,Se.ResourceTemplate=U0,Se.UriTemplate=qt,Se.WebMcpClient=G0,Se.WebMcpServer=H0,Se.completable=N0,Se.createMessageChannelClientTransport=X0,Se.createMessageChannelPairTransport=J0,Se.createMessageChannelServerTransport=W0,Se.createSSEClientTransport=Y0,Se.createStreamableHTTPClientTransport=Q0,Se.getDisplayName=nw,Se.isMcpClient=rw,Se.isMcpServer=B0,Se.isMessageChannelClientTransport=tw,Se.isMessageChannelServerTransport=K0,Se.isSSEClientTransport=ew,Se.isStreamableHTTPClientTransport=ld,Se.z=kg,Object.defineProperty(Se,Symbol.toStringTag,{value:"Module"})}));
|
|
39
|
+
]`;continue}s+=n[c],n[c]==="\\"?o=!0:i&&n[c]==="]"?i=!1:!i&&n[c]==="["&&(i=!0)}try{new RegExp(s)}catch{return console.warn(`Could not convert regex pattern at ${e.currentPath.join("/")} to a flag-independent form! Falling back to the flag-ignorant source`),t.source}return s}function Md(t,e){if(e.target==="openAi"&&console.warn("Warning: OpenAI may not support records in schemas! Try an array of key-value pairs instead."),e.target==="openApi3"&&t.keyType?._def.typeName===D.ZodEnum)return{type:"object",required:t.keyType._def.values,properties:t.keyType._def.values.reduce((n,s)=>({...n,[s]:$e(t.valueType._def,{...e,currentPath:[...e.currentPath,"properties",s]})??st(e)}),{}),additionalProperties:e.rejectedAdditionalProperties};const r={type:"object",additionalProperties:$e(t.valueType._def,{...e,currentPath:[...e.currentPath,"additionalProperties"]})??e.allowedAdditionalProperties};if(e.target==="openApi3")return r;if(t.keyType?._def.typeName===D.ZodString&&t.keyType._def.checks?.length){const{type:n,...s}=Nd(t.keyType._def,e);return{...r,propertyNames:s}}else{if(t.keyType?._def.typeName===D.ZodEnum)return{...r,propertyNames:{enum:t.keyType._def.values}};if(t.keyType?._def.typeName===D.ZodBranded&&t.keyType._def.type._def.typeName===D.ZodString&&t.keyType._def.type._def.checks?.length){const{type:n,...s}=Cd(t.keyType._def,e);return{...r,propertyNames:s}}}return r}function aw(t,e){if(e.mapStrategy==="record")return Md(t,e);const r=$e(t.keyType._def,{...e,currentPath:[...e.currentPath,"items","items","0"]})||st(e),n=$e(t.valueType._def,{...e,currentPath:[...e.currentPath,"items","items","1"]})||st(e);return{type:"array",maxItems:125,items:{type:"array",items:[r,n],minItems:2,maxItems:2}}}function cw(t){const e=t.values,n=Object.keys(t.values).filter(o=>typeof e[e[o]]!="number").map(o=>e[o]),s=Array.from(new Set(n.map(o=>typeof o)));return{type:s.length===1?s[0]==="string"?"string":"number":["string","number"],enum:n}}function uw(t){return t.target==="openAi"?void 0:{not:st({...t,currentPath:[...t.currentPath,"not"]})}}function lw(t){return t.target==="openApi3"?{enum:["null"],nullable:!0}:{type:"null"}}const so={ZodString:"string",ZodNumber:"number",ZodBigInt:"integer",ZodBoolean:"boolean",ZodNull:"null"};function dw(t,e){if(e.target==="openApi3")return jd(t,e);const r=t.options instanceof Map?Array.from(t.options.values()):t.options;if(r.every(n=>n._def.typeName in so&&(!n._def.checks||!n._def.checks.length))){const n=r.reduce((s,o)=>{const i=so[o._def.typeName];return i&&!s.includes(i)?[...s,i]:s},[]);return{type:n.length>1?n:n[0]}}else if(r.every(n=>n._def.typeName==="ZodLiteral"&&!n.description)){const n=r.reduce((s,o)=>{const i=typeof o._def.value;switch(i){case"string":case"number":case"boolean":return[...s,i];case"bigint":return[...s,"integer"];case"object":if(o._def.value===null)return[...s,"null"];case"symbol":case"undefined":case"function":default:return s}},[]);if(n.length===r.length){const s=n.filter((o,i,a)=>a.indexOf(o)===i);return{type:s.length>1?s:s[0],enum:r.reduce((o,i)=>o.includes(i._def.value)?o:[...o,i._def.value],[])}}}else if(r.every(n=>n._def.typeName==="ZodEnum"))return{type:"string",enum:r.reduce((n,s)=>[...n,...s._def.values.filter(o=>!n.includes(o))],[])};return jd(t,e)}const jd=(t,e)=>{const r=(t.options instanceof Map?Array.from(t.options.values()):t.options).map((n,s)=>$e(n._def,{...e,currentPath:[...e.currentPath,"anyOf",`${s}`]})).filter(n=>!!n&&(!e.strictUnions||typeof n=="object"&&Object.keys(n).length>0));return r.length?{anyOf:r}:void 0};function hw(t,e){if(["ZodString","ZodNumber","ZodBigInt","ZodBoolean","ZodNull"].includes(t.innerType._def.typeName)&&(!t.innerType._def.checks||!t.innerType._def.checks.length))return e.target==="openApi3"?{type:so[t.innerType._def.typeName],nullable:!0}:{type:[so[t.innerType._def.typeName],"null"]};if(e.target==="openApi3"){const n=$e(t.innerType._def,{...e,currentPath:[...e.currentPath]});return n&&"$ref"in n?{allOf:[n],nullable:!0}:n&&{...n,nullable:!0}}const r=$e(t.innerType._def,{...e,currentPath:[...e.currentPath,"anyOf","0"]});return r&&{anyOf:[r,{type:"null"}]}}function fw(t,e){const r={type:"number"};if(!t.checks)return r;for(const n of t.checks)switch(n.kind){case"int":r.type="integer",xd(r,"type",n.message,e);break;case"min":e.target==="jsonSchema7"?n.inclusive?Re(r,"minimum",n.value,n.message,e):Re(r,"exclusiveMinimum",n.value,n.message,e):(n.inclusive||(r.exclusiveMinimum=!0),Re(r,"minimum",n.value,n.message,e));break;case"max":e.target==="jsonSchema7"?n.inclusive?Re(r,"maximum",n.value,n.message,e):Re(r,"exclusiveMaximum",n.value,n.message,e):(n.inclusive||(r.exclusiveMaximum=!0),Re(r,"maximum",n.value,n.message,e));break;case"multipleOf":Re(r,"multipleOf",n.value,n.message,e);break}return r}function pw(t,e){const r=e.target==="openAi",n={type:"object",properties:{}},s=[],o=t.shape();for(const a in o){let c=o[a];if(c===void 0||c._def===void 0)continue;let u=_w(c);u&&r&&(c._def.typeName==="ZodOptional"&&(c=c._def.innerType),c.isNullable()||(c=c.nullable()),u=!1);const l=$e(c._def,{...e,currentPath:[...e.currentPath,"properties",a],propertyPath:[...e.currentPath,"properties",a]});l!==void 0&&(n.properties[a]=l,u||s.push(a))}s.length&&(n.required=s);const i=mw(t,e);return i!==void 0&&(n.additionalProperties=i),n}function mw(t,e){if(t.catchall._def.typeName!=="ZodNever")return $e(t.catchall._def,{...e,currentPath:[...e.currentPath,"additionalProperties"]});switch(t.unknownKeys){case"passthrough":return e.allowedAdditionalProperties;case"strict":return e.rejectedAdditionalProperties;case"strip":return e.removeAdditionalStrategy==="strict"?e.allowedAdditionalProperties:e.rejectedAdditionalProperties}}function _w(t){try{return t.isOptional()}catch{return!0}}const gw=(t,e)=>{if(e.currentPath.toString()===e.propertyPath?.toString())return $e(t.innerType._def,e);const r=$e(t.innerType._def,{...e,currentPath:[...e.currentPath,"anyOf","1"]});return r?{anyOf:[{not:st(e)},r]}:st(e)},vw=(t,e)=>{if(e.pipeStrategy==="input")return $e(t.in._def,e);if(e.pipeStrategy==="output")return $e(t.out._def,e);const r=$e(t.in._def,{...e,currentPath:[...e.currentPath,"allOf","0"]}),n=$e(t.out._def,{...e,currentPath:[...e.currentPath,"allOf",r?"1":"0"]});return{allOf:[r,n].filter(s=>s!==void 0)}};function yw(t,e){return $e(t.type._def,e)}function ww(t,e){const n={type:"array",uniqueItems:!0,items:$e(t.valueType._def,{...e,currentPath:[...e.currentPath,"items"]})};return t.minSize&&Re(n,"minItems",t.minSize.value,t.minSize.message,e),t.maxSize&&Re(n,"maxItems",t.maxSize.value,t.maxSize.message,e),n}function bw(t,e){return t.rest?{type:"array",minItems:t.items.length,items:t.items.map((r,n)=>$e(r._def,{...e,currentPath:[...e.currentPath,"items",`${n}`]})).reduce((r,n)=>n===void 0?r:[...r,n],[]),additionalItems:$e(t.rest._def,{...e,currentPath:[...e.currentPath,"additionalItems"]})}:{type:"array",minItems:t.items.length,maxItems:t.items.length,items:t.items.map((r,n)=>$e(r._def,{...e,currentPath:[...e.currentPath,"items",`${n}`]})).reduce((r,n)=>n===void 0?r:[...r,n],[])}}function $w(t){return{not:st(t)}}function Sw(t){return st(t)}const kw=(t,e)=>$e(t.innerType._def,e),Tw=(t,e,r)=>{switch(e){case D.ZodString:return Nd(t,r);case D.ZodNumber:return fw(t,r);case D.ZodObject:return pw(t,r);case D.ZodBigInt:return K0(t,r);case D.ZodBoolean:return G0();case D.ZodDate:return Od(t,r);case D.ZodUndefined:return $w(r);case D.ZodNull:return lw(r);case D.ZodArray:return B0(t,r);case D.ZodUnion:case D.ZodDiscriminatedUnion:return dw(t,r);case D.ZodIntersection:return nw(t,r);case D.ZodTuple:return bw(t,r);case D.ZodRecord:return Md(t,r);case D.ZodLiteral:return sw(t,r);case D.ZodEnum:return tw(t);case D.ZodNativeEnum:return cw(t);case D.ZodNullable:return hw(t,r);case D.ZodOptional:return gw(t,r);case D.ZodMap:return aw(t,r);case D.ZodSet:return ww(t,r);case D.ZodLazy:return()=>t.getter()._def;case D.ZodPromise:return yw(t,r);case D.ZodNaN:case D.ZodNever:return uw(r);case D.ZodEffects:return ew(t,r);case D.ZodAny:return st(r);case D.ZodUnknown:return Sw(r);case D.ZodDefault:return X0(t,r);case D.ZodBranded:return Cd(t,r);case D.ZodReadonly:return kw(t,r);case D.ZodCatch:return Y0(t,r);case D.ZodPipeline:return vw(t,r);case D.ZodFunction:case D.ZodVoid:case D.ZodSymbol:return;default:return(n=>{})()}};function $e(t,e,r=!1){const n=e.seen.get(t);if(e.override){const a=e.override?.(t,e,n,r);if(a!==F0)return a}if(n&&!r){const a=Rw(n,e);if(a!==void 0)return a}const s={def:t,path:e.currentPath,jsonSchema:void 0};e.seen.set(t,s);const o=Tw(t,t.typeName,e),i=typeof o=="function"?$e(o(),e):o;if(i&&Ew(t,e,i),e.postProcess){const a=e.postProcess(i,t,e);return s.jsonSchema=i,a}return s.jsonSchema=i,i}const Rw=(t,e)=>{switch(e.$refStrategy){case"root":return{$ref:t.path.join("/")};case"relative":return{$ref:Id(e.currentPath,t.path)};case"none":case"seen":return t.path.length<e.currentPath.length&&t.path.every((r,n)=>e.currentPath[n]===r)?(console.warn(`Recursive reference detected at ${e.currentPath.join("/")}! Defaulting to any`),st(e)):e.$refStrategy==="seen"?st(e):void 0}},Ew=(t,e,r)=>(t.description&&(r.description=t.description,e.markdownDescription&&(r.markdownDescription=t.description)),r),Pw=(t,e)=>{const r=J0(e);let n=typeof e=="object"&&e.definitions?Object.entries(e.definitions).reduce((c,[u,l])=>({...c,[u]:$e(l._def,{...r,currentPath:[...r.basePath,r.definitionPath,u]},!0)??st(r)}),{}):void 0;const s=typeof e=="string"?e:e?.nameStrategy==="title"?void 0:e?.name,o=$e(t._def,s===void 0?r:{...r,currentPath:[...r.basePath,r.definitionPath,s]},!1)??st(r),i=typeof e=="object"&&e.name!==void 0&&e.nameStrategy==="title"?e.name:void 0;i!==void 0&&(o.title=i),r.flags.hasReferencedOpenAiAnyType&&(n||(n={}),n[r.openAiAnyTypeName]||(n[r.openAiAnyTypeName]={type:["string","number","integer","boolean","array","null"],items:{$ref:r.$refStrategy==="relative"?"1":[...r.basePath,r.definitionPath,r.openAiAnyTypeName].join("/")}}));const a=s===void 0?n?{...o,[r.definitionPath]:n}:o:{$ref:[...r.$refStrategy==="relative"?[]:r.basePath,r.definitionPath,s].join("/"),[r.definitionPath]:{...n,[s]:o}};return r.target==="jsonSchema7"?a.$schema="http://json-schema.org/draft-07/schema#":(r.target==="jsonSchema2019-09"||r.target==="openAi")&&(a.$schema="https://json-schema.org/draft/2019-09/schema#"),r.target==="openAi"&&("anyOf"in a||"oneOf"in a||"allOf"in a||"type"in a&&Array.isArray(a.type))&&console.warn("Warning: OpenAI may not support schemas with unions as roots! Try wrapping it in an object property."),a};function qd(t){const r=Ed(t)?.method;if(!r)throw new Error("Schema is missing a method literal");const n=H0(r);if(typeof n!="string")throw new Error("Schema method literal must be a string");return n}function zd(t,e){const r=nr(t,e);if(!r.success)throw r.error;return r.data}const xw=6e4;let Iw=class{constructor(e){this._options=e,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(yi,r=>{this._oncancel(r)}),this.setNotificationHandler(bi,r=>{this._onprogress(r)}),this.setRequestHandler(wi,r=>({})),this._taskStore=e?.taskStore,this._taskMessageQueue=e?.taskMessageQueue,this._taskStore&&(this.setRequestHandler($i,async(r,n)=>{const s=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!s)throw new ie(ue.InvalidParams,"Failed to retrieve task: Task not found");return{...s}}),this.setRequestHandler(ki,async(r,n)=>{const s=async()=>{const o=r.params.taskId;if(this._taskMessageQueue){let a;for(;a=await this._taskMessageQueue.dequeue(o,n.sessionId);){if(a.type==="response"||a.type==="error"){const c=a.message,u=c.id,l=this._requestResolvers.get(u);if(l)if(this._requestResolvers.delete(u),a.type==="response")l(c);else{const d=c,p=new ie(d.error.code,d.error.message,d.error.data);l(p)}else{const d=a.type==="response"?"Response":"Error";this._onerror(new Error(`${d} handler missing for request ${u}`))}continue}await this._transport?.send(a.message,{relatedRequestId:n.requestId})}}const i=await this._taskStore.getTask(o,n.sessionId);if(!i)throw new ie(ue.InvalidParams,`Task not found: ${o}`);if(!yr(i.status))return await this._waitForTaskUpdate(o,n.signal),await s();if(yr(i.status)){const a=await this._taskStore.getTaskResult(o,n.sessionId);return this._clearTaskQueue(o),{...a,_meta:{...a._meta,[fr]:{taskId:o}}}}return await s()};return await s()}),this.setRequestHandler(Ti,async(r,n)=>{try{const{tasks:s,nextCursor:o}=await this._taskStore.listTasks(r.params?.cursor,n.sessionId);return{tasks:s,nextCursor:o,_meta:{}}}catch(s){throw new ie(ue.InvalidParams,`Failed to list tasks: ${s instanceof Error?s.message:String(s)}`)}}),this.setRequestHandler(Ei,async(r,n)=>{try{const s=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!s)throw new ie(ue.InvalidParams,`Task not found: ${r.params.taskId}`);if(yr(s.status))throw new ie(ue.InvalidParams,`Cannot cancel task in terminal status: ${s.status}`);await this._taskStore.updateTaskStatus(r.params.taskId,"cancelled","Client cancelled task execution.",n.sessionId),this._clearTaskQueue(r.params.taskId);const o=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!o)throw new ie(ue.InvalidParams,`Task not found after cancellation: ${r.params.taskId}`);return{_meta:{},...o}}catch(s){throw s instanceof ie?s:new ie(ue.InvalidRequest,`Failed to cancel task: ${s instanceof Error?s.message:String(s)}`)}}))}async _oncancel(e){if(!e.params.requestId)return;this._requestHandlerAbortControllers.get(e.params.requestId)?.abort(e.params.reason)}_setupTimeout(e,r,n,s,o=!1){this._timeoutInfo.set(e,{timeoutId:setTimeout(s,r),startTime:Date.now(),timeout:r,maxTotalTimeout:n,resetTimeoutOnProgress:o,onTimeout:s})}_resetTimeout(e){const r=this._timeoutInfo.get(e);if(!r)return!1;const n=Date.now()-r.startTime;if(r.maxTotalTimeout&&n>=r.maxTotalTimeout)throw this._timeoutInfo.delete(e),ie.fromError(ue.RequestTimeout,"Maximum total timeout exceeded",{maxTotalTimeout:r.maxTotalTimeout,totalElapsed:n});return clearTimeout(r.timeoutId),r.timeoutId=setTimeout(r.onTimeout,r.timeout),!0}_cleanupTimeout(e){const r=this._timeoutInfo.get(e);r&&(clearTimeout(r.timeoutId),this._timeoutInfo.delete(e))}async connect(e){this._transport=e;const r=this.transport?.onclose;this._transport.onclose=()=>{r?.(),this._onclose()};const n=this.transport?.onerror;this._transport.onerror=o=>{n?.(o),this._onerror(o)};const s=this._transport?.onmessage;this._transport.onmessage=(o,i)=>{s?.(o,i),cn(o)||hv(o)?this._onresponse(o):_i(o)?this._onrequest(o,i):dv(o)?this._onnotification(o):this._onerror(new Error(`Unknown message type: ${JSON.stringify(o)}`))},await this._transport.start()}_onclose(){const e=this._responseHandlers;this._responseHandlers=new Map,this._progressHandlers.clear(),this._taskProgressTokens.clear(),this._pendingDebouncedNotifications.clear();const r=ie.fromError(ue.ConnectionClosed,"Connection closed");this._transport=void 0,this.onclose?.();for(const n of e.values())n(r)}_onerror(e){this.onerror?.(e)}_onnotification(e){const r=this._notificationHandlers.get(e.method)??this.fallbackNotificationHandler;r!==void 0&&Promise.resolve().then(()=>r(e)).catch(n=>this._onerror(new Error(`Uncaught error in notification handler: ${n}`)))}_onrequest(e,r){const n=this._requestHandlers.get(e.method)??this.fallbackRequestHandler,s=this._transport,o=e.params?._meta?.[fr]?.taskId;if(n===void 0){const l={jsonrpc:"2.0",id:e.id,error:{code:ue.MethodNotFound,message:"Method not found"}};o&&this._taskMessageQueue?this._enqueueTaskMessage(o,{type:"error",message:l,timestamp:Date.now()},s?.sessionId).catch(d=>this._onerror(new Error(`Failed to enqueue error response: ${d}`))):s?.send(l).catch(d=>this._onerror(new Error(`Failed to send an error response: ${d}`)));return}const i=new AbortController;this._requestHandlerAbortControllers.set(e.id,i);const a=lv(e.params)?e.params.task:void 0,c=this._taskStore?this.requestTaskStore(e,s?.sessionId):void 0,u={signal:i.signal,sessionId:s?.sessionId,_meta:e.params?._meta,sendNotification:async l=>{const d={relatedRequestId:e.id};o&&(d.relatedTask={taskId:o}),await this.notification(l,d)},sendRequest:async(l,d,p)=>{const _={...p,relatedRequestId:e.id};o&&!_.relatedTask&&(_.relatedTask={taskId:o});const m=_.relatedTask?.taskId??o;return m&&c&&await c.updateTaskStatus(m,"input_required"),await this.request(l,d,_)},authInfo:r?.authInfo,requestId:e.id,requestInfo:r?.requestInfo,taskId:o,taskStore:c,taskRequestedTtl:a?.ttl,closeSSEStream:r?.closeSSEStream,closeStandaloneSSEStream:r?.closeStandaloneSSEStream};Promise.resolve().then(()=>{a&&this.assertTaskHandlerCapability(e.method)}).then(()=>n(e,u)).then(async l=>{if(i.signal.aborted)return;const d={result:l,jsonrpc:"2.0",id:e.id};o&&this._taskMessageQueue?await this._enqueueTaskMessage(o,{type:"response",message:d,timestamp:Date.now()},s?.sessionId):await s?.send(d)},async l=>{if(i.signal.aborted)return;const d={jsonrpc:"2.0",id:e.id,error:{code:Number.isSafeInteger(l.code)?l.code:ue.InternalError,message:l.message??"Internal error",...l.data!==void 0&&{data:l.data}}};o&&this._taskMessageQueue?await this._enqueueTaskMessage(o,{type:"error",message:d,timestamp:Date.now()},s?.sessionId):await s?.send(d)}).catch(l=>this._onerror(new Error(`Failed to send response: ${l}`))).finally(()=>{this._requestHandlerAbortControllers.delete(e.id)})}_onprogress(e){const{progressToken:r,...n}=e.params,s=Number(r),o=this._progressHandlers.get(s);if(!o){this._onerror(new Error(`Received a progress notification for an unknown token: ${JSON.stringify(e)}`));return}const i=this._responseHandlers.get(s),a=this._timeoutInfo.get(s);if(a&&i&&a.resetTimeoutOnProgress)try{this._resetTimeout(s)}catch(c){this._responseHandlers.delete(s),this._progressHandlers.delete(s),this._cleanupTimeout(s),i(c);return}o(n)}_onresponse(e){const r=Number(e.id),n=this._requestResolvers.get(r);if(n){if(this._requestResolvers.delete(r),cn(e))n(e);else{const i=new ie(e.error.code,e.error.message,e.error.data);n(i)}return}const s=this._responseHandlers.get(r);if(s===void 0){this._onerror(new Error(`Received a response for an unknown message ID: ${JSON.stringify(e)}`));return}this._responseHandlers.delete(r),this._cleanupTimeout(r);let o=!1;if(cn(e)&&e.result&&typeof e.result=="object"){const i=e.result;if(i.task&&typeof i.task=="object"){const a=i.task;typeof a.taskId=="string"&&(o=!0,this._taskProgressTokens.set(a.taskId,r))}}if(o||this._progressHandlers.delete(r),cn(e))s(e);else{const i=ie.fromError(e.error.code,e.error.message,e.error.data);s(i)}}get transport(){return this._transport}async close(){await this._transport?.close()}async*requestStream(e,r,n){const{task:s}=n??{};if(!s){try{yield{type:"result",result:await this.request(e,r,n)}}catch(i){yield{type:"error",error:i instanceof ie?i:new ie(ue.InternalError,String(i))}}return}let o;try{const i=await this.request(e,fn,n);if(i.task)o=i.task.taskId,yield{type:"taskCreated",task:i.task};else throw new ie(ue.InternalError,"Task creation did not return a task");for(;;){const a=await this.getTask({taskId:o},n);if(yield{type:"taskStatus",task:a},yr(a.status)){a.status==="completed"?yield{type:"result",result:await this.getTaskResult({taskId:o},r,n)}:a.status==="failed"?yield{type:"error",error:new ie(ue.InternalError,`Task ${o} failed`)}:a.status==="cancelled"&&(yield{type:"error",error:new ie(ue.InternalError,`Task ${o} was cancelled`)});return}if(a.status==="input_required"){yield{type:"result",result:await this.getTaskResult({taskId:o},r,n)};return}const c=a.pollInterval??this._options?.defaultTaskPollInterval??1e3;await new Promise(u=>setTimeout(u,c)),n?.signal?.throwIfAborted()}}catch(i){yield{type:"error",error:i instanceof ie?i:new ie(ue.InternalError,String(i))}}}request(e,r,n){const{relatedRequestId:s,resumptionToken:o,onresumptiontoken:i,task:a,relatedTask:c}=n??{};return new Promise((u,l)=>{const d=h=>{l(h)};if(!this._transport){d(new Error("Not connected"));return}if(this._options?.enforceStrictCapabilities===!0)try{this.assertCapabilityForMethod(e.method),a&&this.assertTaskCapability(e.method)}catch(h){d(h);return}n?.signal?.throwIfAborted();const p=this._requestMessageId++,_={...e,jsonrpc:"2.0",id:p};n?.onprogress&&(this._progressHandlers.set(p,n.onprogress),_.params={...e.params,_meta:{...e.params?._meta||{},progressToken:p}}),a&&(_.params={..._.params,task:a}),c&&(_.params={..._.params,_meta:{..._.params?._meta||{},[fr]:c}});const m=h=>{this._responseHandlers.delete(p),this._progressHandlers.delete(p),this._cleanupTimeout(p),this._transport?.send({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:p,reason:String(h)}},{relatedRequestId:s,resumptionToken:o,onresumptiontoken:i}).catch($=>this._onerror(new Error(`Failed to send cancellation: ${$}`)));const w=h instanceof ie?h:new ie(ue.RequestTimeout,String(h));l(w)};this._responseHandlers.set(p,h=>{if(!n?.signal?.aborted){if(h instanceof Error)return l(h);try{const w=nr(r,h.result);w.success?u(w.data):l(w.error)}catch(w){l(w)}}}),n?.signal?.addEventListener("abort",()=>{m(n?.signal?.reason)});const g=n?.timeout??xw,f=()=>m(ie.fromError(ue.RequestTimeout,"Request timed out",{timeout:g}));this._setupTimeout(p,g,n?.maxTotalTimeout,f,n?.resetTimeoutOnProgress??!1);const v=c?.taskId;if(v){const h=w=>{const $=this._responseHandlers.get(p);$?$(w):this._onerror(new Error(`Response handler missing for side-channeled request ${p}`))};this._requestResolvers.set(p,h),this._enqueueTaskMessage(v,{type:"request",message:_,timestamp:Date.now()}).catch(w=>{this._cleanupTimeout(p),l(w)})}else this._transport.send(_,{relatedRequestId:s,resumptionToken:o,onresumptiontoken:i}).catch(h=>{this._cleanupTimeout(p),l(h)})})}async getTask(e,r){return this.request({method:"tasks/get",params:e},Si,r)}async getTaskResult(e,r,n){return this.request({method:"tasks/result",params:e},r,n)}async listTasks(e,r){return this.request({method:"tasks/list",params:e},Ri,r)}async cancelTask(e,r){return this.request({method:"tasks/cancel",params:e},xv,r)}async notification(e,r){if(!this._transport)throw new Error("Not connected");this.assertNotificationCapability(e.method);const n=r?.relatedTask?.taskId;if(n){const a={...e,jsonrpc:"2.0",params:{...e.params,_meta:{...e.params?._meta||{},[fr]:r.relatedTask}}};await this._enqueueTaskMessage(n,{type:"notification",message:a,timestamp:Date.now()});return}if((this._options?.debouncedNotificationMethods??[]).includes(e.method)&&!e.params&&!r?.relatedRequestId&&!r?.relatedTask){if(this._pendingDebouncedNotifications.has(e.method))return;this._pendingDebouncedNotifications.add(e.method),Promise.resolve().then(()=>{if(this._pendingDebouncedNotifications.delete(e.method),!this._transport)return;let a={...e,jsonrpc:"2.0"};r?.relatedTask&&(a={...a,params:{...a.params,_meta:{...a.params?._meta||{},[fr]:r.relatedTask}}}),this._transport?.send(a,r).catch(c=>this._onerror(c))});return}let i={...e,jsonrpc:"2.0"};r?.relatedTask&&(i={...i,params:{...i.params,_meta:{...i.params?._meta||{},[fr]:r.relatedTask}}}),await this._transport.send(i,r)}setRequestHandler(e,r){const n=qd(e);this.assertRequestHandlerCapability(n),this._requestHandlers.set(n,(s,o)=>{const i=zd(e,s);return Promise.resolve(r(i,o))})}removeRequestHandler(e){this._requestHandlers.delete(e)}assertCanSetRequestHandler(e){if(this._requestHandlers.has(e))throw new Error(`A request handler for ${e} already exists, which would be overridden`)}setNotificationHandler(e,r){const n=qd(e);this._notificationHandlers.set(n,s=>{const o=zd(e,s);return Promise.resolve(r(o))})}removeNotificationHandler(e){this._notificationHandlers.delete(e)}_cleanupTaskProgressHandler(e){const r=this._taskProgressTokens.get(e);r!==void 0&&(this._progressHandlers.delete(r),this._taskProgressTokens.delete(e))}async _enqueueTaskMessage(e,r,n){if(!this._taskStore||!this._taskMessageQueue)throw new Error("Cannot enqueue task message: taskStore and taskMessageQueue are not configured");const s=this._options?.maxTaskQueueSize;await this._taskMessageQueue.enqueue(e,r,n,s)}async _clearTaskQueue(e,r){if(this._taskMessageQueue){const n=await this._taskMessageQueue.dequeueAll(e,r);for(const s of n)if(s.type==="request"&&_i(s.message)){const o=s.message.id,i=this._requestResolvers.get(o);i?(i(new ie(ue.InternalError,"Task cancelled or completed")),this._requestResolvers.delete(o)):this._onerror(new Error(`Resolver missing for request ${o} during task ${e} cleanup`))}}}async _waitForTaskUpdate(e,r){let n=this._options?.defaultTaskPollInterval??1e3;try{const s=await this._taskStore?.getTask(e);s?.pollInterval&&(n=s.pollInterval)}catch{}return new Promise((s,o)=>{if(r.aborted){o(new ie(ue.InvalidRequest,"Request cancelled"));return}const i=setTimeout(s,n);r.addEventListener("abort",()=>{clearTimeout(i),o(new ie(ue.InvalidRequest,"Request cancelled"))},{once:!0})})}requestTaskStore(e,r){const n=this._taskStore;if(!n)throw new Error("No task store configured");return{createTask:async s=>{if(!e)throw new Error("No request provided");return await n.createTask(s,e.id,{method:e.method,params:e.params},r)},getTask:async s=>{const o=await n.getTask(s,r);if(!o)throw new ie(ue.InvalidParams,"Failed to retrieve task: Task not found");return o},storeTaskResult:async(s,o,i)=>{await n.storeTaskResult(s,o,i,r);const a=await n.getTask(s,r);if(a){const c=Js.parse({method:"notifications/tasks/status",params:a});await this.notification(c),yr(a.status)&&this._cleanupTaskProgressHandler(s)}},getTaskResult:s=>n.getTaskResult(s,r),updateTaskStatus:async(s,o,i)=>{const a=await n.getTask(s,r);if(!a)throw new ie(ue.InvalidParams,`Task "${s}" not found - it may have been cleaned up`);if(yr(a.status))throw new ie(ue.InvalidParams,`Cannot update task "${s}" from terminal status "${a.status}" to "${o}". Terminal states (completed, failed, cancelled) cannot transition to other states.`);await n.updateTaskStatus(s,o,i,r);const c=await n.getTask(s,r);if(c){const u=Js.parse({method:"notifications/tasks/status",params:c});await this.notification(u),yr(c.status)&&this._cleanupTaskProgressHandler(s)}},listTasks:s=>n.listTasks(s,r)}}};function Ud(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)}function Cw(t,e){const r={...t};for(const n in e){const s=n,o=e[s];if(o===void 0)continue;const i=r[s];Ud(i)&&Ud(o)?r[s]={...i,...o}:r[s]=o}return r}var oo={exports:{}},Hi={},Ld;function Ow(){return Ld||(Ld=1,(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.formatNames=t.fastFormats=t.fullFormats=void 0;function e(q,W){return{validate:q,compare:W}}t.fullFormats={date:e(o,i),time:e(c(!0),u),"date-time":e(p(!0),_),"iso-time":e(c(),l),"iso-date-time":e(p(),m),duration:/^P(?!$)((\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+S)?)?|(\d+W)?)$/,uri:v,"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:F,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:w,int32:{type:"number",validate:S},int64:{type:"number",validate:T},float:{type:"number",validate:N},double:{type:"number",validate:N},password:!0,binary:!0},t.fastFormats={...t.fullFormats,date:e(/^\d\d\d\d-[0-1]\d-[0-3]\d$/,i),time:e(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,u),"date-time":e(/^\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,_),"iso-time":e(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,l),"iso-date-time":e(/^\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,m),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},t.formatNames=Object.keys(t.fullFormats);function r(q){return q%4===0&&(q%100!==0||q%400===0)}const n=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,s=[0,31,28,31,30,31,30,31,31,30,31,30,31];function o(q){const W=n.exec(q);if(!W)return!1;const K=+W[1],G=+W[2],ke=+W[3];return G>=1&&G<=12&&ke>=1&&ke<=(G===2&&r(K)?29:s[G])}function i(q,W){if(q&&W)return q>W?1:q<W?-1:0}const a=/^(\d\d):(\d\d):(\d\d(?:\.\d+)?)(z|([+-])(\d\d)(?::?(\d\d))?)?$/i;function c(q){return function(K){const G=a.exec(K);if(!G)return!1;const ke=+G[1],tt=+G[2],rt=+G[3],xe=G[4],Ot=G[5]==="-"?-1:1,V=+(G[6]||0),P=+(G[7]||0);if(V>23||P>59||q&&!xe)return!1;if(ke<=23&&tt<=59&&rt<60)return!0;const L=tt-P*Ot,O=ke-V*Ot-(L<0?1:0);return(O===23||O===-1)&&(L===59||L===-1)&&rt<61}}function u(q,W){if(!(q&&W))return;const K=new Date("2020-01-01T"+q).valueOf(),G=new Date("2020-01-01T"+W).valueOf();if(K&&G)return K-G}function l(q,W){if(!(q&&W))return;const K=a.exec(q),G=a.exec(W);if(K&&G)return q=K[1]+K[2]+K[3],W=G[1]+G[2]+G[3],q>W?1:q<W?-1:0}const d=/t|\s/i;function p(q){const W=c(q);return function(G){const ke=G.split(d);return ke.length===2&&o(ke[0])&&W(ke[1])}}function _(q,W){if(!(q&&W))return;const K=new Date(q).valueOf(),G=new Date(W).valueOf();if(K&&G)return K-G}function m(q,W){if(!(q&&W))return;const[K,G]=q.split(d),[ke,tt]=W.split(d),rt=i(K,ke);if(rt!==void 0)return rt||u(G,tt)}const g=/\/|:/,f=/^(?:[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 v(q){return g.test(q)&&f.test(q)}const h=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/gm;function w(q){return h.lastIndex=0,h.test(q)}const $=-2147483648,b=2**31-1;function S(q){return Number.isInteger(q)&&q<=b&&q>=$}function T(q){return Number.isInteger(q)}function N(){return!0}const j=/[^\\]\\Z/;function F(q){if(j.test(q))return!1;try{return new RegExp(q),!0}catch{return!1}}})(Hi)),Hi}var Fi={},Zd;function Nw(){return Zd||(Zd=1,(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.formatLimitDefinition=void 0;const e=ju(),r=fe(),n=r.operators,s={formatMaximum:{okStr:"<=",ok:n.LTE,fail:n.GT},formatMinimum:{okStr:">=",ok:n.GTE,fail:n.LT},formatExclusiveMaximum:{okStr:"<",ok:n.LT,fail:n.GTE},formatExclusiveMinimum:{okStr:">",ok:n.GT,fail:n.LTE}},o={message:({keyword:a,schemaCode:c})=>(0,r.str)`should be ${s[a].okStr} ${c}`,params:({keyword:a,schemaCode:c})=>(0,r._)`{comparison: ${s[a].okStr}, limit: ${c}}`};t.formatLimitDefinition={keyword:Object.keys(s),type:"string",schemaType:"string",$data:!0,error:o,code(a){const{gen:c,data:u,schemaCode:l,keyword:d,it:p}=a,{opts:_,self:m}=p;if(!_.validateFormats)return;const g=new e.KeywordCxt(p,m.RULES.all.format.definition,"format");g.$data?f():v();function f(){const w=c.scopeValue("formats",{ref:m.formats,code:_.code.formats}),$=c.const("fmt",(0,r._)`${w}[${g.schemaCode}]`);a.fail$data((0,r.or)((0,r._)`typeof ${$} != "object"`,(0,r._)`${$} instanceof RegExp`,(0,r._)`typeof ${$}.compare != "function"`,h($)))}function v(){const w=g.schema,$=m.formats[w];if(!$||$===!0)return;if(typeof $!="object"||$ instanceof RegExp||typeof $.compare!="function")throw new Error(`"${d}": format "${w}" does not define "compare" function`);const b=c.scopeValue("formats",{key:w,ref:$,code:_.code.formats?(0,r._)`${_.code.formats}${(0,r.getProperty)(w)}`:void 0});a.fail$data(h(b))}function h(w){return(0,r._)`${w}.compare(${u}, ${l}) ${s[d].fail} 0`}},dependencies:["format"]};const i=a=>(a.addKeyword(t.formatLimitDefinition),a);t.default=i})(Fi)),Fi}var Dd;function Aw(){return Dd||(Dd=1,(function(t,e){Object.defineProperty(e,"__esModule",{value:!0});const r=Ow(),n=Nw(),s=fe(),o=new s.Name("fullFormats"),i=new s.Name("fastFormats"),a=(u,l={keywords:!0})=>{if(Array.isArray(l))return c(u,l,r.fullFormats,o),u;const[d,p]=l.mode==="fast"?[r.fastFormats,i]:[r.fullFormats,o],_=l.formats||r.formatNames;return c(u,_,d,p),l.keywords&&(0,n.default)(u),u};a.get=(u,l="full")=>{const p=(l==="fast"?r.fastFormats:r.fullFormats)[u];if(!p)throw new Error(`Unknown format "${u}"`);return p};function c(u,l,d,p){var _,m;(_=(m=u.opts.code).formats)!==null&&_!==void 0||(m.formats=(0,s._)`require("ajv-formats/dist/formats").${p}`);for(const g of l)u.addFormat(g,d[g])}t.exports=e=a,Object.defineProperty(e,"__esModule",{value:!0}),e.default=a})(oo,oo.exports)),oo.exports}var Mw=Aw();const Vd=kr(Mw);function jw(){const t=new zu({strict:!1,validateFormats:!0,validateSchema:!1,allErrors:!0});return Vd(t),t}let qw=class{constructor(e){this._ajv=e??jw()}getValidator(e){const r="$id"in e&&typeof e.$id=="string"?this._ajv.getSchema(e.$id)??this._ajv.compile(e):this._ajv.compile(e);return n=>r(n)?{valid:!0,data:n,errorMessage:void 0}:{valid:!1,data:void 0,errorMessage:this._ajv.errorsText(r.errors)}}};class zw{constructor(e){this._client=e}async*callToolStream(e,r=Bs,n){const s=this._client,o={...n,task:n?.task??(s.isToolTask(e.name)?{}:void 0)},i=s.requestStream({method:"tools/call",params:e},r,o),a=s.getToolOutputValidator(e.name);for await(const c of i){if(c.type==="result"&&a){const u=c.result;if(!u.structuredContent&&!u.isError){yield{type:"error",error:new ie(ue.InvalidRequest,`Tool ${e.name} has an output schema but did not return structured content`)};return}if(u.structuredContent)try{const l=a(u.structuredContent);if(!l.valid){yield{type:"error",error:new ie(ue.InvalidParams,`Structured content does not match the tool's output schema: ${l.errorMessage}`)};return}}catch(l){if(l instanceof ie){yield{type:"error",error:l};return}yield{type:"error",error:new ie(ue.InvalidParams,`Failed to validate structured content: ${l instanceof Error?l.message:String(l)}`)};return}}yield c}}async getTask(e,r){return this._client.getTask({taskId:e},r)}async getTaskResult(e,r,n){return this._client.getTaskResult({taskId:e},r,n)}async listTasks(e,r){return this._client.listTasks(e?{cursor:e}:void 0,r)}async cancelTask(e,r){return this._client.cancelTask({taskId:e},r)}requestStream(e,r,n){return this._client.requestStream(e,r,n)}}function Uw(t,e,r){if(!t)throw new Error(`${r} does not support task creation (required for ${e})`);switch(e){case"tools/call":if(!t.tools?.call)throw new Error(`${r} does not support task creation for tools/call (required for ${e})`);break}}function Lw(t,e,r){if(!t)throw new Error(`${r} does not support task creation (required for ${e})`);switch(e){case"sampling/createMessage":if(!t.sampling?.createMessage)throw new Error(`${r} does not support task creation for sampling/createMessage (required for ${e})`);break;case"elicitation/create":if(!t.elicitation?.create)throw new Error(`${r} does not support task creation for elicitation/create (required for ${e})`);break}}function io(t,e){if(!(!t||e===null||typeof e!="object")){if(t.type==="object"&&t.properties&&typeof t.properties=="object"){const r=e,n=t.properties;for(const s of Object.keys(n)){const o=n[s];r[s]===void 0&&Object.prototype.hasOwnProperty.call(o,"default")&&(r[s]=o.default),r[s]!==void 0&&io(o,r[s])}}if(Array.isArray(t.anyOf))for(const r of t.anyOf)typeof r!="boolean"&&io(r,e);if(Array.isArray(t.oneOf))for(const r of t.oneOf)typeof r!="boolean"&&io(r,e)}}function Zw(t){if(!t)return{supportsFormMode:!1,supportsUrlMode:!1};const e=t.form!==void 0,r=t.url!==void 0;return{supportsFormMode:e||!e&&!r,supportsUrlMode:r}}let Wi=class extends Iw{constructor(e,r){super(r),this._clientInfo=e,this._cachedToolOutputValidators=new Map,this._cachedKnownTaskTools=new Set,this._cachedRequiredTaskTools=new Set,this._listChangedDebounceTimers=new Map,this._capabilities=r?.capabilities??{},this._jsonSchemaValidator=r?.jsonSchemaValidator??new qw,r?.listChanged&&(this._pendingListChangedConfig=r.listChanged)}_setupListChangedHandlers(e){e.tools&&this._serverCapabilities?.tools?.listChanged&&this._setupListChangedHandler("tools",ad,e.tools,async()=>(await this.listTools()).tools),e.prompts&&this._serverCapabilities?.prompts?.listChanged&&this._setupListChangedHandler("prompts",sd,e.prompts,async()=>(await this.listPrompts()).prompts),e.resources&&this._serverCapabilities?.resources?.listChanged&&this._setupListChangedHandler("resources",td,e.resources,async()=>(await this.listResources()).resources)}get experimental(){return this._experimental||(this._experimental={tasks:new zw(this)}),this._experimental}registerCapabilities(e){if(this.transport)throw new Error("Cannot register capabilities after connecting to transport");this._capabilities=Cw(this._capabilities,e)}setRequestHandler(e,r){const s=Ed(e)?.method;if(!s)throw new Error("Schema is missing a method literal");let o;if(no(s)){const a=s;o=a._zod?.def?.value??a.value}else{const a=s;o=a._def?.value??a.value}if(typeof o!="string")throw new Error("Schema method literal must be a string");const i=o;if(i==="elicitation/create"){const a=async(c,u)=>{const l=nr(ld,c);if(!l.success){const h=l.error instanceof Error?l.error.message:String(l.error);throw new ie(ue.InvalidParams,`Invalid elicitation request: ${h}`)}const{params:d}=l.data;d.mode=d.mode??"form";const{supportsFormMode:p,supportsUrlMode:_}=Zw(this._capabilities.elicitation);if(d.mode==="form"&&!p)throw new ie(ue.InvalidParams,"Client does not support form-mode elicitation requests");if(d.mode==="url"&&!_)throw new ie(ue.InvalidParams,"Client does not support URL-mode elicitation requests");const m=await Promise.resolve(r(c,u));if(d.task){const h=nr(fn,m);if(!h.success){const w=h.error instanceof Error?h.error.message:String(h.error);throw new ie(ue.InvalidParams,`Invalid task creation result: ${w}`)}return h.data}const g=nr(Mi,m);if(!g.success){const h=g.error instanceof Error?g.error.message:String(g.error);throw new ie(ue.InvalidParams,`Invalid elicitation result: ${h}`)}const f=g.data,v=d.mode==="form"?d.requestedSchema:void 0;if(d.mode==="form"&&f.action==="accept"&&f.content&&v&&this._capabilities.elicitation?.form?.applyDefaults)try{io(v,f.content)}catch{}return f};return super.setRequestHandler(e,a)}if(i==="sampling/createMessage"){const a=async(c,u)=>{const l=nr(ud,c);if(!l.success){const m=l.error instanceof Error?l.error.message:String(l.error);throw new ie(ue.InvalidParams,`Invalid sampling request: ${m}`)}const{params:d}=l.data,p=await Promise.resolve(r(c,u));if(d.task){const m=nr(fn,p);if(!m.success){const g=m.error instanceof Error?m.error.message:String(m.error);throw new ie(ue.InvalidParams,`Invalid task creation result: ${g}`)}return m.data}const _=nr(Ai,p);if(!_.success){const m=_.error instanceof Error?_.error.message:String(_.error);throw new ie(ue.InvalidParams,`Invalid sampling result: ${m}`)}return _.data};return super.setRequestHandler(e,a)}return super.setRequestHandler(e,r)}assertCapability(e,r){if(!this._serverCapabilities?.[e])throw new Error(`Server does not support ${e} (required for ${r})`)}async connect(e,r){if(await super.connect(e),e.sessionId===void 0)try{const n=await this.request({method:"initialize",params:{protocolVersion:Hs,capabilities:this._capabilities,clientInfo:this._clientInfo}},Wl,r);if(n===void 0)throw new Error(`Server sent invalid initialize result: ${n}`);if(!av.includes(n.protocolVersion))throw new Error(`Server's protocol version is not supported: ${n.protocolVersion}`);this._serverCapabilities=n.capabilities,this._serverVersion=n.serverInfo,e.setProtocolVersion&&e.setProtocolVersion(n.protocolVersion),this._instructions=n.instructions,await this.notification({method:"notifications/initialized"}),this._pendingListChangedConfig&&(this._setupListChangedHandlers(this._pendingListChangedConfig),this._pendingListChangedConfig=void 0)}catch(n){throw this.close(),n}}getServerCapabilities(){return this._serverCapabilities}getServerVersion(){return this._serverVersion}getInstructions(){return this._instructions}assertCapabilityForMethod(e){switch(e){case"logging/setLevel":if(!this._serverCapabilities?.logging)throw new Error(`Server does not support logging (required for ${e})`);break;case"prompts/get":case"prompts/list":if(!this._serverCapabilities?.prompts)throw new Error(`Server does not support prompts (required for ${e})`);break;case"resources/list":case"resources/templates/list":case"resources/read":case"resources/subscribe":case"resources/unsubscribe":if(!this._serverCapabilities?.resources)throw new Error(`Server does not support resources (required for ${e})`);if(e==="resources/subscribe"&&!this._serverCapabilities.resources.subscribe)throw new Error(`Server does not support resource subscriptions (required for ${e})`);break;case"tools/call":case"tools/list":if(!this._serverCapabilities?.tools)throw new Error(`Server does not support tools (required for ${e})`);break;case"completion/complete":if(!this._serverCapabilities?.completions)throw new Error(`Server does not support completions (required for ${e})`);break}}assertNotificationCapability(e){switch(e){case"notifications/roots/list_changed":if(!this._capabilities.roots?.listChanged)throw new Error(`Client does not support roots list changed notifications (required for ${e})`);break}}assertRequestHandlerCapability(e){if(this._capabilities)switch(e){case"sampling/createMessage":if(!this._capabilities.sampling)throw new Error(`Client does not support sampling capability (required for ${e})`);break;case"elicitation/create":if(!this._capabilities.elicitation)throw new Error(`Client does not support elicitation capability (required for ${e})`);break;case"roots/list":if(!this._capabilities.roots)throw new Error(`Client does not support roots capability (required for ${e})`);break;case"tasks/get":case"tasks/list":case"tasks/result":case"tasks/cancel":if(!this._capabilities.tasks)throw new Error(`Client does not support tasks capability (required for ${e})`);break}}assertTaskCapability(e){Uw(this._serverCapabilities?.tasks?.requests,e,"Server")}assertTaskHandlerCapability(e){this._capabilities&&Lw(this._capabilities.tasks?.requests,e,"Client")}async ping(e){return this.request({method:"ping"},pr,e)}async complete(e,r){return this.request({method:"completion/complete",params:e},dd,r)}async setLoggingLevel(e,r){return this.request({method:"logging/setLevel",params:{level:e}},pr,r)}async getPrompt(e,r){return this.request({method:"prompts/get",params:e},nd,r)}async listPrompts(e,r){return this.request({method:"prompts/list",params:e},rd,r)}async listResources(e,r){return this.request({method:"resources/list",params:e},Ql,r)}async listResourceTemplates(e,r){return this.request({method:"resources/templates/list",params:e},Xl,r)}async readResource(e,r){return this.request({method:"resources/read",params:e},ed,r)}async subscribeResource(e,r){return this.request({method:"resources/subscribe",params:e},pr,r)}async unsubscribeResource(e,r){return this.request({method:"resources/unsubscribe",params:e},pr,r)}async callTool(e,r=Bs,n){if(this.isToolTaskRequired(e.name))throw new ie(ue.InvalidRequest,`Tool "${e.name}" requires task-based execution. Use client.experimental.tasks.callToolStream() instead.`);const s=await this.request({method:"tools/call",params:e},r,n),o=this.getToolOutputValidator(e.name);if(o){if(!s.structuredContent&&!s.isError)throw new ie(ue.InvalidRequest,`Tool ${e.name} has an output schema but did not return structured content`);if(s.structuredContent)try{const i=o(s.structuredContent);if(!i.valid)throw new ie(ue.InvalidParams,`Structured content does not match the tool's output schema: ${i.errorMessage}`)}catch(i){throw i instanceof ie?i:new ie(ue.InvalidParams,`Failed to validate structured content: ${i instanceof Error?i.message:String(i)}`)}}return s}isToolTask(e){return this._serverCapabilities?.tasks?.requests?.tools?.call?this._cachedKnownTaskTools.has(e):!1}isToolTaskRequired(e){return this._cachedRequiredTaskTools.has(e)}cacheToolMetadata(e){this._cachedToolOutputValidators.clear(),this._cachedKnownTaskTools.clear(),this._cachedRequiredTaskTools.clear();for(const r of e){if(r.outputSchema){const s=this._jsonSchemaValidator.getValidator(r.outputSchema);this._cachedToolOutputValidators.set(r.name,s)}const n=r.execution?.taskSupport;(n==="required"||n==="optional")&&this._cachedKnownTaskTools.add(r.name),n==="required"&&this._cachedRequiredTaskTools.add(r.name)}}getToolOutputValidator(e){return this._cachedToolOutputValidators.get(e)}async listTools(e,r){const n=await this.request({method:"tools/list",params:e},id,r);return this.cacheToolMetadata(n.tools),n}_setupListChangedHandler(e,r,n,s){const o=ty.safeParse(n);if(!o.success)throw new Error(`Invalid ${e} listChanged options: ${o.error.message}`);if(typeof n.onChanged!="function")throw new Error(`Invalid ${e} listChanged options: onChanged must be a function`);const{autoRefresh:i,debounceMs:a}=o.data,{onChanged:c}=n,u=async()=>{if(!i){c(null,null);return}try{const d=await s();c(null,d)}catch(d){const p=d instanceof Error?d:new Error(String(d));c(p,null)}},l=()=>{if(a){const d=this._listChangedDebounceTimers.get(e);d&&clearTimeout(d);const p=setTimeout(u,a);this._listChangedDebounceTimers.set(e,p)}else u()};this.setNotificationHandler(r,l)}async sendRootsListChanged(){return this.notification({method:"notifications/roots/list_changed"})}};class Hd extends Error{constructor(e,r){super(e),this.name="ParseError",this.type=r.type,this.field=r.field,this.value=r.value,this.line=r.line}}function Ji(t){}function Fd(t){if(typeof t=="function")throw new TypeError("`callbacks` must be an object, got a function instead. Did you mean `{onEvent: fn}`?");const{onEvent:e=Ji,onError:r=Ji,onRetry:n=Ji,onComment:s}=t;let o="",i=!0,a,c="",u="";function l(g){const f=i?g.replace(/^\xEF\xBB\xBF/,""):g,[v,h]=Dw(`${o}${f}`);for(const w of v)d(w);o=h,i=!1}function d(g){if(g===""){_();return}if(g.startsWith(":")){s&&s(g.slice(g.startsWith(": ")?2:1));return}const f=g.indexOf(":");if(f!==-1){const v=g.slice(0,f),h=g[f+1]===" "?2:1,w=g.slice(f+h);p(v,w,g);return}p(g,"",g)}function p(g,f,v){switch(g){case"event":u=f;break;case"data":c=`${c}${f}
|
|
40
|
+
`;break;case"id":a=f.includes("\0")?void 0:f;break;case"retry":/^\d+$/.test(f)?n(parseInt(f,10)):r(new Hd(`Invalid \`retry\` value: "${f}"`,{type:"invalid-retry",value:f,line:v}));break;default:r(new Hd(`Unknown field "${g.length>20?`${g.slice(0,20)}…`:g}"`,{type:"unknown-field",field:g,value:f,line:v}));break}}function _(){c.length>0&&e({id:a,event:u||void 0,data:c.endsWith(`
|
|
41
|
+
`)?c.slice(0,-1):c}),a=void 0,c="",u=""}function m(g={}){o&&g.consume&&d(o),i=!0,a=void 0,c="",u="",o=""}return{feed:l,reset:m}}function Dw(t){const e=[];let r="",n=0;for(;n<t.length;){const s=t.indexOf("\r",n),o=t.indexOf(`
|
|
42
|
+
`,n);let i=-1;if(s!==-1&&o!==-1?i=Math.min(s,o):s!==-1?s===t.length-1?i=-1:i=s:o!==-1&&(i=o),i===-1){r=t.slice(n);break}else{const a=t.slice(n,i);e.push(a),n=i+1,t[n-1]==="\r"&&t[n]===`
|
|
43
|
+
`&&n++}}return[e,r]}class Wd extends Event{constructor(e,r){var n,s;super(e),this.code=(n=r?.code)!=null?n:void 0,this.message=(s=r?.message)!=null?s:void 0}[Symbol.for("nodejs.util.inspect.custom")](e,r,n){return n(Jd(this),r)}[Symbol.for("Deno.customInspect")](e,r){return e(Jd(this),r)}}function Vw(t){const e=globalThis.DOMException;return typeof e=="function"?new e(t,"SyntaxError"):new SyntaxError(t)}function Bi(t){return t instanceof Error?"errors"in t&&Array.isArray(t.errors)?t.errors.map(Bi).join(", "):"cause"in t&&t.cause instanceof Error?`${t}: ${Bi(t.cause)}`:t.message:`${t}`}function Jd(t){return{type:t.type,message:t.message,code:t.code,defaultPrevented:t.defaultPrevented,cancelable:t.cancelable,timeStamp:t.timeStamp}}var Bd=t=>{throw TypeError(t)},Ki=(t,e,r)=>e.has(t)||Bd("Cannot "+r),_e=(t,e,r)=>(Ki(t,e,"read from private field"),r?r.call(t):e.get(t)),Le=(t,e,r)=>e.has(t)?Bd("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),Me=(t,e,r,n)=>(Ki(t,e,"write to private field"),e.set(t,r),r),Ht=(t,e,r)=>(Ki(t,e,"access private method"),r),ot,wr,jr,ao,co,xn,qr,In,sr,zr,Ur,Lr,Cn,Tt,Gi,Yi,Qi,Kd,Xi,ea,On,ta,ra;class Nn extends EventTarget{constructor(e,r){var n,s;super(),Le(this,Tt),this.CONNECTING=0,this.OPEN=1,this.CLOSED=2,Le(this,ot),Le(this,wr),Le(this,jr),Le(this,ao),Le(this,co),Le(this,xn),Le(this,qr),Le(this,In,null),Le(this,sr),Le(this,zr),Le(this,Ur,null),Le(this,Lr,null),Le(this,Cn,null),Le(this,Yi,async o=>{var i;_e(this,zr).reset();const{body:a,redirected:c,status:u,headers:l}=o;if(u===204){Ht(this,Tt,On).call(this,"Server sent HTTP 204, not reconnecting",204),this.close();return}if(c?Me(this,jr,new URL(o.url)):Me(this,jr,void 0),u!==200){Ht(this,Tt,On).call(this,`Non-200 status code (${u})`,u);return}if(!(l.get("content-type")||"").startsWith("text/event-stream")){Ht(this,Tt,On).call(this,'Invalid content type, expected "text/event-stream"',u);return}if(_e(this,ot)===this.CLOSED)return;Me(this,ot,this.OPEN);const d=new Event("open");if((i=_e(this,Cn))==null||i.call(this,d),this.dispatchEvent(d),typeof a!="object"||!a||!("getReader"in a)){Ht(this,Tt,On).call(this,"Invalid response body, expected a web ReadableStream",u),this.close();return}const p=new TextDecoder,_=a.getReader();let m=!0;do{const{done:g,value:f}=await _.read();f&&_e(this,zr).feed(p.decode(f,{stream:!g})),g&&(m=!1,_e(this,zr).reset(),Ht(this,Tt,ta).call(this))}while(m)}),Le(this,Qi,o=>{Me(this,sr,void 0),!(o.name==="AbortError"||o.type==="aborted")&&Ht(this,Tt,ta).call(this,Bi(o))}),Le(this,Xi,o=>{typeof o.id=="string"&&Me(this,In,o.id);const i=new MessageEvent(o.event||"message",{data:o.data,origin:_e(this,jr)?_e(this,jr).origin:_e(this,wr).origin,lastEventId:o.id||""});_e(this,Lr)&&(!o.event||o.event==="message")&&_e(this,Lr).call(this,i),this.dispatchEvent(i)}),Le(this,ea,o=>{Me(this,xn,o)}),Le(this,ra,()=>{Me(this,qr,void 0),_e(this,ot)===this.CONNECTING&&Ht(this,Tt,Gi).call(this)});try{if(e instanceof URL)Me(this,wr,e);else if(typeof e=="string")Me(this,wr,new URL(e,Hw()));else throw new Error("Invalid URL")}catch{throw Vw("An invalid or illegal string was specified")}Me(this,zr,Fd({onEvent:_e(this,Xi),onRetry:_e(this,ea)})),Me(this,ot,this.CONNECTING),Me(this,xn,3e3),Me(this,co,(n=r?.fetch)!=null?n:globalThis.fetch),Me(this,ao,(s=r?.withCredentials)!=null?s:!1),Ht(this,Tt,Gi).call(this)}get readyState(){return _e(this,ot)}get url(){return _e(this,wr).href}get withCredentials(){return _e(this,ao)}get onerror(){return _e(this,Ur)}set onerror(e){Me(this,Ur,e)}get onmessage(){return _e(this,Lr)}set onmessage(e){Me(this,Lr,e)}get onopen(){return _e(this,Cn)}set onopen(e){Me(this,Cn,e)}addEventListener(e,r,n){const s=r;super.addEventListener(e,s,n)}removeEventListener(e,r,n){const s=r;super.removeEventListener(e,s,n)}close(){_e(this,qr)&&clearTimeout(_e(this,qr)),_e(this,ot)!==this.CLOSED&&(_e(this,sr)&&_e(this,sr).abort(),Me(this,ot,this.CLOSED),Me(this,sr,void 0))}}ot=new WeakMap,wr=new WeakMap,jr=new WeakMap,ao=new WeakMap,co=new WeakMap,xn=new WeakMap,qr=new WeakMap,In=new WeakMap,sr=new WeakMap,zr=new WeakMap,Ur=new WeakMap,Lr=new WeakMap,Cn=new WeakMap,Tt=new WeakSet,Gi=function(){Me(this,ot,this.CONNECTING),Me(this,sr,new AbortController),_e(this,co)(_e(this,wr),Ht(this,Tt,Kd).call(this)).then(_e(this,Yi)).catch(_e(this,Qi))},Yi=new WeakMap,Qi=new WeakMap,Kd=function(){var t;const e={mode:"cors",redirect:"follow",headers:{Accept:"text/event-stream",..._e(this,In)?{"Last-Event-ID":_e(this,In)}:void 0},cache:"no-store",signal:(t=_e(this,sr))==null?void 0:t.signal};return"window"in globalThis&&(e.credentials=this.withCredentials?"include":"same-origin"),e},Xi=new WeakMap,ea=new WeakMap,On=function(t,e){var r;_e(this,ot)!==this.CLOSED&&Me(this,ot,this.CLOSED);const n=new Wd("error",{code:e,message:t});(r=_e(this,Ur))==null||r.call(this,n),this.dispatchEvent(n)},ta=function(t,e){var r;if(_e(this,ot)===this.CLOSED)return;Me(this,ot,this.CONNECTING);const n=new Wd("error",{code:e,message:t});(r=_e(this,Ur))==null||r.call(this,n),this.dispatchEvent(n),Me(this,qr,setTimeout(_e(this,ra),_e(this,xn)))},ra=new WeakMap,Nn.CONNECTING=0,Nn.OPEN=1,Nn.CLOSED=2;function Hw(){const t="document"in globalThis?globalThis.document:void 0;return t&&typeof t=="object"&&"baseURI"in t&&typeof t.baseURI=="string"?t.baseURI:void 0}function uo(t){return t?t instanceof Headers?Object.fromEntries(t.entries()):Array.isArray(t)?Object.fromEntries(t):{...t}:{}}function Gd(t=fetch,e){return e?async(r,n)=>{const s={...e,...n,headers:n?.headers?{...uo(e.headers),...uo(n.headers)}:e.headers};return t(r,s)}:t}let na;na=globalThis.crypto;async function Fw(t){return(await na).getRandomValues(new Uint8Array(t))}async function Ww(t){const e="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._~",r=Math.pow(2,8)-Math.pow(2,8)%e.length;let n="";for(;n.length<t;){const s=await Fw(t-n.length);for(const o of s)o<r&&(n+=e[o%e.length])}return n}async function Jw(t){return await Ww(t)}async function Bw(t){const e=await(await na).subtle.digest("SHA-256",new TextEncoder().encode(t));return btoa(String.fromCharCode(...new Uint8Array(e))).replace(/\//g,"_").replace(/\+/g,"-").replace(/=/g,"")}async function Yd(t){if(t||(t=43),t<43||t>128)throw`Expected a length between 43 and 128. Received ${t}.`;const e=await Jw(t),r=await Bw(e);return{code_verifier:e,code_challenge:r}}const We=Pl().superRefine((t,e)=>{if(!URL.canParse(t))return e.addIssue({code:Ll.custom,message:"URL must be parseable",fatal:!0}),Uu}).refine(t=>{const e=new URL(t);return e.protocol!=="javascript:"&&e.protocol!=="data:"&&e.protocol!=="vbscript:"},{message:"URL cannot use javascript:, data:, or vbscript: scheme"}),Kw=Ee({resource:y().url(),authorization_servers:x(We).optional(),jwks_uri:y().url().optional(),scopes_supported:x(y()).optional(),bearer_methods_supported:x(y()).optional(),resource_signing_alg_values_supported:x(y()).optional(),resource_name:y().optional(),resource_documentation:y().optional(),resource_policy_uri:y().url().optional(),resource_tos_uri:y().url().optional(),tls_client_certificate_bound_access_tokens:oe().optional(),authorization_details_types_supported:x(y()).optional(),dpop_signing_alg_values_supported:x(y()).optional(),dpop_bound_access_tokens_required:oe().optional()}),Qd=Ee({issuer:y(),authorization_endpoint:We,token_endpoint:We,registration_endpoint:We.optional(),scopes_supported:x(y()).optional(),response_types_supported:x(y()),response_modes_supported:x(y()).optional(),grant_types_supported:x(y()).optional(),token_endpoint_auth_methods_supported:x(y()).optional(),token_endpoint_auth_signing_alg_values_supported:x(y()).optional(),service_documentation:We.optional(),revocation_endpoint:We.optional(),revocation_endpoint_auth_methods_supported:x(y()).optional(),revocation_endpoint_auth_signing_alg_values_supported:x(y()).optional(),introspection_endpoint:y().optional(),introspection_endpoint_auth_methods_supported:x(y()).optional(),introspection_endpoint_auth_signing_alg_values_supported:x(y()).optional(),code_challenge_methods_supported:x(y()).optional(),client_id_metadata_document_supported:oe().optional()}),Gw=Ee({issuer:y(),authorization_endpoint:We,token_endpoint:We,userinfo_endpoint:We.optional(),jwks_uri:We,registration_endpoint:We.optional(),scopes_supported:x(y()).optional(),response_types_supported:x(y()),response_modes_supported:x(y()).optional(),grant_types_supported:x(y()).optional(),acr_values_supported:x(y()).optional(),subject_types_supported:x(y()),id_token_signing_alg_values_supported:x(y()),id_token_encryption_alg_values_supported:x(y()).optional(),id_token_encryption_enc_values_supported:x(y()).optional(),userinfo_signing_alg_values_supported:x(y()).optional(),userinfo_encryption_alg_values_supported:x(y()).optional(),userinfo_encryption_enc_values_supported:x(y()).optional(),request_object_signing_alg_values_supported:x(y()).optional(),request_object_encryption_alg_values_supported:x(y()).optional(),request_object_encryption_enc_values_supported:x(y()).optional(),token_endpoint_auth_methods_supported:x(y()).optional(),token_endpoint_auth_signing_alg_values_supported:x(y()).optional(),display_values_supported:x(y()).optional(),claim_types_supported:x(y()).optional(),claims_supported:x(y()).optional(),service_documentation:y().optional(),claims_locales_supported:x(y()).optional(),ui_locales_supported:x(y()).optional(),claims_parameter_supported:oe().optional(),request_parameter_supported:oe().optional(),request_uri_parameter_supported:oe().optional(),require_request_uri_registration:oe().optional(),op_policy_uri:We.optional(),op_tos_uri:We.optional(),client_id_metadata_document_supported:oe().optional()}),Yw=C({...Gw.shape,...Qd.pick({code_challenge_methods_supported:!0}).shape}),Qw=C({access_token:y(),id_token:y().optional(),token_type:y(),expires_in:iv().optional(),scope:y().optional(),refresh_token:y().optional()}).strip(),Xw=C({error:y(),error_description:y().optional(),error_uri:y().optional()}),Xd=We.optional().or(z("").transform(()=>{})),eb=C({redirect_uris:x(We),token_endpoint_auth_method:y().optional(),grant_types:x(y()).optional(),response_types:x(y()).optional(),client_name:y().optional(),client_uri:We.optional(),logo_uri:Xd,scope:y().optional(),contacts:x(y()).optional(),tos_uri:Xd,policy_uri:y().optional(),jwks_uri:We.optional(),jwks:Cl().optional(),software_id:y().optional(),software_version:y().optional(),software_statement:y().optional()}).strip(),tb=C({client_id:y(),client_secret:y().optional(),client_id_issued_at:ne().optional(),client_secret_expires_at:ne().optional()}).strip(),rb=eb.merge(tb);C({error:y(),error_description:y().optional()}).strip(),C({token:y(),token_type_hint:y().optional()}).strip();function nb(t){const e=typeof t=="string"?new URL(t):new URL(t.href);return e.hash="",e}function sb({requestedResource:t,configuredResource:e}){const r=typeof t=="string"?new URL(t):new URL(t.href),n=typeof e=="string"?new URL(e):new URL(e.href);if(r.origin!==n.origin||r.pathname.length<n.pathname.length)return!1;const s=r.pathname.endsWith("/")?r.pathname:r.pathname+"/",o=n.pathname.endsWith("/")?n.pathname:n.pathname+"/";return s.startsWith(o)}let Ze=class extends Error{constructor(e,r){super(e),this.errorUri=r,this.name=this.constructor.name}toResponseObject(){const e={error:this.errorCode,error_description:this.message};return this.errorUri&&(e.error_uri=this.errorUri),e}get errorCode(){return this.constructor.errorCode}},sa=class extends Ze{};sa.errorCode="invalid_request";let lo=class extends Ze{};lo.errorCode="invalid_client";let ho=class extends Ze{};ho.errorCode="invalid_grant";let fo=class extends Ze{};fo.errorCode="unauthorized_client";let oa=class extends Ze{};oa.errorCode="unsupported_grant_type";let ia=class extends Ze{};ia.errorCode="invalid_scope";let aa=class extends Ze{};aa.errorCode="access_denied";let Zr=class extends Ze{};Zr.errorCode="server_error";let ca=class extends Ze{};ca.errorCode="temporarily_unavailable";let ua=class extends Ze{};ua.errorCode="unsupported_response_type";let la=class extends Ze{};la.errorCode="unsupported_token_type";let da=class extends Ze{};da.errorCode="invalid_token";let ha=class extends Ze{};ha.errorCode="method_not_allowed";let fa=class extends Ze{};fa.errorCode="too_many_requests";let po=class extends Ze{};po.errorCode="invalid_client_metadata";let pa=class extends Ze{};pa.errorCode="insufficient_scope";class ma extends Ze{}ma.errorCode="invalid_target";const ob={[sa.errorCode]:sa,[lo.errorCode]:lo,[ho.errorCode]:ho,[fo.errorCode]:fo,[oa.errorCode]:oa,[ia.errorCode]:ia,[aa.errorCode]:aa,[Zr.errorCode]:Zr,[ca.errorCode]:ca,[ua.errorCode]:ua,[la.errorCode]:la,[da.errorCode]:da,[ha.errorCode]:ha,[fa.errorCode]:fa,[po.errorCode]:po,[pa.errorCode]:pa,[ma.errorCode]:ma};let mt=class extends Error{constructor(e){super(e??"Unauthorized")}};function ib(t){return["client_secret_basic","client_secret_post","none"].includes(t)}const _a="code",ga="S256";function ab(t,e){const r=t.client_secret!==void 0;return e.length===0?r?"client_secret_post":"none":"token_endpoint_auth_method"in t&&t.token_endpoint_auth_method&&ib(t.token_endpoint_auth_method)&&e.includes(t.token_endpoint_auth_method)?t.token_endpoint_auth_method:r&&e.includes("client_secret_basic")?"client_secret_basic":r&&e.includes("client_secret_post")?"client_secret_post":e.includes("none")?"none":r?"client_secret_post":"none"}function cb(t,e,r,n){const{client_id:s,client_secret:o}=e;switch(t){case"client_secret_basic":ub(s,o,r);return;case"client_secret_post":lb(s,o,n);return;case"none":db(s,n);return;default:throw new Error(`Unsupported client authentication method: ${t}`)}}function ub(t,e,r){if(!e)throw new Error("client_secret_basic authentication requires a client_secret");const n=btoa(`${t}:${e}`);r.set("Authorization",`Basic ${n}`)}function lb(t,e,r){r.set("client_id",t),e&&r.set("client_secret",e)}function db(t,e){e.set("client_id",t)}async function eh(t){const e=t instanceof Response?t.status:void 0,r=t instanceof Response?await t.text():t;try{const n=Xw.parse(JSON.parse(r)),{error:s,error_description:o,error_uri:i}=n,a=ob[s]||Zr;return new a(o||"",i)}catch(n){const s=`${e?`HTTP ${e}: `:""}Invalid OAuth error response: ${n}. Raw body: ${r}`;return new Zr(s)}}async function br(t,e){try{return await va(t,e)}catch(r){if(r instanceof lo||r instanceof fo)return await t.invalidateCredentials?.("all"),await va(t,e);if(r instanceof ho)return await t.invalidateCredentials?.("tokens"),await va(t,e);throw r}}async function va(t,{serverUrl:e,authorizationCode:r,scope:n,resourceMetadataUrl:s,fetchFn:o}){let i,a;try{i=await pb(e,{resourceMetadataUrl:s},o),i.authorization_servers&&i.authorization_servers.length>0&&(a=i.authorization_servers[0])}catch{}a||(a=new URL("/",e));const c=await fb(e,t,i),u=await yb(a,{fetchFn:o});let l=await Promise.resolve(t.clientInformation());if(!l){if(r!==void 0)throw new Error("Existing OAuth client information is required when exchanging an authorization code");const f=u?.client_id_metadata_document_supported===!0,v=t.clientMetadataUrl;if(v&&!hb(v))throw new po(`clientMetadataUrl must be a valid HTTPS URL with a non-root pathname, got: ${v}`);if(f&&v)l={client_id:v},await t.saveClientInformation?.(l);else{if(!t.saveClientInformation)throw new Error("OAuth client information must be saveable for dynamic registration");const w=await kb(a,{metadata:u,clientMetadata:t.clientMetadata,fetchFn:o});await t.saveClientInformation(w),l=w}}const d=!t.redirectUrl;if(r!==void 0||d){const f=await Sb(t,a,{metadata:u,resource:c,authorizationCode:r,fetchFn:o});return await t.saveTokens(f),"AUTHORIZED"}const p=await t.tokens();if(p?.refresh_token)try{const f=await $b(a,{metadata:u,clientInformation:l,refreshToken:p.refresh_token,resource:c,addClientAuthentication:t.addClientAuthentication,fetchFn:o});return await t.saveTokens(f),"AUTHORIZED"}catch(f){if(!(!(f instanceof Ze)||f instanceof Zr))throw f}const _=t.state?await t.state():void 0,{authorizationUrl:m,codeVerifier:g}=await wb(a,{metadata:u,clientInformation:l,state:_,redirectUrl:t.redirectUrl,scope:n||i?.scopes_supported?.join(" ")||t.clientMetadata.scope,resource:c});return await t.saveCodeVerifier(g),await t.redirectToAuthorization(m),"REDIRECT"}function hb(t){if(!t)return!1;try{const e=new URL(t);return e.protocol==="https:"&&e.pathname!=="/"}catch{return!1}}async function fb(t,e,r){const n=nb(t);if(e.validateResourceURL)return await e.validateResourceURL(n,r?.resource);if(r){if(!sb({requestedResource:n,configuredResource:r.resource}))throw new Error(`Protected resource ${r.resource} does not match expected ${n} (or origin)`);return new URL(r.resource)}}function mo(t){const e=t.headers.get("WWW-Authenticate");if(!e)return{};const[r,n]=e.split(" ");if(r.toLowerCase()!=="bearer"||!n)return{};const s=ya(t,"resource_metadata")||void 0;let o;if(s)try{o=new URL(s)}catch{}const i=ya(t,"scope")||void 0,a=ya(t,"error")||void 0;return{resourceMetadataUrl:o,scope:i,error:a}}function ya(t,e){const r=t.headers.get("WWW-Authenticate");if(!r)return null;const n=new RegExp(`${e}=(?:"([^"]+)"|([^\\s,]+))`),s=r.match(n);return s?s[1]||s[2]:null}async function pb(t,e,r=fetch){const n=await gb(t,"oauth-protected-resource",r,{protocolVersion:e?.protocolVersion,metadataUrl:e?.resourceMetadataUrl});if(!n||n.status===404)throw await n?.body?.cancel(),new Error("Resource server does not implement OAuth 2.0 Protected Resource Metadata.");if(!n.ok)throw await n.body?.cancel(),new Error(`HTTP ${n.status} trying to load well-known OAuth protected resource metadata.`);return Kw.parse(await n.json())}async function wa(t,e,r=fetch){try{return await r(t,{headers:e})}catch(n){if(n instanceof TypeError)return e?wa(t,void 0,r):void 0;throw n}}function mb(t,e="",r={}){return e.endsWith("/")&&(e=e.slice(0,-1)),r.prependPathname?`${e}/.well-known/${t}`:`/.well-known/${t}${e}`}async function th(t,e,r=fetch){return await wa(t,{"MCP-Protocol-Version":e},r)}function _b(t,e){return!t||t.status>=400&&t.status<500&&e!=="/"}async function gb(t,e,r,n){const s=new URL(t),o=n?.protocolVersion??Hs;let i;if(n?.metadataUrl)i=new URL(n.metadataUrl);else{const c=mb(e,s.pathname);i=new URL(c,n?.metadataServerUrl??s),i.search=s.search}let a=await th(i,o,r);if(!n?.metadataUrl&&_b(a,s.pathname)){const c=new URL(`/.well-known/${e}`,s);a=await th(c,o,r)}return a}function vb(t){const e=typeof t=="string"?new URL(t):t,r=e.pathname!=="/",n=[];if(!r)return n.push({url:new URL("/.well-known/oauth-authorization-server",e.origin),type:"oauth"}),n.push({url:new URL("/.well-known/openid-configuration",e.origin),type:"oidc"}),n;let s=e.pathname;return s.endsWith("/")&&(s=s.slice(0,-1)),n.push({url:new URL(`/.well-known/oauth-authorization-server${s}`,e.origin),type:"oauth"}),n.push({url:new URL(`/.well-known/openid-configuration${s}`,e.origin),type:"oidc"}),n.push({url:new URL(`${s}/.well-known/openid-configuration`,e.origin),type:"oidc"}),n}async function yb(t,{fetchFn:e=fetch,protocolVersion:r=Hs}={}){const n={"MCP-Protocol-Version":r,Accept:"application/json"},s=vb(t);for(const{url:o,type:i}of s){const a=await wa(o,n,e);if(a){if(!a.ok){if(await a.body?.cancel(),a.status>=400&&a.status<500)continue;throw new Error(`HTTP ${a.status} trying to load ${i==="oauth"?"OAuth":"OpenID provider"} metadata from ${o}`)}return i==="oauth"?Qd.parse(await a.json()):Yw.parse(await a.json())}}}async function wb(t,{metadata:e,clientInformation:r,redirectUrl:n,scope:s,state:o,resource:i}){let a;if(e){if(a=new URL(e.authorization_endpoint),!e.response_types_supported.includes(_a))throw new Error(`Incompatible auth server: does not support response type ${_a}`);if(e.code_challenge_methods_supported&&!e.code_challenge_methods_supported.includes(ga))throw new Error(`Incompatible auth server: does not support code challenge method ${ga}`)}else a=new URL("/authorize",t);const c=await Yd(),u=c.code_verifier,l=c.code_challenge;return a.searchParams.set("response_type",_a),a.searchParams.set("client_id",r.client_id),a.searchParams.set("code_challenge",l),a.searchParams.set("code_challenge_method",ga),a.searchParams.set("redirect_uri",String(n)),o&&a.searchParams.set("state",o),s&&a.searchParams.set("scope",s),s?.includes("offline_access")&&a.searchParams.append("prompt","consent"),i&&a.searchParams.set("resource",i.href),{authorizationUrl:a,codeVerifier:u}}function bb(t,e,r){return new URLSearchParams({grant_type:"authorization_code",code:t,code_verifier:e,redirect_uri:String(r)})}async function rh(t,{metadata:e,tokenRequestParams:r,clientInformation:n,addClientAuthentication:s,resource:o,fetchFn:i}){const a=e?.token_endpoint?new URL(e.token_endpoint):new URL("/token",t),c=new Headers({"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json"});if(o&&r.set("resource",o.href),s)await s(c,r,a,e);else if(n){const l=e?.token_endpoint_auth_methods_supported??[],d=ab(n,l);cb(d,n,c,r)}const u=await(i??fetch)(a,{method:"POST",headers:c,body:r});if(!u.ok)throw await eh(u);return Qw.parse(await u.json())}async function $b(t,{metadata:e,clientInformation:r,refreshToken:n,resource:s,addClientAuthentication:o,fetchFn:i}){const a=new URLSearchParams({grant_type:"refresh_token",refresh_token:n}),c=await rh(t,{metadata:e,tokenRequestParams:a,clientInformation:r,addClientAuthentication:o,resource:s,fetchFn:i});return{refresh_token:n,...c}}async function Sb(t,e,{metadata:r,resource:n,authorizationCode:s,fetchFn:o}={}){const i=t.clientMetadata.scope;let a;if(t.prepareTokenRequest&&(a=await t.prepareTokenRequest(i)),!a){if(!s)throw new Error("Either provider.prepareTokenRequest() or authorizationCode is required");if(!t.redirectUrl)throw new Error("redirectUrl is required for authorization_code flow");const u=await t.codeVerifier();a=bb(s,u,t.redirectUrl)}const c=await t.clientInformation();return rh(e,{metadata:r,tokenRequestParams:a,clientInformation:c??void 0,addClientAuthentication:t.addClientAuthentication,resource:n,fetchFn:o})}async function kb(t,{metadata:e,clientMetadata:r,fetchFn:n}){let s;if(e){if(!e.registration_endpoint)throw new Error("Incompatible auth server: does not support dynamic client registration");s=new URL(e.registration_endpoint)}else s=new URL("/register",t);const o=await(n??fetch)(s,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)});if(!o.ok)throw await eh(o);return rb.parse(await o.json())}let Tb=class extends Error{constructor(e,r,n){super(`SSE error: ${r}`),this.code=e,this.event=n}},nh=class{constructor(e,r){this._url=e,this._resourceMetadataUrl=void 0,this._scope=void 0,this._eventSourceInit=r?.eventSourceInit,this._requestInit=r?.requestInit,this._authProvider=r?.authProvider,this._fetch=r?.fetch,this._fetchWithInit=Gd(r?.fetch,r?.requestInit)}async _authThenStart(){if(!this._authProvider)throw new mt("No auth provider");let e;try{e=await br(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})}catch(r){throw this.onerror?.(r),r}if(e!=="AUTHORIZED")throw new mt;return await this._startOrAuth()}async _commonHeaders(){const e={};if(this._authProvider){const n=await this._authProvider.tokens();n&&(e.Authorization=`Bearer ${n.access_token}`)}this._protocolVersion&&(e["mcp-protocol-version"]=this._protocolVersion);const r=uo(this._requestInit?.headers);return new Headers({...e,...r})}_startOrAuth(){const e=this?._eventSourceInit?.fetch??this._fetch??fetch;return new Promise((r,n)=>{this._eventSource=new Nn(this._url.href,{...this._eventSourceInit,fetch:async(s,o)=>{const i=await this._commonHeaders();i.set("Accept","text/event-stream");const a=await e(s,{...o,headers:i});if(a.status===401&&a.headers.has("www-authenticate")){const{resourceMetadataUrl:c,scope:u}=mo(a);this._resourceMetadataUrl=c,this._scope=u}return a}}),this._abortController=new AbortController,this._eventSource.onerror=s=>{if(s.code===401&&this._authProvider){this._authThenStart().then(r,n);return}const o=new Tb(s.code,s.message,s);n(o),this.onerror?.(o)},this._eventSource.onopen=()=>{},this._eventSource.addEventListener("endpoint",s=>{const o=s;try{if(this._endpoint=new URL(o.data,this._url),this._endpoint.origin!==this._url.origin)throw new Error(`Endpoint origin does not match connection origin: ${this._endpoint.origin}`)}catch(i){n(i),this.onerror?.(i),this.close();return}r()}),this._eventSource.onmessage=s=>{const o=s;let i;try{i=Er.parse(JSON.parse(o.data))}catch(a){this.onerror?.(a);return}this.onmessage?.(i)}})}async start(){if(this._eventSource)throw new Error("SSEClientTransport already started! If using Client class, note that connect() calls start() automatically.");return await this._startOrAuth()}async finishAuth(e){if(!this._authProvider)throw new mt("No auth provider");if(await br(this._authProvider,{serverUrl:this._url,authorizationCode:e,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new mt("Failed to authorize")}async close(){this._abortController?.abort(),this._eventSource?.close(),this.onclose?.()}async send(e){if(!this._endpoint)throw new Error("Not connected");try{const r=await this._commonHeaders();r.set("content-type","application/json");const n={...this._requestInit,method:"POST",headers:r,body:JSON.stringify(e),signal:this._abortController?.signal},s=await(this._fetch??fetch)(this._endpoint,n);if(!s.ok){const o=await s.text().catch(()=>null);if(s.status===401&&this._authProvider){const{resourceMetadataUrl:i,scope:a}=mo(s);if(this._resourceMetadataUrl=i,this._scope=a,await br(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new mt;return this.send(e)}throw new Error(`Error POSTing to endpoint (HTTP ${s.status}): ${o}`)}await s.body?.cancel()}catch(r){throw this.onerror?.(r),r}}setProtocolVersion(e){this._protocolVersion=e}};class sh extends TransformStream{constructor({onError:e,onRetry:r,onComment:n}={}){let s;super({start(o){s=Fd({onEvent:i=>{o.enqueue(i)},onError(i){e==="terminate"?o.error(i):typeof e=="function"&&e(i)},onRetry:r,onComment:n})},transform(o){s.feed(o)}})}}const Rb={initialReconnectionDelay:1e3,maxReconnectionDelay:3e4,reconnectionDelayGrowFactor:1.5,maxRetries:2};let Dr=class extends Error{constructor(e,r){super(`Streamable HTTP error: ${r}`),this.code=e}},Eb=class{constructor(e,r){this._hasCompletedAuthFlow=!1,this._url=e,this._resourceMetadataUrl=void 0,this._scope=void 0,this._requestInit=r?.requestInit,this._authProvider=r?.authProvider,this._fetch=r?.fetch,this._fetchWithInit=Gd(r?.fetch,r?.requestInit),this._sessionId=r?.sessionId,this._reconnectionOptions=r?.reconnectionOptions??Rb}async _authThenStart(){if(!this._authProvider)throw new mt("No auth provider");let e;try{e=await br(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})}catch(r){throw this.onerror?.(r),r}if(e!=="AUTHORIZED")throw new mt;return await this._startOrAuthSse({resumptionToken:void 0})}async _commonHeaders(){const e={};if(this._authProvider){const n=await this._authProvider.tokens();n&&(e.Authorization=`Bearer ${n.access_token}`)}this._sessionId&&(e["mcp-session-id"]=this._sessionId),this._protocolVersion&&(e["mcp-protocol-version"]=this._protocolVersion);const r=uo(this._requestInit?.headers);return new Headers({...e,...r})}async _startOrAuthSse(e){const{resumptionToken:r}=e;try{const n=await this._commonHeaders();n.set("Accept","text/event-stream"),r&&n.set("last-event-id",r);const s=await(this._fetch??fetch)(this._url,{method:"GET",headers:n,signal:this._abortController?.signal});if(!s.ok){if(await s.body?.cancel(),s.status===401&&this._authProvider)return await this._authThenStart();if(s.status===405)return;throw new Dr(s.status,`Failed to open SSE stream: ${s.statusText}`)}this._handleSseStream(s.body,e,!0)}catch(n){throw this.onerror?.(n),n}}_getNextReconnectionDelay(e){if(this._serverRetryMs!==void 0)return this._serverRetryMs;const r=this._reconnectionOptions.initialReconnectionDelay,n=this._reconnectionOptions.reconnectionDelayGrowFactor,s=this._reconnectionOptions.maxReconnectionDelay;return Math.min(r*Math.pow(n,e),s)}_scheduleReconnection(e,r=0){const n=this._reconnectionOptions.maxRetries;if(r>=n){this.onerror?.(new Error(`Maximum reconnection attempts (${n}) exceeded.`));return}const s=this._getNextReconnectionDelay(r);this._reconnectionTimeout=setTimeout(()=>{this._startOrAuthSse(e).catch(o=>{this.onerror?.(new Error(`Failed to reconnect SSE stream: ${o instanceof Error?o.message:String(o)}`)),this._scheduleReconnection(e,r+1)})},s)}_handleSseStream(e,r,n){if(!e)return;const{onresumptiontoken:s,replayMessageId:o}=r;let i,a=!1,c=!1;(async()=>{try{const l=e.pipeThrough(new TextDecoderStream).pipeThrough(new sh({onRetry:_=>{this._serverRetryMs=_}})).getReader();for(;;){const{value:_,done:m}=await l.read();if(m)break;if(_.id&&(i=_.id,a=!0,s?.(_.id)),!!_.data&&(!_.event||_.event==="message"))try{const g=Er.parse(JSON.parse(_.data));cn(g)&&(c=!0,o!==void 0&&(g.id=o)),this.onmessage?.(g)}catch(g){this.onerror?.(g)}}(n||a)&&!c&&this._abortController&&!this._abortController.signal.aborted&&this._scheduleReconnection({resumptionToken:i,onresumptiontoken:s,replayMessageId:o},0)}catch(l){if(this.onerror?.(new Error(`SSE stream disconnected: ${l}`)),(n||a)&&!c&&this._abortController&&!this._abortController.signal.aborted)try{this._scheduleReconnection({resumptionToken:i,onresumptiontoken:s,replayMessageId:o},0)}catch(_){this.onerror?.(new Error(`Failed to reconnect: ${_ instanceof Error?_.message:String(_)}`))}}})()}async start(){if(this._abortController)throw new Error("StreamableHTTPClientTransport already started! If using Client class, note that connect() calls start() automatically.");this._abortController=new AbortController}async finishAuth(e){if(!this._authProvider)throw new mt("No auth provider");if(await br(this._authProvider,{serverUrl:this._url,authorizationCode:e,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new mt("Failed to authorize")}async close(){this._reconnectionTimeout&&(clearTimeout(this._reconnectionTimeout),this._reconnectionTimeout=void 0),this._abortController?.abort(),this.onclose?.()}async send(e,r){try{const{resumptionToken:n,onresumptiontoken:s}=r||{};if(n){this._startOrAuthSse({resumptionToken:n,replayMessageId:_i(e)?e.id:void 0}).catch(p=>this.onerror?.(p));return}const o=await this._commonHeaders();o.set("content-type","application/json"),o.set("accept","application/json, text/event-stream");const i={...this._requestInit,method:"POST",headers:o,body:JSON.stringify(e),signal:this._abortController?.signal},a=await(this._fetch??fetch)(this._url,i),c=a.headers.get("mcp-session-id");if(c&&(this._sessionId=c),!a.ok){const p=await a.text().catch(()=>null);if(a.status===401&&this._authProvider){if(this._hasCompletedAuthFlow)throw new Dr(401,"Server returned 401 after successful authentication");const{resourceMetadataUrl:_,scope:m}=mo(a);if(this._resourceMetadataUrl=_,this._scope=m,await br(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new mt;return this._hasCompletedAuthFlow=!0,this.send(e)}if(a.status===403&&this._authProvider){const{resourceMetadataUrl:_,scope:m,error:g}=mo(a);if(g==="insufficient_scope"){const f=a.headers.get("WWW-Authenticate");if(this._lastUpscopingHeader===f)throw new Dr(403,"Server returned 403 after trying upscoping");if(m&&(this._scope=m),_&&(this._resourceMetadataUrl=_),this._lastUpscopingHeader=f??void 0,await br(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetch})!=="AUTHORIZED")throw new mt;return this.send(e)}}throw new Dr(a.status,`Error POSTing to endpoint: ${p}`)}if(this._hasCompletedAuthFlow=!1,this._lastUpscopingHeader=void 0,a.status===202){await a.body?.cancel(),Sv(e)&&this._startOrAuthSse({resumptionToken:void 0}).catch(p=>this.onerror?.(p));return}const l=(Array.isArray(e)?e:[e]).filter(p=>"method"in p&&"id"in p&&p.id!==void 0).length>0,d=a.headers.get("content-type");if(l)if(d?.includes("text/event-stream"))this._handleSseStream(a.body,{onresumptiontoken:s},!1);else if(d?.includes("application/json")){const p=await a.json(),_=Array.isArray(p)?p.map(m=>Er.parse(m)):[Er.parse(p)];for(const m of _)this.onmessage?.(m)}else throw await a.body?.cancel(),new Dr(-1,`Unexpected content type: ${d}`);else await a.body?.cancel()}catch(n){throw this.onerror?.(n),n}}get sessionId(){return this._sessionId}async terminateSession(){if(this._sessionId)try{const e=await this._commonHeaders(),r={...this._requestInit,method:"DELETE",headers:e,signal:this._abortController?.signal},n=await(this._fetch??fetch)(this._url,r);if(await n.body?.cancel(),!n.ok&&n.status!==405)throw new Dr(n.status,`Failed to terminate session: ${n.statusText}`);this._sessionId=void 0}catch(e){throw this.onerror?.(e),e}}setProtocolVersion(e){this._protocolVersion=e}get protocolVersion(){return this._protocolVersion}async resumeStream(e,r){await this._startOrAuthSse({resumptionToken:e,onresumptiontoken:r?.onresumptiontoken})}};const Pb="mcp";let xb=class{constructor(e){this._url=e}start(){if(this._socket)throw new Error("WebSocketClientTransport already started! If using Client class, note that connect() calls start() automatically.");return new Promise((e,r)=>{this._socket=new WebSocket(this._url,Pb),this._socket.onerror=n=>{const s="error"in n?n.error:new Error(`WebSocket error: ${JSON.stringify(n)}`);r(s),this.onerror?.(s)},this._socket.onopen=()=>{e()},this._socket.onclose=()=>{this.onclose?.()},this._socket.onmessage=n=>{let s;try{s=Er.parse(JSON.parse(n.data))}catch(o){this.onerror?.(o);return}this.onmessage?.(s)}})}async close(){this._socket?.close()}send(e){return new Promise((r,n)=>{if(!this._socket){n(new Error("Not connected"));return}this._socket?.send(JSON.stringify(e)),r()})}};const or=ht;(function(t,e){const r=ht,n=ht,s=t();for(;;)try{if(parseInt(r(403))/1+-parseInt(r(411))/2*(-parseInt(n(406))/3)+-parseInt(n(425))/4*(parseInt(r(387))/5)+-parseInt(n(426))/6+parseInt(n(395))/7*(-parseInt(r(419))/8)+-parseInt(r(413))/9+parseInt(n(400))/10===e)break;s.push(s.shift())}catch{s.push(s.shift())}})(go,-118057+3521*-35+-2099*-233);const oh=()=>{const t=ht,e=ht,r={};r[t(420)]="3|0|2|1|4",r.vQYJZ=function(i,a){return i!==a},r[e(394)]=e(414),r.ktWqD=function(i,a){return i!==a},r[t(424)]=t(391);const n=r,s=n[e(420)].split("|");let o=859*2+-3*-1039+-4835*1;for(;;){switch(s[o++]){case"0":if(n[e(407)](typeof window,"undefined"))return window;continue;case"1":if(n.vQYJZ(typeof self,n.NZmUq))return self;continue;case"2":if(n[e(405)](typeof global,"undefined"))return global;continue;case"3":if(n[e(405)](typeof globalThis,n[t(394)]))return globalThis;continue;case"4":return Function(n[t(424)])()}break}},Ib=(t,e,r)=>{const n=ht,s=ht,o={};o.eOzBp=function(a,c){return a!==c},o.ooaJk="undefined",o[n(402)]=function(a,c){return a===c},o[n(421)]="function";const i=o;i[s(389)](typeof window,i.ooaJk)?t[s(423)](e,"*",r):n(423)in t&&i.pTvSc(typeof t[s(423)],i[n(421)])&&t.postMessage(e,r)},Cb=(t,e)=>{const r=ht,n=ht,s={};s.nTCfA=function(i,a){return i in a},s[r(390)]="addEventListener",s[r(385)]=function(i,a){return i===a},s[r(409)]="function",s.VaHpd=n(392),s[n(384)]=r(417),s.FPOYW=function(i,a){return i!==a};const o=s;o.nTCfA(o.ogKey,t)&&o[n(385)](typeof t.addEventListener,o[n(409)])?t[n(386)](o.VaHpd,e):o[n(384)]in t&&o[r(398)](typeof t[n(417)],r(414))&&(t.onmessage=e)};class _o{constructor(e){this._port=e}async[or(401)](){const e=or,r=or;this[e(422)]&&(this[r(422)].onmessage=n=>{var s,o;const i=e;try{const a=Er.parse(n.data.message);(s=this.onmessage)==null||s.call(this,a,n[i(412)][i(428)])}catch(a){const c=new Error("MessageChannel failed to parse message: "+a);(o=this[i(383)])==null||o.call(this,c)}},this._port.onmessageerror=n=>{var s;const o=r,i=new Error("MessageChannel transport error: "+JSON[o(415)](n));(s=this.onerror)==null||s.call(this,i)},this[r(422)].start())}async send(e,r){const n={EoBZE:function(s){return s()},leEiG:function(s,o){return s instanceof o},cDUwk:function(s,o){return s(o)}};return new Promise((s,o)=>{var i;const a=ht,c=ht;try{const u={};u[a(404)]=r?.[a(404)];const l={};l[a(392)]=e,l.extra=u,this._port&&this._port[c(423)](l),n[a(399)](s)}catch(u){const l=n.leEiG(u,Error)?u:new Error(n.cDUwk(String,u));(i=this.onerror)==null||i.call(this,l),o(l)}})}async close(){var e,r;const n=or,s=or;(e=this._port)==null||e[n(393)](),this[n(422)]=void 0,(r=this[s(408)])==null||r.call(this)}}class ba extends _o{constructor(e,r=oh()){const n=or,s={lSpBh:function(i,a,c,u){return i(a,c,u)}};super(),this._endpoint=e,this._globalObject=r;const o=new MessageChannel;this._port=o[n(410)],s[n(418)](Ib,this._globalObject,{endpoint:this[n(397)]},[o[n(429)]])}}class $a extends _o{constructor(e,r=oh()){const n=or,s=or,o={HITdC:function(i,a){return i===a},QdDxM:function(i){return i()},jowPp:function(i,a,c){return i(a,c)}};super(),this[n(397)]=e,this[s(388)]=r,this[s(416)]=new Promise(i=>{const a=n,c={XlglK:function(u,l){return o.HITdC(u,l)},pXlad:function(u){return o.QdDxM(u)}};o[a(427)](Cb,this._globalObject,u=>{const l=a,d=a;u[l(412)]&&c.XlglK(u.data[d(396)],this._endpoint)&&(this[l(422)]=u[d(430)][-3036+-1518*-2],c.pXlad(i))})})}async listen(){return this._listen}}function go(){const t=["message","close","NZmUq","177464iLQCGm","endpoint","_endpoint","FPOYW","EoBZE","3022630ngzRBs","start","pTvSc","272809yMhhPJ","authInfo","ktWqD","21849KofsKk","vQYJZ","onclose","mkHJS","port1","22dUTKmE","data","608229RXNlUs","undefined","stringify","_listen","onmessage","lSpBh","8FmlYyF","XwdDB","cHbAW","_port","postMessage","kFtNB","72572mbPnfL","689424jqaGZE","jowPp","extra","port2","ports","onerror","Fzdib","mkuHv","addEventListener","55juYkZZ","_globalObject","eOzBp","ogKey","return this"];return go=function(){return t},go()}function ht(t,e){const r=go();return ht=function(n,s){return n=n-(17227+1*-16844),r[n]},ht(t,e)}const Ob=()=>{const t=new MessageChannel;return[new _o(t.port1),new _o(t.port2)]};(function(t,e){const r=Pe,n=Pe,s=t();for(;;)try{if(parseInt(r(452))/1*(parseInt(n(441))/2)+parseInt(n(434))/3*(-parseInt(n(418))/4)+parseInt(r(459))/5+parseInt(r(482))/6*(-parseInt(r(479))/7)+-parseInt(r(458))/8*(parseInt(r(457))/9)+-parseInt(n(416))/10+-parseInt(r(450))/11*(-parseInt(r(433))/12)===e)break;s.push(s.shift())}catch{s.push(s.shift())}})(vo,-411935*1+228107+208149*2);const Nb=async(t,e,r)=>{var n;const s=Pe,o=Pe,i={};i.VRyiJ="tools/list",i.VkPYu="tools/call",i[s(475)]=s(411),i.SoCaE="resources/templates/list",i[o(484)]="resources/read",i[s(461)]="prompts/get",i.srIIC=o(477),i[o(436)]=o(478),i[o(442)]=s(437),i.dEmVs=s(465);const a=i,{id:c,method:u,params:l}=r;let d={};switch(u){case a.VRyiJ:d=await e.listTools(l);break;case a.VkPYu:d=await e.callTool(l);break;case a.fgMSD:d=await e.listResources(l);break;case a[o(466)]:d=await e.listResourceTemplates(l);break;case a.sthgI:d=await e[s(455)](l);break;case o(486):d=await e.subscribeResource(l);break;case s(410):d=await e.unsubscribeResource(l);break;case a[o(461)]:d=await e[o(414)](l);break;case a[s(412)]:d=await e[s(491)](l);break;case a[s(436)]:d=await e[s(478)]();break;case a.kkNqg:d=await e.complete(l);break;case s(464):d=await e.setLoggingLevel(l?.[o(443)]);break}const p={};p.result=d,p.jsonrpc=a[o(472)],p.id=c,await((n=t?.[o(488)])==null?void 0:n[s(460)](p))},Ab=async(t,e,r)=>{var n;const s=Pe,o=Pe,i={};i[s(487)]=o(462),i.ypHTC="ping",i.fPExS=s(465);const a=i,{id:c,method:u,params:l}=r;let d={};switch(u){case"roots/list":const _={};_.method=u,_[o(446)]=l,d=await e[s(469)](_,hd);break;case"sampling/createMessage":const m={};m[s(481)]=u,m[s(446)]=l,d=await e.request(m,Ai);break;case a[s(487)]:const g={};g.method=u,g[o(446)]=l,d=await e.request(g,Mi);break;case a.ypHTC:const f={};f.method=u,d=await e.request(f,pr);break}const p={};return p.result=d,p.jsonrpc=a.fPExS,p.id=c,await((n=t?.transport)==null?void 0:n.send(p)),d};function Pe(t,e){const r=vo();return Pe=function(n,s){return n=n-(-8023+4*-2344+-17809*-1),r[n]},Pe(t,e)}const Mb=(t,e)=>{const r=Pe,n=Pe,s={vYlhn:function(i,a){return i===a},DhPFX:r(470),NYVNC:function(i,a,c,u){return i(a,c,u)},yfZbw:"2.0"},o=t._onrequest;t[n(463)]=async(i,a)=>{var c,u,l,d,p;const _=n,m=r,{id:g,method:f}=i;try{s[_(451)](f,s.DhPFX)?await o.call(t,i,a):await s[m(474)](Nb,t,e,i)}catch(v){const{code:h,message:w,data:$}=v;try{if(h){const b={};b[m(485)]=h,b[_(422)]=w,b.data=$;const S={};S[m(448)]=b,S.jsonrpc=s[_(417)],S.id=g,await((c=t?.transport)==null?void 0:c[m(460)](S))}else(l=(u=t?.transport)==null?void 0:u.onerror)==null||l.call(u,v)}catch(b){(p=(d=t?.transport)==null?void 0:d.onerror)==null||p.call(d,b)}}}},jb=(t,e)=>{const r=Pe,n=Pe,s={};s[r(476)]=r(439),s[r(431)]=function(i,a){return i!==a},s.UPdQt="notifications/cancelled";const o=s;t[r(421)]=async i=>{var a,c;const u=r,l=n,{method:d,params:p}=i;if(d!==o[u(476)]&&(o.QWYMz(d,o.UPdQt)||p?.[l(490)]))try{await e[u(445)](i)}catch(_){(c=(a=t?.[u(488)])==null?void 0:a[u(480)])==null||c.call(a,_)}}},qb=(t,e)=>async r=>{var n,s,o,i,a;const c=Pe,u=Pe,l={TJhyV:function(d,p,_,m){return d(p,_,m)},MMNTY:c(465)};try{return await l.TJhyV(Ab,t,e,r)}catch(d){const{code:p,message:_,data:m}=d;try{if(p){const g={};g.code=p,g[c(422)]=_,g[u(419)]=m;const f={};f[c(448)]=g,f[c(424)]=l.MMNTY,f.id=r.id,await((n=t?.transport)==null?void 0:n[u(460)](f))}else(o=(s=t?.transport)==null?void 0:s[c(480)])==null||o.call(s,d)}catch(g){(a=(i=t?.[c(488)])==null?void 0:i.onerror)==null||a.call(i,g)}}},zb=(t,e)=>async r=>{var n,s,o;const i=Pe,a=Pe,c={};c.xmcLM=function(p,_){return p!==_},c.xSWLt="notifications/initialized",c[i(420)]=a(453);const u=c,{method:l,params:d}=r;if(u.xmcLM(l,u.xSWLt)&&(u.xmcLM(l,u[a(420)])||d?.[a(490)]))try{const p={...r};p.jsonrpc=i(465),await((n=e?.[i(488)])==null?void 0:n.send(p))}catch(p){(o=(s=t?.transport)==null?void 0:s.onerror)==null||o.call(s,p)}};function vo(){const t=["JMaxV","cNneM","completion/complete","addResponseListener","notifications/initialized","call","570686biwZQB","kkNqg","level","addNotificationListener","notification","params","addListener","error","_onresponse","164054EGcqjc","vYlhn","1PDRdga","notifications/cancelled","_requestHandlers","readResource","FjTAY","1782ueLDLp","4496TJFZWc","1767765yPcVQJ","send","HefvS","elicitation/create","_onrequest","logging/setLevel","2.0","SoCaE","HucXo","function","request","initialize","push","dEmVs","addRequestListener","NYVNC","fgMSD","CSjwA","prompts/list","ping","35pZrnNj","onerror","method","238086YifXhM","get","sthgI","code","resources/subscribe","sttJM","transport","jsmFN","forward","listPrompts","resources/unsubscribe","resources/list","srIIC","originalOnResponse","getPrompt","indexOf","3653560KcjkMk","yfZbw","4SAWlvk","data","rCDHw","_onnotification","message","UlqiY","jsonrpc","yCyFn","clearNotificationListener","VWsxO","name","UynHf","length","QWYMz","fallbackRequestHandler","492jTClKn","1028589HsbHVQ"];return vo=function(){return t},vo()}const Ub=(t,e)=>async r=>{var n,s,o,i,a,c;const u=Pe,l=Pe,d={};d.kSvAZ=u(465);const p=d;try{await((n=e?.[l(488)])==null?void 0:n[l(460)](r))}catch(_){const{code:m,message:g,data:f}=_;try{if(m){const v={};v.code=m,v.message=g,v.data=f;const h={};h.error=v,h[l(424)]=p.kSvAZ,h.id=r.id,await((s=t?.transport)==null?void 0:s.send(h))}else(i=(o=t?.transport)==null?void 0:o[u(480)])==null||i.call(o,_)}catch(v){(c=(a=t?.[u(488)])==null?void 0:a[l(480)])==null||c.call(a,v)}}},Sa=()=>{const t=Pe,e={rgPZO:function(c,u){return c!==u},VWsxO:function(c,u){return c(u)},FjTAY:"function"},r=[],n=(c,u)=>{const l=Pe;if(u){const d=[];for(const p of r)try{d.push(p(c,u))}catch{}for(const p of d)if(e.rgPZO(p,null))return p}else for(const d of r)try{e[l(427)](d,c)}catch{}},s=c=>{const u=Pe,l=Pe;typeof c===e[u(456)]&&!r.includes(c)&&r[l(471)](c)},o=c=>{const u=Pe,l=r[u(415)](c);l!==-1&&r.splice(l,-17591+6*2932)},i=()=>{const c=Pe;r[c(430)]=-505*7+1322+2213},a={};return a.handleListener=n,a[t(447)]=s,a.removeListener=o,a.clearListener=i,a},Lb=t=>{const e=Pe,r=Pe,n={UlqiY:function(s){return s()},jsmFN:function(s){return s()}};{const{handleListener:s,addListener:o,removeListener:i,clearListener:a}=n[e(423)](Sa);t._onresponse=s,t[r(438)]=o,t.removeResponseListener=i,t.clearResponseListener=a}{const{handleListener:s,addListener:o,removeListener:i,clearListener:a}=n[e(489)](Sa);t[e(432)]=s,t[r(473)]=o,t.removeRequestListener=i,t.clearRequestListener=a}{const{handleListener:s,addListener:o,removeListener:i,clearListener:a}=n.jsmFN(Sa);t.fallbackNotificationHandler=s,t[e(444)]=o,t.removeNotificationListener=i,t[r(426)]=a}},Zb=(t,{beforeInit:e,afterInit:r}={})=>{const n=Pe,s=Pe,o={HucXo:function(a,c){return a===c},HicFO:n(468),JMaxV:function(a){return a()},DclXr:function(a,c){return a(c)},UynHf:function(a,c){return a===c},yCyFn:function(a){return a()}},i=new Map(t._notificationHandlers);t[n(454)].clear(),t._notificationHandlers.clear(),o.HucXo(typeof e,o.HicFO)&&o[n(435)](e),o[n(467)](t[n(449)][s(428)],n(449))&&(t[s(413)]=t[s(449)]),o.DclXr(Lb,t),t[s(438)](a=>{const c=n;t.originalOnResponse[c(440)](t,a)}),o[n(429)](typeof r,o.HicFO)&&o[s(425)](r),t[s(444)](a=>{const c=s,{method:u}=a,l=i[c(483)](u);o[c(467)](typeof l,"function")&&l(a)})},Db=Ft;(function(t,e){const r=Ft,n=Ft,s=t();for(;;)try{if(parseInt(r(215))/1*(-parseInt(n(217))/2)+parseInt(r(216))/3+parseInt(r(210))/4*(parseInt(n(223))/5)+-parseInt(n(214))/6*(parseInt(n(220))/7)+parseInt(n(212))/8*(parseInt(r(228))/9)+parseInt(r(219))/10+parseInt(r(222))/11*(parseInt(r(224))/12)===e)break;s.push(s.shift())}catch{s.push(s.shift())}})(yo,995159+-6*-266138+-1619768);const Vb=()=>{const t=Ft,e=Ft,r={};r.svuxn=function(s,o){return s&o},r.ZUPdr=function(s,o){return s===o},r[t(227)]=function(s,o){return s===o},r.SpRzi="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx";const n=r;return n[e(227)](typeof crypto,"object")&&crypto[t(211)]?crypto.randomUUID():n.SpRzi.replace(/[xy]/g,s=>{const o=t,i=n.svuxn(crypto.getRandomValues(new Uint8Array(-3798+8571*-1+12370))[0],-8324+8339*1);return(n[o(225)](s,"x")?i:n[o(209)](i,-12998+-1*-13001)|813*10+-3707+883*-5).toString(-1*-1851+6493+-8328)})},Hb=t=>{const e=Ft,r=Ft,n=new Uint8Array(t);return crypto[e(221)](n),Array[r(218)](n,s=>s[r(226)](11424+4*-2852).padStart(8950+2237*-4,"0"))[e(213)]("")},ir={};ir[Db(211)]=Vb,ir.randomBytes=Hb;function Ft(t,e){const r=yo();return Ft=function(n,s){return n=n-(-7373+7187*1+395),r[n]},Ft(t,e)}function yo(){const t=["join","2500590yHdCUG","3CzpgOE","219762yRRBUK","592022JqIdxi","from","6033730pSHJFF","28gKZiuO","getRandomValues","147169GUBreL","5fFOMNB","1140KVOWlq","ZUPdr","toString","DBGzc","45351XtLuDF","svuxn","9892WpQPGF","randomUUID","2504EaskHQ"];return yo=function(){return t},yo()}function Wt(t,e){const r=wo();return Wt=function(n,s){return n=n-(-1483*3+-5564+20*513),r[n]},Wt(t,e)}const Rt=Wt,An=Wt;(function(t,e){const r=Wt,n=Wt,s=t();for(;;)try{if(parseInt(r(302))/1+-parseInt(n(249))/2+-parseInt(r(291))/3+-parseInt(r(292))/4*(parseInt(r(264))/5)+-parseInt(n(273))/6*(parseInt(r(266))/7)+parseInt(r(300))/8*(parseInt(r(269))/9)+parseInt(n(255))/10*(parseInt(r(284))/11)===e)break;s.push(s.shift())}catch{s.push(s.shift())}})(wo,-4*308317+753182*2+658196);const Fb=(t,e)=>{const r=Wt,n=Wt,s={olCWX:function(c,u,l){return c(u,l)},sfXDX:function(c,u,l){return c(u,l)},ksWFu:function(c,u,l){return c(u,l)}};s[r(283)](Mb,t,e),jb(t,e);const o=s[n(283)](qb,e,t),i=s[n(294)](Ub,e,t),a=s[r(277)](zb,e,t);e.addRequestListener(o),e.addResponseListener(i),e[n(287)](a),t.onclose=()=>{const c=r,u=n;e[c(247)](o),e.removeResponseListener(i),e[u(252)](a)}},ka=(t,e,r)=>{const n={QhPqi:function(i,a){return i instanceof a},AIICR:"close",Qalmc:function(i,a,c){return i(a,c)}},s=()=>{var i;n.QhPqi(r,nh)&&((i=r._eventSource)==null||i.addEventListener(n.AIICR,()=>{var a;(a=r[Wt(295)])==null||a.close()})),n.Qalmc(Fb,t,e)},o={};o.afterInit=s,n.Qalmc(Zb,e,o)},ih=(t,e=ir[Rt(299)]())=>{const r=Rt,n=Rt,s={RVabx:function(l,d,p){return l(d,p)},crCTs:"include"},o={};o["sse-session-id"]=e;const i=o,a={};a["sse-session-id"]=e;const c={};c.headers=a,c.credentials=s[r(304)];const u={requestInit:c,eventSourceInit:{async fetch(l,d){const p=r,_=r,m=new Headers(d?.[p(268)]||{});Object.entries(i).forEach(([f,v])=>{m.set(f,v)});const g={...d};return g.headers=m,s[_(279)](fetch,l,g)},withCredentials:!0}};return t&&(u[r(280)].headers.Authorization="Bearer "+t,i.Authorization=n(256)+t),u},ah=(t,e=ir[Rt(299)]())=>{const r=An,n=Rt,s={};s[r(271)]="include";const o=s,i={};i["stream-session-id"]=e;const a={};a[n(268)]=i,a.credentials=o[r(271)];const c={};c.requestInit=a;const u=c;return t&&(u[n(280)][r(268)][n(301)]=r(256)+t),u},Ta=async(t,e,r)=>{const n=Rt,s=Rt,o={rRtFD:function(a){return a()},ToRAF:function(a,c){return a instanceof c}},i=o[n(276)](r);try{return await t[s(260)](i),i}catch(a){if(o[n(275)](a,mt)){const c=await e();return await i[n(257)](c),await Ta(t,e,r)}else throw a}},ch=(t,e)=>{const r=An,n=An,s={};s[r(267)]=function(i,a){return i in a},s.timcZ="waitForOAuthCode",s[r(253)]=function(i,a){return i===a},s.ufiEQ=r(285),s[n(250)]=r(293);const o=s;if(o.oGmBG(o[r(258)],t))return t[n(278)];if(o[n(253)](typeof e,o.ufiEQ))return e;throw new Error(o.daYBw)};function wo(){const t=["oGmBG","headers","1233BqDPfE","eventSourceInit","jmVYh","wfHUn","1336686qzpbXm","_endpoint","ToRAF","rRtFD","ksWFu","waitForOAuthCode","RVabx","requestInit","mcp-sse-proxy-client","CfBXU","olCWX","341WrxLOu","function","sessionId","addNotificationListener","version","GKDjq","roots","5390433vAXkON","4NpGpPF","waitForOAuthCode need to be provided when authProvider is provided","sfXDX","_eventSource","PdsSn","get","sampling","randomUUID","4064jocfPO","Authorization","452565rqIeHi","elicitation","crCTs","authProvider","removeRequestListener","1.0.0","104070FoHgyi","daYBw","capabilities","removeNotificationListener","lauIp","listChanged","1255910ovFXHu","Bearer ","finishAuth","timcZ","eZwNI","connect","JzpWy","tUMle","kdowC","379385gxVFVP","&token=","49TIzdXg"];return wo=function(){return t},wo()}const Wb=async t=>{const e=An,r=Rt,n={GKDjq:function(j,F,q){return j(F,q)},JzpWy:e(281),mcbiU:"1.0.0",CfBXU:function(j){return j()},kdowC:function(j,F,q,W){return j(F,q,W)},KkViY:"sessionId"},{client:s,url:o,token:i,sessionId:a,authProvider:c,requestInit:u,eventSourceInit:l,waitForOAuthCode:d}=t,p={};p[r(305)]=c,p.requestInit=u,p.eventSourceInit=l;const _=p,m=a||ir[r(299)](),g=n[e(289)](ih,i,m);if(u){const j={...g.requestInit,...u};j[r(268)]={...g[r(280)][e(268)],...u.headers},_.requestInit=j}else _.requestInit=g[e(280)];if(l){const j={...g[e(270)],...l};_.eventSourceInit=j}else _.eventSourceInit=g[e(270)];const f={};f[e(254)]=!0;const v={};v.roots=f,v[e(298)]={},v[r(303)]={};const h=v,w={};w.name=n[r(261)],w[e(288)]=n.mcbiU;const $={};$[e(251)]=h;const b=new Wi(w,$),S=()=>new nh(new URL(o),_);let T=n[e(282)](S);if(c){const j=ch(c,d);T=await n[e(263)](Ta,b,j,S)}else await b.connect(T);ka(b,s,T),T.sessionId=T[r(274)].searchParams[e(297)](n.KkViY);const N={};return N.transport=T,N.sessionId=T[r(286)],N},Jb=async t=>{const e=An,r=Rt,n={wfHUn:function(j,F,q){return j(F,q)},tUMle:"mcp-stream-proxy-client",omKPe:e(248),rSiEq:function(j){return j()},PdsSn:function(j,F,q,W){return j(F,q,W)}},{client:s,url:o,token:i,sessionId:a,authProvider:c,requestInit:u,reconnectionOptions:l,waitForOAuthCode:d}=t,p={};p.authProvider=c,p.requestInit=u,p.reconnectionOptions=l;const _=p,m=a||ir.randomUUID(),g=n[r(272)](ah,i,m);if(u){const j={...g[e(280)],...u};j.headers={...g.requestInit[e(268)],...u.headers},_.requestInit=j}else _[r(280)]=g[r(280)];const f={};f[r(254)]=!0;const v={};v.roots=f,v[e(298)]={},v[e(303)]={};const h=v,w={};w.name=n[e(262)],w.version=n.omKPe;const $={};$.capabilities=h;const b=new Wi(w,$),S=()=>new Eb(new URL(o),_);let T=n.rSiEq(S);if(c){const j=n[e(272)](ch,c,d);T=await n[e(296)](Ta,b,j,S)}else await b[e(260)](T);n.PdsSn(ka,b,s,T);const N={};return N.transport=T,N[r(286)]=T[r(286)],N},Bb=async t=>{const e=Rt,r=Rt,n={eZwNI:function(v,h,w,$){return v(h,w,$)}},{client:s,url:o,token:i,sessionId:a}=t,c={};c[e(254)]=!0;const u={};u[r(290)]=c,u.sampling={},u.elicitation={};const l=u,d={};d.name="mcp-socket-proxy-client",d.version=r(248);const p={};p[r(251)]=l;const _=new Wi(d,p),m=a||ir[r(299)](),g=new xb(new URL(o+"?sessionId="+m+r(265)+i));await _.connect(g),n[e(259)](ka,_,s,g);const f={};return f.transport=g,f[r(286)]=m,f},ar=Et,Mn=Et;(function(t,e){const r=Et,n=Et,s=t();for(;;)try{if(parseInt(r(216))/1+-parseInt(n(219))/2+-parseInt(r(203))/3*(-parseInt(n(204))/4)+-parseInt(n(199))/5*(parseInt(r(193))/6)+-parseInt(r(211))/7*(-parseInt(r(192))/8)+-parseInt(n(221))/9+parseInt(n(201))/10*(parseInt(r(220))/11)===e)break;s.push(s.shift())}catch{s.push(s.shift())}})(bo,1297719+-42747*-22+-1289197);function Et(t,e){const r=bo();return Et=function(n,s){return n=n-(-4158*1+-2*581+-1*-5510),r[n]},Et(t,e)}const Kb=()=>ir.randomBytes(-8746+-382*-23);class Gb{constructor(e){const r=Et,n=Et,s={HbwOh:function(l){return l()}};this._callBackPromise={};const{clientMetadata:o,state:i,redirectCallback:a,getAuthCodeByState:c,waitForOAuthCode:u}=e;this._clientMetadata=o,this[r(206)]=o.redirect_uris[-10*629+1*7646+-1356],this[n(197)]=i||s.HbwOh(Kb),this._redirectCallback=a||this[n(202)],this[n(195)]=c||this[r(191)],this.waitForOAuthCode=u||this.waitForOAuthCodeFunction()}async redirectCallbackFunction(e){var r,n,s,o,i,a;const c=Et,u=Et,l={};l[c(198)]="GET";const d=await fetch(e,l);!d.ok&&((n=(r=this[u(207)])[u(196)])==null||n.call(r,c(208)+d[u(205)]));const p=await this[u(195)](this._redirectUrl,this[c(197)]);if(!p.ok){(o=(s=this[c(207)]).reject)==null||o.call(s,"Failed to fetch auth code: "+p[u(205)]);return}const _=await p.json();(a=(i=this._callBackPromise).resolve)==null||a.call(i,_.code)}async[ar(191)](e,r){const n=ar,s={};s.xAOmI="POST";const o=s,i={};i["Content-Type"]=n(217);const a={};return a.state=r,fetch(e,{method:o.xAOmI,headers:i,body:new URLSearchParams(a)})}waitForOAuthCodeFunction(){const e=this._callBackPromise;return()=>new Promise((r,n)=>{const s=Et;e.resolve=r,e[s(196)]=n})}get redirectUrl(){return this[ar(206)]}get[Mn(190)](){return this._clientMetadata}[ar(213)](){return this[ar(197)]}[Mn(218)](){return this[Mn(200)]}[ar(194)](e){this._clientInformation=e}tokens(){return this[Mn(210)]}saveTokens(e){const r=Mn;this[r(210)]=e}redirectToAuthorization(e){this._redirectCallback(e)}saveCodeVerifier(e){this._codeVerifier=e}[ar(212)](){const e=ar,r={};r[e(215)]=e(214);const n=r;if(!this[e(209)])throw new Error(n.mMdVl);return this[e(209)]}}function bo(){const t=["370aKMzOb","redirectCallbackFunction","6AWGiLu","697420WEpDtk","statusText","_redirectUrl","_callBackPromise","Failed to redirect: ","_codeVerifier","_tokens","21ofrYNd","codeVerifier","state","No code verifier saved","mMdVl","1546908KURscU","application/x-www-form-urlencoded","clientInformation","2551694UzDoIS","571637jVsNJQ","4355271orhxAD","clientMetadata","getAuthCodeByStateFunction","1400360ybYjeP","30zRTJNb","saveClientInformation","_getAuthCodeByState","reject","_state","method","1634810cQPomO","_clientInformation"];return bo=function(){return t},bo()}(function(t,e){for(var r=So,n=So,s=t();;)try{var o=parseInt(r(291))/1+-parseInt(r(295))/2*(parseInt(r(288))/3)+parseInt(r(290))/4*(parseInt(r(296))/5)+-parseInt(n(289))/6+parseInt(r(293))/7*(-parseInt(n(294))/8)+parseInt(n(287))/9+parseInt(n(292))/10;if(o===e)break;s.push(s.shift())}catch{s.push(s.shift())}})($o,262*-2438+1346066*-1+2*1373311);function $o(){var t=["279100FsqxFu","7326315yxcNFg","50823VTWXXj","6441948uoPUwt","92BSiBRu","1361711dyawqa","5202960gnlAWp","7tNVFlv","11056792usEcvw","90CRWXmt"];return $o=function(){return t},$o()}function So(t,e){var r=$o();return So=function(n,s){n=n-287;var o=r[n];return o},So(t,e)}function Pt(t){return!!t._zod}function jn(t){const e=Object.values(t);if(e.length===0)return Rd({});const r=e.every(Pt),n=e.every(s=>!Pt(s));if(r)return Rd(t);if(n)return kd(t);throw new Error("Mixed Zod versions detected in object shape.")}function ko(t,e){return Pt(t)?zs(t,e):t.safeParse(e)}async function Ra(t,e){return Pt(t)?await oi(t,e):await t.safeParseAsync(e)}function qn(t){var e,r;if(!t)return;let n;if(Pt(t)?n=(r=(e=t._zod)===null||e===void 0?void 0:e.def)===null||r===void 0?void 0:r.shape:n=t.shape,!!n){if(typeof n=="function")try{return n()}catch{return}return n}}function zn(t){var e;if(t){if(typeof t=="object"){const r=t,n=t;if(!r._def&&!n._zod){const s=Object.values(t);if(s.length>0&&s.every(o=>typeof o=="object"&&o!==null&&(o._def!==void 0||o._zod!==void 0||typeof o.parse=="function")))return jn(t)}}if(Pt(t)){const n=(e=t._zod)===null||e===void 0?void 0:e.def;if(n&&(n.typeName==="object"||n.shape!==void 0))return t}else if(t.shape!==void 0)return t}}function Ea(t){if(t&&typeof t=="object"){if("message"in t&&typeof t.message=="string")return t.message;if("issues"in t&&Array.isArray(t.issues)&&t.issues.length>0){const e=t.issues[0];if(e&&typeof e=="object"&&"message"in e)return String(e.message)}try{return JSON.stringify(t)}catch{return String(t)}}return String(t)}function Yb(t){var e,r,n,s;if(Pt(t))return(r=(e=t._zod)===null||e===void 0?void 0:e.def)===null||r===void 0?void 0:r.description;const o=t;return(n=t.description)!==null&&n!==void 0?n:(s=o._def)===null||s===void 0?void 0:s.description}function Qb(t){var e,r,n;if(Pt(t))return((r=(e=t._zod)===null||e===void 0?void 0:e.def)===null||r===void 0?void 0:r.typeName)==="ZodOptional";const s=t;return typeof t.isOptional=="function"?t.isOptional():((n=s._def)===null||n===void 0?void 0:n.typeName)==="ZodOptional"}function uh(t){var e;if(Pt(t)){const i=(e=t._zod)===null||e===void 0?void 0:e.def;if(i){if(i.value!==void 0)return i.value;if(Array.isArray(i.values)&&i.values.length>0)return i.values[0]}}const n=t._def;if(n){if(n.value!==void 0)return n.value;if(Array.isArray(n.values)&&n.values.length>0)return n.values[0]}const s=t.value;if(s!==void 0)return s}const Un="2025-06-18",lh=[Un,"2025-03-26","2024-11-05","2024-10-07"],To="2.0",qt=Ul(t=>t!==null&&(typeof t=="object"||typeof t=="function")),dh=ae([y(),ne().int()]),hh=y(),Xb=Ee({progressToken:dh.optional()}),xt=Ee({_meta:Xb.optional()}),it=C({method:y(),params:xt.optional()}),Vr=Ee({_meta:ce(y(),de()).optional()}),It=C({method:y(),params:Vr.optional()}),_t=Ee({_meta:ce(y(),de()).optional()}),Ro=ae([y(),ne().int()]),fh=C({jsonrpc:z(To),id:Ro,...it.shape}).strict(),ph=t=>fh.safeParse(t).success,mh=C({jsonrpc:z(To),...It.shape}).strict(),e$=t=>mh.safeParse(t).success,_h=C({jsonrpc:z(To),id:Ro,result:_t}).strict(),Pa=t=>_h.safeParse(t).success;var ye;(function(t){t[t.ConnectionClosed=-32e3]="ConnectionClosed",t[t.RequestTimeout=-32001]="RequestTimeout",t[t.ParseError=-32700]="ParseError",t[t.InvalidRequest=-32600]="InvalidRequest",t[t.MethodNotFound=-32601]="MethodNotFound",t[t.InvalidParams=-32602]="InvalidParams",t[t.InternalError=-32603]="InternalError",t[t.UrlElicitationRequired=-32042]="UrlElicitationRequired"})(ye||(ye={}));const gh=C({jsonrpc:z(To),id:Ro,error:C({code:ne().int(),message:y(),data:ee(de())})}).strict(),t$=t=>gh.safeParse(t).success,Hr=ae([fh,mh,_h,gh]),$r=_t.strict(),r$=Vr.extend({requestId:Ro,reason:y().optional()}),xa=It.extend({method:z("notifications/cancelled"),params:r$}),n$=C({src:y(),mimeType:y().optional(),sizes:x(y()).optional()}),Ln=C({icons:x(n$).optional()}),Fr=C({name:y(),title:y().optional()}),vh=Fr.extend({...Fr.shape,...Ln.shape,version:y(),websiteUrl:y().optional()}),s$=on(C({applyDefaults:oe().optional()}),ce(y(),de())),o$=pi(t=>t&&typeof t=="object"&&!Array.isArray(t)&&Object.keys(t).length===0?{form:{}}:t,on(C({form:s$.optional(),url:qt.optional()}),ce(y(),de()).optional())),i$=C({experimental:ce(y(),qt).optional(),sampling:C({context:qt.optional(),tools:qt.optional()}).optional(),elicitation:o$.optional(),roots:C({listChanged:oe().optional()}).optional()}),a$=xt.extend({protocolVersion:y(),capabilities:i$,clientInfo:vh}),yh=it.extend({method:z("initialize"),params:a$}),c$=C({experimental:ce(y(),qt).optional(),logging:qt.optional(),completions:qt.optional(),prompts:ee(C({listChanged:ee(oe())})),resources:C({subscribe:oe().optional(),listChanged:oe().optional()}).optional(),tools:C({listChanged:oe().optional()}).optional()}),wh=_t.extend({protocolVersion:y(),capabilities:c$,serverInfo:vh,instructions:y().optional()}),Ia=It.extend({method:z("notifications/initialized")}),u$=t=>Ia.safeParse(t).success,Ca=it.extend({method:z("ping")}),l$=C({progress:ne(),total:ee(ne()),message:ee(y())}),d$=C({...Vr.shape,...l$.shape,progressToken:dh}),Oa=It.extend({method:z("notifications/progress"),params:d$}),h$=xt.extend({cursor:hh.optional()}),Eo=it.extend({params:h$.optional()}),Po=_t.extend({nextCursor:ee(hh)}),bh=C({uri:y(),mimeType:ee(y()),_meta:ce(y(),de()).optional()}),$h=bh.extend({text:y()}),Na=y().refine(t=>{try{return atob(t),!0}catch{return!1}},{message:"Invalid Base64 string"}),Sh=bh.extend({blob:Na}),kh=C({...Fr.shape,...Ln.shape,uri:y(),description:ee(y()),mimeType:ee(y()),_meta:ee(Ee({}))}),f$=C({...Fr.shape,...Ln.shape,uriTemplate:y(),description:ee(y()),mimeType:ee(y()),_meta:ee(Ee({}))}),xo=Eo.extend({method:z("resources/list")}),Th=Po.extend({resources:x(kh)}),Aa=Eo.extend({method:z("resources/templates/list")}),Rh=Po.extend({resourceTemplates:x(f$)}),Ma=xt.extend({uri:y()}),p$=Ma,ja=it.extend({method:z("resources/read"),params:p$}),Eh=_t.extend({contents:x(ae([$h,Sh]))}),Ph=It.extend({method:z("notifications/resources/list_changed")}),m$=Ma,xh=it.extend({method:z("resources/subscribe"),params:m$}),_$=Ma,Ih=it.extend({method:z("resources/unsubscribe"),params:_$}),g$=Vr.extend({uri:y()}),Ch=It.extend({method:z("notifications/resources/updated"),params:g$}),v$=C({name:y(),description:ee(y()),required:ee(oe())}),y$=C({...Fr.shape,...Ln.shape,description:ee(y()),arguments:ee(x(v$)),_meta:ee(Ee({}))}),qa=Eo.extend({method:z("prompts/list")}),Oh=Po.extend({prompts:x(y$)}),w$=xt.extend({name:y(),arguments:ce(y(),y()).optional()}),za=it.extend({method:z("prompts/get"),params:w$}),Nh=C({type:z("text"),text:y(),_meta:ce(y(),de()).optional()}),Ah=C({type:z("image"),data:Na,mimeType:y(),_meta:ce(y(),de()).optional()}),Mh=C({type:z("audio"),data:Na,mimeType:y(),_meta:ce(y(),de()).optional()}),b$=C({type:z("tool_use"),name:y(),id:y(),input:C({}).passthrough(),_meta:ee(C({}).passthrough())}).passthrough(),$$=C({type:z("resource"),resource:ae([$h,Sh]),_meta:ce(y(),de()).optional()}),S$=kh.extend({type:z("resource_link")}),Ua=ae([Nh,Ah,Mh,S$,$$]),k$=C({role:qe(["user","assistant"]),content:Ua}),jh=_t.extend({description:ee(y()),messages:x(k$)}),qh=It.extend({method:z("notifications/prompts/list_changed")}),T$=C({title:y().optional(),readOnlyHint:oe().optional(),destructiveHint:oe().optional(),idempotentHint:oe().optional(),openWorldHint:oe().optional()}),zh=C({...Fr.shape,...Ln.shape,description:y().optional(),inputSchema:C({type:z("object"),properties:ce(y(),qt).optional(),required:x(y()).optional()}).catchall(de()),outputSchema:C({type:z("object"),properties:ce(y(),qt).optional(),required:x(y()).optional()}).catchall(de()).optional(),annotations:ee(T$),_meta:ce(y(),de()).optional()}),La=Eo.extend({method:z("tools/list")}),Uh=Po.extend({tools:x(zh)}),Io=_t.extend({content:x(Ua).default([]),structuredContent:ce(y(),de()).optional(),isError:ee(oe())});Io.or(_t.extend({toolResult:de()}));const R$=xt.extend({name:y(),arguments:ee(ce(y(),de()))}),Za=it.extend({method:z("tools/call"),params:R$}),Lh=It.extend({method:z("notifications/tools/list_changed")}),Co=qe(["debug","info","notice","warning","error","critical","alert","emergency"]),E$=xt.extend({level:Co}),Oo=it.extend({method:z("logging/setLevel"),params:E$}),P$=Vr.extend({level:Co,logger:y().optional(),data:de()}),Zh=It.extend({method:z("notifications/message"),params:P$}),x$=C({name:y().optional()}),I$=C({hints:ee(x(x$)),costPriority:ee(ne().min(0).max(1)),speedPriority:ee(ne().min(0).max(1)),intelligencePriority:ee(ne().min(0).max(1))}),C$=C({mode:ee(qe(["auto","required","none"]))}),O$=C({type:z("tool_result"),toolUseId:y().describe("The unique identifier for the corresponding tool call."),content:x(Ua).default([]),structuredContent:C({}).passthrough().optional(),isError:ee(oe()),_meta:ee(C({}).passthrough())}).passthrough(),No=di("type",[Nh,Ah,Mh,b$,O$]),N$=C({role:qe(["user","assistant"]),content:ae([No,x(No)]),_meta:ee(C({}).passthrough())}).passthrough(),A$=xt.extend({messages:x(N$),modelPreferences:I$.optional(),systemPrompt:y().optional(),includeContext:qe(["none","thisServer","allServers"]).optional(),temperature:ne().optional(),maxTokens:ne().int(),stopSequences:x(y()).optional(),metadata:qt.optional(),tools:ee(x(zh)),toolChoice:ee(C$)}),Dh=it.extend({method:z("sampling/createMessage"),params:A$}),Vh=_t.extend({model:y(),stopReason:ee(qe(["endTurn","stopSequence","maxTokens","toolUse"]).or(y())),role:qe(["user","assistant"]),content:ae([No,x(No)])}),M$=C({type:z("boolean"),title:y().optional(),description:y().optional(),default:oe().optional()}),j$=C({type:z("string"),title:y().optional(),description:y().optional(),minLength:ne().optional(),maxLength:ne().optional(),format:qe(["email","uri","date","date-time"]).optional(),default:y().optional()}),q$=C({type:qe(["number","integer"]),title:y().optional(),description:y().optional(),minimum:ne().optional(),maximum:ne().optional(),default:ne().optional()}),z$=C({type:z("string"),title:y().optional(),description:y().optional(),enum:x(y()),default:y().optional()}),U$=C({type:z("string"),title:y().optional(),description:y().optional(),oneOf:x(C({const:y(),title:y()})),default:y().optional()}),L$=C({type:z("string"),title:y().optional(),description:y().optional(),enum:x(y()),enumNames:x(y()).optional(),default:y().optional()}),Z$=ae([z$,U$]),D$=C({type:z("array"),title:y().optional(),description:y().optional(),minItems:ne().optional(),maxItems:ne().optional(),items:C({type:z("string"),enum:x(y())}),default:x(y()).optional()}),V$=C({type:z("array"),title:y().optional(),description:y().optional(),minItems:ne().optional(),maxItems:ne().optional(),items:C({anyOf:x(C({const:y(),title:y()}))}),default:x(y()).optional()}),H$=ae([D$,V$]),F$=ae([L$,Z$,H$]),W$=ae([F$,M$,j$,q$]),J$=xt.extend({mode:z("form").optional(),message:y(),requestedSchema:C({type:z("object"),properties:ce(y(),W$),required:x(y()).optional()})}),B$=xt.extend({mode:z("url"),message:y(),elicitationId:y(),url:y().url()}),K$=ae([J$,B$]),Da=it.extend({method:z("elicitation/create"),params:K$}),G$=Vr.extend({elicitationId:y()}),Y$=It.extend({method:z("notifications/elicitation/complete"),params:G$}),Ao=_t.extend({action:qe(["accept","decline","cancel"]),content:ce(y(),ae([y(),ne(),oe(),x(y())])).optional()}),Q$=C({type:z("ref/resource"),uri:y()}),X$=C({type:z("ref/prompt"),name:y()}),eS=xt.extend({ref:ae([X$,Q$]),argument:C({name:y(),value:y()}),context:C({arguments:ce(y(),y()).optional()}).optional()}),Va=it.extend({method:z("completion/complete"),params:eS});function tS(t){if(t.params.ref.type!=="ref/prompt")throw new TypeError(`Expected CompleteRequestPrompt, but got ${t.params.ref.type}`)}function rS(t){if(t.params.ref.type!=="ref/resource")throw new TypeError(`Expected CompleteRequestResourceTemplate, but got ${t.params.ref.type}`)}const Hh=_t.extend({completion:Ee({values:x(y()).max(100),total:ee(ne().int()),hasMore:ee(oe())})}),nS=C({uri:y().startsWith("file://"),name:y().optional(),_meta:ce(y(),de()).optional()}),Fh=it.extend({method:z("roots/list")}),Wh=_t.extend({roots:x(nS)}),Jh=It.extend({method:z("notifications/roots/list_changed")});ae([Ca,yh,Va,Oo,za,qa,xo,Aa,ja,xh,Ih,Za,La]),ae([xa,Oa,Ia,Jh]),ae([$r,Vh,Ao,Wh]),ae([Ca,Dh,Da,Fh]),ae([xa,Oa,Zh,Ch,Ph,Lh,qh,Y$]),ae([$r,wh,Hh,jh,Oh,Th,Rh,Eh,Io,Uh]);class we extends Error{constructor(e,r,n){super(`MCP error ${e}: ${r}`),this.code=e,this.data=n,this.name="McpError"}static fromError(e,r,n){if(e===ye.UrlElicitationRequired&&n){const s=n;if(s.elicitations)return new sS(s.elicitations,r)}return new we(e,r,n)}}class sS extends we{constructor(e,r=`URL elicitation${e.length>1?"s":""} required`){super(ye.UrlElicitationRequired,r,{elicitations:e})}get elicitations(){var e,r;return(r=(e=this.data)===null||e===void 0?void 0:e.elicitations)!==null&&r!==void 0?r:[]}}function oS(t){return!t||t==="jsonSchema7"||t==="draft-7"?"draft-7":t==="jsonSchema2019-09"||t==="draft-2020-12"?"draft-2020-12":"draft-7"}function Bh(t,e){var r,n,s;return Pt(t)?sg(t,{target:oS(e?.target),io:(r=e?.pipeStrategy)!==null&&r!==void 0?r:"input"}):Pw(t,{strictUnions:(n=e?.strictUnions)!==null&&n!==void 0?n:!0,pipeStrategy:(s=e?.pipeStrategy)!==null&&s!==void 0?s:"input"})}function Kh(t){const e=qn(t),r=e?.method;if(!r)throw new Error("Schema is missing a method literal");const n=uh(r);if(typeof n!="string")throw new Error("Schema method literal must be a string");return n}function Gh(t,e){const r=ko(t,e);if(!r.success)throw r.error;return r.data}const iS=6e4;class Yh{constructor(e){this._options=e,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.setNotificationHandler(xa,r=>{const n=this._requestHandlerAbortControllers.get(r.params.requestId);n?.abort(r.params.reason)}),this.setNotificationHandler(Oa,r=>{this._onprogress(r)}),this.setRequestHandler(Ca,r=>({}))}_setupTimeout(e,r,n,s,o=!1){this._timeoutInfo.set(e,{timeoutId:setTimeout(s,r),startTime:Date.now(),timeout:r,maxTotalTimeout:n,resetTimeoutOnProgress:o,onTimeout:s})}_resetTimeout(e){const r=this._timeoutInfo.get(e);if(!r)return!1;const n=Date.now()-r.startTime;if(r.maxTotalTimeout&&n>=r.maxTotalTimeout)throw this._timeoutInfo.delete(e),we.fromError(ye.RequestTimeout,"Maximum total timeout exceeded",{maxTotalTimeout:r.maxTotalTimeout,totalElapsed:n});return clearTimeout(r.timeoutId),r.timeoutId=setTimeout(r.onTimeout,r.timeout),!0}_cleanupTimeout(e){const r=this._timeoutInfo.get(e);r&&(clearTimeout(r.timeoutId),this._timeoutInfo.delete(e))}async connect(e){var r,n,s;this._transport=e;const o=(r=this.transport)===null||r===void 0?void 0:r.onclose;this._transport.onclose=()=>{o?.(),this._onclose()};const i=(n=this.transport)===null||n===void 0?void 0:n.onerror;this._transport.onerror=c=>{i?.(c),this._onerror(c)};const a=(s=this._transport)===null||s===void 0?void 0:s.onmessage;this._transport.onmessage=(c,u)=>{a?.(c,u),Pa(c)||t$(c)?this._onresponse(c):ph(c)?this._onrequest(c,u):e$(c)?this._onnotification(c):this._onerror(new Error(`Unknown message type: ${JSON.stringify(c)}`))},await this._transport.start()}_onclose(){var e;const r=this._responseHandlers;this._responseHandlers=new Map,this._progressHandlers.clear(),this._pendingDebouncedNotifications.clear(),this._transport=void 0,(e=this.onclose)===null||e===void 0||e.call(this);const n=we.fromError(ye.ConnectionClosed,"Connection closed");for(const s of r.values())s(n)}_onerror(e){var r;(r=this.onerror)===null||r===void 0||r.call(this,e)}_onnotification(e){var r;const n=(r=this._notificationHandlers.get(e.method))!==null&&r!==void 0?r:this.fallbackNotificationHandler;n!==void 0&&Promise.resolve().then(()=>n(e)).catch(s=>this._onerror(new Error(`Uncaught error in notification handler: ${s}`)))}_onrequest(e,r){var n,s;const o=(n=this._requestHandlers.get(e.method))!==null&&n!==void 0?n:this.fallbackRequestHandler,i=this._transport;if(o===void 0){i?.send({jsonrpc:"2.0",id:e.id,error:{code:ye.MethodNotFound,message:"Method not found"}}).catch(u=>this._onerror(new Error(`Failed to send an error response: ${u}`)));return}const a=new AbortController;this._requestHandlerAbortControllers.set(e.id,a);const c={signal:a.signal,sessionId:i?.sessionId,_meta:(s=e.params)===null||s===void 0?void 0:s._meta,sendNotification:u=>this.notification(u,{relatedRequestId:e.id}),sendRequest:(u,l,d)=>this.request(u,l,{...d,relatedRequestId:e.id}),authInfo:r?.authInfo,requestId:e.id,requestInfo:r?.requestInfo};Promise.resolve().then(()=>o(e,c)).then(u=>{if(!a.signal.aborted)return i?.send({result:u,jsonrpc:"2.0",id:e.id})},u=>{var l;if(!a.signal.aborted)return i?.send({jsonrpc:"2.0",id:e.id,error:{code:Number.isSafeInteger(u.code)?u.code:ye.InternalError,message:(l=u.message)!==null&&l!==void 0?l:"Internal error",...u.data!==void 0&&{data:u.data}}})}).catch(u=>this._onerror(new Error(`Failed to send response: ${u}`))).finally(()=>{this._requestHandlerAbortControllers.delete(e.id)})}_onprogress(e){const{progressToken:r,...n}=e.params,s=Number(r),o=this._progressHandlers.get(s);if(!o){this._onerror(new Error(`Received a progress notification for an unknown token: ${JSON.stringify(e)}`));return}const i=this._responseHandlers.get(s),a=this._timeoutInfo.get(s);if(a&&i&&a.resetTimeoutOnProgress)try{this._resetTimeout(s)}catch(c){i(c);return}o(n)}_onresponse(e){const r=Number(e.id),n=this._responseHandlers.get(r);if(n===void 0){this._onerror(new Error(`Received a response for an unknown message ID: ${JSON.stringify(e)}`));return}if(this._responseHandlers.delete(r),this._progressHandlers.delete(r),this._cleanupTimeout(r),Pa(e))n(e);else{const s=we.fromError(e.error.code,e.error.message,e.error.data);n(s)}}get transport(){return this._transport}async close(){var e;await((e=this._transport)===null||e===void 0?void 0:e.close())}request(e,r,n){const{relatedRequestId:s,resumptionToken:o,onresumptiontoken:i}=n??{};return new Promise((a,c)=>{var u,l,d,p,_,m;if(!this._transport){c(new Error("Not connected"));return}((u=this._options)===null||u===void 0?void 0:u.enforceStrictCapabilities)===!0&&this.assertCapabilityForMethod(e.method),(l=n?.signal)===null||l===void 0||l.throwIfAborted();const g=this._requestMessageId++,f={...e,jsonrpc:"2.0",id:g};n?.onprogress&&(this._progressHandlers.set(g,n.onprogress),f.params={...e.params,_meta:{...((d=e.params)===null||d===void 0?void 0:d._meta)||{},progressToken:g}});const v=$=>{var b;this._responseHandlers.delete(g),this._progressHandlers.delete(g),this._cleanupTimeout(g),(b=this._transport)===null||b===void 0||b.send({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:g,reason:String($)}},{relatedRequestId:s,resumptionToken:o,onresumptiontoken:i}).catch(S=>this._onerror(new Error(`Failed to send cancellation: ${S}`))),c($)};this._responseHandlers.set(g,$=>{var b;if(!(!((b=n?.signal)===null||b===void 0)&&b.aborted)){if($ instanceof Error)return c($);try{const S=ko(r,$.result);S.success?a(S.data):c(S.error)}catch(S){c(S)}}}),(p=n?.signal)===null||p===void 0||p.addEventListener("abort",()=>{var $;v(($=n?.signal)===null||$===void 0?void 0:$.reason)});const h=(_=n?.timeout)!==null&&_!==void 0?_:iS,w=()=>v(we.fromError(ye.RequestTimeout,"Request timed out",{timeout:h}));this._setupTimeout(g,h,n?.maxTotalTimeout,w,(m=n?.resetTimeoutOnProgress)!==null&&m!==void 0?m:!1),this._transport.send(f,{relatedRequestId:s,resumptionToken:o,onresumptiontoken:i}).catch($=>{this._cleanupTimeout(g),c($)})})}async notification(e,r){var n,s;if(!this._transport)throw new Error("Not connected");if(this.assertNotificationCapability(e.method),((s=(n=this._options)===null||n===void 0?void 0:n.debouncedNotificationMethods)!==null&&s!==void 0?s:[]).includes(e.method)&&!e.params&&!r?.relatedRequestId){if(this._pendingDebouncedNotifications.has(e.method))return;this._pendingDebouncedNotifications.add(e.method),Promise.resolve().then(()=>{var c;if(this._pendingDebouncedNotifications.delete(e.method),!this._transport)return;const u={...e,jsonrpc:"2.0"};(c=this._transport)===null||c===void 0||c.send(u,r).catch(l=>this._onerror(l))});return}const a={...e,jsonrpc:"2.0"};await this._transport.send(a,r)}setRequestHandler(e,r){const n=Kh(e);this.assertRequestHandlerCapability(n),this._requestHandlers.set(n,(s,o)=>{const i=Gh(e,s);return Promise.resolve(r(i,o))})}removeRequestHandler(e){this._requestHandlers.delete(e)}assertCanSetRequestHandler(e){if(this._requestHandlers.has(e))throw new Error(`A request handler for ${e} already exists, which would be overridden`)}setNotificationHandler(e,r){const n=Kh(e);this._notificationHandlers.set(n,s=>{const o=Gh(e,s);return Promise.resolve(r(o))})}removeNotificationHandler(e){this._notificationHandlers.delete(e)}}function Qh(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)}function Xh(t,e){const r={...t};for(const n in e){const s=n,o=e[s];if(o===void 0)continue;const i=r[s];Qh(i)&&Qh(o)?r[s]={...i,...o}:r[s]=o}return r}function aS(){const t=new qu.Ajv({strict:!1,validateFormats:!0,validateSchema:!1,allErrors:!0});return Vd(t),t}class ef{constructor(e){this._ajv=e??aS()}getValidator(e){var r;const n="$id"in e&&typeof e.$id=="string"?(r=this._ajv.getSchema(e.$id))!==null&&r!==void 0?r:this._ajv.compile(e):this._ajv.compile(e);return s=>n(s)?{valid:!0,data:s,errorMessage:void 0}:{valid:!1,data:void 0,errorMessage:this._ajv.errorsText(n.errors)}}}class cS extends Yh{constructor(e,r){var n,s;super(r),this._serverInfo=e,this._loggingLevels=new Map,this.LOG_LEVEL_SEVERITY=new Map(Co.options.map((o,i)=>[o,i])),this.isMessageIgnored=(o,i)=>{const a=this._loggingLevels.get(i);return a?this.LOG_LEVEL_SEVERITY.get(o)<this.LOG_LEVEL_SEVERITY.get(a):!1},this._capabilities=(n=r?.capabilities)!==null&&n!==void 0?n:{},this._instructions=r?.instructions,this._jsonSchemaValidator=(s=r?.jsonSchemaValidator)!==null&&s!==void 0?s:new ef,this.setRequestHandler(yh,o=>this._oninitialize(o)),this.setNotificationHandler(Ia,()=>{var o;return(o=this.oninitialized)===null||o===void 0?void 0:o.call(this)}),this._capabilities.logging&&this.setRequestHandler(Oo,async(o,i)=>{var a;const c=i.sessionId||((a=i.requestInfo)===null||a===void 0?void 0:a.headers["mcp-session-id"])||void 0,{level:u}=o.params,l=Co.safeParse(u);return l.success&&this._loggingLevels.set(c,l.data),{}})}registerCapabilities(e){if(this.transport)throw new Error("Cannot register capabilities after connecting to transport");this._capabilities=Xh(this._capabilities,e)}assertCapabilityForMethod(e){var r,n,s;switch(e){case"sampling/createMessage":if(!(!((r=this._clientCapabilities)===null||r===void 0)&&r.sampling))throw new Error(`Client does not support sampling (required for ${e})`);break;case"elicitation/create":if(!(!((n=this._clientCapabilities)===null||n===void 0)&&n.elicitation))throw new Error(`Client does not support elicitation (required for ${e})`);break;case"roots/list":if(!(!((s=this._clientCapabilities)===null||s===void 0)&&s.roots))throw new Error(`Client does not support listing roots (required for ${e})`);break}}assertNotificationCapability(e){var r,n;switch(e){case"notifications/message":if(!this._capabilities.logging)throw new Error(`Server does not support logging (required for ${e})`);break;case"notifications/resources/updated":case"notifications/resources/list_changed":if(!this._capabilities.resources)throw new Error(`Server does not support notifying about resources (required for ${e})`);break;case"notifications/tools/list_changed":if(!this._capabilities.tools)throw new Error(`Server does not support notifying of tool list changes (required for ${e})`);break;case"notifications/prompts/list_changed":if(!this._capabilities.prompts)throw new Error(`Server does not support notifying of prompt list changes (required for ${e})`);break;case"notifications/elicitation/complete":if(!(!((n=(r=this._clientCapabilities)===null||r===void 0?void 0:r.elicitation)===null||n===void 0)&&n.url))throw new Error(`Client does not support URL elicitation (required for ${e})`);break}}assertRequestHandlerCapability(e){switch(e){case"completion/complete":if(!this._capabilities.completions)throw new Error(`Server does not support completions (required for ${e})`);break;case"logging/setLevel":if(!this._capabilities.logging)throw new Error(`Server does not support logging (required for ${e})`);break;case"prompts/get":case"prompts/list":if(!this._capabilities.prompts)throw new Error(`Server does not support prompts (required for ${e})`);break;case"resources/list":case"resources/templates/list":case"resources/read":if(!this._capabilities.resources)throw new Error(`Server does not support resources (required for ${e})`);break;case"tools/call":case"tools/list":if(!this._capabilities.tools)throw new Error(`Server does not support tools (required for ${e})`);break}}async _oninitialize(e){const r=e.params.protocolVersion;return this._clientCapabilities=e.params.capabilities,this._clientVersion=e.params.clientInfo,{protocolVersion:lh.includes(r)?r:Un,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"},$r)}async createMessage(e,r){var n,s;if((e.tools||e.toolChoice)&&!(!((s=(n=this._clientCapabilities)===null||n===void 0?void 0:n.sampling)===null||s===void 0)&&s.tools))throw new Error("Client does not support sampling tools capability.");if(e.messages.length>0){const o=e.messages[e.messages.length-1],i=Array.isArray(o.content)?o.content:[o.content],a=i.some(d=>d.type==="tool_result"),c=e.messages.length>1?e.messages[e.messages.length-2]:void 0,u=c?Array.isArray(c.content)?c.content:[c.content]:[],l=u.some(d=>d.type==="tool_use");if(a){if(i.some(d=>d.type!=="tool_result"))throw new Error("The last message must contain only tool_result content if any is present");if(!l)throw new Error("tool_result blocks are not matching any tool_use from the previous message")}if(l){const d=new Set(u.filter(_=>_.type==="tool_use").map(_=>_.id)),p=new Set(i.filter(_=>_.type==="tool_result").map(_=>_.toolUseId));if(d.size!==p.size||![...d].every(_=>p.has(_)))throw new Error("ids of tool_result blocks and tool_use blocks from previous message do not match")}}return this.request({method:"sampling/createMessage",params:e},Vh,r)}async elicitInput(e,r){var n,s,o,i,a;switch((n=e.mode)!==null&&n!==void 0?n:"form"){case"url":{if(!(!((o=(s=this._clientCapabilities)===null||s===void 0?void 0:s.elicitation)===null||o===void 0)&&o.url))throw new Error("Client does not support url elicitation.");const u=e;return this.request({method:"elicitation/create",params:u},Ao,r)}case"form":{if(!(!((a=(i=this._clientCapabilities)===null||i===void 0?void 0:i.elicitation)===null||a===void 0)&&a.form))throw new Error("Client does not support form elicitation.");const u=e.mode==="form"?e:{...e,mode:"form"},l=await this.request({method:"elicitation/create",params:u},Ao,r);if(l.action==="accept"&&l.content&&u.requestedSchema)try{const p=this._jsonSchemaValidator.getValidator(u.requestedSchema)(l.content);if(!p.valid)throw new we(ye.InvalidParams,`Elicitation response content does not match requested schema: ${p.errorMessage}`)}catch(d){throw d instanceof we?d:new we(ye.InternalError,`Error validating elicitation response: ${d instanceof Error?d.message:String(d)}`)}return l}}}createElicitationCompletionNotifier(e,r){var n,s;if(!(!((s=(n=this._clientCapabilities)===null||n===void 0?void 0:n.elicitation)===null||s===void 0)&&s.url))throw new Error("Client does not support URL elicitation (required for notifications/elicitation/complete)");return()=>this.notification({method:"notifications/elicitation/complete",params:{elicitationId:e}},r)}async listRoots(e,r){return this.request({method:"roots/list",params:e},Wh,r)}async sendLoggingMessage(e,r){if(this._capabilities.logging&&!this.isMessageIgnored(e.level,r))return this.notification({method:"notifications/message",params:e})}async sendResourceUpdated(e){return this.notification({method:"notifications/resources/updated",params:e})}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"})}}const Ha=Symbol.for("mcp.completable");function uS(t,e){return Object.defineProperty(t,Ha,{value:{complete:e},enumerable:!1,writable:!1,configurable:!1}),t}function lS(t){return!!t&&typeof t=="object"&&Ha in t}function dS(t){const e=t[Ha];return e?.complete}var tf;(function(t){t.Completable="McpCompletable"})(tf||(tf={}));const rf=1e6,Fa=1e6,nf=1e4,hS=1e6;class Jt{static isTemplate(e){return/\{[^}\s]+\}/.test(e)}static validateLength(e,r,n){if(e.length>r)throw new Error(`${n} exceeds maximum length of ${r} characters (got ${e.length})`)}get variableNames(){return this.parts.flatMap(e=>typeof e=="string"?[]:e.names)}constructor(e){Jt.validateLength(e,rf,"Template"),this.template=e,this.parts=this.parse(e)}toString(){return this.template}parse(e){const r=[];let n="",s=0,o=0;for(;s<e.length;)if(e[s]==="{"){n&&(r.push(n),n="");const i=e.indexOf("}",s);if(i===-1)throw new Error("Unclosed template expression");if(o++,o>nf)throw new Error(`Template contains too many expressions (max ${nf})`);const a=e.slice(s+1,i),c=this.getOperator(a),u=a.includes("*"),l=this.getNames(a),d=l[0];for(const p of l)Jt.validateLength(p,Fa,"Variable name");r.push({name:d,operator:c,names:l,exploded:u}),s=i+1}else n+=e[s],s++;return n&&r.push(n),r}getOperator(e){return["+","#",".","/","?","&"].find(n=>e.startsWith(n))||""}getNames(e){const r=this.getOperator(e);return e.slice(r.length).split(",").map(n=>n.replace("*","").trim()).filter(n=>n.length>0)}encodeValue(e,r){return Jt.validateLength(e,Fa,"Variable value"),r==="+"||r==="#"?encodeURI(e):encodeURIComponent(e)}expandPart(e,r){if(e.operator==="?"||e.operator==="&"){const i=e.names.map(c=>{const u=r[c];if(u===void 0)return"";const l=Array.isArray(u)?u.map(d=>this.encodeValue(d,e.operator)).join(","):this.encodeValue(u.toString(),e.operator);return`${c}=${l}`}).filter(c=>c.length>0);return i.length===0?"":(e.operator==="?"?"?":"&")+i.join("&")}if(e.names.length>1){const i=e.names.map(a=>r[a]).filter(a=>a!==void 0);return i.length===0?"":i.map(a=>Array.isArray(a)?a[0]:a).join(",")}const n=r[e.name];if(n===void 0)return"";const o=(Array.isArray(n)?n:[n]).map(i=>this.encodeValue(i,e.operator));switch(e.operator){case"":return o.join(",");case"+":return o.join(",");case"#":return"#"+o.join(",");case".":return"."+o.join(".");case"/":return"/"+o.join("/");default:return o.join(",")}}expand(e){let r="",n=!1;for(const s of this.parts){if(typeof s=="string"){r+=s;continue}const o=this.expandPart(s,e);o&&((s.operator==="?"||s.operator==="&")&&n?r+=o.replace("?","&"):r+=o,(s.operator==="?"||s.operator==="&")&&(n=!0))}return r}escapeRegExp(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}partToRegExp(e){const r=[];for(const o of e.names)Jt.validateLength(o,Fa,"Variable name");if(e.operator==="?"||e.operator==="&"){for(let o=0;o<e.names.length;o++){const i=e.names[o],a=o===0?"\\"+e.operator:"&";r.push({pattern:a+this.escapeRegExp(i)+"=([^&]+)",name:i})}return r}let n;const s=e.name;switch(e.operator){case"":n=e.exploded?"([^/]+(?:,[^/]+)*)":"([^/,]+)";break;case"+":case"#":n="(.+)";break;case".":n="\\.([^/,]+)";break;case"/":n="/"+(e.exploded?"([^/]+(?:,[^/]+)*)":"([^/,]+)");break;default:n="([^/]+)"}return r.push({pattern:n,name:s}),r}match(e){Jt.validateLength(e,rf,"URI");let r="^";const n=[];for(const a of this.parts)if(typeof a=="string")r+=this.escapeRegExp(a);else{const c=this.partToRegExp(a);for(const{pattern:u,name:l}of c)r+=u,n.push({name:l,exploded:a.exploded})}r+="$",Jt.validateLength(r,hS,"Generated regex pattern");const s=new RegExp(r),o=e.match(s);if(!o)return null;const i={};for(let a=0;a<n.length;a++){const{name:c,exploded:u}=n[a],l=o[a+1],d=c.replace("*","");u&&l.includes(",")?i[d]=l.split(","):i[d]=l}return i}}const fS=/^[A-Za-z0-9._-]{1,128}$/;function pS(t){const e=[];if(t.length===0)return{isValid:!1,warnings:["Tool name cannot be empty"]};if(t.length>128)return{isValid:!1,warnings:[`Tool name exceeds maximum length of 128 characters (current: ${t.length})`]};if(t.includes(" ")&&e.push("Tool name contains spaces, which may cause parsing issues"),t.includes(",")&&e.push("Tool name contains commas, which may cause parsing issues"),(t.startsWith("-")||t.endsWith("-"))&&e.push("Tool name starts or ends with a dash, which may cause parsing issues in some contexts"),(t.startsWith(".")||t.endsWith("."))&&e.push("Tool name starts or ends with a dot, which may cause parsing issues in some contexts"),!fS.test(t)){const r=t.split("").filter(n=>!/[A-Za-z0-9._-]/.test(n)).filter((n,s,o)=>o.indexOf(n)===s);return e.push(`Tool name contains invalid characters: ${r.map(n=>`"${n}"`).join(", ")}`,"Allowed characters are: A-Z, a-z, 0-9, underscore (_), dash (-), and dot (.)"),{isValid:!1,warnings:e}}return{isValid:!0,warnings:e}}function mS(t,e){if(e.length>0){console.warn(`Tool name validation warning for "${t}":`);for(const r of e)console.warn(` - ${r}`);console.warn("Tool registration will proceed, but this may cause compatibility issues."),console.warn("Consider updating the tool name to conform to the MCP tool naming standard."),console.warn("See SEP: Specify Format for Tool Names (https://github.com/modelcontextprotocol/modelcontextprotocol/issues/986) for more details.")}}function sf(t){const e=pS(t);return mS(t,e.warnings),e.isValid}class of{constructor(e,r){this._registeredResources={},this._registeredResourceTemplates={},this._registeredTools={},this._registeredPrompts={},this._toolHandlersInitialized=!1,this._completionHandlerInitialized=!1,this._resourceHandlersInitialized=!1,this._promptHandlersInitialized=!1,this.server=new cS(e,r)}async connect(e){return await this.server.connect(e)}async close(){await this.server.close()}setToolRequestHandlers(){this._toolHandlersInitialized||(this.server.assertCanSetRequestHandler(cr(La)),this.server.assertCanSetRequestHandler(cr(Za)),this.server.registerCapabilities({tools:{listChanged:!0}}),this.server.setRequestHandler(La,()=>({tools:Object.entries(this._registeredTools).filter(([,e])=>e.enabled).map(([e,r])=>{const n={name:e,title:r.title,description:r.description,inputSchema:(()=>{const s=zn(r.inputSchema);return s?Bh(s,{strictUnions:!0,pipeStrategy:"input"}):gS})(),annotations:r.annotations,_meta:r._meta};if(r.outputSchema){const s=zn(r.outputSchema);s&&(n.outputSchema=Bh(s,{strictUnions:!0,pipeStrategy:"output"}))}return n})})),this.server.setRequestHandler(Za,async(e,r)=>{const n=this._registeredTools[e.params.name];let s;try{if(!n)throw new we(ye.InvalidParams,`Tool ${e.params.name} not found`);if(!n.enabled)throw new we(ye.InvalidParams,`Tool ${e.params.name} disabled`);if(n.inputSchema){const o=n.callback,i=zn(n.inputSchema),a=i??n.inputSchema,c=await Ra(a,e.params.arguments);if(!c.success)throw new we(ye.InvalidParams,`Input validation error: Invalid arguments for tool ${e.params.name}: ${Ea(c.error)}`);const u=c.data;s=await Promise.resolve(o(u,r))}else{const o=n.callback;s=await Promise.resolve(o(r))}if(n.outputSchema&&!s.isError){if(!s.structuredContent)throw new we(ye.InvalidParams,`Output validation error: Tool ${e.params.name} has an output schema but no structured content was provided`);const o=zn(n.outputSchema),i=await Ra(o,s.structuredContent);if(!i.success)throw new we(ye.InvalidParams,`Output validation error: Invalid structured content for tool ${e.params.name}: ${Ea(i.error)}`)}}catch(o){if(o instanceof we&&o.code===ye.UrlElicitationRequired)throw o;return this.createToolError(o instanceof Error?o.message:String(o))}return s}),this._toolHandlersInitialized=!0)}createToolError(e){return{content:[{type:"text",text:e}],isError:!0}}setCompletionRequestHandler(){this._completionHandlerInitialized||(this.server.assertCanSetRequestHandler(cr(Va)),this.server.registerCapabilities({completions:{}}),this.server.setRequestHandler(Va,async e=>{switch(e.params.ref.type){case"ref/prompt":return tS(e),this.handlePromptCompletion(e,e.params.ref);case"ref/resource":return rS(e),this.handleResourceCompletion(e,e.params.ref);default:throw new we(ye.InvalidParams,`Invalid completion reference: ${e.params.ref}`)}}),this._completionHandlerInitialized=!0)}async handlePromptCompletion(e,r){const n=this._registeredPrompts[r.name];if(!n)throw new we(ye.InvalidParams,`Prompt ${r.name} not found`);if(!n.enabled)throw new we(ye.InvalidParams,`Prompt ${r.name} disabled`);if(!n.argsSchema)return Zn;const s=qn(n.argsSchema),o=s?.[e.params.argument.name];if(!lS(o))return Zn;const i=dS(o);if(!i)return Zn;const a=await i(e.params.argument.value,e.params.context);return cf(a)}async handleResourceCompletion(e,r){const n=Object.values(this._registeredResourceTemplates).find(i=>i.resourceTemplate.uriTemplate.toString()===r.uri);if(!n){if(this._registeredResources[r.uri])return Zn;throw new we(ye.InvalidParams,`Resource template ${e.params.ref.uri} not found`)}const s=n.resourceTemplate.completeCallback(e.params.argument.name);if(!s)return Zn;const o=await s(e.params.argument.value,e.params.context);return cf(o)}setResourceRequestHandlers(){this._resourceHandlersInitialized||(this.server.assertCanSetRequestHandler(cr(xo)),this.server.assertCanSetRequestHandler(cr(Aa)),this.server.assertCanSetRequestHandler(cr(ja)),this.server.registerCapabilities({resources:{listChanged:!0}}),this.server.setRequestHandler(xo,async(e,r)=>{const n=Object.entries(this._registeredResources).filter(([o,i])=>i.enabled).map(([o,i])=>({uri:o,name:i.name,...i.metadata})),s=[];for(const o of Object.values(this._registeredResourceTemplates)){if(!o.resourceTemplate.listCallback)continue;const i=await o.resourceTemplate.listCallback(r);for(const a of i.resources)s.push({...o.metadata,...a})}return{resources:[...n,...s]}}),this.server.setRequestHandler(Aa,async()=>({resourceTemplates:Object.entries(this._registeredResourceTemplates).map(([r,n])=>({name:r,uriTemplate:n.resourceTemplate.uriTemplate.toString(),...n.metadata}))})),this.server.setRequestHandler(ja,async(e,r)=>{const n=new URL(e.params.uri),s=this._registeredResources[n.toString()];if(s){if(!s.enabled)throw new we(ye.InvalidParams,`Resource ${n} disabled`);return s.readCallback(n,r)}for(const o of Object.values(this._registeredResourceTemplates)){const i=o.resourceTemplate.uriTemplate.match(n.toString());if(i)return o.readCallback(n,i,r)}throw new we(ye.InvalidParams,`Resource ${n} not found`)}),this.setCompletionRequestHandler(),this._resourceHandlersInitialized=!0)}setPromptRequestHandlers(){this._promptHandlersInitialized||(this.server.assertCanSetRequestHandler(cr(qa)),this.server.assertCanSetRequestHandler(cr(za)),this.server.registerCapabilities({prompts:{listChanged:!0}}),this.server.setRequestHandler(qa,()=>({prompts:Object.entries(this._registeredPrompts).filter(([,e])=>e.enabled).map(([e,r])=>({name:e,title:r.title,description:r.description,arguments:r.argsSchema?yS(r.argsSchema):void 0}))})),this.server.setRequestHandler(za,async(e,r)=>{const n=this._registeredPrompts[e.params.name];if(!n)throw new we(ye.InvalidParams,`Prompt ${e.params.name} not found`);if(!n.enabled)throw new we(ye.InvalidParams,`Prompt ${e.params.name} disabled`);if(n.argsSchema){const s=zn(n.argsSchema),o=await Ra(s,e.params.arguments);if(!o.success)throw new we(ye.InvalidParams,`Invalid arguments for prompt ${e.params.name}: ${Ea(o.error)}`);const i=o.data,a=n.callback;return await Promise.resolve(a(i,r))}else{const s=n.callback;return await Promise.resolve(s(r))}}),this.setCompletionRequestHandler(),this._promptHandlersInitialized=!0)}resource(e,r,...n){let s;typeof n[0]=="object"&&(s=n.shift());const o=n[0];if(typeof r=="string"){if(this._registeredResources[r])throw new Error(`Resource ${r} is already registered`);const i=this._createRegisteredResource(e,void 0,r,s,o);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),i}else{if(this._registeredResourceTemplates[e])throw new Error(`Resource template ${e} is already registered`);const i=this._createRegisteredResourceTemplate(e,void 0,r,s,o);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),i}}registerResource(e,r,n,s){if(typeof r=="string"){if(this._registeredResources[r])throw new Error(`Resource ${r} is already registered`);const o=this._createRegisteredResource(e,n.title,r,n,s);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),o}else{if(this._registeredResourceTemplates[e])throw new Error(`Resource template ${e} is already registered`);const o=this._createRegisteredResourceTemplate(e,n.title,r,n,s);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),o}}_createRegisteredResource(e,r,n,s,o){const i={name:e,title:r,metadata:s,readCallback:o,enabled:!0,disable:()=>i.update({enabled:!1}),enable:()=>i.update({enabled:!0}),remove:()=>i.update({uri:null}),update:a=>{typeof a.uri<"u"&&a.uri!==n&&(delete this._registeredResources[n],a.uri&&(this._registeredResources[a.uri]=i)),typeof a.name<"u"&&(i.name=a.name),typeof a.title<"u"&&(i.title=a.title),typeof a.metadata<"u"&&(i.metadata=a.metadata),typeof a.callback<"u"&&(i.readCallback=a.callback),typeof a.enabled<"u"&&(i.enabled=a.enabled),this.sendResourceListChanged()}};return this._registeredResources[n]=i,i}_createRegisteredResourceTemplate(e,r,n,s,o){const i={resourceTemplate:n,title:r,metadata:s,readCallback:o,enabled:!0,disable:()=>i.update({enabled:!1}),enable:()=>i.update({enabled:!0}),remove:()=>i.update({name:null}),update:a=>{typeof a.name<"u"&&a.name!==e&&(delete this._registeredResourceTemplates[e],a.name&&(this._registeredResourceTemplates[a.name]=i)),typeof a.title<"u"&&(i.title=a.title),typeof a.template<"u"&&(i.resourceTemplate=a.template),typeof a.metadata<"u"&&(i.metadata=a.metadata),typeof a.callback<"u"&&(i.readCallback=a.callback),typeof a.enabled<"u"&&(i.enabled=a.enabled),this.sendResourceListChanged()}};return this._registeredResourceTemplates[e]=i,i}_createRegisteredPrompt(e,r,n,s,o){const i={title:r,description:n,argsSchema:s===void 0?void 0:jn(s),callback:o,enabled:!0,disable:()=>i.update({enabled:!1}),enable:()=>i.update({enabled:!0}),remove:()=>i.update({name:null}),update:a=>{typeof a.name<"u"&&a.name!==e&&(delete this._registeredPrompts[e],a.name&&(this._registeredPrompts[a.name]=i)),typeof a.title<"u"&&(i.title=a.title),typeof a.description<"u"&&(i.description=a.description),typeof a.argsSchema<"u"&&(i.argsSchema=jn(a.argsSchema)),typeof a.callback<"u"&&(i.callback=a.callback),typeof a.enabled<"u"&&(i.enabled=a.enabled),this.sendPromptListChanged()}};return this._registeredPrompts[e]=i,i}_createRegisteredTool(e,r,n,s,o,i,a,c){sf(e);const u={title:r,description:n,inputSchema:af(s),outputSchema:af(o),annotations:i,_meta:a,callback:c,enabled:!0,disable:()=>u.update({enabled:!1}),enable:()=>u.update({enabled:!0}),remove:()=>u.update({name:null}),update:l=>{typeof l.name<"u"&&l.name!==e&&(typeof l.name=="string"&&sf(l.name),delete this._registeredTools[e],l.name&&(this._registeredTools[l.name]=u)),typeof l.title<"u"&&(u.title=l.title),typeof l.description<"u"&&(u.description=l.description),typeof l.paramsSchema<"u"&&(u.inputSchema=jn(l.paramsSchema)),typeof l.callback<"u"&&(u.callback=l.callback),typeof l.annotations<"u"&&(u.annotations=l.annotations),typeof l._meta<"u"&&(u._meta=l._meta),typeof l.enabled<"u"&&(u.enabled=l.enabled),this.sendToolListChanged()}};return this._registeredTools[e]=u,this.setToolRequestHandlers(),this.sendToolListChanged(),u}tool(e,...r){if(this._registeredTools[e])throw new Error(`Tool ${e} is already registered`);let n,s,o,i;if(typeof r[0]=="string"&&(n=r.shift()),r.length>1){const c=r[0];Wa(c)?(s=r.shift(),r.length>1&&typeof r[0]=="object"&&r[0]!==null&&!Wa(r[0])&&(i=r.shift())):typeof c=="object"&&c!==null&&(i=r.shift())}const a=r[0];return this._createRegisteredTool(e,void 0,n,s,o,i,void 0,a)}registerTool(e,r,n){if(this._registeredTools[e])throw new Error(`Tool ${e} is already registered`);const{title:s,description:o,inputSchema:i,outputSchema:a,annotations:c,_meta:u}=r;return this._createRegisteredTool(e,s,o,i,a,c,u,n)}prompt(e,...r){if(this._registeredPrompts[e])throw new Error(`Prompt ${e} is already registered`);let n;typeof r[0]=="string"&&(n=r.shift());let s;r.length>1&&(s=r.shift());const o=r[0],i=this._createRegisteredPrompt(e,void 0,n,s,o);return this.setPromptRequestHandlers(),this.sendPromptListChanged(),i}registerPrompt(e,r,n){if(this._registeredPrompts[e])throw new Error(`Prompt ${e} is already registered`);const{title:s,description:o,argsSchema:i}=r,a=this._createRegisteredPrompt(e,s,o,i,n);return this.setPromptRequestHandlers(),this.sendPromptListChanged(),a}isConnected(){return this.server.transport!==void 0}async sendLoggingMessage(e,r){return this.server.sendLoggingMessage(e,r)}sendResourceListChanged(){this.isConnected()&&this.server.sendResourceListChanged()}sendToolListChanged(){this.isConnected()&&this.server.sendToolListChanged()}sendPromptListChanged(){this.isConnected()&&this.server.sendPromptListChanged()}}class _S{constructor(e,r){this._callbacks=r,this._uriTemplate=typeof e=="string"?new Jt(e):e}get uriTemplate(){return this._uriTemplate}get listCallback(){return this._callbacks.list}completeCallback(e){var r;return(r=this._callbacks.complete)===null||r===void 0?void 0:r[e]}}const gS={type:"object",properties:{}};function Wa(t){return typeof t!="object"||t===null?!1:Object.keys(t).length===0||Object.values(t).some(vS)}function vS(t){return t!==null&&typeof t=="object"&&"parse"in t&&typeof t.parse=="function"&&"safeParse"in t&&typeof t.safeParse=="function"}function af(t){if(t)return Wa(t)?jn(t):t}function yS(t){const e=qn(t);return e?Object.entries(e).map(([r,n])=>{const s=Yb(n),o=Qb(n);return{name:r,description:s,required:!o}}):[]}function cr(t){const e=qn(t),r=e?.method;if(!r)throw new Error("Schema is missing a method literal");const n=uh(r);if(typeof n=="string")return n;throw new Error("Schema method literal must be a string")}function cf(t){return{completion:{values:t.slice(0,100),total:t.length,hasMore:t.length>100}}}const Zn={completion:{values:[],hasMore:!1}};class wS{constructor(e,r){const n={name:"web-mcp-server",version:"1.0.0"},s={prompts:{listChanged:!0},resources:{subscribe:!0,listChanged:!0},tools:{listChanged:!0},completions:{},logging:{}};this.server=new of(e||n,r||{capabilities:s}),this.server.server.oninitialized=()=>{this.oninitialized?.()},this.server.server.onclose=()=>{this.onclose?.()},this.server.server.onerror=o=>{this.onerror?.(o)},this.server.server.setRequestHandler(Oo,async()=>({}))}async connect(e){return typeof e.start=="function"?(this.transport=e,this.transport.onclose=void 0,this.transport.onerror=void 0,this.transport.onmessage=void 0):(this.transport=new $a(e),await this.transport.listen()),await this.server.connect(this.transport),this.transport}async close(){await this.server.close()}registerTool(e,r,n){return this.server.registerTool(e,r,n)}registerPrompt(e,r,n){return this.server.registerPrompt(e,r,n)}registerResource(e,r,n,s){return typeof r=="string"?this.server.registerResource(e,r,n,s):this.server.registerResource(e,r,n,s)}isConnected(){return this.server.isConnected()}sendResourceListChanged(){this.server.sendResourceListChanged()}sendToolListChanged(){this.server.sendToolListChanged()}sendPromptListChanged(){this.server.sendPromptListChanged()}getClientCapabilities(){return this.server.server.getClientCapabilities()}getClientVersion(){return this.server.server.getClientVersion()}async ping(){return await this.server.server.ping()}async createMessage(e,r){return await this.server.server.createMessage(e,r)}async elicitInput(e,r){return await this.server.server.elicitInput(e,r)}async listRoots(e,r){return await this.server.server.listRoots(e,r)}async sendLoggingMessage(e){return await this.server.server.sendLoggingMessage(e)}async sendResourceUpdated(e){return await this.server.server.sendResourceUpdated(e)}request(e,r,n){return this.server.server.request(e,r,n)}async notification(e,r){return await this.server.server.notification(e,r)}setRequestHandler(e,r){this.server.server.setRequestHandler(e,r)}removeRequestHandler(e){this.server.server.removeRequestHandler(e)}setNotificationHandler(e,r){this.server.server.setNotificationHandler(e,r)}removeNotificationHandler(e){this.server.server.removeNotificationHandler(e)}onSubscribe(e){this.server.server.setRequestHandler(xh,e)}onUnsubscribe(e){this.server.server.setRequestHandler(Ih,e)}onSetLogLevel(e){this.server.server.setRequestHandler(Oo,e)}onListResources(e){this.server.server.setRequestHandler(xo,e)}onRootsListChanged(e){this.server.server.setNotificationHandler(Jh,e)}async onPagehide(e){e.persisted||this.transport&&typeof this.transport.close=="function"&&await this.transport.close()}}const bS=(t,e)=>new $a(t,e),$S=()=>Ob(),SS=t=>t instanceof $a,kS=t=>t instanceof of;function Mo(t,e){if(!(!t||e===null||typeof e!="object")){if(t.type==="object"&&t.properties&&typeof t.properties=="object"){const r=e,n=t.properties;for(const s of Object.keys(n)){const o=n[s];r[s]===void 0&&Object.prototype.hasOwnProperty.call(o,"default")&&(r[s]=o.default),r[s]!==void 0&&Mo(o,r[s])}}if(Array.isArray(t.anyOf))for(const r of t.anyOf)Mo(r,e);if(Array.isArray(t.oneOf))for(const r of t.oneOf)Mo(r,e)}}function TS(t){if(!t)return{supportsFormMode:!1,supportsUrlMode:!1};const e=t.form!==void 0,r=t.url!==void 0;return{supportsFormMode:e||!e&&!r,supportsUrlMode:r}}class uf extends Yh{constructor(e,r){var n,s;super(r),this._clientInfo=e,this._cachedToolOutputValidators=new Map,this._capabilities=(n=r?.capabilities)!==null&&n!==void 0?n:{},this._jsonSchemaValidator=(s=r?.jsonSchemaValidator)!==null&&s!==void 0?s:new ef}registerCapabilities(e){if(this.transport)throw new Error("Cannot register capabilities after connecting to transport");this._capabilities=Xh(this._capabilities,e)}setRequestHandler(e,r){var n,s,o;const i=qn(e),a=i?.method;if(!a)throw new Error("Schema is missing a method literal");let c;if(Pt(a)){const l=a,d=(n=l._zod)===null||n===void 0?void 0:n.def;c=(s=d?.value)!==null&&s!==void 0?s:l.value}else{const l=a,d=l._def;c=(o=d?.value)!==null&&o!==void 0?o:l.value}if(typeof c!="string")throw new Error("Schema method literal must be a string");if(c==="elicitation/create"){const l=async(d,p)=>{var _,m,g;const f=ko(Da,d);if(!f.success){const j=f.error instanceof Error?f.error.message:String(f.error);throw new we(ye.InvalidParams,`Invalid elicitation request: ${j}`)}const{params:v}=f.data,h=(_=v.mode)!==null&&_!==void 0?_:"form",{supportsFormMode:w,supportsUrlMode:$}=TS(this._capabilities.elicitation);if(h==="form"&&!w)throw new we(ye.InvalidParams,"Client does not support form-mode elicitation requests");if(h==="url"&&!$)throw new we(ye.InvalidParams,"Client does not support URL-mode elicitation requests");const b=await Promise.resolve(r(d,p)),S=ko(Ao,b);if(!S.success){const j=S.error instanceof Error?S.error.message:String(S.error);throw new we(ye.InvalidParams,`Invalid elicitation result: ${j}`)}const T=S.data,N=h==="form"?v.requestedSchema:void 0;if(h==="form"&&T.action==="accept"&&T.content&&N&&!((g=(m=this._capabilities.elicitation)===null||m===void 0?void 0:m.form)===null||g===void 0)&&g.applyDefaults)try{Mo(N,T.content)}catch{}return T};return super.setRequestHandler(e,l)}return super.setRequestHandler(e,r)}assertCapability(e,r){var n;if(!(!((n=this._serverCapabilities)===null||n===void 0)&&n[e]))throw new Error(`Server does not support ${e} (required for ${r})`)}async connect(e,r){if(await super.connect(e),e.sessionId===void 0)try{const n=await this.request({method:"initialize",params:{protocolVersion:Un,capabilities:this._capabilities,clientInfo:this._clientInfo}},wh,r);if(n===void 0)throw new Error(`Server sent invalid initialize result: ${n}`);if(!lh.includes(n.protocolVersion))throw new Error(`Server's protocol version is not supported: ${n.protocolVersion}`);this._serverCapabilities=n.capabilities,this._serverVersion=n.serverInfo,e.setProtocolVersion&&e.setProtocolVersion(n.protocolVersion),this._instructions=n.instructions,await this.notification({method:"notifications/initialized"})}catch(n){throw this.close(),n}}getServerCapabilities(){return this._serverCapabilities}getServerVersion(){return this._serverVersion}getInstructions(){return this._instructions}assertCapabilityForMethod(e){var r,n,s,o,i;switch(e){case"logging/setLevel":if(!(!((r=this._serverCapabilities)===null||r===void 0)&&r.logging))throw new Error(`Server does not support logging (required for ${e})`);break;case"prompts/get":case"prompts/list":if(!(!((n=this._serverCapabilities)===null||n===void 0)&&n.prompts))throw new Error(`Server does not support prompts (required for ${e})`);break;case"resources/list":case"resources/templates/list":case"resources/read":case"resources/subscribe":case"resources/unsubscribe":if(!(!((s=this._serverCapabilities)===null||s===void 0)&&s.resources))throw new Error(`Server does not support resources (required for ${e})`);if(e==="resources/subscribe"&&!this._serverCapabilities.resources.subscribe)throw new Error(`Server does not support resource subscriptions (required for ${e})`);break;case"tools/call":case"tools/list":if(!(!((o=this._serverCapabilities)===null||o===void 0)&&o.tools))throw new Error(`Server does not support tools (required for ${e})`);break;case"completion/complete":if(!(!((i=this._serverCapabilities)===null||i===void 0)&&i.completions))throw new Error(`Server does not support completions (required for ${e})`);break}}assertNotificationCapability(e){var r;switch(e){case"notifications/roots/list_changed":if(!(!((r=this._capabilities.roots)===null||r===void 0)&&r.listChanged))throw new Error(`Client does not support roots list changed notifications (required for ${e})`);break}}assertRequestHandlerCapability(e){switch(e){case"sampling/createMessage":if(!this._capabilities.sampling)throw new Error(`Client does not support sampling capability (required for ${e})`);break;case"elicitation/create":if(!this._capabilities.elicitation)throw new Error(`Client does not support elicitation capability (required for ${e})`);break;case"roots/list":if(!this._capabilities.roots)throw new Error(`Client does not support roots capability (required for ${e})`);break}}async ping(e){return this.request({method:"ping"},$r,e)}async complete(e,r){return this.request({method:"completion/complete",params:e},Hh,r)}async setLoggingLevel(e,r){return this.request({method:"logging/setLevel",params:{level:e}},$r,r)}async getPrompt(e,r){return this.request({method:"prompts/get",params:e},jh,r)}async listPrompts(e,r){return this.request({method:"prompts/list",params:e},Oh,r)}async listResources(e,r){return this.request({method:"resources/list",params:e},Th,r)}async listResourceTemplates(e,r){return this.request({method:"resources/templates/list",params:e},Rh,r)}async readResource(e,r){return this.request({method:"resources/read",params:e},Eh,r)}async subscribeResource(e,r){return this.request({method:"resources/subscribe",params:e},$r,r)}async unsubscribeResource(e,r){return this.request({method:"resources/unsubscribe",params:e},$r,r)}async callTool(e,r=Io,n){const s=await this.request({method:"tools/call",params:e},r,n),o=this.getToolOutputValidator(e.name);if(o){if(!s.structuredContent&&!s.isError)throw new we(ye.InvalidRequest,`Tool ${e.name} has an output schema but did not return structured content`);if(s.structuredContent)try{const i=o(s.structuredContent);if(!i.valid)throw new we(ye.InvalidParams,`Structured content does not match the tool's output schema: ${i.errorMessage}`)}catch(i){throw i instanceof we?i:new we(ye.InvalidParams,`Failed to validate structured content: ${i instanceof Error?i.message:String(i)}`)}}return s}cacheToolOutputSchemas(e){this._cachedToolOutputValidators.clear();for(const r of e)if(r.outputSchema){const n=this._jsonSchemaValidator.getValidator(r.outputSchema);this._cachedToolOutputValidators.set(r.name,n)}}getToolOutputValidator(e){return this._cachedToolOutputValidators.get(e)}async listTools(e,r){const n=await this.request({method:"tools/list",params:e},Uh,r);return this.cacheToolOutputSchemas(n.tools),n}async sendRootsListChanged(){return this.notification({method:"notifications/roots/list_changed"})}}function Ja(t){return t?t instanceof Headers?Object.fromEntries(t.entries()):Array.isArray(t)?Object.fromEntries(t):{...t}:{}}function lf(t=fetch,e){return e?async(r,n)=>{const s={...e,...n,headers:n?.headers?{...Ja(e.headers),...Ja(n.headers)}:e.headers};return t(r,s)}:t}const Je=Pl().superRefine((t,e)=>{if(!URL.canParse(t))return e.addIssue({code:Ll.custom,message:"URL must be parseable",fatal:!0}),Uu}).refine(t=>{const e=new URL(t);return e.protocol!=="javascript:"&&e.protocol!=="data:"&&e.protocol!=="vbscript:"},{message:"URL cannot use javascript:, data:, or vbscript: scheme"}),RS=Ee({resource:y().url(),authorization_servers:x(Je).optional(),jwks_uri:y().url().optional(),scopes_supported:x(y()).optional(),bearer_methods_supported:x(y()).optional(),resource_signing_alg_values_supported:x(y()).optional(),resource_name:y().optional(),resource_documentation:y().optional(),resource_policy_uri:y().url().optional(),resource_tos_uri:y().url().optional(),tls_client_certificate_bound_access_tokens:oe().optional(),authorization_details_types_supported:x(y()).optional(),dpop_signing_alg_values_supported:x(y()).optional(),dpop_bound_access_tokens_required:oe().optional()}),df=Ee({issuer:y(),authorization_endpoint:Je,token_endpoint:Je,registration_endpoint:Je.optional(),scopes_supported:x(y()).optional(),response_types_supported:x(y()),response_modes_supported:x(y()).optional(),grant_types_supported:x(y()).optional(),token_endpoint_auth_methods_supported:x(y()).optional(),token_endpoint_auth_signing_alg_values_supported:x(y()).optional(),service_documentation:Je.optional(),revocation_endpoint:Je.optional(),revocation_endpoint_auth_methods_supported:x(y()).optional(),revocation_endpoint_auth_signing_alg_values_supported:x(y()).optional(),introspection_endpoint:y().optional(),introspection_endpoint_auth_methods_supported:x(y()).optional(),introspection_endpoint_auth_signing_alg_values_supported:x(y()).optional(),code_challenge_methods_supported:x(y()).optional(),client_id_metadata_document_supported:oe().optional()}),ES=Ee({issuer:y(),authorization_endpoint:Je,token_endpoint:Je,userinfo_endpoint:Je.optional(),jwks_uri:Je,registration_endpoint:Je.optional(),scopes_supported:x(y()).optional(),response_types_supported:x(y()),response_modes_supported:x(y()).optional(),grant_types_supported:x(y()).optional(),acr_values_supported:x(y()).optional(),subject_types_supported:x(y()),id_token_signing_alg_values_supported:x(y()),id_token_encryption_alg_values_supported:x(y()).optional(),id_token_encryption_enc_values_supported:x(y()).optional(),userinfo_signing_alg_values_supported:x(y()).optional(),userinfo_encryption_alg_values_supported:x(y()).optional(),userinfo_encryption_enc_values_supported:x(y()).optional(),request_object_signing_alg_values_supported:x(y()).optional(),request_object_encryption_alg_values_supported:x(y()).optional(),request_object_encryption_enc_values_supported:x(y()).optional(),token_endpoint_auth_methods_supported:x(y()).optional(),token_endpoint_auth_signing_alg_values_supported:x(y()).optional(),display_values_supported:x(y()).optional(),claim_types_supported:x(y()).optional(),claims_supported:x(y()).optional(),service_documentation:y().optional(),claims_locales_supported:x(y()).optional(),ui_locales_supported:x(y()).optional(),claims_parameter_supported:oe().optional(),request_parameter_supported:oe().optional(),request_uri_parameter_supported:oe().optional(),require_request_uri_registration:oe().optional(),op_policy_uri:Je.optional(),op_tos_uri:Je.optional(),client_id_metadata_document_supported:oe().optional()}),PS=C({...ES.shape,...df.pick({code_challenge_methods_supported:!0}).shape}),hf=C({access_token:y(),id_token:y().optional(),token_type:y(),expires_in:ne().optional(),scope:y().optional(),refresh_token:y().optional()}).strip(),xS=C({error:y(),error_description:y().optional(),error_uri:y().optional()}),ff=Je.optional().or(z("").transform(()=>{})),IS=C({redirect_uris:x(Je),token_endpoint_auth_method:y().optional(),grant_types:x(y()).optional(),response_types:x(y()).optional(),client_name:y().optional(),client_uri:Je.optional(),logo_uri:ff,scope:y().optional(),contacts:x(y()).optional(),tos_uri:ff,policy_uri:y().optional(),jwks_uri:Je.optional(),jwks:Cl().optional(),software_id:y().optional(),software_version:y().optional(),software_statement:y().optional()}).strip(),CS=C({client_id:y(),client_secret:y().optional(),client_id_issued_at:ne().optional(),client_secret_expires_at:ne().optional()}).strip(),OS=IS.merge(CS);C({error:y(),error_description:y().optional()}).strip(),C({token:y(),token_type_hint:y().optional()}).strip();function NS(t){const e=typeof t=="string"?new URL(t):new URL(t.href);return e.hash="",e}function AS({requestedResource:t,configuredResource:e}){const r=typeof t=="string"?new URL(t):new URL(t.href),n=typeof e=="string"?new URL(e):new URL(e.href);if(r.origin!==n.origin||r.pathname.length<n.pathname.length)return!1;const s=r.pathname.endsWith("/")?r.pathname:r.pathname+"/",o=n.pathname.endsWith("/")?n.pathname:n.pathname+"/";return s.startsWith(o)}class Be extends Error{constructor(e,r){super(e),this.errorUri=r,this.name=this.constructor.name}toResponseObject(){const e={error:this.errorCode,error_description:this.message};return this.errorUri&&(e.error_uri=this.errorUri),e}get errorCode(){return this.constructor.errorCode}}class Ba extends Be{}Ba.errorCode="invalid_request";class jo extends Be{}jo.errorCode="invalid_client";class qo extends Be{}qo.errorCode="invalid_grant";class zo extends Be{}zo.errorCode="unauthorized_client";class Ka extends Be{}Ka.errorCode="unsupported_grant_type";class Ga extends Be{}Ga.errorCode="invalid_scope";class Ya extends Be{}Ya.errorCode="access_denied";class Wr extends Be{}Wr.errorCode="server_error";class Qa extends Be{}Qa.errorCode="temporarily_unavailable";class Xa extends Be{}Xa.errorCode="unsupported_response_type";class ec extends Be{}ec.errorCode="unsupported_token_type";class tc extends Be{}tc.errorCode="invalid_token";class rc extends Be{}rc.errorCode="method_not_allowed";class nc extends Be{}nc.errorCode="too_many_requests";class Uo extends Be{}Uo.errorCode="invalid_client_metadata";class sc extends Be{}sc.errorCode="insufficient_scope";const MS={[Ba.errorCode]:Ba,[jo.errorCode]:jo,[qo.errorCode]:qo,[zo.errorCode]:zo,[Ka.errorCode]:Ka,[Ga.errorCode]:Ga,[Ya.errorCode]:Ya,[Wr.errorCode]:Wr,[Qa.errorCode]:Qa,[Xa.errorCode]:Xa,[ec.errorCode]:ec,[tc.errorCode]:tc,[rc.errorCode]:rc,[nc.errorCode]:nc,[Uo.errorCode]:Uo,[sc.errorCode]:sc};class Ct extends Error{constructor(e){super(e??"Unauthorized")}}function jS(t){return["client_secret_basic","client_secret_post","none"].includes(t)}const oc="code",ic="S256";function pf(t,e){const r=t.client_secret!==void 0;return e.length===0?r?"client_secret_post":"none":"token_endpoint_auth_method"in t&&t.token_endpoint_auth_method&&jS(t.token_endpoint_auth_method)&&e.includes(t.token_endpoint_auth_method)?t.token_endpoint_auth_method:r&&e.includes("client_secret_basic")?"client_secret_basic":r&&e.includes("client_secret_post")?"client_secret_post":e.includes("none")?"none":r?"client_secret_post":"none"}function mf(t,e,r,n){const{client_id:s,client_secret:o}=e;switch(t){case"client_secret_basic":qS(s,o,r);return;case"client_secret_post":zS(s,o,n);return;case"none":US(s,n);return;default:throw new Error(`Unsupported client authentication method: ${t}`)}}function qS(t,e,r){if(!e)throw new Error("client_secret_basic authentication requires a client_secret");const n=btoa(`${t}:${e}`);r.set("Authorization",`Basic ${n}`)}function zS(t,e,r){r.set("client_id",t),e&&r.set("client_secret",e)}function US(t,e){e.set("client_id",t)}async function ac(t){const e=t instanceof Response?t.status:void 0,r=t instanceof Response?await t.text():t;try{const n=xS.parse(JSON.parse(r)),{error:s,error_description:o,error_uri:i}=n,a=MS[s]||Wr;return new a(o||"",i)}catch(n){const s=`${e?`HTTP ${e}: `:""}Invalid OAuth error response: ${n}. Raw body: ${r}`;return new Wr(s)}}async function Sr(t,e){var r,n;try{return await cc(t,e)}catch(s){if(s instanceof jo||s instanceof zo)return await((r=t.invalidateCredentials)===null||r===void 0?void 0:r.call(t,"all")),await cc(t,e);if(s instanceof qo)return await((n=t.invalidateCredentials)===null||n===void 0?void 0:n.call(t,"tokens")),await cc(t,e);throw s}}async function cc(t,{serverUrl:e,authorizationCode:r,scope:n,resourceMetadataUrl:s,fetchFn:o}){var i,a;let c,u;try{c=await DS(e,{resourceMetadataUrl:s},o),c.authorization_servers&&c.authorization_servers.length>0&&(u=c.authorization_servers[0])}catch{}u||(u=new URL("/",e));const l=await ZS(e,t,c),d=await JS(u,{fetchFn:o});let p=await Promise.resolve(t.clientInformation());if(!p){if(r!==void 0)throw new Error("Existing OAuth client information is required when exchanging an authorization code");const v=d?.client_id_metadata_document_supported===!0,h=t.clientMetadataUrl;if(h&&!LS(h))throw new Uo(`clientMetadataUrl must be a valid HTTPS URL with a non-root pathname, got: ${h}`);if(v&&h)p={client_id:h},await((i=t.saveClientInformation)===null||i===void 0?void 0:i.call(t,p));else{if(!t.saveClientInformation)throw new Error("OAuth client information must be saveable for dynamic registration");const $=await YS(u,{metadata:d,clientMetadata:t.clientMetadata,fetchFn:o});await t.saveClientInformation($),p=$}}if(r!==void 0){const v=await t.codeVerifier(),h=await KS(u,{metadata:d,clientInformation:p,authorizationCode:r,codeVerifier:v,redirectUri:t.redirectUrl,resource:l,addClientAuthentication:t.addClientAuthentication,fetchFn:o});return await t.saveTokens(h),"AUTHORIZED"}const _=await t.tokens();if(_?.refresh_token)try{const v=await GS(u,{metadata:d,clientInformation:p,refreshToken:_.refresh_token,resource:l,addClientAuthentication:t.addClientAuthentication,fetchFn:o});return await t.saveTokens(v),"AUTHORIZED"}catch(v){if(!(!(v instanceof Be)||v instanceof Wr))throw v}const m=t.state?await t.state():void 0,{authorizationUrl:g,codeVerifier:f}=await BS(u,{metadata:d,clientInformation:p,state:m,redirectUrl:t.redirectUrl,scope:n||((a=c?.scopes_supported)===null||a===void 0?void 0:a.join(" "))||t.clientMetadata.scope,resource:l});return await t.saveCodeVerifier(f),await t.redirectToAuthorization(g),"REDIRECT"}function LS(t){if(!t)return!1;try{const e=new URL(t);return e.protocol==="https:"&&e.pathname!=="/"}catch{return!1}}async function ZS(t,e,r){const n=NS(t);if(e.validateResourceURL)return await e.validateResourceURL(n,r?.resource);if(r){if(!AS({requestedResource:n,configuredResource:r.resource}))throw new Error(`Protected resource ${r.resource} does not match expected ${n} (or origin)`);return new URL(r.resource)}}function Lo(t){const e=t.headers.get("WWW-Authenticate");if(!e)return{};const[r,n]=e.split(" ");if(r.toLowerCase()!=="bearer"||!n)return{};const s=uc(t,"resource_metadata")||void 0;let o;if(s)try{o=new URL(s)}catch{}const i=uc(t,"scope")||void 0,a=uc(t,"error")||void 0;return{resourceMetadataUrl:o,scope:i,error:a}}function uc(t,e){const r=t.headers.get("WWW-Authenticate");if(!r)return null;const n=new RegExp(`${e}=(?:"([^"]+)"|([^\\s,]+))`),s=r.match(n);return s?s[1]||s[2]:null}async function DS(t,e,r=fetch){const n=await FS(t,"oauth-protected-resource",r,{protocolVersion:e?.protocolVersion,metadataUrl:e?.resourceMetadataUrl});if(!n||n.status===404)throw new Error("Resource server does not implement OAuth 2.0 Protected Resource Metadata.");if(!n.ok)throw new Error(`HTTP ${n.status} trying to load well-known OAuth protected resource metadata.`);return RS.parse(await n.json())}async function lc(t,e,r=fetch){try{return await r(t,{headers:e})}catch(n){if(n instanceof TypeError)return e?lc(t,void 0,r):void 0;throw n}}function VS(t,e="",r={}){return e.endsWith("/")&&(e=e.slice(0,-1)),r.prependPathname?`${e}/.well-known/${t}`:`/.well-known/${t}${e}`}async function _f(t,e,r=fetch){return await lc(t,{"MCP-Protocol-Version":e},r)}function HS(t,e){return!t||t.status>=400&&t.status<500&&e!=="/"}async function FS(t,e,r,n){var s,o;const i=new URL(t),a=(s=n?.protocolVersion)!==null&&s!==void 0?s:Un;let c;if(n?.metadataUrl)c=new URL(n.metadataUrl);else{const l=VS(e,i.pathname);c=new URL(l,(o=n?.metadataServerUrl)!==null&&o!==void 0?o:i),c.search=i.search}let u=await _f(c,a,r);if(!n?.metadataUrl&&HS(u,i.pathname)){const l=new URL(`/.well-known/${e}`,i);u=await _f(l,a,r)}return u}function WS(t){const e=typeof t=="string"?new URL(t):t,r=e.pathname!=="/",n=[];if(!r)return n.push({url:new URL("/.well-known/oauth-authorization-server",e.origin),type:"oauth"}),n.push({url:new URL("/.well-known/openid-configuration",e.origin),type:"oidc"}),n;let s=e.pathname;return s.endsWith("/")&&(s=s.slice(0,-1)),n.push({url:new URL(`/.well-known/oauth-authorization-server${s}`,e.origin),type:"oauth"}),n.push({url:new URL(`/.well-known/openid-configuration${s}`,e.origin),type:"oidc"}),n.push({url:new URL(`${s}/.well-known/openid-configuration`,e.origin),type:"oidc"}),n}async function JS(t,{fetchFn:e=fetch,protocolVersion:r=Un}={}){const n={"MCP-Protocol-Version":r,Accept:"application/json"},s=WS(t);for(const{url:o,type:i}of s){const a=await lc(o,n,e);if(a){if(!a.ok){if(a.status>=400&&a.status<500)continue;throw new Error(`HTTP ${a.status} trying to load ${i==="oauth"?"OAuth":"OpenID provider"} metadata from ${o}`)}return i==="oauth"?df.parse(await a.json()):PS.parse(await a.json())}}}async function BS(t,{metadata:e,clientInformation:r,redirectUrl:n,scope:s,state:o,resource:i}){let a;if(e){if(a=new URL(e.authorization_endpoint),!e.response_types_supported.includes(oc))throw new Error(`Incompatible auth server: does not support response type ${oc}`);if(e.code_challenge_methods_supported&&!e.code_challenge_methods_supported.includes(ic))throw new Error(`Incompatible auth server: does not support code challenge method ${ic}`)}else a=new URL("/authorize",t);const c=await Yd(),u=c.code_verifier,l=c.code_challenge;return a.searchParams.set("response_type",oc),a.searchParams.set("client_id",r.client_id),a.searchParams.set("code_challenge",l),a.searchParams.set("code_challenge_method",ic),a.searchParams.set("redirect_uri",String(n)),o&&a.searchParams.set("state",o),s&&a.searchParams.set("scope",s),s?.includes("offline_access")&&a.searchParams.append("prompt","consent"),i&&a.searchParams.set("resource",i.href),{authorizationUrl:a,codeVerifier:u}}async function KS(t,{metadata:e,clientInformation:r,authorizationCode:n,codeVerifier:s,redirectUri:o,resource:i,addClientAuthentication:a,fetchFn:c}){var u;const l="authorization_code",d=e?.token_endpoint?new URL(e.token_endpoint):new URL("/token",t);if(e?.grant_types_supported&&!e.grant_types_supported.includes(l))throw new Error(`Incompatible auth server: does not support grant type ${l}`);const p=new Headers({"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json"}),_=new URLSearchParams({grant_type:l,code:n,code_verifier:s,redirect_uri:String(o)});if(a)a(p,_,t,e);else{const g=(u=e?.token_endpoint_auth_methods_supported)!==null&&u!==void 0?u:[],f=pf(r,g);mf(f,r,p,_)}i&&_.set("resource",i.href);const m=await(c??fetch)(d,{method:"POST",headers:p,body:_});if(!m.ok)throw await ac(m);return hf.parse(await m.json())}async function GS(t,{metadata:e,clientInformation:r,refreshToken:n,resource:s,addClientAuthentication:o,fetchFn:i}){var a;const c="refresh_token";let u;if(e){if(u=new URL(e.token_endpoint),e.grant_types_supported&&!e.grant_types_supported.includes(c))throw new Error(`Incompatible auth server: does not support grant type ${c}`)}else u=new URL("/token",t);const l=new Headers({"Content-Type":"application/x-www-form-urlencoded"}),d=new URLSearchParams({grant_type:c,refresh_token:n});if(o)o(l,d,t,e);else{const _=(a=e?.token_endpoint_auth_methods_supported)!==null&&a!==void 0?a:[],m=pf(r,_);mf(m,r,l,d)}s&&d.set("resource",s.href);const p=await(i??fetch)(u,{method:"POST",headers:l,body:d});if(!p.ok)throw await ac(p);return hf.parse({refresh_token:n,...await p.json()})}async function YS(t,{metadata:e,clientMetadata:r,fetchFn:n}){let s;if(e){if(!e.registration_endpoint)throw new Error("Incompatible auth server: does not support dynamic client registration");s=new URL(e.registration_endpoint)}else s=new URL("/register",t);const o=await(n??fetch)(s,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)});if(!o.ok)throw await ac(o);return OS.parse(await o.json())}class QS extends Error{constructor(e,r,n){super(`SSE error: ${r}`),this.code=e,this.event=n}}class dc{constructor(e,r){this._url=e,this._resourceMetadataUrl=void 0,this._scope=void 0,this._eventSourceInit=r?.eventSourceInit,this._requestInit=r?.requestInit,this._authProvider=r?.authProvider,this._fetch=r?.fetch,this._fetchWithInit=lf(r?.fetch,r?.requestInit)}async _authThenStart(){var e;if(!this._authProvider)throw new Ct("No auth provider");let r;try{r=await Sr(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})}catch(n){throw(e=this.onerror)===null||e===void 0||e.call(this,n),n}if(r!=="AUTHORIZED")throw new Ct;return await this._startOrAuth()}async _commonHeaders(){var e;const r={};if(this._authProvider){const n=await this._authProvider.tokens();n&&(r.Authorization=`Bearer ${n.access_token}`)}return this._protocolVersion&&(r["mcp-protocol-version"]=this._protocolVersion),new Headers({...r,...(e=this._requestInit)===null||e===void 0?void 0:e.headers})}_startOrAuth(){var e,r,n;const s=(n=(r=(e=this===null||this===void 0?void 0:this._eventSourceInit)===null||e===void 0?void 0:e.fetch)!==null&&r!==void 0?r:this._fetch)!==null&&n!==void 0?n:fetch;return new Promise((o,i)=>{this._eventSource=new Nn(this._url.href,{...this._eventSourceInit,fetch:async(a,c)=>{const u=await this._commonHeaders();u.set("Accept","text/event-stream");const l=await s(a,{...c,headers:u});if(l.status===401&&l.headers.has("www-authenticate")){const{resourceMetadataUrl:d,scope:p}=Lo(l);this._resourceMetadataUrl=d,this._scope=p}return l}}),this._abortController=new AbortController,this._eventSource.onerror=a=>{var c;if(a.code===401&&this._authProvider){this._authThenStart().then(o,i);return}const u=new QS(a.code,a.message,a);i(u),(c=this.onerror)===null||c===void 0||c.call(this,u)},this._eventSource.onopen=()=>{},this._eventSource.addEventListener("endpoint",a=>{var c;const u=a;try{if(this._endpoint=new URL(u.data,this._url),this._endpoint.origin!==this._url.origin)throw new Error(`Endpoint origin does not match connection origin: ${this._endpoint.origin}`)}catch(l){i(l),(c=this.onerror)===null||c===void 0||c.call(this,l),this.close();return}o()}),this._eventSource.onmessage=a=>{var c,u;const l=a;let d;try{d=Hr.parse(JSON.parse(l.data))}catch(p){(c=this.onerror)===null||c===void 0||c.call(this,p);return}(u=this.onmessage)===null||u===void 0||u.call(this,d)}})}async start(){if(this._eventSource)throw new Error("SSEClientTransport already started! If using Client class, note that connect() calls start() automatically.");return await this._startOrAuth()}async finishAuth(e){if(!this._authProvider)throw new Ct("No auth provider");if(await Sr(this._authProvider,{serverUrl:this._url,authorizationCode:e,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new Ct("Failed to authorize")}async close(){var e,r,n;(e=this._abortController)===null||e===void 0||e.abort(),(r=this._eventSource)===null||r===void 0||r.close(),(n=this.onclose)===null||n===void 0||n.call(this)}async send(e){var r,n,s;if(!this._endpoint)throw new Error("Not connected");try{const o=await this._commonHeaders();o.set("content-type","application/json");const i={...this._requestInit,method:"POST",headers:o,body:JSON.stringify(e),signal:(r=this._abortController)===null||r===void 0?void 0:r.signal},a=await((n=this._fetch)!==null&&n!==void 0?n:fetch)(this._endpoint,i);if(!a.ok){if(a.status===401&&this._authProvider){const{resourceMetadataUrl:u,scope:l}=Lo(a);if(this._resourceMetadataUrl=u,this._scope=l,await Sr(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new Ct;return this.send(e)}const c=await a.text().catch(()=>null);throw new Error(`Error POSTing to endpoint (HTTP ${a.status}): ${c}`)}}catch(o){throw(s=this.onerror)===null||s===void 0||s.call(this,o),o}}setProtocolVersion(e){this._protocolVersion=e}}const XS={initialReconnectionDelay:1e3,maxReconnectionDelay:3e4,reconnectionDelayGrowFactor:1.5,maxRetries:2};class Dn extends Error{constructor(e,r){super(`Streamable HTTP error: ${r}`),this.code=e}}class hc{constructor(e,r){var n;this._hasCompletedAuthFlow=!1,this._url=e,this._resourceMetadataUrl=void 0,this._scope=void 0,this._requestInit=r?.requestInit,this._authProvider=r?.authProvider,this._fetch=r?.fetch,this._fetchWithInit=lf(r?.fetch,r?.requestInit),this._sessionId=r?.sessionId,this._reconnectionOptions=(n=r?.reconnectionOptions)!==null&&n!==void 0?n:XS}async _authThenStart(){var e;if(!this._authProvider)throw new Ct("No auth provider");let r;try{r=await Sr(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})}catch(n){throw(e=this.onerror)===null||e===void 0||e.call(this,n),n}if(r!=="AUTHORIZED")throw new Ct;return await this._startOrAuthSse({resumptionToken:void 0})}async _commonHeaders(){var e;const r={};if(this._authProvider){const s=await this._authProvider.tokens();s&&(r.Authorization=`Bearer ${s.access_token}`)}this._sessionId&&(r["mcp-session-id"]=this._sessionId),this._protocolVersion&&(r["mcp-protocol-version"]=this._protocolVersion);const n=Ja((e=this._requestInit)===null||e===void 0?void 0:e.headers);return new Headers({...r,...n})}async _startOrAuthSse(e){var r,n,s;const{resumptionToken:o}=e;try{const i=await this._commonHeaders();i.set("Accept","text/event-stream"),o&&i.set("last-event-id",o);const a=await((r=this._fetch)!==null&&r!==void 0?r:fetch)(this._url,{method:"GET",headers:i,signal:(n=this._abortController)===null||n===void 0?void 0:n.signal});if(!a.ok){if(a.status===401&&this._authProvider)return await this._authThenStart();if(a.status===405)return;throw new Dn(a.status,`Failed to open SSE stream: ${a.statusText}`)}this._handleSseStream(a.body,e,!0)}catch(i){throw(s=this.onerror)===null||s===void 0||s.call(this,i),i}}_getNextReconnectionDelay(e){if(this._serverRetryMs!==void 0)return this._serverRetryMs;const r=this._reconnectionOptions.initialReconnectionDelay,n=this._reconnectionOptions.reconnectionDelayGrowFactor,s=this._reconnectionOptions.maxReconnectionDelay;return Math.min(r*Math.pow(n,e),s)}_scheduleReconnection(e,r=0){var n;const s=this._reconnectionOptions.maxRetries;if(s>0&&r>=s){(n=this.onerror)===null||n===void 0||n.call(this,new Error(`Maximum reconnection attempts (${s}) exceeded.`));return}const o=this._getNextReconnectionDelay(r);setTimeout(()=>{this._startOrAuthSse(e).catch(i=>{var a;(a=this.onerror)===null||a===void 0||a.call(this,new Error(`Failed to reconnect SSE stream: ${i instanceof Error?i.message:String(i)}`)),this._scheduleReconnection(e,r+1)})},o)}_handleSseStream(e,r,n){if(!e)return;const{onresumptiontoken:s,replayMessageId:o}=r;let i,a=!1;(async()=>{var u,l,d,p;try{const _=e.pipeThrough(new TextDecoderStream).pipeThrough(new sh({onRetry:g=>{this._serverRetryMs=g}})).getReader();for(;;){const{value:g,done:f}=await _.read();if(f)break;if(g.id&&(i=g.id,a=!0,s?.(g.id)),!g.event||g.event==="message")try{const v=Hr.parse(JSON.parse(g.data));o!==void 0&&Pa(v)&&(v.id=o),(u=this.onmessage)===null||u===void 0||u.call(this,v)}catch(v){(l=this.onerror)===null||l===void 0||l.call(this,v)}}(n||a)&&this._abortController&&!this._abortController.signal.aborted&&this._scheduleReconnection({resumptionToken:i,onresumptiontoken:s,replayMessageId:o},0)}catch(_){if((d=this.onerror)===null||d===void 0||d.call(this,new Error(`SSE stream disconnected: ${_}`)),(n||a)&&this._abortController&&!this._abortController.signal.aborted)try{this._scheduleReconnection({resumptionToken:i,onresumptiontoken:s,replayMessageId:o},0)}catch(g){(p=this.onerror)===null||p===void 0||p.call(this,new Error(`Failed to reconnect: ${g instanceof Error?g.message:String(g)}`))}}})()}async start(){if(this._abortController)throw new Error("StreamableHTTPClientTransport already started! If using Client class, note that connect() calls start() automatically.");this._abortController=new AbortController}async finishAuth(e){if(!this._authProvider)throw new Ct("No auth provider");if(await Sr(this._authProvider,{serverUrl:this._url,authorizationCode:e,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new Ct("Failed to authorize")}async close(){var e,r;(e=this._abortController)===null||e===void 0||e.abort(),(r=this.onclose)===null||r===void 0||r.call(this)}async send(e,r){var n,s,o,i;try{const{resumptionToken:a,onresumptiontoken:c}=r||{};if(a){this._startOrAuthSse({resumptionToken:a,replayMessageId:ph(e)?e.id:void 0}).catch(f=>{var v;return(v=this.onerror)===null||v===void 0?void 0:v.call(this,f)});return}const u=await this._commonHeaders();u.set("content-type","application/json"),u.set("accept","application/json, text/event-stream");const l={...this._requestInit,method:"POST",headers:u,body:JSON.stringify(e),signal:(n=this._abortController)===null||n===void 0?void 0:n.signal},d=await((s=this._fetch)!==null&&s!==void 0?s:fetch)(this._url,l),p=d.headers.get("mcp-session-id");if(p&&(this._sessionId=p),!d.ok){if(d.status===401&&this._authProvider){if(this._hasCompletedAuthFlow)throw new Dn(401,"Server returned 401 after successful authentication");const{resourceMetadataUrl:v,scope:h}=Lo(d);if(this._resourceMetadataUrl=v,this._scope=h,await Sr(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new Ct;return this._hasCompletedAuthFlow=!0,this.send(e)}if(d.status===403&&this._authProvider){const{resourceMetadataUrl:v,scope:h,error:w}=Lo(d);if(w==="insufficient_scope"){const $=d.headers.get("WWW-Authenticate");if(this._lastUpscopingHeader===$)throw new Dn(403,"Server returned 403 after trying upscoping");if(h&&(this._scope=h),v&&(this._resourceMetadataUrl=v),this._lastUpscopingHeader=$??void 0,await Sr(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetch})!=="AUTHORIZED")throw new Ct;return this.send(e)}}const f=await d.text().catch(()=>null);throw new Error(`Error POSTing to endpoint (HTTP ${d.status}): ${f}`)}if(this._hasCompletedAuthFlow=!1,this._lastUpscopingHeader=void 0,d.status===202){u$(e)&&this._startOrAuthSse({resumptionToken:void 0}).catch(f=>{var v;return(v=this.onerror)===null||v===void 0?void 0:v.call(this,f)});return}const m=(Array.isArray(e)?e:[e]).filter(f=>"method"in f&&"id"in f&&f.id!==void 0).length>0,g=d.headers.get("content-type");if(m)if(g?.includes("text/event-stream"))this._handleSseStream(d.body,{onresumptiontoken:c},!1);else if(g?.includes("application/json")){const f=await d.json(),v=Array.isArray(f)?f.map(h=>Hr.parse(h)):[Hr.parse(f)];for(const h of v)(o=this.onmessage)===null||o===void 0||o.call(this,h)}else throw new Dn(-1,`Unexpected content type: ${g}`)}catch(a){throw(i=this.onerror)===null||i===void 0||i.call(this,a),a}}get sessionId(){return this._sessionId}async terminateSession(){var e,r,n;if(this._sessionId)try{const s=await this._commonHeaders(),o={...this._requestInit,method:"DELETE",headers:s,signal:(e=this._abortController)===null||e===void 0?void 0:e.signal},i=await((r=this._fetch)!==null&&r!==void 0?r:fetch)(this._url,o);if(!i.ok&&i.status!==405)throw new Dn(i.status,`Failed to terminate session: ${i.statusText}`);this._sessionId=void 0}catch(s){throw(n=this.onerror)===null||n===void 0||n.call(this,s),s}}setProtocolVersion(e){this._protocolVersion=e}get protocolVersion(){return this._protocolVersion}async resumeStream(e,r){await this._startOrAuthSse({resumptionToken:e,onresumptiontoken:r?.onresumptiontoken})}}const e1="mcp";class t1{constructor(e){this._url=e}start(){if(this._socket)throw new Error("WebSocketClientTransport already started! If using Client class, note that connect() calls start() automatically.");return new Promise((e,r)=>{this._socket=new WebSocket(this._url,e1),this._socket.onerror=n=>{var s;const o="error"in n?n.error:new Error(`WebSocket error: ${JSON.stringify(n)}`);r(o),(s=this.onerror)===null||s===void 0||s.call(this,o)},this._socket.onopen=()=>{e()},this._socket.onclose=()=>{var n;(n=this.onclose)===null||n===void 0||n.call(this)},this._socket.onmessage=n=>{var s,o;let i;try{i=Hr.parse(JSON.parse(n.data))}catch(a){(s=this.onerror)===null||s===void 0||s.call(this,a);return}(o=this.onmessage)===null||o===void 0||o.call(this,i)}})}async close(){var e;(e=this._socket)===null||e===void 0||e.close()}send(e){return new Promise((r,n)=>{var s;if(!this._socket){n(new Error("Not connected"));return}(s=this._socket)===null||s===void 0||s.send(JSON.stringify(e)),r()})}}class r1{constructor(e,r){const n={name:"web-mcp-client",version:"1.0.0"},s={roots:{listChanged:!0},sampling:{},elicitation:{}};this.client=new uf(e||n,r||{capabilities:s}),this.client.onclose=()=>{this.onclose?.()},this.client.onerror=o=>{this.onerror?.(o)}}async connect(e){if(typeof e.start=="function")return this.transport=e,this.transport.onclose=void 0,this.transport.onerror=void 0,this.transport.onmessage=void 0,await this.client.connect(this.transport),{transport:this.transport,sessionId:this.transport.sessionId};const{url:r,token:n,sessionId:s,type:o,agent:i,onError:a}=e;if(i===!0){const l={client:this.client,url:r,token:n,sessionId:s};let d;return await(async()=>{const{transport:_,sessionId:m}=o==="sse"?await Wb(l):o==="socket"?await Bb(l):await Jb(l);_.onerror=async g=>{a?.(g)},d={transport:_,sessionId:m}})(),d}const c=new URL(r);let u;if(o==="channel"&&(u=new ba(r),await this.client.connect(u)),o==="sse"){const l=ih(n,s);u=new dc(c,l),await this.client.connect(u)}if(o==="socket"&&(u=new t1(new URL(`${r}?sessionId=${s}&token=${n}`)),u.sessionId=s,await this.client.connect(u)),typeof u>"u"){const l=ah(n,s);u=new hc(c,l),await this.client.connect(u)}return this.transport=u,{transport:this.transport,sessionId:this.transport.sessionId}}async close(){await this.client.close()}getServerCapabilities(){return this.client.getServerCapabilities()}getServerVersion(){return this.client.getServerVersion()}getInstructions(){return this.client.getInstructions()}async ping(e){return await this.client.ping(e)}async complete(e,r){return await this.client.complete(e,r)}async setLoggingLevel(e,r){return await this.client.setLoggingLevel(e,r)}async getPrompt(e,r){return await this.client.getPrompt(e,r)}async listPrompts(e,r){return await this.client.listPrompts(e,r)}async listResources(e,r){return await this.client.listResources(e,r)}async listResourceTemplates(e,r){return await this.client.listResourceTemplates(e,r)}async readResource(e,r){return await this.client.readResource(e,r)}async subscribeResource(e,r){return await this.client.subscribeResource(e,r)}async unsubscribeResource(e,r){return await this.client.unsubscribeResource(e,r)}async callTool(e,r){return await this.client.callTool(e,Io,r)}async listTools(e,r){return await this.client.listTools(e,r)}async sendRootsListChanged(){return await this.client.sendRootsListChanged()}request(e,r,n){return this.client.request(e,r,n)}async notification(e,r){return await this.client.notification(e,r)}setRequestHandler(e,r){this.client.setRequestHandler(e,r)}removeRequestHandler(e){this.client.removeRequestHandler(e)}setNotificationHandler(e,r){this.client.setNotificationHandler(e,r)}removeNotificationHandler(e){this.client.removeNotificationHandler(e)}onElicit(e){this.client.setRequestHandler(Da,e)}onCreateMessage(e){this.client.setRequestHandler(Dh,e)}onListRoots(e){this.client.setRequestHandler(Fh,e)}onToolListChanged(e){this.client.setNotificationHandler(Lh,e)}onPromptListChanged(e){this.client.setNotificationHandler(qh,e)}onResourceListChanged(e){this.client.setNotificationHandler(Ph,e)}onResourceUpdated(e){this.client.setNotificationHandler(Ch,e)}onLoggingMessage(e){this.client.setNotificationHandler(Zh,e)}async onPagehide(e){e.persisted||(gf(this.transport)?await this.transport.terminateSession():this.transport&&typeof this.transport.close=="function"&&await this.transport.close())}}const n1=(t,e)=>new dc(t,e),s1=(t,e)=>new hc(t,e),o1=(t,e)=>new ba(t,e),i1=t=>t instanceof dc,gf=t=>t instanceof hc,a1=t=>t instanceof ba,c1=t=>t instanceof uf;function u1(t){var e;return t.title!==void 0&&t.title!==""?t.title:!((e=t.annotations)===null||e===void 0)&&e.title?t.annotations.title:t.name}const l1=()=>typeof crypto<"u"&&crypto.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,t=>{const e=Math.random()*16|0;return(t==="x"?e:e&3|8).toString(16)}),Zo=(t,e,r)=>{window.postMessage({type:t,direction:r,data:e},"*")},vf=(t,e,r)=>{const n=async function(s){s.source===window&&s.data.type===t&&s.data.direction===r&&await e(s.data.data)};return window.addEventListener("message",n),()=>window.removeEventListener("message",n)};class d1{constructor(e=null){this._isStarted=!1,this._isClosed=!1,this._lastRegistration=null,this.sessionId=e||l1(),this._messageListener1=vf("sidepanel-ready-to-page",()=>{this._lastRegistration&&this._isStarted&&this.notifyRegistration(this._lastRegistration).catch(r=>{console.error("【Page Svr Transport】 notifyRegistration失败:",r)})},"content->page"),this._messageListener2=vf("mcp-client-to-server-to-page",r=>{if(r.sessionId!==this.sessionId)return;console.log("【Page Svr Transport】 即将处理 mcpMessage",r.mcpMessage);const n=Hr.parse(r.mcpMessage);this.onmessage?.(n),r.mcpMessage.params?.name&&Zo("update-page-app-message",{status:"run",message:r.mcpMessage.params?.name},"page->content")},"content->page")}_throwError(e,r){if(e()){const n=new Error(r);throw console.log(r,n),this.onerror&&this.onerror(n),n}}async start(){if(!this._isStarted){if(this._isClosed)throw new Error("【Page Svr Transport】 已关闭,无法重新启动");this._isStarted=!0}}async send(e,r){this._throwError(()=>!this._isStarted,"【Page Svr Transport】 未启动,无法发送消息"),this._throwError(()=>this._isClosed,"【Page Svr Transport】 已关闭,无法发送消息"),Zo("mcp-server-to-client-from-page",{sessionId:this.sessionId,mcpMessage:e},"page->content"),"result"in e&&e.result?.content&&Zo("update-page-app-message",{status:"ready",message:""},"page->content")}async notifyRegistration(e){this._throwError(()=>!this._isStarted,"【Page Svr Transport】 未启动,无法注册消息"),this._lastRegistration=e;try{Zo("mcp-server-register-from-page",{sessionId:this.sessionId,serverInfo:{...e,url:window.location.origin,title:document.title}},"page->content")}catch(r){this._throwError(()=>!0,"【Page Svr Transport】 注册 server 失败"+String(r))}}async close(){if(!this._isClosed)try{this._messageListener1&&this._messageListener1(),this._messageListener2&&this._messageListener2(),this._isClosed=!0,this._isStarted=!1,this.onclose&&this.onclose()}catch(e){this._throwError(()=>!0,"【Page Svr Transport】 关闭时发生错误"+String(e))}}}Ce.Ajv=zu,Ce.AuthClientProvider=Gb,Ce.ExtensionPageServerTransport=d1,Ce.ResourceTemplate=_S,Ce.UriTemplate=Jt,Ce.WebMcpClient=r1,Ce.WebMcpServer=wS,Ce.completable=uS,Ce.createMessageChannelClientTransport=o1,Ce.createMessageChannelPairTransport=$S,Ce.createMessageChannelServerTransport=bS,Ce.createSSEClientTransport=n1,Ce.createStreamableHTTPClientTransport=s1,Ce.getDisplayName=u1,Ce.isMcpClient=c1,Ce.isMcpServer=kS,Ce.isMessageChannelClientTransport=a1,Ce.isMessageChannelServerTransport=SS,Ce.isSSEClientTransport=i1,Ce.isStreamableHTTPClientTransport=gf,Ce.z=Z0,Object.defineProperty(Ce,Symbol.toStringTag,{value:"Module"})}));
|